1(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[240],{87856:function(e){e.exports=function(){"use strict";var e,i,r;function a(a,n){if(e)if(i){var o="self.onerror = function() { console.error('An error occurred while parsing the WebWorker bundle. This is most likely due to improper transpilation by Babel; please see https://docs.mapbox.com/mapbox-gl-js/guides/install/#transpiling'); }; var sharedChunk = {}; ("+e+")(sharedChunk); ("+i+")(sharedChunk); self.onerror = null;",s={};e(s),r=n(s),"undefined"!=typeof window&&window&&window.URL&&window.URL.createObjectURL&&(r.workerUrl=window.URL.createObjectURL(new Blob([o],{type:"text/javascript"})))}else i=n;else e=n}return a(["exports"],function(e){let i,r,a,n,o,s,l,h,u,c,d,p,f,m,_,g,y,x,v,b,w,T,S,E,I,A,C,M,P,z,R,D,L,O,F,k,B,N,V,U,j,G,q,$,H,Z;var W="undefined"!=typeof Float32Array?Float32Array:Array;function X(e,i){var r=i[0],a=i[1],n=i[2],o=i[3],s=r*o-n*a;return s?(e[0]=o*(s=1/s),e[1]=-a*s,e[2]=-n*s,e[3]=r*s,e):null}function Y(){var e=new W(9);return W!=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 K(e,i){var r=i[0],a=i[1],n=i[2],o=i[3],s=i[4],l=i[5],h=i[6],u=i[7],c=i[8];return e[0]=s*c-l*u,e[1]=n*u-a*c,e[2]=a*l-n*s,e[3]=l*h-o*c,e[4]=r*c-n*h,e[5]=n*o-r*l,e[6]=o*u-s*h,e[7]=a*h-r*u,e[8]=r*s-a*o,e}function J(e,i,r){var a=i[0],n=i[1],o=i[2],s=i[3],l=i[4],h=i[5],u=i[6],c=i[7],d=i[8],p=r[0],f=r[1],m=r[2],_=r[3],g=r[4],y=r[5],x=r[6],v=r[7],b=r[8];return e[0]=p*a+f*s+m*u,e[1]=p*n+f*l+m*c,e[2]=p*o+f*h+m*d,e[3]=_*a+g*s+y*u,e[4]=_*n+g*l+y*c,e[5]=_*o+g*h+y*d,e[6]=x*a+v*s+b*u,e[7]=x*n+v*l+b*c,e[8]=x*o+v*h+b*d,e}function Q(){var e=new W(16);return W!=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 ee(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 et(e,i){var r=i[0],a=i[1],n=i[2],o=i[3],s=i[4],l=i[5],h=i[6],u=i[7],c=i[8],d=i[9],p=i[10],f=i[11],m=i[12],_=i[13],g=i[14],y=i[15],x=r*l-a*s,v=r*h-n*s,b=r*u-o*s,w=a*h-n*l,T=a*u-o*l,S=n*u-o*h,E=c*_-d*m,I=c*g-p*m,A=c*y-f*m,C=d*g-p*_,M=d*y-f*_,P=p*y-f*g,z=x*P-v*M+b*C+w*A-T*I+S*E;return z?(e[0]=(l*P-h*M+u*C)*(z=1/z),e[1]=(n*M-a*P-o*C)*z,e[2]=(_*S-g*T+y*w)*z,e[3]=(p*T-d*S-f*w)*z,e[4]=(h*A-s*P-u*I)*z,e[5]=(r*P-n*A+o*I)*z,e[6]=(g*b-m*S-y*v)*z,e[7]=(c*S-p*b+f*v)*z,e[8]=(s*M-l*A+u*E)*z,e[9]=(a*A-r*M-o*E)*z,e[10]=(m*T-_*b+y*x)*z,e[11]=(d*b-c*T-f*x)*z,e[12]=(l*I-s*C-h*E)*z,e[13]=(r*C-a*I+n*E)*z,e[14]=(_*v-m*w-g*x)*z,e[15]=(c*w-d*v+p*x)*z,e):null}function ei(e,i,r){var a=i[0],n=i[1],o=i[2],s=i[3],l=i[4],h=i[5],u=i[6],c=i[7],d=i[8],p=i[9],f=i[10],m=i[11],_=i[12],g=i[13],y=i[14],x=i[15],v=r[0],b=r[1],w=r[2],T=r[3];return e[0]=v*a+b*l+w*d+T*_,e[1]=v*n+b*h+w*p+T*g,e[2]=v*o+b*u+w*f+T*y,e[3]=v*s+b*c+w*m+T*x,e[4]=(v=r[4])*a+(b=r[5])*l+(w=r[6])*d+(T=r[7])*_,e[5]=v*n+b*h+w*p+T*g,e[6]=v*o+b*u+w*f+T*y,e[7]=v*s+b*c+w*m+T*x,e[8]=(v=r[8])*a+(b=r[9])*l+(w=r[10])*d+(T=r[11])*_,e[9]=v*n+b*h+w*p+T*g,e[10]=v*o+b*u+w*f+T*y,e[11]=v*s+b*c+w*m+T*x,e[12]=(v=r[12])*a+(b=r[13])*l+(w=r[14])*d+(T=r[15])*_,e[13]=v*n+b*h+w*p+T*g,e[14]=v*o+b*u+w*f+T*y,e[15]=v*s+b*c+w*m+T*x,e}function er(e,i,r){var a,n,o,s,l,h,u,c,d,p,f,m,_=r[0],g=r[1],y=r[2];return i===e?(e[12]=i[0]*_+i[4]*g+i[8]*y+i[12],e[13]=i[1]*_+i[5]*g+i[9]*y+i[13],e[14]=i[2]*_+i[6]*g+i[10]*y+i[14],e[15]=i[3]*_+i[7]*g+i[11]*y+i[15]):(n=i[1],o=i[2],s=i[3],l=i[4],h=i[5],u=i[6],c=i[7],d=i[8],p=i[9],f=i[10],m=i[11],e[0]=a=i[0],e[1]=n,e[2]=o,e[3]=s,e[4]=l,e[5]=h,e[6]=u,e[7]=c,e[8]=d,e[9]=p,e[10]=f,e[11]=m,e[12]=a*_+l*g+d*y+i[12],e[13]=n*_+h*g+p*y+i[13],e[14]=o*_+u*g+f*y+i[14],e[15]=s*_+c*g+m*y+i[15]),e}function ea(e,i,r){var a=r[0],n=r[1],o=r[2];return e[0]=i[0]*a,e[1]=i[1]*a,e[2]=i[2]*a,e[3]=i[3]*a,e[4]=i[4]*n,e[5]=i[5]*n,e[6]=i[6]*n,e[7]=i[7]*n,e[8]=i[8]*o,e[9]=i[9]*o,e[10]=i[10]*o,e[11]=i[11]*o,e[12]=i[12],e[13]=i[13],e[14]=i[14],e[15]=i[15],e}function en(e,i,r){var a=Math.sin(r),n=Math.cos(r),o=i[4],s=i[5],l=i[6],h=i[7],u=i[8],c=i[9],d=i[10],p=i[11];return i!==e&&(e[0]=i[0],e[1]=i[1],e[2]=i[2],e[3]=i[3],e[12]=i[12],e[13]=i[13],e[14]=i[14],e[15]=i[15]),e[4]=o*n+u*a,e[5]=s*n+c*a,e[6]=l*n+d*a,e[7]=h*n+p*a,e[8]=u*n-o*a,e[9]=c*n-s*a,e[10]=d*n-l*a,e[11]=p*n-h*a,e}function eo(e,i,r){var a=Math.sin(r),n=Math.cos(r),o=i[0],s=i[1],l=i[2],h=i[3],u=i[8],c=i[9],d=i[10],p=i[11];return i!==e&&(e[4]=i[4],e[5]=i[5],e[6]=i[6],e[7]=i[7],e[12]=i[12],e[13]=i[13],e[14]=i[14],e[15]=i[15]),e[0]=o*n-u*a,e[1]=s*n-c*a,e[2]=l*n-d*a,e[3]=h*n-p*a,e[8]=o*a+u*n,e[9]=s*a+c*n,e[10
vendor: 4,279 bytes, line 1
1]=l*a+d*n,e[11]=h*a+p*n,e}function es(e,i,r){var a=Math.sin(r),n=Math.cos(r),o=i[0],s=i[1],l=i[2],h=i[3],u=i[4],c=i[5],d=i[6],p=i[7];return i!==e&&(e[8]=i[8],e[9]=i[9],e[10]=i[10],e[11]=i[11],e[12]=i[12],e[13]=i[13],e[14]=i[14],e[15]=i[15]),e[0]=o*n+u*a,e[1]=s*n+c*a,e[2]=l*n+d*a,e[3]=h*n+p*a,e[4]=u*n-o*a,e[5]=c*n-s*a,e[6]=d*n-l*a,e[7]=p*n-h*a,e}function el(e,i){return e[0]=i[0],e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[5]=i[1],e[6]=0,e[7]=0,e[8]=0,e[9]=0,e[10]=i[2],e[11]=0,e[12]=0,e[13]=0,e[14]=0,e[15]=1,e}function eh(e,i,r){var a,n,o,s=r[0],l=r[1],h=r[2],u=Math.sqrt(s*s+l*l+h*h);return u<1e-6?null:(s*=u=1/u,l*=u,h*=u,a=Math.sin(i),n=Math.cos(i),e[0]=s*s*(o=1-n)+n,e[1]=l*s*o+h*a,e[2]=h*s*o-l*a,e[3]=0,e[4]=s*l*o-h*a,e[5]=l*l*o+n,e[6]=h*l*o+s*a,e[7]=0,e[8]=s*h*o+l*a,e[9]=l*h*o-s*a,e[10]=h*h*o+n,e[11]=0,e[12]=0,e[13]=0,e[14]=0,e[15]=1,e)}function eu(e,i){var r=i[0],a=i[1],n=i[2],o=i[3],s=r+r,l=a+a,h=n+n,u=r*s,c=a*s,d=a*l,p=n*s,f=n*l,m=n*h,_=o*s,g=o*l,y=o*h;return e[0]=1-d-m,e[1]=c+y,e[2]=p-g,e[3]=0,e[4]=c-y,e[5]=1-u-m,e[6]=f+_,e[7]=0,e[8]=p+g,e[9]=f-_,e[10]=1-u-d,e[11]=0,e[12]=0,e[13]=0,e[14]=0,e[15]=1,e}function ec(){var e=new W(3);return W!=Float32Array&&(e[0]=0,e[1]=0,e[2]=0),e}function ed(e){var i=new W(3);return i[0]=e[0],i[1]=e[1],i[2]=e[2],i}function ep(e){var i=e[0],r=e[1],a=e[2];return Math.sqrt(i*i+r*r+a*a)}function ef(e,i,r){var a=new W(3);return a[0]=e,a[1]=i,a[2]=r,a}function em(e,i,r,a){return e[0]=i,e[1]=r,e[2]=a,e}function e_(e,i,r){return e[0]=i[0]+r[0],e[1]=i[1]+r[1],e[2]=i[2]+r[2],e}function eg(e,i,r){return e[0]=i[0]-r[0],e[1]=i[1]-r[1],e[2]=i[2]-r[2],e}function ey(e,i,r){return e[0]=i[0]*r[0],e[1]=i[1]*r[1],e[2]=i[2]*r[2],e}function ex(e,i,r){return e[0]=Math.min(i[0],r[0]),e[1]=Math.min(i[1],r[1]),e[2]=Math.min(i[2],r[2]),e}function ev(e,i,r){return e[0]=Math.max(i[0],r[0]),e[1]=Math.max(i[1],r[1]),e[2]=Math.max(i[2],r[2]),e}function eb(e,i,r){return e[0]=i[0]*r,e[1]=i[1]*r,e[2]=i[2]*r,e}function ew(e,i,r,a){return e[0]=i[0]+r[0]*a,e[1]=i[1]+r[1]*a,e[2]=i[2]+r[2]*a,e}function eT(e,i){var r=i[0]-e[0],a=i[1]-e[1],n=i[2]-e[2];return r*r+a*a+n*n}function eS(e){var i=e[0],r=e[1],a=e[2];return i*i+r*r+a*a}function eE(e,i){return e[0]=-i[0],e[1]=-i[1],e[2]=-i[2],e}function eI(e,i){var r=i[0],a=i[1],n=i[2],o=r*r+a*a+n*n;return o>0&&(o=1/Math.sqrt(o)),e[0]=i[0]*o,e[1]=i[1]*o,e[2]=i[2]*o,e}function eA(e,i){return e[0]*i[0]+e[1]*i[1]+e[2]*i[2]}function eC(e,i,r){var a=i[0],n=i[1],o=i[2],s=r[0],l=r[1],h=r[2];return e[0]=n*h-o*l,e[1]=o*s-a*h,e[2]=a*l-n*s,e}function eM(e,i,r,a){var n=i[0],o=i[1],s=i[2];return e[0]=n+a*(r[0]-n),e[1]=o+a*(r[1]-o),e[2]=s+a*(r[2]-s),e}function eP(e,i,r){var a=i[0],n=i[1],o=i[2],s=r[3]*a+r[7]*n+r[11]*o+r[15];return e[0]=(r[0]*a+r[4]*n+r[8]*o+r[12])/(s=s||1),e[1]=(r[1]*a+r[5]*n+r[9]*o+r[13])/s,e[2]=(r[2]*a+r[6]*n+r[10]*o+r[14])/s,e}function ez(e,i,r){var a=i[0],n=i[1],o=i[2];return e[0]=a*r[0]+n*r[3]+o*r[6],e[1]=a*r[1]+n*r[4]+o*r[7],e[2]=a*r[2]+n*r[5]+o*r[8],e}function eR(e,i,r){var a=r[0],n=r[1],o=r[2],s=r[3],l=i[0],h=i[1],u=i[2],c=n*u-o*h,d=o*l-a*u,p=a*h-n*l;return e[0]=l+s*(c+=c)+n*(p+=p)-o*(d+=d),e[1]=h+s*d+o*c-a*p,e[2]=u+s*p+a*d-n*c,e}function eD(e){return e[0]=0,e[1]=0,e[2]=0,e}function eL(e,i){return e[0]===i[0]&&e[1]===i[1]&&e[2]===i[2]}function eO(){var e=new W(4);return W!=Float32Array&&(e[0]=0,e[1]=0,e[2]=0,e[3]=0),e}function eF(e,i,r){return e[0]=i[0]*r,e[1]=i[1]*r,e[2]=i[2]*r,e[3]=i[3]*r,e}function ek(e,i){var r=i[0],a=i[1],n=i[2],o=i[3],s=r*r+a*a+n*n+o*o;return s>0&&(s=1/Math.sqrt(s)),e[0]=r*s,e[1]=a*s,e[2]=n*s,e[3]=o*s,e}function eB(e,i,r){var a=i[0],n=i[1],o=i[2],s=i[3];return e[0]=r[0]*a+r[4]*n+r[8]*o+r[12]*s,e[1]=r[1]*a+r[5]*n+r[9]*o+r[13]*s,e[2]=r[2]*a+r[6]*n+r[10]*o+r[14]*s,e[3]=r[3]*a+r[7]*n+r[11]*o+r[15]*s,e}function eN(){var e=new W(4);return W!=Float32Array&&(e[0]=0,e[1]=0,e[2]=0),e[3]=1,e}function eV(e){return e[0]=0,e[1]=0,e[2]=0,e[3]=1,e}function eU(e,i,r){r*=.5;var a=i[0],n=i[1],o=i[2],s=i[3],l=Math.sin(r),h=Math.cos(r);return e[0]=a*h+s*l,e[1]=n*h+o*l,e[2]=o*h-n*l,e[3]=s*h-a*l,e}function ej(e,i,r){r*=.5;var a=i[0],n=i[1],o=i[2],s=i[3],l=Math.sin(r),h=Math.cos(r);return e[0]=a*h-o*l,e[1]=n*h+s*l,e[2]=o*h+a*l,e[3]=s*h-n*l,e}ec(),eO();var eG,eq,e$,eH=(eG=ec(),eq=ef(1,0,0),e$=ef(0,1,0),function(e,i,r){var a,n,o=eA(i,r);return o<-.999999?(eC(eG,eq,i),1e-6>
1ep(eG)&&eC(eG,e$,i),eI(eG,eG),n=Math.sin(a=.5*Math.PI),e[0]=n*eG[0],e[1]=n*eG[1],e[2]=n*eG[2],e[3]=Math.cos(a),e):o>.999999?(e[0]=0,e[1]=0,e[2]=0,e[3]=1,e):(eC(eG,i,r),e[0]=eG[0],e[1]=eG[1],e[2]=eG[2],e[3]=1+o,ek(e,e))});function eZ(){var e=new W(2);return W!=Float32Array&&(e[0]=0,e[1]=0),e}function eW(e,i){var r=new W(2);return r[0]=e,r[1]=i,r}function eX(e,i,r){return e[0]=i[0]+r[0],e[1]=i[1]+r[1],e}function eY(e,i,r){return e[0]=i[0]-r[0],e[1]=i[1]-r[1],e}function eK(e,i,r){return e[0]=i[0]*r,e[1]=i[1]*r,e}function eJ(e){var i=e[0],r=e[1];return Math.sqrt(i*i+r*r)}function eQ(e,i){var r=i[0],a=i[1],n=r*r+a*a;return n>0&&(n=1/Math.sqrt(n)),e[0]=i[0]*n,e[1]=i[1]*n,e}function e0(e,i){return e[0]*i[0]+e[1]*i[1]}function e1(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}eN(),eN(),Y(),eZ();var e2=e1(function(){if(t1)return t0;function e(e,i,r,a){this.cx=3*e,this.bx=3*(r-e)-this.cx,this.ax=1-this.cx-this.bx,this.cy=3*i,this.by=3*(a-i)-this.cy,this.ay=1-this.cy-this.by,this.p1x=e,this.p1y=i,this.p2x=r,this.p2y=a}return t1=1,t0=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,i){if(void 0===i&&(i=1e-6),e<0)return 0;if(e>1)return 1;for(var r=e,a=0;a<8;a++){var n=this.sampleCurveX(r)-e;if(Math.abs(n)<i)return r;var o=this.sampleCurveDerivativeX(r);if(1e-6>Math.abs(o))break;r-=n/o}var s=0,l=1;for(r=e,a=0;a<20&&!(Math.abs((n=this.sampleCurveX(r))-e)<i);a++)e>n?s=r:l=r,r=.5*(l-s)+s;return r},solve:function(e,i){return this.sampleCurveY(this.solveCurveX(e,i))}},t0}());function e3(e,i){this.x=e,this.y=i}function e5(e,i){if(Array.isArray(e)){if(!Array.isArray(i)||e.length!==i.length)return!1;for(let r=0;r<e.length;r++)if(!e5(e[r],i[r]))return!1;return!0}if("object"==typeof e&&null!==e&&null!==i){if("object"!=typeof i||Object.keys(e).length!==Object.keys(i).length)return!1;for(let r in e)if(!e5(e[r],i[r]))return!1;return!0}return e===i}e3.prototype={clone(){return new e3(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,i){return this.clone()._rotateAround(e,i)},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){let i=e.x-this.x,r=e.y-this.y;return i*i+r*r},angle(){return Math.atan2(this.y,this.x)},angleTo(e){return Math.atan2(this.y-e.y,this.x-e.x)},angleWith(e){return this.angleWithSep(e.x,e.y)},angleWithSep(e,i){return Math.atan2(this.x*i-this.y*e,this.x*e+this.y*i)},_matMult(e){let i=e[2]*this.x+e[3]*this.y;return this.x=e[0]*this.x+e[1]*this.y,this.y=i,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(){let e=this.y;return this.y=this.x,this.x=-e,this},_rotate(e){let i=Math.cos(e),r=Math.sin(e),a=r*this.x+i*this.y;return this.x=i*this.x-r*this.y,this.y=a,this},_rotateAround(e,i){let r=Math.cos(e),a=Math.sin(e),n=i.y+a*(this.x-i.x)+r*(this.y-i.y);return this.x=i.x+r*(this.x-i.x)-a*(this.y-i.y),this.y=n,this},_round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this},constructor:e3},e3.convert=function(e){if(e instanceof e3)return e;if(Array.isArray(e))return new e3(+e[0],+e[1]);if(void 0!==e.x&&void 0!==e.y)return new e3(+e.x,+e.y);throw Error("Expected [x, y] or {x, y} point format")};let e4=Math.PI/180,e6=180/Math.PI,e8=[[0,0],[1,0],[1,1],[0,1]];function e9(e){if(e<=0)return 0;if(e>=1)return 1;let i=e*e,r=i*e;return 4*(e<.5?r:3*(e-i)+r-.75)}function e7(e,i,r,a){let n=new e2(e,i,r,a);return function(e){return n.solve(e)}}let te=e7(.25,.1,.25,1);function tt(e,i,r){return Math.min(r,Math.max(i,e))}function ti(e,i,r){return(r=tt((r-e)/(i-e),0,1))*r*(3-2*r)}function tr(e,i,r){let a=r-i,n=((e-i)%a+a)%a+i;return n===i?r:n}function ta(e,i,r){if(!e.length)return r(null,[]);let a=e.length,n=Array(e.length),o=null;e.forEach((e,s)=>{i(e,(e,i)=>{e&&(o=e),n[s]=i,0==--a&&r(o,n)})})}let tn=1;function to(){return tn++}function ts(e){return e<=1?1:Math.pow(2,Math.ceil(Math.log2(e)))}
1function tl(e,i){e.forEach(e=>{i[e]&&(i[e]=i[e].bind(i))})}function th(e,i,r){let a={};for(let r in e)a[r]=i.call(this,e[r],r,e);return a}function tu(e,i,r){let a={};for(let r in e)i.call(this,e[r],r,e)&&(a[r]=e[r]);return a}function tc(e){return Array.isArray(e)?e.map(tc):"object"==typeof e&&e?th(e,tc):e}function td(e,i){for(let r=0;r<e.length;r++)if(i.indexOf(e[r])>=0)return!0;return!1}let tp={};function tf(e){tp[e]||("undefined"!=typeof console&&console.warn(e),tp[e]=!0)}function tm(e,i,r){return(r.y-e.y)*(i.x-e.x)>(i.y-e.y)*(r.x-e.x)}function t_([e,i,r]){let a=(i+90)*e4,n=r*e4;return{x:e*Math.cos(a)*Math.sin(n),y:e*Math.sin(a)*Math.sin(n),z:e*Math.cos(n),azimuthal:i,polar:r}}function tg(e){return("undefined"!=typeof self||void 0!==e)&&"undefined"!=typeof WorkerGlobalScope&&(void 0!==e?e:self)instanceof WorkerGlobalScope}function ty(e){let i={};if(e.replace(/(?:^|(?:\s*\,\s*))([^\x00-\x20\(\)<>@\,;\:\\"\/\[\]\?\=\{\}\x7F]+)(?:\=(?:([^\x00-\x20\(\)<>@\,;\:\\"\/\[\]\?\=\{\}\x7F]+)|(?:\"((?:[^"\\]|\\.)*)\")))?/g,(e,r,a,n)=>{let o=a||n;return i[r]=!o||o.toLowerCase(),""}),i["max-age"]){let e=parseInt(i["max-age"],10);isNaN(e)?delete i["max-age"]:i["max-age"]=e}return i}let tx=null;function tv(e,i){return[e[4*i],e[4*i+1],e[4*i+2],e[4*i+3]]}function tb(e,i,r,a){for(;i<r;){let n=i+r>>1;e[n]<a?i=n+1:r=n}return i}function tw(e,i,r,a){for(;i<r;){let n=i+r>>1;e[n]<=a?i=n+1:r=n}return i}function tT(e){return e>0?1/(1.001-e):1+e}function tS(e){return e>0?1-1/(1.001-e):-e}function tE(e,i,r){return(e-i.min)*(r.max-r.min)/(i.max-i.min)+r.min}let tI={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(!tI.API_URL)return null;try{let e=new URL(tI.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.3.wasm",GLYPHS_URL:"mapbox://fonts/mapbox/{fontstack}/{range}.pbf",TILES3D_URL_PREFIX:"3dtiles/v1"};function tA(e){return tI.API_URL_REGEX.test(e)}function tC(e){return tI.API_SPRITE_REGEX.test(e)}function tM(){return null==i&&(i=self.OffscreenCanvas&&new OffscreenCanvas(1,1).getContext("2d")&&"function"==typeof self.createImageBitmap),i}let tP={now:()=>void 0!==n?n:performance.now(),setNow(e){n=e},restoreNow(){n=void 0},frame(e){let i=requestAnimationFrame(e);return{cancel:()=>cancelAnimationFrame(i)}},getImageData(e,i=0){let{width:r,height:a}=e;o||(o=document.createElement("canvas"));let n=o.getContext("2d",{willReadFrequently:!0});if(!n)throw Error("failed to create canvas 2d context");return(r>o.width||a>o.height)&&(o.width=r,o.height=a),n.clearRect(-i,-i,r+2*i,a+2*i),n.drawImage(e,0,0,r,a),n.getImageData(-i,-i,r+2*i,a+2*i)},resolveURL:e=>(r||(r=document.createElement("a")),r.href=e,r.href),get devicePixelRatio(){return window.devicePixelRatio},get prefersReducedMotion(){return!!window.matchMedia&&(null==a&&(a=window.matchMedia("(prefers-reduced-motion: reduce)")),a.matches)},hasCanvasFingerprintNoise(){if(void 0!==s)return s;if(!tM())return s=!1,!1;let e=new OffscreenCanvas(85,1),i=e.getContext("2d",{willReadFrequently:!0}),r=0;for(let a=0;a<e.width;++a)i.fillStyle=`rgba(${r++},${r++},${r++}, 255)`,i.fillRect(a,0,1,1);let a=i.getImageData(0,0,e.width,e.height);r=0;for(let e=0;e<a.data.length;++e)if(e%4!=3&&r++!==a.data[e])return s=!0,!0;return s=!1,!1}};function tz(e,i){let r=e.indexOf("?");if(r<0)return`${e}?${new URLSearchParams(i).toString()}`;let a=new URLSearchParams(e.slice(r));for(let e in i)a.set(e,i[e]);return`${e.slice(0,r)}?${a.toString()}`}
1function tR(e,i={persistentParams:[]}){let r=e.indexOf("?");if(r<0)return e;let a=new URLSearchParams,n=new URLSearchParams(e.slice(r));for(let e of i.persistentParams){let i=n.get(e);i&&a.set(e,i)}let o=a.toString();return`${e.slice(0,r)}${o.length>0?`?${o}`:""}`}let tD="mapbox-tiles",tL=500,tO=50,tF=["language","worldview","jobid"];function tk(){try{return caches}catch(e){}}function tB(){let e=tk();e&&null==l&&(l=e.open(tD))}let tN=1/0,tV={supported:!1,testSupport:function(e){!tG&&tj&&(tq?tH(e):tU=e)}},tU,tj,tG=!1,tq=!1,t$="undefined"!=typeof self?self:{};function tH(e){let i=e.createTexture();e.bindTexture(e.TEXTURE_2D,i);try{if(e.texImage2D(e.TEXTURE_2D,0,e.RGBA,e.RGBA,e.UNSIGNED_BYTE,tj),e.isContextLost())return;tV.supported=!0}catch(e){}e.deleteTexture(i),tG=!0}t$.document&&((tj=t$.document.createElement("img")).onload=function(){tU&&tH(tU),tU=null,tq=!0},tj.onerror=function(){tG=!0,tU=null},tj.src="data:image/webp;base64,UklGRh4AAABXRUJQVlA4TBEAAAAvAQAAAAfQ//73v/+BiOh/AAA=");let tZ={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(tZ);class tW extends Error{constructor(e,i,r){401===i&&tA(r)&&(e+=": you may have provided an invalid Mapbox access token. See https://docs.mapbox.com/api/overview/#access-tokens-and-token-scopes"),super(e),this.status=i,this.url=r}toString(){return`${this.name}: ${this.message} (${this.status}): ${this.url}`}}let tX=tg()?()=>self.worker.referrer:()=>("blob:"===location.protocol?parent:self).location.href,tY=function(e,i){var r;if(!(/^file:/.test(r=e.url)||/^file:/.test(tX())&&!/^\w+:/.test(r))){if(self.fetch&&self.Request&&self.AbortController&&Request.prototype.hasOwnProperty("signal"))return function(e,i){var r;let a=new AbortController,n=new Request(e.url,{method:e.method||"GET",body:e.body,credentials:e.credentials,headers:e.headers,referrer:tX(),referrerPolicy:e.referrerPolicy,signal:a.signal}),o=!1,s=!1,u=(r=n.url).indexOf("sku=")>0&&tA(r);"json"===e.type&&n.headers.set("Accept","application/json");let c=(r,a,o)=>
1{if(s)return;if(r&&"SecurityError"!==r.message&&tf(r.toString()),a&&o)return d(a);let l=Date.now();fetch(n).then(r=>{if(r.ok){let e=u?r.clone():null;return d(r,e,l)}return i(new tW(r.statusText,r.status,e.url))}).catch(r=>{"AbortError"!==r.name&&i(Error(`${r.message} ${e.url}`))})},d=(r,a,u)=>{("arrayBuffer"===e.type?r.arrayBuffer():"json"===e.type?r.json():r.text()).then(e=>{s||(a&&u&&function(e,i,r){if(tB(),null==l)return;let a=ty(i.headers.get("Cache-Control")||"");if(a["no-store"])return;let n={status:i.status,statusText:i.statusText,headers:new Headers};i.headers.forEach((e,i)=>n.headers.set(i,e)),a["max-age"]&&n.headers.set("Expires",new Date(r+1e3*a["max-age"]).toUTCString());let o=n.headers.get("Expires");if(!o||new Date(o).getTime()-r<42e4)return;let s=tR(e.url,{persistentParams:tF});if(206===i.status){let i=e.headers.get("Range");if(!i)return;n.status=200,s=tz(s,{range:i})}var u=e=>{var r;let a=new Response(200!==(r=i.status)&&404!==r&&[101,103,204,205,304].includes(r)?null:e,n);tB(),null!=l&&l.then(e=>e.put(s,a)).catch(e=>tf(e.message))};if(void 0===h)try{new Response(new ReadableStream),h=!0}catch(e){h=!1}h?u(i.body):i.blob().then(u).catch(e=>tf(e.message))}(n,a,u),o=!0,i(null,e,r.headers.get("Cache-Control"),r.headers.get("Expires")))}).catch(e=>{s||i(Error(e.message))})};return u?function(e,i){if(tB(),null==l)return i(null);l.then(r=>
1{let a=tR(e.url,{persistentParams:tF}),n=e.headers.get("Range");n&&(a=tz(a,{range:n})),r.match(a).then(e=>{let n=function(e){if(!e)return!1;let i=new Date(e.headers.get("Expires")||0),r=ty(e.headers.get("Cache-Control")||"");return Number(i)>Date.now()&&!r["no-cache"]}(e);r.delete(a).catch(i),n&&r.put(a,e.clone()).catch(i),i(null,e,n)}).catch(i)}).catch(i)}(n,c):c(null,null),{cancel:()=>{s=!0,o||a.abort()}}}(e,i);if(tg(self)&&self.worker.actor)return self.worker.actor.send("getResource",e,i,void 0,!0)}let a=new XMLHttpRequest;for(let i in a.open(e.method||"GET",e.url,!0),"arrayBuffer"===e.type&&(a.responseType="arraybuffer"),e.headers)a.setRequestHeader(i,e.headers[i]);return"json"===e.type&&(a.responseType="text",a.setRequestHeader("Accept","application/json")),a.withCredentials="include"===e.credentials,a.onerror=()=>{i(Error(a.statusText))},a.onload=()=>{if((a.status>=200&&a.status<300||0===a.status)&&null!==a.response){let r=a.response;if("json"===e.type)try{r=JSON.parse(a.response)}catch(e){return i(e)}i(null,r,a.getResponseHeader("Cache-Control"),a.getResponseHeader("Expires"))}else i(new tW(a.statusText,a.status,e.url))},a.send(e.body),{cancel:()=>a.abort()}},tK=function(e,i){return tY(Object.assign(e,{type:"arrayBuffer"}),i)},tJ="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAAC0lEQVQYV2NgAAIAAAUAAarVyFEAAAAASUVORK5CYII=";u=[],c=0;let tQ=function(e,i){if(tV.supported&&(e.headers||(e.headers={}),e.headers.accept="image/webp,*/*"),c>=tI.MAX_PARALLEL_IMAGE_REQUESTS){let r={requestParameters:e,callback:i,cancelled:!1,cancel(){this.cancelled=!0}};return u.push(r),r}c++;let r=!1,a=()=>{if(!r)for(r=!0,c--;u.length&&c<tI.MAX_PARALLEL_IMAGE_REQUESTS;){let e=u.shift(),{requestParameters:i,callback:r,cancelled:a}=e;a||(e.cancel=tQ(i,r).cancel)}},n=tK(e,(e,r,n,o)=>{var s;a(),e?i(e):r&&(self.createImageBitmap?(s=(e,r)=>i(e,r,n,o),createImageBitmap(new Blob([new Uint8Array(r)],{type:"image/png"})).then(e=>{s(null,e)}).catch(e=>{s(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.`))})):function(e,i){let r=new Image;r.onload=()=>{i(null,r),URL.revokeObjectURL(r.src),r.onload=null,requestAnimationFrame(()=>{r.src=tJ})},r.onerror=()=>i(Error("Could not load image. Please make sure to use a supported image type such as PNG or JPEG. Note that SVGs are not supported."));let a=new Blob([new Uint8Array(e)],{type:"image/png"});r.src=e.byteLength?URL.createObjectURL(a):tJ}(r,(e,r)=>i(e,r,n,o)))});return{cancel:()=>{n.cancel(),a()}}};var t0,t1,t2,t3,t5,t4={exports:{}},t6={exports:{}},t8={exports:{}},t9=e1(function(){if(t5)return t4.exports;t5=1;var e=(t2||(t2=1,t6.exports=function(e,i){var r,a,n,o,s,l;for(a=e.length-(r=3&e.length),n=i,l=0;l<a;)s=255&e.charCodeAt(l)|(255&e.charCodeAt(++l))<<8|(255&e.charCodeAt(++l))<<16|(255&e.charCodeAt(++l))<<24,++l,n=27492+(65535&(o=5*(65535&(n=(n^=s=(65535&(s=(s=(65535&s)*0xcc9e2d51+(((s>>>16)*0xcc9e2d51&65535)<<16)|0)<<15|s>>>17))*0x1b873593+(((s>>>16)*0x1b873593&65535)<<16)|0)<<13|n>>>19))+((5*(n>>>16)&65535)<<16)|0))+((58964+(o>>>16)&65535)<<16);switch(s=0,r){case 3:s^=(255&e.charCodeAt(l+2))<<16;case 2:s^=(255&e.charCodeAt(l+1))<<8;case 1:n^=s=(65535&(s=(s=(65535&(s^=255&e.charCodeAt(l)))*0xcc9e2d51+(((s>>>16)*0xcc9e2d51&65535)<<16)|0)<<15|s>>>17))*0x1b873593+(((s>>>16)*0x1b873593&65535)<<16)|0}return n^=e.length,n=0x85ebca6b*(65535&(n^=n>>>16))+((0x85ebca6b*(n>>>16)&65535)<<16)|0,n=0xc2b2ae35*(65535&(n^=n>>>13))+((0xc2b2ae35*(n>>>16)&65535)<<16)|0,(n^=n>>>16)>>>0}),t6.exports),i=(t3||(t3=1,t8.exports=function(e,i){for(var r,a=e.length,n=i^a,o=0;a>=4;)r=0x5bd1e995*(65535&(r=255&e.charCodeAt(o)|(255&e.charCodeAt(++o))<<8|(255&e.charCodeAt(++o))<<16|(255&e.charCodeAt(++o))<<24))+((0x5bd1e995*(r>>>16)&65535)<<16),n=0x5bd1e995*(65535&n)+((0x5bd1e995*(n>>>16)&65535)<<16)^(r=0x5bd1e995*(65535&(r^=r>>>24))+((0x5bd1e995*(r>>>16)&65535)<<16)),a-=4,++o;switch(a){case 3:n^=(255&e.charCodeAt(o+2))<<16;case 2:n^=(255&e.charCodeAt(o+1))<<8;case 1:n=0x5bd1e995*(65535&(n^=255&e.charCodeAt(o)))+((0x5bd1e995*(n>>>16)&65535)<<16)}return n=0x5bd1e995*(65535&(n^=n>>>13))+((0x5bd1e995*(n>>>16)&65535)<<16),(n^=n>>>15)>>>0}),t8.exports);return t4.exports=e,t4.exports.murmur3=e,t4.exports.murmur2=i,t4.exports}());class t7{constructor(e,...i){Object.assign(this,i[0]||{}),this.type=e}}class ie extends t7{constructor(e,i={}){super("error",Object.assign({error:e},i))}}function it(e,i,r){r[e]&&-1!==r[e].indexOf(i)||(r[e]=r[e]||[],r[e].push(i))}function ii(e,i,r){if(r&&r[e]){let a=r[e].indexOf(i);-1!==a&&r[e].splice(a,1)}}class ir{on(e,i){return this._listeners=this._listeners||{},it(e,i,this._listeners),this}off(e,i){return ii(e,i,this._listeners),ii(e,i,this._oneTimeListeners),this}
1once(e,i){return i?(this._oneTimeListeners=this._oneTimeListeners||{},it(e,i,this._oneTimeListeners),this):new Promise(i=>{this.once(e,i)})}fire(e,i){let r="string"==typeof e?new t7(e,i):e,a=r.type;if(this.listens(a)){for(let e of(r.target=this,this._listeners&&this._listeners[a]?this._listeners[a].slice():[]))e.call(this,r);for(let e of this._oneTimeListeners&&this._oneTimeListeners[a]?this._oneTimeListeners[a].slice():[])ii(a,e,this._oneTimeListeners),e.call(this,r);let e=this._eventedParent;e&&(Object.assign(r,"function"==typeof this._eventedParentData?this._eventedParentData():this._eventedParentData),e.fire(r))}else r instanceof ie&&console.error(r.error);return this}listens(e){return!!(this._listeners&&this._listeners[e]&&this._listeners[e].length>0||this._oneTimeListeners&&this._oneTimeListeners[e]&&this._oneTimeListeners[e].length>0||this._eventedParent&&this._eventedParent.listens(e))}setEventedParent(e,i){return this._eventedParent=e,this._eventedParentData=i,this}}class ia{constructor(e){"string"==typeof e?this.name=e:(this.name=e.name,this.iconsetId=e.iconsetId)}static from(e){return new ia(e)}static toString(e){return e.iconsetId?`${e.name}�${e.iconsetId}`:e.name}static parse(e){let[i,r]=e.split("\x1f");return new ia({name:i,iconsetId:r})}static isEqual(e,i){return e.name===i.name&&e.iconsetId===i.iconsetId}toString(){return ia.toString(this)}serialize(){return{name:this.name,iconsetId:this.iconsetId}}}var io,is={},il=function(){if(io)return is;io=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 i(e){return(e=Math.round(e))<0?0:e>255?255:e}function r(e){return i("%"===e[e.length-1]?parseFloat(e)/100*255:parseInt(e))}function a(e){var i;return(i="%"===e[e.length-1]?parseFloat(e)/100:parseFloat(e))<0?0:i>1?1:i}function n(e,i,r){return r<0?r+=1:r>1&&(r-=1),6*r<1?e+(i-e)*r*6:2*r<1?i:3*r<2?e+(i-e)*(2/3-r)*6:e}try{is.parseCSSColor=function(o){var s,l=o.replace(/ /g,"").toLowerCase();if(l in e)return e[l].slice();if("#"===l[0])return 4===l.length?(s=parseInt(l.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===l.length&&(s=parseInt(l.substr(1),16))>=0&&s<=0xffffff?[(0xff0000&s)>>16,(65280&s)>>8,255&s,1]:null;var h=l.indexOf("("),u=l.indexOf(")");if(-1!==h&&u+1===l.length){var c=l.substr(0,h),d=l.substr(h+1,u-(h+1)).split(","),p=1;switch(c){case"rgba":if(4!==d.length)break;p=a(d.pop());case"rgb":return 3!==d.length?null:[r(d[0]),r(d[1]),r(d[2]),p];case"hsla":if(4!==d.length)break;p=a(d.pop());case"hsl":if(3!==d.length)break;var f=(parseFloat(d[0])%360+360)%360/360,m=a(d[1]),_=a(d[2]),g=_<=.5?_*(m+1):_+m-_*m,y=2*_-g;return[i(255*n(y,g,f+1/3)),i(255*n(y,g,f)),i(255*n(y,g,f-1/3)),p]}}return null}}catch(e){}return is}();class ih{constructor(e,i,r,a=1){this.r=e,this.g=i,this.b=r,this.a=a}static parse(e){if(!e)return;if(e instanceof ih)return e;if("string"!=typeof e)return;let i=il.parseCSSColor(e);return i?new ih(i[0]/255,i[1]/255,i[2]/255,i[3]):void 0}toString(){let[e,i,r,a]=[this.r,this.g,this.b,this.a];return`rgba(${Math.round(255*e)},${Math.round(255*i)},${Math.round(255*r)},${a})`}toNonPremultipliedRenderColor(e){let{r:i,g:r,b:a,a:n}=this;return new ic(e,i,r,a,n)}toPremultipliedRenderColor(e){let{r:i,g:r,b:a,a:n}=this;return new id(e,i*n,r*n,a*n,n)}clone(){return new ih(this.r,this.g,this.b,this.a)}}class iu{constructor(e,i,r,a,n,o=!1){if(this.premultiplied=!1,this.premultiplied=o,e){let o=e.image.height,s=o*o;this.premultiplied?(i=0===n?0:i/n*(o-1),r=0===n?0:r/n*(o-1),a=0===n?0:a/n*(o-1)):(i*=o-1,r*=o-1,a*=o-1);let l=Math.floor(i),h=Math.floor(r),u=Math.floor(a),c=Math.ceil(i),d=Math.ceil(r),p=Math.ceil(a),f=i-l,m=r-h,_=a-u,g=e.image.data,y=4*(l+h*s+u*o),x=4*(l+h*s+p*o),v=4*(l+d*s+u*o),b=4*(l+d*s+p*o),w=4*(c+h*s+u*o),T=4*(c+h*s+p*o),S=4*(c+d*s+u*o),E=4*(c+d*s+p*o);if(y<0||E>=g.length)throw Error("out of range");
1this.r=ip(ip(ip(g[y],g[x],_),ip(g[v],g[b],_),m),ip(ip(g[w],g[T],_),ip(g[S],g[E],_),m),f)/255*(this.premultiplied?n:1),this.g=ip(ip(ip(g[y+1],g[x+1],_),ip(g[v+1],g[b+1],_),m),ip(ip(g[w+1],g[T+1],_),ip(g[S+1],g[E+1],_),m),f)/255*(this.premultiplied?n:1),this.b=ip(ip(ip(g[y+2],g[x+2],_),ip(g[v+2],g[b+2],_),m),ip(ip(g[w+2],g[T+2],_),ip(g[S+2],g[E+2],_),m),f)/255*(this.premultiplied?n:1),this.a=n}else this.r=i,this.g=r,this.b=a,this.a=n}toArray(){let{r:e,g:i,b:r,a:a}=this;return[255*e,255*i,255*r,a]}toHslaArray(){let e,{r:i,g:r,b:a,a:n}=this;if(this.premultiplied){if(0===n)return[0,0,0,0];let e=1/n;i*=e,r*=e,a*=e}let o=Math.min(Math.max(i,0),1),s=Math.min(Math.max(r,0),1),l=Math.min(Math.max(a,0),1),h=Math.min(o,s,l),u=Math.max(o,s,l),c=u-h,d=.5*(h+u);if(0===c)return[0,0,100*d,n];switch(u){case o:e=60*((s-l)/c+6*(s<l));break;case s:e=60*((l-o)/c+2);break;default:e=60*((o-s)/c+4)}return[e,100*(d>.5?c/(2-u-h):c/(u+h)),100*d,n]}toArray01(){let{r:e,g:i,b:r,a:a}=this;return[e,i,r,a]}toArray01Scaled(e){let{r:i,g:r,b:a}=this;return[i*e,r*e,a*e]}toArray01Linear(){let{r:e,g:i,b:r,a:a}=this;return[Math.pow(e,2.2),Math.pow(i,2.2),Math.pow(r,2.2),a]}}class ic extends iu{constructor(e,i,r,a,n){super(e,i,r,a,n,!1)}}class id extends iu{constructor(e,i,r,a,n){super(e,i,r,a,n,!0)}}function ip(e,i,r){return e*(1-r)+i*r}function im(e,i,r){return e.map((e,a)=>ip(e,i[a],r))}ih.black=new ih(0,0,0,1),ih.white=new ih(1,1,1,1),ih.transparent=new ih(0,0,0,0),ih.red=new ih(1,0,0,1),ih.blue=new ih(0,0,1,1);var i_=Object.freeze({__proto__:null,array:im,color:function(e,i,r){return new ih(ip(e.r,i.r,r),ip(e.g,i.g,r),ip(e.b,i.b,r),ip(e.a,i.a,r))},number:ip});class ig extends Error{constructor(e,i){super(i),this.message=i,this.key=e}}class iy{constructor(e,i=[]){for(let[r,a]of(this.parent=e,this.bindings={},i))this.bindings[r]=a}concat(e){return new iy(this,e)}get(e){if(this.bindings[e])return this.bindings[e];if(this.parent)return this.parent.get(e);throw Error(`${e} not found in scope.`)}has(e){return!!this.bindings[e]||!!this.parent&&this.parent.has(e)}}let ix={kind:"null"},iv={kind:"number"},ib={kind:"string"},iw={kind:"boolean"},iT={kind:"color"},iS={kind:"object"},iE={kind:"value"},iI={kind:"collator"},iA={kind:"formatted"},iC={kind:"resolvedImage"};function iM(e,i){return{kind:"array",itemType:e,N:i}}function iP(e){if("array"===e.kind){let i=iP(e.itemType);return"number"==typeof e.N?`array<${i}, ${e.N}>`:"value"===e.itemType.kind?"array":`array<${i}>`}return e.kind}let iz=[ix,iv,ib,iw,iT,iA,iS,iM(iE),iC];function iR(e,i){if("error"===i.kind)return null;if("array"===e.kind){if("array"===i.kind&&(0===i.N&&"value"===i.itemType.kind||!iR(e.itemType,i.itemType))&&("number"!=typeof e.N||e.N===i.N))return null}else{if(e.kind===i.kind)return null;if("value"===e.kind){for(let e of iz)if(!iR(e,i))return null}}return`Expected ${iP(e)} but found ${iP(i)} instead.`}function iD(e,i){return i.some(i=>i.kind===e.kind)}function iL(e,i){return i.some(i=>"null"===i?null===e:"array"===i?Array.isArray(e):"object"===i?e&&!Array.isArray(e)&&"object"==typeof e:i===typeof e)}function iO(e,i){return"array"===e.kind&&"array"===i.kind?e.N===i.N&&iO(e.itemType,i.itemType):e.kind===i.kind}class iF{constructor(e,i,r){this.sensitivity=e?i?"variant":"case":i?"accent":"base",this.locale=r,this.collator=new Intl.Collator(this.locale?this.locale:[],{sensitivity:this.sensitivity,usage:"search"})}compare(e,i){return this.collator.compare(e,i)}resolvedLocale(){return new Intl.Collator(this.locale?this.locale:[]).resolvedOptions().locale}}class ik{constructor(e,i,r,a,n){this.text=e.normalize?e.normalize():e,this.image=i,this.scale=r,this.fontStack=a,this.textColor=n}}class iB{constructor(e){this.sections=e}static fromString(e){return new iB([new ik(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 iB?e:iB.fromString(e)}toString(){return 0===this.sections.length?"":this.sections.map(e=>e.text).join("")}serialize(){let e=["format"];for(let i of this.sections){if(i.image){let r=i.image.getPrimary().id.toString();e.push(["image",r]);continue}e.push(i.text);let r={};i.fontStack&&(r["text-font"]=["literal",i.fontStack.split(",")]),i.scale&&(r["font-scale"]=i.scale),i.textColor&&(r["text-color"]=["rgba"].concat(i.textColor.toNonPremultipliedRenderColor(null).toArray())),e.push(r)}return e}}class iN{constructor(e,i={}){if(this.id=ia.from(e),this.options=Object.assign({},i),i.transform){let{a:e,b:r,c:a,d:n,e:o,f:s}=i.transform;this.options.transform=new DOMMatrix([e,r,a,n,o,s])}else this.options.transform=new DOMMatrix([1,0,0,1,0,0])}toString(){let{a:e,b:i,c:r,d:a,e:n,f:o}=this.options.transform;return JSON.stringify({name:this.id.name,iconsetId:this.id.iconsetId,params:this.options.params,transform:{a:e,b:i,c:r,d:a,e:n,f:o}})}static parse(e){let i,r,a,n;try{({name:i,iconsetId:r,params:a,transform:n}=JSON.parse(e)||{})}catch(e){return null}if(!i)return null;let{a:o,b:s,c:l,d:h,e:u,f:c}=n||{};return new iN({name:i,iconsetId:r},{params:a,transform:new DOMMatrix([o,s,l,h,u,c])})}scaleSelf(e,i){return this.options.transform.scaleSelf(e,i),this}}class iV{constructor(e,i,r,a,n=!1){this.primaryId=ia.from(e),this.primaryOptions=i,r&&(this.secondaryId=ia.from(r)),this.secondaryOptions=a,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 iN(this.primaryId,this.primaryOptions)}hasSecondary(){return!!this.secondaryId}getSecondary(){return this.secondaryId?new iN(this.secondaryId,this.secondaryOptions):null}static from(e){return"string"==typeof e?iV.build({name:e}):e}static build(e,i,r,a){return e&&("object"!=typeof e||"name"in e)?new iV(e,r,i,a):null}}function iU(e,i,r,a){return"number"==typeof e&&e>=0&&e<=255&&"number"==typeof i&&i>=0&&i<=255&&"number"==typeof r&&r>=0&&r<=255?void 0===a||"number"==typeof a&&a>=0&&a<=1?null:`Invalid rgba value [${[e,i,r,a].join(", ")}]: 'a' must be between 0 and 1.`:`Invalid rgba value [${("number"==typeof a?[e,i,r,a]:[e,i,r]).join(", ")}]: 'r', 'g', and 'b' must be between 0 and 255.`}function ij(e){if(null===e||"string"==typeof e||"boolean"==typeof e||"number"==typeof e||e instanceof ih||e instanceof iF||e instanceof iB||e instanceof iV)return!0;
1if(Array.isArray(e)){for(let i of e)if(!ij(i))return!1;return!0}if("object"==typeof e){for(let i in e)if(!ij(e[i]))return!1;return!0}return!1}function iG(e){if(null===e)return ix;if("string"==typeof e)return ib;if("boolean"==typeof e)return iw;if("number"==typeof e)return iv;if(e instanceof ih)return iT;if(e instanceof iF)return iI;if(e instanceof iB)return iA;if(e instanceof iV)return iC;if(Array.isArray(e)){let i,r=e.length;for(let r of e){let e=iG(r);if(i){if(i===e)continue;i=iE;break}i=e}return iM(i||iE,r)}return iS}function iq(e){let i=typeof e;return null===e?"":"string"===i||"number"===i||"boolean"===i?String(e):e instanceof iB||e instanceof iV||e instanceof ih?e.toString():JSON.stringify(e)}class i${constructor(e,i){this.type=e,this.value=i}static parse(e,i){if(2!==e.length)return i.error(`'literal' expression requires exactly one argument, but found ${e.length-1} instead.`);if(!ij(e[1]))return i.error("invalid value");let r=e[1],a=iG(r),n=i.expectedType;return"array"===a.kind&&0===a.N&&n&&"array"===n.kind&&("number"!=typeof n.N||0===n.N)&&(a=n),new i$(a,r)}evaluate(){return this.value}eachChild(){}outputDefined(){return!0}serialize(){return"array"===this.type.kind||"object"===this.type.kind?["literal",this.value]:this.value instanceof ih?["rgba"].concat(this.value.toNonPremultipliedRenderColor(null).toArray()):this.value instanceof iB?this.value.serialize():this.value}}class iH{constructor(e){this.name="ExpressionEvaluationError",this.message=e}toJSON(){return this.message}}let iZ={string:ib,number:iv,boolean:iw,object:iS};class iW{constructor(e,i){this.type=e,this.args=i}static parse(e,i){if(e.length<2)return i.error("Expected at least one argument.");let r,a=1,n=e[0];if("array"===n){let n,o;if(e.length>2){let r=e[1];if("string"!=typeof r||!(r in iZ)||"object"===r)return i.error('The item type argument of "array" must be one of string, number, boolean',1);n=iZ[r],a++}else n=iE;if(e.length>3){if(null!==e[2]&&("number"!=typeof e[2]||e[2]<0||e[2]!==Math.floor(e[2])))return i.error('The length argument to "array" must be a positive integer literal',2);o=e[2],a++}r=iM(n,o)}else r=iZ[n];let o=[];for(;a<e.length;a++){let r=i.parse(e[a],a,iE);if(!r)return null;o.push(r)}return new iW(r,o)}evaluate(e){for(let i=0;i<this.args.length;i++){let r=this.args[i].evaluate(e);if(!iR(this.type,iG(r)))return r;if(i===this.args.length-1)throw new iH(`The expression ${JSON.stringify(this.args[i].serialize())} evaluated to ${iP(iG(r))} but was expected to be of type ${iP(this.type)}.`)}return null}eachChild(e){this.args.forEach(e)}outputDefined(){return this.args.every(e=>e.outputDefined())}serialize(){let e=this.type,i=[e.kind];if("array"===e.kind){let r=e.itemType;if("string"===r.kind||"number"===r.kind||"boolean"===r.kind){i.push(r.kind);let a=e.N;("number"==typeof a||this.args.length>1)&&i.push(a)}}return i.concat(this.args.map(e=>e.serialize()))}}class iX{constructor(e){this.type=iA,this.sections=e}static parse(e,i){if(e.length<2)return i.error("Expected at least one argument.");let r=e[1];if(!Array.isArray(r)&&"object"==typeof r)return i.error("First argument must be an image or text section.");let a=[],n=!1;for(let r=1;r<=e.length-1;++r){let o=e[r];if(n&&"object"==typeof o&&!Array.isArray(o)){n=!1;let e=null;if(o["font-scale"]&&!(e=i.parseObjectValue(o["font-scale"],r,"font-scale",iv)))return null;let s=null;if(o["text-font"]&&!(s=i.parseObjectValue(o["text-font"],r,"text-font",iM(ib))))return null;let l=null;if(o["text-color"]&&!(l=i.parseObjectValue(o["text-color"],r,"text-color",iT)))return null;let h=a[a.length-1];h.scale=e,h.font=s,h.textColor=l}else{let o=i.parse(e[r],r,iE);if(!o)return null;let s=o.type.kind;if("string"!==s&&"value"!==s&&"null"!==s&&"resolvedImage"!==s)return i.error("Formatted text type must be 'string', 'value', 'image' or 'null'.");n=!0,a.push({content:o,scale:null,font:null,textColor:null})}}return new iX(a)}evaluate(e){return new iB(this.sections.map(i=>{let r=i.content.evaluate(e);return iO(iG(r),iC)?new ik("",r,null,null,null):new ik(iq(r),null,i.scale?i.scale.evaluate(e):null,i.font?i.font.evaluate(e).join(","):null,i.textColor?i.textColor.evaluate(e):null)}))}eachChild(e){for(let i of this.sections)e(i.content),i.scale&&e(i.scale),i.font&&e(i.font),i.textColor&&e(i.textColor)}outputDefined(){return!1}serialize(){let e=["format"];for(let i of this.sections){e.push(i.content.serialize());let r={};i.scale&&(r["font-scale"]=i.scale.serialize()),i.font&&(r["text-font"]=i.font.serialize()),i.textColor&&(r["text-color"]=i.textColor.serialize()),e.push(r)}return e}}class iY{constructor(e,i,r,a){this._imageWarnHistory={},this.type=iC,this.namePrimary=e,this.nameSecondary=i,r&&(this.paramsPrimary=r.params,this.iconsetIdPrimary=r.iconset?r.iconset.id:void 0),a&&(this.paramsSecondary=a.params,this.iconsetIdSecondary=a.iconset?a.iconset.id:void 0)}static parse(e,i){if(e.length<2)return i.error("Expected two or more arguments.");let r=1,a=[];for(let n=0;n<2;n++)if(!function(){if(r<e.length){let n=i.parse(e[r],r++,ib);return n?(a.push({image:n,options:{}}),!0):(i.error(a.length?"Secondary image variant is not a string.":"No image name provided."),!1)}return!0}()||!function(){if(r<e.length){let n=e[r];if(null===n||"object"!=typeof n||Array.isArray(n))return!0;let o=n.params,s=n.iconset,l=i.concat(r);if(!o&&!s)return r++,!0;if(o){if("object"!=typeof o||o.constructor!==Object)return l.error('Image options "params" should be an object'),!1;let e={},i=l.concat(void 0,"params");
1for(let r in o){if(!r)return i.error("Image parameter name should be non-empty"),!1;let a=i.concat(void 0,r).parse(o[r],void 0,iT,void 0,{typeAnnotation:"coerce"});if(!a)return!1;e[r]=a}a[a.length-1].options.params=e}if(s){if("object"!=typeof s||s.constructor!==Object)return l.error('Image options "iconset" should be an object'),!1;if(!s.id)return l.error('Image options "iconset" should have an "id" property'),!1;a[a.length-1].options.iconset=s}return r++,!0}return!0}())return;return new iY(a[0].image,a[1]?a[1].image:void 0,a[0].options,a[1]?a[1].options:void 0)}evaluateParams(e,i){let r={};if(i){for(let a in i)if(i[a])try{r[a]=i[a].evaluate(e)}catch(e){continue}if(0!==Object.keys(r).length)return{params:r}}}evaluate(e){let i={name:this.namePrimary.evaluate(e),iconsetId:this.iconsetIdPrimary},r=this.nameSecondary?{name:this.nameSecondary.evaluate(e),iconsetId:this.iconsetIdSecondary}:void 0,a=iV.build(i,r,this.paramsPrimary?this.evaluateParams(e,this.paramsPrimary):void 0,this.paramsSecondary?this.evaluateParams(e,this.paramsSecondary):void 0);if(a&&e.availableImages){let i=a.getPrimary().id;if(a.available=e.availableImages.some(e=>ia.isEqual(e,i)),a.available){let i=a.getSecondary()?a.getSecondary().id:null;i&&(a.available=e.availableImages.some(e=>ia.isEqual(e,i)))}}return a}eachChild(e){if(e(this.namePrimary),this.paramsPrimary)for(let i in this.paramsPrimary)this.paramsPrimary[i]&&e(this.paramsPrimary[i]);if(this.nameSecondary&&(e(this.nameSecondary),this.paramsSecondary))for(let i in this.paramsSecondary)this.paramsSecondary[i]&&e(this.paramsSecondary[i])}outputDefined(){return!1}serializeOptions(e,i){let r={};if(i&&(r.iconset={id:i}),e)for(let i in r.params={},e)e[i]&&(r.params[i]=e[i].serialize());return Object.keys(r).length>0?r:void 0}serialize(){let e=["image",this.namePrimary.serialize()];if(this.paramsPrimary||this.iconsetIdPrimary){let i=this.serializeOptions(this.paramsPrimary,this.iconsetIdPrimary);i&&e.push(i)}if(this.nameSecondary&&(e.push(this.nameSecondary.serialize()),this.paramsSecondary||this.iconsetIdSecondary)){let i=this.serializeOptions(this.paramsSecondary,this.iconsetIdSecondary);i&&e.push(i)}return e}}function iK(e){return iQ(e)?"string":i0(e)?"number":i1(e)?"boolean":Array.isArray(e)?"array":null===e?"null":iJ(e)?"object":typeof e}function iJ(e){return null!=e&&!Array.isArray(e)&&"function"!=typeof e&&!(e instanceof String||e instanceof Number||e instanceof Boolean)&&"object"==typeof e}function iQ(e){return"string"==typeof e||e instanceof String}function i0(e){return"number"==typeof e||e instanceof Number}function i1(e){return"boolean"==typeof e||e instanceof Boolean}let i2={"to-boolean":iw,"to-color":iT,"to-number":iv,"to-string":ib};class i3{constructor(e,i){this.type=e,this.args=i}static parse(e,i){if(e.length<2)return i.error("Expected at least one argument.");let r=e[0],a=[],n=ix;if("to-array"===r){if(!Array.isArray(e[1]))return null;let r=e[1].length;if(i.expectedType){if("array"!==i.expectedType.kind)return i.error(`Expected ${i.expectedType.kind} but found array.`);n=iM(i.expectedType.itemType,r)}else{if(!(r>0&&ij(e[1][0])))return null;n=iM(iG(e[1][0]),r)}for(let o=0;o<r;o++){let r,s=e[1][o];if(Array.isArray(s))r=i.parse(s,void 0,n.itemType);else{let e=iK(s);if(e!==n.itemType.kind)return i.error(`Expected ${n.itemType.kind} but found ${e}.`);r=i.registry.literal.parse(["literal",void 0===s?null:s],i)}if(!r)return null;a.push(r)}}else{if(("to-boolean"===r||"to-string"===r)&&2!==e.length)return i.error("Expected one argument.");n=i2[r];for(let r=1;r<e.length;r++){let n=i.parse(e[r],r,iE);if(!n)return null;a.push(n)}}return new i3(n,a)}evaluate(e){if("boolean"===this.type.kind)return!!this.args[0].evaluate(e);if("color"===this.type.kind){let i,r;for(let a of this.args){if(i=a.evaluate(e),r=null,i instanceof ih)return i;if("string"==typeof i){let r=e.parseColor(i);if(r)return r}else if(Array.isArray(i)&&!(r=i.length<3||i.length>4?`Invalid rbga value ${JSON.stringify(i)}: expected an array containing either three or four numeric values.`:iU(i[0],i[1],i[2],i[3])))return new ih(i[0]/255,i[1]/255,i[2]/255,i[3])}throw new iH(r||`Could not parse color from value '${"string"==typeof i?i:String(JSON.stringify(i))}'`)}if("number"===this.type.kind){let i=null;for(let r of this.args){if(null===(i=r.evaluate(e)))return 0;let a=Number(i);if(!isNaN(a))return a}throw new iH(`Could not convert ${JSON.stringify(i)} to number.`)}return"formatted"===this.type.kind?iB.fromString(iq(this.args[0].evaluate(e))):"resolvedImage"===this.type.kind?iV.build(iq(this.args[0].evaluate(e))):"array"===this.type.kind?this.args.map(i=>i.evaluate(e)):iq(this.args[0].evaluate(e))}
1eachChild(e){this.args.forEach(e)}outputDefined(){return this.args.every(e=>e.outputDefined())}serialize(){if("formatted"===this.type.kind)return new iX([{content:this.args[0],scale:null,font:null,textColor:null}]).serialize();if("resolvedImage"===this.type.kind)return new iY(this.args[0]).serialize();let e="array"===this.type.kind?[]:[`to-${this.type.kind}`];return this.eachChild(i=>{e.push(i.serialize())}),e}}let i5=["Unknown","Point","LineString","Polygon"];class i4{constructor(e,i,r){this.globals=null,this.feature=null,this.featureState=null,this.formattedSection=null,this._parseColorCache={},this.availableImages=null,this.canonical=null,this.featureTileCoord=null,this.featureDistanceData=null,this.scope=e,this.options=i,this.iconImageUseTheme=r}id(){return this.feature&&void 0!==this.feature.id?this.feature.id:null}geometryType(){return this.feature?"number"==typeof this.feature.type?i5[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){let e=this.featureDistanceData.center,i=this.featureDistanceData.scale,{x:r,y:a}=this.featureTileCoord;return this.featureDistanceData.bearing[0]*(r*i-e[0])+this.featureDistanceData.bearing[1]*(a*i-e[1])}return 0}parseColor(e){let i=this._parseColorCache[e];return i||(i=this._parseColorCache[e]=ih.parse(e)),i}getConfig(e){return this.options?this.options.get(e):null}}class i6{constructor(e,i,r,a,n){this.name=e,this.type=i,this._evaluate=r,this.args=a,this._overloadIndex=n}evaluate(e){if(!this._evaluate){let e=i6.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,i){let r=e[0],a=i6.definitions[r];if(!a)return i.error(`Unknown expression "${r}". If you wanted a literal array, use ["literal", [...]].`,0);let n=Array.isArray(a)?a[0]:a.type,o=Array.isArray(a)?[[a[1],a[2]]]:a.overloads,s=[],l=null,h=-1;for(let[a,u]of o){if(Array.isArray(a)&&a.length!==e.length-1)continue;s.push(a),h++,l=new rX(i.registry,i.path,null,i.scope,void 0,i._scope,i.options,i.iconImageUseTheme);let o=[],c=!1;for(let i=1;i<e.length;i++){let r=e[i],n=Array.isArray(a)?a[i-1]:a.type,s=l.parse(r,1+o.length,n);if(!s){c=!0;break}o.push(s)}if(!c)if(Array.isArray(a)&&a.length!==o.length)l.error(`Expected ${a.length} arguments, but found ${o.length} instead.`);else{for(let e=0;e<o.length;e++){let i=Array.isArray(a)?a[e]:a.type,r=o[e];l.concat(e+1).checkSubtype(i,r.type)}if(0===l.errors.length)return new i6(r,n,u,o,h)}}if(1===s.length)i.errors.push(...l.errors);else{let r=(s.length?s:o.map(([e])=>e)).map(i8).join(" | "),a=[];for(let r=1;r<e.length;r++){let n=i.parse(e[r],1+a.length);if(!n)return null;a.push(iP(n.type))}i.error(`Expected arguments of type ${r}, but found (${a.join(", ")}) instead.`)}return null}static register(e,i){for(let r in i6.definitions=i,i)e[r]=i6}}function i8(e){return Array.isArray(e)?`(${e.map(iP).join(", ")})`:`(${iP(e.type)}...)`}class i9{constructor(e,i,r){this.type=iI,this.locale=r,this.caseSensitive=e,this.diacriticSensitive=i}static parse(e,i){if(2!==e.length)return i.error("Expected one argument.");let r=e[1];if("object"!=typeof r||Array.isArray(r))return i.error("Collator options argument must be an object.");let a=void 0===r["case-sensitive"]?i.parse(!1,1,iw):i.parseObjectValue(r["case-sensitive"],1,"case-sensitive",iw);if(!a)return null;let n=void 0===r["diacritic-sensitive"]?i.parse(!1,1,iw):i.parseObjectValue(r["diacritic-sensitive"],1,"diacritic-sensitive",iw);if(!n)return null;let o=null;return!r.locale||(o=i.parseObjectValue(r.locale,1,"locale",ib))?new i9(a,n,o):null}evaluate(e){return new iF(this.caseSensitive.evaluate(e),this.diacriticSensitive.evaluate(e),this.locale?this.locale.evaluate(e):null)}eachChild(e){e(this.caseSensitive),e(this.diacriticSensitive),this.locale&&e(this.locale)}outputDefined(){return!1}serialize(){let e={};return e["case-sensitive"]=this.caseSensitive.serialize(),e["diacritic-sensitive"]=this.diacriticSensitive.serialize(),this.locale&&(e.locale=this.locale.serialize()),["collator",e]}}function i7(e,i,r){let a=e[i];e[i]=e[r],e[r]=a}function re(e,i){e[0]=Math.min(e[0],i[0]),e[1]=Math.min(e[1],i[1]),e[2]=Math.max(e[2],i[0]),e[3]=Math.max(e[3],i[1])}function rt(e,i){return!(e[0]<=i[0]||e[2]>=i[2]||e[1]<=i[1]||e[3]>=i[3])}function ri(e,i,r=!1){let a=!1;for(let n=0,o=i.length;n<o;n++){let o=i[n];for(let i=0,n=o.length,s=n-1;i<n;s=i++){let n=o[s],l=o[i];if(function(e,i,r){let a=e[0]-i[0],n=e[1]-i[1],o=e[0]-r[0],s=e[1]-r[1];return a*s-o*n==0&&a*o<=0&&n*s<=0}(e,n,l))return r;n[1]>e[1]!=l[1]>e[1]&&e[0]<(l[0]-n[0])*(e[1]-n[1])/(l[1]-n[1])+n[0]&&(a=!a)}}return a}function rr(e,i,r,a){let n=a[0]-r[0],o=a[1]-r[1],s=(e[0]-r[0])*o-n*(e[1]-r[1]),l=(i[0]-r[0])*o-n*(i[1]-r[1]);return s>0&&l<0||s<0&&l>0}function ra(e,i,r,a){var n,o;return 0!=(n=[a[0]-r[0],a[1]-r[1]])[0]*(o=[i[0]-e[0],i[1]-e[1]])[1]-n[1]*o[0]&&!(!rr(e,i,r,a)||
1!rr(r,a,e,i))}function rn(e){let i=new e3(1/0,1/0),r=new e3(-1/0,-1/0);for(let a of e[0])i.x>a.x&&(i.x=a.x),i.y>a.y&&(i.y=a.y),r.x<a.x&&(r.x=a.x),r.y<a.y&&(r.y=a.y);return{min:i,max:r}}function ro(e,i){for(let r=0;r<e.length;++r)if(!ri(e[r],i))return!1;for(let r=0;r<e.length-1;++r)if(function(e,i,r){for(let a of r)for(let r=0,n=a.length,o=n-1;r<n;o=r++)if(ra(e,i,a[o],a[r]))return!0;return!1}(e[r],e[r+1],i))return!1;return!0}function rs(e,i,r){let a=[];for(let n=0;n<e.length;n++){let o=[];for(let a=0;a<e[n].length;a++){let s=function(e,i){let r=(180+e[0])/360,a=(180-180/Math.PI*Math.log(Math.tan(Math.PI/4+e[1]*Math.PI/360)))/360,n=Math.pow(2,i.z);return[Math.round(r*n*8192),Math.round(a*n*8192)]}(e[n][a],r);re(i,s),o.push(s)}a.push(o)}return a}function rl(e,i,r){let a=[];for(let n=0;n<e.length;n++){let o=rs(e[n],i,r);a.push(o)}return a}function rh(e,i,r,a){if(e[0]<r[0]||e[0]>r[2]){let i=.5*a,n=e[0]-r[0]>i?-a:r[0]-e[0]>i?a:0;0===n&&(n=e[0]-r[2]>i?-a:r[2]-e[0]>i?a:0),e[0]+=n}re(i,e)}function ru(e,i,r,a){let n=8192*Math.pow(2,a.z),o=[8192*a.x,8192*a.y],s=[];if(!e)return s;for(let a of e)for(let e of a){let a=[e.x+o[0],e.y+o[1]];rh(a,i,r,n),s.push(a)}return s}function rc(e,i,r,a){let n=8192*Math.pow(2,a.z),o=[8192*a.x,8192*a.y],s=[];if(!e)return s;for(let r of e){let e=[];for(let a of r){let r=[a.x+o[0],a.y+o[1]];re(i,r),e.push(r)}s.push(e)}if(i[2]-i[0]<=n/2)for(let e of(i[0]=i[1]=1/0,i[2]=i[3]=-1/0,s))for(let a of e)rh(a,i,r,n);return s}class rd{constructor(e,i){this.type=iw,this.geojson=e,this.geometries=i}static parse(e,i){if(2!==e.length)return i.error(`'within' expression requires exactly one argument, but found ${e.length-1} instead.`);if(ij(e[1])){let i=e[1];if("FeatureCollection"===i.type)for(let e=0;e<i.features.length;++e){let r=i.features[e].geometry.type;if("Polygon"===r||"MultiPolygon"===r)return new rd(i,i.features[e].geometry)}else if("Feature"===i.type){let e=i.geometry.type;if("Polygon"===e||"MultiPolygon"===e)return new rd(i,i.geometry)}else if("Polygon"===i.type||"MultiPolygon"===i.type)return new rd(i,i)}return i.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,i){let r=[1/0,1/0,-1/0,-1/0],a=[1/0,1/0,-1/0,-1/0],n=e.canonicalID();if(!n)return!1;if("Polygon"===i.type){let o=rs(i.coordinates,a,n),s=ru(e.geometry(),r,a,n);if(!rt(r,a))return!1;for(let e of s)if(!ri(e,o))return!1}if("MultiPolygon"===i.type){let o=rl(i.coordinates,a,n),s=ru(e.geometry(),r,a,n);if(!rt(r,a))return!1;for(let e of s)if(!function(e,i){for(let r=0;r<i.length;r++)if(ri(e,i[r]))return!0;return!1}(e,o))return!1}return!0}(e,this.geometries);if("LineString"===e.geometryType())return function(e,i){let r=[1/0,1/0,-1/0,-1/0],a=[1/0,1/0,-1/0,-1/0],n=e.canonicalID();if(!n)return!1;if("Polygon"===i.type){let o=rs(i.coordinates,a,n),s=rc(e.geometry(),r,a,n);if(!rt(r,a))return!1;for(let e of s)if(!ro(e,o))return!1}if("MultiPolygon"===i.type){let o=rl(i.coordinates,a,n),s=rc(e.geometry(),r,a,n);if(!rt(r,a))return!1;for(let e of s)if(!function(e,i){for(let r=0;r<i.length;r++)if(ro(e,i[r]))return!0;return!1}(e,o))return!1}return!0}(e,this.geometries)}return!1}eachChild(){}outputDefined(){return!0}serialize(){return["within",this.geojson]}}let rp={kilometers:1,miles:1e3/1609.344,nauticalmiles:1e3/1852,meters:1e3,metres:1e3,yards:1e3/.9144,feet:1e3/.3048,inches:1e3/.0254},rf=1/298.257223563*(2-1/298.257223563),rm=Math.PI/180;class r_{static fromTile(e,i,r){let a=Math.PI*(1-2*(e+.5)/Math.pow(2,i));return new r_(Math.atan(.5*(Math.exp(a)-Math.exp(-a)))/rm,r)}static get units(){return rp}constructor(e,i){if(void 0===e)throw Error("No latitude given.");if(i&&!rp[i])throw Error(`Unknown unit ${i}. Use one of: ${Object.keys(rp).join(", ")}`);let r=6378.137*rm*(i?rp[i]:1),a=Math.cos(e*rm),n=1/(1-rf*(1-a*a)),o=Math.sqrt(n);this.kx=r*o*a,this.ky=r*o*n*(1-rf)}distance(e,i){let r=rx(e[0]-i[0])*this.kx,a=(e[1]-i[1])*this.ky;return Math.sqrt(r*r+a*a)}bearing(e,i){return Math.atan2(rx(i[0]-e[0])*this.kx,(i[1]-e[1])*this.ky)/rm}destination(e,i,r){let a=r*rm;return this.offset(e,Math.sin(a)*i,Math.cos(a)*i)}offset(e,i,r){return[e[0]+i/this.kx,e[1]+r/this.ky]}lineDistance(e){let i=0;for(let r=0;r<e.length-1;r++)i+=this.distance(e[r],e[r+1]);return i}area(e){let i=0;for(let r=0;r<e.length;r++){let a=e[r];for(let e=0,n=a.length,o=n-1;e<n;o=e++)i+=rx(a[e][0]-a[o][0])*(a[e][1]+a[o][1])*(r?-1:1)}return Math.abs(i)/2*this.kx*this.ky}along(e,i){let r=0;if(i<=0)return e[0];for(let a=0;a<e.length-1;a++){let n=e[a],o=e[a+1],s=this.distance(n,o);if((r+=s)>i)return ry(n,o,(i-(r-s))/s)}return e[e.length-1]}pointToSegmentDistance(e,i,r){let[a,n]=i,o=rx(r[0]-a)*this.kx,s=(r[1]-n)*this.ky;if(0!==o||0!==s){let i=(rx(e[0]-a)*this.kx*o+(e[1]-n)*this.ky*s)/(o*o+s*s);i>1?(a=r[0],n=r[1]):i>0&&(a+=o/this.kx*i,n+=s/this.ky*i)}return Math.sqrt((o=rx(e[0]-a)*this.kx)*o+(s=(e[1]-n)*this.ky)*s)}pointOnLine(e,i){let r=1/0,a=e[0][0],n=e[0][1],o=0,s=0;for(let l=0;l<e.length-1;l++){let h=e[l][0],u=e[l][1],c=rx(e[l+1][0]-h)*this.kx,d=(e[l+1][1]-u)*this.ky,p=0;0===c&&0===d||((p=(rx(i[0]-h)*this.kx*c+(i[1]-u)*this.ky*d)/(c*c+d*d))>1?(h=e[l+1][0],u=e[l+1][1]):p>0&&(h+=c/this.kx*p,u+=d/this.ky*p));let f=(c=rx(i[0]-h)*this.kx)*c+(d=(i[1]-u)*this.ky)*d;f<r&&(r=f,a=h,n=u,o=l,s=p)}return{point:[a,n],index:o,t:Math.max(0,Math.min(1,s))}}lineSlice(e,i,r){let a=this.pointOnLine(r,e),n=this.pointOnLine(r,i);if(a.index>n.index||a.index===n.index&&a.t>n.t){let e=a;a=n,n=e}let o=[a.point],s=a.index+1,l=n.index;!rg(r[s],o[0])&&s<=l&&o.push(r[s]);for(let e=s+1;e<=l;e++)o.push(r[e]);return rg(r[l],n.point)||o.push(n.point),o}lineSliceAlong(e,i,r){let a=0,n=[];for(let o=0;o<r.length-1;o++){let s=r[o],l=r[o+1],h=this.distance(s,l);if((a+=h)>e&&0===n.length&&n.push(ry(s,l,(e-(a-h))/h)),a>=i)return n.push(ry(s,l,(i-(a-h))/h)),n;a>e&&n.push(l)}return n}bufferPoint(e,i){let r=i/this.ky,a=i/this.kx;return[e[0]-a,e[1]-r,e[0]+a,e[1]+r]}bufferBBox(e,i){let r=i/this.ky,a=i/this.kx;return[e[0]-a,e[1]-r,e[2]+a,e[3]+r]}insideBBox(e,i){return rx(e[0]-i[0])>=0&&0>=rx(e[0]-i[2])&&e[1]>=i[1]&&e[1]<=i[3]}}
1function rg(e,i){return e[0]===i[0]&&e[1]===i[1]}function ry(e,i,r){let a=rx(i[0]-e[0]);return[e[0]+a*r,e[1]+(i[1]-e[1])*r]}function rx(e){for(;e<-180;)e+=360;for(;e>180;)e-=360;return e}class rv{constructor(e=[],i=(e,i)=>e<i?-1:+(e>i)){if(this.data=e,this.length=this.data.length,this.compare=i,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;let e=this.data[0],i=this.data.pop();return--this.length>0&&(this.data[0]=i,this._down(0)),e}peek(){return this.data[0]}_up(e){let{data:i,compare:r}=this,a=i[e];for(;e>0;){let n=e-1>>1,o=i[n];if(r(a,o)>=0)break;i[e]=o,e=n}i[e]=a}_down(e){let{data:i,compare:r}=this,a=this.length>>1,n=i[e];for(;e<a;){let a=1+(e<<1),o=a+1;if(o<this.length&&0>r(i[o],i[a])&&(a=o),r(i[a],n)>=0)break;i[e]=i[a],e=a}i[e]=n}}function rb(e,i){return i.dist-e.dist}function rw(e){let i=[1/0,1/0,-1/0,-1/0];if(i.length!==e.length)return!1;for(let r=0;r<i.length;r++)if(i[r]!==e[r])return!1;return!0}function rT(e){return e[1]-e[0]+1}function rS(e,i){let r=e[1]>=e[0]&&e[1]<i;return r||console.warn("Distance Expression: Index is out of range"),r}function rE(e,i){if(e[0]>e[1])return[null,null];let r=rT(e);if(i){if(2===r)return[e,null];let i=Math.floor(r/2);return[[e[0],e[0]+i],[e[0]+i,e[1]]]}{if(1===r)return[e,null];let i=Math.floor(r/2)-1;return[[e[0],e[0]+i],[e[0]+i+1,e[1]]]}}function rI(e,i){let r=[1/0,1/0,-1/0,-1/0];if(!rS(i,e.length))return r;for(let a=i[0];a<=i[1];++a)re(r,e[a]);return r}function rA(e){let i=[1/0,1/0,-1/0,-1/0];for(let r=0;r<e.length;++r)for(let a=0;a<e[r].length;++a)re(i,e[r][a]);return i}function rC(e,i,r){if(rw(e)||rw(i))return NaN;let a=0,n=0;return e[2]<i[0]&&(a=i[0]-e[2]),e[0]>i[2]&&(a=e[0]-i[2]),e[1]>i[3]&&(n=e[1]-i[3]),e[3]<i[1]&&(n=i[1]-e[3]),r.distance([0,0],[a,n])}function rM(e,i){let r=Math.pow(2,i.z),a=(e.y/8192+i.y)/r;return[360*((e.x/8192+i.x)/r)-180,360/Math.PI*Math.atan(Math.exp((180-360*a)*Math.PI/180))-90]}function rP(e,i,r){let a=r.pointOnLine(i,e).point;return r.distance(e,a)}function rz(e,i,r,a,n){let o=r.slice(a[0],a[1]+1),s=1/0;for(let r=i[0];r<=i[1];++r)if(0===(s=Math.min(s,rP(e[r],o,n))))return 0;return s}function rR(e,i,r,a,n){return Math.min(Math.min(n.pointToSegmentDistance(e,r,a),n.pointToSegmentDistance(i,r,a)),Math.min(n.pointToSegmentDistance(r,e,i),n.pointToSegmentDistance(a,e,i)))}function rD(e,i){for(let r of e)for(let e=0;e<=r.length-1;++e)if(ri(r[e],i,!0))return!0;return!1}function rL(e,i,r,a,n,o,s){if(null===o||null===s)return;let l=rC(rI(a,o),rI(n,s),r);l<i&&e.push({dist:l,range1:o,range2:s})}function rO(e,i,r,a,n,o=1/0){let s=Math.min(o,n.distance(e[0],r[0]));if(0===s)return s;let l=new rv([{dist:0,range1:[0,e.length-1],range2:[0,r.length-1]}],rb),h=i?50:100,u=a?50:100;for(;l.length;){let o=l.pop();if(o.dist>=s)continue;let c=o.range1,d=o.range2;if(rT(c)<=h&&rT(d)<=u){if(!rS(c,e.length)||!rS(d,r.length))return NaN;if(i&&a?s=Math.min(s,function(e,i,r,a,n){if(!rS(i,e.length)||!rS(a,r.length))return NaN;let o=1/0;for(let s=i[0];s<i[1];++s)for(let i=a[0];i<a[1];++i){if(ra(e[s],e[s+1],r[i],r[i+1]))return 0;o=Math.min(o,rR(e[s],e[s+1],r[i],r[i+1],n))}return o}(e,c,r,d,n)):i||a?i&&!a?s=Math.min(s,rz(r,d,e,c,n)):!i&&a&&(s=Math.min(s,rz(e,c,r,d,n))):s=Math.min(s,function(e,i,r,a,n){if(!rS(i,e.length)||!rS(a,r.length))return NaN;let o=1/0;for(let s=i[0];s<=i[1];++s)for(let i=a[0];i<=a[1];++i)if(0===(o=Math.min(o,n.distance(e[s],r[i]))))return o;return o}(e,c,r,d,n)),0===s)break}else{let o=rE(c,i),h=rE(d,a);
1rL(l,s,n,e,r,o[0],h[0]),rL(l,s,n,e,r,o[0],h[1]),rL(l,s,n,e,r,o[1],h[0]),rL(l,s,n,e,r,o[1],h[1])}}return s}function rF(e,i,r,a,n=1/0){let o=n,s=rI(e,[0,e.length-1]);for(let n of r)if(!(o!==1/0&&rC(s,rI(n,[0,n.length-1]),a)>=o)&&0===(o=Math.min(o,rO(e,i,n,!0,a,o))))break;return o}function rk(e,i,r,a,n=1/0){let o=n,s=rI(e,[0,e.length-1]);for(let n of r){if(o!==1/0&&rC(s,rA(n),a)>=o)continue;let r=function(e,i,r,a,n=1/0){let o=Math.min(a.distance(e[0],r[0][0]),n);if(0===o)return o;let s=new rv([{dist:0,range1:[0,e.length-1],range2:[0,0]}],rb),l=i?50:100,h=rA(r);for(;s.length;){let n=s.pop();if(n.dist>=o)continue;let u=n.range1;if(rT(u)<=l){if(!rS(u,e.length))return NaN;if(i){if(0===(o=Math.min(o,function(e,i,r,a){if(!rS(i,e.length))return NaN;for(let a=i[0];a<=i[1];++a)if(ri(e[a],r,!0))return 0;let n=1/0;for(let o=i[0];o<i[1];++o)for(let i of r)for(let r=0,s=i.length,l=s-1;r<s;l=r++){if(ra(e[o],e[o+1],i[l],i[r]))return 0;n=Math.min(n,rR(e[o],e[o+1],i[l],i[r],a))}return n}(e,u,r,a))))break}else for(let i=u[0];i<=u[1];++i)if(0===(o=Math.min(o,function(e,i,r){if(ri(e,i,!0))return 0;let a=1/0;for(let n of i){let i=n.length;if(i<2)return console.warn("Distance Expression: Invalid polygon!"),NaN;if(n[0]!==n[i-1]&&0===(a=Math.min(a,r.pointToSegmentDistance(e,n[i-1],n[0])))||0===(a=Math.min(a,rP(e,n,r))))break}return a}(e[i],r,a))))return o}else{let r=rE(u,i);if(null!==r[0]){let i=rC(rI(e,r[0]),h,a);i<o&&s.push({dist:i,range1:r[0],range2:[0,0]})}if(null!==r[1]){let i=rC(rI(e,r[1]),h,a);i<o&&s.push({dist:i,range1:r[1],range2:[0,0]})}}}return o}(e,i,n,a,o);if(isNaN(r))return r;if(0===(o=Math.min(o,r)))break}return o}function rB(e){return"Point"===e||"MultiPoint"===e||"LineString"===e||"MultiLineString"===e||"Polygon"===e||"MultiPolygon"===e}class rN{constructor(e,i){this.type=iv,this.geojson=e,this.geometries=i}static parse(e,i){if(2!==e.length)return i.error(`'distance' expression requires either one argument, but found ' ${e.length-1} instead.`);if(ij(e[1])){let i=e[1];if("FeatureCollection"===i.type){for(let e=0;e<i.features.length;++e)if(rB(i.features[e].geometry.type))return new rN(i,i.features[e].geometry)}else if("Feature"===i.type){if(rB(i.geometry.type))return new rN(i,i.geometry)}else if(rB(i.type))return new rN(i,i)}return i.error("'distance' expression needs to be an array with format ['Distance', GeoJSONObj].")}evaluate(e){let i=e.geometry(),r=e.canonicalID();if(null!=i&&null!=r){if("Point"===e.geometryType()){var a=this.geometries;let e=[];for(let a of i)for(let i of a)e.push(rM(i,r));let n=new r_(e[0][1],"meters");return"Point"===a.type||"MultiPoint"===a.type||"LineString"===a.type?rO(e,!1,"Point"===a.type?[a.coordinates]:a.coordinates,"LineString"===a.type,n):"MultiLineString"===a.type?rF(e,!1,a.coordinates,n):"Polygon"===a.type||"MultiPolygon"===a.type?rk(e,!1,"Polygon"===a.type?[a.coordinates]:a.coordinates,n):null}if("LineString"===e.geometryType())return function(e,i,r){let a=[];for(let r of e){let e=[];for(let a of r)e.push(rM(a,i));a.push(e)}let n=new r_(a[0][0][1],"meters");if("Point"===r.type||"MultiPoint"===r.type||"LineString"===r.type)return rF("Point"===r.type?[r.coordinates]:r.coordinates,"LineString"===r.type,a,n);if("MultiLineString"===r.type){let e=1/0;for(let i=0;i<r.coordinates.length;i++){let o=rF(r.coordinates[i],!0,a,n,e);if(isNaN(o))return o;if(0===(e=Math.min(e,o)))break}return e}if("Polygon"===r.type||"MultiPolygon"===r.type){let e=1/0;for(let i=0;i<a.length;i++){let o=rk(a[i],!0,"Polygon"===r.type?[r.coordinates]:r.coordinates,n,e);if(isNaN(o))return o;if(0===(e=Math.min(e,o)))break}return e}return null}(i,r,this.geometries);if("Polygon"===e.geometryType())return function(e,i,r){let a=[];for(let r of function(e,i){let r,a,n=e.length;if(n<=1)return[e];let o=[];for(let i=0;i<n;i++){let n=function(e){let i=0;for(let r,a,n=0,o=e.length,s=o-1;n<o;s=n++)r=e[n],i+=((a=e[s]).x-r.x)*(r.y+a.y);return i}(e[i]);0!==n&&(e[i].area=Math.abs(n),void 0===a&&(a=n<0),a===n<0?(r&&o.push(r),r=[e[i]]):r.push(e[i]))}return r&&o.push(r),o}(e)){let e=[];for(let a=0;a<r.length;++a)e.push(function(e,i){let r=[];for(let a=0;a<e.length;++a)r.push(rM(e[a],i));return r}(r[a],i));a.push(e)}
1let n=new r_(a[0][0][0][1],"meters");if("Point"===r.type||"MultiPoint"===r.type||"LineString"===r.type)return rk("Point"===r.type?[r.coordinates]:r.coordinates,"LineString"===r.type,a,n);if("MultiLineString"===r.type){let e=1/0;for(let i=0;i<r.coordinates.length;i++){let o=rk(r.coordinates[i],!0,a,n,e);if(isNaN(o))return o;if(0===(e=Math.min(e,o)))break}return e}return"Polygon"===r.type||"MultiPolygon"===r.type?function(e,i,r){let a=1/0;for(let n of e)for(let e of i){let i=function(e,i,r,a=1/0){let n=rA(e),o=rA(i);if(a!==1/0&&rC(n,o,r)>=a)return a;if(rt(n,o)){if(rD(e,i))return 0}else if(rD(i,e))return 0;let s=a;for(let a of e)for(let e=0,n=a.length,o=n-1;e<n;o=e++)for(let n of i)for(let i=0,l=n.length,h=l-1;i<l;h=i++){if(ra(a[o],a[e],n[h],n[i]))return 0;s=Math.min(s,rR(a[o],a[e],n[h],n[i],r))}return s}(n,e,r,a);if(isNaN(i))return i;if(0===(a=Math.min(a,i)))return a}return a}("Polygon"===r.type?[r.coordinates]:r.coordinates,a,n):null}(i,r,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 rV(e){if(e instanceof i6&&("get"===e.name&&1===e.args.length||"feature-state"===e.name||"has"===e.name&&1===e.args.length||"properties"===e.name||"geometry-type"===e.name||"id"===e.name||/^filter-/.test(e.name))||e instanceof rd||e instanceof rN)return!1;if(e instanceof rZ)return e.featureConstant;let i=!0;return e.eachChild(e=>{i&&!rV(e)&&(i=!1)}),i}function rU(e){if(e instanceof i6&&"feature-state"===e.name)return!1;let i=!0;return e.eachChild(e=>{i&&!rU(e)&&(i=!1)}),i}function rj(e){if(e instanceof rZ)return new Set([e.key]);let i=new Set;return e.eachChild(e=>{i=new Set([...i,...rj(e)])}),i}function rG(e,i){if(e instanceof i6&&i.indexOf(e.name)>=0)return!1;let r=!0;return e.eachChild(e=>{r&&!rG(e,i)&&(r=!1)}),r}function rq(e,i,r){return[e,i,r].filter(Boolean).join("\x1f")}function r$(e,i){switch(e){case"string":return iq(i);case"number":return+i;case"boolean":return!!i;case"color":return ih.parse(i);case"formatted":return iB.fromString(iq(i));case"resolvedImage":return iV.build(iq(i))}return i}function rH(e,i,r,a){return void 0!==a&&(e=a*Math.round(e/a)),void 0!==i&&e<i&&(e=i),void 0!==r&&e>r&&(e=r),e}class rZ{constructor(e,i,r,a=!1){this.type=e,this.key=i,this.scope=r,this.featureConstant=a}static parse(e,i){let r=i.expectedType;if(null==r&&(r=iE),e.length<2||e.length>3)return i.error("Invalid number of arguments for 'config' expression.");let a=i.parse(e[1],1);if(!(a instanceof i$))return i.error("Key name of 'config' expression must be a string literal.");let n,o=!0,s=iq(a.value);if(e.length>=3){let r=i.parse(e[2],2);if(!(r instanceof i$))return i.error("Scope of 'config' expression must be a string literal.");n=iq(r.value)}if(i.options){let e=rq(s,n,i._scope),r=i.options.get(e);r&&(o=rV(r.value||r.default))}return new rZ(r,s,n,o)}evaluate(e){let i=rq(this.key,this.scope,e.scope),r=e.getConfig(i);if(!r)return null;let{type:a,value:n,values:o,minValue:s,maxValue:l,stepValue:h}=r,u=r.default.evaluate(e),c=u;if(n){let i=e.scope;e.scope=(i||"").split("\x1f").slice(1).join("\x1f"),c=n.evaluate(e),e.scope=i}return a&&(c=r$(a,c)),void 0===c||void 0===s&&void 0===l&&void 0===h||("number"==typeof c?c=rH(c,s,l,h):Array.isArray(c)&&(c=c.map(e=>"number"==typeof e?rH(e,s,l,h):e))),void 0!==n&&void 0!==c&&o&&!o.includes(c)&&(c=u,a&&(c=r$(a,c))),(a&&a!==this.type||void 0!==c&&!iO(iG(c),this.type))&&(c=r$(this.type.kind,c)),c}eachChild(){}outputDefined(){return!1}serialize(){let e=["config",this.key];return this.scope&&e.concat(this.scope),e}}class rW{constructor(e,i){this.type=i.type,this.name=e,this.boundExpression=i}static parse(e,i){if(2!==e.length||"string"!=typeof e[1])return i.error("'var' expression requires exactly one string literal argument.");let r=e[1];return i.scope.has(r)?new rW(r,i.scope.get(r)):i.error(`Unknown variable "${r}". Make sure "${r}" has been bound in an enclosing "let" expression before using it.`,1)}evaluate(e){return this.boundExpression.evaluate(e)}eachChild(){}outputDefined(){return!1}serialize(){return["var",this.name]}}class rX{constructor(e,i=[],r,a=new iy,n=[],o,s,l){this.registry=e,this.path=i,this.key=i.map(e=>"string"==typeof e?`['${e}']`:`[${e}]`).join(""),this.scope=a,this.errors=n,this.expectedType=r,this._scope=o,this.options=s,this.iconImageUseTheme=l}parse(e,i,r,a,n={}){return i||r?this.concat(i,null,r,a)._parse(e,n):this._parse(e,n)}parseObjectValue(e,i,r,a,n,o={}){return this.concat(i,r,a,n)._parse(e,o)}_parse(e,i){function r(e,i,r){return"assert"===r?new iW(i,[e]):"coerce"===r?new i3(i,[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", []].');let a="string"==typeof e[0]?this.registry[e[0]]:void 0;if(a){let n=a.parse(e,this);if(!n)return null;if(this.expectedType){let e=this.expectedType,a=n.type;if("string"!==e.kind&&"number"!==e.kind&&"boolean"!==e.kind&&"object"!==e.kind&&"array"!==e.kind||"value"!==a.kind)if("color"!==e.kind&&"formatted"!==e.kind&&"resolvedImage"!==e.kind||"value"!==a.kind&&"string"!==a.kind){if(this.checkSubtype(e,a))return null}else n=r(n,e,i.typeAnnotation||"coerce");else n=r(n,e,i.typeAnnotation||"assert")}if(!(n instanceof i$)&&"resolvedImage"!==n.type.kind&&function e(i){if(i instanceof rW)return e(i.boundExpression);if(i instanceof i6&&"error"===i.name||i instanceof i9||i instanceof rd||i instanceof rN||i instanceof rZ)return!1;let r=i instanceof i3||i instanceof iW,a=!0;return i.eachChild(i=>{a=r?a&&e(i):a&&i instanceof i$}),!!a&&rV(i)&&rG(i,["zoom","heatmap-density","worldview","line-progress","raster-value","sky-radial-progress","accumulated","is-supported-script","pitch","distance-from-center","measure-light","raster-particle-speed"])}(n)){let e=new i4(this._scope,this.options,this.iconImageUseTheme);try{n=new i$(n.type,n.evaluate(e))}catch(e){return this.error(e.message),null}}return n}return i3.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,i,r,a){let n="number"==typeof e?this.path.concat(e):this.path;n="string"==typeof i?n.concat(i):n;let o=a?this.scope.concat(a):this.scope;return new rX(this.registry,n,r||null,o,this.errors,this._scope,this.options,this.iconImageUseTheme)}error(e,...i){let r=`${this.key}${i.map(e=>`[${e}]`).join("")}`;this.errors.push(new ig(r,e))}checkSubtype(e,i){let r=iR(e,i);return r&&this.error(r),r}}function rY(e,i){let r=e.length-1,a,n,o=0,s=r,l=0;for(;o<=s;)if(a=e[l=Math.floor((o+s)/2)],n=e[l+1],a<=i){if(l===r||i<n)return l;o=l+1}else{if(!(a>i))throw new iH("Input is not a number.");s=l-1}return 0}
1class rK{constructor(e,i,r){for(let[a,n]of(this.type=e,this.input=i,this.labels=[],this.outputs=[],r))this.labels.push(a),this.outputs.push(n)}static parse(e,i){if(e.length-1<4)return i.error(`Expected at least 4 arguments, but found only ${e.length-1}.`);if((e.length-1)%2!=0)return i.error("Expected an even number of arguments.");let r=i.parse(e[1],1,iv);if(!r)return null;let a=[],n=null;i.expectedType&&"value"!==i.expectedType.kind&&(n=i.expectedType);for(let r=1;r<e.length;r+=2){let o=1===r?-1/0:e[r],s=e[r+1],l=r,h=r+1;if("number"!=typeof o)return i.error('Input/output pairs for "step" expressions must be defined using literal numeric values (not computed expressions) for the input values.',l);if(a.length&&a[a.length-1][0]>=o)return i.error('Input/output pairs for "step" expressions must be arranged with input values in strictly ascending order.',l);let u=i.parse(s,h,n);if(!u)return null;n=n||u.type,a.push([o,u])}return new rK(n,r,a)}evaluate(e){let i=this.labels,r=this.outputs;if(1===i.length)return r[0].evaluate(e);let a=this.input.evaluate(e);if(a<=i[0])return r[0].evaluate(e);let n=i.length;return a>=i[n-1]?r[n-1].evaluate(e):r[rY(i,a)].evaluate(e)}eachChild(e){for(let i of(e(this.input),this.outputs))e(i)}outputDefined(){return this.outputs.every(e=>e.outputDefined())}serialize(){let e=["step",this.input.serialize()];for(let i=0;i<this.labels.length;i++)i>0&&e.push(this.labels[i]),e.push(this.outputs[i].serialize());return e}}let rJ=4/29,rQ=6/29,r0=6/29*3*(6/29),r1=6/29*(6/29)*(6/29),r2=Math.PI/180,r3=180/Math.PI;function r5(e){return e>r1?Math.pow(e,1/3):e/r0+rJ}function r4(e){return e>rQ?e*e*e:r0*(e-rJ)}function r6(e){return 255*(e<=.0031308?12.92*e:1.055*Math.pow(e,1/2.4)-.055)}function r8(e){return(e/=255)<=.04045?e/12.92:Math.pow((e+.055)/1.055,2.4)}function r9(e){let i=r8(e.r),r=r8(e.g),a=r8(e.b),n=r5((.4124564*i+.3575761*r+.1804375*a)/.95047),o=r5((.2126729*i+.7151522*r+.072175*a)/1);return{l:116*o-16,a:500*(n-o),b:200*(o-r5((.0193339*i+.119192*r+.9503041*a)/1.08883)),alpha:e.a}}function r7(e){let i=(e.l+16)/116,r=isNaN(e.a)?i:i+e.a/500,a=isNaN(e.b)?i:i-e.b/200;return i=+r4(i),new ih(r6(3.2404542*(r=.95047*r4(r))-1.5371385*i-.4985314*(a=1.08883*r4(a))),r6(-.969266*r+1.8760108*i+.041556*a),r6(.0556434*r-.2040259*i+1.0572252*a),e.alpha)}let ae={forward:r9,reverse:r7,interpolate:function(e,i,r){return{l:ip(e.l,i.l,r),a:ip(e.a,i.a,r),b:ip(e.b,i.b,r),alpha:ip(e.alpha,i.alpha,r)}}},at={forward:function(e){let{l:i,a:r,b:a}=r9(e),n=Math.atan2(a,r)*r3;return{h:n<0?n+360:n,c:Math.sqrt(r*r+a*a),l:i,alpha:e.a}},reverse:function(e){let i=e.h*r2,r=e.c;return r7({l:e.l,a:Math.cos(i)*r,b:Math.sin(i)*r,alpha:e.alpha})},interpolate:function(e,i,r){return{h:function(e,i,r){let a=i-e;return e+r*(a>180||a<-180?a-360*Math.round(a/360):a)}(e.h,i.h,r),c:ip(e.c,i.c,r),l:ip(e.l,i.l,r),alpha:ip(e.alpha,i.alpha,r)}}};var ai=Object.freeze({__proto__:null,hcl:at,lab:ae});class ar{constructor(e,i,r,a,n){for(let[o,s]of(this.type=e,this.operator=i,this.interpolation=r,this.input=a,this.labels=[],this.outputs=[],n))this.labels.push(o),this.outputs.push(s)}static interpolationFactor(e,i,r,a){let n=0;if("exponential"===e.name)n=aa(i,e.base,r,a);else if("linear"===e.name)n=aa(i,1,r,a);else if("cubic-bezier"===e.name){let o=e.controlPoints;n=new e2(o[0],o[1],o[2],o[3]).solve(aa(i,1,r,a))}return n}static parse(e,i){let[r,a,n,...o]=e;if(!Array.isArray(a)||0===a.length)return i.error("Expected an interpolation type expression.",1);if("linear"===a[0])a={name:"linear"};else if("exponential"===a[0]){let e=a[1];if("number"!=typeof e)return i.error("Exponential interpolation requires a numeric base.",1,1);a={name:"exponential",base:e}}else{if("cubic-bezier"!==a[0])return i.error(`Unknown interpolation type ${String(a[0])}`,1,0);{let e=a.slice(1);if(4!==e.length||e.some(e=>"number"!=typeof e||e<0||e>1))return i.error("Cubic bezier interpolation requires four numeric arguments with values between 0 and 1.",1);a={name:"cubic-bezier",controlPoints:e}}}if(e.length-1<4)return i.error(`Expected at least 4 arguments, but found only ${e.length-1}.`);if(e.length-1>3&&(e.length-1)%2!=0)return i.error("Expected an even number of arguments.");if(!(n=i.parse(n,2,iv)))return null;let s=[],l=null;
1"interpolate-hcl"===r||"interpolate-lab"===r?l=iT:i.expectedType&&"value"!==i.expectedType.kind&&(l=i.expectedType);for(let e=0;e<o.length;e+=2){let r=o[e],a=o[e+1],n=e+3,h=e+4;if("number"!=typeof r)return i.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]>=r)return i.error('Input/output pairs for "interpolate" expressions must be arranged with input values in strictly ascending order.',n);let u=i.parse(a,h,l);if(!u)return null;l=l||u.type,s.push([r,u])}return"number"===l.kind||"color"===l.kind||"array"===l.kind&&"number"===l.itemType.kind&&"number"==typeof l.N?new ar(l,r,a,n,s):i.error(`Type ${iP(l)} is not interpolatable.`)}evaluate(e){let i=this.labels,r=this.outputs;if(1===i.length)return r[0].evaluate(e);let a=this.input.evaluate(e);if(a<=i[0])return r[0].evaluate(e);let n=i.length;if(a>=i[n-1])return r[n-1].evaluate(e);let o=rY(i,a),s=ar.interpolationFactor(this.interpolation,a,i[o],i[o+1]),l=r[o].evaluate(e),h=r[o+1].evaluate(e);return"interpolate"===this.operator?i_[this.type.kind.toLowerCase()](l,h,s):"interpolate-hcl"===this.operator?at.reverse(at.interpolate(at.forward(l),at.forward(h),s)):ae.reverse(ae.interpolate(ae.forward(l),ae.forward(h),s))}eachChild(e){for(let i of(e(this.input),this.outputs))e(i)}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];let i=[this.operator,e,this.input.serialize()];for(let e=0;e<this.labels.length;e++)i.push(this.labels[e],this.outputs[e].serialize());return i}}function aa(e,i,r,a){let n=a-r,o=e-r;return 0===n?0:1===i?o/n:(Math.pow(i,o)-1)/(Math.pow(i,n)-1)}class an{constructor(e,i){this.type=e,this.args=i}static parse(e,i){if(e.length<2)return i.error("Expectected at least one argument.");let r=null,a=i.expectedType;a&&"value"!==a.kind&&(r=a);let n=[];for(let a of e.slice(1)){let e=i.parse(a,1+n.length,r,void 0,{typeAnnotation:"omit"});if(!e)return null;r=r||e.type,n.push(e)}return new an(a&&n.some(e=>iR(a,e.type))?iE:r,n)}evaluate(e){let i,r=null,a=0;for(let n of this.args){if(a++,(r=n.evaluate(e))&&r instanceof iV&&!r.available&&(i||(i=r),r=null,a===this.args.length))return i;if(null!==r)break}return r}eachChild(e){this.args.forEach(e)}outputDefined(){return this.args.every(e=>e.outputDefined())}serialize(){let e=["coalesce"];return this.eachChild(i=>{e.push(i.serialize())}),e}}class ao{constructor(e,i){this.type=i.type,this.bindings=[].concat(e),this.result=i}evaluate(e){return this.result.evaluate(e)}eachChild(e){for(let i of this.bindings)e(i[1]);e(this.result)}static parse(e,i){if(e.length<4)return i.error(`Expected at least 3 arguments, but found ${e.length-1} instead.`);let r=[];for(let a=1;a<e.length-1;a+=2){let n=e[a];if("string"!=typeof n)return i.error(`Expected string, but found ${typeof n} instead.`,a);if(/[^a-zA-Z0-9_]/.test(n))return i.error("Variable names must contain only alphanumeric characters or '_'.",a);let o=i.parse(e[a+1],a+1);if(!o)return null;r.push([n,o])}let a=i.parse(e[e.length-1],e.length-1,i.expectedType,r);return a?new ao(r,a):null}outputDefined(){return this.result.outputDefined()}serialize(){let e=["let"];for(let[i,r]of this.bindings)e.push(i,r.serialize());return e.push(this.result.serialize()),e}}class as{constructor(e,i,r){this.type=e,this.index=i,this.input=r}static parse(e,i){if(3!==e.length)return i.error(`Expected 2 arguments, but found ${e.length-1} instead.`);let r=i.parse(e[1],1,iv),a=i.parse(e[2],2,iM(i.expectedType||iE));return r&&a?new as(a.type.itemType,r,a):null}evaluate(e){let i=this.index.evaluate(e),r=this.input.evaluate(e);if(i<0)throw new iH("Array index out of bounds: negative index");if(i>=r.length)throw new iH("Array index out of bounds: index exceeds array size");if(i!==Math.floor(i))throw new iH("Array index must be an integer. Use at-interpolated for fractional indices");return r[i]}eachChild(e){e(this.index),e(this.input)}outputDefined(){return!1}serialize(){return["at",this.index.serialize(),this.input.serialize()]}}class al{constructor(e,i,r){this.type=e,this.index=i,this.input=r}static parse(e,i){if(3!==e.length)return i.error(`Expected 2 arguments, but found ${e.length-1} instead.`);let r=i.parse(e[1],1,iv),a=i.parse(e[2],2,iM(i.expectedType||iE));return r&&a?new al(a.type.itemType,r,a):null}evaluate(e){let i=this.index.evaluate(e),r=this.input.evaluate(e);if(i<0)throw new iH(`Array index out of bounds: ${i} < 0.`);if(i>r.length-1)throw new iH(`Array index out of bounds: ${i} > ${r.length-1}.`);if(i===Math.floor(i))return r[i];let a=Math.floor(i),n=Math.ceil(i),o=r[a],s=r[n];if("number"!=typeof o||"number"!=typeof s)throw new iH(`Cannot interpolate between non-number values at index ${i}.`);let l=i-a;return o*(1-l)+s*l}eachChild(e){e(this.index),e(this.input)}outputDefined(){return!1}serialize(){return["at-interpolated",this.index.serialize(),this.input.serialize()]}}class ah{constructor(e,i){this.type=iw,this.needle=e,this.haystack=i}static parse(e,i){if(3!==e.length)return i.error(`Expected 2 arguments, but found ${e.length-1} instead.`);let r=i.parse(e[1],1,iE),a=i.parse(e[2],2,iE);
1return r&&a?iD(r.type,[iw,ib,iv,ix,iE])?new ah(r,a):i.error(`Expected first argument to be of type boolean, string, number or null, but found ${iP(r.type)} instead`):null}evaluate(e){let i=this.needle.evaluate(e),r=this.haystack.evaluate(e);if(null==r)return!1;if(!iL(i,["boolean","string","number","null"]))throw new iH(`Expected first argument to be of type boolean, string, number or null, but found ${iP(iG(i))} instead.`);if(!iL(r,["string","array"]))throw new iH(`Expected second argument to be of type array or string, but found ${iP(iG(r))} instead.`);return r.indexOf(i)>=0}eachChild(e){e(this.needle),e(this.haystack)}outputDefined(){return!0}serialize(){return["in",this.needle.serialize(),this.haystack.serialize()]}}class au{constructor(e,i,r){this.type=iv,this.needle=e,this.haystack=i,this.fromIndex=r}static parse(e,i){if(e.length<=2||e.length>=5)return i.error(`Expected 3 or 4 arguments, but found ${e.length-1} instead.`);let r=i.parse(e[1],1,iE),a=i.parse(e[2],2,iE);if(!r||!a)return null;if(!iD(r.type,[iw,ib,iv,ix,iE]))return i.error(`Expected first argument to be of type boolean, string, number or null, but found ${iP(r.type)} instead`);if(4===e.length){let n=i.parse(e[3],3,iv);return n?new au(r,a,n):null}return new au(r,a)}evaluate(e){let i=this.needle.evaluate(e),r=this.haystack.evaluate(e);if(!iL(i,["boolean","string","number","null"]))throw new iH(`Expected first argument to be of type boolean, string, number or null, but found ${iP(iG(i))} instead.`);if(!iL(r,["string","array"]))throw new iH(`Expected second argument to be of type array or string, but found ${iP(iG(r))} instead.`);if(this.fromIndex){let a=this.fromIndex.evaluate(e);return r.indexOf(i,a)}return r.indexOf(i)}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){let e=this.fromIndex.serialize();return["index-of",this.needle.serialize(),this.haystack.serialize(),e]}return["index-of",this.needle.serialize(),this.haystack.serialize()]}}class ac{constructor(e,i,r,a,n,o){this.inputType=e,this.type=i,this.input=r,this.cases=a,this.outputs=n,this.otherwise=o}static parse(e,i){let r,a;if(e.length<5)return i.error(`Expected at least 4 arguments, but found only ${e.length-1}.`);if(e.length%2!=1)return i.error("Expected an even number of arguments.");i.expectedType&&"value"!==i.expectedType.kind&&(a=i.expectedType);let n={},o=[];for(let s=2;s<e.length-1;s+=2){let l=e[s],h=e[s+1];Array.isArray(l)||(l=[l]);let u=i.concat(s);if(0===l.length)return u.error("Expected at least one branch label.");for(let e of l){if("number"!=typeof e&&"string"!=typeof e)return u.error("Branch labels must be numbers or strings.");if("number"==typeof e&&Math.abs(e)>Number.MAX_SAFE_INTEGER)return u.error(`Branch labels must be integers no larger than ${Number.MAX_SAFE_INTEGER}.`);if("number"==typeof e&&Math.floor(e)!==e)return u.error("Numeric branch labels must be integer values.");if(r){if(u.checkSubtype(r,iG(e)))return null}else r=iG(e);if(void 0!==n[String(e)])return u.error("Branch labels must be unique.");n[String(e)]=o.length}let c=i.parse(h,s,a);if(!c)return null;a=a||c.type,o.push(c)}let s=i.parse(e[1],1,iE);if(!s)return null;let l=i.parse(e[e.length-1],e.length-1,a);return l?"value"!==s.type.kind&&i.concat(1).checkSubtype(r,s.type)?null:new ac(r,a,s,n,o,l):null}evaluate(e){let i=this.input.evaluate(e);return(iO(iG(i),this.inputType)&&this.outputs[this.cases[i]]||this.otherwise).evaluate(e)}eachChild(e){e(this.input),this.outputs.forEach(e),e(this.otherwise)}outputDefined(){return this.outputs.every(e=>e.outputDefined())&&this.otherwise.outputDefined()}serialize(){let e=["match",this.input.serialize()],i=Object.keys(this.cases).sort(),r=[],a={};for(let e of i){let i=a[this.cases[e]];void 0===i?(a[this.cases[e]]=r.length,r.push([this.cases[e],[e]])):r[i][1].push(e)}let n=e=>"number"===this.inputType.kind?Number(e):e;for(let[i,a]of r)e.push(1===a.length?n(a[0]):a.map(n)),e.push(this.outputs[i].serialize());return e.push(this.otherwise.serialize()),e}}class ad{constructor(e,i,r){this.type=e,this.branches=i,this.otherwise=r}static parse(e,i){let r;if(e.length<4)return i.error(`Expected at least 3 arguments, but found only ${e.length-1}.`);if(e.length%2!=0)return i.error("Expected an odd number of arguments.");i.expectedType&&"value"!==i.expectedType.kind&&(r=i.expectedType);let a=[];for(let n=1;n<e.length-1;n+=2){let o=i.parse(e[n],n,iw);if(!o)return null;let s=i.parse(e[n+1],n+1,r);if(!s)return null;a.push([o,s]),r=r||s.type}let n=i.parse(e[e.length-1],e.length-1,r);return n?new ad(r,a,n):null}evaluate(e){for(let[i,r]of this.branches)if(i.evaluate(e))return r.evaluate(e);return this.otherwise.evaluate(e)}eachChild(e){for(let[i,r]of this.branches)e(i),e(r);e(this.otherwise)}outputDefined(){return this.branches.every(([e,i])=>i.outputDefined())&&this.otherwise.outputDefined()}serialize(){let e=["case"];return this.eachChild(i=>{e.push(i.serialize())}),e}}class ap{constructor(e,i,r,a){this.type=e,this.input=i,this.beginIndex=r,this.endIndex=a}static parse(e,i){if(e.length<=2||e.length>=5)return i.error(`Expected 3 or 4 arguments, but found ${e.length-1} instead.`);let r=i.parse(e[1],1,iE),a=i.parse(e[2],2,iv);if(!r||!a)return null;if(!iD(r.type,[iM(iE),ib,iE]))return i.error(`Expected first argument to be of type array or string, but found ${iP(r.type)} instead`);if(4===e.length){let n=i.parse(e[3],3,iv);return n?new ap(r.type,r,a,n):null}return new ap(r.type,r,a)}evaluate(e){let i=this.input.evaluate(e),r=this.beginIndex.evaluate(e);if(!iL(i,["string","array"]))throw new iH(`Expected first argument to be of type array or string, but found ${iP(iG(i))} instead.`);if(this.endIndex){let a=this.endIndex.evaluate(e);return i.slice(r,a)}return i.slice(r)}eachChild(e){e(this.input),e(this.beginIndex),this.endIndex&&e(this.endIndex)}outputDefined(){return!1}serialize(){if(null!=this.endIndex&&void 0!==this.endIndex){let e=this.endIndex.serialize();return["slice",this.input.serialize(),this.beginIndex.serialize(),e]}return["slice",this.input.serialize(),this.beginIndex.serialize()]}}class af{constructor(e,i){this.type=iM(ib),this.str=e,this.delimiter=i}static parse(e,i){if(3!==e.length)return i.error(`Expected 2 arguments, but found ${e.length-1} instead.`);let r=i.parse(e[1],1,ib),a=i.parse(e[2],2,ib);return r&&a?new af(r,a):void 0}evaluate(e){let i=this.str.evaluate(e),r=this.delimiter.evaluate(e);return i.split(r)}eachChild(e){e(this.str),e(this.delimiter)}outputDefined(){return!1}serialize(){return["split",this.str.serialize(),this.delimiter.serialize()]}}function am(e,i){return"=="===e||"!="===e?"boolean"===i.kind||"string"===i.kind||"number"===i.kind||"null"===i.kind||"value"===i.kind:"string"===i.kind||"number"===i.kind||"value"===i.kind}function a_(e,i,r,a){return 0===a.compare(i,r)}function ag(e,i,r){let a="=="!==e&&"!="!==e;
1return class n{constructor(e,i,r){this.type=iw,this.lhs=e,this.rhs=i,this.collator=r,this.hasUntypedArgument="value"===e.type.kind||"value"===i.type.kind}static parse(e,i){if(3!==e.length&&4!==e.length)return i.error("Expected two or three arguments.");let r=e[0],o=i.parse(e[1],1,iE);if(!o)return null;if(!am(r,o.type))return i.concat(1).error(`"${r}" comparisons are not supported for type '${iP(o.type)}'.`);let s=i.parse(e[2],2,iE);if(!s)return null;if(!am(r,s.type))return i.concat(2).error(`"${r}" comparisons are not supported for type '${iP(s.type)}'.`);if(o.type.kind!==s.type.kind&&"value"!==o.type.kind&&"value"!==s.type.kind)return i.error(`Cannot compare types '${iP(o.type)}' and '${iP(s.type)}'.`);a&&("value"===o.type.kind&&"value"!==s.type.kind?o=new iW(s.type,[o]):"value"!==o.type.kind&&"value"===s.type.kind&&(s=new iW(o.type,[s])));let l=null;if(4===e.length){if("string"!==o.type.kind&&"string"!==s.type.kind&&"value"!==o.type.kind&&"value"!==s.type.kind)return i.error("Cannot use collator to compare non-string types.");if(!(l=i.parse(e[3],3,iI)))return null}return new n(o,s,l)}evaluate(n){let o=this.lhs.evaluate(n),s=this.rhs.evaluate(n);if(a&&this.hasUntypedArgument){let i=iG(o),r=iG(s);if(i.kind!==r.kind||"string"!==i.kind&&"number"!==i.kind)throw new iH(`Expected arguments for "${e}" to be (string, string) or (number, number), but found (${i.kind}, ${r.kind}) instead.`)}if(this.collator&&!a&&this.hasUntypedArgument){let e=iG(o),r=iG(s);if("string"!==e.kind||"string"!==r.kind)return i(n,o,s)}return this.collator?r(n,o,s,this.collator.evaluate(n)):i(n,o,s)}eachChild(e){e(this.lhs),e(this.rhs),this.collator&&e(this.collator)}outputDefined(){return!0}serialize(){let i=[e];return this.eachChild(e=>{i.push(e.serialize())}),i}}}let ay=ag("==",function(e,i,r){return i===r},a_),ax=ag("!=",function(e,i,r){return i!==r},function(e,i,r,a){return!a_(0,i,r,a)}),av=ag("<",function(e,i,r){return i<r},function(e,i,r,a){return 0>a.compare(i,r)}),ab=ag(">",function(e,i,r){return i>r},function(e,i,r,a){return a.compare(i,r)>0}),aw=ag("<=",function(e,i,r){return i<=r},function(e,i,r,a){return 0>=a.compare(i,r)}),aT=ag(">=",function(e,i,r){return i>=r},function(e,i,r,a){return a.compare(i,r)>=0});class aS{constructor(e,i,r,a,n,o){this.type=ib,this.number=e,this.locale=i,this.currency=r,this.unit=a,this.minFractionDigits=n,this.maxFractionDigits=o}static parse(e,i){if(3!==e.length)return i.error("Expected two arguments.");let r=i.parse(e[1],1,iv);if(!r)return null;let a=e[2];if("object"!=typeof a||Array.isArray(a))return i.error("NumberFormat options argument must be an object.");let n=null;if(a.locale&&!(n=i.parseObjectValue(a.locale,2,"locale",ib)))return null;let o=null;if(a.currency&&!(o=i.parseObjectValue(a.currency,2,"currency",ib)))return null;let s=null;if(a.unit&&!(s=i.parseObjectValue(a.unit,2,"unit",ib)))return null;let l=null;if(a["min-fraction-digits"]&&!(l=i.parseObjectValue(a["min-fraction-digits"],2,"min-fraction-digits",iv)))return null;let h=null;return!a["max-fraction-digits"]||(h=i.parseObjectValue(a["max-fraction-digits"],2,"max-fraction-digits",iv))?new aS(r,n,o,s,l,h):null}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(){let 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 aE{constructor(e){this.type=iv,this.input=e}static parse(e,i){if(2!==e.length)return i.error(`Expected 1 argument, but found ${e.length-1} instead.`);let r=i.parse(e[1],1);return r?"array"!==r.type.kind&&"string"!==r.type.kind&&"value"!==r.type.kind?i.error(`Expected argument of type string or array, but found ${iP(r.type)} instead.`):new aE(r):null}evaluate(e){let i=this.input.evaluate(e);if("string"==typeof i||Array.isArray(i))return i.length;throw new iH(`Expected value to be of type string or array, but found ${iP(iG(i))} instead.`)}eachChild(e){e(this.input)}outputDefined(){return!1}serialize(){let e=["length"];return this.eachChild(i=>{e.push(i.serialize())}),e}}function aI(e){return function(){let i=Math.imul((e=0x6d2b79f5+(e|=0)|0)^e>>>15,1|e);return(((i=i+Math.imul(i^i>>>7,61|i)^i)^i>>>14)>>>0)/0x100000000}}let aA={"==":ay,"!=":ax,">":ab,"<":av,">=":aT,"<=":aw,array:iW,at:as,"at-interpolated":al,boolean:iW,case:ad,coalesce:an,collator:i9,format:iX,image:iY,in:ah,"index-of":au,interpolate:ar,"interpolate-hcl":ar,"interpolate-lab":ar,length:aE,let:ao,literal:i$,match:ac,number:iW,"number-format":aS,object:iW,slice:ap,step:rK,string:iW,"to-boolean":i3,"to-color":i3,"to-number":i3,"to-string":i3,var:rW,within:rd,distance:rN,config:rZ,split:af};function aC(e,[i,r,a,n]){i=i.evaluate(e),r=r.evaluate(e),a=a.evaluate(e);let o=n?n.evaluate(e):1,s=iU(i,r,a,o);if(s)throw new iH(s);return new ih(i/255,r/255,a/255,o)}function aM(e,[i,r,a,n]){var o,s,l;i=i.evaluate(e),r=r.evaluate(e),a=a.evaluate(e);let h=n?n.evaluate(e):1,u=(o=i,s=r,l=a,"number"==typeof o&&o>=0&&o<=360?"number"==typeof s&&s>=0&&s<=100&&"number"==typeof l&&l>=0&&l<=100?void 0===h||"number"==typeof h&&h>=0&&h<=1?null:`Invalid hsla value [${[o,s,l,h].join(", ")}]: 'a' must be between 0 and 1.`:`Invalid hsla value [${("number"==typeof h?[o,s,l,h]:[o,s,l]).join(", ")}]: 's', and 'l' must be between 0 and 100.`:`Invalid hsla value [${("number"==typeof h?[o,s,l,h]:[o,s,l]).join(", ")}]: 'h' must be between 0 and 360.`);if(u)throw new iH(u);let c=`hsla(${i}, ${r}%, ${a}%, ${h})`,d=ih.parse(c);if(!d)throw new iH(`Failed to parse HSLA color: ${c}`);return d}function aP(e,i){let r=i[e];return void 0===r?null:r}function az(e){return{type:e}}function aR(e){return{result:"success",value:e}}function aD(e){return{result:"error",value:e}}function aL(e,i){return!!e&&!!e.parameters&&e.parameters.indexOf(i)>-1}function aO(e){return"data-driven"===e["property-type"]}function aF(e){return aL(e.expression,"measure-light")}function ak(e){return aL(e.expression,"zoom")}function aB(e){return!!e.expression&&e.expression.interpolated}function aN(e){return"object"==typeof e&&null!==e&&!Array.isArray(e)}function aV(e){return e}function aU(e,i,r){return void 0!==e?e:void 0!==i?i:void 0!==r?r:void 0}function aj(e,i,r,a,n){return aU(typeof r===n?a[r]:void 0,e.default,i.default)}function aG(e,i,r){if(!i0(r))return aU(e.default,i.default);let a=e.stops.length;if(1===a||r<=e.stops[0][0])return e.stops[0][1];if(r>=e.stops[a-1][0])return e.stops[a-1][1];let n=rY(e.stops.map(e=>e[0]),r);return e.stops[n][1]}
1function aq(e,i,r){let a=void 0!==e.base?e.base:1;if(!i0(r))return aU(e.default,i.default);let n=e.stops.length;if(1===n||r<=e.stops[0][0])return e.stops[0][1];if(r>=e.stops[n-1][0])return e.stops[n-1][1];let o=rY(e.stops.map(e=>e[0]),r),s=function(e,i,r,a){let n=a-r,o=e-r;return 0===n?0:1===i?o/n:(Math.pow(i,o)-1)/(Math.pow(i,n)-1)}(r,a,e.stops[o][0],e.stops[o+1][0]),l=e.stops[o][1],h=e.stops[o+1][1],u=i_[i.type]||aV;if(e.colorSpace&&"rgb"!==e.colorSpace){let i=ai[e.colorSpace];u=(e,r)=>i.reverse(i.interpolate(i.forward(e),i.forward(r),s))}return"function"==typeof l.evaluate?{evaluate(...e){let i=l.evaluate.apply(void 0,e),r=h.evaluate.apply(void 0,e);if(void 0!==i&&void 0!==r)return u(i,r,s)}}:u(l,h,s)}function a$(e,i,r){return"color"===i.type?r=ih.parse(r):"formatted"===i.type?r=iB.fromString(r.toString()):"resolvedImage"===i.type?r=iV.build(r.toString()):iK(r)===i.type||"enum"===i.type&&i.values[r]||(r=void 0),aU(r,e.default,i.default)}i6.register(aA,{error:[{kind:"error"},[ib],(e,[i])=>{throw new iH(i.evaluate(e))}],typeof:[ib,[iE],(e,[i])=>iP(iG(i.evaluate(e)))],"to-rgba":[iM(iv,4),[iT],(e,[i])=>i.evaluate(e).toNonPremultipliedRenderColor(null).toArray()],"to-hsla":[iM(iv,4),[iT],(e,[i])=>i.evaluate(e).toNonPremultipliedRenderColor(null).toHslaArray()],rgb:[iT,[iv,iv,iv],aC],rgba:[iT,[iv,iv,iv,iv],aC],hsl:[iT,[iv,iv,iv],aM],hsla:[iT,[iv,iv,iv,iv],aM],has:{type:iw,overloads:[[[ib],(e,[i])=>i.evaluate(e)in e.properties()],[[ib,iS],(e,[i,r])=>i.evaluate(e)in r.evaluate(e)]]},get:{type:iE,overloads:[[[ib],(e,[i])=>aP(i.evaluate(e),e.properties())],[[ib,iS],(e,[i,r])=>aP(i.evaluate(e),r.evaluate(e))]]},"feature-state":[iE,[ib],(e,[i])=>aP(i.evaluate(e),e.featureState||{})],properties:[iS,[],e=>e.properties()],"geometry-type":[ib,[],e=>e.geometryType()],worldview:[ib,[],e=>e.globals.worldview||""],id:[iE,[],e=>e.id()],zoom:[iv,[],e=>e.globals.zoom],pitch:[iv,[],e=>e.globals.pitch||0],"distance-from-center":[iv,[],e=>e.distanceFromCenter()],"measure-light":[iv,[ib],(e,[i])=>e.measureLight(i.evaluate(e))],"heatmap-density":[iv,[],e=>e.globals.heatmapDensity||0],"line-progress":[iv,[],e=>e.globals.lineProgress||0],"raster-value":[iv,[],e=>e.globals.rasterValue||0],"raster-particle-speed":[iv,[],e=>e.globals.rasterParticleSpeed||0],"sky-radial-progress":[iv,[],e=>e.globals.skyRadialProgress||0],accumulated:[iE,[],e=>void 0===e.globals.accumulated?null:e.globals.accumulated],"+":[iv,az(iv),(e,i)=>{let r=0;for(let a of i)r+=a.evaluate(e);return r}],"*":[iv,az(iv),(e,i)=>{let r=1;for(let a of i)r*=a.evaluate(e);return r}],"-":{type:iv,overloads:[[[iv,iv],(e,[i,r])=>i.evaluate(e)-r.evaluate(e)],[[iv],(e,[i])=>-i.evaluate(e)]]},"/":[iv,[iv,iv],(e,[i,r])=>i.evaluate(e)/r.evaluate(e)],"%":[iv,[iv,iv],(e,[i,r])=>i.evaluate(e)%r.evaluate(e)],ln2:[iv,[],()=>Math.LN2],pi:[iv,[],()=>Math.PI],e:[iv,[],()=>Math.E],"^":[iv,[iv,iv],(e,[i,r])=>Math.pow(i.evaluate(e),r.evaluate(e))],sqrt:[iv,[iv],(e,[i])=>Math.sqrt(i.evaluate(e))],log10:[iv,[iv],(e,[i])=>Math.log(i.evaluate(e))/Math.LN10],ln:[iv,[iv],(e,[i])=>Math.log(i.evaluate(e))],log2:[iv,[iv],(e,[i])=>Math.log2(i.evaluate(e))],sin:[iv,[iv],(e,[i])=>Math.sin(i.evaluate(e))],cos:[iv,[iv],(e,[i])=>Math.cos(i.evaluate(e))],tan:[iv,[iv],(e,[i])=>Math.tan(i.evaluate(e))],asin:[iv,[iv],(e,[i])=>Math.asin(i.evaluate(e))],acos:[iv,[iv],(e,[i])=>Math.acos(i.evaluate(e))],atan:[iv,[iv],(e,[i])=>Math.atan(i.evaluate(e))],min:[iv,az(iv),(e,i)=>Math.min(...i.map(i=>i.evaluate(e)))],max:[iv,az(iv),(e,i)=>Math.max(...i.map(i=>i.evaluate(e)))],abs:[iv,[iv],(e,[i])=>Math.abs(i.evaluate(e))],round:[iv,[iv],(e,[i])=>{let r=i.evaluate(e);return r<0?-Math.round(-r):Math.round(r)}],floor:[iv,[iv],(e,[i])=>Math.floor(i.evaluate(e))],ceil:[iv,[iv],(e,[i])=>Math.ceil(i.evaluate(e))],"filter-==":[iw,[ib,iE],(e,[i,r])=>e.properties()[i.value]===r.value],"filter-id-==":[iw,[iE],(e,[i])=>e.id()===i.value],"filter-type-==":[iw,[ib],(e,[i])=>e.geometryType()===i.value],"filter-<":[iw,[ib,iE],(e,[i,r])=>{let a=e.properties()[i.value],n=r.value;return typeof a==typeof n&&a<n}],"filter-id-<":[iw,[iE],(e,[i])=>{let r=e.id(),a=i.value;return typeof r==typeof a&&r<a}],"filter->":[iw,[ib,iE],(e,[i,r])=>{let a=e.properties()[i.value],n=r.value;return typeof a==typeof n&&a>n}],"filter-id->":[iw,[iE],(e,[i])=>{let r=e.id(),a=i.value;return typeof r==typeof a&&r>a}],"filter-<=":[iw,[ib,iE],(e,[i,r])=>{let a=e.properties()[i.value],n=r.value;return typeof a==typeof n&&a<=n}],"filter-id-<=":[iw,[iE],(e,[i])=>{let r=e.id(),a=i.value;return typeof r==typeof a&&r<=a}],"filter->=":[iw,[ib,iE],(e,[i,r])=>{let a=e.properties()[i.value],n=r.value;return typeof a==typeof n&&a>=n}],"filter-id->=":[iw,[iE],(e,[i])=>{let r=e.id(),a=i.value;return typeof r==typeof a&&r>=a}],"filter-has":[iw,[iE],(e,[i])=>i.value in e.properties()],"filter-has-id":[iw,[],e=>null!==e.id()&&void 0!==e.id()],"filter-type-in":[iw,[iM(ib)],(e,[i])=>i.value.indexOf(e.geometryType())>=0],"filter-id-in":[iw,[iM(iE)],(e,[i])=>i.value.indexOf(e.id())>=0],"filter-in-small":[iw,[ib,iM(iE)],(e,[i,r])=>r.value.indexOf(e.properties()[i.value])>=0],"filter-in-large":[iw,[ib,iM(iE)],(e,[i,r])=>(function(e,i,r,a){for(;r<=a;){let n=r+a>>1;if(i[n]===e)return!0;
1i[n]>e?a=n-1:r=n+1}return!1})(e.properties()[i.value],r.value,0,r.value.length-1)],all:{type:iw,overloads:[[[iw,iw],(e,[i,r])=>i.evaluate(e)&&r.evaluate(e)],[az(iw),(e,i)=>{for(let r of i)if(!r.evaluate(e))return!1;return!0}]]},any:{type:iw,overloads:[[[iw,iw],(e,[i,r])=>i.evaluate(e)||r.evaluate(e)],[az(iw),(e,i)=>{for(let r of i)if(r.evaluate(e))return!0;return!1}]]},"!":[iw,[iw],(e,[i])=>!i.evaluate(e)],"is-supported-script":[iw,[ib],(e,[i])=>{let r=e.globals&&e.globals.isSupportedScript;return!r||r(i.evaluate(e))}],upcase:[ib,[ib],(e,[i])=>i.evaluate(e).toUpperCase()],downcase:[ib,[ib],(e,[i])=>i.evaluate(e).toLowerCase()],concat:[ib,az(iE),(e,i)=>i.map(i=>iq(i.evaluate(e))).join("")],"resolved-locale":[ib,[iI],(e,[i])=>i.evaluate(e).resolvedLocale()],random:[iv,[iv,iv,iE],(e,i)=>{let r,[a,n,o]=i.map(i=>i.evaluate(e));if(a>n||a===n)return a;if("string"==typeof o)r=function(e){let i=0;if(0===e.length)return i;for(let r=0;r<e.length;r++)i=(i<<5)-i+e.charCodeAt(r)|0;return i}(o);else{if("number"!=typeof o)throw new iH(`Invalid seed input: ${o}`);r=o}return a+aI(r)()*(n-a)}]});class aH{constructor(e,i,r,a,n){this.expression=e,this._warningHistory={},this._evaluator=new i4(r,a,n),this._defaultValue=i?function(e){return"color"===e.type&&(aN(e.default)||Array.isArray(e.default))?new ih(0,0,0,0):"color"===e.type?ih.parse(e.default)||null:void 0===e.default?null:e.default}(i):null,this._enumValues=i&&"enum"===i.type?i.values:null,this.configDependencies=rj(e)}evaluateWithoutErrorHandling(e,i,r,a,n,o,s,l){return this._evaluator.globals=e,this._evaluator.feature=i,this._evaluator.featureState=r,this._evaluator.canonical=a||null,this._evaluator.availableImages=n||null,this._evaluator.formattedSection=o,this._evaluator.featureTileCoord=s||null,this._evaluator.featureDistanceData=l||null,this.expression.evaluate(this._evaluator)}evaluate(e,i,r,a,n,o,s,l,h){this._evaluator.globals=e,this._evaluator.feature=i||null,this._evaluator.featureState=r||null,this._evaluator.canonical=a||null,this._evaluator.availableImages=n||null,this._evaluator.formattedSection=o||null,this._evaluator.featureTileCoord=s||null,this._evaluator.featureDistanceData=l||null,this._evaluator.iconImageUseTheme=h||null;try{let 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 iH(`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){return this._warningHistory[e.message]||(this._warningHistory[e.message]=!0,"undefined"!=typeof console&&console.warn(`Failed to evaluate expression "${JSON.stringify(this.expression.serialize())}". ${e.message}`)),this._defaultValue}}}function aZ(e){return Array.isArray(e)&&e.length>0&&"string"==typeof e[0]&&e[0]in aA}function aW(e,i,r,a,n){let o=new rX(aA,[],i?function(e){let i={color:iT,string:ib,number:iv,enum:ib,boolean:iw,formatted:iA,resolvedImage:iC};return"array"===e.type?iM(i[e.value]||iE,e.length):i[e.type]}(i):void 0,void 0,void 0,r,a,n),s=o.parse(e,void 0,void 0,void 0,i&&"string"===i.type?{typeAnnotation:"coerce"}:void 0);return s?aR(new aH(s,i,r,a,n)):aD(o.errors)}class aX{constructor(e,i,r,a){this.kind=e,this._styleExpression=i,this.isLightConstant=r,this.isLineProgressConstant=a,this.isStateDependent="constant"!==e&&!rU(i.expression),this.configDependencies=rj(i.expression)}evaluateWithoutErrorHandling(e,i,r,a,n,o){return this._styleExpression.evaluateWithoutErrorHandling(e,i,r,a,n,o)}evaluate(e,i,r,a,n,o,s){return this._styleExpression.evaluate(e,i,r,a,n,o,void 0,void 0,s)}}class aY{constructor(e,i,r,a,n,o){this.kind=e,this.zoomStops=r,this._styleExpression=i,this.isStateDependent="camera"!==e&&!rU(i.expression),this.isLightConstant=n,this.isLineProgressConstant=o,this.configDependencies=rj(i.expression),this.interpolationType=a}evaluateWithoutErrorHandling(e,i,r,a,n,o){return this._styleExpression.evaluateWithoutErrorHandling(e,i,r,a,n,o)}evaluate(e,i,r,a,n,o){return this._styleExpression.evaluate(e,i,r,a,n,o)}interpolationFactor(e,i,r){return this.interpolationType?ar.interpolationFactor(this.interpolationType,e,i,r):0}}function aK(e,i,r,a,n){if("error"===(e=aW(e,i,r,a,n)).result)return e;let o=e.value.expression,s=rV(o);if(!s&&!aO(i))return aD([new ig("","data expressions not supported")]);let l=rG(o,["zoom","pitch","distance-from-center"]);if(!l&&!ak(i))return aD([new ig("","zoom expressions not supported")]);let h=rG(o,["measure-light"]);if(!h&&!aF(i))return aD([new ig("","measure-light expression not supported")]);let u=rG(o,["line-progress"]);if(!u&&!aL(i.expression,"line-progress"))return aD([new ig("","line-progress expression not supported")]);let c=i.expression&&i.expression.relaxZoomRestriction,d=function e(i){let r=null;if(i instanceof ao)r=e(i.result);else if(i instanceof an){for(let a of i.args)if(r=e(a))break}else(i instanceof rK||i instanceof ar)&&i.input instanceof i6&&"zoom"===i.input.name&&(r=i);return r instanceof ig||i.eachChild(i=>{let a=e(i);a instanceof ig?r=a:r&&a&&r!==a&&(r=new ig("",'Only one zoom-based "step" or "interpolate" subexpression may be used in an expression.'))}),r}(o);return d||l||c?d instanceof ig?aD([d]):d instanceof ar&&!aB(i)?aD([new ig("",'"interpolate" expressions cannot be used with this property')]):aR(d?new aY(s&&u?"camera":"composite",e.value,d.labels,d instanceof ar?d.interpolation:void 0,h,u):new aX(s&&u?"constant":"source",e.value,h,u)):aD([new ig("",'"zoom" expression may only be used as input to a top-level "step" or "interpolate" expression, or in the properties of atmosphere.')])}class aJ{constructor(e,i){this._parameters=e,this._specification=i,Object.assign(this,function e(i,r){let a,n,o,s="color"===r.type,l=i.stops&&"object"==typeof i.stops[0][0],h=l||!(l||void 0!==i.property),u=i.type||(aB(r)?"exponential":"interval");if(s&&((i=Object.assign({},i)).stops&&(i.stops=i.stops.map(e=>[e[0],ih.parse(e[1])])),i.default=ih.parse(i.default?i.default:r.default)),i.colorSpace&&"rgb"!==i.colorSpace&&!ai[i.colorSpace])throw Error(`Unknown color space: ${i.colorSpace}`);if("exponential"===u)a=aq;else if("interval"===u)a=aG;else if("categorical"===u){for(let e of(a=aj,n=Object.create(null),i.stops))n[e[0]]=e[1];o=typeof i.stops[0][0]}else{if("identity"!==u)throw Error(`Unknown function type "${u}"`);a=a$}if(l){let a={},n=[];for(let e=0;e<i.stops.length;e++){let r=i.stops[e],o=r[0].zoom;void 0===a[o]&&(a[o]={zoom:o,type:i.type,property:i.property,default:i.default,stops:[]},n.push(o)),a[o].stops.push([r[0].value,r[1]])}let o=[];for(let i of n)o.push([a[i].zoom,e(a[i],r)]);let s={name:"linear"};return{kind:"composite",interpolationType:s,interpolationFactor:ar.interpolationFactor.bind(void 0,s),zoomStops:o.map(e=>e[0]),evaluate:({zoom:e},a)=>aq({stops:o,base:i.base},r,e).evaluate(e,a)}}if(h){let e="exponential"===u?{name:"exponential",base:void 0!==i.base?i.base:1}:null;return{kind:"camera",interpolationType:e,interpolationFactor:ar.interpolationFactor.bind(void 0,e),zoomStops:i.stops.map(e=>e[0]),evaluate:({zoom:e})=>a(i,r,e,n,o)}}return{kind:"source",evaluate(e,s){let l=s&&s.properties?s.properties[i.property]:void 0;return void 0===l?aU(i.default,r.default):a(i,r,l,n,o)}}}(this._parameters,this._specification))}static deserialize(e){return new aJ(e._parameters,e._specification)}static serialize(e){return{_parameters:e._parameters,_specification:e._specification}}}var aQ,a0,a1=e1(function(){if(a0)return aQ;function e(e,i,r){var a=this.cells=[];if(e instanceof ArrayBuffer){this.arrayBuffer=e;var n=new Int32Array(this.arrayBuffer);e=n[0],this.d=(i=n[1])+2*(r=n[2]);for(var o=0;o<this.d*this.d;
1o++){var s=n[3+o],l=n[3+o+1];a.push(s===l?null:n.subarray(s,l))}var h=n[3+a.length+1];this.keys=n.subarray(n[3+a.length],h),this.bboxes=n.subarray(h),this.insert=this._insertReadonly}else{this.d=i+2*r;for(var u=0;u<this.d*this.d;u++)a.push([]);this.keys=[],this.bboxes=[]}this.n=i,this.extent=e,this.padding=r,this.scale=i/e,this.uid=0;var c=r/i*e;this.min=-c,this.max=e+c}return a0=1,aQ=e,e.prototype.insert=function(e,i,r,a,n){this._forEachCell(i,r,a,n,this._insertCell,this.uid++),this.keys.push(e),this.bboxes.push(i),this.bboxes.push(r),this.bboxes.push(a),this.bboxes.push(n)},e.prototype._insertReadonly=function(){throw"Cannot insert into a GridIndex created from an ArrayBuffer."},e.prototype._insertCell=function(e,i,r,a,n,o){this.cells[n].push(o)},e.prototype.query=function(e,i,r,a,n){var o=this.min,s=this.max;if(e<=o&&i<=o&&s<=r&&s<=a&&!n)return Array.prototype.slice.call(this.keys);var l=[];return this._forEachCell(e,i,r,a,this._queryCell,l,{},n),l},e.prototype._queryCell=function(e,i,r,a,n,o,s,l){var h=this.cells[n];if(null!==h)for(var u=this.keys,c=this.bboxes,d=0;d<h.length;d++){var p=h[d];if(void 0===s[p]){var f=4*p;(l?l(c[f+0],c[f+1],c[f+2],c[f+3]):e<=c[f+2]&&i<=c[f+3]&&r>=c[f+0]&&a>=c[f+1])?(s[p]=!0,o.push(u[p])):s[p]=!1}}},e.prototype._forEachCell=function(e,i,r,a,n,o,s,l){for(var h=this._convertToCellCoord(e),u=this._convertToCellCoord(i),c=this._convertToCellCoord(r),d=this._convertToCellCoord(a),p=h;p<=c;p++)for(var f=u;f<=d;f++){var m=this.d*f+p;if((!l||l(this._convertFromCellCoord(p),this._convertFromCellCoord(f),this._convertFromCellCoord(p+1),this._convertFromCellCoord(f+1)))&&n.call(this,e,i,r,a,m,o,s,l))return}},e.prototype._convertFromCellCoord=function(e){return(e-this.padding)/this.scale},e.prototype._convertToCellCoord=function(e){return Math.max(0,Math.min(this.d-1,Math.floor(e*this.scale)+this.padding))},e.prototype.toArrayBuffer=function(){if(this.arrayBuffer)return this.arrayBuffer;for(var e=this.cells,i=3+this.cells.length+1+1,r=0,a=0;a<this.cells.length;a++)r+=this.cells[a].length;var n=new Int32Array(i+r+this.keys.length+this.bboxes.length);n[0]=this.extent,n[1]=this.n,n[2]=this.padding;for(var o=i,s=0;s<e.length;s++){var l=e[s];n[3+s]=o,n.set(l,o),o+=l.length}return n[3+e.length]=o,n.set(this.keys,o),n[3+e.length+1]=o+=this.keys.length,n.set(this.bboxes,o),o+=this.bboxes.length,n.buffer},aQ}());let a2={};function a3(e,i,r={}){Object.defineProperty(e,"_classRegistryKey",{value:i,writable:!1}),a2[i]={klass:e,omit:r.omit||[]}}for(let e in a3(Object,"Object"),a1.serialize=function(e,i){let r=e.toArrayBuffer();return i&&i.add(r),{buffer:r}},a1.deserialize=function(e){return new a1(e.buffer)},Object.defineProperty(a1,"name",{value:"Grid"}),a3(a1,"Grid"),delete e3.prototype.constructor,"undefined"!=typeof DOMMatrix&&a3(DOMMatrix,"DOMMatrix"),a3(ih,"Color"),a3(Error,"Error"),a3(iB,"Formatted"),a3(ik,"FormattedSection"),a3(tW,"AJAXError"),a3(iV,"ResolvedImage"),a3(aJ,"StylePropertyFunction"),a3(aH,"StyleExpression",{omit:["_evaluator"]}),a3(ia,"ImageId"),a3(iN,"ImageVariant"),a3(aY,"ZoomDependentExpression"),a3(aX,"ZoomConstantExpression"),a3(i6,"CompoundExpression",{omit:["_evaluate"]}),aA)a2[aA[e]._classRegistryKey]||a3(aA[e],`Expression${e}`);function a5(e){return e&&"undefined"!=typeof ArrayBuffer&&(e instanceof ArrayBuffer||e.constructor&&"ArrayBuffer"===e.constructor.name)}function a4(e){return self.ImageBitmap&&e instanceof ImageBitmap}function a6(e,i){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(a5(e)||a4(e))return i&&i.add(e),e;if(ArrayBuffer.isView(e))return i&&i.add(e.buffer),e;if(e instanceof ImageData)return i&&i.add(e.data.buffer),e;if(Array.isArray(e)){let r=[];for(let a of e)r.push(a6(a,i));return r}if(e instanceof Map){let r={$name:"Map",entries:[]};for(let[a,n]of e.entries())r.entries.push(a6(a),a6(n,i));return r}if(e instanceof Set){let i={$name:"Set"},r=0;for(let a of e.values())i[++r]=a6(a);return i}if(e instanceof DOMMatrix){let i={$name:"DOMMatrix"};for(let r of["is2D","m11","m12","m13","m14","m21","m22","m23","m24","m31","m32","m33","m34","m41","m42","m43","m44","a","b","c","d","e","f"])i[r]=e[r];return i}if("bigint"==typeof e)return{$name:"BigInt",value:e.toString()};if("object"==typeof e){let r=e.constructor,a=r._classRegistryKey;if(!a)throw Error(`Can't serialize object of unregistered class "${r.name}".`);let n=r.serialize?r.serialize(e,i):{};if(!r.serialize){for(let r in e)e.hasOwnProperty(r)&&(a2[a].omit.indexOf(r)>=0||(n[r]=a6(e[r],i)));e instanceof Error&&(n.message=e.message)}if(n.$name)throw Error("$name property is reserved for worker serialization logic.");return"Object"!==a&&(n.$name=a),n}throw Error("can't serialize object of type "+typeof e)}function a8(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||a5(e)||a4(e)||ArrayBuffer.isView(e)||e instanceof ImageData)return e;if(Array.isArray(e))return e.map(a8);if("object"==typeof e){let i=e.$name||"Object";if("Map"===i){let i=e.entries||[],r=new Map;for(let e=0;e<i.length;e+=2)r.set(a8(i[e]),a8(i[e+1]));return r}if("Set"===i){let i=new Set;for(let r of Object.keys(e))"$name"!==r&&i.add(a8(e[r]));return i}if("DOMMatrix"===i)return new DOMMatrix(e.is2D?[e.a,e.b,e.c,e.d,e.e,e.f]:[e.m11,e.m12,e.m13,e.m14,e.m21,e.m22,e.m23,e.m24,e.m31,e.m32,e.m33,e.m34,e.m41,e.m42,e.m43,e.m44]);if("BigInt"===i)return BigInt(e.value);let{klass:r}=a2[i];if(!r)throw Error(`Can't deserialize unregistered class "${i}".`);if(r.deserialize)return r.deserialize(e);let a=Object.create(r.prototype);for(let i of Object.keys(e))"$name"!==i&&(a[i]=a8(e[i]));return a}throw Error("can't deserialize object of type "+typeof e)}let a9=e=>e>=1536&&e<=1791,a7=e=>e>=1872&&e<=1919,ne=e=>e>=2208&&e<=2303,nt=e=>e>=6016&&e<=6143,ni=e=>e>=11904&&e<=12031,nr=e=>e>=12032&&e<=12255,na=e=>e>=12272&&e<=12287,nn=e=>e>=12288&&e<=12351,no=e=>e>=12352&&e<=12447,ns=e=>e>=12448&&e<=12543,nl=e=>e>=12544&&e<=12591,nh=e=>e>=12704&&e<=12735,nu=e=>e>=12736&&e<=12783,nc=e=>e>=12784&&e<=12799,nd=e=>e>=12800&&e<=13055,np=e=>e>=13056&&e<=13311,nf=e=>e>=13312&&e<=19903,nm=e=>e>=19968&&e<=40959,n_=e=>e>=40960&&e<=42127,ng=e=>e>=42128&&e<=42191,ny=e=>e>=44032&&e<=55215,nx=e=>e>=63744&&e<=64255,nv=e=>e>=64336&&e<=65023,nb=e=>e>=65040&&e<=65055,nw=e=>e>=65072&&e<=65103,nT=e=>e>=65104&&e<=65135,nS=e=>e>=65136&&e<=65279,nE=e=>e>=65280&&e<=65519;function nI(e){for(let i of e)if(nA(i.charCodeAt(0)))return!0;return!1}function nA(e){let i,r,a,n,o,s,l,h;return!(746!==e&&747!==e&&(e<4352||!(nh(e)||nl(e)||nw(e)&&!(e>=65097&&e<=65103)||nx(e)||np(e)||ni(e)||nu(e)||!(!nn(e)||e>=12296&&e<=12305||e>=12308&&e<=12319||12336===e)||nf(e)||nm(e)||nd(e)||(i=e)>=12592&&i<=12687||(r=e)>=43360&&r<=43391||(a=e)>=55216&&a<=55295||(n=e)>=4352&&n<=4607||ny(e)||no(e)||na(e)||(o=e)>=12688&&o<=12703||nr(e)||nc(e)||ns(e)&&12540!==e||!(!nE(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)||!(!nT(e)||e>=65112&&e<=65118||e>=65123&&e<=65126)||(s=e)>=5120&&s<=5759||(l=e)>=6320&&l<=6399||nb(e)||(h=e)>=19904&&h<=19967||n_(e)||ng(e))))}function nC(e){let i,r,a,n,o,s,l,h,u,c,d,p;return!(nA(e)||(i=e)>=128&&i<=255&&(167===e||169===e||174===e||177===e||188===e||189===e||190===e||215===e||247===e)||(r=e)>=8192&&r<=8303&&(8214===e||8224===e||8225===e||8240===e||8241===e||8251===e||8252===e||8258===e||8263===e||8264===e||8265===e||8273===e)||(a=e)>=8448&&a<=8527||(n=e)>=8528&&n<=8591||(o=e)>=8960&&o<=9215&&(e>=8960&&e<=8967||e>=8972&&e<=8991||e>=8996&&e<=9e3||9003===e||e>=9085&&e<=9114||e>=9150&&e<=9165||9167===e||e>=9169&&e<=9179||e>=9186&&e<=9215)||(s=e)>=9216&&s<=9279&&9251!==e||(l=e)>
1=9280&&l<=9311||(h=e)>=9312&&h<=9471||(u=e)>=9632&&u<=9727||(c=e)>=9728&&c<=9983&&!(e>=9754&&e<=9759)||(d=e)>=11008&&d<=11263&&(e>=11026&&e<=11055||e>=11088&&e<=11097||e>=11192&&e<=11243)||nn(e)||ns(e)||(p=e)>=57344&&p<=63743||nw(e)||nT(e)||nE(e)||8734===e||8756===e||8757===e||e>=9984&&e<=10087||e>=10102&&e<=10131||65532===e||65533===e)}function nM(e){return e>=1424&&e<=2303||nv(e)||nS(e)}let nP={unavailable:"unavailable",deferred:"deferred",loading:"loading",parsing:"parsing",parsed:"parsed",loaded:"loaded",error:"error"},nz=null,nR=nP.unavailable,nD=null,nL=function(e){e&&"string"==typeof e&&e.indexOf("NetworkError")>-1&&(nR=nP.error),nz&&nz(e)};function nO(){nF.fire(new t7("pluginStateChange",{pluginStatus:nR,pluginURL:nD}))}let nF=new ir,nk=function(){return nR},nB=function(){if(nR!==nP.deferred||!nD)throw Error("rtl-text-plugin cannot be downloaded unless a pluginURL is specified");nR=nP.loading,nO(),nD&&tK({url:nD},e=>{e?nL(e):(nR=nP.loaded,nO())})},nN={applyArabicShaping:null,processBidirectionalText:null,processStyledBidirectionalText:null,isLoaded:()=>nR===nP.loaded||null!=nN.applyArabicShaping,isLoading:()=>nR===nP.loading,setState(e){nR=e.pluginStatus,nD=e.pluginURL},isParsing:()=>nR===nP.parsing,isParsed:()=>nR===nP.parsed,getPluginURL:()=>nD};class nV{constructor(e,i){this.zoom=e,i?(this.now=i.now,this.fadeDuration=i.fadeDuration,this.transition=i.transition,this.pitch=i.pitch,this.brightness=i.brightness,this.worldview=i.worldview):(this.now=0,this.fadeDuration=0,this.transition={},this.pitch=0,this.brightness=0)}isSupportedScript(e){var i,r=nN.isLoaded();for(let a of e)if(i=a.charCodeAt(0),!r&&nM(i)||i>=2304&&i<=3583||i>=3840&&i<=4255||nt(i))return!1;return!0}}class nU{constructor(e,i,r,a,n){this.property=e,this.value=i,this.expression=function(e,i,r,a,n){if(aN(e))return new aJ(e,i);if(aZ(e)||Array.isArray(e)&&e.length>0){let o=aK(e,i,r,a,n);if("error"===o.result)throw Error(o.value.map(e=>`${e.key}: ${e.message}`).join(", "));return o.value}{let r=e;return"string"==typeof e&&"color"===i.type&&(r=ih.parse(e)),{kind:"constant",configDependencies:new Set,evaluate:()=>r}}}(void 0===i?e.specification.default:i,e.specification,r,a,n)}isDataDriven(){return"source"===this.expression.kind||"composite"===this.expression.kind}possiblyEvaluate(e,i,r,a){return this.property.possiblyEvaluate(this,e,i,r,a)}}class nj{constructor(e,i,r,a){this.property=e,this.value=new nU(e,void 0,i,r,a)}transitioned(e,i){return new nq(this.property,this.value,i,Object.assign({},e.transition,this.transition),e.now)}untransitioned(){return new nq(this.property,this.value,null,{},0)}}class nG{constructor(e,i,r,a){this._properties=e,this._values=Object.create(e.defaultTransitionablePropertyValues),this._scope=i,this._options=r,this._iconImageUseTheme=a,this.configDependencies=new Set}getValue(e){return tc(this._values[e].value.value)}setValue(e,i){this._values.hasOwnProperty(e)||(this._values[e]=new nj(this._values[e].property,this._scope,this._options,this._iconImageUseTheme)),this._values[e].value=new nU(this._values[e].property,null===i?void 0:tc(i),this._scope,this._options,this._iconImageUseTheme),this._values[e].value.expression.configDependencies&&(this.configDependencies=new Set([...this.configDependencies,...this._values[e].value.expression.configDependencies]))}setTransitionOrValue(e,i){i&&(this._options=i);let r=this._properties.properties;if(e)for(let i in e){let a=e[i];if(i.endsWith("-transition")){let e=i.slice(0,-11);r[e]&&this.setTransition(e,a)}else r.hasOwnProperty(i)&&this.setValue(i,a)}}getTransition(e){return tc(this._values[e].transition)}setTransition(e,i){this._values.hasOwnProperty(e)||(this._values[e]=new nj(this._values[e].property)),this._values[e].transition=tc(i)||void 0}serialize(){let e={};for(let i of Object.keys(this._values)){let r=this.getValue(i);void 0!==r&&(e[i]=r);let a=this.getTransition(i);void 0!==a&&(e[`${i}-transition`]=a)}return e}transitioned(e,i){let r=new n$(this._properties);for(let a of Object.keys(this._values))r._values[a]=this._values[a].transitioned(e,i._values[a]);return r}untransitioned(){let e=new n$(this._properties);for(let i of Object.keys(this._values))e._values[i]=this._values[i].untransitioned();return e}}class nq{constructor(e,i,r,a,n){let o=a.delay||0,s=a.duration||0;n=n||0,this.property=e,this.value=i,this.begin=n+o,this.end=this.begin+s,e.specification.transition&&(a.delay||a.duration)&&(this.prior=r)}possiblyEvaluate(e,i,r){let a=e.now||0,n=this.value.possiblyEvaluate(e,i,r),o=this.prior;if(o){if(a>this.end||this.value.isDataDriven())return this.prior=null,n;if(a<this.begin)return o.possiblyEvaluate(e,i,r);{let s=(a-this.begin)/(this.end-this.begin);return this.property.interpolate(o.possiblyEvaluate(e,i,r),n,e9(s))}}return n}}class n${constructor(e){this._properties=e,this._values=Object.create(e.defaultTransitioningPropertyValues)}possiblyEvaluate(e,i,r){let a=new nW(this._properties);for(let n of Object.keys(this._values))a._values[n]=this._values[n].possiblyEvaluate(e,i,r);return a}hasTransition(){for(let e of Object.keys(this._values))if(this._values[e].prior)return!0;return!1}}class nH{constructor(e,i,r,a){this._properties=e,this._values=Object.create(e.defaultPropertyValues),this._scope=i,this._options=r,this._iconImageUseTheme=a,this.configDependencies=new Set}getValue(e){return tc(this._values[e].value)}setValue(e,i){this._values[e]=new nU(this._values[e].property,null===i?void 0:tc(i),this._scope,this._options,this._iconImageUseTheme),this._values[e].expression.configDependencies&&(this.configDependencies=new Set([...this.configDependencies,...this._values[e].expression.configDependencies]))}serialize(){let e={};for(let i of Object.keys(this._values)){let r=this.getValue(i);void 0!==r&&(e[i]=r)}return e}possiblyEvaluate(e,i,r,a){let n=new nW(this._properties);for(let o of Object.keys(this._values))n._values[o]=this._values[o].possiblyEvaluate(e,i,r,a);return n}}class nZ{constructor(e,i,r,a){this.property=e,this.value=i,this.parameters=r,this.iconImageUseTheme=a}isConstant(){return"constant"===this.value.kind}constantOr(e){return"constant"===this.value.kind?this.value.value:e}evaluate(e,i,r,a){return this.property.evaluate(this.value,this.parameters,e,i,r,a,this.iconImageUseTheme)}}class nW{constructor(e){this._properties=e,this._values=Object.create(e.defaultPossiblyEvaluatedValues)}get(e){return this._values[e]}}class nX{constructor(e){this.specification=e}
1possiblyEvaluate(e,i){return e.expression.evaluate(i)}interpolate(e,i,r){let a=i_[this.specification.type];return a?a(e,i,r):e}}class nY{constructor(e,i){this.specification=e,this.overrides=i}possiblyEvaluate(e,i,r,a,n){return"constant"===e.expression.kind||"camera"===e.expression.kind?new nZ(this,{kind:"constant",value:e.expression.evaluate(i,null,{},r,a,void 0,n)},i):new nZ(this,e.expression,i,n)}interpolate(e,i,r){if("constant"!==e.value.kind||"constant"!==i.value.kind)return e;if(void 0===e.value.value||void 0===i.value.value)return new nZ(this,{kind:"constant",value:void 0},e.parameters);let a=i_[this.specification.type];return a?new nZ(this,{kind:"constant",value:a(e.value.value,i.value.value,r)},e.parameters):e}evaluate(e,i,r,a,n,o,s){return"constant"===e.kind?e.value:e.evaluate(i,r,a,n,o,void 0,s)}}class nK{constructor(e){this.specification=e}possiblyEvaluate(e,i,r,a){return!!e.expression.evaluate(i,null,{},r,a)}interpolate(){return!1}}class nJ{constructor(e){this.properties=e,this.defaultPropertyValues={},this.defaultTransitionablePropertyValues={},this.defaultTransitioningPropertyValues={},this.defaultPossiblyEvaluatedValues={},this.overridableProperties=[];let i=new nV(0,{});for(let r in e){let a=e[r];a.specification.overridable&&this.overridableProperties.push(r);let n=this.defaultPropertyValues[r]=new nU(a,void 0),o=this.defaultTransitionablePropertyValues[r]=new nj(a);this.defaultTransitioningPropertyValues[r]=o.untransitioned(),this.defaultPossiblyEvaluatedValues[r]=n.possiblyEvaluate(i)}}}a3(nY,"DataDrivenProperty"),a3(nX,"DataConstantProperty"),a3(nK,"ColorRampProperty");var nQ=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}}
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":{"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,"maximum":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"}
1,"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,"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,"maximum":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,"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],"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":{"floorplanFeaturesetId":{"type":"string","expression":{}},"buildingFeaturesetId":{"type":"string","expression":{}}},"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":{"ty
1pe":"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"}
1,"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"]}},"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"]}},"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":{"int
1erpolated":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 n0(e){return e instanceof Number||e instanceof String||e instanceof Boolean?e.valueOf():e}function n1(e){if(Array.isArray(e))return e.map(n1);if(e instanceof Object&&!(e instanceof Number||e instanceof String||e instanceof Boolean)){let i={};for(let r in e)i[r]=n1(e[r]);return i}return n0(e)}function n2(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(let i of e.slice(1))if(!n2(i)&&"boolean"!=typeof i)return!1;return!0;default:return!0}}function n3(e,i="",r=null,a="fill"){if(null==e)return{filter:()=>!0,needGeometry:!1,needFeature:!1};n2(e)||(e=function e(i){if(!i)return!0;let r=i[0];return i.length<=1?"any"!==r:"=="===r?n8(i[1],i[2],"=="):"!="===r?oe(n8(i[1],i[2],"==")):"<"===r||">"===r||"<="===r||">="===r?n8(i[1],i[2],r):"any"===r?["any"].concat(i.slice(1).map(e)):"all"===r?["all"].concat(i.slice(1).map(e)):"none"===r?["all"].concat(i.slice(1).map(e).map(oe)):"in"===r?n9(i[1],i.slice(2)):"!in"===r?oe(n9(i[1],i.slice(2))):"has"===r?n7(i[1]):"!has"!==r||oe(n7(i[1]))}(e));let n=e,o=!0;try{o=function(e){if(!n5(e))return e;let i=n1(e);return function e(i){let r=!1,a=[];if("case"===i[0]){for(let e=1;e<i.length-1;e+=2)r=r||n5(i[e]),a.push(i[e+1]);a.push(i[i.length-1])}else if("match"===i[0]){r=r||n5(i[1]);for(let e=2;e<i.length-1;e+=2)a.push(i[e+1]);a.push(i[i.length-1])}else if("step"===i[0]){r=r||n5(i[1]);for(let e=1;e<i.length-1;e+=2)a.push(i[e+1])}r&&(i.length=0,i.push("any",...a));for(let r=1;r<i.length;r++)e(i[r])}(i),i=function e(i){if(!Array.isArray(i))return i;let r=function(e){if(n4.has(e[0])){for(let i=1;i<e.length;i++)if(n5(e[i]))return!0}return e}(i);return!0===r?r:r.map(i=>e(i))}(i)}(n)}catch(e){console.warn(`Failed to extract static filter. Filter will continue working, but at higher memory usage and slower framerate. 2This is most likely a bug, please report this via https://github.com/mapbox/mapbox-gl-js/issues/new?assignees=&labels=&template=Bug_report.md 3and paste the contents of this message in the report. 4Thank you! 5Filter Expression: 6${JSON.stringify(n,null,2)} 7 `)}let s=null,l=null;if("background"!==a&&"sky"!==a&&"slot"!==a){let e=aW(o,l=nQ[`filter_${a}`],i,r);if("error"===e.result)throw Error(e.value.map(e=>`${e.key}: ${e.message}`).join(", "));s=(i,r,a)=>e.value.evaluate(i,r,{},a)}let h=null,u=null;if(o!==n){let e=aW(n,l,i,r);if("error"===e.result)throw Error(e.value.map(e=>`${e.key}: ${e.message}`).join(", "));h=(i,r,a,n,o)=>e.value.evaluate(i,r,{}
7,a,void 0,void 0,n,o),u=!rV(e.value.expression)}return{filter:s,dynamicFilter:h||void 0,needGeometry:function e(i){if(!Array.isArray(i))return!1;if("within"===i[0]||"distance"===i[0])return!0;for(let r=1;r<i.length;r++)if(e(i[r]))return!0;return!1}(o),needFeature:!!u}}function n5(e){var i;if(!Array.isArray(e))return!1;if("pitch"===(i=e[0])||"distance-from-center"===i)return!0;for(let i=1;i<e.length;i++)if(n5(e[i]))return!0;return!1}let n4=new Set(["in","==","!=",">",">=","<","<=","to-boolean"]);function n6(e,i){return e<i?-1:+(e>i)}function n8(e,i,r){switch(e){case"$type":return[`filter-type-${r}`,i];case"$id":return[`filter-id-${r}`,i];default:return[`filter-${r}`,e,i]}}function n9(e,i){if(0===i.length)return!1;switch(e){case"$type":return["filter-type-in",["literal",i]];case"$id":return["filter-id-in",["literal",i]];default:return i.length>200&&!i.some(e=>typeof e!=typeof i[0])?["filter-in-large",e,["literal",i.sort(n6)]]:["filter-in-small",e,["literal",i]]}}function n7(e){switch(e){case"$type":return!0;case"$id":return["filter-has-id"];default:return["filter-has",e]}}function oe(e){return["!",e]}function ot(e,i){return i?`${e}�${i}`:e}let oi=()=>d||(d=new nJ({"icon-size":new nY(nQ.layout_symbol["icon-size"]),"icon-image":new nY(nQ.layout_symbol["icon-image"]),"icon-rotate":new nY(nQ.layout_symbol["icon-rotate"]),"icon-offset":new nY(nQ.layout_symbol["icon-offset"])}));class or{constructor(e,i,r,a,n,o){let s=aW(e,nQ.appearance.condition);if("success"===s.result&&(this.condition=s.value),this.name=i,r)for(let e in this.properties=new nW(oi()),this.unevaluatedLayout=new nH(oi(),a,n,o),r)this.unevaluatedLayout.setValue(e,r[e])}isActive(e){return!(this.condition||!e.isHidden||"hidden"!==this.name)||this.condition.evaluate(e.globals,e.feature,e.featureState,e.canonical)}getCondition(){return this.condition}getName(){return this.name}getProperty(e){return this.properties.get(e)}getUnevaluatedProperties(){return this.unevaluatedLayout}serialize(){let e={};return e.condition=this.condition.expression.serialize(),this.name&&(e.name=this.name),this.properties&&(e.properties=this.properties),e}}let oa="-transition",on=new Set(["fill","line","background","hillshade","raster"]);class oo extends ir{constructor(e,i,r,a,n,o){if(super(),this.id=e.id,this.fqid=ot(this.id,r),this.type=e.type,this.scope=r,this.lut=a,this.options=n,this.iconImageUseTheme=o,this.appearances=[],this._featureFilter={filter:()=>!0,needGeometry:!1,needFeature:!1},this._filterCompiled=!1,this.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;let i=aW(this.filter,nQ[`filter_${e.type}`]);"error"!==i.result&&(this.configDependencies=new Set([...this.configDependencies,...i.value.configDependencies]))}if(e.slot&&(this.slot=e.slot),e.appearances&&e.appearances.forEach(e=>{this.appearances.push(new or(e.condition,e.name,e.properties,this.scope,n,this.iconImageUseTheme))}),i.layout&&(this._unevaluatedLayout=new nH(i.layout,this.scope,n,this.iconImageUseTheme),this.configDependencies=new Set([...this.configDependencies,...this._unevaluatedLayout.configDependencies])),i.paint){for(let r in this._transitionablePaint=new nG(i.paint,this.scope,n),e.paint)this.setPaintProperty(r,e.paint[r]);for(let i in e.layout)this.setLayoutProperty(i,e.layout[i]);this.configDependencies=new Set([...this.configDependencies,...this._transitionablePaint.configDependencies]),this._transitioningPaint=this._transitionablePaint.untransitioned(),this.paint=new nW(i.paint)}}}onAdd(e){}onRemove(e){}isDraped(e){return!this.is3D(!0)&&on.has(this.type)}getLayoutProperty(e){return"visibility"===e?this.visibility:this._unevaluatedLayout.getValue(e)}setLayoutProperty(e,i){if("custom"===this.type&&"visibility"===e)return void(this.visibility=i);let r=this._unevaluatedLayout;r._properties.properties[e]&&(r.setValue(e,i),this.configDependencies=new Set([...this.configDependencies,...r.configDependencies]),"visibility"===e&&this.possiblyEvaluateVisibility())}possiblyEvaluateVisibility(){this._unevaluatedLayout._values.visibility&&(this.visibility=this._unevaluatedLayout._values.visibility.possiblyEvaluate({zoom:0}))}getPaintProperty(e){return e.endsWith(oa)?this._transitionablePaint.getTransition(e.slice(0,-11)):this._transitionablePaint.getValue(e)}setPaintProperty(e,i){let r=this._transitionablePaint,a=r._properties.properties;if(e.endsWith(oa)){let n=e.slice(0,-11);return a[n]&&r.setTransition(n,i||void 0),!1}if(!a[e])return!1;let n=r._values[e],o=n.value.isDataDriven(),s=n.value;r.setValue(e,i),this.configDependencies=new Set([...this.configDependencies,...r.configDependencies]),this._handleSpecialPaintPropertyUpdate(e);let l=r._values[e].value,h=l.isDataDriven(),u=e.endsWith("pattern")||"line-dasharray"===e;return h||o||u||this._handleOverridablePaintPropertyUpdate(e,s,l)}_handleSpecialPaintPropertyUpdate(e){}getProgramIds(){return null}getDefaultProgramParams(e,i,r){return null}_handleOverridablePaintPropertyUpdate(e,i,r){return!1}
7isHidden(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,i){this._unevaluatedLayout&&(this.layout=this._unevaluatedLayout.possiblyEvaluate(e,void 0,i,this.iconImageUseTheme)),this.paint=this._transitioningPaint.possiblyEvaluate(e,void 0,i)}serialize(){let 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())),tu(e,(e,i)=>!(void 0===e||"layout"===i&&!Object.keys(e).length||"paint"===i&&!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(let e in this.paint._values){let i=this.paint.get(e);if(i instanceof nZ&&aO(i.property.specification)&&("source"===i.value.kind||"composite"===i.value.kind)&&i.value.isStateDependent)return!0}return!1}compileFilter(e){this._filterCompiled||(this._featureFilter=n3(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}queryRadius(e){}queryIntersectsFeature(e,i,r,a,n,o,s,l,h){}}let os={Int8:Int8Array,Uint8:Uint8Array,Int16:Int16Array,Uint16:Uint16Array,Int32:Int32Array,Uint32:Uint32Array,Float32:Float32Array};class ol{constructor(e,i){this._structArray=e,this._pos1=i*this.size,this._pos2=this._pos1/2,this._pos4=this._pos1/4,this._pos8=this._pos1/8}}class oh{constructor(){this.capacity=-1,this.resize(0)}static serialize(e,i){return e._trim(),i&&i.add(e.arrayBuffer),{length:e.length,arrayBuffer:e.arrayBuffer}}static deserialize(e){let i=Object.create(this.prototype);return i.arrayBuffer=e.arrayBuffer,i.length=e.length,i.capacity=e.arrayBuffer.byteLength/i.bytesPerElement,i._refreshViews(),i}_trim(){this.length!==this.capacity&&(this.capacity=this.length,this.arrayBuffer=this.arrayBuffer.slice(0,this.length*this.bytesPerElement),this._refreshViews())}clear(){this.length=0}resize(e){this.reserve(e),this.length=e}reserve(e){if(e>this.capacity){this.capacity=Math.max(e,Math.floor(5*this.capacity),128),this.arrayBuffer=new ArrayBuffer(this.capacity*this.bytesPerElement);let i=this.uint8;this._refreshViews(),i&&this.uint8.set(i)}}_refreshViews(){throw Error("StructArray#_refreshViews() must be implemented by each concrete StructArray layout")}emplace(){throw Error("StructArray#emplace() must be implemented by each concrete StructArray layout")}emplaceBack(){throw 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 ou(e,i=1){let r=0,a=0;return{members:e.map(e=>{let n=os[e.type].BYTES_PER_ELEMENT,o=r=oc(r,Math.max(i,n)),s=e.components||1;return a=Math.max(a,n),r+=n*s,{name:e.name,type:e.type,components:s,offset:o}}),size:oc(r,Math.max(a,i)),alignment:i}}function oc(e,i){return Math.ceil(e/i)*i}class od extends oh{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(e,i){let r=this.length;
7return this.resize(r+1),this.emplace(r,e,i)}emplace(e,i,r){let a=2*e;return this.int16[a+0]=i,this.int16[a+1]=r,e}}od.prototype.bytesPerElement=4,a3(od,"StructArrayLayout2i4");class op extends oh{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(e,i,r){let a=this.length;return this.resize(a+1),this.emplace(a,e,i,r)}emplace(e,i,r,a){let n=3*e;return this.int16[n+0]=i,this.int16[n+1]=r,this.int16[n+2]=a,e}}op.prototype.bytesPerElement=6,a3(op,"StructArrayLayout3i6");class of extends oh{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(e,i,r,a){let n=this.length;return this.resize(n+1),this.emplace(n,e,i,r,a)}emplace(e,i,r,a,n){let o=4*e;return this.int16[o+0]=i,this.int16[o+1]=r,this.int16[o+2]=a,this.int16[o+3]=n,e}}of.prototype.bytesPerElement=8,a3(of,"StructArrayLayout4i8");class om extends oh{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(e){let i=this.length;return this.resize(i+1),this.emplace(i,e)}emplace(e,i){return this.float32[+e+0]=i,e}}om.prototype.bytesPerElement=4,a3(om,"StructArrayLayout1f4");class o_ extends oh{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(e,i,r){let a=this.length;return this.resize(a+1),this.emplace(a,e,i,r)}emplace(e,i,r,a){let n=4*e;return this.int16[n+0]=i,this.int16[n+1]=r,this.float32[2*e+1]=a,e}}o_.prototype.bytesPerElement=8,a3(o_,"StructArrayLayout2i1f8");class og extends oh{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(e,i,r){let a=this.length;return this.resize(a+1),this.emplace(a,e,i,r)}emplace(e,i,r,a){let n=4*e;return this.int16[n+0]=i,this.int16[n+1]=r,this.int16[n+2]=a,e}}og.prototype.bytesPerElement=8,a3(og,"StructArrayLayout3i8");class oy extends oh{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(e,i,r,a,n){let o=this.length;return this.resize(o+1),this.emplace(o,e,i,r,a,n)}emplace(e,i,r,a,n,o){let s=5*e;return this.int16[s+0]=i,this.int16[s+1]=r,this.int16[s+2]=a,this.int16[s+3]=n,this.int16[s+4]=o,e}}oy.prototype.bytesPerElement=10,a3(oy,"StructArrayLayout5i10");class ox extends oh{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(e,i,r,a,n,o,s){let l=this.length;return this.resize(l+1),this.emplace(l,e,i,r,a,n,o,s)}emplace(e,i,r,a,n,o,s,l){let h=6*e,u=12*e;return this.int16[h+0]=i,this.int16[h+1]=r,this.uint8[u+4]=a,this.uint8[u+5]=n,this.uint8[u+6]=o,this.uint8[u+7]=s,this.float32[3*e+2]=l,e}}ox.prototype.bytesPerElement=12,a3(ox,"StructArrayLayout2i4ub1f12");class ov extends oh{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(e,i,r){let a=this.length;return this.resize(a+1),this.emplace(a,e,i,r)}emplace(e,i,r,a){let n=3*e;return this.float32[n+0]=i,this.float32[n+1]=r,this.float32[n+2]=a,e}}ov.prototype.bytesPerElement=12,a3(ov,"StructArrayLayout3f12");class ob extends oh{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(e,i,r,a,n){let o=this.length;return this.resize(o+1),this.emplace(o,e,i,r,a,n)}emplace(e,i,r,a,n,o){let s=6*e;return this.uint16[s+0]=i,this.uint16[s+1]=r,this.uint16[s+2]=a,this.uint16[s+3]=n,this.float32[3*e+2]=o,e}}ob.prototype.bytesPerElement=12,a3(ob,"StructArrayLayout4ui1f12");class ow extends oh{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(e,i,r,a){let n=this.length;return this.resize(n+1),this.emplace(n,e,i,r,a)}emplace(e,i,r,a,n){let o=4*e;return this.uint16[o+0]=i,this.uint16[o+1]=r,this.uint16[o+2]=a,this.uint16[o+3]=n,e}}ow.prototype.bytesPerElement=8,a3(ow,"StructArrayLayout4ui8");class oT extends oh{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(e,i,r,a,n,o){let s=this.length;return this.resize(s+1),this.emplace(s,e,i,r,a,n,o)}emplace(e,i,r,a,n,o,s){let l=6*e;return this.int16[l+0]=i,this.int16[l+1]=r,this.int16[l+2]=a,this.int16[l+3]=n,this.int16[l+4]=o,this.int16[l+5]=s,e}}oT.prototype.bytesPerElement=12,a3(oT,"StructArrayLayout6i12");class oS extends oh{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(e,i,r,a,n,o,s,l,h,u,c,d){let p=this.length;return this.resize(p+1),this.emplace(p,e,i,r,a,n,o,s,l,h,u,c,d)}emplace(e,i,r,a,n,o,s,l,h,u,c,d,p){let f=12*e;return this.int16[f+0]=i,this.int16[f+1]=r,this.int16[f+2]=a,this.int16[f+3]=n,this.uint16[f+4]=o,this.uint16[f+5]=s,this.uint16[f+6]=l,this.uint16[f+7]=h,this.int16[f+8]=u,this.int16[f+9]=c,this.int16[f+10]=d,this.int16[f+11]=p,e}}oS.prototype.bytesPerElement=24,a3(oS,"StructArrayLayout4i4ui4i24");class oE extends oh{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(e,i,r,a,n,o){let s=this.length;return this.resize(s+1),this.emplace(s,e,i,r,a,n,o)}emplace(e,i,r,a,n,o,s){let l=10*e,h=5*e;return this.int16[l+0]=i,this.int16[l+1]=r,this.int16[l+2]=a,this.float32[h+2]=n,this.float32[h+3]=o,this.float32[h+4]=s,e}}oE.prototype.bytesPerElement=20,a3(oE,"StructArrayLayout3i3f20");class oI extends oh{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(e,i,r,a){let n=this.length;return this.resize(n+1),this.emplace(n,e,i,r,a)}emplace(e,i,r,a,n){let o=4*e;return this.float32[o+0]=i,this.float32[o+1]=r,this.float32[o+2]=a,this.float32[o+3]=n,e}}oI.prototype.bytesPerElement=16,a3(oI,"StructArrayLayout4f16");class oA extends oh{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint32=new Uint32Array(this.arrayBuffer)}emplaceBack(e){let i=this.length;return this.resize(i+1),this.emplace(i,e)}emplace(e,i){return this.uint32[+e+0]=i,e}}oA.prototype.bytesPerElement=4,a3(oA,"StructArrayLayout1ul4");class oC extends oh{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(e,i){let r=this.length;
7return this.resize(r+1),this.emplace(r,e,i)}emplace(e,i,r){let a=2*e;return this.uint16[a+0]=i,this.uint16[a+1]=r,e}}oC.prototype.bytesPerElement=4,a3(oC,"StructArrayLayout2ui4");class oM extends oh{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer),this.uint32=new Uint32Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(e,i,r,a,n,o,s,l,h,u,c,d,p){let f=this.length;return this.resize(f+1),this.emplace(f,e,i,r,a,n,o,s,l,h,u,c,d,p)}emplace(e,i,r,a,n,o,s,l,h,u,c,d,p,f){let m=20*e,_=10*e;return this.int16[m+0]=i,this.int16[m+1]=r,this.int16[m+2]=a,this.int16[m+3]=n,this.int16[m+4]=o,this.float32[_+3]=s,this.float32[_+4]=l,this.float32[_+5]=h,this.float32[_+6]=u,this.int16[m+14]=c,this.uint32[_+8]=d,this.uint16[m+18]=p,this.uint16[m+19]=f,e}}oM.prototype.bytesPerElement=40,a3(oM,"StructArrayLayout5i4f1i1ul2ui40");class oP extends oh{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(e,i,r,a,n,o,s){let l=this.length;return this.resize(l+1),this.emplace(l,e,i,r,a,n,o,s)}emplace(e,i,r,a,n,o,s,l){let h=8*e;return this.int16[h+0]=i,this.int16[h+1]=r,this.int16[h+2]=a,this.int16[h+4]=n,this.int16[h+5]=o,this.int16[h+6]=s,this.int16[h+7]=l,e}}oP.prototype.bytesPerElement=16,a3(oP,"StructArrayLayout3i2i2i16");class oz extends oh{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(e,i,r,a,n){let o=this.length;return this.resize(o+1),this.emplace(o,e,i,r,a,n)}emplace(e,i,r,a,n,o){let s=4*e,l=8*e;return this.float32[s+0]=i,this.float32[s+1]=r,this.float32[s+2]=a,this.int16[l+6]=n,this.int16[l+7]=o,e}}oz.prototype.bytesPerElement=16,a3(oz,"StructArrayLayout2f1f2i16");class oR extends oh{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(e,i,r,a,n,o){let s=this.length;return this.resize(s+1),this.emplace(s,e,i,r,a,n,o)}emplace(e,i,r,a,n,o,s){let l=20*e,h=5*e;return this.uint8[l+0]=i,this.uint8[l+1]=r,this.float32[h+1]=a,this.float32[h+2]=n,this.float32[h+3]=o,this.float32[h+4]=s,e}}oR.prototype.bytesPerElement=20,a3(oR,"StructArrayLayout2ub4f20");class oD extends oh{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(e,i,r){let a=this.length;return this.resize(a+1),this.emplace(a,e,i,r)}emplace(e,i,r,a){let n=3*e;return this.uint16[n+0]=i,this.uint16[n+1]=r,this.uint16[n+2]=a,e}}oD.prototype.bytesPerElement=6,a3(oD,"StructArrayLayout3ui6");class oL extends oh{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer),this.uint32=new Uint32Array(this.arrayBuffer)}emplaceBack(e,i,r,a,n,o,s,l,h,u,c,d,p,f,m,_,g,y,x,v,b){let w=this.length;return this.resize(w+1),this.emplace(w,e,i,r,a,n,o,s,l,h,u,c,d,p,f,m,_,g,y,x,v,b)}emplace(e,i,r,a,n,o,s,l,h,u,c,d,p,f,m,_,g,y,x,v,b,w){let T=30*e,S=15*e,E=60*e;return this.int16[T+0]=i,this.int16[T+1]=r,this.int16[T+2]=a,this.float32[S+2]=n,this.float32[S+3]=o,this.uint16[T+8]=s,this.uint16[T+9]=l,this.uint32[S+5]=h,this.uint32[S+6]=u,this.uint32[S+7]=c,this.uint16[T+16]=d,this.uint16[T+17]=p,this.uint16[T+18]=f,this.float32[S+10]=m,this.float32[S+11]=_,this.uint8[E+48]=g,this.uint8[E+49]=y,this.uint8[E+50]=x,this.uint32[S+13]=v,this.int16[T+28]=b,this.uint8[E+58]=w,e}}oL.prototype.bytesPerElement=60,a3(oL,"StructArrayLayout3i2f2ui3ul3ui2f3ub1ul1i1ub60");class oO extends oh{_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,i,r,a,n,o,s,l,h,u,c,d,p,f,m,_,g,y,x,v,b,w,T,S,E,I,A,C,M,P,z,R,D){let L=this.length;return this.resize(L+1),this.emplace(L,e,i,r,a,n,o,s,l,h,u,c,d,p,f,m,_,g,y,x,v,b,w,T,S,E,I,A,C,M,P,z,R,D)}emplace(e,i,r,a,n,o,s,l,h,u,c,d,p,f,m,_,g,y,x,v,b,w,T,S,E,I,A,C,M,P,z,R,D,L){let O=20*e,F=40*e;return this.float32[O+0]=i,this.float32[O+1]=r,this.int16[F+4]=a,this.int16[F+5]=n,this.int16[F+6]=o,this.int16[F+7]=s,this.int16[F+8]=l,this.int16[F+9]=h,this.int16[F+10]=u,this.int16[F+11]=c,this.int16[F+12]=d,this.uint16[F+13]=p,this.uint16[F+14]=f,this.uint16[F+15]=m,this.uint16[F+16]=_,this.uint16[F+17]=g,this.uint16[F+18]=y,this.uint16[F+19]=x,this.uint16[F+20]=v,this.uint16[F+21]=b,this.uint16[F+22]=w,this.uint16[F+23]=T,this.uint16[F+24]=S,this.uint16[F+25]=E,this.uint16[F+26]=I,this.uint16[F+27]=A,this.uint32[O+14]=C,this.float32[O+15]=M,this.float32[O+16]=P,this.float32[O+17]=z,this.float32[O+18]=R,this.uint8[80*e+76]=D,this.uint16[F+39]=L,e}}oO.prototype.bytesPerElement=80,a3(oO,"StructArrayLayout2f9i15ui1ul4f1ub1ui80");class oF extends oh{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(e,i,r,a,n,o){let s=this.length;return this.resize(s+1),this.emplace(s,e,i,r,a,n,o)}emplace(e,i,r,a,n,o,s){let l=6*e;return this.float32[l+0]=i,this.float32[l+1]=r,this.float32[l+2]=a,this.float32[l+3]=n,this.float32[l+4]=o,this.float32[l+5]=s,e}}oF.prototype.bytesPerElement=24,a3(oF,"StructArrayLayout6f24");class ok extends oh{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(e,i,r,a,n){let o=this.length;return this.resize(o+1),this.emplace(o,e,i,r,a,n)}emplace(e,i,r,a,n,o){let s=5*e;return this.float32[s+0]=i,this.float32[s+1]=r,this.float32[s+2]=a,this.float32[s+3]=n,this.float32[s+4]=o,e}}ok.prototype.bytesPerElement=20,a3(ok,"StructArrayLayout5f20");class oB extends oh{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(e,i,r,a,n,o,s){let l=this.length;return this.resize(l+1),this.emplace(l,e,i,r,a,n,o,s)}emplace(e,i,r,a,n,o,s,l){let h=7*e;return this.float32[h+0]=i,this.float32[h+1]=r,this.float32[h+2]=a,this.float32[h+3]=n,this.float32[h+4]=o,this.float32[h+5]=s,this.float32[h+6]=l,e}}oB.prototype.bytesPerElement=28,a3(oB,"StructArrayLayout7f28");class oN extends oh{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(e,i,r,a,n,o,s,l,h,u,c){let d=this.length;return this.resize(d+1),this.emplace(d,e,i,r,a,n,o,s,l,h,u,c)}emplace(e,i,r,a,n,o,s,l,h,u,c,d){let p=11*e;return this.float32[p+0]=i,this.float32[p+1]=r,this.float32[p+2]=a,this.float32[p+3]=n,this.float32[p+4]=o,this.float32[p+5]=s,this.float32[p+6]=l,this.float32[p+7]=h,this.float32[p+8]=u,this.float32[p+9]=c,this.float32[p+10]=d,e}}oN.prototype.bytesPerElement=44,a3(oN,"StructArrayLayout11f44");class oV extends oh{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(e,i,r,a,n,o,s,l,h){let u=this.length;return this.resize(u+1),this.emplace(u,e,i,r,a,n,o,s,l,h)}emplace(e,i,r,a,n,o,s,l,h,u){let c=9*e;return this.float32[c+0]=i,this.float32[c+1]=r,this.float32[c+2]=a,this.float32[c+3]=n,this.float32[c+4]=o,this.float32[c+5]=s,this.float32[c+6]=l,this.float32[c+7]=h,this.float32[c+8]=u,e}}oV.prototype.bytesPerElement=36,a3(oV,"StructArrayLayout9f36");class oU extends oh{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(e,i){let r=this.length;
7return this.resize(r+1),this.emplace(r,e,i)}emplace(e,i,r){let a=2*e;return this.float32[a+0]=i,this.float32[a+1]=r,e}}oU.prototype.bytesPerElement=8,a3(oU,"StructArrayLayout2f8");class oj extends oh{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint32=new Uint32Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(e,i,r,a){let n=this.length;return this.resize(n+1),this.emplace(n,e,i,r,a)}emplace(e,i,r,a,n){let o=6*e;return this.uint32[3*e+0]=i,this.uint16[o+2]=r,this.uint16[o+3]=a,this.uint16[o+4]=n,e}}oj.prototype.bytesPerElement=12,a3(oj,"StructArrayLayout1ul3ui12");class oG extends oh{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(e){let i=this.length;return this.resize(i+1),this.emplace(i,e)}emplace(e,i){return this.uint16[+e+0]=i,e}}oG.prototype.bytesPerElement=2,a3(oG,"StructArrayLayout1ui2");class oq extends oh{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(e,i,r,a,n,o,s,l,h,u,c,d,p,f,m,_){let g=this.length;return this.resize(g+1),this.emplace(g,e,i,r,a,n,o,s,l,h,u,c,d,p,f,m,_)}emplace(e,i,r,a,n,o,s,l,h,u,c,d,p,f,m,_,g){let y=16*e;return this.float32[y+0]=i,this.float32[y+1]=r,this.float32[y+2]=a,this.float32[y+3]=n,this.float32[y+4]=o,this.float32[y+5]=s,this.float32[y+6]=l,this.float32[y+7]=h,this.float32[y+8]=u,this.float32[y+9]=c,this.float32[y+10]=d,this.float32[y+11]=p,this.float32[y+12]=f,this.float32[y+13]=m,this.float32[y+14]=_,this.float32[y+15]=g,e}}oq.prototype.bytesPerElement=64,a3(oq,"StructArrayLayout16f64");class o$ extends oh{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(e,i,r,a,n,o,s){let l=this.length;return this.resize(l+1),this.emplace(l,e,i,r,a,n,o,s)}emplace(e,i,r,a,n,o,s,l){let h=10*e,u=5*e;return this.uint16[h+0]=i,this.uint16[h+1]=r,this.uint16[h+2]=a,this.uint16[h+3]=n,this.float32[u+2]=o,this.float32[u+3]=s,this.float32[u+4]=l,e}}o$.prototype.bytesPerElement=20,a3(o$,"StructArrayLayout4ui3f20");class oH extends oh{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(e){let i=this.length;return this.resize(i+1),this.emplace(i,e)}emplace(e,i){return this.int16[+e+0]=i,e}}oH.prototype.bytesPerElement=2,a3(oH,"StructArrayLayout1i2");class oZ extends oh{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer)}emplaceBack(e){let i=this.length;return this.resize(i+1),this.emplace(i,e)}emplace(e,i){return this.uint8[+e+0]=i,e}}oZ.prototype.bytesPerElement=1,a3(oZ,"StructArrayLayout1ub1");class oW extends ol{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]}}oW.prototype.size=40;class oX extends oM{get(e){return new oW(this,e)}}a3(oX,"CollisionBoxArray");class oY extends ol{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]}
7get 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}}oY.prototype.size=60;class oK extends oL{get(e){return new oY(this,e)}}a3(oK,"PlacedSymbolArray");class oJ extends ol{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]}}oJ.prototype.size=80;class oQ extends oO{get(e){return new oJ(this,e)}}a3(oQ,"SymbolInstanceArray");class o0 extends om{getoffsetX(e){return this.float32[+e+0]}}a3(o0,"GlyphOffsetArray");class o1 extends od{getx(e){return this.int16[2*e+0]}gety(e){return this.int16[2*e+1]}}a3(o1,"SymbolLineVertexArray");class o2 extends ol{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]}}o2.prototype.size=12;class o3 extends oj{get(e){return new o2(this,e)}}a3(o3,"FeatureIndexArray");class o5 extends oC{geta_centroid_pos0(e){return this.uint16[2*e+0]}geta_centroid_pos1(e){return this.uint16[2*e+1]}}a3(o5,"FillExtrusionCentroidArray");class o4 extends ol{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]}}o4.prototype.size=6;class o6 extends op{get(e){return new o4(this,e)}}a3(o6,"FillExtrusionWallArray");let o8=ou([{name:"a_pos",components:2,type:"Int16"}],4),o9=ou([{name:"a_circle_z_offset",components:1,type:"Float32"}],4),o7=ou([{name:"a_pos_3",components:3,type:"Int16"},{name:"a_pos_normal_3",components:3,type:"Int16"}]);class se{constructor(e=[]){this.segments=e}_prepareSegment(e,i,r,a){let n=this.segments[this.segments.length-1];return e>se.MAX_VERTEX_ARRAY_LENGTH&&tf(`Max vertices per segment is ${se.MAX_VERTEX_ARRAY_LENGTH}: bucket requested ${e}`),(!n||n.vertexLength+e>se.MAX_VERTEX_ARRAY_LENGTH||n.sortKey!==a)&&(n={vertexOffset:i,primitiveOffset:r,vertexLength:0,primitiveLength:0},void 0!==a&&(n.sortKey=a),this.segments.push(n)),n}prepareSegment(e,i,r,a){return this._prepareSegment(e,i.length,r.length,a)}get(){return this.segments}destroy(){for(let e of this.segments)for(let i in e.vaos)e.vaos[i].destroy()}static simpleSegment(e,i,r,a){return new se([{vertexOffset:e,primitiveOffset:i,vertexLength:r,primitiveLength:a,vaos:{},sortKey:0}])}}function st(e,i){return 256*(e=tt(Math.floor(e),0,255))+tt(Math.floor(i),0,255)}se.MAX_VERTEX_ARRAY_LENGTH=65535,a3(se,"SegmentVector");let si=ou([{name:"a_pattern",components:4,type:"Uint16"},{name:"a_pixel_ratio",components:1,type:"Float32"}]),sr=ou([{name:"a_pattern_b",components:4,type:"Uint16"}]),sa=ou([{name:"a_dash",components:4,type:"Uint16"}]);class sn{constructor(){this.ids=[],this.uniqueIds=[],this.positions=[],this.indexed=!1}
7add(e,i,r,a){this.ids.push(so(e)),this.positions.push(i,r,a)}eachPosition(e,i){let r=so(e),a=0,n=this.ids.length-1;for(;a<n;){let e=a+n>>1;this.ids[e]>=r?n=e:a=e+1}for(;this.ids[a]===r;)i(this.positions[3*a],this.positions[3*a+1],this.positions[3*a+2]),a++}static serialize(e,i){let r=new Float64Array(e.ids),a=new Uint32Array(e.positions);return function e(i,r,a,n){for(;a<n;){let o=i[a+n>>1],s=a-1,l=n+1;for(;;){do s++;while(i[s]<o);do l--;while(i[l]>o);if(s>=l)break;ss(i,s,l),ss(r,3*s,3*l),ss(r,3*s+1,3*l+1),ss(r,3*s+2,3*l+2)}l-a<n-l?(e(i,r,a,l),a=l+1):(e(i,r,l+1,n),n=l)}}(r,a,0,r.length-1),i&&(i.add(r.buffer),i.add(a.buffer)),{ids:r,positions:a}}static deserialize(e){let i,r=new sn;for(let a of(r.ids=e.ids,r.positions=e.positions,r.ids))a!==i&&r.uniqueIds.push(a),i=a;return r.indexed=!0,r}}function so(e){let i=+e;return Number.isSafeInteger(i)?i:t9(String(e))}function ss(e,i,r){let a=e[i];e[i]=e[r],e[r]=a}a3(sn,"FeaturePositionMap");class sl{constructor(e){this.gl=e.gl,this.initialized=!1}fetchUniformLocation(e,i){return this.location||this.initialized||(this.location=this.gl.getUniformLocation(e,i),this.initialized=!0),!!this.location}set(e,i,r){throw Error("Uniform#set() must be implemented by each concrete Uniform")}}class sh extends sl{constructor(e){super(e),this.current=0}set(e,i,r){this.fetchUniformLocation(e,i)&&this.current!==r&&(this.current=r,this.gl.uniform1i(this.location,r))}}class su extends sl{constructor(e){super(e),this.current=0}set(e,i,r){this.fetchUniformLocation(e,i)&&this.current!==r&&(this.current=r,this.gl.uniform1f(this.location,r))}}class sc extends sl{constructor(e){super(e),this.current=[0,0]}set(e,i,r){this.fetchUniformLocation(e,i)&&(r[0]===this.current[0]&&r[1]===this.current[1]||(this.current=r,this.gl.uniform2f(this.location,r[0],r[1])))}}class sd extends sl{constructor(e){super(e),this.current=[0,0,0]}set(e,i,r){this.fetchUniformLocation(e,i)&&(r[0]===this.current[0]&&r[1]===this.current[1]&&r[2]===this.current[2]||(this.current=r,this.gl.uniform3f(this.location,r[0],r[1],r[2])))}}class sp extends sl{constructor(e){super(e),this.current=[0,0,0,0]}set(e,i,r){this.fetchUniformLocation(e,i)&&(r[0]===this.current[0]&&r[1]===this.current[1]&&r[2]===this.current[2]&&r[3]===this.current[3]||(this.current=r,this.gl.uniform4f(this.location,r[0],r[1],r[2],r[3])))}}class sf extends sl{constructor(e){super(e),this.current=ih.transparent.toPremultipliedRenderColor(null)}set(e,i,r){this.fetchUniformLocation(e,i)&&(r.r===this.current.r&&r.g===this.current.g&&r.b===this.current.b&&r.a===this.current.a||(this.current=r,this.gl.uniform4f(this.location,r.r,r.g,r.b,r.a)))}}let sm=new Float32Array(16);class s_ extends sl{constructor(e){super(e),this.current=sm}set(e,i,r){if(this.fetchUniformLocation(e,i)){if(r[12]!==this.current[12]||r[0]!==this.current[0])return this.current=r,void this.gl.uniformMatrix4fv(this.location,!1,r);for(let e=1;e<16;e++)if(r[e]!==this.current[e]){this.current=r,this.gl.uniformMatrix4fv(this.location,!1,r);break}}}}let sg=new Float32Array(9),sy=new Float32Array(4);class sx extends sl{constructor(e){super(e),this.current=sy}set(e,i,r){if(this.fetchUniformLocation(e,i)){for(let e=0;e<4;e++)if(r[e]!==this.current[e]){this.current=r,this.gl.uniformMatrix2fv(this.location,!1,r);break}}}}function sv(e){return[st(255*e.r,255*e.g),st(255*e.b,255*e.a)]}class sb{constructor(e,i,r,a){this.value=e,this.uniformNames=i.map(e=>`u_${e}`),this.type=r,this.context=a}setUniform(e,i,r,a,n){let o=a.constantOr(this.value);i.set(e,n,o instanceof ih?o.toPremultipliedRenderColor(this.lutExpression&&"constant"===this.lutExpression.kind&&"none"===this.lutExpression.value?null:this.context.lut):o)}getBinding(e,i){return"color"===this.type?new sf(e):new su(e)}}class sw{constructor(e,i){this.uniformNames=i.map(e=>`u_${e}`),this.pattern=null,this.patternTransition=null,this.pixelRatio=1}setConstantPatternPositions(e,i){this.pixelRatio=e.pixelRatio||1,this.pattern=e.tl.concat(e.br),this.patternTransition=i?i.tl.concat(i.br):this.pattern}setUniform(e,i,r,a,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&&i.set(e,n,o)}getBinding(e,i){return"u_pattern"===i||"u_pattern_b"===i||"u_dash"===i?new sp(e):new su(e)}}class sT{constructor(e,i,r,a){this.expression=e,this.type=r,this.maxValue=0,this.paintVertexAttributes=i.map(e=>({name:`a_${e}`,type:"Float32",components:"color"===r?2:1,offset:0})),this.paintVertexArray=new a}populatePaintArray(e,i,r,a,n,o,s,l){let h=this.paintVertexArray.length,u="composite"===this.expression.kind||"source"===this.expression.kind?this.expression.evaluate(new nV(0,{brightness:o,worldview:l}),i,{},n,a,s):"constant"===this.expression.kind&&this.expression.value,c=!!this.lutExpression&&"none"===("composite"===this.lutExpression.kind||"source"===this.lutExpression.kind?this.lutExpression.evaluate(new nV(0,{brightness:o,worldview:l}),i,{},n,a,s):this.lutExpression.value);this.paintVertexArray.resize(e),this._setPaintValue(h,e,u,c?null:this.context.lut)}updatePaintArray(e,i,r,a,n,o,s,l){let h="composite"===this.expression.kind||"source"===this.expression.kind?this.expression.evaluate({zoom:0,brightness:s,worldview:l},r,a,void 0,n):"constant"===this.expression.kind&&this.expression.value,u=!!this.lutExpression&&"none"===("composite"===this.lutExpression.kind||"source"===this.lutExpression.kind?this.lutExpression.evaluate(new nV(0,{brightness:s,worldview:l}),r,a,void 0,n):this.lutExpression.value);this._setPaintValue(e,i,h,u?null:this.context.lut)}_setPaintValue(e,i,r,a){if("color"===this.type){let n=sv(r.toPremultipliedRenderColor(a));for(let r=e;r<i;r++)this.paintVertexArray.emplace(r,n[0],n[1])}else{for(let a=e;a<i;a++)this.paintVertexArray.emplace(a,r);this.maxValue=Math.max(this.maxValue,Math.abs(r))}}upload(e){this.paintVertexArray&&this.paintVertexArray.arrayBuffer&&(this.paintVertexBuffer&&this.paintVertexBuffer.buffer?this.paintVertexBuffer.updateData(this.paintVertexArray):this.paintVertexBuffer=e.createVertexBuffer(this.paintVertexArray,this.paintVertexAttributes,this.lutExpression&&"constant"!==this.lutExpression.kind&&(this.lutExpression.isStateDependent||!this.lutExpression.isLightConstant)||"constant"!==this.expression.kind&&(this.expression.isStateDependent||!this.expression.isLightConstant)))}destroy(){this.paintVertexBuffer&&this.paintVertexBuffer.destroy()}}class sS{constructor(e,i,r,a,n,o){this.expression=e,this.uniformNames=i.map(e=>`u_${e}_t`),this.type=r,this.useIntegerZoom=a,this.context=n,this.maxValue=0,this.paintVertexAttributes=i.map(e=>({name:`a_${e}`,type:"Float32",components:"color"===r?4:2,offset:0})),this.paintVertexArray=new o}populatePaintArray(e,i,r,a,n,o,s,l){let h=this.expression.evaluate(new nV(this.context.zoom,{brightness:o,worldview:l}),i,{},n,a,s),u=this.expression.evaluate(new nV(this.context.zoom+1,{brightness:o,worldview:l}),i,{},n,a,s),c=!!this.lutExpression&&"none"===("composite"===this.lutExpression.kind||"source"===this.lutExpression.kind?this.lutExpression.evaluate(new nV(0,{brightness:o,worldview:l}),i,{},n,a,s):this.lutExpression.value),d=this.paintVertexArray.length;this.paintVertexArray.resize(e),this._setPaintValue(d,e,h,u,c?null:this.context.lut)}updatePaintArray(e,i,r,a,n,o,s,l){let h=this.expression.evaluate({zoom:this.context.zoom,brightness:s,worldview:l},r,a,void 0,n),u=this.expression.evaluate({zoom:this.context.zoom+1,brightness:s,worldview:l},r,a,void 0,n),c=!!this.lutExpression&&"none"===("composite"===this.lutExpression.kind||"source"===this.lutExpression.kind?this.lutExpression.evaluate(new nV(0,{brightness:s,worldview:l}),r,a,void 0,n):this.lutExpression.value);this._setPaintValue(e,i,h,u,c?null:this.context.lut)}_setPaintValue(e,i,r,a,n){if("color"===this.type){let a=sv(r.toPremultipliedRenderColor(n)),o=sv(r.toPremultipliedRenderColor(n));for(let r=e;r<i;r++)this.paintVertexArray.emplace(r,a[0],a[1],o[0],o[1])}else{for(let n=e;n<i;n++)this.paintVertexArray.emplace(n,r,a);
7this.maxValue=Math.max(this.maxValue,Math.abs(r),Math.abs(a))}}upload(e){this.paintVertexArray&&this.paintVertexArray.arrayBuffer&&(this.paintVertexBuffer&&this.paintVertexBuffer.buffer?this.paintVertexBuffer.updateData(this.paintVertexArray):this.paintVertexBuffer=e.createVertexBuffer(this.paintVertexArray,this.paintVertexAttributes,this.expression.isStateDependent||!this.expression.isLightConstant))}destroy(){this.paintVertexBuffer&&this.paintVertexBuffer.destroy()}setUniform(e,i,r,a,n){let o=this.useIntegerZoom?Math.floor(r.zoom):r.zoom,s=tt(this.expression.interpolationFactor(o,this.context.zoom,this.context.zoom+1),0,1);i.set(e,n,s)}getBinding(e,i){return new su(e)}}class sE{constructor(e,i,r,a,n){this.expression=e,this.layerId=n,this.paintVertexAttributes=("array"===r?sa:si).members;for(let e=0;e<i.length;++e);this.paintVertexArray=new a,this.paintTransitionVertexArray=new ow}populatePaintArray(e,i,r,a){let n=this.paintVertexArray.length;this.paintVertexArray.resize(e),this._setPaintValues(n,e,i.patterns&&i.patterns[this.layerId],r)}updatePaintArray(e,i,r,a,n,o,s){this._setPaintValues(e,i,r.patterns&&r.patterns[this.layerId],o)}_setPaintValues(e,i,r,a){if(!a||!r)return;let n=a[r[0]],o=a[r[1]];if(n){if(n){let{tl:r,br:a,pixelRatio:o}=n;for(let n=e;n<i;n++)this.paintVertexArray.emplace(n,r[0],r[1],a[0],a[1],o)}if(o){this.paintTransitionVertexArray.resize(this.paintVertexArray.length);let{tl:r,br:a}=o;for(let n=e;n<i;n++)this.paintTransitionVertexArray.emplace(n,r[0],r[1],a[0],a[1])}}}upload(e){let i=this.expression.isStateDependent||!this.expression.isLightConstant;this.paintVertexArray&&this.paintVertexArray.arrayBuffer&&(this.paintVertexBuffer=e.createVertexBuffer(this.paintVertexArray,this.paintVertexAttributes,i)),this.paintTransitionVertexArray&&this.paintTransitionVertexArray.length&&(this.paintTransitionVertexBuffer=e.createVertexBuffer(this.paintTransitionVertexArray,sr.members,i))}destroy(){this.paintVertexBuffer&&this.paintVertexBuffer.destroy(),this.paintTransitionVertexBuffer&&this.paintTransitionVertexBuffer.destroy()}}class sI{constructor(e,i,r=()=>!0){this.binders={},this._buffers=[],this.context=i;let a=[];for(let n in e.paint._values){let o=e.paint.get(n);if(n.endsWith("-use-theme")||!r(n)||!(o instanceof nZ&&aO(o.property.specification)))continue;let s=function(e,i){return sC[e]||[e.replace(`${i}-`,"").replace(/-/g,"_")]}(n,e.type),l=o.value,h=o.property.specification.type,u=!!o.property.useIntegerZoom,c="line-dasharray"===n||n.endsWith("pattern"),d=e.paint.get(`${n}-use-theme`),p="line-dasharray"===n&&"constant"!==e.layout.get("line-cap").value.kind||d&&"constant"!==d.value.kind;if("constant"!==l.kind||p)if("source"===l.kind||p||c){let i=sz(n,h,"source");this.binders[n]=c?new sE(l,s,h,i,e.id):new sT(l,s,h,i),a.push(`/a_${n}`)}else{let e=sz(n,h,"composite");this.binders[n]=new sS(l,s,h,u,i,e),a.push(`/z_${n}`)}else this.binders[n]=c?new sw(l.value,s):new sb(l.value,s,h,i),a.push(`/u_${n}`);d&&(this.binders[n].lutExpression=d.value)}this.cacheKey=a.sort().join("")}getMaxValue(e){let i=this.binders[e];return i instanceof sT||i instanceof sS?i.maxValue:0}populatePaintArrays(e,i,r,a,n,o,s,l){for(let h in this.binders){let u=this.binders[h];u.context=this.context,(u instanceof sT||u instanceof sS||u instanceof sE)&&u.populatePaintArray(e,i,r,a,n,o,s,l)}}setConstantPatternPositions(e,i){for(let r in this.binders){let a=this.binders[r];a instanceof sw&&a.setConstantPatternPositions(e,i)}}getPatternTransitionVertexBuffer(e){let i=this.binders[e];return i instanceof sE?i.paintTransitionVertexBuffer:null}updatePaintArrays(e,i,r,a,n,o,s,l,h,u){let c=!1,d=Object.keys(e),p=0!==d.length&&!l,f=p?d:i.uniqueIds;for(let l in this.context.lut=n.lut,this.binders){let d=this.binders[l];if(d.context=this.context,(d instanceof sT||d instanceof sS||d instanceof sE)&&d.expression&&d.expression.kind&&"constant"!==d.expression.kind&&(!0===d.expression.isStateDependent||!1===d.expression.isLightConstant)){for(let r of(d.expression=n.paint.get(l).value,f)){let n=e[r.toString()];i.eachPosition(r,(e,i,r)=>{let l=a.feature(e);d.updatePaintArray(i,r,l,n,o,s,h,u)})}if(!p)for(let i of r.uniqueIds){let n=e[i.toString()];r.eachPosition(i,(e,i,r)=>{let l=a.feature(e);d.updatePaintArray(i,r,l,n,o,s,h,u)})}c=!0}}return c}defines(){let e=[];for(let i in this.binders){let r=this.binders[i];(r instanceof sb||r instanceof sw)&&e.push(...r.uniformNames.map(e=>`#define HAS_UNIFORM_${e}`))}return e}getPaintVertexBuffers(){return this._buffers}getUniforms(e){let i=[];for(let r in this.binders){let a=this.binders[r];if(a instanceof sb||a instanceof sw||a instanceof sS)for(let n of a.uniformNames)i.push({name:n,property:r,binding:a.getBinding(e,n)})}return i}setUniforms(e,i,r,a,n){for(let{name:i,property:o,binding:s}of r)this.binders[o].setUniform(e,s,n,a.get(o),i)}updatePaintBuffers(){for(let e in this._buffers=[],this.binders){let i=this.binders[e];(i instanceof sT||i instanceof sS||i instanceof sE)&&i.paintVertexBuffer&&this._buffers.push(i.paintVertexBuffer),i instanceof sE&&i.paintTransitionVertexBuffer&&this._buffers.push(i.paintTransitionVertexBuffer)}}upload(e){for(let i in this.binders){let r=this.binders[i];(r instanceof sT||r instanceof sS||r instanceof sE)&&r.upload(e)}this.updatePaintBuffers()}destroy(){for(let e in this.binders){let i=this.binders[e];(i instanceof sT||i instanceof sS||i instanceof sE)&&i.destroy()}}}class sA{constructor(e,i,r=()=>!0){for(let a of(this.programConfigurations={},e))this.programConfigurations[a.id]=new sI(a,i,r);this.needsUpload=!1,this._featureMap=new sn,this._featureMapWithoutIds=new sn,this._bufferOffset=0,this._idlessCounter=0}populatePaintArrays(e,i,r,a,n,o,s,l,h){for(let r in this.programConfigurations)this.programConfigurations[r].populatePaintArrays(e,i,a,n,o,s,l,h);void 0!==i.id?this._featureMap.add(i.id,r,this._bufferOffset,e):(this._featureMapWithoutIds.add(this._idlessCounter,r,this._bufferOffset,e),this._idlessCounter+=1),this._bufferOffset=e,this.needsUpload=!0}updatePaintArrays(e,i,r,a,n,o,s,l){for(let h of r)this.needsUpload=this.programConfigurations[h.id].updatePaintArrays(e,this._featureMap,this._featureMapWithoutIds,i,h,a,n,o,s||0,l)||this.needsUpload}get(e){return this.programConfigurations[e]}upload(e){if(this.needsUpload){for(let i in this.programConfigurations)this.programConfigurations[i].upload(e);this.needsUpload=!1}}destroy(){for(let e in this.programConfigurations)this.programConfigurations[e].destroy()}}let sC={"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":["ga
7pwidth"],"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"]},sM={"line-pattern":{source:ob,composite:ob},"fill-pattern":{source:ob,composite:ob},"fill-extrusion-pattern":{source:ob,composite:ob},"line-dasharray":{source:ow,composite:ow}},sP={color:{source:oU,composite:oI},number:{source:om,composite:oU}};function sz(e,i,r){let a=sM[e];return a&&a[r]||sP[i][r]}a3(sb,"ConstantBinder"),a3(sw,"PatternConstantBinder"),a3(sT,"SourceExpressionBinder"),a3(sE,"PatternCompositeBinder"),a3(sS,"CompositeExpressionBinder"),a3(sI,"ProgramConfiguration",{omit:["_buffers"]}),a3(sA,"ProgramConfigurationSet");let sR=8192/Math.PI/2,sD=[64,32,16],sL=-sR;function sO(e,i,r,a=sR){return[e*Math.sin(r*=e4)*a,-i*a,e*Math.cos(r)*a]}function sF(e,i,r){return sO(Math.cos(e*e4),Math.sin(e*e4),i,r)}let sk=2*Math.PI*6371008.8;class sB{constructor(e,i){if(isNaN(e)||isNaN(i))throw Error(`Invalid LngLat object: (${e}, ${i})`);if(this.lng=+e,this.lat=+i,this.lat>90||this.lat<-90)throw Error("Invalid LngLat latitude value: must be between -90 and 90")}wrap(){return new sB(tr(this.lng,-180,180),this.lat)}toArray(){return[this.lng,this.lat]}toString(){return`LngLat(${this.lng}, ${this.lat})`}distanceTo(e){let i=Math.PI/180,r=this.lat*i,a=e.lat*i;return 6371008.8*Math.acos(Math.min(Math.sin(r)*Math.sin(a)+Math.cos(r)*Math.cos(a)*Math.cos((e.lng-this.lng)*i),1))}toBounds(e=0){let i=360*e/0x2637f09,r=i/Math.cos(Math.PI/180*this.lat);return new sN({lng:this.lng-r,lat:this.lat-i},{lng:this.lng+r,lat:this.lat+i})}toEcef(e){return sF(this.lat,this.lng,sR+e*sR/6371008.8)}static convert(e){if(e instanceof sB)return e;if(Array.isArray(e)&&(2===e.length||3===e.length))return new sB(Number(e[0]),Number(e[1]));if(!Array.isArray(e)&&"object"==typeof e&&null!==e)return new sB(Number("lng"in e?e.lng:e.lon),Number(e.lat));throw Error("`LngLatLike` argument must be specified as a LngLat instance, an object {lng: <lng>, lat: <lat>}, an object {lon: <lng>, lat: <lat>}, or an array of [<lng>, <lat>]")}}class sN{constructor(e,i){e&&(i?this.setSouthWest(e).setNorthEast(i):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 sB?new sB(e.lng,e.lat):sB.convert(e),this}setSouthWest(e){return this._sw=e instanceof sB?new sB(e.lng,e.lat):sB.convert(e),this}extend(e){let i,r,a=this._sw,n=this._ne;if(e instanceof sB)i=e,r=e;else{if(!(e instanceof sN))return Array.isArray(e)?4===e.length||e.every(Array.isArray)?this.extend(sN.convert(e)):this.extend(sB.convert(e)):"object"==typeof e&&null!==e&&e.hasOwnProperty("lat")&&(e.hasOwnProperty("lon")||e.hasOwnProperty("lng"))?this.extend(sB.convert(e)):this;if(i=e._sw,r=e._ne,!i||!r)return this}return a||n?(a.lng=Math.min(i.lng,a.lng),a.lat=Math.min(i.lat,a.lat),n.lng=Math.max(r.lng,n.lng),n.lat=Math.max(r.lat,n.lat)):(this._sw=new sB(i.lng,i.lat),this._ne=new sB(r.lng,r.lat)),this}getCenter(){return new sB((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 sB(this.getWest(),this.getNorth())}getSouthEast(){return new sB(this.getEast(),this.getSouth())}getWest(){return this._sw.lng}getSouth(){return this._sw.lat}getEast(){return this._ne.lng}getNorth(){return this._ne.lat}toArray(){return[this._sw.toArray(),this._ne.toArray()]}toString(){return`LngLatBounds(${this._sw.toString()}, ${this._ne.toString()})`}isEmpty(){return!(this._sw&&this._ne)}contains(e){let{lng:i,lat:r}=sB.convert(e),a=this._sw.lng<=i&&i<=this._ne.lng;return this._sw.lng>this._ne.lng&&(a=this._sw.lng>=i&&i>=this._ne.lng),this._sw.lat<=r&&r<=this._ne.lat&&a}static convert(e){if(e)return e instanceof sN?e:new sN(e)}}function sV(e){return sk*Math.cos(e*Math.PI/180)}function sU(e){return(180+e)/360}function sj(e){return(180-180/Math.PI*Math.log(Math.tan(Math.PI/4+e*Math.PI/360)))/360}function sG(e){return 360*e-180}function sq(e){return 360/Math.PI*Math.atan(Math.exp((180-360*e)*Math.PI/180)
7)-90}function s$(e,i){return e*sV(sq(i))}function sH(e){return Math.cos(tt(e,-85.051129,85.051129)*e4)}function sZ(e,i){let r=Math.pow(2,tt(i,0,25.5));return sH(e)*sk/(512*r)}function sW(e){return 1/Math.cos(e*Math.PI/180)}function sX(e,i=0){let r=Math.exp(Math.PI*(1-(e.y+i/8192)/(1<<e.z)*2));return 0x4c6fe12*r/(r*r+1)/8192/(1<<e.z)}class sY{constructor(e,i,r=0){this.x=+e,this.y=+i,this.z=+r}static fromLngLat(e,i=0){let r=sB.convert(e);return new sY(sU(r.lng),sj(r.lat),i/sV(r.lat))}toLngLat(){return new sB(sG(this.x),sq(this.y))}toAltitude(){return s$(this.z,this.y)}meterInMercatorCoordinateUnits(){return 1/sk*sW(sq(this.y))}}function sK(e,i,r){let a=e[0],n=a.x,o=a.y;i(a);let s=[a];for(let l=1;l<e.length;l++){let h=e[l],{x:u,y:c}=h;i(h),function e(i,r,a,n,o,s,l,h,u){let c=(r+n)/2,d=(a+o)/2,p=new e3(c,d);h(p),function(e,i,r,a,n,o){let s=r-n,l=a-o;return Math.abs((a-i)*s-(r-e)*l)/Math.hypot(s,l)}(p.x,p.y,s.x,s.y,l.x,l.y)>=u?(e(i,r,a,c,d,s,p,h,u),e(i,c,d,n,o,p,l,h,u)):i.push(l)}(s,n,o,u,c,a,h,i,r),n=u,o=c,a=h}return s}let sJ=-16383-1;function sQ(e,i,r){let a=e.loadGeometry(),n=e.extent,o=8192/n;if(i&&r&&r.projection.isReprojectedInTileSpace){let o=1<<i.z,{scale:s,x:l,y:h,projection:u}=r,c=e=>{let r=sG((i.x+e.x/n)/o),a=sq((i.y+e.y/n)/o),c=u.project(r,a);e.x=(c.x*s-l)*n,e.y=(c.y*s-h)*n};for(let i=0;i<a.length;i++)if(1!==e.type)a[i]=sK(a[i],c,1);else{let e=[];for(let r of a[i])r.x<0||r.x>=n||r.y<0||r.y>=n||(c(r),e.push(r));a[i]=e}}for(let e of a)for(let i of e){var s=i,l=o;let e=Math.round(s.x*l),r=Math.round(s.y*l);s.x=tt(e,sJ,16383),s.y=tt(r,sJ,16383),(e<s.x||e>s.x+1||r<s.y||r>s.y+1)&&tf("Geometry exceeds allowed extent, reduce your vector tile buffer size")}return a}function s0(e,i){return{type:e.type,id:e.id,properties:e.properties,geometry:i?sQ(e):[]}}class s1{constructor(e,i,r,a,n){this.properties={},this.extent=r,this.type=0,this.id=void 0,this._pbf=e,this._geometry=-1,this._keys=a,this._values=n,e.readFields(s2,this,i)}loadGeometry(){let e=this._pbf;e.pos=this._geometry;let i=e.readVarint()+e.pos,r=[],a,n=1,o=0,s=0,l=0;for(;e.pos<i;){if(o<=0){let i=e.readVarint();n=7&i,o=i>>3}if(o--,1===n||2===n)s+=e.readSVarint(),l+=e.readSVarint(),1===n&&(a&&r.push(a),a=[]),a&&a.push(new e3(s,l));else{if(7!==n)throw Error(`unknown command ${n}`);a&&a.push(a[0].clone())}}return a&&r.push(a),r}bbox(){let e=this._pbf;e.pos=this._geometry;let i=e.readVarint()+e.pos,r=1,a=0,n=0,o=0,s=1/0,l=-1/0,h=1/0,u=-1/0;for(;e.pos<i;){if(a<=0){let i=e.readVarint();r=7&i,a=i>>3}if(a--,1===r||2===r)n+=e.readSVarint(),o+=e.readSVarint(),n<s&&(s=n),n>l&&(l=n),o<h&&(h=o),o>u&&(u=o);else if(7!==r)throw Error(`unknown command ${r}`)}return[s,h,l,u]}toGeoJSON(e,i,r){let a,n=this.extent*Math.pow(2,r),o=this.extent*e,s=this.extent*i,l=this.loadGeometry();function h(e){return[360*(e.x+o)/n-180,360/Math.PI*Math.atan(Math.exp((1-2*(e.y+s)/n)*Math.PI))-90]}function u(e){return e.map(h)}if(1===this.type){let e=[];for(let i of l)e.push(i[0]);let i=u(e);a=1===e.length?{type:"Point",coordinates:i[0]}:{type:"MultiPoint",coordinates:i}}else if(2===this.type){let e=l.map(u);a=1===e.length?{type:"LineString",coordinates:e[0]}:{type:"MultiLineString",coordinates:e}}else{if(3!==this.type)throw Error("unknown feature type");{let e=function(e){let i,r,a=e.length;if(a<=1)return[e];let n=[];for(let o=0;o<a;o++){let a=function(e){let i=0;for(let r,a,n=0,o=e.length,s=o-1;n<o;s=n++)r=e[n],i+=((a=e[s]).x-r.x)*(r.y+a.y);return i}(e[o]);0!==a&&(void 0===r&&(r=a<0),r===a<0?(i&&n.push(i),i=[e[o]]):i&&i.push(e[o]))}return i&&n.push(i),n}(l),i=[];for(let r of e)i.push(r.map(u));a=1===i.length?{type:"Polygon",coordinates:i[0]}:{type:"MultiPolygon",coordinates:i}}}let c={type:"Feature",geometry:a,properties:this.properties};return null!=this.id&&(c.id=this.id),c}}function s2(e,i,r){1===e?i.id=r.readVarint():2===e?function(e,i){let r=e.readVarint()+e.pos;for(;e.pos<r;){let r=i._keys[e.readVarint()],a=i._values[e.readVarint()];i.properties[r]=a}}(r,i):3===e?i.type=r.readVarint():4===e&&(i._geometry=r.pos)}s1.types=["Unknown","Point","LineString","Polygon"];class s3{constructor(e,i){this.version=1,this.name="",this.extent=4096,this.length=0,this._pbf=e,this._keys=[],this._values=[],this._features=[],e.readFields(s5,this,i),this.length=this._features.length}feature(e){if(e<0||e>=this._features.length)throw Error("feature index out of bounds");this._pbf.pos=this._features[e];let i=this._pbf.readVarint()+this._pbf.pos;return new s1(this._pbf,i,this.extent,this._keys,this._values)}}function s5(e,i,r){15===e?i.version=r.readVarint():1===e?i.name=r.readString():5===e?i.extent=r.readVarint():2===e?i._features.push(r.pos):3===e?i._keys.push(r.readString()):4===e&&i._values.push(function(e){let i=null,r=e.readVarint()+e.pos;for(;e.pos<r;){let r=e.readVarint()>>3;i=1===r?e.readString():2===r?e.readFloat():3===r?e.readDouble():4===r?e.readVarint64():5===r?e.readVarint():6===r?e.readSVarint():7===r?e.readBoolean():null}if(null==i)throw Error("unknown feature value");return i}(r))}class s4{constructor(e,i){this.layers=e.readFields(s6,{},i)}}function s6(e,i,r){if(3===e){let e=new s3(r,r.readVarint()+r.pos);e.length&&(i[e.name]=e)}}let s8="3d_elevation_id",s9="level";
7class s7{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,i){return this._valid&&e(i(this._geometry)),this}require(e,i,r){return this.get(e,!0,i,r)}optional(e,i,r){return this.get(e,!1,i,r)}success(){return this._valid}get(e,i,r,a){let n=this.feature.properties.hasOwnProperty(e)?+this.feature.properties[e]:void 0;return this._valid&&void 0!==n&&!Number.isNaN(n)?r(a?a(n):n):i&&(this._valid=!1),this}}class le{constructor(e,i){this.featureFunc=e,this.vertexFunc=i}parseFeature(e,i,r){return this.featureFunc(e,i,r)}parseVertex(e,i,r){return this.vertexFunc(e,i,r)}}let lt=new le((e,i,r)=>e.reset(i).require(s8,e=>{r.id=e}).optional("fixed_height_relative",e=>{r.constantHeight=e},lr.decodeRelativeHeight).geometry(e=>{r.bounds=e},rn).success(),(e,i,r)=>e.reset(i).require(s8,e=>{r.id=e}).require("elevation_idx",e=>{r.idx=e}).require("extent",e=>{r.extent=e}).require("height_relative",e=>{r.height=e},lr.decodeRelativeHeight).geometry(e=>{r.position=e},lr.getPoint).success()),li=new le((e,i,r)=>e.reset(i).require(s8,e=>{r.id=e}).optional("fixed_height",e=>{r.constantHeight=e},lr.decodeMetricHeight).geometry(e=>{r.bounds=e},rn).success(),(e,i,r)=>e.reset(i).require(s8,e=>{r.id=e}).require("elevation_idx",e=>{r.idx=e}).require("extent",e=>{r.extent=e}).require("height",e=>{r.height=e},lr.decodeMetricHeight).geometry(e=>{r.position=e},lr.getPoint).success());class lr{static getPoint(e){return eW(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?li:void 0:lt}static parse(e){let i=[],r=[],a=e.length,n=new s7;for(let o=0;o<a;o++){let a=e.feature(o),s=a.properties.version,l=lr.getVersionSchema(s);if(void 0===l){tf(`Unknown elevation feature version number ${s||"(unknown)"}`);continue}let h=a.properties.type;if(!h)continue;let u=s1.types[a.type];if("Point"===u&&"curve_point"===h){let e={};l.parseVertex(n,a,e)&&i.push(e)}else if("Polygon"===u&&"curve_meta"===h){let e={};l.parseFeature(n,a,e)&&r.push(e)}}return{vertices:i,features:r}}}class la{constructor(e,i){this.pos=e,this.dir=i}intersectsPlane(e,i,r){let a=e0(i,this.dir);if(1e-6>Math.abs(a))return!1;let n=((e[0]-this.pos[0])*i[0]+(e[1]-this.pos[1])*i[1])/a;return r[0]=this.pos[0]+this.dir[0]*n,r[1]=this.pos[1]+this.dir[1]*n,!0}}class ln{constructor(e,i){this.pos=e,this.dir=i}intersectsPlane(e,i,r){let a=eA(i,this.dir);if(1e-6>Math.abs(a))return!1;let n=((e[0]-this.pos[0])*i[0]+(e[1]-this.pos[1])*i[1]+(e[2]-this.pos[2])*i[2])/a;return r[0]=this.pos[0]+this.dir[0]*n,r[1]=this.pos[1]+this.dir[1]*n,r[2]=this.pos[2]+this.dir[2]*n,!0}closestPointOnSphere(e,i,r){var a,n,o,s,l,h,u;if(a=this.pos,n=a[0],o=a[1],s=a[2],l=e[0],h=e[1],u=e[2],Math.abs(n-l)<=1e-6*Math.max(1,Math.abs(n),Math.abs(l))&&Math.abs(o-h)<=1e-6*Math.max(1,Math.abs(o),Math.abs(h))&&Math.abs(s-u)<=1e-6*Math.max(1,Math.abs(s),Math.abs(u))||0===i)return r[0]=r[1]=r[2]=0,!1;let[c,d,p]=this.dir,f=this.pos[0]-e[0],m=this.pos[1]-e[1],_=this.pos[2]-e[2],g=c*c+d*d+p*p,y=2*(f*c+m*d+_*p),x=y*y-4*g*(f*f+m*m+_*_-i*i);if(x<0){let e=Math.max(-y/2,0),a=f+c*e,n=m+d*e,o=_+p*e,s=Math.hypot(a,n,o);return r[0]=a*i/s,r[1]=n*i/s,r[2]=o*i/s,!1}{let e=(-y-Math.sqrt(x))/(2*g);if(e<0){let e=Math.hypot(f,m,_);return r[0]=f*i/e,r[1]=m*i/e,r[2]=_*i/e,!1}return r[0]=f+c*e,r[1]=m+d*e,r[2]=_+p*e,!0}}}class lo{constructor(e,i,r,a,n){this.TL=e,this.TR=i,this.BR=r,this.BL=a,this.horizon=n}static fromInvProjectionMatrix(e,i,r){let a=[-1,1,1],n=[1,1,1],o=[1,-1,1],s=[-1,-1,1],l=eP(a,a,e),h=eP(n,n,e);return new lo(l,h,eP(o,o,e),eP(s,s,e),i/r)}}function ls(e,i,r){let a=1/0,n=-1/0,o=[];for(let s of e){eg(o,s,i);let e=eA(o,r);a=Math.min(a,e),n=Math.max(n,e)}return[a,n]}function ll(e,i){let r=!0;for(let a=0;a<e.planes.length;a++){let n=e.planes[a],o=0;for(let e=0;e<i.length;e++)o+=+(eA(n,i[e])+n[3]>=0);if(0===o)return 0;o!==i.length&&(r=!1)}return r?2:1}function lh(e,i){for(let r of e.projections){let a=ls(i,e.points[0],r.axis);if(r.projection[1]<a[0]||r.projection[0]>a[1])return 0}return 1}function lu(e,i){let r=0,a=[0,0,0,0];for(let n=0;n<e.length;n++)a[0]=e[n][0],a[1]=e[n][1],a[2]=e[n][2],a[3]=1,a[0]*i[0]+a[1]*i[1]+a[2]*i[2]+a[3]*i[3]>=0&&r++;return r}class lc{constructor(e,i){for(let r of(this.points=e||Array(8).fill([0,0,0]),this.planes=i||Array(6).fill([
70,0,0,0]),this.bounds=ld.fromPoints(this.points),this.projections=[],this.frustumEdges=[eg([],this.points[2],this.points[3]),eg([],this.points[0],this.points[3]),eg([],this.points[4],this.points[0]),eg([],this.points[5],this.points[1]),eg([],this.points[6],this.points[2]),eg([],this.points[7],this.points[3])],this.frustumEdges)){let e=[0,-r[2],r[1]],i=[r[2],0,-r[0]];this.projections.push({axis:e,projection:ls(this.points,this.points[0],e)}),this.projections.push({axis:i,projection:ls(this.points,this.points[0],i)})}}static fromInvProjectionMatrix(e,i,r,a){let n=Math.pow(2,r),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(r=>{var o;let s=eB([],r,e),l=1/s[3]/i*n;return s[0]=s[0]*(o=[l,l,a?1/s[3]:l,l])[0],s[1]=s[1]*o[1],s[2]=s[2]*o[2],s[3]=s[3]*o[3],s}),s=[[0,1,2],[6,5,4],[0,3,7],[2,1,5],[3,2,6],[0,4,5]].map(e=>{let i=eI([],eC([],eg([],o[e[0]],o[e[1]]),eg([],o[e[2]],o[e[1]]))),r=-eA(i,o[e[1]]);return i.concat(r)}),l=[];for(let e=0;e<o.length;e++)l.push([o[e][0],o[e][1],o[e][2]]);return new lc(l,s)}intersectsPrecise(e,i,r){for(let r=0;r<i.length;r++)if(!lu(e,i[r]))return 0;for(let i=0;i<this.planes.length;i++)if(!lu(e,this.planes[i]))return 0;for(let i of r)for(let r of this.frustumEdges){let a=eC([],i,r),n=ep(a);if(0===n)continue;eb(a,a,1/n);let o=ls(this.points,this.points[0],a),s=ls(e,this.points[0],a);if(o[0]>s[1]||s[0]>o[1])return 0}return 1}containsPoint(e){for(let i of this.planes){let r=i[3];if(eA([i[0],i[1],i[2]],e)+r<0)return!1}return!0}}class ld{static fromPoints(e){let i=[1/0,1/0,1/0],r=[-1/0,-1/0,-1/0];for(let a of e)ex(i,i,a),ev(r,r,a);return new ld(i,r)}static fromTileIdAndHeight(e,i,r){let a=1<<e.canonical.z,n=e.canonical.x,o=e.canonical.y;return new ld([n/a,o/a,i],[(n+1)/a,(o+1)/a,r])}static applyTransform(e,i){let r=e.getCorners();for(let e=0;e<r.length;++e)eP(r[e],r[e],i);return ld.fromPoints(r)}static applyTransformFast(e,i){let r=[i[12],i[13],i[14]],a=[...r];for(let n=0;n<3;n++)for(let o=0;o<3;o++){let s=i[4*o+n],l=s*e.min[o],h=s*e.max[o];r[n]+=Math.min(l,h),a[n]+=Math.max(l,h)}return new ld(r,a)}static projectAabbCorners(e,i){let r=e.getCorners();for(let e=0;e<r.length;++e)eP(r[e],r[e],i);return r}constructor(e,i){this.min=e,this.max=i,this.center=eb([],e_([],this.min,this.max),.5)}quadrant(e){let i=[e%2==0,e<2],r=ed(this.min),a=ed(this.max);for(let e=0;e<i.length;e++)r[e]=i[e]?this.min[e]:this.center[e],a[e]=i[e]?this.center[e]:this.max[e];return a[2]=this.max[2],new ld(r,a)}distanceX(e){return Math.max(Math.min(this.max[0],e[0]),this.min[0])-e[0]}distanceY(e){return Math.max(Math.min(this.max[1],e[1]),this.min[1])-e[1]}distanceZ(e){return Math.max(Math.min(this.max[2],e[2]),this.min[2])-e[2]}getCorners(){let e=this.min,i=this.max;return[[e[0],e[1],e[2]],[i[0],e[1],e[2]],[i[0],i[1],e[2]],[e[0],i[1],e[2]],[e[0],e[1],i[2]],[i[0],e[1],i[2]],[i[0],i[1],i[2]],[e[0],i[1],i[2]]]}intersects(e){return this.intersectsAabb(e.bounds)?ll(e,this.getCorners()):0}intersectsFlat(e){return this.intersectsAabb(e.bounds)?ll(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,i){return i||this.intersects(e)?lh(e,this.getCorners()):0}intersectsPreciseFlat(e,i){return i||this.intersectsFlat(e)?lh(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 i=0;i<3;++i)if(this.min[i]>e.max[i]||e.min[i]>this.max[i])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 i=0;i<3;i++)this.min[i]=Math.min(this.min[i],e.min[i]),this.max[i]=Math.max(this.max[i],e.max[i])}encapsulatePoint(e){for(let i=0;i<3;i++)this.min[i]=Math.min(this.min[i],e[i]),this.max[i]=Math.max(this.max[i],e[i])}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])]}}a3(ld,"Aabb");class lp{constructor(e,i){this.feature=e,this.metersToTile=i,this.index=0}get(){let e=this.feature.vertices[this.index],i=this.feature.vertexProps[this.index].dir,r=i[1],a=-i[0],n=(e.extent+1)*this.metersToTile;return[new e3(Math.trunc(e.position[0]+r*n),Math.trunc(e.position[1]+a*n)),new e3(Math.trunc(e.position[0]-r*n),Math.trunc(e.position[1]-a*n))]}next(){this.index++}valid(){return this.index<this.feature.vertices.length}}class lf{constructor(e,i,r,a,n,o){if(this.vertices=[],this.vertexProps=[],this.edges=[],this.edgeProps=[],this._tmpVec2=[eZ(),eZ(),eZ(),eZ(),eZ(),eZ(),eZ()],this.id=e,this.heightRange={min:r,max:r},this.safeArea=i,this.constantHeight=r,null==this.constantHeight&&(null!=this.constantHeight||0!==a.length)){for(let e of(this.vertices=a,this.edges=n,this.edges=this.edges.filter(e=>{var i,r;return e.a<this.vertices.length&&e.b<this.vertices.length&&((i=this.vertices[e.a].position)[0]!==(r=this.vertices[e.b].position)[0]||i[1]!==r[1])}),this.heightRange={min:1/0,max:-1/0},this.vertices))this.vertexProps.push({dir:eW(0,0)}),this.heightRange.min=Math.min(this.heightRange.min,e.height),this.heightRange.max=Math.max(this.heightRange.max,e.height);for(let e of this.edges){let i=this.vertices[e.a].position,r=this.vertices[e.b].position,a=eY(eZ(),r,i),n=eJ(a),o=eK(eZ(),a,1/n);this.edgeProps.push({vec:a,dir:o,len:n});let s=this.vertexProps[e.a].dir,l=this.vertexProps[e.b].dir;eX(s,s,o),eX(l,l,o)}for(let e of this.vertexProps)0===e.dir[0]&&0===e.dir[1]||eQ(e.dir,e.dir);this.tessellate(o)}}pointElevation(e){if(null!=this.constantHeight)return this.constantHeight;let i=this.getClosestEdge(e);if(null==i)return 0;let[r,a]=i;return ip(this.vertices[this.edges[r].a].height,this.vertices[this.edges[r].b].height,a)}computeSlopeNormal(e,i){let r=this.getClosestEdge(e);if(!r)return ef(0,0,1);let a=r[0],n=this.edges[a],o=this.edgeProps[a].vec,s=ef(o[0],o[1],(this.vertices[n.b].height-this.vertices[n.a].height)*i),l=ef(s[1],-s[0],0);eC(l,l,s);let h=ep(l);return h>0?eb(l,l,1/h):em(l,0,0,1)}getSafeArea(){return this.safeArea}isTunnel(){return this.heightRange.max<=-5}getClosestEdge(e){var i,r,a,n;if(0===this.edges.length)return;let o=0,s=1/0,l=0,[h,u,c,d,p,f,m]=this._tmpVec2;i=e.x,r=e.y,m[0]=i,m[1]=r;let _=new la(m,null);for(let e=0;e<this.edges.length;e++){let i=this.edges[e],r=this.edgeProps[e].dir;_.dir=r;let g=this.vertices[i.a].position,y=this.vertices[i.b].position,x=_.intersectsPlane(g,this.vertexProps[i.a].dir,h),v=_.intersectsPlane(y,this.vertexProps[i.b].dir,u);if(!x||!v)continue;eY(c,u,h),eY(d,m,h);let b=e0(c,c),w=b>0?e0(d,c)/b:0,T=tt(w,0,1),S=Math.abs((w-T)*this.edgeProps[e].len);eY(p,m,g),a=r[1],n=-r[0],f[0]=a,f[1]=n;let E=S+Math.abs(e0(p,f));E<s&&(o=e,s=E,l=T)}return[o,l]}tessellate(e){let i=ec(),r=ec(),a=ec(),n=ec();for(let o=this.edges.length-1;o>=0;--o){let s=this.edges[o].a,l=this.edges[o].b,{position:h,height:u,extent:c}=this.vertices[s],{position:d,height:p,extent:f}=this.vertices[l],m=this.vertexProps[s].dir,_=this.vertexProps[l].dir;if(em(i,h[0]/e,h[1]/e,u),em(r,d[0]/e,d[1]/e,p),em(a,m[1],-m[0],0
7),eb(a,a,c),em(n,_[1],-_[0],0),eb(n,n,f),.0025000000000000005>=this.distSqLines(ef(i[0]+.5*a[0],i[1]+.5*a[1],i[2]+.5*a[2]),ef(r[0]-.5*n[0],r[1]-.5*n[1],r[2]-.5*n[2]),ef(i[0]-.5*a[0],i[1]-.5*a[1],i[2]-.5*a[2]),ef(r[0]+.5*n[0],r[1]+.5*n[1],r[2]+.5*n[2])))continue;let g=this.vertices.length,y=eX(eZ(),h,d);this.vertices.push({position:eK(y,y,.5),height:.5*(u+p),extent:.5*(c+f)});let x=eX(eZ(),m,_);this.vertexProps.push({dir:eQ(x,x)}),this.edges.splice(o,1),this.edgeProps.splice(o,1),this.edges.push({a:s,b:g}),this.edges.push({a:g,b:l});let v=eY(eZ(),this.vertices[g].position,h),b=eJ(v),w={vec:v,dir:eK(eZ(),v,1/b),len:b};this.edgeProps.push(w),this.edgeProps.push(w)}}distSqLines(e,i,r,a){let n=eg(ec(),i,e),o=eg(ec(),a,r),s=eg(ec(),e,r),l=eA(n,n),h=eA(n,o),u=eA(n,s),c=eA(o,o),d=eA(o,s),p=l*c-h*h;return 0===p?eT(eM(n,r,a,eA(s,o)/eA(o,o)),e):eT(eM(n,e,i,(h*d-u*c)/p),eM(o,r,a,(l*d-h*u)/p))}}class lm{static parseFrom(e,i){let r=lr.parse(e);if(!r)return[];let{vertices:a,features:n}=r,o=1/sX(i);n.sort((e,i)=>e.id-i.id),a.sort((e,i)=>e.id-i.id||e.idx-i.idx);let s=[],l=0,h=(a=a.filter((e,i,r)=>i===r.findIndex(i=>i.id===e.id&&i.idx===e.idx))).length;for(let e of n){if(e.constantHeight){s.push(new lf(e.id,e.bounds,e.constantHeight));continue}for(;l!==h&&a[l].id<e.id;)l++;if(l===h||a[l].id!==e.id)continue;let i=[],r=[],n=l;for(;l!==h&&a[l].id===e.id;){let e=a[l];if(i.push({position:e.position,height:e.height,extent:e.extent}),l!==n&&a[l-1].idx===e.idx-1){let e=l-n;r.push({a:e-1,b:e})}l++}s.push(new lf(e.id,e.bounds,void 0,i,r,o))}return s}static getElevationFeature(e,i){if(!i)return;let r=+e.properties[s8];return Number.isNaN(r)?void 0:i.find(e=>e.id===r)}}class l_{constructor(e,i){this.zScale=1,this.xOffset=0,this.yOffset=0,e.equals(i)||(this.zScale=Math.pow(2,i.z-e.z),this.xOffset=(e.x*this.zScale-i.x)*8192,this.yOffset=(e.y*this.zScale-i.y)*8192)}constantElevation(e,i){if(null!=e.constantHeight)return this.computeBiasedHeight(e.constantHeight,i)}pointElevation(e,i,r){let a=this.constantElevation(i,r);return null!=a?a:(e.x=e.x*this.zScale+this.xOffset,e.y=e.y*this.zScale+this.yOffset,this.computeBiasedHeight(i.pointElevation(e),r))}computeBiasedHeight(e,i){return i<=0?e:e+i*ti(0,i,e>=0?e:Math.abs(.5*e))}}a3(lf,"ElevationFeature");class lg{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 od,this.indexArray=new oD,this.segments=new se,this.programConfigurations=new sA(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 om),this.worldview=e.worldview}updateFootprints(e,i){}populate(e,i,r,a){let n=this.layers[0],o=[],s=null;for(let{feature:i,id:l,index:h,sourceLayerIndex:u}of("circle"===n.type&&(s=n.layout.get("circle-sort-key")),e)){let e=this.layers[0]._featureFilter.needGeometry,n=s0(i,e);if(!this.layers[0]._featureFilter.filter(new nV(this.zoom,{worldview:this.worldview}),n,r))continue;let c=s?s.evaluate(n,{},r):void 0,d={id:l,properties:i.properties,type:i.type,sourceLayerIndex:u,index:h,geometry:e?n.geometry:sQ(i,r,a),patterns:{},sortKey:c};o.push(d)}s&&o.sort((e,i)=>e.sortKey-i.sortKey);let l=null;for(let n of("globe"===a.projection.name&&(this.globeExtVertexArray=new oT,l=a.projection),o)){let{geometry:a,index:o,sourceLayerIndex:s}=n,h=e[o].feature;this.addFeature(n,a,o,i.availableImages,r,l,i.brightness,i.elevationFeatures),i.featureIndex.insert(h,a,o,s,this.index)}this.hasElevation||(this.elevatedLayoutVertexArray=void 0)}update(e,i,r,a,n,o,s){this.programConfigurations.updatePaintArrays(e,i,n,r,a,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,o8.members),this.indexBuffer=e.createIndexBuffer(this.indexArray),this.globeExtVertexArray&&(this.globeExtVertexBuffer=e.createVertexBuffer(this.globeExtVertexArray,o7.members)),this.elevatedLayoutVertexArray&&(this.elevatedLayoutVertexBuffer=e.createVertexBuffer(this.elevatedLayoutVertexArray,o9.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,i,r,a,n,o,s,l){let h;for(let r of("none"!==this.elevationMode&&(h=lm.getElevationFeature(e,l)),i))for(let i of r){let r=i.x,a=i.y;if(r<0||r>=8192||a<0||a>=8192)continue;if(o){let e=o.projectTilePoint(r,a,n),i=o.upVector(n,r,a);this.addGlobeExtVertex(e,i),this.addGlobeExtVertex(e,i),this.addGlobeExtVertex(e,i),this.addGlobeExtVertex(e,i)}let s=this.segments.prepareSegment(4,this.layoutVertexArray,this.indexArray,e.sortKey),l=s.vertexLength;if(this.addCircleVertex(r,a,-1,-1),this.addCircleVertex(r,a,1,-1),this.addCircleVertex(r,a,1,1),this.addCircleVertex(r,a,-1,1),"none"!==this.elevationMode){let e=h?h.pointElevation(new e3(r,a)):0;this.hasElevation=this.hasElevation||0!==e;for(let i=0;i<4;i++)this.elevatedLayoutVertexArray.emplaceBack(e)}this.indexArray.emplaceBack(l,l+1,l+2),this.indexArray.emplaceBack(l,l+2,l+3),s.vertexLength+=4,s.primitiveLength+=2}this.programConfigurations.populatePaintArrays(this.layoutVertexArray.length,e,r,{},a,n,s,void 0,this.worldview)}addCircleVertex(e,i,r,a){this.layoutVertexArray.emplaceBack(2*e+(r+1)/2,2*i+(a+1)/2)}addGlobeExtVertex(e,i){this.globeExtVertexArray.emplaceBack(e.x,e.y,e.z,16384*i[0],16384*i[1],16384*i[2])}}function ly(e,i){for(let r=0;r<e.length;r++)if(lE(i,e[r]))return!0;for(let r=0;r<i.length;r++)if(lE(e,i[r]))return!0;return!!lv(e,i)}function lx(e,i){if(1===e.length)return lS(i,e[0]);for(let r=0;r<i.length;r++){let a=i[r];for(let i=0;i<a.length;i++)if(lE(e,a[i]))return!0}for(let r=0;r<e.length;r++)if(lS(i,e[r]))return!0;for(let r=0;r<i.length;r++)if(lv(e,i[r]))return!0;return!1}function lv(e,i){if(0===e.length||0===i.length)return!1;for(let s=0;s<e.length-1;s++){let l=e[s],h=e[s+1];for(let e=0;e<i.length-1;e++){var r,a,n,o;if(r=l,a=h,n=i[e],tm(r,n,o=i[e+1])!==tm(a,n,o)&&tm(r,a,n)!==tm(r,a,o))return!0}}return!1}function lb(e,i,r){return(e.x-r.x)*(i.y-r.y)-(e.y-r.y)*(i.x-r.x)}function lw(e,i,r){let a=r*r;if(1===i.length)return e.distSqr(i[0])<a;for(let r=1;r<i.length;r++)if(lT(e,i[r-1],i[r])<a)return!0;return!1}function lT(e,i,r){let a=i.distSqr(r);if(0===a)return e.distSqr(i);let n=((e.x-i.x)*(r.x-i.x)+(e.y-i.y)*(r.y-i.y))/a;return e.distSqr(n<0?i:n>1?r:r.sub(i)._mult(n)._add(i))}function lS(e,i){let r,a,n,o=!1;for(let s=0;s<e.length;s++){r=e[s];for(let e=0,s=r.length-1;e<r.length;s=e++)a=r[e],n=r[s],a.y>i.y!=n.y>i.y&&i.x<(n.x-a.x)*(i.y-a.y)/(n.y-a.y)+a.x&&(o=!o)}return o}function lE(e,i){let r=!1;for(let a=0,n=e.length-1;a<e.length;n=a++){let o=e[a],s=e[n];o.y>i.y!=s.y>i.y&&i.x<(s.x-o.x)*(i.y-o.y)/(s.y-o.y)+o.x&&(r=!r)}return r}function lI(e,i,r,a,n){for(let o of e)if(i<=o.x&&r<=o.y&&a>=o.x&&n>=o.y)return!0;
7let o=[new e3(i,r),new e3(i,n),new e3(a,n),new e3(a,r)];if(e.length>2){for(let i of o)if(lE(e,i))return!0}for(let i=0;i<e.length-1;i++)if(lA(e[i],e[i+1],o))return!0;return!1}function lA(e,i,r){let a=r[0],n=r[2];if(e.x<a.x&&i.x<a.x||e.x>n.x&&i.x>n.x||e.y<a.y&&i.y<a.y||e.y>n.y&&i.y>n.y)return!1;let o=tm(e,i,r[0]);return o!==tm(e,i,r[1])||o!==tm(e,i,r[2])||o!==tm(e,i,r[3])}function lC(e,i,r,a,n,o){let s=i.y-e.y,l=e.x-i.x;if(o=o||0){let e=s*s+l*l;if(0===e)return!0;let i=Math.sqrt(e);s/=i,l/=i}return!((r.x-e.x)*s+(r.y-e.y)*l-o<0||(a.x-e.x)*s+(a.y-e.y)*l-o<0||(n.x-e.x)*s+(n.y-e.y)*l-o<0)}function lM(e,i,r,a,n,o,s){return!(lC(e,i,a,n,o,s)||lC(i,r,a,n,o,s)||lC(r,e,a,n,o,s)||lC(a,n,e,i,r,s)||lC(n,o,e,i,r,s)||lC(o,a,e,i,r,s))}function lP(e,i,r){let a=i.paint.get(e).value;return"constant"===a.kind?a.value:r.programConfigurations.get(i.id).getMaxValue(e)}function lz(e){return Math.sqrt(e[0]*e[0]+e[1]*e[1])}function lR(e,i,r,a,n){if(!i[0]&&!i[1])return e;let o=e3.convert(i)._mult(n);"viewport"===r&&o._rotate(-a);let s=[];for(let i=0;i<e.length;i++)s.push(e[i].sub(o));return s}function lD(e,i,r,a){let n=e3.convert(e)._mult(a);return"viewport"===i&&n._rotate(-r),n}function lL(e,i,r){var a=2*Math.PI*6378137/256/Math.pow(2,r);return[e*a-2*Math.PI*6378137/2,i*a-2*Math.PI*6378137/2]}a3(lg,"CircleBucket",{omit:["layers"]});class lO{constructor(e,i,r){this.z=e,this.x=i,this.y=r,this.key=lB(0,e,e,i,r)}equals(e){return this.z===e.z&&this.x===e.x&&this.y===e.y}isChildOf(e){let i=this.z-e.z;return 0===e.z||e.z<this.z&&e.x===this.x>>i&&e.y===this.y>>i}url(e,i){var r,a,n,o,s;let l=(r=this.x,a=this.y,o=lL(256*r,256*(a=Math.pow(2,n=this.z)-a-1),n),s=lL(256*(r+1),256*(a+1),n),o[0]+","+o[1]+","+s[0]+","+s[1]),h=function(e,i,r){let a,n="";for(let o=e;o>0;o--)n+=(i&(a=1<<o-1)?1:0)+(r&a?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"===i?Math.pow(2,this.z)-this.y-1:this.y)).replace("{quadkey}",h).replace("{bbox-epsg-3857}",l)}toString(){return`${this.z}/${this.x}/${this.y}`}}class lF{constructor(e,i){this.wrap=e,this.canonical=i,this.key=lB(e,i.z,i.z,i.x,i.y)}}class lk{constructor(e,i,r,a,n){this.overscaledZ=e,this.wrap=i,this.canonical=new lO(r,+a,+n),this.key=0===i&&e===r?this.canonical.key:lB(i,e,r,a,n)}equals(e){return this.overscaledZ===e.overscaledZ&&this.wrap===e.wrap&&this.canonical.equals(e.canonical)}scaledTo(e){let i=this.canonical.z-e;return e>this.canonical.z?new lk(e,this.wrap,this.canonical.z,this.canonical.x,this.canonical.y):new lk(e,this.wrap,e,this.canonical.x>>i,this.canonical.y>>i)}calculateScaledKey(e,i=!0){if(this.overscaledZ===e&&i)return this.key;if(e>this.canonical.z)return lB(this.wrap*i,e,this.canonical.z,this.canonical.x,this.canonical.y);{let r=this.canonical.z-e;return lB(this.wrap*i,e,e,this.canonical.x>>r,this.canonical.y>>r)}}isChildOf(e){if(e.wrap!==this.wrap)return!1;let i=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>>i&&e.canonical.y===this.canonical.y>>i}children(e){if(this.overscaledZ>=e)return[new lk(this.overscaledZ+1,this.wrap,this.canonical.z,this.canonical.x,this.canonical.y)];let i=this.canonical.z+1,r=2*this.canonical.x,a=2*this.canonical.y;return[new lk(i,this.wrap,i,r,a),new lk(i,this.wrap,i,r+1,a),new lk(i,this.wrap,i,r,a+1),new lk(i,this.wrap,i,r+1,a+1)]}isLessThan(e){return this.wrap<e.wrap||!(this.wrap>e.wrap)&&(this.overscaledZ<e.overscaledZ||!(this.overscaledZ>e.overscaledZ)&&(this.canonical.x<e.canonical.x||!(this.canonical.x>e.canonical.x)&&this.canonical.y<e.canonical.y))}wrapped(){return new lk(this.overscaledZ,0,this.canonical.z,this.canonical.x,this.canonical.y)}unwrapTo(e){return new lk(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 lF(this.wrap,this.canonical)}toString(){return`${this.overscaledZ}/${this.canonical.x}/${this.canonical.y}`}}
7function lB(e,i,r,a,n){let o=1<<Math.min(r,22),s=n%o*o+a%o;return e&&r<22&&(s+=o*o*((e<0?-2*e-1:2*e)%(1<<2*(22-r)))),16*(32*s+r)+(i-r)}let lN=[e=>{let i=e.canonical.x-1,r=e.wrap;return i<0&&(i=(1<<e.canonical.z)-1,r--),new lk(e.overscaledZ,r,e.canonical.z,i,e.canonical.y)},e=>{let i=e.canonical.x+1,r=e.wrap;return i===1<<e.canonical.z&&(i=0,r++),new lk(e.overscaledZ,r,e.canonical.z,i,e.canonical.y)},e=>new lk(e.overscaledZ,e.wrap,e.canonical.z,e.canonical.x,(0===e.canonical.y?1<<e.canonical.z:e.canonical.y)-1),e=>new lk(e.overscaledZ,e.wrap,e.canonical.z,e.canonical.x,e.canonical.y===(1<<e.canonical.z)-1?0:e.canonical.y+1)];a3(lO,"CanonicalTileID"),a3(lk,"OverscaledTileID",{omit:["projMatrix","expandedProjMatrix"]});let{members:lV}=ou([{type:"Float32",name:"a_globe_pos",components:3},{type:"Float32",name:"a_uv",components:2}]),lU=ou([{name:"a_pos_3",components:3,type:"Int16"}]);var lj=ou([{name:"a_pos",type:"Int16",components:2}]);function lG(e){return e*sR/6371008.8}let lq=[new ld([sL,sL,sL],[sR,sR,sR]),new ld([sL,sL,sL],[0,0,sR]),new ld([0,sL,sL],[sR,0,sR]),new ld([sL,0,sL],[0,sR,sR]),new ld([0,0,sL],[sR,sR,sR])];function l$(e,i,r,a=!0){let n=eb([],e._camera.position,e.worldSize),o=[i,r,1,1];eB(o,o,e.pixelMatrixInverse),eF(o,o,1/o[3]);let s=eI([],eg([],o,n)),l=e.globeMatrix,h=[l[12],l[13],l[14]],u=eg([],h,n),c=ep(u),d=eI([],u),p=e.worldSize/(2*Math.PI),f=eA(d,s),m=Math.asin(p/c);if(m<Math.acos(f)){if(!a)return null;let e=[],i=[];eb(e,s,c/f),eI(i,eg(i,e,u)),eI(s,e_(s,u,eb(s,i,Math.tan(m)*c)))}let _=[];new ln(n,s).closestPointOnSphere(h,p,_);let g=eI([],tv(l,0)),y=eI([],tv(l,1)),x=eI([],tv(l,2)),v=eA(g,_),b=eA(y,_),w=eA(x,_),T=Math.asin(-b/p)*e6,S=Math.atan2(v,w)*e6;return new sY(sU(S=e.center.lng+function(e,i){let r=(i-e+180)%360-180;return r<-180?r+360:r}(e.center.lng,S)),tt(sj(T),0,1))}class lH{constructor(e,i,r){this.a=eg([],e,r),this.b=eg([],i,r),this.center=r;let a=eI([],this.a),n=eI([],this.b);this.angle=Math.acos(eA(a,n))}}function lZ(e,i){let r;return 0===e.angle||(r=0===e.a[i]?1/e.angle*.5*Math.PI:1/e.angle*Math.atan(e.b[i]/e.a[i]/Math.sin(e.angle)-1/Math.tan(e.angle)))<0||r>1?null:function(e,i,r,a){let n=Math.sin(r);return Math.sin((1-a)*r)/n*e+Math.sin(a*r)/n*i}(e.a[i],e.b[i],e.angle,tt(r,0,1))+e.center[i]}function lW(e){if(e.z<=1)return lq[e.z+2*e.y+e.x];let i=lQ(lJ(e));return ld.fromPoints(i)}function lX(e,i,r){return eb(e,e,1-r),ew(e,e,i,r)}function lY(e,i,r){for(let a of e)eP(a,a,i),eb(a,a,r)}function lK(e,i,r,a){let n=i/e.worldSize,o=e.globeMatrix;if(r.z<=1){let e=lW(r).getCorners();return lY(e,o,n),ld.fromPoints(e)}let s=lJ(r,a),l=lQ(s,sR+lG(e._tileCoverLift));lY(l,o,n);let h=Number.MAX_VALUE,u=[-h,-h,-h],c=[h,h,h];if(s.contains(e.center)){for(let e of l)ex(c,c,e),ev(u,u,e);u[2]=0;let i=e.point,r=[i.x*n,i.y*n,0];return ex(c,c,r),ev(u,u,r),new ld(c,u)}if(e._tileCoverLift>0){for(let e of l)ex(c,c,e),ev(u,u,e);return new ld(c,u)}let d=[o[12]*n,o[13]*n,o[14]*n],p=s.getCenter(),f=tt(e.center.lat,-85.051129,85.051129),m=tt(p.lat,-85.051129,85.051129),_=sU(e.center.lng),g=sj(f),y=_-sU(p.lng),x=g-sj(m);y>.5?y-=1:y<-.5&&(y+=1);let v=0;Math.abs(y)>Math.abs(x)?v=y>=0?1:3:(v=x>=0?0:2,ew(d,d,[o[4]*n,o[5]*n,o[6]*n],-Math.sin((x>=0?s.getSouth():s.getNorth())*e4)*sR));let b=l[v],w=l[(v+1)%4],T=new lH(b,w,d),S=[lZ(T,0)||b[0],lZ(T,1)||b[1],lZ(T,2)||b[2]],E=l9(e.zoom);if(E>0){let a=function({x:e,y:i,z:r},a,n,o,s){let l=1/(1<<r),h=e*l,u=h+l,c=i*l,d=c+l,p=0,f=(h+u)/2-o;return f>.5?p=-1:f<-.5&&(p=1),h=((h+p)*a-(o*=a))*n+o,u=((u+p)*a-o)*n+o,c=(c*a-(s*=a))*n+s,[[h,d=(d*a-s)*n+s,0],[u,d,0],[u,c,0],[h,c,0]]}(r,i,e._pixelsPerMercatorPixel,_,g);for(let e=0;e<l.length;e++)lX(l[e],a[e],E);let n=e_([],a[v],a[(v+1)%4]);eb(n,n,.5),lX(S,n,E)}for(let e of l)ex(c,c,e),ev(u,u,e);return c[2]=Math.min(b[2],w[2]),ex(c,c,S),ev(u,u,S),new ld(c,u)}function lJ({x:e,y:i,z:r},a=!1){let n=1/(1<<r);return new sN(new sB(sG(e*n),i===(1<<r)-1&&a?-90:sq((i+1)*n)),new sB(sG((e+1)*n),0===i&&a?90:sq(i*n)))}function lQ(e,i=sR){let r=e.getNorth()*e4,a=e.getSouth()*e4,n=Math.cos(r),o=Math.cos(a),s=Math.sin(r),l=Math.sin(a),h=e.getWest(),u=e.getEast();return[sO(o,l,h,i),sO(o,l,u,i),sO(n,s,u,i),sO(n,s,h,i)]}function l0(e,i,r,a){let n=1<<r.z,o=(e/8192+r.x)/n;return sF(sq((i/8192+r.y)/n),sG(o),a)}function l1({min:e,max:i}){return 16383/Math.max(i[0]-e[0],i[1]-e[1],i[2]-e[2])}let l2=new Float64Array(16);function l3(e){let i=l1(e),r=el(l2,[i,i,i]);return er(r,r,eE([],e.min))}function l5(e){var i;let r=(i=e.min,l2[0]=1,l2[1]=0,l2[2]=0,l2[3]=0,l2[4]=0,l2[5]=1,l2[6]=0,l2[7]=0,l2[8]=0,l2[9]=0,l2[10]=1,l2[11]=0,l2[12]=i[0],l2[13]=i[1],l2[14]=i[2],l2[15]=1,l2),a=1/l1(e);return ea(r,r,[a,a,a])}function l4(e){return e/(2*Math.PI)/(8192/(2*Math.PI))}function l6(e,i){return 8192/(512*Math.pow(2,e))*l1(lW(i))}function l8(e,i,r,a,n){let o=l4(r),s=[e,i,-r/(2*Math.PI)],l=ee(new Float64Array(16));return er(l,l,s),ea(l,l,[o,o,o]),en(l,l,-n*e4),eo(l,l,-a*e4),l}function l9(e){return ti(5,6,e)}function l7(e,i){var r,a,n,o,s,l,h,u;let c=sF(i.lat,i.lng);return a=(r=eg([],function(e){let i=sF(e._center.lat,e._center.lng),r=eC([],ef(0,1,0),i),a=eh([],-e.angle,i);r=eP(r,r,a),eh(a,-e._pitch,r);let n=eI([],i);return eb(n,n,lG(e.cameraToCenterDistance/e.pixelsPerMeter)),eP(n,n,a),e_([],i,n)}(e),c))[0],n=r[1],o=r[2],s=c[0],Math.acos(Math.min(Math.max((u=Math.sqrt((a*a+n*n+o*o)*(s*s+(l=c[1])*l+(h=c[2])*h)))&&eA(r,c)/u,-1),1))}
7function he(e,i){return l7(e,i)>Math.PI/2*1.01}let ht=85*e4,hi=Math.cos(ht),hr=Math.sin(ht),ha=Q(),hn=e=>{let i=[];return"map"===e.paint.get("circle-pitch-alignment")&&i.push("PITCH_WITH_MAP"),"map"===e.paint.get("circle-pitch-scale")&&i.push("SCALE_WITH_MAP"),i};function ho(e,i,r,a,n,o,s,l,h){if(o&&e.queryGeometry.isAboveHorizon)return!1;o&&(h*=e.pixelToTileUnitsFactor);let u=e.tileID.canonical,c=r.projection.upVectorScale(u,r.center.lat,r.worldSize).metersToTile;for(let p of i)for(let i of p){var d;let p=i.add(l),f=n&&r.elevation?r.elevation.exaggeration()*n.getElevationAt(p.x,p.y,!0):0,m=r.projection.projectTilePoint(p.x,p.y,u);if(f>0){let e=r.projection.upVector(u,p.x,p.y);m.x+=e[0]*c*f,m.y+=e[1]*c*f,m.z+=e[2]*c*f}let _=o?p:function(e,i,r,a){let n=eB([],[e,i,r,1],a);return new e3(n[0]/n[3],n[1]/n[3])}(m.x,m.y,m.z,a),g=o?e.tilespaceRays.map(e=>(function(e,i){let r=ec();return hs[2]=i,e.intersectsPlane(hs,hl,r),new e3(r[0],r[1])})(e,f)):e.queryGeometry.screenGeometry,y=eB([],[m.x,m.y,m.z,1],a);if(!s&&o?h*=y[3]/r.cameraToCenterDistance:s&&!o&&(h*=r.cameraToCenterDistance/y[3]),o){let e=sq((i.y/8192+u.y)/(1<<u.z));h/=r.projection.pixelsPerMeter(e,1)/(1/sV(e))}if(d=h,lE(g,_)||lw(_,g,d))return!0}return!1}let hs=ef(0,0,0),hl=ef(0,0,1);class hh extends lg{}function hu(e,{width:i,height:r}
7,a,n){if(n){if(n instanceof Uint8ClampedArray)n=new Uint8Array(n.buffer);else if(n.length!==i*r*a)throw RangeError("mismatched image size")}else n=new Uint8Array(i*r*a);return e.width=i,e.height=r,e.data=n,e}function hc(e,i,r){let{width:a,height:n}=i;a===e.width&&n===e.height||(hd(e,i,{x:0,y:0},{x:0,y:0},{width:Math.min(e.width,a),height:Math.min(e.height,n)},r,null),e.width=a,e.height=n,e.data=i.data)}function hd(e,i,r,a,n,o,s,l){if(0===n.width||0===n.height)return i;if(n.width>e.width||n.height>e.height||r.x>e.width-n.width||r.y>e.height-n.height)throw RangeError("out of range source coordinates for image copy");if(n.width>i.width||n.height>i.height||a.x>i.width-n.width||a.y>i.height-n.height)throw RangeError("out of range destination coordinates for image copy");let h=e.data,u=i.data,c=4===o&&l;for(let l=0;l<n.height;l++){let d=((r.y+l)*e.width+r.x)*o,p=((a.y+l)*i.width+a.x)*o;if(c)for(let e=0;e<n.width;e++){let i=d+e*o+3,r=p+e*o;u[r+0]=255,u[r+1]=255,u[r+2]=255,u[r+3]=h[i]}else if(s)for(let e=0;e<n.width;e++){let i=d+e*o,r=p+e*o,a=new ih(h[i+0]/255,h[i+1]/255,h[i+2]/255,h[i+3]).toNonPremultipliedRenderColor(s).toArray();u[r+0]=a[0],u[r+1]=a[1],u[r+2]=a[2],u[r+3]=a[3]}else for(let e=0;e<n.width*o;e++)u[p+e]=h[d+e]}return i}a3(hh,"HeatmapBucket",{omit:["layers"]});class hp{constructor(e,i){hu(this,e,1,i)}resize(e){hc(this,new hp(e),1)}clone(){return new hp({width:this.width,height:this.height},new Uint8Array(this.data))}static copy(e,i,r,a,n){hd(e,i,r,a,n,1,null)}}class hf{constructor(e,i){hu(this,e,4,i)}resize(e){hc(this,new hf(e),4)}replace(e,i){i?this.data.set(e):this.data=e instanceof Uint8ClampedArray?new Uint8Array(e.buffer):e}clone(){return new hf({width:this.width,height:this.height},new Uint8Array(this.data))}static copy(e,i,r,a,n,o,s){hd(e,i,r,a,n,4,o,s)}}class hm{constructor(e,i){this.width=e.width,this.height=e.height,this.data=i instanceof Uint8Array?new Float32Array(i.buffer):i}}function h_(e){let i={},r=e.resolution||256,a=e.clips?e.clips.length:1,n=e.image||new hf({width:r,height:a}),o=(r,a,o)=>{i[e.evaluationKey]=o;let s=e.expression.evaluate(i),l=s?s.toNonPremultipliedRenderColor(null):null;l&&(n.data[r+a+0]=Math.floor(255*l.r),n.data[r+a+1]=Math.floor(255*l.g),n.data[r+a+2]=Math.floor(255*l.b),n.data[r+a+3]=Math.floor(255*l.a))};if(e.clips)for(let i=0,n=0;i<a;++i,n+=4*r)for(let a=0,s=0;a<r;a++,s+=4){let l=a/(r-1),{start:h,end:u}=e.clips[i];o(n,s,h*(1-l)+u*l)}else for(let e=0,i=0;e<r;e++,i+=4)o(0,i,e/(r-1));return n}a3(hp,"AlphaImage"),a3(hf,"RGBAImage");let hg=ou([{name:"a_pos",components:2,type:"Int16"}],4),hy=ou([{name:"a_road_z_offset",components:1,type:"Float32"}],4),hx=ou([{name:"a_pos",components:2,type:"Int16"},{name:"a_height",components:1,type:"Float32"}],4),hv=ou([{name:"a_pos_normal_3",components:3,type:"Int16"}],4);function hb(e,i,r=2){let a,n,o,s=i&&i.length,l=s?i[0]*r:e.length,h=hw(e,0,l,r,!0),u=[];if(!h||h.next===h.prev)return u;if(s&&(h=function(e,i,r,a){let n=[];for(let r=0,o=i.length;r<o;r++){let s=hw(e,i[r]*a,r<o-1?i[r+1]*a:e.length,a,!1);s===s.next&&(s.steiner=!0),n.push(function(e){let i=e,r=e;do(i.x<r.x||i.x===r.x&&i.y<r.y)&&(r=i),i=i.next;while(i!==e);return r}(s))}n.sort(hS);for(let e=0;e<n.length;e++)r=function(e,i){let r=function(e,i){let r=i,a=e.x,n=e.y,o,s=-1/0;if(hM(e,r))return r;do{if(hM(e,r.next))return r.next;if(n<=r.y&&n>=r.next.y&&r.next.y!==r.y){let e=r.x+(n-r.y)*(r.next.x-r.x)/(r.next.y-r.y
7);if(e<=a&&e>s&&(s=e,o=r.x<r.next.x?r:r.next,e===a))return o}r=r.next}while(r!==i);if(!o)return null;let l=o,h=o.x,u=o.y,c=1/0;r=o;do{if(a>=r.x&&r.x>=h&&a!==r.x&&hI(n<u?a:s,n,h,u,n<u?s:a,n,r.x,r.y)){var d,p;let i=Math.abs(n-r.y)/(a-r.x);hD(r,e)&&(i<c||i===c&&(r.x>o.x||r.x===o.x&&(d=o,p=r,0>hC(d.prev,d,p.prev)&&0>hC(p.next,d,d.next))))&&(o=r,c=i)}r=r.next}while(r!==l);return o}(e,i);if(!r)return i;let a=hL(r,e);return hT(a,a.next),hT(r,r.next)}(n[e],r);return r}(e,i,h,r)),e.length>80*r){a=e[0],n=e[1];let i=a,s=n;for(let o=r;o<l;o+=r){let r=e[o],l=e[o+1];r<a&&(a=r),l<n&&(n=l),r>i&&(i=r),l>s&&(s=l)}o=0!==(o=Math.max(i-a,s-n))?32767/o:0}return function e(i,r,a,n,o,s,l){if(!i)return;!l&&s&&function(e,i,r,a){let n=e;do 0===n.z&&(n.z=hE(n.x,n.y,i,r,a)),n.prevZ=n.prev,n.nextZ=n.next,n=n.next;while(n!==e);n.prevZ.nextZ=null,n.prevZ=null,function(e){let i,r=1;do{let a,n=e;e=null;let o=null;for(i=0;n;){i++;let s=n,l=0;for(let e=0;e<r&&(l++,s=s.nextZ);e++);let h=r;for(;l>0||h>0&&s;)0!==l&&(0===h||!s||n.z<=s.z)?(a=n,n=n.nextZ,l--):(a=s,s=s.nextZ,h--),o?o.nextZ=a:e=a,a.prevZ=o,o=a;n=s}o.nextZ=null,r*=2}while(i>1)}(n)}(i,n,o,s);let h=i;for(;i.prev!==i.next;){let u=i.prev,c=i.next;if(s?function(e,i,r,a){let n=e.prev,o=e.next;if(hC(n,e,o)>=0)return!1;let s=n.x,l=e.x,h=o.x,u=n.y,c=e.y,d=o.y,p=Math.min(s,l,h),f=Math.min(u,c,d),m=Math.max(s,l,h),_=Math.max(u,c,d),g=hE(p,f,i,r,a),y=hE(m,_,i,r,a),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!==o&&hA(s,u,l,c,h,d,x.x,x.y)&&hC(x.prev,x,x.next)>=0||(x=x.prevZ,v.x>=p&&v.x<=m&&v.y>=f&&v.y<=_&&v!==n&&v!==o&&hA(s,u,l,c,h,d,v.x,v.y)&&hC(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!==o&&hA(s,u,l,c,h,d,x.x,x.y)&&hC(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!==o&&hA(s,u,l,c,h,d,v.x,v.y)&&hC(v.prev,v,v.next)>=0)return!1;v=v.nextZ}return!0}(i,n,o,s):function(e){let i=e.prev,r=e.next;if(hC(i,e,r)>=0)return!1;let a=i.x,n=e.x,o=r.x,s=i.y,l=e.y,h=r.y,u=Math.min(a,n,o),c=Math.min(s,l,h),d=Math.max(a,n,o),p=Math.max(s,l,h),f=r.next;for(;f!==i;){if(f.x>=u&&f.x<=d&&f.y>=c&&f.y<=p&&hA(a,s,n,l,o,h,f.x,f.y)&&hC(f.prev,f,f.next)>=0)return!1;f=f.next}return!0}(i))r.push(u.i,i.i,c.i),hF(i),i=c.next,h=c.next;else if((i=c)===h){l?1===l?e(i=function(e,i){let r=e;do{let a=r.prev,n=r.next.next;!hM(a,n)&&hP(a,r,r.next,n)&&hD(a,n)&&hD(n,a)&&(i.push(a.i,r.i,n.i),hF(r),hF(r.next),r=e=n),r=r.next}while(r!==e);return hT(r)}(hT(i),r),r,a,n,o,s,2):2===l&&function(i,r,a,n,o,s){let l=i;do{let i=l.next.next;for(;i!==l.prev;){var h,u;if(l.i!==i.i&&(h=l,u=i,h.next.i!==u.i&&h.prev.i!==u.i&&!function(e,i){let r=e;do{if(r.i!==e.i&&r.next.i!==e.i&&r.i!==i.i&&r.next.i!==i.i&&hP(r,r.next,e,i))return!0;r=r.next}while(r!==e);return!1}(h,u)&&(hD(h,u)&&hD(u,h)&&function(e,i){let r=e,a=!1,n=(e.x+i.x)/2,o=(e.y+i.y)/2;do r.y>o!=r.next.y>
7o&&r.next.y!==r.y&&n<(r.next.x-r.x)*(o-r.y)/(r.next.y-r.y)+r.x&&(a=!a),r=r.next;while(r!==e);return a}(h,u)&&(hC(h.prev,h,u.prev)||hC(h,u.prev,u))||hM(h,u)&&hC(h.prev,h,h.next)>0&&hC(u.prev,u,u.next)>0))){let h=hL(l,i);return l=hT(l,l.next),h=hT(h,h.next),e(l,r,a,n,o,s,0),void e(h,r,a,n,o,s,0)}i=i.next}l=l.next}while(l!==i)}(i,r,a,n,o,s):e(hT(i),r,a,n,o,s,1);break}}}(h,u,r,a,n,o,0),u}function hw(e,i,r,a,n){let o;if(n===function(e,i,r,a){let n=0;for(let o=i,s=r-a;o<r;o+=a)n+=(e[s]-e[o])*(e[o+1]+e[s+1]),s=o;return n}(e,i,r,a)>0)for(let n=i;n<r;n+=a)o=hO(n/a|0,e[n],e[n+1],o);else for(let n=r-a;n>=i;n-=a)o=hO(n/a|0,e[n],e[n+1],o);return o&&hM(o,o.next)&&(hF(o),o=o.next),o}function hT(e,i){if(!e)return e;i||(i=e);let r,a=e;do if(r=!1,a.steiner||!hM(a,a.next)&&0!==hC(a.prev,a,a.next))a=a.next;else{if(hF(a),(a=i=a.prev)===a.next)break;r=!0}while(r||a!==i);return i}function hS(e,i){let r=e.x-i.x;return 0===r&&0==(r=e.y-i.y)&&(r=(e.next.y-e.y)/(e.next.x-e.x)-(i.next.y-i.y)/(i.next.x-i.x)),r}function hE(e,i,r,a,n){return(e=0x55555555&((e=0x33333333&((e=0xf0f0f0f&((e=0xff00ff&((e=(e-r)*n|0)|e<<8))|e<<4))|e<<2))|e<<1))|(i=0x55555555&((i=0x33333333&((i=0xf0f0f0f&((i=0xff00ff&((i=(i-a)*n|0)|i<<8))|i<<4))|i<<2))|i<<1))<<1}function hI(e,i,r,a,n,o,s,l){return(n-s)*(i-l)>=(e-s)*(o-l)&&(e-s)*(a-l)>=(r-s)*(i-l)&&(r-s)*(o-l)>=(n-s)*(a-l)}function hA(e,i,r,a,n,o,s,l){return(e!==s||i!==l)&&hI(e,i,r,a,n,o,s,l)}function hC(e,i,r){return(i.y-e.y)*(r.x-i.x)-(i.x-e.x)*(r.y-i.y)}function hM(e,i){return e.x===i.x&&e.y===i.y}function hP(e,i,r,a){let n=hR(hC(e,i,r)),o=hR(hC(e,i,a)),s=hR(hC(r,a,e)),l=hR(hC(r,a,i));return n!==o&&s!==l||!(0!==n||!hz(e,r,i))||!(0!==o||!hz(e,a,i))||!(0!==s||!hz(r,e,a))||!(0!==l||!hz(r,i,a))}function hz(e,i,r){return i.x<=Math.max(e.x,r.x)&&i.x>=Math.min(e.x,r.x)&&i.y<=Math.max(e.y,r.y)&&i.y>=Math.min(e.y,r.y)}function hR(e){return e>0?1:e<0?-1:0}function hD(e,i){return 0>hC(e.prev,e,e.next)?hC(e,i,e.next)>=0&&hC(e,e.prev,i)>=0:0>hC(e,i,e.prev)||0>hC(e,e.next,i)}function hL(e,i){let r=hk(e.i,e.x,e.y),a=hk(i.i,i.x,i.y),n=e.next,o=i.prev;return e.next=i,i.prev=e,r.next=n,n.prev=r,a.next=r,r.prev=a,o.next=a,a.prev=o,a}function hO(e,i,r,a){let n=hk(e,i,r);return a?(n.next=a.next,n.prev=a,a.next.prev=n,a.next=n):(n.prev=n,n.next=n),n}function hF(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 hk(e,i,r){return{i:e,x:i,y:r,prev:null,next:null,z:0,prevZ:null,nextZ:null,steiner:!1}}function hB(e,i){let r,a,n=e.length;if(n<=1)return[e];let o=[];for(let i=0;i<n;i++){let n=function(e){let i=0;for(let r,a,n=0,o=e.length,s=o-1;n<o;s=n++)r=e[n],i+=((a=e[s]).x-r.x)*(r.y+a.y);return i}(e[i]);0!==n&&(e[i].area=Math.abs(n),void 0===a&&(a=n<0),a===n<0?(r&&o.push(r),r=[e[i]]):r.push(e[i]))}if(r&&o.push(r),i>1)for(let e=0;e<o.length;e++)o[e].length<=i||(function e(i,r,a=0,n=i.length-1,o=function(e,i){return e<i?-1:+(e>i)}){for(;n>a;){if(n-a>600){let s=n-a+1,l=r-a+1,h=Math.log(s),u=.5*Math.exp(2*h/3),c=.5*Math.sqrt(h*u*(s-u)/s)*(l-s/2<0?-1:1);e(i,r,Math.max(a,Math.floor(r-l*u/s+c)),Math.min(n,Math.floor(r+(s-l)*u/s+c)),o)}let s=i[r],l=a,h=n;for(i7(i,a,r),o(i[n],s)>0&&i7(i,a,n);l<h;){for(i7(i,l,h),l++,h--;0>o(i[l],s);)l++;for(;o(i[h],s)>0;)h--}0===o(i[a],s)?i7(i,a,h):i7(i,++h,n),h<=r&&(a=h+1),r<=h&&(n=h-1)}}(o[e],i,1,o[e].length-1,hN),o[e]=o[e].slice(0,i));return o}function hN(e,i){return i.area-e.area}function hV(e,i,r=1){if(!e)return null;let a="string"==typeof e?iV.from(e).getPrimary():e.getPrimary(),n="string"==typeof e?null:e.getSecondary();for(let e of[a,n]){if(!e)continue;let a=e.id.toString();i.has(a)||i.set(a,[]),e.scaleSelf(r),i.get(a).push(e)}return{primary:a.toString(),secondary:n?n.toString():null}}function hU(e,i,r,a){let n=a.patternDependencies,o=!1;for(let a of i){let i=a.paint.get(`${e}-pattern`);i.isConstant()||(o=!0),hV(i.constantOr(null),n,r)&&(o=!0)}return o}function hj(e,i,r,a,n,o){let s=o.patternDependencies;for(let l of i){let i=l.paint.get(`${e}-pattern`).value;if("constant"!==i.kind){let e=i.evaluate({zoom:a},r,{},o.availableImages),h=hV(e=e&&e.name?e.name:e,s,n);if(!h)continue;let{primary:u,secondary:c}=h;
7u&&(r.patterns[l.id]=[u,c].filter(Boolean))}}return r}class hG{constructor(){this.polygons=new Map}add(e,...i){let r=this.polygons.get(e);r?r.push(...i):this.polygons.set(e,i)}merge(e){for(let[i,r]of e.polygons)this.add(i,...r)}}class hq{constructor(){this.portals=[]}static isOnBorder(e,i){return e<=0&&i<=0||e>=8192&&i>=8192}static evaluate(e){if(0===e.length)return new hq;let i=[];for(let r of e)i.push(...r.portals);if(0===i.length)return new hq;for(let e of i){let i=e.va,r=e.vb;(hq.isOnBorder(i.x,r.x)||hq.isOnBorder(i.y,r.y))&&(e.type="border")}let r=i.filter(e=>"unevaluated"!==e.type),a=i.filter(e=>"unevaluated"===e.type);if(0===a.length)return new hq;a.sort((e,i)=>e.hash===i.hash?e.isTunnel===i.isTunnel?0:e.isTunnel?-1:1:e.hash<i.hash?1:-1),i=r.concat(a);let n=r.length,o=n,s=n;do if(++o===i.length||i[n].hash!==i[o].hash){if(o-n==2){s<n&&(i[s]=i[n],i[n]=null);let e=i[s],r=i[o-1];e.type=e.isTunnel!==r.isTunnel?"tunnel":"polygon",e.connection={a:e.connection.a,b:r.connection.a},s++}n=o}while(n!==i.length);return i.splice(s),i.sort((e,i)=>e.hash<i.hash?1:-1),{portals:i}}}a3(hq,"ElevationPortalGraph"),a3(hG,"ElevationPolygons");class h${constructor(e,i,r){this.outPositions=e,this.outNormals=i,this.outIndices=r,this.vertexLookup=new Map}addVertex(e,i,r){let a=e[2];null!=r&&(a*=r);let n=`${e[0]},${e[1]},${e[2]},${i[0]},${i[1]},${i[2]}`,o=this.vertexLookup.get(n);if(null!=o)return o;let s=this.outPositions.length;this.vertexLookup.set(n,s);let l=Math.trunc(16384*i[0]),h=Math.trunc(16384*i[1]),u=Math.trunc(16384*i[2]);return this.outPositions.emplaceBack(e[0],e[1],a),this.outNormals.emplaceBack(l,h,u),s}addTriangle(e,i,r){this.outIndices.emplaceBack(e,i,r)}addTriangles(e,i,r){if(0===e.length)return;let a=1===r.length,n=ec(),o=ec();for(let s=0;s<e.length;s+=3){let l=i[e[s+0]],h=i[e[s+1]],u=i[e[s+2]],c=a?r[0]:r[e[s+1]],d=a?r[0]:r[e[s+2]];em(n,l.x,l.y,a?r[0]:r[e[s+0]]);let p=this.addVertex(n,o);em(n,h.x,h.y,c);let f=this.addVertex(n,o);em(n,u.x,u.y,d);let m=this.addVertex(n,o);this.outIndices.emplaceBack(p,f,m)}}addQuad(e,i,r,a,n,o){let s=this.addVertex(e,n,o),l=this.addVertex(i,n,o),h=this.addVertex(r,n,o),u=this.addVertex(a,n,o);this.addTriangle(s,l,h),this.addTriangle(h,u,s)}getVertexCount(){return this.outPositions.length}clearVertexLookup(){this.vertexLookup.clear()}}class hH{constructor(e,i,r,a){this.unevaluatedPortals=new hq,this.portalPolygons=new hG,this.bridgeFeatureSections=[],this.tunnelFeatureSections=[],this.vertexHashLookup=new Map,this.unevalVertices=[],this.unevalHeights=[],this.unevalTriangles=[],this.unevalTunnelTriangles=[],this.unevalEdges=[],this.vertexPositions=new o_,this.vertexNormals=new og,this.indexArray=new oD,this.tileToMeters=sX(e),this.bridgeProgramConfigurations=new sA(i,{zoom:r,lut:a},e=>"fill-tunnel-structure-color"!==e),this.tunnelProgramConfigurations=new sA(i,{zoom:r,lut:a},e=>"fill-bridge-guard-rail-color"!==e)}addVertices(e,i){let r=this.unevalVertices.length;for(let r=0;r<e.length;r++)this.unevalVertices.push(e[r]),this.unevalHeights.push(i[r]);return r}
7addTriangles(e,i,r){let a=r?this.unevalTunnelTriangles:this.unevalTriangles;for(let r of e)a.push(r+i)}addRenderableRing(e,i,r,a,n,o){let s=[new e3(n.min.x,n.min.y),new e3(n.max.x,n.min.y),new e3(n.max.x,n.max.y),new e3(n.min.x,n.max.y)];for(let l=0;l<r-1;l++){let r=i+l,h=r+1,u=this.unevalVertices[r],c=this.unevalVertices[h];if(!(u.x>=n.min.x&&u.x<=n.max.x&&u.y>=n.min.y&&u.y<=n.max.y||c.x>=n.min.x&&c.x<=n.max.x&&c.y>=n.min.y&&c.y<=n.max.y||lA(u,c,s))||this.isOnBorder(u.x,c.x)||this.isOnBorder(u.y,c.y))continue;let d=hH.computeEdgeHash(this.unevalVertices[r],this.unevalVertices[h]),p,f=this.vertexHashLookup.get(hH.computePosHash(u));p=null!=f?f.next:null!=(f=this.vertexHashLookup.get(hH.computePosHash(c)))?f.prev:d,this.unevalEdges.push({polygonIdx:e,a:r,b:h,hash:d,portalHash:p,isTunnel:a,type:"unevaluated",featureInfo:o})}}addPortalCandidates(e,i,r,a,n){if(0===i.length)return;this.portalPolygons.add(e,{geometry:i,zLevel:n});let o=i[0];this.vertexHashLookup.clear();let s=hH.computeEdgeHash(o[o.length-2],o[o.length-1]);for(let i=0;i<o.length-1;i++){let n=o[i+0],l=o[i+1],h=eW(l.x-n.x,l.y-n.y),u=eJ(h);if(0===u)continue;let c="unevaluated",d=a.pointElevation(n),p=a.pointElevation(l);.01>Math.abs(d)&&.01>Math.abs(p)?c="entrance":(this.isOnBorder(n.x,l.x)||this.isOnBorder(n.y,l.y))&&(c="border");let f=hH.computeEdgeHash(n,l);this.unevaluatedPortals.portals.push({connection:{a:e,b:void 0},va:n,vb:l,vab:h,length:u,hash:f,isTunnel:r,type:c});let m=hH.computePosHash(n);this.vertexHashLookup.set(m,{prev:s,next:f}),s=f}}construct(e){if(0===this.unevalVertices.length)return;let i=()=>({vertexOffset:0,primitiveOffset:this.indexArray.length}),r=e=>{e.primitiveLength=this.indexArray.length-e.primitiveOffset},a=new h$(this.vertexPositions,this.vertexNormals,this.indexArray);this.prepareEdges(e.portals,this.unevalEdges);let n=i(),o=i(),s=i(),l=(e,i)=>{e.sort((e,r)=>e.type===i&&r.type!==i?-1:+(e.type!==i&&r.type===i));let r=e.findIndex(e=>e.type!==i);return r>=0?r:e.length},h=0;this.unevalEdges.length>0&&(h=l(this.unevalEdges,"none"),this.constructBridgeStructures(a,this.unevalVertices,this.unevalHeights,this.unevalEdges,{min:0,max:h},this.tileToMeters)),r(s);let u=i(),c=i();if(this.unevalEdges.length>0){let e=this.unevalEdges.splice(h),i=l(e,"tunnel")+h;this.unevalEdges.push(...e),this.constructTunnelStructures(a,this.unevalVertices,this.unevalHeights,this.unevalEdges,{min:0,max:h},{min:h,max:i})}r(u),a.addTriangles(this.unevalTriangles,this.unevalVertices,this.unevalHeights),r(c),a.addTriangles(this.unevalTunnelTriangles,this.unevalVertices,this.unevalHeights),r(o),a.addTriangles(this.unevalTunnelTriangles,this.unevalVertices,[-.1]),r(n),this.maskSegments=se.simpleSegment(0,c.primitiveOffset,0,c.primitiveLength),this.depthSegments=se.simpleSegment(0,o.primitiveOffset,0,o.primitiveLength),this.renderableBridgeSegments=se.simpleSegment(0,s.primitiveOffset,0,s.primitiveLength),this.renderableTunnelSegments=se.simpleSegment(0,u.primitiveOffset,0,u.primitiveLength),this.shadowCasterSegments=se.simpleSegment(0,n.primitiveOffset,0,n.primitiveLength)}update(e,i,r,a,n,o,s,l){this.bridgeProgramConfigurations.updatePaintArrays(e,i,n,r,a,o,s,l),this.tunnelProgramConfigurations.updatePaintArrays(e,i,n,r,a,o,s,l)}upload(e){this.vertexBuffer||0===this.vertexPositions.length||0===this.vertexNormals.length||0===this.indexArray.length||(this.vertexBuffer=e.createVertexBuffer(this.vertexPositions,hx.members),this.vertexBufferNormal=e.createVertexBuffer(this.vertexNormals,hv.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,i,r,a,n){let o=(o,s)=>{for(let l=0;l<s.length-1;l++){let h=s[l].featureIndex,u=s[l+1].vertexStart,c=e.feature(h);o.populatePaintArrays(u,c,h,{},r,i,a,void 0,n)}};o(this.bridgeProgramConfigurations,this.bridgeFeatureSections),o(this.tunnelProgramConfigurations,this.tunnelFeatureSections)}computeVertexConnections(e,i,r,a,n){let o=new Map;for(let s=a;s<n;s++){let a=r[s],n=a.a,l=a.b,h=hH.computePosHash(e[n]),u=hH.computePosHash(e[l]),c=o.get(h);c||(c={},o.set(h,c));let d=o.get(u);d||(d={},o.set(u,d)),i[n]<=0&&i[l]<=0||(c.to=l,d.from=n)}return o}isTerminalVertex(e,i){let r=hH.computePosHash(this.unevalVertices[e]),a=i.get(r);return!a||!a.from||!a.to}constructBridgeStructures(e,i,r,a,n,o){e.clearVertexLookup();let s=this.computeVertexConnections(i,r,a,n.min,n.max),l=1/o,h=.5*l,u=(e,a)=>em(e,i[a].x,i[a].y,r[a]*l),c=ec(),d=ec(),p=ec(),f=ec(),m=ec(),_=(e,r)=>{let a=s.get(hH.computePosHash(i[r])),n=a.from,o=a.to;
7if(!n||!o)return;u(c,n),u(d,r),u(p,o),eD(f),eL(c,d)||(eg(m,d,c),eI(f,m)),eL(p,d)||(eg(m,p,d),e_(f,f,eI(m,m)));let l=ep(f);return l>0?eb(e,f,1/l):void 0},g=1/0;this.sortSubarray(a,n.min,n.max,(e,i)=>e.featureInfo.featureIndex-i.featureInfo.featureIndex);let y=ec(),x=ec(),v=ec(),b=ec(),w=ec(),T=ec(),S=ec(),E=ec(),I=ec(),A=[ec(),ec(),ec(),ec()],C=[ec(),ec(),ec(),ec()],M=[{coord:new e3(0,0),height:0},{coord:new e3(0,0),height:0}],P=(e,i)=>e>i;for(let u=n.min;u<n.max;u++){let n=a[u];if(!n.featureInfo.guardRailEnabled||!this.prepareEdgePoints(M,i,r,n,P))continue;let[c,d]=M;if(em(y,c.coord.x,c.coord.y,l*c.height),em(x,d.coord.x,d.coord.y,l*d.height),eL(y,x))continue;eg(v,x,y),eI(v,v);let p=_(E,n.a)||v,f=_(I,n.b)||v;em(b,p[1],-p[0],0),eI(b,b),em(w,f[1],-f[0],0),eI(w,w),eC(E,b,p),eI(T,E),eC(E,w,f),eI(S,E),e_(A[0],y,eb(E,eg(E,b,T),h)),e_(A[1],y,eb(E,e_(E,b,T),h)),e_(A[2],y,eb(E,T,h)),A[3]=y,e_(C[0],x,eb(E,eg(E,w,S),h)),e_(C[1],x,eb(E,e_(E,w,S),h)),e_(C[2],x,eb(E,S,h)),C[3]=x,g=this.addFeatureSection(n.featureInfo.featureIndex,g,this.bridgeFeatureSections,e);let m=e.addVertex(A[0],b,o),z=e.addVertex(A[1],b,o),R=e.addVertex(C[0],w,o),D=e.addVertex(C[1],w,o);e.addTriangle(m,z,R),e.addTriangle(z,D,R);let L=e.addVertex(A[1],T,o),O=e.addVertex(A[2],T,o),F=e.addVertex(C[1],S,o),k=e.addVertex(C[2],S,o);e.addTriangle(L,O,F),e.addTriangle(O,k,F),eE(b,b),eE(w,w);let B=e.addVertex(A[2],b,o),N=e.addVertex(A[3],b,o),V=e.addVertex(C[2],w,o),U=e.addVertex(C[3],w,o);e.addTriangle(B,N,V),e.addTriangle(N,U,V);let j=this.isTerminalVertex(n.a,s),G=this.isTerminalVertex(n.b,s);c.height<.01&&j&&e.addQuad(A[3],A[2],A[1],A[0],eE(p,p),o),d.height<.01&&G&&e.addQuad(C[0],C[1],C[2],C[3],f,o)}this.bridgeFeatureSections.push({featureIndex:1/0,vertexStart:e.getVertexCount()})}constructTunnelStructures(e,i,r,a,n,o){e.clearVertexLookup();let s=1/0,l=(e,i)=>e.featureInfo.featureIndex-i.featureInfo.featureIndex;this.sortSubarray(a,n.min,n.max,l),this.sortSubarray(a,o.min,o.max,l);let h=e=>eI(e,e),u=[{coord:new e3(0,0),height:0},{coord:new e3(0,0),height:0}],c=(e,i)=>e<i,d=ec(),p=ec(),f=ec(),m=ec(),_=ec();for(let o=n.min;o<n.max;o++){if(!this.prepareEdgePoints(u,i,r,a[o],c))continue;let[n,l]=u,g=h(em(_,-(l.coord.y-n.coord.y),l.coord.x-n.coord.x,0));s=this.addFeatureSection(a[o].featureInfo.featureIndex,s,this.tunnelFeatureSections,e),e.addQuad(em(d,n.coord.x,n.coord.y,n.height),em(p,l.coord.x,l.coord.y,l.height),em(f,l.coord.x,l.coord.y,a[o].isTunnel?-.1:0),em(m,n.coord.x,n.coord.y,a[o].isTunnel?-.1:0),g)}for(let n=o.min;n<o.max;n++){let o=a[n];o.isTunnel&&([o.a,o.b]=[o.b,o.a]);let l=i[o.a],u=i[o.b],c=h(em(_,-(u.y-l.y),u.x-l.x,0));s=this.addFeatureSection(o.featureInfo.featureIndex,s,this.tunnelFeatureSections,e),e.addQuad(em(d,u.x,u.y,0),em(p,l.x,l.y,0),em(f,l.x,l.y,r[o.a]+4),em(m,u.x,u.y,r[o.b]+4),c),e.addQuad(em(d,l.x,l.y,0),em(p,u.x,u.y,0),em(f,u.x,u.y,r[o.b]+4),em(m,l.x,l.y,r[o.a]+4),c)}this.tunnelFeatureSections.push({featureIndex:1/0,vertexStart:e.getVertexCount()})}setElevatedPoint(e,i,r,a){e.coord.x=i,e.coord.y=r,e.height=a}prepareEdgePoints(e,i,r,a,n){let o=i[a.a].x,s=i[a.a].y,l=i[a.b].x,h=i[a.b].y,u=r[a.a],c=r[a.b],d=n(u,0),p=n(c,0);if(d&&p)return this.setElevatedPoint(e[0],o,s,u),this.setElevatedPoint(e[1],l,h,c),!0;if(!d&&!p)return!1;if(d){if(!p){let e=c/(c-u);l=ip(l,o,e),h=ip(h,s,e),c=ip(c,u,e)}}else{let e=u/(u-c);o=ip(o,l,e),s=ip(s,h,e),u=ip(u,c,e)}return this.setElevatedPoint(e[0],o,s,u),this.setElevatedPoint(e[1],l,h,c),!0}prepareEdges(e,i){if(0===i.length)return;i.sort((e,i)=>e.hash===i.hash?i.polygonIdx-e.polygonIdx:i.hash>e.hash?1:-1);let r=0,a=0,n=0,o=i[0].polygonIdx;do(++a===i.length||i[r].hash!==i[a].hash)&&((1==a-r||i[a-1].polygonIdx!==o)&&(n<r&&(i[n]=i[r],i[r]=null),i[n].type="none",n++),(r=a)!==i.length&&(o=i[r].polygonIdx));while(r!==i.length);if(i.splice(n),0!==i.length&&0!==e.length){i.sort((e,i)=>e.portalHash<i.portalHash?1:-1);let r=0,a=0;for(;r!==i.length&&a!==e.length;){let n=i[r],o=e[a];n.portalHash>o.hash?r++:o.hash>n.portalHash?a++:(n.type=o.type,r++)}}}isOnBorder(e,i){return e<=0&&i<=0||e>=8192&&i>=8192}addFeatureSection(e,i,r,a){return e!==i&&(i=e,r.push({featureIndex:e,vertexStart:a.getVertexCount()}),a.clearVertexLookup()),i}sortSubarray(e,i,r,a){let n=e.slice(i,r);n.sort(a),e.splice(i,n.length,...n)}static computeEdgeHash(e,i){return(e.y===i.y&&e.x>i.x||e.y>i.y)&&([e,i]=[i,e]),BigInt(hH.computePosHash(e))<<32n|BigInt(hH.computePosHash(i))}static computePosHash(e){return((65535&e.x)<<16|65535&e.y)>>>0}}var hZ,hW={},hX=(hZ||(hZ=1,!function(e){function i(e,i){return e>i?1:e<i?-1:0}var r=function(e,r){void 0===e&&(e=i),void 0===r&&(r=!1),this._compare=e,this._root=null,this._size=0,this._noDuplicates=!!r},a={size:{configurable:!0}};function n(e,i,r){null===i?(e.inOut=!1,e.otherInOut=!0):(e.isSubject===i.isSubject?(e.inOut=!i.inOut,e.otherInOut=i.otherInOut):(e.inOut=!i.otherInOut,e.otherInOut=i.isVertical()?!i.inOut:i.inOut),i&&(e.prevInResult=!o(i,r)||i.isVertical()?i.prevInResult:i));var a=o(e,r);e.resultTransition=a?function(e,i){var r,a=!e.inOut,n=!e.otherInOut;switch(i){case 0:r=a&&n;break;case 1:r=a||n;break;case 3:r=a^n;break;case 2:r=e.isSubject?a&&!n:n&&!a}return r?1:-1}(e,r):0}function o(e,i){switch(e.type){case 0:switch(i){case 0:return!e.otherInOut;case 1:return e.otherInOut;case 2:return e.isSubject&&e.otherInOut||!e.isSubject&&!e.otherInOut;case 3:return!0}break;case 2:return 0===i||1===i;case 3:return 2===i}return!1}r.prototype.rotateLeft=function(e){var i=e.right;i&&(e.right=i.left,i.left&&(i.left.parent=e),i.parent=e.parent),e.parent?e===e.parent.left?e.parent.left=i:e.parent.right=i:this._root=i,i&&(i.left
7=e),e.parent=i},r.prototype.rotateRight=function(e){var i=e.left;i&&(e.left=i.right,i.right&&(i.right.parent=e),i.parent=e.parent),e.parent?e===e.parent.left?e.parent.left=i:e.parent.right=i:this._root=i,i&&(i.right=e),e.parent=i},r.prototype._splay=function(e){for(;e.parent;){var i=e.parent;i.parent?i.left===e&&i.parent.left===i?(this.rotateRight(i.parent),this.rotateRight(i)):i.right===e&&i.parent.right===i?(this.rotateLeft(i.parent),this.rotateLeft(i)):i.left===e&&i.parent.right===i?(this.rotateRight(i),this.rotateLeft(i)):(this.rotateLeft(i),this.rotateRight(i)):i.left===e?this.rotateRight(i):this.rotateLeft(i)}},r.prototype.splay=function(e){for(var i,r,a,n,o;e.parent;)(r=(i=e.parent).parent)&&r.parent?((a=r.parent).left===r?a.left=e:a.right=e,e.parent=a):(e.parent=null,this._root=e),n=e.left,o=e.right,e===i.left?(r&&(r.left===i?(i.right?(r.left=i.right,r.left.parent=r):r.left=null,i.right=r,r.parent=i):(n?(r.right=n,n.parent=r):r.right=null,e.left=r,r.parent=e)),o?(i.left=o,o.parent=i):i.left=null,e.right=i):(r&&(r.right===i?(i.left?(r.right=i.left,r.right.parent=r):r.right=null,i.left=r,r.parent=i):(o?(r.left=o,o.parent=r):r.left=null,e.right=r,r.parent=e)),n?(i.right=n,n.parent=i):i.right=null,e.left=i),i.parent=e},r.prototype.replace=function(e,i){e.parent?e===e.parent.left?e.parent.left=i:e.parent.right=i:this._root=i,i&&(i.parent=e.parent)},r.prototype.minNode=function(e){if(void 0===e&&(e=this._root),e)for(;e.left;)e=e.left;return e},r.prototype.maxNode=function(e){if(void 0===e&&(e=this._root),e)for(;e.right;)e=e.right;return e},r.prototype.insert=function(e,i){var r=this._root,a=null,n=this._compare;if(this._noDuplicates)for(;r;){if(a=r,0===n(r.key,e))return;r=0>n(r.key,e)?r.right:r.left}else for(;r;)a=r,r=0>n(r.key,e)?r.right:r.left;return r={key:e,data:i,left:null,right:null,parent:a},a?0>n(a.key,r.key)?a.right=r:a.left=r:this._root=r,this.splay(r),this._size++,r},r.prototype.find=function(e){for(var i=this._root,r=this._compare;i;){var a=r(i.key,e);if(a<0)i=i.right;else{if(!(a>0))return i;i=i.left}}return null},r.prototype.contains=function(e){for(var i=this._root,r=this._compare;i;){var a=r(e,i.key);if(0===a)return!0;i=a<0?i.left:i.right}return!1},r.prototype.remove=function(e){var i=this.find(e);if(!i)return!1;if(this.splay(i),i.left)if(i.right){var r=this.minNode(i.right);r.parent!==i&&(this.replace(r,r.right),r.right=i.right,r.right.parent=r),this.replace(i,r),r.left=i.left,r.left.parent=r}else this.replace(i,i.left);else this.replace(i,i.right);return this._size--,!0},r.prototype.removeNode=function(e){if(!e)return!1;if(this.splay(e),e.left)if(e.right){var i=this.minNode(e.right);i.parent!==e&&(this.replace(i,i.right),i.right=e.right,i.right.parent=i),this.replace(e,i),i.left=e.left,i.left.parent=i}else this.replace(e,e.left);else this.replace(e,e.right);return this._size--,!0},r.prototype.erase=function(e){var i=this.find(e);if(i){this.splay(i);var r=i.left,a=i.right,n=null;r&&(r.parent=null,n=this.maxNode(r),this.splay(n),this._root=n),a&&(r?n.right=a:this._root=a,a.parent=n),this._size--}},r.prototype.pop=function(){var e=this._root,i=null;if(e){for(;e.left;)e=e.left;i={key:e.key,data:e.data},this.remove(e.key)}return i},r.prototype.next=function(e){var i=e;if(i)if(i.right)for(i=i.right;i&&i.left;)i=i.left;else for(i=e.parent;i&&i.right===e;)e=i,i=i.parent;return i},r.prototype.prev=function(e){var i=e;if(i)if(i.left)for(i=i.left;i&&i.right;)i=i.right;else for(i=e.parent;i&&i.left===e;)e=i,i=i.parent;return i},r.prototype.forEach=function(e){for(var i=this._root,r=[],a=!1,n=0;!a;)i?(r.push(i),i=i.left):r.length>0?(e(i=r.pop(),n++),i=i.right):a=!0;return this},r.prototype.range=function(e,i,r,a){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,i)>0)break;if(o(s.key,e)>=0&&r.call(a,s))return this;s=s.right}return this},r.prototype.keys=function(){for(var e=this._root,i=[],r=[],a=!1;!a;)e?(i.push(e),e=e.left):i.length>0?(r.push((e=i.pop()).key),e=e.right):a=!0;return r},r.prototype.values=function(){for(var e=this._root,i=[],r=[],a=!1;!a;)e?(i.push(e),e=e.left):i.length>0?(r.push((e=i.pop()).data),e=e.right):a=!0;return r},r.prototype.at=function(e){for(var i=this._root,r=[],a=!1,n=0;!a;)if(i)r.push(i),i=i.left;else if(r.length>0){if(i=r.pop(),n===e)return i;n++,i=i.right}else a=!0;return null},r.prototype.load=function(e,i,r){if(void 0===e&&(e=[]),void 0===i&&(i=[]),void 0===r&&(r=!1),0!==this._size)throw Error("bulk-load: tree is not empty");var a=e.length;return r&&function e(i,r,a,n,o){if(!(a>=n)){for(var s=i[a+n>>1],l=a-1,h=n+1;;){do l++;while(0>o(i[l],s));do h--;while(o(i[h],s)>0);if(l>=h)break;var u=i[l];i[l]=i[h],i[h]=u,u=r[l],r[l]=r[h],r[h]=u}e(i,r,a,h,o),e(i,r,h+1,n,o)}}(e,i,0,a-1,this._compare),this._root=function e(i,r,a,n,o){var s=o-n;if(s>0){var l=n+Math.floor(s/2),h={key:r[l],data:a[l],parent:i};return h.left=e(h,r,a,n,l),h.right=e(h,r,a,l+1,o),h}return null}(null,e,i,0,a),this._size=a,this},r.prototype.min=function(){var e=this.minNode(this._root);return e?e.key:null},r.prototype.max=function(){var e=this.maxNode(this._root);return e?e.key:null},r.prototype.isEmpty=function(){return null===this._root},a.size.get=function(){return this._size},r.createTree=function(e,i,a,n,o){return new r(a,o).load(e,i,n)},Object.defineProperties(r.prototype,a);var s=function(e,i,r,a,n){this.left=i,this.point=e,this.otherEvent=r,this.isSubject=a,this.type=n||0,this.inOut=!1,this.otherInOut=!1,this.prevInResult=null,this.resultTransition=0,this.otherPos=-1,this.outputContourId=-1,this.isExteriorRing=!0},l={inResult:{configurable:!0}};function h(e,i){return e[0]===i[0]&&e[1]===i[1]}s.prototype.isBelow=function(e){var i=this.point,r=this.otherEvent.point;
7return this.left?(i[0]-e[0])*(r[1]-e[1])-(r[0]-e[0])*(i[1]-e[1])>0:(r[0]-e[0])*(i[1]-e[1])-(i[0]-e[0])*(r[1]-e[1])>0},s.prototype.isAbove=function(e){return!this.isBelow(e)},s.prototype.isVertical=function(){return this.point[0]===this.otherEvent.point[0]},l.inResult.get=function(){return 0!==this.resultTransition},s.prototype.clone=function(){var e=new s(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(s.prototype,l);var u=(3+8881784197001252e-31)*11102230246251565e-32;function c(e,i,r,a,n){var o,s,l,h,u=i[0],c=a[0],d=0,p=0;c>u==c>-u?(o=u,u=i[++d]):(o=c,c=a[++p]);var f=0;if(d<e&&p<r)for(c>u==c>-u?(l=o-((s=u+o)-u),u=i[++d]):(l=o-((s=c+o)-c),c=a[++p]),o=s,0!==l&&(n[f++]=l);d<e&&p<r;)c>u==c>-u?(l=o-((s=o+u)-(h=s-o))+(u-h),u=i[++d]):(l=o-((s=o+c)-(h=s-o))+(c-h),c=a[++p]),o=s,0!==l&&(n[f++]=l);for(;d<e;)l=o-((s=o+u)-(h=s-o))+(u-h),u=i[++d],o=s,0!==l&&(n[f++]=l);for(;p<r;)l=o-((s=o+c)-(h=s-o))+(c-h),c=a[++p],o=s,0!==l&&(n[f++]=l);return 0===o&&0!==f||(n[f++]=o),f}function d(e){return new Float64Array(e)}var p=d(4),f=d(8),m=d(12),_=d(16),g=d(4);function y(e,i,r){var a=function(e,i,r,a,n,o){var s=(i-o)*(r-n),l=(e-n)*(a-o),h=s-l;if(0===s||0===l||s>0!=l>0)return h;var d=Math.abs(s+l);return Math.abs(h)>=33306690738754716e-32*d?h:-function(e,i,r,a,n,o,s){var l,h,d,y,x,v,b,w,T,S,E,I,A,C,M,P,z,R,D=e-n,L=r-n,O=i-o,F=a-o;p[0]=(M=(w=D-(b=(v=0x8000001*D)-(v-D)))*(S=F-(T=(v=0x8000001*F)-(v-F)))-((C=D*F)-b*T-w*T-b*S))-((E=M-(z=(w=O-(b=(v=0x8000001*O)-(v-O)))*(S=L-(T=(v=0x8000001*L)-(v-L)))-((P=O*L)-b*T-w*T-b*S)))+(x=M-E))+(x-z),p[1]=(A=C-((I=C+E)-(x=I-C))+(E-x))-((E=A-P)+(x=A-E))+(x-P),p[2]=I-((R=I+E)-(x=R-I))+(E-x),p[3]=R;var k=function(e,i){for(var r=i[0],a=1;a<4;a++)r+=i[a];return r}(0,p),B=22204460492503146e-32*s;if(k>=B||-k>=B||(l=e-(D+(x=e-D))+(x-n),d=r-(L+(x=r-L))+(x-n),h=i-(O+(x=i-O))+(x-o),y=a-(F+(x=a-F))+(x-o),0===l&&0===h&&0===d&&0===y)||(B=11093356479670487e-47*s+u*Math.abs(k),(k+=D*y+F*l-(O*d+L*h))>=B||-k>=B))return k;g[0]=(M=(w=l-(b=(v=0x8000001*l)-(v-l)))*(S=F-(T=(v=0x8000001*F)-(v-F)))-((C=l*F)-b*T-w*T-b*S))-((E=M-(z=(w=h-(b=(v=0x8000001*h)-(v-h)))*(S=L-(T=(v=0x8000001*L)-(v-L)))-((P=h*L)-b*T-w*T-b*S)))+(x=M-E))+(x-z),g[1]=(A=C-((I=C+E)-(x=I-C))+(E-x))-((E=A-P)+(x=A-E))+(x-P),g[2]=I-((R=I+E)-(x=R-I))+(E-x),g[3]=R;var N=c(4,p,4,g,f);g[0]=(M=(w=D-(b=(v=0x8000001*D)-(v-D)))*(S=y-(T=(v=0x8000001*y)-(v-y)))-((C=D*y)-b*T-w*T-b*S))-((E=M-(z=(w=O-(b=(v=0x8000001*O)-(v-O)))*(S=d-(T=(v=0x8000001*d)-(v-d)))-((P=O*d)-b*T-w*T-b*S)))+(x=M-E))+(x-z),g[1]=(A=C-((I=C+E)-(x=I-C))+(E-x))-((E=A-P)+(x=A-E))+(x-P),g[2]=I-((R=I+E)-(x=R-I))+(E-x),g[3]=R;var V=c(N,f,4,g,m);g[0]=(M=(w=l-(b=(v=0x8000001*l)-(v-l)))*(S=y-(T=(v=0x8000001*y)-(v-y)))-((C=l*y)-b*T-w*T-b*S))-((E=M-(z=(w=h-(b=(v=0x8000001*h)-(v-h)))*(S=d-(T=(v=0x8000001*d)-(v-d)))-((P=h*d)-b*T-w*T-b*S)))+(x=M-E))+(x-z),g[1]=(A=C-((I=C+E)-(x=I-C))+(E-x))-((E=A-P)+(x=A-E))+(x-P),g[2]=I-((R=I+E)-(x=R-I))+(E-x),g[3]=R;var U=c(V,m,4,g,_);return _[U-1]}(e,i,r,a,n,o,d)}(e[0],e[1],i[0],i[1],r[0],r[1]);return a>0?-1:+(a<0)}function x(e,i){var r=e.point,a=i.point;return r[0]>a[0]?1:r[0]<a[0]?-1:r[1]!==a[1]?r[1]>a[1]?1:-1:e.left!==i.left?e.left?1:-1:0!==y(r,e.otherEvent.point,i.otherEvent.point)?e.isBelow(i.otherEvent.point)?-1:1:!e.isSubject&&i.isSubject?1:-1}function v(e,i,r){var a=new s(i,!1,e,e.isSubject),n=new s(i,!0,e.otherEvent,e.isSubject);return h(e.point,e.otherEvent.point)&&console.warn("what is that, a collapsed segment?",e),a.contourId=n.contourId=e.contourId,x(n,e.otherEvent)>0&&(e.otherEvent.left=!0,n.left=!1),e.otherEvent.otherEvent=n,e.otherEvent=a,r.push(n),r.push(a),r}function b(e,i){return e[0]*i[1]-e[1]*i[0]}function w(e,i){return e[0]*i[0]+e[1]*i[1]}function T(e,i,r){var a=function(e,i,r,a,n){var o=[i[0]-e[0],i[1]-e[1]],s=[a[0]-r[0],a[1]-r[1]];function l(e,i,r){return[e[0]+i*r[0],e[1]+i*r[1]]}var h=[r[0]-e[0],r[1]-e[1]],u=b(o,s),c=u*u,d=w(o,o);if(c>0){var p=b(h,s)/u;if(p<0||p>1)return null;var f=b(h,o)/u;return f<0||f>1?null:0===p||1===p?[l(e,p,o)]:0===f||1===f?[l(r,f,s)]:[l(e,p,o)]}if((c=(u=b(h,o))*u)>0)return null;var m=w(o,h)/d,_=m+w(o,s)/d,g=Math.min(m,_),y=Math.max(m,_);return g<=1&&y>=0?1===g?[l(e,g>0?g:0,o)]:0===y?[l(e,y<1?y:1,o)]:[l(e,g>0?g:0,o),l(e,y<1?y:1,o)]:null}(e.point,e.otherEvent.point,i.point,i.otherEvent.point),n=a?a.length:0;if(0===n||1===n&&(h(e.point,i.point)||h(e.otherEvent.point,i.otherEvent.point))||2===n&&e.isSubject===i.isSubject)return 0;if(1===n)return h(e.point,a[0])||h(e.otherEvent.point,a[0])||v(e,a[0],r),h(i.point,a[0])||h(i.otherEvent.point,a[0])||v(i,a[0],r),1;var o=[],s=!1,l=!1;return h(e.point,i.point)?s=!0:1===x(e,i)?o.push(i,e):o.push(e,i),h(e.otherEvent.point,i.otherEvent.point)?l=!0:1===x(e.otherEvent,i.otherEvent)?o.push(i.otherEvent,e.otherEvent):o.push(e.otherEvent,i.otherEvent),s&&l||s?(i.type=1,e.type=i.inOut===e.inOut?2:3,s&&!l&&v(o[1].otherEvent,o[0].point,r),2):(l?v(o[0],o[1].point,r):o[0]!==o[3].otherEvent?(v(o[0],o[1].point,r),v(o[1],o[2].point,r)):(v(o[0],o[1].point,r),v(o[3].otherEvent,o[2].point,r)),3)}function S(e,i){if(e===i)return 0;if(0!==y(e.point,e.otherEvent.point,i.point)||0!==y(e.point,e.otherEvent.point,i.otherEvent.point))return h(e.point,i.point)?e.isBelow(i.otherEvent.point)?-1:1:e.point[0]===i.point[0]?e.point[1]<i.point[1]?-1:1:1===x(e,i)?i.isAbove(e.point)?-1:1:e.isBelow(i.point)?-1:1;if(e.isSubject!==i.isSubject)return e.isSubject?-1:1;var r=e.point,a=i.point;return r[0]===a[0]&&r[1]===a[1]?(r=e.otherEvent.point)[0]===(a=i.otherEvent.point)[0]&&r[1]===a[1]?0:e.contourId>i.contourId?1:-1:1===x(e,i)?1:-1}var E=function(){this.points=[],this.holeIds=[],this.holeOf=null,this.depth=null};function I(e,i){if(!(this instanceof I))return new I(e,i);if(this.data=e||[],this.length=this.data.length,this.compare=i||A,this.length>0)for(var r=(this.length>>1)-1;r>=0;r--)this._down(r)}function A(e,i){return e<i?-1:+(e>i)}E.prototype.isExterior=function(){return null==this.holeOf},I.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 i=this.data,r=this.compare,a=i[e];e>0;){var n=e-1>>1,o=i[n];if(r(a,o)>=0)break;i[e]=o,e=n}i[e]=a},_down:function(e){for(var i=this.data,r=this.compare,a=this.length>>1,n=i[e];e<a;){var o=1+(e<<1),s=o+1,l=i[o];if(s<this.length&&0>r(i[s],l)&&(o=s,l=i[s]),r(l,n)>=0)break;i[e]=l,e=o}i[e]=n}},I.default=I;var C=Math.max,M=Math.min,P=0;function z(e,i,r,a,n,o){var l,h,u,c,d,p;for(l=0,h=e.length-1;l<h;l++)if(c=e[l+1],d=new s(u=e[l],!1,void 0,i),p=new s(c,!1,d,i),d.otherEvent=p,u[0]!==c[0]||u[1]!==c[1]){d.contourId=p.contourId=r,o||(d.isExteriorRing=!1,p.isExteriorRing=!1),x(d,p)>
70?p.left=!0:d.left=!0;var f=u[0],m=u[1];n[0]=M(n[0],f),n[1]=M(n[1],m),n[2]=C(n[2],f),n[3]=C(n[3],m),a.push(d),a.push(p)}}var R=[];function D(e,i,a){"number"==typeof e[0][0][0]&&(e=[e]),"number"==typeof i[0][0][0]&&(i=[i]);var o,s,l,h,u,c,d=(o=e,s=i,l=null,o.length*s.length==0&&(0===a?l=R:2===a?l=o:1!==a&&3!==a||(l=0===o.length?s:o)),l);if(d)return d===R?null:d;var p=[1/0,1/0,-1/0,-1/0],f=[1/0,1/0,-1/0,-1/0],m=function(e,i,r,a,n){var o,s,l,h,u,c,d=new I(null,x);for(l=0,h=e.length;l<h;l++)for(u=0,c=(o=e[l]).length;u<c;u++)(s=0===u)&&P++,z(o[u],!0,P,d,r,s);for(l=0,h=i.length;l<h;l++)for(u=0,c=(o=i[l]).length;u<c;u++)s=0===u,2===n&&(s=!1),s&&P++,z(o[u],!1,P,d,a,s);return d}(e,i,p,f,a);if(h=e,u=i,c=null,(p[0]>f[2]||f[0]>p[2]||p[1]>f[3]||f[1]>p[3])&&(0===a?c=R:2===a?c=h:1!==a&&3!==a||(c=h.concat(u))),d=c)return d===R?null:d;for(var _=function(e){var i,r,a=function(e){var i,r,a,n,o=[];for(r=0,a=e.length;r<a;r++)((i=e[r]).left&&i.inResult||!i.left&&i.otherEvent.inResult)&&o.push(i);for(var s=!1;!s;)for(s=!0,r=0,a=o.length;r<a;r++)r+1<a&&1===x(o[r],o[r+1])&&(n=o[r],o[r]=o[r+1],o[r+1]=n,s=!1);for(r=0,a=o.length;r<a;r++)(i=o[r]).otherPos=r;for(r=0,a=o.length;r<a;r++)(i=o[r]).left||(n=i.otherPos,i.otherPos=i.otherEvent.otherPos,i.otherEvent.otherPos=n);return o}(e),n={},o=[];for(i=0,r=a.length;i<r;i++)!function(){if(!n[i]){var e=o.length,r=function(e,i,r){var a=new E;if(null!=e.prevInResult){var n=e.prevInResult,o=n.outputContourId;if(n.resultTransition>0){var s=i[o];if(null!=s.holeOf){var l=s.holeOf;i[l].holeIds.push(r),a.holeOf=l,a.depth=i[o].depth}else i[o].holeIds.push(r),a.holeOf=o,a.depth=i[o].depth+1}else a.holeOf=null,a.depth=i[o].depth}else a.holeOf=null,a.depth=0;return a}(a[i],o,e),s=function(i){n[i]=!0,i<a.length&&a[i]&&(a[i].outputContourId=e)},l=i,h=i;for(r.points.push(a[i].point);s(l),s(l=a[l].otherPos),r.points.push(a[l].point),!((l=function(e,i,r,a){var n,o=e+1,s=i[e].point,l=i.length;for(o<l&&(n=i[o].point);o<l&&n[0]===s[0]&&n[1]===s[1];){if(!r[o])return o;++o<l&&(n=i[o].point)}for(o=e-1;r[o]&&o>a;)o--;return o}(l,a,n,h))==h||l>=a.length)&&a[l];);o.push(r)}}();return o}(function(e,i,a,o,s,l){for(var h,u,c,d=new r(S),p=[],f=Math.min(o[2],s[2]);0!==e.length;){var m=e.pop();if(p.push(m),0===l&&m.point[0]>f||2===l&&m.point[0]>o[2])break;if(m.left){u=h=d.insert(m),h=h!==(c=d.minNode())?d.prev(h):null,u=d.next(u);var _=h?h.key:null;if(n(m,_,l),u&&2===T(m,u.key,e)&&(n(m,_,l),n(u.key,m,l)),h&&2===T(h.key,m,e)){var g=h;n(_,(g=g!==c?d.prev(g):null)?g.key:null,l),n(m,_,l)}}else u=h=d.find(m=m.otherEvent),h&&u&&(h=h!==c?d.prev(h):null,u=d.next(u),d.remove(m),u&&h&&T(h.key,u.key,e))}return p}(m,0,0,p,f,a)),g=[],y=0;y<_.length;y++){var v=_[y];if(v.isExterior()){for(var b=[v.points],w=0;w<v.holeIds.length;w++)b.push(_[v.holeIds[w]].points);g.push(b)}}return g}e.diff=function(e,i){return D(e,i,2)},e.intersection=function(e,i){return D(e,i,0)},e.operations={UNION:1,DIFFERENCE:2,INTERSECTION:0,XOR:3},e.union=function(e,i){return D(e,i,1)},e.xor=function(e,i){return D(e,i,3)},Object.defineProperty(e,"__esModule",{value:!0})}(hW)),hW);function hY(e,i,r,a){let n=[],o=0===a?(e,i,r,a,n,o)=>{e.push(new e3(o,r+(o-i)/(a-i)*(n-r)))}:(e,i,r,a,n,o)=>{e.push(new e3(i+(o-r)/(n-r)*(a-i),o))};for(let s of e){let e=[];for(let n of s){if(n.length<=2)continue;let s=[];for(let e=0;e<n.length-1;e++){let l=n[e].x,h=n[e].y,u=n[e+1].x,c=n[e+1].y,d=0===a?l:h,p=0===a?u:c;d<i?p>i&&o(s,l,h,u,c,i):d>r?p<r&&o(s,l,h,u,c,r):s.push(n[e]),p<i&&d>=i&&o(s,l,h,u,c,i),p>r&&d<=r&&o(s,l,h,u,c,r)}let l=n[n.length-1],h=0===a?l.x:l.y;h>=i&&h<=r&&s.push(l),s.length&&(l=s[s.length-1],s[0].x===l.x&&s[0].y===l.y||s.push(s[0]),e.push(s))}e.length&&n.push(e)}return n}function hK(e,i=1){return[e.map(e=>e.map(e=>[e.x*i,e.y*i]))]}function hJ(e,i=1){return e.map(e=>e.map((e,r)=>{let a=e.map(e=>new e3(e[0]*i,e[1]*i).round());return r>0&&a.reverse(),a}))}class hQ{constructor(e,i){this.layoutVertexArray=new od,this.indexArray=new oD,this.lineIndexArray=new oC,this.triangleSegments=new se,this.lineSegments=new se,this.programConfigurations=new sA(e.layers,{zoom:e.zoom,lut:e.lut}),this.uploaded=!1,i&&(this.elevatedLayoutVertexArray=new om)}update(e,i,r,a,n,o,s,l){this.programConfigurations.updatePaintArrays(e,i,n,r,a,o,s,l)}isEmpty(){return 0===this.layoutVertexArray.length}needsUpload(){return this.programConfigurations.needsUpload}upload(e){this.uploaded||(this.layoutVertexBuffer=e.createVertexBuffer(this.layoutVertexArray,hg.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,hy.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,i,r,a,n,o,s){this.programConfigurations.populatePaintArrays(this.layoutVertexArray.length,e,i,r,a,n,o,void 0,s)}}class h0{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 hQ(e,!1),this.elevationBufferData=new hQ(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.s
7ourceLayerIndex,this.worldview=e.worldview}updateFootprints(e,i){}populate(e,i,r,a){this.hasPattern=hU("fill",this.layers,this.pixelRatio,i);let n=this.layers[0].layout.get("fill-sort-key"),o=[];for(let{feature:s,id:l,index:h,sourceLayerIndex:u}of e){let e=this.layers[0]._featureFilter.needGeometry,c=s0(s,e);if(!this.layers[0]._featureFilter.filter(new nV(this.zoom,{worldview:this.worldview}),c,r))continue;let d=n?n.evaluate(c,{},r,i.availableImages):void 0,p={id:l,properties:s.properties,type:s.type,sourceLayerIndex:u,index:h,geometry:e?c.geometry:sQ(s,r,a),patterns:{},sortKey:d};o.push(p)}for(let a of(n&&o.sort((e,i)=>e.sortKey-i.sortKey),o)){let{geometry:n,index:o,sourceLayerIndex:s}=a;if(this.hasPattern){let e=hj("fill",this.layers,a,this.zoom,this.pixelRatio,i);this.patternFeatures.push(e)}else this.addFeature(a,n,o,r,{},i.availableImages,i.brightness,i.elevationFeatures);i.featureIndex.insert(e[o].feature,n,o,s,this.index)}}update(e,i,r,a,n,o,s){this.bufferData.update(e,i,r,a,n,o,s,this.worldview),this.elevationBufferData.update(e,i,r,a,n,o,s,this.worldview),this.elevatedStructures&&this.elevatedStructures.update(e,i,r,a,n,o,s,this.worldview)}addFeatures(e,i,r,a,n,o){for(let n of this.patternFeatures)this.addFeature(n,n.geometry,n.index,i,r,a,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,i,r,a,n,o=[],s,l){let h=hB(i,500);"none"!==this.elevationMode?this.addElevatedRoadFeature(e,h,a,r,l):this.addGeometry(h,this.bufferData),this.bufferData.populatePaintArrays(e,r,n,o,a,s,this.worldview),this.elevationBufferData.populatePaintArrays(e,r,n,o,a,s,this.worldview)}getUnevaluatedPortalGraph(){return this.elevatedStructures?this.elevatedStructures.unevaluatedPortals:void 0}getElevationPolygons(){return this.elevatedStructures?this.elevatedStructures.portalPolygons:void 0}setEvaluatedPortalGraph(e,i,r,a,n){this.elevatedStructures&&(this.elevatedStructures.construct(e),this.elevatedStructures.populatePaintArrays(i,r,a,n,this.worldview))}addElevatedRoadFeature(e,i,r,a,n){let o=[],s=lm.getElevationFeature(e,n);if(!s)return void this.addGeometry(i,this.bufferData);{let e=this.clipPolygonsToTile(i,1);e.length>0&&o.push({polygons:e,elevationFeature:s,elevationTileID:r})}let l={guardRailEnabled:this.layers[0].layout.get("fill-construct-bridge-guard-rail").evaluate(e,{},r),featureIndex:a};for(let i of o)if(i.elevationFeature){if("hd-road-base"===this.elevationMode){this.elevatedStructures||(this.elevatedStructures=new hH(i.elevationTileID,this.layers,this.zoom,this.lut));let r=i.elevationFeature.isTunnel(),a=0;for(let n of(e.properties.hasOwnProperty(s9)&&(a=+e.properties[s9]),i.polygons))this.elevatedStructures.addPortalCandidates(i.elevationFeature.id,n,r,i.elevationFeature,a)}null==i.elevationFeature.constantHeight&&(i.polygons=this.prepareElevatedPolygons(i.polygons,i.elevationFeature,i.elevationTileID));let n=new l_(r,i.elevationTileID);this.addElevatedGeometry(i.polygons,n,i.elevationFeature,.05*("hd-road-base"!==this.elevationMode),a,l)}}addElevatedGeometry(e,i,r,a,n,o){let[s,l]=this.addGeometry(e,this.elevationBufferData,{elevation:r,elevationSampler:i,bias:a,index:n,featureInfo:o});null==this.elevationBufferData.heightRange?this.elevationBufferData.heightRange={min:s,max:l}:(this.elevationBufferData.heightRange.min=Math.min(this.elevationBufferData.heightRange.min,s),this.elevationBufferData.heightRange.max=Math.max(this.elevationBufferData.heightRange.max,l))}addGeometry(e,i,r){let a=1/0,n=-1/0,o=null;r&&null!=(o=r.elevationSampler.constantElevation(r.elevation,r.bias))&&(a=o,n=o);let s=(e,s,l)=>{if(null!=r)if(s.push(e),null!=o)i.elevatedLayoutVertexArray.emplaceBack(o),l.push(o);else{let o=r.elevationSampler.pointElevation(e,r.elevation,r.bias);i.elevatedLayoutVertexArray.emplaceBack(o),l.push(o),a=Math.min(a,o),n=Math.max(n,o)}};for(let a of e){let e=0;for(let i of a)e+=i.length;let n=i.triangleSegments.prepareSegment(e,i.layoutVertexArray,i.indexArray),o=n.vertexLength,l=[],h=[],u=[],c=[],d=[],p=i.layoutVertexArray.length;for(let e of a){if(0===e.length)continue;e!==a[0]&&h.push(l.length/2);let n=i.lineSegments.prepareSegment(e.length,i.layoutVertexArray,i.lineIndexArray),o=n.vertexLength;r&&d.push(i.layoutVertexArray.length-p),s(e[0],u,c),i.layoutVertexArray.emplaceBack(e[0].x,e[0].y),i.lineIndexArray.emplaceBack(o+e.length-1,o),l.push(e[0].x),l.push(e[0].y);for(let r=1;r<e.length;r++)s(e[r],u,c),i.layoutVertexArray.emplaceBack(e[r].x,e[r].y),i.lineIndexArray.emplaceBack(o+r-1,o+r),l.push(e[r].x),l.push(e[r].y);n.vertexLength+=e.length,n.primitiveLength+=e.length}let f=hb(l,h);for(let e=0;e<f.length;e+=3)i.indexArray.emplaceBack(o+f[e],o+f[e+1],o+f[e+2]);if(f.length>0&&r&&"hd-road-base"===this.elevationMode){let e=r.elevation.isTunnel(),i=r.elevation.safeArea,a=this.elevatedStructures.addVertices(u,c);this.elevatedStructures.addTriangles(f,a,e);let n=d.length;if(n>0){for(let o=0;o<n-1;o++)this.elevatedStructures.addRenderableRing(r.index,d[o]+a,d[o+1]-d[o],e,i,r.featureInfo);this.elevatedStructures.addRenderableRing(r.index,d[n-1]+a,u.length-d[n-1],e,i,r.featureInfo)}}n.vertexLength+=e,n.primitiveLength+=f.length/3}return[a,n]}prepareElevatedPolygons(e,i,r){let a=1/sX(r),n=[];for(let r of e){let e=function(e,i){let r=hK(e,65536),a=[];for(;i.valid();i.next()){let[e,r]=i.get(),n=65536*e.x,o=65536*e.y,s=65536*r.x,l=65536*r.y,h=s-n,u=l-o,c=Math.hypot(h,u);if(0===c)continue;let d=Math.trunc(u/c*3),p=-Math.trunc(h/c*3);a.push([[[n,o],[s,l],[s+d,l+p],[n+d,o+p],[n,o]]])}return a.length>0&&(r=hX.diff(r,a)),hJ(r,152587890625e-16)}(r,new lp(i,a));n.push(...e)}return n}clipPolygonsToTile(e,i){let r=-i,a=-i,n=8192+i,o=8192+i,s=0,l=[],h=[];for(;s<e.length;s++){let i=e[s],u=rn(i);(u.min.x>=r&&u.max.x<=n&&u.min.y>=a&&u.max.y<=o?l:h).push(i)}if(l.length===e.length)return e;let u=[new e3(r,a),new e3(n,a),new e3(n,o),new e3(r,o),new e3(r,a)];for(let e of h)l.push(...function(e,i){let r=hK(e),a=hK([i]),n=hX.intersection(r,a);return null==n?[]:hJ(n)}(e,u));return l}}a3(h0,"FillBucket",{omit:["layers","patternFeatures"]}),a3(hQ,"FillBufferData"),a3(hH,"ElevatedStructures");class h1{constructor(e,i,r,a){if(this.triangleCount=i.length/3,this.min=new e3(0,0),this.max=new e3(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;let[n,o]=[e[0].clone(),e[0].clone()];for(let i=1;i<e.length;++i){let r=e[i];n.x=Math.min(n.x,r.x),n.y=Math.min(n.y,r.y),o.x=Math.max(o.x,r.x),o.y=Math.max(o.y,r.y)}if(a&&(r=Math.max(r,Math.ceil(Math.max(o.x-n.x,o.y-n.y)/a))),0===r)return;this.min=n,this.max=o;let s=this.max.sub(this.min);s.x=Math.max(s.x,1),s.y=Math.max(s.y,1);let l=Math.max(s.x,s.y)/r;this.cellsX=Math.max(1,Math.ceil(s.x/l)),this.cellsY=Math.max(1,Math.ceil(s.y/l)),this.xScale=1/l,this.yScale=1/l;let h=[];for(let r=0;r<this.triangleCount;r++){let a=e[i[3*r+0]].sub(this.min),n=e[i[3*r+1]].sub(this.min),o=e[i[3*r+2]].sub(this.min),s=h2(Math.floor(Math.min(a.x,n.x,o.x)),this.xScale,this.cellsX),u=h2(Math.floor(Math.max(a.x,n.x,o.x)),this.xScale,this.cellsX),c=h2(Math.floor(Math.min(a.y,n.y,o.y)),this.yScale,this.cellsY),d=h2(Math.floor(Math.max(a.y,n.y,o.y)),this.yScale,this.cellsY),p=new e3(0,0),f=new e3(0,0),m=new e3(0,0),_=new e3(0,0);for(let e=c;e<=d;++e){p.y=f.y=e*l,m.y=_.y=(e+1)*l;for(let i=s;i<=u;++i)p.x=m.x=i*l,f.x=_.x=(i+1)*l,(lM(a,n,o,p,f,_)||lM(a,n,o,p,_,m))&&h.push({cellIdx:e*this.cellsX+i,triIdx:r})}}if(0===h.length)return;h.sort((e,i)=>e.cellIdx-i.cellIdx||e.triIdx-i.triIdx);let u=0;for(;u<h.length;){let e=h[u].cellIdx,i={start:this.payload.length,len:0};for(;u<h.length&&h[u].cellIdx===e;)++i.len,this.payload.push(h[u++].triIdx);this.cells[e]=i}}_lazyInitLookup(){this.lookup||(this.lookup=new Uint8Array(Math.ceil(this.triangleCount/8))),this.lookup.fill(0)}queryPoint(e,i){if(0===this.triangleCount||0===this.cells.length||e.x>this.max.x||this.min.x>e.x||e.y>this.max.y||this.min.y>e.y)return;let r=h2(e.x-this.min.x,this.xScale,this.cellsX),a=h2(e.y-this.min.y,this.yScale,this.cellsY),n=this.cells[a*this.cellsX+r];if(n){this._lazyInitLookup();for(let e=0;e<n.len;e++){let r=this.payload[n.start+e],a=Math.floor(r/8),o=1<<r%8;if(!(this.lookup[a]&o)&&(this.lookup[a]|=o,i.push(r),i.length===this.triangleCount))return}}}query(e,i,r){if(0===this.triangleCount||0===this.cells.length||e.x>this.max.x||this.min.x>i.x||e.y>this.max.y||this.min.y>i.y)return;this._lazyInitLookup();let a=h2(e.x-this.min.x,this.xScale,this.cellsX),n=h2(i.x-this.min.x,this.xScale,this.cellsX),o=h2(e.y-this.min.y,this.yScale,this.cellsY),s=h2(i.y-this.min.y,this.yScale,this.cellsY);for(let e=o;e<=s;e++)for(let i=a;i<=n;
7i++){let a=this.cells[e*this.cellsX+i];if(a)for(let e=0;e<a.len;e++){let i=this.payload[a.start+e],n=Math.floor(i/8),o=1<<i%8;if(!(this.lookup[n]&o)&&(this.lookup[n]|=o,r.push(i),r.length===this.triangleCount))return}}}}function h2(e,i,r){return Math.max(0,Math.min(r-1,Math.floor(e*i)))}a3(h1,"TriangleGridIndex");class h3{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}updateFootprints(e,i){for(let r of this.footprints)i.push({footprint:r,id:e})}populate(e,i,r,a){let n=[];for(let{feature:i,id:o,index:s,sourceLayerIndex:l}of e){let e=this.layers[0]._featureFilter.needGeometry,h=s0(i,e);if(!this.layers[0]._featureFilter.filter(new nV(this.zoom,{worldview:this.worldview}),h,r))continue;let u={id:o,properties:i.properties,type:i.type,sourceLayerIndex:l,index:s,geometry:e?h.geometry:sQ(i,r,a),patterns:{}};n.push(u)}for(let a of n){let{geometry:n,index:o,sourceLayerIndex:s}=a;this.addFeature(a,n,o,r,{},i.availableImages,i.brightness),i.featureIndex.insert(e[o].feature,n,o,s,this.index)}}isEmpty(){return 0===this.footprints.length}uploadPending(){return!1}upload(e){}update(e,i,r,a,n,o,s){}destroy(){}addFeature(e,i,r,a,n,o=[],s){for(let e of hB(i,2)){let i=[],r=[],a=[],n=new e3(1/0,1/0),o=new e3(-1/0,-1/0);for(let s of e)if(0!==s.length){s!==e[0]&&a.push(r.length/2);for(let e=0;e<s.length;e++)r.push(s[e].x),r.push(s[e].y),i.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)}let s=hb(r,a),l=new h1(i,s,8,256);this.footprints.push({vertices:i,indices:s,grid:l,min:n,max:o})}}}a3(h3,"ClipBucket",{omit:["layers"]});let h5=ou([{name:"a_pos_normal_ed",components:4,type:"Int16"}]),h4=ou([{name:"a_pos_end",components:4,type:"Int16"},{name:"a_angular_offset_factor",components:1,type:"Int16"}]),h6=ou([{name:"a_centroid_pos",components:2,type:"Uint16"}]),h8=ou([{name:"a_join_normal_inside",components:3,type:"Int16"}]),h9=ou([{name:"a_hidden_by_landmark",components:1,type:"Uint8"}]),h7=ou([{name:"a_pos_3",components:3,type:"Int16"},{name:"a_pos_normal_3",components:3,type:"Int16"}]),{members:ue}=h5,ut=Number.MAX_SAFE_INTEGER,ui=ut-1;function ur(e,i,r,a){var n;return e.order<i||e.order===ut||!(e.clipMask&r)||0!==(n=e.clipScope).length&&void 0===n.find(e=>e===a)}function ua(e,i){return e.x-i.x||e.y-i.y}function un(e,i){return 0===ua(e.min,i.min)&&0===ua(e.max,i.max)}function uo(e,i){return!(e.min.x>i.max.x||e.max.x<i.min.x||e.min.y>i.max.y||e.max.y<i.min.y)}function us(e,i){if(e.length!==i.length)return!1;for(let r=0;r<e.length;r++)if(e[r].sourceId!==i[r].sourceId||!un(e[r],i[r])||e[r].order!==i[r].order||e[r].clipMask!==i[r].clipMask||!e5(e[r].clipScope,i[r].clipScope))return!1;return!0}function ul(e,i,r){let a=1/(1<<r.canonical.z),n=(1220703125e-13*i.x+r.canonical.x)*a+r.wrap,o=(1220703125e-13*i.y+r.canonical.y)*a;return{min:new e3((1220703125e-13*e.x+r.canonical.x)*a+r.wrap,(1220703125e-13*e.y+r.canonical.y)*a),max:new e3(n,o)}}function uh(e,i,r,a,n,o,s){let l=e.indices,h=e.vertices,u=[];for(let c=a;c<a+n;c+=3){let a=i[r[c+0]+o],n=i[r[c+1]+o],d=i[r[c+2]+o],p=Math.min(a.x,n.x,d.x),f=Math.max(a.x,n.x,d.x),m=Math.min(a.y,n.y,d.y),_=Math.max(a.y,n.y,d.y);u.length=0,e.grid.query(new e3(p,m),new e3(f,_),u);for(let e=0;e<u.length;e++){let i=u[e];if(lM(h[l[3*i+0]],h[l[3*i+1]],h[l[3*i+2]],a,n,d,s))return!0}}return!1}function uu(e,i,r,a){let n=Math.pow(2,a.z-r.z);return new e3((e+8192*r.x)*n-8192*a.x,(i+8192*r.y)*n-8192*a.y)}function uc(e,i){let r=[];i.grid.queryPoint(e,r);let a=i.indices,n=i.vertices;for(let i=0;i<r.length;i++){let o=r[i];if(lE([n[a[3*o+0]],n[a[3*o+1]],n[a[3*o+2]]],e))return!0}return!1}let ud=[new e3(0,0),new e3(8192,0),new e3(8192,8192),new e3(0,8192)];function up(e,i){let r=[],a=[];if(!i||e.length<2)return[e];if(2===e.length)return lA(e[0],e[1],ud)?[e]:[];for(let i=0;i<e.length+2;i++){let n=e[i%e.length],o=e[(i+1)%e.length],s=lA(0===i?e[e.length-1]:e[(i-1)%e.length],n,ud),l=lA(n,o,ud),h=s||l;h&&a.push(n),h&&l||a.length>0&&(a.length>1&&r.push(a),a=[])}return a.length>1&&r.push(a),r}let uf=s1.types,um=["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"],u_=["fill-extrusion-flood-light-ground-radius"],ug=new e3(0,1);function uy(e,i,r,a,n,o,s,l){e.emplaceBack((i<<1)+s,(r<<1)+o,(Math.floor(8192*a)<<1)+n,Math.round(l))}function ux(e,i,r){e.emplaceBack(8192*i.x,8192*i.y,+!!r)}function uv(e,i,r,a,n,o){e.emplaceBack(i.x,i.y,(r.x<<1)+a,(r.y<<1)+n,o)}function ub(e,i,r){e.emplaceBack(i.x,i.y,i.z,16384*r[0],16384*r[1],16384*r[2])}class uw{constructor(){this.vertexOffset=0,this.vertexCount=0,this.indexOffset=0,this.indexCount=0}}class uT{constructor(){this.centroidXY=new e3(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 e3(Number.MAX_VALUE,Number.MAX_VALUE),this.max=new e3(-Number.MAX_VALUE,-Number.MAX_VALUE),this.height=0,this.buildingId=0}span(){return new e3(this.max.x-this.min.x,this.max.y-this.min.y)}}class uS{constructor(){this.acc=new e3(0,0),this.accCount=0,this.centroidDataIndex=0}startRing(e,i){e.min.x===Number.MAX_VALUE&&(e.min.x=e.max.x=i.x,e.min.y=e.max.y=i.y)}appendEdge(e,i,r){this.accCount++,this.acc._add(i);let a=!!this.borders;i.x<e.min.x?(e.min.x=i.x,a=!0):i.x>e.max.x&&(e.max.x=i.x,a=!0),i.y<e.min.y?(e.min.y=i.y,a=!0):i.y>e.max.y&&(e.max.y=i.y,a=!0),((0===i.x||8192===i.x)&&i.x===r.x)!=((0===i.y||8192===i.y)&&i.y===r.y)&&this.processBorderOverlap(i,r),a&&this.checkBorderIntersection(i,r)}checkBorderIntersection(e,i){i.x<0!=e.x<0&&this.addBorderIntersection(0,ip(i.y,e.y,(0-i.x)/(e.x-i.x))),i.x>8192!=e.x>
78192&&this.addBorderIntersection(1,ip(i.y,e.y,(8192-i.x)/(e.x-i.x))),i.y<0!=e.y<0&&this.addBorderIntersection(2,ip(i.x,e.x,(0-i.y)/(e.y-i.y))),i.y>8192!=e.y>8192&&this.addBorderIntersection(3,ip(i.x,e.x,(8192-i.y)/(e.y-i.y)))}addBorderIntersection(e,i){this.borders||(this.borders=[[Number.MAX_VALUE,-Number.MAX_VALUE],[Number.MAX_VALUE,-Number.MAX_VALUE],[Number.MAX_VALUE,-Number.MAX_VALUE],[Number.MAX_VALUE,-Number.MAX_VALUE]]);let r=this.borders[e];i<r[0]&&(r[0]=i),i>r[1]&&(r[1]=i)}processBorderOverlap(e,i){if(e.x===i.x){if(e.y===i.y)return;let r=+(0!==e.x);this.addBorderIntersection(r,i.y),this.addBorderIntersection(r,e.y)}else{let r=0===e.y?2:3;this.addBorderIntersection(r,i.x),this.addBorderIntersection(r,e.x)}}centroid(){return 0===this.accCount?new e3(0,0):new e3(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,i)=>e+ +(i[0]!==Number.MAX_VALUE),0):0}}function uE(e,i){let r=e.add(i)._unit();return Math.min(4,Math.max(-4,Math.tan(Math.acos(tt(e.x*r.x+e.y*r.y,-1,1)))))/4*32767*(e.x*i.y-e.y*i.x<0?-1:1)}let uI=[e=>e.x<0,e=>e.x>8192,e=>e.y<0,e=>e.y>8192];class uA{constructor(e){this.vertexArray=new oy,this.indexArray=new oD,this.programConfigurations=new sA(e.layers,{zoom:e.zoom,lut:e.lut},e=>u_.includes(e)),this._segments=new se,this.hiddenByLandmarkVertexArray=new oZ,this._segmentToGroundQuads={},this._segmentToGroundQuads[0]=[],this._segmentToRegionTriCounts={},this._segmentToRegionTriCounts[0]=[0,0,0,0,0],this.regionSegments={},this.regionSegments[4]=new se}getDefaultSegment(){return this.regionSegments[4]}hasData(){return 0!==this.vertexArray.length}addData(e,i,r,a=!1){let n=e.length;if(n>2){let o,s=Math.max(0,this._segments.get().length-1),l=this._segments._prepareSegment(4*n,this.vertexArray.length,2*this._segmentToGroundQuads[s].length);s!==this._segments.get().length-1&&(s++,this._segmentToGroundQuads[s]=[],this._segmentToRegionTriCounts[s]=[0,0,0,0,0]);{let i=e[0],r=e[1];o=uE(i.sub(e[n-1])._perp()._unit(),r.sub(i)._perp()._unit())}for(let h=0;h<n;h++){let u=h===n-1?0:h+1,c=e[h],d=e[u],p=e[u===n-1?0:u+1],f=d.sub(c)._perp()._unit(),m=uE(f,p.sub(d)._perp()._unit()),_=o;if(uz(c,d,i)||a&&uR(c,i)&&uR(d,i)){o=m;continue}let g=l.vertexLength;for(let e of(uv(this.vertexArray,c,d,1,1,_),uv(this.vertexArray,c,d,1,0,_),uv(this.vertexArray,c,d,0,1,m),uv(this.vertexArray,c,d,0,0,m),l.vertexLength+=4,function(e,i,r,a){let n=[4];if(0===a)return n;r._mult(a);let o=e.sub(r),s=i.sub(r),l=[e,i,o,s];for(let e=0;e<4;e++)for(let i of l)if(uI[e](i)){n.push(e);break}return n}(c,d,f,r)))this._segmentToGroundQuads[s].push({id:g,region:e}),this._segmentToRegionTriCounts[s][e]+=2,l.primitiveLength+=2;o=m}}}prepareBorderSegments(){if(!this.hasData())return;let e=this._segments.get(),i=e.length;for(let e=0;e<i;e++)this._segmentToGroundQuads[e].sort((e,i)=>e.region-i.region);for(let r=0;r<i;r++){let i=this._segmentToGroundQuads[r],a=e[r],n=this._segmentToRegionTriCounts[r];n.reduce((e,i)=>e+i,0);let o=0;for(let e=0;e<=4;e++){let i=n[e];if(0!==i){let r=this.regionSegments[e];r||(r=this.regionSegments[e]=new se);let n={vertexOffset:a.vertexOffset,primitiveOffset:a.primitiveOffset+o,vertexLength:a.vertexLength,primitiveLength:i};r.get().push(n)}o+=i}for(let e=0;e<i.length;e++){let r=i[e].id;this.indexArray.emplaceBack(r,r+1,r+3),this.indexArray.emplaceBack(r,r+3,r+2)}}this._segmentToGroundQuads=null,this._segmentToRegionTriCounts=null,this._segments.destroy(),this._segments=null}addPaintPropertiesData(e,i,r,a,n,o,s){this.hasData()&&this.programConfigurations.populatePaintArrays(this.vertexArray.length,e,i,r,a,n,o,void 0,s)}upload(e){this.hasData()&&(this.vertexBuffer=e.createVertexBuffer(this.vertexArray,h4.members),this.indexBuffer=e.createIndexBuffer(this.indexArray))}uploadPaintProperties(e){this.hasData()&&this.programConfigurations.upload(e)}update(e,i,r,a,n,o,s,l){this.hasData()&&this.programConfigurations.updatePaintArrays(e,i,r,a,n,o,s,l)}updateHiddenByLandmark(e){this.updateHiddenByLandmarkRange(e.groundVertexArrayOffset,e.groundVertexCount,!!(0x80000000&e.flags))}updateHiddenByLandmarkRange(e,i,r){if(!this.hasData())return;let a=i+e;if(0!==i){for(let i=e;i<a;++i)this.hiddenByLandmarkVertexArray.emplace(i,+!!r);this._needsHiddenByLandmarkUpdate=!0}}uploadHiddenByLandmark(e){this.hasData()&&this._needsHiddenByLandmarkUpdate&&(!this.hiddenByLandmarkVertexBuffer&&this.hiddenByLandmarkVertexArray.length>0?this.hiddenByLandmarkVertexBuffer=e.createVertexBuffer(this.hiddenByLandmarkVertexArray,h9.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._segments&&this._segments.destroy(),this.programConfigurations.destroy();for(let e=0;e<=4;e++){let i=this.regionSegments[e];i&&i.destroy()}}}}class uC{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 oD,this.footprintVertices=new od,this.footprintSegments=[],this.layoutVertexArray=new of,this.centroidVertexArray=new o5,this.wallVertexArray=new o6,this.indexArray=new oD,this.programConfigurations=new sA(e.layers,{zoom:e.zoom,lut:e.lut},e=>um.includes(e)),this.segments=new se,this.stateDependentLayerIds=this.layers.filter(e=>e.isStateDependent()).map(e=>e.id),this.groundEffect=new uA(e),this.maxHeight=0,this.partLookup={},this.triangleSubSegments=[],this.polygonSegments=[],this.worldview=e.worldview}updateFootprints(e,i){}populate(e,i,r,a){for(let{feature:n,id:o,index:s,sourceLayerIndex:l}of(this.features=[],this.hasPattern=hU("fill-extrusion",this.layers,this.pixelRatio,i),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=sX(r),this.edgeRadius=this.layers[0].layout.get("fill-extrusion-edge-radius")/this.tileToMeter,this.wallMode=0!==this.layers[0].paint.get("fill-extrusion-line-width").constantOr(1),e)){let e=this.layers[0]._featureFilter.needGeometry,h=s0(n,e);if(!this.layers[0]._featureFilter.filter(new nV(this.zoom,{worldview:this.worldview}),h,r))continue;let u={id:o,sourceLayerIndex:l,index:s,geometry:e?h.geometry:sQ(n,r,a),properties:n.properties,type:n.type,patterns:{}},c=this.layoutVertexArray.length,d="Polygon"===uf[u.type];if(this.hasPattern)this.features.push({featureId:n.id,feature:hj("fill-extrusion",this.layers,u,this.zoom,this.pixelRatio,i)});else if(this.wallMode)for(let e of u.geometry)for(let o of up(e,d))this.addFeature(n.id,u,[o],s,r,{},i.availableImages,a,i.brightness);else this.addFeature(n.id,u,u.geometry,s,r,{},i.availableImages,a,i.brightness);i.featureIndex.insert(n,u.geometry,s,l,this.index,c)}this.sortBorders(),"mercator"===this.projection.name&&this.splitToSubtiles(),this.groundEffect.prepareBorderSegments(),this.polygonSegments.length=0}addFeatures(e,i,r,a,n,o){for(let{featureId:e,feature:s}of this.features){let l="Polygon"===uf[s.type],{geometry:h}=s;
7if(this.wallMode)for(let u of h)for(let h of up(u,l))this.addFeature(e,s,[h],s.index,i,r,a,n,o);else this.addFeature(e,s,h,s.index,i,r,a,n,o)}this.sortBorders(),"mercator"===this.projection.name&&this.splitToSubtiles()}update(e,i,r,a,n,o,s){this.programConfigurations.updatePaintArrays(e,i,n,r,a,o,s,this.worldview),this.groundEffect.update(e,i,n,r,a,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,ue),this.indexBuffer=e.createIndexBuffer(this.indexArray),this.wallVertexBuffer=e.createVertexBuffer(this.wallVertexArray,h8.members),this.layoutVertexExtArray&&(this.layoutVertexExtBuffer=e.createVertexBuffer(this.layoutVertexExtArray,h7.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,h6.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,i,r,a,n,o,s,l,h){var u;let c,d,p=this.layers[0].paint.get("fill-extrusion-flood-light-ground-radius").evaluate(i,{})/this.tileToMeter,f=[new e3(0,0),new e3(8192,8192)],m=l.projection,_="globe"===m.name,g=this.wallMode||"Polygon"===uf[i.type],y=new uS;y.centroidDataIndex=this.centroidData.length;let x=new uT;x.buildingId=e,i.properties&&i.properties.hasOwnProperty("building_id")&&(x.buildingId=i.properties.building_id);let v=0>=this.layers[0].paint.get("fill-extrusion-base").evaluate(i,{},n),b=this.layers[0].paint.get("fill-extrusion-height").evaluate(i,{},n);if(x.height=b,x.vertexArrayOffset=this.layoutVertexArray.length,x.groundVertexArrayOffset=this.groundEffect.vertexArray.length,_&&!this.layoutVertexExtArray&&(this.layoutVertexExtArray=new oT),this.wallMode){if(_)return void tf("Non zero fill-extrusion-line-width is not yet supported on globe.");if(1!==r.length)return;r=[(c=function(e){let i=e[0].x===e[e.length-1].x&&e[0].y===e[e.length-1].y;(function(e){let i=0,r=e.length;for(let a=0;a<r;a++)i+=(e[(a+1)%r].x-e[a].x)*(e[(a+1)%r].y+e[a].y);return i>=0})(e)||(e=e.reverse());let r={geometry:[],joinNormals:[],indices:[]},a=[],n=[],o=[],s=e.length;for(;s>=2&&e[s-1].equals(e[s-2]);)s--;if(s<(i?3:2))return r;let l,h,u,c,d,p=0;for(;p<s-1&&e[p].equals(e[p+1]);)p++;i&&(l=e[s-2],d=e[p].sub(l)._unit()._perp());for(let r=p;r<s;r++){if((u=r===s-1?i?e[p+1]:void 0:e[r+1])&&e[r].equals(u))continue;d&&(c=d),l&&(h=l),l=e[r],d=u?u.sub(l)._unit()._perp():c;let f=(c=c||d).add(d);0===f.x&&0===f.y||f._unit();let m=f.x*d.x+f.y*d.y,_=0!==m?1/m:1/0,g=c.x*d.y-c.y*d.x>0,y="miter";"miter"===y&&_>2&&(y="bevel"),"bevel"===y&&(_>100&&(y="flipbevel"),_<2&&(y="miter"));let x=(e,i,r,s)=>{let l=new e3(e.x,e.y),h=new e3(e.x,e.y);l.x+=i.x*s,l.y+=i.y*s,h.x-=i.x*Math.max(r,1),h.y-=i.y*Math.max(r,1),o.push(i),a.push(l),n.push(h)};if("miter"===y)f._mult(_),x(l,f,0,0);else if("flipbevel"===y)x(l,f=d.mult(-1),0,0),x(l,f.mult(-1),0,0);else{let e=-Math.sqrt(_*_-1),i=g?e:0,r=g?0:e;h&&x(l,c,i,r),u&&x(l,d,i,r)}}r.geometry=[...a,...n.reverse(),a[0]],r.joinNormals=[...o,...o.reverse(),o[o.length-1]];let f=r.geometry.length-1;for(let e=0;e<f/2;e++)if(e+1<f/2){let i=e,a=e+1,n=f-1-e,o=f-2-e;i=0===i?f-1:i-1,a=0===a?f-1:a-1,n=0===n?f-1:n-1,o=0===o?f-1:o-1,r.indices.push(n),r.indices.push(a),r.indices.push(i),r.indices.push(n),r.indices.push(o),r.indices.push(a)}return r}(r[0])).geometry]}let w=(e,i)=>e<(i.length-1)/2||e===i.length-1,T=this.wallMode?[r]:hB(r,500);for(let e=T.length-1;e>=0;e--){let i=T[e];(0===i.length||(u=i[0]).every(e=>e.x<=0)||u.every(e=>e.x>=8192)||u.every(e=>e.y<=0)||u.every(e=>e.y>=8192))&&T.splice(e,1)}if(_)d=uF(T,f,n);else for(let e of(d=[],T))d.push({polygon:e,bounds:f});let S=g?this.edgeRadius:0,E=S>0&&this.zoom<17,I=(e,i)=>{if(0===e.length)return!1;let r=e[e.length-1];return i.x===r.x&&i.y===r.y};for(let{polygon:e,bounds:i}of d){let r=0,a=0;for(let i of e)g&&!i[0].equals(i[i.length-1])&&i.push(i[0]),a+=g?i.length-1:i.length;let o=this.segments.prepareSegment((g?5:4)*a,this.layoutVertexArray,this.indexArray);x.footprintSegIdx<0&&(x.footprintSegIdx=this.footprintSegments.length),x.polygonSegIdx<0&&(x.polygonSegIdx=this.polygonSegments.length);let s={triangleArrayOffset:this.indexArray.length,triangleCount:0,triangleSegIdx:this.segments.segments.length-1},l=new uw;if(l.vertexOffset=this.footprintVertices.length,l.indexOffset=3*this.footprintIndices.length,l.ringIndices=[],g){let a=[],s=[];r=o.vertexLength;for(let r=0;r<e.length;r++){let h,u,d=e[r];d.length&&0!==r&&s.push(a.length/2);let f=[];h=d[1].sub(d[0])._perp()._unit(),l.ringIndices.push(d.length-1);for(let e=1;e<d.length;e++){let i=d[e],r=d[e===d.length-1?1:e+1],s=i.clone();if(S){u=r.sub(i)._perp()._unit();let e=h.add(u)._unit(),a=S*Math.min(4,1/(h.x*e.x+h.y*e.y));s.x+=a*e.x,s.y+=a*e.y,s.x=Math.round(s.x),s.y=Math.round(s.y),h=u}if(!v||0!==S&&!E||I(f,s)||f.push(s),uy(this.layoutVertexArray,s.x,s.y,0,0,1,1,0),this.wallMode){let i=w(e,d);ux(this.wallVertexArray,c.joinNormals[e],!i)}o.vertexLength++,this.footprintVertices.emplaceBack(i.x,i.y),a.push(i.x,i.y),_&&ub(this.layoutVertexExtArray,m.projectTilePoint(s.x,s.y,n),m.upVector(n,s.x,s.y))}v&&(0===S||E)&&(0!==f.length&&I(f,f[0])&&f.pop(),this.groundEffect.addData(f,i,p))}let h=this.wallMode?c.indices:hb(a,s);for(let e=0;e<h.length;e+=3)this.footprintIndices.emplaceBack(l.vertexOffset+h[e+0],l.vertexOffset+h[e+1],l.vertexOffset+h[e+2]),this.indexArray.emplaceBack(r+h[e],r+h[e+2],r+h[e+1]),o.primitiveLength++;l.indexCount+=h.length,l.vertexCount+=this.footprintVertices.length-l.vertexOffset}for(let a=0;a<e.length;a++){let s,l,h,u=e[a];y.startRing(x,u[0]);let d=u.length>4&&uD(u[u.length-2],u[0],u[1]),f=S?function(e,i,r,a){let n=i.sub(e)._perp()._unit(),o=r.sub(i)._perp()._unit();return uP(e,i,r,uM(n,o),a)}(u[u.length-2],u[0],u[1],S):0,b=[];l=u[1].sub(u[0])._perp()._unit();let T=!0;for(let e=1,a=0;e<u.length;e++){let p=u[e-1],g=u[e],E=u[e===u.length-1?1:e+1];if(y.appendEdge(x,g,p),uz(g,p,i)){S&&(l=E.sub(g)._perp()._unit(),T=!T);continue}let A=g.sub(p)._perp(),C=A.x/(Math.abs(A.x)+Math.abs(A.y)),M=+(A.y>0),P=p.dist(g);if(a+P>32768&&(a=0),S){h=E.sub(g)._perp()._unit();let e=uP(p,g,E,uM(l,h),S);isNaN(e)&&(e=0);let i=g.sub(p)._unit();p=p.add(i.mult(f))._round(),g=g.add(i.mult(-e))._round(),f=e,l=h,v&&this.zoom>=17&&(I(b,p)||b.push(p),I(b,g)||b.push(g))}let z=o.vertexLength,R=u.length>4&&uD(p,g,E),D=uL(a,d,T);if(uy(this.layoutVertexArray,p.x,p.y,C,M,0,0,D),uy(this.layoutVertexArray,p.x,p.y,C,M,0,1,D),this.wallMode){let i=w(e-1,u),r=c.joinNormals[e-1];ux(this.wallVertexArray,r,i),ux(this.wallVertexArray,r,i)}if(a+=P,D=uL(a,R,!T),d=R,uy(this.layoutVertexArray,g.x,g.y,C,M,0,0,D),uy(this.layoutVertexArray,g.x,g.y,C,M,0,1,D),this.wallMode){let i=w(e,u),r=c.joinNormals[e];ux(this.wallVertexArray,r,i),ux(this.wallVertexArray,r,i)}if(o.vertexLength+=4,this.indexArray.emplaceBack(z+0,z+1,z+2),this.indexArray.emplaceBack(z+1,z+3,z+2),o.primitiveLength+=2,S){let a=r+(1===e?u.length-2:e-2),n=1===e?r:a+1;if(this.indexArray.emplaceBack(z+1,a,z+3),this.indexArray.emplaceBack(a,n,z+3),o.primitiveLength+=2,void 0===s&&(s=z),!uz(E,u[e],i)){let i=e===u.length-1?s:o.vertexLength;this.indexArray.emplaceBack(z+2,z+3,i),this.indexArray.emplaceBack(z+3,i+1,i),this.indexArray.emplaceBack(z+3,n,i+1),o.primitiveLength+=3}T=!T}if(_){let e=this.layoutVertexExtArray,i=m.projectTilePoint(p.x,p.y,n),r=m.projectTilePoint(g.x,g.y,n),a=m.upVector(n,p.x,p.y),o=m.upVector(n,g.x,g.y);ub(e,i,a),ub(e,i,a),ub(e,r,o),ub(e,r,o)}}g&&(r+=u.length-1),v&&S&&this.zoom>=17&&(0!==b.length&&I(b,b[0])&&b.pop(),this.groundEffect.addData(b,i,p,S>0))}this.footprintSegments.push(l),s.triangleCount=this.indexArray.length-s.triangleArrayOffset,this.polygonSegments.push(s),++x.footprintSegLen,++x.polygonSegLen}if(x.vertexCount=this.layoutVertexArray.length-x.vertexArrayOffset,x.groundVertexCount=this.groundEffect.vertexArray.length-x.groundVertexArrayOffset,0!==x.vertexCount){if(x.centroidXY=y.borders?ug:this.encodeCentroid(y,x),this.centroidData.push(x),y.borders){this.featuresOnBorder.push(y);let e=this.featuresOnBorder.length-1;for(let i=0;i<y.borders.length;i++)y.borders[i][0]!==Number.MAX_VALUE&&this.borderFeatureIndices[i].push(e)}this.programConfigurations.populatePaintArrays(this.layoutVertexArray.length,i,a,o,s,n,h,void 0,this.worldview),this.groundEffect.addPaintPropertiesData(i,a,o,s,n,h,this.worldview),this.maxHeight=Math.max(this.maxHeight,b)}}sortBorders(){for(let e=0;e<this.borderFeatureIndices.length;e++)this.borderFeatureIndices[e].sort((i,r)=>this.featuresOnBorder[i].borders[e][0]-this.featuresOnBorder[r].borders[e][0])}splitToSubtiles(){let e=[];for(let i=0;i<this.centroidData.length;i++){let r=this.centroidData[i],a=+(r.min.y+r.max.y>8192),n=2*a+(r.min.x+r.max.x>8192^a);for(let a=0;a<r.polygonSegLen;a++){let o=r.polygonSegIdx+a;e.push({centroidIdx:i,subtile:n,polygonSegmentIdx:o,triangleSegmentIdx:this.polygonSegments[o].triangleSegIdx})}}let i=new oD;e.sort((e,i)=>e.triangleSegmentIdx===i.triangleSegmentIdx?e.subtile-i.subtile:e.triangleSegmentIdx-i.triangleSegmentIdx);let r=0,a=0,n=0;
7for(let i of e){if(i.triangleSegmentIdx!==r)break;n++}let o=e.length;for(;a!==e.length;){r=e[a].triangleSegmentIdx;let s=0,l=a,h=a;for(let i=l;i<n&&e[i].subtile===s;i++)h++;for(;l!==n;){let a=e[l];s=a.subtile;let o=this.centroidData[a.centroidIdx].min.clone(),u=this.centroidData[a.centroidIdx].max.clone(),c={vertexOffset:this.segments.segments[r].vertexOffset,primitiveOffset:i.length,vertexLength:this.segments.segments[r].vertexLength,primitiveLength:0,sortKey:void 0,vaos:{}};for(let r=l;r<h;r++){let a=e[r],n=this.polygonSegments[a.polygonSegmentIdx],s=this.centroidData[a.centroidIdx].min,l=this.centroidData[a.centroidIdx].max,h=this.indexArray.uint16;for(let e=n.triangleArrayOffset;e<n.triangleArrayOffset+n.triangleCount;e++)i.emplaceBack(h[3*e],h[3*e+1],h[3*e+2]);c.primitiveLength+=n.triangleCount,o.x=Math.min(o.x,s.x),o.y=Math.min(o.y,s.y),u.x=Math.max(u.x,l.x),u.y=Math.max(u.y,l.y)}c.primitiveLength>0&&this.triangleSubSegments.push({segment:c,min:o,max:u}),l=h;for(let i=l;i<n&&e[i].subtile===e[l].subtile;i++)h++}a=n;for(let i=a;i<o&&e[i].triangleSegmentIdx===e[a].triangleSegmentIdx;i++)n++}i._trim(),this.indexArray=i}getVisibleSegments(e,i,r){let a,n=new se;if(this.wallMode){for(let e of this.triangleSubSegments)n.segments.push(e.segment);return n}let o=0,s=0,l=1<<e.canonical.z;if(i){let r=i.getMinMaxForTile(e);r&&(o=r.min,s=r.max)}s+=this.maxHeight;let h=e.toUnwrapped(),u=[h.canonical.x/l+h.wrap,h.canonical.y/l],c=[(h.canonical.x+1)/l+h.wrap,(h.canonical.y+1)/l],d=(e,i,r)=>[e[0]*(1-r[0])+i[0]*r[0],e[1]*(1-r[1])+i[1]*r[1]],p=[],f=[];for(let e of this.triangleSubSegments){p[0]=e.min.x/8192,p[1]=e.min.y/8192,f[0]=e.max.x/8192,f[1]=e.max.y/8192;let i=d(u,c,p),l=d(u,c,f);if(0===new ld([i[0],i[1],o],[l[0],l[1],s]).intersectsPrecise(r)){a&&(n.segments.push(a),a=void 0);continue}let h=e.segment;a&&a.vertexOffset!==h.vertexOffset&&(n.segments.push(a),a=void 0),a?(a.vertexLength+=h.vertexLength,a.primitiveLength+=h.primitiveLength):a={vertexOffset:h.vertexOffset,primitiveLength:h.primitiveLength,vertexLength:h.vertexLength,primitiveOffset:h.primitiveOffset,sortKey:void 0,vaos:{}}}return a&&n.segments.push(a),n}encodeCentroid(e,i){let r=e.centroid(),a=i.span(),n=Math.min(7,Math.round(a.x*this.tileToMeter/10)),o=Math.min(7,Math.round(a.y*this.tileToMeter/10));return new e3(tt(r.x,1,8191)<<3|n,tt(r.y,1,8191)<<3|o)}encodeBorderCentroid(e){if(!e.borders)return new e3(0,0);let i=e.borders,r=Number.MAX_VALUE;if(i[0][0]!==r||i[1][0]!==r){let e=+(i[0][0]===r);return new e3(6|65528*(i[0][0]===r),(i[e][0]+i[e][1])/2<<3|6)}{let e=i[2][0]!==r?2:3;return new e3((i[e][0]+i[e][1])/2<<3|6,6|65528*(i[2][0]===r))}}showCentroid(e){let i=this.centroidData[e.centroidDataIndex];i.flags&=0x7fffffff,i.centroidXY.x=0,i.centroidXY.y=0,this.writeCentroidToBuffer(i)}writeCentroidToBuffer(e){this.groundEffect.updateHiddenByLandmark(e);let i=e.vertexArrayOffset,r=e.vertexCount+e.vertexArrayOffset,a=0x80000000&e.flags?ug:e.centroidXY,n=this.centroidVertexArray.geta_centroid_pos0(i);if(this.centroidVertexArray.geta_centroid_pos1(i)!==a.y||n!==a.x){for(let e=i;e<r;++e)this.centroidVertexArray.emplace(e,a.x,a.y);this.needsCentroidUpdate=!0}}createCentroidsBuffer(){for(let e of(this.centroidVertexArray.resize(this.layoutVertexArray.length),this.groundEffect.hiddenByLandmarkVertexArray.resize(this.groundEffect.vertexArray.length),this.centroidData))this.writeCentroidToBuffer(e)}updateReplacement(e,i,r){if(i.updateTime===this.replacementUpdateTime)return;this.replacementUpdateTime=i.updateTime;let a=i.getReplacementRegionsForTile(e.toUnwrapped());if(us(this.activeReplacements,a))return;if(this.activeReplacements=a,0===this.centroidVertexArray.length)this.createCentroidsBuffer();else for(let e of this.centroidData)e.flags&=0x7fffffff;let n=[];for(let i of this.activeReplacements){if(i.order<r)continue;let a=Math.max(1,Math.pow(2,i.footprintTileId.canonical.z-e.canonical.z));if(i.footprint.buildingId){let e=i.footprint.buildingId;for(let i of this.centroidData)i.buildingId===e&&(i.flags|=0x80000000)}else for(let r of this.centroidData)if(!(0x80000000&r.flags||i.min.x>r.max.x||r.min.x>i.max.x||i.min.y>r.max.y||r.min.y>i.max.y))for(let o=0;o<r.footprintSegLen;o++){let s=this.footprintSegments[r.footprintSegIdx+o];if(n.length=0,function(e,i,r,a,n,o){let s=Math.pow(2,a.z-n.z);for(let l=0;l<r;l++){let r=e.int16[2*(l+i)+0],h=e.int16[2*(l+i)+1];r=(r+8192*n.x)*s-8192*a.x,h=(h+8192*n.y)*s-8192*a.y,o.push(new e3(r,h))}}(this.footprintVertices,s.vertexOffset,s.vertexCount,i.footprintTileId.canonical,e.canonical,n),uh(i.footprint,n,this.footprintIndices.uint16,s.indexOffset,s.indexCount,-s.vertexOffset,
7-a)){r.flags|=0x80000000;break}}}for(let e of this.centroidData)this.writeCentroidToBuffer(e);this.borderDoneWithNeighborZ=[-1,-1,-1,-1]}footprintContainsPoint(e,i,r){let a=!1;for(let n=0;n<r.footprintSegLen;n++){let o=this.footprintSegments[r.footprintSegIdx+n],s=0;for(let r of o.ringIndices){for(let n=s,l=r+s-1;n<r+s;l=n++){let r=this.footprintVertices.int16[2*(n+o.vertexOffset)+0],s=this.footprintVertices.int16[2*(n+o.vertexOffset)+1],h=this.footprintVertices.int16[2*(l+o.vertexOffset)+1];s>i!=h>i&&e<(this.footprintVertices.int16[2*(l+o.vertexOffset)+0]-r)*(i-s)/(h-s)+r&&(a=!a)}s=r}}return a}getHeightAtTileCoord(e,i){let r=-1/0,a=!0,n=4*(e+8192)*8192+(i+8192);if(this.partLookup.hasOwnProperty(n)){let e=this.partLookup[n];return e?{height:e.height,hidden:!!(0x80000000&e.flags)}:void 0}for(let o of this.centroidData)e>o.max.x||o.min.x>e||i>o.max.y||o.min.y>i||o.height<=r||this.footprintContainsPoint(e,i,o)&&(r=o.height,this.partLookup[n]=o,a=!!(0x80000000&o.flags));if(r!==-1/0)return{height:r,hidden:a};this.partLookup[n]=void 0}}function uM(e,i){let r=e.add(i)._unit();return e.x*r.x+e.y*r.y}function uP(e,i,r,a,n){let o=Math.sqrt(1-a*a);return Math.min(e.dist(i)/3,i.dist(r)/3,n*o/a)}function uz(e,i,r){return e.x<r[0].x&&i.x<r[0].x||e.x>r[1].x&&i.x>r[1].x||e.y<r[0].y&&i.y<r[0].y||e.y>r[1].y&&i.y>r[1].y}function uR(e,i){return e.x<i[0].x||e.x>i[1].x||e.y<i[0].y||e.y>i[1].y}function uD(e,i,r){if(e.x<0||e.x>=8192||i.x<0||i.x>=8192||r.x<0||r.x>=8192)return!1;let a=r.sub(i),n=a.perp(),o=e.sub(i);return(a.x*o.x+a.y*o.y)/Math.sqrt((a.x*a.x+a.y*a.y)*(o.x*o.x+o.y*o.y))>-.866&&n.x*o.x+n.y*o.y<0}function uL(e,i,r){let a=i?2|e:-3&e;return r?1|a:-2&a}function uO(){let e=Math.tan(Math.PI/32);return 6371008.8*Math.sqrt(1+2*e*e)-6371008.8}function uF(e,i,r){let a=1<<r.z,n=sG(r.x/a),o=sG((r.x+1)/a);return function(e,i,r,a,n=0,o){let s=[];if(!e.length||!r||!a)return s;let l=(e,i)=>{for(let r of e)s.push({polygon:r,bounds:i})},h=Math.ceil(Math.log2(r)),u=Math.ceil(Math.log2(a)),c=h-u,d=[];for(let e=0;e<Math.abs(c);e++)d.push(c>0?0:1);for(let e=0;e<Math.min(h,u);e++)d.push(0),d.push(1);let p=e;if(p=hY(p,i[0].y-n,i[1].y+n,1),!(p=hY(p,i[0].x-n,i[1].x+n,0)).length)return s;let f=[];for(d.length?f.push({polygons:p,bounds:i,depth:0}):l(p,i);f.length;){let e=f.pop(),i=e.depth,r=d[i],a=e.bounds[0],s=e.bounds[1],h=0===r?a.x:a.y,u=0===r?s.x:s.y,c=o?o(r,h,u):.5*(h+u),p=hY(e.polygons,h-n,c+n,r),m=hY(e.polygons,c-n,u+n,r);if(p.length){let e=[a,new e3(0===r?c:s.x,1===r?c:s.y)];d.length>i+1?f.push({polygons:p,bounds:e,depth:i+1}):l(p,e)}if(m.length){let e=[new e3(0===r?c:a.x,1===r?c:a.y),s];d.length>i+1?f.push({polygons:m,bounds:e,depth:i+1}):l(m,e)}}return s}(e,i,Math.ceil((o-n)/11.25),Math.ceil((sq(r.y/a)-sq((r.y+1)/a))/11.25),1,(e,i,n)=>{if(0===e)return .5*(i+n);{let e=sq((r.y+i/8192)/a);return(sj(.5*(sq((r.y+n/8192)/a)+e))*a-r.y)*8192}})}a3(uC,"FillExtrusionBucket",{omit:["layers","features"]}),a3(uT,"PartData"),a3(uw,"FootprintSegment"),a3(uS,"BorderCentroidData"),a3(uA,"GroundEffect");class uk extends e3{constructor(e,i,r){super(e,i),this.z=r}}class uB extends uk{constructor(e,i,r,a){super(e,i,r),this.w=a}}function uN(e,i,r,a){let n="x"===r?"y":"x",o=(a-e[r])/(i[r]-e[r]);e[n]=Math.round(e[n]+(i[n]-e[n])*o),e[r]=a,e.hasOwnProperty("z")&&(e.z=ip(e.z,i.z,o)),e.hasOwnProperty("w")&&(e.w=ip(e.w,i.w,o))}function uV(e,i,r,a){for(let n of["x","y"]){let o=e,s=i;o[n]>=s[n]&&(o=i,s=e),o[n]<r&&s[n]>r&&uN(o,s,n,r),o[n]<a&&s[n]>a&&uN(s,o,n,a)}}function uU(e,i,r,a,n,o){let s=[];for(let l=0;l<e.length;l++){let h,u=e[l],c=s.length,d=0;for(let e=0;e<u.length-1;e++){let c,p,f=u[e],m=u[e+1],_=0,g=d;o&&(d+=_=Math.hypot(m.x-f.x,m.y-f.y),c=f,p=m),f.x<i&&m.x<i||(f.x<i?f=new e3(i,f.y+(i-f.x)/(m.x-f.x)*(m.y-f.y))._round():m.x<i&&(m=new e3(i,f.y+(i-f.x)/(m.x-f.x)*(m.y-f.y))._round()),f.y<r&&m.y<r||(f.y<r?f=new e3(f.x+(r-f.y)/(m.y-f.y)*(m.x-f.x),r)._round():m.y<r&&(m=new e3(f.x+(r-f.y)/(m.y-f.y)*(m.x-f.x),r)._round()),f.x>=a&&m.x>=a||(f.x>=a?f=new e3(a,f.y+(a-f.x)/(m.x-f.x)*(m.y-f.y))._round():m.x>=a&&(m=new e3(a,f.y+(a-f.x)/(m.x-f.x)*(m.y-f.y))._round()),f.y>=n&&m.y>=n||(f.y>
7=n?f=new e3(f.x+(n-f.y)/(m.y-f.y)*(m.x-f.x),n)._round():m.y>=n&&(m=new e3(f.x+(n-f.y)/(m.y-f.y)*(m.x-f.x),n)._round()),h&&f.equals(h[h.length-1])||(h=[f],s.push(h),o&&o.push({progress:{min:g+uj(c,p,f)*_,max:1},parentIndex:l,prevPoint:c,nextPoint:p})),h.push(m),o&&(o[o.length-1].progress.max=g+uj(c,p,m)*_,o[o.length-1].nextPoint=p)))))}if(o&&d>0)for(let e=c;e<s.length;e++)o[e].progress.min/=d,o[e].progress.max/=d}return s}function uj(e,i,r){return e.x!==i.x?(r.x-e.x)/(i.x-e.x):e.y!==i.y?(r.y-e.y)/(i.y-e.y):0}function uG(e,i){return e.x*i.x+e.y*i.y}function uq(e,i){if(1===e.length){let r,a=0,n=i[a++];for(;!r||n.equals(r);)if(!(r=i[a++]))return 1/0;for(;a<i.length;a++){let o=i[a],s=e[0],l=r.sub(n),h=o.sub(n),u=s.sub(n),c=uG(l,l),d=uG(l,h),p=uG(h,h),f=uG(u,l),m=uG(u,h),_=c*p-d*d,g=(p*f-d*m)/_,y=(c*m-d*f)/_,x=n.z*(1-g-y)+r.z*g+o.z*y;if(isFinite(x))return x}return 1/0}{let e=1/0;for(let r of i)e=Math.min(e,r.z);return e}}function u$(e,i,r,a,n,o,s,l){let h=s*n.getElevationAt(e,i,!0,!0),u=0!==o[0],c=u?0===o[1]?s*(o[0]/7-450):s*function(e,i,r){var a,n;let o=Math.floor(i[0]/8),s=Math.floor(i[1]/8),l=10*(i[0]-8*o),h=10*(i[1]-8*s),u=e.getElevationAt(o,s,!0,!0),c=e.getMeterToDEM(r),d=Math.floor(.5*(l*c-1)),p=Math.floor(.5*(h*c-1)),f=e.tileCoordToPixel(o,s),m=2*d+1,_=2*p+1,g=(a=f.x-d,n=f.y-p,[e.getElevationAtPixel(a,n,!0),e.getElevationAtPixel(a+_,n,!0),e.getElevationAtPixel(a,n+_,!0),e.getElevationAtPixel(a+m,n+_,!0)]),y=Math.abs(g[0]-g[1]),x=Math.abs(g[2]-g[3]);return u+Math.max(Math.min(.25,.5*c*(y+x)/m)*l,Math.min(.25,.5*c*(Math.abs(g[0]-g[2])+Math.abs(g[1]-g[3]))/_)*h)}(n,o,l):h;return{base:h+(0===r?-1:r),top:u?Math.max(c+a,h+r+2):h+a}}class uH{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 uZ{constructor(){this.tasks={},this.taskQueue=[],tl(["process"],this),this.invoker=new uH(this.process),this.nextId=0}add(e,i){let r=this.nextId++,a=function({type:e,isSymbolTile:i,zoom:r}){return r=r||0,"message"===e?0:"maybePrepare"!==e||i?"parseTile"!==e||i?"parseTile"===e&&i?300-r:"maybePrepare"===e&&i?400-r:500:200-r:100-r}(i);return 0===a?(e(),null):(this.tasks[r]={fn:e,metadata:i,priority:a,id:r},this.taskQueue.push(r),this.invoker.trigger(),{cancel:()=>{delete this.tasks[r]}})}process(){{if(this.taskQueue=this.taskQueue.filter(e=>!!this.tasks[e]),!this.taskQueue.length)return;let e=this.pick();if(null===e)return;let i=this.tasks[e];if(delete this.tasks[e],this.taskQueue.length&&this.invoker.trigger(),!i)return;i.fn()}}pick(){let e=null,i=1/0;for(let r=0;r<this.taskQueue.length;r++){let a=this.tasks[this.taskQueue[r]];a.priority<i&&(i=a.priority,e=r)}if(null===e)return null;let r=this.taskQueue[e];return this.taskQueue.splice(e,1),r}remove(){this.invoker.remove()}}class uW{constructor(e,i,r){this.target=e,this.parent=i,this.mapId=r,this.callbacks={},this.cancelCallbacks={},tl(["receive"],this),this.target.addEventListener("message",this.receive,!1),this.scheduler=new uZ}send(e,i,r,a,n=!1,o){let s=Math.round(1e18*Math.random()).toString(36).substring(0,10);r&&(r.metadata=o,this.callbacks[s]=r);let l=new Set;return this.target.postMessage({id:s,type:e,hasCallback:!!r,targetMapId:a,mustQueue:n,sourceMapId:this.mapId,data:a6(i,l)},l),{cancel:()=>{r&&delete this.callbacks[s],this.target.postMessage({id:s,type:"<cancel>",targetMapId:a,sourceMapId:this.mapId})}}}receive(e){let i=e.data;if(!i)return;let r=i.id;if(r&&(!i.targetMapId||this.mapId===i.targetMapId))if("<cancel>"===i.type){let e=this.cancelCallbacks[r];delete this.cancelCallbacks[r],e&&e.cancel()}else if(i.mustQueue||tg(self)){let e=this.callbacks[r],a=this.scheduler.add(()=>this.processTask(r,i),e&&e.metadata||{type:"message"});a&&(this.cancelCallbacks[r]=a)}else this.processTask(r,i)}processTask(e,i){if(delete this.cancelCallbacks[e],"<response>
7"===i.type){let r=this.callbacks[e];delete this.callbacks[e],r&&(i.error?r(a8(i.error)):r(null,a8(i.data)))}else{let r=new Set,a=i.hasCallback?(i,a)=>{this.target.postMessage({id:e,type:"<response>",sourceMapId:this.mapId,error:i?a6(i):null,data:a6(a,r)},r)}:()=>{},n=a8(i.data);if(this.parent[i.type])this.parent[i.type](i.sourceMapId,n,a);else if(this.parent.getWorkerSource){let e=i.type.split("."),{source:r,scope:o}=n;this.parent.getWorkerSource(i.sourceMapId,e[0],r,o)[e[1]](n,a)}else a(Error(`Could not find function ${i.type}`))}}remove(){this.scheduler.remove(),this.target.removeEventListener("message",this.receive,!1)}}var uX={workerUrl:"",workerClass:null,workerParams:void 0};let uY="mapboxgl_preloaded_worker_pool";class uK{constructor(){this.active={}}acquire(e,i=uK.workerCount){if(!this.workers)for(this.workers=[];this.workers.length<i;)this.workers.push(null!=uX.workerClass?new uX.workerClass:new self.Worker(uX.workerUrl,uX.workerParams));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[uY]}numActive(){return Object.keys(this.active).length}}uK.workerCount=2;class uJ{constructor(e,i,r="Worker",a=uK.workerCount){this.workerPool=e,this.actors=[],this.currentActor=0,this.id=to();let n=this.workerPool.acquire(this.id,a);for(let e=0;e<n.length;e++){let a=new uJ.Actor(n[e],i,this.id);a.name=`${r} ${e}`,this.actors.push(a)}this.ready=!1,this.broadcast("checkIfReady",null,()=>{this.ready=!0})}broadcast(e,i,r){ta(this.actors,(r,a)=>{r.send(e,i,a)},r=r||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)}}function uQ(){return E||(E=new uK),E}uJ.Actor=uW;class u0{constructor(e){this.module=e}createIntArray(e){let i=new Int32Array(e),r=this.module.malloc(i.length*i.BYTES_PER_ELEMENT);return this.module.heap32.set(i,r/i.BYTES_PER_ELEMENT),r}createFloatArray(e){let i=new Float32Array(e),r=this.module.malloc(i.length*i.BYTES_PER_ELEMENT);return this.module.heapF32.set(i,r/i.BYTES_PER_ELEMENT),r}createStringBuffer(e){let i=this.module.malloc(e.length+1);for(let r=0;r<e.length;++r)this.module.heapU8[i+r]=e.charCodeAt(r);return this.module.heapU8[i+e.length]=0,i}readStringBuffer(e){let i="";for(;0!==this.module.heapU8[e];)i+=String.fromCharCode(this.module.heapU8[e]),++e;return i}setStyle(e){let i=e.entranceColorRgb,r=e.facadeGlazingColorRgb,a=e.roofColorRgb,n=e.wallColorRgb,o=e.normalScale;this.module.setStyle(i[0],i[1],i[2],r[0],r[1],r[2],a[0],a[1],a[2],n[0],n[1],n[2],o[0],o[1],o[2],e.tileToMeters)}setAOOptions(e,i){this.module.setAOOptions(+!!e,i)}setMetricOptions(e,i){this.module.setMetricOptions(+!!e,i)}setStructuralOptions(e){this.module.setStructuralOptions(+!!e)}setFacadeOptions(e,i){this.module.setFacadeOptions(e,+!!i)}setFauxFacadeOptions(e,i,r){this.module.setFauxFacadeOptions(+!!e,+!!i,r)}setFacadeClassifierOptions(e){this.module.setFacadeClassifierOptions(e)}generateMesh(e,i){for(let i of e){let e=this.createStringBuffer(i.roofType),r=[0],a=[];for(let e of i.coordinates)if(Array.isArray(e)){for(let i of e)a.push(i.x),a.push(i.y);r.push(a.length)}let n=this.createIntArray(r),o=this.createFloatArray(a);this.module.addFeature(i.id,i.sourceId,i.minHeight,i.height,e,i.roofType.length,o,n,r.length-1),this.module.free(e),this.module.free(n),this.module.free(o)}for(let e of i){let i;i=e.entrances?JSON.parse(e.entrances):[];let r=this.createFloatArray(i),a=[];for(let i of e.coordinates)a.push(i.x),a.push(i.y);let n=this.createFloatArray(a);this.module.addFacade(e.sourceId,e.crossPerc,e.distanceToRoad,r,i.length,n,a.length),this.module.free(r),this.module.free(n)}if(!this.module.generateMesh()){let e=this.module.getLastError();return this.readStringBuffer(e)}let r=this.module.getMeshCount(),a=Array(r);for(let e=0;e<r;e++){let i=this.module.getPositionsPtr(e),r=this.module.getPositionsLength(e),n=new Float32Array(this.module.heapF32.buffer,i,r),o=this.module.getNormalsPtr(e),s=this.module.getNormalsLength(e),l=new Float32Array(this.module.heapF32.buffer,o,s),h=this.module.getColorsPtr(e),u=this.module.getColorsLength(e),c=new Uint8Array(this.module.heapU8.buffer,h,u),d=this.module.getAOPtr(e),p=this.module.getAOLength(e),f=new Float32Array(this.module.heapF32.buffer,d,p),m=this.module.getUVPtr(e),_=this.module.getUVLength(e),g=new Float32Array(this.module.heapF32.buffer,m,_),y=this.module.getFauxFacadePtr(e),x=this.module.getFauxFacadeLength(e),v=new Uint8Array(this.module.heapU8.buffer,y,x),b=this.module.getIndicesPtr(e),w=this.module.getIndicesLength(e),T=new Int32Array(this.module.heap32.buffer,b,w),S=this.module.getBuildingPart(e),E=this.readStringBuffer(S);a[e]={positions:n,normals:l,colors:c,ao:f,uv:g,isFauxFacade:v,indices:T,buildingPart:E}}let n=this.module.getRingCount(),o=[];for(let e=0;e<n;e++){let i=this.module.getRingPtr(e),r=this.module.getRingLength(e),a=new Float32Array(this.module.heapF32.buffer,i,r);o.push(a)}return{meshes:a,outerRingLength:this.module.getOuterRingLength(),modifiedPolygonRings:o}}}let u1,u2,u3,u5,u4,u6=null,u8=null,u9=null,u7=null;function ce(){return tg(self)&&self.worker.dracoUrl?self.worker.dracoUrl:u2||tI.DRACO_URL}function ct(){if(tg(self)&&self.worker.meshoptUrl)return self.worker.meshoptUrl;if(u5)return u5;let 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 Error("WebAssembly not supported, cannot instantiate meshoptimizer");return u5=WebAssembly.validate(e)?tI.MESHOPT_SIMD_URL:tI.MESHOPT_URL}let ci={5120:Int8Array,5121:Uint8Array,5122:Int16Array,5123:Uint16Array,5125:Uint32Array,5126:Float32Array},cr={5120:"DT_INT8",5121:"DT_UINT8",5122:"DT_INT16",5123:"DT_UINT16",5125:"DT_UINT32",5126:"DT_FLOAT32"},ca={SCALAR:1,VEC2:2,VEC3:3,VEC4:4,MAT2:4,MAT3:9,MAT4:16};function cn(e,i,r){let a=r.json.bufferViews.length,n=r.buffers.length;i.bufferView=a,r.json.bufferViews[a]={buffer:n,byteLength:e.byteLength},r.buffers[n]=e}let co="KHR_draco_mesh_compression",cs="EXT_meshopt_compression",cl=new TextDecoder("utf8");function ch(e,i){return new URL(e,i).href}function cu(e,i){let r=e.json.bufferViews[i];return new Uint8Array(e.buffers[r.buffer],r.byteOffset||0,r.byteLength)}function cc(e,i=0,r){let a={json:null,images:[],buffers:[]};if(0x46546c67===new Uint32Array(e,i,1)[0]){let r=new Uint32Array(e,i),n=2,o=(r[n++]>>2)-3,s=r[n++]>>2;if(n++,a.json=JSON.parse(cl.decode(r.subarray(n,n+s))),(n+=s)<o){let o=r[n++],s=i+(++n<<2);a.buffers[0]=e.slice(s,s+o)}}else a.json=JSON.parse(cl.decode(new Uint8Array(e,i)));let{buffers:n,images:o,meshes:s,extensionsUsed:l,bufferViews:h}=a.json,u=Promise.resolve();if(n){let e=[];for(let i=0;i<n.length;i++){let o=n[i];o.uri?e.push(function(e,i,r,a){return fetch(ch(e.uri,a)).then(e=>e.arrayBuffer()).then(e=>{i.buffers[r]=e})}(o,a,i,r)):a.buffers[i]||(a.buffers[i]=null)}u=Promise.all(e)}return u.then(()=>{let e=[],i=l&&l.includes(co),n=l&&l.includes(cs);if(i&&e.push(function(){if(!u3)return null!=u1?u1:(u1=function(e){let i,r=null;function a(){i=new Uint8Array(r.buffer)}function n(){throw Error("Unexpected Draco error.")}let o={a:{a:n,d:function(e,r,a){return i.copyWithin(e,r,r+a)},c:function(e){let n=i.length,o=Math.ceil((Math.max(e>>>0,Math.ceil(1.2*n))-n)/65536);try{return r.grow(o),a(),!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=>{let n,o,s,l,{Rb:h,Qb:u,P:c,T:d,X:p,Ja:f,La:m,Qa:_,Va:g,Wa:y,eb:x,jb:v,f:b,e:w,yb:T,zb:S,Ab:E,Bb:I,Db:A,Gb:C}=e.instance.exports;r=w;let M=(n=0,o=0,s=0,l=0,e=>
7{s&&(h(l),h(n),o+=s,s=n=0),n||(o+=128,n=u(o));let r=e.length+7&-8,a=n;r>=o&&(s=r,a=l=u(r));for(let r=0;r<e.length;r++)i[a+r]=e[r];return a});return a(),b(),{memory:w,_free:h,_malloc:u,Mesh:class{constructor(){this.ptr=c()}destroy(){d(this.ptr)}},Decoder:class{constructor(){this.ptr=f()}destroy(){v(this.ptr)}DecodeArrayToMesh(e,i,r){let a=M(e);return!!p(m(this.ptr,a,i,r.ptr))}GetAttributeByUniqueId(e,i){return{ptr:_(this.ptr,e.ptr,i)}}GetTrianglesUInt16Array(e,i,r){g(this.ptr,e.ptr,i,r)}GetTrianglesUInt32Array(e,i,r){y(this.ptr,e.ptr,i,r)}GetAttributeDataArrayForAllPoints(e,i,r,a,n){x(this.ptr,e.ptr,i.ptr,r,a,n)}},DT_INT8:T(),DT_UINT8:S(),DT_INT16:E(),DT_UINT16:I(),DT_UINT32:A(),DT_FLOAT32:C()}})}(fetch(ce()))).then(e=>{u3=e,u1=void 0})}()),n&&e.push(function(){if(u4)return;let e=function(e){let i,r=WebAssembly.instantiateStreaming(e,{}).then(e=>{(i=e.instance).exports.__wasm_call_ctors()}),a={NONE:"",OCTAHEDRAL:"meshopt_decodeFilterOct",QUATERNION:"meshopt_decodeFilterQuat",EXPONENTIAL:"meshopt_decodeFilterExp"},n={ATTRIBUTES:"meshopt_decodeVertexBuffer",TRIANGLES:"meshopt_decodeIndexBuffer",INDICES:"meshopt_decodeIndexSequence"};return{ready:r,supported:!0,decodeGltfBuffer(e,r,o,s,l,h){!function(e,i,r,a,n,o,s){let l=e.exports.sbrk,h=a+3&-4,u=l(h*n),c=l(o.length),d=new Uint8Array(e.exports.memory.buffer);d.set(o,c);let p=i(u,a,n,c,o.length);if(0===p&&s&&s(u,h,n),r.set(d.subarray(u,u+a*n)),l(u-l(0)),0!==p)throw Error(`Malformed buffer data: ${p}`)}(i,i.exports[n[l]],e,r,o,s,i.exports[a[h]])}}}(fetch(ct()));return e.ready.then(()=>{u4=e})}()),o)for(let i=0;i<o.length;i++)e.push(function(e,i,r,a){return e.uri?fetch(ch(e.uri,a)).then(e=>e.blob()).then(e=>createImageBitmap(e)).then(e=>{i.images[r]=e}):void 0!==e.bufferView?createImageBitmap(new Blob([cu(i,e.bufferView)],{type:e.mimeType})).then(e=>{i.images[r]=e}):void 0}(o[i],a,i,r));return(e.length?Promise.all(e):Promise.resolve()).then(()=>{if(i&&s)for(let{primitives:e}of s)for(let i of e)!function(e,i){let r=e.extensions&&e.extensions[co];if(!r)return;let a=new u3.Decoder,n=cu(i,r.bufferView),o=new u3.Mesh;if(!a.DecodeArrayToMesh(n,n.byteLength,o))throw Error("Failed to decode Draco mesh");let s=i.json.accessors[e.indices],l=ci[s.componentType],h=s.count*l.BYTES_PER_ELEMENT,u=u3._malloc(h);for(let n of(l===Uint16Array?a.GetTrianglesUInt16Array(o,h,u):a.GetTrianglesUInt32Array(o,h,u),cn(u3.memory.buffer.slice(u,u+h),s,i),u3._free(u),Object.keys(r.attributes))){let s=a.GetAttributeByUniqueId(o,r.attributes[n]),l=i.json.accessors[e.attributes[n]],h=cr[l.componentType],u=l.count*ca[l.type]*ci[l.componentType].BYTES_PER_ELEMENT,c=u3._malloc(u);a.GetAttributeDataArrayForAllPoints(o,s,u3[h],u,c),cn(u3.memory.buffer.slice(c,c+u),l,i),u3._free(c)}a.destroy(),o.destroy(),delete e.extensions[co]}(i,a);if(n&&s&&h)for(let e of h)!function(e,i){if(!e.extensions||!e.extensions[cs])return;let r=e.extensions[cs],a=new Uint8Array(i.buffers[r.buffer],r.byteOffset||0,r.byteLength||0),n=new Uint8Array(r.count*r.byteStride);u4.decodeGltfBuffer(n,r.count,r.byteStride,a,r.mode,r.filter),e.buffer=i.buffers.length,e.byteOffset=0,i.buffers[e.buffer]=n.buffer,delete e.extensions[cs]}(e,a);return a})})}function cd(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 cp(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 cf{constructor(e,i,r,a){this.context=e,this.format=r,this.useMipmap=a&&a.useMipmap,this.texture=e.gl.createTexture(),this.update(i,{premultiply:a&&a.premultiply})}update(e,i){let r=e&&e instanceof HTMLVideoElement&&0===e.width?e.videoWidth:e.width,a=e&&e instanceof HTMLVideoElement&&0===e.height?e.videoHeight:e.height,{context:n}=this,{gl:o}=n,{x:s,y:l}=i&&i.position?i.position:{x:0,y:0},h=s+r,u=l+a;this.size&&(this.size[0]!==h||this.size[1]!==u)&&(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&&(!i||!1!==i.premultiply));let c=e instanceof HTMLImageElement||e instanceof HTMLCanvasElement||e instanceof HTMLVideoElement||e instanceof ImageData||ImageBitmap&&e instanceof ImageBitmap;if(!this.size&&h>0&&u>0){let e=this.useMipmap?Math.floor(Math.log2(Math.max(h,u)))+1:1;o.texStorage2D(o.TEXTURE_2D,e,this.format,h,u),this.size=[h,u]}this.size&&(c?o.texSubImage2D(o.TEXTURE_2D,0,s,l,cd(this.format),cp(this.format),e):"data"in e&&e.data&&o.texSubImage2D(o.TEXTURE_2D,0,s,l,r,a,cd(this.format),cp(this.format),e.data)),this.useMipmap&&o.generateMipmap(o.TEXTURE_2D)}bind(e,i,r=!1){let{context:a}=this,{gl:n}=a;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&&!r?e===n.NEAREST?n.NEAREST_MIPMAP_NEAREST:n.LINEAR_MIPMAP_LINEAR:e),this.minFilter=e),i!==this.wrapS&&(n.texParameteri(n.TEXTURE_2D,n.TEXTURE_WRAP_S,i),n.texParameteri(n.TEXTURE_2D,n.TEXTURE_WRAP_T,i),this.wrapS=i)}bindExtraParam(e,i,r,a,n){let{context:o}=this,{gl:s}=o;s.bindTexture(s.TEXTURE_2D,this.texture),i!==this.magFilter&&(s.texParameteri(s.TEXTURE_2D,s.TEXTURE_MAG_FILTER,i),this.magFilter=i),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),r!==this.wrapS&&(s.texParameteri(s.TEXTURE_2D,s.TEXTURE_WRAP_S,r),this.wrapS=r),a!==this.wrapT&&(s.texParameteri(s.TEXTURE_2D,s.TEXTURE_WRAP_T,a),this.wrapT=a),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(){let{gl:e}=this.context;e.deleteTexture(this.texture),this.texture=null}}
7class cm{constructor(e,i){this.context=e,this.texture=i}bind(e,i){let{context:r}=this,{gl:a}=r;a.bindTexture(a.TEXTURE_2D,this.texture),e!==this.minFilter&&(a.texParameteri(a.TEXTURE_2D,a.TEXTURE_MAG_FILTER,e),a.texParameteri(a.TEXTURE_2D,a.TEXTURE_MIN_FILTER,e),this.minFilter=e),i!==this.wrapS&&(a.texParameteri(a.TEXTURE_2D,a.TEXTURE_WRAP_S,i),a.texParameteri(a.TEXTURE_2D,a.TEXTURE_WRAP_T,i),this.wrapS=i)}}let c_=ou([{name:"a_pos_3f",components:3,type:"Float32"}]),cg=ou([{name:"a_color_3f",components:3,type:"Float32"}]),cy=ou([{name:"a_color_4f",components:4,type:"Float32"}]),cx=ou([{name:"a_uv_2f",components:2,type:"Float32"}]),cv=ou([{name:"a_normal_3f",components:3,type:"Float32"}]),cb=ou([{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"}]),cw=ou([{name:"a_pbr",components:4,type:"Uint16"},{name:"a_heightBasedEmissiveStrength",components:3,type:"Float32"}]);function cT(e,i){let r=cE(e.projection,e.zoom,e.width,e.height),a=function(e,i,r,a,n){let o=new sB(r.lng-180*cI,r.lat),s=new sB(r.lng+180*cI,r.lat),l=e.project(o.lng,o.lat),h=e.project(s.lng,s.lat),u=-Math.atan2(h.y-l.y,h.x-l.x),c=sY.fromLngLat(r);c.y=tt(c.y,-1+cI,1-cI);let d=c.toLngLat(),p=e.project(d.lng,d.lat),f=sY.fromLngLat(d);f.x+=cI;let m=f.toLngLat(),_=e.project(m.lng,m.lat),g=cC(_.x-p.x,_.y-p.y,u),y=sY.fromLngLat(d);y.y+=cI;let x=y.toLngLat(),v=e.project(x.lng,x.lat),b=cC(v.x-p.x,v.y-p.y,u),w=Math.abs(g.x)/Math.abs(b.y),T=ee([]);es(T,T,-u*(1-(n?0:a)));let S=ee([]);return ea(S,S,[1,1-(1-w)*a,1]),S[4]=-b.x/b.y*a,es(S,S,u),ei(S,T,S),S}(e.projection,0,e.center,r,i),n=cS(e);return ea(a,a,[n,n,1]),a}function cS(e){let i=e.projection,r=cE(e.projection,e.zoom,e.width,e.height);return Math.pow(2,cA(i,e.center)*r+(1-r)*cA(i,sB.convert(i.center)))}function cE(e,i,r,a,n=1/0){let o=e.range;if(!o)return 0;let s=Math.log2(Math.min(n,Math.max(r,a))/1024);return ti(o[0]+s,o[1]+s,i)}let cI=1/4e4;function cA(e,i){let r=tt(i.lat,-85.051129,85.051129),a=new sB(i.lng-180*cI,r),n=new sB(i.lng+180*cI,r),o=e.project(a.lng,r),s=e.project(n.lng,r),l=sY.fromLngLat(a),h=sY.fromLngLat(n),u=s.x-o.x,c=s.y-o.y,d=h.x-l.x,p=h.y-l.y;return Math.log2(Math.sqrt((d*d+p*p)/(u*u+c*c)))}function cC(e,i,r){let a=Math.cos(r),n=Math.sin(r);return{x:e*a-i*n,y:e*n+i*a}}function cM(e,i,r){ee(e),es(e,e,i[2]*e4),en(e,e,i[0]*e4),eo(e,e,i[1]*e4),ea(e,e,r),ei(e,e,[1,0,0,0,0,0,1,0,0,1,0,0,0,0,0,1])}function cP(e,i,r,a,n,o,s,l){let h=[r[0]-i[0],r[1]-i[1],0],u=[a[0]-i[0],a[1]-i[1],0];if(1e-12>ep(h)||1e-12>ep(u))return eV(e);let c=eC([],h,u);return eI(c,c),eg(u,a,i),h[2]=(o-n)*l,u[2]=(s-n)*l,eC(h,h,u),eI(h,h),eH(e,c,h)}function cz(e,i,r=!1){let a=l9(i.zoom),n=function(e,i,r){let a=i.worldSize,n=[e[12],e[13],e[14]],o=sq(n[1]/a),s=sG(n[0]/a),l=ee([]),h=1/sV(o)*a,u=1/sV(0)*a*sZ(o,i.zoom),c=1/l4(a),d=u*c;if(r){let e=cE(i.projection,i.zoom,i.width,i.height,1024);d=c*i.projection.pixelSpaceConversion(i.center.lat,a,e)}let p=sF(o,s);e_(p,p,eb([],eI([],p),h*d*n[2]));let f=function(e){let i=[e[0],e[1],e[2]],r=[0,1,0],a=eC([],r,i);return eC(r,i,a),0===eS(r)&&eC(a,i,r=[0,1,0]),eI(a,a),eI(r,r),eI(i,i),[a[0],a[1],a[2],0,r[0],r[1],r[2],0,i[0],i[1],i[2],0,e[0],e[1],e[2],1]}(p);ea(l,l,[d,d,d*h]),er(l,l,[-n[0],-n[1],-n[2]]);let m=ei([],i.globeMatrix,f);return ei(m,m,l),ei(m,m,e),m}(e,i,r);return a>0?function(e,i,r){let a=(e,i,r)=>{let a=ep(e),n=ep(i),o=lX(e,i,r);return eb(o,o,1/ep(o)*ip(a,n,r))},n=a([e[0],e[1],e[2]],[i[0],i[1],i[2]],r),o=a([e[4],e[5],e[6]],[i[4],i[5],i[6]],r),s=a([e[8],e[9],e[10]],[i[8],i[9],i[10]],r),l=lX([e[12],e[13],e[14]],[i[12],i[13],i[14]],r);return[n[0],n[1],n[2],0,o[0],o[1],o[2],0,s[0],s[1],s[2],0,l[0],l[1],l[2],1]}(n,function(e,i){let r=i.worldSize,a=1/sV(0)*r*sZ(i.center.lat,i.zoom)/l4(r),n=1/sV(i.center.lat)*r,o=ee([]);eo(o,o,i.center.lng*e4),en(o,o,i.center.lat*e4),er(o,o,[0,0,sR]),ea(o,o,[a,a,a*n]);let s=i.point;return er(o,o,[-s.x,-s.y,0]),ei(o,o,e),ei(o,i.globeMatrix,o)}(e,i),a):n}function cR(e,i,r,a){let n,o=ld.projectAabbCorners(a,r),s=Number.MAX_VALUE,l=-1;for(let e=0;e<o.length;++e){let r=o[e];r[0]=(.5*r[0]+.5)*i.width,r[1]=(.5-.5*r[1])*i.height,r[2]<s&&(l=e,s=r[2])}let h=e=>new e3(o[e][0],o[e][1]);switch(l){case 0:case 6:n=[h(1),h(5),h(4),h(7),h(3),h(2),h(1)];break;case 1:case 7:n=[h(0),h(4),h(5),h(6),h(2),h(3),h(0)];break;case 3:case 5:n=[h(1),h(0),h(4),h(7),h(6),h(2),h(1)];break;default:n=[h(1),h(5),h(6),h(7),h(3),h(0),h(1)]}if(ly(e,n))return s}
7let cD={CoordinateSpaceTile:1,HasMapboxMeshFeatures:4,HasMeshoptCompression:8};function cL(e,i,r,a,n,o,s,l,h,u=!1){let c=r.zoom,d=r.project(a),p=sZ(a.lat,c),f=1/p;ee(e),er(e,e,[d.x+s[0]*f,d.y+s[1]*f,s[2]]);let m=1,_=1,g=r.worldSize;if(u){if("mercator"===r.projection.name){let e=0;r.elevation&&(e=r.elevation.getAtPointOrZero(new sY(d.x/g,d.y/g),0));let i=eB([],[d.x,d.y,e,1],r.projMatrix)[3]/r.cameraToCenterDistance;m=i,_=i*sZ(r.center.lat,c)}else if("globe"===r.projection.name){let i=cz(e,r),n=[0,0,0,1];eB(n,n,ei([],r.projMatrix,i));let o=n[3]/r.cameraToCenterDistance,s=l9(c),l=r.projection.pixelsPerMeter(a.lat,g)*sZ(a.lat,c),h=r.projection.pixelsPerMeter(r.center.lat,g)*sZ(r.center.lat,c);m=o/ip(l,sH(r.center.lat),s),_=o*p/l,m*=h,_*=h}}else m=f;ea(e,e,[m,m,_]);let y=[...e],x=i.orientation,v=[];if(cM(v,[x[0]+n[0],x[1]+n[1],x[2]+n[2]],o),ei(e,y,v),l&&r.elevation){let n=0,o=[];if(h&&r.elevation){n=function(e,i,r,a,n){let o=i.elevation;if(!o)return 0;let s=ld.projectAabbCorners(r,a),l=1/sV(n.lat)*i.worldSize,h=function(e,i){let r=[0,0,1],a=[{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(let n of a){let a=e[n.corners[0]],o=e[n.corners[1]],s=e[n.corners[2]],l=[o[0]-a[0],o[1]-a[1],i*(o[2]-a[2])],h=eC(l,l,[s[0]-a[0],s[1]-a[1],i*(s[2]-a[2])]);eI(h,h),n.dotProductWithUp=eA(h,r)}return a.sort((e,i)=>e.dotProductWithUp-i.dotProductWithUp),a[0].corners}(s,l),u=s[h[0]],c=s[h[1]],d=s[h[2]],p=s[h[3]],f=o.getAtPointOrZero(new sY(u[0]/i.worldSize,u[1]/i.worldSize),0),m=o.getAtPointOrZero(new sY(c[0]/i.worldSize,c[1]/i.worldSize),0),_=o.getAtPointOrZero(new sY(d[0]/i.worldSize,d[1]/i.worldSize),0),g=o.getAtPointOrZero(new sY(p[0]/i.worldSize,p[1]/i.worldSize),0),y=(f+g)/2,x=(m+_)/2;return y>x?m<_?cP(e,c,p,u,m,g,f,l):cP(e,d,u,p,_,f,g,l):f<g?cP(e,u,c,d,f,m,_,l):cP(e,p,d,c,g,_,m,l),Math.max(y,x)}(o,r,i.aabb,e,a);let s=ei([],eu([],o),v);ei(e,y,s)}else n=r.elevation.getAtPointOrZero(new sY(d.x/g,d.y/g),0);0!==n&&(e[14]+=n)}}function cO(e,i,r=!1){e.uploaded||(e.gfxTexture=new cf(i,e.image,r?i.gl.R8:i.gl.RGBA8,{useMipmap:e.sampler.minFilter>=i.gl.NEAREST_MIPMAP_NEAREST}),e.uploaded=!0,e.image=null)}function cF(e,i,r){if(e.meshes)for(let a of e.meshes){a.indexBuffer=i.createIndexBuffer(a.indexArray,!1,!0),a.vertexBuffer=i.createVertexBuffer(a.vertexArray,c_.members,!1,!0),a.normalArray&&(a.normalBuffer=i.createVertexBuffer(a.normalArray,cv.members,!1,!0)),a.texcoordArray&&(a.texcoordBuffer=i.createVertexBuffer(a.texcoordArray,cx.members,!1,!0)),a.colorArray&&(a.colorBuffer=i.createVertexBuffer(a.colorArray,(12===a.colorArray.bytesPerElement?cg:cy).members,!1,!0)),a.featureArray&&(a.pbrBuffer=i.createVertexBuffer(a.featureArray,cw.members,!0)),a.segments=se.simpleSegment(0,0,a.vertexArray.length,a.indexArray.length);let e=a.material;e.pbrMetallicRoughness.baseColorTexture&&cO(e.pbrMetallicRoughness.baseColorTexture,i),e.pbrMetallicRoughness.metallicRoughnessTexture&&cO(e.pbrMetallicRoughness.metallicRoughnessTexture,i),e.normalTexture&&cO(e.normalTexture,i),e.occlusionTexture&&cO(e.occlusionTexture,i,r),e.emissionTexture&&cO(e.emissionTexture,i)}if(e.children)for(let a of e.children)cF(a,i,r)}function ck(e){if(e.meshes)for(let i of e.meshes)i.indexArray.destroy(),i.vertexArray.destroy(),i.colorArray&&i.colorArray.destroy(),i.normalArray&&i.normalArray.destroy(),i.texcoordArray&&i.texcoordArray.destroy(),i.featureArray&&i.featureArray.destroy();if(e.children)for(let i of e.children)ck(i)}function cB(e){var i;if(e.meshes)for(let r of e.meshes)r.vertexBuffer&&(r.vertexBuffer.destroy(),r.indexBuffer.destroy(),r.normalBuffer&&r.n
7ormalBuffer.destroy(),r.texcoordBuffer&&r.texcoordBuffer.destroy(),r.colorBuffer&&r.colorBuffer.destroy(),r.pbrBuffer&&r.pbrBuffer.destroy(),r.segments.destroy(),r.material&&((i=r.material).pbrMetallicRoughness.baseColorTexture&&i.pbrMetallicRoughness.baseColorTexture.gfxTexture&&i.pbrMetallicRoughness.baseColorTexture.gfxTexture.destroy(),i.pbrMetallicRoughness.metallicRoughnessTexture&&i.pbrMetallicRoughness.metallicRoughnessTexture.gfxTexture&&i.pbrMetallicRoughness.metallicRoughnessTexture.gfxTexture.destroy(),i.normalTexture&&i.normalTexture.gfxTexture&&i.normalTexture.gfxTexture.destroy(),i.emissionTexture&&i.emissionTexture.gfxTexture&&i.emissionTexture.gfxTexture.destroy(),i.occlusionTexture&&i.occlusionTexture.gfxTexture&&i.occlusionTexture.gfxTexture.destroy()));if(e.children)for(let i of e.children)cB(i)}function cN(e,i){let r=e.json.bufferViews[i.bufferView],a=ci[i.componentType];return new a(e.buffers[r.buffer],(i.byteOffset||0)+(r.byteOffset||0),i.count*(r.byteStride&&r.byteStride!==ca[i.type]*a.BYTES_PER_ELEMENT?r.byteStride/a.BYTES_PER_ELEMENT:ca[i.type]))}function cV(e,i,r,a){let n=ci[i.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[i.bufferView],l=s.byteStride?s.byteStride/n.BYTES_PER_ELEMENT:ca[i.type],h=r.float32,u=h.length/r.capacity;for(let e=0,r=0;e<i.count*l;e+=l,r+=u)for(let i=0;i<u;i++)h[r+i]=a[e+i]*o;r._trim()}function cU(e){let i=function(e,i){let r=[],a=WebGL2RenderingContext;if(e.json.textures)for(let n of e.json.textures){let o={magFilter:a.LINEAR,minFilter:a.NEAREST,wrapS:a.REPEAT,wrapT:a.REPEAT};void 0!==n.sampler&&Object.assign(o,e.json.samplers[n.sampler]),r.push({image:i[n.source],sampler:o,uploaded:!1})}return r}(e,e.images),r=function(e,i){let r=[];for(let a of e.json.meshes){let n=[];for(let r of a.primitives)n.push(function(e,i,r){let a=e.indices,n=e.attributes,o={};o.indexArray=new oD;let s=i.json.accessors[a],l=s.count/3;o.indexArray.reserve(l);let h=cN(i,s);for(let e=0;e<l;e++)o.indexArray.emplaceBack(h[3*e],h[3*e+1],h[3*e+2]);o.indexArray._trim(),o.vertexArray=new ov;let u=i.json.accessors[n.POSITION];o.vertexArray.reserve(u.count);let c=cN(i,u);for(let e=0;e<u.count;e++)o.vertexArray.emplaceBack(c[3*e],c[3*e+1],c[3*e+2]);if(o.vertexArray._trim(),o.aabb=new ld(u.min,u.max),o.centroid=function(e,i){let r=[0,0,0],a=e.length;if(a>0){for(let n=0;n<a;n++){let a=3*e[n];r[0]+=i[a],r[1]+=i[a+1],r[2]+=i[a+2]}r[0]/=a,r[1]/=a,r[2]/=a}return r}(h,c),void 0!==n.COLOR_0){let e=i.json.accessors[n.COLOR_0],r=ca[e.type],a=cN(i,e);o.colorArray=3===r?new ov:new oI,o.colorArray.resize(e.count),cV(i,e,o.colorArray,a)}if(void 0!==n.NORMAL){o.normalArray=new ov;let e=i.json.accessors[n.NORMAL];o.normalArray.resize(e.count);let r=cN(i,e);cV(i,e,o.normalArray,r)}if(void 0!==n.TEXCOORD_0&&r.length>0){o.texcoordArray=new oU;let e=i.json.accessors[n.TEXCOORD_0];o.texcoordArray.resize(e.count);let r=cN(i,e);cV(i,e,o.texcoordArray,r)}if(void 0!==n._FEATURE_ID_RGBA4444){let e=i.json.accessors[n._FEATURE_ID_RGBA4444];i.json.extensionsUsed&&i.json.extensionsUsed.includes("EXT_meshopt_compression")&&(o.featureData=cN(i,e))}void 0!==n._FEATURE_RGBA4444&&(o.featureData=new Uint32Array(cN(i,i.json.accessors[n._FEATURE_RGBA4444]).buffer));let d=e.material;return o.material=function(e,i){let{emissiveFactor:r=[0,0,0],alphaMode:a="OPAQUE",alphaCutoff:n=.5,normalTexture:o,occlusionTexture:s,emissiveTexture:l,doubleSided:h}=e,{baseColorFactor:u=[1,1,1,1],metallicFactor:c=1,roughnessFactor:d=1,baseColorTexture:p,metallicRoughnessTexture:f}=e.pbrMetallicRoughness||{},m=s?i[s.index]:void 0;if(s&&s.extensions&&s.extensions.KHR_texture_transform&&m){let e=s.extensions.KHR_texture_transform;m.offsetScale=[e.offset[0],e.offset[1],e.scale[0],e.scale[1]]}return{pbrMetallicRoughness:{baseColorFactor:new ih(...u),metallicFactor:c,roughnessFactor:d,baseColorTexture:p?i[p.index]:void 0,metallicRoughnessTexture:f?i[f.index]:void 0},doubleSided:h,emissiveFactor:new ih(...r),alphaMode:a,alphaCutoff:n,normalTexture:o?i[o.index]:void 0,occlusionTexture:m,emissionTexture:l?i[l.index]:void 0,defined:void 0===e.defined}}(void 0!==d?i.json.materials[d]:{defined:!1},r),o}(r,e,i));r.push(n)}return r}(e,i),{scenes:a,scene:n,nodes:o}=e.json,s=a?a[n||0].nodes:[...o.keys()],l=[];for(let i of s)l.push(function e(i,r,a){var n,o,s,l,h,u,c,d,p,f,m,_,g,y,x,v,b,w,T,S,E,I,A;let{matrix:C,rotation:M,translation:P,scale:z,mesh:R,extras:D,children:L}=i,O={};if(O.matrix=C||(n=[],o=M||[0,0,0,1],s=P||[0,0,0],l=z||[1,1,1],h=o[0],u=o[1],c=o[2],d=o[3],p=h+h,f=u+u,m=c+c,_=h*p,g=h*f,y=h*m,x=u*f,v=u*m,b=c*m,w=d*p,T=d*f,S=d*m,E=l[0],I=l[1],A=l[2],n[0]=(1-(x+b))*E,n[1]=(g+S)*E,n[2]=(y-T)*E,n[3]=0,n[4]=(g-S)*I,n[5]=(1-(_+b))*I,n[6]=(v+w)*I,n[7]=0,n[8]=(y+T)*A,n[9]=(v-w)
7*A,n[10]=(1-(_+x))*A,n[11]=0,n[12]=s[0],n[13]=s[1],n[14]=s[2],n[15]=1,n),void 0!==R){O.meshes=a[R];let e=O.anchor=[0,0];for(let i of O.meshes){let{min:r,max:a}=i.aabb;e[0]+=r[0]+a[0],e[1]+=r[1]+a[1]}e[0]=Math.floor(e[0]/O.meshes.length/2),e[1]=Math.floor(e[1]/O.meshes.length/2)}if(D&&(D.id&&(O.id=D.id),D.lights&&(O.lights=function(e){if(!e.length)return[];let i=function(e){let i=atob(e),r=new Uint8Array(i.length);for(let e=0;e<i.length;e++)r[e]=i.codePointAt(e);return r}(e),r=[],a=i.length/24,n=new Uint16Array(i.buffer),o=new Float32Array(i.buffer);for(let e=0;e<a;e++){let i=n[2*e*6]/30,a=n[2*e*6+1]/30,s=n[2*e*6+10]/100,l=o[6*e+1],h=o[6*e+2],u=o[6*e+3],c=o[6*e+4],d=u-l,p=c-h,f=Math.hypot(d,p);r.push({pos:[l+.5*d,h+.5*p,a],normal:[p/f,-d/f,0],width:f,height:i,depth:s,points:[l,h,u,c]})}return r}(D.lights))),L){let i=[];for(let n of L)i.push(e(r.json.nodes[n],r,a));O.children=i}return O}(o[i],e,r));return function(e,i,r){let a={},n=new Set;for(let o=0;o<e.length;o++){let e=r[i[o]];if(!e.extras)continue;let s=e.extras["mapbox:footprint:version"],l=e.extras["mapbox:footprint:id"];(s||l)&&n.add(o),"1.0.0"===s&&l&&(a[l]=o)}for(let o=0;o<e.length;o++){if(n.has(o))continue;let s=e[o],l=r[i[o]];if(!l.extras)continue;let h=null;s.id in a&&(h=function(e,i){let r=[],a=[],n=0,o=[];for(let s of e){n=r.length;let e=s.vertexArray.float32,l=s.indexArray.uint16;for(let a=0;a<s.vertexArray.length;a++)o[0]=e[3*a+0],o[1]=e[3*a+1],o[2]=e[3*a+2],eP(o,o,i),r.push(new e3(o[0],o[1]));for(let e=0;e<3*s.indexArray.length;e++)a.push(l[e]+n)}if(a.length%3!=0)return null;for(let e=0;e<a.length;e+=3){let i=r[a[e+0]],n=r[a[e+1]],o=r[a[e+2]];(i.x-n.x)*(o.y-n.y)-(o.x-n.x)*(i.y-n.y)>0&&([a[e+1],a[e+2]]=[a[e+2],a[e+1]])}return{vertices:r,indices:a}}(e[a[s.id]].meshes,s.matrix)),h||(h=function(e){if(!e.extras||!e.extras.ground)return null;let i=e.extras.ground;if(!i||!Array.isArray(i)||0===i.length)return null;let r=i[0];if(!r||!Array.isArray(r)||0===r.length)return null;let a=[];for(let e of r){if(!Array.isArray(e)||2!==e.length)continue;let i=e[0],r=e[1];"number"==typeof i&&"number"==typeof r&&a.push(new e3(i,r))}if(a.length<3)return null;a.length>1&&a[a.length-1].equals(a[0])&&a.pop();let n=0;for(let e=0;e<a.length;e++){let i=a[e],r=a[(e+1)%a.length],o=a[(e+2)%a.length];n+=(i.x-r.x)*(o.y-r.y)-(o.x-r.x)*(i.y-r.y)}n>0&&a.reverse();let o=hb(a.flatMap(e=>[e.x,e.y]),[]);return 0===o.length?null:{vertices:a,indices:o}}(l)),h&&(s.footprint=function(e){if(0===e.vertices.length||0===e.indices.length)return null;let i=new h1(e.vertices,e.indices,8,256),[r,a]=[i.min.clone(),i.max.clone()];return{vertices:e.vertices,indices:e.indices,grid:i,min:r,max:a}}(h))}if(n.size>0){let i=Array.from(n.values()).sort((e,i)=>e-i);for(let r=i.length-1;r>=0;r--)e.splice(i[r],1)}}(l,s,e.json.nodes),l}function cj(e,i,r,a,n){r.reserve(r.length+4*e.length),a.reserve(a.length+10*e.length),n.reserve(n.length+10*e.length);let o=a.length;for(let s of e){let e=Math.min(10,Math.max(4,1.3*s.height))*i,l=[-s.normal[1],s.normal[0],0],h=Math.min(.29,.1*s.width/s.depth),u=s.width-2*s.depth*i*(h+.01),c=ew([],s.pos,l,u/2),d=ew([],s.pos,l,-u/2),p=[c[0],c[1],c[2]+s.height],f=[d[0],d[1],d[2]+s.height],m=ew([],s.normal,l,h);eb(m,m,e);let _=ew([],s.normal,l,-h);eb(_,_,e),e_(m,c,m),e_(_,d,_),c[2]+=.1,d[2]+=.1,a.emplaceBack(m[0],m[1],m[2]),a.emplaceBack(_[0],_[1],_[2]),a.emplaceBack(c[0],c[1],c[2]),a.emplaceBack(d[0],d[1],d[2]),a.emplaceBack(p[0],p[1],p[2]),a.emplaceBack(f[0],f[1],f[2]),a.emplaceBack(c[0],c[1],c[2]),a.emplaceBack(d[0],d[1],d[2]),a.emplaceBack(m[0],m[1],m[2]),a.emplaceBack(_[0],_[1],_[2]);let g=u/e/2;n.emplaceBack(-g-h,-1,g,.8),n.emplaceBack(g+h,-1,g,.8),n.emplaceBack(-g,0,g,1.3),n.emplaceBack(g,0,g,1.3),n.emplaceBack(g+h,-.8,g,.7),n.emplaceBack(g+h,-.8,g,.7),n.emplaceBack(0,0,g,1.3),n.emplaceBack(0,0,g,1.3),n.emplaceBack(g+h,-1.2,g,.8),n.emplaceBack(g+h,-1.2,g,.8),r.emplaceBack(6+o,4+o,8+o),r.emplaceBack(7+o,9+o,5+o),r.emplaceBack(0+o,1+o,2+o),r.emplaceBack(1+o,3+o,2+o),o+=10}}let cG=ou([{name:"a_pos_3f",components:3,type:"Float32"}]),cq=ou([{name:"a_normal_3",components:3,type:"Int16"}]),c$=ou([{name:"a_centroid_3",components:3,type:"Int16"}]),cH=ou([{name:"a_part_color_emissive",components:2,type:"Uint16"}]),cZ=ou([{name:"a_faux_facade_color_emissive",components:2,type:"Uint16"}]),cW=ou([{name:"a_faux_facade_data",components:4,type:"Uint16"}]),cX=ou([{name:"a_faux_facade_vertical_range",components:2,type:"Uint16"}]),cY=ou([{name:"a_bloom_attenuation",components:4,type:"Float32"}]),cK=s1.types;
7class cJ{constructor(){this.layoutVertexArray=new ov,this.layoutAttenuationArray=new oI,this.layoutColorArray=new oC,this.indexArray=new oD,this.indexArrayForConflation=new oD,this.segmentsBucket=new se}}class cQ{constructor(){this.layoutVertexArray=new ov,this.layoutNormalArray=new op,this.layoutCentroidArray=new op,this.layoutColorArray=new oC,this.layoutFacadePaintArray=null,this.layoutFacadeDataArray=null,this.layoutFacadeVerticalRangeArray=null,this.layoutAOArray=[],this.indexArray=new oD,this.indexArrayForConflation=new oD,this.segmentsBucket=new se,this.entranceBloom=new cJ}}class c0{constructor(e){this.colorBufferUploaded=!1,this.maxHeight=0,this.replacementUpdateTime=0,this.activeReplacements=[],this.footprints=[],this.featuresOnBorder=[],this.buildingFeatures=[],this.buildingWithoutFacade=new cQ,this.buildingWithFacade=new cQ,this.indexArrayForConflationUploaded=!1,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.buildingWithFacade.layoutFacadePaintArray=new oC,this.buildingWithFacade.layoutFacadeDataArray=new ow,this.buildingWithFacade.layoutFacadeVerticalRangeArray=new oC,this.programConfigurations=new sA(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 uA(e)}updateFootprints(e,i){for(let r of this.footprints)i.push({footprint:r,id:e})}prepare(){return null!=u7||null!=u9?null:null!=u8?u8:u8=(function(e){let i,r,a,n;function o(){i=new Uint8Array(n.buffer),r=new Int32Array(n.buffer),a=new Float32Array(n.buffer)}function s(){throw Error("Unexpected BuildingGen error.")}let l=()=>{},h={a:{a:s,f:function(e){let r=i.length,a=Math.ceil((Math.max(e>>>0,Math.ceil(1.2*r))-r)/65536);try{return n.grow(a),o(),!0}catch(e){return!1}},g:s,b:l,c:l,d:l,e:l}};return(WebAssembly.instantiateStreaming?WebAssembly.instantiateStreaming(e,h):e.then(e=>e.arrayBuffer()).then(e=>WebAssembly.instantiate(e,h))).then(e=>{let s=e.instance.exports;return(0,s.g)(),n=s.f,o(),new u0({setStyle:s.h,setAOOptions:s.i,setMetricOptions:s.j,setStructuralOptions:s.k,setFacadeOptions:s.l,setFauxFacadeOptions:s.m,setFacadeClassifierOptions:s.n,addFeature:s.o,addFacade:s.p,generateMesh:s.q,getLastError:s.r,getOuterRingLength:s.s,getMeshCount:s.t,getPositionsPtr:s.u,getPositionsLength:s.v,getNormalsPtr:s.w,getNormalsLength:s.x,getColorsPtr:s.y,getColorsLength:s.z,getAOPtr:s.A,getAOLength:s.B,getUVPtr:s.C,getUVLength:s.D,getFauxFacadePtr:s.E,getFauxFacadeLength:s.F,getIndicesPtr:s.G,getIndicesLength:s.H,getBuildingPart:s.I,getRingCount:s.J,getRingPtr:s.K,getRingLength:s.L,free:s.M,malloc:s.N,heapU8:i,heap32:r,heapF32:a})})})(fetch(tI.BUILDING_GEN_URL)).then(e=>(u8=null,u7=e)).catch(e=>{tf("Could not load building-gen"),u8=null,u9=e})}populate(e,i,r,a){let n=u7;if(!n)return;let o=sX(r);this.tileToMeter=o,this.brightness=i.brightness,n.setStyle({convertToMeters:!1,entranceColorRgb:[1,1,1],facadeGlazingColorRgb:[.5607843137254902,.6745098039215687,.7215686274509804],normalScale:[1,-1,o],ridgeHeight:3,roofColorRgb:[.886274516,.784313738,.713725507],tileToMeters:o,tileZoom:16,wallColorRgb:[.988235294,.933333337,.811764717]}),n.setAOOptions(!1,.3),n.setMetricOptions(!1,16),n.setStructuralOptions(!0),n.setFacadeClassifierOptions(3);let s=new Map;for(let{feature:i}of e){if("LineString"!==cK[i.type])continue;let e=this.layers[0]._featureFilter.needGeometry,n=s0(i,e);if(!this.layers[0]._featureFilter.filter(new nV(this.zoom),n,r))continue;let o=e?n.geometry:sQ(i,r,a),l=[];for(let e of o)for(let i of e)l.push({x:i.x,y:i.y});let h={coordinates:l,crossPerc:i.properties.cross_perc,distanceToRoad:i.properties.distance_to_road,entrances:i.properties.entrances,sourceId:0},u=i.properties.source_id,c=s.get(u);c||(c=[],s.set(u,c)),c.push(h)}for(let{feature:l,index:h}of(this.maxHeight=0,e)){let e;if("LineString"===cK[l.type])continue;let u=this.layers[0]._featureFilter.needGeometry,c=s0(l,u);if(!this.layers[0]._featureFilter.filter(new nV(this.zoom),c,r))continue;let d=u?c.geometry:sQ(l,r,a),p=hB(d,500);if(!function(e,i){for(let r of e)for(let e of r)if(e.x<-163||e.x>8355||e.y<-i||e.y>8355)return!1;return!0}(d,163))continue;let f=this.layers[0],m=f.layout.get("building-base").evaluate(l,{},r),_=f.layout.get("building-height").evaluate(l,{},r),g=f.layout.get("building-roof-shape").evaluate(l,{},r),y=f.paint.get("building-ambient-occlusion-intensity"),x=f.paint.get("building-ambient-occlusion-ground-radius")/this.tileToMeter;if("flat"===g)continue;let v=f.layout.get("building-facade").evaluate(l,{},r);n.setFacadeOptions(4,!0),n.setFauxFacadeOptions(v,!1,1);let b=l.properties.source_id;e=s.has(b)?s.get(b):[];let w=0,T=0,S=0,E=0,I=0,A=0;if(v){let i=Math.round(f.layout.get("building-facade-floors").evaluate(l,{},r));if(0===m){i=Math.max(1,i-(e.length>0));let r=4;if(_>100){let e=[10,13,15];r=e[l.id?l.id%e.length:0],n.setFacadeOptions(r,!0)}I=1.6803*r/o}else I=m/o;I=Math.min(I,A=_/o),S=f.layout.get("building-facade-unit-width").evaluate(l,{},r)/o,E=(A-I)/i,n.setFauxFacadeOptions(!0,!0,S);let a=f.layout.get("building-facade-window").evaluate(l,{},r);w=a[0],T=a[1]}let C=[],M=new e3(1/0,1/0),P=new e3(-1/0,-1/0),z=new e3(0,0),R=0;for(let e of p)if(e.length>0){let i=[];for(let r of e){let e=[];for(let i=r.length-1;i>=0;i--){let a=r[i];e.push({x:a.x,y:a.y}),M.x=Math.min(M.x,a.x),M.y=Math.min(M.y,a.y),P.x=Math.max(P.x,a.x),P.y=Math.max(P.y,a.y),z.x+=a.x,z.y+=a.y,R++}i.push(e)}C.push({id:l.id?l.id:0,height:_,minHeight:m,sourceId:0,roofType:g,coordinates:i})}z.x/=R||1,z.y/=R||1;let D=n.generateMesh(C,e);if("string"==typeof D){tf(`Unable to generate building ${l.id}: ${D}`);continue}if(0===D.meshes.length||0===D.modifiedPolygonRings.length)continue;let L=0;for(let e of D.meshes)L+=e.positions.length/3;let O=v?this.buildingWithFacade:this.buildingWithoutFacade,F=O.segmentsBucket.prepareSegment(L,O.layoutVertexArray,O.indexArray),k=[],B=null,N=0,V=-1,U=O.indexArray.length,j=0;for(let e of D.meshes){let i=O.layoutVertexArray.length;if("entrance"===e.buildingPart){let i=[];for(let r=0;r<e.indices.length;r+=12){let a=e.positions[r+0],n=e.positions[r+1],o=e.positions[r+3],s=e.positions[r+4],l=e.positions[r+2],h=e.positions[r+8]-l,u=o-a,c=s-n,d=Math.hypot(u,c);i.push({pos:[a+.5*u,n+.5*c,l],normal:[c/d,-u/d,0],width:d,height:h,depth:1,points:[a,n,o,s]})}let r=O.entranceBloom.segmentsBucket.prepareSegment(10*i.length,O.entranceBloom.layoutVertexArray,O.entranceBloom.indexArray),a=O.entranceBloom.layoutVertexArray.length;N=O.entranceBloom.indexArray.length,cj(i,.5/this.tileToMeter,O.entranceBloom.indexArray,O.entranceBloom.layoutVertexArray,O.entranceBloom.layoutAttenuationArray);let n=O.entranceBloom.layoutVertexArray.length-a;V=O.entranceBloom.indexArray.length-N;for(let e=0;e<n;e++)O.entranceBloom.layoutColorArray.emplaceBack(65535,65535);r.vertexLength+=n,r.primitiveLength+=V,B={part:e.buildingPart,vertexOffset:a,vertexLength:n}}for(let i=0;i<e.positions.length;i+=3)j=Math.max(j,e.positions[i+2]),O.layoutVertexArray.emplaceBack(e.positions[i],e.positions[i+1],e.positions[i+2]);let r=Math.floor(z.x),a=Math.floor(z.y),n=Math.floor(j);for(let i=0;i<e.positions.length;i+=3)O.layoutCentroidArray.emplaceBack(r,a,n);for(let i=0;i<e.normals.length;i+=3)O.layoutNormalArray.emplaceBack(32767*e.normals[i+0],32767*e.normals[i+1],32767*e.normals[i+2]);for(let i=0;i<e.ao.length;i++)O.layoutAOArray.push(e.ao[i]);for(let i=0;i<e.colors.length;i+=3){let r=1+(e.ao[i/3]-1)*y;O.layoutColorArray.emplaceBack(e.colors[i]*r<<8|e.colors[i+1]*r,e.colors[i+2]*r<<8)}if(v){for(let i=0;i<e.positions.length;i+=3)O.layoutFacadePaintArray.emplaceBack(65535,255);for(let i=0;i<e.isFauxFacade.length;i++)if(e.isFauxFacade[i]){let r=1|Math.min(65535,Math.floor(e.uv[2*i]*D.outerRingLength)),a=Math.floor(255*w)<<8|Math.floor(255*T),n=Math.floor(65535*Math.min(1,S/8192)),o=Math.floor(65535*Math.min(1,E/8192));O.layoutFacadeDataArray.emplaceBack(r,a,n,o);let s=Math.floor(65535*Math.min(1,I/8192)),l=Math.floor(65535*Math.min(1,A/8192));O.layoutFacadeVerticalRangeArray.emplaceBack(s,l)}else O.layoutFacadeDataArray.emplaceBack(0,0,0,0),O.layoutFacadeVerticalRangeArray.emplaceBack(0,0)}let o=F.vertexLength;for(let i=0;i<e.indices.length;i+=3)O.indexArray.emplaceBack(o+e.indices[i],o+e.indices[i+1],o+e.indices[i+2]);F.vertexLength+=e.positions.length/3,F.primitiveLength+=e.indices.length/3,("roof"===e.buildingPart||"wall"===e.buildingPart||"facade_glazing"===e.buildingPart||"entrance"===e.buildingPart)&&k.push({part:e.buildingPart,vertexOffset:i,vertexLength:e.positions.length/3})}this.maxHeight=Math.max(this.maxHeight,j),this.buildingFeatures.push({feature:c,hasFauxFacade:v,segment:F,parts:k,buildingBloom:B});let G=O.indexArray.length-U,q=[],$=[],H=new e3(1/0,1/0),Z=new e3(-1/0,-1/0),W=this.groundEffect.vertexArray.length;for(let e of D.modifiedPolygonRings){let i=[],r=new e3(1/0,1/0),a=new e3(-1/0,-1/0);for(let n=0;n<e.length;n+=2){let o=e.length-n-2;r.x=Math.min(r.x,e[o]),r.y=Math.min(r.y,e[o+1]),a.x=Math.max(a.x,e[o]),a.y=Math.max(a.y,e[o+1]);let s=new e3(e[o],e[o+1]);i.push(s),q.push(s.x,s.y),$.push(s.clone())}H.x=Math.min(H.x,r.x),H.y=Math.min(H.y,r.y),Z.x=Math.max(Z.x,a.x),Z.y=Math.max(Z.y,a.y),this.groundEffect.addData(i,[r,a],x)}
7let X=this.groundEffect.vertexArray.length-W;(M.x<0||P.x>8192||M.y<0||P.y>8192)&&this.featuresOnBorder.push({featureId:l.id,footprintIndex:this.footprints.length});{let e=hb(q,null,2),i=new h1($,e,8,256),r=l.id;l.properties&&l.properties.hasOwnProperty("building_id")&&(r=l.properties.building_id),this.footprints.push({vertices:$,indices:e,grid:i,min:H,max:Z,buildingId:r,hiddenFlags:0,indicesOffset:U,indicesLength:G,bloomIndicesOffset:N,bloomIndicesLength:V,groundEffectVertexOffset:W,groundEffectVertexLength:X,hasFauxFacade:v,segment:F,height:j})}this.programConfigurations.populatePaintArrays(O.layoutVertexArray.length,l,h,{},i.availableImages,r,i.brightness),this.groundEffect.addPaintPropertiesData(l,h,{},i.availableImages,r,i.brightness)}this.groundEffect.prepareBorderSegments(),this.evaluate(this.layers[0],{})}update(e,i,r,a,n,o,s){this.programConfigurations.updatePaintArrays(e,i,n,r,a,o,s),this.groundEffect.update(e,i,n,r,a,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){let i=i=>{i.layoutVertexBuffer=e.createVertexBuffer(i.layoutVertexArray,cG.members),i.layoutNormalBuffer=e.createVertexBuffer(i.layoutNormalArray,cq.members),i.layoutCentroidBuffer=e.createVertexBuffer(i.layoutCentroidArray,c$.members),i.layoutFacadeDataArray&&i.layoutFacadeDataArray.length&&(i.layoutFacadeDataBuffer=e.createVertexBuffer(i.layoutFacadeDataArray,cW.members)),i.layoutFacadeVerticalRangeArray&&i.layoutFacadeVerticalRangeArray.length&&(i.layoutFacadeVerticalRangeBuffer=e.createVertexBuffer(i.layoutFacadeVerticalRangeArray,cX.members)),i.entranceBloom.layoutVertexArray.length&&(i.entranceBloom.layoutVertexBuffer=e.createVertexBuffer(i.entranceBloom.layoutVertexArray,cG.members),i.entranceBloom.layoutAttenuationBuffer=e.createVertexBuffer(i.entranceBloom.layoutAttenuationArray,cY.members)),this.uploadUpdatedColorBuffer(e),this.uploadUpdatedIndexBuffer(e)};this.uploaded||(i(this.buildingWithoutFacade),i(this.buildingWithFacade),this.groundEffect.upload(e)),this.groundEffect.uploadPaintProperties(e),this.programConfigurations.upload(e),this.uploaded=!0}destroy(){let 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,i,r=!0){let a=!1,n=r?i:0,o=0|(r?-1:~i);for(let i of(0===this.groundEffect.hiddenByLandmarkVertexArray.length&&this.groundEffect.hiddenByLandmarkVertexArray.resize(this.groundEffect.vertexArray.length),e)){let e=this.footprints[i],r=e.hiddenFlags&o|n;e.hiddenFlags!==r&&(e.hiddenFlags=r,a=!0,this.groundEffect.updateHiddenByLandmarkRange(e.groundEffectVertexOffset,e.groundEffectVertexLength,0!==e.hiddenFlags))}return a&&(this.indexArrayForConflationUploaded=!1),a}uploadUpdatedIndexBuffer(e){if(this.groundEffect.uploadHiddenByLandmark(e),this.indexArrayForConflationUploaded)return;let i=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))};for(let e of(i(this.buildingWithoutFacade),i(this.buildingWithFacade),this.footprints)){let i=e.hasFauxFacade?this.buildingWithFacade:this.buildingWithoutFacade,r=e.indicesOffset+e.indicesLength;if(0!==e.hiddenFlags){for(let a=e.indicesOffset;a<r;a++)i.indexArrayForConflation.uint16[3*a+0]=0,i.indexArrayForConflation.uint16[3*a+1]=0,i.indexArrayForConflation.uint16[3*a+2]=0;let a=e.bloomIndicesOffset+e.bloomIndicesLength;for(let r=e.bloomIndicesOffset;r<a;r++)i.entranceBloom.indexArrayForConflation.uint16[3*r+0]=0,i.entranceBloom.indexArrayForConflation.uint16[3*r+1]=0,i.entranceBloom.indexArrayForConflation.uint16[3*r+2]=0}}let r=i=>{0!==i.indexArray.length&&(i.indexBuffer?i.indexBuffer.updateData(i.indexArrayForConflation):i.indexBuffer=e.createIndexBuffer(i.indexArrayForConflation,!0),i.entranceBloom.indexBuffer?i.entranceBloom.indexBuffer.updateData(i.entranceBloom.indexArrayForConflation):i.entranceBloom.indexBuffer=e.createIndexBuffer(i.entranceBloom.indexArrayForConflation,!0))};r(this.buildingWithoutFacade),r(this.buildingWithFacade),this.indexArrayForConflationUploaded=!0}uploadUpdatedColorBuffer(e){let i=i=>{i.layoutColorBuffer?i.layoutColorBuffer.updateData(i.layoutColorArray):i.layoutColorBuffer=e.createVertexBuffer(i.layoutColorArray,cH.members,!0),i.layoutFacadePaintArray&&(i.layoutFacadePaintBuffer?i.layoutFacadePaintBuffer.updateData(i.layoutFacadePaintArray):i.layoutFacadePaintBuffer=e.createVertexBuffer(i.layoutFacadePaintArray,cZ.members,!0)),i.entranceBloom.layoutColorBuffer?i.entranceBloom.layoutColorBuffer.updateData(i.entranceBloom.layoutColorArray):i.entranceBloom.layoutColorBuffer=e.createVertexBuffer(i.entranceBloom.layoutColorArray,cH.members,!0)};i(this.buildingWithoutFacade),i(this.buildingWithFacade),this.colorBufferUploaded=!0}evaluate(e,i){let r=e.paint.get("building-ambient-occlusion-intensity");for(let a of this.buildingFeatures){let n=i[a.feature.id],o=a.feature;o.properties["building-part"]="roof";let s=e.paint.get("building-color").evaluate(o,n,this.canonical).toPremultipliedRenderColor(this.lut),l=e.paint.get("building-emissive-strength").evaluate(o,n,this.canonical);o.properties["building-part"]="wall";let h=e.paint.get("building-color").evaluate(o,n,this.canonical).toPremultipliedRenderColor(this.lut),u=e.paint.get("building-emissive-strength").evaluate(o,n,this.canonical);o.properties["building-part"]="window";
7let c=e.paint.get("building-color").evaluate(o,n,this.canonical).toPremultipliedRenderColor(this.lut),d=e.paint.get("building-emissive-strength").evaluate(o,n,this.canonical);o.properties["building-part"]="door";let p=e.paint.get("building-color").evaluate(o,n,this.canonical).toPremultipliedRenderColor(this.lut),f=e.paint.get("building-emissive-strength").evaluate(o,n,this.canonical),m=a.hasFauxFacade?this.buildingWithFacade:this.buildingWithoutFacade;for(let e of a.parts){let i,n=s;"roof"===e.part?(n=s,i=l):"wall"===e.part?(n=h,i=u):"facade_glazing"===e.part?(n=c,i=d):"entrance"===e.part&&(n=p,i=f),i=tt(i,0,1);for(let o=0;o<e.vertexLength;o++){let s=e.vertexOffset+o,l=1+(m.layoutAOArray[s]-1)*r;m.layoutColorArray.emplace(s,n.r*l*255<<8|n.g*l*255,n.b*l*255<<8|255*i),a.hasFauxFacade&&m.layoutFacadePaintArray.emplace(s,255*c.r<<8|255*c.g,255*c.b<<8|255*d)}}let _=a.buildingBloom;if(_)for(let e=0;e<_.vertexLength;e++)m.entranceBloom.layoutColorArray.emplace(_.vertexOffset+e,255*p.r<<8|255*p.g,255*p.b<<8|51*f)}}needsEvaluation(){return!this.colorBufferUploaded}updateReplacement(e,i,r){if(i.updateTime===this.replacementUpdateTime)return;this.replacementUpdateTime=i.updateTime;let a=i.getReplacementRegionsForTile(e.toUnwrapped());if(us(this.activeReplacements,a))return;for(let e of(this.activeReplacements=a,this.footprints))e.hiddenFlags&=-2;let n=[];for(let i of this.activeReplacements){if(i.order<=ui)continue;let r=Math.max(1,Math.pow(2,i.footprintTileId.canonical.z-e.canonical.z));for(let a of this.footprints)a.min.x>i.max.x||a.max.x<i.min.x||a.min.y>i.max.y||a.max.y<i.min.y||(n.length=0,function(e,i,r,a,n,o){let s=Math.pow(2,a.z-n.z);for(let l=0;l<r;l++){let r=e[l+0].x,h=e[l+i].y;r=(r+8192*n.x)*s-8192*a.x,h=(h+8192*n.y)*s-8192*a.y,o.push(new e3(r,h))}}(a.vertices,0,a.vertices.length,i.footprintTileId.canonical,e.canonical,n),uh(i.footprint,n,a.indices,0,a.indices.length,0,-r)&&(a.hiddenFlags|=1))}for(let e of(0===this.groundEffect.hiddenByLandmarkVertexArray.length&&this.groundEffect.hiddenByLandmarkVertexArray.resize(this.groundEffect.vertexArray.length),this.footprints))this.groundEffect.updateHiddenByLandmarkRange(e.groundEffectVertexOffset,e.groundEffectVertexLength,0!==e.hiddenFlags);this.indexArrayForConflationUploaded=!1}getHeightAtTileCoord(e,i){let r=-1/0,a=!0,n=4*(e+8192)*8192+(i+8192);if(this.footprintLookup.hasOwnProperty(n)){let e=this.footprintLookup[n];return e?{height:e.height,hidden:0!==e.hiddenFlags}:void 0}let o=new e3(e,i);for(let s of this.footprints)e>s.max.x||s.min.x>e||i>s.max.y||s.min.y>i||s.height<=r||uc(o,s)&&(r=s.height,this.footprintLookup[n]=s,a=0!==s.hiddenFlags);if(r!==-1/0)return{height:r,hidden:a};this.footprintLookup[n]=void 0}}a3(c0,"BuildingBucket",{omit:["layers"]}),a3(cQ,"BuildingGeometry"),a3(cJ,"BuildingBloomGeometry");let c1=ou([{name:"a_pos_normal",components:2,type:"Int16"},{name:"a_data",components:4,type:"Uint8"},{name:"a_linesofar",components:1,type:"Float32"}],4),c2=ou([{name:"a_z_offset_width",components:3,type:"Float32"}],4),{members:c3}=c1,{members:c5}=ou([{name:"a_packed",components:3,type:"Float32"}]),{members:c4}=ou([{name:"a_pattern_data",components:3,type:"Float32"}]);class c6{constructor(e,i){this.width=e,this.height=i,this.nextRow=0,this.image=new hp({width:e,height:i}),this.positions={},this.uploaded=!1}getDash(e,i){let r=this.getKey(e,i);return this.positions[r]}trim(){let e=this.width,i=this.height=ts(this.nextRow);this.image.resize({width:e,height:i})}getKey(e,i){return e.join(",")+i}getDashRanges(e,i,r){let a=[],n=e.length%2==1?-e[e.length-1]*r:0,o=e[0]*r,s=!0;a.push({left:n,right:o,isDash:s,zeroLength:0===e[0]});let l=e[0];for(let i=1;i<e.length;i++){s=!s;let h=e[i];n=l*r,l+=h,o=l*r,a.push({left:n,right:o,isDash:s,zeroLength:0===h})}return a}addRoundDash(e,i,r){let a=i/2;for(let i=-r;i<=r;i++){let n=this.width*(this.nextRow+r+i),o=0,s=e[0];for(let l=0;l<this.width;l++){let h;l/s.right>1&&(s=e[++o]);let u=Math.min(Math.abs(l-s.left),Math.abs(l-s.right)),c=i/r*(a+1);if(s.isDash){let e=a-Math.abs(c);h=Math.sqrt(u*u+e*e)}else h=a-Math.sqrt(u*u+c*c);this.image.data[n+l]=Math.max(0,Math.min(255,h+128))}}}
7addRegularDash(e,i){for(let i=e.length-1;i>=0;--i){let r=e[i],a=e[i+1];r.zeroLength?e.splice(i,1):a&&a.isDash===r.isDash&&(a.left=r.left,e.splice(i,1))}let r=e[0],a=e[e.length-1];r.isDash===a.isDash&&(r.left=a.left-this.width,a.right=r.right+this.width);let n=this.width*this.nextRow,o=0,s=e[0];for(let r=0;r<this.width;r++){r/s.right>1&&(s=e[++o]);let a=Math.min(Math.abs(r-s.left),Math.abs(r-s.right));this.image.data[n+r]=Math.max(0,Math.min(255,(s.isDash?a:-a)+i+128))}}addDash(e,i){let r=this.getKey(e,i);if(this.positions[r])return this.positions[r];let a="round"===i,n=7*!!a,o=2*n+1;if(this.nextRow+o>this.height)return tf("LineAtlas out of space"),null;0===e.length&&e.push(1);let s=0;for(let i=0;i<e.length;i++)e[i]<0&&(tf("Negative value is found in line dasharray, replacing values with 0"),e[i]=0),s+=e[i];if(0!==s){let r=this.width/s,o=this.getDashRanges(e,this.width,r);a?this.addRoundDash(o,r,n):this.addRegularDash(o,"square"===i?.5*r:0)}let l=this.nextRow+n;this.nextRow+=o;let h={tl:[l,n],br:[s,0]};return this.positions[r]=h,h}}a3(c6,"LineAtlas");let c8=s1.types,c9=Math.cos(Math.PI/180*37.5),c7=Math.cos(Math.PI/180*5);class de{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 ox,this.layoutVertexArray2=new ov,this.patternVertexArray=new ov,this.indexArray=new oD,this.programConfigurations=new sA(e.layers,{zoom:e.zoom,lut:e.lut}),this.segments=new se,this.maxLineLength=0,this.zOffsetVertexArray=new ov,this.stateDependentLayerIds=this.layers.filter(e=>e.isStateDependent()).map(e=>e.id),this.tessellationStep=e.tessellationStep?e.tessellationStep:128,this.worldview=e.worldview}updateFootprints(e,i){}populate(e,i,r,a){this.hasPattern=hU("line",this.layers,this.pixelRatio,i);let n=this.layers[0].layout.get("line-sort-key");this.tileToMeter=sX(r);let o=this.layers[0].layout.get("line-elevation-reference");if("hd-road-markup"===o)this.elevationType="road";else{let e=this.layers[0].layout.get("line-z-offset"),i=e.isConstant()&&!e.constantOr(0);this.elevationType="sea"!==o&&"ground"!==o&&i?"none":"offset","offset"===this.elevationType&&"none"===o&&tf(`line-elevation-reference: ground is used for the layer ${this.layerIds[0]} because non-zero line-z-offset value was found.`)}let s=this.layers[0].layout.get("line-cross-slope");this.hasCrossSlope="offset"===this.elevationType&&void 0!==s;let l=[];for(let{feature:i,id:o,index:s,sourceLayerIndex:h}of e){let e=this.layers[0]._featureFilter.needGeometry,u=s0(i,e);if(!this.layers[0]._featureFilter.filter(new nV(this.zoom,{worldview:this.worldview}),u,r))continue;let c=n?n.evaluate(u,{},r):void 0,d={id:o,properties:i.properties,type:i.type,sourceLayerIndex:h,index:s,geometry:e?u.geometry:sQ(i,r,a),patterns:{},sortKey:c};l.push(d)}n&&l.sort((e,i)=>e.sortKey-i.sortKey);let{lineAtlas:h,featureIndex:u}=i,c=this.addConstantDashes(h);for(let a of l){let{geometry:n,index:o,sourceLayerIndex:s}=a;if(c&&this.addFeatureDashes(a,h),this.hasPattern){let e=hj("line",this.layers,a,this.zoom,this.pixelRatio,i);this.patternFeatures.push(e)}else this.addFeature(a,n,o,r,h.positions,i.availableImages,i.brightness,i.elevationFeatures);u.insert(e[o].feature,n,o,s,this.index)}}addConstantDashes(e){let i=!1;for(let r of this.layers){let a=r.paint.get("line-dasharray").value,n=r.layout.get("line-cap").value;if("constant"!==a.kind||"constant"!==n.kind)i=!0;else{let i=n.value,r=a.value;if(!r)continue;e.addDash(r,i)}}return i}addFeatureDashes(e,i){let r=this.zoom;for(let a of this.layers){let n,o,s=a.paint.get("line-dasharray").value,l=a.layout.get("line-cap").value;if("constant"!==s.kind||"constant"!==l.kind){if("constant"===s.kind){if(!(n=s.value))continue}else n=s.evaluate({zoom:r},e);o="constant"===l.kind?l.value:l.evaluate({zoom:r},e),i.addDash(n,o),e.patterns[a.id]=[i.getKey(n,o)]}}}update(e,i,r,a,n,o,s,l){this.programConfigurations.updatePaintArrays(e,i,n,r,a,o,s,l)}
7addFeatures(e,i,r,a,n,o){for(let e of this.patternFeatures)this.addFeature(e,e.geometry,e.index,i,r,a,o)}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,c5)),0!==this.patternVertexArray.length&&(this.patternVertexBuffer=e.createVertexBuffer(this.patternVertexArray,c4)),!this.zOffsetVertexBuffer&&this.zOffsetVertexArray.length>0&&(this.zOffsetVertexBuffer=e.createVertexBuffer(this.zOffsetVertexArray,c2.members,!0)),this.layoutVertexBuffer=e.createVertexBuffer(this.layoutVertexArray,c3),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,i){let r,a;if(i&&i>0?(r=`mapbox_clip_start_${i}`,a=`mapbox_clip_end_${i}`):(r="mapbox_clip_start",a="mapbox_clip_end"),e.properties&&e.properties.hasOwnProperty(r)&&e.properties.hasOwnProperty(a))return{start:+e.properties[r],end:+e.properties[a]}}addFeature(e,i,r,a,n,o,s,l){let h=this.layers[0].layout,u=h.get("line-join").evaluate(e,{}),c=h.get("line-cap").evaluate(e,{}),d=h.get("line-miter-limit"),p=h.get("line-round-limit");this.lineClips=this.lineFeatureClips(e),this.lineFeature=e;let f=!(!e.properties||!e.properties.hasOwnProperty("mapbox_line_metrics"))&&e.properties.mapbox_line_metrics;this.zOffsetValue=h.get("line-z-offset").value;let m=this.layers[0].paint.get("line-width").value;if("constant"!==m.kind&&!1===m.isLineProgressConstant&&(this.variableWidthValue=m),"road"===this.elevationType){let r=this.layoutVertexArray.length;if(!this.addElevatedRoadFeature(e,i,a,l,u,c,d,p)){let[n,o]=this.clipRuntimeLinesToTile(i,1);for(let i=0;i<n.length;i++){let r=n[i],s=o[i],l={progress:{min:s.progress.min,max:s.progress.max},nextDir:this.computeSegNextDir(s,r),prevDir:this.computeSegPrevDir(s,r)};this.addLine(r,e,a,u,c,d,p,l,f&&s.parentIndex>0?s.parentIndex:null)}this.fillNonElevatedRoadSegment(r)}}else for(let r=0;r<i.length;r++)this.addLine(i[r],e,a,u,c,d,p,void 0,f&&r>0?r:null);this.programConfigurations.populatePaintArrays(this.layoutVertexArray.length,e,r,n,o,a,s,void 0,this.worldview)}computeSegNextDir(e,i){return e.nextPoint.sub(i.at(-2)).unit()}computeSegPrevDir(e,i){return i[1].sub(e.prevPoint).unit()}clipLinesToTile(e,i){return uU(e,-i,-i,8192+i,8192+i)}clipRuntimeLinesToTile(e,i){let r=[];return[uU(e,-i,-i,8192+i,8192+i,r),r]}addElevatedRoadFeature(e,i,r,a,n,o,s,l){let h=[],u=lm.getElevationFeature(e,a);if(u){let e=this.clipLinesToTile(i,1);for(let i of this.prepareElevatedLines(e,u,r))h.push({geometry:i,elevation:u,elevationTileID:r,segment:{progress:{min:0,max:1},nextDir:void 0,prevDir:void 0}})}if(0===h.length)return!1;for(let i of h){let a=this.layoutVertexArray.length;this.addLine(i.geometry,e,r,n,o,s,l);let h=new l_(r,i.elevationTileID);if(i.elevation)for(let e=a;e<this.layoutVertexArray.length;e++){let r=new e3(this.layoutVertexArray.int16[6*e]>>1,this.layoutVertexArray.int16[6*e+1]>>1),a=h.pointElevation(r,i.elevation,.05);this.updateHeightRange(a),this.zOffsetVertexArray.emplaceBack(a,0,0)}else this.fillNonElevatedRoadSegment(a)}return!0}prepareElevatedLines(e,i,r){if(null!=i.constantHeight)return e;let a=[],n=1/sX(r);for(let r of e)!function(e,i,r,a,n){if(e.length<2)return a.push(e);let o=[];for(;i.valid();){let[r,a]=i.get();for(let i=0;i<e.length-1;i++){let n=e[i],s=e[i+1],l=function(e,i,r,a){let n=lb(e,i,a),o=lb(e,i,r);if(Math.sign(n)===Math.sign(o))return;let s=lb(r,a,e),l=s+o-n;return Math.sign(s)!==Math.sign(l)?[s/(s-l),o/(o-n)]:void 0}(n,s,r,a);if(l){let[e]=l,r=new e3(ip(n.x,s.x,e),ip(n.y,s.y,e));o.push({t:i+e,distance:0,point:r})}}i.next()}if(0===o.length)return a.push(e);o.sort((e,i)=>e.t-i.t);let s=0,l=0,h=[];for(a.push(h);s!==e.length;){if(l===o.length){for(;s!==e.length;)0!==h.length&&h[h.length-1].equals(e[s])||h.push(e[s]),s++;break}o[l].t<=s?(0!==h.length&&h[h.length-1].equals(o[l].point)||h.push(o[l].point),o[l].t,l++):(0!==h.length&&h[h.length-1].equals(e[s])||h.push(e[s]),s++)}}(r,new lp(i,n),0,a);return a}fillNonElevatedRoadSegment(e){for(let i=e;i<this.layoutVertexArray.length;i++)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,i,r,a,n,o,s,l,h){let u,c,d,p,f,m,_,g;this.distance=0,this.prevDistance=0,this.scaledDistance=0,this.totalDistance=0,this.totalFeatureLength=0,this.lineS
7oFar=0,this.currentVertex=void 0,this.lineClips=h?this.lineFeatureClips(i,h):this.lineClips;let y="none"===a;this.patternJoinNone=this.hasPattern&&y,this.segmentStart=0,this.segmentStartf32=0,this.segmentPoints=[];let x=l&&l.progress.min>0,v=l&&l.progress.max<1;if(this.lineClips){let r={min:this.lineClips.start,max:this.lineClips.end},a=1;if(l){var b,w,T;let e=this.lineClips.end-this.lineClips.start;b=l.progress,w={min:0,max:1},T=r,r={min:tE(b.min,w,T),max:tE(b.max,w,T)},e>0&&(a=(r.max-r.min)/e)}let n=+i.properties.mapbox_clip_feature_len,o=+i.properties.mapbox_clip_seg_len;if(Number.isNaN(n)||Number.isNaN(o)){for(let i=0;i<e.length-1;i++)this.totalDistance+=e[i].dist(e[i+1]);let i=this.totalDistance/(r.max-r.min);this.totalFeatureLength=Number.isFinite(i)?i:0,this.lineClips.start=r.min,this.lineClips.end=r.max,this.maxLineLength=Math.max(this.maxLineLength,this.totalDistance)}else this.totalFeatureLength=n,this.distance=o*a,this.lineClips.start=r.min,this.lineClips.end=r.max,this.maxLineLength=Math.max(this.maxLineLength,this.distance);this.lineClipsArray.push(this.lineClips),this.updateScaledDistance()}let S="Polygon"===c8[i.type],E=e.length;for(;E>=2&&e[E-1].equals(e[E-2]);)E--;let I=0;for(;I<E-1&&e[I].equals(e[I+1]);)I++;if(E<(S?3:2))return;"bevel"===a&&(o=1.05);let A=this.segments.prepareSegment(10*E,this.layoutVertexArray,this.indexArray);l&&l.prevDir&&(m=l.prevDir.perp()),l&&l.nextDir&&(_=l.nextDir.perp()),this.e1=this.e2=-1,S&&(u=e[E-2],f=e[I].sub(u)._unit()._perp());for(let i=I;i<E;i++){if((d=i===E-1?S?e[I+1]:void 0:e[i+1])&&e[i].equals(d))continue;f&&(p=f),u&&(c=u),u=e[i],g=this.evaluateLineProgressFeatures(c?c.dist(u):0),f=d?d.sub(u)._unit()._perp():p,p=p||f;let r=c&&d,l=r?a:S||y?"butt":n,h=p.x*f.x+p.y*f.y;if(y){let e=function(e){if(e.patternJoinNone){let i=e.segmentPoints.length/2,r=e.lineSoFar-e.segmentStart;for(let a=0;a<i;++a){let i=e.segmentPoints[2*a+1],n=Math.round(e.segmentPoints[2*a])+.5+.25*i;e.patternVertexArray.emplaceBack(n,r,e.segmentStart),e.patternVertexArray.emplaceBack(n,r,e.segmentStart)}e.segmentPoints.length=0}e.e1=e.e2=-1};if(r&&h<c7){this.updateDistance(c,u),this.addCurrentVertex(u,p,1,1,A,g),e(this),this.addCurrentVertex(u,f,-1,-1,A,g);continue}if(c){if(!d){this.updateDistance(c,u),this.addCurrentVertex(u,p,1,1,A,g),e(this);continue}l="miter"}}let b=p.add(f);0===b.x&&0===b.y||b._unit();let w=b.x*f.x+b.y*f.y,T=0!==w?1/w:1/0,C=2*Math.sqrt(2-2*w),M=w<c9&&c&&d,P=p.x*f.y-p.y*f.x>0,z=this.overscaling<=16?122880/(512*this.overscaling):0;if(r&&"round"===l){if(T<s)l="miter";else if(T<=2){let e=dt(u,-10,8202);l="offset"===this.elevationType&&(e||this.hasCrossSlope)?"miter":"fakeround"}}if("miter"===l&&T>o&&(l="bevel"),"bevel"===l&&(T>2&&(l="flipbevel"),T<o&&(l="miter")),c&&!("miter"===l&&M)&&this.updateDistance(c,u),"miter"===l)if(M){let e=u.dist(c);if(e>2*z){let i=u.sub(u.sub(c)._mult(z/e)._round());this.updateDistance(c,i),this.addCurrentVertex(i,p,0,0,A,g),c=i}this.updateDistance(c,u),b._mult(T),this.addCurrentVertex(u,b,0,0,A,g);let i=u.dist(d);if(i>2*z){let e=u.add(d.sub(u)._mult(z/i)._round());this.updateDistance(u,e),this.addCurrentVertex(e,f,0,0,A,g),u=e}}else b._mult(T),this.addCurrentVertex(u,b,0,0,A,g);else if("flipbevel"===l){if(T>100)b=f.mult(-1);else{let e=T*p.add(f).mag()/p.sub(f).mag();b._perp()._mult(e*(P?-1:1))}this.addCurrentVertex(u,b,0,0,A,g),this.addCurrentVertex(u,b.mult(-1),0,0,A,g)}else if("bevel"===l||"fakeround"===l){null!=g&&c&&this.addCurrentVertex(u,_||p,-1,-1,A,g);let e=u.dist(c)<=2*z&&"bevel"!==l,i=b.mult(P?1:-1);i._mult(T);let r=f.mult(P?-1:1),a=p.mult(P?-1:1),n=this.evaluateLineProgressFeatures(this.distance);if(null==g&&(this.addHalfVertex(u,i.x,i.y,!1,!P,0,A,n),e||this.addHalfVertex(u,i.x+2*a.x,i.y+2*a.y,!1,P,0,A,n)),"fakeround"===l){let e=Math.round(180*C/Math.PI/20);this.addHalfVertex(u,a.x,a.y,!1,P,0,A,n);for(let i=0;i<e;i++){let o=i/e;if(.5!==o){let e=o-.5;o+=o*e*(o-1)*((1.0904+h*(h*(3.55645-1.43519*h)-3.2452))*e*e+(.848013+h*(.215638*h-1.06021)))}let s=r.sub(a)._mult(o)._add(a)._unit();this.addHalfVertex(u,s.x,s.y,!1,P,0,A,n)}this.addHalfVertex(u,r.x,r.y,!1,P,0,A,n)}e||null!=g||this.addHalfVertex(u,i.x+2*r.x,i.y+2*r.y,!1,P,0,A,n),null!=g&&d&&this.addCurrentVertex(u,m||f,1,1,A,g)}else if("butt"===l)this.addCurrentVertex(u,b,0,0,A,g);else if("square"===l){if(!c){let e=x?0:-1;this.addCurrentVertex(u,b,e,e,A,g)}if(this.addCurrentVertex(u,b,0,0,A,g),c){let e=+!v;this.addCurrentVertex(u,b,e,e,A,g)}}else if("round"===l){if(c){let e=!r&&_?_:p;this.addCurrentVertex(u,e,0,0,A,g),!r&&v||this.addCurrentVertex(u,e,1,1,A,g,!0)}if(d){let e=!r&&m?m:f;!r&&x||this.addCurrentVertex(u,e,-1,-1,A,g,!0),this.addCurrentVertex(u,e,0,0,A,g)}}}}addVerticesTo(e,i,r,a,n,o,s,l,h,u){let c=(i.w-e.w)/this.tessellationStep|0,d=0,p=this.scaledDistance;if(c>
71){this.lineSoFar=e.w;let p=(i.x-e.x)/c,f=(i.y-e.y)/c,m=(i.z-e.z)/c,_=(i.w-e.w)/c;for(let i=1;i<c;++i){e.x+=p,e.y+=f,e.z+=m,this.lineSoFar+=_,d+=_;let i=this.evaluateLineProgressFeatures(this.prevDistance+d);this.scaledDistance=(this.prevDistance+d)/this.totalDistance,this.addHalfVertex(e,r,a,u,!1,s,h,i),this.addHalfVertex(e,n,o,u,!0,-l,h,i)}}this.lineSoFar=i.w,this.scaledDistance=p;let f=this.evaluateLineProgressFeatures(this.distance);this.addHalfVertex(i,r,a,u,!1,s,h,f),this.addHalfVertex(i,n,o,u,!0,-l,h,f)}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):tf(`line-progress evaluation for ${this.layerIds[0]} requires enabling 'lineMetrics' for the source.`);let i=0;return this.variableWidthValue&&"constant"!==this.variableWidthValue.kind&&(i=this.variableWidthValue.evaluate(this.evaluationGlobals,this.lineFeature)||0),"offset"!==this.elevationType?{zOffset:0,variableWidth:i}:"constant"===this.zOffsetValue.kind?{zOffset:this.zOffsetValue.value,variableWidth:i}:{zOffset:this.zOffsetValue.evaluate(this.evaluationGlobals,this.lineFeature)||0,variableWidth:i}}addCurrentVertex(e,i,r,a,n,o,s=!1){let l=i.x+i.y*r,h=i.y-i.x*r,u=i.y*a-i.x,c=-i.y-i.x*a;if(null!=o){let i="offset"===this.elevationType,d=o.zOffset,p=new uB(e.x,e.y,d,this.lineSoFar),f=!!i&&dt(e,-10,8202),m=this.lineSoFar,_=this.distance;if(this.currentVertex)if(f){let i=this.currentVertexIsOutside,o=this.currentVertex,f=new uB(e.x,e.y,d,this.lineSoFar);if(uV(o,f,-10,8202),!dt(f,-10,8202)){if(i){this.e1=this.e2=-1,this.distance-=o.dist(p),this.lineSoFar=o.w;let e=this.evaluateLineProgressFeatures(o.w-this.totalFeatureLength*(this.lineClips?this.lineClips.start:0));this.addHalfVertex(o,l,h,s,!1,r,n,e),this.addHalfVertex(o,u,c,s,!0,-a,n,e),this.prevDistance=this.distance}this.distance=this.prevDistance+o.dist(f),this.scaledDistance=this.distance/this.totalDistance,this.addVerticesTo(o,f,l,h,u,c,r,a,n,s),this.distance=_,this.scaledDistance=this.distance/this.totalDistance}}else{let e=this.currentVertex;if(this.currentVertexIsOutside){uV(e,p,-10,8202),this.e1=this.e2=-1,this.distance-=e.dist(p),this.scaledDistance=this.distance/this.totalDistance,this.lineSoFar=e.w;let i=this.evaluateLineProgressFeatures(e.w-this.totalFeatureLength*(this.lineClips?this.lineClips.start:0));this.addHalfVertex(e,l,h,s,!1,r,n,i),this.addHalfVertex(e,u,c,s,!0,-a,n,i),this.prevDistance=this.distance,this.distance=_,this.scaledDistance=this.distance/this.totalDistance}this.addVerticesTo(e,p,l,h,u,c,r,a,n,s)}else f||(this.addHalfVertex(e,l,h,s,!1,r,n,o),this.addHalfVertex(e,u,c,s,!0,-a,n,o));this.currentVertex=p,this.currentVertexIsOutside=f,this.lineSoFar=m}else this.addHalfVertex(e,l,h,s,!1,r,n,o),this.addHalfVertex(e,u,c,s,!0,-a,n,o)}addHalfVertex({x:e,y:i},r,a,n,o,s,l,h){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,(i<<1)+ +!!o,Math.round(63*r)+128,Math.round(63*a)+128,1+(0===s?0:s<0?-1:1),0,this.lineSoFar-this.segmentStartf32),this.lineClips){let e=ip(this.lineClips.start,this.lineClips.end,this.scaledDistance);this.layoutVertexArray2.emplaceBack(this.scaledDistance,this.lineClipsArray.length,e)}let u=l.vertexLength++;this.e1>=0&&this.e2>=0&&(this.indexArray.emplaceBack(this.e1,this.e2,u),l.primitiveLength++),o?this.e2=u:this.e1=u,null!=h&&this.zOffsetVertexArray.emplaceBack(h.zOffset,h.variableWidth,h.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,i){this.prevDistance=this.distance,this.distance+=e.dist(i),this.updateScaledDistance()}}function dt(e,i,r){return e.x<i||e.x>r||e.y<i||e.y>r}function di(e,i,r){return i*(8192/(e.tileSize*Math.pow(2,r-e.tileID.overscaledZ
7)))}a3(de,"LineBucket",{omit:["layers","patternFeatures","currentVertex","currentVertexIsOutside"]});let dr=(e,i,r)=>(1-r)*e+r*i;function da(e,i){return 1/di(e,1,i.tileZoom)}function dn(e,i,r,a){return e.translatePosMatrix(a||i.tileID.projMatrix,i,r.paint.get("line-translate"),r.paint.get("line-translate-anchor"))}let ds=e=>{let i=[];dl(e)&&i.push("RENDER_LINE_DASH"),e.paint.get("line-gradient")&&i.push("RENDER_LINE_GRADIENT");let r=e.paint.get("line-trim-offset");0===r[0]&&0===r[1]||i.push("RENDER_LINE_TRIM_OFFSET"),0!==e.paint.get("line-border-width").constantOr(1)&&i.push("RENDER_LINE_BORDER");let a="none"===e.layout.get("line-join").constantOr("miter"),n=!!e.paint.get("line-pattern").constantOr(1);return a&&n&&i.push("LINE_JOIN_NONE"),i};function dl(e){let i=e.paint.get("line-dasharray").value;return"constant"!==i.kind||i.value}let dh=()=>z||(z={layout:M||(M=new nJ({"line-cap":new nY(nQ.layout_line["line-cap"]),"line-join":new nY(nQ.layout_line["line-join"]),"line-miter-limit":new nX(nQ.layout_line["line-miter-limit"]),"line-round-limit":new nX(nQ.layout_line["line-round-limit"]),"line-sort-key":new nY(nQ.layout_line["line-sort-key"]),"line-z-offset":new nY(nQ.layout_line["line-z-offset"]),"line-elevation-reference":new nX(nQ.layout_line["line-elevation-reference"]),"line-cross-slope":new nX(nQ.layout_line["line-cross-slope"]),visibility:new nX(nQ.layout_line.visibility),"line-width-unit":new nX(nQ.layout_line["line-width-unit"])})),paint:P||(P=new nJ({"line-opacity":new nY(nQ.paint_line["line-opacity"]),"line-color":new nY(nQ.paint_line["line-color"]),"line-translate":new nX(nQ.paint_line["line-translate"]),"line-translate-anchor":new nX(nQ.paint_line["line-translate-anchor"]),"line-width":new nY(nQ.paint_line["line-width"]),"line-gap-width":new nY(nQ.paint_line["line-gap-width"]),"line-offset":new nY(nQ.paint_line["line-offset"]),"line-blur":new nY(nQ.paint_line["line-blur"]),"line-dasharray":new nY(nQ.paint_line["line-dasharray"]),"line-pattern":new nY(nQ.paint_line["line-pattern"]),"line-pattern-cross-fade":new nX(nQ.paint_line["line-pattern-cross-fade"]),"line-gradient":new nK(nQ.paint_line["line-gradient"]),"line-trim-offset":new nX(nQ.paint_line["line-trim-offset"]),"line-trim-fade-range":new nX(nQ.paint_line["line-trim-fade-range"]),"line-trim-color":new nX(nQ.paint_line["line-trim-color"]),"line-emissive-strength":new nX(nQ.paint_line["line-emissive-strength"]),"line-border-width":new nY(nQ.paint_line["line-border-width"]),"line-border-color":new nY(nQ.paint_line["line-border-color"]),"line-occlusion-opacity":new nX(nQ.paint_line["line-occlusion-opacity"]),"line-color-use-theme":new nY({type:"string",default:"default","property-type":"data-driven"}),"line-gradient-use-theme":new nY({type:"string",default:"default","property-type":"data-driven"}),"line-trim-color-use-theme":new nY({type:"string",default:"default","property-type":"data-driven"}),"line-border-color-use-theme":new nY({type:"string",default:"default","property-type":"data-driven"})}))});class du extends nY{possiblyEvaluate(e,i){return i=new nV(Math.floor(i.zoom),{now:i.now,fadeDuration:i.fadeDuration,transition:i.transition,worldview:i.worldview}),super.possiblyEvaluate(e,i)}evaluate(e,i,r,a){return i=Object.assign({},i,{zoom:Math.floor(i.zoom)}),super.evaluate(e,i,r,a)}}let dc=ou([{name:"a_pos_offset",components:4,type:"Int16"},{name:"a_tex_size",components:4,type:"Uint16"},{name:"a_pixeloffset",components:4,type:"Int16"}],4),dd=ou([{name:"a_globe_anchor",components:3,type:"Int16"},{name:"a_globe_normal",components:3,type:"Float32"}],4),dp=ou([{name:"a_projected_pos",components:4,type:"Float32"}],4);ou([{name:"a_fade_opacity",components:1,type:"Uint32"}],4);let df=ou([{name:"a_auto_z_offset",components:1,type:"Float32"}],4),dm=ou([{name:"a_x_axis",components:3,type:"Float32"},{name:"a_y_axis",components:3,type:"Float32"}]),d_=ou([{name:"a_texb",components:2,type:"Uint16"}]),dg=ou([{name:"a_placed",components:2,type:"Uint8"},{name:"a_shift",components:2,type:"Float32"},{name:"a_elevation_from_sea",components:2,type:"Float32"}]),dy=ou([{name:"a_size_scale",components:1,type:"Float32"},{name:"a_padding",components:2,type:"Float32"},{name:"a_auto_z_offset",components:1,type:"Float32"}]);ou([{type:"Int16",name:"projectedAnchorX"},{type:"Int16",name:"projectedAnchorY"},{type:"Int16",name:"projectedAnchorZ"},{type:"Int16",name:"tileAnchorX"},{type:"Int16",name:"tileAnchorY"},{type:"Float32",name:"x1"},{type:"Float32",name:"y1"},{type:"Float32",name:"x2"},{type:"Float32",name:"y2"},{type:"Int16",name:"padding"},{type:"Uint32",name:"featureIndex"},{type:"Uint16",name:"sourceLayerIndex"},{type:"Uint16",name:"bucketIndex"}]);let dx=ou([{name:"a_pos",components:3,type:"Int16"},{name:"a_anchor_pos",components:2,type:"Int16"},{name:"a_extrude",components:2,type:"Int16"}],4),dv=ou([{name:"a_pos_2f",components:2,type:"Float32"},{name:"a_radius",components:1,type:"Float32"},{name:"a_flags",components:2,type:"Int16"}],4);ou([{name:"triangle",components:3,type:"Uint16"}]),ou([{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"}]),ou([{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"}
7]),ou([{type:"Float32",name:"offsetX"}]),ou([{type:"Int16",name:"x"},{type:"Int16",name:"y"}]);let db={"!":"ï¸","#":"ï¼",$:"ï¼","%":"ï¼
","&":"ï¼","(":"︵",")":"︶","*":"ï¼","+":"ï¼",",":"ï¸","-":"︲",".":"ã»","/":"ï¼",":":"ï¸",";":"ï¸","<":"︿","=":"ï¼",">":"ï¹","?":"ï¸","@":"ï¼ ","[":"ï¹","\\":"ï¼¼","]":"ï¹","^":"ï¼¾",_:"︳","`":"ï½","{":"︷","|":"â","}":"︸","~":"ï½","\xa2":"ï¿ ","\xa3":"ï¿¡","\xa5":"ï¿¥","\xa6":"¦","\xac":"ï¿¢","\xaf":"ï¿£","â":"︲","â":"︱","â":"ï¹","â":"ï¹","â":"ï¹","â":"ï¹","â¦":"ï¸","â§":"ã»","â©":"₩","ã":"ï¸","ã":"ï¸","ã":"︿","ã":"ï¹","ã":"︽","ã":"︾","ã":"ï¹","ã":"ï¹","ã":"ï¹","ã":"ï¹","ã":"︻","ã":"︼","ã":"︹","ã":"︺","ã":"ï¸","ã":"ï¸","ï¼":"ï¸","ï¼":"︵","ï¼":"︶","ï¼":"ï¸","ï¼":"︲","ï¼":"ã»","ï¼":"ï¸","ï¼":"ï¸","ï¼":"︿","ï¼":"ï¹","ï¼":"ï¸","ï¼»":"ï¹","ï¼½":"ï¹","_":"︳","ï½":"︷","ï½":"â","ï½":"︸","ï½":"︵","ï½ ":"︶","。":"ï¸","ï½¢":"ï¹","ï½£":"ï¹","â":"â","â":"â"},dw="undefined"==typeof TextDecoder?null:new TextDecoder("utf-8"),dT=class{constructor(e=new Uint8Array(16)){this.buf=ArrayBuffer.isView(e)?e:new Uint8Array(e),this.dataView=new DataView(this.buf.buffer),this.pos=0,this.type=0,this.length=this.buf.length}readFields(e,i,r=this.length){for(;this.pos<r;){let r=this.readVarint(),a=r>>3,n=this.pos;this.type=7&r,e(a,i,this),this.pos===n&&this.skip(r)}return i}readMessage(e,i){return this.readFields(e,i,this.readVarint()+this.pos)}readFixed32(){let e=this.dataView.getUint32(this.pos,!0);return this.pos+=4,e}readSFixed32(){let e=this.dataView.getInt32(this.pos,!0);return this.pos+=4,e}readFixed64(){let e=this.dataView.getUint32(this.pos,!0)+0x100000000*this.dataView.getUint32(this.pos+4,!0);return this.pos+=8,e}readSFixed64(){let e=this.dataView.getUint32(this.pos,!0)+0x100000000*this.dataView.getInt32(this.pos+4,!0);return this.pos+=8,e}readFloat(){let e=this.dataView.getFloat32(this.pos,!0);return this.pos+=4,e}readDouble(){let e=this.dataView.getFloat64(this.pos,!0);return this.pos+=8,e}readVarint(e){let i,r,a=this.buf;return i=127&(r=a[this.pos++]),r<128?i:(i|=(127&(r=a[this.pos++]))<<7,r<128?i:(i|=(127&(r=a[this.pos++]))<<14,r<128?i:(i|=(127&(r=a[this.pos++]))<<21,r<128?i:function(e,i,r){let a,n,o=r.buf;if(a=(112&(n=o[r.pos++]))>>4,n<128||(a|=(127&(n=o[r.pos++]))<<3,n<128)||(a|=(127&(n=o[r.pos++]))<<10,n<128)||(a|=(127&(n=o[r.pos++]))<<17,n<128)||(a|=(127&(n=o[r.pos++]))<<24,n<128)||(a|=(1&(n=o[r.pos++]))<<31,n<128))return function(e,i,r){return r?0x100000000*i+(e>>>0):0x100000000*(i>>>0)+(e>>>0)}(e,a,i);throw Error("Expected varint not more than 10 bytes")}(i|=(15&(r=a[this.pos]))<<28,e,this))))}readVarint64(){return this.readVarint(!0)}readSVarint(){let e=this.readVarint();return e%2==1?-((e+1)/2):e/2}readBoolean(){return!!this.readVarint()}readString(){let e=this.readVarint()+this.pos,i=this.pos;return this.pos=e,e-i>=12&&dw?dw.decode(this.buf.subarray(i,e)):function(e,i,r){let a="",n=i;for(;n<r;){let i=e[n],o,s,l,h=null,u=i>239?4:i>223?3:i>191?2:1;if(n+u>r)break;
71===u?i<128&&(h=i):2===u?128==(192&(o=e[n+1]))&&(h=(31&i)<<6|63&o)<=127&&(h=null):3===u?(o=e[n+1],s=e[n+2],128==(192&o)&&128==(192&s)&&((h=(15&i)<<12|(63&o)<<6|63&s)<=2047||h>=55296&&h<=57343)&&(h=null)):4===u&&(o=e[n+1],s=e[n+2],l=e[n+3],128==(192&o)&&128==(192&s)&&128==(192&l)&&((h=(15&i)<<18|(63&o)<<12|(63&s)<<6|63&l)<=65535||h>=1114112)&&(h=null)),null===h?(h=65533,u=1):h>65535&&(h-=65536,a+=String.fromCharCode(h>>>10&1023|55296),h=56320|1023&h),a+=String.fromCharCode(h),n+=u}return a}(this.buf,i,e)}readBytes(){let e=this.readVarint()+this.pos,i=this.buf.subarray(this.pos,e);return this.pos=e,i}readPackedVarint(e=[],i){let r=this.readPackedEnd();for(;this.pos<r;)e.push(this.readVarint(i));return e}readPackedSVarint(e=[]){let i=this.readPackedEnd();for(;this.pos<i;)e.push(this.readSVarint());return e}readPackedBoolean(e=[]){let i=this.readPackedEnd();for(;this.pos<i;)e.push(this.readBoolean());return e}readPackedFloat(e=[]){let i=this.readPackedEnd();for(;this.pos<i;)e.push(this.readFloat());return e}readPackedDouble(e=[]){let i=this.readPackedEnd();for(;this.pos<i;)e.push(this.readDouble());return e}readPackedFixed32(e=[]){let i=this.readPackedEnd();for(;this.pos<i;)e.push(this.readFixed32());return e}readPackedSFixed32(e=[]){let i=this.readPackedEnd();for(;this.pos<i;)e.push(this.readSFixed32());return e}readPackedFixed64(e=[]){let i=this.readPackedEnd();for(;this.pos<i;)e.push(this.readFixed64());return e}readPackedSFixed64(e=[]){let i=this.readPackedEnd();for(;this.pos<i;)e.push(this.readSFixed64());return e}readPackedEnd(){return 2===this.type?this.readVarint()+this.pos:this.pos+1}skip(e){let i=7&e;if(0===i)for(;this.buf[this.pos++]>127;);else if(2===i)this.pos=this.readVarint()+this.pos;else if(5===i)this.pos+=4;else{if(1!==i)throw Error(`Unimplemented type: ${i}`);this.pos+=8}}writeTag(e,i){this.writeVarint(e<<3|i)}realloc(e){let i=this.length||16;for(;i<this.pos+e;)i*=2;if(i!==this.length){let e=new Uint8Array(i);e.set(this.buf),this.buf=e,this.dataView=new DataView(e.buffer),this.length=i}}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(23283064365386963e-26*e),!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(23283064365386963e-26*e),!0),this.pos+=8}writeVarint(e){(e=+e||0)>0xfffffff||e<0?function(e,i){var r;let a,n;if(e>=0?(a=e%0x100000000|0,n=e/0x100000000|0):(a=~(-e%0x100000000),n=~(-e/0x100000000),0xffffffff^a?a=a+1|0:(a=0,n=n+1|0)),e>=0xffffffffffffffff||e<-0xffffffffffffffff)throw Error("Given varint doesn't fit into 10 bytes");i.realloc(10),r=a,i.buf[i.pos++]=127&r|128,r>>>=7,i.buf[i.pos++]=127&r|128,r>>>=7,i.buf[i.pos++]=127&r|128,r>>>=7,i.buf[i.pos++]=127&r|128,i.buf[i.pos]=127&(r>>>=7),function(e,i){let r=(7&e)<<4;i.buf[i.pos++]|=r|128*!!(e>>>=3),e&&(i.buf[i.pos++]=127&e|128*!!(e>>>=7),e&&(i.buf[i.pos++]=127&e|128*!!(e>>>=7),e&&(i.buf[i.pos++]=127&e|128*!!(e>>>=7),e&&(i.buf[i.pos++]=127&e|128*!!(e>>>=7),e&&(i.buf[i.pos++]=127&e)))))}(n,i)}(e,this):(this.realloc(4),this.buf[this.pos++]=127&e|128*(e>127),e<=127||(this.buf[this.pos++]=127&(e>>>=7)|128*(e>127),e<=127||(this.buf[this.pos++]=127&(e>>>=7)|128*(e>127),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++;let i=this.pos;this.pos=function(e,i,r){for(let a,n,o=0;o<i.length;o++){if((a=i.charCodeAt(o))>55295&&a<57344){if(!n){a>56319||o+1===i.length?(e[r++]=239,e[r++]=191,e[r++]=189):n=a;continue}if(a<56320){e[r++]=239,e[r++]=191,e[r++]=189,n=a;continue}a=n-55296<<10|a-56320|65536,n=null}else n&&(e[r++]=239,e[r++]=191,e[r++]=189,n=null);a<128?e[r++]=a:(a<2048?e[r++]=a>>6|192:(a<65536?e[r++]=a>>12|224:(e[r++]=a>>18|240,e[r++]=a>>12&63|128),e[r++]=a>>6&63|128),e[r++]=63&a|128)}return r}(this.buf,e,this.pos);let r=this.pos-i;r>=128&&dS(i,r,this),this.pos=i-1,this.writeVarint(r),this.pos+=r}writeFloat(e){this.realloc(4),this.dataView.setFloat32(this.pos,e,!0),this.pos+=4}writeDouble(e){this.realloc(8),this.dataView.setFloat64(this.pos,e,!0),this.pos+=8}writeBytes(e){let i=e.length;this.writeVarint(i),this.realloc(i);for(let r=0;r<i;r++)this.buf[this.pos++]=e[r]}writeRawMessage(e,i){this.pos++;let r=this.pos;e(i,this);let a=this.pos-r;a>=128&&dS(r,a,this),this.pos=r-1,this.writeVarint(a),this.pos+=a}writeMessage(e,i,r){this.writeTag(e,2),this.writeRawMessage(i,r)}writePackedVarint(e,i){i.length&&this.writeMessage(e,dE,i)}writePackedSVarint(e,i){i.length&&this.writeMessage(e,dI,i)}writePackedBoolean(e,i){i.length&&this.writeMessage(e,dM,i)}writePackedFloat(e,i){i.length&&this.writeMessage(e,dA,i)}writePackedDouble(e,i){i.length&&this.writeMessage(e,dC,i)}writePackedFixed32(e,i){i.length&&this.writeMessage(e,dP,i)}writePackedSFixed32(e,i){i.length&&this.writeMessage(e,dz,i)}writePackedFixed64(e,i){i.length&&this.writeMessage(e,dR,i)}writePackedSFixed64(e,i){i.length&&this.writeMessage(e,dD,i)}writeBytesField(e,i){this.writeTag(e,2),this.writeBytes(i)}writeFixed32Field(e,i){this.writeTag(e,5),this.writeFixed32(i)}writeSFixed32Field(e,i){this.writeTag(e,5),this.writeSFixed32(i)}
7writeFixed64Field(e,i){this.writeTag(e,1),this.writeFixed64(i)}writeSFixed64Field(e,i){this.writeTag(e,1),this.writeSFixed64(i)}writeVarintField(e,i){this.writeTag(e,0),this.writeVarint(i)}writeSVarintField(e,i){this.writeTag(e,0),this.writeSVarint(i)}writeStringField(e,i){this.writeTag(e,2),this.writeString(i)}writeFloatField(e,i){this.writeTag(e,5),this.writeFloat(i)}writeDoubleField(e,i){this.writeTag(e,1),this.writeDouble(i)}writeBooleanField(e,i){this.writeVarintField(e,+i)}};function dS(e,i,r){let a=i<=16383?1:i<=2097151?2:i<=0xfffffff?3:Math.floor(Math.log(i)/(7*Math.LN2));r.realloc(a);for(let i=r.pos-1;i>=e;i--)r.buf[i+a]=r.buf[i]}function dE(e,i){for(let r=0;r<e.length;r++)i.writeVarint(e[r])}function dI(e,i){for(let r=0;r<e.length;r++)i.writeSVarint(e[r])}function dA(e,i){for(let r=0;r<e.length;r++)i.writeFloat(e[r])}function dC(e,i){for(let r=0;r<e.length;r++)i.writeDouble(e[r])}function dM(e,i){for(let r=0;r<e.length;r++)i.writeBoolean(e[r])}function dP(e,i){for(let r=0;r<e.length;r++)i.writeFixed32(e[r])}function dz(e,i){for(let r=0;r<e.length;r++)i.writeSFixed32(e[r])}function dR(e,i){for(let r=0;r<e.length;r++)i.writeFixed64(e[r])}function dD(e,i){for(let r=0;r<e.length;r++)i.writeSFixed64(e[r])}function dL(e,i,r){i.glyphs=[],1===e&&r.readMessage(dO,i)}function dO(e,i,r){if(3===e){let{id:e,bitmap:a,width:n,height:o,left:s,top:l,advance:h}=r.readMessage(dF,{});i.glyphs.push({id:e,bitmap:new hp({width:n+6,height:o+6},a),metrics:{width:n,height:o,left:s,top:l,advance:h}})}else 4===e?i.ascender=r.readSVarint():5===e&&(i.descender=r.readSVarint())}function dF(e,i,r){1===e?i.id=r.readVarint():2===e?i.bitmap=r.readBytes():3===e?i.width=r.readVarint():4===e?i.height=r.readVarint():5===e?i.left=r.readSVarint():6===e?i.top=r.readSVarint():7===e&&(i.advance=r.readVarint())}let dk={horizontal:1,vertical:2,horizontalOnly:3};class dB{constructor(){this.scale=1,this.fontStack="",this.image=null}static forText(e,i){let r=new dB;return r.scale=e||1,r.fontStack=i,r}static forImage(e){let i=new dB;return i.image=e,i}}class dN{constructor(){this.text="",this.sectionIndex=[],this.sections=[],this.imageSectionID=null}static fromFeature(e,i,r){let a=new dN;for(let n=0;n<e.sections.length;n++){let o=e.sections[n];o.image?a.addImageSection(o,r):a.addTextSection(o,i)}return a}length(){return this.text.length}getSection(e){return this.sections[this.sectionIndex[e]]}getSections(){return this.sections}getSectionIndex(e){return this.sectionIndex[e]}getCodePoint(e){return this.text.codePointAt(e)}verticalizePunctuation(e){this.text=function(e,i){let r="";for(let a=0;a<e.length;a++){let n=e.charCodeAt(a+1)||null,o=e.charCodeAt(a-1)||null;r+=!i&&(n&&nC(n)&&!db[e[a+1]]||o&&nC(o)&&!db[e[a-1]])||!db[e[a]]?e[a]:db[e[a]]}return r}(this.text,e)}trim(){let e=0;for(let i=0;i<this.text.length&&dU[this.text.charCodeAt(i)];i++)e++;let i=this.text.length;for(let r=this.text.length-1;r>=0&&r>=e&&dU[this.text.charCodeAt(r)];r--)i--;this.text=this.text.substring(e,i),this.sectionIndex=this.sectionIndex.slice(e,i)}substring(e,i){let r=new dN;return r.text=this.text.substring(e,i),r.sectionIndex=this.sectionIndex.slice(e,i),r.sections=this.sections,r}toString(){return this.text}getMaxScale(){return this.sectionIndex.reduce((e,i)=>Math.max(e,this.sections[i].scale),0)}addTextSection(e,i){this.text+=e.text,this.sections.push(dB.forText(e.scale,e.fontStack||i));let r=this.sections.length-1;for(let i=0;i<e.text.length;++i)this.sectionIndex.push(r)}addImageSection(e,i){let r=e.image?e.image.getPrimary():null;if(!r)return void tf("Can't add FormattedSection with an empty image.");r.scaleSelf(i);let a=this.getNextImageSectionCharCode();a?(this.text+=String.fromCodePoint(a),this.sections.push(dB.forImage(r)),this.sectionIndex.push(this.sections.length-1)):tf("Reached maximum number of images 6401")}getNextImageSectionCharCode(){return this.imageSectionID?this.imageSectionID>=63743?null:++this.imageSectionID:(this.imageSectionID=57344,this.imageSectionID)}}function dV(e,i,r,a,n,o,s,l,h,u,c,d,p,f,m,_=1){let g=dN.fromFeature(e,n,_);d===dk.vertical&&g.verticalizePunctuation(p);let y=[],x=function(e,i,r,a,n,o){if(!e)return[];let s=[],l=function(e,i,r,a,n,o){let s=0;for(let r=0;r<e.length();r++){let l=e.getSection(r);s+=dG(e.getCodePoint(r),l,a,n,i,o)}return s/Math.max(1,Math.ceil(s/r))}(e,i,r,a,n,o),h=e.text.indexOf("â")>=0,u=0;for(let r=0;r<e.length();r++){let c=e.getSection(r),d=e.getCodePoint(r);if(dU[d]||(u+=dG(d,c,a,n,i,o)),r<e.length()-1){let i=!(d<11904||!(nh(d)||nl(d)||nw(d)||nx(d)||np(d)||ni(d)||nu(d)||nn(d)||nf(d)||nm(d
7)||nd(d)||nE(d)||no(d)||na(d)||nr(d)||nc(d)||ns(d)||nb(d)||ng(d)||n_(d)));(dj[d]||i||c.image)&&s.push(d$(r+1,u,l,s,function(e,i,r){let a=0;return 10===e&&(a-=1e4),r&&(a+=150),40!==e&&65288!==e||(a+=50),41!==i&&65289!==i||(a+=50),a}(d,e.getCodePoint(r+1),i&&h),!1))}}return function e(i){return i?e(i.priorBreak).concat(i.index):[]}(d$(e.length(),u,l,s,0,!0))}(g,u,o,i,a,f),{processBidirectionalText:v,processStyledBidirectionalText:b}=nN;if(v&&1===g.sections.length)for(let e of v(g.toString(),x)){let i=new dN;i.text=e,i.sections=g.sections;for(let r=0;r<e.length;r++)i.sectionIndex.push(0);y.push(i)}else if(b)for(let e of b(g.text,g.sectionIndex,x)){let i=new dN;i.text=e[0],i.sectionIndex=e[1],i.sections=g.sections,y.push(i)}else y=function(e,i){let r=[],a=e.text,n=0;for(let a of i)r.push(e.substring(n,a)),n=a;return n<a.length&&r.push(e.substring(n,a.length)),r}(g,x);let w=[],T={positionedLines:w,text:g.toString(),top:c[1],bottom:c[1],left:c[0],right:c[0],writingMode:d,iconsInText:!1,verticalizable:!1,hasBaseline:!1};if(function(e,i,r,a,n,o,s,l,h,u,c,d){let p=0,f=0,m=0,_="right"===l?1:.5*("left"!==l),g=!1;for(let e of n){for(let r of e.getSections()){if(r.image)continue;let e=i[r.fontStack];if(e&&!(g=void 0!==e.ascender&&void 0!==e.descender))break}if(!g)break}let y=0;for(let s of n){s.trim();let n=s.getMaxScale(),l=(n-1)*24,x={positionedGlyphs:[],lineOffset:0};e.positionedLines[y]=x;let v=x.positionedGlyphs,b=0;if(!s.length()){f+=o,++y;continue}let w=0,T=0;for(let o=0;o<s.length();o++){let l=s.getSection(o),m=s.getSectionIndex(o),_=s.getCodePoint(o),y=l.scale,x=null,S=null,E=null,I=24,A=0,C=h;C===dk.vertical&&(12312===_||12313===_||12316===_||12540===_||12448===_)&&(C=dk.horizontal);let M=!(C===dk.horizontal||!c&&!nA(_)||c&&(dU[_]||a9(_)||a7(_)||ne(_)||nv(_)||nS(_)));if(l.image){let i=a.get(l.image.toString());if(!i)continue;E=l.image,e.iconsInText=e.iconsInText||!0,S=i.paddedRect;let r=i.displaySize;y=24*y/d,x={width:r[0],height:r[1],left:0,top:-3,advance:M?r[1]:r[0],localGlyph:!1},A=g?-x.height*y:24*n-17-r[1]*y,I=x.advance;let o=(M?r[0]:r[1])*y-24*n;o>0&&o>b&&(b=o)}else{let e=r[l.fontStack];if(!e)continue;e[_]&&(S=e[_]);let a=i[l.fontStack];if(!a)continue;let o=a.glyphs[_];if(!o)continue;if(x=o.metrics,I=24*(8203!==_),g){let e=void 0!==a.ascender?Math.abs(a.ascender):0,i=void 0!==a.descender?Math.abs(a.descender):0,r=(e+i)*y;w<r&&(w=r,T=(e-i)/2*y),A=-e*y}else A=(n-y)*24-17}M?(e.verticalizable=!0,v.push({glyph:_,image:E,x:p,y:f+A,vertical:M,scale:y,localGlyph:x.localGlyph,fontStack:l.fontStack,sectionIndex:m,metrics:x,rect:S}),p+=I*y+u):(v.push({glyph:_,image:E,x:p,y:f+A,vertical:M,scale:y,localGlyph:x.localGlyph,fontStack:l.fontStack,sectionIndex:m,metrics:x,rect:S}),p+=x.advance*y+u)}0!==v.length&&(m=Math.max(p-u,m),g?dZ(v,_,b,T,o*n/2):dZ(v,_,b,0,o/2)),p=0;let S=o*n+b;x.lineOffset=Math.max(b,l),f+=S,++y}let x=f,{horizontalAlign:v,verticalAlign:b}=dH(s);(function(e,i,r,a,n,o){let s=(i-r)*n,l=-o*a;for(let i of e)for(let e of i.positionedGlyphs)e.x+=s,e.y+=l})(e.positionedLines,_,v,b,m,x),e.top+=-b*x,e.bottom=e.top+x,e.left+=-v*m,e.right=e.left+m,e.hasBaseline=g}(T,i,r,a,y,s,l,h,d,u,p,m),!function(e){for(let i of e)if(0!==i.positionedGlyphs.length)return!1;return!0}(w))return T}let dU={9:!0,10:!0,11:!0,12:!0,13:!0,32:!0},dj={10:!0,32:!0,38:!0,40:!0,41:!0,43:!0,45:!0,47:!0,173:!0,183:!0,8203:!0,8208:!0,8211:!0,8231:!0};function dG(e,i,r,a,n,o){if(i.image){let e=a.get(i.image.toString());return e?e.displaySize[0]*i.scale*24/o+n:0}{let a=r[i.fontStack],o=a&&a.glyphs[e];return o?o.metrics.advance*i.scale+n:0}}function dq(e,i,r,a){let n=Math.pow(e-i,2);return a?e<i?n/2:2*n:n+Math.abs(r)*r}function d$(e,i,r,a,n,o){let s=null,l=dq(i,r,n,o);for(let e of a){let a=dq(i-e.x,r,n,o)+e.badness;a<=l&&(s=e,l=a)}return{index:e,x:i,priorBreak:s,badness:l}}function dH(e){let i=.5,r=.5;switch(e){case"right":case"top-right":case"bottom-right":i=1;break;case"left":case"top-left":case"bottom-left":i=0}switch(e){case"bottom":case"bottom-right":case"bottom-left":r=1;break;case"top":case"top-right":case"top-left":r=0}return{horizontalAlign:i,verticalAlign:r}}function dZ(e,i,r,a,n){if(!(i||r||a||n))return;let o=e.length-1,s=e[o],l=(s.x+s.metrics.advance*s.scale)*i;for(let i=0;i<=o;i++)e[i].x-=l,e[i].y+=r+a+n}function dW(e){return void 0!==e.imagePrimary&&void 0!==e.top&&void 0!==e.bottom&&void 0!==e.left&&void 0!==e.right}function dX(e,i,r,a,n,o){let s,l,h,u,c,d=e.imagePrimary;if(d.content){let e=d.content,i=d.pixelRatio||1;s=[e[0]/i,e[1]/i,d.displaySize[0]-e[2]/i,d.displaySize[1]-e[3]/i]}let p=i.left*o,f=i.right*o;"width"===r||"both"===r?(c=n[0]+p-a[3],h=n[0]+f+a[1]):h=(c=n[0]+(p+f-d.displaySize[0])/2)+d.displaySize[0];let m=i.top*o,_=i.bottom*o;return"height"===r||"both"===r?(l=n[1]+m-a[0],u=n[1]+_+a[2]):u=(l=n[1]+(m+_-d.displaySize[1])/2)+d.displaySize[1],{imagePrimary:d,imageSecondary:void 0,top:l,right:h,bottom:u,left:c,collisionPadding:s}}function dY(e){return!e.imagePrimary.stretchX}function dK(e){return!e.imagePrimary.stretchY}function dJ(e){return{width:e.right-e.left,height:e.bottom-e.top}}function dQ(e,i,r){let{expression:a}=i;if("constant"===a.kind)return{kind:"constant",layoutSize:a.evaluate(new nV(e+1,{worldview:r}))};if("source"===a.kind)return{kind:"source"};{let{zoomStops:i,interpolationType:n}=a,o=0;for(;o<i.length&&i[o]<=e;)o++;let s=o=Math.max(0,o-1);for(;s<i.length&&i[s]<e+1;)s++;s=Math.min(i.length-1,s);let l=i[o],h=i[s];return"composite"===a.kind?{kind:"composite",minZoom:l,maxZoom:h,interpolationType:n}:{kind:"camera",minZoom:l,maxZoom:h,minSize:a.evaluate(new nV(l,{worldview:r})),maxSize:a.evaluate(new nV(h,{worldview:r})),interpolationType:n}}}function d0(e,{uSize:i,uSizeT:r},{lowerSize:a,upperSize:n}){return"source"===e.kind?a/128:"composite"===e.kind?ip(a/128,n/128,r):i}function d1(e,i,r=1){let a=0,n=0;if("constant"===e.kind)n=e.layoutSize*r;else if("source"!==e.kind){let{interpolationType:o,minZoom:s,maxZoom:l}=e,h=o?tt(ar.interpolationFactor(o,i,s,l),0,1):0;"camera"===e.kind?n=ip(e.minSize,e.maxSize,h)*r:a=h*r}return{uSizeT:a,uSize:n}}
7class d2 extends e3{constructor(e,i,r,a,n){super(e,i),this.angle=a,this.z=r,void 0!==n&&(this.segment=n)}clone(){return new d2(this.x,this.y,this.z,this.angle,this.segment)}}function d3(e,i,r,a,n){if(void 0===i.segment)return!0;let o=i,s=i.segment+1,l=0;for(;l>-r/2;){if(--s<0)return!1;l-=e[s].dist(o),o=e[s]}l+=e[s].dist(e[s+1]),s++;let h=[],u=0;for(;l<r/2;){let i=e[s],r=e[s+1];if(!r)return!1;let o=e[s-1].angleTo(i)-i.angleTo(r);for(o=Math.abs((o+3*Math.PI)%(2*Math.PI)-Math.PI),h.push({distance:l,angleDelta:o}),u+=o;l-h[0].distance>a;)u-=h.shift().angleDelta;if(u>n)return!1;s++,l+=i.dist(r)}return!0}function d5(e){let i=0;for(let r=0;r<e.length-1;r++)i+=e[r].dist(e[r+1]);return i}function d4(e,i){return Math.max(e?e.right-e.left:0,i?i.right-i.left:0)}function d6(e){let i=0,r=0;for(let a of e)i+=a.w*a.h,r=Math.max(r,a.w);e.sort((e,i)=>i.h-e.h);let a=[{x:0,y:0,w:Math.max(Math.ceil(Math.sqrt(i/.95)),r),h:1/0}],n=0,o=0;for(let i of e)for(let e=a.length-1;e>=0;e--){let r=a[e];if(!(i.w>r.w||i.h>r.h)){if(i.x=r.x,i.y=r.y,o=Math.max(o,i.y+i.h),n=Math.max(n,i.x+i.w),i.w===r.w&&i.h===r.h){let i=a.pop();i&&e<a.length&&(a[e]=i)}else i.h===r.h?(r.x+=i.w,r.w-=i.w):(i.w===r.w||a.push({x:r.x+i.w,y:r.y,w:r.w-i.w,h:i.h}),r.y+=i.h,r.h-=i.h);break}}return{w:n,h:o,fill:i/(n*o)||0}}a3(d2,"Anchor");class d8{static getImagePositionScale(e,i,r){if(i&&e&&e.options&&e.options.transform){let i=e.options.transform;return{x:i.a,y:i.d}}return{x:r,y:r}}constructor(e,i,r,a){this.paddedRect=e;let{pixelRatio:n,version:o,stretchX:s,stretchY:l,content:h,sdf:u,usvg:c}=i;this.pixelRatio=n,this.stretchX=s,this.stretchY=l,this.content=h,this.version=o,this.padding=r,this.sdf=u,this.usvg=c,this.scale=d8.getImagePositionScale(a,c,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 d9(e,i,r){let a=iN.parse(e),n=function(e,i,r=[1,1]){return{x:0,y:0,w:(e.data?e.data.width:e.width*r[0])+2*i,h:(e.data?e.data.height:e.height*r[1])+2*i}}(i,r,[a.options.transform.a,a.options.transform.d]);return{bin:n,imagePosition:new d8(n,i,r,a),imageVariant:a}}class d7{constructor(e,i,r){let a=new Map,n=new Map;this.haveRenderCallbacks=[];let o=[];this.addImages(e,a,1,o),this.addImages(i,n,2,o);let{w:s,h:l}=d6(o),h=new hf({width:s||1,height:l||1});for(let[i,r]of e.entries()){let e=a.get(i).paddedRect;hf.copy(r.data,h,{x:0,y:0},{x:e.x+1,y:e.y+1},r.data,null,r.sdf)}for(let[e,a]of i.entries()){let i=n.get(e),o=i.paddedRect,s=i.padding,l=o.x+s,u=o.y+s,c=a.data.width,d=a.data.height;s=s>1?s-1:s,hf.copy(a.data,h,{x:0,y:0},{x:l,y:u},a.data,r),hf.copy(a.data,h,{x:0,y:d-s},{x:l,y:u-s},{width:c,height:s},r),hf.copy(a.data,h,{x:0,y:0},{x:l,y:u+d},{width:c,height:s},r),hf.copy(a.data,h,{x:c-s,y:0},{x:l-s,y:u},{width:s,height:d},r),hf.copy(a.data,h,{x:0,y:0},{x:l+c,y:u},{width:s,height:d},r),hf.copy(a.data,h,{x:c-s,y:d-s},{x:l-s,y:u-s},{width:s,height:s},r),hf.copy(a.data,h,{x:0,y:d-s},{x:l+c,y:u-s},{width:s,height:s},r),hf.copy(a.data,h,{x:0,y:0},{x:l+c,y:u+d},{width:s,height:s},r),hf.copy(a.data,h,{x:c-s,y:0},{x:l-s,y:u+d},{width:s,height:s},r)}this.lut=r,this.image=h,this.iconPositions=a,this.patternPositions=n}addImages(e,i,r,a){for(let[n,o]of e.entries()){let{bin:e,imagePosition:s,imageVariant:l}=d9(n,o,r);i.set(n,s),a.push(e),o.hasRenderCallback&&this.haveRenderCallbacks.push(l.id)}}patchUpdatedImages(e,i,r){for(let a of(this.haveRenderCallbacks=this.haveRenderCallbacks.filter(i=>e.hasImage(i,r)),e.dispatchRenderCallbacks(this.haveRenderCallbacks,r),e.getUpdatedImages(r))){for(let n of this.iconPositions.keys()){let o=iN.parse(n);if(ia.isEqual(o.id,a)){let o=e.getImage(a,r);this.patchUpdatedImage(this.iconPositions.get(n),o,i,null)}}for(let n of this.patternPositions.keys()){let o=iN.parse(n);if(ia.isEqual(o.id,a)){let o=e.getImage(a,r);this.patchUpdatedImage(this.patternPositions.get(n),o,i,this.lut)}}}}patchUpdatedImage(e,i,r,a=null){if(!e||!i||e.version===i.version)return;e.version=i.version;let[n,o]=e.tl,s=e.sdf;if(this.lut||s){let e={width:i.data.width,height:i.data.height},l=new hf(e);hf.copy(i.data,l,{x:0,y:0},{x:0,y:0},e,a,s),r.update(l,{position:{x:n,y:o}})}else r.update(i.data,{position:{x:n,y:o}})}}function pe(e,i,r,a,n,o,s,l,h){for(let u=i;u<i+a;u++)pt(e,r*o+u,o,n,s,l,h);for(let u=r;u<r+n;u++)pt(e,u*o+i,1,a,s,l,h)}function pt(e,i,r,a,n,o,s){o[0]=0,s[0]=-1e20,s[1]=1e20,n[0]=e[i];for(let l=1,h=0,u=0;l<a;
7l++){n[l]=e[i+l*r];let a=l*l;do{let e=o[h];u=(n[l]-n[e]+a-e*e)/(l-e)/2}while(u<=s[h]&&--h>-1);o[++h]=l,s[h]=u,s[h+1]=1e20}for(let l=0,h=0;l<a;l++){for(;s[h+1]<l;)h++;let a=o[h],u=l-a;e[i+l*r]=n[a]+u*u}}a3(d8,"ImagePosition"),a3(d7,"ImageAtlas");let pi={none:0,ideographs:1,all:2};class pr{constructor(e,i,r){this.requestManager=e,this.localGlyphMode=i,this.localFontFamily=r,this.url="",this.entries={},this.localGlyphs={200:{},400:{},500:{},900:{}}}setURL(e){this.url=e}getGlyphs(e,i){let r=[],a=this.url||tI.GLYPHS_URL;for(let i in e)for(let a of e[i])r.push({stack:i,id:a});ta(r,({stack:e,id:i},r)=>{let n=this.entries[e];n||(n=this.entries[e]={glyphs:{},requests:{},ranges:{},ascender:void 0,descender:void 0});let o=n.glyphs[i];if(void 0!==o)return void r(null,{stack:e,id:i,glyph:o});if(o=this._tinySDF(n,e,i))return n.glyphs[i]=o,void r(null,{stack:e,id:i,glyph:o});let s=Math.floor(i/256);if(256*s>65535)return tf("glyphs > 65535 not supported"),void r(null,{stack:e,id:i,glyph:o});if(n.ranges[s])return void r(null,{stack:e,id:i,glyph:o});let l=n.requests[s];l||(l=n.requests[s]=[],pr.loadGlyphRange(e,s,a,this.requestManager,(e,i)=>{if(i){for(let e in n.ascender=i.ascender,n.descender=i.descender,i.glyphs)this._doesCharSupportLocalGlyph(+e)||(n.glyphs[+e]=i.glyphs[+e]);n.ranges[s]=!0}for(let r of l)r(e,i);delete n.requests[s]})),l.push((a,n)=>{a?r(a):n&&r(null,{stack:e,id:i,glyph:n.glyphs[i]||null})})},(e,r)=>{if(e)i(e);else if(r){let e={};for(let{stack:i,id:a,glyph:n}of r)void 0===e[i]&&(e[i]={}),void 0===e[i].glyphs&&(e[i].glyphs={}),e[i].glyphs[a]=n&&{id:n.id,bitmap:n.bitmap.clone(),metrics:n.metrics},e[i].ascender=this.entries[i].ascender,e[i].descender=this.entries[i].descender;i(null,e)}})}_doesCharSupportLocalGlyph(e){let i,r;return this.localGlyphMode!==pi.none&&(this.localGlyphMode===pi.all?!!this.localFontFamily:!!this.localFontFamily&&(nm(e)||ny(e)||no(e)||ns(e)||nn(e)||nf(e)||(i=e)>=131072&&i<=173791||(r=e)>=66736&&r<=66815))}_tinySDF(e,i,r){let a=this.localFontFamily;if(!a||!this._doesCharSupportLocalGlyph(r))return;let n=e.tinySDF;if(!n){let r="400";/bold/i.test(i)?r="900":/medium/i.test(i)?r="500":/light/i.test(i)&&(r="200"),(n=e.tinySDF=new pr.TinySDF({fontFamily:a,fontWeight:r,fontSize:48,buffer:6,radius:16})).fontWeight=r}if(this.localGlyphs[n.fontWeight][r])return this.localGlyphs[n.fontWeight][r];let o=String.fromCodePoint(r),{data:s,width:l,height:h,glyphWidth:u,glyphHeight:c,glyphLeft:d,glyphTop:p,glyphAdvance:f}=n.draw(o);return this.localGlyphs[n.fontWeight][r]={id:r,bitmap:new hp({width:l,height:h},s),metrics:{width:u/2,height:c/2,left:d/2,top:p/2-27,advance:f/2,localGlyph:!0}}}}function pa(e,i){return e+i[1]-i[0]}function pn(e,i,r,a,n=1){let o=[],s=e.imagePrimary,l=s.pixelRatio,h=s.paddedRect.w-2,u=s.paddedRect.h-2,c=(e.right-e.left)*n,d=(e.bottom-e.top)*n,p=s.stretchX||[[0,h]],f=s.stretchY||[[0,u]],m=p.reduce(pa,0),_=f.reduce(pa,0),g=h-m,y=u-_,x=0,v=m,b=0,w=_,T=0,S=g,E=0,I=y;if(s.content&&a){let e=s.content;x=po(p,0,e[0]),b=po(f,0,e[1]),v=po(p,e[0],e[2]),w=po(f,e[1],e[3]),T=e[0]-x,E=e[1]-b,S=e[2]-e[0]-v,I=e[3]-e[1]-w}let A=(a,o,h,u)=>{var p,f,g,y,A,C,M,P,z,R,D,L,O,F,k,B;let N=(p=a.stretch-x,p/v*c+e.left*n),V=(f=a.fixed-T,g=S,y=a.stretch,f-g*y/m),U=(A=o.stretch-b,A/w*d+e.top*n),j=(C=o.fixed-E,M=I,P=o.stretch,C-M*P/_),G=(z=h.stretch-x,z/v*c+e.left*n),q=(R=h.fixed-T,D=S,L=h.stretch,R-D*L/m),$=(O=u.stretch-b,O/w*d+e.top*n),H=(F=u.fixed-E,k=I,B=u.stretch,F-k*B/_),Z=new e3(N,U),W=new e3(G,U),X=new e3(G,$),Y=new e3(N,$),K=new e3(V/l,j/l),J=new e3(q/l,H/l),Q=i*Math.PI/180;if(Q){let e=Math.sin(Q),i=Math.cos(Q),r=[i,-e,e,i];Z._matMult(r),W._matMult(r),Y._matMult(r),X._matMult(r)}let ee=a.stretch+a.fixed,et=h.stretch+h.fixed,ei=o.stretch+o.fixed,er=u.stretch+u.fixed,ea=e.imageSecondary;return{tl:Z,tr:W,bl:Y,br:X,texPrimary:{x:s.paddedRect.x+1+ee,y:s.paddedRect.y+1+ei,w:et-ee,h:er-ei},texSecondary:ea?{x:ea.paddedRect.x+1+ee,y:ea.paddedRect.y+1+ei,w:et-ee,h:er-ei}:void 0,writingMode:void 0,glyphOffset:[0,0],sectionIndex:0,pixelOffsetTL:K,pixelOffsetBR:J,minFontScaleX:S/l/c,minFontScaleY:I/l/d,isSDF:r}};if(a&&(s.stretchX||s.stretchY)){let e=ps(p,g,m),i=ps(f,y,_);for(let r=0;r<e.length-1;r++){let a=e[r],n=e[r+1];for(let e=0;e<i.length-1;e++)o.push(A(a,i[e],n,i[e+1]))}}else o.push(A({fixed:0,stretch:-1},{fixed:0,stretch:-1},{fixed:0,stretch:h+1},{fixed:0,stretch:u+1}));return o}function po(e,i,r){let a=0;for(let n of e)a+=Math.max(i,Math.min(r,n[1]))-Math.max(i,Math.min(r,n[
70]));return a}function ps(e,i,r){let a=[{fixed:-1,stretch:0}];for(let[i,r]of e){let e=a[a.length-1];a.push({fixed:i-e.stretch,stretch:e.stretch}),a.push({fixed:i-e.stretch,stretch:e.stretch+(r-i)})}return a.push({fixed:i+1,stretch:r}),a}pr.loadGlyphRange=function(e,i,r,a,n){let o=256*i;tK(a.transformRequest(a.normalizeGlyphsURL(r).replace("{fontstack}",e).replace("{range}",`${o}-${o+255}`),tZ.Glyphs),(e,i)=>{if(e)n(e);else if(i){let e={},r=new dT(i).readFields(dL,{});for(let i of r.glyphs)e[i.id]=i;n(null,{glyphs:e,ascender:r.ascender,descender:r.descender})}})},pr.TinySDF=class{constructor({fontSize:e=24,buffer:i=3,radius:r=8,cutoff:a=.25,fontFamily:n="sans-serif",fontWeight:o="normal",fontStyle:s="normal",lang:l=null}={}){this.buffer=i,this.cutoff=a,this.radius=r,this.lang=l;let h=this.size=e+4*i,u=this._createCanvas(h),c=this.ctx=u.getContext("2d",{willReadFrequently:!0});c.font=`${s} ${o} ${e}px ${n}`,c.textBaseline="alphabetic",c.textAlign="left",c.fillStyle="black",this.gridOuter=new Float64Array(h*h),this.gridInner=new Float64Array(h*h),this.f=new Float64Array(h),this.z=new Float64Array(h+1),this.v=new Uint16Array(h)}_createCanvas(e){let i=document.createElement("canvas");return i.width=i.height=e,i}draw(e){let{width:i,actualBoundingBoxAscent:r,actualBoundingBoxDescent:a,actualBoundingBoxLeft:n,actualBoundingBoxRight:o}=this.ctx.measureText(e),s=Math.ceil(r),l=Math.max(0,Math.min(this.size-this.buffer,Math.ceil(o-n))),h=Math.min(this.size-this.buffer,s+Math.ceil(a)),u=l+2*this.buffer,c=h+2*this.buffer,d=Math.max(u*c,0),p=new Uint8ClampedArray(d),f={data:p,width:u,height:c,glyphWidth:l,glyphHeight:h,glyphTop:s,glyphLeft:0,glyphAdvance:i};if(0===l||0===h)return f;let{ctx:m,buffer:_,gridInner:g,gridOuter:y}=this;this.lang&&(m.lang=this.lang),m.clearRect(_,_,l,h),m.fillText(e,_,_+s);let x=m.getImageData(_,_,l,h);y.fill(1e20,0,d),g.fill(0,0,d);for(let e=0;e<h;e++)for(let i=0;i<l;i++){let r=x.data[4*(e*l+i)+3]/255;if(0===r)continue;let a=(e+_)*u+i+_;if(1===r)y[a]=0,g[a]=1e20;else{let e=.5-r;y[a]=e>0?e*e:0,g[a]=e<0?e*e:0}}pe(y,0,0,u,c,u,this.f,this.v,this.z),pe(g,_,_,l,h,u,this.f,this.v,this.z);for(let e=0;e<d;e++){let i=Math.sqrt(y[e])-Math.sqrt(g[e]);p[e]=Math.round(255-255*(i/this.radius+this.cutoff))}return f}};function pl(e,i){return i.max-e.max}class ph{constructor(e,i,r,a){this.p=new e3(e,i),this.h=r,this.d=function(e,i){let r=!1,a=1/0;for(let n=0;n<i.length;n++){let o=i[n];for(let i=0,n=o.length,s=n-1;i<n;s=i++){let n=o[i],l=o[s];n.y>e.y!=l.y>e.y&&e.x<(l.x-n.x)*(e.y-n.y)/(l.y-n.y)+n.x&&(r=!r),a=Math.min(a,lT(e,n,l))}}return(r?1:-1)*Math.sqrt(a)}(this.p,a),this.max=this.d+this.h*Math.SQRT2}}let pu=Object.keys,pc=1/0,pd=Math.sqrt(2);function pp(e,[i,r]){let a=0,n=0;if(r===pc){i<0&&(i=0);let r=i/pd;switch(e){case"top-right":case"top-left":n=r-7;break;case"bottom-right":case"bottom-left":n=7-r;break;case"bottom":n=7-i;break;case"top":n=i-7}switch(e){case"top-right":case"bottom-right":a=-r;break;case"top-left":case"bottom-left":a=r;break;case"left":a=i;break;case"right":a=-i}}else{switch(i=Math.abs(i),r=Math.abs(r),e){case"top-right":case"top-left":case"top":n=r-7;break;case"bottom-right":case"bottom-left":case"bottom":n=7-r}switch(e){case"top-right":case"bottom-right":case"right":a=-i;break;case"top-left":case"bottom-left":case"left":a=i}}return[a,n]}function pf(e,i,r,a,n,o,s,l,h){if(!i||!i.usvg)return;let u=dJ(a),c=dJ(n),d=("both"===o||"width"===o)&&dY(a)?c.width/u.width:1,p=("both"===o||"height"===o)&&dK(a)?c.height/u.height:1;r.scaleSelf(d,p);let f=r.toString();s.set(f,r),l.set(f,i);let{imagePosition:m}=d9(f,i,1);h.set(f,m)}function pm(e,i,r,a,n,o,s,l,h){var u,c,d,p,f,m;if(!e)return;let _=(u=i,c=r,d=a,p=n,f=o,m=h,"camera"===u.kind?u.maxSize:"composite"===u.kind?Math.max(c.possiblyEvaluate(new nV(u.maxZoom,{worldview:m}),d).evaluate(f,{},d),c.possiblyEvaluate(new nV(u.minZoom,{worldview:m}),d).evaluate(f,{},d)):c.possiblyEvaluate(new nV(p,{worldview:m})).evaluate(f,{},d));return e.scaleSelf(_*l*s)}function p_(e,i,r,a,n,o,s,l,h){return{iconPrimary:pm(e.getPrimary(),i,r,a,n,o,s,l,h),iconSecondary:pm(e.getSecondary(),i,r,a,n,o,s,l,h)}}function pg(e,i,r,a){e&&(e.imagePrimary=i.get(r.toString()),a&&(e.imageSecondary=i.get(a.toString())))}function py(e,i){if(e){for(let r of e.positionedLines)for(let e of r.positionedGlyphs)if(null!==e.image){let r=e.image.toString();e.rect=i.get(r).paddedRect}}}function px(e){switch(e){case"right":case"top-right":case"bottom-right":return"right";case"left":case"top-left":case"bottom-left":return"left"}return"center"}function pv(e,i,r,a,n,o,s,l,h,u,c,d,p,f,m,_,g,y){let x=function(e,i,r,a,n,o,s,l){let h=[];if(0===i.positionedLines.length)return h;let u=a.layout.get("text-rotate").evaluate(o,{})*Math.PI/180,c=function(e){let i=e[0],r=e[1],a=i*r;return a>
70?[i,-r]:a<0?[-i,r]:0===i?[r,i]:[r,-i]}(r),d=Math.abs(i.top-i.bottom);for(let e of i.positionedLines)d-=e.lineOffset;let p=i.positionedLines.length,f=d/p,m=i.top-r[1];for(let e=0;e<p;++e){let a=i.positionedLines[e];for(let o of(m=function(e,i,r,a){let n=i+e.positionedLines[a].lineOffset;return 0===a?r+n/2:r+(n+(i+e.positionedLines[a-1].lineOffset))/2}(i,f,m,e),a.positionedGlyphs)){let e,a,d,p;if(!o.rect)continue;let f=o.rect||{},_=4,g=!0,y=1,x=0;if(o.image){let e=s.get(o.image.toString());if(!e)continue;if(e.sdf){tf("SDF images are not supported in formatted text and will be ignored.");continue}g=!1,_=1/(y=e.pixelRatio)}let v=(n||l)&&o.vertical,b=o.metrics.advance*o.scale/2,w=o.metrics,T=o.rect;if(null===T)continue;l&&i.verticalizable&&(x=o.image?b-o.metrics.width*o.scale/2:0);let S=n?[o.x+b,o.y]:[0,0],E=[0,0],I=[0,0],A=!1;n||(v?(I=[o.x+b+c[0],o.y+c[1]-x],A=!0):E=[o.x+b+r[0],o.y+r[1]-x]);let C=T.w*o.scale/(y*(o.localGlyph?2:1)),M=T.h*o.scale/(y*(o.localGlyph?2:1));if(v){let i=o.y-m,r=new e3(-b,b-i),n=-Math.PI/2,s=new e3(...I);(e=new e3(-b+E[0],E[1]))._rotateAround(n,r)._add(s),e.x+=-i+b,e.y-=(w.left-_)*o.scale;let l=o.image?w.advance*o.scale:24*o.scale,h=String.fromCodePoint(o.glyph);"︶"===h||"ï¹"===h||"︸"===h||"ï¹"===h||"ï¹"===h||"︾"===h||"︼"===h||"︺"===h||"ï¸"===h||"ï¹"===h||"ï¸"===h||"ï¸"===h||"ï¸"===h||"ï½"===h||"ï¿£"===h||"ï¸"===h||"ï¸"===h?e.x+=(1-_)*o.scale:"︵"===h||"ï¹"===h||"︷"===h||"ï¹"===h||"ï¹"===h||"︽"===h||"︻"===h||"︹"===h||"ï¸"===h||"︿"===h?e.x+=l-w.height*o.scale+(-_-1)*o.scale:e.x+=o.image||w.width+2*_===T.w&&w.height+2*_===T.h?(l-M)/2:(l-(w.height+2*_)*o.scale)/2,a=new e3(e.x,e.y-C),d=new e3(e.x+M,e.y),p=new e3(e.x+M,e.y-C)}else{let i=(w.left-_)*o.scale-b+E[0],r=(-w.top-_)*o.scale+E[1],n=i+C,s=r+M;e=new e3(i,r),a=new e3(n,r),d=new e3(i,s),p=new e3(n,s)}if(u){let i;i=n?new e3(0,0):A?new e3(c[0],c[1]):new e3(r[0],r[1]),e._rotateAround(u,i),a._rotateAround(u,i),d._rotateAround(u,i),p._rotateAround(u,i)}let P=new e3(0,0),z=new e3(0,0);h.push({tl:e,tr:a,bl:d,br:p,texPrimary:f,texSecondary:void 0,writingMode:i.writingMode,glyphOffset:S,sectionIndex:o.sectionIndex,isSDF:g,pixelOffsetTL:P,pixelOffsetBR:z,minFontScaleX:0,minFontScaleY:0})}}return h}(0,a,h,o,s,l,n,e.allowVerticalPlacement),v=e.textSizeData,b=null;for(let a of("source"===v.kind?(b=[128*o.layout.get("text-size").evaluate(l,{},g)*m.textScaleFactor])[0]>32640&&tf(`${e.layerIds[0]}: Value for "text-size" is >= 255. Reduce your "text-size".`):"composite"===v.kind&&((b=[128*m.compositeTextSizes[0].evaluate(l,{},g)*m.textScaleFactor,128*m.compositeTextSizes[1].evaluate(l,{},g)*m.textScaleFactor])[0]>32640||b[1]>32640)&&tf(`${e.layerIds[0]}: Value for "text-size" is >= 255. Reduce your "text-size".`),e.addSymbols(e.text,x,b,h,s,l,c,i,r,u.lineStartIndex,u.lineLength,f,_,g,y,!1),d))p[a]=e.text.placedSymbolArray.length-1;return 4*x.length}function pb(e){for(let i in e)return e[i];return null}function pw(e,i,r,a,n,o,s,l,h,u){let c=s.top,d=s.bottom,p=s.left,f=s.right;if(dW(s)&&s.collisionPadding){let e=s.collisionPadding;p-=e[0],c-=e[1],f+=e[2],d+=e[3]}if(h){let e=new e3(p,c),i=new e3(f,c),r=new e3(p,d),a=new e3(f,d),n=h*e4,o=new e3(0,0);u&&(o=new e3(u[0],u[1])),e._rotateAround(n,o),i._rotateAround(n,o),r._rotateAround(n,o),a._rotateAround(n,o),p=Math.min(e.x,i.x,r.x,a.x),f=Math.max(e.x,i.x,r.x,a.x),c=Math.min(e.y,i.y,r.y,a.y),d=Math.max(e.y,i.y,r.y,a.y)}return e.emplaceBack(i.x,i.y,i.z,r.x,r.y,p,c,f,d,l,a,n,o),e.length-1}function pT(e){dW(e)&&e.collisionPadding&&(e.top-=e.collisionPadding[1],e.bottom+=e.collisionPadding[3]);let i=e.bottom-e.top;return i>0?Math.max(10,i):null}function pS(e,i){let r=e.fovAboveCenter,a=e.elevation?e.elevation.getMinElevationBelowMSL()*i:0,n=(e._camera.position[2]*e.worldSize-a)/Math.cos(e._pitch),o=Math.sin(r)*n/Math.sin(Math.max(Math.PI/2-e._pitch-r,.01)),s=Math.sin(e._pitch)*o+n,l=n*(1/e._horizonShift);if(!e.elevation||0===e.elevation.exaggeration()){let i=Math.max(e.zoom-17,0);e.isOrthographic&&(i/=10),s*=1+i}return Math.min(1.01*s,l)}function pE(e,i){if(!i.isReprojectedInTileSpace)return{scale:1<<e.z,x:e.x,y:e.y,x2:e.x+1,y2:e.y+1,projection:i};let r=Math.pow(2,-e.z),a=e.x*r,n=(e.x+1)*r,o=e.y*r,s=(e.y+1)*r,l=sG(a),h=sG(n),u=sq(o),c=sq(s),d=i.project(l,u),p=i.project(h,u),f=i.project(h,c),m=i.project(l,c),_=Math.min(d.x,p.x,f.x,m.x),g=Math.min(d.y,p.y,f.y,m.y),y=Math.max(d.x,p.x,f.x,m.x),x=Math.max(d.y,p.y,f.y,m.y),v=r/16;function b(e,r,a,n,o,s){let l=(a+o)/2,h=(n+s)/2,u=i.project(sG(l),sq(h)),c=Math.max(0,_-u.x,g-u.y,u.x-y,u.y-x);_=Math.min(_,u.x),y=Math.max(y,u.x),g=Math.min(g,u.y),x=Math.max(x,u.y),c>v&&(b(e,u,a,n,l,h),b(u,r,l,h,o,s))}b(d,p,a,o,n,o),b(p,f,n,o,n,s),b(f,m,n,s,a,s),b(m,d,a,s,a,o),_-=v,g-=v,y+=v,x+=v;let w=1/Math.max(y-_,x-g);return{scale:w,x:_*w,y:g*w,x2:y*w,y2:x*w,projection:i}}function pI(e,{x:i,y:r},a=0){return new e3(((i-a)*e.scale-e.x)*8192,(r*e.scale-e.y)*8192)}let pA=ee(new Float32Array(16));class pC{constructor(e){this.spec=e,this.name=e.name,this.wrap=!1,this.requiresDraping=!1,this.supportsWorldCopies=!1,this.supportsTerrain=!1,this.supportsFog=!1,this.supportsFreeCamera=!1,this.zAxisUnit="meters",this.isReprojectedInTileSpace=!0,this.unsupportedLayers=["custom"],this.center=[0,0],this.range=[3.5,7]}project(e,i){return{x:0,y:0,z:0}}unproject(e,i){return new sB(0,0)}projectTilePoint(e,i,r){return{x:e,y:i,z:0}}locationPoint(e,i,r,a=!0){return e._coordinatePoint(e.locationCoordinate(i,r),a)}pixelsPerMeter(e,i){return 1/sV(e)*i}pixelSpaceConversion(e,i,r){return 1}farthestPixelDistance(e){return pS(e,e.pixelsPerMeter)}pointCoordinate(e,i,r,a){let n=new e3(i,Math.max(e.horizonLineFromTop(!1),r));return e.rayIntersectionCoordinate(e.pointRayIntersection(n,a))}pointCoordinate3D(e,i,r){let a=new e3(i,r);if(e.elevation)return e.elevation.pointCoordinate(a);{let i=this.pointCoordinate(e,a.x,a.y,0);return[i.x,i.y,i.z]}}isPointAboveHorizon(e,i){if(e.elevation&&e.elevation.visibleDemTiles.length)return!this.pointCoordinate3D(e,i.x,i.y);let r=e.horizonLineFromTop();return i.y<r}createInversionMatrix(e,i){return pA}createTileMatrix(e,i,r){let a,n,o,s=r.canonical,l=ee(new Float64Array(16));if(this.isReprojectedInTileSpace){let h=pE(s,this);a=1,n=h.x+r.wrap*h.scale,o=h.y,ea(l,l,[a/h.scale,a/h.scale,e.pixelsPerMeter/i])}else a=i/e.zoomScale(s.z),n=(s.x+Math.pow(2,s.z)*r.wrap)*a,o=s.y*a;return er(l,l,[n,o,0]),ea(l,l,[a/8192,a/8192,1]),l}upVector(e,i,r){return[0,0,1]}upVectorScale(e,i,r){return{metersToTile:1}}}class pM extends pC{constructor(e){super(e),this.range=[4,7],this.center=e.center||[-96,37.5];let[i,r]=this.parallels=e.parallels||[29.5,45.5],a=Math.sin(i*e4);this.n=(a+Math.sin(r*e4))/2,this.c=1+a*(2*this.n-a),this.r0=Math.sqrt(this.c)/this.n}project(e,i){let{n:r,c:a,r0:n}=this,o=(e-this.center[0])*e4,s=Math.sqrt(a-2*r*Math.sin(i*e4))/r;return{x:s*Math.sin(o*r),y:s*Math.cos(o*r)-n,z:0}}unproject(e,i){let{n:r,c:a,r0:n}=this,o=n+i,s=Math.atan2(e,Math.abs(o))*Math.sign(o);o*r<0&&(s-=Math.PI*Math.sign(e)*Math.sign(o));let l=this.center[0]*e4*r,h=tt((s=tr(s,-Math.PI-l,Math.PI-l))/r*e6+this.center[0],-180,180),u=Math.asin(tt((a-(e*e+o*o)*r*r)/(2*r),-1,1));return new sB(h,tt(u*e6,-85.051129,85.051129))}}let pP=Math.sqrt(3)/2;class pz extends pC{project(e,i){i=i/180*Math.PI,e=e/180*Math.PI;let r=Math.asin(pP*Math.sin(i)),a=r*r,n=a*a*a;return{x:.5*(e*Math.cos(r)/(pP*(1.340264+-.24331799999999998*a+n*(.0062510000000000005+.034164*a)))/M
7ath.PI+.5),y:1-.5*(r*(1.340264+-.081106*a+n*(893e-6+.003796*a))/Math.PI+1),z:0}}unproject(e,i){e=(2*e-.5)*Math.PI;let r=i=(2*(1-i)-1)*Math.PI,a=r*r,n=a*a*a;for(let e,o,s=0;s<12&&(o=r*(1.340264+-.081106*a+n*(893e-6+.003796*a))-i,n=(a=(r=tt(r-(e=o/(1.340264+-.24331799999999998*a+n*(.0062510000000000005+.034164*a))),-Math.PI/3,Math.PI/3))*r)*a*a,!(1e-12>Math.abs(e)));++s);let o=pP*e*(1.340264+-.24331799999999998*a+n*(.0062510000000000005+.034164*a))/Math.cos(r),s=Math.asin(Math.sin(r)/pP);return new sB(tt(180*o/Math.PI,-180,180),tt(180*s/Math.PI,-85.051129,85.051129))}}class pR extends pC{constructor(e){super(e),this.wrap=!0,this.supportsWorldCopies=!0}project(e,i){return{x:.5+e/360,y:.5-i/360,z:0}}unproject(e,i){return new sB(360*(e-.5),tt(360*(.5-i),-85.051129,85.051129))}}let pD=Math.PI/2;function pL(e){return Math.tan((pD+e)/2)}class pO extends pC{constructor(e){super(e),this.center=e.center||[0,30];let[i,r]=this.parallels=e.parallels||[30,30],a=i*e4,n=r*e4;this.southernCenter=a+n<0,this.southernCenter&&(a=-a,n=-n);let o=Math.cos(a),s=pL(a);this.n=a===n?Math.sin(a):Math.log(o/Math.cos(n))/Math.log(pL(n)/s),this.f=o*Math.pow(pL(a),this.n)/this.n}project(e,i){i*=e4,this.southernCenter&&(i=-i),e=(e-this.center[0])*e4;let{n:r,f:a}=this;a>0?i<-pD+1e-6&&(i=-pD+1e-6):i>pD-1e-6&&(i=pD-1e-6);let n=a/Math.pow(pL(i),r),o=n*Math.sin(r*e),s=a-n*Math.cos(r*e);return o=.5*(o/Math.PI+.5),s=.5*(s/Math.PI+.5),{x:o,y:this.southernCenter?s:1-s,z:0}}unproject(e,i){e=(2*e-.5)*Math.PI,this.southernCenter&&(i=1-i);let{n:r,f:a}=this,n=a-(i=(2*(1-i)-.5)*Math.PI),o=Math.sign(n),s=Math.sign(r)*Math.sqrt(e*e+n*n),l=Math.atan2(e,Math.abs(n))*o;n*r<0&&(l-=Math.PI*Math.sign(e)*o);let h=tt(l/r*e6+this.center[0],-180,180),u=tt((2*Math.atan(Math.pow(a/s,1/r))-pD)*e6,-85.051129,85.051129);return new sB(h,this.southernCenter?-u:u)}}class pF extends pC{constructor(e){super(e),this.wrap=!0,this.supportsWorldCopies=!0,this.supportsTerrain=!0,this.supportsFog=!0,this.supportsFreeCamera=!0,this.isReprojectedInTileSpace=!1,this.unsupportedLayers=[],this.range=null}project(e,i){return{x:sU(e),y:sj(i),z:0}}unproject(e,i){return new sB(sG(e),sq(i))}}let pk=85.051129*e4;class pB extends pC{project(e,i){let r=(i*=e4)*i,a=r*r;return{x:.5*((e*=e4)*(.8707-.131979*r+a*(a*(.003971*r-.001529*a)-.013791))/Math.PI+.5),y:1-.5*(i*(1.007226+r*(.015085+a*(.028874*r-.044475-.005916*a)))/Math.PI+1),z:0}}unproject(e,i){e=(2*e-.5)*Math.PI;let r=i=(2*(1-i)-1)*Math.PI,a=25,n=0,o=r*r;do{let e=(o=r*r)*o;n=(r*(1.007226+o*(.015085+e*(.028874*o-.044475-.005916*e)))-i)/(1.007226+o*(.045255+e*(.259866*o-.311325-.005916*11*e))),r=tt(r-n,-pk,pk)}while(Math.abs(n)>1e-6&&--a>0);return new sB(tt(e/(.8707+(o=r*r)*(o*(o*o*o*(.003971-.001529*o)-.013791)-.131979))*e6,-180,180),r*e6)}}let pN=85.051129*e4;class pV extends pC{project(e,i){i*=e4,e*=e4;let r=Math.cos(i),a=Math.acos(r*Math.cos(e/2)),n=Math.sin(a)/a;return{x:.5*((.5*(2/Math.PI*e+2*r*Math.sin(e/2)/n)||0)/Math.PI+.5),y:1-.5*((.5*(i+Math.sin(i)/n)||0)/Math.PI+1),z:0}}unproject(e,i){let r=e=(2*e-.5)*Math.PI,a=i=(2*(1-i)-1)*Math.PI,n=25,o=0,s=0;do{let n=Math.cos(a),l=Math.sin(a),h=2*l*n,u=l*l,c=n*n,d=Math.cos(r/2),p=Math.sin(r/2),f=2*d*p,m=p*p,_=1-c*d*d,g=_?1/_:0,y=_?Math.acos(n*d)*Math.sqrt(1/_):0,x=.5*(2*y*n*p+2*r/Math.PI)-e,v=.5*(y*l+a)-i,b=.5*g*(c*m+y*n*d*u)+1/Math.PI,w=g*(f*h/4-y*l*p),T=.125*g*(h*p-y*l*c*f),S=.5*g*(u*d+y*m*n)+.5,E=w*T-S*b;o=(v*w-x*S)/E,s=(x*T-v*b)/E,r=tt(r-o,-Math.PI,Math.PI),a=tt(a-s,-pN,pN)}while((Math.abs(o)>1e-6||Math.abs(s)>1e-6)&&--n>0);return new sB(r*e6,a*e6)}}class pU extends pC{constructor(e){super(e),this.center=e.center||[0,0],this.parallels=e.parallels||[0,0],this.cosPhi=Math.max(.01,Math.cos(this.parallels[0]*e4)),this.scale=1/(2*Math.max(Math.PI*this.cosPhi,1/this.cosPhi)),this.wrap=!0,this.supportsWorldCopies=!0}project(e,i){let{scale:r,cosPhi:a}=this;return{x:e*e4*a*r+.5,y:-Math.sin(i*e4)/a*r+.5,z:0}}unproject(e,i){let{scale:r,cosPhi:a}=this,n=tt((e-.5)/r*e6/a,-180,180),o=Math.asin(tt(-(i-.5)/r*a,-1,1));return new sB(n,tt(o*e6,-85.051129,85.051129))}}class pj extends pF{constructor(e){super(e),this.requiresDraping=!0,this.supportsWorldCopies=!1,this.supportsFog=!0,this.zAxisUnit="pixels",this.unsupportedLayers=["debug"],this.range=[3,5]}projectTilePoint(e,i,r){let a=l0(e,i,r);return eP(a,a,l3(lW(r))),{x:a[0],y:a[1],z:a[2]}}locationPoint(e,i,r){let a=sF(i.lat,i.lng),n=eI([],a),o=r?e._centerAltitude+r:e.elevation?e.elevation.getAtPointOrZero(e.locationCoordinate(i),e._centerAltitude):e._centerAltitude;ew(a,a,n,1/sV(0)*8192*o);let s=ee(new Float64Array(16));
7return ei(s,e.pixelMatrix,e.globeMatrix),eP(a,a,s),new e3(a[0],a[1])}pixelsPerMeter(e,i){return 1/sV(0)*i}pixelSpaceConversion(e,i,r){let a=1/sV(e)*i,n=ip(1/sV(45)*i,a,r);return this.pixelsPerMeter(e,i)/n}createTileMatrix(e,i,r){let a=l5(lW(r.canonical));return ei(new Float64Array(16),e.globeMatrix,a)}createInversionMatrix(e,i){let{center:r}=e,a=l3(lW(i));return eo(a,a,r.lng*e4),en(a,a,r.lat*e4),ea(a,a,[e._pixelsPerMercatorPixel,e._pixelsPerMercatorPixel,1]),Float32Array.from(a)}pointCoordinate(e,i,r,a){return l$(e,i,r,!0)||new sY(0,0)}pointCoordinate3D(e,i,r){let a=this.pointCoordinate(e,i,r,0);return[a.x,a.y,a.z]}isPointAboveHorizon(e,i){return!l$(e,i.x,i.y,!1)}farthestPixelDistance(e){let i=function(e,i){let r,a=e.cameraToCenterDistance,n=e._centerAltitude*i,o=e._camera,s=e._camera.forward(),l=e_([],eb([],s,-a),[0,0,n]),h=e.worldSize/(2*Math.PI),u=[0,0,-h],c=e.width/e.height,d=Math.tan(e.fovAboveCenter),p=eb([],o.up(),d),f=eb([],o.right(),d*c),m=eI([],e_([],e_([],s,p),f)),_=[];if(new ln(l,m).closestPointOnSphere(u,h,_)){let i=eg([],e_([],_,u),l);r=Math.cos(e.fovAboveCenter)*ep(i)}else{let e=eg([],l,u),i=eg([],u,l);eI(i,i);let a=ep(e)-h,n=Math.acos((r=Math.sqrt(a*(a+2*h)))/(h+a))-Math.acos(eA(s,i));r*=Math.cos(n)}return 1.01*r}(e,this.pixelsPerMeter(e.center.lat,e.worldSize)),r=l9(e.zoom);if(r>0){let a=pS(e,1/sV(e.center.lat)*e.worldSize);return ip(i,a+e.worldSize/(2*Math.PI)*(1-Math.cos(Math.max(e.width,e.height)/e.worldSize*Math.PI)),Math.pow(r,10))}return i}upVector(e,i,r){return l0(i,r,e,1)}upVectorScale(e){return{metersToTile:lG(l1(lW(e)))}}}function pG(e){let i=e.parallels,r=!!i&&.01>Math.abs(i[0]+i[1]);switch(e.name){case"mercator":return new pF(e);case"equirectangular":return new pR(e);case"naturalEarth":return new pB(e);case"equalEarth":return new pz(e);case"winkelTripel":return new pV(e);case"albers":return r?new pU(e):new pM(e);case"lambertConformalConic":return r?new pU(e):new pO(e);case"globe":return new pj(e)}throw Error(`Invalid projection name: ${e.name}`)}let pq=s1.types,p$=[{name:"a_fade_opacity",components:1,type:"Uint8",offset:0}];function pH(e,i,r,a,n,o,s,l,h,u,c,d,p){let f=l?Math.min(32640,Math.round(l[0])):0,m=l?Math.min(32640,Math.round(l[1])):0;e.emplaceBack(i,r,Math.round(32*a),Math.round(32*n),o,s,(f<<1)+ +!!h,m,16*u,16*c,256*d,256*p)}function pZ(e,i,r){e.emplaceBack(i,r)}function pW(e,i,r,a,n,o,s){e.emplaceBack(i,r,a,n,o,s)}let pX=(e,i,r,a)=>{for(let n=0;n<i;n++)e.emplaceBack(r[0],r[1],r[2],a[0],a[1],a[2])};function pY(e,i,r,a,n){e.emplaceBack(i,r,a,n),e.emplaceBack(i,r,a,n),e.emplaceBack(i,r,a,n),e.emplaceBack(i,r,a,n)}class pK{constructor(e){this.layoutVertexArray=new oS,this.indexArray=new oD,this.programConfigurations=e,this.segments=new se,this.dynamicLayoutVertexArray=new oI,this.opacityVertexArray=new oA,this.placedSymbolArray=new oK,this.iconTransitioningVertexArray=new oC,this.globeExtVertexArray=new oE,this.zOffsetVertexArray=new om,this.orientationVertexArray=new oF}isEmpty(){return 0===this.layoutVertexArray.length&&0===this.indexArray.length&&0===this.dynamicLayoutVertexArray.length&&0===this.opacityVertexArray.length&&0===this.iconTransitioningVertexArray.length}upload(e,i,r,a,n){this.isEmpty()||(r&&(this.layoutVertexBuffer=e.createVertexBuffer(this.layoutVertexArray,dc.members),this.indexBuffer=e.createIndexBuffer(this.indexArray,i),this.dynamicLayoutVertexBuffer=e.createVertexBuffer(this.dynamicLayoutVertexArray,dp.members,!0),this.opacityVertexBuffer=e.createVertexBuffer(this.opacityVertexArray,p$,!0),this.iconTransitioningVertexArray.length>0&&(this.iconTransitioningVertexBuffer=e.createVertexBuffer(this.iconTransitioningVertexArray,d_.members,!0)),this.globeExtVertexArray.length>0&&(this.globeExtVertexBuffer=e.createVertexBuffer(this.globeExtVertexArray,dd.members,!0)),!this.zOffsetVertexBuffer&&(this.zOffsetVertexArray.length>0||n)&&(this.zOffsetVertexBuffer=e.createVertexBuffer(this.zOffsetVertexArray,df.members,!0)),!this.orientationVertexBuffer&&this.orientationVertexArray&&this.orientationVertexArray.length>0&&(this.orientationVertexBuffer=e.createVertexBuffer(this.orientationVertexArray,dm.members,!0)),this.opacityVertexBuffer.itemSize=1),(r||a)&&this.programConfigurations.upload(e))}destroy(){this.layoutVertexBuffer&&(this.layoutVertexBuffer.destroy(),this.indexBuffer.destroy(),this.programConfigurations.destroy(),this.segments.destroy(),this.dynamicLayoutVertexBuffer.destroy(),this.opacityVertexBuffer.destroy(),this.iconTransitioningVertexBuffer&&this.iconTransitioningVertexBuffer.destroy(),this.globeExtVertexBuffer&&this.globeExtVertexBuffer.destroy(),this.zOffsetVertexBuffer&&this.zOffsetVertexBuffer.destroy(),this.orientationVertexBuffer&&this.orientationVertexBuffer.destroy())}}a3(pK,"SymbolBuffers");class pJ{constructor(e,i,r){this.layoutVertexArray=new e,this.layoutAttributes=i,this.indexArray=new r,this.segments=new se,this.collisionVertexArray=new oR,this.collisionVertexArrayExt=new oI}upload(e){this.layoutVertexBuffer=e.createVertexBuffer(this.layoutVertexArray,this.layoutAttributes),this.indexBuffer=e.createIndexBuffer(this.indexArray),this.collisionVertexBuffer=e.createVertexBuffer(this.collisionVertexArray,dg.members,!0),this.collisionVertexBufferExt=e.createVertexBuffer(this.collisionVertexArrayExt,dy.members,!0)}destroy(){this.layoutVertexBuffer&&(this.layoutVertexBuffer.destroy(),this.indexBuffer.destroy(),this.segments.destroy(),this.collisionVertexBuffer.destroy(),this.collisionVertexBufferExt.de
7stroy())}}a3(pJ,"CollisionBuffers");class pQ{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=ee([]),this.placementViewportMatrix=ee([]);let i=this.layers[0]._unevaluatedLayout._values;this.worldview=e.worldview,this.textSizeData=dQ(this.zoom,i["text-size"],this.worldview),this.iconSizeData=dQ(this.zoom,i["icon-size"],this.worldview);let r=this.layers[0].layout,a=r.get("symbol-sort-key"),n=r.get("symbol-z-order");this.lut=e.lut,this.canOverlap=r.get("text-allow-overlap")||r.get("icon-allow-overlap")||r.get("text-ignore-placement")||r.get("icon-ignore-placement"),this.sortFeaturesByKey="viewport-y"!==n&&void 0!==a.constantOr(1),this.sortFeaturesByY=("viewport-y"===n||"auto"===n&&!this.sortFeaturesByKey)&&this.canOverlap,this.writingModes=r.get("text-writing-mode").map(e=>dk[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}createArrays(){this.text=new pK(new sA(this.layers,{zoom:this.zoom,lut:this.lut},e=>e.startsWith("text")||e.startsWith("symbol"))),this.icon=new pK(new sA(this.layers,{zoom:this.zoom,lut:this.lut},e=>e.startsWith("icon")||e.startsWith("symbol"))),this.glyphOffsetArray=new o0,this.lineVertexArray=new o1,this.symbolInstances=new oQ}calculateGlyphDependencies(e,i,r,a,n){for(let r of e){let e=r.codePointAt(0);if(void 0===e)break;if(i[e]=!0,a&&n&&e<=65535){let e=db[r];e&&(i[e.charCodeAt(0)]=!0)}}}updateFootprints(e,i){}updateReplacement(e,i){if(i.updateTime===this.replacementUpdateTime)return!1;this.replacementUpdateTime=i.updateTime;let r=i.getReplacementRegionsForTile(e.toUnwrapped(),!0);return!us(this.activeReplacements,r)&&(this.activeReplacements=r,!0)}populate(e,i,r,a){let n=this.layers[0],o=n.layout,s="globe"===this.projection.name,l=o.get("text-font"),h=o.get("text-field"),u=o.get("icon-image"),[c,d]=o.get("icon-size-scale-range"),p=tt(i.scaleFactor||1,c,d),f=("constant"!==h.value.kind||h.value.value instanceof iB&&!h.value.value.isEmpty()||h.value.value.toString().length>0)&&("constant"!==l.value.kind||l.value.value.length>0),m="constant"!==u.value.kind||!!u.value.value||Object.keys(u.parameters).length>0,_=o.get("symbol-sort-key");if(this.features=[],!f&&!m)return;let g=i.iconDependencies,y=i.glyphDependencies,x=i.availableImages,v=new nV(this.zoom,{worldview:this.worldview});for(let{feature:i,id:h,index:u,sourceLayerIndex:c}of e){let e,d,b=n._featureFilter.needGeometry,w=s0(i,b);if(!n._featureFilter.filter(v,w,r))continue;if(b||(w.geometry=sQ(i,r,a)),s&&1!==i.type&&r.z<=5){let e=w.geometry,i=(e,i)=>.98078528056>eA(l0(e.x,e.y,r,1),l0(i.x,i.y,r,1));for(let r=0;r<e.length;r++)e[r]=function(e,i){let r=e[0],a=[r];for(let n=1;n<e.length;n++){let o=e[n];(function e(i,r,a,n){if(n(r,a)){let o=r.add(a)._mult(.5);e(i,r,o,n),e(i,o,a,n)}else i.push(a)})(a,r,o,i),r=o}return a}(e[r],i)}if(f){let i=n.getValueAndResolveTokens("text-field",w,r,x),a=iB.factory(i);(function(e){for(let i of e.sections)if(function(e){for(let i of e)if(nM(i.charCodeAt(0)))return!0;return!1}(i.text))return!0;return!1})(a)&&(this.hasRTLText=!0),(!this.hasRTLText||"unavailable"===nk()||this.hasRTLText&&nN.isParsed())&&(e=function(e,i,r){return e.sections.forEach(e=>{e.text=function(e,i,r){let a=i.layout.get("text-transform").evaluate(r,{});return"uppercase"===a?e=e.toLocaleUpperCase():"lowercase"===a&&(e=e.toLocaleLowerCase()),nN.applyArabicShaping&&(e=nN.applyArabicShaping(e)),e}(e.text,i,r)}),e}(a,n,w))}if(m){let e=n.getValueAndResolveTokens("icon-image",w,r,x);
7d="string"==typeof e?iV.build(e):e}if(!e&&!d)continue;let T=this.sortFeaturesByKey?_.evaluate(w,{},r):void 0,S={id:h,text:e,icon:d,index:u,sourceLayerIndex:c,geometry:w.geometry,properties:i.properties,type:pq[i.type],sortKey:T};if(this.features.push(S),d){let e=this.layers[0]._unevaluatedLayout._values,{iconPrimary:i,iconSecondary:a}=p_(d,this.iconSizeData,e["icon-size"],r,this.zoom,S,this.pixelRatio,p,this.worldview),n=i.id.toString();if(g.has(n)?g.get(n).push(i):g.set(n,[i]),a){this.hasAnySecondaryIcon=!0;let e=a.id.toString();g.has(e)?g.get(e).push(a):g.set(e,[a])}}if(e){let i=l.evaluate(w,{},r).join(","),a="map"===o.get("text-rotation-alignment")&&"point"!==o.get("symbol-placement");for(let r of(this.allowVerticalPlacement=this.writingModes&&this.writingModes.indexOf(dk.vertical)>=0,e.sections))if(r.image){let e=r.image.getPrimary().scaleSelf(this.pixelRatio),i=e.id.toString(),a=g.get(i)||[];a.push(e),g.set(i,a)}else{let n=nI(e.toString()),o=r.fontStack||i,s=y[o]=y[o]||{};this.calculateGlyphDependencies(r.text,s,a,this.allowVerticalPlacement,n)}}}if("line"===o.get("symbol-placement")&&(this.features=function(e){let i={},r={},a=[],n=0;function o(i){a.push(e[i]),n++}function s(e,i,n){let o=r[e];return delete r[e],r[i]=o,a[o].geometry[0].pop(),a[o].geometry[0]=a[o].geometry[0].concat(n[0]),o}function l(e,r,n){let o=i[r];return delete i[r],i[e]=o,a[o].geometry[0].shift(),a[o].geometry[0]=n[0].concat(a[o].geometry[0]),o}function h(e,i,r){let a=r?i[0][i[0].length-1]:i[0][0];return`${e}:${a.x}:${a.y}`}for(let u=0;u<e.length;u++){let c=e[u],d=c.geometry,p=c.text?c.text.toString():null;if(!p){o(u);continue}let f=h(p,d),m=h(p,d,!0);if(f in r&&m in i&&r[f]!==i[m]){let e=l(f,m,d),n=s(f,m,a[e].geometry);delete i[f],delete r[m],r[h(p,a[n].geometry,!0)]=n,a[e].geometry=null}else f in r?s(f,m,d):m in i?l(f,m,d):(o(u),i[f]=n-1,r[m]=n-1)}return a.filter(e=>e.geometry)}(this.features)),"hd-road-markup"===o.get("symbol-elevation-reference")){if(this.elevationType="road",i.elevationFeatures)for(let e of(!this.elevationFeatures&&i.elevationFeatures.length>0&&(this.elevationFeatures=[],this.elevationFeatureIdToIndex=new Map),i.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,i)=>e.sortKey-i.sortKey)}update(e,i,r,a,n,o,s){this.text.programConfigurations.updatePaintArrays(e,i,n,r,a,o,s,this.worldview),this.icon.programConfigurations.updatePaintArrays(e,i,n,r,a,o,s,this.worldview)}updateRoadElevation(e){if("road"!==this.elevationType||!this.elevationFeatures||this.elevationStateComplete)return;this.elevationStateComplete=!0,this.hasAnyZOffset=!1;let i=!1,r=sX(e),a=1/r,n=!1,o=!1;for(let e=0;e<this.symbolInstances.length;e++){let s=this.symbolInstances.get(e),l=ef(1,0,0),h=ef(0,1,0),{numHorizontalGlyphVertices:u,numVerticalGlyphVertices:c,numIconVertices:d,numVerticalIconVertices:p}=s,f=u>0||c>0,m=d>0,_=this.elevationFeatures[s.elevationFeatureIndex];if(_){let e=new e3(s.tileAnchorX,s.tileAnchorY),u=.075+_.pointElevation(e);s.zOffset!==u&&(i=!0,s.zOffset=u);let c=_.computeSlopeNormal(e,a),d=eH(eN(),ef(0,0,1),c);eR(l,l,d),eR(h,h,d),l[2]*=r,h[2]*=r,1===l[0]&&0===l[1]&&0===l[2]&&0===h[0]&&1===h[1]&&0===h[2]||(n=n||f,o=o||m)}if(f&&(pX(this.text.orientationVertexArray,u,l,h),pX(this.text.orientationVertexArray,c,l,h)),m){let{placedIconSymbolIndex:e,verticalPlacedIconSymbolIndex:i}=s;e>=0&&pX(this.icon.orientationVertexArray,d,l,h),i>=0&&pX(this.icon.orientationVertexArray,p,l,h)}}n||(this.text.orientationVertexArray=void 0),o||(this.icon.orientationVertexArray=void 0),i&&(this.zOffsetBuffersNeedUpload=!0,this.zOffsetSortDirty=!0)}updateZOffset(){let e=(e,i,a)=>{(r+=i)>e.length&&e.resize(r);for(let n=-i;n<0;n++)e.emplace(n+r,a)},i=(e,i,r)=>{(a+=i)>e.length&&e.resize(a);for(let n=-i;n<0;n++)e.emplace(n+a,r)};if(!this.zOffsetBuffersNeedUpload)return;this.zOffsetBuffersNeedUpload=!1;let r=0,a=0;for(let r=0;r<this.symbolInstances.length;r++){let a=this.symbolInstances.get(r),{numHorizontalGlyphVertices:n,numVerticalGlyphVertices:o,numIconVertices:s}=a,l=a.zOffset,h=s>0;if((n>0||o>0)&&(e(this.text.zOffsetVertexArray,n,l),e(this.text.zOffsetVertexArray,o,l)),h){let{placedIconSymbolIndex:e,verticalPlacedIconSymbolIndex:r}=a;e>=0&&i(this.icon.zOffsetVertexArray,s,l),r>=0&&i(this.icon.zOffsetVertexArray,a.numVerticalIconVertices,l)}}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){!this.uploaded&&this.hasDebugData()&&(this.textCollisionBox.upload(e),this.iconCollisionBox.upload(e)),this.text.upload(e,this.sortFeaturesByY,!this.uploaded,this.text.programConfigurations.needsUpload,this.zOffsetBuffersNeedUpload),this.icon.upload(e,this.sortFeaturesByY,!this.uploaded,this.icon.programConfigurations.needsUpload,this.zOffsetBuffersNeedUpload),this.uploaded=!0}destroyDebugData(){this.textCollisionBox.destroy(),this.iconCollisionBox.destroy()}getProjection(){return this.projectionInstance||(this.projectionInstance=pG(this.projection)),this.projectionInstance}destroy(){this.text.destroy(),this.icon.destroy(),this.hasDebugData()&&this.destroyDebugData()}addToLineVertexArray(e,i){let r=this.lineVertexArray.length;if(void 0!==e.segment)for(let{x:e,y:r}of i)this.lineVertexArray.emplaceBack(e,r);return{lineStartIndex:r,lineLength:this.lineVertexArray.length-r}}addSymbols(e,i,r,a,n,o,s,l,h,u,c,d,p,f,m,_){let g=e.indexArray,y=e.layoutVertexArray,x=e.globeExtVertexArray,v=e.segments.prepareSegment(4*i.length,y,g,this.canOverlap?o.sortKey:void 0),b=this.glyphOffsetArray.length,w=v.vertexLength,T=this.allowVerticalPlacement&&s===dk.vertical?Math.PI/2:0,S=o.text&&o.text.sections;for(let a=0;a<i.length;a++){let{tl:n,tr:s,bl:u,br:c,texPrimary:d,texSecondary:b,pixelOffsetTL:w,pixelOffsetBR:E,minFontScaleX:I,minFontScaleY:A,glyphOffset:C,isSDF:M,sectionIndex:P}=i[a],z=v.vertexLength,R=C[1];if(pH(y,h.x,h.y,n.x,R+n.y,d.x,d.y,r,M,w.x,w.y,I,A),pH(y,h.x,h.y,s.x,R+s.y,d.x+d.w,d.y,r,M,E.x,w.y,I,A),pH(y,h.x,h.y,u.x,R+u.y,d.x,d.y+d.h,r,M,w.x,E.y,I,A),pH(y,h.x,h.y,c.x,R+c.y,d.x+d.w,d.y+d.h,r,M,E.x,E.y,I,A),l){let{x:i,y:r,z:a}=l.anchor,[n,o,s]=l.up;pW(x,i,r,a,n,o,s),pW(x,i,r,a,n,o,s),pW(x,i,r,a,n,o,s),pW(x,i,r,a,n,o,s),pY(e.dynamicLayoutVertexArray,i,r,a,T)}else pY(e.dynamicLayoutVertexArray,h.x,h.y,h.z,T);if(_){let i=b||d;pZ(e.iconTransitioningVertexArray,i.x,i.y),pZ(e.iconTransitioningVertexArray,i.x+i.w,i.y),pZ(e.iconTransitioningVertexArray,i.x,i.y+i.h),pZ(e.iconTransitioningVertexArray,i.x+i.w,i.y+i.h)}g.emplaceBack(z,z+1,z+2),g.emplaceBack(z+1,z+2,z+3),v.vertexLength+=4,v.primitiveLength+=2,this.glyphOffsetArray.emplaceBack(C[0]),a!==i.length-1&&P===i[a+1].sectionIndex||e.programConfigurations.populatePaintArrays(y.length,o,o.index,{},p,f,m,S&&S[P],this.worldview)}let E=l?l.anchor:h;e.placedSymbolArray.emplaceBack(E.x,E.y,E.z,h.x,h.y,b,this.glyphOffsetArray.length-b,w,u,c,h.segment,r?r[0]:0,r?r[1]:0,a[0],a[1],s,0,0,0,d,0)}_commitLayoutVertex(e,i,r,a,n,o,s){e.emplaceBack(i,r,a,n,o,Math.round(s.x),Math.round(s.y))}_addCollisionDebugVertices(e,i,r,a,n,o,s){let l=r.segments.prepareSegment(4,r.layoutVertexArray,r.indexArray),h=l.vertexLength,u=s.tileAnchorX,c=s.tileAnchorY;for(let e=0;e<4;e++)r.collisionVertexArray.emplaceBack(0,0,0,0,0,0);this._commitDebugCollisionVertexUpdate(r.collisionVertexArrayExt,i,e.padding,s.zOffset),this._commitLayoutVertex(r.layoutVertexArray,a,n,o,u,c,new e3(e.x1,e.y1)),this._commitLayoutVertex(r.layoutVertexArray,a,n,o,u,c,new e3(e.x2,e.y1)),this._commitLayoutVertex(r.layoutVertexArray,a,n,o,u,c,new e3(e.x2,e.y2)),this._commitLayoutVertex(r.layoutVertexArray,a,n,o,u,c,new e3(e.x1,e.y2)),l.vertexLength+=4;let d=r.indexArray;d.emplaceBack(h,h+1),d.emplaceBack(h+1,h+2),d.emplaceBack(h+2,h+3),d.emplaceBack(h+3,h),l.primitiveLength+=4}_addTextDebugCollisionBoxes(e,i,r,a,n,o){for(let s=a;s<n;s++){let a=r.get(s),n=this.getSymbolInstanceTextSize(e,o,i,s);this._addCollisionDebugVertices(a,n,this.textCollisionBox,a.projectedAnchorX,a.projectedAnchorY,a.projectedAnchorZ,o)}}_addIconDebugCollisionBoxes(e,i,r,a,n,o){for(let s=a;s<n;s++){let a=r.get(s),n=this.getSymbolInstanceIconSize(e,i,o.placedIconSymbolIndex);this._addCollisionDebugVertices(a,n,this.iconCollisionBox,a.projectedAnchorX,a.projectedAnchorY,a.projectedAnchorZ,o)}}generateCollisionDebugBuffers(e,i,r){this.hasDebugData()&&this.destroyDebugData(),this.textCollisionBox=new pJ(oP,dx.members,oC),this.iconCollisionBox=new pJ(oP,dx.members,oC);let a=d1(this.iconSizeData,e),n=d1(this.textSizeData,e,r);for(let r=0;r<this.symbolInstances.length;r++){let o=this.symbolInstances.get(r);this._addTextDebugCollisionBoxes(n,e,i,o.textBoxStartIndex,o.textBoxEndIndex,o),this._addTextDebugCollisionBoxes(n,e,i,o.verticalTextBoxStartIndex,o.verticalTextBoxEndIndex,o),this._addIconDebugCollisionBoxes(a,e,i,o.iconBoxStartIndex,o.iconBoxEndIndex,o),this._addIconDebugCollisionBoxes(a,e,i,o.verticalIconBoxStartIndex,o.verticalIconBoxEndIndex,o)}}getSymbolInstanceTextSize(e,i,r,a){let n=this.text.placedSymbolArray.get(i.rightJustifiedTextSymbolIndex>=0?i.rightJustifiedTextSymbolIndex:i.centerJustifiedTextSymbolIndex>=0?i.centerJustifiedTextSymbolIndex:i.leftJustifiedTextSymbolIndex>=0?i.leftJustifiedTextSymbolIndex:i.verticalPlacedTextSymbolIndex>=0?i.verticalPlacedTextSymbolIndex:a),o=d0(this.textSizeData,e,n)/24;return this.tilePixelRatio*o}getSymbolInstanceIconSize(e,i,r){let a=this.icon.placedSymbolArray.get(r),n=d0(this.iconSizeData,e,a);return this.tilePixelRatio*n}_commitDebugCollisionVertexUpdate(e,i,r,a){e.emplaceBack(i,-r,-r,a),e.emplaceBack(i,r,-r,a),e.emplaceBack(i,r,r,a),e.emplaceBack(i,-r,r,a)}_updateTextDebugCollisionBoxes(e,i,r,a,n,o,s){for(let s=a;s<n;s++){let a=r.get(s),n=this.getSymbolInstanceTextSize(e,o,i,s);this._commitDebugCollisionVertexUpdate(this.textCollisionBox.collisionVertexArrayExt,n,a.padding,o.zOffset)}}_updateIconDebugCollisionBoxes(e,i,r,a,n,o,s){for(let s=a;s<n;s++){let a=r.get(s),n=this.getSymbolInstanceIconSize(e,i,o.placedIconSymbolIndex);this._commitDebugCollisionVertexUpdate(this.iconCollisionBox.collisionVertexArrayExt,n,a.padding,o.zOffset)}}updateCollisionDebugBuffers(e,i,r,a){if(!this.hasDebugData())return;this.hasTextCollisionBoxData()&&this.textCollisionBox.collisionVertexArrayExt.clear(),this.hasIconCollisionBoxData()&&this.iconCollisionBox.collisionVertexArrayExt.clear();let n=d1(this.iconSizeData,e,a),o=d1(this.textSizeData,e,r);for(let s=0;s<this.symbolInstances.length;s++){let l=this.symbolInstances.get(s);this._updateTextDebugCollisionBoxes(o,e,i,l.textBoxStartIndex,l.textBoxEndIndex,l,r),this._updateTextDebugCollisionBoxes(o,e,i,l.verticalTextBoxStartIndex,l.verticalTextBoxEndIndex,l,r),this._updateIconDebugCollisionBoxes(n,e,i,l.iconBoxStartIndex,l.iconBoxEndIndex,l,a),this._updateIconDebugCollisionBoxes(n,e,i,l.verticalIconBoxStartIndex,l.verticalIconBoxEndIndex,l,a)}this.hasTextCollisionBoxData()&&this.textCollisionBox.collisionVertexBufferExt&&this.textCollisionBox.collisionVertexBufferExt.updateData(this.textCollisionBox.collisionVertexArrayExt),this.hasIconCollisionBoxData()&&this.iconCollisionBox.collisionVertexBufferExt&&this.iconCollisionBox.collisionVertexBufferExt.updateData(this.iconCollisionBox.collisionVertexArrayExt)}_deserializeCollisionBoxesForSymbol(e,i,r,a,n,o,s,l,h){let u={};if(i<r){let{x1:r,y1:a,x2:n,y2:o,padding:s,projectedAnchorX:l,projectedAnchorY:h,projectedAnchorZ:c,tileAnchorX:d,tileAnchorY:p,featureIndex:f}=e.get(i);u.textBox={x1:r,y1:a,x2:n,y2:o,padding:s,projectedAnchorX:l,projectedAnchorY:h,projectedAnchorZ:c,tileAnchorX:d,tileAnchorY:p},u.textFeatureIndex=f}if(a<n){let{x1:i,y1:r,x2:n,y2:o,padding:s,projectedAnchorX:l,projectedAnchorY:h,projectedAnchorZ:c,tileAnchorX:d,tileAnchorY:p,featureIndex:f}=e.get(a);u.verticalTextBox={x1:i,y1:r,x2:n,y2:o,padding:s,projectedAnchorX:l,projectedAnchorY:h,projectedAnchorZ:c,tileAnchorX:d,tileAnchorY:p},u.verticalTextFeatureIndex=f}
7if(o<s){let{x1:i,y1:r,x2:a,y2:n,padding:s,projectedAnchorX:l,projectedAnchorY:h,projectedAnchorZ:c,tileAnchorX:d,tileAnchorY:p,featureIndex:f}=e.get(o);u.iconBox={x1:i,y1:r,x2:a,y2:n,padding:s,projectedAnchorX:l,projectedAnchorY:h,projectedAnchorZ:c,tileAnchorX:d,tileAnchorY:p},u.iconFeatureIndex=f}if(l<h){let{x1:i,y1:r,x2:a,y2:n,padding:o,projectedAnchorX:s,projectedAnchorY:h,projectedAnchorZ:c,tileAnchorX:d,tileAnchorY:p,featureIndex:f}=e.get(l);u.verticalIconBox={x1:i,y1:r,x2:a,y2:n,padding:o,projectedAnchorX:s,projectedAnchorY:h,projectedAnchorZ:c,tileAnchorX:d,tileAnchorY:p},u.verticalIconFeatureIndex=f}return u}deserializeCollisionBoxes(e){this.collisionArrays=[];for(let i=0;i<this.symbolInstances.length;i++){let r=this.symbolInstances.get(i);this.collisionArrays.push(this._deserializeCollisionBoxesForSymbol(e,r.textBoxStartIndex,r.textBoxEndIndex,r.verticalTextBoxStartIndex,r.verticalTextBoxEndIndex,r.iconBoxStartIndex,r.iconBoxEndIndex,r.verticalIconBoxStartIndex,r.verticalIconBoxEndIndex))}}hasTextData(){return this.text.segments.get().length>0}hasIconData(){return this.icon.segments.get().length>0}hasDebugData(){return this.textCollisionBox&&this.iconCollisionBox}hasTextCollisionBoxData(){return this.hasDebugData()&&this.textCollisionBox.segments.get().length>0}hasIconCollisionBoxData(){return this.hasDebugData()&&this.iconCollisionBox.segments.get().length>0}hasIconTextFit(){return this.hasAnyIconTextFit}addIndicesForPlacedSymbol(e,i){let r=e.placedSymbolArray.get(i),a=r.vertexStartIndex+4*r.numGlyphs;for(let i=r.vertexStartIndex;i<a;i+=4)e.indexArray.emplaceBack(i,i+1,i+2),e.indexArray.emplaceBack(i+1,i+2,i+3)}getSortedSymbolIndexes(e){if(this.sortedAngle===e&&void 0!==this.symbolInstanceIndexes)return this.symbolInstanceIndexes;let i=Math.sin(e),r=Math.cos(e),a=[],n=[],o=[];for(let e=0;e<this.symbolInstances.length;++e){o.push(e);let s=this.symbolInstances.get(e);a.push(0|Math.round(i*s.tileAnchorX+r*s.tileAnchorY)),n.push(s.featureIndex)}return o.sort((e,i)=>a[e]-a[i]||n[i]-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,i)=>this.symbolInstances.get(i).zOffset-this.symbolInstances.get(e).zOffset)}addToSortKeyRanges(e,i){let r=this.sortKeyRanges[this.sortKeyRanges.length-1];r&&r.sortKey===i?r.symbolInstanceEnd=e+1:this.sortKeyRanges.push({sortKey:i,symbolInstanceStart:e,symbolInstanceEnd:e+1})}sortFeatures(e){if(this.sortFeaturesByY&&this.sortedAngle!==e&&!(this.text.segments.get().length>1||this.icon.segments.get().length>1)){for(let i of(this.symbolInstanceIndexes=this.getSortedSymbolIndexes(e),this.sortedAngle=e,this.text.indexArray.clear(),this.icon.indexArray.clear(),this.featureSortOrder=[],this.symbolInstanceIndexes)){let e=this.symbolInstances.get(i);this.featureSortOrder.push(e.featureIndex);let{rightJustifiedTextSymbolIndex:r,centerJustifiedTextSymbolIndex:a,leftJustifiedTextSymbolIndex:n,verticalPlacedTextSymbolIndex:o,placedIconSymbolIndex:s,verticalPlacedIconSymbolIndex:l}=e;r>=0&&this.addIndicesForPlacedSymbol(this.text,r),a>=0&&a!==r&&this.addIndicesForPlacedSymbol(this.text,a),n>=0&&n!==a&&n!==r&&this.addIndicesForPlacedSymbol(this.text,n),o>=0&&this.addIndicesForPlacedSymbol(this.text,o),s>=0&&this.addIndicesForPlacedSymbol(this.icon,s),l>=0&&this.addIndicesForPlacedSymbol(this.icon,l)}this.text.indexBuffer&&this.text.indexBuffer.updateData(this.text.indexArray),this.icon.indexBuffer&&this.icon.indexBuffer.updateData(this.icon.indexArray)}}}a3(pQ,"SymbolBucket",{omit:["layers","collisionBoxArray","features","compareText"]}),pQ.addDynamicAttributes=pY;class p0{constructor(e){this.type=e.property.overrides?e.property.overrides.runtimeType:ix,this.defaultValue=e}evaluate(e){if(e.formattedSection){let i=this.defaultValue.property.overrides;if(i&&i.hasOverride(e.formattedSection))return i.getOverride(e.formattedSection)}return e.feature&&e.featureState?this.defaultValue.evaluate(e.feature,e.featureState):this.defaultValue.property.specification.default}eachChild(e){this.defaultValue.isConstant()||e(this.defaultValue.value._styleExpression.expression)}outputDefined(){return!1}serialize(){return null}}a3(p0,"FormatSectionOverride",{omit:["defaultValue"]});let p1=()=>
7O||(O={layout:D||(D=new nJ({"symbol-placement":new nX(nQ.layout_symbol["symbol-placement"]),"symbol-spacing":new nX(nQ.layout_symbol["symbol-spacing"]),"symbol-avoid-edges":new nX(nQ.layout_symbol["symbol-avoid-edges"]),"symbol-sort-key":new nY(nQ.layout_symbol["symbol-sort-key"]),"symbol-z-order":new nX(nQ.layout_symbol["symbol-z-order"]),"symbol-z-elevate":new nX(nQ.layout_symbol["symbol-z-elevate"]),"symbol-elevation-reference":new nX(nQ.layout_symbol["symbol-elevation-reference"]),"icon-allow-overlap":new nX(nQ.layout_symbol["icon-allow-overlap"]),"icon-ignore-placement":new nX(nQ.layout_symbol["icon-ignore-placement"]),"icon-optional":new nX(nQ.layout_symbol["icon-optional"]),"icon-rotation-alignment":new nX(nQ.layout_symbol["icon-rotation-alignment"]),"icon-size":new nY(nQ.layout_symbol["icon-size"]),"icon-size-scale-range":new nX(nQ.layout_symbol["icon-size-scale-range"]),"icon-text-fit":new nY(nQ.layout_symbol["icon-text-fit"]),"icon-text-fit-padding":new nY(nQ.layout_symbol["icon-text-fit-padding"]),"icon-image":new nY(nQ.layout_symbol["icon-image"]),"icon-image-use-theme":new nX({type:"string",default:"default","property-type":"data-constant"}),"icon-rotate":new nY(nQ.layout_symbol["icon-rotate"]),"icon-padding":new nX(nQ.layout_symbol["icon-padding"]),"icon-keep-upright":new nX(nQ.layout_symbol["icon-keep-upright"]),"icon-offset":new nY(nQ.layout_symbol["icon-offset"]),"icon-anchor":new nY(nQ.layout_symbol["icon-anchor"]),"icon-pitch-alignment":new nX(nQ.layout_symbol["icon-pitch-alignment"]),"text-pitch-alignment":new nX(nQ.layout_symbol["text-pitch-alignment"]),"text-rotation-alignment":new nX(nQ.layout_symbol["text-rotation-alignment"]),"text-field":new nY(nQ.layout_symbol["text-field"]),"text-font":new nY(nQ.layout_symbol["text-font"]),"text-size":new nY(nQ.layout_symbol["text-size"]),"text-size-scale-range":new nX(nQ.layout_symbol["text-size-scale-range"]),"text-max-width":new nY(nQ.layout_symbol["text-max-width"]),"text-line-height":new nY(nQ.layout_symbol["text-line-height"]),"text-letter-spacing":new nY(nQ.layout_symbol["text-letter-spacing"]),"text-justify":new nY(nQ.layout_symbol["text-justify"]),"text-radial-offset":new nY(nQ.layout_symbol["text-radial-offset"]),"text-variable-anchor":new nX(nQ.layout_symbol["text-variable-anchor"]),"text-anchor":new nY(nQ.layout_symbol["text-anchor"]),"text-max-angle":new nX(nQ.layout_symbol["text-max-angle"]),"text-writing-mode":new nX(nQ.layout_symbol["text-writing-mode"]),"text-rotate":new nY(nQ.layout_symbol["text-rotate"]),"text-padding":new nX(nQ.layout_symbol["text-padding"]),"text-keep-upright":new nX(nQ.layout_symbol["text-keep-upright"]),"text-transform":new nY(nQ.layout_symbol["text-transform"]),"text-offset":new nY(nQ.layout_symbol["text-offset"]),"text-allow-overlap":new nX(nQ.layout_symbol["text-allow-overlap"]),"text-ignore-placement":new nX(nQ.layout_symbol["text-ignore-placement"]),"text-optional":new nX(nQ.layout_symbol["text-optional"]),visibility:new nX(nQ.layout_symbol.visibility)})),paint:L||(L=new nJ({"icon-opacity":new nY(nQ.paint_symbol["icon-opacity"]),"icon-occlusion-opacity":new nY(nQ.paint_symbol["icon-occlusion-opacity"]),"icon-emissive-strength":new nY(nQ.paint_symbol["icon-emissive-strength"]),"text-emissive-strength":new nY(nQ.paint_symbol["text-emissive-strength"]),"icon-color":new nY(nQ.paint_symbol["icon-color"]),"icon-halo-color":new nY(nQ.paint_symbol["icon-halo-color"]),"icon-halo-width":new nY(nQ.paint_symbol["icon-halo-width"]),"icon-halo-blur":new nY(nQ.paint_symbol["icon-halo-blur"]),"icon-translate":new nX(nQ.paint_symbol["icon-translate"]),"icon-translate-anchor":new nX(nQ.paint_symbol["icon-translate-anchor"]),"icon-image-cross-fade":new nX(nQ.paint_symbol["icon-image-cross-fade"]),"text-opacity":new nY(nQ.paint_symbol["text-opacity"]),"text-occlusion-opacity":new nY(nQ.paint_symbol["text-occlusion-opacity"]),"text-color":new nY(nQ.paint_symbol["text-color"],{runtimeType:iT,getOverride:e=>e.textColor,hasOverride:e=>!!e.textColor}),"text-halo-color":new nY(nQ.paint_symbol["text-halo-color"]),"text-halo-width":new nY(nQ.paint_symbol["text-halo-width"]),"text-halo-blur":new nY(nQ.paint_symbol["text-halo-blur"]),"text-translate":new nX(nQ.paint_symbol["text-translate"]),"text-translate-anchor":new nX(nQ.paint_symbol["text-translate-anchor"]),"icon-color-saturation":new nX(nQ.paint_symbol["icon-color-saturation"]),"icon-color-contrast":new nX(nQ.paint_symbol["icon-color-contrast"]),"icon-color-brightness-min":new nX(nQ.paint_symbol["icon-color-brightness-min"]),"icon-color-brightness-max":new nX(nQ.paint_symbol["icon-color-brightness-max"]),"symbol-z-offset":new nY(nQ.paint_symbol["symbol-z-offset"]),"icon-color-use-theme":new nY({type:"string",default:"default","property-type":"data-driven"}),"icon-halo-color-use-theme":new nY({type:"string",default:"default","property-type":"data-driven"}),"text-color-use-theme":new nY({type:"string",default:"default","property-type":"data-driven"}),"text-halo-color-use-theme":new nY({type:"string",default:"default","property-type":"data-driven"})}))});class p2 extends oo{constructor(e,i,r,a){super(e,p1(),i,r,a,e.layout?e.layout["icon-image-use-theme"]:null),this._colorAdjustmentMatrix=ee([]),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,i){super.recalculate(e,i),"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"));let r=this.layout.get("text-writing-mode");if(r){let e=[];for(let i of r)0>e.indexOf(i)&&e.push(i);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,i,r,a){return this._saturation===e&&this._contrast===i&&this._brightnessMin===r&&this._brightnessMax===a||(this._colorAdjustmentMatrix=function(e,i,r,a){e=tS(e),i=tT(i);let n=Q(),o=e/3,s=1-2*o,l=.5-.5*i,h=a-r;return ei(n,[h,0,0,0,0,h,0,0,0,0,h,0,r,r,r,1],[i,0,0,0,0,i,0,0,0,0,i,0,l,l,l,1]),ei(n,n,[s,o,o,0,o,s,o,0,o,o,s,0,0,0,0,1]),n}(e,i,r,a),this._saturation=e,this._contrast=i,this._brightnessMin=r,this._brightnessMax=a),this._colorAdjustmentMatrix}getValueAndResolveTokens(e,i,r,a){var n;let o=this.layout.get(e).evaluate(i,{},r,a),s=this._unevaluatedLayout._values[e];return s.isDataDriven()||aZ(s.value)||!o?o:(n=i.properties,o.replace(/{([^{}]+)}/g,(e,i)=>i in n?String(n[i]):""))}createBucket(e){return new pQ(e)}queryRadius(){return 0}queryIntersectsFeature(){return!1}_setPaintOverrides(){for(let e of p1().paint.overridableProperties){if(!p2.hasPaintOverride(this.layout,e))continue;let i=this.paint.get(e),r=new aH(new p0(i),i.property.specification,this.scope,this.options,this.layout.get("icon-image-use-theme")),a=null;a="constant"===i.value.kind||"source"===i.value.kind?new aX("source",r):new aY("composite",r,i.value.zoomStops,i.value.interpolationType),this.paint._values[e]=new nZ(i.property,a,i.parameters)}}_handleOverridablePaintPropertyUpdate(e,i,r){return!(!this.layout||i.isDataDriven()||r.isDataDriven())&&p2.hasPaintOverride(this.layout,e)}static hasPaintOverride(e,i){let r=e.get("text-field"),a=p1().paint.properties[i],n=!1,o=e=>{for(let i of e)if(a.overrides&&a.overrides.hasOverride(i))return void(n=!0)};if("constant"===r.value.kind&&r.value.value instanceof iB)o(r.value.value.sections);else if("source"===r.value.kind){let e=i=>{n||(i instanceof i$&&iG(i.value)===iA?o(i.value.sections):i instanceof iX?o(i.sections):i.eachChild(e))},i=r.value;i._styleExpression&&e(i._styleExpression.expression)}return n}getProgramIds(){return["symbol"]}getDefaultProgramParams(e,i,r){return{config:new sI(this,{zoom:i,lut:r}),overrideFog:!1}}hasElevation(){return this.layout&&"hd-road-markup"===this.layout.get("symbol-elevation-reference")}}var p3=ou([{name:"a_pos",type:"Int16",components:2},{name:"a_texture_pos",type:"Int16",components:2}]);function p5(e,i,r,a,n,o,s,l){let h=[e,i,1,r,a,1,n,o,1],u=[s,l,1],[c,d,p]=ez(u,u,K([],h));return J(h,h,[c,0,0,0,d,0,0,0,p])}function p4(e,i,r,a,n,o,s,l){let h=function(e,i,r,a,n,o,s,l){let h=p5(0,0,1,0,1,1,0,1),u=p5(e,i,r,a,n,o,s,l);return J(u,u,K([],h))}(e,i,r,a,n,o,s,l);return[h[2]/h[8]/8192,h[5]/h[8]/8192]}function p6(e){return[e[0],Math.min(Math.max(e[1],-85.051129),85.051129)]}class p8 extends ir{constructor(e,i,r,a){super(),this.id=e,this.dispatcher=r,this.coordinates=i.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(a),this.options=i,this._dirty=!1}load(e,i){if(this._loaded=i||!1,this.fire(new t7("dataloading",{dataType:"source"})),this.url=this.options.url,!this.url)return e&&(this.coordinates=e),this._loaded=!0,void this._finishLoading();this._imageRequest=tQ(this.map._requestManager.transformRequest(this.url,tZ.Image),(i,r)=>{this._imageRequest=null,this._loaded=!0,i?this.fire(new ie(i)):r&&(this.image=r instanceof HTMLImageElement?tP.getImageData(r):r,this._dirty=!0,this.width=this.image.width,this.height=this.image.height,e&&(this.coordinates=e),this._finishLoading())})}loaded(){return this._loaded}updateImage(e){return e.url&&(this._imageRequest&&e.url!==this.options.url&&(this._imageRequest.cancel(),this._imageRequest=null),this.options.url=e.url,this.load(e.coordinates,this._loaded)),this}setTexture(e){if(!(e.handle instanceof WebGLTexture))throw Error("The provided handle is not a WebGLTexture instance");return this.texture=new cm(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 t7("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 cm||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 i=e[0][1],r=e[0][1];for(let a of e)a[1]>r&&(r=a[1]),a[1]<i&&(i=a[1]);let a=(r+i)/2;if(a>85.051129?this.onNorthPole=!0:a<-85.051129&&(this.onSouthPole=!0),!this.onNorthPole&&!this.onSouthPole){let i=e.map(sY.fromLngLat);this.tileID=function(e){let i=1/0,r=1/0,a=-1/0,n=-1/0;
7for(let o of e)i=Math.min(i,o.x),r=Math.min(r,o.y),a=Math.max(a,o.x),n=Math.max(n,o.y);let o=Math.max(0,Math.floor(-Math.log2(Math.max(a-i,n-r)))),s=Math.pow(2,o),l=Math.floor((i+a)/2*s);return l>1&&(l-=1),new lO(o,l,Math.floor((r+n)/2*s))}(i),this.minzoom=this.maxzoom=this.tileID.z}return this.fire(new t7("data",{dataType:"source",sourceDataType:"content"})),this}_clear(){!this.texture||this.texture instanceof cm||(this.texture.destroy(),this._dirty=!0),this.texture=null,this._boundsArray=void 0,this._unsupportedCoords=!1}_prepareData(e){var i;for(let e in this.tiles){let i=this.tiles[e];"loaded"!==i.state&&(i.state="loaded",i.texture=this.texture)}if(this._boundsArray||this.onNorthPole||this.onSouthPole||this._unsupportedCoords)return;let r=pE(new lO(0,0,0),this.map.transform.projection),a=[r.projection.project(this.coordinates[0][0],this.coordinates[0][1]),r.projection.project(this.coordinates[1][0],this.coordinates[1][1]),r.projection.project(this.coordinates[2][0],this.coordinates[2][1]),r.projection.project(this.coordinates[3][0],this.coordinates[3][1])];if(!function(e){let i=e[1].x-e[0].x,r=e[1].y-e[0].y,a=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,l=e[0].x-e[3].x,h=e[0].y-e[3].y,u=i*n-a*r,c=a*s-o*n,d=o*h-l*s,p=l*r-i*h;return u>0&&c>0&&d>0&&p>0||u<0&&c<0&&d<0&&p<0}(a))return console.warn("Image source coordinates are defining non-convex area in the Mercator projection"),void(this._unsupportedCoords=!0);let n=pE(this.tileID,this.map.transform.projection),[o,s,l,h]=this.coordinates.map(e=>{let i=n.projection.project(e[0],e[1]);return pI(n,i)._round()});this.perspectiveTransform=p4(o.x,o.y,s.x,s.y,l.x,l.y,h.x,h.y);let u=this._boundsArray=new of;u.emplaceBack(o.x,o.y,0,0),u.emplaceBack(s.x,s.y,8192,0),u.emplaceBack(h.x,h.y,0,8192),u.emplaceBack(l.x,l.y,8192,8192),this.boundsBuffer&&(this.boundsBuffer.destroy(),this.elevatedGlobeVertexBuffer&&this.elevatedGlobeVertexBuffer.destroy(),this.elevatedGlobeIndexBuffer&&this.elevatedGlobeIndexBuffer.destroy()),this.boundsBuffer=e.createVertexBuffer(u,p3.members),this.boundsSegments=se.simpleSegment(0,0,4,2);let c=[],[d,p,f,m]=function(e){let i=e[0][0],r=i,a=e[0][1],n=a;for(let o=1;o<e.length;o++)e[o][0]<i?i=e[o][0]:e[o][0]>r&&(r=e[o][0]),e[o][1]<a?a=e[o][1]:e[o][1]>n&&(n=e[o][1]);return[i,a,r-i,n-a]}([p6((i=this.coordinates)[0]),p6(i[1]),p6(i[2]),p6(i[3])]);{let i=new of,[n,o,s,l]=function(e){let i=e[0].x,r=i,a=e[0].y,n=a;for(let o=1;o<e.length;o++)e[o].x<i?i=e[o].x:e[o].x>r&&(r=e[o].x),e[o].y<a?a=e[o].y:e[o].y>n&&(n=e[o].y);return[i,a,r-i,n-a]}(a),h=e=>[(e.x-n)/s,(e.y-o)/l],[u,_,g,y]=a.map(h),x=function(e,i,r,a,n,o,s,l){let h=p5(0,0,1,0,1,1,0,1);return J(h,h,K([],p5(e,i,r,a,n,o,s,l)))}(u[0],u[1],_[0],_[1],g[0],g[1],y[0],y[1]);this.elevatedGlobePerspectiveTransform=p4(u[0],u[1],_[0],_[1],g[0],g[1],y[0],y[1]);let v=(e,r)=>{c.push(e.lng);let a=Math.round((e.lng-d)/f*8192),n=Math.round((e.lat-p)/m*8192),o=h(r),s=ez([],[o[0],o[1],1],x),l=Math.round(s[0]/s[2]*8192),u=Math.round(s[1]/s[2]*8192);i.emplaceBack(a,n,l,u)},b=a[3].x-a[0].x,w=a[3].y-a[0].y,T=a[2].x-a[1].x,S=a[2].y-a[1].y;for(let e=0;e<65;e++){let i=e/64,n=[a[0].x+i*b,a[0].y+i*w],o=[a[1].x+i*T,a[1].y+i*S],s=o[0]-n[0],l=o[1]-n[1];for(let e=0;e<65;e++){let i=e/64,a={x:n[0]+s*i,y:n[1]+l*i};v(r.projection.unproject(a.x,a.y),a)}}this.elevatedGlobeVertexBuffer=e.createVertexBuffer(i,p3.members)}{this.maxLongitudeTriangleSize=0;let i=[],r=new oD,a=(e,a,n)=>{r.emplaceBack(e,a,n);let o=c[e],s=c[a],l=c[n],h=Math.min(Math.min(o,s),l),u=Math.max(Math.max(o,s),l)-h;u>this.maxLongitudeTriangleSize&&(this.maxLongitudeTriangleSize=u),i.push(h+u/2)};for(let e=0;e<64;e++)for(let i=0;i<64;i++){let r=65*e+i,n=r+1,o=r+65,s=o+1;a(r,o,n),a(n,o,s)}[i,r]=function(e,i){let r=Array.from({length:e.length},(e,i)=>i);r.sort((i,r)=>e[i]-e[r]);let a=[],n=new oD;for(let o=0;o<r.length;o++){let s=r[o];a.push(e[s]);let l=3*s,h=l+1;n.emplaceBack(i.uint16[l],i.uint16[h],i.uint16[h+1])}return[a,n]}(i,r),this.elevatedGlobeTrianglesCenterLongitudes=i,this.elevatedGlobeIndexBuffer=e.createIndexBuffer(r)}this.elevatedGlobeSegments=se.simpleSegment(0,0,4225,8192),this.elevatedGlobeGridMatrix=new Float32Array([0,f/8192,0,m/8192,0,0,p,d,0])}prepare(){let e=0!==Object.keys(this.tiles).length;if(this.tileID&&!e)return;let i=this.map.painter.context,r=i.gl;!this._dirty||this.texture instanceof cm||(this.texture?this.texture.update(this.image):(this.texture=new cf(i,this.image,r.RGBA8),this.texture.bind(r.LINEAR,r.CLAMP_TO_EDGE)),this._dirty=!1),e&&this._prepareData(i)}loadTile(e,i){this.tileID&&this.tileID.equals(e.tileID.canonical)?(this.tiles[String(e.tileID.wrap)]=e,e.buckets={}):e.state="errored",i(null)}serialize(){return{type:"image",url:this.options.url,coordinates:this.coordinates}}hasTransition(){return!1}getSegmentsForLongitude(e){var i;let r=this.elevatedGlobeSegments;if(!this.elevatedGlobeTrianglesCenterLongitudes||!r)return null;let a=this.elevatedGlobeTrianglesCenterLongitudes,n=(i=e+180)+360*Math.round((a[0]-i)/360),o=new se,s=(e,i)=>{o.segments.push({vertexOffset:0,primitiveOffset:e,vertexLength:r.segments[0].vertexLength,primitiveLength:i,sortKey:void 0,vaos:{}})},l=.51*this.maxLongitudeTriangleSize;if(Math.abs(a[0]-n)<=l){let e=tw(a,0,a.length,n+l);return e===a.length||s(e,tb(a,e+1,a.length,n+360-l)-e),o}n<a[0]&&(n+=360);let h=tb(a,0,a.length,n-l);if(h===a.length)return s(0,a.length),o;s(0,h-0);let u=tw(a,h+1,a.length,n+l);return u!==a.length&&s(u,a.length-u),o}}class p9 extends oo{constructor(e,i,r,a){super(e,{layout:B||(B=new nJ({visibility:new nX(nQ.layout_raster.visibility)})),paint:N||(N=new nJ({"raster-opacity":new nX(nQ.paint_raster["raster-opacity"]),"raster-color":new nK(nQ.paint_raster["raster-color"]),"raster-color-mix":ne
7w nX(nQ.paint_raster["raster-color-mix"]),"raster-color-range":new nX(nQ.paint_raster["raster-color-range"]),"raster-hue-rotate":new nX(nQ.paint_raster["raster-hue-rotate"]),"raster-brightness-min":new nX(nQ.paint_raster["raster-brightness-min"]),"raster-brightness-max":new nX(nQ.paint_raster["raster-brightness-max"]),"raster-saturation":new nX(nQ.paint_raster["raster-saturation"]),"raster-contrast":new nX(nQ.paint_raster["raster-contrast"]),"raster-resampling":new nX(nQ.paint_raster["raster-resampling"]),"raster-fade-duration":new nX(nQ.paint_raster["raster-fade-duration"]),"raster-emissive-strength":new nX(nQ.paint_raster["raster-emissive-strength"]),"raster-array-band":new nX(nQ.paint_raster["raster-array-band"]),"raster-elevation":new nX(nQ.paint_raster["raster-elevation"]),"raster-color-use-theme":new nY({type:"string",default:"default","property-type":"data-driven"})}))},i,r,a),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 p8&&(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()||!this._curRampRange)return;let i=this._transitionablePaint._values["raster-color"].value.expression,[r,a]=e||this._transitionablePaint._values["raster-color-range"].value.expression.evaluate({zoom:0})||[NaN,NaN];isNaN(r)&&isNaN(a)||r===this._curRampRange[0]&&a===this._curRampRange[1]||(this.colorRamp=h_({expression:i,evaluationKey:"rasterValue",image:this.colorRamp,clips:[{start:r,end:a}],resolution:256}),this.colorRampTexture=null,this._curRampRange=[r,a])}}class p7 extends oo{constructor(e,i,r,a){super(e,{layout:V||(V=new nJ({visibility:new nX(nQ["layout_raster-particle"].visibility)})),paint:U||(U=new nJ({"raster-particle-array-band":new nX(nQ["paint_raster-particle"]["raster-particle-array-band"]),"raster-particle-count":new nX(nQ["paint_raster-particle"]["raster-particle-count"]),"raster-particle-color":new nK(nQ["paint_raster-particle"]["raster-particle-color"]),"raster-particle-max-speed":new nX(nQ["paint_raster-particle"]["raster-particle-max-speed"]),"raster-particle-speed-factor":new nX(nQ["paint_raster-particle"]["raster-particle-speed-factor"]),"raster-particle-fade-opacity-factor":new nX(nQ["paint_raster-particle"]["raster-particle-fade-opacity-factor"]),"raster-particle-reset-rate-factor":new nX(nQ["paint_raster-particle"]["raster-particle-reset-rate-factor"]),"raster-particle-elevation":new nX(nQ["paint_raster-particle"]["raster-particle-elevation"]),"raster-particle-color-use-theme":new nY({type:"string",default:"default","property-type":"data-driven"})}))},i,r,a),this._updateColorRamp(),this.lastInvalidatedAt=tP.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;let e=this._transitionablePaint._values["raster-particle-color"].value.expression,i=this._transitionablePaint._values["raster-particle-max-speed"].value.expression.evaluate({zoom:0});this.colorRamp=h_({expression:e,evaluationKey:"rasterParticleSpeed",image:this.colorRamp,clips:[{start:0,end:i}],resolution:256}),this.colorRampTexture=null}
7_invalidateAnimationState(){this.lastInvalidatedAt=tP.now()}tileCoverLift(){return this.paint.get("raster-particle-elevation")}}class fe extends oo{constructor(e,i){super(e,{},i,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 ft(e,i,r){let a=[0,0,1],n=eV([]);return ej(n,n,r?-(e*e4)+Math.PI:e*e4),eU(n,n,-(i*e4)),eR(a,a,n),eI(a,a)}let fi={None:0,Model:1,Symbol:2,FillExtrusion:4};class fr{constructor(e,i,r,a){this.message=(e?`${e}: `:"")+r,a&&(this.identifier=a),null!=i&&i.__line__&&(this.line=i.__line__)}}function fa(e,i){let r=-1===e.indexOf("://");try{return new URL(e,r&&i?"http://example.com":void 0),!0}catch(e){return!1}}class fn{constructor(e,i){this.feature=e,this.instancedDataOffset=i,this.instancedDataCount=0,this.rotation=[0,0,0],this.scale=[1,1,1],this.translation=[0,0,0]}}class fo{constructor(){this.instancedDataArray=new oq,this.instancesEvaluatedElevation=[],this.features=[],this.idToFeaturesIndex={}}}class fs{constructor(e){this.zoom=e.zoom,this.canonical=e.canonical,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}updateFootprints(e,i){}populate(e,i,r,a){this.tileToMeter=sX(r);let n=this.layers[0]._featureFilter.needGeometry;for(let{feature:o,id:s,index:l,sourceLayerIndex:h}of(this.lookup=new Uint8Array(this.lookupDim*this.lookupDim),e)){let e=null!=s?s:o.properties&&o.properties.hasOwnProperty("id")?o.properties.id:void 0,u=s0(o,n);if(!this.layers[0]._featureFilter.filter(new nV(this.zoom,{worldview:this.worldview}),u,r))continue;let c={id:e,sourceLayerIndex:h,index:l,geometry:n?u.geometry:sQ(o,r,a),properties:o.properties,type:o.type,patterns:{}},d=this.addFeature(c,c.geometry,u);d&&i.featureIndex.insert(o,c.geometry,l,h,this.index,this.instancesPerModel[d].instancedDataArray.length,256)}this.lookup=null}update(e,i,r,a){for(let i in this.instancesPerModel){let r=this.instancesPerModel[i];for(let i in e)r.idToFeaturesIndex.hasOwnProperty(i)&&(this.evaluate(r.features[r.idToFeaturesIndex[i]],e[i],r,!0),this.uploaded=!1)}this.maxHeight=0}updateZoomBasedPaintProperties(){if(!this.hasZoomDependentProperties)return!1;let e=!1;for(let i in this.instancesPerModel){let r=this.instancesPerModel[i];for(let i of r.features){let a=this.layers[0],n=i.feature,o=this.canonical,s=a.paint.get("model-rotation").evaluate(n,{},o),l=a.paint.get("model-scale").evaluate(n,{},o),h=a.paint.get("model-translation").evaluate(n,{},o);eL(i.rotation,s)&&eL(i.scale,l)&&eL(i.translation,h)||(this.evaluate(i,i.featureStates,r,!0),e=!0)}}return e}updateReplacement(e,i,r,a){if(i.updateTime===this.replacementUpdateTime)return!1;this.replacementUpdateTime=i.updateTime;let n=i.getReplacementRegionsForTile(e.toUnwrapped(),!0);if(us(this.activeReplacements,n))return!1;this.activeReplacements=n;let o=!1;for(let i in this.instancesPerModel){let n=this.instancesPerModel[i],s=n.instancedDataArray;for(let i of n.features){let n=i.instancedDataOffset,l=i.instancedDataCount;for(let i=0;i<l;i++){let l=16*(i+n),h=s.float32[l+0],u=h>8192,c=Math.floor(h=u?h-8192:h),d=s.float32[l+1],p=!1;for(let i of this.activeReplacements)if(!ur(i,r,fi.Model,a)&&!(i.min.x>c||c>i.max.x||i.min.y>d||d>i.max.y)&&(p=uc(uu(c,d,e.canonical,i.footprintTileId.canonical),i.footprint)))break;s.float32[l]=p?h+8192:h,o=o||p!==u}}}return o}isEmpty(){for(let 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(let i in this.instancesPerModel){let r=this.instancesPerModel[i];r.instancedDataArray.length<0||0===r.instancedDataArray.length||(r.instancedDataBuffer?r.instancedDataBuffer.updateData(r.instancedDataArray):r.instancedDataBuffer=e.createVertexBuffer(r.
7instancedDataArray,cb.members,!0,void 0,this.instanceCount))}this.uploaded=!0}destroy(){for(let e in this.instancesPerModel){let i=this.instancesPerModel[e];0!==i.instancedDataArray.length&&i.instancedDataBuffer&&i.instancedDataBuffer.destroy()}let e=this.layers[0].modelManager;if(e&&this.modelUris&&this.modelsRequested)for(let i of this.modelUris)e.removeModel(i,"",!0)}addFeature(e,i,r){let a=this.layers[0],n=a.layout.get("model-id").evaluate(r,{},this.canonical);if(!n)return tf(`modelId is not evaluated for layer ${a.id} and it is not going to get rendered.`),n;(fa(n,!1)||void 0!==this.styleDefinedModelURLs[n])&&(this.modelUris.includes(n)||this.modelUris.push(n)),this.instancesPerModel[n]||(this.instancesPerModel[n]=new fo);let o=this.instancesPerModel[n],s=o.instancedDataArray,l=new fn(r,s.length);for(let e of i)for(let i of e){if(i.x<0||i.x>=8192||i.y<0||i.y>=8192)continue;if(0!==this.lookupDim){let e=(this.lookupDim-1)/8192,r=this.lookupDim*(i.y*e|0)+i.x*e|0;if(this.lookup){if(0!==this.lookup[r])continue;this.lookup[r]=1}}this.instanceCount++;let e=s.length;s.resize(e+1),o.instancesEvaluatedElevation.push(0),s.float32[16*e]=i.x,s.float32[16*e+1]=i.y}return l.instancedDataCount=o.instancedDataArray.length-l.instancedDataOffset,l.instancedDataCount>0&&(e.id&&(o.idToFeaturesIndex[e.id]=o.features.length),o.features.push(l),this.evaluate(l,{},o,!1)),n}getModelUris(){return this.modelUris}evaluate(e,i,r,a){let n=this.layers[0],o=e.feature,s=this.canonical,l=e.rotation=n.paint.get("model-rotation").evaluate(o,i,s),h=e.scale=n.paint.get("model-scale").evaluate(o,i,s),u=e.translation=n.paint.get("model-translation").evaluate(o,i,s),c=n.paint.get("model-color").evaluate(o,i,s);c.a=n.paint.get("model-color-mix-intensity").evaluate(o,i,s);let d=[];this.maxVerticalOffset<u[2]&&(this.maxVerticalOffset=u[2]),this.maxScale=Math.max(Math.max(this.maxScale,h[0]),Math.max(h[1],h[2])),cM(d,l,h);let p=Math.round(100*c.a)+c.b/1.05;for(let i=0;i<e.instancedDataCount;++i){let n=e.instancedDataOffset+i,o=16*n,l=r.instancedDataArray.float32,h=0;a&&(h=l[o+6]-r.instancesEvaluatedElevation[n]);let f=0|l[o+1];l[o]=(0|l[o])+c.r/1.05,l[o+1]=f+c.g/1.05,l[o+2]=p,l[o+3]=1/(s.z>10?this.tileToMeter:sX(s,f)),l[o+4]=u[0],l[o+5]=u[1],l[o+6]=u[2]+h,l[o+7]=d[0],l[o+8]=d[1],l[o+9]=d[2],l[o+10]=d[4],l[o+11]=d[5],l[o+12]=d[6],l[o+13]=d[8],l[o+14]=d[9],l[o+15]=d[10],r.instancesEvaluatedElevation[n]=u[2]}}}a3(fs,"ModelBucket",{omit:["layers"]}),a3(fo,"PerModelAttributes"),a3(fn,"ModelFeature");class fl{constructor(e,i,r){this._demTile=e,this._dem=this._demTile.dem,this._scale=i,this._offset=r}static create(e,i,r){let a=r||e.findDEMTileFor(i);if(!a||!a.dem)return;let n=a.dem,o=a.tileID,s=1<<i.canonical.z-o.canonical.z;return new fl(a,n.dim/8192/s,[(i.canonical.x/s-o.canonical.x)*n.dim,(i.canonical.y/s-o.canonical.y)*n.dim])}tileCoordToPixel(e,i){let r=i*this._scale+this._offset[1];return new e3(Math.floor(e*this._scale+this._offset[0]),Math.floor(r))}getElevationAt(e,i,r,a){let n=e*this._scale+this._offset[0],o=i*this._scale+this._offset[1],s=Math.floor(n),l=Math.floor(o),h=this._dem;return a=!!a,r?ip(ip(h.get(s,l,a),h.get(s,l+1,a),o-l),ip(h.get(s+1,l,a),h.get(s+1,l+1,a),o-l),n-s):h.get(s,l,a)}getElevationAtPixel(e,i,r){return this._dem.get(e,i,!!r)}getMeterToDEM(e){return(1<<this._demTile.tileID.canonical.z)*(1/sV(e))*this._dem.stride}}let fh=new Float32Array(262144),fu=new Uint8Array(262144),fc=["","wall","door","roof","window","lamp","logo"];class fd{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:function e(i){let r=0;if(i.meshes)for(let e of i.meshes)r=Math.max(r,e.aabb.max[2]);if(i.children)for(let a of i.children)r=Math.max(r,e(a));return r}(e)}},this.aabb=this._getLocalBounds(),this.state=null}_getLocalBounds(){if(!this.node.meshes)return new ld([1/0,1/0,1/0],[-1/0,-1/0,-1/0]);if(!this.aabb){let e=0,i=new ld([1/0,1/0,1/0],[-1/0,-1/0,-1/0]);for(let r of this.node.meshes)this.node.lightMeshIndex!==e&&(r.transformedAabb=ld.applyTransformFast(r.aabb,this.node.matrix),i.encapsulate(r.transformedAabb)),e++;this.aabb=i}return this.aabb}}class fp{constructor(e,i,r,a,n,o,s,l){for(let h of(this.id=r,this.layers=e,this.layerIds=this.layers.map(e=>e.fqid),this.stateDependentLayerIds=this.layers.filter(e=>e.isStateDependent()).map(e=>e.id),this.modelTraits|=cD.CoordinateSpaceTile,this.uploaded=!1,this.hasPattern=!1,a&&(this.modelTraits|=cD.HasMapbox
7MeshFeatures),n&&(this.modelTraits|=cD.HasMeshoptCompression),this.zoom=-1,this.terrainExaggeration=1,this.projection={name:"mercator"},this.replacementUpdateTime=0,this.elevationReadFromZ=255,this.brightness=o,this.worldview=l,this.dirty=!0,this.needsUpload=!1,this.filter=null,this.nodesInfo=[],i))this.nodesInfo.push(new fd(h)),function e(i,r,a){if(i.meshes)for(let e of i.meshes){if(e.aabb.min[0]===1/0)continue;let n=ld.applyTransform(e.aabb,i.matrix);a.insert(r,n.min[0],n.min[1],n.max[0],n.max[1])}if(i.children)for(let n of i.children)e(n,r,a)}(h,s.featureIndexArray.length,s.grid),s.featureIndexArray.emplaceBack(this.nodesInfo.length-1,0,s.bucketLayerIDs.length-1,0);this.states={}}updateFootprints(e,i){for(let r of this.getNodesInfo()){let a=r.node;a.footprint&&i.push({footprint:a.footprint,id:e})}}update(e){let i=0!==Object.keys(e).length;if(i&&!this.stateDependentLayers.length)return;let r=i?this.stateDependentLayers:this.layers;if(!e5(e,this.states))for(let i of r)this.evaluate(i,e);this.states=structuredClone(e)}populate(){console.log("populate 3D model bucket")}uploadPending(){return!this.uploaded||this.needsUpload}upload(e){if(!this.needsUpload)return;let i=this.getNodesInfo();for(let r of i){let i=r.node;this.uploaded?this.updatePbrBuffer(i):cF(i,e,!0)}for(let e of i)ck(e.node);this.uploaded=!0,this.needsUpload=!1}updatePbrBuffer(e){let i=!1;if(!e.meshes)return i;for(let r of e.meshes)r.pbrBuffer&&(r.pbrBuffer.updateData(r.featureArray),i=!0);return i}needsReEvaluation(e,i,r){let a=e.transform.projectionOptions,n=e.style.getBrightness(),o=this.brightness!==n;if(!this.uploaded||this.dirty||a.name!==this.projection.name||ff(r.paint.get("model-color").value,o)||ff(r.paint.get("model-color-mix-intensity").value,o)||ff(r.paint.get("model-roughness").value,o)||ff(r.paint.get("model-emissive-strength").value,o)||ff(r.paint.get("model-height-based-emissive-strength-multiplier").value,o)){for(let e of(this.projection=a,this.brightness=n,this.getNodesInfo()))e.state=null;return!0}return!1}evaluateTransform(e,i){if(e.transform.zoom===this.zoom)return;this.zoom=e.transform.zoom;let r=this.getNodesInfo(),a=this.id.canonical;for(let e of r){let r=e.feature;e.evaluatedTranslation=i.paint.get("model-translation").evaluate(r,{},a),e.evaluatedScale=i.paint.get("model-scale").evaluate(r,{},a)}}evaluate(e,i){for(let r of this.getNodesInfo()){if(!r.node.meshes)continue;let a=r.feature,n=i&&i[a.id];if(e5(n,r.state))continue;r.state=structuredClone(n);let o=r.node.meshes&&r.node.meshes[0].featureData,s=r.evaluatedColor[2],l=r.evaluatedRMEA[2],h=this.id.canonical;if(r.hasTranslucentParts=!1,o){for(let i=0;i<fc.length;i++){let o=fc[i];o.length&&(a.properties.part=o);let s=e.paint.get("model-color").evaluate(a,n,h).toPremultipliedRenderColor(null),l=e.paint.get("model-color-mix-intensity").evaluate(a,n,h);r.evaluatedColor[i]=[s.r,s.g,s.b,l],r.evaluatedRMEA[i][0]=e.paint.get("model-roughness").evaluate(a,n,h),r.evaluatedRMEA[i][2]=e.paint.get("model-emissive-strength").evaluate(a,n,h),r.evaluatedRMEA[i][3]=s.a,r.emissionHeightBasedParams[i]=e.paint.get("model-height-based-emissive-strength-multiplier").evaluate(a,n,h),!r.hasTranslucentParts&&s.a<1&&(r.hasTranslucentParts=!0)}delete a.properties.part,function(e,i,r){let a=e.node,n=0,o=r&cD.HasMeshoptCompression;for(let r of a.meshes){if(a.lights&&a.lightMeshIndex===n||!r.featureData)continue;r.featureArray=new o$,r.featureArray.reserve(r.featureData.length);let s=i;for(let i of r.featureData){let n,l=o?65535&i:i>>16&65535,h=o?i>>16&65535:65535&i,u=(15&h)<8?15&h:0,c=e.evaluatedRMEA[u],d=e.evaluatedColor[u],p=e.emissionHeightBasedParams[u];if(s&&2===u&&a.lights&&(n=new o$).resize(10*a.lights.length),function(e,i,r,a,n,o,s,l){let h,u,c,d,p=(61440&i|(61440&i)>>4)>>8,f=(3840&i|(3840&i)>>4)>>4,m=240&i|(240&i)>>4;r[3]>0&&(p=ip(p,255*r[0],r[3]),f=ip(f,255*r[1],r[3]),m=ip(m,255*r[2],r[3]));let _=p<<8|f,g=m<<8|Math.floor(255*a[3]),y=Math.min(Math.round(.5*tt(a[2],0,2)*255),255)<<8|15*a[0]<<4|15*a[1],x=tt(n[0],0,1),v=tt(n[1],0,1),b=tt(n[2],0,1),w=tt(n[3],0,1);if(x!==v&&s!==o&&v!==x){let e=s-o;u=1/(e*(v-x)),c=-(o+e*x)/(e*(v-x)),d=Math.pow(10,tt(n[4],-1,1)),h=255*b<<8|255*w}else h=65535,u=0,c=1,d=1;if(e.emplaceBack(_,g,y,h,u,c,d),l){let e=l.length;l.clear();for(let i=0;i<e;i++)l.emplaceBack(_,g,y,h,u,c,d)}}(r.featureArray,l,d,c,p,r.aabb.min[2],r.aabb.max[2],n),n&&s){s=!1;let e=a.meshes[a.lightMeshIndex];e.featureArray=n,e.featureArray._trim()}}r.featureArray._trim(),n++}}(r,s!==r.evaluatedColor[2]||l!==r.evaluatedRMEA[2],this.modelTraits)}else r.evaluatedRMEA[0][2]=e.paint.get("model-emissive-strength").evaluate(a,n,h);r.evaluatedTranslation=e.paint.get("model-translation").evaluate(a,n,h),r.evaluatedScale=e.paint.get("model-scale").evaluate(a,n,h),this.updatePbrBuffer(r.node)||(this.needsUpload=!0)}this.dirty=!1}elevationUpdate(e,i,r,a){let n=e.findDEMTileFor(r);if(n&&(n.tileID.canonical!==this.terrainTile||i!==this.terrainExaggeration)){if
7(n.dem&&n.tileID.overscaledZ!==this.elevationReadFromZ){this.elevationReadFromZ=n.tileID.overscaledZ;let i=fl.create(e,r,n);if(!i)return;for(let n of(this.modelTraits&cD.HasMapboxMeshFeatures&&this.updateDEM(e,i,r,a),this.getNodesInfo())){let e=n.node;if(!e.footprint||!e.footprint.vertices||!e.footprint.vertices.length)continue;let r=e.footprint.vertices,a=i.getElevationAt(r[0].x,r[0].y,!0,!0);for(let e=1;e<r.length;e++)a=Math.min(a,i.getElevationAt(r[e].x,r[e].y,!0,!0));e.elevation=a}}this.terrainTile=n.tileID.canonical,this.terrainExaggeration=i}}updateDEM(e,i,r,a){let n=i._dem._modifiedForSources[a];if(void 0===n&&(i._dem._modifiedForSources[a]=[],n=i._dem._modifiedForSources[a]),n.includes(r.canonical))return;let o=i._dem.dim;n.push(r.canonical);let s=!1;for(let e of this.getNodesInfo()){let r=e.node;if(!r.footprint||!r.footprint.grid)continue;let a=r.footprint.grid,n=i.tileCoordToPixel(a.min.x,a.min.y),l=i.tileCoordToPixel(a.max.x,a.max.y),h=Math.min(Math.min(o-l.y,n.x),Math.min(n.y,o-l.x));if(h<0)continue;let u=tt(h,2,5),c=Math.max(0,n.x-u),d=Math.max(0,n.y-u),p=Math.min(l.x+u,o-1),f=Math.min(l.y+u,o-1);for(let e=d;e<=f;++e)for(let i=c;i<=p;++i)fu[e*o+i]=255;let m=0,_=0;for(let e=0;e<a.cellsY;++e)for(let r=0;r<a.cellsX;++r){if(!a.cells[e*a.cellsX+r])continue;let n=i.tileCoordToPixel(a.min.x+r/a.xScale,a.min.y+e/a.yScale),s=i.tileCoordToPixel(a.min.x+(r+1)/a.xScale,a.min.y+(e+1)/a.yScale);for(let e=n.y;e<=Math.min(s.y+1,o-1);++e)for(let r=n.x;r<=Math.min(s.x+1,o-1);++r)255===fu[e*o+r]&&(fu[e*o+r]=0,m+=i.getElevationAtPixel(r,e),_++)}let g=m/_;c=Math.max(1,n.x-u),d=Math.max(1,n.y-u),p=Math.min(l.x+u,o-2),f=Math.min(l.y+u,o-2),s=!0;for(let e=d;e<=f;++e)for(let r=c;r<=p;++r)0===fu[e*o+r]&&(fh[e*o+r]=i._dem.set(r,e,g));for(let e=1;e<u;++e){c=Math.max(1,n.x-e),d=Math.max(1,n.y-e),p=Math.min(l.x+e,o-2),f=Math.min(l.y+e,o-2);for(let r=d;r<=f;++r)for(let a=c;a<=p;++a){let n=r*o+a;if(255===fu[n]){let s=0,l=0,h=-1,c=-1;for(let i=-1;i<=1;++i)for(let n=-1;n<=1;++n){let u=(r+i)*o+a+n;if(fu[u]>=e)continue;let d=fh[u],p=Math.abs(d);p>l&&(s=d,l=p,h=n,c=i)}if(l>.1){let o=1-(e+.5*Math.abs(h*c))/u,l=i._dem.get(a,r)+s*o,d=i._dem.get(a+h,r+c),p=i._dem.get(a-h,r-c,!0);(l-d)*(l-p)>0&&(l=(d+p)/2),fh[n]=i._dem.set(a,r,l),fu[n]=e}}}}}s&&(i._demTile.needsDEMTextureUpload=!0,i._dem._timestamp=tP.now())}setFilter(e){this.filter=e?n3(e):null}getNodesInfo(){return this.filter?this.nodesInfo.filter(e=>this.filter.filter(new nV(this.id.overscaledZ,{worldview:this.worldview}),e.feature,this.id.canonical)):this.nodesInfo}destroy(){for(let e of this.getNodesInfo())ck(e.node),cB(e.node)}isEmpty(){return!this.nodesInfo.length}updateReplacement(e,i){if(i.updateTime===this.replacementUpdateTime)return;this.replacementUpdateTime=i.updateTime;let r=i.getReplacementRegionsForTile(e.toUnwrapped());for(let e of this.getNodesInfo()){let i=e.node.footprint;e.hiddenByReplacement=!!i&&!r.find(e=>e.footprint===i)}}getHeightAtTileCoord(e,i){let r=[],a=[0,0,0],n=ee([]);for(let o of this.getNodesInfo()){let s=o.node.meshes[0],l=s.transformedAabb;if(e<l.min[0]||i<l.min[1]||e>l.max[0]||i>l.max[1])continue;if(!0===o.node.hidden)return{height:1/0,maxHeight:o.feature.properties.height,hidden:!1,verticalScale:o.evaluatedScale[2]};et(n,o.node.matrix),a[0]=e,a[1]=i,eP(a,a,n);let h=(a[0]-s.aabb.min[0])/(s.aabb.max[0]-s.aabb.min[0])*64|0,u=64*Math.min(63,(a[1]-s.aabb.min[1])/(s.aabb.max[1]-s.aabb.min[1])*64|0)+Math.min(63,h),c=s.heightmap[u];if(!(c<0&&o.node.footprint)){if(o.hiddenByReplacement)return;return{height:c,maxHeight:o.feature.properties.height,hidden:!1,verticalScale:o.evaluatedScale[2]}}if(o.node.footprint.grid.query(new e3(e,i),new e3(e,i),r),r.length>0)return{height:void 0,maxHeight:o.feature.properties.height,hidden:o.hiddenByReplacement,verticalScale:o.evaluatedScale[2]}}}}function ff(e,i){return e instanceof aX&&!e.isLightConstant&&i}function fm(e,i,r,a){let n=1<<e.z;i.lat=sq((a/8192+e.y)/n),i.lng=sG((r/8192+e.x)/n)}a3(fp,"Tiled3dModelBucket",{omit:["layers"]}),a3(fd,"Tiled3dModelFeature");let f_={circle:class extends oo{constructor(e,i,r,a){super(e,{layout:p||(p=new nJ({"circle-sort-key":new nY(nQ.layout_circle["circle-sort-key"]),"circle-elevation-reference":new nX(nQ.layout_circle["circle-elevation-reference"]),visibility:new nX(nQ.layout_circle.visibility)}
vendor: 7,418 bytes, line 7
7)),paint:f||(f=new nJ({"circle-radius":new nY(nQ.paint_circle["circle-radius"]),"circle-color":new nY(nQ.paint_circle["circle-color"]),"circle-blur":new nY(nQ.paint_circle["circle-blur"]),"circle-opacity":new nY(nQ.paint_circle["circle-opacity"]),"circle-translate":new nX(nQ.paint_circle["circle-translate"]),"circle-translate-anchor":new nX(nQ.paint_circle["circle-translate-anchor"]),"circle-pitch-scale":new nX(nQ.paint_circle["circle-pitch-scale"]),"circle-pitch-alignment":new nX(nQ.paint_circle["circle-pitch-alignment"]),"circle-stroke-width":new nY(nQ.paint_circle["circle-stroke-width"]),"circle-stroke-color":new nY(nQ.paint_circle["circle-stroke-color"]),"circle-stroke-opacity":new nY(nQ.paint_circle["circle-stroke-opacity"]),"circle-emissive-strength":new nX(nQ.paint_circle["circle-emissive-strength"]),"circle-color-use-theme":new nY({type:"string",default:"default","property-type":"data-driven"}),"circle-stroke-color-use-theme":new nY({type:"string",default:"default","property-type":"data-driven"})}))},i,r,a)}createBucket(e){return new lg(e)}queryRadius(e){return lP("circle-radius",this,e)+lP("circle-stroke-width",this,e)+lz(this.paint.get("circle-translate"))}queryIntersectsFeature(e,i,r,a,n,o,s,l){let h=lD(this.paint.get("circle-translate"),this.paint.get("circle-translate-anchor"),o.angle,e.pixelToTileUnitsFactor),u=this.paint.get("circle-radius").evaluate(i,r)+this.paint.get("circle-stroke-width").evaluate(i,r);return ho(e,a,o,s,l,"map"===this.paint.get("circle-pitch-alignment"),"map"===this.paint.get("circle-pitch-scale"),h,u)}getProgramIds(){return["circle"]}getDefaultProgramParams(e,i,r){let a=hn(this);return{config:new sI(this,{zoom:i,lut:r}),defines:a,overrideFog:!1}}is3D(e){return!e&&!!this.layout&&"none"!==this.layout.get("circle-elevation-reference")}hasElevation(){return this.layout&&"none"!==this.layout.get("circle-elevation-reference")}},heatmap:class extends oo{createBucket(e){return new hh(e)}constructor(e,i,r,a){super(e,{layout:m||(m=new nJ({visibility:new nX(nQ.layout_heatmap.visibility)})),paint:_||(_=new nJ({"heatmap-radius":new nY(nQ.paint_heatmap["heatmap-radius"]),"heatmap-weight":new nY(nQ.paint_heatmap["heatmap-weight"]),"heatmap-intensity":new nX(nQ.paint_heatmap["heatmap-intensity"]),"heatmap-color":new nK(nQ.paint_heatmap["heatmap-color"]),"heatmap-opacity":new nX(nQ.paint_heatmap["heatmap-opacity"]),"heatmap-color-use-theme":new nY({type:"string",default:"default","property-type":"data-driven"})}))},i,r,a),this._updateColorRamp()}_handleSpecialPaintPropertyUpdate(e){"heatmap-color"===e&&this._updateColorRamp()}_updateColorRamp(){this.colorRamp=h_({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 lP("heatmap-radius",this,e)}queryIntersectsFeature(e,i,r,a,n,o,s,l){let h=this.paint.get("heatmap-radius").evaluate(i,r);return ho(e,a,o,s,l,!0,!0,new e3(0,0),h)}hasOffscreenPass(){return 0!==this.paint.get("heatmap-opacity")&&"none"!==this.visibility}getProgramIds(){return["heatmap","heatmapTexture"]}getDefaultProgramParams(e,i,r){return"heatmap"===e?{config:new sI(this,{zoom:i,lut:r}),overrideFog:!1}:{}}},hillshade:class extends oo{constructor(e,i,r,a){super(e,{layout:g||(g=new nJ({visibility:new nX(nQ.layout_hillshade.visibility)})),paint:y||(y=new nJ({"hillshade-illumination-direction":new nX(nQ.paint_hillshade["hillshade-illumination-direction"]),"hillshade-illumination-anchor":new nX(nQ.paint_hillshade["hillshade-illumination-anchor"]),"hillshade-exaggeration":new nX(nQ.paint_hillshade["hillshade-exaggeration"]),"hillshade-shadow-color":new nX(nQ.paint_hillshade["hillshade-shadow-color"]),"hillshade-highlight-color":new nX(nQ.paint_hillshade["hillshade-highlight-color"]),"hillshade-accent-color":new nX(nQ.paint_hillshade["hillshade-accent-color"]),"hillshade-emissive-strength":new nX(nQ.paint_hillshade["hillshade-emissive-strength"]),"hillshade-shadow-color-use-theme":new nY({type:"string",default:"default","property-type":"data-driven"}),"hillshade-highlight-color-use-theme":new nY({type:"string",default:"default","property-type":"data-driven"}),"hillshade-accent-color-use-theme":new nY({type:"string",default:"default","property-type":"data-driven"})}))},i,r,a)}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,i,r){return{overrideFog:!1}}},fill:class extends oo{constructor(e,i,r,a){super(e,{layout:x||(x=new nJ({"fill-sort-key":new nY(nQ.layout_fill["fill-sort-key"]),visibility:new nX(nQ.layout_fill.visibility),"fill-elevation-reference":new nX(nQ.layout_fill["fill-elevation-reference"]),"fill-construct-bridge-guard-rail":new nY(nQ.layout_fill["fill-construct-bridge-guard-rail"])})),paint:v||(v=new nJ({"fill-antialias":new nX(nQ.paint_fill["fill-antialias"]),"fill-opacity":new nY(nQ.paint_fill["fill-opacity"]),"fill-color":new nY(nQ.paint_fill["fill-color"]),"fill-outline-color":new nY(nQ.paint_fill["fill-outline-color"]),"fill-translate":new nX(nQ.paint_fill["fill-translate"]),"fill-translate-anchor":new nX(nQ.paint_fill["fill-translate-anchor"]),"fill-pattern":new nY(nQ.paint_fill["fill-pattern"]),"fill-pattern-cross-fade":new nX(nQ.paint_fill["fill-pattern-cross-fade"]),"fill-emissive-strength":new nX(nQ.paint_fill["fill-emissive-strength"]),"fill-z-offset":new nY(nQ.paint_fill["fill-z-offset"]),"fill-bridge-guard-rail-color":new nY(nQ.paint_fill["fill-bridge-guard-rail-color"]),"fill-tunnel-structure-color":new nY(nQ.paint_fill["fill-tunnel-structure-color"]),"fill-color-use-theme":new nY({type:"string",default:"default","property-type":"data-driven"}),"fill-outline-color-use-theme":new nY({type:"string",default:"default","property-type":"data-driven"}),"fill-bridge-guard-rail-color-use-theme":new nY({type:"string",default:"default","property-type":"data-driven"}),"fill-tunnel-structure-color-use-theme":new nY({type:"string",default:"default","property-type":"data-driven"})}))},i,r,a)}getProgramIds(){let e=this.paint.get("fill-pattern"),i=e&&e.constantOr(1),r=[i?"fillPattern":"fill"];return this.paint.get("fill-antialias")&&r.push(i&&!this.getPaintProperty("fill-outline-color")?"fillOutlinePattern":"fillOutline"),r}getDefaultProgramParams(e,i,r){return{config:new sI(this,{zoom:i,lut:r}),overrideFog:!1}}recalculate(e,i){super.recalculate(e,i);let r=this.paint._values["fill-outline-color"];"constant"===r.value.kind&&void 0===r.value.value&&(this.paint._values["fill-outline-color"]=this.paint._values["fill-color"])}createBucket(e){return new h0(e)}queryRadius(){return lz(this.paint.get("fill-translate"))}queryIntersectsFeature(e,i,r,a,n,o){return!e.queryGeometry.isAboveHorizon&&lx(lR(e.tilespaceGeometry,this.paint.get("fill-translate"),this.paint.get("fill-translate-anchor"),o.angle,e.pixelToTileUnitsFactor),a)}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;
7let i=this.layout&&"none"!==this.layout.get("fill-elevation-reference");return null!=e?i&&!e:i}hasElevation(){return this.layout&&"none"!==this.layout.get("fill-elevation-reference")}hasShadowPass(){return this.layout&&"none"!==this.layout.get("fill-elevation-reference")}},"fill-extrusion":class extends oo{constructor(e,i,r,a){super(e,{layout:T||(T=new nJ({visibility:new nX(nQ["layout_fill-extrusion"].visibility),"fill-extrusion-edge-radius":new nX(nQ["layout_fill-extrusion"]["fill-extrusion-edge-radius"])})),paint:S||(S=new nJ({"fill-extrusion-opacity":new nX(nQ["paint_fill-extrusion"]["fill-extrusion-opacity"]),"fill-extrusion-color":new nY(nQ["paint_fill-extrusion"]["fill-extrusion-color"]),"fill-extrusion-translate":new nX(nQ["paint_fill-extrusion"]["fill-extrusion-translate"]),"fill-extrusion-translate-anchor":new nX(nQ["paint_fill-extrusion"]["fill-extrusion-translate-anchor"]),"fill-extrusion-pattern":new nY(nQ["paint_fill-extrusion"]["fill-extrusion-pattern"]),"fill-extrusion-pattern-cross-fade":new nX(nQ["paint_fill-extrusion"]["fill-extrusion-pattern-cross-fade"]),"fill-extrusion-height":new nY(nQ["paint_fill-extrusion"]["fill-extrusion-height"]),"fill-extrusion-base":new nY(nQ["paint_fill-extrusion"]["fill-extrusion-base"]),"fill-extrusion-height-alignment":new nX(nQ["paint_fill-extrusion"]["fill-extrusion-height-alignment"]),"fill-extrusion-base-alignment":new nX(nQ["paint_fill-extrusion"]["fill-extrusion-base-alignment"]),"fill-extrusion-vertical-gradient":new nX(nQ["paint_fill-extrusion"]["fill-extrusion-vertical-gradient"]),"fill-extrusion-ambient-occlusion-intensity":new nX(nQ["paint_fill-extrusion"]["fill-extrusion-ambient-occlusion-intensity"]),"fill-extrusion-ambient-occlusion-radius":new nX(nQ["paint_fill-extrusion"]["fill-extrusion-ambient-occlusion-radius"]),"fill-extrusion-ambient-occlusion-wall-radius":new nX(nQ["paint_fill-extrusion"]["fill-extrusion-ambient-occlusion-wall-radius"]),"fill-extrusion-ambient-occlusion-ground-radius":new nX(nQ["paint_fill-extrusion"]["fill-extrusion-ambient-occlusion-ground-radius"]),"fill-extrusion-ambient-occlusion-ground-attenuation":new nX(nQ["paint_fill-extrusion"]["fill-extrusion-ambient-occlusion-ground-attenuation"]),"fill-extrusion-flood-light-color":new nX(nQ["paint_fill-extrusion"]["fill-extrusion-flood-light-color"]),"fill-extrusion-flood-light-intensity":new nX(nQ["paint_fill-extrusion"]["fill-extrusion-flood-light-intensity"]),"fill-extrusion-flood-light-wall-radius":new nY(nQ["paint_fill-extrusion"]["fill-extrusion-flood-light-wall-radius"]),"fill-extrusion-flood-light-ground-radius":new nY(nQ["paint_fill-extrusion"]["fill-extrusion-flood-light-ground-radius"]),"fill-extrusion-flood-light-ground-attenuation":new nX(nQ["paint_fill-extrusion"]["fill-extrusion-flood-light-ground-attenuation"]),"fill-extrusion-vertical-scale":new nX(nQ["paint_fill-extrusion"]["fill-extrusion-vertical-scale"]),"fill-extrusion-rounded-roof":new nX(nQ["paint_fill-extrusion"]["fill-extrusion-rounded-roof"]),"fill-extrusion-cutoff-fade-range":new nX(nQ["paint_fill-extrusion"]["fill-extrusion-cutoff-fade-range"]),"fill-extrusion-emissive-strength":new nY(nQ["paint_fill-extrusion"]["fill-extrusion-emissive-strength"]),"fill-extrusion-line-width":new nY(nQ["paint_fill-extrusion"]["fill-extrusion-line-width"]),"fill-extrusion-cast-shadows":new nX(nQ["paint_fill-extrusion"]["fill-extrusion-cast-shadows"]),"fill-extrusion-color-use-theme":new nY({type:"string",default:"default","property-type":"data-driven"}),"fill-extrusion-flood-light-color-use-theme":new nY({type:"string",default:"default","property-type":"data-driven"})}))},i,r,a),this._stats={numRenderedVerticesInShadowPass:0,numRenderedVerticesInTransparentPass:0}}createBucket(e){return new uC(e)}queryRadius(){return lz(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,i,r,a,n,o,s,l,h){var u,c,d,p;let f=lD(this.paint.get("fill-extrusion-translate"),this.paint.get("fill-extrusion-translate-anchor"),o.angle,e.pixelToTileUnitsFactor),m=this.paint.get("fill-extrusion-height").evaluate(i,r),_=this.paint.get("fill-extrusion-base").evaluate(i,r),g=[0,0],y=l&&o.elevation,x=o.elevation?o.elevation.exaggeration():1,v=e.tile.getBucket(this);if(y&&v instanceof uC){let e=v.centroidVertexArray,i=h+1;i<e.length&&(g[0]=e.geta_centroid_pos0(i),g[1]=e.geta_centroid_pos1(i))}if(0===g[0]&&1===g[1])return!1;"globe"===o.projection.name&&(a=uF([a],[new e3(0,0),new e3(8192,8192)],e.tileID.canonical).map(e=>e.polygon).flat());let[b,w]=(u=a,c=y?l:null,d=o.center.lat,p=e.tileID.canonical,"globe"===o.projection.name?function(e,i,r,a,n,o,s,l,h,u,c){let d=[],p=[],f=e.projection.upVectorScale(c,e.center.lat,e.worldSize).metersToTile,m=[0,0,0,1],_=[0,0,0,1],g=(e,i,r,a)=>{e[0]=i,e[1]=r,e[2]=a,e[3]=1},y=uO();for(let x of(r>0&&(r+=y),a+=y,i)){let i=[],y=[];for(let d of x){let p=d.x+n.x,x=d.y+n.y,v=e.projection.projectTilePoint(p,x,c),b=e.projection.upVector(c,d.x,d.y),w=r,T=a;if(s){let e=u$(p,x,r,a,s,l,h,u);w+=e.base,T+=e.top}0!==r?g(m,v.x+b[0]*f*w,v.y+b[1]*f*w,v.z+b[2]*f*w):g(m,v.x,v.y,v.z),g(_,v.x+b[0]*f*T,v.y+b[1]*f*T,v.z+b[2]*f*T),eP(m,m,o),eP(_,_,o),i.push(new uk(m[0],m[1],m[2])),y.push(new uk(_[0],_[1],_[2]))}d.push(i),p.push(y)}
7return[d,p]}(o,u,_,m,f,s,c,g,x,d,p):c?function(e,i,r,a,n,o,s,l,h){let u=[],c=[],d=[0,0,0,1];for(let p of e){let e=[],f=[];for(let u of p){let c=u.x+a.x,p=u.y+a.y,m=u$(c,p,i,r,o,s,l,h);d[0]=c,d[1]=p,d[2]=m.base,d[3]=1,eB(d,d,n),d[3]=Math.max(d[3],1e-5);let _=new uk(d[0]/d[3],d[1]/d[3],d[2]/d[3]);d[0]=c,d[1]=p,d[2]=m.top,d[3]=1,eB(d,d,n),d[3]=Math.max(d[3],1e-5);let g=new uk(d[0]/d[3],d[1]/d[3],d[2]/d[3]);e.push(_),f.push(g)}u.push(e),c.push(f)}return[u,c]}(u,_,m,f,s,c,g,x,d):function(e,i,r,a,n){let o=[],s=[],l=n[8]*i,h=n[9]*i,u=n[10]*i,c=n[11]*i,d=n[8]*r,p=n[9]*r,f=n[10]*r,m=n[11]*r;for(let i of e){let e=[],r=[];for(let o of i){let i=o.x+a.x,s=o.y+a.y,_=n[0]*i+n[4]*s+n[12],g=n[1]*i+n[5]*s+n[13],y=n[2]*i+n[6]*s+n[14],x=n[3]*i+n[7]*s+n[15],v=_+l,b=g+h,w=y+u,T=Math.max(x+c,1e-5),S=_+d,E=g+p,I=y+f,A=Math.max(x+m,1e-5);e.push(new uk(v/T,b/T,w/T)),r.push(new uk(S/A,E/A,I/A))}o.push(e),s.push(r)}return[o,s]}(u,_,m,f,s)),T=e.queryGeometry;return function(e,i,r){let a=1/0;lx(r,i)&&(a=uq(r,i[0]));for(let n=0;n<i.length;n++){let o=i[n],s=e[n];for(let e=0;e<o.length-1;e++){let i=o[e],n=[i,o[e+1],s[e+1],s[e],i];ly(r,n)&&(a=Math.min(a,uq(r,n)))}}return a!==1/0&&a}(b,w,T.isPointQuery()?T.screenBounds:T.screenGeometry)}},building:class extends oo{constructor(e,i,r,a){super(e,{layout:A||(A=new nJ({visibility:new nX(nQ.layout_building.visibility),"building-facade":new nY(nQ.layout_building["building-facade"]),"building-facade-floors":new nY(nQ.layout_building["building-facade-floors"]),"building-facade-unit-width":new nY(nQ.layout_building["building-facade-unit-width"]),"building-facade-window":new nY(nQ.layout_building["building-facade-window"]),"building-roof-shape":new nY(nQ.layout_building["building-roof-shape"]),"building-height":new nY(nQ.layout_building["building-height"]),"building-base":new nY(nQ.layout_building["building-base"]),"building-flood-light-wall-radius":new nY(nQ.layout_building["building-flood-light-wall-radius"]),"building-flood-light-ground-radius":new nY(nQ.layout_building["building-flood-light-ground-radius"]),"building-flip-roof-orientation":new nY(nQ.layout_building["building-flip-roof-orientation"])})),paint:C||(C=new nJ({"building-opacity":new nX(nQ.paint_building["building-opacity"]),"building-ambient-occlusion-intensity":new nX(nQ.paint_building["building-ambient-occlusion-intensity"]),"building-ambient-occlusion-ground-intensity":new nX(nQ.paint_building["building-ambient-occlusion-ground-intensity"]),"building-ambient-occlusion-ground-radius":new nX(nQ.paint_building["building-ambient-occlusion-ground-radius"]),"building-ambient-occlusion-ground-attenuation":new nX(nQ.paint_building["building-ambient-occlusion-ground-attenuation"]),"building-vertical-scale":new nX(nQ.paint_building["building-vertical-scale"]),"building-cast-shadows":new nX(nQ.paint_building["building-cast-shadows"]),"building-color":new nY(nQ.paint_building["building-color"]),"building-emissive-strength":new nY(nQ.paint_building["building-emissive-strength"]),"building-facade-emissive-chance":new nX(nQ.paint_building["building-facade-emissive-chance"]),"building-cutoff-fade-range":new nX(nQ.paint_building["building-cutoff-fade-range"]),"building-flood-light-color":new nX(nQ.paint_building["building-flood-light-color"]),"building-flood-light-intensity":new nX(nQ.paint_building["building-flood-light-intensity"]),"building-flood-light-ground-attenuation":new nX(nQ.paint_building["building-flood-light-ground-attenuation"]),"building-color-use-theme":new nY({type:"string",default:"default","property-type":"data-driven"}),"building-flood-light-color-use-theme":new nY({type:"string",default:"default","property-type":"data-driven"})}))},i,r,a),this._stats={numRenderedVerticesInShadowPass:0,numRenderedVerticesInTransparentPass:0}}createBucket(e){return new c0(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}},line:class extends oo{constructor(e,i,r,a){let n=dh();super(e,n,i,r,a),n.layout&&(this.layout=new nW(n.layout)),this.gradientVersion=0,this.hasElevatedBuckets=!1,this.hasNonElevatedBuckets=!1}_handleSpecialPaintPropertyUpdate(e){if("line-gradient"===e){let e=this._transitionablePaint._values["line-gradient"].value.expression;this.stepInterpolant=e._styleExpression&&e._styleExpression.expression instanceof rK,this.gradientVersion=(this.gradientVersion+1)%Number.MAX_SAFE_INTEGER}}gradientExpression(){return this._transitionablePaint._values["line-gradient"].value.expression}widthExpression(){return this._transitionablePaint._values["line-width"].value.expression}recalculate(e,i){super.recalculate(e,i),this.paint._values["line-floorwidth"]=(R||((R=new du(dh().paint.properties["line-width"].specification)).useIntegerZoom=!0),R).possiblyEvaluate(this._transitioningPaint._values["line-width"].value,e)}createBucket(e){return new de(e)}getProgramIds(){return[this.paint.get("line-pattern").constantOr(1)?"linePattern":"line"]}getDefaultProgramParams(e,i,r){let a=ds(this);return{config:new sI(this,{zoom:i,lut:r}),defines:a,overrideFog:!1}}queryRadius(e){var i,r;return i=lP("line-width",this,e),((r=lP("line-gap-width",this,e))>0?r+2*i:i)/2+Math.abs(lP("line-offset",this,e))+lz(this.paint.get("line-translate"))}queryIntersectsFeature(e,i,r,a,n,o){var s,l;if(e.queryGeometry.isAboveHorizon)return!1;let h=lR(e.tilespaceGeometry,this.paint.get("line-translate"),this.paint.get("line-translate-anchor"),o.angle,e.pixelToTileUnitsFactor),u=e.pixelToTileUnitsFactor/2*(s=this.paint.get("line-width").evaluate(i,r),(l=this.paint.get("line-gap-width").evaluate(i,r))>0?l+2*s:s),c=this.paint.get("line-offset").evaluate(i,r);return c&&(a=function(e,i){let r=[],a=new e3(0,0);for(let n=0;n<e.length;n++){let o=e[n],s=[];for(let e=0;e<o.length;e++){let r=o[e],n=o[e+1],l=0===e?a:r.sub(o[e-1])._unit()._perp(),h=e===o.length-1?a:n.sub(r)._unit()._perp(),u=l._add(h)._unit();u._mult(1/(u.x*h.x+u.y*h.y)),s.push(u._mult(i)._add(r))}r.push(s)}return r}(a,c*e.pixelToTileUnitsFactor)),function(e,i,r){for(let a=0;a<i.length;a++){let n=i[a];if(e.length>=3){for(let i=0;i<n.length;
7i++)if(lE(e,n[i]))return!0}if(function(e,i,r){if(e.length>1){if(lv(e,i))return!0;for(let a=0;a<i.length;a++)if(lw(i[a],e,r))return!0}for(let a=0;a<e.length;a++)if(lw(e[a],i,r))return!0;return!1}(e,n,r))return!0}return!1}(h,a,u)}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:p2,background:class extends oo{constructor(e,i,r,a){super(e,{layout:F||(F=new nJ({visibility:new nX(nQ.layout_background.visibility)})),paint:k||(k=new nJ({"background-pitch-alignment":new nX(nQ.paint_background["background-pitch-alignment"]),"background-color":new nX(nQ.paint_background["background-color"]),"background-pattern":new nX(nQ.paint_background["background-pattern"]),"background-opacity":new nX(nQ.paint_background["background-opacity"]),"background-emissive-strength":new nX(nQ.paint_background["background-emissive-strength"]),"background-color-use-theme":new nY({type:"string",default:"default","property-type":"data-driven"})}))},i,r,a)}getProgramIds(){return[this.paint.get("background-pattern")?"backgroundPattern":"background"]}getDefaultProgramParams(e,i,r){return{overrideFog:!1}}is3D(e){return"viewport"===this.paint.get("background-pitch-alignment")}},raster:p9,"raster-particle":p7,sky:class extends oo{constructor(e,i,r,a){super(e,{layout:j||(j=new nJ({visibility:new nX(nQ.layout_sky.visibility)})),paint:G||(G=new nJ({"sky-type":new nX(nQ.paint_sky["sky-type"]),"sky-atmosphere-sun":new nX(nQ.paint_sky["sky-atmosphere-sun"]),"sky-atmosphere-sun-intensity":new nX(nQ.paint_sky["sky-atmosphere-sun-intensity"]),"sky-gradient-center":new nX(nQ.paint_sky["sky-gradient-center"]),"sky-gradient-radius":new nX(nQ.paint_sky["sky-gradient-radius"]),"sky-gradient":new nK(nQ.paint_sky["sky-gradient"]),"sky-atmosphere-halo-color":new nX(nQ.paint_sky["sky-atmosphere-halo-color"]),"sky-atmosphere-color":new nX(nQ.paint_sky["sky-atmosphere-color"]),"sky-opacity":new nX(nQ.paint_sky["sky-opacity"]),"sky-gradient-use-theme":new nY({type:"string",default:"default","property-type":"data-driven"}),"sky-atmosphere-halo-color-use-theme":new nY({type:"string",default:"default","property-type":"data-driven"}),"sky-atmosphere-color-use-theme":new nY({type:"string",default:"default","property-type":"data-driven"})}))},i,r,a),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=h_({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")){let i=e.style.light.properties.get("position");return this._lightPosition.azimuthal!==i.azimuthal||this._lightPosition.polar!==i.polar}return!1}getCenter(e,i){if("atmosphere"===this.paint.get("sky-type")){let r=this.paint.get("sky-atmosphere-sun"),a=!r,n=e.style.light,o=n.properties.get("position");return a&&"viewport"===n.properties.get("anchor")&&tf("The sun direction is attached to a light with viewport anchor, lighting may behave unexpectedly."),a?ft(o.azimuthal,90-o.polar,i):ft(r[0],90-r[1],i)}let r=this.paint.get("sky-gradient-center");return ft(r[0],90-r[1],i)}isSky(){return!0}markSkyboxValid(e){this._skyboxInvalidated=!1,this._lightPosition=e.style.light.properties.get("position")}hasOffscreenPass(){return!0}getProgramIds(){let e=this.paint.get("sky-type");return"atmosphere"===e?["skyboxCapture","skybox"]:"gradient"===e?["skyboxGradient"]:null}},slot:class extends oo{constructor(e,i,r,a){super(e,{paint:q||(q=new nJ({}))},i,null)}},model:class extends oo{constructor(e,i,r,a){super(e,{layout:$||($=new nJ({visibility:new nX(nQ.layout_model.visibility),"model-id":new nY(nQ.layout_model["model-id"])})),paint:H||(H=new nJ({"model-opacity":new nY(nQ.paint_model["model-opacity"]),"model-rotation":new nY(nQ.paint_model["model-rotation"]),"model-scale":new nY(nQ.paint_model["model-scale"]),"model-translation":new nY(nQ.paint_model["model-translation"]),"model-color":new nY(nQ.paint_model["model-color"]),"model-color-mix-intensity":new nY(nQ.paint_model["model-color-mix-intensity"]),"model-type":new nX(nQ.paint_model["model-type"]),"model-cast-shadows":new nX(nQ.paint_model["model-cast-shadows"]),"model-receive-shadows":new nX(nQ.paint_model["model-receive-shadows"]),"model-ambient-occlusion-intensity":new nX(nQ.paint_model["model-ambient-occlusion-intensity"]),"model-emissive-strength":new nY(nQ.paint_model["model-emissive-strength"]),"model-roughness":new nY(nQ.paint_model["model-roughness"]),"model-height-based-emissive-strength-multiplier":new nY(nQ.paint_model["model-height-based-emissive-strength-multiplier"]),"model-cutoff-fade-range":new nX(nQ.paint_model["model-cutoff-fade-range"]),"model-front-cutoff":new nX(nQ.paint_model["model-front-cutoff"]),"model-elevation-reference":new nX(nQ.paint_model["model-elevation-reference"]),"model-color-use-theme":new nY({type:"string",default:"default","property-type":"data-driven"})}))},i,r,a),this._stats={numRenderedVerticesInShadowPass:0,numRenderedVerticesInTransparentPass:0}}createBucket(e){return new fs(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 8191*(e instanceof fp)}queryIntersectsFeature(e,i,r,a,n,o){if(!this.modelManager)return!1;let s=this.modelManager,l=e.tile.getBucket(this);if(!(l&&l instanceof fs))return!1;for(let r in l.instancesPerModel){let a=l.instancesPerModel[r],n=void 0!==i.id?i.id:i.properties&&i.properties.hasOwnProperty("id")?i.properties.id:void 0;if(a.idToFeaturesIndex.hasOwnProperty(n)){let i=a.features[a.idToFeaturesIndex[n]],h=s.getModel(r,this.scope);if(!h)return!1;let u=Q(),c=new sB(0,0),d=l.canonical,p=Number.MAX_VALUE;for(let r=0;r<i.instancedDataCount;++r){let n=16*(i.instancedDataOffset+r),s=a.instancedDataArray.float32,l=[s[n+4],s[n+5],s[n+6]];fm(d,c,s[n],0|s[n+1]),cL(u,h,o,c,i.rotation,i.scale,l,!1,!1,!1),"globe"===o.projection.name&&(u=cz(u,o));let f=ei([],o.projMatrix,u),m=e.queryGeometry,_=cR(m.isPointQuery()?m.screenBounds:m.screenGeometry,o,f,h.aabb);null!=_&&(p=Math.min(_,p))}return p!==Number.MAX_VALUE&&p}}return!1}_handleOverridablePaintPropertyUpdate(e,i,r){return!(!this.layout||i.isDataDriven()||r.isDataDriven()||"model-color"!==e&&"model-color-mix-intensity"!==e&&"model-rotation"!==e&&"model-scale"!==e&&"model-translation"!==e&&"model-emissive-strength"!==e)}_isPropertyZoomDependent(e){let i=this._transitionablePaint._values[e];return null!=i&&null!=i.value&&null!=i.value.expression&&i.value.expression instanceof aY}isZoomDependent(){return this._isPropertyZoomDependent("model-scale")||this._isPropertyZoomDependent("model-rotation")||this._isPropertyZoomDependent("model-translation")}},clip:class extends oo{constructor(e,i,r,a){super(e,{layout:b||(b=ne
7w nJ({"clip-layer-types":new nX(nQ.layout_clip["clip-layer-types"]),"clip-layer-scope":new nX(nQ.layout_clip["clip-layer-scope"])})),paint:w||(w=new nJ({}))},i,r,a)}recalculate(e,i){super.recalculate(e,i)}createBucket(e){return new h3(e)}is3D(e){return!0}}},fg=new ih(0,0,0);function fy(e,i,r){var a;1===e&&i.icons.push((a=r.readVarint()+r.pos,function(e){if(e.usvg_tree.height||(e.usvg_tree.height=e.usvg_tree.width),!e.metadata)return e;let{metadata:i}=e;if(i.content_area){let{content_area:r}=i;null==r.left&&(r.left=0),null==r.top&&(r.top=r.left),null==r.width&&(r.width=e.usvg_tree.width),null==r.height&&(r.height=r.width)}if(i.text_placeholder){let{text_placeholder:e}=i;null==e.top&&(e.top=e.left),null==e.height&&(e.height=e.width)}return i.stretch_x&&i.stretch_x.length&&fx(i,"x"),i.stretch_y&&i.stretch_y.length&&fx(i,"y"),e}(r.readFields(fv,{name:void 0},a))))}function fx(e,i){let r=[],a=e[`stretch_${i}`],n=null;for(let e=0;e<a.length;e++)null===n?n=0===r.length?a[0]:r[r.length-1][1]+a[e]:(r.push([n,n+a[e]]),n=null);e[`stretch_${i}_areas`]=r}function fv(e,i,r){var a,n;1===e?i.name=r.readString():2===e?(a=r.readVarint()+r.pos,i.metadata=r.readFields(fb,{stretch_x:null,stretch_y:null,stretch_x_areas:null,stretch_y_areas:null,variables:[]},a)):3===e&&(n=r.readVarint()+r.pos,i.usvg_tree=r.readFields(fE,{width:20,children:[],linear_gradients:[],radial_gradients:[],clip_paths:[],masks:[]},n),i.data="usvg_tree")}function fb(e,i,r){var a;1===e?i.stretch_x=r.readPackedVarint():2===e?i.stretch_y=r.readPackedVarint():3===e?i.content_area=fw(r,r.readVarint()+r.pos):4===e?i.variables.push((a=r.readVarint()+r.pos,r.readFields(fS,{name:void 0},a))):5===e&&(i.text_placeholder=fw(r,r.readVarint()+r.pos))}function fw(e,i){return e.readFields(fT,{},i)}function fT(e,i,r){1===e?i.left=r.readVarint():2===e?i.width=r.readVarint():3===e?i.top=r.readVarint():4===e&&(i.height=r.readVarint())}function fS(e,i,r){1===e?i.name=r.readString():2===e&&(i.rgb_color=fD(r.readVarint()),i.value="rgb_color")}function fE(e,i,r){var a,n,o;1===e?i.width=i.height=r.readVarint():2===e?i.height=r.readVarint():3===e?i.children.push(fI(r,r.readVarint()+r.pos)):4===e?i.linear_gradients.push((a=r.readVarint()+r.pos,r.readFields(fO,{spread_method:1,stops:[],x1:0,y1:0,x2:1,y2:0},a))):5===e?i.radial_gradients.push((n=r.readVarint()+r.pos,r.readFields(fB,{spread_method:1,stops:[],cx:.5,cy:.5,r:.5,fx:.5,fy:.5,fr:0},n))):7===e?i.clip_paths.push((o=r.readVarint()+r.pos,r.readFields(fN,{children:[]},o))):8===e&&i.masks.push(function(e,i){let r=e.readFields(fV,{left:0,width:20,mask_type:1,children:[]},i);return null==r.height&&(r.height=r.width),null==r.top&&(r.top=r.left),r}(r,r.readVarint()+r.pos))}function fI(e,i){return e.readFields(fA,{},i)}function fA(e,i,r){var a,n;1===e?(a=r.readVarint()+r.pos,i.group=r.readFields(fC,{opacity:255,children:[]},a),i.node="group"):2===e&&(n=r.readVarint()+r.pos,i.path=r.readFields(fz,{paint_order:1,commands:[],step:1,diffs:[],rule:1},n),i.node="path")}function fC(e,i,r){1===e?i.transform=fM(r,r.readVarint()+r.pos):2===e?i.opacity=r.readVarint():5===e?i.clip_path_idx=r.readVarint():6===e?i.mask_idx=r.readVarint():7===e&&i.children.push(fI(r,r.readVarint()+r.pos))}function fM(e,i){return e.readFields(fP,{sx:1,ky:0,kx:0,sy:1,tx:0,ty:0},i)}function fP(e,i,r){1===e?i.sx=r.readFloat():2===e?i.ky=r.readFloat():3===e?i.kx=r.readFloat():4===e?i.sy=r.readFloat():5===e?i.tx=r.readFloat():6===e&&(i.ty=r.readFloat())}function fz(e,i,r){var a,n;1===e?(a=r.readVarint()+r.pos,i.fill=r.readFields(fR,{rgb_color:fg,paint:"rgb_color",opacity:255},a)):2===e?(n=r.readVarint()+r.pos,i.stroke=r.readFields(fL,{rgb_color:fg,paint:"rgb_color",dasharray:[],dashoffset:0,miterlimit:4,opacity:255,width:1,linecap:1,linejoin:1},n)):3===e?i.paint_order=r.readVarint():5===e?r.readPackedVarint(i.commands):6===e?i.step=r.readFloat():7===e?r.readPackedSVarint(i.diffs):8===e&&(i.rule=r.readVarint())}function fR(e,i,r){1===e?(i.rgb_color=fD(r.readVarint()),i.paint="rgb_color"):2===e?(i.linear_gradient_idx=r.readVarint(),i.paint="linear_gradient_idx"):3===e?(i.radial_gradient_idx=r.readVarint(),i.paint="radial_gradient_idx"):5===e&&(i.op
7acity=r.readVarint())}function fD(e){return new ih((e>>16&255)/255,(e>>8&255)/255,(255&e)/255,1)}function fL(e,i,r){1===e?(i.rgb_color=fD(r.readVarint()),i.paint="rgb_color"):2===e?(i.linear_gradient_idx=r.readVarint(),i.paint="linear_gradient_idx"):3===e?(i.radial_gradient_idx=r.readVarint(),i.paint="radial_gradient_idx"):5===e?r.readPackedFloat(i.dasharray):6===e?i.dashoffset=r.readFloat():7===e?i.miterlimit=r.readFloat():8===e?i.opacity=r.readVarint():9===e?i.width=r.readFloat():10===e?i.linecap=r.readVarint():11===e&&(i.linejoin=r.readVarint())}function fO(e,i,r){1===e?i.transform=fM(r,r.readVarint()+r.pos):2===e?i.spread_method=r.readVarint():3===e?i.stops.push(fF(r,r.readVarint()+r.pos)):4===e?i.x1=r.readFloat():5===e?i.y1=r.readFloat():6===e?i.x2=r.readFloat():7===e&&(i.y2=r.readFloat())}function fF(e,i){return e.readFields(fk,{offset:0,opacity:255,rgb_color:fg},i)}function fk(e,i,r){1===e?i.offset=r.readFloat():2===e?i.opacity=r.readVarint():3===e&&(i.rgb_color=fD(r.readVarint()))}function fB(e,i,r){1===e?i.transform=fM(r,r.readVarint()+r.pos):2===e?i.spread_method=r.readVarint():3===e?i.stops.push(fF(r,r.readVarint()+r.pos)):4===e?i.cx=r.readFloat():5===e?i.cy=r.readFloat():6===e?i.r=r.readFloat():7===e?i.fx=r.readFloat():8===e?i.fy=r.readFloat():9===e&&(i.fr=r.readFloat())}function fN(e,i,r){1===e?i.transform=fM(r,r.readVarint()+r.pos):2===e?i.clip_path_idx=r.readVarint():3===e&&i.children.push(fI(r,r.readVarint()+r.pos))}function fV(e,i,r){1===e?i.left=i.top=r.readFloat():2===e?i.width=i.height=r.readFloat():3===e?i.top=r.readFloat():4===e?i.height=r.readFloat():5===e?i.mask_type=r.readVarint():6===e?i.mask_idx=r.readVarint():7===e&&i.children.push(fI(r,r.readVarint()+r.pos))}class fU{static calculate(e={},i=[]){let r=new Map,a=new Map;if(0===Object.keys(e).length)return r;for(let[n,o]of(i.forEach(e=>{a.set(e.name,e.rgb_color||new ih(0,0,0))}),Object.entries(e)))a.has(n)?r.set(a.get(n).toString(),o):console.warn(`Ignoring unknown image variable "${n}"`);return r}}function fj(e,i=255,r){let a=e.toString(),n=r.has(a)?r.get(a).clone():e.clone();return n.a*=i/255,n.toString()}function fG(e,i){if(!tM()){let r=document.createElement("canvas");return r.width=e,r.height=i,r}return new OffscreenCanvas(e,i)}function fq(e,i){let r=fU.calculate(i.params,e.metadata?e.metadata.variables:[]),a=e.usvg_tree,n=a.width,o=a.height,s=i.transform?i.transform:new DOMMatrix,l=Math.max(1,Math.round(n*s.a)),h=Math.max(1,Math.round(o*s.d)),u=new DOMMatrix([l/n,0,0,h/o,0,0]),c=fG(l,h).getContext("2d");return f$(c,u,a,a,r),c.getImageData(0,0,l,h)}function f$(e,i,r,a,n){for(let o of a.children)(function e(i,r,a,n,o){var s;n.group?(i.save(),function(i,r,a,n,o){var s,l;let h=null!=n.mask_idx?a.masks[n.mask_idx]:null,u=null!=n.clip_path_idx?a.clip_paths[n.clip_path_idx]:null;if(n.transform&&(r=fK(n.transform).preMultiplySelf(r)),s=null!=u,l=null!=h,255===n.opacity&&!s&&!l)return f$(i,r,a,n,o);let c=fG(i.canvas.width,i.canvas.height),d=c.getContext("2d");f$(d,r,a,n,o),u&&function e(i,r,a,n){let o=fG(i.canvas.width,i.canvas.height);(function i(r,a,n,o){let s=o.transform?fK(o.transform).preMultiplySelf(a):a,l=fG(r.canvas.width,r.canvas.height),h=l.getContext("2d");for(let e of o.children)if(e.group)i(h,s,n,e.group);else if(e.path){let i=e.path,r=new Path2D;r.addPath(fQ(i),s),h.fill(r,fZ(i))}let u=null!=o.clip_path_idx?n.clip_paths[o.clip_path_idx]:null;u&&e(h,s,n,u),r.globalCompositeOperation="source-over",r.drawImage(l,0,0)})(o.getContext("2d"),r,a,n),i.globalCompositeOperation="destination-in",i.drawImage(o,0,0)}(d,r,a,u),h&&function i(r,a,n,o,s){if(0===o.children.length)return;let l=null!=o.mask_idx?n.masks[o.mask_idx]:null;l&&i(r,a,n,l,s);let h=r.canvas.width,u=r.canvas.height,c=fG(h,u),d=c.getContext("2d"),p=o.width,f=o.height,m=o.left,_=o.top,g=new Path2D,y=new Path2D;for(let i of(y.rect(m,_,p,f),g.addPath(y,a),d.clip(g),o.children))e(d,a,n,i,s);let x=d.getImageData(0,0,h,u),v=x.data;if(1===o.mask_type)for(let e=0;e<v.length;e+=4)v[e+3]=v[e+3]/255*(.2126*v[e]+.7152*v[e+1]+.0722*v[e+2]);d.putImageData(x,0,0),r.globalCompositeOperation="destination-in",r.drawImage(c,0,0)}(d,r,a,h,o),i.globalAlpha=n.opacity/255,i.drawImage(c,0,0)}
7(i,r,a,n.group,o),i.restore()):n.path&&(i.save(),s=n.path,i.setTransform(r),1===s.paint_order?(fH(i,a,s,o),fW(i,a,s,o)):(fW(i,a,s,o),fH(i,a,s,o)),i.restore())})(e,i,r,o,n)}function fH(e,i,r,a){let n=r.fill;if(!n)return;let o=n.opacity/255;switch(e.save(),e.beginPath(),fJ(r,e),n.paint){case"rgb_color":e.fillStyle=fj(n.rgb_color,n.opacity,a);break;case"linear_gradient_idx":{let r=i.linear_gradients[n.linear_gradient_idx];r.transform&&e.setTransform(fK(r.transform).preMultiplySelf(e.getTransform())),e.fillStyle=fX(e,r,o,a);break}case"radial_gradient_idx":{let r=i.radial_gradients[n.radial_gradient_idx];r.transform&&e.setTransform(fK(r.transform).preMultiplySelf(e.getTransform())),e.fillStyle=fY(e,r,o,a)}}e.fill(fZ(r)),e.restore()}function fZ(e){return 1===e.rule?"nonzero":2===e.rule?"evenodd":void 0}function fW(e,i,r,a){let n=r.stroke;if(!n)return;let o=fQ(r);e.lineWidth=n.width,e.miterLimit=n.miterlimit,e.setLineDash(n.dasharray),e.lineDashOffset=n.dashoffset;let s=n.opacity/255;switch(n.paint){case"rgb_color":e.strokeStyle=fj(n.rgb_color,n.opacity,a);break;case"linear_gradient_idx":e.strokeStyle=fX(e,i.linear_gradients[n.linear_gradient_idx],s,a,!0);break;case"radial_gradient_idx":e.strokeStyle=fY(e,i.radial_gradients[n.radial_gradient_idx],s,a,!0)}switch(n.linejoin){case 2:case 1:e.lineJoin="miter";break;case 3:e.lineJoin="round";break;case 4:e.lineJoin="bevel"}switch(n.linecap){case 1:e.lineCap="butt";break;case 2:e.lineCap="round";break;case 3:e.lineCap="square"}e.stroke(o)}function fX(e,i,r,a,n=!1){if(1===i.stops.length){let e=i.stops[0];return fj(e.rgb_color,e.opacity*r,a)}let{x1:o,y1:s,x2:l,y2:h}=i,u=new DOMPoint(o,s),c=new DOMPoint(l,h);if(n){let e=fK(i.transform);u=e.transformPoint(u),c=e.transformPoint(c)}let d=e.createLinearGradient(u.x,u.y,c.x,c.y);for(let e of i.stops)d.addColorStop(e.offset,fj(e.rgb_color,e.opacity*r,a));return d}function fY(e,i,r,a,n=!1){if(1===i.stops.length){let e=i.stops[0];return fj(e.rgb_color,e.opacity*r,a)}let o=fK(i.transform),{fx:s,fy:l,fr:h,cx:u,cy:c,r:d}=i,p=new DOMPoint(s,l),f=new DOMPoint(u,c),m=h,_=d;if(n){p=o.transformPoint(p),f=o.transformPoint(f);let e=(o.a+o.d)/2;m=h*e,_=i.r*e}let g=e.createRadialGradient(p.x,p.y,m,f.x,f.y,_);for(let e of i.stops)g.addColorStop(e.offset,fj(e.rgb_color,e.opacity*r,a));return g}function fK(e){return e?new DOMMatrix([e.sx,e.ky,e.kx,e.sy,e.tx,e.ty]):new DOMMatrix}function fJ(e,i){let r=e.step,a=e.diffs[0]*r,n=e.diffs[1]*r;i.moveTo(a,n);for(let o=0,s=2;o<e.commands.length;o++)switch(e.commands[o]){case 1:a+=e.diffs[s++]*r,n+=e.diffs[s++]*r,i.moveTo(a,n);break;case 2:a+=e.diffs[s++]*r,n+=e.diffs[s++]*r,i.lineTo(a,n);break;case 3:{let o=a+e.diffs[s++]*r,l=n+e.diffs[s++]*r;a=o+e.diffs[s++]*r,n=l+e.diffs[s++]*r,i.quadraticCurveTo(o,l,a,n);break}case 4:{let o=a+e.diffs[s++]*r,l=n+e.diffs[s++]*r,h=o+e.diffs[s++]*r,u=l+e.diffs[s++]*r;a=h+e.diffs[s++]*r,n=u+e.diffs[s++]*r,i.bezierCurveTo(o,l,h,u,a,n);break}case 5:i.closePath()}return i}function fQ(e){return fJ(e,new Path2D)}class f0{constructor(e){this.capacity=e,this.cache=new Map}get(e){if(!this.cache.has(e))return;let i=this.cache.get(e);return this.cache.delete(e),this.cache.set(e,i),i}put(e,i){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,i)}delete(e){this.cache.delete(e)}}a3(f0,"LRUCache");class f1{constructor(){this.cacheMap=new Map,this.cacheDependenciesMap=new Map}static _getImage(e){return new hf(e,e.data)}getFromCache(e,i,r){return this.cacheMap.has(r)||this.cacheMap.set(r,new f0(150)),this.cacheMap.get(r).get(ot(e.toString(),i))}setInCache(e,i,r,a){this.cacheDependenciesMap.has(a)||this.cacheDependenciesMap.set(a,new Map),this.cacheMap.has(a)||this.cacheMap.set(a,new f0(150));let n=this.cacheDependenciesMap.get(a),o=ot(e.id.toString(),r);n.get(o)||n.set(o,new Set);let s=this.cacheMap.get(a),l=e.toString();n.get(o).add(l),s.put(ot(e.toString(),r),i)}removeImagesFromCacheByIds(e,i,r=0){if(!this.cacheMap.has(r)||!this.cacheDependenciesMap.has(r))return;let a=this.cacheMap.get(r),n=this.cacheDependenciesMap.get(r);for(let r of e){let e=ot(r.toString(),i);if(n.has(e)){for(let i of n.get(e))a.delete(i);n.delete(e)}}}rasterize(e,i,r,a,n=fq){let o=this.getFromCache(e,r,a);if(o)return o.clone();let s=n(i.icon,e.options),l=f1._getImage(s);return this.setInCache(e,l,r,a),l.clone()}}class f2{constructor(e){this.size=e,this.minimums=[],this.maximums=[],this.leaves=[]}getElevation(e,i){let r=this.toIdx(e,i);return{min:this.minimums[r],max:this.maximums[r]}}isLeaf(e,i){return this.leaves[this.toIdx(e,i)]}toIdx(e,i){return i*this.size+e}}function f3(e,i,r,a){let n=0,o=Number.MAX_VALUE;for(let s=0;s<3;s++)if(1e-15>Math.abs(a[s])){if(r[s]<e[s]||r[s]>i[s])return null}else{let l=1/a[s],h=(e[s]-r[s])*l,u=(i[s]-r[s])*l;if(h>u){let e=h;h=u,u=e}if(h>n&&(n=h),u<o&&(o=u),n>o)return null}return n}function f5(e,i,r,a,n,o,s,l,h,u,c){let d=a-e,p=n-i,f=o-r,m=s-e,_=l-i,g=h-r,y=c[1]*g-c[2]*_,x=c[2]*m-c[0]*g,v=c[0]*_-c[1]*m,b=d*y+p*x+f*v;if(1e-15>Math.abs(b))return null;let w=1/b,T=u[0]-e,S=u[1]-i,E=u[2]-r,I=(T*y+S*x+E*v)*w;if(I<0||I>1)return null;let A=S*f-E*p,C=E*d-T*f,M=T*p-S*d,P=(c[0]*A+c[1]*C+c[2]*M)*w;return P<0||I+P>1?null:(m*A+_*C+g*M)*w}function f4(e,i,r,a,n,o,s,l,h){let u=1<<r,c=o-a,d=s-n;l[0]=(e+0)/u*c+a,l[1]=(i+0)/u*d+n,h[0]=(e+1)/u*c+a,h[1]=(i+1)/u*d+n}class f6{constructor(e){if(this.maximums=[],this.minimums=[],this.leaves=[],this.childOffsets=[],this.nodeCount=0,this.dem=e,this._siblingOffset=[[0,0],[1,0],[0,1],[1,1]],!this.dem)return;let i=function(e){let i=Math.ceil(Math.log2(e.dim/8)),r=[],a=Math.ceil(Math.pow(2,i)),n=1/a,o=(e,i,r,a,n)=>{let o=+!!a;n[0]=e*r,n[1]=i*r,n[2]=(e+1)*r-o,n[3]=(i+1)*r-o},s=new f2(a),l=[];for(let i=0;i<a*a;i++){o(i%a,Math.floor(i/a),n,!1,l);let r=f9(l[0],l[1],e),h=f9(l[2],l[1],e),u=f9(l[2],l[3],e),c=f9(l[0],l[3],e);s.minimums.push(Math.min(r,h,u,c)),s.maximums.push(Math.max(r,h,u,c)),s.leaves.push(1)}for(r.push(s),a/=2;a>=1;a/=2){let e=r[r.length-1];s=new f2(a);for(let i=0;i<a*a;i++){o(i%a,Math.floor(i/a),2,!0,l);let r=e.getElevation(l[0],l[1]),n=e.getElevation(l[2],l[1]),h=e.getElevation(l[2],l[3]),u=e.getElevation(l[0],l[3]),c=e.isLeaf(l[0],l[1]),d=e.isLeaf(l[2],l[1]),p=e.isLeaf(l[2],l[3]),f=e.isLeaf(l[0],l[3]),m=Math.min(r.min,n.min,h.min,u.min),_=Math.max(r.max,n.max,h.max,u.max),g=c&&d&&p&&f;s.maximums.push(_),s.minimums.push(m),s.leaves.push(_-m<=5&&g?1:0)}r.push(s)}return r}(this.dem),r=i.length-1,a=i[r];this._addNode(a.minimums[0],a.maximums[0],a.leaves[0]),this._construct(i,
70,0,r,0)}raycastRoot(e,i,r,a,n,o,s=1){return f3([e,i,-100],[r,a,this.maximums[0]*s],n,o)}raycast(e,i,r,a,n,o,s=1){if(!this.nodeCount)return null;let l=this.raycastRoot(e,i,r,a,n,o,s);if(null==l)return null;let h=[],u=[],c=[],d=[],p=[{idx:0,t:l,nodex:0,nodey:0,depth:0}];for(;p.length>0;){let{idx:l,t:y,nodex:x,nodey:v,depth:b}=p.pop();if(this.leaves[l]){f4(x,v,b,e,i,r,a,c,d);let l=1<<b,h=(x+0)/l,u=(x+1)/l,p=(v+0)/l,w=(v+1)/l,T=f9(h,p,this.dem)*s,S=f9(u,p,this.dem)*s,E=f9(u,w,this.dem)*s,I=f9(h,w,this.dem)*s,A=f5(c[0],c[1],T,d[0],c[1],S,d[0],d[1],E,n,o),C=f5(d[0],d[1],E,c[0],d[1],I,c[0],c[1],T,n,o),M=Math.min(null!==A?A:Number.MAX_VALUE,null!==C?C:Number.MAX_VALUE);if(M!==Number.MAX_VALUE)return M;{var f,m,_,g;let e=ew([],n,o,y);if(f8(T,S,I,E,(f=e[0],(f-(m=c[0]))/(d[0]-m)),(_=e[1],(_-(g=c[1]))/(d[1]-g)))>=e[2])return y}continue}let w=0;for(let p=0;p<this._siblingOffset.length;p++){f4((x<<1)+this._siblingOffset[p][0],(v<<1)+this._siblingOffset[p][1],b+1,e,i,r,a,c,d),c[2]=-100,d[2]=this.maximums[this.childOffsets[l]+p]*s;let f=f3(c,d,n,o);if(null!=f){h[p]=f;let e=!1;for(let i=0;i<w&&!e;i++)f>=h[u[i]]&&(u.splice(i,0,p),e=!0);e||(u[w]=p),w++}}for(let e=0;e<w;e++){let i=u[e];p.push({idx:this.childOffsets[l]+i,t:h[i],nodex:(x<<1)+this._siblingOffset[i][0],nodey:(v<<1)+this._siblingOffset[i][1],depth:b+1})}}return null}_addNode(e,i,r){return this.minimums.push(e),this.maximums.push(i),this.leaves.push(r),this.childOffsets.push(0),this.nodeCount++}_construct(e,i,r,a,n){if(1===e[a].isLeaf(i,r))return;this.childOffsets[n]||(this.childOffsets[n]=this.nodeCount);let o=a-1,s=e[o],l=0,h=0;for(let e=0;e<this._siblingOffset.length;e++){let a=2*i+this._siblingOffset[e][0],n=2*r+this._siblingOffset[e][1],o=s.getElevation(a,n),u=s.isLeaf(a,n),c=this._addNode(o.min,o.max,u);u&&(l|=1<<e),h||(h=c)}for(let a=0;a<this._siblingOffset.length;a++)l&1<<a||this._construct(e,2*i+this._siblingOffset[a][0],2*r+this._siblingOffset[a][1],o,h+a)}}function f8(e,i,r,a,n,o){return ip(ip(e,r,o),ip(i,a,o),n)}function f9(e,i,r){let a=r.dim,n=tt(e*a-.5,0,a-1),o=tt(i*a-.5,0,a-1),s=Math.floor(n),l=Math.floor(o),h=Math.min(s+1,a-1),u=Math.min(l+1,a-1);return f8(r.get(s,l),r.get(h,l),r.get(s,u),r.get(h,u),n-s,o-l)}let f7={mapbox:[6553.6,25.6,.1,1e4],terrarium:[256,1,1/256,32768]};function me(e,i,r){return(256*e*256+256*i+r)/10-1e4}function mt(e,i,r){return 256*e+i+r/256-32768}class mi{get tree(){return this._tree||this._buildQuadTree(),this._tree}constructor(e,i,r,a=!1){if(this.uid=e,i.height!==i.width)throw RangeError("DEM tiles must be square");if(r&&"mapbox"!==r&&"terrarium"!==r)return void tf(`"${r}" is not a valid encoding type. Valid types include "mapbox" and "terrarium".`);this.stride=i.height;let n=this.dim=i.height-2,o=new Uint32Array(i.data.buffer);if(this.pixels=new Uint8Array(i.data.buffer),this.floatView=new Float32Array(i.data.buffer),this.borderReady=a,this._modifiedForSources={},!a){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)]}let s="terrarium"===r?mt:me;for(let e=0;e<o.length;++e){let i=4*e;this.floatView[e]=s(this.pixels[i],this.pixels[i+1],this.pixels[i+2])}this._timestamp=tP.now()}_buildQuadTree(){this._tree=new f6(this)}get(e,i,r=!1){r&&(e=tt(e,-1,this.dim),i=tt(i,-1,this.dim));let a=this._idx(e,i);return this.floatView[a]}set(e,i,r){let a=this._idx(e,i),n=this.floatView[a];return this.floatView[a]=r,r-n}static getUnpackVector(e){return f7[e]}_idx(e,i){if(e<-1||e>=this.dim+1||i<-1||i>=this.dim+1)throw RangeError("out of range source coordinates for DEM data");return(i+1)*this.stride+(e+1)}static pack(e,i){let r=[0,0,0,0],a=mi.getUnpackVector(i),n=Math.floor((e+a[3])/a[2]);return r[2]=n%256,n=Math.floor(n/256),r[1]=n%256,n=Math.floor(n/256),r[0]=n,r}getPixels(){return new hm({width:this.stride,height:this.stride},this.pixels)}backfillBorder(e,i,r){if(this.dim!==e.dim)throw Error("dem dimension mismatch");let a=i*this.dim,n=i*this.dim+this.dim,o=r*this.dim,s=r*this.dim+this.dim;switch(i){case -1:a=n-1;break;case 1:n=a+1}switch(r){case -1:o=s-1;break;case 1:s=o+1}let l=-i*this.dim,h=-r*this.dim;for(let i=o;i<s;i++)for(let r=a;r<n;r++){let a=4*this._idx(r,i),n=4*this._idx(r+l,i+h);this.pixels[a+0]=e.pixels[n+0],this.pixels[a+1]=e.pixels[n+1],this.pixels[a+2]=e.pixels[n+2],this.pixels[a+3]=e.pixels[n+3]}}onDeserialize(){this._tree&&(this._tree.dem=this)}}function mr(e,i,r){var a;1===e?i.headerLength=r.readFixed32():2===e?i.x=r.readVarint():3===e?i.y=r.readVarint():4===e?i.z=r.readVarint():5===e&&i.layers.push((a=r.readVarint()+r.pos,r.readFields(ml,{version:0,name:"",units:"",tileSize:0,buffer:0,pixelFormat:0,dataIndex:[]},a)))}function ma(e,i,r){var a;1===e?(a=r.readVarint()+r.pos,i.delta_filter=r.readFields(mn,{blockSize:0},a),i.filter="delta_filter"):2===e?(r.readVarint(),i.filter="zigzag_filter"):3===e?(r.readVarint(),i.filter="bitshuffle_filter"):4===e&&(r.readVarint(),i.filter="byteshuffle_filter")}function mn(e,i,r){1===e&&(i.blockSize=r.readVarint())}function mo(e,i,r){1===e?(r.readVarint(),i.codec="gzip_data"):2===e?(r.readVarint(),i.codec="jpeg_image"):3===e?(r.readVarint(),i.codec="webp_image"):4===e&&(r.readVarint(),i.codec="png_image")}function ms(e,i,r){var a,n;let o=0,s=0;1===e?i.firstByte=r.readFixed64():2===e?i.lastByte=r.readFixed64():3===e?i.filters.push((a=r.readVarint()+r.pos,r.readFields(ma,{},a))):4===e?(n=r.readVarint()+r.pos,i.codec=r.readFields(mo,{},n)):5===e?s=r.readFloat():6===e?o=r.readFloat():7===e?i.bands.push(r.readString()):8===e?i.offset=r.readDouble():9===e&&(i.scale=r.readDouble()),0===i.offset&&(i.offset=s),0===i.scale&&(i.scale=o)}function ml(e,i,r){var a;1===e?i.version=r.readVarint():2===e?i.name=r.readString():3===e?i.units=r.readString():4===e?i.tileSize=r.readVarint():5===e?i.buffer=r.readVarint():6===e?i.pixelFormat=r.readVarint():7===e&&i.dataIndex.push((a=r.readVarint()+r.pos,r.readFields(ms,{firstByte:0,lastByte:0,filters:[],codec:null,offset:0,scale:0,bands:[]},a)))}function mh(e,i,r){if(2===e){var a;a=r.readVarint()+r.pos,r.readFields(mu,i,a)}else if(3===e)throw Error("Not implemented")}function mu(e,i,r){if(1===e){let e=0,a=r.readVarint()+r.pos;for(;r.pos<a;)i[e++]=r.readVarint()}}a3(mi,"DEMData"),a3(f6,"DemMinMaxQuadTree",{omit:["dem"]});var mc=Uint8Array,md=Uint16Array,mp=Int32Array,mf=new mc([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]),mm=new mc([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]),m_=new mc([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),mg=function(e,i){for(var r=new md(31),a=0;a<31;++a)r[a]=i+=1<<e[a-1];var n=new mp(r[30]);for(a=1;a<30;++a)for(var o=r[a];o<r[a+1];++o)n[o]=o-r[a]<<5|a;return{b:r,r:n}},my=mg(mf,2),mx=my.b,mv=my.r;mx[28]=258,mv[258]=28;for(var mb=mg(mm,0).b,mw=new md(32768),mT=0;mT<32768;++mT){var mS=(43690&mT)>>1|(21845&mT)<<1;mw[mT]=((65280&(mS=(61680&(mS=(52428&mS)>>2|(13107&mS)<<2))>>4|(3855&mS)<<4))>>8|(255&mS)<<8)>>1}var mE=function(e,i,r){for(var a=e.length,n=0,o=new md(i);n<a;++n)e[n]&&++o[e[n]-1];var s,l=new md(i);for(n=1;n<i;++n)l[n]=l[n-1]+o[n-1]<<1;s=new md(1<<i);var h=15-i;for(n=0;n<a;++n)if(e[n])for(var u=n<<4|e[n],c=i-e[n],d=l[e[n]-1]++<<c,p=d|(1<<c)-1;d<=p;++d)s[mw[d]>>h]=u;return s},mI=new mc(288);for(mT=0;mT<144;++mT)mI[mT]=8;for(mT=144;mT<256;++mT)mI[mT]=9;for(mT=256;mT<280;++mT)mI[mT]=7;for(mT=280;mT<288;++mT)mI[mT]=8;var mA=new mc(32);for(mT=0;mT<32;++mT)mA[mT]=5;var mC=mE(mI,9),mM=mE(mA,5),mP=function(e){for(var i=e[0],r=1;r<e.length;++r)e[r]>i&&(i=e[r]);return i},mz=function(e,i,r){var a=i/8|0;return(e[a]|e[a+1]<<8)>>(7&i)&r},mR=function(e,i){var r=i/8|0;return(e[r]|e[r+1]<<8|e[r+2]<<16)>>(7&i)}
7,mD=["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"],mL=function(e,i,r){var a=Error(i||mD[e]);if(a.code=e,Error.captureStackTrace&&Error.captureStackTrace(a,mL),!r)throw a;return a},mO=new mc(0),mF="undefined"!=typeof TextDecoder&&new TextDecoder;try{mF.decode(mO,{stream:!0})}catch(e){}let mk={gzip_data:"gzip"};class mB extends Error{constructor(e){super(e),this.name="MRTError"}}let mN={0:"uint32",1:"uint32",2:"uint16",3:"uint8"},mV={uint32:1,uint16:2,uint8:4},mU={uint32:Uint32Array,uint16:Uint16Array,uint8:Uint8Array};class mj{constructor(e=5){this.x=NaN,this.y=NaN,this.z=NaN,this.layers={},this._cacheSize=e}getLayer(e){let i=this.layers[e];if(!i)throw new mB(`Layer '${e}' not found`);return i}getHeaderLength(e){let i=new Uint8Array(e),r=new DataView(e);if(13!==i[0])throw new mB("File is not a valid MRT.");return r.getUint32(1,!0)}parseHeader(e){let i=new Uint8Array(e),r=this.getHeaderLength(e);if(i.length<r)throw new mB(`Expected header with length >= ${r} but got buffer of length ${i.length}`);let a=new Z(i.subarray(0,r)).readFields(mr,{headerLength:0,x:0,y:0,z:0,layers:[]},void 0);if(!isNaN(this.x)&&(this.x!==a.x||this.y!==a.y||this.z!==a.z))throw new mB(`Invalid attempt to parse header ${a.z}/${a.x}/${a.y} for tile ${this.z}/${this.x}/${this.y}`);for(let e of(this.x=a.x,this.y=a.y,this.z=a.z,a.layers))this.layers[e.name]=new mG(e,{cacheSize:this._cacheSize});return this}createDecodingTask(e){let i=[],r=this.getLayer(e.layerName);for(let a of e.blockIndices){let n=r.dataIndex[a],o=n.firstByte-e.firstByte,s=n.lastByte-e.firstByte;if(r._blocksInProgress.has(a))continue;let l={layerName:r.name,firstByte:o,lastByte:s,pixelFormat:r.pixelFormat,blockIndex:a,blockShape:[n.bands.length].concat(r.bandShape),buffer:r.buffer,codec:n.codec.codec,filters:n.filters.map(e=>e.filter)};r._blocksInProgress.add(a),i.push(l)}return new mq(i,()=>{i.forEach(e=>r._blocksInProgress.delete(e.blockIndex))},(e,a)=>{if(i.forEach(e=>r._blocksInProgress.delete(e.blockIndex)),e)throw e;a.forEach(e=>{this.getLayer(e.layerName).processDecodedData(e)})})}}class mG{constructor({version:e,name:i,units:r,tileSize:a,pixelFormat:n,buffer:o,dataIndex:s},l){if(this.version=e,1!==this.version)throw new mB(`Cannot parse raster layer encoded with MRT version ${e}`);this.name=i,this.units=r,this.tileSize=a,this.buffer=o,this.pixelFormat=mN[n],this.dataIndex=s,this.bandShape=[a+2*o,a+2*o,mV[this.pixelFormat]],this._decodedBlocks=new f0(l?l.cacheSize:5),this._blocksInProgress=new Set}get dimension(){return mV[this.pixelFormat]}get cacheSize(){return this._decodedBlocks.capacity}getBandList(){return this.dataIndex.map(({bands:e})=>e).flat()}processDecodedData(e){let i=e.blockIndex.toString();this._decodedBlocks.get(i)||this._decodedBlocks.put(i,e.data)}getBlockForBand(e){let i=0;switch(typeof e){case"string":for(let[r,a]of this.dataIndex.entries()){for(let[n,o]of a.bands.entries())if(o===e)return{bandIndex:i+n,blockIndex:r,blockBandIndex:n};i+=a.bands.length}break;case"number":for(let[r,a]of this.dataIndex.entries()){if(e>=i&&e<i+a.bands.length)return{bandIndex:e,blockIndex:r,blockBandIndex:e-i};i+=a.bands.length}break;default:throw new mB(`Invalid band \`${JSON.stringify(e)}\`. Expected string or integer.`)}return{blockIndex:-1,blockBandIndex:-1}}getDataRange(e){let i=1/0,r=-1/0,a=[],n=new Set;for(let o of e){let{blockIndex:e}=this.getBlockForBand(o);if(e<0)throw new mB(`Invalid band: ${JSON.stringify(o)}`);let s=this.dataIndex[e];a.includes(e)||a.push(e),n.add(e),i=Math.min(i,s.firstByte),r=Math.max(r,s.lastByte)}if(n.size>this.cacheSize)throw new mB(`Number of blocks to decode (${n.size}) exceeds cache size (${this.cacheSize}).`);return{layerName:this.name,firstByte:i,lastByte:r,blockIndices:a}}hasBand(e){let{blockIndex:i}=this.getBlockForBand(e);return i>=0}hasDataForBand(e){let{blockIndex:i}=this.getBlockForBand(e);return i>=0&&!!this._decodedBlocks.get(i.toString())}getBandView(e){let{blockIndex:i,blockBandIndex:r}=this.getBlockForBand(e);if(i<0)throw new mB(`Band not found: ${JSON.stringify(e)}`);let a=this._decodedBlocks.get(i.toString());if(!a)throw new mB(`Data for band ${JSON.stringify(e)} of layer "${this.name}" not decoded.`);let n=this.dataIndex[i],o=this.bandShape.reduce((e,i)=>e*i,1),s=r*o,l=a.subarray(s,s+o);return{data:l,bytes:new Uint8Array(l.buffer).subarray(l.byteOffset,l.byteOffset+l.byteLength),tileSize:this.tileSize,buffer:this.buffer,pixelFormat:this.pixelFormat,dimension:this.dimension,offset:n.offset,scale:n.scale}}}mj.setPbf=function(e){Z=e};class mq{constructor(e,i,r){this.tasks=e,this._onCancel=i,this._onComplete=r,this._finalized=!1}cancel(){this._finalized||(this._onCancel(),this._finalized=!0)}complete(e,i){this._finalized||(this._onComplete(e,i),this._finalized=!0)}}mj.performDecoding=function(e,i){let r=new Uint8Array(e);return Promise.all(i.tasks.map(e=>
7{let{layerName:i,firstByte:a,lastByte:n,pixelFormat:o,blockShape:s,blockIndex:l,filters:h,codec:u}=e,c=r.subarray(a,n+1),d=new Uint32Array(s[0]*s[1]*s[2]);if("gzip_data"!==u)throw new mB(`Unhandled codec: ${u}`);return(function(e,i){var r,a;if(!globalThis.DecompressionStream&&"gzip_data"===i)return Promise.resolve(((a=function(e){31==e[0]&&139==e[1]&&8==e[2]||mL(6,"invalid gzip data");var i=e[3],r=10;4&i&&(r+=2+(e[10]|e[11]<<8));for(var a=(i>>3&1)+(i>>4&1);a>0;a-=!e[r++]);return r+(2&i)}(e))+8>e.length&&mL(6,"invalid gzip data"),function(e,i,r,a){var n=e.length;if(!n||i.f&&!i.l)return r||new mc(0);var o=!r,s=o||2!=i.i,l=i.i;o&&(r=new mc(3*n));var h,u,c=function(e){var i=r.length;if(e>i){var a=new mc(Math.max(2*i,e));a.set(r),r=a}},d=i.f||0,p=i.p||0,f=i.b||0,m=i.l,_=i.d,g=i.m,y=i.n,x=8*n;do{if(!m){d=mz(e,p,1);var v=mz(e,p+1,3);if(p+=3,!v){var b=e[(R=4+((p+7)/8|0))-4]|e[R-3]<<8,w=R+b;if(w>n){l&&mL(0);break}s&&c(f+b),r.set(e.subarray(R,w),f),i.b=f+=b,i.p=p=8*w,i.f=d;continue}if(1==v)m=mC,_=mM,g=9,y=5;else if(2==v){var T=mz(e,p,31)+257,S=mz(e,p+10,15)+4,E=T+mz(e,p+5,31)+1;p+=14;for(var I=new mc(E),A=new mc(19),C=0;C<S;++C)A[m_[C]]=mz(e,p+3*C,7);p+=3*S;var M=mP(A),P=(1<<M)-1,z=mE(A,M);for(C=0;C<E;){var R,D=z[mz(e,p,P)];if(p+=15&D,(R=D>>4)<16)I[C++]=R;else{var L=0,O=0;for(16==R?(O=3+mz(e,p,3),p+=2,L=I[C-1]):17==R?(O=3+mz(e,p,7),p+=3):18==R&&(O=11+mz(e,p,127),p+=7);O--;)I[C++]=L}}var F=I.subarray(0,T),k=I.subarray(T);g=mP(F),y=mP(k),m=mE(F,g),_=mE(k,y)}else mL(1);if(p>x){l&&mL(0);break}}s&&c(f+131072);for(var B=(1<<g)-1,N=(1<<y)-1,V=p;;V=p){var U=(L=m[mR(e,p)&B])>>4;if((p+=15&L)>x){l&&mL(0);break}if(L||mL(2),U<256)r[f++]=U;else{if(256==U){V=p,m=null;break}var j=U-254;U>264&&(j=mz(e,p,(1<<($=mf[C=U-257]))-1)+mx[C],p+=$);var G=_[mR(e,p)&N],q=G>>4;if(G||mL(3),p+=15&G,k=mb[q],q>3){var $=mm[q];k+=mR(e,p)&(1<<$)-1,p+=$}if(p>x){l&&mL(0);break}s&&c(f+131072);var H=f+j;if(f<k){var Z=0-k,W=Math.min(k,H);for(Z+f<0&&mL(3);f<W;++f)r[f]=(void 0)[Z+f]}for(;f<H;++f)r[f]=r[f-k]}}i.l=m,i.p=V,i.b=f,i.f=d,m&&(d=1,i.m=g,i.d=_,i.n=y)}while(!d);return f!=r.length&&o?(h=r,(null==(u=f)||u>h.length)&&(u=h.length),new mc(h.subarray(0,u))):r.subarray(0,f)}(e.subarray(a,-8),{i:2},new mc((e[(r=e.length)-4]|e[r-3]<<8|e[r-2]<<16|e[r-1]<<24)>>>0))));let n=mk[i];if(!n)throw Error(`Unhandled codec: ${i}`);let o=new globalThis.DecompressionStream(n);return new Response(new Blob([e]).stream().pipeThrough(o)).arrayBuffer().then(e=>new Uint8Array(e))})(c,u).then(e=>{var i;return i=new Z(e),i.readFields(mh,d),new(0,mU[o])(d.buffer)}).then(e=>{for(let i=h.length-1;i>=0;i--)switch(h[i]){case"delta_filter":!function(e,i){if(4!==i.length)throw Error(`Expected data of dimension 4 but got ${i.length}.`);let r=i[3];for(let a=2;a>=1;a--){let n=+(1===a),o=+(2===a);for(let a=0;a<i[0];a++){let s=i[1]*a;for(let a=n;a<i[1];a++){let n=i[2]*(a+s);for(let a=o;a<i[2];a++){let o=i[3]*(a+n);for(let a=0;a<i[3];a++){let i=o+a;e[i]+=e[i-r]}}}}r*=i[a]}}(e,s);break;case"zigzag_filter":var r=e;for(let e=0,i=r.length;e<i;e++)r[e]=r[e]>>>1^-(1&r[e]);break;case"bitshuffle_filter":!function(e,i){switch(i){case"uint32":return;case"uint16":for(let i=0;i<e.length;i+=2){let r=e[i],a=e[i+1];e[i]=(240&r)>>4|(61440&r)>>8|(240&a)<<4|61440&a,e[i+1]=15&r|(3840&r)>>4|(15&a)<<8|(3840&a)<<4}return;case"uint8":for(let i=0;i<e.length;i+=4){let r=e[i],a=e[i+1],n=e[i+2],o=e[i+3];e[i+0]=(192&r)>>6|(192&a)>>4|(192&n)>>2|192&o,e[i+1]=(48&r)>>4|(48&a)>>2|48&n|(48&o)<<2,e[i+2]=(12&r)>>2|12&a|(12&n)<<2|(12&o)<<4,e[i+3]=3&r|(3&a)<<2|(3&n)<<4|(3&o)<<6}return;default:throw Error(`Invalid pixel format, "${i}"`)}}(e,o);break;default:throw new mB(`Unhandled filter "${h[i]}"`)}return{layerName:i,blockIndex:l,data:e}}).catch(e=>{throw e})}))},a3(mq,"MRTDecodingBatch",{omit:["_onCancel","_onComplete"]}),a3(mj,"MapboxRasterTile"),a3(mG,"MapboxRasterLayer",{omit:["_blocksInProgress"]});class m${constructor(e){this._stringToNumber={},this._numberToString=[];for(let i=0;i<e.length;i++){let r=e[i];this._stringToNumber[r]=i,this._numberToString[i]=r}}encode(e){return this._stringToNumber[e]}decode(e){return this._numberToString[e]}}let mH=["id","tile","layer","source","sourceLayer","state"];class mZ{constructor(e,i,r,a,n){this.type="Feature",this._vectorTileFeature=e,this._z=i,this._x=r,this._y=a,this.properties=e.properties,this.id=n}clone(){let e=new mZ(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._geometry=this._vectorTileFeature.toGeoJSON(this._x,this._y,this._z).geometry),this._geometry}set geometry(e){this._geometry=e}toJSON(){let e={type:"Feature",state:void 0,geometry:this.geometry,properties:this.properties};for(let i of mH)void 0!==this[i]&&(e[i]=this[i]);return e}}class mW{constructor(e,i){this.tileID=e,this.x=e.canonical.x,this.y=e.canonical.y,this.z=e.canonical.z,this.grid=new a1(8192,16,0),this.featureIndexArray=new o3,this.promoteId=i,this.is3DTile=!1,this.serializedLayersCache=new Map}insert(e,i,r,a,n,o=0,s=0){let l=this.featureIndexArray.length;this.featureIndexArray.emplaceBack(r,a,n,o);let h=this.grid;for(let e=0;e<i.length;e++){let r=i[e],a=[1/0,1/0,-1/0,-1/0];for(let e=0;e<r.length;e++){let i=r[e];a[0]=Math.min(a[0],i.x),a[1]=Math.min(a[1],i.y),a[2]=Math.max(a[2],i.x),a[3]=Math.max(a[3],i.y)}
70!==s&&(a[0]-=s,a[1]-=s,a[2]+=s,a[3]+=s),a[0]<8192&&a[1]<8192&&a[2]>=0&&a[3]>=0&&h.insert(l,a[0],a[1],a[2],a[3])}}loadVTLayers(){if(!this.vtLayers)for(let e in this.vtLayers=new s4(new dT(this.rawTileData)).layers,this.sourceLayerCoder=new m$(this.vtLayers?Object.keys(this.vtLayers).sort():["_geojsonTileLayer"]),this.vtFeatures={},this.vtLayers)this.vtFeatures[e]=[];return this.vtLayers}query(e,i){let r,{tilespaceGeometry:a,transform:n,tileTransform:o,pixelPosMatrix:s,availableImages:l,worldview:h}=i;this.loadVTLayers(),this.serializedLayersCache.clear();let u=a.bufferedTilespaceBounds,c=this.grid.query(u.min.x,u.min.y,u.max.x,u.max.y,(e,i,r,n)=>lI(a.bufferedTilespaceGeometry,e,i,r,n));c.sort(mY);let d=null;n.elevation&&c.length>0&&(d=fl.create(n.elevation,this.tileID));let p={};for(let i=0;i<c.length;i++){let u=c[i];if(u===r)continue;r=u;let f=this.featureIndexArray.get(u),m=null;this.is3DTile?this.loadMatchingModelFeature(p,f,e,a,n,h):this.loadMatchingFeature(p,f,e,l,h,(e,i,r,l=0)=>(m||(m=sQ(e,this.tileID.canonical,o)),i.queryIntersectsFeature(a,e,r,m,this.z,n,s,d,l)))}return p}loadMatchingFeature(e,i,r,a,n,o){let{featureIndex:s,bucketIndex:l,sourceLayerIndex:h,layoutVertexArrayOffset:u}=i,c=this.bucketLayerIDs[l],d=r.layers,p=Object.keys(d);if(p.length&&!td(p,c))return;let f=r.sourceCache,m=this.sourceLayerCoder.decode(h),_=this.vtLayers[m].feature(s),g=this.getId(_,m);for(let i=0;i<c.length;i++){let r=c[i];if(!d[r])continue;let{styleLayer:l,targets:h}=d[r],p={};void 0!==g&&(p=f.getFeatureState(l.sourceLayer,g));let m=!o||o(_,l,p,u);if(!m)continue;let y=new mZ(_,this.z,this.x,this.y,g);y.tile=this.tileID.canonical,y.state=p;let x=this.serializedLayersCache.get(r);x||((x=l.serialize()).id=r,this.serializedLayersCache.set(r,x)),y.source=x.source,y.sourceLayer=x["source-layer"],y.layer=Object.assign({},x),y.layer.paint=mX(x.paint,l.paint,_,p,a),y.layer.layout=mX(x.layout,l.layout,_,p,a);let v=!1;for(let e of h){this.updateFeatureProperties(y,e);let{filter:i}=e;if(i){if(_.properties=y.properties,i.needGeometry){let e=s0(_,!0);if(!i.filter(new nV(this.tileID.overscaledZ,{worldview:n}),e,this.tileID.canonical))continue}else if(!i.filter(new nV(this.tileID.overscaledZ,{worldview:n}),_))continue}v=!0,e.targetId&&this.addFeatureVariant(y,e)}v&&this.appendToResult(e,r,s,y,m)}}loadMatchingModelFeature(e,i,r,a,n,o){let{featureIndex:s,bucketIndex:l}=i,h=this.bucketLayerIDs[l],u=r.layers,c=Object.keys(u);if(!c.length||td(c,h))for(let i=0;i<h.length;i++){let l=h[i],{styleLayer:c,targets:d}=u[l];if("model"!==c.type)continue;let p=a.tile,f=p.getBucket(c);if(!(f&&f instanceof fp))continue;let m=function(e,i,r,a){let n=e.getNodesInfo()[i];if(!n||n.hiddenByReplacement||!n.node.meshes)return;let o=Number.MAX_VALUE,s=n.node,l=r.tile,h=a.calculatePosMatrix(l.tileID.toUnwrapped(),a.worldSize),u=n.evaluatedScale,c=0;a.elevation&&s.elevation&&(c=s.elevation*a.elevation.exaggeration()),er(h,h,[(s.anchor?s.anchor[0]:0)*(u[0]-1),(s.anchor?s.anchor[1]:0)*(u[1]-1),c]),ea(h,h,u);let d=r.queryGeometry,p=d.isPointQuery()?d.screenBounds:d.screenGeometry,f=function(e){let i=ei([],h,e.matrix);ei(i,a.expandedFarZProjMatrix,i);for(let r=0;r<e.meshes.length;++r){let n=e.meshes[r];if(r===e.lightMeshIndex)continue;let s=cR(p,a,i,n.aabb);null!=s&&(o=Math.min(s,o))}if(e.children)for(let i of e.children)f(i)};if(f(s),o===Number.MAX_VALUE)return;let m=new sB(0,0);return fm(l.tileID.canonical,m,n.node.anchor[0],n.node.anchor[1]),{intersectionZ:o,position:m,feature:n.feature}}(f,s,a,n);if(!m)continue;let{z:_,x:g,y:y}=p.tileID.canonical,{feature:x,intersectionZ:v,position:b}=m,w={};void 0!==x.id&&(w=r.sourceCache.getFeatureState(c.sourceLayer,x.id));let T=new mZ({},_,g,y,x.id);T.tile=this.tileID.canonical,T.state=w,T.properties=x.properties,T.geometry={type:"Point",coordinates:[b.lng,b.lat]};let S=this.serializedLayersCache.get(l);S||((S=c.serialize()).id=l,this.serializedLayersCache.set(l,S)),T.source=S.source,T.sourceLayer=S["source-layer"],T.layer=Object.assign({},S);let E=!1;for(let e of d){this.updateFeatureProperties(T,e);let{filter:i}=e;if(i){if(x.properties=T.properties,i.needGeometry){if(!i.filter(new nV(this.tileID.overscaledZ,{worldview:o}),x,this.tileID.canonical))continue}else if(!i.filter(new nV(this.tileID.overscaledZ,{worldview:o}),x))continue}E=!0,e.targetId&&this.addFeatureVariant(T,e)}E&&this.appendToResult(e,l,s,T,v)}}updateFeatureProperties(e,i,r){if(i.properties){let a={};for(let n in i.properties){let o=i.properties[n].evaluate({zoom:this.z},e._vectorTileFeature,e.state,e.tile,r);null!=o&&(a[n]=o)}e.properties=a}}addFeatureVariant(e,i,r){let a={target:i.target,namespace:i.namespace,uniqueFeatureID:i.uniqueFeatureID};i.properties&&(a.properties=e.properties),e.variants=e.variants||{},e.variants[i.targetId]=e.variants[i.targetId]||[],e.variants[i.targetId].push(a)}appendToResult(e,i,r,a,n){let o=e[i];void 0===o&&(o=e[i]=[]),o.push({featureIndex:r,feature:a,intersectionZ:n})}lookupSymbolFeatures(e,i,r,a,n,o){let s={};
7for(let l of(this.loadVTLayers(),e))this.loadMatchingFeature(s,{bucketIndex:i,sourceLayerIndex:r,featureIndex:l,layoutVertexArrayOffset:0},a,n,o);return s}loadFeature(e){let{featureIndex:i,sourceLayerIndex:r}=e;this.loadVTLayers();let a=this.sourceLayerCoder.decode(r),n=this.vtFeatures[a];if(n[i])return n[i];let o=this.vtLayers[a].feature(i);return n[i]=o,o}hasLayer(e){for(let i of this.bucketLayerIDs)for(let r of i)if(e===r)return!0;return!1}getId(e,i){let r=e.id;if(this.promoteId){let a=Array.isArray(this.promoteId)||"object"!=typeof this.promoteId?this.promoteId:this.promoteId[i];if(null!=a)if(Array.isArray(a)){if(!this.promoteIdExpression){let e=aW(a);if("success"!==e.result){let i=e.value.map(e=>`${e.key}: ${e.message}`).join(", ");return void tf(`Failed to create expression for promoteId: ${i}`)}this.promoteIdExpression=e.value}this.promoteIdExpression._evaluator||(this.promoteIdExpression._evaluator=new i4),r=this.promoteIdExpression.evaluate({zoom:0},e)}else r=e.properties[a];"boolean"==typeof r&&(r=Number(r))}return r}}function mX(e,i,r,a,n){return th(e,(e,o)=>{let s=i instanceof nW?i.get(o):null;return s&&s.evaluate?s.evaluate(r,a,void 0,n):s})}function mY(e,i){return i-e}a3(mW,"FeatureIndex",{omit:["rawTileData","sourceLayerCoder"]});let mK=[Int8Array,Uint8Array,Uint8ClampedArray,Int16Array,Uint16Array,Int32Array,Uint32Array,Float32Array,Float64Array];class mJ{static from(e){if(!(e instanceof ArrayBuffer))throw Error("Data must be an instance of ArrayBuffer.");let[i,r]=new Uint8Array(e,0,2);if(219!==i)throw Error("Data does not appear to be in a KDBush format.");let a=r>>4;if(1!==a)throw Error(`Got v${a} data when expected v1.`);let n=mK[15&r];if(!n)throw Error("Unrecognized array type.");let[o]=new Uint16Array(e,2,1),[s]=new Uint32Array(e,4,1);return new mJ(s,o,n,e)}constructor(e,i=64,r=Float64Array,a){if(isNaN(e)||e<0)throw Error(`Unpexpected numItems value: ${e}.`);this.numItems=+e,this.nodeSize=Math.min(Math.max(+i,2),65535),this.ArrayType=r,this.IndexArrayType=e<65536?Uint16Array:Uint32Array;let n=mK.indexOf(this.ArrayType),o=2*e*this.ArrayType.BYTES_PER_ELEMENT,s=e*this.IndexArrayType.BYTES_PER_ELEMENT,l=(8-s%8)%8;if(n<0)throw Error(`Unexpected typed array class: ${r}.`);a&&a instanceof ArrayBuffer?(this.data=a,this.ids=new this.IndexArrayType(this.data,8,e),this.coords=new this.ArrayType(this.data,8+s+l,2*e),this._pos=2*e,this._finished=!0):(this.data=new ArrayBuffer(8+o+s+l),this.ids=new this.IndexArrayType(this.data,8,e),this.coords=new this.ArrayType(this.data,8+s+l,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]=i,new Uint32Array(this.data,4,1)[0]=e)}add(e,i){let r=this._pos>>1;return this.ids[r]=r,this.coords[this._pos++]=e,this.coords[this._pos++]=i,r}finish(){let e=this._pos>>1;if(e!==this.numItems)throw Error(`Added ${e} items when expected ${this.numItems}.`);return function e(i,r,a,n,o,s){if(o-n<=a)return;let l=n+o>>1;(function e(i,r,a,n,o,s){for(;o>n;){if(o-n>600){let l=o-n+1,h=a-n+1,u=Math.log(l),c=.5*Math.exp(2*u/3),d=.5*Math.sqrt(u*c*(l-c)/l)*(h-l/2<0?-1:1);e(i,r,a,Math.max(n,Math.floor(a-h*c/l+d)),Math.min(o,Math.floor(a+(l-h)*c/l+d)),s)}let l=r[2*a+s],h=n,u=o;for(mQ(i,r,n,a),r[2*o+s]>l&&mQ(i,r,n,o);h<u;){for(mQ(i,r,h,u),h++,u--;r[2*h+s]<l;)h++;for(;r[2*u+s]>l;)u--}r[2*n+s]===l?mQ(i,r,n,u):mQ(i,r,++u,o),u<=a&&(n=u+1),a<=u&&(o=u-1)}})(i,r,l,n,o,s),e(i,r,a,n,l-1,1-s),e(i,r,a,l+1,o,1-s)}(this.ids,this.coords,this.nodeSize,0,this.numItems-1,0),this._finished=!0,this}range(e,i,r,a){if(!this._finished)throw Error("Data not yet indexed - call index.finish().");let{ids:n,coords:o,nodeSize:s}=this,l=[0,n.length-1,0],h=[];for(;l.length;){let u=l.pop()||0,c=l.pop()||0,d=l.pop()||0;if(c-d<=s){for(let s=d;s<=c;s++){let l=o[2*s],u=o[2*s+1];l>=e&&l<=r&&u>=i&&u<=a&&h.push(n[s])}continue}let p=d+c>>1,f=o[2*p],m=o[2*p+1];f>=e&&f<=r&&m>=i&&m<=a&&h.push(n[p]),(0===u?e<=f:i<=m)&&(l.push(d),l.push(p-1),l.push(1-u)),(0===u?r>=f:a>=m)&&(l.push(p+1),l.push(c),l.push(1-u))}return h}within(e,i,r){if(!this._finished)throw Error("Data not yet indexed - call index.finish().");let{ids:a,coords:n,nodeSize:o}=this,s=[0,a.length-1,0],l=[],h=r*r;for(;s.length;){let u=s.pop()||0,c=s.pop()||0,d=s.pop()||0;
7if(c-d<=o){for(let r=d;r<=c;r++)m1(n[2*r],n[2*r+1],e,i)<=h&&l.push(a[r]);continue}let p=d+c>>1,f=n[2*p],m=n[2*p+1];m1(f,m,e,i)<=h&&l.push(a[p]),(0===u?e-r<=f:i-r<=m)&&(s.push(d),s.push(p-1),s.push(1-u)),(0===u?e+r>=f:i+r>=m)&&(s.push(p+1),s.push(c),s.push(1-u))}return l}}function mQ(e,i,r,a){m0(e,r,a),m0(i,2*r,2*a),m0(i,2*r+1,2*a+1)}function m0(e,i,r){let a=e[i];e[i]=e[r],e[r]=a}function m1(e,i,r,a){let n=e-r,o=i-a;return n*n+o*o}e.$=i1,e.A=iN,e.B=ot,e.C=2,e.D=uJ,e.E=ir,e.F=d8,e.G=d6,e.H=iJ,e.I=ia,e.J=n0,e.K=iK,e.L=i0,e.M=aB,e.N=aO,e.O=ak,e.P=e3,e.Q=aZ,e.R=tZ,e.S=n1,e.T=cf,e.U=aW,e.V=fr,e.W=aK,e.X=rG,e.Y=rV,e.Z=rU,e._=i6,e.a=function(e){return tI.API_CDN_URL_REGEX.test(e)},e.a$=sq,e.a0=iQ,e.a1=il,e.a2=n2,e.a3=class extends fr{},e.a4=aN,e.a5=aF,e.a6=nQ,e.a7=function(e){let i=e.value;return i?iQ(i)?fa(i,!0)?[]:[new fr(e.key,i,`invalid url "${i}"`)]:[new fr(e.key,i,`string expected, "${iK(i)}" found`)]:[]},e.a8=nG,e.a9=nJ,e.aA=tt,e.aB=ei,e.aC=eB,e.aD=sR,e.aE=lE,e.aF=sU,e.aG=sK,e.aH=function(e,i){let r={};for(let a=0;a<i.length;a++){let n=i[a];n in e&&(r[n]=e[n])}return r},e.aI=sN,e.aJ=sj,e.aK=class{constructor(e){this.entries={},this.scheduler=e}request(e,i,r,a){let n=this.entries[e]=this.entries[e]||{callbacks:[]};if(n.result){let[e,r]=n.result;return this.scheduler?this.scheduler.add(()=>{a(e,r)},i):a(e,r),()=>{}}return n.callbacks.push(a),n.cancel||(n.cancel=r((r,a)=>{for(let e of(n.result=[r,a],n.callbacks))this.scheduler?this.scheduler.add(()=>{e(r,a)},i):e(r,a);setTimeout(()=>delete this.entries[e],3e3)})),()=>{n.result||(n.callbacks=n.callbacks.filter(e=>e!==a),n.callbacks.length||(n.cancel(),delete this.entries[e]))}}},e.aL=function(e,i,r){let a=JSON.stringify(e.request);return e.data&&(this.deduped.entries[a]={result:[null,e.data]}),this.deduped.request(a,{type:"parseTile",isSymbolTile:e.isSymbolTile,zoom:e.tileZoom},i=>{let a=tK(e.request,(e,a,n,o)=>{e?i(e):a&&i(null,{vectorTile:r?void 0:new s4(new dT(a)),rawData:a,cacheControl:n,expires:o})});return()=>{a.cancel(),i()}},i)},e.aM=function(e){++tN>tO&&(e.getActor().send("enforceCacheSizeLimit",tL),tN=0)},e.aN=function(e){return e<=1?1:Math.pow(2,Math.floor(Math.log2(e)))},e.aO=lk,e.aP=p9,e.aQ=p7,e.aR=sB,e.aS=p8,e.aT=function(e,i){let r=document.createElement("video");r.muted=!0,r.onloadstart=function(){i(null,r)};for(let i=0;i<e.length;i++){let a=document.createElement("source");(function(e){let i=document.createElement("a");return i.href=e,i.protocol===location.protocol&&i.host===location.host})(e[i])||(r.crossOrigin="Anonymous"),a.src=e[i],r.appendChild(a)}return{cancel:()=>{}}},e.aU=cm,e.aV=function(e){return fetch(e).then(e=>e.arrayBuffer()).then(i=>cc(i,0,e))},e.aW=cU,e.aX=class{constructor(e,i,r,a){this.id=e,this.position=null!=i?new sB(i[0],i[1]):new sB(0,0),this.orientation=null!=r?r:[0,0,0],this.nodes=a,this.uploaded=!1,this.aabb=new ld([1/0,1/0,1/0],[-1/0,-1/0,-1/0]),this.matrix=[]}_applyTransformations(e,i){if(ei(e.matrix,i,e.matrix),e.meshes)for(let i of e.meshes){let r=ld.applyTransformFast(i.aabb,e.matrix);this.aabb.encapsulate(r)}if(e.children)for(let i of e.children)this._applyTransformations(i,e.matrix)}computeBoundsAndApplyParent(){let e=ee([]);for(let i of this.nodes)this._applyTransformations(i,e)}computeModelMatrix(e,i,r,a,n,o,s=!1){cL(this.matrix,this,e.transform,this.position,i,r,a,n,o,s)}upload(e){if(!this.uploaded){for(let i of this.nodes)cF(i,e);for(let e of this.nodes)ck(e);this.uploaded=!0}}destroy(){for(let e of this.nodes)cB(e)}},e.aY=tl,e.aZ=pE,e.a_=sG,e.aa=nX,e.ab=class{constructor(e){this.specification=e}possiblyEvaluate(e,i){return t_(e.expression.evaluate(i))}interpolate(e,i,r){return{x:ip(e.x,i.x,r),y:ip(e.y,i.y,r),z:ip(e.z,i.z,r),azimuthal:ip(e.azimuthal,i.azimuthal,r),polar:ip(e.polar,i.polar,r)}}},e.ac=nV,e.ad=aY,e.ae=sY,e.af=eP,e.ag=ep,e.ah=ti,e.ai=nW,e.aj=l9,e.ak=ip,e.al=8192,e.am=im,e.an=function(e){return e*e4},e.ao=ih,e.ap=class{constructor(e){this.specification=e}possiblyEvaluate(e,i){return function([e,i]){let r=t_([1,e,i]);return{x:r.x,y:r.y,z:r.z}}(e.expression.evaluate(i))}interpolate(e,i,r){return{x:ip(e.x,i.x,r),y:ip(e.y,i.y,r),z:ip(e.z,i.z,r)}}},e.aq=function(e,i,r=0,a=!0){let n=new e3(r,r),o=e.sub(n),s=i.add(n),l=[o,new e3(s.x,o.y),s,new e3(o.x,s.y)];return a&&l.push(o.clone()),l},e.ar=function(e,i){let r=[];for(let a=0;a<e.length;a++){let n=tr(a-1,-1,e.length-1),o=tr(a+1,-1,e.length-1),s=e[a],l=e[o],h=e[n].sub(s).unit(),u=l.sub(s).unit(),c=u.angleWithSep(h.x,h.y),d=h.add(u).unit().mult(-1*i/Math.sin(c/2));
7r.push(s.add(d))}return r},e.as=pI,e.at=lI,e.au=function(e,i,r=0){return ef(((i.x-r)*e.scale-e.x)*8192,(i.y*e.scale-e.y)*8192,s$(i.z,i.y))},e.av=eg,e.aw=eI,e.ax=ln,e.ay=di,e.az=function(e){let i=1/0,r=1/0,a=-1/0,n=-1/0;for(let o of e)i=Math.min(i,o.x),r=Math.min(r,o.y),a=Math.max(a,o.x),n=Math.max(n,o.y);return{min:new e3(i,r),max:new e3(a,n)}},e.b=function(e){return tI.API_FONTS_REGEX.test(e)},e.b$=uc,e.b0=of,e.b1=oD,e.b2=to,e.b3=oX,e.b4=pQ,e.b5=function(){nN.isLoading()||nN.isLoaded()||"deferred"!==nk()||nB()},e.b6=n3,e.b7=s0,e.b8=mZ,e.b9=ty,e.bA=ee,e.bB=es,e.bC=Q,e.bD=function(e,i){let{x:r,y:a}=e.point,n=l8(r,a,e.worldSize/e._pixelsPerMercatorPixel,0,0);return ei(n,n,l5(lW(i)))},e.bE=X,e.bF=eD,e.bG=function(e,i){var r=i[0]-e[0],a=i[1]-e[1],n=i[2]-e[2];return Math.sqrt(r*r+a*a+n*n)},e.bH=ew,e.bI=eC,e.bJ=eA,e.bK=d1,e.bL=dk,e.bM=d0,e.bN=function(e,i,r,a,n){let o=5*i+2;e.float32[o+0]=r,e.float32[o+1]=a,e.float32[o+2]=n},e.bO=pY,e.bP=eW,e.bQ=eK,e.bR=eX,e.bS=eY,e.bT=tr,e.bU=function(e,i,r,a){var n=new W(4);return n[0]=e,n[1]=i,n[2]=r,n[3]=a,n},e.bV=uU,e.bW=ly,e.bX=24,e.bY=ur,e.bZ=fi,e.b_=uu,e.ba=de,e.bb=h0,e.bc=sQ,e.bd=od,e.be=oG,e.bf=lj,e.bg=se,e.bh=hb,e.bi=p3,e.bj=function(e,i){let r=l9(i.zoom);if(0===r)return lW(e);let a=lJ(e),n=lQ(a),o=sU(a.getWest())*i.worldSize,s=sU(a.getEast())*i.worldSize,l=sj(a.getNorth())*i.worldSize,h=sj(a.getSouth())*i.worldSize,u=[o,l,0],c=[s,l,0],d=[o,h,0],p=[s,h,0],f=et([],i.globeMatrix);return eP(u,u,f),eP(c,c,f),eP(d,d,f),eP(p,p,f),n[0]=lX(n[0],d,r),n[1]=lX(n[1],p,r),n[2]=lX(n[2],c,r),n[3]=lX(n[3],u,r),ld.fromPoints(n)},e.bk=l3,e.bl=et,e.bm=l0,e.bn=lX,e.bo=op,e.bp=lU,e.bq=el,e.br=er,e.bs=mj,e.bt=dT,e.bu=tK,e.bv=function(e,i){let r=[];for(let a in e)a in i||r.push(a);return r},e.bw=ta,e.bx=["type","source","source-layer","minzoom","maxzoom","filter","layout"],e.by=e5,e.bz=function(e){var i=new W(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},e.c=tC,e.c$=function(e){return e*e*e*e*e},e.c0=dH,e.c1=pp,e.c2=px,e.c3=mJ,e.c4=eb,e.c5=ep,e.c6=eV,e.c7=function(e,i,r){r*=.5;var a=i[0],n=i[1],o=i[2],s=i[3],l=Math.sin(r),h=Math.cos(r);return e[0]=a*h+n*l,e[1]=n*h-a*l,e[2]=o*h+s*l,e[3]=s*h-o*l,e},e.c8=eU,e.c9=tv,e.cA=lc,e.cB=cS,e.cC=lO,e.cD=lK,e.cE=function(e,i,r,a,n,o,s,l,h){if("globe"===h.name)return lK(e,i,new lO(r,a,n),!1);let u=pE({z:r,x:a,y:n},h);return new ld([(o+u.x/u.scale)*i,i*(u.y/u.scale),s],[(o+u.x2/u.scale)*i,i*(u.y2/u.scale),l])},e.cF=function(e,i,r){return e[0]=Math.min(i[0],r[0]),e[1]=Math.min(i[1],r[1]),e[2]=Math.min(i[2],r[2]),e[3]=Math.min(i[3],r[3]),e},e.cG=function(e,i,r){return e[0]=Math.max(i[0],r[0]),e[1]=Math.max(i[1],r[1]),e[2]=Math.max(i[2],r[2]),e[3]=Math.max(i[3],r[3]),e},e.cH=function(e){return e8[Math.round((e+45+360)%360/90)%4]},e.cI=85.051129,e.cJ=eF,e.cK=6,e.cL=function(e){let i=ee(new Float64Array(16));ei(i,e.pixelMatrix,e.globeMatrix);let r=[0,sL,0],a=[0,sR,0];return eP(r,r,i),eP(a,a,i),[r[0]>0&&r[0]<=e.width&&r[1]>0&&r[1]<=e.height&&!he(e,new sB(e.center.lat,90)),a[0]>0&&a[0]<=e.width&&a[1]>0&&a[1]<=e.height&&!he(e,new sB(e.center.lat,-90))]},e.cM=function(e,i){var r,a,n,o,s,l,h,u;let{scale:c}=e.tileTransform,d=8192*c/(e.tileSize*Math.pow(2,i.zoom-e.tileID.overscaledZ+e.tileID.canonical.z));return r=new Float32Array(4),a=i.inverseAdjustmentMatrix,n=[d,d],o=a[1],s=a[2],l=a[3],h=n[0],u=n[1],r[0]=a[0]*h,r[1]=o*h,r[2]=s*u,r[3]=l*u,r},e.cN=cE,e.cO=ei,e.cP=cT,e.cQ=function(e){let i=cT(e,!0);return X([],[i[0],i[1],i[4],i[5]])},e.cR=ea,e.cS=lo,e.cT=en,e.cU=function(e){let{x:i,y:r}=e.point,{lng:a,lat:n}=e._center;return l8(i,r,e.worldSize,a,n)},e.cV=ey,e.cW=function(e){return e*e6},e.cX=lB,e.cY=lA,e.cZ=5,e.c_=function(e,i,r){let a=0;for(let r=0;r<2;++r)e[r]>0&&(a+=(e[r]-0)*(e[r]-0)),i[r]<0&&(a+=(0-i[r])*(0-i[r]));return a},e.ca=function(e,i){return e[0]=-i[0],e[1]=-i[1],e[2]=-i[2],e[3]=i[3],e},e.cb=eu,e.cc=function(e,i,r,a,n){var o=1/Math.tan(i/2);if(e[0]=o/r,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/(a-n);e[10]=(n+a)*s,e[14]=2*n*a*s}else e[10]=-1,e[14]=-2*a;return e},e.cd=function(e,i,r,a,n,o,s){var l=1/(i-r),h=1/(a-n),u=1/(o-s);return e[0]=-2*l,e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[5]=-2*h,e[6]=0,e[7]=0,e[8]=0,e[9]=0,e[10
7]=2*u,e[11]=0,e[12]=(i+r)*l,e[13]=(n+a)*h,e[14]=(s+o)*u,e[15]=1,e},e.ce=function(e,i){return e/sV(i)},e.cf=function(e,i,r){e[4*i+0]=r[0],e[4*i+1]=r[1],e[4*i+2]=r[2],e[4*i+3]=r[3]},e.cg=sh,e.ch=sd,e.ci=su,e.cj=sc,e.ck=s_,e.cl=pG,e.cm=function(){var e=new W(4);return W!=Float32Array&&(e[1]=0,e[2]=0),e[0]=1,e[3]=1,e},e.cn=function(e,i,r){var a=i[0],n=i[1],o=i[2],s=i[3],l=Math.sin(r),h=Math.cos(r);return e[0]=a*h+o*l,e[1]=n*h+s*l,e[2]=-(a*l)+o*h,e[3]=-(n*l)+s*h,e},e.co=function(e,i){return e[0]===i[0]&&e[1]===i[1]&&e[2]===i[2]&&e[3]===i[3]},e.cp=eL,e.cq=function(e){var i=e[0],r=e[1],a=e[2],n=e[3];return Math.sqrt(i*i+r*r+a*a+n*n)},e.cr=ek,e.cs=eR,e.ct=lF,e.cu=3,e.cv=2,e.cw=7,e.cx=6,e.cy=eM,e.cz=ec,e.d=function(e){return tI.API_TILEJSON_REGEX.test(e)},e.d$=ds,e.d0=sV,e.d1=45,e.d2=sp,e.d3=function(e,i,r){let a=Math.sqrt(e*e+i*i+r*r),n=a>0?Math.acos(r/a)*e6:0,o=0!==e||0!==i?Math.atan2(-i,-e)*e6+90:0;return o<0&&(o+=360),[a,o,n]},e.d4=ef,e.d5=t_,e.d6=sX,e.d7=e_,e.d8=ld,e.d9=eg,e.dA=function(e,i,r){let a=l9(r.zoom),n=e.style.map._antialias,o=e.terrain&&e.terrain.exaggeration()>0;return 0===a&&!n&&!o},e.dB=function(e){let i=e.pixelsPerMeter,r=i/(1/sV(e.center.lat)),a=ee(new Float64Array(16));return er(a,a,[e.point.x,e.point.y,0]),ea(a,a,[r,r,i]),Float32Array.from(a)},e.dC=lJ,e.dD=function(e){return Math.round(Math.pow(Math.abs(Math.sin((e=tt(e,-80.051129,80.051129)/80.051129*90)*e4)),3)*(sD.length-1))},e.dE=function(e,i,r,a){let n=i.getNorth(),o=i.getSouth(),s=i.getWest(),l=i.getEast(),h=1<<e.z,u=l-s,c=n-o,d=u/64,p=-c/sD[r],f=[0,d,0,p,0,0,n,s,0];if(e.z>0){let e=180/a;J(f,f,[e/u+1,0,0,0,e/c+1,0,-.5*e/d,.5*e/p,1])}return f[2]=h,f[5]=e.x,f[8]=e.y,f},e.dF=lW,e.dG=function(e,i,r){let a=ee(new Float64Array(16)),n=(i/(1<<e)-.5)*Math.PI*2;return eo(a,r.globeMatrix,n),Float32Array.from(a)},e.dH=class{isDataAvailableAtPoint(e){let i=this._source();if(this.isUsingMockSource()||!i||e.y<0||e.y>1)return!1;let r=i.getSource().maxzoom,a=1<<r,n=Math.floor(e.x),o=Math.floor((e.x-n)*a),s=Math.floor(e.y*a),l=this.findDEMTileFor(new lk(r,n,r,o,s));return!(!l||!l.dem)}getAtPointOrZero(e,i=0){return this.getAtPoint(e,i)||0}getAtPoint(e,i,r=!0){if(this.isUsingMockSource())return null;null==i&&(i=null);let a=this._source();if(!a||e.y<0||e.y>1)return i;let n=a.getSource().maxzoom,o=1<<n,s=Math.floor(e.x),l=e.x-s,h=new lk(n,s,n,Math.floor(l*o),Math.floor(e.y*o)),u=this.findDEMTileFor(h);if(!u||!u.dem)return i;let c=u.dem,d=1<<u.tileID.canonical.z,p=(l*d-u.tileID.canonical.x)*c.dim,f=(e.y*d-u.tileID.canonical.y)*c.dim,m=Math.floor(p),_=Math.floor(f);return(r?this.exaggeration():1)*ip(ip(c.get(m,_),c.get(m,_+1),f-_),ip(c.get(m+1,_),c.get(m+1,_+1),f-_),p-m)}getAtTileOffset(e,i,r){let a=1<<e.canonical.z;return this.getAtPointOrZero(new sY(e.wrap+(e.canonical.x+i/8192)/a,(e.canonical.y+r/8192)/a))}getAtTileOffsetFunc(e,i,r,a){return n=>{let o=this.getAtTileOffset(e,n.x,n.y),s=a.upVector(e.canonical,n.x,n.y);return eb(s,s,o*a.upVectorScale(e.canonical,i,r).metersToTile),s}}getForTilePoints(e,i,r,a){if(this.isUsingMockSource())return!1;let n=fl.create(this,e,a);return!!n&&(i.forEach(e=>{e[2]=this.exaggeration()*n.getElevationAt(e[0],e[1],r)}),!0)}getMinMaxForTile(e){if(this.isUsingMockSource())return null;let i=this.findDEMTileFor(e);if(!i||!i.dem)return null;let r=i.dem.tree,a=i.tileID,n=1<<e.canonical.z-a.canonical.z,o=e.canonical.x/n-a.canonical.x,s=e.canonical.y/n-a.canonical.y,l=0;for(let i=0;i<e.canonical.z-a.canonical.z&&!r.leaves[l];i++){let e=2*Math.floor(s*=2)+Math.floor(o*=2);l=r.childOffsets[l]+e,o%=1,s%=1}return{min:this.exaggeration()*r.minimums[l],max:this.exaggeration()*r.maximums[l]}}getMinElevationBelowMSL(){throw Error("Pure virtual method called.")}raycast(e,i,r){throw Error("Pure virtual method called.")}pointCoordinate(e){throw Error("Pure virtual method called.")}_source(){throw Error("Pure virtual method called.")}isUsingMockSource(){throw Error("Pure virtual method called.")}exaggeration(){throw Error("Pure virtual method called.")}findDEMTileFor(e){throw Error("Pure virtual method called.")}get visibleDemTiles(){throw Error("Getter must be implemented in subclass.")}getMinMaxForVisibleTiles(){let e=this.visibleDemTiles;if(0===e.length)return null;let i=!1,r=Number.MAX_VALUE,a=5e-324;for(let n of e){let e=this.getMinMaxForTile(n.tileID);e&&(r=Math.min(r,e.min),a=Math.max(a,e.max),i=!0)}return i?{min:r,max:a}:null}},e.dI=hm,e.dJ=lG,e.dK=function(e,i){return[Math.pow(e[0],2.2)*i,Math.pow(e[1],2.2)*i,Math.pow(e[2],2.2)*i]},e.dL=Y,e.dM=function(e,i){var r=Math.sin(i),a=Math.cos(i);return e[0]=a,e[1]=r,e[2]=0,e[3]=-r,e[4]=a,e[5]=0,e[6]=0,e[7]=0,e[8]=1,e},e.dN=ez,e.dO=l6,e.dP=tT,e.dQ=tS,e.dR=256,e.dS=function(e,i){let r=[
70,0,0];return eP(r,r,l3(lW(i.canonical))),eP(r,r,e),r},e.dT=e=>({u_matrix:new s_(e),u_texsize:new sc(e),u_pixels_to_tile_units:new sx(e),u_device_pixel_ratio:new su(e),u_width_scale:new su(e),u_floor_width_scale:new su(e),u_image:new sh(e),u_units_to_pixels:new sc(e),u_tile_units_to_pixels:new su(e),u_alpha_discard_threshold:new su(e),u_trim_offset:new sc(e),u_trim_fade_range:new sc(e),u_trim_color:new sp(e),u_emissive_strength:new su(e),u_zbias_factor:new su(e),u_tile_to_meter:new su(e),u_ground_shadow_factor:new sd(e),u_pattern_transition:new su(e)}),e.dU=e=>({u_matrix:new s_(e),u_pixels_to_tile_units:new sx(e),u_device_pixel_ratio:new su(e),u_width_scale:new su(e),u_floor_width_scale:new su(e),u_units_to_pixels:new sc(e),u_dash_image:new sh(e),u_gradient_image:new sh(e),u_image_height:new su(e),u_texsize:new sc(e),u_tile_units_to_pixels:new su(e),u_alpha_discard_threshold:new su(e),u_trim_offset:new sc(e),u_trim_fade_range:new sc(e),u_trim_color:new sp(e),u_emissive_strength:new su(e),u_zbias_factor:new su(e),u_tile_to_meter:new su(e),u_ground_shadow_factor:new sd(e)}),e.dV=e=>({u_camera_to_center_distance:new su(e),u_extrude_scale:new sx(e),u_device_pixel_ratio:new su(e),u_matrix:new s_(e),u_inv_rot_matrix:new s_(e),u_merc_center:new sc(e),u_tile_id:new sd(e),u_zoom_transition:new su(e),u_up_dir:new sd(e),u_emissive_strength:new su(e)}),e.dW=oz,e.dX=dv,e.dY=class{constructor(e,i,r,a){this.context=e,this.format=a,this.size=r,this.texture=e.gl.createTexture();let[n,o,s]=this.size,{gl:l}=e;l.bindTexture(l.TEXTURE_3D,this.texture),e.pixelStoreUnpackFlipY.set(!1),e.pixelStoreUnpack.set(1),e.pixelStoreUnpackPremultiplyAlpha.set(!1),"data"in i&&i.data&&l.texImage3D(l.TEXTURE_3D,0,this.format,n,o,s,0,cd(this.format),cp(this.format),i.data)}bind(e,i){let{context:r}=this,{gl:a}=r;a.bindTexture(a.TEXTURE_3D,this.texture),e!==this.minFilter&&(a.texParameteri(a.TEXTURE_3D,a.TEXTURE_MAG_FILTER,e),a.texParameteri(a.TEXTURE_3D,a.TEXTURE_MIN_FILTER,e),this.minFilter=e),i!==this.wrapS&&(a.texParameteri(a.TEXTURE_3D,a.TEXTURE_WRAP_S,i),a.texParameteri(a.TEXTURE_3D,a.TEXTURE_WRAP_T,i),this.wrapS=i)}destroy(){let{gl:e}=this.context;e.deleteTexture(this.texture),this.texture=null}},e.dZ=hn,e.d_=(e,i,r,a,n,o)=>{let s,l=e.transform,h="globe"===l.projection.name;if("map"===o.paint.get("circle-pitch-alignment"))if(h){let e=l6(l.zoom,i.canonical)*l._pixelsPerMercatorPixel;s=Float32Array.from([e,0,0,e])}else s=l.calculatePixelsToTileUnitsMatrix(r);else s=new Float32Array([l.pixelsToGLUnits[0],0,0,l.pixelsToGLUnits[1]]);let u={u_camera_to_center_distance:e.transform.getCameraToCenterDistance(l.projection),u_matrix:e.translatePosMatrix(i.projMatrix,r,o.paint.get("circle-translate"),o.paint.get("circle-translate-anchor")),u_device_pixel_ratio:tP.devicePixelRatio,u_extrude_scale:s,u_inv_rot_matrix:ha,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(h){u.u_inv_rot_matrix=a,u.u_merc_center=n,u.u_tile_id=[i.canonical.x,i.canonical.y,1<<i.canonical.z],u.u_zoom_transition=l9(l.zoom);let e=8192*n[0],r=8192*n[1];u.u_up_dir=l.projection.upVector(new lO(0,0,0),e,r)}return u},e.da=function(e){return[Math.pow(e[0],1/2.2),Math.pow(e[1],1/2.2),Math.pow(e[2],1/2.2)]},e.db=fa,e.dc=function(e,i){return e.readFields(fy,{icons:[]},i)},e.dd=uQ,e.de=pr,e.df=pi,e.dg=tX,e.dh=nL,e.di=tR,e.dj=t9,e.dk=tc,e.dl=function(e){let i=e.indexOf("\x1f");return i>=0?e.slice(0,i):e},e.dm=function(e){return e.indexOf("\x1f")>=0},e.dn=function(e){let i=e.lastIndexOf("\x1f");return i>=0?e.slice(i+1):""},e.dp=function(e){let i=[],r=e.id;return void 0===r&&i.push({message:`layers.${r}: missing required property "id"`}),void 0===e.render&&i.push({message:`layers.${r}: missing required method "render"`}),e.renderingMode&&"2d"!==e.renderingMode&&"3d"!==e.renderingMode&&i.push({message:`layers.${r}: property "renderingMode" must be either "2d" or "3d"`}),i},e.dq=function(e,i,r,a){return"custom"===e.type?new fe(e,i):new f_[e.type](e,i,r,a)},e.dr=tu,e.ds=function(e){let i=e.indexOf("\x1f");return i>=0?e.slice(i+1):""},e.dt=class extends mZ{constructor(e,i){super(e._vectorTileFeature,e._z,e._x,e._y,e.id),e.state&&(this.state=Object.assign({},e.state)),this.target=i.target,this.namespace=i.namespace,i.properties&&(this.properties=i.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(){let e=super.toJSON();return e.target=this.target,e.namespace=this.namespace,e}},e.du=nF,e.dv=tY,e.dw=function(e){return e({pluginStatus:nR,pluginURL:nD}),nF.on("pluginStateChange",e),e},e.dx=sf,e.dy=class extends sl{constructor(e){super(e),this.current=sg}set(e,i,r){if(this.fetchUniformLocation(e,i)){for(let e=0;e<9;e++)if(r[e]!==this.current[e]){this.current=r,this.gl.uniformMatrix3fv(this.location,!1,r);break}}}},e.dz=e9,e.e=tI,e.e$=function(){let e=E;e&&(e.isPreloaded()&&1===e.numActive()?(e.release(uY),E=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()"))},e.e0=iV,e.e1=(e,i,r,a,n,o,s,l,h,u)=>{let c=e.transform,d=c.pitch<15?dr(.07,.7,tt((14-c.zoom)/5,0,1)):.07,p="none"===r.paint.get("line-trim-color-use-theme").
7constantOr("default");return{u_matrix:dn(e,i,r,a),u_texsize:i.imageAtlasTexture?i.imageAtlasTexture.size:[0,0],u_pixels_to_tile_units:c.calculatePixelsToTileUnitsMatrix(i),u_device_pixel_ratio:n,u_width_scale:o,u_floor_width_scale:s,u_image:0,u_tile_units_to_pixels:da(i,c),u_units_to_pixels:[1/c.pixelsToGLUnits[0],1/c.pixelsToGLUnits[1]],u_alpha_discard_threshold:0,u_trim_offset:l,u_trim_fade_range:r.paint.get("line-trim-fade-range"),u_trim_color:r.paint.get("line-trim-color").toPremultipliedRenderColor(p?null:r.lut).toArray01(),u_emissive_strength:r.paint.get("line-emissive-strength"),u_zbias_factor:d,u_tile_to_meter:sX(i.tileID.canonical,0),u_ground_shadow_factor:h,u_pattern_transition:u}},e.e2=(e,i,r,a,n,o,s,l,h,u)=>{let c=e.transform,d=c.calculatePixelsToTileUnitsMatrix(i),p="none"===r.paint.get("line-trim-color-use-theme").constantOr("default"),f=c.pitch<15?dr(.07,.7,tt((14-c.zoom)/5,0,1)):.07;return{u_matrix:dn(e,i,r,a),u_pixels_to_tile_units:d,u_device_pixel_ratio:o,u_width_scale:s,u_floor_width_scale:l,u_units_to_pixels:[1/c.pixelsToGLUnits[0],1/c.pixelsToGLUnits[1]],u_dash_image:0,u_gradient_image:1,u_image_height:n,u_texsize:dl(r)&&i.lineAtlasTexture?i.lineAtlasTexture.size:[0,0],u_tile_units_to_pixels:da(i,e.transform),u_alpha_discard_threshold:0,u_trim_offset:h,u_trim_fade_range:r.paint.get("line-trim-fade-range"),u_trim_color:r.paint.get("line-trim-color").toPremultipliedRenderColor(p?null:r.lut).toArray01(),u_emissive_strength:r.paint.get("line-emissive-strength"),u_zbias_factor:f,u_tile_to_meter:sX(i.tileID.canonical,0),u_ground_shadow_factor:u}},e.e3=ts,e.e4=h_,e.e5=s$,e.e6=lN,e.e7=uC,e.e8=uO,e.e9=0x80000000,e.eA=oC,e.eB=oU,e.eC=function(e,i,r,a,n,o,s,l,h,u,c,d,p,f,m,_){var g=new W(16);return g[0]=e,g[1]=i,g[2]=r,g[3]=a,g[4]=n,g[5]=o,g[6]=s,g[7]=l,g[8]=h,g[9]=u,g[10]=c,g[11]=d,g[12]=p,g[13]=f,g[14]=m,g[15]=_,g},e.eD=6371008.8,e.eE=oV,e.eF=oN,e.eG=class{constructor(){this._updateTime=0,this._sourceIds=[],this._activeRegions=[],this._prevRegions=[],this._globalClipBounds={min:new e3(1/0,1/0),max:new e3(-1/0,-1/0)}}clear(){this._activeRegions.length>0&&++this._updateTime,this._activeRegions=[],this._prevRegions=[]}get updateTime(){return this._updateTime}getReplacementRegionsForTile(e,i=!1){let r=ul(new e3(0,0),new e3(8192,8192),e),a=[];if(i&&!uo(r,this._globalClipBounds))return a;for(let i of this._activeRegions){if(i.hiddenByOverlap||!uo(r,i))continue;let n=function(e,i,r){let a=1<<r.canonical.z,n=((i.x-r.wrap)*a-r.canonical.x)*8192,o=(i.y*a-r.canonical.y)*8192;return{min:new e3(((e.x-r.wrap)*a-r.canonical.x)*8192,(e.y*a-r.canonical.y)*8192),max:new e3(n,o)}}(i.min,i.max,e);a.push({min:n.min,max:n.max,sourceId:this._sourceIds[i.priority],footprint:i.footprint,footprintTileId:i.tileId,order:i.order,clipMask:i.clipMask,clipScope:i.clipScope})}return a}setSources(e){this._setSources(e.map(e=>({getSourceId:()=>e.cache.id,getFootprints:()=>{let i=[];for(let r of e.cache.getVisibleCoordinates()){let a=e.cache.getTile(r).buckets[e.layer];a&&a.updateFootprints(r.toUnwrapped(),i)}return i},getOrder:()=>e.order,getClipMask:()=>e.clipMask,getClipScope:()=>e.clipScope})))}_addSource(e){let i=e.getFootprints();if(0===i.length)return;let r=e.getOrder(),a=e.getClipMask(),n=e.getClipScope();for(let e of i){if(!e.footprint)continue;let i=ul(e.footprint.min,e.footprint.max,e.id);this._activeRegions.push({min:i.min,max:i.max,hiddenByOverlap:!1,priority:this._sourceIds.length,tileId:e.id,footprint:e.footprint,order:r,clipMask:a,clipScope:n})}this._sourceIds.push(e.getSourceId())}_computeReplacement(){this._activeRegions.sort((e,i)=>e.priority-i.priority||ua(e.min,i.min)||ua(e.max,i.max)||e.order-i.order||e.clipMask-i.clipMask||function(e,i){let r=(e,i)=>e+i;return e.length-i.length||e.reduce(r,"").localeCompare(i.reduce(r,""))}(e.clipScope,i.clipScope));let e=this._activeRegions.length!==this._prevRegions.length;if(!e){let i=0;for(;!e&&i!==this._activeRegions.length;){let r=this._activeRegions[i],a=this._prevRegions[i];e=r.priority!==a.priority||!un(r,a)||r.order!==a.order||r.clipMask!==a.clipMask||!e5(r.clipScope,a.clipScope),++i}}if(e){for(let e of(++this._updateTime,this._activeRegions))e.order!==ut&&(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));let e=e=>{let i=this._activeRegions;if(e>=i.length)return e;let r=i[e].priority;for(;e<i.length&&i[e].priority===r;)++e;return e};if(this._sourceIds.length>1){let i=0,r=e(0);for(;i!==r;){let a=i,n=i;for(;a!==r;){let e=this._activeRegions[a];e.hiddenByOverlap=!1;for(let i=0;i<n;i++){let r=this._activeRegions[i];if(!r.hiddenByOverlap&&e.order===ut&&uo(e,r)&&(e.hiddenByOverlap=function e(i,r,a,n){if(!i||!a)return!1;let o=i.vertices;if(!r.canonical.equals(n.canonical)||r.wrap!==n.wrap){if(a.vertices.length<i.vertices.length)return e(a,n,i,r);let s=r.canonical,l=n.canonical,h=Math.pow(2,l.z-s.z);o=i.vertices.map(e=>new e3((e.x+8192*s.x)*h-8192*l.x,(e.y+8192*s.y)*h-8192*l.y))}return uh(a,o,i.indices,0,i.indices.length,0,0)}(e.footprint,e.tileId,r.footprint,r.tileId),e.hiddenByOverlap))break}++a}r=e(i=r)}}}}_setSources(e){[this._prevRegions,this._activeRegions]=[this._activeRegions,[]],this._sourceIds=[];for(let i=e.length-1;i>=0;i--)this._addSource(e[i]);this._computeReplacement()}},e.eH=ut,e.eI=class{constructor(e){this._createGrid(e),this._createPoles(e)}destroy(){for(let e of(this._poleIndexBuffer.destroy(),this._gridBuffer.destroy(),this._gridIndexBuffer.destroy(),this._poleNorthVertexBuffer.destroy(),this._poleSouthVertexBuffer.destroy(),this._poleSegments))e.destroy();for(let e of this._gridSegments)e.withSkirts.destroy(),e.withoutSkirts.destroy()}_fillGridMeshWithLods(e,i){let r=new od,a=new oD,n=[],o=e+1+2,s=i[0]+1,l=i[0]+1+(1+i.length),h=(e,i,r)=>{let a=e===o-1?e-2:0===e?e:e-1;return[a+=24575*!!r,i]};for(let e=0;e<o;++e)r.emplaceBack(...h(e,0,!0));for(let e=0;e<s;++e)for(let i=0;i<o;++i)r.emplaceBack(...h(i,e,0===i||i===o-1));for(let e=0;e<i.length;++e){let a=i[e];for(let e=0;e<o;++e)r.emplaceBack(...h(e,a,!0))}for(let e=0;e<i.length;++e){let s=a.length,h=i[e]+1+2,u=new oD;for(let r=0;r<h-1;r++){let n=r===h-2,s=n?o*(l-i.length+e-r):o;for(let e=0;e<o-1;e++){let i=r*o+e;0===r||n||0===e||e===o-2?(u.emplaceBack(i+1,i,i+s),u.emplaceBack(i+s,i+s+1,i+1)):(a.emplaceBack(i+1,i,i+s),a.emplaceBack(i+s,i+s+1,i+1))}}let c=se.simpleSegment(0,s,r.length,a.length-s);for(let e=0;e<u.uint16.length;e+=3)a.emplaceBack(u.uint16[e],u.uint16[e+1],u.uint16[e+2]);let d=se.simpleSegment(0,s,r.length,a.length-s);n.push({withoutSkirts:c,withSkirts:d})}return{vertices:r,indices:a,segments:n}}_createGrid(e){let i=this._fillGridMeshWithLods(64,sD);this._gridSegments=i.segments,this._gridBuffer=e.createVertexBuffer(i.vertices,lj.members),this._gridIndexBuffer=e.createIndexBuffer(i.indices,!0)}_createPoles(e){let i=new oD;for(let e=0;e<=64;e++)i.emplaceBack(0,e+1,e+2);this._poleIndexBuffer=e.createIndexBuffer(i,!0);let r=new ok,a=new ok,n=new ok,o=new ok;this._poleSegments=[];for(let e=0,i=0;e<5;e++){let s=360/(1<<e);r.emplaceBack(0,-sR,0,.5,0),a.emplaceBack(0,-sR,0,.5,1),n.emplaceBack(0,-sR,0,.5,.5),o.emplaceBack(0,-sR,0,.5,.5);for(let e=0;e<=64;e++){let i=e/64,l=0,h=ip(0,s,i),[u,c,d]=sO(hi,hr,h,sR);r.emplaceBack(u,c,d,i,l),a.emplaceBack(u,c,d,i,1-l);let p=h*e4;i=.5+.5*Math.sin(p),l=.5+.5*Math.cos(p),n.emplaceBack(u,c,d,i,l),o.emplaceBack(u,c,d,i,1-l)}this._poleSegments.push(se.simpleSegment(i,0,66,64)),i+=66}this._poleNorthVertexBuffer=e.createVertexBuffer(r,lV,!1),this._poleSouthVertexBuffer=e.createVertexBuffer(a,lV,!1),this._texturedPoleNorthVertexBuffer=e.createVertexBuffer(n,lV,!1),this._texturedPoleSouthVertexBuffer=e.createVertexBuffer(o,lV,!1)}getGridBuffers(e,i){return[this._gridBuffer,this._gridIndexBuffer,i?this._gridSegments[e].withSkirts:this._gridSegments[e].withoutSkirts]}getPoleBuffers(e,i){return[i?this._texturedPoleNorthVertexBuffer:this._poleNorthVertexBuffer,i?this._texturedPoleSouthVertexBuffer:this._poleSouthVertexBuffer,this._poleIndexBuffer,this._poleSegments[e]]}},e.eJ=ui,e.eK=e7,e.eL=function(){return!!document.fullscreenElement||!!document.webkitFullscreenElement},e.eM=te,e.eN=sW,e.eO=function(e,i,r){return e[0]=i[0]/r[0],e[1]=i[1]/r[1],e[2]=i[2]/r[2],e},e.eP=ey,e.eQ=sF,e.eR=eS,e.eS=em,e.eT=function([e,i,r]){let a=Math.hypot(e,i,r);return new sB(Math.atan2(e,r)*e6,(.5*Math.PI-Math.acos(-i/a))*e6)},e.eU=ek,e.eV=cA,e.eW=function(e){let i=e.navigator?e.navigator.userAgent:null;return!!function(e){if(null==tx){let i=e.navigator?e.navigator.userAgent:null;tx=!!e.safari||!(!i||!(/\b(iPad|iPhone|iPod)\b/.test(i)||i.match("Safari")&&!i.match("Chrome")))}return tx}(e)&&!(!i||!(i.match("Version/15.4")||i.match("Version/15.5")||i.match(/CPU (OS|iPhone OS) (15_4|15_5) like Mac OS X/)))},e.eX=function(e,i){tL=e,tO=i},e.eY=he,e.eZ=l7,e.e_=function(e){let i=[0,0,0],r=ee(new Float64Array(16));return ei(r,e.pixelMatrix,e.globeMatrix),eP(i,i,r),new e3(i[0],i[1])},e.ea=450,e.eb=7,e.ec=sZ,e.ed=function(e,i){if(e===i){var r=i[1],a=i[2],n=i[3],o=i[6],s=i[7],l=i[11];e[1]=i[4],e[2]=i[8],e[3]=i[12],e[4]=r,e[6]=i[9],e[7]=i[13],e[8]=a,e[9]=o,e[11]=i[14],e[12]=n,e[13]=s,e[14]=l}else e[0]=i[0],e[1]=i[4],e[2]=i[8],e[3]=i[12],e[4]=i[1],e[5]=i[5],e[6]=i[9],e[7]=i[13],e[8]=i[2],e[9]=i[6],e[10]=i[10],e[11]=i[14],e[12]=i[3],e[13]=i[7],e[14]=i[11],e[15]=i[15];return e},e.ee=.0038760859073359074,e.ef=ou,e.eg=oH,e.eh=256,e.ei=l5,e.ej=ov,e.ek=eo,e.el=function(e,i){return e[0]=i[0],e[1]=i[1],e[2]=i[2],e[3]=i[4],e[4]=i[5],e[5]=i[6],e[6]=i[8],e[7]=i[9],e[8]=i[10],e},e.em=ok,e.en=oB,e.eo=aI,e.ep=function(e,i,r,a,n){return tt((e-i)/(r-i)*(n-a)+a,a,n)},e.eq=ej,e.er=function(e,i){var r=i[0],a=i[1],n=i[2],o=i[3],s=i[4],l=i[5],h=i[6],u=i[7],c=i[8],d=c*s-l*u,p=-c*o+l*h,f=u*o-s*h,m=r*d+a*p+n*f;return m?(e[0]=d*(m=1/m),e[1]=(-c*a+n*u)*m,e[2]=(l*a-n*s)*m,e[3]=p*m,e[4]=(c*r-n*h)*m,e[5]=(-l*r+n*o)*m,e[6]=f*m,e[7]=(-u*r+a*h)*m,e[8]=(s*r-a*o)*m,e):null},e.es=2,e.et=eE,e.eu=cz,e.ev=[1,1,1],e.ew=fl,e.ex=eO,e.ey=function(e,i,r,a){var n=i[0],o=i[1],s=i[2],l=i[3];return e[0]=n+a*(r[0]-n),e[1]=o+a*(r[1]-o),e[2]=s+a*(r[2]-s),e[3]=l+a*(r[3]-l),e},e.ez=cD,e.f=function(e){return btoa(encodeURIComponent(e).replace(/%([0-9A-F]{2})/g,(e,i)=>String.fromCharCode(Number("0x"+i))))},e.f0=function(){uQ().acquire(uY)},e.f1=nk,e.f2=function(e,i,r=!1){if(nR===nP.deferred||nR===nP.loading||nR===nP.loaded)throw Error("setRTLTextPlugin cannot be called multiple times.");nD=tP.resolveURL(e),nR=nP.deferred,nz=i,nO(),r||nB()},e.f3=function(e){u5=tP.resolveURL(e),u6||(u6=new uJ(uQ(),new ir)),u6.broadcast("setMeshoptUrl",u5)},e.f4=ct,e.f5=function(e){u2=tP.resolveURL(e),u6||(u6=new uJ(uQ(),new ir)),u6.broadcast("setDracoUrl",u2)},e.f6=ce,e.f7=uX,e.f8=function(e){let i=tk();if(!i)return;let r=i.delete(tD);e&&r.then(()=>e()).catch(e)},e.f9=uK,e.fA=function(e){tB(),null!=l&&l.then(i=>{i.keys().then(r=>{for(let a=0;a<r.length-e;a++)i.delete(r[a]).catch(e=>tf(e.message))}).catch(e=>tf(e.message))}).catch(e=>tf(e.message))},e.fa=a3,e.fb=hp,e.fc=2,e.fd=m$,e.fe=mW,e.ff=c6,e.fg=s8,e.fh="hd_road_elevation",e.fi=lm,e.fj=th,e.fk=hq,e.fl=d9,e.fm=1,e.fn=function(e,i,r,a,n,o,s,l=1,h,u,c){e.createArrays(),e.tilePixelRatio=8192/(512*e.overscaling),e.compareText={},e.iconsNeedLinear=!1;let d=e.layers[0].layout,p=e.layers[0]._unevaluatedLayout._values,f={};f.scaleFactor=l,f.textSizeScaleRange=d.get("text-size-scale-range"),f.iconSizeScaleRange=d.get("icon-size-scale-range");let[m,_]=f.textSizeScaleRange,[g,y]=f.iconSizeScaleRange;f.textScaleFactor=tt(f.scaleFactor,m,_),f.iconScaleFactor=tt(f.scaleFactor,g,y);let x=p["text-size"],v=p["icon-size"];
7if("composite"===e.textSizeData.kind){let{minZoom:i,maxZoom:r}=e.textSizeData;f.compositeTextSizes=[x.possiblyEvaluate(new nV(i,{worldview:c}),o),x.possiblyEvaluate(new nV(r,{worldview:c}),o)]}if("composite"===e.iconSizeData.kind){let{minZoom:i,maxZoom:r}=e.iconSizeData;f.compositeIconSizes=[v.possiblyEvaluate(new nV(i,{worldview:c}),o),v.possiblyEvaluate(new nV(r,{worldview:c}),o)]}f.layoutTextSize=x.possiblyEvaluate(new nV(s+1,{worldview:c}),o),f.layoutIconSize=v.possiblyEvaluate(new nV(s+1,{worldview:c}),o),f.textMaxSize=x.possiblyEvaluate(new nV(18,{worldview:c}),o);let b=d.get("symbol-placement"),w="map"===d.get("text-rotation-alignment")&&"point"!==b,T=d.get("text-size"),S=!1,E=[];for(let s of e.features){let l=d.get("text-font").evaluate(s,{},o).join(","),m=T.evaluate(s,{},o)*f.textScaleFactor,_=f.layoutTextSize.evaluate(s,{},o)*f.textScaleFactor,g=f.layoutIconSize.evaluate(s,{},o)*f.iconScaleFactor,y={horizontal:{},vertical:void 0},x=s.text,v,I=[0,0];if(x){let a=x.toString(),u=24*d.get("text-letter-spacing").evaluate(s,{},o),c=24*d.get("text-line-height").evaluate(s,{},o),p=!function(e){for(let r of e){var i;if(a9(i=r.charCodeAt(0))||a7(i)||ne(i)||nv(i)||nS(i))return!1}return!0}(a)?0:u,f=d.get("text-anchor").evaluate(s,{},o),g=d.get("text-variable-anchor");if(!g){let e=d.get("text-radial-offset").evaluate(s,{},o);if(e)I=pp(f,[24*e,pc]);else{let e=d.get("text-offset").evaluate(s,{},o);I=[24*e[0],24*e[1]]}}let v=w?"center":d.get("text-justify").evaluate(s,{},o),T="point"===b,S=T?24*d.get("text-max-width").evaluate(s,{},o):1/0,E=o=>{e.allowVerticalPlacement&&nI(a)&&(y.vertical=dV(x,i,r,n,l,S,c,f,o,p,I,dk.vertical,!0,_,m,h))};if(!w&&g){let e="auto"===v?g.map(e=>px(e)):[v],a=!1;for(let o=0;o<e.length;o++){let s=e[o];if(!y.horizontal[s])if(a)y.horizontal[s]=y.horizontal[0];else{let e=dV(x,i,r,n,l,S,c,"center",s,p,I,dk.horizontal,!1,_,m,h);e&&(y.horizontal[s]=e,a=1===e.positionedLines.length)}}E("left")}else{if("auto"===v&&(v=px(f)),T||d.get("text-writing-mode").indexOf("horizontal")>=0||!nI(a)){let e=dV(x,i,r,n,l,S,c,f,v,p,I,dk.horizontal,!1,_,m,h);e&&(y.horizontal[v]=e)}E(T?"left":v)}}let A,C,M,P,z,R,D=!1,L=d.get("icon-text-fit").evaluate(s,{},o);if(s.icon&&s.icon.hasPrimary()){let i=p_(s.icon,e.iconSizeData,p["icon-size"],o,e.zoom,s,h,f.iconScaleFactor,c);A=i.iconPrimary,M=i.iconSecondary;let r=A.toString();if((C=a.get(r))&&(z=d.get("icon-offset").evaluate(s,{},o),R=d.get("icon-anchor").evaluate(s,{},o),v=function(e,i,r,a){let{horizontalAlign:n,verticalAlign:o}=dH(a),s=r[0]-e.displaySize[0]*n,l=r[1]-e.displaySize[1]*o;return{imagePrimary:e,imageSecondary:i,top:l,bottom:l+e.displaySize[1],left:s,right:s+e.displaySize[0]}}(n.get(r),M?n.get(M.toString()):void 0,z,R),D=C.sdf,void 0===e.sdfIcons?e.sdfIcons=C.sdf:e.sdfIcons!==C.sdf&&tf("Style sheet warning: Cannot mix SDF and non-SDF icons in one buffer"),(C.pixelRatio!==e.pixelRatio||0!==d.get("icon-rotate").constantOr(1))&&(e.iconsNeedLinear=!0)),M){let e=M.toString();P=a.get(e)}}S=S||!(!s.icon||!s.icon.hasSecondary());let O=pb(y.horizontal)||y.vertical;e.iconsInText||(e.iconsInText=!!O&&O.iconsInText);let{defaultShapedIcon:F,verticallyShapedIcon:k}=function(e,i,r,a,n,o,s,l,h){let u=pb(o.horizontal)||o.vertical,c=r.get("icon-text-fit-padding").evaluate(a,{},n),d,p=i;return i&&"none"!==h&&(e.allowVerticalPlacement&&o.vertical&&(d=dX(i,o.vertical,h,c,l,s)),u&&(p=dX(i,u,h,c,l,s))),{defaultShapedIcon:p,verticallyShapedIcon:d}}(e,v,d,s,o,y,_*f.textScaleFactor/24,z,L);"none"!==L&&v&&(dY(v)||dK(v))&&(pf(0,C,A,v,F,L,u,a,n),pf(0,P,M,v,F,L,u,a,n),k&&(pf(0,C,A,v,k,L,u,a,n),pf(0,P,M,v,k,L,u,a,n))),v=F,E.push({feature:s,shapedTextOrientations:y,shapedText:O,shapedIcon:v,iconPrimary:A,iconSecondary:M,iconOffset:z,iconAnchor:R,verticallyShapedIcon:k,layoutTextSize:_,layoutIconSize:g,textOffset:I,isSDFIcon:D,iconTextFit:L})}return{featureData:E,sizes:f,hasAnySecondaryIcon:S,textAlongLine:w,symbolPlacement:b}},e.fo=d7,e.fp=function(e,i,r,a,n,o,s,l,h,u){let{featureData:c,hasAnySecondaryIcon:d,sizes:p,textAlongLine:f,symbolPlacement:m}=i;for(let i of c){let{shapedIcon:r,verticallyShapedIcon:o,feature:c,shapedTextOrientations:_,shapedText:g,layoutTextSize:y,textOffset:x,isSDFIcon:v,iconPrimary:b,iconSecondary:w,iconTextFit:T,iconOffset:S}=i;pg(r,u.iconPositions,b,w),pg(o,u.iconPositions,b,w),function(e,i){for(let r in e.horizontal)py(e.horizontal[r],i);py(e.vertical,i)}(_,u.iconPositions),function(e,i,r){if(!i)return;let a=r.get(e.toString()),n=r.get(i.toString());a&&n&&(a.paddedRect.w===n.paddedRect.w&&a.paddedRect.h===n.paddedRect.h||tf(`Mismatch in icon variant sizes: ${e.toString()} and ${i.toString()}`),a.usvg!==n.usvg&&tf(`Mismatch in icon variant image types: ${e.id} and ${i.id}`))}(b,w,u.iconPositions),(g||r)&&function(e,i,r,a,n,o,s,l,h,u,c,d,p,f,m,_,g,y,x,v){var b;let w=s.textMaxSize.evaluate(i,{},p);void 0===w?w=l*s.textScaleFactor:w*=s.textScaleFactor;let T=e.layers[0].layout,S=pb(r.horizontal)||r.vertical,E="globe"===f.name,I=e.tilePixelRatio*w/24,A=(b=e.overscaling,e.zoom>18&&b>2&&(b>>=1),Math.max(8192/(512*b),1)*T.get("symbol-spacing")),C=T.get("text-padding")*e.tilePixelRatio,M=T.get("icon-padding")*e.tilePixelRatio,P=T.get("text-max-angle")*e4,z="map"===T.get("icon-rotation-alignment")&&"point"!==v,R=A/2;!1===e.hasAnyIconTextFit&&"none"!==g&&(e.hasAnyIconTextFit=!0);
7let D=i.properties?+i.properties[s8]:null,L=D&&e.elevationFeatureIdToIndex?e.elevationFeatureIdToIndex.get(D):65535,O=(l,h,v)=>{if(h.x<0||h.x>=8192||h.y<0||h.y>=8192)return;let b=null;if(E){let{x:e,y:i,z:r}=f.projectTilePoint(h.x,h.y,v);b={anchor:new d2(e,i,r,0,void 0),up:f.upVector(v,h.x,h.y)}}!function(e,i,r,a,n,o,s,l,h,u,c,d,p,f,m,_,g,y,x,v,b,w,T,S,E,I,A,C,M){let P=e.addToLineVertexArray(i,a),z,R,D,L,O,F,k,B=0,N=0,V=0,U=0,j=-1,G=-1,q={},$=t9(""),H=r?r.anchor:i,Z="none"!==C,W=0,X=0;if(void 0===h._unevaluatedLayout.getValue("text-radial-offset")){let e=h.layout.get("text-offset").evaluate(b,{},E);W=24*e[0],X=24*e[1]}else W=24*h.layout.get("text-radial-offset").evaluate(b,{},E),X=pc;if(e.allowVerticalPlacement&&n.vertical){let e=n.vertical;if(m)F=pT(e),l&&(k=pT(l));else{let r=h.layout.get("text-rotate").evaluate(b,{},E)+90;D=pw(u,H,i,c,d,p,e,f,r,_),l&&(L=pw(u,H,i,c,d,p,l,y,r))}}if(o){let a=e.iconSizeData,n=h.layout.get("icon-rotate").evaluate(b,{},E),s=pn(o,n,T,Z,w.iconScaleFactor),f=l?pn(l,n,T,Z,w.iconScaleFactor):void 0;R=pw(u,H,i,c,d,p,o,y,n,null),B=4*s.length;let m=null;"source"===a.kind?(m=[128*h.layout.get("icon-size").evaluate(b,{},E)*w.iconScaleFactor])[0]>32640&&tf(`${e.layerIds[0]}: Value for "icon-size" is >= 255. Reduce your "icon-size".`):"composite"===a.kind&&((m=[128*w.compositeIconSizes[0].evaluate(b,{},E)*w.iconScaleFactor,128*w.compositeIconSizes[1].evaluate(b,{},E)*w.iconScaleFactor])[0]>32640||m[1]>32640)&&tf(`${e.layerIds[0]}: Value for "icon-size" is >= 255. Reduce your "icon-size".`),e.addSymbols(e.icon,s,m,v,x,b,void 0,r,i,P.lineStartIndex,P.lineLength,-1,S,E,I,A),j=e.icon.placedSymbolArray.length-1,f&&(N=4*f.length,e.addSymbols(e.icon,f,m,v,x,b,dk.vertical,r,i,P.lineStartIndex,P.lineLength,-1,S,E,I,A),G=e.icon.placedSymbolArray.length-1)}for(let a in n.horizontal){let o=n.horizontal[a];z||($=t9(o.text),m?O=pT(o):z=pw(u,H,i,c,d,p,o,f,h.layout.get("text-rotate").evaluate(b,{},E),_));let l=1===o.positionedLines.length;if(V+=pv(e,r,i,o,s,h,m,b,_,P,n.vertical?dk.horizontal:dk.horizontalOnly,l?pu(n.horizontal):[a],q,j,w,S,E,I),l)break}n.vertical&&(U+=pv(e,r,i,n.vertical,s,h,m,b,_,P,dk.vertical,["vertical"],q,G,w,S,E,I));let Y=-1,K=(e,i)=>e?Math.max(e,i):i;Y=K(O,-1),Y=K(F,Y);let J=+((Y=K(k,Y))>-1);e.glyphOffsetArray.length>=65535&&tf("Too many glyphs being rendered in a tile. See https://github.com/mapbox/mapbox-gl-js/issues/2907"),void 0!==b.sortKey&&e.addToSortKeyRanges(e.symbolInstances.length,b.sortKey),e.symbolInstances.emplaceBack(i.x,i.y,H.x,H.y,H.z,q.right>=0?q.right:-1,q.center>=0?q.center:-1,q.left>=0?q.left:-1,q.vertical>=0?q.vertical:-1,j,G,$,void 0!==z?z:e.collisionBoxArray.length,void 0!==z?z+1:e.collisionBoxArray.length,void 0!==D?D:e.collisionBoxArray.length,void 0!==D?D+1:e.collisionBoxArray.length,void 0!==R?R:e.collisionBoxArray.length,void 0!==R?R+1:e.collisionBoxArray.length,L||e.collisionBoxArray.length,L?L+1:e.collisionBoxArray.length,c,V,U,B,N,J,0,W,X,Y,0,+!!Z,M)}(e,h,b,l,r,a,o,n,e.layers[0],e.collisionBoxArray,i.index,i.sourceLayerIndex,e.index,C,x,u,0,M,z,y,i,s,c,d,p,m,_,g,L)};if("line"===v)for(let n of uU(i.geometry,0,0,8192,8192))for(let i of function(e,i,r,a,n,o,s,l,h){let u=a?14.399999999999999*s:0,c=d4(a,n),d=c*s,p=0===e[0].x||8192===e[0].x||0===e[0].y||8192===e[0].y;return i-d<i/4&&(i=d+i/4),function e(i,r,a,n,o,s,l,h,u){let c=s/2,d=d5(i),p=0,f=r-a,m=[];for(let e=0;e<i.length-1;e++){let r=i[e],l=i[e+1],h=r.dist(l),_=l.angleTo(r);for(;f+a<p+h;){let g=((f+=a)-p)/h,y=ip(r.x,l.x,g),x=ip(r.y,l.y,g);if(y>=0&&y<u&&x>=0&&x<u&&f-c>=0&&f+c<=d){let r=new d2(y,x,0,_,e);n&&!d3(i,r,s,n,o)||m.push(r)}}p+=h}return h||m.length||l||(m=e(i,p/2,a,n,o,s,l,!0,u)),m}(e,p?i/2*l%i:(c/2+48)*s*l%i,i,u,r,d,p,!1,h)}(n,A,P,r.vertical||S,a,24,I,e.overscaling,8192))S&&function(e,i,r,a){let n=e.compareText;if(i in n){let e=n[i];for(let i=e.length-1;i>=0;i--)if(a.dist(e[i])<r)return!0}else n[i]=[];return n[i].push(a),!1}(e,S.text,R,i)||O(n,i,p);else if("line-center"===v){for(let e of i.geometry)if(e.length>1){let i=function(e,i,r,a,n,o){let s=r?14.399999999999999*o:0,l=d4(r,a)*o,h=0,u=d5(e)/2;for(let r=0;r<e.length-1;r++){let a=e[r],n=e[r+1],o=a.dist(n);if(h+o>u){let c=(u-h)/o,d=new d2(ip(a.x,n.x,c),ip(a.y,n.y,c),0,n.angleTo(a),r);return!s||d3(e,d,l,s,i)?d:void 0}h+=o}}(e,P,r.vertical||S,a,0,I);i&&O(e,i,p)}}
7else if("Polygon"===i.type)for(let e of hB(i.geometry,0)){let i=function(e,i=1,r=!1){let a=1/0,n=1/0,o=-1/0,s=-1/0,l=e[0];for(let e=0;e<l.length;e++){let i=l[e];(!e||i.x<a)&&(a=i.x),(!e||i.y<n)&&(n=i.y),(!e||i.x>o)&&(o=i.x),(!e||i.y>s)&&(s=i.y)}let h=Math.min(o-a,s-n),u=h/2,c=new rv([],pl);if(0===h)return new e3(a,n);for(let i=a;i<o;i+=h)for(let r=n;r<s;r+=h)c.push(new ph(i+u,r+u,u,e));let d=function(e){let i=0,r=0,a=0,n=e[0];for(let e=0,o=n.length,s=o-1;e<o;s=e++){let o=n[e],l=n[s],h=o.x*l.y-l.x*o.y;r+=(o.x+l.x)*h,a+=(o.y+l.y)*h,i+=3*h}return new ph(r/i,a/i,0,e)}(e),p=c.length;for(;c.length;){let a=c.pop();(a.d>d.d||!d.d)&&(d=a,r&&console.log("found best %d after %d probes",Math.round(1e4*a.d)/1e4,p)),a.max-d.d<=i||(u=a.h/2,c.push(new ph(a.p.x-u,a.p.y-u,u,e)),c.push(new ph(a.p.x+u,a.p.y-u,u,e)),c.push(new ph(a.p.x-u,a.p.y+u,u,e)),c.push(new ph(a.p.x+u,a.p.y+u,u,e)),p+=4)}return r&&(console.log(`num probes: ${p}`),console.log(`best distance: ${d.d}`)),d.p}(e,16);O(e[0],new d2(i.x,i.y,0,0,void 0),p)}else if("LineString"===i.type)for(let e of i.geometry)O(e,new d2(e[0].x,e[0].y,0,0,void 0),p);else if("Point"===i.type)for(let e of i.geometry)for(let i of e)O([i],new d2(i.x,i.y,0,0,void 0),p)}(e,c,_,r,o,h,p,y,0,x,v,a,n,s,l,d,T,S,f,m)}r&&e.generateCollisionDebugBuffers(o,e.collisionBoxArray,p.textScaleFactor)},e.fq=s4,e.fr=mi,e.fs=s1,e.ft=function(e){let i=0;if(0x46546c67!==new Uint32Array(e,0,1)[0]){let r=new Uint32Array(e,0,7),[,,a,n,o,s]=r;i=r.byteLength+n+o+s+o,(a!==e.byteLength||i>=e.byteLength)&&tf("Invalid b3dm header information.")}return cc(e,i)},e.fu=function(e,i){let r=cU(e);for(let e of r){for(let i of e.meshes)!function(e){e.heightmap=new Float32Array(4096),e.heightmap.fill(-1);let i=e.vertexArray.float32,r=e.aabb.min[0]-1,a=e.aabb.min[1]-1,n=64/(e.aabb.max[0]-r+2),o=64/(e.aabb.max[1]-a+2);for(let s=0;s<i.length;s+=3){let l=i[s+2],h=(i[s+0]-r)*n|0,u=(i[s+1]-a)*o|0;l>e.heightmap[64*u+h]&&(e.heightmap[64*u+h]=l)}}(i);e.lights&&(e.lightMeshIndex=e.meshes.length,e.meshes.push(function(e,i){let r={};r.indexArray=new oD,r.vertexArray=new ov,r.colorArray=new oI,cj(e,i,r.indexArray,r.vertexArray,r.colorArray);let a={defined:!0};a.emissiveFactor=ih.black;let n={};return n.baseColorFactor=ih.white,a.pbrMetallicRoughness=n,r.material=a,r.aabb=new ld([1/0,1/0,1/0],[-1/0,-1/0,-1/0]),r}(e.lights,i)))}return r},e.fv=fp,e.fw=tg,e.fx=uW,e.fy=nN,e.fz=nP,e.g=function(e,i){return tY(Object.assign(e,{method:"GET"}),i)},e.h=function(e){return 0===e.indexOf("mapbox:")},e.i=function(e){return tI.API_STYLE_REGEX.test(e)&&!tC(e)},e.j=tA,e.k=tV,e.l=function(e){return decodeURIComponent(atob(e).split("").map(e=>"%"+("00"+e.charCodeAt(0).toString(16)).slice(-2)).join(""))},e.m=function(e,i){return tY(Object.assign(e,{type:"json"}),i)},e.n=tQ,e.o=tP,e.p=function(e,i){return tY(Object.assign(e,{method:"POST"}),i)},e.q=hf,e.r=tM,e.s=function(e){try{let i=self[e];return i.setItem("_mapbox_test_",1),i.removeItem("_mapbox_test_"),!0}catch(e){return!1}},e.t=function(){return I||(I=new uK),I},e.u=function(){return function e(i){return i?(i^Math.random()*(16>>i/4)).toString(16):([1e7]+-[1e3]+-4e3+-8e3+-1e11).replace(/[018]/g,e)}()},e.v=function(e){return!!e&&/^[0-9a-f]{8}-[0-9a-f]{4}-[4][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i.test(e)},e.w=tf,e.x=f1,e.y=ie,e.z=t7}),a(["./shared"],function(e){var i;function r(e){let i=e?e.url.toString():void 0;return i?performance.getEntriesByName(i):[]}function a(e){if("number"==typeof e||"boolean"==typeof e||"string"==typeof e||null==e)return JSON.stringify(e);if(Array.isArray(e)){let i="[";for(let r of e)i+=`${a(r)},`;return`${i}]`}let i="{";for(let r of Object.keys(e).sort())i+=`${r}:${a(e[r])},`;return`${i}}`}class n{constructor(e){this.keyCache={},this._layers={},this._layerConfigs={},e&&this.replace(e)}replace(e,i){this._layerConfigs={},this._layers={},this.update(e,[],i)}update(i,r,n){for(let r of(this._options=n,i))this._layerConfigs[r.id]=r,(this._layers[r.id]=e.dq(r,this.scope,null,this._options)).compileFilter(n),this.keyCache[r.id]&&delete this.keyCache[r.id];for(let e of r)delete this.keyCache[e],delete this._layerConfigs[e],delete this._layers[e];for(let i of(this.familiesBySource={},function(i,r){let n={};for(let o=0;o<i.length;o++){let s=i[o],l=r&&r[s.id];l||("symbol"===s.type?l=s.id:(l=function(i){let r="";for(let n of e.bx)r+=`/${a(i[n])}`;return r}(s),"line"===s.type&&s.paint&&function e(i){return"string"==typeof i&&"line-progress"===i||(Array.isArray(i)?i.some(e):!(!i||"object"!=typeof i)&&Object.values(i).some(e))}(s.paint["line-width"])&&(l+=`/${a(s.paint["line-width"])}`))),r&&(r[s.id]=l);let h=n[l];h||(h=n[l]=[]),h.push(s)}let o=[];for(let e in n)o.push(n[e]);return o}(Object.values(this._layerConfigs),this.keyCache))){let e=i.map(e=>
7this._layers[e.id]),r=e[0];if("none"===r.visibility)continue;let a=r.source||"",n=this.familiesBySource[a];n||(n=this.familiesBySource[a]={});let o=r.sourceLayer||"_geojsonTileLayer",s=n[o];s||(s=n[o]=[]),s.push(e)}}}let o=+e.fc;class s{constructor(i){let r={},a=[];for(let e in i){let n=i[e],s=r[e]={};for(let e in n.glyphs){let i=n.glyphs[+e];if(!i||0===i.bitmap.width||0===i.bitmap.height)continue;let r=i.metrics.localGlyph?o:1,l={x:0,y:0,w:i.bitmap.width+2*r,h:i.bitmap.height+2*r};a.push(l),s[e]=l}}let{w:n,h:s}=e.G(a),l=new e.fb({width:n||1,height:s||1});for(let a in i){let n=i[a];for(let i in n.glyphs){let s=n.glyphs[+i];if(!s||0===s.bitmap.width||0===s.bitmap.height)continue;let h=r[a][i],u=s.metrics.localGlyph?o:1;e.fb.copy(s.bitmap,l,{x:0,y:0},{x:h.x+u,y:h.y+u},s.bitmap)}}this.image=l,this.positions=r}}e.fa(s,"GlyphAtlas");class l{constructor(i){this.tileID=new e.aO(i.tileID.overscaledZ,i.tileID.wrap,i.tileID.canonical.z,i.tileID.canonical.x,i.tileID.canonical.y),this.tileZoom=i.tileZoom,this.uid=i.uid,this.zoom=i.zoom,this.lut=i.lut,this.canonical=i.tileID.canonical,this.pixelRatio=i.pixelRatio,this.tileSize=i.tileSize,this.source=i.source,this.scope=i.scope,this.overscaling=this.tileID.overscaleFactor(),this.showCollisionBoxes=i.showCollisionBoxes,this.collectResourceTiming=!!i.request&&i.request.collectResourceTiming,this.promoteId=i.promoteId,this.isSymbolTile=i.isSymbolTile,this.tileTransform=e.aZ(i.tileID.canonical,i.projection),this.projection=i.projection,this.worldview=i.worldview,this.localizableLayerIds=i.localizableLayerIds,this.brightness=i.brightness,this.extraShadowCaster=!!i.extraShadowCaster,this.tessellationStep=i.tessellationStep,this.scaleFactor=i.scaleFactor,this.worldview=i.worldview}parse(i,r,a,n,o,l){this.status="parsing",this.data=i,this.collisionBoxArray=new e.b3;let u=new e.fd(Object.keys(i.layers).sort()),c=new e.fe(this.tileID,this.promoteId);c.bucketLayerIDs=[];let d={},p=new e.ff(256,256),f={featureIndex:c,iconDependencies:new Map,patternDependencies:new Map,glyphDependencies:{},lineAtlas:p,availableImages:a,brightness:this.brightness,scaleFactor:this.scaleFactor,elevationFeatures:void 0},m=[],_=r.familiesBySource[this.source];for(let r in _){let o=i.layers[r];if(!o)continue;let s=!1,l=!1,p=!1;for(let e of _[r])"symbol"===e[0].type?s=!0:l=!0,e[0].is3D()&&"model"!==e[0].type&&(p=!0);if(this.extraShadowCaster&&!p||!0===this.isSymbolTile&&!s||!1===this.isSymbolTile&&!l)continue;1===o.version&&e.w(`Vector tile source "${this.source}" layer "${r}" does not use vector tile spec v2 and therefore may have some rendering errors.`);let g=u.encode(r),y=[],x=!1;for(let i=0,a=0;i<o.length;i++){let n=o.feature(i),s=c.getId(n,r);if(this.localizableLayerIds&&this.localizableLayerIds.has(r)){let e=n.properties?n.properties.worldview:null;if(this.worldview&&"string"==typeof e)if("all"===e)n.properties.$localized=!0;else{if(!e.split(",").includes(this.worldview))continue;n.properties.$localized=!0,n.properties.worldview=this.worldview}}!x&&n.properties&&n.properties.hasOwnProperty(e.fg)&&(x=!0),y.push({feature:n,id:s,index:a,sourceLayerIndex:g}),a++}for(let o of(x&&!f.elevationFeatures&&i.layers.hasOwnProperty(e.fh)&&(f.elevationFeatures=e.fi.parseFrom(i.layers[e.fh],this.canonical)),_[r])){let i=o[0];if(this.extraShadowCaster&&(!i.is3D()||"model"===i.type)||void 0!==this.isSymbolTile&&"symbol"===i.type!==this.isSymbolTile||i.minzoom&&this.zoom<Math.floor(i.minzoom)||i.maxzoom&&this.zoom>=i.maxzoom||"none"===i.visibility)continue;h(o,this.zoom,f.brightness,a,this.worldview);let r=d[i.id]=i.createBucket({index:c.bucketLayerIDs.length,layers:o,zoom:this.zoom,lut:this.lut,canonical:this.canonical,pixelRatio:this.pixelRatio,overscaling:this.overscaling,collisionBoxArray:this.collisionBoxArray,sourceLayerIndex:g,sourceID:this.source,projection:this.projection.spec,tessellationStep:this.tessellationStep,styleDefinedModelURLs:n,worldview:this.worldview});c.bucketLayerIDs.push(o.map(i=>e.B(i.id,i.scope)));let s=r.prepare?r.prepare():null;null!=s?(s=s.then(()=>r.populate(y,f,this.tileID.canonical,this.tileTransform)),m.push(s)):r.populate(y,f,this.tileID.canonical,this.tileTransform)}}let g=()=>{let r,n,m,_,g,y;p.trim();let x={type:"maybePrepare",isSymbolTile:this.isSymbolTile,zoom:this.zoom},v=()=>{if(r)return this.status="done",l(r);if(this.extraShadowCaster)this.status="done",l(null,{buckets:Object.values(d).filter(e=>!e.isEmpty()),featureIndex:c,collisionBoxArray:null,glyphAtlasImage:null,lineAtlas:null,imageAtlas:null,brightness:f.brightness,glyphMap:null,iconMap:null,glyphPositions:null});else if(n&&m&&_){let i=new s(n),r=new Map;for(let[i,a]of m.entries()){let{imagePosition:n}=e.fl(i,a,e.fm);r.set(i,n)}let l={};for(let o in d){let s=d[o];s instanceof e.b4&&(h(s.layers,this.zoom,f.brightness,a,this.worldview),l[o]=e.fn(s,n,i.positions,m,r,this.tileID.canonical,this.tileZoom,this.scaleFactor,this.pixelRatio,g,this.worldview))}let u={iconsPending:!0,patternsPending:!0};this.rasterizeIfNeeded(o,m,g,()=>{u.iconsPending=!1,b(l,i,u)}),this.rasterizeIfNeeded(o,_,y,()=>{u.patternsPending=!1,b(l,i,u)})}},b=(i,r,n,o)=>
7{if(n.iconsPending||n.patternsPending)return;let s=new e.fo(m,_,this.lut);for(let r in d){let n=d[r];if(r in i)e.fp(n,i[r],this.showCollisionBoxes,a,this.tileID.canonical,this.tileZoom,this.projection,this.brightness,m,s);else if(n.hasPattern&&(n instanceof e.ba||n instanceof e.bb||n instanceof e.e7)){h(n.layers,this.zoom,f.brightness,a,this.worldview);let e=Object.fromEntries(s.patternPositions);n.addFeatures(f,this.tileID.canonical,e,a,this.tileTransform,this.brightness)}}this.status="done",l(null,{buckets:Object.values(d).filter(e=>!e.isEmpty()),featureIndex:c,collisionBoxArray:this.collisionBoxArray,glyphAtlasImage:r.image,lineAtlas:p,imageAtlas:s,brightness:f.brightness})};if(!this.extraShadowCaster){let i=e.fj(f.glyphDependencies,e=>Object.keys(e).map(Number));Object.keys(i).length?o.send("getGlyphs",{uid:this.uid,stacks:i},(e,i)=>{r||(r=e,n=i,v())},void 0,!1,x):n={};let a=Array.from(f.iconDependencies.keys()).map(i=>e.I.parse(i));a.length?o.send("getImages",{images:a,source:this.source,scope:this.scope,tileID:this.tileID,type:"icons"},(e,i)=>{r||(r=e,m=new Map,g=this.updateImageMapAndGetImageTaskQueue(m,i,f.iconDependencies),v())},void 0,!1,x):(m=new Map,g=new Map);let s=Array.from(f.patternDependencies.keys()).map(i=>e.I.parse(i));s.length?o.send("getImages",{images:s,source:this.source,scope:this.scope,tileID:this.tileID,type:"patterns"},(e,i)=>{r||(r=e,_=new Map,y=this.updateImageMapAndGetImageTaskQueue(_,i,f.patternDependencies),v())},void 0,!1,x):(_=new Map,y=new Map)}if(f.elevationFeatures&&f.elevationFeatures.length>0){let r=[];for(let i of Object.values(d))if(i instanceof e.bb){let e=i.getUnevaluatedPortalGraph();e&&r.push(e)}let a=e.fk.evaluate(r);for(let r of Object.values(d))if(r instanceof e.bb){let e=i.layers[u.decode(r.sourceLayerIndex)];r.setEvaluatedPortalGraph(a,e,this.tileID.canonical,f.availableImages,f.brightness)}}v()};m.length>0?Promise.allSettled(m).then(g).catch(l):g()}rasterizeIfNeeded(e,i,r,a){Array.from(i.values()).some(e=>e.usvg)?this.rasterize(e,i,r,a):a()}updateImageMapAndGetImageTaskQueue(e,i,r){let a=new Map;for(let n of i.keys())for(let o of r.get(n)||[]){let r=o.toString(),n=i.get(o.id.toString());n.usvg?a.has(r)||(a.set(r,o),e.set(r,Object.assign({},n))):e.set(r,n)}return a}rasterize(e,i,r,a){this.rasterizeTask=e.send("rasterizeImages",{scope:this.scope,tasks:r},(e,r)=>{if(!e)for(let[e,a]of r.entries()){let r=Object.assign(i.get(e),{data:a});i.set(e,r)}a()})}cancelRasterize(){this.rasterizeTask&&this.rasterizeTask.cancel()}}function h(i,r,a,n,o){let s=new e.ac(r,{brightness:a,worldview:o});for(let e of i)e.recalculate(s,n)}class u extends e.E{constructor(i,r,a,n,o,s,l){super(),this.actor=i,this.layerIndex=r,this.availableImages=a,this.availableModels=n,this.loadVectorData=s||e.aL,this.loading={},this.loaded={},this.deduped=new e.aK(i.scheduler),this.isSpriteLoaded=o,this.scheduler=i.scheduler,this.brightness=l}loadTile(i,a){let n=i.uid,o=i&&i.request,s=o&&o.collectResourceTiming,h=this.loading[n]=new l(i);h.abort=this.loadVectorData(i,(l,u)=>{let c=!this.loading[n];if(delete this.loading[n],h.cancelRasterize(),c||l||!u)return h.status="done",c||(this.loaded[n]=h),a(l);let d=u.rawData,p={};u.expires&&(p.expires=u.expires),u.cacheControl&&(p.cacheControl=u.cacheControl),h.vectorTile=u.vectorTile||new e.fq(new e.bt(d));let f=()=>{h.parse(h.vectorTile,this.layerIndex,this.availableImages,this.availableModels,this.actor,(e,i)=>{if(e||!i)return a(e);let n={};if(s){let e=r(o);e.length>0&&(n.resourceTiming=JSON.parse(JSON.stringify(e)))}a(null,Object.assign({rawTileData:d.slice(0)},i,p,n))})};this.isSpriteLoaded?f():this.once("isSpriteLoaded",()=>{this.scheduler?this.scheduler.add(f,{type:"parseTile",isSymbolTile:i.isSymbolTile,zoom:i.tileZoom}
7):f()}),this.loaded=this.loaded||{},this.loaded[n]=h})}reloadTile(i,r){let a=this.loaded,n=i.uid;if(a&&a[n]){let o=a[n];o.scaleFactor=i.scaleFactor,o.showCollisionBoxes=i.showCollisionBoxes,o.projection=i.projection,o.brightness=i.brightness,o.tileTransform=e.aZ(i.tileID.canonical,i.projection),o.extraShadowCaster=i.extraShadowCaster,o.lut=i.lut,o.worldview=i.worldview;let s=(e,i)=>{let a=o.reloadCallback;a&&(delete o.reloadCallback,o.parse(o.vectorTile,this.layerIndex,this.availableImages,this.availableModels,this.actor,a)),r(e,i)};"parsing"===o.status?o.reloadCallback=s:"done"===o.status&&(o.vectorTile?o.parse(o.vectorTile,this.layerIndex,this.availableImages,this.availableModels,this.actor,s):s())}else r(null,void 0)}abortTile(e,i){let r=e.uid,a=this.loading[r];a&&(a.abort&&a.abort(),delete this.loading[r]),i()}removeTile(e,i){let r=this.loaded,a=e.uid;r&&r[a]&&delete r[a],i()}}class c{loadTile(i,r){let{uid:a,encoding:n,rawImageData:o,padding:s}=i,l=ImageBitmap&&o instanceof ImageBitmap?this.getImageData(o,s):o;r(null,new e.fr(a,l,n,s<1))}reloadTile(e,i){i(null,null)}abortTile(e,i){i()}removeTile(e,i){i()}getImageData(e,i){this.offscreenCanvas&&this.offscreenCanvasContext||(this.offscreenCanvas=new OffscreenCanvas(e.width,e.height),this.offscreenCanvasContext=this.offscreenCanvas.getContext("2d",{willReadFrequently:!0})),this.offscreenCanvas.width=e.width,this.offscreenCanvas.height=e.height,this.offscreenCanvasContext.drawImage(e,0,0,e.width,e.height);let r=this.offscreenCanvasContext.getImageData(-i,-i,e.width+2*i,e.height+2*i);return this.offscreenCanvasContext.clearRect(0,0,this.offscreenCanvas.width,this.offscreenCanvas.height),r}}e.bs.setPbf(e.bt);class d{constructor(i){this._mrt=new e.bs(i.partial?30:1/0),this._isHeaderLoaded=!1,this.uid=i.uid,this.tileID=i.tileID,this.source=i.source}parse(i,r){let a=this._mrt;this.status="parsing",this._entireBuffer=i;try{a.parseHeader(i),this._isHeaderLoaded=!0;let n=[];for(let r in a.layers){let o=a.getLayer(r),s=o.getDataRange(o.getBandList()),l=a.createDecodingTask(s),h=i.slice(s.firstByte,s.lastByte+1),u=e.bs.performDecoding(h,l).then(e=>l.complete(null,e)).catch(e=>l.complete(e,null));n.push(u)}Promise.allSettled(n).then(()=>r(null,a)).catch(e=>r(e))}catch(e){r(e)}}}class p{constructor(e){this.actor=e,this.loading={},this.loaded={}}loadTile(i,r){let a=i.uid,n=i.request,o=this.loading[a]=new d(i),{cancel:s}=e.bu(n,(e,i,n,s)=>{let l=!this.loading[a];if(delete this.loading[a],l||e||!i)return o.status="done",l||(this.loaded[a]=o),r(e);o.parse(i,(e,i)=>{if(e||!i)return r(e);r(null,i,n,s)}),this.loaded[a]=o});o.abort=s}reloadTile(e,i){i(null,void 0)}abortTile(e,i){let r=e.uid,a=this.loading[r];a&&(a.abort&&a.abort(),delete this.loading[r]),i()}removeTile(e,i){let r=e.uid;this.loaded[r]&&delete this.loaded[r],i()}decodeRasterArray(i,r){e.bs.performDecoding(i.buffer,i.task).then(e=>r(null,e)).catch(e=>r(e))}}let f=e.fs.prototype.toGeoJSON;class m{constructor(i){this._feature=i,this.extent=e.al,this.type=i.type,this.properties=i.tags,"id"in i&&!isNaN(i.id)&&(this.id=parseInt(i.id,10))}loadGeometry(){if(1===this._feature.type){let i=[];for(let r of this._feature.geometry)i.push([new e.P(r[0],r[1])]);return i}{let i=[];for(let r of this._feature.geometry){let a=[];for(let i of r)a.push(new e.P(i[0],i[1]));i.push(a)}return i}}toGeoJSON(e,i,r){return f.call(this,e,i,r)}}class _{constructor(i,r){this.name=i,this.extent=e.al,this.length=r.length,this._jsonFeatures=r}feature(e){return new m(this._jsonFeatures[e])}}class g{constructor(i){for(let r of(this.layers={},this.extent=e.al,Object.keys(i)))this.layers[r]=new _(r,i[r])}}let y=64/4096;class x{constructor(){this.features=new Map}clear(){this.features.clear()}load(e=[],i){for(let r of e){let e=r.id;if(null==e)continue;let a=this.features.get(e);a&&this.updateCache(a,i),r.geometry?(a=function(e){let{id:i,geometry:r,properties:a}=e;if(!r)return;if("GeometryCollection"===r.type)throw Error("GeometryCollection not supported in dynamic mode.");let{type:n,coordinates:o}=r,s={id:i,type:1,geometry:[],tags:a,minX:1/0,minY:1/0,maxX:-1/0,maxY:-1/0},l=s.geometry;if("Point"===n)b(o,l,s);else if("MultiPoint"===n)for(let e of o)b(e,l,s);else if("LineString"===n)s.type=2,w(o,l,s);else if("MultiLineString"===n)s.type=2,T(o,l,s);else if("Polygon"===n)s.type=3,T(o,l,s,!0);else{if("MultiPolygon"!==n)throw Error("Input data is not a valid GeoJSON object.");for(let e of(s.type=3,o))T(e,l,s,!0)}return s}(r),this.updateCache(a,i),this.features.set(e,a)):this.features.delete(e),this.updateCache(a,i)}}updateCache(e,i){for(let{canonical:r,uid:a}of Object.values(i)){let{z:n,x:o,y:s}=r;v(e,Math.pow(2,n),o,s)&&delete i[a]}}getTile(i,r,a){let n=Math.pow(2,i),o=[];for(let i of this.features.values())v(i,n,r,a)&&o.push(function(i,r,a,n){let{id:o,type:s,geometry:l,tags:h}=i,u=[];
7if(1===s)for(let i=0;i<l.length;i+=2){let o=Math.round(e.al*(l[i+0]*r-a)),s=Math.round(e.al*(l[i+1]*r-n));u.push([o,s])}else for(let i of l)!function(i,r,a,n,o){let s,l=e.al+128;for(let h=0;h<i.length-2;h+=2){let u=Math.round(e.al*(i[h+0]*r-a)),c=Math.round(e.al*(i[h+1]*r-n)),d=Math.round(e.al*(i[h+2]*r-a)),p=Math.round(e.al*(i[h+3]*r-n)),f=d-u,m=p-c;u<-128&&d<-128||(u<-128?(c+=Math.round((-128-u)/f*m),u=-128):d<-128&&(p=c+Math.round((-128-u)/f*m),d=-128),c<-128&&p<-128||(c<-128?(u+=Math.round((-128-c)/m*f),c=-128):p<-128&&(d=u+Math.round((-128-c)/m*f),p=-128),u>=l&&d>=l||(u>=l?(c+=Math.round((l-u)/f*m),u=l):d>=l&&(p=c+Math.round((l-u)/f*m),d=l),c>=l&&p>=l||(c>=l?(u+=Math.round((l-c)/m*f),c=l):p>=l&&(d=u+Math.round((l-c)/m*f),p=l),s&&u===s[s.length-1][0]&&c===s[s.length-1][1]||(s=[[u,c]],o.push(s)),s.push([d,p])))))}}(i,r,a,n,u);return{id:o,type:s,geometry:u,tags:h}}(i,n,r,a));return{features:o}}getFeatures(){return[...this.features.values()]}}function v({minX:e,minY:i,maxX:r,maxY:a},n,o,s){return e<(o+1+y)/n&&i<(s+1+y)/n&&r>(o-y)/n&&a>(s-y)/n}function b([i,r],a,n){let o=e.aF(i),s=e.aJ(r);s=s<0?0:s>1?1:s,a.push(o,s),n.minX=Math.min(n.minX,o),n.minY=Math.min(n.minY,s),n.maxX=Math.max(n.maxX,o),n.maxY=Math.max(n.maxY,s)}function w(e,i,r,a=!1,n=!1){let o=[];for(let i of e)b(i,o,r);i.push(o),a&&function(e,i){let r=0;for(let i=0,a=e.length,n=a-2;i<a;n=i,i+=2)r+=(e[i]-e[n])*(e[i+1]+e[n+1]);if(r>0===i)for(let i=0,r=e.length;i<r/2;i+=2){let a=e[i],n=e[i+1];e[i]=e[r-2-i],e[i+1]=e[r-1-i],e[r-2-i]=a,e[r-1-i]=n}}(o,n)}function T(e,i,r,a=!1){for(let n=0;n<e.length;n++)w(e[n],i,r,a,0===n)}function S({name:i,features:r},a){a.writeStringField(1,i),a.writeVarintField(5,e.al);let n=new Map,o=new Map,s={keys:n,values:o,feature:null};for(let e of r)s.feature=e,a.writeMessage(2,E,s);for(let e of n.keys())a.writeStringField(3,e);for(let e of o.keys())a.writeMessage(4,P,e)}function E(e,i){let r=e.feature;void 0!==r.id&&Number.isSafeInteger(+r.id)&&i.writeVarintField(1,+r.id),r.tags&&i.writeMessage(2,I,e),i.writeVarintField(3,r.type),i.writeMessage(4,M,r)}function I({keys:e,values:i,feature:r},a){for(let n of Object.keys(r.tags)){let o=r.tags[n];if(null===o)continue;let s=e.get(n);void 0===s&&(s=e.size,e.set(n,s)),a.writeVarint(s);let l=typeof o;"string"!==l&&"boolean"!==l&&"number"!==l&&(o=JSON.stringify(o));let h=i.get(o);void 0===h&&(h=i.size,i.set(o,h)),a.writeVarint(h)}}function A(e,i){return(i<<3)+(7&e)}function C(e){return e<<1^e>>31}function M(e,i){let{geometry:r,type:a}=e,n=0,o=0;if(1===a)for(let e of(i.writeVarint(A(1,r.length)),r)){let r=e[0]-n,a=e[1]-o;i.writeVarint(C(r)),i.writeVarint(C(a)),n+=r,o+=a}else for(let e of r){i.writeVarint(A(1,1));let r=e.length-(3===a);for(let a=0;a<r;a++){1===a&&i.writeVarint(A(2,r-1));let s=e[a][0]-n,l=e[a][1]-o;i.writeVarint(C(s)),i.writeVarint(C(l)),n+=s,o+=l}3===a&&i.writeVarint(A(7,1))}}
7function P(e,i){let r=typeof e;"string"===r?i.writeStringField(1,e):"boolean"===r?i.writeBooleanField(7,e):"number"===r&&(e%1!=0?i.writeDoubleField(3,e):e<0?i.writeSVarintField(6,e):i.writeVarintField(5,e))}let z={minZoom:0,maxZoom:16,minPoints:2,radius:40,extent:512,nodeSize:64,log:!1,generateId:!1,reduce:null,map:e=>e},R=Math.fround||(i=new Float32Array(1),e=>(i[0]=+e,i[0]));class D{constructor(e){this.options=Object.assign(Object.create(z),e),this.trees=Array(this.options.maxZoom+1),this.stride=this.options.reduce?7:6,this.clusterProps=[]}load(e){let{log:i,minZoom:r,maxZoom:a}=this.options;i&&console.time("total time");let n=`prepare ${e.length} points`;i&&console.time(n),this.points=e;let o=[];for(let i=0;i<e.length;i++){let r=e[i];if(!r.geometry)continue;let[a,n]=r.geometry.coordinates,s=R(F(a)),l=R(k(n));o.push(s,l,1/0,i,-1,1),this.options.reduce&&o.push(0)}let s=this.trees[a+1]=this._createTree(o);i&&console.timeEnd(n);for(let e=a;e>=r;e--){let r=+Date.now();s=this.trees[e]=this._createTree(this._cluster(s,e)),i&&console.log("z%d: %d clusters in %dms",e,s.numItems,Date.now()-r)}return i&&console.timeEnd("total time"),this}getClusters(e,i){let r=((e[0]+180)%360+360)%360-180,a=Math.max(-90,Math.min(90,e[1])),n=180===e[2]?180:((e[2]+180)%360+360)%360-180,o=Math.max(-90,Math.min(90,e[3]));if(e[2]-e[0]>=360)r=-180,n=180;else if(r>n){let e=this.getClusters([r,a,180,o],i),s=this.getClusters([-180,a,n,o],i);return e.concat(s)}let s=this.trees[this._limitZoom(i)],l=s.range(F(r),k(o),F(n),k(a)),h=s.data,u=[];for(let e of l){let i=this.stride*e;u.push(h[i+5]>1?L(h,i,this.clusterProps):this.points[h[i+3]])}return u}getChildren(e){let i=this._getOriginId(e),r=this._getOriginZoom(e),a="No cluster with the specified id.",n=this.trees[r];if(!n)throw Error(a);let o=n.data;if(i*this.stride>=o.length)throw Error(a);let s=this.options.radius/(this.options.extent*Math.pow(2,r-1)),l=n.within(o[i*this.stride],o[i*this.stride+1],s),h=[];for(let i of l){let r=i*this.stride;o[r+4]===e&&h.push(o[r+5]>1?L(o,r,this.clusterProps):this.points[o[r+3]])}if(0===h.length)throw Error(a);return h}getLeaves(e,i,r){let a=[];return this._appendLeaves(a,e,i=i||10,r=r||0,0),a}getTile(e,i,r){let a=this.trees[this._limitZoom(e)],n=Math.pow(2,e),{extent:o,radius:s}=this.options,l=s/o,h=(r-l)/n,u=(r+1+l)/n,c={features:[]};return this._addTileFeatures(a.range((i-l)/n,h,(i+1+l)/n,u),a.data,i,r,n,c),0===i&&this._addTileFeatures(a.range(1-l/n,h,1,u),a.data,n,r,n,c),i===n-1&&this._addTileFeatures(a.range(0,h,l/n,u),a.data,-1,r,n,c),c.features.length?c:null}getClusterExpansionZoom(e){let i=this._getOriginZoom(e)-1;for(;i<=this.options.maxZoom;){let r=this.getChildren(e);if(i++,1!==r.length)break;e=r[0].properties.cluster_id}return i}_appendLeaves(e,i,r,a,n){for(let o of this.getChildren(i)){let i=o.properties;if(i&&i.cluster?n+i.point_count<=a?n+=i.point_count:n=this._appendLeaves(e,i.cluster_id,r,a,n):n<a?n++:e.push(o),e.length===r)break}return n}_createTree(i){let r=new e.c3(i.length/this.stride|0,this.options.nodeSize,Float32Array);for(let e=0;e<i.length;e+=this.stride)r.add(i[e],i[e+1]);return r.finish(),r.data=i,r}_addTileFeatures(e,i,r,a,n,o){for(let s of e){let e,l,h,u,c=s*this.stride,d=i[c+5]>1;if(d)e=O(i,c,this.clusterProps),l=i[c],h=i[c+1];else{let r=this.points[i[c+3]];e=r.properties;let[a,n]=r.geometry.coordinates;l=F(a),h=k(n)}let p={type:1,geometry:[[Math.round(this.options.extent*(l*n-r)),Math.round(this.options.extent*(h*n-a))]],tags:e};void 0!==(u=d||this.options.generateId?i[c+3]:this.points[i[c+3]].id)&&(p.id=u),o.features.push(p)}}_limitZoom(e){return Math.max(this.options.minZoom,Math.min(Math.floor(+e),this.options.maxZoom+1))}_cluster(e,i){let{radius:r,extent:a,reduce:n,minPoints:o}=this.options,s=r/(a*Math.pow(2,i)),l=e.data,h=[],u=this.stride;for(let r=0;r<l.length;r+=u){if(l[r+2]<=i)continue;l[r+2]=i;let a=l[r],c=l[r+1],d=e.within(l[r],l[r+1],s),p=l[r+5],f=p;for(let e of d){let r=e*u;l[r+2]>i&&(f+=l[r+5])}if(f>p&&f>=o){let e,o=a*p,s=c*p,m=-1,_=(r/u<<5)+(i+1)+this.points.length;for(let a of d){let h=a*u;if(l[h+2]<=i)continue;l[h+2]=i;let c=l[h+5];o+=l[h]*c,s+=l[h+1]*c,l[h+4]=_,n&&(e||(e=this._map(l,r,!0),m=this.clusterProps.length,this.clusterProps.push(e)),n(e,this._map(l,h)))}l[r+4]=_,h.push(o/f,s/f,1/0,_,-1,f),n&&h.push(m)}else{for(let e=0;e<u;e++)h.push(l[r+e]);if(f>1)for(let e of d){let r=e*u;if(!(l[r+2]<=i)){l[r+2]=i;for(let e=0;e<u;e++)h.push(l[r+e])}}}}return h}_getOriginId(e){return e-this.points.length>>5}_getOriginZoom(e){return(e-this.points.length)%32}_map(e,i,r){if(e[i+5]>1){let a=this.clusterProps[e[i+6]];return r?Object.assign({},a):a}let a=this.points[e[i+3]].properties,n=this.options.map(a);return r&&n===a?Object.assign({},n):n}}function L(e,i,r){return{type:"Feature",id:e[i+3],properties:O(e,i,r),geometry:{type:"Point",coordinates:[360*(e[i]-.5),360*Math.atan(Math.exp((180-360*e[i+1])*Math.PI/180)
7)/Math.PI-90]}}}function O(e,i,r){let a=e[i+5],n=a>=1e4?`${Math.round(a/1e3)}k`:a>=1e3?Math.round(a/100)/10+"k":a,o=e[i+6];return Object.assign(-1===o?{}:Object.assign({},r[o]),{cluster:!0,cluster_id:e[i+3],point_count:a,point_count_abbreviated:n})}function F(e){return e/360+.5}function k(e){let i=Math.sin(e*Math.PI/180),r=.5-.25*Math.log((1+i)/(1-i))/Math.PI;return r<0?0:r>1?1:r}function B(e,i,r,a){let n={id:e??null,type:i,geometry:r,tags:a,minX:1/0,minY:1/0,maxX:-1/0,maxY:-1/0};if("Point"===i||"MultiPoint"===i||"LineString"===i)N(n,r);else if("Polygon"===i)N(n,r[0]);else if("MultiLineString"===i)for(let e of r)N(n,e);else if("MultiPolygon"===i)for(let e of r)N(n,e[0]);return n}function N(e,i){for(let r=0;r<i.length;r+=3)e.minX=Math.min(e.minX,i[r]),e.minY=Math.min(e.minY,i[r+1]),e.maxX=Math.max(e.maxX,i[r]),e.maxY=Math.max(e.maxY,i[r+1])}function V(e,i,r,a){if(!i.geometry)return;let n=i.geometry.coordinates;if(n&&0===n.length)return;let o=i.geometry.type,s=Math.pow(r.tolerance/((1<<r.maxZoom)*r.extent),2),l=[],h=i.id;if(r.promoteId?h=i.properties[r.promoteId]:r.generateId&&(h=a||0),"Point"===o)U(n,l);else if("MultiPoint"===o)for(let e of n)U(e,l);else if("LineString"===o)j(n,l,s,!1);else if("MultiLineString"===o){if(r.lineMetrics){for(let r of n)j(r,l=[],s,!1),e.push(B(h,"LineString",l,i.properties));return}G(n,l,s,!1)}else if("Polygon"===o)G(n,l,s,!0);else{if("MultiPolygon"!==o){if("GeometryCollection"===o){for(let n of i.geometry.geometries)V(e,{id:h,geometry:n,properties:i.properties},r,a);return}throw Error("Input data is not a valid GeoJSON object.")}for(let e of n){let i=[];G(e,i,s,!0),l.push(i)}}e.push(B(h,o,l,i.properties))}function U(e,i){i.push(e[0]/360+.5,q(e[1]),0)}function j(e,i,r,a){let n,o,s=0;for(let r=0;r<e.length;r++){let l=e[r][0]/360+.5,h=q(e[r][1]);i.push(l,h,0),r>0&&(s+=a?(n*h-l*o)/2:Math.sqrt(Math.pow(l-n,2)+Math.pow(h-o,2))),n=l,o=h}let l=i.length-3;i[2]=1,function e(i,r,a,n){let o=n,s=r+(a-r>>1),l,h=a-r,u=i[r],c=i[r+1],d=i[a],p=i[a+1];for(let e=r+3;e<a;e+=3){let r=function(e,i,r,a,n,o){let s=n-r,l=o-a;if(0!==s||0!==l){let h=((e-r)*s+(i-a)*l)/(s*s+l*l);h>1?(r=n,a=o):h>0&&(r+=s*h,a+=l*h)}return(s=e-r)*s+(l=i-a)*l}(i[e],i[e+1],u,c,d,p);if(r>o)l=e,o=r;else if(r===o){let i=Math.abs(e-s);i<h&&(l=e,h=i)}}o>n&&(l-r>3&&e(i,r,l,n),i[l+2]=o,a-l>3&&e(i,l,a,n))}(i,0,l,r),i[l+2]=1,i.size=Math.abs(s),i.start=0,i.end=i.size}function G(e,i,r,a){for(let n=0;n<e.length;n++){let o=[];j(e[n],o,r,a),i.push(o)}}function q(e){let i=Math.sin(e*Math.PI/180),r=.5-.25*Math.log((1+i)/(1-i))/Math.PI;return r<0?0:r>1?1:r}function $(e,i,r,a,n,o,s,l){if(a/=i,o>=(r/=i)&&s<a)return e;if(s<r||o>=a)return null;let h=[];for(let i of e){let e=i.geometry,o=i.type,s=0===n?i.minX:i.minY,m=0===n?i.maxX:i.maxY;if(s>=r&&m<a){h.push(i);continue}if(m<r||s>=a)continue;let _=[];
7if("Point"===o||"MultiPoint"===o){var u=e,c=_,d=r,p=a,f=n;for(let e=0;e<u.length;e+=3){let i=u[e+f];i>=d&&i<=p&&X(c,u[e],u[e+1],u[e+2])}}else if("LineString"===o)H(e,_,r,a,n,!1,l.lineMetrics);else if("MultiLineString"===o)W(e,_,r,a,n,!1);else if("Polygon"===o)W(e,_,r,a,n,!0);else if("MultiPolygon"===o)for(let i of e){let e=[];W(i,e,r,a,n,!0),e.length&&_.push(e)}if(_.length){if(l.lineMetrics&&"LineString"===o){for(let e of _)h.push(B(i.id,o,e,i.tags));continue}"LineString"!==o&&"MultiLineString"!==o||(1===_.length?(o="LineString",_=_[0]):o="MultiLineString"),"Point"!==o&&"MultiPoint"!==o||(o=3===_.length?"Point":"MultiPoint"),h.push(B(i.id,o,_,i.tags))}}return h.length?h:null}function H(e,i,r,a,n,o,s){let l=Z(e),h=0===n?Y:K,u,c,d=e.start;for(let p=0;p<e.length-3;p+=3){let f=e[p],m=e[p+1],_=e[p+2],g=e[p+3],y=e[p+4],x=0===n?f:m,v=0===n?g:y,b=!1;s&&(u=Math.sqrt(Math.pow(f-g,2)+Math.pow(m-y,2))),x<r?v>r&&(c=h(l,f,m,g,y,r),s&&(l.start=d+u*c)):x>a?v<a&&(c=h(l,f,m,g,y,a),s&&(l.start=d+u*c)):X(l,f,m,_),v<r&&x>=r&&(c=h(l,f,m,g,y,r),b=!0),v>a&&x<=a&&(c=h(l,f,m,g,y,a),b=!0),!o&&b&&(s&&(l.end=d+u*c),i.push(l),l=Z(e)),s&&(d+=u)}let p=e.length-3,f=e[p],m=e[p+1],_=0===n?f:m;_>=r&&_<=a&&X(l,f,m,e[p+2]),p=l.length-3,o&&p>=3&&(l[p]!==l[0]||l[p+1]!==l[1])&&X(l,l[0],l[1],l[2]),l.length&&i.push(l)}function Z(e){let i=[];return i.size=e.size,i.start=e.start,i.end=e.end,i}function W(e,i,r,a,n,o){for(let s of e)H(s,i,r,a,n,o,!1)}function X(e,i,r,a){e.push(i,r,a)}function Y(e,i,r,a,n,o){let s=(o-i)/(a-i);return X(e,o,r+(n-r)*s,1),s}function K(e,i,r,a,n,o){let s=(o-r)/(n-r);return X(e,i+(a-i)*s,o,1),s}function J(e,i){let r=[];for(let a=0;a<e.length;a++){let n,o=e[a],s=o.type;if("Point"===s||"MultiPoint"===s||"LineString"===s)n=Q(o.geometry,i);else if("MultiLineString"===s||"Polygon"===s)for(let e of(n=[],o.geometry))n.push(Q(e,i));else if("MultiPolygon"===s)for(let e of(n=[],o.geometry)){let r=[];for(let a of e)r.push(Q(a,i));n.push(r)}r.push(B(o.id,s,n,o.tags))}return r}function Q(e,i){let r=[];r.size=e.size,void 0!==e.start&&(r.start=e.start,r.end=e.end);for(let a=0;a<e.length;a+=3)r.push(e[a]+i,e[a+1],e[a+2]);return r}function ee(e,i){if(e.transformed)return e;let r=1<<e.z,a=e.x,n=e.y;for(let o of e.features){let e=o.geometry,s=o.type;if(o.geometry=[],1===s)for(let s=0;s<e.length;s+=2)o.geometry.push(et(e[s],e[s+1],i,r,a,n));else for(let s=0;s<e.length;s++){let l=[];for(let o=0;o<e[s].length;o+=2)l.push(et(e[s][o],e[s][o+1],i,r,a,n));o.geometry.push(l)}}return e.transformed=!0,e}function et(e,i,r,a,n,o){return[Math.round(r*(e*a-n)),Math.round(r*(i*a-o))]}function ei(e,i,r,a,n,o){let s=a*a;if(a>0&&i.size<(n?s:a))return void(r.numPoints+=i.length/3);let l=[];for(let e=0;e<i.length;e+=3)(0===a||i[e+2]>s)&&(r.numSimplified++,l.push(i[e],i[e+1])),r.numPoints++;n&&function(e,i){let r=0;for(let i=0,a=e.length,n=a-2;i<a;n=i,i+=2)r+=(e[i]-e[n])*(e[i+1]+e[n+1]);if(r>0===i)for(let i=0,r=e.length;i<r/2;i+=2){let a=e[i],n=e[i+1];e[i]=e[r-2-i],e[i+1]=e[r-1-i],e[r-2-i]=a,e[r-1-i]=n}}(l,o),e.push(l)}let er={maxZoom:14,indexMaxZoom:5,indexMaxPoints:1e5,tolerance:3,extent:4096,buffer:64,lineMetrics:!1,promoteId:null,generateId:!1,debug:0};class ea{constructor(e,i){let r=(i=this.options=function(e,i){for(let r in i)e[r]=i[r];return e}(Object.create(er),i)).debug;if(r&&console.time("preprocess data"),i.maxZoom<0||i.maxZoom>24)throw Error("maxZoom should be in the 0-24 range");if(i.promoteId&&i.generateId)throw Error("promoteId and generateId cannot be used together.");let a=function(e,i){let r=[];if("FeatureCollection"===e.type)for(let a=0;a<e.features.length;a++)V(r,e.features[a],i,a);else V(r,"Feature"===e.type?e:{geometry:e},i);return r}(e,i);this.tiles={},this.tileCoords=[],r&&(console.timeEnd("preprocess data"),console.log("index: maxZoom: %d, maxPoints: %d",i.indexMaxZoom,i.indexMaxPoints),console.time("generate tiles"),this.stats={},this.total=0),(a=function(e,i){let r=i.buffer/i.extent,a=e,n=$(e,1,-1-r,r,0,-1,2,i),o=$(e,1,1-r,2+r,0,-1,2,i);return(n||o)&&(a=$(e,1,-r,1+r,0,-1,2,i)||[],n&&(a=J(n,1).concat(a)),o&&(a=a.concat(J(o,-1)))),a}(a,i)).length&&this.splitTile(a,0,0,0),r&&(a.length&&console.log("features: %d, points: %d",this.tiles[0].numFeatures,this.tiles[0].numPoints),console.timeEnd("generate tiles"),console.log("tiles generated:",this.total,JSON.stringify(this.stats)))}splitTile(e,i,r,a,n,o,s){let l=[e,i,r,a],h=this.options,u=h.debug;for(;l.length;){a=l.pop(),r=l.pop(),i=l.pop(),e=l.pop();let c=1<<i,d=en(i,r,a),p=this.tiles[d];if(!p&&(u>1&&console.time("creation"),p=this.tiles[d]=function(e,i,r,a,n){let o=i===n.maxZoom?0:n.tolerance/((1<<i)*n.extent),s={features:[],numPoints:0,numSimplified:0,numFeatures:e.length,source:null,x:r,y:a,z:i,transformed:!1,minX:2,minY:1,maxX:-1,maxY:0};
7for(let i of e)!function(e,i,r,a){let n=i.geometry,o=i.type,s=[];if(e.minX=Math.min(e.minX,i.minX),e.minY=Math.min(e.minY,i.minY),e.maxX=Math.max(e.maxX,i.maxX),e.maxY=Math.max(e.maxY,i.maxY),"Point"===o||"MultiPoint"===o)for(let i=0;i<n.length;i+=3)s.push(n[i],n[i+1]),e.numPoints++,e.numSimplified++;else if("LineString"===o)ei(s,n,e,r,!1,!1);else if("MultiLineString"===o||"Polygon"===o)for(let i=0;i<n.length;i++)ei(s,n[i],e,r,"Polygon"===o,0===i);else if("MultiPolygon"===o)for(let i=0;i<n.length;i++){let a=n[i];for(let i=0;i<a.length;i++)ei(s,a[i],e,r,!0,0===i)}if(s.length){let r=i.tags||null;if("LineString"===o&&a.lineMetrics){for(let e in r={},i.tags)r[e]=i.tags[e];r.mapbox_clip_start=n.start/n.size,r.mapbox_clip_end=n.end/n.size}let l={geometry:s,type:"Polygon"===o||"MultiPolygon"===o?3:"LineString"===o||"MultiLineString"===o?2:1,tags:r};null!==i.id&&(l.id=i.id),e.features.push(l)}}(s,i,o,n);return s}(e,i,r,a,h),this.tileCoords.push({z:i,x:r,y:a}),u)){u>1&&(console.log("tile z%d-%d-%d (features: %d, points: %d, simplified: %d)",i,r,a,p.numFeatures,p.numPoints,p.numSimplified),console.timeEnd("creation"));let e=`z${i}`;this.stats[e]=(this.stats[e]||0)+1,this.total++}if(p.source=e,null==n){if(i===h.indexMaxZoom||p.numPoints<=h.indexMaxPoints)continue}else{if(i===h.maxZoom||i===n)continue;if(null!=n){let e=n-i;if(r!==o>>e||a!==s>>e)continue}}if(p.source=null,0===e.length)continue;u>1&&console.time("clipping");let f=.5*h.buffer/h.extent,m=.5-f,_=.5+f,g=1+f,y=null,x=null,v=null,b=null,w=$(e,c,r-f,r+_,0,p.minX,p.maxX,h),T=$(e,c,r+m,r+g,0,p.minX,p.maxX,h);e=null,w&&(y=$(w,c,a-f,a+_,1,p.minY,p.maxY,h),x=$(w,c,a+m,a+g,1,p.minY,p.maxY,h),w=null),T&&(v=$(T,c,a-f,a+_,1,p.minY,p.maxY,h),b=$(T,c,a+m,a+g,1,p.minY,p.maxY,h),T=null),u>1&&console.timeEnd("clipping"),l.push(y||[],i+1,2*r,2*a),l.push(x||[],i+1,2*r,2*a+1),l.push(v||[],i+1,2*r+1,2*a),l.push(b||[],i+1,2*r+1,2*a+1)}}getTile(e,i,r){e*=1,i*=1,r*=1;let{extent:a,debug:n}=this.options;if(e<0||e>24)return null;let o=1<<e,s=en(e,i=i+o&o-1,r);if(this.tiles[s])return ee(this.tiles[s],a);n>1&&console.log("drilling down to z%d-%d-%d",e,i,r);let l,h=e,u=i,c=r;for(;!l&&h>0;)h--,u>>=1,c>>=1,l=this.tiles[en(h,u,c)];return l&&l.source?(n>1&&(console.log("found parent tile z%d-%d-%d",h,u,c),console.time("drilling down")),this.splitTile(l.source,h,u,c,e,i,r),n>1&&console.timeEnd("drilling down"),this.tiles[s]?ee(this.tiles[s],a):null):null}}function en(e,i,r){return 32*((1<<e)*r+i)+e}function eo(i,r){let a=i.tileID.canonical;if(!this._geoJSONIndex)return void r(null,null);let n=this._geoJSONIndex.getTile(a.z,a.x,a.y);if(!n)return void r(null,null);let o=e=>e.tags&&"3d_elevation_id"in e.tags&&"source"in e.tags&&"elevation"===e.tags.source,s=n.features.filter(e=>o(e)),l={_geojsonTileLayer:n.features};s.length>0&&(l={_geojsonTileLayer:n.features.filter(e=>!o(e)),hd_road_elevation:s}),r(null,{vectorTile:new g(l),rawData:function(i){let r=new e.bt;for(let e of Object.keys(i))r.writeMessage(3,S,{name:e,features:i[e]});return r.finish()}(l).buffer})}class es extends u{constructor(e,i,r,a,n,o,s){super(e,i,r,a,n,eo,s),o&&(this.loadGeoJSON=o),this._dynamicIndex=new x}loadData(i,a){let n=i&&i.request,o=n&&n.collectResourceTiming;this._geoJSONIndex=null,this.loadGeoJSON(i,(s,l)=>{if(s||!l)return a(s);if("object"!=typeof l)return a(Error(`Input data given to '${i.source}' is not a valid GeoJSON object.`));{try{var h,u;if(i.filter){let r=e.U(i.filter,{type:"boolean","property-type":"data-driven",overridable:!1,transition:!1});if("error"===r.result)throw Error(r.value.map(e=>`${e.key}: ${e.message}`).join(", "));l.features=l.features.filter(e=>r.value.evaluate({zoom:0},e))}i.dynamic?("Feature"===l.type&&(l={type:"FeatureCollection",features:[l]}),i.append||(this._dynamicIndex.clear(),this.loaded={}),this._dynamicIndex.load(l.features,this.loaded),i.cluster&&(l.features=this._dynamicIndex.getFeatures())):this.loaded={},this._geoJSONIndex=i.cluster?new D(function({superclusterOptions:i,clusterProperties:r}){if(!r||!i)return i;let a={},n={},o={accumulated:null,zoom:0},s={properties:null},l=Object.keys(r);for(let i of l){let[o,s]=r[i],l=e.U(s),h=e.U("string"==typeof o?[o,["accumulated"],["get",i]]:o);a[i]=l.value,n[i]=h.value}return i.map=e=>{s.properties=e;let i={};for(let e of l)i[e]=a[e].evaluate(o,s);return i},i.reduce=(e,i)=>{for(let r of(s.properties=i,l))o.accumulated=e[r],e[r]=n[r].evaluate(o,s)},i}(i)).load(l.features):i.dynamic?this._dynamicIndex:(h=l,u=i.geojsonVtOptions,new ea(h,u))}catch(e){return a(e)}let s={};if(o){let e=r(n);e&&(s.resourceTiming={},s.resourceTiming[i.source]=JSON.parse(JSON.stringify(e)))}a(null,s)}})}reloadTile(e,i){let r=this.loaded;return r&&r[e.uid]?e.partial?i(null,void 0):super.reloadTile(e,i):this.loadTile(e,i)}loadGeoJSON(i,r){if(i.request)e.m(i.request,r);else{if("string"!=typeof i.data)return r(Error(`Input data given to '${i.source}' is not a valid GeoJSON object.`));setTimeout(()=>{try{return r(null,JSON.parse(i.data))}catch(e){return r(Error(`Input data given to '${i.source}' is not a valid GeoJSON object.`))}},0)}}getClusterExpansionZoom(e,i){try{i(null,this._geoJSONIndex.getClusterExpansionZoom(e.clusterId))}catch(e){i(e)}}getClusterChildren(e,i){try{i(null,this._geoJSONIndex.getChildren(e.clusterId))}catch(e){i(e)}}getClusterLeaves(e,i){try{i(null,this._geoJSONIndex.getLeaves(e.clusterId,e.limit,e.offset))}catch(e){i(e)}}}
7class el{constructor(i,r,a){this.tileID=new e.aO(i.tileID.overscaledZ,i.tileID.wrap,i.tileID.canonical.z,i.tileID.canonical.x,i.tileID.canonical.y),this.tileZoom=i.tileZoom,this.uid=i.uid,this.zoom=i.zoom,this.canonical=i.tileID.canonical,this.pixelRatio=i.pixelRatio,this.tileSize=i.tileSize,this.source=i.source,this.overscaling=this.tileID.overscaleFactor(),this.projection=i.projection,this.brightness=r,this.worldview=a}parse(i,r,a,n){this.status="parsing";let o=new e.aO(a.tileID.overscaledZ,a.tileID.wrap,a.tileID.canonical.z,a.tileID.canonical.x,a.tileID.canonical.y),s=[],l=r.familiesBySource[a.source],h=new e.fe(o,a.promoteId);h.bucketLayerIDs=[],h.is3DTile=!0,e.ft(i).then(i=>{if(!i)return n(Error("Could not parse tile"));let r=i.json.extensionsUsed&&i.json.extensionsUsed.includes("MAPBOX_mesh_features")||i.json.asset.extras&&i.json.asset.extras.MAPBOX_mesh_features,u=i.json.extensionsUsed&&i.json.extensionsUsed.includes("EXT_meshopt_compression"),c=new e.ac(this.zoom,{brightness:this.brightness,worldview:this.worldview});for(let n in l)for(let d of l[n]){let n=d[0];h.bucketLayerIDs.push(d.map(i=>e.B(i.id,i.scope))),n.recalculate(c,[]);let l=e.fu(i,1/e.d6(a.tileID.canonical)),p=new e.fv(d,l,o,r,u,this.brightness,h,this.worldview);r||(p.needsUpload=!0),s.push(p),p.evaluate(n)}this.status="done",n(null,{buckets:s,featureIndex:h,collisionBoxArray:null,glyphAtlasImage:null,lineAtlas:null,imageAtlas:null,brightness:null})}).catch(e=>n(Error(e.message)))}}class eh{constructor(e,i,r,a,n,o,s,l){this.actor=e,this.layerIndex=i,this.availableImages=r,this.availableModels=a,this.brightness=s,this.loading={},this.loaded={},this.worldview=l}loadTile(i,r){let a=i.uid,n=this.loading[a]=new el(i,this.brightness,this.worldview);e.bu(i.request,(e,o)=>{let s=!this.loading[a];return delete this.loading[a],s||e?(n.status="done",s||(this.loaded[a]=n),r(e)):o&&0!==o.byteLength?void n.parse(o,this.layerIndex,i,(e,i)=>{n.status="done",this.loaded=this.loaded||{},this.loaded[a]=n,e||!i?r(e):r(null,i)}):(n.status="done",this.loaded[a]=n,r())})}reloadTile(e,i){let r=this.loaded,a=e.uid;if(r&&r[a]){let n=r[a];n.projection=e.projection,n.brightness=e.brightness;let o=(r,a)=>{n.reloadCallback&&(delete n.reloadCallback,this.loadTile(e,i)),i(r,a)};"parsing"===n.status?n.reloadCallback=o:"done"===n.status&&this.loadTile(e,i)}}abortTile(e,i){let r=e.uid;this.loading[r]&&delete this.loading[r],i()}removeTile(e,i){let r=this.loaded,a=e.uid;r&&r[a]&&delete r[a],i()}}class eu{constructor(i){this.self=i,this.actor=new e.fx(i,this),this.layerIndexes={},this.availableImages={},this.availableModels={},this.isSpriteLoaded={},this.imageRasterizer=new e.x,this.rtlPluginParsingListeners=[],this.projections={},this.defaultProjection=e.cl({name:"mercator"}),this.workerSourceTypes={vector:u,geojson:es,"raster-dem":c,"raster-array":p,"batched-model":eh},this.workerSources={},this.self.registerWorkerSource=(e,i)=>{if(this.workerSourceTypes[e])throw Error(`Worker source with name "${e}" already registered.`);this.workerSourceTypes[e]=i},this.self.registerRTLTextPlugin=i=>{if(e.fy.isParsed())throw Error("RTL text plugin already registered.");for(let r of(e.fy.setState({pluginStatus:e.fz.parsed,pluginURL:e.fy.getPluginURL()}),e.fy.applyArabicShaping=i.applyArabicShaping,e.fy.processBidirectionalText=i.processBidirectionalText,e.fy.processStyledBidirectionalText=i.processStyledBidirectionalText,this.rtlPluginParsingListeners))r(null,!0);this.rtlPluginParsingListeners=[]}}clearCaches(e,i,r){delete this.layerIndexes[e],delete this.availableImages[e],delete this.availableModels[e],delete this.workerSources[e],r()}checkIfReady(e,i,r){r()}setReferrer(e,i){this.referrer=i}spriteLoaded(i,r){this.isSpriteLoaded[i]||(this.isSpriteLoaded[i]={});let{scope:a,isLoaded:n}=r;if(this.isSpriteLoaded[i][a]=n,this.workerSources[i]&&this.workerSources[i][a])for(let r in this.workerSources[i][a]){let o=this.workerSources[i][a][r];for(let i in o){let r=o[i];r instanceof u&&(r.isSpriteLoaded=n,r.fire(new e.z("isSpriteLoaded")))}}}setImages(e,i,r){this.availableImages[e]||(this.availableImages[e]={});let{scope:a,images:n}=i;
7if(this.availableImages[e][a]=n,this.workerSources[e]&&this.workerSources[e][a]){for(let i in this.workerSources[e][a]){let r=this.workerSources[e][a][i];for(let e in r)r[e].availableImages=n}r()}else r()}setModels(e,{scope:i,models:r},a){if(this.availableModels[e]||(this.availableModels[e]={}),this.availableModels[e][i]=r,this.workerSources[e]&&this.workerSources[e][i]){for(let a in this.workerSources[e][i]){let n=this.workerSources[e][i][a];for(let e in n)n[e].availableModels=r}a()}else a()}setProjection(i,r){this.projections[i]=e.cl(r)}setBrightness(e,i,r){this.brightness=i,r()}setWorldview(e,i,r){this.worldview=i,r()}setLayers(e,i,r){this.getLayerIndex(e,i.scope).replace(i.layers,i.options),r()}updateLayers(e,i,r){this.getLayerIndex(e,i.scope).update(i.layers,i.removedIds,i.options),r()}loadTile(e,i,r){i.projection=this.projections[e]||this.defaultProjection,this.getWorkerSource(e,i.type,i.source,i.scope).loadTile(i,r)}decodeRasterArray(e,i,r){this.getWorkerSource(e,i.type,i.source,i.scope).decodeRasterArray(i,r)}reloadTile(e,i,r){i.projection=this.projections[e]||this.defaultProjection,this.getWorkerSource(e,i.type,i.source,i.scope).reloadTile(i,r)}abortTile(e,i,r){this.getWorkerSource(e,i.type,i.source,i.scope).abortTile(i,r)}removeTile(e,i,r){this.getWorkerSource(e,i.type,i.source,i.scope).removeTile(i,r)}removeSource(e,i,r){if(!(this.workerSources[e]&&this.workerSources[e][i.scope]&&this.workerSources[e][i.scope][i.type]&&this.workerSources[e][i.scope][i.type][i.source]))return;let a=this.workerSources[e][i.scope][i.type][i.source];delete this.workerSources[e][i.scope][i.type][i.source],void 0!==a.removeSource?a.removeSource(i,r):r()}loadWorkerSource(e,i,r){try{this.self.importScripts(i.url),r()}catch(e){r(e.toString())}}syncRTLPluginState(i,r,a){if(e.fy.isParsed())a(null,!0);else if(e.fy.isParsing())this.rtlPluginParsingListeners.push(a);else try{e.fy.setState(r);let i=e.fy.getPluginURL();!e.fy.isLoaded()||e.fy.isParsed()||e.fy.isParsing()||null==i||(e.fy.setState({pluginStatus:e.fz.parsing,pluginURL:e.fy.getPluginURL()}),this.self.importScripts(i),e.fy.isParsed()?a(null,!0):this.rtlPluginParsingListeners.push(a))}catch(e){a(e.toString())}}setDracoUrl(e,i){this.dracoUrl=i}getAvailableImages(e,i){this.availableImages[e]||(this.availableImages[e]={});let r=this.availableImages[e][i];return r||(r=[]),r}getAvailableModels(e,i){this.availableModels[e]||(this.availableModels[e]={});let r=this.availableModels[e][i];return r||(r={}),r}getLayerIndex(e,i){this.layerIndexes[e]||(this.layerIndexes[e]={});let r=this.layerIndexes[e][i];return r||((r=this.layerIndexes[e][i]=new n).scope=i),r}getWorkerSource(e,i,r,a){let n=this.workerSources;return n[e]||(n[e]={}),n[e][a]||(n[e][a]={}),n[e][a][i]||(n[e][a][i]={}),this.isSpriteLoaded[e]||(this.isSpriteLoaded[e]={}),n[e][a][i][r]||(n[e][a][i][r]=new this.workerSourceTypes[i]({send:(i,r,a,n,o,s)=>this.actor.send(i,r,a,e,o,s),scheduler:this.actor.scheduler},this.getLayerIndex(e,a),this.getAvailableImages(e,a),this.getAvailableModels(e,a),this.isSpriteLoaded[e][a],void 0,this.brightness,this.worldview)),n[e][a][i][r]}rasterizeImagesWorker(e,i,r){let a=new Map;for(let[r,{image:n,imageVariant:o}]of i.tasks.entries()){let s=this.imageRasterizer.rasterize(o,n,i.scope,e);a.set(r,s)}r(void 0,a)}removeRasterizedImages(e,i,r){this.imageRasterizer.removeImagesFromCacheByIds(i.imageIds,i.scope,e),r()}enforceCacheSizeLimit(i,r){e.fA(r)}getWorkerPerformanceMetrics(e,i,r){r(void 0,void 0)}}return e.fw(self)&&(self.worker=new eu(self)),eu}),a(["./shared"],function(e){let i,r,a;var n="3.15.0";let o={create:"create",load:"load",fullLoad:"fullLoad"},s={mark(e){performance.mark(e)},measure(e,i,r){performance.measure(e,i,r)}};function l(i){let r=i.name.split("?")[0];return e.a(r)&&r.includes("mapbox-gl.js")?"javascript":e.a(r)&&r.includes("mapbox-gl.css")?"css":e.b(r)?"fontRange":e.c(r)?"sprite":e.i(r)?"style":e.d(r)?"tilejson":"other"}var h,u={},c=function(){if(h)return u;function e(e){return!i(e)}function i(i){var a;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,i,r=new Blob([""],{type:"text/javascript"}),a=URL.createObjectURL(r);try{i=new Worker(a),e=!0}catch(i){e=!1}return i&&i.terminate(),URL.revokeObjectURL(a),e}()?"insufficient worker support":!function(){var e=document.createElement("canvas");e.width=e.height=1;var i=e.getContext("2d");if(!i)return!1;var r=i.getImageData(0,0,1,1);return r&&r.width===e.width}
7()?"insufficient Canvas/getImageData support":(void 0===r[a=i&&i.failIfMajorPerformanceCaveat]&&(r[a]=function(i){var r,a,n,o=(r=document.createElement("canvas"),(a=Object.create(e.webGLContextAttributes)).failIfMajorPerformanceCaveat=i,r.getContext("webgl2",a));if(!o)return!1;try{n=o.createShader(o.VERTEX_SHADER)}catch(e){return!1}return!(!n||o.isContextLost())&&(o.shaderSource(n,"void main() {}"),o.compileShader(n),!0===o.getShaderParameter(n,o.COMPILE_STATUS))}(a)),r[a]?document.documentMode?"insufficient ECMAScript 6 support":void 0:"insufficient WebGL2 support")}h=1,u.supported=e,u.notSupportedReason=i;var r={};return e.webGLContextAttributes={antialias:!1,alpha:!0,stencil:!0,depth:!0},u}();function d(e,i,r){let a=document.createElement(e);return null!=i&&(a.className=i),r&&r.appendChild(a),a}function p(e,i,r){let a=document.createElementNS("http://www.w3.org/2000/svg",e);for(let e of Object.keys(i))a.setAttributeNS(null,e,String(i[e]));return r&&r.appendChild(a),a}let f="undefined"!=typeof document?document.documentElement&&document.documentElement.style:null,m=f&&void 0!==f.userSelect?"userSelect":"WebkitUserSelect";function _(){f&&m&&(i=f[m],f[m]="none")}function g(){f&&m&&(f[m]=i)}function y(e){e.preventDefault(),e.stopPropagation(),window.removeEventListener("click",y,!0)}function x(){window.addEventListener("click",y,!0),window.setTimeout(()=>{window.removeEventListener("click",y,!0)},0)}function v(e,i){let r=e.getBoundingClientRect();return T(e,r,i)}function b(e,i){let r=e.getBoundingClientRect(),a=[];for(let n=0;n<i.length;n++)a.push(T(e,r,i[n]));return a}function w(e){return/firefox/i.test(navigator.userAgent)&&/macintosh/i.test(navigator.userAgent)&&2===e.button&&e.ctrlKey?0:e.button}function T(i,r,a){let n=i.offsetWidth===r.width?1:i.offsetWidth/r.width;return new e.P((a.clientX-r.left)*n,(a.clientY-r.top)*n)}let S="NO_ACCESS_TOKEN";class E{constructor(e,i,r){this._transformRequestFn=e,this._customAccessToken=i,this._silenceAuthErrors=!!r,this._createSkuToken()}_createSkuToken(){let e=function(){let e="";for(let i=0;i<10;i++)e+="0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"[Math.floor(62*Math.random())];return{token:"101"+e,tokenExpiresAt:Date.now()+432e5}}();this._skuToken=e.token,this._skuTokenExpiresAt=e.tokenExpiresAt}_isSkuTokenExpired(){return Date.now()>this._skuTokenExpiresAt}transformRequest(e,i){return this._transformRequestFn&&this._transformRequestFn(e,i)||{url:e}}normalizeStyleURL(i,r){if(!e.h(i))return i;let a=A(i);return a.params.push(`sdk=js-${n}`),a.path=`/styles/v1${a.path}`,this._makeAPIURL(a,this._customAccessToken||r)}normalizeGlyphsURL(i,r){if(!e.h(i))return i;let a=A(i);return a.path=`/fonts/v1${a.path}`,this._makeAPIURL(a,this._customAccessToken||r)}normalizeModelURL(i,r){if(!e.h(i))return i;let a=A(i);return a.path=`/models/v1${a.path}`,this._makeAPIURL(a,this._customAccessToken||r)}normalizeSourceURL(i,r,a,n){if(!e.h(i))return i;let o=A(i);return o.path=`/v4/${o.authority}.json`,o.params.push("secure"),a&&o.params.push(`language=${a}`),n&&o.params.push(`worldview=${n}`),this._makeAPIURL(o,this._customAccessToken||r)}normalizeIconsetURL(i,r){let a=A(i);return e.h(i)?(a.path=`/styles/v1${a.path}/iconset.pbf`,this._makeAPIURL(a,this._customAccessToken||r)):C(a)}normalizeSpriteURL(i,r,a,n){let o=A(i);return e.h(i)?(o.path=`/styles/v1${o.path}/sprite${r}${a}`,this._makeAPIURL(o,this._customAccessToken||n)):(o.path+=`${r}${a}`,C(o))}normalizeTileURL(i,r,a){if(this._isSkuTokenExpired()&&this._createSkuToken(),i&&!e.h(i))return i;let n=A(i);n.path=n.path.replace(/(\.(png|jpg)\d*)(?=$)/,`${r||a&&"raster"!==n.authority&&512===a?"@2x":""}${e.k.supported?".webp":"$1"}`),"raster"===n.authority?n.path=`/${e.e.RASTER_URL_PREFIX}${n.path}`:"rasterarrays"===n.authority?n.path=`/${e.e.RASTERARRAYS_URL_PREFIX}${n.path}`:"3dtiles"===n.authority?n.path=`/${e.e.TILES3D_URL_PREFIX}${n.path}`:(n.path=n.path.replace(/^.+\/v4\//,"/"),n.path=`/${e.e.TILE_URL_VERSION}${n.path}`);let o=this._customAccessToken||function(e){for(let i of e){let e=i.match(/^access_token=(.*)$/);if(e)return e[1]}return null}(n.params)||e.e.ACCESS_TOKEN;return e.e.REQUIRE_ACCESS_TOKEN&&o&&this._skuToken&&n.params.push(`sku=${this._skuToken}`),this._makeAPIURL(n,o)}canonicalizeTileURL(i,r){let a=A(i);if(!a.path.match(/^(\/v4\/|\/(raster|rasterarrays)\/v1\/)/)||!a.path.match(/\.[\w]+$/))return i;let n="mapbox://";a.path.match(/^\/raster\/v1\//)?n+=`raster/${a.path.replace(`/${e.e.RASTER_URL_PREFIX}/`,"")}`:a.path.match(/^\/rasterarrays\/v1\//)?n+=`rasterarrays/${a.path.replace(`/${e.e.RASTERARRAYS_URL_PREFIX}/`,"")}`:n+=`tiles/${a.path.replace(`/${e.e.TILE_URL_VERSION}/`,"")}`;let o=a.params;return r&&(o=o.filter(e=>!e.match(/^access_token=/))),o.length&&(n+=`?${o.join("&")}`),n}canonicalizeTileset(i,r){let a=!!r&&e.h(r),n=[];for(let r of i.tiles||[])e.j(r)?n.push(this.canonicalizeTileURL(r,a)):n.push(r);return n}_makeAPIURL(i,r){let a="See https://docs.mapbox.com/api/overview/#access-tokens-and-token-scopes",n=A(e.e.API_URL);if(i.protocol=n.protocol,i.authority=n.authority,"http"===i.protocol){let e=i.params.indexOf("secure");e>=0&&i.params.splice(e,1)}if("/"!==n.path&&(i.path=`${n.path}${i.path}`),!e.e.REQUIRE_ACCESS_TOKEN)return C(i);if(r=r||e.e.ACCESS_TOKEN,!this._silenceAuthErrors){if(!r)throw Error(`An API access token is required to use Mapbox GL. ${a}`);if("s"===r[0])throw Error(`Use a public access token (pk.*) with Mapbox GL, not a secret access token (sk.*). ${a}`)}return i.params=i.params.filter(e=>-1===e.indexOf("access_token")),i.params.push(`access_token=${r||""}`),C(i)}}let I=/^(\w+):\/\/([^/?]*)(\/[^?]+)?\??(.+)?/;function A(e){let i=e.match(I);if(!i)throw Error("Unable to parse URL object");return{protocol:i[1],authority:i[2],path:i[3]||"/",params:i[4]?i[4].split("&"):[]}}function C(e){let i=e.params.length?`?${e.params.join("&")}`:"";return`${e.protocol}://${e.authority}${e.path}${i}`}let M="mapbox.eventData";function P(i){if(!i)return null;let r=i.split(".");if(!r||3!==r.length)return null;try{return JSON.parse(e.l(r[1]))}catch(e){return null}}class z{constructor(e){this.type=e,this.anonId=null,this.eventData={},this.queue=[],this.pendingRequest=null}getStorageKey(i){let r=P(e.e.ACCESS_TOKEN),a="";return a=r&&r.u?e.f(r.u):e.e.ACCESS_TOKEN||"",i?`${M}.${i}:${a}`:`${M}:${a}
7`}fetchEventData(){let i=e.s("localStorage"),r=this.getStorageKey(),a=this.getStorageKey("uuid");if(i)try{let e=localStorage.getItem(r);e&&(this.eventData=JSON.parse(e));let i=localStorage.getItem(a);i&&(this.anonId=i)}catch(i){e.w("Unable to read from LocalStorage")}}saveEventData(){let i=e.s("localStorage"),r=this.getStorageKey(),a=this.getStorageKey("uuid"),n=this.anonId;if(i&&n)try{localStorage.setItem(a,n),Object.keys(this.eventData).length>=1&&localStorage.setItem(r,JSON.stringify(this.eventData))}catch(i){e.w("Unable to write to LocalStorage")}}processRequests(e){}postEvent(i,r,a,n){if(!e.e.EVENTS_URL)return;let o=A(e.e.EVENTS_URL);o.params.push(`access_token=${n||e.e.ACCESS_TOKEN||""}`);let s={event:this.type,created:new Date(i).toISOString()},l=r?Object.assign(s,r):s,h={url:C(o),headers:{"Content-Type":"text/plain"},body:JSON.stringify([l])};this.pendingRequest=e.p(h,e=>{this.pendingRequest=null,a(e),this.saveEventData(),this.processRequests(n)})}queueRequest(e,i){this.queue.push(e),this.processRequests(i)}}let R=new class extends z{constructor(e){super("appUserTurnstile"),this._customAccessToken=e}postTurnstileEvent(i,r){e.e.EVENTS_URL&&e.e.ACCESS_TOKEN&&Array.isArray(i)&&i.some(i=>e.h(i)||e.j(i))&&this.queueRequest(Date.now(),r)}processRequests(i){if(this.pendingRequest||0===this.queue.length)return;this.anonId&&this.eventData.lastSuccess&&this.eventData.tokenU||this.fetchEventData();let r=P(e.e.ACCESS_TOKEN),a=r?r.u:e.e.ACCESS_TOKEN,o=a!==this.eventData.tokenU;e.v(this.anonId)||(this.anonId=e.u(),o=!0);let s=this.queue.shift();if(this.eventData.lastSuccess){let e=new Date(this.eventData.lastSuccess),i=new Date(s),r=(s-this.eventData.lastSuccess)/864e5;o=o||r>=1||r<-1||e.getDate()!==i.getDate()}else o=!0;o?this.postEvent(s,{sdkIdentifier:"mapbox-gl-js",sdkVersion:n,skuId:"01","enabled.telemetry":!1,userId:this.anonId},e=>{e||(this.eventData.lastSuccess=s,this.eventData.tokenU=a)},i):this.processRequests()}},D=R.postTurnstileEvent.bind(R),L=new class extends z{constructor(){super("map.load"),this.success={},this.skuToken=""}postMapLoadEvent(i,r,a,n){this.skuToken=r,this.errorCb=n,e.e.EVENTS_URL&&(a||e.e.ACCESS_TOKEN?this.queueRequest({id:i,timestamp:Date.now()},a):this.errorCb(Error(S)))}processRequests(i){if(this.pendingRequest||0===this.queue.length)return;let{id:r,timestamp:a}=this.queue.shift();r&&this.success[r]||(this.anonId||this.fetchEventData(),e.v(this.anonId)||(this.anonId=e.u()),this.postEvent(a,{sdkIdentifier:"mapbox-gl-js",sdkVersion:n,skuId:"01",skuToken:this.skuToken,userId:this.anonId},e=>{e?this.errorCb(e):r&&(this.success[r]=!0)},i))}remove(){this.errorCb=null}},O=L.postMapLoadEvent.bind(L),F=new class extends z{constructor(){super("style.load"),this.eventIdPerMapInstanceMap=new Map,this.mapInstanceIdMap=new WeakMap}getMapInstanceId(i){let r=this.mapInstanceIdMap.get(i);return r||(r=e.u(),this.mapInstanceIdMap.set(i,r)),r}getEventId(e){let i=this.eventIdPerMapInstanceMap.get(e)||0;return this.eventIdPerMapInstanceMap.set(e,i+1),i}postStyleLoadEvent(i,r){let{map:a,style:n,importedStyles:o}=r;if(!e.e.EVENTS_URL||!i&&!e.e.ACCESS_TOKEN)return;let s=this.getMapInstanceId(a),l={mapInstanceId:s,eventId:this.getEventId(s),style:n};o.length&&(l.importedStyles=o),this.queueRequest({timestamp:Date.now(),payload:l},i)}processRequests(e){if(this.pendingRequest||0===this.queue.length)return;let{timestamp:i,payload:r}=this.queue.shift();this.postEvent(i,r,()=>{},e)}},k=F.postStyleLoadEvent.bind(F),B=new class extends z{constructor(){super("gljs.performance")}postPerformanceEvent(i,r){e.e.EVENTS_URL&&(i||e.e.ACCESS_TOKEN)&&this.queueRequest({timestamp:Date.now(),performanceData:r},i)}processRequests(i){if(this.pendingRequest||0===this.queue.length)return;let{timestamp:r,performanceData:a}=this.queue.shift(),s=function(i){let r=performance.getEntriesByType("resource"),a=performance.getEntriesByType("mark"),s=function(e){let i={};if(e){for(let r in e)if("other"!==r)for(let a of e[r]){let e=`${r}ResolveRangeMin`,n=`${r}ResolveRangeMax`,o=`${r}RequestCount`,s=`${r}RequestCachedCount`;i[e]=Math.min(i[e]||1/0,a.startTime),i[n]=Math.max(i[n]||-1/0,a.responseEnd);let l=e=>{void 0===i[e]&&(i[e]=0),++i[e]};void 0!==a.transferSize&&0===a.transferSize&&l(s),l(o)}}return i}(function(e,i){let r={};if(e)for(let a of e){let e=i(a);void 0===r[e]&&(r[e]=[]),r[e].push(a)}return r}(r,l)),h=window.devicePixelRatio,u=navigator.connection||navigator.mozConnection||navigator.webkitConnection,c=u?u.effectiveType:void 0,d={counters:[],metadata:[],attributes:[]},p=(e,i,r)=>{null!=r&&e.push({name:i,value:r.toString()})};for(let e in s)p(d.counters,e,s[e]);if(i.interactionRange[0]!==1/0&&i.interactionRange[1]!==-1/0&&(p(d.counters,"interactionRangeMin",i.interactionRange[0]),p(d.counters,"interactionRangeMax",i.interactionRange[1])),a)for(let e of Object.keys(o)){let i=o[e],r=a.find(e=>e.name===i);
7r&&p(d.counters,i,r.startTime)}return p(d.counters,"visibilityHidden",i.visibilityHidden),p(d.attributes,"style",function(i){if(i)for(let r of i){let i=r.name.split("?")[0];if(e.i(i)){let e=i.split("/").slice(-2);if(2===e.length)return`mapbox://styles/${e[0]}/${e[1]}`}}}(r)),p(d.attributes,"terrainEnabled",i.terrainEnabled?"true":"false"),p(d.attributes,"fogEnabled",i.fogEnabled?"true":"false"),p(d.attributes,"projection",i.projection),p(d.attributes,"zoom",i.zoom),p(d.metadata,"devicePixelRatio",h),p(d.metadata,"connectionEffectiveType",c),p(d.metadata,"navigatorUserAgent",navigator.userAgent),p(d.metadata,"screenWidth",window.screen.width),p(d.metadata,"screenHeight",window.screen.height),p(d.metadata,"windowWidth",window.innerWidth),p(d.metadata,"windowHeight",window.innerHeight),p(d.metadata,"mapWidth",i.width/h),p(d.metadata,"mapHeight",i.height/h),p(d.metadata,"webglRenderer",i.renderer),p(d.metadata,"webglVendor",i.vendor),p(d.metadata,"sdkVersion",n),p(d.metadata,"sdkIdentifier","mapbox-gl-js"),d}(a);for(let e of s.metadata);for(let e of s.counters);for(let e of s.attributes);this.postEvent(r,s,()=>{},i)}},N=B.postPerformanceEvent.bind(B),V=new class extends z{constructor(){super("map.auth"),this.success={},this.skuToken=""}getSession(i,r,a,n){if(!e.e.API_URL||!e.e.SESSION_PATH)return;let o=A(e.e.API_URL+e.e.SESSION_PATH);o.params.push(`sku=${r||""}`),o.params.push(`access_token=${n||e.e.ACCESS_TOKEN||""}`);let s={url:C(o),headers:{"Content-Type":"text/plain"}};this.pendingRequest=e.g(s,e=>{this.pendingRequest=null,a(e),this.saveEventData(),this.processRequests(n)})}getSessionAPI(i,r,a,n){this.skuToken=r,this.errorCb=n,e.e.SESSION_PATH&&e.e.API_URL&&(a||e.e.ACCESS_TOKEN?this.queueRequest({id:i,timestamp:Date.now()},a):this.errorCb(Error(S)))}processRequests(e){if(this.pendingRequest||0===this.queue.length)return;let{id:i,timestamp:r}=this.queue.shift();i&&this.success[i]||this.getSession(r,this.skuToken,e=>{e?this.errorCb(e):i&&(this.success[i]=!0)},e)}remove(){this.errorCb=null}},U=V.getSessionAPI.bind(V),j=new Set;function G(e,i){i?j.add(e):j.delete(e)}class q{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,i){this._updatedSourceCaches[e]=i,this.setDirty()}discardSourceCacheUpdate(e){delete this._updatedSourceCaches[e]}updateLayer(e){let i=e.scope;this._updatedLayers[i]=this._updatedLayers[i]||new Set,this._updatedLayers[i].add(e.id),this.setDirty()}removeLayer(e){let i=e.scope;this._removedLayers[i]=this._removedLayers[i]||{},this._updatedLayers[i]=this._updatedLayers[i]||new Set,this._removedLayers[i][e.id]=e,this._updatedLayers[i].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(){let e={};for(let i in this._updatedLayers)e[i]=e[i]||{},e[i].updatedIds=Array.from(this._updatedLayers[i].values());for(let i in this._removedLayers)e[i]=e[i]||{},e[i].removedIds=Object.keys(this._removedLayers[i]);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(i,r){this._updatedImages[r]=this._updatedImages[r]||new Set,this._updatedImages[r].add(e.I.toString(i)),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={}}}class $ extends e.E{constructor(i){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=i,"raster"!==i&&e.r()&&(this.imageRasterizerDispatcher=new e.D(e.t(),this,"Image Rasterizer Worker",1))}addScope(i){this.loaded.set(i,!1),this.imageProviders.set(i,new Map),this.images.set(i,new Map),this.updatedImages.set(i,new Set),this.callbackDispatchedThisFrame.set(i,new Set),this.patterns.set(i,new Map),this.atlasImage.set(i,new e.q({width:1,height:1}))}removeScope(e){this.loaded.delete(e),this.imageProviders.delete(e),this.images.delete(e),this.updatedImages.delete(e),this.callbackDispatchedThisFrame.delete(e),this.patterns.delete(e),this.atlasImage.delete(e);let i=this.atlasTexture.get(e);i&&(i.destroy(),this.atlasTexture.delete(e))}addImageProvider(e,i){this.imageProviders.has(i)||this.imageProviders.set(i,new Map),this.imageProviders.get(i).set(e.id,e)}removeImageProvider(e,i){this.imageProviders.has(i)&&this.imageProviders.get(i).delete(e)}getPendingImageProviders(){let e=[];for(let i of this.imageProviders.values())for(let r of i.values())r.hasPendingRequests()&&e.push(r);return e}get imageRasterizer(){return this._imageRasterizer||(this._imageRasterizer=new e.x),this._imageRasterizer}isLoaded(){for(let e of this.loaded.keys())if(!this.loaded.get(e))return!1;return!0}setLoaded(e,i){if(this.loaded.get(i)!==e&&(this.loaded.set(i,e),e)){for(let{ids:e,callback:r}of this.requestors)this._notify(e,i,r);this.requestors=[]}}hasImage(e,i){return!!this.getImage(e,i)}getImage(e,i){return this.images.get(i).get(e.toString())}
7addImage(e,i,r){this._validate(e,r)&&this.images.get(i).set(e.toString(),r)}_validate(i,r){let a=!0;return this._validateStretch(r.stretchX,r.data&&r.data.width)||(this.fire(new e.y(Error(`Image "${i.name}" has invalid "stretchX" value`))),a=!1),this._validateStretch(r.stretchY,r.data&&r.data.height)||(this.fire(new e.y(Error(`Image "${i.name}" has invalid "stretchY" value`))),a=!1),this._validateContent(r.content,r)||(this.fire(new e.y(Error(`Image "${i.name}" has invalid "content" value`))),a=!1),a}_validateStretch(e,i){if(!e)return!0;let r=0;for(let a of e){if(a[0]<r||a[1]<a[0]||i<a[1])return!1;r=a[1]}return!0}_validateContent(e,i){return!e||4===e.length&&(!!i.usvg||!(e[0]<0)&&!(i.data.width<e[0])&&!(e[1]<0)&&!(i.data.height<e[1])&&!(e[2]<0)&&!(i.data.width<e[2])&&!(e[3]<0)&&!(i.data.height<e[3]))&&!(e[2]<e[0]||e[3]<e[1])}updateImage(e,i,r){r.version=this.images.get(i).get(e.toString()).version+1,this.images.get(i).set(e.toString(),r),this.updatedImages.get(i).add(e),this.removeFromImageRasterizerCache(e,i)}clearUpdatedImages(e){this.updatedImages.get(e).clear()}removeFromImageRasterizerCache(i,r){"raster"!==this.spriteFormat&&(e.r()?this.imageRasterizerDispatcher.getActor().send("removeRasterizedImages",{imageIds:[i],scope:r}):this.imageRasterizer.removeImagesFromCacheByIds([i],r))}removeImage(e,i){let r=this.images.get(i),a=r.get(e.toString());r.delete(e.toString()),this.patterns.get(i).delete(e.toString()),this.removeFromImageRasterizerCache(e,i),a.userImage&&a.userImage.onRemove&&a.userImage.onRemove()}listImages(i){return Array.from(this.images.get(i).keys()).map(i=>e.I.from(i))}getImages(e,i,r){let a=[],n=[],o=this.imageProviders.get(i);for(let r of e){if(!r.iconsetId){a.push(r);continue}let e=o.get(r.iconsetId);e&&(this.getImage(r,i)?n.push(r):e.addPendingRequest(r))}if(0===a.length)return void this._notify(n,i,r);let s=!0,l=!!this.loaded.get(i),h=this.images.get(i);if(!l)for(let e of a)h.has(e.toString())||(s=!1);l||s?this._notify(a,i,r):this.requestors.push({ids:a,scope:i,callback:r})}rasterizeImages(e,i){let r=new Map,{tasks:a,scope:n}=e;for(let[e,i]of a.entries()){let a=this.getImage(i.id,n);a&&r.set(e,{image:a,imageVariant:i})}this._rasterizeImages(n,r,i)}_rasterizeImages(i,r,a){if(e.r())this.imageRasterizerDispatcher.getActor().send("rasterizeImagesWorker",{tasks:r,scope:i},a);else{let e=new Map;for(let[a,{image:n,imageVariant:o}]of r.entries())e.set(a,this.imageRasterizer.rasterize(o,n,i,0));a(void 0,e)}}getUpdatedImages(e){return this.updatedImages.get(e)||new Set}_notify(i,r,a){let n=this.images.get(r),o=new Map;for(let r of i){if(!n.get(r.toString())){if(r.iconsetId)continue;this.fire(new e.z("styleimagemissing",{id:r.name}))}let i=n.get(r.toString());if(!i){e.w(`Image "${r.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}let a={data:i.usvg?null:i.data.clone(),pixelRatio:i.pixelRatio,sdf:i.sdf,usvg:i.usvg,version:i.version,stretchX:i.stretchX,stretchY:i.stretchY,content:i.content,hasRenderCallback:!!(i.userImage&&i.userImage.render)};i.usvg&&Object.assign(a,{width:i.icon.usvg_tree.width,height:i.icon.usvg_tree.height}),o.set(e.I.toString(r),a)}a(null,o)}getPixelSize(e){let{width:i,height:r}=this.atlasImage.get(e);return{width:i,height:r}}getPattern(i,r,a){let n=i.toString(),o=this.patterns.get(r),s=o.get(n),l=this.getImage(i,r);if(!l)return null;if(s){if(s.position.version===l.version)return s.position;s.position.version=l.version}else{if(l.usvg&&!l.data){let o=this.getPatternInFlightId(n,r);if(this.patternsInFlight.has(o))return null;this.patternsInFlight.add(o);let s=new e.A(i).scaleSelf(e.o.devicePixelRatio),h=new Map([[s.toString(),{image:l,imageVariant:s}]]);return this._rasterizeImages(r,h,(e,i)=>this.storePatternImage(s,r,l,a,i)),null}this.storePattern(i,r,l)}return this._updatePatternAtlas(r,a),o.get(n).position}getPatternInFlightId(i,r){return e.B(i,r)}hasPatternsInFlight(){return 0!==this.patternsInFlight.size}storePatternImage(e,i,r,a,n){let o=e.toString(),s=n?n.get(o):void 0;s&&(r.data=s,this.storePattern(e.id,i,r),this._updatePatternAtlas(i,a),this.patternsInFlight.delete(this.getPatternInFlightId(e.id.toString(),i)))}storePattern(i,r,a){let n={w:a.data.width+2*e.C,h:a.data.height+2*e.C,x:0,y:0},o=new e.F(n,a,e.C);this.patterns.get(r).set(i.toString(),{bin:n,position:o})}destroyAtlasTextures(){for(let e of this.atlasTexture.values())e&&e.destroy();this.atlasTexture.clear()}bind(i,r){let a=i.gl,n=this.atlasTexture.get(r);n?this.dirty&&(n.update(this.atlasImage.get(r)),this.dirty=!1):(n=new e.T(i,this.atlasImage.get(r),a.RGBA8),this.atlasTexture.set(r,n)),n.bind(a.LINEAR,a.CLAMP_TO_EDGE)}_updatePatternAtlas(i,r){let a=this.patterns.get(i),n=Array.from(a.values()).map(({bin:e})=>e),{w:o,h:s}=e.G(n),l=this.atlasImage.get(i);l.resize({width:o||1,height:s||1});let h=this.images.get(i);for(let[i,{bin:n,position:o}]of a.entries()){let a=o.padding,s=n.x+a,u=n.y+a,c=h.get(i).data,d=c.width,p=c.height;a=a>1?a-1:a,e.q.copy(c,l,{x:0,y:0},{x:s,y:u},{width:d,height:p},r),e.q.copy(c,l,{x:0,y:p-a},{x:s,y:u-a},{width:d,height:a},r),e.q.copy(c,l,{x:0,y:0},{x:s,y:u+p},{width:d,height:a},r),e.q.copy(c,l,{x:d-a,y:0},{x:s-a,y:u},{width:a,height:p},r),e.q.copy(c,l,{x:0,y:0},{x:s+d,y:u},{width:a,height:p},r),e.q.copy(c,l,{x:d-a,y:p-a},{x:s-a,y:u-a},{width:a,height:a},r),e.q.copy(c,l,{x:0,y:p-a},{x:s+d,y:u-a},{width:a,height:a},r),e.q.copy(c,l,{x:0,y:0},{x:s+d,y:u+p},{width:a,height:a},r),e.q.copy(c,l,{x:d-a,y:0},{x:s-a,y:u+p},{width:a,height:a},r)}this.dirty=!0}beginFrame(){for(let e of this.images.keys())this.callbackDispatchedThisFrame.set(e,new Set)}
7dispatchRenderCallbacks(e,i){let r=this.images.get(i);for(let a of e){if(this.callbackDispatchedThisFrame.get(i).has(a.toString()))continue;this.callbackDispatchedThisFrame.get(i).add(a.toString());let e=r.get(a.toString());(function(e){let{userImage:i}=e;return!!(i&&i.render&&i.render())&&(e.data.replace(new Uint8Array(i.data.buffer)),!0)})(e)&&this.updateImage(a,i,e)}}destroy(){this.imageRasterizerDispatcher&&this.imageRasterizerDispatcher.remove()}}function H(i){let r=i.value,a=i.valueSpec,n=i.style,o=i.styleSpec,s=i.key,l=i.arrayElementValidator||eu;if(!Array.isArray(r))return[new e.V(s,r,`array expected, ${e.K(r)} found`)];if(a.length&&r.length!==a.length)return[new e.V(s,r,`array length ${a.length} expected, length ${r.length} found`)];if(a["min-length"]&&r.length<a["min-length"])return[new e.V(s,r,`array length at least ${a["min-length"]} expected, length ${r.length} found`)];let h={type:a.value,values:a.values,minimum:a.minimum,maximum:a.maximum,function:void 0};o.$version<7&&(h.function=a.function),e.H(a.value)&&(h=a.value);let u=[];for(let e=0;e<r.length;e++)u=u.concat(l({array:r,arrayIndex:e,value:r[e],valueSpec:h,style:n,styleSpec:o,key:`${s}[${e}]`},!0));return u}function Z(i){let r=i.key,a=i.value,n=i.valueSpec;if(!e.L(a))return[new e.V(r,a,`number expected, ${e.K(a)} found`)];if(a!=a)return[new e.V(r,a,"number expected, NaN found")];if("minimum"in n){let o=n.minimum;if(Array.isArray(n.minimum)&&(o=n.minimum[i.arrayIndex]),a<o)return[new e.V(r,a,`${a} is less than the minimum value ${o}`)]}if("maximum"in n){let o=n.maximum;if(Array.isArray(n.maximum)&&(o=n.maximum[i.arrayIndex]),a>o)return[new e.V(r,a,`${a} is greater than the maximum value ${o}`)]}return[]}function W(i){let r=i.key,a=i.value;if(!e.H(a))return[new e.V(r,a,`object expected, ${e.K(a)} found`)];let n=i.valueSpec,o=e.J(a.type),s,l,h,u={},c="categorical"!==o&&void 0===a.property,d=function(i){let r=i.stops;return Array.isArray(r)&&Array.isArray(r[0])&&e.H(r[0][0])}(a),p=ec({key:i.key,value:i.value,valueSpec:i.styleSpec.function,style:i.style,styleSpec:i.styleSpec,objectElementValidators:{stops:function(i){if("identity"===o)return[new e.V(i.key,i.value,'identity function may not have a "stops" property')];let r=[],a=i.value;return r=r.concat(H({key:i.key,value:a,valueSpec:i.valueSpec,style:i.style,styleSpec:i.styleSpec,arrayElementValidator:f})),Array.isArray(a)&&0===a.length&&r.push(new e.V(i.key,a,"array must have at least one stop")),r},default:function(e){return eu({key:e.key,value:e.value,valueSpec:n,style:e.style,styleSpec:e.styleSpec})}}});return"identity"===o&&c&&p.push(new e.V(i.key,i.value,'missing required property "property"')),"identity"===o||a.stops||p.push(new e.V(i.key,i.value,'missing required property "stops"')),"exponential"===o&&n.expression&&!e.M(n)&&p.push(new e.V(i.key,i.value,"exponential functions not supported")),i.styleSpec.$version>=8&&(c||e.N(n)?c&&!e.O(n)&&p.push(new e.V(i.key,i.value,"zoom functions not supported")):p.push(new e.V(i.key,i.value,"property functions not supported"))),("categorical"===o||d)&&void 0===a.property&&p.push(new e.V(i.key,i.value,'"property" property is required')),p;function f(i){let r=[],a=i.value,o=i.key;if(!Array.isArray(a))return[new e.V(o,a,`array expected, ${e.K(a)} found`)];if(2!==a.length)return[new e.V(o,a,`array length 2 expected, length ${a.length} found`)];if(d){if(!e.H(a[0]))return[new e.V(o,a,`object expected, ${e.K(a[0])} found`)];let n=a[0];if(void 0===n.zoom)return[new e.V(o,a,"object stop key must have zoom")];if(void 0===n.value)return[new e.V(o,a,"object stop key must have value")];let s=e.J(n.zoom);if("number"!=typeof s)return[new e.V(o,n.zoom,"stop zoom values must be numbers")];if(h&&h>s)return[new e.V(o,n.zoom,"stop zoom values must appear in ascending order")];s!==h&&(h=s,l=void 0,u={}),r=r.concat(ec({key:`${o}[0]`,value:a[0],valueSpec:{zoom:{}},style:i.style,styleSpec:i.styleSpec,objectElementValidators:{zoom:Z,value:m}}))}else r=r.concat(m({key:`${o}[0]`,value:a[0],style:i.style,styleSpec:i.styleSpec},a));return e.Q(e.S(a[1]))?r.concat([new e.V(`${o}[1]`,a[1],"expressions are not allowed in function stops.")]):r.concat(eu({key:`${o}[1]`,value:a[1],valueSpec:n,style:i.style,styleSpec:i.styleSpec}))}
7function m(i,r){let a=e.K(i.value),h=e.J(i.value),c=null!==i.value?i.value:r;if(s){if(a!==s)return[new e.V(i.key,c,`${a} stop domain type must match previous stop domain type ${s}`)]}else s=a;if("number"!==a&&"string"!==a&&"boolean"!==a&&"number"!=typeof h&&"string"!=typeof h&&"boolean"!=typeof h)return[new e.V(i.key,c,"stop domain value must be a number, string, or boolean")];if("number"!==a&&"categorical"!==o){let r=`number expected, ${a} found`;return e.N(n)&&void 0===o&&(r+='\nIf you intended to use a categorical function, specify `"type": "categorical"`.'),[new e.V(i.key,c,r)]}return"categorical"!==o||"number"!==a||"number"==typeof h&&isFinite(h)&&Math.floor(h)===h?"categorical"!==o&&"number"===a&&"number"==typeof h&&"number"==typeof l&&void 0!==l&&h<l?[new e.V(i.key,c,"stop domain values must appear in ascending order")]:(l=h,"categorical"===o&&h in u?[new e.V(i.key,c,"stop domain values must be unique")]:(u[h]=!0,[])):[new e.V(i.key,c,`integer expected, found ${String(h)}`)]}}function X(i){let r=("property"===i.expressionContext?e.W:e.U)(e.S(i.value),i.valueSpec);if("error"===r.result)return r.value.map(r=>new e.V(`${i.key}${r.key}`,i.value,r.message));let a=r.value.expression||r.value._styleExpression.expression;if("property"===i.expressionContext&&"text-font"===i.propertyKey&&!a.outputDefined())return[new e.V(i.key,i.value,`Invalid data expression for "${i.propertyKey}". Output values must be contained as literals within the expression.`)];if("property"===i.expressionContext&&"layout"===i.propertyType&&!e.Z(a))return[new e.V(i.key,i.value,'"feature-state" data expressions are not supported with layout properties.')];if("filter"===i.expressionContext)return function i(r,a){let n=new Set(["zoom","feature-state","pitch","distance-from-center"]);if(a.valueSpec&&a.valueSpec.expression)for(let e of a.valueSpec.expression.parameters)n.delete(e);if(0===n.size)return[];let o=[];return r instanceof e._&&n.has(r.name)?[new e.V(a.key,a.value,`["${r.name}"] expression is not supported in a filter for a ${a.object.type} layer with id: ${a.object.id}`)]:(r.eachChild(e=>{o.push(...i(e,a))}),o)}(a,i);if("appearance"===i.expressionContext)return function i(r,a){let n=new Set;if(a.valueSpec&&a.valueSpec.expression)for(let e of a.valueSpec.expression.parameters)n.add(e);if(0===n.size)return[];let o=[];return r instanceof e._&&!n.has(r.name)?[new e.V(a.key,a.value,`["${r.name}"] is not an allowed parameter`)]:(r.eachChild(e=>{o.push(...i(e,a))}),o)}(a,i);if(i.expressionContext&&0===i.expressionContext.indexOf("cluster")){if(!e.X(a,["zoom","feature-state"]))return[new e.V(i.key,i.value,'"zoom" and "feature-state" expressions are not supported with cluster properties.')];if("cluster-initial"===i.expressionContext&&!e.Y(a))return[new e.V(i.key,i.value,"Feature data expressions are not supported with initial expression part of cluster properties.")]}return[]}function Y(i){let r=i.key,a=i.value,n=i.valueSpec,o=[];return Array.isArray(n.values)?-1===n.values.indexOf(e.J(a))&&o.push(new e.V(r,a,`expected one of [${n.values.join(", ")}], ${JSON.stringify(a)} found`)):-1===Object.keys(n.values).indexOf(e.J(a))&&o.push(new e.V(r,a,`expected one of [${Object.keys(n.values).join(", ")}], ${JSON.stringify(a)} found`)),o}function K(i){return e.a2(e.S(i.value))?X(Object.assign({},i,{expressionContext:"filter",valueSpec:i.styleSpec[`filter_${i.layerType||"fill"}`]})):function i(r){let a=r.value,n=r.key;if(!Array.isArray(a))return[new e.V(n,a,`array expected, ${e.K(a)} found`)];if(a.length<1)return[new e.V(n,a,"filter array must have at least 1 element")];let o=r.styleSpec,s=Y({key:`${n}[0]`,value:a[0],valueSpec:o.filter_operator});switch(e.J(a[0])){case"<":case"<=":case">":case">=":a.length>=2&&"$type"===e.J(a[1])&&s.push(new e.V(n,a,`"$type" cannot be use with operator "${a[0]}"`));case"==":case"!=":3!==a.length&&s.push(new e.V(n,a,`filter array for operator "${a[0]}" must have 3 elements`));case"in":case"!in":a.length>=2&&(e.a0(a[1])||s.push(new e.V(`${n}[1]`,a[1],`string expected, ${e.K(a[1])} found`)));for(let i=2;i<a.length;i++)"$type"===e.J(a[1])?s=s.concat(Y({key:`${n}[${i}]`,value:a[i],valueSpec:o.geometry_type})):e.a0(a[i])||e.L(a[i])||e.$(a[i])||s.push(new e.V(`${n}[${i}]`,a[i],`string, number, or boolean expected, ${e.K(a[i])} found.`));break;case"any":case"all":case"none":for(let e=1;e<a.length;e++)s=s.concat(i({key:`${n}[${e}]`,value:a[e],style:r.style,styleSpec:r.styleSpec}));break;case"has":case"!has":2!==a.length?s.push(new e.V(n,a,`filter array for "${a[0]}" operator must have 2 elements`)):e.a0(a[1])||s.push(new e.V(`${n}[1]`,a[1],`string expected, ${e.K(a[1])} found`))}return s}(i)}function J(i,r){let a,n=i.key,o=i.style,s=i.layer,l=i.styleSpec,h=i.value,u=i.objectKey,c=l[`${r}_${i.layerType}`];if(!c)return[];let d=u.match(/^(.*)-use-theme$/);if(d&&c[d[1]])return e.Q(h)?[].concat(eu({key:i.key,value:h,valueSpec:{type:"string",expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"data-driven"},style:o,styleSpec:l,expressionContext:"property",propertyType:r,propertyKey:u})):eu({key:n,value:h,valueSpec:{type:"string"},style:o,styleSpec:l});let p=u.match(/^(.*)-transition$/);if("paint"===r&&p&&c[p[1]]&&c[p[1]].transition)return eu({key:n,value:h,valueSpec:l.transition,style:o,styleSpec:l});let f=i.valueSpec||c[u];if(!f)return[new e.a3(n,h,`unknown property "${u}"`)];if(e.a0(h)&&e.N(f)&&!f.tokens&&(a=/^{([^}]+)}$/.exec(h))){let i=`\`{ "type": "identity", "property": ${a?JSON.stringify(a[1]):'"_"'} }\``;return[new e.V(n,h,`"${u}" does not support interpolation syntax 8Use an identity property function instead: ${i}.`)]}let m=[];
8if("symbol"===i.layerType)"text-field"!==u||!o||o.glyphs||o.imports||m.push(new e.V(n,h,'use of "text-field" requires a style "glyphs" property')),"text-font"===u&&e.a4(e.S(h))&&"identity"===e.J(h.type)&&m.push(new e.V(n,h,'"text-font" does not support identity functions'));else if("model"===i.layerType&&"paint"===r&&s&&s.layout&&s.layout.hasOwnProperty("model-id")&&e.N(f)&&(e.a5(f)||e.O(f))){let i=e.W(e.S(h),f),r=i.value.expression||i.value._styleExpression.expression;r&&!e.X(r,["measure-light"])&&("model-emissive-strength"===u&&e.Y(r)&&e.Z(r)||m.push(new e.V(n,h,`${u} does not support measure-light expressions when the model layer source is vector tile or GeoJSON.`)))}return m.concat(eu({key:i.key,value:h,valueSpec:f,style:o,styleSpec:l,expressionContext:"property",propertyType:r,propertyKey:u}))}function Q(e){return J(e,"paint")}function ee(e){return J(e,"layout")}function et(i){let r=[],a=i.value,n=i.key,o=i.style,s=i.styleSpec;if(!e.H(a))return[new e.V(n,a,"object expected")];a.type||a.ref||r.push(new e.V(n,a,'either "type" or "ref" is required'));let l=e.J(a.type),h=e.J(a.ref);if(a.id){let s=e.J(a.id);for(let l=0;l<i.arrayIndex;l++){let i=o.layers[l];e.J(i.id)===s&&r.push(new e.V(n,a.id,`duplicate layer id "${s}", previously used at line ${i.id.__line__}`))}}if("ref"in a){let i;["type","source","source-layer","filter","layout"].forEach(i=>{i in a&&r.push(new e.V(n,a[i],`"${i}" is prohibited for ref layers`))}),o.layers.forEach(r=>{e.J(r.id)===h&&(i=r)}),i?i.ref?r.push(new e.V(n,a.ref,"ref cannot reference another ref layer")):l=e.J(i.type):"string"==typeof h&&r.push(new e.V(n,a.ref,`ref layer "${h}" not found`))}else if("background"!==l&&"sky"!==l&&"slot"!==l)if(a.source)if(e.a0(a.source)){let i=o.sources&&o.sources[a.source],s=i&&e.J(i.type);i?"vector"===s&&"raster"===l?r.push(new e.V(n,a.source,`layer "${a.id}" requires a raster source`)):"raster"===s&&"raster"!==l?r.push(new e.V(n,a.source,`layer "${a.id}" requires a vector source`)):"vector"!==s||a["source-layer"]?"raster-dem"===s&&"hillshade"!==l?r.push(new e.V(n,a.source,"raster-dem source can only be used with layer type 'hillshade'.")):"raster-array"!==s||["raster","raster-particle"].includes(l)?"line"===l&&a.paint&&(
8a.paint["line-gradient"]||a.paint["line-trim-offset"])&&"geojson"===s&&!i.lineMetrics?r.push(new e.V(n,a,`layer "${a.id}" specifies a line-gradient, which requires the GeoJSON source to have \`lineMetrics\` enabled.`)):"raster-particle"===l&&"raster-array"!==s&&r.push(new e.V(n,a.source,`layer "${a.id}" requires a 'raster-array' source.`)):r.push(new e.V(n,a.source,"raster-array source can only be used with layer type 'raster'.")):r.push(new e.V(n,a,`layer "${a.id}" must specify a "source-layer"`)):r.push(new e.V(n,a.source,`source "${a.source}" not found`))}else r.push(new e.V(`${n}.source`,a.source,'"source" must be a string'));else r.push(new e.V(n,a,'missing required property "source"'));return r=r.concat(ec({key:n,value:a,valueSpec:s.layer,style:i.style,styleSpec:i.styleSpec,objectElementValidators:{"*":()=>[],type:()=>eu({key:`${n}.type`,value:a.type,valueSpec:s.layer.type,style:i.style,styleSpec:i.styleSpec,object:a,objectKey:"type"}),filter:e=>K(Object.assign({layerType:l},e)),layout:e=>ec({layer:a,key:e.key,value:e.value,valueSpec:{},style:e.style,styleSpec:e.styleSpec,objectElementValidators:{"*":e=>ee(Object.assign({layerType:l},e))}}),paint:e=>ec({layer:a,key:e.key,value:e.value,valueSpec:{},style:e.style,styleSpec:e.styleSpec,objectElementValidators:{"*":e=>Q(Object.assign({layerType:l,layer:a},e))}}),appearances(i){let r=H({key:i.key,value:i.value,valueSpec:i.valueSpec,style:i.style,styleSpec:i.styleSpec,arrayElementValidator:i=>(function(i){let{key:r,layer:a,layerType:n}=i,o=e.J(i.value),s=e.J(o.name),l=e.J(o.condition),h=ec({key:r,value:o,valueSpec:i.styleSpec.appearance,style:i.style,styleSpec:i.styleSpec,objectElementValidators:{condition:i=>(function(i){let r=[];return r.push(...X({key:i.key,value:i.object.condition,valueSpec:e.a6.appearance.condition,expressionContext:"appearance"})),r})(Object.assign({layer:a,layerType:n},i)),properties:i=>(function(i){let r=[],{styleSpec:a,layer:n,layerType:o}=i,s=a[`paint_${o}`],l=a[`layout_${o}`],h=i.object[i.objectKey];for(let a in h){let u=a in s?"paint":a in l?"layout":void 0;if(!u){r.push(new e.V(i.key,a,`unknown property "${a}" for layer type "${o}"`));continue}let c=Object.assign({},i,{key:`${i.key}.${a}`,object:h,objectKey:a,layer:n,layerType:o,value:h[a],valueSpec:"paint"===u?s[a]:l[a]});r.push(...J(c,u))}return r})(Object.assign({layer:a,layerType:n},i))}});return"hidden"===s||l||h.push(new e.V(i.key,"name",'Appearance with name different than "hidden" must have a condition')),h})(Object.assign({layerType:l,layer:a},i))}),n=Array.isArray(i.value)?i.value:[],o=new Set;return n.forEach((n,s)=>{let l=e.J(n.name);if(l)if(o.has(l)){let n=e.J(a.id);r.push(new e.V(i.key,l,`Duplicated appearance name "${l}" for layer "${n}"`))}else o.add(l)}),r}}}))}function ei({key:i,value:r}){return e.a0(r)?[]:[new e.V(i,r,`string expected, ${e.K(r)} found`)]}let er={promoteId:function i({key:r,value:a}){if(e.a0(a))return ei({key:r,value:a});if(Array.isArray(a)){let i=[],n=e.S(a),o=e.U(n);return"error"===o.result&&o.value.forEach(a=>{i.push(new e.V(`${r}${a.key}`,null,`${a.message}`))}),e.X(o.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"])||i.push(new e.V(`${r}`,null,"promoteId expression should be only feature dependent")),i}if(!e.H(a))return[new e.V(r,a,`string, expression or object expected, "${e.K(a)}" found`)];let n=[];for(let e in a)n.push(...i({key:`${r}.${e}`,value:a[e]}));return n}};function ea(i){let r=i.value,a=i.key,n=i.styleSpec,o=i.style;if(!e.H(r))return[new e.V(a,r,`object expected, ${e.K(r)} found`)];if(!("type"in r))return[new e.V(a,r,'"type" is required')];let s=e.J(r.type),l=[];switch(["vector","raster","raster-dem","raster-array"].includes(s)&&("url"in r||"tiles"in r||l.push(new e.a3(a,r,'Either "url" or "tiles" is required.'))),s){case"vector":case"raster":case"raster-dem":case"raster-array":return l.concat(ec({key:a,value:r,valueSpec:n[`source_${s.replace("-","_")}`],style:i.style,styleSpec:n,objectElementValidators:er}));case"geojson":if(l=ec({key:a,value:r,valueSpec:n.source_geojson,style:o,styleSpec:n,objectElementValidators:er}),"cluster"in r&&"clusterProperties"in r){if(!e.H(r.clusterProperties))return[new e.V(`${a}.clusterProperties`,r,`object expected, ${e.K(r)} found`)];for(let i in r.clusterProperties){let n=r.clusterProperties[i];if(!Array.isArray(n))return[new e.V(`${a}.clusterProperties.${i}`,n,"array expected")];
8let[o,s]=n,h="string"==typeof o?[o,["accumulated"],["get",i]]:o;l.push(...X({key:`${a}.${i}.map`,value:s,expressionContext:"cluster-map"})),l.push(...X({key:`${a}.${i}.reduce`,value:h,expressionContext:"cluster-reduce"}))}}return l;case"video":return ec({key:a,value:r,valueSpec:n.source_video,style:o,styleSpec:n});case"image":return ec({key:a,value:r,valueSpec:n.source_image,style:o,styleSpec:n});case"canvas":return[new e.V(a,null,"Please use runtime APIs to add canvas sources, rather than including them in stylesheets.","source.canvas")];default:var h;return Y({key:`${a}.type`,value:r.type,valueSpec:{values:(h=n).source.reduce((e,i)=>{let r=h[i];return"enum"===r.type.type&&(e=e.concat(Object.keys(r.type.values))),e},[])}})}}function en(i){let r=i.value,a=i.styleSpec,n=a.light,o=i.style;if(void 0===r)return[];if(!e.H(r))return[new e.V("light",r,`object expected, ${e.K(r)} found`)];let s=[];for(let i in r){let l=i.match(/^(.*)-transition$/),h=i.match(/^(.*)-use-theme$/);s=s.concat(h&&n[h[1]]?eu({key:i,value:r[i],valueSpec:{type:"string"},style:o,styleSpec:a}):l&&n[l[1]]&&n[l[1]].transition?eu({key:i,value:r[i],valueSpec:a.transition,style:o,styleSpec:a}):n[i]?eu({key:i,value:r[i],valueSpec:n[i],style:o,styleSpec:a}):[new e.V(i,r[i],`unknown property "${i}"`)])}return s}function eo(i){let r=i.value;if(!r)return[];let a=i.key;if(!e.H(r))return[new e.V(a,r,`object expected, ${e.K(r)} found`)];let n=[],o=i.styleSpec,s=o["light-3d"],l=i.style,h=i.style.lights;for(let i of["type","id"])if(!(i in r))return n.concat([new e.V(a,r,`missing property "${i}"`)]);if(!e.a0(r.type))return n.concat([new e.V(`${a}.type`,r.type,"string expected")]);if(h)for(let o=0;o<i.arrayIndex;o++){let i=e.J(r.type),s=h[o];e.J(s.type)===i&&n.push(new e.V(a,r.id,`duplicate light type "${r.type}", previously defined at line ${s.id.__line__}`))}let u=`properties_light_${r.type}`;if(!(u in o))return n.concat([new e.V(`${a}.type`,r,`Invalid light type ${r.type}`)]);let c=o[u];for(let a in r)if("properties"===a){let s=r[a];if(!e.H(s))return n.concat([new e.V("properties",s,`object expected, ${e.K(s)} found`)]);for(let h in s){let u=h.match(/^(.*)-transition$/),d=h.match(/^(.*)-use-theme$/);n=n.concat(d&&c[d[1]]?eu({key:a,value:s[h],valueSpec:{type:"string"},style:l,styleSpec:o}):u&&c[u[1]]&&c[u[1]].transition?eu({key:a,value:r[a],valueSpec:o.transition,style:l,styleSpec:o}):c[h]?eu({key:h,value:s[h],valueSpec:c[h],style:l,styleSpec:o}):[new e.a3(i.key,s[h],`unknown property "${h}"`)])}}else n=n.concat(s[a]?eu({key:a,value:r[a],valueSpec:s[a],style:l,styleSpec:o}):[new e.a3(a,r[a],`unknown property "${a}"`)]);return n}function es(i){let r=i.value,a=i.key,n=i.style,o=i.styleSpec,s=o.terrain;if(null==r)return[];if(!e.H(r))return[new e.V("terrain",r,`object expected, ${e.K(r)} found`)];let l=[];for(let i in r){let a=i.match(/^(.*)-transition$/),h=i.match(/^(.*)-use-theme$/);l=l.concat(h&&s[h[1]]?eu({key:i,value:r[i],valueSpec:{type:"string"},style:n,styleSpec:o}):a&&s[a[1]]&&s[a[1]].transition?eu({key:i,value:r[i],valueSpec:o.transition,style:n,styleSpec:o}):s[i]?eu({key:i,value:r[i],valueSpec:s[i],style:n,styleSpec:o}):[new e.a3(i,r[i],`unknown property "${i}"`)])}if(r.source)if(e.a0(r.source)){let i=n.sources&&n.sources[r.source],o=i&&e.J(i.type);i?"raster-dem"!==o&&l.push(new e.V(`${a}.source`,r.source,`terrain cannot be used with a source of type ${o}, it only be used with a "raster-dem" source type`)):l.push(new e.V(`${a}.source`,r.source,`source "${r.source}" not found`))}else l.push(new e.V(`${a}.source`,r.source,"source must be a string"));else l.push(new e.V(a,r,'terrain is missing required property "source"'));return l}function el(i){let r=i.value,a=i.style,n=i.styleSpec,o=n.fog;if(void 0===r)return[];if(!e.H(r))return[new e.V("fog",r,`object expected, ${e.K(r)} found`)];let s=[];for(let i in r){let l=i.match(/^(.*)-transition$/),h=i.match(/^(.*)-use-theme$/);s=s.concat(h&&o[h[1]]?eu({key:i,value:r[i],valueSpec:{type:"string"},style:a,styleSpec:n}):l&&o[l[1]]&&o[l[1]].transition?eu({key:i,value:r[i],valueSpec:n.transition,style:a,styleSpec:n}):o[i]?eu({key:i,value:r[i],valueSpec:o[i],style:a,styleSpec:n}):[new e.a3(i,r[i],`unknown property "${i}"`)])}return s}let eh={"*":()=>[],array:H,boolean:function(i){let r=i.value,a=i.key;return e.$(r)?[]:[new e.V(a,r,`boolean expected, ${e.K(r)} found`)]},number:Z,color:function({key:i,value:r}){return e.a0(r)?null===e.a1.parseCSSColor(r)?[new e.V(i,r,`color expected, "${r}" found`)]:[]:[new e.V(i,r,`color expected, ${e.K(r)} found`)]},enum:Y,filter:K,function:W,layer:et,object:ec,source:ea,model:e.a7,light:en,"light-3d":eo,terrain:e
8s,fog:el,string:ei,formatted:function(e){return 0===ei(e).length?[]:X(e)},resolvedImage:function(e){return 0===ei(e).length?[]:X(e)},projection:function(i){let r=i.value,a=i.styleSpec,n=a.projection,o=i.style;if(e.H(r)){let e=[];for(let i in r)e=e.concat(eu({key:i,value:r[i],valueSpec:n[i],style:o,styleSpec:a}));return e}return e.a0(r)?[]:[new e.V("projection",r,`object or string expected, ${e.K(r)} found`)]},import:function(i){let r=i.key,{value:a,styleSpec:n}=i;if(!e.H(a))return[new e.V(r,a,"import must be an object")];let{data:o,...s}=a;Object.defineProperty(s,"__line__",{value:a.__line__,enumerable:!1});let l=ec(Object.assign({},i,{value:s,valueSpec:n.import}));return""===e.J(s.id)&&l.push(new e.V(`${i.key}.id`,s,"import id can't be an empty string")),o&&(l=l.concat(ep(o,n,{key:`${i.key}.data`}))),l},iconset:function(i){let r=i.value,a=i.key,n=i.styleSpec,o=i.style;if(!e.H(r))return[new e.V(a,r,"object expected")];if(!r.type)return[new e.V(a,r,'"type" is required')];let s=e.J(r.type),l=[];if(l=l.concat(ec({key:a,value:r,valueSpec:n[`iconset_${s}`],style:o,styleSpec:n})),!("source"!==s||!r.source)){let i=o.sources&&o.sources[r.source],n=i&&e.J(i.type);i?"raster-array"!==n&&l.push(new e.V(a,r.source,`iconset cannot be used with a source of type ${String(n)}, it only be used with a "raster-array" source type`)):l.push(new e.V(a,r.source,`source "${r.source}" not found`))}return l}};function eu(i,r=!1){let a=i.value,n=i.valueSpec,o=i.styleSpec;if(n.expression){if(e.a4(e.J(a)))return W(i);if(e.Q(e.S(a)))return X(i)}if(n.type&&eh[n.type]){let e=eh[n.type](i);return!0===r&&e.length>0&&Array.isArray(i.value)?X(i):e}return ec(Object.assign({},i,{valueSpec:n.type?o[n.type]:n}))}function ec(i){let r=i.key,a=i.value,n=i.valueSpec||{},o=i.objectElementValidators||{},s=i.style,l=i.styleSpec;if(!e.H(a))return[new e.V(r,a,`object expected, ${e.K(a)} found`)];let h=[];for(let i in a){let u,c=i.split(".")[0];o[c]?u=o[c]:n[c]?u=eu:o["*"]?u=o["*"]:n["*"]&&(u=eu),u?h=h.concat(u({key:(r?`${r}.`:r)+i,value:a[i],valueSpec:n[c]||n["*"],style:s,styleSpec:l,object:a,objectKey:i},a)):h.push(new e.a3(r,a[i],`unknown property "${i}"`))}for(let i in n)o[i]||n[i].required&&void 0===n[i].default&&void 0===a[i]&&h.push(new e.V(r,a,`missing required property "${i}"`));return h}function ed({key:i,value:r}
8){let a=ei({key:i,value:r});return a.length||(-1===r.indexOf("{fontstack}")&&a.push(new e.V(i,r,'"glyphs" url must include a "{fontstack}" token')),-1===r.indexOf("{range}")&&a.push(new e.V(i,r,'"glyphs" url must include a "{range}" token'))),a}function ep(i,r=e.a6,a={}){return ec({key:a.key||"",value:i,valueSpec:Object.assign(r.$root,{"*":{type:"*"}}),styleSpec:r,style:i,objectElementValidators:{glyphs:ed}})}function ef(i,r=e.a6){return eA(ep(i,r))}let em=e=>eA(ea(e)),e_=e=>eA(en(e)),eg=e=>eA(eo(e)),ey=e=>eA(es(e)),ex=e=>eA(el(e)),ev=i=>eA(function(i){let r=i.value,a=i.style,n=i.styleSpec,o=n.snow;if(void 0===r)return[];if(!e.H(r))return[new e.V("snow",r,`object expected, ${e.K(r)} found`)];let s=[];for(let i in r){let l=i.match(/^(.*)-transition$/);s=s.concat(l&&o[l[1]]&&o[l[1]].transition?eu({key:i,value:r[i],valueSpec:n.transition,style:a,styleSpec:n}):o[i]?eu({key:i,value:r[i],valueSpec:o[i],style:a,styleSpec:n}):[new e.a3(i,r[i],`unknown property "${i}"`)])}return s}(i)),eb=i=>eA(function(i){let r=i.value,a=i.style,n=i.styleSpec,o=n.rain;if(void 0===r)return[];if(!e.H(r))return[new e.V("rain",r,`object expected, ${e.K(r)} found`)];let s=[];for(let i in r){let l=i.match(/^(.*)-transition$/);s=s.concat(l&&o[l[1]]&&o[l[1]].transition?eu({key:i,value:r[i],valueSpec:n.transition,style:a,styleSpec:n}):o[i]?eu({key:i,value:r[i],valueSpec:o[i],style:a,styleSpec:n}):[new e.a3(i,r[i],`unknown property "${i}"`)])}return s}(i)),ew=e=>eA(et(e)),eT=e=>eA(K(e)),eS=e=>eA(Q(e)),eE=e=>eA(ee(e)),eI=i=>eA(e.a7(i));function eA(e){return e.slice().sort((e,i)=>e.line&&i.line?e.line-i.line:0)}function eC(i,r){let a=!1;if(r&&r.length)for(let n of r)n instanceof e.a3?e.w(n.message):(i.fire(new e.y(Error(n.message))),a=!0);return a}class eM extends e.E{constructor(i,a="flat"){super(),this._transitionable=new e.a8(r||(r=new e.a9({anchor:new e.aa(e.a6.light.anchor),position:new e.ab(e.a6.light.position),color:new e.aa(e.a6.light.color),intensity:new e.aa(e.a6.light.intensity)}))),this.setLight(i,a),this._transitioning=this._transitionable.untransitioned()}getLight(){return this._transitionable.serialize()}setLight(e,i,r={}){this._validate(e_,e,r)||(this._transitionable.setTransitionOrValue(e),this.id=i)}updateTransitions(e){this._transitioning=this._transitionable.transitioned(e,this._transitioning)}hasTransition(){return this._transitioning.hasTransition()}recalculate(e){this.properties=this._transitioning.possiblyEvaluate(e)}_validate(i,r,a){return(!a||!1!==a.validate)&&eC(this,i.call(ef,Object.assign({value:r,style:{glyphs:!0,sprite:!0},styleSpec:e.a6})))}}let eP=class extends e.E{constructor(i,r,a,n,o){super(),this.scope=a,this._transitionable=new e.a8(new e.a9({source:new e.aa(e.a6.terrain.source),exaggeration:new e.aa(e.a6.terrain.exaggeration)}),a,n),this._transitionable.setTransitionOrValue(i,n),this._transitioning=this._transitionable.untransitioned(),this.drapeRenderMode=r,this.worldview=o}get(){return this._transitionable.serialize()}set(e,i){this._transitionable.setTransitionOrValue(e,i)}updateTransitions(e){this._transitioning=this._transitionable.transitioned(e,this._transitioning)}hasTransition(){return this._transitioning.hasTransition()}recalculate(e){this.properties=this._transitioning.possiblyEvaluate(e)}getExaggeration(i){return this._transitioning.possiblyEvaluate(new e.ac(i,{worldview:this.worldview})).get("exaggeration")}getAttenuationRange(){if(!this.isZoomDependent())return null;let i=this._transitionable._values.exaggeration;if(!i)return null;let r=i.value.expression;if(!r)return null;let a=-1,n=-1,o=1;for(let i of r.zoomStops)(o=r.evaluate(new e.ac(i,{worldview:this.worldview})))>.01?(a=i,n=-1):n=i;return o<.01&&a>0&&n>a?[a,n]:null}isZoomDependent(){let i=this._transitionable._values.exaggeration;return null!=i&&null!=i.value&&null!=i.value.expression&&i.value.expression instanceof e.ad}};function ez(i,r,a,n){let o=e.ah(45,65,a),[s,l]=eR(i,n),h=1-Math.min(1,Math.exp(-((r-s)/(l-s)*6)));return h*=h*h,(h=Math.min(1,1.00747*h))*o*i.alpha}function eR(e,i){let r=.5/Math.tan(.5*i);return[e.range[0]+r,e.range[1]+r]}function eD(i,r,a,n,o){let s=e.af([],[r,a,n],o.mercatorFogMatrix);return ez(i,e.ag(s),o.pitch,o._fov)}function eL(i,r,a,n,o,s,l){let h=Number.MAX_VALUE,u=-Number.MAX_VALUE;for(let i of[[a,n,0],[o,n,0],[o,s,0],[a,s,0]]){let a=e.af([],i,r),n=e.ag(a);h=Math.min(h,n),u=Math.max(u,n)}return[ez(i,h,l.pitch,l._fov),ez(i,u,l.pitch,l._fov)]}class eO extends e.E{constructor(i,r,a,n){super();let o=new e.a9({range:new e.aa(e.a6.fog.range),color:new e.aa(e.a6.fog.color),"color-use-theme":new e.aa({type:"string","property-type":"data-constant",default:"default"}),"high-color":new e.aa(e.a6.fog["high-color"]),"high-color-use-theme":new e.aa({type:"string","property-type":"data-constant",default:"default"}),"space-color":new e.aa(e.a6.fog["space-color"]),"space-color-use-theme":new e.aa({type:"string","property-type":"data-constant",default:"default"}
8),"horizon-blend":new e.aa(e.a6.fog["horizon-blend"]),"star-intensity":new e.aa(e.a6.fog["star-intensity"]),"vertical-range":new e.aa(e.a6.fog["vertical-range"])});this._transitionable=new e.a8(o,a,new Map(n)),this.set(i,n),this._transitioning=this._transitionable.untransitioned(),this._transform=r,this.properties=new e.ai(o),this.scope=a}get state(){let i=this._transform,r="globe"===i.projection.name,a=e.aj(i.zoom),n=this.properties.get("range");return{range:r?[e.ak(.5,n[0],a),e.ak(3,n[1],a)]:n,horizonBlend:this.properties.get("horizon-blend"),alpha:this.properties.get("color").a}}get(){return this._transitionable.serialize()}set(i,r,a={}){if(this._validate(ex,i,a))return;let n=Object.assign({},i);for(let i of Object.keys(e.a6.fog))void 0===n[i]&&(n[i]=e.a6.fog[i].default);this._options=n,this._transitionable.setTransitionOrValue(this._options,r)}getOpacity(i){if(!this._transform.projection.supportsFog)return 0;let r=this.properties&&this.properties.get("color")||1;return("globe"===this._transform.projection.name?1:e.ah(45,65,i))*r.a}getOpacityAtLatLng(i,r){return this._transform.projection.supportsFog?function(i,r,a){let n=e.ae.fromLngLat(r),o=a.elevation?a.elevation.getAtPointOrZero(n):0;return eD(i,n.x,n.y,o,a)}(this.state,i,r):0}getOpacityForTile(i){if(!this._transform.projection.supportsFog)return[1,1];let r=this._transform.calculateFogTileMatrix(i.toUnwrapped());return eL(this.state,r,0,0,e.al,e.al,this._transform)}getOpacityForBounds(e,i,r,a,n){return this._transform.projection.supportsFog?eL(this.state,e,i,r,a,n,this._transform):[1,1]}getFovAdjustedRange(e){return this._transform.projection.supportsFog?eR(this.state,e):[0,1]}isVisibleOnFrustum(i){if(!this._transform.projection.supportsFog)return!1;for(let r of[4,5,6,7]){let a,n=i.points[r];if(n[2]>=0)a=n;else{let o=i.points[r-4];a=e.am(o,n,o[2]/(o[2]-n[2]))}if(eD(this.state,a[0],a[1],0,this._transform)>=.05)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(i,r,a){return(!a||!1!==a.validate)&&eC(this,i.call(ef,Object.assign({value:r,style:{glyphs:!0,sprite:!0},styleSpec:e.a6})))}}let eF,ek,eB,eN,eV=class extends e.E{constructor(i,r,a,n){super();let o=eF||(eF=new e.a9({density:new e.aa(e.a6.snow.density),intensity:new e.aa(e.a6.snow.intensity),color:new e.aa(e.a6.snow.color),opacity:new e.aa(e.a6.snow.opacity),vignette:new e.aa(e.a6.snow.vignette),"vignette-color":new e.aa(e.a6.snow["vignette-color"]),"center-thinning":new e.aa(e.a6.snow["center-thinning"]),direction:new e.aa(e.a6.snow.direction),"flake-size":new e.aa(e.a6.snow["flake-size"])}));this._transitionable=new e.a8(o,a,new Map(n)),this.set(i,n),this._transitioning=this._transitionable.untransitioned(),this.properties=new e.ai(o),this.scope=a}get state(){let i=this.properties.get("opacity"),r=this.properties.get("color"),a=this.properties.get("direction"),n=e.an(a[0]),o=-Math.max(e.an(a[1]),.01),s=[Math.cos(n)*Math.cos(o),Math.sin(n)*Math.cos(o),Math.sin(o)],l=this.properties.get("vignette"),h=this.properties.get("vignette-color");return h.a=l,{density:this.properties.get("density"),intensity:this.properties.get("intensity"),color:new e.ao(r.r,r.g,r.b,r.a*i),direction:s,centerThinning:this.properties.get("center-thinning"),flakeSize:this.properties.get("flake-size"),vignetteColor:h}}get(){return this._transitionable.serialize()}set(i,r,a={}){if(this._validate(ev,i,a))return;let n=Object.assign({},i);for(let i of Object.keys(e.a6.snow))void 0===n[i]&&(n[i]=e.a6.snow[i].default);this._options=n,this._transitionable.setTransitionOrValue(this._options,r)}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)}
8_validate(i,r,a){return(!a||!1!==a.validate)&&eC(this,i.call(ef,Object.assign({value:r,style:{glyphs:!0,sprite:!0},styleSpec:e.a6})))}},eU=class extends e.E{constructor(i,r,a,n){super();let o=ek||(ek=new e.a9({density:new e.aa(e.a6.rain.density),intensity:new e.aa(e.a6.rain.intensity),color:new e.aa(e.a6.rain.color),opacity:new e.aa(e.a6.rain.opacity),vignette:new e.aa(e.a6.rain.vignette),"vignette-color":new e.aa(e.a6.rain["vignette-color"]),"center-thinning":new e.aa(e.a6.rain["center-thinning"]),direction:new e.aa(e.a6.rain.direction),"droplet-size":new e.aa(e.a6.rain["droplet-size"]),"distortion-strength":new e.aa(e.a6.rain["distortion-strength"])}));this._transitionable=new e.a8(o,a,new Map(n)),this.set(i,n),this._transitioning=this._transitionable.untransitioned(),this.properties=new e.ai(o),this.scope=a}get state(){let i=this.properties.get("opacity"),r=this.properties.get("color"),a=this.properties.get("direction"),n=e.an(a[0]),o=-Math.max(e.an(a[1]),.01),s=[Math.cos(n)*Math.cos(o),Math.sin(n)*Math.cos(o),Math.sin(o)],l=this.properties.get("vignette-color");return l.a=this.properties.get("vignette"),{density:this.properties.get("density"),intensity:this.properties.get("intensity"),color:new e.ao(r.r,r.g,r.b,r.a*i),direction:s,centerThinning:this.properties.get("center-thinning"),dropletSize:this.properties.get("droplet-size"),distortionStrength:this.properties.get("distortion-strength"),vignetteColor:l}}get(){return this._transitionable.serialize()}set(i,r,a={}){if(this._validate(eb,i,a))return;let n=Object.assign({},i);for(let i of Object.keys(e.a6.rain))void 0===n[i]&&(n[i]=e.a6.rain[i].default);this._options=n,this._transitionable.setTransitionOrValue(this._options,r)}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(i,r,a){return(!a||!1!==a.validate)&&eC(this,i.call(ef,Object.assign({value:r,style:{glyphs:!0,sprite:!0},styleSpec:e.a6})))}};class ej extends e.E{constructor(i,r,a,n){super(),this.scope=a,this._options=i,this.properties=new e.ai(r),this._transitionable=new e.a8(r,a,new Map(n)),this._transitionable.setTransitionOrValue(i.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,i){this._options=e,this._transitionable.setTransitionOrValue(e.properties,i)}shadowsEnabled(){return!!this.properties&&!0===this.properties.get("cast-shadows")}}class eG{constructor(e,i,r){this.screenBounds=e,this.cameraPoint=r.getCameraPoint(),this._screenRaycastCache={},this._cameraRaycastCache={},this.isAboveHorizon=i,this.screenGeometry=this.bufferedScreenGeometry(0),this.screenGeometryMercator=this._bufferedScreenMercator(0,r)}static createFromScreenPoints(i,r){let a,n;if(i instanceof e.P||"number"==typeof i[0]){let o=e.P.convert(i);a=[o],n=r.isPointAboveHorizon(o)}else{let o=e.P.convert(i[0]),s=e.P.convert(i[1]),l=o.add(s)._div(2);a=[o,s],n=e.aq(o,s).every(e=>r.isPointAboveHorizon(e))&&r.isPointAboveHorizon(l)}return new eG(a,n,r)}isPointQuery(){return 1===this.screenBounds.length}bufferedScreenGeometry(i){return e.aq(this.screenBounds[0],1===this.screenBounds.length?this.screenBounds[0]:this.screenBounds[1],i)}bufferedCameraGeometry(i){let r=this.screenBounds[0],a=1===this.screenBounds.length?this.screenBounds[0].add(new e.P(1,1)):this.screenBounds[1],n=e.aq(r,a,0,!1);return this.cameraPoint.y>a.y&&(this.cameraPoint.x>r.x&&this.cameraPoint.x<a.x?n.splice(3,0,this.cameraPoint):this.cameraPoint.x>=a.x?n[2]=this.cameraPoint:this.cameraPoint.x<=r.x&&(n[3]=this.cameraPoint)),e.ar(n,i)}bufferedCameraGeometryGlobe(i){let r=this.screenBounds[0],a=1===this.screenBounds.length?this.screenBounds[0].add(new e.P(1,1)):this.screenBounds[1],n=e.aq(r,a,i),o=this.cameraPoint.clone();switch(3*((o.y>r.y)+(o.y>a.y))+((o.x>r.x)+(o.x>a.x))){case 0:n[0]=o,n[4]=o.clone();break;case 1:n.splice(1,0,o);break;case 2:n[1]=o;break;case 3:n.splice(4,0,o);break;case 5:n.splice(2,0,o);break;case 6:n[3]=o;break;case 7:n.splice(3,0,o);break;case 8:n[2]=o}return n}containsTile(i,r,a,n=0){var o;let s=i.queryPadding/r._pixelsPerMercatorPixel+1,l=a?this._bufferedCameraMercator(s,r):this._bufferedScreenMercator(s,r),h=i.tileID.wrap+(l.unwrapped?n:0),u=l.polygon.map(r=>e.as(i.tileTransform,r,h));if(!e.at(u,0,0,e.al,e.al))return;h=i.tileID.wrap+(this.screenGeometryMercator.unwrapped?n:0);let c=this.screenGeometryMercator.polygon.map(r=>e.au(i.tileTransform,r,h)),d=c.map(i=>new e.P(i[0],i[1])),p=r.getFreeCameraOptions().position||new e.ae(0,0,0),f=e.au(i.tileTransform,p,h),m=c.map(i=>{let r=e.av(i,i,f);return e.aw(r,r),new e.ax(f,r)}),_=e.ay(i,1,r.zoom)*r._pixelsPerMercatorPixel;return{queryGeometry:this,tilespaceGeometry:d,tilespaceRays:m,bufferedTilespaceGeometry:u,bufferedTilespaceBounds:((o=e.az(u)).min.x=e.aA(o.min.x,0,e.al),o.min.y=e.aA(o.min.y,0,e.al),o.max.x=e.aA(o.max.x,0,e.al),o.max.y=e.aA(o.max.y,0,e.al),o),tile:i,tileID:i.tileID,pixelToTileUnitsFactor:_}}_bufferedScreenMercator(e,i){let r=100*e|0;if(this._screenRaycastCache[r])return this._screenRaycastCache[r];{let a;return a="globe"===i.projection.name?this._projectAndResample(this.bufferedScreenGeometry(e),i):{polygon:this.bufferedScreenGeometry(e).map(e=>i.pointCoordinate3D(e)),unwrapped:!0},this._screenRaycastCache[r]=a,a}}_bufferedCameraMercator(e,i){let r=100*e|0;if(this._cameraRaycastCache[r])return this._cameraRaycastCache[r];{let a;return a="globe"===i.projection.name?this._projectAndResample(this.bufferedCameraGeometryGlobe(e),i):{polygon:this.bufferedCameraGeometry(e).map(e=>i.pointCoordinate3D(e)),unwrapped:!0},this._cameraRaycastCache[r]=a,a}}_projectAndResample(i,r){let a=function(i,r){let a=e.aB([],r.pixelMatrix,r.globeMatrix),n=[0,-e.aD,0,1],o=[0,e.aD,0,1],s=[0,0,0,1];e.aC(n,n,a),e.aC(o,o,a),e.aC(s,s,a);let l=new e.P(n[0]/n[3],n[1]/n[3]),h=new e.P(o[0]/o[3],o[1]/o[3]),u=e.aE(i,l)&&n[3]<s[3],c=e.aE(i,h)&&o[3]<s[3];if(!u&&!c)return null;let d=function(e,i,r){for(let a=1;a<e.length;a++){let n=e$(i.pointCoordinate3D(e[a-1]).x),o=e$(i.pointCoordinate3D(e[a]).x);
8if(r<0){if(n<o)return{idx:a,t:-n/(o-1-n)}}else if(o<n)return{idx:a,t:(1-n)/(o+1-n)}}return null}(i,r,u?-1:1);if(!d)return null;let{idx:p,t:f}=d,m=p>1?eq(i.slice(0,p),r):[],_=p<i.length?eq(i.slice(p),r):[];m=m.map(i=>new e.P(e$(i.x),i.y)),_=_.map(i=>new e.P(e$(i.x),i.y));let g=[...m];0===g.length&&g.push(_[_.length-1]);let y=e.ak(g[g.length-1].y,(0===_.length?m[0]:_[0]).y,f);return g.push(...u?[new e.P(0,y),new e.P(0,0),new e.P(1,0),new e.P(1,y)]:[new e.P(1,y),new e.P(1,1),new e.P(0,1),new e.P(0,y)]),0===_.length?g.push(m[0]):g.push(..._),{polygon:g.map(i=>new e.ae(i.x,i.y)),unwrapped:!1}}(i,r);if(a)return a;let n=function(i,r){let a=!1,n=-1/0,o=0;for(let e=0;e<i.length-1;e++)i[e].x>n&&(n=i[e].x,o=e);for(let e=0;e<i.length-1;e++){let r=(o+e)%(i.length-1),n=i[r],s=i[r+1];Math.abs(n.x-s.x)>.5&&(n.x<s.x?(n.x+=1,0===r&&(i[i.length-1].x+=1)):(s.x+=1,r+1===i.length-1&&(i[0].x+=1)),a=!0)}let s=e.aF(r.center.lng);return a&&s<Math.abs(s-1)&&i.forEach(e=>{e.x-=1}),{polygon:i,unwrapped:a}}(eq(i,r).map(i=>new e.P(e$(i.x),i.y)),r);return{polygon:n.polygon.map(i=>new e.ae(i.x,i.y)),unwrapped:n.unwrapped}}}function eq(i,r){return e.aG(i,e=>{let i=r.pointCoordinate3D(e);e.x=i.x,e.y=i.y},1/256)}function e$(e){return e<0?1+e%1:e%1}function eH(i,r,a,n,o){let s=function(a,n){if(a)return o(a);if(n){if(i.url&&n.tiles&&i.tiles&&delete i.tiles,n.variants){if(!Array.isArray(n.variants))return o(Error("variants must be an array"));for(let e of n.variants){if(null==e||"object"!=typeof e||e.constructor!==Object)return o(Error("variant must be an object"));if(!Array.isArray(e.capabilities))return o(Error("capabilities must be an array"));if(1===e.capabilities.length&&"meshopt"===e.capabilities[0]){n=Object.assign(n,e);break}}}let a=e.aH(Object.assign({},n,i),["tilejson","tiles","minzoom","maxzoom","attribution","mapbox_logo","bounds","extra_bounds","scheme","tileSize","encoding","vector_layers","raster_layers","worldview_options","worldview_default","worldview"]);a.tiles=r.canonicalizeTileset(a,i.url),o(null,a)}},l=function(e,i,r){if(!e)return null;if(!i&&!r)return e;r=r||e.worldview_default;let a=Object.values(e.language||{});if(0===a.length)return null;let n=Object.values(e.worldview||{});if(0===n.length)return null;let o=a.every(e=>e===i),s=n.every(e=>e===r);return o&&s?e:i in(e.language_options||{})||r in(e.worldview_options||{})?null:e.language_options&&e.worldview_options?e:null}(i.data,a,n);return l?e.o.frame(()=>s(null,l)):i.url?e.m(r.transformRequest(r.normalizeSourceURL(i.url,null,a,n),e.R.Source),s):e.o.frame(()=>{let{data:e,...r}=i;s(null,r)})}function eZ(i,r){let a=Math.pow(2,r.z),n=Math.floor(e.aF(i.getWest())*a),o=Math.floor(e.aJ(i.getNorth())*a),s=Math.ceil(e.aF(i.getEast())*a),l=Math.ceil(e.aJ(i.getSouth())*a);return r.x>=n&&r.x<s&&r.y>=o&&r.y<l}class eW{constructor(i,r,a){this.bounds=i?e.aI.convert(this.validateBounds(i)):null,this.minzoom=r||0,this.maxzoom=a||24}
8validateBounds(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(i){if(i)for(let r of(this.extraBounds||(this.extraBounds=[]),i))this.extraBounds.push(e.aI.convert(this.validateBounds(r)))}contains(e){if(e.z>this.maxzoom||e.z<this.minzoom||this.bounds&&!eZ(this.bounds,e))return!1;if(!this.extraBounds)return!0;for(let i of this.extraBounds)if(eZ(i,e))return!0;return!1}static fromTileJSON(e){if(!e.bounds&&!e.extra_bounds)return null;let i=new eW(e.bounds,e.minzoom,e.maxzoom);return i.addExtraBounds(e.extra_bounds),i}}class eX extends e.E{constructor(i,r,a,n){if(super(),this.id=i,this.dispatcher=a,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,e.aH(r,["url","scheme","tileSize","promoteId"])),this._options=Object.assign({type:"vector"},r),this._collectResourceTiming=!!r.collectResourceTiming,512!==this.tileSize)throw Error("vector tile sources must have a tileSize of 512");this.setEventedParent(n),this._tileWorkers={},this._deduped=new e.aK}load(i){this._loaded=!1,this.fire(new e.z("dataloading",{dataType:"source"}));let r=Array.isArray(this.map._language)?this.map._language.join():this.map._language,a=this.map.getWorldview();this._tileJSONRequest=eH(this._options,this.map._requestManager,r,a,(n,o)=>{if(this._tileJSONRequest=null,this._loaded=!0,n)r&&console.warn(`Ensure that your requested language string is a valid BCP-47 code or list of codes. Found: ${r}`),a&&console.warn(`Requested worldview strings must be a valid ISO alpha-2 code. Found: ${a}`),this.fire(new e.y(n));else if(o){if(Object.assign(this,o),this.hasWorldviews=!!o.worldview_options,o.worldview_default&&(this.worldviewDefault=o.worldview_default),o.vector_layers)for(let e of(this.vectorLayers=o.vector_layers,this.vectorLayerIds=[],this.localizableLayerIds=new Set,o.vector_layers))this.vectorLayerIds.push(e.id),o.worldview&&o.worldview[e.source]&&this.localizableLayerIds.add(e.id);this.tileBounds=eW.fromTileJSON(o),D(o.tiles,this.map._requestManager._customAccessToken),this.fire(new e.z("data",{dataType:"source",sourceDataType:"metadata"})),this.fire(new e.z("data",{dataType:"source",sourceDataType:"content"}))}i&&i(n)})}loaded(){return this._loaded}hasTile(e){return!this.tileBounds||this.tileBounds.contains(e.canonical)}onAdd(e){this.map=e,this.load()}reload(){this.cancelTileJSONRequest();let i=e.B(this.id,this.scope);this.load(()=>this.map.style.clearSource(i))}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(i,r){let a=i.tileID.canonical.url(this.tiles,this.scheme),n=this.map._requestManager.normalizeTileURL(a),o=this.map._requestManager.transformRequest(n,e.R.Tile),s=this.map.style?this.map.style.getLut(this.scope):null,l=s?{image:s.image.clone()}:null,h={request:o,data:void 0,uid:i.uid,tileID:i.tileID,tileZoom:i.tileZoom,zoom:i.tileID.overscaledZ,maxZoom:this.maxzoom,lut:l,tileSize:this.tileSize*i.tileID.overscaleFactor(),type:this.t
8ype,source:this.id,scope:this.scope,pixelRatio:e.o.devicePixelRatio,showCollisionBoxes:this.map.showCollisionBoxes,promoteId:this.promoteId,isSymbolTile:i.isSymbolTile,brightness:this.map.style&&this.map.style.getBrightness()||0,extraShadowCaster:i.isExtraShadowCaster,tessellationStep:this.map._tessellationStep,scaleFactor:this.map.getScaleFactor(),worldview:this.map.getWorldview()||this.worldviewDefault};if(this.hasWorldviews&&e.h(a)&&(h.localizableLayerIds=this.localizableLayerIds),h.request.collectResourceTiming=this._collectResourceTiming,i.actor&&"expired"!==i.state)"loading"===i.state?i.reloadCallback=r:i.request=i.actor.send("reloadTile",h,u.bind(this));else if(i.actor=this._tileWorkers[n]=this._tileWorkers[n]||this.dispatcher.getActor(),this.dispatcher.ready)i.request=i.actor.send("loadTile",h,u.bind(this),void 0,!0);else{let r=e.aL.call({deduped:this._deduped},h,(e,r)=>{e||!r?u.call(this,e):(h.data={cacheControl:r.cacheControl,expires:r.expires,rawData:r.rawData.slice(0)},i.actor&&i.actor.send("loadTile",h,u.bind(this),void 0,!0))},!0);i.request={cancel:r}}function u(a,n){return delete i.request,i.aborted?r(null):a&&404!==a.status?r(a):(n&&n.resourceTiming&&(i.resourceTiming=n.resourceTiming),this.map._refreshExpiredTiles&&n&&i.setExpiryData(n),i.loadVectorData(n,this.map.painter),e.aM(this.dispatcher),r(null),void(i.reloadCallback&&(this.loadTile(i,i.reloadCallback),i.reloadCallback=null)))}}abortTile(e){e.request&&(e.request.cancel(),delete e.request),e.actor&&e.actor.send("abortTile",{uid:e.uid,type:this.t
8ype,source:this.id,scope:this.scope})}unloadTile(e,i){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 eY extends e.E{constructor(i,r,a,n){super(),this.id=i,this.dispatcher=a,this.setEventedParent(n),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"},r),Object.assign(this,e.aH(r,["url","scheme","tileSize"]))}load(i){this._loaded=!1,this.fire(new e.z("dataloading",{dataType:"source"}));let r=this.map.getWorldview();this._tileJSONRequest=eH(this._options,this.map._requestManager,null,r,(r,a)=>{this._tileJSONRequest=null,this._loaded=!0,r?this.fire(new e.y(r)):a&&(Object.assign(this,a),a.raster_layers&&(this.rasterLayers=a.raster_layers,this.rasterLayerIds=this.rasterLayers.map(e=>e.id)),this.tileBounds=eW.fromTileJSON(a),D(a.tiles),this.fire(new e.z("data",{dataType:"source",sourceDataType:"metadata"})),this.fire(new e.z("data",{dataType:"source",sourceDataType:"content"}))),i&&i(r)})}loaded(){return this._loaded}onAdd(e){this.map=e,this.load()}reload(){this.cancelTileJSONRequest();let i=e.B(this.id,this.scope);this.load(()=>this.map.style.clearSource(i))}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(i,r){let a=e.o.devicePixelRatio>=2,n=this.map._requestManager.normalizeTileURL(i.tileID.canonical.url(this.tiles,this.scheme),a,this.tileSize);i.request=e.n(this.map._requestManager.transformRequest(n,e.R.Tile),(a,n,o,s)=>(delete i.request,i.aborted?(i.state="unloaded",r(null)):a?(i.state="errored",r(a)):n?(this.map._refreshExpiredTiles&&i.setExpiryData({cacheControl:o,expires:s}),i.setTexture(n,this.map.painter),i.state="loaded",e.aM(this.dispatcher),void r(null)):r(null)))}abortTile(e,i){e.request&&(e.request.cancel(),delete e.request),i&&i()}unloadTile(i,r){i.texture&&i.texture instanceof e.T?(i.destroy(!0),i.texture&&i.texture instanceof e.T&&this.map.painter.saveTileTexture(i.texture)):i.destroy(),r&&r()}hasTransition(){return!1}cancelTileJSONRequest(){this._tileJSONRequest&&(this._tileJSONRequest.cancel(),this._tileJSONRequest=null)}}class eK extends eY{constructor(e,i,r,a){super(e,i,r,a),this.type="raster-array",this.maxzoom=22,this.partial=!0,this._loadTilePending={},this._loadTileLoaded={},this._options=Object.assign({type:"raster-array"},i)}triggerRepaint(e){let i=this.map.painter._terrain,r=this.map.style.getSourceCache(this.id);i&&i.enabled&&r&&i._clearRenderCacheForTile(r.id,e.tileID),this.map.triggerRepaint()}loadTile(i,r){let a=this.map._requestManager.normalizeTileURL(i.tileID.canonical.url(this.tiles,this.scheme),!1,this.tileSize),n=this.map._requestManager.transformRequest(a,e.R.Tile),o={request:n,uid:i.uid,tileID:i.tileID,type:this.t
8ype,source:this.id,scope:this.scope,partial:this.partial};i.source=this.id,i.scope=this.scope,i.requestParams=n,i.actor||(i.actor=this.dispatcher.getActor());let s=(e,a,n,o)=>{if(delete i.request,i.aborted)return i.state="unloaded",r(null);if(e){if("AbortError"===e.name)return;return i.state="errored",r(e)}if(this.map._refreshExpiredTiles&&a&&i.setExpiryData({cacheControl:n,expires:o}),this.partial&&"expired"!==i.state)i.state="empty";else if(!this.partial){if(!a)return r(null);i.state="loaded",i._isHeaderLoaded=!0,i._mrt=a}r(null)};i.request=this.partial?i.fetchHeader(void 0,s.bind(this)):i.actor.send("loadTile",o,s.bind(this),void 0,!0)}abortTile(e){e.request&&(e.request.cancel(),delete e.request),e.actor&&e.actor.send("abortTile",{uid:e.uid,type:this.type,source:this.id,scope:this.scope})}unloadTile(e,i){let r=e.texturePerLayer;if(e.flushAllQueues(),r.size)for(let i of(e.destroy(!0),r.values()))this.map.painter.saveTileTexture(i);else e.destroy()}prepareTile(i,r,a,n){i._isHeaderLoaded&&("empty"!==i.state&&(i.state="reloading"),i.fetchBandForRender(r,a,n,(r,n)=>{if(r)return i.state="errored",this.fire(new e.y(r)),void this.triggerRepaint(i);n&&(i._isHeaderLoaded=!0,i.setTexturePerLayer(a,n,this.map.painter),i.state="loaded",this.triggerRepaint(i))}))}getInitialBand(e){if(!this.rasterLayers)return 0;let i=this.rasterLayers.find(({id:i})=>i===e),r=i&&i.fields,a=r&&r.bands&&r.bands;return a?a[0]:0}getTextureDescriptor(i,r,a){if(!i)return;let n=r.sourceLayer||this.rasterLayerIds&&this.rasterLayerIds[0];if(!n)return;let o=null;r instanceof e.aP?o=r.paint.get("raster-array-band"):r instanceof e.aQ&&(o=r.paint.get("raster-particle-array-band"));let s=o||this.getInitialBand(n);return null==s?void 0:i.textureDescriptorPerLayer.get(r.id)?!i.updateNeeded(r.id,s)||a?Object.assign({},i.textureDescriptorPerLayer.get(r.id),{texture:i.texturePerLayer.get(r.id)}):void 0:void this.prepareTile(i,n,r.id,s)}getImages(i,r){let a=new Map;for(let n of i)for(let i of r){let[r,o]=i.split("/"),s=n.getLayer(r);if(!s||!s.hasBand(o)||!s.hasDataForBand(o))continue;let{bytes:l,tileSize:h,buffer:u}=s.getBandView(o),c=h+2*u,d={data:new e.q({width:c,height:c},l),pixelRatio:2,sdf:!1,usvg:!1,version:0};a.set(i,d)}return a}queryRasterArrayValueByBandId(i,r,a){let n=r._mrt;return new Promise(o=>{let s={},l=new Set;for(let[h,u]of Object.entries(n.layers)){if(a.layerName&&h!==a.layerName)continue;let c={};for(let{bands:d}of(s[h]=c,u.dataIndex))for(let p of d)a.bands&&!a.bands.includes(p)||(l.add(e.B(h,p)),r.fetchBand(h,null,p,r=>{e.o.frame(()=>{c[p]=r?null:function([i,r],a,n,{scaled:o=!0}={}){let{tileSize:s,buffer:l}=n,{x:h,y:u,z:c}=a;if(!isFinite(h)||!isFinite(u)||!isFinite(c))throw Error("Invalid MRT header");let d=2**c;return function([e,i],r,{scaled:a=!0}={}){if(!r)throw Error("bandView is undefined");let{data:n,tileSize:o,buffer:s,offset:l,scale:h,dimension:u}=r;if(e<-s||e>o+s||i<-s||i>o+s)throw Error(`Point (${e}, ${i}) out of bounds for tileSize=${o}, buffer=${s}`);let c=(i+s)*(o+2*s)+(e+s);if(0xffffffff===new Uint32Array(n.buffer)[c])return null;let d=[];d=a?[]:new(0,r.data.constructor)(u);for(let e=0;e<u;e++)d[e]=Math.round(1e12*(n[u*c+e]*h+l))/1e12;return d}([Math.min(Math.max(-l,Math.floor((d*e.aF(i)-h)*s)),s-1+l),Math.min(Math.max(-l,Math.floor((d*e.aJ(r)-u)*s)),s-1+l)],n,{scaled:o})}([i.lng,i.lat],n,u.getBandView(p)),l.delete(e.B(h,p)),0===l.size&&o(s)})},!1))}0===l.size&&o(s)})}_loadTileForQuery(i,r){if(this._loadTileLoaded[i.uid])return void r(null,i._mrt);if(this._loadTilePending[i.uid])return void this._loadTilePending[i.uid].push(r);this._loadTilePending[i.uid]=[r];let a=this.map._requestManager.normalizeTileURL(i.tileID.canonical.url(this.tiles,this.scheme),!1,this.tileSize),n=this.map._requestManager.transformRequest(a,e.R.Tile);i.actor.send("loadTile",{request:n,uid:i.uid,tileID:i.tileID,type:this.t
8ype,source:this.id,scope:this.scope,partial:!1},(e,r,a,n)=>(e?this._loadTilePending[i.uid].forEach(i=>i(e,null)):r?(this.map._refreshExpiredTiles&&r&&i.setExpiryData({cacheControl:a,expires:n}),i._mrt=r,i._isHeaderLoaded=!0,i.state="loaded",this._loadTilePending[i.uid].forEach(e=>e(null,r)),this._loadTileLoaded[i.uid]=!0):this._loadTilePending[i.uid].forEach(e=>e(null,null)),void delete this._loadTilePending[i.uid]),void 0,!0)}queryRasterArrayValueByAllBands(e,i,r){return new Promise((a,n)=>{this._loadTileForQuery(i,(o,s)=>{o?n(o):a(s?this.queryRasterArrayValueByBandId(e,i,r):null)})})}queryRasterArrayValue(i,r){let a=e.aR.convert(i),n=this.findLoadedParent(a);return n&&n._mrt?r.bands||!this.partial?this.queryRasterArrayValueByBandId(a,n,r):this.queryRasterArrayValueByAllBands(a,n,r):Promise.resolve(null)}findLoadedParent(i){let r=e.ae.fromLngLat(i,this.map.transform.tileSize),a=this.maxzoom+1,n=1<<a,o=Math.floor(r.x),s=Math.floor((r.x-o)*n),l=Math.floor(r.y*n),h=this.map.style.getSourceCache(this.id),u=new e.aO(a,o,a,s,l);return h.findLoadedParent(u,this.minzoom)}}let eJ={vector:eX,raster:eY,"raster-dem":class extends eY{constructor(e,i,r,a){super(e,i,r,a),this.type="raster-dem",this.maxzoom=22,this._options=Object.assign({type:"raster-dem"},i),this.encoding=i.encoding||"mapbox"}loadTile(i,r){let a=this.map._requestManager.normalizeTileURL(i.tileID.canonical.url(this.tiles,this.scheme),!1,this.tileSize);function n(e,a){e&&(i.state="errored",r(e)),a&&(i.dem=a,i.dem.onDeserialize(),i.needsHillshadePrepare=!0,i.needsDEMTextureUpload=!0,i.state="loaded",r(null))}i.request=e.n(this.map._requestManager.transformRequest(a,e.R.Tile),(function(a,o,s,l){if(delete i.request,i.aborted)i.state="unloaded",r(null);else if(a)i.state="errored",r(a);else if(o){this.map._refreshExpiredTiles&&i.setExpiryData({cacheControl:s,expires:l});let r=ImageBitmap&&o instanceof ImageBitmap&&e.r(),a=1-(o.width-e.aN(o.width))/2;a<1||i.neighboringTiles||(i.neighboringTiles=this._getNeighboringTiles(i.tileID));let h=r?o:e.o.getImageData(o,a),u={uid:i.uid,tileID:i.tileID,source:this.id,type:this.t
8ype,scope:this.scope,rawImageData:h,encoding:this.encoding,padding:a};i.actor&&"expired"!==i.state||(i.actor=this.dispatcher.getActor(),i.actor.send("loadTile",u,n.bind(this),void 0,!0))}}).bind(this))}_getNeighboringTiles(i){let r=i.canonical,a=Math.pow(2,r.z),n=(r.x-1+a)%a,o=0===r.x?i.wrap-1:i.wrap,s=(r.x+1+a)%a,l=r.x+1===a?i.wrap+1:i.wrap,h={};return h[new e.aO(i.overscaledZ,o,r.z,n,r.y).key]={backfilled:!1},h[new e.aO(i.overscaledZ,l,r.z,s,r.y).key]={backfilled:!1},r.y>0&&(h[new e.aO(i.overscaledZ,o,r.z,n,r.y-1).key]={backfilled:!1},h[new e.aO(i.overscaledZ,i.wrap,r.z,r.x,r.y-1).key]={backfilled:!1},h[new e.aO(i.overscaledZ,l,r.z,s,r.y-1).key]={backfilled:!1}),r.y+1<a&&(h[new e.aO(i.overscaledZ,o,r.z,n,r.y+1).key]={backfilled:!1},h[new e.aO(i.overscaledZ,i.wrap,r.z,r.x,r.y+1).key]={backfilled:!1},h[new e.aO(i.overscaledZ,l,r.z,s,r.y+1).key]={backfilled:!1}),h}},"raster-array":eK,geojson:class extends e.E{constructor(i,r,a,n){super(),this.id=i,this.type="geojson",this.minzoom=0,this.maxzoom=18,this.tileSize=512,this.isTileClipped=!0,this.reparseOverscaled=!0,this._loaded=!1,this.actor=a.getActor(),this.setEventedParent(n),this._data=r.data,this._options=Object.assign({},r),this._collectResourceTiming=r.collectResourceTiming,void 0!==r.maxzoom&&(this.maxzoom=r.maxzoom),void 0!==r.minzoom&&(this.minzoom=r.minzoom),r.type&&(this.type=r.type),r.attribution&&(this.attribution=r.attribution),this.promoteId=r.promoteId;let o=e.al/this.tileSize;this.workerOptions=Object.assign({source:this.id,scope:this.scope,cluster:r.cluster||!1,geojsonVtOptions:{buffer:(void 0!==r.buffer?r.buffer:128)*o,tolerance:(void 0!==r.tolerance?r.tolerance:.375)*o,extent:e.al,maxZoom:this.maxzoom,lineMetrics:r.lineMetrics||!1,generateId:r.generateId||!1},superclusterOptions:{maxZoom:void 0!==r.clusterMaxZoom?r.clusterMaxZoom:this.maxzoom-1,minPoints:Math.max(2,r.clusterMinPoints||2),extent:e.al,radius:(void 0!==r.clusterRadius?r.clusterRadius:50)*o,log:!1,generateId:r.generateId||!1},clusterProperties:r.clusterProperties,filter:r.filter,dynamic:r.dynamic},r.workerOptions)}onAdd(e){this.map=e,this.setData(this._data)}setData(e){return this._data=e,this._updateWorkerData(),this}updateData(i){if(!this._options.dynamic)return this.fire(new e.y(Error("Can't call updateData on a GeoJSON source with dynamic set to false.")));if("string"!=typeof i&&("Feature"===i.type&&(i={type:"FeatureCollection",features:[i]}),"FeatureCollection"!==i.type))return this.fire(new e.y(Error("Data to update should be a feature or a feature collection.")));if(this._coalesce&&"string"!=typeof i&&"string"!=typeof this._data&&"FeatureCollection"===this._data.type){let e=new Map;for(let i of this._data.features)e.set(i.id,i);for(let r of i.features)e.set(r.id,r);this._data.features=[...e.values()]}else this._data=i;return this._updateWorkerData(!0),this}getClusterExpansionZoom(e,i){return this.actor.send("geojson.getClusterExpansionZoom",{clusterId:e,source:this.id,scope:this.scope},i),this}getClusterChildren(e,i){return this.actor.send("geojson.getClusterChildren",{clusterId:e,source:this.id,scope:this.scope},i),this}getClusterLeaves(e,i,r,a){return this.actor.send("geojson.getClusterLeaves",{source:this.id,scope:this.scope,clusterId:e,limit:i,offset:r},a),this}_updateWorkerData(i=!1){if(this._pendingLoad)return void(this._coalesce=!0);this.fire(new e.z("dataloading",{dataType:"source"})),this._loaded=!1;let r=Object.assign({append:i},this.workerOptions);r.scope=this.scope;let a=this._data;"string"==typeof a?(r.request=this.map._requestManager.transformRequest(e.o.resolveURL(a),e.R.Source),r.request.collectResourceTiming=this._collectResourceTiming):r.data=JSON.stringify(a),this._pendingLoad=this.actor.send(`${this.type}.loadData`,r,(r,a)=>{if(this._loaded=!0,this._pendingLoad=null,r)this.fire(new e.y(r));else{let r={dataType:"source",sourceDataType:this._metadataFired?"content":"metadata"};this._collectResourceTiming&&a&&a.resourceTiming&&a.resourceTiming[this.id]&&(r.resourceTiming=a.resourceTiming[this.id]),i&&(this._partialReload=!0),this.fire(new e.z("data",r)),this._partialReload=!1,this._metadataFired=!0}this._coalesce&&(this._updateWorkerData(i),this._coalesce=!1)})}loaded(){return this._loaded}reload(){let i=e.B(this.id,this.scope);this.map.style.clearSource(i),this._updateWorkerData()}loadTile(i,r){let a=i.actor?"reloadTile":"loadTile";i.actor=this.actor;let n=this.map.style?this.map.style.getLut(this.scope):null,o=n?{image:n.image.clone()}
8:null,s=this._partialReload,l={type:this.type,uid:i.uid,tileID:i.tileID,tileZoom:i.tileZoom,zoom:i.tileID.overscaledZ,maxZoom:this.maxzoom,tileSize:this.tileSize,source:this.id,lut:o,scope:this.scope,pixelRatio:e.o.devicePixelRatio,showCollisionBoxes:this.map.showCollisionBoxes,promoteId:this.promoteId,brightness:this.map.style&&this.map.style.getBrightness()||0,extraShadowCaster:i.isExtraShadowCaster,scaleFactor:this.map.getScaleFactor(),partial:s,worldview:this.map.getWorldview()};i.request=this.actor.send(a,l,(e,n)=>s&&!n?(i.state="loaded",r(null)):(delete i.request,i.destroy(),i.aborted?r(null):e?r(e):(i.loadVectorData(n,this.map.painter,"reloadTile"===a),r(null))),void 0,"loadTile"===a)}abortTile(e){e.request&&(e.request.cancel(),delete e.request),e.aborted=!0}unloadTile(e,i){this.actor.send("removeTile",{uid:e.uid,type:this.type,source:this.id,scope:this.scope}),e.destroy()}onRemove(e){this._pendingLoad&&this._pendingLoad.cancel()}serialize(){return Object.assign({},this._options,{type:this.type,data:this._data})}hasTransition(){return!1}},video:class extends e.aS{constructor(e,i,r,a){super(e,i,r,a),this.roundZoom=!0,this.type="video",this.options=i}load(){this._loaded=!1;let i=this.options;for(let r of(this.urls=[],i.urls))this.urls.push(this.map._requestManager.transformRequest(r,e.R.Source).url);e.aT(this.urls,(i,r)=>{this._loaded=!0,i?this.fire(new e.y(i)):r&&(this.video=r,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(i){if(this.video){let r=this.video.seekable;i<r.start(0)||i>r.end(0)?this.fire(new e.y(new e.V(`sources.${this.id}`,null,`Playback for this video can be set only between the ${r.start(0)} and ${r.end(0)}-second mark.`))):this.video.currentTime=i}}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;let i=this.map.painter.context,r=i.gl;this.texture?this.video.paused||(this.texture.bind(r.LINEAR,r.CLAMP_TO_EDGE),r.texSubImage2D(r.TEXTURE_2D,0,0,0,r.RGBA,r.UNSIGNED_BYTE,this.video)):(this.texture=new e.T(i,this.video,r.RGBA8),this.texture.bind(r.LINEAR,r.CLAMP_TO_EDGE),this.width=this.video.videoWidth,this.height=this.video.videoHeight),this._prepareData(i)}serialize(){return{type:"video",urls:this.urls,coordinates:this.coordinates}}hasTransition(){return this.video&&!this.video.paused}},image:e.aS,model:class extends e.E{constructor(e,i,r,a){super(),this.id=e,this.type="model",this.models=[],this._loaded=!1,this._options=i}load(){let i=[];for(let r in this._options.models){let a=this._options.models[r],n=e.aV(this.map._requestManager.transformRequest(a.uri,e.R.Model).url).then(i=>{if(!i)return;let n=e.aW(i),o=new e.aX(r,a.position,a.orientation,n);o.computeBoundsAndApplyParent(),this.models.push(o)}).catch(i=>{this.fire(new e.y(Error(`Could not load model ${r} from ${a.uri}: ${i.message}`)))});i.push(n)}Promise.allSettled(i).then(()=>{this._loaded=!0,this.fire(new e.z("data",{dataType:"source",sourceDataType:"metadata"}))}).catch(i=>{this._loaded=!0,this.fire(new e.y(Error(`Could not load models: ${i.message}`)))})}onAdd(e){this.map=e,this.load()}hasTransition(){return!1}loaded(){return this._loaded}getModels(){return this.models}loadTile(e,i){}serialize(){return this._options}},"batched-model":class extends e.E{constructor(e,i,r,a){super(),this.type="batched-model",this.id=e,this.tileSize=512,this._options=i,this.tiles=this._options.tiles,this.maxzoom=i.maxzoom||19,this.minzoom=i.minzoom||0,this.roundZoom=!0,this.usedInConflation=!0,this.dispatcher=r,this.reparseOverscaled=!1,this.scheme="xyz",this._loaded=!1,this.setEventedParent(a)}onAdd(e){this.map=e,this.load()}reload(){this.cancelTileJSONRequest();let i=e.B(this.id,this.scope);this.load(()=>this.map.style.clearSource(i))}cancelTileJSONRequest(){this._tileJSONRequest&&(this._tileJSONRequest.cancel(),this._tileJSONRequest=null)}load(i){this._loaded=!1,this.fire(new e.z("dataloading",{dataType:"source"}));let r=Array.isArray(this.map._language)?this.map._language.join():this.map._language,a=this.map.getWorldview();this._tileJSONRequest=eH(this._options,this.map._requestManager,r,a,(n,o)=>{this._tileJSONRequest=null,this._loaded=!0,n?(r&&console.warn(`Ensure that your requested language string is a valid BCP-47 code or list of codes. Found: ${r}`),a&&2!==a.length&&console.warn(`Requested worldview strings must be a valid ISO alpha-2 code. Found: ${a}`),this.fire(new e.y(n))):o&&(Object.assign(this,o),o.bounds&&(this.tileBounds=new eW(o.bounds,this.minzoom,this.maxzoom)),D(o.tiles,this.map._requestManager._customAccessToken),this.fire(new e.z("data",{dataType:"source",sourceDataType:"metadata"})),this.fire(new e.z("data",{dataType:"source",sourceDataType:"content"}))),i&&i(n)})}hasTransition(){return!1}hasTile(e){return!this.tileBounds||this.tileBounds.contains(e.canonical)}loaded(){return this._loaded}loadTile(i,r){let a=this.map._requestManager.normalizeTileURL(i.tileID.canonical.url(this.tiles,this.scheme)),n={request:this.map._requestManager.transformRequest(a,e.R.Tile),data:void 0,uid:i.uid,tileID:i.tileID,tileZoom:i.tileZoom,zoom:i.tileID.overscaledZ,tileSize:this.tileSize*i.tileID.overscaleFactor(),type:this.t
8ype,source:this.id,scope:this.scope,showCollisionBoxes:this.map.showCollisionBoxes,isSymbolTile:i.isSymbolTile,brightness:this.map.style&&this.map.style.getBrightness()||0,pixelRatio:e.o.devicePixelRatio,promoteId:this.promoteId};if(i.actor&&"expired"!==i.state)if("loading"===i.state)i.reloadCallback=r;else{if(i.buckets){for(let e of Object.values(i.buckets))e.dirty=!0;return void(i.state="loaded")}i.request=i.actor.send("reloadTile",n,o.bind(this))}else i.actor=this.dispatcher.getActor(),i.request=i.actor.send("loadTile",n,o.bind(this),void 0,!0);function o(e,a){return i.aborted?r(null):e&&404!==e.status?r(e):(this.map._refreshExpiredTiles&&a&&i.setExpiryData(a),i.loadModelData(a,this.map.painter),i.state="loaded",void r(null))}}serialize(){return Object.assign({},this._options)}},canvas:class extends e.aS{constructor(i,r,a,n){super(i,r,a,n),r.coordinates?Array.isArray(r.coordinates)&&4===r.coordinates.length&&!r.coordinates.some(e=>!Array.isArray(e)||2!==e.length||e.some(e=>"number"!=typeof e))||this.fire(new e.y(new e.V(`sources.${i}`,null,'"coordinates" property must be an array of 4 longitude/latitude array pairs'))):this.fire(new e.y(new e.V(`sources.${i}`,null,'missing required property "coordinates"'))),r.animate&&"boolean"!=typeof r.animate&&this.fire(new e.y(new e.V(`sources.${i}`,null,'optional "animate" property must be a boolean value'))),r.canvas?"string"==typeof r.canvas||r.canvas instanceof HTMLCanvasElement||this.fire(new e.y(new e.V(`sources.${i}`,null,'"canvas" must be either a string representing the ID of the canvas element from which to read, or an HTMLCanvasElement instance'))):this.fire(new e.y(new e.V(`sources.${i}`,null,'missing required property "canvas"'))),this.options=r,this.animate=void 0===r.animate||r.animate}load(){this._loaded=!0,this.canvas||(this.canvas=this.options.canvas instanceof HTMLCanvasElement?this.options.canvas:document.getElementById(this.options.canvas)),this.width=this.canvas.width,this.height=this.canvas.height,this._hasInvalidDimensions()?this.fire(new e.y(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 i=!1;if(this.canvas.width!==this.width&&(this.width=this.canvas.width,i=!0),this.canvas.height!==this.height&&(this.height=this.canvas.height,i=!0),this._hasInvalidDimensions()||0===Object.keys(this.tiles).length)return;let r=this.map.painter.context;this.texture?!i&&!this._playing||this.texture instanceof e.aU||this.texture.update(this.canvas,{premultiply:!0}):this.texture=new e.T(r,this.canvas,r.gl.RGBA8,{premultiply:!0}),this._prepareData(r)}serialize(){return{type:"canvas",coordinates:this.coordinates}}hasTransition(){return this._playing}_hasInvalidDimensions(){for(let e of[this.canvas.width,this.canvas.height])if(isNaN(e)||e<=0)return!0;return!1}},custom:class extends e.E{constructor(i,r,a,n){super(),this.id=i,this.type="custom",this._dataType="raster",this._dispatcher=a,this._implementation=r,this.setEventedParent(n),this.scheme="xyz",this.minzoom=0,this.maxzoom=22,this.tileSize=512,this._loaded=!1,this.roundZoom=!0,this._implementation||this.fire(new e.y(Error(`Missing implementation for ${this.id} custom source`))),this._implementation.loadTile||this.fire(new e.y(Error(`Missing loadTile implementation for ${this.id} custom source`))),this._implementation.bounds&&(this.tileBounds=new eW(this._implementation.bounds,this.minzoom,this.maxzoom)),r.update=this._update.bind(this),r.clearTiles=this._clearTiles.bind(this),r.coveringTiles=this._coveringTiles.bind(this),Object.assign(this,e.aH(r,["dataType","scheme","minzoom","maxzoom","tileSize","attribution","minTileCacheSize","maxTileCacheSize"]))}serialize(){return e.aH(this,["type","scheme","minzoom","maxzoom","tileSize","attribution"])}load(){this._loaded=!0,this.fire(new e.z("data",{dataType:"source",sourceDataType:"metadata"})),this.fire(new e.z("data",{dataType:"source",sourceDataType:"content"}))}loaded(){return this._loaded}onAdd(i){this.map=i,this._loaded=!1,this.fire(new e.z("dataloading",{dataType:"source"})),this._implementation.onAdd&&this._implementation.onAdd(i),this.load()}onRemove(e){this._implementation.onRemove&&this._implementation.onRemove(e)}hasTile(e){if(this._implementation.hasTile){let{x:i,y:r,z:a}=e.canonical;return this._implementation.hasTile({x:i,y:r,z:a})}return!this.tileBounds||this.tileBounds.contains(e.canonical)}loadTile(e,i){let{x:r,y:a,z:n}=e.tileID.canonical,o=new AbortController;e.request=Promise.resolve(this._implementation.loadTile({x:r,y:a,z:n},{signal:o.signal})).then((function(r){return delete e.request,e.aborted?(e.state="unloaded",i(null)):void 0===r?(e.state="errored",i(null)):null===r?(this.loadTileData(e,{width:this.tileSize,height:this.tileSize,data:null}),e.state="loaded",i(null)):r instanceof ImageData||r instanceof HTMLCanvasElement||r instanceof ImageBitmap||r instanceof HTMLImageElement?(this.loadTileData(e,r),e.state="loaded",void i(null)):(e.state="errored",i(Error(`Can't infer data type for ${this.id}, only raster data supported at the moment`)))}).bind(this)).catch(r=>{"AbortError"!==r.name&&(e.state="errored",i(r))}),e.request.cancel=()=>o.abort()}loadTileData(e,i){e.setTexture(i,this.map.painter)}unloadTile(i,r){if(i.texture&&i.texture instanceof e.T?(i.destroy(!0),i.texture&&i.texture instanceof e.T&&this.map.painter.saveTileTexture(i.texture)):i.destroy(),this._implementation.unloadTile){let{x:e,y:r,z:a}=i.tileID.canonical;this._implementation.unloadTile({x:e,y:r,z:a})}r&&r()}abortTile(e,i){e.request&&e.request.cancel&&(e.request.cancel(),delete e.request),i&&i()}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(){let i=e.B(this.id,this.scope);this.map.style.clearSource(i)}
8_update(){this.fire(new e.z("data",{dataType:"source",sourceDataType:"content"}))}}},eQ=function(i,r,a,n){let o=new eJ[r.type](i,r,a,n);if(o.id!==i)throw Error(`Expected Source id to be ${i} instead of ${o.id}`);return e.aY(["load","abort","unload","serialize","prepare"],o),o};function e0(e,i,r=""){return`${r}:${i.id||""}:${i.layer.id}:${function(e){if("layerId"in e)return`layer:${e.layerId}`;{let{featuresetId:i,importId:r}=e;return`featureset:${i}${r?`:import:${r}`:""}`}}(e.target)}`}function e1(e,i,r,a=""){if(e.uniqueFeatureID){let n=e0(e,i,a);if(r.has(n))return!0;r.add(n)}return!1}function e2(e,i){let r=e.tileID,a=i.tileID;return r.overscaledZ-a.overscaledZ||r.canonical.y-a.canonical.y||r.wrap-a.wrap||r.canonical.x-a.canonical.x}function e3(e,i){let r={};if(!i)return r;for(let a of e){let e=a.layerIds.map(e=>i.getLayer(e)).filter(Boolean);if(0!==e.length)for(let i of(a.layers=e,a.stateDependentLayerIds&&(a.stateDependentLayers=a.stateDependentLayerIds.map(i=>e.filter(e=>e.id===i)[0])),e))r[i.fqid]=a}return r}let e5=new Uint16Array(8184);for(let e=0;e<2046;e++){let i=e+2,r=0,a=0,n=0,o=0,s=0,l=0;for(1&i?n=o=s=32:r=a=l=32;(i>>=1)>1;){let e=r+n>>1,h=a+o>>1;1&i?(n=r,o=a,r=s,a=l):(r=n,a=o,n=s,o=l),s=e,l=h}let h=4*e;e5[h+0]=r,e5[h+1]=a,e5[h+2]=n,e5[h+3]=o}let e4=new Uint16Array(2178),e6=new Uint8Array(1089),e8=new Uint16Array(1089);function e9(e){return 0===e?-.03125:.03125*(32===e)}let e7={type:2,extent:e.al,loadGeometry:()=>[[new e.P(0,0),new e.P(e.al+1,0),new e.P(e.al+1,e.al+1),new e.P(0,e.al+1),new e.P(0,0)]]};class te{constructor(i,r,a,n,o,s){this.tileID=i,this.uid=e.b2(),this.uses=0,this.tileSize=r,this.tileZoom=a,this.buckets={},this.expirationTime=null,this.queryPadding=0,this.hasSymbolBuckets=!1,this.hasRTLText=!1,this.dependencies={},this.isRaster=o,n&&n.style&&(this._lastUpdatedBrightness=n.style.getBrightness()),this.expiredRequestCount=0,this.state="loading",n&&n.transform&&(this.projection=n.transform.projection),this.worldview=s}registerFadeDuration(i){let r=i+this.timeAdded;r<e.o.now()||this.fadeEndTime&&r<this.fadeEndTime||(this.fadeEndTime=r)}wasRequested(){return"errored"===this.state||"loaded"===this.state||"reloading"===this.state}get tileTransform(){return this._tileTransform||(this._tileTransform=e.aZ(this.tileID.canonical,this.projection)),this._tileTransform}loadVectorData(i,r,a){if(this.unloadVectorData(),this.state="loaded",i){for(let n in i.featureIndex&&(this.latestFeatureIndex=i.featureIndex,i.rawTileData?(this.latestRawTileData=i.rawTileData,this.latestFeatureIndex.rawTileData=i.rawTileData):this.latestRawTileData&&(this.latestFeatureIndex.rawTileData=this.latestRawTileData)),this.collisionBoxArray=i.collisionBoxArray,this.buckets=e3(i.buckets,r.style),this.hasSymbolBuckets=!1,this.buckets){let i=this.buckets[n];if(i instanceof e.b4){if(this.hasSymbolBuckets=!0,!a)break;i.justReloaded=!0}}if(this.hasRTLText=!1,this.hasSymbolBuckets)for(let i in this.buckets){let r=this.buckets[i];if(r instanceof e.b4&&r.hasRTLText){this.hasRTLText=!0,e.b5();break}}for(let e in this.queryPadding=0,this.buckets){let i=this.buckets[e],a=r.style.getOwnLayer(e);if(!a)continue;let n=a.queryRadius(i);this.queryPadding=Math.max(this.queryPadding,n)}i.imageAtlas&&(this.imageAtlas=i.imageAtlas),i.glyphAtlasImage&&(this.glyphAtlasImage=i.glyphAtlasImage),i.lineAtlas&&(this.lineAtlas=i.lineAtlas),this._lastUpdatedBrightness=i.brightness}else this.collisionBoxArray=new e.b3}unloadVectorData(){if(this.hasData()){for(let e in this.buckets)this.buckets[e].destroy();this.buckets={},this.imageAtlas&&(this.imageAtlas=null),this.lineAtlas&&(this.lineAtlas=null),this.imageAtlasTexture&&this.imageAtlasTexture.destroy(),this.glyphAtlasTexture&&this.glyphAtlasTexture.destroy(),this.lineAtlasTexture&&this.lineAtlasTexture.destroy(),this._tileBoundsBuffer&&(this._tileBoundsBuffer.destroy(),this._tileBoundsIndexBuffer.destroy(),this._tileBoundsSegments.destroy(),this._tileBoundsBuffer=null),this._tileDebugBuffer&&(this._tileDebugBuffer.destroy(),this._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,i,r){e&&(e.resourceTiming&&(this.resourceTiming=e.resourceTiming),this.buckets=Object.assign({},this.buckets,e3(e.buckets,i.style)),e.featureIndex&&(this.latestFeatureIndex=e.featureIndex))}getBucket(e){return this.buckets[e.fqid]}upload(i){for(let e in this.buckets){let r=this.buckets[e];r.uploadPending()&&r.upload(i)}let r=i.gl,a=this.imageAtlas;a&&!a.uploaded&&(this.imageAtlasTexture=new e.T(i,a.image,r.RGBA8,{useMipmap:!!a.patternPositions.size}),this.imageAtlas.uploaded=!0),this.glyphAtlasImage&&(this.glyphAtlasTexture=new e.T(i,this.glyphAtlasImage,r.R8),this.glyphAtlasImage=null),this.lineAtlas&&!this.lineAtlas.uploaded&&(this.lineAtlasTexture=new e.T(i,this.lineAtlas.image,r.R8),this.lineAtlas.uploaded=!0)}prepare(e,i,r){if(this.imageAtlas&&this.imageAtlasTexture&&this.imageAtlas.patchUpdatedImages(e,this.imageAtlasTexture,r),!i||!this.latestFeatureIndex||!this.latestFeatureIndex.rawTileData)return;let a=i.style.getBrightness();(this._lastUpdatedBrightness||a)&&(this._lastUpdatedBrightness&&a&&.001>Math.abs(this._lastUpdatedBrightness-a)||(this.updateBuckets(i,this._lastUpdatedBrightness!==a),this._lastUpdatedBrightness=a))}
8queryRenderedFeatures(i,r,a,n,o,s){if(!this.latestFeatureIndex||!this.latestFeatureIndex.rawTileData&&!this.latestFeatureIndex.is3DTile)return{};let l=function(i,r){let a=e.bq([],[.5*i.width,-(.5*i.height),1]);return e.br(a,a,[1,-1,0]),e.aB(a,a,i.calculateProjMatrix(r.toUnwrapped())),Float32Array.from(a)}(o,this.tileID);return this.latestFeatureIndex.query(i,{tilespaceGeometry:r,pixelPosMatrix:l,transform:n,availableImages:a,tileTransform:this.tileTransform,worldview:this.worldview})}querySourceFeatures(i,r){let a=this.latestFeatureIndex;if(!a||!a.rawTileData)return;let n=a.loadVTLayers(),o=r?r.sourceLayer:"",s=n._geojsonTileLayer||n[o];if(!s)return;let l=e.b6(r&&r.filter),{z:h,x:u,y:c}=this.tileID.canonical,d={z:h,x:u,y:c};for(let r=0;r<s.length;r++){let n=s.feature(r);if(l.needGeometry){let i=e.b7(n,!0);if(!l.filter(new e.ac(this.tileID.overscaledZ,{worldview:this.worldview}),i,this.tileID.canonical))continue}else if(!l.filter(new e.ac(this.tileID.overscaledZ,{worldview:this.worldview}),n))continue;let p=a.getId(n,o),f=new e.b8(n,h,u,c,p);f.tile=d,i.push(f)}}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(i){let r=this.expirationTime;if(i.cacheControl){let r=e.b9(i.cacheControl);r["max-age"]&&(this.expirationTime=Date.now()+1e3*r["max-age"])}else i.expires&&(this.expirationTime=new Date(i.expires).getTime());if(this.expirationTime){let e=Date.now(),i=!1;if(this.expirationTime>e)i=!1;else if(r)if(this.expirationTime<r)i=!0;else{let a=this.expirationTime-r;a?this.expirationTime=e+Math.max(a,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(),0x7fffffff)}refreshFeatureState(e){this.latestFeatureIndex&&(this.latestFeatureIndex.rawTileData||this.latestFeatureIndex.is3DTile)&&e&&this.updateBuckets(e)}updateBuckets(i,r){if(!this.latestFeatureIndex||!i.style)return;let a=this.latestFeatureIndex.loadVTLayers(),n=i.style.listImages(),o=i.style.getBrightness();for(let s in this.buckets){if(!i.style.hasLayer(s))continue;let l=this.buckets[s],h=l.layers[0],u=h.sourceLayer||"_geojsonTileLayer",c=a[u],d=i.style.getLayerSourceCache(h),p={};d&&(p=d._state.getState(u,void 0));let f=this.imageAtlas?Object.fromEntries(this.imageAtlas.patternPositions):{},m=Object.keys(p).length>0&&!r;(m&&0!==l.stateDependentLayers.length||r)&&l.update(p,c,n,f,m?l.stateDependentLayers:l.layers,r,o),(l instanceof e.ba||l instanceof e.bb)&&i._terrain&&i._terrain.enabled&&d&&l.uploadPending()&&i._terrain._clearRenderCacheForTile(d.id,this.tileID);let _=i&&i.style&&i.style.getOwnLayer(s);_&&(this.queryPadding=Math.max(this.queryPadding,_.queryRadius(l)))}}holdingForFade(){return void 0!==this.symbolFadeHoldUntil}symbolFadeFinished(){return!this.symbolFadeHoldUntil||this.symbolFadeHoldUntil<e.o.now()}clearFadeHold(){this.symbolFadeHoldUntil=void 0}setHoldDuration(i){this.symbolFadeHoldUntil=e.o.now()+i}setTexture(i,r){let a=r.context,n=a.gl;this.texture=this.texture||r.getTileTexture(i.width),this.texture&&this.texture instanceof e.T?this.texture.update(i):(this.texture=new e.T(a,i,n.RGBA8,{useMipmap:!0}),this.texture.bind(n.LINEAR,n.CLAMP_TO_EDGE))}setDependencies(e,i){let r={};for(let e of i)r[e]=!0;this.dependencies[e]=r}hasDependency(e,i){for(let r of e){let e=this.dependencies[r];if(e){for(let r of i)if(e[r])return!0}}return!1}clearQueryDebugViz(){}_makeDebugTileBoundsBuffers(i,r){if(!r||"mercator"===r.name||this._tileDebugBuffer)return;let a=e.bc(e7,this.tileID.canonical,this.tileTransform)[0],n=new e.bd,o=new e.be;for(let e=0;e<a.length;e++){let{x:i,y:r}=a[e];n.emplaceBack(i,r),o.emplaceBack(e)}o.emplaceBack(0),this._tileDebugIndexBuffer=i.createIndexBuffer(o),this._tileDebugBuffer=i.createVertexBuffer(n,e.bf.members),this._tileDebugSegments=e.bg.simpleSegment(0,0,n.length,o.length)}_makeTileBoundsBuffers(i,r){let a,n;if(this._tileBoundsBuffer||!r||"mercator"===r.name)return;let o=e.bc(e7,this.tileID.canonical,this.tileTransform)[0];if(this.isRaster){let i=function(i,r){let a=e.aZ(i,r),n=Math.pow(2,i.z);for(let o=0;o<33;o++)for(let s=0;s<33;s++){let l=e.a_((i.x+(s+e9(s))/32)/n),h=e.a$((i.y+(o+e9(o))/32)/n),u=r.project(l,h),c=33*o+s;e4[2*c+0]=Math.round((u.x*a.scale-a.x)*e.al),e4[2*c+1]=Math.round((u.y*a.scale-a.y)*e.al)}e6.fill(0),e8.fill(0);for(let e=2045;e>=0;e--){let i=4*e,r=e5[i+0],a=e5[i+1],n=e5[i+2],o=e5[i+3],s=r+n>>1,l=a+o>>
81,h=s+l-a,u=l+r-s,c=33*a+r,d=33*o+n,p=33*l+s,f=Math.hypot((e4[2*c+0]+e4[2*d+0])/2-e4[2*p+0],(e4[2*c+1]+e4[2*d+1])/2-e4[2*p+1])>=16;e6[p]=e6[p]||+!!f,e<1022&&(e6[p]=e6[p]||e6[(a+u>>1)*33+(r+h>>1)]||e6[(o+u>>1)*33+(n+h>>1)])}let o=new e.b0,s=new e.b1,l=0;function h(i,r){let a=33*r+i;return 0===e8[a]&&(o.emplaceBack(e4[2*a+0],e4[2*a+1],i*e.al/32,r*e.al/32),e8[a]=++l),e8[a]-1}function u(e,i,r,a,n,o){let l=e+r>>1,c=i+a>>1;if(Math.abs(e-n)+Math.abs(i-o)>1&&e6[33*c+l])u(n,o,e,i,l,c),u(r,a,n,o,l,c);else{let l=h(e,i),u=h(r,a),c=h(n,o);s.emplaceBack(l,u,c)}}return u(0,0,32,32,32,0),u(32,32,0,0,0,32),{vertices:o,indices:s}}(this.tileID.canonical,r);a=i.vertices,n=i.indices}else{for(let{x:i,y:r}of(a=new e.b0,n=new e.b1,o))a.emplaceBack(i,r,0,0);let i=e.bh(a.int16.subarray(0,4*a.length),void 0,4);for(let e=0;e<i.length;e+=3)n.emplaceBack(i[e],i[e+1],i[e+2])}this._tileBoundsBuffer=i.createVertexBuffer(a,e.bi.members),this._tileBoundsIndexBuffer=i.createIndexBuffer(n),this._tileBoundsSegments=e.bg.simpleSegment(0,0,a.length,n.length)}_makeGlobeTileDebugBuffers(i,r){let a,n=r.projection;if(!n||"globe"!==n.name||r.freezeTileCoverage)return;let o=this.tileID.canonical,s=e.bj(o,r),l=e.bk(s),h=e.aj(r.zoom);h>0&&(a=e.bl(new Float64Array(16),r.globeMatrix)),this._makeGlobeTileDebugBorderBuffer(i,o,r,l,a,h),this._makeGlobeTileDebugTextBuffer(i,o,r,l,a,h)}_globePoint(i,r,a,n,o,s,l){let h=e.bm(i,r,a);if(s){let o=1<<a.z,u=e.aF(n.center.lng),c=e.aJ(n.center.lat),d=(a.x+.5)/o-u,p=0;d>.5?p=-1:d<-.5&&(p=1);let f=(i/e.al+a.x)/o+p,m=(r/e.al+a.y)/o;f=(f-u)*n._pixelsPerMercatorPixel+u,m=(m-c)*n._pixelsPerMercatorPixel+c;let _=[f*n.worldSize,m*n.worldSize,0];e.af(_,_,s),h=e.bn(h,_,l)}return e.af(h,h,o)}_makeGlobeTileDebugBorderBuffer(i,r,a,n,o,s){let l=new e.bd,h=new e.be,u=new e.bo,c=(e,i,c,d,p)=>{let f=(c-e)/(p-1),m=(d-i)/(p-1),_=l.length;for(let c=0;c<p;c++){let d=e+c*f,p=i+c*m;l.emplaceBack(d,p);let g=this._globePoint(d,p,r,a,n,o,s);u.emplaceBack(g[0],g[1],g[2]),h.emplaceBack(_+c)}},d=e.al;c(0,0,d,0,16),c(d,0,d,d,16),c(d,d,0,d,16),c(0,d,0,0,16),this._tileDebugIndexBuffer=i.createIndexBuffer(h),this._tileDebugBuffer=i.createVertexBuffer(l,e.bf.members),this._globeTileDebugBorderBuffer=i.createVertexBuffer(u,e.bp.members),this._tileDebugSegments=e.bg.simpleSegment(0,0,l.length,h.length)}_makeGlobeTileDebugTextBuffer(i,r,a,n,o,s){let l=e.al/4,h=new e.bd,u=new e.b1,c=new e.bo;u.reserve(32),h.reserve(25),c.reserve(25);let d=(e,i)=>25*e+i;for(let e=0;e<25;e++){let i=e*l;for(let e=0;e<25;e++){let u=e*l;h.emplaceBack(u,i);let d=this._globePoint(u,i,r,a,n,o,s);c.emplaceBack(d[0],d[1],d[2])}}for(let e=0;e<4;e++)for(let i=0;i<4;i++){let r=d(e,i),a=d(e,i+1),n=d(e+1,i),o=d(e+1,i+1);u.emplaceBack(r,a,n),u.emplaceBack(n,a,o)}this._tileDebugTextIndexBuffer=i.createIndexBuffer(u),this._tileDebugTextBuffer=i.createVertexBuffer(h,e.bf.members),this._globeTileDebugTextBuffer=i.createVertexBuffer(c,e.bp.members),this._tileDebugTextSegments=e.bg.simpleSegment(0,0,25,32)}destroy(i=!1){for(let e in this.buckets)this.buckets[e].destroy();this.buckets={},this.imageAtlas&&(this.imageAtlas=null),this.lineAtlas&&(this.lineAtlas=null),this.imageAtlasTexture&&(this.imageAtlasTexture.destroy(),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),!i&&this.texture&&this.texture instanceof e.T&&(this.texture.destroy(),delete this.texture),this.hillshadeFBO&&(this.hillshadeFBO.destroy(),delete this.hillshadeFBO),this.dem&&delete this.dem,this.neighboringTiles&&delete this.neighboringTiles,this.demTexture&&(this.demTexture.destroy(),delete this.demTexture),this.rasterParticleState&&(this.rasterParticleState.destroy(),delete this.rasterParticleState),this.latestFeatureIndex=null,this.state="unloaded"}}e.bs.setPbf(e.bt);class tt extends te{constructor(e,i,r,a,n){super(e,i,r,a,n),this._workQueuePerLayer=new Map,this._fetchQueuePerLayer=new Map,this._taskQueue=new Map,this._isHeaderLoaded=!1,this.textureDescriptorPerLayer=new Map,this.texturePerLayer=new Map}
8getLayers(){return this._mrt?Object.values(this._mrt.layers):[]}getLayer(e){return this._mrt&&this._mrt.getLayer(e)}setTexturePerLayer(i,r,a){let n=a.context,o=n.gl,s=this.texturePerLayer.get(i)||a.getTileTexture(r.width);s&&s instanceof e.T?s.update(r,{premultiply:!1}):s=new e.T(n,r,o.RGBA8,{premultiply:!1}),this.texturePerLayer.has(i)||this.texturePerLayer.set(i,s)}flushQueues(e){let i=this._workQueuePerLayer.get(e)||[],r=this._fetchQueuePerLayer.get(e)||[];for(;i.length;)i.pop()();for(;r.length;)r.pop()()}flushAllQueues(){for(let e of this._workQueuePerLayer.keys()){let i=this._workQueuePerLayer.get(e)||[];for(;i.length;)i.pop()()}for(let e of this._fetchQueuePerLayer.keys()){let i=this._fetchQueuePerLayer.get(e)||[];for(;i.length;)i.pop()()}}fetchHeader(i=16384,r){let a=this._mrt=new e.bs(30),n=Object.assign({},this.requestParams,{headers:{Range:"bytes=0-"+(i-1)}});return this.entireBuffer=null,this.request=e.bu(n,(e,n,o,s)=>{if(e)r(e);else try{let e=a.getHeaderLength(n);if(e>i)return void(this.request=this.fetchHeader(e,r));a.parseHeader(n),this._isHeaderLoaded=!0;let l=0;for(let e of Object.values(a.layers))l=Math.max(l,e.dataIndex[e.dataIndex.length-1].lastByte);n.byteLength>=l&&(this.entireBuffer=n),r(null,this.entireBuffer||n,o,s)}catch(e){r(e)}}),this.request}fetchBandForRender(e,i,r,a){this.fetchBand(e,i,r,n=>{if(n)return void a(n);this.updateTextureDescriptor(e,i,r);let o=this.textureDescriptorPerLayer.get(i);a(null,o?o.img:null)})}fetchBand(i,r,a,n,o=!0){let s,l,h=this._mrt;if(!this._isHeaderLoaded||!h)return void n(Error("Tile header is not ready"));let u=this.actor;if(!u)return void n(Error("Can't fetch tile band without an actor"));let c=e.B(String(a),e.B(this.tileID.key,i)),d=this._taskQueue.get(c);d?d.add(n):((d=new Set).add(n),this._taskQueue.set(c,d));let p=(e,i)=>
8{s.complete(e,i),e?n(e):(d.values().forEach(e=>e(null,i)),this._taskQueue.delete(c))},f=(e,i)=>{if(e)return n(e);let a=u.send("decodeRasterArray",{type:"raster-array",source:this.source,scope:this.scope,tileID:this.tileID,uid:this.uid,buffer:i,task:s},p,void 0,!0);if(null!==r){let e=this._workQueuePerLayer.get(r)||[];e.push(()=>{a&&a.cancel(),s.cancel()}),this._workQueuePerLayer.has(r)||this._workQueuePerLayer.set(r,e)}};try{l=h.getLayer(i)}catch(e){if("reloading"===this.state)return;throw e}if(!l)return void n(Error(`Unknown sourceLayer "${i}"`));if(l.hasDataForBand(a))return d.values().forEach(e=>e(null,null)),void this._taskQueue.delete(c);let m=l.getDataRange([a]);if(!(s=h.createDecodingTask(m))||s.tasks.length)if(null!==r&&this.flushQueues(r),this.entireBuffer)f(null,this.entireBuffer.slice(m.firstByte,m.lastByte+1));else{let i=Object.assign({},this.requestParams,{headers:{Range:`bytes=${m.firstByte}-${m.lastByte}`}}),a=e.bu(i,f);if(null!==r){let e=this._fetchQueuePerLayer.get(r)||[];e.push(()=>{a.cancel(),s.cancel()}),this._fetchQueuePerLayer.has(r)||this._fetchQueuePerLayer.set(r,e)}}}updateNeeded(e,i){return(!this.textureDescriptorPerLayer.get(e)||this.textureDescriptorPerLayer.get(e).band!==i||this.refreshedUponExpiration)&&"errored"!==this.state}updateTextureDescriptor(i,r,a){if(!this._mrt)return;let n=this._mrt.getLayer(i);if(!n||!n.hasBand(a)||!n.hasDataForBand(a))return;let{bytes:o,tileSize:s,buffer:l,offset:h,scale:u}=n.getBandView(a),c=s+2*l,d=new e.q({width:c,height:c},o),p=this.texturePerLayer.get(r);p&&p instanceof e.T&&p.update(d,{premultiply:!1}),this.textureDescriptorPerLayer.set(r,{layer:i,band:a,img:d,buffer:l,offset:h,tileSize:s,format:n.pixelFormat,mix:[u,256*u,65536*u,0x1000000*u]})}destroy(i=!1){if(super.destroy(i),delete this._mrt,!i)for(let i of this.texturePerLayer.values())i&&i instanceof e.T&&i.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 ti{constructor(e,i){this.max=e,this.onRemove=i,this.reset()}reset(){for(let e in this.data)for(let i of this.data[e])i.timeout&&clearTimeout(i.timeout),this.onRemove(i.value);return this.data={},this.order=[],this}add(e,i,r){let a=e.wrapped().key;void 0===this.data[a]&&(this.data[a]=[]);let n={value:i,timeout:void 0};if(void 0!==r&&(n.timeout=setTimeout(()=>{this.remove(e,n)},r)),this.data[a].push(n),this.order.push(a),this.order.length>this.max){let 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){let i=this.data[e].shift();return i.timeout&&clearTimeout(i.timeout),0===this.data[e].length&&delete this.data[e],this.order.splice(this.order.indexOf(e),1),i.value}getByKey(e){let i=this.data[e];return i?i[0].value:null}get(e){return this.has(e)?this.data[e.wrapped().key][0].value:null}remove(e,i){if(!this.has(e))return this;let r=e.wrapped().key,a=void 0===i?0:this.data[r].indexOf(i),n=this.data[r][a];return this.data[r].splice(a,1),n.timeout&&clearTimeout(n.timeout),0===this.data[r].length&&delete this.data[r],this.onRemove(n.value),this.order.splice(this.order.indexOf(r),1),this}setMaxSize(e){for(this.max=e;this.order.length>this.max;){let e=this._getAndRemoveByKey(this.order[0]);e&&this.onRemove(e)}return this}filter(e){let i=[];for(let r in this.data)for(let a of this.data[r])e(a.value)||i.push(a);for(let e of i)this.remove(e.value.tileID,e)}}class tr{constructor(){this.state={},this.stateChanges={},this.deletedStates={}}updateState(e,i,r){let a=String(i);if(this.stateChanges[e]=this.stateChanges[e]||{},this.stateChanges[e][a]=this.stateChanges[e][a]||{},Object.assign(this.stateChanges[e][a],r),null===this.deletedStates[e])for(let i in this.deletedStates[e]={},this.state[e])i!==a&&(this.deletedStates[e][i]=null);else if(this.deletedStates[e]&&null===this.deletedStates[e][a])for(let i in this.deletedStates[e][a]={},this.state[e][a])r[i]||(this.deletedStates[e][a][i]=null);else for(let i in r)this.deletedStates[e]&&this.deletedStates[e][a]&&null===this.deletedStates[e][a][i]&&delete this.deletedStates[e][a][i]}removeFeatureState(e,i,r){if(null===this.deletedStates[e])return;let a=String(i);if(this.deletedStates[e]=this.deletedStates[e]||{},r&&void 0!==i)null!==this.deletedStates[e][a]&&(this.deletedStates[e][a]=this.deletedStates[e][a]||{},this.deletedStates[e][a][r]=null);else if(void 0!==i)if(this.stateChanges[e]&&this.stateChanges[e][a])for(r in this.deletedStates[e][a]={},this.stateChanges[e][a])this.deletedStates[e][a][r]=null;else this.deletedStates[e][a]=null;else this.deletedStates[e]=null}getState(e,i){let r=this.state[e]||{},a=this.stateChanges[e]||{},n=this.deletedStates[e];if(null===n)return{};if(void 0!==i){let e=String(i),o=Object.assign({},r[e],a[e]);if(n){let e=n[i];if(null===e)return{};for(let i in e)delete o[i]}return o}let o=Object.assign({},r,a);if(n)for(let e in n)delete o[e];return o}initializeTileState(e,i){e.refreshFeatureState(i)}coalesceChanges(e,i){let r={};for(let e in this.stateChanges){this.state[e]=this.state[e]||{};let i={};for(let r in this.stateChanges[e])this.state[e][r]||(this.state[e][r]={}),Object.assign(this.state[e][r],this.stateChanges[e][r]),i[r]=this.state[e][r];r[e]=i}for(let e in this.deletedStates){this.state[e]=this.state[e]||{};let i={};if(null===this.deletedStates[e])for(let r in this.state[e])i[r]={},this.state[e][r]={};else for(let r in this.deletedStates[e]){if(null===this.deletedStates[e][r])this.state[e][r]={};else if(this.state[e][r])for(let i of Object.keys(this.deletedStates[e][r]))delete this.state[e][r][i];i[r]=this.state[e][r]}r[e]=r[e]||{},Object.assign(r[e],i)}if(this.stateChanges={},this.deletedStates={},0!==Object.keys(r).length)for(let r in e)e[r].refreshFeatureState(i)}}class ta extends e.E{constructor(e,i,r){super(),this.id=e,this._onlySymbols=r,i.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))}),i.on("error",()=>{this._sourceErrored=!0}),this._source=i,this._tiles={},this._cache=new ti(0,this._unloadTile.bind(this)),this._timers={},this._cacheTimers={}
8,this._minTileCacheSize=i.minTileCacheSize,this._maxTileCacheSize=i.maxTileCacheSize,this._loadedParentTiles={},this.castsShadows=!1,this.tileCoverLift=0,this._coveredTiles={},this._shadowCasterTiles={},this._state=new tr,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||!this._source.loaded())return!1;for(let 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;let e=this._shouldReloadOnResume;this._paused=!1,this._shouldReloadOnResume=!1,e&&this.reload(),this.transform&&this.update(this.transform)}_loadTile(e,i){return e.isSymbolTile=this._onlySymbols,e.isExtraShadowCaster=this._shadowCasterTiles[e.tileID.key],this._source.loadTile(e,i)}_unloadTile(e){if(this._source.unloadTile)return this._source.unloadTile(e)}_abortTile(e){if(this._source.abortTile)return this._source.abortTile(e)}serialize(){return this._source.serialize()}prepare(e){for(let i in this._source.prepare&&this._source.prepare(),this._state.coalesceChanges(this._tiles,this.map?this.map.painter:null),this._tiles){let r=this._tiles[i];r.upload(e),r.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(tn).map(e=>e.key)}getRenderableIds(i,r){let a=[];for(let e in this._tiles)this._isIdRenderable(+e,i,r)&&a.push(this._tiles[e]);return i?a.sort((i,r)=>{let a=i.tileID,n=r.tileID,o=new e.P(a.canonical.x,a.canonical.y)._rotate(this.transform.angle),s=new e.P(n.canonical.x,n.canonical.y)._rotate(this.transform.angle);return a.overscaledZ-n.overscaledZ||s.y-o.y||s.x-o.x}).map(e=>e.tileID.key):a.map(e=>e.tileID).sort(tn).map(e=>e.key)}hasRenderableParent(e){let i=this.findLoadedParent(e,0);return!!i&&this._isIdRenderable(i.tileID.key)}_isIdRenderable(e,i,r){return this._tiles[e]&&this._tiles[e].hasData()&&!this._coveredTiles[e]&&(i||!this._tiles[e].holdingForFade())&&(r||!this._shadowCasterTiles[e])}reload(){if(this._paused)this._shouldReloadOnResume=!0;else for(let e in this._cache.reset(),this._tiles)"errored"!==this._tiles[e].state&&this._reloadTile(+e,"reloading")}_reloadTile(e,i){let r=this._tiles[e];r&&("loading"!==r.state&&(r.state=i),this._loadTile(r,this._tileLoaded.bind(this,r,e,i)))}_tileLoaded(i,r,a,n){if(n)if(i.state="errored",404!==n.status)this._source.fire(new e.y(n,{tile:i}));else{if(this._source.fire(new e.z("data",{dataType:"source",sourceDataType:"error",sourceId:this._source.id,tile:i})),!(i.tileID.key in this._loadedParentTiles))return;if("raster-dem"===this._source.type&&this.usedForTerrain&&this.map.painter.terrain){let e=this.map.painter.terrain;this.update(this.transform,e.getScaledDemTileSize(),!0),e.resetTileLookupCache(this.id)}else this.update(this.transform)}else i.timeAdded=e.o.now(),"expired"===a&&(i.refreshedUponExpiration=!0),this._setTileReloadTimer(r,i),"raster-dem"===this._source.type&&i.dem&&this._backfillDEM(i),this._state.initializeTileState(i,this.map?this.map.painter:null),this._source.fire(new e.z("data",{dataType:"source",tile:i,coord:i.tileID,sourceCacheId:this.id}))}_backfillDEM(e){let i=this.getRenderableIds();for(let a=0;a<i.length;a++){let n=i[a];if(e.neighboringTiles&&e.neighboringTiles[n]){let i=this.getTileByID(n);r(e,i),r(i,e)}}function r(e,i){if(!e.dem||e.dem.borderReady)return;e.needsHillshadePrepare=!0,e.needsDEMTextureUpload=!0;let r=i.tileID.canonical.x-e.tileID.canonical.x,a=i.tileID.canonical.y-e.tileID.canonical.y,n=Math.pow(2,e.tileID.canonical.z),o=i.tileID.key;0===r&&0===a||Math.abs(a)>1||(Math.abs(r)>1&&(1===Math.abs(r+n)?r+=n:1===Math.abs(r-n)&&(r-=n)),i.dem&&e.dem&&(e.dem.backfillBorder(i.dem,r,a),e.neighboringTiles&&e.neighboringTiles[o]&&(e.neighboringTiles[o].backfilled=!0)))}}
8getTile(e){return this.getTileByID(e.key)}getTileByID(e){return this._tiles[e]}_retainLoadedChildren(e,i,r,a){for(let n in this._tiles){let o=this._tiles[n];if(a[n]||!o.hasData()||o.tileID.overscaledZ<=i||o.tileID.overscaledZ>r)continue;let s=o.tileID;for(;o&&o.tileID.overscaledZ>i+1;){let e=o.tileID.scaledTo(o.tileID.overscaledZ-1);(o=this._tiles[e.key])&&o.hasData()&&(s=e)}let l=s;for(;l.overscaledZ>i;)if(e[(l=l.scaledTo(l.overscaledZ-1)).key]){a[s.key]=s;break}}}findLoadedParent(e,i){if(e.key in this._loadedParentTiles){let r=this._loadedParentTiles[e.key];return r&&r.tileID.overscaledZ>=i?r:null}for(let r=e.overscaledZ-1;r>=i;r--){let i=e.scaledTo(r),a=this._getLoadedTile(i);if(a)return a}}_getLoadedTile(e){let i=this._tiles[e.key];return i&&i.hasData()?i:this._cache.getByKey(this._source.reparseOverscaled?e.wrapped().key:e.canonical.key)}updateCacheSize(e,i){i=i||this._source.tileSize;let r=Math.floor((Math.ceil(e.width/i)+1)*(Math.ceil(e.height/i)+1)*5),a="number"==typeof this._minTileCacheSize?Math.max(this._minTileCacheSize,r):r,n="number"==typeof this._maxTileCacheSize?Math.min(this._maxTileCacheSize,a):a;this._cache.setMaxSize(n)}handleWrapJump(e){let i=Math.round((e-(void 0===this._prevLng?e:this._prevLng))/360);if(this._prevLng=e,i){let e={};for(let r in this._tiles){let a=this._tiles[r];a.tileID=a.tileID.unwrapTo(a.tileID.wrap+i),e[a.tileID.key]=a}for(let i in this._tiles=e,this._timers)clearTimeout(this._timers[i]),delete this._timers[i];for(let e in this._tiles)this._setTileReloadTimer(+e,this._tiles[e])}}update(i,r,a,n,o){if(this.transform=i,!this._sourceLoaded||this._paused||this.transform.freezeTileCoverage||this.usedForTerrain&&!a)return;this.updateCacheSize(i,r),"globe"!==this.transform.projection.name&&this.handleWrapJump(this.transform.center.lng),this._shadowCasterTiles={},this._coveredTiles={};let s="batched-model"===this._source.type,l,h=this._source.maxzoom,u=this.map&&this.map.painter?this.map.painter._terrain:null;if(u&&u.sourceCache===this&&u.attenuationRange()){let e=Math.floor(u.attenuationRange()[0])-Math.log2(u.getDemUpscale());h>e&&(h=e)}if(this.used||this.usedForTerrain){if(this._source.tileID)l=i.getVisibleUnwrappedCoordinates(this._source.tileID).map(i=>new e.aO(i.canonical.z,i.wrap,i.canonical.z,i.canonical.x,i.canonical.y));else if(0!==this.tileCoverLift){let n=i.clone();n.tileCoverLift=this.tileCoverLift,l=n.coveringTiles({tileSize:r||this._source.tileSize,minzoom:this._source.minzoom,maxzoom:h,roundZoom:this._source.roundZoom&&!a,reparseOverscaled:this._source.reparseOverscaled,isTerrainDEM:this.usedForTerrain,calculateQuadrantVisibility:s}),this._source.minzoom<=1&&"globe"===i.projection.name&&(l.push(new e.aO(1,0,1,0,0)),l.push(new e.aO(1,0,1,1,0)),l.push(new e.aO(1,0,1,0,1)),l.push(new e.aO(1,0,1,1,1)))}else if(l=i.coveringTiles({tileSize:r||this._source.tileSize,minzoom:this._source.minzoom,maxzoom:h,roundZoom:this._source.roundZoom&&!a,reparseOverscaled:this._source.reparseOverscaled,isTerrainDEM:this.usedForTerrain,calculateQuadrantVisibility:s}),this._source.hasTile){let e=this._source.hasTile.bind(this._source);l=l.filter(i=>e(i))}}else l=[];
8if(l.length>0&&"globe"!==this.transform.projection.name&&!this.usedForTerrain&&!to(this._source.type)){let e=Math.min(i.coveringZoomLevel({tileSize:r||this._source.tileSize,roundZoom:this._source.roundZoom&&!a}),this._source.maxzoom);if(s)for(let r of i.extendTileCover(l,e))l.push(r);else if(o)for(let r of i.extendTileCoverToNearPlane(l,this.transform.getFrustum(e),e))l.push(r);else if(this.castsShadows&&n)for(let r of i.extendTileCover(l,e,n))this._shadowCasterTiles[r.key]=!0,l.push(r)}let c=this._updateRetainedTiles(l);if(to(this._source.type)&&0!==l.length){let i={},r={};for(let a of Object.keys(c)){let n=c[a],o=this._tiles[a];if(!o||o.fadeEndTime&&o.fadeEndTime<=e.o.now())continue;let s=this.findLoadedParent(n,Math.max(n.overscaledZ-ta.maxOverzooming,this._source.minzoom));s&&(this._addTile(s.tileID),i[s.tileID.key]=s.tileID),r[a]=n}let a=l[l.length-1].overscaledZ;for(let e in this._tiles){let i=this._tiles[e];if(c[e]||!i.hasData())continue;let n=i.tileID;for(;n.overscaledZ>a;){n=n.scaledTo(n.overscaledZ-1);let a=this._tiles[n.key];if(a&&a.hasData()&&r[n.key]){c[e]=i.tileID;break}}}for(let e in i)c[e]||(this._coveredTiles[e]=!0,c[e]=i[e])}for(let e in c)this._tiles[e].clearFadeHold();for(let i of e.bv(this._tiles,c)){let e=this._tiles[i];e.hasSymbolBuckets&&!e.holdingForFade()?e.setHoldDuration(this.map._fadeDuration):e.hasSymbolBuckets&&!e.symbolFadeFinished()||this._removeTile(+i)}this._updateLoadedParentTileCache(),this._onlySymbols&&this._source.afterUpdate&&this._source.afterUpdate()}releaseSymbolFadeTiles(){for(let e in this._tiles)this._tiles[e].holdingForFade()&&this._removeTile(+e)}_updateRetainedTiles(e){let i={};if(0===e.length)return i;let r={},a=e.reduce((e,i)=>Math.min(e,i.overscaledZ),1/0),n=e[0].overscaledZ,o=Math.max(n-ta.maxOverzooming,this._source.minzoom),s=Math.max(n+ta.maxUnderzooming,this._source.minzoom),l={};for(let r of e){let e=this._addTile(r);i[r.key]=r,e.hasData()||a<this._source.maxzoom&&(l[r.key]=r)}for(let n of(this._retainLoadedChildren(l,a,s,i),e)){let e=this._tiles[n.key];if(e.hasData())continue;if(n.canonical.z>=this._source.maxzoom){let e=n.children(this._source.maxzoom)[0],r=this.getTile(e);if(r&&r.hasData()){i[e.key]=e;continue}}else{let e=n.children(this._source.maxzoom);if(i[e[0].key]&&i[e[1].key]&&i[e[2].key]&&i[e[3].key])continue}let a=e.wasRequested();for(let s=n.overscaledZ-1;s>=o;--s){let o=n.scaledTo(s);if(r[o.key]||(r[o.key]=!0,(e=this.getTile(o))||!a||(e=this._addTile(o)),e&&(i[o.key]=o,a=e.wasRequested(),e.hasData())))break}}return i}_updateLoadedParentTileCache(){for(let e in this._loadedParentTiles={},this._tiles){let i=[],r,a=this._tiles[e].tileID;for(;a.overscaledZ>0;){if(a.key in this._loadedParentTiles){r=this._loadedParentTiles[a.key];break}i.push(a.key);let e=a.scaledTo(a.overscaledZ-1);if(r=this._getLoadedTile(e))break;a=e}for(let e of i)this._loadedParentTiles[e]=r}}_addTile(i){let r=this._tiles[i.key];if(r)return!0!==r.isExtraShadowCaster||this._shadowCasterTiles[i.key]||this._reloadTile(i.key,"reloading"),r;(r=this._cache.getAndRemove(i))&&(this._setTileReloadTimer(i.key,r),r.tileID=i,this._state.initializeTileState(r,this.map?this.map.painter:null),this._cacheTimers[i.key]&&(clearTimeout(this._cacheTimers[i.key]),delete this._cacheTimers[i.key],this._setTileReloadTimer(i.key,r)));let a=!!r;if(!a){let e=this.map?this.map.painter:null,a=this._source.tileSize*i.overscaleFactor();r="raster-array"===this._source.type?new tt(i,a,this.transform.tileZoom,e,this._isRaster):new te(i,a,this.transform.tileZoom,e,this._isRaster,this._source.worldview),this._loadTile(r,this._tileLoaded.bind(this,r,i.key,r.state))}return r.uses++,this._tiles[i.key]=r,a||this._source.fire(new e.z("dataloading",{tile:r,coord:r.tileID,dataType:"source"})),r}_setTileReloadTimer(e,i){e in this._timers&&(clearTimeout(this._timers[e]),delete this._timers[e]);let r=i.getExpiryTimeout();r&&(this._timers[e]=setTimeout(()=>{this._reloadTile(e,"expired"),delete this._timers[e]},r))}_removeTile(e){let i=this._tiles[e];i&&(i.uses--,delete this._tiles[e],this._timers[e]&&(clearTimeout(this._timers[e]),delete this._timers[e]),i.uses>0||(i.hasData()&&"reloading"!==i.state||"empty"===i.state?this._cache.add(i.tileID,i,i.getExpiryTimeout()):(i.aborted=!0,this._abortTile(i),this._unloadTile(i))))}clearTiles(){for(let e in this._shouldReloadOnResume=!1,this._paused=!1,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
8)}tilesIn(i,r,a){let n=[],o=this.transform;if(!o)return n;let s="globe"===o.projection.name,l=e.aF(o.center.lng);for(let h in this._tiles){let u,c=this._tiles[h];if(a&&c.clearQueryDebugViz(),!c.holdingForFade()){if(s){let i=c.tileID.canonical;if(0===i.z){let r=[Math.abs(e.aA(l,...ts(i,-1))-l),Math.abs(e.aA(l,...ts(i,1))-l)];u=[0,2*r.indexOf(Math.min(...r))-1]}else{let r=[Math.abs(e.aA(l,...ts(i,-1))-l),Math.abs(e.aA(l,...ts(i,0))-l),Math.abs(e.aA(l,...ts(i,1))-l)];u=[r.indexOf(Math.min(...r))-1]}}else u=[0];for(let e of u){let a=i.containsTile(c,o,r,e);a&&n.push(a)}}}return n}getShadowCasterCoordinates(){return this._getRenderableCoordinates(!1,!0)}getVisibleCoordinates(e){return this._getRenderableCoordinates(e)}_getRenderableCoordinates(e,i){let r=this.getRenderableIds(e,i).map(e=>this._tiles[e].tileID),a="globe"===this.transform.projection.name;for(let e of r)e.projMatrix=this.transform.calculateProjMatrix(e.toUnwrapped()),e.expandedProjMatrix=a?this.transform.calculateProjMatrix(e.toUnwrapped(),!1,!0):e.projMatrix;return r}sortCoordinatesByDistance(e){let i=e.slice(),r=this.transform._camera.position,a=this.transform._camera.forward(),n={};for(let e of i){let i=1/(1<<e.canonical.z);n[e.key]=((e.canonical.x+.5)*i+e.wrap-r[0])*a[0]+((e.canonical.y+.5)*i-r[1])*a[1]-r[2]*a[2]}return i.sort((e,i)=>n[e.key]-n[i.key]),i}hasTransition(){if(this._source.hasTransition())return!0;if(to(this._source.type))for(let i in this._tiles){let r=this._tiles[i];if(void 0!==r.fadeEndTime&&r.fadeEndTime>=e.o.now())return!0}return!1}setFeatureState(e,i,r){this._state.updateState(e=e||"_geojsonTileLayer",i,r)}removeFeatureState(e,i,r){this._state.removeFeatureState(e=e||"_geojsonTileLayer",i,r)}getFeatureState(e,i){return this._state.getState(e=e||"_geojsonTileLayer",i)}setDependencies(e,i,r){let a=this._tiles[e];a&&a.setDependencies(i,r)}reloadTilesForDependencies(e,i){for(let r in this._tiles)this._tiles[r].hasDependency(e,i)&&this._reloadTile(+r,"reloading");this._cache.filter(r=>!r.hasDependency(e,i))}_preloadTiles(i,r){if(!this._sourceLoaded){let e=()=>{this._sourceLoaded&&(this._source.off("data",e),this._preloadTiles(i,r))};return void this._source.on("data",e)}let a=new Map,n=Array.isArray(i)?i:[i],o=this.map.painter.terrain,s=this.usedForTerrain&&o?o.getScaledDemTileSize():this._source.tileSize;for(let e of n){for(let i of e.coveringTiles({tileSize:s,minzoom:this._source.minzoom,maxzoom:this._source.maxzoom,roundZoom:this._source.roundZoom&&!this.usedForTerrain,reparseOverscaled:this._source.reparseOverscaled,isTerrainDEM:this.usedForTerrain}))a.set(i.key,i);this.usedForTerrain&&e.updateElevation(!1)}let l=Array.from(a.values());e.bw(l,(e,i)=>{let r=new te(e,this._source.tileSize*e.overscaleFactor(),this.transform.tileZoom,this.map.painter,this._isRaster,this._source.worldview);this._loadTile(r,e=>{"raster-dem"===this._source.type&&r.dem&&this._backfillDEM(r),i(e,r)})},r)}}function tn(e,i){let r=Math.abs(2*e.wrap)-(e.wrap<0),a=Math.abs(2*i.wrap)-(i.wrap<0);return e.overscaledZ-i.overscaledZ||a-r||i.canonical.y-e.canonical.y||i.canonical.x-e.canonical.x}function to(e){return"raster"===e||"image"===e||"video"===e||"custom"===e}function ts(e,i){let r=1<<e.z;return[e.x/r+i,(e.x+1)/r+i]}ta.maxOverzooming=10,ta.maxUnderzooming=3;class tl{constructor(e){this.style=e,this.layersGotHidden=!1,this.layers=[]}processLayersChanged(){for(let e in this.layers=[],this.style._mergedLayers){let i=this.style._mergedLayers[e];if("fill-extrusion"===i.type||"building"===i.type)this.layers.push({layer:i,visible:!1,visibilityChanged:!1});else if("model"===i.type){let e=this.style.getLayerSource(i);e&&"batched-model"===e.type&&this.layers.push({layer:i,visible:!1,visibilityChanged:!1})}}}onNewFrame(e){for(let i of(this.layersGotHidden=!1,this.layers)){let r=i.layer,a=!1;"fill-extrusion"===r.type?a=!r.isHidden(e)&&r.paint.get("fill-extrusion-opacity")>0:"building"===r.type?a=!r.isHidden(e)&&r.paint.get("building-opacity")>0:"model"===r.type&&(a=!r.isHidden(e)&&r.paint.get("model-opacity").constantOr(1)>0),this.layersGotHidden=this.layersGotHidden||!a&&i.visible,i.visible=a}}updateZOffset(e,i){for(let e of(this.currentBuildingBuckets=[],this.layers)){let r=e.layer,a=this.style.getLayerSourceCache(r),n=1;"fill-extrusion"===r.type?n=e.visible?r.paint.get("fill-extrusion-vertical-scale"):0:"building"===r.type&&(n=e.visible?r.paint.get("building-vertical-scale"):0);let o=a?a.getTile(i):null;if(!o&&a)for(let e in a._tiles){let r=a._tiles[e];if(i.canonical.isChildOf(r.tileID.canonical)){o=r;break}}this.currentBuildingBuckets.push({bucket:o?o.getBucket(r):null,tileID:o?o.tileID:i,verticalScale:n})}e.hasAnyZOffset=!1;let r=!1;for(let a=0;a<e.symbolInstances.length;a++){let n=e.symbolInstances.get(a),o=n.zOffset,s=this._getHeightAtTileOffset(i,n.tileAnchorX,n.tileAnchorY);n.zOffset=s!==-1/0?s:o,r||o===n.zOffset||(r=!0),e.hasAnyZOffset||0===n.zOffset||(e.hasAnyZOffset=!0)}r&&(e.zOffsetBuffersNeedUpload=!0,e.zOffsetSortDirty=!0)}_mapCoordToOverlappingTile(i,r,a,n){let o=r,s=a;if(i.canonical.z!==n.canonical.z){let l=n.canonical,h=1/(1<<i.canonical.z-l.z);o=(r+i.canonical.x*e.al)*h-l.x*e.al|0,s=(a+i.canonical.y*e.al)*h-l.y*e.al|0}return{tileX:o,tileY:s}}_getHeightAtTileOffset(e,i,r){let a,n;for(let o=0;o<this.layers.length;++o){let s=this.layers[o].layer;if("fill-extrusion"!==s.type&&"building"!==s.type)continue;let{bucket:l,tileID:h,verticalScale:u}=this.currentBuildingBuckets[o];if(!l)continue;let{tileX:c,tileY:d}=this._mapCoordToOverlappingTile(e,i,r,h),p=l.getHeightAtTileCoord(c,d);p&&void 0!==p.height&&(p.hidden?a=p.height:n=Math.max(p.height*u,n||0))}if(void 0!==n)return n;for(let n=0;n<this.layers.length;++n){let o=this.layers[n];if("model"!==o.layer.type||!o.visible)continue;let{bucket:s,tileID:l}=this.currentBuildingBuckets[n];if(!s)continue;let{tileX:h,tileY:u}=this._mapCoordToOverlappingTile(e,i,r,l),c=s.getHeightAtTileCoord(h,u);if(c&&!c.hidden)return void 0===c.height&&void 0!==a?Math.min(c.maxHeight,a)*c.verticalScale:c.height?c.height*c.verticalScale:-1/0}return this.layersGotHidden?0:-1/0}}function th(i){i=i.slice();let r=Object.create(null);for(let e=0;e<i.length;e++)r[i[e].id]=i[e];for(let a=0;a<i.length;a++)"ref"in i[a]&&(i[a]=function(i,r){let a={};for(let e in i)"ref"!==e&&(a[e]=i[e]);
8return e.bx.forEach(e=>{e in r&&(a[e]=r[e])}),a}(i[a],r[i[a].ref]));return i}let tu={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 tc(e,i,r){r.push({command:tu.addSource,args:[e,i[e]]})}function td(e,i,r){i.push({command:tu.removeSource,args:[e]}),r[e]=!0}function tp(i,r,a,n,o,s){let l;for(l in r=r||{},i=i||{})i.hasOwnProperty(l)&&(e.by(i[l],r[l])||a.push({command:s,args:[n,l,r[l],o]}));for(l in r)r.hasOwnProperty(l)&&!i.hasOwnProperty(l)&&(e.by(i[l],r[l])||a.push({command:s,args:[n,l,r[l],o]}))}function tf(e){return e.id}function tm(e,i){return e[i.id]=i,e}function t_(i,r,a){let n=r.createTileMatrix(i,i.worldSize,a.toUnwrapped());return e.aB(new Float32Array(16),i.projMatrix,n)}function tg(e,i,r){return i.name===r.projection.name?e.projMatrix:t_(r,i,e)}class ty{constructor(e,i){this.reset(e,i)}reset(e,i){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(i||0,.5*this.length),this.paddedLength=this.length-2*this.padding}lerp(i){if(1===this.points.length)return this.points[0];i=e.aA(i,0,1);let r=1,a=this._distances[r],n=i*this.paddedLength+this.padding;for(;a<n&&r<this._distances.length;)a=this._distances[++r];let o=r-1,s=this._distances[o],l=a-s,h=l>0?(n-s)/l:0;return this.points[o].mult(1-h).add(this.points[r].mult(h))}}class tx{constructor(e,i,r){let a=this.boxCells=[],n=this.circleCells=[];this.xCellCount=Math.ceil(e/r),this.yCellCount=Math.ceil(i/r);for(let e=0;e<this.xCellCount*this.yCellCount;e++)a.push([]),n.push([]);this.circleKeys=[],this.boxKeys=[],this.bboxes=[],this.circles=[],this.width=e,this.height=i,this.xScale=this.xCellCount/e,this.yScale=this.yCellCount/i,this.boxUid=0,this.circleUid=0}keysLength(){return this.boxKeys.length+this.circleKeys.length}insert(e,i,r,a,n){this._forEachCell(i,r,a,n,this._insertBoxCell,this.boxUid++),this.boxKeys.push(e),this.bboxes.push(i),this.bboxes.push(r),this.bboxes.push(a),this.bboxes.push(n)}insertCircle(e,i,r,a){this._forEachCell(i-a,r-a,i+a,r+a,this._insertCircleCell,this.circleUid++),this.circleKeys.push(e),this.circles.push(i),this.circles.push(r),this.circles.push(a)}_insertBoxCell(e,i,r,a,n,o){this.boxCells[n].push(o)}_insertCircleCell(e,i,r,a,n,o){this.circleCells[n].push(o)}_query(e,i,r,a,n,o){if(r<0||e>this.width||a<0||i>this.height)return!n&&[];let s=[];if(e<=0&&i<=0&&this.width<=r&&this.height<=a){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++){let i=this.circles[3*e],r=this.circles[3*e+1],a=this.circles[3*e+2];s.push({key:this.circleKeys[e],x1:i-a,y1:r-a,x2:i+a,y2:r+a})}return o?s.filter(o):s}return this._forEachCell(e,i,r,a,this._queryCell,s,{hitTest:n,seenUids:{box:{},circle:{}}},o),n?s.length>0:s}_queryCircle(e,i,r,a,n){let o=e-r,s=e+r,l=i-r,h=i+r;if(s<0||o>this.width||h<0||l>this.height)return!a&&[];let u=[];return this._forEachCell(o,l,s,h,this._queryCellCircle,u,{hitTest:a,circle:{x:e,y:i,radius:r},seenUids:{box:{},circle:{}}},n),a?u.length>0:u}query(e,i,r,a,n){return this._query(e,i,r,a,!1,n)}hitTest(e,i,r,a,n){return this._query(e,i,r,a,!0,n)}hitTestCircle(e,i,r,a){return this._queryCircle(e,i,r,!0,a)}_queryCell(e,i,r,a,n,o,s,l){let h=s.seenUids,u=this.boxCells[n];if(null!==u){let n=this.bboxes;for(let c of u)if(!h.box[c]){h.box[c]=!0;let u=4*c;if(e<=n[u+2]&&i<=n[u+3]&&r>=n[u+0]&&a>
8=n[u+1]&&(!l||l(this.boxKeys[c]))){if(s.hitTest)return o.push(!0),!0;o.push({key:this.boxKeys[c],x1:n[u],y1:n[u+1],x2:n[u+2],y2:n[u+3]})}}}let c=this.circleCells[n];if(null!==c){let n=this.circles;for(let u of c)if(!h.circle[u]){h.circle[u]=!0;let c=3*u;if(this._circleAndRectCollide(n[c],n[c+1],n[c+2],e,i,r,a)&&(!l||l(this.circleKeys[u]))){if(s.hitTest)return o.push(!0),!0;{let e=n[c],i=n[c+1],r=n[c+2];o.push({key:this.circleKeys[u],x1:e-r,y1:i-r,x2:e+r,y2:i+r})}}}}}_queryCellCircle(e,i,r,a,n,o,s,l){let h=s.circle,u=s.seenUids,c=this.boxCells[n];if(null!==c){let e=this.bboxes;for(let i of c)if(!u.box[i]){u.box[i]=!0;let r=4*i;if(this._circleAndRectCollide(h.x,h.y,h.radius,e[r+0],e[r+1],e[r+2],e[r+3])&&(!l||l(this.boxKeys[i])))return o.push(!0),!0}}let d=this.circleCells[n];if(null!==d){let e=this.circles;for(let i of d)if(!u.circle[i]){u.circle[i]=!0;let r=3*i;if(this._circlesCollide(e[r],e[r+1],e[r+2],h.x,h.y,h.radius)&&(!l||l(this.circleKeys[i])))return o.push(!0),!0}}}_forEachCell(e,i,r,a,n,o,s,l){let h=this._convertToXCellCoord(e),u=this._convertToYCellCoord(i),c=this._convertToXCellCoord(r),d=this._convertToYCellCoord(a);for(let p=h;p<=c;p++)for(let h=u;h<=d;h++)if(n.call(this,e,i,r,a,this.xCellCount*h+p,o,s,l))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,i,r,a,n,o){let s=a-e,l=n-i,h=r+o;return h*h>s*s+l*l}_circleAndRectCollide(e,i,r,a,n,o,s){let l=(o-a)/2,h=Math.abs(e-(a+l));if(h>l+r)return!1;let u=(s-n)/2,c=Math.abs(i-(n+u));if(c>u+r)return!1;if(h<=l||c<=u)return!0;let d=h-l,p=c-u;return d*d+p*p<=r*r}}let tv=Math.tan(85*Math.PI/180);function tb(i,r,a,n,o,s,l){let h=e.bC();if(a)if("globe"===s.name){let i=e.bD(o,r);e.aB(h,h,i)}else{let i=e.bE([],l);h[0]=i[0],h[1]=i[1],h[4]=i[2],h[5]=i[3],n||e.bB(h,h,o.angle)}else e.aB(h,o.labelPlaneMatrix,i);return h}function tw(e,i,r,a,n,o,s){let l=tb(e,i,r,a,n,o,s);return"globe"===o.name&&r||(l[2]=l[6]=l[10]=l[14]=0),l}function tT(i,r,a,n,o,s,l){if(a){if("globe"===s.name){let h=tb(i,r,a,n,o,s,l);return e.bl(h,h),e.aB(h,i,h),h}{let r=e.bz(i),a=e.bA([]);return a[0]=l[0],a[1]=l[1],a[4]=l[2],a[5]=l[3],e.aB(r,r,a),n||e.bB(r,r,-o.angle),r}}return o.glCoordMatrix}function tS(i,r,a,n){let o=[i,r,a,1];a?e.aC(o,o,n):tL(o,o,n);let s=o[3];return o[0]/=s,o[1]/=s,o[2]/=s,o}function tE(e,i){return Math.min(.5+e/i*.5,1.5)}function tI(i,r,a,n,o,s,l,h,u,c){let d=a.transform,p=n?i.textSizeData:i.iconSizeData,f=e.bK(p,a.transform.zoom),m="globe"===d.projection.name,_=[256/a.width*2+1,256/a.height*2+1],g=n?i.text.dynamicLayoutVertexArray:i.icon.dynamicLayoutVertexArray;g.clear();let y=null;m&&(y=n?i.text.globeExtVertexArray:i.icon.globeExtVertexArray);let x=i.lineVertexArray,v=n?i.text.placedSymbolArray:i.icon.placedSymbolArray,b=a.transform.width/a.transform.height,w,T=!1;for(let n=0;n<v.length;n++){let m=v.get(n),{numGlyphs:S,writingMode:E}=m;if(E!==e.bL.vertical||T||w===e.bL.horizontal||(T=!0),w=E,(m.hidden||E===e.bL.vertical)&&!T){tD(S,g);continue}T=!1;let I=new e.P(m.tileAnchorX,m.tileAnchorY),{x:A,y:C,z:M}=d.projection.projectTilePoint(I.x,I.y,c.canonical);if(u){let[e,i,r]=u(I);A+=e,C+=i,M+=r}let P=[A,C,M,1];if(e.aC(P,P,r),!function(e,i){let r=e[0]/e[3],a=e[1]/e[3];return r>=-i[0]&&r<=i[0]&&a>=-i[1]&&a<=i[1]}(P,_)){tD(S,g);continue}let z=P[3],R=tE(a.transform.getCameraToCenterDistance(d.projection),z),D=e.bM(p,f,m),L=l?D/R:D*R,O=tS(A,C,M,o);if(O[3]<=0){tD(S,g);continue}let F={},k=Math.cos(e.an(i.layers[0].layout.get("text-max-angle"))),B=l?null:u,N=tM(m,L,!1,h,r,o,s,i.glyphOffsetArray,x,g,y,O,I,F,b,B,d.projection,c,l,k);T=N.useVertical,B&&N.needsFlipping&&(F={}),(N.notEnoughRoom||T||N.needsFlipping&&tM(m,L,!0,h,r,o,s,i.glyphOffsetArray,x,g,y,O,I,F,b,B,d.projection,c,l,k).notEnoughRoom)&&tD(S,g)}n?(i.text.dynamicLayoutVertexBuffer.updateData(g),y&&i.text.globeExtVertexBuffer&&i.text.globeExtVertexBuffer.updateData(y)):(i.icon.dynamicLayoutVertexBuffer.updateData(g),y&&i.icon.globeExtVertexBuffer&&i.icon.globeExtVertexBuffer.updateData(y))}function tA(e,i,r,a,n,o,s,l,h,u,c,d,p,f,m,_,g){let{lineStartIndex:y,glyphStartIndex:x,segment:v}=l,b=x+l.numGlyphs,w=y+l.lineLength,T=i.getoffsetX(x),S=i.getoffsetX(b-1),E=tR(e*T,r,a,n,o,s,v,y,w,h,u,c,d,p,!0,f,m,_,g);if(!E)return null;let I=tR(e*S,r,a,n,o,s,v,y,w,h,u,c,d,p,!0,f,m,_,g);return I?{first:E,last:I}:null}function tC(i,r,a,n){return i===e.bL.horizontal&&Math.abs(n)>Math.abs(a)?{useVertical:!0}:i===e.bL.vertical?n>0?{needsFlipping:!0}:null:0!==r&&(0===a||Math.abs(n/a)>tv)?1===r?{needsFlipping:!0}:null:a<0?{needsFlipping:!0}:null}function tM(i,r,a,n,o,s,l,h,u,c,d,p,f,m,_,g,y,x,v,b){let w=r/24,T=i.lineOffsetX*w,S=i.lineOffsetY*w,{lineStartIndex:E,glyphStartIndex:I,numGlyphs:A,segment:C,writingMode:M,flipState:P}=i,z=E+i.lineLength,R=i=>{if(d){let[r,a,n]=i.up,o=c.length;e.bN(d,o+0,r,a,n),e.bN(d,o+1,r,a,n),e.bN(d,o+2,r,a,n),e.bN(d,o+3,r,a,n)}let[r,a,n]=i.point;e.bO(c,r,a,n,i.angle)};if(A>1){let e=tA(w,h,T,S,a,p,f,i,u,s,m,g,!1,y,x,v,b);if(!e)return{notEnoughRoom:!0};if(n&&!a){let[r,a,n]=e.first.point,[o,s,h]=e.last.point;[r,a]=tS(r,a,n,l),[o,s]=tS(o,s,h,l);let u=tC(M,P,(o-r)*_,s-a);if(i.flipState=u&&u.needsFlipping?1:2,u)return u}R(e.first);for(let e=I+1;e<I+A-1;e++){let i=tR(w*h.getoffsetX(e),T,S,a,p,f,C,E,z,u,s,m,g,!1,!1,y,x,v,b);if(!i)return c.length-=4*(e-I),{notEnoughRoom:!0};R(i)}R(e.last)}else{if(n&&!a){let r=tS(f.x,f.y,0,o),a=E+C+1,n=new e.P(u.getx(a),u.gety(a)),s=tS(n.x,n.y,0,o),l=s[3]>0?s:tz(f,n,r,1,o,void 0,y,x.canonical),h=tC(M,P,(l[0]-r[0])*_,l[1]-r[1]);if(i.flipState=h&&h.needsFlipping?1:2,h)return h}let r=tR(w*h.getoffsetX(I),T,S,a,p,f,C,E,z,u,s,m,g,!1,!1,y,x,v,b);if(!r)return{notEnoughRoom:!0};R(r)}return{}}function tP(e,i,r,a,n){let{x:o,y:s,z:l}=a.projectTilePoint(e.x,e.y,i);if(!n)return tS(o,s,l,r);let[h,u,c]=n(e);return tS(o+h,s+u,l+c,r)}function tz(i,r,a,n,o,s,l,h){let u=tP(i.sub(r)._unit()._add(i),h,o,l,s);return e.av(u,a,u),e.aw(u,u),e.bH(u,a,u,n)}function tR(i,r,a,n,o,s,l,h,u,c,d,p,f,m,_,g,y,x,v){let b=n?i-r:i+r,w=b>0?1:-1,T=0;n&&(w*=-1,T=Math.PI),w<0&&(T+=Math.PI);let S=h+l+(w>0?0:1)|0,E=o,I=o,A=0,C=0,M=Math.abs(b),P=[],z=[],R=s,D=R,L=e.bF([]),O=()=>tz(D,R,I,M-A+1,d,f,g,y.canonical);for(;A+C<=M;){if((S+=w)<h||S>=u)return null;
8if(I=E,D=R,P.push(I),m&&z.push(D),R=new e.P(c.getx(S),c.gety(S)),!(E=p[S])){let e=tP(R,y.canonical,d,g,f);E=e[3]>0?p[S]=e:O()}A+=C;let i=e.av([],E,I),r=e.bG(I,E);if(a&&r>0&&C>0&&e.bJ(L,i)/(C*r)<v)return null;C=r,L=i}_&&f&&(p[S]&&(E=O(),C=e.bG(I,E),L=e.av([],E,I)),p[S]=E);let F=(M-A)/C,k=R.sub(D)._mult(F)._add(D),B=e.bH([],I,L,F),N=[0,0,1],V=L[0],U=L[1];if(x&&(0!==(N=g.upVector(y.canonical,k.x,k.y))[0]||0!==N[1]||1!==N[2])){let i=[N[2],0,-N[0]],r=e.bI([],N,i);e.aw(i,i),e.aw(r,r),V=e.bJ(L,i),U=e.bJ(L,r)}if(a){let i=e.bI([],N,L);e.aw(i,i),e.bH(B,B,i,a*w)}let j=T+Math.atan2(U,V);return P.push(B),m&&z.push(k),{point:B,angle:j,path:P,tilePath:z,up:N}}function tD(e,i){let r=i.length,a=r+4*e;i.resize(a),i.float32.fill(-1/0,4*r,4*a)}function tL(e,i,r){let a=i[0],n=i[1];return e[0]=r[0]*a+r[4]*n+r[12],e[1]=r[1]*a+r[5]*n+r[13],e[3]=r[3]*a+r[7]*n+r[15],e}class tO{constructor(e,i,r=new tx(e.width+200,e.height+200,25),a=new tx(e.width+200,e.height+200,25)){this.transform=e,this.grid=r,this.ignoredGrid=a,this.pitchfactor=Math.cos(e._pitch)*e.cameraToCenterDistance,this.screenRightBoundary=e.width+100,this.screenBottomBoundary=e.height+100,this.gridRightBoundary=e.width+200,this.gridBottomBoundary=e.height+200,this.fogState=i}placeCollisionBox(i,r,a,n,o,s,l,h,u,c,d){let p=a.projectedAnchorX,f=a.projectedAnchorY,m=a.projectedAnchorZ,_=a.tileAnchorX,g=a.tileAnchorY,y=a.elevation,x=a.tileID,v=i.getProjection();if(y&&x){let[e,i,r]=v.upVector(x.canonical,a.tileAnchorX,a.tileAnchorY),n=v.upVectorScale(x.canonical,this.transform.center.lat,this.transform.worldSize).metersToTile;p+=e*y*n,f+=i*y*n,m+=r*y*n}let b="globe"===i.projection.name,w="globe"===i.projection.name?e.aj(this.transform.zoom):0;if(x&&b&&w<1&&!s){let i=1<<x.canonical.z,r=e.bP(_,g);e.bQ(r,r,1/e.al),e.bR(r,r,e.bP(x.canonical.x,x.canonical.y)),e.bQ(r,r,1/i),e.bS(r,r,e.bP(n[0],n[1])),r[0]=e.bT(r[0],-.5,.5),e.bQ(r,r,e.al);let a=e.bU(r[0],r[1],e.al/(2*Math.PI),1);e.aC(a,a,o),p=e.ak(p,a[0],w),f=e.ak(f,a[1],w),m=e.ak(m,a[2],w)}let T=this.projectAndGetPerspectiveRatio(c,p,f,m,a.tileID,"globe"===v.name||!!y||this.transform.pitch>0,v),S=u*T.perspectiveRatio,E=(a.x1*r+l.x-a.padding)*S+T.point.x,I=(a.y1*r+l.y-a.padding)*S+T.point.y,A=(a.x2*r+l.x+a.padding)*S+T.point.x,C=(a.y2*r+l.y+a.padding)*S+T.point.y,M=T.perspectiveRatio<=.55||T.occluded;return!this.isInsideGrid(E,I,A,C)||!h&&this.grid.hitTest(E,I,A,C,d)||M?{box:[],offscreen:!1,occluded:T.occluded}:{box:[E,I,A,C],offscreen:this.isOffscreen(E,I,A,C),occluded:!1}}placeCollisionCircles(i,r,a,n,o,s,l,h,u,c,d,p,f,m,_){let g=[],y=this.transform.elevation,x=i.getProjection(),v=y?y.getAtTileOffsetFunc(_,this.transform.center.lat,this.transform.worldSize,x):null,b=new e.P(a.tileAnchorX,a.tileAnchorY),{x:w,y:T,z:S}=x.projectTilePoint(b.x,b.y,_.canonical);if(v){let[e,i,r]=v(b);w+=e,T+=i,S+=r}let E="globe"===x.name,I=this.projectAndGetPerspectiveRatio(l,w,T,S,_,E||!!y||this.transform.pitch>0,x),{perspectiveRatio:A}=I,C=(d?s/A:s*A)/e.bX,M=tS(w,T,S,h),P=a.lineOffsetX*C,z=a.lineOffsetY*C,R=Math.cos(e.an(i.layers[0].layout.get("text-max-angle"))),D=I.signedDistanceFromCamera>0?tA(C,o,P,z,!1,M,b,a,n,h,{},y&&!d?v:null,d&&!!y,x,_,d,R):null,L=!1,O=!1,F=!0;if(D&&!I.occluded){let i=.5*f*A+m,a=new e.P(-100,-100),n=new e.P(this.screenRightBoundary,this.screenBottomBoundary),o=new ty,{first:s,last:l}=D,h=s.path.length,d=[];for(let e=h-1;e>=1;e--)d.push(s.path[e]);for(let e=1;e<l.path.length;e++)d.push(l.path[e]);let _=2.5*i;u&&(d=d.map(([e,i,r],a)=>(v&&!E&&(r=v(a<h-1?s.tilePath[h-1-a]:l.tilePath[a-h+2])[2]),tS(e,i,r,u)))).some(e=>e[3]<=0)&&(d=[]);let y=[];if(d.length>0){let i=1/0,r=-1/0,o=1/0,s=-1/0;for(let e of d)i=Math.min(i,e[0]),o=Math.min(o,e[1]),r=Math.max(r,e[0]),s=Math.max(s,e[1]);r>=a.x&&i<=n.x&&s>=a.y&&o<=n.y&&(y=[d.map(i=>new e.P(i[0],i[1]))],(i<a.x||r>n.x||o<a.y||s>n.y)&&(y=e.bV(y,a.x,a.y,n.x,n.y)))}for(let e of y){o.reset(e,.25*i);let a=0;a=o.length<=.5*i?1:Math.ceil(o.paddedLength/_)+1;for(let e=0;e<a;e++){let n=e/Math.max(a-1,1),s=o.lerp(n),l=s.x+100,h=s.y+100;g.push(l,h,i,0);let u=l-i,d=h-i,f=l+i,m=h+i;if(F=F&&this.isOffscreen(u,d,f,m),O=O||this.isInsideGrid(u,d,f,m),!r&&this.grid.hitTestCircle(l,h,i,p)&&(L=!0,!c))return{circles:[],offscreen:!1,collisionDetected:L,occluded:!1}}}}return{circles:(c||!L)&&O?g:[],offscreen:F,collisionDetected:L,occluded:I.occluded}}queryRenderedSymbols(i){if(0===i.length||0===this.grid.keysLength()&&0===this.ignoredGrid.keysLength())return{};let r=[],a=1/0,n=1/0,o=-1/0,s=-1/0;for(let l of i){let i=new e.P(l.x+100,l.y+100);a=Math.min(a,i.x),n=Math.min(n,i.y),o=Math.max(o,i.x),s=Math.max(s,i.y),r.push(i)}let l=this.grid.query(a,n,o,s).concat(this.ignoredGrid.query(a,n,o,s)),h={},u={};for(let i of l){let a=i.key;if(void 0===h[a.bucketInstanceId]&&(h[a.bucketInstanceId]={}),h[a.bucketInstanceId][a.featureIndex])continue;let n=[new e.P(i.x1,i.y1),new e.P(i.x2,i.y1),new e.P(i.x2,i.y2),new e.P(i.x1,i.y2)];e.bW(r,n)&&(h[a.bucketInstanceId][a.featureIndex]=!0,void 0===u[a.bucketInstanceId]&&(u[a.bucketInstanceId]=[]),u[a.bucketInstanceId].push(a.featureIndex))}return u}insertCollisionBox(e,i,r,a,n){(i?this.ignoredGrid:this.grid).insert({bucketInstanceId:r,featureIndex:a,collisionGroupID:n},e[0],e[1],e[2],e[3])}insertCollisionCircles(e,i,r,a,n){let o=i?this.ignoredGrid:this.grid,s={bucketInstanceId:r,featureIndex:a,collisionGroupID:n};for(let i=0;i<e.length;
8i+=4)o.insertCircle(s,e[i],e[i+1],e[i+2])}projectAndGetPerspectiveRatio(i,r,a,n,o,s,l){let h=[r,a,n,1],u=!1;n||this.transform.pitch>0?(e.aC(h,h,i),this.fogState&&o&&"globe"!==l.name&&(u=function(i,r,a,n,o,s){let l=s.calculateFogTileMatrix(o),h=[r,a,n];return e.af(h,h,l),ez(i,e.ag(h),s.pitch,s._fov)}(this.fogState,r,a,n,o.toUnwrapped(),this.transform)>.9)):tL(h,h,i);let c=h[3];return{point:new e.P((h[0]/c+1)/2*this.transform.width+100,(-h[1]/c+1)/2*this.transform.height+100),perspectiveRatio:Math.min(.5+this.transform.getCameraToCenterDistance(l)/c*.5,1.5),signedDistanceFromCamera:c,occluded:s&&h[2]>c||u}}isOffscreen(e,i,r,a){return r<100||e>=this.screenRightBoundary||a<100||i>this.screenBottomBoundary}isInsideGrid(e,i,r,a){return r>=0&&e<this.gridRightBoundary&&a>=0&&i<this.gridBottomBoundary}getViewportMatrix(){let i=e.bA([]);return e.br(i,i,[-100,-100,0]),i}}class tF{constructor(e,i,r,a){this.opacity=e?Math.max(0,Math.min(1,e.opacity+(e.placed?i:-i))):a&&r?1:0,this.placed=r}isHidden(){return 0===this.opacity&&!this.placed}}class tk{constructor(e,i,r,a,n,o=!1){this.text=new tF(e?e.text:null,i,r,n),this.icon=new tF(e?e.icon:null,i,a,n),this.clipped=o}isHidden(){return this.text.isHidden()&&this.icon.isHidden()}}class tB{constructor(e,i,r,a=!1){this.text=e,this.icon=i,this.skipFade=r,this.clipped=a}}class tN{constructor(){this.invProjMatrix=e.bC(),this.viewportMatrix=e.bC(),this.circles=[]}}class tV{constructor(e,i,r,a,n){this.bucketInstanceId=e,this.featureIndex=i,this.sourceLayerIndex=r,this.bucketIndex=a,this.tileID=n}}class tU{constructor(e){this.crossSourceCollisions=e,this.maxGroupID=0,this.collisionGroups={}}get(e){if(this.crossSourceCollisions)return{ID:0,predicate:null};if(!this.collisionGroups[e]){let i=++this.maxGroupID;this.collisionGroups[e]={ID:i,predicate:e=>e.collisionGroupID===i}}return this.collisionGroups[e]}}function tj(i,r,a,n,o){let{horizontalAlign:s,verticalAlign:l}=e.c0(i),h=e.c1(i,n);return new e.P(-(s-.5)*r+h[0]*o,-(l-.5)*a+h[1]*o)}function tG(i,r,a,n,o){let s=new e.P(i,r);return a&&s._rotate(n?o:-o),s}class tq{constructor(e,i,r,a,n,o){this.transform=e.clone(),this.projection=e.projection.name,this.collisionIndex=new tO(this.transform,n),this.buildingIndex=o,this.placements={},this.opacities={},this.variableOffsets={},this.stale=!1,this.commitTime=0,this.fadeDuration=i,this.retainedQueryData={},this.collisionGroups=new tU(r),this.collisionCircleArrays={},this.prevPlacement=a,a&&(a.prevPlacement=void 0),this.placedOrientations={}}getBucketParts(i,r,a,n,o=1){var s,l,h;let u=a.getBucket(r),c=a.latestFeatureIndex;if(!u||!c||r.fqid!==u.layerIds[0])return;let d=u.layers[0].layout,p=u.layers[0].paint,f=a.collisionBoxArray,m=Math.pow(2,this.transform.zoom-a.tileID.overscaledZ),_=a.tileSize/e.al,g=a.tileID.toUnwrapped();this.transform.setProjection(u.projection);let y=(s=a.tileID,l=u.getProjection(),h=this.transform,l.name===this.projection?h.calculateProjMatrix(s.toUnwrapped()):t_(h,l,s)),x="map"===d.get("text-pitch-alignment"),v="map"===d.get("text-rotation-alignment");r.compileFilter(r.options);let b=r.dynamicFilter(),w=r.dynamicFilterNeedsFeature(),T=this.transform.calculatePixelsToTileUnitsMatrix(a),S=tw(y,a.tileID.canonical,x,v,this.transform,u.getProjection(),T),E=null,I=u.getProjection().createInversionMatrix(this.transform,a.tileID.canonical);if(x){let i=tT(y,a.tileID.canonical,x,v,this.transform,u.getProjection(),T);E=e.aB([],this.transform.labelPlaneMatrix,i)}let A=null;b&&a.latestFeatureIndex&&(A={unwrappedTileID:g,dynamicFilter:b,dynamicFilterNeedsFeature:w}),this.retainedQueryData[u.bucketInstanceId]=new tV(u.bucketInstanceId,c,u.sourceLayerIndex,u.index,a.tileID);let[C,M]=u.layers[0].layout.get("text-size-scale-range"),P=e.aA(o,C,M),[z,R]=d.get("icon-size-scale-range"),D=e.aA(o,z,R),L={bucket:u,layout:d,paint:p,posMatrix:y,invMatrix:I,mercatorCenter:[e.aF(this.transform.center.lng),e.aJ(this.transform.center.lat)],textLabelPlaneMatrix:S,labelToScreenMatrix:E,clippingData:A,scale:m,textPixelRatio:_,holdingForFade:a.holdingForFade(),collisionBoxArray:f,partiallyEvaluatedTextSize:e.bK(u.textSizeData,this.transform.zoom,P),partiallyEvaluatedIconSize:e.bK(u.iconSizeData,this.transform.zoom,D),collisionGroup:this.collisionGroups.get(u.sourceID),latestFeatureIndex:a.latestFeatureIndex};if(n)for(let e of u.sortKeyRanges){let{sortKey:r,symbolInstanceStart:a,symbolInstanceEnd:n}=e;i.push({sortKey:r,symbolInstanceStart:a,symbolInstanceEnd:n,parameters:L})}else i.push({symbolInstanceStart:0,symbolInstanceEnd:u.symbolInstances.length,parameters:L})}attemptAnchorPlacement(e,i,r,a,n,o,s,l,h,u,c,d,p,f,m,_,g,y,x,v,b){let{textOffset0:w,textOffset1:T,crossTileID:S}=m,E=[w,T],I=tj(e,o,s,E,l),A=this.collisionIndex.placeCollisionBox(g,l,i,r,a,n,tG(I.x,I.y,h,u,this.transform.angle),f,c,d,p.predicate);if(x){let e=g.getSymbolInstanceIconSize(b,this.transform.zoom,m.placedIconSymbolIndex);if(0===this.collisionIndex.placeCollisionBox(g,e,x,r,a,n,tG(I.x,I.y,h,u,this.transform.angle),f,c,d,p.predicate).box.length)return}if(A.box.length>0){let i;return this.prevPlacement&&this.prevPlacement.variableOffsets[S]&&this.prevPlacement.placements[S]&&this.prevPlacement.placements[S].text&&(i=this.prevPlacement.variableOffsets[S].anchor),this.variableOffsets[S]={textOffset:E,width:o,height:s,anchor:e,textScale:l,prevAnchor:i},this.markUsedJustification(g,e,m,y),g.allowVerticalPlacement&&(this.markUsedOrientation(g,y,m),this.placedOrientations[S]=y),{shift:I,placedGlyphBoxes:A}}}placeLayerBucketPart(i,r,a,n,o=1){let{bucket:s,layout:l,paint:h,posMatrix:u,textLabelPlaneMatr
8ix:c,labelToScreenMatrix:d,clippingData:p,textPixelRatio:f,mercatorCenter:m,invMatrix:_,holdingForFade:g,collisionBoxArray:y,partiallyEvaluatedTextSize:x,partiallyEvaluatedIconSize:v,collisionGroup:b,latestFeatureIndex:w}=i.parameters,T=l.get("text-optional"),S=l.get("icon-optional"),E=l.get("text-allow-overlap"),I=l.get("icon-allow-overlap"),A="map"===l.get("text-rotation-alignment"),C="map"===l.get("icon-rotation-alignment"),M="map"===l.get("text-pitch-alignment"),P=h.get("symbol-z-offset"),z="sea"===l.get("symbol-elevation-reference"),R=l.get("symbol-placement"),[D,L]=l.get("text-size-scale-range"),[O,F]=l.get("icon-size-scale-range"),k=e.aA(o,D,L),B=e.aA(o,O,F),N=l.get("text-variable-anchor"),V=A&&"point"!==R,U=N&&s.hasTextData(),j=s.hasIconTextFit()&&U&&s.hasIconData();this.transform.setProjection(s.projection);let G=U||V,q=C&&"point"!==R||j,$=E&&(I||!s.hasIconData()||S),H=I&&(E||!s.hasTextData()||T),Z=!P.isConstant();!s.collisionArrays&&y&&s.deserializeCollisionBoxes(y),a&&n&&s.updateCollisionDebugBuffers(this.transform.zoom,y,k,B);let W=(i,n,o)=>{let{crossTileID:h,numVerticalGlyphVertices:y}=i,C=null;if(p&&p.dynamicFilterNeedsFeature||Z){let e=this.retainedQueryData[s.bucketInstanceId];C=w.loadFeature({featureIndex:i.featureIndex,bucketIndex:e.bucketIndex,sourceLayerIndex:e.s
8ourceLayerIndex,layoutVertexArrayOffset:0})}if(p&&!(0,p.dynamicFilter)({zoom:this.transform.zoom,pitch:this.transform.pitch},C,this.retainedQueryData[s.bucketInstanceId].tileID.canonical,new e.P(i.tileAnchorX,i.tileAnchorY),this.transform.calculateDistanceTileData(p.unwrappedTileID)))return this.placements[h]=new tB(!1,!1,!1,!0),void r.add(h);let R=P.evaluate(C,{});if(r.has(h))return;if(g)return void(this.placements[h]=new tB(!1,!1,!1));let D=!1,L=!1,O=!0,F=!1,k=!1,B=null,V={box:null,offscreen:null,occluded:null},U={box:null},j=null,W=null,X=null,Y=0,K=0,J=0;o.textFeatureIndex?Y=o.textFeatureIndex:i.useRuntimeCollisionCircles&&(Y=i.featureIndex),o.verticalTextFeatureIndex&&(K=o.verticalTextFeatureIndex);let Q=e=>{e.tileID=this.retainedQueryData[s.bucketInstanceId].tileID;let r=this.transform.elevation;e.elevation=z?R:R+(r?r.getAtTileOffset(e.tileID,e.tileAnchorX,e.tileAnchorY):0),e.elevation+=i.zOffset},ee=o.textBox;if(ee){Q(ee);let r=r=>{let a=e.bL.horizontal;if(s.allowVerticalPlacement&&!r&&this.prevPlacement){let e=this.prevPlacement.placedOrientations[h];e&&(this.placedOrientations[h]=e,a=e,this.markUsedOrientation(s,a,i))}return a},a=(i,r)=>{if(s.allowVerticalPlacement&&y>0&&o.verticalTextBox){for(let a of s.writingModes)if(a===e.bL.vertical?U=V=r():V=i(),V&&V.box&&V.box.length)break}else V=i()};if(N){let l=N;if(this.prevPlacement&&this.prevPlacement.variableOffsets[h]){let e=this.prevPlacement.variableOffsets[h];l.indexOf(e.anchor)>0&&(l=l.filter(i=>i!==e.anchor)).unshift(e.anchor)}let c=(e,r,a)=>{let o=s.getSymbolInstanceTextSize(x,i,this.transform.zoom,n),h=(e.x2-e.x1)*o+2*e.padding,c=(e.y2-e.y1)*o+2*e.padding,d=i.hasIconTextFit&&!I?r:null;d&&Q(d);let p={box:[],offscreen:!1,occluded:!1},g=E?2*l.length:l.length;for(let r=0;r<g;++r){let g=this.attemptAnchorPlacement(l[r%l.length],e,m,_,G,h,c,o,A,M,f,u,b,r>=l.length,i,n,s,a,d,x,v);if(g&&(p=g.placedGlyphBoxes)&&p.box&&p.box.length){D=!0,B=g.shift;break}}return p};a(()=>c(ee,o.iconBox,e.bL.horizontal),()=>{let i=o.verticalTextBox;return i&&Q(i),s.allowVerticalPlacement&&!(V&&V.box&&V.box.length)&&y>0&&i?c(i,o.verticalIconBox,e.bL.vertical):{box:null,offscreen:null,occluded:null}}),V&&(D=V.box,O=V.offscreen,F=V.occluded);let d=r(!(!V||!V.box));if(!D&&this.prevPlacement){let e=this.prevPlacement.variableOffsets[h];e&&(this.variableOffsets[h]=e,this.markUsedJustification(s,e.anchor,i,d))}}else{let l=(r,a)=>{let o=s.getSymbolInstanceTextSize(x,i,this.transform.zoom,n),l=this.collisionIndex.placeCollisionBox(s,o,r,m,_,G,new e.P(0,0),E,f,u,b.predicate);return l&&l.box&&l.box.length&&(this.markUsedOrientation(s,a,i),this.placedOrientations[h]=a),l};a(()=>l(ee,e.bL.horizontal),()=>{let i=o.verticalTextBox;return s.allowVerticalPlacement&&y>0&&i?(Q(i),l(i,e.bL.vertical)):{box:null,offscreen:null,occluded:null}}),r(!!(V&&V.box&&V.box.length))}}if(D=(j=V)&&j.box&&j.box.length>0,O=j&&j.offscreen,F=j&&j.occluded,i.useRuntimeCollisionCircles){let r=s.text.placedSymbolArray.get(i.centerJustifiedTextSymbolIndex>=0?i.centerJustifiedTextSymbolIndex:i.verticalPlacedTextSymbolIndex),n=e.bM(s.textSizeData,x,r),o=l.get("text-padding");W=this.collisionIndex.placeCollisionCircles(s,E,r,s.lineVertexArray,s.glyphOffsetArray,n,u,c,d,a,M,b.predicate,i.collisionCircleDiameter*n/e.bX,o,this.retainedQueryData[s.bucketInstanceId].tileID),D=E||W.circles.length>0&&!W.collisionDetected,O=O&&W.offscreen,F=W.occluded}if(o.iconFeatureIndex&&(J=o.iconFeatureIndex),o.iconBox){let r=r=>{Q(r);let a=i.hasIconTextFit&&B?tG(B.x,B.y,A,M,this.transform.angle):new e.P(0,0),n=s.getSymbolInstanceIconSize(v,this.transform.zoom,i.placedIconSymbolIndex);return this.collisionIndex.placeCollisionBox(s,n,r,m,_,q,a,I,f,u,b.predicate)};L=U&&U.box&&U.box.length&&o.verticalIconBox?(X=r(o.verticalIconBox)).box.length>0:(X=r(o.iconBox)).box.length>0,O=O&&X.offscreen,k=X.occluded}let et=T||0===i.numHorizontalGlyphVertices&&0===y,ei=S||0===i.numIconVertices;if(et||ei?ei?et||(L=L&&D):D=L&&D:L=D=L&&D,D&&j&&j.box&&this.collisionIndex.insertCollisionBox(j.box,l.get("text-ignore-placement"),s.bucketInstanceId,U&&U.box&&K?K:Y,b.ID),L&&X&&this.collisionIndex.insertCollisionBox(X.box,l.get("icon-ignore-placement"),s.bucketInstanceId,J,b.ID),W&&(D&&this.collisionIndex.insertCollisionCircles(W.circles,l.get("text-ignore-placement"),s.bucketInstanceId,Y,b.ID),a)){let e=s.bucketInstanceId,i=this.collisionCircleArrays[e];void 0===i&&(i=this.collisionCircleArrays[e]=new tN);for(let e=0;e<W.circles.length;e+=4)i.circles.push(W.circles[e+0]),i.circles.push(W.circles[e+1]),i.circles.push(W.circles[e+2]),i.circles.push(+!!W.collisionDetected)}let er="globe"!==s.projection.name;
8$=$&&(er||!F),H=H&&(er||!k),this.placements[h]=new tB(D||$,L||H,O||s.justReloaded),r.add(h)},X=this.retainedQueryData[s.bucketInstanceId].tileID;if("offset"===s.elevationType&&this.buildingIndex&&this.buildingIndex.updateZOffset(s,X),"road"===s.elevationType&&s.updateRoadElevation(X.canonical),s.updateZOffset(),s.sortFeaturesByY){let i=s.getSortedSymbolIndexes(this.transform.angle);for(let e=i.length-1;e>=0;--e){let r=i[e];W(s.symbolInstances.get(r),r,s.collisionArrays[r])}s.hasAnyZOffset&&e.w(`${s.layerIds[0]} layer symbol-z-elevate: symbols are not sorted by elevation if symbol-z-order is evaluated to viewport-y`)}else if(s.hasAnyZOffset){let e=s.getSortedIndexesByZOffset();for(let i=0;i<e.length;++i){let r=e[i];W(s.symbolInstances.get(r),r,s.collisionArrays[r])}}else for(let e=i.symbolInstanceStart;e<i.symbolInstanceEnd;e++)W(s.symbolInstances.get(e),e,s.collisionArrays[e]);if(a&&s.bucketInstanceId in this.collisionCircleArrays){let i=this.collisionCircleArrays[s.bucketInstanceId];e.bl(i.invProjMatrix,u),i.viewportMatrix=this.collisionIndex.getViewportMatrix()}s.justReloaded=!1}markUsedJustification(i,r,a,n){let{leftJustifiedTextSymbolIndex:o,centerJustifiedTextSymbolIndex:s,rightJustifiedTextSymbolIndex:l,verticalPlacedTextSymbolIndex:h,crossTileID:u}=a,c=e.c2(r),d=n===e.bL.vertical?h:"left"===c?o:"center"===c?s:"right"===c?l:-1;o>=0&&(i.text.placedSymbolArray.get(o).crossTileID=d>=0&&o!==d?0:u),s>=0&&(i.text.placedSymbolArray.get(s).crossTileID=d>=0&&s!==d?0:u),l>=0&&(i.text.placedSymbolArray.get(l).crossTileID=d>=0&&l!==d?0:u),h>=0&&(i.text.placedSymbolArray.get(h).crossTileID=d>=0&&h!==d?0:u)}markUsedOrientation(i,r,a){let n=r===e.bL.horizontal||r===e.bL.horizontalOnly?r:0,o=r===e.bL.vertical?r:0,{leftJustifiedTextSymbolIndex:s,centerJustifiedTextSymbolIndex:l,rightJustifiedTextSymbolIndex:h,verticalPlacedTextSymbolIndex:u}=a,c=i.text.placedSymbolArray;s>=0&&(c.get(s).placedOrientation=n),l>=0&&(c.get(l).placedOrientation=n),h>=0&&(c.get(h).placedOrientation=n),u>=0&&(c.get(u).placedOrientation=o)}commit(e){this.commitTime=e,this.zoomAtLastRecencyCheck=this.transform.zoom;let i=this.prevPlacement,r=!1;this.prevZoomAdjustment=i?i.zoomAdjustment(this.transform.zoom):0;let a=i?i.symbolFadeChange(e):1,n=i?i.opacities:{},o=i?i.variableOffsets:{},s=i?i.placedOrientations:{};for(let e in this.placements){let i=this.placements[e],o=n[e];o?(this.opacities[e]=new tk(o,a,i.text,i.icon,null,i.clipped),r=r||i.text!==o.text.placed||i.icon!==o.icon.placed):(this.opacities[e]=new tk(null,a,i.text,i.icon,i.skipFade,i.clipped),r=r||i.text||i.icon)}for(let e in n){let i=n[e];if(!this.opacities[e]){let n=new tk(i,a,!1,!1);n.isHidden()||(this.opacities[e]=n,r=r||i.text.placed||i.icon.placed)}}for(let e in o)this.variableOffsets[e]||!this.opacities[e]||this.opacities[e].isHidden()||(this.variableOffsets[e]=o[e]);for(let e in s)this.placedOrientations[e]||!this.opacities[e]||this.opacities[e].isHidden()||(this.placedOrientations[e]=s[e]);r?this.lastPlacementChangeTime=e:"number"!=typeof this.lastPlacementChangeTime&&(this.lastPlacementChangeTime=i?i.lastPlacementChangeTime:e)}updateLayerOpacities(e,i,r,a){let n=new Set;for(let o of i){let i=o.getBucket(e);i&&o.latestFeatureIndex&&e.fqid===i.layerIds[0]&&(this.updateBucketOpacities(i,n,o,o.collisionBoxArray,r,a,o.tileID,e.scope),"offset"===i.elevationType&&this.buildingIndex&&this.buildingIndex.updateZOffset(i,o.tileID),"road"===i.elevationType&&i.updateRoadElevation(o.tileID.canonical),i.updateZOffset())}}updateBucketOpacities(i,r,a,n,o,s,l,h){i.hasTextData()&&i.text.opacityVertexArray.clear(),i.hasIconData()&&i.icon.opacityVertexArray.clear(),i.hasIconCollisionBoxData()&&i.iconCollisionBox.collisionVertexArray.clear(),i.hasTextCollisionBoxData()&&i.textCollisionBox.collisionVertexArray.clear();let u=i.layers[0].layout,c=i.layers[0].paint,d=!!i.layers[0].dynamicFilter(),p=new tk(null,0,!1,!1,!0),f=u.get("text-allow-overlap"),m=u.get("icon-allow-overlap"),_=u.get("text-variable-anchor"),g="map"===u.get("text-rotation-alignment"),y="map"===u.get("text-pitch-alignment"),x=c.get("symbol-z-offset"),v="sea"===u.get("symbol-elevation-reference"),b=!x.isConstant(),w=new tk(null,0,f&&(m||!i.hasIconData()||u.get("icon-optional")),m&&(f||!i.hasTextData()||u.get("text-optional")),!0);!i.collisionArrays&&n&&(i.hasIconCollisionBoxData()||i.hasTextCollisionBoxData())&&i.deserializeCollisionBoxes(n);let T=(e,i,r)=>{for(let a=0;a<i/4;a++)e.opacityVertexArray.emplaceBack(r)},S=0;s&&i.updateReplacement(l,s);for(let n=0;n<i.symbolInstances.length;n++){let u=i.symbolInstances.get(n),{numHorizontalGlyphVertices:c,numVerticalGlyphVertices:f,crossTileID:m,numIconVertices:E,tileAnchorX:I,tileAnchorY:A}=u,C=null,M=this.retainedQueryData[i.bucketInstanceId];b&&u&&M&&(C=a.latestFeatureIndex.loadFeature({featureIndex:u.featureIndex,bucketIndex:M.bucketIndex,sourceLayerIndex:M.sourceLayerIndex,layoutVertexArrayOffset:0}));let P=x.evaluate(C,{}),z=r.has(m),R=this.opacities[m];z?R=p:R||(R=w,this.opacities[m]=R),r.add(m);let D=c>0||f>0,L=E>0,O=this.placedOrientations[m],F=O===e.bL.vertical,k=O===e.bL.horizontal||O===e.bL.horizontalOnly;!D&&!L||R.isHidden()||S++;let B=!1;if((D||L)&&s)for(let r of i.activeReplacements){if(e.bY(r,o,e.bZ.Symbol,h)||r.min.x>I||I>r.max.x||r.min.y>A||A>r.max.y)continue;let i=e.b_(I,A,l.canonical,r.footprintTileId.canonical);if(B=e.b$(i,r.footprint))break}if(D){let e=B?tZ:tH(R.text);T(i.text,c,F?tZ:e),T(i.text,f,k?tZ:e);let r=R.text.isHidden(),{leftJustifiedTextSymbolIndex:a,centerJustifiedTextSymbolIndex:n,rightJustifiedTextSymbolIndex:o,verticalPlacedTextSymbolIndex:s}=u,l=i.text.placedSymbolArray,h=r||F?1:0;a>=0&&(l.get(a).hidden=h),n>=0&&(l.get(n).hidden=h),o>=0&&(l.get(o).hidden=h),s>=0&&(l.get(s).hidden=r||k?1:0);let d=this.variableOffsets[m];d&&this.markUsedJustification(i,d.anchor,u,O);let p=this.placedOrientations[m];p&&(this.markUsedJustification(i,"left",u,p),this.markUsedOrientation(i,p,u))}if(L){let e=B?tZ:tH(R.icon),{placedIconSymbolIndex:r,verticalPlacedIconSymbolIndex:a}=u,n=i.icon.placedSymbolArray,o=+!!R.icon.isHidden();r>=0&&(T(i.icon,E,F?tZ:e),n.get(r).hidden=o),a>=0&&(T(i.icon,u.numVerticalIconVertices,k?tZ:e),n.get(a).hidden=o)}if(i.hasIconCollisionBoxData()||i.hasTextCollisionBoxData()){let r=i.collisionArrays[n];if(r){let a=new e.P(0,0),n=!0;if(r.textBox||r.verticalTextBox){if(_){let e=this.variableOffsets[m];e?(a=tj(e.anchor,e.width,e.height,e.textOffset,e.textScale),g&&a._rotate(y?this.transform.angle:-this.transform.angle)):n=!1}d&&(n=!R.clipped),r.textBox&&t$(i.textCollisionBox.collisionVertexArray,R.text.placed,!n||F,P,v,a.x,a.y),r.verticalTextBox&&t$(i.textCollisionBox.collisionVertexArray,R.text.placed,!n||k,P,v,a.x,a.y)}let o=n&&!!(!k&&r.verticalIconBox);r.iconBox&&t$(i.iconCollisionBox.collisionVertexArray,R.icon.placed,o,P,v,u.hasIconTextFit?a.x:0,u.hasIconTextFit?a.y:0),r.verticalIconBox&&t$(i.iconCollisionBox.collisionVertexArray,R.icon.placed,!o,P,v,u.hasIconTextFit?a.x:0,u.hasIconTextFit?a.y:0)}}}if(i.fullyClipped=0===S,i.sortFeatures(this.transform.angle),this.retainedQueryData[i.bucketInstanceId]&&(this.retainedQueryData[i.bucketInstanceId].featureSortOrder=i.featureSortOrder),i.hasTextData()&&i.text.opacityVertexBuffer&&i.text.opacityVertexBuffer.updateData(i.text.o
8pacityVertexArray),i.hasIconData()&&i.icon.opacityVertexBuffer&&i.icon.opacityVertexBuffer.updateData(i.icon.opacityVertexArray),i.hasIconCollisionBoxData()&&i.iconCollisionBox.collisionVertexBuffer&&i.iconCollisionBox.collisionVertexBuffer.updateData(i.iconCollisionBox.collisionVertexArray),i.hasTextCollisionBoxData()&&i.textCollisionBox.collisionVertexBuffer&&i.textCollisionBox.collisionVertexBuffer.updateData(i.textCollisionBox.collisionVertexArray),i.bucketInstanceId in this.collisionCircleArrays){let e=this.collisionCircleArrays[i.bucketInstanceId];i.placementInvProjMatrix=e.invProjMatrix,i.placementViewportMatrix=e.viewportMatrix,i.collisionCircleArray=e.circles,delete this.collisionCircleArrays[i.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,i){let r=this.zoomAtLastRecencyCheck===i?1-this.zoomAdjustment(i):1;return this.zoomAtLastRecencyCheck=i,this.commitTime+this.fadeDuration*r>e}setStale(){this.stale=!0}}function t$(e,i,r,a,n,o,s){e.emplaceBack(+!!i,+!!r,o||0,s||0,a,+!!n),e.emplaceBack(+!!i,+!!r,o||0,s||0,a,+!!n),e.emplaceBack(+!!i,+!!r,o||0,s||0,a,+!!n),e.emplaceBack(+!!i,+!!r,o||0,s||0,a,+!!n)}function tH(e){if(0===e.opacity&&!e.placed)return 0;if(1===e.opacity&&e.placed)return 0xffffffff;let i=+!!e.placed,r=Math.floor(127*e.opacity);return 0x2000000*r+0x1000000*i+131072*r+65536*i+512*r+256*i+2*r+i}let tZ=0;class tW{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,i,r,a,n,o){let s=this._bucketParts;for(;this._currentTileIndex<e.length;)if(i.getBucketParts(s,a,e[this._currentTileIndex],this._sortAcrossTiles,o),this._currentTileIndex++,n())return!0;for(this._sortAcrossTiles&&(this._sortAcrossTiles=!1,s.sort((e,i)=>e.sortKey-i.sortKey));this._currentPartIndex<s.length;){let e=s[this._currentPartIndex];if(i.placeLayerBucketPart(e,this._seenCrossTileIDs,r,0===e.symbolInstanceStart,o),this._currentPartIndex++,n())return!0}return!1}}class tX{constructor(e,i,r,a,n,o,s,l,h){this.placement=new tq(e,n,o,s,l,h),this._currentPlacementIndex=i.length-1,this._forceFullPlacement=r,this._showCollisionBoxes=a,this._done=!1}isDone(){return this._done}continuePlacement(i,r,a,n,o){let s=e.o.now(),l=()=>{let i=e.o.now()-s;return!this._forceFullPlacement&&i>2};for(;this._currentPlacementIndex>=0;){let s=r[i[this._currentPlacementIndex]],h=this.placement.collisionIndex.transform.zoom;if("symbol"===s.type&&(!s.minzoom||s.minzoom<=h)&&(!s.maxzoom||s.maxzoom>h)){let i=s.layout.get("symbol-z-elevate"),r=void 0!==s.layout.get("symbol-sort-key").constantOr(1),h=s.layout.get("symbol-z-order"),u="viewport-y"===h||"auto"===h&&!("viewport-y"!==h&&r),c=s.layout.get("text-allow-overlap")||s.layout.get("icon-allow-overlap")||s.layout.get("text-ignore-placement")||s.layout.get("icon-ignore-placement"),d=u&&c,p=this._inProgressLayer=this._inProgressLayer||new tW(s),f=e.B(s.source,s.scope);if(p.continuePlacement(i||d?n[f]:a[f],this.placement,this._showCollisionBoxes,s,l,o))return;delete this._inProgressLayer}this._currentPlacementIndex--}this._done=!0}commit(e){return this.placement.commit(e),this.placement}}let tY=512/e.al/2;class tK{constructor(i,r,a){this.tileID=i,this.bucketInstanceId=a,this.index=new e.c3(r.length,16,Int32Array),this.keys=[],this.crossTileIDs=[];let n=i.canonical.x*e.al,o=i.canonical.y*e.al;for(let e=0;e<r.length;e++){let{key:i,crossTileID:a,tileAnchorX:s,tileAnchorY:l}=r.get(e),h=Math.floor((n+s)*tY),u=Math.floor((o+l)*tY);this.index.add(h,u),this.keys.push(i),this.crossTileIDs.push(a)}this.index.finish()}findMatches(i,r,a){let n=this.tileID.canonical.z<r.canonical.z?1:Math.pow(2,this.tileID.canonical.z-r.canonical.z),o=tY/Math.pow(2,r.canonical.z-this.tileID.canonical.z),s=r.canonical.x*e.al,l=r.canonical.y*e.al;for(let e=0;e<i.length;e++){let r=i.get(e);if(r.crossTileID)continue;let{key:h,tileAnchorX:u,tileAnchorY:c}=r,d=Math.floor((s+u)*o),p=Math.floor((l+c)*o);for(let e of this.index.range(d-n,p-n,d+n,p+n).sort((e,i)=>e-i)){let i=this.crossTileIDs[e];if(this.keys[e]===h&&!a.has(i)){a.add(i),r.crossTileID=i;break}}}}}class tJ{constructor(){this.maxCrossTileID=0}generate(){return++this.maxCrossTileID}}class tQ{constructor(){this.indexes={},this.usedCrossTileIDs={},this.lng=0}handleWrapJump(e){let i=Math.round((e-this.lng)/360);if(0!==i)for(let e in this.indexes){let r=this.indexes[e],a={};for(let e in r){let n=r[e];n.tileID=n.tileID.unwrapTo(n.tileID.wrap+i),a[n.tileID.key]=n}this.indexes[e]=a}this.lng=e}addBucket(e,i,r){if(this.indexes[e.overscaledZ]&&this.indexes[e.overscaledZ][e.key]){if
8(this.indexes[e.overscaledZ][e.key].bucketInstanceId===i.bucketInstanceId)return!1;this.removeBucketCrossTileIDs(e.overscaledZ,this.indexes[e.overscaledZ][e.key])}for(let e=0;e<i.symbolInstances.length;e++)i.symbolInstances.get(e).crossTileID=0;this.usedCrossTileIDs[e.overscaledZ]||(this.usedCrossTileIDs[e.overscaledZ]=new Set);let a=this.usedCrossTileIDs[e.overscaledZ];for(let r in this.indexes){let n=this.indexes[r];if(Number(r)>e.overscaledZ)for(let r in n){let o=n[r];o.tileID.isChildOf(e)&&o.findMatches(i.symbolInstances,e,a)}else{let o=n[e.scaledTo(Number(r)).key];o&&o.findMatches(i.symbolInstances,e,a)}}for(let e=0;e<i.symbolInstances.length;e++){let n=i.symbolInstances.get(e);n.crossTileID||(n.crossTileID=r.generate(),a.add(n.crossTileID))}return void 0===this.indexes[e.overscaledZ]&&(this.indexes[e.overscaledZ]={}),this.indexes[e.overscaledZ][e.key]=new tK(e,i.symbolInstances,i.bucketInstanceId),!0}removeBucketCrossTileIDs(e,i){for(let r of i.crossTileIDs)this.usedCrossTileIDs[e].delete(r)}removeStaleBuckets(e){let i=!1;for(let r in this.indexes){let a=this.indexes[r];for(let n in a)e[a[n].bucketInstanceId]||(this.removeBucketCrossTileIDs(r,a[n]),delete a[n],i=!0)}return i}}class t0{constructor(){this.layerIndexes={},this.crossTileIDs=new tJ,this.maxBucketInstanceId=0,this.bucketsInCurrentPlacement={}}addLayer(e,i,r,a){let n=this.layerIndexes[e.fqid];void 0===n&&(n=this.layerIndexes[e.fqid]=new tQ);let o=!1,s={};for(let l of("globe"!==a.name&&n.handleWrapJump(r),i)){let i=l.getBucket(e);i&&e.fqid===i.layerIds[0]&&(i.bucketInstanceId||(i.bucketInstanceId=++this.maxBucketInstanceId),n.addBucket(l.tileID,i,this.crossTileIDs)&&(o=!0),s[i.bucketInstanceId]=!0)}return n.removeStaleBuckets(s)&&(o=!0),o}pruneUnusedLayers(e){let i={};for(let r in e.forEach(e=>{i[e]=!0}),this.layerIndexes)i[r]||delete this.layerIndexes[r]}}class t1{constructor(e,i,r,a){this.blendFunction=e,this.blendColor=i.toNonPremultipliedRenderColor(null),this.mask=r,this.blendEquation=a}}t1.Replace=[1,0,1,0],t1.disabled=new t1(t1.Replace,e.ao.transparent,[!1,!1,!1,!1]),t1.unblended=new t1(t1.Replace,e.ao.transparent,[!0,!0,!0,!0]),t1.alphaBlended=new t1([1,771,1,771],e.ao.transparent,[!0,!0,!0,!0]),t1.alphaBlendedNonPremultiplied=new t1([770,771,770,771],e.ao.transparent,[!0,!0,!0,!0]),t1.multiply=new t1([774,0,774,0],e.ao.transparent,[!0,!0,!0,!0]);class t2{constructor(e,i,r){this.func=e,this.mask=i,this.range=r}}t2.ReadOnly=!1,t2.ReadWrite=!0,t2.disabled=new t2(519,t2.ReadOnly,[0,1]);class t3{constructor(e,i,r,a,n,o){this.test=e,this.ref=i,this.mask=r,this.fail=a,this.depthFail=n,this.pass=o}}t3.disabled=new t3({func:519,mask:0},0,0,7680,7680,7680);class t5{constructor(e,i,r){this.enable=e,this.mode=i,this.frontFace=r}}function t4(i,r){let a=e.c9(i,3);e.cb(i,r),e.cf(i,3,a)}function t6(i,r){let a=e.c6([]);return e.c7(a,a,-r),e.c8(a,a,-i),a}function t8(i,r){let a=[i[0],i[1],0],n=[r[0],r[1],0];if(e.ag(a)>=1e-15){let i=e.aw([],a);e.c4(n,i,e.bJ(n,i)),r[0]=n[0],r[1]=n[1]}let o=e.bI([],r,i);if(1e-15>e.c5(o))return null;let s=Math.atan2(-o[1],o[0]);return t6(Math.atan2(Math.sqrt(i[0]*i[0]+i[1]*i[1]),-i[2]),s)}t5.disabled=new t5(!1,1029,2305),t5.backCCW=new t5(!0,1029,2305),t5.backCW=new t5(!0,1029,2304),t5.frontCW=new t5(!0,1028,2304),t5.frontCCW=new t5(!0,1028,2305);class t9{constructor(e,i){this.position=e,this.orientation=i}get position(){return this._position}set position(i){if(i){let r=i instanceof e.ae?i:new e.ae(i[0],i[1],i[2]);
8this._renderWorldCopies&&(r.x=e.bT(r.x,0,1)),this._position=r}else this._position=null}lookAtPoint(i,r){if(this.orientation=null,!this.position)return;let a=this.position,n=this._elevation?this._elevation.getAtPointOrZero(e.ae.fromLngLat(i)):0,o=e.ae.fromLngLat(i,n),s=[o.x-a.x,o.y-a.y,o.z-a.z];r||(r=[0,0,1]),r[2]=Math.abs(r[2]),this.orientation=t8(s,r)}setPitchBearing(i,r){this.orientation=t6(e.an(i),e.an(-r))}}class t7{constructor(i,r){this._transform=e.bA([]),this.orientation=r,this.position=i}get mercatorPosition(){let i=this.position;return new e.ae(i[0],i[1],i[2])}get position(){let i=e.c9(this._transform,3);return[i[0],i[1],i[2]]}set position(i){i&&e.cf(this._transform,3,[i[0],i[1],i[2],1])}get orientation(){return this._orientation}set orientation(i){this._orientation=i||e.c6([]),i&&t4(this._transform,this._orientation)}getPitchBearing(){let e=this.forward(),i=this.right();return{bearing:Math.atan2(-i[1],i[0]),pitch:Math.atan2(Math.sqrt(e[0]*e[0]+e[1]*e[1]),-e[2])}}setPitchBearing(e,i){this._orientation=t6(e,i),t4(this._transform,this._orientation)}forward(){let i=e.c9(this._transform,2);return[-i[0],-i[1],-i[2]]}up(){let i=e.c9(this._transform,1);return[-i[0],-i[1],-i[2]]}right(){let i=e.c9(this._transform,0);return[i[0],i[1],i[2]]}getCameraToWorld(i,r){let a=new Float64Array(16);return e.bl(a,this.getWorldToCamera(i,r)),a}getCameraToWorldMercator(){return this._transform}getWorldToCameraPosition(i,r,a){let n=this.position;e.c4(n,n,-i);let o=new Float64Array(16);return e.bq(o,[a,a,a]),e.br(o,o,n),o[10]*=r,o}getWorldToCamera(i,r){let a=new Float64Array(16),n=new Float64Array(4),o=this.position;return e.ca(n,this._orientation),e.c4(o,o,-i),e.cb(a,n),e.br(a,a,o),a[1]*=-1,a[5]*=-1,a[9]*=-1,a[13]*=-1,a[8]*=r,a[9]*=r,a[10]*=r,a[11]*=r,a}getCameraToClipPerspective(i,r,a,n){let o=new Float64Array(16);return e.cc(o,i,r,a,n),o}getCameraToClipOrthographic(i,r,a,n,o,s){let l=new Float64Array(16);return e.cd(l,i,r,a,n,o,s),l}getDistanceToElevation(i,r=!1){let a=0===i?0:e.ce(i,r?e.a$(this.position[1]):this.position[1]),n=this.forward();return(a-this.position[2])/n[2]}clone(){return new t7([...this.position],[...this.orientation])}}class ie{constructor(e=0,i=0,r=0,a=0){if(isNaN(e)||e<0||isNaN(i)||i<0||isNaN(r)||r<0||isNaN(a)||a<0)throw Error("Invalid value for edge-insets, top, bottom, left and right must all be numbers");this.top=e,this.bottom=i,this.left=r,this.right=a}interpolate(i,r,a){return null!=r.top&&null!=i.top&&(this.top=e.ak(i.top,r.top,a)),null!=r.bottom&&null!=i.bottom&&(this.bottom=e.ak(i.bottom,r.bottom,a)),null!=r.left&&null!=i.left&&(this.left=e.ak(i.left,r.left,a)),null!=r.right&&null!=i.right&&(this.right=e.ak(i.right,r.right,a)),this}getCenter(i,r){let a=e.aA((this.left+i-this.right)/2,0,i),n=e.aA((this.top+r-this.bottom)/2,0,r);return new e.P(a,n)}equals(e){return this.top===e.top&&this.bottom===e.bottom&&this.left===e.left&&this.right===e.right}clone(){return new ie(this.top,this.bottom,this.left,this.right)}toJSON(){return{top:this.top,bottom:this.bottom,left:this.left,right:this.right}}}class it{constructor(i,r,a,n,o,s,l){this.tileSize=512,this._renderWorldCopies=void 0===o||o,this._minZoom=i||0,this._maxZoom=r||22,this._minPitch=a??0,this._maxPitch=n??60,this.setProjection(s),this.setMaxBounds(l),this.width=0,this.height=0,this._center=new e.aR(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 ie,this._projMatrixCache={},this._alignedProjMatrixCache={},this._fogTileMatrixCache={},this._expandedProjMatrixCache={},this._distanceTileDataCache={},this._camera=new t7,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(){let e=new it(this._minZoom,this._maxZoom,this._minPitch,this.maxPitch,this._renderWorldCopies,this.getProjection(),this.maxBounds);return e._elevation=this._elevation,e._centerAltitude=this._centerAltitude,e._centerAltitudeValidForE
8xaggeration=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<15}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,i=!1){let r=this._elevation&&this._elevation.exaggeration()!==this._centerAltitudeValidForE
8xaggeration;(null==this._seaLevelZoom||r)&&this._updateCameraOnTerrain(),(e||r)&&this._constrainCamera(i),this._calcMatrices()}getProjection(){return e.aH(this.projection,["name","center","parallels"])}setProjection(i){this.projectionOptions=i||{name:"mercator"};let r=this.projection?this.getProjection():void 0;this.projection=e.cl(this.projectionOptions);let a=this.getProjection(),n=!e.by(r,a);return n&&this._calcMatrices(),this.mercatorFromTransition=!1,n}setOrthographicProjectionAtLowPitch(e){return this._orthographicProjectionAtLowPitch!==e&&(this._orthographicProjectionAtLowPitch=e,this._calcMatrices(),!0)}setMercatorFromTransition(){let i=this.projection.name;this.mercatorFromTransition=!0,this.projectionOptions={name:"mercator"},this.projection=e.cl({name:"mercator"});let r=i!==this.projection.name;return r&&this._calcMatrices(),r}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(){let e=Math.max(this._camera.getDistanceToElevation(this._averageElevation),Number.EPSILON);return this._worldSizeFromZoom(this._zoomFromMercatorZ(e))}get cameraWorldSize(){let e=Math.max(this._camera.getDistanceToElevation(this._averageElevation,!0),Number.EPSILON);return this._worldSizeFromZoom(this._zoomFromMercatorZ(e))}get pixelsPerMeter(){return this.projection.pixelsPerMeter(this.center.lat,this.worldSize)}get cameraPixelsPerMeter(){return e.ce(1,this.center.lat)*this.cameraWorldSizeForFog}get centerOffset(){return this.centerPoint._sub(this.size._div(2))}get size(){return new e.P(this.width,this.height)}get bearing(){return e.bT(this.rotation,-180,180)}set bearing(e){this.rotation=e}get rotation(){return-this.angle/Math.PI*180}set rotation(i){let r=-i*Math.PI/180;this.angle!==r&&(this._unmodified=!1,this.angle=r,this._calcMatrices(),this.rotationMatrix=e.cm(),e.cn(this.rotationMatrix,this.rotationMatrix,this.angle))}get pitch(){return this._pitch/Math.PI*180}set pitch(i){let r=e.aA(i,this.minPitch,this.maxPitch)/180*Math.PI;this._pitch!==r&&(this._unmodified=!1,this._pitch=r,this._calcMatrices())}get aspect(){return this.width/this.height}get fov(){return this._fov/Math.PI*180}set fov(i){i=Math.max(.01,Math.min(60,i)),this._fov!==i&&(this._unmodified=!1,this._fov=e.an(i),this._calcMatrices())}get fovX(){return this._fov}get fovY(){let 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){let i=Math.min(Math.max(e,this.minZoom),this.maxZoom);this._zoom!==i&&(this._unmodified=!1,this._setZoom(i),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(){let e=this.elevation?this.elevation.getAtPoint(this.locationCoordinate(this.center),-1/0):-1/0,i=this.elevation&&e===-1/0&&this.elevation.visibleDemTiles.length>0&&this.elevation.exaggeration()>
80&&this._centerAltitudeValidForExaggeration;if(!this._elevation||e===-1/0&&(!i||!this._centerAltitude))return this._centerAltitude=0,this._seaLevelZoom=null,void(this._centerAltitudeValidForExaggeration=void 0);let r=this._elevation;i||this._centerAltitude&&this._centerAltitudeValidForExaggeration&&r.exaggeration()&&this._centerAltitudeValidForExaggeration!==r.exaggeration()?this._centerAltitude=this._centerAltitude/this._centerAltitudeValidForExaggeration*r.exaggeration():this._centerAltitude=e||0,this._centerAltitudeValidForExaggeration=r.exaggeration(),this._updateSeaLevelZoom()}_updateSeaLevelZoom(){if(void 0===this._centerAltitudeValidForExaggeration)return;let e=Math.max(0,(this.pixelsPerMeter*this._centerAltitude+this.cameraToCenterDistance)/this.worldSize);this._seaLevelZoom=this._zoomFromMercatorZ(e)}sampleAverageElevation(){if(!this._elevation)return 0;let i=this._elevation,r=[[.5,.2],[.3,.5],[.5,.5],[.7,.5],[.5,.8]],a=this.horizonLineFromTop(),n=0,o=0;for(let s=0;s<r.length;s++){let l=new e.P(r[s][0]*this.width,a+r[s][1]*(this.height-a)),h=i.pointCoordinate(l);if(!h)continue;let u=1/Math.hypot(h[0]-this._camera.position[0],h[1]-this._camera.position[1]);n+=h[3]*u,o+=u}return 0===o?NaN:n/o}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;let e=this._seaLevelZoom,i=this._elevation.getAtPointOrZero(this.locationCoordinate(this.center)),r=this.pixelsPerMeter/this.worldSize*i,a=Math.max(this._mercatorZfromZoom(e)-r,this._mercatorZfromZoom(this._maxZoom));this._setZoom(this._zoomFromMercatorZ(a))}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())}computeZoomRelativeTo(i){let r,a=this.rayIntersectionCoordinate(this.pointRayIntersection(this.centerPoint,i.toAltitude()));r=i.z<this._camera.position[2]?[a.x,a.y,a.z]:[i.x,i.y,i.z];let n=e.ag(e.av([],this._camera.position,r));return e.aA(this._zoomFromMercatorZ(n),this._minZoom,this._maxZoom)}setFreeCameraOptions(i){if(!this.height||!i.position&&!i.orientation)return;this._updateCameraState();let r=!1;if(i.orientation&&!e.co(i.orientation,this._camera.orientation)&&(r=this._setCameraOrientation(i.orientation)),i.position){let a=[i.position.x,i.position.y,i.position.z];e.cp(a,this._camera.position)||(this._setCameraPosition(a),r=!0)}r&&(this._updateStateFromCamera(),this.recenterOnTerrain())}getFreeCameraOptions(){this._updateCameraState();let i=this._camera.position,r=new t9;return r.position=new e.ae(i[0],i[1],i[2]),r.orientation=this._camera.orientation,r._elevation=this.elevation,r._renderWorldCopies=this.renderWorldCopies,r}_setCameraOrientation(i){if(!e.cq(i))return!1;e.cr(i,i);let r=e.cs([],[0,0,-1],i),a=e.cs([],[0,-1,0],i);if(a[2]<0)return!1;let n=t8(r,a);return!!n&&(this._camera.orientation=n,!0)}_setCameraPosition(i){let r=this.zoomScale(this.minZoom)*this.tileSize,a=this.zoomScale(this.maxZoom)*this.tileSize,n=this.cameraToCenterDistance;i[2]=e.aA(i[2],n/a,n/r),this._camera.position=i}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,i,r){this._unmodified=!1,this._edgeInsets.interpolate(e,i,r),this._constrain(),this._calcMatrices()}coveringZoomLevel(e){return Math.max(0,(e.roundZoom?Math.round:Math.floor)(this.zoom+this.scaleZoom(this.tileSize/e.tileSize)))}getVisibleUnwrappedCoordinates(i){let r=[new e.ct(0,i)];if(this.renderWorldCopies){let a=this.pointCoordinate(new e.P(0,0)),n=this.pointCoordinate(new e.P(this.width,0)),o=this.pointCoordinate(new e.P(this.width,this.height)),s=this.pointCoordinate(new e.P(0,this.height)),l=Math.floor(Math.min(a.x,n.x,o.x,s.x)),h=Math.floor(Math.max(a.x,n.x,o.x,s.x));for(let a=l-1;a<=h+1;a++)0!==a&&r.push(new e.ct(a,i))}return r}isLODDisabled(e){return(!e||this.pitch<=60)&&this._edgeInsets.top<=this._edgeInsets.bottom&&!this._elevation&&!this.projection.isReprojectedInTileSpace}extendTileCover(i,r,a){let n=[],o=null!=a,s=!o;if(s&&this.zoom<r||o&&0===a[0]&&0===a[1])return n;let l=new Set,h=(i,r,a,o,s)=>{let h=e.cX(r,i,a,o,s);l.has(h)||(n.push(new e.aO(i,r,a,o,s)),l.add(h))};for(let e=0;e<i.length;e++){let n=i[e];if(s&&n.canonical.z!==r)continue;let l=n.canonical,u=n.overscaledZ,c=n.wrap,d=1<<l.z,p=l.x+1<d,f=l.x>0,m=l.y+1<d,_=l.y>0,g=n.wrap-!f,y=n.wrap+ +!p,x=f?l.x-1:d-1,v=p?l.x+1:0;if(o)a[0]<0?(h(u,y,l.z,v,l.y),a[1]<0&&m&&(h(u,c,l.z,l.x,l.y+1),h(u,y,l.z,v,l.y+1)),a[1]>0&&_&&(h(u,c,l.z,l.x,l.y-1),h(u,y,l.z,v,l.y-1))):a[0]>0?(h(u,g,l.z,x,l.y),a[1]<0&&m&&(h(u,c,l.z,l.x,l.y+1),h(u,g,l.z,x,l.y+1)),a[1]>0&&_&&(h(u,c,l.z,l.x,l.y-1),h(u,g,l.z,x,l.y-1))):a[1]<0&&m?h(u,c,l.z,l.x,l.y+1):_&&h(u,c,l.z,l.x,l.y-1);else{let e=n.visibleQuadrants;1&e&&(h(u,g,l.z,x,l.y),_&&(h(u,c,l.z,l.x,l.y-1),h(u,g,l.z,x,l.y-1))),2&e&&(h(u,y,l.z,v,l.y),_&&(h(u,c,l.z,l.x,l.y-1),h(u,y,l.z,v,l.y-1))),4&e&&(h(u,g,l.z,x,l.y),m&&(h(u,c,l.z,l.x,l.y+1),h(u,g,l.z,x,l.y+1))),8&e&&(h(u,y,l.z,v,l.y),m&&(h(u,c,l.z,l.x,l.y+1),h(u,y,l.z,v,l.y+1)))}}let u=[];for(let e of n)n.some(i=>e.isChildOf(i))||u.push(e);if(n=u.filter(e=>!i.some(i=>!!(e.overscaledZ<r&&i.isChildOf(e))||e.equals(i)||e.isChildOf(i))),s){let e=1<<r,i="globe"===this.projection.name?this._camera.mercatorPosition:this.pointCoordinate(this.getCameraPoint()),a=[e*i.x,e*i.y];n=n.filter(e=>{let i=e.canonical.x+.5-a[0],r=e.canonical.y+.5-a[1];return i*i+r*r<16})}return n}extendTileCoverToNearPlane(i,r,a){let n=[],o=new Set;for(let e of i)o.add(e.key);let s=(i,r,a,s,l)=>{let h=e.cX(r,i,a,s,l);o.has(h)||(n.push(new e.aO(i,r,a,s,l)),o.add(h))},l=i.reduce((e,i)=>
8Math.max(e,i.overscaledZ),a),h=1<<a,u=[new e.P(0,0),new e.P(e.al,0),new e.P(e.al,e.al),new e.P(0,e.al)],c=new e.P(0,0),d=new e.P(0,0),p=(i,r)=>{let n=Math.floor(i[0]),o=Math.floor(i[1]),p=(i[0]-n)*e.al,f=(i[1]-o)*e.al,m=Math.floor(r[0]),_=Math.floor(r[1]),g=(r[0]-m)*e.al,y=(r[1]-_)*e.al;for(let i=-1;i<=1;i++){let r=n+i;if(!(r<0||r>=h)){c.x=p-i*e.al,d.x=g-(r-m)*e.al;for(let i=-1;i<=1;i++){let n=o+i;c.y=f-i*e.al,d.y=y-(n-_)*e.al,e.cY(c,d,u)&&s(l,0,a,r,n)}}}},f=r.points,m=f[e.cu],_=f[e.cv],g=this._projectToGround(m,f[e.cw]),y=this._projectToGround(_,f[e.cx]);return p(m,g),p(_,y),n}_projectToGround(i,r){return e.cy(e.cz(),i,r,i[2]/(i[2]-r[2]))}coveringTiles(i){let r,a=this.coveringZoomLevel(i),n=a,o=this.elevation&&this.elevation.exaggeration(),s=o&&!i.isTerrainDEM,l="mercator"===this.projection.name;if(void 0!==i.minzoom&&a<i.minzoom)return[];void 0!==i.maxzoom&&a>i.maxzoom&&(a=i.maxzoom);let h=this.locationCoordinate(this.center),u=this.center.lat,c=1<<a,d=[c*h.x,c*h.y,0],p="globe"===this.projection.name,f=!p,m=e.cA.fromInvProjectionMatrix(this.invProjMatrix,this.worldSize,a,f),_=p?this._camera.mercatorPosition:this.pointCoordinate(this.getCameraPoint()),g=c*e.ce(1,this.center.lat),y=this._camera.position[2]/e.ce(1,this.center.lat),x=[c*_.x,c*_.y,y*(f?1:g)],v=p||o,b=this.cameraToCenterDistance/i.tileSize*(i.roundZoom?1:.502),w=this.isLODDisabled(!0)?a:0;if(this._elevation&&i.isTerrainDEM)r=1e4*this._elevation.exaggeration();else if(this._elevation){let e=this._elevation.getMinMaxForVisibleTiles();r=e?e.max:this._centerAltitude}else r=this._centerAltitude;let T=i.isTerrainDEM?-r:this._elevation?this._elevation.getMinElevationBelowMSL():0,S=this.projection.isReprojectedInTileSpace?e.cB(this):1,E=i=>{let r=1/4e4,a=new e.ae(i.x+r,i.y,i.z),n=new e.ae(i.x,i.y+r,i.z),o=i.toLngLat(),s=a.toLngLat(),l=n.toLngLat(),h=this.locationCoordinate(o),u=this.locationCoordinate(s),c=this.locationCoordinate(l);return Math.sqrt(Math.hypot(u.x-h.x,u.y-h.y)*Math.hypot(c.x-h.x,c.y-h.y))*S/r},I=i=>{let a=r;return{aabb:e.cE(this,c,0,0,0,i,T,a,this.projection),zoom:0,x:0,y:0,minZ:T,maxZ:a,wrap:i,fullyVisible:!1}},A=[],C=[],M=a,P=i.reparseOverscaled?n:a,z=(y-this._centerAltitude)*g,R=e=>{if(!this._elevation||!e.tileID||!l)return;let i=this._elevation.getMinMaxForTile(e.tileID),r=e.aabb;i?(r.min[2]=i.min,r.max[2]=i.max,r.center[2]=(r.min[2]+r.max[2])/2):(e.shouldSplit=L(e),e.shouldSplit||(r.min[2]=r.max[2]=r.center[2]=this._centerAltitude))},D=(e,i)=>{if(.707*i<e)return 1;let r=i/e;return r/(1.4144271570014144+(Math.pow(1.1,r-1.4144271570014144+1)-1)/(1.1-1)-1)},L=i=>{if(i.zoom<w)return!0;if(i.zoom===M)return!1;if(null!=i.shouldSplit)return i.shouldSplit;let r=i.aabb.distanceX(x),a=i.aabb.distanceY(x),o=z,h=1;if(p){o=i.aabb.distanceZ(x);let r=Math.pow(2,i.zoom),a=Math.min(Math.max(u,e.a$((i.y+1)/r)),e.a$(i.y/r)),n=e.d0(a)/e.d0(u);if(h=a===u?1/Math.max(1,this._mercatorScaleRatio-.3):Math.min(1,n/this._mercatorScaleRatio),this.zoom<=e.cZ&&i.zoom===M-1&&n>=.9)return!0}else if(s&&(o=i.aabb.distanceZ(x)*g),this.projection.isReprojectedInTileSpace&&n<=5){let r=Math.pow(2,i.zoom),a=E(new e.ae((i.x+.5)/r,(i.y+.5)/r));h=a>.85?1:a}if(!l){let e=Math.sqrt(r*r+a*a+o*o),n=(1<<M-i.zoom)*b*h;return n*=D(Math.max(o,z),e),e<n}let c=Number.MAX_VALUE,f=0,m=i.aabb.getCorners(),_=[];for(let i of m){e.av(_,i,x),p||(s?_[2]*=g:_[2]=z);let r=e.bJ(_,this._camera.forward());r<c&&(c=r,f=Math.abs(_[2]))}let y=(1<<M-i.zoom)*b*h;if(y*=D(Math.max(f,z),c),c<y)return!0;let v=i.aabb.closestPoint(d);return v[0]===d[0]&&v[1]===d[1]};if(this.renderWorldCopies)for(let e=1;e<=3;e++)A.push(I(-e)),A.push(I(e));for(A.push(I(0));A.length>0;){let r=A.pop(),n=r.x,o=r.y,h=r.fullyVisible,u=()=>"globe"===this.projection.name&&(0===r.y||r.y===(1<<r.zoom)-1);if(!h){let i=v?r.aabb.intersects(m):r.aabb.intersectsFlat(m);if(0===i&&u()){let a=new e.cC(r.zoom,n,o);i=e.cD(this,c,a,!0).intersects(m)}if(0===i)continue;h=2===i}if(r.zoom!==M&&L(r))for(let i=0;i<4;i++){let a=(n<<1)+i%2,u=(o<<1)+(i>>1),d={aabb:l?r.aabb.quadrant(i):e.cE(this,c,r.zoom+1,a,u,r.wrap,r.minZ,r.maxZ,this.projection),zoom:r.zoom+1,x:a,y:u,wrap:r.wrap,fullyVisible:h,tileID:void 0,shouldSplit:void 0,minZ:r.minZ,maxZ:r.maxZ};s&&!p&&(d.tileID=new e.aO(r.zoom+1===M?P:r.zoom+1,r.wrap,r.zoom+1,a,u),R(d)),A.push(d)}else{let s=r.zoom===M?P:r.zoom;if(i.minzoom&&i.minzoom>s)continue;let l=0;if(!h){let a=v?r.aabb.intersectsPrecise(m):r.aabb.intersectsPreciseFlat(m);if(0===a&&u()){let i=new e.cC(r.zoom,n,o);a=e.cD(this,c,i,!0).intersectsPrecise(m)}if(0===a)continue;if(i.calculateQuadrantVisibility)if(m.containsPoint(r.aabb.center))l=15;else for(let e=0;e<4;e++)0!==r.aabb.quadrant(e).intersects(m)&&(l|=1<<e)}let p=d[0]-(.5+n+(r.wrap<<r.zoom))*(1<<a-r.zoom),f=d[1]-.5-o,_=r.tileID?r.tileID:new e.aO(s,r.wrap,r.zoom,n,o);i.calculateQuadrantVisibility&&(_.visibleQuadrants=l),C.push({tileID:_,distanceSq:p*p+f*f})}}if(this.fogCullDistSq){let a=this.fogCullDistSq,n=this.horizonLineFromTop();C=C.filter(o=>{let s=[0,0,0,1],l=[e.al,e.al,0,1],h=this.calculateFogTileMatrix(o.tileID.toUnwrapped());e.aC(s,s,h),e.aC(l,l,h);let u=e.cF([],s,l),c=e.cG([],s,l),d=e.c_(u,c);if(0===d)return!0;let p=!1,f=this._elevation;if(f&&d>a&&0!==n){let a,s=this.calculateProjMatrix(o.tileID.toUnwrapped());i.isTerrainDEM||(a=f.getMinMaxForTile(o.tileID)),a||(a={min:T,max:r});let l=e.cH(this.rotation),h=[l[0]*e.al,l[1]*e.al,a.max];e.af(h,h,s),p=(1-h[1])*this.height*.5<n}return d<a||p})}return C.sort((e,i)=>e.distanceSq-i.distanceSq).map(e=>e.tileID)}resize(e,i){this.width=e,this.height=i,this.pixelsToGLUnits=[2/e,-2/i],this._constrain(),this._calcMatrices()}get unmodified(){return this._unmodified}zoomScale(e){return Math.pow(2,e)}scaleZoom(e){return Math.log2(e)}project(i){let r=e.aA(i.lat,-e.cI,e.cI),a=this.projection.project(i.lng,r);return new e.P(a.x*this.worldSize,a.y*this.worldSize)}unproject(e){return this.projection.unproject(e.x/this.worldSize,e.y/this.worldSize)}get point(){return this.project(this.center)}get pointMerc(){return this.point._div(this.worldSize)}get pixelsPerMeterRatio(){return this.pixelsPerMeter/e.ce(1,this.center.lat)/this.worldSize}setLocationAtPoint(i,r){let a,n,o=this.centerPoint;if("globe"===this.projection.name){let e=this.worldSize;a=(r.x-o.x)/e,n=(r.y-o.y)/e}else{let e=this.pointCoordinate(r),i=this.pointCoordinate(o);a=e.x-i.x,n=e.y-i.y}let s=this.locationCoordinate(i);this.setLocation(new e.ae(s.x-a,s.y-n))}setLocation(e){this.center=this.coordinateLocation(e),this.projection.wrap&&(this.center=this.center.wrap())}locationPoint(e,i){return this.projection.locationPoint(this,e,i)}locationPoint3D(e,i){return this.projection.locationPoint(this,e,i,!0)}pointLocation(e){return this.coordinateLocation(this.pointCoordinate(e))}pointLocation3D(e,i){return this.coordinateLocation(this.pointCoordinate3D(e,i))}locationCoordinate(i,r){let a=r?e.ce(r,i.lat):void 0,n=this.projection.project(i.lng,i.lat);return new e.ae(n.x,n.y,a)}coordinateLocation(e){return this.projection.unproject(e.x,e.y)}pointRayIntersection(i,r){let a=null!=r?r:this._centerAltitude,n=[i.x,i.y,0,1],o=[i.x,i.y,1,1];e.aC(n,n,this.pixelMatrixInverse),e.aC(o,o,this.pixelMatrixInverse);let s=o[3];e.cJ(n,n,1/n[3]),e.cJ(o,o,1/s);let l=n[2],h=o[2];return{p0:n,p1:o,t:l===h?0:(a-l)/(h-l)}}screenPointToMercatorRay(i){let r=[i.x,i.y,0,1],a=[i.x,i.y,1,1];return e.aC(r,r,this.pixelMatrixInverse),e.aC(a,a,this.pixelMatrixInverse),e.cJ(r,r,1/r[3]),e.cJ(a,a,1/a[3]),r[2]=e.ce(r[2],this._center.lat)*this.worldSize,a[2]=e.ce(a[2],this._center.lat)*this.worldSize,e.cJ(r,r,1/this.worldSize),e.cJ(a,a,1/this.worldSize),new e.ax([r[0],r[1],r[2]],e.aw([],e.av([],a,r)))}rayIntersectionCoordinate(i){let{p0:r,p1:a,t:n}=i,o=e.ce(r[2],this._center.lat),s=e.ce(a[2],this._center.lat);return new e.ae(e.ak(r[0],a[0],n)/this.worldSize,e.ak(r[1],a[1],n)/this.worldSize,e.ak(o,s,n))}pointCoordinate(e,i=this._centerAltitude){return this.projection.pointCoordinate(this,e.x,e.y,i)}pointCoordinate3D(i,r){if(!this.elevation)return this.pointCoordinate(i,r);let a=this.projection.pointCoordinate3D(this,i.x,i.y);if(a)return new e.ae(a[0],a[1],a[2]);let n=0,o=this.horizonLineFromTop();if(i.y>o)return this.pointCoordinate(i,r);let s=.02*o,l=i.clone();for(let i=0;i<10&&o-n>s;i++){l.y=e.ak(n,o,.66);let i=this.projection.pointCoordinate3D(this,l.x,l.y);i?(o=l.y,a=i):n=l.y}return a?new e.ae(a[0],a[1],a[2]):this.pointCoordinate(i)}isPointAboveHorizon(e){return this.projection.isPointAboveHorizon(this,e)}isPointOnSurface(i){if(i.y<0||i.y>this.height||i.x<0||i.x>this.width)return!1;if(this.elevation||this.zoom>=e.cK)return!this.isPointAboveHorizon(i);let r=this.pointCoordinate(i);return r.y>=0&&r.y<=1}_coordinatePoint(i,r){let a=r&&this.elevation?this.elevation.getAtPointOrZero(i,this._centerAltitude):this._centerAltitude,n=[i.x*this.worldSize,i.y*this.worldSize,a+i.toAltitude(),1];return e.aC(n,n,this.pixelMatrix),n[3]>
80?new e.P(n[0]/n[3],n[1]/n[3]):new e.P(Number.MAX_VALUE,Number.MAX_VALUE)}_getBoundsNonRectangular(){let{top:i,left:r}=this._edgeInsets,a=this.height-this._edgeInsets.bottom,n=this.width-this._edgeInsets.right,o=this.pointLocation3D(new e.P(r,i)),s=this.pointLocation3D(new e.P(n,i)),l=this.pointLocation3D(new e.P(n,a)),h=this.pointLocation3D(new e.P(r,a)),u=Math.min(o.lng,s.lng,l.lng,h.lng),c=Math.max(o.lng,s.lng,l.lng,h.lng),d=Math.min(o.lat,s.lat,l.lat,h.lat),p=Math.max(o.lat,s.lat,l.lat,h.lat),f=Math.pow(2,-this.zoom)/16*270,m="globe"===this.projection.name?1:4,_=(i,r,a,n,o)=>{let s=(i+a)/2,l=(r+n)/2,h=new e.P(s,l),{lng:g,lat:y}=this.pointLocation3D(h),x=Math.max(0,u-g,d-y,g-c,y-p);u=Math.min(u,g),c=Math.max(c,g),d=Math.min(d,y),p=Math.max(p,y),(o<m||x>f)&&(_(i,r,s,l,o+1),_(s,l,a,n,o+1))};if(_(r,i,n,i,1),_(n,i,n,a,1),_(n,a,r,a,1),_(r,a,r,i,1),"globe"===this.projection.name){let[i,r]=e.cL(this);i?(p=90,c=180,u=-180):r&&(d=-90,c=180,u=-180)}return new e.aI(new e.aR(u,d),new e.aR(c,p))}_getBoundsRectangular(i,r){let{top:a,left:n}=this._edgeInsets,o=this.height-this._edgeInsets.bottom,s=this.width-this._edgeInsets.right,l=new e.P(n,a),h=new e.P(s,a),u=new e.P(s,o),c=new e.P(n,o),d=this.pointCoordinate(l,i),p=this.pointCoordinate(h,i),f=this.pointCoordinate(u,r),m=this.pointCoordinate(c,r),_=(e,i)=>(i.y-e.y)/(i.x-e.x);return d.y>1&&p.y>=0?d=new e.ae((1-m.y)/_(m,d)+m.x,1):d.y<0&&p.y<=1&&(d=new e.ae(-m.y/_(m,d)+m.x,0)),p.y>1&&d.y>=0?p=new e.ae((1-f.y)/_(f,p)+f.x,1):p.y<0&&d.y<=1&&(p=new e.ae(-f.y/_(f,p)+f.x,0)),(new e.aI).extend(this.coordinateLocation(d)).extend(this.coordinateLocation(p)).extend(this.coordinateLocation(m)).extend(this.coordinateLocation(f))}_getBoundsRectangularTerrain(){let e=this.elevation;if(!e.visibleDemTiles.length||e.isUsingMockSource())return this._getBoundsRectangular(0,0);let i=e.visibleDemTiles.reduce((e,i)=>{if(i.dem){let r=i.dem.tree;e.min=Math.min(e.min,r.minimums[0]),e.max=Math.max(e.max,r.maximums[0])}return e},{min:Number.MAX_VALUE,max:0});return this._getBoundsRectangular(i.min*e.exaggeration(),i.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){let i=this.height/2/Math.tan(this._fov/2)/Math.tan(Math.max(this._pitch,.1))-this.centerOffset.y,r=this.height/2-i*(1-this._horizonShift);return e?Math.max(0,r):r}getMaxBounds(){return this.maxBounds}setMaxBounds(i){this.maxBounds=i,this.minLat=-e.cI,this.maxLat=e.cI,this.minLng=-180,this.maxLng=180,i&&(this.minLat=i.getSouth(),this.maxLat=i.getNorth(),this.minLng=i.getWest(),this.maxLng=i.getEast(),this.maxLng<this.minLng&&(this.maxLng+=360)),this.worldMinX=e.aF(this.minLng)*this.tileSize,this.worldMaxX=e.aF(this.maxLng)*this.tileSize,this.worldMinY=e.aJ(this.maxLat)*this.tileSize,this.worldMaxY=e.aJ(this.minLat)*this.tileSize,this._constrain()}calculatePosMatrix(e,i){return this.projection.createTileMatrix(this,i,e)}calculateDistanceTileData(i){let r=i.key,a=this._distanceTileDataCache;if(a[r])return a[r];let n=i.canonical,o=1/this.height,s=this.cameraWorldSize,l=s/this.zoomScale(n.z),h=(n.x+Math.pow(2,n.z)*i.wrap)*l,u=n.y*l,c=this.point;c.x*=s/this.worldSize,c.y*=s/this.worldSize;let d=this.angle,p=Math.sin(-d),f=-Math.cos(-d);return a[r]={bearing:[p,f],center:[(c.x-h)*o,(c.y-u)*o],scale:l/e.al*o},a[r]}calculateFogTileMatrix(i){let r=i.key,a=this._fogTileMatrixCache;if(a[r])return a[r];let n=this.projection.createTileMatrix(this,this.cameraWorldSizeForFog,i);return e.aB(n,this.worldToFogMatrix,n),a[r]=new Float32Array(n),a[r]}calculateProjMatrix(i,r=!1,a=!1){let n,o,s=i.key;if((n=a?this._expandedProjMatrixCache:r?this._alignedProjMatrixCache:this._projMatrixCache)[s])return n[s];let l=this.calculatePosMatrix(i,this.worldSize);return o=this.projection.isReprojectedInTileSpace?this.mercatorMatrix:a?this.expandedFarZProjMatrix:r?this.alignedProjMatrix:this.projMatrix,e.aB(l,o,l),n[s]=new Float32Array(l),n[s]}calculatePixelsToTileUnitsMatrix(i){let r=i.tileID.key,a=this._pixelsToTileUnitsCache;if(a[r])return a[r];let n=e.cM(i,this);return a[r]=n,a[r]}customLayerMatrix(){return this.mercatorMatrix.slice()}globeToMercatorMatrix(){if("globe"===this.projection.name){let i=1/this.worldSize,r=e.bq([],[i,i,i]);return e.aB(r,r,this.globeMatrix),r}}recenterOnTerrain(){if(!this._elevation||"globe"===this.projection.name)return;let i=this._elevation;this._updateCameraState();let r=e.ce(1,this._center.lat)*this.worldSize,a=this._computeCameraPosition(r),n=this._camera.forward(),o=e.ce(1,this._center.lat);a[2]/=o,n[2]/=o,e.aw(n,n);let s=i.raycast(a,n,i.exaggeration());if(s){let i=e.bH([],a,n,s),r=new e.ae(i[0],i[1],e.ce(i[2],e.a$(i[1]))),l=(r.z+e.ag([r.x-a[0],r.y-a[1],r.z-a[2]*o]))*this._pixelsPerMercatorPixel;this._seaLevelZoom=this._zoomFromMercatorZ(l),this._centerAltitude=r.toAltitude(),this._center=this.coordinateLocation(r),this._updateZoomFromElevation(),this._constrain(),this._calcMatrices()}}_constrainCamera(i=!1){if(!this._elevation)return;let r=this._elevation,a=e.ce(1,this._center.lat)*this.worldSize,n=this._computeCameraPosition(a),o=r.getAtPointOrZero(new e.ae(...n)),s=this.pixelsPerMeter/this.worldSize*o,l=this._minimumHeightOverTerrain(),h=n[2]-s;if(h<=l)if(h<0||i){let i=this.locationCoordinate(this._center,this._centerAltitude),r=[n[0],n[1],i.z-n[2]],a=e.ag(r);r[2]-=(l-h)/this._pixelsPerMercatorPixel;let o=e.ag(r);if(0===o)return;e.c4(r,r,a/o*this._pixelsPerMercatorPixel),this._camera.position=[n[0],n[1],i.z*this._pixelsPerMercatorPixel-r[2]],this._updateStateFromCamera()}else this._isCameraConstrained=!0}_constrain(){if(!this.center||!this.width||!this.height||this._constraining)return;this._constraining=!0;let i="globe"===this.projection.name||this.mercatorFromTransition;if(this.projection.isReprojectedInTileSpace||i){let r=this.center;return r.lat=e.aA(r.lat,this.minLat,this.maxLat),!this.maxBounds&&(this.renderWorldCopies||i)||(r.lng=e.aA(r.lng,this.minLng,this.maxLng)),this.center=r,void(this._constraining=!1)}let r=this._unmodified,{x:a,y:n}=this.point,o=0,s=a,l=n,h=this.width/2,u=this.height/2,c=this.worldMinY*this.scale,d=this.worldMaxY*this.scale;if(n-u<c&&(l=c+u),n+u>d&&(l=d-u),d-c<this.height&&(o=Math.max(o,this.height/(d-c)),l=(d+c)/2),this.maxBounds||!this._renderWorldCopies||!this.projection.wrap){let e=this.worldMinX*this.scale,i=this.worldMaxX*this.scale,r=this.worldSize/2-(e+i)/2;(s=(a+r+this.worldSize)%this.worldSize-r)-h<e&&(s=e+h),s+h>i&&(s=i-h),i-e<this.width&&(o=Math.max(o,this.width/(i-e)),s=(i+e)/2)}s===a&&l===n||this._allowWorldUnderZoom||(this.center=this.unproject(new e.P(s,l))),o&&!this._allowWorldUnderZoom&&(this.zoom+=this.scaleZoom(o)),this._constrainCamera(),this._unmodified=r,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(){let i;if(!this.height)return;let r=this.centerOffset,a="globe"===this.projection.name,n=this.pixelsPerMeter;"globe"===this.projection.name&&(this._mercatorScaleRatio=e.ce(1,this.center.lat)/e.ce(1,e.d1));let o=e.cN(this.projection,this.zoom,this.width,this.height,1024);this._pixelsPerMercatorPixel=this.projection.pixelSpaceConversion(this.center.lat,this.worldSize,o),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;let s="meters"===this.projection.zAxisUnit?n:1,l=this._camera.getWorldToCamera(this.worldSize,s),h=this._camera.getCameraToClipPerspective(this._fov,this.width/this.height,this._nearZ,this._farZ);if(h[8]=-(2*r.x)/this.width,h[9]=2*r.y/this.height,this.isOrthographic){let a=.5*this.height/Math.tan(this._fov/2)*1*Math.tan(.5*this._fov),n=a*this.aspect,o=-n,s=-a;n-=r.x,o-=r.x,a+=r.y,s+=r.y,((i,r,a,n)=>{for(let o=0;o<16;o++)i[o]=e.ak(r[o],a[o],n)})(i=this._camera.getCameraToClipOrthographic(o,n,s,a,this._nearZ,this._farZ),i,h,e.c$(this.pitch>=15?1:this.pitch/15))}else i=h;let u=e.cO([],h,l),c=e.cO([],i,l);if(this.projection.isReprojectedInTileSpace){let i=this.locationCoordinate(this.center),r=e.bA([]);e.br(r,r,[i.x*this.worldSize,i.y*this.worldSize,0]),e.aB(r,r,e.cP(this)),e.br(r,r,[-i.x*this.worldSize,-i.y*this.worldSize,0]),e.aB(c,c,r),e.aB(u,u,r),this.inverseAdjustmentMatrix=e.cQ(this)}else this.inverseAdjustmentMatrix=[1,0,0,1];if(this.mercatorMatrix=e.cR([],c,[this.worldSize,this.worldSize,this.worldSize/s,1]),this.projMatrix=c,this.invProjMatrix=e.bl(new Float64Array(16),this.projMatrix),a){let i=this._camera.getCameraToClipPerspective(this._fov,this.width/this.height,this._nearZ,1/0);i[8]=-(2*r.x)/this.width,i[9]=2*r.y/this.height,this.expandedFarZProjMatrix=e.cO([],i,l)}else this.expandedFarZProjMatrix=this.projMatrix;let d=e.bl([],i);this.frustumCorners=e.cS.fromInvProjectionMatrix(d,this.horizonLineFromTop(),this.height),this.cameraFrustum=e.cA.fromInvProjectionMatrix(this.invProjMatrix,this.worldSize,0,!a);let p=new Float32Array(16);e.bA(p),e.cR(p,p,[1,-1,1]),e.cT(p,p,this._pitch),e.bB(p,p,this.angle);let f=e.cc(new Float32Array(16),this._fov,this.width/this.height,this._nearZ,this._farZ);this.starsProjMatrix=e.bz(f);let m=(Math.PI/2-this._pitch)*(this.height/this._fov)*this._horizonShift;f[8]=-(2*r.x)/this.width,f[9]=2*(r.y+m)/this.height,this.skyboxMatrix=e.aB(p,f,p);let _=this.point,g=_.x,y=_.y,x=this.width%2/2,v=this.height%2/2,b=Math.cos(this.angle),w=Math.sin(this.angle),T=g-
8Math.round(g)+b*x+w*v,S=y-Math.round(y)+b*v+w*x,E=new Float64Array(c);if(e.br(E,E,[T>.5?T-1:T,S>.5?S-1:S,0]),this.alignedProjMatrix=E,c=e.bC(),e.cR(c,c,[this.width/2,-this.height/2,1]),e.br(c,c,[1,-1,0]),this.labelPlaneMatrix=c,c=e.bC(),e.cR(c,c,[1,-1,1]),e.br(c,c,[-1,-1,0]),e.cR(c,c,[2/this.width,2/this.height,1]),this.glCoordMatrix=c,this.pixelMatrix=e.aB(new Float64Array(16),this.labelPlaneMatrix,u),this._calcFogMatrices(),this._distanceTileDataCache={},!(c=e.bl(new Float64Array(16),this.pixelMatrix)))throw Error("failed to invert matrix");if(this.pixelMatrixInverse=c,"globe"===this.projection.name||this.mercatorFromTransition){this.globeMatrix=e.cU(this);let i=[this.globeMatrix[12],this.globeMatrix[13],this.globeMatrix[14]];this.globeCenterInViewSpace=e.af(i,i,l),this.globeRadius=this.worldSize/2/Math.PI-1}else this.globeMatrix=c;this._projMatrixCache={},this._alignedProjMatrixCache={},this._pixelsToTileUnitsCache={},this._expandedProjMatrixCache={}}_calcFogMatrices(){this._fogTileMatrixCache={};let i=this.cameraWorldSizeForFog,r=this.cameraPixelsPerMeter,a=this._camera.position,n=1/this.height/this._pixelsPerMercatorPixel,o=[i,i,r];e.c4(o,o,n),e.c4(a,a,-1),e.cV(a,a,o);let s=e.bC();e.br(s,s,a),e.cR(s,s,o),this.mercatorFogMatrix=s,this.worldToFogMatrix=this._camera.getWorldToCameraPosition(i,r,n)}_computeCameraPosition(e){let i=(e=e||this.pixelsPerMeter)/this.pixelsPerMeter,r=this._camera.forward(),a=this.point,n=this._mercatorZfromZoom(this._seaLevelZoom?this._seaLevelZoom:this._zoom)*i-e/this.worldSize*this._centerAltitude;return[a.x/this.worldSize-r[0]*n,a.y/this.worldSize-r[1]*n,e/this.worldSize*this._centerAltitude-r[2]*n]}_updateCameraState(){this.height&&(this._camera.setPitchBearing(this._pitch,this.angle),this._camera.position=this._computeCameraPosition())}_translateCameraConstrained(i){let r=this._maxCameraBoundsDistance()*Math.cos(this._pitch),a=this._camera.position[2],n=i[2],o=1;this.projection.wrap&&(this.center=this.center.wrap()),n>0&&(o=Math.min((r-a)/n,1)),this._camera.position=e.bH([],this._camera.position,i,o),this._updateStateFromCamera()}_updateStateFromCamera(){let i=this._camera.position,r=this._camera.forward(),{pitch:a,bearing:n}=this._camera.getPitchBearing(),o=e.ce(this._centerAltitude,this.center.lat)*this._pixelsPerMercatorPixel,s=this._mercatorZfromZoom(this._maxZoom)*Math.cos(e.an(this._maxPitch)),l=Math.max((i[2]-o)/Math.cos(a),s),h=this._zoomFromMercatorZ(l);e.bH(i,i,r,l),this._pitch=e.aA(a,e.an(this.minPitch),e.an(this.maxPitch)),this.angle=e.bT(n,-Math.PI,Math.PI),this._setZoom(e.aA(h,this._minZoom,this._maxZoom)),this._updateSeaLevelZoom(),this._center=this.coordinateLocation(new e.ae(i[0],i[1],i[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(){let 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(i){let r=0,a=e.cK,n=0,o=1/0;for(;a-r>1e-6&&a>r;){let e=r+.5*(a-r),s=this.tileSize*Math.pow(2,e),l=this.getCameraToCenterDistance(this.projection,e,s),h=this.scaleZoom(l/(Math.max(0,i)*this.tileSize)),u=Math.abs(e-h);u<o&&(o=u,n=e),e<h?r=e:a=e}return n}_terrainEnabled(){return!(!this._elevation||!this.projection.supportsTerrain&&(e.w("Terrain is not yet supported with alternate projections. Use mercator or globe to enable terrain."),1))}anyCornerOffEdge(i,r){let a=Math.min(i.x,r.x),n=Math.max(i.x,r.x),o=Math.min(i.y,r.y),s=Math.max(i.y,r.y);if(o<this.horizonLineFromTop(!1))return!0;if("mercator"!==this.projection.name)return!1;let l=[new e.P(a,o),new e.P(n,s),new e.P(a,s),new e.P(n,o)],h=this.renderWorldCopies?-3:0,u=this.renderWorldCopies?4:1;for(let e of l){let i=this.pointRayIntersection(e);if(i.t<0)return!0;let r=this.rayIntersectionCoordinate(i);if(r.x<h||r.y<0||r.x>u||r.y>1)return!0}return!1}isHorizonVisible(){return this.pitch+e.cW(this.fovAboveCenter)>88||this.anyCornerOffEdge(new e.P(0,0),new e.P(this.width,this.height))}zoomDeltaToMovement(i,r){let a=e.ag(e.av([],this._camera.position,i)),n=this._zoomFromMercatorZ(a)+r;return a-this._mercatorZfromZoom(n)}getCameraPoint(){if("globe"===this.projection.name){let i=function([i,r,a],n){let o=[i,r,a,1];e.aC(o,o,n);let s=o[3]=Math.max(o[3],1e-6);return o[0]/=s,o[1]/=s,o[2]/=s,o}([this.globeMatrix[12],this.globeMatrix[13],this.globeMatrix[14]],this.pixelMatrix);return new e.P(i[0],i[1])}{let i=Math.tan(this._pitch)*(this.cameraToCenterDistance||1);return this.centerPoint.add(new e.P(0,i))}}getCameraToCenterDistance(i,r=this.zoom,a=this.worldSize){let n=e.cN(i,r,this.width,this.height,1024),o=i.pixelSpaceConversion(this.center.lat,a,n),s=.5/Math.tan(.5*this._fov)*this.height*o;return this.isOrthographic&&(s=e.ak(1,s,e.c$(this.pitch>=15?1:this.pitch/15))),s}getWorldToCameraMatrix(){let i=this._camera.getWorldToCamera(this.worldSize,"meters"===this.projection.zAxisUnit?this.pixelsPerMeter:1);return"globe"===this.projection.name&&e.aB(i,i,this.globeMatrix),i}getFrustum(i){return e.cA.fromInvProjectionMatrix(this.invProjMatrix,this.worldSize,i,"meters"===this.projection.zAxisUnit)}}let ii=(i,r)=>{if(r>0&&i.terrain&&e.w("Cutoff is currently disabled on terrain"),r<=0||i.terrain)return{shouldRenderCutoff:!1,uniformValues:{u_cutoff_params:[0,0,0,1]}};let a=i.transform,n=Math.max(Math.abs(a._zoom-(i.minCutoffZoom-1)),1),o=a.isLODDisabled(!1)?e.ah(60,45,a.pitch):e.ah(30,15,a.pitch),s=a._farZ-a._nearZ,l=r*a.height,h=((1-o)*a.cameraToCenterDistance+o*(a._farZ+l))*n;return{shouldRenderCutoff:o<1,uniformValues:{u_cutoff_params:[a._nearZ,a._farZ,(h-a._nearZ)/s,(h-l-a._nearZ)/s]}}},ir={cascadeCount:2,normalOffset:3,shadowMapResolution:2048};class ia{constructor(e,i){this.aabb=e,this.lastCascade=i}}class io{add(e,i){let r=this.receivers[e.key];void 0!==r?(r.aabb.min[0]=Math.min(r.aabb.min[0],i.min[0]),r.aabb.min[1]=Math.min(r.aabb.min[1],i.min[1]),r.aabb.min[2]=Math.min(r.aabb.min[2],i.min[2]),r.aabb.max[0]=Math.max(r.aabb.max[0],i.max[0]),r.aabb.max[1]=Math.max(r.aabb.max[1],i.max[1]),r.aabb.max[2]=Math.max(r.aabb.max[2],i.max[2])):this.receivers[e.key]=new ia(i,null)}clear(){this.receivers={}}get(e){return this.receivers[e.key]}computeRequiredCascades(i,r,a){let n=e.d8.fromPoints(i.points),o=0;for(let i in this.receivers){let s=this.receivers[i];if(!s||!n.intersectsAabb(s.aabb))continue;s.aabb.min=n.closestPoint(s.aabb.min),s.aabb.max=n.closestPoint(s.aabb.max);let l=s.aabb.getCorners();for(let i=0;i<a.length;i++){let n=!0;for(let o of l){let s=[o[0]*r,o[1]*r,o[2]];if(e.af(s,s,a[i].matrix),s[0]<-1||s[0]>1||s[1]<-1||s[1]>1){n=!1;break}}if(s.lastCascade=i,o=Math.max(o,i),n)break}}return o+1}}class is{constructor(e){this.painter=e,this._enabled=!1,this._shadowLayerCount=0,this._numCascadesToRender=0,this._cascades=[],this._groundShadowTiles=[],this._receivers=new io,this._depthMode=new t2(e.context.gl.LEQUAL,t2.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,e.tp.registerParameter(this,["Shadows"],"_forceDisable",{label:"forceDisable"},()=>{this.painter.style.map.triggerRepaint()}),e.tp.registerParameter(ir,["Shadows"],"cascadeCount",{min:1,max:2,step:1}),e.tp.registerParameter(ir,["Shadows"],"normalOffset",{min:0,max:10,step:.
805}),e.tp.registerParameter(ir,["Shadows"],"shadowMapResolution",{min:32,max:2048,step:32}),e.tp.registerBinding(this,["Shadows"],"_numCascadesToRender",{readonly:!0,label:"numCascadesToRender"})}destroy(){for(let e of this._cascades)e.texture.destroy(),e.framebuffer.destroy();this._cascades=[]}updateShadowParameters(i,r){let a=this.painter;if(this._enabled=!1,this._shadowLayerCount=0,this._receivers.clear(),!r||!r.properties)return;let n=r.properties.get("shadow-intensity");if(!r.shadowsEnabled()||n<=0||(this._shadowLayerCount=a.style.order.reduce((e,r)=>{let n=a.style._mergedLayers[r];return e+(n.hasShadowPass()&&!n.isHidden(i.zoom)?1:0)},0),this._enabled=this._shadowLayerCount>0,!this.enabled))return;let o=a.context,s=ir.shadowMapResolution,l=ir.shadowMapResolution;if(0===this._cascades.length||ir.shadowMapResolution!==this._cascades[0].texture.size[0]){this._cascades=[];for(let i=0;i<ir.cascadeCount;++i){let i=a._shadowMapDebug,r=o.gl,n=o.createFramebuffer(s,l,i,"texture"),h=new e.T(o,{width:s,height:l,data:null},r.DEPTH_COMPONENT16);if(n.depthAttachment.set(h.texture),i){let i=new e.T(o,{width:s,height:l,data:null},r.RGBA8);n.colorAttachment.set(i.texture)}this._cascades.push({framebuffer:n,texture:h,matrix:[],far:0,boundingSphereRadius:0,frustum:new e.cA,scale:0})}}this.shadowDirection=ih(r);let h=0;if(i.elevation){let e=i.elevation,r=[1e4,-1e4];e.visibleDemTiles.filter(e=>e.dem).forEach(e=>{let i=e.dem.tree;r[0]=Math.min(r[0],i.minimums[0]),r[1]=Math.max(r[1],i.maximums[0])}),1e4!==r[0]&&(h=(r[1]-r[0])*e.exaggeration())}let u=1.5*i.cameraToCenterDistance,c=3*u,d=new Float64Array(16);for(let r=0;r<this._cascades.length;++r){let a=this._cascades[r],n=i.height/50,o=1;1===ir.cascadeCount?o=c:0===r?o=u:(n=u,o=c);let[s,l]=function(i,r,a,n,o,s){let l,h,u=i.zoom,c=i.scale,d=i.worldSize,p=1/d,f=i.aspect,m=Math.sqrt(1+f*f)*Math.tan(.5*i.fovX),_=m*m,g=n-a,y=n+a;_>g/y?(l=n,h=n*m):(l=.5*y*(1+_),h=.5*Math.sqrt(g*g+2*(n*n+a*a)*_+y*y*_*_));let x=i.projection.pixelsPerMeter(i.center.lat,d),v=i._camera.getCameraToWorldMercator(),b=[0,0,-l*p];e.af(b,b,v);let w=h*p,T=i._edgeInsets;if((0!==T.left||0!==T.top||0!==T.right||0!==T.bottom)&&(T.left!==T.right||T.top!==T.bottom)){let r=i._camera.getWorldToCamera(i.worldSize,"meters"===i.projection.zAxisUnit?x:1),o=i._camera.getCameraToClipPerspective(i._fov,i.width/i.height,a,n);o[8]=-(2*i.centerOffset.x)/i.width,o[9]=2*i.centerOffset.y/i.height;let s=new Float64Array(16);e.cO(s,o,r);let l=new Float64Array(16);for(let r of(e.bl(l,s),e.cA.fromInvProjectionMatrix(l,d,u,!0).points)){let a=(r[0]/=c,r[1]/=c,r[2]=e.ce(r[2],i._center.lat),r);w=Math.max(w,e.c5(e.d9([],b,a)))}}w*=o/(o-1);let S=Math.acos(r[2]),E=Math.atan2(-r[0],-r[1]),I=new t7;I.position=b,I.setPitchBearing(S,E);let A=I.getWorldToCamera(d,x),C=w*d,M=Math.min(-(i._mercatorZfromZoom(17)*d*2),-2*C),P=I.getCameraToClipOrthographic(-C,C,-C,C,M,(C+s*x)/r[2]),z=new Float64Array(16);e.aB(z,P,A);let R=e.d4(Math.floor(1e6*b[0])/1e6*d,Math.floor(1e6*b[1])/1e6*d,0),D=.5*o,L=[0,0,0];e.af(L,R,z),e.c4(L,L,D);let O=[Math.floor(L[0]),Math.floor(L[1]),Math.floor(L[2])],F=[0,0,0];e.av(F,L,O),e.c4(F,F,-1/D);let k=new Float64Array(16);return e.bA(k),e.br(k,k,F),e.aB(z,k,z),[z,C]}(i,this.shadowDirection,n,o,ir.shadowMapResolution,h);a.scale=i.scale,a.matrix=s,a.boundingSphereRadius=l,e.bl(d,a.matrix),a.frustum=e.cA.fromInvProjectionMatrix(d,1,0,!0),a.far=o}let p=this._cascades.length-1;this._uniformValues.u_fade_range=[.75*this._cascades[p].far,this._cascades[p].far],this._uniformValues.u_shadow_intensity=n,this._uniformValues.u_shadow_direction=[this.shadowDirection[0],this.shadowDirection[1],this.shadowDirection[2]],this._uniformValues.u_shadow_texel_size=1/ir.shadowMapResolution,this._uniformValues.u_shadow_map_resolution=ir.shadowMapResolution,this._uniformValues.u_shadowmap_0=11,this._uniformValues.u_shadowmap_1=12,this._groundShadowTiles=a.transform.coveringTiles({tileSize:512,renderWorldCopies:!0});let f=a.transform.elevation;for(let e of this._groundShadowTiles){let i={min:0,max:0};if(f){let r=f.getMinMaxForTile(e);r&&(i=r)}this.addShadowReceiver(e.toUnwrapped(),i.min,i.max)}}get enabled(){return this._enabled&&!this._forceDisable}set enabled(e){this._enabled=e}drawShadowPass(i,r){if(!this.enabled)return;
8let a=this.painter,n=a.context;this._numCascadesToRender=this._receivers.computeRequiredCascades(a.transform.getFrustum(0),a.transform.worldSize,this._cascades),n.viewport.set([0,0,ir.shadowMapResolution,ir.shadowMapResolution]);for(let o=0;o<this._numCascadesToRender;++o)for(let s of(a.currentShadowCascade=o,n.bindFramebuffer.set(this._cascades[o].framebuffer.framebuffer),n.clear({color:e.ao.white,depth:1}),i.order)){let e=i._mergedLayers[s];if(!e.hasShadowPass()||e.isHidden(a.transform.zoom))continue;let n=i.getLayerSourceCache(e),o=n?r[n.id]:void 0;("model"===e.type||o&&o.length)&&a.renderLayer(a,n,e,o)}a.currentShadowCascade=0}drawGroundShadows(){if(!this.enabled)return;let e=this.painter,i=e.style,r=e.context,a=r.gl,n=i.directionalLight,o=i.ambientLight;if(!n||!o)return;let s=[],l=ii(e,e.longestCutoffRange);l.shouldRenderCutoff&&s.push("RENDER_CUTOFF"),s.push("RENDER_SHADOWS","DEPTH_TEXTURE"),this.useNormalOffset&&s.push("NORMAL_OFFSET");let h=iu(i,n,o),u=new t2(a.LEQUAL,t2.ReadOnly,e.depthRangeFor3D),c=new t3({func:a.EQUAL,mask:255},0,255,a.KEEP,a.KEEP,a.KEEP);for(let i of this._groundShadowTiles){let n=i.toUnwrapped(),o=e.isTileAffectedByFog(i),d=e.getOrCreateProgram("groundShadow",{defines:s,overrideFog:o});this.setupShadows(n,d),e.uploadCommonUniforms(r,d,n,null,l);let p={u_matrix:e.transform.calculateProjMatrix(n),u_ground_shadow_factor:h};d.draw(e,a.TRIANGLES,u,c,t1.multiply,t5.disabled,p,"ground_shadow",e.tileExtentBuffer,e.quadTriangleIndexBuffer,e.tileExtentSegments,null,e.transform.zoom,null,null)}}getShadowPassColorMode(){return this.painter._shadowMapDebug?t1.unblended:t1.disabled}getShadowPassDepthMode(){return this._depthMode}getShadowCastingLayerCount(){return this._shadowLayerCount}calculateShadowPassMatrixFromTile(i){let r=this.painter.transform,a=r.calculatePosMatrix(i,r.worldSize);return e.aB(a,this._cascades[this.painter.currentShadowCascade].matrix,a),Float32Array.from(a)}calculateShadowPassMatrixFromMatrix(i){return e.aB(i,this._cascades[this.painter.currentShadowCascade].matrix,i),Float32Array.from(i)}setupShadows(i,r,a){if(!this.enabled)return;let n=this.painter.transform,o=this.painter.context,s=o.gl,l=this._uniformValues,h=new Float64Array(16),u=n.calculatePosMatrix(i,n.worldSize);for(let i=0;i<this._cascades.length;i++)e.aB(h,this._cascades[i].matrix,u),l[0===i?"u_light_matrix_0":"u_light_matrix_1"]=Float32Array.from(h),o.activeTexture.set(s.TEXTURE0+11+i),this._cascades[i].texture.bindExtraParam(s.LINEAR,s.LINEAR,s.CLAMP_TO_EDGE,s.CLAMP_TO_EDGE,s.GREATER);if(this.useNormalOffset=!!a,this.useNormalOffset){let r=e.d6(i.canonical),o=2/n.tileSize*e.al/ir.shadowMapResolution,s=o*this._cascades[0].boundingSphereRadius,h=o*this._cascades[this._cascades.length-1].boundingSphereRadius,u=("vector-tile"===a?1:3)*function(i,r,a,n,o){let s=e.aA(-((i-22)/22),0,1);return .125*(1-s)+4*s}(n.zoom);l.u_shadow_normal_offset=[r,s*u,h*u],l.u_shadow_bias=[1e-4,.0012,.012]}else l.u_shadow_bias=[36e-5,.0012,.012];r.setShadowUniformValues(o,l)}setupShadowsFromMatrix(i,r,a=!1){if(!this.enabled)return;let n=this.painter.context,o=n.gl,s=this._uniformValues,l=new Float64Array(16);for(let r=0;r<ir.cascadeCount;r++)e.aB(l,this._cascades[r].matrix,i),s[0===r?"u_light_matrix_0":"u_light_matrix_1"]=Float32Array.from(l),n.activeTexture.set(o.TEXTURE0+11+r),this._cascades[r].texture.bindExtraParam(o.LINEAR,o.LINEAR,o.CLAMP_TO_EDGE,o.CLAMP_TO_EDGE,o.GREATER);if(this.useNormalOffset=a,a){let e=ir.normalOffset;s.u_shadow_normal_offset=[1,e,e],s.u_shadow_bias=[6e-5,.0012,.012]}else s.u_shadow_bias=[36e-5,.0012,.012];r.setShadowUniformValues(n,s)}getShadowUniformValues(){return this._uniformValues}getCurrentCascadeFrustum(){return this._cascades[this.painter.currentShadowCascade].frustum}computeSimplifiedTileShadowVolume(i,r,a,n){if(n[2]>=0)return{};let o=(function(i,r,a){let n=a/(1<<i.canonical.z);return new e.d8([i.canonical.x*n+i.wrap*a,i.canonical.y*n+i.wrap*a,0],[(i.canonical.x+1)*n+i.wrap*a,(i.canonical.y+1)*n+i.wrap*a,r])})(i,r,a).getCorners(),s=-(r/n[2]);n[0]<0?(e.d7(o[0],o[0],[n[0]*s,0,0]),e.d7(o[3],o[3],[n[0]*s,0,0])):n[0]>0&&(e.d7(o[1],o[1],[n[0]*s,0,0]),e.d7(o[2],o[2],[n[0]*s,0,0])),n[1]<0?(e.d7(o[0],o[0],[0,n[1]*s,0]),e.d7(o[1],o[1],[0,n[1]*s,0])):n[1]>0&&(e.d7(o[2],o[2],[0,n[1]*s,0]),e.d7(o[3],o[3],[0,n[1]*s,0]));let l={};return l.vertices=o,l.planes=[il(o[1],o[0],o[4]),il(o[2],o[1],o[5]),il(o[3],o[2],o[6]),il(o[0],o[3],o[7])],l}addShadowReceiver(i,r,a){this._receivers.add(i,e.d8.fromTileIdAndHeight(i,r,a))}getMaxCascadeForTile(e){let i=this._receivers.get(e);return i&&i.lastCascade?i.lastCascade:0}}function il(i,r,a){let n=e.av([],a,r),o=e.av([],i,r),s=e.bI([],n,o),l=e.ag(s);return 0===l?[0,0,1,0]:(e.c4(s,s,1/l),[s[0],s[1],s[2],-e.bJ(s,r)])}function ih(i){let r=i.properties.get("direction"),a=e.d3(r.x,r.y,r.z);
8a[2]=e.aA(a[2],0,75);let n=e.d5([a[0],a[1],a[2]]);return e.d4(n.x,n.y,n.z)}function iu(i,r,a){let n="none"===r.properties.get("color-use-theme"),o=r.properties.get("color"),s=r.properties.get("intensity"),l=r.properties.get("direction"),h=[l.x,l.y,l.z],u="none"===a.properties.get("color-use-theme"),c=a.properties.get("color"),d=a.properties.get("intensity"),p=Math.max(e.bJ([0,0,1],h),0),f=[0,0,0];e.c4(f,c.toPremultipliedRenderColor(u?null:i.getLut(r.scope)).toArray01Linear().slice(0,3),d);let m=[0,0,0];return e.c4(m,o.toPremultipliedRenderColor(n?null:i.getLut(a.scope)).toArray01Linear().slice(0,3),p*s),e.da([f[0]>0?f[0]/(f[0]+m[0]):0,f[1]>0?f[1]/(f[1]+m[1]):0,f[2]>0?f[2]/(f[2]+m[2]):0])}class ic extends e.E{constructor(e){super(),this.requestManager=e,this.models={"":{}},this.modelUris={"":{}},this.modelByURL={},this.numModelsLoading={}}loadModel(i,r){return e.aV(this.requestManager.transformRequest(r,e.R.Model).url).then(r=>{if(!r)return;let a=e.aW(r),n=new e.aX(i,void 0,void 0,a);return n.computeBoundsAndApplyParent(),n}).catch(a=>{if(a&&404===a.status)return null;this.fire(new e.y(Error(`Could not load model ${i} from ${r}: ${a.message}`)))})}load(i,r,a={forceReload:!1}){this.models[r]||(this.models[r]={});let n=Object.keys(i),o=[],s=[];for(let e of n){let n=i[e];this.hasURLBeenRequested(n)&&!a.forceReload||(this.modelByURL[n]={modelId:e,scope:r},o.push(this.loadModel(e,n)),s.push(e)),this.models[r][e]||(this.models[r][e]={model:null,numReferences:1})}this.numModelsLoading[r]=(this.numModelsLoading[r]||0)+s.length,Promise.allSettled(o).then(i=>{for(let e=0;e<i.length;e++){let{status:a}=i[e];if("rejected"===a)continue;let{value:n}=i[e];this.models[r][s[e]]||(this.models[r][s[e]]={model:null,numReferences:1}),this.models[r][s[e]].model=n}this.numModelsLoading[r]-=s.length,this.fire(new e.z("data",{dataType:"style"}))}).catch(i=>{this.fire(new e.y(Error(`Could not load models: ${i.message}`)))})}isLoaded(){for(let e in this.numModelsLoading)if(this.numModelsLoading[e]>0)return!1;return!0}hasModel(e,i,r={exactIdMatch:!1}){return!!(r.exactIdMatch?this.getModel(e,i):this.getModelByURL(this.modelUris[i][e]))}getModel(e,i){return this.models[i]||(this.models[i]={}),this.models[i][e]?this.models[i][e].model:void 0}getModelByURL(e){if(!e)return null;let i=this.modelByURL[e];return i?this.models[i.scope][i.modelId].model:null}hasModelBeenAdded(e,i){return this.models[i]&&void 0!==this.models[i][e]}getModelURIs(e){return this.modelUris[e]||{}}addModel(e,i,r){this.models[r]||(this.models[r]={}),this.modelUris[r]||(this.modelUris[r]={});let a=this.requestManager.normalizeModelURL(i);if((this.hasModel(e,r,{exactIdMatch:!0})||this.hasModelBeenAdded(e,r))&&this.modelUris[r][e]===a)this.models[r][e].numReferences++;else if(this.hasURLBeenRequested(a)){let{scope:e,modelId:i}=this.modelByURL[a];this.models[e][i].numReferences++}else this.modelUris[r][e]=a,this.load({[e]:this.modelUris[r][e]},r)}addModelURLs(e,i){this.models[i]||(this.models[i]={}),this.modelUris[i]||(this.modelUris[i]={});let r=this.modelUris[i];for(let i in e)r[i]=this.requestManager.normalizeModelURL(e[i])}reloadModels(e){this.load(this.modelUris[e],e,{forceReload:!0})}addModelsFromBucket(i,r){this.models[r]||(this.models[r]={}),this.modelUris[r]||(this.modelUris[r]={});let a={};for(let n of i)this.hasModel(n,r,{exactIdMatch:!0})||this.hasURLBeenRequested(n)?this.models[r][n].numReferences++:this.modelUris[r][n]&&!this.hasURLBeenRequested(n)?a[n]=this.modelUris[r][n]:!this.hasURLBeenRequested(n)&&e.db(n,!1)&&(this.modelUris[r][n]=this.requestManager.normalizeModelURL(n),a[n]=this.modelUris[r][n]);this.load(a,r)}hasURLBeenRequested(e){return void 0!==this.modelByURL[e]}removeModel(e,i,r=!1,a=!1){if(this.models[i]&&this.models[i][e]&&(this.models[i][e].numReferences--,0===this.models[i][e].numReferences||a)){let a=this.modelUris[i][e];r||delete this.modelUris[i][e],delete this.modelByURL[a];let n=this.models[i][e].model;n&&(delete this.models[i][e],n.destroy())}}destroy(){for(let e of Object.keys(this.models))for(let i of Object.keys(this.models[e])){let r=this.models[e][i].model;delete this.models[e][i],r&&r.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,i){for(let r in this.models[i]||(this.models[i]={}),this.models[i])this.models[i][r].model&&this.models[i][r].model.upload(e.context)}}let id=new e.a9({data:new e.aa(e.a6.colorTheme.data)});function ip(i){if(i)return i.map(([i,r])=>[i*e.o.devicePixelRatio,r*e.o.devicePixelRatio])}class im{constructor(e,i,r){this.id=e,this.scope=i,this.sourceCache=r,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(){let i=new Map;if(!this.sourceCache.loaded())return i;let r=this.sourceCache.getVisibleCoordinates();if(0===r.length)return i;let a=this.sourceCache.getSource();if(!(a instanceof eK))return i;let n=r.map(e=>this.sourceCache.getTile(e));for(let[r,o]of a.getImages(n,Array.from(this.pendingRequests)))i.set(e.I.from({name:r,iconsetId:this.id}),o),this.pendingRequests.delete(r);for(let e of this.pendingRequests)this.missingRequests.add(e);return this.pendingRequests.clear(),i}}let i_=(e,i)=>eC(e,i&&i.filter(e=>"source.canvas"!==e.identifier)),ig=e.aH(tu,["addLayer","removeLayer","setLights","setPaintProperty","setLayoutProperty","setSlot","setFilter","addSource","removeSource","setLayerZoomRange","setLight","setTransition","setGeoJSONSourceData","setTerrain","setFog","setSnow","setRain","setProjection","setCamera","addImport","removeImport","updateImport","addIconset","removeIconset"]),iy=e.aH(tu,["setCenter","setZoom","setBearing","setP
8itch"]),ix=new Set(["background","sky","slot","custom"]),iv={version:8,layers:[],sources:{}},ib={duration:300,delay:0};class iw extends e.E{constructor(i,r={}){super(),this.map=i,this.scope=r.scope||"",this.globalId=null,this.fragments=[],this.importDepth=r.importDepth||0,this.importsCache=r.importsCache||new Map,this.resolvedImports=r.resolvedImports||new Set,this.transition=Object.assign({},ib),this._buildingIndex=new tl(this),this.crossTileSymbolIndex=new t0,this._mergedOrder=[],this._drapedFirstOrder=[],this._mergedLayers={},this._mergedSourceCaches={},this._mergedOtherSourceCaches={},this._mergedSymbolSourceCaches={},this._clipLayerPresent=!1,this._has3DLayers=!1,this._hasCircleLayers=!1,this._hasSymbolLayers=!1,this._changes=r.styleChanges||new q,this.dispatcher=r.dispatcher?r.dispatcher:new e.D(e.dd(),this),r.imageManager?this.imageManager=r.imageManager:(this.imageManager=new $(this.map._spriteFormat),this.imageManager.setEventedParent(this)),this.imageManager.addScope(this.scope),this.glyphManager=r.glyphManager?r.glyphManager:new e.de(i._requestManager,r.localFontFamily?e.df.all:r.localIdeographFontFamily?e.df.ideographs:e.df.none,r.localFontFamily||r.localIdeographFontFamily),r.modelManager?this.modelManager=r.modelManager:(this.modelManager=new ic(i._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=r.configOptions?r.configOptions:new Map,this._configDependentLayers=r.configDependentLayers?r.configDependentLayers:new Set,this._config=r.config,this._styleColorTheme={lut:null,lutLoading:!1,lutLoadingCorrelationID:0,colorTheme:null,colorThemeOverride:r.colorThemeOverride},this._styleColorThemeForScope={},this._initialConfig=r.initialConfig,this.dispatcher.broadcast("setReferrer",e.dg());let a=this;this._rtlTextPluginCallback=iw.registerForPluginStateChange(i=>{a.dispatcher.broadcast("syncRTLPluginState",{pluginStatus:i.pluginStatus,pluginURL:i.pluginURL},(i,r)=>{if(e.dh(i),r&&r.every(e=>e))for(let e in a._sourceCaches){let i=a._sourceCaches[e],r=i.getSource().type;"vector"!==r&&"geojson"!==r||i.reload()}})}),this.on("data",e=>{if("source"!==e.dataType||"metadata"!==e.sourceDataType)return;let i=this.getOwnSource(e.sourceId);if(i&&i.vectorLayerIds)for(let e in this._layers){let r=this._layers[e];r.source===i.id&&this._validateLayer(r)}})}load(e){return e&&("string"==typeof e?this.loadURL(e):this.loadJSON(e)),this}_getGlobalId(i){if(!i)return null;if("string"==typeof i){if(e.h(i))return i;let r=e.di(i);if(!r.startsWith("http"))try{return new URL(r,location.href).toString()}catch(e){}return r}return`json://${e.dj(JSON.stringify(i))}`}_diffStyle(i,r,a){this.globalId=this._getGlobalId(i);let n=(e,i)=>{try{i(null,this.setState(e,a))}catch(e){i(e,!1)}};if("string"==typeof i){let a=this.map._requestManager.normalizeStyleURL(i),o=this.map._requestManager.transformRequest(a,e.R.Style);e.m(o,(i,a)=>{i?this.fire(new e.y(i)):a&&n(a,r)})}else"object"==typeof i&&n(i,r)}loadURL(i,r={}){this.fire(new e.z("dataloading",{dataType:"style"}));let a="boolean"==typeof r.validate?r.validate:!e.h(i);this.globalId=this._getGlobalId(i),i=this.map._requestManager.normalizeStyleURL(i,r.accessToken),this.resolvedImports.add(i);let n=this.importsCache.get(i);if(n)return this._load(n,a);let o=this.map._requestManager.transformRequest(i,e.R.Style);this._request=e.m(o,(r,n)=>{if(this._request=null,r)this.fire(new e.y(r));else if(n)return this.importsCache.set(i,n),this._load(n,a)})}loadJSON(i,r={}){this.fire(new e.z("dataloading",{dataType:"style"})),this.globalId=this._getGlobalId(i),this._request=e.o.frame(()=>{this._request=null,this._load(i,!1!==r.validate)})}loadEmpty(){this.fire(new e.z("dataloading",{dataType:"style"})),this._load(iv,!1)}_loadImports(i,r,a){if(this.importDepth>=4)return e.w("Style doesn't support nesting deeper than 5"),Promise.resolve();let n=[];for(let e of i){let i=this._createFragmentStyle(e),o=new Promise(e=>{i.once("style.import.load",e),i.once("error",e)}).then(()=>this.mergeAll());if(n.push(o),this.resolvedImports.has(e.url)){i.loadEmpty();continue}let s=e.data||this.importsCache.get(e.url);s?(i.loadJSON(s,{validate:r}),this._isInternalStyle(s)&&(i.globalId=null)):e.url?i.loadURL(e.url,{validate:r}):i.loadEmpty();let l={style:i,id:e.id,config:e.config};if(a){let e=this.fragments.findIndex(({id:e})=>e===a);this.fragments=this.fragments.slice(0,e).concat(l).concat(this.fragments.slice(e))}else this.fragments.push(l)}return Promise.allSettled(n)}getImportGlobalIds(e=this,i=new Set){for(let r of e.fragments)r.style.globalId&&i.add(r.style.globalId),this.getImportGlobalIds(r.style,i);return[...i.values()]}_createFragmentStyle(i){let r,a=this.scope?e.B(i.id,this.scope):i.id,n=this._initialConfig&&this._initialConfig[a];(i.config||n)&&(r=Object.assign({},i.config,n));let o=new iw(this.map,{scope:a,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:r,configOptions:this.options,colorThemeOverride:i["color-theme"],configDependentLayers:this._configDependentLayers});return o.setEventedParent(this.map,{style:o}),o}_reloadImports(){this.mergeAll(),this._updateMapProjection(),this.updateConfigDependencies(),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(i,r){if(this._isInternalStyle(i)){let e=Object.assign({},iv,{imports:[{id:"basemap",data:i,url:""}]});return void this._load(e,r)}if(this.updateConfig(this._config,i.schema),r&&i_(this,ef(i)))return;this._loaded=!0,this.stylesheet=e.dk(i);let a=()=>{for(let e in i.sources)this.addSource(e,i.sources[e],{validate:!1,isInitialLoad:!0});if(i.iconsets)for(let e in i.iconsets)this.addIconset(e,i.iconsets[e]);i.sprite?this._loadIconset(i.sprite):(this.imageManager.setLoaded(!0,this.scope),this.dispatcher.broadcast("spriteLoaded",{scope:this.scope,isLoaded:!0})),!this.glyphManager.url&&i.glyphs&&this.glyphManager.setURL(i.glyphs);
8let a=th(this.stylesheet.layers);if(this._order=a.map(e=>e.id),this.stylesheet.light&&e.w("The `light` root property is deprecated, prefer using `lights` with `flat` light type instead."),this.stylesheet.lights)if(1===this.stylesheet.lights.length&&"flat"===this.stylesheet.lights[0].type){let e=this.stylesheet.lights[0];this.light=new eM(e.properties,e.id)}else this.setLights(this.stylesheet.lights);for(let i of(this.light||(this.light=new eM(this.stylesheet.light)),this._layers={},a)){let r=e.dq(i,this.scope,this._styleColorTheme.lut,this.options);0!==r.configDependencies.size&&this._configDependentLayers.add(r.fqid),r.setEventedParent(this,{layer:{id:r.id}}),this._layers[r.id]=r;let a=this.getOwnLayerSourceCache(r),n=!!this.directionalLight&&this.directionalLight.shadowsEnabled();a&&r.canCastShadows()&&n&&(a.castsShadows=!0)}this.stylesheet.featuresets&&this.setFeaturesetSelectors(this.stylesheet.featuresets),this.stylesheet.models&&this.addModelURLs(this.stylesheet.models);let n=this.stylesheet.terrain;n&&(this.checkCanvasFingerprintNoise(),this.disableElevatedTerrain||this.terrainSetForDrapingOnly()||this._createTerrain(n,1)),this.stylesheet.fog&&this._createFog(this.stylesheet.fog),this.stylesheet.snow&&this._createSnow(this.stylesheet.snow),this.stylesheet.rain&&this._createRain(this.stylesheet.rain),this.stylesheet.transition&&this.setTransition(this.stylesheet.transition),this.fire(new e.z("data",{dataType:"style"}));let o=this.isRootStyle();i.imports?this._loadImports(i.imports,r).then(()=>{this._reloadImports(),this.fire(new e.z(o?"style.load":"style.import.load"))}).catch(i=>{this.fire(new e.y(Error("Failed to load imports",i))),this.fire(new e.z(o?"style.load":"style.import.load"))}):(this._reloadImports(),this.fire(new e.z(o?"style.load":"style.import.load")))};this._styleColorTheme.colorTheme=this.stylesheet["color-theme"];let n=this._styleColorTheme.colorThemeOverride?this._styleColorTheme.colorThemeOverride:this._styleColorTheme.colorTheme;if(n){let i=this._evaluateColorThemeData(n);this._loadColorTheme(i).then(()=>{a()}).catch(i=>{e.w(`Couldn't load color theme from the stylesheet: ${i}`),a()})}else this._styleColorTheme.lut=null,a()}isRootStyle(){return 0===this.importDepth}mergeAll(){let e,i,r,a,n,o,s,l,h,u,c={};this.terrain&&this.terrain.scope!==this.scope&&delete this.terrain,this.forEachFragmentStyle(d=>{if(d.stylesheet){if(null!=d.light&&(e=d.light),d.stylesheet.lights)for(let e of d.stylesheet.lights)"ambient"===e.type&&null!=d.ambientLight&&(i=d.ambientLight),"directional"===e.type&&null!=d.directionalLight&&(r=d.directionalLight);a=this._prioritizeTerrain(a,d.terrain,d.stylesheet.terrain),d.stylesheet.fog&&null!=d.fog&&(n=d.fog),d.stylesheet.snow&&null!=d.snow&&(o=d.snow),d.stylesheet.rain&&null!=d.rain&&(s=d.rain),null!=d.stylesheet.camera&&(u=d.stylesheet.camera),null!=d.stylesheet.projection&&(l=d.stylesheet.projection),null!=d.stylesheet.transition&&(h=d.stylesheet.transition),c[d.scope]=d._styleColorTheme}}),this.light=e,this.ambientLight=i,this.directionalLight=r,this.fog=n,this.snow=o,this.rain=s,this._styleColorThemeForScope=c,null===a?delete this.terrain:this.terrain=a,this.camera=u||{"camera-projection":"perspective"},this.projection=l||{name:"mercator"},this.transition=Object.assign({},ib,h),this.mergeSources(),this.mergeLayers()}forEachFragmentStyle(e){let i=r=>{for(let e of r.fragments)i(e.style);e(r)};i(this)}_prioritizeTerrain(e,i,r){let a=e&&0===e.drapeRenderMode;return null===r?i&&0===i.drapeRenderMode?i:a?e:null:null!=i&&(!e||a||i&&1===i.drapeRenderMode)?i:e}mergeTerrain(){let e;this.terrain&&this.terrain.scope!==this.scope&&delete this.terrain,this.forEachFragmentStyle(i=>{e=this._prioritizeTerrain(e,i.terrain,i.stylesheet.terrain)}),null===e?delete this.terrain:this.terrain=e}mergeProjection(){let e;this.forEachFragmentStyle(i=>{null!=i.stylesheet.projection&&(e=i.stylesheet.projection)}),this.projection=e||{name:"mercator"}}mergeSources(){let i={},r={},a={};this.forEachFragmentStyle(n=>{for(let r in n._sourceCaches)i[e.B(r,n.scope)]=n._sourceCaches[r];for(let i in n._otherSourceCaches)r[e.B(i,n.scope)]=n._otherSourceCaches[i];for(let i in n._symbolSourceCaches)a[e.B(i,n.scope)]=n._symbolSourceCaches[i]}),this._mergedSourceCaches=i,this._mergedOtherSourceCaches=r,this._mergedSymbolSourceCaches=a}mergeLayers(){let i={},r=[],a={};this._mergedSlots=[],this._has3DLayers=!1,this._hasCircleLayers=!1,this._hasSymbolLayers=!1,this.forEachFragmentStyle(a=>{for(let n of a._order){let o=a._layers[n];if("slot"===o.type){let r=e.dl(n);if(i[r])continue;i[r]=[]}o.slot&&i[o.slot]?i[o.slot].push(o):r.push(o)}}),this._mergedOrder=[];let n=-1,o=(r=[])=>{for(let s of r)if("slot"===s.type){let r=e.dl(s.id);i[r]&&o(i[r]),this._mergedSlots.push(r)}else{let i=e.B(s.id,s.scope);this._mergedOrder.push(i),a[i]=s,s.is3D(!!this.terrain)&&(this._has3DLayers=!0,n=this._mergedOrder.length-1),"circle"===s.type&&(this._hasCircleLayers=!0),"symbol"===s.type&&(this._hasSymbolLayers=!0),"clip"===s.type&&(this._clipLayerPresent=!0)}};if(o(r),this._has3DLayers){let e={};for(let i=0;i<this._mergedOrder.length;++i){let r=this._mergedOrder[i];e[r]=i===n?1:i<n?2*!!a[r].hasOcclusionOpacityProperties:4}this._mergedOrder.sort((i,r)=>e[i]-e[r])}this._mergedLayers=a,this.updateDrapeFirstLayers(),this._buildingIndex.processLayersChanged()}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(i){return i.data?(function(i,r,a,n){let o=Object.assign({},r);for(let i of Object.keys(e.a6.colorTheme))void 0===o[i]&&(o[i]=e.a6.colorTheme[i].default);let s=new e.a8(id,i,new Map(a));return s.setTransitionOrValue(o,a),s.untransitioned().possiblyEvaluate(new e.ac(0,{worldview:void 0}))})(this.scope,i,this.options).get("data"):null}_loadColorTheme(i){this._styleColorTheme.lutLoading=!0,this._styleColorTheme.lutLoadingCorrelationID+=1;let r=this._styleColorTheme.lutLoadingCorrelationID;return new Promise((a,n)=>{let o="data:image/png;base64,";if(!i||0===i.length)return this._styleColorTheme.lut=null,this._styleColorTheme.lutLoading=!1,void a();let s=i;s.startsWith(o)||(s=o+s);let l=e.I.from("mapbox-reserved-lut"),h=new Image;h.src=s,h.onerror=()=>{this._styleColorTheme.lutLoading=!1,n(Error("Failed to load image data"))},h.onload=()=>
8{if(this._styleColorTheme.lutLoadingCorrelationID!==r)return void a();this._styleColorTheme.lutLoading=!1;let{width:o,height:s,data:u}=e.o.getImageData(h);if(s>32)return void n(Error("The height of the image must be less than or equal to 32 pixels."));if(o!==s*s)return void n(Error("The width of the image must be equal to the height squared."));this.getImage(l)&&this.removeImage(l),this.addImage(l,{data:new e.q({width:o,height:s},u),pixelRatio:1,sdf:!1,usvg:!1,version:0});let c=this.imageManager.getImage(l,this.scope);c?(this._styleColorTheme.lut={image:c.data,data:i},a()):n(Error("Missing LUT image."))}})}getLut(e){let i=this._styleColorThemeForScope[e];return i?i.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(i){this._spriteRequest=function(i,r,a){let n,o,s,l=e.o.devicePixelRatio>1?"@2x":"",h=e.m(r.transformRequest(r.normalizeSpriteURL(i,l,".json"),e.R.SpriteJSON),(e,i)=>{h=null,s||(s=e,n=i,c())}),u=e.n(r.transformRequest(r.normalizeSpriteURL(i,l,".png"),e.R.SpriteImage),(e,i)=>{u=null,s||(s=e,o=i,c())});function c(){if(s)a(s);else if(n&&o){let i=e.o.getImageData(o),r={};for(let a in n){let{width:o,height:s,x:l,y:h,sdf:u,pixelRatio:c,stretchX:d,stretchY:p,content:f}=n[a],m=new e.q({width:o,height:s});e.q.copy(i,m,{x:l,y:h},{x:0,y:0},{width:o,height:s},null),r[a]={data:m,pixelRatio:void 0!==c?c:1,sdf:void 0!==u&&u,stretchX:d,stretchY:p,content:f,usvg:!1,version:0}}a(null,r)}}return{cancel(){h&&(h.cancel(),h=null),u&&(u.cancel(),u=null)}}}(i,this.map._requestManager,(i,r)=>{if(this._spriteRequest=null,i)this.fire(new e.y(i));else if(r){let i=new Map;for(let a in r)i.set(e.I.from(a),r[a]);this.addImages(i)}this.imageManager.setLoaded(!0,this.scope),this.dispatcher.broadcast("spriteLoaded",{scope:this.scope,isLoaded:!0}),this.fire(new e.z("data",{dataType:"style"}))})}addIconset(i,r){if("sprite"===r.type)return void this._loadSprite(r.url);let a=this.getOwnSourceCache(r.source);if(!a)return void this.fire(new e.y(Error(`Source "${r.source}" as specified by iconset "${i}" does not exist and cannot be used as an iconset source`)));let n=a.getSource();if("raster-array"!==n.type)return void this.fire(new e.y(Error(`Source "${r.source}" as specified by iconset "${i}" is not a "raster-array" source and cannot be used as an iconset source`)));n.partial=!1;let o=new im(i,this.scope,a);this.imageManager.addImageProvider(o,this.scope)}removeIconset(e){this.imageManager.removeImageProvider(e,this.scope)}_loadIconset(i){var r,a;if(!e.h(i)&&"icon_set"!==this.map._spriteFormat||"raster"===this.map._spriteFormat)return void this._loadSprite(i);let n="auto"===this.map._spriteFormat;this._spriteRequest=(a=(r,a)=>{if(this._spriteRequest=null,r)n?this._loadSprite(i):this.fire(new e.y(r));else if(a){let i=new Map;for(let r in a)i.set(e.I.from(r),a[r]);this.addImages(i)}this.imageManager.setLoaded(!0,this.scope),this.dispatcher.broadcast("spriteLoaded",{scope:this.scope,isLoaded:!0}),this.fire(new e.z("data",{dataType:"style"}))},e.bu((r=this.map._requestManager).transformRequest(r.normalizeIconsetURL(i),e.R.Iconset),(i,r)=>{if(i)return void a(i);let n={};for(let i of e.dc(new e.bt(r)).icons){let r={version:1,pixelRatio:e.o.devicePixelRatio,content:function(i){if(!i.metadata||!i.metadata.content_area)return;let r=e.o.devicePixelRatio,{left:a,top:n,width:o,height:s}=i.metadata.content_area,l=a*r,h=n*r;return[l,h,l+o*r,h+s*r]}(i),stretchX:i.metadata?ip(i.metadata.stretch_x_areas):void 0,stretchY:i.metadata?ip(i.metadata.stretch_y_areas):void 0,sdf:!1,usvg:!0,icon:i};n[i.name]=r}a(null,n)}))}_validateLayer(i){let r=this.getOwnSource(i.source);if(!r)return;let a=i.sourceLayer;a&&("geojson"===r.type||r.vectorLayerIds&&-1===r.vectorLayerIds.indexOf(a))&&this.fire(new e.y(Error(`Source layer "${a}" does not exist on source "${r.id}" as specified by style layer "${i.id}"`)))}
8loaded(){if(!this._loaded||Object.keys(this._changes.getUpdatedSourceCaches()).length)return!1;for(let e in this._sourceCaches)if(!this._sourceCaches[e].loaded())return!1;if(!this.imageManager.isLoaded()||this.imageManager.hasPatternsInFlight()||!this.modelManager.isLoaded()||this._styleColorTheme.lutLoading)return!1;for(let{style:e}of this.fragments)if(!e.loaded())return!1;return!0}_serializeImports(){if(this.stylesheet.imports)return this.stylesheet.imports.map((e,i)=>{let r=this.fragments[i];return r&&r.style&&(e.data=r.style.serialize()),e})}_serializeSources(){let e={};for(let i in this._sourceCaches){let r=this._sourceCaches[i].getSource();e[r.id]||(e[r.id]=r.serialize())}return e}_serializeLayers(e){let i=[];for(let r of e){let e=this._layers[r];e&&"custom"!==e.type&&i.push(e.serialize())}return i}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()||this.hasFogTransition()||this.hasSnowTransition()||this.hasRainTransition())return!0;for(let e in this._sourceCaches)if(this._sourceCaches[e].hasTransition())return!0;for(let e in this._layers)if(this._layers[e].hasTransition())return!0;return!1}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 Error("Style is not done loading")}_checkLayer(i){let r=this.getOwnLayer(i);if(r)return r;this.fire(new e.y(Error(`The layer '${i}' does not exist in the map's style.`)))}_checkSource(i){let r=this.getOwnSource(i);if(r)return r;this.fire(new e.y(Error(`The source '${i}' does not exist in the map's style.`)))}precompilePrograms(e,i){let r=this.map.painter;if(r)for(let a=e.minzoom||0;a<(e.maxzoom||25.5);a++){let a=e.getProgramIds();if(a)for(let n of a){let a=e.getDefaultProgramParams(n,i.zoom,this._styleColorTheme.lut);a&&(r.style=this,this.fog&&(r._fogVisible=!0,a.overrideFog=!0,r.getOrCreateProgram(n,a)),r._fogVisible=!1,a.overrideFog=!1,r.getOrCreateProgram(n,a),(this.stylesheet.terrain||this.stylesheet.projection&&"globe"===this.stylesheet.projection.name)&&(a.overrideRtt=!0,r.getOrCreateProgram(n,a)))}}}update(i){if(!this._loaded)return;this.ambientLight&&this.ambientLight.recalculate(i),this.directionalLight&&this.directionalLight.recalculate(i);let r=this.calculateLightsBrightness();i.brightness=r||0,r!==this._brightness&&(this._brightness=r,this.dispatcher.broadcast("setBrightness",r)),i.worldview!==this._worldview&&(this._worldview=i.worldview,this.dispatcher.broadcast("setWorldview",this._worldview));let a=this._changes.isDirty(),n=!1;if(this._changes.isDirty()){let e=this._changes.getLayerUpdatesByScope();for(let i in e){let{updatedIds:r,removedIds:a}=e[i];(r||a)&&(this._updateWorkerLayers(i,r,a),n=!0)}this.updateSourceCaches(),this._updateTilesForChangedImages(),this.updateLayers(i),this.light&&this.light.updateTransitions(i),this.ambientLight&&this.ambientLight.updateTransitions(i),this.directionalLight&&this.directionalLight.updateTransitions(i),this.fog&&this.fog.updateTransitions(i),this.snow&&this.snow.updateTransitions(i),this.rain&&this.rain.updateTransitions(i),this._changes.reset()}let o={};for(let e in this._mergedSourceCaches){let i=this._mergedSourceCaches[e];o[e]=i.used,i.used=!1,i.tileCoverLift=0}for(let e of this._mergedOrder){let r=this._mergedLayers[e];if(r.recalculate(i,this._availableImages),!r.isHidden(i.zoom)){let e=this.getLayerSourceCache(r);e&&(e.used=!0,e.tileCoverLift=Math.max(e.tileCoverLift,r.tileCoverLift()))}!this._precompileDone&&this._shouldPrecompile&&("requestIdleCallback"in window?requestIdleCallback(()=>{this.precompilePrograms(r,i)}):this.precompilePrograms(r,i))}for(let e of(this._shouldPrecompile&&(this._precompileDone=!0),this.terrain&&n&&this.mergeLayers(),this.imageManager.getPendingImageProviders()))e.sourceCache.used=!0;for(let i in o){let r=this._mergedSourceCaches[i];o[i]!==r.used&&r.getSource().fire(new e.z("data",{sourceDataType:"visibility",dataType:"source",sourceId:r.getSource().id}))}this.light&&this.light.recalculate(i),this.terrain&&this.terrain.recalculate(i),this.fog&&this.fog.recalculate(i),this.snow&&this.snow.recalculate(i),this.rain&&this.rain.recalculate(i),this.z=i.zoom,this._markersNeedU
8pdate&&(this._updateMarkersOpacity(),this._markersNeedUpdate=!1),this.imageManager.clearUpdatedImages(this.scope),a&&this.fire(new e.z("data",{dataType:"style"}))}updateImageProviders(){for(let e of this.imageManager.getPendingImageProviders()){let i=e.resolvePendingRequests(),r=this.getFragmentStyle(e.scope);r&&r.addImages(i)}}_updateTilesForChangedImages(){let e={};for(let i in this._mergedSourceCaches){let r=this._mergedSourceCaches[i].getSource().scope;e[r]=e[r]||this._changes.getUpdatedImages(r),0!==e[r].length&&this._mergedSourceCaches[i].reloadTilesForDependencies(["icons","patterns"],e[r])}for(let i in e)this._changes.resetUpdatedImages(i)}_updateWorkerLayers(e,i,r){let a=this.getFragmentStyle(e);a&&this.dispatcher.broadcast("updateLayers",{layers:i?a._serializeLayers(i):[],scope:e,removedIds:r||[],options:a.options})}setState(i,r){if(this._checkLoaded(),i_(this,ef(i)))return!1;(i=e.dk(i)).layers=th(i.layers);let a=(function(i,r){if(!i)return[{command:tu.setStyle,args:[r]}];let a=[];try{if(!e.by(i.version,r.version)||(e.by(i.center,r.center)||a.push({command:tu.setCenter,args:[r.center]}),e.by(i.zoom,r.zoom)||a.push({command:tu.setZoom,args:[r.zoom]}),e.by(i.bearing,r.bearing)||a.push({command:tu.setBearing,args:[r.bearing]}),e.by(i.pitch,r.pitch)||a.push({command:tu.setPitch,args:[r.pitch]}),e.by(i.sprite,r.sprite)||a.push({command:tu.setSprite,args:[r.sprite]}),e.by(i.glyphs,r.glyphs)||a.push({command:tu.setGlyphs,args:[r.glyphs]}),e.by(i.imports,r.imports)||function(i=[],r=[],a){let n,o,s,l;r=r||[];let h=(i=i||[]).map(tf),u=r.map(tf),c=i.reduce(tm,{}),d=r.reduce(tm,{}),p=h.slice();for(n=0,o=0;n<h.length;n++)s=h[n],d.hasOwnProperty(s)?o++:(a.push({command:tu.removeImport,args:[s]}),p.splice(p.indexOf(s,o),1));for(n=0,o=0;n<u.length;n++)s=u[u.length-1-n],p[p.length-1-n]!==s&&(c.hasOwnProperty(s)?(a.push({command:tu.removeImport,args:[s]}),p.splice(p.lastIndexOf(s,p.length-o),1)):o++,l=p[p.length-n],a.push({command:tu.addImport,args:[d[s],l]}),p.splice(p.length-n,0,s));for(let i of r){let r=c[i.id];r&&(delete r.data,e.by(r,i)||a.push({command:tu.updateImport,args:[i.id,i]}))}}(i.imports,r.imports,a),e.by(i.transition,r.transition)||a.push({command:tu.setTransition,args:[r.transition]}),e.by(i.light,r.light)||a.push({command:tu.setLight,args:[r.light]}),e.by(i.fog,r.fog)||a.push({command:tu.setFog,args:[r.fog]}),e.by(i.snow,r.snow)||a.push({command:tu.setSnow,args:[r.snow]}),e.by(i.rain,r.rain)||a.push({command:tu.setRain,args:[r.rain]}),e.by(i.projection,r.projection)||a.push({command:tu.setProjection,args:[r.projection]}),e.by(i.lights,r.lights)||a.push({command:tu.setLights,args:[r.lights]}),e.by(i.camera,r.camera)||a.push({command:tu.setCamera,args:[r.camera]}),e.by(i.iconsets,r.iconsets)||function(i,r,a){let n;for(n in r=r||{},i=i||{})i.hasOwnProperty(n)&&(r.hasOwnProperty(n)||a.push({command:tu.removeIconset,args:[n]}));for(n in r){if(!r.hasOwnProperty(n))continue;let o=r[n];i.hasOwnProperty(n)?e.by(i[n],o)||(a.push({command:tu.removeIconset,args:[n]}),a.push({command:tu.addIconset,args:[n,o]})):a.push({command:tu.addIconset,args:[n,o]})}}(i.iconsets,r.iconsets,a),!e.by(i["color-theme"],r["color-theme"])))return[{command:tu.setStyle,args:[r]}];let n={},o=[];!function(i,r,a,n){let o;for(o in r=r||{},i=i||{})i.hasOwnProperty(o)&&(r.hasOwnProperty(o)||td(o,a,n));for(o in r){var s;if(!r.hasOwnProperty(o))continue;let l=r[o];i.hasOwnProperty(o)?e.by(i[o],l)||("geojson"===i[o].type&&"geojson"===l.type&&function(i,r,a){let n;for(n in i[a])if(i[a].hasOwnProperty(n)&&"data"!==n&&!e.by(i[a][n],r[a][n]))return!1;for(n in r[a])if(r[a].hasOwnProperty(n)&&"data"!==n&&!e.by(i[a][n],r[a][n]))return!1;return!0}(i,r,o)?a.push({command:tu.setGeoJSONSourceData,args:[o,l.data]}):(s=r,td(o,a,n),tc(o,s,a))):tc(o,r,a)}}(i.sources,r.sources,o,n);let s=[];i.layers&&i.layers.forEach(e=>{e.source&&n[e.source]?a.push({command:tu.removeLayer,args:[e.id]}):s.push(e)});let l=i.terrain;l&&n[l.source]&&(a.push({command:tu.setTerrain,args:[void 0]}),l=void 0),a=a.concat(o),e.by(l,r.terrain)||a.push({command:tu.setTerrain,args:[r.terrain]}),function(i,r,a){let n,o,s,l,h,u,c;r=r||[];let d=(i=i||[]).map(tf),p=r.map(tf),f=i.reduce(tm,{}),m=r.reduce(tm,{}),_=d.slice(),g=Object.create(null);for(n=0,o=0;n<d.length;n++)s=d[n],m.hasOwnProperty(s)?o++:(a.push({command:tu.removeLayer,args:[s]}),_.splice(_.indexOf(s,o),1));for(n=0,o=0;n<p.length;n++)s=p[p.length-1-n],_[_.length-1-n]!==s&&(f.hasOwnProperty(s)?(a.push({command:tu.removeLayer,args:[s]}),_.splice(_.lastIndexOf(s,_.length-o),1)):o++,u=_[_.length-n],a.push({command:tu.addLayer,args:[m[s],u]}),_.splice(_.length-n,0,s),g[s]=!0);for(n=0;n<p.length;
8n++)if(l=f[s=p[n]],h=m[s],!g[s]&&!e.by(l,h))if(e.by(l.source,h.source)&&e.by(l["source-layer"],h["source-layer"])&&e.by(l.type,h.type)){for(c in tp(l.layout,h.layout,a,s,null,tu.setLayoutProperty),tp(l.paint,h.paint,a,s,null,tu.setPaintProperty),e.by(l.slot,h.slot)||a.push({command:tu.setSlot,args:[s,h.slot]}),e.by(l.filter,h.filter)||a.push({command:tu.setFilter,args:[s,h.filter]}),e.by(l.minzoom,h.minzoom)&&e.by(l.maxzoom,h.maxzoom)||a.push({command:tu.setLayerZoomRange,args:[s,h.minzoom,h.maxzoom]}),l)l.hasOwnProperty(c)&&"layout"!==c&&"paint"!==c&&"filter"!==c&&"metadata"!==c&&"minzoom"!==c&&"maxzoom"!==c&&"slot"!==c&&(0===c.indexOf("paint.")?tp(l[c],h[c],a,s,c.slice(6),tu.setPaintProperty):e.by(l[c],h[c])||a.push({command:tu.setLayerProperty,args:[s,c,h[c]]}));for(c in h)h.hasOwnProperty(c)&&!l.hasOwnProperty(c)&&"layout"!==c&&"paint"!==c&&"filter"!==c&&"metadata"!==c&&"minzoom"!==c&&"maxzoom"!==c&&"slot"!==c&&(0===c.indexOf("paint.")?tp(l[c],h[c],a,s,c.slice(6),tu.setPaintProperty):e.by(l[c],h[c])||a.push({command:tu.setLayerProperty,args:[s,c,h[c]]}))}else a.push({command:tu.removeLayer,args:[s]}),u=_[_.lastIndexOf(s)+1],a.push({command:tu.addLayer,args:[h,u]})}(s,r.layers,a)}catch(e){console.warn("Unable to compute style diff:",e),a=[{command:tu.setStyle,args:[r]}]}return a})(this.serialize(),i).filter(e=>!(e.command in iy));if(0===a.length)return!1;let n=a.filter(e=>!(e.command in ig));if(n.length>0)throw Error(`Unimplemented: ${n.map(e=>e.command).join(", ")}.`);let o=[];return a.forEach(e=>{o.push(this[e.command](...e.args))}),r&&Promise.all(o).then(r).catch(r),this.stylesheet=i,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})}
8addImages(i){if(0===i.size)return this;for(let[r,a]of i.entries()){if(this.getImage(r))return this.fire(new e.y(Error(`An image with the name "${r.name}" already exists.`)));this.imageManager.addImage(r,this.scope,a),this._changes.updateImage(r,this.scope)}return this._updateWorkerImages(),this.fire(new e.z("data",{dataType:"style"})),this}addImage(i,r){return this.getImage(i)?this.fire(new e.y(Error(`An image with the name "${i.name}" already exists.`))):(this.imageManager.addImage(i,this.scope,r),this._changes.updateImage(i,this.scope),this._updateWorkerImages(),this.fire(new e.z("data",{dataType:"style"})),this)}updateImage(i,r,a=!1){this.imageManager.updateImage(i,this.scope,r),a&&(this._changes.updateImage(i,this.scope),this._updateWorkerImages(),this.fire(new e.z("data",{dataType:"style"})))}getImage(e){return this.imageManager.getImage(e,this.scope)}removeImage(i){return this.getImage(i)?(this.imageManager.removeImage(i,this.scope),this._changes.updateImage(i,this.scope),this._updateWorkerImages(),this.fire(new e.z("data",{dataType:"style"})),this):this.fire(new e.y(Error("No image with this name exists.")))}listImages(){return this._checkLoaded(),this._availableImages.slice()}addModelURLs(i){return this.modelManager.addModelURLs(i,this.scope),this._updateWorkerModels(),this.fire(new e.z("data",{dataType:"style"})),this}addModel(i,r,a={}){return this._checkLoaded(),this._validate(eI,`models.${i}`,r,null,a)||(this.modelManager.addModel(i,r,this.scope),this.fire(new e.z("data",{dataType:"style"}))),this}hasModel(e){return this.modelManager.hasModel(e,this.scope)}removeModel(i){return this.hasModel(i)?(this.modelManager.removeModel(i,this.scope,!1,!0),this.fire(new e.z("data",{dataType:"style"})),this):this.fire(new e.y(Error("No model with this ID exists.")))}listModels(){return this._checkLoaded(),this.modelManager.listModels(this.scope)}addSource(i,r,a={}){if(this._checkLoaded(),void 0!==this.getOwnSource(i))throw Error(`There is already a source with ID "${i}".`);if(!r.type)throw Error(`The type property must be defined, but only the following properties were given: ${Object.keys(r).join(", ")}.`);if(["vector","raster","geojson","video","image"].indexOf(r.type)>=0&&this._validate(em,`sources.${i}`,r,null,a))return;this.map&&this.map._collectResourceTiming&&(r.collectResourceTiming=!0);let n=eQ(i,r,this.dispatcher,this);n.scope=this.scope,n.setEventedParent(this,()=>({isSourceLoaded:this._isSourceCacheLoaded(n.id),source:n.serialize(),sourceId:n.id}));let o=i=>{let r=(i?"symbol:":"other:")+n.id,a=e.B(r,this.scope),o=this._sourceCaches[r]=new ta(a,n,i);(i?this._symbolSourceCaches:this._otherSourceCaches)[n.id]=o,o.onAdd(this.map)};o(!1),"vector"!==r.type&&"geojson"!==r.type||o(!0),n.onAdd&&n.onAdd(this.map),a.isInitialLoad||(this.mergeSources(),this._changes.setDirty())}removeSource(i){this._checkLoaded();let r=this.getOwnSource(i);if(!r)throw Error("There is no source with this ID");for(let r in this._layers)if(this._layers[r].source===i)return this.fire(new e.y(Error(`Source "${i}" cannot be removed while layer "${r}" is using it.`)));if(this.terrain&&this.terrain.scope===this.scope&&this.terrain.get().source===i)return this.fire(new e.y(Error(`Source "${i}" cannot be removed while terrain is using it.`)));if(this.stylesheet.iconsets){let r=Object.entries(this.stylesheet.iconsets).find(([e,r])=>"source"===r.type&&r.source===i);if(r)return this.fire(new e.y(Error(`Source "${i}" cannot be removed while iconset "${r[0]}" is using it.`)))}for(let r of this.getOwnSourceCaches(i)){let i=e.dl(r.id);delete this._sourceCaches[i],this._changes.discardSourceCacheUpdate(r.id),r.fire(new e.z("data",{sourceDataType:"metadata",dataType:"source",sourceId:r.getSource().id})),r.setEventedParent(null),r.clearTiles()}return delete this._otherSourceCaches[i],delete this._symbolSourceCaches[i],this.mergeSources(),r.setEventedParent(null),r.onRemove&&r.onRemove(this.map),this._changes.setDirty(),this}setGeoJSONSourceData(e,i){this._checkLoaded(),this.getOwnSource(e).setData(i),this._changes.setDirty()}getOwnSource(e){let i=this.getOwnSourceCache(e);return i&&i.getSource()}getOwnSources(){let e=[];for(let i in this._otherSourceCaches){let r=this.getOwnSourceCache(i);r&&e.push(r.getSource())}return e}areTilesLoaded(){let e=this._mergedSourceCaches;for(let i in e){let r=e[i]._tiles;for(let e in r){let i=r[e];if("loaded"!==i.state&&"errored"!==i.state)return!1}}return!0}setLights(i){if(this._checkLoaded(),!i)return delete this.ambientLight,void delete this.directionalLight;let r=this._getTransitionParameters();
8for(let a of i){if(this._validate(eg,"lights",a))return;switch(a.type){case"ambient":if(this.ambientLight){let e=this.ambientLight;e.set(a),e.updateTransitions(r)}else this.ambientLight=new ej(a,eB||(eB=new e.a9({color:new e.aa(e.a6.properties_light_ambient.color),"color-use-theme":new e.aa({type:"string",default:"default","property-type":"data-constant"}),intensity:new e.aa(e.a6.properties_light_ambient.intensity)})),this.scope,this.options);break;case"directional":if(this.directionalLight){let e=this.directionalLight;e.set(a),e.updateTransitions(r)}else this.directionalLight=new ej(a,eN||(eN=new e.a9({direction:new e.ap(e.a6.properties_light_directional.direction),color:new e.aa(e.a6.properties_light_directional.color),"color-use-theme":new e.aa({type:"string",default:"default","property-type":"data-constant"}),intensity:new e.aa(e.a6.properties_light_directional.intensity),"cast-shadows":new e.aa(e.a6.properties_light_directional["cast-shadows"]),"shadow-quality":new e.aa(e.a6.properties_light_directional["shadow-quality"]),"shadow-intensity":new e.aa(e.a6.properties_light_directional["shadow-intensity"])})),this.scope,this.options)}}let a=Object.assign(r,{worldview:this.map.getWorldview()}),n=new e.ac(this.z||0,a);this.ambientLight&&this.ambientLight.recalculate(n),this.directionalLight&&this.directionalLight.recalculate(n),this._brightness=this.calculateLightsBrightness(),this.dispatcher.broadcast("setBrightness",this._brightness)}calculateLightsBrightness(){let i=this.directionalLight,r=this.ambientLight;if(!i||!r)return;let a=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)),n=i.properties.get("color").toNonPremultipliedRenderColor(null).toArray01(),o=i.properties.get("intensity"),s=i.properties.get("direction"),l=1-e.d3(s.x,s.y,s.z)[2]/90,h=a(n)*o*l,u=r.properties.get("color").toNonPremultipliedRenderColor(null).toArray01(),c=r.properties.get("intensity");return Number(((h+a(u)*c)/2).toFixed(6))}getBrightness(){return this._brightness}getLights(){if(!this.enable3dLights())return null;let e=[];return this.directionalLight&&e.push(this.directionalLight.get()),this.ambientLight&&e.push(this.ambientLight.get()),e}enable3dLights(){return!!this.ambientLight&&!!this.directionalLight}getFragmentStyle(i){if(null==i||""===i&&this.isRootStyle())return this;if(e.dm(i)){let r=e.dn(i),a=this.fragments.find(({id:e})=>e===r);if(!a)return;let n=e.dl(i);return a.style.getFragmentStyle(n)}{let e=this.fragments.find(({id:e})=>e===i);return e?e.style:void 0}}setFeaturesetSelectors(i){if(!i)return;let r={},a=(e,i="")=>`${e}::${i}`;for(let n in this._featuresetSelectors={},i){let o=this._featuresetSelectors[n]=[];for(let s of i[n].selectors){let i;if(s.featureNamespace){let i=this.getOwnLayer(s.layer);if(!i){e.w(`Layer is undefined for selector: ${s.layer}`);continue}let o=a(i.source,i.sourceLayer);if(o in r&&r[o]!==s.featureNamespace){e.w(`"featureNamespace ${s.featureNamespace} of featureset ${n}'s selector is not associated to the same source, skip this selector`);continue}r[o]=s.featureNamespace}if(s.properties)for(let r in s.properties){let a=e.U(s.properties[r]);"success"===a.result&&((i=i||{})[r]=a.value)}o.push({layerId:s.layer,namespace:s.featureNamespace,properties:i,uniqueFeatureID:s._uniqueFeatureID})}}}getFeaturesetDescriptors(e){let i=this.getFragmentStyle(e);if(!i||!i.stylesheet.featuresets)return[];let r=[];for(let e in i.stylesheet.featuresets)r.push({featuresetId:e,importId:i.scope?i.scope:void 0});return r}getFeaturesetLayers(i,r){let a=this.getFragmentStyle(r),n=a.stylesheet.featuresets;if(!n||!n[i])return this.fire(new e.y(Error(`The featureset '${i}' does not exist in the map's style and cannot be queried.`))),[];let o=[];for(let e of n[i].selectors){let i=a.getOwnLayer(e.layer);i&&o.push(i)}return o}getConfigProperty(i,r){let a=this.getFragmentStyle(i);if(!a)return null;let n=e.B(r,a.scope),o=a.options.get(n),s=o?o.value||o.default:null;return s?s.serialize():null}setConfigProperty(i,r,a){let n,o=this.getFragmentStyle(i);if(!o)return;let s=o.stylesheet.schema;if(!s||!s[r])return;let l=e.U(a);if("success"!==l.result)return void i_(this,l.value);let h=l.value.expression,u=e.B(r,o.scope),c=o.options.get(u);if(!c)return;let{minValue:d,maxValue:p,stepValue:f,type:m,values:_}=s[r],g=e.U(s[r].default);"success"===g.result&&(n=g.value.expression),n?(this.options.set(u,Object.assign({},c,{value:h,default:n,minValue:d,maxValue:p,stepValue:f,type:m,values:_})),this.updateConfigDependencies(r)):this.fire(new e.y(Error(`No schema defined for the config option "${r}" in the "${i}" fragment.`)))}getConfig(i){let r=this.getFragmentStyle(i);if(!r)return null;let a=r.stylesheet.schema;if(!a)return null;let n={};for(let i in a){let a=e.B(i,r.scope),o=r.options.get(a),s=o?o.value||o.default:null;n[i]=s?s.serialize():null}return n}setConfig(e,i){let r=this.getFragmentStyle(e);r&&(r.updateConfig(i,r.stylesheet.schema),this.updateConfigDependencies())}getSchema(e){let i=this.getFragmentStyle(e);return i?i.stylesheet.schema:null}setSchema(e,i){let r=this.getFragmentStyle(e);r&&(r.stylesheet.schema=i,r.updateConfig(r._config,i),this.updateConfigDependencies())}updateConfig(i,r){if(this._config=i,i||r)if(r)for(let a in r){let n,o,s=e.U(r[a].default);if("success"===s.result&&(n=s.value.expression),i&&void 0!==i[a]){let r=e.U(i[a]);"success"===r.result&&(o=r.value.expression)}let{minValue:l,maxValue:h,stepValue:u,type:c,values:d}=r[a];if(n){let i=e.B(a,this.scope);this.options.set(i,{default:n,value:o,minValue:l,maxValue:h,stepValue:u,type:c,values:d})}
8else this.fire(new e.y(Error(`No schema defined for config option "${a}".`)))}else this.fire(new e.y(Error("Attempting to set config for a style without schema.")))}updateConfigDependencies(e){for(let i of this._configDependentLayers){let r=this.getLayer(i);if(r){if(e&&!r.configDependencies.has(e))continue;r.possiblyEvaluateVisibility(),this._updateLayer(r)}}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=>{let i=e._styleColorTheme.colorThemeOverride?e._styleColorTheme.colorThemeOverride:e._styleColorTheme.colorTheme;if(i){let r=e._evaluateColorThemeData(i);(!e._styleColorTheme.lut&&""!==r||e._styleColorTheme.lut&&r!==e._styleColorTheme.lut.data)&&e.setColorTheme(i)}}),this._changes.setDirty()}addLayer(i,r,a={}){let n;this._checkLoaded();let o=i.id;if(this._layers[o])return void this.fire(new e.y(Error(`Layer with i
8d "${o}" already exists on this map`)));if("custom"===i.type){if(i_(this,e.dp(i)))return;n=e.dq(i,this.scope,this._styleColorTheme.lut,this.options)}else{if("object"==typeof i.source&&(this.addSource(o,i.source),i=Object.assign(i=e.dk(i),{source:o})),this._validate(ew,`layers.${o}`,i,{arrayIndex:-1},a))return;n=e.dq(i,this.scope,this._styleColorTheme.lut,this.options),this._validateLayer(n),n.setEventedParent(this,{layer:{id:o}})}0!==n.configDependencies.size&&this._configDependentLayers.add(n.fqid);let s=this._order.length;if(r){let i=this._order.indexOf(r);if(-1===i)return void this.fire(new e.y(Error(`Layer with id "${r}" does not exist on this map.`)));n.slot===this._layers[r].slot?s=i:e.w(`Layer with id "${r}" has a different slot. Layers can only be rearranged within the same slot.`)}this._order.splice(s,0,o),this._layerOrderChanged=!0,this._layers[o]=n;let l=this.getOwnLayerSourceCache(n),h=!!this.directionalLight&&this.directionalLight.shadowsEnabled();l&&n.canCastShadows()&&h&&(l.castsShadows=!0);let u=this._changes.getRemovedLayer(n);if(u&&n.source&&l&&"custom"!==n.type){this._changes.discardLayerRemoval(n);let i=e.B(n.source,n.scope);u.type!==n.type?this._changes.updateSourceCache(i,"clear"):(this._changes.updateSourceCache(i,"reload"),l.pause())}this._updateLayer(n),n.onAdd&&n.onAdd(this.map),n.scope=this.scope,this.mergeLayers()}moveLayer(i,r){this._checkLoaded();let a=this._checkLayer(i);if(!a||i===r)return;let n=this._order.indexOf(i);this._order.splice(n,1);let o=this._order.length;if(r){let i=this._order.indexOf(r);
8if(-1===i)return void this.fire(new e.y(Error(`Layer with id "${r}" does not exist on this map.`)));a.slot===this._layers[r].slot?o=i:e.w(`Layer with id "${r}" has a different slot. Layers can only be rearranged within the same slot.`)}this._order.splice(o,0,i),this._changes.setDirty(),this._layerOrderChanged=!0,this.mergeLayers()}removeLayer(e){this._checkLoaded();let i=this._checkLayer(e);if(!i)return;i.setEventedParent(null);let r=this._order.indexOf(e);this._order.splice(r,1),delete this._layers[e],this._changes.setDirty(),this._layerOrderChanged=!0,this._configDependentLayers.delete(i.fqid),this._changes.removeLayer(i);let a=this.getOwnLayerSourceCache(i);if(a&&a.castsShadows){let e=!1;for(let r in this._layers)if(this._layers[r].source===i.source&&this._layers[r].canCastShadows()){e=!0;break}a.castsShadows=e}i.onRemove&&i.onRemove(this.map),this.mergeLayers()}getOwnLayer(e){return this._layers[e]}hasLayer(e){return e in this._mergedLayers}hasLayerType(e){for(let i in this._layers)if(this._layers[i].type===e)return!0;return!1}setLayerZoomRange(e,i,r){this._checkLoaded();let a=this._checkLayer(e);a&&(a.minzoom===i&&a.maxzoom===r||(null!=i&&(a.minzoom=i),null!=r&&(a.maxzoom=r),this._updateLayer(a)))}getSlots(){return this._checkLoaded(),this._mergedSlots}setSlot(e,i){this._checkLoaded();let r=this._checkLayer(e);r&&r.slot!==i&&(r.slot=i,this._updateLayer(r))}setFilter(i,r,a={}){this._checkLoaded();let n=this._checkLayer(i);if(n&&!e.by(n.filter,r))return null==r?(n.filter=void 0,void this._updateLayer(n)):void(this._validate(eT,`layers.${n.id}.filter`,r,{layerType:n.type},a)||(n.filter=e.dk(r),this._updateLayer(n)))}getFilter(i){let r=this._checkLayer(i);if(r)return e.dk(r.filter)}setLayoutProperty(i,r,a,n={}){this._checkLoaded();let o=this._checkLayer(i);if(o&&!e.by(o.getLayoutProperty(r),a)){if(null!=a&&(!n||!1!==n.validate)&&i_(o,eE.call(ef,{key:`layers.${i}.layout.${r}`,layerType:o.type,objectKey:r,value:a,styleSpec:e.a6,style:{glyphs:!0,sprite:!0}})))return;o.setLayoutProperty(r,a),0!==o.configDependencies.size&&this._configDependentLayers.add(o.fqid),this._updateLayer(o)}}getLayoutProperty(e,i){let r=this._checkLayer(e);if(r)return r.getLayoutProperty(i)}setPaintProperty(i,r,a,n={}){this._checkLoaded();let o=this._checkLayer(i);if(!o||e.by(o.getPaintProperty(r),a)||null!=a&&(!n||!1!==n.validate)&&i_(o,eS.call(ef,{key:`layers.${i}.paint.${r}`,layerType:o.type,objectKey:r,value:a,styleSpec:e.a6})))return;let s=o.setPaintProperty(r,a);0!==o.configDependencies.size&&this._configDependentLayers.add(o.fqid),s&&this._updateLayer(o),this._changes.updatePaintProperties(o)}getPaintProperty(e,i){let r=this._checkLayer(e);if(r)return r.getPaintProperty(i)}setFeatureState(i,r){if(this._checkLoaded(),"target"in i){if("featuresetId"in i.target){let{featuresetId:e,importId:a}=i.target,n=this.getFragmentStyle(a);for(let{source:a,sourceLayer:o}of n.getFeaturesetLayers(e))n.setFeatureState({id:i.id,source:a,sourceLayer:o},r)}else if("layerId"in i.target){let{layerId:e}=i.target,a=this.getLayer(e);this.setFeatureState({id:i.id,source:a.source,sourceLayer:a.sourceLayer},r)}return}let a=i.source,n=i.sourceLayer,o=this._checkSource(a);if(!o)return;let s=o.type;if("geojson"===s&&n)return void this.fire(new e.y(Error("GeoJSON sources cannot have a sourceLayer parameter.")));if("vector"===s&&!n)return void this.fire(new e.y(Error("The sourceLayer parameter must be provided for vector source types.")));for(let o of(void 0===i.id&&this.fire(new e.y(Error("The feature id parameter must be provided."))),this.getOwnSourceCaches(a)))o.setFeatureState(n,i.id,r)}removeFeatureState(i,r){if(this._checkLoaded(),"target"in i){if("featuresetId"in i.target){let{featuresetId:e,importId:a}=i.target,n=this.getFragmentStyle(a);for(let{source:a,sourceLayer:o}of n.getFeaturesetLayers(e))n.removeFeatureState({id:i.id,source:a,sourceLayer:o},r)}else if("layerId"in i.target){let{layerId:e}=i.target,a=this.getLayer(e);this.removeFeatureState({id:i.id,source:a.source,sourceLayer:a.sourceLayer},r)}return}let a=i.source,n=this._checkSource(a);if(!n)return;let o=n.type,s="vector"===o?i.sourceLayer:void 0;if("vector"===o&&!s)return void this.fire(new e.y(Error("The sourceLayer parameter must be provided for vector source types.")));if(r&&"string"!=typeof i.id&&"number"!=typeof i.id)return void this.fire(new e.y(Error("A feature id is required to remove its specific state property.")));for(let e of this.getOwnSourceCaches(a))e.removeFeatureState(s,i.id,r)}getFeatureState(i){if(this._checkLoaded(),"target"in i){let r;if("featuresetId"in i.target){let{featuresetId:a,importId:n}=i.target,o=this.getFragmentStyle(n);for(let{source:n,sourceLayer:s}of o.getFeaturesetLayers(a)){let a=o.getFeatureState({id:i.id,source:n,sourceLayer:s});if(a&&!r)r=a;else if(!e.by(r,a))return void this.fire(new e.y(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 i.target){let{layerId:e}=i.target,a=this.getLayer(e);r=this.getFeatureState({id:i.id,source:a.source,sourceLayer:a.sourceLayer})}return r}let r=i.source,a=i.sourceLayer,n=this._checkSource(r);if(n){if("vector"!==n.type||a)return void 0===i.id&&this.fire(new e.y(Error("The feature id parameter must be provided."))),this.getOwnSourceCaches(r)[0].getFeatureState(a,i.id);this.fire(new e.y(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();let i=this.getTerrain(),r=i&&this.terrain&&this.terrain.scope===this.scope?i:this.stylesheet.terrain;return e.dr({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:r,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(let i of Object.values(this._mergedLayers))e(i)&&this._updateLayer(i)}_updateLayer(i){this._changes.updateLayer(i);let r=this.getLayerSourceCache(i),a=e.B(i.source,i.scope),n=this._changes.getUpd
8atedSourceCaches();i.source&&!n[a]&&r&&"raster"!==r.getSource().type&&(this._changes.updateSourceCache(a,"reload"),r.pause()),i.invalidateCompiledFilter()}_flattenAndSortRenderedFeatures(e){let i=e=>this._mergedLayers[e].is3D(!!this.terrain),r=this.order,a={},n=[];for(let o=r.length-1;o>=0;o--){let s=r[o];if(i(s))for(let i of(a[s]=o,e)){let e=i[s];if(e)for(let i of e)n.push(i)}}n.sort((e,i)=>i.intersectionZ-e.intersectionZ);let o=[];for(let s=r.length-1;s>=0;s--){let l=r[s];if(i(l))for(let e=n.length-1;e>=0;e--){let i=n[e].feature;if(i.layer&&a[i.layer.id]<s)break;o.push(i),n.pop()}else for(let i of e){let e=i[l];if(e)for(let i of e)o.push(i.feature)}}return o}queryRasterValue(i,r,a){let n=this.getOwnSource(i);return n?"raster-array"!==n.type?(this.fire(new e.y(Error('queryRasterValue support only "raster-array" sources.'))),Promise.resolve(null)):n.queryRasterArrayValue(r,a):(this.fire(new e.y(Error(`Source with id "${i}" does not exist in the style.`))),Promise.resolve(null))}queryRenderedFeatures(i,r,a){let n;r&&!Array.isArray(r)&&r.filter&&(this._validate(eT,"queryRenderedFeatures.filter",r.filter,null,r),n=e.b6(r.filter));let o={},s=e=>{if(ix.has(e.type))return;let i=this.getOwnLayerSourceCache(e),r=o[i.id]=o[i.id]||{sourceCache:i,layers:{},has3DLayers:!1};e.is3D(!!this.terrain)&&(r.has3DLayers=!0),r.layers[e.fqid]=r.layers[e.fqid]||{styleLayer:e,targets:[]},r.layers[e.fqid].targets.push({filter:n})};if(r&&r.layers){if(!Array.isArray(r.layers))return this.fire(new e.y(Error("parameters.layers must be an Array."))),[];for(let i of r.layers){let r=this._layers[i];if(!r)return this.fire(new e.y(Error(`The layer '${i}' does not exist in the map's style and cannot be queried for features.`))),[];s(r)}}else for(let e in this._layers)s(this._layers[e]);let l=this._queryRenderedFeatures(i,o,a),h=this._flattenAndSortRenderedFeatures(l),u=[];for(let i of h)e.ds(i.layer.id)===this.scope&&u.push(i);return u}queryRenderedFeatureset(i,r,a){let n;r&&!Array.isArray(r)&&r.filter&&(this._validate(eT,"queryRenderedFeatures.filter",r.filter,null,r),n=e.b6(r.filter));let o="mock",s=[];if(r&&r.target)s.push(Object.assign({},r,{targetId:o,filter:n}));else{for(let e of this.getFeaturesetDescriptors())s.push({targetId:o,filter:n,target:e});for(let{style:e}of this.fragments)for(let i of e.getFeaturesetDescriptors())s.push({targetId:o,filter:n,target:i})}let l=this.queryRenderedTargets(i,s,a),h=[],u=new Set;for(let i of l)for(let r of i.variants[o])e1(r,i,u)||h.push(new e.dt(i,r));return h}queryRenderedTargets(i,r,a){let n={},o=(e,i,r,a)=>{let o=n[i.id]=n[i.id]||{sourceCache:i,layers:{},has3DLayers:!1};if(o.layers[e.fqid]=o.layers[e.fqid]||{styleLayer:e,targets:[]},e.is3D(!!this.terrain)&&(o.has3DLayers=!0),!a)return r.uniqueFeatureID=!1,void o.layers[e.fqid].targets.push(r);o.layers[e.fqid].targets.push(Object.assign({},r,{namespace:a.namespace,properties:a.properties,uniqueFeatureID:a.uniqueFeatureID}))};for(let i of r)if("featuresetId"in i.target){let{featuresetId:r,importId:a}=i.target,n=this.getFragmentStyle(a);if(!n||!n._featuresetSelectors)continue;let s=n._featuresetSelectors[r];if(!s){this.fire(new e.y(Error(`The featureset '${r}' does not exist in the map's style and cannot be queried for features.`)));continue}for(let e of s){let r=n.getOwnLayer(e.layerId);r&&!ix.has(r.type)&&o(r,n.getOwnLayerSourceCache(r),i,e)}}else if("layerId"in i.target){let{layerId:e}=i.target,r=this.getLayer(e);if(!r||ix.has(r.type))continue;o(r,this.getLayerSourceCache(r),i)}let s=this._queryRenderedFeatures(i,n,a);return this._flattenAndSortRenderedFeatures(s)}_queryRenderedFeatures(e,i,r){let a=[],n=!!this.map._showQueryGeometry,o=eG.createFromScreenPoints(e,r);for(let e in i){let s=function(e,i,r,a,n=!1){let o=i.sourceCache.transform,s=i.sourceCache.tilesIn(e,i.has3DLayers,n);s.sort(e2);let l=[];for(let e of s){let s=e.tile.queryRenderedFeatures(i,e,r,a,o,n);Object.keys(s).length&&l.push({wrappedTileID:e.tile.tileID.wrapped().key,queryResults:s})}return 0===l.length?{}:function(e){let i={},r={};for(let a of e){let e=a.queryResults,n=a.wrappedTileID,o=r[n]=r[n]||{};for(let r in e){let a=e[r],n=o[r]=o[r]||{},s=i[r]=i[r]||[];for(let e of a)n[e.featureIndex]||(n[e.featureIndex]=!0,s.push(e))}}return i}(l)}(o,i[e],this._availableImages,r,n);Object.keys(s).length&&a.push(s)}if(this.placement)for(let e in i){if(!i[e].sourceCache._onlySymbols)continue;let r=function(e,i,r,a,n,o){let s={},l=a.queryRenderedSymbols(e),h=[];for(let e of Object.keys(l).map(Number))h.push(n[e]);for(let e of(h.sort(e2),h)){let a=e.featureIndex.lookupSymbolFeatures(l[e.bucketInstanceId],e.bucketIndex,e.sourceLayerIndex,i,r,o);for(let i in a){let r=s[i]=s[i]||[],n=a[i];for(let i of(n.sort((i,r)=>{let a=e.featureSortOrder;if(a){let e=a.indexOf(i.featureIndex);return a.indexOf(r.featureIndex)-e}return r.featureIndex-i.featureIndex}),n))r.push(i)}}return s}(o.screenGeometry,i[e],this._availableImages,this.placement.collisionIndex,this.placement.retainedQueryData,this.map.getWorldview());Object.keys(r).length&&a.push(r)}return a}querySourceFeatures(e,i){let r=i&&i.filter;
8r&&this._validate(eT,"querySourceFeatures.filter",r,null,i);let a=[];for(let r of this.getOwnSourceCaches(e))a=a.concat(function(e,i){let r=e.getRenderableIds().map(i=>e.getTileByID(i)),a=[],n={};for(let e=0;e<r.length;e++){let o=r[e],s=o.tileID.canonical.key;n[s]||(n[s]=!0,o.querySourceFeatures(a,i))}return a}(r,i));return a}addSourceType(e,i,r){return iw.getSourceType(e)?r(Error(`A source type called "${e}" already exists.`)):(iw.setSourceType(e,i),i.workerSourceURL?void this.dispatcher.broadcast("loadWorkerSource",{name:e,url:i.workerSourceURL},r):r(null,null))}getFlatLight(){return this.light.getLight()}setFlatLight(i,r,a={}){this._checkLoaded();let n=this.light.getLight(),o=!1;for(let r in i)if(!e.by(i[r],n[r])){o=!0;break}if(!o)return;let s=this._getTransitionParameters();this.light.setLight(i,r,a),this.light.updateTransitions(s)}getTerrain(){return this.terrain&&1===this.terrain.drapeRenderMode?this.terrain.get():null}setTerrainForDraping(){this.setTerrain({source:"",exaggeration:0},0)}checkCanvasFingerprintNoise(){void 0===this.disableElevatedTerrain&&(this.disableElevatedTerrain=e.o.hasCanvasFingerprintNoise(),this.disableElevatedTerrain&&e.w("Terrain and hillshade are disabled because of Canvas2D limitations when fingerprinting protection is enabled (e.g. in private browsing mode)."))}setTerrain(i,r=1){if(this._checkLoaded(),!i)return this.terrainSetForDrapingOnly()||(delete this.terrain,this.map.transform.projection.requiresDraping&&this.setTerrainForDraping()),0===r&&delete this.terrain,null===i?this.stylesheet.terrain=null:delete this.stylesheet.terrain,this._force3DLayerUpdate(),void(this._markersNeedUpdate=!0);this.checkCanvasFingerprintNoise();let a=i,n=null==i.source;if(1===r){if(this.disableElevatedTerrain)return;if("object"==typeof a.source){let i="terrain-dem-src";this.addSource(i,a.source),a=Object.assign(a=e.dk(a),{source:i})}let i=Object.assign({},a),r={};if(this.terrain&&n){i.source=this.terrain.get().source;let e=this.terrain?this.getFragmentStyle(this.terrain.scope):null;e&&(r.style=e.serialize())}if(this._validate(ey,"terrain",i,r))return}if(this.terrain&&(this.terrain.scope===this.scope||n)&&(!this.terrain||r===this.terrain.drapeRenderMode)){let r=this.terrain,n=r.get();for(let i of Object.keys(e.a6.terrain))!a.hasOwnProperty(i)&&e.a6.terrain[i].default&&(a[i]=e.a6.terrain[i].default);for(let a in i)if(!e.by(i[a],n[a])){r.set(i,this.options),this.stylesheet.terrain=i;let a=this._getTransitionParameters({duration:0});r.updateTransitions(a),this.fire(new e.z("data",{dataType:"style"}));break}}else{if(!a)return;this._createTerrain(a,r),this.fire(new e.z("data",{dataType:"style"}))}this.mergeTerrain(),this.updateDrapeFirstLayers(),this._markersNeedUpdate=!0}_createFog(e){let i=this.fog=new eO(e,this.map.transform,this.scope,this.options);this.stylesheet.fog=i.get();let r=this._getTransitionParameters({duration:0});i.updateTransitions(r)}_createSnow(e){let i=this.snow=new eV(e,this.map.transform,this.scope,this.options);this.stylesheet.snow=i.get();let r=this._getTransitionParameters({duration:0});i.updateTransitions(r)}_createRain(e){let i=this.rain=new eU(e,this.map.transform,this.scope,this.options);this.stylesheet.rain=i.get();let r=this._getTransitionParameters({duration:0});i.updateTransitions(r)}_updateMarkersOpacity(){0!==this.map._markers.length&&this.map._requestDomTask(()=>{for(let e of this.map._markers)e._evaluateOpacity()})}getFog(){return this.fog?this.fog.get():null}setFog(i){if(this._checkLoaded(),!i)return delete this.fog,delete this.stylesheet.fog,void(this._markersNeedUpdate=!0);if(this.fog){let r=this.fog;if(!e.by(r.get(),i)){r.set(i,this.options),this.stylesheet.fog=r.get();let e=this._getTransitionParameters({duration:0});r.updateTransitions(e)}}else this._createFog(i);this._markersNeedUpdate=!0}getSnow(){return this.snow?this.snow.get():null}setSnow(i){if(this._checkLoaded(),!i)return delete this.snow,void delete this.stylesheet.snow;if(this.snow){let r=this.snow;if(!e.by(r.get(),i)){r.set(i,this.options),this.stylesheet.snow=r.get();let e=this._getTransitionParameters({duration:0});r.updateTransitions(e)}}else this._createSnow(i);
8this._markersNeedUpdate=!0}getRain(){return this.rain?this.rain.get():null}setRain(i){if(this._checkLoaded(),!i)return delete this.rain,void delete this.stylesheet.rain;if(this.rain){let r=this.rain;if(!e.by(r.get(),i)){r.set(i,this.options),this.stylesheet.rain=r.get();let e=this._getTransitionParameters({duration:0});r.updateTransitions(e)}}else this._createRain(i);this._markersNeedUpdate=!0}_reloadColorTheme(){let i=()=>{for(let e in this._layers)this._layers[e].lut=this._styleColorTheme.lut;for(let e in this._sourceCaches)this._sourceCaches[e].clearTiles()},r=this._styleColorTheme.colorThemeOverride?this._styleColorTheme.colorThemeOverride:this._styleColorTheme.colorTheme;if(!r)return this._styleColorTheme.lut=null,void i();let a=this._evaluateColorThemeData(r);this._loadColorTheme(a).then(()=>{this.fire(new e.z("colorthemeset")),i()}).catch(i=>{e.w(`Couldn't set color theme: ${i}`)})}setColorTheme(i){this._checkLoaded(),this._styleColorTheme.colorThemeOverride&&e.w("Note: setColorTheme is called on a style with a color-theme override, the passed color-theme won't be visible."),this._styleColorTheme.colorTheme=i,this._reloadColorTheme()}setImportColorTheme(e,i){let r=this.getFragmentStyle(e);r&&(r._styleColorTheme.colorThemeOverride=i,r._reloadColorTheme())}_getTransitionParameters(i){return{now:e.o.now(),transition:Object.assign(this.transition,i)}}updateDrapeFirstLayers(){if(!this.terrain)return;let e=[],i=[];for(let r of this._mergedOrder)this.isLayerDraped(this._mergedLayers[r])?e.push(r):i.push(r);this._drapedFirstOrder=[],this._drapedFirstOrder.push(...e),this._drapedFirstOrder.push(...i)}_createTerrain(e,i){let r=this.terrain=new eP(e,i,this.scope,this.options,this.map.getWorldview());1===i&&(this.stylesheet.terrain=e),this.mergeTerrain(),this.updateDrapeFirstLayers(),this._force3DLayerUpdate();let a=this._getTransitionParameters({duration:0});r.updateTransitions(a)}_force3DLayerUpdate(){for(let e in this._layers){let i=this._layers[e];"fill-extrusion"===i.type&&this._updateLayer(i)}}_forceSymbolLayerUpdate(){for(let e in this._layers){let i=this._layers[e];"symbol"===i.type&&this._updateLayer(i)}}_validate(i,r,a,n,o={}){if(o&&!1===o.validate)return!1;let s=Object.assign({},this.serialize());return i_(this,i.call(ef,Object.assign({key:r,style:s,value:a,styleSpec:e.a6},n)))}_remove(){for(let i in this._request&&(this._request.cancel(),this._request=null),this._spriteRequest&&(this._spriteRequest.cancel(),this._spriteRequest=null),e.du.off("pluginStateChange",this._rtlTextPluginCallback),this._mergedLayers)this._mergedLayers[i].setEventedParent(null);for(let 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())}
8clearSource(e){for(let i of this.getSourceCaches(e))i.clearTiles()}clearSources(){for(let e in this._mergedSourceCaches)this._mergedSourceCaches[e].clearTiles()}clearLayers(){for(let e in this._mergedLayers){let i=this._mergedLayers[e];i._clear&&i._clear()}}reloadSource(e){for(let i of this.getSourceCaches(e))i.resume(),i.reload()}reloadSources(){for(let e of this.getSources())e.reload&&e.reload()}reloadModels(){this.modelManager.reloadModels(""),this.forEachFragmentStyle(e=>{e.modelManager.reloadModels(e.scope)})}updateSources(e){let i;this.directionalLight&&(i=ih(this.directionalLight));let r=new Set;for(let e in this._mergedLayers){let i=this._mergedLayers[e];i.hasElevation()&&!r.has(i.source)&&r.add(i.source)}for(let a in this._mergedSourceCaches){let n=this._mergedSourceCaches[a],o=r.has(n._source.id);n.update(e,void 0,void 0,i,o)}}_generateCollisionBoxes(){for(let e in this._sourceCaches){let i=this._sourceCaches[e];i.resume(),i.reload()}}_updatePlacement(i,r,a,n,o,s,l=!1){let h=!1,u=!1,c={},d={};for(let i of this._mergedOrder){let a=this._mergedLayers[i];if("symbol"!==a.type)continue;let n=e.B(a.source,a.scope),o=c[n];if(!o){let e=this.getLayerSourceCache(a);if(!e)continue;let i=e.getRenderableIds(!0).map(i=>e.getTileByID(i));d[n]=i.slice(),o=c[n]=i.sort((e,i)=>i.tileID.overscaledZ-e.tileID.overscaledZ||(e.tileID.isLessThan(i.tileID)?-1:1))}let s=this.crossTileSymbolIndex.addLayer(a,o,r.center.lng,r.projection);h=h||s}if(this.crossTileSymbolIndex.pruneUnusedLayers(this._mergedOrder),l=l||this._layerOrderChanged||0===n,this._layerOrderChanged&&this.fire(new e.z("neworder")),(l||!this.pauseablePlacement||this.pauseablePlacement.isDone()&&!this.placement.stillRecent(e.o.now(),r.zoom))&&(this.pauseablePlacement=new tX(r,this._mergedOrder,l,a,n,o,this.placement,this.fog&&r.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,d,this.map.painter.scaleFactor),this.pauseablePlacement.isDone()&&(this.placement=this.pauseablePlacement.commit(e.o.now()),u=!0),h&&this.pauseablePlacement.placement.setStale()),u||h){this._buildingIndex.onNewFrame(r.zoom);for(let i=0;i<this._mergedOrder.length;i++){let r=this._mergedLayers[this._mergedOrder[i]];if("symbol"!==r.type)continue;let a=this.isLayerClipped(r);this.placement.updateLayerOpacities(r,c[e.B(r.source,r.scope)],i,a?s:null)}}return{needsRerender:!this.pauseablePlacement.isDone()||this.placement.hasTransitions(e.o.now())}}_releaseSymbolFadeTiles(){for(let e in this._sourceCaches)this._sourceCaches[e].releaseSymbolFadeTiles()}addImport(i,r){this._checkLoaded();let a=this.stylesheet.imports=this.stylesheet.imports||[];if(-1!==a.findIndex(({id:e})=>e===i.id))return void this.fire(new e.y(Error(`Import with id '${i.id}' already exists in the map's style.`)));if(!r)return a.push(i),this._loadImports([i],!0);let n=a.findIndex(({id:e})=>e===r);return -1===n&&this.fire(new e.y(Error(`Import with id "${r}" does not exist on this map.`))),this.stylesheet.imports=a.slice(0,n).concat(i).concat(a.slice(n)),this._loadImports([i],!0,r)}updateImport(i,r){this._checkLoaded();let a=this.stylesheet.imports||[],n=this.getImportIndex(i);return -1===n||("string"==typeof r?this.setImportUrl(i,r):(r.url&&r.url!==a[n].url&&this.setImportUrl(i,r.url),e.by(r.config,a[n].config)||this.setImportConfig(i,r.config,r.data.schema),e.by(r.data,a[n].data)||this.setImportData(i,r.data))),this}moveImport(e,i){this._checkLoaded();let r=this.stylesheet.imports||[],a=this.getImportIndex(e);if(-1===a)return this;let n=this.getImportIndex(i);if(-1===n)return this;let o=r[a],s=this.fragments[a];return r=r.filter(({id:i})=>i!==e),this.fragments=this.fragments.filter(({id:i})=>i!==e),this.stylesheet.imports=r.slice(0,n).concat(o).concat(r.slice(n)),this.fragments=this.fragments.slice(0,n).concat(s).concat(this.fragments.slice(n)),this.mergeLayers(),this}setImportUrl(e,i){this._checkLoaded();let r=this.stylesheet.imports||[],a=this.getImportIndex(e);if(-1===a)return this;r[a].url=i;let n=this.fragments[a];return n.style=this._createFragmentStyle(r[a]),n.style.on("style.import.load",()=>this.mergeAll()),n.style.loadURL(i),this}setImportData(e,i){this._checkLoaded();let r=this.getImportIndex(e),a=this.stylesheet.imports||[];return -1===r?this:i?(this.fragments[r].style.setState(i),this._reloadImports(),this):(delete a[r].data,this.setImportUrl(e,a[r].url))}setImportConfig(e,i,r){this._checkLoaded();let a=this.getImportIndex(e),n=this.stylesheet.imports||[];if(-1===a)return this;i?n[a].config=i:delete n[a].config;let o=this.fragments[a];r&&o.style.stylesheet&&(o.style.stylesheet.schema=r);let s=o.style.stylesheet&&o.style.stylesheet.schema;return o.config=i,o.style.updateConfig(i,s),this.updateConfigDependencies(),this}removeImport(e){this._checkLoaded();let i=this.stylesheet.imports||[],r=this.getImportIndex(e);-1!==r&&(i.splice(r,1),this.fragments[r].style._remove(),this.fragments.splice(r,1),this._reloadImports())}getImportIndex(i){let r=(this.stylesheet.imports||[]).findIndex(e=>e.id===i);return -1===r&&this.fire(new e.y(Error(`Import '${i}' does not exist in the map's style and cannot be updated.`))),r}getLayer(e){return this._mergedLayers[e]}getSources(){let e=[];for(let i in this._mergedOtherSourceCaches){let r=this._mergedOtherSourceCaches[i];r&&e.push(r.getSource())}return e}getSource(e,i){let r=this.getSourceCache(e,i);return r&&r.getSource()}getLayerSource(e){let i=this.getLayerSourceCache(e);return i&&i.getSource()}getSourceCache(i,r){let a=e.B(i,r);return this._mergedOtherSourceCaches[a]}getLayerSourceCache(i){let r=e.B(i.source,i.scope);return"symbol"===i.type?this._mergedSymbolSourceCaches[r]:this._mergedOtherSourceCaches[r]}getSourceCaches(e){if(null==e)return Object.values(this._mergedSourceCaches);let i=[];return this._mergedOtherSourceCaches[e]&&i.push(this._mergedOtherSourceCaches[e]),this._mergedSymbolSourceCaches[e]&&i.push(this._mergedSymbolSourceCaches[e]),i}
8updateSourceCaches(){let e=this._changes.getUpdatedSourceCaches();for(let i in e){let r=e[i];"reload"===r?this.reloadSource(i):"clear"===r&&this.clearSource(i)}}updateLayers(e){for(let i of this._changes.getUpdatedPaintProperties()){let r=this.getLayer(i);r&&r.updateTransitions(e)}}getGlyphsUrl(){return this.stylesheet.glyphs}setGlyphsUrl(e){this.stylesheet.glyphs=e,this.glyphManager.setURL(e)}getImages(i,r,a){this.imageManager.getImages(r.images,r.scope,a),this._updateTilesForChangedImages();let n=i=>{if(i){let a=r.images.map(i=>e.I.toString(i));i.setDependencies(r.tileID.key,r.type,a)}},o=e.B(r.source,r.scope);n(this._mergedOtherSourceCaches[o]),n(this._mergedSymbolSourceCaches[o]),r.images.some(e=>e.iconsetId)&&this.fire(new e.z("data",{dataType:"style"}))}rasterizeImages(e,i,r){this.imageManager.rasterizeImages(i,r)}getGlyphs(e,i,r){this.glyphManager.getGlyphs(i.stacks,r)}getResource(i,r,a){return e.dv(r,a)}getOwnSourceCache(e){return this._otherSourceCaches[e]}getOwnLayerSourceCache(e){return"symbol"===e.type?this._symbolSourceCaches[e.source]:this._otherSourceCaches[e.source]}getOwnSourceCaches(e){let i=[];return this._otherSourceCaches[e]&&i.push(this._otherSourceCaches[e]),this._symbolSourceCaches[e]&&i.push(this._symbolSourceCaches[e]),i}_isSourceCacheLoaded(i){let r=this.getOwnSourceCaches(i);return 0===r.length?(this.fire(new e.y(Error(`There is no source with ID '${i}'`))),!1):r.every(e=>e.loaded())}has3DLayers(){return this._has3DLayers}hasSymbolLayers(){return this._hasSymbolLayers}hasCircleLayers(){return this._hasCircleLayers}isLayerClipped(e,i){if(!this._clipLayerPresent&&"fill-extrusion"!==e.type&&"building"!==e.type)return!1;let r="fill-extrusion"===e.type&&("building"===e.sourceLayer||"procedural_buildings"===e.sourceLayer),a="building"===e.type;if(e.is3D(!!this.terrain)){if(r||a||i&&"batched-model"===i.type||"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)}}iw.getSourceType=function(e){return eJ[e]},iw.setSourceType=function(e,i){eJ[e]=i},iw.registerForPluginStateChange=e.dw;class iT{execute(e){let i=this._makeBuildingsQueryArea(e),r=this._makeFloorsQueryArea(e),a=e.queryRenderedFeatures(i).reduce((e,i)=>{let r=i.properties.id;return"building"!==i.properties.type||e.some(e=>e.properties.id===r)||e.push(i),e},[]),n=e.queryRenderedFeatures(r).reduce((e,i)=>{let r=i.properties.id;return"floor"!==i.properties.type||e.some(e=>e.properties.id===r)||e.push(i),e},[]),o=[e.getCenter().lng,e.getCenter().lat],s=this._findBuildingAtCenter(o,a),l=a.length>0?a[0]:null;return{floors:n.map(e=>({id:e.properties.id,name:e.properties.name,isDefault:e.properties.is_default,zIndex:e.properties.z_index,connectedFloorIds:e.properties.connected_floor_ids,conflictedFloorIds:e.properties.conflicted_floor_ids,buildingIds:e.properties.building_ids})),building:s?{id:s.properties.id,name:s.properties.name}:{id:l.properties.id,name:l.properties.name}}}_makeBuildingsQueryArea(i){let r=i.transform.width,a=i.transform.height,n=1/8*Math.min(r,a),o=.5*(r-n),s=.5*(a-n);return[new e.P(o,s),new e.P(o+n,s+n)]}_makeFloorsQueryArea(i){let r=i.transform.width,a=i.transform.height;return[new e.P(0,0),new e.P(r,a)]}_findBuildingAtCenter(e,i){for(let r of i)if("Polygon"===r.geometry.type&&this._pointInPolygon(e,r.geometry.coordinates[0]))return r;return null}_pointInPolygon(e,i){let r=!1;for(let a=0,n=i.length-1;a<i.length;n=a++){let o=i[a][0],s=i[a][1],l=i[n][1];s>e[1]!=l>e[1]&&e[0]<(i[n][0]-o)*(e[1]-s)/(l-s)+o&&(r=!r)}return r}}class iS{constructor(){this._floors=new Map,this._buildings=new Map}append(e){let i=e.building,r=!1;if(i){let e=i.id;e&&(this._buildings.set(e,i),r||this._buildings.has(e)||(r=!0))}return e.floors.forEach(e=>{let i=e.id;r||this._floors.has(i)||(r=!0),this._floors.set(i,e)}),r}clear(){this._floors.clear(),this._buildings.clear()}getFloors(e=null){let i=Array.from(this._floors.values());return e?i.filter(i=>{let r=i.buildingIds;return!!r&&r.split(";").includes(e)}):i}}class iE{constructor(){this._selectedFloorId=null,this._selectedBuildingId=null,this._lastActiveFloors=[],this._featuresStorage=new iS}setIndoorData(e){let i=this._featuresStorage.append(e);return this._selectedBuildingId=e.building?e.building.id:null,i}setFloorId(e){let i=this._selectedFloorId!==e;return i&&(this._selectedFloorId=e),i}getCurrentBuildingSelection(){if(!this._selectedBuildingId)return{selectedFloorId:null,floors:[]};let e=this._featuresStorage.getFloors(this._selectedBuildingId),i=this.getActiveFloors().find(e=>{let i=e.buildingIds;if(!i)return!1;let r=i.split(";");return!!this._selectedBuildingId&&r.includes(this._selectedBuildingId)});return{selectedFloorId:i?i.id:null,floors:e}}getActiveFloors(e=!1){let i=this._featuresStorage.getFloors(),r=i.find(e=>e.id===this._selectedFloorId),a=i.filter(e=>!0===e.isDefault),n=[];if(r)return this._calculateCurrentActiveFloors(i,r,a,e);if(0===a.length){let e=this._featuresStorage.getFloors(this._selectedBuildingId);n=e.length>0?[e[0]]:[]}else n=a;let o=this._getNonConflictingLastActiveFloors(n),s=[...n,...o];return this._lastActiveFloors=s,s}hasBuildingChanged(e){return this._selectedBuildingId!==(e.building?e.building.id:null)}hasActiveBuilding(){return null!==this._selectedBuildingId}isEmpty(){return null===this._selectedFloorId&&null===this._selectedBuildingId&&0===this._lastActiveFloors.length}_calculateCurrentActiveFloors(e,i,r,a){if(!i)return this._getNonConflictingDefaultFloors(this._lastActiveFloors,r);let n=this._getConnectedFloors(i,e);return a?this._buildExplicitSelectionFloors(i,n,r):this._buildImplicitSelectionFloors(n,r)}_getConnectedFloors(e,i){let r=e.connectedFloorIds;
8if(!r)return[];let a=new Set(r.split(";"));return i.filter(e=>a.has(e.id))}_buildExplicitSelectionFloors(e,i,r){let a=[e,...i],n=this._getNonConflictingLastActiveFloors(a),o=[...a,...n],s=this._deduplicateFloors(o),l=this._getConflictingFloorIdsFrom(s),h=[...s,...r.filter(e=>!l.has(e.id))];return this._lastActiveFloors=h,h}_buildImplicitSelectionFloors(e,i){let r=this._getConflictingFloorIdsFrom(this._lastActiveFloors),a=i.filter(e=>!r.has(e.id)),n=this._deduplicateFloors([...this._lastActiveFloors,...a]);return this._lastActiveFloors=n,n}_getNonConflictingDefaultFloors(e,i){let r=this._getConflictingFloorIdsFrom(e),a=i.filter(e=>!r.has(e.id)),n=this._deduplicateFloors([...e,...a]);return this._lastActiveFloors=n,n}_deduplicateFloors(e){let i=new Set;return e.filter(e=>{let r=e.id;return!i.has(r)&&(i.add(r),!0)})}_getConflictingFloorIdsFrom(e){let i=new Set;return e.forEach(e=>{let r=e.conflictedFloorIds;r&&r.split(";").forEach(e=>i.add(e))}),i}_getNonConflictingLastActiveFloors(e){if(!this._lastActiveFloors||0===this._lastActiveFloors.length)return[];let i=new Set(e.map(e=>e.id)),r=this._getConflictingFloorIdsFrom(e);return this._lastActiveFloors.filter(e=>{let a=e.id;return!i.has(a)&&!r.has(a)})}_isFloorConflicted(e,i){let r=e.id;return i.some(e=>{let i=e.conflictedFloorIds;return!!i&&i.split(";").includes(r)})}reset(){this._selectedFloorId=null,this._selectedBuildingId=null,this._lastActiveFloors=[],this._featuresStorage.clear()}}class iI extends e.E{constructor(i){super(),e.aY(["_onLoad","_onMove"],this),this._map=i,this._floorSelectionState=new iE,this._queryIndoor(),this._map.on("load",this._onLoad),this._map.on("move",this._onMove)}destroy(){this._map.off("load",this._onLoad),this._map.off("move",this._onMove),this._map=null,this._floorSelectionState=null}selectFloor(e){this._floorSelectionState.setFloorId(e)&&this._updateIndoorConfig(!0)}_onLoad(){this._map.style.forEachFragmentStyle(i=>{i.stylesheet.indoor&&(this._indoorDataQuery?this.fire(new e.y(Error("Multiple indoor map styles detected, simultaneous usage is not allowed currently."))):(this._scope=i.scope,this._indoorDataQuery=new iT))}),this._map._addIndoorControl(),this._queryIndoor()}_onMove(){this._queryIndoor()}_queryIndoor(){if(!this._indoorDataQuery||!this._map.isStyleLoaded())return;if(this._map.transform.zoom<15)return void this._clearIndoorData();let e=this._indoorDataQuery.execute(this._map);if(!e||0===e.floors.length||this._map.transform.zoom<16)this._clearIndoorData();else if(this._floorSelectionState.hasBuildingChanged(e)){if(!e.building&&this._floorSelectionState.getActiveFloors().length<=0)return void this._clearIndoorData();this._setIndoorData(e),e.building&&this._updateIndoorSelector()}else this._setIndoorData(e)}_setIndoorData(e){this._floorSelectionState.setIndoorData(e)&&this._updateIndoorConfig()}_clearIndoorData(){this._floorSelectionState.isEmpty()||(this._floorSelectionState.reset(),this._updateIndoorSelector(),this._map.setConfigProperty(this._scope,"activeFloors",["literal",[]]))}_updateIndoorSelector(){let i=this._floorSelectionState.getCurrentBuildingSelection(),r=i.floors.map(e=>({id:e.id,name:e.name,shortName:e.zIndex.toString(),levelOrder:e.zIndex}));this.fire(new e.z("indoorupdate",{selectedFloorId:i.selectedFloorId,floors:r}))}_updateIndoorConfig(e=!1){let i=this._floorSelectionState.getActiveFloors(e).map(e=>e.id)||[];this._map.setConfigProperty(this._scope,"activeFloors",["literal",i])}}var iA="\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",iC="\nout vec4 glFragColor;highp 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;
8float 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;}",iM="\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);}",iP="in highp vec3 a_pos_3f;uniform lowp mat4 u_matrix;out highp vec3 v_uv;
8void 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;}",iz="\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 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_
8size_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;int 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;highp 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//DEPTH_OCCLUSION",iR="#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",iD="#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;}
8vec3 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",iL="#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",iO="#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;}",iF="#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];}
8\n#endif//RENDER_SHADOWS",ik="#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";let iB=[];iG(iA,iB),iG(iM,iB),iG(iC,iB);let iN={"_prelude_fog.vertex.glsl":iR,"_prelude_terrain.vertex.glsl":iz,"_prelude_shadow.vertex.glsl":iF,"_prelude_fog.fragment.glsl":iD,"_prelude_shadow.fragment.glsl":ik,"_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
8));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//LIGHTING_3D_MODE","_prelude_raster_array.glsl":iL,"_prelude_raster_particle.glsl":iO},iV={};iq("",iz),iq(iD,iR),iq(ik,iF),iq(iL,""),iq(iO,"");let iU=iq(iC,iM);var ij={background:iq('#include "_prelude_fog.fragment.glsl"\n#include "_prelude_lighting.glsl"\nuniform vec4 u_color;uniform float u_opacity;\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 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;\n#ifdef LIGHTING_3D_MODE\nuniform mediump vec4 u_color;out vec4 v_color;uniform float u_emissive_strength;\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:iq('#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 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:iq('#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;in float v_depth_shadows;\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;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);}
8float 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\nshadowed_lighting_factor=shadowed_light_factor_normal(xy_flipped_normal,v_pos_light_view_0,v_pos_light_view_1,v_depth_shadows);\n#else\nshadowed_lighting_factor=dot(normal,u_lighting_directional_dir);\n#endif\ncolor.rgb=apply_lighting_linear(color.rgb,xy_flipped_normal,shadowed_lighting_factor);color.rgb=mix(color.rgb,base_color.rgb,emissive);\n#ifdef FOG\ncolor=fog_dither(fog_apply_premultiplied(color,v_fog_pos,v_pos.z));\n#endif\ncolor.rgb=linearTosRGB(color.rgb);color*=u_opacity;\n#ifdef INDICATOR_CUTOUT\ncolor=applyCutout(color,v_pos.z);\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 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;out float v_depth_shadows;\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;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\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;\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);}\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);v_depth_shadows=gl_Position.w;\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);}'),buildingBloom:iq("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));
8opacity*=saturate(1.0-distance*distance);\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);}"),buildingDepth:iq("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:iq('#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(void) {\n#pragma mapbox: initialize highp vec4 color\n#pragma mapbox: initialize mediump float radius\n#pragma mapbox: initialize lowp float blur\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize highp vec4 stroke_color\n#pragma mapbox: initialize mediump float stroke_width\n#pragma mapbox: initialize lowp float stroke_opacity\nvec2 extrude=vec2(mod(a_pos,2.0)*2.0-1.0);vec2 circle_center=floor(a_pos*0.5);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);
8\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:iq("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:iq('#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(void) {\n#pragma mapbox: initialize highp float weight\n#pragma mapbox: initialize mediump float radius\nvec2 unscaled_extrude=vec2(mod(a_pos,2.0)*2.0-1.0);float S=sqrt(-2.0*log(ZERO/weight/u_intensity/GAUSS_COEF))/3.0;v_extrude=S*unscaled_extrude;vec2 extrude=v_extrude*radius*u_extrude_scale;vec2 tilePos=floor(a_pos*0.5);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:iq("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);
8\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:iq("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:iq("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:iq("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
8);\n#else\ngl_Position=u_matrix*vec4(a_pos*u_overlay_scale,h,1);\n#endif\n}'),elevatedStructuresDepth:iq("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:iq("#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:iq('#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));}
8vec3 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:iq('#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 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:iq('#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 OVERDRAW_INSPECTOR\nglFragColor=vec4(1.0);
8\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:iq('#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 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:iq('#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 OVERDRAW_INSPECTOR\nglFragColor=vec4(1.0);
8\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:iq('#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;
8\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"\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() {\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;
8float 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(ce
8ntroid_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:iq("in highp float v_depth;void main() {\n#ifndef DEPTH_TEXTURE\nglFragColor=pack_depth(v_depth);\n#endif\n}",'#include "_prelude_terrain.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() {\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:iq('#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
8),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"\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() {\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);
8\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:iq('#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:iq("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\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\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;
8\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:iq("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:iq('#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 OVERDRAW_INSPECTOR\nglFragColor=vec4(1.0);
8\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:iq('#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;}uniform float u_emissive_strength;\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 lowp float border_width\n#pragma mapbox: define lowp vec4 border_color\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 lowp float border_width\n#pragma mapbox: initialize lowp vec4 border_color\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);\n#ifdef RENDER_LINE_DASH\nfloat sdfdist=texture(u_dash_image,v_tex).r;
8float 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#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,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 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 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 lowp float border_width\n#pragma mapbox: define lowp vec4 border_color\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 lowp float border_width\n#pragma mapbox: initialize lowp vec4 border_color\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\nfloat left=a_pos_normal.y-2.0*floor(a_pos_normal.y*0.5);halfwidth=(u_width_scale*(left==1.0 ? a_z_offset_width.y : a_z_offset_width.z))/2.0;\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;
8vec4 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:iq('#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\nuniform float u_emissive_strength;\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\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\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,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\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 OVERDRAW_INSPECTOR\nglFragColor=vec4(1.0);
8\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\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\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:iq('#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);
8\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];
8if (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:iq('#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),0.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:iq("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:iq("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:iq('#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;
8vec2 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:iq('#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);
8\n#endif\nHANDLE_WIREFRAME_DEBUG;}','#include "_prelude_terrain.vertex.glsl"\n#include "_prelude_shadow.vertex.glsl"\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);vec2 a_pxoffset=a_pixeloffset.xy;vec2 a_min_font_scale=a_pixeloffset.zw/256.0;highp float segment_angle=-a_projected_pos[3];float size;if (!u_is_size_zoom_constant && !u_is_size_feature_constant) {size=mix(a_size_min,a_size[1],u_size_t)/128.0;} else if (u_is_size_zoom_constant && !u_is_size_feature_constant) {size=a_size_min/128.0;} else {size=u_size;}vec2 tile_anchor=a_pos;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\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:iq('#include "_prelude_fog.fragment.glsl"\n#include "_prelude_shadow.fragment.glsl"\n#include "_prelude_lighting.glsl"\nuniform sampler2D u_image0;in 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\nvec3 unlit_base=image_color.rgb*(1.0-image_color.a);vec3 emissive_base=image_color.rgb*image_color.a;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\ncolor.rgb=mix(color.rgb,image_color.rgb,image_color.a);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);
8\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:iq("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:iq('#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))/(e
8nd-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}',iP),skyboxGradient:iq('#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}',iP),skyboxCapture:iq
vendor: 3,689 bytes, line 8
8("\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;
8v_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:iq('#include "_prelude_fog.fragment.glsl"\n#include "_prelude_lighting.glsl"\nuniform sampler2D u_image0;uniform 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\nraster=apply_lighting_with_emission_ground(raster,raster.a);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\ncolor=apply_lighting_with_emission_ground(color,color.a);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:iq('#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;
8vec3 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:iq('#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 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)-light
8Color),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*light
8Color;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.
8y));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#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);
8\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:iq("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;
8rs[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:iq("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:iq("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:iq("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;
8pos*=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:iq("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:iq("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 iG(e,i){for(let r of e.replace(/\s*\/\/[^\n]*\n/g,"\n").split("\n"))if("#"===(r=r.trim())[0]&&r.includes("if")&&!r.includes("endif"))for(let e of(r=r.replace("#","").replace(/ifdef|ifndef|elif|if/g,"").replace(/!|defined|\(|\)|\|\||&&/g,"").replace(/\s+/g," ").trim()).split(" "))i.includes(e)||i.push(e)}function iq(e,i){let r=/#include\s+"([^"]+)"/g,a=/#pragma mapbox: ([\w\-]+) ([\w]+) ([\w]+) ([\w]+)/g,n={},o=[],s=[];if(e=e.replace(r,(e,i)=>(s.push(i),"")),(i=i.replace(r,(e,i)=>(o.push(i),""))).includes("flat out"))return void console.error('The usage of "flat" qualifier is disallowed, see: https://bugs.webkit.org/show_bug.cgi?id=268071');let l=[...iB];for(let r of(iG(e,l),iG(i,l),[...o,...s]))iN[r]||console.error(`Undefined include: ${r}`),iV[r]||(iV[r]=[],iG(iN[r],iV[r])),l=[...l,...iV[r]];return{fragmentSource:e=e.replace(a,(e,i,r,a,o)=>(n[o]=!0,"define"===i?` 9#ifndef HAS_UNIFORM_u_${o} 10in ${r} ${a} ${o}; 11#else 12uniform ${r} ${a} u_${o}; 13#endif 14`:"initialize"===i?` 15#ifdef HAS_UNIFORM_u_${o} 16 ${r} ${a} ${o} = u_${o}; 17#endif 18`:"define-attribute"===i?` 19#ifdef HAS_ATTRIBUTE_a_${o} 20 in ${r} ${a} ${o}; 21#endif 22`:"initialize-attribute"===i?"":void 0)),vertexSource:i=i.replace(a,(e,i,r,a,o)=>{let s="float"===a?"vec2":a,l=o.match(/color/)?"color":s;return"define-attribute-vertex-shader-only"===i?` 23#ifdef HAS_ATTRIBUTE_a_${o} 24in ${r} ${a} a_${o}; 25#endif 26`:n[o]?"define"===i?` 27#ifndef HAS_UNIFORM_u_${o} 28uniform lowp float u_${o}_t; 29in ${r} ${s} a_${o}; 30out ${r} ${a} ${o}; 31#else 32uniform ${r} ${a} u_${o}; 33#endif 34`:"initialize"===i?"vec4"===l?` 35#ifndef HAS_UNIFORM_u_${o} 36 ${o} = a_${o}; 37#else 38 ${r} ${a} ${o} = u_${o}; 39#endif 40`:` 41#ifndef HAS_UNIFORM_u_${o} 42 ${o} = unpack_mix_${l}(a_${o}, u_${o}_t); 43#else 44 ${r} ${a} ${o} = u_${o}; 45#endif 46`:"define-attribute"===i?` 47#ifdef HAS_ATTRIBUTE_a_${o} 48 in ${r} ${a} a_${o}; 49 out ${r} ${a} ${o}; 50#endif 51`:"initialize-attribute"===i?` 52#ifdef HAS_ATTRIBUTE_a_${o} 53 ${o} = a_${o}; 54#endif 55`:void 0:"define"===i?` 56#ifndef HAS_UNIFORM_u_${o} 57uniform lowp float u_${o}_t; 58in ${r} ${s} a_${o}; 59#else 60uniform ${r} ${a} u_${o}; 61#endif 62`:"define-instanced"===i?"mat4"===l?` 63#ifdef INSTANCED_ARRAYS 64in vec4 a_${o}0; 65in vec4 a_${o}1; 66in vec4 a_${o}2; 67in vec4 a_${o}3; 68#else 69uniform ${r} ${a} u_${o}; 70#endif 71`:` 72#ifdef INSTANCED_ARRAYS 73in ${r} ${s} a_${o}; 74#else 75uniform ${r} ${a} u_${o}; 76#endif 77`:"initialize-attribute-custom"===i?` 78#ifdef HAS_ATTRIBUTE_a_${o} 79 ${r} ${a} ${o} = a_${o}; 80#endif 81`:"vec4"===l?` 82#ifndef HAS_UNIFORM_u_${o} 83 ${r} ${a} ${o} = a_${o}; 84#else 85 ${r} ${a} ${o} = u_${o}; 86#endif 87`:` 88#ifndef HAS_UNIFORM_u_${o} 89 ${r} ${a} ${o} = unpack_mix_${l}(a_${o}, u_${o}_t); 90#else 91 ${r} ${a} ${o} = u_${o}; 92#endif 93`}),usedDefines:l,vertexIncludes:o,fragmentIncludes:s}}class i${constructor(){this.boundProgram=null,this.boundLayoutVertexBuffer=null,this.boundPaintVertexBuffers=[],this.boundIndexBuffer=null,this.boundVertexOffset=null,this.boundDynamicVertexBuffers=[],this.vao=null}bind(e,i,r,a,n,o,s,l){this.context=e;let h=this.boundPaintVertexBuffers.length!==a.length;for(let e=0;!h&&e<a.length;e++)this.boundPaintVertexBuffers[e]!==a[e]&&(h=!0);let u=this.boundDynamicVertexBuffers.length!==s.length;for(let e=0;!u&&e<s.length;e++)this.boundDynamicVertexBuffers[e]!==s[e]&&(u=!0);if(!this.vao||this.boundProgram!==i||this.boundLayoutVertexBuffer!==r||h||u||this.boundIndexBuffer!==n||this.boundVertexOffset!==o)this.freshBind(i,r,a,n,o,s,l);else{for(let r of(e.bindVertexArrayOES.set(this.vao),s))r&&(r.bind(),l&&r.instanceCount&&r.setVertexAttribDivisor(e.gl,i,l));n&&n.dynamicDraw&&n.bind()}}freshBind(e,i,r,a,n,o,s){let l=this.context,h=l.gl;for(let s of(this.vao&&this.destroy(),this.vao=l.gl.createVertexArray(),l.bindVertexArrayOES.set(this.vao),this.boundProgram=e,this.boundLayoutVertexBuffer=i,this.boundPaintVertexBuffers=r,this.boundIndexBuffer=a,this.boundVertexOffset=n,this.boundDynamicVertexBuffers=o,i.enableAttributes(h,e),i.bind(),i.setVertexAttribPointers(h,e,n),r))s.enableAttributes(h,e),s.bind(),s.setVertexAttribPointers(h,e,n);for(let i of o)i&&(i.enableAttributes(h,e),i.bind(),i.setVertexAttribPointers(h,e,n),s&&i.instanceCount&&i.setVertexAttribDivisor(h,e,s));a&&a.bind()}destroy(){this.vao&&(this.context.gl.deleteVertexArray(this.vao),this.vao=null)}}function iH(i,r,a){if(!r.needsDEMTextureUpload)return;let n=i.context,o=n.gl;n.pixelStoreUnpackPremultiplyAlpha.set(!1),r.demTexture=r.demTexture||i.getTileTexture(a.stride);let s=a.getPixels();r.demTexture?r.demTexture.update(s,{premultiply:!1}):r.demTexture=new e.T(n,s,o.R32F,{premultiply:!1}),r.needsDEMTextureUpload=!1}class iZ{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 iW extends iZ{getDefault(){return e.ao.transparent.toNonPremultipliedRenderColor(null)}set(e){let i=this.current;(e.r!==i.r||e.g!==i.g||e.b!==i.b||e.a!==i.a||this.dirty)&&(this.gl.clearColor(e.r,e.g,e.b,e.a),this.current=e,this.dirty=!1)}}class iX extends iZ{getDefault(){return 1}set(e){(e!==this.current||this.dirty)&&(this.gl.clearDepth(e),this.current=e,this.dirty=!1)}}class iY extends iZ{getDefault(){return 0}set(e){(e!==this.current||this.dirty)&&(this.gl.clearStencil(e),this.current=e,this.dirty=!1)}}
93class iK extends iZ{getDefault(){return[!0,!0,!0,!0]}set(e){let i=this.current;(e[0]!==i[0]||e[1]!==i[1]||e[2]!==i[2]||e[3]!==i[3]||this.dirty)&&(this.gl.colorMask(e[0],e[1],e[2],e[3]),this.current=e,this.dirty=!1)}}class iJ extends iZ{getDefault(){return!0}set(e){(e!==this.current||this.dirty)&&(this.gl.depthMask(e),this.current=e,this.dirty=!1)}}class iQ extends iZ{getDefault(){return 255}set(e){(e!==this.current||this.dirty)&&(this.gl.stencilMask(e),this.current=e,this.dirty=!1)}}class i0 extends iZ{getDefault(){return{func:this.gl.ALWAYS,ref:0,mask:255}}set(e){let i=this.current;(e.func!==i.func||e.ref!==i.ref||e.mask!==i.mask||this.dirty)&&(this.gl.stencilFunc(e.func,e.ref,e.mask),this.current=e,this.dirty=!1)}}class i1 extends iZ{getDefault(){let e=this.gl;return[e.KEEP,e.KEEP,e.KEEP]}set(e){let i=this.current;(e[0]!==i[0]||e[1]!==i[1]||e[2]!==i[2]||this.dirty)&&(this.gl.stencilOp(e[0],e[1],e[2]),this.current=e,this.dirty=!1)}}class i2 extends iZ{getDefault(){return!1}set(e){if(e===this.current&&!this.dirty)return;let i=this.gl;e?i.enable(i.STENCIL_TEST):i.disable(i.STENCIL_TEST),this.current=e,this.dirty=!1}}class i3 extends iZ{getDefault(){return[0,1]}set(e){let i=this.current;(e[0]!==i[0]||e[1]!==i[1]||this.dirty)&&(this.gl.depthRange(e[0],e[1]),this.current=e,this.dirty=!1)}}class i5 extends iZ{getDefault(){return!1}set(e){if(e===this.current&&!this.dirty)return;let i=this.gl;e?i.enable(i.DEPTH_TEST):i.disable(i.DEPTH_TEST),this.current=e,this.dirty=!1}}class i4 extends iZ{getDefault(){return this.gl.LESS}set(e){(e!==this.current||this.dirty)&&(this.gl.depthFunc(e),this.current=e,this.dirty=!1)}}class i6 extends iZ{getDefault(){return!1}set(e){if(e===this.current&&!this.dirty)return;let i=this.gl;e?i.enable(i.BLEND):i.disable(i.BLEND),this.current=e,this.dirty=!1}}class i8 extends iZ{getDefault(){let e=this.gl;return[e.ONE,e.ZERO,e.ONE,e.ZERO]}set(e){let i=this.current;(e[0]!==i[0]||e[1]!==i[1]||e[2]!==i[2]||e[3]!==i[3]||this.dirty)&&(this.gl.blendFuncSeparate(e[0],e[1],e[2],e[3]),this.current=e,this.dirty=!1)}}class i9 extends iZ{getDefault(){return e.ao.transparent.toNonPremultipliedRenderColor(null)}set(e){let i=this.current;(e.r!==i.r||e.g!==i.g||e.b!==i.b||e.a!==i.a||this.dirty)&&(this.gl.blendColor(e.r,e.g,e.b,e.a),this.current=e,this.dirty=!1)}}class i7 extends iZ{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 re extends iZ{getDefault(){return!1}set(e){if(e===this.current&&!this.dirty)return;let i=this.gl;e?i.enable(i.CULL_FACE):i.disable(i.CULL_FACE),this.current=e,this.dirty=!1}}class rt extends iZ{getDefault(){return this.gl.BACK}set(e){(e!==this.current||this.dirty)&&(this.gl.cullFace(e),this.current=e,this.dirty=!1)}}class ri extends iZ{getDefault(){return this.gl.CCW}set(e){(e!==this.current||this.dirty)&&(this.gl.frontFace(e),this.current=e,this.dirty=!1)}}let rr=class extends iZ{getDefault(){return null}set(e){(e!==this.current||this.dirty)&&(this.gl.useProgram(e),this.current=e,this.dirty=!1)}};class ra extends iZ{getDefault(){return this.gl.TEXTURE0}set(e){(e!==this.current||this.dirty)&&(this.gl.activeTexture(e),this.current=e,this.dirty=!1)}}class rn extends iZ{getDefault(){let e=this.gl;return[0,0,e.drawingBufferWidth,e.drawingBufferHeight]}set(e){let i=this.current;(e[0]!==i[0]||e[1]!==i[1]||e[2]!==i[2]||e[3]!==i[3]||this.dirty)&&(this.gl.viewport(e[0],e[1],e[2],e[3]),this.current=e,this.dirty=!1)}}class ro extends iZ{getDefault(){return null}set(e){if(e===this.current&&!this.dirty)return;let i=this.gl;i.bindFramebuffer(i.FRAMEBUFFER,e),this.current=e,this.dirty=!1}}class rs extends iZ{getDefault(){return null}set(e){if(e===this.current&&!this.dirty)return;let i=this.gl;i.bindRenderbuffer(i.RENDERBUFFER,e),this.current=e,this.dirty=!1}}class rl extends iZ{getDefault(){return null}set(e){if(e===this.current&&!this.dirty)return;let i=this.gl;i.bindTexture(i.TEXTURE_2D,e),this.current=e,this.dirty=!1}}class rh extends iZ{getDefault(){return null}set(e){if(e===this.current&&!this.dirty)return;let i=this.gl;i.bindBuffer(i.ARRAY_BUFFER,e),this.current=e,this.dirty=!1}}class ru extends iZ{getDefault(){return null}set(e){let i=this.gl;i.bindBuffer(i.ELEMENT_ARRAY_BUFFER,e),this.current=e,this.dirty=!1}}class rc extends iZ{getDefault(){return null}set(e){this.gl&&(e!==this.current||this.dirty)&&(this.gl.bindVertexArray(e),this.current=e,this.dirty=!1)}}class rd extends iZ{getDefault(){return 4}set(e){if(e===this.current&&!this.dirty)return;let i=this.gl;i.pixelStorei(i.UNPACK_ALIGNMENT,e),this.current=e,this.dirty=!1}}class rp extends iZ{getDefault(){return!1}set(e){if(e===this.current&&!this.dirty)return;let i=this.gl;i.pixelStorei(i.UNPACK_PREMULTIPLY_ALPHA_WEBGL,e),this.current=e,this.dirty=!1}}class rf extends iZ{getDefault(){return!1}set(e){if(e===this.current&&!this.dirty)return;let i=this.gl;i.pixelStorei(i.UNPACK_FLIP_Y_WEBGL,e),this.current=e,this.dirty=!1}}class rm extends iZ{constructor(e,i){super(e),this.context=e,this.parent=i}getDefault(){return null}}class r_ extends rm{setDirty(){this.dirty=!0}set(e){if(e===this.current&&!this.dirty)return;this.context.bindFramebuffer.set(this.parent);let i=this.gl;i.framebufferTexture2D(i.FRAMEBUFFER,i.COLOR_ATTACHMENT0,i.TEXTURE_2D,e,0),this.current=e,this.dirty=!1}}class rg extends rm{attachment(){return this.gl.DEPTH_ATTACHMENT}set(e){if(e===this.current&&!this.dirty)return;this.context.bindFramebuffer.set(this.parent);let i=this.gl;i.framebufferRenderbuffer(i.FRAMEBUFFER,this.attachment(),i.RENDERBUFFER,e),this.current=e,this.dirty=!1}}class ry extends rm{attachment(){return this.gl.DEPTH_ATTACHMENT}set(e){if(e===this.current&&!this.dirty)return;this.context.bindFramebuffer.set(this.parent);let i=this.gl;i.framebufferTexture2D(i.FRAMEBUFFER,this.attachment(),i.TEXTURE_2D,e,0),this.current=e,this.dirty=!1}}class rx extends rg{attachment(){return this.gl.DEPTH_STENCIL_ATTACHMENT}}let rv=(e,i,r)=>({u_matrix:e,u_image0:0,u_skirt_height:i,u_ground_shadow_factor:r}),rb=(e,i,r,a,n,o,s,l,h,u,c,d,p,f,m,_)=>({u_proj_matrix:Float32Array.from(e),u_globe_matrix:i,u_normalize_matrix:Float32Array.from(a),u_merc_matrix:r,u_zoom_transition:n,u_merc_center:o,u_image0:0,u_frustum_tl:s,u_frustum_tr:l,u_frustum_br:h,u_frustum_bl:u,u_globe_pos:c,u_globe_radius:d,u_viewport:p,u_grid_matrix:_?Float32Array.from(_):new Float32Array(9),u_skirt_height:f,u_far_z_cutoff:m});function rw(e,i){return null!=e&&null!=i&&!(!e.hasData()||!i.hasData())&&null!=e.demTexture&&null!=i.demTexture&&e.tileID.key!==i.tileID.key}let rT=new class{constructor(){this.operations={}}newMorphing(e,i,r,a,n){if(e in this.operations){let i=this.operations[e];i.to.tileID.key!==r.tileID.key&&(i.queued=r)}else this.operations[e]={startTime:a,phase:0,duration:n,from:i,to:r,queued:null}}getMorphValuesForProxy(e){if(!(e in this.operations))return null;let i=this.operations[e];return{from:i.from,to:i.to,phase:i.phase}}update(e){for(let i in this.operations){let r=this.operations[i];for(r.phase=(e-r.startTime)/r.duration;r.phase>
93=1||!this._validOp(r);)if(!this._nextOp(r,e)){delete this.operations[i];break}}}_nextOp(e,i){return!!e.queued&&(e.from=e.to,e.to=e.queued,e.queued=null,e.phase=0,e.startTime=i,!0)}_validOp(e){return e.from.hasData()&&e.to.hasData()}},rS={0:null,1:"TERRAIN_VERTEX_MORPHING"};function rE(e,i,r){return 0===i?0:6*Math.pow(1.5,22-e)*Math.max(i,1)*(i<1&&514===r?.25/i:1)}let rI=e=>({u_matrix:e});function rA(i,r,a,n,o){if(o>0){let s=e.o.now(),l=(s-i.timeAdded)/o,h=r?(s-r.timeAdded)/o:-1,u=a.getSource(),c=n.coveringZoomLevel({tileSize:u.tileSize,roundZoom:u.roundZoom}),d=!r||Math.abs(r.tileID.overscaledZ-c)>Math.abs(i.tileID.overscaledZ-c),p=d&&i.refreshedUponExpiration?1:e.aA(d?l:1-h,0,1);return r?{opacity:1,mix:1-p,isFading:l<1}:{opacity:p,mix:0,isFading:l<1}}return{opacity:1,mix:0,isFading:!1}}class rC extends ta{constructor(e){let i=eQ("mock-dem",{type:"raster-dem",maxzoom:e.transform.maxZoom},e.style.dispatcher,e.style);super("mock-dem",i,!1),i.setEventedParent(this),this._sourceLoaded=!0}_loadTile(e,i){e.state="loaded",i(null)}}class rM extends ta{constructor(e){let i=eQ("proxy",{type:"geojson",maxzoom:e.transform.maxZoom},e.style.dispatcher,e.style);super("proxy",i,!1),i.setEventedParent(this),this.map=this.getSource().map=e,this.used=this._sourceLoaded=!0,this.renderCache=[],this.renderCachePool=[],this.proxyCachedFBO={}}update(e,i,r){if(e.freezeTileCoverage)return;this.transform=e;let a=e.coveringTiles({tileSize:this._source.tileSize,minzoom:this._source.minzoom,maxzoom:this._source.maxzoom,roundZoom:this._source.roundZoom,reparseOverscaled:this._source.reparseOverscaled}).reduce((i,r)=>{if(i[r.key]="",!this._tiles[r.key]){let i=new te(r,this._source.tileSize*r.overscaleFactor(),e.tileZoom,void 0,void 0,this._source.worldview);i.state="loaded",this._tiles[r.key]=i}return i},{});for(let e in this._tiles)e in a||(this.freeFBO(e),this._tiles[e].unloadVectorData(),delete this._tiles[e])}freeFBO(e){let i=this.proxyCachedFBO[e];if(void 0!==i){let r=Object.values(i);this.renderCachePool.push(...r),delete this.proxyCachedFBO[e]}}deallocRenderCache(){this.renderCache.forEach(e=>e.fb.destroy()),this.renderCache=[],this.renderCachePool=[],this.proxyCachedFBO={}}}class rP extends e.aO{constructor(e,i,r){super(e.overscaledZ,e.wrap,e.canonical.z,e.canonical.x,e.canonical.y),this.proxyTileKey=i,this.projMatrix=r}}class rz extends e.dH{constructor(i,r){super(),this._debugParams={sortTilesHiZFirst:!0,disableRenderCache:!1},i.tp.registerParameter(this._debugParams,["Terrain"],"sortTilesHiZFirst",{},()=>{this._style.map.triggerRepaint()}),i.tp.registerParameter(this._debugParams,["Terrain"],"disableRenderCache",{},()=>{this._style.map.triggerRepaint()}),i.tp.registerButton(["Terrain"],"Invalidate Render Cache",()=>{this.invalidateRenderCache=!0,this._style.map.triggerRepaint()}),this.painter=i,this.terrainTileForTile={},this.prevTerrainTileForTile={};let[a,n,o]=function(i){let r=new e.bd,a=new e.b1;r.reserve(17161),a.reserve(33800);let n=e.al/128,o=e.al+n/2,s=o+n;for(let i=-n;i<s;i+=n)for(let a=-n;a<s;a+=n){let n=24575*(a<0||a>o||i<0||i>o),s=e.aA(Math.round(a),0,e.al),l=e.aA(Math.round(i),0,e.al);r.emplaceBack(s+n,l)}let l=(e,i)=>{let r=131*i+e;a.emplaceBack(r+1,r,r+131),a.emplaceBack(r+131,r+131+1,r+1)};for(let e=1;e<129;e++)for(let i=1;i<129;i++)l(i,e);return[0,129].forEach(e=>{for(let i=0;i<130;i++)l(i,e),l(e,i)}),[r,a,32768]}(),s=i.context;this.gridBuffer=s.createVertexBuffer(a,e.bf.members),this.gridIndexBuffer=s.createIndexBuffer(n),this.gridSegments=e.bg.simpleSegment(0,0,a.length,n.length),this.gridNoSkirtSegments=e.bg.simpleSegment(0,0,a.length,o),this.proxyCoords=[],this.proxiedCoords={},this._visibleDemTiles=[],this._drapedRenderBatches=[],this._sourceTilesOverlap={},this.proxySourceCache=new rM(r.map),this.orthoMatrix=e.bC(),e.cd(this.orthoMatrix,.015*("globe"===this.painter.transform.projection.name),e.al,0,e.al,0,1);let l=s.gl;this._overlapStencilMode=new t3({func:l.GEQUAL,mask:255},0,255,l.KEEP,l.KEEP,l.REPLACE),this._previousZoom=i.transform.zoom,this.pool=[],this._findCoveringTileCache={},this._tilesDirty={},this.style=r,this._useVertexMorphing=!0,this._exaggeration=1,this._mockSourceCache=new rC(r.map),this._pendingGroundEffectLayers=[]}set style(e){e.on("data",this._onStyleDataEvent.bind(this)),this._style=e,this._style.map.on("moveend",()=>{this._clearLineLayersFromRenderCache()})}update(i,r,a){if(i&&i.terrain){this._style!==i&&(this.style=i,this._evaluationZoom=void 0);let n=i.terrain.properties,o=0===i.terrain.drapeRenderMode,s=i.terrain.isZoomDependent();this._previousUpdateTimestamp=this.enabled?this._updateTimestamp:void 0,this._updateTimestamp=e.o.now();let l=i.terrain&&i.terrain.scope,h=n.get("source"),u=o?this._mockSourceCache:i.getSourceCache(h,l);if(!u)return void e.w(`Couldn't find terrain source "${h}".`);if(this.sourceCache=u,this._attenuationRange=i.terrain.getAttenuationRange(),this._exaggeration=s?this.calculateExaggeration(r):n.get("exaggeration"),!r.projection.requiresDraping&&s&&0===this._exaggeration)return void this._disable();this.enabled=!0;let c=()=>{this.sourceCache.used&&e.w(`Raster DEM source '${this.sourceCache.id}' is used both for terrain and as layer source. 94This leads to lower resolution of hillshade. For full hillshade resolution but higher memory consumption, define another raster DEM source.`);let i=this.getScaledDemTileSize();this.sourceCache.update(r,i,!0),this.resetTileLookupCache(this.sourceCache.id)};this.sourceCache.usedForTerrain||(this.resetTileLookupCache(this.sourceCache.id),this.sourceCache.usedForTerrain=!0,c(),this._initializing=!0),c(),r.updateElevation(!0,a),this.resetTileLookupCache(this.proxySourceCache.id),this.proxySourceCache.update(r),this._emptyDEMTextureDirty=!0,this._previousZoom=r.zoom}else this._disable()}calculateExaggeration(i){if(this._attenuationRange&&i.zoom>=Math.ceil(this._attenuationRange[1]))return this._style.terrain.getExaggeration(i.zoom);let r=this._previousCameraAltitude,a=i.getFreeCameraOptions().position.z/i.pixelsPerMeter*i.worldSize;this._previousCameraAltitude=a;let n=null!=r?a-r:Number.MAX_VALUE;if(2>Math.abs(n))return this._exaggeration;let o=i.zoom,s=this._style.terrain;if(!this._previousUpdateTimestamp)return s.getExaggeration(o);let l=o-this._previousZoom,h=this._previousUpdateTimestamp,u=o;null!=this._evaluationZoom&&(Math.abs(o-(u=this._evaluationZoom))>.5&&(l=.5*(o-u+l)),l*n<0&&(u+=l)),this._evaluationZoom=u;let c=s.getExaggeration(u),d=c===s.getExaggeration(Math.max(0,u-.1));if(d&&.01>Math.abs(c-this._exaggeration))return c;
94let p=Math.min(.1,.00375*(this._updateTimestamp-h));return(d||c<.1||1e-4>Math.abs(l))&&(p=Math.min(.2,4*p)),e.ak(this._exaggeration,c,p)}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(let 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(){let e=2*this.proxySourceCache.getSource().tileSize;return[e,e]}set useVertexMorphing(e){this._useVertexMorphing=e}updateTileBinding(i){if(!this.enabled)return;this.prevTerrainTileForTile=this.terrainTileForTile;let r=this.proxySourceCache,a=this.painter.transform;this._initializing&&(this._initializing=0===a._centerAltitude&&-1===this.getAtPointOrZero(e.ae.fromLngLat(a.center),-1),this._emptyDEMTextureDirty=!this._initializing);let n=this.proxyCoords=r.getIds().map(e=>{let i=r.getTileByID(e).tileID;return i.projMatrix=a.calculateProjMatrix(i.toUnwrapped()),i});var o=this.painter;let s=o.transform.pointCoordinate(o.transform.getCameraPoint()),l=new e.P(s.x,s.y);n.sort((i,r)=>{if(r.overscaledZ-i.overscaledZ)return r.overscaledZ-i.overscaledZ;let a=new e.P(i.canonical.x+(1<<i.canonical.z)*i.wrap,i.canonical.y),n=new e.P(r.canonical.x+(1<<r.canonical.z)*r.wrap,r.canonical.y),o=l.mult(1<<i.canonical.z);return o.x-=.5,o.y-=.5,o.distSqr(a)-o.distSqr(n)});let h=this.proxyToSource||{};this.proxyToSource={},n.forEach(e=>{this.proxyToSource[e.key]={}}),this.terrainTileForTile={};let u=this._style._mergedSourceCaches;for(let e in u){let r=u[e];if(!r.used||(r!==this.sourceCache&&this.resetTileLookupCache(r.id),this._setupProxiedCoordsForOrtho(r,i[e],h),r.usedForTerrain))continue;let a=i[e];r.getSource().reparseOverscaled&&this._assignTerrainTiles(a)}this.proxiedCoords[r.id]=n.map(e=>new rP(e,e.key,this.orthoMatrix)),this._assignTerrainTiles(n),this._prepareDEMTextures(),this._setupDrapedRenderBatches(),this._initFBOPool(),this._setupRenderCache(h),this.renderingToTexture=!1;let c={};for(let e of(this._visibleDemTiles=[],this.proxyCoords)){let i=this.terrainTileForTile[e.key];if(!i)continue;let r=i.tileID.key;r in c||(this._visibleDemTiles.push(i),c[r]=r)}}_assignTerrainTiles(e){this._initializing||e.forEach(e=>{if(this.terrainTileForTile[e.key])return;let i=this._findTileCoveringTileID(e,this.sourceCache);i&&(this.terrainTileForTile[e.key]=i)})}_prepareDEMTextures(){let e=this.painter.context,i=e.gl;for(let r in this.terrainTileForTile){let a=this.terrainTileForTile[r],n=a.dem;n&&(!a.demTexture||a.needsDEMTextureUpload)&&(e.activeTexture.set(i.TEXTURE1),iH(this.painter,a,n))}}_prepareDemTileUniforms(e,i,r,a){if(!i||null==i.demTexture)return!1;let n=e.tileID.canonical,o=Math.pow(2,i.tileID.canonical.z-n.z),s=a||"";return r[`u_dem_tl${s}`]=[n.x*o%1,n.y*o%1],r[`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,i=this._visibleDemTiles.reduce((i,r)=>{if(!r.dem)return i;let a=r.dem.tree.minimums[0];return a>0&&e++,i+a},0);return e?i/e:0}_updateEmptyDEMTexture(){let i=this.painter.context,r=i.gl;i.activeTexture.set(r.TEXTURE2);let a=this._getLoadedAreaMinimum(),n=new e.dI({width:1,height:1},new Float32Array([a]));this._emptyDEMTextureDirty=!1;let o=this._emptyDEMTexture;return o?o.update(n,{premultiply:!1}):o=this._emptyDEMTexture=new e.T(i,n,r.R32F,{premultiply:!1}),o}setupElevationDraw(i,r,a){var n;let o=this.painter.context,s=o.gl,l={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};l.u_exaggeration=this.exaggeration();let h=null,u=null,c=1;if(a&&a.morphing&&this._useVertexMorphing){let e=a.morphing.srcDemTile,r=a.morphing.dstDemTile;
94c=a.morphing.phase,e&&r&&(this._prepareDemTileUniforms(i,e,l,"_prev")&&(u=e),this._prepareDemTileUniforms(i,r,l)&&(h=r))}let d=e=>e&&e.demTexture&&this.painter.linearFloatFilteringSupported()?s.LINEAR:s.NEAREST,p=null;if(this.enabled?u&&h?(p=h.demTexture,o.activeTexture.set(s.TEXTURE4),u.demTexture.bind(d(u),s.CLAMP_TO_EDGE),l.u_dem_lerp=c):(h=this.terrainTileForTile[i.tileID.key],p=this._prepareDemTileUniforms(i,h,l)?h.demTexture:this.emptyDEMTexture):p=this.emptyDEMTexture,o.activeTexture.set(s.TEXTURE2),p&&(l.u_dem_size=1===(n=p).size[0]?1:n.size[0]-2,p.bind(d(h),s.CLAMP_TO_EDGE)),this.painter.setupDepthForOcclusion(a&&a.useDepthForOcclusion,r,l),a&&a.useMeterToDem&&h&&(l.u_meter_to_dem=(1<<h.tileID.canonical.z)*e.ce(1,this.painter.transform.center.lat)*this.sourceCache.getSource().tileSize),a&&a.labelPlaneMatrixInv&&(l.u_label_plane_matrix_inv=a.labelPlaneMatrixInv),r.setTerrainUniformValues(o,l),"globe"===this.painter.transform.projection.name){let e=this.globeUniformValues(this.painter.transform,i.tileID.canonical,a&&a.useDenormalizedUpVectorScale);r.setGlobeUniformValues(o,e)}}globeUniformValues(i,r,a){let n=i.projection;return{u_tile_tl_up:n.upVector(r,0,0),u_tile_tr_up:n.upVector(r,e.al,0),u_tile_br_up:n.upVector(r,e.al,e.al),u_tile_bl_up:n.upVector(r,0,e.al),u_tile_up_scale:a?e.dJ(1):n.upVectorScale(r,i.center.lat,i.worldSize).metersToTile}}renderToBackBuffer(i){let r=this.painter,a=this.painter.context;0!==i.length&&(a.bindFramebuffer.set(null),a.viewport.set([0,0,r.width,r.height]),r.gpuTimingDeferredRenderStart(),this.renderingToTexture=!1,function(i,r,a,n,o){if("globe"===i.transform.projection.name)!function(i,r,a,n,o){let s,l,h=i.context,u=h.gl,c=i.transform,d=e.dA(i,h,c),p=(e,r)=>{if(l===r)return;let a=[rS[r],"PROJECTION_GLOBE_VIEW"];d&&a.push("CUSTOM_ANTIALIASING");let n=i.isTileAffectedByFog(e);s=i.getOrCreateProgram("globeRaster",{defines:a,overrideFog:n}),l=r},f=i.colorModeForRenderPass(),m=new t2(u.LEQUAL,t2.ReadWrite,i.depthRangeFor3D);rT.update(o);let _=e.dB(c),g=[e.aF(c.center.lng),e.aJ(c.center.lat)],y=i.globeSharedBuffers,x=[c.width*e.o.devicePixelRatio,c.height*e.o.devicePixelRatio],v=Float32Array.from(c.globeMatrix),b={useDenormalizedUpVectorScale:!0};{let c=i.transform,d=rE(c.zoom,r.exaggeration(),r.sourceCache._source.tileSize);l=-1;let w=u.TRIANGLES;for(let l of n){let n=a.getTile(l),T=t3.disabled,S=r.prevTerrainTileForTile[l.key],E=r.terrainTileForTile[l.key];rw(S,E)&&rT.newMorphing(l.key,S,E,o,250),h.activeTexture.set(u.TEXTURE0),n.texture&&n.texture.bind(u.LINEAR,u.CLAMP_TO_EDGE);let I=rT.getMorphValuesForProxy(l.key),A=+!!I;I&&Object.assign(b,{morphing:{srcDemTile:I.from,dstDemTile:I.to,phase:e.dz(I.phase)}});let C=e.dC(l.canonical),M=e.dD(C.getCenter().lat),P=e.dE(l.canonical,C,M,c.worldSize/c._pixelsPerMercatorPixel),z=e.bk(e.dF(l.canonical)),R=rb(c.expandedFarZProjMatrix,v,_,z,e.aj(c.zoom),g,c.frustumCorners.TL,c.frustumCorners.TR,c.frustumCorners.BR,c.frustumCorners.BL,c.globeCenterInViewSpace,c.globeRadius,x,d,c._farZ,P);if(p(l,A),s&&(r.setupElevationDraw(n,s,b),i.uploadCommonUniforms(h,s,l.toUnwrapped()),y)){let[e,r,a]=y.getGridBuffers(M,0!==d);s.draw(i,w,m,T,f,t5.backCCW,R,"globe_raster",e,r,a)}}}if(y&&(i.renderDefaultNorthPole||i.renderDefaultSouthPole)){let o=["GLOBE_POLES","PROJECTION_GLOBE_VIEW"];for(let l of(d&&o.push("CUSTOM_ANTIALIASING"),s=i.getOrCreateProgram("globeRaster",{defines:o}),n)){let{x:n,y:o,z:d}=l.canonical,p=0===o,_=o===(1<<d)-1,[v,w,T,S]=y.getPoleBuffers(d,!1);if(S&&(p||_)){let o=a.getTile(l);h.activeTexture.set(u.TEXTURE0),o.texture&&o.texture.bind(u.LINEAR,u.CLAMP_TO_EDGE);let y=e.dG(d,n,c),E=e.bk(e.dF(l.canonical)),I=(e,r)=>e.draw(i,u.TRIANGLES,m,t3.disabled,f,t5.disabled,rb(c.expandedFarZProjMatrix,y,y,E,0,g,c.frustumCorners.TL,c.frustumCorners.TR,c.frustumCorners.BR,c.frustumCorners.BL,c.globeCenterInViewSpace,c.globeRadius,x,0,c._farZ),"globe_pole_raster",r,T,S);r.setupElevationDraw(o,s,b),i.uploadCommonUniforms(h,s,l.toUnwrapped()),p&&i.renderDefaultNorthPole&&I(s,v),_&&i.renderDefaultSouthPole&&(y=e.cR(e.bC(),y,[1,-1,1]),I(s,w))}}}}(i,r,a,n,o);else{let s,l,h=i.context,u=h.gl,c=i.shadowRenderer,d=ii(i,i.longestCutoffRange),p=e=>{if(l===e)return;let r=[];r.push(rS[e]),d.shouldRenderCutoff&&r.push("RENDER_CUTOFF"),c&&(r.push("RENDER_SHADOWS","DEPTH_TEXTURE"),c.useNormalOffset&&r.push("NORMAL_OFFSET")),s=i.getOrCreateProgram("terrainRaster",{defines:r}),l=e},f=i.colorModeForRenderPass(),m=new t2(u.LEQUAL,t2.ReadWrite,i.depthRangeFor3D);rT.update(o);let _=i.transform,g=rE(_.zoom,r.exaggeration(),r.sourceCache._source.tileSize),y=[0,0,0];if(c){let e=i.style.directionalLight,r=i.style.ambientLight;e&&r&&(y=iu(i.style,e,r))}{l=-1;let x=u.TRIANGLES,[v,b]=[r.gridIndexBuffer,r.gridSegments];for(let l of n){let n,w=a.getTile(l),T=t3.disabled,S=r.prevTerrainTileForTile[l.key],E=r.terrainTileForTile[l.key];rw(S,E)&&rT.newMorphing(l.key,S,E,o,250),h.activeTexture.set(u.TEXTURE0),w.texture&&w.texture.bind(u.LINEAR,u.CLAMP_TO_EDGE);let I=rT.getMorphValuesForProxy(l.key),A=+!!I;I&&(n={morphing:{srcDemTile:I.from,dstDemTile:I.to,phase:e.dz(I.phase)}});let C=rv(l.projMatrix,!function(e,i){let r=1<<e.z;return!i&&(0===e.x||e.x===r-1)||0===e.y||e.y===r-1}(l.canonical,_.renderWorldCopies)?g:g/10,y);if(p(A),!s)continue;r.setupElevationDraw(w,s,n);let M=l.toUnwrapped();c&&c.setupShadows(M,s),i.uploadCommonUniforms(h,s,M,null,d),s.draw(i,x,m,T,f,t5.backCCW,C,"terrain_raster",r.gridBuffer,v,b)}}}}(r,this,this.proxySourceCache,i,this._updateTimestamp),this.renderingToTexture=!0,r.gpuTimingDeferredRenderEnd(),i.splice(0,i.length))}renderBatch(i){if(0===this._drapedRenderBatches.length)return i+1;this.renderingToTexture=!0;let r=this.painter,a=this.painter.context,n=this.proxySourceCache,o=this.proxiedCoords[n.id],s=this._drapedRenderBatches.shift(),l=r.style.order,h=[],u=0;for(let c of o){let o,d=n.getTileByID(c.proxyTileKey),p=n.proxyCachedFBO[c.key]?n.proxyCachedFBO[c.key][i]:void 0,f=void 0!==p?n.renderCache[p]:this.pool[u++],m=void 0!==p;if(d.texture=f.tex,m&&!f.dirty){h.push(d.tileID);continue}a.bindFramebuffer.set(f.fb.framebuffer),this.renderedToTile=!1,f.dirty&&(a.clear({color:e.ao.transparent,stencil:0}),f.dirty=!1);for(let e=s.start;e<=s.end;++e){let i=r.style._mergedLayers[l[e]];if(i.isHidden(r.transform.zoom))continue;let n=r.style.getLayerSourceCache(i),s=n?this.proxyToSource[c.key][n.id]:[c];s&&(a.viewport.set([0,0,f.fb.width,f.fb.height]),o!==(n?n.id:null)&&(this._setupStencil(f,s,i,n),o=n?n.id:null),r.renderLayer(r,n,i,s)
94)}if(0===this._drapedRenderBatches.length)for(let e of this._pendingGroundEffectLayers){let i=r.style._mergedLayers[l[e]];if(i.isHidden(r.transform.zoom))continue;let n=r.style.getLayerSourceCache(i),s=n?this.proxyToSource[c.key][n.id]:[c];s&&(a.viewport.set([0,0,f.fb.width,f.fb.height]),o!==(n?n.id:null)&&(this._setupStencil(f,s,i,n),o=n?n.id:null),r.renderLayer(r,n,i,s))}this.renderedToTile?(f.dirty=!0,h.push(d.tileID)):m||--u,5===u&&(u=0,this.renderToBackBuffer(h))}return this.renderToBackBuffer(h),this.renderingToTexture=!1,a.bindFramebuffer.set(null),a.viewport.set([0,0,r.width,r.height]),s.end+1}postRender(){}isLayerOrderingCorrect(e){let i=e.order.length,r=-1,a=i;for(let n=0;n<i;++n)this._style.isLayerDraped(e._mergedLayers[e.order[n]])?r=Math.max(r,n):a=Math.min(a,n);return a>r}getMinElevationBelowMSL(){let e=0;return this._visibleDemTiles.filter(e=>e.dem).forEach(i=>{e=Math.min(e,i.dem.tree.minimums[0])}),0===e?e:(e-30)*this._exaggeration}raycast(e,i,r){if(!this._visibleDemTiles)return null;let a=this._visibleDemTiles.filter(e=>e.dem).map(a=>{let n=a.tileID,o=1<<n.overscaledZ,{x:s,y:l}=n.canonical,h=s/o,u=(s+1)/o,c=l/o,d=(l+1)/o;return{minx:h,miny:c,maxx:u,maxy:d,t:a.dem.tree.raycastRoot(h,c,u,d,e,i,r),tile:a}});for(let n of(a.sort((e,i)=>(null!==e.t?e.t:Number.MAX_VALUE)-(null!==i.t?i.t:Number.MAX_VALUE)),a)){if(null==n.t)break;let a=n.tile.dem.tree.raycast(n.minx,n.miny,n.maxx,n.maxy,e,i,r);if(null!=a)return a}return null}_createFBO(){let i=this.painter.context,r=i.gl,a=this.drapeBufferSize;i.activeTexture.set(r.TEXTURE0);let n=new e.T(i,{width:a[0],height:a[1],data:null},r.RGBA8);n.bind(r.LINEAR,r.CLAMP_TO_EDGE);let o=i.createFramebuffer(a[0],a[1],!0,null);return o.colorAttachment.set(n.texture),o.depthAttachment=new rx(i,o.framebuffer),void 0===this._sharedDepthStencil?(this._sharedDepthStencil=i.createRenderbuffer(i.gl.DEPTH_STENCIL,a[0],a[1]),this._stencilRef=0,o.depthAttachment.set(this._sharedDepthStencil),i.clear({stencil:0})):o.depthAttachment.set(this._sharedDepthStencil),i.extTextureFilterAnisotropic&&r.texParameterf(r.TEXTURE_2D,i.extTextureFilterAnisotropic.TEXTURE_MAX_ANISOTROPY_EXT,i.extTextureFilterAnisotropicMax),{fb:o,tex:n,dirty:!1}}_initFBOPool(){for(;this.pool.length<Math.min(5,this.proxyCoords.length);)this.pool.push(this._createFBO())}_shouldDisableRenderCache(){if(this._debugParams.disableRenderCache||this._style.hasLightTransitions())return!0;for(let e in this._style._mergedSourceCaches)if(this._style._mergedSourceCaches[e].hasTransition())return!0;return this._style.order.some(e=>{let i=this._style._mergedLayers[e],r=i.isHidden(this.painter.transform.zoom);return"hillshade"===i.type||"custom"===i.type?!r&&i.shouldRedrape():!r&&i.hasTransition()})}_clearLineLayersFromRenderCache(){let i=!1;for(let e of this._style.getSources())if(e instanceof eX){i=!0;break}if(!i)return;let r={};for(let i=0;i<this._style.order.length;++i){let a=this._style._mergedLayers[this._style.order[i]],n=this._style.getLayerSourceCache(a);if(n&&!r[n.id]&&!a.isHidden(this.painter.transform.zoom)&&"line"===a.type&&a.widthExpression()instanceof e.ad)for(let e of(r[n.id]=!0,this.proxyCoords)){let i=this.proxyToSource[e.key][n.id];if(i)for(let e of i)this._clearRenderCacheForTile(n.id,e)}}}_clearRasterLayersFromRenderCache(){let e=!1;for(let i in this._style._mergedSourceCaches)if(this._style._mergedSourceCaches[i]._source instanceof eY){e=!0;break}if(!e)return;let i={};for(let e=0;e<this._style.order.length;++e){let r=this._style._mergedLayers[this._style.order[e]],a=this._style.getLayerSourceCache(r);if(!a||i[a.id]||r.isHidden(this.painter.transform.zoom)||"raster"!==r.type)continue;let n=r.paint.get("raster-fade-duration");for(let e of this.proxyCoords){let i=this.proxyToSource[e.key][a.id];if(i)for(let e of i){let i=rA(a.getTile(e),a.findLoadedParent(e,0),a,this.painter.transform,n);(1!==i.opacity||0!==i.mix)&&this._clearRenderCacheForTile(a.id,e)}}}}_setupDrapedRenderBatches(){this._style.updateDrapeFirstLayers();let i=this._style.order,r=i.length;if(0===r)return;let a=[];this._pendingGroundEffectLayers=[];let n,o=0,s=this._style._mergedLayers[i[o]];for(;!this._style.isLayerDraped(s)&&s.isHidden(this.painter.transform.zoom)&&++o<r;)s=this._style._mergedLayers[i[o]];for(;o<r;++o){let e=this._style._mergedLayers[i[o]];e.isHidden(this.painter.transform.zoom)||(this._style.isLayerDraped(e)?void 0===n&&(n=o):("fill-extrusion"===e.type&&this._pendingGroundEffectLayers.push(o),void 0!==n&&(a.push({start:n,end:o-1}),n=void 0)))}if(void 0!==n&&a.push({start:n,end:o-1}),0!==a.length){let i=a[a.length-1];this._pendingGroundEffectLayers.every(e=>e>i.end)||e.w("fill-extrusion with flood lighting and/or ground ambient occlusion should be moved to be on top of all draped layers.")}this._drapedRenderBatches=a}_setupRenderCache(e){let i=this.proxySourceCache;if(this._shouldDisableRenderCache()||this.invalidateRenderCache){if(this.invalidateRenderCache=!1,i.renderCache.length>i.renderCachePool.length){let e=Object.values(i.proxyCachedFBO);i.proxyCachedFBO={};for(let r=0;r<e.length;++r){let a=Object.values(e[r]);i.renderCachePool.push(...a)}}return}this._clearRasterLayersFromRenderCache();let r=this.proxyCoords,a=this._tilesDirty;for(let n=r.length-1;n>=0;n--){let o=r[n];if(i.getTileByID(o.key),void 0!==i.proxyCachedFBO[o.key]){let r=e[o.key],n=this.proxyToSource[o.key],s=0;for(let e in n){let i=n[e],o=r[e];if(!o||o.length!==i.length||i.some((i,r)=>i!==o[r]||a[e]&&a[e].hasOwnProperty(i.key))){s=-1;break}++s}for(let e in i.proxyCachedFBO[o.key])i.renderCache[i.proxyCachedFBO[o.key][e]].dirty=s<0||s!==Object.values(r).length}}let n=[...this._drapedRenderBatches];for(let e of(n.sort((e,i)=>i.end-i.start-(e.end-e.start)),n))for(let a of r){if(i.proxyCachedFBO[a.key])continue;let r=i.renderCachePool.pop();void 0===r&&i.renderCache.length<50&&(r=i.renderCache.length,i.renderCache.push(this._createFBO())),void 0!==r&&(i.proxyCachedFBO[a.key]={},i.proxyCachedFBO[a.key][e.start]=r,i.renderCache[r].dirty=!0)}this._tilesDirty={}}_setupStencil(e,i,r,a){let n;if(!a||!this._sourceTilesOverlap[a.id])return void(this._overlapStencilType&&(this._overlapStencilType=!1));let o=this.painter.context,s=o.gl;if(i.length<=1)return void(this._overlapStencilType=!1);if(r.isTileClipped())n=i.length,this._overlapStencilMode.test={func:s.EQUAL,mask:255},this._overlapStencilType="Clip";else{if(!(i[0].overscaledZ>
94i[i.length-1].overscaledZ))return void(this._overlapStencilType=!1);n=1,this._overlapStencilMode.test={func:s.GREATER,mask:255},this._overlapStencilType="Mask"}this._stencilRef+n>255&&(o.clear({stencil:0}),this._stencilRef=0),this._stencilRef+=n,this._overlapStencilMode.ref=this._stencilRef,r.isTileClipped()&&this._renderTileClippingMasks(i,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):t3.disabled}_renderTileClippingMasks(e,i){let r=this.painter,a=this.painter.context,n=a.gl;r._tileClippingMaskIDs={},a.setColorMode(t1.disabled),a.setDepthMode(t2.disabled);let o=r.getOrCreateProgram("clippingMask");for(let a of e){let e=r._tileClippingMaskIDs[a.key]=--i;o.draw(r,n.TRIANGLES,t2.disabled,new t3({func:n.ALWAYS,mask:0},e,255,n.KEEP,n.KEEP,n.REPLACE),t1.disabled,t5.disabled,rI(a.projMatrix),"$clipping",r.tileExtentBuffer,r.quadTriangleIndexBuffer,r.tileExtentSegments)}}pointCoordinate(i){let r=this.painter.transform;if(i.x<0||i.x>r.width||i.y<0||i.y>r.height)return null;let a=[i.x,i.y,1,1];e.aC(a,a,r.pixelMatrixInverse),e.cJ(a,a,1/a[3]),a[0]/=r.worldSize,a[1]/=r.worldSize;let n=r._camera.position,o=e.ce(1,r.center.lat),s=[n[0],n[1],n[2]/o,0],l=e.d9([],a.slice(0,3),s);e.aw(l,l);let h=this.raycast(s,l,this._exaggeration);return null!==h&&h?(e.bH(s,s,l,h),s[3]=s[2],s[2]*=o,s):null}_setupProxiedCoordsForOrtho(i,r,a){if(i.getSource()instanceof e.aS)return this._setupProxiedCoordsForImageSource(i,r,a);this._findCoveringTileCache[i.id]=this._findCoveringTileCache[i.id]||{};let n=this.proxiedCoords[i.id]=[],o=this.proxyCoords;for(let e=0;e<o.length;e++){let r=o[e],s=this._findTileCoveringTileID(r,i);if(s){let e=this._createProxiedId(r,s,a[r.key]&&a[r.key][i.id]);n.push(e),this.proxyToSource[r.key][i.id]=[e]}}let s=!1,l=new Set;for(let e=0;e<r.length;e++){let o=i.getTile(r[e]);if(!o||!o.hasData())continue;let h=this._findTileCoveringTileID(o.tileID,this.proxySourceCache);if(h&&h.tileID.canonical.z!==o.tileID.canonical.z){let e=this.proxyToSource[h.tileID.key][i.id],r=this._createProxiedId(h.tileID,o,a[h.tileID.key]&&a[h.tileID.key][i.id]);e?e.splice(e.length-1,0,r):this.proxyToSource[h.tileID.key][i.id]=[r];let u=this.proxyToSource[h.tileID.key][i.id];l.has(u)||l.add(u),n.push(r),s=!0}}if(this._sourceTilesOverlap[i.id]=s,s&&this._debugParams.sortTilesHiZFirst)for(let e of l)e.sort((e,i)=>i.overscaledZ-e.overscaledZ)}
94_setupProxiedCoordsForImageSource(i,r,a){if(!i.getSource().loaded())return;let n=this.proxiedCoords[i.id]=[],o=this.proxyCoords,s=i.getSource(),l=s.tileID;if(!l)return;let h=new e.P(l.x,l.y)._div(1<<l.z),u=s.coordinates.map(e.ae.fromLngLat).reduce((e,i)=>(e.min.x=Math.min(e.min.x,i.x-h.x),e.min.y=Math.min(e.min.y,i.y-h.y),e.max.x=Math.max(e.max.x,i.x-h.x),e.max.y=Math.max(e.max.y,i.y-h.y),e),{min:new e.P(Number.MAX_VALUE,Number.MAX_VALUE),max:new e.P(-Number.MAX_VALUE,-Number.MAX_VALUE)}),c=(i,r)=>{let a=i.wrap+i.canonical.x/(1<<i.canonical.z),n=i.canonical.y/(1<<i.canonical.z),o=e.al/(1<<i.canonical.z),s=r.wrap+r.canonical.x/(1<<r.canonical.z),l=r.canonical.y/(1<<r.canonical.z);return a+o<s+u.min.x||a>s+u.max.x||n+o<l+u.min.y||n>l+u.max.y};for(let e=0;e<o.length;e++){let s=o[e];for(let e=0;e<r.length;e++){let o=i.getTile(r[e]);if(!o||!o.hasData()||c(s,o.tileID))continue;let l=this._createProxiedId(s,o,a[s.key]&&a[s.key][i.id]),h=this.proxyToSource[s.key][i.id];h?h.push(l):this.proxyToSource[s.key][i.id]=[l],n.push(l)}}}_createProxiedId(i,r,a){let n=this.orthoMatrix;if(a){let e=a.find(e=>e.key===r.tileID.key);if(e)return e}if(r.tileID.key!==i.key){let a,o,s,l=i.canonical.z-r.tileID.canonical.z;n=e.bC();let h=r.tileID.wrap-i.wrap<<i.overscaledZ;l>0?(o=(a=e.al>>l)*((r.tileID.canonical.x<<l)-i.canonical.x+h),s=a*((r.tileID.canonical.y<<l)-i.canonical.y)):(a=e.al<<-l,o=e.al*(r.tileID.canonical.x-(i.canonical.x+h<<-l)),s=e.al*(r.tileID.canonical.y-(i.canonical.y<<-l))),e.cd(n,0,a,0,a,0,1),e.br(n,n,[o,s,0])}return new rP(r.tileID,i.key,n)}_findTileCoveringTileID(i,r){let a=r.getTile(i);if(a&&a.hasData())return a;let n=this._findCoveringTileCache[r.id],o=n[i.key];if((a=o?r.getTileByID(o):null)&&a.hasData()||null===o)return a;let s=a?a.tileID:i,l=s.overscaledZ,h=r.getSource().minzoom,u=[];if(!o){let n=r.getSource().maxzoom;if(i.canonical.z>=n){let a=i.canonical.z-n;r.getSource().reparseOverscaled?(l=Math.max(i.canonical.z+2,r.transform.tileZoom),s=new e.aO(l,i.wrap,n,i.canonical.x>>a,i.canonical.y>>a)):0!==a&&(l=n,s=new e.aO(l,i.wrap,n,i.canonical.x>>a,i.canonical.y>>a))}s.key!==i.key&&(u.push(s.key),a=r.getTile(s))}let c=e=>{u.forEach(i=>{n[i]=e}),u.length=0};for(l-=1;l>=h&&(!a||!a.hasData());l--){a&&c(a.tileID.key);let e=s.calculateScaledKey(l);if((a=r.getTileByID(e))&&a.hasData())break;let i=n[e];if(null===i)break;void 0===i?u.push(e):a=r.getTileByID(i)}return c(a?a.tileID.key:null),a&&a.hasData()?a:null}findDEMTileFor(e){return this.enabled?this._findTileCoveringTileID(e,this.sourceCache):null}prepareDrawTile(){this.renderedToTile=!0}_clearRenderCacheForTile(e,i){let r=this._tilesDirty[e];r||(r=this._tilesDirty[e]={}),r[i.key]=!0}}let rR=["fill","fillOutline","fillPattern","line","linePattern","background","backgroundPattern","hillshade","raster"],rD=["stars","rainParticle","snowParticle","fillExtrusion","fillExtrusionGroundEffect","elevatedStructures","model","symbol"];class rL{static cacheKey(e,i,r,a){let n=`${i}${a?a.cacheKey:""}`;for(let i of r)e.usedDefines.includes(i)&&(n+=`/${i}`);return n}constructor(i,r,a,n,o,s){let l=i.gl;this.program=l.createProgram(),this.configuration=n,this.name=r,this.fixedDefines=[...s];let h=n?n.defines():[];h=h.concat(s.map(e=>`#define ${e}`));let u="#version 300 es\n",c=u+h.concat("precision mediump float;",iA,iU.fragmentSource).join("\n");for(let e of a.fragmentIncludes)c+=` 95${iN[e]}`;c+=` 96${a.fragmentSource}`;let d=u+h.concat("precision highp float;",iA,iU.vertexSource).join("\n");for(let e of a.vertexIncludes)d+=` 97${iN[e]}`;this.forceManualRenderingForInstanceIDShaders=i.forceManualRenderingForInstanceIDShaders&&-1!==a.vertexSource.indexOf("gl_InstanceID"),this.forceManualRenderingForInstanceIDShaders&&(d+="\nuniform int u_instanceID;\n"),d+=` 98${a.vertexSource}`,this.forceManualRenderingForInstanceIDShaders&&(d=d.replaceAll("gl_InstanceID","u_instanceID"));let p=l.createShader(l.FRAGMENT_SHADER);if(l.isContextLost())return void(this.failedToCreate=!0);l.shaderSource(p,c),l.compileShader(p),l.attachShader(this.program,p);let f=l.createShader(l.VERTEX_SHADER);l.isContextLost()?this.failedToCreate=!0:(l.shaderSource(f,d),l.compileShader(f),l.attachShader(this.program,f),this.attributes={},l.linkProgram(this.program),l.deleteShader(f),l.deleteShader(p),this.fixedUniforms=o(i),this.binderUniforms=n?n.getUniforms(i):[],this.forceManualRenderingForInstanceIDShaders&&(this.instancingUniforms={u_instanceID:new e.cg(i)}),(s.includes("TERRAIN")||-1!==r.indexOf("symbol")||-1!==r.indexOf("circle"))&&(this.terrainUniforms=(i=>({u_dem:new e.cg(i),u_dem_prev:new e.cg(i),u_dem_tl:new e.cj(i),u_dem_scale:new e.ci(i),u_dem_tl_prev:new e.cj(i),u_dem_scale_prev:new e.ci(i),u_dem_size:new e.ci(i),u_dem_lerp:new e.ci(i),u_exaggeration:new e.ci(i),u_depth:new e.cg(i),u_depth_size_inv:new e.cj(i),u_depth_range_unpack:new e.cj(i),u_occluder_half_size:new e.ci(i),u_occlusion_depth_offset:new e.ci(i),u_meter_to_dem:new e.ci(i),u_label_plane_matrix_inv:new e.ck(i)}))(i)),s.includes("GLOBE")&&(this.globeUniforms=(i=>({u_tile_tl_up:new e.ch(i),u_tile_tr_up:new e.ch(i),u_tile_br_up:new e.ch(i),u_tile_bl_up:new e.ch(i),u_tile_up_scale:new e.ci(i)}))(i)),s.includes("FOG")&&(this.fogUniforms=(i=>({u_fog_matrix:new e.ck(i),u_fog_range:new e.cj(i),u_fog_color:new e.d2(i),u_fog_horizon_blend:new e.ci(i),u_fog_vertical_limit:new e.cj(i),u_fog_temporal_offset:new e.ci(i),u_frustum_tl:new e.ch(i),u_frustum_tr:new e.ch(i),u_frustum_br:new e.ch(i),u_frustum_bl:new e.ch(i),u_globe_pos:new e.ch(i),u_globe_radius:new e.ci(i),u_globe_transition:new e.ci(i),u_is_globe:new e.cg(i),u_viewport:new e.cj(i)}))(i)),s.includes("RENDER_CUTOFF")&&(this.cutoffUniforms={u_cutoff_params:new e.d2(i)}),s.includes("LIGHTING_3D_MODE")&&(this.lightsUniforms=(i=>({u_lighting_ambient_color:new e.ch(i),u_lighting_directional_dir:new e.ch(i),u_lighting_directional_color:new e.ch(i),u_ground_radiance:new e.ch(i)}))(i)),s.includes("RENDER_SHADOWS")&&(this.shadowUniforms=(i=>({u_light_matrix_0:new e.ck(i),u_light_matrix_1:new e.ck(i),u_fade_range:new e.cj(i),u_shadow_normal_offset:new e.ch(i),u_shadow_intensity:new e.ci(i),u_shadow_texel_size:new e.ci(i),u_shadow_map_resolution:new e.ci(i),u_shadow_direction:new e.ch(i),u_shadow_bias:new e.ch(i),u_shadowmap_0:new e.cg(i),u_shadowmap_1:new e.cg(i)}))(i)))}getAttributeLocation(e,i){let r=this.attributes[i];return void 0===r&&(r=this.attributes[i]=e.getAttribLocation(this.program,i)),r}setTerrainUniformValues(e,i){if(!this.terrainUniforms)return;let r=this.terrainUniforms;if(!this.failedToCreate)for(let a in e.program.set(this.program),i)r[a]&&r[a].set(this.program,a,i[a])}setGlobeUniformValues(e,i){if(!this.globeUniforms)return;let r=this.globeUniforms;if(!this.failedToCreate)for(let a in e.program.set(this.program),i)r[a]&&r[a].set(this.program,a,i[a])}setFogUniformValues(e,i){if(!this.fogUniforms)return;let r=this.fogUniforms;if(!this.failedToCreate)for(let a in e.program.set(this.program),i)r[a].set(this.program,a,i[a])}setCutoffUniformValues(e,i){if(!this.cutoffUniforms)return;let r=this.cutoffUniforms;if(!this.failedToCreate)for(let a in e.program.set(this.program),i)r[a].set(this.program,a,i[a])}setLightsUniformValues(e,i){if(!this.lightsUniforms)return;let r=this.lightsUniforms;if(!this.failedToCreate)for(let a in e.program.set(this.program),i)r[a].set(this.program,a,i[a])}setShadowUniformValues(e,i){if(this.failedToCreate||!this.shadowUniforms)return;let r=this.shadowUniforms;for(let a in e.program.set(this.program),i)r[a].set(this.program,a,i[a])}_drawDebugWireframe(i,r,a,n,o,s,l,h,u,c){let d=i.options.wireframe;if(!1===d.terrain&&!1===d.layers2D&&!1===d.layers3D)return;let p=i.context;if(!(!(!d.terrain||"terrainRaster"!==this.name&&"globeRaster"!==this.name)||!(!d.layers2D||i._terrain&&i._terrain.renderingToTexture||!rR.includes(this.name))||!(!d.layers3D||!rD.includes(this.name))))return;let f=p.gl,m=i.wireframeDebugCache.getLinesFromTrianglesBuffer(i.frameCounter,o,p);if(!m)return;let _=[...this.fixedDefines];
98_.push("DEBUG_WIREFRAME");let g=i.getOrCreateProgram(this.name,{config:this.configuration,defines:_});p.program.set(g.program);let y=(e,i,r)=>{if(i[e]&&r[e])for(let a in i[e])r[e][a]&&r[e][a].set(r.program,a,i[e][a].current)};u&&u.setUniforms(g.program,p,g.binderUniforms,l,{zoom:h}),y("fixedUniforms",this,g),y("terrainUniforms",this,g),y("globeUniforms",this,g),y("fogUniforms",this,g),y("lightsUniforms",this,g),y("shadowUniforms",this,g),m.bind(),p.setColorMode(new t1([f.ONE,f.ONE_MINUS_SRC_ALPHA,f.ZERO,f.ONE],e.ao.transparent,[!0,!0,!0,!1])),p.setDepthMode(new t2(r.func===f.LESS?f.LEQUAL:r.func,t2.ReadOnly,r.range)),p.setStencilMode(t3.disabled);let x=3*s.primitiveLength*2,v=3*s.primitiveOffset*4;if(this.forceManualRenderingForInstanceIDShaders){let e=c||1;for(let i=0;i<e;++i)g.instancingUniforms.u_instanceID.set(this.program,"u_instanceID",i),f.drawElements(f.LINES,x,f.UNSIGNED_SHORT,v)}else c&&c>1?f.drawElementsInstanced(f.LINES,x,f.UNSIGNED_SHORT,v,c):f.drawElements(f.LINES,x,f.UNSIGNED_SHORT,v);o.bind(),p.program.set(this.program),p.setDepthMode(r),p.setStencilMode(a),p.setColorMode(n)}checkUniforms(e,i,r){if(this.fixedDefines.includes(i)){for(let a of Object.keys(r))if(!r[a].initialized)throw Error(`Program '${this.name}', from draw '${e}': uniform ${a} not set but required by ${i} being defined`)}}draw(e,i,r,a,n,o,s,l,h,u,c,d,p,f,m,_){let g=e.context,y=g.gl;if(this.failedToCreate)return;for(let e of(g.program.set(this.program),g.setDepthMode(r),g.setStencilMode(a),g.setColorMode(n),g.setCullFace(o),Object.keys(this.fixedUniforms)))this.fixedUniforms[e].set(this.program,e,s[e]);f&&f.setUniforms(this.program,g,this.binderUniforms,d,{zoom:p});let x={[y.POINTS]:1,[y.LINES]:2,[y.TRIANGLES]:3,[y.LINE_STRIP]:1}[i];this.checkUniforms(l,"RENDER_SHADOWS",this.shadowUniforms);let v=_&&_>0?1:void 0;for(let o of c.get()){let s=o.vaos||(o.vaos={});if((s[l]||(s[l]=new i$)).bind(g,this,h,f?f.getPaintVertexBuffers():[],u,o.vertexOffset,m||[],v),this.forceManualRenderingForInstanceIDShaders){let e=_||1;for(let r=0;r<e;++r)this.instancingUniforms.u_instanceID.set(this.program,"u_instanceID",r),u?y.drawElements(i,o.primitiveLength*x,y.UNSIGNED_SHORT,o.primitiveOffset*x*2):y.drawArrays(i,o.vertexOffset,o.vertexLength)}else _&&_>1?y.drawElementsInstanced(i,o.primitiveLength*x,y.UNSIGNED_SHORT,o.primitiveOffset*x*2,_):u?y.drawElements(i,o.primitiveLength*x,y.UNSIGNED_SHORT,o.primitiveOffset*x*2):y.drawArrays(i,o.vertexOffset,o.vertexLength);i===y.TRIANGLES&&u&&this._drawDebugWireframe(e,r,a,n,u,o,d,p,f,_)}}}function rO(i,r,a=0){let n=Math.pow(2,r.tileID.overscaledZ),o=r.tileSize*Math.pow(2,i.transform.tileZoom)/n,s=o*(r.tileID.canonical.x+r.tileID.wrap*n),l=o*r.tileID.canonical.y;return{u_image:0,u_texsize:r.imageAtlasTexture?r.imageAtlasTexture.size:[0,0],u_tile_units_to_pixels:1/e.ay(r,1,i.transform.tileZoom),u_pixel_coord_upper:[s>>16,l>>16],u_pixel_coord_lower:[65535&s,65535&l],u_pattern_transition:a}}let rF={terrain:0,flat:1},rk=e.bC(),rB=(i,r,a,n,o,s,l,h,u,c,d,p,f,m,_,g,y,x)=>{let v=r.style.light,b=v.properties.get("position"),w=[b.x,b.y,b.z],T=e.dL();"viewport"===v.properties.get("anchor")&&(e.dM(T,-r.transform.angle),e.dN(w,w,T));let S=v.properties.get("color").toPremultipliedRenderColor(null),E=r.transform,I={u_matrix:i,u_lightpos:w,u_lightintensity:v.properties.get("intensity"),u_lightcolor:[S.r,S.g,S.b],u_vertical_gradient:+a,u_opacity:n,u_tile_id:[0,0,0],u_zoom_transition:0,u_inv_rot_matrix:rk,u_merc_center:[0,0],u_up_dir:[0,0,0],u_height_lift:0,u_height_type:rF[c],u_base_type:rF[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"===E.projection.name&&(I.u_tile_id=[h.canonical.x,h.canonical.y,1<<h.canonical.z],I.u_zoom_transition=p,I.u_inv_rot_matrix=m,I.u_merc_center=f,I.u_up_dir=E.projection.upVector(new e.cC(0,0,0),f[0]*e.al,f[1]*e.al),I.u_height_lift=u),I},rN=(e,i,r,a,n,o)=>({u_matrix:e,u_edge_radius:i,u_width_scale:r,u_vertical_scale:a,u_height_type:rF[n],u_base_type:rF[o]}),rV=(e,i,r,a,n,o,s,l,h,u,c,d,p,f,m,_,g,y)=>{let x=rB(e,i,r,a,n,o,s,l,u,c,d,p,f,m,_,g,1,[0,0,0]),v={u_height_factor:-Math.pow(2,l.overscaledZ
98)/h.tileSize/8};return Object.assign(x,rO(i,h,y),v)},rU=(e,i,r)=>({u_matrix:e,u_emissive_strength:i,u_ground_shadow_factor:r}),rj=(e,i,r,a,n,o=0)=>Object.assign(rU(e,i,n),rO(r,a,o)),rG=(e,i,r,a)=>({u_matrix:e,u_world:r,u_emissive_strength:i,u_ground_shadow_factor:a}),rq=(e,i,r,a,n,o,s=0)=>Object.assign(rj(e,i,r,a,o,s),{u_world:n}),r$=(e,i)=>({u_matrix:e,u_ground_shadow_factor:i}),rH=(e,i,r,a,n)=>({u_matrix:e,u_camera_pos:[i[0],i[1],i[2]],u_depth_bias:r,u_height_scale:a,u_reset_depth:n}),rZ=(e,i,r,a,n,o,s)=>({u_matrix:e,u_normal_matrix:i,u_opacity:r,u_faux_facade_ao_intensity:a,u_camera_pos:n,u_tile_to_meter:o,u_facade_emissive_chance:s}),rW=e=>({u_matrix:e}),rX=e=>({u_matrix:e}),rY=(i,r,a,n,o,s,l,h)=>{let u=e.al/s.tileSize;return{u_matrix:i,u_inv_rot_matrix:r,u_camera_to_center_distance:a.getCameraToCenterDistance(h),u_extrude_scale:[a.pixelsToGLUnits[0]/u,a.pixelsToGLUnits[1]/u],u_zoom_transition:n,u_tile_id:l,u_merc_center:o}},rK=(e,i,r=1)=>({u_matrix:e,u_color:i,u_overlay:0,u_overlay_scale:r}),rJ=e.bC(),rQ=(i,r,a,n,o,s,l)=>{let h=i.transform,u="globe"===h.projection.name,c=u?e.dO(h.zoom,r.canonical)*h._pixelsPerMercatorPixel:e.ay(a,1,s),d={u_matrix:r.projMatrix,u_extrude_scale:c,u_intensity:l,u_inv_rot_matrix:rJ,u_merc_center:[0,0],u_tile_id:[0,0,0],u_zoom_transition:0,u_up_dir:[0,0,0]};if(u){d.u_inv_rot_matrix=n,d.u_merc_center=o,d.u_tile_id=[r.canonical.x,r.canonical.y,1<<r.canonical.z],d.u_zoom_transition=e.aj(h.zoom);let i=o[0]*e.al,a=o[1]*e.al;d.u_up_dir=h.projection.upVector(new e.cC(0,0,0),i,a)}return d};function r0(e,[i,r,a,n],[o,s]){if(o===s)return[0,0,0,0];let l=255*(e-1)/(e*(s-o));return[i*l,r*l,a*l,n*l]}function r1(e,i,[r,a]){return r===a?0:.5/e+(i-r)*(e-1)/(e*(a-r))}let r2=(i,r,a,n,o,s,l,h,u,c,d,p,f,m,_,g,y,x,v,b,w)=>({u_matrix:i,u_normalize_matrix:r,u_globe_matrix:a,u_merc_matrix:n,u_grid_matrix:o,u_tl_parent:s,u_scale_parent:c,u_fade_t:d.mix,u_opacity:d.opacity*p.paint.get("raster-opacity"),u_image0:0,u_image1:1,u_brightness_low:p.paint.get("raster-brightness-min"),u_brightness_high:p.paint.get("raster-brightness-max"),u_saturation_factor:e.dQ(p.paint.get("raster-saturation")),u_contrast_factor:e.dP(p.paint.get("raster-contrast")),u_spin_weights:function(e){let i=Math.sin(e*=Math.PI/180),r=Math.cos(e);return[(2*r+1)/3,(-Math.sqrt(3)*i-r+1)/3,(Math.sqrt(3)*i-r+1)/3]}(p.paint.get("raster-hue-rotate")),u_perspective_transform:f,u_raster_elevation:m,u_zoom_transition:l,u_merc_center:h,u_cutoff_params:u,u_colorization_mix:r0(e.dR,g,x),u_colorization_offset:r1(e.dR,y,x),u_color_ramp:_,u_texture_offset:[b/(v+2*b),v/(v+2*b)],u_texture_res:[v+2*b,v+2*b],u_emissive_strength:w}),r3=(e,i,r,a,n,o,s,l,h,u,c,d)=>({u_matrix:e,u_normalize_matrix:i,u_globe_matrix:r,u_merc_matrix:a,u_grid_matrix:n,u_tl_parent:o,u_scale_parent:u,u_fade_t:c.mix,u_opacity:c.opacity,u_image0:0,u_image1:1,u_raster_elevation:d,u_zoom_transition:s,u_merc_center:l,u_cutoff_params:h}),r5=(e,i,r,a,n,o,s,l,h,u)=>({u_particle_texture:e,u_particle_texture_side_len:i,u_tile_offset:r,u_velocity:a,u_color_ramp:o,u_velocity_res:n,u_max_speed:s,u_uv_offset:l,u_data_scale:[255*h[0],255*h[1]],u_data_offset:u,u_particle_pos_scale:1.1,u_particle_pos_offset:[.05,.05]}),r4=(e,i,r,a,n,o,s,l,h,u)=>({u_particle_texture:e,u_particle_texture_side_len:i,u_velocity:r,u_velocity_res:a,u_max_speed:n,u_speed_factor:o,u_reset_rate:s,u_rand_seed:Math.random(),u_uv_offset:l,u_data_scale:[255*h[0],255*h[1]],u_data_offset:u,u_particle_pos_scale:1.1,u_particle_pos_offset:[.05,.05]}),r6=e.bC(),r8=(i,r,a,n,o,s,l,h,u,c,d,p,f,m,_,g,y,x,v,b,w,T,S,E)=>{let I=o.transform,A={u_is_size_zoom_constant:+("constant"===i||"source"===i),u_is_size_feature_constant:+("constant"===i||"camera"===i),u_size_t:r?r.uSizeT:0,u_size:r?r.uSize:0,u_camera_to_center_distance:I.getCameraToCenterDistance(v),u_rotate_symbol:+a,u_aspect_ratio:I.width/I.height,u_fade_change:o.options.fadeDuration?o.symbolFadeChange:1,u_matrix:s,u_label_plane_matrix:l,u_coord_matrix:h,u_is_text:+c,u_elevation_from_sea:+!!u,u_pitch_with_map:+n,u_texsize:d,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:r6,u_merc_center:[0,0],u_camera_forward:[0,0,0],u_ecef_origin:[0,0,0],u_tile_matrix:r6,u_up_vector:[0,-1,0],u_color_adj_mat:T,u_icon_transition:S||0,u_gamma_scale:n?o.transform.getCameraToCenterDistance(v)*Math.cos(o.terrain?0:o.transform._pitch):1,u_device_pixel_ratio:e.o.devicePixelRatio,u_is_halo:1,u_scale_factor:E||1,u_ground_shadow_factor:b,u_inv_matrix:e.bl(e.bC(),l),u_normal_scale:w,u_lutTexture:10};return"globe"===v.name&&(A.u_tile_id=[m.canonical.x,m.canonical.y,1<<m.canonical.z],A.u_zoom_transition=_,A.u_inv_rot_matrix=y,A.u_merc_center=g,A.u_camera_forward=I._camera.forward(),A.u_ecef_origin=e.dS(I.globeMatrix,m.toUnwrapped()),A.u_tile_matrix=Float32Array.from(I.globeMatrix),A.u_up_vector=x),A},r9=(e,i,r,a)=>({u_matrix:e,u_emissive_strength:i,u_opacity:r,u_color:a}),r7=(i,r,a,n,o,s,l,h,u)=>Object.assign(function(i,r,a,n,o,s){let{width:l,height:h}=n.imageManager.getPixelSize(r),u=Math.pow(2,s.tileID.overscaledZ
98),c=s.tileSize*Math.pow(2,n.transform.tileZoom)/u,d=c*(s.tileID.canonical.x+s.tileID.wrap*u),p=c*s.tileID.canonical.y;return{u_image:0,u_pattern_tl:a.tl,u_pattern_br:a.br,u_texsize:[l,h],u_pattern_size:a.displaySize,u_pattern_units_to_pixels:o?[n.transform.width,-1*n.transform.height]:[1/e.ay(s,1,n.transform.tileZoom),1/e.ay(s,1,n.transform.tileZoom)],u_pixel_coord_upper:[d>>16,p>>16],u_pixel_coord_lower:[65535&d,65535&p]}}(0,s,l,n,h,u),{u_matrix:i,u_emissive_strength:r,u_opacity:a}),ae=new Float32Array(e.bA([])),at=(i,r,a,n,o,s,l,h,u,c,d,p,f,m=[0,0,0],_)=>{let g=o.style.light,y=g.properties.get("position"),x=[-y.x,-y.y,y.z],v=e.dL();"viewport"===g.properties.get("anchor")&&(e.dM(v,-o.transform.angle),e.dN(x,x,v));let b="MASK"===d.alphaMode,w=g.properties.get("color").toNonPremultipliedRenderColor(null),T=f.paint.get("model-ambient-occlusion-intensity"),S=f.paint.get("model-color").constantOr(e.ao.white).toNonPremultipliedRenderColor(null);return S.a=f.paint.get("model-color-mix-intensity").constantOr(0),{u_matrix:i,u_lighting_matrix:r,u_normal_matrix:a,u_node_matrix:n||ae,u_lightpos:x,u_lightintensity:g.properties.get("intensity"),u_lightcolor:[w.r,w.g,w.b],u_camera_pos:m,u_opacity:s,u_baseTextureIsAlpha:0,u_alphaMask:+b,u_alphaCutoff:d.alphaCutoff,u_baseColorFactor:l.toNonPremultipliedRenderColor(null).toArray01(),u_emissiveFactor:h.toNonPremultipliedRenderColor(null).toArray01(),u_metallicFactor:u,u_roughnessFactor:c,u_baseColorTexture:5,u_metallicRoughnessTexture:6,u_normalTexture:7,u_occlusionTexture:8,u_emissionTexture:9,u_lutTexture:10,u_color_mix:S.toArray01(),u_aoIntensity:T,u_emissive_strength:p,u_occlusionTextureTransform:_||[0,0,0,0]}},ai=(e,i=ae,r=ae)=>({u_matrix:e,u_instance:i,u_node_matrix:r}),ar={fillExtrusion:i=>({u_matrix:new e.ck(i),u_lightpos:new e.ch(i),u_lightintensity:new e.ci(i),u_lightcolor:new e.ch(i),u_vertical_gradient:new e.ci(i),u_opacity:new e.ci(i),u_edge_radius:new e.ci(i),u_width_scale:new e.ci(i),u_ao:new e.cj(i),u_height_type:new e.cg(i),u_base_type:new e.cg(i),u_tile_id:new e.ch(i),u_zoom_transition:new e.ci(i),u_inv_rot_matrix:new e.ck(i),u_merc_center:new e.cj(i),u_up_dir:new e.ch(i),u_height_lift:new e.ci(i),u_flood_light_color:new e.ch(i),u_vertical_scale:new e.ci(i),u_flood_light_intensity:new e.ci(i),u_ground_shadow_factor:new e.ch(i)}),fillExtrusionDepth:i=>({u_matrix:new e.ck(i),u_edge_radius:new e.ci(i),u_width_scale:new e.ci(i),u_vertical_scale:new e.ci(i),u_height_type:new e.cg(i),u_base_type:new e.cg(i)}),fillExtrusionPattern:i=>({u_matrix:new e.ck(i),u_lightpos:new e.ch(i),u_lightintensity:new e.ci(i),u_lightcolor:new e.ch(i),u_vertical_gradient:new e.ci(i),u_height_factor:new e.ci(i),u_edge_radius:new e.ci(i),u_width_scale:new e.ci(i),u_ao:new e.cj(i),u_height_type:new e.cg(i),u_base_type:new e.cg(i),u_tile_id:new e.ch(i),u_zoom_transition:new e.ci(i),u_inv_rot_matrix:new e.ck(i),u_merc_center:new e.cj(i),u_up_dir:new e.ch(i),u_height_lift:new e.ci(i),u_image:new e.cg(i),u_texsize:new e.cj(i),u_pixel_coord_upper:new e.cj(i),u_pixel_coord_lower:new e.cj(i),u_tile_units_to_pixels:new e.ci(i),u_opacity:new e.ci(i),u_pattern_transition:new e.ci(i)}),fillExtrusionGroundEffect:i=>({u_matrix:new e.ck(i),u_opacity:new e.ci(i),u_ao_pass:new e.ci(i),u_meter_to_tile:new e.ci(i),u_ao:new e.cj(i),u_flood_light_intensity:new e.ci(i),u_flood_light_color:new e.ch(i),u_attenuation:new e.ci(i),u_edge_radius:new e.ci(i),u_fb:new e.cg(i),u_fb_size:new e.ci(i),u_dynamic_offset:new e.ci(i)}),fill:i=>({u_matrix:new e.ck(i),u_emissive_strength:new e.ci(i),u_ground_shadow_factor:new e.ch(i)}),fillPattern:i=>({u_matrix:new e.ck(i),u_emissive_strength:new e.ci(i),u_image:new e.cg(i),u_texsize:new e.cj(i),u_pixel_coord_upper:new e.cj(i),u_pixel_coord_lower:new e.cj(i),u_tile_units_to_pixels:new e.ci(i),u_ground_shadow_factor:new e.ch(i),u_pattern_transition:new e.ci(i)}),fillOutline:i=>({u_matrix:new e.ck(i),u_emissive_strength:new e.ci(i),u_world:new e.cj(i),u_ground_shadow_factor:new e.ch(i)}),fillOutlinePattern:i=>({u_matrix:new e.ck(i),u_emissive_strength:new e.ci(i),u_world:new e.cj(i),u_image:new e.cg(i),u_texsize:new e.cj(i),u_pixel_coord_upper:new e.cj(i),u_pixel_coord_lower:new e.cj(i),u_tile_units_to_pixels:new e.ci(i),u_ground_shadow_factor:new e.ch(i),u_pattern_transition:new e.ci(i)}),building:i=>({u_matrix:new e.ck(i),u_normal_matrix:new e.ck(i),u_opacity:new e.ci(i),u_faux_facade_ao_intensity:new e.ci(i),u_camera_pos:new e.ch(i),u_tile_to_meter:new e.ci(i),u_facade_emissive_chance:new e.ci(i)}),buildingBloom:i=>({u_matrix:new e.ck(i)}),buildingDepth:i=>({u_matrix:new e.ck(i)}),elevatedStructuresDepth:i=>
98({u_matrix:new e.ck(i),u_depth_bias:new e.ci(i)}),elevatedStructures:i=>({u_matrix:new e.ck(i),u_ground_shadow_factor:new e.ch(i)}),elevatedStructuresDepthReconstruct:i=>({u_matrix:new e.ck(i),u_camera_pos:new e.ch(i),u_depth_bias:new e.ci(i),u_height_scale:new e.ci(i),u_reset_depth:new e.ci(i)}),circle:e.dV,collisionBox:i=>({u_matrix:new e.ck(i),u_inv_rot_matrix:new e.ck(i),u_camera_to_center_distance:new e.ci(i),u_extrude_scale:new e.cj(i),u_zoom_transition:new e.ci(i),u_merc_center:new e.cj(i),u_tile_id:new e.ch(i)}),collisionCircle:i=>({u_matrix:new e.ck(i),u_inv_matrix:new e.ck(i),u_camera_to_center_distance:new e.ci(i),u_viewport_size:new e.cj(i)}),debug:i=>({u_color:new e.dx(i),u_matrix:new e.ck(i),u_overlay:new e.cg(i),u_overlay_scale:new e.ci(i)}),clippingMask:i=>({u_matrix:new e.ck(i)}),heatmap:i=>({u_extrude_scale:new e.ci(i),u_intensity:new e.ci(i),u_matrix:new e.ck(i),u_inv_rot_matrix:new e.ck(i),u_merc_center:new e.cj(i),u_tile_id:new e.ch(i),u_zoom_transition:new e.ci(i),u_up_dir:new e.ch(i)}),heatmapTexture:i=>({u_image:new e.cg(i),u_color_ramp:new e.cg(i),u_opacity:new e.ci(i)}),hillshade:i=>({u_matrix:new e.ck(i),u_image:new e.cg(i),u_latrange:new e.cj(i),u_light:new e.cj(i),u_shadow:new e.dx(i),u_highlight:new e.dx(i),u_emissive_strength:new e.ci(i),u_accent:new e.dx(i)}),hillshadePrepare:i=>({u_matrix:new e.ck(i),u_image:new e.cg(i),u_dimension:new e.cj(i),u_zoom:new e.ci(i)}),line:e.dU,linePattern:e.dT,raster:i=>({u_matrix:new e.ck(i),u_normalize_matrix:new e.ck(i),u_globe_matrix:new e.ck(i),u_merc_matrix:new e.ck(i),u_grid_matrix:new e.dy(i),u_tl_parent:new e.cj(i),u_scale_parent:new e.ci(i),u_fade_t:new e.ci(i),u_opacity:new e.ci(i),u_image0:new e.cg(i),u_image1:new e.cg(i),u_brightness_low:new e.ci(i),u_brightness_high:new e.ci(i),u_saturation_factor:new e.ci(i),u_contrast_factor:new e.ci(i),u_spin_weights:new e.ch(i),u_perspective_transform:new e.cj(i),u_raster_elevation:new e.ci(i),u_zoom_transition:new e.ci(i),u_merc_center:new e.cj(i),u_cutoff_params:new e.d2(i),u_colorization_mix:new e.d2(i),u_colorization_offset:new e.ci(i),u_color_ramp:new e.cg(i),u_texture_offset:new e.cj(i),u_texture_res:new e.cj(i),u_emissive_strength:new e.ci(i)}),rasterParticle:i=>({u_matrix:new e.ck(i),u_normalize_matrix:new e.ck(i),u_globe_matrix:new e.ck(i),u_merc_matrix:new e.ck(i),u_grid_matrix:new e.dy(i),u_tl_parent:new e.cj(i),u_scale_parent:new e.ci(i),u_fade_t:new e.ci(i),u_opacity:new e.ci(i),u_image0:new e.cg(i),u_image1:new e.cg(i),u_raster_elevation:new e.ci(i),u_zoom_transition:new e.ci(i),u_merc_center:new e.cj(i),u_cutoff_params:new e.d2(i)}),rasterParticleTexture:i=>({u_texture:new e.cg(i),u_opacity:new e.ci(i)}),rasterParticleDraw:i=>({u_particle_texture:new e.cg(i),u_particle_texture_side_len:new e.ci(i),u_tile_offset:new e.cj(i),u_velocity:new e.cg(i),u_color_ramp:new e.cg(i),u_velocity_res:new e.cj(i),u_max_speed:new e.ci(i),u_uv_offset:new e.cj(i),u_data_scale:new e.cj(i),u_data_offset:new e.ci(i),u_particle_pos_scale:new e.ci(i),u_particle_pos_offset:new e.cj(i)}),rasterParticleUpdate:i=>({u_particle_texture:new e.cg(i),u_particle_texture_side_len:new e.ci(i),u_velocity:new e.cg(i),u_velocity_res:new e.cj(i),u_max_speed:new e.ci(i),u_speed_factor:new e.ci(i),u_reset_rate:new e.ci(i),u_rand_seed:new e.ci(i),u_uv_offset:new e.cj(i),u_data_scale:new e.cj(i),u_data_offset:new e.ci(i),u_particle_pos_scale:new e.ci(i),u_particle_pos_offset:new e.cj(i)}),symbol:i=>({u_is_size_zoom_constant:new e.cg(i),u_is_size_feature_constant:new e.cg(i),u_size_t:new e.ci(i),u_size:new e.ci(i),u_camera_to_center_distance:new e.ci(i),u_rotate_symbol:new e.cg(i),u_aspect_ratio:new e.ci(i),u_fade_change:new e.ci(i),u_matrix:new e.ck(i),u_label_plane_matrix:new e.ck(i),u_coord_matrix:new e.ck(i),u_is_text:new e.cg(i),u_elevation_from_sea:new e.cg(i),u_pitch_with_map:new e.cg(i),u_texsize:new e.cj(i),u_texsize_icon:new e.cj(i),u_texture:new e.cg(i),u_texture_icon:new e.cg(i),u_gamma_scale:new e.ci(i),u_device_pixel_ratio:new e.ci(i),u_tile_id:new e.ch(i),u_zoom_transition:new e.ci(i),u_inv_rot_matrix:new e.ck(i),u_merc_center:new e.cj(i),u_camera_forward:new e.ch(i),u_tile_matrix:new e.ck(i),u_up_vector:new e.ch(i),u_ecef_origin:new e.ch(i),u_is_halo:new e.cg(i),u_icon_transition:new e.ci(i),u_color_adj_mat:new e.ck(i),u_scale_factor:new e.ci(i),u_ground_shadow_factor:new e.ch(i),u_inv_matrix:new e.ck(i),u_normal_scale:new e.ci(i),u_lutTexture:new e.cg(i)}),background:i=>({u_matrix:new e.ck(i),u_emissive_strength:new e.ci(i),u_opacity:new e.ci(i),u_color:new e.dx(i)}),backgroundPattern:i=>({u_matrix:new e.ck(i),u_emissive_strength:new e.ci(i),u_opacity:new e.ci(i),u_image:new e.cg(i),u_pattern_tl:new e.cj(i),u_pattern_br:new e.cj(i),u_texsize:new e.cj(i),u_pattern_size:new e.cj(i),u_pixel_coord_upper:new e.cj(i),u_pixel_coord_lower:new e.cj(i),u_pattern_units_to_pixels:new e.cj(i)}),terrainRaster:i=>({u_matrix:new e.ck(i),u_image0:new e.cg(i),u_skirt_height:new e.ci(i),u_ground_shadow_factor:new e.ch(i)}),skybox:i=>({u_matrix:new e.ck(i),u_sun_direction:new e.ch(i),u_cubemap:new e.cg(i),u_opacity:new e.ci(i),u_temporal_offset:new e.ci(i)}),skyboxGradient:i=>({u_matrix:new e.ck(i),u_color_ramp:new e.cg(i),u_center_direction:new e.ch(i),u_radius:new e.ci(i),u_opacity:new e.ci(i),u_temporal_offset:new e.ci(i)}),skyboxCapture:i=>({u_matrix_3f:new e.dy(i),u_sun_direction:new e.ch(i),u_sun_intensity:new e.ci(i),u_color_tint_r:new e.d2(i),u_color_tint_m:new e.d2(i),u_luminance:new e.ci(i)}),globeRaster:i=>({u_proj_matrix:new e.ck(i),u_globe_matrix:new e.ck(i),u_normalize_matrix:new e.ck(i),u_merc_matrix:new e.ck(i),u_zoom_transition:new e.ci(i),u_merc_center:new e.cj(i),u_image0:new e.cg(i),u_grid_matrix:new e.dy(i),u_skirt_height:new e.ci(i),u_far_z_cutoff:new e.ci(i),u_frustum_tl:new e.ch(i),u_frustum_tr:new e.ch(i),u_frustum_br:new e.ch(i),u_frustum_bl:new e.ch(i),u_globe_pos:new e.ch(i),u_globe_radius:new e.ci(i),u_viewport:new e.cj(i)}),globeAtmosphere:i=>({u_frustum_tl:new e.ch(i),u_frustum_tr:new e.ch(i),u_frustum_br:new e.ch(i),u_frustum_bl:new e.ch(i),u_horizon:new e.ci(i),u_transition:new e.ci(i),u_fadeout_range:new e.ci(i),u_atmosphere_fog_color:new e.d2(i),u_high_color:new e.d2(i),u_space_color:new e.d2(i),u_temporal_offset:new e.ci(i),u_horizon_angle:new e.ci(i)}),model:i=>({u_matrix:new e.ck(i),u_lighting_matrix:new e.ck(i),u_normal_matrix:new e.ck(i),u_node_matrix:new e.ck(i),u_lightpos:new e.ch(i),u_lightintensity:new e.ci(i),u_lightcolor:new e.ch(i),u_camera_pos:new e.ch(i),u_opacity:new e.ci(i),u_baseColorFactor:new e.d2(i),u_emissiveFactor:new e.d2(i),u_metallicFactor:new e.ci(i),u_roughnessFactor:new e.ci(i),u_baseTextureIsAlpha:new e.cg(i),u_alph
98aMask:new e.cg(i),u_alphaCutoff:new e.ci(i),u_baseColorTexture:new e.cg(i),u_metallicRoughnessTexture:new e.cg(i),u_normalTexture:new e.cg(i),u_occlusionTexture:new e.cg(i),u_emissionTexture:new e.cg(i),u_lutTexture:new e.cg(i),u_color_mix:new e.d2(i),u_aoIntensity:new e.ci(i),u_emissive_strength:new e.ci(i),u_occlusionTextureTransform:new e.d2(i)}),modelDepth:i=>({u_matrix:new e.ck(i),u_instance:new e.ck(i),u_node_matrix:new e.ck(i)}),groundShadow:i=>({u_matrix:new e.ck(i),u_ground_shadow_factor:new e.ch(i)}),stars:i=>({u_matrix:new e.ck(i),u_up:new e.ch(i),u_right:new e.ch(i),u_intensity_multiplier:new e.ci(i)}),snowParticle:i=>({u_modelview:new e.ck(i),u_projection:new e.ck(i),u_time:new e.ci(i),u_cam_pos:new e.ch(i),u_velocityConeAperture:new e.ci(i),u_velocity:new e.ci(i),u_horizontalOscillationRadius:new e.ci(i),u_horizontalOscillationRate:new e.ci(i),u_boxSize:new e.ci(i),u_billboardSize:new e.ci(i),u_simpleShapeParameters:new e.cj(i),u_screenSize:new e.cj(i),u_thinningCenterPos:new e.cj(i),u_thinningShape:new e.ch(i),u_thinningAffectedRatio:new e.ci(i),u_thinningParticleOffset:new e.ci(i),u_particleColor:new e.d2(i),u_direction:new e.ch(i)}),rainParticle:i=>({u_modelview:new e.ck(i),u_projection:new e.ck(i),u_time:new e.ci(i),u_cam_pos:new e.ch(i),u_texScreen:new e.cg(i),u_velocityConeAperture:new e.ci(i),u_velocity:new e.ci(i),u_boxSize:new e.ci(i),u_rainDropletSize:new e.cj(i),u_distortionStrength:new e.ci(i),u_rainDirection:new e.ch(i),u_color:new e.d2(i),u_screenSize:new e.cj(i),u_thinningCenterPos:new e.cj(i),u_thinningShape:new e.ch(i),u_thinningAffectedRatio:new e.ci(i),u_thinningParticleOffset:new e.ci(i),u_shapeDirectionalPower:new e.ci(i),u_shapeNormalPower:new e.ci(i),u_mode:new e.ci(i)}),vignette:i=>({u_vignetteShape:new e.ch(i),u_vignetteColor:new e.d2(i)}),occlusion:i=>({u_matrix:new e.ck(i),u_anchorPos:new e.ch(i),u_screenSizePx:new e.cj(i),u_occluderSizePx:new e.cj(i),u_color:new e.d2(i)})};class aa{constructor(e,i,r,a){this.id=aa.uniqueIdxCounter,aa.uniqueIdxCounter++,this.context=e;let n=e.gl;this.buffer=n.createBuffer(),this.dynamicDraw=!!r,this.context.unbindVAO(),e.bindElementBuffer.set(this.buffer),n.bufferData(n.ELEMENT_ARRAY_BUFFER,i.arrayBuffer,this.dynamicDraw?n.DYNAMIC_DRAW:n.STATIC_DRAW),this.dynamicDraw||a||i.destroy()}bind(){this.context.bindElementBuffer.set(this.buffer)}updateData(e){this.id=aa.uniqueIdxCounter,aa.uniqueIdxCounter++;let i=this.context.gl;this.context.unbindVAO(),this.bind(),i.bufferSubData(i.ELEMENT_ARRAY_BUFFER,0,e.arrayBuffer)}destroy(){this.buffer&&(this.context.gl.deleteBuffer(this.buffer),delete this.buffer)}}aa.uniqueIdxCounter=0;let an={Int8:"BYTE",Uint8:"UNSIGNED_BYTE",Int16:"SHORT",Uint16:"UNSIGNED_SHORT",Int32:"INT",Uint32:"UNSIGNED_INT",Float32:"FLOAT"};class ao{constructor(e,i,r,a,n,o){this.length=i.length,this.attributes=r,this.itemSize=i.bytesPerElement,this.dynamicDraw=a,this.instanceCount=o,this.context=e;let s=e.gl;this.buffer=s.createBuffer(),e.bindVertexBuffer.set(this.buffer),s.bufferData(s.ARRAY_BUFFER,i.arrayBuffer,this.dynamicDraw?s.DYNAMIC_DRAW:s.STATIC_DRAW),this.dynamicDraw||n||i.destroy()}bind(){this.context.bindVertexBuffer.set(this.buffer)}updateData(e){let i=this.context.gl;this.bind(),i.bufferSubData(i.ARRAY_BUFFER,0,e.arrayBuffer)}enableAttributes(e,i){for(let r=0;r<this.attributes.length;r++){let a=i.getAttributeLocation(e,this.attributes[r].name);-1!==a&&e.enableVertexAttribArray(a)}}setVertexAttribPointers(e,i,r){for(let a=0;a<this.attributes.length;a++){let n=this.attributes[a],o=i.getAttributeLocation(e,n.name);-1!==o&&e.vertexAttribPointer(o,n.components,e[an[n.type]],!1,this.itemSize,n.offset+this.itemSize*(r||0))}}setVertexAttribDivisor(e,i,r){for(let a=0;a<this.attributes.length;a++){let n=i.getAttributeLocation(e,this.attributes[a].name);-1!==n&&this.instanceCount&&this.instanceCount>0&&e.vertexAttribDivisor(n,r)}}destroy(){this.buffer&&(this.context.gl.deleteBuffer(this.buffer),delete this.buffer)}}class as{constructor(e,i,r,a,n){this.context=e,this.width=i,this.height=r;let o=this.framebuffer=e.gl.createFramebuffer();
98a&&(this.colorAttachment=new r_(e,o)),n&&(this.depthAttachmentType=n,this.depthAttachment="renderbuffer"===n?new rg(e,o):new ry(e,o))}destroy(){let e=this.context.gl;if(this.colorAttachment){let i=this.colorAttachment.get();i&&e.deleteTexture(i)}if(this.depthAttachment&&this.depthAttachmentType)if("renderbuffer"===this.depthAttachmentType){let i=this.depthAttachment.get();i&&e.deleteRenderbuffer(i)}else{let i=this.depthAttachment.get();i&&e.deleteTexture(i)}e.deleteFramebuffer(this.framebuffer)}}class al{constructor(e,i){this.gl=e,this.clearColor=new iW(this),this.clearDepth=new iX(this),this.clearStencil=new iY(this),this.colorMask=new iK(this),this.depthMask=new iJ(this),this.stencilMask=new iQ(this),this.stencilFunc=new i0(this),this.stencilOp=new i1(this),this.stencilTest=new i2(this),this.depthRange=new i3(this),this.depthTest=new i5(this),this.depthFunc=new i4(this),this.blend=new i6(this),this.blendFunc=new i8(this),this.blendColor=new i9(this),this.blendEquation=new i7(this),this.cullFace=new re(this),this.cullFaceSide=new rt(this),this.frontFace=new ri(this),this.program=new rr(this),this.activeTexture=new ra(this),this.viewport=new rn(this),this.bindFramebuffer=new ro(this),this.bindRenderbuffer=new rs(this),this.bindTexture=new rl(this),this.bindVertexBuffer=new rh(this),this.bindElementBuffer=new ru(this),this.bindVertexArrayOES=new rc(this),this.pixelStoreUnpack=new rd(this),this.pixelStoreUnpackPremultiplyAlpha=new rp(this),this.pixelStoreUnpackFlipY=new rf(this),this.options=i?Object.assign({},i):{},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=i&&!!i.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.maxPointSize=e.getParameter(e.ALIASED_POINT_SIZE_RANGE)[1]}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,i,r){return new aa(this,e,i,r)}createVertexBuffer(e,i,r,a,n){return new ao(this,e,i,r,a,n)}createRenderbuffer(e,i,r){let a=this.gl,n=a.createRenderbuffer();return this.bindRenderbuffer.set(n),a.renderbufferStorage(a.RENDERBUFFER,e,i,r),this.bindRenderbuffer.set(null),n}createFramebuffer(e,i,r,a){return new as(this,e,i,r,a)}clear({color:e,depth:i,stencil:r,colorMask:a}){let n=this.gl,o=0;e&&(o|=n.COLOR_BUFFER_BIT,this.clearColor.set(e.toNonPremultipliedRenderColor(null)),this.colorMask.set(a||[!0,!0,!0,!0])),void 0!==i&&(o|=n.DEPTH_BUFFER_BIT,this.depthRange.set([0,1]),this.clearDepth.set(i),this.depthMask.set(!0)),void 0!==r&&(o|=n.STENCIL_BUFFER_BIT,this.clearStencil.set(r),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(i){e.by(i.blendFunction,t1.Replace)?this.blend.set(!1):(this.blend.set(!0),this.blendFunc.set(i.blendFunction),this.blendColor.set(i.blendColor),i.blendEquation?this.blendEquation.set(i.blendEquation):this.blendEquation.setDefault()),this.colorMask.set(i.mask)}unbindVAO(){this.bindVertexArrayOES.set(null)}}function ah(i,r,n,o,s,l,h){let u=i.context,c=u.gl,d=i.transform,p=[e.aF(d.center.lng),e.aJ(d.center.lat)],f=n.layout.get("symbol-placement"),m=n.layout.get("text-variable-anchor"),_="map"===n.layout.get("icon-rotation-alignment"),g="map"===n.layout.get("text-rotation-alignment"),y="point"!==f,x=[],v=0,b=0;for(let a=0;a<o.length;a++){let u=o[a],f=r.getTile(u),w=f.getBucket(n);if(!w)continue;let T=w.getProjection().createInversionMatrix(d,u.canonical),S=[],E=function(e,i,r){if(i.projection.name===r.projection.name)return e.projMatrix;let a=r.clone();return a.setProjection(i.projection),t_(a,i.getProjection(),e)}(u,w,d),I=!h&&_&&y,A=h&&g&&y,C=m&&w.hasTextData(),M=w.hasIconTextFit()&&C&&w.hasIconData(),P=I||A||h&&C||M,z="globe"===w.projection.name,R=z?e.aj(d.zoom):0;z&&(S.push("PROJECTION_GLOBE_VIEW"),P&&S.push("PROJECTED_POS_ON_VIEWPORT"));let D=i.getOrCreateProgram("collisionBox",{defines:S}),L=E;0===s[0]&&0===s[1]||(L=i.translatePosMatrix(E,f,s,l));let O=h?w.textCollisionBox:w.iconCollisionBox,F=w.collisionCircleArray;
98if(F.length>0){let i=e.bC(),r=L;e.cO(i,w.placementInvProjMatrix,d.glCoordMatrix),e.cO(i,i,w.placementViewportMatrix),x.push({circleArray:F,circleOffset:b,transform:r,invTransform:i,projection:w.getProjection()}),v+=F.length/4,b=v}if(!O)continue;i.terrain&&i.terrain.setupElevationDraw(f,D);let k=z?[u.canonical.x,u.canonical.y,1<<u.canonical.z]:[0,0,0];D.draw(i,c.LINES,t2.disabled,t3.disabled,i.colorModeForRenderPass(),t5.disabled,rY(L,T,d,R,p,f,k,w.getProjection()),n.id,O.layoutVertexBuffer,O.indexBuffer,O.segments,null,d.zoom,null,[O.collisionVertexBuffer,O.collisionVertexBufferExt])}if(!h||!x.length)return;let w=i.getOrCreateProgram("collisionCircle"),T=new e.dW;T.resize(4*v),T._trim();let S=0;for(let e of x)for(let i=0;i<e.circleArray.length/4;i++){let r=4*i,a=e.circleArray[r+0],n=e.circleArray[r+1],o=e.circleArray[r+2],s=e.circleArray[r+3];T.emplace(S++,a,n,o,s,0),T.emplace(S++,a,n,o,s,1),T.emplace(S++,a,n,o,s,2),T.emplace(S++,a,n,o,s,3)}(!a||a.length<2*v)&&(a=function(i){let r=2*i,a=new e.b1;a.resize(r),a._trim();for(let e=0;e<r;e++){let i=6*e;a.uint16[i+0]=4*e+0,a.uint16[i+1]=4*e+1,a.uint16[i+2]=4*e+2,a.uint16[i+3]=4*e+2,a.uint16[i+4]=4*e+3,a.uint16[i+5]=4*e+0}return a}(v));let E=u.createIndexBuffer(a,!0),I=u.createVertexBuffer(T,e.dX.members,!0);for(let r of x){let a={u_matrix:r.transform,u_inv_matrix:r.invTransform,u_camera_to_center_distance:d.getCameraToCenterDistance(r.projection),u_viewport_size:[d.width,d.height]};w.draw(i,c.TRIANGLES,t2.disabled,t3.disabled,i.colorModeForRenderPass(),t5.disabled,a,n.id,I,E,e.bg.simpleSegment(0,2*r.circleOffset,r.circleArray.length,r.circleArray.length/2),null,d.zoom)}I.destroy(),E.destroy()}let au=e.bC();function ac(i){let r=i._camera.getWorldToCamera(i.worldSize,1),a=e.aB([],r,i.globeMatrix);e.bl(a,a);let n=[0,0,0],o=[0,1,0,0];return e.aC(o,o,a),n[0]=o[0],n[1]=o[1],n[2]=o[2],e.aw(n,n),n}function ad(i,r,a,n,o,s,l={}){let h=a.paint.get("icon-translate"),u=a.paint.get("text-translate"),c=a.paint.get("icon-translate-anchor"),d=a.paint.get("text-translate-anchor"),p=a.layout.get("icon-rotation-alignment"),f=a.layout.get("text-rotation-alignment"),m=a.layout.get("icon-pitch-alignment"),_=a.layout.get("text-pitch-alignment"),g=a.layout.get("icon-keep-upright"),y=a.layout.get("text-keep-upright"),x=a.paint.get("icon-color-saturation"),v=a.paint.get("icon-color-contrast"),b=a.paint.get("icon-color-brightness-min"),w=a.paint.get("icon-color-brightness-max"),T="sea"===a.layout.get("symbol-elevation-reference"),S="none"===a.layout.get("icon-image-use-theme"),E=i.context,I=E.gl,A=i.transform,C="map"===p,M="map"===f,P="map"===m,z="map"===_,R=void 0!==a.layout.get("symbol-sort-key").constantOr(1),D=!1,L=i.depthModeForSublayer(0,t2.ReadOnly),O=new t2(i.context.gl.LEQUAL,t2.ReadOnly,i.depthRangeFor3D),F=[e.aF(A.center.lng),e.aJ(A.center.lat)],k=a.layout.get("text-variable-anchor"),B="globe"===A.projection.name,N=[],V=[0,-1,0];for(let o of n){let n=r.getTile(o),s=n.getBucket(a);if(!s||"mercator"===s.projection.name&&B||s.fullyClipped)continue;let p="globe"===s.projection.name,f=p?e.aj(A.zoom):0,m=tg(o,s.getProjection(),A),_=A.calculatePixelsToTileUnitsMatrix(n),U=k&&s.hasTextData(),j=s.hasIconTextFit()&&U&&s.hasIconData(),G=s.getProjection().createInversionMatrix(A,o.canonical),q=(1<<n.tileID.canonical.z)*e.al/i.transform.worldSize,$=e=>{let r=[0,0,0];if(e){let e=i.style.directionalLight,a=i.style.ambientLight;e&&a&&(r=iu(i.style,e,a))}return r},H=e=>{A.depthOcclusionForSymbolsAndCircles&&(a.hasOcclusionOpacityProperties||i.terrain)&&(e.push("DEPTH_D24"),e.push("DEPTH_OCCLUSION"))},Z=r=>{a.lut&&!S&&(a.lut.texture||(a.lut.texture=new e.dY(i.context,a.lut.image,[a.lut.image.height,a.lut.image.height,a.lut.image.height],E.gl.RGBA8)),E.activeTexture.set(E.gl.TEXTURE0+10),a.lut.texture&&a.lut.texture.bind(E.gl.LINEAR,E.gl.CLAMP_TO_EDGE),r.push("APPLY_LUT_ON_GPU"))},W=()=>{let r=C&&"point"!==a.layout.get("symbol-placement"),l=[];H(l),Z(l);let u=r||j,d="road"===s.elevationType,y=i.shadowRenderer,S=d&&P&&!!y&&y.enabled,E=$(S),M=d&&P&&!i.terrain?O:L,z=a.paint.get("icon-image-cross-fade");i.terrainRenderModeElevated()&&P&&l.push("PITCH_WITH_MAP_TERRAIN"),p&&(l.push("PROJECTION_GLOBE_VIEW"),u&&l.push("PROJECTED_POS_ON_VIEWPORT")),z>0&&s.hasAnySecondaryIcon&&l.push("ICON_TRANSITION"),!s.icon.zOffsetVertexBuffer||d&&i.terrain||l.push("Z_OFFSET"),0===x&&0===v&&0===b&&1===w||l.push("COLOR_ADJUSTMENT"),s.sdfIcons&&l.push("RENDER_SDF"),S&&l.push("RENDER_SHADOWS","DEPTH_TEXTURE","NORMAL_OFFSET"),d&&P&&!i.terrain&&s.icon.orientationVertexBuffer&&l.push("ELEVATED_ROADS");let R=s.icon.programConfigurations.get(a.id),D=i.getOrCreateProgram("symbol",{c
98onfig:R,defines:l}),k=n.imageAtlasTexture?n.imageAtlasTexture.size:[0,0],N=s.iconSizeData,U=e.bK(N,A.zoom),W=P||!A.isOrthographic,X=tb(m,n.tileID.canonical,P,C,A,s.getProjection(),_),Y=tT(m,n.tileID.canonical,P,C,A,s.getProjection(),_),K=i.translatePosMatrix(Y,n,h,c,!0),J=i.translatePosMatrix(m,n,h,c),Q=u?au:X,ee=C&&!P&&!r,et=V;(B||A.mercatorFromTransition)&&!C&&(et=ac(A));let ei=p?et:V,er=a.getColorAdjustmentMatrix(x,v,b,w),ea=r8(N.kind,U,ee,P,i,J,Q,K,T,!1,k,[0,0],0,o,f,F,G,ei,s.getProjection(),E,q,er,z,null),en=n.imageAtlasTexture?n.imageAtlasTexture:null,eo=1!==a.layout.get("icon-size").constantOr(0)||s.iconsNeedLinear,es=s.sdfIcons||i.options.rotating||i.options.zooming||eo||W?I.LINEAR:I.NEAREST,el=s.sdfIcons&&0!==a.paint.get("icon-halo-width").constantOr(1),eh=i.terrain&&P&&r?e.bl(e.bC(),X):au;if(r&&s.icon){let e=A.elevation,r=e?e.getAtTileOffsetFunc(o,A.center.lat,A.worldSize,s.getProjection()):null,a=tw(m,n.tileID.canonical,P,C,A,s.getProjection(),_);tI(s,m,i,!1,a,Y,P,g,r,o)}return{program:D,buffers:s.icon,uniformValues:ea,atlasTexture:en,atlasTextureIcon:null,atlasInterpolation:es,atlasInterpolationIcon:null,isSDF:s.sdfIcons,hasHalo:el,depthMode:M,tile:n,renderWithShadows:S,labelPlaneMatrixInv:eh}},X=()=>{let r=M&&"point"!==a.layout.get("symbol-placement"),l=[],h=r||k||j,c="road"===s.elevationType,g=i.shadowRenderer,x=c&&z&&!!g&&g.enabled,v=$(x),b=c&&z&&!i.terrain?O:L;i.terrainRenderModeElevated()&&z&&l.push("PITCH_WITH_MAP_TERRAIN"),p&&(l.push("PROJECTION_GLOBE_VIEW"),h&&l.push("PROJECTED_POS_ON_VIEWPORT")),!s.text.zOffsetVertexBuffer||c&&i.terrain||l.push("Z_OFFSET"),s.iconsInText&&l.push("RENDER_TEXT_AND_SYMBOL"),l.push("RENDER_SDF"),x&&l.push("RENDER_SHADOWS","DEPTH_TEXTURE","NORMAL_OFFSET"),c&&z&&!i.terrain&&s.text.orientationVertexBuffer&&l.push("ELEVATED_ROADS"),H(l);let w=s.text.programConfigurations.get(a.id),S=i.getOrCreateProgram("symbol",{config:w,defines:l}),E,C=[0,0],P=null,R=s.textSizeData;s.iconsInText&&(C=n.imageAtlasTexture?n.imageAtlasTexture.size:[0,0],P=n.imageAtlasTexture?n.imageAtlasTexture:null,E=z||!A.isOrthographic||i.options.rotating||i.options.zooming||"composite"===R.kind||"camera"===R.kind?I.LINEAR:I.NEAREST);let D=n.glyphAtlasTexture?n.glyphAtlasTexture.size:[0,0],N=a.layout.get("text-size-scale-range"),U=e.aA(i.scaleFactor,N[0],N[1]),Z=e.bK(R,A.zoom,U),W=tb(m,n.tileID.canonical,z,M,A,s.getProjection(),_),X=tT(m,n.tileID.canonical,z,M,A,s.getProjection(),_),Y=i.translatePosMatrix(X,n,u,d,!0),K=i.translatePosMatrix(m,n,u,d),J=h?au:W,Q=M&&!z&&!r,ee=V;(B||A.mercatorFromTransition)&&!M&&(ee=ac(A));let et=r8(R.kind,Z,Q,z,i,K,J,Y,T,!0,D,C,0,o,f,F,G,p?ee:V,s.getProjection(),v,q,null,null,U),ei=n.glyphAtlasTexture?n.glyphAtlasTexture:null,er=I.LINEAR,ea=0!==a.paint.get("text-halo-width").constantOr(1),en=i.terrain&&z&&r?e.bl(e.bC(),W):au;if(r&&s.text){let e=A.elevation,r=e?e.getAtTileOffsetFunc(o,A.center.lat,A.worldSize,s.getProjection()):null,a=tw(m,n.tileID.canonical,z,M,A,s.getProjection(),_);tI(s,m,i,!0,a,X,z,y,r,o)}return{program:S,buffers:s.text,uniformValues:et,atlasTexture:ei,atlasTextureIcon:P,atlasInterpolation:er,atlasInterpolationIcon:E,isSDF:!0,hasHalo:ea,depthMode:b,tile:n,renderWithShadows:x,labelPlaneMatrixInv:en}},Y=s.icon.segments.get().length,K=s.text.segments.get().length,J=Y&&!l.onlyText?W():null,Q=K&&!l.onlyIcons?X():null,ee=a.paint.get("icon-opacity").constantOr(1),et=a.paint.get("text-opacity").constantOr(1);if(R&&s.canOverlap){D=!0;let i=ee&&!l.onlyText?s.icon.segments.get():[],r=et&&!l.onlyIcons?s.text.segments.get():[];for(let r of i)N.push({segments:new e.bg([r]),sortKey:r.sortKey,state:J});for(let i of r)N.push({segments:new e.bg([i]),sortKey:i.sortKey,state:Q})}else l.onlyText||N.push({segments:ee?s.icon.segments:new e.bg([]),sortKey:0,state:J}),l.onlyIcons||N.push({segments:et?s.text.segments:new e.bg([]),sortKey:0,state:Q})}for(let e of(D&&N.sort((e,i)=>e.sortKey-i.sortKey),N)){let r=e.state;if(r)if(i.terrain?i.terrain.setupElevationDraw(r.tile,r.program,{useDepthForOcclusion:A.depthOcclusionForSymbolsAndCircles,labelPlaneMatrixInv:r.labelPlaneMatrixInv}):i.setupDepthForOcclusion(A.depthOcclusionForSymbolsAndCircles,r.program),E.activeTexture.set(I.TEXTURE0),r.atlasTexture&&r.atlasTexture.bind(r.atlasInterpolation,I.CLAMP_TO_EDGE,!0),r.atlasTextureIcon&&(E.activeTexture.set(I.TEXTURE1),r.atlasTextureIcon&&r.atlasTextureIcon.bind(r.atlasInterpolationIcon,I.CLAMP_TO_EDGE,!0)),r.renderWithShadows&&i.shadowRenderer.setupShadows(r.tile.tileID.toUnwrapped(),r.program,"vector-tile"),i.uploadCommonLightUniforms(i.context,r.program),r.hasHalo){let n=r.uniformValues;n.u_is_halo=1,ap(r.buffers,e.segments,a,i,r.program,r.depthMode,o,s,n,2),n.u_is_halo=0}else{if(r.isSDF){let n=r.uniformValues;r.hasHalo&&(n.u_is_halo=1,ap(r.buffers,e.segments,a,i,r.program,r.depthMode,o,s,n,1)),n.u_is_halo=0}ap(r.buffers,e.segments,a,i,r.program,r.depthMode,o,s,r.uniformValues,1)}}}function ap(e,i,r,a,n,o,s,l,h,u){let c=[e.dynamicLayoutVertexBuffer,e.opacityVertexBuffer,e.iconTransitioningVertexBuffer,e.globeExtVertexBuffer,e.zOffsetVertexBuffer,e.orientationVertexBuffer];n.draw(a,a.context.gl.TRIANGLES,o,s,l,t5.disabled,h,r.id,e.layoutVertexBuffer,e.indexBuffer,i,r.paint,a.transform.zoom,e.programConfigurations.get(r.id),c,u)}function af(i,r){let a=1<<i.canonical.z,n=(r.x*a-i.canonical.x-i.wrap*a)*e.al,o=(r.y*a-i.canonical.y)*e.al,s=e.e5(r.z,r.y);return e.d4(n,o,s)}function am(i,r,a,n,o){var s;let l;if(!a.layout||"none"===a.layout.get("fill-elevation-reference"))return;let h=i.context.gl,u=new t2(i.context.gl.LEQUAL,t2.ReadWrite,i.depthRangeFor3D),c=new t2(i.context.gl.GREATER,t2.ReadWrite,i.depthRangeFor3D),d=(s=i.transform,l=.01,s.isOrthographic&&(l=e.ak(1e-4,l,e.c$(s.pitch>=15?1:s.pitch/15))),2*l),p=i.transform.getFreeCameraOptions().position,f="elevatedStructuresDepthReconstruct",m=i.getOrCreateProgram(f,{defines:["DEPTH_RECONSTRUCTION"]}),_=i.getOrCreateProgram(f);for(let e of n){let n,s,l,f,g=r.getTile(e),y=g.getBucket(a);if(!y)continue;let x=y.elevatedStructures;if(!x)continue;
98let v=y.elevationBufferData.heightRange,b=af(e.toUnwrapped(),p),w=i.translatePosMatrix(e.projMatrix,g,a.paint.get("fill-translate"),a.paint.get("fill-translate-anchor"));if("initialize"===o){if(!v||v.min>=1||0===x.depthSegments.segments[0].primitiveLength)continue;n=rH(w,b,d,1,0),s=u,l=x.depthSegments,f=m}else if("reset"===o){if(!v||v.min>=0||0===x.maskSegments.segments[0].primitiveLength)continue;n=rH(w,b,0,0,1),s=c,l=x.maskSegments,f=m}else if("geometry"===o){if(0===x.depthSegments.segments[0].primitiveLength)continue;n=rH(w,b,d,1,0),s=u,l=x.depthSegments,f=_}f.draw(i,h.TRIANGLES,s,t3.disabled,t1.disabled,t5.disabled,n,a.id,x.vertexBuffer,x.indexBuffer,l,a.paint,i.transform.zoom)}}function a_(i,r,a){let{painter:n,sourceCache:o,layer:s,coords:l,colorMode:h,elevationType:u,terrainEnabled:c,pass:d}=i,p=n.context.gl,f=s.paint.get("fill-pattern"),m=s.paint.get("fill-pattern-cross-fade"),_=f.constantOr(null),g=u;"road"!==u||r&&!c||(g="none");let y="road"===g,x=i.painter.shadowRenderer,v=y&&!!x&&x.enabled,b=new t2(n.context.gl.LEQUAL,t2.ReadOnly,n.depthRangeFor3D),w=[0,0,0];if(v){let e=n.style.directionalLight,i=n.style.ambientLight;e&&i&&(w=iu(n.style,e,i))}let T=f&&f.constantOr(1),S=(i,d)=>{let f,g,S,E,I;for(let A of(d?(f=T&&!s.getPaintProperty("fill-outline-color")?"fillOutlinePattern":"fillOutline",S=p.LINES):(f=T?"fillPattern":"fill",S=p.TRIANGLES),l)){let l=o.getTile(A);if(T&&!l.patternsLoaded())continue;let C=l.getBucket(s);if(!C)continue;let M=r?C.elevationBufferData:C.bufferData;if(M.isEmpty())continue;n.prepareDrawTile();let P=M.programConfigurations.get(s.id),z=n.isTileAffectedByFog(A),R=[],D=[];y&&(R.push("ELEVATED_ROADS"),D.push(M.elevatedLayoutVertexBuffer)),v&&R.push("RENDER_SHADOWS","DEPTH_TEXTURE","NORMAL_OFFSET"),T&&(n.context.activeTexture.set(p.TEXTURE0),l.imageAtlasTexture&&l.imageAtlasTexture.bind(p.LINEAR,p.CLAMP_TO_EDGE),P.updatePaintBuffers());let L=!1;if(_&&l.imageAtlas){let i=l.imageAtlas,r=e.e0.from(_),a=r.getPrimary().scaleSelf(e.o.devicePixelRatio).toString(),n=r.getSecondary(),o=i.patternPositions.get(a),s=n?i.patternPositions.get(n.scaleSelf(e.o.devicePixelRatio).toString()):null;L=!!o&&!!s,o&&P.setConstantPatternPositions(o,s)}m>0&&(L||P.getPatternTransitionVertexBuffer("fill-pattern"))&&R.push("FILL_PATTERN_TRANSITION");let O=n.getOrCreateProgram(f,{config:P,overrideFog:z,defines:R}),F=n.translatePosMatrix(A.projMatrix,l,s.paint.get("fill-translate"),s.paint.get("fill-translate-anchor"));v&&x.setupShadows(l.tileID.toUnwrapped(),O,"vector-tile");let k=s.paint.get("fill-emissive-strength");if(d){E=M.lineIndexBuffer,I=M.lineSegments;let e=n.terrain&&n.terrain.renderingToTexture?n.terrain.drapeBufferSize:[p.drawingBufferWidth,p.drawingBufferHeight];g="fillOutlinePattern"===f&&T?rq(F,k,n,l,e,w,m):rG(F,k,e,w)}else E=M.indexBuffer,I=M.triangleSegments,g=T?rj(F,k,n,l,w,m):rU(F,k,w);n.uploadCommonUniforms(n.context,O,A.toUnwrapped());let B=i;("road"!==u||c)&&"offset"!==u||(B=b),O.draw(n,S,B,a||n.stencilModeForClipping(A),h,t5.disabled,g,s.id,M.layoutVertexBuffer,E,I,s.paint,n.transform.zoom,P,D)}};n.renderPass===d&&S(n.depthModeForSublayer(1,"opaque"===n.renderPass?t2.ReadWrite:t2.ReadOnly),!1),"none"===g&&"translucent"===n.renderPass&&s.paint.get("fill-antialias")&&S(n.depthModeForSublayer(2*!!s.getPaintProperty("fill-outline-color"),t2.ReadOnly),!0)}function ag(i,r,a,n,o,s,l,h){let u;a.resetLayerRenderingStats(i);let c=i.context,d=c.gl,p=i.transform,f=a.paint.get("fill-extrusion-pattern"),m=a.paint.get("fill-extrusion-pattern-cross-fade"),_=f.constantOr(null),g=f.constantOr(1),y=a.paint.get("fill-extrusion-opacity"),x=i.style.enable3dLights(),v=a.paint.get(x&&!g?"fill-extrusion-ambient-occlusion-wall-radius":"fill-extrusion-ambient-occlusion-radius"),b=[a.paint.get("fill-extrusion-ambient-occlusion-intensity"),v],w=a.layout.get("fill-extrusion-edge-radius"),T=w>0&&!a.paint.get("fill-extrusion-rounded-roof"),S=T?0:w,E="globe"===p.projection.name?e.e8():0,I="globe"===p.projection.name,A=I?e.aj(p.zoom):0,C=[e.aF(p.center.lng),e.aJ(p.center.lat)],M="none"===a.paint.get("fill-extrusion-flood-light-color-use-theme").
98constantOr("default"),P=a.paint.get("fill-extrusion-flood-light-color").toNonPremultipliedRenderColor(M?null:a.lut).toArray01().slice(0,3),z=a.paint.get("fill-extrusion-flood-light-intensity"),R=a.paint.get("fill-extrusion-vertical-scale"),D=0!==a.paint.get("fill-extrusion-line-width").constantOr(1),L=a.paint.get("fill-extrusion-height-alignment"),O=a.paint.get("fill-extrusion-base-alignment"),F=ii(i,a.paint.get("fill-extrusion-cutoff-fade-range")),k=[];I&&k.push("PROJECTION_GLOBE_VIEW"),b[0]>0&&k.push("FAUX_AO"),T&&k.push("ZERO_ROOF_RADIUS"),h&&k.push("HAS_CENTROID"),z>0&&k.push("FLOOD_LIGHT"),F.shouldRenderCutoff&&k.push("RENDER_CUTOFF"),D&&k.push("RENDER_WALL_MODE");let B="shadow"===i.renderPass,N=i.shadowRenderer,V=B&&!!N,U=B?t5.disabled:t5.backCCW;i.shadowRenderer&&(i.shadowRenderer.useNormalOffset=!0);let j=[0,0,0];if(N){let e=i.style.directionalLight,r=i.style.ambientLight;e&&r&&(j=iu(i.style,e,r)),B||(k.push("RENDER_SHADOWS","DEPTH_TEXTURE"),N.useNormalOffset&&k.push("NORMAL_OFFSET")),u=k.concat(["SHADOWS_SINGLE_CASCADE"])}let G=V?"fillExtrusionDepth":g?"fillExtrusionPattern":"fillExtrusion",q=a.getLayerRenderingStats();for(let f of n){let n,x=r.getTile(f),v=x.getBucket(a);if(!v||v.projection.name!==p.projection.name)continue;let w=!1;N&&(w=0===N.getMaxCascadeForTile(f.toUnwrapped()));let T=i.isTileAffectedByFog(f),M=v.programConfigurations.get(a.id),V=!1;if(_&&x.imageAtlas){let i=x.imageAtlas,r=e.e0.from(_),a=r.getPrimary().scaleSelf(e.o.devicePixelRatio).toString(),n=r.getSecondary(),o=i.patternPositions.get(a),s=n?i.patternPositions.get(n.scaleSelf(e.o.devicePixelRatio).toString()):null;V=!!o&&!!s,o&&M.setConstantPatternPositions(o,s)}m>0&&(V||M.getPatternTransitionVertexBuffer("fill-extrusion-pattern"))&&k.push("FILL_EXTRUSION_PATTERN_TRANSITION");let $=i.getOrCreateProgram(G,{config:M,defines:w?u:k,overrideFog:T});if(i.terrain&&i.terrain.setupElevationDraw(x,$,{useMeterToDem:!0}),!v.centroidVertexBuffer){let e=$.getAttributeLocation(d,"a_centroid_pos");-1!==e&&d.vertexAttrib2f(e,0,0)}!B&&N&&N.setupShadows(x.tileID.toUnwrapped(),$,"vector-tile"),g&&(i.context.activeTexture.set(d.TEXTURE0),x.imageAtlasTexture&&x.imageAtlasTexture.bind(d.LINEAR,d.CLAMP_TO_EDGE),M.updatePaintBuffers());let H=a.paint.get("fill-extrusion-vertical-gradient"),Z=1/v.tileToMeter;if(B&&N){if(aT(x.tileID,v.maxHeight,i))continue;n=rN(N.calculateShadowPassMatrixFromTile(x.tileID.toUnwrapped()),S,Z,R,L,O)}else{let e=i.translatePosMatrix(f.expandedProjMatrix,x,a.paint.get("fill-extrusion-translate"),a.paint.get("fill-extrusion-translate-anchor")),r=p.projection.createInversionMatrix(p,f.canonical);n=g?rV(e,i,H,y,b,S,Z,f,x,E,L,O,A,C,r,P,R,m):rB(e,i,H,y,b,S,Z,f,E,L,O,A,C,r,P,R,z,j)}i.uploadCommonUniforms(c,$,f.toUnwrapped(),null,F);let W=v.segments;if("mercator"===p.projection.name&&!B&&!(W=v.getVisibleSegments(x.tileID,i.terrain,i.transform.getFrustum(0))).get().length)continue;if(q)if(B)for(let e of W.get())q.numRenderedVerticesInShadowPass+=e.primitiveLength;else for(let e of W.get())q.numRenderedVerticesInTransparentPass+=e.primitiveLength;let X=[];(i.terrain||h)&&X.push(v.centroidVertexBuffer),I&&X.push(v.layoutVertexExtBuffer),D&&X.push(v.wallVertexBuffer),$.draw(i,c.gl.TRIANGLES,o,s,l,U,n,a.id,v.layoutVertexBuffer,v.indexBuffer,W,a.paint,i.transform.zoom,M,X)}i.shadowRenderer&&(i.shadowRenderer.useNormalOffset=!1)}class ay{constructor(){this.translate=[0,0],this.translateAnchor="map",this.edgeRadius=0,this.cutoffFadeRange=0}}function ax(i,r,a,n,o,s,l,h,u,c,d,p,f,m,_,g,y,x,v,b){let w=r.context,T=w.gl,S=r.transform,E=r.transform.zoom,I=[],A=i.translate,C=i.translateAnchor,M=i.edgeRadius,P=ii(r,i.cutoffFadeRange);"clear"===d?(I.push("CLEAR_SUBPASS"),b&&(I.push("CLEAR_FROM_TEXTURE"),w.activeTexture.set(T.TEXTURE0),b.bind(T.LINEAR,T.CLAMP_TO_EDGE))):"sdf"===d&&I.push("SDF_SUBPASS"),x&&I.push("HAS_CENTROID"),P.shouldRenderCutoff&&I.push("RENDER_CUTOFF");let z=(e,i,a,o,d)=>{let v=i.programConfigurations.get(n.id),T=r.isTileAffectedByFog(e),S=r.getOrCreateProgram("fillExtrusionGroundEffect",{config:v,defines:I,overrideFog:T}),A={u_matrix:o,u_opacity:p,u_ao_pass:+!!c,u_meter_to_tile:d,u_ao:[f,m*d],u_flood_light_intensity:_,u_flood_light_color:g,u_attenuation:y,u_edge_radius:E>=17?0:M*d,u_fb:0,u_fb_size:b?b.size[0]:0,u_dynamic_offset:1},C=[];x&&C.push(i.hiddenByLandmarkVertexBuffer),r.uploadCommonUniforms(w,S,e.toUnwrapped(),null,P),S.draw(r,w.gl.TRIANGLES,s,l,h,u,A,n.id,i.vertexBuffer,i.indexBuffer,a,n.paint,E,v,C)};for(let i of o){let o=a.getTile(i),s=o.getBucket(n);if(!s||s.projection.name!==S.projection.name||!s.groundEffect||s.groundEffect&&!s.groundEffect.hasData())continue;let l=s.groundEffect,h=1/s.tileToMeter;{let e=r.translatePosMatrix(i.projMatrix,o,A,C),a=l.getDefaultSegment();z(i,l,a,e,h)}if(v)for(let s=0;s<4;s++){let l,u,c=e.e6[s](i),d=a.getTile(c);if(!d)continue;let p=d.getBucket(n);if(!p||p.projection.name!==S.projection.name||!p.groundEffect||p.groundEffect&&!p.groundEffect.hasData())continue;let f=p.groundEffect;0===s?(l=[-e.al,0,0],u=1):1===s?(l=[e.al,0,0],u=0):2===s?(l=[0,-e.al,0],u=3):(l=[0,e.al,0],u=2);let m=f.regionSegments[u];if(!m)continue;let _=new Float32Array(16);e.br(_,i.projMatrix,l),z(i,f,m,r.translatePosMatrix(_,o,A,C),h)}}}let av=[1,0,0],ab=[0,1,0],aw=[0,0,1];function aT(i,r,a){let n=a.transform,o=a.shadowRenderer;if(!o)return!0;let s=i.toUnwrapped(),l=n.tileSize*o._cascades[a.currentShadowCascade].scale,h=r;if(n.elevation){let e=n.elevation.getMinMaxForTile(i);e&&(h+=e.max)}let u=[...o.shadowDirection];u[2]=-u[2];let c=o.computeSimplifiedTileShadowVolume(s,h,l,u);if(!c)return!1;let d=[av,ab,aw,u,[u[0],0,u[2]],[0,u[1],u[2]]],p="globe"===n.projection.name,f=n.scaleZoom(l),m=e.cA.fromInvProjectionMatrix(n.invProjMatrix,n.worldSize,f,!p),_=o.getCurrentCascadeFrustum();return 0===m.intersectsPrecise(c.vertices,c.planes,d)||0===_.intersectsPrecise(c.vertices,c.planes,d)}function aS(i){let{painter:r,source:a,layer:n,coords:o}=i,s=i.defines,l=r.context,h="shadow"===r.renderPass,u="light-beam"===r.renderPass,c=r.shadowRenderer,d=e.ec(r.transform.center.lat,r.transform.zoom),p=ii(r,n.paint.get("building-cutoff-fade-range"));for(let f of(p.shouldRenderCutoff&&(s=s.concat("RENDER_CUTOFF")),o)){let o=a.getTile(f),m=o.getBucket(n);if(!m)continue;c&&0===c.getMaxCascadeForTile(f.toUnwrapped())&&(s=s.concat("SHADOWS_SINGLE_CASCADE"));let _=m.programConfigurations.get(n.id),g,y,x,v=r.translatePosMatrix(f.expandedProjMatrix,o,[0,0],"map");if(v=e.cR(e.bC(),v,[1,1,i.verticalScale]),h&&c){if(aT(o.tileID,m.maxHeight*d,r))continue;let a=c.calculateShadowPassMatrixFromTile(o.tileID.toUnwrapped());x=rX(a=e.cR(e.bC(),a,[1,1,i.verticalScale])),g=y=r.getOrCreateProgram("buildingDepth",{config:_,defines:s,overrideFog:!1})}else if(u)g=y=r.getOrCreateProgram("buildingBloom",{config:_,defines:s,overrideFog:!1}),x=rW(v);else{let a=r.transform.calculatePosMatrix(f.toUnwrapped(),r.transform.worldSize);e.cR(a,a,[1,1,i.verticalScale]);let n=e.bC();
98e.cR(n,a,[1,-1,1/d]),e.bl(n,n),e.ed(n,n);let o=r.transform.getFreeCameraOptions().position,l=1<<f.canonical.z;x=rZ(v,n,i.opacity,i.facadeAOIntensity,[((o.x-f.wrap)*l-f.canonical.x)*e.al,(o.y*l-f.canonical.y)*e.al,o.z*l*e.al],m.tileToMeter,i.facadeEmissiveChance),y=r.getOrCreateProgram("building",{config:_,defines:s,overrideFog:!1});let h=s.concat(["BUILDING_FAUX_FACADE","HAS_ATTRIBUTE_a_faux_facade_color_emissive"]);g=r.getOrCreateProgram("building",{config:_,defines:h,overrideFog:!1}),c&&(c.setupShadowsFromMatrix(a,y,!0),c.setupShadowsFromMatrix(a,g,!0))}let b=(e,a)=>{if(u){let o=e.entranceBloom;a.draw(r,l.gl.TRIANGLES,i.depthMode,t3.disabled,i.blendMode,t5.disabled,x,n.id,o.layoutVertexBuffer,o.indexBuffer,o.segmentsBucket,n.paint,r.transform.zoom,_,[o.layoutAttenuationBuffer,o.layoutColorBuffer])}else{let o=e.segmentsBucket,s=[e.layoutNormalBuffer,e.layoutCentroidBuffer,e.layoutColorBuffer];e.layoutFacadePaintBuffer&&(s=s.concat([e.layoutFacadeDataBuffer,e.layoutFacadeVerticalRangeBuffer,e.layoutFacadePaintBuffer])),a.draw(r,l.gl.TRIANGLES,i.depthMode,t3.disabled,i.blendMode,h?t5.disabled:t5.backCW,x,n.id,e.layoutVertexBuffer,e.indexBuffer,o,n.paint,r.transform.zoom,_,s)}};r.uploadCommonUniforms(l,y,f.toUnwrapped(),null,p),m.buildingWithoutFacade&&b(m.buildingWithoutFacade,y),g!==y&&r.uploadCommonUniforms(l,g,f.toUnwrapped(),null,p),m.buildingWithFacade&&b(m.buildingWithFacade,g)}}function aE(i){return[i[0]*e.ee,i[1]*e.ee,i[2]*e.ee,0]}function aI(i,r,a,n,o,s,l,h,u){let c,d,p,f,m,_,g,y,x=n.getSource(),v=a.globeSharedBuffers;if(!v||(r&&(c=n.getTile(r)),x instanceof e.aS?(d=x.texture,p=e.dG(0,0,a.transform)):c&&r&&(d=c.texture,p=e.dG(r.canonical.z,r.canonical.x,a.transform)),!d||!p))return;i||(p=e.cR(e.bC(),p,[1,-1,1]));let b=a.context,w=b.gl,T="nearest"===o.paint.get("raster-resampling")?w.NEAREST:w.LINEAR,S=a.colorModeForDrapableLayerRenderPass(s),E=l.defines;E.push("GLOBE_POLES");let I=new t2(w.LEQUAL,t2.ReadWrite,a.depthRangeFor3D),A=Float32Array.from(a.transform.expandedFarZProjMatrix),C=Float32Array.from(e.bk(e.dF(new e.cC(0,0,0))));a.terrain&&a.terrain.prepareDrawTile(),b.activeTexture.set(w.TEXTURE0),d.bind(T,w.CLAMP_TO_EDGE),b.activeTexture.set(w.TEXTURE1),d.bind(T,w.CLAMP_TO_EDGE),"useMipmap"in d&&b.extTextureFilterAnisotropic&&a.transform.pitch>20&&w.texParameterf(w.TEXTURE_2D,b.extTextureFilterAnisotropic.TEXTURE_MAX_ANISOTROPY_EXT,b.extTextureFilterAnisotropicMax);let[M,P,z,R]=r?v.getPoleBuffers(r.canonical.z,!1):v.getPoleBuffers(0,!0),D=o.paint.get("raster-elevation");i?(f=M,a.renderDefaultNorthPole=0!==D):(f=P,a.renderDefaultSouthPole=0!==D);let L=aE(l.mix),O=(m=p,_=e.aj(a.transform.zoom),g=l.offset,y=l.range,r2(A,C,m,new Float32Array(16),new Float32Array(9),[0,0],_,[0,0],[0,0,0,0],1,{opacity:1,mix:0},o,[0,0],D,2,L,g,y,1,0,s)),F=a.getOrCreateProgram("raster",{defines:E});a.uploadCommonUniforms(b,F,null),F.draw(a,w.TRIANGLES,I,u,S,h,O,o.id,f,z,R)}var aA=e.ef([{name:"a_index",type:"Int16",components:1}]);class aC{constructor(i,r,a,n){let o={width:a[0],height:a[1],data:null},s=i.gl;this.targetColorTexture=new e.T(i,o,s.RGBA8,{useMipmap:!1}),this.backgroundColorTexture=new e.T(i,o,s.RGBA8,{useMipmap:!1}),this.context=i,this.updateParticleTexture(r,n),this.lastInvalidatedAt=0}updateParticleTexture(i,r){if(this.particleTextureDimension===r.width)return;(this.particleTexture0||this.particleTexture1||this.particleIndexBuffer||this.particleSegment)&&(this.particleTexture0.destroy(),this.particleTexture1.destroy(),this.particleIndexBuffer.destroy(),this.particleSegment.destroy());let a=this.context.gl,n=r.width*r.height;this.particleTexture0=new e.T(this.context,r,a.RGBA8,{premultiply:!1,useMipmap:!1}),this.particleTexture1=new e.T(this.context,r,a.RGBA8,{premultiply:!1,useMipmap:!1});let o=new e.eg;o.reserve(n);for(let e=0;e<n;e++)o.emplaceBack(e);this.particleIndexBuffer=this.context.createVertexBuffer(o,aA.members,!0),this.particleSegment=e.bg.simpleSegment(0,0,this.particleIndexBuffer.length,0),this.particleTextureDimension=r.width}update(i){return!(this.lastInvalidatedAt<i&&(this.lastInvalidatedAt=e.o.now(),1))}destroy(){this.targetColorTexture.destroy(),this.backgroundColorTexture.destroy(),this.particleIndexBuffer.destroy(),this.particleTexture0.destroy(),this.particleTexture1.destroy(),this.particleSegment.destroy()}}let aM=new e.ao(1,0,0,1),aP=new e.ao(0,1,0,1),az=new e.ao(0,0,1,1),aR=new e.ao(1,0,1,1),aD=new e.ao(0,1,1,1);function aL(i,r,a,n,o,s){for(let l=0;l<a.length;l++)if(o){let o=new e.ao(.8*n.r,.8*n.g,.8*n.b,1);aO(i,r,a[l],n,-1,-1,s),aO(i,r,a[l],n,-1,1,s),aO(i,r,a[l],n,1,1,s),aO(i,r,a[l],n,1,-1,s),aO(i,r,a[l],o,0,0,s)}else aO(i,r,a[l],n,0,0,s)}function aO(i,r,a,n,o,s,l){let h=i.context,u=i.transform,c=h.gl,d="globe"===u.projection.name,p=e.bz(a.projMatrix);if(d&&e.aj(u.zoom)>0){let i=e.bj(a.canonical,u),r=e.ei(i);p=e.aB(new Float32Array(16),u.globeMatrix,r),e.aB(p,u.projMatrix,p)}let f=e.bC();f[12]+=2*o/(e.o.devicePixelRatio*u.width),f[13]+=2*s/(e.o.devicePixelRatio*u.height),e.aB(p,f,p);let m=i.getOrCreateProgram("debug",{defines:d?["PROJECTION_GLOBE_VIEW"]:[]}),_=r.getTileByID(a.key);i.terrain&&i.terrain.setupElevationDraw(_,m);let g=t2.disabled,y=t3.disabled,x=i.colorModeForRenderPass(),v="$debug";h.activeTexture.set(c.TEXTURE0),i.emptyTexture.bind(c.LINEAR,c.CLAMP_TO_EDGE),d?_._makeGlobeTileDebugBuffers(i.context,u):_._makeDebugTileBoundsBuffers(i.context,u.projection);let b=_._tileDebugBuffer||i.debugBuffer,w=_._tileDebugIndexBuffer||i.debugIndexBuffer,T=_._tileDebugSegments||i.debugSegments;if(m.draw(i,c.LINE_STRIP,g,y,x,t5.disabled,rK(p,n.toPremultipliedRenderColor(null)),v,b,w,T,null,null,null,[_._globeTileDebugBorderBuffer]),l){let e=_.latestRawTileData,r=Math.floor((e&&e.byteLength||0)/1024),n=a.canonical.toString();a.overscaledZ!==a.canonical.z&&(n+=` => ${a.overscaledZ}`),n+=` ${_.state}`,function(e,i){e.initDebugOverlayCanvas();let r=e.debugOverlayCanvas,a=e.context.gl,n=e.debugOverlayCanvas.getContext("2d");n.clearRect(0,0,r.width,r.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(i,5,5),n.strokeText(i,5,5),e.debugOverlayTexture.update(r),e.debugOverlayTexture.bind(a.LINEAR,a.CLAMP_TO_EDGE)}(i,n+=` ${r}kb`)}
98let S=512/Math.min(r.getTile(a).tileSize,512)*(a.overscaledZ/u.zoom)*.5,E=_._tileDebugTextBuffer||i.debugBuffer,I=_._tileDebugTextIndexBuffer||i.quadTriangleIndexBuffer,A=_._tileDebugTextSegments||i.debugSegments;m.draw(i,c.TRIANGLES,g,y,t1.alphaBlended,t5.disabled,rK(p,e.ao.transparent.toPremultipliedRenderColor(null),S),v,E,I,A,null,null,null,[_._globeTileDebugTextBuffer])}function aF(e,i,r,a){aB(e,0,i+r/2,e.transform.width,r,a)}function ak(e,i,r,a){aB(e,i-r/2,0,r,e.transform.height,a)}function aB(i,r,a,n,o,s){let l=i.context,h=l.gl;h.enable(h.SCISSOR_TEST),h.scissor(r*e.o.devicePixelRatio,a*e.o.devicePixelRatio,n*e.o.devicePixelRatio,o*e.o.devicePixelRatio),l.clear({color:s}),h.disable(h.SCISSOR_TEST)}let{members:aN}=e.ef([{name:"a_pos_3f",components:3,type:"Float32"}]);function aV(e,i,r,a){e.emplaceBack(i,r,a)}class aU{constructor(i){this.vertexArray=new e.ej,this.indices=new e.b1,aV(this.vertexArray,-1,-1,1),aV(this.vertexArray,1,-1,1),aV(this.vertexArray,-1,1,1),aV(this.vertexArray,1,1,1),aV(this.vertexArray,-1,-1,-1),aV(this.vertexArray,1,-1,-1),aV(this.vertexArray,-1,1,-1),aV(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=i.createVertexBuffer(this.vertexArray,aN),this.indexBuffer=i.createIndexBuffer(this.indices),this.segment=e.bg.simpleSegment(0,0,36,12)}}function aj(i,r,a,n,o,s){let l,h,u,c=i.context.gl,d=r.paint.get("sky-atmosphere-color"),p=r.paint.get("sky-atmosphere-halo-color"),f=r.paint.get("sky-atmosphere-sun-intensity"),m=(l=e.el(e.dL(),n),h=d.toPremultipliedRenderColor(null),u=p.toPremultipliedRenderColor(null),{u_matrix_3f:l,u_sun_direction:o,u_sun_intensity:f,u_color_tint_r:[h.r,h.g,h.b,h.a],u_color_tint_m:[u.r,u.g,u.b,u.a],u_luminance:5e-5});c.framebufferTexture2D(c.FRAMEBUFFER,c.COLOR_ATTACHMENT0,c.TEXTURE_CUBE_MAP_POSITIVE_X+s,r.skyboxTexture,0),a.draw(i,c.TRIANGLES,t2.disabled,t3.disabled,t1.unblended,t5.frontCW,m,"skyboxCapture",r.skyboxGeometry.vertexBuffer,r.skyboxGeometry.indexBuffer,r.skyboxGeometry.segment)}let aG=e.ef([{type:"Float32",name:"a_pos",components:3},{type:"Float32",name:"a_uv",components:2}]);class aq{constructor(i){let r=new e.em;r.emplaceBack(-1,1,1,0,0),r.emplaceBack(1,1,1,1,0),r.emplaceBack(1,-1,1,1,1),r.emplaceBack(-1,-1,1,0,1);let a=new e.b1;a.emplaceBack(0,1,2),a.emplaceBack(2,3,0),this.vertexBuffer=i.createVertexBuffer(r,aG.members),this.indexBuffer=i.createIndexBuffer(a),this.segments=e.bg.simpleSegment(0,0,4,2)}destroy(){this.vertexBuffer.destroy(),this.indexBuffer.destroy(),this.segments.destroy()}}let a$=e.ef([{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 aH{constructor(){this.starsCount=16e3,this.sizeMultiplier=.15,this.sizeRange=100,this.intensityRange=200}}class aZ{constructor(i){this.colorModeAlphaBlendedWriteRGB=new t1([1,771,1,771],e.ao.transparent,[!0,!0,!0,!1]),this.colorModeWriteAlpha=new t1([1,0,1,0],e.ao.transparent,[!1,!1,!1,!0]),this.params=new aH,this.updateNeeded=!0,i.tp.registerParameter(this.params,["Stars"],"starsCount",{min:100,max:16e3,step:1},()=>{this.updateNeeded=!0}),i.tp.registerParameter(this.params,["Stars"],"sizeMultiplier",{min:.01,max:2,step:.01}),i.tp.registerParameter(this.params,["Stars"],"sizeRange",{min:0,max:200,step:1},()=>{this.updateNeeded=!0}),i.tp.registerParameter(this.params,["Stars"],"intensityRange",{min:0,max:200,step:1},()=>{this.updateNeeded=!0})}update(i){let r=i.context;if(!this.atmosphereBuffer||this.updateNeeded){this.updateNeeded=!1,this.atmosphereBuffer=new aq(r);let i=this.params.sizeRange,a=this.params.intensityRange,n=function(i){let r=e.eo(30),a=[];for(let n=0;n<i;++n){let i=2*Math.PI*r(),n=Math.acos(1-2*r())-.5*Math.PI;a.push(e.d4(Math.cos(n)*Math.cos(i),Math.cos(n)*Math.sin(i),Math.sin(n)))}return a}(this.params.starsCount),o=e.eo(300),s=new e.en,l=new e.b1,h=0;for(let r=0;r<n.length;++r){let u=e.c4([],n[r],200),c=Math.max(0,1+.01*i*(o()-.5)),d=Math.max(0,1+.01*a*(o()-.5));s.emplaceBack(u[0],u[1],u[2],-1,-1,c,d),s.emplaceBack(u[0],u[1],u[2],1,-1,c,d),s.emplaceBack(u[0],u[1],u[2],1,1,c,d),s.emplaceBack(u[0],u[1],u[2],-1,1,c,d),l.emplaceBack(h+0,h+1,h+2),l.emplaceBack(h+0,h+2,h+3),h+=4}this.starsVx=r.createVertexBuffer(s,a$.members),this.starsIdx=r.createIndexBuffer(l),this.starsSegments=e.bg.simpleSegment(0,0,s.length,l.length)}}destroy(){this.atmosphereBuffer&&this.atmosphereBuffer.destroy(),this.starsVx&&this.starsVx.destroy(),this.starsIdx&&this.starsIdx.destroy()}drawAtmosphereGlow(i,r){let a=i.context,n=a.gl,o=i.transform,s=new t2(n.LEQUAL,t2.ReadOnly,[0,1]),l=e.aj(o.zoom),h=i.style.getLut(r.scope),u="none"===r.properties.get("color-use-theme"),c=r.properties.get("color").toNonPremultipliedRenderColor(u?null:h),d="none"===r.properties.get("high-color-use-theme"),p=r.properties.get("high-color").toNonPremultipliedRenderColor(d?null:h),f="none"===r.properties.get("space-color-use-theme"),m=r.properties.get("space-color").toNonPremultipliedRenderColor(f?null:h),_=e.ep(r.properties.get("horizon-blend"),0,1,5e-4,.25),g=e.dA(i,a,o)&&5e-4===_?o.worldSize/(2*Math.PI*1.025)-1:o.globeRadius,y=i.frameCounter/1e3%1,x=e.ag(o.globeCenterInViewSpace),v=Math.acos(Math.sqrt(Math.pow(x,2)-Math.pow(g,2))/x),b=e=>{let r,h,u,d,f,g="globe"===o.projection.name?["PROJECTION_GLOBE_VIEW","FOG"]:["FOG"];
98e&&g.push("ALPHA_PASS");let x=i.getOrCreateProgram("globeAtmosphere",{defines:g}),b=(r=o.frustumCorners.TL,h=o.frustumCorners.TR,u=o.frustumCorners.BR,d=o.frustumCorners.BL,f=o.frustumCorners.horizon,{u_frustum_tl:r,u_frustum_tr:h,u_frustum_br:u,u_frustum_bl:d,u_horizon:f,u_transition:l,u_fadeout_range:_,u_atmosphere_fog_color:c.toArray01(),u_high_color:p.toArray01(),u_space_color:m.toArray01(),u_temporal_offset:y,u_horizon_angle:v});i.uploadCommonUniforms(a,x);let w=this.atmosphereBuffer;w&&x.draw(i,n.TRIANGLES,s,t3.disabled,e?this.colorModeWriteAlpha:this.colorModeAlphaBlendedWriteRGB,t5.backCW,b,e?"atmosphere_glow_alpha":"atmosphere_glow",w.vertexBuffer,w.indexBuffer,w.segments)};b(!1),b(!0)}drawStars(i,r){let a=e.aA(r.properties.get("star-intensity"),0,1);if(0===a)return;let n=i.context,o=n.gl,s=i.transform,l=i.getOrCreateProgram("stars"),h=e.c6([]);e.c8(h,h,-s._pitch),e.c7(h,h,-s.angle),e.c8(h,h,e.an(s._center.lat)),e.eq(h,h,-e.an(s._center.lng));let u=e.cb(new Float32Array(16),h),c=e.aB([],s.starsProjMatrix,u),d=e.el([],u),p=e.er([],d),f=[0,1,0];e.dN(f,f,p),e.c4(f,f,this.params.sizeMultiplier);let m=[1,0,0];e.dN(m,m,p),e.c4(m,m,this.params.sizeMultiplier);let _={u_matrix:Float32Array.from(c),u_up:f,u_right:m,u_intensity_multiplier:a};i.uploadCommonUniforms(n,l),this.starsVx&&this.starsIdx&&l.draw(i,o.TRIANGLES,t2.disabled,t3.disabled,this.colorModeAlphaBlendedWriteRGB,t5.disabled,_,"atmosphere_stars",this.starsVx,this.starsIdx,this.starsSegments)}}class aW{constructor(){this.visibleTiles=[]}updateBorders(i,r){let a=[],n=[];for(let e of i._getRenderableCoordinates(!1,!0)){let o=i.getTile(e);if(!o.hasData())continue;let s=o.getBucket(r);s&&(s.isEmpty()||(a.push(e.key),n.push({bucket:s,tileID:e.canonical})))}let o=a.length!==this.visibleTiles.length;if(!o){a.sort();for(let e=0;e<a.length;e++)if(a[e]!==this.visibleTiles[e]){o=!0;break}}if(!o)return;let s=new Set;for(let i of(this.visibleTiles=a,n.sort((e,i)=>e.tileID.z-i.tileID.z||e.tileID.x-i.tileID.x||e.tileID.y-i.tileID.y),n)){let r=[],a=[],n=i.bucket;for(let e of n.featuresOnBorder)s.has(e.featureId)?a.push(e.footprintIndex):(s.add(e.featureId),r.push(e.footprintIndex));n.updateFootprintHiddenFlags(r,e.es,!1),n.updateFootprintHiddenFlags(a,e.es,!0)}}}function aX(i,r){let a=[...i],n=r.cameraWorldSizeForFog/r.worldSize,o=e.bA([]);return e.cR(o,o,[n,n,1]),e.aB(a,o,a),e.aB(a,r.worldToFogMatrix,a),a}function aY(i,r,a,n,o){let s=a.material,l=n.context,{baseColorTexture:h,metallicRoughnessTexture:u}=s.pbrMetallicRoughness,{normalTexture:c,occlusionTexture:d,emissionTexture:p}=s;function f(e,r,a){if(e&&(i.push(r),l.activeTexture.set(l.gl.TEXTURE0+a),e.gfxTexture)){let{minFilter:i,magFilter:r,wrapS:a,wrapT:n}=e.sampler;e.gfxTexture.bindExtraParam(i,r,a,n)}}f(h,"HAS_TEXTURE_u_baseColorTexture",5),f(u,"HAS_TEXTURE_u_metallicRoughnessTexture",6),f(c,"HAS_TEXTURE_u_normalTexture",7),f(d,"HAS_TEXTURE_u_occlusionTexture",8),f(p,"HAS_TEXTURE_u_emissionTexture",9),o&&(o.texture||(o.texture=new e.dY(n.context,o.image,[o.image.height,o.image.height,o.image.height],l.gl.RGBA8)),l.activeTexture.set(l.gl.TEXTURE0+10),o.texture&&o.texture.bind(l.gl.LINEAR,l.gl.CLAMP_TO_EDGE),i.push("APPLY_LUT_ON_GPU")),a.texcoordBuffer&&(i.push("HAS_ATTRIBUTE_a_uv_2f"),r.push(a.texcoordBuffer)),a.colorBuffer&&(i.push(12===a.colorBuffer.itemSize?"HAS_ATTRIBUTE_a_color_3f":"HAS_ATTRIBUTE_a_color_4f"),r.push(a.colorBuffer)),a.normalBuffer&&(i.push("HAS_ATTRIBUTE_a_normal_3f"),r.push(a.normalBuffer)),a.pbrBuffer&&(i.push("HAS_ATTRIBUTE_a_pbr"),i.push("HAS_ATTRIBUTE_a_heightBasedEmissiveStrength"),r.push(a.pbrBuffer)),"OPAQUE"!==s.alphaMode&&"MASK"!==s.alphaMode||i.push("UNPREMULT_TEXTURE_IN_SHADER"),s.defined||i.push("DIFFUSE_SHADED");let m=n.shadowRenderer;m&&(i.push("RENDER_SHADOWS","DEPTH_TEXTURE"),m.useNormalOffset&&i.push("NORMAL_OFFSET"))}function aK(i,r,a,n,o,s){let l,h=a.paint.get("model-opacity").constantOr(1),u=r.context,c=new t2(r.context.gl.LEQUAL,t2.ReadWrite,r.depthRangeFor3D),d=r.transform,p=i.mesh,f=p.material,m=f.pbrMetallicRoughness,_=r.style.fog;l="pixels"===r.transform.projection.zAxisUnit?[...i.nodeModelMatrix]:e.aB([],n.zScaleMatrix,i.nodeModelMatrix),e.aB(l,n.negCameraPosMatrix,l);let g=e.bl([],l);e.ed(g,g);
98let y="none"===a.paint.get("model-color-use-theme").constantOr("default"),x=a.paint.get("model-emissive-strength").constantOr(0),v=at(new Float32Array(i.worldViewProjection),new Float32Array(l),new Float32Array(g),null,r,h,m.baseColorFactor,f.emissiveFactor,m.metallicFactor,m.roughnessFactor,f,x,a),b={defines:[]},w=[],T=r.shadowRenderer;T&&(T.useNormalOffset=!1),aY(b.defines,w,p,r,y?null:a.lut);let S=null;if(_){let e=aX(i.nodeModelMatrix,r.transform);if(S=new Float32Array(e),"globe"!==d.projection.name){let i=p.aabb.min,r=p.aabb.max,[a,n]=_.getOpacityForBounds(e,i[0],i[1],r[0],r[1]);b.overrideFog=a>=.05||n>=.05}}let E=ii(r,a.paint.get("model-cutoff-fade-range"));E.shouldRenderCutoff&&b.defines.push("RENDER_CUTOFF");let I=r.getOrCreateProgram("model",b);r.uploadCommonUniforms(u,I,null,S,E),"shadow"!==r.renderPass&&T&&T.setupShadowsFromMatrix(i.nodeModelMatrix,I),I.draw(r,u.gl.TRIANGLES,c,o,s,p.material.doubleSided?t5.disabled:t5.backCCW,v,a.id,p.vertexBuffer,p.indexBuffer,p.segments,a.paint,r.transform.zoom,void 0,w)}function aJ(e,i,r,a){let n=r.shadowRenderer;if(!n)return;let o=n.getShadowPassDepthMode(),s=n.getShadowPassColorMode(),l=ai(n.calculateShadowPassMatrixFromMatrix(i));r.getOrCreateProgram("modelDepth",{defines:r._shadowMapDebug?[]:["DEPTH_TEXTURE"]}).draw(r,r.context.gl.TRIANGLES,o,t3.disabled,s,t5.backCCW,l,a.id,e.vertexBuffer,e.indexBuffer,e.segments,a.paint,r.transform.zoom,void 0,void 0)}let aQ={shadowUniformsInitialized:!1,useSingleShadowCascade:!1,tileMatrix:new Float64Array(16),shadowTileMatrix:new Float32Array(16),aabb:new e.d8([0,0,0],[e.al,e.al,0])},a0=[1,-1,1];class a1{}class a2{constructor(){this._storage=new Map}getLinesFromTrianglesBuffer(i,r,a){{let e=this._storage.get(r.id);if(e)return e.lastUsedFrameIdx=i,e.buf}let n=a.gl,o=n.getBufferParameter(n.ELEMENT_ARRAY_BUFFER,n.BUFFER_SIZE),s=new ArrayBuffer(o),l=new Int16Array(s);n.getBufferSubData(n.ELEMENT_ARRAY_BUFFER,0,new Int16Array(s));let h=new e.eA;for(let e=0;e<o/2;e+=3){let i=l[e],r=l[e+1],a=l[e+2];h.emplaceBack(i,r),h.emplaceBack(r,a),h.emplaceBack(a,i)}let u=a.bindVertexArrayOES.current,c=new a1;return c.buf=new aa(a,h),c.lastUsedFrameIdx=i,this._storage.set(r.id,c),a.bindVertexArrayOES.set(u),c.buf}update(e){for(let[i,r]of this._storage)e-r.lastUsedFrameIdx>30&&(r.buf.destroy(),this._storage.delete(i))}destroy(){for(let[e,i]of this._storage)i.buf.destroy(),this._storage.delete(e)}}class a3{constructor(e){this.occluderSize=30,this.depthOffset=-1e-4,e.registerParameter(this,["Occlusion"],"occluderSize",{min:1,max:100,step:1}),e.registerParameter(this,["Occlusion"],"depthOffset",{min:-.05,max:0,step:1e-5})}}let a5=e.ef([{type:"Float32",name:"a_pos_3f",components:3},{type:"Float32",name:"a_uv",components:2},{type:"Float32",name:"a_rainParticleData",components:4}]);class a4{registerParameter(){}registerButton(){}registerBinding(){}refreshUI(){}}class a6{constructor(e,i){this.revealStart=11,this.revealRange=2,e.registerParameter(this,[...i,"Reveal"],"revealStart",{min:0,max:17,step:.05}
98),e.registerParameter(this,[...i,"Reveal"],"revealRange",{min:.1,max:5.1,step:.05})}}let a8=e.ef([{type:"Float32",name:"a_pos_2f",components:2}]);class a9{destroy(){this.vignetteVx&&this.vignetteVx.destroy(),this.vignetteIdx&&this.vignetteIdx.destroy()}draw(i,r){var a;let n=i.getOrCreateProgram("vignette");if(!this.vignetteVx||!this.vignetteIdx){let r=new e.eB,a=new e.b1;r.emplaceBack(-1,-1),r.emplaceBack(1,-1),r.emplaceBack(1,1),r.emplaceBack(-1,1),a.emplaceBack(0,1,2),a.emplaceBack(0,2,3),this.vignetteVx=i.context.createVertexBuffer(r,a8.members),this.vignetteIdx=i.context.createIndexBuffer(a)}let o=e.bg.simpleSegment(0,0,4,6);if(this.vignetteVx&&this.vignetteIdx){i.uploadCommonUniforms(i.context,n);let e={u_vignetteShape:(a={vignetteShape:[r.start,r.range,Math.pow(10,r.fadePower)],vignetteColor:[r.color.r,r.color.g,r.color.b,r.color.a*r.strength]}).vignetteShape,u_vignetteColor:a.vignetteColor};n.draw(i,i.context.gl.TRIANGLES,t2.disabled,t3.disabled,t1.alphaBlended,t5.disabled,e,"vignette",this.vignetteVx,this.vignetteIdx,o)}}}class a7{constructor(){this._accumulatedOffsetX=0,this._accumulatedOffsetY=0,this._accumulatedElevation=0}update(i,r){let a=i.getFreeCameraOptions().position,n=a.toAltitude(),o=a.toLngLat(),s=e.an(o.lng),l=e.an(o.lat),h=i.pixelsPerMeter/r,u=s*e.eD,c=e.eD*Math.log(Math.tan(Math.PI/4+l/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{let e=-this._offsetYPrev+c,i=-this._elevationPrev+n;this._accumulatedOffsetX+=(-this._offsetXPrev+u)*h,this._accumulatedOffsetY+=e*h,this._accumulatedElevation+=i*h,this._offsetXPrev=u,this._offsetYPrev=c,this._elevationPrev=n}}getPosition(){return[this._accumulatedOffsetX,this._accumulatedOffsetY,this._accumulatedElevation]}}function ne(e,i){return[-(e[0]-Math.floor(e[0]/i)*i),-(e[1]-Math.floor(e[1]/i)*i),-(e[2]-Math.floor(e[2]/i)*i)]}function nt(i){let r=e.eo(0x134104da55e),a=[];for(let n=0;n<i;++n){let i=2*r()-1,n=2*r()-1,o=2*r()-1;a.push(e.d4(i,n,o))}return a}function ni(i,r,a,n,o){let s=e.aA((o-a)/(n-a),0,1);return(1-s)*i+s*r}class nr{constructor(e){this._movement=new a7,this._accumulatedTimeFromStart=0,this._prevTime=Date.now()/1e3,this._vignette=new a9,this._ppmScaleFactor=e}destroy(){this.particlesVx&&this.particlesVx.destroy(),this.particlesIdx&&this.particlesIdx.destroy(),this._vignette&&this._vignette.destroy()}updateOnRender(i,r){let a=i.transform;this._movement.update(a,this._ppmScaleFactor);let n=a.starsProjMatrix,o=e.c6([]);e.c8(o,o,e.an(90)-a._pitch),e.c7(o,o,-a.angle);let s=e.cb(new Float32Array(16),o),l=e.eC(1,0,0,0,0,0,1,0,0,-1,0,0,0,0,0,1),h=e.ed([],l),u=e.aB([],h,s),c=Date.now()/1e3;return this._accumulatedTimeFromStart+=(c-this._prevTime)*r,this._prevTime=c,{projectionMatrix:n,modelviewMatrix:u}}}class na extends nr{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 a6(e.tp,["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(i){let r=i.context;if(!this.particlesVx){let i=nt(this.particlesCount),a=new e.eE,n=new e.b1,o=0,s=e.eo(0x134104da55e);for(let e=0;e<i.length;++e){let r=i[e],l=[2*s()-1,s(),s(),s()];a.emplaceBack(r[0],r[1],r[2],-1,-1,...l),a.emplaceBack(r[0],r[1],r[2],1,-1,...l),a.emplaceBack(r[0],r[1],r[2],1,1,...l),a.emplaceBack(r[0],r[1],r[2],-1,1,...l),n.emplaceBack(o+0,o+1,o+2),n.emplaceBack(o+0,o+2,o+3),o+=4}this.particlesVx=r.createVertexBuffer(a,a5.members),this.particlesIdx=r.createIndexBuffer(n)}}draw(i){if(!this._params.overrideStyleParameters&&!i.style.rain)return;let r=this._params.overrideStyleParameters?this._revealParams:{revealStart:0,revealRange:.01},a=i.transform.zoom;if(r.revealStart>a)return;let n=ni(0,1,r.revealStart,r.revealStart+r.revealRange,a);if(!this.particlesVx||!this.particlesIdx)return;let o=structuredClone(this._params),s=[-o.direction.x,o.direction.y,-100];e.aw(s,s);
98let l=structuredClone(this._vignetteParams);l.strength*=n,o.overrideStyleParameters||(o.intensity=i.style.rain.state.density,o.timeFactor=i.style.rain.state.intensity,o.color=structuredClone(i.style.rain.state.color),s=structuredClone(i.style.rain.state.direction),o.screenThinning.intensity=i.style.rain.state.centerThinning,o.dropletSizeX=i.style.rain.state.dropletSize[0],o.dropletSizeYScale=i.style.rain.state.dropletSize[1]/i.style.rain.state.dropletSize[0],o.distortionStrength=100*i.style.rain.state.distortionStrength,l.strength=1,l.color=structuredClone(i.style.rain.state.vignetteColor));let h=this.updateOnRender(i,o.timeFactor),u=i.context,c=u.gl,d=i.transform;this.screenTexture&&this.screenTexture.size[0]===i.width&&this.screenTexture.size[1]===i.height||(this.screenTexture=new e.T(u,{width:i.width,height:i.height,data:null},c.RGBA8)),o.distortionStrength>0&&(u.activeTexture.set(c.TEXTURE0),this.screenTexture.bind(c.LINEAR,c.CLAMP_TO_EDGE),c.copyTexSubImage2D(c.TEXTURE_2D,0,0,0,0,0,i.width,i.height));let p=i.getOrCreateProgram("rainParticle");i.uploadCommonUniforms(u,p),u.activeTexture.set(c.TEXTURE0),this.screenTexture.bind(c.LINEAR,c.CLAMP_TO_EDGE);let f=[o.color.r,o.color.g,o.color.b,o.color.a],m=(r,a)=>{var n;let l=ne(this._movement.getPosition(),r),u=o.dropletSizeX,m=o.dropletSizeX*o.dropletSizeYScale,_=i.width/2,g=i.height/2,y=ni(0,o.screenThinning.start,0,1,o.screenThinning.intensity),x=ni(.001,o.screenThinning.range,0,1,o.screenThinning.intensity),v=ni(0,o.screenThinning.particleOffset,0,1,o.screenThinning.intensity),b=(n={modelview:h.modelviewMatrix,projection:h.projectionMatrix,time:this._accumulatedTimeFromStart,camPos:l,velocityConeAperture:o.velocityConeAperture,velocity:o.velocity,boxSize:r,rainDropletSize:[u,m],distortionStrength:o.distortionStrength,rainDirection:s,color:f,screenSize:[d.width,d.height],thinningCenterPos:[_,g],thinningShape:[y,x,Math.pow(10,o.screenThinning.fadePower)],thinningAffectedRatio:o.screenThinning.affectedRatio,thinningParticleOffset:v,shapeDirectionalPower:o.shapeDirPower,shapeNormalPower:o.shapeNormalPower,mode:+!a},{u_modelview:Float32Array.from(n.modelview),u_projection:Float32Array.from(n.projection),u_time:n.time,u_cam_pos:n.camPos,u_texScreen:0,u_velocityConeAperture:n.velocityConeAperture,u_velocity:n.velocity,u_boxSize:n.boxSize,u_rainDropletSize:n.rainDropletSize,u_distortionStrength:n.distortionStrength,u_rainDirection:n.rainDirection,u_color:n.color,u_screenSize:n.screenSize,u_thinningCenterPos:n.thinningCenterPos,u_thinningShape:n.thinningShape,u_thinningAffectedRatio:n.thinningAffectedRatio,u_thinningParticleOffset:n.thinningParticleOffset,u_shapeDirectionalPower:n.shapeDirectionalPower,u_shapeNormalPower:n.shapeNormalPower,u_mode:n.mode}),w=Math.round(o.intensity*this.particlesCount),T=e.bg.simpleSegment(0,0,4*w,2*w);p.draw(i,c.TRIANGLES,t2.disabled,t3.disabled,t1.alphaBlended,t5.disabled,b,"rain_particles",this.particlesVx,this.particlesIdx,T)};o.distortionStrength>0&&m(o.boxSize,!0),m(o.boxSize,!1),this._vignette.draw(i,l)}}let nn=e.ef([{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 no extends nr{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 a6(e.tp,["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(i){let r=i.context;if(!this.particlesVx){let i=nt(this.particlesCount),a=new e.eF,n=new e.b1,o=0,s=e.eo(0x134104da55e);for(let e=0;e<i.length;++e){let r=i[e],l=s(),h=s(),u=s(),c=[e/i.length,l,h,u],d=[s(),s()];a.emplaceBack(r[0],r[1],r[2],-1,-1,...c,...d),a.emplaceBack(r[0],r[1],r[2],1,-1,...c,...d),a.emplaceBack(r[0],r[1],r[2],1,1,...c,...d),a.emplaceBack(r[0],r[1],r[2],-1,1,...c,...d),n.emplaceBack(o+0,o+1,o+2),n.emplaceBack(o+0,o+2,o+3),o+=4}this.particlesVx=r.createVertexBuffer(a,nn.members),this.particlesIdx=r.createIndexBuffer(n)}}draw(i){if(!this._params.overrideStyleParameters&&!i.style.snow)return;let r=structuredClone(this._params),a=[-r.direction.x,r.direction.y,-100];e.aw(a,a);
98let n=structuredClone(this._vignetteParams),o=r.overrideStyleParameters?this._revealParams:{revealStart:0,revealRange:.01},s=i.transform.zoom;if(o.revealStart>s)return;let l=ni(0,1,o.revealStart,o.revealStart+o.revealRange,s);n.strength*=l,r.overrideStyleParameters||(r.intensity=i.style.snow.state.density,r.timeFactor=i.style.snow.state.intensity,r.color=structuredClone(i.style.snow.state.color),a=structuredClone(i.style.snow.state.direction),r.screenThinning.intensity=i.style.snow.state.centerThinning,r.billboardSize=2.79*i.style.snow.state.flakeSize,n.strength=1,n.color=structuredClone(i.style.snow.state.vignetteColor));let h=this.updateOnRender(i,r.timeFactor);if(!this.particlesVx||!this.particlesIdx)return;let u=i.context,c=u.gl,d=i.transform,p=i.getOrCreateProgram("snowParticle");i.uploadCommonUniforms(u,p),((r,n,o)=>{var s;let l=ne(this._movement.getPosition(),r),u=d.width/2,f=d.height/2,m=ni(0,o.screenThinning.start,0,1,o.screenThinning.intensity),_=ni(.001,o.screenThinning.range,0,1,o.screenThinning.intensity),g=ni(0,o.screenThinning.particleOffset,0,1,o.screenThinning.intensity),y=(s={modelview:h.modelviewMatrix,projection:h.projectionMatrix,time:this._accumulatedTimeFromStart,camPos:l,velocityConeAperture:o.velocityConeAperture,velocity:o.velocity,horizontalOscillationRadius:o.horizontalOscillationRadius,horizontalOscillationRate:o.horizontalOscillationRate,boxSize:r,billboardSize:+o.billboardSize,simpleShapeParameters:[o.shapeFadeStart,o.shapeFadePower],screenSize:[d.width,d.height],thinningCenterPos:[u,f],thinningShape:[m,_,Math.pow(10,o.screenThinning.fadePower)],thinningAffectedRatio:o.screenThinning.affectedRatio,thinningParticleOffset:g,color:[o.color.r,o.color.g,o.color.b,o.color.a],direction:a},{u_modelview:Float32Array.from(s.modelview),u_projection:Float32Array.from(s.projection),u_time:s.time,u_cam_pos:s.camPos,u_velocityConeAperture:s.velocityConeAperture,u_velocity:s.velocity,u_horizontalOscillationRadius:s.horizontalOscillationRadius,u_horizontalOscillationRate:s.horizontalOscillationRate,u_boxSize:s.boxSize,u_billboardSize:s.billboardSize,u_simpleShapeParameters:s.simpleShapeParameters,u_screenSize:s.screenSize,u_thinningCenterPos:s.thinningCenterPos,u_thinningShape:s.thinningShape,u_thinningAffectedRatio:s.thinningAffectedRatio,u_thinningParticleOffset:s.thinningParticleOffset,u_particleColor:s.color,u_direction:s.direction}),x=Math.round(o.intensity*this.particlesCount),v=e.bg.simpleSegment(0,0,4*x,2*x);this.particlesVx&&this.particlesIdx&&p.draw(i,c.TRIANGLES,t2.disabled,t3.disabled,t1.alphaBlended,t5.disabled,y,"snow_particles",this.particlesVx,this.particlesIdx,v)})(r.boxSize,0,r),this._vignette.draw(i,n)}}let ns={symbol:function(i,r,a,n,o){if("translucent"!==i.renderPass)return;let s=t3.disabled,l=i.colorModeForRenderPass(),h=a.layout.get("text-variable-anchor"),u=a.layout.get("text-size-scale-range"),c=e.aA(i.scaleFactor,u[0],u[1]);h&&function(i,r,a,n,o,s,l,h){let u=r.transform,c="map"===o,d="map"===s;for(let r of i){let i=n.getTile(r),o=i.getBucket(a);if(!o||!o.text||!o.text.segments.get().length)continue;let s=e.bK(o.textSizeData,u.zoom,h),p=tg(r,o.getProjection(),u),f=u.calculatePixelsToTileUnitsMatrix(i),m=tb(p,i.tileID.canonical,d,c,u,o.getProjection(),f),_=o.hasIconTextFit()&&o.hasIconData();s&&function(i,r,a,n,o,s,l,h,u,c){let d=i.text.placedSymbolArray,p=i.text.dynamicLayoutVertexArray,f=i.icon.dynamicLayoutVertexArray,m={},_=i.getProjection(),g=tg(l,_,o),y=o.elevation,x=_.upVectorScale(l.canonical,o.center.lat,o.worldSize).metersToTile;p.clear();for(let f=0;f<d.length;f++){let v=d.get(f),{tileAnchorX:b,tileAnchorY:w,numGlyphs:T}=v,S=v.hidden||!v.crossTileID||i.allowVerticalPlacement&&!v.placedOrientation?null:n[v.crossTileID];if(S){let n=0,d=0,f=0;if(y){let e=y?y.getAtTileOffset(l,b,w):0,[i,r,a]=_.upVector(l.canonical,b,w);n=e*i*x,d=e*r*x,f=e*a*x}let[E,I,A,C]=tS(v.projectedAnchorX+n,v.projectedAnchorY+d,v.projectedAnchorZ+f,a?g:s),M=tE(o.getCameraToCenterDistance(_),C),P=e.bM(i.textSizeData,u,v)*M/e.bX;a&&(P*=i.tilePixelRatio/h);let z=function({width:i,height:r,anchor:a,textOffset:n,textScale:o},s){let{horizontalAlign:l,verticalAlign:h}=e.c0(a),u=e.c1(a,n);return new e.P((-(l-.5)*i/o+u[0])*s,(-(h-.5)*r/o+u[1])*s)}(S,P);a?({x:E,y:I,z:A}=_.projectTilePoint(b+z.x,w+z.y,l.canonical),[E,I,A]=tS(E+n,I+d,A+f,s)):(r&&z._rotate(-o.angle),E+=z.x,I+=z.y,A=0);let R=i.allowVerticalPlacement&&v.placedOrientation===e.bL.vertical?Math.PI/2:0;for(let i=0;i<T;i++)e.bO(p,E,I,A,R);c&&v.associatedIconIndex>=0&&(m[v.associatedIconIndex]={x:E,y:I,z:A,angle:R})}else tD(T,p)}if(c){f.clear();let r=i.icon.placedSymbolArray;for(let i=0;i<r.length;i++){let a=r.get(i),{numGlyphs:n}=a,o=m[i];if(a.hidden||!o)tD(n,f);else{let{x:i,y:r,z:a,angle:s}=o;for(let o=0;o<n;o++)e.bO(f,i,r,a,s)}}i.icon.dynamicLayoutVertexBuffer.updateData(f)}i.text.dynamicLayoutVertexBuffer.updateData(p)}
98(o,c,d,l,u,m,r,Math.pow(2,u.zoom-i.tileID.overscaledZ),s,_)}}(n,i,a,r,a.layout.get("text-rotation-alignment"),a.layout.get("text-pitch-alignment"),o,c);let d=0!==a.paint.get("icon-opacity").constantOr(1),p=0!==a.paint.get("text-opacity").constantOr(1);void 0!==a.layout.get("symbol-sort-key").constantOr(1)&&(d||p)?ad(i,r,a,n,s,l):(d&&ad(i,r,a,n,s,l,{onlyIcons:!0}),p&&ad(i,r,a,n,s,l,{onlyText:!0})),r.map.showCollisionBoxes&&(ah(i,r,a,n,a.paint.get("text-translate"),a.paint.get("text-translate-anchor"),!0),ah(i,r,a,n,a.paint.get("icon-translate"),a.paint.get("icon-translate-anchor"),!1))},circle:function(i,r,a,n){if("translucent"!==i.renderPass)return;let o=a.paint.get("circle-opacity"),s=a.paint.get("circle-stroke-width"),l=a.paint.get("circle-stroke-opacity"),h=void 0!==a.layout.get("circle-sort-key").constantOr(1),u=a.paint.get("circle-emissive-strength");if(0===o.constantOr(1)&&(0===s.constantOr(1)||0===l.constantOr(1)))return;let c=i.context,d=c.gl,p=i.transform,f=!(!i.terrain||!i.terrain.enabled),m=a.layout.get("circle-elevation-reference"),_=i.depthModeForSublayer(0,t2.ReadOnly),g=new t2(i.context.gl.LEQUAL,t2.ReadOnly,i.depthRangeFor3D),y="none"===m||f?_:g,x=t3.disabled,v=i.colorModeForDrapableLayerRenderPass(u),b="globe"===p.projection.name,w=[e.aF(p.center.lng),e.aJ(p.center.lat)],T=[];for(let o=0;o<n.length;o++){let s=n[o],l=r.getTile(s),u=l.getBucket(a);if(!u||u.projection.name!==p.projection.name)continue;let c=u.programConfigurations.get(a.id),d=u.layoutVertexBuffer,f=u.globeExtVertexBuffer,m=u.indexBuffer,_=e.dZ(a),g=[f],y=i.isTileAffectedByFog(s);b&&_.push("PROJECTION_GLOBE_VIEW"),_.push("DEPTH_D24"),i.terrain&&p.depthOcclusionForSymbolsAndCircles&&_.push("DEPTH_OCCLUSION"),u.hasElevation&&!i.terrain&&(_.push("ELEVATED_ROADS"),g.push(u.elevatedLayoutVertexBuffer));let x=i.getOrCreateProgram("circle",{config:c,defines:_,overrideFog:y}),v=p.projection.createInversionMatrix(p,s.canonical),S={programConfiguration:c,program:x,layoutVertexBuffer:d,dynamicBuffers:g,indexBuffer:m,uniformValues:e.d_(i,s,l,v,w,a),tile:l};if(h)for(let i of u.segments.get())T.push({segments:new e.bg([i]),sortKey:i.sortKey,state:S});else T.push({segments:u.segments,sortKey:0,state:S})}h&&T.sort((e,i)=>e.sortKey-i.sortKey);let S={useDepthForOcclusion:p.depthOcclusionForSymbolsAndCircles};for(let e of T){let{programConfiguration:r,program:n,layoutVertexBuffer:o,dynamicBuffers:s,indexBuffer:l,uniformValues:h,tile:u}=e.state,f=e.segments;i.terrain&&i.terrain.setupElevationDraw(u,n,S),i.uploadCommonUniforms(c,n,u.tileID.toUnwrapped()),n.draw(i,d.TRIANGLES,y,x,v,t5.disabled,h,a.id,o,l,f,a.paint,p.zoom,r,s)}},heatmap:function(i,r,a,n){if(0!==a.paint.get("heatmap-opacity"))if("offscreen"===i.renderPass){let o=i.context,s=o.gl,l=t3.disabled,h=new t1([s.ONE,s.ONE,s.ONE,s.ONE],e.ao.transparent,[!0,!0,!0,!0]);!function(e,i,r,a){let n=e.gl,o=i.width*a,s=i.height*a;e.activeTexture.set(n.TEXTURE1),e.viewport.set([0,0,o,s]);let l=r.heatmapFbo;if(!l||l&&(l.width!==o||l.height!==s)){l&&l.destroy();let i=n.createTexture();n.bindTexture(n.TEXTURE_2D,i),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.L
98INEAR),n.texParameteri(n.TEXTURE_2D,n.TEXTURE_MAG_FILTER,n.LINEAR),l=r.heatmapFbo=e.createFramebuffer(o,s,!0,null),function(e,i,r,a,n,o){let 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),a.colorAttachment.set(r)}(e,0,i,l,o,s)}else n.bindTexture(n.TEXTURE_2D,l.colorAttachment.get()),e.bindFramebuffer.set(l.framebuffer)}(o,i,a,"globe"===i.transform.projection.name?.5:.25),o.clear({color:e.ao.transparent});let u=i.transform,c="globe"===u.projection.name,d=c?["PROJECTION_GLOBE_VIEW"]:[],p=c?t5.frontCCW:t5.disabled,f=[e.aF(u.center.lng),e.aJ(u.center.lat)];for(let e=0;e<n.length;e++){let m=n[e];if(r.hasRenderableParent(m))continue;let _=r.getTile(m),g=_.getBucket(a);if(!g||g.projection.name!==u.projection.name)continue;let y=i.isTileAffectedByFog(m),x=g.programConfigurations.get(a.id),v=i.getOrCreateProgram("heatmap",{config:x,defines:d,overrideFog:y}),{zoom:b}=i.transform;i.terrain&&i.terrain.setupElevationDraw(_,v),i.uploadCommonUniforms(o,v,m.toUnwrapped());let w=u.projection.createInversionMatrix(u,m.canonical);v.draw(i,s.TRIANGLES,t2.disabled,l,h,p,rQ(i,m,_,w,f,b,a.paint.get("heatmap-intensity")),a.id,g.layoutVertexBuffer,g.indexBuffer,g.segments,a.paint,i.transform.zoom,x,c?[g.globeExtVertexBuffer]:null)}o.viewport.set([0,0,i.width,i.height])}else"translucent"===i.renderPass&&(i.context.setColorMode(i.colorModeForRenderPass()),function(i,r){let a=i.context,n=a.gl,o=r.heatmapFbo;if(!o)return;a.activeTexture.set(n.TEXTURE0),n.bindTexture(n.TEXTURE_2D,o.colorAttachment.get()),a.activeTexture.set(n.TEXTURE1);let s=r.colorRampTexture;s||(s=r.colorRampTexture=new e.T(a,r.colorRamp,n.RGBA8)),s.bind(n.LINEAR,n.CLAMP_TO_EDGE),i.getOrCreateProgram("heatmapTexture").draw(i,n.TRIANGLES,t2.disabled,t3.disabled,i.colorModeForRenderPass(),t5.disabled,{u_image:0,u_color_ramp:1,u_opacity:r.paint.get("heatmap-opacity")},r.id,i.viewportBuffer,i.quadTriangleIndexBuffer,i.viewportSegments,r.paint,i.transform.zoom)}(i,a))},line:function(i,r,a,n){let o;if("translucent"!==i.renderPass)return;let s=a.paint.get("line-opacity"),l=a.paint.get("line-width");if(0===s.constantOr(1)||0===l.constantOr(1))return;let h=a.paint.get("line-emissive-strength"),u=a.paint.get("line-occlusion-opacity"),c=a.layout.get("line-elevation-reference"),d="meters"===a.layout.get("line-width-unit"),p="sea"===c,f=!(!i.terrain||!i.terrain.enabled),m=i.context,_=m.gl;if(a.hasElevatedBuckets&&"globe"===i.transform.projection.name)return;let g=a.layout.get("line-cross-slope"),y=i.colorModeForDrapableLayerRenderPass(h),x=i.terrain&&i.terrain.renderingToTexture,v=x?1:e.o.devicePixelRatio,b=a.paint.get("line-dasharray"),w=b.constantOr(1),T=a.layout.get("line-cap"),S=b.constantOr(null),E=T.constantOr(null),I=a.paint.get("line-pattern"),A=I.constantOr(1),C=a.paint.get("line-pattern-cross-fade"),M=I.constantOr(null),P=a.paint.get("line-opacity").constantOr(1),z=!A&&1!==P||i.depthOcclusion&&u>0&&u<1,R=a.paint.get("line-gradient"),D=A?"linePattern":"line",L=e.d$(a);if(x&&i.terrain&&i.terrain.clipOrMaskOverlapStencilType()&&(z=!1),0!==u&&i.depthOcclusion){let i=a.paint._values["line-opacity"];i&&i.value&&"constant"===i.value.kind?o=i.value:e.w(`Occlusion opacity for layer ${a.id} is supported only when line-opacity isn't data-driven.`)}"constant"!==l.value.kind&&!1===l.value.isLineProgressConstant&&L.push("VARIABLE_LINE_WIDTH");let O=(n,s,l,h,c,f)=>{for(let g of n){let n=r.getTile(g);if(A&&!n.patternsLoaded())continue;let b=n.getBucket(a);if(!b||"none"!==b.elevationType&&!c||"none"===b.elevationType&&c)continue;i.prepareDrawTile();let T=[...s],I=i.shadowRenderer,L="road"===b.elevationType&&!!I&&I.enabled,O=[0,0,0];if(L){let e=i.style.directionalLight,r=i.style.ambientLight;e&&r&&(O=iu(i.style,e,r)),T.push("RENDER_SHADOWS","DEPTH_TEXTURE","NORMAL_OFFSET")}let F=b.programConfigurations.get(a.id),k=!1;if(M&&n.imageAtlas){let i=e.e0.from(M),r=i.getPrimary().scaleSelf(v).toString(),a=n.imageAtlas.patternPositions.get(r),o=i.getSecondary(),s=o?n.imageAtlas.patternPositions.get(o.scaleSelf(v).toString()):null;
98k=!!a&&!!s,a&&F.setConstantPatternPositions(a,s)}C>0&&(k||F.getPatternTransitionVertexBuffer("line-pattern"))&&T.push("LINE_PATTERN_TRANSITION");let B=i.isTileAffectedByFog(g),N=i.getOrCreateProgram(D,{config:F,defines:T,overrideFog:B});if(!A&&S&&E&&n.lineAtlas){let e=n.lineAtlas.getDash(S,E);e&&F.setConstantPatternPositions(e)}L&&I.setupShadows(n.tileID.toUnwrapped(),N,"vector-tile");let[V,U]=a.paint.get("line-trim-offset");("round"===E||"square"===E)&&V!==U&&(0===V&&(V-=1),1===U&&(U+=1));let j=x?g.projMatrix:null,G=d?1/b.tileToMeter/e.ay(n,1,i.transform.zoom):1,q=d?1/b.tileToMeter/e.ay(n,1,Math.floor(i.transform.zoom)):1,$=A?e.e1(i,n,a,j,v,G,q,[V,U],O,C):e.e2(i,n,a,j,b.lineClipsArray.length,v,G,q,[V,U],O);if(R){let n=b.gradients[a.id],o=n.texture;if(a.gradientVersion!==n.version){let s=256;if(a.stepInterpolant){let a=r.getSource().maxzoom,n=g.canonical.z===a?Math.ceil(1<<i.transform.maxZoom-g.canonical.z):1;s=e.aA(e.e3(b.maxLineLength/e.al*1024*n),256,m.maxTextureSize)}n.gradient=e.e4({expression:a.gradientExpression(),evaluationKey:"lineProgress",resolution:s,image:n.gradient||void 0,clips:b.lineClipsArray}),n.texture?n.texture.update(n.gradient):n.texture=new e.T(m,n.gradient,_.RGBA8),n.version=a.gradientVersion,o=n.texture}m.activeTexture.set(_.TEXTURE1),o.bind(a.stepInterpolant?_.NEAREST:_.LINEAR,_.CLAMP_TO_EDGE)}w&&(m.activeTexture.set(_.TEXTURE0),n.lineAtlasTexture&&n.lineAtlasTexture.bind(_.LINEAR,_.REPEAT),F.updatePaintBuffers()),A&&(m.activeTexture.set(_.TEXTURE0),n.imageAtlasTexture&&n.imageAtlasTexture.bind(_.LINEAR,_.CLAMP_TO_EDGE),F.updatePaintBuffers()),c&&!p&&i.terrain.setupElevationDraw(n,N),i.uploadCommonUniforms(m,N,g.toUnwrapped());let H=e=>{null!=o&&(o.value=P*u),N.draw(i,_.TRIANGLES,l,e,y,t5.disabled,$,a.id,b.layoutVertexBuffer,b.indexBuffer,b.segments,a.paint,i.transform.zoom,F,[b.layoutVertexBuffer2,b.patternVertexBuffer,b.zOffsetVertexBuffer]),null!=o&&(o.value=P)};if(z&&!c){let e=i.stencilModeForClipping(g).ref;0===e&&x&&m.clear({stencil:0});let r={func:_.EQUAL,mask:255};$.u_alpha_discard_threshold=.8,H(new t3(r,e,255,_.KEEP,_.KEEP,_.INVERT)),$.u_alpha_discard_threshold=0,H(new t3(r,e,255,_.KEEP,_.KEEP,_.KEEP))}else $.u_alpha_discard_threshold=z&&c&&f?.8:0,H(c?h:i.stencilModeForClipping(g))}},F=i.depthModeForSublayer(0,t2.ReadOnly),k=new t2(i.depthOcclusion?_.GREATER:_.LEQUAL,t2.ReadOnly,i.depthRangeFor3D);if(a.hasNonElevatedBuckets){let r=!x&&i.terrain;0!==u&&r?e.w(`Occlusion opacity for layer ${a.id} is supported on terrain only if the layer has line-z-offset enabled.`):r?e.w(`Cannot render non-elevated lines in immediate mode when terrain is enabled. Layer: ${a.id}.`):O(n,L,F,t3.disabled,!1,!0)}if(a.hasElevatedBuckets){"hd-road-markup"===c?f||(F=k,L.push("ELEVATED_ROADS")):(L.push("ELEVATED"),F=k,void 0!==g&&L.push(g<1?"CROSS_SLOPE_HORIZONTAL":"CROSS_SLOPE_VERTICAL"),p&&L.push("ELEVATION_REFERENCE_SEA"));let e=z?i.stencilModeFor3D():t3.disabled;i.forceTerrainMode=!0,O(n,L,F,e,!0,!0),z&&O(n,L,F,e,!0,!1),i.forceTerrainMode=!1}z&&(i.resetStencilClippingMasks(),x&&m.clear({stencil:0})),0===u||i.depthOcclusion||x||i.layersWithOcclusionOpacity.push(i.currentLayer)},fill:function(i,r,a,n){let o=a.paint.get("fill-color"),s=a.paint.get("fill-opacity");if(0===s.constantOr(1))return;let l=a.paint.get("fill-emissive-strength"),h=i.colorModeForDrapableLayerRenderPass(l),u=a.paint.get("fill-pattern"),c=i.opaquePassEnabledForLayer()&&!u.constantOr(1)&&1===o.constantOr(e.ao.transparent).a&&1===s.constantOr(0)?"opaque":"translucent",d="none";"none"!==a.layout.get("fill-elevation-reference")?d="road":0!==a.paint.get("fill-z-offset").constantOr(1)&&(d="offset");let p=!(!i.terrain||!i.terrain.enabled),f={painter:i,sourceCache:r,layer:a,coords:n,colorMode:h,elevationType:d,terrainEnabled:p,pass:c};if("shadow"!==i.renderPass)if("offset"!==d){if(a_(f,!1),"road"===d){let e=!p&&"translucent"===i.renderPass;e&&am(i,r,a,n,"geometry"),a_(f,!0,t3.disabled),e&&function(e){let{painter:i,sourceCache:r,layer:a,coords:n,colorMode:o}=e,s=i.context.gl,l=e.painter.shadowRenderer,h=!!l&&l.enabled,u=new t2(i.context.gl.LEQUAL,t2.ReadOnly,i.depthRangeFor3D),c=[0,0,0];if(h){let e=i.style.directionalLight,r=i.style.ambientLight;e&&r&&(c=iu(i.style,e,r))}let d=e=>{for(let d of n){let n,p,f=r.getTile(d),m=f.getBucket(a);if(!m)continue;let _=m.elevatedStructures;if(!_||(e?(n=_.renderableBridgeSegments,p=_.bridgeProgramConfigurations.get(a.id)):(n=_.renderableTunnelSegments,p=_.tunnelProgramConfigurations.get(a.id)),!n||0===n.segments[0].primitiveLength))continue;p.updatePaintBuffers(),i.prepareDrawTile();let g=i.isTileAffectedByFog(d),y=[];h&&y.push("RENDER_SHADOWS","DEPTH_TEXTURE","NORMAL_OFFSET");let x=i.getOrCreateProgram("elevatedStructures",{config:p,overrideFog:g,defines:y}),v=i.translatePosMatrix(d.projMatrix,f,a.paint.get("fill-translate"),a.paint.get("fill-translate-anchor"));h&&l.setupShadows(f.tileID.toUnwrapped(),x,"vector-tile");let b=r$(v,c);i.uploadCommonUniforms(i.context,x,d.toUnwrapped()),x.draw(i,s.TRIANGLES,u,t3.disabled,o,t5.backCCW,b,a.id,_.vertexBuffer,_.indexBuffer,n,a.paint,i.transform.zoom,p,[_.vertexBufferNormal])}};d(!0),d(!1)}(f)}}else a_(f,!1,i.stencilModeFor3D());else i.shadowRenderer&&"road"===d&&!p&&function(e){let{painter:i,sourceCache:r,layer:a,coords:n}=e,o=i.context.gl,s=e.painter.shadowRenderer;for(let e of n){let n=r.getTile(e),l=n.getBucket(a);if(!l)continue;let h=l.elevatedStructures;if(!h||!h.shadowCasterSegments||0===h.shadowCasterSegments.segments[0].primitiveLength)continue;i.prepareDrawTile();let u=l.bufferData.programConfigurations.get(a.id),c=i.isTileAffectedByFog(e),d=i.getOrCreateProgram("elevatedStructuresDepth",{config:u,overrideFog:c}),p=s.calculateShadowPassMatrixFromTile(n.tileID.toUnwrapped());i.uploadCommonUniforms(i.context,d,e.toUnwrapped());let f={u_matrix:p,u_depth_bias:0};d.draw(i,o.TRIANGLES,s.getShadowPassDepthMode(),t3.disabled,s.getShadowPassColorMode(),t5.disabled,f,a.id,h.vertexBuffer,h.indexBuffer,h.shadowCasterSegments,a.paint,i.transform.zoom,u)}}(f)},"fill-extrusion":function(i,r,a,n){let o=a.paint.get("fill-extrusion-opacity"),s=i.context,l=s.gl,h=i.terrain,u=h&&h.renderingToTexture;if(0===o)return;let c=i.conflationActive&&i.style.isLayerClipped(a,r.getSource()),d=i.style.order.indexOf(a.fqid);if(c&&function(e,i,r,a,n){for(let o of a){let a=i.getTile(o).getBucket(r);a&&(a.updateReplacement(o,e.replacementSource,n),a.uploadCentroid(e.context))}}(i,r,a,n,d),h||c)for(let o of n){let n=r.getTile(o).getBucket(a);n&&function(i,r,a,n,o,s,l){0===n.centroidVertexArray.length&&n.createCentroidsBuffer();let h=s?s.findDEMTileFor(a):null;if(!(h&&h.dem||l))return;s&&h&&h.dem&&n.selfDEMTileTimestamp!==h.dem._timestamp&&(n.borderDoneWithNeighborZ=[-1,-1,-1,-1],n.selfDEMTileTimestamp=h.dem._timestamp);let u=i=>new e.P(Math.ceil((i+e.ea)*e.eb),0),c=e=>{let i=r.getSource().minzoom,a=e=>{let i=r.getTileByID(e);if(i&&i.hasData())return i.getBucket(o)};
98for(let r of[0,-1,1]){if(e.overscaledZ+r<i)continue;let n=a(e.calculateScaledKey(e.overscaledZ+r));if(n)return n}},d=[0,0,0],p=(i,r)=>(d[0]=Math.min(i.min.y,r.min.y),d[1]=Math.max(i.max.y,r.max.y),d[2]=e.al-r.min.x>i.max.x?r.min.x-e.al:i.max.x,d),f=(i,r)=>(d[0]=Math.min(i.min.x,r.min.x),d[1]=Math.max(i.max.x,r.max.x),d[2]=e.al-r.min.y>i.max.y?r.min.y-e.al:i.max.y,d),m=[(e,i)=>p(e,i),(e,i)=>p(i,e),(e,i)=>f(e,i),(e,i)=>f(i,e)],_=(i,r,n,o,l,u,c)=>{if(!s)return 0;let d=[[u?n:i,u?i:n,0],[u?n:r,u?r:n,0]],p=c<0?e.al+c:c,f=[u?p:(i+r)/2,u?(i+r)/2:p,0];return 0===n&&c<0||0!==n&&c>0?s.getForTilePoints(l,[f],!0,o):d.push(f),s.getForTilePoints(a,d,!0,h),Math.max(d[0][2],d[1][2],f[2])/s.exaggeration()};for(let i=0;i<4;i++){let r=n.borderFeatureIndices[i];if(0===r.length)continue;let o=e.e6[i](a),h=c(o);if(!(h&&h instanceof e.e7))continue;let d=s?s.findDEMTileFor(o):null;if(!(d&&d.dem||l)||(s&&d&&d.dem&&n.borderDEMTileTimestamp[i]!==d.dem._timestamp&&(n.borderDoneWithNeighborZ[i]=-1,n.borderDEMTileTimestamp[i]=d.dem._timestamp),n.borderDoneWithNeighborZ[i]===h.canonical.z))continue;0===h.centroidVertexArray.length&&h.createCentroidsBuffer();let p=(i<2?1:5)-i,f=h.borderDoneWithNeighborZ[p]!==n.canonical.z,g=h.borderFeatureIndices[p],y=0;if(n.canonical.z!==h.canonical.z){for(let e of r)n.showCentroid(n.featuresOnBorder[e]);if(f)for(let e of g)h.showCentroid(h.featuresOnBorder[e]);n.borderDoneWithNeighborZ[i]=h.canonical.z,h.borderDoneWithNeighborZ[p]=n.canonical.z}for(let a of r){let r,s=n.featuresOnBorder[a],c=n.centroidData[s.centroidDataIndex],f=s.borders[i];for(;y<g.length;){let e=(r=h.featuresOnBorder[g[y]]).borders[p];if(e[1]>f[0]+3||e[0]>f[0]-3)break;h.showCentroid(r),y++}if(r&&y<g.length){let a=y,x=0;for(;!(r.borders[p][0]>f[1]-3)&&(x++,++y!==g.length);)r=h.featuresOnBorder[g[y]];r=h.featuresOnBorder[g[a]];let v=!1;if(x>=1){let e=r.borders[p];3>Math.abs(f[0]-e[0])&&3>Math.abs(f[1]-e[1])&&(x=1,v=!0,y=a+1)}else if(0===x){n.showCentroid(s);continue}let b=h.centroidData[r.centroidDataIndex];l&&v&&((c.flags|b.flags)&e.e9?(c.flags|=e.e9,b.flags|=e.e9):(c.flags&=~e.e9,b.flags&=~e.e9));let w=s.intersectsCount()>1||r.intersectsCount()>1;if(x>1)y=a,c.centroidXY=b.centroidXY=new e.P(0,0);else if(d&&d.dem&&!w){let r=m[i](c,b),a=i%2?e.al-1:0;c.centroidXY=b.centroidXY=u(_(r[0],Math.min(e.al-1,r[1]),a,d,o,i<2,r[2]))}else w?c.centroidXY=b.centroidXY=new e.P(0,0):(c.centroidXY=n.encodeBorderCentroid(s),b.centroidXY=h.encodeBorderCentroid(r));n.writeCentroidToBuffer(c),h.writeCentroidToBuffer(b)}else n.showCentroid(s)}n.borderDoneWithNeighborZ[i]=h.canonical.z,h.borderDoneWithNeighborZ[p]=n.canonical.z}(n.needsCentroidUpdate||!n.centroidVertexBuffer&&0!==n.centroidVertexArray.length)&&n.uploadCentroid(i)}(i.context,r,o,n,a,h,c)}if("shadow"===i.renderPass&&i.shadowRenderer){let s=i.shadowRenderer;if(h&&o<.65&&a._transitionablePaint._values["fill-extrusion-opacity"].value.expression instanceof e.ad)return;let l=s.getShadowPassDepthMode(),u=s.getShadowPassColorMode();ag(i,r,a,n,l,t3.disabled,u,c)}else if("translucent"===i.renderPass){let d=!a.paint.get("fill-extrusion-pattern").constantOr(1),p=a.paint.get("fill-extrusion-color").constantOr(e.ao.white);if(!u&&0!==p.a){let e=new t2(i.context.gl.LEQUAL,t2.ReadWrite,i.depthRangeFor3D);1===o&&d?ag(i,r,a,n,e,t3.disabled,t1.unblended,c):(ag(i,r,a,n,e,t3.disabled,t1.disabled,c),ag(i,r,a,n,e,i.stencilModeFor3D(),i.colorModeForRenderPass(),c),i.resetStencilClippingMasks())}if(i.style.enable3dLights()&&d&&(!h&&"globe"!==i.transform.projection.name||u)){let o=a.paint.get("fill-extrusion-opacity"),d=a.paint.get("fill-extrusion-ambient-occlusion-intensity"),p=a.paint.get("fill-extrusion-ambient-occlusion-ground-radius"),f=a.paint.get("fill-extrusion-flood-light-intensity"),m="none"===a.paint.get("fill-extrusion-flood-light-color-use-theme").constantOr("default"),_=a.paint.get("fill-extrusion-flood-light-color").toNonPremultipliedRenderColor(m?null:a.lut).toArray01().slice(0,3),g=d>0&&p>0,y=f>0,x=(e,i,r)=>(1-r)*e+r*i,v=new ay;v.translate=a.paint.get("fill-extrusion-translate"),v.translateAnchor=a.paint.get("fill-extrusion-translate-anchor"),v.edgeRadius=a.layout.get("fill-extrusion-edge-radius"),v.cutoffFadeRange=a.paint.get("fill-extrusion-cutoff-fade-range");let b=s=>{let h=i.depthModeForSublayer(1,t2.ReadOnly,l.LEQUAL,!0),u=x(.1,3,a.paint.get(s?"fill-extrusion-ambient-occlusion-ground-attenuation":"fill-extrusion-flood-light-ground-attenuation")),m=i._showOverdrawInspector;m||ax(v,i,r,a,n,h,new t3({func:l.ALWAYS,mask:255},255,255,l.KEEP,l.KEEP,l.REPLACE),new t1([l.ONE,l.ONE,l.ONE,l.ONE],e.ao.transparent,[!1,!1,!1,!0],l.MIN),t5.disabled,s,"sdf",o,d,p,f,_,u,c,!1);{let g=m?t3.disabled:new t3({func:l.EQUAL,mask:255}
98,255,255,l.KEEP,l.DECR,l.DECR),y=m?i.colorModeForRenderPass():new t1([l.ONE_MINUS_DST_ALPHA,l.DST_ALPHA,l.ONE,l.ONE],e.ao.transparent,[!0,!0,!0,!0]);ax(v,i,r,a,n,h,g,y,t5.disabled,s,"color",o,d,p,f,_,u,c,!1)}};if(u){let u=(s,h,u)=>{let m=i.depthModeForSublayer(1,t2.ReadOnly,l.LEQUAL,!1),g=x(.1,3,a.paint.get(s?"fill-extrusion-ambient-occlusion-ground-attenuation":"fill-extrusion-flood-light-ground-attenuation"));{let u=new t1([l.ONE,l.ONE,l.ONE,l.ONE],e.ao.transparent,[!1,!1,!1,!0]);ax(v,i,r,a,n,m,t3.disabled,u,t5.disabled,s,"clear",o,d,p,f,_,g,c,h)}ax(v,i,r,a,n,m,new t3({func:l.ALWAYS,mask:255},255,255,l.KEEP,l.KEEP,l.REPLACE),new t1([l.ONE,l.ONE,l.ONE,l.ONE],e.ao.transparent,[!1,!1,!1,!0],l.MIN),t5.disabled,s,"sdf",o,d,p,f,_,g,c,h);{let u=s?l.ZERO:l.ONE_MINUS_DST_ALPHA;ax(v,i,r,a,n,m,new t3({func:l.EQUAL,mask:255},255,255,l.KEEP,l.DECR,l.DECR),new t1([u,l.DST_ALPHA,l.ONE_MINUS_DST_ALPHA,l.ZERO],e.ao.transparent,[!0,!0,!0,!0]),t5.disabled,s,"color",o,d,p,f,_,g,c,h)}{let y=new t1([l.ONE,l.ONE,l.ONE,s?l.ZERO:l.ONE],e.ao.transparent,[!1,!1,!1,!0],s?l.FUNC_ADD:l.MAX);ax(v,i,r,a,n,m,t3.disabled,y,t5.disabled,s,"clear",o,d,p,f,_,g,c,h,u)}};if(g||y){let r;if(i.prepareDrawTile(),h){let i=h.drapeBufferSize[0],a=h.drapeBufferSize[1];(r=h.framebufferCopyTexture)&&(!r||r.size[0]===i&&r.size[1]===a)||(r&&r.destroy(),r=h.framebufferCopyTexture=new e.T(s,new e.q({width:i,height:a}),l.RGBA8)),r.bind(l.LINEAR,l.CLAMP_TO_EDGE),l.copyTexSubImage2D(l.TEXTURE_2D,0,0,0,0,0,i,a)}g&&u(!0,!1,r),y&&u(!1,!0,r)}}else g&&b(!0),y&&b(!1),(g||y)&&i.resetStencilClippingMasks()}}},building:function(i,r,a,n){i.currentLayer<i.firstLightBeamLayer&&(i.firstLightBeamLayer=i.currentLayer);let o=a.paint.get("building-ambient-occlusion-ground-intensity"),s=a.paint.get("building-ambient-occlusion-ground-radius"),l=a.paint.get("building-ambient-occlusion-ground-attenuation"),h=a.paint.get("building-opacity");if(h<=0)return;let u=o>0&&s>0,c=!0,d=a.paint.get("building-vertical-scale");(!i.shadowRenderer||d<1)&&(c=!1);let p=i.conflationActive&&i.style.isLayerClipped(a,r.getSource()),f=i.style.order.indexOf(a.fqid);if(function(e,i,r,a,n,o){for(let s of o){let o=i.getTile(s).getBucket(r);o&&(n&&o.updateReplacement(s,e.replacementSource,a),o.uploadUpdatedIndexBuffer(e.context))}}(i,r,a,f,p,n),function(e,i,r,a){for(let n of a){let a=i.getTile(n).getBucket(r);a&&a.needsEvaluation()&&a.uploadUpdatedColorBuffer(e.context)}}(i,r,a,n),a.resetLayerRenderingStats(i),i.shadowRenderer&&(i.shadowRenderer.useNormalOffset=!0),"shadow"===i.renderPass&&i.shadowRenderer){let e=i.shadowRenderer,o=e.getShadowPassDepthMode();aS({painter:i,source:r,layer:a,coords:n,defines:[],blendMode:e.getShadowPassColorMode(),depthMode:o,opacity:h,verticalScale:d,facadeEmissiveChance:0,facadeAOIntensity:0})}else if("translucent"===i.renderPass){let f=["HAS_ATTRIBUTE_a_part_color_emissive","LIGHTING_3D_MODE"];c&&(f=f.concat("RENDER_SHADOWS","DEPTH_TEXTURE")),i.shadowRenderer&&i.shadowRenderer.useNormalOffset&&(f=f.concat("NORMAL_OFFSET"));let m=a.paint.get("building-facade-emissive-chance"),_=a.paint.get("building-ambient-occlusion-intensity"),g=new t2(i.context.gl.LEQUAL,t2.ReadWrite,i.depthRangeFor3D);h<1&&aS({painter:i,source:r,layer:a,coords:n,defines:f,blendMode:t1.disabled,depthMode:g,opacity:h,verticalScale:d,facadeEmissiveChance:m,facadeAOIntensity:_});let y=i.colorModeForRenderPass();aS({painter:i,source:r,layer:a,coords:n,defines:f,blendMode:y,depthMode:g,opacity:h,verticalScale:d,facadeEmissiveChance:m,facadeAOIntensity:_}),u&&function(i,r,a,n,o,s,l,h,u,c,d,p,f){let m=i.context.gl,_=i.depthModeForSublayer(1,t2.ReadOnly,m.LEQUAL,!0),g=.1*(1-d)+3*d,y=i._showOverdrawInspector,x=new ay;y||ax(x,i,r,a,n,_,new t3({func:m.ALWAYS,mask:255},255,255,m.KEEP,m.KEEP,m.REPLACE),new t1([m.ONE,m.ONE,m.ONE,m.ONE],e.ao.transparent,[!1,!1,!1,!0],m.MIN),t5.disabled,o,"sdf",s,l,h,0,c,g,p,!1);{let u=y?t3.disabled:new t3({func:m.EQUAL,mask:255},255,255,m.KEEP,m.DECR,m.DECR),d=y?i.colorModeForRenderPass():new t1([m.ONE_MINUS_DST_ALPHA,m.DST_ALPHA,m.ONE,m.ONE],e.ao.transparent,[!0,!0,!0,!0]);ax(x,i,r,a,n,_,u,d,t5.disabled,o,"color",s,l,h,0,c,g,p,!1)}}(i,r,a,n,!0,h,o,s,0,[0,0,0],l,p)}else if("light-beam"===i.renderPass){let e=new t2(i.context.gl.LEQUAL,t2.ReadOnly,i.depthRangeFor3D);aS({painter:i,source:r,layer:a,coords:n,defines:["HAS_ATTRIBUTE_a_part_color_emissive","HAS_ATTRIBUTE_a_bloom_attenuation"],blendMode:t1.alphaBlended,depthMode:e,opacity:h,verticalScale:d,facadeEmissiveChance:0,facadeAOIntensity:0})}i.shadowRenderer&&(i.shadowRenderer.useNormalOffset=!1),i.resetStencilClippingMasks()},hillshade:function(i,r,a,n){if("offscreen"!==i.renderPass&&"translucent"!==i.renderPass||i.style.disableElevatedTerrain)return;let o=i.context,s=i.terrain&&i.terrain.renderingToTexture,[l,h]="translucent"!==i.renderPass||s?[{},n]:i.stencilConfigForOverlap(n);for(let n of h){let o=r.getTile(n);if(o.needsHillshadePrepare&&"offscreen"===i.renderPass)!function(i,r,a){let n=i.context,o=n.gl;if(!r.dem)return;let s=r.dem;if(n.activeTexture.set(o.TEXTURE1),iH(i,r,s),!r.demTexture)return;r.demTexture.bind(o.NEAREST,o.CLAMP_TO_EDGE);let l=s.dim;n.activeTexture.set(o.TEXTURE0);let h=r.hillshadeFBO;if(!h){let i=new e.T(n,{width:l,height:l,data:null},o.RGBA8);i.bind(o.LINEAR,o.CLAMP_TO_EDGE),(h=r.hillshadeFBO=n.createFramebuffer(l,l,!0,"renderbuffer")).colorAttachment.set(i.texture)}n.bindFramebuffer.set(h.framebuffer),n.viewport.set([0,0,l,l]);let{tileBoundsBuffer:u,tileBoundsIndexBuffer:c,tileBoundsSegments:d}=i.getMercatorTileBoundsBuffers(),p=[];i.linearFloatFilteringSupported()&&p.push("TERRAIN_DEM_FLOAT_FORMAT"),i.getOrCreateProgram("hillshadePrepare",{defines:p}).draw(i,o.TRIANGLES,t2.disabled,t3.disabled,t1.unblended,t5.disabled,((i,r)=>{let a=r.stride,n=e.bC();return e.cd(n,0,e.al,-e.al,0,0,1),e.br(n,n,[0,-e.al,0]),{u_matrix:n,u_image:1,u_dimension:[a,a],u_zoom:i.overscaledZ}})(r.tileID,s),a.id,u,c,d),r.needsHillshadePrepare=!1}(i,o,a);else if("translucent"===i.renderPass){let r=i.depthModeForSublayer(0,t2.ReadOnly),h=a.paint.get("hillshade-emissive-strength"),u=i.colorModeForDrapableLayerRenderPass(h),c=s&&i.terrain?i.terrain.stencilModeForRTTOverlap(n):l[n.overscaledZ];!function(i,r,a,n,o,s,l){let h=i.context,u=h.gl,c=a.hillshadeFBO;if(!c)return;i.prepareDrawTile();let d=i.isTileAffectedByFog(r),p=i.getOrCreateProgram("hillshade",{overrideFog:d});h.activeTexture.set(u.TEXTURE0),u.bindTexture(u.TEXTURE_2D,c.colorAttachment.get());let f=((i,r,a,n)=>{let o=a.paint.get("hillshade-shadow-color"),s="none"===a.paint.get("hillshade-shadow-color-use-theme").
98constantOr("default"),l=a.paint.get("hillshade-highlight-color"),h="none"===a.paint.get("hillshade-highlight-color-use-theme").constantOr("default"),u=a.paint.get("hillshade-accent-color"),c="none"===a.paint.get("hillshade-accent-color-use-theme").constantOr("default"),d=a.paint.get("hillshade-emissive-strength"),p=e.an(a.paint.get("hillshade-illumination-direction"));if("viewport"===a.paint.get("hillshade-illumination-anchor"))p-=i.transform.angle;else if(i.style&&i.style.enable3dLights()&&i.style.directionalLight){let r=i.style.directionalLight.properties.get("direction"),a=e.d3(r.x,r.y,r.z);p=e.an(a[1])}let f=!i.options.moving;return{u_matrix:n||i.transform.calculateProjMatrix(r.tileID.toUnwrapped(),f),u_image:0,u_latrange:function(i,r){let a=Math.pow(2,r.canonical.z),n=r.canonical.y;return[new e.ae(0,n/a).toLngLat().lat,new e.ae(0,(n+1)/a).toLngLat().lat]}(0,r.tileID),u_light:[a.paint.get("hillshade-exaggeration"),p],u_shadow:o.toPremultipliedRenderColor(s?null:a.lut),u_highlight:l.toPremultipliedRenderColor(h?null:a.lut),u_emissive_strength:d,u_accent:u.toPremultipliedRenderColor(c?null:a.lut)}})(i,a,n,i.terrain?r.projMatrix:null);i.uploadCommonUniforms(h,p,r.toUnwrapped());let{tileBoundsBuffer:m,tileBoundsIndexBuffer:_,tileBoundsSegments:g}=i.getTileBoundsBuffers(a);p.draw(i,u.TRIANGLES,o,s,l,t5.disabled,f,n.id,m,_,g)}(i,n,o,a,r,c,u)}}o.viewport.set([0,0,i.width,i.height]),i.resetStencilClippingMasks()},raster:function(i,r,a,n,o,s){if("translucent"!==i.renderPass||0===a.paint.get("raster-opacity"))return;let l="globe"===i.transform.projection.name,h=0!==a.paint.get("raster-elevation"),u=h&&l;if(i.renderElevatedRasterBackface&&!u)return;let c=i.context,d=c.gl,p=r.getSource(),f=function(i,r,a,n){let o=r.paint.get("raster-color"),s="raster-array"===i.type,l=[],h=r.paint.get("raster-resampling"),u=r.paint.get("raster-color-mix"),c=r.paint.get("raster-color-range"),d=[u[0],u[1],u[2],0],p=u[3],f="nearest"===h?n.NEAREST:n.LINEAR;if(s&&(l.push("RASTER_ARRAY"),o||l.push("RASTER_COLOR"),"linear"===h&&l.push("RASTER_ARRAY_LINEAR"),f=n.NEAREST,!c&&i.rasterLayers)){let e=i.rasterLayers.find(({id:e})=>e===r.sourceLayer);e&&e.fields&&e.fields.range&&(c=e.fields.range)}if(c=c||[0,1],o){l.push("RASTER_COLOR"),a.activeTexture.set(n.TEXTURE2),r.updateColorRamp(c);let i=r.colorRampTexture;i||(i=r.colorRampTexture=new e.T(a,r.colorRamp,n.RGBA8)),i.bind(n.LINEAR,n.CLAMP_TO_EDGE)}return{mix:d,range:c,offset:p,defines:l,resampling:f}}(p,a,c,d);if(p instanceof e.aS&&!n.length&&!l)return;let m=a.paint.get("raster-emissive-strength"),_=i.colorModeForDrapableLayerRenderPass(m),g=i.terrain&&i.terrain.renderingToTexture,y=!i.options.moving,x="nearest"===a.paint.get("raster-resampling")?d.NEAREST:d.LINEAR;if(p instanceof e.aS&&!n.length&&(p.onNorthPole||p.onSouthPole)){let e=h?i.stencilModeFor3D():t3.disabled;return void aI(!!p.onNorthPole,null,i,r,a,m,f,t5.disabled,e)}if(!n.length)return;let[v,b]=p instanceof e.aS||g?[{},n]:i.stencilConfigForOverlap(n),w=b[b.length-1].overscaledZ;u&&f.defines.push("PROJECTION_GLOBE_VIEW"),h&&f.defines.push("RENDER_CUTOFF");let T=(n,o,b)=>{for(let T of n){let n,S,E,I,A,C=T.toUnwrapped(),M=r.getTile(T);if(g&&(!M||!M.hasData()))continue;c.activeTexture.set(d.TEXTURE0);let P=function(e,i,r,a){if(e)return i instanceof eK&&e instanceof tt?i.getTextureDescriptor(e,r,!0):{texture:e.texture,mix:aE(a.mix),offset:a.offset,buffer:0,tileSize:1}}(M,p,a,f);if(!P||!P.texture)continue;let{texture:z,mix:R,offset:D,tileSize:L,buffer:O}=P;g?(n=t2.disabled,S=T.projMatrix):h?(n=new t2(d.LEQUAL,t2.ReadWrite,i.depthRangeFor3D),S=l?Float32Array.from(i.transform.expandedFarZProjMatrix):i.transform.calculateProjMatrix(C,y)):(n=i.depthModeForSublayer(T.overscaledZ-w,1===a.paint.get("raster-opacity")?t2.ReadWrite:t2.ReadOnly,d.LESS),S=i.transform.calculateProjMatrix(C,y));let F=i.terrain&&g?i.terrain.stencilModeForRTTOverlap(T):v[T.overscaledZ],k=s?0:a.paint.get("raster-fade-duration");M.registerFadeDuration(k);let B=r.findLoadedParent(T,0),N=rA(M,B,r,i.transform,k);!N.isFading&&M.refreshedUponExpiration&&(M.refreshedUponExpiration=!1),i.terrain&&i.terrain.prepareDrawTile(),c.activeTexture.set(d.TEXTURE0),z.bind(x,d.CLAMP_TO_EDGE),c.activeTexture.set(d.TEXTURE1),B?(B.texture&&B.texture.bind(x,d.CLAMP_TO_EDGE),E=Math.pow(2,B.tileID.overscaledZ-M.tileID.overscaledZ
98),I=[M.tileID.canonical.x*E%1,M.tileID.canonical.y*E%1]):z.bind(x,d.CLAMP_TO_EDGE),"useMipmap"in z&&c.extTextureFilterAnisotropic&&i.transform.pitch>20&&d.texParameterf(d.TEXTURE_2D,c.extTextureFilterAnisotropic.TEXTURE_MAX_ANISOTROPY_EXT,c.extTextureFilterAnisotropicMax);let V=i.transform,U=h?function(e){let i=e._nearZ,r=e.projection.farthestPixelDistance(e),a=r-i,n=.2*e.height,o=i+n;return[i,r,(o-n-i)/a,(o-i)/a]}(V):[0,0,0,0],j,G,q,$,H,Z=0;if(u&&p instanceof e.aS&&p.coordinates.length>3)j=Float32Array.from(e.bk(e.dF(new e.cC(0,0,0)))),G=Float32Array.from(V.globeMatrix),q=Float32Array.from(e.dB(V)),$=[e.aF(V.center.lng),e.aJ(V.center.lat)],A=p.elevatedGlobePerspectiveTransform,H=p.elevatedGlobeGridMatrix||new Float32Array(9);else if(u){let i=e.dC(T.canonical);Z=e.dD(i.getCenter().lat),j=Float32Array.from(e.bk(e.dF(T.canonical))),G=Float32Array.from(V.globeMatrix),q=Float32Array.from(e.dB(V)),$=[e.aF(V.center.lng),e.aJ(V.center.lat)],A=[0,0],H=Float32Array.from(e.dE(T.canonical,i,Z,V.worldSize/V._pixelsPerMercatorPixel))}else A=p instanceof e.aS?p.perspectiveTransform:[0,0],j=new Float32Array(16),G=new Float32Array(9),q=new Float32Array(16),$=[0,0],H=new Float32Array(9);let W=r2(S,j,G,q,H,I||[0,0],e.aj(i.transform.zoom),$,U,E||1,N,a,A,h?a.paint.get("raster-elevation"):0,2,R,D,f.range,L,O,m),X=i.isTileAffectedByFog(T),Y=i.getOrCreateProgram("raster",{defines:f.defines,overrideFog:X});if(i.uploadCommonUniforms(c,Y,C),p instanceof e.aS){let r=p.elevatedGlobeVertexBuffer,s=p.elevatedGlobeIndexBuffer;if(g||!l)p.boundsBuffer&&p.boundsSegments&&Y.draw(i,d.TRIANGLES,n,t3.disabled,_,t5.disabled,W,a.id,p.boundsBuffer,i.quadTriangleIndexBuffer,p.boundsSegments);else if(r&&s){let l=V.zoom<=e.cZ?p.elevatedGlobeSegments:p.getSegmentsForLongitude(V.center.lng);l&&Y.draw(i,d.TRIANGLES,n,t3.disabled,_,o,W,a.id,r,s,l)}}else if(u){n=new t2(d.LEQUAL,t2.ReadOnly,i.depthRangeFor3D);let e=i.globeSharedBuffers;if(e){let[r,s,l]=e.getGridBuffers(Z,!1);Y.draw(i,d.TRIANGLES,n,b||F,i.colorModeForRenderPass(),o,W,a.id,r,s,l)}}else{let{tileBoundsBuffer:e,tileBoundsIndexBuffer:r,tileBoundsSegments:o}=i.getTileBoundsBuffers(M);Y.draw(i,d.TRIANGLES,n,F,_,t5.disabled,W,a.id,e,r,o)}}if(!(p instanceof e.aS)&&u)for(let e of n){let n=e.canonical.y===(1<<e.canonical.z)-1;0===e.canonical.y&&aI(!0,e,i,r,a,m,f,o,b||t3.disabled),n&&aI(!1,e,i,r,a,m,f,o===t5.frontCW?t5.backCW:t5.frontCW,b||t3.disabled)}};u?T(b,i.renderElevatedRasterBackface?t5.backCW:t5.frontCW,i.stencilModeFor3D()):T(b,t5.disabled,void 0),i.resetStencilClippingMasks()},"raster-particle":function(i,r,a,n,o,s){"offscreen"===i.renderPass&&function(i,r,a,n){if(!n.length)return;let o=i.context,s=o.gl,l=r.getSource();if(!(l instanceof eK))return;let h=Math.ceil(Math.sqrt(a.paint.get("raster-particle-count"))),u=a.particlePositionRGBAImage;if(!u||u.width!==h){let i=function(e){let i=e*e,r=new Uint8Array(4*i),a=function(e){return e|=0,((e=Math.imul((e=Math.imul((e=Math.imul(0xa3c59ac3^e,0x9e3779b9))^e>>>16,0x9e3779b9))^e>>>16,0x9e3779b9))>>>0)/0x100000000},n=1/1.1;for(let e=0;e<i;e++){let i=n*(a(2*e+0)+.05),o=n*(a(2*e+1)+.05),s=255*i%1,l=255*o%1,h=o-l/255;r[4*e+0]=255*(i-s/255),r[4*e+1]=255*s,r[4*e+2]=255*h,r[4*e+3]=255*l}return r}(h);u=a.particlePositionRGBAImage=new e.q({width:h,height:h},i)}let c=a.particleFramebuffer;c?c.width!==h&&(c.destroy(),c=a.particleFramebuffer=o.createFramebuffer(h,h,!0,null)):c=a.particleFramebuffer=o.createFramebuffer(h,h,!0,null);let d=[];for(let i of n){let n=r.getTile(i);if(!(n instanceof tt))continue;let s=function(i,r,a){if(!i)return null;let n=r.getTextureDescriptor(i,a,!0);if(!n)return null;let{texture:o,mix:s,offset:l,tileSize:h,buffer:u,format:c}=n;if(!o||!c)return null;let d=!1;return"uint32"===c&&(d=!0,s[3]=0,s=r0(e.eh,s,[0,a.paint.get("raster-particle-max-speed")]),l=r1(e.eh,l,[0,a.paint.get("raster-particle-max-speed")])),{texture:o,textureOffset:[u/(h+2*u),h/(h+2*u)],tileSize:h,scalarData:d,scale:s,offset:l,defines:["RASTER_ARRAY",{uint8:"DATA_FORMAT_UINT8",uint16:"DATA_FORMAT_UINT16",uint32:"DATA_FORMAT_UINT32"}[c]]}}(n,l,a);if(!s)continue;let c=[n.tileSize,n.tileSize],p=a.tileFramebuffer;p||(p=a.tileFramebuffer=o.createFramebuffer(c[0],c[1],!0,null));let f=n.rasterParticleState;f||(f=n.rasterParticleState=new aC(o,i,c,u));let m=f.update(a.lastInvalidatedAt);f.particleTextureDimension!==h&&f.updateParticleTexture(i,u);let _=f.targetColorTexture;f.targetColorTexture=f.backgroundColorTexture,f.backgroundColorTexture=_;let g=f.particleTexture0;f.particleTexture0=f.particleTexture1,f.particleTexture1=g,d.push([i,s,f,m])}if(0===d.length)return;let p=e.o.now(),f=a.previousDrawTimestamp?.001*(p-a.previousDrawTimestamp):.0167;if(a.previousDrawTimestamp=p,a.hasColorMap()){o.activeTexture.set(s.TEXTURE0+2);let i=a.colorRampTexture;i||(i=a.colorRampTexture=new e.T(o,a.colorRamp,s.RGBA8)),i.bind(s.LINEAR,s.CLAMP_TO_EDGE)}o.bindFramebuffer.set(a.tileFramebuffer.framebuffer),function(i,r,a){var n;let o=i.context,s=o.gl,l=r.tileFramebuffer;o.activeTexture.set(s.TEXTURE0);let h={u_texture:0,u_opacity:1.05*(n=r.paint.get("raster-particle-fade-opacity-factor"))/(n+.05)},u=i.getOrCreateProgram("rasterParticleTexture",{defines:[],overrideFog:!1});for(let n of a){let[,,a,c]=n;l.colorAttachment.set(a.targetColorTexture.texture),o.viewport.set([0,0,l.width,l.height]),o.clear({color:e.ao.transparent}),c&&(a.backgroundColorTexture.bind(s.NEAREST,s.CLAMP_TO_EDGE),u.draw(i,s.TRIANGLES,t2.disabled,t3.disabled,t1.alphaBlended,t5.disabled,h,r.id,i.viewportBuffer,i.quadTriangleIndexBuffer,i.viewportSegments))}}(i,a,d),function(i,r,a,n){let o=i.context,s=o.gl,l=a.tileFramebuffer,h="globe"===i.transform.projection.name,u=a.paint.get("raster-particle-max-speed");for(let c of n){let[n,d,p]=c;o.activeTexture.set(s.TEXTURE0+0),d.texture.bind(s.LINEAR,s.CLAMP_TO_EDGE),l.colorAttachment.set(p.targetColorTexture.texture);let f=i.getOrCreateProgram("rasterParticleDraw",{defines:d.defines,overrideFog:!1});o.activeTexture.set(s.TEXTURE0+1);let m=d.scalarData?[]:[0,1,2,3].map(i=>e.e6[i](n));m.push(n);let _=n.canonical.x,g=n.canonical.y;for(let e of m){let o=r.getTile(h?e.wrapped():e);if(!o)continue;let l=o.rasterParticleState;if(!l)continue;let c=e.canonical.x+(1<<e.canonical.z)*(e.wrap-n.wrap),p=e.canonical.y;l.particleTexture0.bind(s.NEAREST,s.CLAMP_TO_EDGE);let m=r5(1,l.particleTexture0.size[0],[c-_,p-g],0,d.texture.size,2,u,d.textureOffset,d.scale,d.offset);f.draw(i,s.POINTS,t2.disabled,t3.disabled,t1.alphaBlended,t5.disabled,m,a.id,l.particleIndexBuffer,void 0,l.particleSegment)}}}(i,r,a,d),o.bindFramebuffer.set(a.particleFramebuffer.framebuffer),function(i,r,a,n){let o=i.context,s=o.gl,l=r.paint.get("raster-particle-max-speed"),h=n*r.paint.get("raster-particle-speed-factor")*.15,u=Math.pow(.01+ +r.paint.get("raster-particle-reset-rate-factor"),6),c=r.particleFramebuffer;for(let n of(o.viewport.set([0,0,c.width,c.height]),a)){let[,a,d]=n;o.activeTexture.set(s.TEXTURE0+0),a.texture.bind(s.LINEAR,s.CLAMP_TO_EDGE),o.activeTexture.set(s.TEXTURE0+1);let p=d.particleTexture0;p.bind(s.NEAREST,s.CLAMP_TO_EDGE);let f=r4(1,p.size[0],0,a.texture.size,l,h,u,a.textureOffset,a.scale,a.offset);c.colorAttachment.set(d.particleTexture1.texture),o.clear({color:e.ao.transparent}),i.getOrCreateProgram("rasterParticleUpdate",{defines:a.defines}).draw(i,s.TRIANGLES,t2.disabled,t3.disabled,t1.unblended,t5.disabled,f,r.id,i.viewportBuffer,i.quadTriangleIndexBuffer,i.viewportSegments)}}(i,a,d,f)}(i,r,a,n),"translucent"===i.renderPass&&(function(i,r,a,n,o){let s=i.context,l=s.gl,h=r.getSource().tileSize,u=5*(1-e.ah(e.cK,e.cK+1,i.transform.zoom))*h+a.paint.get("raster-particle-elevation"),c=!i.options.moving,d="globe"===i.transform.projection.name;if(!n.length)return;let[p,f]=i.stencilConfigForOverlap(n),m=[];d&&m.push("PROJECTION_GLOBE_VIEW");let _=i.stencilModeFor3D();for(let n of f){let o,h,f,g,y,x,v,b=n.toUnwrapped(),w=r.getTile(n);if(!w.rasterParticleState)continue;let T=w.rasterParticleState;w.registerFadeDuration(100);let S=r.findLoadedParent(n,0),E=rA(w,S,r,i.transform,100);i.terrain&&i.terrain.prepareDrawTile(),s.activeTexture.set(l.TEXTURE0),T.targetColorTexture.bind(l.LINEAR,l.CLAMP_TO_EDGE),s.activeTexture.set(l.TEXTURE1),S&&S.rasterParticleState?(S.rasterParticleState.targetColorTexture.bind(l.LINEAR,l.CLAMP_TO_EDGE),o=Math.pow(2,S.tileID.overscaledZ-w.tileID.overscaledZ
98),h=[w.tileID.canonical.x*o%1,w.tileID.canonical.y*o%1]):T.targetColorTexture.bind(l.LINEAR,l.CLAMP_TO_EDGE);let I=d?Float32Array.from(i.transform.expandedFarZProjMatrix):i.transform.calculateProjMatrix(b,c),A=i.transform,C=function(e){let i=e._nearZ,r=e.projection.farthestPixelDistance(e),a=r-i,n=.2*e.height,o=i+n;return[i,r,(o-n-i)/a,(o-i)/a]}(A),M=e.dC(n.canonical),P=e.dD(M.getCenter().lat);d?(f=Float32Array.from(e.bk(e.dF(n.canonical))),g=Float32Array.from(A.globeMatrix),y=Float32Array.from(e.dB(A)),x=[e.aF(A.center.lng),e.aJ(A.center.lat)],v=Float32Array.from(e.dE(n.canonical,M,P,A.worldSize/A._pixelsPerMercatorPixel))):(f=new Float32Array(16),g=new Float32Array(9),y=new Float32Array(16),x=[0,0],v=new Float32Array(9));let z=r3(I,f,g,y,v,h||[0,0],e.aj(i.transform.zoom),x,C,o||1,E,u),R=i.isTileAffectedByFog(n),D=i.getOrCreateProgram("rasterParticle",{defines:m,overrideFog:R});if(i.uploadCommonUniforms(s,D,b),d){let e=new t2(l.LEQUAL,t2.ReadOnly,i.depthRangeFor3D),r=i.globeSharedBuffers;if(r){let[n,o,s]=r.getGridBuffers(P,!1);D.draw(i,l.TRIANGLES,e,_,t1.alphaBlended,i.renderElevatedRasterBackface?t5.frontCCW:t5.backCCW,z,a.id,n,o,s)}}else{let e=i.depthModeForSublayer(0,t2.ReadOnly),r=p[n.overscaledZ],{tileBoundsBuffer:o,tileBoundsIndexBuffer:s,tileBoundsSegments:h}=i.getTileBoundsBuffers(w);D.draw(i,l.TRIANGLES,e,r,t1.alphaBlended,t5.disabled,z,a.id,o,s,h)}}i.resetStencilClippingMasks()}(i,r,a,n),i.style.map.triggerRepaint())},background:function(i,r,a,n){let o,s=a.paint.get("background-color"),l="none"===a.paint.get("background-color-use-theme").constantOr("default"),h=a.paint.get("background-opacity"),u=a.paint.get("background-emissive-strength"),c="viewport"===a.paint.get("background-pitch-alignment");if(0===h)return;let d=i.context,p=d.gl,f=i.transform,m=f.tileSize,_=a.paint.get("background-pattern");if(void 0!==_&&(null===_||!(o=i.imageManager.getPattern(e.I.from(_.toString()),a.scope,i.style.getLut(a.scope)))))return;let g=!_&&1===s.a&&1===h&&i.opaquePassEnabledForLayer()?"opaque":"translucent";if(i.renderPass!==g)return;let y=t3.disabled,x=i.depthModeForSublayer(0,"opaque"===g?t2.ReadWrite:t2.ReadOnly),v=i.colorModeForDrapableLayerRenderPass(u),b=_?"backgroundPattern":"background",w,T=n;if(T||(T=Object.values(w=i.getBackgroundTiles()).map(e=>e.tileID)),_&&(d.activeTexture.set(p.TEXTURE0),i.imageManager.bind(i.context,a.scope)),c){let r=i.getOrCreateProgram(b,{overrideFog:!1,overrideRtt:!0}),n=new Float32Array(e.bA([])),d=new e.aO(0,0,0,0,0),f=_?r7(n,u,h,i,0,a.scope,o,c,{tileID:d,tileSize:m}):r9(n,u,h,s.toPremultipliedRenderColor(l?null:a.lut));r.draw(i,p.TRIANGLES,x,y,v,t5.disabled,f,a.id,i.viewportBuffer,i.quadTriangleIndexBuffer,i.viewportSegments)}else for(let e of T){let g=i.isTileAffectedByFog(e),T=i.getOrCreateProgram(b,{overrideFog:g}),S=e.toUnwrapped(),E=n?e.projMatrix:i.transform.calculateProjMatrix(S);i.prepareDrawTile();let I=r?r.getTile(e):w?w[e.key]:new te(e,m,f.zoom,i),A=_?r7(E,u,h,i,0,a.scope,o,c,{tileID:e,tileSize:m}):r9(E,u,h,s.toPremultipliedRenderColor(l?null:a.lut));i.uploadCommonUniforms(d,T,S);let{tileBoundsBuffer:C,tileBoundsIndexBuffer:M,tileBoundsSegments:P}=i.getTileBoundsBuffers(I);T.draw(i,p.TRIANGLES,x,y,v,t5.disabled,A,a.id,C,M,P)}},sky:function(i,r,a){let n=i._atmosphere?e.aj(i.transform.zoom):1,o=a.paint.get("sky-opacity")*n;if(0===o)return;let s=i.context,l=a.paint.get("sky-type"),h=new t2(s.gl.LEQUAL,t2.ReadOnly,[0,1]),u=i.frameCounter/1e3%1;"atmosphere"===l?"offscreen"===i.renderPass?a.needsSkyboxCapture(i)&&(function(i,r,a,n){let o=i.context,s=o.gl,l=r.skyboxFbo;if(!l){l=r.skyboxFbo=o.createFramebuffer(32,32,!0,null),r.skyboxGeometry=new aU(o),r.skyboxTexture=o.gl.createTexture(),s.bindTexture(s.TEXTURE_CUBE_MAP,r.skyboxTexture),s.texParameteri(s.TEXTURE_CUBE_MAP,s.TEXTURE_WRAP_S,s.CLAMP_TO_EDGE),s.texParameteri(s.TEXTURE_CUBE_MAP,s.TEXTURE_WRAP_T,s.CLAMP_TO_EDGE),s.texParameteri(s.TEXTURE_CUBE_MAP,s.TEXTURE_MIN_FILTER,s.LINEAR),s.texParameteri(s.TEXTURE_CUBE_MAP,s.TEXTURE_MAG_FILTER,s.LINEAR);for(let e=0;e<6;++e)s.texImage2D(s.TEXTURE_CUBE_MAP_POSITIVE_X+e,0,s.RGBA,32,32,0,s.RGBA,s.UNSIGNED_BYTE,null)}o.bindFramebuffer.set(l.framebuffer),o.viewport.set([0,0,32,32]);let h=r.getCenter(i,!0),u=i.getOrCreateProgram("skyboxCapture"),c=new Float64Array(16);e.bA(c),e.ek(c,c,-(.5*Math.PI)),aj(i,r,u,c,h,0),e.bA(c),e.ek(c,c,.5*Math.PI),aj(i,r,u,c,h,1),e.bA(c),e.cT(c,c,-(.5*Math.PI)),aj(i,r,u,c,h,2),e.bA(c),e.cT(c,c,.5*
98Math.PI),aj(i,r,u,c,h,3),e.bA(c),aj(i,r,u,c,h,4),e.bA(c),e.ek(c,c,Math.PI),aj(i,r,u,c,h,5),o.viewport.set([0,0,i.width,i.height])}(i,a),a.markSkyboxValid(i)):"sky"===i.renderPass&&function(e,i,r,a,n){let o,s=e.context,l=s.gl,h=e.transform,u=e.getOrCreateProgram("skybox");s.activeTexture.set(l.TEXTURE0),l.bindTexture(l.TEXTURE_CUBE_MAP,i.skyboxTexture);let c=(o=h.skyboxMatrix,{u_matrix:o,u_sun_direction:i.getCenter(e,!1),u_cubemap:0,u_opacity:a,u_temporal_offset:n});e.uploadCommonUniforms(s,u),u.draw(e,l.TRIANGLES,r,t3.disabled,e.colorModeForRenderPass(),t5.backCW,c,"skybox",i.skyboxGeometry.vertexBuffer,i.skyboxGeometry.indexBuffer,i.skyboxGeometry.segment)}(i,a,h,o,u):"gradient"===l&&"sky"===i.renderPass&&function(i,r,a,n,o){let s,l,h,u=i.context,c=u.gl,d=i.transform,p=i.getOrCreateProgram("skyboxGradient");r.skyboxGeometry||(r.skyboxGeometry=new aU(u)),u.activeTexture.set(c.TEXTURE0);let f=r.colorRampTexture;f||(f=r.colorRampTexture=new e.T(u,r.colorRamp,c.RGBA8)),f.bind(c.LINEAR,c.CLAMP_TO_EDGE);let m=(s=d.skyboxMatrix,l=r.getCenter(i,!1),h=r.paint.get("sky-gradient-radius"),{u_matrix:s,u_color_ramp:0,u_center_direction:l,u_radius:e.an(h),u_opacity:n,u_temporal_offset:o});i.uploadCommonUniforms(u,p),p.draw(i,c.TRIANGLES,a,t3.disabled,i.colorModeForRenderPass(),t5.backCW,m,"skyboxGradient",r.skyboxGeometry.vertexBuffer,r.skyboxGeometry.indexBuffer,r.skyboxGeometry.segment)}(i,a,h,o,u)},custom:function(i,r,a,n){let o=i.context,s=a.implementation;if(!i.transform.projection.unsupportedLayers||!i.transform.projection.unsupportedLayers.includes("custom")||i.terrain&&(i.terrain.renderingToTexture||"offscreen"===i.renderPass)&&a.isDraped(r)){if("offscreen"===i.renderPass){let r=s.prerender;if(r){if(i.setCustomLayerDefaults(),o.setColorMode(i.colorModeForRenderPass()),"globe"===i.transform.projection.name){let a=i.transform.pointMerc;r.call(s,o.gl,i.transform.customLayerMatrix(),i.transform.getProjection(),i.transform.globeToMercatorMatrix(),e.aj(i.transform.zoom),[a.x,a.y],i.transform.pixelsPerMeterRatio)}else r.call(s,o.gl,i.transform.customLayerMatrix());o.setDirty(),i.setBaseState()}}else if("translucent"===i.renderPass){if(i.terrain&&i.terrain.renderingToTexture){let e=s.renderToTile;if(e){let r=n[0].canonical,a={x:r.x+n[0].wrap*(s.wrapTileId?0:1<<r.z),y:r.y,z:r.z};o.setDepthMode(t2.disabled),o.setStencilMode(t3.disabled),o.setColorMode(i.colorModeForRenderPass()),i.setCustomLayerDefaults(),e.call(s,o.gl,a),o.setDirty(),i.setBaseState()}return}i.setCustomLayerDefaults(),o.setColorMode(i.colorModeForRenderPass()),o.setStencilMode(t3.disabled);let r="3d"===s.renderingMode?new t2(i.context.gl.LEQUAL,t2.ReadWrite,i.depthRangeFor3D):i.depthModeForSublayer(0,t2.ReadOnly);if(o.setDepthMode(r),"globe"===i.transform.projection.name){let r=i.transform.pointMerc;s.render(o.gl,i.transform.customLayerMatrix(),i.transform.getProjection(),i.transform.globeToMercatorMatrix(),e.aj(i.transform.zoom),[r.x,r.y],i.transform.pixelsPerMeterRatio)}else s.render(o.gl,i.transform.customLayerMatrix());o.setDirty(),i.setBaseState(),o.bindFramebuffer.set(null)}}else e.w("Custom layers are not yet supported with this projection. Use mercator or globe to enable usage of custom layers.")},model:function(i,r,a,n){if("opaque"===i.renderPass)return;let o=a.paint.get("model-opacity").constantOr(1);if(0===o)return;let s=a.paint.get("model-cast-shadows");if("shadow"===i.renderPass&&(!s||i.terrain&&o<.65&&a._transitionablePaint._values["model-opacity"].value.expression instanceof e.ad))return;let l=i.shadowRenderer,h=a.paint.get("model-receive-shadows");l&&(l.useNormalOffset=!0,h||(l.enabled=!1));let u=()=>{l&&(l.useNormalOffset=!0,h||(l.enabled=!0))},c=r.getSource();if("light-beam"===i.renderPass&&"batched-model"!==c.type)return;if("vector"===c.type||"geojson"===c.type)return function(i,r,a,n,o){let s=i.transform;if("mercator"!==s.projection.name)return e.w(`Drawing 3D models for ${s.projection.name} projection is not yet implemented`);let l=s.getFreeCameraOptions().position;if(!i.modelManager)return;let h=i.modelManager;a.modelManager=h;let u=i.shadowRenderer;if(!a._unevaluatedLayout._values.hasOwnProperty("model-id"))return;let c=a._unevaluatedLayout._values["model-id"],d=Object.assign({},a.layout.get("model-id").parameters),p=i.style.order.indexOf(a.fqid);for(let f of n){let n=r.getTile(f).getBucket(a);if(!n||n.projection.name!==s.projection.name)continue;let m=n.getModelUris();m&&!n.modelsRequested&&(h.addModelsFromBucket(m,o),n.modelsRequested=!0),d.zoom=function(i,r){let a=1<<i.canonical.z,n=r.getFreeCameraOptions().position,o=r.elevation,s=i.canonical.x/a,l=(i.canonical.x+1)/a,h=i.canonical.y/a,u=(i.canonical.y+1)/a,c=r._centerAltitude;if(o){let e=o.getMinMaxForTile(i);e&&e.max>c&&(c=e.max)}let d=e.aA(n.x,s,l)-n.x,p=e.aA(n.y,h,u)-n.y,f=e.ce(c,r.center.lat)-n.z;return r._zoomFromMercatorZ(Math.sqrt(d*d+p*p+f*f))}(f,s);let _=c.possiblyEvaluate(d);if(function(i,r,a){let n=r.updateZoomBasedPaintProperties(),o=function(i,r,a){let n,o,s,l=i.terrain?i.terrain.exaggeration():0;if(i.terrain&&l>0){let r=i.terrain,o=r.findDEMTileFor(a);o&&o.dem?n=e.ew.create(r,a,o):l=0}if(0===l&&(r.terrainElevationMin=0,r.terrainElevationMax=0),l===r.validForExaggeration&&(0===l||n&&n._demTile&&n._demTile.tileID===r.validForDEMTile.id&&n._dem._timestamp===r.validForDEMTile.timestamp))return!1;for(let e in r.instancesPerModel){let i=r.instancesPerModel[e];for(let e=0;e<i.instancedDataArray.length;++e){let a=(n?l*n.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,o=o?Math.min(r.terrainElevationMin,a):a,s=s?Math.max(r.terrainElevationMax,a):a}}return r.terrainElevationMin=o||0,r.terrainElevationMax=s||0,r.validForExaggeration=l,r.validForDEMTile=n&&n._demTile?{id:n._demTile.tileID,timestamp:n._dem._timestamp}:{id:void 0,timestamp:0},!0}(i,r,a);(n||o)&&(r.uploaded=!1,r.upload(i.context))}(i,n,f),aQ.shadowUniformsInitialized=!1,aQ.useSingleShadowCascade=!!u&&0===u.getMaxCascadeForTile(f.toUnwrapped()),"shadow"===i.renderPass&&u){if(1===i.currentShadowCascade&&n.isInsideFirstShadowMapFrustum)continue;let r=s.calculatePosMatrix(f.toUnwrapped(),s.worldSize);if(aQ.tileMatrix.set(r),aQ.shadowTileMatrix=Float32Array.from(u.calculateShadowPassMatrixFromMatr
98ix(r)),aQ.aabb.min=[0,0,0],aQ.aabb.max[0]=aQ.aabb.max[1]=e.al,aQ.aabb.max[2]=0,function(i,r,a,n){if(!a.modelManager)return!0;let o=a.modelManager;if(!a.shadowRenderer)return!0;let s=a.shadowRenderer,l=r.aabb,h=!0,u=i.maxHeight;if(0===u){let e=0;for(let r in i.instancesPerModel){let i=o.getModel(r,n);i?e=Math.max(e,Math.max(Math.max(i.aabb.max[0],i.aabb.max[1]),i.aabb.max[2])):h=!1}u=i.maxScale*e*1.41+i.maxVerticalOffset,h&&(i.maxHeight=u)}l.max[2]=u,l.min[2]+=i.terrainElevationMin,l.max[2]+=i.terrainElevationMax,e.af(l.min,l.min,r.tileMatrix),e.af(l.max,l.max,r.tileMatrix);let c=l.intersects(s.getCurrentCascadeFrustum());return 0===a.currentShadowCascade&&(i.isInsideFirstShadowMapFrustum=2===c),0===c}(n,aQ,i,a.scope))continue}let g=1<<f.canonical.z,y=[((l.x-f.wrap)*g-f.canonical.x)*e.al,(l.y*g-f.canonical.y)*e.al,l.z*g*e.al];for(let e in i.conflationActive&&Object.keys(n.instancesPerModel).length>0&&i.style.isLayerClipped(a,r.getSource())&&n.updateReplacement(f,i.replacementSource,p,o)&&(n.uploaded=!1,n.upload(i.context)),n.instancesPerModel){let r=n.instancesPerModel[e];r.features.length>0&&(e=_.evaluate(r.features[0].feature,{}));let s=h.getModel(e,o);if(s||h.hasURLBeenRequested(e)||n.modelUris.includes(e)||(n.modelUris.push(e),n.modelsRequested=!1),s&&s.uploaded)for(let e of s.nodes)!function e(i,r,a,n,o,s,l){let h=i.context,u="shadow"===i.renderPass,c=i.shadowRenderer,d=u&&c?c.getShadowPassDepthMode():new t2(h.gl.LEQUAL,t2.ReadWrite,i.depthRangeFor3D),p=i.isTileAffectedByFog(s);if(a.meshes)for(let e of a.meshes){let f,m,_,g=["MODEL_POSITION_ON_GPU"],y=[];n.instancedDataArray.length>20&&g.push("INSTANCED_ARRAYS");let x=ii(i,r.paint.get("model-cutoff-fade-range"));if(x.shouldRenderCutoff&&g.push("RENDER_CUTOFF"),u&&c)f=i.getOrCreateProgram("modelDepth",{defines:g}),m=ai(l.shadowTileMatrix,l.shadowTileMatrix,Float32Array.from(a.matrix)),_=c.getShadowPassColorMode();else{aY(g,y,e,i,"none"===r.paint.get("model-color-use-theme").constantOr("default")?null:r.lut),f=i.getOrCreateProgram("model",{defines:g,overrideFog:p});let n=e.material,u=n.pbrMetallicRoughness,d=r.paint.get("model-opacity").constantOr(1),v=r.paint.get("model-emissive-strength").constantOr(0);m=at(s.expandedProjMatrix,Float32Array.from(a.matrix),new Float32Array(16),null,i,d,u.baseColorFactor,n.emissiveFactor,u.metallicFactor,u.roughnessFactor,n,v,r,o),c&&(l.shadowUniformsInitialized?f.setShadowUniformValues(h,c.getShadowUniformValues()):(c.setupShadows(s.toUnwrapped(),f,"model-tile"),l.shadowUniformsInitialized=!0)),_=x.shouldRenderCutoff||d<1||"OPAQUE"!==n.alphaMode?t1.alphaBlended:t1.unblended}i.uploadCommonUniforms(h,f,s.toUnwrapped(),null,x);let v=e.material.doubleSided?t5.disabled:t5.backCCW;if(n.instancedDataArray.length>20)y.push(n.instancedDataBuffer),f.draw(i,h.gl.TRIANGLES,d,t3.disabled,_,v,m,r.id,e.vertexBuffer,e.indexBuffer,e.segments,r.paint,i.transform.zoom,void 0,y,n.instancedDataArray.length);else{let a=u?"u_instance":"u_normal_matrix";for(let o=0;o<n.instancedDataArray.length;++o)m[a]=new Float32Array(n.instancedDataArray.arrayBuffer,64*o,16),f.draw(i,h.gl.TRIANGLES,d,t3.disabled,_,v,m,r.id,e.vertexBuffer,e.indexBuffer,e.segments,r.paint,i.transform.zoom,void 0,y)}}if(a.children)for(let h of a.children)e(i,r,h,n,o,s,l)}(i,a,e,r,y,f,aQ)}}}(i,r,a,n,"vector"===c.type?a.scope:""),void u();if(!c.loaded())return;if("batched-model"===c.type)return function(i,r,a,n){a.resetLayerRenderingStats(i);let o=i.context,s=i.transform,l=i.style.fog,h=i.shadowRenderer;if("mercator"!==s.projection.name)return e.w(`Drawing 3D landmark models for ${s.projection.name} projection is not yet implemented`);let u=i.transform.getFreeCameraOptions().position,c=e.c4([],[u.x,u.y,u.z],i.transform.worldSize),d=e.et([],c),p=e.bA([]),f=e.ec(s.center.lat,s.zoom),m=e.bq([],[1,1,1/f]);e.br(p,p,d);let _=a.paint.get("model-opacity").constantOr(1),g=new t2(o.gl.LEQUAL,t2.ReadWrite,i.depthRangeFor3D),y=new t2(o.gl.LEQUAL,t2.ReadOnly,i.depthRangeFor3D),x=new e.d8([1/0,1/0,1/0],[-1/0,-1/0,-1/0]),v="shadow"===i.renderPass,b=v&&h?h.getCurrentCascadeFrustum():s.getFrustum(s.scaleZoom(s.worldSize)),w=a.paint.get("model-front-cutoff"),T=w[2]<1,S=ii(i,a.paint.get("model-cutoff-fade-range")),E=a.getLayerRenderingStats();(function(e,i,r,a){let n=e.terrain?e.terrain.exaggeration():0,o=e.transform.zoom;for(let s of a){let a=i.getTile(s).getBucket(r);a&&(a.setFilter(r.filter),e.conflationActive&&a.updateReplacement(s,e.replacementSource),a.evaluateTransform(e,r),e.terrain&&n>0&&a.elevationUpdate(e.terrain,n,s,r.source),a.needsReEvaluation(e,o,r)&&a.evaluate(r))}})(i,r,a,n),function(){let u,d,I;T?(u=n.length-1,d=-1,I=-1):(u=0,d=n.length,I=1);let A=new Float64Array(16),C=e.cz(),M=new e.P(0,0);for(let P=u;P!==d;P+=I){let u=n[P],d=r.getTile(u).getBucket(a);if(!d||!d.uploaded)continue;let I=!1;h&&(I=0===h.getMaxCascadeForTile(u.toUnwrapped()));let z=s.calculatePosMatrix(u.toUnwrapped(),s.worldSize),R=d.modelTraits;!v&&T&&(e.bl(A,z),e.af(C,c,A),M.x=C[0],M.y=C[1]);let D=[];for(let r of(d.setFilter(a.filter),d.getNodesInfo())){if(r.hiddenByReplacement||!r.node.meshes)continue;let a=r.node,n=0;i.terrain&&a.elevation&&(n=a.elevation*i.terrain.exaggeration());let o=(()=>{let i=r.aabb;return x.min=[...i.min],x.max=[...i.max],x.min[2]+=n,x.max[2]+=n,e.af(x.min,x.min,z),e.af(x.max,x.max,z),x})(),l=r.evaluatedScale;if(l[0]<=1&&l[1]<=1&&l[2]<=1&&0===o.intersects(b))continue;if(!v&&T){let i=1/6;r.cameraCollisionOpacity=c[0]>o.min[0]&&c[0]<o.max[0]&&c[1]>o.min[1]&&c[1]<o.max[1]&&c[2]*f<o.max[2]&&a.footprint&&e.b$(M,a.footprint)?Math.max(r.cameraCollisionOpacity-i,0):Math.min(1,r.cameraCollisionOpacity+i)}
98let h=[...z],d=1/e.d6(u.canonical),p=a.anchor?a.anchor[0]:0,m=a.anchor?a.anchor[1]:0;e.br(h,h,[p*(l[0]-1)+r.evaluatedTranslation[0]*d,m*(l[1]-1)+r.evaluatedTranslation[1]*d,n+r.evaluatedTranslation[2]]),e.cp(l,e.ev)||e.cR(h,h,l);let g=e.aB([],h,a.matrix),y=e.aB([],s.expandedFarZProjMatrix,g),E=e.aB([],s.expandedFarZProjMatrix,h),I=e.aC([],[p,m,n,1],y)[2];a.hidden=!1;let A=_;v||(T&&(A*=r.cameraCollisionOpacity*function(i,r,a,n){if(r.pitch<20)return 1;let o=r.getWorldToCameraMatrix();e.aB(o,o,i);let s=e.bU(a.min[0],a.min[1],a.min[2],1),l=e.aC(e.ex(),s,o),h=l,u=l;s[1]=a.max[1],h=(l=e.aC(e.ex(),s,o))[1]<h[1]?l:h,u=l[1]>u[1]?l:u,s[0]=a.max[0],h=(l=e.aC(e.ex(),s,o))[1]<h[1]?l:h,u=l[1]>u[1]?l:u,s[1]=a.min[1],h=(l=e.aC(e.ex(),s,o))[1]<h[1]?l:h,u=l[1]>u[1]?l:u;let c=e.aA(n[0],0,1),d=100*r.pixelsPerMeter*e.aA(n[1],0,1),p=e.aA(n[2],0,1),f=e.ey(e.ex(),h,u,c),m=Math.tan(.5*r.fovX),_=-f[2]*m;if(0===d)return f[1]<-Math.abs(_)?p:1;let g=(-Math.abs(_)-f[1])/d,y=(e,i,r)=>(1-r)*e+r*i,x=e.aA(y(1,p,g),p,1);return y(1,x,e.aA((r.pitch-20)/20,0,1))}(h,s,r.aabb,w)),A*=function(i,r){let a=i.uniformValues.u_cutoff_params[0],n=i.uniformValues.u_cutoff_params[1],o=i.uniformValues.u_cutoff_params[2],s=i.uniformValues.u_cutoff_params[3];return n===a||s===o?1:e.aA(((r-a)/(n-a)-o)/(s-o),0,1)}(S,I)),0!==A?D.push({nodeInfo:r,depth:I,opacity:A,wvpForNode:y,wvpForTile:E,nodeModelMatrix:g,tileModelMatrix:h}):a.hidden=!0}for(let r of(v||D.sort((e,i)=>T&&(1!==e.opacity||1!==i.opacity)?1===e.opacity?-1:1===i.opacity?1:e.depth>i.depth?-1:1:e.depth<i.depth?-1:1),D)){let n=r.nodeInfo,u=n.node,c=e.aB([],m,r.tileModelMatrix);e.aB(c,p,c);let d=e.bl([],c);e.ed(d,d),e.cR(d,d,a0),c=e.aB(c,c,u.matrix);let f="light-beam"===i.renderPass,_="none"===a.paint.get("model-color-use-theme").constantOr("default"),x=R&e.ez.HasMapboxMeshFeatures,b=x?0:n.evaluatedRMEA[0][2];for(let e=0;e<u.meshes.length;++e){let p,m=u.meshes[e],w=e===u.lightMeshIndex,T=r.wvpForNode;if(w){if(!f&&!i.terrain&&i.shadowRenderer){i.currentLayer<i.firstLightBeamLayer&&(i.firstLightBeamLayer=i.currentLayer);continue}T=r.wvpForTile}else if(f)continue;let S={defines:[]},A=[];if(!v&&h&&(h.useNormalOffset=!!m.normalBuffer),aY(S.defines,A,m,i,_?null:a.lut),x||S.defines.push("DIFFUSE_SHADED"),I&&S.defines.push("SHADOWS_SINGLE_CASCADE"),E&&(v?E.numRenderedVerticesInShadowPass+=m.vertexArray.length:E.numRenderedVerticesInTransparentPass+=m.vertexArray.length),v){aJ(m,r.nodeModelMatrix,i,a);continue}let C=null;if(l){let e=aX(r.nodeModelMatrix,i.transform);if(C=new Float32Array(e),"globe"!==s.projection.name){let i=m.aabb.min,r=m.aabb.max,[a,n]=l.getOpacityForBounds(e,i[0],i[1],r[0],r[1]);S.overrideFog=a>=.05||n>=.05}}let M=m.material;M.occlusionTexture&&M.occlusionTexture.offsetScale&&(p=M.occlusionTexture.offsetScale,S.defines.push("OCCLUSION_TEXTURE_TRANSFORM"));let P=i.getOrCreateProgram("model",S);!v&&h&&h.setupShadowsFromMatrix(r.tileModelMatrix,P,h.useNormalOffset),i.uploadCommonUniforms(o,P,null,C);let z=M.pbrMetallicRoughness;z.metallicFactor=.9,z.roughnessFactor=.5;let R=at(new Float32Array(T),new Float32Array(c),new Float32Array(d),new Float32Array(u.matrix),i,r.opacity,z.baseColorFactor,M.emissiveFactor,z.metallicFactor,z.roughnessFactor,M,b,a,[0,0,0],p);!w&&(n.hasTranslucentParts||r.opacity<1)&&P.draw(i,o.gl.TRIANGLES,g,t3.disabled,t1.disabled,t5.backCCW,R,a.id,m.vertexBuffer,m.indexBuffer,m.segments,a.paint,i.transform.zoom,void 0,A),P.draw(i,o.gl.TRIANGLES,w?y:g,t3.disabled,w||r.opacity<1||n.hasTranslucentParts?t1.alphaBlended:t1.unblended,t5.backCCW,R,a.id,m.vertexBuffer,m.indexBuffer,m.segments,a.paint,i.transform.zoom,void 0,A)}}}}()}(i,r,a,n),void u();if("model"!==c.type)return;let d=c.getModels(),p=[],f=i.transform.getFreeCameraOptions().position,m=e.c4([],[f.x,f.y,f.z],i.transform.worldSize);e.et(m,m);let _=[],g=[],y=0;for(let r of d){let n=a.paint.get("model-rotation").constantOr(null),o=a.paint.get("model-scale").constantOr(null),s=a.paint.get("model-translation").constantOr(null);r.computeModelMatrix(i,n,o,s,!0,!0,!1);let l=e.bA([]),h=e.ec(r.position.lat,i.transform.zoom),u=e.bq([],[1,1,1/h]);for(let a of(e.br(l,l,m),p.push({zScaleMatrix:u,negCameraPosMatrix:l}),r.nodes))!function i(r,a,n,o,s,l,h){let u;u="globe"===r.projection.name?e.eu(n,r):[...n],e.aB(u,u,a.matrix
98);let c=e.aB([],o,u);if(a.meshes)for(let i of a.meshes){if("BLEND"!==i.material.alphaMode){h.push({mesh:i,depth:0,modelIndex:s,worldViewProjection:c,nodeModelMatrix:u});continue}let a=e.af([],i.centroid,c);!r.isOrthographic&&a[2]<=0||l.push({mesh:i,depth:a[2],modelIndex:s,worldViewProjection:c,nodeModelMatrix:u})}if(a.children)for(let e of a.children)i(r,e,n,o,s,l,h)}(i.transform,a,r.matrix,i.transform.expandedFarZProjMatrix,y,_,g);y++}if(_.sort((e,i)=>i.depth-e.depth),"shadow"!==i.renderPass){if(1===o)for(let e of g)aK(e,i,a,p[e.modelIndex],t3.disabled,i.colorModeForRenderPass());else{for(let e of g)aK(e,i,a,p[e.modelIndex],t3.disabled,t1.disabled);for(let e of g)aK(e,i,a,p[e.modelIndex],i.stencilModeFor3D(),i.colorModeForRenderPass());i.resetStencilClippingMasks()}for(let e of _)aK(e,i,a,p[e.modelIndex],t3.disabled,i.colorModeForRenderPass());u()}else{for(let e of g)aJ(e.mesh,e.nodeModelMatrix,i,a);for(let e of _)aJ(e.mesh,e.nodeModelMatrix,i,a);u()}}},nl={line:function(e,i,r){if(e.hasElevatedBuckets=!1,e.hasNonElevatedBuckets=!1,void 0!==e._unevaluatedLayout.getValue("line-elevation-reference")||void 0!==e._unevaluatedLayout.getValue("line-z-offset")){if(i)for(let r of i.getVisibleCoordinates()){let a=i.getTile(r).getBucket(e);if(a&&("none"!==a.elevationType?e.hasElevatedBuckets=!0:e.hasNonElevatedBuckets=!0,e.hasElevatedBuckets&&e.hasNonElevatedBuckets))break}}else e.hasNonElevatedBuckets=!0},model:function(e,i,r){let a=i.getSource();if(a.loaded()){if("vector"===a.type||"geojson"===a.type)return void(r.modelManager&&r.modelManager.upload(r,"vector"===a.type?e.scope:""));if("batched-model"!==a.type&&"model"===a.type)for(let e of a.getModels())e.upload(r.context)}},raster:function(e,i,r){let a=i.getSource();if(!(a instanceof eK&&a.loaded()))return;let n=e.sourceLayer||a.rasterLayerIds&&a.rasterLayerIds[0];if(!n)return;let o=e.paint.get("raster-array-band")||a.getInitialBand(n);if(null!=o)for(let r of i.getIds().map(e=>i.getTileByID(e)))r.updateNeeded(e.id,o)&&a.prepareTile(r,n,e.id,o)},"raster-particle":function(e,i,r){let a=i.getSource();if(!(a instanceof eK&&a.loaded()))return;let n=e.sourceLayer||a.rasterLayerIds&&a.rasterLayerIds[0];if(!n)return;let o=e.paint.get("raster-particle-array-band")||a.getInitialBand(n);if(null!=o)for(let r of i.getIds().map(e=>i.getTileByID(e)))r.updateNeeded(e.id,o)&&a.prepareTile(r,n,e.id,o)}},nh={fill:am},nu={fill:function(e,i,r,a){if(!r.layout||"none"===r.layout.get("fill-elevation-reference"))return;let n=e.context.gl,o=new t2(n.LEQUAL,t2.ReadOnly,e.depthRangeFor3D),s=new t3({func:n.ALWAYS,mask:255},255,255,n.KEEP,n.KEEP,n.REPLACE),l=e.transform.getFreeCameraOptions().position,h=e.getOrCreateProgram("elevatedStructuresDepthReconstruct");for(let u of a){let a=i.getTile(u),c=a.getBucket(r);if(!c)continue;let d=c.elevatedStructures;if(!d||0===d.depthSegments.segments[0].primitiveLength)continue;let p=af(u.toUnwrapped(),l),f=rH(e.translatePosMatrix(u.projMatrix,a,r.paint.get("fill-translate"),r.paint.get("fill-translate-anchor")),p,0,1,0);h.draw(e,n.TRIANGLES,o,s,t1.disabled,t5.disabled,f,r.id,d.vertexBuffer,d.indexBuffer,d.depthSegments,r.paint,e.transform.zoom)}}};class nc{constructor(i,r,a,n,o,s){this.context=new al(i,r),this.transform=a,this._tileTextures={},this.frameCopies=[],this.loadTimeStamps=[],this.tp=o,this._timeStamp=e.o.now(),this._averageFPS=0,this._fpsHistory=[],this._dt=0,this._debugParams={forceEnablePrecipitation:!1,showTerrainProxyTiles:!1,fpsWindow:30,continousRedraw:!1,enabledLayers:{}};let l=["fill","line","symbol","circle","heatmap","fill-extrusion","building","raster","raster-particle","hillshade","model","background","sky"];for(let e of l)this._debugParams.enabledLayers[e]=!0;for(let e of(o.registerParameter(this._debugParams,["Terrain"],"showTerrainProxyTiles",{},()=>{this.style.map.triggerRepaint()}),o.registerParameter(this._debugParams,["Precipitation"],"forceEnablePrecipitation"),o.registerParameter(this._debugParams,["FPS"],"fpsWindow",{min:1,max:100,step:1}),o.registerBinding(this._debugParams,["FPS"],"continousRedraw",{readonly:!0,label:"continuous redraw"}),o.registerBinding(this,["FPS"],"_averageFPS",{readonly:!0,label:"value"}),o.registerBinding(this,["FPS"],"_averageFPS",{readonly:!0,label:"graph",view:"graph",min:0,max:200}),l))o.registerParameter(this._debugParams.enabledLayers,["Debug","Layers"],e);this.occlusionParams=new a3(o),this.setup(),this.numSublayers=ta.maxUnderzooming+ta.maxOverzooming+1,this.depthEpsilon=1/65536,this.deferredRenderGpuTimeQueries=[],this.gpuTimers={},this.frameCounter=0,this._backgroundTiles={},this.conflationActive=!1,this.replacementSource=new e.eG,this.longestCutoffRange=0,this.minCutoffZoom=0,this._fogVisible=!1,this._cachedTileFogOpacities={},this._shadowRenderer=new is(this),this._wireframeDebugCache=new a2,this.renderDefaultNorthPole=!0,this.renderDefaultSouthPole=!0,this.layersWithOcclusionOpacity=[];let h=new e.q({width:1,height:1},Uint8Array.of(0,0,0,0));
98this.emptyDepthTexture=new e.T(this.context,h,i.RGBA8),this._clippingActiveLastFrame=!1,this.scaleFactor=n,this.worldview=s}updateTerrain(e,i){let r=!!e&&!!e.terrain&&this.transform.projection.supportsTerrain;if(!(r||this._terrain&&this._terrain.enabled))return;this._terrain||(this._terrain=new rz(this,e));let a=this._terrain;this.transform.elevation=r?a:null,a.update(e,this.transform,i),this.transform.elevation&&!a.enabled&&(this.transform.elevation=null)}_updateFog(e){let i=e.fog;if(!i||"globe"===this.transform.projection.name||1>i.getOpacity(this.transform.pitch)||.03>i.properties.get("horizon-blend"))return void(this.transform.fogCullDistSq=null);let[r,a]=i.getFovAdjustedRange(this.transform._fov);if(r>a)return void(this.transform.fogCullDistSq=null);let n=r+.78*(a-r);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 rz(this,this.style)),this._forceTerrainMode=e}get shadowRenderer(){return this._shadowRenderer&&this._shadowRenderer.enabled?this._shadowRenderer:null}get wireframeDebugCache(){return this._wireframeDebugCache}resize(i,r){if(this.width=i*e.o.devicePixelRatio,this.height=r*e.o.devicePixelRatio,this.context.viewport.set([0,0,this.width,this.height]),this.style)for(let e of this.style.order)this.style._mergedLayers[e].resize()}setup(){let i=this.context,r=new e.bd;r.emplaceBack(0,0),r.emplaceBack(e.al,0),r.emplaceBack(0,e.al),r.emplaceBack(e.al,e.al),this.tileExtentBuffer=i.createVertexBuffer(r,e.bf.members),this.tileExtentSegments=e.bg.simpleSegment(0,0,4,2);let a=new e.bd;a.emplaceBack(0,0),a.emplaceBack(e.al,0),a.emplaceBack(0,e.al),a.emplaceBack(e.al,e.al),this.debugBuffer=i.createVertexBuffer(a,e.bf.members),this.debugSegments=e.bg.simpleSegment(0,0,4,5);let n=new e.bd;n.emplaceBack(-1,-1),n.emplaceBack(1,-1),n.emplaceBack(-1,1),n.emplaceBack(1,1),this.viewportBuffer=i.createVertexBuffer(n,e.bf.members),this.viewportSegments=e.bg.simpleSegment(0,0,4,2);let o=new e.b0;o.emplaceBack(0,0,0,0),o.emplaceBack(e.al,0,e.al,0),o.emplaceBack(0,e.al,0,e.al),o.emplaceBack(e.al,e.al,e.al,e.al),this.mercatorBoundsBuffer=i.createVertexBuffer(o,e.bi.members),this.mercatorBoundsSegments=e.bg.simpleSegment(0,0,4,2);let s=new e.b1;s.emplaceBack(0,1,2),s.emplaceBack(2,1,3),this.quadTriangleIndexBuffer=i.createIndexBuffer(s);let l=new e.be;for(let e of[0,1,3,2,0])l.emplaceBack(e);this.debugIndexBuffer=i.createIndexBuffer(l),this.emptyTexture=new e.T(i,new e.q({width:1,height:1},Uint8Array.of(0,0,0,0)),i.gl.RGBA8),this.identityMat=e.bC();let h=this.context.gl;this.stencilClearMode=new t3({func:h.ALWAYS,mask:0},0,255,h.ZERO,h.ZERO,h.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(){let e=this.context.gl;this.nextStencilID=1,this.currentStencilSource=void 0,this._tileClippingMaskIDs={},this.getOrCreateProgram("clippingMask").draw(this,e.TRIANGLES,t2.disabled,this.stencilClearMode,t1.disabled,t5.disabled,rI(this.identityMat),"$clipping",this.viewportBuffer,this.quadTriangleIndexBuffer,this.viewportSegments)}resetStencilClippingMasks(){this.terrain||(this.currentStencilSource=void 0,this._tileClippingMaskIDs={})}_renderTileClippingMasks(e,i,r){if(!i||this.currentStencilSource===i.id||!e.isTileClipped()||!r||0===r.length)return;if(this._tileClippingMaskIDs&&!this.terrain){let e=!1;for(let i of r)if(void 0===this._tileClippingMaskIDs[i.key]){e=!0;break}if(!e)return}this.currentStencilSource=i.id;let a=this.context,n=a.gl;this.nextStencilID+r.length>256&&this.clearStencil(),a.setColorMode(t1.disabled),a.setDepthMode(t2.disabled);let o=this.getOrCreateProgram("clippingMask");for(let e of(this._tileClippingMaskIDs={},r)){let r=i.getTile(e),a=this._tileClippingMaskIDs[e.key]=this.nextStencilID++,{tileBoundsBuffer:s,tileBoundsIndexBuffer:l,tileBoundsSegments:h}=this.getTileBoundsBuffers(r);o.draw(this,n.TRIANGLES,t2.disabled,new t3({func:n.ALWAYS,mask:0},a,255,n.KEEP,n.KEEP,n.REPLACE),t1.disabled,t5.disabled,rI(e.projMatrix),"$clipping",s,l,h)}}stencilModeFor3D(){this.currentStencilSource=void 0,this.nextStencilID+1>256&&this.clearStencil();let e=this.nextStencilID++,i=this.context.gl;return new t3({func:i.NOTEQUAL,mask:255},e,255,i.KEEP,i.KEEP,i.REPLACE)}stencilModeForClipping(e){if(this.terrain)return this.terrain.stencilModeForRTTOverlap(e);let i=this.context.gl;return new t3({func:i.EQUAL,mask:255},this._tileClippingMaskIDs[e.key],0,i.KEEP,i.KEEP,i.REPLACE)}stencilConfigForOverlap(e){let i=this.context.gl,r=e.sort((e,i)=>
98i.overscaledZ-e.overscaledZ),a=r[r.length-1].overscaledZ,n=r[0].overscaledZ-a+1;if(n>1){this.currentStencilSource=void 0,this.nextStencilID+n>256&&this.clearStencil();let e={};for(let r=0;r<n;r++)e[r+a]=new t3({func:i.GEQUAL,mask:255},r+this.nextStencilID,255,i.KEEP,i.KEEP,i.REPLACE);return this.nextStencilID+=n,[e,r]}return[{[a]:t3.disabled},r]}colorModeForRenderPass(){let i=this.context.gl;if(this._showOverdrawInspector){let r=1/8;return new t1([i.CONSTANT_COLOR,i.ONE,i.CONSTANT_COLOR,i.ONE],new e.ao(r,r,r,0),[!0,!0,!0,!0])}return"opaque"===this.renderPass?t1.unblended:t1.alphaBlended}colorModeForDrapableLayerRenderPass(i){let r=this.context.gl;return this.style&&this.style.enable3dLights()&&this.terrain&&this.terrain.renderingToTexture&&"translucent"===this.renderPass?new t1([r.ONE,r.ONE_MINUS_SRC_ALPHA,r.CONSTANT_ALPHA,r.ONE_MINUS_SRC_ALPHA],new e.ao(0,0,0,void 0===i?0:i),[!0,!0,!0,!0]):this.colorModeForRenderPass()}depthModeForSublayer(e,i,r,a=!1){if(this.depthOcclusion)return new t2(this.context.gl.GREATER,t2.ReadOnly,this.depthRangeFor3D);if(!this.opaquePassEnabledForLayer()&&!a)return t2.disabled;let n=1-((1+this.currentLayer)*this.numSublayers+e)*this.depthEpsilon;return new t2(r||this.context.gl.LEQUAL,i,[n,n])}opaquePassEnabledForLayer(){return this.currentLayer<this.opaquePassCutoff}blitDepth(){let i=this.context.gl,r=Math.ceil(this.width),a=Math.ceil(this.height),n=this.context.bindFramebuffer.get(),o=i.getParameter(i.TEXTURE_BINDING_2D);this.depthFBO&&this.depthFBO.width===r&&this.depthFBO.height===a||(this.depthFBO&&(this.depthFBO.destroy(),this.depthFBO=void 0,this.depthTexture=void 0),0!==r&&0!==a&&(this.depthFBO=new as(this.context,r,a,!1,"texture"),this.depthTexture=new e.T(this.context,{width:r,height:a,data:null},i.DEPTH24_STENCIL8),this.depthFBO.depthAttachment.set(this.depthTexture.texture))),this.context.bindFramebuffer.set(n),i.bindTexture(i.TEXTURE_2D,o),this.depthFBO&&(i.bindFramebuffer(i.READ_FRAMEBUFFER,null),i.bindFramebuffer(i.DRAW_FRAMEBUFFER,this.depthFBO.framebuffer),i.blitFramebuffer(0,0,r,a,0,0,r,a,i.DEPTH_BUFFER_BIT,i.NEAREST),i.bindFramebuffer(i.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,i)=>e+i/this._fpsHistory.length,0))}render(i,r){let a=e.o.now();this._dt=a-this._timeStamp,this._timeStamp=a,this._wireframeDebugCache.update(this.frameCounter),this._debugParams.continousRedraw=i.map.repaint,this.style=i,this.options=r;let n=this.style._mergedLayers,o=!(!this.terrain||!this.terrain.enabled),s=()=>this.style._getOrder(o).filter(e=>{let i=n[e];return!(i.type in this._debugParams.enabledLayers)||this._debugParams.enabledLayers[i.type]}
98),l=s(),h=!1,u=!1,c=null;for(let e of l){let i=n[e];"circle"===i.type?h=!0:"building"===i.type?c=i:"symbol"===i.type&&(i.hasOcclusionOpacityProperties?u=!0:h=!0)}let d=l.map(e=>n[e]),p=this.style._mergedSourceCaches;this.imageManager=i.imageManager,this.modelManager=i.modelManager,this.symbolFadeChange=i.placement.symbolFadeChange(e.o.now()),this.imageManager.beginFrame();let f=0,m=!1;for(let e in p){let i=p[e];i.used&&(i.prepare(this.context),i.getSource().usedInConflation&&++f)}let _=!1;for(let e of d)e.isHidden(this.transform.zoom)||("clip"===e.type&&(_=!0),this.prepareLayer(e));let g={},y={},x={},v={},b={};for(let e in p){let i=p[e];g[e]=i.getVisibleCoordinates(),y[e]=g[e].slice().reverse(),x[e]=i.getVisibleCoordinates(!0).reverse(),v[e]=i.getShadowCasterCoordinates(),b[e]=i.sortCoordinatesByDistance(g[e])}let w=e=>{let i=this.style.getLayerSourceCache(e);return i&&i.used?i.getSource():null};if(f||_||this._clippingActiveLastFrame){let i=[],r=[],a=0;for(let e of d)this.isSourceForClippingOrConflation(e,w(e))&&(i.push(e),r.push(a)),a++;if(i&&(_||i.length>1)||this._clippingActiveLastFrame){_=!1;let a=[];for(let n=0;n<i.length;n++){let o=i[n],s=r[n],l=this.style.getLayerSourceCache(o);if(!l||!l.used||!l.getSource().usedInConflation&&"clip"!==o.type&&"building"!==o.type)continue;let h=e.eH,u=e.bZ.None,c=[],d=!0;if("building"===o.type)h=e.eJ;else if("clip"===o.type){for(let i of(h=s,o.layout.get("clip-layer-types")))u|="model"===i?e.bZ.Model:"symbol"===i?e.bZ.Symbol:e.bZ.FillExtrusion;for(let e of o.layout.get("clip-layer-scope"))c.push(e);o.isHidden(this.transform.zoom)?d=!1:_=!0}d&&a.push({layer:o.fqid,cache:l,order:h,clipMask:u,clipScope:c})}this.replacementSource.setSources(a),m=!0}}this._clippingActiveLastFrame=_,m||this.replacementSource.clear(),this.conflationActive=m,this.minCutoffZoom=0,this.longestCutoffRange=0,this.opaquePassCutoff=1/0,this._lastOcclusionLayer=-1,this.layersWithOcclusionOpacity=[];for(let e=0;e<d.length;e++){let i=d[e],r=i.cutoffRange();if(this.longestCutoffRange=Math.max(r,this.longestCutoffRange),r>0){let e=w(i);e&&(this.minCutoffZoom=Math.max(e.minzoom,this.minCutoffZoom)),i.minzoom&&(this.minCutoffZoom=Math.max(i.minzoom,this.minCutoffZoom))}i.is3D(o)&&(this.opaquePassCutoff===1/0&&(this.opaquePassCutoff=e),this._lastOcclusionLayer=e)}let T=this.style&&this.style.fog;T?(this._fogVisible=0!==T.getOpacity(this.transform.pitch),this._fogVisible&&"globe"!==this.transform.projection.name&&(this._fogVisible=T.isVisibleOnFrustum(this.transform.cameraFrustum))):this._fogVisible=!1,this._cachedTileFogOpacities={},this.terrain&&(this.terrain.updateTileBinding(x),this.opaquePassCutoff=0,d=(l=s()).map(e=>n[e]));let S=this._shadowRenderer;if(S)for(let e in S.updateShadowParameters(this.transform,this.style.directionalLight),p)for(let i of g[e]){let e={min:0,max:0};this.terrain&&(e=this.terrain.getMinMaxForTile(i)||e),S.addShadowReceiver(i.toUnwrapped(),e.min,e.max)}"globe"!==this.transform.projection.name||this.globeSharedBuffers||(this.globeSharedBuffers=new e.eI(this.context)),this.style.fog&&this.transform.projection.supportsFog?(this._atmosphere||(this._atmosphere=new aZ(this)),this._atmosphere.update(this)):this._atmosphere&&(this._atmosphere.destroy(),this._atmosphere=void 0);let E=this._debugParams.forceEnablePrecipitation||!(!this.style||!this.style.snow),I=this._debugParams.forceEnablePrecipitation||!(!this.style||!this.style.rain);if(E&&!this._snow&&(this._snow=new no(this)),!E&&this._snow&&(this._snow.destroy(),delete this._snow),I&&!this._rain&&(this._rain=new na(this)),!I&&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 aW);let e=this.style.getLayerSourceCache(c);this.buildingTileBorderManager.updateBorders(e,c)}if(!j.has(this.context.gl))return;for(let e of(this.renderPass="offscreen",d)){let r=i.getLayerSourceCache(e);if(!e.hasOffscreenPass()||e.isHidden(this.transform.zoom))continue;let a=r?y[r.id]:void 0;("custom"===e.type||"raster"===e.type||"raster-particle"===e.type||e.isSky()||a&&a.length)&&this.renderLayer(this,r,e,a)}this.depthRangeFor3D=[0,1-(d.length+2)*this.numSublayers*this.depthEpsilon],this._shadowRenderer&&(this.renderPass="shadow",this._shadowRenderer.drawShadowPass(this.style,v)),this.context.bindFramebuffer.set(null),this.context.viewport.set([0,0,this.width,this.height]);let A="globe"===this.transform.projection.name||this.transform.isH
98orizonVisible(),C=(()=>{if(r.showOverdrawInspector)return e.ao.black;let i=this.style.fog;if(i&&this.transform.projection.supportsFog){let r=this.style.getLut(i.scope);if(!A){let a="none"===i.properties.get("color-use-theme"),n=i.properties.get("color").toNonPremultipliedRenderColor(a?null:r).toArray01();return new e.ao(...n)}if(A){let a="none"===i.properties.get("space-color-use-theme"),n=i.properties.get("space-color").toNonPremultipliedRenderColor(a?null:r).toArray01();return new e.ao(...n)}}return e.ao.transparent})();if(this.context.clear({color:C,depth:1}),this.clearStencil(),this._showOverdrawInspector=r.showOverdrawInspector,this.renderPass="opaque",this.style.fog&&this.transform.projection.supportsFog&&this._atmosphere&&!this._showOverdrawInspector&&A&&this._atmosphere.drawStars(this,this.style.fog),!this.terrain)for(this.currentLayer=l.length-1;this.currentLayer>=0;this.currentLayer--){let e=d[this.currentLayer],r=i.getLayerSourceCache(e);if(e.isSky())continue;let a=r?(e.is3D(o)?b:y)[r.id]:void 0;this._renderTileClippingMasks(e,r,a),this.renderLayer(this,r,e,a)}if(this.style.fog&&this.transform.projection.supportsFog&&this._atmosphere&&!this._showOverdrawInspector&&A&&this._atmosphere.drawAtmosphereGlow(this,this.style.fog),this.renderPass="sky",(!this._atmosphere||e.aj(this.transform.zoom)>0)&&("globe"===this.transform.projection.name||this.transform.isHorizonVisible()))for(this.currentLayer=0;this.currentLayer<l.length;this.currentLayer++){let e=d[this.currentLayer],r=i.getLayerSourceCache(e);e.isSky()&&this.renderLayer(this,r,e,r?y[r.id]:void 0)}function M(e,i){let r;return i&&(r=("symbol"===e.type?x:e.is3D(o)?b:y)[i.id]),r}if(this.renderPass="translucent","globe"===this.transform.projection.name){for(this.renderElevatedRasterBackface=!0,this.currentLayer=0;this.currentLayer<l.length;){let e=d[this.currentLayer];if("raster"===e.type||"raster-particle"===e.type){let r=i.getLayerSourceCache(e);this.renderLayer(this,r,e,M(e,r))}++this.currentLayer}this.renderElevatedRasterBackface=!1}this.currentLayer=0,this.firstLightBeamLayer=Number.MAX_SAFE_INTEGER;let P=0;S&&(P=S.getShadowCastingLayerCount());let z=!1,R=-1;for(let e=0;e<l.length;++e){let i=d[e];i.isHidden(this.transform.zoom)||i.is3D(o)&&(R=e)}u&&-1===R&&(h=!0);let D=!1;for(;this.currentLayer<l.length;){let e=d[this.currentLayer],r=i.getLayerSourceCache(e);if(e.isSky())++this.currentLayer;else if(this.terrain&&this.style.isLayerDraped(e)){if(e.isHidden(this.transform.zoom)){++this.currentLayer;continue}this.currentLayer=this.terrain.renderBatch(this.currentLayer),this._lastOcclusionLayer=Math.max(this.currentLayer,this._lastOcclusionLayer)}else{if(!D&&e.is3D(o)&&!o){let e=this.currentLayer,i=e=>{for(this.currentLayer=0;this.currentLayer<d.length;this.currentLayer++){let i=d[this.currentLayer];if(nh[i.type]){let r=this.style.getLayerSourceCache(i);nh[i.type](this,r,i,M(i,r),e)}}};i("initialize"),i("reset"),this.currentLayer=e,D=!0}if(h&&!z&&this.terrain&&!this.transform.isOrthographic&&(z=!0,this.blitDepth()),u&&-1!==R&&this.currentLayer===R+1&&!this.transform.isOrthographic&&this.blitDepth(),this.terrain||this._renderTileClippingMasks(e,r,r?g[r.id]:void 0),this.renderLayer(this,r,e,M(e,r)),!this.terrain&&S&&P>0&&e.hasShadowPass()&&0==--P){{this.clearStencil(),this.resetStencilClippingMasks();let e=this.currentLayer;for(this.currentLayer=0;this.currentLayer<d.length;this.currentLayer++){let e=d[this.currentLayer];if(nu[e.type]){let i=this.style.getLayerSourceCache(e);nu[e.type](this,i,e,M(e,i))}}this.currentLayer=e}if(S.drawGroundShadows(),this.firstLightBeamLayer<=this.currentLayer){let e=this.currentLayer;for(this.renderPass="light-beam",this.currentLayer=this.firstLightBeamLayer;this.currentLayer<=e;this.currentLayer++){let e=d[this.currentLayer];if(!e.hasLightBeamPass())continue;let r=i.getLayerSourceCache(e);this.renderLayer(this,r,e,r?y[r.id]:void 0)}this.currentLayer=e,this.renderPass="translucent"}}if(this.currentLayer>=this._lastOcclusionLayer&&this.layersWithOcclusionOpacity.length>0){let e=this.currentLayer;for(let e of(this.depthOcclusion=!0,this.layersWithOcclusionOpacity)){this.currentLayer=e;let r=d[this.currentLayer],a=i.getLayerSourceCache(r),n=a?y[a.id]:void 0;this.terrain||this._renderTileClippingMasks(r,a,a?g[a.id]:void 0),this.renderLayer(this,a,r,n)}this.depthOcclusion=!1,this.currentLayer=e,this.renderPass="translucent",this.layersWithOcclusionOpacity=[]}++this.currentLayer}}if(this.terrain&&this.terrain.postRender(),this._snow&&this._snow.draw(this),this._rain&&this._rain.draw(this),this.options.showTileBoundaries||this.options.showQueryGeometry||this.options.showTileAABBs){let r=null;
98d.forEach(e=>{let a=i.getLayerSourceCache(e);a&&!e.isHidden(this.transform.zoom)&&a.getVisibleCoordinates().length&&(!r||r.getSource().maxzoom<a.getSource().maxzoom)&&(r=a)}),r&&this.options.showTileBoundaries&&aL(this,r,r.getVisibleCoordinates(),e.ao.red,!1,this.options.showParseStatus)}this.terrain&&this._debugParams.showTerrainProxyTiles&&aL(this,this.terrain.proxySourceCache,this.terrain.proxyCoords,new e.ao(1,.8,.1,1),!0,this.options.showParseStatus),this.options.showPadding&&function(e){var i,r;let a=e.transform.padding;aF(e,e.transform.height-(a.top||0),3,aM),aF(e,a.bottom||0,3,aP),ak(e,a.left||0,3,az),ak(e,e.transform.width-(a.right||0),3,aR);let n=e.transform.centerPoint;i=n.x,r=e.transform.height-n.y,aB(e,i-1,r-10,2,20,aD),aB(e,i-10,r-1,20,2,aD)}(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()),m||(this.conflationActive=!1)}prepareLayer(e){this.gpuTimingStart(e);let{unsupportedLayers:i}=this.transform.projection,r=!i||!i.includes(e.type);if(nl[e.type]&&(r||this.terrain&&"custom"===e.type)){let i=this.style.getLayerSourceCache(e);nl[e.type](e,i,this)}this.gpuTimingEnd()}renderLayer(e,i,r,a){r.isHidden(this.transform.zoom)||("background"===r.type||"sky"===r.type||"custom"===r.type||"model"===r.type||"raster"===r.type||"raster-particle"===r.type||a&&a.length)&&(this.id=r.id,this.gpuTimingStart(r),e.transform.projection.unsupportedLayers&&e.transform.projection.unsupportedLayers.includes(r.type)&&(!e.terrain||"custom"!==r.type)||"clip"===r.type||ns[r.type](e,i,r,a,this.style.placement.variableOffsets,this.options.isInitialLoad),this.gpuTimingEnd())}gpuTimingStart(e){if(!this.options.gpuTiming)return;let i=this.context.extTimerQuery,r=this.context.gl,a=this.gpuTimers[e.id];a||(a=this.gpuTimers[e.id]={calls:0,cpuTime:0,query:r.createQuery()}),a.calls++,r.beginQuery(i.TIME_ELAPSED_EXT,a.query)}gpuTimingDeferredRenderStart(){if(this.options.gpuTimingDeferredRender){let e=this.context.extTimerQuery,i=this.context.gl,r=i.createQuery();this.deferredRenderGpuTimeQueries.push(r),i.beginQuery(e.TIME_ELAPSED_EXT,r)}}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(){let e=this.gpuTimers;return this.gpuTimers={},e}collectDeferredRenderGpuQueries(){let e=this.deferredRenderGpuTimeQueries;return this.deferredRenderGpuTimeQueries=[],e}queryGpuTimers(e){let i={};for(let r in e){let a=e[r],n=this.context.extTimerQuery,o=n.getQueryParameter(a.query,this.context.gl.QUERY_RESULT)/1e6;n.deleteQueryEXT(a.query),i[r]=o}return i}queryGpuTimeDeferredRender(e){if(!this.options.gpuTimingDeferredRender)return 0;let i=this.context.gl,r=0;for(let a of e)r+=i.getQueryParameter(a,i.QUERY_RESULT)/1e6,i.deleteQuery(a);return r}translatePosMatrix(i,r,a,n,o){if(!a[0]&&!a[1])return i;let s=o?"map"===n?this.transform.angle:0:"viewport"===n?-this.transform.angle:0;if(s){let e=Math.sin(s),i=Math.cos(s);a=[a[0]*i-a[1]*e,a[0]*e+a[1]*i]}let l=[o?a[0]:e.ay(r,a[0],this.transform.zoom),o?a[1]:e.ay(r,a[1],this.transform.zoom),0],h=new Float32Array(16);return e.br(h,i,l),h}saveTileTexture(e){if(e.context!==this.context)return;let i=e.size[0],r=this._tileTextures[i];r?r.push(e):this._tileTextures[i]=[e]}getTileTexture(e){let i=this._tileTextures[e];return i&&i.length>0?i.pop():null}terrainRenderModeElevated(){return this.style&&!!this.style.getTerrain()&&!!this.terrain&&!this.terrain.renderingToTexture||this.forceTerrainMode}linearFloatFilteringSupported(){return null!=this.context.extTextureFloatLinear}currentGlobalDefines(e,i,r){let a=void 0===r?this.terrain&&this.terrain.renderingToTexture:r,n=[];return this.style&&this.style.enable3dLights()&&("globeRaster"===e||"terrainRaster"===e?(n.push("LIGHTING_3D_MODE"),n.push("LIGHTING_3D_ALPHA_EMISSIVENESS")):a||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&&!a&&(void 0===i||i)&&n.push("FOG","FOG_DITHERING"),a&&n.push("RENDER_TO_TEXTURE"),this._showOverdrawInspector&&n.push("OVERDRAW_INSPECTOR"),n}getOrCreateProgram(e,i){this.cache=this.cache||{};let r=i&&i.defines||[],a=i&&i.config,n=this.currentGlobalDefines(e,i&&i.overrideFog,i&&i.overrideRtt).concat(r),o=rL.cacheKey(ij[e],e,n,a);
98return this.cache[o]||(this.cache[o]=new rL(this.context,e,ij[e],a,ar[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(){let e=this.context.gl;this.context.cullFace.set(!1),this.context.viewport.set([0,0,this.width,this.height]),this.context.blendEquation.set(e.FUNC_ADD)}initDebugOverlayCanvas(){null==this.debugOverlayCanvas&&(this.debugOverlayCanvas=document.createElement("canvas"),this.debugOverlayCanvas.width=512,this.debugOverlayCanvas.height=512,this.debugOverlayTexture=new e.T(this.context,this.debugOverlayCanvas,this.context.gl.RGBA8))}destroy(){this._terrain&&this._terrain.destroy(),this._atmosphere&&(this._atmosphere.destroy(),this._atmosphere=void 0),this.globeSharedBuffers&&this.globeSharedBuffers.destroy(),this.emptyTexture.destroy(),this.debugOverlayTexture&&this.debugOverlayTexture.destroy(),this._wireframeDebugCache.destroy(),this.depthFBO&&(this.depthFBO.destroy(),this.depthFBO=void 0,this.depthTexture=void 0),this.emptyDepthTexture&&this.emptyDepthTexture.destroy()}prepareDrawTile(){this.terrain&&this.terrain.prepareDrawTile()}uploadCommonLightUniforms(i,r){if(this.style.enable3dLights()){let a=this.style.directionalLight,n=this.style.ambientLight;if(a&&n){let o=((i,r,a)=>{let n=i.properties.get("direction"),o="none"===i.properties.get("color-use-theme"),s=i.properties.get("color").toNonPremultipliedRenderColor(o?null:a.getLut(i.scope)).toArray01(),l=i.properties.get("intensity"),h="none"===r.properties.get("color-use-theme"),u=r.properties.get("color").toNonPremultipliedRenderColor(h?null:a.getLut(r.scope)).toArray01(),c=r.properties.get("intensity"),d=[n.x,n.y,n.z],p=e.dK(u,c),f=e.dK(s,l);return{u_lighting_ambient_color:p,u_lighting_directional_dir:d,u_lighting_directional_color:f,u_ground_radiance:function(i,r,a){let n=function(i,r,a){let n=e.bJ(r,i),o=e.bJ(a,[.2126,.7152,.0722]),s=(e,i,r)=>(1-r)*e+r*i,l=s(1-.3*Math.min(o,1),1,Math.min(n+1,1));return s(.92,1,Math.asin(e.aA(r[2],-1,1))/Math.PI+.5)*l}(i,[0,0,1],r),o=[0,0,0];e.c4(o,a.slice(0,3),n);let s=[0,0,0];e.c4(s,r.slice(0,3),i[2]);let l=[0,0,0];return e.d7(l,o,s),e.da(l)}(d,f,p)}})(a,n,this.style);r.setLightsUniformValues(i,o)}}}uploadCommonUniforms(i,r,a,n,o){if(this.uploadCommonLightUniforms(i,r),this.terrain&&this.terrain.renderingToTexture)return;let s=this.style.fog;if(s){let o=s.getOpacity(this.transform.pitch),l=((i,r,a,n,o,s,l,h,u,c,d,p)=>{let f=i.transform,m="none"===r.properties.get("color-use-theme"),_=r.properties.get("color").toNonPremultipliedRenderColor(m?null:i.style.getLut(r.scope)).toArray01();_[3]=n;let g=i.frameCounter/1e3%1,[y,x]=r.properties.get("vertical-range");return{u_fog_matrix:a?f.calculateFogTileMatrix(a):p||i.identityMat,u_fog_range:r.getFovAdjustedRange(f._fov),u_fog_color:_,u_fog_horizon_blend:r.properties.get("horizon-blend"),u_fog_vertical_limit:[Math.min(y,x),x],u_fog_temporal_offset:g,u_frustum_tl:o,u_frustum_tr:s,u_frustum_br:l,u_frustum_bl:h,u_globe_pos:u,u_globe_radius:c,u_viewport:d,u_globe_transition:e.aj(f.zoom),u_is_globe:+("globe"===f.projection.name)}})(this,s,a,o,this.transform.frustumCorners.TL,this.transform.frustumCorners.TR,this.transform.frustumCorners.BR,this.transform.frustumCorners.BL,this.transform.globeCenterInViewSpace,this.transform.globeRadius,[this.transform.width*e.o.devicePixelRatio,this.transform.height*e.o.devicePixelRatio],n);r.setFogUniformValues(i,l)}o&&r.setCutoffUniformValues(i,o.uniformValues)}setTileLoadedFlag(e){this.tileLoaded=e}saveCanvasCopy(){let e=this.canvasCopy();e&&(this.frameCopies.push(e),this.tileLoaded=!1)}canvasCopy(){let e=this.context.gl,i=e.createTexture();return e.bindTexture(e.TEXTURE_2D,i),e.copyTexImage2D(e.TEXTURE_2D,0,e.RGBA,0,0,e.drawingBufferWidth,e.drawingBufferHeight,0),i}getCanvasCopiesAndTimestamps(){return{canvasCopies:this.frameCopies,timeStamps:this.loadTimeStamps}}averageElevationNeedsEasing(){if(!this.transform._elevation)return!1;let e=this.style&&this.style.fog;return!!e&&0!==e.getOpacity(this.transform.pitch)}
98getBackgroundTiles(){let e=this._backgroundTiles,i=this._backgroundTiles={};for(let r of this.transform.coveringTiles({tileSize:512}))i[r.key]=e[r.key]||new te(r,512,this.transform.tileZoom,this,void 0,this.worldview);return i}clearBackgroundTiles(){this._backgroundTiles={}}isSourceForClippingOrConflation(e,i){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)&&(!i||"batched-model"!==i.type)))}isTileAffectedByFog(e){if(!this.style||!this.style.fog)return!1;if("globe"===this.transform.projection.name)return!0;let i=this._cachedTileFogOpacities[e.key];return i||(this._cachedTileFogOpacities[e.key]=i=this.style.fog.getOpacityForTile(e)),i[0]>=.05||i[1]>=.05}setupDepthForOcclusion(e,i,r){var a;let n=this.context,o=n.gl,s=!!r;r||(r={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}),n.activeTexture.set(o.TEXTURE3),e&&this.depthFBO&&this.depthTexture?(this.depthTexture.bind(o.NEAREST,o.CLAMP_TO_EDGE),r.u_depth_size_inv=[1/this.depthFBO.width,1/this.depthFBO.height],r.u_depth_range_unpack=[2/((a=this.depthRangeFor3D)[1]-a[0]),-1-2*a[0]/(a[1]-a[0])],r.u_occluder_half_size=.5*this.occlusionParams.occluderSize,r.u_occlusion_depth_offset=this.occlusionParams.depthOffset):this.emptyDepthTexture.bind(o.NEAREST,o.CLAMP_TO_EDGE),n.activeTexture.set(o.TEXTURE0),s||i.setTerrainUniformValues(n,r)}}function nd(e,i){let r=!1,a=null,n=()=>{a=null,r&&(e(),a=setTimeout(n,i),r=!1)};return()=>(r=!0,a||n(),a)}class np{constructor(i){this._hashName=i&&encodeURIComponent(i),e.aY(["_getCurrentHash","_onHashChange","_updateHash"],this),this._updateHash=nd(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}getHashString(){let e=this._map;if(!e)return"";let i=nf(e);if(this._hashName){let e=this._hashName,r=!1,a=location.hash.slice(1).split("&").map(a=>{let n=a.split("=")[0];return n===e?(r=!0,`${n}=${i}`):a}).filter(e=>e);return r||a.push(`${e}=${i}`),`#${a.join("&")}`}return`#${i}`}_getCurrentHash(){let e=location.hash.replace("#","");if(this._hashName){let i;return e.split("&").map(e=>e.split("=")).forEach(e=>{e[0]===this._hashName&&(i=e)}),(i&&i[1]||"").split("/")}return e.split("/")}_onHashChange(){let e=this._map;if(!e)return!1;let i=this._getCurrentHash();if(i.length>=3&&!i.some(e=>isNaN(Number(e)))){let r=e.dragRotate.isEnabled()&&e.touchZoomRotate.isEnabled()?+(i[3]||0):e.getBearing();return e.jumpTo({center:[+i[2],+i[1]],zoom:+i[0],bearing:r,pitch:+(i[4]||0)}),!0}return!1}_updateHashUnthrottled(){history.replaceState(history.state,"",location.href.replace(/(#.+)?$/,this.getHashString()))}}function nf(e,i){let r=e.getCenter(),a=Math.round(100*e.getZoom())/100,n=Math.pow(10,Math.ceil((a*Math.LN2+Math.log(512/360/.5))/Math.LN10)),o=Math.round(r.lng*n)/n,s=Math.round(r.lat*n)/n,l=e.getBearing(),h=e.getPitch(),u=i?`/${o}/${s}/${a}`:`${a}/${s}/${o}`;return(l||h)&&(u+="/"+Math.round(10*l)/10),h&&(u+=`/${Math.round(h)}`),u}let nm={linearity:.3,easing:e.eK(0,0,.3,1)},n_=Object.assign({deceleration:2500,maxSpeed:1400},nm),ng=Object.assign({deceleration:20,maxSpeed:1400},nm),ny=Object.assign({deceleration:1e3,maxSpeed:360},nm),nx=Object.assign({deceleration:1e3,maxSpeed:90},nm);class nv{constructor(e){this._map=e,this.clear()}clear(){this._inertiaBuffer=[]}record(i){this._drainInertiaBuffer(),this._inertiaBuffer.push({time:e.o.now(),settings:i})}_drainInertiaBuffer(){let i=this._inertiaBuffer,r=e.o.now();for(;i.length>0&&r-i[0].time>160;)i.shift()}_onMoveEnd(i){if(this._map._prefersReducedMotion()||(this._drainInertiaBuffer(),this._inertiaBuffer.length<2))return;let r={zoom:0,bearing:0,pitch:0,pan:new e.P(0,0),pinchAround:void 0,around:void 0};for(let{settings:e}of this._inertiaBuffer)r.zoom+=e.zoomDelta||0,r.bearing+=e.bearingDelta||0,r.pitch+=e.pitchDelta||0,e.panDelta&&r.pan._add(e.panDelta),e.around&&(r.around=e.around),e.pinchAround&&(r.pinchAround=e.pinchAround);let a=this._inertiaBuffer[this._inertiaBuffer.length-1].time-this._inertiaBuffer[0].time,n={};if(r.pan.mag()){let e=nw(r.pan.mag(),a,Object.assign({},n_,i||{}));n.offset=r.pan.mult(e.amount/r.pan.mag()),n.center=this._map.transform.center,nb(n,e)}if(r.zoom){let e=nw(r.zoom,a,ng);n.zoom=this._map.transform.zoom+e.amount,nb(n,e)}if(r.bearing){let i=nw(r.bearing,a,ny);
98n.bearing=this._map.transform.bearing+e.aA(i.amount,-179,179),nb(n,i)}if(r.pitch){let e=nw(r.pitch,a,nx);n.pitch=this._map.transform.pitch+e.amount,nb(n,e)}if(n.zoom||n.bearing){let e=void 0===r.pinchAround?r.around:r.pinchAround;n.around=e?this._map.unproject(e):this._map.getCenter()}return this.clear(),n.noMoveStart=!0,n}}function nb(e,i){(!e.duration||e.duration<i.duration)&&(e.duration=i.duration,e.easing=i.easing)}function nw(i,r,a){let{maxSpeed:n,linearity:o,deceleration:s}=a,l=e.aA(i*o/(r/1e3),-n,n),h=Math.abs(l)/(s*o);return{easing:a.easing,duration:1e3*h,amount:h/2*l}}class nT extends e.z{preventDefault(){this._defaultPrevented=!0}get defaultPrevented(){return this._defaultPrevented}constructor(e,i,r,a={}){let n=v(i.getCanvasContainer(),r);super(e,Object.assign({point:n,lngLat:i.unproject(n),originalEvent:r},a)),this._defaultPrevented=!1,this.target=i}}class nS extends e.z{preventDefault(){this._defaultPrevented=!0}get defaultPrevented(){return this._defaultPrevented}constructor(i,r,a){let n="touchend"===i?a.changedTouches:a.touches,o=b(r.getCanvasContainer(),n),s=o.map(e=>r.unproject(e)),l=o.reduce((e,i,r,a)=>e.add(i.div(a.length)),new e.P(0,0));super(i,{points:o,point:l,lngLats:s,lngLat:r.unproject(l),originalEvent:a}),this._defaultPrevented=!1}}class nE extends e.z{preventDefault(){this._defaultPrevented=!0}get defaultPrevented(){return this._defaultPrevented}constructor(e,i){super("wheel",{originalEvent:i}),this._defaultPrevented=!1}}class nI{constructor(e,i){this._map=e,this._clickTolerance=i.clickTolerance}reset(){this._mousedownPos=void 0}wheel(e){return this._firePreventable(new nE(this._map,e))}mousedown(e,i){return this._mousedownPos=i,this._firePreventable(new nT(e.type,this._map,e))}mouseup(e){this._map.fire(new nT(e.type,this._map,e))}preclick(e){let i=new MouseEvent("preclick",e);this._map.fire(new nT(i.type,this._map,i))}click(e,i){this._mousedownPos&&this._mousedownPos.dist(i)>=this._clickTolerance||(this.preclick(e),this._map.fire(new nT(e.type,this._map,e)))}dblclick(e){return this._firePreventable(new nT(e.type,this._map,e))}mouseover(e){this._map.fire(new nT(e.type,this._map,e))}mouseout(e){this._map.fire(new nT(e.type,this._map,e))}touchstart(e){return this._firePreventable(new nS(e.type,this._map,e))}touchmove(e){this._map.fire(new nS(e.type,this._map,e))}touchend(e){this._map.fire(new nS(e.type,this._map,e))}touchcancel(e){this._map.fire(new nS(e.type,this._map,e))}_firePreventable(e){if(this._map.fire(e),e.defaultPrevented)return{}}isEnabled(){return!0}isActive(){return!1}enable(){}disable(){}}class nA{constructor(e){this._map=e}reset(){this._delayContextMenu=!1,this._contextMenuEvent=void 0}mousemove(e){this._map.fire(new nT(e.type,this._map,e))}mousedown(){this._delayContextMenu=!0}mouseup(){this._delayContextMenu=!1,this._contextMenuEvent&&(this._map.fire(new nT("contextmenu",this._map,this._contextMenuEvent)),delete this._contextMenuEvent)}contextmenu(e){this._delayContextMenu?this._contextMenuEvent=e:this._map.fire(new nT(e.type,this._map,e)),this._map.listens("contextmenu")&&e.preventDefault()}isEnabled(){return!0}isActive(){return!1}enable(){}disable(){}}class nC{constructor(e,i){this._map=e,this._el=e.getCanvasContainer(),this._container=e.getContainer(),this._clickTolerance=i.clickTolerance||1}isEnabled(){return!!this._enabled}isActive(){return!!this._active}enable(){this.isEnabled()||(this._enabled=!0)}disable(){this.isEnabled()&&(this._enabled=!1)}mousedown(e,i){this.isEnabled()&&e.shiftKey&&0===e.button&&(_(),this._startPos=this._lastPos=i,this._active=!0)}mousemoveWindow(e,i){if(!this._active)return;let r=this._startPos,a=this._lastPos;if(!r||!a||a.equals(i)||!this._box&&i.dist(r)<this._clickTolerance)return;this._lastPos=i,this._box||(this._box=d("div","mapboxgl-boxzoom",this._container),this._container.classList.add("mapboxgl-crosshair"),this._fireEvent("boxzoomstart",e));let n=Math.min(r.x,i.x),o=Math.max(r.x,i.x),s=Math.min(r.y,i.y),l=Math.max(r.y,i.y);this._map._requestDomTask(()=>{this._box&&(this._box.style.transform=`translate(${n}px,${s}px)`,this._box.style.width=o-n+"px",this._box.style.height=l-s+"px")})}mouseupWindow(i,r){if(!this._active)return;let a=this._startPos;if(a&&0===i.button){if(this.reset(),x(),a.x!==r.x||a.y!==r.y)return this._map.fire(new e.z("boxzoomend",{originalEvent:i})),{cameraAnimation:e=>e.fitScreenCoordinates(a,r,this._map.getBearing(),{linear:!1})};this._fireEvent("boxzoomcancel",i)}}
98keydown(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),g(),delete this._startPos,delete this._lastPos}_fireEvent(i,r){return this._map.fire(new e.z(i,{originalEvent:r}))}}function nM(e,i){let r={};for(let a=0;a<e.length;a++)r[e[a].identifier]=i[a];return r}class nP{constructor(e){this.reset(),this.numTouches=e.numTouches}reset(){this.centroid=void 0,this.startTime=0,this.touches={},this.aborted=!1}touchstart(i,r,a){(this.centroid||a.length>this.numTouches)&&(this.aborted=!0),this.aborted||(0===this.startTime&&(this.startTime=i.timeStamp),a.length===this.numTouches&&(this.centroid=function(i){let r=new e.P(0,0);for(let e of i)r._add(e);return r.div(i.length)}(r),this.touches=nM(a,r)))}touchmove(e,i,r){if(this.aborted||!this.centroid)return;let a=nM(r,i);for(let e in this.touches){let i=a[e];(!i||i.dist(this.touches[e])>30)&&(this.aborted=!0)}}touchend(e,i,r){if((!this.centroid||e.timeStamp-this.startTime>500)&&(this.aborted=!0),0===r.length){let e=!this.aborted&&this.centroid;if(this.reset(),e)return e}}}class nz{constructor(e){this.singleTap=new nP(e),this.numTaps=e.numTaps,this.reset()}reset(){this.lastTime=1/0,this.lastTap=void 0,this.count=0,this.singleTap.reset()}touchstart(e,i,r){this.singleTap.touchstart(e,i,r)}touchmove(e,i,r){this.singleTap.touchmove(e,i,r)}touchend(e,i,r){let a=this.singleTap.touchend(e,i,r);if(a){let i=e.timeStamp-this.lastTime<500,r=!this.lastTap||30>this.lastTap.dist(a);if(i&&r||this.reset(),this.count++,this.lastTime=e.timeStamp,this.lastTap=a,this.count===this.numTaps)return this.reset(),a}}}class nR{constructor(){this._zoomIn=new nz({numTouches:1,numTaps:2}),this._zoomOut=new nz({numTouches:2,numTaps:1}),this.reset()}reset(){this._active=!1,this._zoomIn.reset(),this._zoomOut.reset()}touchstart(e,i,r){this._zoomIn.touchstart(e,i,r),this._zoomOut.touchstart(e,i,r)}touchmove(e,i,r){this._zoomIn.touchmove(e,i,r),this._zoomOut.touchmove(e,i,r)}touchend(e,i,r){let a=this._zoomIn.touchend(e,i,r),n=this._zoomOut.touchend(e,i,r);return a?(this._active=!0,e.preventDefault(),setTimeout(()=>this.reset(),0),{cameraAnimation:i=>i.easeTo({duration:300,zoom:i.getZoom()+1,around:i.unproject(a)},{originalEvent:e})}):n?(this._active=!0,e.preventDefault(),setTimeout(()=>this.reset(),0),{cameraAnimation:i=>i.easeTo({duration:300,zoom:i.getZoom()-1,around:i.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}}let nD={0:1,2:2},nL={Control:"ctrlKey",Alt:"altKey",Shift:"shiftKey",Meta:"metaKey"};class nO{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,i){return!1}_move(e,i){return{}}mousedown(e,i){if(this._lastPoint)return;let r=w(e);this._correctButton(e,r)&&(this._lastPoint=i,this._eventButton=r)}mousemoveWindow(e,i){let r=this._lastPoint;if(r){if(e.preventDefault(),null!=this._eventButton&&function(e,i){let r=nD[i];return void 0===e.buttons||(e.buttons&r)!==r}(e,this._eventButton))this.reset();else if(this._moved||!(i.dist(r)<this._clickTolerance))return this._moved=!0,this._lastPoint=i,this._move(r,i)}}mouseupWindow(e){this._lastPoint&&w(e)===this._eventButton&&(this._moved&&x(),this.reset())}enable(){this._enabled=!0}disable(){this._enabled=!1,this.reset()}isEnabled(){return this._enabled}isActive(){return this._active}}class nF extends nO{mousedown(e,i){super.mousedown(e,i),this._lastPoint&&(this._active=!0)}_correctButton(e,i){return 0===i&&!e.ctrlKey}_move(e,i){return{around:i,panDelta:i.sub(e)}}}class nk extends nO{constructor(e){super(e),this._pitchRotateKey=e.pitchRotateKey?nL[e.pitchRotateKey]:void 0}_correctButton(e,i){return this._pitchRotateKey?0===i&&e[this._pitchRotateKey]:0===i&&e.ctrlKey||2===i}_move(e,i){let r=.8*(i.x-e.x);if(r)return this._active=!0,{bearingDelta:r}}contextmenu(e){this._pitchRotateKey||e.preventDefault()}}class nB extends nO{constructor(e){super(e),this._pitchRotateKey=e.pitchRotateKey?nL[e.pitchRotateKey]:void 0}_correctButton(e,i){return this._pitchRotateKey?0===i&&e[this._pitchRotateKey]:0===i&&e.ctrlKey||2===i}_move(e,i){let r=-.5*(i.y-e.y);if(r)return this._active=!0,{pitchDelta:r}}contextmenu(e){this._pitchRotateKey||e.preventDefault()}}class nN{constructor(i,r){this._map=i,this._el=i.getCanvasContainer(),this._minTouches=1,this._clickTolerance=r.clickTolerance||1,this.reset(),e.aY(["_addTouchPanBlocker","_showTouchPanBlockerAlert"],this)}reset(){this._active=!1,this._touches={},this._sum=new e.P(0,0)}touchstart(e,i,r){return this._calculateTransform(e,i,r)}touchmove(i,r,a){if(this._active&&!(a.length<this._minTouches)){if(this._map._cooperativeGestures&&!this._map.isMoving()){if(1===a.length&&!e.eL())return void this._showTouchPanBlockerAlert();
98"hidden"!==this._alertContainer.style.visibility&&(this._alertContainer.style.visibility="hidden",clearTimeout(this._alertTimer))}return i.cancelable&&i.preventDefault(),this._calculateTransform(i,r,a)}}touchend(e,i,r){this._calculateTransform(e,i,r),this._active&&r.length<this._minTouches&&this.reset()}touchcancel(){this.reset()}_calculateTransform(i,r,a){a.length>0&&(this._active=!0);let n=nM(a,r),o=new e.P(0,0),s=new e.P(0,0),l=0;for(let e in n){let i=n[e],r=this._touches[e];r&&(o._add(i),s._add(i.sub(r)),l++,n[e]=i)}if(this._touches=n,l<this._minTouches||!s.mag())return;let h=s.div(l);return this._sum._add(h),this._sum.mag()<this._clickTolerance?void 0:{around:o.div(l),panDelta:h}}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=d("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 nV{constructor(){this.reset()}reset(){this._active=!1,this._firstTwoTouches=void 0}_start(e){}_move(e,i,r){return{}}touchstart(e,i,r){this._firstTwoTouches||r.length<2||(this._firstTwoTouches=[r[0].identifier,r[1].identifier],this._start([i[0],i[1]]))}touchmove(e,i,r){let a=this._firstTwoTouches;if(!a)return;e.preventDefault();let[n,o]=a,s=nU(r,i,n),l=nU(r,i,o);if(!s||!l)return;let h=this._aroundCenter?null:s.add(l).div(2);return this._move([s,l],h,e)}touchend(e,i,r){if(!this._firstTwoTouches)return;let[a,n]=this._firstTwoTouches,o=nU(r,i,a),s=nU(r,i,n);o&&s||(this._active&&x(),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 nU(e,i,r){for(let a=0;a<e.length;a++)if(e[a].identifier===r)return i[a]}function nj(e,i){return Math.log2(e/i)}class nG extends nV{reset(){super.reset(),this._distance=0,this._startDistance=0}_start(e){this._startDistance=this._distance=e[0].dist(e[1])}_move(e,i){let r=this._distance;if(this._distance=e[0].dist(e[1]),this._active||!(.1>Math.abs(nj(this._distance,this._startDistance))))return this._active=!0,{zoomDelta:nj(this._distance,r),pinchAround:i}}}function nq(e,i){return 180*e.angleWith(i)/Math.PI}class n$ extends nV{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,i){let r=this._vector;if(this._vector=e[0].sub(e[1]),r&&(this._active||!this._isBelowThreshold(this._vector)))return this._active=!0,{bearingDelta:nq(this._vector,r),pinchAround:i}}_isBelowThreshold(e){this._minDiameter=Math.min(this._minDiameter,e.mag());let i=25/(Math.PI*this._minDiameter)*360,r=this._startVector;return!!r&&Math.abs(nq(e,r))<i}}function nH(e){return Math.abs(e.y)>Math.abs(e.x)}class nZ extends nV{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,nH(e[0].sub(e[1]))&&(this._valid=!1)}_move(i,r,a){let n=this._lastPoints;if(!n)return;let o=i[0].sub(n[0]),s=i[1].sub(n[1]);return this._map._cooperativeGestures&&!e.eL()&&a.touches.length<3||(this._val
98id=this.gestureBeginsVertically(o,s,a.timeStamp),!this._valid)?void 0:(this._lastPoints=i,this._active=!0,{pitchDelta:-((o.y+s.y)/2*.5)})}gestureBeginsVertically(e,i,r){if(void 0!==this._valid)return this._valid;let a=e.mag()>=2,n=i.mag()>=2;if(!a&&!n)return;if(!a||!n)return null==this._firstMove&&(this._firstMove=r),r-this._firstMove<100&&void 0;let o=e.y>0==i.y>0;return nH(e)&&nH(i)&&o}}let nW=100,nX=15,nY=10;class nK{constructor(){this._panStep=nW,this._bearingStep=nX,this._pitchStep=nY,this._rotationDisabled=!1}blur(){this.reset()}reset(){this._active=!1}keydown(e){if(e.altKey||e.ctrlKey||e.metaKey)return;let i=0,r=0,a=0,n=0,o=0;switch(e.keyCode){case 61:case 107:case 171:case 187:i=1;break;case 189:case 109:case 173:i=-1;break;case 37:e.shiftKey?r=-1:(e.preventDefault(),n=-1);break;case 39:e.shiftKey?r=1:(e.preventDefault(),n=1);break;case 38:e.shiftKey?a=1:(e.preventDefault(),o=-1);break;case 40:e.shiftKey?a=-1:(e.preventDefault(),o=1);break;default:return}return this._rotationDisabled&&(r=0,a=0),{cameraAnimation:s=>{let l=s.getZoom();s.easeTo({duration:300,easeId:"keyboardHandler",easing:nJ,zoom:i?Math.round(l)+i*(e.shiftKey?2:1):l,bearing:s.getBearing()+r*this._bearingStep,pitch:s.getPitch()+a*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 nJ(e){return e*(2-e)}let nQ=1/450;class n0{constructor(i,r){this._map=i,this._el=i.getCanvasContainer(),this._handler=r,this._delta=0,this._lastDelta=0,this._defaultZoomRate=.01,this._wheelZoomRate=nQ,e.aY(["_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(i){if(!this.isEnabled())return;if(this._map._cooperativeGestures){if(!(i.ctrlKey||i.metaKey||this.isZooming()||e.eL()))return void this._showBlockerAlert();"hidden"!==this._alertContainer.style.visibility&&(this._alertContainer.style.visibility="hidden",clearTimeout(this._alertTimer))}let r=i.deltaMode===WheelEvent.DOM_DELTA_LINE?40*i.deltaY:i.deltaY,a=e.o.now(),n=a-(this._lastWheelEventTime||0);this._lastWheelEventTime=a,0!==r&&r%4.000244140625==0?this._type="wheel":0!==r&&4>Math.abs(r)?this._type="trackpad":n>400?(this._type=null,this._lastValue=r,this._timeout=window.setTimeout(this._onTimeout,40,i)):this._type||(this._type=200>Math.abs(n*r)?"trackpad":"wheel",this._timeout&&(clearTimeout(this._timeout),this._timeout=null,r+=this._lastValue)),i.shiftKey&&r&&(r/=4),this._type&&(this._lastWheelEvent=i,this._delta-=r,this._active||this._start(i)),i.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);let i=v(this._el,e);this._aroundPoint=this._aroundCenter?this._map.transform.centerPoint:i,this._aroundCoord=this._map.transform.pointCoordinate3D(this._aroundPoint),this._targetZoom=void 0,this._frameId||(this._frameId=!0,this._handler._triggerRenderFrame())}renderFrame(){if(!this._frameId||(this._frameId=null,!this.isActive()))return;let i=this._map.transform;"wheel"===this._type&&i.projection.wrap&&(i._center.lng>=180||i._center.lng<=-180)&&(this._prevEase=null,this._easing=null,this._lastWheelEvent=null,this._lastWheelEventTime=0);let r=()=>i._terrainEnabled()&&this._aroundCoord?i.computeZoomRelativeTo(this._aroundCoord):i.zoom;if(0!==this._delta){let e="wheel"===this._type&&Math.abs(this._delta)>4.000244140625?this._wheelZoomRate:this._defaultZoomRate,a=2/(1+Math.exp(-Math.abs(this._delta*e)));this._delta<0&&0!==a&&(a=1/a);let n=r(),o=Math.pow(2,n),s="number"==typeof this._targetZoom?i.zoomScale(this._targetZoom):o;this._targetZoom=Math.min(i.maxZoom,Math.max(i.minZoom,i.scaleZoom(s*a))),"wheel"===this._type&&(this._startZoom=n,this._easing=this._smoothOutEasing(200)),this._lastDelta=this._delta,this._delta=0}let a="number"==typeof this._targetZoom?this._targetZoom:r(),n=this._startZoom,o=this._easing,s,l=!1;if("wheel"===this._type&&n&&o){let i=Math.min((e.o.now()-this._lastWheelEventTime)/200,1),r=o(i);s=e.ak(n,a,r),i<1?this._frameId||(this._frameId=!0):l=!0}else s=a,l=!0;this._active=!0,l&&(this._active=!1,this._finishTimeout=window.setTimeout(()=>
vendor: 5,418 bytes, line 98
98{this._zooming=!1,this._handler._triggerRenderFrame(),delete this._targetZoom,delete this._finishTimeout},200));let h=s-r();return h*this._lastDelta<0&&(h=0),{noInertia:!0,needsRenderFrame:!l,zoomDelta:h,around:this._aroundPoint,aroundCoord:this._aroundCoord,originalEvent:this._lastWheelEvent}}_smoothOutEasing(i){let r=e.eM;if(this._prevEase){let i=this._prevEase,a=(e.o.now()-i.start)/i.duration,n=i.easing(a+.01)-i.easing(a),o=.27/Math.sqrt(n*n+1e-4)*.01,s=Math.sqrt(.0729-o*o);r=e.eK(o,s,.25,1)}return this._prevEase={start:e.o.now(),duration:i,easing:r},r}blur(){this.reset()}reset(){this._active=!1}_addScrollZoomBlocker(){this._map&&!this._alertContainer&&(this._alertContainer=d("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 n1{constructor(e,i){this._clickZoom=e,this._tapZoom=i}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 n2{constructor(){this.reset()}reset(){this._active=!1}blur(){this.reset()}dblclick(e,i){return e.preventDefault(),{cameraAnimation:r=>{r.easeTo({duration:300,zoom:r.getZoom()+(e.shiftKey?-1:1),around:r.unproject(i)},{originalEvent:e})}}}enable(){this._enabled=!0}disable(){this._enabled=!1,this.reset()}isEnabled(){return this._enabled}isActive(){return this._active}}class n3{constructor(){this._tap=new nz({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,i,r){this._swipePoint||(this._tapTime&&e.timeStamp-this._tapTime>500&&this.reset(),this._tapTime?r.length>0&&(this._swipePoint=i[0],this._swipeTouch=r[0].identifier):this._tap.touchstart(e,i,r))}touchmove(e,i,r){if(this._tapTime){if(this._swipePoint){if(r[0].identifier!==this._swipeTouch)return;let a=i[0],n=a.y-this._swipePoint.y;return this._swipePoint=a,e.preventDefault(),this._active=!0,{zoomDelta:n/128}}}else this._tap.touchmove(e,i,r)}touchend(e,i,r){this._tapTime?this._swipePoint&&0===r.length&&this.reset():this._tap.touchend(e,i,r)&&(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 n5{constructor(e,i,r){this._el=e,this._mousePan=i,this._touchPan=r}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 n4{constructor(e,i,r){this._pitchWithRotate=e.pitchWithRotate,this._mouseRotate=i,this._mousePitch=r}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 n6{constructor(e,i,r,a){this._el=e,this._touchZoom=i,this._touchRotate=r,this._tapDragZoom=a,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()}}let n8=e=>e.zoom||e.drag||e.pitch||e.rotate;class n9 extends e.z{}class n7{constructor(){this.constants=[1,1,.01],this.radius=0}setup(i,r){let a=e.av([],r,i);this.radius=e.ag(a[2]<0?e.eO([],a,this.constants):[a[0],a[1],0])}projectRay(i){e.eO(i,i,this.constants),e.aw(i,i),e.eP(i,i,this.constants);let r=e.c4([],i,this.radius);if(r[2]>0){let i=e.c4([],[0,0,1],e.bJ(r,[0,0,1])),a=e.c4([],e.aw([],[r[0],r[1],0]),this.radius),n=e.d7([],r,e.c4([],e.av([],e.d7([],a,i),r),2));r[0]=n[0],r[1]=n[1]}return r}}function oe(e){return e.panDelta&&e.panDelta.mag()||e.zoomDelta||e.bearingDelta||e.pitchDelta}
98class ot{constructor(i,r){this._map=i,this._el=this._map.getCanvasContainer(),this._handlers=[],this._handlersById={},this._changes=[],this._inertia=new nv(i),this._bearingSnap=r.bearingSnap,this._previousActiveHandlers={},this._trackingEllipsoid=new n7,this._dragOrigin=null,this._eventsInProgress={},this._addDefaultHandlers(r),e.aY(["handleEvent","handleWindowEvent"],this);let a=this._el;for(let[e,i,r]of(this._listeners=[[a,"touchstart",{passive:!0}],[a,"touchmove",{passive:!1}],[a,"touchend",void 0],[a,"touchcancel",void 0],[a,"mousedown",void 0],[a,"mousemove",void 0],[a,"mouseup",void 0],[document,"mousemove",{capture:!0}],[document,"mouseup",void 0],[a,"mouseover",void 0],[a,"mouseout",void 0],[a,"dblclick",void 0],[a,"click",void 0],[a,"keydown",{capture:!1}],[a,"keyup",void 0],[a,"wheel",{passive:!1}],[a,"contextmenu",void 0],[window,"blur",void 0]],this._listeners)){let a=e===document?this.handleWindowEvent:this.handleEvent;e.addEventListener(i,a,r)}}destroy(){for(let[e,i,r]of this._listeners){let a=e===document?this.handleWindowEvent:this.handleEvent;e.removeEventListener(i,a,r)}}_addDefaultHandlers(e){let i=this._map,r=i.getCanvasContainer();this._add("mapEvent",new nI(i,e));let a=i.boxZoom=new nC(i,e);this._add("boxZoom",a);let n=new nR,o=new n2;i.doubleClickZoom=new n1(o,n),this._add("tapZoom",n),this._add("clickZoom",o);let s=new n3;this._add("tapDragZoom",s);let l=i.touchPitch=new nZ(i);this._add("touchPitch",l);let h=new nk(e),u=new nB(e);i.dragRotate=new n4(e,h,u),this._add("mouseRotate",h,["mousePitch"]),this._add("mousePitch",u,["mouseRotate"]);let c=new nF(e),d=new nN(i,e);i.dragPan=new n5(r,c,d),this._add("mousePan",c),this._add("touchPan",d,["touchZoom","touchRotate"]);let p=new n$,f=new nG;i.touchZoomRotate=new n6(r,f,p,s),this._add("touchRotate",p,["touchPan","touchZoom"]),this._add("touchZoom",f,["touchPan","touchRotate"]),this._add("blockableMapEvent",new nA(i));let m=i.scrollZoom=new n0(i,this);this._add("scrollZoom",m,["mousePan"]);let _=i.keyboard=new nK;for(let r of(this._add("keyboard",_),["boxZoom","doubleClickZoom","tapDragZoom","touchPitch","dragRotate","dragPan","touchZoomRotate","scrollZoom","keyboard"]))e.interactive&&e[r]&&i[r].enable(e[r])}_add(e,i,r){this._handlers.push({handlerName:e,handler:i,allowed:r}),this._handlersById[e]=i}stop(e){if(!this._updatingCamera){for(let{handler:e}of this._handlers)e.reset();this._inertia.clear(),this._fireEvents({},{},e),this._changes=[],this._originalZoom=void 0}}isActive(){for(let{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!!n8(this._eventsInProgress)||this.isZooming()}_isDragging(){return!!this._eventsInProgress.drag}_blockedByActive(e,i,r){for(let a in e)if(a!==r&&(!i||0>i.indexOf(a)))return!0;return!1}handleWindowEvent(e){this.handleEvent(e,`${e.type}Window`)}_getMapTouches(e){let i=[];for(let r of e)this._el.contains(r.target)&&i.push(r);return i}handleEvent(e,i){this._updatingCamera=!0;let r="renderFrame"===e.type,a=r?void 0:e,n={needsRenderFrame:!1},o={},s={},l=e.touches?this._getMapTouches(e.touches):void 0,h=l?b(this._el,l):r?void 0:v(this._el,e);for(let{handlerName:r,handler:u,allowed:c}of this._handlers){let d;u.isEnabled()&&(this._blockedByActive(s,c,r)?u.reset():u[i||e.type]&&(d=u[i||e.type](e,h,l),this.mergeHandlerResult(n,o,d,r,a),d&&d.needsRenderFrame&&this._triggerRenderFrame()),(d||u.isActive())&&(s[r]=u))}let u={};for(let e in this._previousActiveHandlers)s[e]||(u[e]=a);this._previousActiveHandlers=s,(Object.keys(u).length||oe(n))&&(this._changes.push([n,o,u]),this._triggerRenderFrame()),(Object.keys(s).length||oe(n))&&this._map._stop(!0),this._updatingCamera=!1;let{cameraAnimation:c}=n;c&&(this._inertia.clear(),this._fireEvents({},{},!0),this._changes=[],c(this._map))}mergeHandlerResult(e,i,r,a,n){if(!r)return;Object.assign(e,r);let o={handlerName:a,originalEvent:r.originalEvent||n};void 0!==r.zoomDelta&&(i.zoom=o),void 0!==r.panDelta&&(i.drag=o),void 0!==r.pitchDelta&&(i.pitch=o),void 0!==r.bearingDelta&&(i.rotate=o)}_applyChanges(){let i={},r={},a={};for(let[n,o,s]of this._changes)n.panDelta&&(i.panDelta=(i.panDelta||new e.P(0,0))._add(n.panDelta)),n.zoomDelta&&(i.zoomDelta=(i.zoomDelta||0)+n.zoomDelta),n.bearingDelta&&(i.bearingDelta=(i.bearingDelta||0)+n.bearingDelta),n.pitchDelta&&(i.pitchDelta=(i.pitchDelta||0)+n.pitchDelta),void 0!==n.around&&(i.around=n.around),void 0!==n.aroundCoord&&(i.aroundCoord=n.aroundCoord),void 0!==n.pinchAround&&(i.pinchAround=n.pinchAround),n.noInertia&&(i.noInertia=n.noInertia),Object.assign(r,o),Ob
98ject.assign(a,s);this._updateMapTransform(i,r,a),this._changes=[]}_updateMapTransform(i,r,a){let n=this._map,o=n.transform,s=e=>[e.x,e.y,e.z];if((e=>{let i=this._eventsInProgress.drag;return i&&!this._handlersById[i.handlerName].isActive()})()&&!oe(i)){let e=o.zoom;o.cameraElevationReference="sea",null!=this._originalZoom&&o._orthographicProjectionAtLowPitch&&"globe"!==o.projection.name&&0===o.pitch?(o.cameraElevationReference="ground",o.zoom=this._originalZoom):(o.recenterOnTerrain(),o.cameraElevationReference="ground"),e!==o.zoom&&this._map._update(!0)}if(o._isCameraConstrained&&n._stop(!0),!oe(i))return void this._fireEvents(r,a,!0);let{panDelta:l,zoomDelta:h,bearingDelta:u,pitchDelta:c,around:d,aroundCoord:p,pinchAround:f}=i;o._isCameraConstrained&&(h>0&&(h=0),o._isCameraConstrained=!1),void 0!==f&&(d=f),(h||r.drag&&!this._eventsInProgress.drag)&&d&&(this._dragOrigin=s(o.pointCoordinate3D(d)),this._originalZoom=o.zoom,this._trackingEllipsoid.setup(o._camera.position,this._dragOrigin)),o.cameraElevationReference="sea",n._stop(!0),d=d||n.transform.centerPoint,u&&(o.bearing+=u),c&&(o.pitch+=c),o._updateCameraState();let m=[0,0,0];if(l)if("mercator"===o.projection.name){let e=this._trackingEllipsoid.projectRay(o.screenPointToMercatorRay(d).dir),i=this._trackingEllipsoid.projectRay(o.screenPointToMercatorRay(d.sub(l)).dir);m[0]=i[0]-e[0],m[1]=i[1]-e[1]}else{let i=o.pointCoordinate(d);if("globe"===o.projection.name){l=l.rotate(-o.angle);let r=o._pixelsPerMercatorPixel/o.worldSize;m[0]=-l.x*e.eN(e.a$(i.y))*r,m[1]=-l.y*e.eN(o.center.lat)*r}else{let e=o.pointCoordinate(d.sub(l));i&&e&&(m[0]=e.x-i.x,m[1]=e.y-i.y)}}let _=o.zoom,g=[0,0,0];if(h){let i=s(p||o.pointCoordinate3D(d)),r={dir:e.aw([],e.av([],i,o._camera.position))};if(r.dir[2]<0){let a=o.zoomDeltaToMovement(i,h);e.c4(g,r.dir,a)}}let y=e.d7(m,m,g);o._translateCameraConstrained(y),h&&Math.abs(o.zoom-_)>1e-4&&o.recenterOnTerrain(),o.cameraElevationReference="ground",this._map._update(),i.noInertia||this._inertia.record(i),this._fireEvents(r,a,!0)}_fireEvents(i,r,a){let n,o=n8(this._eventsInProgress),s=n8(i),l={};for(let e in i){let{originalEvent:r}=i[e];this._eventsInProgress[e]||(l[`${e}start`]=r),this._eventsInProgress[e]=i[e]}for(let e in!o&&s&&this._fireEvent("movestart",s.originalEvent),l)this._fireEvent(e,l[e]);for(let e in s&&this._fireEvent("move",s.originalEvent),i){let{originalEvent:r}=i[e];this._fireEvent(e,r)}let h={};for(let e in this._eventsInProgress){let{handlerName:i,originalEvent:a}=this._eventsInProgress[e];this._handlersById[i].isActive()||(delete this._eventsInProgress[e],n=r[i]||a,h[`${e}end`]=n)}for(let e in h)this._fireEvent(e,h[e]);let u=n8(this._eventsInProgress);if(a&&(o||s)&&!u){this._updatingCamera=!0;let i=this._inertia._onMoveEnd(this._map.dragPan._inertiaOptions),r=e=>0!==e&&-this._bearingSnap<e&&e<this._bearingSnap;i?(r(i.bearing||this._map.getBearing())&&(i.bearing=0),this._map.easeTo(i,{originalEvent:n})):(this._map.fire(new e.z("moveend",{originalEvent:n})),r(this._map.getBearing())&&this._map.resetNorth()),this._updatingCamera=!1}}_fireEvent(i,r){this._map.fire(new e.z(i,r?{originalEvent:r}:{}))}_requestFrame(){return this._map.triggerRepaint(),this._map._renderTaskQueue.add(e=>{this._frameId=void 0,this.handleEvent(new n9("renderFrame",{timeStamp:e})),this._applyChanges()})}
98_triggerRenderFrame(){void 0===this._frameId&&(this._frameId=this._requestFrame())}}let oi="map.setFreeCameraOptions(...) and map.getFreeCameraOptions() are not yet supported for non-mercator projections.";class or extends e.E{constructor(i,r){super(),this._moving=!1,this._zooming=!1,this.transform=i,this._bearingSnap=r.bearingSnap,this._respectPrefersReducedMotion=!1!==r.respectPrefersReducedMotion,e.aY(["_renderFrameCallback"],this)}getCenter(){return new e.aR(this.transform.center.lng,this.transform.center.lat)}setCenter(e,i){return this.jumpTo({center:e},i)}panBy(i,r,a){return i=e.P.convert(i).mult(-1),this.panTo(this.transform.center,Object.assign({offset:i},r),a)}panTo(e,i,r){return this.easeTo(Object.assign({center:e},i),r)}getZoom(){return this.transform.zoom}setZoom(e,i){return this.jumpTo({zoom:e},i),this}zoomTo(e,i,r){return this.easeTo(Object.assign({zoom:e},i),r)}zoomIn(e,i){return this.zoomTo(this.getZoom()+1,e,i),this}zoomOut(e,i){return this.zoomTo(this.getZoom()-1,e,i),this}getBearing(){return this.transform.bearing}setBearing(e,i){return this.jumpTo({bearing:e},i),this}getPadding(){return this.transform.padding}setPadding(e,i){return this.jumpTo({padding:e},i),this}rotateTo(e,i,r){return this.easeTo(Object.assign({bearing:e},i),r)}resetNorth(e,i){return this.rotateTo(0,Object.assign({duration:1e3},e),i),this}resetNorthPitch(e,i){return this.easeTo(Object.assign({bearing:0,pitch:0,duration:1e3},e),i),this}snapToNorth(e,i){return Math.abs(this.getBearing())<this._bearingSnap?this.resetNorth(e,i):this}getPitch(){return this.transform.pitch}setPitch(e,i){return this.jumpTo({pitch:e},i),this}cameraForBounds(i,r){i=e.aI.convert(i);let a=r&&r.bearing||0,n=r&&r.pitch||0,o=i.getNorthWest(),s=i.getSouthEast();return this._cameraForBounds(this.transform,o,s,a,n,r)}_extendPadding(e){let i={top:0,right:0,bottom:0,left:0};return null==e?Object.assign({},i,this.transform.padding):"number"==typeof e?{top:e,bottom:e,right:e,left:e}:Object.assign({},i,e)}_extendCameraOptions(e){return(e=Object.assign({offset:[0,0],maxZoom:this.transform.maxZoom},e)).padding=this._extendPadding(e.padding),e}_minimumAABBFrustumDistance(e,i){let r=i.max[0]-i.min[0],a=i.max[1]-i.min[1];return r/a>e.aspect?r/(2*Math.tan(.5*e.fovX)*e.aspect):a/(2*Math.tan(.5*e.fovY)*e.aspect)}_cameraForBoundsOnGlobe(i,r,a,n,o,s){let l=i.clone(),h=this._extendCameraOptions(s);l.bearing=n,l.pitch=o;let u=e.aR.convert(r),c=e.aR.convert(a),d=.5*(u.lat+c.lat),p=.5*(u.lng+c.lng),f=e.eQ(d,p),m=e.aw([],f),_=e.aw([],e.bI([],m,[0,1,0])),g=e.bI([],_,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,e.eQ(u.lat,u.lng),e.eQ(c.lat,u.lng),e.eQ(c.lat,c.lng),e.eQ(u.lat,c.lng),e.eQ(d,u.lng),e.eQ(d,c.lng),e.eQ(u.lat,p),e.eQ(c.lat,p)],v=e.d8.fromPoints(x.map(i=>[e.bJ(_,i),e.bJ(g,i),e.bJ(m,i)])),b=e.af([],v.center,y);0===e.eR(b)&&e.eS(b,0,0,1),e.aw(b,b),e.c4(b,b,e.aD),l.center=e.eT(b);let w=l.getWorldToCameraMatrix(),T=e.bl(new Float64Array(16),w);v=e.d8.applyTransform(v,e.aB([],w,y));let S=this._extendAABB(v,l,h,n);if(!S)return void e.w("Map cannot fit within canvas with the given bounds, padding, and/or offset.");v=S,e.af(b,b,w);let E=.5*(v.max[2]-v.min[2]),I=this._minimumAABBFrustumDistance(l,v),A=e.c4([],[0,0,1],E),C=e.d7(A,b,A),M=I+(0===l.pitch?0:e.bG(b,C)),P=l.globeCenterInViewSpace,z=e.av([],b,[P[0],P[1],P[2]]);e.aw(z,z),e.c4(z,z,M);let R=e.d7([],b,z);e.af(R,R,T);let D=e.eD/e.aD,L=e.ag(R),O=e.ce(Math.max(L*D-e.eD,Number.EPSILON),0),F=Math.min(l.zoomFromMercatorZAdjusted(O),h.maxZoom);return F>.5*(e.cZ+e.cK)?(l.setProjection({name:"mercator"}),l.zoom=F,this._cameraForBounds(l,r,a,n,o,s)):{center:l.center,zoom:F,bearing:n,pitch:o}}_extendAABB(i,r,a,n){let o=.5*((a.padding.left||0)+(a.padding.right||0)),s=.5*((a.padding.top||0)+(a.padding.bottom||0)),l=r.width-(o+o),h=r.height-(s+s),u=e.av([],i.max,i.min),c=Math.min(l/u[0],h/u[1]),d=Math.min(r.scaleZoom(r.scale*c),a.maxZoom);if(isNaN(d))return null;let p=r.scale/r.zoomScale(d),f=new e.d8([i.min[0]-o*p,i.min[1]-s*p,i.min[2]],[i.max[0]+o*p,i.max[1]+s*p,i.max[2]]),m=("number"==typeof a.offset.x&&"number"==typeof a.offset.y?new e.P(a.offset.x,a.offset.y):e.P.convert(a.offset)).rotate(-e.an(n));return f.center[0]-=m.x*p,f.center[1]+=m.y*p,f}queryTerrainElevation(i,r){let a=this.transform.elevation;return a?(r=Object.assign({},{exaggerated:!0},r),a.getAtPoint(e.ae.fromLngLat(i),null,r.exaggerated)):null}
98_cameraForBounds(i,r,a,n,o,s){if("globe"===i.projection.name)return this._cameraForBoundsOnGlobe(i,r,a,n,o,s);let l=i.clone(),h=this._extendCameraOptions(s);l.bearing=n,l.pitch=o;let u=e.aR.convert(r),c=e.aR.convert(a),d=new e.aR(u.lng,c.lat),p=new e.aR(c.lng,u.lat),f=l.project(u),m=l.project(c),_=this.queryTerrainElevation(u),g=this.queryTerrainElevation(c),y=this.queryTerrainElevation(d),x=this.queryTerrainElevation(p),v=[[f.x,f.y,Math.min(_||0,g||0,y||0,x||0)],[m.x,m.y,Math.max(_||0,g||0,y||0,x||0)]],b=e.d8.fromPoints(v),w=l.getWorldToCameraMatrix(),T=e.bl(new Float64Array(16),w);b=e.d8.applyTransform(b,w);let S=this._extendAABB(b,l,h,n);if(!S)return void e.w("Map cannot fit within canvas with the given bounds, padding, and/or offset.");b=S;let E=.5*e.av([],b.max,b.min)[2],I=this._minimumAABBFrustumDistance(l,b),A=[0,0,1,0];e.aC(A,A,w),e.eU(A,A);let C=e.c4([],A,I+E),M=e.d7([],b.center,C);e.af(b.center,b.center,T),e.af(M,M,T);let P=l.unproject(new e.P(b.center[0],b.center[1])),z=Math.pow(2,e.eV(l.projection,P)),R=Math.min(l._zoomFromMercatorZ(M[2]*l.pixelsPerMeter*z/l.worldSize),h.maxZoom);return l.mercatorFromTransition&&R<.5*(e.cZ+e.cK)?(l.setProjection({name:"globe"}),l.zoom=R,this._cameraForBounds(l,r,a,n,o,s)):{center:P,zoom:R,bearing:n,pitch:o}}fitBounds(e,i,r){let a=this.cameraForBounds(e,i);return this._fitInternal(a,i,r)}fitScreenCoordinates(i,r,a,n,o){let s=e.P.convert(i),l=e.P.convert(r),h=new e.P(Math.min(s.x,l.x),Math.min(s.y,l.y)),u=new e.P(Math.max(s.x,l.x),Math.max(s.y,l.y));if("mercator"===this.transform.projection.name&&this.transform.anyCornerOffEdge(s,l))return this;let c=this.transform.pointLocation3D(h),d=this.transform.pointLocation3D(u),p=this.transform.pointLocation3D(new e.P(h.x,u.y)),f=this.transform.pointLocation3D(new e.P(u.x,h.y)),m=[Math.min(c.lng,d.lng,p.lng,f.lng),Math.min(c.lat,d.lat,p.lat,f.lat)],_=[Math.max(c.lng,d.lng,p.lng,f.lng),Math.max(c.lat,d.lat,p.lat,f.lat)],g=n&&n.pitch?n.pitch:this.getPitch(),y=this._cameraForBounds(this.transform,m,_,a,g,n);return this._fitInternal(y,n,o)}_fitInternal(e,i,r){return e?(i=Object.assign(e,i)).linear?this.easeTo(i,r):this.flyTo(i,r):this}jumpTo(i,r){this.stop();let a=i.preloadOnly?this.transform.clone():this.transform,n=!1,o=!1,s=!1;"zoom"in i&&a.zoom!==+i.zoom&&(n=!0,a.zoom=+i.zoom),void 0!==i.center&&(a.center=e.aR.convert(i.center)),"bearing"in i&&a.bearing!==+i.bearing&&(o=!0,a.bearing=+i.bearing),"pitch"in i&&a.pitch!==+i.pitch&&(s=!0,a.pitch=+i.pitch);let l="number"==typeof i.padding?this._extendPadding(i.padding):i.padding;if(null!=i.padding&&!a.isPaddingEqual(l))if(!1===i.retainPadding){let e=a.clone();e.padding=l,a.setLocationAtPoint(a.center,e.centerPoint)}else a.padding=l;return i.preloadOnly?(this._preloadTiles(a),this):(this.fire(new e.z("movestart",r)).fire(new e.z("move",r)),n&&this.fire(new e.z("zoomstart",r)).fire(new e.z("zoom",r)).fire(new e.z("zoomend",r)),o&&this.fire(new e.z("rotatestart",r)).fire(new e.z("rotate",r)).fire(new e.z("rotateend",r)),s&&this.fire(new e.z("pitchstart",r)).fire(new e.z("pitch",r)).fire(new e.z("pitchend",r)),this.fire(new e.z("moveend",r)))}getFreeCameraOptions(){return this.transform.projection.supportsFreeCamera||e.w(oi),this.transform.getFreeCameraOptions()}setFreeCameraOptions(i,r){let a=this.transform;if(!a.projection.supportsFreeCamera)return e.w(oi),this;this.stop();let n=a.zoom,o=a.pitch,s=a.bearing;a.setFreeCameraOptions(i);let l=n!==a.zoom,h=o!==a.pitch,u=s!==a.bearing;return this.fire(new e.z("movestart",r)).fire(new e.z("move",r)),l&&this.fire(new e.z("zoomstart",r)).fire(new e.z("zoom",r)).fire(new e.z("zoomend",r)),u&&this.fire(new e.z("rotatestart",r)).fire(new e.z("rotate",r)).fire(new e.z("rotateend",r)),h&&this.fire(new e.z("pitchstart",r)).fire(new e.z("pitch",r)).fire(new e.z("pitchend",r)),this.fire(new e.z("moveend",r)),this}easeTo(i,r){let a,n,o,s,l;this._stop(!1,i.easeId),(!1===(i=Object.assign({offset:[0,0],duration:500,easing:e.eM},i)).animate||this._prefersReducedMotion(i))&&(i.duration=0);let h=this.transform,u=this.getZoom(),c=this.getBearing(),d=this.getPitch(),p=this.getPadding(),f="zoom"in i?+i.zoom:u,m="bearing"in i?this._normalizeBearing(i.bearing,c):c,_="pitch"in i?+i.pitch:d,g=this._extendPadding(i.padding),y=e.P.convert(i.offset);if("globe"===h.projection.name){let r=e.ae.fromLngLat(h.center),s=y.rotate(-h.angle);r.x+=s.x/h.worldSize,r.y+=s.y/h.worldSize;let l=r.toLngLat(),u=e.aR.convert(i.center||l);this._normalizeCenter(u),a=h.centerPoint.add(s),n=new e.P(r.x,r.y).mult(h.worldSize),o=new e.P(e.aF(u.lng),e.aJ(u.lat)).mult(h.worldSize).sub(n)}else{a=h.centerPoint.add(y);let r=h.pointLocation(a),s=e.aR.convert(i.center||r);this._normalizeCenter(s),n=h.project(r),o=h.project(s).sub(n)}let x=h.zoomScale(f-u);i.around&&(s=e.aR.convert(i.around),l=h.locationPoint(s));let v=this._zooming||f!==u,b=this._rotating||c!==m,w=this._pitching||_!==d,T=!h.isPaddingEqual(g),S=!1===i.retainPadding?h.clone():h,E=h=>E=>{if(v&&(h.zoom=e.ak(u,f,E)),b&&(h.bearing=e.ak(c,m,E)),w&&(h.pitch=e.ak(d,_,E)),T&&(S.interpolatePadding(p,g,E),a=S.centerPoint.add(y)),s)h.setLocationAtPoint(s,l);else{let e=h.zoomScale(h.zoom-u),i=Math.pow(f>u?Math.min(2,x):Math.max(.5,x),1-E),r=h.unproject(n.add(o.mult(E*i)).mult(e));h.setLocationAtPoint(h.renderWorldCopies?r.wrap():r,a)}return i.preloadOnly||this._fireMoveEvents(r),h};if(i.preloadOnly){let e=this._emulate(E,i.duration,h);return this._preloadTiles(e),this}let I={moving:this._moving,zooming:this._zooming,rotating:this._rotating,pitching:this._pitching};return this._zooming=v,this._rotating=b,this._pitching=w,this._padding=T,this._easeId=i.easeId,this._prepareEase(r,i.noMoveStart,I),this._ease(E(h
98),e=>{"sea"===h.cameraElevationReference&&h.recenterOnTerrain(),this._afterEase(r,e)},i),this}_prepareEase(i,r,a={}){this._moving=!0,this.transform.cameraElevationReference="sea",this.transform._orthographicProjectionAtLowPitch&&0===this.transform.pitch&&"globe"!==this.transform.projection.name&&(this.transform.cameraElevationReference="ground"),r||a.moving||this.fire(new e.z("movestart",i)),this._zooming&&!a.zooming&&this.fire(new e.z("zoomstart",i)),this._rotating&&!a.rotating&&this.fire(new e.z("rotatestart",i)),this._pitching&&!a.pitching&&this.fire(new e.z("pitchstart",i))}_fireMoveEvents(i){this.fire(new e.z("move",i)),this._zooming&&this.fire(new e.z("zoom",i)),this._rotating&&this.fire(new e.z("rotate",i)),this._pitching&&this.fire(new e.z("pitch",i))}_afterEase(i,r){if(this._easeId&&r&&this._easeId===r)return;this._easeId=void 0,this.transform.cameraElevationReference="ground";let a=this._zooming,n=this._rotating,o=this._pitching;this._moving=!1,this._zooming=!1,this._rotating=!1,this._pitching=!1,this._padding=!1,a&&this.fire(new e.z("zoomend",i)),n&&this.fire(new e.z("rotateend",i)),o&&this.fire(new e.z("pitchend",i)),this.fire(new e.z("moveend",i))}flyTo(i,r){if(this._prefersReducedMotion(i)){let a=e.aH(i,["center","zoom","bearing","pitch","around","padding","retainPadding"]);return this.jumpTo(a,r)}this.stop(),i=Object.assign({offset:[0,0],speed:1.2,curve:1.42,easing:e.eM},i);let a=this.transform,n=this.getZoom(),o=this.getBearing(),s=this.getPitch(),l=this.getPadding(),h="zoom"in i?e.aA(+i.zoom,a.minZoom,a.maxZoom):n,u="bearing"in i?this._normalizeBearing(i.bearing,o):o,c="pitch"in i?+i.pitch:s,d=this._extendPadding(i.padding),p=a.zoomScale(h-n),f=e.P.convert(i.offset),m=a.centerPoint.add(f),_=a.pointLocation(m),g=e.aR.convert(i.center||_);this._normalizeCenter(g);let y=a.project(_),x=a.project(g).sub(y),v=i.curve,b=Math.max(a.width,a.height),w=b/p,T=x.mag();if("minZoom"in i){let r=e.aA(Math.min(i.minZoom,n,h),a.minZoom,a.maxZoom);v=Math.sqrt(b/a.zoomScale(r-n)/T*2)}let S=v*v;function E(e){let i=(w*w-b*b+(e?-1:1)*S*S*T*T)/(2*(e?w:b)*S*T);return Math.log(Math.sqrt(i*i+1)-i)}function I(e){return(Math.exp(e)-Math.exp(-e))/2}function A(e){return(Math.exp(e)+Math.exp(-e))/2}let C=E(0),M=function(e){return A(C)/A(C+v*e)},P=function(e){var i;return b*((A(C)*(I(i=C+v*e)/A(i))-I(C))/S)/T},z=(E(1)-C)/v;if(1e-6>Math.abs(T)||!isFinite(z)){if(1e-6>Math.abs(b-w))return this.easeTo(i,r);let e=w<b?-1:1;z=Math.abs(Math.log(w/b))/v,P=function(){return 0},M=function(i){return Math.exp(e*v*i)}}i.duration="duration"in i?+i.duration:1e3*z/("screenSpeed"in i?i.screenSpeed/v:+i.speed),i.maxDuration&&i.duration>i.maxDuration&&(i.duration=0);let R=o!==u,D=c!==s,L=!a.isPaddingEqual(d),O=!1===i.retainPadding?a.clone():a,F=a=>p=>{let _=p*z,v=1/M(_);a.zoom=1===p?h:n+a.scaleZoom(v),R&&(a.bearing=e.ak(o,u,p)),D&&(a.pitch=e.ak(s,c,p)),L&&(O.interpolatePadding(l,d,p),m=O.centerPoint.add(f));let b=1===p?g:a.unproject(y.add(x.mult(P(_))).mult(v));return a.setLocationAtPoint(a.renderWorldCopies?b.wrap():b,m),a._updateCameraOnTerrain(),i.preloadOnly||this._fireMoveEvents(r),a};if(i.preloadOnly){let e=this._emulate(F,i.duration,a);return this._preloadTiles(e),this}return this._zooming=!0,this._rotating=R,this._pitching=D,this._padding=L,this._prepareEase(r,!1),this._ease(F(a),()=>this._afterEase(r),i),this}isEasing(){return!!this._easeFrameId}stop(){return this._stop()}_requestRenderFrame(e){}_cancelRenderFrame(e){}_stop(e,i){if(this._easeFrameId&&(this._cancelRenderFrame(this._easeFrameId),this._easeFrameId=void 0,this._onEaseFrame=void 0),this._onEaseEnd){let e=this._onEaseEnd;this._onEaseEnd=void 0,e.call(this,i)}if(!e){let e=this.handlers;e&&e.stop(!1)}return this}_ease(i,r,a){!1===a.animate||0===a.duration?(i(1),r()):(this._easeStart=e.o.now(),this._easeOptions=a,this._onEaseFrame=i,this._onEaseEnd=r,this._easeFrameId=this._requestRenderFrame(this._renderFrameCallback))}_renderFrameCallback(){let i=Math.min((e.o.now()-this._easeStart)/this._easeOptions.duration,1),r=this._onEaseFrame;r&&r(this._easeOptions.easing(i)),i<1?this._easeFrameId=this._requestRenderFrame(this._renderFrameCallback):this.stop()}_normalizeBearing(i,r){let a=Math.abs((i=e.bT(i,-180,180))-r);return Math.abs(i-360-r)<a&&(i-=360),Math.abs(i+360-r)<a&&(i+=360),i}_normalizeCenter(e){let i=this.transform;if(i.maxBounds||"globe"!==i.projection.name&&!i.renderWorldCopies)return;let r=e.lng-i.center.lng;e.lng+=r>180?-360:360*(r<-180)}_prefersReducedMotion(i){return this._respectPrefersReducedMotion&&e.o.prefersReducedMotion&&!(i&&i.essential)}_emulate(e,i,r){let a=Math.ceil(15*i/1e3),n=[],o=e(r.clone());for(let e=0;e<=a;e++){let i=o(e/a);n.push(i.clone())}return n}_preloadTiles(e,i){}}class oa{constructor(i={}){this.options=i,e.aY(["_toggleAttribution","_updateEditLink","_updateData","_updateCompact"],this)}getDefaultPosition(){return"bottom-right"}onAdd(e){let i=this.options&&this.options.compact,r=e._getUIString("AttributionControl.ToggleAttribution");this._map=e,this._container=d("div","mapboxgl-ctrl mapboxgl-ctrl-attrib"),this._compactButton=d("button","mapboxgl-ctrl-attrib-button",this._container),this._compactButton.type="button",this._compactButton.addEventListener("click",this._toggleAttribution),this._compactButton.setAttribute("aria-label",r);let a=d("span","mapboxgl-ctrl-icon",this._compactButton);return a.setAttribute("aria-hidden","true"),a.setAttribute("title",r),this._innerContainer=d("div","mapboxgl-ctrl-attrib-inner",this._container),i&&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===i&&(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","fal
98se")):(this._container.classList.add("mapboxgl-compact-show"),this._compactButton.setAttribute("aria-expanded","true"))}_updateEditLink(){let i=this._editLink;i||(i=this._editLink=this._container.querySelector(".mapbox-improve-map"));let r=[{key:"owner",value:this.styleOwner},{key:"id",value:this.styleId},{key:"access_token",value:this._map._requestManager._customAccessToken||e.e.ACCESS_TOKEN}];if(i){let a=r.reduce((e,i,a)=>(i.value&&(e+=`${i.key}=${i.value}${a<r.length-1?"&":""}`),e),"?");i.href=`${e.e.FEEDBACK_URL}/${a}#${nf(this._map,!0)}`,i.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){let e=this._map.style.stylesheet;this.styleOwner=e.owner,this.styleId=e.id}let i=this._map.style._mergedSourceCaches;for(let r in i){let a=i[r];if(a.used){let i=a.getSource();i.attribution&&0>e.indexOf(i.attribution)&&e.push(i.attribution)}}e.sort((e,i)=>e.length-i.length),e=e.filter((i,r)=>{for(let a=r+1;a<e.length;a++)if(e[a].indexOf(i)>=0)return!1;return!0}),this.options.customAttribution&&(Array.isArray(this.options.customAttribution)?e=[...this.options.customAttribution,...e]:e.unshift(this.options.customAttribution));let r=e.join(" | ");r!==this._attribHTML&&(this._attribHTML=r,e.length?(this._innerContainer.innerHTML=r,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 on{constructor(){e.aY(["_updateLogo","_updateCompact"],this)}onAdd(e){this._map=e,this._container=d("div","mapboxgl-ctrl");let i=d("a","mapboxgl-ctrl-logo");return i.target="_blank",i.rel="noopener nofollow",i.href="https://www.mapbox.com/",i.setAttribute("aria-label",this._map._getUIString("LogoControl.Title")),i.setAttribute("rel","noopener nofollow"),this._container.appendChild(i),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;let e=this._map.style._sourceCaches;if(0===Object.entries(e).length)return!0;for(let i in e){let r=e[i].getSource();if(r.hasOwnProperty("mapbox_logo")&&!r.mapbox_logo)return!1}return!0}_updateCompact(){let e=this._container.children;if(e.length){let i=e[0];this._map.getCanvasContainer().offsetWidth<250?i.classList.add("mapboxgl-compact"):i.classList.remove("mapboxgl-compact")}}}class oo{constructor(){e.aY(["_onIndoorUpdate"],this)}onAdd(e){return this._map=e,this._container=d("div","mapboxgl-ctrl mapboxgl-ctrl-group"),this._map.indoor.on("indoorupdate",e=>this._onIndoorUpdate({selectedFloorId:e.selectedFloorId,floors:e.floors})),this._container}_createButton(e,i){let r=d("button",e,this._container);return r.type="button",r.addEventListener("click",i),r}_createSeparator(){return d("div","mapboxgl-ctrl-separator",this._container)}_setButtonTitle(e,i){this._map&&(e.setAttribute("aria-label",i),e.textContent=i)}onRemove(){this._container&&this._container.remove(),this._map&&this._map.indoor&&(this._map.indoor.off("indoorupdate",this._onIndoorUpdate),this._map=null)}getDefaultPosition(){return"right"}_onIndoorUpdate(e){if(!e||!e.floors)return void(this._container.style.display="none");let i=this._model;this._model=e,this._container.style.display="inline-block",this._container.style.borderRadius="8px";let r=e.floors.sort((e,i)=>i.levelOrder-e.levelOrder);
98i&&Array.from(this._container.children).forEach(e=>e.remove()),this.addCurrentFloors(r)}addCurrentFloors(e){for(let i=0;i<e.length;i++){let r=e[i],a=this._createButton("mapboxgl-ctrl-level-button",()=>{this._map._selectIndoorFloor(r.id),this._model&&(this._model.selectedFloorId=r.id),Array.from(this._container.children).forEach(e=>{e.classList.contains("mapboxgl-ctrl-level-button")&&e.classList.remove("mapboxgl-ctrl-level-button-selected")}),a.classList.add("mapboxgl-ctrl-level-button-selected")});this._setButtonTitle(a,r.shortName),this._model&&r.id===this._model.selectedFloorId&&a.classList.add("mapboxgl-ctrl-level-button-selected"),this._container.append(a),i<e.length-1&&this._createSeparator()}}}class os{constructor(){this._queue=[],this._id=0,this._cleared=!1,this._currentlyRunning=!1}add(e){let i=++this._id;return this._queue.push({callback:e,id:i,cancelled:!1}),i}remove(e){let i=this._currentlyRunning;for(let r of i?this._queue.concat(i):this._queue)if(r.id===e)return void(r.cancelled=!0)}run(e=0){let i=this._currentlyRunning=this._queue;for(let r of(this._queue=[],i))if(!r.cancelled&&(r.callback(e),this._cleared))break;this._cleared=!1,this._currentlyRunning=!1}clear(){this._currentlyRunning&&(this._cleared=!0),this._queue=[]}}class ol{constructor(e){this.jumpTo(e)}getValue(i){if(i<=this._startTime)return this._start;if(i>=this._endTime)return this._end;let r=e.dz((i-this._startTime)/(this._endTime-this._startTime));return this._start*(1-r)+this._end*r}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,i,r){this._start=this.getValue(i),this._end=e,this._startTime=i,this._endTime=i+r}}let oh={"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 ou extends e.z{constructor(e,i,r,a){let{point:n,lngLat:o,originalEvent:s,target:l}=e;super(e.type,{point:n,lngLat:o,originalEvent:s,target:l}),this.preventDefault=()=>{e.preventDefault()},this.id=i,this.interaction=r,this.feature=a}}class oc{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(i,r){if(this.typeById.has(i))throw Error(`Interaction id "${i}" already exists.`);let a=r.filter,n=r.type;a&&this.filters.set(i,e.b6(a)),"mouseover"===n&&(n="mouseenter"),"mouseout"===n&&(n="mouseleave");let o=this.interactionsByType.get(n)||new Map;"mouseenter"===n||"mouseleave"===n?(0===this.delegatedInteractions.size&&(this.map.on("mousemove",this.handleMove),this.map.on("mouseout",this.handleOut)),this.delegatedInteractions.set(i,r)):0===o.size&&this.map.on(n,this.handleType),0===o.size&&this.interactionsByType.set(n,o),o.set(i,r),this.typeById.set(i,n)}get(e){let i=this.typeById.get(e);if(!i)return;let r=this.interactionsByType.get(i);return r?r.get(e):void 0}remove(e){let i=this.typeById.get(e);if(!i)return;this.typeById.delete(e),this.filters.delete(e);let r=this.interactionsByType.get(i);r&&(r.delete(e),"mouseenter"===i||"mouseleave"===i?(this.delegatedInteractions.delete(e),0===this.delegatedInteractions.size&&(this.map.off("mousemove",this.handleMove),this.map.off("mouseout",this.handleOut))):0===r.size&&this.map.off(i,this.handleType))}queryTargets(e,i){let r=[];for(let[e,a]of i)a.target&&r.push({targetId:e,target:a.target,filter:this.filters.get(e)});return this.map.style.queryRenderedTargets(e,r,this.map.transform)}handleMove(e){this.prevHoveredFeatures=this.hoveredFeatures,this.hoveredFeatures=new Map;let i=this.queryTargets(e.point,Array.from(this.delegatedInteractions).reverse());i.length&&(e.type="mouseenter",this.handleType(e,i));let r=new Map;for(let[e,{feature:i}]of this.prevHoveredFeatures)this.hoveredFeatures.has(e)||r.set(i.id,i);r.size&&(e.type="mouseleave",this.handleType(e,Array.from(r.values())
98))}handleOut(e){let i=Array.from(this.hoveredFeatures.values()).map(({feature:e})=>e);i.length&&(e.type="mouseleave",this.handleType(e,i)),this.hoveredFeatures.clear()}handleType(i,r){let a="mouseenter"===i.type;if(a&&!this.interactionsByType.has(i.type))return void e.w("mouseenter interaction required for mouseleave to work.");let n=Array.from(this.interactionsByType.get(i.type)).reverse(),o=!!r;r=r||this.queryTargets(i.point,n);let s=!1,l=new Set;for(let h of r){for(let[r,u]of n){if(!u.target)continue;let n=h.variants?h.variants[r]:null;if(n){for(let c of n){if(e1(c,h,l,r))continue;let n=new e.dt(h,c),d=e0(c,h,r);o&&(n.state=this.map.getFeatureState(n));let p=a?this.prevHoveredFeatures.get(d):null,f=new ou(i,r,u,n),m=p?p.stop:u.handler(f);if(a&&this.hoveredFeatures.set(d,{feature:h,stop:m}),!1!==m){s=!0;break}}if(s)break}}if(s)break}if(!s)for(let[e,r]of n){let{handler:a,target:n}=r;if(!n&&!1!==a(new ou(i,e,r,null)))break}}}let od={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"},op={showCompass:!0,showZoom:!0,visualizePitch:!1};class of{constructor(i,r,a=!1){this._clickTolerance=10,this.element=r,this.mouseRotate=new nk({clickTolerance:i.dragRotate._mouseRotate._clickTolerance}),this.map=i,a&&(this.mousePitch=new nB({clickTolerance:i.dragRotate._mousePitch._clickTolerance})),e.aY(["mousedown","mousemove","mouseup","touchstart","touchmove","touchend","reset"],this),r.addEventListener("mousedown",this.mousedown),r.addEventListener("touchstart",this.touchstart,{passive:!1}),r.addEventListener("touchmove",this.touchmove),r.addEventListener("touchend",this.touchend),r.addEventListener("touchcancel",this.reset)}down(e,i){this.mouseRotate.mousedown(e,i),this.mousePitch&&this.mousePitch.mousedown(e,i),_()}move(e,i){let r=this.map,a=this.mouseRotate.mousemoveWindow(e,i),n=a&&a.bearingDelta;if(n&&r.setBearing(r.getBearing()+n),this.mousePitch){let a=this.mousePitch.mousemoveWindow(e,i),n=a&&a.pitchDelta;n&&r.setPitch(r.getPitch()+n)}}off(){let 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(){g(),window.removeEventListener("mousemove",this.mousemove),window.removeEventListener("mouseup",this.mouseup)}mousedown(e){this.down(Object.assign({},e,{ctrlKey:!0,preventDefault:()=>e.preventDefault()}),v(this.element,e)),window.addEventListener("mousemove",this.mousemove),window.addEventListener("mouseup",this.mouseup)}mousemove(e){this.move(e,v(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=b(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=b(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 om(i,r,a){if(i=new e.aR(i.lng,i.lat),r){let n=new e.aR(i.lng-360,i.lat),o=new e.aR(i.lng+360,i.lat),s=360*Math.ceil(Math.abs(i.lng-a.center.lng)/360),l=a.locationPoint3D(i).distSqr(r),h=r.x<0||r.y<0||r.x>a.width||r.y>a.height;a.locationPoint3D(n).distSqr(r)<l&&(h||Math.abs(n.lng-a.center.lng)<s)?i=n:a.locationPoint3D(o).distSqr(r)<l&&(h||Math.abs(o.lng-a.center.lng)<s)&&(i=o)}for(;Math.abs(i.lng-a.center.lng)>180;){let e=a.locationPoint3D(i);if(e.x>=0&&e.y>=0&&e.x<=a.width&&e.y<=a.height)break;
98i.lng>a.center.lng?i.lng-=360:i.lng+=360}return i}let o_={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%)"},og="auto",oy="auto";class ox extends e.E{constructor(i,r){super(),(i instanceof HTMLElement||r)&&(i=Object.assign({element:i},r)),e.aY(["_update","_onMove","_onUp","_addDragHandler","_onMapClick","_onKeyPress","_clearFadeTimer"],this);let{anchor:a="center",color:n="#3FB1CE",scale:o=1,draggable:s=!1,clickTolerance:l=0,rotation:h=0,rotationAlignment:u=og,pitchAlignment:c=oy,occludedOpacity:d=.2,altitude:p=0}=i||{};this._anchor=a,this._color=n,this._scale=o,this._draggable=s,this._clickTolerance=l,this._rotation=h,this._rotationAlignment=u,this._pitchAlignment=c,this._occludedOpacity=d,this._altitude=p,this._state="inactive",this._isDragging=!1,this._updateMoving=()=>this._update(!0),i&&i.element?(this._element=i.element,this._offset=e.P.convert(i&&i.offset||[0,0])):(this._defaultMarker=!0,this._element=this._createDefaultMarker(),this._offset=e.P.convert(i&&i.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()});let f=this._element.classList;for(let e in o_)f.remove(`mapboxgl-marker-anchor-${e}`);f.add(`mapboxgl-marker-anchor-${this._anchor}`);let m=i&&i.className?i.className.trim().split(/\s+/):[];f.add(...m),this._popup=null}_createDefaultMarker(){let e=d("div"),i=p("svg",{display:"block",height:41*this._scale+"px",width:27*this._scale+"px",viewBox:"0 0 27 41"},e);if(0===this._altitude){let e=p("radialGradient",{id:"shadowGradient"},p("defs",{},i));p("stop",{offset:"10%","stop-opacity":.4},e),p("stop",{offset:"100%","stop-opacity":.05},e),p("ellipse",{cx:13.5,cy:34.8,rx:10.5,ry:5.25,fill:"url(#shadowGradient)"},i)}return p("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"},i),p("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"},i),p("circle",{fill:"white",cx:13.5,cy:13.5,r:5.5},i),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(){let 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(i){return this._lngLat=e.aR.convert(i),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||0,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)){let i=Math.sqrt(91.125);e.options.offset=this._defaultMarker?{top:[0,0],"top-left":[0,0],"top-right":[0,0],bottom:[
980,-38.1],"bottom-left":[i,-1*(24.6+i)],"bottom-right":[-i,-1*(24.6+i)],left:[13.5,-24.6],right:[-13.5,-24.6]}: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){let i=e.code,r=e.charCode||e.keyCode;"Space"!==i&&"Enter"!==i&&32!==r&&13!==r||this.togglePopup()}_onMapClick(e){let i=e.originalEvent.target,r=this._element;this._popup&&(i===r||r.contains(i))&&this.togglePopup()}getPopup(){return this._popup}togglePopup(){let 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}_behindTerrain(){let e=this._map,i=this._pos;if(!e||!i)return!1;let r=e.unproject(i,this._altitude),a=e.getFreeCameraOptions();if(!a.position)return!1;let n=a.position.toLngLat();return n.distanceTo(r)<.9*n.distanceTo(this._lngLat)}_evaluateOpacity(){let i,r=this._map;if(!r)return;let a=this._pos;if(!a||a.x<0||a.x>r.transform.width||a.y<0||a.y>r.transform.height)return void this._clearFadeTimer();let n=r.unproject(a,this._altitude);r._showingGlobe()&&e.eY(r.transform,this._lngLat)?i=0:(i=1-r._queryFogOpacity(n),r.transform._terrainEnabled()&&r.getTerrain()&&this._behindTerrain()&&(i*=this._occludedOpacity)),this._element.style.opacity=`${i}`,this._element.style.pointerEvents=i>0?"auto":"none",this._popup&&this._popup._setOpacity(i),this._fadeTimer=null}_clearFadeTimer(){this._fadeTimer&&(clearTimeout(this._fadeTimer),this._fadeTimer=null)}_updateDOM(){let e=this._pos;if(!e||!this._map)return;let i=this._offset.mult(this._scale);this._element.style.transform=` 99 translate(${e.x}px,${e.y}px) 100 ${o_[this._anchor]} 101 ${this._calculateXYTransform()} ${this._calculateZTransform()} 102 translate(${i.x}px,${i.y}px) 103 `}_calculateXYTransform(){let i=this._pos,r=this._map,a=this.getPitchAlignment();if(!r||!i||"map"!==a)return"";if(!r._showingGlobe()){let e=r.getPitch();return e?`rotateX(${e}deg)`:""}let n=e.cW(e.eZ(r.transform,this._lngLat)),o=i.sub(e.e_(r.transform)),s=Math.abs(o.x)+Math.abs(o.y);if(0===s)return"";let l=n/s;return`rotateX(${-o.y*l}deg) rotateY(${o.x*l}deg)`}_calculateZTransform(){let i=this._pos,r=this._map;if(!r||!i)return"";let a=0,n=this.getRotationAlignment();if("map"===n)if(r._showingGlobe()){let i=r.project(new e.aR(this._lngLat.lng,this._lngLat.lat+.001),this._altitude),n=r.project(new e.aR(this._lngLat.lng,this._lngLat.lat-.001),this._altitude).sub(i);a=e.cW(Math.atan2(n.y,n.x))-90}else a=-r.getBearing();else if("horizon"===n){let n=e.ah(4,6,r.getZoom()),o=e.e_(r.transform);o.y+=n*r.transform.height;let s=i.sub(o),l=e.cW(Math.atan2(s.y,s.x));a=(l>90?l-270:l+90)*(1-n)}return(a+=this._rotation)?`rotateZ(${a}deg)`:""}_update(e){cancelAnimationFrame(this._updateFrameId);let i=this._map;
103i&&(i.transform.renderWorldCopies&&(this._lngLat=om(this._lngLat,this._pos,i.transform)),this._pos=i.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(),i._requestDomTask(()=>{this._map&&(this._element&&this._pos&&this._anchor&&this._updateDOM(),(i._showingGlobe()||i.getTerrain()||i.getFog())&&!this._fadeTimer&&(this._fadeTimer=window.setTimeout(this._evaluateOpacity.bind(this),60)))}))}getOffset(){return this._offset}setOffset(i){return this._offset=e.P.convert(i),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(i){let r=this._map;if(!r)return;let a=this._pointerdownPos,n=this._positionDelta;if(a&&n){if(!this._isDragging){let e=this._clickTolerance||r._clickTolerance;if(i.point.dist(a)<e)return;this._isDragging=!0}this._pos=i.point.sub(n),this._lngLat=r.unproject(this._pos,this._altitude),this.setLngLat(this._lngLat),this._element.style.pointerEvents="none","pending"===this._state&&(this._state="active",this.fire(new e.z("dragstart"))),this.fire(new e.z("drag"))}}_onUp(){this._element.style.pointerEvents="auto",this._positionDelta=null,this._pointerdownPos=null,this._isDragging=!1;let i=this._map;i&&(i.off("mousemove",this._onMove),i.off("touchmove",this._onMove)),"active"===this._state&&this.fire(new e.z("dragend")),this._state="inactive"}_addDragHandler(e){let i=this._map,r=this._pos;i&&r&&this._element.contains(e.originalEvent.target)&&(e.preventDefault(),this._positionDelta=e.point.sub(r),this._pointerdownPos=e.point,this._state="pending",i.on("mousemove",this._onMove),i.on("touchmove",this._onMove),i.once("mouseup",this._onUp),i.once("touchend",this._onUp))}setDraggable(e){this._draggable=!!e;let i=this._map;return i&&(e?(i.on("mousedown",this._addDragHandler),i.on("touchstart",this._addDragHandler)):(i.off("mousedown",this._addDragHandler),i.off("touchstart",this._addDragHandler))),this}isDraggable(){return this._draggable}setRotation(e){return this._rotation=e||0,this._update(),this}getRotation(){return this._rotation}setRotationAlignment(e){return this._rotationAlignment=e||og,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||oy,this._update(),this}getPitchAlignment(){return"auto"===this._pitchAlignment?this.getRotationAlignment():this._pitchAlignment}setOccludedOpacity(e){return this._occludedOpacity=e||.2,this._update(),this}getOccludedOpacity(){return this._occludedOpacity}}let ov={positionOptions:{enableHighAccuracy:!1,maximumAge:0,timeout:6e3},fitBoundsOptions:{maxZoom:15},trackUserLocation:!1,showAccuracyCircle:!0,showUserLocation:!0,showUserHeading:!1},ob={maxWidth:100,unit:"metric"},ow={kilometer:"km",meter:"m",mile:"mi",foot:"ft","nautical-mile":"nm"},oT={closeButton:!0,closeOnClick:!0,focusAfterOpen:!0,className:"",maxWidth:"240px",altitude:0};function oS(i=new e.P(0,0),r="bottom"){if("number"==typeof i){let a=Math.round(Math.sqrt(.5*Math.pow(i,2)));switch(r){case"top":return new e.P(0,i);case"top-left":return new e.P(a,a);case"top-right":return new e.P(-a,a);case"bottom":return new e.P(0,-i);case"bottom-left":return new e.P(a,-a);case"bottom-right":return new e.P(-a,-a);case"left":return new e.P(i,0);case"right":return new e.P(-i,0)}return new e.P(0,0)}return i instanceof e.P||Array.isArray(i)?e.P.convert(i):e.P.convert(i[r]||[0,0])}return{version:n,supported:c.supported,setRTLTextPlugin:e.f2,getRTLTextPluginStatus:e.f1,Map:class extends or{constructor(i){s.mark(o.create);let r=i;if(null!=(i=Object.assign({},od,i)).minZoom&&null!=i.maxZoom&&i.minZoom>i.maxZoom)throw Error("maxZoom must be greater than or equal to minZoom");if(null!=i.minPitch&&null!=i.maxPitch&&i.minPitch>i.maxPitch)throw Error("maxPitch must be greater than or equal to minPitch");if(null!=i.minPitch&&i.minPitch<0)throw Error("minPitch must be greater than or equal to 0");if(null!=i.maxPitch&&i.maxPitch>85)throw Error("maxPitch must be less than or equal to 85");if(i.antialias&&e.eW(window)&&(i.antialias=!1,e.w("Antialiasing is disabled for this WebGL context to avoid browser bug: https://github.com/mapbox/mapbox-gl-js/issues/11609")),super(new it(i.minZoom,i.maxZoom,i.minPitch,i.maxPitch,i.renderWorldCopies,null,null),i),this._repaint=!!i.repaint,this._interactive=i.interactive,this._minTileCacheSize=i.minTileCacheSize,this._maxTileC
103acheSize=i.maxTileCacheSize,this._failIfMajorPerformanceCaveat=i.failIfMajorPerformanceCaveat,this._preserveDrawingBuffer=i.preserveDrawingBuffer,this._antialias=i.antialias,this._trackResize=i.trackResize,this._bearingSnap=i.bearingSnap,this._refreshExpiredTiles=i.refreshExpiredTiles,this._fadeDuration=i.fadeDuration,this._isInitialLoad=!0,this._crossSourceCollisions=i.crossSourceCollisions,this._collectResourceTiming=i.collectResourceTiming,this._language=this._parseLanguage(i.language),this._worldview=i.worldview,this._renderTaskQueue=new os,this._domRenderTaskQueue=new os,this._controls=[],this._markers=[],this._popups=[],this._mapId=e.b2(),this._locale=Object.assign({},oh,i.locale),this._clickTolerance=i.clickTolerance,this._cooperativeGestures=i.cooperativeGestures,this._performanceMetricsCollection=i.performanceMetricsCollection,this._tessellationStep=i.tessellationStep,this._containerWidth=0,this._containerHeight=0,this._showParseStatus=!0,this._precompilePrograms=i.precompilePrograms,this._scaleFactorChanged=!1,this._averageElevationLastSampledAt=-1/0,this._averageElevationExaggeration=0,this._averageElevation=new ol(0),this._interactionRange=[1/0,-1/0],this._visibilityHidden=0,this._useExplicitProjection=!1,this._frameId=0,this._scaleFactor=i.scaleFactor,this._requestManager=new E(i.transformRequest,i.accessToken,i.testMode),this._silenceAuthErrors=!!i.testMode,this._contextCreateOptions=i.contextCreateOptions?Object.assign({},i.contextCreateOptions):{},"string"==typeof i.container){let e=document.getElementById(i.container);if(!e)throw Error(`Container '${i.container.toString()}' not found.`);this._container=e}else{if(!(i.container instanceof HTMLElement))throw Error("Invalid type: 'container' must be a String or HTMLElement.");this._container=i.container}if(this._container.childNodes.length>0&&e.w("The map container element should be empty, otherwise the map's interactivity will be negatively impacted. If you want to display a message when WebGL is not supported, use the Mapbox GL Supported plugin instead."),i.maxBounds&&this.setMaxBounds(i.maxBounds),this._spriteFormat=i.spriteFormat,e.aY(["_onWindowOnline","_onWindowResize","_onVisibilityChange","_onMapScroll","_contextLost","_contextRestored"],this),this._setupContainer(),this._tp||(this._tp=new a4),this._tp.registerParameter(this,["Debug"],"showOverdrawInspector"),this._tp.registerParameter(this,["Debug"],"showTileBoundaries"),this._tp.registerParameter(this,["Debug"],"showParseStatus"),this._tp.registerParameter(this,["Debug"],"repaint"),this._tp.registerParameter(this,["Debug"],"showTileAABBs"),this._tp.registerParameter(this,["Debug"],"showPadding"),this._tp.registerParameter(this,["Debug"],"showCollisionBoxes",{noSave:!0}),this._tp.registerParameter(this.transform,["Debug"],"freezeTileCoverage",{noSave:!0},()=>{this._update()}),this._tp.registerParameter(this,["Debug","Wireframe"],"showTerrainWireframe"),this._tp.registerParameter(this,["Debug","Wireframe"],"showLayers2DWireframe"),this._tp.registerParameter(this,["Debug","Wireframe"],"showLayers3DWireframe"),this._tp.registerParameter(this,["Scaling"],"_scaleFactor",{min:.1,max:10,step:.1},()=>{this.setScaleFactor(this._scaleFactor)}),this._setupPainter(),void 0===this.painter)throw 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 ot(this,i),this._localFontFamily=i.localFontFamily,this._localIdeographFontFamily=i.localIdeographFontFamily,(i.style||!i.testMode)&&this.setStyle(i.style||e.e.DEFAULT_STYLE,{config:i.config,localFontFamily:this._localFontFamily,localIdeographFontFamily:this._localIdeographFontFamily}),i.projection&&this.setProjection(i.projection),this.indoor=new iI(this),i.hash&&(this._hash=new np("string"==typeof i.hash&&i.hash||void 0).addTo(this)),!this._hash||!this._hash._onHashChange()){null==r.center&&null==r.zoom||(this.transform._unmodified=!1),this.jumpTo({center:i.center,zoom:i.zoom,bearing:i.bearing,pitch:i.pitch});let e=i.bounds;e&&(this.resize(),this.fitBounds(e,Object.assign({},i.fitBoundsOptions,{duration:0})))}this.resize(),i.attributionControl&&this.addControl(new oa({customAttribution:i.customAttribution}
103)),this._logoControl=new on,this.addControl(this._logoControl,i.logoPosition),this.on("style.load",()=>{this.transform.unmodified&&this.jumpTo(this.style.stylesheet),this._postStyleLoadEvent()}),this.on("data",i=>{this._update("style"===i.dataType),this.fire(new e.z(`${i.dataType}data`,i))}),this.on("dataloading",i=>{this.fire(new e.z(`${i.dataType}dataloading`,i))}),this._interactions=new oc(this)}_getMapId(){return this._mapId}addControl(i,r){if(void 0===r&&(r=i.getDefaultPosition?i.getDefaultPosition():"top-right"),!i||!i.onAdd)return this.fire(new e.y(Error("Invalid argument to map.addControl(). Argument must be a control with onAdd and onRemove methods.")));let a=i.onAdd(this);this._controls.push(i);let n=this._controlPositions[r];return -1!==r.indexOf("bottom")?n.insertBefore(a,n.firstChild):n.appendChild(a),this}removeControl(i){if(!i||!i.onRemove)return this.fire(new e.y(Error("Invalid argument to map.removeControl(). Argument must be a control with onAdd and onRemove methods.")));let r=this._controls.indexOf(i);return r>-1&&this._controls.splice(r,1),i.onRemove(this),this}hasControl(e){return this._controls.indexOf(e)>-1}getContainer(){return this._container}getCanvasContainer(){return this._canvasContainer}getCanvas(){return this._canvas}resize(i){if(this._updateContainerDimensions(),this._containerWidth===this.transform.width&&this._containerHeight===this.transform.height)return this;this._resizeCanvas(this._containerWidth,this._containerHeight),this.transform.resize(this._containerWidth,this._containerHeight),this.painter.resize(Math.ceil(this._containerWidth),Math.ceil(this._containerHeight));let r=!this._moving;return r&&this.fire(new e.z("movestart",i)).fire(new e.z("move",i)),this.fire(new e.z("resize",i)),r&&this.fire(new e.z("moveend",i)),this}getBounds(){return this.transform.getBounds()}getMaxBounds(){return this.transform.getMaxBounds()||null}setMaxBounds(i){return this.transform.setMaxBounds(e.aI.convert(i)),this._update()}setMinZoom(i){if((i=i??-2)>=-2&&i<=this.transform.maxZoom)return this.transform.minZoom=i,this._update(),this.getZoom()<i?this.setZoom(i):this.fire(new e.z("zoomstart")).fire(new e.z("zoom")).fire(new e.z("zoomend")),this;throw Error("minZoom must be between -2 and the current maxZoom, inclusive")}getMinZoom(){return this.transform.minZoom}setMaxZoom(i){if((i=i??22)>=this.transform.minZoom)return this.transform.maxZoom=i,this._update(),this.getZoom()>i?this.setZoom(i):this.fire(new e.z("zoomstart")).fire(new e.z("zoom")).fire(new e.z("zoomend")),this;throw Error("maxZoom must be greater than the current minZoom")}getMaxZoom(){return this.transform.maxZoom}setMinPitch(i){if((i=i??0)<0)throw Error("minPitch must be greater than or equal to 0");if(i>=0&&i<=this.transform.maxPitch)return this.transform.minPitch=i,this._update(),this.getPitch()<i?this.setPitch(i):this.fire(new e.z("pitchstart")).fire(new e.z("pitch")).fire(new e.z("pitchend")),this;throw Error("minPitch must be between 0 and the current maxPitch, inclusive")}getMinPitch(){return this.transform.minPitch}setMaxPitch(i){if((i=i??85)>85)throw Error("maxPitch must be less than or equal to 85");if(i>=this.transform.minPitch)return this.transform.maxPitch=i,this._update(),this.getPitch()>i?this.setPitch(i):this.fire(new e.z("pitchstart")).fire(new e.z("pitch")).fire(new e.z("pitchend")),this;throw 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._tp.refreshUI(),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){let i=this._parseLanguage(e);if(!this.style||i===this._language)return this;for(let e of(this._language=i,this.style.reloadSources(),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}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(){let i;if("globe"!==this.getProjection().name)return;let r=this.transform,a=r.projection.name;"globe"===a&&r.zoom>=e.cK?(r.setMercatorFromTransition(),i=!0):"mercator"===a&&r.zoom<e.cK&&(r.setProjection({name:"globe"}),i=!0),i&&(this.style.applyProjectionUpdate(),this.style._forceSymbolLayer
103Update(),this._update(!0))}_prioritizeAndUpdateProjection(e,i){return this._updateProjection(e||i||{name:"mercator"})}_updateProjection(i){let r;return r="globe"===i.name&&this.transform.zoom>=e.cK?this.transform.setMercatorFromTransition():this.transform.setProjection(i),this.style.applyProjectionUpdate(),r&&(this.painter.clearBackgroundTiles(),this.style.clearSources(),this._update(!0),this._forceMarkerAndPopupUpdate(!0)),this}project(i,r){return this.transform.locationPoint3D(e.aR.convert(i),r)}unproject(i,r){return this.transform.pointLocation3D(e.P.convert(i),r)}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,i,r){let a=e=>{let r=[];if(Array.isArray(i)){let a=i.filter(e=>this.getLayer(e));r=a.length?this.queryRenderedFeatures(e,{layers:a}):[]}else r=this.queryRenderedFeatures(e,{target:i});return r};if("mouseenter"===e||"mouseover"===e){let n=!1,o=i=>{let o=a(i.point);o.length?n||(n=!0,r.call(this,new nT(e,this,i.originalEvent,{features:o}))):n=!1};return{listener:r,targets:i,delegates:{mousemove:o,mouseout:()=>{n=!1}}}}if("mouseleave"===e||"mouseout"===e){let n=!1,o=i=>{a(i.point).length?n=!0:n&&(n=!1,r.call(this,new nT(e,this,i.originalEvent)))},s=i=>{n&&(n=!1,r.call(this,new nT(e,this,i.originalEvent)))};return{listener:r,targets:i,delegates:{mousemove:o,mouseout:s}}}{let n=e=>{let i=a(e.point);i.length&&(e.features=i,r.call(this,e),delete e.features)};return{listener:r,targets:i,delegates:{[e]:n}}}}on(e,i,r){if("function"==typeof i||void 0===r)return super.on(e,i);if("string"==typeof i&&(i=[i]),!this._areTargetsValid(i))return this;let a=this._createDelegatedListener(e,i,r);for(let i in this._delegatedListeners=this._delegatedListeners||{},this._delegatedListeners[e]=this._delegatedListeners[e]||[],this._delegatedListeners[e].push(a),a.delegates)this.on(i,a.delegates[i]);return this}once(e,i,r){if("function"==typeof i||void 0===r)return super.once(e,i);if("string"==typeof i&&(i=[i]),!this._areTargetsValid(i))return this;let a=this._createDelegatedListener(e,i,r);for(let e in a.delegates)this.once(e,a.delegates[e]);return this}off(i,r,a){if("function"==typeof r||void 0===a)return super.off(i,r);if("string"==typeof r&&(r=[r]),!this._areTargetsValid(r))return this;let n=this._delegatedListeners?this._delegatedListeners[i]:void 0;return n&&(i=>{for(let n=0;n<i.length;n++){let o=i[n];if(o.listener===a&&function(i,r){if(Array.isArray(i)&&Array.isArray(r)){let e=new Set(i),a=new Set(r);return e.size===a.size&&i.every(e=>a.has(e))}return e.by(i,r)}(o.targets,r)){for(let e in o.delegates)this.off(e,o.delegates[e]);return i.splice(n,1),this}}})(n),this}queryRenderedFeatures(i,r){if(!this.style)return[];if(void 0===i||i instanceof e.P||Array.isArray(i)||void 0!==r||(r=i,i=void 0),i=i||[[0,0],[this.transform.width,this.transform.height]],!r){let e=this.style.queryRenderedFeatures(i,void 0,this.transform),r=this.style.queryRenderedFeatureset(i,void 0,this.transform);return e.concat(r)}let a=!0;if(r.target&&(a=this._isTargetValid(r.target))&&!r.layers)return this.style.queryRenderedFeatureset(i,r,this.transform);let n=!0;if(r.layers&&Array.isArray(r.layers)){for(let e of r.layers)if(!this._isValidId(e)){n=!1;break}if(n&&!r.target)return this.style.queryRenderedFeatures(i,r,this.transform)}let o=[];return n&&(o=o.concat(this.style.queryRenderedFeatures(i,r,this.transform))),a&&(o=o.concat(this.style.queryRenderedFeatureset(i,r,this.transform))),o}querySourceFeatures(e,i){return e&&("string"!=typeof e||this._isValidId(e))?this.style.querySourceFeatures(e,i):[]}queryRasterValue(e,i,r){return this._isValidId(e)?this.style.queryRasterValue(e,i,r):Promise.resolve(null)}isPointOnSurface(i){let{name:r}=this.transform.projection;return"globe"!==r&&"mercator"!==r&&e.w(`${r} projection does not support isPointOnSurface, this API may behave unexpectedly.`),this.transform.isPointOnSurface(e.P.convert(i))}addInteraction(e,i){return this._interactions.add(e,i),this}removeInteraction(e){return this._interactions.remove(e),this}getCooperativeGestures(){return this._cooperativeGestures}setCooperativeGestures(e){return this._cooperativeGestures=e,this}setStyle(i,r){return r=Object.assign({},{localIdeographFontFamily:this._localIdeographFontFamily,localFontFamily:this._localFontFamily},r),this.style&&i&&!1!==r.diff&&r.localFontFamily===this._localFontFamily&&r.localIdeographFontFamily===this._localIdeographFontFamily&&!r.config?(this.style._diffStyle(i,(a,n)=>{if(a){let n="string"==typeof a?a:a instanceof Error?a.message:a.error;e.w(`Unable to perform style diff: ${n}. Rebuilding the style from scratch.`),this._updateStyle(i,r)}else n&&this._update(!0)},()=>this._postStyleLoadEvent()),this):(this._localIdeographFontFamily=r.localIdeographFontFamily,this._localFontFamily=r.localFontFamily,this._updateStyle(i,r))}_getUIString(e){let i=this._locale[e];if(null==i)throw Error(`Missing UI string '${e}'`);return i}_updateStyle(e,i){if(this.style&&(this.style.setEventedParent(null),this.style._remove(),this.style=void 0),e){let r=Object.assign({},i);
103i&&i.config&&(r.initialConfig=i.config,delete r.config),this.style=new iw(this,r).load(e),this.style.setEventedParent(this,{style:this.style})}return this._updateTerrain(),this}_lazyInitEmptyStyle(){this.style||(this.style=new iw(this,{}),this.style.setEventedParent(this,{style:this.style}),this.style.loadEmpty())}getStyle(){if(this.style)return this.style.serialize()}isStyleLoaded(){return this.style?this.style.loaded():(e.w("There is no style added to the map."),!1)}_isValidId(i){return null==i?(this.fire(new e.y(Error("IDs can't be empty."))),!1):!e.dm(i)||(this.fire(new e.y(Error(`IDs can't contain special symbols: "${i}".`))),!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(let i of e)if(!this._isValidId(i))return!1;return!0}return this._isTargetValid(e)}addSource(e,i){return this._isValidId(e)?(this._lazyInitEmptyStyle(),this.style.addSource(e,i),this._update(!0)):this}isSourceLoaded(e){return!!this._isValidId(e)&&!!this.style&&this.style._isSourceCacheLoaded(e)}areTilesLoaded(){return this.style.areTilesLoaded()}addSourceType(e,i,r){this._lazyInitEmptyStyle(),this.style.addSourceType(e,i,r)}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(i,r,{pixelRatio:a=1,sdf:n=!1,stretchX:o,stretchY:s,content:l}={}){this._lazyInitEmptyStyle();let h=e.I.from(i);if(r instanceof HTMLImageElement||ImageBitmap&&r instanceof ImageBitmap){let{width:i,height:u,data:c}=e.o.getImageData(r);this.style.addImage(h,{data:new e.q({width:i,height:u},c),pixelRatio:a,stretchX:o,stretchY:s,content:l,sdf:n,version:0,usvg:!1})}else if(void 0===r.width||void 0===r.height)this.fire(new e.y(Error("Invalid arguments to map.addImage(). The second argument must be an `HTMLImageElement`, `ImageData`, `ImageBitmap`, or object with `width`, `height`, and `data` properties with the same format as `ImageData`")));else{let{width:u,height:c}=r;this.style.addImage(h,{data:new e.q({width:u,height:c},new Uint8Array(r.data)),pixelRatio:a,stretchX:o,stretchY:s,content:l,sdf:n,usvg:!1,version:0,userImage:r}),r.onAdd&&r.onAdd(this,i)}}updateImage(i,r){this._lazyInitEmptyStyle();let a=e.I.from(i),n=this.style.getImage(a);if(!n)return void this.fire(new e.y(Error("The map has no image with that id. If you are adding a new image use `map.addImage(...)` instead.")));let{width:o,height:s,data:l}=r instanceof HTMLImageElement||ImageBitmap&&r instanceof ImageBitmap?e.o.getImageData(r):r;if(void 0===o||void 0===s)return void this.fire(new e.y(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!==(n.usvg?n.icon.usvg_tree.width:n.data.width)||s!==(n.usvg?n.icon.usvg_tree.height:n.data.height))return void this.fire(new e.y(Error(`The width and height of the updated image (${o}, ${s}) 104 must be that same as the previous version of the image 105 (${n.data.width}, ${n.data.height})`)));let h=!(r instanceof HTMLImageElement||ImageBitmap&&r instanceof ImageBitmap),u=!1;n.usvg?(n.data=new e.q({width:o,height:s},new Uint8Array(l)),n.usvg=!1,n.icon=void 0,u=!0):n.data.replace(l,h),this.style.updateImage(a,n,u)}hasImage(i){return i?!!this.style&&!!this.style.getImage(e.I.from(i)):(this.fire(new e.y(Error("Missing required image id"))),!1)}removeImage(i){this.style.removeImage(e.I.from(i))}loadImage(i,r){e.n(this._requestManager.transformRequest(i,e.R.Image),(i,a)=>{r(i,a instanceof HTMLImageElement?e.o.getImageData(a):a)})}listImages(){return this.style.listImages().map(e=>e.name)}addModel(e,i){this._lazyInitEmptyStyle(),this.style.addModel(e,i)}hasModel(i){return i?this.style.hasModel(i):(this.fire(new e.y(Error("Missing required model id"))),!1)}removeModel(e){this.style.removeModel(e)}listModels(){return this.style.listModels()}addLayer(e,i){return this._isValidId(e.id)?(this._lazyInitEmptyStyle(),this.style.addLayer(e,i),this._update(!0)):this}getSlot(e){let i=this.getLayer(e);return i&&i.slot||null}setSlot(e,i){return this.style.setSlot(e,i),this.style.mergeLayers(),this._update(!0)}
105addImport(i,r){return this.style.addImport(i,r).catch(i=>this.fire(new e.y(Error("Failed to add import",i)))),this}updateImport(e,i){return"string"!=typeof i&&i.id!==e?(this.removeImport(e),this.addImport(i)):(this.style.updateImport(e,i),this._update(!0))}removeImport(e){return this.style.removeImport(e),this}moveImport(e,i){return this.style.moveImport(e,i),this._update(!0)}moveLayer(e,i){return this._isValidId(e)?(this.style.moveLayer(e,i),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;let i=this.style.getOwnLayer(e);return i?"custom"===i.type?i.implementation:i.serialize():void 0}getSlots(){return this.style.getSlots()}setLayerZoomRange(e,i,r){return this._isValidId(e)?(this.style.setLayerZoomRange(e,i,r),this._update(!0)):this}setFilter(e,i,r={}){return this._isValidId(e)?(this.style.setFilter(e,i,r),this._update(!0)):this}getFilter(e){return this._isValidId(e)?this.style.getFilter(e):null}setPaintProperty(e,i,r,a={}){return this._isValidId(e)?(this.style.setPaintProperty(e,i,r,a),this._update(!0)):this}getPaintProperty(e,i){return this._isValidId(e)?this.style.getPaintProperty(e,i):null}setLayoutProperty(e,i,r,a={}){return this._isValidId(e)?(this.style.setLayoutProperty(e,i,r,a),this._update(!0)):this}getLayoutProperty(e,i){return this._isValidId(e)?this.style.getLayoutProperty(e,i):null}getGlyphsUrl(){return this.style.getGlyphsUrl()}setGlyphsUrl(e){return this.style.setGlyphsUrl(e),this._update(!0)}getSchema(e){return this.style.getSchema(e)}setSchema(e,i){return this.style.setSchema(e,i),this._update(!0)}getConfig(e){return this.style.getConfig(e)}setConfig(e,i){return this.style.setConfig(e,i),this._update(!0)}getConfigProperty(e,i){return this.style.getConfigProperty(e,i)}setConfigProperty(e,i,r){return this.style.setConfigProperty(e,i,r),this._update(!0)}getFeaturesetDescriptors(e){return this.style.getFeaturesetDescriptors(e)}setLights(e){if(this._lazyInitEmptyStyle(),e&&1===e.length&&"flat"===e[0].type){let i=e[0];i.properties?this.style.setFlatLight(i.properties,i.id,{}):this.style.setFlatLight({},"flat")}else this.style.setLights(e),this.painter.terrain&&(this.painter.terrain.invalidateRenderCache=!0);return this._update(!0)}getLights(){let e=this.style.getLights()||[];return 0===e.length&&e.push({id:this.style.light.id,type:"flat",properties:this.style.getFlatLight()}),e}setLight(e,i={}){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,i){return this._lazyInitEmptyStyle(),this.style.setImportColorTheme(e,i),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(i){return this.style&&this.style.fog?this.style.fog.getOpacityAtLatLng(e.aR.convert(i),this.transform):0}setFeatureState(e,i){return e.source&&!this._isValidId(e.source)?this:(this.style.setFeatureState(e,i),this._update())}removeFeatureState(e,i){return e.source&&!this._isValidId(e.source)?this:(this.style.removeFeatureState(e,i),this._update())}getFeatureState(e){return e.source&&!this._isValidId(e.source)?null:this.style.getFeatureState(e)}_selectIndoorFloor(e){this.indoor.selectFloor(e)}
105_addIndoorControl(){this._indoorControl||(this._indoorControl=new oo),this.addControl(this._indoorControl,"right")}_removeIndoorControl(){this._indoorControl&&this.removeControl(this._indoorControl)}_updateContainerDimensions(){if(!this._container)return;let e=this._container.getBoundingClientRect().width||400,i=this._container.getBoundingClientRect().height||300,r,a,n,o=this._container;for(;o&&(!a||!n);){let e=window.getComputedStyle(o).transform;e&&"none"!==e&&((r=e.match(/matrix.*\((.+)\)/)[1].split(", "))[0]&&"0"!==r[0]&&"1"!==r[0]&&(a=r[0]),r[3]&&"0"!==r[3]&&"1"!==r[3]&&(n=r[3])),o=o.parentElement}this._containerWidth=a?Math.abs(e/a):e,this._containerHeight=n?Math.abs(i/n):i}_detectMissingCSS(){"rgb(250, 128, 114)"!==window.getComputedStyle(this._missingCSSCanary).getPropertyValue("background-color")&&e.w("This page appears to be missing CSS declarations for Mapbox GL JS, which may cause the map to display incorrectly. Please ensure your page includes mapbox-gl.css, as described in https://www.mapbox.com/mapbox-gl-js/api/.")}_setupContainer(){let e=this._container;e.classList.add("mapboxgl-map"),(this._missingCSSCanary=d("div","mapboxgl-canary",e)).style.visibility="hidden",this._detectMissingCSS();let i=this._canvasContainer=d("div","mapboxgl-canvas-container",e);this._canvas=d("canvas","mapboxgl-canvas",i),this._interactive&&(i.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);let r=this._controlContainer=d("div","mapboxgl-control-container",e),a=this._controlPositions={};["top-left","top","top-right","right","bottom-right","bottom","bottom-left","left"].forEach(e=>{a[e]=d("div",`mapboxgl-ctrl-${e}`,r)}),this._container.addEventListener("scroll",this._onMapScroll,!1)}_resizeCanvas(i,r){let a=e.o.devicePixelRatio||1;this._canvas.width=a*Math.ceil(i),this._canvas.height=a*Math.ceil(r),this._canvas.style.width=`${i}px`,this._canvas.style.height=`${r}px`}_addMarker(e){this._markers.push(e)}_removeMarker(e){let i=this._markers.indexOf(e);-1!==i&&this._markers.splice(i,1)}_addPopup(e){this._popups.push(e)}_removePopup(e){let i=this._popups.indexOf(e);-1!==i&&this._popups.splice(i,1)}_setupPainter(){let i=Object.assign({},c.supported.webGLContextAttributes,{failIfMajorPerformanceCaveat:this._failIfMajorPerformanceCaveat,preserveDrawingBuffer:this._preserveDrawingBuffer,antialias:this._antialias||!1}),r=this._canvas.getContext("webgl2",i);r?(G(r,!0),this.painter=new nc(r,this._contextCreateOptions,this.transform,this._scaleFactor,this._tp,this._worldview),this.on("data",e=>{"source"===e.dataType&&this.painter.setTileLoadedFlag(!0)}),e.k.testSupport(r)):this.fire(new e.y(Error("Failed to initialize WebGL")))}_contextLost(i){i.preventDefault(),this._frame&&(this._frame.cancel(),this._frame=null),this.fire(new e.z("webglcontextlost",{originalEvent:i}))}_contextRestored(i){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 e.z("webglcontextrestored",{originalEvent:i}))}_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}_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(i){let r;this.fire(new e.z("renderstart")),++this._frameId;let a=this.painter.context.extTimerQuery,n=e.o.now(),l=this.painter.context.gl;if(this.listens("gpu-timing-frame")&&(r=l.createQuery(),l.beginQuery(a.TIME_ELAPSED_EXT,r)),this.painter.context.setDirty(),this.painter.setBaseState(),(this.isMoving()||this.isRotating()||this.isZooming())&&
105(this._interactionRange[0]=Math.min(this._interactionRange[0],performance.now()),this._interactionRange[1]=Math.max(this._interactionRange[1],performance.now())),this._renderTaskQueue.run(i),this._domRenderTaskQueue.run(i),this._removed)return;this._updateProjectionTransition();let h=this._isInitialLoad?0:this._fadeDuration;if(this.style&&this._styleDirty){this._styleDirty=!1;let i=this.transform.zoom,r=this.transform.pitch,a=e.o.now(),n=new e.ac(i,{now:a,fadeDuration:h,pitch:r,transition:this.style.transition,worldview:this._worldview});this.style.update(n)}this.style&&this.style.hasFogTransition()&&(this.style._markersNeedUpdate=!0,this._sourcesDirty=!0);let u=!1;this.style&&this._sourcesDirty?(this._sourcesDirty=!1,this.painter._updateFog(this.style),this._updateTerrain(),u=this._updateAverageElevation(n),this.style.updateSources(this.transform),this.style.updateImageProviders(),this.isMoving()||this._forceMarkerAndPopupUpdate()):u=this._updateAverageElevation(n);let c=this.style&&this.style._updatePlacement(this.painter,this.painter.transform,this.showCollisionBoxes,h,this._crossSourceCollisions,this.painter.replacementSource,this._scaleFactorChanged);if(this._scaleFactorChanged&&(this._scaleFactorChanged=!1),c&&(this._placementDirty=c.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:h,isInitialLoad:this._isInitialLoad,showPadding:this.showPadding,gpuTiming:!!this.listens("gpu-timing-layer"),gpuTimingDeferredRender:!!this.listens("gpu-timing-deferred-render"),speedIndexTiming:this.speedIndexTiming}),this.fire(new e.z("render")),this.loaded()&&!this._loaded&&(this._loaded=!0,s.mark(o.load),this.fire(new e.z("load"))),this.style&&this.style.hasTransitions()&&(this._styleDirty=!0),this.style&&(this.style.snow||this.style.rain)&&(this._styleDirty=!0),this.style&&this.style.imageManager.hasPatternsInFlight()&&(this._styleDirty=!0),this.style&&!this.style.modelManager.isLoaded()&&(this._styleDirty=!0),this.style&&!this._placementDirty&&this.style._releaseSymbolFadeTiles(),r){let i=e.o.now()-n;l.endQuery(a.TIME_ELAPSED_EXT),setTimeout(()=>{let a=l.getQueryParameter(r,l.QUERY_RESULT)/1e6;l.deleteQuery(r),this.fire(new e.z("gpu-timing-frame",{cpuTime:i,gpuTime:a}))},50)}if(this.listens("gpu-timing-layer")){let i=this.painter.collectGpuTimers();setTimeout(()=>{let r=this.painter.queryGpuTimers(i);this.fire(new e.z("gpu-timing-layer",{layerTimes:r}))},50)}if(this.listens("gpu-timing-deferred-render")){let i=this.painter.collectDeferredRenderGpuQueries();setTimeout(()=>{let r=this.painter.queryGpuTimeDeferredRender(i);this.fire(new e.z("gpu-timing-deferred-render",{gpuTime:r}))},50)}let d=this._sourcesDirty||this._styleDirty||this._placementDirty||u;if(d||this._repaint)this.triggerRepaint();else{let i=this.idle();if(i&&(u=this._updateAverageElevation(n,!0)),u)this.triggerRepaint();else if(this._triggerFrame(!1),i&&(this.fire(new e.z("idle")),this._isInitialLoad=!1,this.speedIndexTiming)){let i=this._calculateSpeedIndex();this.fire(new e.z("speedindexcompleted",{speedIndex:i})),this.speedIndexTiming=!1}}!this._loaded||this._fullyLoaded||d||(this._fullyLoaded=!0,s.mark(o.fullLoad),this._performanceMetricsCollection&&N(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(let i of this._markers)e&&!this.getRenderWorldCopies()&&(i._lngLat=i._lngLat.wrap()),i._update();for(let i of this._popups)!e||this.getRenderWorldCopies()||i._trackPointer||(i._lngLat=i._lngLat.wrap()),i._update()}_updateAverageElevation(e,i=!1){let r=e=>(this.transform.averageElevation=e,this._update(!1),!0);if(!this.painter.averageElevationNeedsEasing())return 0!==this.transform.averageElevation&&r(0);let a=this.transform.elevation&&this.transform.elevation.exaggeration()!==this._averageElevationExaggeration;if(a||(i||e-this._averageElevationLastSampledAt>500)&&!this._averageElevation.isEasing(e)){let i=this.transform.averageElevation,n=this.transform.sampleAverageElevation();null!=this.transform.elevation&&(this._averageElevationExaggeration=this.transform.elevation.exaggeration()),isNaN(n)?n=0:this._averageElevationLastSampledAt=e;let o=Math.abs(i-n);if(o>1){if(this._isInitialLoad||a)return this._averageElevation.jumpTo(n),r(n);this._averageElevation.easeTo(n,e,300)}else if(o>1e-4)return this._averageElevation.jumpTo(n),r(n)}return!!this._averageElevation.isEasing(e)&&r(this._averageElevation.getValue(e))}_authenticate(){U(this._getMapId(),this._requestManager._skuToken,this._requestManager._customAccessToken,i=>{if(i&&(i.message===S||401===i.status)){let i=this.painter.context.gl;G(i,!1),this._logoControl instanceof on&&this._logoControl._updateLogo(),i&&i.clear(i.DEPTH_BUFFER_BIT|i.COLOR_BUFFER_BIT|i.STENCIL_BUFFER_BIT),this._silenceAuthErrors||this.fire(new e.y(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/")))}}),O(this._getMapId(),this._requestManager._skuToken,this._requestManager._customAccessToken,()=>{})}_postStyleLoadEvent(){this.style.globalId&&k(this._requestManager._customAccessToken,{map:this,style:this.style.globalId,importedStyles:this.style.getImportGlobalIds()})}_updateTerrain(){let e=this._isDragging();this.painter.updateTerrain(this.style,e)}_calculateSpeedIndex(){let e=this.painter.canvasCopy(),i=this.painter.getCanvasCopiesAndTimestamps();i.timeStamps.push(performance.now());let r=this.painter.context.gl,a=r.createFramebuffer();function n(e){r.framebufferTexture2D(r.FRAMEBUFFER,r.COLOR_ATTACHMENT0,r.TEXTURE_2D,e,0);let i=new Uint8Array(r.drawingBufferWidth*r.drawingBufferHeight*4);return r.readPixels(0,0,r.drawingBufferWidth,r.drawingBufferHeight,r.RGBA,r.UNSIGNED_BYTE,i),i}return r.bindFramebuffer(r.FRAMEBUFFER,a),this._canvasPixelComparison(n(e),i.canvasCopies.map(n),i.timeStamps)}_canvasPixelComparison(e,i,r){let a=r[1]-r[0],n=e.length/4;for(let o=0;o<i.length;o++){let s=i[o],l=0;for(let i=0;i<s.length;
105i+=4)s[i]===e[i]&&s[i+1]===e[i+1]&&s[i+2]===e[i+2]&&s[i+3]===e[i+3]&&(l+=1);a+=(r[o+2]-r[o+1])*(1-l/n)}return a}remove(){for(let e of(this._hash&&this._hash.remove(),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.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);let i=this.painter.context.gl.getExtension("WEBGL_lose_context");i&&i.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),j.delete(this.painter.context.gl),V.remove(),L.remove(),this._removed=!0,this.fire(new e.z("remove"))}triggerRepaint(){this._triggerFrame(!0)}_triggerFrame(i){this._renderNextFrame=this._renderNextFrame||i,this.style&&!this._frame&&(this._frame=e.o.frame(e=>{let i=!!this._renderNextFrame;this._frame=null,this._renderNextFrame=null,i&&this._render(e)}))}_preloadTiles(i){let r=this.style?this.style.getSourceCaches():[];return e.bw(r,(e,r)=>e._preloadTiles(i,r),()=>{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._tp.refreshUI(),this._update())}get showParseStatus(){return!!this._showParseStatus}set showParseStatus(e){this._showParseStatus!==e&&(this._showParseStatus=e,this._tp.refreshUI(),this._update())}get showTerrainWireframe(){return!!this._showTerrainWireframe}set showTerrainWireframe(e){this._showTerrainWireframe!==e&&(this._showTerrainWireframe=e,this._tp.refreshUI(),this._update())}get showLayers2DWireframe(){return!!this._showLayers2DWireframe}set showLayers2DWireframe(e){this._showLayers2DWireframe!==e&&(this._showLayers2DWireframe=e,this._tp.refreshUI(),this._update())}get showLayers3DWireframe(){return!!this._showLayers3DWireframe}set showLayers3DWireframe(e){this._showLayers3DWireframe!==e&&(this._showLayers3DWireframe=e,this._tp.refreshUI(),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._tp.refreshUI(),this._update())}get showCollisionBoxes(){return!!this._showCollisionBoxes}set showCollisionBoxes(e){this._showCollisionBoxes!==e&&(this._showCollisionBoxes=e,this._tp.refreshUI(),e?this.style._generateCollisionBoxes():this._update())}get showOverdrawInspector(){return!!this._showOverdrawInspector}set showOverdrawInspector(e){this._showOverdrawInspector!==e&&(this._showOverdrawInspector=e,this._tp.refreshUI(),this._update())}get repaint(){return!!this._repaint}set repaint(e){this._repaint!==e&&(this._repaint=e,this._tp.refreshUI(),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,this._tp.refreshUI(),e&&this._update())}_setCacheLimits(i,r){e.eX(i,r)}get version(){return n}},NavigationControl:class{constructor(i={}){this.options=Object.assign({},op,i),this._container=d("div","mapboxgl-ctrl mapboxgl-ctrl-group"),this._container.addEventListener("contextmenu",e=>e.preventDefault()),this.options.showZoom&&(e.aY(["_setButtonTitle","_updateZoomButtons"],this),this._zoomInButton=this._createButton("mapboxgl-ctrl-zoom-in",e=>{this._map&&this._map.zoomIn({},{originalEvent:e})}),d("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})}),d("span","mapboxgl-ctrl-icon",this._zoomOutButton).setAttribute("aria-hidden","true")),this.options.showCompass&&(e.aY(["_rotateCompassArrow"],this),this._compass=this._createButton("mapboxgl-ctrl-compass",e=>{let i=this._map;i&&(this.options.visualizePitch?i.resetNorthPitch({},{originalEvent:e}):i.resetNorth({},{originalEvent:e}))}),this._compassIcon=d("span","mapboxgl-ctrl-icon",this._compass),this._compassIcon.setAttribute("aria-hidden","true"))}_updateZoomButtons(){let e=this._map;if(!e)return;
105let i=e.getZoom(),r=i===e.getMaxZoom(),a=i===e.getMinZoom();this._zoomInButton.disabled=r,this._zoomOutButton.disabled=a,this._zoomInButton.setAttribute("aria-disabled",r.toString()),this._zoomOutButton.setAttribute("aria-disabled",a.toString())}_rotateCompassArrow(){let e=this._map;if(!e)return;let i=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=i)})}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 of(e,this._compass,this.options.visualizePitch)),this._container}onRemove(){let 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,i){let r=d("button",e,this._container);return r.type="button",r.addEventListener("click",i),r}_setButtonTitle(e,i){if(!this._map)return;let r=this._map._getUIString(`NavigationControl.${i}`);e.setAttribute("aria-label",r),e.firstElementChild&&e.firstElementChild.setAttribute("title",r)}},GeolocateControl:class extends e.E{constructor(i={}){super();let r=navigator.geolocation;this.options=Object.assign({geolocation:r},ov,i),e.aY(["_onSuccess","_onError","_onZoom","_finish","_setupUI","_updateCamera","_updateMarker","_updateMarkerRotation","_onDeviceOrientation"],this),this._updateMarkerRotationThrottled=nd(this._updateMarkerRotation,20),this._numberOfWatches=0}onAdd(e){return this._map=e,this._container=d("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){let i=(i=!!this.options.geolocation)=>{this._supportsGeolocation=i,e(i)};void 0!==this._supportsGeolocation?e(this._supportsGeolocation):void 0!==navigator.permissions?navigator.permissions.query({name:"geolocation"}).then(e=>i("denied"!==e.state)).catch(()=>i()):i()}_isOutOfMapMaxBounds(e){let i=this._map.getMaxBounds(),r=e.coords;return!!i&&(r.longitude<i.getWest()||r.longitude>i.getEast()||r.latitude<i.getSouth()||r.latitude>i.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(i){if(this._map){if(this._isOutOfMapMaxBounds(i))return this._setErrorState(),this.fire(new e.z("outofmaxbounds",i)),this._updateMarker(),void this._finish();if(this.options.trackUserLocation)switch(this._lastKnownPosition=i,this._watchState){case"WAITING_ACTIVE":case"ACTIVE_LOCK":case"ACTIVE_E
105RROR":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(i),this.options.trackUserLocation&&"ACTIVE_LOCK"!==this._watchState||this._updateCamera(i),this.options.showUserLocation&&this._userLocationDotMarker.removeClassName("mapboxgl-user-location-dot-stale"),this.fire(new e.z("geolocate",i)),this._finish()}}_updateCamera(i){let r=new e.aR(i.coords.longitude,i.coords.latitude),a=i.coords.accuracy,n=Object.assign({bearing:this._map.getBearing()},this.options.fitBoundsOptions);this._map.fitBounds(r.toBounds(a),n,{geolocateSource:!0})}_updateMarker(i){if(i){let r=new e.aR(i.coords.longitude,i.coords.latitude);this._accuracyCircleMarker.setLngLat(r).addTo(this._map),this._userLocationDotMarker.setLngLat(r).addTo(this._map),this._accuracy=i.coords.accuracy,this.options.showUserLocation&&this.options.showAccuracyCircle&&this._updateCircleRadius()}else this._userLocationDotMarker.remove(),this._accuracyCircleMarker.remove()}_updateCircleRadius(){let i=this._map.transform,r=e.ce(1,i._center.lat)*i.worldSize,a=Math.ceil(2*this._accuracy*r);this._circleElement.style.width=`${a}px`,this._circleElement.style.height=`${a}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(i){if(this._map){if(this.options.trackUserLocation)if(1===i.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;let 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===i.code&&this._noTimeout)return;this._setErrorState()}"OFF"!==this._watchState&&this.options.showUserLocation&&this._userLocationDotMarker.addClassName("mapboxgl-user-location-dot-stale"),this.fire(new e.z("error",i)),this._finish()}}_finish(){this._timeoutId&&clearTimeout(this._timeoutId),this._timeoutId=void 0}_setupUI(i){if(void 0!==this._map){if(this._container.addEventListener("contextmenu",e=>e.preventDefault()),this._geolocateButton=d("button","mapboxgl-ctrl-geolocate",this._container),d("span","mapboxgl-ctrl-icon",this._geolocateButton).setAttribute("aria-hidden","true"),this._geolocateButton.type="button",!1===i){e.w("Geolocation support is not available so the GeolocateControl will be disabled.");let i=this._map._getUIString("GeolocateControl.LocationNotAvailable");this._geolocateButton.disabled=!0,this._geolocateButton.setAttribute("aria-label",i),this._geolocateButton.firstElementChild&&this._geolocateButton.firstElementChild.setAttribute("title",i)}else{let 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","fal
105se"),this._watchState="OFF"),this.options.showUserLocation&&(this._dotElement=d("div","mapboxgl-user-location"),this._dotElement.appendChild(d("div","mapboxgl-user-location-dot")),this._dotElement.appendChild(d("div","mapboxgl-user-location-heading")),this._userLocationDotMarker=new ox({element:this._dotElement,rotationAlignment:"map",pitchAlignment:"map"}),this._circleElement=d("div","mapboxgl-user-location-accuracy-circle"),this._accuracyCircleMarker=new ox({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",i=>{i.geolocateSource||"ACTIVE_LOCK"!==this._watchState||i.originalEvent&&"resize"===i.originalEvent.type||(this._watchState="BACKGROUND",this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-background"),this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-active"),this.fire(new e.z("trackuserlocationend")))})}}_onDeviceOrientation(e){this._userLocationDotMarker&&(e.webkitCompassHeading?this._heading=e.webkitCompassHeading:!0===e.absolute&&(this._heading=-1*e.alpha),this._updateMarkerRotationThrottled())}trigger(){if(!this._setup)return e.w("Geolocate control triggered before added to a map"),!1;if(this.options.trackUserLocation){switch(this._watchState){case"OFF":this._watchState="WAITING_ACTIVE",this.fire(new e.z("trackuserlocationstart"));break;case"WAITING_ACTIVE":case"ACTIVE_LOCK":case"ACTIVE_ERROR":case"BACKGROUND_ERROR":this._numberOfWatches--,this._noTimeout=!1,this._watchState="OFF",this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-waiting"),this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-active"),this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-active-error"),this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-background"),this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-background-error"),this.fire(new e.z("trackuserlocationend"));break;case"BACKGROUND":this._watchState="ACTIVE_LOCK",this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-background"),this._lastKnownPosition&&this._updateCamera(this._lastKnownPosition),this.fire(new e.z("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(){let e=()=>{"ondeviceorientationabsolute"in window?window.addEventListener("deviceorientationabsolute",this._onDeviceOrientation):window.addEventListener("deviceorientation",this._onDeviceOrientation)};"undefined"!=typeof DeviceMotionEvent&&"function"==typeof DeviceMotionEvent.requestPermission?DeviceOrientationEvent.requestPermission().then(i=>{"granted"===i&&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","fal
105se"),this.options.showUserLocation&&this._updateMarker(null)}},AttributionControl:oa,ScaleControl:class{constructor(i={}){this.options=Object.assign({},ob,i),this._isNumberFormatSupported=function(){try{return new Intl.NumberFormat("en",{style:"unit",unitDisplay:"short",unit:"meter"}),!0}catch(e){return!1}}(),e.aY(["_update","_setScale","setUnit"],this)}getDefaultPosition(){return"bottom-left"}_update(){let e=this.options.maxWidth||100,i=this._map,r=i._containerHeight/2,a=i._containerWidth/2-e/2,n=i.unproject([a,r]),o=i.unproject([a+e,r]),s=n.distanceTo(o);if("imperial"===this.options.unit){let i=3.2808*s;i>5280?this._setScale(e,i/5280,"mile"):this._setScale(e,i,"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,i,r){this._map._requestDomTask(()=>{let a=function(e){let i=Math.pow(10,`${Math.floor(e)}`.length-1),r=e/i;return i*(r=r>=10?10:r>=5?5:r>=3?3:r>=2?2:r>=1?1:function(e){let i=Math.pow(10,Math.ceil(-Math.log(e)/Math.LN10));return Math.round(e*i)/i}(r))}(i),n=a/i;this._container.innerHTML=this._isNumberFormatSupported&&"nautical-mile"!==r?new Intl.NumberFormat(this._language,{style:"unit",unitDisplay:"short",unit:r}).format(a):`${a} ${ow[r]}`,this._container.style.width=e*n+"px"})}onAdd(e){return this._map=e,this._language=e.getLanguage(),this._container=d("div","mapboxgl-ctrl mapboxgl-ctrl-scale",e.getContainer()),this._container.dir="auto",this._map.on("move",this._update),this._update(),this._container}onRemove(){this._container.remove(),this._map.off("move",this._update),this._map=void 0}_setLanguage(e){this._language=e,this._update()}setUnit(e){this.options.unit=e,this._update()}},FullscreenControl:class{constructor(i={}){this._fullscreen=!1,i&&i.container&&(i.container instanceof HTMLElement?this._container=i.container:e.w("Full screen control 'container' must be a DOM element.")),e.aY(["_onClickFullscreen","_changeIcon"],this),"onfullscreenchange"in document?this._fullscreenchange="fullscreenchange":"onwebkitfullscreenchange"in document&&(this._fullscreenchange="webkitfullscreenchange")}onAdd(i){return this._map=i,this._container||(this._container=this._map.getContainer()),this._controlContainer=d("div","mapboxgl-ctrl mapboxgl-ctrl-group"),this._checkFullscreenSupport()?this._setupUI():(this._controlContainer.style.display="none",e.w("This device does not support fullscreen mode.")),this._controlContainer}onRemove(){this._controlContainer.remove(),this._map=null,document.removeEventListener(this._fullscreenchange,this._changeIcon)}_checkFullscreenSupport(){return!(!document.fullscreenEnabled&&!document.webkitFullscreenEnabled)}_setupUI(){let e=this._fullscreenButton=d("button","mapboxgl-ctrl-fullscreen",this._controlContainer);d("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(){let 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:oo,Popup:class extends e.E{constructor(i){super(),this.options=Object.assign(Object.create(oT),i),this._altitude=this.options.altitude,e.aY(["_update","_onClose","remove","_onMouseEvent"],this),this._classList=new Set(i&&i.className?i.className.trim().split(/\s+/):[])}addTo(i){return this._map&&this.remove(),this._map=i,this.options.closeOnClick&&i.on("preclick",this._onClose),this.options.closeOnMove&&i.on("move",this._onClose),i.on("remove",this.remove),this._update(),i._addPopup(this),this._focusFirstElement(),this._trackPointer?(i.on("mousemove",this._onMouseEvent),i.on("mouseup",this._onMouseEvent),i._canvasContainer.classList.add("mapboxgl-track-pointer")):i.on("move",this._update),this.fire(new e.z("open")),this}isOpen(){return!!this._map}remove(){this._content&&this._content.remove(),this._container&&(this._container.remove(),this._container=void 0);let i=this._map;return i&&(i.off("move",this._update),i.off("move",this._onClose),i.off("preclick",this._onClose),i.off("click",this._onClose),i.off("remove",this.remove),i.off("mousemove",this._onMouseEvent),i.off("mouseup",this._onMouseEvent),i.off("drag",this._onMouseEvent),i._canvasContainer&&i._canvasContainer.classList.remove("mapboxgl-track-pointer"),i._removePopup(this),this._map=void 0),this.fire(new e.z("close")),this}getLngLat(){return this._lngLat}setLngLat(i){this._lngLat=e.aR.convert(i),this._pos=null,this._trackPointer=!1,this._update();let r=this._map;return r&&(r.on("move",this._update),r.off("mousemove",this._onMouseEvent),r._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();let 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){let i,r=document.createDocumentFragment(),a=document.createElement("body");for(a.innerHTML=e;i=a.firstChild;)r.appendChild(i);return this.setDOMContent(r)}getMaxWidth(){return this._container&&this._container.style.maxWidth}setMaxWidth(e){return this.options.maxWidth=e,this._update(),this}setDOMContent(e){let i=this._content;if(i)for(;i.hasChildNodes();)i.firstChild&&i.removeChild(i.firstChild);else i=this._content=d("div","mapboxgl-popup-content",this._container||void 0);if(i.appendChild(e),this.options.closeButton){let e=this._closeButton=d("button","mapboxgl-popup-close-button",i);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 i;return this._classList.delete(e)?i=!1:(this._classList.add(e),i=!0),this._updateClassList(),i}_onMouseEvent(e){this._update(e.point)}_getAnchor(e){if(this.options.anchor)return this.options.anchor;let i=this._map,r=this._container,a=this._pos;if(!i||!r||!a)return"bottom";let n=r.offsetWidth,o=r.offsetHeight,s=a.x<n/2,l=a.x>i.transform.width-n/2;if(a.y+e<o)return s?"top-left":l?"top-right":"top";if(a.y>i.transform.height-o){if(s)return"bottom-left";if(l)return"bottom-right"}return s?"left":l?"right":"bottom"}_updateClassList(){let e=this._container;if(!e)return;let i=[...this._classList];i.push("mapboxgl-popup"),this._anchor&&i.push(`mapboxgl-popup-anchor-${this._anchor}`),this._trackPointer&&i.push("mapboxgl-popup-track-pointer"),e.className=i.join(" ")}_update(i){let r=this._map,a=this._content;if(!r||!this._lngLat&&!this._trackPointer||!a)return;let n=this._container;if(n||(n=this._container=d("div","mapboxgl-popup",r.getContainer()),this._tip=d("div","mapboxgl-popup-tip",n),n.appendChild(a)),this.options.maxWidth&&n.style.maxWidth!==this.options.maxWidth&&(n.style.maxWidth=this.options.maxWidth),r.transform.renderWorldCopies&&!this._trackPointer&&(this._lngLat=om(this._lngLat,this._pos,r.transform)),!this._trackPointer||i){let a=this._pos=this._trackPointer&&i instanceof e.P?i:r.project(this._lngLat,this._altitude),n=oS(this.options.offset),o=this._anchor=this._getAnchor(n.y),s=oS(this.options.offset,o),l=a.add(s).round();r._requestDomTask(()=>{this._container&&o&&(this._container.style.transform=`${o_[o]} translate(${l.x}px,${l.y}px)`)})}if(!this._marker&&r._showingGlobe()){let i=+!e.eY(r.transform,this._lngLat);this._setOpacity(i)}this._updateClassList()}_focusFirstElement(){if(!this.options.focusAfterOpen||!this._container)return;
105let e=this._container.querySelector("a[href], [tabindex]:not([tabindex='-1']), [contenteditable]:not([contenteditable='false']), button:not([disabled]), input:not([disabled]), select:not([disabled]), textarea:not([disabled])");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:ox,Style:iw,LngLat:e.aR,LngLatBounds:e.aI,Point:e.P,MercatorCoordinate:e.ae,FreeCameraOptions:t9,Evented:e.E,config:e.e,prewarm:e.f0,clearPrewarmedResources:e.e$,get accessToken(){return e.e.ACCESS_TOKEN},set accessToken(t){e.e.ACCESS_TOKEN=t},get baseApiUrl(){return e.e.API_URL},set baseApiUrl(t){e.e.API_URL=t},get workerCount(){return e.f9.workerCount},set workerCount(t){e.f9.workerCount=t},get maxParallelImageRequests(){return e.e.MAX_PARALLEL_IMAGE_REQUESTS},set maxParallelImageRequests(t){e.e.MAX_PARALLEL_IMAGE_REQUESTS=t},clearStorage(i){e.f8(i)},get workerUrl(){return e.f7.workerUrl},set workerUrl(t){e.f7.workerUrl=t},get workerClass(){return e.f7.workerClass},set workerClass(t){e.f7.workerClass=t},get workerParams(){return e.f7.workerParams},set workerParams(t){e.f7.workerParams=t},get dracoUrl(){return e.f6()},set dracoUrl(t){e.f5(t)},get meshoptUrl(){return e.f4()},set meshoptUrl(t){e.f3(t)},setNow:e.o.setNow,restoreNow:e.o.restoreNow}}),r}()}}]);
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.