1"use strict";(()=>{var WT=Object.create;var E1=Object.defineProperty;var XT=Object.getOwnPropertyDescriptor;var YT=Object.getOwnPropertyNames;var JT=Object.getPrototypeOf,KT=Object.prototype.hasOwnProperty;var QT=(Vt,ci)=>()=>(ci||Vt((ci={exports:{}}).exports,ci),ci.exports);var e2=(Vt,ci,ri,Zi)=>{if(ci&&typeof ci=="object"||typeof ci=="function")for(let pn of YT(ci))!KT.call(Vt,pn)&&pn!==ri&&E1(Vt,pn,{get:()=>ci[pn],enumerable:!(Zi=XT(ci,pn))||Zi.enumerable});return Vt};var t2=(Vt,ci,ri)=>(ri=Vt!=null?WT(JT(Vt)):{},e2(ci||!Vt||!Vt.__esModule?E1(ri,"default",{value:Vt,enumerable:!0}):ri,Vt));var M1=QT(($y,Hy)=>{(function(Vt,ci){typeof $y=="object"&&typeof Hy<"u"?Hy.exports=ci():typeof define=="function"&&define.amd?define(ci):(Vt=typeof globalThis<"u"?globalThis:Vt||self,Vt.mapboxgl=ci())})($y,function(){"use strict";let Vt,ci,ri;function Zi(h,U){if(!Vt)Vt=U;else if(!ci)ci=U;else{let ln={};Vt(void 0,ln),ri=U(ln);let gi="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 = {}; ("+Vt+")(undefined, sharedChunk); ("+ci+")(undefined, sharedChunk); self.onerror = null;";typeof window<"u"&&window&&window.URL&&window.URL.createObjectURL&&(ri.workerUrl=window.URL.createObjectURL(new Blob([gi],{type:"text/javascript"})))}}Zi(["require","exports"],function(h,U){var ln=1e-6,gi=typeof Float32Array<"u"?Float32Array:Array;function Cr(n,e){var i=e[0],r=e[1],s=e[2],l=e[3],u=i*l-s*r;return u?(n[0]=l*(u=1/u),n[1]=-r*u,n[2]=-s*u,n[3]=i*u,n):null}function Yr(){var n=new gi(9);return gi!=Float32Array&&(n[1]=0,n[2]=0,n[3]=0,n[5]=0,n[6]=0,n[7]=0),n[0]=1,n[4]=1,n[8]=1,n}function uo(n,e){var i=e[0],r=e[1],s=e[2],l=e[3],u=e[4],p=e[5],f=e[6],g=e[7],x=e[8];return n[0]=u*x-p*g,n[1]=s*g-r*x,n[2]=r*p-s*u,n[3]=p*f-l*x,n[4]=i*x-s*f,n[5]=s*l-i*p,n[6]=l*g-u*f,n[7]=r*f-i*g,n[8]=i*u-r*l,n}function Jr(n,e,i){var r=e[0],s=e[1],l=e[2],u=e[3],p=e[4],f=e[5],g=e[6],x=e[7],b=e[8],w=i[0],S=i[1],E=i[2],M=i[3],C=i[4],R=i[5],F=i[6],z=i[7],j=i[8];return n[0]=w*r+S*u+E*g,n[1]=w*s+S*p+E*x,n[2]=w*l+S*f+E*b,n[3]=M*r+C*u+R*g,n[4]=M*s+C*p+R*x,n[5]=M*l+C*f+R*b,n[6]=F*r+z*u+j*g,n[7]=F*s+z*p+j*x,n[8]=F*l+z*f+j*b,n}function fs(){var n=new gi(16);return gi!=Float32Array&&(n[1]=0,n[2]=0,n[3]=0,n[4]=0,n[6]=0,n[7]=0,n[8]=0,n[9]=0,n[11]=0,n[12]=0,n[13]=0,n[14]=0),n[0]=1,n[5]=1,n[10]=1,n[15]=1,n}function Kl(n){var e=new gi(16);return e[0]=n[0],e[1]=n[1],e[2]=n[2],e[3]=n[3],e[4]=n[4],e[5]=n[5],e[6]=n[6],e[7]=n[7],e[8]=n[8],e[9]=n[9],e[10]=n[10],e[11]=n[11],e[12]=n[12],e[13]=n[13],e[14]=n[14],e[15]=n[15],e}function Rt(n){return n[0]=1,n[1]=0,n[2]=0,n[3]=0,n[4]=0,n[5]=1,n[6]=0,n[7]=0,n[8]=0,n[9]=0,n[10]=1,n[11]=0,n[12]=0,n[13]=0,n[14]=0,n[15]=1,n}function mr(n,e){var i=e[0],r=e[1],s=e[2],l=e[3],u=e[4],p=e[5],f=e[6],g=e[7],x=e[8],b=e[9],w=e[10],S=e[11],E=e[12],M=e[13],C=e[14],R=e[15],F=i*p-r*u,z=i*f-s*u,j=i*g-l*u,$=r*f-s*p,H=r*g-l*p,ie=s*g-l*f,W=x*M-b*E,Q=x*C-w*E,Y=x*R-S*E,ee=b*C-w*M,me=b*R-S*M,ge=w*R-S*C,Te=F*ge-z*me+j*ee+$*Y-H*Q+ie*W;return Te?(n[0]=(p*ge-f*me+g*ee)*(Te=1/Te),n[1]=(s*me-r*ge-l*ee)*Te,n[2]=(M*ie-C*H+R*$)*Te,n[3]=(w*H-b*ie-S*$)*Te,n[4]=(f*Y-u*ge-g*Q)*Te,n[5]=(i*ge-s*Y+l*Q)*Te,n[6]=(C*j-E*ie-R*z)*Te,n[7]=(x*ie-w*j+S*z)*Te,n[8]=(u*me-p*Y+g*W)*Te,n[9]=(r*Y-i*me-l*W)*Te,n[10]=(E*H-M*j+R*F)*Te,n[11]=(b*j-x*H-S*F)*Te,n[12]=(p*Q-u*ee-f*W)*Te,n[13]=(i*ee-r*Q+s*W)*Te,n[14]=(M*z-E*$-C*F)*Te,n[15]=(x*$-b*z+w*F)*Te,n):null}function xi(n,e,i){var r=e[0],s=e[1],l=e[2],u=e[3],p=e[4],f=e[5],g=e[6],x=e[7],b=e[8],w=e[9],S=e[10],E=e[11],M=e[12],C=e[13],R=e[14],F=e[15],z=i[0],j=i[1],$=i[2],H=i[3];return n[0]=z*r+j*p+$*b+H*M,n[1]=z*s+j*f+$*w+H*C,n[2]=z*l+j*g+$*S+H*R,n[3]=z*u+j*x+$*E+H*F,n[4]=(z=i[4])*r+(j=i[5])*p+($=i[6])*b+(H=i[7])*M,n[5]=z*s+j*f+$*w+H*C,n[6]=z*l+j*g+$*S+H*R,n[7]=z*u+j*x+$*E+H*F,n[8]=(z=i[8])*r+(j=i[9])*p+($=i[10])*b+(H=i[11])*M,n[9]=z*s+j*f+$*w+H*C,n[10]=z*l+j*g+$*S+H*R,n[11]=z*u+j*x+$*E+H*F,n[12]=(z=i[12])*r+(j=i[13])*p+($=i[14])*b+(H=i[15])*M,n[13]=z*s+j*f+$*w+H*C,n[14]=z*l+j*g+$*S+H*R,n[15]=z*u+j*x+$*E+H*F,n}function Gn(n,e,i){var r,s,l,u,p,f,g,x,b,w,S,E,M=i[0],C=i[1],R=i[2];return e===n?(n[12]=e[0]*M+e[4]*C+e[8]*R+e[12],n[13]=e[1]*M+e[5]*C+e[9]*R+e[13],n[14]=e[2]*M+e[6]*C+e[10]*R+e[14],n[15]=e[3]*M+e[7]*C+e[11]*R+e[15]):(s=e[1],l=e[2],u=e[3],p=e[4],f=e[5],g=e[6],x=e[7],b=e[8],w=e[9],S=e[10],E=e[11],n[0]=r=e[0],n[1]=s,n[2]=l,n[3]=u,n[4]=p,n[5]=f,n[6]=g,n[7]=x,n[8]=b,n[9]=w,n[10]=S,n[11]=E,n[12]=r*M+p*C+b*R+e[12],n[13]=s*M+f*C+w*R+e[13],n[14]=l*M+g*C+S*R+e[14],n[15]=u*M+x*C+E*R+e[15]),n}function Zn(n,e,i){var r=i[0],s=i[1],l=i[2];return n[0]=e[0]*r,n[1]=e[1]*r,n[2]=e[2]*r,n[3]=e[3]*r,n[4]=e[4]*s,n[5]=e[5]*s,n[6]=e[6]*s,n[7]=e[7]*s,n[8]=e[8]*l,n[9]=e[9]*l,n[10]=e[10]*l,n[11]=e[11]*l,n[12]=e[12],n[13]=e[13],n[14]=e[14],n[15]=e[15],n}function Vo(n,e,i){var r=Math.sin(i),s=Math.cos(i),l=e[4],u=e[5],p=e[6],f=e[7],g=e[8],x=e[9],b=e[10],w=e[11];return e!==n&&(n[0]=e[0],n[1]=e[1],n[2]=e[2],n[3]=e[3],n[12]=e[12],n[13]=e[13],n[14]=e[14],n[15]=e[15]),n[4]=l*s+g*r,n[5]=u*s+x*r,n[6]=p*s+b*r,n[7]=f*s+w*r,n[8]=g*s-l*r,n[9]=x*s-u*r,n[10]=b*s-p*r,n[11]=w*s-f*r,n}function jo(n,e,i){var r=Math.sin(i),s=Math.cos(i),l=e[0],u=e[1],p=e[2],f=e[3],g=e[8],x=e[9],b=e[10],w=e[11];return e!==n&&(n[4]=e[4],n[5]=e[5],n[6]=e[6],n[7]=e[7],n[12]=e[12],n[13]=e[13],n[14]=e[14],n[15]=e[15]),n[0]=l*s-g*r,n[1]=u*s-x*r,
vendor: 4,453 bytes, line 1
1n[2]=p*s-b*r,n[3]=f*s-w*r,n[8]=l*r+g*s,n[9]=u*r+x*s,n[10]=p*r+b*s,n[11]=f*r+w*s,n}function ho(n,e,i){var r=Math.sin(i),s=Math.cos(i),l=e[0],u=e[1],p=e[2],f=e[3],g=e[4],x=e[5],b=e[6],w=e[7];return e!==n&&(n[8]=e[8],n[9]=e[9],n[10]=e[10],n[11]=e[11],n[12]=e[12],n[13]=e[13],n[14]=e[14],n[15]=e[15]),n[0]=l*s+g*r,n[1]=u*s+x*r,n[2]=p*s+b*r,n[3]=f*s+w*r,n[4]=g*s-l*r,n[5]=x*s-u*r,n[6]=b*s-p*r,n[7]=w*s-f*r,n}function ms(n,e){return n[0]=1,n[1]=0,n[2]=0,n[3]=0,n[4]=0,n[5]=1,n[6]=0,n[7]=0,n[8]=0,n[9]=0,n[10]=1,n[11]=0,n[12]=e[0],n[13]=e[1],n[14]=e[2],n[15]=1,n}function Go(n,e){return n[0]=e[0],n[1]=0,n[2]=0,n[3]=0,n[4]=0,n[5]=e[1],n[6]=0,n[7]=0,n[8]=0,n[9]=0,n[10]=e[2],n[11]=0,n[12]=0,n[13]=0,n[14]=0,n[15]=1,n}function ta(n,e,i){var r,s,l,u=i[0],p=i[1],f=i[2],g=Math.sqrt(u*u+p*p+f*f);return g<ln?null:(u*=g=1/g,p*=g,f*=g,r=Math.sin(e),s=Math.cos(e),n[0]=u*u*(l=1-s)+s,n[1]=p*u*l+f*r,n[2]=f*u*l-p*r,n[3]=0,n[4]=u*p*l-f*r,n[5]=p*p*l+s,n[6]=f*p*l+u*r,n[7]=0,n[8]=u*f*l+p*r,n[9]=p*f*l-u*r,n[10]=f*f*l+s,n[11]=0,n[12]=0,n[13]=0,n[14]=0,n[15]=1,n)}function Ql(n,e){var i=e[0],r=e[1],s=e[2],l=e[4],u=e[5],p=e[6],f=e[8],g=e[9],x=e[10];return n[0]=Math.sqrt(i*i+r*r+s*s),n[1]=Math.sqrt(l*l+u*u+p*p),n[2]=Math.sqrt(f*f+g*g+x*x),n}function ec(n,e){var i=e[0],r=e[1],s=e[2],l=e[3],u=i+i,p=r+r,f=s+s,g=i*u,x=r*u,b=r*p,w=s*u,S=s*p,E=s*f,M=l*u,C=l*p,R=l*f;return n[0]=1-b-E,n[1]=x+R,n[2]=w-C,n[3]=0,n[4]=x-R,n[5]=1-g-E,n[6]=S+M,n[7]=0,n[8]=w+C,n[9]=S-M,n[10]=1-g-b,n[11]=0,n[12]=0,n[13]=0,n[14]=0,n[15]=1,n}var tc=xi;function si(){var n=new gi(3);return gi!=Float32Array&&(n[0]=0,n[1]=0,n[2]=0),n}function ic(n){var e=new gi(3);return e[0]=n[0],e[1]=n[1],e[2]=n[2],e}function Dn(n){var e=n[0],i=n[1],r=n[2];return Math.sqrt(e*e+i*i+r*r)}function Fn(n,e,i){var r=new gi(3);return r[0]=n,r[1]=e,r[2]=i,r}function Ei(n,e,i,r){return n[0]=e,n[1]=i,n[2]=r,n}function tn(n,e,i){return n[0]=e[0]+i[0],n[1]=e[1]+i[1],n[2]=e[2]+i[2],n}function po(n,e,i){return n[0]=e[0]-i[0],n[1]=e[1]-i[1],n[2]=e[2]-i[2],n}function nc(n,e,i){return n[0]=e[0]*i[0],n[1]=e[1]*i[1],n[2]=e[2]*i[2],n}function Rn(n,e,i){return n[0]=Math.min(e[0],i[0]),n[1]=Math.min(e[1],i[1]),n[2]=Math.min(e[2],i[2]),n}function Pr(n,e,i){return n[0]=Math.max(e[0],i[0]),n[1]=Math.max(e[1],i[1]),n[2]=Math.max(e[2],i[2]),n}function Li(n,e,i){return n[0]=e[0]*i,n[1]=e[1]*i,n[2]=e[2]*i,n}function Dr(n,e,i,r){return n[0]=e[0]+i[0]*r,n[1]=e[1]+i[1]*r,n[2]=e[2]+i[2]*r,n}function ia(n,e){var i=e[0]-n[0],r=e[1]-n[1],s=e[2]-n[2];return Math.sqrt(i*i+r*r+s*s)}function $o(n,e){var i=e[0]-n[0],r=e[1]-n[1],s=e[2]-n[2];return i*i+r*r+s*s}function rc(n){var e=n[0],i=n[1],r=n[2];return e*e+i*i+r*r}function fo(n,e){return n[0]=-e[0],n[1]=-e[1],n[2]=-e[2],n}function hi(n,e){var i=e[0],r=e[1],s=e[2],l=i*i+r*r+s*s;return l>0&&(l=1/Math.sqrt(l)),n[0]=e[0]*l,n[1]=e[1]*l,n[2]=e[2]*l,n}function Qi(n,e){return n[0]*e[0]+n[1]*e[1]+n[2]*e[2]}function Wn(n,e,i){var r=e[0],s=e[1],l=e[2],u=i[0],p=i[1],f=i[2];return n[0]=s*f-l*p,n[1]=l*u-r*f,n[2]=r*p-s*u,n}function na(n,e,i,r){var s=e[0],l=e[1],u=e[2];return n[0]=s+r*(i[0]-s),n[1]=l+r*(i[1]-l),n[2]=u+r*(i[2]-u),n}function Oi(n,e,i){var r=e[0],s=e[1],l=e[2],u=i[3]*r+i[7]*s+i[11]*l+i[15];return n[0]=(i[0]*r+i[4]*s+i[8]*l+i[12])/(u=u||1),n[1]=(i[1]*r+i[5]*s+i[9]*l+i[13])/u,n[2]=(i[2]*r+i[6]*s+i[10]*l+i[14])/u,n}function _s(n,e,i){var r=e[0],s=e[1],l=e[2];return n[0]=r*i[0]+s*i[3]+l*i[6],n[1]=r*i[1]+s*i[4]+l*i[7],n[2]=r*i[2]+s*i[5]+l*i[8],n}function Za(n,e,i){var r=i[0],s=i[1],l=i[2],u=i[3],p=e[0],f=e[1],g=e[2],x=s*g-l*f,b=l*p-r*g,w=r*f-s*p;return n[0]=p+u*(x+=x)+s*(w+=w)-l*(b+=b),n[1]=f+u*b+l*x-r*w,n[2]=g+u*w+r*b-s*x,n}function Wa(n){return n[0]=0,n[1]=0,n[2]=0,n}function Mo(n,e){return n[0]===e[0]&&n[1]===e[1]&&n[2]===e[2]}var Gi=po,Xa=nc,ra=Dn;function Ya(){var n=new gi(4);return gi!=Float32Array&&(n[0]=0,n[1]=0,n[2]=0,n[3]=0),n}function oa(n,e,i){return n[0]=e[0]*i,n[1]=e[1]*i,n[2]=e[2]*i,n[3]=e[3]*i,n}function Ho(n,e){var i=e[0],r=e[1],s=e[2],l=e[3],u=i*i+r*r+s*s+l*l;return u>0&&(u=1/Math.sqrt(u)),n[0]=i*u,n[1]=r*u,n[2]=s*u,n[3]=l*u,n}function _r(n,e,i){var r=e[0],s=e[1],l=e[2],u=e[3];return n[0]=i[0]*r+i[4]*s+i[8]*l+i[12]*u,n[1]=i[1]*r+i[5]*s+i[9]*l+i[13]*u,n[2]=i[2]*r+i[6]*s+i[10]*l+i[14]*u,n[3]=i[3]*r+i[7]*s+i[11]*l+i[15]*u,n}function gs(){var n=new gi(4);return gi!=Float32Array&&(n[0]=0,n[1]=0,n[2]=0),n[3]=1,n}function ys(n){return n[0]=0,n[1]=0,n[2]=0,n[3]=1,n}function Ja(n,e,i){i*=.5;var r=e[0],s=e[1],l=e[2],u=e[3],p=Math.sin(i),f=Math.cos(i);
1return n[0]=r*f+u*p,n[1]=s*f+l*p,n[2]=l*f-s*p,n[3]=u*f-r*p,n}function sa(n,e,i){i*=.5;var r=e[0],s=e[1],l=e[2],u=e[3],p=Math.sin(i),f=Math.cos(i);return n[0]=r*f-l*p,n[1]=s*f+u*p,n[2]=l*f+r*p,n[3]=u*f-s*p,n}si(),Ya();var gr,oc,Rr,uu=Ho,sc=(gr=si(),oc=Fn(1,0,0),Rr=Fn(0,1,0),function(n,e,i){var r=Qi(e,i);return r<-.999999?(Wn(gr,oc,e),ra(gr)<1e-6&&Wn(gr,Rr,e),hi(gr,gr),function(s,l,u){u*=.5;var p=Math.sin(u);s[0]=p*l[0],s[1]=p*l[1],s[2]=p*l[2],s[3]=Math.cos(u)}(n,gr,Math.PI),n):r>.999999?(n[0]=0,n[1]=0,n[2]=0,n[3]=1,n):(Wn(gr,e,i),n[0]=gr[0],n[1]=gr[1],n[2]=gr[2],n[3]=1+r,uu(n,n))});function Xn(){var n=new gi(2);return gi!=Float32Array&&(n[0]=0,n[1]=0),n}function mo(n,e){var i=new gi(2);return i[0]=n,i[1]=e,i}function qo(n,e,i){return n[0]=e,n[1]=i,n}function aa(n,e,i){return n[0]=e[0]+i[0],n[1]=e[1]+i[1],n}function _o(n,e,i){return n[0]=e[0]-i[0],n[1]=e[1]-i[1],n}function la(n,e,i){return n[0]=e[0]*i,n[1]=e[1]*i,n}function ca(n){var e=n[0],i=n[1];return Math.sqrt(e*e+i*i)}function ac(n,e){var i=e[0],r=e[1],s=i*i+r*r;return s>0&&(s=1/Math.sqrt(s)),n[0]=e[0]*s,n[1]=e[1]*s,n}function Co(n,e){return n[0]*e[0]+n[1]*e[1]}gs(),gs(),Yr();var lc,hu,Ka=_o;function du(n){return n&&n.__esModule&&Object.prototype.hasOwnProperty.call(n,"default")?n.default:n}Xn();var Fh=function(){if(hu)return lc;function n(e,i,r,s){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*(s-i)-this.cy,this.ay=1-this.cy-this.by,this.p1x=e,this.p1y=i,this.p2x=r,this.p2y=s}return hu=1,lc=n,n.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(i===void 0&&(i=1e-6),e<0)return 0;if(e>1)return 1;for(var r=e,s=0;s<8;s++){var l=this.sampleCurveX(r)-e;if(Math.abs(l)<i)return r;var u=this.sampleCurveDerivativeX(r);if(Math.abs(u)<1e-6)break;r-=l/u}var p=0,f=1;for(r=e,s=0;s<20&&(l=this.sampleCurveX(r),!(Math.abs(l-e)<i));s++)e>l?p=r:f=r,r=.5*(f-p)+p;return r},solve:function(e,i){return this.sampleCurveY(this.solveCurveX(e,i))}},lc}(),Qa=du(Fh);function ke(n,e){this.x=n,this.y=e}function Zo(n,e){if(Array.isArray(n)){if(!Array.isArray(e)||n.length!==e.length)return!1;for(let i=0;i<n.length;i++)if(!Zo(n[i],e[i]))return!1;return!0}if(typeof n=="object"&&n!==null&&e!==null){if(typeof e!="object"||Object.keys(n).length!==Object.keys(e).length)return!1;for(let i in n)if(!Zo(n[i],e[i]))return!1;return!0}return n===e}ke.prototype={clone(){return new ke(this.x,this.y)},add(n){return this.clone()._add(n)},sub(n){return this.clone()._sub(n)},multByPoint(n){return this.clone()._multByPoint(n)},divByPoint(n){return this.clone()._divByPoint(n)},mult(n){return this.clone()._mult(n)},div(n){return this.clone()._div(n)},rotate(n){return this.clone()._rotate(n)},rotateAround(n,e){return this.clone()._rotateAround(n,e)},matMult(n){return this.clone()._matMult(n)},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(n){return this.x===n.x&&this.y===n.y},dist(n){return Math.sqrt(this.distSqr(n))},distSqr(n){let e=n.x-this.x,i=n.y-this.y;return e*e+i*i},angle(){return Math.atan2(this.y,this.x)},angleTo(n){return Math.atan2(this.y-n.y,this.x-n.x)},angleWith(n){return this.angleWithSep(n.x,n.y)},angleWithSep(n,e){return Math.atan2(this.x*e-this.y*n,this.x*n+this.y*e)},_matMult(n){let e=n[2]*this.x+n[3]*this.y;return this.x=n[0]*this.x+n[1]*this.y,this.y=e,this},_add(n){return this.x+=n.x,this.y+=n.y,this},_sub(n){return this.x-=n.x,this.y-=n.y,this},_mult(n){return this.x*=n,this.y*=n,this},_div(n){return this.x/=n,this.y/=n,this},_multByPoint(n){return this.x*=n.x,this.y*=n.y,this},_divByPoint(n){return this.x/=n.x,this.y/=n.y,this},_unit(){return this._div(this.mag()),this},_perp(){let n=this.y;return this.y=this.x,this.x=-n,this},_rotate(n){let e=Math.cos(n),i=Math.sin(n),r=i*this.x+e*this.y;return this.x=e*this.x-i*this.y,this.y=r,this},_rotateAround(n,e){let i=Math.cos(n),r=Math.sin(n),s=e.y+r*(this.x-e.x)+i*(this.y-e.y);return this.x=e.x+i*(this.x-e.x)-r*(this.y-e.y),this.y=s,this},_round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this},constructor:ke},ke.convert=function(n){if(n instanceof ke)return n;if(Array.isArray(n))return new ke(+n[0],+n[1]);if(n.x!==void 0&&n.y!==void 0)return new ke(+n.x,+n.y);throw new Error("Expected [x, y] or {x, y} point format")};let xs=Math.PI/180,ua=180/Math.PI,el=/^[0-9a-f]{8}-[0-9a-f]{4}-[4][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i,_e=/\b(iPad|iPhone|iPod)\b/,B=/CPU (OS|iPhone OS) (15_4|15_5) like Mac OS X/;function V(n){return n*xs}function X(n){return n*ua}let ae=[[0,0],[1,0],[1,1],[0,1]];function le(n){if(n<=0)return 0;if(n>=1)return 1;let e=n*n,i=e*n;return 4*(n<.5?i:3*(n-e)+i-.75)}function ce(n,e,i,r){let s=new Qa(n,e,i,r);return function(l){return s.solve(l)}}let we=ce(.25,.1,.25,1);function ne(n,e,i){return Math.min(i,Math.max(e,n))}function ye(n,e,i){return(i=ne((i-n)/(e-n),0,1))*i*(3-2*i)}function Ne(n,e,i){let r=i-e,s=((n-e)%r+r)%r+e;return s===e?i:s}function Oe(n,e,i){if(!n.length)return i(null,[]);let r=n.length,s=new Array(n.length),l=null;
1n.forEach((u,p)=>{e(u,(f,g)=>{f&&(l=f),s[p]=g,--r===0&&i(l,s)})})}function Ke(n,e){let i={};for(let r=0;r<e.length;r++){let s=e[r];s in n&&(i[s]=n[s])}return i}let ct=1;function ht(){return ct++}function Lt(n){return n<=1?1:Math.pow(2,Math.ceil(Math.log2(n)))}function St(n,e){n.forEach(i=>{e[i]&&(e[i]=e[i].bind(e))})}function Mt(n,e,i){let r={};for(let s in n)r[s]=e.call(this,n[s],s,n);return r}function Ve(n,e,i){let r={};for(let s in n)e.call(this,n[s],s,n)&&(r[s]=n[s]);return r}function Ut(n){return Array.isArray(n)?n.map(Ut):typeof n=="object"&&n?Mt(n,Ut):n}function $i(n,e){for(let i=0;i<n.length;i++)if(e.includes(n[i]))return!0;return!1}let Hi={};function Ot(n){Hi[n]||(typeof console<"u"&&console.warn(n),Hi[n]=!0)}function ti(n,e,i){return(i.y-n.y)*(e.x-n.x)>(e.y-n.y)*(i.x-n.x)}function Ci(n){let e=0;for(let i,r,s=0,l=n.length,u=l-1;s<l;u=s++)i=n[s],r=n[u],e+=(r.x-i.x)*(i.y+r.y);return e}function nn([n,e,i]){let r=V(e+90),s=V(i);return{x:n*Math.cos(r)*Math.sin(s),y:n*Math.sin(r)*Math.sin(s),z:n*Math.cos(s),azimuthal:e,polar:i}}function ii(n){return(typeof self<"u"||n!==void 0)&&typeof WorkerGlobalScope<"u"&&(n!==void 0?n:self)instanceof WorkerGlobalScope}function Ai(n){let e={};if(n.replace(/(?:^|(?:\s*\,\s*))([^\x00-\x20\(\)<>@\,;\:\\"\/\[\]\?\=\{\}\x7F]+)(?:\=(?:([^\x00-\x20\(\)<>@\,;\:\\"\/\[\]\?\=\{\}\x7F]+)|(?:\"((?:[^"\\]|\\.)*)\")))?/g,(i,r,s,l)=>{let u=s||l;return e[r]=!u||u.toLowerCase(),""}),e["max-age"]){let i=parseInt(e["max-age"],10);isNaN(i)?delete e["max-age"]:e["max-age"]=i}return e}let Bi,vi=null;function Wi(n,e){return[n[4*e],n[4*e+1],n[4*e+2],n[4*e+3]]}function Bn(n,e,i,r){for(;e<i;){let s=e+i>>1;n[s]<r?e=s+1:i=s}return e}function yn(n,e,i,r){for(;e<i;){let s=e+i>>1;n[s]<=r?e=s+1:i=s}return e}function zn(n){return n>0?1/(1.001-n):1+n}function zr(n){return n>0?1-1/(1.001-n):-n}function go(n,e,i){return(n-e.min)*(i.max-i.min)/(e.max-e.min)+i.min}let di={API_URL:"https://api.mapbox.com",API_URL_REGEX:/^((https?:)?\/\/)?([^\/]+\.)?mapbox\.c(n|om)(\/|\?|$)/i,API_TILEJSON_REGEX:/^((https?:)?\/\/)?([^\/]+\.)?mapbox\.c(n|om)(\/v[0-9]*\/.*\.json.*$)/i,API_SPRITE_REGEX:/^((https?:)?\/\/)?([^\/]+\.)?mapbox\.c(n|om)(\/styles\/v[0-9]*\/)(.*\/sprite.*\..*$)/i,API_FONTS_REGEX:/^((https?:)?\/\/)?([^\/]+\.)?mapbox\.c(n|om)(\/fonts\/v[0-9]*\/)(.*\.pbf.*$)/i,API_STYLE_REGEX:/^((https?:)?\/\/)?([^\/]+\.)?mapbox\.c(n|om)(\/styles\/v[0-9]*\/)(.*$)/i,API_CDN_URL_REGEX:/^((https?:)?\/\/)?api\.mapbox\.c(n|om)(\/mapbox-gl-js\/)(.*$)/i,get EVENTS_URL(){if(!di.API_URL)return null;try{let n=new URL(di.API_URL);return n.hostname==="api.mapbox.cn"?"https://events.mapbox.cn/events/v2":n.hostname==="api.mapbox.com"?"https://events.mapbox.com/events/v2":null}catch{return null}},SESSION_PATH:"/map-sessions/v1",FEEDBACK_URL:"https://apps.mapbox.com/feedback",TILE_URL_VERSION:"v4",RASTER_URL_PREFIX:"raster/v1",RASTERARRAYS_URL_PREFIX:"rasterarrays/v1",REQUIRE_ACCESS_TOKEN:!0,ACCESS_TOKEN:null,DEFAULT_STYLE:"mapbox://styles/mapbox/standard",MAX_PARALLEL_IMAGE_REQUESTS:16,DRACO_URL:"/mapbox-gl-js/draco_decoder_gltf_v1.5.6.wasm",MESHOPT_URL:"/mapbox-gl-js/meshopt_base_v0.20.wasm",MESHOPT_SIMD_URL:"/mapbox-gl-js/meshopt_simd_v0.20.wasm",BUILDING_GEN_URL:"/mapbox-gl-js/building-gen/building_gen_v1.2.4.wasm",GLYPHS_URL:"mapbox://fonts/mapbox/{fontstack}/{range}.pbf",TILES3D_URL_PREFIX:"3dtiles/v1",TILE_PROVIDER_URLS:Object.assign(Object.create(null),{pmtiles:"/mapbox-gl-js/plugins/mapbox-gl-pmtiles-provider/v0.0.2/mapbox-gl-pmtiles-provider.js"})};function ha(){return new URL(di.DRACO_URL,di.API_URL).href}function da(){if(typeof WebAssembly!="object")throw new Error("WebAssembly not supported, cannot instantiate meshoptimizer");return new URL(function(){if(Bi===void 0){if(typeof WebAssembly!="object")return!1;let n=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]);Bi=WebAssembly.validate(n)}return Bi}()?di.MESHOPT_SIMD_URL:di.MESHOPT_URL,di.API_URL).href}function pa(){return new URL(di.BUILDING_GEN_URL,di.API_URL).href}function vs(n){return di.API_URL_REGEX.test(n)}function tl(n){return di.API_SPRITE_REGEX.test(n)}let pu,cc,fu,Pi,In,uc;function Bh(){return pu==null&&(pu=self.OffscreenCanvas&&new OffscreenCanvas(1,1).getContext("2d")&&typeof self.createImageBitmap=="function"),pu}let xn={requestIdleCallback:n=>{if(typeof requestIdleCallback<"u")return requestIdleCallback(n);setTimeout(()=>n({didTimeout:!1,timeRemaining:()=>50}),0)},now:()=>Pi!==void 0?Pi:performance.now(),setNow(n){Pi=n},restoreNow(){Pi=void 0},frame(n){let e=requestAnimationFrame(n);return{cancel:()=>cancelAnimationFrame(e)}},getImageData(n,e=0){let{width:i,height:r}=n;In||(In=document.createElement("canvas"));let s=In.getContext("2d",{willReadFrequently:!0});if(!s)throw new Error("failed to create canvas 2d context");return(i>In.width||r>In.height)&&(In.width=i,In.height=r),s.clearRect(-e,-e,i+2*e,r+2*e),s.drawImage(n,
10,0,i,r),s.getImageData(-e,-e,i+2*e,r+2*e)},resolveURL:n=>(cc||(cc=document.createElement("a")),cc.href=n,cc.href),get devicePixelRatio(){return window.devicePixelRatio},get prefersReducedMotion(){return!!window.matchMedia&&(fu==null&&(fu=window.matchMedia("(prefers-reduced-motion: reduce)")),fu.matches)},hasCanvasFingerprintNoise(){if(uc!==void 0)return uc;if(!Bh())return uc=!1,!1;let n=new OffscreenCanvas(85,1),e=n.getContext("2d",{willReadFrequently:!0}),i=0;for(let s=0;s<n.width;++s)e.fillStyle=`rgba(${i++},${i++},${i++}, 255)`,e.fillRect(s,0,1,1);let r=e.getImageData(0,0,n.width,n.height);i=0;for(let s=0;s<r.data.length;++s)if(s%4!=3&&i++!==r.data[s])return uc=!0,!0;return uc=!1,!1}};function Jp(n,e){let i=n.indexOf("?");if(i<0)return`${n}?${new URLSearchParams(e).toString()}`;let r=new URLSearchParams(n.slice(i));for(let s in e)r.set(s,e[s]);return`${n.slice(0,i)}?${r.toString()}`}function kh(n,e={persistentParams:[]}){let i=n.indexOf("?");if(i<0)return n;let r=new URLSearchParams,s=new URLSearchParams(n.slice(i));
1for(let u of e.persistentParams){let p=s.get(u);p&&r.set(u,p)}let l=r.toString();return`${n.slice(0,i)}${l.length>0?`?${l}`:""}`}let Kp="mapbox-tiles",Qp=500,ef=50,tf=["language","worldview","jobid"],Wo;function nf(){try{return caches}catch{}}function fa(){let n=nf();n&&Wo==null&&(Wo=n.open(Kp))}let Nh=1/0,Uh={supported:!1,testSupport:function(n){!ma&&$n&&(dc?jh(n):hc=n)}},hc,$n,ma=!1,dc=!1,Vh=typeof self<"u"?self:{};function jh(n){let e=n.createTexture();n.bindTexture(n.TEXTURE_2D,e);try{if(n.texImage2D(n.TEXTURE_2D,0,n.RGBA,n.RGBA,n.UNSIGNED_BYTE,$n),n.isContextLost())return;Uh.supported=!0}catch{}n.deleteTexture(e),ma=!0}Vh.document&&($n=Vh.document.createElement("img"),$n.onload=function(){hc&&jh(hc),hc=null,dc=!0},$n.onerror=function(){ma=!0,hc=null},$n.src="data:image/webp;base64,UklGRh4AAABXRUJQVlA4TBEAAAAvAQAAAAfQ//73v/+BiOh/AAA=");let bs={Unknown:"Unknown",Style:"Style",Source:"Source",Tile:"Tile",Glyphs:"Glyphs",SpriteImage:"SpriteImage",SpriteJSON:"SpriteJSON",Iconset:"Iconset",Image:"Image",Model:"Model"};Object.freeze(bs);
1class Gh extends Error{constructor(e,i,r){i===401&&vs(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}`}}function ws(n){return typeof n=="object"&&n!==null&&"status"in n&&n.status===404}let il=ii()?()=>self.worker.referrer:()=>(location.protocol==="blob:"?parent:self).location.href,rf=/^\w+:/,of=/[\r\n]+/,Lr=function(n,e){return(i=n.url).startsWith("file:")||il().startsWith("file:")&&!rf.test(i)?function(r,s){let l=new XMLHttpRequest;l.open(r.method||"GET",r.url,!0),r.type==="arrayBuffer"&&(l.responseType="arraybuffer");for(let u in r.headers)l.setRequestHeader(u,r.headers[u]);return r.type==="json"&&(l.responseType="text",l.setRequestHeader("Accept","application/json")),l.withCredentials=r.credentials==="include",l.onerror=()=>{s(new Error(l.statusText))},l.onload=()=>{if((l.status>=200&&l.status<300||l.status===0)&&l.response!==null){let u=l.response;if(r.type==="json")try{u=JSON.parse(l.response)}catch(f){return s(f)}let p=new Headers;l.getAllResponseHeaders().trim().split(of).forEach(f=>{let g=f.split(": "),x=g.shift(),b=g.join(": ");p.append(x,b)}),s(null,u,p)}else s(new Gh(l.statusText,l.status,r.url))},l.send(r.body),{cancel:()=>l.abort()}}(n,e):function(r,s){let l=new AbortController,u=new Request(r.url,{method:r.method||"GET",body:r.body,credentials:r.credentials,headers:r.headers,referrer:il(),referrerPolicy:r.referrerPolicy,signal:l.signal}),p=!1,f=!1,g=(x=u.url).indexOf("sku=")>0&&vs(x);var x;r.type==="json"&&u.headers.set("Accept","application/json");let b=(S,E,M)=>{if(f)return;if(S&&S.message!=="SecurityError"&&Ot(S.toString()),E&&M)return w(E);let C=Date.now();fetch(u).then(R=>{if(R.ok){let F=g?R.clone():null;return w(R,F,C)}return s(new Gh(R.statusText,R.status,r.url))}).catch(R=>{R.name!=="AbortError"&&s(new Error(`${R.message} ${r.url}`))})},w=(S,E,M)=>{(r.type==="arrayBuffer"?S.arrayBuffer():r.type==="json"?S.json():S.text()).then(C=>{f||(E&&M&&function(R,F,z){if(fa(),Wo==null)return;let j=Ai(F.headers.get("cache-control")||"");if(j["no-store"])return;let $={status:F.status,statusText:F.statusText,headers:new Headers};F.headers.forEach((Y,ee)=>$.headers.set(ee,Y)),j["max-age"]&&$.headers.set("Expires",new Date(z+1e3*j["max-age"]).toUTCString());let H=$.headers.get("expires");if(!H||new Date(H).getTime()-z<42e4)return;
1let ie=kh(R.url,{persistentParams:tf});if(F.status===206){let Y=R.headers.get("Range");if(!Y)return;$.status=200,ie=Jp(ie,{range:Y})}let W=new Response((Q=F.status)!==200&&Q!==404&&[101,103,204,205,304].includes(Q)?null:F.body,$);var Q;fa(),Wo?.then(Y=>Y.put(ie,W)).catch(Y=>Ot(Y.message))}(u,E,M),p=!0,s(null,C,S.headers))}).catch(C=>{f||s(new Error(C.message))})};return g?function(S,E){if(fa(),Wo==null)return E(null);Wo.then(M=>{let C=kh(S.url,{persistentParams:tf}),R=S.headers.get("Range");R&&(C=Jp(C,{range:R})),M.match(C).then(F=>{let z=function(j){if(!j)return!1;let $=new Date(j.headers.get("expires")||0),H=Ai(j.headers.get("cache-control")||"");return Number($)>Date.now()&&!H["no-cache"]}(F);M.delete(C).catch(E),z&&M.put(C,F.clone()).catch(E),E(null,F,z)}).catch(E)}).catch(E)}(u,b):b(null,null),{cancel:()=>{f=!0,p||l.abort()}}}(n,e);var i},sf=function(n,e){return Lr(Object.assign(n,{type:"json"}),e)},nl=function(n,e){return Lr(Object.assign(n,{type:"arrayBuffer"}),e)};function af(n){let e=document.createElement("a");return e.href=n,e.protocol===location.protocol&&e.host===location.host}let mu,pc;mu=[],pc=0;let Kr=function(n,e){if(Uh.supported&&(n.headers||(n.headers={}),n.headers.accept="image/webp,*/*"),pc>=di.MAX_PARALLEL_IMAGE_REQUESTS){let l={requestParameters:n,callback:e,cancelled:!1,cancel(){this.cancelled=!0}};return mu.push(l),l}pc++;let i=!1,r=()=>{if(!i)for(i=!0,pc--;mu.length&&pc<di.MAX_PARALLEL_IMAGE_REQUESTS;){let l=mu.shift(),{requestParameters:u,callback:p,cancelled:f}=l;f||(l.cancel=Kr(u,p).cancel)}},s=nl(n,(l,u,p)=>{r(),l?e(l):u&&function(f,g){let x=new Blob([new Uint8Array(f)],{type:"image/png"});createImageBitmap(x).then(b=>{g(null,b)}).catch(b=>{g(new Error(`Could not load image because of ${b.message}. Please make sure to use a supported image type such as PNG or JPEG. Note that SVGs are not supported.`))})}(u,(f,g)=>e(f,g,p))});return{cancel:()=>{s.cancel(),r()}}};var lf,_u,Ts,Ss={exports:{}},$h={exports:{}},Hh={exports:{}},O_=function(){if(Ts)return Ss.exports;Ts=1;var n=(lf||(lf=1,$h.exports=function(i,r){var s,l,u,p,f,g,x,b;for(l=i.length-(s=3&i.length),u=r,f=3432918353,g=461845907,b=0;b<l;)x=255&i.charCodeAt(b)|(255&i.charCodeAt(++b))<<8|(255&i.charCodeAt(++b))<<16|(255&i.charCodeAt(++b))<<24,++b,u=27492+(65535&(p=5*(65535&(u=(u^=x=(65535&(x=(x=(65535&x)*f+(((x>>>16)*f&65535)<<16)&4294967295)<<15|x>>>17))*g+(((x>>>16)*g&65535)<<16)&4294967295)<<13|u>>>19))+((5*(u>>>16)&65535)<<16)&4294967295))+(((p>>>16)+58964&65535)<<16);switch(x=0,s){case 3:x^=(255&i.charCodeAt(b+2))<<16;case 2:x^=(255&i.charCodeAt(b+1))<<8;case 1:u^=x=(65535&(x=(x=(65535&(x^=255&i.charCodeAt(b)))*f+(((x>>>16)*f&65535)<<16)&4294967295)<<15|x>>>17))*g+(((x>>>16)*g&65535)<<16)&4294967295}return u^=i.length,u=2246822507*(65535&(u^=u>>>16))+((2246822507*(u>>>16)&65535)<<16)&4294967295,u=3266489909*(65535&(u^=u>>>13))+((3266489909*(u>>>16)&65535)<<16)&4294967295,(u^=u>>>16)>>>0}
1),$h.exports),e=(_u||(_u=1,Hh.exports=function(i,r){for(var s,l=i.length,u=r^l,p=0;l>=4;)s=1540483477*(65535&(s=255&i.charCodeAt(p)|(255&i.charCodeAt(++p))<<8|(255&i.charCodeAt(++p))<<16|(255&i.charCodeAt(++p))<<24))+((1540483477*(s>>>16)&65535)<<16),u=1540483477*(65535&u)+((1540483477*(u>>>16)&65535)<<16)^(s=1540483477*(65535&(s^=s>>>24))+((1540483477*(s>>>16)&65535)<<16)),l-=4,++p;switch(l){case 3:u^=(255&i.charCodeAt(p+2))<<16;case 2:u^=(255&i.charCodeAt(p+1))<<8;case 1:u=1540483477*(65535&(u^=255&i.charCodeAt(p)))+((1540483477*(u>>>16)&65535)<<16)}return u=1540483477*(65535&(u^=u>>>13))+((1540483477*(u>>>16)&65535)<<16),(u^=u>>>15)>>>0}),Hh.exports);return Ss.exports=n,Ss.exports.murmur3=n,Ss.exports.murmur2=e,Ss.exports}(),fc=du(O_);class Xo{constructor(e,...i){Object.assign(this,i[0]||{}),this.type=e}}class rl extends Xo{constructor(e,i={}){super("error",Object.assign({error:e},i))}}function gu(n,e,i){i[n]&&i[n].includes(e)||(i[n]=i[n]||[],i[n].push(e))}function _a(n,e,i){if(i&&i[n]){let r=i[n].indexOf(e);r!==-1&&i[n].splice(r,1)}}class ol{on(e,i){return this._listeners=this._listeners||{},gu(e,i,this._listeners),this}off(e,i){return _a(e,i,this._listeners),_a(e,i,this._oneTimeListeners),this}once(e,i){return i?(this._oneTimeListeners=this._oneTimeListeners||{},gu(e,i,this._oneTimeListeners),this):new Promise(r=>{this.once(e,r)})}fire(e,i){let r=typeof e=="string"?new Xo(e,i):e,s=r.type;if(this.listens(s)){r.target=this;let l=this._listeners&&this._listeners[s]?this._listeners[s].slice():[];for(let f of l)f.call(this,r);let u=this._oneTimeListeners&&this._oneTimeListeners[s]?this._oneTimeListeners[s].slice():[];for(let f of u)_a(s,f,this._oneTimeListeners),f.call(this,r);let p=this._eventedParent;if(p){let f=typeof this._eventedParentData=="function"?this._eventedParentData():this._eventedParentData;Object.assign(r,f),p.fire(r)}}else r instanceof rl&&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 yr{constructor(e){typeof e=="string"?this.name=e:(this.name=e.name,this.iconsetId=e.iconsetId)}static from(e){return new yr(e)}static toString(e){return e.iconsetId?`${e.name}�${e.iconsetId}`:e.name}static parse(e){let[i,r]=e.split("�");return new yr({name:i,iconsetId:r})}static isEqual(e,i){return e.name===i.name&&e.iconsetId===i.iconsetId}toString(){return yr.toString(this)}serialize(){return{name:this.name,iconsetId:this.iconsetId}}}var ga,yu={},mc=function(){if(ga)return yu;ga=1;var n={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 e(l){return(l=Math.round(l))<0?0:l>255?255:l}function i(l){return e(l[l.length-1]==="%"?parseFloat(l)/100*255:parseInt(l))}function r(l){return(u=l[l.length-1]==="%"?parseFloat(l)/100:parseFloat(l))<0?0:u>1?1:u;var u}function s(l,u,p){return p<0?p+=1:p>1&&(p-=1),6*p<1?l+(u-l)*p*6:2*p<1?u:3*p<2?l+(u-l)*(2/3-p)*6:l}try{yu.parseCSSColor=function(l){var u,p=l.replace(/ /g,"").toLowerCase();if(p in n)return n[p].slice();if(p[0]==="#")return p.length===4?(u=parseInt(p.substr(1),16))>=0&&u<=4095?[(3840&u)>>4|(3840&u)>>8,240&u|(240&u)>>4,15&u|(15&u)<<4,1]:null:p.length===7&&(u=parseInt(p.substr(1),16))>=0&&u<=16777215?[(16711680&u)>>16,(65280&u)>>8,255&u,1]:null;var f=p.indexOf("("),g=p.indexOf(")");if(f!==-1&&g+1===p.length){var x=p.substr(0,f),b=p.substr(f+1,g-(f+1)).split(","),w=1;switch(x){case"rgba":if(b.length!==4)return null;w=r(b.pop());case"rgb":return b.length!==3?null:[i(b[0]),i(b[1]),i(b[2]),w];case"hsla":if(b.length!==4)return null;w=r(b.pop());case"hsl":if(b.length!==3)return null;var S=(parseFloat(b[0])%360+360)%360/360,E=r(b[1]),M=r(b[2]),C=M<=.5?M*(E+1):M+E-M*E,R=2*M-C;return[e(255*s(R,C,S+1/3)),e(255*s(R,C,S)),e(255*s(R,C,S-1/3)),w];default:return null}}return null}}catch{}return yu}();function ft(n,e,i){return n*(1-i)+e*i}class jt{constructor(e,i,r,s=1){this.r=e,this.g=i,this.b=r,this.a=s}static parse(e){if(!e)return;if(e instanceof jt)return e;if(typeof e!="string")return;let i=mc.parseCSSColor(e);return i?new jt(i[0]/255,i[1]/255,i[2]/255,i[3]):void 0}toString(){let{r:e,g:i,b:r,a:s}=this;return`rgba(${Math.round(255*e)},${Math.round(255*i)},${Math.round(255*r)},${s})`}toNonPremultipliedRenderColor(e){let{r:i,g:r,b:s,a:l}=this;return new qh(e,i,r,s,l)}toPremultipliedRenderColor(e){let{r:i,g:r,b:s,a:l}=this;return new cf(e,i*l,r*l,s*l,l)}clone(){return new jt(this.r,this.g,this.b,this.a)}}class xu{constructor(e,i,r,s,l,u=!1){if(this.premultiplied=!1,this.premultiplied=u,e){let p=e.image.height,f=p*p;this.premultiplied?(i=l===0?0:i/l*(p-1),r=l===0?0:r/l*(p-1),s=l===0?0:s/l*(p-1)):(i*=p-1,r*=p-1,s*=p-1),i=Math.max(0,Math.min(p-1,i)),r=Math.max(0,Math.min(p-1,r)),s=Math.max(0,Math.min(p-1,s));let g=Math.floor(i),x=Math.floor(r),b=Math.floor(s),w=Math.ceil(i),S=Math.ceil(r),E=Math.ceil(s),M=i-g,C=r-x,R=s-b,F=e.image.data,z=4*(g+x*f+b*p),j=4*(g+x*f+E*p),$=4*(g+S*f+b*p),H=4*(g+S*f+E*p),ie=4*(w+x*f+b*p),W=4*(w+x*f+E*p),Q=4*(w+S*f+b*p),Y=4*(w+S*f+E*p);this.r=ft(ft(ft(F[z],F[j],R),ft(F[$],F[H],R),C),ft(ft(F[ie],F[W],R),ft(F[Q],F[Y],R),C),M)/255*(this.premultiplied?l:1),this.g=ft(ft(ft(F[z+1],F[j+1],R),ft(F[$+1],F[H+1],R),C),ft(ft(F[ie+1],F[W+1],R),ft(F[Q+1],F[Y+1],R),C),M)/255*(this.premultiplied?l:1),this.b=ft(ft(ft(F[z+2],F[j+2],R),ft(F[$+2],F[H+2],R),C),ft(ft(F[ie+2],F[W+2],R),ft(F[Q+2],F[Y+2],R),C),M)/255*(this.premultiplied?l:1),this.a=l}else this.r=i,this.g=r,this.b=s,this.a=l}toArray(){let{r:e,g:i,b:r,a:s}=this;return[255*e,255*i,255*r,s]}toHslaArray(){let{r:e,g:i,b:r,a:s}=this;if(this.premultiplied){if(s===0)return[0,0,0,0];let E=1/s;e*=E,i*=E,r*=E}let l=Math.min(Math.max(e,0),1),u=Math.min(Math.max(i,0),1),p=Math.min(Math.max(r,0),1),f=Math.min(l,u,p),g=Math.max(l,u,p),x=g-f,b=.5*(f+g);if(x===0)return[0,0,100*b,s];let w=b>.5?x/(2-g-f):x/(g+f),S;switch(g){case l:S=60*((u-p)/x+(u<p?6:0));break;case u:S=60*((p-l)/x+2);break;default:S=60*((l-u)/x+4)}return[S,100*w,100*b,s]}toArray01(){let{r:e,g:i,b:r,a:s}=this;return[e,i,r,s]}toArray01Scaled(e){let{r:i,g:r,b:s}=this;return[i*e,r*e,s*e]}toArray01Linear(){let{r:e,g:i,b:r,a:s}=this;return[Math.pow(e,2.2),Math.pow(i,2.2),Math.pow(r,2.2),s]}}class qh extends xu{constructor(e,i,r,s,l){super(e,i,r,s,l,!1)}}class cf extends xu{constructor(e,i,r,s,l){super(e,i,r,s,l,!0)}}function Zh(n,e,i){return n.map((r,s)=>ft(r,e[s],i))}jt.black=new jt(0,0,0,1),jt.white=new jt(1,1,1,1),jt.transparent=new jt(0,0,0,0),jt.red=new jt(1,0,0,1),jt.blue=new jt(0,0,1,1);var vu=Object.freeze({__proto__:null,array:Zh,color:function(n,e,i){return new jt(ft(n.r,e.r,i),ft(n.g,e.g,i),ft(n.b,e.b,i),ft(n.a,e.a,i))},number:ft});
1class yo extends Error{constructor(e,i){super(i),this.message=i,this.key=e}}class Wh{constructor(e,i=[]){this.parent=e,this.bindings={};for(let[r,s]of i)this.bindings[r]=s}concat(e){return new Wh(this,e)}get(e){if(this.bindings[e])return this.bindings[e];if(this.parent)return this.parent.get(e);throw new Error(`${e} not found in scope.`)}has(e){return!!this.bindings[e]||!!this.parent&&this.parent.has(e)}}let ya={kind:"null"},st={kind:"number"},Kt={kind:"string"},ni={kind:"boolean"},rn={kind:"color"},xa={kind:"object"},qt={kind:"value"},bu={kind:"collator"},Yo={kind:"formatted"},sl={kind:"resolvedImage"};function Yn(n,e){return{kind:"array",itemType:n,N:e}}function on(n){if(n.kind==="array"){let e=on(n.itemType);return typeof n.N=="number"?`array<${e}, ${n.N}>`:n.itemType.kind==="value"?"array":`array<${e}>`}return n.kind}let Wt=[ya,st,Kt,ni,rn,Yo,xa,Yn(qt),sl];function al(n,e){if(e.kind==="error")return null;if(n.kind==="array"){if(e.kind==="array"&&(e.N===0&&e.itemType.kind==="value"||!al(n.itemType,e.itemType))&&(typeof n.N!="number"||n.N===e.N))return null}else{if(n.kind===e.kind)return null;if(n.kind==="value"){for(let i of Wt)if(!al(i,e))return null}}return`Expected ${on(n)} but found ${on(e)} instead.`}function wu(n,e){return e.some(i=>i.kind===n.kind)}function _c(n,e){return e.some(i=>i==="null"?n===null:i==="array"?Array.isArray(n):i==="object"?n&&!Array.isArray(n)&&typeof n=="object":i===typeof n)}function Tu(n,e){return n.kind==="array"&&e.kind==="array"?n.N===e.N&&Tu(n.itemType,e.itemType):n.kind===e.kind}class ll{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 va{constructor(e,i,r,s,l){this.text=e.normalize?e.normalize():e,this.image=i,this.scale=r,this.fontStack=s,this.textColor=l}}class kn{constructor(e){this.sections=e}static fromString(e){return new kn([new va(e,null,null,null,null)])}isEmpty(){return this.sections.length===0||!this.sections.some(e=>e.text.length!==0||!!e.image&&e.image.hasPrimary())}static factory(e){return e instanceof kn?e:kn.fromString(e)}toString(){return this.sections.length===0?"":this.sections.map(e=>e.text).join("")}serialize(){let e=["format"];for(let i of this.sections){if(i.image){let s=i.image.getPrimary().id.toString();e.push(["image",s]);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 xr{constructor(e,i={}){this.id=yr.from(e),this.params=i.params,this.sx=i.sx||1,this.sy=i.sy||1}toString(){return JSON.stringify(this)}static parse(e){let i,r,s,l;try{({id:i,params:r,sx:s,sy:l}=JSON.parse(e)||{})}catch{return null}return i?new xr(i,{params:r,sx:s,sy:l}):null}scaleSelf(e,i=e){return this.sx*=e,this.sy*=i,this}}class cr{constructor(e,i,r,s,l=!1){this.primaryId=yr.from(e),this.primaryOptions=i,r&&(this.secondaryId=yr.from(r)),this.secondaryOptions=s,this.available=l}toString(){return this.primaryId&&this.secondaryId?`[${this.primaryId.name},${this.secondaryId.name}]`:this.primaryId.name}hasPrimary(){return!!this.primaryId}getPrimary(){return new xr(this.primaryId,this.primaryOptions)}hasSecondary(){return!!this.secondaryId}getSecondary(){return this.secondaryId?new xr(this.secondaryId,this.secondaryOptions):null}static from(e){return typeof e=="string"?cr.build({name:e}):e}static build(e,i,r,s){return!e||typeof e=="object"&&!("name"in e)?null:new cr(e,r,i,s)}}function Su(n,e,i,r){return typeof n=="number"&&n>=0&&n<=255&&typeof e=="number"&&e>=0&&e<=255&&typeof i=="number"&&i>=0&&i<=255?r===void 0||typeof r=="number"&&r>=0&&r<=1?null:`Invalid rgba value [${[n,e,i,r].join(", ")}]: 'a' must be between 0 and 1.`:`Invalid rgba value [${(typeof r=="number"?[n,e,i,r]:[n,e,i]).join(", ")}]: 'r', 'g', and 'b' must be between 0 and 255.`}function cl(n){if(n===null||typeof n=="string"||typeof n=="boolean"||typeof n=="number"||n instanceof jt||n instanceof ll||n instanceof kn||n instanceof cr)return!0;
1if(Array.isArray(n)){for(let e of n)if(!cl(e))return!1;return!0}if(typeof n=="object"){for(let e in n)if(!cl(n[e]))return!1;return!0}return!1}function vn(n){if(n===null)return ya;if(typeof n=="string")return Kt;if(typeof n=="boolean")return ni;if(typeof n=="number")return st;if(n instanceof jt)return rn;if(n instanceof ll)return bu;if(n instanceof kn)return Yo;if(n instanceof cr)return sl;if(Array.isArray(n)){let e=n.length,i;for(let r of n){let s=vn(r);if(i){if(i===s)continue;i=qt;break}i=s}return Yn(i||qt,e)}return xa}function vr(n){let e=typeof n;return n===null?"":e==="string"||e==="number"||e==="boolean"?String(n):n instanceof kn||n instanceof cr||n instanceof jt?n.toString():JSON.stringify(n)}class xo{constructor(e,i){this.type=e,this.value=i}static parse(e,i){if(e.length!==2)return i.error(`'literal' expression requires exactly one argument, but found ${e.length-1} instead.`);if(!cl(e[1]))return i.error("invalid value");let r=e[1],s=vn(r),l=i.expectedType;return s.kind!=="array"||s.N!==0||!l||l.kind!=="array"||typeof l.N=="number"&&l.N!==0||(s=l),new xo(s,r)}evaluate(){return this.value}eachChild(){}outputDefined(){return!0}serialize(){return this.type.kind==="array"||this.type.kind==="object"?["literal",this.value]:this.value instanceof jt?["rgba"].concat(this.value.toNonPremultipliedRenderColor(null).toArray()):this.value instanceof kn?this.value.serialize():this.value}}class sn{constructor(e){this.name="ExpressionEvaluationError",this.message=e}toJSON(){return this.message}}let Or={string:Kt,number:st,boolean:ni,object:xa};class Qr{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,s=1,l=e[0];if(l==="array"){let p,f;if(e.length>2){let g=e[1];if(typeof g!="string"||!(g in Or)||g==="object")return i.error('The item type argument of "array" must be one of string, number, boolean',1);p=Or[g],s++}else p=qt;if(e.length>3){if(e[2]!==null&&(typeof e[2]!="number"||e[2]<0||e[2]!==Math.floor(e[2])))return i.error('The length argument to "array" must be a positive integer literal',2);f=e[2],s++}r=Yn(p,f)}else r=Or[l];let u=[];for(;s<e.length;s++){let p=i.parse(e[s],s,qt);if(!p)return null;u.push(p)}return new Qr(r,u)}evaluate(e){for(let i=0;i<this.args.length;i++){let r=this.args[i].evaluate(e);if(!al(this.type,vn(r)))return r;if(i===this.args.length-1)throw new sn(`The expression ${JSON.stringify(this.args[i].serialize())} evaluated to ${on(vn(r))} but was expected to be of type ${on(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(e.kind==="array"){let r=e.itemType;if(r.kind==="string"||r.kind==="number"||r.kind==="boolean"){i.push(r.kind);let s=e.N;(typeof s=="number"||this.args.length>1)&&i.push(s)}}return i.concat(this.args.map(r=>r.serialize()))}}class gc{constructor(e){this.type=Yo,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)&&typeof r=="object")return i.error("First argument must be an image or text section.");let s=[],l=!1;for(let u=1;u<=e.length-1;++u){let p=e[u];if(l&&typeof p=="object"&&!Array.isArray(p)){l=!1;let f=null;if(p["font-scale"]&&(f=i.parseObjectValue(p["font-scale"],u,"font-scale",st),!f))return null;let g=null;if(p["text-font"]&&(g=i.parseObjectValue(p["text-font"],u,"text-font",Yn(Kt)),!g))return null;let x=null;if(p["text-color"]&&(x=i.parseObjectValue(p["text-color"],u,"text-color",rn),!x))return null;let b=s.at(-1);b.scale=f,b.font=g,b.textColor=x}else{let f=i.parse(e[u],u,qt);if(!f)return null;let g=f.type.kind;if(g!=="string"&&g!=="value"&&g!=="null"&&g!=="resolvedImage")return i.error("Formatted text type must be 'string', 'value', 'image' or 'null'.");l=!0,s.push({content:f,scale:null,font:null,textColor:null})}}return new gc(s)}evaluate(e){return new kn(this.sections.map(i=>{let r=i.content.evaluate(e);return Tu(vn(r),sl)?new va("",r,null,null,null):new va(vr(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}}
1class yc{constructor(e,i,r,s){this._imageWarnHistory={},this.type=sl,this.namePrimary=e,this.nameSecondary=i,r&&(this.paramsPrimary=r.params,this.iconsetIdPrimary=r.iconset?r.iconset.id:void 0),s&&(this.paramsSecondary=s.params,this.iconsetIdSecondary=s.iconset?s.iconset.id:void 0)}static parse(e,i){if(e.length<2)return i.error("Expected two or more arguments.");let r=1,s=[];function l(){if(r<e.length){let p=i.parse(e[r],r++,Kt);return p?(s.push({image:p,options:{}}),!0):(i.error(s.length?"Secondary image variant is not a string.":"No image name provided."),!1)}return!0}function u(){if(r<e.length){let f=e[r];if((p=f)===null||typeof p!="object"||Array.isArray(p))return!0;let g=f.params,x=f.iconset,b=i.concat(r);if(!g&&!x)return r++,!0;if(g){if(typeof g!="object"||g.constructor!==Object)return b.error('Image options "params" should be an object'),!1;let w={},S=b.concat(void 0,"params");for(let E in g){if(!E)return S.error("Image parameter name should be non-empty"),!1;let M=S.concat(void 0,E).parse(g[E],void 0,rn,void 0,{typeAnnotation:"coerce"});if(!M)return!1;w[E]=M}s.at(-1).options.params=w}if(x){if(typeof x!="object"||x.constructor!==Object)return b.error('Image options "iconset" should be an object'),!1;if(!x.id)return b.error('Image options "iconset" should have an "id" property'),!1;s.at(-1).options.iconset=x}return r++,!0}var p;return!0}for(let p=0;p<2;p++)if(!l()||!u())return;return new yc(s[0].image,s[1]?s[1].image:void 0,s[0].options,s[1]?s[1].options:void 0)}evaluateParams(e,i){let r={};if(i){for(let s in i)if(i[s])try{r[s]=i[s].evaluate(e)}catch{continue}if(Object.keys(r).length!==0)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,s=cr.build(i,r,this.paramsPrimary?this.evaluateParams(e,this.paramsPrimary):void 0,this.paramsSecondary?this.evaluateParams(e,this.paramsSecondary):void 0);if(s&&e.availableImages){let l=s.getPrimary().id;if(s.available=e.availableImages.some(u=>yr.isEqual(u,l)),s.available){let u=s.getSecondary()?s.getSecondary().id:null;u&&(s.available=e.availableImages.some(p=>yr.isEqual(p,u)))}}return s}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){r.params={};for(let s in e)e[s]&&(r.params[s]=e[s].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 Iu(n){return Yh(n)?"string":xc(n)?"number":Jh(n)?"boolean":Array.isArray(n)?"array":n===null?"null":Xh(n)?"object":typeof n}function Xh(n){return n!=null&&!Array.isArray(n)&&typeof n!="function"&&!(n instanceof String||n instanceof Number||n instanceof Boolean)&&typeof n=="object"}function Yh(n){return typeof n=="string"||n instanceof String}function xc(n){return typeof n=="number"||n instanceof Number}function Jh(n){return typeof n=="boolean"||n instanceof Boolean}let Eu={"to-boolean":ni,"to-color":rn,"to-number":st,"to-string":Kt};class br{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],s=[],l=ya;if(r==="to-array"){if(!Array.isArray(e[1]))return null;let u=e[1].length;if(i.expectedType){if(i.expectedType.kind!=="array")return i.error(`Expected ${i.expectedType.kind} but found array.`);l=Yn(i.expectedType.itemType,u)}else{if(!(u>0&&cl(e[1][0])))return null;l=Yn(vn(e[1][0]),u)}for(let p=0;p<u;p++){let f=e[1][p],g;if(Array.isArray(f))g=i.parse(f,void 0,l.itemType);else{let x=Iu(f);if(x!==l.itemType.kind)return i.error(`Expected ${l.itemType.kind} but found ${x}.`);g=i.registry.literal.parse(["literal",f===void 0?null:f],i)}if(!g)return null;s.push(g)}}else{if((r==="to-boolean"||r==="to-string")&&e.length!==2)return i.error("Expected one argument.");l=Eu[r];for(let u=1;u<e.length;u++){let p=i.parse(e[u],u,qt);
1if(!p)return null;s.push(p)}}return new br(l,s)}evaluate(e){if(this.type.kind==="boolean")return!!this.args[0].evaluate(e);if(this.type.kind==="color"){let i,r;for(let s of this.args){if(i=s.evaluate(e),r=null,i instanceof jt)return i;if(typeof i=="string"){let l=e.parseColor(i);if(l)return l}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.`:Su(i[0],i[1],i[2],i[3]),!r))return new jt(i[0]/255,i[1]/255,i[2]/255,i[3])}throw new sn(r||`Could not parse color from value '${typeof i=="string"?i:String(JSON.stringify(i))}'`)}if(this.type.kind==="number"){let i=null;for(let r of this.args){if(i=r.evaluate(e),i===null)return 0;let s=Number(i);if(!isNaN(s))return s}throw new sn(`Could not convert ${JSON.stringify(i)} to number.`)}return this.type.kind==="formatted"?kn.fromString(vr(this.args[0].evaluate(e))):this.type.kind==="resolvedImage"?cr.build(vr(this.args[0].evaluate(e))):this.type.kind==="array"?this.args.map(i=>i.evaluate(e)):vr(this.args[0].evaluate(e))}eachChild(e){this.args.forEach(e)}outputDefined(){return this.args.every(e=>e.outputDefined())}serialize(){if(this.type.kind==="formatted")return new gc([{content:this.args[0],scale:null,font:null,textColor:null}]).serialize();if(this.type.kind==="resolvedImage")return new yc(this.args[0]).serialize();let e=this.type.kind==="array"?[]:[`to-${this.type.kind}`];return this.eachChild(i=>{e.push(i.serialize())}),e}}let uf=["Unknown","Point","LineString","Polygon"];class eo{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&&this.feature.id!==void 0?this.feature.id:null}geometryType(){return this.feature?typeof this.feature.type=="number"?uf[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:s}=this.featureTileCoord;return this.featureDistanceData.bearing[0]*(r*i-e[0])+this.featureDistanceData.bearing[1]*(s*i-e[1])}return 0}parseColor(e){let i=this._parseColorCache[e];return i||(i=this._parseColorCache[e]=jt.parse(e)),i}getConfig(e){return this.options?this.options.get(e):null}}class ur{constructor(e,i,r,s,l){this.name=e,this.type=i,this._evaluate=r,this.args=s,this._overloadIndex=l}evaluate(e){if(!this._evaluate){let i=ur.definitions[this.name];this._evaluate=Array.isArray(i)?i[2]:i.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],s=ur.definitions[r];if(!s)return i.error(`Unknown expression "${r}". If you wanted a literal array, use ["literal", [...]].`,0);let l=Array.isArray(s)?s[0]:s.type,u=Array.isArray(s)?[[s[1],s[2]]]:s.overloads,p=[],f=null,g=-1;for(let[x,b]of u){if(Array.isArray(x)&&x.length!==e.length-1)continue;p.push(x),g++,f===null?f=new Ec(i.registry,i.path,null,i.scope,[],i._scope,i.options,i.iconImageUseTheme):f.errors.length=0;let w=[],S=!1;for(let E=1;E<e.length;E++){let M=e[E],C=Array.isArray(x)?x[E-1]:x.type,R=f.parse(M,1+w.length,C);if(!R){S=!0;break}w.push(R)}if(!S)if(Array.isArray(x)&&x.length!==w.length)f.error(`Expected ${x.length} arguments, but found ${w.length} instead.`);else{for(let E=0;E<w.length;E++){let M=Array.isArray(x)?x[E]:x.type;f.checkSubtype(M,w[E].type,E+1)}if(f.errors.length===0)return new ur(r,l,b,w,g)}}if(p.length===1)i.errors.push(...f.errors);else{let x=(p.length?p:u.map(([w])=>w)).map(hf).join(" | "),b=[];for(let w=1;w<e.length;w++){let S=i.parse(e[w],1+b.length);if(!S)return null;b.push(on(S.type))}i.error(`Expected arguments of type ${x}, but found (${b.join(", ")}) instead.`)}return null}static register(e,i){ur.definitions=i;for(let r in i)e[r]=ur}}function hf(n){return Array.isArray(n)?`(${n.map(on).join(", ")})`:`(${on(n.type)}...)`}class Is{constructor(e,i,r){this.type=bu,this.locale=r,this.caseSensitive=e,this.diacriticSensitive=i}static parse(e,i){if(e.length!==2)return i.error("Expected one argument."),null;let r=e[1];if(typeof r!="object"||Array.isArray(r))return i.error("Collator options argument must be an object."),null;let s=r["case-sensitive"]===void 0?i.parse(!1,1,ni):i.parseObjectValue(r["case-sensitive"],1,"case-sensitive",ni);if(!s)return null;let l=r["diacritic-sensitive"]===void 0?i.parse(!1,1,ni):i.parseObjectValue(r["diacritic-sensitive"],1,"diacritic-sensitive",ni);if(!l)return null;let u=null;return r.locale&&(u=i.parseObjectValue(r.locale,1,"locale",Kt),!u)?null:new Is(s,l,u)}evaluate(e){return new ll(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 vc(n,e,i=0,r=n.length-1,s=F_){for(;r>i;){if(r-i>600){let f=r-i+1,g=e-i+1,x=Math.log(f),b=.5*Math.exp(2*x/3),w=.5*Math.sqrt(x*b*(f-b)/f)*(g-f/2<0?-1:1);vc(n,e,Math.max(i,Math.floor(e-g*b/f+w)),Math.min(r,Math.floor(e+(f-g)*b/f+w)),s)}let l=n[e],u=i,p=r;for(bc(n,i,e),s(n[r],l)>0&&bc(n,i,r);u<p;){for(bc(n,u,p),u++,p--;s(n[u],l)<0;)u++;for(;s(n[p],l)>0;)p--}s(n[i],l)===0?bc(n,i,p):(p++,bc(n,p,r)),p<=e&&(i=p+1),e<=p&&(r=p-1)}}function bc(n,e,i){let r=n[e];n[e]=n[i],n[i]=r}function F_(n,e){return n<e?-1:n>e?1:0}function B_(n){let e=0;for(let i,r,s=0,l=n.length,u=l-1;s<l;u=s++)i=n[s],r=n[u],e+=(r.x-i.x)*(i.y+r.y);return e}function ul(n,e){n[0]=Math.min(n[0],e[0]),n[1]=Math.min(n[1],e[1]),n[2]=Math.max(n[2],e[0]),n[3]=Math.max(n[3],e[1])}function ba(n,e){return!(n[0]<=e[0]||n[2]>=e[2]||n[1]<=e[1]||n[3]>=e[3])}function k_(n,e,i){let r=n[0]-e[0],s=n[1]-e[1],l=n[0]-i[0],u=n[1]-i[1];return r*u-l*s===0&&r*l<=0&&s*u<=0}function Au(n,e,i){return e[1]>n[1]!=i[1]>n[1]&&n[0]<(i[0]-e[0])*(n[1]-e[1])/(i[1]-e[1])+e[0]}function hl(n,e,i=!1){let r=!1;for(let s=0,l=e.length;s<l;s++){let u=e[s];for(let p=0,f=u.length,g=f-1;p<f;g=p++){let x=u[g],b=u[p];if(k_(n,x,b))return i;Au(n,x,b)&&(r=!r)}}return r}function df(n,e,i,r){let s=r[0]-i[0],l=r[1]-i[1],u=(n[0]-i[0])*l-s*(n[1]-i[1]),p=(e[0]-i[0])*l-s*(e[1]-i[1]);return u>0&&p<0||u<0&&p>0}function Mu(n,e,i,r){return(s=[r[0]-i[0],r[1]-i[1]])[0]*(l=[e[0]-n[0],e[1]-n[1]])[1]-s[1]*l[0]!==0&&!(!df(n,e,i,r)||!df(i,r,n,e));var s,l}function Kh(n){let e=new ke(Number.POSITIVE_INFINITY,Number.POSITIVE_INFINITY),i=new ke(Number.NEGATIVE_INFINITY,Number.NEGATIVE_INFINITY);for(let r of n[0])e.x>r.x&&(e.x=r.x),e.y>r.y&&(e.y=r.y),i.x<r.x&&(i.x=r.x),i.y<r.y&&(i.y=r.y);return{min:e,max:i}}let Es=8192;function N_(n,e){let i=(180+n[0])/360,r=(180-180/Math.PI*Math.log(Math.tan(Math.PI/4+n[1]*Math.PI/360)))/360,s=Math.pow(2,e.z);return[Math.round(i*s*Es),Math.round(r*s*Es)]}function U_(n,e){for(let i=0;i<e.length;i++)if(hl(n,e[i]))return!0;return!1}function pf(n,e,i){for(let r of i)for(let s=0,l=r.length,u=l-1;s<l;u=s++)if(Mu(n,e,r[u],r[s]))return!0;return!1}function wa(n,e){for(let i=0;i<n.length;++i)if(!hl(n[i],e))return!1;for(let i=0;i<n.length-1;++i)if(pf(n[i],n[i+1],e))return!1;return!0}function V_(n,e){for(let i=0;i<e.length;i++)if(wa(n,e[i]))return!0;return!1}function Cu(n,e,i){let r=[];for(let s=0;s<n.length;s++){let l=[];for(let u=0;u<n[s].length;u++){let p=N_(n[s][u],i);ul(e,p),l.push(p)}r.push(l)}return r}function Pu(n,e,i){let r=[];for(let s=0;s<n.length;s++){let l=Cu(n[s],e,i);r.push(l)}return r}function ff(n,e,i,r){if(n[0]<i[0]||n[0]>i[2]){let s=.5*r,l=n[0]-i[0]>s?-r:i[0]-n[0]>s?r:0;l===0&&(l=n[0]-i[2]>s?-r:i[2]-n[0]>s?r:0),n[0]+=l}ul(e,n)}function mf(n,e,i,r){let s=Math.pow(2,r.z)*Es,l=[r.x*Es,r.y*Es],u=[];
1if(!n)return u;for(let p of n)for(let f of p){let g=[f.x+l[0],f.y+l[1]];ff(g,e,i,s),u.push(g)}return u}function _f(n,e,i,r){let s=Math.pow(2,r.z)*Es,l=[r.x*Es,r.y*Es],u=[];if(!n)return u;for(let f of n){let g=[];for(let x of f){let b=[x.x+l[0],x.y+l[1]];ul(e,b),g.push(b)}u.push(g)}if(e[2]-e[0]<=s/2){(p=e)[0]=p[1]=1/0,p[2]=p[3]=-1/0;for(let f of u)for(let g of f)ff(g,e,i,s)}var p;return u}class Ta{constructor(e,i){this.type=ni,this.geojson=e,this.geometries=i}static parse(e,i){if(e.length!==2)return i.error(`'within' expression requires exactly one argument, but found ${e.length-1} instead.`);if(cl(e[1])){let r=e[1];if(r.type==="FeatureCollection")for(let s=0;s<r.features.length;++s){let l=r.features[s].geometry.type;if(l==="Polygon"||l==="MultiPolygon")return new Ta(r,r.features[s].geometry)}else if(r.type==="Feature"){let s=r.geometry.type;if(s==="Polygon"||s==="MultiPolygon")return new Ta(r,r.geometry)}else if(r.type==="Polygon"||r.type==="MultiPolygon")return new Ta(r,r)}return i.error("'within' expression requires valid geojson object that contains polygon geometry type.")}evaluate(e){if(e.geometry()!=null&&e.canonicalID()!=null){if(e.geometryType()==="Point")return function(i,r){let s=[1/0,1/0,-1/0,-1/0],l=[1/0,1/0,-1/0,-1/0],u=i.canonicalID();if(!u)return!1;if(r.type==="Polygon"){let p=Cu(r.coordinates,l,u),f=mf(i.geometry(),s,l,u);if(!ba(s,l))return!1;for(let g of f)if(!hl(g,p))return!1}if(r.type==="MultiPolygon"){let p=Pu(r.coordinates,l,u),f=mf(i.geometry(),s,l,u);if(!ba(s,l))return!1;for(let g of f)if(!U_(g,p))return!1}return!0}(e,this.geometries);if(e.geometryType()==="LineString")return function(i,r){let s=[1/0,1/0,-1/0,-1/0],l=[1/0,1/0,-1/0,-1/0],u=i.canonicalID();if(!u)return!1;if(r.type==="Polygon"){let p=Cu(r.coordinates,l,u),f=_f(i.geometry(),s,l,u);if(!ba(s,l))return!1;for(let g of f)if(!wa(g,p))return!1}if(r.type==="MultiPolygon"){let p=Pu(r.coordinates,l,u),f=_f(i.geometry(),s,l,u);if(!ba(s,l))return!1;for(let g of f)if(!V_(g,p))return!1}return!0}(e,this.geometries)}return!1}eachChild(){}outputDefined(){return!0}serialize(){return["within",this.geojson]}}let Sa={kilometers:1,miles:1e3/1609.344,nauticalmiles:1e3/1852,meters:1e3,metres:1e3,yards:1e3/.9144,feet:1e3/.3048,inches:1e3/.0254},As=1/298.257223563,mt=As*(2-As),nt=Math.PI/180;class Ia{static fromTile(e,i,r){let s=Math.PI*(1-2*(e+.5)/Math.pow(2,i)),l=Math.atan(.5*(Math.exp(s)-Math.exp(-s)))/nt;return new Ia(l,r)}static get units(){return Sa}constructor(e,i){if(e===void 0)throw new Error("No latitude given.");if(i&&!Sa[i])throw new Error(`Unknown unit ${i}. Use one of: ${Object.keys(Sa).join(", ")}`);let r=6378.137*nt*(i?Sa[i]:1),s=Math.cos(e*nt),l=1/(1-mt*(1-s*s)),u=Math.sqrt(l);this.kx=r*u*s,this.ky=r*u*l*(1-mt)}distance(e,i){let r=wr(e[0]-i[0])*this.kx,s=(e[1]-i[1])*this.ky;return Math.sqrt(r*r+s*s)}bearing(e,i){let r=wr(i[0]-e[0])*this.kx;return Math.atan2(r,(i[1]-e[1])*this.ky)/nt}destination(e,i,r){let s=r*nt;return this.offset(e,Math.sin(s)*i,Math.cos(s)*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 s=e[r];for(let l=0,u=s.length,p=u-1;l<u;p=l++)i+=wr(s[l][0]-s[p][0])*(s[l][1]+s[p][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 s=0;s<e.length-1;s++){let l=e[s],u=e[s+1],p=this.distance(l,u);if(r+=p,r>i)return wc(l,u,(i-(r-p))/p)}return e[e.length-1]}pointToSegmentDistance(e,i,r){let[s,l]=i,u=wr(r[0]-s)*this.kx,p=(r[1]-l)*this.ky;if(u!==0||p!==0){let f=(wr(e[0]-s)*this.kx*u+(e[1]-l)*this.ky*p)/(u*u+p*p);f>1?(s=r[0],l=r[1]):f>0&&(s+=u/this.kx*f,l+=p/this.ky*f)}return u=wr(e[0]-s)*this.kx,p=(e[1]-l)*this.ky,Math.sqrt(u*u+p*p)}pointOnLine(e,i){let r=1/0,s=e[0][0],l=e[0][1],u=0,p=0;for(let f=0;f<e.length-1;f++){let g=e[f][0],x=e[f][1],b=wr(e[f+1][0]-g)*this.kx,w=(e[f+1][1]-x)*this.ky,S=0;b===0&&w===0||(S=(wr(i[0]-g)*this.kx*b+(i[1]-x)*this.ky*w)/(b*b+w*w),S>1?(g=e[f+1][0],x=e[f+1][1]):S>0&&(g+=b/this.kx*S,x+=w/this.ky*S)),b=wr(i[0]-g)*this.kx,w=(i[1]-x)*this.ky;let E=b*b+w*w;E<r&&(r=E,s=g,l=x,u=f,p=S)}return{point:[s,l],index:u,t:Math.max(0,Math.min(1,p))}}lineSlice(e,i,r){let s=this.pointOnLine(r,e),l=this.pointOnLine(r,i);if(s.index>l.index||s.index===l.index&&s.t>l.t){let g=s;s=l,l=g}let u=[s.point],p=s.index+1,f=l.index;!gt(r[p],u[0])&&p<=f&&u.push(r[p]);for(let g=p+1;g<=f;g++)u.push(r[g]);return gt(r[f],l.point)||u.push(l.point),u}lineSliceAlong(e,i,r){let s=0,l=[];for(let u=0;u<r.length-1;u++){let p=r[u],f=r[u+1],g=this.distance(p,f);if(s+=g,s>e&&l.length===0&&l.push(wc(p,f,(e-(s-g))/g)),s>=i)return l.push(wc(p,f,(i-(s-g))/g)),l;s>e&&l.push(f)}return l}bufferPoint(e,i){let r=i/this.ky,s=i/this.kx;return[e[0]-s,e[1]-r,e[0]+s,e[1]+r]}bufferBBox(e,i){let r=i/this.ky,s=i/this.kx;return[e[0]-s,e[1]-r,e[2]+s,e[3]+r]}insideBBox(e,i){return wr(e[0]-i[0])>=0&&wr(e[0]-i[2])<=0&&e[1]>=i[1]&&e[1]<=i[3]}}function gt(n,e){return n[0]===e[0]&&n[1]===e[1]}function wc(n,e,i){let r=wr(e[0]-n[0]);return[n[0]+r*i,n[1]+(e[1]-n[1])*i]}function wr(n){for(;n<-180;)n+=360;for(;n>180;)n-=360;return n}class dt{constructor(e=[],i=(r,s)=>r<s?-1:r>s?1:0){if(this.data=e,this.length=this.data.length,this.compare=i,this.length>0)for(let r=(this.length>>1)-1;r>=0;r--)this._down(r)}push(e){this.data.push(e),this._up(this.length++)}pop(){if(this.length===0)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,s=i[e];for(;e>0;){let l=e-1>>1,u=i[l];if(r(s,u)>=0)break;i[e]=u,e=l}i[e]=s}_down(e){let{data:i,compare:r}=this,s=this.length>>1,l=i[e];for(;e<s;){let u=1+(e<<1),p=u+1;if(p<this.length&&r(i[p],i[u])<0&&(u=p),r(i[u],l)>=0)break;i[e]=i[u],e=u}i[e]=l}}var Xe=8192;function Du(n,e){return e.dist-n.dist}function Qh(n){let e=[1/0,1/0,-1/0,-1/0];if(e.length!==n.length)return!1;for(let i=0;i<e.length;i++)if(e[i]!==n[i])return!1;return!0}function Tc(n){return n[1]-n[0]+1}function to(n,e){let i=n[1]>=n[0]&&n[1]<e;return i||console.warn("Distance Expression: Index is out of range"),i}function ed(n,e){if(n[0]>
1n[1])return[null,null];let i=Tc(n);if(e){if(i===2)return[n,null];let r=Math.floor(i/2);return[[n[0],n[0]+r],[n[0]+r,n[1]]]}{if(i===1)return[n,null];let r=Math.floor(i/2)-1;return[[n[0],n[0]+r],[n[0]+r+1,n[1]]]}}function Jo(n,e){let i=[1/0,1/0,-1/0,-1/0];if(!to(e,n.length))return i;for(let r=e[0];r<=e[1];++r)ul(i,n[r]);return i}function Po(n){let e=[1/0,1/0,-1/0,-1/0];for(let i=0;i<n.length;++i)for(let r=0;r<n[i].length;++r)ul(e,n[i][r]);return e}function Ms(n,e,i){if(Qh(n)||Qh(e))return NaN;let r=0,s=0;return n[2]<e[0]&&(r=e[0]-n[2]),n[0]>e[2]&&(r=n[0]-e[2]),n[1]>e[3]&&(s=n[1]-e[3]),n[3]<e[1]&&(s=e[1]-n[3]),i.distance([0,0],[r,s])}function Cs(n){return 360*n-180}function gf(n){return 360/Math.PI*Math.atan(Math.exp((180-360*n)*Math.PI/180))-90}function Sc(n,e,i=8192){let r=Math.pow(2,e.z),s=(n.y/i+e.y)/r;return[Cs((n.x/i+e.x)/r),gf(s)]}function j_(n,e){let i=[];for(let r=0;r<n.length;++r)i.push(Sc(n[r],e));return i}function yf(n,e,i){let r=i.pointOnLine(e,n).point;return i.distance(n,r)}function xf(n,e,i,r,s){let l=i.slice(r[0],r[1]+1),u=1/0;for(let p=e[0];p<=e[1];++p)if((u=Math.min(u,yf(n[p],l,s)))===0)return 0;return u}function dl(n,e,i,r,s){let l=Math.min(s.pointToSegmentDistance(n,i,r),s.pointToSegmentDistance(e,i,r)),u=Math.min(s.pointToSegmentDistance(i,n,e),s.pointToSegmentDistance(r,n,e));return Math.min(l,u)}function vf(n,e,i,r,s){if(!to(e,n.length)||!to(r,i.length))return NaN;let l=1/0;for(let u=e[0];u<e[1];++u)for(let p=r[0];p<r[1];++p){if(Mu(n[u],n[u+1],i[p],i[p+1]))return 0;l=Math.min(l,dl(n[u],n[u+1],i[p],i[p+1],s))}return l}function Ea(n,e,i,r,s){if(!to(e,n.length)||!to(r,i.length))return NaN;let l=1/0;for(let u=e[0];u<=e[1];++u)for(let p=r[0];p<=r[1];++p)if((l=Math.min(l,s.distance(n[u],i[p])))===0)return l;return l}function G_(n,e,i){if(hl(n,e,!0))return 0;let r=1/0;for(let s of e){let l=s.length;if(l<2)return console.warn("Distance Expression: Invalid polygon!"),NaN;if(s[0]!==s[l-1]&&(r=Math.min(r,i.pointToSegmentDistance(n,s[l-1],s[0])))===0||(r=Math.min(r,yf(n,s,i)))===0)return r}return r}function $_(n,e,i,r){if(!to(e,n.length))return NaN;for(let l=e[0];l<=e[1];++l)if(hl(n[l],i,!0))return 0;let s=1/0;for(let l=e[0];l<e[1];++l)for(let u of i)for(let p=0,f=u.length,g=f-1;p<f;g=p++){if(Mu(n[l],n[l+1],u[g],u[p]))return 0;s=Math.min(s,dl(n[l],n[l+1],u[g],u[p],r))}return s}function bf(n,e){for(let i of n)for(let r=0;r<=i.length-1;++r)if(hl(i[r],e,!0))return!0;return!1}function H_(n,e,i,r=1/0){let s=Po(n),l=Po(e);if(r!==1/0&&Ms(s,l,i)>=r)return r;if(ba(s,l)){if(bf(n,e))return 0}else if(bf(e,n))return 0;let u=r;for(let p of n)for(let f=0,g=p.length,x=g-1;f<g;x=f++)for(let b of e)for(let w=0,S=b.length,E=S-1;w<S;E=w++){if(Mu(p[x],p[f],b[E],b[w]))return 0;u=Math.min(u,dl(p[x],p[f],b[E],b[w],i))}return u}function pl(n,e,i,r,s,l,u){if(l===null||u===null)return;let p=Ms(Jo(r,l),Jo(s,u),i);p<e&&n.push({dist:p,range1:l,range2:u})}function q_(n,e,i,r,s=1/0){let l=Math.min(r.distance(n[0],i[0][0]),s);if(l===0)return l;let u=new dt([{dist:0,range1:[0,n.length-1],range2:[0,0]}],Du),p=e?50:100,f=Po(i);for(;u.length;){let g=u.pop();if(g.dist>=l)continue;let x=g.range1;if(Tc(x)<=p){if(!to(x,n.length))return NaN;if(e){let b=$_(n,x,i,r);if((l=Math.min(l,b))===0)return l}else for(let b=x[0];b<=x[1];++b){let w=G_(n[b],i,r);if((l=Math.min(l,w))===0)return l}}else{let b=ed(x,e);if(b[0]!==null){let w=Ms(Jo(n,b[0]),f,r);w<l&&u.push({dist:w,range1:b[0],range2:[0,0]})}if(b[1]!==null){let w=Ms(Jo(n,b[1]),f,r);w<l&&u.push({dist:w,range1:b[1],range2:[0,0]})}}}return l}function Ru(n,e,i,r,s,l=1/0){let u=Math.min(l,s.distance(n[0],i[0]));if(u===0)return u;let p=new dt([{dist:0,range1:[0,n.length-1],range2:[0,i.length-1]}],Du),f=e?50:100,g=r?50:100;for(;p.length;){let x=p.pop();if(x.dist>=u)continue;let b=x.range1,w=x.range2;if(Tc(b)<=f&&Tc(w)<=g){if(!to(b,n.length)||!to(w,i.length))return NaN;if(e&&r?u=Math.min(u,vf(n,b,i,w,s)):e||r?e&&!r?u=Math.min(u,xf(i,w,n,b,s)):!e&&r&&(u=Math.min(u,xf(n,b,i,w,s))):u=Math.min(u,Ea(n,b,i,w,s)),u===0)return u}else{let S=ed(b,e),E=ed(w,r);pl(p,u,s,n,i,S[0],E[0]),pl(p,u,s,n,i,S[0],E[1]),pl(p,u,s,n,i,S[1],E[0]),pl(p,u,s,n,i,S[1],E[1])}}return u}function td(n,e,i,r,s=1/0){let l=s,u=Jo(n,[0,n.length-1]);for(let p of i)if(!(l!==1/0&&Ms(u,Jo(p,[0,p.length-1]),r)>=l)&&(l=Math.min(l,Ru(n,e,p,!0,r,l)),l===0))return l;return l}function zu(n,e,i,r,s=1/0){let l=s,u=Jo(n,[0,n.length-1]);for(let p of i){if(l!==1/0&&Ms(u,Po(p),r)>=l)continue;let f=q_(n,e,p,r,l);if(isNaN(f))return f;if((l=Math.min(l,f))===0)return l}return l}function Lu(n){return n==="Point"||n==="MultiPoint"||n==="LineString"||n==="MultiLineString"||n==="Polygon"||n==="MultiPolygon"}class Aa{constructor(e,i){this.type=st,this.geojson=e,this.geometries=i}static parse(e,i){if(e.length!==2)return i.error(`'distance' expression requires either one argument, but found ' ${e.length-1} instead.`);if(cl(e[1])){let r=e[1];if(r.type==="FeatureCollection"){for(let s=0;s<r.features.length;++s)if(Lu(r.features[s].geometry.type))return new Aa(r,r.features[s].geometry)}else if(r.type==="Feature"){if(Lu(r.geometry.type))return new Aa(r,r.geometry)}else if(Lu(r.type))return new Aa(r,r)}return i.error("'distance' expression needs to be an array with format ['Distance', GeoJSONObj].")}evaluate(e){let i=e.geometry(),r=e.canonicalID();if(i!=null&&r!=null){if(e.geometryType()==="Point")return function(s,l,u){let p=[];for(let g of s)for(let x of g)p.push(Sc(x,l));let f=new Ia(p[0][1],"meters");return u.type==="Point"||u.type==="MultiPoint"||u.type==="LineString"?Ru(p,!1,u.type==="Point"?[u.coordinates]:u.coordinates,u.type==="LineString",f):u.type==="MultiLineString"?td(p,!1,u.coordinates,f):u.type==="Polygon"||u.type==="MultiPolygon"?zu(p,!1,u.type==="Polygon"?[u.coordinates]:u.coordinates,f):null}(i,r,this.geometries);if(e.geometryType()==="LineString")return function(s,l,u){let p=[];for(let g of s){let x=[];for(let b of g)x.push(Sc(b,l));p.push(x)}let f=new Ia(p[0][0][1],"meters");if(u.type==="Point"||u.type==="MultiPoint"||u.type==="LineString")return td(u.type==="Point"?[u.coordinates]:u.coordinates,u.type==="LineString",p,f);if(u.type==="MultiLineString"){let g=1/0;for(let x=0;x<u.coordinates.length;x++){let b=td(u.coordinates[x],!0,p,f,g);if(isNaN(b))return b;if((g=Math.min(g,b))===0)return g}return g}if(u.type==="Polygon"||u.type==="MultiPolygon"){let g=1/0;for(let x=0;x<p.length;x++){let b=zu(p[x],!0,u.type==="Polygon"?[u.coordinates]:u.coordinates,f,g);if(isNaN(b))return b;if((g=Math.min(g,b))===0)return g}return g}return null}(i,r,this.geometries);if(e.geometryType()==="Polygon")return function(s,l,u){let p=[];for(let g of function(x){let b=x.length;if(b<=1)return[x];let w=[],S,E;for(let M=0;M<b;M++){let C=B_(x[M]);C!==0&&(x[M].area=Math.abs(C),E===void 0&&(E=C<0),E===C<0?(S&&w.push(S),S=[x[M]]):S.push(x[M]))}return S&&w.push(S),w}(s)){let x=[];for(let b=0;b<g.length;++b)x.push(j_(g[b],l));p.push(x)}let f=new Ia(p[0][0][0][1],"meters");if(u.type==="Point"||u.type==="MultiPoint"||u.type==="LineString")return zu(u.type==="Point"?[u.coordinates]:u.coordinates,u.type==="LineString",p,f);if(u.type==="MultiLineString"){let g=1/0;for(let x=0;x<u.coordinates.length;x++){let b=zu(u.coordinates[x],!0,p,f,g);if(isNaN(b))return b;if((g=Math.min(g,b))===0)return g}return g}return u.type==="Polygon"||u.type==="MultiPolygon"?function(g,x,b){let w=1/0;for(let S of g)for(let E of x){let M=H_(S,E,b,w);if(isNaN(M))return M;if((w=Math.min(w,M))===0)return w}return w}(u.type==="Polygon"?[u.coordinates]:u.coordinates,p,f):null}(i,r,this.geometries);console.warn("Distance Expression: currently only evaluates valid Point/LineString/Polygon geometries.")}else console.warn("Distance Expression: requires valid feature and canonical information.");return null}eachChild(){}outputDefined(){return!0}serialize(){return["distance",this.geojson]}}function Ma(n){if(n instanceof ur&&(n.name==="get"&&n.args.length===1||n.name==="feature-state"||n.name==="has"&&n.args.length===1||n.name==="properties"||n.name==="geometry-type"||n.name==="id"||n.name.startsWith("filter-"))||n instanceof Ta||n instanceof Aa)return!1;if(n instanceof ml)return n.featureConstant;let e=!0;return n.eachChild(i=>{e&&!Ma(i)&&(e=!1)}),e}function fl(n){if(n instanceof ur&&n.name==="feature-state")return!1;let e=!0;return n.eachChild(i=>{e&&!fl(i)&&(e=!1)}),e}function tr(n,e){if(n instanceof ur&&e.includes(n.name))return!1;let i=!0;return n.eachChild(r=>{i&&!tr(r,e)&&(i=!1)}),i}
1function wf(n,e,i){return[n,e,i].filter(Boolean).join("�")}function id(n,e){switch(n){case"string":return vr(e);case"number":return+e;case"boolean":return!!e;case"color":return jt.parse(e);case"formatted":return kn.fromString(vr(e));case"resolvedImage":return cr.build(vr(e))}return e}function Ou(n,e,i,r){return r!==void 0&&(n=r*Math.round(n/r)),e!==void 0&&n<e&&(n=e),i!==void 0&&n>i&&(n=i),n}class ml{constructor(e,i,r,s=!1){this.type=e,this.key=i,this.scope=r,this.featureConstant=s}static parse(e,i){let r=i.expectedType;if(r==null&&(r=qt),e.length<2||e.length>3)return i.error("Invalid number of arguments for 'config' expression.");let s=i.parse(e[1],1);if(!(s instanceof xo))return i.error("Key name of 'config' expression must be a string literal.");let l,u=!0,p=vr(s.value);if(e.length>=3){let f=i.parse(e[2],2);if(!(f instanceof xo))return i.error("Scope of 'config' expression must be a string literal.");l=vr(f.value)}if(i.options){let f=wf(p,l,i._scope),g=i.options.get(f);g&&(u=Ma(g.value||g.default))}return new ml(r,p,l,u)}evaluate(e){let i=wf(this.key,this.scope,e.scope),r=e.getConfig(i);if(!r)return null;let{type:s,value:l,values:u,minValue:p,maxValue:f,stepValue:g}=r,x=r.default.evaluate(e),b=x;if(l){let w=e.scope;e.scope=(w||"").split("�").slice(1).join("�"),b=l.evaluate(e),e.scope=w}return s&&(b=id(s,b)),b===void 0||p===void 0&&f===void 0&&g===void 0||(typeof b=="number"?b=Ou(b,p,f,g):Array.isArray(b)&&(b=b.map(w=>typeof w=="number"?Ou(w,p,f,g):w))),l!==void 0&&b!==void 0&&u&&!u.includes(b)&&(b=x,s&&(b=id(s,b))),(s&&s!==this.type||b!==void 0&&!Tu(vn(b),this.type))&&(b=id(this.type.kind,b)),b}eachChild(){}outputDefined(){return!1}serialize(){let e=["config",this.key];return this.scope&&e.concat(this.scope),e}}class Ic{constructor(e,i){this.type=i.type,this.name=e,this.boundExpression=i}static parse(e,i){if(e.length!==2||typeof e[1]!="string")return i.error("'var' expression requires exactly one string literal argument.");let r=e[1];return i.scope.has(r)?new Ic(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 Ec{constructor(e,i=[],r,s=new Wh,l=[],u,p,f){this.registry=e,this.path=i,this.scope=s,this.errors=l,this.expectedType=r,this._scope=u,this.options=p,this.iconImageUseTheme=f}get key(){if(this._key===void 0){let e=this.path,i="";for(let r=0;r<e.length;r++){let s=e[r];i+=typeof s=="string"?`['${s}']`:`[${s}]`}this._key=i}return this._key}parse(e,i,r,s,l={}){return i||r?this.concat(i,null,r,s)._parse(e,l):this._parse(e,l)}parseObjectValue(e,i,r,s,l,u={}){return this.concat(i,r,s,l)._parse(e,u)}_parse(e,i){function r(s,l,u){return u==="assert"?new Qr(l,[s]):u==="coerce"?new br(l,[s]):s}if(e!==null&&typeof e!="string"&&typeof e!="boolean"&&typeof e!="number"||(e=["literal",e]),Array.isArray(e)){if(e.length===0)return this.error('Expected an array with at least one element. If you wanted a literal array, use ["literal", []].');let s=typeof e[0]=="string"?this.registry[e[0]]:void 0;if(s){let l=s.parse(e,this);if(!l)return null;if(this.expectedType){let u=this.expectedType,p=l.type;if(u.kind!=="string"&&u.kind!=="number"&&u.kind!=="boolean"&&u.kind!=="object"&&u.kind!=="array"||p.kind!=="value")if(u.kind!=="color"&&u.kind!=="formatted"&&u.kind!=="resolvedImage"||p.kind!=="value"&&p.kind!=="string"){if(this.checkSubtype(u,p))return null}else l=r(l,u,i.typeAnnotation||"coerce");else l=r(l,u,i.typeAnnotation||"assert")}if(!(l instanceof xo)&&l.type.kind!=="resolvedImage"&&Fr(l)){let u=new eo(this._scope,this.options,this.iconImageUseTheme);try{l=new xo(l.type,l.evaluate(u))}catch(p){return this.error(p.message),null}}return l}return br.parse(["to-array",e],this)}return this.error(e===void 0?"'undefined' value invalid. Use null instead.":typeof e=="object"?'Bare objects invalid. Use ["literal", {...}] instead.':`Expected an array, but found ${typeof e} instead.`)}concat(e,i,r,s){let l=typeof e=="number"?this.path.concat(e):this.path;l=typeof i=="string"?l.concat(i):l;let u=s?this.scope.concat(s):this.scope;return new Ec(this.registry,l,r||null,u,this.errors,this._scope,this.options,this.iconImageUseTheme)}error(e,...i){let r=`${this.key}${i.map(s=>`[${s}]`).join("")}`;this.errors.push(new yo(r,e))}checkSubtype(e,i,r){let s=al(e,i);return s&&this.error(s,...typeof r=="number"?[r]:[]),s}}function Fr(n){if(n instanceof Ic)return Fr(n.boundExpression);if(n instanceof ur&&n.name==="error"||n instanceof Is||n instanceof Ta||n instanceof Aa||n instanceof ml)return!1;let e=n instanceof br||n instanceof Qr,i=!0;return n.eachChild(r=>{i=e?i&&Fr(r):i&&r instanceof xo}),!!i&&Ma(n)&&tr(n,["zoom","heatmap-density","worldview","line-progress","raster-value","sky-radial-progress","accumulated","is-supported-script","pitch","distance-from-center","measure-light","raster-particle-speed","is-active-floor"])}function _l(n,e){let i=n.length-1,r,s,l=0,u=i,p=0;for(;l<=u;)if(p=Math.floor((l+u)/2),r=n[p],s=n[p+1],r<=e){if(p===i||e<s)return p;l=p+1}else{if(!(r>e))throw new sn("Input is not a number.");u=p-1}return 0}class gl{constructor(e,i,r){this.type=e,this.input=i,this.labels=[],this.outputs=[];for(let[s,l]of r)this.labels.push(s),this.outputs.push(l)}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,st);if(!r)return null;let s=[],l=null;i.expectedType&&i.expectedType.kind!=="value"&&(l=i.expectedType);for(let u=1;u<e.length;u+=2){let p=u===1?-1/0:e[u],f=e[u+1],g=u,x=u+1;if(typeof p!="number")return i.error('Input/output pairs for "step" expressions must be defined using literal numeric values (not c
1omputed expressions) for the input values.',g);if(s.length&&s.at(-1)[0]>=p)return i.error('Input/output pairs for "step" expressions must be arranged with input values in strictly ascending order.',g);let b=i.parse(f,x,l);if(!b)return null;l=l||b.type,s.push([p,b])}return new gl(l,r,s)}evaluate(e){let i=this.labels,r=this.outputs;if(i.length===1)return r[0].evaluate(e);let s=this.input.evaluate(e);if(s<=i[0])return r[0].evaluate(e);let l=i.length;return s>=i[l-1]?r[l-1].evaluate(e):r[_l(i,s)].evaluate(e)}eachChild(e){e(this.input);for(let i of 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 nd=.95047,rd=1.08883,od=4/29,Ca=6/29,sd=3*Ca*Ca,ad=Ca*Ca*Ca,Tf=Math.PI/180,Sf=180/Math.PI;function Fu(n){return n>ad?Math.pow(n,1/3):n/sd+od}function Bu(n){return n>Ca?n*n*n:sd*(n-od)}function ku(n){return 255*(n<=.0031308?12.92*n:1.055*Math.pow(n,1/2.4)-.055)}function ld(n){return(n/=255)<=.04045?n/12.92:Math.pow((n+.055)/1.055,2.4)}function If(n){let e=ld(n.r),i=ld(n.g),r=ld(n.b),s=Fu((.4124564*e+.3575761*i+.1804375*r)/nd),l=Fu((.2126729*e+.7151522*i+.072175*r)/1);return{l:116*l-16,a:500*(s-l),b:200*(l-Fu((.0193339*e+.119192*i+.9503041*r)/rd)),alpha:n.a}}function Ac(n){let e=(n.l+16)/116,i=isNaN(n.a)?e:e+n.a/500,r=isNaN(n.b)?e:e-n.b/200;return e=1*Bu(e),i=nd*Bu(i),r=rd*Bu(r),new jt(ku(3.2404542*i-1.5371385*e-.4985314*r),ku(-.969266*i+1.8760108*e+.041556*r),ku(.0556434*i-.2040259*e+1.0572252*r),n.alpha)}function Mc(n,e,i){let r=e-n;return n+i*(r>180||r<-180?r-360*Math.round(r/360):r)}let Ps={forward:If,reverse:Ac,interpolate:function(n,e,i){return{l:ft(n.l,e.l,i),a:ft(n.a,e.a,i),b:ft(n.b,e.b,i),alpha:ft(n.alpha,e.alpha,i)}}},yl={forward:function(n){let{l:e,a:i,b:r}=If(n),s=Math.atan2(r,i)*Sf;return{h:s<0?s+360:s,c:Math.sqrt(i*i+r*r),l:e,alpha:n.a}},reverse:function(n){let e=n.h*Tf,i=n.c;return Ac({l:n.l,a:Math.cos(e)*i,b:Math.sin(e)*i,alpha:n.alpha})},interpolate:function(n,e,i){return{h:Mc(n.h,e.h,i),c:ft(n.c,e.c,i),l:ft(n.l,e.l,i),alpha:ft(n.alpha,e.alpha,i)}}};var cd=Object.freeze({__proto__:null,hcl:yl,lab:Ps});class Tr{constructor(e,i,r,s,l){this.type=e,this.operator=i,this.interpolation=r,this.input=s,this.labels=[],this.outputs=[];for(let[u,p]of l)this.labels.push(u),this.outputs.push(p)}static interpolationFactor(e,i,r,s){let l=0;if(e.name==="exponential")l=Nu(i,e.base,r,s);else if(e.name==="linear")l=Nu(i,1,r,s);else if(e.name==="cubic-bezier"){let u=e.controlPoints;l=new Qa(u[0],u[1],u[2],u[3]).solve(Nu(i,1,r,s))}return l}static parse(e,i){let[r,s,l,...u]=e;if(!Array.isArray(s)||s.length===0)return i.error("Expected an interpolation type expression.",1);if(s[0]==="linear")s={name:"linear"};else if(s[0]==="exponential"){let g=s[1];if(typeof g!="number")return i.error("Exponential interpolation requires a numeric base.",1,1);s={name:"exponential",base:g}}else{if(s[0]!=="cubic-bezier")return i.error(`Unknown interpolation type ${String(s[0])}`,1,0);{let g=s.slice(1);if(g.length!==4||g.some(x=>typeof x!="number"||x<0||x>1))return i.error("Cubic bezier interpolation requires four numeric arguments with values between 0 and 1.",1);s={name:"cubic-bezier",controlPoints:g}}}if(e.length-1<4)return 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(l=i.parse(l,2,st),!l)return null;let p=[],f=null;r==="interpolate-hcl"||r==="interpolate-lab"?f=rn:i.expectedType&&i.expectedType.kind!=="value"&&(f=i.expectedType);for(let g=0;g<u.length;g+=2){let x=u[g],b=u[g+1],w=g+3,S=g+4;if(typeof x!="number")return i.error('Input/output pairs for "interpolate" expressions must be defined using literal numeric values (not computed expressions) for the input values.',w);if(p.length&&p.at(-1)[0]>=x)return i.error('Input/output pairs for "interpolate" expressions must be arranged with input values in strictly ascending order.',w);let E=i.parse(b,S,f);if(!E)return null;f=f||E.type,p.push([x,E])}return f.kind==="number"||f.kind==="color"||f.kind==="array"&&f.itemType.kind==="number"&&typeof f.N=="number"?new Tr(f,r,s,l,p):i.error(`Type ${on(f)} is not interpolatable.`)}evaluate(e){let i=this.labels,r=this.outputs;if(i.length===1)return r[0].evaluate(e);let s=this.input.evaluate(e);if(s<=i[0])return r[0].evaluate(e);let l=i.length;if(s>=i[l-1])return r[l-1].evaluate(e);let u=_l(i,s),p=Tr.interpolationFactor(this.interpolation,s,i[u],i[u+1]),f=r[u].evaluate(e),g=r[u+1].evaluate(e);return this.operator==="interpolate"?vu[this.type.kind.toLowerCase()](f,g,p):this.operator==="interpolate-hcl"?yl.reverse(yl.interpolate(yl.forward(f),yl.forward(g),p)):Ps.reverse(Ps.interpolate(Ps.forward(f),Ps.forward(g),p))}eachChild(e){e(this.input);for(let i of this.outputs)e(i)}outputDefined(){return this.outputs.every(e=>e.outputDefined())}serialize(){let e;e=this.interpolation.name==="linear"?["linear"]:this.interpolation.name==="exponential"?this.interpolation.base===1?["linear"]:["exponential",this.interpolation.base]:["cubic-bezier",...this.interpolation.controlPoints];let i=[this.operator,e,this.input.serialize()];for(let r=0;r<this.labels.length;
1r++)i.push(this.labels[r],this.outputs[r].serialize());return i}}function Nu(n,e,i,r){let s=r-i,l=n-i;return s===0?0:e===1?l/s:(Math.pow(e,l)-1)/(Math.pow(e,s)-1)}class Uu{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."),null;let r=null,s=i.expectedType;s&&s.kind!=="value"&&(r=s);let l=[];for(let p of e.slice(1)){let f=i.parse(p,1+l.length,r,void 0,{typeAnnotation:"omit"});if(!f)return null;r=r||f.type,l.push(f)}let u=s&&l.some(p=>al(s,p.type));return new Uu(u?qt:r,l)}evaluate(e){let i,r=null,s=0;for(let l of this.args){if(s++,r=l.evaluate(e),r&&r instanceof cr&&!r.available&&(i||(i=r),r=null,s===this.args.length))return i;if(r!==null)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}}let Z_=/[^a-zA-Z0-9_]/;class Vu{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 l=1;l<e.length-1;l+=2){let u=e[l];if(typeof u!="string")return i.error(`Expected string, but found ${typeof u} instead.`,l);if(Z_.test(u))return i.error("Variable names must contain only alphanumeric characters or '_'.",l);let p=i.parse(e[l+1],l+1);if(!p)return null;r.push([u,p])}let s=i.parse(e.at(-1),e.length-1,i.expectedType,r);return s?new Vu(r,s):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 Ds{constructor(e,i,r){this.type=e,this.index=i,this.input=r}static parse(e,i){if(e.length!==3)return i.error(`Expected 2 arguments, but found ${e.length-1} instead.`);let r=i.parse(e[1],1,st),s=i.parse(e[2],2,Yn(i.expectedType||qt));return r&&s?new Ds(s.type.itemType,r,s):null}evaluate(e){let i=this.index.evaluate(e),r=this.input.evaluate(e);if(i<0)throw new sn("Array index out of bounds: negative index");if(i>=r.length)throw new sn("Array index out of bounds: index exceeds array size");if(i!==Math.floor(i))throw new sn("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 ju{constructor(e,i,r){this.type=e,this.index=i,this.input=r}static parse(e,i){if(e.length!==3)return i.error(`Expected 2 arguments, but found ${e.length-1} instead.`);let r=i.parse(e[1],1,st),s=i.parse(e[2],2,Yn(i.expectedType||qt));return r&&s?new ju(s.type.itemType,r,s):null}evaluate(e){let i=this.index.evaluate(e),r=this.input.evaluate(e);if(i<0)throw new sn(`Array index out of bounds: ${i} < 0.`);if(i>r.length-1)throw new sn(`Array index out of bounds: ${i} > ${r.length-1}.`);if(i===Math.floor(i))return r[i];let s=Math.floor(i),l=Math.ceil(i),u=r[s],p=r[l];if(typeof u!="number"||typeof p!="number")throw new sn(`Cannot interpolate between non-number values at index ${i}.`);let f=i-s;return u*(1-f)+p*f}eachChild(e){e(this.index),e(this.input)}outputDefined(){return!1}serialize(){return["at-interpolated",this.index.serialize(),this.input.serialize()]}}class zt{constructor(e,i){this.type=ni,this.needle=e,this.haystack=i}static parse(e,i){if(e.length!==3)return i.error(`Expected 2 arguments, but found ${e.length-1} instead.`),null;let r=i.parse(e[1],1,qt),s=i.parse(e[2],2,qt);return r&&s?wu(r.type,[ni,Kt,st,ya,qt])?new zt(r,s):(i.error(`Expected first argument to be of type boolean, string, number or null, but found ${on(r.type)} instead`),null):null}evaluate(e){let i=this.needle.evaluate(e),r=this.haystack.evaluate(e);if(r==null)return!1;if(!_c(i,["boolean","string","number","null"]))throw new sn(`Expected first argument to be of type boolean, string, number or null, but found ${on(vn(i))} instead.`);if(!_c(r,["string","array"]))throw new sn(`Expected second argument to be of type array or string, but found ${on(vn(r))} instead.`);return r.includes(i)}eachChild(e){e(this.needle),e(this.haystack)}outputDefined(){return!0}serialize(){return["in",this.needle.serialize(),this.haystack.serialize()]}}class Gu{constructor(e,i,r){this.type=st,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.`),null;let r=i.parse(e[1],1,qt),s=i.parse(e[2],2,qt);if(!r||!s)return null;if(!wu(r.type,[ni,Kt,st,ya,qt]))return i.error(`Expected first argument to be of type boolean, string, number or null, but found ${on(r.type)} instead`),null;if(e.length===4){let l=i.parse(e[3],3,st);return l?new Gu(r,s,l):null}return new Gu(r,s)}evaluate(e){let i=this.needle.evaluate(e),r=this.haystack.evaluate(e);if(!_c(i,["boolean","string","number","null"]))throw new sn(`Expected first argument to be of type boolean, string, number or null, but found ${on(vn(i))} instead.`);if(!_c(r,["string","array"]))throw new sn(`Expected second argument to be of type array or string, but found ${on(vn(r))} instead.`);if(this.fromIndex){let s=this.fromIndex.evaluate(e);return r.indexOf(i,s)}return r.indexOf(i)}eachChild(e){e(this.needle),e(this.haystack),this.fromIndex&&e(this.fromIndex)}outputDefined(){return!1}serialize(){if(this.fromIndex!=null&&this.fromIndex!==void 0){let e=this.fromIndex.serialize();return["index-of",this.needle.serialize(),this.haystack.serialize(),e]}return["index-of",this.needle.serialize(),this.haystack.serialize()]}}class ud{constructor(e,i,r,s,l,u){this.inputType=e,this.type=i,this.input=r,this.cases=s,this.outputs=l,this.otherwise=u}static parse(e,i){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.");let r,s;i.expectedType&&i.expectedType.kind!=="value"&&(s=i.expectedType);let l={},u=[];for(let g=2;g<e.length-1;g+=2){let x=e[g],b=e[g+1];Array.isArray(x)||(x=[x]);let w=i.concat(g);if(x.length===0)return w.error("Expected at least one branch label.");
1for(let E of x){if(typeof E!="number"&&typeof E!="string")return w.error("Branch labels must be numbers or strings.");if(typeof E=="number"&&Math.abs(E)>Number.MAX_SAFE_INTEGER)return w.error(`Branch labels must be integers no larger than ${Number.MAX_SAFE_INTEGER}.`);if(typeof E=="number"&&Math.floor(E)!==E)return w.error("Numeric branch labels must be integer values.");if(r){if(w.checkSubtype(r,vn(E)))return null}else r=vn(E);if(l[String(E)]!==void 0)return w.error("Branch labels must be unique.");l[String(E)]=u.length}let S=i.parse(b,g,s);if(!S)return null;s=s||S.type,u.push(S)}let p=i.parse(e[1],1,qt);if(!p)return null;let f=i.parse(e.at(-1),e.length-1,s);return f?p.type.kind!=="value"&&i.concat(1).checkSubtype(r,p.type)?null:new ud(r,s,p,l,u,f):null}evaluate(e){let i=this.input.evaluate(e);return(Tu(vn(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=[],s={};for(let u of i){let p=s[this.cases[u]];p===void 0?(s[this.cases[u]]=r.length,r.push([this.cases[u],[u]])):r[p][1].push(u)}let l=u=>this.inputType.kind==="number"?Number(u):u;for(let[u,p]of r)e.push(p.length===1?l(p[0]):p.map(l)),e.push(this.outputs[u].serialize());return e.push(this.otherwise.serialize()),e}}class hd{constructor(e,i,r){this.type=e,this.branches=i,this.otherwise=r}static parse(e,i){if(e.length<4)return i.error(`Expected at least 3 arguments, but found only ${e.length-1}.`),null;if(e.length%2!=0)return i.error("Expected an odd number of arguments."),null;let r;i.expectedType&&i.expectedType.kind!=="value"&&(r=i.expectedType);let s=[];for(let u=1;u<e.length-1;u+=2){let p=i.parse(e[u],u,ni);if(!p)return null;let f=i.parse(e[u+1],u+1,r);if(!f)return null;s.push([p,f]),r=r||f.type}let l=i.parse(e.at(-1),e.length-1,r);return l?new hd(r,s,l):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 Cc{constructor(e,i,r,s){this.type=e,this.input=i,this.beginIndex=r,this.endIndex=s}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.`),null;let r=i.parse(e[1],1,qt),s=i.parse(e[2],2,st);if(!r||!s)return null;if(!wu(r.type,[Yn(qt),Kt,qt]))return i.error(`Expected first argument to be of type array or string, but found ${on(r.type)} instead`),null;if(e.length===4){let l=i.parse(e[3],3,st);return l?new Cc(r.type,r,s,l):null}return new Cc(r.type,r,s)}evaluate(e){let i=this.input.evaluate(e),r=this.beginIndex.evaluate(e);if(!_c(i,["string","array"]))throw new sn(`Expected first argument to be of type array or string, but found ${on(vn(i))} instead.`);if(this.endIndex){let s=this.endIndex.evaluate(e);return i.slice(r,s)}return i.slice(r)}eachChild(e){e(this.input),e(this.beginIndex),this.endIndex&&e(this.endIndex)}outputDefined(){return!1}serialize(){if(this.endIndex!=null&&this.endIndex!==void 0){let e=this.endIndex.serialize();return["slice",this.input.serialize(),this.beginIndex.serialize(),e]}return["slice",this.input.serialize(),this.beginIndex.serialize()]}}class dd{constructor(e,i){this.type=Yn(Kt),this.str=e,this.delimiter=i}static parse(e,i){if(e.length!==3)return i.error(`Expected 2 arguments, but found ${e.length-1} instead.`);let r=i.parse(e[1],1,Kt),s=i.parse(e[2],2,Kt);return r&&s?new dd(r,s):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 Ti(n,e){return n==="=="||n==="!="?e.kind==="boolean"||e.kind==="str
1ing"||e.kind==="number"||e.kind==="null"||e.kind==="value":e.kind==="string"||e.kind==="number"||e.kind==="value"}function Ef(n,e,i,r){return r.compare(e,i)===0}function xl(n,e,i){let r=n!=="=="&&n!=="!=";return class A1{constructor(l,u,p){this.type=ni,this.lhs=l,this.rhs=u,this.collator=p,this.hasUntypedArgument=l.type.kind==="value"||u.type.kind==="value"}static parse(l,u){if(l.length!==3&&l.length!==4)return u.error("Expected two or three arguments.");let p=l[0],f=u.parse(l[1],1,qt);if(!f)return null;if(!Ti(p,f.type))return u.concat(1).error(`"${p}" comparisons are not supported for type '${on(f.type)}'.`);let g=u.parse(l[2],2,qt);if(!g)return null;if(!Ti(p,g.type))return u.concat(2).error(`"${p}" comparisons are not supported for type '${on(g.type)}'.`);if(f.type.kind!==g.type.kind&&f.type.kind!=="value"&&g.type.kind!=="value")return u.error(`Cannot compare types '${on(f.type)}' and '${on(g.type)}'.`);r&&(f.type.kind==="value"&&g.type.kind!=="value"?f=new Qr(g.type,[f]):f.type.kind!=="value"&&g.type.kind==="value"&&(g=ne
1w Qr(f.type,[g])));let x=null;if(l.length===4){if(f.type.kind!=="string"&&g.type.kind!=="string"&&f.type.kind!=="value"&&g.type.kind!=="value")return u.error("Cannot use collator to compare non-string types.");if(x=u.parse(l[3],3,bu),!x)return null}return new A1(f,g,x)}evaluate(l){let u=this.lhs.evaluate(l),p=this.rhs.evaluate(l);if(r&&this.hasUntypedArgument){let f=vn(u),g=vn(p);if(f.kind!==g.kind||f.kind!=="string"&&f.kind!=="number")throw new sn(`Expected arguments for "${n}" to be (string, string) or (number, number), but found (${f.kind}, ${g.kind}) instead.`)}if(this.collator&&!r&&this.hasUntypedArgument){let f=vn(u),g=vn(p);if(f.kind!=="string"||g.kind!=="string")return e(l,u,p)}return this.collator?i(l,u,p,this.collator.evaluate(l)):e(l,u,p)}eachChild(l){l(this.lhs),l(this.rhs),this.collator&&l(this.collator)}outputDefined(){return!0}serialize(){let l=[n];return this.eachChild(u=>{l.push(u.serialize())}),l}}}let W_=xl("==",function(n,e,i){return e===i},Ef),X_=xl("!=",function(n,e,i){return e!==i},function(n,e,i,r){return!Ef(0,e,i,r)}),Y_=xl("<",function(n,e,i){return e<i},function(n,e,i,r){return r.compare(e,i)<0}),J_=xl(">",function(n,e,i){return e>i},function(n,e,i,r){return r.compare(e,i)>0}),K_=xl("<=",function(n,e,i){return e<=i},function(n,e,i,r){return r.compare(e,i)<=0}),Q_=xl(">=",function(n,e,i){return e>=i},function(n,e,i,r){return r.compare(e,i)>=0});class pd{constructor(e,i,r,s,l,u){this.type=Kt,this.number=e,this.locale=i,this.currency=r,this.unit=s,this.minFractionDigits=l,this.maxFractionDigits=u}static parse(e,i){if(e.length!==3)return i.error("Expected two arguments.");let r=i.parse(e[1],1,st);if(!r)return null;let s=e[2];if(typeof s!="object"||Array.isArray(s))return i.error("NumberFormat options argument must be an object.");let l=null;if(s.locale&&(l=i.parseObjectValue(s.locale,2,"locale",Kt),!l))return null;let u=null;if(s.currency&&(u=i.parseObjectValue(s.currency,2,"currency",Kt),!u))return null;let p=null;if(s.unit&&(p=i.parseObjectValue(s.unit,2,"unit",Kt),!p))return null;let f=null;if(s["min-fraction-digits"]&&(f=i.parseObjectValue(s["min-fraction-digits"],2,"min-fraction-digits",st),!f))return null;let g=null;return s["max-fraction-digits"]&&(g=i.parseObjectValue(s["max-fraction-digits"],2,"max-fraction-digits",st),!g)?null:new pd(r,l,u,p,f,g)}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 fd{constructor(e){this.type=st,this.input=e}static parse(e,i){if(e.length!==2)return i.error(`Expected 1 argument, but found ${e.length-1} instead.`),null;let r=i.parse(e[1],1);return r?r.type.kind!=="array"&&r.type.kind!=="string"&&r.type.kind!=="value"?(i.error(`Expected argument of type string or array, but found ${on(r.type)} instead.`),null):new fd(r):null}evaluate(e){let i=this.input.evaluate(e);if(typeof i=="string"||Array.isArray(i))return i.length;throw new sn(`Expected value to be of type string or array, but found ${on(vn(i))} instead.`)}eachChild(e){e(this.input)}outputDefined(){return!1}serialize(){let e=["length"];return this.eachChild(i=>{e.push(i.serialize())}),e}}function md(n){return function(){n=1831565813+(n|=0)|0;let e=Math.imul(n^n>>>15,1|n);return e=e+Math.imul(e^e>>>7,61|e)^e,((e^e>>>14)>>>0)/4294967296}}let vl={"==":W_,"!=":X_,">":J_,"<":Y_,">=":Q_,"<=":K_,array:Qr,at:Ds,"at-interpolated":ju,boolean:Qr,case:hd,coalesce:Uu,collator:Is,format:gc,image:yc,in:zt,"index-of":Gu,interpolate:Tr,"interpolate-hcl":Tr,"interpolate-lab":Tr,length:fd,let:Vu,literal:xo,match:ud,number:Qr,"number-format":pd,object:Qr,slice:Cc,step:gl,string:Qr,"to-boolean":br,"to-color":br,"to-number":br,"to-string":br,var:Ic,within:Ta,distance:Aa,config:ml,split:dd};function Af(n,[e,i,r,s]){e=e.evaluate(n),i=i.evaluate(n),r=r.evaluate(n);let l=s?s.evaluate(n):1,u=Su(e,i,r,l);if(u)throw new sn(u);return new jt(e/255,i/255,r/255,l)}function Mf(n,[e,i,r,s]){e=e.evaluate(n),i=i.evaluate(n),r=r.evaluate(n);let l=s?s.evaluate(n):1,u=function(g,x,b,w){return typeof g=="number"&&g>=0&&g<=360?typeof x=="number"&&x>=0&&x<=100&&typeof b=="number"&&b>=0&&b<=100?w===void 0||typeof w=="number"&&w>=0&&w<=1?null:`Invalid hsla value [${[g,x,b,w].join(", ")}]: 'a' must be between 0 and 1.`:`Invalid hsla value [${(typeof w=="number"?[g,x,b,w]:[g,x,b]).join(", ")}]: 's', and 'l' must be between 0 and 100.`:`Invalid hsla value [${(typeof w=="number"?[g,x,b,w]:[g,x,b]).join(", ")}]: 'h' must be between 0 and 360.`}(e,i,r,l);if(u)throw new sn(u);let p=`hsla(${e}, ${i}%, ${r}%, ${l})`,f=jt.parse(p);if(!f)throw new sn(`Failed to parse HSLA color: ${p}`);return f}function Cf(n,e){return n in e}function _d(n,e){let i=e[n];return i===void 0?null:i}function Rs(n){return{type:n}}function $u(n){if(n instanceof ml)return new Set([n.key]);let e=new Set;return n.eachChild(i=>{e=new Set([...e,...$u(i)])}),e}function Hu(n){if(n instanceof ur&&n.name==="is-active-floor")return!0;let e=!1;return n.eachChild(i=>{!e&&Hu(i)&&(e=!0)}),e}function Pf(n){return{result:"success",value:n}}function zs(n){return{result:"error",value:n}}function gd(n,e){return!!n&&!!n.parameters&&n.parameters.includes(e)}function qu(n){return n["property-type"]==="data-driven"}function Df(n){return gd(n.expression,"measure-light")}function Rf(n){return gd(n.expression,"zoom")}function yd(n){return!!n.expression&&n.expression.interpolated}function xd(n){return typeof n=="object"&&n!==null&&!Array.isArray(n)}function eg(n){return n}function zf(n,e){let i=e.type==="color",r=n.stops&&typeof n.stops[0][0]=="object",s=r||!(r||n.property!==void 0),l=n.type||(yd(e)?"exponential":"interval");if(i&&((n=Object.assign({},n)).stops&&(n.stops=n.stops.map(g=>[g[0],jt.parse(g[1])])),n.default=jt.parse(n.default?n.default:e.default)),n.colorSpace&&n.colorSpace!=="rgb"&&!cd[n.colorSpace])throw new Error(`Unknown color space: ${n.colorSpace}`);let u,p,f;if(l==="exponential")u=Dc;else if(l==="interval")u=vd;else if(l==="categorical"){u=tg,p=Object.create(null);for(let g of n.stops)p[g[0]]=g[1];f=typeof n.stops[0][0]}else{if(l!=="identity")throw new Error(`Unknown function type "${l}"`);u=Lf}if(r){let g={},x=[];for(let S=0;S<n.stops.length;S++){let E=n.stops[S],M=E[0].zoom;g[M]===void 0&&(g[M]={zoom:M,type:n.type,property:n.property,default:n.default,stops:[]},x.push(M)),g[M].stops.push([E[0].value,E[1]])}let b=[];
1for(let S of x)b.push([g[S].zoom,zf(g[S],e)]);let w={name:"linear"};return{kind:"composite",interpolationType:w,interpolationFactor:Tr.interpolationFactor.bind(void 0,w),zoomStops:b.map(S=>S[0]),evaluate:({zoom:S},E)=>Dc({stops:b,base:n.base},e,S).evaluate(S,E)}}if(s){let g=l==="exponential"?{name:"exponential",base:n.base!==void 0?n.base:1}:null;return{kind:"camera",interpolationType:g,interpolationFactor:Tr.interpolationFactor.bind(void 0,g),zoomStops:n.stops.map(x=>x[0]),evaluate:({zoom:x})=>u(n,e,x,p,f)}}return{kind:"source",evaluate(g,x){let b=x&&x.properties?x.properties[n.property]:void 0;return b===void 0?Pc(n.default,e.default):u(n,e,b,p,f)}}}function Pc(n,e,i){return n!==void 0?n:e!==void 0?e:i!==void 0?i:void 0}function tg(n,e,i,r,s){return Pc(typeof i===s?r[i]:void 0,n.default,e.default)}function vd(n,e,i){if(!xc(i))return Pc(n.default,e.default);let r=n.stops.length;if(r===1||i<=n.stops[0][0])return n.stops[0][1];if(i>=n.stops[r-1][0])return n.stops[r-1][1];let s=_l(n.stops.map(l=>l[0]),i);return n.stops[s][1]}function Dc(n,e,i){let r=n.base!==void 0?n.base:1;if(!xc(i))return Pc(n.default,e.default);let s=n.stops.length;if(s===1||i<=n.stops[0][0])return n.stops[0][1];if(i>=n.stops[s-1][0])return n.stops[s-1][1];let l=_l(n.stops.map(x=>x[0]),i),u=function(x,b,w,S){let E=S-w,M=x-w;return E===0?0:b===1?M/E:(Math.pow(b,M)-1)/(Math.pow(b,E)-1)}(i,r,n.stops[l][0],n.stops[l+1][0]),p=n.stops[l][1],f=n.stops[l+1][1],g=vu[e.type]||eg;if(n.colorSpace&&n.colorSpace!=="rgb"){let x=cd[n.colorSpace];g=(b,w)=>x.reverse(x.interpolate(x.forward(b),x.forward(w),u))}return typeof p.evaluate=="function"?{evaluate(...x){let b=p.evaluate.apply(void 0,x),w=f.evaluate.apply(void 0,x);if(b!==void 0&&w!==void 0)return g(b,w,u)}}:g(p,f,u)}function Lf(n,e,i){return e.type==="color"?i=jt.parse(i):e.type==="formatted"?i=kn.fromString(i.toString()):e.type==="resolvedImage"?i=cr.build(i.toString()):Iu(i)===e.type||e.type==="enum"&&e.values[i]||(i=void 0),Pc(i,n.default,e.default)}ur.register(vl,{error:[{kind:"error"},[Kt],(n,[e])=>{throw new sn(e.evaluate(n))}],typeof:[Kt,[qt],(n,[e])=>on(vn(e.evaluate(n)))],"to-rgba":[Yn(st,4),[rn],(n,[e])=>e.evaluate(n).toNonPremultipliedRenderColor(null).toArray()],"to-hsla":[Yn(st,4),[rn],(n,[e])=>e.evaluate(n).toNonPremultipliedRenderColor(null).toHslaArray()],rgb:[rn,[st,st,st],Af],rgba:[rn,[st,st,st,st],Af],hsl:[rn,[st,st,st],Mf],hsla:[rn,[st,st,st,st],Mf],has:{type:ni,overloads:[[[Kt],(n,[e])=>Cf(e.evaluate(n),n.properties())],[[Kt,xa],(n,[e,i])=>Cf(e.evaluate(n),i.evaluate(n))]]},get:{type:qt,overloads:[[[Kt],(n,[e])=>_d(e.evaluate(n),n.properties())],[[Kt,xa],(n,[e,i])=>_d(e.evaluate(n),i.evaluate(n))]]},"feature-state":[qt,[Kt],(n,[e])=>_d(e.evaluate(n),n.featureState||{})],properties:[xa,[],n=>n.properties()],"geometry-type":[Kt,[],n=>n.geometryType()],worldview:[Kt,[],n=>n.globals.worldview||""],"is-active-floor":[ni,Rs(Kt),(n,e)=>{if(!(n.globals&&n.globals.activeFloors&&n.globals.activeFloors.size>0))return!1;if(e.length===0)return!0;let i=n.globals.activeFloors;return e.some(r=>{let s=r.evaluate(n);return i.has(s)})}],id:[qt,[],n=>n.id()],zoom:[st,[],n=>n.globals.zoom],pitch:[st,[],n=>n.globals.pitch||0],"distance-from-center":[st,[],n=>n.distanceFromCenter()],"measure-light":[st,[Kt],(n,[e])=>n.measureLight(e.evaluate(n))],"heatmap-density":[st,[],n=>n.globals.heatmapDensity||0],"line-progress":[st,[],n=>n.globals.lineProgress||0],"raster-value":[st,[],n=>n.globals.rasterValue||0],"raster-particle-speed":[st,[],n=>n.globals.rasterParticleSpeed||0],"sky-radial-progress":[st,[],n=>n.globals.skyRadialProgress||0],accumulated:[qt,[],n=>n.globals.accumulated===void 0?null:n.globals.accumulated],"+":[st,Rs(st),(n,e)=>{let i=0;for(let r of e)i+=r.evaluate(n);return i}],"*":[st,Rs(st),(n,e)=>{let i=1;for(let r of e)i*=r.evaluate(n);return i}],"-":{type:st,overloads:[[[st,st],(n,[e,i])=>e.evaluate(n)-i.evaluate(n)],[[st],(n,[e])=>-e.evaluate(n)]]},"/":[st,[st,st],(n,[e,i])=>e.evaluate(n)/i.evaluate(n)],"%":[st,[st,st],(n,[e,i])=>e.evaluate(n)%i.evaluate(n)],ln2:[st,[],()=>Math.LN2],pi:[st,[],()=>Math.PI],e:[st,[],()=>
1Math.E],"^":[st,[st,st],(n,[e,i])=>Math.pow(e.evaluate(n),i.evaluate(n))],sqrt:[st,[st],(n,[e])=>Math.sqrt(e.evaluate(n))],log10:[st,[st],(n,[e])=>Math.log(e.evaluate(n))/Math.LN10],ln:[st,[st],(n,[e])=>Math.log(e.evaluate(n))],log2:[st,[st],(n,[e])=>Math.log2(e.evaluate(n))],sin:[st,[st],(n,[e])=>Math.sin(e.evaluate(n))],cos:[st,[st],(n,[e])=>Math.cos(e.evaluate(n))],tan:[st,[st],(n,[e])=>Math.tan(e.evaluate(n))],asin:[st,[st],(n,[e])=>Math.asin(e.evaluate(n))],acos:[st,[st],(n,[e])=>Math.acos(e.evaluate(n))],atan:[st,[st],(n,[e])=>Math.atan(e.evaluate(n))],min:[st,Rs(st),(n,e)=>Math.min(...e.map(i=>i.evaluate(n)))],max:[st,Rs(st),(n,e)=>Math.max(...e.map(i=>i.evaluate(n)))],abs:[st,[st],(n,[e])=>Math.abs(e.evaluate(n))],round:[st,[st],(n,[e])=>{let i=e.evaluate(n);return i<0?-Math.round(-i):Math.round(i)}],floor:[st,[st],(n,[e])=>Math.floor(e.evaluate(n))],ceil:[st,[st],(n,[e])=>Math.ceil(e.evaluate(n))],"filter-==":[ni,[Kt,qt],(n,[e,i])=>n.properties()[e.value]===i.value],"filter-id-==":[ni,[qt],(n,[e])=>n.id()===e.value],"filter-type-==":[ni,[Kt],(n,[e])=>n.geometryType()===e.value],"filter-<":[ni,[Kt,qt],(n,[e,i])=>{let r=n.properties()[e.value],s=i.value;return typeof r==typeof s&&r<s}],"filter-id-<":[ni,[qt],(n,[e])=>{let i=n.id(),r=e.value;return typeof i==typeof r&&i<r}],"filter->":[ni,[Kt,qt],(n,[e,i])=>{let r=n.properties()[e.value],s=i.value;return typeof r==typeof s&&r>s}],"filter-id->":[ni,[qt],(n,[e])=>{let i=n.id(),r=e.value;return typeof i==typeof r&&i>r}],"filter-<=":[ni,[Kt,qt],(n,[e,i])=>{let r=n.properties()[e.value],s=i.value;return typeof r==typeof s&&r<=s}],"filter-id-<=":[ni,[qt],(n,[e])=>{let i=n.id(),r=e.value;return typeof i==typeof r&&i<=r}],"filter->=":[ni,[Kt,qt],(n,[e,i])=>{let r=n.properties()[e.value],s=i.value;return typeof r==typeof s&&r>=s}],"filter-id->=":[ni,[qt],(n,[e])=>{let i=n.id(),r=e.value;return typeof i==typeof r&&i>=r}],"filter-has":[ni,[qt],(n,[e])=>e.value in n.properties()],"filter-has-id":[ni,[],n=>n.id()!==null&&n.id()!==void 0],"filter-type-in":[ni,[Yn(Kt)],(n,[e])=>e.value.includes(n.geometryType())],"filter-id-in":[ni,[Yn(qt)],(n,[e])=>e.value.includes(n.id())],"filter-in-small":[ni,[Kt,Yn(qt)],(n,[e,i])=>i.value.includes(n.properties()[e.value])],"filter-in-large":[ni,[Kt,Yn(qt)],(n,[e,i])=>function(r,s,l,u){for(;l<=u;){let p=l+u>>1;if(s[p]===r)return!0;s[p]>r?u=p-1:l=p+1}return!1}(n.properties()[e.value],i.value,0,i.value.length-1)],all:{type:ni,overloads:[[[ni,ni],(n,[e,i])=>e.evaluate(n)&&i.evaluate(n)],[Rs(ni),(n,e)=>{for(let i of e)if(!i.evaluate(n))return!1;return!0}]]},any:{type:ni,overloads:[[[ni,ni],(n,[e,i])=>e.evaluate(n)||i.evaluate(n)],[Rs(ni),(n,e)=>{for(let i of e)if(i.evaluate(n))return!0;return!1}]]},"!":[ni,[ni],(n,[e])=>!e.evaluate(n)],"is-supported-script":[ni,[Kt],(n,[e])=>{let i=n.globals&&n.globals.isSupportedScript;return!i||i(e.evaluate(n))}],upcase:[Kt,[Kt],(n,[e])=>e.evaluate(n).toUpperCase()],downcase:[Kt,[Kt],(n,[e])=>e.evaluate(n).toLowerCase()],concat:[Kt,Rs(qt),(n,e)=>e.map(i=>vr(i.evaluate(n))).join("")],"resolved-locale":[Kt,[bu],(n,[e])=>e.evaluate(n).resolvedLocale()],random:[st,[st,st,qt],(n,e)=>{let[i,r,s]=e.map(u=>u.evaluate(n));if(i>r||i===r)return i;let l;if(typeof s=="string")l=function(u){let p=0;if(u.length===0)return p;for(let f=0;f<u.length;f++)p=(p<<5)-p+u.charCodeAt(f),p&=p;return p}(s);else{if(typeof s!="number")throw new sn(`Invalid seed input: ${s}`);l=s}return i+md(l)()*(r-i)}]});class bd{constructor(e,i,r,s,l){this.expression=e,this._warningHistory={},this._scope=r,this._options=s,this._iconImageUseTheme=l,this._evaluator=new eo(r,s,l),this._defaultValue=i?function(u){return u.type==="color"&&(xd(u.default)||Array.isArray(u.default))?new jt(0,0,0,0):u.type==="color"?jt.parse(u.default)||null:u.default===void 0?null:u.default}(i):null,this._enumValues=i&&i.type==="enum"?i.values:null,this.configDependencies=$u(e),this.isIndoorDependent=Hu(e)}evaluateWithoutErrorHandling(e,i,r,s,l,u,p,f){return this._evaluator.globals=e,this._evaluator.feature=i,this._evaluator.featureState=r,this._evaluator.canonical=s||null,this._evaluator.availableImages=l||null,this._evaluator.formattedSection=u,this._evaluator.featureTileCoord=p||null,this._evaluator.featureDistanceData=f||null,this.expression.evaluate(this._evaluator)}evaluate(e,i,r,s,l,u,p,f,g){this._evaluator||(this._evaluator=new eo(this._scope,this._options,this._iconImageUseTheme)),this._evaluator.globals=e,this._evaluator.feature=i||null,this._evaluator.featureState=r||null,this._evaluator.canonical=s||null,this._evaluator.availableImages=l||null,this._evaluator.formattedSection=u||null,this._evaluator.featureTileCoord=p||null,this._evaluator.featureDistanceData=f||null,this._evaluator.iconImageUseTheme=g||null;try{let x=this.expression.evaluate(this._evaluator);if(x==null||typeof x=="number"&&x!=x)return this._defaultValue;if(this._enumValues&&!(x in this._enumValues))throw new sn(`Expected value to be one of ${Object.keys(this._enumValues).map(b=>JSON.stringify(b)).join(", ")}, but found ${JSON.stringify(x)} instead.`);return x}catch(x){let b=x;return this._warningHistory[b.message]||(this._warningHistory[b.message]=!0,typeof console<"u"&&console.warn(`Failed to evaluate expression "${JSON.stringify(this.expression.serialize())}". ${b.message}`)),this._defaultValue}}}function Zu(n){return Array.isArray(n)&&n.length>0&&typeof n[0]=="string"&&n[0]in vl}function Pa(n,e,i,r,s){let l=new Ec(vl,[],e?function(p){let f={color:rn,string:Kt,number:st,enum:Kt,boolean:ni,formatted:Yo,resolvedImage:sl};return p.type==="array"?Yn(f[p.value]||qt,p.length):f[p.type]}(e):void 0,void 0,void 0,i,r,s),u=l.parse(n,void 0,void 0,void 0,e&&e.type==="string"?{typeAnnotation:"coerce"}:void 0);return u?Pf(new bd(u,e,i,r,s)):zs(l.errors)}
1class Rc{constructor(e,i,r,s){this.kind=e,this._styleExpression=i,this.isLightConstant=r,this.isLineProgressConstant=s,this.isStateDependent=e!=="constant"&&!fl(i.expression),this.configDependencies=$u(i.expression),this.isIndoorDependent=Hu(i.expression)}evaluateWithoutErrorHandling(e,i,r,s,l,u){return this._styleExpression.evaluateWithoutErrorHandling(e,i,r,s,l,u)}evaluate(e,i,r,s,l,u,p){return this._styleExpression.evaluate(e,i,r,s,l,u,void 0,void 0,p)}}class bl{constructor(e,i,r,s,l,u){this.kind=e,this.zoomStops=r,this._styleExpression=i,this.isStateDependent=e!=="camera"&&!fl(i.expression),this.isIndoorDependent=Hu(i.expression),this.isLightConstant=l,this.isLineProgressConstant=u,this.configDependencies=$u(i.expression),this.interpolationType=s}evaluateWithoutErrorHandling(e,i,r,s,l,u){return this._styleExpression.evaluateWithoutErrorHandling(e,i,r,s,l,u)}evaluate(e,i,r,s,l,u){return this._styleExpression.evaluate(e,i,r,s,l,u)}interpolationFactor(e,i,r){return this.interpolationType?Tr.interpolationFactor(this.interpolationType,e,i,r):0}}function Da(n,e,i,r,s){if((n=Pa(n,e,i,r,s)).result==="error")return n;let l=n.value.expression,u=Ma(l);if(!u&&!qu(e))return zs([new yo("","data expressions not supported")]);let p=tr(l,["zoom","pitch","distance-from-center"]);if(!p&&!Rf(e))return zs([new yo("","zoom expressions not supported")]);let f=tr(l,["measure-light"]);if(!f&&!Df(e))return zs([new yo("","measure-light expression not supported")]);let g=tr(l,["line-progress"]);if(!g&&!function(w){return gd(w.expression,"line-progress")}(e))return zs([new yo("","line-progress expression not supported")]);let x=e.expression&&e.expression.relaxZoomRestriction,b=Wu(l);return b||p||x?b instanceof yo?zs([b]):b instanceof Tr&&!yd(e)?zs([new yo("",'"interpolate" expressions cannot be used with this property')]):Pf(b?new bl(u&&g?"camera":"composite",n.value,b.labels,b instanceof Tr?b.interpolation:void 0,f,g):new Rc(u&&g?"constant":"source",n.value,f,g)):zs([new yo("",'"zoom" expression may only be used as input to a top-level "step" or "interpolate" expression, or in the properties of atmosphere.')])}class zc{constructor(e,i){this._parameters=e,this._specification=i,Object.assign(this,zf(this._parameters,this._specification))}static deserialize(e){return new zc(e._parameters,e._specification)}static serialize(e){return{_parameters:e._parameters,_specification:e._specification}}}function Wu(n){let e=null;if(n instanceof Vu)e=Wu(n.result);else if(n instanceof Uu){for(let i of n.args)if(e=Wu(i),e)break}else(n instanceof gl||n instanceof Tr)&&n.input instanceof ur&&n.input.name==="zoom"&&(e=n);return e instanceof yo||n.eachChild(i=>{let r=Wu(i);r instanceof yo?e=r:e&&r&&e!==r&&(e=new yo("",'Only one zoom-based "step" or "interpolate" subexpression may be used in an expression.'))}),e}class Ra{constructor(e,i,r){if(this.boxSeen=new Uint32Array(0),this.circleSeen=new Uint32Array(0),this.generation=0,e instanceof ArrayBuffer){let s=new Int32Array(e);this.width=s[0],this.height=s[1],this.xCellCount=s[2],this.yCellCount=s[3],this.boxUid=s[4],this.circleUid=s[5];let l=this.xCellCount*this.yCellCount,u=[];for(let x=0;x<l;x++){let b=s[6+x],w=s[6+x+1];u.push(b===w?null:s.subarray(b,w))}let p=s[6+l],f=[];for(let x=0;x<l;x++){let b=s[p+x],w=s[p+x+1];f.push(b===w?null:s.subarray(b,w))}let g=s[p+l];this.boxCells=u,this.circleCells=f,this.boxKeys=s.subarray(g,g+this.boxUid),g+=this.boxUid,this.circleKeys=s.subarray(g,g+this.circleUid),g+=this.circleUid,this.bboxes=s.subarray(g,g+4*this.boxUid),g+=4*this.boxUid,this.circles=s.subarray(g,g+3*this.circleUid)}else{this.width=e,this.height=i,this.xCellCount=Math.ceil(e/r),this.yCellCount=Math.ceil(i/r);let s=this.xCellCount*this.yCellCount,l=[],u=[];for(let p=0;p<s;p++)l.push([]),u.push([]);this.boxCells=l,this.circleCells=u,this.boxKeys=[],this.circleKeys=[],this.bboxes=[],this.circles=[],this.boxUid=0,this.circleUid=0}this.xScale=this.xCellCount/this.width,this.yScale=this.yCellCount/this.height}keysLength(){return this.boxKeys.length+this.circleKeys.length}insert(e,i,r,s,l){let u=this.boxUid++,p=this._xCell(i),f=this._yCell(r),g=this._xCell(s),x=this._yCell(l);for(let b=p;b<=g;b++)for(let w=f;w<=x;w++)this.boxCells[this.xCellCount*w+b].push(u);this.boxKeys.push(e),this.bboxes.push(i,r,s,l)}
1insertCircle(e,i,r,s){let l=this.circleUid++,u=this._xCell(i-s),p=this._yCell(r-s),f=this._xCell(i+s),g=this._yCell(r+s);for(let x=u;x<=f;x++)for(let b=p;b<=g;b++)this.circleCells[this.xCellCount*b+x].push(l);this.circleKeys.push(e),this.circles.push(i,r,s)}query(e,i,r,s,l){let u=[];if(r<0||e>this.width||s<0||i>this.height)return u;let p=this._nextGen(),{boxCells:f,circleCells:g,boxKeys:x,circleKeys:b,bboxes:w,circles:S,boxSeen:E,circleSeen:M,xCellCount:C}=this,R=this._xCell(e),F=this._yCell(i),z=this._xCell(r),j=this._yCell(s);for(let $=R;$<=z;$++)for(let H=F;H<=j;H++){let ie=C*H+$,W=f[ie];if(W)for(let Y=0;Y<W.length;Y++){let ee=W[Y];if(E[ee]===p)continue;E[ee]=p;let me=4*ee,ge=w[me],Te=w[me+1],Ae=w[me+2],Ee=w[me+3];e<=Ae&&i<=Ee&&r>=ge&&s>=Te&&(!l||l(x[ee]))&&u.push({key:x[ee],x1:ge,y1:Te,x2:Ae,y2:Ee})}let Q=g[ie];if(Q)for(let Y=0;Y<Q.length;Y++){let ee=Q[Y];if(M[ee]===p)continue;M[ee]=p;let me=3*ee,ge=S[me],Te=S[me+1],Ae=S[me+2];!this._circleAndRectCollide(ge,Te,Ae,e,i,r,s)||l&&!l(b[ee])||u.push({key:b[ee],x1:ge-Ae,y1:Te-Ae,x2:ge+Ae,y2:Te+Ae})}}return u}queryKeys(e,i,r,s,l){let u=[];if(r<0||e>this.width||s<0||i>this.height)return u;let p=this._nextGen(),{boxCells:f,boxKeys:g,bboxes:x,boxSeen:b,xCellCount:w,xScale:S,yScale:E}=this,M=this._xCell(e),C=this._yCell(i),R=this._xCell(r),F=this._yCell(s);for(let z=M;z<=R;z++)for(let j=C;j<=F;j++){if(l&&!l(z/S,j/E,(z+1)/S,(j+1)/E))continue;let $=f[w*j+z];if($)for(let H=0;H<$.length;H++){let ie=$[H];if(b[ie]===p)continue;b[ie]=p;let W=4*ie,Q=x[W],Y=x[W+1],ee=x[W+2],me=x[W+3];(l?l(Q,Y,ee,me):e<=ee&&i<=me&&r>=Q&&s>=Y)&&u.push(g[ie])}}return u}hitTest(e,i,r,s,l){if(r<0||e>this.width||s<0||i>this.height)return!1;let u=this._nextGen(),{boxCells:p,circleCells:f,boxKeys:g,circleKeys:x,bboxes:b,circles:w,boxSeen:S,circleSeen:E,xCellCount:M}=this,C=this._xCell(e),R=this._yCell(i),F=this._xCell(r),z=this._yCell(s);for(let j=C;j<=F;j++)for(let $=R;$<=z;$++){let H=M*$+j,ie=p[H];if(ie)for(let Q=0;Q<ie.length;Q++){let Y=ie[Q];if(S[Y]===u)continue;S[Y]=u;let ee=4*Y;if(e<=b[ee+2]&&i<=b[ee+3]&&r>=b[ee]&&s>=b[ee+1]&&(!l||l(g[Y])))return!0}let W=f[H];if(W)for(let Q=0;Q<W.length;Q++){let Y=W[Q];if(E[Y]===u)continue;E[Y]=u;let ee=3*Y;if(this._circleAndRectCollide(w[ee],w[ee+1],w[ee+2],e,i,r,s)&&(!l||l(x[Y])))return!0}}return!1}hitTestCircle(e,i,r,s){let l=e-r,u=i-r,p=e+r,f=i+r;if(p<0||l>this.width||f<0||u>this.height)return!1;let g=this._nextGen(),{boxCells:x,circleCells:b,boxKeys:w,circleKeys:S,bboxes:E,circles:M,boxSeen:C,circleSeen:R,xCellCount:F}=this,z=this._xCell(l),j=this._yCell(u),$=this._xCell(p),H=this._yCell(f);for(let ie=z;ie<=$;ie++)for(let W=j;W<=H;W++){let Q=F*W+ie,Y=x[Q];if(Y)for(let me=0;me<Y.length;me++){let ge=Y[me];if(C[ge]===g)continue;C[ge]=g;let Te=4*ge;if(this._circleAndRectCollide(e,i,r,E[Te],E[Te+1],E[Te+2],E[Te+3])&&(!s||s(w[ge])))return!0}let ee=b[Q];if(ee)for(let me=0;me<ee.length;me++){let ge=ee[me];if(R[ge]===g)continue;R[ge]=g;let Te=3*ge;if(this._circlesCollide(M[Te],M[Te+1],M[Te+2],e,i,r)&&(!s||s(S[ge])))return!0}}return!1}static serialize(e,i){let r=e.toArrayBuffer();return i&&i.add(r),{buffer:r}}static deserialize(e){return new Ra(e.buffer)}toArrayBuffer(){let e=this.xCellCount*this.yCellCount,i=0,r=0;for(let p=0;p<e;p++)i+=this.boxCells[p].length,r+=this.circleCells[p].length;let s=new Int32Array(6+(e+1)+i+(e+1)+r+this.boxUid+this.circleUid+4*this.boxUid+3*this.circleUid);s[0]=this.width,s[1]=this.height,s[2]=this.xCellCount,s[3]=this.yCellCount,s[4]=this.boxUid,s[5]=this.circleUid;let l=6+(e+1);for(let p=0;p<e;p++){s[6+p]=l;let f=this.boxCells[p];s.set(f,l),l+=f.length}s[6+e]=l;let u=l;l+=e+1;for(let p=0;p<e;p++){s[u+p]=l;let f=this.circleCells[p];s.set(f,l),l+=f.length}return s[u+e]=l,s.set(this.boxKeys,l),l+=this.boxUid,s.set(this.circleKeys,l),l+=this.circleUid,s.set(this.bboxes,l),l+=4*this.boxUid,s.set(this.circles,l),s.buffer}_xCell(e){return Math.max(0,Math.min(this.xCellCount-1,Math.floor(e*this.xScale)))}_yCell(e){return Math.max(0,Math.min(this.yCellCount-1,Math.floor(e*this.yScale)))}_nextGen(){return this.boxSeen.length<this.boxUid&&(this.boxSeen=new Uint32Array(this.boxUid)),this.circleSeen.length<this.circleUid&&(this.circleSeen=new Uint32Array(this.circleUid)),this.generation=this.generation+1>>>0,this.generation===0&&(this.boxSeen.fill(0),this.circleSeen.fill(0),this.generation=1),this.generation}
1_circlesCollide(e,i,r,s,l,u){let p=s-e,f=l-i,g=r+u;return g*g>p*p+f*f}_circleAndRectCollide(e,i,r,s,l,u,p){let f=(u-s)/2,g=Math.abs(e-(s+f));if(g>f+r)return!1;let x=(p-l)/2,b=Math.abs(i-(l+x));if(b>x+r)return!1;if(g<=f||b<=x)return!0;let w=g-f,S=b-x;return w*w+S*S<=r*r}}let wl={};function Qe(n,e,i={}){Object.defineProperty(n,"_classRegistryKey",{value:e,writable:!1}),wl[e]={klass:n,omit:i.omit||[]}}Qe(Object,"Object"),Qe(Ra,"Grid"),delete ke.prototype.constructor,Qe(jt,"Color"),Qe(Error,"Error"),Qe(kn,"Formatted"),Qe(va,"FormattedSection"),Qe(Gh,"AJAXError"),Qe(cr,"ResolvedImage"),Qe(zc,"StylePropertyFunction"),Qe(bd,"StyleExpression",{omit:["_evaluator"]}),Qe(yr,"ImageId"),Qe(xr,"ImageVariant"),Qe(bl,"ZoomDependentExpression"),Qe(Rc,"ZoomConstantExpression"),Qe(ur,"CompoundExpression",{omit:["_evaluate"]});for(let n in vl)wl[vl[n]._classRegistryKey]||Qe(vl[n],`Expression${n}`);function Of(n){return n&&(n instanceof ArrayBuffer||n.constructor&&n.constructor.name==="ArrayBuffer")}function Ls(n,e){if(n===null)return null;let i=typeof n;if(i!=="object")return i==="bigint"?{$name:"BigInt",value:n.toString()}:n;if(Array.isArray(n)){let u=n.length,p=[];p.length=u;for(let f=0;f<u;f++)p[f]=Ls(n[f],e);return p}if(ArrayBuffer.isView(n))return e&&e.add(n.buffer),n;if(Of(n)||n instanceof ImageBitmap)return e&&e.add(n),n;if(n instanceof ImageData)return e&&e.add(n.data.buffer),n;if(n instanceof Map){let u={$name:"Map",entries:[]};for(let[p,f]of n.entries())u.entries.push(Ls(p),Ls(f,e));return u}if(n instanceof Set){let u={$name:"Set"},p=0;for(let f of n.values())u[++p]=Ls(f);return u}if(n instanceof Date||n instanceof RegExp||n instanceof Boolean||n instanceof Number||n instanceof String)return n;let r=n.constructor,s=r._classRegistryKey;if(!s)throw new Error(`Can't serialize object of unregistered class "${r.name}".`);let l=r.serialize?r.serialize(n,e):{};if(!r.serialize){let u=wl[s].omit,p=n;for(let f in p)Object.hasOwn(p,f)&&(u.includes(f)||(l[f]=Ls(p[f],e)));n instanceof Error&&(l.message=n.message)}if(l.$name)throw new Error("$name property is reserved for worker serialization logic.");return s!=="Object"&&(l.$name=s),l}function Ko(n){if(n===null||typeof n!="object")return n;if(Array.isArray(n)){for(let s=0;s<n.length;s++)n[s]=Ko(n[s]);return n}if(ArrayBuffer.isView(n)||Of(n)||n instanceof ImageBitmap||n instanceof ImageData||n instanceof Date||n instanceof RegExp||n instanceof Boolean||n instanceof Number||n instanceof String)return n;let e=n.$name||"Object";if(e==="Map"){let s=n.entries||[],l=new Map;for(let u=0;u<s.length;u+=2)l.set(Ko(s[u]),Ko(s[u+1]));return l}if(e==="Set"){let s=new Set;for(let l in n)l!=="$name"&&s.add(Ko(n[l]));return s}if(e==="BigInt")return BigInt(n.value);let{klass:i}=wl[e];if(!i)throw new Error(`Can't deserialize unregistered class "${e}".`);if(i.deserialize)return i.deserialize(n);let r=Object.create(i.prototype);for(let s in n)s!=="$name"&&(r[s]=Ko(n[s]));return r}let wd=n=>n>=1536&&n<=1791,Ff=n=>n>=1872&&n<=1919,Bf=n=>n>=2208&&n<=2303,kf=n=>n>=11904&&n<=12031,Td=n=>n>=12032&&n<=12255,Sd=n=>n>=12272&&n<=12287,za=n=>n>=12288&&n<=12351,Id=n=>n>=12352&&n<=12447,Lc=n=>n>=12448&&n<=12543,Nf=n=>n>=12544&&n<=12591,Uf=n=>n>=12704&&n<=12735,Ed=n=>n>=12736&&n<=12783,Ad=n=>n>=12784&&n<=12799,Vf=n=>n>=12800&&n<=13055,jf=n=>n>=13056&&n<=13311,Md=n=>n>=13312&&n<=19903,Cd=n=>n>=19968&&n<=40959,Oc=n=>n>=40960&&n<=42127,Gf=n=>n>=42128&&n<=42191,$f=n=>n>=44032&&n<=55215,Hf=n=>n>=63744&&n<=64255,Fc=n=>n>=64336&&n<=65023,qf=n=>n>=65040&&n<=65055,Pd=n=>n>=65072&&n<=65103,Dd=n=>n>=65104&&n<=65135,Xu=n=>n>=65136&&n<=65279,Rd=n=>n>=65280&&n<=65519;function Yu(n){for(let e of n)if(Ju(e.charCodeAt(0)))return!0;return!1}function ig(n){for(let e of n)if(!Zf(e.charCodeAt(0)))return!1;return!0}function Zf(n){return!(wd(n)||Ff(n)||Bf(n)||Fc(n)||Xu(n))}function Wf(n){return!(n<11904||!(Uf(n)||Nf(n)||Pd(n)||Hf(n)||jf(n)||kf(n)||Ed(n)||za(n)||Md(n)||Cd(n)||Vf(n)||Rd(n)||Id(n)||Sd(n)||Td(n)||Ad(n)||Lc(n)||qf(n)||Gf(n)||Oc(n)))}function Ju(n){return!(n!==746&&n!==747&&(n<4352||!(Uf(n)||Nf(n)||Pd(n)&&!(n>=65097&&n<=65103)||Hf(n)||jf(n)||kf(n)||Ed(n)||!(!za(n)||n>=12296&&n<=12305||n>=12308&&n<=12319||n===12336)||Md(n)||Cd(n)||Vf(n)||(e=>e>=12592&&e<=12687)(n)||(e=>e>=43360&&e<=43391)(n)||(e=>e>=55216&&e<=55295)(n)||(e=>e>
1=4352&&e<=4607)(n)||$f(n)||Id(n)||Sd(n)||(e=>e>=12688&&e<=12703)(n)||Td(n)||Ad(n)||Lc(n)&&n!==12540||!(!Rd(n)||n===65288||n===65289||n===65293||n>=65306&&n<=65310||n===65339||n===65341||n===65343||n>=65371&&n<=65503||n===65507||n>=65512&&n<=65519)||!(!Dd(n)||n>=65112&&n<=65118||n>=65123&&n<=65126)||(e=>e>=5120&&e<=5759)(n)||(e=>e>=6320&&e<=6399)(n)||qf(n)||(e=>e>=19904&&e<=19967)(n)||Oc(n)||Gf(n))))}function Xf(n){return n===12312||n===12313||n===12316||n===12540||n===12448}function Ku(n){return!(Ju(n)||function(e){return!!((i=>i>=128&&i<=255)(e)&&(e===167||e===169||e===174||e===177||e===188||e===189||e===190||e===215||e===247)||(i=>i>=8192&&i<=8303)(e)&&(e===8214||e===8224||e===8225||e===8240||e===8241||e===8251||e===8252||e===8258||e===8263||e===8264||e===8265||e===8273)||(i=>i>=8448&&i<=8527)(e)||(i=>i>=8528&&i<=8591)(e)||(i=>i>=8960&&i<=9215)(e)&&(e>=8960&&e<=8967||e>=8972&&e<=8991||e>=8996&&e<=9e3||e===9003||e>=9085&&e<=9114||e>=9150&&e<=9165||e===9167||e>=9169&&e<=9179||e>=9186&&e<=9215)||(i=>i>=9216&&i<=9279)(e)&&e!==9251||(i=>i>=9280&&i<=9311)(e)||(i=>i>=9312&&i<=9471)(e)||(i=>i>=9632&&i<=9727)(e)||(i=>i>=9728&&i<=9983)(e)&&!(e>=9754&&e<=9759)||(i=>i>=11008&&i<=11263)(e)&&(e>=11026&&e<=11055||e>=11088&&e<=11097||e>=11192&&e<=11243)||za(e)||Lc(e)||(i=>i>=57344&&i<=63743)(e)||Pd(e)||Dd(e)||Rd(e)||e===8734||e===8756||e===8757||e>=9984&&e<=10087||e>=10102&&e<=10131||e===65532||e===65533)}(n))}function zd(n){return wd(n)||Ff(n)||Bf(n)||Fc(n)||Xu(n)}function Ld(n){return n>=1424&&n<=2303||Fc(n)||Xu(n)}function ng(n,e){return!(!e&&Ld(n)||n>=2304&&n<=3583||n>=3840&&n<=4255||(i=>i>=6016&&i<=6143)(n))}function Os(n){for(let e of n)if(Ld(e.charCodeAt(0)))return!0;return!1}let Sr={unavailable:"unavailable",deferred:"deferred",loading:"loading",parsing:"parsing",parsed:"parsed",loaded:"loaded",error:"error"},Od=null,En=Sr.unavailable,Fs=null,Bc=function(n){n&&(En=Sr.error),Od&&Od(n)};function Qu(){Tl.fire(new Xo("pluginStateChange",{pluginStatus:En,pluginURL:Fs}))}let Tl=new ol,eh=function(){return En},Yf=function(){if(En!==Sr.deferred||!Fs)throw new Error("rtl-text-plugin cannot be downloaded unless a pluginURL is specified");En=Sr.loading,Qu(),Fs&&nl({url:Fs},n=>{n?Bc(n):(En=Sr.loaded,Qu())})},Qo={applyArabicShaping:null,processBidirectionalText:null,processStyledBidirectionalText:null,isLoaded:()=>En===Sr.loaded||Qo.applyArabicShaping!=null,isLoading:()=>En===Sr.loading,setState(n){En=n.pluginStatus,Fs=n.pluginURL},isParsing:()=>En===Sr.parsing,isParsed:()=>En===Sr.parsed,getPluginURL:()=>Fs},Fd=function(){Qo.isLoading()||Qo.isLoaded()||eh()!=="deferred"||Yf()};class Xt{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.activeFloors=i.activeFloors):(this.now=0,this.fadeDuration=0,this.transition={},this.pitch=0,this.brightness=0)}isSupportedScript(e){return function(i,r){for(let s of i)if(!ng(s.charCodeAt(0),r))return!1;return!0}(e,Qo.isLoaded())}}class Sl{constructor(e,i,r,s,l){this.property=e,this.value=i,this.expression=function(u,p,f,g,x){if(xd(u))return new zc(u,p);if(Zu(u)||Array.isArray(u)&&u.length>0){let b=Da(u,p,f,g,x);if(b.result==="error")throw new Error(b.value.map(w=>`${w.key}: ${w.message}`).join(", "));return b.value}{let b=u;return typeof u=="string"&&p.type==="color"&&(b=jt.parse(u)),{kind:"constant",configDependencies:new Set,isIndoorDependent:!1,evaluate:()=>b}}}(i===void 0?e.specification.default:i,e.specification,r,s,l)}isIndoorDependent(){return this.expression.isIndoorDependent}isDataDriven(){return this.expression.kind==="source"||this.expression.kind==="composite"}possiblyEvaluate(e,i,r,s){return this.property.possiblyEvaluate(this,e,i,r,s)}}class th{constructor(e,i,r,s){this.property=e,this.value=new Sl(e,void 0,i,r,s)}transitioned(e,i){return new kc(this.property,this.value,i,Object.assign({},e.transition,this.transition),e.now)}untransitioned(){return new kc(this.property,this.value,null,{},0)}}class Jf{constructor(e,i,r,s){this._properties=e,this._values=Object.create(e.defaultTransitionablePropertyValues),this._scope=i,this._options=r,this._iconImageUseTheme=s,this._isIndoorDependent=!1,this.configDependencies=new Set}getValue(e){return Ut(this._values[e].value.value)}setValue(e,i){Object.hasOwn(this._values,e)||(this._values[e]=new th(this._values[e].property,this._scope,this._options,this._iconImageUseTheme)),this._values[e].value=new Sl(this._values[e].property,i===null?void 0:Ut(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]),this._isIndoorDependent=this._isIndoorDependent||this._values[e].value.isIndoorDependent())}setTransitionOrValue(e,i){i&&(this._options=i);let r=this._properties.properties;if(e)for(let s in e){let l=e[s];if(s.endsWith("-transition")){let u=s.slice(0,-11);r[u]&&this.setTransition(u,l)}else Object.hasOwn(r,s)&&this.setValue(s,l)}}getTransition(e){return Ut(this._values[e].transition)}setTransition(e,i){Object.hasOwn(this._values,e)||(this._values[e]=new th(this._values[e].property)),this._values[e].transition=Ut(i)||void 0}serialize(){let e={};for(let i of Object.keys(this._values)){let r=this.getValue(i);r!==void 0&&(e[i]=r);let s=this.getTransition(i);s!==void 0&&(e[`${i}-transition`]=s)}return e}transitioned(e,i){let r=new Nc(this._properties);for(let s of Object.keys(this._values))r._values[s]=this._values[s].transitioned(e,i._values[s]);return r}untransitioned(){let e=new Nc(this._properties);for(let i of Object.keys(this._values))e._values[i]=this._values[i].untransitioned();return e}isIndoorDependent(){return this._isIndoorDependent}}class kc{constructor(e,i,r,s,l){let u=s.delay||0,p=s.duration||0;l=l||0,this.property=e,this.value=i,this.begin=l+u,this.end=this.begin+p,e.specification.transition&&(s.delay||s.duration)&&(this.prior=r)}possiblyEvaluate(e,i,r){let s=e.now||0,l=this.value.possiblyEvaluate(e,i,r),u=this.prior;if(u){if(s>this.end)return this.prior=null,l;if(this.value.isDataDriven())return this.prior=null,l;if(s<this.begin)return u.possiblyEvaluate(e,i,r);{let p=(s-this.begin)/(this.end-this.begin);return this.property.interpolate(u.possiblyEvaluate(e,i,r),l,le(p))}}return l}}class Nc{constructor(e){this._properties=e,this._values=Object.create(e.defaultTransitioningPropertyValues)}possiblyEvaluate(e,i,r){let s=new es(this._properties);for(let l of Object.keys(this._values))s._values[l]=this._values[l].possiblyEvaluate(e,i,r);return s}hasTransition(){for(let e of Object.keys(this._values))if(this._values[e].prior)return!0;return!1}}
1class Uc{constructor(e,i,r,s){this._properties=e,this._values=Object.create(e.defaultPropertyValues),this._scope=i,this._options=r,this._iconImageUseTheme=s,this._isIndoorDependent=!1,this.configDependencies=new Set}getValue(e){return Ut(this._values[e].value)}setValue(e,i){this._values[e]=new Sl(this._values[e].property,i===null?void 0:Ut(i),this._scope,this._options,this._iconImageUseTheme),this._values[e].expression.configDependencies&&(this.configDependencies=new Set([...this.configDependencies,...this._values[e].expression.configDependencies]),this._isIndoorDependent=this._isIndoorDependent||this._values[e].isIndoorDependent())}serialize(){let e={};for(let i of Object.keys(this._values)){let r=this.getValue(i);r!==void 0&&(e[i]=r)}return e}possiblyEvaluate(e,i,r,s){let l=new es(this._properties);for(let u of Object.keys(this._values))l._values[u]=this._values[u].possiblyEvaluate(e,i,r,s);return l}isIndoorDependent(){return this._isIndoorDependent}}class Bs{constructor(e,i,r,s){this.property=e,this.value=i,this.parameters=r,this.iconImageUseTheme=s}isConstant(){return this.value.kind==="constant"}constantOr(e){return this.value.kind==="constant"?this.value.value:e}evaluate(e,i,r,s,l){return this.property.evaluate(this.value,this.parameters,e,i,r,s,this.iconImageUseTheme,l)}}class es{constructor(e){this._properties=e,this._values=Object.create(e.defaultPossiblyEvaluatedValues)}get(e){return this._values[e]}}class qe{constructor(e){this.specification=e}possiblyEvaluate(e,i){return e.expression.evaluate(i)}interpolate(e,i,r){let s=vu[this.specification.type];return s?s(e,i,r):e}}class Ze{constructor(e,i){this.specification=e,this.overrides=i}possiblyEvaluate(e,i,r,s,l){return e.expression.kind==="constant"||e.expression.kind==="camera"?new Bs(this,{kind:"constant",value:e.expression.evaluate(i,null,{},r,s,void 0,l)},i):new Bs(this,e.expression,i,l)}interpolate(e,i,r){if(e.value.kind!=="constant"||i.value.kind!=="constant")return e;if(e.value.value===void 0||i.value.value===void 0)return new Bs(this,{kind:"constant",value:void 0},e.parameters);let s=vu[this.specification.type];return s?new Bs(this,{kind:"constant",value:s(e.value.value,i.value.value,r)},e.parameters):e}evaluate(e,i,r,s,l,u,p,f){return e.kind==="constant"?e.value:e.evaluate(i,r,s,l,u,f,p)}}class La{constructor(e){this.specification=e}possiblyEvaluate(e,i,r,s){return!!e.expression.evaluate(i,null,{},r,s)}interpolate(){return!1}}class wi{constructor(e){this.properties=e,this.defaultPropertyValues={},this.defaultTransitionablePropertyValues={},this.defaultTransitioningPropertyValues={},this.defaultPossiblyEvaluatedValues={},this.overridableProperties=[];let i=new Xt(0,{});for(let r in e){let s=e[r],l=s.specification;l&&l.overridable&&this.overridableProperties.push(r);let u=this.defaultPropertyValues[r]=new Sl(s,void 0),p=this.defaultTransitionablePropertyValues[r]=new th(s);this.defaultTransitioningPropertyValues[r]=p.untransitioned(),this.defaultPossiblyEvaluatedValues[r]=u.possiblyEvaluate(i)}}}Qe(Ze,"DataDrivenProperty"),Qe(qe,"DataConstantProperty"),Qe(La,"ColorRampProperty");var he=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"}}
1,"featureset":{"metadata":{"type":"*"},"selectors":{"type":"array","value":"selector"}},"selector":{"layer":{"type":"string"},"properties":{"type":"selectorProperty"},"featureNamespace":{"type":"string"},"_uniqueFeatureID":{"type":"boolean"}},"selectorProperty":{"*":{"type":"*"}},"model":{"type":"string"},"import":{"id":{"type":"string"},"url":{"type":"string"},"config":{"type":"config"},"data":{"type":"$root"},"color-theme":{"type":"colorTheme","optional":true}},"config":{"*":{"type":"*"}},"schema":{"*":{"type":"option"}},"option":{"default":{"type":"*","expression":{}},"type":{"type":"enum","values":{"string":1,"number":1,"boolean":1,"color":1}},"array":{"type":"boolean"},"minValue":{"type":"number"},"maxValue":{"type":"number"},"stepValue":{"type":"number"},"values":{"type":"array","value":"*"},"metadata":{"type":"*"}},"models":{"*":{"type":"model"}},"light-3d":{"id":{"type":"string"},"properties":{"type":"properties"},"type":{"type":"enum","values":{"ambient":{},"directional":{},"flat":{}}}},"properties":["properties_light_directional","properties_light_ambient","properties_light_flat"],"properties_light_directional":{"direction":{"type":"array","default":[210,30],"minimum":[0,0],"maximum":[360,90],"length":2,"value":"number","transition":true,"expression":{"interpolated":true,"parameters":["zoom"]}},"color":{"type":"color","default":"#ffffff","expression":{"interpolated":true,"parameters":["zoom"]},"use-theme":true,"transition":true},"intensity":{"type":"number","default":0.5,"minimum":0,"maximum":1,"expression":{"interpolated":true,"parameters":["zoom"]},"transition":true},"cast-shadows":{"type":"boolean","default":false},"shadow-quality":{"type":"number","default":1,"minimum":0,"maximum":1,"expression":{"parameters":["zoom"]}},"shadow-intensity":{"type":"number","default":1,"minimum":0,"maximum":1,"expression":{"interpolated":true,"parameters":["zoom"]},"transition":true},"shadow-draw-before-layer":{"type":"string"}},"properties_light_ambient":{"color":{"type":"color","default":"#ffffff","expression":{"interpolated":true,"parameters":["zoom"]},"use-theme":true,"transition":true},"intensity":{"type":"number","default":0.5,"minimum":0,"maximum":1,"expression":{"interpolated":true,"parameters":["zoom"]},"transition":true}},"properties_light_flat":{"anchor":{"type":"enum","default":"viewport","values":{"map":1,"viewport":1},"expression":{"parameters":["zoom"]}},"position":{"type":"array","default":[1.15,210,30],"length":3,"value":"number","transition":true,"expression":{"interpolated":true,"parameters":["zoom"]}},"color":{"type":"color","default":"#ffffff","expression":{"interpolated":true,"parameters":["zoom"]},"use-theme":true,"transition":true},"intensity":{"type":"number","default":0.5,"minimum":0,"maximum":1,"expression":{"interpolated":true,"parameters":["zoom"]},"transition":true}},"iconsets":{"*":{"type":"iconset"}},"iconset":["iconset_sprite","iconset_source"],"iconset_sprite":{"type":{"type":"enum","values":{"sprite":1}},"url":{"type":"string"}},"iconset_source":{"type":{"type":"enum","values":{"source":1}},"source":{"type":"string"}},"sources":{"*":{"type":"source"}},"source":["source_vector","source_raster","source_raster_dem","source_raster_array","source_geojson","source_video","source_image","source_model"],"source_vector":{"type":{"type":"enum","values":{"vector":1}},"url":{"type":"string"},"tiles":{"type":"array","value":"string"},"bounds":{"type":"array","value":"number","length":4,"default":[-180,-85.051129,180,85.051129]},"extra_bounds":{"type":"array","value":{"type":"array","value":"number","length":4}},"scheme":{"type":"enum","values":{"xyz":1,"tms":1},"default":"xyz"},"minzoom":{"type":"number","default":0},"maxzoom":{"type":"number","default":22},"attribution":{"type":"string"},"promoteId":{"type":"promoteId"},"volatile":{"type":"boolean","default":false},"*":{"type":"*"}},"source_raster":{"type":{"type":"enum","values":{"raster":1}},"url":{"type":"string"},"tiles":{"type":"array","value":"string"},"bounds":{"type":"array","value":"number","length":4,"default":[-180,-85.051129,180,85.051129]},"extra_bounds":{"type":"array","value":{"type":"array","value":"number","length":4}},"minzoom":{"type":"number","default":0},"maxzoom":{"type":"number","default":22},"tileSize":{"type":"number","default":512},"scheme":{"type":"enum","values":{"xyz":1,"tms":1},"default":"xyz"},"attribution":{"type":"string"},"volatile":{"type":"boolean","default":false},"*":{"type":"*"}},"source_raster_dem":{"type":{"type":"enum","values":{"raster-dem":1}},"url":{"type":"string"},"tiles":{"type":"array","value":"string"},"bounds":{"type":"array","value":"number","length":4,"default":[-180,-85.051129,180,85.051129]},"extra_bounds":{"type":"array","value":{"type":"array","value":"number","length":4}},"minzoom":{"type":"number","default":0},"maxzoom":{"type":"number","default":22},"tileSize":{"type":"number","default":512},"attribution":{"type":"string"},"encoding":{"type":"enum","values":{"terrarium":1,"mapbox":1},"default":"mapbox"},"volatile":{"type":"boolean","default":false},"*":{"type":"*"}},"source_raster_array":{"type":{"type":"enum","values":{"raster-array":1}},"url":{"type":"string"},"tiles":{"type":"array","value":"string"},"bounds":{"type":"array","value":"number","length":4,"default":[-180,-85.051129,180,85.051129]},"extra_bounds":{"type":"array","value":{"type":"array","value":"number","length":4}},"minzoom":{"type":"number","default":0},"maxzoom":{"type":"number","default":22},"tileSize":{"type":"number","default":512},"attribution":{"type":"string"},"rasterLayers":{"type":"*"},"volatile":{"type":"boolean","default":false},"*":{"type":"*"}},"source_geojson":{"type":{"type":"enum","values":{"geojson":1}},"data":{"type":"*"},"maxzoom":{"type":"number","default":18},"minzoom":{"type":"number","default":0},"attribution":{"type":"string"},"buffer":{"type":"number","default":128,"maximum":512,"minimum":0},"filter":{"type":"*"},"tolerance":{"type":"number","default":0.375},"cluster":{"type":"boolean","default":false},"clusterRadius":{"type":"number","default":50,"minimum":0}
1,"clusterMaxZoom":{"type":"number"},"clusterMinPoints":{"type":"number"},"clusterProperties":{"type":"*"},"lineMetrics":{"type":"boolean","default":false},"generateId":{"type":"boolean","default":false},"promoteId":{"type":"promoteId"},"dynamic":{"type":"boolean","default":false}},"source_video":{"type":{"type":"enum","values":{"video":1}},"urls":{"type":"array","value":"string"},"coordinates":{"type":"array","length":4,"value":{"type":"array","length":2,"value":"number"}}},"source_image":{"type":{"type":"enum","values":{"image":1}},"url":{"type":"string"},"coordinates":{"type":"array","length":4,"value":{"type":"array","length":2,"value":"number"}}},"modelNodeOverride":{"orientation":{"type":"array","value":"number","length":3,"default":[0,0,0],"period":360}},"modelNodeOverrides":{"*":{"type":"modelNodeOverride"}},"modelMaterialOverride":{"model-color":{"type":"color"},"model-color-mix-intensity":{"type":"number"},"model-opacity":{"type":"number"},"model-emissive-strength":{"type":"number"}},"modelMaterialOverrides":{"*":{"type":"modelMaterialOverride"}},"modelSourceModel":{"uri":{"type":"string"},"position":{"type":"array","value":"number","length":2,"default":[0,0],"minimum":[-180,-90],"maximum":[180,90]},"orientation":{"type":"array","value":"number","length":3,"default":[0,0,0],"period":360},"nodeOverrides":{"type":"modelNodeOverrides"},"materialOverrides":{"type":"modelMaterialOverrides"},"nodeOverrideNames":{"type":"array","value":"string"},"materialOverrideNames":{"type":"array","value":"string"},"featureProperties":{"type":"*"}},"modelSourceModels":{"*":{"type":"modelSourceModel"}},"source_model":{"type":{"type":"enum","values":{"model":1,"batched-model":1}},"url":{"type":"string"},"maxzoom":{"type":"number","default":18},"minzoom":{"type":"number","default":0},"tiles":{"type":"array","value":"string"},"models":{"type":"modelSourceModels"}},"layer":{"id":{"type":"string"},"type":{"type":"enum","values":{"fill":{},"line":{},"symbol":{},"circle":{},"heatmap":{},"fill-extrusion":{},"building":{},"raster":{},"raster-particle":{},"hillshade":{},"model":{},"background":{},"sky":{},"slot":{},"clip":{}}},"metadata":{"type":"*"},"source":{"type":"string"},"source-layer":{"type":"string"},"slot":{"type":"string"},"minzoom":{"type":"number","minimum":0,"maximum":24},"maxzoom":{"type":"number","minimum":0,"maximum":24},"filter":{"type":"filter"},"layout":{"type":"layout"},"paint":{"type":"paint"},"appearances":{"type":"array","value":"appearance","supported-layer-types":["symbol"]}},"appearance":{"condition":{"type":"boolean","expression":{"interpolated":true,"parameters":["zoom","pitch","feature","feature-state","measure-light","distance-from-center"]},"property-type":"data-driven"},"name":{"type":"string"},"properties":{"type":"*"}},"layout":["layout_clip","layout_fill","layout_line","layout_circle","layout_heatmap","layout_fill-extrusion","layout_building","layout_symbol","layout_raster","layout_raster-particle","layout_hillshade","layout_background","layout_sky","layout_model"],"layout_background":{"visibility":{"type":"enum","values":{"visible":1,"none":1},"default":"visible","expression":{}}},"layout_sky":{"visibility":{"type":"enum","values":{"visible":1,"none":1},"default":"visible","expression":{}}},"layout_model":{"visibility":{"type":"enum","values":{"visible":1,"none":1},"default":"visible","expression":{}},"model-id":{"type":"string","default":"","property-type":"data-driven","expression":{"parameters":["zoom","feature"]}},"model-allow-density-reduction":{"type":"boolean","default":true}},"layout_clip":{"clip-layer-types":{"type":"array","value":"enum","values":{"model":1,"symbol":1},"default":[],"expression":{}},"clip-layer-scope":{"type":"array","value":"string","default":[],"expression":{}},"visibility":{"type":"enum","values":{"visible":1,"none":1},"default":"visible","expression":{}}},"layout_fill":{"fill-sort-key":{"type":"number","expression":{"parameters":["zoom","feature"]},"property-type":"data-driven"},"visibility":{"type":"enum","values":{"visible":1,"none":1},"default":"visible","expression":{}},"fill-elevation-reference":{"type":"enum","values":{"none":1,"hd-road-base":1,"hd-road-markup":1},"default":"none","expression":{}},"fill-construct-bridge-guard-rail":{"type":"boolean","default":"true","expression":{"parameters":["zoom","feature"]},"property-type":"data-driven"}},"layout_circle":{"circle-sort-key":{"type":"number","expression":{"parameters":["zoom","feature"]},"property-type":"data-driven"},"circle-elevation-reference":{"type":"enum","values":{"none":1,"hd-road-markup":1},"default":"none","expression":{}},"visibility":{"type":"enum","values":{"visible":1,"none":1},"default":"visible","expression":{}}},"layout_heatmap":{"visibility":{"type":"enum","values":{"visible":1,"none":1},"default":"visible","expression":{}}},"layout_fill-extrusion":{"visibility":{"type":"enum","values":{"visible":1,"none":1},"default":"visible","expression":{}},"fill-extrusion-edge-radius":{"type":"number","default":0,"minimum":0,"maximum":1,"expression":{}},"source-max-zoom":{"type":"number","minimum":0,"maximum":24}},"layout_building":{"visibility":{"type":"enum","values":{"visible":1,"none":1},"default":"visible","expression":{}},"building-facade":{"type":"boolean","default":false,"expression":{"parameters":["feature"]},"property-type":"data-driven"},"building-facade-floors":{"type":"number","minimum":1,"maximum":200,"default":3,"property-type":"data-driven","expression":{"parameters":["feature"]}},"building-facade-unit-width":{"type":"number","minimum":1,"maximum":20,"default":3.1,"property-type":"data-driven","expression":{"parameters":["feature"]}},"building-facade-window":{"type":"array","length":2,"value":"number","minimum":0.1,"maximum":1,"default":[0.9,0.9],"property-type":"data-driven","expression":{"parameters":["feature"]}},"building-roof-shape":{"type":"enum","values":{"flat":1,"hipped":1,"gabled":1,"parapet":1,"mansard":1,"skillion":1,"pyramidal":1},"default":"flat","expression":{"parameters":["feature"]},"property-type":"data-driven"},"building-height":{"type":"number","default":0,"minimum":0,"transition":true,"expression":{},"property-type":"data-driven"},"building-base":{"type":"number","default":0,"minimum":0,"transition":true,"expression":{},"property-type":"data-driven"},"building-flood-light-wall-radius":{"property-type":"data-driven","type":"number","default":0,"minimum":0,"transition":true,"expression":{"interpolated":true,"parameters":["feature","feature-state"]}},"building-flood-light-ground-radius":{"property-type":"data-driven","type":"number","default":0,"transition":true,"expression":{"interpolated":true,"parameters":["feature","feature-state"]}},"building-flip-roof-orientation":{"property-type":"data-driven","type":"boolean","default":false,"transition":true,"expression":{"interpolated":true,"parameters":["feature","feature-state"]}}},"layout_line":{"line-cap":{"type":"enum","values":{"butt":1,"round":1,"square":1},"default":"butt","expression":{"parameters":["zoom","feature"]},"property-type":"data-driven"},"line-join":{"type":"enum","values":{"bevel":1,"round":1,"miter":1,"none":1},"default":"miter","expression":{"parameters":["zoom","feature"]},"property-type":"data-driven"},"line-miter-limit":{"type":"number","default":2,"expression":{"interpolated":true,"parameters":["zoom"]}},"line-round-limit":{"type":"number","default":1.05,"expression":{"interpolated":true,"parameters":["zoom"]}},"line-sort-key":{"type":"number","expression":{"parameters":["zoom","feature"]},"property-type":"data-driven"},"line-z-offset":{"type":"number","default":0,"expression":{"parameters":["zoom","feature","line-progress"]},"property-type":"data-driven"},"line-elevation-reference":{"type":"enum","values":{"none":1,"sea":1,"ground":1,"hd-road-markup":1},"default":"none","expression":{}},"line-cross-slope":{"type":"number","expression":{}},"visibility":{"type":"enum","values":{"visible":1,"none":1},"default":"visible","expression":{}},"line-width-unit":{"type":"enum","values":{"pixels":1,"meters":1},"default":"pixels","expression":{"parameters":["zoom"]}},"line-elevation-ground-scale":{"type":"number","default":0,"minimum":0,"maximum":1,"expression":{"interpolated":true,"parameters":["zoom","feature","line-progress"]},"transition":true,"property-type":"data-driven"}},"layout_symbol":{"symbol-placement":{"type":"enum","values":{"point":1,"line":1,"line-center":1},"default":"point","expression":{"parameters":["zoom"]}},"symbol-spacing":{"type":"number","default":250,"minimum":1,"expression":{"interpolated":true,"parameters":["zoom"]}},"symbol-avoid-edges":{"type":"boolean","default":false,"expression":{"parameters":["zoom"]}},"symbol-sort-key":{"type":"number","expression":{"parameters":["zoom","feature"]},"property-type":"data-driven"},"symbol-z-order":{"type":"enum","values":{"auto":1,"viewport-y":1,"source":1},"default":"auto","expression":{"parameters":["zoom"]}},"symbol-z-elevate":{"type":"boolean","default":false,"expression":{"parameters":["zoom"]}},"symbol-elevation-reference":{"type":"enum","values":{"sea":1,"ground":1,"hd-road-markup":1},"default":"ground","expression":{"parameters":["zoom"]}},"icon-allow-overlap":{"type":"boolean","default":false,"expression":{"parameters":["zoom"]}},"icon-ignore-placement":{"type":"boolean","default":false,"expression":{"parameters":["zoom"]}},"icon-optional":{"type":"boolean","default":false,"expression":{"parameters":["zoom"]}},"icon-rotation-alignment":{"type":"enum","values":{"map":1,"viewport":1,"auto":1},"default":"auto","expression":{"parameters":["zoom"]}},"icon-size":{"type":"number","default":1,"minimum":0,"appearance":true,"expression":{"interpolated":true,"parameters":["zoom","feature"]},"property-type":"data-driven"},"icon-size-scale-range":{"type":"array","value":"number","length":2,"default":[0.8,2],"minimum":[0.1,0.1],"maximum":[10,10],"expression":{}},"icon-text-fit":{"type":"enum","values":{"none":1,"width":1,"height":1,"both":1},"default":"none","expression":{"parameters":["zoom","feature"]},"property-type":"data-driven"},"icon-text-fit-padding":{"type":"array","value":"number","length":4,"default":[0,0,0,0],"expression":{"interpolated":true,"parameters":["zoom","feature"]},"property-type":"data-driven"},"icon-image":{"type":"resolvedImage","tokens":true,"appearance":true,"use-theme":true,"expression":{"parameters":["zoom","feature"]},"property-type":"data-driven"},"icon-rotate":{"type":"number","default":0,"period":360,"appearance":true,"expression":{"interpolated":true,"parameters":["zoom","feature"]},"property-type":"data-driven"},"icon-padding":{"type":"number","default":2,"minimum":0,"expression":{"interpolated":true,"parameters":["zoom"]}},"icon-keep-upright":{"type":"boolean","default":false,"expression":{"parameters":["zoom"]}},"icon-offset":{"type":"array","value":"number","length":2,"default":[0,0],"appearance":true,"expression":{"interpolated":true,"parameters":["zoom","feature"]},"property-type":"data-driven"}
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,"appearance":true,"expression":{"interpolated":true,"parameters":["zoom","feature"]},"property-type":"data-driven"},"text-size-scale-range":{"type":"array","value":"number","length":2,"default":[0.8,2],"minimum":[0.1,0.1],"maximum":[10,10],"expression":{}},"text-max-width":{"type":"number","default":10,"minimum":0,"expression":{"interpolated":true,"parameters":["zoom","feature"]},"property-type":"data-driven"},"text-line-height":{"type":"number","default":1.2,"expression":{"interpolated":true,"parameters":["zoom","feature"]},"property-type":"data-driven"},"text-letter-spacing":{"type":"number","default":0,"expression":{"interpolated":true,"parameters":["zoom","feature"]},"property-type":"data-driven"},"text-justify":{"type":"enum","values":{"auto":1,"left":1,"center":1,"right":1},"default":"center","expression":{"parameters":["zoom","feature"]},"property-type":"data-driven"},"text-radial-offset":{"type":"number","default":0,"property-type":"data-driven","expression":{"interpolated":true,"parameters":["zoom","feature"]}},"text-variable-anchor":{"type":"array","value":"enum","values":{"center":1,"left":1,"right":1,"top":1,"bottom":1,"top-left":1,"top-right":1,"bottom-left":1,"bottom-right":1},"expression":{"parameters":["zoom"]}},"text-anchor":{"type":"enum","values":{"center":1,"left":1,"right":1,"top":1,"bottom":1,"top-left":1,"top-right":1,"bottom-left":1,"bottom-right":1},"default":"center","expression":{"parameters":["zoom","feature"]},"property-type":"data-driven"},"text-max-angle":{"type":"number","default":45,"expression":{"interpolated":true,"parameters":["zoom"]}},"text-writing-mode":{"type":"array","value":"enum","values":{"horizontal":1,"vertical":1},"expression":{"parameters":["zoom"]}},"text-rotate":{"type":"number","default":0,"period":360,"appearance":true,"expression":{"interpolated":true,"parameters":["zoom","feature"]},"property-type":"data-driven"},"text-padding":{"type":"number","default":2,"minimum":0,"expression":{"interpolated":true,"parameters":["zoom"]}},"text-keep-upright":{"type":"boolean","default":true,"expression":{"parameters":["zoom"]}},"text-transform":{"type":"enum","values":{"none":1,"uppercase":1,"lowercase":1},"default":"none","expression":{"parameters":["zoom","feature"]},"property-type":"data-driven"},"text-offset":{"type":"array","value":"number","length":2,"default":[0,0],"appearance":true,"expression":{"interpolated":true,"parameters":["zoom","feature"]},"property-type":"data-driven"},"text-allow-overlap":{"type":"boolean","default":false,"expression":{"parameters":["zoom"]}},"text-ignore-placement":{"type":"boolean","default":false,"expression":{"parameters":["zoom"]}},"text-optional":{"type":"boolean","default":false,"expression":{"parameters":["zoom"]}},"visibility":{"type":"enum","values":{"visible":1,"none":1},"default":"visible","expression":{}}},"layout_raster":{"visibility":{"type":"enum","values":{"visible":1,"none":1},"default":"visible","expression":{}}},"layout_raster-particle":{"visibility":{"type":"enum","values":{"visible":1,"none":1},"default":"visible","expression":{}}},"layout_hillshade":{"visibility":{"type":"enum","values":{"visible":1,"none":1},"default":"visible","expression":{}}},"filter":{"type":"array","value":"*"},"filter_symbol":{"type":"boolean","default":false,"property-type":"data-driven","expression":{"parameters":["zoom","feature","pitch","distance-from-center"]}},"filter_fill":{"type":"boolean","default":false,"property-type":"data-driven","expression":{"parameters":["zoom","feature"]}},"filter_hillshade":{"type":"boolean","default":false,"property-type":"data-driven","expression":{"parameters":["zoom","feature"]}},"filter_raster":{"type":"boolean","default":false,"property-type":"data-driven","expression":{"parameters":["zoom","feature"]}},"filter_raster-particle":{"type":"boolean","default":false,"property-type":"data-driven","expression":{"parameters":["zoom","feature"]}},"filter_clip":{"type":"boolean","default":false,"property-type":"data-driven","expression":{"parameters":["zoom","feature"]}},"filter_model":{"type":"boolean","default":false,"property-type":"data-driven","expression":{"parameters":["zoom","feature"]}},"filter_line":{"type":"boolean","default":false,"property-type":"data-driven","expression":{"parameters":["zoom","feature"]}},"filter_circle":{"type":"boolean","default":false,"property-type":"data-driven","expression":{"parameters":["zoom","feature"]}},"filter_fill-extrusion":{"type":"boolean","default":false,"property-type":"data-driven","expression":{"parameters":["zoom","feature"]}},"filter_building":{"type":"boolean","default":false,"property-type":"data-driven","expression":{"parameters":["zoom","feature"]}},"filter_heatmap":{"type":"boolean","default":false,"property-type":"data-driven","expression":{"parameters":["zoom","feature"]}},"filter_operator":{"type":"enum","values":{"==":1,"!=":1,">":1,">=":1,"<":1,"<=":1,"in":1,"!in":1,"all":1,"any":1,"none":1,"has":1,"!has":1}},"geometry_type":{"type":"enum","values":{"Point":1,"LineString":1,"Polygon":1}},"function":{"expression":{"type":"expression"},"stops":{"type":"array","value":"function_stop"},"base":{"type":"number","default":1,"minimum":0},"property":{"type":"string","default":"$zoom"},"type":{"type":"enum","values":{"identity":1,"exponential":1,"interval":1,"categorical":1},"default":"exponential"},"colorSpace":{"type":"enum","values":{"rgb":1,"lab":1,"hcl":1},"default":"rgb"},"default":{"type":"*"}},"function_stop":{"type":"array","minimum":0,"maximum":24,"value":["number","color"],"length":2},"expression":{"type":"array","value":"*","minimum":1},"fog":{"range":{"type":"array","default":[0.5,10],"minimum":-20,"maximum":20,"length":2,"value":"number","transition":true,"expression":{"interpolated":true,"parameters":["zoom","measure-light"],"relaxZoomRestriction":true}},"color":{"type":"color","default":"#ffffff","expression":{"interpolated":true,"parameters":["zoom","measure-light"],"relaxZoomRestriction":true},"use-theme":true,"transition":true},"high-color":{"type":"color","default":"#245cdf","expression":{"interpolated":true,"parameters":["zoom","measure-light"],"relaxZoomRestriction":true},"use-theme":true,"transition":true},"space-color":{"type":"color","default":["interpolate",["linear"],["zoom"],4,"#010b19",7,"#367ab9"],"expression":{"interpolated":true,"parameters":["zoom","measure-light"],"relaxZoomRestriction":true},"use-theme":true,"transition":true},"horizon-blend":{"type":"number","default":["interpolate",["linear"],["zoom"],4,0.2,7,0.1],"minimum":0,"maximum":1,"expression":{"interpolated":true,"parameters":["zoom","measure-light"],"relaxZoomRestriction":true},"transition":true},"star-intensity":{"type":"number","default":["interpolate",["linear"],["zoom"],5,0.35,6,0],"minimum":0,"maximum":1,"expression":{"interpolated":true,"parameters":["zoom","measure-light"],"relaxZoomRestriction":true},"transition":true},"vertical-range":{"type":"array","default":[0,0],"minimum":0,"length":2,"value":"number","transition":true,"expression":{"interpolated":true,"parameters":["zoom","measure-light"],"relaxZoomRestriction":true}}},"snow":{"density":{"type":"number","default":["interpolate",["linear"],["zoom"],11,0,13,0.85],"minimum":0,"maximum":1,"expression":{"interpolated":true,"parameters":["zoom","measure-light"],"relaxZoomRestriction":true},"transition":true},"intensity":{"type":"number","default":1,"minimum":0,"maximum":1,"expression":{"interpolated":true,"parameters":["zoom","measure-light"],"relaxZoomRestriction":true},"transition":true},"color":{"type":"color","default":"#ffffff","expression":{"interpolated":true,"parameters":["zoom","measure-light"],"relaxZoomRestriction":true},"use-theme":true,"transition":true},"opacity":{"type":"number","default":1,"minimum":0,"maximum":1,"expression":{"interpolated":true,"parameters":["zoom","measure-light"],"relaxZoomRestriction":true},"transition":true},"vignette":{"type":"number","default":["interpolate",["linear"],["zoom"],11,0,13,0.3],"minimum":0,"maximum":1,"expression":{"interpolated":true,"parameters":["zoom","measure-light"],"relaxZoomRestriction":true},"transition":true},"vignette-color":{"type":"color","default":"#ffffff","expression":{"interpolated":true,"parameters":["zoom","measure-light"],"relaxZoomRestriction":true},"use-theme":true,"transition":true},"center-thinning":{"type":"number","default":0.4,"minimum":0,"maximum":1,"expression":{"interpolated":true,"parameters":["zoom","measure-light"],"relaxZoomRestriction":true},"transition":true},"direction":{"type":"array","default":[0,50],"minimum":0,"maximum":360,"length":2,"value":"number","transition":true,"expression":{"interpolated":true,"parameters":["zoom","measure-light"],"relaxZoomRestriction":true}},"flake-size":{"type":"number","default":0.71,"minimum":0,"maximum":5,"expression":{"interpolated":true,"parameters":["zoom","measure-light"],"relaxZoomRestriction":true},"transition":true}},"rain":{"density":{"type":"number","default":["interpolate",["linear"],["zoom"],11,0,13,0.5],"minimum":0,"maximum":1,"expression":{"interpolated":true,"parameters":["zoom","measure-light"],"relaxZoomRestriction":true},"transition":true},"intensity":{"type":"number","default":1,"minimum":0,"maximum":1,"expression":{"interpolated":true,"parameters":["zoom","measure-light"],"relaxZoomRestriction":true},"transition":true},"color":{"type":"color","default":["interpolate",["linear"],["measure-light","brightness"],0,"#03113d",0.3,"#a8adbc"],"expression":{"interpolated":true,"parameters":["zoom","measure-light"],"relaxZoomRestriction":true},"use-theme":true,"transition":true},"opacity":{"type":"number","default":["interpolate",["linear"],["measure-light","brightness"],0,0.88,1,0.7],"minimum":0,"maximum":1,"expression":{"interpolated":true,"parameters":["zoom","measure-light"],"relaxZoomRestriction":true},"transition":true},"vignette":{"type":"number","default":["interpolate",["linear"],["zoom"],11,0,13,1],"minimum":0,"maximum":1,"expression":{"interpolated":true,"parameters":["zoom","measure-light"],"relaxZoomRestriction":true},"transition":true},"vignette-color":{"type":"color","default":["interpolate",["linear"],["measure-light","brightness"],0,"#001736",0.3,"#464646"],"expression":{"interpolated":true,"parameters":["zoom","measure-light"],"relaxZoomRestriction":true},"use-theme":true,"transition":true},"center-thinning":{"type":"number","default":0.57,"minimum":0,"maximum":1,"expression":{"interpolated":true,"parameters":["zoom","measure-light"],"relaxZoomRestriction":true},"transition":true},"direction":{"type":"array","default":[0,80],"minimum":0,"maximum":360,"length":2,"value":"number","transition":true,"expression":{"interpolated":true,"parameters":["zoom","measure-light"],"relaxZoomRestriction":true}},"droplet-size":{"type":"array","default":[2.6,18.2],"minimum":0,"maximum":50,"length":2,"value":"number","transition":true,"expression":{"interpolated":true,"parameters":["zoom","measure-light"],"relaxZoomRestriction":true}},"distortion-strength":{"type":"number","default":0.7,"minimum":0,"maximum":1,"expression":{"interpolated":true,"parameters":["zoom","measure-light"],"relaxZoomRestriction":true},"transition":true}},"camera":{"camera-projection":{"type":"enum","values":{"perspective":1,"orthographic":1},"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]},"default":"perspective"}},"colorTheme":{"data":{"type":"string","expression":{}}},"indoor_source":{"sourceId":{"type":"string"},"sourceLayers":{"type":"array","value":"string"}},"indoor":{"*":{"type":"indoor_source"}},"light":{"anchor":{"type":"enum","default":"viewport","values":{"map":1,"viewport":1},"expression":{"parameters":["zoom"]}},"position":{"type":"array","default":[1.15,210,30],"length":3,"value":"number","transition":true,"expression":{"interpolated":true,"parameters":["zoom"]}},"color":{"type":"color","default":"#ffffff","expression":{"interpolated":true,"parameters":["zoom"]},"use-theme":true,"transition":true},"intensity":{"type":"number","default":0.5,"minimum":0,"maximum":1,"expression":{"interpolated":true,"parameters":["zoom"]},"transition":true}},"projection":{"name":{"type":"enum","values":{"albers":1,"equalEarth":1,"equirectangular":1,"lambertConformalConic":1,"mercator":1,"naturalEarth":1,"winkelTripel":1,"globe":1},"default":"mercator"},"center":{"type":"array","length":2,"value":"number","minimum":[-180,-90],"maximum":[180,90]},"parallels":{"type":"array","length":2,"value":"number","minimum":[-90,-90],"maximum":[90,90]}},"terrain":{"source":{"type":"string"},"exaggeration":{"type":"number","default":1,"minimum":0,"maximum":1000,"expression":{"interpolated":true,"parameters":["zoom"]},"transition":true}},"paint":["paint_fill","paint_line","paint_circle","paint_heatmap","paint_fill-extrusion","paint_building","paint_symbol","paint_raster","paint_raster-particle","paint_hillshade","paint_background","paint_sky","paint_model"],"paint_fill":{"fill-antialias":{"type":"boolean","default":true,"expression":{"parameters":["zoom"]}},"fill-opacity":{"type":"number","default":1,"minimum":0,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state","measure-light"]},"property-type":"data-driven"},"fill-color":{"type":"color","default":"#000000","use-theme":true,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state","measure-light"]},"property-type":"data-driven"},"fill-outline-color":{"type":"color","use-theme":true,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state","measure-light"]},"property-type":"data-driven"},"fill-translate":{"type":"array","value":"number","length":2,"default":[0,0],"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]}},"fill-translate-anchor":{"type":"enum","values":{"map":1,"viewport":1},"default":"map","expression":{"parameters":["zoom"]}},"fill-pattern":{"type":"resolvedImage","expression":{"parameters":["zoom","feature"]},"property-type":"data-driven"},"fill-pattern-cross-fade":{"type":"number","default":0,"minimum":0,"maximum":1,"expression":{"interpolated":true,"parameters":["zoom","measure-light"]}},"fill-emissive-strength":{"type":"number","default":0,"minimum":0,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","measure-light"]}},"fill-z-offset":{"type":"number","default":0,"minimum":0,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature"]},"property-type":"data-driven"},"fill-bridge-guard-rail-color":{"type":"color","default":"rgba(241, 236, 225, 255)","use-theme":true,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","measure-light","feature"]},"property-type":"data-driven"},"fill-tunnel-structure-color":{"type":"color","default":"rgba(241, 236, 225, 255)","use-theme":true,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","measure-light","feature"]},"property-type":"data-driven"}},"paint_fill-extrusion":{"fill-extrusion-opacity":{"type":"number","default":1,"minimum":0,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]}},"fill-extrusion-color":{"type":"color","default":"#000000","use-theme":true,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state","meas
1ure-light"]},"property-type":"data-driven"},"fill-extrusion-translate":{"type":"array","value":"number","length":2,"default":[0,0],"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]}},"fill-extrusion-translate-anchor":{"type":"enum","values":{"map":1,"viewport":1},"default":"map","expression":{"parameters":["zoom"]}},"fill-extrusion-pattern":{"type":"resolvedImage","expression":{"parameters":["zoom","feature"]},"property-type":"data-driven"},"fill-extrusion-pattern-cross-fade":{"type":"number","default":0,"minimum":0,"maximum":1,"expression":{"interpolated":true,"parameters":["zoom","measure-light"]}},"fill-extrusion-height":{"type":"number","default":0,"minimum":0,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"fill-extrusion-base":{"type":"number","default":0,"minimum":0,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"fill-extrusion-height-alignment":{"type":"enum","values":{"terrain":1,"flat":1},"default":"flat"},"fill-extrusion-base-alignment":{"type":"enum","values":{"terrain":1,"flat":1},"default":"terrain"},"fill-extrusion-vertical-gradient":{"type":"boolean","default":true,"expression":{"parameters":["zoom"]}},"fill-extrusion-ambient-occlusion-intensity":{"type":"number","default":0,"minimum":0,"maximum":1,"expression":{"interpolated":true,"parameters":["zoom"]},"transition":true},"fill-extrusion-ambient-occlusion-radius":{"type":"number","default":3,"minimum":0,"expression":{"interpolated":true,"parameters":["zoom"]},"transition":true},"fill-extrusion-ambient-occlusion-wall-radius":{"type":"number","default":3,"minimum":0,"expression":{"interpolated":true,"parameters":["zoom"]},"transition":true},"fill-extrusion-ambient-occlusion-ground-radius":{"type":"number","default":3,"minimum":0,"expression":{"interpolated":true,"parameters":["zoom"]},"transition":true},"fill-extrusion-ambient-occlusion-ground-attenuation":{"type":"number","default":0.69,"minimum":0,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]}},"fill-extrusion-flood-light-color":{"type":"color","default":"#ffffff","use-theme":true,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","measure-light"]}},"fill-extrusion-flood-light-intensity":{"type":"number","default":0,"minimum":0,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","measure-light"]}},"fill-extrusion-flood-light-wall-radius":{"property-type":"data-driven","type":"number","default":0,"minimum":0,"transition":true,"expression":{"interpolated":true,"parameters":["feature","feature-state"]}},"fill-extrusion-flood-light-ground-radius":{"property-type":"data-driven","type":"number","default":0,"transition":true,"expression":{"interpolated":true,"parameters":["feature","feature-state"]}},"fill-extrusion-flood-light-ground-attenuation":{"type":"number","default":0.69,"minimum":0,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]}},"fill-extrusion-vertical-scale":{"type":"number","default":1,"minimum":0,"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]}},"fill-extrusion-rounded-roof":{"type":"boolean","default":true,"expression":{"parameters":["zoom"]}},"fill-extrusion-cutoff-fade-range":{"type":"number","default":0,"minimum":0,"maximum":1,"expression":{}},"fill-extrusion-front-cutoff":{"type":"array","value":"number","expression":{"interpolated":true,"parameters":["zoom"]},"length":3,"default":[0,0,1],"minimum":[0,0,0],"maximum":[1,1,1]},"fill-extrusion-emissive-strength":{"type":"number","default":0,"minimum":0,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","measure-light","feature-state"]},"property-type":"data-driven"},"fill-extrusion-line-width":{"type":"number","default":0,"minimum":0,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state","measure-light"]},"property-type":"data-driven"},"fill-extrusion-cast-shadows":{"type":"boolean","default":true}},"paint_building":{"building-opacity":{"type":"number","default":1,"minimum":0,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]}},"building-ambient-occlusion-intensity":{"type":"number","default":0,"minimum":0,"maximum":1,"expression":{"parameters":[]},"transition":true},"building-ambient-occlusion-ground-intensity":{"type":"number","default":0,"minimum":0,"maximum":1,"expression":{"interpolated":true,"parameters":["zoom"]},"transition":true},"building-ambient-occlusion-ground-radius":{"type":"number","default":3,"minimum":0,"expression":{"interpolated":true,"parameters":["zoom"]},"transition":true},"building-ambient-occlusion-ground-attenuation":{"type":"number","default":0.69,"minimum":0,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]}},"building-vertical-scale":{"type":"number","default":1,"minimum":0,"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]}},"building-cast-shadows":{"type":"boolean","default":true},"building-color":{"type":"color","default":"rgba(193, 154, 127, 1)","use-theme":true,"expression":{"interpolated":true,"parameters":["feature","feature-state","measure-light"]},"property-type":"data-driven"},"building-emissive-strength":{"type":"number","default":0,"minimum":0,"maximum":5,"expression":{"interpolated":true,"parameters":["feature","feature-state","measure-light"]},"property-type":"data-driven"},"building-facade-emissive-chance":{"type":"number","default":0.35,"minimum":0,"maximum":1,"expression":{"interpolated":true,"parameters":["measure-light","zoom"]}},"building-cutoff-fade-range":{"type":"number","default":0,"minimum":0,"maximum":1,"expression":{}},"building-front-cutoff":{"type":"array","value":"number","expression":{"interpolated":true,"parameters":["zoom"]},"length":3,"default":[0,0,1],"minimum":[0,0,0],"maximum":[1,1,1]},"building-flood-light-color":{"type":"color","default":"#ffffff","use-theme":true,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","measure-light"]}},"building-flood-light-intensity":{"type":"number","default":0,"minimum":0,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","measure-light"]}},"building-flood-light-ground-attenuation":{"type":"number","default":0.69,"minimum":0,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]}}},"paint_line":{"line-opacity":{"type":"number","default":1,"minimum":0,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state","measure-light"]},"property-type":"data-driven"},"line-color":{"type":"color","default":"#000000","use-theme":true,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state","measure-light"]},"property-type":"data-driven"},"line-translate":{"type":"array","value":"number","length":2,"default":[0,0],"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]}},"line-translate-anchor":{"type":"enum","values":{"map":1,"viewport":1},"default":"map","expression":{"parameters":["zoom"]}},"line-width":{"type":"number","default":1,"minimum":0,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state","measure-light","line-progress"]},"property-type":"data-driven"},"line-gap-width":{"type":"number","default":0,"minimum":0,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state","measure-light"]},"property-type":"data-driven"},"line-offset":{"type":"number","default":0,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state","measure-light"]},"property-type":"data-driven"}
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"]},"property-type":"data-driven"},"line-border-width":{"type":"number","default":0,"minimum":0,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"line-border-color":{"type":"color","default":"rgba(0, 0, 0, 0)","use-theme":true,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"line-occlusion-opacity":{"type":"number","default":0,"minimum":0,"maximum":1,"expression":{"interpolated":true,"parameters":["zoom"]},"transition":true},"line-blend-mode":{"type":"enum","values":{"default":1,"multiply":1,"additive":1},"default":"default","expression":{"parameters":["zoom"]}},"line-blend-additive-clamp":{"type":"number","default":0,"minimum":0,"expression":{"interpolated":true,"parameters":["zoom"]}}},"paint_circle":{"circle-radius":{"type":"number","default":5,"minimum":0,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state","measure-light"]},"property-type":"data-driven"},"circle-color":{"type":"color","default":"#000000","use-theme":true,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state","measure-light"]},"property-type":"data-driven"},"circle-blur":{"type":"number","default":0,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state","measure-light"]},"property-type":"data-driven"},"circle-opacity":{"type":"number","default":1,"minimum":0,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state","measure-light"]},"property-type":"data-driven"},"circle-translate":{"type":"array","value":"number","length":2,"default":[0,0],"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]}},"circle-translate-anchor":{"type":"enum","values":{"map":1,"viewport":1},"default":"map","expression":{"parameters":["zoom"]}},"circle-pitch-scale":{"type":"enum","values":{"map":1,"viewport":1},"default":"map","expression":{"parameters":["zoom"]}},"circle-pitch-alignment":{"type":"enum","values":{"map":1,"viewport":1},"default":"viewport","expression":{"parameters":["zoom"]}},"circle-stroke-width":{"type":"number","default":0,"minimum":0,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state","measure-light"]},"property-type":"data-driven"},"circle-stroke-color":{"type":"color","default":"#000000","use-theme":true,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state","measure-light"]},"property-type":"data-driven"},"circle-stroke-opacity":{"type":"number","default":1,"minimum":0,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state","measure-light"]},"property-type":"data-driven"},"circle-emissive-strength":{"type":"number","default":0,"minimum":0,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","measure-light"]}}},"paint_heatmap":{"heatmap-radius":{"type":"number","default":30,"minimum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state","measure-light"]},"property-type":"data-driven"},"heatmap-weight":{"type":"number","default":1,"minimum":0,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state","measure-light"]},"property-type":"data-driven"},"heatmap-intensity":{"type":"number","default":1,"minimum":0,"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]}},"heatmap-color":{"type":"color","default":["interpolate",["linear"],["heatmap-density"],0,"rgba(0, 0, 255, 0)",0.1,"royalblue",0.3,"cyan",0.5,"lime",0.7,"yellow",1,"red"],"use-theme":true,"expression":{"interpolated":true,"parameters":["heatmap-density"]}},"heatmap-opacity":{"type":"number","default":1,"minimum":0,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]}}},"paint_symbol":{"icon-opacity":{"type":"number","default":1,"minimum":0,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state","measure-light"]},"appearance":true,"property-type":"data-driven"},"icon-occlusion-opacity":{"type":"number","minimum":0,"maximum":1,"default":0,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state","measure-light"]},"appearance":true,"property-type":"data-driven"},"icon-emissive-strength":{"type":"number","default":1,"minimum":0,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","measure-light","feature-state"]},"appearance":true,"property-type":"data-driven"},"text-emissive-strength":{"type":"number","default":1,"minimum":0,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","measure-light","feature-state"]},"appearance":true,"property-type":"data-driven"},"icon-color":{"type":"color","default":"#000000","use-theme":true,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state","measure-light"]},"appearance":true,"property-type":"data-driven"},"icon-halo-color":{"type":"color","default":"rgba(0, 0, 0, 0)","use-theme":true,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state","measure-light"]},"appearance":true,"property-type":"data-driven"},"icon-halo-width":{"type":"number","default":0,"minimum":0,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state","measure-light"]},"appearance":true,"property-type":"data-driven"},"icon-halo-blur":{"type":"number","default":0,"minimum":0,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state","measure-light"]},"appearance":true,"property-type":"data-driven"},"icon-translate":{"type":"array","value":"number","length":2,"default":[0,0],"transition":true,"appearance":true,"expression":{"interpolated":true,"parameters":["zoom"]}},"icon-translate-anchor":{"type":"enum","values":{"map":1,"viewport":1},"default":"map","expression":{"parameters":["zoom"]}},"icon-image-cross-fade":{"type":"number","default":0,"minimum":0,"maximum":1,"expression":{"interpolated":true,"parameters":["zoom","measure-light"]}},"text-opacity":{"type":"number","default":1,"minimum":0,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state","measure-light"]},"appearance":true,"property-type":"data-driven"},"text-occlusion-opacity":{"type":"number","minimum":0,"maximum":1,"default":0,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state","measure-light"]},"appearance":true,"property-type":"data-driven"},"text-color":{"type":"color","default":"#000000","use-theme":true,"transition":true,"overridable":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state","measure-light"]},"appearance":true,"property-type":"data-driven"},"text-halo-color":{"type":"color","default":"rgba(0, 0, 0, 0)","use-theme":true,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state","measure-light"]},"appearance":true,"property-type":"data-driven"},"text-halo-width":{"type":"number","default":0,"minimum":0,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state","measure-light"]},"appearance":true,"property-type":"data-driven"},"text-halo-blur":{"type":"number","default":0,"minimum":0,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state","measure-light"]},"appearance":true,"property-type":"data-driven"},"text-translate":{"type":"array","value":"number","length":2,"default":[0,0],"transition":true,"appearance":true,"expression":{"interpolated":true,"parameters":["zoom"]}},"text-translate-anchor":{"type":"enum","values":{"map":1,"viewport":1},"default":"map","expression":{"parameters":["zoom"]}},"icon-color-saturation":{"type":"number","default":0,"minimum":-1,"maximum":1,"expression":{}},"icon-color-contrast":{"type":"number","default":0,"minimum":-1,"maximum":1,"expression":{}},"icon-color-brightness-min":{"type":"number","default":0,"minimum":0,"maximum":1,"expression":{}},"icon-color-brightness-max":{"type":"number","default":1,"minimum":0,"maximum":1,"expression":{}},"symbol-z-offset":{"type":"number","default":0,"minimum":0,"transition":true,"appearance":true,"expression":{"interpolated":true,"parameters":["zoom","feature"]},"property-type":"data-driven"}},"paint_raster":{"raster-opacity":{"type":"number","default":1,"minimum":0,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]}},"raster-color":{"type":"color","use-theme":true,"expression":{"interpolated":true,"parameters":["raster-value"]}},"raster-color-mix":{"type":"array","default":[0.2126,0.7152,0.0722,0],"length":4,"value":"number","transition":true,"expression":{"interpolated":true,"parameters":["zoom"]}},"raster-color-range":{"type":"array","length":2,"value":"number","transition":true,"expression":{"interpolated":true,"parameters":["zoom"]}},"raster-hue-rotate":{"type":"number","default":0,"period":360,"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]}},"raster-brightness-min":{"type":"number","default":0,"minimum":0,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]}},"raster-brightness-max":{"type":"number","default":1,"minimum":0,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]}},"raster-saturation":{"type":"number","default":0,"minimum":-1,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]}},"raster-contrast":{"type":"number","default":0,"minimum":-1,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]}},"raster-resampling":{"type":"enum","values":{"linear":1,"nearest":1},"default":"linear","expression":{"parameters":["zoom"]}},"raster-fade-duration":{"type":"number","default":300,"minimum":0,"expression":{"interpolated":true,"parameters":["zoom"]}},"raster-emissive-strength":{"type":"number","default":0,"minimum":0,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","measure-light"]}},"raster-array-band":{"type":"string"},"raster-elevation":{"type":"number","default":0,"minimum":0,"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]}},"raster-elevation-reference":{"type":"enum","values":{"sea":1,"ground":1},"default":"sea","expression":{}}},"paint_raster-particle":{"raster-particle-array-band":{"type":"string"},"raster-particle-count":{"type":"number","default":512,"minimum":1},"raster-particle-color":{"type":"color","use-theme":true,"expression":{"interpolated":true,"parameters":["raster-particle-speed"]}},"raster-particle-max-speed":{"type":"number","default":1,"minimum":1},"raster-particle-speed-factor":{"type":"number","default":0.2,"minimum":0,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]}},"raster-particle-fade-opacity-factor":{"type":"number","default":0.98,"minimum":0,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]}},"raster-particle-reset-rate-factor":{"type":"number","default":0.8,"minimum":0,"maximum":1},"raster-particle-elevation":{"type":"number","default":0,"minimum":0,"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]}}},"paint_hillshade":{"hillshade-illumination-direction":{"type":"number","default":335,"minimum":0,"maximum":359,"expression":{"interpolated":true,"parameters":["zoom"]}},"hillshade-illumination-anchor":{"type":"enum","values":{"map":1,"viewport":1},"default":"viewport","expression":{"parameters":["zoom"]}},"hillshade-exaggeration":{"type":"number","default":0.5,"minimum":0,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]}},"hillshade-shadow-color":{"type":"color","default":"#000000","use-theme":true,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","measure-light"]}},"hillshade-highlight-color":{"type":"color","default":"#FFFFFF","use-theme":true,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","measure-light"]}},"hillshade-accent-color":{"type":"color","default":"#000000","use-theme":true,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","measure-light"]}},"hillshade-emissive-strength":{"type":"number","default":0,"minimum":0,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","measure-light"]}}},"paint_background":{"background-pitch-alignment":{"type":"enum","values":{"map":1,"viewport":1},"default":"map","expression":{"parameters":[]}},"background-color":{"type":"color","default":"#000000","use-theme":true,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","measure-light"]}},"background-pattern":{"type":"resolvedImage","expression":{"parameters":["zoom"]}},"background-opacity":{"type":"number","default":1,"minimum":0,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]}},"background-emissive-strength":{"type":"number","default":0,"minimum":0,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","measure-light"]}}},"paint_sky":{"sky-type":{"type":"enum","values":{"gradient":1,"atmosphere":1},"default":"atmosphere","expression":{"parameters":["zoom"]}},"sky-atmosphere-sun":{"type":"array","value":"number","length":2,"minimum":[0,0],"maximum":[360,180],"expression":{"parameters":["zoom"]}},"sky-atmosphere-sun-intensity":{"type":"number","default":10,"minimum":0,"maximum":100},"sky-gradient-center":{"type":"array","value":"number","default":[0,0],"length":2,"minimum":[0,0],"maximum":[360,180],"expression":{"parameters":["zoom"]}},"sky-gradient-radius":{"type":"number","default":90,"minimum":0,"maximum":180,"expression":{"parameters":["zoom"]}},"sky-gradient":{"type":"color","default":["interpolate",["linear"],["sky-radial-progress"],0.8,"#87ceeb",1,"white"],"use-theme":true,"expression":{"interpolated":true,"parameters":["sky-radial-progress"]}},"sky-atmosphere-halo-color":{"type":"color","default":"white","use-theme":true},"sky-atmosphere-color":{"type":"color","default":"white","use-theme":true},"sky-opacity":{"type":"number","default":1,"minimum":0,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]}}},"paint_model":{"model-opacity":{"type":"number","default":1,"minimum":0,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["feature","feature-state","zoom"]},"property-type":"data-driven"},"model-rotation":{"type":"array","value":"number","length":3,"default":[0,0,0],"period":360,"property-type":"data-driven","expression":{"interpolated":true,"parameters":["feature","feature-state","zoom"]},"transition":true},"model-scale":{"type":"array","value":"n
1umber","length":3,"default":[1,1,1],"property-type":"data-driven","expression":{"interpolated":true,"parameters":["feature","feature-state","zoom"]},"transition":true},"model-translation":{"type":"array","value":"number","length":3,"default":[0,0,0],"property-type":"data-driven","expression":{"interpolated":true,"parameters":["feature","feature-state","zoom"]},"transition":true},"model-color":{"type":"color","default":"#ffffff","property-type":"data-driven","expression":{"interpolated":true,"parameters":["feature","feature-state","measure-light","zoom"]},"use-theme":true,"transition":true},"model-color-mix-intensity":{"type":"number","property-type":"data-driven","default":0,"minimum":0,"maximum":1,"expression":{"interpolated":true,"parameters":["feature","feature-state","measure-light"]},"transition":true},"model-type":{"type":"enum","values":{"common-3d":1,"location-indicator":1},"default":"common-3d"},"model-cast-shadows":{"type":"boolean","default":true},"model-receive-shadows":{"type":"boolean","default":true},"model-ambient-occlusion-intensity":{"type":"number","default":1,"minimum":0,"maximum":1,"expression":{"interpolated":true,"parameters":["zoom"]},"transition":true},"model-emissive-strength":{"type":"number","property-type":"data-driven","default":0,"minimum":0,"maximum":5,"expression":{"interpolated":true,"parameters":["feature","feature-state","measure-light"]},"transition":true},"model-roughness":{"type":"number","default":1,"minimum":0,"maximum":1,"property-type":"data-driven","expression":{"interpolated":true,"parameters":["feature","feature-state"]},"transition":true},"model-height-based-emissive-strength-multiplier":{"type":"array","default":[1,1,1,1,0],"length":5,"value":"number","property-type":"data-driven","expression":{"interpolated":true,"parameters":["feature","feature-state","measure-light"]},"transition":true},"model-cutoff-fade-range":{"type":"number","default":0,"minimum":0,"maximum":1,"expression":{}},"model-front-cutoff":{"type":"array","value":"number","expression":{"interpolated":true,"parameters":["zoom"]},"length":3,"default":[0,0,1],"minimum":[0,0,0],"maximum":[1,1,1]},"model-elevation-reference":{"type":"enum","values":{"sea":1,"ground":1,"hd-road-markup":1},"default":"ground","expression":{}},"model-ignore-line-cutout":{"type":"boolean","default":false,"expression":{}}},"transition":{"duration":{"type":"number","default":300,"minimum":0},"delay":{"type":"number","default":0,"minimum":0}},"promoteId":{"*":{"type":"*"}}}');function Vc(n){return n instanceof Number||n instanceof String||n instanceof Boolean?n.valueOf():n}function jc(n){if(Array.isArray(n))return n.map(jc);if(n instanceof Object&&!(n instanceof Number||n instanceof String||n instanceof Boolean)){let e={};for(let i in n)e[i]=jc(n[i]);return e}return Vc(n)}function Gc(n){if(n===!0||n===!1)return!0;if(!Array.isArray(n)||n.length===0)return!1;switch(n[0]){case"has":return n.length>=2&&n[1]!=="$id"&&n[1]!=="$type";case"in":return n.length>=3&&(typeof n[1]!="string"||Array.isArray(n[2]));case"!in":case"!has":case"none":return!1;case"==":case"!=":case">":case">=":case"<":case"<=":return n.length!==3||Array.isArray(n[1])||Array.isArray(n[2]);case"any":case"all":for(let e of n.slice(1))if(!Gc(e)&&typeof e!="boolean")return!1;return!0;default:return!0}}function io(n,e="",i=null,r="fill"){if(n==null)return{filter:()=>!0,needGeometry:!1,needFeature:!1};Gc(n)||(n=ih(n));let s=n,l=!0;try{l=function(x){if(!Il(x))return x;let b=jc(x);return Qf(b),b=Kf(b),b}(s)}catch{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(s,null,2)} 7 `)}let u=null,p=null;if(r!=="background"&&r!=="sky"&&r!=="slot"){p=he[`filter_${r}`];let x=Pa(l,p,e,i);if(x.result==="error")throw new Error(x.value.map(b=>`${b.key}: ${b.message}`).join(", "));u=(b,w,S)=>x.value.evaluate(b,w,{},S)}let f=null,g=null;if(l!==s){let x=Pa(s,p,e,i);if(x.result==="error")throw new Error(x.value.map(b=>`${b.key}: ${b.message}`).join(", "));f=(b,w,S,E,M)=>x.value.evaluate(b,w,{},S,void 0,void 0,E,M),g=!Ma(x.value.expression)}return{filter:u,dynamicFilter:f||void 0,needGeometry:tm(l),needFeature:!!g}}function Kf(n){if(!Array.isArray(n))return n;let e=function(i){if(rg.has(i[0])){for(let r=1;r<i.length;r++)if(Il(i[r]))return!0}return i}(n);return e===!0?e:e.map(i=>Kf(i))}function Qf(n){let e=!1,i=[];if(n[0]==="case"){for(let r=1;r<n.length-1;r+=2)e=e||Il(n[r]),i.push(n[r+1]);i.push(n.at(-1))}else if(n[0]==="match"){e=e||Il(n[1]);for(let r=2;r<n.length-1;r+=2)i.push(n[r+1]);i.push(n.at(-1))}else if(n[0]==="step"){e=e||Il(n[1]);for(let r=1;r<n.length-1;r+=2)i.push(n[r+1])}e&&(n.length=0,n.push("any",...i));for(let r=1;r<n.length;r++)Qf(n[r])}function Il(n){if(!Array.isArray(n))return!1;if((e=n[0])==="pitch"||e==="distance-from-center")return!0;var e;
7for(let i=1;i<n.length;i++)if(Il(n[i]))return!0;return!1}let rg=new Set(["in","==","!=",">",">=","<","<=","to-boolean"]);function em(n,e){return n<e?-1:n>e?1:0}function tm(n){if(!Array.isArray(n))return!1;if(n[0]==="within"||n[0]==="distance")return!0;for(let e=1;e<n.length;e++)if(tm(n[e]))return!0;return!1}function ih(n){if(!n)return!0;let e=n[0];return n.length<=1?e!=="any":e==="=="?Bd(n[1],n[2],"=="):e==="!="?Fa(Bd(n[1],n[2],"==")):e==="<"||e===">"||e==="<="||e===">="?Bd(n[1],n[2],e):e==="any"?(i=n.slice(1),["any"].concat(i.map(ih))):e==="all"?["all"].concat(n.slice(1).map(ih)):e==="none"?["all"].concat(n.slice(1).map(ih).map(Fa)):e==="in"?kd(n[1],n.slice(2)):e==="!in"?Fa(kd(n[1],n.slice(2))):e==="has"?Oa(n[1]):e!=="!has"||Fa(Oa(n[1]));var i}function Bd(n,e,i){switch(n){case"$type":return[`filter-type-${i}`,e];case"$id":return[`filter-id-${i}`,e];default:return[`filter-${i}`,n,e]}}function kd(n,e){if(e.length===0)return!1;switch(n){case"$type":return["filter-type-in",["literal",e]];case"$id":return["filter-id-in",["literal",e]];default:return e.length>200&&!e.some(i=>typeof i!=typeof e[0])?["filter-in-large",n,["literal",e.sort(em)]]:["filter-in-small",n,["literal",e]]}}function Oa(n){switch(n){case"$type":return!0;case"$id":return["filter-has-id"];default:return["filter-has",n]}}function Fa(n){return["!",n]}let El="�";function ks(n,e){return e?`${n}${El}${e}`:n}function im(n){let e=n.indexOf(El);return e>=0?n.slice(e+1):""}let nm,rm=()=>nm||(nm=new wi({"icon-size":new Ze(he.layout_symbol["icon-size"]),"icon-image":new Ze(he.layout_symbol["icon-image"]),"icon-rotate":new Ze(he.layout_symbol["icon-rotate"]),"icon-offset":new Ze(he.layout_symbol["icon-offset"]),"text-size":new Ze(he.layout_symbol["text-size"]),"text-rotate":new Ze(he.layout_symbol["text-rotate"]),"text-offset":new Ze(he.layout_symbol["text-offset"])})),om,sm=()=>om||(om=new wi({"icon-opacity":new Ze(he.paint_symbol["icon-opacity"]),"icon-occlusion-opacity":new Ze(he.paint_symbol["icon-occlusion-opacity"]),"icon-emissive-strength":new Ze(he.paint_symbol["icon-emissive-strength"]),"text-emissive-strength":new Ze(he.paint_symbol["text-emissive-strength"]),"icon-color":new Ze(he.paint_symbol["icon-color"]),"icon-halo-color":new Ze(he.paint_symbol["icon-halo-color"]),"icon-halo-width":new Ze(he.paint_symbol["icon-halo-width"]),"icon-halo-blur":new Ze(he.paint_symbol["icon-halo-blur"]),"icon-translate":new Ze(he.paint_symbol["icon-translate"]),"text-opacity":new Ze(he.paint_symbol["text-opacity"]),"text-occlusion-opacity":new Ze(he.paint_symbol["text-occlusion-opacity"]),"text-color":new Ze(he.paint_symbol["text-color"],{runtimeType:rn,getOverride:n=>n.textColor,hasOverride:n=>!!n.textColor}),"text-halo-color":new Ze(he.paint_symbol["text-halo-color"]),"text-halo-width":new Ze(he.paint_symbol["text-halo-width"]),"text-halo-blur":new Ze(he.paint_symbol["text-halo-blur"]),"text-translate":new Ze(he.paint_symbol["text-translate"]),"symbol-z-offset":new Ze(he.paint_symbol["symbol-z-offset"]),"icon-color-use-theme":new Ze({type:"string",default:"default","property-type":"data-driven"}),"icon-halo-color-use-theme":new Ze({type:"string",default:"default","property-type":"data-driven"}),"text-color-use-theme":new Ze({type:"string",default:"default","property-type":"data-driven"}),"text-halo-color-use-theme":new Ze({type:"string",default:"default","property-type":"data-driven"})}));class og{constructor(e,i,r,s,l,u){this._conditionSpec=e,this._propertiesSpec=r;let p=Pa(e,he.appearance.condition);if(p.result==="success"&&(this.condition=p.value),this.name=i,r){this.layoutProperties=new es(rm()),this.unevaluatedLayout=new Uc(rm(),s,l,u),this.paintProperties=new es(sm()),this.unevaluatedPaint=new Uc(sm(),s,l,"");for(let f in r)f in this.unevaluatedLayout._values?this.unevaluatedLayout.setValue(f,r[f]):f in this.unevaluatedPaint._values&&this.unevaluatedPaint.setValue(f,r[f])}}isActive(e){return!(this.condition||!e.isHidden||this.name!=="hidden")||this.condition.evaluate(e.globals,e.feature,e.featureState,e.canonical)}getCondition(){return this.condition}getName(){return this.name}getLayoutProperty(e){return this.layoutProperties.get(e)}getPaintProperty(e){return this.paintProperties.get(e)}getUnevaluatedLayoutProperties(){return this.unevaluatedLayout}getUnevaluatedLayoutProperty(e){return this.unevaluatedLayout._values[e]}getUnevaluatedPaintProperty(e){return this.unevaluatedPaint._values[e]}recalculate(e,i,r){this.unevaluatedLayout&&(this.layoutProperties=this.unevaluatedLayout.possiblyEvaluate(e,void 0,i,r)),this.unevaluatedPaint&&(this.paintProperties=this.unevaluatedPaint.possiblyEvaluate(e,void 0,i,""))}serialize(){let e={};e.condition=this.condition.expression.serialize(),this.name&&(e.name=this.name);let i=this.unevaluatedLayout?this.unevaluatedLayout.serialize():{},r=this.unevaluatedPaint?this.unevaluatedPaint.serialize():{},s=Object.assign({},i,r);return Object.keys(s).length>0&&(e.properties=s),e}hasIconLayoutProperties(){let e=this.hasLayoutProperty("icon-image"),i=this.hasLayoutProperty("icon-size"),r=this.hasLayoutProperty("icon-offset"),s=this.hasLayoutProperty("icon-rotate");return e||i||r||s}hasTextLayoutProperties(){let e=this.hasLayoutProperty("text-size"),i=this.hasLayoutProperty("text-offset"),r=this.hasLayoutProperty("text-rotate");return e||i||r}hasIconPaintProperties(){return!!this.unevaluatedPaint&&Object.keys(this.unevaluatedPaint._values).filter(e=>!e.endsWith("-use-theme")).some(e=>(e.startsWith("icon-")||e==="symbol-z-offset")&&this.hasPaintProperty(e))}hasTextPaintProperties(){return!!this.unevaluatedPaint&&Object.keys(this.unevaluatedPaint._values).filter(e=>!e.endsWith("-use-theme")).some(e=>(e.startsWith("text-")||e==="symbol-z-offset")&&this.hasPaintProperty(e))}hasLayoutProperty(e){return this.unevaluatedLayout&&this.unevaluatedLayout._values[e].value!==void 0}hasPaintProperty(e){return this.unevaluatedPaint&&this.unevaluatedPaint._values[e].value!==void 0}}let am="-transition",lm=new Set(["fill","line","background","hillshade","raster"]);class ir extends ol{constructor(e,i,r,s,l,u){if(super(),this.id=e.id,this.fqid=ks(this.id,r),this.type=e.type,this.scope=r,this.lut=s,this.options=l,this.iconImageUseTheme=u,this.appearances=new Array,this.appearancesVersion=0,this._featureFilter={filter:()=>!0,needGeometry:!1,needFeature:!1},this._filterCompiled=!1,this.expressionDependencies={isIndoorDependent:!1,configDependencies:new Set},e.type!=="custom"){if(this.metadata=e.metadata,this.minzoom=e.minzoom,this.maxzoom=e.maxzoom,e.type&&e.type!=="background"&&e.type!=="sky"&&e.type!=="slot"){this.source=e.source,this.sourceLayer=e["source-layer"],this.filter=e.filter;let p=Pa(this.filter,he[`filter_${e.type}`]);p.result!=="error"&&(this.expressionDependencies.configDependencies=new Set([...this.expressionDependencies.configDependencies,...p.value.configDependencies]),this.expressionDependencies.isIndoorDependent=this.expressionDependencies.isIndoorDependent||p.value.isIndoorDependent)}if(e.slot&&(this.slot=e.slot),e.appearances&&this.setAppearances(e.appearances),i.layout&&(this._unevaluatedLayout=new
7Uc(i.layout,this.scope,l,this.iconImageUseTheme),this.expressionDependencies.configDependencies=new Set([...this.expressionDependencies.configDependencies,...this._unevaluatedLayout.configDependencies]),this.expressionDependencies.isIndoorDependent=this.expressionDependencies.isIndoorDependent||this._unevaluatedLayout.isIndoorDependent()),i.paint){this._transitionablePaint=new Jf(i.paint,this.scope,l);for(let p in e.paint)this.setPaintProperty(p,e.paint[p]);for(let p in e.layout)this.setLayoutProperty(p,e.layout[p]);this.expressionDependencies.configDependencies=new Set([...this.expressionDependencies.configDependencies,...this._transitionablePaint.configDependencies]),this.expressionDependencies.isIndoorDependent=this.expressionDependencies.isIndoorDependent||this._transitionablePaint.isIndoorDependent(),this._transitioningPaint=this._transitionablePaint.untransitioned(),this.paint=new es(i.paint)}}}onAdd(e){}onRemove(e){}isDraped(e){return!this.is3D(!0)&&lm.has(this.type)}getLayoutProperty(e){return e==="visibility"?this.visibility:this._unevaluatedLayout.getValue(e)}setLayoutProperty(e,i){if(this.type==="custom"&&e==="visibility")return void(this.visibility=i);let r=this._unevaluatedLayout;r._properties.properties[e]&&(r.setValue(e,i),this.expressionDependencies.configDependencies=new Set([...this.expressionDependencies.configDependencies,...r.configDependencies]),this.expressionDependencies.isIndoorDependent=this.expressionDependencies.isIndoorDependent||r.isIndoorDependent(),e==="visibility"&&this.possiblyEvaluateVisibility())}setAppearances(e){this.appearances=[],e.forEach(i=>{this.appearances.push(new og(i.condition,i.name,i.properties,this.scope,this.options,this.iconImageUseTheme))}),this.appearancesVersion++}possiblyEvaluateVisibility(){this._unevaluatedLayout._values.visibility&&(this.visibility=this._unevaluatedLayout._values.visibility.possiblyEvaluate({zoom:0}))}getPaintProperty(e){return e.endsWith(am)?this._transitionablePaint.getTransition(e.slice(0,-11)):this._transitionablePaint.getValue(e)}isPaintProperty(e){return!!this._transitionablePaint._properties.properties[e]}setPaintProperty(e,i){let r=this._transitionablePaint,s=r._properties.properties;if(e.endsWith(am)){let b=e.slice(0,-11);return s[b]&&r.setTransition(b,i||void 0),!1}if(!s[e])return!1;let l=r._values[e],u=l.value.isDataDriven(),p=l.value;r.setValue(e,i),this.expressionDependencies.configDependencies=new Set([...this.expressionDependencies.configDependencies,...r.configDependencies]),this.expressionDependencies.isIndoorDependent=this.expressionDependencies.isIndoorDependent||r.isIndoorDependent(),this._handleSpecialPaintPropertyUpdate(e);let f=r._values[e].value,g=f.isDataDriven(),x=e.endsWith("pattern")||e==="line-dasharray";return g||u||x||this._handleOverridablePaintPropertyUpdate(e,p,f)}_handleSpecialPaintPropertyUpdate(e){}getProgramIds(){return null}getDefaultProgramParams(e,i,r){return null}_handleOverridablePaintPropertyUpdate(e,i,r){return!1}isHidden(e){return!!(this.minzoom&&e<this.minzoom)||!!(this.maxzoom&&e>=this.maxzoom)||this.visibility==="none"}updateTransitions(e){this._transitioningPaint=this._transitionablePaint.transitioned(e,this._transitioningPaint)}hasTransition(){return this._transitioningPaint.hasTransition()}recalculate(e,i){this._unevaluatedLayout&&(this.layout=this._unevaluatedLayout.possiblyEvaluate(e,void 0,i,this.iconImageUseTheme)),this.paint=this._transitioningPaint.possiblyEvaluate(e,void 0,i)}
7serialize(){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 this.appearances.length!==0&&(e.appearances=this.appearances.map(i=>i.serialize())),Ve(e,(i,r)=>!(i===void 0||r==="layout"&&!Object.keys(i).length||r==="paint"&&!Object.keys(i).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 Bs&&qu(i.property.specification)&&(i.value.kind==="source"||i.value.kind==="composite")&&i.value.isStateDependent)return!0}for(let e of this.appearances)if(!fl(e.condition.expression))return!0;return!1}compileFilter(e){this._filterCompiled||(this._featureFilter=io(this.filter,this.scope,e),this._filterCompiled=!0)}invalidateCompiledFilter(){this._filterCompiled=!1}dynamicFilter(){return this._featureFilter.dynamicFilter}dynamicFilterNeedsFeature(){return this._featureFilter.needFeature}dynamicFilterNeedsGeometry(){return this._featureFilter.needGeometry}getLayerRenderingStats(){return this._stats}resetLayerRenderingStats(e){this._stats&&(e.renderPass==="shadow"?this._stats.numRenderedVerticesInShadowPass=0:this._stats.numRenderedVerticesInTransparentPass=0)}getAppearances(){return this.appearances}queryRenderedFeatures(e,i,r){return{}}queryRadius(e){}queryIntersectsFeature(e,i,r,s,l,u,p,f,g,x){}}let sg={Int8:Int8Array,Uint8:Uint8Array,Int16:Int16Array,Uint16:Uint16Array,Int32:Int32Array,Uint32:Uint32Array,Float32:Float32Array};class $c{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}}let ag=new ArrayBuffer(0);class _i{constructor(){this._reallocCount=0,this.capacity=0,this.length=0}static serialize(e,i){return e._trim(),i&&e.arrayBuffer&&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,e.arrayBuffer?i.capacity=e.arrayBuffer.byteLength/i.bytesPerElement:(i.capacity=0,i.arrayBuffer=ag),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._reallocCount++,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)}}reserveForAdditional(e){this.reserve(this.length+e)}_refreshViews(){throw new Error("StructArray#_refreshViews() must be implemented by each concrete StructArray layout")}emplace(...e){throw new Error("StructArray#emplace() must be implemented by each concrete StructArray layout")}emplaceBack(...e){throw new Error("StructArray#emplaceBack() must be implemented by each concrete StructArray layout")}destroy(){this.int8=this.uint8=this.int16=this.uint16=this.int32=this.uint32=this.float32=null,this.arrayBuffer=null}}function Ct(n,e=1){let i=0,r=0;return{members:n.map(s=>{let l=sg[s.type].BYTES_PER_ELEMENT,u=i=Nd(i,Math.max(e,l)),p=s.components||1;return r=Math.max(r,l),i+=l*p,{name:s.name,type:s.type,components:p,offset:u}}),size:Nd(i,Math.max(r,e)),alignment:e}}function Nd(n,e){return Math.ceil(n/e)*e}class Hn extends _i{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(e,i){let r=this.length;return this.resize(r+1),this.emplace(r,e,i)}emplace(e,i,r){let s=2*e;return this.int16[s+0]=i,this.int16[s+1]=r,e}}Hn.prototype.bytesPerElement=4,Qe(Hn,"StructArrayLayout2i4");class Ns extends _i{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(e,i,r){let s=this.length;return this.resize(s+1),this.emplace(s,e,i,r)}
vendor: 18,521 bytes, line 7
7emplace(e,i,r,s){let l=3*e;return this.int16[l+0]=i,this.int16[l+1]=r,this.int16[l+2]=s,e}}Ns.prototype.bytesPerElement=6,Qe(Ns,"StructArrayLayout3i6");class Ba extends _i{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(e,i,r,s){let l=this.length;return this.resize(l+1),this.emplace(l,e,i,r,s)}emplace(e,i,r,s,l){let u=4*e;return this.int16[u+0]=i,this.int16[u+1]=r,this.uint16[u+2]=s,this.uint16[u+3]=l,e}}Ba.prototype.bytesPerElement=8,Qe(Ba,"StructArrayLayout2i2ui8");class Do extends _i{_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[1*e+0]=i,e}}Do.prototype.bytesPerElement=4,Qe(Do,"StructArrayLayout1f4");class no extends _i{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(e,i,r){let s=this.length;return this.resize(s+1),this.emplace(s,e,i,r)}emplace(e,i,r,s){let l=4*e,u=2*e;return this.int16[l+0]=i,this.int16[l+1]=r,this.float32[u+1]=s,e}}no.prototype.bytesPerElement=8,Qe(no,"StructArrayLayout2i1f8");class nh extends _i{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(e,i,r){let s=this.length;return this.resize(s+1),this.emplace(s,e,i,r)}emplace(e,i,r,s){let l=4*e;return this.int16[l+0]=i,this.int16[l+1]=r,this.int16[l+2]=s,e}}nh.prototype.bytesPerElement=8,Qe(nh,"StructArrayLayout3i8");class Hc extends _i{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(e,i,r,s){let l=this.length;return this.resize(l+1),this.emplace(l,e,i,r,s)}emplace(e,i,r,s,l){let u=4*e;return this.int16[u+0]=i,this.int16[u+1]=r,this.int16[u+2]=s,this.int16[u+3]=l,e}}Hc.prototype.bytesPerElement=8,Qe(Hc,"StructArrayLayout4i8");class Ud extends _i{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(e,i,r,s,l){let u=this.length;return this.resize(u+1),this.emplace(u,e,i,r,s,l)}emplace(e,i,r,s,l,u){let p=5*e;return this.int16[p+0]=i,this.int16[p+1]=r,this.int16[p+2]=s,this.int16[p+3]=l,this.int16[p+4]=u,e}}Ud.prototype.bytesPerElement=10,Qe(Ud,"StructArrayLayout5i10");class Vd extends _i{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(e,i,r,s,l,u,p){let f=this.length;return this.resize(f+1),this.emplace(f,e,i,r,s,l,u,p)}emplace(e,i,r,s,l,u,p,f){let g=6*e,x=12*e,b=3*e;return this.int16[g+0]=i,this.int16[g+1]=r,this.uint8[x+4]=s,this.uint8[x+5]=l,this.uint8[x+6]=u,this.uint8[x+7]=p,this.float32[b+2]=f,e}}Vd.prototype.bytesPerElement=12,Qe(Vd,"StructArrayLayout2i4ub1f12");class Br extends _i{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(e,i,r){let s=this.length;return this.resize(s+1),this.emplace(s,e,i,r)}emplace(e,i,r,s){let l=3*e;return this.float32[l+0]=i,this.float32[l+1]=r,this.float32[l+2]=s,e}}Br.prototype.bytesPerElement=12,Qe(Br,"StructArrayLayout3f12");class Us extends _i{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(e,i,r,s,l){let u=this.length;return this.resize(u+1),this.emplace(u,e,i,r,s,l)}emplace(e,i,r,s,l,u){let p=6*e,f=3*e;return this.uint16[p+0]=i,this.uint16[p+1]=r,this.uint16[p+2]=s,this.uint16[p+3]=l,this.float32[f+2]=u,e}}Us.prototype.bytesPerElement=12,Qe(Us,"StructArrayLayout4ui1f12");class Al extends _i{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(e,i,r,s){let l=this.length;return this.resize(l+1),this.emplace(l,e,i,r,s)}emplace(e,i,r,s,l){let u=4*e;return this.uint16[u+0]=i,this.uint16[u+1]=r,this.uint16[u+2]=s,this.uint16[u+3]=l,e}}Al.prototype.bytesPerElement=8,Qe(Al,"StructArrayLayout4ui8");class rh extends _i{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(e,i,r,s,l,u){let p=this.length;return this.resize(p+1),this.emplace(p,e,i,r,s,l,u)}emplace(e,i,r,s,l,u,p){let f=6*e;return this.int16[f+0]=i,this.int16[f+1]=r,this.int16[f+2]=s,this.int16[f+3]=l,this.int16[f+4]=u,this.int16[f+5]=p,e}}rh.prototype.bytesPerElement=12,Qe(rh,"StructArrayLayout6i12");class jd extends _i{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(e,i,r,s,l,u,p,f,g,x,b,w){let S=this.length;return this.resize(S+1),this.emplace(S,e,i,r,s,l,u,p,f,g,x,b,w)}emplace(e,i,r,s,l,u,p,f,g,x,b,w,S){let E=12*e;return this.int16[E+0]=i,this.int16[E+1]=r,this.int16[E+2]=s,this.int16[E+3]=l,this.uint16[E+4]=u,this.uint16[E+5]=p,this.uint16[E+6]=f,this.uint16[E+7]=g,this.int16[E+8]=x,this.int16[E+9]=b,this.int16[E+10]=w,this.int16[E+11]=S,e}}jd.prototype.bytesPerElement=24,Qe(jd,"StructArrayLayout4i4ui4i24");class Gd extends _i{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(e,i,r,s,l,u){let p=this.length;return this.resize(p+1),this.emplace(p,e,i,r,s,l,u)}emplace(e,i,r,s,l,u,p){let f=10*e,g=5*e;return this.int16[f+0]=i,this.int16[f+1]=r,this.int16[f+2]=s,this.float32[g+2]=l,this.float32[g+3]=u,this.float32[g+4]=p,e}}Gd.prototype.bytesPerElement=20,Qe(Gd,"StructArrayLayout3i3f20");class Vs extends _i{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(e,i,r,s){let l=this.length;return this.resize(l+1),this.emplace(l,e,i,r,s)}emplace(e,i,r,s,l){let u=4*e;return this.float32[u+0]=i,this.float32[u+1]=r,this.float32[u+2]=s,this.float32[u+3]=l,e}}Vs.prototype.bytesPerElement=16,Qe(Vs,"StructArrayLayout4f16");class oh extends _i{_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[1*e+0]=i,e}}oh.prototype.bytesPerElement=4,Qe(oh,"StructArrayLayout1ul4");class kr extends _i{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(e,i){let r=this.length;return this.resize(r+1),this.emplace(r,e,i)}emplace(e,i,r){let s=2*e;return this.uint16[s+0]=i,this.uint16[s+1]=r,e}}kr.prototype.bytesPerElement=4,Qe(kr,"StructArrayLayout2ui4");class Ml extends _i{_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,s,l,u,p,f,g,x,b,w,S){let E=this.length;return this.resize(E+1),this.emplace(E,e,i,r,s,l,u,p,f,g,x,b,w,S)}emplace(e,i,r,s,l,u,p,f,g,x,b,w,S,E){let M=20*e,C=10*e;return this.int16[M+0]=i,this.int16[M+1]=r,this.int16[M+2]=s,this.int16[M+3]=l,this.int16[M+4]=u,this.float32[C+3]=p,this.float32[C+4]=f,this.float32[C+5]=g,this.float32[C+6]=x,this.int16[M+14]=b,this.uint32[C+8]=w,this.uint16[M+18]=S,this.uint16[M+19]=E,e}}Ml.prototype.bytesPerElement=40,Qe(Ml,"StructArrayLayout5i4f1i1ul2ui40");class sh extends _i{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(e,i,r,s,l,u,p){let f=this.length;return this.resize(f+1),this.emplace(f,e,i,r,s,l,u,p)}emplace(e,i,r,s,l,u,p,f){let g=8*e;return this.int16[g+0]=i,this.int16[g+1]=r,this.int16[g+2]=s,this.int16[g+4]=l,this.int16[g+5]=u,this.int16[g+6]=p,this.int16[g+7]=f,e}}sh.prototype.bytesPerElement=16,Qe(sh,"StructArrayLayout3i2i2i16");class $d extends _i{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(e,i,r,s,l){let u=this.length;return this.resize(u+1),this.emplace(u,e,i,r,s,l)}emplace(e,i,r,s,l,u){let p=4*e,f=8*e;return this.float32[p+0]=i,this.float32[p+1]=r,this.float32[p+2]=s,this.int16[f+6]=l,this.int16[f+7]=u,e}}$d.prototype.bytesPerElement=16,Qe($d,"StructArrayLayout2f1f2i16");class Ro extends _i{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(e,i,r,s,l,u){let p=this.length;return this.resize(p+1),this.emplace(p,e,i,r,s,l,u)}emplace(e,i,r,s,l,u,p){let f=20*e,g=5*e;return this.uint8[f+0]=i,this.uint8[f+1]=r,this.float32[g+1]=s,this.float32[g+2]=l,this.float32[g+3]=u,this.float32[g+4]=p,e}}Ro.prototype.bytesPerElement=20,Qe(Ro,"StructArrayLayout2ub4f20");class Xi extends _i{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(e,i,r){let s=this.length;return this.resize(s+1),this.emplace(s,e,i,r)}emplace(e,i,r,s){let l=3*e;return this.uint16[l+0]=i,this.uint16[l+1]=r,this.uint16[l+2]=s,e}}Xi.prototype.bytesPerElement=6,Qe(Xi,"StructArrayLayout3ui6");class js extends _i{_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,s,l,u,p,f,g,x,b,w,S,E,M,C,R,F,z,j,$){let H=this.length;return this.resize(H+1),this.emplace(H,e,i,r,s,l,u,p,f,g,x,b,w,S,E,M,C,R,F,z,j,$)}emplace(e,i,r,s,l,u,p,f,g,x,b,w,S,E,M,C,R,F,z,j,$,H){let ie=30*e,W=15*e,Q=60*e;return this.int16[ie+0]=i,this.int16[ie+1]=r,this.int16[ie+2]=s,this.float32[W+2]=l,this.float32[W+3]=u,this.uint16[ie+8]=p,this.uint16[ie+9]=f,this.uint32[W+5]=g,this.uint32[W+6]=x,this.uint32[W+7]=b,this.uint16[ie+16]=w,this.uint16[ie+17]=S,this.uint16[ie+18]=E,this.float32[W+10]=M,this.float32[W+11]=C,this.uint8[Q+48]=R,this.uint8[Q+49]=F,this.uint8[Q+50]=z,this.uint32[W+13]=j,this.int16[ie+28]=$,this.uint8[Q+58]=H,e}}js.prototype.bytesPerElement=60,Qe(js,"StructArrayLayout3i2f2ui3ul3ui2f3ub1ul1i1ub60");class Hd extends _i{_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,s,l,u,p,f,g,x,b,w,S,E,M,C,R,F,z,j,$,H,ie,W,Q,Y,ee,me,ge,Te,Ae,Ee,Be){let xe=this.length;return this.resize(xe+1),this.emplace(xe,e,i,r,s,l,u,p,f,g,x,b,w,S,E,M,C,R,F,z,j,$,H,ie,W,Q,Y,ee,me,ge,Te,Ae,Ee,Be)}emplace(e,i,r,s,l,u,p,f,g,x,b,w,S,E,M,C,R,F,z,j,$,H,ie,W,Q,Y,ee,me,ge,Te,Ae,Ee,Be,xe){let Se=20*e,Me=40*e,ze=80*e;return this.float32[Se+0]=i,this.float32[Se+1]=r,this.int16[Me+4]=s,this.int16[Me+5]=l,this.int16[Me+6]=u,this.int16[Me+7]=p,this.int16[Me+8]=f,this.int16[Me+9]=g,this.int16[Me+10]=x,this.int16[Me+11]=b,this.int16[Me+12]=w,this.uint16[Me+13]=S,this.uint16[Me+14]=E,this.uint16[Me+15]=M,this.uint16[Me+16]=C,this.uint16[Me+17]=R,this.uint16[Me+18]=F,this.uint16[Me+19]=z,this.uint16[Me+20]=j,this.uint16[Me+21]=$,this.uint16[Me+22]=H,this.uint16[Me+23]=ie,this.uint16[Me+24]=W,this.uint16[Me+25]=Q,this.uint16[Me+26]=Y,this.uint16[Me+27]=ee,this.uint32[Se+14]=me,this.float32[Se+15]=ge,this.float32[Se+16]=Te,this.float32[Se+17]=Ae,this.float32[Se+18]=Ee,this.uint8[ze+76]=Be,this.uint16[Me+39]=xe,e}}Hd.prototype.bytesPerElement=80,Qe(Hd,"StructArrayLayout2f9i15ui1ul4f1ub1ui80");class qd extends _i{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(e,i,r,s,l,u){let p=this.length;return this.resize(p+1),this.emplace(p,e,i,r,s,l,u)}emplace(e,i,r,s,l,u,p){let f=6*e;return this.float32[f+0]=i,this.float32[f+1]=r,this.float32[f+2]=s,this.float32[f+3]=l,this.float32[f+4]=u,this.float32[f+5]=p,e}}qd.prototype.bytesPerElement=24,Qe(qd,"StructArrayLayout6f24");class ka extends _i{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(e,i,r,s,l){let u=this.length;return this.resize(u+1),this.emplace(u,e,i,r,s,l)}emplace(e,i,r,s,l,u){let p=5*e;return this.float32[p+0]=i,this.float32[p+1]=r,this.float32[p+2]=s,this.float32[p+3]=l,this.float32[p+4]=u,e}}ka.prototype.bytesPerElement=20,Qe(ka,"StructArrayLayout5f20");class Zd extends _i{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(e,i,r,s,l,u,p){let f=this.length;return this.resize(f+1),this.emplace(f,e,i,r,s,l,u,p)}emplace(e,i,r,s,l,u,p,f){let g=7*e;return this.float32[g+0]=i,this.float32[g+1]=r,this.float32[g+2]=s,this.float32[g+3]=l,this.float32[g+4]=u,this.float32[g+5]=p,this.float32[g+6]=f,e}}Zd.prototype.bytesPerElement=28,Qe(Zd,"StructArrayLayout7f28");class Wd extends _i{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(e,i,r,s,l,u,p,f,g,x,b){let w=this.length;return this.resize(w+1),this.emplace(w,e,i,r,s,l,u,p,f,g,x,b)}emplace(e,i,r,s,l,u,p,f,g,x,b,w){let S=11*e;return this.float32[S+0]=i,this.float32[S+1]=r,this.float32[S+2]=s,this.float32[S+3]=l,this.float32[S+4]=u,this.float32[S+5]=p,this.float32[S+6]=f,this.float32[S+7]=g,this.float32[S+8]=x,this.float32[S+9]=b,this.float32[S+10]=w,e}}Wd.prototype.bytesPerElement=44,Qe(Wd,"StructArrayLayout11f44");class hr extends _i{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(e,i,r,s,l,u,p,f,g){let x=this.length;return this.resize(x+1),this.emplace(x,e,i,r,s,l,u,p,f,g)}emplace(e,i,r,s,l,u,p,f,g,x){let b=9*e;return this.float32[b+0]=i,this.float32[b+1]=r,this.float32[b+2]=s,this.float32[b+3]=l,this.float32[b+4]=u,this.float32[b+5]=p,this.float32[b+6]=f,this.float32[b+7]=g,this.float32[b+8]=x,e}}hr.prototype.bytesPerElement=36,Qe(hr,"StructArrayLayout9f36");class nr extends _i{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(e,i){let r=this.length;return this.resize(r+1),this.emplace(r,e,i)}emplace(e,i,r){let s=2*e;return this.float32[s+0]=i,this.float32[s+1]=r,e}}nr.prototype.bytesPerElement=8,Qe(nr,"StructArrayLayout2f8");class ah extends _i{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint32=new Uint32Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(e,i,r,s){let l=this.length;return this.resize(l+1),this.emplace(l,e,i,r,s)}emplace(e,i,r,s,l){let u=6*e;return this.uint32[3*e+0]=i,this.uint16[u+2]=r,this.uint16[u+3]=s,this.uint16[u+4]=l,e}}ah.prototype.bytesPerElement=12,Qe(ah,"StructArrayLayout1ul3ui12");class Cl extends _i{_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[1*e+0]=i,e}}Cl.prototype.bytesPerElement=2,Qe(Cl,"StructArrayLayout1ui2");class Pl extends _i{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(e,i,r,s,l,u,p,f,g,x,b,w,S,E,M,C){let R=this.length;return this.resize(R+1),this.emplace(R,e,i,r,s,l,u,p,f,g,x,b,w,S,E,M,C)}emplace(e,i,r,s,l,u,p,f,g,x,b,w,S,E,M,C,R){let F=16*e;return this.float32[F+0]=i,this.float32[F+1]=r,this.float32[F+2]=s,this.float32[F+3]=l,this.float32[F+4]=u,this.float32[F+5]=p,this.float32[F+6]=f,this.float32[F+7]=g,this.float32[F+8]=x,this.float32[F+9]=b,this.float32[F+10]=w,this.float32[F+11]=S,this.float32[F+12]=E,this.float32[F+13]=M,this.float32[F+14]=C,this.float32[F+15]=R,e}}Pl.prototype.bytesPerElement=64,Qe(Pl,"StructArrayLayout16f64");class Dl extends _i{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(e,i,r,s,l,u,p){let f=this.length;return this.resize(f+1),this.emplace(f,e,i,r,s,l,u,p)}emplace(e,i,r,s,l,u,p,f){let g=10*e,x=5*e;return this.uint16[g+0]=i,this.uint16[g+1]=r,this.uint16[g+2]=s,this.uint16[g+3]=l,this.float32[x+2]=u,this.float32[x+3]=p,this.float32[x+4]=f,e}}Dl.prototype.bytesPerElement=20,Qe(Dl,"StructArrayLayout4ui3f20");class Rl extends _i{_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[1*e+0]=i,e}}Rl.prototype.bytesPerElement=2,Qe(Rl,"StructArrayLayout1i2");class zl extends _i{_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[1*e+0]=i,e}}zl.prototype.bytesPerElement=1,Qe(zl,"StructArrayLayout1ub1");class Xd extends $c{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]}}Xd.prototype.size=40;class qc extends Ml{get(e){return new Xd(this,e)}}Qe(qc,"CollisionBoxArray");class Ll extends $c{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]}
vendor: 5,877 bytes, line 7
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}}Ll.prototype.size=60;class Yd extends js{get(e){return new Ll(this,e)}}Qe(Yd,"PlacedSymbolArray");class cm extends $c{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]}}cm.prototype.size=80;class um extends Hd{get(e){return new cm(this,e)}}Qe(um,"SymbolInstanceArray");class Jd extends Do{getoffsetX(e){return this.float32[1*e+0]}}Qe(Jd,"GlyphOffsetArray");class hm extends Hn{getx(e){return this.int16[2*e+0]}gety(e){return this.int16[2*e+1]}}Qe(hm,"SymbolLineVertexArray");class vo extends $c{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]}}vo.prototype.size=12;class dm extends ah{get(e){return new vo(this,e)}}Qe(dm,"FeatureIndexArray");class Kd extends kr{geta_centroid_pos0(e){return this.uint16[2*e+0]}geta_centroid_pos1(e){return this.uint16[2*e+1]}}Qe(Kd,"FillExtrusionCentroidArray");class pm extends $c{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]}}pm.prototype.size=6;class fm extends Ns{get(e){return new pm(this,e)}}Qe(fm,"FillExtrusionWallArray");let lg=Ct([{name:"a_pos",components:2,type:"Int16"}],4),cg=Ct([{name:"a_circle_z_offset",components:1,type:"Float32"}],4),ug=Ct([{name:"a_pos_3",components:3,type:"Int16"},{name:"a_pos_normal_3",components:3,type:"Int16"}]);class pi{constructor(e=[]){this.segments=e}_prepareSegment(e,i,r,s,l){let u=this.segments.at(-1);return e>pi.MAX_VERTEX_ARRAY_LENGTH&&Ot(`Max vertices per segment is ${pi.MAX_VERTEX_ARRAY_LENGTH}: bucket requested ${e}`),(!u||u.vertexLength+e>pi.MAX_VERTEX_ARRAY_LENGTH||u.sortKey!==s||l!==void 0&&u&&u.batchIndex!==void 0&&u.batchIndex!==l)&&(u={vertexOffset:i,primitiveOffset:r,vertexLength:0,primitiveLength:0},s!==void 0&&(u.sortKey=s),l!==void 0&&(u.batchIndex=l),this.segments.push(u)),u}prepareSegment(e,i,r,s,l){return this._prepareSegment(e,i.length,r.length,s,l)}get(){return this.segments}destroy(){for(let e of this.segments)for(let i in e.vaos)e.vaos[i].destroy()}
7static simpleSegment(e,i,r,s){return new pi([{vertexOffset:e,primitiveOffset:i,vertexLength:r,primitiveLength:s,vaos:{},sortKey:0}])}}function Ol(n,e){return 256*(n=ne(Math.floor(n),0,255))+ne(Math.floor(e),0,255)}pi.MAX_VERTEX_ARRAY_LENGTH=Math.pow(2,16)-1,Qe(pi,"SegmentVector");let hg=Ct([{name:"a_pattern",components:4,type:"Uint16"},{name:"a_pixel_ratio",components:1,type:"Float32"}]),lh=Ct([{name:"a_pattern_b",components:4,type:"Uint16"}]),Qd=Ct([{name:"a_dash",components:4,type:"Uint16"}]);class Fl{constructor(){this.ids=[],this.uniqueIds=[],this.positions=[],this.indexed=!1}add(e,i,r,s){this.ids.push(ep(e)),this.positions.push(i,r,s)}eachPosition(e,i){let r=ep(e),s=0,l=this.ids.length-1;for(;s<l;){let u=s+l>>1;this.ids[u]>=r?l=u:s=u+1}for(;this.ids[s]===r;)i(this.positions[3*s],this.positions[3*s+1],this.positions[3*s+2]),s++}static serialize(e,i){let r=new Float64Array(e.ids),s=new Uint32Array(e.positions);return tp(r,s,0,r.length-1),i&&(i.add(r.buffer),i.add(s.buffer)),{ids:r,positions:s}}static deserialize(e){let i=new Fl,r;i.ids=e.ids,i.positions=e.positions;for(let s of i.ids)s!==r&&i.uniqueIds.push(s),r=s;return i.indexed=!0,i}}function ep(n){let e=+n;return Number.isSafeInteger(e)?e:fc(String(n))}function tp(n,e,i,r){for(;i<r;){let s=n[i+r>>1],l=i-1,u=r+1;for(;;){do l++;while(n[l]<s);do u--;while(n[u]>s);if(l>=u)break;Zc(n,l,u),Zc(e,3*l,3*u),Zc(e,3*l+1,3*u+1),Zc(e,3*l+2,3*u+2)}u-i<r-u?(tp(n,e,i,u),i=u+1):(tp(n,e,u+1,r),r=u)}}function Zc(n,e,i){let r=n[e];n[e]=n[i],n[i]=r}Qe(Fl,"FeaturePositionMap");class zo{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 new Error("Uniform#set() must be implemented by each concrete Uniform")}}class ch extends zo{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 an extends zo{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 dr extends zo{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 Wc extends zo{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 dg extends zo{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.uniform4ui(this.location,r[0],r[1],r[2],r[3])))}}class ip extends zo{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 mm extends zo{constructor(e){super(e),this.current=jt.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)))}}class Xc extends zo{constructor(e){super(e),this.current=new Float32Array(16)}set(e,i,r){if(!this.fetchUniformLocation(e,i))return;let s=this.current;if(r[12]!==s[12]||r[0]!==s[0])return s.set(r),void this.gl.uniformMatrix4fv(this.location,!1,s);for(let l=1;l<16;l++)if(r[l]!==s[l]){s.set(r),this.gl.uniformMatrix4fv(this.location,!1,s);break}}}class Bl extends zo{constructor(e){super(e),this.current=new Float32Array(4)}set(e,i,r){if(!this.fetchUniformLocation(e,i))return;let s=this.current;for(let l=0;l<4;l++)if(r[l]!==s[l]){s.set(r),this.gl.uniformMatrix2fv(this.location,!1,s);break}}}function kl(n){return[Ol(255*n.r,255*n.g),Ol(255*n.b,255*n.a)]}function rr(n,e,i,r,s,l,u,p){return!!n&&(n.kind==="composite"||n.kind==="source"?n.evaluate(new Xt(0,{brightness:l,worldview:p}),e,i,s,r,u)==="none":n.value==="none")}
7class Na{constructor(e,i,r,s){this.value=e,this.uniformNames=i.map(l=>`u_${l}`),this.type=r,this.context=s}setUniform(e,i,r,s,l){let u=s.constantOr(this.value);i.set(e,l,u instanceof jt?u.toPremultipliedRenderColor(this.lutExpression&&this.lutExpression.kind==="constant"&&this.lutExpression.value==="none"?null:this.context.lut):u)}getBinding(e,i){return this.type==="color"?new mm(e):new an(e)}}class Yc{constructor(e,i){this.uniformNames=i.map(r=>`u_${r}`),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,s,l){let u=null;l!=="u_pattern"&&l!=="u_dash"||(u=this.pattern),l==="u_pattern_b"&&(u=this.patternTransition),l==="u_pixel_ratio"&&(u=this.pixelRatio),u&&i.set(e,l,u)}getBinding(e,i){return i==="u_pattern"||i==="u_pattern_b"||i==="u_dash"?new dg(e):new an(e)}}class ts{constructor(e,i,r,s){this.expression=e,this.type=r,this.maxValue=0,this.paintVertexAttributes=i.map(l=>({name:`a_${l}`,type:"Float32",components:r==="color"?2:1,offset:0})),this.paintVertexArray=new s}populatePaintArray(e,i,r,s,l,u,p,f){let g=this.paintVertexArray.length,x=this.expression.kind==="composite"||this.expression.kind==="source"?this.expression.evaluate(new Xt(0,{brightness:u,worldview:f}),i,{},l,s,p):this.expression.kind==="constant"&&this.expression.value,b=rr(this.lutExpression,i,{},s,l,u,p,f);this.paintVertexArray.resize(e),this._setPaintValue(g,e,x,b?null:this.context.lut)}updatePaintArray(e,i,r,s,l,u,p,f){let g=this.expression.kind==="composite"||this.expression.kind==="source"?this.expression.evaluate({zoom:0,brightness:p,worldview:f},r,s,void 0,l):this.expression.kind==="constant"&&this.expression.value,x=rr(this.lutExpression,r,s,l,void 0,p,void 0,f);this._setPaintValue(e,i,g,x?null:this.context.lut)}_setPaintValue(e,i,r,s){if(this.type==="color"){let l=kl(r.toPremultipliedRenderColor(s));for(let u=e;u<i;u++)this.paintVertexArray.emplace(u,l[0],l[1])}else{for(let l=e;l<i;l++)this.paintVertexArray.emplace(l,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&&this.lutExpression.kind!=="constant"&&(this.lutExpression.isStateDependent||!this.lutExpression.isLightConstant)||this.expression.kind!=="constant"&&(this.expression.isStateDependent||!this.expression.isLightConstant)))}destroy(){this.paintVertexBuffer&&this.paintVertexBuffer.destroy()}}class Lo{constructor(e,i,r,s,l,u){this.expression=e,this.uniformNames=i.map(p=>`u_${p}_t`),this.type=r,this.useIntegerZoom=s,this.context=l,this.maxValue=0,this.paintVertexAttributes=i.map(p=>({name:`a_${p}`,type:"Float32",components:r==="color"?4:2,offset:0})),this.paintVertexArray=new u}populatePaintArray(e,i,r,s,l,u,p,f){let g=this.expression.evaluate(new Xt(this.context.zoom,{brightness:u,worldview:f}),i,{},l,s,p),x=this.expression.evaluate(new Xt(this.context.zoom+1,{brightness:u,worldview:f}),i,{},l,s,p),b=rr(this.lutExpression,i,{},s,l,u,p,f),w=this.paintVertexArray.length;this.paintVertexArray.resize(e),this._setPaintValue(w,e,g,x,b?null:this.context.lut)}updatePaintArray(e,i,r,s,l,u,p,f){let g=this.expression.evaluate({zoom:this.context.zoom,brightness:p,worldview:f},r,s,void 0,l),x=this.expression.evaluate({zoom:this.context.zoom+1,brightness:p,worldview:f},r,s,void 0,l),b=rr(this.lutExpression,r,s,l,void 0,p,void 0,f);this._setPaintValue(e,i,g,x,b?null:this.context.lut)}_setPaintValue(e,i,r,s,l){if(this.type==="color"){let u=kl(r.toPremultipliedRenderColor(l)),p=kl(s.toPremultipliedRenderColor(l));for(let f=e;f<i;f++)this.paintVertexArray.emplace(f,u[0],u[1],p[0],p[1])}else{for(let u=e;u<i;u++)this.paintVertexArray.emplace(u,r,s);this.maxValue=Math.max(this.maxValue,Math.abs(r),Math.abs(s))}}upload(e){this.paintVertexArray&&this.paintVertexArray.arrayBuffer&&(this.paintVertexBuffer&&this.paintVertexBuffer.buffer?this.paintVertexBuffer.updateData(this.paintVertexArray):this.paintVertexBuffer=e.createVertexBuffer(this.paintVertexArray,this.paintVertexAttributes,this.expression.isStateDependent||!this.expression.isLightConstant))}destroy(){this.paintVertexBuffer&&this.paintVertexBuffer.destroy()}setUniform(e,i,r,s,l){let u=this.useIntegerZoom?Math.floor(r.zoom):r.zoom,p=ne(this.expression.interpolationFactor(u,this.context.zoom,this.context.zoom+1),0,1);i.set(e,l,p)}getBinding(e,i){return new an(e)}}class Oo{constructor(e,i,r,s,l){this.expression=e,this.layerId=l,this.paintVertexAttributes=(r==="array"?Qd:hg).members;for(let u=0;u<i.length;++u);this.paintVertexArray=new s,this.paintTransitionVertexArray=new Al}populatePaintArray(e,i,r,s){let l=this.paintVertexArray.length;this.paintVertexArray.resize(e),this._setPaintValues(l,e,i.patterns&&i.patterns[this.layerId],r)}updatePaintArray(e,i,r,s,l,u,p){this._setPaintValues(e,i,r.patterns&&r.patterns[this.layerId],u)}_setPaintValues(e,i,r,s){if(!s||!r)return;let l=s[r[0]],u=s[r[1]];if(l){if(l){let{tl:p,br:f,pixelRatio:g}=l;for(let x=e;x<i;x++)this.paintVertexArray.emplace(x,p[0],p[1],f[0],f[1],g)}if(u){this.paintTransitionVertexArray.resize(this.paintVertexArray.length);let{tl:p,br:f}=u;for(let g=e;g<i;g++)this.paintTransitionVertexArray.emplace(g,p[0],p[1],f[0],f[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,lh.members,i))}destroy(){this.paintVertexBuffer&&this.paintVertexBuffer.destroy(),this.paintTransitionVertexBuffer&&this.paintTransitionVertexBuffer.destroy()}}class is{constructor(e,i,r=()=>!0){this.binders={},this._buffers=[],this.context=i;let s=[],l=e;for(let u in e.paint._values){let p=l.paint.get(u);if(u.endsWith("-use-theme")||!r(u)||!(p instanceof Bs&&qu(p.property.specification)))continue;let f=pg(u,e.type),g=p.value,x=p.property.specification.type,b=!!p.property.useIntegerZoom,w=u==="line-dasharray"||u.endsWith("pattern"),S=l.paint.get(`${u}-use-theme`),E=u==="line-dasharray"&&l.layout.get("line-cap").value.kind!=="constant"||S&&S.value.kind!=="constant";if(g.kind!=="constant"||E)if(g.kind==="source"||E||w){let M=_m(u,x,"source");this.binders[u]=w?new Oo(g,f,x,M,e.id):new ts(g,f,x,M),s.push(`/a_${u}`)}else{let M=_m(u,x,"composite");this.binders[u]=new Lo(g,f,x,b,i,M),s.push(`/z_${u}`)}else this.binders[u]=w?new Yc(g.value,f):new Na(g.value,f,x,i),s.push(`/u_${u}`);S&&(this.binders[u].lutExpression=S.value)}this.cacheKey=s.sort().join("")}updateExpressions(e){let i=e;for(let r in this.binders){let s=this.binders[r];if(s instanceof ts||s instanceof Lo||s instanceof Oo){let l=i.paint.get(r);s.expression=l.value}}}getMaxValue(e){let i=this.binders[e];return i instanceof ts||i instanceof Lo?i.maxValue:0}populatePaintArrays(e,i,r,s,l,u,p,f){for(let g in this.binders){let x=this.binders[g];x.context=this.context,(x instanceof ts||x instanceof Lo||x instanceof Oo)&&x.populatePaintArray(e,i,r,s,l,u,p,f)}}setConstantPatternPositions(e,i){for(let r in this.binders){let s=this.binders[r];s instanceof Yc&&s.setConstantPatternPositions(e,i)}}getPatternTransitionVertexBuffer(e){let i=this.binders[e];return i instanceof Oo?i.paintTransitionVertexBuffer:null}updatePaintArrays(e,i,r,s,l,u,p,f,g,x){let b=!1,w=Object.keys(e),S=w.length!==0&&!f,E=S?w:i.uniqueIds;this.context.lut=l.lut;for(let M in this.binders){let C=this.binders[M];if(C.context=this.context,(C instanceof ts||C instanceof Lo||C instanceof Oo)&&C.expression&&C.expression.kind&&C.expression.kind!=="constant"&&(C.expression.isStateDependent===!0||C.expression.isLightConstant===!1)){let R=l.paint.get(M);C.expression=R.value;for(let F of E){let z=e[F.toString()];i.eachPosition(F,(j,$,H)=>{let ie=s.feature(j);C.updatePaintArray($,H,ie,z,u,p,g,x)})}if(!S)for(let F of r.uniqueIds){let z=e[F.toString()];r.eachPosition(F,(j,$,H)=>{let ie=s.feature(j);C.updatePaintArray($,H,ie,z,u,p,g,x)})}b=!0}}return b}
7defines(){let e=[];for(let i in this.binders){let r=this.binders[i];(r instanceof Na||r instanceof Yc)&&e.push(...r.uniformNames.map(s=>`#define HAS_UNIFORM_${s}`))}return e}getPaintVertexBuffers(){return this._buffers}getUniforms(e){let i=[];for(let r in this.binders){let s=this.binders[r];if(s instanceof Na||s instanceof Yc||s instanceof Lo)for(let l of s.uniformNames)i.push({name:l,property:r,binding:s.getBinding(e,l)})}return i}setUniforms(e,i,r,s,l){for(let{name:u,property:p,binding:f}of r)this.binders[p].setUniform(e,f,l,s.get(p),u)}updatePaintBuffers(){this._buffers=[];for(let e in this.binders){let i=this.binders[e];(i instanceof ts||i instanceof Lo||i instanceof Oo)&&i.paintVertexBuffer&&this._buffers.push(i.paintVertexBuffer),i instanceof Oo&&i.paintTransitionVertexBuffer&&this._buffers.push(i.paintTransitionVertexBuffer)}}upload(e){for(let i in this.binders){let r=this.binders[i];(r instanceof ts||r instanceof Lo||r instanceof Oo)&&r.upload(e)}this.updatePaintBuffers()}destroy(){for(let e in this.binders){let i=this.binders[e];(i instanceof ts||i instanceof Lo||i instanceof Oo)&&i.destroy()}}}class bo{constructor(e,i,r=()=>!0){this.programConfigurations={};for(let s of e)this.programConfigurations[s.id]=new is(s,i,r);this.needsUpload=!1,this._featureMap=new Fl,this._featureMapWithoutIds=new Fl,this._bufferOffset=0,this._idlessCounter=0}populatePaintArrays(e,i,r,s,l,u,p,f,g){for(let x in this.programConfigurations)this.programConfigurations[x].populatePaintArrays(e,i,s,l,u,p,f,g);i.id!==void 0?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,s,l,u,p,f){for(let g of r)this.needsUpload=this.programConfigurations[g.id].updatePaintArrays(e,this._featureMap,this._featureMapWithoutIds,i,g,s,l,u,p||0,f)||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()}updateExpressions(e){let i=new Set;for(let r of e){let s=this.programConfigurations[r.id];s&&(s.updateExpressions(r),i.add(r.id))}for(let r in this.programConfigurations)i.has(r)||delete this.programConfigurations[r]}}let np={"text-opacity":["opacity"],"icon-opacity":["opacity"],"text-occlusion-opacity":["occlusion_opacity"],"icon-occlusion-opacity":["occlusion_opacity"],"text-color":["fill_color"],"icon-color":["fill_color"],"text-emissive-strength":["emissive_strength"],"icon-emissive-strength":["emissive_strength"],"text-halo-color":["halo_color"],"icon-halo-color":["halo_color"],"text-halo-blur":["halo_blur"],"icon-halo-blur":["halo_blur"],"text-halo-width":["halo_width"],"icon-halo-width":["halo_width"],"symbol-z-offset":["z_offset"],"line-gap-width":["gapwidth"],"line-pattern":["pattern","pixel_ratio","pattern_b"],"fill-pattern":["pattern","pixel_ratio","pattern_b"],"fill-extrusion-pattern":["pattern","pixel_ratio","pattern_b"],"line-dasharray":["dash"],"fill-bridge-guard-rail-color":["structure_color"],"fill-tunnel-structure-color":["structure_color"]};function pg(n,e){return np[n]||[n.replace(`${e}-`,"").replace(/-/g,"_")]}let fg={"line-pattern":{source:Us,composite:Us},"fill-pattern":{source:Us,composite:Us},"fill-extrusion-pattern":{source:Us,composite:Us},"line-dasharray":{source:Al,composite:Al}},mg={color:{source:nr,composite:Vs},number:{source:Do,composite:nr}};function _m(n,e,i){let r=fg[n];return r&&r[i]||mg[e][i]}Qe(Na,"ConstantBinder"),Qe(Yc,"PatternConstantBinder"),Qe(ts,"SourceExpressionBinder",{omit:["expression"]}),Qe(Oo,"PatternCompositeBinder",{omit:["expression"]}),Qe(Lo,"CompositeExpressionBinder",{omit:["expression"]}),Qe(is,"ProgramConfiguration",{omit:["_buffers"]}),Qe(bo,"ProgramConfigurationSet");let Jn=Xe/Math.PI/2,Gs=64,rp=[Gs,32,16],Nr=-Jn,Ur=Jn;function Nl(n,e,i,r=Jn){return i=V(i),[n*Math.sin(i)*r,-e*r,n*Math.cos(i)*r]}function ns(n,e,i){return Nl(Math.cos(V(n)),Math.sin(V(n)),e,i)}let rs=63710088e-1,uh=2*Math.PI*rs;
7class Yt{constructor(e,i){if(isNaN(e)||isNaN(i))throw new Error(`Invalid LngLat object: (${e}, ${i})`);if(this.lng=+e,this.lat=+i,this.lat>90||this.lat<-90)throw new Error("Invalid LngLat latitude value: must be between -90 and 90")}wrap(){return new Yt(Ne(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,s=e.lat*i,l=Math.sin(r)*Math.sin(s)+Math.cos(r)*Math.cos(s)*Math.cos((e.lng-this.lng)*i);return rs*Math.acos(Math.min(l,1))}toBounds(e=0){let i=360*e/40075017,r=i/Math.cos(Math.PI/180*this.lat);return new os({lng:this.lng-r,lat:this.lat-i},{lng:this.lng+r,lat:this.lat+i})}toEcef(e){return ns(this.lat,this.lng,Jn+e*Jn/rs)}static convert(e){if(e instanceof Yt)return e;if(Array.isArray(e)&&(e.length===2||e.length===3))return new Yt(Number(e[0]),Number(e[1]));if(!Array.isArray(e)&&typeof e=="object"&&e!==null)return new Yt(Number("lng"in e?e.lng:e.lon),Number(e.lat));throw new Error("`LngLatLike` argument must be specified as a LngLat instance, an object {lng: <lng>, lat: <lat>}, an object {lon: <lng>, lat: <lat>}, or an array of [<lng>, <lat>]")}}class os{constructor(e,i){e&&(i?this.setSouthWest(e).setNorthEast(i):Array.isArray(e)&&e.length===4?this.setSouthWest([e[0],e[1]]).setNorthEast([e[2],e[3]]):this.setSouthWest(e[0]).setNorthEast(e[1]))}setNorthEast(e){return this._ne=e instanceof Yt?new Yt(e.lng,e.lat):Yt.convert(e),this}setSouthWest(e){return this._sw=e instanceof Yt?new Yt(e.lng,e.lat):Yt.convert(e),this}extend(e){let i=this._sw,r=this._ne,s,l;if(e instanceof Yt)s=e,l=e;else{if(!(e instanceof os))return Array.isArray(e)?e.length===4||e.every(Array.isArray)?this.extend(os.convert(e)):this.extend(Yt.convert(e)):typeof e=="object"&&e!==null&&Object.hasOwn(e,"lat")&&(Object.hasOwn(e,"lon")||Object.hasOwn(e,"lng"))?this.extend(Yt.convert(e)):this;if(s=e._sw,l=e._ne,!s||!l)return this}return i||r?(i.lng=Math.min(s.lng,i.lng),i.lat=Math.min(s.lat,i.lat),r.lng=Math.max(l.lng,r.lng),r.lat=Math.max(l.lat,r.lat)):(this._sw=new Yt(s.lng,s.lat),this._ne=new Yt(l.lng,l.lat)),this}getCenter(){return new Yt((this._sw.lng+this._ne.lng)/2,(this._sw.lat+this._ne.lat)/2)}getSouthWest(){return this._sw}getNorthEast(){return this._ne}getNorthWest(){return new Yt(this.getWest(),this.getNorth())}getSouthEast(){return new Yt(this.getEast(),this.getSouth())}getWest(){return this._sw.lng}getSouth(){return this._sw.lat}getEast(){return this._ne.lng}getNorth(){return this._ne.lat}toArray(){return[this._sw.toArray(),this._ne.toArray()]}toString(){return`LngLatBounds(${this._sw.toString()}, ${this._ne.toString()})`}isEmpty(){return!(this._sw&&this._ne)}contains(e){let{lng:i,lat:r}=Yt.convert(e),s=this._sw.lng<=i&&i<=this._ne.lng;return this._sw.lng>this._ne.lng&&(s=this._sw.lng>=i&&i>=this._ne.lng),this._sw.lat<=r&&r<=this._ne.lat&&s}static convert(e){if(e)return e instanceof os?e:new os(e)}}function op(n){return uh*Math.cos(n*Math.PI/180)}function wo(n){return(180+n)/360}function Fo(n){return(180-180/Math.PI*Math.log(Math.tan(Math.PI/4+n*Math.PI/360)))/360}function or(n,e){return n/op(e)}function Ir(n){return 360*n-180}function Ln(n){return 360/Math.PI*Math.atan(Math.exp((180-360*n)*Math.PI/180))-90}function hh(n,e){return n*op(Ln(e))}let Er=85.051129;function gm(n){return Math.cos(V(ne(n,-85.051129,Er)))}function Ua(n,e){let i=ne(e,0,25.5),r=Math.pow(2,i);return gm(n)*uh/(512*r)}function ym(n){return 1/Math.cos(n*Math.PI/180)}function Vr(n,e=0){let i=Math.exp(Math.PI*(1-(n.y+e/Xe)/(1<<n.z)*2));return 80150034*i/(i*i+1)/Xe/(1<<n.z)}class qn{constructor(e,i,r=0){this.x=+e,this.y=+i,this.z=+r}static fromLngLat(e,i=0){let r=Yt.convert(e);return new qn(wo(r.lng),Fo(r.lat),or(i,r.lat))}toLngLat(){return new Yt(Ir(this.x),Ln(this.y))}toAltitude(){return hh(this.z,this.y)}meterInMercatorCoordinateUnits(){return 1/uh*ym(Ln(this.y))}}function sp(n,e,i,r,s,l,u,p,f){let g=(e+r)/2,x=(i+s)/2,b=new ke(g,x);p(b),function(w,S,E,M,C,R){let F=E-C,z=M-R;return Math.abs((M-S)*F-(E-w)*z)/Math.hypot(F,z)}(b.x,b.y,l.x,l.y,u.x,u.y)>=f?(sp(n,e,i,g,x,l,b,p,f),sp(n,g,x,r,s,b,u,p,f)):n.push(u)}function xm(n,e,i){let r=n[0],s=r.x,l=r.y;e(r);let u=[r];for(let p=1;p<n.length;p++){let f=n[p],{x:g,y:x}=f;e(f),sp(u,s,l,g,x,r,f,e,i),s=g,l=x,r=f}return u}function ap(n,e,i,r){if(r(e,i)){let s=e.add(i)._mult(.5);ap(n,e,s,r),ap(n,s,i,r)}else n.push(i)}function dh(n,e){let i=n[0],r=[i];for(let s=1;s<n.length;s++){let l=n[s];ap(r,i,l,e),i=l}return r}let lp=Math.pow(2,14)-1,vm=-lp-1;function ph(n,e){let i=Math.round(n.x*e),r=Math.round(n.y*e);return n.x=ne(i,vm,lp),n.y=ne(r,vm,lp),(i<n.x||i>n.x+1||r<n.y||r>n.y+1)&&Ot("Geometry exceeds allowed extent, reduce your vector tile buffer size"),n}function jr(n,e,i){let r=n.loadGeometry(),s=n.extent,l=Xe/s;if(e&&i&&i.projection.isReprojectedInTileSpace){let u=1<<e.z,{scale:p,x:f,y:g,projection:x}=i,b=w=>{let S=Ir((e.x+w.x/s)/u),E=Ln((e.y+w.y/s)/u),M=x.project(S,E);w.x=(M.x*p-f)*s,w.y=(M.y*p-g)*s};for(let w=0;w<r.length;w++)if(n.type!==1)r[w]=xm(r[w],b,1);else{let S=[];for(let E of r[w])E.x<0||E.x>=s||E.y<0||E.y>=s||(b(E),S.push(E));r[w]=S}}for(let u of r)for(let p of u)ph(p,l);return r}function Gr(n,e){return{type:n.type,id:n.id,properties:n.properties,geometry:e?jr(n):[]}}class $s{constructor(e,i,r,s,l){this.properties={},this.extent=r,this.type=0,this.id=void 0,this._pbf=e,this._geometry=-1,this._keys=s,this._values=l,e.readFields(_g,this,i)}loadGeometry(){let e=this._pbf;e.pos=this._geometry;let i=e.readVarint()+e.pos,r=[],s,l=1,u=0,p=0,f=0;for(;e.pos<i;){if(u<=0){let g=e.readVarint();l=7&g,u=g>>3}if(u--,l===1||l===2)p+=e.readSVarint(),f+=e.readSVarint(),l===1&&(s&&r.push(s),s=[]),s&&s.push(new ke(p,f));else{if(l!==7)throw new Error(`unknown command ${l}`);
7s&&s.push(s[0].clone())}}return s&&r.push(s),r}bbox(){let e=this._pbf;e.pos=this._geometry;let i=e.readVarint()+e.pos,r=1,s=0,l=0,u=0,p=1/0,f=-1/0,g=1/0,x=-1/0;for(;e.pos<i;){if(s<=0){let b=e.readVarint();r=7&b,s=b>>3}if(s--,r===1||r===2)l+=e.readSVarint(),u+=e.readSVarint(),l<p&&(p=l),l>f&&(f=l),u<g&&(g=u),u>x&&(x=u);else if(r!==7)throw new Error(`unknown command ${r}`)}return[p,g,f,x]}toGeoJSON(e,i,r){let s=this.extent*Math.pow(2,r),l=this.extent*e,u=this.extent*i,p=this.loadGeometry();function f(w){return[360*(w.x+l)/s-180,360/Math.PI*Math.atan(Math.exp((1-2*(w.y+u)/s)*Math.PI))-90]}function g(w){return w.map(f)}let x;if(this.type===1){let w=[];for(let E of p)w.push(E[0]);let S=g(w);x=w.length===1?{type:"Point",coordinates:S[0]}:{type:"MultiPoint",coordinates:S}}else if(this.type===2){let w=p.map(g);x=w.length===1?{type:"LineString",coordinates:w[0]}:{type:"MultiLineString",coordinates:w}}else{if(this.type!==3)throw new Error("unknown feature type");{let w=function(E){let M=E.length;if(M<=1)return[E];let C=[],R,F;for(let z=0;z<M;z++){let j=bm(E[z]);j!==0&&(F===void 0&&(F=j<0),F===j<0?(R&&C.push(R),R=[E[z]]):R&&R.push(E[z]))}return R&&C.push(R),C}(p),S=[];for(let E of w)S.push(E.map(g));x=S.length===1?{type:"Polygon",coordinates:S[0]}:{type:"MultiPolygon",coordinates:S}}}let b={type:"Feature",geometry:x,properties:this.properties};return this.id!=null&&(b.id=this.id),b}}function _g(n,e,i){n===1?e.id=i.readVarint():n===2?function(r,s){let l=r.readVarint()+r.pos;for(;r.pos<l;){let u=s._keys[r.readVarint()],p=s._values[r.readVarint()];s.properties[u]=p}}(i,e):n===3?e.type=i.readVarint():n===4&&(e._geometry=i.pos)}function bm(n){let e=0;for(let i,r,s=0,l=n.length,u=l-1;s<l;u=s++)i=n[s],r=n[u],e+=(r.x-i.x)*(i.y+r.y);return e}$s.types=["Unknown","Point","LineString","Polygon"];class wm{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(Tm,this,i),this.length=this._features.length}feature(e){if(e<0||e>=this._features.length)throw new Error("feature index out of bounds");this._pbf.pos=this._features[e];let i=this._pbf.readVarint()+this._pbf.pos;return new $s(this._pbf,i,this.extent,this._keys,this._values)}}function Tm(n,e,i){n===15?e.version=i.readVarint():n===1?e.name=i.readString():n===5?e.extent=i.readVarint():n===2?e._features.push(i.pos):n===3?e._keys.push(i.readString()):n===4&&e._values.push(function(r){let s=null,l=r.readVarint()+r.pos;for(;r.pos<l;){let u=r.readVarint()>>3;s=u===1?r.readString():u===2?r.readFloat():u===3?r.readDouble():u===4?r.readVarint64():u===5?r.readVarint():u===6?r.readSVarint():u===7?r.readBoolean():null}if(s==null)throw new Error("unknown feature value");return s}(i))}class cp{constructor(e,i){this.layers=e.readFields(gg,{},i)}}function gg(n,e,i){if(n===3){let r=new wm(i,i.readVarint()+i.pos);r.length&&(e[r.name]=r)}}let Hs="3d_elevation_id",Sm="level";class yg{constructor(){this._valid=!1}reset(e){return this.feature=e,this._valid=!0,this._geometry=e.loadGeometry(),this._geometry.length!==0&&this._geometry[0].length!==0||(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,s){let l=Object.hasOwn(this.feature.properties,e)?+this.feature.properties[e]:void 0;return this._valid&&l!==void 0&&!Number.isNaN(l)?r(s?s(l):l):i&&(this._valid=!1),this}}class Im{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 xg=new Im((n,e,i)=>n.reset(e).require(Hs,r=>{i.id=r}).optional("fixed_height_relative",r=>{i.constantHeight=r},ss.decodeRelativeHeight).geometry(r=>{i.bounds=r},Kh).success(),(n,e,i)=>n.reset(e).require(Hs,r=>{i.id=r}).require("elevation_idx",r=>{i.idx=r}).require("extent",r=>{i.extent=r}).require("height_relative",r=>{i.height=r},ss.decodeRelativeHeight).geometry(r=>{i.position=r},ss.getPoint).success()),vg=new Im((n,e,i)=>n.reset(e).require(Hs,r=>{i.id=r}).optional("fixed_height",r=>{i.constantHeight=r},ss.decodeMetricHeight).geometry(r=>{i.bounds=r},Kh).success(),(n,e,i)=>n.reset(e).require(Hs,r=>{i.id=r}).require("elevation_idx",r=>{i.idx=r}).require("extent",r=>{i.extent=r}).require("height",r=>{i.height=r},ss.decodeMetricHeight).geometry(r=>{i.position=r},ss.getPoint).success());class ss{static getPoint(e){return mo(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?e==="1.0.1"?vg:void 0:xg}static parse(e){let i=[],r=[],s=e.length,l=new yg;for(let u=0;u<s;u++){let p=e.feature(u),f=p.properties.version,g=ss.getVersionSchema(f);if(g===void 0){Ot(`Unknown elevation feature version number ${f||"(unknown)"}`);continue}let x=p.properties.type;if(!x)continue;let b=$s.types[p.type];if(b==="Point"&&x==="curve_point"){let w={};g.parseVertex(l,p,w)&&i.push(w)}else if(b==="Polygon"&&x==="curve_meta"){let w={};g.parseFeature(l,p,w)&&r.push(w)}}return{vertices:i,features:r}}}class Em{constructor(e,i){this.pos=e,this.dir=i}intersectsPlane(e,i,r){let s=Co(i,this.dir);if(Math.abs(s)<1e-6)return!1;let l=((e[0]-this.pos[0])*i[0]+(e[1]-this.pos[1])*i[1])/s;return r[0]=this.pos[0]+this.dir[0]*l,r[1]=this.pos[1]+this.dir[1]*l,!0}}class Jc{constructor(e,i){this.pos=e,this.dir=i}intersectsPlane(e,i,r){let s=Qi(i,this.dir);if(Math.abs(s)<1e-6)return!1;let l=((e[0]-this.pos[0])*i[0]+(e[1]-this.pos[1])*i[1]+(e[2]-this.pos[2])*i[2])/s;return r[0]=this.pos[0]+this.dir[0]*l,r[1]=this.pos[1]+this.dir[1]*l,r[2]=this.pos[2]+this.dir[2]*l,!0}closestPointOnSphere(e,i,r){if(function(S,E){var M=S[0],C=S[1],R=S[2],F=E[0],z=E[1],j=E[2];return Math.abs(M-F)<=ln*Math.max(1,Math.abs(M),Math.abs(F))&&Math.abs(C-z)<=ln*Math.max(1,Math.abs(C),Math.abs(z))&&Math.abs(R-j)<=ln*Math.max(1,Math.abs(R),Math.abs(j))}(this.pos,e)||i===0)return r[0]=r[1]=r[2]=0,!1;let[s,l,u]=this.dir,p=this.pos[0]-e[0],f=this.pos[1]-e[1],g=this.pos[2]-e[2],x=s*s+l*l+u*u,b=2*(p*s+f*l+g*u),w=b*b-4*x*(p*p+f*f+g*g-i*i);if(w<0){let S=Math.max(-b/2,0),E=p+s*S,M=f+l*S,C=g+u*S,R=Math.hypot(E,M,C);return r[0]=E*i/R,r[1]=M*i/R,r[2]=C*i/R,!1}{let S=(-b-Math.sqrt(w))/(2*x);if(S<0){let E=Math.hypot(p,f,g);return r[0]=p*i/E,r[1]=f*i/E,r[2]=g*i/E,!1}return r[0]=p+s*S,r[1]=f+l*S,r[2]=g+u*S,!0}}}class up{constructor(e,i,r,s,l){this.TL=e,this.TR=i,this.BR=r,this.BL=s,this.horizon=l}static fromInvProjectionMatrix(e,i,r){let s=[-1,1,1],l=[1,1,1],u=[1,-1,1],p=[-1,-1,1],f=Oi(s,s,e),g=Oi(l,l,e),x=Oi(u,u,e),b=Oi(p,p,e);return new up(f,g,x,b,i/r)}}function ro(n,e,i,r){let s=e[0],l=e[1],u=e[2],p=i[0],f=i[1],g=i[2],x=1/0,b=-1/0;for(let w=0;w<n.length;w++){let S=n[w],E=(S[0]-s)*p+(S[1]-l)*f+(S[2]-u)*g;E<x&&(x=E),E>b&&(b=E)}return r[0]=x,r[1]=b,r}function fh(n,e){let i=!0;for(let r=0;r<n.planes.length;r++){let s=n.planes[r],l=0;for(let u=0;u<e.length;u++)l+=+(Qi(s,e[u])+s[3]>=0);if(l===0)return 0;l!==e.length&&(i=!1)}return i?2:1}let Am=[0,0];function Mm(n,e){for(let i of n.projections){let r=ro(e,n.points[0],i.axis,Am);if(i.projection[1]<r[0]||i.projection[0]>r[1])return 0}return 1}function Cm(n,e){let i=e[0],r=e[1],s=e[2],l=e[3];for(let u=0;u<n.length;u++){let p=n[u];if(i*p[0]+r*p[1]+s*p[2]+l>=0)return!0}return!1}class hp{constructor(e,i){this.points=e||new Array(8).fill([0,0,0]),this.planes=i||new Array(6).fill([
70,0,0,0]),this.bounds=Si.fromPoints(this.points),this.projections=[],this.frustumEdges=[Gi([],this.points[2],this.points[3]),Gi([],this.points[0],this.points[3]),Gi([],this.points[4],this.points[0]),Gi([],this.points[5],this.points[1]),Gi([],this.points[6],this.points[2]),Gi([],this.points[7],this.points[3])];for(let r of this.frustumEdges){let s=[0,-r[2],r[1]],l=[r[2],0,-r[0]];this.projections.push({axis:s,projection:ro(this.points,this.points[0],s,[0,0])}),this.projections.push({axis:l,projection:ro(this.points,this.points[0],l,[0,0])})}}static fromInvProjectionMatrix(e,i,r,s){let l=Math.pow(2,r),u=[[-1,1,-1,1],[1,1,-1,1],[1,-1,-1,1],[-1,-1,-1,1],[-1,1,1,1],[1,1,1,1],[1,-1,1,1],[-1,-1,1,1]].map(g=>{let x=_r([],g,e),b=1/x[3]/i*l;return(w=x)[0]=(S=x)[0]*(E=[b,b,s?1/x[3]:b,b])[0],w[1]=S[1]*E[1],w[2]=S[2]*E[2],w[3]=S[3]*E[3],w;var w,S,E}),p=[[0,1,2],[6,5,4],[0,3,7],[2,1,5],[3,2,6],[0,4,5]].map(g=>{let x=hi([],Wn([],Gi([],u[g[0]],u[g[1]]),Gi([],u[g[2]],u[g[1]]))),b=-Qi(x,u[g[1]]);return x.concat(b)}),f=[];for(let g=0;g<u.length;g++)f.push([u[g][0],u[g][1],u[g][2]]);return new hp(f,p)}intersectsPrecise(e,i,r){for(let f=0;f<i.length;f++)if(!Cm(e,i[f]))return 0;for(let f=0;f<this.planes.length;f++)if(!Cm(e,this.planes[f]))return 0;let s=this.points,l=s[0][0],u=s[0][1],p=s[0][2];for(let f of r)for(let g of this.frustumEdges){let x=f[1]*g[2]-f[2]*g[1],b=f[2]*g[0]-f[0]*g[2],w=f[0]*g[1]-f[1]*g[0];if(x===0&&b===0&&w===0)continue;let S=1/0,E=-1/0;for(let R=0;R<s.length;R++){let F=s[R],z=(F[0]-l)*x+(F[1]-u)*b+(F[2]-p)*w;z<S&&(S=z),z>E&&(E=z)}let M=1/0,C=-1/0;for(let R=0;R<e.length;R++){let F=e[R],z=(F[0]-l)*x+(F[1]-u)*b+(F[2]-p)*w;z<M&&(M=z),z>C&&(C=z)}if(S>C||M>E)return 0}return 1}containsPoint(e){for(let i of this.planes){let r=i[3];if(Qi([i[0],i[1],i[2]],e)+r<0)return!1}return!0}}class Si{static fromPoints(e){let i=[1/0,1/0,1/0],r=[-1/0,-1/0,-1/0];for(let s of e)Rn(i,i,s),Pr(r,r,s);return new Si(i,r)}static fromTileIdAndHeight(e,i,r){let s=1<<e.canonical.z,l=e.canonical.x,u=e.canonical.y;return new Si([l/s,u/s,i],[(l+1)/s,(u+1)/s,r])}static applyTransform(e,i){let r=e.getCorners();for(let s=0;s<r.length;++s)Oi(r[s],r[s],i);return Si.fromPoints(r)}static applyTransformFast(e,i){let r=[i[12],i[13],i[14]],s=[...r];for(let l=0;l<3;l++)for(let u=0;u<3;u++){let p=i[4*u+l],f=p*e.min[u],g=p*e.max[u];r[l]+=Math.min(f,g),s[l]+=Math.max(f,g)}return new Si(r,s)}static projectAabbCorners(e,i){let r=e.getCorners();for(let s=0;s<r.length;++s)Oi(r[s],r[s],i);return r}constructor(e,i){this.min=e,this.max=i,this.center=Li([],tn([],this.min,this.max),.5)}quadrant(e){let i=[e%2==0,e<2],r=ic(this.min),s=ic(this.max);for(let l=0;l<i.length;l++)r[l]=i[l]?this.min[l]:this.center[l],s[l]=i[l]?this.center[l]:this.max[l];return s[2]=this.max[2],new Si(r,s)}distanceX(e){return Math.max(Math.min(this.max[0],e[0]),this.min[0])-e[0]}distanceY(e){return Math.max(Math.min(this.max[1],e[1]),this.min[1])-e[1]}distanceZ(e){return Math.max(Math.min(this.max[2],e[2]),this.min[2])-e[2]}getCorners(){let e=this.min,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)?fh(e,this.getCorners()):0}intersectsFlat(e){return this.intersectsAabb(e.bounds)?fh(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)?Mm(e,this.getCorners()):0}intersectsPreciseFlat(e,i){return i||this.intersectsFlat(e)?Mm(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])]}}Qe(Si,"Aabb");class Pm{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],s=-i[0],l=(e.extent+1)*this.metersToTile;return[new ke(Math.trunc(e.position[0]+r*l),Math.trunc(e.position[1]+s*l)),new ke(Math.trunc(e.position[0]-r*l),Math.trunc(e.position[1]-s*l))]}next(){this.index++}valid(){return this.index<this.feature.vertices.length}}class mh{constructor(e,i,r,s,l,u){if(this.vertices=new Array,this.vertexProps=new Array,this.edges=new Array,this.edgeProps=new Array,this._tmpVec2=[Xn(),Xn(),Xn(),Xn(),Xn(),Xn(),Xn()],this.id=e,this.heightRange={min:r,max:r},this.safeArea=i,this.constantHeight=r,this.constantHeight==null&&(this.constantHeight!=null||s.length!==0)){this.vertices=s,this.edges=l,this.edges=this.edges.filter(p=>{return p.a<this.vertices.length&&p.b<this.vertices.length&&!((f=this.vertices[p.a].position)[0]===(g=this.vertices[p.b].position)[0]&&f[1]===g[1]);var f,g}),this.heightRange={min:Number.POSITIVE_INFINITY,max:Number.NEGATIVE_INFINITY};for(let p of this.vertices)this.vertexProps.push({dir:mo(0,0)}),this.heightRange.min=Math.min(this.heightRange.min,p.height),this.heightRange.max=Math.max(this.heightRange.max,p.height);for(let p of this.edges){let f=this.vertices[p.a].position,g=this.vertices[p.b].position,x=_o(Xn(),g,f),b=ca(x),w=la(Xn(),x,1/b);this.edgeProps.push({vec:x,dir:w,len:b});let S=this.vertexProps[p.a].dir,E=this.vertexProps[p.b].dir;aa(S,S,w),aa(E,E,w)}for(let p of this.vertexProps)p.dir[0]===0&&p.dir[1]===0||ac(p.dir,p.dir);this.tessellate(u)}}pointElevation(e){if(this.constantHeight!=null)return this.constantHeight;let i=this.getClosestEdge(e);if(i==null)return 0;let[r,s]=i;return ft(this.vertices[this.edges[r].a].height,this.vertices[this.edges[r].b].height,s)}computeSlopeNormal(e,i){let r=this.getClosestEdge(e);if(!r)return Fn(0,0,1);let s=r[0],l=this.edges[s],u=this.edgeProps[s].vec,p=Fn(u[0],u[1],(this.vertices[l.b].height-this.vertices[l.a].height)*i),f=Fn(p[
71],-p[0],0);Wn(f,f,p);let g=Dn(f);return g>0?Li(f,f,1/g):Ei(f,0,0,1)}getSafeArea(){return this.safeArea}isTunnel(){return this.heightRange.max<=-5}getClosestEdge(e){if(this.edges.length===0)return;let i=0,r=Number.POSITIVE_INFINITY,s=0,[l,u,p,f,g,x,b]=this._tmpVec2;qo(b,e.x,e.y);let w=new Em(b,null);for(let S=0;S<this.edges.length;S++){let E=this.edges[S],M=this.edgeProps[S].dir;w.dir=M;let C=this.vertices[E.a].position,R=this.vertices[E.b].position,F=w.intersectsPlane(C,this.vertexProps[E.a].dir,l),z=w.intersectsPlane(R,this.vertexProps[E.b].dir,u);if(!F||!z)continue;_o(p,u,l),_o(f,b,l);let j=Co(p,p),$=j>0?Co(f,p)/j:0,H=ne($,0,1),ie=Math.abs(($-H)*this.edgeProps[S].len);_o(g,b,C),qo(x,M[1],-M[0]);let W=ie+Math.abs(Co(g,x));W<r&&(i=S,r=W,s=H)}return[i,s]}tessellate(e){let i=si(),r=si(),s=si(),l=si();for(let u=this.edges.length-1;u>=0;--u){let p=this.edges[u].a,f=this.edges[u].b,{position:g,height:x,extent:b}=this.vertices[p],{position:w,height:S,extent:E}=this.vertices[f],M=this.vertexProps[p].dir,C=this.vertexProps[f].dir;if(Ei(i,g[0]/e,g[1]/e,x),Ei(r,w[0]/e,w[1]/e,S),Ei(s,M[1],-M[0],0),Li(s,s,b),Ei(l,C[1],-C[0],0),Li(l,l,E),this.distSqLines(Fn(i[0]+.5*s[0],i[1]+.5*s[1],i[2]+.5*s[2]),Fn(r[0]-.5*l[0],r[1]-.5*l[1],r[2]-.5*l[2]),Fn(i[0]-.5*s[0],i[1]-.5*s[1],i[2]-.5*s[2]),Fn(r[0]+.5*l[0],r[1]+.5*l[1],r[2]+.5*l[2]))<=.0025000000000000005)continue;let R=this.vertices.length,F=aa(Xn(),g,w);this.vertices.push({position:la(F,F,.5),height:.5*(x+S),extent:.5*(b+E)});let z=aa(Xn(),M,C);this.vertexProps.push({dir:ac(z,z)}),this.edges.splice(u,1),this.edgeProps.splice(u,1),this.edges.push({a:p,b:R}),this.edges.push({a:R,b:f});let j=_o(Xn(),this.vertices[R].position,g),$=ca(j),H={vec:j,dir:la(Xn(),j,1/$),len:$};this.edgeProps.push(H),this.edgeProps.push(H)}}distSqLines(e,i,r,s){let l=po(si(),i,e),u=po(si(),s,r),p=po(si(),e,r),f=Qi(l,l),g=Qi(l,u),x=Qi(l,p),b=Qi(u,u),w=Qi(u,p),S=f*b-g*g;if(S===0)return $o(na(l,r,s,Qi(p,u)/Qi(u,u)),e);let E=(f*w-g*x)/S;return $o(na(l,e,i,(g*w-x*b)/S),na(u,r,s,E))}}class _h{static parseFrom(e,i){let r=ss.parse(e);if(!r)return[];let{vertices:s,features:l}=r,u=1/Vr(i);l.sort((x,b)=>x.id-b.id),s.sort((x,b)=>x.id-b.id||x.idx-b.idx),s=s.filter((x,b,w)=>b===w.findIndex(S=>S.id===x.id&&S.idx===x.idx));let p=new Array,f=0,g=s.length;for(let x of l){if(x.constantHeight){p.push(new mh(x.id,x.bounds,x.constantHeight));continue}for(;f!==g&&s[f].id<x.id;)f++;if(f===g||s[f].id!==x.id)continue;let b=new Array,w=new Array,S=f;for(;f!==g&&s[f].id===x.id;){let E=s[f];if(b.push({position:E.position,height:E.height,extent:E.extent}),f!==S&&s[f-1].idx===E.idx-1){let M=f-S;w.push({a:M-1,b:M})}f++}p.push(new mh(x.id,x.bounds,void 0,b,w,u))}return p}static getElevationFeature(e,i){if(!i)return;let r=+e.properties[Hs];return Number.isNaN(r)?void 0:i.find(s=>s.id===r)}}class a{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)*Xe,this.yOffset=(e.y*this.zScale-i.y)*Xe)}constantElevation(e,i){if(e.constantHeight!=null)return this.computeBiasedHeight(e.constantHeight,i)}pointElevation(e,i,r){let s=this.constantElevation(i,r);return s??(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*ye(0,i,e>=0?e:Math.abs(.5*e))}}function t(n){if(n===0)return[0,0,0];let e=md(n);return[e(),e(),e()]}Qe(mh,"ElevationFeature");class o{constructor(e){this.zoom=e.zoom,this.overscaling=e.overscaling,this.layers=e.layers,this.layerIds=this.layers.map(i=>i.fqid),this.index=e.index,this.hasPattern=!1,this.projection=e.projection,this.layoutVertexArray=new Hn,this.indexArray=new Xi,this.segments=new pi,this.programConfigurations=new bo(e.layers,{zoom:e.zoom,lut:e.lut}),this.stateDependentLayerIds=this.layers.filter(i=>i.isStateDependent()).map(i=>i.id),this.elevationMode=this.layers[0].layout.get("circle-elevation-reference"),this.hasElevation=!1,this.elevationMode!=="none"&&(this.elevatedLayoutVertexArray=new Do),this.worldview=e.worldview,this.hasAppearances=null}updateFootprints(e,i){}updateAppearances(e,i,r,s){return{hasLayoutChanges:!1,hasUboChanges:!1}}
7populate(e,i,r,s){let l=this.layers[0],u=[],p=null;l.type==="circle"&&(p=l.layout.get("circle-sort-key"));for(let{feature:g,id:x,index:b,sourceLayerIndex:w}of e){let S=this.layers[0]._featureFilter.needGeometry,E=Gr(g,S);if(!this.layers[0]._featureFilter.filter(new Xt(this.zoom,{worldview:this.worldview,activeFloors:i.activeFloors}),E,r))continue;let M=p?p.evaluate(E,{},r):void 0,C={id:x,properties:g.properties,type:g.type,sourceLayerIndex:w,index:b,geometry:S?E.geometry:jr(g,r,s),patterns:{},sortKey:M};u.push(C)}p&&u.sort((g,x)=>g.sortKey-x.sortKey);let f=null;s.projection.name==="globe"&&(this.globeExtVertexArray=new rh,f=s.projection);for(let g of u){let{geometry:x,index:b,sourceLayerIndex:w}=g,S=e[b].feature;this.addFeature(g,x,b,i.availableImages,r,f,i.brightness,i.elevationFeatures),i.featureIndex.insert(S,x,b,w,this.index)}this.hasElevation||(this.elevatedLayoutVertexArray=void 0)}update(e,i,r,s,l,u,p){this.programConfigurations.updatePaintArrays(e,i,l,r,s,u,p,this.worldview)}updateExpressions(e){this.programConfigurations.updateExpressions(e)}isEmpty(){return this.layoutVertexArray.length===0}uploadPending(){return!this.uploaded||this.programConfigurations.needsUpload}upload(e){this.uploaded||(this.layoutVertexBuffer=e.createVertexBuffer(this.layoutVertexArray,lg.members),this.indexBuffer=e.createIndexBuffer(this.indexArray),this.globeExtVertexArray&&(this.globeExtVertexBuffer=e.createVertexBuffer(this.globeExtVertexArray,ug.members)),this.elevatedLayoutVertexArray&&(this.elevatedLayoutVertexBuffer=e.createVertexBuffer(this.elevatedLayoutVertexArray,cg.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,s,l,u,p,f){let g;this.elevationMode!=="none"&&(g=_h.getElevationFeature(e,f));for(let x of i)for(let b of x){let w=b.x,S=b.y;if(w<0||w>=Xe||S<0||S>=Xe)continue;if(u){let C=u.projectTilePoint(w,S,l),R=u.upVector(l,w,S);this.addGlobeExtVertex(C,R),this.addGlobeExtVertex(C,R),this.addGlobeExtVertex(C,R),this.addGlobeExtVertex(C,R)}let E=this.segments.prepareSegment(4,this.layoutVertexArray,this.indexArray,e.sortKey),M=E.vertexLength;if(this.addCircleVertex(w,S,-1,-1),this.addCircleVertex(w,S,1,-1),this.addCircleVertex(w,S,1,1),this.addCircleVertex(w,S,-1,1),this.elevationMode!=="none"){let C=g?g.pointElevation(new ke(w,S)):0;this.hasElevation=this.hasElevation||C!==0;for(let R=0;R<4;R++)this.elevatedLayoutVertexArray.emplaceBack(C)}this.indexArray.emplaceBack(M,M+1,M+2),this.indexArray.emplaceBack(M,M+2,M+3),E.vertexLength+=4,E.primitiveLength+=2}this.programConfigurations.populatePaintArrays(this.layoutVertexArray.length,e,r,{},s,l,p,void 0,this.worldview)}addCircleVertex(e,i,r,s){this.layoutVertexArray.emplaceBack(2*e+(r+1)/2,2*i+(s+1)/2)}addGlobeExtVertex(e,i){this.globeExtVertexArray.emplaceBack(e.x,e.y,e.z,i[0]*16384,i[1]*16384,i[2]*16384)}}function c(n,e){for(let i=0;i<n.length;i++)if(L(e,n[i]))return!0;for(let i=0;i<e.length;i++)if(L(n,e[i]))return!0;return!!y(n,e)}function d(n,e,i){return!!L(n,e)||!!P(e,n,i)}function m(n,e){if(n.length===1)return D(e,n[0]);for(let i=0;i<e.length;i++){let r=e[i];for(let s=0;s<r.length;s++)if(L(n,r[s]))return!0}for(let i=0;i<n.length;i++)if(D(e,n[i]))return!0;for(let i=0;i<e.length;i++)if(y(n,e[i]))return!0;return!1}function _(n,e,i){if(n.length>1){if(y(n,e))return!0;for(let r=0;r<e.length;r++)if(P(e[r],n,i))return!0}for(let r=0;r<n.length;r++)if(P(n[r],e,i))return!0;return!1}function y(n,e){if(n.length===0||e.length===0)return!1;for(let i=0;i<n.length-1;i++){let r=n[i],s=n[i+1];for(let l=0;l<e.length-1;l++)if(v(r,s,e[l],e[l+1]))return!0}return!1}function v(n,e,i,r){return ti(n,i,r)!==ti(e,i,r)&&ti(n,e,i)!==ti(n,e,r)}function T(n,e,i){return(n.x-i.x)*(e.y-i.y)-(n.y-i.y)*(e.x-i.x)}function I(n,e,i,r){let s=T(n,e,r),l=T(n,e,i);if(Math.sign(s)===Math.sign(l))return;let u=T(i,r,n),p=u+l-s;return Math.sign(u)!==Math.sign(p)?[u/(u-p),l/(l-s)]:void 0}function P(n,e,i){let r=i*i;if(e.length===1)return n.distSqr(e[0])<r;for(let s=1;s<e.length;s++)if(A(n,e[s-1],e[s])<r)return!0;return!1}function A(n,e,i){let r=e.distSqr(i);if(r===0)return n.distSqr(e);let s=((n.x-e.x)*(i.x-e.x)+(n.y-e.y)*(i.y-e.y))/r;return n.distSqr(s<0?e:s>1?i:i.sub(e)._mult(s)._add(e))}function D(n,e){let i,r,s,l=!1;for(let u=0;u<n.length;u++){i=n[u];for(let p=0,f=i.length-1;p<i.length;f=p++)r=i[p],s=i[f],r.y>e.y!=s.y>e.y&&e.x<(s.x-r.x)*(e.y-r.y)/(s.y-r.y)+r.x&&(l=!l)}return l}function L(n,e){let i=!1;for(let r=0,s=n.length-1;r<n.length;s=r++){let l=n[r],u=n[s];l.y>e.y!=u.y>e.y&&e.x<(u.x-l.x)*(e.y-l.y)/(u.y-l.y)+l.x&&(i=!i)}return i}function O(n,e,i,r,s){for(let u of n)if(e<=u.x&&i<=u.y&&r>=u.x&&s>=u.y)return!0;let l=[new ke(e,i),new ke(e,s),new ke(r,s),new ke(r,i)];if(n.length>2){for(let u of l)if(L(n,u))return!0}for(let u=0;u<n.length-1;u++)if(k(n[u],n[u+1],l))return!0;return!1}function k(n,e,i){let r=i[0],s=i[2];if(n.x<r.x&&e.x<r.x||n.x>s.x&&e.x>s.x||n.y<r.y&&e.y<r.y||n.y>s.y&&e.y>s.y)return!1;let l=ti(n,e,i[0]);return l!==ti(n,e,i[1])||l!==ti(n,e,i[2])||l!==ti(n,e,i[3])}function N(n,e,i,r,s,l){let u=e.y-n.y,p=n.x-e.x;if(l=l||0){let f=u*u+p*p;if(f===0)return!0;let g=Math.sqrt(f);u/=g,p/=g}return!((i.x-n.x)*u+(i.y-n.y)*p-l<0||(r.x-n.x)*u+(r.y-n.y)*p-l<0||(s.x-n.x)*u+(s.y-n.y)*p-l<0)}function q(n,e,i,r,s,l,u){return!(N(n,e,r,s,l,u)||N(e,i,r,s,l,u)||N(i,n,r,s,l,u)||N(r,s,n,e,i,u)||N(s,l,n,e,i,u)||N(l,r,n,e,i,u))}function Z(n,e,i){let r=e.paint.get(n).value;return r.kind==="constant"?r.value:i.programConfigurations.get(e.id).getMaxValue(n)}function G(n){return Math.sqrt(n[0]*n[0]+n[1]*n[1])}function re(n,e,i,r,s){if(!e[0]&&!e[1])return n;let l=ke.convert(e)._mult(s);i==="viewport"&&l._rotate(-r);let u=[];for(let p=0;p<n.length;p++)u.push(n[p].sub(l));return u}function te(n,e,i,r){let s=ke.convert(n)._mult(r);return e==="viewport"&&s._rotate(-i),s}let se,K;Qe(o,"CircleBucket",{omit:["layers"]});class J{constructor(e,i,r){this.z=e,this.x=i,this.y=r,this.key=de(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 e.z===0||e.z<this.z&&e.x===this.x>>i&&e.y===this.y>>i}url(e,i){let r=function(l,u,p){let f=2**p,g=2*Math.PI*6378137,x=g*(l/f-.5),b=g*(.5-(u+1)/f);return`${x},${b},${x+g/f},${b+g/f}`}(this.x,this.y,this.z),s=function(l,u,p){let f,g="";for(let x=l;x>0;x--)f=1<<x-1,g+=(u&f?1:0)+(p&f?2:0);return g}(this.z,this.x,this.y);return e[(this.x+this.y)%e.length].replace("{prefix}",(this.x%16).toString(16)+(this.y%16).toString(16)).replace(/{z}/g,String(this.z)).replace(/{x}/g,String(this.x)).replace(/{y}/g,String(i==="tms"?Math.pow(2,this.z)-this.y-1:this.y)).replace("{quadkey}",s).replace("{bbox-epsg-3857}",r)}toString(){return`${this.z}/${this.x}/${this.y}`}}class oe{constructor(e,i){this.wrap=e,this.canonical=i,this.key=de(e,i.z,i.z,i.x,i.y)}}class ue{constructor(e,i,r,s,l){this.overscaledZ=e,this.wrap=i,this.canonical=new J(r,+s,+l),this.key=i===0&&e===r?this.canonical.key:de(i,e,r,s,l)}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 ue(e,this.wrap,this.canonical.z,this.canonical.x,this.canonical.y):new ue(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 de(this.wrap*+i,e,this.canonical.z,this.canonical.x,this.canonical.y);{let r=this.canonical.z-e;return de(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 e.overscaledZ===0||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 ue(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,s=2*this.canonical.y;return[new ue(i,this.wrap,i,r,s),new ue(i,this.wrap,i,r+1,s),new ue(i,this.wrap,i,r,s+1),new ue(i,this.wrap,i,r+1,s+1)]}isLessThan(e){return this.wrap<e.wrap||!(this.wrap>e.wrap)&&(this.overscaledZ<e.overscaledZ||!(this.overscaledZ>
7e.overscaledZ)&&(this.canonical.x<e.canonical.x||!(this.canonical.x>e.canonical.x)&&this.canonical.y<e.canonical.y))}wrapped(){return new ue(this.overscaledZ,0,this.canonical.z,this.canonical.x,this.canonical.y)}unwrapTo(e){return new ue(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 oe(this.wrap,this.canonical)}toString(){return`${this.overscaledZ}/${this.canonical.x}/${this.canonical.y}`}}function de(n,e,i,r,s){let l=1<<Math.min(i,22),u=l*(s%l)+r%l;return n&&i<22&&(u+=l*l*((n<0?-2*n-1:2*n)%(1<<2*(22-i)))),16*(32*u+i)+(e-i)}let be=[n=>{let e=n.canonical.x-1,i=n.wrap;return e<0&&(e=(1<<n.canonical.z)-1,i--),new ue(n.overscaledZ,i,n.canonical.z,e,n.canonical.y)},n=>{let e=n.canonical.x+1,i=n.wrap;return e===1<<n.canonical.z&&(e=0,i++),new ue(n.overscaledZ,i,n.canonical.z,e,n.canonical.y)},n=>new ue(n.overscaledZ,n.wrap,n.canonical.z,n.canonical.x,(n.canonical.y===0?1<<n.canonical.z:n.canonical.y)-1),n=>new ue(n.overscaledZ,n.wrap,n.canonical.z,n.canonical.x,n.canonical.y===(1<<n.canonical.z)-1?0:n.canonical.y+1)];Qe(J,"CanonicalTileID"),Qe(ue,"OverscaledTileID",{omit:["projMatrix","expandedProjMatrix"]});let ve=Ct([{type:"Float32",name:"a_globe_pos",components:3},{type:"Float32",name:"a_uv",components:2}]),{members:Fe}=ve,pe=Ct([{name:"a_pos_3",components:3,type:"Int16"}]);var Ie=Ct([{name:"a_pos",type:"Int16",components:2}]);function fe(n){return n*Jn/rs}let Pe=[new Si([Nr,Nr,Nr],[Ur,Ur,Ur]),new Si([Nr,Nr,Nr],[0,0,Ur]),new Si([0,Nr,Nr],[Ur,0,Ur]),new Si([Nr,0,Nr],[0,Ur,Ur]),new Si([0,0,Nr],[Ur,Ur,Ur])];function Ce(n,e,i,r=!0){let s=Li([],n._camera.position,n.worldSize),l=[e,i,1,1];_r(l,l,n.pixelMatrixInverse),oa(l,l,1/l[3]);let u=hi([],Gi([],l,s)),p=n.globeMatrix,f=[p[12],p[13],p[14]],g=Gi([],f,s),x=Dn(g),b=hi([],g),w=n.worldSize/(2*Math.PI),S=Qi(b,u),E=Math.asin(w/x);if(E<Math.acos(S)){if(!r)return null;let Y=[],ee=[];Li(Y,u,x/S),hi(ee,Gi(ee,Y,g)),hi(u,tn(u,g,Li(u,ee,Math.tan(E)*x)))}let M=[];new Jc(s,u).closestPointOnSphere(f,w,M);let C=hi([],Wi(p,0)),R=hi([],Wi(p,1)),F=hi([],Wi(p,2)),z=Qi(C,M),j=Qi(R,M),$=Qi(F,M),H=X(Math.asin(-j/w)),ie=X(Math.atan2(z,$));ie=n.center.lng+function(Y,ee){let me=(ee-Y+180)%360-180;return me<-180?me+360:me}(n.center.lng,ie);let W=wo(ie),Q=ne(Fo(H),0,1);return new qn(W,Q)}class Re{constructor(e,i,r){this.a=Gi([],e,r),this.b=Gi([],i,r),this.center=r;let s=hi([],this.a),l=hi([],this.b);this.angle=Math.acos(Qi(s,l))}}function Ye(n,e){if(n.angle===0)return null;let i;return i=n.a[e]===0?1/n.angle*.5*Math.PI:1/n.angle*Math.atan(n.b[e]/n.a[e]/Math.sin(n.angle)-1/Math.tan(n.angle)),i<0||i>1?null:function(r,s,l,u){let p=Math.sin(l);return r*(Math.sin((1-u)*l)/p)+s*(Math.sin(u*l)/p)}(n.a[e],n.b[e],n.angle,ne(i,0,1))+n.center[e]}function $e(n){if(n.z<=1)return Pe[n.z+2*n.y+n.x];let e=it(et(n));return Si.fromPoints(e)}function je(n,e,i){return Li(n,n,1-i),Dr(n,n,e,i)}function Ue(n,e){let i=$t(e.zoom);if(i===0)return $e(n);let r=et(n),s=it(r),l=wo(r.getWest())*e.worldSize,u=wo(r.getEast())*e.worldSize,p=Fo(r.getNorth())*e.worldSize,f=Fo(r.getSouth())*e.worldSize,g=[l,p,0],x=[u,p,0],b=[l,f,0],w=[u,f,0],S=mr([],e.globeMatrix);return Oi(g,g,S),Oi(x,x,S),Oi(b,b,S),Oi(w,w,S),s[0]=je(s[0],b,i),s[1]=je(s[1],w,i),s[2]=je(s[2],x,i),s[3]=je(s[3],g,i),Si.fromPoints(s)}function at(n,e,i){for(let r of n)Oi(r,r,e),Li(r,r,i)}function ot(n,e,i,r){let s=e/n.worldSize,l=n.globeMatrix;if(i.z<=1){let Q=$e(i).getCorners();return at(Q,l,s),Si.fromPoints(Q)}let u=et(i,r),p=it(u,Jn+fe(n._tileCoverLift));at(p,l,s);let f=Number.MAX_VALUE,g=[-f,-f,-f],x=[f,f,f];if(u.contains(n.center)){for(let ee of p)Rn(x,x,ee),Pr(g,g,ee);g[2]=0;let Q=n.point,Y=[Q.x*s,Q.y*s,0];return Rn(x,x,Y),Pr(g,g,Y),new Si(x,g)}if(n._tileCoverLift>0){for(let Q of p)Rn(x,x,Q),Pr(g,g,Q);return new Si(x,g)}let b=[l[12]*s,l[13]*s,l[14]*s],w=u.getCenter(),S=ne(n.center.lat,-85.051129,Er),E=ne(w.lat,-85.051129,Er),M=wo(n.center.lng),C=Fo(S),R=M-wo(w.lng),F=C-Fo(E);R>.5?R-=1:R<-.5&&(R+=1);let z=0;Math.abs(R)>Math.abs(F)?z=R>=0?1:3:(z=F>=0?0:2,Dr(b,b,[l[4]*s,l[5]*s,l[6]*s],-Math.sin(V(F>=0?u.getSouth():u.getNorth()))*Jn));let j=p[z],$=p[(z+1)%4],H=new Re(j,$,b),ie=[Ye(H,0)||j[0],Ye(H,1)||j[1],Ye(H,2)||j[2]],W=$t(n.zoom);if(W>0){let Q=function({x:ee,y:me,z:ge},Te,Ae,Ee,Be){let xe=1/(1<<ge),Se=ee*xe,Me=Se+xe,ze=me*xe,Le=ze+xe,We=0,De=(Se+Me)/2-Ee;return De>.5?We=-1:De<-.5&&(We=1),Se=((Se+We)*Te-(Ee*=Te))*Ae+Ee,Me=((Me+We)*Te-Ee)*Ae+Ee,ze=(ze*Te-(Be*=Te))*Ae+Be,Le=(Le*Te-Be)*Ae+Be,[[Se,Le,0],[Me,Le,0],[Me,ze,0],[Se,ze,0]]}(i,e,n._pixelsPerMercatorPixel,M,C);for(let ee=0;ee<p.length;ee++)je(p[ee],Q[ee],W);let Y=tn([],Q[z],Q[(z+1)%4]);Li(Y,Y,.5),je(ie,Y,W)}for(let Q of p)Rn(x,x,Q),Pr(g,g,Q);return x[2]=Math.min(j[2],$[2]),Rn(x,x,ie),Pr(g,g,ie),new Si(x,g)}function et({x:n,y:e,z:i},r=!1){let s=1/(1<<i),l=new Yt(Ir(n*s),e===(1<<i)-1&&r?-90:Ln((e+1)*s)),u=new Yt(Ir((n+1)*s),e===0&&r?90:Ln(e*s));return new os(l,u)}
7function it(n,e=Jn){let i=V(n.getNorth()),r=V(n.getSouth()),s=Math.cos(i),l=Math.cos(r),u=Math.sin(i),p=Math.sin(r),f=n.getWest(),g=n.getEast();return[Nl(l,p,f,e),Nl(l,p,g,e),Nl(s,u,g,e),Nl(s,u,f,e)]}function ut(n,e,i,r){let s=1<<i.z,l=(n/Xe+i.x)/s;return ns(Ln((e/Xe+i.y)/s),Ir(l),r)}function xt({min:n,max:e}){return 16383/Math.max(e[0]-n[0],e[1]-n[1],e[2]-n[2])}let _t=new Float64Array(16);function Tt(n){let e=xt(n),i=Go(_t,[e,e,e]);return Gn(i,i,fo([],n.min))}function yt(n){let e=1/xt(n);return ms(_t,n.min),Zn(_t,_t,[e,e,e])}function Ft(n){let e=Xe/(2*Math.PI);return n/(2*Math.PI)/e}function bt(n,e){return Xe/(512*Math.pow(2,n))*xt($e(e))}function Nt(n,e,i,r,s){let l=Ft(i),u=[n,e,-i/(2*Math.PI)],p=Rt(new Float64Array(16));return Gn(p,p,u),Zn(p,p,[l,l,l]),Vo(p,p,V(-s)),jo(p,p,V(-r)),p}function $t(n){return ye(5,6,n)}function bi(n,e){let i=ns(e.lat,e.lng),r=function(E){let M=ns(E._center.lat,E._center.lng),C=Wn([],Fn(0,1,0),M),R=ta([],-E.angle,M);C=Oi(C,C,R),ta(R,-E._pitch,C);let F=hi([],M);return Li(F,F,fe(E.cameraToCenterDistance/E.pixelsPerMeter)),Oi(F,F,R),tn([],M,F)}(n);return u=(s=po([],r,i))[0],p=s[1],f=s[2],g=(l=i)[0],x=l[1],b=l[2],S=(w=Math.sqrt((u*u+p*p+f*f)*(g*g+x*x+b*b)))&&Qi(s,l)/w,Math.acos(Math.min(Math.max(S,-1),1));var s,l,u,p,f,g,x,b,w,S}function ai(n,e){return bi(n,e)>Math.PI/2*1.01}let Zt=V(85),It=Math.cos(Zt),Et=Math.sin(Zt),li=fs(),Di=n=>{let e=[];return n.paint.get("circle-pitch-alignment")==="map"&&e.push("PITCH_WITH_MAP"),n.paint.get("circle-pitch-scale")==="map"&&e.push("SCALE_WITH_MAP"),e};function Qt(n,e,i,r,s,l,u,p,f){if(l&&n.queryGeometry.isAboveHorizon)return!1;l&&(f*=n.pixelToTileUnitsFactor);let g=n.tileID.canonical,x=i.projection.upVectorScale(g,i.center.lat,i.worldSize).metersToTile;for(let b of e)for(let w of b){let S=w.add(p),E=s&&i.elevation?i.elevation.exaggeration()*s.getElevationAt(S.x,S.y,!0):0,M=i.projection.projectTilePoint(S.x,S.y,g);if(E>0){let z=i.projection.upVector(g,S.x,S.y);M.x+=z[0]*x*E,M.y+=z[1]*x*E,M.z+=z[2]*x*E}let C=l?S:vt(M.x,M.y,M.z,r),R=l?n.tilespaceRays.map(z=>ki(z,E)):n.queryGeometry.screenGeometry,F=_r([],[M.x,M.y,M.z,1],r);if(!u&&l?f*=F[3]/i.cameraToCenterDistance:u&&!l&&(f*=i.cameraToCenterDistance/F[3]),l){let z=Ln((w.y/Xe+g.y)/(1<<g.z));f/=i.projection.pixelsPerMeter(z,1)/or(1,z)}if(d(R,C,f))return!0}return!1}function vt(n,e,i,r){let s=_r([],[n,e,i,1],r);return new ke(s[0]/s[3],s[1]/s[3])}let yi=Fn(0,0,0),fi=Fn(0,0,1);function ki(n,e){let i=si();return yi[2]=e,n.intersectsPlane(yi,fi,i),new ke(i[0],i[1])}class Bt extends o{}let Yi,Nn,fn,An;function cn(n,{width:e,height:i},r,s){if(s){if(s instanceof Uint8ClampedArray)s=new Uint8Array(s.buffer);else if(s.length!==e*i*r)throw new RangeError("mismatched image size")}else s=new Uint8Array(e*i*r);return n.width=e,n.height=i,n.data=s,n}function sr(n,e,i){let{width:r,height:s}=e;r===n.width&&s===n.height||(Kn(n,e,{x:0,y:0},{x:0,y:0},{width:Math.min(n.width,r),height:Math.min(n.height,s)},i,null),n.width=r,n.height=s,n.data=e.data)}function Kn(n,e,i,r,s,l,u,p){if(s.width===0||s.height===0)return e;if(s.width>n.width||s.height>n.height||i.x>n.width-s.width||i.y>n.height-s.height)throw new RangeError("out of range source coordinates for image copy");if(s.width>e.width||s.height>e.height||r.x>e.width-s.width||r.y>e.height-s.height)throw new RangeError("out of range destination coordinates for image copy");let f=n.data,g=e.data,x=l===4&&p;for(let b=0;b<s.height;b++){let w=((i.y+b)*n.width+i.x)*l,S=((r.y+b)*e.width+r.x)*l;if(x)for(let E=0;E<s.width;E++){let M=w+E*l+3,C=S+E*l;g[C+0]=255,g[C+1]=255,g[C+2]=255,g[C+3]=f[M]}else if(u)for(let E=0;E<s.width;E++){let M=w+E*l,C=S+E*l,R=new jt(f[M+0]/255,f[M+1]/255,f[M+2]/255,f[M+3]).toNonPremultipliedRenderColor(u).toArray();g[C+0]=R[0],g[C+1]=R[1],g[C+2]=R[2],g[C+3]=R[3]}else for(let E=0;E<s.width*l;E++)g[S+E]=f[w+E]}return e}Qe(Bt,"HeatmapBucket",{omit:["layers"]});class Ri{constructor(e,i){cn(this,e,1,i)}resize(e){sr(this,new Ri(e),1)}clone(){return new Ri({width:this.width,height:this.height},new Uint8Array(this.data))}static copy(e,i,r,s,l){Kn(e,i,r,s,l,1,null)}}class Ni{constructor(e,i){cn(this,e,4,i)}resize(e){sr(this,new Ni(e),4)}replace(e,i){i?this.data.set(e):this.data=e instanceof Uint8ClampedArray?new Uint8Array(e.buffer):e}clone(){return new Ni({width:this.width,height:this.height},new Uint8Array(this.data))}static copy(e,i,r,s,l,u,p){Kn(e,i,r,s,l,4,u,p)}}class Ii{constructor(e,i){this.width=e.width,this.height=e.height,this.data=i instanceof Uint8Array?new Float32Array(i.buffer):i}}function ei(n){let e={},i=n.resolution||256,r=n.clips?n.clips.length:1,s=n.image||new Ni({width:i,height:r}),l=(u,p,f)=>{e[n.evaluationKey]=f;let g=n.expression.evaluate(e),x=g?g.toNonPremultipliedRenderColor(null):null;x&&(s.data[u+p+0]=Math.floor(255*x.r),s.data[u+p+1]=Math.floor(255*x.g),s.data[u+p+2]=Math.floor(255*x.b),s.data[u+p+3]=Math.floor(255*x.a))};if(n.clips)for(let u=0,p=0;u<r;++u,p+=4*i)for(let f=0,g=0;f<i;f++,g+=4){let x=f/(i-1),{start:b,end:w}=n.clips[u];l(p,g,b*(1-x)+w*x)}else for(let u=0,p=0;u<i;u++,p+=4)l(0,p,u/(i-1));return s}Qe(Ri,"AlphaImage"),Qe(Ni,"RGBAImage");let oi=Ct([{name:"a_pos",components:2,type:"Int16"}],4),Ji=Ct([{name:"a_road_z_offset",components:1,type:"Float32"}],4),bn=Ct([{name:"a_pos",components:2,type:"Int16"},{name:"a_height",components:1,type:"Float32"}],4),Fi=Ct([{name:"a_pos_normal_3",components:3,type:"Int16"}],4);function wn(n,e,i=2){let r=e&&e.length,s=r?e[0]*i:n.length,l=$r(n,0,s,i,!0),u=[];
vendor: 2,364 bytes, line 7
7if(!l||l.next===l.prev)return u;let p,f,g;if(r&&(l=function(x,b,w,S){let E=[];for(let M=0,C=b.length;M<C;M++){let R=$r(x,b[M]*S,M<C-1?b[M+1]*S:x.length,S,!1);R===R.next&&(R.steiner=!0),E.push(Dm(R))}E.sort(qs);for(let M=0;M<E.length;M++)w=Va(E[M],w);return w}(n,e,l,i)),n.length>80*i){p=n[0],f=n[1];let x=p,b=f;for(let w=i;w<s;w+=i){let S=n[w],E=n[w+1];S<p&&(p=S),E<f&&(f=E),S>x&&(x=S),E>b&&(b=E)}g=Math.max(x-p,b-f),g=g!==0?32767/g:0}return oo(l,u,i,p,f,g,0),u}function $r(n,e,i,r,s){let l;if(s===function(u,p,f,g){let x=0;for(let b=p,w=f-g;b<f;b+=g)x+=(u[w]-u[b])*(u[b+1]+u[w+1]),w=b;return x}(n,e,i,r)>0)for(let u=e;u<i;u+=r)l=Xy(u/r|0,n[u],n[u+1],l);else for(let u=i-r;u>=e;u-=r)l=Xy(u/r|0,n[u],n[u+1],l);return l&&gh(l,l.next)&&(mp(l),l=l.next),l}function ar(n,e){if(!n)return n;e||(e=n);let i,r=n;do if(i=!1,r.steiner||!gh(r,r.next)&&Mn(r.prev,r,r.next)!==0)r=r.next;else{if(mp(r),r=e=r.prev,r===r.next)break;i=!0}while(i||r!==e);return e}function oo(n,e,i,r,s,l,u){if(!n)return;!u&&l&&function(f,g,x,b){let w=f;do w.z===0&&(w.z=Qc(w.x,w.y,g,x,b)),w.prevZ=w.prev,w.nextZ=w.next,w=w.next;while(w!==f);w.prevZ.nextZ=null,w.prevZ=null,function(S){let E,M=1;do{let C,R=S;S=null;let F=null;for(E=0;R;){E++;let z=R,j=0;for(let H=0;H<M&&(j++,z=z.nextZ,z);H++);let $=M;for(;j>0||$>0&&z;)j!==0&&($===0||!z||R.z<=z.z)?(C=R,R=R.nextZ,j--):(C=z,z=z.nextZ,$--),F?F.nextZ=C:S=C,C.prevZ=F,F=C;R=z}F.nextZ=null,M*=2}while(E>1)}(w)}(n,r,s,l);let p=n;for(;n.prev!==n.next;){let f=n.prev,g=n.next;if(l?ls(n,r,s,l):as(n))e.push(f.i,n.i,g.i),mp(n),n=g.next,p=g.next;else if((n=g)===p){u?u===1?oo(n=To(ar(n),e),e,i,r,s,l,2):u===2&&Kc(n,e,i,r,s,l):oo(ar(n),e,i,r,s,l,1);break}}}function as(n){let e=n.prev,i=n,r=n.next;if(Mn(e,i,r)>=0)return!1;let s=e.x,l=i.x,u=r.x,p=e.y,f=i.y,g=r.y,x=Math.min(s,l,u),b=Math.min(p,f,g),w=Math.max(s,l,u),S=Math.max(p,f,g),E=r.next;for(;E!==e;){if(E.x>=x&&E.x<=w&&E.y>=b&&E.y<=S&&pp(s,p,l,f,u,g,E.x,E.y)&&Mn(E.prev,E,E.next)>=0)return!1;E=E.next}return!0}function ls(n,e,i,r){let s=n.prev,l=n,u=n.next;if(Mn(s,l,u)>=0)return!1;let p=s.x,f=l.x,g=u.x,x=s.y,b=l.y,w=u.y,S=Math.min(p,f,g),E=Math.min(x,b,w),M=Math.max(p,f,g),C=Math.max(x,b,w),R=Qc(S,E,e,i,r),F=Qc(M,C,e,i,r),z=n.prevZ,j=n.nextZ;for(;z&&z.z>=R&&j&&j.z<=F;){if(z.x>=S&&z.x<=M&&z.y>=E&&z.y<=C&&z!==s&&z!==u&&pp(p,x,f,b,g,w,z.x,z.y)&&Mn(z.prev,z,z.next)>=0||(z=z.prevZ,j.x>=S&&j.x<=M&&j.y>
7=E&&j.y<=C&&j!==s&&j!==u&&pp(p,x,f,b,g,w,j.x,j.y)&&Mn(j.prev,j,j.next)>=0))return!1;j=j.nextZ}for(;z&&z.z>=R;){if(z.x>=S&&z.x<=M&&z.y>=E&&z.y<=C&&z!==s&&z!==u&&pp(p,x,f,b,g,w,z.x,z.y)&&Mn(z.prev,z,z.next)>=0)return!1;z=z.prevZ}for(;j&&j.z<=F;){if(j.x>=S&&j.x<=M&&j.y>=E&&j.y<=C&&j!==s&&j!==u&&pp(p,x,f,b,g,w,j.x,j.y)&&Mn(j.prev,j,j.next)>=0)return!1;j=j.nextZ}return!0}function To(n,e){let i=n;do{let r=i.prev,s=i.next.next;!gh(r,s)&&Zy(r,i,i.next,s)&&fp(r,s)&&fp(s,r)&&(e.push(r.i,i.i,s.i),mp(i),mp(i.next),i=n=s),i=i.next}while(i!==n);return ar(i)}function Kc(n,e,i,r,s,l){let u=n;do{let p=u.next.next;for(;p!==u.prev;){if(u.i!==p.i&&R1(u,p)){let f=Wy(u,p);return u=ar(u,u.next),f=ar(f,f.next),oo(u,e,i,r,s,l,0),void oo(f,e,i,r,s,l,0)}p=p.next}u=u.next}while(u!==n)}function qs(n,e){let i=n.x-e.x;return i===0&&(i=n.y-e.y,i===0)&&(i=(n.next.y-n.y)/(n.next.x-n.x)-(e.next.y-e.y)/(e.next.x-e.x)),i}function Va(n,e){let i=function(s,l){let u=l,p=s.x,f=s.y,g,x=-1/0;if(gh(s,u))return u;do{if(gh(s,u.next))return u.next;if(f<=u.y&&f>=u.next.y&&u.next.y!==u.y){let M=u.x+(f-u.y)*(u.next.x-u.x)/(u.next.y-u.y);if(M<=p&&M>x&&(x=M,g=u.x<u.next.x?u:u.next,M===p))return g}u=u.next}while(u!==l);if(!g)return null;let b=g,w=g.x,S=g.y,E=1/0;u=g;do{if(p>=u.x&&u.x>=w&&p!==u.x&&Rm(f<S?p:x,f,w,S,f<S?x:p,f,u.x,u.y)){let M=Math.abs(f-u.y)/(p-u.x);fp(u,s)&&(M<E||M===E&&(u.x>g.x||u.x===g.x&&dp(g,u)))&&(g=u,E=M)}u=u.next}while(u!==b);return g}(n,e);if(!i)return e;let r=Wy(i,n);return ar(r,r.next),ar(i,i.next)}function dp(n,e){return Mn(n.prev,n,e.prev)<0&&Mn(e.next,n,n.next)<0}function Qc(n,e,i,r,s){return(n=1431655765&((n=858993459&((n=252645135&((n=16711935&((n=(n-i)*s|0)|n<<8))|n<<4))|n<<2))|n<<1))|(e=1431655765&((e=858993459&((e=252645135&((e=16711935&((e=(e-r)*s|0)|e<<8))|e<<4))|e<<2))|e<<1))<<1}function Dm(n){let e=n,i=n;do(e.x<i.x||e.x===i.x&&e.y<i.y)&&(i=e),e=e.next;while(e!==n);return i}function Rm(n,e,i,r,s,l,u,p){return(s-u)*(e-p)>=(n-u)*(l-p)&&(n-u)*(r-p)>=(i-u)*(e-p)&&(i-u)*(l-p)>=(s-u)*(r-p)}function pp(n,e,i,r,s,l,u,p){return!(n===u&&e===p)&&Rm(n,e,i,r,s,l,u,p)}function R1(n,e){return n.next.i!==e.i&&n.prev.i!==e.i&&!function(i,r){let s=i;do{if(s.i!==i.i&&s.next.i!==i.i&&s.i!==r.i&&s.next.i!==r.i&&Zy(s,s.next,i,r))return!0;s=s.next}while(s!==i);return!1}(n,e)&&(fp(n,e)&&fp(e,n)&&function(i,r){let s=i,l=!1,u=(i.x+r.x)/2,p=(i.y+r.y)/2;do s.y>p!=s.next.y>p&&s.next.y!==s.y&&u<(s.next.x-s.x)*(p-s.y)/(s.next.y-s.y)+s.x&&(l=!l),s=s.next;while(s!==i);return l}(n,e)&&(Mn(n.prev,n,e.prev)||Mn(n,e.prev,e))||gh(n,e)&&Mn(n.prev,n,n.next)>0&&Mn(e.prev,e,e.next)>0)}function Mn(n,e,i){return(e.y-n.y)*(i.x-e.x)-(e.x-n.x)*(i.y-e.y)}function gh(n,e){return n.x===e.x&&n.y===e.y}function Zy(n,e,i,r){let s=Lm(Mn(n,e,i)),l=Lm(Mn(n,e,r)),u=Lm(Mn(i,r,n)),p=Lm(Mn(i,r,e));return s!==l&&u!==p||!(s!==0||!zm(n,i,e))||!(l!==0||!zm(n,r,e))||!(u!==0||!zm(i,n,r))||!(p!==0||!zm(i,e,r))}function zm(n,e,i){return e.x<=Math.max(n.x,i.x)&&e.x>=Math.min(n.x,i.x)&&e.y<=Math.max(n.y,i.y)&&e.y>=Math.min(n.y,i.y)}function Lm(n){return n>0?1:n<0?-1:0}function fp(n,e){return Mn(n.prev,n,n.next)<0?Mn(n,e,n.next)>=0&&Mn(n,n.prev,e)>=0:Mn(n,e,n.prev)<0||Mn(n,n.next,e)<0}function Wy(n,e){let i=bg(n.i,n.x,n.y),r=bg(e.i,e.x,e.y),s=n.next,l=e.prev;return n.next=e,e.prev=n,i.next=s,s.prev=i,r.next=i,i.prev=r,l.next=r,r.prev=l,r}function Xy(n,e,i,r){let s=bg(n,e,i);return r?(s.next=r.next,s.prev=r,r.next.prev=s,r.next=s):(s.prev=s,s.next=s),s}function mp(n){n.next.prev=n.prev,n.prev.next=n.next,n.prevZ&&(n.prevZ.nextZ=n.nextZ),n.nextZ&&(n.nextZ.prevZ=n.prevZ)}function bg(n,e,i){return{i:n,x:e,y:i,prev:null,next:null,z:0,prevZ:null,nextZ:null,steiner:!1}}function _p(n,e){let i=n.length;if(i<=1)return[n];let r=[],s,l;for(let u=0;u<i;u++){let p=Ci(n[u]);p!==0&&(n[u].area=Math.abs(p),l===void 0&&(l=p<0),l===p<0?(s&&r.push(s),s=[n[u]]):s.push(n[u]))}if(s&&r.push(s),e>1)for(let u=0;u<r.length;u++)r[u].length<=e||(vc(r[u],e,1,r[u].length-1,z1),r[u]=r[u].slice(0,e));return r}function z1(n,e){return e.area-n.area}function Yy(n,e,i=1){if(!n)return null;let r=typeof n=="string"?cr.from(n).getPrimary():n.getPrimary(),s=typeof n=="string"?null:n.getSecondary();for(let l of[r,s]){if(!l)continue;let u=l.id.toString();e.has(u)||e.set(u,[]),l.scaleSelf(i),e.get(u).push(l)}return{primary:r.toString(),secondary:s?s.toString():null}}function wg(n,e,i,r){let s=r.patternDependencies,l=!1;for(let u of e){let p=u.paint.get(`${n}-pattern`);p.isConstant()||(l=!0),Yy(p.constantOr(null),s,i)&&(l=!0)}return l}function Tg(n,e,i,r,s,l){let u=l.patternDependencies;for(let p of e){let f=p.paint.get(`${n}-pattern`).value;if(f.kind!=="constant"){let g=Yy(f.evaluate({zoom:r},i,{},void 0,l.availableImages),u,s);if(!g)continue;let{primary:x,secondary:b}=g;
7x&&(i.patterns[p.id]=[x,b].filter(Boolean))}}return i}class ja{constructor(){this.portals=[]}static isOnBorder(e,i){return e<=0&&i<=0||e>=Xe&&i>=Xe}static evaluate(e){if(e.length===0)return new ja;let i=[];for(let f of e)i.push(...f.portals);if(i.length===0)return new ja;for(let f of i){let g=f.va,x=f.vb;(ja.isOnBorder(g.x,x.x)||ja.isOnBorder(g.y,x.y))&&(f.type="border")}let r=i.filter(f=>f.type!=="unevaluated"),s=i.filter(f=>f.type==="unevaluated");if(s.length===0)return new ja;s.sort((f,g)=>f.hash===g.hash?f.isTunnel===g.isTunnel?0:f.isTunnel?-1:1:f.hash<g.hash?1:-1),i=r.concat(s);let l=r.length,u=l,p=l;do if(u++,u===i.length||i[l].hash!==i[u].hash){if(u-l===2){p<l&&(i[p]=i[l],i[l]=null);let f=i[p],g=i[u-1];f.type=f.isTunnel!==g.isTunnel?"tunnel":"polygon",f.connection={a:f.connection.a,b:g.connection.a},p++}l=u}while(l!==i.length);return i.splice(p),i.sort((f,g)=>f.hash<g.hash?1:-1),{portals:i}}}Qe(ja,"ElevationPortalGraph");class L1{constructor(e,i,r){this.outPositions=e,this.outNormals=i,this.outIndices=r,this.vertexLookup=new Map}addVertex(e,i,r){let s=e[2];r!=null&&(s*=r);let l=`${e[0]},${e[1]},${e[2]},${i[0]},${i[1]},${i[2]}`,u=this.vertexLookup.get(l);if(u!=null)return u;let p=this.outPositions.length;this.vertexLookup.set(l,p);let f=Math.trunc(16384*i[0]),g=Math.trunc(16384*i[1]),x=Math.trunc(16384*i[2]);return this.outPositions.emplaceBack(e[0],e[1],s),this.outNormals.emplaceBack(f,g,x),p}addTriangle(e,i,r){this.outIndices.emplaceBack(e,i,r)}addTriangles(e,i,r){if(e.length===0)return;let s=r.length===1,l=si(),u=si();for(let p=0;p<e.length;p+=3){let f=i[e[p+0]],g=i[e[p+1]],x=i[e[p+2]],b=s?r[0]:r[e[p+1]],w=s?r[0]:r[e[p+2]];Ei(l,f.x,f.y,s?r[0]:r[e[p+0]]);let S=this.addVertex(l,u);Ei(l,g.x,g.y,b);let E=this.addVertex(l,u);Ei(l,x.x,x.y,w);let M=this.addVertex(l,u);this.outIndices.emplaceBack(S,E,M)}}addQuad(e,i,r,s,l,u){let p=this.addVertex(e,l,u),f=this.addVertex(i,l,u),g=this.addVertex(r,l,u),x=this.addVertex(s,l,u);this.addTriangle(p,f,g),this.addTriangle(g,x,p)}getVertexCount(){return this.outPositions.length}clearVertexLookup(){this.vertexLookup.clear()}}class Hr{constructor(e,i,r,s){this.unevaluatedPortals=new ja,this.bridgeFeatureSections=[],this.tunnelFeatureSections=[],this.vertexHashLookup=new Map,this.unevalVertices=[],this.unevalHeights=[],this.unevalTriangles=[],this.unevalTunnelTriangles=[],this.unevalEdges=[],this.vertexPositions=new no,this.vertexNormals=new nh,this.indexArray=new Xi,this.tileToMeters=Vr(e),this.bridgeProgramConfigurations=new bo(i,{zoom:r,lut:s},l=>l!=="fill-tunnel-structure-color"),this.tunnelProgramConfigurations=new bo(i,{zoom:r,lut:s},l=>l!=="fill-bridge-guard-rail-color")}addVertices(e,i){let r=this.unevalVertices.length;for(let s=0;s<e.length;s++)this.unevalVertices.push(e[s]),this.unevalHeights.push(i[s]);return r}
7addTriangles(e,i,r){let s=r?this.unevalTunnelTriangles:this.unevalTriangles;for(let l of e)s.push(l+i)}addRenderableRing(e,i,r,s,l,u){let p=[new ke(l.min.x,l.min.y),new ke(l.max.x,l.min.y),new ke(l.max.x,l.max.y),new ke(l.min.x,l.max.y)];for(let f=0;f<r-1;f++){let g=i+f,x=g+1,b=this.unevalVertices[g],w=this.unevalVertices[x];if(!(b.x>=l.min.x&&b.x<=l.max.x&&b.y>=l.min.y&&b.y<=l.max.y||w.x>=l.min.x&&w.x<=l.max.x&&w.y>=l.min.y&&w.y<=l.max.y||k(b,w,p))||this.isOnBorder(b.x,w.x)||this.isOnBorder(b.y,w.y))continue;let S=Hr.computeEdgeHash(this.unevalVertices[g],this.unevalVertices[x]),E,M=this.vertexHashLookup.get(Hr.computePosHash(b));M!=null?E=M.next:(M=this.vertexHashLookup.get(Hr.computePosHash(w)),E=M!=null?M.prev:S),this.unevalEdges.push({polygonIdx:e,a:g,b:x,hash:S,portalHash:E,isTunnel:s,type:"unevaluated",featureInfo:u})}}addPortalCandidates(e,i,r,s,l){if(i.length!==0){this.vertexHashLookup.clear();for(let u of i){if(u.length===0)continue;let p=u[0],f=Hr.computeEdgeHash(p[p.length-2],p.at(-1));for(let g=0;g<p.length-1;g++){let x=p[g+0],b=p[g+1],w=mo(b.x-x.x,b.y-x.y),S=ca(w);if(S===0)continue;let E="unevaluated",M=s.pointElevation(x),C=s.pointElevation(b);Math.abs(M)<.01&&Math.abs(C)<.01?E="entrance":(this.isOnBorder(x.x,b.x)||this.isOnBorder(x.y,b.y))&&(E="border");let R=Hr.computeEdgeHash(x,b);this.unevaluatedPortals.portals.push({connection:{a:e,b:void 0},va:x,vb:b,vab:w,length:S,hash:R,isTunnel:r,type:E});let F=Hr.computePosHash(x);this.vertexHashLookup.set(F,{prev:f,next:R}),f=R}}}}construct(e){if(this.unevalVertices.length===0)return;let i=()=>({vertexOffset:0,primitiveOffset:this.indexArray.length}),r=w=>{w.primitiveLength=this.indexArray.length-w.primitiveOffset},s=new L1(this.vertexPositions,this.vertexNormals,this.indexArray);this.prepareEdges(e.portals,this.unevalEdges);let l=i(),u=i(),p=i(),f=(w,S)=>{w.sort((M,C)=>M.type===S&&C.type!==S?-1:M.type!==S&&C.type===S?1:0);let E=w.findIndex(M=>M.type!==S);return E>=0?E:w.length},g=0;this.unevalEdges.length>0&&(g=f(this.unevalEdges,"none"),this.constructBridgeStructures(s,this.unevalVertices,this.unevalHeights,this.unevalEdges,{min:0,max:g},this.tileToMeters)),r(p);let x=i(),b=i();if(this.unevalEdges.length>0){let w=this.unevalEdges.splice(g),S=f(w,"tunnel")+g;this.unevalEdges.push(...w),this.constructTunnelStructures(s,this.unevalVertices,this.unevalHeights,this.unevalEdges,{min:0,max:g},{min:g,max:S})}r(x),s.addTriangles(this.unevalTriangles,this.unevalVertices,this.unevalHeights),r(b),s.addTriangles(this.unevalTunnelTriangles,this.unevalVertices,this.unevalHeights),r(u),s.addTriangles(this.unevalTunnelTriangles,this.unevalVertices,[-.1]),r(l),this.maskSegments=pi.simpleSegment(0,b.primitiveOffset,0,b.primitiveLength),this.depthSegments=pi.simpleSegment(0,u.primitiveOffset,0,u.primitiveLength),this.renderableBridgeSegments=pi.simpleSegment(0,p.primitiveOffset,0,p.primitiveLength),this.renderableTunnelSegments=pi.simpleSegment(0,x.primitiveOffset,0,x.primitiveLength),this.shadowCasterSegments=pi.simpleSegment(0,l.primitiveOffset,0,l.primitiveLength)}update(e,i,r,s,l,u,p,f){this.bridgeProgramConfigurations.updatePaintArrays(e,i,l,r,s,u,p,f),this.tunnelProgramConfigurations.updatePaintArrays(e,i,l,r,s,u,p,f)}upload(e){this.vertexBuffer||this.vertexPositions.length===0||this.vertexNormals.length===0||this.indexArray.length===0||(this.vertexBuffer=e.createVertexBuffer(this.vertexPositions,bn.members),this.vertexBufferNormal=e.createVertexBuffer(this.vertexNormals,Fi.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,s,l){let u=(p,f)=>{for(let g=0;g<f.length-1;g++){let x=f[g].featureIndex,b=f[g+1].vertexStart,w=e.feature(x);p.populatePaintArrays(b,w,x,{},r,i,s,void 0,l)}};u(this.bridgeProgramConfigurations,this.bridgeFeatureSections),u(this.tunnelProgramConfigurations,this.tunnelFeatureSections)}computeVertexConnections(e,i,r,s,l){let u=new Map;for(let p=s;p<l;p++){let f=r[p],g=f.a,x=f.b,b=Hr.computePosHash(e[g]),w=Hr.computePosHash(e[x]),S=u.get(b);
7S||(S={},u.set(b,S));let E=u.get(w);E||(E={},u.set(w,E)),i[g]<=0&&i[x]<=0||(S.to=x,E.from=g)}return u}isTerminalVertex(e,i){let r=Hr.computePosHash(this.unevalVertices[e]),s=i.get(r);return!s||!s.from||!s.to}constructBridgeStructures(e,i,r,s,l,u){e.clearVertexLookup();let p=this.computeVertexConnections(i,r,s,l.min,l.max),f=1/u,g=.5*f,x=(Ae,Ee)=>Ei(Ae,i[Ee].x,i[Ee].y,r[Ee]*f),b=si(),w=si(),S=si(),E=si(),M=si(),C=(Ae,Ee)=>{let Be=p.get(Hr.computePosHash(i[Ee])),xe=Be.from,Se=Be.to;if(!xe||!Se)return;x(b,xe),x(w,Ee),x(S,Se),Wa(E),Mo(b,w)||(Gi(M,w,b),hi(E,M)),Mo(S,w)||(Gi(M,S,w),tn(E,E,hi(M,M)));let Me=ra(E);return Me>0?Li(Ae,E,1/Me):void 0},R=Number.POSITIVE_INFINITY;this.sortSubarray(s,l.min,l.max,(Ae,Ee)=>Ae.featureInfo.featureIndex-Ee.featureInfo.featureIndex);let F=si(),z=si(),j=si(),$=si(),H=si(),ie=si(),W=si(),Q=si(),Y=si(),ee=[si(),si(),si(),si()],me=[si(),si(),si(),si()],ge=[{coord:new ke(0,0),height:0},{coord:new ke(0,0),height:0}],Te=(Ae,Ee)=>Ae>Ee;for(let Ae=l.min;Ae<l.max;Ae++){let Ee=s[Ae];if(!Ee.featureInfo.guardRailEnabled||!this.prepareEdgePoints(ge,i,r,Ee,Te))continue;let[Be,xe]=ge;if(Ei(F,Be.coord.x,Be.coord.y,f*Be.height),Ei(z,xe.coord.x,xe.coord.y,f*xe.height),Mo(F,z))continue;Gi(j,z,F),hi(j,j);let Se=C(Q,Ee.a)||j,Me=C(Y,Ee.b)||j;Ei($,Se[1],-Se[0],0),hi($,$),Ei(H,Me[1],-Me[0],0),hi(H,H),Wn(Q,$,Se),hi(ie,Q),Wn(Q,H,Me),hi(W,Q),tn(ee[0],F,Li(Q,Gi(Q,$,ie),g)),tn(ee[1],F,Li(Q,tn(Q,$,ie),g)),tn(ee[2],F,Li(Q,ie,g)),ee[3]=F,tn(me[0],z,Li(Q,Gi(Q,H,W),g)),tn(me[1],z,Li(Q,tn(Q,H,W),g)),tn(me[2],z,Li(Q,W,g)),me[3]=z,R=this.addFeatureSection(Ee.featureInfo.featureIndex,R,this.bridgeFeatureSections,e);let ze=e.addVertex(ee[0],$,u),Le=e.addVertex(ee[1],$,u),We=e.addVertex(me[0],H,u),De=e.addVertex(me[1],H,u);e.addTriangle(ze,Le,We),e.addTriangle(Le,De,We);let Ge=e.addVertex(ee[1],ie,u),He=e.addVertex(ee[2],ie,u),Je=e.addVertex(me[1],W,u),tt=e.addVertex(me[2],W,u);e.addTriangle(Ge,He,Je),e.addTriangle(He,tt,Je),fo($,$),fo(H,H);let lt=e.addVertex(ee[2],$,u),rt=e.addVertex(ee[3],$,u),pt=e.addVertex(me[2],H,u),Ht=e.addVertex(me[3],H,u);e.addTriangle(lt,rt,pt),e.addTriangle(rt,Ht,pt);let wt=this.isTerminalVertex(Ee.a,p),kt=this.isTerminalVertex(Ee.b,p);Be.height<.01&&wt&&e.addQuad(ee[3],ee[2],ee[1],ee[0],fo(Se,Se),u),xe.height<.01&&kt&&e.addQuad(me[0],me[1],me[2],me[3],Me,u)}this.bridgeFeatureSections.push({featureIndex:Number.POSITIVE_INFINITY,vertexStart:e.getVertexCount()})}constructTunnelStructures(e,i,r,s,l,u){e.clearVertexLookup();let p=Number.POSITIVE_INFINITY,f=(R,F)=>R.featureInfo.featureIndex-F.featureInfo.featureIndex;this.sortSubarray(s,l.min,l.max,f),this.sortSubarray(s,u.min,u.max,f);let g=R=>hi(R,R),x=[{coord:new ke(0,0),height:0},{coord:new ke(0,0),height:0}],b=(R,F)=>R<F,w=si(),S=si(),E=si(),M=si(),C=si();for(let R=l.min;R<l.max;R++){if(!this.prepareEdgePoints(x,i,r,s[R],b))continue;let[F,z]=x,j=g(Ei(C,-(z.coord.y-F.coord.y),z.coord.x-F.coord.x,0));p=this.addFeatureSection(s[R].featureInfo.featureIndex,p,this.tunnelFeatureSections,e),e.addQuad(Ei(w,F.coord.x,F.coord.y,F.height),Ei(S,z.coord.x,z.coord.y,z.height),Ei(E,z.coord.x,z.coord.y,s[R].isTunnel?-.1:0),Ei(M,F.coord.x,F.coord.y,s[R].isTunnel?-.1:0),j)}for(let R=u.min;R<u.max;R++){let F=s[R];F.isTunnel&&([F.a,F.b]=[F.b,F.a]);let z=i[F.a],j=i[F.b],$=g(Ei(C,-(j.y-z.y),j.x-z.x,0));p=this.addFeatureSection(F.featureInfo.featureIndex,p,this.tunnelFeatureSections,e),e.addQuad(Ei(w,j.x,j.y,0),Ei(S,z.x,z.y,0),Ei(E,z.x,z.y,r[F.a]+4),Ei(M,j.x,j.y,r[F.b]+4),$),e.addQuad(Ei(w,z.x,z.y,0),Ei(S,j.x,j.y,0),Ei(E,j.x,j.y,r[F.b]+4),Ei(M,z.x,z.y,r[F.a]+4),$)}this.tunnelFeatureSections.push({featureIndex:Number.POSITIVE_INFINITY,vertexStart:e.getVertexCount()})}setElevatedPoint(e,i,r,s){e.coord.x=i,e.coord.y=r,e.height=s}prepareEdgePoints(e,i,r,s,l){let u=i[s.a].x,p=i[s.a].y,f=i[s.b].x,g=i[s.b].y,x=r[s.a],b=r[s.b],w=l(x,0),S=l(b,0);if(w&&S)return this.setElevatedPoint(e[0],u,p,x),this.setElevatedPoint(e[1],f,g,b),!0;if(!w&&!S)return!1;if(w){if(!S){let E=b/(b-x);f=ft(f,u,E),g=ft(g,p,E),b=ft(b,x,E)}}else{let E=x/(x-b);u=ft(u,f,E),p=ft(p,g,E),x=ft(x,b,E)}return this.setElevatedPoint(e[0],u,p,x),this.setElevatedPoint(e[1],f,g,b),!0}prepareEdges(e,i){if(i.length===0)return;i.sort((p,f)=>p.hash===f.hash?f.polygonIdx-p.polygonIdx:f.hash>p.hash?1:-1);let r=0,s=0,l=0,u=i[r].polygonIdx;do s++,(s===i.length||i[r].hash!==i[s].hash)&&((s-r===1||i[s-1].polygonIdx!==u)&&(l<r&&(i[l]=i[r],i[r]=null),i[l].type="none",l++),r=s,r!==i.length&&(u=i[r].polygonIdx));while(r!==i.length);if(i.splice(l),i.length!==0&&e.length!==0){i.sort((g,x)=>g.portalHash<x.portalHash?1:-1);let p=0,f=0;for(;p!==i.length&&f!==e.length;){let g=i[p],x=e[f];g.portalHash>x.hash?p++:x.hash>g.portalHash?f++:(g.type=x.type,p++)}}}isOnBorder(e,i){return e<=0&&i<=0||e>=Xe&&i>=Xe}addFeatureSection(e,i,r,s){return e!==i&&(i=e,r.push({featureIndex:e,vertexStart:s.getVertexCount()}),s.clearVertexLookup()),i}sortSubarray(e,i,r,s){let l=e.slice(i,r);l.sort(s),e.splice(i,l.length,...l)}static computeEdgeHash(e,i){return(e.y===i.y&&e.x>i.x||e.y>i.y)&&([e,i]=[i,e]),BigInt(Hr.computePosHash(e))<<32n|BigInt(Hr.computePosHash(i))}static computePosHash(e){return((65535&e.x)<<16|65535&e.y)>>>0}}function O1(n,e){return n>e?1:n<e?-1:0}class Sg{constructor(e=O1,i=!1){this._compare=e,this._root=null,this._size=0,this._noDuplicates=!!i}rotateLeft(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
vendor: 4,640 bytes, line 7
7=e),e.parent=i}rotateRight(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}_splay(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)}}splay(e){for(var i,r,s,l,u;e.parent;)(r=(i=e.parent).parent)&&r.parent?((s=r.parent).left===r?s.left=e:s.right=e,e.parent=s):(e.parent=null,this._root=e),l=e.left,u=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):(l?(r.right=l,l.parent=r):r.right=null,e.left=r,r.parent=e)),u?(i.left=u,u.parent=i):i.left=null,e.right=i,i.parent=e):(r&&(r.right===i?(i.left?(r.right=i.left,r.right.parent=r):r.right=null,i.left=r,r.parent=i):(u?(r.left=u,u.parent=r):r.left=null,e.right=r,r.parent=e)),l?(i.right=l,l.parent=i):i.right=null,e.left=i,i.parent=e)}replace(e,i){e.parent?e===e.parent.left?e.parent.left=i:e.parent.right=i:this._root=i,i&&(i.parent=e.parent)}minNode(e=this._root){if(e)for(;e.left;)e=e.left;return e}maxNode(e=this._root){if(e)for(;e.right;)e=e.right;return e}insert(e,i){var r=this._root,s=null,l=this._compare;if(this._noDuplicates)for(;r;){if(s=r,l(r.key,e)===0)return;r=l(r.key,e)<0?r.right:r.left}else for(;r;)s=r,r=l(r.key,e)<0?r.right:r.left;return r={key:e,data:i,left:null,right:null,parent:s},s?l(s.key,r.key)<0?s.right=r:s.left=r:this._root=r,this.splay(r),this._size++,r}find(e){for(var i=this._root,r=this._compare;i;){var s=r(i.key,e);if(s<0)i=i.right;else{if(!(s>0))return i;i=i.left}}return null}contains(e){for(var i=this._root,r=this._compare;i;){var s=r(e,i.key);if(s===0)return!0;i=s<0?i.left:i.right}return!1}remove(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}removeNode(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}erase(e){var i=this.find(e);if(i){this.splay(i);var r=i.left,s=i.right,l=null;r&&(r.parent=null,l=this.maxNode(r),this.splay(l),this._root=l),s&&(r?l.right=s:this._root=s,s.parent=l),this._size--}}pop(){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}next(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}prev(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}forEach(e){for(var i=this._root,r=[],s=!1,l=0;!s;)i?(r.push(i),i=i.left):r.length>0?(e(i=r.pop(),l++),i=i.right):s=!0;return this}range(e,i,r,s){let l=[],u=this._compare,p,f=this._root;for(;l.length!==0||f;)if(f)l.push(f),f=f.left;else{if(f=l.pop(),p=u(f.key,i),p>0)break;if(u(f.key,e)>=0&&r.call(s,f))return this;f=f.right}return this}keys(){for(var e=this._root,i=[],r=[],s=!1;!s;)e?(i.push(e),e=e.left):i.length>0?(e=i.pop(),r.push(e.key),e=e.right):s=!0;return r}values(){for(var e=this._root,i=[],r=[],s=!1;!s;)e?(i.push(e),e=e.left):i.length>0?(e=i.pop(),r.push(e.data),e=e.right):s=!0;return r}at(e){for(var i=this._root,r=[],s=!1,l=0;!s;)if(i)r.push(i),i=i.left;else if(r.length>0){if(i=r.pop(),l===e)return i;l++,i=i.right}else s=!0;return null}load(e=[],i=[],r=!1){if(this._size!==0)throw new Error("bulk-load: tree is not empty");let s=e.length;return r&&Eg(e,i,0,s-1,this._compare),this._root=Ig(null,e,i,0,s),this._size=s,this}min(){var e=this.minNode(this._root);return e?e.key:null}max(){var e=this.maxNode(this._root);return e?e.key:null}isEmpty(){return this._root===null}get size(){return this._size}static createTree(e,i,r,s,l){return new Sg(r,l).load(e,i,s)}}function Ig(n,e,i,r,s){let l=s-r;if(l>0){let u=r+Math.floor(l/2),p={key:e[u],data:i[u],parent:n};return p.left=Ig(p,e,i,r,u),p.right=Ig(p,e,i,u+1,s),p}return null}function Eg(n,e,i,r,s){if(i>=r)return;let l=n[i+r>>1],u=i-1,p=r+1;for(;;){do u++;while(s(n[u],l)<0);do p--;while(s(n[p],l)>0);if(u>=p)break;let f=n[u];
7n[u]=n[p],n[p]=f,f=e[u],e[u]=e[p],e[p]=f}Eg(n,e,i,p,s),Eg(n,e,p+1,r,s)}let Jy=11102230246251565e-32,Ar=134217729,F1=(3+8*Jy)*Jy;function Ag(n,e,i,r,s){let l,u,p,f,g=e[0],x=r[0],b=0,w=0;x>g==x>-g?(l=g,g=e[++b]):(l=x,x=r[++w]);let S=0;if(b<n&&w<i)for(x>g==x>-g?(u=g+l,p=l-(u-g),g=e[++b]):(u=x+l,p=l-(u-x),x=r[++w]),l=u,p!==0&&(s[S++]=p);b<n&&w<i;)x>g==x>-g?(u=l+g,f=u-l,p=l-(u-f)+(g-f),g=e[++b]):(u=l+x,f=u-l,p=l-(u-f)+(x-f),x=r[++w]),l=u,p!==0&&(s[S++]=p);for(;b<n;)u=l+g,f=u-l,p=l-(u-f)+(g-f),g=e[++b],l=u,p!==0&&(s[S++]=p);for(;w<i;)u=l+x,f=u-l,p=l-(u-f)+(x-f),x=r[++w],l=u,p!==0&&(s[S++]=p);return l===0&&S!==0||(s[S++]=l),S}function gp(n){return new Float64Array(n)}let yh=gp(4),Ky=gp(8),Qy=gp(12),e0=gp(16),qr=gp(4);function yp(n,e,i){e===null?(n.inOut=!1,n.otherInOut=!0):(n.isSubject===e.isSubject?(n.inOut=!e.inOut,n.otherInOut=e.otherInOut):(n.inOut=!e.otherInOut,n.otherInOut=e.isVertical()?!e.inOut:e.inOut),e&&(n.prevInResult=!t0(e,i)||e.isVertical()?e.prevInResult:e)),n.resultTransition=t0(n,i)?function(r,s){let l,u=!r.inOut,p=!r.otherInOut;switch(s){case 0:l=u&&p;break;case 1:l=u||p;break;case 3:l=u!==p;break;case 2:l=r.isSubject?u&&!p:p&&!u}return l?1:-1}(n,i):0}function t0(n,e){switch(n.type){case 0:switch(e){case 0:return!n.otherInOut;case 1:return n.otherInOut;case 2:return n.isSubject&&n.otherInOut||!n.isSubject&&!n.otherInOut;case 3:return!0}break;case 2:return e===0||e===1;case 3:return e===2;case 1:return!1}return!1}class xh{constructor(e,i,r,s,l){this.left=i,this.point=e,this.otherEvent=r,this.isSubject=s??!1,this.type=l||0,this.inOut=!1,this.otherInOut=!1,this.prevInResult=null,this.resultTransition=0,this.otherPos=-1,this.outputContourId=-1,this.isExteriorRing=!0}isBelow(e){let i=this.point,r=this.otherEvent.point;return 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}isAbove(e){return!this.isBelow(e)}isVertical(){return this.point[0]===this.otherEvent.point[0]}get inResult(){return this.resultTransition!==0}clone(){let e=new xh(this.point,this.left,this.otherEvent,this.isSubject,this.type);return e.contourId=this.contourId,e.resultTransition=this.resultTransition,e.prevInResult=this.prevInResult,e.isExteriorRing=this.isExteriorRing,e.inOut=this.inOut,e.otherInOut=this.otherInOut,e}}function Zs(n,e){return n[0]===e[0]&&n[1]===e[1]}function Mg(n,e,i){let r=function(s,l,u,p,f,g){let x=(l-g)*(u-f),b=(s-f)*(p-g),w=x-b;if(x===0||b===0||x>0!=b>0)return w;let S=Math.abs(x+b);return Math.abs(w)>=33306690738754716e-32*S?w:-function(E,M,C,R,F,z,j){let $,H,ie,W,Q,Y,ee,me,ge,Te,Ae,Ee,Be,xe,Se,Me,ze,Le,We=E-F,De=C-F,Ge=M-z,He=R-z;xe=We*He,Y=Ar*We,ee=Y-(Y-We),me=We-ee,Y=Ar*He,ge=Y-(Y-He),Te=He-ge,Se=me*Te-(xe-ee*ge-me*ge-ee*Te),Me=Ge*De,Y=Ar*Ge,ee=Y-(Y-Ge),me=Ge-ee,Y=Ar*De,ge=Y-(Y-De),Te=De-ge,ze=me*Te-(Me-ee*ge-me*ge-ee*Te),Ae=Se-ze,Q=Se-Ae,yh[0]=Se-(Ae+Q)+(Q-ze),Ee=xe+Ae,Q=Ee-xe,Be=xe-(Ee-Q)+(Ae-Q),Ae=Be-Me,Q=Be-Ae,yh[1]=Be-(Ae+Q)+(Q-Me),Le=Ee+Ae,Q=Le-Ee,yh[2]=Ee-(Le-Q)+(Ae-Q),yh[3]=Le;let Je=function(Ht,wt){let kt=wt[0];for(let At=1;At<4;At++)kt+=wt[At];return kt}(0,yh),tt=22204460492503146e-32*j;if(Je>=tt||-Je>=tt||(Q=E-We,$=E-(We+Q)+(Q-F),Q=C-De,ie=C-(De+Q)+(Q-F),Q=M-Ge,H=M-(Ge+Q)+(Q-z),Q=R-He,W=R-(He+Q)+(Q-z),$===0&&H===0&&ie===0&&W===0)||(tt=11093356479670487e-47*j+F1*Math.abs(Je),Je+=We*W+He*$-(Ge*ie+De*H),Je>=tt||-Je>=tt))return Je;xe=$*He,Y=Ar*$,ee=Y-(Y-$),me=$-ee,Y=Ar*He,ge=Y-(Y-He),Te=He-ge,Se=me*Te-(xe-ee*ge-me*ge-ee*Te),Me=H*De,Y=Ar*H,ee=Y-(Y-H),me=H-ee,Y=Ar*De,ge=Y-(Y-De),Te=De-ge,ze=me*Te-(Me-ee*ge-me*ge-ee*Te),Ae=Se-ze,Q=Se-Ae,qr[0]=Se-(Ae+Q)+(Q-ze),Ee=xe+Ae,Q=Ee-xe,Be=xe-(Ee-Q)+(Ae-Q),Ae=Be-Me,Q=Be-Ae,qr[1]=Be-(Ae+Q)+(Q-Me),Le=Ee+Ae,Q=Le-Ee,qr[2]=Ee-(Le-Q)+(Ae-Q),qr[3]=Le;let lt=Ag(4,yh,4,qr,Ky);xe=We*W,Y=Ar*We,ee=Y-(Y-We),me=We-ee,Y=Ar*W,ge=Y-(Y-W),Te=W-ge,Se=me*Te-(xe-ee*ge-me*ge-ee*Te),Me=Ge*ie,Y=Ar*Ge,ee=Y-(Y-Ge),me=Ge-ee,Y=Ar*ie,ge=Y-(Y-ie),Te=ie-ge,ze=me*Te-(Me-ee*ge-me*ge-ee*Te),Ae=Se-ze,Q=Se-Ae,qr[0]=Se-(Ae+Q)+(Q-ze),Ee=xe+Ae,Q=Ee-xe,Be=xe-(Ee-Q)+(Ae-Q),Ae=Be-Me,Q=Be-Ae,qr[1]=Be-(Ae+Q)+(Q-Me),Le=Ee+Ae,Q=Le-Ee,qr[2]=Ee-(Le-Q)+(Ae-Q),qr[3]=Le;let rt=Ag(lt,Ky,4,qr,Qy);
7xe=$*W,Y=Ar*$,ee=Y-(Y-$),me=$-ee,Y=Ar*W,ge=Y-(Y-W),Te=W-ge,Se=me*Te-(xe-ee*ge-me*ge-ee*Te),Me=H*ie,Y=Ar*H,ee=Y-(Y-H),me=H-ee,Y=Ar*ie,ge=Y-(Y-ie),Te=ie-ge,ze=me*Te-(Me-ee*ge-me*ge-ee*Te),Ae=Se-ze,Q=Se-Ae,qr[0]=Se-(Ae+Q)+(Q-ze),Ee=xe+Ae,Q=Ee-xe,Be=xe-(Ee-Q)+(Ae-Q),Ae=Be-Me,Q=Be-Ae,qr[1]=Be-(Ae+Q)+(Q-Me),Le=Ee+Ae,Q=Le-Ee,qr[2]=Ee-(Le-Q)+(Ae-Q),qr[3]=Le;let pt=Ag(rt,Qy,4,qr,e0);return e0[pt-1]}(s,l,u,p,f,g,S)}(n[0],n[1],e[0],e[1],i[0],i[1]);return r>0?-1:r<0?1:0}function Ul(n,e){let i=n.point,r=e.point;return i[0]>r[0]?1:i[0]<r[0]?-1:i[1]!==r[1]?i[1]>r[1]?1:-1:function(s,l,u){return s.left!==l.left?s.left?1:-1:Mg(u,s.otherEvent.point,l.otherEvent.point)!==0?s.isBelow(l.otherEvent.point)?-1:1:!s.isSubject&&l.isSubject?1:-1}(n,e,i)}function Vl(n,e,i){let r=new xh(e,!1,n,n.isSubject),s=new xh(e,!0,n.otherEvent,n.isSubject);return Zs(n.point,n.otherEvent.point)&&console.warn("what is that, a collapsed segment?",n),r.contourId=s.contourId=n.contourId,Ul(s,n.otherEvent)>0&&(n.otherEvent.left=!0,s.left=!1),n.otherEvent.otherEvent=s,n.otherEvent=r,i.push(s),i.push(r),i}function Om(n,e){return n[0]*e[1]-n[1]*e[0]}function Cg(n,e){return n[0]*e[0]+n[1]*e[1]}function Pg(n,e,i){let r=function(f,g,x,b){let w=[g[0]-f[0],g[1]-f[1]],S=[b[0]-x[0],b[1]-x[1]];function E(ie,W,Q){return[ie[0]+W*Q[0],ie[1]+W*Q[1]]}let M=[x[0]-f[0],x[1]-f[1]],C=Om(w,S),R=C*C,F=Cg(w,w);if(R>0){let ie=Om(M,S)/C;if(ie<0||ie>1)return null;let W=Om(M,w)/C;return W<0||W>1?null:ie===0||ie===1?[E(f,ie,w)]:W===0||W===1?[E(x,W,S)]:[E(f,ie,w)]}if(C=Om(M,w),R=C*C,R>0)return null;let z=Cg(w,M)/F,j=z+Cg(w,S)/F,$=Math.min(z,j),H=Math.max(z,j);return $<=1&&H>=0?$===1?[E(f,$>0?$:0,w)]:H===0?[E(f,H<1?H:1,w)]:[E(f,$>0?$:0,w),E(f,H<1?H:1,w)]:null}
7(n.point,n.otherEvent.point,e.point,e.otherEvent.point),s=r?r.length:0;if(s===0||s===1&&(Zs(n.point,e.point)||Zs(n.otherEvent.point,e.otherEvent.point))||s===2&&n.isSubject===e.isSubject)return 0;if(s===1)return!Zs(n.point,r[0])&&!Zs(n.otherEvent.point,r[0])&&Vl(n,r[0],i),!Zs(e.point,r[0])&&!Zs(e.otherEvent.point,r[0])&&Vl(e,r[0],i),1;let l=[],u=!1,p=!1;return Zs(n.point,e.point)?u=!0:Ul(n,e)===1?l.push(e,n):l.push(n,e),Zs(n.otherEvent.point,e.otherEvent.point)?p=!0:Ul(n.otherEvent,e.otherEvent)===1?l.push(e.otherEvent,n.otherEvent):l.push(n.otherEvent,e.otherEvent),u&&p||u?(e.type=1,n.type=e.inOut===n.inOut?2:3,u&&!p&&Vl(l[1].otherEvent,l[0].point,i),2):p?(Vl(l[0],l[1].point,i),3):l[0]!==l[3].otherEvent?(Vl(l[0],l[1].point,i),Vl(l[1],l[2].point,i),3):(Vl(l[0],l[1].point,i),Vl(l[3].otherEvent,l[2].point,i),3)}function B1(n,e){if(n===e)return 0;if(Mg(n.point,n.otherEvent.point,e.point)!==0||Mg(n.point,n.otherEvent.point,e.otherEvent.point)!==0)return Zs(n.point,e.point)?n.isBelow(e.otherEvent.point)?-1:1:n.point[0]===e.point[0]?n.point[1]<e.point[1]?-1:1:Ul(n,e)===1?e.isAbove(n.point)?-1:1:n.isBelow(e.point)?-1:1;if(n.isSubject!==e.isSubject)return n.isSubject?-1:1;{let i=n.point,r=e.point;if(i[0]===r[0]&&i[1]===r[1])return i=n.otherEvent.point,r=e.otherEvent.point,i[0]===r[0]&&i[1]===r[1]?0:(n.contourId??0)>(e.contourId??0)?1:-1}return Ul(n,e)===1?1:-1}class k1{constructor(){this.points=[],this.holeIds=[],this.holeOf=null,this.depth=null}isExterior(){return this.holeOf==null}}function N1(n,e,i,r){let s,l=n+1,u=e[n].point,p=e.length;for(l<p&&(s=e[l].point);l<p&&s[0]===u[0]&&s[1]===u[1];){if(!i[l])return l;l++,l<p&&(s=e[l].point)}for(l=n-1;i[l]&&l>r;)l--;return l}function U1(n,e,i){let r=new k1;if(n.prevInResult!=null){let s=n.prevInResult,l=s.outputContourId;if(s.resultTransition>0){let u=e[l];if(u.holeOf!=null){let p=u.holeOf;e[p].holeIds.push(i),r.holeOf=p,r.depth=e[l].depth}else e[l].holeIds.push(i),r.holeOf=l,r.depth=e[l].depth+1}else r.holeOf=null,r.depth=e[l].depth}else r.holeOf=null,r.depth=0;return r}let i0=Math.max,n0=Math.min,Fm=0;function r0(n,e,i,r,s,l){let u,p,f,g,x,b;for(u=0,p=n.length-1;u<p;u++){if(f=n[u],g=n[u+1],x=new xh(f,!1,void 0,e),b=new xh(g,!1,x,e),x.otherEvent=b,f[0]===g[0]&&f[1]===g[1])continue;x.contourId=b.contourId=i,l||(x.isExteriorRing=!1,b.isExteriorRing=!1),Ul(x,b)>0?b.left=!0:x.left=!0;let w=f[0],S=f[1];s[0]=n0(s[0],w),s[1]=n0(s[1],S),s[2]=i0(s[2],w),s[3]=i0(s[3],S),r.push(x),r.push(b)}}let Bm=[];function o0(n,e,i){let r=n,s=e;typeof n[0][0][0]=="number"&&(r=[n]),typeof e[0][0][0]=="number"&&(s=[e]);let l=function(w,S,E){let M=null;return w.length*S.length===0&&(E===0?M=Bm:E===2?M=w:(E===1||E===3)&&(M=w.length===0?S:w)),M}(r,s,i);if(l)return l===Bm?null:l;let u=[1/0,1/0,-1/0,-1/0],p=[1/0,1/0,-1/0,-1/0],f=function(w,S,E,M,C){let R=new dt(void 0,Ul),F,z,j,$,H,ie;for(j=0,$=w.length;j<$;j++)for(F=w[j],H=0,ie=F.length;H<ie;H++)z=H===0,z&&Fm++,r0(F[H],!0,Fm,R,E,z);for(j=0,$=S.length;j<$;j++)for(F=S[j],H=0,ie=F.length;H<ie;H++)z=H===0,C===2&&(z=!1),z&&Fm++,r0(F[H],!1,Fm,R,M,z);return R}(r,s,u,p,i);if(l=function(w,S,E,M,C){let R=null;return(E[0]>M[2]||M[0]>E[2]||E[1]>M[3]||M[1]>E[3])&&(C===0?R=Bm:C===2?R=w:(C===1||C===3)&&(R=w.concat(S))),R}(r,s,u,p,i),l)return l===Bm?null:l;let g=function(w,S,E,M,C,R){let F=new Sg(B1),z=[],j=Math.min(M[2],C[2]),$,H,ie;for(;w.length!==0;){let W=w.pop();if(z.push(W),R===0&&W.point[0]>j||R===2&&W.point[0]>M[2])break;if(W.left){H=$=F.insert(W),ie=F.minNode(),$=$!==ie?F.prev($):null,H=F.next(H);let Q=$?$.key:null,Y;if(yp(W,Q,R),H&&Pg(W,H.key,w)===2&&(yp(W,Q,R),yp(H.key,W,R)),$&&Pg($.key,W,w)===2){let ee=$;ee=ee!==ie?F.prev(ee):null,Y=ee?ee.key:null,yp(Q,Y,R),yp(W,Q,R)}}else W=W.otherEvent,H=$=F.find(W),$&&H&&($=$!==ie?F.prev($):null,H=F.next(H),F.remove(W),H&&$&&Pg($.key,H.key,w))}return z}(f,0,0,u,p,i),x=function(w){let S,E,M=function(F){let z,j,$,H,ie,W=[];for(j=0,$=F.length;j<$;j++)z=F[j],(z.left&&z.inResult||!z.left&&z.otherEvent.inResult)&&W.push(z);let Q=!1;for(;!Q;)for(Q=!0,j=0,$=W.length;j<$;j++)j+1<$&&Ul(W[j],W[j+1])===1&&(H=W[j],W[j]=W[j+1],W[j+1]=H,Q=!1);for(j=0,$=W.length;j<$;j++)z=W[j],z.otherPos=j;for(j=0,$=W.length;j<$;j++)z=W[j],z.left||(ie=z.otherPos,z.otherPos=z.otherEvent.otherPos,z.otherEvent.otherPos=ie);return W}(w),C={},R=[];for(S=0,E=M.length;S<E;S++){if(C[S])continue;let F=R.length,z=U1(M[S],R,F),j=ie=>{C[ie]=!0,ie<M.length&&M[ie]&&(M[ie].outputContourId=F)},$=S,H=S;for(z.points.push(M[S].point);j($),$=M[$].otherPos,j($),z.points.push(M[$].point),$=N1($,M,C,H),!($==H||$>=M.length)&&M[$];);R.push(z)}return R}(g),b=[];for(let w=0;w<x.length;w++){let S=x[w];if(S.isExterior()){let E=[S.points];for(let M=0;M<S.holeIds.length;M++)E.push(x[S.holeIds[M]].points);b.push(E)}}return b}function km(n,e,i,r){let s=[],l=r===0?(u,p,f,g,x,b)=>{u.push(new ke(b,f+(b-p)/(g-p)*(x-f)))}:(u,p,f,g,x,b)=>{u.push(new ke(p+(b-f)/(x-f)*(g-p),b))};for(let u of n){let p=[];for(let f of u){if(f.length<=2)continue;let g=[];for(let w=0;w<f.length-1;w++){let S=f[w].x,E=f[w].y,M=f[w+1].x,C=f[w+1].y,R=r===0?S:E,F=r===0?M:C;R<e?F>e&&l(g,S,E,M,C,e):R>i?F<i&&l(g,S,E,M,C,i):g.push(f[w]),F<e&&R>=e&&l(g,S,E,M,C,e),F>i&&R<=i&&l(g,S,E,M,C,i)}let x=f.at(-1),b=r===0?x.x:x.y;b>=e&&b<=i&&g.push(x),g.length&&(x=g.at(-1),g[0].x===x.x&&g[0].y===x.y||g.push(g[0]),p.push(g))}p.length&&s.push(p)}return s}
7function V1(n,e){let i=o0(Dg(n),Dg([e]),0);return i==null?[]:s0(i)}function j1(n,e,i=0){let s=Dg(n,65536),l=[];for(;e.valid();e.next()){let[u,p]=e.get(),f=u.x*65536,g=u.y*65536,x=p.x*65536,b=p.y*65536,w=x-f,S=b-g,E=Math.hypot(w,S);if(E===0)continue;f-=w*i,g-=S*i,x+=w*i,b+=S*i;let M=Math.trunc(S/E*3),C=-Math.trunc(w/E*3);l.push([[[f,g],[x,b],[x+M,b+C],[f+M,g+C],[f,g]]])}return l.length>0&&(s=o0(s,l,2)),s0(s,1/65536,128)}function Dg(n,e=1){return[n.map(i=>i.map(r=>[r.x*e,r.y*e]))]}function s0(n,e=1,i){return n.map(r=>r.map((s,l)=>{let u=s.map(p=>{let f=p[0],g=p[1];return i&&(f=Math.round(f/i)*i,g=Math.round(g/i)*i),new ke(f*e,g*e)._round()});return l>0&&u.reverse(),u}))}class Rg{constructor(e,i){this.layoutVertexArray=new Hn,this.indexArray=new Xi,this.lineIndexArray=new kr,this.triangleSegments=new pi,this.lineSegments=new pi,this.programConfigurations=new bo(e.layers,{zoom:e.zoom,lut:e.lut}),this.uploaded=!1,i&&(this.elevatedLayoutVertexArray=new Do)}update(e,i,r,s,l,u,p,f){this.programConfigurations.updatePaintArrays(e,i,l,r,s,u,p,f)}isEmpty(){return this.layoutVertexArray.length===0}needsUpload(){return this.programConfigurations.needsUpload}upload(e){this.uploaded||(this.layoutVertexBuffer=e.createVertexBuffer(this.layoutVertexArray,oi.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,Ji.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,s,l,u,p){this.programConfigurations.populatePaintArrays(this.layoutVertexArray.length,e,i,r,s,l,u,void 0,p)}}class Nm{constructor(e){this.zoom=e.zoom,this.pixelRatio=e.pixelRatio,this.overscaling=e.overscaling,this.layers=e.layers,this.layerIds=this.layers.map(i=>i.fqid),this.index=e.index,this.hasPattern=!1,this.patternFeatures=[],this.lut=e.lut,this.bufferData=new Rg(e,!1),this.elevationBufferData=new Rg(e,!0),this.stateDependentLayerIds=this.layers.filter(i=>i.isStateDependent()).map(i=>i.id),this.projection=e.projection,this.elevationMode=this.layers[0].layout.get("fill-elevation-reference"),this.sourceLayerIndex=e.sourceLayerIndex,this.worldview=e.worldview,this.hasAppearances=null}updateFootprints(e,i){}updateAppearances(e,i,r,s){return{hasLayoutChanges:!1,hasUboChanges:!1}}populate(e,i,r,s){this.hasPattern=wg("fill",this.layers,this.pixelRatio,i);let l=this.layers[0].layout.get("fill-sort-key"),u=[];for(let{feature:p,id:f,index:g,sourceLayerIndex:x}of e){let b=this.layers[0]._featureFilter.needGeometry,w=Gr(p,b);if(!this.layers[0]._featureFilter.filter(new Xt(this.zoom,{worldview:this.worldview,activeFloors:i.activeFloors}),w,r))continue;let S=l?l.evaluate(w,{},r,i.availableImages):void 0,E={id:f,properties:p.properties,type:p.type,sourceLayerIndex:x,index:g,geometry:b?w.geometry:jr(p,r,s),patterns:{},sortKey:S};u.push(E)}l&&u.sort((p,f)=>p.sortKey-f.sortKey);for(let p of u){let{geometry:f,index:g,sourceLayerIndex:x}=p;if(this.hasPattern){let b=Tg("fill",this.layers,p,this.zoom,this.pixelRatio,i);this.patternFeatures.push(b)}else this.addFeature(p,f,g,r,{},i.availableImages,i.brightness,i.elevationFeatures);i.featureIndex.insert(e[g].feature,f,g,x,this.index)}}update(e,i,r,s,l,u,p){this.bufferData.update(e,i,r,s,l,u,p,this.worldview),this.elevationBufferData.update(e,i,r,s,l,u,p,this.worldview),this.elevatedStructures&&this.elevatedStructures.update(e,i,r,s,l,u,p,this.worldview)}updateExpressions(e){this.bufferData.programConfigurations.updateExpressions(e),this.elevationBufferData.programConfigurations.updateExpressions(e),this.elevatedStructures&&(this.elevatedStructures.bridgeProgramConfigurations.updateExpressions(e),this.elevatedStructures.tunnelProgramConfigurations.updateExpressions(e))}addFeatures(e,i,r,s,l,u){for(let p of this.patternFeatures)this.addFeature(p,p.geometry,p.index,i,r,s,u,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()}
7addFeature(e,i,r,s,l,u=[],p,f){let g=_p(i,500);this.elevationMode!=="none"?this.addElevatedRoadFeature(e,g,s,r,f):this.addGeometry(g,this.bufferData),this.bufferData.populatePaintArrays(e,r,l,u,s,p,this.worldview),this.elevationBufferData.populatePaintArrays(e,r,l,u,s,p,this.worldview)}getUnevaluatedPortalGraph(){return this.elevatedStructures?this.elevatedStructures.unevaluatedPortals:void 0}setEvaluatedPortalGraph(e,i,r,s,l){this.elevatedStructures&&(this.elevatedStructures.construct(e),this.elevatedStructures.populatePaintArrays(i,r,s,l,this.worldview))}addElevatedRoadFeature(e,i,r,s,l){let u=new Array,p=_h.getElevationFeature(e,l);if(!p)return void this.addGeometry(i,this.bufferData);{let g=this.clipPolygonsToTile(i,1);g.length>0&&u.push({polygons:g,elevationFeature:p,elevationTileID:r})}let f={guardRailEnabled:this.layers[0].layout.get("fill-construct-bridge-guard-rail").evaluate(e,{},r),featureIndex:s};for(let g of u)if(g.elevationFeature){if(this.elevationMode==="hd-road-base"){this.elevatedStructures||(this.elevatedStructures=new Hr(g.elevationTileID,this.layers,this.zoom,this.lut));let b=g.elevationFeature.isTunnel(),w=0;Object.hasOwn(e.properties,Sm)&&(w=+e.properties[Sm]),this.elevatedStructures.addPortalCandidates(g.elevationFeature.id,g.polygons,b,g.elevationFeature,w)}g.elevationFeature.constantHeight==null&&(g.polygons=this.prepareElevatedPolygons(g.polygons,g.elevationFeature,g.elevationTileID));let x=new a(r,g.elevationTileID);this.addElevatedGeometry(g.polygons,x,g.elevationFeature,this.elevationMode==="hd-road-base"?0:.05,s,f)}}addElevatedGeometry(e,i,r,s,l,u){let p={elevation:r,elevationSampler:i,bias:s,index:l,featureInfo:u},[f,g]=this.addGeometry(e,this.elevationBufferData,p);this.elevationBufferData.heightRange==null?this.elevationBufferData.heightRange={min:f,max:g}:(this.elevationBufferData.heightRange.min=Math.min(this.elevationBufferData.heightRange.min,f),this.elevationBufferData.heightRange.max=Math.max(this.elevationBufferData.heightRange.max,g))}addGeometry(e,i,r){let s=Number.POSITIVE_INFINITY,l=Number.NEGATIVE_INFINITY,u=null;r&&(u=r.elevationSampler.constantElevation(r.elevation,r.bias),u!=null&&(s=u,l=u));let p=(f,g,x)=>{if(r!=null)if(g.push(f),u!=null)i.elevatedLayoutVertexArray.emplaceBack(u),x.push(u);else{let b=r.elevationSampler.pointElevation(f,r.elevation,r.bias);i.elevatedLayoutVertexArray.emplaceBack(b),x.push(b),s=Math.min(s,b),l=Math.max(l,b)}};for(let f of e){let g=0;for(let z of f)g+=z.length;let x=i.triangleSegments.prepareSegment(g,i.layoutVertexArray,i.indexArray),b=x.vertexLength,w=[],S=[],E=[],M=[],C=[],R=i.layoutVertexArray.length;for(let z of f){if(z.length===0)continue;z!==f[0]&&S.push(w.length/2);let j=i.lineSegments.prepareSegment(z.length,i.layoutVertexArray,i.lineIndexArray),$=j.vertexLength;r&&C.push(i.layoutVertexArray.length-R),p(z[0],E,M),i.layoutVertexArray.emplaceBack(z[0].x,z[0].y),i.lineIndexArray.emplaceBack($+z.length-1,$),w.push(z[0].x),w.push(z[0].y);for(let H=1;H<z.length;H++)p(z[H],E,M),i.layoutVertexArray.emplaceBack(z[H].x,z[H].y),i.lineIndexArray.emplaceBack($+H-1,$+H),w.push(z[H].x),w.push(z[H].y);j.vertexLength+=z.length,j.primitiveLength+=z.length}let F=wn(w,S);for(let z=0;z<F.length;z+=3)i.indexArray.emplaceBack(b+F[z],b+F[z+1],b+F[z+2]);if(F.length>0&&r&&this.elevationMode==="hd-road-base"){let z=r.elevation.isTunnel(),j=r.elevation.safeArea,$=this.elevatedStructures.addVertices(E,M);this.elevatedStructures.addTriangles(F,$,z);let H=C.length;if(H>0){for(let ie=0;ie<H-1;ie++)this.elevatedStructures.addRenderableRing(r.index,C[ie]+$,C[ie+1]-C[ie],z,j,r.featureInfo);this.elevatedStructures.addRenderableRing(r.index,C[H-1]+$,E.length-C[H-1],z,j,r.featureInfo)}}x.vertexLength+=g,x.primitiveLength+=F.length/3}return[s,l]}prepareElevatedPolygons(e,i,r){let s=1/Vr(r),l=[];for(let u of e){let p=j1(u,new Pm(i,s),.1);l.push(...p)}return l}clipPolygonsToTile(e,i){let r=-i,s=-i,l=Xe+i,u=Xe+i,p=0,f=[],g=[];for(;p<e.length;p++){let w=e[p],S=Kh(w);(S.min.x>=r&&S.max.x<=l&&S.min.y>=s&&S.max.y<=u?f:g).push(w)}if(f.length===e.length)return e;let x=[new ke(r,s),new ke(l,s),new ke(l,u),new ke(r,u),new ke(r,s)],b=f;for(let w of g)b.push(...V1(w,x));return b}}let a0,l0,c0,u0;Qe(Nm,"FillBucket",{omit:["layers","patternFeatures"]}),Qe(Rg,"FillBufferData"),Qe(Hr,"ElevatedStructures");
7class Um{constructor(e,i,r,s){if(this.triangleCount=i.length/3,this.min=new ke(0,0),this.max=new ke(0,0),this.xScale=0,this.yScale=0,this.cellsX=0,this.cellsY=0,this.cells=[],this.payload=[],this.triangleCount===0||e.length===0)return;let[l,u]=[e[0].clone(),e[0].clone()];for(let b=1;b<e.length;++b){let w=e[b];l.x=Math.min(l.x,w.x),l.y=Math.min(l.y,w.y),u.x=Math.max(u.x,w.x),u.y=Math.max(u.y,w.y)}if(s){let b=Math.ceil(Math.max(u.x-l.x,u.y-l.y)/s);r=Math.max(r,b)}if(r===0)return;this.min=l,this.max=u;let p=this.max.sub(this.min);p.x=Math.max(p.x,1),p.y=Math.max(p.y,1);let f=Math.max(p.x,p.y)/r;this.cellsX=Math.max(1,Math.ceil(p.x/f)),this.cellsY=Math.max(1,Math.ceil(p.y/f)),this.xScale=1/f,this.yScale=1/f;let g=[];for(let b=0;b<this.triangleCount;b++){let w=e[i[3*b+0]].sub(this.min),S=e[i[3*b+1]].sub(this.min),E=e[i[3*b+2]].sub(this.min),M=Ws(Math.floor(Math.min(w.x,S.x,E.x)),this.xScale,this.cellsX),C=Ws(Math.floor(Math.max(w.x,S.x,E.x)),this.xScale,this.cellsX),R=Ws(Math.floor(Math.min(w.y,S.y,E.y)),this.yScale,this.cellsY),F=Ws(Math.floor(Math.max(w.y,S.y,E.y)),this.yScale,this.cellsY),z=new ke(0,0),j=new ke(0,0),$=new ke(0,0),H=new ke(0,0);for(let ie=R;ie<=F;++ie){z.y=j.y=ie*f,$.y=H.y=(ie+1)*f;for(let W=M;W<=C;++W)z.x=$.x=W*f,j.x=H.x=(W+1)*f,(q(w,S,E,z,j,H)||q(w,S,E,z,H,$))&&g.push({cellIdx:ie*this.cellsX+W,triIdx:b})}}if(g.length===0)return;g.sort((b,w)=>b.cellIdx-w.cellIdx||b.triIdx-w.triIdx);let x=0;for(;x<g.length;){let b=g[x].cellIdx,w={start:this.payload.length,len:0};for(;x<g.length&&g[x].cellIdx===b;)++w.len,this.payload.push(g[x++].triIdx);this.cells[b]=w}}_lazyInitLookup(){this.lookup||(this.lookup=new Uint8Array(Math.ceil(this.triangleCount/8))),this.lookup.fill(0)}queryPoint(e,i){if(this.triangleCount===0||this.cells.length===0||e.x>this.max.x||this.min.x>e.x||e.y>this.max.y||this.min.y>e.y)return;let r=Ws(e.x-this.min.x,this.xScale,this.cellsX),s=Ws(e.y-this.min.y,this.yScale,this.cellsY),l=this.cells[s*this.cellsX+r];if(l){this._lazyInitLookup();for(let u=0;u<l.len;u++){let p=this.payload[l.start+u],f=Math.floor(p/8),g=1<<p%8;if(!(this.lookup[f]&g)&&(this.lookup[f]|=g,i.push(p),i.length===this.triangleCount))return}}}query(e,i,r){if(this.triangleCount===0||this.cells.length===0||e.x>this.max.x||this.min.x>i.x||e.y>this.max.y||this.min.y>i.y)return;this._lazyInitLookup();let s=Ws(e.x-this.min.x,this.xScale,this.cellsX),l=Ws(i.x-this.min.x,this.xScale,this.cellsX),u=Ws(e.y-this.min.y,this.yScale,this.cellsY),p=Ws(i.y-this.min.y,this.yScale,this.cellsY);for(let f=u;f<=p;f++)for(let g=s;g<=l;g++){let x=this.cells[f*this.cellsX+g];if(x)for(let b=0;b<x.len;b++){let w=this.payload[x.start+b],S=Math.floor(w/8),E=1<<w%8;if(!(this.lookup[S]&E)&&(this.lookup[S]|=E,r.push(w),r.length===this.triangleCount))return}}}}function Ws(n,e,i){return Math.max(0,Math.min(i-1,Math.floor(n*e)))}Qe(Um,"TriangleGridIndex");class h0{constructor(e){this.zoom=e.zoom,this.layers=e.layers,this.layerIds=this.layers.map(i=>i.fqid),this.index=e.index,this.hasPattern=!1,this.stateDependentLayerIds=this.layers.filter(i=>i.isStateDependent()).map(i=>i.id),this.footprints=[],this.worldview=e.worldview,this.hasAppearances=null}updateFootprints(e,i){for(let r of this.footprints)i.push({footprint:r,id:e})}updateAppearances(e,i,r,s){return{hasLayoutChanges:!1,hasUboChanges:!1}}populate(e,i,r,s){let l=[];for(let{feature:u,id:p,index:f,sourceLayerIndex:g}of e){let x=this.layers[0]._featureFilter.needGeometry,b=Gr(u,x);if(!this.layers[0]._featureFilter.filter(new Xt(this.zoom,{worldview:this.worldview,activeFloors:i.activeFloors}),b,r))continue;let w={id:p,properties:u.properties,type:u.type,sourceLayerIndex:g,index:f,geometry:x?b.geometry:jr(u,r,s),patterns:{}};l.push(w)}for(let u of l){let{geometry:p,index:f,sourceLayerIndex:g}=u;this.addFeature(u,p,f,r,{},i.availableImages,i.brightness),i.featureIndex.insert(e[f].feature,p,f,g,this.index)}}isEmpty(){return this.footprints.length===0}uploadPending(){return!1}upload(e){}update(e,i,r,s,l,u,p){}destroy(){}addFeature(e,i,r,s,l,u=[],p){for(let f of _p(i,2)){let g=[],x=[],b=[],w=new ke(1/0,1/0),S=new ke(-1/0,-1/0);for(let C of f)if(C.length!==0){C!==f[0]&&b.push(x.length/2);for(let R=0;R<C.length;
vendor: 7,176 bytes, line 7
7R++)x.push(C[R].x),x.push(C[R].y),g.push(C[R]),w.x=Math.min(w.x,C[R].x),w.y=Math.min(w.y,C[R].y),S.x=Math.max(S.x,C[R].x),S.y=Math.max(S.y,C[R].y)}let E=wn(x,b),M=new Um(g,E,8,256);this.footprints.push({vertices:g,indices:E,grid:M,min:w,max:S})}}}Qe(h0,"ClipBucket",{omit:["layers"]});let G1=Ct([{name:"a_pos_normal_ed",components:4,type:"Int16"}]),$1=Ct([{name:"a_pos_end",components:4,type:"Int16"},{name:"a_angular_offset_factor",components:1,type:"Int16"}]),H1=Ct([{name:"a_flood_light_ground_radius",components:1,type:"Float32"}]),q1=Ct([{name:"a_centroid_pos",components:2,type:"Uint16"}]),Z1=Ct([{name:"a_join_normal_inside",components:3,type:"Int16"}]),W1=Ct([{name:"a_hidden_by_landmark",components:1,type:"Uint8"}]),X1=Ct([{name:"a_pos_3",components:3,type:"Int16"},{name:"a_pos_normal_3",components:3,type:"Int16"}]),{members:Y1}=G1,xp=Number.MAX_SAFE_INTEGER,J1=xp-1;function d0(n,e,i,r){return n.order<e||n.order===xp||!(n.clipMask&i)||function(s,l){if(l.length===0)return!1;let u=s;for(;u!=="";){if(l.includes(u))return!1;u=im(u)}return!0}(r,n.clipScope)}function Vm(n,e){return n.x-e.x||n.y-e.y}function p0(n,e){return Vm(n.min,e.min)===0&&Vm(n.max,e.max)===0}function zg(n,e){return!(n.min.x>e.max.x||n.max.x<e.min.x||n.min.y>e.max.y||n.max.y<e.min.y)}function jm(n,e){if(n.length!==e.length)return!1;for(let i=0;i<n.length;i++)if(n[i].sourceId!==e[i].sourceId||!p0(n[i],e[i])||n[i].order!==e[i].order||n[i].clipMask!==e[i].clipMask||!Zo(n[i].clipScope,e[i].clipScope))return!1;return!0}function f0(n,e,i){let r=1/Xe,s=1/(1<<i.canonical.z),l=(e.x*r+i.canonical.x)*s+i.wrap,u=(e.y*r+i.canonical.y)*s;return{min:new ke((n.x*r+i.canonical.x)*s+i.wrap,(n.y*r+i.canonical.y)*s),max:new ke(l,u)}}function K1(n,e,i){let r=1<<i.canonical.z,s=((e.x-i.wrap)*r-i.canonical.x)*Xe,l=(e.y*r-i.canonical.y)*Xe;return{min:new ke(((n.x-i.wrap)*r-i.canonical.x)*Xe,(n.y*r-i.canonical.y)*Xe),max:new ke(s,l)}}function Lg(n,e,i,r,s,l,u){let p=n.indices,f=n.vertices,g=[];for(let x=r;x<r+s;x+=3){let b=e[i[x+0]+l],w=e[i[x+1]+l],S=e[i[x+2]+l],E=Math.min(b.x,w.x,S.x),M=Math.max(b.x,w.x,S.x),C=Math.min(b.y,w.y,S.y),R=Math.max(b.y,w.y,S.y);g.length=0,n.grid.query(new ke(E,C),new ke(M,R),g);for(let F=0;F<g.length;F++){let z=g[F];if(q(f[p[3*z+0]],f[p[3*z+1]],f[p[3*z+2]],b,w,S,u))return!0}}return!1}function m0(n,e,i,r){if(!n||!i)return!1;let s=n.vertices;if(!e.canonical.equals(r.canonical)||e.wrap!==r.wrap){if(i.vertices.length<n.vertices.length)return m0(i,r,n,e);let l=e.canonical,u=r.canonical,p=Math.pow(2,u.z-l.z);s=n.vertices.map(f=>new ke((f.x+l.x*Xe)*p-u.x*Xe,(f.y+l.y*Xe)*p-u.y*Xe))}return Lg(i,s,n.indices,0,n.indices.length,0,0)}function _0(n,e,i,r){let s=Math.pow(2,r.z-i.z);return new ke((n+i.x*Xe)*s-r.x*Xe,(e+i.y*Xe)*s-r.y*Xe)}function g0(n,e){let i=[];e.grid.queryPoint(n,i);let r=e.indices,s=e.vertices;for(let l=0;l<i.length;l++){let u=i[l];if(L([s[r[3*u+0]],s[r[3*u+1]],s[r[3*u+2]]],n))return!0}return!1}let Gm={None:0,Model:1,Symbol:2,FillExtrusion:4},Og=[new ke(0,0),new ke(Xe,0),new ke(Xe,Xe),new ke(0,Xe)];function y0(n,e){let i=[],r=[];if(!e||n.length<2)return[n];if(n.length===2)return k(n[0],n[1],Og)?[n]:[];for(let s=0;s<n.length+2;s++){let l=s===0?n.at(-1):n[(s-1)%n.length],u=n[s%n.length],p=n[(s+1)%n.length],f=k(l,u,Og),g=k(u,p,Og),x=f||g;x&&r.push(u),x&&g||r.length>0&&(r.length>1&&i.push(r),r=[])}return r.length>1&&i.push(r),i}let Fg=$s.types,Q1=["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"],eb=["fill-extrusion-flood-light-ground-radius"],tb=Math.pow(2,13),ib=Math.pow(2,15)-1,$m=new ke(0,1),Ga=2147483648,Hm=1073741824;function vp(n,e,i,r,s,l,u,p){n.emplaceBack((e<<1)+u,(i<<1)+l,(Math.floor(r*tb)<<1)+s,Math.round(p))}function bp(n,e,i){n.emplaceBack(e.x*Xe,e.y*Xe,i?1:0)}function qm(n,e,i,r,s,l){n.emplaceBack(e.x,e.y,(i.x<<1)+r,(i.y<<1)+s,l)}function wp(n,e,i){n.emplaceBack(e.x,e.y,e.z,i[0]*16384,i[1]*16384,i[2]*16384)}class x0{constructor(){this.vertexOffset=0,this.vertexCount=0,this.indexOffset=0,this.indexCount=0}}class Zm{constructor(){this.data=[]}get length(){return this.data.length}push(e){this.data.push(e)}get(e){return this.data[e]}static serialize(e,i){let r=e.data.length,s=new Uint32Array(4*r),l=[];l.length=r;for(let u=0;u<r;u++){let p=e.data[u],f=4*u;s[f]=p.vertexOffset,s[f+1]=p.vertexCount,s[f+2]=p.indexOffset,s[f+3]=p.indexCount,l[u]=p.ringIndices}return i&&i.add(s.buffer),{scalars:s,rings:l}}static deserialize(e){let{scalars:i,rings:r}=e,s=i.length/4,l=new Zm,u=[];u.length=s,l.data=u;for(let p=0;p<s;p++){let f=4*p,g=new x0;g.vertexOffset=i[f],g.vertexCount=i[f+1],g.indexOffset=i[f+2],g.indexCount=i[f+3],g.ringIndices=r[p],l.data[p]=g}return l}}class Wm{constructor(){this.centroidXY=new ke(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 ke(Number.MAX_VALUE,Number.MAX_VALUE),this.max=new ke(-Number.MAX_VALUE,-Number.MAX_VALUE),this.height=0,this.buildingId=0,this.groupCentroidPos=new ke(0,0)}span(){return new ke(this.max.x-this.min.x,this.max.y-this.min.y)}}class Xm{constructor(){this.data=[],this.buffer=null}get length(){return this.data.length}push(e){this.data.push(e)}get(e){return this.data[e]}find(e){return this.data.find(e)}[Symbol.iterator](){return this.data[Symbol.iterator]()}static serialize(e,i){let r=e.data.length,s=new Float64Array(15*r);for(let l=0;l<r;l++){let u=e.data[l],p=15*l;s[p]=u.centroidXY.x,s[p+1]=u.centroidXY.y,s[p+2]=u.min.x,s[p+3]=u.min.y,s[p+4]=u.max.x,s[p+5]=u.max.y,s[p+6]=u.groupCentroidPos.x,s[p+7]=u.groupCentroidPos.y,s[p+8]=u.vertexArrayOffset,s[p+9]=u.vertexCount,s[p+10]=u.groundVertexArrayOffset,s[p+11]=u.groundVertexCount,s[p+12]=u.footprintSegLen,s[p+13]=u.height,s[p+14]=u.buildingId}return i&&i.add(s.buffer),{buffer:s}}static deserialize(e){let i=e.buffer,r=i.length/15,s=new Xm;s.buffer=i;let l=[];l.length=r,s.data=l;let u=0;for(let p=0;p<r;p++){let f=15*p,g=new Wm;g.centroidXY=new ke(i[f],i[f+1]),g.min=new ke(i[f+2],i[f+3]),g.max=new ke(i[f+4],i[f+5]),g.groupCentroidPos=new ke(i[f+6],i[f+7]),g.vertexArrayOffset=i[f+8],g.vertexCount=i[f+9],g.groundVertexArrayOffset=i[f+10],g.groundVertexCount=i[f+11],g.footprintSegLen=i[f+12],g.height=i[f+13],g.buildingId=i[f+14],g.footprintSegIdx=u,u+=g.footprintSegLen,s.data[p]=g}return s}}class Bg{constructor(){this.acc=new ke(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 s=!!this.borders;i.x<e.min.x?(e.min.x=i.x,s=!0):i.x>e.max.x&&(e.max.x=i.x,s=!0),i.y<e.min.y?(e.min.y=i.y,s=!0):i.y>e.max.y&&(e.max.y=i.y,s=!0),((i.x===0||i.x===Xe)&&i.x===r.x)!=((i.y===0||i.y===Xe)&&i.y===r.y)&&this.processBorderOverlap(i,r),s&&this.checkBorderIntersection(i,r)}checkBorderIntersection(e,i){i.x<0!=e.x<0&&this.addBorderIntersection(0,ft(i.y,e.y,(0-i.x)/(e.x-i.x))),i.x>Xe!=e.x>Xe&&this.addBorderIntersection(1,ft(i.y,e.y,(Xe-i.x)/(e.x-i.x))),i.y<0!=e.
7y<0&&this.addBorderIntersection(2,ft(i.x,e.x,(0-i.y)/(e.y-i.y))),i.y>Xe!=e.y>Xe&&this.addBorderIntersection(3,ft(i.x,e.x,(Xe-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=e.x===0?0:1;this.addBorderIntersection(r,i.y),this.addBorderIntersection(r,e.y)}else{let r=e.y===0?2:3;this.addBorderIntersection(r,i.x),this.addBorderIntersection(r,e.x)}}centroid(){return this.accCount===0?new ke(0,0):new ke(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 v0(n,e){let i=n.add(e)._unit(),r=ne(n.x*i.x+n.y*i.y,-1,1);var s,l,u;return u=Math.acos(r),Math.min(4,Math.max(-4,Math.tan(u)))/4*ib*((s=n).x*(l=e).y-s.y*l.x<0?-1:1)}let nb=[n=>n.x<0,n=>n.x>Xe,n=>n.y<0,n=>n.y>Xe];function rb(n,e,i,r){let s=[4];if(r===0)return s;i._mult(r);let l=n.sub(i),u=e.sub(i),p=[n,e,l,u];for(let f=0;f<4;f++)for(let g of p)if(nb[f](g)){s.push(f);break}return s}class kg{constructor(e){this.groundRadiusArray=null,this.groundRadiusBuffer=null,this.vertexArray=new Ud,this.indexArray=new Xi,this.programConfigurations=new bo(e.layers,{zoom:e.zoom,lut:e.lut},i=>eb.includes(i)),this._segments=new pi,this.hiddenByLandmarkVertexArray=new zl,this._segmentToGroundQuads={},this._segmentToGroundQuads[0]=[],this._segmentToRegionTriCounts={},this._segmentToRegionTriCounts[0]=[0,0,0,0,0],this.regionSegments={},this.regionSegments[4]=new pi}getDefaultSegment(){return this.regionSegments[4]}hasData(){return this.vertexArray.length!==0}addData(e,i,r,s=!1){let l=e.length;if(l>2){let u=Math.max(0,this._segments.get().length-1),p=this._segments._prepareSegment(4*l,this.vertexArray.length,2*this._segmentToGroundQuads[u].length),f;u!==this._segments.get().length-1&&(u++,this._segmentToGroundQuads[u]=[],this._segmentToRegionTriCounts[u]=[0,0,0,0,0]);{let g=e[0],x=e[1];f=v0(g.sub(e[l-1])._perp()._unit(),x.sub(g)._perp()._unit())}for(let g=0;g<l;g++){let x=g===l-1?0:g+1,b=e[g],w=e[x],S=e[x===l-1?0:x+1],E=w.sub(b)._perp()._unit(),M=v0(E,S.sub(w)._perp()._unit()),C=f,R=M;if(Ng(b,w,i)||s&&T0(b,i)&&T0(w,i)){f=M;continue}let F=p.vertexLength;qm(this.vertexArray,b,w,1,1,C),qm(this.vertexArray,b,w,1,0,C),qm(this.vertexArray,b,w,0,1,R),qm(this.vertexArray,b,w,0,0,R),p.vertexLength+=4;let z=rb(b,w,E,r);for(let j of z)this._segmentToGroundQuads[u].push({id:F,region:j}),this._segmentToRegionTriCounts[u][j]+=2,p.primitiveLength+=2;f=M}}}prepareBorderSegments(){if(!this.hasData())return;let e=this._segments.get(),i=e.length;for(let r=0;r<i;r++)this._segmentToGroundQuads[r].sort((s,l)=>s.region-l.region);for(let r=0;r<i;r++){let s=this._segmentToGroundQuads[r],l=e[r],u=this._segmentToRegionTriCounts[r];u.reduce((f,g)=>f+g,0);let p=0;for(let f=0;f<=4;f++){let g=u[f];if(g!==0){let x=this.regionSegments[f];x||(x=this.regionSegments[f]=new pi);let b={vertexOffset:l.vertexOffset,primitiveOffset:l.primitiveOffset+p,vertexLength:l.vertexLength,primitiveLength:g};x.get().push(b)}p+=g}for(let f=0;f<s.length;f++){let g=s[f].id;this.indexArray.emplaceBack(g,g+1,g+3),this.indexArray.emplaceBack(g,g+3,g+2)}}this._segmentToGroundQuads=null,this._segmentToRegionTriCounts=null,this._segments.destroy(),this._segments=null}addPaintPropertiesData(e,i,r,s,l,u,p){this.hasData()&&this.programConfigurations.populatePaintArrays(this.vertexArray.length,e,i,r,s,l,u,void 0,p)}upload(e){this.hasData()&&(this.vertexBuffer=e.createVertexBuffer(this.vertexArray,$1.members),this.indexBuffer=e.createIndexBuffer(this.indexArray),this.groundRadiusArray!=null&&(this.groundRadiusBuffer=e.createVertexBuffer(this.groundRadiusArray,H1.members)))}uploadPaintProperties(e){this.hasData()&&this.programConfigurations.upload(e)}update(e,i,r,s,l,u,p,f){this.hasData()&&this.programConfigurations.updatePaintArrays(e,i,r,s,l,u,p,f)}updateHiddenByLandmark(e){this.updateHiddenByLandmarkRange(e.groundVertexArrayOffset,e.groundVertexCount,!!(e.flags&Ga||e.flags&Hm))}updateHiddenByLandmarkRange(e,i,r){if(!this.hasData())return;let s=i+e;if(i!==0){for(let l=e;l<s;++l)this.hiddenByLandmarkVertexArray.emplace(l,r?1:0);this._needsHiddenByLandmarkUpdate=!0}}uploadHiddenByLandmark(e){this.hasData()&&this._needsHiddenByLandmarkUpdate&&(!this.hiddenByLandmarkVertexBuffer&&this.hiddenByLandmarkVertexArray.length>0?this.hiddenByLandmarkVertexBuffer=e.createVertexBuffer(this.hiddenByLandmarkVertexArray,W1.members,!0):this.hiddenByLandmarkVertexBuffer&&this.hiddenByLandmarkVertexBuffer.updateData(this.hiddenByLandmarkVertexArray),this._needsHiddenByLandmarkUpdate=!1)}destroy(){if(this.vertexBuffer){this.vertexBuffer.destroy(),this.indexBuffer.destroy(),this.hiddenByLandmarkVertexBuffer&&this.hiddenByLandmarkVertexBuffer.destroy(),this.groundRadiusBuffer&&this.groundRadiusBuffer.destroy(),this._segments&&this._segments.destroy(),this.programConfigurations.destroy();for(let e=0;e<=4;e++){let i=this.regionSegments[e];i&&i.destroy()}}}}class Ym{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(i=>i.fqid),this.index=e.index,this.hasPattern=!1,this.edgeRadius=0,this.projection=e.projection,this.activeReplacements=[],this.replacementUpdateTime=0,this.centroidData=new Xm,this.footprintIndices=new Xi,this.footprintVertices=new Hn,this.footprintSegments=new Zm,this.layoutVertexArray=new Hc,this.centroidVertexArray=new Kd,this.wallVertexArray=new fm,this.indexArray=new Xi,this.programConfigurations=new bo(e.layers,{zoom:e.zoom,lut:e.lut},i=>Q1.includes(i)),this.segments=new pi,this.stateDependentLayerIds=this.layers.filter(i=>i.isStateDependent()).map(i=>i.id),this.groundEffect=new kg(e),this.maxHeight=0,this.partLookup={},this.triangleSubSegments=[],this.polygonSegments=[],this.buildingGroups=new Map,this.worldview=e.worldview,this.hasAppearances=null}updateFootprints(e,i){}updateAppearances(e,i,r,s){return{hasLayoutChanges:!1,hasUboChanges:!1}}
7populate(e,i,r,s){this.features=[],this.hasPattern=wg("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=Vr(r),this.edgeRadius=this.layers[0].layout.get("fill-extrusion-edge-radius")/this.tileToMeter,this.wallMode=this.layers[0].paint.get("fill-extrusion-line-width").constantOr(1)!==0;for(let{feature:l,id:u,index:p,sourceLayerIndex:f}of e){let g=this.layers[0]._featureFilter.needGeometry,x=Gr(l,g);if(!this.layers[0]._featureFilter.filter(new Xt(this.zoom,{worldview:this.worldview,activeFloors:i.activeFloors}),x,r))continue;let b={id:u,sourceLayerIndex:f,index:p,geometry:g?x.geometry:jr(l,r,s),properties:l.properties,type:l.type,patterns:{}},w=this.layoutVertexArray.length,S=Fg[b.type]==="Polygon";if(this.hasPattern)this.features.push({featureId:l.id,feature:Tg("fill-extrusion",this.layers,b,this.zoom,this.pixelRatio,i)});else if(this.wallMode)for(let E of b.geometry)for(let M of y0(E,S))this.addFeature(l.id,b,[M],p,r,{},i.availableImages,s,i.brightness);else this.addFeature(l.id,b,b.geometry,p,r,{},i.availableImages,s,i.brightness);i.featureIndex.insert(l,b.geometry,p,f,this.index,w)}this._finalizeBuildingGroups(),this.sortBorders(),this.projection.name==="mercator"&&this.splitToSubtiles(),this.groundEffect.prepareBorderSegments(),this.polygonSegments.length=0}addFeatures(e,i,r,s,l,u){for(let{featureId:p,feature:f}of this.features){let g=Fg[f.type]==="Polygon",{geometry:x}=f;if(this.wallMode)for(let b of x)for(let w of y0(b,g))this.addFeature(p,f,[w],f.index,i,r,s,l,u);else this.addFeature(p,f,x,f.index,i,r,s,l,u)}this._finalizeBuildingGroups(),this.sortBorders(),this.projection.name==="mercator"&&this.splitToSubtiles()}update(e,i,r,s,l,u,p){this.programConfigurations.updatePaintArrays(e,i,l,r,s,u,p,this.worldview),this.groundEffect.update(e,i,l,r,s,u,p,this.worldview)}updateExpressions(e){this.programConfigurations.updateExpressions(e),this.groundEffect.programConfigurations.updateExpressions(e)}isEmpty(){return this.layoutVertexArray.length===0}uploadPending(){return!this.uploaded||this.programConfigurations.needsUpload||this.groundEffect.programConfigurations.needsUpload}upload(e){this.uploaded||(this.layoutVertexBuffer=e.createVertexBuffer(this.layoutVertexArray,Y1),this.indexBuffer=e.createIndexBuffer(this.indexArray),this.wallVertexBuffer=e.createVertexBuffer(this.wallVertexArray,Z1.members),this.layoutVertexExtArray&&(this.layoutVertexExtBuffer=e.createVertexBuffer(this.layoutVertexExtArray,X1.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,q1.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,s,l,u,p,f,g){let x=this.layers[0].paint.get("fill-extrusion-flood-light-ground-radius").evaluate(i,{})/this.tileToMeter,b=[new ke(0,0),new ke(Xe,Xe)],w=f.projection,S=w.name==="globe",E=this.wallMode||Fg[i.type]==="Polygon",M=new Bg;M.centroidDataIndex=this.centroidData.length;let C=new Wm;C.buildingId=e,i.properties&&Object.hasOwn(i.properties,"building_id")&&(C.buildingId=Number(i.properties.building_id)),M.buildingId=C.buildingId;let R=this.layers[0].paint.get("fill-extrusion-base").evaluate(i,{},l)<=0,F=this.layers[0].paint.get("fill-extrusion-height").evaluate(i,{},l),z;if(C.height=F,C.vertexArrayOffset=this.layoutVertexArray.length,C.groundVertexArrayOffset=this.groundEffect.vertexArray.length,S&&!this.layoutVertexExtArray&&(this.layoutVertexExtArray=new rh),this.wallMode){if(S)return void Ot("Non zero fill-extrusion-line-width is not yet supported on globe.");if(r.length!==1)return;z=function(Y){let ee=Y[0].x===Y.at(-1).x&&Y[0].y===Y.at(-1).y;(function(Ge){let He=0,Je=Ge.length;for(let tt=0;tt<Je;tt++)He+=(Ge[(tt+1)%Je].x-Ge[tt].x)*(Ge[(tt+1)%Je].y+Ge[tt].y);return He>=0})(Y)||(Y=Y.reverse());let ge={geometry:[],joinNormals:[],indices:[]},Te=[],Ae=[],Ee=[],Be=Y.length;for(;Be>=2&&Y[Be-1].equals(Y[Be-2]);)Be--;if(Be<(ee?3:2))return ge;let xe,Se,Me,ze,Le,We=0;for(;We<Be-1&&Y[We].equals(Y[We+1]);)We++;ee&&(xe=Y[Be-2],Le=Y[We].sub(xe)._unit()._perp());for(let Ge=We;Ge<Be;Ge++){if(Me=Ge===Be-1?ee?Y[We+1]:void 0:Y[Ge+1],Me&&Y[Ge].equals(Me))continue;Le&&(ze=Le),xe&&(Se=xe),xe=Y[Ge],Le=Me?Me.sub(xe)._unit()._perp():ze,ze=ze||Le;let He=ze.add(Le);He.x===0&&He.y===0||He._unit();let Je=He.x*Le.x+He.y*Le.y,tt=Je!==0?1/Je:1/0,lt=ze.x*Le.y-ze.y*Le.x>0,rt="miter",pt=2;rt==="miter"&&tt>pt&&(rt="bevel"),rt==="bevel"&&(tt>100&&(rt="flipbevel"),tt<pt&&(rt="miter"));let Ht=(wt,kt,At,Ui)=>{let Jt=new ke(wt.x,wt.y),Gt=new ke(wt.x,wt.y);Jt.x+=kt.x*Ui,Jt.y+=kt.y*Ui,Gt.x-=kt.x*Math.max(At,1),Gt.y-=kt.y*Math.max(At,1),Ee.push(kt),Te.push(Jt),Ae.push(Gt)};if(rt==="miter")He._mult(tt),Ht(xe,He,0,0);else if(rt==="flipbevel")He=Le.mult(-1),Ht(xe,He,0,0),Ht(xe,He.mult(-1),0,0);else{let wt=-Math.sqrt(tt*tt-1),kt=lt?wt:0,At=lt?0:wt;Se&&Ht(xe,ze,kt,At),Me&&Ht(xe,Le,kt,At)}}ge.geometry=[...Te,...Ae.reverse(),Te[0]],ge.joinNormals=[...Ee,...Ee.reverse(),Ee.at(-1)];let De=ge.geometry.length-1;for(let Ge=0;Ge<De/2;Ge++)if(Ge+1<De/2){let He=Ge,Je=Ge+1,tt=De-1-Ge,lt=De-2-Ge;He=He===0?De-1:He-1,Je=Je===0?De-1:Je-1,tt=tt===0?De-1:tt-1,lt=lt===0?De-1:lt-1,ge.indices.push(tt),ge.indices.push(Je),ge.indices.push(He),ge.indices.push(tt),ge.indices.push(lt),ge.indices.push(Je)}return ge}(r[0]),r=[z.geometry]}let j=(Y,ee)=>Y<(ee.length-1)/2||Y===ee.length-1,$=this.wallMode?[r]:_p(r,500);for(let Y=$.length-1;Y>=0;Y--){let ee=$[Y];(ee.length===0||sb(ee[0]))&&$.splice(Y,1)}let H;if(S)H=A0($,b,l);else{H=[];for(let Y of $)H.push({polygon:Y,bounds:b})}let ie=E?this.edgeRadius:0,W=ie>0&&this.zoom<17,Q=(Y,ee)=>{if(Y.length===0)return!1;let me=Y.at(-1);return ee.x===me.x&&ee.y===me.y};for(let{polygon:Y,bounds:ee}of H){let me=0,ge=0;for(let Be of Y)E&&!Be[0].equals(Be.at(-1))&&Be.push(Be[0]),ge+=E?Be.length-1:Be.length;let Te=this.segments.prepareSegment((E?5:4)*ge,this.layoutVertexArray,this.indexArray);C.footprintSegIdx<0&&(C.footprintSegIdx=this.footprintSegments.length),C.pol
7ygonSegIdx<0&&(C.polygonSegIdx=this.polygonSegments.length);let Ae={triangleArrayOffset:this.indexArray.length,triangleCount:0,triangleSegIdx:this.segments.segments.length-1},Ee=new x0;if(Ee.vertexOffset=this.footprintVertices.length,Ee.indexOffset=3*this.footprintIndices.length,Ee.ringIndices=[],E){let Be=[],xe=[];me=Te.vertexLength;for(let Me=0;Me<Y.length;Me++){let ze=Y[Me];ze.length&&Me!==0&&xe.push(Be.length/2);let Le=[],We,De;We=ze[1].sub(ze[0])._perp()._unit(),Ee.ringIndices.push(ze.length-1);for(let Ge=1;Ge<ze.length;Ge++){let He=ze[Ge],Je=ze[Ge===ze.length-1?1:Ge+1],tt=He.clone();if(ie){De=Je.sub(He)._perp()._unit();let lt=We.add(De)._unit(),rt=ie*Math.min(4,1/(We.x*lt.x+We.y*lt.y));tt.x+=rt*lt.x,tt.y+=rt*lt.y,tt.x=Math.round(tt.x),tt.y=Math.round(tt.y),We=De}if(!R||ie!==0&&!W||Q(Le,tt)||Le.push(tt),vp(this.layoutVertexArray,tt.x,tt.y,0,0,1,1,0),this.wallMode){let lt=j(Ge,ze);bp(this.wallVertexArray,z.joinNormals[Ge],!lt)}Te.vertexLength++,this.footprintVertices.emplaceBack(He.x,He.y),Be.push(He.x,He.y),S&&wp(this.layoutVertexExtArray,w.projectTilePoint(tt.x,tt.y,l),w.upVector(l,tt.x,tt.y))}R&&(ie===0||W)&&(Le.length!==0&&Q(Le,Le[0])&&Le.pop(),this.groundEffect.addData(Le,ee,x))}let Se=this.wallMode?z.indices:wn(Be,xe);for(let Me=0;Me<Se.length;Me+=3)this.footprintIndices.emplaceBack(Ee.vertexOffset+Se[Me+0],Ee.vertexOffset+Se[Me+1],Ee.vertexOffset+Se[Me+2]),this.indexArray.emplaceBack(me+Se[Me],me+Se[Me+2],me+Se[Me+1]),Te.primitiveLength++;Ee.indexCount+=Se.length,Ee.vertexCount+=this.footprintVertices.length-Ee.vertexOffset}for(let Be=0;Be<Y.length;Be++){let xe=Y[Be];M.startRing(C,xe[0]);let Se=xe.length>4&&S0(xe[xe.length-2],xe[0],xe[1]),Me=ie?ob(xe[xe.length-2],xe[0],xe[1],ie):0,ze=[],Le,We,De;We=xe[1].sub(xe[0])._perp()._unit();let Ge=!0;for(let He=1,Je=0;He<xe.length;He++){let tt=xe[He-1],lt=xe[He],rt=xe[He===xe.length-1?1:He+1];if(M.appendEdge(C,lt,tt),Ng(lt,tt,ee)){ie&&(We=rt.sub(lt)._perp()._unit(),Ge=!Ge);continue}let pt=lt.sub(tt)._perp(),Ht=pt.x/(Math.abs(pt.x)+Math.abs(pt.y)),wt=pt.y>0?1:0,kt=tt.dist(lt);if(Je+kt>32768&&(Je=0),ie){De=rt.sub(lt)._perp()._unit();let Gt=w0(tt,lt,rt,b0(We,De),ie);isNaN(Gt)&&(Gt=0);let ui=lt.sub(tt)._unit();tt=tt.add(ui.mult(Me))._round(),lt=lt.add(ui.mult(-Gt))._round(),Me=Gt,We=De,R&&this.zoom>=17&&(Q(ze,tt)||ze.push(tt),Q(ze,lt)||ze.push(lt))}let At=Te.vertexLength,Ui=xe.length>4&&S0(tt,lt,rt),Jt=I0(Je,Se,Ge);if(vp(this.layoutVertexArray,tt.x,tt.y,Ht,wt,0,0,Jt),vp(this.layoutVertexArray,tt.x,tt.y,Ht,wt,0,1,Jt),this.wallMode){let Gt=j(He-1,xe),ui=z.joinNormals[He-1];bp(this.wallVertexArray,ui,Gt),bp(this.wallVertexArray,ui,Gt)}if(Je+=kt,Jt=I0(Je,Ui,!Ge),Se=Ui,vp(this.layoutVertexArray,lt.x,lt.y,Ht,wt,0,0,Jt),vp(this.layoutVertexArray,lt.x,lt.y,Ht,wt,0,1,Jt),this.wallMode){let Gt=j(He,xe),ui=z.joinNormals[He];bp(this.wallVertexArray,ui,Gt),bp(this.wallVertexArray,ui,Gt)}if(Te.vertexLength+=4,this.indexArray.emplaceBack(At+0,At+1,At+2),this.indexArray.emplaceBack(At+1,At+3,At+2),Te.primitiveLength+=2,ie){let Gt=me+(He===1?xe.length-2:He-2),ui=He===1?me:Gt+1;if(this.indexArray.emplaceBack(At+1,Gt,At+3),this.indexArray.emplaceBack(Gt,ui,At+3),Te.primitiveLength+=2,Le===void 0&&(Le=At),!Ng(rt,xe[He],ee)){let Mi=He===xe.length-1?Le:Te.vertexLength;this.indexArray.emplaceBack(At+2,At+3,Mi),this.indexArray.emplaceBack(At+3,Mi+1,Mi),this.indexArray.emplaceBack(At+3,ui,Mi+1),Te.primitiveLength+=3}Ge=!Ge}if(S){let Gt=this.layoutVertexExtArray,ui=w.projectTilePoint(tt.x,tt.y,l),Mi=w.projectTilePoint(lt.x,lt.y,l),Sn=w.upVector(l,tt.x,tt.y),mi=w.upVector(l,lt.x,lt.y);wp(Gt,ui,Sn),wp(Gt,ui,Sn),wp(Gt,Mi,mi),wp(Gt,Mi,mi)}}E&&(me+=xe.length-1),R&&ie&&this.zoom>=17&&(ze.length!==0&&Q(ze,ze[0])&&ze.pop(),this.groundEffect.addData(ze,ee,x,ie>0))}this.footprintSegments.push(Ee),Ae.triangleCount=this.indexArray.length-Ae.triangleArrayOffset,this.polygonSegments.push(Ae),++C.footprintSegLen,++C.polygonSegLen}if(C.vertexCount=this.layoutVertexArray.length-C.vertexArrayOffset,C.groundVertexCount=this.groundEffect.vertexArray.length-C.groundVertexArrayOffset,C.vertexCount!==0){if(C.centroidXY=M.borders?$m:this.encodeCentroid(M,C),i.properties&&Object.hasOwn(i.properties,"building_id")){let Y=C.buildingId,ee=this.buildingGroups.get(Y);ee||(ee={accX:0,accY:0,accCount:0,mergedMin:new ke(Number.MAX_VALUE,Number.MAX_VALUE),mergedMax:new ke(-Number.MAX_VALUE,-Number.MAX_VALUE),partIndices:[]},this.buildingGroups.set(Y,ee)),ee.accX+=M.acc.x,ee.accY+=M.acc.y,ee.accCount+=M.accCount,ee.mergedMin.x=Math.min(ee.mergedMin.x,C.min.x),ee.mergedMin.y=Math.min(ee.mergedMin.y,C.min.y),ee.mergedMax.x=Math.max(ee.mergedMax.x,C.max.x),ee.mergedMax.y=Math.max(ee.mergedMax.y,C.max.y),ee.partIndices.push(this.centroidData.length)}if(this.centroidData.push(C),M.borders){this.featuresOnBorder.push(M);let Y=this.featuresOnBorder.length-1;for(let ee=0;ee<M.borders.length;ee++)M.borders[ee][0]!==Number.MAX_VALUE&&this.borderFeatureIndices[ee].push(Y)}this.programConfigurations.populatePaintArrays(this.layoutVertexArray.length,i,s,u,p,l,g,void 0,this.worldview),this.groundEffect.addPaintPropertiesData(i,s,u,p,l,g,this.worldview),this.maxHeight=Math.max(this.maxHeight,F)}}_finalizeBuildingGroups(){for(let[,e]of this.buildingGroups){if(e.partIndices.length===0)continue;let i=new Bg;i.acc=new ke(e.accX,e.accY),i.accCount=e.accCount;let r=new Wm;r.min=e.mergedMin,r.max=e.mergedMax;let s=this.encodeCentroid(i,r),l=i.centroid();for(let u of e.partIndices){let p=this.centroidData.get(u);p.centroidXY.x===$m.x&&p.centroidXY.y===$m.y||(p.centroidXY=s),p.min=e.mergedMin,p.max=e.mergedMax,p.groupCentroidPos=l}}this.buildingGroups.clear()}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 p=0;p<this.centroidData.length;p++){let f=this.centroidData.get(p),g=+(f.min.y+f.max.y>Xe),x=2*g+(+(f.min.x+f.max.x>Xe)^g);for(let b=0;b<f.polygonSegLen;b++){let w=f.polygonSegIdx+b;e.push({centroidIdx:p,subtile:x,polygonSegmentIdx:w,triangleSegmentIdx:this.polygonSegments[w].triangleSegIdx})}}let i=new Xi;e.sort((p,f)=>p.triangleSegmentIdx===f.triangleSegmentIdx?p.subtile-f.subtile:p.triangleSegmentIdx-f.triangleSegmentIdx);let r=0,s=0,l=0;for(let p of e){if(p.triangleSegmentIdx!==r)break;l++}let u=e.length;for(;s!==e.length;){r=e[s].triangleSegmentIdx;let p=0,f=s,g=s;for(let x=f;x<l&&e[x].subtile===p;x++)g++;for(;f!==l;){let x=e[f];p=x.subtile;let b=this.centroidData.get(x.centroidIdx).min.clone(),w=this.centroidData.get(x.centroidIdx).max.clone(),S={vertexOffset:this.segments.segments[r].vertexOffset,primitiveOffset:i.length,vertexLength:this.segments.segments[r].vertexLength,primitiveLength:0,sortKey:void 0,vaos:{}};for(let E=f;E<g;E++){let M=e[E],C=this.polygonSegments[M.polygonSegmentIdx],R=this.centroidData.get(M.centroidIdx).min,F=this.centroidData.get(M.centroidIdx).max,z=this.indexArray.uint16;for(let j=C.triangleArrayOffset;j<C.triangleArrayOffset+C.triangleCount;j++)i.emplaceBack(z[3*j],z[3*j+1],z[3*j+2]);S.primitiveLength+=C.triangleCount,b.x=Math.min(b.x,R.x),b.y=Math.min(b.y,R.y),w.x=Math.max(w.x,F.x),w.y=Math.max(w.y,F.y)}S.primitiveLength>0&&this.triangleSubSegments.push({segment:S,min:b,max:w}),f=g;for(let E=f;E<l&&e[E].subtile===e[f].subtile;E++)g++}s=l;for(let x=s;x<u&&e[x].triangleSegmentIdx===e[s].triangleSegmentIdx;x++)l++}i._trim(),this.indexArray=i}getVisibleSegments(e,i,r){let s=new pi;if(this.wallMode){for(let M of this.triangleSubSegments)s.segments.push(M.segment);return s}let l=0,u=0,p=1<<e.canonical.z;if(i){let M=i.getMinMaxForTile(e);M&&(l=M.min,u=M.max)}u+=this.maxHeight;let f=e.toUnwrapped(),g,x=[f.canonical.x/p+f.wrap,f.canonical.y/p],b=[(f.canonical.x+1)/p+f.
7wrap,(f.canonical.y+1)/p],w=(M,C,R)=>[M[0]*(1-R[0])+C[0]*R[0],M[1]*(1-R[1])+C[1]*R[1]],S=[],E=[];for(let M of this.triangleSubSegments){S[0]=M.min.x/Xe,S[1]=M.min.y/Xe,E[0]=M.max.x/Xe,E[1]=M.max.y/Xe;let C=w(x,b,S),R=w(x,b,E);if(new Si([C[0],C[1],l],[R[0],R[1],u]).intersectsPrecise(r)===0){g&&(s.segments.push(g),g=void 0);continue}let F=M.segment;g&&g.vertexOffset!==F.vertexOffset&&(s.segments.push(g),g=void 0),g?(g.vertexLength+=F.vertexLength,g.primitiveLength+=F.primitiveLength):g={vertexOffset:F.vertexOffset,primitiveLength:F.primitiveLength,vertexLength:F.vertexLength,primitiveOffset:F.primitiveOffset,sortKey:void 0,vaos:{}}}return g&&s.segments.push(g),s}encodeCentroid(e,i){let r=e.centroid(),s=i.span(),l=Math.min(7,Math.round(s.x*this.tileToMeter/10)),u=Math.min(6,Math.round(s.y*this.tileToMeter/10));return new ke(ne(r.x,1,8191)<<3|l,ne(r.y,1,8191)<<3|u)}encodeBorderCentroid(e){if(!e.borders)return new ke(0,0);let i=e.borders,r=Number.MAX_VALUE;if(i[0][0]!==r||i[1][0]!==r){let s=i[0][0]!==r?0:1;return new ke(6|(i[0][0]!==r?0:65528),(i[s][0]+i[s][1])/2<<3|6)}{let s=i[2][0]!==r?2:3;return new ke((i[s][0]+i[s][1])/2<<3|6,6|(i[2][0]!==r?0:65528))}}showCentroid(e){let i=this.centroidData.get(e.centroidDataIndex);if(i.flags&=Ga,i.groupCentroidPos.x!==0||i.groupCentroidPos.y!==0){let r=i.span(),s=Math.min(7,Math.round(r.x*this.tileToMeter/10)),l=Math.min(6,Math.round(r.y*this.tileToMeter/10));i.centroidXY=new ke(ne(i.groupCentroidPos.x,1,8191)<<3|s,ne(i.groupCentroidPos.y,1,8191)<<3|l)}else i.centroidXY=new ke(0,0);this.writeCentroidToBuffer(i)}writeCentroidToBuffer(e){this.groundEffect.updateHiddenByLandmark(e);let i=e.vertexArrayOffset,r=e.vertexCount+e.vertexArrayOffset,s=-1073741824&e.flags?$m:e.centroidXY,l=this.centroidVertexArray.geta_centroid_pos0(i);if(this.centroidVertexArray.geta_centroid_pos1(i)!==s.y||l!==s.x){for(let u=i;u<r;++u)this.centroidVertexArray.emplace(u,s.x,s.y);this.needsCentroidUpdate=!0}}createCentroidsBuffer(){this.centroidVertexArray.resize(this.layoutVertexArray.length),this.groundEffect.hiddenByLandmarkVertexArray.resize(this.groundEffect.vertexArray.length);for(let e of this.centroidData)this.writeCentroidToBuffer(e)}updateReplacement(e,i,r){if(i.updateTime===this.replacementUpdateTime)return;this.replacementUpdateTime=i.updateTime;let s=i.getReplacementRegionsForTile(e.toUnwrapped());if(jm(this.activeReplacements,s))return;if(this.activeReplacements=s,this.centroidVertexArray.length===0)this.createCentroidsBuffer();else for(let u of this.centroidData)u.flags&=1073741823;let l=[];for(let u of this.activeReplacements){if(u.order<r)continue;let p=Math.max(1,Math.pow(2,u.footprintTileId.canonical.z-e.canonical.z));if(u.footprint.buildingIds)for(let f of this.centroidData)f.flags&Ga||f.flags&Hm||u.min.x>f.max.x||f.min.x>u.max.x||u.min.y>f.max.y||f.min.y>u.max.y||u.footprint.buildingIds.has(f.buildingId)&&(f.flags|=u.clipMask!==Gm.None?-1073741824:Ga);else for(let f of this.centroidData)if(!(f.flags&Ga||f.flags&Hm||u.min.x>f.max.x||f.min.x>u.max.x||u.min.y>f.max.y||f.min.y>u.max.y))for(let g=0;g<f.footprintSegLen;g++){let x=this.footprintSegments.get(f.footprintSegIdx+g);if(l.length=0,ab(this.footprintVertices,x.vertexOffset,x.vertexCount,u.footprintTileId.canonical,e.canonical,l),Lg(u.footprint,l,this.footprintIndices.uint16,x.indexOffset,x.indexCount,-x.vertexOffset,-p)){f.flags|=u.clipMask!==Gm.None?-1073741824:Ga;break}}}for(let u of this.centroidData)this.writeCentroidToBuffer(u);this.borderDoneWithNeighborZ=[-1,-1,-1,-1]}footprintContainsPoint(e,i,r){let s=!1;for(let l=0;l<r.footprintSegLen;l++){let u=this.footprintSegments.get(r.footprintSegIdx+l),p=0;for(let f of u.ringIndices){for(let g=p,x=f+p-1;g<f+p;x=g++){let b=this.footprintVertices.int16[2*(g+u.vertexOffset)+0],w=this.footprintVertices.int16[2*(g+u.vertexOffset)+1],S=this.footprintVertices.int16[2*(x+u.vertexOffset)+1];w>i!=S>i&&e<(this.footprintVertices.int16[2*(x+u.vertexOffset)+0]-b)*(i-w)/(S-w)+b&&(s=!s)}p=f}}return s}getHeightAtTileCoord(e,i){let r=Number.NEGATIVE_INFINITY,s=!0,l=4*(e+Xe)*Xe+(i+Xe);if(Object.hasOwn(this.partLookup,l)){let f=this.partLookup[l];return f?{height:f.height,hidden:!!(f.flags&Ga)}:void 0}let u=this.centroidData.buffer,p=this.centroidData.length;for(let f=0;f<p;f++){let g=15*f;if(e>u[g+4]||u[g+2]>e||i>u[g+5]||u[g+3]>i)continue;let x=u[g+13];if(x<=r)continue;let b=this.centroidData.get(f);this.footprintContainsPoint(e,i,b)&&(r=x,this.partLookup[l]=b,s=!!(b.flags&Ga))}if(r!==Number.NEGATIVE_INFINITY)return{height:r,hidden:s};this.partLookup[l]=void 0}}function b0(n,e){let i=n.add(e)._unit();return n.x*i.x+n.y*i.y}function ob(n,e,i,r){let s=e.sub(n)._perp()._unit(),l=i.sub(e)._perp()._unit();return w0(n,e,i,b0(s,l),r)}function w0(n,e,i,r,s){let l=Math.sqrt(1-r*r);return Math.min(n.dist(e)/3,e.dist(i)/3,s*l/r)}function Ng(n,e,i){return n.x<i[0].x&&e.x<i[0].x||n.x>i[1].x&&e.x>i[1].x||n.y<i[0].y&&e.y<i[0].y||n.y>i[1].y&&e.y>i[1].y}function T0(n,e){return n.x<e[0].x||n.x>e[1].x||n.y<e[0].y||n.y>e[1].y}
7function sb(n){return n.every(e=>e.x<=0)||n.every(e=>e.x>=Xe)||n.every(e=>e.y<=0)||n.every(e=>e.y>=Xe)}function S0(n,e,i){if(n.x<0||n.x>=Xe||e.x<0||e.x>=Xe||i.x<0||i.x>=Xe)return!1;let r=i.sub(e),s=r.perp(),l=n.sub(e);return(r.x*l.x+r.y*l.y)/Math.sqrt((r.x*r.x+r.y*r.y)*(l.x*l.x+l.y*l.y))>-.866&&s.x*l.x+s.y*l.y<0}function I0(n,e,i){let r=e?2|n:-3&n;return i?1|r:-2&r}function E0(){let n=Math.PI/32,e=Math.tan(n),i=rs;return i*Math.sqrt(1+2*e*e)-i}function A0(n,e,i){let r=1<<i.z,s=Ir(i.x/r),l=Ir((i.x+1)/r),u=Ln(i.y/r),p=Ln((i.y+1)/r);return function(f,g,x,b,w=0,S){let E=[];if(!f.length||!x||!b)return E;let M=(H,ie)=>{for(let W of H)E.push({polygon:W,bounds:ie})},C=Math.ceil(Math.log2(x)),R=Math.ceil(Math.log2(b)),F=C-R,z=[];for(let H=0;H<Math.abs(F);H++)z.push(F>0?0:1);for(let H=0;H<Math.min(C,R);H++)z.push(0),z.push(1);let j=f;if(j=km(j,g[0].y-w,g[1].y+w,1),j=km(j,g[0].x-w,g[1].x+w,0),!j.length)return E;let $=[];for(z.length?$.push({polygons:j,bounds:g,depth:0}):M(j,g);$.length;){let H=$.pop(),ie=H.depth,W=z[ie],Q=H.bounds[0],Y=H.bounds[1],ee=W===0?Q.x:Q.y,me=W===0?Y.x:Y.y,ge=S?S(W,ee,me):.5*(ee+me),Te=km(H.polygons,ee-w,ge+w,W),Ae=km(H.polygons,ge-w,me+w,W);if(Te.length){let Ee=[Q,new ke(W===0?ge:Y.x,W===1?ge:Y.y)];z.length>ie+1?$.push({polygons:Te,bounds:Ee,depth:ie+1}):M(Te,Ee)}if(Ae.length){let Ee=[new ke(W===0?ge:Q.x,W===1?ge:Q.y),Y];z.length>ie+1?$.push({polygons:Ae,bounds:Ee,depth:ie+1}):M(Ae,Ee)}}return E}(n,e,Math.ceil((l-s)/11.25),Math.ceil((u-p)/11.25),1,(f,g,x)=>{if(f===0)return .5*(g+x);{let b=Ln((i.y+g/Xe)/r);return(Fo(.5*(Ln((i.y+x/Xe)/r)+b))*r-i.y)*Xe}})}function ab(n,e,i,r,s,l){let u=Math.pow(2,r.z-s.z);for(let p=0;p<i;p++){let f=n.int16[2*(p+e)+0],g=n.int16[2*(p+e)+1];f=(f+s.x*Xe)*u-r.x*Xe,g=(g+s.y*Xe)*u-r.y*Xe,l.push(new ke(f,g))}}let M0,C0,P0,D0;Qe(Ym,"FillExtrusionBucket",{omit:["layers","features"]}),Qe(Wm,"PartData"),Qe(Xm,"PartDataArray"),Qe(Zm,"FootprintSegmentArray"),Qe(Bg,"BorderCentroidData"),Qe(kg,"GroundEffect");class eu extends ke{constructor(e,i,r){super(e,i),this.z=r}}class R0 extends eu{constructor(e,i,r,s){super(e,i,r),this.w=s}}function z0(n,e,i,r){let s=i==="x"?"y":"x",l=(r-n[i])/(e[i]-n[i]);n[s]=Math.round(n[s]+(e[s]-n[s])*l),n[i]=r,Object.hasOwn(n,"z")&&(n.z=ft(n.z,e.z,l)),Object.hasOwn(n,"w")&&(n.w=ft(n.w,e.w,l))}function L0(n,e,i,r){let s=i,l=r;for(let u of["x","y"]){let p=n,f=e;p[u]>=f[u]&&(p=e,f=n),p[u]<s&&f[u]>s&&z0(p,f,u,s),p[u]<l&&f[u]>l&&z0(f,p,u,l)}}function Jm(n,e,i,r,s,l){let u=[];for(let p=0;p<n.length;p++){let f=n[p],g,x=u.length,b=0;for(let w=0;w<f.length-1;w++){let S=f[w],E=f[w+1],M=0,C=b,R,F;l&&(M=Math.hypot(E.x-S.x,E.y-S.y),b+=M,R=S,F=E),S.x<e&&E.x<e||(S.x<e?S=new ke(e,S.y+(e-S.x)/(E.x-S.x)*(E.y-S.y))._round():E.x<e&&(E=new ke(e,S.y+(e-S.x)/(E.x-S.x)*(E.y-S.y))._round()),S.y<i&&E.y<i||(S.y<i?S=new ke(S.x+(i-S.y)/(E.y-S.y)*(E.x-S.x),i)._round():E.y<i&&(E=new ke(S.x+(i-S.y)/(E.y-S.y)*(E.x-S.x),i)._round()),S.x>=r&&E.x>=r||(S.x>=r?S=new ke(r,S.y+(r-S.x)/(E.x-S.x)*(E.y-S.y))._round():E.x>=r&&(E=new ke(r,S.y+(r-S.x)/(E.x-S.x)*(E.y-S.y))._round()),S.y>=s&&E.y>=s||(S.y>=s?S=new ke(S.x+(s-S.y)/(E.y-S.y)*(E.x-S.x),s)._round():E.y>=s&&(E=new ke(S.x+(s-S.y)/(E.y-S.y)*(E.x-S.x),s)._round()),g&&S.equals(g.at(-1))||(g=[S],u.push(g),l&&l.push({progress:{min:C+O0(R,F,S)*M,max:1},parentIndex:p,prevPoint:R,nextPoint:F})),g.push(E),l&&(l.at(-1).progress.max=C+O0(R,F,E)*M,l.at(-1).nextPoint=F)))))}if(l&&b>0)for(let w=x;w<u.length;w++)l[w].progress.min/=b,l[w].progress.max/=b}return u}function lb(n,e,i,r,s){if(n.length<2)return void r.push(n);let l=[];for(;e.valid();){let[g,x]=e.get();for(let b=0;b<n.length-1;b++){let w=n[b],S=n[b+1],E=I(w,S,g,x);if(E){let[M]=E,C=new ke(ft(w.x,S.x,M),ft(w.y,S.y,M));l.push({t:b+M,distance:0,point:C})}}e.next()}if(l.length===0)return void r.push(n);l.sort((g,x)=>g.t-x.t);let u=0,p=0,f=[];for(r.push(f);u!==n.length;){if(p===l.length){for(;u!==n.length;)f.length!==0&&f.at(-1).equals(n[u])||f.push(n[u]),u++;break}l[p].t<=u?(f.length!==0&&f.at(-1).equals(l[p].point)||f.push(l[p].point),Math.trunc(l[p].t),p++):(f.length!==0&&f.at(-1).equals(n[u])||f.push(n[u]),u++)}}function O0(n,e,i){return n.x!==e.x?(i.x-n.x)/(e.x-n.x):n.y!==e.y?(i.y-n.y)/(e.y-n.y):0}function Tp(n,e){return n.x*e.x+n.y*e.y}function F0(n,e){if(n.length===1){let i=0,r=e[i++],s;for(;!s||r.equals(s);)if(s=e[i++],!s)return 1/0;for(;i<e.length;i++){let l=e[i],u=n[0],p=s.sub(r),f=l.sub(r),g=u.sub(r),x=Tp(p,p),b=Tp(p,f),w=Tp(f,f),S=Tp(g,p),E=Tp(g,f),M=x*w-b*b,C=(w*S-b*E)/M,R=(x*E-b*S)/M,F=r.z*(1-C-R)+s.z*C+l.z*R;if(isFinite(F))return F}return 1/0}{let i=1/0;for(let r of e)i=Math.min(i,r.z);return i}}function B0(n,e,i){let r=1/0;m(i,e)&&(r=F0(i,e[0]));for(let s=0;s<e.length;s++){let l=e[s],u=n[s];for(let p=0;p<l.length-1;p++){let f=l[p],g=[f,l[p+1],u[p+1],u[p],f];c(i,g)&&(r=Math.min(r,F0(i,g)))}}return r!==1/0&&r}function k0(n,e,i,r,s,l,u,p,f,g,x){return n.projection.name==="globe"?function(b,w,S,E,M,C,R,F,z,j,$){let H=[],ie=[],W=b.projection.upVectorScale($,b.center.lat,b.worldSize).metersToTile,Q=[0,0,0,1],Y=[0,0,0,1],ee=(ge,Te,Ae,Ee)=>{ge[0]=Te,ge[1]=Ae,ge[2]=Ee,ge[3]=1},me=E0();S>0&&(S+=me),E+=me;for(let ge of w){let Te=[],Ae=[];for(let Ee of ge){let Be=Ee.x+M.x,xe=Ee.y+M.y,Se=b.projection.projectTilePoint(Be,xe,$),Me=b.projection.upVector($,Ee.x,Ee.y),ze=S,Le=E;if(R){let We=N0(Be,xe,S,E,R,F,z,j);ze+=We.base,Le+=We.top}S!==0?ee(Q,Se.x+Me[0]*W*ze,Se.y+Me[1]*W*ze,Se.z+Me[2]*W*ze):ee(Q,Se.x,Se.y,Se.z),ee(Y,Se.x+Me[0]*W*Le,Se.y+Me[1]*W*Le,Se.z+Me[2]*W*Le),Oi(Q,Q,C),Oi(Y,Y,C),Te.push(new eu(Q[0],Q[1],Q[2])),Ae.push(new eu(Y[0],Y[1],Y[2]))}
7H.push(Te),ie.push(Ae)}return[H,ie]}(n,e,i,r,s,l,u,p,f,g,x):u?function(b,w,S,E,M,C,R,F,z){let j=[],$=[],H=[0,0,0,1];for(let ie of b){let W=[],Q=[];for(let Y of ie){let ee=Y.x+E.x,me=Y.y+E.y,ge=N0(ee,me,w,S,C,R,F,z);H[0]=ee,H[1]=me,H[2]=ge.base,H[3]=1,_r(H,H,M),H[3]=Math.max(H[3],1e-5);let Te=new eu(H[0]/H[3],H[1]/H[3],H[2]/H[3]);H[0]=ee,H[1]=me,H[2]=ge.top,H[3]=1,_r(H,H,M),H[3]=Math.max(H[3],1e-5);let Ae=new eu(H[0]/H[3],H[1]/H[3],H[2]/H[3]);W.push(Te),Q.push(Ae)}j.push(W),$.push(Q)}return[j,$]}(e,i,r,s,l,u,p,f,g):function(b,w,S,E,M){let C=[],R=[],F=M[8]*w,z=M[9]*w,j=M[10]*w,$=M[11]*w,H=M[8]*S,ie=M[9]*S,W=M[10]*S,Q=M[11]*S;for(let Y of b){let ee=[],me=[];for(let ge of Y){let Te=ge.x+E.x,Ae=ge.y+E.y,Ee=M[0]*Te+M[4]*Ae+M[12],Be=M[1]*Te+M[5]*Ae+M[13],xe=M[2]*Te+M[6]*Ae+M[14],Se=M[3]*Te+M[7]*Ae+M[15],Me=Ee+F,ze=Be+z,Le=xe+j,We=Math.max(Se+$,1e-5),De=Ee+H,Ge=Be+ie,He=xe+W,Je=Math.max(Se+Q,1e-5);ee.push(new eu(Me/We,ze/We,Le/We)),me.push(new eu(De/Je,Ge/Je,He/Je))}C.push(ee),R.push(me)}return[C,R]}(e,i,r,s,l)}function N0(n,e,i,r,s,l,u,p){let f=u*s.getElevationAt(n,e,!0,!0),g=l[0]!==0,x=g?l[1]===0?u*(l[0]/7-450):u*function(b,w,S){let E=Math.floor(w[0]/8),M=Math.floor(w[1]/8),C=10*(w[0]-8*E),R=10*(w[1]-8*M),F=b.getElevationAt(E,M,!0,!0),z=b.getMeterToDEM(S),j=Math.floor(.5*(C*z-1)),$=Math.floor(.5*(R*z-1)),H=b.tileCoordToPixel(E,M),ie=2*j+1,W=2*$+1,Q=function(Ae,Ee,Be,xe,Se){return[Ae.getElevationAtPixel(Ee,Be,!0),Ae.getElevationAtPixel(Ee+Se,Be,!0),Ae.getElevationAtPixel(Ee,Be+Se,!0),Ae.getElevationAtPixel(Ee+xe,Be+Se,!0)]}(b,H.x-j,H.y-$,ie,W),Y=Math.abs(Q[0]-Q[1]),ee=Math.abs(Q[2]-Q[3]),me=Math.abs(Q[0]-Q[2])+Math.abs(Q[1]-Q[3]),ge=Math.min(.25,.5*z*(Y+ee)/ie),Te=Math.min(.25,.5*z*me/W);return F+Math.max(ge*C,Te*R)}(s,l,p):f;return{base:f+(i===0?-1:i),top:g?Math.max(x+r,f+i+2):f+r}}let cs=null,Km=null,Ug=null,Qm=null,U0=5120,V0=5121,j0=5122,G0=5123,$0=5125,H0=5126,e_={[U0]:Int8Array,[V0]:Uint8Array,[j0]:Int16Array,[G0]:Uint16Array,[$0]:Uint32Array,[H0]:Float32Array},cb={[U0]:"DT_INT8",[V0]:"DT_UINT8",[j0]:"DT_INT16",[G0]:"DT_UINT16",[$0]:"DT_UINT32",[H0]:"DT_FLOAT32"},Sp={SCALAR:1,VEC2:2,VEC3:3,VEC4:4,MAT2:4,MAT3:9,MAT4:16};function q0(n,e,i){let r=i.json.bufferViews.length,s=i.buffers.length;e.bufferView=r,i.json.bufferViews[r]={buffer:s,byteLength:n.byteLength},i.buffers[s]=n}let Vg="KHR_draco_mesh_compression";function ub(n,e){let i=n.extensions&&n.extensions[Vg];if(!i)return;let r=new cs.Decoder,s=Y0(e,i.bufferView),l=new cs.Mesh;if(!r.DecodeArrayToMesh(s,s.byteLength,l))throw new Error("Failed to decode Draco mesh");let u=e.json.accessors[n.indices],p=e_[u.componentType],f=u.count*p.BYTES_PER_ELEMENT,g=cs._malloc(f);p===Uint16Array?r.GetTrianglesUInt16Array(l,f,g):r.GetTrianglesUInt32Array(l,f,g),q0(cs.memory.buffer.slice(g,g+f),u,e),cs._free(g);for(let x of Object.keys(i.attributes)){let b=r.GetAttributeByUniqueId(l,i.attributes[x]),w=e.json.accessors[n.attributes[x]],S=cb[w.componentType],E=w.count*Sp[w.type]*e_[w.componentType].BYTES_PER_ELEMENT,M=cs._malloc(E);r.GetAttributeDataArrayForAllPoints(l,b,cs[S],E,M),q0(cs.memory.buffer.slice(M,M+E),w,e),cs._free(M)}r.destroy(),l.destroy(),delete n.extensions[Vg]}let t_="EXT_meshopt_compression";function hb(n,e){if(!n.extensions||!n.extensions[t_])return;let i=n.extensions[t_],r=new Uint8Array(e.buffers[i.buffer],i.byteOffset||0,i.byteLength||0),s=new Uint8Array(i.count*i.byteStride);Ug.decodeGltfBuffer(s,i.count,i.byteStride,r,i.mode,i.filter),n.buffer=e.buffers.length,n.byteOffset=0,e.buffers[n.buffer]=s.buffer,delete n.extensions[t_]}let Z0=1179937895,W0=new TextDecoder("utf8");function X0(n,e){return new URL(n,e).href}async function db(n,e,i,r,s){let l=await fetch(X0(n.uri,r),{signal:s}),u=await l.arrayBuffer();e.buffers[i]=u}function Y0(n,e){let i=n.json.bufferViews[e];return new Uint8Array(n.buffers[i.buffer],i.byteOffset||0,i.byteLength)}async function pb(n,e,i,r,s){if(n.uri){let l=X0(n.uri,r),u=await fetch(l,{signal:s}),p=await u.blob(),f=await createImageBitmap(p);e.images[i]=f}else if(n.bufferView!==void 0){let l=Y0(e,n.bufferView),u=new Blob([l],{type:n.mimeType}),p=await createImageBitmap(u);e.images[i]=p}}async function J0(n,e=0,i,r){let s={json:null,images:[],buffers:[]};
7if(new Uint32Array(n,e,1)[0]===Z0){let S=new Uint32Array(n,e),E=2,M=(S[E++]>>2)-3,C=S[E++]>>2;if(E++,s.json=JSON.parse(W0.decode(S.subarray(E,E+C))),E+=C,E<M){let R=S[E++];E++;let F=e+(E<<2);s.buffers[0]=n.slice(F,F+R)}}else s.json=JSON.parse(W0.decode(new Uint8Array(n,e)));let{buffers:l,images:u,meshes:p,extensionsUsed:f,bufferViews:g}=s.json;if(l){let S=[];for(let E=0;E<l.length;E++){let M=l[E];M.uri?S.push(db(M,s,E,i,r)):s.buffers[E]||(s.buffers[E]=null)}await Promise.all(S)}if(r&&r.aborted)throw new DOMException("Aborted","AbortError");let x=[],b=f&&f.includes(Vg),w=f&&f.includes(t_);if(b&&x.push(function(){if(!cs)return Km!=null||(Km=function(S){let E,M=null;function C(){E=new Uint8Array(M.buffer)}function R(){throw new Error("Unexpected Draco error.")}return WebAssembly.instantiateStreaming(S,{a:{a:R,d:function(F,z,j){return E.copyWithin(F,z,z+j)},c:function(F){let z=E.length,j=Math.max(F>>>0,Math.ceil(1.2*z)),$=Math.ceil((j-z)/65536);try{return M.grow($),C(),!0}catch{return!1}},b:R}}).then(F=>{let{Rb:z,Qb:j,P:$,T:H,X:ie,Ja:W,La:Q,Qa:Y,Va:ee,Wa:me,eb:ge,jb:Te,f:Ae,e:Ee,yb:Be,zb:xe,Ab:Se,Bb:Me,Db:ze,Gb:Le}=F.instance.exports;M=Ee;let We=(()=>{let De=0,Ge=0,He=0,Je=0;return tt=>{He&&(z(Je),z(De),Ge+=He,He=De=0),De||(Ge+=128,De=j(Ge));let lt=tt.length+7&-8,rt=De;lt>=Ge&&(He=lt,rt=Je=j(lt));for(let pt=0;pt<tt.length;pt++)E[rt+pt]=tt[pt];return rt}})();return C(),Ae(),{memory:Ee,_free:z,_malloc:j,Mesh:class{constructor(){this.ptr=$()}destroy(){H(this.ptr)}},Decoder:class{constructor(){this.ptr=W()}destroy(){Te(this.ptr)}DecodeArrayToMesh(De,Ge,He){let Je=We(De),tt=Q(this.ptr,Je,Ge,He.ptr);return!!ie(tt)}GetAttributeByUniqueId(De,Ge){return{ptr:Y(this.ptr,De.ptr,Ge)}}GetTrianglesUInt16Array(De,Ge,He){ee(this.ptr,De.ptr,Ge,He)}GetTrianglesUInt32Array(De,Ge,He){me(this.ptr,De.ptr,Ge,He)}GetAttributeDataArrayForAllPoints(De,Ge,He,Je,tt){ge(this.ptr,De.ptr,Ge.ptr,He,Je,tt)}},DT_INT8:Be(),DT_UINT8:xe(),DT_INT16:Se(),DT_UINT16:Me(),DT_UINT32:ze(),DT_FLOAT32:Le()}})}(fetch(ha())).then(S=>{cs=S,Km=null})),Km}()),w&&x.push(function(){var S;if(!Ug)return Qm!=null||(Qm=(S=fetch(da()),WebAssembly.instantiateStreaming(S,{}).then(E=>{let{sbrk:M,memory:C,meshopt_decodeVertexBuffer:R,meshopt_decodeIndexBuffer:F,meshopt_decodeIndexSequence:z,meshopt_decodeFilterOct:j,meshopt_decodeFilterQuat:$,meshopt_decodeFilterExp:H}=E.instance.exports,ie={ATTRIBUTES:R,TRIANGLES:F,INDICES:z},W={OCTAHEDRAL:j,QUATERNION:$,EXPONENTIAL:H};return E.instance.exports.__wasm_call_ctors(),{decodeGltfBuffer(Q,Y,ee,me,ge,Te){let Ae=Y+3&-4,Ee=M(Ae*ee),Be=M(me.length),xe=new Uint8Array(C.buffer);xe.set(me,Be);let Se=ie[ge](Ee,Y,ee,Be,me.length);if(Se===0&&W[Te]&&W[Te](Ee,Ae,ee),Q.set(xe.subarray(Ee,Ee+Y*ee)),M(Ee-M(0)),Se!==0)throw new Error(`Malformed buffer data: ${Se}`)}}})).then(E=>{Ug=E,Qm=null})),Qm}()),u)for(let S=0;S<u.length;S++)x.push(pb(u[S],s,S,i,r));if(x.length&&await Promise.all(x),r&&r.aborted)throw new DOMException("Aborted","AbortError");if(b&&p)for(let{primitives:S}of p)for(let E of S)ub(E,s);if(w&&p&&g)for(let S of g)hb(S,s);return s}async function K0(n,e){let i=await async function(r,s){if(s&&s.aborted)throw new DOMException("Aborted","AbortError");return new Promise((l,u)=>{let p=Lr(r,(f,g)=>{f?u(f):l(g)});s&&s.addEventListener("abort",()=>{p.cancel(),u(new DOMException("Aborted","AbortError"))},{once:!0})})}({url:n,type:"arrayBuffer"},e);return J0(i,0,n,e)}function jg(n){switch(n){case WebGL2RenderingContext.RGBA8:case WebGL2RenderingContext.RGBA16F:return WebGL2RenderingContext.RGBA;case WebGL2RenderingContext.DEPTH_COMPONENT16:return WebGL2RenderingContext.DEPTH_COMPONENT;case WebGL2RenderingContext.DEPTH24_STENCIL8:return WebGL2RenderingContext.DEPTH_STENCIL;case WebGL2RenderingContext.R8:case WebGL2RenderingContext.R32F:return WebGL2RenderingContext.RED}}function Gg(n){switch(n){case WebGL2RenderingContext.RGBA8:return WebGL2RenderingContext.UNSIGNED_BYTE;case WebGL2RenderingContext.RGBA16F:return WebGL2RenderingContext.HALF_FLOAT;case WebGL2RenderingContext.DEPTH_COMPONENT16:return WebGL2RenderingContext.UNSIGNED_SHORT;case WebGL2RenderingContext.DEPTH24_STENCIL8:return WebGL2RenderingContext.UNSIGNED_INT_24_8;case WebGL2RenderingContext.R8:return WebGL2RenderingContext.UNSIGNED_BYTE;case WebGL2RenderingContext.R32F:return WebGL2RenderingContext.FLOAT}}
7class Xs{constructor(e,i,r,s){this.context=e,this.format=r,this.useMipmap=s&&s.useMipmap,this.texture=e.gl.createTexture(),this.update(i,{premultiply:s&&s.premultiply})}update(e,i){let r=e&&e instanceof HTMLVideoElement&&e.width===0?e.videoWidth:e.width,s=e&&e instanceof HTMLVideoElement&&e.height===0?e.videoHeight:e.height,{context:l}=this,{gl:u}=l,{x:p,y:f}=i&&i.position?i.position:{x:0,y:0},g=p+r,x=f+s;this.size&&(this.size[0]!==g||this.size[1]!==x)&&(!i||i.recreateWhenResize===void 0||i.recreateWhenResize)&&(u.bindTexture(u.TEXTURE_2D,null),u.deleteTexture(this.texture),this.texture=u.createTexture(),this.size=null),u.bindTexture(u.TEXTURE_2D,this.texture),l.pixelStoreUnpackFlipY.set(!1),l.pixelStoreUnpack.set(1),l.pixelStoreUnpackPremultiplyAlpha.set(this.format===u.RGBA8&&(!i||i.premultiply!==!1));let b=e instanceof HTMLImageElement||e instanceof HTMLCanvasElement||e instanceof HTMLVideoElement||e instanceof ImageData||ImageBitmap&&e instanceof ImageBitmap;if(!this.size&&g>0&&x>0){let w=this.useMipmap?Math.floor(Math.log2(Math.max(g,x)))+1:1;u.texStorage2D(u.TEXTURE_2D,w,this.format,g,x),this.size=[g,x]}this.size&&(b?u.texSubImage2D(u.TEXTURE_2D,0,p,f,jg(this.format),Gg(this.format),e):"data"in e&&e.data&&u.texSubImage2D(u.TEXTURE_2D,0,p,f,r,s,jg(this.format),Gg(this.format),e.data)),this.useMipmap&&u.generateMipmap(u.TEXTURE_2D)}bind(e,i,r=!1){let{context:s}=this,{gl:l}=s;l.bindTexture(l.TEXTURE_2D,this.texture),e!==this.minFilter&&(l.texParameteri(l.TEXTURE_2D,l.TEXTURE_MAG_FILTER,e),l.texParameteri(l.TEXTURE_2D,l.TEXTURE_MIN_FILTER,this.useMipmap&&!r?e===l.NEAREST?l.NEAREST_MIPMAP_NEAREST:l.LINEAR_MIPMAP_LINEAR:e),this.minFilter=e),i!==this.wrapS&&(l.texParameteri(l.TEXTURE_2D,l.TEXTURE_WRAP_S,i),l.texParameteri(l.TEXTURE_2D,l.TEXTURE_WRAP_T,i),this.wrapS=i)}bindExtraParam(e,i,r,s,l){let{context:u}=this,{gl:p}=u;p.bindTexture(p.TEXTURE_2D,this.texture),i!==this.magFilter&&(p.texParameteri(p.TEXTURE_2D,p.TEXTURE_MAG_FILTER,i),this.magFilter=i),e!==this.minFilter&&(p.texParameteri(p.TEXTURE_2D,p.TEXTURE_MIN_FILTER,this.useMipmap?e===p.NEAREST?p.NEAREST_MIPMAP_NEAREST:p.LINEAR_MIPMAP_LINEAR:e),this.minFilter=e),r!==this.wrapS&&(p.texParameteri(p.TEXTURE_2D,p.TEXTURE_WRAP_S,r),this.wrapS=r),s!==this.wrapT&&(p.texParameteri(p.TEXTURE_2D,p.TEXTURE_WRAP_T,s),this.wrapT=s),l!==this.compareMode&&(l?(p.texParameteri(p.TEXTURE_2D,p.TEXTURE_COMPARE_MODE,p.COMPARE_REF_TO_TEXTURE),p.texParameteri(p.TEXTURE_2D,p.TEXTURE_COMPARE_FUNC,l)):p.texParameteri(p.TEXTURE_2D,p.TEXTURE_COMPARE_MODE,p.NONE),this.compareMode=l)}destroy(){let{gl:e}=this.context;e.deleteTexture(this.texture),this.texture=null}}class Ip{constructor(e,i){this.context=e,this.texture=i}bind(e,i){let{context:r}=this,{gl:s}=r;s.bindTexture(s.TEXTURE_2D,this.texture),e!==this.minFilter&&(s.texParameteri(s.TEXTURE_2D,s.TEXTURE_MAG_FILTER,e),s.texParameteri(s.TEXTURE_2D,s.TEXTURE_MIN_FILTER,e),this.minFilter=e),i!==this.wrapS&&(s.texParameteri(s.TEXTURE_2D,s.TEXTURE_WRAP_S,i),s.texParameteri(s.TEXTURE_2D,s.TEXTURE_WRAP_T,i),this.wrapS=i)}}let fb=Ct([{name:"a_pos_3f",components:3,type:"Float32"}]),mb=Ct([{name:"a_color_3f",components:3,type:"Float32"}]),_b=Ct([{name:"a_color_4f",components:4,type:"Float32"}]),gb=Ct([{name:"a_uv_2f",components:2,type:"Float32"}]),yb=Ct([{name:"a_normal_3f",components:3,type:"Float32"}]),xb=Ct([{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"}]),vb=Ct([{name:"a_pbr",components:4,type:"Uint16"},{name:"a_heightBasedEmissiveStrength",components:3,type:"Float32"}]);function Q0(n,e){let i=i_(n.projection,n.zoom,n.width,n.height),r=function(l,u,p,f,g){let x=new Yt(p.lng-180*jl,p.lat),b=new Yt(p.lng+180*jl,p.lat),w=l.project(x.lng,x.lat),S=l.project(b.lng,b.lat),E=-Math.atan2(S.y-w.y,S.x-w.x),M=qn.fromLngLat(p);M.y=ne(M.y,-1+jl,1-jl);let C=M.toLngLat(),R=l.project(C.lng,C.lat),F=qn.fromLngLat(C);F.x+=jl;let z=F.toLngLat(),j=l.project(z.lng,z.lat),$=tx(j.x-R.x,j.y-R.y,E),H=qn.fromLngLat(C);H.y+=jl;let ie=H.toLngLat(),W=l.project(ie.lng,ie.lat),Q=tx(W.x-R.x,W.y-R.y,E),Y=Math.abs($.x)/Math.abs(Q.y),ee=Rt([]);ho(ee,ee,-E*(1-(g?0:f)));let me=Rt([]);return Zn(me,me,[1,1-(1-Y)*f,1]),me[4]=-Q.x/Q.y*f,ho(me,me,E),xi(me,ee,me),me}
7(n.projection,0,n.center,i,e),s=ex(n);return Zn(r,r,[s,s,1]),r}function ex(n){let e=n.projection,i=i_(n.projection,n.zoom,n.width,n.height),r=$g(e,n.center),s=$g(e,Yt.convert(e.center));return Math.pow(2,r*i+(1-i)*s)}function i_(n,e,i,r,s=1/0){let l=n.range;if(!l)return 0;let u=Math.min(s,Math.max(i,r)),p=Math.log2(u/1024);return ye(l[0]+p,l[1]+p,e)}let jl=1/4e4;function $g(n,e){let i=ne(e.lat,-85.051129,Er),r=new Yt(e.lng-180*jl,i),s=new Yt(e.lng+180*jl,i),l=n.project(r.lng,i),u=n.project(s.lng,i),p=qn.fromLngLat(r),f=qn.fromLngLat(s),g=u.x-l.x,x=u.y-l.y,b=f.x-p.x,w=f.y-p.y,S=Math.sqrt((b*b+w*w)/(g*g+x*x));return Math.log2(S)}function tx(n,e,i){let r=Math.cos(i),s=Math.sin(i);return{x:n*r-e*s,y:n*s+e*r}}let bb=new Float64Array([1,0,0,0,0,0,1,0,0,1,0,0,0,0,0,1]);function ix(n,e,i){Rt(n),ho(n,n,V(e[2])),Vo(n,n,V(e[0])),jo(n,n,V(e[1])),Zn(n,n,i),xi(n,n,bb)}function n_(n,e,i,r,s,l,u,p){let f=[i[0]-e[0],i[1]-e[1],0],g=[r[0]-e[0],r[1]-e[1],0];if(Dn(f)<1e-12||Dn(g)<1e-12)return ys(n);let x=Wn([],f,g);hi(x,x),po(g,r,e),f[2]=(l-s)*p,g[2]=(u-s)*p;let b=f;return Wn(b,f,g),hi(b,b),sc(n,x,b)}function r_(n,e,i=!1){let r=$t(e.zoom),s=function(l,u,p){let f=u.worldSize,g=[l[12],l[13],l[14]],x=Ln(g[1]/f),b=Ir(g[0]/f),w=Rt([]),S=or(1,x)*f,E=or(1,0)*f*Ua(x,u.zoom),M=1/Ft(f),C=E*M;if(p){let j=i_(u.projection,u.zoom,u.width,u.height,1024);C=M*u.projection.pixelSpaceConversion(u.center.lat,f,j)}let R=ns(x,b);tn(R,R,Li([],hi([],R),S*C*g[2]));let F=function(j){let $=[j[0],j[1],j[2]],H=[0,1,0],ie=Wn([],H,$);return Wn(H,$,ie),rc(H)===0&&(H=[0,1,0],Wn(ie,$,H)),hi(ie,ie),hi(H,H),hi($,$),[ie[0],ie[1],ie[2],0,H[0],H[1],H[2],0,$[0],$[1],$[2],0,j[0],j[1],j[2],1]}(R);Zn(w,w,[C,C,C*S]),Gn(w,w,[-g[0],-g[1],-g[2]]);let z=xi([],u.globeMatrix,F);return xi(z,z,w),xi(z,z,l),z}(n,e,i);if(r>0){let l=function(u,p){let f=p.worldSize,g=or(1,0)*f*Ua(p.center.lat,p.zoom)/Ft(f),x=or(1,p.center.lat)*f,b=Rt([]);jo(b,b,V(p.center.lng)),Vo(b,b,V(p.center.lat)),Gn(b,b,[0,0,Jn]),Zn(b,b,[g,g,g*x]);let w=p.point;return Gn(b,b,[-w.x,-w.y,0]),xi(b,b,u),xi(b,p.globeMatrix,b)}(n,e);return function(u,p,f){let g=(E,M,C)=>{let R=Dn(E),F=Dn(M),z=je(E,M,C);return Li(z,z,1/Dn(z)*ft(R,F,C))},x=g([u[0],u[1],u[2]],[p[0],p[1],p[2]],f),b=g([u[4],u[5],u[6]],[p[4],p[5],p[6]],f),w=g([u[8],u[9],u[10]],[p[8],p[9],p[10]],f),S=je([u[12],u[13],u[14]],[p[12],p[13],p[14]],f);return[x[0],x[1],x[2],0,b[0],b[1],b[2],0,w[0],w[1],w[2],0,S[0],S[1],S[2],1]}(s,l,r)}return s}function Hg(n,e,i,r){let s=Si.projectAabbCorners(r,i),l=Number.MAX_VALUE;for(let p=0;p<s.length;++p){let f=s[p];f[0]=(.5*f[0]+.5)*e.width,f[1]=(.5-.5*f[1])*e.height,f[2]<l&&(l=f[2])}let u=function(p){let f=[],g=0;for(let S=1;S<p.length;S++)(p[S][0]<p[g][0]||p[S][0]===p[g][0]&&p[S][1]<p[g][1])&&(g=S);let x,b=g,w=new Uint8Array(p.length);do{if(w[b])break;f.push(new ke(p[b][0],p[b][1])),w[b]=1,x=(b+1)%p.length;for(let S=0;S<p.length;S++){if(p[S][0]===p[x][0]&&p[S][1]===p[x][1]||p[S][0]===p[b][0]&&p[S][1]===p[b][1])continue;let E=[p[S][0]-p[b][0],p[S][1]-p[b][1]],M=[p[x][0]-p[b][0],p[x][1]-p[b][1]],C=E[0]*M[1]-E[1]*M[0];(C>0||C===0&&E[0]*M[0]+E[1]*M[1]>=0&&E[0]*E[0]+E[1]*E[1]>M[0]*M[0]+M[1]*M[1])&&(x=S)}b=x}while(b!==g);return f.length>0&&f.push(f[0]),f}(s);if(c(n,u))return l}let tu=64,vh={CoordinateSpaceTile:1,HasMapboxMeshFeatures:4,HasMeshoptCompression:8};function o_(n,e,i,r,s,l,u,p,f,g=!1){let x=i.zoom,b=i.project(r),w=Ua(r.lat,x),S=1/w;Rt(n),Gn(n,n,[b.x+u[0]*S,b.y+u[1]*S,u[2]]);let E=1,M=1,C=i.worldSize;if(g){if(i.projection.name==="mercator"){let j=0;i.elevation&&(j=i.elevation.getAtPointOrZero(new qn(b.x/C,b.y/C),0));let $=_r([],[b.x,b.y,j,1],i.projMatrix)[3]/i.cameraToCenterDistance;E=$,M=$*Ua(i.center.lat,x)}else if(i.projection.name==="globe"){let j=r_(n,i),$=[0,0,0,1];_r($,$,xi([],i.projMatrix,j));let H=$[3]/i.cameraToCenterDistance,ie=$t(x),W=i.projection.pixelsPerMeter(r.lat,C)*Ua(r.lat,x),Q=i.projection.pixelsPerMeter(i.center.lat,C)*Ua(i.center.lat,x);E=H/ft(W,gm(i.center.lat),ie),M=H*w/W,E*=Q,M*=Q}}else E=S;Zn(n,n,[E,E,M]);let R=[...n],F=e.orientation,z=[];if(ix(z,[F[0]+(s?s[0]:0),F[1]+(s?s[1]:0),F[2]+(s?s[2]:0)],l),xi(n,R,z),p&&i.elevation){let j=0,$=[];if(f&&i.elevation){j=function(ie,W,Q,Y,ee){let me=W.elevation;if(!me)return 0;let ge=Si.projectAabbCorners(Q,Y),Te=or(1,ee.lat)*W.worldSize,Ae=function(He,Je){let tt=[0,0,1],lt=[{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 rt of lt){let pt=He[rt.corners[0]],Ht=He[rt.corners[1]],wt=He[rt.corners[2]],kt=[Ht[0]-pt[0],Ht[1]-pt[1],Je*(Ht[2]-pt[2])],At=Wn(kt,kt,[wt[0]-pt[0],wt[1]-pt[1],Je*(wt[2]-pt[2])]);hi(At,At),rt.dotProductWithUp=Qi(At,tt)}return lt.sort((rt,pt)=>rt.dotProductWithUp-pt.dotProductWithUp),lt[0].corners}(ge,Te),Ee=ge[Ae[0]],Be=ge[Ae[1]],xe=ge[Ae[2]],Se=ge[Ae[3]],Me=me.getAtPointOrZero(new qn(Ee[0]/W.worldSize,Ee[1]/W.worldSize),0),ze=me.getAtPointOrZero(new qn(Be[0]/W.worldSize,Be[1]/W.worldSize),0),Le=me.getAtPointOrZero(new qn(xe[0]/W.worldSize,xe[1]/W.worldSize),0),We=me.getAtPointOrZero(new qn(Se[0]/W.worldSize,Se[1]/W.worldSize),0),De=(Me+We)/2,Ge=(ze+Le)/2;return De>
7Ge?ze<Le?n_(ie,Be,Se,Ee,ze,We,Me,Te):n_(ie,xe,Ee,Se,Le,Me,We,Te):Me<We?n_(ie,Ee,Be,xe,Me,ze,Le,Te):n_(ie,Se,xe,Be,We,Le,ze,Te),Math.max(De,Ge)}($,i,e.aabb,n,r);let H=xi([],ec([],$),z);xi(n,R,H)}else j=i.elevation.getAtPointOrZero(new qn(b.x/C,b.y/C),0);j!==0&&(n[14]+=j)}}class nx{constructor(e,i,r,s,l){this.materialOverrides=new Map,this.nodeOverrides=new Map,this.materialOverrideNames=[],this.nodeOverrideNames=[],this.featureProperties={},this.id=e,this.uri=i,this.position=r!=null?new Yt(r[0],r[1]):new Yt(0,0),this.orientation=s??[0,0,0],this.nodes=l,this.uploaded=!1,this.aabb=new Si([1/0,1/0,1/0],[-1/0,-1/0,-1/0]),this.matrix=[]}_applyTransformations(e,i){xi(e.globalMatrix,i,e.localMatrix);let r=this.nodeOverrides.get(e.name);if(r!==void 0){let u=[];l=r.orientation,Rt(s=u),jo(s,s,V(l[1])),ho(s,s,V(l[2])),Vo(s,s,V(l[0])),xi(e.globalMatrix,e.globalMatrix,u)}var s,l;if(e.meshes)for(let u of e.meshes){let p=Si.applyTransformFast(u.aabb,e.globalMatrix);this.aabb.encapsulate(p)}if(e.children)for(let u of e.children)this._applyTransformations(u,e.globalMatrix)}computeBoundsAndApplyParent(){let e=Rt([]);this.aabb=new Si([1/0,1/0,1/0],[-1/0,-1/0,-1/0]);for(let i of this.nodes)this._applyTransformations(i,e)}computeModelMatrix(e,i,r,s,l,u,p=!1){o_(this.matrix,this,e.transform,this.position,i,r,s,l,u,p)}upload(e){if(!this.uploaded){for(let i of this.nodes)qg(i,e);for(let i of this.nodes)s_(i);this.uploaded=!0}}destroy(){for(let e of this.nodes)Zg(e)}}function Ep(n,e,i=!1){n.uploaded||(n.gfxTexture=new Xs(e,n.image,i?e.gl.R8:e.gl.RGBA8,{useMipmap:n.sampler.minFilter>=e.gl.NEAREST_MIPMAP_NEAREST}),n.uploaded=!0,n.image=null)}function rx(n,e,i){n.indexBuffer=e.createIndexBuffer(n.indexArray,!1,!0),n.vertexBuffer=e.createVertexBuffer(n.vertexArray,fb.members,!1,!0),n.normalArray&&(n.normalBuffer=e.createVertexBuffer(n.normalArray,yb.members,!1,!0)),n.texcoordArray&&(n.texcoordBuffer=e.createVertexBuffer(n.texcoordArray,gb.members,!1,!0)),n.colorArray&&(n.colorBuffer=e.createVertexBuffer(n.colorArray,(n.colorArray.bytesPerElement===12?mb:_b).members,!1,!0)),n.featureArray&&(n.pbrBuffer=e.createVertexBuffer(n.featureArray,vb.members,!0)),n.segments=pi.simpleSegment(0,0,n.vertexArray.length,n.indexArray.length);let r=n.material;r.pbrMetallicRoughness.baseColorTexture&&Ep(r.pbrMetallicRoughness.baseColorTexture,e),r.pbrMetallicRoughness.metallicRoughnessTexture&&Ep(r.pbrMetallicRoughness.metallicRoughnessTexture,e),r.normalTexture&&Ep(r.normalTexture,e),r.occlusionTexture&&Ep(r.occlusionTexture,e,i),r.emissionTexture&&Ep(r.emissionTexture,e)}function qg(n,e,i){if(n.meshes)for(let r of n.meshes)rx(r,e,i);if(n.lodMeshes)for(let r of n.lodMeshes)rx(r,e,i);if(n.children)for(let r of n.children)qg(r,e,i)}function ox(n){n.indexArray.destroy(),n.vertexArray.destroy(),n.colorArray&&n.colorArray.destroy(),n.normalArray&&n.normalArray.destroy(),n.texcoordArray&&n.texcoordArray.destroy(),n.featureArray&&n.featureArray.destroy()}function s_(n){if(n.meshes)for(let e of n.meshes)ox(e);if(n.lodMeshes)for(let e of n.lodMeshes)ox(e);if(n.children)for(let e of n.children)s_(e)}function sx(n){var e;n.vertexBuffer&&(n.vertexBuffer.destroy(),n.indexBuffer.destroy(),n.normalBuffer&&n.normalBuffer.destroy(),n.texcoordBuffer&&n.texcoordBuffer.destroy(),n.colorBuffer&&n.colorBuffer.destroy(),n.pbrBuffer&&n.pbrBuffer.destroy(),n.segments.destroy(),n.material&&((e=n.material).pbrMetallicRoughness.baseColorTexture&&e.pbrMetallicRoughness.baseColorTexture.gfxTexture&&e.pbrMetallicRoughness.baseColorTexture.gfxTexture.destroy(),e.pbrMetallicRoughness.metallicRoughnessTexture&&e.pbrMetallicRoughness.metallicRoughnessTexture.gfxTexture&&e.pbrMetallicRoughness.metallicRoughnessTexture.gfxTexture.destroy(),e.normalTexture&&e.normalTexture.gfxTexture&&e.normalTexture.gfxTexture.destroy(),e.emissionTexture&&e.emissionTexture.gfxTexture&&e.emissionTexture.gfxTexture.destroy(),e.occlusionTexture&&e.occlusionTexture.gfxTexture&&e.occlusionTexture.gfxTexture.destroy()))}function Zg(n){if(n.meshes)for(let e of n.meshes)sx(e);if(n.lodMeshes)for(let e of n.lodMeshes)sx(e);if(n.footprintDebugMesh&&(n.footprintDebugMesh.vertexBuffer.destroy(),n.footprintDebugMesh.indexBuffer.destroy(),n.footprintDebugMesh.segments.destroy()),n.children)for(let e of n.children)Zg(e)}function Wg(n,e,i,r){return n[0]<=r[0]&&e[0]>=i[0]&&n[1]<=r[1]&&e[1]>=i[1]&&n[2]<=r[2]&&e[2]>=i[2]}function wb(n,e,i,r,s,l,u,p,f,g,x){let b=.5*(g[0]+x[0]),w=.5*(g[1]+x[1]),S=.5*(g[2]+x[2]),E=.5*(x[0]-g[0]),M=.5*(x[1]-g[1]),C=.5*(x[2]-g[2]),R=n-b,F=e-w,z=i-S,j=r-b,$=s-w,H=l-S,ie=u-b,W=p-w,Q=f-S,Y=j-R,ee=$-F,me=H-z,ge=ie-j,Te=W-$,Ae=Q-H,Ee=R-ie,Be=F-W,xe=z-Q,Se,Me,ze,Le,We,De;if(Se=z*ee-F*me,Me=H*ee-$*me,ze=Q*ee-W*me,Le=Math.min(Se,Me,ze),We=Math.max(Se,Me,ze),De=Math.abs(me)*M+Math.abs(ee)*C,Le>De||We<-De||(Se=z*Te-F*Ae,Me=H*Te-$*Ae,ze=Q*Te-W*Ae,Le=Math.min(Se,Me,ze),We=Math.max(Se,Me,ze),De=Math.abs(Ae)*M+Math.abs(Te)*C,Le>De||We<-De)||(Se=z*Be-F*xe,Me=H*Be-$*xe,ze=Q*Be-W*xe,Le=Math.min(Se,Me,ze),We=Math.max(Se,Me,ze),De=Math.abs(xe)*M+Math.abs(Be)*C,Le>
7De||We<-De)||(Se=R*me-z*Y,Me=j*me-H*Y,ze=ie*me-Q*Y,Le=Math.min(Se,Me,ze),We=Math.max(Se,Me,ze),De=Math.abs(me)*E+Math.abs(Y)*C,Le>De||We<-De)||(Se=R*Ae-z*ge,Me=j*Ae-H*ge,ze=ie*Ae-Q*ge,Le=Math.min(Se,Me,ze),We=Math.max(Se,Me,ze),De=Math.abs(Ae)*E+Math.abs(ge)*C,Le>De||We<-De)||(Se=R*xe-z*Ee,Me=j*xe-H*Ee,ze=ie*xe-Q*Ee,Le=Math.min(Se,Me,ze),We=Math.max(Se,Me,ze),De=Math.abs(xe)*E+Math.abs(Ee)*C,Le>De||We<-De)||(Se=F*Y-R*ee,Me=$*Y-j*ee,ze=W*Y-ie*ee,Le=Math.min(Se,Me,ze),We=Math.max(Se,Me,ze),De=Math.abs(ee)*E+Math.abs(Y)*M,Le>De||We<-De)||(Se=F*ge-R*Te,Me=$*ge-j*Te,ze=W*ge-ie*Te,Le=Math.min(Se,Me,ze),We=Math.max(Se,Me,ze),De=Math.abs(Te)*E+Math.abs(ge)*M,Le>De||We<-De)||(Se=F*Ee-R*Be,Me=$*Ee-j*Be,ze=W*Ee-ie*Be,Le=Math.min(Se,Me,ze),We=Math.max(Se,Me,ze),De=Math.abs(Be)*E+Math.abs(Ee)*M,Le>De||We<-De)||(Le=Math.min(R,j,ie),We=Math.max(R,j,ie),Le>E||We<-E)||(Le=Math.min(F,$,W),We=Math.max(F,$,W),Le>M||We<-M)||(Le=Math.min(z,H,Q),We=Math.max(z,H,Q),Le>C||We<-C))return!1;let Ge=ee*Ae-me*Te,He=me*ge-Y*Ae,Je=Y*Te-ee*ge,tt=-(Ge*R+He*F+Je*z);return De=E*Math.abs(Ge)+M*Math.abs(He)+C*Math.abs(Je),!(Math.abs(tt)>De)}let Tb=[];class ax{serializeFromGltf(e,i,r,s){if(e.length<7)return;let l=0;if(e[l++]!==109||e[l++]!==98||e[l++]!==120||e[l++]!==98||e[l++]!==118||e[l++]!==104||e[l++]!==43)return;let u=new DataView(e.buffer,e.byteOffset),p=u.getUint16(l,!0);if(l+=2,p===0)return;this._nodes=[];let f=0;for(let x=0;x<p;x++){let b=[i[3*f],i[3*f+1],i[3*f+2]],w=[r[3*f],r[3*f+1],r[3*f+2]];f++;let S=u.getUint16(l,!0);l+=2;let E=0,M=0;S===65535&&(E=u.getUint16(l,!0),l+=2,M=u.getUint32(l,!0),l+=4),this._nodes.push({aabbMin:b,aabbMax:w,backChild:S,indexCount:E,indexOffset:M})}let g=u.getUint32(l,!0);this._indices=s.slice(0,g)}setVertices(e){this._vertices=e}findHighestPoint(e,i){if(!this._nodes||this._nodes.length===0||!Wg(this._nodes[0].aabbMin,this._nodes[0].aabbMax,e,i))return null;let r=Tb;r.length=0,r.push(0);let s=-1/0;for(;r.length>0;){let l=r.pop(),u=this._nodes[l];if(u.aabbMax[2]<=s)continue;if(u.backChild===65535){for(let S=0;S<u.indexCount;S+=3){let E=3*this._indices[u.indexOffset+S],M=3*this._indices[u.indexOffset+S+1],C=3*this._indices[u.indexOffset+S+2];wb(this._vertices[E],this._vertices[E+1],this._vertices[E+2],this._vertices[M],this._vertices[M+1],this._vertices[M+2],this._vertices[C],this._vertices[C+1],this._vertices[C+2],e,i)&&(s=Math.max(s,this._vertices[E+2],this._vertices[M+2],this._vertices[C+2]))}continue}let p=l+1,f=u.backChild,g=this._nodes[p],x=this._nodes[f],b=Wg(g.aabbMin,g.aabbMax,e,i),w=Wg(x.aabbMin,x.aabbMax,e,i);b&&w?g.aabbMax[2]<x.aabbMax[2]?(r.push(p),r.push(f)):(r.push(f),r.push(p)):b?r.push(p):w&&r.push(f)}return s>=0?s:null}}function iu(n,e){let i=n.json.bufferViews[e.bufferView],r=e_[e.componentType];return new r(n.buffers[i.buffer],(e.byteOffset||0)+(i.byteOffset||0),e.count*(i.byteStride&&i.byteStride!==Sp[e.type]*r.BYTES_PER_ELEMENT?i.byteStride/r.BYTES_PER_ELEMENT:Sp[e.type]))}function Xg(n,e,i,r){let s=e_[e.componentType],l=function(x){switch(x){case Int8Array:return 1/127;case Uint8Array:return 1/255;case Int16Array:return 1/32767;case Uint16Array:return 1/65535;default:return 1}}(s),u=n.json.bufferViews[e.bufferView],p=u.byteStride?u.byteStride/s.BYTES_PER_ELEMENT:Sp[e.type],f=i.float32,g=f.length/i.capacity;for(let x=0,b=0;x<e.count*p;x+=p,b+=g)for(let w=0;w<g;w++)f[b+w]=r[x+w]*l;i._trim()}function Sb(n,e,i){let r=n.indices,s=n.attributes,l={};l.indexArray=new Xi;let u=e.json.accessors[r],p=u.count/3;l.indexArray.reserve(p);let f=iu(e,u);for(let w=0;w<p;w++)l.indexArray.emplaceBack(f[3*w],f[3*w+1],f[3*w+2]);l.indexArray._trim(),l.vertexArray=new Br;let g=e.json.accessors[s.POSITION];l.vertexArray.reserve(g.count);let x=iu(e,g);for(let w=0;w<g.count;w++)l.vertexArray.emplaceBack(x[3*w],x[3*w+1],x[3*w+2]);if(l.vertexArray._trim(),l.aabb=new Si(g.min,g.max),l.centroid=function(w,S){let E=[0,0,0],M=w.length;if(M>0){for(let C=0;C<M;C++){let R=3*w[C];E[0]+=S[R],E[1]+=S[R+1],E[2]+=S[R+2]}E[0]/=M,E[1]/=M,E[2]/=M}return E}(f,x),s.COLOR_0!==void 0){let w=e.json.accessors[s.COLOR_0],S=Sp[w.type],E=iu(e,w);l.colorArray=S===3?new Br:new Vs,l.colorArray.resize(w.count),Xg
7(e,w,l.colorArray,E)}if(s.NORMAL!==void 0){l.normalArray=new Br;let w=e.json.accessors[s.NORMAL];l.normalArray.resize(w.count);let S=iu(e,w);Xg(e,w,l.normalArray,S)}if(s.TEXCOORD_0!==void 0&&i.length>0){l.texcoordArray=new nr;let w=e.json.accessors[s.TEXCOORD_0];l.texcoordArray.resize(w.count);let S=iu(e,w);Xg(e,w,l.texcoordArray,S)}if(s._FEATURE_ID_RGBA4444!==void 0){let w=e.json.accessors[s._FEATURE_ID_RGBA4444];e.json.extensionsUsed&&e.json.extensionsUsed.includes("EXT_meshopt_compression")&&(l.featureData=iu(e,w))}s._FEATURE_RGBA4444!==void 0&&(l.featureData=new Uint32Array(iu(e,e.json.accessors[s._FEATURE_RGBA4444]).buffer));let b=n.material;return l.material=function(w,S){let{emissiveFactor:E=[0,0,0],alphaMode:M="OPAQUE",alphaCutoff:C=.5,normalTexture:R,occlusionTexture:F,emissiveTexture:z,doubleSided:j,name:$}=w,{baseColorFactor:H=[1,1,1,1],metallicFactor:ie=1,roughnessFactor:W=1,baseColorTexture:Q,metallicRoughnessTexture:Y}=w.pbrMetallicRoughness||{},ee=F?S[F.index]:void 0;if(F&&F.extensions&&F.extensions.KHR_texture_transform&&ee){let me=F.extensions.KHR_texture_transform;ee.offsetScale=[me.offset[0],me.offset[1],me.scale[0],me.scale[1]]}return{name:$,pbrMetallicRoughness:{baseColorFactor:new jt(...H),metallicFactor:ie,roughnessFactor:W,baseColorTexture:Q?S[Q.index]:void 0,metallicRoughnessTexture:Y?S[Y.index]:void 0},doubleSided:j,emissiveFactor:new jt(...E),alphaMode:M,alphaCutoff:C,normalTexture:R?S[R.index]:void 0,occlusionTexture:ee,emissionTexture:z?S[z.index]:void 0,defined:w.defined===void 0}}(b!==void 0?e.json.materials[b]:{defined:!1},i),l}function Yg(n,e,i){let{matrix:r,rotation:s,translation:l,scale:u,mesh:p,extras:f,children:g,name:x}=n,b={};if(b.name=x,b.localMatrix=r||function(w,S,E,M){var C=S[0],R=S[1],F=S[2],z=S[3],j=C+C,$=R+R,H=F+F,ie=C*j,W=C*$,Q=C*H,Y=R*$,ee=R*H,me=F*H,ge=z*j,Te=z*$,Ae=z*H,Ee=M[0],Be=M[1],xe=M[2];return w[0]=(1-(Y+me))*Ee,w[1]=(W+Ae)*Ee,w[2]=(Q-Te)*Ee,w[3]=0,w[4]=(W-Ae)*Be,w[5]=(1-(ie+me))*Be,w[6]=(ee+ge)*Be,w[7]=0,w[8]=(Q+Te)*xe,w[9]=(ee-ge)*xe,w[10]=(1-(ie+Y))*xe,w[11]=0,w[12]=E[0],w[13]=E[1],w[14]=E[2],w[15]=1,w}([],s||[0,0,0,1],l||[0,0,0],u||[1,1,1]),b.globalMatrix=Kl(b.localMatrix),p!==void 0){b.meshes=i[p];let w=b.anchor=[0,0];for(let S of b.meshes){let{min:E,max:M}=S.aabb;w[0]+=E[0]+M[0],w[1]+=E[1]+M[1]}w[0]=Math.floor(w[0]/b.meshes.length/2),w[1]=Math.floor(w[1]/b.meshes.length/2)}if(f&&(f.id&&(b.id=f.id),f.lights&&(b.lights=function(w){if(!w.length)return[];let S=function(F){let z=atob(F),j=new Uint8Array(z.length);for(let $=0;$<z.length;$++)j[$]=z.codePointAt($);return j}(w),E=[],M=S.length/24,C=new Uint16Array(S.buffer),R=new Float32Array(S.buffer);for(let F=0;F<M;F++){let z=C[2*F*6]/30,j=C[2*F*6+1]/30,$=C[2*F*6+10]/100,H=R[6*F+1],ie=R[6*F+2],W=R[6*F+3],Q=R[6*F+4],Y=W-H,ee=Q-ie,me=Math.hypot(Y,ee);E.push({pos:[H+.5*Y,ie+.5*ee,j],normal:[ee/me,-Y/me,0],width:me,height:z,depth:$,points:[H,ie,W,Q]})}return E}(f.lights)),f.MAPBOX_geometry_bloom&&(b.isGeometryBloom=f.MAPBOX_geometry_bloom)),g){let w=[];for(let S of g)w.push(Yg(e.json.nodes[S],e,i));b.children=w}if(n.extensions&&n.extensions.mbx_bvh&&(b.meshBVH=function(w,S,E){let M=S.binaryAccessor,C=S.positionMinAccessor,R=S.positionMaxAccessor,F=S.indexAccessor;if(!(Number.isInteger(M)&&Number.isInteger(C)&&Number.isInteger(R)&&Number.isInteger(F)))return null;let z=w.json.accessors;if(M>=z.length||C>=z.length||R>=z.length||F>=z.length)return null;let j=z[M],$=z[C],H=z[R],ie=z[F];if(j.bufferView===void 0||$.bufferView===void 0||H.bufferView===void 0||ie.bufferView===void 0)return null;let W=w.json.bufferViews;if(j.bufferView>=W.length||$.bufferView>=W.length||H.bufferView>=W.length||ie.bufferView>=W.length)return null;let Q=W[j.bufferView],Y=W[$.bufferView],ee=W[H.bufferView],me=W[ie.bufferView];if(Q.buffer>=w.buffers.length||Y.buffer>=w.buffers.length||ee.buffer>=w.buffers.length||me.buffer>=w.buffers.length)return null;let ge=(We,De,Ge)=>We>=0&&We<=Ge&&De<=Ge-We,Te=j.byteOffset||0,Ae=$.byteOffset||0,Ee=H.byteOffset||0,Be=ie.byteOffset||0;if(!(ge(Te,0,Q.byteLength)&&ge(Ae,3*$.count*4,Y.byteLength)&&ge(Ee,3*H.count*4,ee.byteLength)&&ge(Be,4*ie.count,me.byteLength)))return null;let xe=new Uint8Array(w.buffers[Q.buffer],(Q.byteOffset||0)+Te,Q.byteLength-Te),Se=new Float32Array(w.buffers[Y.buffer],(Y.byteOffset||0)+Ae,3*$.count),Me=new Float32Array(w.buffers[ee.buffer],(ee.byteOffset||0)+Ee,3*H.count),ze=new Uint32Array(w.buffers[me.buffer],(me.byteOffset||0)+Be,ie.count),Le=new ax;if(Le.serializeFromGltf(xe,Se,Me,ze),E!==void 0&&w.json.meshes&&w.json.meshes[E]){let We=w.json.meshes[E].primitives[0];if(We&&We.attributes.POSITION!==void 0&&We.attributes.POSITION<z.length){let De=z[We.attributes.POSITION];if(De.bufferView!==void 0&&De.bufferView<W.length){let Ge=W[De.bufferView];if(Ge.buffer<w.buffers.length){let He=De.byteOffset||0,Je=Ge.byteStride?Ge.byteStride/4:3;if(ge(He,De.count*Je*4,Ge.byteLength)){let tt=(Ge.byteOffset||0)+He;if(Je===3)Le.setVertices(new Float32Array(w.buffers[Ge.buffer],tt,3*De.count));else{let lt=new Float32Array(w.buffers[Ge.buffer],tt,De.count*Je),rt=new Float32Array(3*De.count);for(let pt=0;pt<De.count;pt++)rt[3*pt]=lt[pt*Je],rt[3*pt+1]=lt[pt*Je+1],rt[3*pt+2]=lt[pt*Je+2];Le.setVertices(rt)}}}}}}return Le}(e,n.extensions.mbx_bvh,p)),!b.meshBVH&&b.children){for(let w of b.children)if(w.meshBVH){b.meshBVH=w.meshBVH;break}}return b}function Ib(n){if(n.vertices.length===0||n.indices.length===0)return null;let e=new Um(n.vertices,n.indices,8,256),[i,r]=[e.min.clone(),e.max.clone()];return{vertices:n.vertices,indices:n.indices,grid:e,min:i,max:r}}function Eb(n){if(!n.extras||!n.extras.ground)return null;let e=n.extras.ground;if(!e||!Array.isArray(e)||e.length===0)return null;let i=e[0];if(!i||!Array.isArray(i)||i.length===0)return null;let r=[];for(let u of i){if(!Array.isArray(u)||u.length!==2)continue;let p=u[0],f=u[1];typeof p=="number"&&typeof f=="number"&&r.push(new ke(p,f))}if(r.length<3)return null;r.length>1&&r.at(-1).equals(r[0])&&r.pop();let s=0;for(let u=0;u<r.length;u++){let p=r[u],f=r[(u+1)%r.length],g=r[(u+2)%r.length];s+=(p.x-f.x)*(g.y-f.y)-(g.x-f.x)*(p.y-f.y)}s>0&&r.reverse();let l=wn(r.flatMap(u=>[u.x,u.y]),[]);return l.length===0?null:{vertices:r,indices:l}}function Ab(n,e){let i=[],r=[],s=0,l=[];for(let u of n){s=i.length;let p=u.vertexArray.float32,f=u.indexArray.uint16;for(let g=0;g<u.vertexArray.length;g++)l[0]=p[3*g+0],l[1]=p[3*g+1],l[2]=p[3*g+2],Oi(l,l,e),i.push(new ke(l[0],l[1]));for(let g=0;g<3*u.indexArray.length;g++)r.push(f[g]+s)}if(r.length%3!=0)return null;for(let u=0;u<r.length;u+=3){let p=i[r[u+0]],f=i[r[u+1]],g=i[r[u+2]];(p.x-f.x)*(g.y-f.y)-(g.x-f.x)*(p.y-f.y)>0&&([r[u+1],r[u+2]]=[r[u+2],r[u+1]])}return{vertices:i,indices:r}}function lx(n,e){for(let i=0;i<n.length;i++)if(n[i].name===e)return i;return-1}function Jg(n){let e=function(x,b){let w=[],S=WebGL2RenderingContext;if(x.json.textures)for(let E of x.json.textures){let M={magFilter:S.LINEAR,minFilter:S.NEAREST,wrapS:S.REPEAT,wrapT:S.REPEAT};E.sampler!==void 0&&Object.assign(M,x.json.samplers[E.sampler]),w.push({image:b[E.source],sampler:M,uploaded:!1})}return w}(n,n.images),i=function(x,b){let w=[];for(let S of x.json.meshes){let E=[];for(let M of S.primitives)E.push(Sb(M,x,b));w.push(E)}return w}(n,e),{scenes:r,scene:s,nodes:l}=n.json,u=r?lx(r,"Default Scene"):-1;u<0&&(u=s||0);let p=r?r[u].nodes:[...l.keys()],f=[];for(let x of p)f.push(Yg(l[x],n,i));(function(x,b,w){let S={},E=new Set;for(let M=0;M<x.length;M++){let C=w[b[M]];if(!C.extras)continue;let R=C.extras["mapbox:footprint:version"],F=C.extras["mapbox:footprint:id"];(R||F)&&E.add(M),R==="1.0.0"&&F&&(S[F]=M)}for(let M=0;M<x.length;M++){if(E.has(M))continue;let C=x[M],R=w[b[M]];if(!R.extras)continue;let F=null;C.id in S&&(F=Ab(x[S[C.id]].meshes,C.localMatrix)),F||(F=Eb(R)),F&&(C.footprint=Ib(F))}if(E.size>0){let M=Array.from(E.values()).sort((C,R)=>C-R);for(let C=M.length-1;C>=0;C--)x.splice(M[C],1)}})(f,p,n.json.nodes);let g=r?lx(r,"LOD"):-1;if(g>=0){let x=r[g].nodes,b=new Map;for(let w of x){let S=Yg(l[w],n,i);S.id&&b.set(S.id,S)}for(let w of f)if(w.id){let S=b.get(w.id);
7S&&S.meshes&&(w.lodMeshes=S.meshes,S.meshBVH&&(w.meshBVH=S.meshBVH))}}return f}function Mb(n){n.heightmap=new Float32Array(4096),n.heightmap.fill(-1);let e=n.vertexArray.float32,i=n.aabb.min[0]-1,r=n.aabb.min[1]-1,s=tu/(n.aabb.max[0]-i+2),l=tu/(n.aabb.max[1]-r+2);for(let u=0;u<e.length;u+=3){let p=e[u+2],f=(e[u+0]-i)*s|0,g=(e[u+1]-r)*l|0;p>n.heightmap[g*tu+f]&&(n.heightmap[g*tu+f]=p)}}function cx(n,e,i,r,s){i.reserve(i.length+4*n.length),r.reserve(r.length+10*n.length),s.reserve(s.length+10*n.length);let l=r.length;for(let u of n){let p=Math.min(10,Math.max(4,1.3*u.height))*e,f=[-u.normal[1],u.normal[0],0],g=Math.min(.29,.1*u.width/u.depth),x=u.width-2*u.depth*e*(g+.01),b=Dr([],u.pos,f,x/2),w=Dr([],u.pos,f,-x/2),S=[b[0],b[1],b[2]+u.height],E=[w[0],w[1],w[2]+u.height],M=Dr([],u.normal,f,g);Li(M,M,p);let C=Dr([],u.normal,f,-g);Li(C,C,p),tn(M,b,M),tn(C,w,C),b[2]+=.1,w[2]+=.1,r.emplaceBack(M[0],M[1],M[2]),r.emplaceBack(C[0],C[1],C[2]),r.emplaceBack(b[0],b[1],b[2]),r.emplaceBack(w[0],w[1],w[2]),r.emplaceBack(S[0],S[1],S[2]),r.emplaceBack(E[0],E[1],E[2]),r.emplaceBack(b[0],b[1],b[2]),r.emplaceBack(w[0],w[1],w[2]),r.emplaceBack(M[0],M[1],M[2]),r.emplaceBack(C[0],C[1],C[2]);let R=x/p/2;s.emplaceBack(-R-g,-1,R,.8),s.emplaceBack(R+g,-1,R,.8),s.emplaceBack(-R,0,R,1.3),s.emplaceBack(R,0,R,1.3),s.emplaceBack(R+g,-.8,R,.7),s.emplaceBack(R+g,-.8,R,.7),s.emplaceBack(0,0,R,1.3),s.emplaceBack(0,0,R,1.3),s.emplaceBack(R+g,-1.2,R,.8),s.emplaceBack(R+g,-1.2,R,.8),i.emplaceBack(6+l,4+l,8+l),i.emplaceBack(7+l,9+l,5+l),i.emplaceBack(0+l,1+l,2+l),i.emplaceBack(1+l,3+l,2+l),l+=10}}function Cb(n,e){let i={};i.indexArray=new Xi,i.vertexArray=new Br,i.colorArray=new Vs,cx(n,e,i.indexArray,i.vertexArray,i.colorArray);let r={defined:!0};r.emissiveFactor=jt.black;let s={};return s.baseColorFactor=jt.white,r.pbrMetallicRoughness=s,i.material=r,i.aabb=new Si([1/0,1/0,1/0],[-1/0,-1/0,-1/0]),i}Qe(ax,"ModelBVH");let ux=Ct([{name:"a_pos_3f",components:3,type:"Float32"}]),Pb=Ct([{name:"a_normal_3",components:3,type:"Int16"}]),Db=Ct([{name:"a_centroid_3",components:3,type:"Int16"}]),hx=Ct([{name:"a_part_color_emissive",components:2,type:"Uint16"}]),Rb=Ct([{name:"a_faux_facade_color_emissive",components:2,type:"Uint16"}]),zb=Ct([{name:"a_faux_facade_data",components:4,type:"Uint16"}]),Lb=Ct([{name:"a_faux_facade_vertical_range",components:2,type:"Uint16"}]),Ob=Ct([{name:"a_bloom_attenuation",components:4,type:"Float32"}]),Fb=Ct([{name:"a_flood_light_wall_radius_1i16",components:1,type:"Int16"}]),Kg=4096;class Bb{constructor(e){this.module=e,this.memoryStack=this.module.malloc(Kg),this.memoryStackNextFree=this.memoryStack}createIntArray(e){let i=this.memoryStackNextFree;return this.memoryStackNextFree+=e.length*Int32Array.BYTES_PER_ELEMENT,this.memoryStackNextFree-this.memoryStack>Kg?-1:(new Int32Array(this.module.heap32.buffer,i,e.length).set(e),i)}createFloatArray(e){let i=this.memoryStackNextFree;return this.memoryStackNextFree+=e.length*Float32Array.BYTES_PER_ELEMENT,this.memoryStackNextFree-this.memoryStack>Kg?-1:(new Float32Array(this.module.heapF32.buffer,i,e.length).set(e),i)}readStringBuffer(e){let i="";for(;this.module.heapU8[e]!==0;)i+=String.fromCharCode(this.module.heapU8[e]),++e;return i}setStyle(e){let i=e.normalScale;this.module.setStyle(i[0],i[1],i[2],e.tileToMeters)}setAOOptions(e,i){this.module.setAOOptions(e?1:0,i)}setMetricOptions(e,i){this.module.setMetricOptions(e?1:0,i)}setStructuralOptions(e){this.module.setStructuralOptions(e?1:0)}setFacadeOptions(e,i){this.module.setFacadeOptions(e,i?1:0)}setFauxFacadeOptions(e,i,r){this.module.setFauxFacadeOptions(e?1:0,i?1:0,r)}setFacadeClassifierOptions(e){this.module.setFacadeClassifierOptions(e)}generateMesh(e,i){this.memoryStackNextFree=this.memoryStack;for(let p of e){let f=this.createIntArray(p.ringIndices),g=this.createFloatArray(p.coordinates);if(f===-1||g===-1)return`building_gen: Out of stack memory: ${this.memoryStackNextFree-this.memoryStack}/4096`;this.module.addFeature(p.id,p.sourceId,p.minHeight,p.height,p.roofType,g,f,p.ringIndices.length-1)}for(let p of i){let f;f=p.entrances?JSON.parse(p.entrances):[];let g=this.createFloatArray(f),x=this.createFloatArray(p.coordinates);if(g===-1||x===-1)return`building_gen: Out of stack memory: ${this.memoryStackNextFree-this.memoryStack}/4096`;this.module.addFacade(p.sourceId,p.crossPerc,p.distanceToRoad,g,f.length,x,p.coordinates.length)}if(!this.module.generateMesh()){let p=this.module.getLastError();return this.readStringBuffer(p)}
7let r=this.module.getMeshCount(),s=new Array(r);for(let p=0;p<r;p++){let f=this.module.getPositionsPtr(p),g=this.module.getPositionsLength(p),x=new Float32Array(this.module.heapF32.buffer,f,g),b=this.module.getNormalsPtr(p),w=this.module.getNormalsLength(p),S=new Float32Array(this.module.heapF32.buffer,b,w),E=this.module.getAOPtr(p),M=this.module.getAOLength(p),C=new Float32Array(this.module.heapF32.buffer,E,M),R=this.module.getUVPtr(p),F=this.module.getUVLength(p),z=new Float32Array(this.module.heapF32.buffer,R,F),j=this.module.getFauxFacadePtr(p),$=this.module.getFauxFacadeLength(p),H=new Uint8Array(this.module.heapU8.buffer,j,$),ie=this.module.getIndicesPtr(p),W=this.module.getIndicesLength(p),Q=new Int16Array(this.module.heap16.buffer,ie,W),Y=this.module.getBuildingPart(p);s[p]={positions:x,normals:S,ao:C,uv:z,isFauxFacade:H,indices:Q,buildingPart:Y}}let l=this.module.getRingCount(),u=[];for(let p=0;p<l;p++){let f=this.module.getRingPtr(p),g=this.module.getRingLength(p),x=new Float32Array(this.module.heapF32.buffer,f,g);u.push(x)}return{meshes:s,outerRingLength:this.module.getOuterRingLength(),modifiedPolygonRings:u}}}let dx=$s.types,a_=32767;function kb(n,e){let i=Xe+e;for(let r of n)for(let s of r)if(s.x<-e||s.x>i||s.y<-e||s.y>i)return!1;return!0}function Nb(n){switch(n){case"flat":return 3;case"hipped":return 1;case"gabled":return 2;case"parapet":return 0;case"mansard":return 4;case"skillion":return 5;case"pyramidal":return 6;default:throw new Error(`Unknown roof shape: ${n}`)}}let bh=null,px=null,So=null;class Qg{constructor(){this.layoutVertexArray=new Br,this.layoutAttenuationArray=new Vs,this.layoutColorArray=new kr,this.indexArray=new Xi,this.indexArrayForConflation=new Xi,this.segmentsBucket=new pi}}class ey{constructor(e){this.layoutFacadePaintArray=null,this.layoutFacadeDataArray=null,this.layoutFacadeVerticalRangeArray=null,this.segmentsBucket=new pi,this.entranceBloom=new Qg;let i=66560;this.layoutVertexArray=new Br,this.layoutVertexArray.reserve(i),this.layoutNormalArray=new Ns,this.layoutNormalArray.reserve(i),this.layoutCentroidArray=new Ns,this.layoutCentroidArray.reserve(i),this.layoutColorArray=new kr,this.layoutColorArray.reserve(i),this.layoutFloodLightDataArray=new Rl,this.layoutFloodLightDataArray.reserve(i),this.layoutAOArray=new zl,this.layoutAOArray.reserve(i),this.indexArray=new Xi,this.indexArray.reserve(66560),this.indexArrayForConflation=new Xi,this.segmentsBucket=new pi,this.entranceBloom=new Qg,e&&(this.layoutFacadePaintArray=new kr,this.layoutFacadeDataArray=new Al,this.layoutFacadeVerticalRangeArray=new kr)}reserve(e,i,r){this.layoutVertexArray.reserveForAdditional(e),this.layoutCentroidArray.reserveForAdditional(e),this.layoutFloodLightDataArray.reserveForAdditional(e),this.layoutNormalArray.reserveForAdditional(e),this.layoutAOArray.reserveForAdditional(e),this.layoutColorArray.reserveForAdditional(e),this.indexArray.reserveForAdditional(i),r&&(this.layoutFacadePaintArray.reserveForAdditional(e),this.layoutFacadeDataArray.reserveForAdditional(e),this.layoutFacadeVerticalRangeArray.reserveForAdditional(e))}}class fx{constructor(e){this.colorBufferUploaded=!1,this.maxHeight=0,this.replacementUpdateTime=0,this.activeReplacements=[],this.footprints=[],this.footprintsVertices=new nr,this.footprintsIndices=new Cl,this.footprintsMin=new ke(1/0,1/0),this.footprintsMax=new ke(-1/0,-1/0),this.featuresOnBorder=[],this.buildingWithoutFacade=new ey(!1),this.buildingWithFacade=new ey(!0),this.indexArrayForConflationUploaded=!1,this.featureFootprintLookup=new Map,this.buildingIds=new Set,this.footprintLookup={},this.zoom=e.zoom,this.canonical=e.canonical,this.layers=e.layers,this.layerIds=this.layers.map(i=>i.fqid),this.index=e.index,this.hasPattern=!1,this.worldview=e.worldview,this.lut=e.lut,this.programConfigurations=new bo(e.layers,{zoom:e.zoom,lut:e.lut}),this.stateDependentLayerIds=this.layers.filter(i=>i.isStateDependent()).map(i=>i.id),this.projection=e.projection,this.groundEffect=new kg(e),this.groundEffect.groundRadiusArray=new Do,this.hasAppearances=null}updateFootprints(e,i){let r=new Um([],[],1),s={vertices:[],indices:new Uint32Array(0),grid:r,min:this.footprintsMin,max:this.footprintsMax,buildingIds:this.buildingIds};i.push({footprint:s,id:e})}updateAppearances(e,i,r,s){return{hasLayoutChanges:!1,hasUboChanges:!1}}
7populate(e,i,r,s){if(!So)return;let l=Vr(r);this.tileToMeter=l,this.brightness=i.brightness,So.setStyle({normalScale:[1,-1,l],tileToMeters:l}),So.setAOOptions(!1,.3),So.setMetricOptions(!1,16),So.setStructuralOptions(!0),So.setFacadeClassifierOptions(3);let u=new Map,p=new Map,f=0;for(let{feature:C}of e){if(dx[C.type]!=="LineString"){u.set(C.id,C.properties.source_id);continue}let R=this.layers[0]._featureFilter.needGeometry;if(R&&!this.layers[0]._featureFilter.filter(new Xt(this.zoom),C,r))continue;let F=Gr(C,R);if(!R&&!this.layers[0]._featureFilter.filter(new Xt(this.zoom),F,r))continue;let z=R?F.geometry:jr(C,r,s),j=[];for(let W of z)for(let Q of W)j.push(Q.x),j.push(Q.y);let $={coordinates:j,crossPerc:C.properties.cross_perc,distanceToRoad:C.properties.distance_to_road,entrances:C.properties.entrances,sourceId:0},H=C.properties.source_id,ie=p.get(H);ie||(ie=[],p.set(H,ie)),ie.push($),++f}this.maxHeight=0;let g=new Array,x=new Set,b=C=>{C!=null&&x.add(C)},w=(C,R)=>{C!=null&&g.push({buildingId:C,footprintIndex:R})},S=64*(e.length-f),E=S/2;this.buildingWithFacade.reserve(S,E,!0),this.buildingWithoutFacade.reserve(2*S,2*E,!1),this.footprintsIndices.reserve(16*(e.length-f)),this.footprintsVertices.reserve(8*(e.length-f));for(let{feature:C,id:R,index:F,sourceLayerIndex:z}of e){if(dx[C.type]==="LineString")continue;let j=this.layers[0]._featureFilter.needGeometry;if(j&&!this.layers[0]._featureFilter.filter(new Xt(this.zoom),C,r))continue;let $=null;if(C.properties&&Object.hasOwn(C.properties,"building_id")&&($=Number(C.properties.building_id),x.has($)))continue;let H=Gr(C,j);if(!j&&!this.layers[0]._featureFilter.filter(new Xt(this.zoom),H,r))continue;let ie=j?H.geometry:jr(C,r,s),W=_p(ie,500),Q=!1;for(let Dt of W)if(Dt.length!==1){Q=!0;break}if(Q){b($);continue}if(!kb(ie,163)){b($);continue}let Y=this.layers[0],ee=Nb(Y.layout.get("building-roof-shape").evaluate(C,{},r)),me=Y.layout.get("building-base").evaluate(C,{},r),ge=Y.layout.get("building-height").evaluate(C,{},r),Te=Y.layout.get("building-flood-light-ground-radius").evaluate(C,{},r),Ae=Y.paint.get("building-ambient-occlusion-intensity"),Ee=Te/this.tileToMeter;C.properties["building-part"]="roof";let Be=Y.paint.get("building-color").evaluate(C,{},this.canonical).toPremultipliedRenderColor(this.lut),xe=Y.paint.get("building-emissive-strength").evaluate(C,{},this.canonical);C.properties["building-part"]="wall";let Se=Y.paint.get("building-color").evaluate(C,{},this.canonical).toPremultipliedRenderColor(this.lut),Me=Y.paint.get("building-emissive-strength").evaluate(C,{},this.canonical);C.properties["building-part"]="window";let ze=Y.paint.get("building-color").evaluate(C,{},this.canonical).toPremultipliedRenderColor(this.lut),Le=Y.paint.get("building-emissive-strength").evaluate(C,{},this.canonical);C.properties["building-part"]="door";let We=Y.paint.get("building-color").evaluate(C,{},this.canonical).toPremultipliedRenderColor(this.lut),De=Y.paint.get("building-emissive-strength").evaluate(C,{},this.canonical),Ge=Y.layout.get("building-flood-light-wall-radius").evaluate(C,{},r);Ge=ne(Ge,0,2048);let He=Ge/2048*a_,Je=u.get(R),tt=p.get(Je)||[],lt=tt.length!==0&&Y.layout.get("building-facade").evaluate(C,{},r);So.setFacadeOptions(4,!0),So.setFauxFacadeOptions(lt,!1,1);let rt=0,pt=0,Ht=0,wt=0,kt=0,At=0,Ui=0,Jt=0,Gt=0,ui=0,Mi=0;if(lt){let Dt=Math.round(Y.layout.get("building-facade-floors").evaluate(C,{},r));if(me===0){Dt=Math.max(1,Dt-(tt.length>0?1:0));let ji=4;if(ge>100){let gn=[10,13,15];ji=gn[C.id?C.id%gn.length:0]}else ge<=10&&(ji=3);So.setFacadeOptions(ji,!0),kt=(ge<15?1.3:1.61803)*ji/l}else kt=me/l;At=ge/l,kt=Math.min(kt,At),Ht=Y.layout.get("building-facade-unit-width").evaluate(C,{},r)/l,wt=(At-kt)/Dt,So.setFauxFacadeOptions(!0,!0,Ht);let Pn=Y.layout.get("building-facade-window").evaluate(C,{},r);rt=Pn[0],pt=Pn[1],Ui=Math.floor(65535*Math.min(1,kt/Xe)),Jt=Math.floor(65535*Math.min(1,At/Xe)),Gt=Math.floor(255*rt)<<8|Math.floor(255*pt),ui=Math.floor(65535*Math.min(1,Ht/Xe)),Mi=Math.floor(65535*Math.min(1,wt/Xe))}let Sn=Array(W.length),mi={x:1/0,y:1/0},Vi={x:-1/0,y:-1/0},un={x:0,y:0},en=0;for(let Dt=0;Dt<W.length;Dt++){let Pn=W[Dt];if(Pn.length>0){let ji=[],gn=Array(Pn.length+1);gn[0]=0;for(let Ao=0;Ao<Pn.length;Ao++){let Wr=Pn[Ao];for(let ao=0;ao<Wr.length;ao++){let Xr=Wr[Wr.length-ao-1];mi.x=Math.min(mi.x,Xr.x),mi.y=Math.min(mi.y,Xr.y),Vi.x=Math.max(Vi.x,Xr.x),Vi.y=Math.max(Vi.y,Xr.y),un.x+=Xr.x,un.y+=Xr.y,en++,ji.push(Xr.x),ji.push(Xr.y)}gn[Ao+1]=ji.length}Sn[Dt]={id:C.id?C.id:0,height:ge,minHeight:me,sourceId:0,roofType:ee,coordinates:ji,ringIndices:gn}}}un.x/=en||1,un.y/=en||1;let hn=So.generateMesh(Sn,tt);if(typeof hn=="string"){Ot(`Unable to generate building ${C.id}: ${hn}`),b($);continue}if(hn.meshes.length===0||hn.modifiedPolygonRings.length===0){b($);continue}let Pt=lt?this.buildingWithFacade:this.buildingWithoutFacade,Un=0;for(let Dt of hn.meshes)Un+=Dt.positions.length/3;let lr=Pt.segmentsBucket.prepareSegment(Un,Pt.layoutVertexArray,Pt.indexArray),Ki=[],Cn=null,Qn=0,Vn=-1,zi=Pt.layoutVertexArray.length,_n=zi+Un;Pt.layoutVertexArray.resize(_n),Pt.layoutCentroidArray.resize(_n),Pt.layoutNormalArray.resize(_n),Pt.layoutAOArray.resize(_n),Pt.layoutColorArray.resize(_n),Pt.layoutFloodLightDataArray.resize(_n),lt&&(Pt.layoutFacadePaintArray.resize(_n),Pt.layoutFacadeDataArray.resize(_n),Pt.layoutFacadeVerticalRangeArray.resize(_n));let Mr=Pt.indexArray.length,Dh=0,pr=zi;for(let Dt of hn.meshes){let Pn,ji;if(Dt.buildingPart===1)Pn=Be,ji=xe;else if(Dt.buildingPart===0)Pn=Se,ji=Me;else if(Dt.buildingPart===2)Pn=ze,ji=Le;else{if(Dt.buildingPart!==3)continue;Pn=We,ji=De}if(ji=ne(ji,0,1),Dt.buildingPart===3){let dn=new Array;for(let fr=0;fr<Dt.positions.length;fr+=12){let jn=Dt.positions[fr+0],er=Dt.positions[fr+1],co=Dt.positions[fr+3],Qs=Dt.positions[fr+4],z_=Dt.positions[fr+2],Uy=Dt.positions[fr+8]-z_,Vy=1,Lh=co-jn,ps=Qs-er,Xp=Math.hypot(Lh,ps);dn.push({pos:[jn+.5*Lh,er+.5*ps,z_],normal:[ps/Xp,-Lh/Xp,0],width:Xp,height:Uy,depth:Vy,points:[jn,er,co,Qs]})}let On=Pt.entranceBloom.segmentsBucket.prepareSegment(10*dn.length,Pt.entranceBloom.layoutVertexArray,Pt.entranceBloom.indexArray),qi=Pt.entranceBloom.layoutVertexArray.length;Qn=Pt.entranceBloom.indexArray.length,cx(dn,.5/this.tileToMeter,Pt.entranceBloom.indexArray,Pt.entranceBloom.layoutVertexArray,Pt.entranceBloom.layoutAttenuationArray);let lo=Pt.entranceBloom.layoutVertexArray.length-qi;Vn=Pt.entranceBloom.indexArray.length-Qn;for(let fr=0;fr<lo;fr++)Pt.entranceBloom.layoutColorArray.emplaceBack(255*We.r<<8|255*We.g,255*We.b<<8|51*De);On.vertexLength+=lo,On.primitiveLength+=Vn,Cn={part:Dt.buildingPart,vertexOffset:qi,vertexLength:lo}}Pt.layoutVertexArray.float32.set(Dt.positions,3*pr);let gn=Dt.positions.length/3;for(let dn=0;dn<gn;++dn){let On=3*dn;Dh=Math.max(Dh,Dt.positions[On+2]);
7let qi=Dt.normals[On+1]*a_,lo=Dt.normals[On+2]*a_,fr=3*(pr+dn);Pt.layoutNormalArray.int16[fr]=Dt.normals[On]*a_,Pt.layoutNormalArray.int16[fr+1]=qi,Pt.layoutNormalArray.int16[fr+2]=lo;let jn=Dt.ao[dn];Pt.layoutAOArray.uint8[pr+dn]=255*jn;let er=1+(jn-1)*Ae,co=255*Pn.b*er<<8|255*ji;Pt.layoutColorArray.uint16[2*(pr+dn)]=255*Pn.r*er<<8|255*Pn.g*er,Pt.layoutColorArray.uint16[2*(pr+dn)+1]=co}let Ao=Math.min(8191,Math.max(0,Math.floor(un.x))),Wr=Math.min(8191,Math.max(0,Math.floor(un.y))),ao=Math.floor(ge),Xr=20,Wp=4*Ao+Math.min(3,Math.round((Vi.x-mi.x)*this.tileToMeter/Xr)),Uo=4*Wr+Math.min(3,Math.round((Vi.y-mi.y)*this.tileToMeter/Xr));for(let dn=0;dn<gn;++dn){let On=3*(pr+dn);Pt.layoutCentroidArray.int16[On]=Wp,Pt.layoutCentroidArray.int16[On+1]=Uo,Pt.layoutCentroidArray.int16[On+2]=ao}if(Pt.layoutFloodLightDataArray.int16.fill(Dt.buildingPart===0?He:0,pr,pr+gn),lt){let dn=255*ze.r<<8|255*ze.g,On=255*ze.b<<8|255*Le;for(let qi=0;qi<gn;++qi){let lo=2*(pr+qi);Pt.layoutFacadePaintArray.uint16[lo]=dn,Pt.layoutFacadePaintArray.uint16[lo+1]=On}for(let qi=0;qi<gn;++qi)if(Dt.isFauxFacade[qi]){let lo=Math.min(65535,Math.floor(Dt.uv[2*qi]*hn.outerRingLength));Pt.layoutFacadeDataArray.emplace(pr+qi,1|lo,Gt,ui,Mi),Pt.layoutFacadeVerticalRangeArray.emplace(pr+qi,Ui,Jt)}else Pt.layoutFacadeDataArray.emplace(pr+qi,0,0,0,0),Pt.layoutFacadeVerticalRangeArray.emplace(pr+qi,0,0)}let Rh=lr.vertexLength,Ks=Dt.indices.length/3,zh=Pt.indexArray.length;Pt.indexArray.resize(zh+Ks);for(let dn=0;dn<Ks;++dn){let On=3*dn,qi=3*zh+On;Pt.indexArray.uint16[qi]=Rh+Dt.indices[On],Pt.indexArray.uint16[qi+1]=Rh+Dt.indices[On+1],Pt.indexArray.uint16[qi+2]=Rh+Dt.indices[On+2]}Dt.buildingPart!==1&&Dt.buildingPart!==0&&Dt.buildingPart!==2&&Dt.buildingPart!==3||Ki.push({part:Dt.buildingPart,vertexOffset:pr,vertexLength:Dt.positions.length/3}),pr+=gn,lr.vertexLength+=gn,lr.primitiveLength+=Dt.indices.length/3}this.maxHeight=Math.max(this.maxHeight,Dh);let Ny=Pt.indexArray.length-Mr,qp=this.footprintsIndices.length,Zp=this.footprintsVertices.length,qa=[],so=new ke(1/0,1/0),Eo=new ke(-1/0,-1/0),Xl=this.groundEffect.vertexArray.length;for(let Dt of hn.modifiedPolygonRings){let Pn=[],ji=new ke(1/0,1/0),gn=new ke(-1/0,-1/0);for(let Ao=0;Ao<Dt.length;Ao+=2){let Wr=Dt.length-Ao-2;ji.x=Math.min(ji.x,Dt[Wr]),ji.y=Math.min(ji.y,Dt[Wr+1]),gn.x=Math.max(gn.x,Dt[Wr]),gn.y=Math.max(gn.y,Dt[Wr+1]);let ao=new ke(Dt[Wr],Dt[Wr+1]);Pn.push(ao),qa.push(ao.x,ao.y),this.footprintsVertices.emplaceBack(ao.x,ao.y)}so.x=Math.min(so.x,ji.x),so.y=Math.min(so.y,ji.y),Eo.x=Math.max(Eo.x,gn.x),Eo.y=Math.max(Eo.y,gn.y),this.groundEffect.addData(Pn,[ji,gn],Ee)}let Yl=this.groundEffect.vertexArray.length-Xl;this.groundEffect.groundRadiusArray.reserveForAdditional(Yl);for(let Dt=0;Dt<Yl;Dt++)this.groundEffect.groundRadiusArray.emplaceBack(Te);(mi.x<0||Vi.x>Xe||mi.y<0||Vi.y>Xe)&&this.featuresOnBorder.push({featureId:C.id,footprintIndex:this.footprints.length});{let Dt=wn(qa,null,2);this.footprintsIndices.resize(this.footprintsIndices.length+Dt.length),this.footprintsIndices.uint16.set(Dt,qp),this.buildingIds.add($??C.id),this.footprintsMin.x=Math.min(this.footprintsMin.x,so.x),this.footprintsMin.y=Math.min(this.footprintsMin.y,so.y),this.footprintsMax.x=Math.max(this.footprintsMax.x,Eo.x),this.footprintsMax.y=Math.max(this.footprintsMax.y,Eo.y);let Pn={footprintVertexOffset:Zp,footprintVertexLength:this.footprintsVertices.length-Zp,footprintIndexOffset:qp,footprintIndexLength:this.footprintsIndices.length-qp,min:so,max:Eo,hiddenFlags:0,indicesOffset:Mr,indicesLength:Ny,bloomIndicesOffset:Qn,bloomIndicesLength:Vn,groundEffectVertexOffset:Xl,groundEffectVertexLength:Yl,hasFauxFacade:lt,height:Dh,promoteId:R,feature:H,parts:Ki,buildingBloom:Cn},ji=this.footprints.length;C.id!==void 0&&this.featureFootprintLookup.set(C.id,ji),w($,ji),this.footprints.push(Pn)}this.programConfigurations.populatePaintArrays(Pt.layoutVertexArray.length,C,F,{},i.availableImages,r,i.brightness),this.groundEffect.addPaintPropertiesData(C,F,{},i.availableImages,r,i.brightness),i.featureIndex.insert(C,ie,F,z,this.index,zi)}g.forEach(({buildingId:C,footprintIndex:R})=>{x.has(C)&&(this.footprints[R].hiddenFlags|=4)});let M=new Set;this.buildingIds.forEach((C,R,F)=>{x.has(C)||M.add(C)}),this.buildingIds=M,this.groundEffect.prepareBorderSegments()}update(e,i,r,s,l,u,p){this.programConfigurations.updatePaintArrays(e,i,l,r,s,u,p),this.groundEffect.update(e,i,l,r,s,u,p),this.evaluate(this.layers[0],e),this.colorBufferUploaded=!1}updateExpressions(e){this.programConfigurations.updateExpressions(e),this.groundEffect.programConfigurations.updateExpressions(e)}isEmpty(){return this.buildingWithoutFacade.layoutVertexArray.length===0&&this.buildingWithFacade.layoutVertexArray.length===0}uploadPending(){return!this.uploaded||this.programConfigurations.needsUpload||this.groundEffect.programConfigurations.needsUpload}upload(e){let i=r=>{r.layoutVertexBuffer=e.createVertexBuffer(r.layoutVertexArray,ux.members),r.layoutNormalBuffer=e.createVertexBuffer(r.layoutNormalArray,Pb.members),r.layoutCentroidBuffer=e.createVertexBuffer(r.layoutCentroidArray,Db.members),r.layoutFloodLightDataBuffer=e.createVertexBuffer(r.layoutFloodLightDataArray,Fb.members),r.layoutFacadeDataArray&&r.layoutFacadeDataArray.length&&(r.layoutFacadeDataBuffer=e.createVertexBuffer(r.layoutFacadeDataArray,zb.members)),r.layoutFacadeVerticalRangeArray&&r.layoutFacadeVerticalRangeArray.length&&(r.layoutFacadeVerticalRangeBuffer=e.createVertexBuffer(r.layoutFacadeVerticalRangeArray,Lb.members)),r.entranceBloom.layoutVertexArray.length&&(r.entranceBloom.layoutVertexBuffer=e.createVertexBuffer(r.entranceBloom.layoutVertexArray,ux.members),r.entranceBloom.layoutAttenuationBuffer=e.createVertexBuffer(r.entranceBloom.layoutAttenuationArray,Ob.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=i=>{i.layoutVertexBuffer&&(i.layoutVertexBuffer.destroy(),i.layoutNormalBuffer.destroy(),i.layoutColorBuffer.destroy(),i.segmentsBucket.destroy(),i.indexBuffer&&i.indexBuffer.destroy(),i.entranceBloom.layoutVertexBuffer&&(i.entranceBloom.layoutVertexBuffer.destroy(),i.entranceBloom.layoutColorBuffer.destroy(),i.entranceBloom.layoutAttenuationBuffer.destroy(),i.entranceBloom.indexBuffer.destroy(),i.entranceBloom.segmentsBucket.destroy()))};e(this.buildingWithoutFacade),e(this.buildingWithFacade),this.groundEffect.destroy(),this.programConfigurations.destroy()}updateFootprintHiddenFlags(e,i,r=!0){let s=!1,l=r?i:0,u=0|(r?-1:~i);this.groundEffect.hiddenByLandmarkVertexArray.length===0&&this.groundEffect.hiddenByLandmarkVertexArray.resize(this.groundEffect.vertexArray.length);for(let p of e){let f=this.footprints[p],g=f.hiddenFlags&u|l;f.hiddenFlags!==g&&(f.hiddenFlags=g,s=!0,this.groundEffect.updateHiddenByLandmarkRange(f.groundEffectVertexOffset,f.groundEffectVertexLength,f.hiddenFlags!==0))}return s&&(this.indexArrayForConflationUploaded=!1),s}uploadUpdatedIndexBuffer(e){if(this.groundEffect.uploadHiddenByLandmark(e),this.indexArrayForConflationUploaded)return;let i=s=>{s.indexArray.length!==0&&(s.indexArrayForConflation.resize(s.indexArray.length),s.indexArrayForConflation.uint16.set(s.indexArray.uint16),s.entranceBloom.indexArrayForConflation.resize(s.entranceBloom.indexArray.length),s.entranceBloom.indexArrayForConflation.uint16.set(s.entranceBloom.indexArray.uint16))};i(this.buildingWithoutFacade),i(this.buildingWithFacade);for(let s of this.footprints){let l=s.hasFauxFacade?this.buildingWithFacade:this.buildingWithoutFacade,u=s.indicesOffset+s.indicesLength;if(s.hiddenFlags!==0){for(let f=s.indicesOffset;f<u;f++)l.indexArrayForConflation.uint16[3*f+0]=0,l.indexArrayForConflation.uint16[3*f+1]=0,l.indexArrayForConflation.uint16[3*f+2]=0;let p=s.bloomIndicesOffset+s.bloomIndicesLength;for(let f=s.bloomIndicesOffset;f<p;f++)l.entranceBloom.indexArrayForConflation.uint16[3*f+0]=0,l.entranceBloom.indexArrayForConflation.uint16[3*f+1]=0,l.entranceBloom.indexArrayForConflation.uint16[3*f+2]=0}}let r=s=>
7{s.indexArray.length!==0&&(s.indexBuffer?s.indexBuffer.updateData(s.indexArrayForConflation):s.indexBuffer=e.createIndexBuffer(s.indexArrayForConflation,!0),s.entranceBloom.indexBuffer?s.entranceBloom.indexBuffer.updateData(s.entranceBloom.indexArrayForConflation):s.entranceBloom.indexBuffer=e.createIndexBuffer(s.entranceBloom.indexArrayForConflation,!0))};r(this.buildingWithoutFacade),r(this.buildingWithFacade),this.indexArrayForConflationUploaded=!0}uploadUpdatedColorBuffer(e){let i=r=>{r.layoutColorBuffer?r.layoutColorBuffer.updateData(r.layoutColorArray):r.layoutColorBuffer=e.createVertexBuffer(r.layoutColorArray,hx.members,!0),r.layoutFacadePaintArray&&(r.layoutFacadePaintBuffer?r.layoutFacadePaintBuffer.updateData(r.layoutFacadePaintArray):r.layoutFacadePaintBuffer=e.createVertexBuffer(r.layoutFacadePaintArray,Rb.members,!0)),r.entranceBloom.layoutColorBuffer?r.entranceBloom.layoutColorBuffer.updateData(r.entranceBloom.layoutColorArray):r.entranceBloom.layoutColorBuffer=e.createVertexBuffer(r.entranceBloom.layoutColorArray,hx.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 s of this.footprints){if(4&s.hiddenFlags)continue;let l=i[s.promoteId],u=s.feature;u.properties["building-part"]="roof";let p=e.paint.get("building-color").evaluate(u,l,this.canonical).toPremultipliedRenderColor(this.lut),f=e.paint.get("building-emissive-strength").evaluate(u,l,this.canonical);u.properties["building-part"]="wall";let g=e.paint.get("building-color").evaluate(u,l,this.canonical).toPremultipliedRenderColor(this.lut),x=e.paint.get("building-emissive-strength").evaluate(u,l,this.canonical);u.properties["building-part"]="window";let b=e.paint.get("building-color").evaluate(u,l,this.canonical).toPremultipliedRenderColor(this.lut),w=e.paint.get("building-emissive-strength").evaluate(u,l,this.canonical);u.properties["building-part"]="door";let S=e.paint.get("building-color").evaluate(u,l,this.canonical).toPremultipliedRenderColor(this.lut),E=e.paint.get("building-emissive-strength").evaluate(u,l,this.canonical),M=s.hasFauxFacade?this.buildingWithFacade:this.buildingWithoutFacade;for(let R of s.parts){let F,z=p;R.part===1?(z=p,F=f):R.part===0?(z=g,F=x):R.part===2?(z=b,F=w):R.part===3&&(z=S,F=E),F=ne(F,0,1);for(let j=0;j<R.vertexLength;j++){let $=R.vertexOffset+j,H=1+(M.layoutAOArray.uint8[$]/255-1)*r;M.layoutColorArray.emplace($,z.r*H*255<<8|z.g*H*255,z.b*H*255<<8|255*F),s.hasFauxFacade&&M.layoutFacadePaintArray.emplace($,255*b.r<<8|255*b.g,255*b.b<<8|255*w)}}let C=s.buildingBloom;if(C)for(let R=0;R<C.vertexLength;R++)M.entranceBloom.layoutColorArray.emplace(C.vertexOffset+R,255*S.r<<8|255*S.g,255*S.b<<8|51*E)}}needsEvaluation(){return!this.colorBufferUploaded}updateReplacement(e,i,r){if(i.updateTime===this.replacementUpdateTime)return;this.replacementUpdateTime=i.updateTime;let s=i.getReplacementRegionsForTile(e.toUnwrapped());if(jm(this.activeReplacements,s))return;this.activeReplacements=s;for(let u of this.footprints)u.hiddenFlags&=-2;let l=[];for(let u of this.activeReplacements){if(u.order<r)continue;let p=Math.max(1,Math.pow(2,u.footprintTileId.canonical.z-e.canonical.z));for(let f of this.footprints)f.min.x>u.max.x||f.max.x<u.min.x||f.min.y>u.max.y||f.max.y<u.min.y||(l.length=0,Vb(this.footprintsVertices,f.footprintVertexOffset,f.footprintVertexLength,u.footprintTileId.canonical,e.canonical,l),Lg(u.footprint,l,this.footprintsIndices.uint16,f.footprintIndexOffset,f.footprintIndexLength,0,-p)&&(f.hiddenFlags|=1))}this.groundEffect.hiddenByLandmarkVertexArray.length===0&&this.groundEffect.hiddenByLandmarkVertexArray.resize(this.groundEffect.vertexArray.length);for(let u of this.footprints)this.groundEffect.updateHiddenByLandmarkRange(u.groundEffectVertexOffset,u.groundEffectVertexLength,u.hiddenFlags!==0);this.indexArrayForConflationUploaded=!1}getFootprint(e){if(e.id!==void 0){let i=this.featureFootprintLookup.get(e.id);return this.footprints[i]}return null}getHeightAtTileCoord(e,i){let r=Number.NEGATIVE_INFINITY,s=!0,l=4*(e+Xe)*Xe+(i+Xe);if(Object.hasOwn(this.footprintLookup,l)){let p=this.footprintLookup[l];return p?{height:p.height,hidden:p.hiddenFlags!==0}:void 0}let u=new ke(e,i);for(let p of this.footprints)e>p.max.x||p.min.x>e||i>p.max.y||p.min.y>i||p.height<=r||Ub(u,this.footprintsVertices.float32.subarray(2*p.footprintVertexOffset,2*(p.footprintVertexOffset+p.footprintVertexLength)),this.footprintsIndices.uint16.subarray(p.footprintIndexOffset,p.footprintIndexOffset+p.footprintIndexLength))&&(r=p.height,this.footprintLookup[l]=p,s=p.hiddenFlags!==0);if(r!==Number.NEGATIVE_INFINITY)return{height:r,hidden:s};this.footprintLookup[l]=void 0}}function Ub(n,e,i){for(let r=0;r<i.length;r+=3){let s=i[r],l=i[r+1],u=i[r+2],p=e[2*s+0],f=e[2*s+1],g=e[2*l+0],x=e[2*l+1],b=e[2*u+0
7],w=e[2*u+1],S=(p-b)*(n.y-w)-(f-w)*(n.x-b),E=(g-p)*(n.y-f)-(x-f)*(n.x-p);if(S<0!=E<0&&S!==0&&E!==0)continue;let M=(b-g)*(n.y-x)-(w-x)*(n.x-g);if(M===0||M<0==S+E<=0)return!0}return!1}function Vb(n,e,i,r,s,l){let u=Math.pow(2,r.z-s.z);for(let p=0;p<i;p++){let f=n.float32[2*(p+e)+0],g=n.float32[2*(p+e)+1];f=(f+s.x*Xe)*u-r.x*Xe,g=(g+s.y*Xe)*u-r.y*Xe,l.push(new ke(f,g))}}async function mx(){return function(){if(!ii(self)||So!=null||px!=null)return null;if(bh!=null)return bh;let n=fetch(pa());return bh=function(e){let i,r,s,l,u;function p(){i=new Uint8Array(u.buffer),r=new Int16Array(u.buffer),s=new Int32Array(u.buffer),l=new Float32Array(u.buffer)}function f(){throw new Error("Unexpected BuildingGen error.")}let g=()=>{},x={a:{a:f,f:function(b){let w=i.length,S=Math.max(b>>>0,Math.ceil(1.2*w)),E=Math.ceil((S-w)/65536);try{return u.grow(E),p(),!0}catch{return!1}},g:f,b:g,c:g,d:g,e:g}};return(WebAssembly.instantiateStreaming?WebAssembly.instantiateStreaming(e,x):e.then(b=>b.arrayBuffer()).then(b=>WebAssembly.instantiate(b,x))).then(b=>{let w=b.instance.exports;return(0,w.g)(),u=w.f,p(),new Bb({setStyle:w.h,setAOOptions:w.i,setMetricOptions:w.j,setStructuralOptions:w.k,setFacadeOptions:w.l,setFauxFacadeOptions:w.m,setFacadeClassifierOptions:w.n,addFeature:w.o,addFacade:w.p,generateMesh:w.q,getLastError:w.r,getOuterRingLength:w.s,getMeshCount:w.t,getPositionsPtr:w.u,getPositionsLength:w.v,getNormalsPtr:w.w,getNormalsLength:w.x,getAOPtr:w.y,getAOLength:w.z,getUVPtr:w.A,getUVLength:w.B,getFauxFacadePtr:w.C,getFauxFacadeLength:w.D,getIndicesPtr:w.E,getIndicesLength:w.F,getBuildingPart:w.G,getRingCount:w.H,getRingPtr:w.I,getRingLength:w.J,malloc:w.K,free:w.L,heapU8:i,heap16:r,heap32:s,heapF32:l})})}(n).then(e=>{bh=null,So=e}).catch(e=>{Ot("Could not load building-gen"),bh=null,px=e}),bh}()}Qe(fx,"BuildingBucket",{omit:["layers"]}),Qe(ey,"BuildingGeometry"),Qe(Qg,"BuildingBloomGeometry");let jb=Ct([{name:"a_pos_normal",components:2,type:"Int16"},{name:"a_data",components:4,type:"Uint8"},{name:"a_linesofar",components:1,type:"Float32"}],4),Gb=Ct([{name:"a_z_offset_width",components:3,type:"Float32"}],4),$b=Ct([{name:"a_elevation_id_col",components:3,type:"Float32"}],4),Hb=Ct([{name:"a_elevation_ground_scale",components:1,type:"Float32"}],4),{members:qb}=jb,Zb=Ct([{name:"a_packed",components:3,type:"Float32"}]),{members:Wb}=Zb,Xb=Ct([{name:"a_pattern_data",components:3,type:"Float32"}]),{members:Yb}=Xb;class _x{constructor(e,i){this.width=e,this.height=i,this.nextRow=0,this.image=new Ri({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=Lt(this.nextRow);this.image.resize({width:e,height:i})}getKey(e,i){return e.join(",")+i}getDashRanges(e,i,r){let s=[],l=e.length%2==1?-e.at(-1)*r:0,u=e[0]*r,p=!0;s.push({left:l,right:u,isDash:p,zeroLength:e[0]===0});let f=e[0];for(let g=1;g<e.length;g++){p=!p;let x=e[g];l=f*r,f+=x,u=f*r,s.push({left:l,right:u,isDash:p,zeroLength:x===0})}return s}addRoundDash(e,i,r){let s=i/2;for(let l=-r;l<=r;l++){let u=this.width*(this.nextRow+r+l),p=0,f=e[p];for(let g=0;g<this.width;g++){g/f.right>1&&(f=e[++p]);let x=Math.abs(g-f.left),b=Math.abs(g-f.right),w=Math.min(x,b),S,E=l/r*(s+1);if(f.isDash){let M=s-Math.abs(E);S=Math.sqrt(w*w+M*M)}else S=s-Math.sqrt(w*w+E*E);this.image.data[u+g]=Math.max(0,Math.min(255,S+128))}}}addRegularDash(e,i){for(let f=e.length-1;f>=0;--f){let g=e[f],x=e[f+1];g.zeroLength?e.splice(f,1):x&&x.isDash===g.isDash&&(x.left=g.left,e.splice(f,1))}let r=e[0],s=e.at(-1);r.isDash===s.isDash&&(r.left=s.left-this.width,s.right=r.right+this.width);let l=this.width*this.nextRow,u=0,p=e[u];for(let f=0;f<this.width;f++){f/p.right>1&&(p=e[++u]);let g=Math.abs(f-p.left),x=Math.abs(f-p.right),b=Math.min(g,x);this.image.data[l+f]=Math.max(0,Math.min(255,(p.isDash?b:-b)+i+128))}}addDash(e,i){let r=this.getKey(e,i);if(this.positions[r])return this.positions[r];let s=i==="round",l=s?7:0,u=2*l+1;if(this.nextRow+u>this.height)return Ot("LineAtlas out of space"),null;e.length===0&&e.push(1);let p=0;for(let b=0;b<e.length;b++)e[b]<0&&(Ot("Negative value is found in line dasharray, replacing values with 0"),e[b]=0),p+=e[b];if(p!==0){let b=this.width/p,w=this.getDashRanges(e,this.width,b);s?this.addRoundDash(w,b,l):this.addRegularDash(w,i==="square"?.5*b:0)}let f=this.nextRow+l;this.nextRow+=u;let g=Math.floor(p),x={tl:[f,l],br:[g,Math.round(65535*(p-g))]};return this.positions[r]=x,x}}Qe(_x,"LineAtlas");let Jb=$s.types,Kb=Math.cos(Math.PI/180*37.5),Qb=Math.cos(Math.PI/180*5);class l_{constructor(e){this.evaluationGlobals={zoom:0,lineProgress:void 0},this.elevationType="none",this.isSeaLevelReference=!1,this.showElevationIdDebug=!1,this.zoom=e.zoom,this.evaluationGlobals.zoom=this.zoom,this.overscaling=e.overscaling,this.pixelRatio=e.pixelRatio,this.layers=e.layers,this.layerIds=this.layers.map(i=>i.fqid),this.index=e.index,this.projection=e.projection,this.hasPattern=!1,this.hasCrossSlope=!1,this.patternFeatures=[],this.lineClipsArray=[],this.gradients={}
7,this.layers.forEach(i=>{this.gradients[i.id]={}}),this.layoutVertexArray=new Vd,this.layoutVertexArray2=new Br,this.patternVertexArray=new Br,this.indexArray=new Xi,this.programConfigurations=new bo(e.layers,{zoom:e.zoom,lut:e.lut}),this.segments=new pi,this.maxLineLength=0,this.zOffsetVertexArray=new Br,this.elevationIdColVertexArray=new Br,this.elevationGroundScaleVertexArray=new Do,this.stateDependentLayerIds=this.layers.filter(i=>i.isStateDependent()).map(i=>i.id),this.tessellationStep=e.tessellationStep?e.tessellationStep:128,this.worldview=e.worldview,this.hasAppearances=null}updateFootprints(e,i){}updateAppearances(e,i,r,s){return{hasLayoutChanges:!1,hasUboChanges:!1}}populate(e,i,r,s){this.showElevationIdDebug=i.showElevationIdDebug,this.hasPattern=wg("line",this.layers,this.pixelRatio,i);let l=this.layers[0].layout.get("line-sort-key");this.tileToMeter=Vr(r);let u=this.layers[0].layout.get("line-elevation-reference");if(u==="hd-road-markup")this.elevationType="road";else{let w=this.layers[0].layout.get("line-z-offset"),S=w.isConstant()&&!w.constantOr(0);this.elevationType=u!=="sea"&&u!=="ground"&&S?"none":"offset",this.elevationType==="offset"&&u==="none"&&Ot(`line-elevation-reference: ground is used for the layer ${this.layerIds[0]} because non-zero line-z-offset value was found.`),this.isSeaLevelReference=u==="sea"}let p=this.layers[0].layout.get("line-cross-slope");this.hasCrossSlope=this.elevationType==="offset"&&p!==void 0;let f=[];for(let{feature:w,id:S,index:E,sourceLayerIndex:M}of e){let C=this.layers[0]._featureFilter.needGeometry,R=Gr(w,C);if(!this.layers[0]._featureFilter.filter(new Xt(this.zoom,{worldview:this.worldview,activeFloors:i.activeFloors}),R,r))continue;let F=l?l.evaluate(R,{},r):void 0,z={id:S,properties:w.properties,type:w.type,sourceLayerIndex:M,index:E,geometry:C?R.geometry:jr(w,r,s),patterns:{},sortKey:F};f.push(z)}l&&f.sort((w,S)=>w.sortKey-S.sortKey);let{lineAtlas:g,featureIndex:x}=i,b=this.addConstantDashes(g);for(let w of f){let{geometry:S,index:E,sourceLayerIndex:M}=w;if(b&&this.addFeatureDashes(w,g),this.hasPattern){let C=Tg("line",this.layers,w,this.zoom,this.pixelRatio,i);this.patternFeatures.push(C)}else this.addFeature(w,S,E,r,g.positions,i.availableImages,i.brightness,i.elevationFeatures);x.insert(e[E].feature,S,E,M,this.index)}}addConstantDashes(e){let i=!1;for(let r of this.layers){let s=r.paint.get("line-dasharray").value,l=r.layout.get("line-cap").value;if(s.kind!=="constant"||l.kind!=="constant")i=!0;else{let u=l.value,p=s.value;if(!p)continue;e.addDash(p,u)}}return i}addFeatureDashes(e,i){let r=this.zoom;for(let s of this.layers){let l=s.paint.get("line-dasharray").value,u=s.layout.get("line-cap").value;if(l.kind==="constant"&&u.kind==="constant")continue;let p,f;if(l.kind==="constant"){if(p=l.value,!p)continue}else p=l.evaluate({zoom:r},e);f=u.kind==="constant"?u.value:u.evaluate({zoom:r},e),i.addDash(p,f),e.patterns[s.id]=[i.getKey(p,f)]}}update(e,i,r,s,l,u,p,f,g){this.programConfigurations.updatePaintArrays(e,i,l,r,s,u,p,g)}updateExpressions(e){this.programConfigurations.updateExpressions(e)}addFeatures(e,i,r,s,l,u){for(let p of this.patternFeatures)this.addFeature(p,p.geometry,p.index,i,r,s,u,e.elevationFeatures)}isEmpty(){return this.layoutVertexArray.length===0}uploadPending(){return!this.uploaded||this.programConfigurations.needsUpload}upload(e){this.uploaded||(this.layoutVertexArray2.length!==0&&(this.layoutVertexBuffer2=e.createVertexBuffer(this.layoutVertexArray2,Wb)),this.patternVertexArray.length!==0&&(this.patternVertexBuffer=e.createVertexBuffer(this.patternVertexArray,Yb)),!this.zOffsetVertexBuffer&&this.zOffsetVertexArray.length>0&&(this.zOffsetVertexBuffer=e.createVertexBuffer(this.zOffsetVertexArray,Gb.members,!0)),!this.elevationIdColVertexBuffer&&this.elevationIdColVertexArray.length>0&&(this.elevationIdColVertexBuffer=e.createVertexBuffer(this.elevationIdColVertexArray,$b.members,!0)),!this.elevationGroundScaleVertexBuffer&&this.elevationGroundScaleVertexArray.length>0&&(this.elevationGroundScaleVertexBuffer=e.createVertexBuffer(this.elevationGroundScaleVertexArray,Hb.members,!0)),this.layoutVertexBuffer=e.createVertexBuffer(this.layoutVertexArray,qb),this.indexBuffer=e.createIndexBuffer(this.indexArray)),this.programConfigurations.upload(e),this.uploaded=!0}destroy(){this.layoutVertexBuffer&&(this.zOffsetVertexBuffer&&this.zOffsetVertexBuffer.destroy(),this.elevationIdColVertexBuffer&&this.elevationIdColVertexBuffer.destroy(),this.elevationGroundScaleVertexBuffer&&this.elevationGroundScaleVertexBuffer.destroy(),this.layoutVertexBuffer.destroy(),this.indexBuffer.destroy(),this.programConfigurations.destroy(),this.segments.destroy())}lineFeatureClips(e,i){let r,s;if(i&&i>0?(r=`mapbox_clip_start_${i}`,s=`mapbox_clip_end_${i}`):(r="mapbox_clip_start",s="mapbox_clip_end"),e.properties&&Object.hasOwn(e.properties,r)&&Object.hasOwn(e.properties,s))return{start:+e.properties[r],end:+e.properties[s]}}addFeature(e,i,r,s,l,u,p,f){let g=this.layers[0].layout,x=g.get("line-join").evaluate(e,{}),b=g.get("line-cap").evaluate(e,{}),w=g.get("line-miter-limit"),S=g.get("line-round-limit");this.lineClips=this.lineFeatureClips(e),this.lineFeature=e;let E=!(!e.properties||!Object.hasOwn(e.properties,"mapbox_line_metrics"))&&e.properties.mapbox_line_metrics;this.zOffsetValue=g.get("line-z-offset").value;let M=this.layers[0].paint.get("line-width").value;if(M.kind!=="constant"&&M.isLineProgressConstant===!1&&(this.variableWidthValue=M),this.isSeaLevelReference){let C=g.get("line-elevation-ground-scale").value;C.kind==="constant"&&C.value===0||(this.elevationGroundScaleValue=C)}if(this.elevationType==="road"){let C=this.layoutVertexArray.length;if(!this.addElevatedRoadFeature(e,i,s,f,x,b,w,S)){let[R,F]=this.clipRuntimeLinesToTile(i,1);for(let z=0;z<R.length;z++){let j=R[z],$=F[z],H={progress:{min:$.progress.min,max:$.progress.max},nextDir:this.computeSegNextDir($,j),prevDir:this.computeSegPrevDir($,j)};this.addLine(j,e,s,x,b,w,S,H,E&&$.parentIndex>0?$.parentIndex:null)}this.fillNonElevatedRoadSegment(C)}}else for(let C=0;C<i.length;C++)this.addLine(i[C],e,s,x,b,w,S,void 0,E&&C>0?C:null);this.programConfigurations.populatePaintArrays(this.layoutVertexArray.length,e,r,l,u,s,p,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 Jm(e,-i,-i,Xe+i,Xe+i)}clipRuntimeLinesToTile(e,i){let r=[];return[Jm(e,-i,-i,Xe+i,Xe+i,r),r]}addElevatedRoadFeature(e,i,r,s,l,u,p,f){let g=[],x=_h.getElevationFeature(e,s);if(x){let b=this.clipLinesToTile(i,1),w=this.prepareElevatedLines(b,x,r);for(let S of w)g.push({geometry:S,elevation:x,elevationTileID:r,segment:{progress:{min:0,max:1},nextDir:void 0,prevDir:void 0}})}if(g.length===0)return!1;for(let b of g){let w=this.layoutVertexArray.length;this.addLine(b.geometry,e,r,l,u,p,f);let S=new a(r,b.elevationTileID);if(b.elevation){let E=this.showElevationIdDebug?t(b.elevation.id):null;for(let M=w;M<this.layoutVertexArray.length;M++){let C=new ke(this.layoutVertexArray.int16[6*M]>>1,this.layoutVertexArray.int16[6*M+1]>>1),R=S.pointElevation(C,b.elevation,.05);this.updateHeightRange(R),this.zOffsetVertexArray.emplaceBack(R,0,0),E?this.elevationIdColVertexArray.emplaceBack(E[0],E[1],E[2]):this.showElevationIdDebug&&this.elevationIdColVertexArray.emplaceBack(0,0,0)}}else this.fillNonElevatedRoadSegment(w)}return!0}prepareElevatedLines(e,i,r){if(i.constantHeight!=null)return e;let s=[],l=1/Vr(r);for(let u of e)lb(u,new Pm(i,l),0,s);return s}fillNonElevatedRoadSegment(e){for(let i=e;i<this.layoutVertexArray.length;i++)this.zOffsetVertexArray.emplaceBack(0,0,0),this.showElevationIdDebug&&this.elevationIdColVertexArray.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,s,l,u,p,f,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=g?this.lineFeatureClips(i,g):this.lineClips;let x=s==="none";this.patternJoinNone=this.hasPattern&&x,this.currentLineJoinType=s,this.segmentStart=0,this.segmentStartf32=0,this.segmentPoints=[];let b=f&&f.progress.min>0,w=f&&f.progress.max<1;if(this.lineClips){let Q={min:this.lineClips.start,max:this.lineClips.end},Y=1;if(f){let ge=this.lineClips.end-this.lineClips.start;Q=function(Te,Ae,Ee){return{min:go(Te.min,Ae,Ee),max:go(Te.max,Ae,Ee)}}(f.progress,{min:0,max:1},Q),ge>0&&(Y=(Q.max-Q.min)/ge)}let ee=+i.properties.mapbox_clip_feature_len,me=+i.properties.mapbox_clip_seg_len;if(Number.isNaN(ee)||Number.isNaN(me)){for(let Te=0;Te<e.length-1;Te++)this.totalDistance+=e[Te].dist(e[Te+1]);let ge=this.totalDistance/(Q.max-Q.min);this.totalFeatureLength=Number.isFinite(ge)?ge:0,this.lineClips.start=Q.min,this.lineClips.end=Q.max,this.maxLineLength=Math.max(this.maxLineLength,this.totalDistance)}else this.totalFeatureLength=ee,this.distance=me*Y,this.lineClips.start=Q.min,this.lineClips.end=Q.max,this.maxLineLength=Math.max(this.maxLineLength,this.distance);this.lineClipsArray.push(this.lineClips),this.updateScaledDistance()}let S=Jb[i.type]==="Polygon",E=e.length;for(;E>=2&&e[E-1].equals(e[E-2]);)E--;let M=0;for(;M<E-1&&e[M].equals(e[M+1]);)M++;if(E<(S?3:2))return;s==="bevel"&&(u=1.05);let C=this.segments.prepareSegment(10*E,this.layoutVertexArray,this.indexArray),R,F,z,j,$,H,ie,W;f&&f.prevDir&&(H=f.prevDir.perp()),f&&f.nextDir&&(ie=f.nextDir.perp()),this.e1=this.e2=-1,S&&(R=e[E-2],$=e[M].sub(R)._unit()._perp());for(let Q=M;Q<E;Q++){if(z=Q===E-1?S?e[M+1]:void 0:e[Q+1],z&&e[Q].equals(z))continue;$&&(j=$),R&&(F=R),R=e[Q],W=this.evaluateLineProgressFeatures(F?F.dist(R):0),$=z?z.sub(R)._unit()._perp():j,j=j||$;let Y=F&&z,ee=Y?s:S||x?"butt":l,me=j.x*$.x+j.y*$.y;if(x){let Me=function(ze){if(ze.patternJoinNone){let Le=ze.segmentPoints.length/2,We=ze.lineSoFar-ze.segmentStart;for(let De=0;De<Le;++De){let Ge=ze.segmentPoints[2*De+1],He=Math.round(ze.segmentPoints[2*De])+.5+.25*Ge;ze.patternVertexArray.emplaceBack(He,We,ze.segmentStart),ze.patternVertexArray.emplaceBack(He,We,ze.segmentStart)}ze.segmentPoints.length=0}ze.e1=ze.e2=-1};if(Y&&me<Qb){this.updateDistance(F,R),this.addCurrentVertex(R,j,1,1,C,W),Me(this),this.addCurrentVertex(R,$,-1,-1,C,W);continue}if(F){if(!z){this.updateDistance(F,R),this.addCurrentVertex(R,j,1,1,C,W),Me(this);continue}ee="miter"}}let ge=j.add($);ge.x===0&&ge.y===0||ge._unit();let Te=ge.x*$.x+ge.y*$.y,Ae=Te!==0?1/Te:1/0,Ee=2*Math.sqrt(2-2*Te),Be=Te<Kb&&F&&z,xe=j.x*$.y-j.y*$.x>0,Se=this.overscaling<=16?122880/(512*this.overscaling):0;if(Y&&ee==="round"){if(Ae<p)ee="miter";else if(Ae<=2){let Me=ty(R,-10,8202);ee=this.elevationType==="offset"&&(Me||this.hasCrossSlope)?"miter":"fakeround"}}if(ee==="miter"&&Ae>u&&(ee="bevel"),ee==="bevel"&&(Ae>2&&(ee="flipbevel"),Ae<u&&(ee="miter")),F&&!(ee==="miter"&&Be)&&this.updateDistance(F,R),ee==="miter")if(Be){let Me=R.dist(F);if(Me>2*Se){let Le=R.sub(R.sub(F)._mult(Se/Me)._round());this.updateDistance(F,Le),this.addCurrentVertex(Le,j,0,0,C,W),F=Le}this.updateDistance(F,R),ge._mult(Ae),this.addCurrentVertex(R,ge,0,0,C,W);let ze=R.dist(z);if(ze>2*Se){let Le=R.add(z.sub(R)._mult(Se/ze)._round());this.updateDistance(R,Le),this.addCurrentVertex(Le,$,0,0,C,W),R=Le}}else ge._mult(Ae),this.addCurrentVertex(R,ge,0,0,C,W);else if(ee==="flipbevel"){if(Ae>100)ge=$.mult(-1);else{let Me=Ae*j.add($).mag()/j.sub($).mag();ge._perp()._mult(Me*(xe?-1:1))}this.addCurrentVertex(R,ge,0,0,C,W),this.addCurrentVertex(R,ge.mult(-1),0,0,C,W)}else if(ee==="bevel"||ee==="fakeround"){let Me=R.dist(F),ze=1;if(this.elevationType==="offset"&&ee==="bevel"&&this.currentLineJoinType!=="round"&&!this.patternJoinNone&&W!=null&&F&&z){let Je=4*Se;Me<Je&&(ze=Math.max(0,Me/Je))}W!=null&&F&&this.addCurrentVertex(R,ie||j,-ze,-ze,C,W);let Le=Me<=2*Se&&ee!=="bevel",We=ge.mult(xe?1:-1);We._mult(Ae);let De=$.mult(xe?-1:1),Ge=j.mult(xe?-1:1),He=this.evaluateLineProgressFeatures(this.distance);if(W==null&&(this.addHalfVertex(R,We.x,We.y,!1,!xe,0,C,He),Le||this.addHalfVertex(R,We.x+2*Ge.x,We.y+2*Ge.y,!1,xe,0,C,He)),ee==="fakeround"){let Je=Math.round(180*Ee/Math.PI/20);this.addHalfVertex(R,Ge.x,Ge.y,!1,xe,0,C,He);for(let tt=0;tt<Je;tt++){let lt=tt/Je;if(lt!==.5){let pt=lt-.5;lt+=lt*pt*(lt-1)*((1.0904+me*(me*(3.55645-1.43519*me)-3.2452))*pt*pt+(.848013+me*(.215638*me-1.06021)))}let rt=De.sub(Ge)._mult(lt)._add(Ge)._unit();this.addHalfVertex(R,rt.x,rt.y,!1,xe,0,C,He)}this.addHalfVertex(R,De.x,De.y,!1,xe,0,C,He)}Le||W!=null||this.addHalfVertex(R,We.x+2*De.x,We.y+2*De.y,!1,xe,0,C,He),W!=null&&z&&this.addCurrentVertex(R,H||$,ze,ze,C,W)}else if(ee==="butt")this.addCurrentVertex(R,ge,0,0,C,W);else if(ee==="square"){if(!F){let Me=b?0:-1;this.addCurrentVertex(R,ge,Me,Me,C,W)}if(this.addCurrentVertex(R,ge,0,0,C,W),F){let Me=w?0:1;this.addCurrentVertex(R,ge,Me,Me,C,W)}}else if(ee==="round"){if(F){let Me=!Y&&ie?ie:j;this.addCurrentVertex(R,Me,0,0,C,W),!Y&&w||this.addCurrentVertex(R,Me,1,1,C,W,!0)}if(z){let Me=!Y&&H?H:$;!Y&&b||this.addCurrentVertex(R,Me,-1,-1,C,W,!0),this.addCurrentVertex(R,Me,0,0,C,W)}}}}addVerticesTo(e,i,r,s,l,u,p,f,g,x){let b=(i.w-e.w)/this.tessellationStep|0,w=0,S=this.scaledDistance;if(b>
71){this.lineSoFar=e.w;let M=(i.x-e.x)/b,C=(i.y-e.y)/b,R=(i.z-e.z)/b,F=(i.w-e.w)/b,z=i.x-e.x,j=i.y-e.y,$=Math.sqrt(z*z+j*j);if($===0)return;let H=-j/$,ie=z/$,W=H,Q=ie,Y=-H,ee=-ie;for(let me=1;me<b;++me){e.x+=M,e.y+=C,e.z+=R,this.lineSoFar+=F,w+=F;let ge=this.evaluateLineProgressFeatures(this.prevDistance+w);this.scaledDistance=(this.prevDistance+w)/this.totalDistance,this.addHalfVertex(e,W,Q,x,!1,0,g,ge),this.addHalfVertex(e,Y,ee,x,!0,0,g,ge)}}this.lineSoFar=i.w,this.scaledDistance=S;let E=this.evaluateLineProgressFeatures(this.distance);this.addHalfVertex(i,r,s,x,!1,p,g,E),this.addHalfVertex(i,l,u,x,!0,-f,g,E)}evaluateLineProgressFeatures(e){if(!this.variableWidthValue&&this.elevationType!=="offset")return null;this.evaluationGlobals.lineProgress=0,this.lineClips?this.evaluationGlobals.lineProgress=Math.min(1,(this.totalFeatureLength*this.lineClips.start+e)/this.totalFeatureLength):Ot(`line-progress evaluation for ${this.layerIds[0]} requires enabling 'lineMetrics' for the source.`);let i=0;this.variableWidthValue&&this.variableWidthValue.kind!=="constant"&&(i=this.variableWidthValue.evaluate(this.evaluationGlobals,this.lineFeature)||0);let r=this.evaluateElevationGroundScale();return this.elevationType!=="offset"?{zOffset:0,variableWidth:i,elevationGroundScale:r}:this.zOffsetValue.kind==="constant"?{zOffset:this.zOffsetValue.value,variableWidth:i,elevationGroundScale:r}:{zOffset:this.zOffsetValue.evaluate(this.evaluationGlobals,this.lineFeature)||0,variableWidth:i,elevationGroundScale:r}}evaluateElevationGroundScale(){return this.elevationGroundScaleValue?this.elevationGroundScaleValue.kind==="constant"?this.elevationGroundScaleValue.value:this.elevationGroundScaleValue.evaluate(this.evaluationGlobals,this.lineFeature)||0:0}addCurrentVertex(e,i,r,s,l,u,p=!1){let f=i.x+i.y*r,g=i.y-i.x*r,x=i.y*s-i.x,b=-i.y-i.x*s;if(u!=null){let w=this.elevationType==="offset",S=this.elevationType==="offset"?2:10,E=-S,M=Xe+S,C=u.zOffset,R=new R0(e.x,e.y,C,this.lineSoFar),F=!!w&&ty(e,E,M),z=this.lineSoFar,j=this.distance;if(this.currentVertex)if(F){let $=this.currentVertexIsOutside,H=this.currentVertex,ie=new R0(e.x,e.y,C,this.lineSoFar);if(L0(H,ie,E,M),!ty(ie,E,M)){if($){this.e1=this.e2=-1,this.distance-=H.dist(R),this.lineSoFar=H.w;let W=this.evaluateLineProgressFeatures(H.w-this.totalFeatureLength*(this.lineClips?this.lineClips.start:0));this.addHalfVertex(H,f,g,p,!1,r,l,W),this.addHalfVertex(H,x,b,p,!0,-s,l,W),this.prevDistance=this.distance}this.distance=this.prevDistance+H.dist(ie),this.scaledDistance=this.distance/this.totalDistance,this.addVerticesTo(H,ie,f,g,x,b,r,s,l,p),this.distance=j,this.scaledDistance=this.distance/this.totalDistance}}else{let $=this.currentVertex;if(this.currentVertexIsOutside){L0($,R,E,M),this.e1=this.e2=-1,this.distance-=$.dist(R),this.scaledDistance=this.distance/this.totalDistance,this.lineSoFar=$.w;let H=this.evaluateLineProgressFeatures($.w-this.totalFeatureLength*(this.lineClips?this.lineClips.start:0));this.addHalfVertex($,f,g,p,!1,r,l,H),this.addHalfVertex($,x,b,p,!0,-s,l,H),this.prevDistance=this.distance,this.distance=j,this.scaledDistance=this.distance/this.totalDistance}this.addVerticesTo($,R,f,g,x,b,r,s,l,p)}else F||(this.addHalfVertex(e,f,g,p,!1,r,l,u),this.addHalfVertex(e,x,b,p,!0,-s,l,u));this.currentVertex=R,this.currentVertexIsOutside=F,this.lineSoFar=z}else this.addHalfVertex(e,f,g,p,!1,r,l,u),this.addHalfVertex(e,x,b,p,!0,-s,l,u)}addHalfVertex({x:e,y:i},r,s,l,u,p,f,g){if(this.patternJoinNone&&(this.segmentPoints.length===0&&(this.segmentStart=this.lineSoFar,this.segmentStartf32=Math.fround(this.lineSoFar)),u||this.segmentPoints.push(this.lineSoFar-this.segmentStart,p)),this.layoutVertexArray.emplaceBack((e<<1)+(l?1:0),(i<<1)+(u?1:0),Math.round(63*r)+128,Math.round(63*s)+128,1+(p===0?0:p<0?-1:1),0,this.lineSoFar-this.segmentStartf32),this.lineClips){let b=ft(this.lineClips.start,this.lineClips.end,this.scaledDistance);this.layoutVertexArray2.emplaceBack(this.scaledDistance,this.lineClipsArray.length,b)}let x=f.vertexLength++;if(this.e1>=0&&this.e2>=0&&(this.indexArray.emplaceBack(this.e1,this.e2,x),f.primitiveLength++),u?this.e2=x:this.e1=x,g!=null&&(this.zOffsetVertexArray.emplaceBack(g.zOffset,g.variableWidth,g.variableWidth),this.showElevationIdDebug&&this.elevationIdColVertexArray.emplaceBack(0,0,0)),this.elevationGroundScaleValue){let b=g?g.elevationGroundScale:this.evaluateElevationGroundScale();this.elevationGroundScaleVertexArray.emplaceBack(b)}}updateScaledDistance(){this.lineClips?(this.scaledDistance=this.distance/this.totalDistance,this.lineS
7oFar=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 ty(n,e,i){return n.x<e||n.x>i||n.y<e||n.y>i}let gx,yx;function xx(n,e,i){return e*(Xe/(n.tileSize*Math.pow(2,i-n.tileID.overscaledZ)))}Qe(l_,"LineBucket",{omit:["layers","patternFeatures","currentVertex","currentVertexIsOutside"]});let vx=(n,e,i)=>(1-i)*n+i*e;function bx(n,e){return 1/xx(n,1,e.tileZoom)}function wx(n,e,i,r){return n.translatePosMatrix(r||e.tileID.projMatrix,e,i.paint.get("line-translate"),i.paint.get("line-translate-anchor"))}let Tx=n=>{let e=[];Sx(n)&&e.push("RENDER_LINE_DASH"),n.paint.get("line-gradient")&&e.push("RENDER_LINE_GRADIENT"),n.paint.get("line-blend-mode")==="multiply"&&e.push("LINE_BLEND_MULTIPLY"),n.paint.get("line-blend-mode")==="additive"&&e.push("LINE_BLEND_ADDITIVE");let i=n.paint.get("line-trim-offset");i[0]===0&&i[1]===0||e.push("RENDER_LINE_TRIM_OFFSET"),n.paint.get("line-border-width").constantOr(1)!==0&&e.push("RENDER_LINE_BORDER");let r=n.layout.get("line-join").constantOr("miter")==="none",s=!!n.paint.get("line-pattern").constantOr(1);return r&&s&&e.push("LINE_JOIN_NONE"),e};function Sx(n){let e=n.paint.get("line-dasharray").value;return e.kind!=="constant"||e.value}let iy,Ix=()=>iy||(iy={layout:gx||(gx=new wi({"line-cap":new Ze(he.layout_line["line-cap"]),"line-join":new Ze(he.layout_line["line-join"]),"line-miter-limit":new qe(he.layout_line["line-miter-limit"]),"line-round-limit":new qe(he.layout_line["line-round-limit"]),"line-sort-key":new Ze(he.layout_line["line-sort-key"]),"line-z-offset":new Ze(he.layout_line["line-z-offset"]),"line-elevation-reference":new qe(he.layout_line["line-elevation-reference"]),"line-cross-slope":new qe(he.layout_line["line-cross-slope"]),visibility:new qe(he.layout_line.visibility),"line-width-unit":new qe(he.layout_line["line-width-unit"]),"line-elevation-ground-scale":new Ze(he.layout_line["line-elevation-ground-scale"])})),paint:yx||(yx=new wi({"line-opacity":new Ze(he.paint_line["line-opacity"]),"line-color":new Ze(he.paint_line["line-color"]),"line-translate":new qe(he.paint_line["line-translate"]),"line-translate-anchor":new qe(he.paint_line["line-translate-anchor"]),"line-width":new Ze(he.paint_line["line-width"]),"line-gap-width":new Ze(he.paint_line["line-gap-width"]),"line-offset":new Ze(he.paint_line["line-offset"]),"line-blur":new Ze(he.paint_line["line-blur"]),"line-dasharray":new Ze(he.paint_line["line-dasharray"]),"line-pattern":new Ze(he.paint_line["line-pattern"]),"line-pattern-cross-fade":new qe(he.paint_line["line-pattern-cross-fade"]),"line-gradient":new La(he.paint_line["line-gradient"]),"line-trim-offset":new qe(he.paint_line["line-trim-offset"]),"line-trim-fade-range":new qe(he.paint_line["line-trim-fade-range"]),"line-trim-color":new qe(he.paint_line["line-trim-color"]),"line-emissive-strength":new Ze(he.paint_line["line-emissive-strength"]),"line-border-width":new Ze(he.paint_line["line-border-width"]),"line-border-color":new Ze(he.paint_line["line-border-color"]),"line-occlusion-opacity":new qe(he.paint_line["line-occlusion-opacity"]),"line-blend-mode":new qe(he.paint_line["line-blend-mode"]),"line-blend-additive-clamp":new qe(he.paint_line["line-blend-additive-clamp"]),"line-color-use-theme":new Ze({type:"string",default:"default","property-type":"data-driven"}),"line-gradient-use-theme":new Ze({type:"string",default:"default","property-type":"data-driven"}),"line-trim-color-use-theme":new Ze({type:"string",default:"default","property-type":"data-driven"}),"line-border-color-use-theme":new Ze({type:"string",default:"default","property-type":"data-driven"})}))},iy);class ew extends Ze{possiblyEvaluate(e,i){return i=new Xt(Math.floor(i.zoom),{now:i.now,fadeDuration:i.fadeDuration,transition:i.transition,worldview:i.worldview}),super.possiblyEvaluate(e,i)}evaluate(e,i,r,s){return i=Object.assign({},i,{zoom:Math.floor(i.zoom)}),super.evaluate(e,i,r,s)}}let Ap;function Ex(n,e){return e>0?e+2*n:n}let tw=Ct([{name:"a_pos_offset",components:4,type:"Int16"},{name:"a_tex_size",components:4,type:"Uint16"},{name:"a_pixeloffset",components:4,type:"Int16"}],4),iw=Ct([{name:"a_globe_anchor",components:3,type:"Int16"},{name:"a_globe_normal",components:3,type:"Float32"}],4),nw=Ct([{name:"a_projected_pos",components:4,type:"Float32"}],4);Ct([{name:"a_fade_opacity",components:1,type:"Uint32"}],4);let rw=Ct([{name:"a_auto_z_offset",components:1,type:"Float32"}],4),ow=Ct([{name:"a_feature_index",components:1,type:"Float32"}],4),sw=Ct([{name:"a_x_axis",components:3,type:"Float32"},{name:"a_y_axis",components:3,type:"Float32"}]),aw=Ct([{name:"a_texb",components:2,type:"Uint16"}]),lw=Ct([{name:"a_placed",components:2,type:"Uint8"},{name:"a_shift",components:2,type:"Float32"},{name:"a_elevation_from_sea",components:2,type:"Float32"}]),cw=Ct([{name:"a_size_scale",components:1,type:"Float32"},{name:"a_padding",components:2,type:"Float32"},{name:"a_auto_z_offset",components:1,type:"Float32"}]);Ct([{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 Ax=Ct([{name:"a_pos",components:3,type:"Int16"},{name:"a_anchor_pos",components:2,type:"Int16"},{name:"a_extrude",components:2,type:"Int16"}],4),uw=Ct([{name:"a_pos_2f",components:2,type:"Float32"},{name:"a_radius",components:1,type:"Float32"},{name:"a_flags",components:2,type:"Int16"}],4);Ct([{name:"triangle",components:3,type:"Uint16"}]),Ct([{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"}]),Ct([{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]),Ct([{type:"Float32",name:"offsetX"}]),Ct([{type:"Int16",name:"x"},{type:"Int16",name:"y"}]);let nu=class Jl{constructor(e=null,i=0,r=4096){if(this.batchIndex=i,this.headerBuffer=null,this.propertiesBuffer=null,this.blockIndicesBuffer=null,this.context=e||null,this.propsDwords=r,this.totalBytes=4*this.propsDwords,this.headerData=new Uint32Array(Jl.HEADER_DWORDS),this.propertiesData=new Float32Array(this.propsDwords),!Jl._blockIndicesTemplate){Jl._blockIndicesTemplate=new Uint32Array(this.propsDwords);for(let s=0;s<this.propsDwords;s++)Jl._blockIndicesTemplate[s]=s}this.blockIndicesData=new Uint32Array(Jl._blockIndicesTemplate),e&&this._initBuffers(e)}_initBuffers(e){let i=e.gl;if(this.totalBytes>e.maxUniformBlockSize)throw new Error(`UBO size ${this.totalBytes} exceeds device limit ${e.maxUniformBlockSize}`);if(this.headerBuffer=i.createBuffer(),!this.headerBuffer)throw new Error("Failed to create header UBO buffer");if(i.bindBuffer(i.UNIFORM_BUFFER,this.headerBuffer),i.bufferData(i.UNIFORM_BUFFER,Jl.HEADER_BYTES,i.DYNAMIC_DRAW),this.propertiesBuffer=i.createBuffer(),!this.propertiesBuffer)throw new Error("Failed to create properties UBO buffer");if(i.bindBuffer(i.UNIFORM_BUFFER,this.propertiesBuffer),i.bufferData(i.UNIFORM_BUFFER,this.totalBytes,i.DYNAMIC_DRAW),this.blockIndicesBuffer=i.createBuffer(),!this.blockIndicesBuffer)throw new Error("Failed to create block-indices UBO buffer");i.bindBuffer(i.UNIFORM_BUFFER,this.blockIndicesBuffer),i.bufferData(i.UNIFORM_BUFFER,this.totalBytes,i.DYNAMIC_DRAW),i.bindBuffer(i.UNIFORM_BUFFER,null)}writeHeader(e){let i=this.headerData;i[0]=e.dataDrivenMask,i[1]=e.zoomDependentMask,i[2]=e.dataDrivenBlockSizeVec4,i[3]=e.offsets[0],i[4]=e.offsets[1],i[5]=e.offsets[2],i[6]=e.offsets[3],i[7]=e.offsets[4],i[8]=e.offsets[5],i[9]=e.offsets[6],i[10]=e.offsets[7],i[11]=e.offsets[8]}writeDataDrivenBlock(e,i,r){let s=4*r.dataDrivenBlockSizeVec4;if(s===0)return;let l=i*s;if(l+s>this.propertiesData.length)throw new Error(`UBO write out of bounds: feature index ${i} exceeds propertiesData capacity`);for(let u=0;u<9;u++)r.dataDrivenMask&1<<u&&this._copyFromFlat(l+r.offsets[u],u,e,Jl.EVAL_FLAT_OFFSETS[u],r.zoomDependentMask)}static getMaxFeatureCount(e,i=4096){let r=4*e.dataDrivenBlockSizeVec4;return r===0?1/0:Math.floor(i/r)}_copyFromFlat(e,i,r,s,l){let u=this.propertiesData,p=i===8,f=!!(l&1<<i);i<2||p&&f?(u[e]=r[s],u[e+1]=r[s+1],u[e+2]=r[s+2],u[e+3]=r[s+3]):p||f?(u[e]=r[s],u[e+1]=r[s+1]):u[e]=r[s]}upload(e){this.context||(this.context=e);let i=e.gl;this.headerBuffer&&this.propertiesBuffer&&this.blockIndicesBuffer||this._initBuffers(e),i.bindBuffer(i.UNIFORM_BUFFER,this.headerBuffer),i.bufferSubData(i.UNIFORM_BUFFER,0,this.headerData),i.bindBuffer(i.UNIFORM_BUFFER,this.propertiesBuffer),i.bufferSubData(i.UNIFORM_BUFFER,0,this.propertiesData),i.bindBuffer(i.UNIFORM_BUFFER,this.blockIndicesBuffer),i.bufferSubData(i.UNIFORM_BUFFER,0,this.blockIndicesData),i.bindBuffer(i.UNIFORM_BUFFER,null)}bind(e,i){let r=e.gl,s=(u,p,f)=>{if(!p)return;let g=r.getUniformBlockIndex(i,u);g!==r.INVALID_INDEX&&(r.uniformBlockBinding(i,g,f),r.bindBufferBase(r.UNIFORM_BUFFER,f,p))},l=3*this.batchIndex;s("SymbolPaintPropertiesHeaderUniform",this.headerBuffer,l),s("SymbolPaintPropertiesUniform",this.propertiesBuffer,l+1),s("SymbolPaintPropertiesIndexUniform",this.blockIndicesBuffer,l+2)}destroy(){if(this.context){let e=this.context.gl;this.headerBuffer&&(e.deleteBuffer(this.headerBuffer),this.headerBuffer=null),this.propertiesBuffer&&(e.deleteBuffer(this.propertiesBuffer),this.propertiesBuffer=null),this.blockIndicesBuffer&&(e.deleteBuffer(this.blockIndicesBuffer),this.blockIndicesBuffer=null)}}};nu.HEADER_DWORDS=12,nu.HEADER_BYTES=48,nu.EVAL_FLAT_OFFSETS=[0,4,8,10,12,14,16,18,20],nu.EVAL_FLAT_SIZES=[4,4,2,2,2,2,2,2,4],nu.EVAL_FLAT_TOTAL=24,nu._blockIndicesTemplate=null;let Gl=nu;function Mx(n,e,i,r,s,l,u,p){return!!n&&(n.kind==="constant"?n.value==="none":n.kind==="composite"||n.kind==="source"?n.evaluate({zoom:0,brightness:l,worldview:p},e,i,s,r,u)==="none":typeof n=="string"&&n==="none")}Qe(Gl,"SymbolPropertiesUBO",{omit:["headerBuffer","propertiesBuffer","blockIndicesBuffer"]});
7class ny{constructor(e,i,r,s,l="",u,p){this.layer=e,this.zoom=i,this.lut=r,this.isText=s,this.propDefs=this._getPropDefs(),this.worldview=l,this.maxUniformBufferBindings=u||24,this.uboSizeDwords=p||4096,this.featureVertexRangesFromId=new Map,this.allFeatures=[],this.ubos=[],this.featureCount=0,this.cachedHeader=null,this.maxFeaturesPerBatch=0,this.propertyHashToUBOIndex=new Map,this.canDeduplicate=this._checkIfAllPropertiesAreConstant(e,s),this.cachedParams=null,this.cachedParamsNext=null,this.cachedBrightness=void 0,this.cachedConstantUniforms=null,this.cachedConstantRenderZoom=null,this.cachedConstantBrightness=void 0,this.activeAppearanceByVtIndex=new Map,this.isLightConstant=!0,this._evalFlat=new Float32Array(Gl.EVAL_FLAT_TOTAL)}_getPropDefs(){let e=this.isText?"text":"icon";return[{name:`${e}-color`,useThemeName:`${e}-color-use-theme`,isColor:!0},{name:`${e}-halo-color`,useThemeName:`${e}-halo-color-use-theme`,isColor:!0},{name:`${e}-opacity`,useThemeName:null,isColor:!1},{name:`${e}-halo-width`,useThemeName:null,isColor:!1},{name:`${e}-halo-blur`,useThemeName:null,isColor:!1},{name:`${e}-emissive-strength`,useThemeName:null,isColor:!1},{name:`${e}-occlusion-opacity`,useThemeName:null,isColor:!1},{name:"symbol-z-offset",useThemeName:null,isColor:!1},{name:`${e}-translate`,useThemeName:null,isColor:!1,isVec2:!0}]}buildHeader(){let e=this.layer.paint,i=this.propDefs,r=0,s=0,l=0,u=0,p=!0,f=[0,0,0,0,0,0,0,0,0];for(let x=0;x<9;x++){let{name:b,isColor:w,isVec2:S}=i[x],E=e.get(b),M=!(!E||typeof E.isConstant!="function"||E.isConstant()),C=this._appearancesHavePaintProperties(b),R=M||C,F=!(!E||!E.value||E.value.kind!=="composite"),z=this.layer._transitionablePaint._values[b],j=!R&&(z&&z.value&&z.value.expression&&z.value.expression.kind)==="camera";if(R){r|=1<<x,F&&(s|=1<<x);let $=E&&E.value;$&&$.isLightConstant===!1&&(p=!1),w?(u%4!=0&&(u=u+3&-4),f[x]=u,u+=4):S?F?(u%4!=0&&(u=u+3&-4),f[x]=u,u+=4):(u%4==3&&u++,f[x]=u,u+=2):(f[x]=u,u+=F?2:1)}else j&&(l|=1<<x)}let g=(u===0?0:u+3&-4)/4;return this.isLightConstant=p,{dataDrivenMask:r,zoomDependentMask:s,cameraMask:l,dataDrivenBlockSizeVec4:g,offsets:f}}get hasCameraExpression(){return!(!this.cachedHeader||!this.cachedHeader.cameraMask)}evaluateAllProperties(e,i,r,s,l,u,p){let{params:f,paramsNext:g}=this._getCachedParams(l),x={feature:e,featureState:i,canonical:r,availableImages:s,params:f,paramsNext:g,formattedSection:u},b=this.cachedHeader,w=this.propDefs;this._evalFlat||(this._evalFlat=new Float32Array(Gl.EVAL_FLAT_TOTAL));let S=this._evalFlat;for(let E=0;E<9;E++){let{name:M,useThemeName:C,isColor:R,isVec2:F}=w[E],z=!!(b&&b.zoomDependentMask&1<<E),j=Gl.EVAL_FLAT_OFFSETS[E];R?this._evaluateColorValue(M,C,x,l,z,p,S,j):F?this._evaluateTranslateValue(M,z,x,p,S,j):this._evaluateFloatValue(M,z,x,p,S,j)}return S}_evaluateColorValue(e,i,r,s,l,u,p,f){let g=this.layer.paint,x=e,b=u&&u.hasPaintProperty(x)?u.paintProperties.get(x):g.get(e),w=i,S=i&&u&&u.hasPaintProperty(w)?u.paintProperties.get(w):i?g.get(i):void 0;if(!b)return p[f]=0,p[f+1]=0,p[f+2]=0,void(p[f+3]=1);let E=Mx(S&&typeof S!="string"?S.value:void 0,r.feature,r.featureState,r.availableImages,r.canonical,s,r.formattedSection,this.worldview)?null:this.lut,M,C;b.isConstant()?M=C=b.constantOr(jt.transparent):(M=b.property.evaluate(b.value,r.params,r.feature,r.featureState,r.canonical,r.availableImages,b.iconImageUseTheme,r.formattedSection),C=l?b.property.evaluate(b.value,r.paramsNext,r.feature,r.featureState,r.canonical,r.availableImages,b.iconImageUseTheme,r.formattedSection):M);let R=(M||jt.transparent).toNonPremultipliedRenderColor(E);if(p[f]=Ol(255*R.r,255*R.g),p[f+1]=Ol(255*R.b,255*R.a),l){let F=(C||jt.transparent).toNonPremultipliedRenderColor(E);p[f+2]=Ol(255*F.r,255*F.g),p[f+3]=Ol(255*F.b,255*F.a)}else p[f+2]=0,p[f+3]=0}_evaluateFloatValue(e,i,r,s,l,u){let p=this.layer.paint,f=e.endsWith("opacity")?1:0,g=e,x=s&&s.hasPaintProperty(g)?s.paintProperties.get(g):p.get(e);if(!x)return l[u]=f,void(l[u+1]=0);if(x.isConstant())return l[u]=x.constantOr(f),void(l[u+1]=0);let b=x.property.evaluate(x.value,r.params,r.feature,r.featureState,r.canonical,r.availableImages,x.iconImageUseTheme,r.formattedSection);if(l[u]=b??f,i){let w=x.property.evaluate(x.value,r.paramsNext,r.feature,r.featureState,r.canonical,r.availableImages,x.iconImageUseTheme,r.formattedSection);l[u+1]=w??f}else l[u+1]=0}_evaluateTranslateValue(e,i,r,s,l,u){let p=this.layer.paint,f=e,g=s&&s.hasPaintProperty(f)?s.paintProperties.get(f):p.get(e);if(!g)return l[u]=0,l[u+1]=0,l[u+2]=0,void(l[u+3]=0);if(typeof g.isConstant!="function"){let b=g||[0,0];return l[u]=b[0],l[u+1]=b[1],l[u+2]=0,void(l[u+3]=0)}if(g.isConstant()){let b=g.constantOr([0,0]);return l[u]=b[0],l[u+1]=b[1],l[u+2]=0,void(l[u+3]=0)}let x=g.property.evaluate(g.value,r.params,r.feature,r.featureState,r.canonical,r.availableImages,g.iconImageUseTheme,r.formattedSection)||[0,0];if(l[u]=x[0],l[u+1]=x[1],i){let b=g.property.evaluate(g.value,r.paramsNext,r.feature,r.featureState,r.canonical,r.availableImages,g.iconImageUseTheme,r.formattedSection)||[0,0];l[u+2]=b[0],l[u+3]=b[1]}else l[u+2]=0,l[u+3]=0}_getCachedParams(e){return this.cachedParams&&this.cachedParamsNext&&this.cachedBrightness===e||(this.cachedParams=new Xt(this.zoom,{brightness:e,worldview:this.worldview}),this.cachedParamsNext=new Xt(this.zoom+1,{brightness:e,worldview:this.worldview}),this.cachedBrightness=e),{params:this.cachedParams,paramsNext:this.cachedParamsNext}}_appearancesHavePaintProperties(e){return this.layer.getAppearances().some(e!==void 0?i=>i.hasPaintProperty(e):this.isText?i=>i.hasTextPaintProperties():i=>i.hasIconPaintProperties())}_checkIfAllPropertiesAreConstant(e,i){let r=e.paint,s=i?"text":"icon",l=[`${s}-color`,`${s}-halo-color`,`${s}-opacity`,`${s}-halo-width`,`${s}-halo-blur`,`${s}-emissive-strength`,`${s}-occlusion-opacity`,"symbol-z-offset",`${s}-translate`];for(let u of l){let p=r.get(u);if(p&&typeof p=="object"&&"isConstant"in p&&!p.isConstant())return!1}return!this._appearancesHavePaintProperties()}_hashDataDrivenValues(e,i){if(i.dataDrivenMask===0)return"";let r=[];for(let s=0;s<this.propDefs.length;s++){if(!(i.dataDrivenMask&1<<s))continue;let l=Gl.EVAL_FLAT_OFFSETS[s],u=Gl.EVAL_FLAT_SIZES[s],p=String(e[l]);for(let f=1;f<u;f++)p+=`,${String(e[l+f])}`;r.push(p)}return r.join("|")}getCurrentBatchIndex(){return this.cachedHeader&&this.maxFeaturesPerBatch!==0?Math.floor(this.featureCount/this.maxFeaturesPerBatch):0}populateUBO(e,i,r,s,l,u,p){let f=e.id;if(!this.cachedHeader){this.cachedHeader=this.buildHeader();let C=Gl.getMaxFeatureCount(this.cachedHeader,this.uboSizeDwords);this.maxFeaturesPerBatch=isFinite(C)?C:Number.MAX_SAFE_INTEGER}let g=this.cachedHeader,x=this.evaluateAllProperties(e,{},r,s,l,u);if(this.canDeduplicate){let C=this._hashDataDrivenValues(x,g),R=this.propertyHashToUBOIndex.get(C);if(R!==void 0){let F=isFinite(this.maxFeaturesPerBatch)?Math.floor(R/this.maxFeaturesPerBatch):0,z=isFinite(this.maxFeaturesPerBatch)?R%this.maxFeaturesPerBatch:R,j={batchIndex:F,localFeatureIndex:z,vtFeatureIndex:i,featureId:f};return this.allFeatures.push(j),f!=null&&(this.featureVertexRangesFromId.has(f)||this.featureVertexRangesFromId.set(f,[]),this.featureVertexRangesFromId.get(f).push(j)),z}this.propertyHashToUBOIndex.set(C,this.featureCount)}
7let b=this.featureCount++,w=isFinite(this.maxFeaturesPerBatch)?Math.floor(b/this.maxFeaturesPerBatch):0,S=isFinite(this.maxFeaturesPerBatch)?b%this.maxFeaturesPerBatch:b,E=p?p.maxUniformBufferBindings:this.maxUniformBufferBindings;if(3*w+2>=E){Ot(`Too many symbol features: batch ${w} requires binding points up to ${3*w+2}, device limit ${E}. Some features will render incorrectly.`);let C={batchIndex:0,localFeatureIndex:0,vtFeatureIndex:i,featureId:f};return this.allFeatures.push(C),f!=null&&(this.featureVertexRangesFromId.has(f)||this.featureVertexRangesFromId.set(f,[]),this.featureVertexRangesFromId.get(f).push(C)),0}this.ubos[w]||(this.ubos[w]=new Gl(p,w,this.uboSizeDwords),this.ubos[w].writeHeader(g)),this.ubos[w].writeDataDrivenBlock(x,S,g);let M={batchIndex:w,localFeatureIndex:S,vtFeatureIndex:i,featureId:f};return this.allFeatures.push(M),f!=null&&(this.featureVertexRangesFromId.has(f)||this.featureVertexRangesFromId.set(f,[]),this.featureVertexRangesFromId.get(f).push(M)),S}updateFeatures(e,i,r,s,l,u,p){if(this.layer=i,this.cachedConstantUniforms=null,!this.cachedHeader)return;let f=this.cachedHeader;for(let g of e){let x=this.featureVertexRangesFromId.get(g);if(!x)continue;let b=u[g]||{};for(let w of x){if(!r)continue;let S=r.feature(w.vtFeatureIndex);if(!S)continue;let E={type:S.type,id:g,properties:S.properties||{},geometry:[]},M=this.activeAppearanceByVtIndex?this.activeAppearanceByVtIndex.get(w.vtFeatureIndex):void 0,C=this.evaluateAllProperties(E,b,s,l,p,void 0,M);this.ubos[w.batchIndex]&&this.ubos[w.batchIndex].writeDataDrivenBlock(C,w.localFeatureIndex,f)}}}updateDynamicExpressions(e,i,r,s,l,u){if(this.layer=e,this.cachedConstantUniforms=null,!this.cachedHeader||this.cachedHeader.dataDrivenMask===0)return;let p=this.cachedHeader;for(let f of this.allFeatures){if(!i)continue;let g=i.feature(f.vtFeatureIndex);if(!g)continue;let x=f.featureId!=null&&l[f.featureId]||{},b={type:g.type,id:f.featureId,properties:g.properties||{},geometry:[]},w=this.activeAppearanceByVtIndex?this.activeAppearanceByVtIndex.get(f.vtFeatureIndex):void 0,S=this.evaluateAllProperties(b,x,r,s,u,void 0,w);this.ubos[f.batchIndex]&&this.ubos[f.batchIndex].writeDataDrivenBlock(S,f.localFeatureIndex,p)}}updateFeaturePaintForAppearance(e,i,r,s,l,u,p){if(!this.layer||(this.activeAppearanceByVtIndex||(this.activeAppearanceByVtIndex=new Map),this.activeAppearanceByVtIndex.set(e,p||null),!this.cachedHeader))return!1;let f=this.cachedHeader;if(f.dataDrivenMask===0)return!1;let g=!1;for(let x of this.allFeatures){if(x.vtFeatureIndex!==e)continue;let b=this.evaluateAllProperties(i,r,s,l,u,void 0,p);this.ubos[x.batchIndex]&&(this.ubos[x.batchIndex].writeDataDrivenBlock(b,x.localFeatureIndex,f),g=!0)}return g}getConstantUniformValues(e,i){let r=this.cachedHeader,s=!(!r||!r.cameraMask);if(this.cachedConstantUniforms&&this.cachedConstantBrightness===i&&(!s||this.cachedConstantRenderZoom===e))return this.cachedConstantUniforms;let l=this.layer.paint,u=this.propDefs,p=s?new Xt(e,{brightness:i,worldview:this.worldview}):null,f={type:1,id:void 0,properties:{},geometry:[]},g=w=>{let S=u[w],E=l.get(S.name);if(!E)return[0,0,0,1];let M=S.useThemeName?l.get(S.useThemeName):void 0,C=Mx(M&&typeof M!="string"?M.value:void 0,f,{},[],void 0,i,void 0,this.worldview)?null:this.lut,R;R=r&&r.cameraMask&1<<w&&p?E.property.evaluate(E.value,p,f,{},void 0,[]):E.constantOr(jt.transparent);let F=(R||jt.transparent).toNonPremultipliedRenderColor(C);return[F.r,F.g,F.b,F.a]},x=(w,S)=>{let E=l.get(u[w].name);if(!E)return S;if(r&&r.cameraMask&1<<w&&p){let M=E.property.evaluate(E.value,p,f,{},void 0,[]);return M??S}return E.constantOr(S)},b={fill_np_color:g(0),halo_np_color:g(1),opacity:x(2,1),halo_width:x(3,0),halo_blur:x(4,0),emissive_strength:x(5,0),occlusion_opacity:x(6,1),z_offset:x(7,0)};return this.cachedConstantUniforms=b,this.cachedConstantRenderZoom=e,this.cachedConstantBrightness=i,b}upload(e){for(let i of this.ubos)i.upload(e)}bind(e,i,r=0){this.ubos[r]&&this.ubos[r].bind(e,i)}destroy(){for(let e of this.ubos)e.destroy();this.ubos=[],this.featureVertexRangesFromId.clear(),this.allFeatures=[],this.featureCount=0,this.cachedHeader=null,this.maxFeaturesPerBatch=0,this.propertyHashToUBOIndex&&this.propertyHashToUBOIndex.clear()}}Qe(ny,"SymbolPropertyBinderUBO",{omit:["layer","cachedParams","cachedParamsNext","cachedBrightness","propertyHashToUBOIndex","cachedConstantUniforms","cachedConstantRenderZoom","cachedConstantBrightness","activeAppearanceByVtIndex","_evalFlat"]});var Tn=24;function hw(n,e,i){return n.sections.forEach(r=>{r.text=function(s,l,u){let p=l.layout.get("text-transform").evaluate(u,{});return p==="uppercase"?s=s.toLocaleUpperCase():p==="lowercase"&&(s=s.toLocaleLowerCase()),Qo.applyArabicShaping&&(s=Qo.applyArabicShaping(s)),s}(r.text,e,i)}),n}let Mp={"!":"\uFE15","#":"\uFF03",$:"\uFF04","%":"\uFF05","&":"\uFF06","(":"\uFE35",")":"\uFE36","*":"\uFF0A","+":"\uFF0B",",":"\uFE10","-":"\uFE32",".":"\u30FB","/":"\uFF0F",":":"\uFE13",";":"\uFE14","<":"\uFE3F","=":"\uFF1D",">":"\uFE40","?":"\uFE16","@":"\uFF20","[":"\uFE47","\\":"\uFF3C","]":"\uFE48","^":"\uFF3E",_:"\uFE33","`":"\uFF40","{":"\uFE37","|":"\u2015","}":"\uFE38","~":"\uFF5E","\xA2":"\uFFE0","\xA3":"\uFFE1","\xA5":"\uFFE5","\xA6":"\uFFE4","\xAC":"\uFFE2","\xAF":"\uFFE3","\u2013":"\uFE32","\u2014":"\uFE31","\u2018":"\uFE43","\u2019":"\uFE44","\u201C":"\uFE41","\u201D":"\uFE42","\u2026":"\uFE19","\u2027":"\u30FB","\u20A9":"\uFFE6","\u3001":"\uFE11","\u3002":"\uFE12","\u3008":"\uFE3F","\u3009":"\uFE40","\u300A":"\uFE3D","\u300B":"\uFE3E","\u300C":"\uFE41","\u300D":"\uFE42","\u300E":"\uFE43","\u300F":"\uFE44","\u3010":"\uFE3B","\u3011":"\uFE3C","\u3014":"\uFE39","\u3015":"\uFE3A","\u3016":"\uFE17","\u3017":"\uFE18","\uFF01":"\uFE15","\uFF08":"\uFE35","\uFF09":"\uFE36","\uFF0C":"\uFE10","\uFF0D":"\uFE32","\uFF0E":"\u30FB","\uFF1A":"\uFE13","\uFF1B":"\uFE14","\uFF1C":"\uFE3F","\uFF1E":"\uFE40","\uFF1F":"\uFE16","\uFF3B":"\uFE47","\uFF3D":"\uFE48","\uFF3F":"\uFE33","\uFF5B":"\uFE37","\uFF5C":"\u2015","\uFF5D":"\uFE38","\uFF5F":"\uFE35","\uFF60":"\uFE36","\uFF61":"\uFE12","\uFF62":"\uFE41","\uFF63"
vendor: 9,145 bytes, line 7
7:"\uFE42","\u2190":"\u2191","\u2192":"\u2193"};function dw(n){return n==="\uFE36"||n==="\uFE48"||n==="\uFE38"||n==="\uFE44"||n==="\uFE42"||n==="\uFE3E"||n==="\uFE3C"||n==="\uFE3A"||n==="\uFE18"||n==="\uFE40"||n==="\uFE10"||n==="\uFE13"||n==="\uFE14"||n==="\uFF40"||n==="\uFFE3"||n==="\uFE11"||n==="\uFE12"}function pw(n){return n==="\uFE35"||n==="\uFE47"||n==="\uFE37"||n==="\uFE43"||n==="\uFE41"||n==="\uFE3D"||n==="\uFE3B"||n==="\uFE39"||n==="\uFE17"||n==="\uFE3F"}let ry=4294967296,Cx=1/ry,Px=typeof TextDecoder>"u"?null:new TextDecoder("utf-8"),c_=class{constructor(n=new Uint8Array(16)){this.buf=ArrayBuffer.isView(n)?n:new Uint8Array(n),this.dataView=new DataView(this.buf.buffer),this.pos=0,this.type=0,this.length=this.buf.length}readFields(n,e,i=this.length){for(;this.pos<i;){let r=this.readVarint(),s=r>>3,l=this.pos;this.type=7&r,n(s,e,this),this.pos===l&&this.skip(r)}return e}readMessage(n,e){return this.readFields(n,e,this.readVarint()+this.pos)}readFixed32(){let n=this.dataView.getUint32(this.pos,!0);return this.pos+=4,n}readSFixed32(){let n=this.dataView.getInt32(this.pos,!0);return this.pos+=4,n}readFixed64(){let n=this.dataView.getUint32(this.pos,!0)+this.dataView.getUint32(this.pos+4,!0)*ry;return this.pos+=8,n}readSFixed64(){let n=this.dataView.getUint32(this.pos,!0)+this.dataView.getInt32(this.pos+4,!0)*ry;return this.pos+=8,n}readFloat(){let n=this.dataView.getFloat32(this.pos,!0);return this.pos+=4,n}readDouble(){let n=this.dataView.getFloat64(this.pos,!0);return this.pos+=8,n}readVarint(n){let e=this.buf,i,r;return r=e[this.pos++],i=127&r,r<128?i:(r=e[this.pos++],i|=(127&r)<<7,r<128?i:(r=e[this.pos++],i|=(127&r)<<14,r<128?i:(r=e[this.pos++],i|=(127&r)<<21,r<128?i:(r=e[this.pos],i|=(15&r)<<28,function(s,l,u){let p=u.buf,f,g;if(g=p[u.pos++],f=(112&g)>>4,g<128||(g=p[u.pos++],f|=(127&g)<<3,g<128)||(g=p[u.pos++],f|=(127&g)<<10,g<128)||(g=p[u.pos++],f|=(127&g)<<17,g<128)||(g=p[u.pos++],f|=(127&g)<<24,g<128)||(g=p[u.pos++],f|=(1&g)<<31,g<128))return wh(s,f,l);throw new Error("Expected varint not more than 10 bytes")}(i,n,this)))))}readVarint64(){return this.readVarint(!0)}readSVarint(){let n=this.readVarint();return n%2==1?(n+1)/-2:n/2}readBoolean(){return!!this.readVarint()}readString(){let n=this.readVarint()+this.pos,e=this.pos;return this.pos=n,n-e>=12&&Px?Px.decode(this.buf.subarray(e,n)):function(i,r,s){let l="",u=r;for(;u<s;){let p=i[u],f,g,x,b=null,w=p>239?4:p>223?3:p>191?2:1;if(u+w>s)break;w===1?p<128&&(b=p):w===2?(f=i[u+1],(192&f)==128&&(b=(31&p)<<6|63&f,b<=127&&(b=null))):w===3?(f=i[u+1],g=i[u+2],(192&f)==128&&(192&g)==128&&(b=(15&p)<<12|(63&f)<<6|63&g,(b<=2047||b>=55296&&b<=57343)&&(b=null))):w===4&&(f=i[u+1],g=i[u+2],x=i[u+3],(192&f)==128&&(192&g)==128&&(192&x)==128&&(b=(15&p)<<18|(63&f)<<12|(63&g)<<6|63&x,(b<=65535||b>=1114112)&&(b=null))),b===null?(b=65533,w=1):b>65535&&(b-=65536,l+=String.fromCharCode(b>>>10&1023|55296),b=56320|1023&b),l+=String.fromCharCode(b),u+=w}return l}(this.buf,e,n)}readBytes(){let n=this.readVarint()+this.pos,e=this.buf.subarray(this.pos,n);return this.pos=n,e}readPackedVarint(n=[],e){let i=this.readPackedEnd();for(;this.pos<i;)n.push(this.readVarint(e));return n}readPackedSVarint(n=[]){let e=this.readPackedEnd();for(;this.pos<e;)n.push(this.readSVarint());return n}readPackedBoolean(n=[]){let e=this.readPackedEnd();for(;this.pos<e;)n.push(this.readBoolean());return n}readPackedFloat(n=[]){let e=this.readPackedEnd();for(;this.pos<e;)n.push(this.readFloat());return n}readPackedDouble(n=[]){let e=this.readPackedEnd();for(;this.pos<e;)n.push(this.readDouble());return n}readPackedFixed32(n=[]){let e=this.readPackedEnd();for(;this.pos<e;)n.push(this.readFixed32());return n}readPackedSFixed32(n=[]){let e=this.readPackedEnd();for(;this.pos<e;)n.push(this.readSFixed32());return n}readPackedFixed64(n=[]){let e=this.readPackedEnd();for(;this.pos<e;)n.push(this.readFixed64());return n}readPackedSFixed64(n=[]){let e=this.readPackedEnd();for(;this.pos<e;)n.push(this.readSFixed64());return n}readPackedEnd(){return this.type===2?this.readVarint()+this.pos:this.pos+1}skip(n){let e=7&n;if(e===0)for(;this.buf[this.pos++]>127;);else if(e===2)this.pos=this.readVarint()+this.pos;else if(e===5)this.pos+=4;else{if(e!==1)throw new Error(`Unimplemented type: ${e}`);this.pos+=8}}writeTag(n,e){this.writeVarint(n<<3|e)}realloc(n){let e=this.length||16;for(;e<this.pos+n;)e*=2;if(e!==this.length){let i=new Uint8Array(e);i.set(this.buf),this.buf=i,this.dataView=new DataView(i.buffer),this.length=e}}finish(){return this.length=this.pos,this.pos=0,this.buf.subarray(0,this.length)}writeFixed32(n){this.realloc(4),this.dataView.setInt32(this.pos,n,!0),this.pos+=4}writeSFixed32(n){this.realloc(4),this.dataView.setInt32(this.pos,n,!0),this.pos+=4}writeFixed64(n){this.realloc(8),this.dataView.setInt32(this.pos,-1&n,!0),this.dataView.setInt32(this.pos+4,Math.floor(n*Cx),!0),this.pos+=8}writeSFixed64(n){this.realloc(8),this.dataView.setInt32(this.pos,-1&n,!0),this.dataView.setInt32(this.pos+4,Math.floor(n*Cx),!0),this.pos+=8}writeVarint(n){(n=+n||0)>268435455||n<0?function(e,i){let r,s;if(e>=0?(r=e%4294967296|0,s=e/4294967296|0):(r=~(-e%4294967296),s=~(-e/4294967296),4294967295^r?r=r+1|0:(r=0,s=s+1|0)),e>=18446744073709552e3||e<-18446744073709552e3)throw new Error("Given varint doesn't fit into 10 bytes");i.realloc(10),function(l,u,p){p.buf[p.pos++]=127&l|128,l>>>=7,p.buf[p.pos++]=127&l|128,l>>>=7,p.buf[p.pos++]=127&l|128,l>>>=7,p.buf[p.pos++]=127&l|128,p.buf[p.pos]=127&(l>>>=7)}(r,0,i),function(l,u){let p=(7&l)<<4;u.buf[u.pos++]|=p|((l>>>=3)?128:0),l&&(u.buf[u.pos++]=127&l|((l>>>=7)?128:0),l&&(u.buf[u.pos++]=127&l|((l>>>=7)?128:0),l&&(u.buf[u.pos++]=127&l|((l>>>=7)?128:0),l&&(u.buf[u.pos++]=127&l|((l>>>=7)?128:0),l&&(u.buf[u.pos++]=127&l)))))}(s,i)}(n,this):(this.realloc(4),this.buf[this.pos++]=127&n|(n>127?128:0),n<=127||(this.buf[this.pos++]=127&(n>>>=7)|(n>127?128:0),n<=127||(this.buf[this.pos++]=127&(n>>>=7)|(n>127?128:0),n<=127||(this.buf[this.pos++]=n>>>7&127))))}writeSVarint(n){this.writeVarint(n<0?2*-n-1:2*n)}writeBoolean(n){this.writeVarint(+n)}writeString(n){n=String(n),this.realloc(4*n.length),this.pos++;let e=this.pos;this.pos=function(r,s,l){for(let u,p,f=0;f<s.length;f++){if(u=s.charCodeAt(f),u>55295&&u<57344){if(!p){u>56319||f+1===s.length?(r[l++]=239,r[l++]=191,r[l++]=189):p=u;continue}if(u<56320){r[l++]=239,r[l++]=191,r[l++]=189,p=u;continue}u=p-55296<<10|u-56320|65536,p=null}else p&&(r[l++]=239,r[l++]=191,r[l++]=189,p=null);u<128?r[l++]=u:(u<2048?r[l++]=u>>6|192:(u<65536?r[l++]=u>>12|224:(r[l++]=u>>18|240,r[l++]=u>>12&63|128),r[l++]=u>>6&63|128),r[l++]=63&u|128)}return l}(this.buf,n,this.pos);let i=this.pos-e;i>=128&&Dx(e,i,this),this.pos=e-1,this.writeVarint(i),this.pos+=i}writeFloat(n){this.realloc(4),this.dataView.setFloat32(this.pos,n,!0),this.pos+=4}writeDouble(n){this.realloc(8),this.dataView.setFloat64(this.pos,n,!0),this.pos+=8}writeBytes(n){let e=n.length;this.writeVarint(e),this.realloc(e);for(let i=0;i<e;i++)this.buf[this.pos++]=n[i]}writeRawMessage(n,e){this.pos++;let i=this.pos;n(e,this);let r=this.pos-i;r>=128&&Dx(i,r,this),this.pos=i-1,this.writeVarint(r),this.pos+=r}writeMessage(n,e,i){this.writeTag(n,2),this.writeRawMessage(e,i)}writePackedVarint(n,e){e.length&&this.writeMessage(n,fw,e)}writePackedSVarint(n,e){e.length&&this.writeMessage(n,mw,e)}writePackedBoolean(n,e){e.length&&this.writeMessage(n,yw,e)}writePackedFloat(n,e){e.length&&this.writeMessage(n,_w,e)}writePackedDouble(n,e){e.length&&this.writeMessage(n,gw,e)}writePackedFixed32(n,e){e.length&&this.writeMessage(n,xw,e)}writePackedSFixed32(n,e){e.length&&this.writeMessage(n,vw,e)}writePackedFixed64(n,e){e.length&&this.writeMessage(n,bw,e)}writePackedSFixed64(n,e){e.length&&this.writeMessage(n,ww,e)}writeBytesField(n,e){this.writeTag(n,2),this.writeBytes(e)}writeFixed32Field(n,e){this.writeTag(n,5),this.writeFixed32(e)}writeSFixed32Field(n,e){this.writeTag(n,5),this.writeSFixed32(e)}writeFixed64Field(n,e){this.writeTag(n,1),this.writeFixed64(e)}writeSFixed64Field(n,e){this.writeTag(n,1),this.writeSFixed64(e)}writeVarintField(n,e){this.writeTag(n,0),this.writeVarint(e)}writeSVarintField(n,e){this.writeTag(n,0),this.writeSVarint(e)}writeStringField(n,e){this.writeTag(n,2),this.writeString(e)}writeFloatField(n,e){this.writeTag(n,5),this.writeFloat(e)}writeDoubleField(n,e){this.writeTag(n,1),this.writeDouble(e)}writeBooleanField(n,e){this.writeVarintField(n,+e)}};function wh(n,e,i){return i?4294967296*e+(n>>>0):4294967296*(e>>>0)+(n>>>0)}function Dx(n,e,i){let r=e<=16383?1:e<=2097151?2:e<=268435455?3:Math.floor(Math.log(e)/(7*Math.LN2));i.realloc(r);for(let s=i.pos-1;s>=n;s--)i.buf[s+r]=i.buf[s]}function fw(n,e){for(let i=0;i<n.length;i++)e.writeVarint(n[i])}function mw(n,e){for(let i=0;i<n.length;i++)e.writeSVarint(n[i])}function _w(n,e){for(let i=0;i<n.length;i++)e.writeFloat(n[i])}function gw(n,e){for(let i=0;i<n.length;i++)e.writeDouble(n[i])}function yw(n,e){for(let i=0;i<n.length;i++)e.writeBoolean(n[i])}function xw(n,e){for(let i=0;i<n.length;i++)e.writeFixed32(n[i])}function vw(n,e){for(let i=0;i<n.length;i++)e.writeSFixed32(n[i])}function bw(n,e){for(let i=0;i<n.length;
7i++)e.writeFixed64(n[i])}function ww(n,e){for(let i=0;i<n.length;i++)e.writeSFixed64(n[i])}function Tw(n,e,i){e.glyphs=[],n===1&&i.readMessage(Sw,e)}function Sw(n,e,i){if(n===3){let{id:r,bitmap:s,width:l,height:u,left:p,top:f,advance:g}=i.readMessage(Iw,{});e.glyphs.push({id:r,bitmap:new Ri({width:l+6,height:u+6},s),metrics:{width:l,height:u,left:p,top:f,advance:g}})}else n===4?e.ascender=i.readSVarint():n===5&&(e.descender=i.readSVarint())}function Iw(n,e,i){n===1?e.id=i.readVarint():n===2?e.bitmap=i.readBytes():n===3?e.width=i.readVarint():n===4?e.height=i.readVarint():n===5?e.left=i.readSVarint():n===6?e.top=i.readSVarint():n===7&&(e.advance=i.readVarint())}let Zr={horizontal:1,vertical:2,horizontalOnly:3};class Cp{constructor(){this.scale=1,this.fontStack="",this.image=null}static forText(e,i){let r=new Cp;return r.scale=e||1,r.fontStack=i,r}static forImage(e){let i=new Cp;return i.image=e,i}}class Th{constructor(){this.text="",this.sectionIndex=[],this.sections=[],this.imageSectionID=null}static fromFeature(e,i,r,s=1){let l=new Th;for(let u=0;u<e.sections.length;u++){let p=e.sections[u];p.image?l.addImageSection(p,r,s):l.addTextSection(p,i)}return l}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(i,r){let s="";for(let l=0;l<i.length;l++){let u=i.charCodeAt(l+1)||null,p=i.charCodeAt(l-1)||null;s+=!r&&(u&&Ku(u)&&!Mp[i[l+1]]||p&&Ku(p)&&!Mp[i[l-1]])||!Mp[i[l]]?i[l]:Mp[i[l]]}return s}(this.text,e)}trim(){let e=0;for(let r=0;r<this.text.length&&u_[this.text.charCodeAt(r)];r++)e++;let i=this.text.length;for(let r=this.text.length-1;r>=0&&r>=e&&u_[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 Th;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(Cp.forText(e.scale,e.fontStack||i));let r=this.sections.length-1;for(let s=0;s<e.text.length;++s)this.sectionIndex.push(r)}addImageSection(e,i,r=1){let s=e.image?e.image.getPrimary():null;if(!s)return void Ot("Can't add FormattedSection with an empty image.");s.scaleSelf(i*r);let l=this.getNextImageSectionCharCode();l?(this.text+=String.fromCodePoint(l),this.sections.push(Cp.forImage(s)),this.sectionIndex.push(this.sections.length-1)):Ot("Reached maximum number of images 6401")}getNextImageSectionCharCode(){return this.imageSectionID?this.imageSectionID>=63743?null:++this.imageSectionID:(this.imageSectionID=57344,this.imageSectionID)}}function oy(n,e,i,r,s,l,u,p,f,g,x,b,w,S,E,M=1,C=1){let R=Th.fromFeature(n,s,M,C);b===Zr.vertical&&R.verticalizePunctuation(w);let F=[],z=function(W,Q,Y,ee,me,ge,Te=1){if(!W)return[];let Ae=[],Ee=function(Se,Me,ze,Le,We,De,Ge=1){let He=0;for(let Je=0;Je<Se.length();Je++){let tt=Se.getSection(Je);He+=Rx(Se.getCodePoint(Je),tt,Le,We,Me,De,Ge)}return He/Math.max(1,Math.ceil(He/ze))}(W,Q,Y,ee,me,ge,Te),Be=W.text.includes("\u200B"),xe=0;for(let Se=0;Se<W.length();Se++){let Me=W.getSection(Se),ze=W.getCodePoint(Se);if(u_[ze]||(xe+=Rx(ze,Me,ee,me,Q,ge,Te)),Se<W.length()-1){let Le=Wf(ze);(Ew[ze]||Le||Me.image)&&Ae.push(Lx(Se+1,xe,Ee,Ae,Aw(ze,W.getCodePoint(Se+1),Le&&Be),!1))}}return Ox(Lx(W.length(),xe,Ee,Ae,0,!0))}(R,g,l,e,r,S,C),{processBidirectionalText:j,processStyledBidirectionalText:$}=Qo;if(j&&R.sections.length===1){let W=j(R.toString(),z);for(let Q of W){let Y=new Th;Y.text=Q,Y.sections=R.sections;for(let ee=0;ee<Q.length;ee++)Y.sectionIndex.push(0);F.push(Y)}}else if($){let W=$(R.text,R.sectionIndex,z);for(let Q of W){let Y=new Th;Y.text=Q[0],Y.sectionIndex=Q[1],Y.sections=R.sections,F.push(Y)}}else F=function(W,Q){let Y=[],ee=W.text,me=0;for(let ge of Q)Y.push(W.substring(me,ge)),me=ge;return me<ee.length&&Y.push(W.substring(me,ee.length)),Y}(R,z);let H=[],ie={positionedLines:H,text:R.toString(),top:x[1],bottom:x[1],left:x[0],right:x[0],writingMode:b,iconsInText:!1,verticalizable:!1,hasBaseline:!1};if(function(W,Q,Y,ee,me,ge,Te,Ae,Ee,Be,xe,Se,Me=1){let ze=0,Le=0,We=0,De=Ae==="right"?1:Ae==="left"?0:.5,Ge=!1;for(let rt of me){let pt=rt.getSections();for(let Ht of pt){if(Ht.image)continue;let wt=Q[Ht.fontStack];if(wt&&(Ge=wt.ascender!==void 0&&wt.descender!==void 0,!Ge))break}if(!Ge)break}let He=0;for(let rt of me){rt.trim();let pt=rt.getMaxScale(),Ht=(pt-1)*Tn,wt={positionedGlyphs:[],lineOffset:0};W.positionedLines[He]=wt;let kt=wt.positionedGlyphs,At=0;if(!rt.length()){Le+=ge,++He;continue}let Ui=0,Jt=0;for(let ui=0;ui<rt.length();ui++){let Mi=rt.getSection(ui),Sn=rt.getSectionIndex(ui),mi=rt.getCodePoint(ui),Vi=Mi.scale,un=null,en=null,hn=null,Pt=Tn,Un=0,lr=Ee;lr===Zr.vertical&&Xf(mi)&&(lr=Zr.horizontal);let Ki=!(lr===Zr.horizontal||!xe&&!Ju(mi)||xe&&(u_[mi]||zd(mi)));if(Mi.image){let Cn=ee.get(Mi.image.toString());if(!Cn)continue;hn=Mi.image,W.iconsInText=W.iconsInText||!0,en=Cn.paddedRect;let Qn=Cn.displaySize,Vn=Qn[0]*Me,zi=Qn[1]*Me;Vi=Vi*Tn/Se,un={width:Vn,height:zi,left:0,top:-3,advance:Ki?zi:Vn,localGlyph:!1},Un=Ge?-un.height*Vi:pt*Tn-17-zi*Vi,Pt=un.advance;let _n=(Ki?Vn:zi)*Vi-Tn*pt;_n>0&&_n>At&&(At=_n)}else{let Cn=Y[Mi.fontStack];if(!Cn)continue;Cn[mi]&&(en=Cn[mi]);let Qn=Q[Mi.fontStack];if(!Qn)continue;let Vn=Qn.glyphs[mi];if(!Vn)continue;if(un=Vn.metrics,Pt=mi!==8203?Tn:0,Ge){let zi=Qn.ascender!==void 0?Math.abs(Qn.ascender):0,_n=Qn.descender!==void 0?Math.abs(Qn.descender):0,Mr=(zi+_n)*Vi;Ui<Mr&&(Ui=Mr,Jt=(zi-_n)/2*Vi),Un=-zi*Vi}else Un=(pt-Vi)*Tn-17}Ki?(W.verticalizable=!0,kt.push({glyph:mi,image:hn,x:ze,y:Le+Un,vertical:Ki,scale:Vi,localGlyph:un.localGlyph,fontStack:Mi.fontStack,sectionIndex:Sn,metrics:un,rect:en}),ze+=Pt*Vi+Be):(kt.push({glyph:mi,image:hn,x:ze,y:Le+Un,vertical:Ki,scale:Vi,localGlyph:un.localGlyph,fontStack:Mi.fontStack,sectionIndex:Sn,metrics:un,rect:en}),ze+=un.advance*Vi+Be)}kt.length!==0&&(We=Math.max(ze-Be,We),Ge?Fx(kt,De,At,Jt,ge*pt/2):Fx(kt,De,At,0,ge/2)),ze=0;let Gt=ge*pt+At;wt.lineOffset=Math.max(At,Ht),Le+=Gt,++He}let Je=Le,{horizontalAlign:tt,verticalAlign:lt}=sy(Te);(function(rt,pt,Ht,wt,kt,At){let Ui=(pt-Ht)*kt,Jt=-At*wt;for(let Gt of rt)for(let ui of Gt.positionedGlyphs)ui.x+=Ui,ui.y+=Jt})(W.positionedLines,De,tt,lt,We,Je),W.top+=-lt*Je,W.bottom=W.top+Je,W.left+=-tt*We,W.right=W.left+We,W.hasBaseline=Ge}(ie,e,i,r,F,u,p,f,b,g,w,E,C),!function(W){for(let Q of W)if(Q.positionedGlyphs.length!==0)return!1;return!0}(H))return ie}let u_={9:!0,10:!0,11:!0,12:!0,13:!0,32:!0},Ew={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 Rx(n,e,i,r,s,l,u=1){if(e.image){let p=r.get(e.image.toString());return p?p.displaySize[0]*u*e.scale*Tn/l+s:0}{let p=i[e.fontStack],f=p&&p.glyphs[n];return f?f.metrics.advance*e.scale+s:0}}function zx(n,e,i,r){let s=Math.pow(n-e,2);return r?n<e?s/2:2*s:s+Math.abs(i)*i}function Aw(n,e,i){let r=0;return n===10&&(r-=1e4),i&&(r+=150),n!==40&&n!==65288||(r+=50),e!==41&&e!==65289||(r+=50),r}function Lx(n,e,i,r,s,l){let u=null,p=zx(e,i,s,l);for(let f of r){let g=zx(e-f.x,i,s,l)+f.badness;g<=p&&(u=f,p=g)}return{index:n,x:e,priorBreak:u,badness:p}}function Ox(n){return n?Ox(n.priorBreak).concat(n.index):[]}function sy(n){let e=.5,i=.5;
7switch(n){case"right":case"top-right":case"bottom-right":e=1;break;case"left":case"top-left":case"bottom-left":e=0}switch(n){case"bottom":case"bottom-right":case"bottom-left":i=1;break;case"top":case"top-right":case"top-left":i=0}return{horizontalAlign:e,verticalAlign:i}}function Fx(n,e,i,r,s){if(!(e||i||r||s))return;let l=n.length-1,u=n[l],p=(u.x+u.metrics.advance*u.scale)*e;for(let f=0;f<=l;f++)n[f].x-=p,n[f].y+=i+r+s}function ay(n){return n.imagePrimary!==void 0&&n.top!==void 0&&n.bottom!==void 0&&n.left!==void 0&&n.right!==void 0}function h_(n,e,i,r){let{horizontalAlign:s,verticalAlign:l}=sy(r),u=i[0]-n.displaySize[0]*s,p=i[1]-n.displaySize[1]*l;return{imagePrimary:n,imageSecondary:e,top:p,bottom:p+n.displaySize[1],left:u,right:u+n.displaySize[0]}}function ly(n,e,i,r,s,l){let u=n.imagePrimary,p;if(u.content){let C=u.content,R=u.pixelRatio||1;p=[C[0]/R,C[1]/R,u.displaySize[0]-C[2]/R,u.displaySize[1]-C[3]/R]}let f=e.left*l,g=e.right*l,x,b,w,S;i==="width"||i==="both"?(S=s[0]+f-r[3],b=s[0]+g+r[1]):(S=s[0]+(f+g-u.displaySize[0])/2,b=S+u.displaySize[0]);let E=e.top*l,M=e.bottom*l;return i==="height"||i==="both"?(x=s[1]+E-r[0],w=s[1]+M+r[2]):(x=s[1]+(E+M-u.displaySize[1])/2,w=x+u.displaySize[1]),{imagePrimary:u,imageSecondary:void 0,top:x,right:b,bottom:w,left:S,collisionPadding:p}}function Bx(n){return!n.imagePrimary.stretchX}function kx(n){return!n.imagePrimary.stretchY}function Nx(n){return{width:n.right-n.left,height:n.bottom-n.top}}let $a=128;function ru(n,e,i,r){let{expression:s}=e;if(s.kind==="constant")return{kind:"constant",layoutSize:s.evaluate(new Xt(n+1,{worldview:i}),void 0,void 0,void 0,r)};if(s.kind==="source")return{kind:"source"};{let{zoomStops:l,interpolationType:u}=s,p=0;for(;p<l.length&&l[p]<=n;)p++;p=Math.max(0,p-1);let f=p;for(;f<l.length&&l[f]<n+1;)f++;f=Math.min(l.length-1,f);let g=l[p],x=l[f];return s.kind==="composite"?{kind:"composite",minZoom:g,maxZoom:x,interpolationType:u}:{kind:"camera",minZoom:g,maxZoom:x,minSize:s.evaluate(new Xt(g,{worldview:i}),void 0,void 0,void 0,r),maxSize:s.evaluate(new Xt(x,{worldview:i}),void 0,void 0,void 0,r),interpolationType:u}}}function cy(n,{uSize:e,uSizeT:i},{lowerSize:r,upperSize:s}){return n.kind==="source"?r/$a:n.kind==="composite"?ft(r/$a,s/$a,i):e}function Sh(n,e,i=1){let r=0,s=0;if(n.kind==="constant")s=n.layoutSize*i;else if(n.kind!=="source"){let{interpolationType:l,minZoom:u,maxZoom:p}=n,f=l?ne(Tr.interpolationFactor(l,e,u,p),0,1):0;n.kind==="camera"?s=ft(n.minSize,n.maxSize,f)*i:r=f*i}return{uSizeT:r,uSize:s}}class Ha extends ke{constructor(e,i,r,s,l){super(e,i),this.angle=s,this.z=r,l!==void 0&&(this.segment=l)}clone(){return new Ha(this.x,this.y,this.z,this.angle,this.segment)}}function Ux(n,e,i,r,s){if(e.segment===void 0)return!0;let l=e,u=e.segment+1,p=0;for(;p>-i/2;){if(u--,u<0)return!1;p-=n[u].dist(l),l=n[u]}p+=n[u].dist(n[u+1]),u++;let f=[],g=0;for(;p<i/2;){let x=n[u],b=n[u+1];if(!b)return!1;let w=n[u-1].angleTo(x)-x.angleTo(b);for(w=Math.abs((w+3*Math.PI)%(2*Math.PI)-Math.PI),f.push({distance:p,angleDelta:w}),g+=w;p-f[0].distance>r;)g-=f.shift().angleDelta;if(g>s)return!1;u++,p+=x.dist(b)}return!0}function Vx(n){let e=0;for(let i=0;i<n.length-1;i++)e+=n[i].dist(n[i+1]);return e}function jx(n,e,i){return n?.6*e*i:0}function Gx(n,e){return Math.max(n?n.right-n.left:0,e?e.right-e.left:0)}function Mw(n,e,i,r,s,l){let u=jx(i,s,l),p=Gx(i,r)*l,f=0,g=Vx(n)/2;for(let x=0;x<n.length-1;x++){let b=n[x],w=n[x+1],S=b.dist(w);if(f+S>g){let E=(g-f)/S,M=ft(b.x,w.x,E),C=ft(b.y,w.y,E),R=new Ha(M,C,0,w.angleTo(b),x);return!u||Ux(n,R,p,u,e)?R:void 0}f+=S}}function Cw(n,e,i,r,s,l,u,p,f){let g=jx(r,l,u),x=Gx(r,s),b=x*u,w=n[0].x===0||n[0].x===f||n[0].y===0||n[0].y===f;return e-b<e/4&&(e=b+e/4),$x(n,w?e/2*p%e:(x/2+2*l)*u*p%e,e,g,i,b,w,!1,f)}function $x(n,e,i,r,s,l,u,p,f){let g=l/2,x=Vx(n),b=0,w=e-i,S=[];for(let E=0;E<n.length-1;E++){let M=n[E],C=n[E+1],R=M.dist(C),F=C.angleTo(M);for(;w+i<b+R;){w+=i;let z=(w-b)/R,j=ft(M.x,C.x,z),$=ft(M.y,C.y,z);if(j>=0&&j<f&&$>=0&&$<f&&w-g>=0&&w+g<=x){let H=new Ha(j,$,0,F,E);r&&!Ux(n,H,l,r,s)||S.push(H)}}b+=R}return p||S.length||u||(S=$x(n,b/2,i,r,s,l,u,!0,f)),S}function Hx(n){let e=0,i=0;for(let u of n)e+=u.w*u.h,i=Math.max(i,u.w);n.sort((u,p)=>p.h-u.h);let r=[{x:0,y:0,w:Math.max(Math.ceil(Math.sqrt(e/.95)),i),h:1/0}],s=0,l=0;for(let u of n)for(let p=r.length-1;p>=0;p--){let f=r[p];if(!(u.w>f.w||u.h>
7f.h)){if(u.x=f.x,u.y=f.y,l=Math.max(l,u.y+u.h),s=Math.max(s,u.x+u.w),u.w===f.w&&u.h===f.h){let g=r.pop();g&&p<r.length&&(r[p]=g)}else u.h===f.h?(f.x+=u.w,f.w-=u.w):u.w===f.w?(f.y+=u.h,f.h-=u.h):(r.push({x:f.x+u.w,y:f.y,w:f.w-u.w,h:u.h}),f.y+=u.h,f.h-=u.h);break}}return{w:s,h:l,fill:e/(s*l)||0}}function d_(n,e){return n.id<e.id?-1:n.id>e.id?1:n.version<e.version?-1:n.version>e.version?1:n.sx<e.sx?-1:n.sx>e.sx?1:n.sy<e.sy?-1:n.sy>e.sy?1:0}function uy(n){let e=0;for(let i=0;i<n.length;i++)e=(e<<5)-e+n.charCodeAt(i),e&=e;return e}function us(n,e){return(n<<5)-n+e}function qx(n,e,i,r){for(let[s]of n.entries()){let l=r&&r.get(s)||xr.parse(s),u=l.id.toString(),p=e.get(u)||0;i.push({id:s,version:p,sx:l.sx,sy:l.sy})}}Qe(Ha,"Anchor");class hy{constructor(e,i,r,s,l){this.iconDescriptors=[],this.patternDescriptors=[],this.requiresMipMaps=i.size>0,qx(e,r,this.iconDescriptors,l),qx(i,r,this.patternDescriptors,l),this.iconDescriptors.sort(d_),this.patternDescriptors.sort(d_);let u=0,p=s?s.data:"";p&&(u=us(u,uy(p))),u=us(u,1);for(let f of this.iconDescriptors)u=us(u,uy(f.id)),u=us(u,f.version),u=us(u,f.sx),u=us(u,f.sy);u=us(u,1);for(let f of this.patternDescriptors)u=us(u,uy(f.id)),u=us(u,f.version),u=us(u,f.sx),u=us(u,f.sy);this.hash=u}subsetOf(e){return this.isSubsetArray(this.iconDescriptors,e.iconDescriptors,d_)&&this.isSubsetArray(this.patternDescriptors,e.patternDescriptors,d_)}isSubsetArray(e,i,r){let s=0,l=0;if(e.length>i.length)return!1;for(;s<e.length&&l<i.length;){let u=r(e[s],i[l]);if(u===0)s++,l++;else{if(u<0)return!1;l++}}return s===e.length}}Qe(hy,"AtlasContentDescriptor");class Pp{static getImagePositionScale(e,i,r){if(i&&e){let{sx:s,sy:l}=e;return{x:s,y:l}}return{x:r,y:r}}constructor(e,i,r,s){this.paddedRect=e;let{pixelRatio:l,version:u,stretchX:p,stretchY:f,content:g,sdf:x,usvg:b}=i;this.pixelRatio=l,this.stretchX=p,this.stretchY=f,this.content=g,this.version=u,this.padding=r,this.sdf=x,this.usvg=b,this.scale=Pp.getImagePositionScale(s,b,l)}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 dy(n,e,i){let r=xr.parse(n),s=function(l,u,p=[1,1]){return{x:0,y:0,w:(l.data?l.data.width:l.width*p[0])+2*u,h:(l.data?l.data.height:l.height*p[1])+2*u}}(e,i,[r.sx,r.sy]);return{bin:s,imagePosition:new Pp(s,e,i,r),imageVariant:r}}function py(n,e){let i=[];for(let[s,l]of n.entries()){let u=xr.parse(s);u&&(i.push({key:s,value:l,variant:u}),e&&e.set(s,u))}i.sort((s,l)=>{let u=s.variant.id.toString().localeCompare(l.variant.id.toString());return u!==0?u:s.variant.sx!==l.variant.sx?s.variant.sx-l.variant.sx:s.variant.sy!==l.variant.sy?s.variant.sy-l.variant.sy:0});let r=new Map;for(let s of i)r.set(s.key,s.value);return r}class Zx{constructor(e){this.sourceAtlasHash=e}}class Wx{constructor(e,i,r,s){let l=new Map,u=new Map;this.haveRenderCallbacks=[];let p=[],f=s!==void 0,g=f?new Map:void 0,x=f?py(e,g):e,b=f?py(i,g):i;this.addImages(x,l,1,p),this.addImages(b,u,2,p);let{w,h:S}=Hx(p),E=new Ni({width:w||1,height:S||1});for(let[M,C]of x.entries()){let R=l.get(M).paddedRect;Ni.copy(C.data,E,{x:0,y:0},{x:R.x+1,y:R.y+1},C.data,null,C.sdf)}for(let[M,C]of b.entries()){let R=u.get(M),F=R.paddedRect,z=R.padding,j=F.x+z,$=F.y+z,H=C.data.width,ie=C.data.height;z=z>1?z-1:z,Ni.copy(C.data,E,{x:0,y:0},{x:j,y:$},C.data,r),Ni.copy(C.data,E,{x:0,y:ie-z},{x:j,y:$-z},{width:H,height:z},r),Ni.copy(C.data,E,{x:0,y:0},{x:j,y:$+ie},{width:H,height:z},r),Ni.copy(C.data,E,{x:H-z,y:0},{x:j-z,y:$},{width:z,height:ie},r),Ni.copy(C.data,E,{x:0,y:0},{x:j+H,y:$},{width:z,height:ie},r),Ni.copy(C.data,E,{x:H-z,y:ie-z},{x:j-z,y:$-z},{width:z,height:z},r),Ni.copy(C.data,E,{x:0,y:ie-z},{x:j+H,y:$-z},{width:z,height:z},r),Ni.copy(C.data,E,{x:0,y:0},{x:j+H,y:$+ie},{width:z,height:z},r),Ni.copy(C.data,E,{x:H-z,y:0},{x:j-z,y:$+ie},{width:z,height:z},r)}this.lut=r,this.image=E,this.iconPositions=l,this.patternPositions=u,f&&(this.contentDescriptor=new hy(x,b,s,r,g))}addImages(e,i,r,s){for(let[l,u]of e.entries()){let{bin:p,imagePosition:f,imageVariant:g}=dy(l,u,r);i.set(l,f),s.push(p),u.hasRenderCallback&&this.haveRenderCallbacks.push(g.id)}}patchUpdatedImages(e,i,r,s){this.haveRenderCallbacks=this.haveRenderCallbacks.filter(l=>e.hasImage(l,r)),e.dispatchRenderCallbacks(this.haveRenderCallbacks,r);for(let l of e.getUpdatedImages(r)){for(let u of this.iconPositions.keys()){let p=xr.parse(u);if(yr.isEqual(p.id,l)){let f=e.getImage(l,r);this.patchUpdatedImage(this.iconPositions.get(u),f,i,null)}}for(let u of this.patternPositions.keys()){let p=xr.parse(u);if(yr.isEqual(p.id,l)){let f=e.getImage(l,r);this.patchUpdatedImage(this.patternPositions.get(u),f,i,s||this.lut)}}}}patchUpdatedImage(e,i,r,s=null){if(!e||!i||e.version===i.version)return;e.version=i.version;let[l,u]=e.tl,p=e.sdf;if(this.lut||p){let f={width:i.data.width,height:i.data.height},g=new Ni(f);Ni.copy(i.data,g,{x:0,y:0},{x:0,y:0},f,s,p),r.update(g,{position:{x:l,y:u},recreateWhenResize:!1})}else r.update(i.data,{position:{x:l,y:u},recreateWhenResize:!1})}}Qe(Pp,"ImagePosition"),Qe(Wx,"ImageAtlas",{omit:["lut"]}
7),Qe(Zx,"ImageAtlasReference");class Dp{constructor(e){this.pendingRequests=new Map,this.cachedRanges=new Map,this.fontstackCompositing=e&&e.fontstackCompositing||"client"}loadGlyphRange(e,i,r,s,l){if(this.fontstackCompositing==="server")return void Dp.loadGlyphRange(e,i,r,s,l);let u=e.split(",").map(p=>p.trim()).filter(p=>p.length>0);u.length!==0?u.length!==1?this._loadMultipleFonts(u,i,r,s,l):this._loadFont(u[0],i,r,s,l):l(new Error("Empty fontstack"))}_loadMultipleFonts(e,i,r,s,l){let u=e.map(()=>null),p={completed:0,firstError:null,callbackCalled:!1},f=(g,x,b)=>{if(!p.callbackCalled&&(x&&!p.firstError&&(p.firstError=x),b&&(u[g]=b),p.completed++,p.completed===e.length)){p.callbackCalled=!0;let w=u.filter(E=>E!==null);if(w.length===0)return void l(p.firstError||new Error("All fonts failed to load"));let S=this._composeGlyphs(w);l(null,S)}};for(let g=0;g<e.length;g++)this._loadFont(e[g],i,r,s,(x,b)=>{f(g,x,b)})}_loadFont(e,i,r,s,l){let u=`${e}:${i}`;if(this.cachedRanges.has(u)){let f=this.cachedRanges.get(u);return void xn.frame(()=>l(null,f))}let p=this.pendingRequests.get(u);p?p.push(l):(this.pendingRequests.set(u,[l]),Dp.loadGlyphRange(e,i,r,s,(f,g)=>{f||this.cachedRanges.set(u,g||null);let x=this.pendingRequests.get(u);if(this.pendingRequests.delete(u),x)for(let b of x)b(f,g)}))}_composeGlyphs(e){let i={},r,s;for(let l of e)if(r===void 0&&l.ascender!==void 0&&(r=l.ascender),s===void 0&&l.descender!==void 0&&(s=l.descender),l.glyphs)for(let u in l.glyphs)i[u]===void 0&&(i[u]=l.glyphs[u]);return{glyphs:i,ascender:r,descender:s}}}Dp.loadGlyphRange=function(n,e,i,r,s){let l=256*e,u=l+255,p=r.transformRequest(r.normalizeGlyphsURL(i).replace("{fontstack}",n).replace("{range}",`${l}-${u}`),bs.Glyphs);nl(p,(f,g)=>{if(f)s(f);else if(g){let x={},b=function(w){return new c_(w).readFields(Tw,{})}(g);for(let w of b.glyphs)x[w.id]=w;s(null,{glyphs:x,ascender:b.ascender,descender:b.descender})}})};let Rp=1e20,fy=new Float64Array(256);for(let n=0;n<256;n++){let e=.5-Math.pow(n/255,.45454545454545453);fy[n]=e*Math.abs(e)}function Xx(n,e,i,r,s,l,u,p,f){for(let g=e;g<e+r;g++)Yx(n,i*l+g,l,s,u,p,f);for(let g=i;g<i+s;g++)Yx(n,g*l+e,1,r,u,p,f)}function Yx(n,e,i,r,s,l,u){l[0]=0,u[0]=-Rp,u[1]=Rp,s[0]=n[e];for(let p=1,f=0,g=0;p<r;p++){s[p]=n[e+p*i];let x=p*p;do{let b=l[f];g=(s[p]-s[b]+x-b*b)/(p-b)/2}while(g<=u[f]&&--f>-1);f++,l[f]=p,u[f]=g,u[f+1]=Rp}for(let p=0,f=0;p<r;p++){for(;u[f+1]<p;)f++;let g=l[f],x=p-g;n[e+p*i]=s[g]+x*x}}fy[255]=-Rp;let Pw=/bold/i,Dw=/medium/i,Rw=/light/i,my={none:0,ideographs:1,all:2};class p_{constructor(e,i,r,s){this.requestManager=e,this.localGlyphMode=i,this.localFontFamily=r,this.url="",this.entries={},this.localGlyphs={200:{},400:{},500:{},900:{}},this.glyphLoader=new Dp({fontstackCompositing:s})}setURL(e){this.url=e}prefetchRange(e,i){let r=this.url||di.GLYPHS_URL;if(!r)return;let s=this.entries[e];s||(s=this.entries[e]={glyphs:{},requests:{},ranges:{}}),s.ranges[i]||s.requests[i]||(s.requests[i]=[],this.glyphLoader.loadGlyphRange(e,i,r,this.requestManager,(l,u)=>{if(u){s.ascender=u.ascender,s.descender=u.descender;for(let p in u.glyphs)this._doesCharSupportLocalGlyph(+p)||(s.glyphs[+p]=u.glyphs[+p]);s.ranges[i]=!0}for(let p of s.requests[i]||[])p(l,u);delete s.requests[i]}))}getGlyphs(e,i){let r=[],s=this.url||di.GLYPHS_URL;for(let l in e)for(let u of e[l])r.push({stack:l,id:u});Oe(r,({stack:l,id:u},p)=>{let f=this.entries[l];f||(f=this.entries[l]={glyphs:{},requests:{},ranges:{},ascender:void 0,descender:void 0});let g=f.glyphs[u];if(g!==void 0)return void p(null,{stack:l,id:u,glyph:g});if(g=this._tinySDF(f,l,u),g)return f.glyphs[u]=g,void p(null,{stack:l,id:u,glyph:g});let x=Math.floor(u/256);if(256*x>65535)return Ot("glyphs > 65535 not supported"),void p(null,{stack:l,id:u,glyph:g});if(f.ranges[x])return void p(null,{stack:l,id:u,glyph:g});let b=f.requests[x];b||(b=f.requests[x]=[],this.glyphLoader.loadGlyphRange(l,x,s,this.requestManager,(w,S)=>{if(S){f.ascender=S.ascender,f.descender=S.descender;for(let E in S.glyphs)this._doesCharSupportLocalGlyph(+E)||(f.glyphs[+E]=S.glyphs[+E]);f.ranges[x]=!0}for(let E of b)E(w,S);delete f.requests[x]}
7)),b.push((w,S)=>{w?p(w):S&&p(null,{stack:l,id:u,glyph:S.glyphs[u]||null})})},(l,u)=>{if(l)i(l);else if(u){let p={};for(let{stack:f,id:g,glyph:x}of u)p[f]===void 0&&(p[f]={}),p[f].glyphs===void 0&&(p[f].glyphs={}),p[f].glyphs[g]=x&&{id:x.id,bitmap:x.bitmap.clone(),metrics:x.metrics},p[f].ascender=this.entries[f].ascender,p[f].descender=this.entries[f].descender;i(null,p)}})}_doesCharSupportLocalGlyph(e){return this.localGlyphMode!==my.none&&(this.localGlyphMode===my.all?!!this.localFontFamily:!!this.localFontFamily&&(Cd(e)||$f(e)||Id(e)||Lc(e)||za(e)||Md(e)||(i=e)>=131072&&i<=173791||(r=>r>=66736&&r<=66815)(e)));var i}_tinySDF(e,i,r){let s=this.localFontFamily;if(!s||!this._doesCharSupportLocalGlyph(r))return;let l=e.tinySDF;if(!l){let C="400";Pw.test(i)?C="900":Dw.test(i)?C="500":Rw.test(i)&&(C="200"),l=e.tinySDF=new p_.TinySDF({fontFamily:s,fontWeight:C,fontSize:48,buffer:6,radius:16}),l.fontWeight=C}let u=l.fontWeight;if(this.localGlyphs[u][r])return this.localGlyphs[u][r];let p=String.fromCodePoint(r),{data:f,width:g,height:x,glyphWidth:b,glyphHeight:w,glyphLeft:S,glyphTop:E,glyphAdvance:M}=l.draw(p);return this.localGlyphs[u][r]={id:r,bitmap:new Ri({width:g,height:x},f),metrics:{width:b/2,height:w/2,left:S/2,top:E/2-27,advance:M/2,localGlyph:!0}}}}function Jx(n,e){return n+e[1]-e[0]}function _y(n,e,i,r,s=1){let l=[],u=n.imagePrimary,p=u.pixelRatio,f=u.paddedRect.w-2,g=u.paddedRect.h-2,x=(n.right-n.left)*s,b=(n.bottom-n.top)*s,w=u.stretchX||[[0,f]],S=u.stretchY||[[0,g]],E=w.reduce(Jx,0),M=S.reduce(Jx,0),C=f-E,R=g-M,F=0,z=E,j=0,$=M,H=0,ie=C,W=0,Q=R;if(u.content&&r){let ee=u.content;F=f_(w,0,ee[0]),j=f_(S,0,ee[1]),z=f_(w,ee[0],ee[2]),$=f_(S,ee[1],ee[3]),H=ee[0]-F,W=ee[1]-j,ie=ee[2]-ee[0]-z,Q=ee[3]-ee[1]-$}let Y=(ee,me,ge,Te)=>{let Ae=m_(ee.stretch-F,z,x,n.left*s),Ee=__(ee.fixed-H,ie,ee.stretch,E),Be=m_(me.stretch-j,$,b,n.top*s),xe=__(me.fixed-W,Q,me.stretch,M),Se=m_(ge.stretch-F,z,x,n.left*s),Me=__(ge.fixed-H,ie,ge.stretch,E),ze=m_(Te.stretch-j,$,b,n.top*s),Le=__(Te.fixed-W,Q,Te.stretch,M),We=new ke(Ae,Be),De=new ke(Se,Be),Ge=new ke(Se,ze),He=new ke(Ae,ze),Je=new ke(Ee/p,xe/p),tt=new ke(Me/p,Le/p),lt=e*Math.PI/180;if(lt){let At=Math.sin(lt),Ui=Math.cos(lt),Jt=[Ui,-At,At,Ui];We._matMult(Jt),De._matMult(Jt),He._matMult(Jt),Ge._matMult(Jt)}let rt=ee.stretch+ee.fixed,pt=ge.stretch+ge.fixed,Ht=me.stretch+me.fixed,wt=Te.stretch+Te.fixed,kt=n.imageSecondary;return{tl:We,tr:De,bl:He,br:Ge,texPrimary:{x:u.paddedRect.x+1+rt,y:u.paddedRect.y+1+Ht,w:pt-rt,h:wt-Ht},texSecondary:kt?{x:kt.paddedRect.x+1+rt,y:kt.paddedRect.y+1+Ht,w:pt-rt,h:wt-Ht}:void 0,writingMode:void 0,glyphOffset:[0,0],sectionIndex:0,pixelOffsetTL:Je,pixelOffsetBR:tt,minFontScaleX:ie/p/x,minFontScaleY:Q/p/b,isSDF:i}};if(u.stretchX||u.stretchY){let ee=Kx(w,C,E),me=Kx(S,R,M);for(let ge=0;ge<ee.length-1;ge++){let Te=ee[ge],Ae=ee[ge+1];for(let Ee=0;Ee<me.length-1;Ee++)l.push(Y(Te,me[Ee],Ae,me[Ee+1]))}}else l.push(Y({fixed:0,stretch:-1},{fixed:0,stretch:-1},{fixed:0,stretch:f+1},{fixed:0,stretch:g+1}));return l}function zw(n,e){let i=n.stretchY||[[0,n.paddedRect.h-2]];return n.stretchX||n.stretchY?Qx(n.stretchX||[[0,n.paddedRect.w-2]])*Qx(i):1}function f_(n,e,i){let r=0;for(let s of n)r+=Math.max(e,Math.min(i,s[1]))-Math.max(e,Math.min(i,s[0]));return r}function Kx(n,e,i){let r=[{fixed:-1,stretch:0}];for(let[s,l]of n){let u=r.at(-1);r.push({fixed:s-u.stretch,stretch:u.stretch}),r.push({fixed:s-u.stretch,stretch:u.stretch+(l-s)})}return r.push({fixed:e+1,stretch:i}),r}function Qx(n){return 2*n.length+1}function m_(n,e,i,r){return n/e*i+r}function __(n,e,i,r){return n-e*i/r}function Lw(n,e,i,r){let s=e+n.positionedLines[r].lineOffset;return r===0?i+s/2:i+(s+(e+n.positionedLines[r-1].lineOffset))/2}function ev(n,e,i,r,s,l,u,p,f,g=1){let x=[];if(e.positionedLines.length===0)return x;let b=(f!==void 0?f:r.layout.get("text-rotate").evaluate(l,{}))*Math.PI/180,w=function(R){let F=R[0],z=R[1],j=F*z;return j>0?[F,-z]:j<0?[-F,z]:F===0?[z,F]:[z,-F]}(i),S=Math.abs(e.top-e.bottom);for(let R of e.positionedLines)S-=R.lineOffset;let E=e.positionedLines.length,M=S/E,C=e.top-i[1];for(let R=0;R<E;++R){let F=e.positionedLines[R];C=Lw(e,M,C,R);for(let z of F.positionedGlyphs){if(!z.rect)continue;let j=z.rect||{},$=4,H=!0,ie=1,W=0;if(z.image){let Ge=u.get(z.image.toString());if(!Ge)continue;if(Ge.sdf){Ot("SDF images are not supported in formatted text and will be ignored.");continue}H=!1,ie=Ge.pixelRatio,$=1/ie,Ge.usvg||(ie/=g)}let Q=(s||p)&&z.vertical,Y=z.metrics.advance*z.scale/2,ee=z.metrics,me=z.re
7ct;if(me===null)continue;p&&e.verticalizable&&(W=z.image?Y-z.metrics.width*z.scale/2:0);let ge=s?[z.x+Y,z.y]:[0,0],Te=[0,0],Ae=[0,0],Ee=!1;s||(Q?(Ae=[z.x+Y+w[0],z.y+w[1]-W],Ee=!0):Te=[z.x+Y+i[0],z.y+i[1]-W]);let Be=me.w*z.scale/(ie*(z.localGlyph?2:1)),xe=me.h*z.scale/(ie*(z.localGlyph?2:1)),Se,Me,ze,Le;if(Q){let Ge=z.y-C,He=new ke(-Y,Y-Ge),Je=-Math.PI/2,tt=new ke(...Ae);Se=new ke(-Y+Te[0],Te[1]),Se._rotateAround(Je,He)._add(tt),Se.x+=-Ge+Y,Se.y-=(ee.left-$)*z.scale;let lt=z.image?ee.advance*z.scale:Tn*z.scale,rt=String.fromCodePoint(z.glyph);dw(rt)?Se.x+=(1-$)*z.scale:pw(rt)?Se.x+=lt-ee.height*z.scale+(-$-1)*z.scale:Se.x+=z.image||ee.width+2*$===me.w&&ee.height+2*$===me.h?(lt-xe)/2:(lt-(ee.height+2*$)*z.scale)/2,Me=new ke(Se.x,Se.y-Be),ze=new ke(Se.x+xe,Se.y),Le=new ke(Se.x+xe,Se.y-Be)}else{let Ge=(ee.left-$)*z.scale-Y+Te[0],He=(-ee.top-$)*z.scale+Te[1],Je=Ge+Be,tt=He+xe;Se=new ke(Ge,He),Me=new ke(Je,He),ze=new ke(Ge,tt),Le=new ke(Je,tt)}if(b){let Ge;Ge=s?new ke(0,0):Ee?new ke(w[0],w[1]):new ke(i[0],i[1]),Se._rotateAround(b,Ge),Me._rotateAround(b,Ge),ze._rotateAround(b,Ge),Le._rotateAround(b,Ge)}let We=new ke(0,0),De=new ke(0,0);x.push({tl:Se,tr:Me,bl:ze,br:Le,texPrimary:j,texSecondary:void 0,writingMode:e.writingMode,glyphOffset:ge,sectionIndex:z.sectionIndex,isSDF:H,pixelOffsetTL:We,pixelOffsetBR:De,minFontScaleX:0,minFontScaleY:0})}}return x}function Ow(n,e=1,i=!1){let r=1/0,s=1/0,l=-1/0,u=-1/0,p=n[0];for(let S=0;S<p.length;S++){let E=p[S];(!S||E.x<r)&&(r=E.x),(!S||E.y<s)&&(s=E.y),(!S||E.x>l)&&(l=E.x),(!S||E.y>u)&&(u=E.y)}let f=Math.min(l-r,u-s),g=f/2,x=new dt([],Fw);if(f===0)return new ke(r,s);for(let S=r;S<l;S+=f)for(let E=s;E<u;E+=f)x.push(new Ih(S+g,E+g,g,n));let b=function(S){let E=0,M=0,C=0,R=S[0];for(let F=0,z=R.length,j=z-1;F<z;j=F++){let $=R[F],H=R[j],ie=$.x*H.y-H.x*$.y;M+=($.x+H.x)*ie,C+=($.y+H.y)*ie,E+=3*ie}return new Ih(M/E,C/E,0,S)}(n),w=x.length;for(;x.length;){let S=x.pop();(S.d>b.d||!b.d)&&(b=S,i&&console.log("found best %d after %d probes",Math.round(1e4*S.d)/1e4,w)),S.max-b.d<=e||(g=S.h/2,x.push(new Ih(S.p.x-g,S.p.y-g,g,n)),x.push(new Ih(S.p.x+g,S.p.y-g,g,n)),x.push(new Ih(S.p.x-g,S.p.y+g,g,n)),x.push(new Ih(S.p.x+g,S.p.y+g,g,n)),w+=4)}return i&&(console.log(`num probes: ${w}`),console.log(`best distance: ${b.d}`)),b.p}function Fw(n,e){return e.max-n.max}p_.TinySDF=class{constructor({fontSize:n=24,buffer:e=3,radius:i=8,cutoff:r=.25,fontFamily:s="sans-serif",fontWeight:l="normal",fontStyle:u="normal",lang:p=null}={}){this.buffer=e,this.radius=i,this.cutoff=r,this.lang=p;let f=this.size=n+4*e,g=this._createCanvas(f),x=this.ctx=g.getContext("2d",{willReadFrequently:!0});x.font=`${u} ${l} ${n}px ${s}`,x.textBaseline="alphabetic",x.textAlign="left",x.fillStyle="black",this.gridOuter=new Float64Array(f*f),this.gridInner=new Float64Array(f*f),this.f=new Float64Array(f),this.z=new Float64Array(f+1),this.v=new Uint16Array(f)}_createCanvas(n){if(typeof OffscreenCanvas<"u")return new OffscreenCanvas(n,n);let e=document.createElement("canvas");return e.width=e.height=n,e}draw(n){let{width:e,actualBoundingBoxAscent:i,actualBoundingBoxDescent:r,actualBoundingBoxLeft:s,actualBoundingBoxRight:l}=this.ctx.measureText(n),u=Math.ceil(i),p=Math.floor(s),f=Math.max(0,Math.min(this.size-this.buffer,Math.ceil(l)-p)),g=Math.max(0,Math.min(this.size-this.buffer,u+Math.ceil(r))),x=f+2*this.buffer,b=g+2*this.buffer,w=Math.max(x*b,0),S=new Uint8ClampedArray(w),E={data:S,width:x,height:b,glyphWidth:f,glyphHeight:g,glyphTop:u,glyphLeft:p,glyphAdvance:e};if(f===0||g===0)return E;let{ctx:M,buffer:C,gridInner:R,gridOuter:F}=this;this.lang&&(M.lang=this.lang),M.clearRect(C,C,f,g),M.fillText(n,C-p,C+u);let z=M.getImageData(C,C,f,g);F.fill(Rp,0,w),R.fill(0,0,w);let j=3;for(let ie=0;ie<g;ie++){let W=(ie+C)*x+C;for(let Q=0;Q<f;Q++,j+=4,W++){let Y=z.data[j];if(Y===0)continue;let ee=fy[Y];F[W]=Math.max(0,ee),R[W]=Math.max(0,-ee)}}Xx(F,0,0,x,b,x,this.f,this.v,this.z),Xx(R,C,C,f,g,x,this.f,this.v,this.z);let $=255/this.radius,H=255*(1-this.cutoff);for(let ie=0;ie<w;ie++){let W=Math.sqrt(F[ie])-Math.sqrt(R[ie]);S[ie]=Math.round(H-$*W)}return E}};
7class Ih{constructor(e,i,r,s){this.p=new ke(e,i),this.h=r,this.d=function(l,u){let p=!1,f=1/0;for(let g=0;g<u.length;g++){let x=u[g];for(let b=0,w=x.length,S=w-1;b<w;S=b++){let E=x[b],M=x[S];E.y>l.y!=M.y>l.y&&l.x<(M.x-E.x)*(l.y-E.y)/(M.y-E.y)+E.x&&(p=!p),f=Math.min(f,A(l,E,M))}}return(p?1:-1)*Math.sqrt(f)}(this.p,s),this.max=this.d+this.h*Math.SQRT2}}let Bw=Object.keys,gy=Number.POSITIVE_INFINITY,kw=Math.sqrt(2);function $l(n,e,i,r,s,l){let u=ay(n)&&n.collisionPadding?n.collisionPadding:[0,0,0,0],p={top:n.top-u[1],bottom:n.bottom+u[3],left:n.left-u[0],right:n.right+u[2],scaled:!1};return r!==void 0&&function(f,g){f.top*=g,f.bottom*=g,f.left*=g,f.right*=g,f.scaled=!0}(p,r),l&&(p.left+=l[0],p.right+=l[0],p.top+=l[1],p.bottom+=l[1]),i&&function(f,g,x){if(!g)return;let b=V(g),w=new ke(x?x[0]:0,x?x[1]:0),S=new ke(f.left,f.top),E=new ke(f.right,f.top),M=new ke(f.left,f.bottom),C=new ke(f.right,f.bottom);S._rotateAround(b,w),E._rotateAround(b,w),M._rotateAround(b,w),C._rotateAround(b,w),f.left=Math.min(S.x,E.x,M.x,C.x),f.right=Math.max(S.x,E.x,M.x,C.x),f.top=Math.min(S.y,E.y,M.y,C.y),f.bottom=Math.max(S.y,E.y,M.y,C.y)}(p,i,s),e?{top:Math.min(e.top,p.top),bottom:Math.max(e.bottom,p.bottom),left:Math.min(e.left,p.left),right:Math.max(e.right,p.right),scaled:e.scaled||p.scaled}:p}function tv(n,[e,i]){let r=0,s=0;if(i===gy){e<0&&(e=0);let l=e/kw;switch(n){case"top-right":case"top-left":s=l-7;break;case"bottom-right":case"bottom-left":s=7-l;break;case"bottom":s=7-e;break;case"top":s=e-7}switch(n){case"top-right":case"bottom-right":r=-l;break;case"top-left":case"bottom-left":r=l;break;case"left":r=e;break;case"right":r=-e}}else{switch(e=Math.abs(e),i=Math.abs(i),n){case"top-right":case"top-left":case"top":s=i-7;break;case"bottom-right":case"bottom-left":case"bottom":s=7-i}switch(n){case"top-right":case"bottom-right":case"right":r=-e;break;case"top-left":case"bottom-left":case"left":r=e}}return[r,s]}function Nw(n,e,i,r,s,l,u,p,f,g,x,b,w,S,E){let M=n.layers[0],C=M.appearances;if(C.length===0)return{iconBBox:null,iconVerticalBBox:null,textBBox:null,textVerticalBBox:null};let R={iconBBox:null,iconVerticalBBox:null},F={textBBox:null,textVerticalBBox:null},{baseIconRotate:z,baseTextRotate:j,iconScaleFactor:$}=function(ie,W,Q){let Y=ie.get("icon-rotate").evaluate(W,{},Q),ee=ie.get("text-rotate").evaluate(W,{},Q),[me,ge]=ie.get("icon-size-scale-range");return{baseIconRotate:Y,baseTextRotate:ee,iconScaleFactor:ne(1,me,ge)}}(r,s,l);e&&(R.iconBBox=$l(e,R.iconBBox,z),i)&&(R.iconVerticalBBox=$l(i,R.iconVerticalBBox,z+90));let H=y_(b.horizontal);H&&(F.textBBox=$l(H,F.textBBox,j,1,S)),b.vertical&&(F.textVerticalBBox=$l(b.vertical,F.textVerticalBBox,j+90,1,S));for(let ie of C)ie.hasIconLayoutProperties()&&Uw(R,n,M,ie,s,l,p,z,u,f,e,g,$,x,E),ie.hasTextLayoutProperties()&&Vw(
7F,M,ie,s,l,S,j,w,H,b.vertical);return{iconBBox:R.iconBBox,iconVerticalBBox:R.iconVerticalBBox,textBBox:F.textBBox,textVerticalBBox:F.textVerticalBBox}}function Uw(n,e,i,r,s,l,u,p,f,g,x,b,w,S,E){let{appearanceIconOffset:M,appearanceIconRotate:C,appearanceIconSize:R}=iv(r,i,s,l,u,p,f,g.iconScaleFactor),F=null,z=null,j=null;r.hasLayoutProperty("icon-image")?j=function(H,ie,W,Q,Y,ee,me,ge){let Te=null,Ae=ie.getAppearanceValueAndResolveTokens(W,"icon-image",Q,Y,ge);if(Ae){let Ee=H.getResolvedImageFromTokens(Ae),Be=W.hasLayoutProperty("icon-size")?W.getUnevaluatedLayoutProperty("icon-size"):ie._unevaluatedLayout._values["icon-size"],xe=zp(Ee,ru(H.zoom,Be,H.worldview,ge),Be,Y,H.zoom,Q,H.pixelRatio,me,H.worldview,ge);Te=ee.get(xe.iconPrimary.toString())}return Te}(e,i,r,s,l,b,w,E):x&&(j=x.imagePrimary),j&&(F=h_(j,null,M,S),e.allowVerticalPlacement&&(z=h_(j,null,M,S)));let $=f>0?R/f:1;F&&(n.iconBBox=$l(F,n.iconBBox,C,$!==1?$:void 0)),z&&(n.iconVerticalBBox=$l(z,n.iconVerticalBBox,C+90,$!==1?$:void 0))}function iv(n,e,i,r,s,l,u,p){let f=n.hasLayoutProperty("icon-offset")?e.getAppearanceValueAndResolveTokens(n,"icon-offset",i,r,[]):null,g=f&&Array.isArray(f)?f:s,x=n.hasLayoutProperty("icon-rotate")?e.getAppearanceValueAndResolveTokens(n,"icon-rotate",i,r,[]):null,b=typeof x=="number"?x:l,w=n.hasLayoutProperty("icon-size")?e.getAppearanceValueAndResolveTokens(n,"icon-size",i,r,[]):null;return{appearanceIconOffset:g,appearanceIconRotate:b,appearanceIconSize:typeof w=="number"?w*p:u}}function Vw(n,e,i,r,s,l,u,p,f,g){let{appearanceTextOffset:x,appearanceTextRotate:b,appearanceTextSize:w}=nv(i,e,r,s,l,u,p),S=w/p,E=[(x[0]-l[0])*S,(x[1]-l[1])*S],M=E[0]!==0||E[1]!==0;f&&(n.textBBox=$l(f,n.textBBox,b,S,x,M?E:void 0)),g&&(n.textVerticalBBox=$l(g,n.textVerticalBBox,b+90,S,x,M?E:void 0))}function nv(n,e,i,r,s,l,u){let p=n.hasLayoutProperty("text-offset")?e.getAppearanceValueAndResolveTokens(n,"text-offset",i,r,[]):null,f=p&&Array.isArray(p)?[p[0]*Tn,p[1]*Tn]:s,g=n.hasLayoutProperty("text-rotate")?e.getAppearanceValueAndResolveTokens(n,"text-rotate",i,r,[]):null,x=typeof g=="number"?g:l,b=n.hasLayoutProperty("text-size")?e.getAppearanceValueAndResolveTokens(n,"text-size",i,r,[]):null;return{appearanceTextOffset:f,appearanceTextRotate:x,appearanceTextSize:typeof b=="number"?b:u}}function g_(n,e,i,r,s,l,u,p,f){if(!e||!e.usvg)return;let g=Nx(r),x=Nx(s),b=l!=="both"&&l!=="width"||!Bx(r)?1:x.width/g.width,w=l!=="both"&&l!=="height"||!kx(r)?1:x.height/g.height;i.scaleSelf(b,w);let S=i.toString();u.set(S,i),p.set(S,e);let{imagePosition:E}=dy(S,e,1);f.set(S,E)}function rv(n,e,i,r,s,l,u,p,f,g){if(!n)return;let x=function(b,w,S,E,M,C,R){if(b.kind==="camera")return b.maxSize;if(b.kind==="composite"){let F=w.possiblyEvaluate(new Xt(b.maxZoom,{worldview:C}),S,R).evaluate(M,{},S,R),z=w.possiblyEvaluate(new Xt(b.minZoom,{worldview:C}),S,R).evaluate(M,{},S,R);return Math.max(F,z)}return w.possiblyEvaluate(new Xt(E,{worldview:C}),S,R).evaluate(M,{},S,R)}(e,i,r,s,l,f,g);return n.scaleSelf(x*p*u)}function zp(n,e,i,r,s,l,u,p,f,g){return{iconPrimary:rv(n.getPrimary(),e,i,r,s,l,u,p,f,g),iconSecondary:rv(n.getSecondary(),e,i,r,s,l,u,p,f,g)}}function jw(n,e,i){if(!e)return;let r=i.get(n.toString()),s=i.get(e.toString());r&&s&&(r.paddedRect.w===s.paddedRect.w&&r.paddedRect.h===s.paddedRect.h||Ot(`Mismatch in icon variant sizes: ${n.toString()} and ${e.toString()}`),r.usvg!==s.usvg&&Ot(`Mismatch in icon variant image types: ${n.id} and ${e.id}`))}function ov(n,e,i,r){if(!n)return;let s=e.get(i.toString());if(s&&(n.imagePrimary=s),r){let l=e.get(r.toString());n.imageSecondary=l}}function Gw(n,e){for(let i in n.horizontal)sv(n.horizontal[i],e);sv(n.vertical,e)}function sv(n,e){if(n){for(let i of n.positionedLines)for(let r of i.positionedGlyphs)if(r.image!==null){let s=r.image.toString();r.rect=e.get(s).paddedRect}}}function yy(n){switch(n){case"right":case"top-right":case"bottom-right":return"right";case"left":case"top-left":case"bottom-left":return"left"}return"center"}function $w(n,e,i,r,s,l,u,p,f){let g=y_(l.horizontal)||l.vertical,x=i.get("icon-text-fit-padding").evaluate(r,{},s),b,w=e;return e&&f!=="none"&&(n.allowVerticalPlacement&&l.vertical&&(b=ly(e,l.vertical,f,x,p,u)),g&&(w=ly(e,g,f,x,p,u))),{defaultShapedIcon:w,verticallyShapedIcon:b}}function av(n,e){return n*e/24}function Hw(n,e,i,r,s,l,u,p,f,g,x,b,w,S,E,M,C,R,F,z,j,$,H,ie){let W=u.textMaxSize.evaluate(e,{},w);W===void 0?W=p*u.textScaleFactor:W*=u.textScaleFactor;let Q=n.layers[0].layout,Y=av(p,u.textScaleFactor),ee=y_(i.horizontal)||i.vertical,me=n.hasAnyAppearanceLayoutProperty(["text-size","text-offset","text-rotate"]),ge=n.getAppearanceFeatureData(e.index);(C!=="none"||me)&&ge&&(ge.textShaping=ee,ge.iconTextFitPadding=Q.get("icon-text-fit-padding").evaluate(e,{},w),ge.fontScale=Y,ge.textScaleFactor=u.textScaleFactor);let Te=S.name==="globe",Ae=n.tilePixelRatio*W/24,Ee=(Le=n.overscaling,n.zoom>18&&Le>2&&(Le>>=1),Math.max(Xe/(512*Le),1)*Q.get("symbol-spacing")),Be=Q.get("text-padding")*n.tilePixelRatio,xe=Q.get("icon-padding")*n.tilePixelRatio,Se=V(Q.get("text-max-angle")),Me=Q.get("icon-rotation-alignment")==="map"&&z!=="point",ze=Ee/2;var Le;n.hasAnyIconTextFit===!1&&C!=="none"&&(n.hasAnyIconTextFit=!0);let We=e.properties?+e.properties[Hs]:null,De=We&&n.elevationFeatureIdToIndex?n.elevationFeatureIdToIndex.get(We):65535,Ge=(
7He,Je,tt)=>{if(Je.x<0||Je.x>=Xe||Je.y<0||Je.y>=Xe)return;let lt=null;if(Te){let{x:rt,y:pt,z:Ht}=S.projectTilePoint(Je.x,Je.y,tt);lt={anchor:new Ha(rt,pt,Ht,0,void 0),up:S.upVector(tt,Je.x,Je.y)}}(function(rt,pt,Ht,wt,kt,At,Ui,Jt,Gt,ui,Mi,Sn,mi,Vi,un,en,hn,Pt,Un,lr,Ki,Cn,Qn,Vn,zi,_n,Mr,Dh,pr,Ny,qp,Zp){let qa=rt.addToLineVertexArray(pt,wt),so,Eo,Xl,Yl,Dt,Pn,ji,gn=0,Ao=0,Wr=0,ao=0,Xr=-1,Wp=-1,Uo={},Rh=fc(""),Ks=Ht?Ht.anchor:pt,zh=Dh!=="none",dn=0,On=0;if(Gt._unevaluatedLayout.getValue("text-radial-offset")===void 0){let jn=Gt.layout.get("text-offset").evaluate(Ki,{},zi);dn=jn[0]*Tn,On=jn[1]*Tn}else dn=Gt.layout.get("text-radial-offset").evaluate(Ki,{},zi)*Tn,On=gy;if(rt.allowVerticalPlacement&&kt.vertical){let jn=kt.vertical;if(un)Pn=by(jn),Jt&&(ji=by(Jt));else{let er=Gt.layout.get("text-rotate").evaluate(Ki,{},zi)+90;Xl=x_(ui,Ks,pt,Mi,Sn,mi,jn,Vi,er,en,Zp),Jt&&(Yl=x_(ui,Ks,pt,Mi,Sn,mi,Jt,Pt,er,null,qp))}}if(At){let jn=Gt.layout.get("icon-rotate").evaluate(Ki,{},zi),er=_y(At,jn,Qn,zh,Cn.iconScaleFactor),co=Jt?_y(Jt,jn,Qn,zh,Cn.iconScaleFactor):void 0;Eo=x_(ui,Ks,pt,Mi,Sn,mi,At,Pt,jn,null,Ny);let Qs=function(ps,Xp,g1,VT,jT,y1,x1,GT,r2,jy){let v1=ps.layers[0],b1=v1.appearances,Oh=Xp.length;if(g1&&(Oh=Math.max(Oh,g1.length)),b1.length===0)return Oh;let[$T,HT]=VT.get("icon-size-scale-range"),qT=ne(1,$T,HT);for(let L_ of b1)if(L_.hasLayoutProperty("icon-image")){let w1=v1.getAppearanceValueAndResolveTokens(L_,"icon-image",y1,x1,jy);if(w1){let T1=ps.getResolvedImageFromTokens(w1);if(T1){let S1=L_.hasLayoutProperty("icon-size")?L_.getUnevaluatedLayoutProperty("icon-size"):jT._values["icon-size"],ZT=zp(T1,ru(ps.zoom,S1,ps.worldview,jy),S1,x1,ps.zoom,y1,ps.pixelRatio,qT,ps.worldview,jy),I1=GT.get(ZT.iconPrimary.toString());I1&&(Oh=Math.max(Oh,zw(I1)))}}}return Oh}(rt,er,co,Gt.layout,Gt._unevaluatedLayout,Ki,zi,rt.iconAtlasPositions,0,Vn);gn=4*Qs;let z_=Gt.layout.get("icon-size").evaluate(Ki,{},zi,Vn),Uy=Cn.compositeIconSizes?Cn.compositeIconSizes[0].evaluate(Ki,{},zi,Vn):0,Vy=Cn.compositeIconSizes?Cn.compositeIconSizes[1].evaluate(Ki,{},zi,Vn):0,Lh=vy(rt.layerIds[0],rt.iconSizeData,z_,At.imagePrimary.usvg?1:Cn.iconScaleFactor,Uy,Vy);rt.addSymbols(rt.icon,er,Lh,lr,Un,Ki,void 0,Ht,pt,qa.lineStartIndex,qa.lineLength,-1,Vn,zi,_n,Mr,rt.symbolInstances.length,Qs),Xr=rt.icon.placedSymbolArray.length-1,co&&(Ao=4*Qs,rt.addSymbols(rt.icon,co,Lh,lr,Un,Ki,Zr.vertical,Ht,pt,qa.lineStartIndex,qa.lineLength,-1,Vn,zi,_n,Mr,rt.symbolInstances.length,Qs),Wp=rt.icon.placedSymbolArray.length-1)}for(let jn in kt.horizontal){let er=jn,co=kt.horizontal[er];so||(Rh=fc(co.text),un?Dt=by(co):so=x_(ui,Ks,pt,Mi,Sn,mi,co,Vi,Gt.layout.get("text-rotate").evaluate(Ki,{},zi),en,Zp));let Qs=co.positionedLines.length===1;if(Wr+=lv(rt,Ht,pt,co,Ui,Gt,un,Ki,en,qa,kt.vertical?Zr.horizontal:Zr.horizontalOnly,Qs?Bw(kt.horizontal):[er],Uo,Xr,Cn,Vn,zi,rt.symbolInstances.length,_n),Qs)break}kt.vertical&&(ao+=lv(rt,Ht,pt,kt.vertical,Ui,Gt,un,Ki,en,qa,Zr.vertical,["vertical"],Uo,Wp,Cn,Vn,zi,rt.symbolInstances.length,_n));let qi=-1,lo=(jn,er)=>jn?Math.max(jn,er):er;qi=lo(Dt,qi),qi=lo(Pn,qi),qi=lo(ji,qi);let fr=qi>-1?1:0;rt.glyphOffsetArray.length>=65535&&Ot("Too many glyphs being rendered in a tile. See https://github.com/mapbox/mapbox-gl-js/issues/2907"),Ki.sortKey!==void 0&&rt.addToSortKeyRanges(rt.symbolInstances.length,Ki.sortKey),rt.symbolInstances.emplaceBack(pt.x,pt.y,Ks.x,Ks.y,Ks.z,Uo.right>=0?Uo.right:-1,Uo.center>=0?Uo.center:-1,Uo.left>=0?Uo.left:-1,Uo.vertical>=0?Uo.vertical:-1,Xr,Wp,Rh,so!==void 0?so:rt.collisionBoxArray.length,so!==void 0?so+1:rt.collisionBoxArray.length,Xl!==void 0?Xl:rt.collisionBoxArray.length,Xl!==void 0?Xl+1:rt.collisionBoxArray.length,Eo!==void 0?Eo:rt.collisionBoxArray.length,Eo!==void 0?Eo+1:rt.collisionBoxArray.length,Yl||rt.collisionBoxArray.length,Yl?Yl+1:rt.collisionBoxArray.length,Mi,Wr,ao,gn,Ao,fr,0,dn,On,qi,0,zh?1:0,pr)})(n,Je,lt,He,i,r,l,s,n.layers[0],n.collisionBoxArray,e.index,e.sourceLayerIndex,n.index,Be,F,g,0,xe,Me,R,e,u,x,b,w,E,M,C,De,j,$,H)};if(z==="line")for(let He of Jm(e.geometry,0,0,Xe,Xe)){let Je=Cw(He,Ee,Se,i.vertical||ee,r,24,Ae,n.overscaling,Xe);for(let tt of Je)ee&&qw(n,ee.text,ze,tt)||Ge(He,tt,w)}else if(z==="line-center"){for(let He of e.geometry)if(He.length>1){let Je=Mw(He,Se,i.vertical||ee,r,24,Ae);Je&&Ge(He,Je,w)}}else if(e.type==="Polygon")for(let He of _p(e.geometry,0)){let Je=Ow(He,16);Ge(He[0],new Ha(Je.x,Je.y,0,0,void 0),w)}else if(e.type==="LineString")for(let He of e.geometry)Ge(He,new Ha(He[0].x,He[0].y,0,0,void 0),w);else if(e.type==="Point")for(let He of e.geometry)for(let Je of He)Ge([Je],new Ha(Je.x,Je.y,0,0,void 0),w)}let xy=255,ou=xy*$a;function lv(n,e,i,r,s,l,u,p,f,g,x,b,w,S,E,M,C,R,F){let z=ev(0,r,f,l,u,p,s,n.allowVerticalPlacement,void 0,E.textScaleFactor),j=l.layout.get("text-size").evaluate(p,{},C),$=E.compositeTextSizes?E.compositeTextSizes[0].evaluate(p,{},C):0,H=E.compositeTextSizes?E.compositeTextSizes[1].evaluate(p,{},C):0,ie=vy(n.layerIds[0],n.textSizeData,j,E.textScaleFactor,$,H);n.addSymbols(n.text,z,ie,f,u,p,x,e,i,g.lineStartIndex,g.lineLength,S,M,C,F,!1,R,z.length);for(let W of b)w[W]=n.text.placedSymbolArray.length-1;return 4*z.length}function vy(n,e,i,r,s,l){let u=e,p=null;return u.kind==="source"?(p=[$a*i*r],p[0]>ou&&Ot(`${n}: Value for "text-size" or "icon-size" is >= ${xy}. Reduce your "text-size" or "icon-size".`)):u.kind==="composite"&&(p=[$a*s*r,$a*l*r],(p[0]>ou||p[1]>ou)&&Ot(`${n}: Value for "text-size" or "icon-size" is >= ${xy}. Reduce your "text-size" or "icon-size".`)),p}function y_(n){for(let e in n)return n[e];return null}function x_(n,e,i,r,s,l,u,p,f,g,x){let b,w,S,E;if(b=x?x.top:u.top,w=x?x.bottom:u.bottom,S=x?x.left:u.left,E=x?x.right:u.right,ay(u)&&u.collisionPadding){let M=u.collisionPadding;S-=M[0],b-=M[1],E+=M[2],w+=M[3]}if(f){let M=new ke(S,b),C=new ke(E,b),R=new ke(S,w),F=new ke(E,w),z=V(f),j=new ke(0,0);
7g&&(j=new ke(g[0],g[1])),M._rotateAround(z,j),C._rotateAround(z,j),R._rotateAround(z,j),F._rotateAround(z,j),S=Math.min(M.x,C.x,R.x,F.x),E=Math.max(M.x,C.x,R.x,F.x),b=Math.min(M.y,C.y,R.y,F.y),w=Math.max(M.y,C.y,R.y,F.y)}return n.emplaceBack(e.x,e.y,e.z,i.x,i.y,S,b,E,w,p,r,s,l),n.length-1}function by(n){ay(n)&&n.collisionPadding&&(n.top-=n.collisionPadding[1],n.bottom+=n.collisionPadding[3]);let e=n.bottom-n.top;return e>0?Math.max(10,e):null}function qw(n,e,i,r){let s=n.compareText;if(e in s){let l=s[e];for(let u=l.length-1;u>=0;u--)if(r.dist(l[u])<i)return!0}else s[e]=[];return s[e].push(r),!1}function cv(n,e){let i=n.fovAboveCenter,r=n.elevation?n.elevation.getMinElevationBelowMSL()*e:0,s=Math.min(r,n.isOrthographic?-10*e:0),l=(n._camera.position[2]*n.worldSize-s)/Math.cos(n._pitch),u=Math.sin(i)*l/Math.sin(Math.max(Math.PI/2-n._pitch-i,.01)),p=Math.sin(n._pitch)*u+l,f=l*(1/n._horizonShift);if(!n.elevation||n.elevation.exaggeration()===0){let g=Math.max(n.zoom-17,0);n.isOrthographic&&(g/=10),p*=1+g}return Math.min(1.01*p,f)}function su(n,e){if(!e.isReprojectedInTileSpace)return{scale:1<<n.z,x:n.x,y:n.y,x2:n.x+1,y2:n.y+1,projection:e};let i=Math.pow(2,-n.z),r=n.x*i,s=(n.x+1)*i,l=n.y*i,u=(n.y+1)*i,p=Ir(r),f=Ir(s),g=Ln(l),x=Ln(u),b=e.project(p,g),w=e.project(f,g),S=e.project(f,x),E=e.project(p,x),M=Math.min(b.x,w.x,S.x,E.x),C=Math.min(b.y,w.y,S.y,E.y),R=Math.max(b.x,w.x,S.x,E.x),F=Math.max(b.y,w.y,S.y,E.y),z=i/16;function j(H,ie,W,Q,Y,ee){let me=(W+Y)/2,ge=(Q+ee)/2,Te=e.project(Ir(me),Ln(ge)),Ae=Math.max(0,M-Te.x,C-Te.y,Te.x-R,Te.y-F);M=Math.min(M,Te.x),R=Math.max(R,Te.x),C=Math.min(C,Te.y),F=Math.max(F,Te.y),Ae>z&&(j(H,Te,W,Q,me,ge),j(Te,ie,me,ge,Y,ee))}j(b,w,r,l,s,l),j(w,S,s,l,s,u),j(S,E,s,u,r,u),j(E,b,r,u,r,l),M-=z,C-=z,R+=z,F+=z;let $=1/Math.max(R-M,F-C);return{scale:$,x:M*$,y:C*$,x2:R*$,y2:F*$,projection:e}}function uv(n,{x:e,y:i},r=0){return new ke(((e-r)*n.scale-n.x)*Xe,(i*n.scale-n.y)*Xe)}let Zw=Rt(new Float32Array(16));class Hl{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 Yt(0,0)}projectTilePoint(e,i,r){return{x:e,y:i,z:0}}locationPoint(e,i,r,s=!0){return e._coordinatePoint(e.locationCoordinate(i,r),s)}pixelsPerMeter(e,i){return or(1,e)*i}pixelSpaceConversion(e,i,r){return 1}farthestPixelDistance(e){return cv(e,e.pixelsPerMeter)}pointCoordinate(e,i,r,s){let l=e.horizonLineFromTop(!1),u=new ke(i,Math.max(l,r));return e.rayIntersectionCoordinate(e.pointRayIntersection(u,s))}pointCoordinate3D(e,i,r){let s=new ke(i,r);if(e.elevation)return e.elevation.pointCoordinate(s);{let l=this.pointCoordinate(e,s.x,s.y,0);return[l.x,l.y,l.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 Zw}createTileMatrix(e,i,r){let s,l,u,p=r.canonical,f=Rt(new Float64Array(16));if(this.isReprojectedInTileSpace){let g=su(p,this);s=1,l=g.x+r.wrap*g.scale,u=g.y,Zn(f,f,[s/g.scale,s/g.scale,e.pixelsPerMeter/i])}else s=i/e.zoomScale(p.z),l=(p.x+Math.pow(2,p.z)*r.wrap)*s,u=p.y*s;return Gn(f,f,[l,u,0]),Zn(f,f,[s/Xe,s/Xe,1]),f}upVector(e,i,r){return[0,0,1]}upVectorScale(e,i,r){return{metersToTile:1}}}class Ww extends Hl{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],s=Math.sin(V(i));this.n=(s+Math.sin(V(r)))/2,this.c=1+s*(2*this.n-s),this.r0=Math.sqrt(this.c)/this.n}project(e,i){let{n:r,c:s,r0:l}=this,u=V(e-this.center[0]),p=V(i),f=Math.sqrt(s-2*r*Math.sin(p))/r;return{x:f*Math.sin(u*r),y:f*Math.cos(u*r)-l,z:0}}unproject(e,i){let{n:r,c:s,r0:l}=this,u=l+i,p=Math.atan2(e,Math.abs(u))*Math.sign(u);u*r<0&&(p-=Math.PI*Math.sign(e)*Math.sign(u));let f=V(this.center[0])*r;p=Ne(p,-Math.PI-f,Math.PI-f);let g=ne(X(p/r)+this.center[0],-180,180),x=Math.asin(ne((s-(e*e+u*u)*r*r)/(2*r),-1,1)),b=ne(X(x),-85.051129,Er);return new Yt(g,b)}}let Lp=1.340264,Op=-.081106,Fp=893e-6,Bp=.003796,v_=Math.sqrt(3)/2;class Xw extends Hl{project(e,i){i=i/180*Math.PI,e=e/180*Math.PI;let r=Math.asin(v_*Math.sin(i)),s=r*r,l=s*s*s;return{x:.5*(e*Math.cos(r)/(v_*(Lp+3*Op*s+l*(7*Fp+9*Bp*s)))/Math.PI+.5),y:1-.5*(r*(Lp+Op*s+l*(Fp+Bp*s))/Math.PI+1),z:0}}unproject(e,i){e=(2*e-.5)*Math.PI;let r=i=(2*(1-i)-1)*Math.PI,s=r*r,l=s*s*s;for(let x,b,w,S=0;S<12&&(b=r*(Lp+Op*s+l*(Fp+Bp*s))-i,w=Lp+3*Op*s+l*(7*Fp+9*Bp*s),x=b/w,r=ne(r-x,-Math.PI/3,Math.PI/3),s=r*r,l=s*s*s,!(Math.abs(x)<1e-12));++S);let u=v_*e*(Lp+3*Op*s+l*(7*Fp+9*Bp*s))/Math.cos(r),p=Math.asin(Math.sin(r)/v_),f=ne(180*u/Math.PI,-180,180),g=ne(180*p/Math.PI,-85.051129,Er);return new Yt(f,g)}}class Yw extends Hl{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){let r=360*(e-.5),s=ne(360*(.5-i),-85.051129,Er);return new Yt(r,s)}}let Eh=Math.PI/2;function b_(n){return Math.tan((Eh+n)/2)}class Jw extends Hl{constructor(e){super(e),this.center=e.center||[0,30];let[i,r]=this.parallels=e.parallels||[30,30],s=V(i),l=V(r);this.southernCenter=s+l<0,this.southernCenter&&(s=-s,l=-l);let u=Math.cos(s),p=b_(s);this.n=s===l?Math.sin(s):Math.log(u/Math.cos(l))/Math.log(b_(l)/p),this.f=u*Math.pow(b_(s),this.n)/this.n}project(e,i){i=V(i),this.southernCenter&&(i=-i),e=V(e-this.center[0]);let r=1e-6,{n:s,f:l}=this;l>0?i<-Eh+r&&(i=-Eh+r):i>Eh-r&&(i=Eh-r);let u=l/Math.pow(b_(i),s),p=u*Math.sin(s*e),f=l-u*Math.cos(s*e);return p=.5*(p/Math.PI+.5),f=.5*(f/Math.PI+.5),{x:p,y:this.southernCenter?f:1-f,z:0}}unproject(e,i){e=(2*e-.5)*Math.PI,this.southernCenter&&(i=1-i),i=(2*(1-i)-.5)*Math.PI;let{n:r,f:s}=this,l=s-i,u=Math.sign(l),p=Math.sign(r)*Math.sqrt(e*e+l*l),f=Math.atan2(e,Math.abs(l))*u;l*r<0&&(f-=Math.PI*Math.sign(e)*u);let g=ne(X(f/r)+this.center[0],-180,180),x=ne(X(2*Math.atan(Math.pow(s/p,1/r))-Eh),-85.051129,Er);return new Yt(g,this.southernCenter?-x:x)}}class hv extends Hl{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:wo(e),y:Fo(i),z:0}}unproject(e,i){let r=Ir(e),s=Ln(i);return new Yt(r,s)}}let dv=V(Er);class Kw extends Hl{project(e,i){let r=(i=V(i))*i,s=r*r;return{x:.5*((e=V(e))*(.8707-.131979*r+s*(s*(.003971*r-.001529*s)-.013791))/Math.PI+.5),y:1-.5*(i*(1.007226+r*(.015085+s*(.028874*r-.044475-.005916*s)))/Math.PI+1),z:0}}unproject(e,i){e=(2*e-.5)*Math.PI;let r=i=(2*(1-i)-1)*Math.PI,s=25,l=0,u=r*r;do{u=r*r;let g=u*u;l=(r*(1.007226+u*(.015085+g*(.028874*u-.044475-.005916*g)))-i)/(1.007226+u*(.045255+g*(.259866*u-.311325-.005916*11*g))),r=ne(r-l,-dv,dv)}while(Math.abs(l)>1e-6&&--s>0);u=r*r;let p=ne(X(e/(.8707+u*(u*(u*u*u*(.003971-.001529*u)-.013791)-.131979))),-180,180),f=X(r);return new Yt(p,f)}}let pv=V(Er);class Qw extends Hl{project(e,i){i=V(i),e=V(e);
7let r=Math.cos(i),s=2/Math.PI,l=Math.acos(r*Math.cos(e/2)),u=Math.sin(l)/l,p=.5*(e*s+2*r*Math.sin(e/2)/u)||0,f=.5*(i+Math.sin(i)/u)||0;return{x:.5*(p/Math.PI+.5),y:1-.5*(f/Math.PI+1),z:0}}unproject(e,i){let r=e=(2*e-.5)*Math.PI,s=i=(2*(1-i)-1)*Math.PI,l=25,u=1e-6,p=0,f=0;do{let g=Math.cos(s),x=Math.sin(s),b=2*x*g,w=x*x,S=g*g,E=Math.cos(r/2),M=Math.sin(r/2),C=2*E*M,R=M*M,F=1-S*E*E,z=F?1/F:0,j=F?Math.acos(g*E)*Math.sqrt(1/F):0,$=.5*(2*j*g*M+2*r/Math.PI)-e,H=.5*(j*x+s)-i,ie=.5*z*(S*R+j*g*E*w)+1/Math.PI,W=z*(C*b/4-j*x*M),Q=.125*z*(b*M-j*x*S*C),Y=.5*z*(w*E+j*R*g)+.5,ee=W*Q-Y*ie;p=(H*W-$*Y)/ee,f=($*Q-H*ie)/ee,r=ne(r-p,-Math.PI,Math.PI),s=ne(s-f,-pv,pv)}while((Math.abs(p)>u||Math.abs(f)>u)&&--l>0);return new Yt(X(r),X(s))}}class fv extends Hl{constructor(e){super(e),this.center=e.center||[0,0],this.parallels=e.parallels||[0,0],this.cosPhi=Math.max(.01,Math.cos(V(this.parallels[0]))),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:s}=this;return{x:V(e)*s*r+.5,y:-Math.sin(V(i))/s*r+.5,z:0}}unproject(e,i){let{scale:r,cosPhi:s}=this,l=-(i-.5)/r,u=ne(X((e-.5)/r)/s,-180,180),p=Math.asin(ne(l*s,-1,1)),f=ne(X(p),-85.051129,Er);return new Yt(u,f)}}class eT extends hv{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 s=ut(e,i,r);return Oi(s,s,Tt($e(r))),{x:s[0],y:s[1],z:s[2]}}locationPoint(e,i,r){let s=ns(i.lat,i.lng),l=hi([],s),u=r?e._centerAltitude+r:e.elevation?e.elevation.getAtPointOrZero(e.locationCoordinate(i),e._centerAltitude):e._centerAltitude;Dr(s,s,l,or(1,0)*Xe*u);let p=Rt(new Float64Array(16));return xi(p,e.pixelMatrix,e.globeMatrix),Oi(s,s,p),new ke(s[0],s[1])}pixelsPerMeter(e,i){return or(1,0)*i}pixelSpaceConversion(e,i,r){let s=or(1,e)*i,l=ft(or(1,45)*i,s,r);return this.pixelsPerMeter(e,i)/l}createTileMatrix(e,i,r){let s=yt($e(r.canonical));return xi(new Float64Array(16),e.globeMatrix,s)}createInversionMatrix(e,i){let{center:r}=e,s=Tt($e(i));return jo(s,s,V(r.lng)),Vo(s,s,V(r.lat)),Zn(s,s,[e._pixelsPerMercatorPixel,e._pixelsPerMercatorPixel,1]),Float32Array.from(s)}pointCoordinate(e,i,r,s){return Ce(e,i,r,!0)||new qn(0,0)}pointCoordinate3D(e,i,r){let s=this.pointCoordinate(e,i,r,0);return[s.x,s.y,s.z]}isPointAboveHorizon(e,i){return!Ce(e,i.x,i.y,!1)}farthestPixelDistance(e){let i=function(s,l){let u=s.cameraToCenterDistance,p=s._centerAltitude*l,f=s._camera,g=s._camera.forward(),x=tn([],Li([],g,-u),[0,0,p]),b=s.worldSize/(2*Math.PI),w=[0,0,-b],S=s.width/s.height,E=Math.tan(s.fovAboveCenter),M=Li([],f.up(),E),C=Li([],f.right(),E*S),R=hi([],tn([],tn([],g,M),C)),F=[],z;if(new Jc(x,R).closestPointOnSphere(w,b,F)){let j=tn([],F,w),$=Gi([],j,x);z=Math.cos(s.fovAboveCenter)*Dn($)}else{let j=Gi([],x,w),$=Gi([],w,x);hi($,$);let H=Dn(j)-b;z=Math.sqrt(H*(H+2*b));let ie=Math.acos(z/(b+H))-Math.acos(Qi(g,$));z*=Math.cos(ie)}return 1.01*z}(e,this.pixelsPerMeter(e.center.lat,e.worldSize)),r=$t(e.zoom);if(r>0){let s=cv(e,or(1,e.center.lat)*e.worldSize),l=e.worldSize/(2*Math.PI),u=Math.max(e.width,e.height)/e.worldSize*Math.PI;return ft(i,s+l*(1-Math.cos(u)),Math.pow(r,10))}return i}upVector(e,i,r){return ut(i,r,e,1)}upVectorScale(e){return{metersToTile:fe(xt($e(e)))}}}function mv(n){let e=n.parallels,i=!!e&&Math.abs(e[0]+e[1])<.01;switch(n.name){case"mercator":return new hv(n);case"equirectangular":return new Yw(n);case"naturalEarth":return new Kw(n);case"equalEarth":return new Xw(n);case"winkelTripel":return new Qw(n);case"albers":return i?new fv(n):new Ww(n);case"lambertConformalConic":return i?new fv(n):new Jw(n);case"globe":return new eT(n)}throw new Error(`Invalid projection name: ${n.name}`)}class tT{constructor(e,i){this.lastParams=null,this.lastAllFeaturesIndex=-2,this.appearancesVersion=i,this.appearances=e;let r=e.map(s=>function(l){if(!l.condition)return{featureDependent:!1,stateDependent:!1,zoomDependent:!1,pitchDependent:!1,brightnessDependent:!1,worldviewDependent:!1};let u=l.condition.expression;return{featureDependent:!Ma(u),stateDependent:!fl(u),zoomDependent:!tr(u,["zoom"]),pitchDependent:!tr(u,["pitch"]),brightnessDependent:!tr(u,["brightness","measure-light"]),worldviewDependent:!tr(u,["worldview"])}}(s));this.anyFeatureDependent=r.some(s=>s.featureDependent),this.anyStateDependent=r.some(s=>s.stateDependent)}update(e,i){let r=this.lastParams,s=!r||r.zoom!==e.zoom||r.pitch!==(e.pitch||0)||r.brightness!==(e.brightness||0)||r.worldview!==e.worldview;this.lastParams={zoom:e.zoom,pitch:e.pitch||0,brightness:e.brightness||0,worldview:e.worldview};let l=i&&this.anyStateDependent;if(!s&&!l&&this.lastAllFeaturesIndex!==-2)return{kind:"no-changes"};if(!this.anyFeatureDependent&&!l){let u=this.evaluateAllFeatures(e);return u===this.lastAllFeaturesIndex?{kind:"no-changes"}
7:(this.lastAllFeaturesIndex=u,{kind:"all-features",appearanceIndex:u})}return{kind:"per-feature"}}evaluateAllFeatures(e){for(let i=0;i<this.appearances.length;i++){let r=this.appearances[i];if(r.condition&&r.condition.evaluate(e,void 0,void 0,void 0))return i}return-1}}let iT=$s.types,nT=[{name:"a_fade_opacity",components:1,type:"Uint8",offset:0}];function kp(n,e,i,r,s,l,u,p,f,g,x,b,w){let S=p?Math.min(ou,Math.round(p[0])):0,E=p?Math.min(ou,Math.round(p[1])):0;n.emplaceBack(e,i,Math.round(32*r),Math.round(32*s),l,u,(S<<1)+(f?1:0),0+(E<<1),16*g,16*x,256*b,256*w)}function Np(n,e,i){n.emplaceBack(e,i)}function Up(n,e,i,r,s,l,u){n.emplaceBack(e,i,r,s,l,u)}let w_=(n,e,i,r)=>{for(let s=0;s<e;s++)n.emplaceBack(i[0],i[1],i[2],r[0],r[1],r[2])};function Ah(n,e,i,r,s){n.emplaceBack(e,i,r,s),n.emplaceBack(e,i,r,s),n.emplaceBack(e,i,r,s),n.emplaceBack(e,i,r,s)}function rT(n){for(let e of n.sections)if(Os(e.text))return!0;return!1}let Mh=12;class wy{constructor(e){this.layoutVertexArray=new jd,this.indexArray=new Xi,this.programConfigurations=e,this.segments=new pi,this.dynamicLayoutVertexArray=new Vs,this.opacityVertexArray=new oh,this.placedSymbolArray=new Yd,this.iconTransitioningVertexArray=new kr,this.globeExtVertexArray=new Gd,this.zOffsetVertexArray=new Do,this.orientationVertexArray=new qd,this.symbolInstanceIndices=[],this.uboBinder=null,this.featureIdArray=new Do,this.featureIdBuffer=null,this.cachedBatchIndices=null,this.cachedBatchSegments=null}isEmpty(){return this.layoutVertexArray.length===0&&this.indexArray.length===0&&this.dynamicLayoutVertexArray.length===0&&this.opacityVertexArray.length===0&&this.iconTransitioningVertexArray.length===0}getBatchGrouping(e){let i=e.get().length===this.segments.get().length;if(i&&this.cachedBatchIndices&&this.cachedBatchSegments)return{batchIndices:this.cachedBatchIndices,batchSegments:this.cachedBatchSegments};let r=new Map;for(let u of e.get()){let p=u.batchIndex!==void 0?u.batchIndex:0;r.has(p)||r.set(p,[]),r.get(p).push(u)}let s=Array.from(r.keys()).sort((u,p)=>u-p),l=new Map;for(let u of s){let p=r.get(u);l.set(u,new pi(p))}return i&&(this.cachedBatchIndices=s,this.cachedBatchSegments=l),{batchIndices:s,batchSegments:l}}snapshotSymbolVertexData(e,i){let r=e*Mh;return this.layoutVertexArray.uint16.slice(r,r+i*Mh)}restoreSymbolVertexData(e,i){this.layoutVertexArray.uint16.set(i,e*Mh)}updateSymbolVertexData(e,i,r,s,l,u,p,f,g,x,b,w,S){let E=this.layoutVertexArray.uint16,M=e*Mh;E[M]=i,E[M+1]=r,E[M+2]=s,E[M+3]=l,E[M+4]=u,E[M+5]=p,E[M+6]=f,E[M+7]=g,E[M+8]=x,E[M+9]=b,E[M+10]=w,E[M+11]=S}upload(e,i,r,s,l,u){this.isEmpty()||(r&&(this.cachedBatchIndices=null,this.cachedBatchSegments=null,this.layoutVertexBuffer=e.createVertexBuffer(this.layoutVertexArray,tw.members,!!u),this.indexBuffer=e.createIndexBuffer(this.indexArray,i),this.dynamicLayoutVertexBuffer=e.createVertexBuffer(this.dynamicLayoutVertexArray,nw.members,!0),this.opacityVertexBuffer=e.createVertexBuffer(this.opacityVertexArray,nT,!0),this.iconTransitioningVertexArray.length>0&&(this.iconTransitioningVertexBuffer=e.createVertexBuffer(this.iconTransitioningVertexArray,aw.members,!0)),this.globeExtVertexArray.length>0&&(this.globeExtVertexBuffer=e.createVertexBuffer(this.globeExtVertexArray,iw.members,!0)),!this.zOffsetVertexBuffer&&(this.zOffsetVertexArray.length>0||l)&&(this.zOffsetVertexBuffer=e.createVertexBuffer(this.zOffsetVertexArray,rw.members,!0)),!this.orientationVertexBuffer&&this.orientationVertexArray&&this.orientationVertexArray.length>0&&(this.orientationVertexBuffer=e.createVertexBuffer(this.orientationVertexArray,sw.members,!0)),this.opacityVertexBuffer.itemSize=1,this.featureIdArray&&this.featureIdArray.length>0&&(this.featureIdBuffer=e.createVertexBuffer(this.featureIdArray,ow.members,!1))),(r||s)&&(this.programConfigurations.upload(e),this.uboBinder&&this.uboBinder.upload(e)))}destroy(){this.layoutVertexBuffer&&(this.layoutVertexBuffer.destroy(),this.indexBuffer.destroy(),this.programConfigurations.destroy(),this.segments.destroy(),this.dynamicLayoutVertexBuffer.destroy(),this.opacityVertexBuffer.destroy(),this.iconTransitioningVertexBuffer&&this.iconTransitioningVertexBuffer.destroy(),this.globeExtVertexBuffer&&this.globeExtVertexBuffer.destroy(),this.zOffsetVertexBuffer&&this.zOffsetVertexBuffer.destroy(),this.orientationVertexBuffer&&this.orientationVertexBuffer.destroy(),this.featureIdBuffer&&this.featureIdBuffer.destroy(),this.uboBinder&&this.uboBinder.destroy())}}Qe(wy,"SymbolBuffers",{omit:["cachedBatchIndices","cachedBatchSegments"]});class Ty{constructor(e,i,r){this.layoutVertexArray=new e,this.layoutAttributes=i,this.indexArray=new r,this.segments=new pi,this.collisionVertexArray=new Ro,this.collisionVertexArrayExt=new Vs}upload(e){this.layoutVertexBuffer=e.createVertexBuffer(this.layoutVertexArray,this.layoutAttributes),this.indexBuffer=e.createIndexBuffer(this.indexArray),this.collisionVertexBuffer=e.createVertexBuffer(this.collisionVertexArray,lw.members,!0),this.collisionVertexBufferExt=e.createVertexBuffer(this.collisionVertexArrayExt,cw.members,!0)}destroy(){this.layoutVertexBuffer&&(this.layoutVertexBuffer.destroy(),this.indexBuffer.destroy(),this.segments.destroy(),this.collisionVertexBuffer.destroy(),this.collisionVertexBufferExt.de
7stroy())}}Qe(Ty,"CollisionBuffers");class Bo{constructor(e){this.collisionBoxArray=e.collisionBoxArray,this.zoom=e.zoom,this.overscaling=e.overscaling,this.layers=e.layers,this.layerIds=this.layers.map(u=>u.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=Rt([]),this.placementViewportMatrix=Rt([]);let i=this.layers[0]._unevaluatedLayout._values;this.worldview=e.worldview,this.localizable=e.localizable,this.maxUniformBufferBindings=e.maxUniformBufferBindings,this.maxUniformBlockSizeDwords=e.maxUniformBlockSizeDwords,this.disableSymbolUBO=e.disableSymbolUBO,this.textSizeData=ru(this.zoom,i["text-size"],this.worldview,e.availableImages),this.iconSizeData=ru(this.zoom,i["icon-size"],this.worldview,e.availableImages);let r=this.layers[0].layout,s=r.get("symbol-sort-key"),l=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=l!=="viewport-y"&&s.constantOr(1)!==void 0,this.sortFeaturesByY=(l==="viewport-y"||l==="auto"&&!this.sortFeaturesByKey)&&this.canOverlap,this.writingModes=r.get("text-writing-mode").map(u=>Zr[u]),this.stateDependentLayerIds=this.layers.filter(u=>u.isStateDependent()).map(u=>u.id),this.sourceID=e.sourceID,this.projection=e.projection,this.hasAnyZOffset=!1,this.zOffsetSortDirty=!1,this.zOffsetBuffersNeedUpload=!1,this.elevationType="none",this.elevationStateComplete=!1,this.activeReplacements=[],this.replacementUpdateTime=0,this.hasAnySecondaryIcon=!1,this.hasAppearances=null,this.featureAppearances=null,this.featureAppearanceData=new Map}hasAnyAppearanceLayoutProperty(e){let i=this.layers[0].getAppearances();if(!i||i.length===0)return!1;let r=Array.isArray(e)?e:[e];return i.some(s=>r.some(l=>s.hasLayoutProperty(l)))}getAppearanceFeatureData(e){return this.featureAppearanceData.get(e)}createArrays(){this.text=new wy(new bo(this.layers,{zoom:this.zoom,lut:this.lut},e=>e.startsWith("text")||e.startsWith("symbol"))),this.icon=new wy(new bo(this.layers,{zoom:this.zoom,lut:this.lut},e=>e.startsWith("icon")||e.startsWith("symbol"))),this.disableSymbolUBO||(this.text.uboBinder=new ny(this.layers[0],this.zoom,this.lut,!0,"",this.maxUniformBufferBindings,this.maxUniformBlockSizeDwords),this.icon.uboBinder=new ny(this.layers[0],this.zoom,this.lut,!1,"",this.maxUniformBufferBindings,this.maxUniformBlockSizeDwords)),this.glyphOffsetArray=new Jd,this.lineVertexArray=new hm,this.symbolInstances=new um}calculateGlyphDependencies(e,i,r,s,l){for(let u of e){let p=u.codePointAt(0);if(p===void 0)break;if(i[p]=!0,s&&l&&p<=65535){let f=Mp[u];f&&(i[f.charCodeAt(0)]=!0)}}}calculateEffectiveAppearanceIconSize(e,i,r,s,l,u,p){if(!e.hasLayoutProperty("icon-size"))return p*u;let f=1,g=e.getUnevaluatedLayoutProperty("icon-size"),x=ru(this.zoom,g,this.worldview,l),b=Sh(x,i);if(x.kind!=="constant"&&x.kind!=="camera"||(f=b.uSize),x.kind==="composite"){let{minZoom:w,maxZoom:S}=x,E=g.possiblyEvaluate(new Xt(w,{worldview:this.worldview}),s),M=g.possiblyEvaluate(new Xt(S,{worldview:this.worldview}),s),C=E.evaluate(r,{},s,l);f=C+(M.evaluate(r,{},s,l)-C)*b.uSizeT}return x.kind==="source"&&(f=g.possiblyEvaluate(new Xt(this.zoom,{worldview:this.worldview}),s).evaluate(r,{},s,l)),f*u}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!jm(this.activeReplacements,r)&&(this.activeReplacements=r,!0)}getResolvedImageFromTokens(e){return typeof e=="string"?cr.build(e):e}populate(e,i,r,s){let l=this.layers[0],u=l.layout,p=this.projection.name==="globe",f=u.get("text-font"),g=u.get("text-field"),x=u.get("icon-image"),[b,w]=u.get("icon-size-scale-range"),S=ne(i.scaleFactor||1,b,w),[E,M]=u.get("text-size-scale-range"),C=ne(i.scaleFactor||1,E,M),R=(g.value.kind!=="constant"||g.value.value instanceof kn&&!g.value.value.isEmpty()||g.value.value.toString().length>0)&&(f.value.kind!=="constant"||f.value.value.length>0),F=x.value.kind!=="constant"||!!x.value.value||Object.keys(x.parameters).length>0,z=this.hasAnyAppearanceLayoutProperty("icon-image"),j=u.get("symbol-sort-key");if(this.features=[],this.featureAppearanceData=new Map,!R&&!F&&!z)return;let $=i.iconDependencies,H=i.glyphDependencies,ie=i.availableImages,W=new Xt(this.zoom,{worldview:this.worldview,activeFloors:i.activeFloors}),Q=Y=>{let ee=Y.id.toString();$.has(ee)?$.get(ee).push(Y):$.set(ee,[Y])};for(let Y of e){let{feature:ee,id:me,index:ge,sourceLayerIndex:Te}=Y,Ae=l._featureFilter.needGeometry,Ee=Gr(ee,Ae);if(!l._featureFilter.filter(W,Ee,r))continue;if(Ae||(Ee.geometry=jr(ee,r,s)),p&&ee.type!==1&&r.z<=5){let De=Ee.geometry,Ge=.98078528056,He=(Je,tt)=>Qi(ut(Je.x,Je.y,r,1),ut(tt.x,tt.y,r,1))<Ge;
7for(let Je=0;Je<De.length;Je++)De[Je]=dh(De[Je],He)}let Be,xe;if(R){let De=l.getValueAndResolveTokens("text-field",Ee,r,ie),Ge=kn.factory(De);rT(Ge)&&(this.hasRTLText=!0),(!this.hasRTLText||eh()==="unavailable"||this.hasRTLText&&Qo.isParsed())&&(Be=hw(Ge,l,Ee))}if(F){let De=l.getValueAndResolveTokens("icon-image",Ee,r,ie);xe=this.getResolvedImageFromTokens(De)}let Se=this.layers[0],Me=!1;if(!xe&&z){let De=Se.getAppearances();for(let Ge of De)if(Ge.getLayoutProperty("icon-image")){let He=Se.getAppearanceValueAndResolveTokens(Ge,"icon-image",Ee,r,ie);if(He){xe=this.getResolvedImageFromTokens(He),Me=!0;break}}}if(!Be&&!xe)continue;let ze=this.sortFeaturesByKey?j.evaluate(Ee,{},r):void 0,Le={id:me,text:Be,icon:xe,index:ge,sourceLayerIndex:Te,geometry:Ee.geometry,properties:ee.properties,type:iT[ee.type],sortKey:ze};if(this.features.push(Le),this.featureAppearanceData.set(ge,{id:me,properties:ee.properties,usesAppearanceIconAsPlaceholder:Me}),xe){let De=Se._unevaluatedLayout._values,{iconPrimary:Ge,iconSecondary:He}=zp(xe,this.iconSizeData,De["icon-size"],r,this.zoom,Le,this.pixelRatio,S,this.worldview,ie);Q(Ge),He&&(this.hasAnySecondaryIcon=!0,Q(He))}let We=Se.getAppearances();if(We.length!==0&&We.forEach(De=>{if(!De.getLayoutProperty("icon-image"))return;let Ge=this.getCombinedIconPrimary(De,Se,Ee,r,ie,Le,S);Ge&&Q(Ge)}),Be){let De=f.evaluate(Ee,{},r).join(","),Ge=u.get("text-rotation-alignment")==="map"&&u.get("symbol-placement")!=="point";this.allowVerticalPlacement=this.writingModes&&this.writingModes.includes(Zr.vertical);for(let He of Be.sections)if(He.image){let Je=He.image.getPrimary().scaleSelf(this.pixelRatio*C),tt=Je.id.toString(),lt=$.get(tt)||[];lt.push(Je),$.set(tt,lt)}else{let Je=Yu(Be.toString()),tt=He.fontStack||De,lt=H[tt]=H[tt]||{};this.calculateGlyphDependencies(He.text,lt,Ge,this.allowVerticalPlacement,Je)}}}if(u.get("symbol-placement")==="line"&&(this.features=function(Y){let ee={},me={},ge=[],Te=0;function Ae(Se){ge.push(Y[Se]),Te++}function Ee(Se,Me,ze){let Le=me[Se];return delete me[Se],me[Me]=Le,ge[Le].geometry[0].pop(),ge[Le].geometry[0]=ge[Le].geometry[0].concat(ze[0]),Le}function Be(Se,Me,ze){let Le=ee[Me];return delete ee[Me],ee[Se]=Le,ge[Le].geometry[0].shift(),ge[Le].geometry[0]=ze[0].concat(ge[Le].geometry[0]),Le}function xe(Se,Me,ze){let Le=ze?Me[0].at(-1):Me[0][0];return`${Se}:${Le.x}:${Le.y}`}for(let Se=0;Se<Y.length;Se++){let Me=Y[Se],ze=Me.geometry,Le=Me.text?Me.text.toString():null;if(!Le){Ae(Se);continue}let We=xe(Le,ze),De=xe(Le,ze,!0);if(We in me&&De in ee&&me[We]!==ee[De]){let Ge=Be(We,De,ze),He=Ee(We,De,ge[Ge].geometry);delete ee[We],delete me[De],me[xe(Le,ge[He].geometry,!0)]=He,ge[Ge].geometry=null}else We in me?Ee(We,De,ze):De in ee?Be(We,De,ze):(Ae(Se),ee[We]=Te-1,me[De]=Te-1)}return ge.filter(Se=>Se.geometry)}(this.features)),u.get("symbol-elevation-reference")==="hd-road-markup"){if(this.elevationType="road",i.elevationFeatures){!this.elevationFeatures&&i.elevationFeatures.length>0&&(this.elevationFeatures=[],this.elevationFeatureIdToIndex=new Map);for(let Y of i.elevationFeatures)this.elevationFeatureIdToIndex.set(Y.id,this.elevationFeatures.length),this.elevationFeatures.push(Y)}}else u.get("symbol-z-elevate")&&(this.elevationType="offset");this.elevationType!=="none"&&(this.zOffsetBuffersNeedUpload=!0),this.sortFeaturesByKey&&this.features.sort((Y,ee)=>Y.sortKey-ee.sortKey)}getCombinedIconPrimary(e,i,r,s,l,u,p){let f,g;if(e.hasLayoutProperty("icon-image")){let x=i.getAppearanceValueAndResolveTokens(e,"icon-image",r,s,l);f=this.getResolvedImageFromTokens(x)}else{let x=i.getValueAndResolveTokens("icon-image",r,s,l);f=this.getResolvedImageFromTokens(x)}if(f){let x=e.hasLayoutProperty("icon-size")?e.getUnevaluatedLayoutProperty("icon-size"):i._unevaluatedLayout._values["icon-size"];g=zp(f,ru(this.zoom,x,this.worldview,l),x,s,this.zoom,u,this.pixelRatio,p,this.worldview,l).iconPrimary}return g}updateSymbolInstanceIconVertices(e,i,r,s,l,u){let{canonical:p,availableImages:f,globalProperties:g,layer:x,iconScaleFactor:b,featureState:w,layoutIconOffset:S,layoutIconSize:E,layoutIconRotate:M}=u;if(e.placedIconSymbolIndex<0)return{vertexOffsetDelta:0,hasChanges:!1};if(i.activeAppearanceIndex===r)return{vertexOffsetDelta:e.numIconVertices,hasChanges:!1};let C=r>=0?x.appearances[r]:null;if(C){let R=this.getCombinedIconPrimary(C,x,s,p,f,{sortKey:void 0,text:void 0,icon:null,index:e.featureIndex,sourceLayerIndex:e.featureIndex,geometry:[],properties:i.properties,type:"Point",id:i.id},b);if(!R)return{vertexOffsetDelta:0,hasChanges:!1};let F=R.toString(),z=this.iconAtlasPositions&&this.iconAtlasPositions.get(F);if(z){let{appearanceIconOffset:j,appearanceIconRotate:$}=iv(C,x,s,p,S,M,E,b),H=h_(z,void 0,j,x.layout.get("icon-anchor").evaluate(s,w,p)),ie=z.sdf,W=x.layout.get("icon-text-fit").constantOr("none");W!=="none"&&i.textShaping&&i.iconTextFitPadding&&i.fontScale&&(H=ly(H,i.textShaping,W,i.iconTextFitPadding,j,i.fontScale));
7let Q=this.calculateEffectiveAppearanceIconSize(C,g.zoom,s,p,f,b,E),Y=0,ee=1+(Math.min(ou,Math.round(Q*$a))<<1),me=_y(H,$,ie,W!=="none",b);i.isUsingAppearanceIconVertexData||(i.isUsingAppearanceIconVertexData=!0,i.layoutBasedIconVertexData=this.icon.snapshotSymbolVertexData(l,e.numIconVertices));let ge=Math.floor(e.numIconVertices/4),Te=Math.min(me.length,ge),Ae=l;for(let Be=0;Be<Te;++Be){let xe=me[Be],Se=i.layoutBasedIconVertexData[0]||e.tileAnchorX,Me=i.layoutBasedIconVertexData[1]||e.tileAnchorY,ze=16*xe.pixelOffsetTL.x,Le=16*xe.pixelOffsetTL.y,We=16*xe.pixelOffsetBR.x,De=16*xe.pixelOffsetBR.y,Ge=16*xe.minFontScaleX,He=16*xe.minFontScaleY;this.icon.updateSymbolVertexData(Ae,Se,Me,Math.round(32*xe.tl.x),Math.round(32*xe.tl.y),xe.texPrimary.x,xe.texPrimary.y,Y,ee,ze,Le,Ge,He),this.icon.updateSymbolVertexData(Ae+1,Se,Me,Math.round(32*xe.tr.x),Math.round(32*xe.tr.y),xe.texPrimary.x+xe.texPrimary.w,xe.texPrimary.y,Y,ee,We,Le,Ge,He),this.icon.updateSymbolVertexData(Ae+2,Se,Me,Math.round(32*xe.bl.x),Math.round(32*xe.bl.y),xe.texPrimary.x,xe.texPrimary.y+xe.texPrimary.h,Y,ee,ze,De,Ge,He),this.icon.updateSymbolVertexData(Ae+3,Se,Me,Math.round(32*xe.br.x),Math.round(32*xe.br.y),xe.texPrimary.x+xe.texPrimary.w,xe.texPrimary.y+xe.texPrimary.h,Y,ee,We,De,Ge,He),Ae+=4}let Ee=e.numIconVertices-4*Te;for(let Be=0;Be<Ee;++Be)this.icon.updateSymbolVertexData(Ae+Be,0,0,0,0,0,0,0,0,0,0,0,0);return{vertexOffsetDelta:e.numIconVertices,hasChanges:!0}}}else{if(i.usesAppearanceIconAsPlaceholder)return this.icon.updateSymbolVertexData(l,0,0,0,0,0,0,0,0,0,0,0,0),this.icon.updateSymbolVertexData(l+1,0,0,0,0,0,0,0,0,0,0,0,0),this.icon.updateSymbolVertexData(l+2,0,0,0,0,0,0,0,0,0,0,0,0),this.icon.updateSymbolVertexData(l+3,0,0,0,0,0,0,0,0,0,0,0,0),{vertexOffsetDelta:e.numIconVertices,hasChanges:!0};if(i.isUsingAppearanceIconVertexData)return this.icon.restoreSymbolVertexData(l,i.layoutBasedIconVertexData),i.isUsingAppearanceIconVertexData=!1,{vertexOffsetDelta:i.layoutBasedIconVertexData.length/Mh,hasChanges:!0}}return{vertexOffsetDelta:e.numIconVertices,hasChanges:!1}}updateSymbolInstanceTextVertices(e,i,r,s,l,u){let{canonical:p,layer:f,textScaleFactor:g,imageMap:x,featureState:b,layoutTextOffset:w,layoutTextSize:S,layoutTextRotate:E,layoutMinZoomSize:M,layoutMaxZoomSize:C,layoutTextSizeMinZoom:R,layoutTextSizeMaxZoom:F,availableImages:z}=u,j=e.numHorizontalGlyphVertices>0||e.numVerticalGlyphVertices>0;if(!j)return{vertexOffsetDelta:j?e.numHorizontalGlyphVertices+e.numVerticalGlyphVertices:0,hasChanges:!1};if(i.activeAppearanceIndex===r)return{vertexOffsetDelta:e.numHorizontalGlyphVertices+e.numVerticalGlyphVertices,hasChanges:!1};let $=r>=0?f.appearances[r]:null;if($&&i.textShaping){let{appearanceTextOffset:H,appearanceTextRotate:ie,appearanceTextSize:W}=nv($,f,s,p,w,E,S);i.fontScale=av(W,i.textScaleFactor);let Q=$.getUnevaluatedLayoutProperty("text-size"),Y=this.textSizeData,ee=R,me=F;$.hasLayoutProperty("text-size")&&(Y=ru(this.zoom,Q,this.worldview,z),ee=this.textSizeData.kind==="composite"?this.textSizeData.minZoom:0,me=this.textSizeData.kind==="composite"?this.textSizeData.maxZoom:0);let ge=i.textShaping.bottom-w[1],Te=i.textShaping.left-w[0],Ae=i.textShaping.right-w[0];i.textShaping.top=H[1]+(i.textShaping.top-w[1]),i.textShaping.bottom=H[1]+ge,i.textShaping.left=H[0]+Te,i.textShaping.right=H[0]+Ae;let Ee=ev(0,i.textShaping,H,f,!1,s,x,this.allowVerticalPlacement,ie),Be=W&&Y.kind==="composite"?Q.possiblyEvaluate(new Xt(ee,{}),p).evaluate(s,b,p):M,xe=W&&Y.kind==="composite"?Q.possiblyEvaluate(new Xt(me,{}),p).evaluate(s,b,p):C,Se=vy($.name,Y,W,g,Be,xe),Me=Array.isArray(Se)?Se[1]:W,ze=0,Le=1+(Math.min(ou,Math.round(Me*$a))<<1);i.isUsingAppearanceTextVertexData||(i.isUsingAppearanceTextVertexData=!0,i.layoutBasedTextVertexData=this.text.snapshotSymbolVertexData(l,e.numHorizontalGlyphVertices+e.numVerticalGlyphVertices));for(let We=0;We<Ee.length&&We<(e.numHorizontalGlyphVertices+e.numVerticalGlyphVertices)/4;++We){let De=Ee[We],Ge=De.glyphOffset[1],He=e.tileAnchorX,Je=e.tileAnchorY,tt=l+4*We;this.text.updateSymbolVertexData(tt,He,Je,Math.round(32*De.tl.x),Math.round(32*(Ge+De.tl.y)),De.texPrimary.x,De.texPrimary.y,ze,Le,De.pixelOffsetTL.x,De.pixelOffsetTL.y,De.minFontScaleX,De.minFontScaleY),this.text.updateSymbolVertexData(tt+1,He,Je,Math.round(32*De.tr.x),Math.round(32*(Ge+De.tr.y)),De.texPrimary.x+De.texPrimary.w,De.texPrimary.y,ze,Le,De.pixelOffsetBR.x,De.pixelOffsetTL.y,De.minFontScaleX,De.minFontScaleY),this.text.updateSymbolVertexData(tt+2,He,Je,Math.round(32*De.bl.x),Math.round(32*(Ge+De.bl.y)),De.texPrimary.x,De.texPrimary.y+De.texPrimary.h,ze,Le,De.pixelOffsetTL.x,De.pixelOffsetBR.y,De.minFontScaleX,De.minFontScaleY),this.text.updateSymbolVertexData(tt+3,He,Je,Math.round(32*De.br.x),Math.round(32*(Ge+De.br.y)),De.texPrimary.x+De.texPrimary.w,De.texPrimary.y+De.texPrimary.h,ze,Le,De.pixelOffsetBR.x,De.pixelOffsetBR.y,De.minFontScaleX,De.minFontScaleY)}return{vertexOffsetDelta:e.numHorizontalGlyphVertices+e.numVerticalGlyphVertices,hasChanges:!0}}return i.isUsingAppearanceTextVertexData?(this.text.restoreSymbolVertexData(l,i.layoutBasedTextVertexData),i.isUsingAppearanceTextVertexData=!1,{vertexOffsetDelta:i.layoutBasedTextVertexData.length/Mh,hasChanges:!0}):{vertexOffsetDelta:e.numHorizontalGlyphVertices+e.numVerticalGlyphVertices,hasChanges:!1}}updateExpressions(e){this.text&&this.text.programConfigurations.updateExpressions(e),this.icon&&this.icon.programConfigurations.updateExpressions(e)}update(e,i,r,s,l,u,p,f){if(this.text.uboBinder||this.text.programConfigurations.updatePaintArrays(e,i,l,r,s,u,p,this.worldview),this.icon.uboBinder||this.icon.programConfigurations.updatePaintArrays(e,i,l,r,s,u,p,this.worldview),f){if(u)this.text.uboBinder&&!this.text.uboBinder.isLightConstant&&this.text.uboBinder.updateDynamicExpressions(l[0],i,f,r,e,p),this.icon.uboBinder&&!this.icon.uboBinder.isLightConstant&&this.icon.uboBinder.updateDynamicExpressions(l[0],i,f,r,e,p);else if(Object.keys(e).length>0){let g=new Set(Object.keys(e).map(x=>{let b=Number(x);return!isNaN(b)&&Number.isSafeInteger(b)&&String(b)===x?b:x}));this.text.uboBinder&&this.text.uboBinder.updateFeatures(g,l[0],i,f,r,e,p),this.icon.uboBinder&&this.icon.uboBinder.updateFeatures(g,l[0],i,f,r,e,p)}}}updateRoadElevation(e){if(this.elevationType!=="road"||!this.elevationFeatures||this.elevationStateComplete)return;this.elevationStateComplete=!0,this.hasAnyZOffset=!1;let i=!1,r=Vr(e),s=1/r,l=!1,u=!1;for(let p=0;p<this.symbolInstances.length;p++){let f=this.symbolInstances.get(p),g=Fn(1,0,0),x=Fn(0,1,0),{numHorizontalGlyphVertices:b,numVerticalGlyphVertices:w,numIconVertices:S,numVerticalIconVertices:E}=f,M=b>0||w>0,C=S>0,R=this.elevationFeatures[f.elevationFeatureIndex];if(R){let F=new ke(f.tileAnchorX,f.tileAnchorY),z=.075+R.pointElevation(F);f.zOffset!==z&&(i=!0,f.zOffset=z),z!==0&&(this.hasAnyZOffset=!0);let j=R.computeSlopeNormal(F,s),$=sc(gs(),Fn(0,0,1),j);Za(g,g,$),Za(x,x,$),g[2]*=r,x[2]*=r,g[0]===1&&g[1]===0&&g[2]===0&&x[0]===0&&x[1]===1&&x[2]===0||(l=l||M,u=u||C)}if(M&&(w_(this.text.orientationVertexArray,b,g,x),w_(this.text.orientationVertexArray,w,g,x)),C){let{placedIconSymbolIndex:F,verticalPlacedIconSymbolIndex:z}=f;F>=0&&w_(this.icon.orientationVertexArray,S,g,x),z>=0&&w_(this.icon.orientationVertexArray,E,g,x)}}l||(this.text.orientationVertexArray=void 0),u||(this.icon.orientationVertexArray=void 0),i&&(this.zOffsetBuffersNeedUpload=!0,this.zOffsetSortDirty=!0)}updateZOffset(){let e=(l,u,p)=>{r+=u,r>l.length&&l.resize(r);for(let f=-u;f<0;f++)l.emplace(f+r,p)},i=(l,u,p)=>{s+=u,s>l.length&&l.resize(s);for(let f=-u;f<0;f++)l.emplace(f+s,p)};if(!this.zOffsetBuffersNeedUpload)return;this.zOffsetBuffersNeedUpload=!1;let r=0,s=0;for(let l=0;l<this.symbolInstances.length;l++){let u=this.symbolInstances.get(l),{numHorizontalGlyphVertices:p,numVerticalGlyphVertices:f,numIconVertices:g}=u,x=u.zOffset,b=g>0;if((p>0||f>0)&&(e(this.text.zOffsetVertexArray,p,x),e(this.text.zOffsetVertexArray,f,x)),b){let{placedIconSymbolIndex:w,verticalPlacedIconSymbolIndex:S}=u;w>=0&&i(this.icon.zOffsetVertexArray,g,x),S>=0&&i(this.icon.zOffsetVertexArray,u.numVerticalIconVertices,x)}}this.text.zOffsetVertexBuffer&&this.text.zOffsetVertexBuffer.updateData(this.text.zOffsetVertexArray),this.icon.zOffsetVertexBuffer&&this.icon.zOffsetVertexBuffer.updateData(this.icon.zOffsetVertexArray)}isEmpty(){return this.symbolInstances.length===0&&!this.hasRTLText}uploadPending(){return!this.uploaded||this.text.programConfigurations.needsUpload||this.icon.programConfigurations.needsUpload}upload(e,i,r,s,l){!this.uploaded&&this.hasDebugData()&&(this.textCollisionBox.upload(e),this.iconCollisionBox.upload(e)),this.text.upload(e,this.sortFeaturesByY,!this.uploaded,this.text.programConfigurations.needsUpload,this.zOffsetBuffersNeedUpload,this.hasAppearances),this.hasAppearances===null&&(this.hasAppearances=this.layers.some(u=>u.appearances&&u.appearances.length>0)),this.icon.upload(e,this.sortFeaturesByY,!this.uploaded,this.icon.programConfigurations.needsUpload,this.zOffsetBuffersNeedUpload,this.hasAppearances),this.uploaded=!0}updateAppearances(e,i,r,s,l,u=!1){let p={hasLayoutChanges:!1,hasUboChanges:!1};if(!e||!r||!this.featureAppearanceData)return p;let f=i||{},g=this.icon.layoutVertexArray&&this.icon.layoutVertexArray.length>0&&this.icon.layoutVertexArray.arrayBuffer,x=this.text.layoutVertexArray&&this.text.layoutVertexArray.length>0&&this.text.layoutVertexArray.arrayBuffer;if(!g&&!x)return p;let b=this.layers[0],w=b.layout;this.featureAppearances&&this.featureAppearances.appearancesVersion===b.appearancesVersion||(this.featureAppearances=new tT(b.appearances,b.appearancesVersion));let S=this.featureAppearances.update(s,u);if(S.kind==="no-changes")return p;let E=1,M=0,C=!1,R=!1;if(g){let[H,ie]=w.get("icon-size-scale-range");E=ne(1,H,ie)}let F=1,z=0,j=!1;if(x){let[H,ie]=w.get("text-size-scale-range");F=ne(1,H,ie)}let $=new Map;if(l&&r)for(let H of r){let ie=l.getImage(H,b.scope);if(ie){let W=new xr(H.toString());$.set(W.toString(),ie)}}for(let H=0;H<this.symbolInstances.length;H++){let ie=this.symbolInstances.get(H),W=this.getAppearanceFeatureData(ie.featureIndex);if(!W)continue;let Q=W.id,Y=Q!==void 0?f[String(Q)]:void 0,ee={type:"Point",id:W.id,properties:W.properties,geometry:[]},me;if(S.kind==="all-features")me=S.appearanceIndex;else{let Te=b.appearances?b.appearances.findIndex(Ae=>Ae.isActive({globals:s,feature:ee,canonical:e,featureState:Y})):-1;me=Te>=0?Te:-1}let ge=W.activeAppearanceIndex!==me;if(x){let Te=w.get("text-size"),Ae=this.textSizeData.kind==="composite"?this.textSizeData.minZoom:0,Ee=this.textSizeData.kind==="composite"?this.textSizeData.maxZoom:0,Be={canonical:e,layer:b,featureState:Y,availableImages:r,textScaleFactor:F,imageMap:$,layoutTextOffset:w.get("text-offset").evaluate(ee,Y,e).map(Se=>Se*Tn),layoutTextSize:Te.evaluate(ee,Y,e),layoutTextRotate:w.get("text-rotate").evaluate(ee,Y,e),layoutMinZoomSize:Te.evaluate(ee,{zoom:Ae},e),layoutMaxZoomSize:Te.evaluate(ee,{zoom:Ee},e),layoutTextSizeMinZoom:Ae,layoutTextSizeMaxZoom:Ee},xe=this.updateSymbolInstanceTextVertices(ie,W,me,ee,z,Be);z+=xe.vertexOffsetDelta,j=j||xe.hasChanges}if(g){let Te={canonical:e,layer:b,featureState:Y,availableImages:r,globalProperties:s,iconScaleFactor:E,layoutIconOffset:w.get("icon-offset").evaluate(ee,Y,e),layoutIconSize:w.get("icon-size").evaluate(ee,Y,e,r),layoutIconRotate:w.get("icon-rotate").evaluate(ee,Y,e)},Ae=this.updateSymbolInstanceIconVertices(ie,W,me,ee,M,Te);M+=Ae.vertexOffsetDelta,C=C||Ae.hasChanges}if(ge){let Te=ie.featureIndex,Ae=s?s.brightness:null,Ee=Y||{},Be=me>=0?b.appearances[me]:null;this.text.uboBinder&&(this.text.uboBinder.layer=b,R=this.text.uboBinder.updateFeaturePaintForAppearance(Te,ee,Ee,e,r,Ae,Be)||R),this.icon.uboBinder&&(this.icon.uboBinder.layer=b,R=this.icon.uboBinder.updateFeaturePaintForAppearance(Te,ee,Ee,e,r,Ae,Be)||R)}W.activeAppearanceIndex=me}return C&&this.icon.layoutVertexBuffer&&this.icon.layoutVertexArray.arrayBuffer!==null&&this.icon.layoutVertexArray.length===this.icon.layoutVertexBuffer.length&&this.icon.layoutVertexBuffer.updateData(this.icon.layoutVertexArray),j&&this.text.layoutVertexBuffer&&this.text.layoutVertexArray.arrayBuffer!==null&&this.text.layoutVertexArray.length===this.text.layoutVertexBuffer.length&&this.text.layoutVertexBuffer.updateData(this.text.layoutVertexArray),{hasLayoutChanges:C||j,hasUboChanges:R}}destroyDebugData(){this.textCollisionBox.destroy(),this.iconCollisionBox.destroy()}getProjection(){return this.projectionInstance||(this.projectionInstance=mv(this.projection)),this.projectionInstance}destroy(){this.text.destroy(),this.icon.destroy(),this.hasDebugData()&&this.destroyDebugData()}addToLineVertexArray(e,i){let r=this.lineVertexArray.length;if(e.segment!==void 0)for(let{x:s,y:l}of i)this.lineVertexArray.emplaceBack(s,l);return{lineStartIndex:r,lineLength:this.lineVertexArray.length-r}}addSymbols(e,i,r,s,l,u,p,f,g,x,b,w,S,E,M,C,R,F){let z=e.indexArray,j=e.layoutVertexArray,$=e.globeExtVertexArray,H=F,ie=e.uboBinder?e.uboBinder.getCurrentBatchIndex():void 0,W=e.segments.prepareSegment(4*H,j,z,this.canOverlap?u.sortKey:void 0,ie),Q=this.glyphOffsetArray.length,Y=W.vertexLength,ee=this.allowVerticalPlacement&&p===Zr.vertical?Math.PI/2:0,me=u.text&&u.text.sections,ge=j.length,Te=-1;for(let Be=0;Be<i.length;Be++){let{tl:xe,tr:Se,bl:Me,br:ze,texPrimary:Le,texSecondary:We,pixelOffsetTL:De,pixelOffsetBR:Ge,minFontScaleX:He,minFontScaleY:Je,glyphOffset:tt,isSDF:lt,sectionIndex:rt}=i[Be],pt=W.vertexLength,Ht=tt[1];if(kp(j,g.x,g.y,xe.x,Ht+xe.y,Le.x,Le.y,r,lt,De.x,De.y,He,Je),kp(j,g.x,g.y,Se.x,Ht+Se.y,Le.x+Le.w,Le.y,r,lt,Ge.x,De.y,He,Je),kp(j,g.x,g.y,Me.x,Ht+Me.y,Le.x,Le.y+Le.h,r,lt,De.x,Ge.y,He,Je),kp(j,g.x,g.y,ze.x,Ht+ze.y,Le.x+Le.w,Le.y+Le.h,r,lt,Ge.x,Ge.y,He,Je),f){let{x:wt,y:kt,z:At}=f.anchor,[Ui,Jt,Gt]=f.up;Up($,wt,kt,At,Ui,Jt,Gt),Up($,wt,kt,At,Ui,Jt,Gt),Up($,wt,kt,At,Ui,Jt,Gt),Up($,wt,kt,At,Ui,Jt,Gt),Ah(e.dynamicLayoutVertexArray,wt,kt,At,ee)}else Ah(e.dynamicLayoutVertexArray,g.x,g.y,g.z,ee);if(C){let wt=We||Le;Np(e.iconTransitioningVertexArray,wt.x,wt.y),Np(e.iconTransitioningVertexArray,wt.x+wt.w,wt.y),Np(e.iconTransitioningVertexArray,wt.x,wt.y+wt.h),Np(e.iconTransitioningVertexArray,wt.x+wt.w,wt.y+wt.h)}if(z.emplaceBack(pt,pt+1,pt+2),z.emplaceBack(pt+1,pt+2,pt+3),W.vertexLength+=4,W.primitiveLength+=2,this.glyphOffsetArray.emplaceBack(tt[0]),(Be===i.length-1||rt!==i[Be+1].sectionIndex)&&(e.uboBinder||e.programConfigurations.populatePaintArrays(j.length,u,u.index,{},S,E,M,me&&me[rt],this.worldview),e.uboBinder&&e.featureIdArray)){let wt=e.uboBinder.populateUBO(u,u.index,E,S,M,me&&me[rt],void 0);Te=wt;let kt=j.length-ge;for(let At=0;At<kt;At++)e.featureIdArray.emplaceBack(wt);ge=j.length}}let Ae=F-i.length;if(Ae!==0&&(this._addNullVertices(Ae,j,r,f,$,e,C,W,z),e.uboBinder&&e.featureIdArray&&Te>=0)){let Be=4*Ae;for(let xe=0;xe<Be;xe++)e.featureIdArray.emplaceBack(Te)}let Ee=f?f.anchor:g;e.placedSymbolArray.emplaceBack(Ee.x,Ee.y,Ee.z,g.x,g.y,Q,this.glyphOffsetArray.length-Q,Y,x,b,g.segment,r?r[0]:0,r?r[1]:0,s[0],s[1],p,0,0,0,w,0),e.symbolInstanceIndices.push(R)}_addNullVertices(e,i,r,s,l,u,p,f,g){for(let x=0;x<e;x++){for(let w=0;w<4;w++)kp(i,0,0,0,0,0,0,r,!1,0,0,0,0),s&&Up(l,0,0,0,0,0,0),Ah(u.dynamicLayoutVertexArray,0,0,0,0),p&&Np(u.iconTransitioningVertexArray,0,0);let b=f.vertexLength;g.emplaceBack(b,b+1,b+2),g.emplaceBack(b+1,b+2,b+3),f.vertexLength+=4,f.primitiveLength+=2,this.glyphOffsetArray.emplaceBack(0)}}_commitLayoutVertex(e,i,r,s,l,u,p){e.emplaceBack(i,r,s,l,u,Math.round(p.x),Math.round(p.y))}_addCollisionDebugVertices(e,i,r,s,l,u,p){let f=r.segments.prepareSegment(4,r.layoutVertexArray,r.indexArray),g=f.vertexLength,x=p.tileAnchorX,b=p.tileAnchorY;for(let S=0;S<4;S++)r.collisionVertexArray.emplaceBack(0,0,0,0,0,0);this._commitDebugCollisionVertexUpdate(r.collisionVertexArrayExt,i,e.padding,p.zOffset),this._commitLayoutVertex(r.layoutVertexArray,s,l,u,x,b,new ke(e.x1,e.y1)),this._commitLayoutVertex(r.layoutVertexArray,s,l,u,x,b,new ke(e.x2,e.y1)),this._commitLayoutVertex(r.layoutVertexArray,s,l,u,x,b,new ke(e.x2,e.y2)),this._commitLayoutVertex(r.layoutVertexArray,s,l,u,x,b,new ke(e.x1,e.y2)),f.vertexLength+=4;let w=r.indexArray;w.emplaceBack(g,g+1),w.emplaceBack(g+1,g+2),w.emplaceBack(g+2,g+3),w.emplaceBack(g+3,g),f.primitiveLength+=4}_addTextDebugCollisionBoxes(e,i,r,s,l,u){for(let p
7=s;p<l;p++){let f=r.get(p),g=this.getSymbolInstanceTextSize(e,u,i,p);this._addCollisionDebugVertices(f,g,this.textCollisionBox,f.projectedAnchorX,f.projectedAnchorY,f.projectedAnchorZ,u)}}_addIconDebugCollisionBoxes(e,i,r,s,l,u){for(let p=s;p<l;p++){let f=r.get(p),g=this.getSymbolInstanceIconSize(e,i,u.placedIconSymbolIndex);this._addCollisionDebugVertices(f,g,this.iconCollisionBox,f.projectedAnchorX,f.projectedAnchorY,f.projectedAnchorZ,u)}}generateCollisionDebugBuffers(e,i,r){this.hasDebugData()&&this.destroyDebugData(),this.textCollisionBox=new Ty(sh,Ax.members,kr),this.iconCollisionBox=new Ty(sh,Ax.members,kr);let s=Sh(this.iconSizeData,e),l=Sh(this.textSizeData,e,r);for(let u=0;u<this.symbolInstances.length;u++){let p=this.symbolInstances.get(u);this._addTextDebugCollisionBoxes(l,e,i,p.textBoxStartIndex,p.textBoxEndIndex,p),this._addTextDebugCollisionBoxes(l,e,i,p.verticalTextBoxStartIndex,p.verticalTextBoxEndIndex,p),this._addIconDebugCollisionBoxes(s,e,i,p.iconBoxStartIndex,p.iconBoxEndIndex,p),this._addIconDebugCollisionBoxes(s,e,i,p.verticalIconBoxStartIndex,p.verticalIconBoxEndIndex,p)}}getSymbolInstanceTextSize(e,i,r,s){let l=this.text.placedSymbolArray.get(i.rightJustifiedTextSymbolIndex>=0?i.rightJustifiedTextSymbolIndex:i.centerJustifiedTextSymbolIndex>=0?i.centerJustifiedTextSymbolIndex:i.leftJustifiedTextSymbolIndex>=0?i.leftJustifiedTextSymbolIndex:i.verticalPlacedTextSymbolIndex>=0?i.verticalPlacedTextSymbolIndex:s),u=cy(this.textSizeData,e,l)/Tn;return this.tilePixelRatio*u}getSymbolInstanceIconSize(e,i,r){let s=this.icon.placedSymbolArray.get(r),l=cy(this.iconSizeData,e,s);return this.tilePixelRatio*l}
7_commitDebugCollisionVertexUpdate(e,i,r,s){e.emplaceBack(i,-r,-r,s),e.emplaceBack(i,r,-r,s),e.emplaceBack(i,r,r,s),e.emplaceBack(i,-r,r,s)}_updateTextDebugCollisionBoxes(e,i,r,s,l,u,p){for(let f=s;f<l;f++){let g=r.get(f),x=this.getSymbolInstanceTextSize(e,u,i,f);this._commitDebugCollisionVertexUpdate(this.textCollisionBox.collisionVertexArrayExt,x,g.padding,u.zOffset)}}_updateIconDebugCollisionBoxes(e,i,r,s,l,u,p){for(let f=s;f<l;f++){let g=r.get(f),x=this.getSymbolInstanceIconSize(e,i,u.placedIconSymbolIndex);this._commitDebugCollisionVertexUpdate(this.iconCollisionBox.collisionVertexArrayExt,x,g.padding,u.zOffset)}}updateCollisionDebugBuffers(e,i,r,s){if(!this.hasDebugData())return;this.hasTextCollisionBoxData()&&this.textCollisionBox.collisionVertexArrayExt.clear(),this.hasIconCollisionBoxData()&&this.iconCollisionBox.collisionVertexArrayExt.clear();let l=Sh(this.iconSizeData,e,s),u=Sh(this.textSizeData,e,r);for(let p=0;p<this.symbolInstances.length;p++){let f=this.symbolInstances.get(p);this._updateTextDebugCollisionBoxes(u,e,i,f.textBoxStartIndex,f.textBoxEndIndex,f,r),this._updateTextDebugCollisionBoxes(u,e,i,f.verticalTextBoxStartIndex,f.verticalTextBoxEndIndex,f,r),this._updateIconDebugCollisionBoxes(l,e,i,f.iconBoxStartIndex,f.iconBoxEndIndex,f,s),this._updateIconDebugCollisionBoxes(l,e,i,f.verticalIconBoxStartIndex,f.verticalIconBoxEndIndex,f,s)}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,s,l,u,p,f,g){let x={};if(i<r){let{x1:b,y1:w,x2:S,y2:E,padding:M,projectedAnchorX:C,projectedAnchorY:R,projectedAnchorZ:F,tileAnchorX:z,tileAnchorY:j,featureIndex:$}=e.get(i);x.textBox={x1:b,y1:w,x2:S,y2:E,padding:M,projectedAnchorX:C,projectedAnchorY:R,projectedAnchorZ:F,tileAnchorX:z,tileAnchorY:j},x.textFeatureIndex=$}if(s<l){let{x1:b,y1:w,x2:S,y2:E,padding:M,projectedAnchorX:C,projectedAnchorY:R,projectedAnchorZ:F,tileAnchorX:z,tileAnchorY:j,featureIndex:$}=e.get(s);x.verticalTextBox={x1:b,y1:w,x2:S,y2:E,padding:M,projectedAnchorX:C,projectedAnchorY:R,projectedAnchorZ:F,tileAnchorX:z,tileAnchorY:j},x.verticalTextFeatureIndex=$}if(u<p){let{x1:b,y1:w,x2:S,y2:E,padding:M,projectedAnchorX:C,projectedAnchorY:R,projectedAnchorZ:F,tileAnchorX:z,tileAnchorY:j,featureIndex:$}=e.get(u);x.iconBox={x1:b,y1:w,x2:S,y2:E,padding:M,projectedAnchorX:C,projectedAnchorY:R,projectedAnchorZ:F,tileAnchorX:z,tileAnchorY:j},x.iconFeatureIndex=$}if(f<g){let{x1:b,y1:w,x2:S,y2:E,padding:M,projectedAnchorX:C,projectedAnchorY:R,projectedAnchorZ:F,tileAnchorX:z,tileAnchorY:j,featureIndex:$}=e.get(f);x.verticalIconBox={x1:b,y1:w,x2:S,y2:E,padding:M,projectedAnchorX:C,projectedAnchorY:R,projectedAnchorZ:F,tileAnchorX:z,tileAnchorY:j},x.verticalIconFeatureIndex=$}return x}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),s=r.vertexStartIndex+4*r.numGlyphs;for(let l=r.vertexStartIndex;l<s;l+=4)e.indexArray.emplaceBack(l,l+1,l+2),e.indexArray.emplaceBack(l+1,l+2,l+3)}
7getSortedSymbolIndexes(e){if(this.sortedAngle===e&&this.symbolInstanceIndexes!==void 0)return this.symbolInstanceIndexes;let i=Math.sin(e),r=Math.cos(e),s=[],l=[],u=[];for(let p=0;p<this.symbolInstances.length;++p){u.push(p);let f=this.symbolInstances.get(p);s.push(0|Math.round(i*f.tileAnchorX+r*f.tileAnchorY)),l.push(f.featureIndex)}return u.sort((p,f)=>s[p]-s[f]||l[f]-l[p]),u}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.at(-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)if(this.text.segments.get().length>1||this.icon.segments.get().length>1)this.sortFeaturesWithinSegments();else{this.symbolInstanceIndexes=this.getSortedSymbolIndexes(e),this.sortedAngle=e,this.text.indexArray.clear(),this.icon.indexArray.clear(),this.featureSortOrder=[];for(let i of this.symbolInstanceIndexes){let r=this.symbolInstances.get(i);this.featureSortOrder.push(r.featureIndex);let{rightJustifiedTextSymbolIndex:s,centerJustifiedTextSymbolIndex:l,leftJustifiedTextSymbolIndex:u,verticalPlacedTextSymbolIndex:p,placedIconSymbolIndex:f,verticalPlacedIconSymbolIndex:g}=r;s>=0&&this.addIndicesForPlacedSymbol(this.text,s),l>=0&&l!==s&&this.addIndicesForPlacedSymbol(this.text,l),u>=0&&u!==l&&u!==s&&this.addIndicesForPlacedSymbol(this.text,u),p>=0&&this.addIndicesForPlacedSymbol(this.text,p),f>=0&&this.addIndicesForPlacedSymbol(this.icon,f),g>=0&&this.addIndicesForPlacedSymbol(this.icon,g)}this.text.indexBuffer&&this.text.indexBuffer.updateData(this.text.indexArray),this.icon.indexBuffer&&this.icon.indexBuffer.updateData(this.icon.indexArray)}}getOrCreateSortedSymbolsByBatch(e,i){let r=(this.text.uboBinder&&this.text.uboBinder.maxFeaturesPerBatch>0?this.text.uboBinder:this.icon.uboBinder&&this.icon.uboBinder.maxFeaturesPerBatch>0?this.icon.uboBinder:null).maxFeaturesPerBatch;if(this.symbolsByBatch)for(let s of this.symbolsByBatch.values())for(let l of s){let u=this.symbolInstances.get(l.index);l.rotatedY=0|Math.round(e*u.tileAnchorX+i*u.tileAnchorY)}else{this.symbolsByBatch=new Map;for(let s=0;s<this.symbolInstances.length;s++){let l=this.symbolInstances.get(s),u=Math.floor(s/r),p=0|Math.round(e*l.tileAnchorX+i*l.tileAnchorY);this.symbolsByBatch.has(u)||this.symbolsByBatch.set(u,[]),this.symbolsByBatch.get(u).push({index:s,rotatedY:p,featureIndex:l.featureIndex})}}for(let s of this.symbolsByBatch.values())s.sort((l,u)=>l.rotatedY-u.rotatedY||u.featureIndex-l.featureIndex);return this.symbolsByBatch}rebuildTextSegmentIndices(e,i){for(let r of e){let s=r.batchIndex;if(s===void 0)continue;let l=i.get(s);if(!l){r.primitiveOffset=this.text.indexArray.length,r.primitiveLength=0;continue}r.primitiveOffset=this.text.indexArray.length;let u=this.text.indexArray.length;for(let{index:p}of l){let f=this.symbolInstances.get(p),{rightJustifiedTextSymbolIndex:g,centerJustifiedTextSymbolIndex:x,leftJustifiedTextSymbolIndex:b,verticalPlacedTextSymbolIndex:w}=f;g>=0&&this.addIndicesForPlacedSymbol(this.text,g),x>=0&&x!==g&&this.addIndicesForPlacedSymbol(this.text,x),b>=0&&b!==x&&b!==g&&this.addIndicesForPlacedSymbol(this.text,b),w>=0&&this.addIndicesForPlacedSymbol(this.text,w)}r.primitiveLength=this.text.indexArray.length-u}}rebuildIconSegmentIndices(e,i){for(let r of e){let s=r.batchIndex;if(s===void 0)continue;let l=i.get(s);if(!l){r.primitiveOffset=this.icon.indexArray.length,r.primitiveLength=0;continue}r.primitiveOffset=this.icon.indexArray.length;let u=this.icon.indexArray.length;for(let{index:p}of l){let f=this.symbolInstances.get(p),{placedIconSymbolIndex:g,verticalPlacedIconSymbolIndex:x}=f;g>=0&&this.addIndicesForPlacedSymbol(this.icon,g),x>=0&&this.addIndicesForPlacedSymbol(this.icon,x)}r.primitiveLength=this.icon.indexArray.length-u}}sortFeaturesWithinSegments(){this.featureSortOrder=[];let e=Math.sin(this.sortedAngle),i=Math.cos(this.sortedAngle),r=this.getOrCreateSortedSymbolsByBatch(e,i),s=Array.from(r.keys()).sort((l,u)=>l-u);for(let l of s){let u=r.get(l);for(let{index:p}of u){let f=this.symbolInstances.get(p);this.featureSortOrder.push(f.featureIndex)}}this.text.indexArray.clear(),this.icon.indexArray.clear(),this.rebuildTextSegmentIndices(this.text.segments.get(),r),this.rebuildIconSegmentIndices(this.icon.segments.get(),r),this.text.indexBuffer&&this.text.indexBuffer.updateData(this.text.indexArray),this.icon.indexBuffer&&this.icon.indexBuffer.updateData(this.icon.indexArray)}getElevationFeatureForText(e){let i=this.symbolInstances.get(this.text.symbolInstanceIndices[e]).elevationFeatureIndex,r;return this.elevationFeatures&&i<this.elevationFeatures.length&&(r=this.elevationFeatures[i]),r}}function _v(n,e){return e.replace(/{([^{}]+)}/g,(i,r)=>r in n?String(n[r]):"")}let gv,yv,Sy;Qe(Bo,"SymbolBucket",{omit:["layers","collisionBoxArray","compareText","features"]}),Bo.addDynamicAttributes=Ah;class xv{constructor(e){this.type=e.property.overrides?e.property.overrides.runtimeType:ya,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}}Qe(xv,"FormatSectionOverride",{omit:["defaultValue"]});let Iy=()=>Sy||(Sy={layout:gv||(gv=new wi({"symbol-placement":new qe(he.layout_symbol["symbol-placement"]),"symbol-spacing":new qe(he.layout_symbol["symbol-spacing"]),"symbol-avoid-edges":new qe(he.layout_symbol["symbol-avoid-edges"]),"symbol-sort-key":new Ze(he.layout_symbol["symbol-sort-key"]),"symbol-z-order":new qe(he.layout_symbol["symbol-z-order"]),"symbol-z-elevate":new qe(he.layout_symbol["symbol-z-elevate"]),"symbol-elevation-reference":new qe(he.layout_symbol["symbol-elevation-reference"]),"icon-allow-overlap":new qe(he.layout_symbol["icon-allow-overlap"]),"icon-ignore-placement":new qe(he.layout_symbol["icon-ignore-placement"]),"icon-optional":new qe(he.layout_symbol["icon-optional"]),"icon-rotation-alignment":new qe(he.layout_symbol["icon-rotation-alignment"]),"icon-size":new Ze(he.layout_symbol["icon-size"]),"icon-size-scale-range":new qe(he.layout_symbol["icon-size-scale-range"]),"icon-text-fit":new Ze(he.layout_symbol["icon-text-fit"]),"icon-text-fit-padding":new Ze(he.layout_symbol["icon-text-fit-padding"]),"icon-image":new Ze(he.layout_symbol["icon-image"]),"icon-image-use-theme":new qe({type:"string",default:"default","property-type":"data-constant"}),"icon-rotate":new Ze(he.layout_symbol["icon-rotate"]),"icon-padding":new qe(he.layout_symbol["icon-padding"]),"icon-keep-upright":new qe(he.layout_symbol["icon-keep-upright"]),"icon-offset":new Ze(he.layout_symbol["icon-offset"]),"icon-anchor":new Ze(he.layout_symbol["icon-anchor"]),"icon-pitch-alignment":new qe(he.layout_symbol["icon-pitch-alignment"]),"text-pitch-alignment":new qe(he.layout_symbol["text-pitch-alignment"]),"text-rotation-alignment":new qe(he.layout_symbol["text-rotation-alignment"]),"text-field":new Ze(he.layout_symbol["text-field"]),"text-font":new Ze(he.layout_symbol["text-font"]),"text-size":new Ze(he.layout_symbol["text-size"]),"text-size-scale-range":new qe(he.layout_symbol["text-size-scale-range"]),"text-max-width":new Ze(he.layout_symbol["text-max-width"]),"text-line-height":new Ze(he.layout_symbol["text-line-height"]),"text-letter-spacing":new Ze(he.layout_symbol["text-letter-spacing"]),"text-justify":new Ze(he.layout_symbol["text-justify"]),"text-radial-offset":new Ze(he.layout_symbol["text-radial-offset"]),"text-variable-anchor":new qe(he.layout_symbol["text-variable-anchor"]),"text-anchor":new Ze(he.layout_symbol["text-anchor"]),"text-max-angle":new qe(he.layout_symbol["text-max-angle"]),"text-writing-mode":new qe(he.layout_symbol["text-writing-mode"]),"text-rotate":new Ze(he.layout_symbol["text-rotate"]),"text-padding":new qe(he.layout_symbol["text-padding"]),"text-keep-upright":new qe(he.layout_symbol["text-keep-upright"]),"text-transform":new Ze(he.layout_symbol["text-transform"]),"text-offset":new Ze(he.layout_symbol["text-offset"]),"text-allow-overlap":new qe(he.layout_symbol["text-allow-overlap"]),"text-ignore-placement":new qe(he.layout_symbol["text-ignore-placement"]),"text-optional":new qe(he.layout_symbol["text-optional"]),visibility:new qe(he.layout_symbol.visibility)})),paint:yv||(yv=new wi({"icon-opacity":new Ze(he.paint_symbol["icon-opacity"]),"icon-occlusion-opacity":new Ze(he.paint_symbol["icon-occlusion-opacity"]),"icon-emissive-strength":new Ze(he.paint_symbol["icon-emissive-strength"]),"text-emissive-strength":new Ze(he.paint_symbol["text-emissive-strength"]),"icon-color":new Ze(he.paint_symbol["icon-color"]),"icon-halo-color":new Ze(he.paint_symbol["icon-halo-color"]),"icon-halo-width":new Ze(he.paint_symbol["icon-halo-width"]),"icon-halo-blur":new Ze(he.paint_symbol["icon-halo-blur"]),"icon-translate":new qe(he.paint_symbol["icon-translate"]),"icon-translate-anchor":new qe(he.paint_symbol["icon-translate-anchor"]),"icon-image-cross-fade":new qe(he.paint_symbol["icon-image-cross-fade"]),"text-opacity":new Ze(he.paint_symbol["text-opacity"]),"text-occlusion-opacity":new Ze(he.paint_symbol["text-occlusion-opacity"]),"text-color":new Ze(he.paint_symbol["text-color"],{runtimeType:rn,getOverride:n=>n.textColor,hasOverride:n=>!!n.textColor}),"text-halo-color":new Ze(he.paint_symbol["text-halo-color"]),"text-halo-width":new Ze(he.paint_symbol["text-halo-width"]),"text-halo-blur":new Ze(he.paint_symbol["text-halo-blur"]),"text-translate":new qe(he.paint_symbol["text-translate"]),"text-translate-anchor":new qe(he.paint_symbol["text-translate-anchor"]),"icon-color-saturation":new qe(he.paint_symbol["icon-color-saturation"]),"icon-color-contrast":new qe(he.paint_symbol["icon-color-contrast"]),"icon-color-brightness-min":new qe(he.paint_symbol["icon-color-brightness-min"]),"icon-color-brightness-max":new qe(he.paint_symbol["icon-color-brightness-max"]),"symbol-z-offset":new Ze(he.paint_symbol["symbol-z-offset"]),"icon-color-use-theme":new Ze({type:"string",default:"default","property-type":"data-driven"}),"icon-halo-color-use-theme":new Ze({type:"string",default:"default","property-type":"data-driven"}),"text-color-use-theme":new Ze({type:"string",default:"default","property-type":"data-driven"}),"text-halo-color-use-theme":new Ze({type:"string",default:"default","property-type":"data-driven"})}))},Sy);
7class T_ extends ir{constructor(e,i,r,s){super(e,Iy(),i,r,s,e.layout?e.layout["icon-image-use-theme"]:null),this._colorAdjustmentMatrix=Rt([]),this.hasOcclusionOpacityProperties=e.paint!==void 0&&("icon-occlusion-opacity"in e.paint||"text-occlusion-opacity"in e.paint)}_handleSpecialPaintPropertyUpdate(e){e!=="icon-occlusion-opacity"&&e!=="text-occlusion-opacity"||(this.hasOcclusionOpacityProperties=!0)}recalculate(e,i){super.recalculate(e,i),this.appearances&&this.appearances.forEach(s=>{s.recalculate(e,i,this.iconImageUseTheme)}),this.layout.get("icon-rotation-alignment")==="auto"&&(this.layout._values["icon-rotation-alignment"]=this.layout.get("symbol-placement")!=="point"?"map":"viewport"),this.layout.get("text-rotation-alignment")==="auto"&&(this.layout._values["text-rotation-alignment"]=this.layout.get("symbol-placement")!=="point"?"map":"viewport"),this.layout.get("text-pitch-alignment")==="auto"&&(this.layout._values["text-pitch-alignment"]=this.layout.get("text-rotation-alignment")),this.layout.get("icon-pitch-alignment")==="auto"&&(this.layout._values["icon-pitch-alignment"]=this.layout.get("icon-rotation-alignment"));let r=this.layout.get("text-writing-mode");if(r){let s=[];for(let l of r)s.includes(l)||s.push(l);this.layout._values["text-writing-mode"]=s}else this.layout._values["text-writing-mode"]=this.layout.get("symbol-placement")==="point"?["horizontal"]:["horizontal","vertical"];this._setPaintOverrides()}getColorAdjustmentMatrix(e,i,r,s){return this._saturation===e&&this._contrast===i&&this._brightnessMin===r&&this._brightnessMax===s||(this._colorAdjustmentMatrix=function(l,u,p,f){l=zr(l),u=zn(u);let g=fs(),x=l/3,b=1-2*x,w=[b,x,x,0,x,b,x,0,x,x,b,0,0,0,0,1],S=.5-.5*u,E=f-p;return xi(g,[E,0,0,0,0,E,0,0,0,0,E,0,p,p,p,1],[u,0,0,0,0,u,0,0,0,0,u,0,S,S,S,1]),xi(g,g,w),g}(e,i,r,s),this._saturation=e,this._contrast=i,this._brightnessMin=r,this._brightnessMax=s),this._colorAdjustmentMatrix}getValueAndResolveTokens(e,i,r,s){let l=this.layout.get(e).evaluate(i,{},r,s),u=this._unevaluatedLayout._values[e];return u.isDataDriven()||Zu(u.value)||!l?l:_v(i.properties,l)}getAppearanceValueAndResolveTokens(e,i,r,s,l){let u=e.getLayoutProperty(i);if(!u)return;let p=u.evaluate(r,{},s,l),f=e.getUnevaluatedLayoutProperties()._values[i];return f.isDataDriven()||Zu(f.value)||!p||typeof p!="string"?p:_v(r.properties,p)}createBucket(e){return new Bo(e)}queryRadius(){return 0}queryIntersectsFeature(){return!1}_setPaintOverrides(){for(let e of Iy().paint.overridableProperties){if(!T_.hasPaintOverride(this.layout,e))continue;let i=this.paint.get(e),r=new xv(i),s=new bd(r,i.property.specification,this.scope,this.options,this.layout.get("icon-image-use-theme")),l=null;l=i.value.kind==="constant"||i.value.kind==="source"?new Rc("source",s):new bl("composite",s,i.value.zoomStops,i.value.interpolationType),this.paint._values[e]=new Bs(i.property,l,i.parameters)}}_handleOverridablePaintPropertyUpdate(e,i,r){return!(!this.layout||i.isDataDriven()||r.isDataDriven())&&T_.hasPaintOverride(this.layout,e)}static hasPaintOverride(e,i){let r=e.get("text-field"),s=Iy().paint.properties[i],l=!1,u=p=>{for(let f of p)if(s.overrides&&s.overrides.hasOverride(f))return void(l=!0)};if(r.value.kind==="constant"&&r.value.value instanceof kn)u(r.value.value.sections);else if(r.value.kind==="source"){let p=g=>{l||(g instanceof xo&&vn(g.value)===Yo?u(g.value.sections):g instanceof gc?u(g.sections):g.eachChild(p))},f=r.value;f._styleExpression&&p(f._styleExpression.expression)}return l}getProgramIds(){return["symbol"]}getDefaultProgramParams(e,i,r){return{config:new is(this,{zoom:i,lut:r}),overrideFog:!1}}hasElevation(){return this.layout&&this.layout.get("symbol-elevation-reference")==="hd-road-markup"}}let vv,bv,wv,Tv;var S_=Ct([{name:"a_pos",type:"Int16",components:2},{name:"a_texture_pos",type:"Uint16",components:2}]);function I_(n,e,i,r,s,l,u,p){let f=[n,e,1,i,r,1,s,l,1],g=[u,p,1],x=uo([],f),[b,w,S]=_s(g,g,x);return Jr(f,f,[b,0,0,0,w,0,0,0,S])}function Sv(n,e,i,r,s,l,u,p){let f=function(g,x,b,w,S,E,M,C){let R=I_(0,0,1,0,1,1,0,1),F=I_(g,x,b,w,S,E,M,C);return Jr(F,F,uo([],R))}(n,e,i,r,s,l,u,p);return[f[2]/f[8]/Xe,f[5]/f[8]/Xe]}function E_(n){return[n[0],Math.min(Math.max(n[1],-85.051129),Er)]}
7class Iv extends ol{constructor(e,i,r,s){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(s),this.options=i,this._dirty=!1}load(e,i){if(this._loaded=i||!1,this.fire(new Xo("dataloading",{dataType:"source"})),this.url=this.options.url,!this.url)return e&&(this.coordinates=e),this._loaded=!0,void this._finishLoading();this._imageRequest=Kr(this.map._requestManager.transformRequest(this.url,bs.Image),(r,s)=>{this._imageRequest=null,this._loaded=!0,r?this.fire(new rl(r)):s&&(this.image=s,this._dirty=!0,this.width=this.image.width,this.height=this.image.height,e&&(this.coordinates=e),this._finishLoading())})}loaded(){return this._loaded}updateImage(e){return e.url?(this._imageRequest&&e.url!==this.options.url&&(this._imageRequest.cancel(),this._imageRequest=null),this.options.url=e.url,this.load(e.coordinates,this._loaded),this):this}setTexture(e){if(!(e.handle instanceof WebGLTexture))throw new Error("The provided handle is not a WebGLTexture instance");return this.texture=new Ip(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 Xo("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 Ip||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 l of e)l[1]>r&&(r=l[1]),l[1]<i&&(i=l[1]);let s=(r+i)/2;if(s>Er?this.onNorthPole=!0:s<-85.051129&&(this.onSouthPole=!0),!this.onNorthPole&&!this.onSouthPole){let l=e.map(qn.fromLngLat);this.tileID=function(u){let p=1/0,f=1/0,g=-1/0,x=-1/0;for(let M of u)p=Math.min(p,M.x),f=Math.min(f,M.y),g=Math.max(g,M.x),x=Math.max(x,M.y);let b=Math.max(g-p,x-f),w=Math.max(0,Math.floor(-Math.log2(b))),S=Math.pow(2,w),E=Math.floor((p+g)/2*S);return E>1&&(E-=1),new J(w,E,Math.floor((f+x)/2*S))}(l),this.minzoom=this.maxzoom=this.tileID.z}return this.fire(new Xo("data",{dataType:"source",sourceDataType:"content"})),this}_clear(){!this.texture||this.texture instanceof Ip||(this.texture.destroy(),this._dirty=!0),this.texture=null,this._boundsArray=void 0,this._unsupportedCoords=!1}_prepareData(e){for(let C in this.tiles){let R=this.tiles[C];R.state!=="loaded"&&(R.state="loaded",R.texture=this.texture)}if(this._boundsArray||this.onNorthPole||this.onSouthPole||this._unsupportedCoords)return;let i=su(new J(0,0,0),this.map.transform.projection),r=[i.projection.project(this.coordinates[0][0],this.coordinates[0][1]),i.projection.project(this.coordinates[1][0],this.coordinates[1][1]),i.projection.project(this.coordinates[2][0],this.coordinates[2][1]),i.projection.project(this.coordinates[3][0],this.coordinates[3][1])];if(!function(C){let R=C[1].x-C[0].x,F=C[1].y-C[0].y,z=C[2].x-C[1].x,j=C[2].y-C[1].y,$=C[3].x-C[2].x,H=C[3].y-C[2].y,ie=C[0].x-C[3].x,W=C[0].y-C[3].y,Q=R*j-z*F,Y=z*H-$*j,ee=$*W-ie*H,me=ie*F-R*W;return Q>0&&Y>0&&ee>0&&me>0||Q<0&&Y<0&&ee<0&&me<0}(r))return console.warn("Image source coordinates are defining non-convex area in the Mercator projection"),void(this._unsupportedCoords=!0);let s=su(this.tileID,this.map.transform.projection),[l,u,p,f]=this.coordinates.map(C=>{let R=s.projection.project(C[0],C[1]);return uv(s,R)._round()});this.perspectiveTransform=Sv(l.x,l.y,u.x,u.y,p.x,p.y,f.x,f.y);let g=this._boundsArray=new Ba;g.emplaceBack(l.x,l.y,0,0),g.emplaceBack(u.x,u.y,Xe,0),g.emplaceBack(f.x,f.y,0,Xe),g.emplaceBack(p.x,p.y,Xe,Xe),this.boundsBuffer&&(this.boundsBuffer.destroy(),this.elevatedGlobeVertexBuffer&&this.elevatedGlobeVertexBuffer.destroy(),this.elevatedGlobeIndexBuffer&&this.elevatedGlobeIndexBuffer.destroy()),this.boundsBuffer=e.createVertexBuffer(g,S_.members),this.boundsSegments=pi.simpleSegment(0,0,4,2);let x=[],b=function(C){return[E_(C[0]),E_(C[1]),E_(C[2]),E_(C[3])]}(this.coordinates),[w,S,E,M]=function(C){let R=C[0][0],F=R,z=C[0][1],j=z;for(let $=1;$<C.length;$++)C[$][0]<R?R=C[$][0]:C[$][0]>F&&(F=C[$][0]),C[$][1]<z?z=C[$][1]:C[$][1]>j&&(j=C[$][1]);return[R,z,F-R,j-z]}(b);{let C=new Ba,[R,F,z,j]=function(Ee){let Be=Ee[0].x,xe=Be,Se=Ee[0].y,Me=Se;for(let ze=1;ze<Ee.length;ze++)Ee[ze].x<Be?Be=Ee[ze].x:Ee[ze].x>xe&&(xe=Ee[ze].x),Ee[ze].y<Se?Se=Ee[ze].y:Ee[ze].y>Me&&(Me=Ee[ze].y);return[Be,Se,xe-Be,Me-Se]}(r),$=Ee=>[(Ee.x-R)/z,(Ee.y-F)/j],[H,ie,W,Q]=r.map($),Y=function(Ee,Be,xe,Se,Me,ze,Le,We){let De=I_(0,0,1,0,1,1,0,1);return Jr(De,De,uo([],I_(Ee,Be,xe,Se,Me,ze,Le,We)))}(H[0],H[1],ie[0],ie[1],W[0],W[1],Q[0],Q[1]);this.elevatedGlobePerspectiveTransform=Sv(H[0],H[1],ie[0],ie[1],W[0],W[1],Q[0],Q[1]);let ee=(Ee,Be)=>{x.push(Ee.lng);let xe=Math.round((Ee.lng-w)/E*Xe),Se=Math.round((Ee.lat-S)/M*Xe),Me=$(Be),ze=_s([],[Me[0],Me[1],1],Y),Le=Math.round(ze[0]/ze[2]*Xe),We=Math.round(ze[1]/ze[2]*Xe);C.emplaceBack(xe,Se,Le,We)},me=r[3].x-r[0].x,ge=r[3].y-r[0].y,Te=r[2].x-r[1].x,Ae=r[2].y-r[1].y;for(let Ee=0;Ee<65;Ee++){let Be=Ee/64,xe=[r[0].x+Be*me,r[0].y+Be*ge],Se=[r[1].x+Be*Te,r[1].y+Be*Ae],Me=Se[0]-xe[0],ze=Se[1]-xe[1];for(let Le=0;Le<65;Le++){let We=Le/64,De={x:xe[0]+Me*We,y:xe[1]+ze*We};ee(i.projection.unproject(De.x,De.y),De)}}this.elevatedGlobeVertexBuffer=e.createVertexBuffer(C,S_.members)}{this.maxLongitudeTriangleSize=0;let C=[],R=new Xi,F=(z,j,$)=>{R.emplaceBack(z,j,$);let H=x[z],ie=x[j],W=x[$],Q=Math.min(Math.min(H,ie),W),Y=Math.max(Math.max(H,ie),W)-Q;Y>this.maxLongitudeTriangleSize&&(this.maxLongitudeTriangleSize=Y),C.push(Q+Y/2)};for(let z=0;z<64;z++)for(let j=0;j<64;j++){let $=65*z+j,H=$+1,ie=$+65,W=ie+1;F($,ie,H),F(H,ie,W)}[C,R]=function(z,j){let $=Array.from({length:z.length},(W,Q)=>Q);$.sort((W,Q)=>z[W]-z[Q]);let H=[],ie=new Xi;for(let W=0;W<$.length;W++){let Q=$[W];H.push(z[Q]);let Y=3*Q,ee=Y+1;ie.emplaceBack(j.uint16[Y],j.uint16[ee],j.uint16[ee+1])}return[H,ie]}(C,R),this.elevatedGlobeTrianglesCenterLongitudes=C,this.elevatedGlobeIndexBuffer=e.createIndexBuffer(R)}this.elevatedGlobeSegments=pi.simpleSegment(0,0,4225,8192),this.elevatedGlobeGridMatrix=new Float32Array([0,E/Xe,0,M/Xe,0,0,S,w,0])}prepare(){let e=Object.keys(this.tiles).length!==0;if(this.tileID&&!e)return;let i=this.map.painter.context,r=i.gl;!this._dirty||this.texture instanceof Ip||(this.texture?this.texture.update(this.image):(this.texture=new Xs(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={},i(null)):(e.state="errored",i(null))}serialize(){return{type:"image",url:this.options.url,coordinates:this.coordinates}}hasTransition(){return!1}getSegmentsForLongitude(e){let i=this.elevatedGlobeSegments;if(!this.elevatedGlobeTrianglesCenterLongitudes||!i)return null;let r=this.elevatedGlobeTrianglesCenterLongitudes,s=(l=e+180)+360*Math.round((r[0]-l)/360);var l;let u=new pi,p=(b,w)=>{u.segments.push({vertexOffset:0,primitiveOffset:b,vertexLength:i.segments[0].vertexLength,primitiveLength:w,sortKey:void 0,vaos:{}})},f=.51*this.maxLongitudeTriangleSize;if(Math.abs(r[0]-s)<=f){let b=yn(r,0,r.length,s+f);return b===r.length||p(b,Bn(r,b+1,r.length,s+360-f)-b),u}s<r[0]&&(s+=360);let g=Bn(r,0,r.length,s-f);if(g===r.length)return p(0,r.length),u;p(0,g-0);let x=yn(r,g+1,r.length,s+f);return x!==r.length&&p(x,r.length-x),u}}let Ey=1024,oT=(Math.pow(Ey,2)-1)/268170240;
7class Ev extends ir{constructor(e,i,r,s){super(e,{layout:wv||(wv=new wi({visibility:new qe(he.layout_raster.visibility)})),paint:Tv||(Tv=new wi({"raster-opacity":new qe(he.paint_raster["raster-opacity"]),"raster-color":new La(he.paint_raster["raster-color"]),"raster-color-mix":new qe(he.paint_raster["raster-color-mix"]),"raster-color-range":new qe(he.paint_raster["raster-color-range"]),"raster-hue-rotate":new qe(he.paint_raster["raster-hue-rotate"]),"raster-brightness-min":new qe(he.paint_raster["raster-brightness-min"]),"raster-brightness-max":new qe(he.paint_raster["raster-brightness-max"]),"raster-saturation":new qe(he.paint_raster["raster-saturation"]),"raster-contrast":new qe(he.paint_raster["raster-contrast"]),"raster-resampling":new qe(he.paint_raster["raster-resampling"]),"raster-fade-duration":new qe(he.paint_raster["raster-fade-duration"]),"raster-emissive-strength":new qe(he.paint_raster["raster-emissive-strength"]),"raster-array-band":new qe(he.paint_raster["raster-array-band"]),"raster-elevation":new qe(he.paint_raster["raster-elevation"]),"raster-elevation-reference":new qe(he.paint_raster["raster-elevation-reference"]),"raster-color-use-theme":new Ze({type:"string",default:"default","property-type":"data-driven"})}))},i,r,s),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 Iv&&(e._source.onNorthPole||e._source.onSouthPole))&&this.paint.get("raster-elevation")===0}_handleSpecialPaintPropertyUpdate(e){e!=="raster-color"&&e!=="raster-color-range"||(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,s]=e||this._transitionablePaint._values["raster-color-range"].value.expression.evaluate({zoom:0})||[NaN,NaN];isNaN(r)&&isNaN(s)||r===this._curRampRange[0]&&s===this._curRampRange[1]||(this.colorRamp=ei({expression:i,evaluationKey:"rasterValue",image:this.colorRamp,clips:[{start:r,end:s}],resolution:Ey}),this.colorRampTexture=null,this._curRampRange=[r,s])}is3D(e){return this.paint.get("raster-elevation")>0}}let Av,Mv,Cv,Pv,Dv,Rv,zv;class Lv extends ir{constructor(e,i,r,s){super(e,{layout:Av||(Av=new wi({visibility:new qe(he["layout_raster-particle"].visibility)})),paint:Mv||(Mv=new wi({"raster-particle-array-band":new qe(he["paint_raster-particle"]["raster-particle-array-band"]),"raster-particle-count":new qe(he["paint_raster-particle"]["raster-particle-count"]),"raster-particle-color":new La(he["paint_raster-particle"]["raster-particle-color"]),"raster-particle-max-speed":new qe(he["paint_raster-particle"]["raster-particle-max-speed"]),"raster-particle-speed-factor":new qe(he["paint_raster-particle"]["raster-particle-speed-factor"]),"raster-particle-fade-opacity-factor":new qe(he["paint_raster-particle"]["raster-particle-fade-opacity-factor"]),"raster-particle-reset-rate-factor":new qe(he["paint_raster-particle"]["raster-particle-reset-rate-factor"]),"raster-particle-elevation":new qe(he["paint_raster-particle"]["raster-particle-elevation"]),"raster-particle-color-use-theme":new Ze({type:"string",default:"default","property-type":"data-driven"})}))},i,r,s),this._updateColorRamp(),this.lastInvalidatedAt=xn.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 this.visibility!=="none"}isDraped(e){return!1}_handleSpecialPaintPropertyUpdate(e){e!=="raster-particle-color"&&e!=="raster-particle-max-speed"||(this._updateColorRamp(),this._invalidateAnimationState()),e==="raster-particle-count"&&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=ei({expression:e,evaluationKey:"rasterParticleSpeed",image:this.colorRamp,clips:[{start:0,end:i}],resolution:256}),this.colorRampTexture=null}
7_invalidateAnimationState(){this.lastInvalidatedAt=xn.now()}tileCoverLift(){return this.paint.get("raster-particle-elevation")}}class sT extends ir{constructor(e,i){super(e,{},i,null),this.implementation=e,e.slot&&(this.slot=e.slot)}is3D(e){return this.implementation.renderingMode==="3d"}hasOffscreenPass(){return this.implementation.prerender!==void 0}isDraped(e){return this.implementation.renderToTile!==void 0}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 Ay(n,e,i){let r=[0,0,1],s=ys([]);return sa(s,s,i?-V(n)+Math.PI:V(n)),Ja(s,s,-V(e)),Za(r,r,s),hi(r,r)}class Ov{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 Fv{constructor(){this.maxScale=1,this.maxXYTranslationDistance=0,this.instancedDataArray=new Pl,this.instancesEvaluatedElevation=[],this.features=[],this.idToFeaturesIndex={}}colorForInstance(e){let i=16*e,r=this.instancedDataArray.float32,s=Math.floor(r[i+2]),l=1.05*(r[i+2]-s);return s/=100,[r[i]%1*1.05,r[i+1]%1*1.05,l,s]}tileCoordinatesForInstance(e){let i=16*e,r=this.instancedDataArray.float32,s=r[i+0];return s=s>Xe?s-Xe:s,new ke(Math.trunc(s),Math.trunc(r[i+1]))}translationForInstance(e){let i=16*e,r=this.instancedDataArray.float32;return[r[i+4],r[i+5],r[i+6]]}rotationScaleForInstance(e){let i=16*e,r=this.instancedDataArray.float32;return[r[i+7],r[i+8],r[i+9],r[i+10],r[i+11],r[i+12],r[i+13],r[i+14],r[i+15]]}transformForInstance(e){let i=16*e,r=this.instancedDataArray.float32;return[r[i+7],r[i+8],r[i+9],r[i+4],r[i+10],r[i+11],r[i+12],r[i+5],r[i+13],r[i+14],r[i+15],r[i+6],0,0,0,1]}}class My{constructor(e){this.zoom=e.zoom,this.canonical=e.canonical,this.overscaledZ=this.canonical.z+Math.log2(e.overscaling),this.layers=e.layers,this.layerIds=this.layers.map(i=>i.fqid),this.projection=e.projection,this.index=e.index,this.worldview=e.worldview,this.hasZoomDependentProperties=this.layers[0].isZoomDependent(),this.stateDependentLayerIds=this.layers.filter(i=>i.isStateDependent()).map(i=>i.id),this.hasPattern=!1,this.instancesPerModel={},this.validForExaggeration=0,this.maxVerticalOffset=0,this.maxScale=0,this.maxHeight=0,this.lookupDim=this.zoom>this.canonical.z+1?0:this.zoom>this.canonical.z?256:this.zoom>15?75:100,this.instanceCount=0,this.terrainElevationMin=0,this.terrainElevationMax=0,this.validForDEMTile={id:null,timestamp:0},this.modelUris=[],this.modelsRequested=!1,this.activeReplacements=[],this.replacementUpdateTime=0,this.styleDefinedModelURLs=e.styleDefinedModelURLs,this.hasAppearances=null}updateFootprints(e,i){}updateAppearances(e,i,r,s){return{hasLayoutChanges:!1,hasUboChanges:!1}}populate(e,i,r,s){this.tileToMeter=Vr(r);let l=this.layers[0]._featureFilter.needGeometry;this.lookup=new Uint8Array(this.lookupDim*this.lookupDim);let u=this.layers[0].paint.get("model-elevation-reference")==="hd-road-markup"?i.elevationFeatures:void 0;for(let{feature:p,id:f,index:g,sourceLayerIndex:x}of e){let b=f??(p.properties&&Object.hasOwn(p.properties,"id")?p.properties.id:void 0),w=Gr(p,l);if(!this.layers[0]._featureFilter.filter(new Xt(this.zoom,{worldview:this.worldview,activeFloors:i.activeFloors}),w,r))continue;let S={id:b,sourceLayerIndex:x,index:g,geometry:l?w.geometry:jr(p,r,s),properties:p.properties,type:p.type,patterns:{}},E=this.addFeature(S,S.geometry,w,u,r);E&&i.featureIndex.insert(p,S.geometry,g,x,this.index,this.instancesPerModel[E].instancedDataArray.length,256)}this.lookup=null}evaluateQueryRenderedFeaturePadding(){let e=this.layers[0].modelManager,i=this.layers[0].scope,r=0;for(let s of this.modelUris){let l=e.getModel(s,i);if(!l)continue;let u=this.instancesPerModel[s];if(u){let p=.5*ia(l.aabb.max,l.aabb.min)*u.maxScale+u.maxXYTranslationDistance,f=Math.min(Xe,Math.max(p/this.tileToMeter,256));r=Math.max(f,r)}}return r}
7update(e,i,r,s){for(let l in this.instancesPerModel){let u=this.instancesPerModel[l];for(let p in e)Object.hasOwn(u.idToFeaturesIndex,p)&&(this.evaluate(u.features[u.idToFeaturesIndex[p]],e[p],u,!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 s of r.features){let l=this.layers[0],u=s.feature,p=this.canonical,f=l.paint.get("model-rotation").evaluate(u,{},p),g=l.paint.get("model-scale").evaluate(u,{},p),x=l.paint.get("model-translation").evaluate(u,{},p);Mo(s.rotation,f)&&Mo(s.scale,g)&&Mo(s.translation,x)||(this.evaluate(s,s.featureStates,r,!0),e=!0)}}return e}updateReplacement(e,i,r,s){if(i.updateTime===this.replacementUpdateTime)return!1;this.replacementUpdateTime=i.updateTime;let l=i.getReplacementRegionsForTile(e.toUnwrapped(),!0);if(jm(this.activeReplacements,l))return!1;this.activeReplacements=l;let u=!1;for(let p in this.instancesPerModel){let f=this.instancesPerModel[p],g=f.instancedDataArray;for(let x of f.features){let b=x.instancedDataOffset,w=x.instancedDataCount;for(let S=0;S<w;S++){let E=16*(S+b),M=g.float32[E+0],C=M>Xe;M=C?M-Xe:M;let R=Math.floor(M),F=Math.floor(g.float32[E+1]),z=!1;for(let j of this.activeReplacements)if(!d0(j,r,Gm.Model,s)&&!(j.min.x>R||R>j.max.x||j.min.y>F||F>j.max.y)&&(z=g0(_0(R,F,e.canonical,j.footprintTileId.canonical),j.footprint),z))break;g.float32[E]=z?M+Xe:M,u=u||z!==C}}}return u}isEmpty(){for(let e in this.instancesPerModel)if(this.instancesPerModel[e].instancedDataArray.length!==0)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||r.instancedDataArray.length===0||(r.instancedDataBuffer?r.instancedDataBuffer.updateData(r.instancedDataArray):r.instancedDataBuffer=e.createVertexBuffer(r.instancedDataArray,xb.members,!0,void 0,this.instanceCount))}this.uploaded=!0}destroy(e){for(let r in this.instancesPerModel){let s=this.instancesPerModel[r];s.instancedDataArray.length!==0&&s.instancedDataBuffer&&s.instancedDataBuffer.destroy()}let i=this.layers[0].modelManager;if(e&&i&&this.modelUris&&this.modelsRequested)for(let r of this.modelUris)i.removeModel(r,"",!0)}addFeature(e,i,r,s,l){let u=this.layers[0],p=u.layout.get("model-id"),f=u.layout.get("model-allow-density-reduction"),g=p.evaluate(r,{},this.canonical);if(!g)return Ot(`modelId is not evaluated for layer ${u.id} and it is not going to get rendered.`),g;!g.includes("://")&&!this.styleDefinedModelURLs[g]||this.modelUris.includes(g)||this.modelUris.push(g),this.instancesPerModel[g]||(this.instancesPerModel[g]=new Fv);let x=this.instancesPerModel[g],b=x.instancedDataArray,w=new Ov(r,b.length),S;s&&(S=_h.getElevationFeature(e,s));for(let E of i)for(let M of E){if(M.x<0||M.x>=Xe||M.y<0||M.y>=Xe)continue;if(this.lookupDim!==0&&f){let R=(this.lookupDim-1)/Xe,F=this.lookupDim*(M.y*R|0)+M.x*R|0;if(this.lookup){if(this.lookup[F]!==0)continue;this.lookup[F]=1}}this.instanceCount++;let C=b.length;if(b.resize(C+1),s){x.instancesRoadElevation||(x.instancesRoadElevation=[]);let R=S?S.pointElevation(new ke(M.x,M.y)):0;x.instancesRoadElevation.push(R)}x.instancesEvaluatedElevation.push(0),b.float32[16*C]=M.x,b.float32[16*C+1]=M.y}return w.instancedDataCount=x.instancedDataArray.length-w.instancedDataOffset,w.instancedDataCount>0&&(e.id&&(x.idToFeaturesIndex[e.id]=x.features.length),x.features.push(w),this.evaluate(w,{},x,!1)),g}getModelUris(){return this.modelUris}evaluate(e,i,r,s){let l=this.layers[0],u=e.feature,p=this.canonical,f=e.rotation=l.paint.get("model-rotation").evaluate(u,i,p),g=e.scale=l.paint.get("model-scale").evaluate(u,i,p),x=e.translation=l.paint.get("model-translation").evaluate(u,i,p),b=Object.assign({},l.paint.get("model-color").evaluate(u,i,p));b.a=l.paint.get("model-color-mix-intensity").evaluate(u,i,p);let w=[];this.maxVerticalOffset<x[2]&&(this.maxVerticalOffset=x[2]);let S=x[0]*x[0]+x[1]*x[1],E=S>0?Math.sqrt(S):0;r.maxScale=Math.max(Math.max(r.maxScale,g[0]),Math.max(g[1],g[2])),r.maxXYTranslationDistance=Math.max(r.maxXYTranslationDistance,E),this.maxScale=Math.max(Math.max(this.maxScale,g[0]),Math.max(g[1],g[2])),ix(w,f,g);let M=Math.round(100*b.a)+b.b/1.05;for(let C=0;C<e.instancedDataCount;++C){let R=e.instancedDataOffset+C,F=16*R,z=r.instancedDataArray.float32,j=0;s&&(j=z[F+6]-r.instancesEvaluatedElevation[R]);let $=0|z[F+1];z[F]=(0|z[F])+b.r/1.05,z[F+1]=$+b.g/1.05,z[F+2]=M,z[F+3]=1/(p.z>10?this.tileToMeter:Vr(p,$)),z[F+4]=x[0],z[F+5]=x[1],z[F+6]=x[2]+(r.instancesRoadElevation?r.instancesRoadElevation[R]:0)+j,z[F+7]=w[0],z[F+8]=w[1],z[F+9]=w[2],z[F+10]=w[4],z[F+11]=w[5],z[F+12]=w[6],z[F+13]=w[8],z[F+14]=w[9],z[F+15]=w[10],r.instancesEvaluatedElevation[R]=x[2]}}}Qe(My,"ModelBucket",{omit:["layers"]}),Qe(Fv,"PerModelAttributes"),Qe(Ov,"ModelFeature");class Ch{constructor(e,i,r){this._demTile=e,this._dem=this._demTile.dem,this._scale=i,this._offset=r}static create(e,i,r){let s=r||e.findDEMTileFor(i);if(!s||!s.dem)return;let l=s.dem,u=s.tileID,p=1<<i.canonical.z-u.canonical.z;return new Ch(s,l.dim/Xe/p,[(i.canonical.x/p-u.canonical.x)*l.dim,(i.canonical.y/p-u.canonical.y)*l.dim])}tileCoordToPixel(e,i){let r=i*this._scale+this._offset[1];return new ke(Math.floor(e*this._scale+this._offset[0]),Math.floor(r))}
7getElevationAt(e,i,r,s){let l=e*this._scale+this._offset[0],u=i*this._scale+this._offset[1],p=Math.floor(l),f=Math.floor(u),g=this._dem;return s=!!s,r?ft(ft(g.get(p,f,s),g.get(p,f+1,s),u-f),ft(g.get(p+1,f,s),g.get(p+1,f+1,s),u-f),l-p):g.get(p,f,s)}getElevationAtPixel(e,i,r){return this._dem.get(e,i,!!r)}getMeterToDEM(e){return(1<<this._demTile.tileID.canonical.z)*or(1,e)*this._dem.stride}}let Cy=new Float32Array(262144),au=new Uint8Array(262144),A_=[0,0,0],M_=[0,0,0];function Bv(n){let e=0;if(n.meshes)for(let i of n.meshes)e=Math.max(e,i.aabb.max[2]);if(n.children)for(let i of n.children)e=Math.max(e,Bv(i));return e}function kv(n,e,i){if(n.meshes)for(let r of n.meshes){if(r.aabb.min[0]===1/0)continue;let s=Si.applyTransform(r.aabb,n.globalMatrix);i.insert(e,s.min[0],s.min[1],s.max[0],s.max[1])}if(n.children)for(let r of n.children)kv(r,e,i)}let Nv=["","wall","door","roof","window","lamp","logo"];class Uv{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.targetLod=-1,this.feature={type:"Point",id:e.id,geometry:[],properties:{height:Bv(e)}},this.aabb=this._getLocalBounds(),this.state=null}_getLocalBounds(){if(!this.node.meshes)return new Si([1/0,1/0,1/0],[-1/0,-1/0,-1/0]);if(!this.aabb){let e=0,i=new Si([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=Si.applyTransformFast(r.aabb,this.node.globalMatrix),i.encapsulate(r.transformedAabb)),e++;this.aabb=i}return this.aabb}}class C_{constructor(e,i,r,s,l,u,p,f){this.id=r,this.layers=e,this.layerIds=this.layers.map(g=>g.fqid),this.stateDependentLayerIds=this.layers.filter(g=>g.isStateDependent()).map(g=>g.id),this.modelTraits|=vh.CoordinateSpaceTile,this.uploaded=!1,this.hasPattern=!1,s&&(this.modelTraits|=vh.HasMapboxMeshFeatures),l&&(this.modelTraits|=vh.HasMeshoptCompression),this.zoom=-1,this.terrainExaggeration=1,this.projection={name:"mercator"},this.replacementUpdateTime=0,this.elevationReadFromZ=255,this.brightness=u,this.worldview=f,this.dirty=!0,this.needsUpload=!1,this.filter=null,this.nodesInfo=[];for(let g of i)this.nodesInfo.push(new Uv(g)),kv(g,p.featureIndexArray.length,p.grid),p.featureIndexArray.emplaceBack(this.nodesInfo.length-1,0,p.bucketLayerIDs.length-1,0);this.states={},this.hasAppearances=null}updateFootprints(e,i){for(let r of this.getNodesInfo()){let s=r.node;s.footprint&&i.push({footprint:s.footprint,id:e})}}updateAppearances(e,i,r,s){return{hasLayoutChanges:!1,hasUboChanges:!1}}update(e){let i=Object.keys(e).length!==0;if(i&&!this.stateDependentLayers.length)return;let r=i?this.stateDependentLayers:this.layers;if(!Zo(e,this.states))for(let s of r)this.evaluate(s,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 s=r.node;this.uploaded?this.updatePbrBuffer(s):qg(s,e,!0)}for(let r of i)s_(r.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);if(e.lodMeshes)for(let r of e.lodMeshes)r.pbrBuffer&&(r.pbrBuffer.updateData(r.featureArray),i=!0);return i}needsReEvaluation(e,i,r){let s=e.transform.projectionOptions,l=e.style.getBrightness(),u=this.brightness!==l;if(!this.uploaded||this.dirty||s.name!==this.projection.name||Vp(r.paint.get("model-color").value,u)||Vp(r.paint.get("model-color-mix-intensity").value,u)||Vp(r.paint.get("model-roughness").value,u)||Vp(r.paint.get("model-emissive-strength").value,u)||Vp(r.paint.get("model-height-based-emissive-strength-multiplier").value,u)){this.projection=s,this.brightness=l;let p=this.getNodesInfo();for(let f of p)f.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(),s=this.id.canonical;for(let l of r){let u=l.feature;l.evaluatedTranslation=i.paint.get("model-translation").evaluate(u,{},s),l.evaluatedScale=i.paint.get("model-scale").evaluate(u,{},s)}}evaluate(e,i){let r=this.getNodesInfo();for(let s of r){if(!s.node.meshes)continue;let l=s.feature,u=i&&i[l.id];if(Zo(u,s.state))continue;s.state=structuredClone(u);let p=s.node.meshes&&s.node.meshes[0].featureData,f=s.evaluatedColor[2],g=s.evaluatedRMEA[2],x=this.id.canonical;if(s.hasTranslucentParts=!1,p){for(let b=0;b<Nv.length;b++){let w=Nv[b];w.length&&(l.properties.part=w);let S=e.paint.get("model-color").evaluate(l,u,x).toPremultipliedRenderColor(null),E=e.paint.get("model-color-mix-intensity").evaluate(l,u,x);s.evaluatedColor[b]=[S.r,S.g,S.b,E],s.evaluatedRMEA[b][0]=e.paint.get("model-roughness").evaluate(l,u,x),s.evaluatedRMEA[b][2]=e.paint.get("model-emissive-strength").evaluate(l,u,x),s.evaluatedRMEA[b][3]=S.a,s.emissionHeightBasedParams[b]=e.paint.get("model-height-based-emissive-strength-multiplier").evaluate(l,u,x),!s.hasTranslucentParts&&S.a<1&&(s.hasTranslucentParts=!0)}delete l.properties.part,aT(s,f!==s.evaluatedColor[2]||g!==s.evaluatedRMEA[2],this.modelTraits)}else s.evaluatedRMEA[0][2]=e.paint.get("model-emissive-strength").evaluate(l,u,x);s.evaluatedTranslation=e.paint.get("model-translation").evaluate(l,u,x),s.evaluatedScale=e.paint.get("model-scale").evaluate(l,u,x),this.updatePbrBuffer(s.node)||(this.needsUpload=!0)}this.dirty=!1}
7elevationUpdate(e,i,r,s){let l=e.findDEMTileFor(r);if(l&&(l.tileID.canonical!==this.terrainTile||i!==this.terrainExaggeration)){if(l.dem&&l.tileID.overscaledZ!==this.elevationReadFromZ){this.elevationReadFromZ=l.tileID.overscaledZ;let u=Ch.create(e,r,l);if(!u)return;this.modelTraits&vh.HasMapboxMeshFeatures&&this.updateDEM(e,u,r,s);for(let p of this.getNodesInfo()){let f=p.node;if(!f.footprint||!f.footprint.vertices||!f.footprint.vertices.length)continue;let g=f.footprint.vertices,x=u.getElevationAt(g[0].x,g[0].y,!0,!0);for(let b=1;b<g.length;b++)x=Math.min(x,u.getElevationAt(g[b].x,g[b].y,!0,!0));f.elevation=x}}this.terrainTile=l.tileID.canonical,this.terrainExaggeration=i}}updateDEM(e,i,r,s){let l=i._dem._modifiedForSources[s];if(l===void 0&&(i._dem._modifiedForSources[s]=[],l=i._dem._modifiedForSources[s]),l.includes(r.canonical))return;let u=i._dem.dim;l.push(r.canonical);let p=!1;for(let f of this.getNodesInfo()){let g=f.node;if(!g.footprint||!g.footprint.grid)continue;let x=g.footprint.grid,b=i.tileCoordToPixel(x.min.x,x.min.y),w=i.tileCoordToPixel(x.max.x,x.max.y),S=Math.min(Math.min(u-w.y,b.x),Math.min(b.y,u-w.x));if(S<0)continue;let E=ne(S,2,5),M=Math.max(0,b.x-E),C=Math.max(0,b.y-E),R=Math.min(w.x+E,u-1),F=Math.min(w.y+E,u-1);for(let H=C;H<=F;++H)for(let ie=M;ie<=R;++ie)au[H*u+ie]=255;let z=0,j=0;for(let H=0;H<x.cellsY;++H)for(let ie=0;ie<x.cellsX;++ie){if(!x.cells[H*x.cellsX+ie])continue;let W=i.tileCoordToPixel(x.min.x+ie/x.xScale,x.min.y+H/x.yScale),Q=i.tileCoordToPixel(x.min.x+(ie+1)/x.xScale,x.min.y+(H+1)/x.yScale);for(let Y=W.y;Y<=Math.min(Q.y+1,u-1);++Y)for(let ee=W.x;ee<=Math.min(Q.x+1,u-1);++ee)au[Y*u+ee]===255&&(au[Y*u+ee]=0,z+=i.getElevationAtPixel(ee,Y),j++)}let $=z/j;M=Math.max(1,b.x-E),C=Math.max(1,b.y-E),R=Math.min(w.x+E,u-2),F=Math.min(w.y+E,u-2),p=!0;for(let H=C;H<=F;++H)for(let ie=M;ie<=R;++ie)au[H*u+ie]===0&&(Cy[H*u+ie]=i._dem.set(ie,H,$));for(let H=1;H<E;++H){M=Math.max(1,b.x-H),C=Math.max(1,b.y-H),R=Math.min(w.x+H,u-2),F=Math.min(w.y+H,u-2);for(let ie=C;ie<=F;++ie)for(let W=M;W<=R;++W){let Q=ie*u+W;if(au[Q]===255){let Y=0,ee=0,me=-1,ge=-1;for(let Te=-1;Te<=1;++Te)for(let Ae=-1;Ae<=1;++Ae){let Ee=(ie+Te)*u+W+Ae;if(au[Ee]>=H)continue;let Be=Cy[Ee],xe=Math.abs(Be);xe>ee&&(Y=Be,ee=xe,me=Ae,ge=Te)}if(ee>.1){let Te=1-(H+.5*Math.abs(me*ge))/E,Ae=i._dem.get(W,ie)+Y*Te,Ee=i._dem.get(W+me,ie+ge),Be=i._dem.get(W-me,ie-ge,!0);(Ae-Ee)*(Ae-Be)>0&&(Ae=(Ee+Be)/2),Cy[Q]=i._dem.set(W,ie,Ae),au[Q]=H}}}}}p&&(i._demTile.needsDEMTextureUpload=!0,i._dem._timestamp=xn.now())}setFilter(e){this.filter=e?io(e):null}getNodesInfo(){return this.filter?this.nodesInfo.filter(e=>this.filter.filter(new Xt(this.id.overscaledZ,{worldview:this.worldview}),e.feature,this.id.canonical)):this.nodesInfo}destroy(){let e=this.getNodesInfo();for(let i of e)s_(i.node),Zg(i.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 s of this.getNodesInfo()){let l=s.node.footprint;s.hiddenByReplacement=!!l&&!r.some(u=>u.footprint===l)}}getHeightAtTileCoord(e,i){let r=[0,0,0],s=Rt([]);for(let l of this.getNodesInfo()){let u=l.node.meshes[0],p=u.transformedAabb;if(e<p.min[0]||i<p.min[1]||e>p.max[0]||i>p.max[1])continue;if(l.node.hidden===!0)return{height:1/0,maxHeight:l.feature.properties.height,hidden:!1,verticalScale:l.evaluatedScale[2]};if(mr(s,l.node.globalMatrix),r[0]=e,r[1]=i,r[2]=0,Oi(r,r,s),l.node.meshBVH){let b=r[0],w=r[1];A_[0]=b-1,A_[1]=w-1,A_[2]=-1e3,M_[0]=b+1,M_[1]=w+1,M_[2]=1e3;let S=l.node.meshBVH.findHighestPoint(A_,M_);if(S!==null)return{height:S,maxHeight:l.feature.properties.height,hidden:l.hiddenByReplacement,verticalScale:l.evaluatedScale[2]};continue}let f=(r[0]-u.aabb.min[0])/(u.aabb.max[0]-u.aabb.min[0])*tu|0,g=Math.min(63,(r[1]-u.aabb.min[1])/(u.aabb.max[1]-u.aabb.min[1])*tu|0)*tu+Math.min(63,f),x=u.heightmap[g];if(x<0&&l.node.footprint){let b=[];if(l.node.footprint.grid.query(new ke(e,i),new ke(e,i),b),b.length>0)return{height:void 0,maxHeight:l.feature.properties.height,hidden:l.hiddenByReplacement,verticalScale:l.evaluatedScale[2]};continue}return l.hiddenByReplacement?void 0:{height:x,maxHeight:l.feature.properties.height,hidden:!1,verticalScale:l.evaluatedScale[2]}}}}function Vp(n,e){return n instanceof Rc&&!n.isLightConstant&&e}function Vv(n,e,i,r,s,l,u,p){let f=(61440&e|(61440&e)>>4)>>8,g=(3840&e|(3840&e)>>4)>>4,x=240&e|(240&e)>>4,b=15&e|(15&e)<<4;i[3]>0&&(f=ft(f,255*i[0],i[3]),g=ft(g,255*i[1],i[3]),x=ft(x,255*i[2],i[3]));let w=b/255;f*=w,g*=w,x*=w;let S=f<<8|g,E=x<<8|Math.floor(255*r[3]),M=function(W){let Q=ne(W,0,2);return Math.min(Math.round(.5*Q*255),255)}(r[2])<<8|15*r[0]<<4|15*r[1],C=ne(s[0],0,1),R=ne(s[1],0,1),F=ne(s[2],0,1),z=ne(s[3],0,1),j,$,H,ie;if(C!==R&&u!==l&&R!==C){let W=u-l;$=1/(W*(R-C)),H=-(l+W*C)/(W*(R-C));let Q=ne(s[4],-1,1);ie=Math.pow(10,Q),j=255*F<<8|255*z}else j=65535,$=0,H=1,ie=1;if(n.emplaceBack(S,E,M,j,$,H,ie),p){let W=p.length;p.clear();for(let Q=0;Q<W;Q++)p.emplaceBack(S,E,M,j,$,H,ie)}}function aT(n,e,i){let r=n.node,s=0,l=i&vh.HasMeshoptCompression;for(let u of r.meshes){if(r.lights&&r.lightMeshIndex===s||!u.featureData)continue;u.featureArray=new Dl,u.featureArray.reserve(u.featureData.length);let p=e;for(let f of u.featureData){let g=l?65535&f:f>>16&65535,x=l?f>>16&65535:65535&f,b=(15&x)<8?15&x:0,w=n.evaluatedRMEA[b],S=n.evaluatedColor[b],E=n.emissionHeightBasedParams[b],M;if(p&&b===2&&r.lights&&(M=new Dl,M.resize(10*r.lights.length)),Vv(u.featureArray,g,S,w,E,u.aabb.min[2],u.aabb.max[2],M),M&&p){p=!1;let C=r.meshes[r.lightMeshIndex];C.featureArray=M,C.featureArray._trim()}}u.featureArray._trim(),s++}if(r.lodMeshes){for(let u of r.lodMeshes)if(u.featureData){u.featureArray=new Dl,u.featureArray.reserve(u.featureData.length);for(let p of u.featureData){let f=l?p>>16&65535:65535&p,g=(15&f)<8?15&f:0;Vv(u.featureArray,l?65535&p:p>>16&65535,n.evaluatedColor[g],n.evaluatedRMEA[g],n.emissionHeightBasedParams[g],u.aabb.min[2],u.aabb.max[2],null)}u.featureArray._trim()}}}Qe(C_,"Tiled3dModelBucket",{omit:["layers"]}),Qe(Uv,"Tiled3dModelFeature");let lT=["id","tile","layer","source","sourceLayer","state"];class lu{constructor(e,i,r,s,l){this.type="Feature",this._vectorTileFeature=e,this._z=i,this._x=r,this._y=s,this.properties=e?e.properties:{},this.id=l}clone(){let e=new lu(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 this._geometry===void 0&&this._vectorTileFeature&&(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 lT)this[i]!==void 0&&(e[i]=this[i]);return e}}
7class cu extends ol{constructor(e,i,r,s){super(),this.id=e,this.type="model",this.models=[],this._options=i,this._modelsInfo=new Map,this._abortController=null}cancelModelRequests(){this._abortController&&(this._abortController.abort(),this._abortController=null)}loadGLTFFromURI(e,i){return K0(this.map._requestManager.transformRequest(e,bs.Model).url,i)}async loadModel(e,i,r){try{let s=await this.loadGLTFFromURI(i.uri,r);if(r.aborted)return;let l=this._modelsInfo.get(e);if(!l)return;let u=Jg(s),p=l.modelSpec,f=new nx(e,p.uri,p.position,p.orientation,u);cu.applyModelSpecification(f,p),f.computeBoundsAndApplyParent(),this.models.push(f),l.model=f}catch(s){if(s instanceof Error&&s.name==="AbortError")return;let l=s instanceof Error?s.message:"Unknown error";this.fire(new rl(new Error(`Could not load model ${e} from ${i.uri}: ${l}`)))}}async load(){this._abortController||(this._abortController=new AbortController);let e=this._abortController.signal,i=[];for(let r in this._options.models){let s=this._options.models[r],l=this._modelsInfo.get(r);if(l&&l.model){l.modelSpec=s;let u=l.model;u.position=s.position!=null?new Yt(s.position[0],s.position[1]):new Yt(0,0),u.orientation=s.orientation!=null?s.orientation:[0,0,0],cu.applyModelSpecification(u,s),u.computeBoundsAndApplyParent(),this.models.push(u)}else l?l.modelSpec=s:(this._modelsInfo.set(r,{modelSpec:s,model:null}),i.push(this.loadModel(r,s,e)))}i.length!==0?(await Promise.allSettled(i),e.aborted||this.fire(new Xo("data",{dataType:"source",sourceDataType:"metadata"}))):this.loaded()&&this.fire(new Xo("data",{dataType:"source",sourceDataType:"metadata"}))}static applyModelSpecification(e,i){i.nodeOverrides&&cu.convertNodeOverrides(e,i.nodeOverrides),i.materialOverrides&&cu.convertMaterialOverrides(e,i.materialOverrides),i.nodeOverrideNames&&(e.nodeOverrideNames=[...i.nodeOverrideNames]),i.materialOverrideNames&&(e.materialOverrideNames=[...i.materialOverrideNames]),i.featureProperties&&(e.featureProperties=i.featureProperties)}static convertNodeOverrides(e,i){if(Array.isArray(i)&&i.every(r=>typeof r=="string")){e.nodeOverrideNames=[];for(let r of i)e.nodeOverrideNames.push(r)}else Object.entries(i).forEach(([r,s])=>{let l={orientation:[0,0,0]};if(Object.hasOwn(s,"orientation")){let u=s.orientation;u&&(l.orientation=u)}e.nodeOverrides.set(r,l)})}static convertMaterialOverrides(e,i){if(Array.isArray(i)&&i.every(r=>typeof r=="string")){e.materialOverrideNames=[];for(let r of i)e.materialOverrideNames.push(r)}else Object.entries(i).forEach(([r,s])=>{let l={color:new jt(1,1,1),colorMix:0,emissionStrength:0,opacity:1},u=s["model-color"];u!==void 0&&(l.color.r=u[0],l.color.g=u[1],l.color.b=u[2]);let p=s["model-color-mix-intensity"];p!==void 0&&(l.colorMix=p);let f=s["model-emissive-strength"];f!==void 0&&(l.emissionStrength=f);let g=s["model-opacity"];g!==void 0&&(l.opacity=g),e.materialOverrides.set(r,l)})}onAdd(e){this.map=e,this.load()}hasTransition(){return!1}loaded(){if(this._modelsInfo.size===0)return!0;for(let e of this._modelsInfo.values())if(e.model==null)return!1;return!0}getModels(){return this.models}loadTile(e,i){}serialize(){return this._options}setProperty(e,i){return!1}reload(){this.cancelModelRequests();let e=ks(this.id,this.scope);this.map.style.clearSource(e),this.models=[],this._modelsInfo.clear(),this.load()}onRemove(e){this.cancelModelRequests()}setModels(e){this.models=[];let i=new Map;for(let r in e){let s=e[r],l=this._modelsInfo.get(r);l&&l.modelSpec.uri===s.uri&&i.set(r,l)}if(this._modelsInfo.size!==i.size){this.cancelModelRequests();for(let[r,s]of i)s.model||i.delete(r)}this._modelsInfo=i,this._options.models=e,this.load()}}function Py(n,e,i,r){let s=1<<n.z;e.lat=Ln((r/Xe+n.y)/s),e.lng=Ir((i/Xe+n.x)/s)}function cT(n,e,i,r){let s=n.getNodesInfo()[e];if(!s||s.hiddenByReplacement||!s.node.meshes)return;let l=Number.MAX_VALUE,u=s.node,p=i.tile,f=r.calculatePosMatrix(p.tileID.toUnwrapped(),r.worldSize),g=s.evaluatedScale,x=0;r.elevation&&u.elevation&&(x=u.elevation*r.elevation.exaggeration()),Gn(f,f,[(u.anchor?u.anchor[0]:0)*(g[0]-1),(u.anchor?u.anchor[1]:0)*(g[1]-1),x]),Zn(f,f,g);let b=i.queryGeometry,w=b.isPointQuery()?b.screenBounds:b.screenGeometry,S=function(M){let C=xi([],f,M.globalMatrix);xi(C,r.expandedFarZProjMatrix,C);for(let R=0;R<M.meshes.length;++R){let F=M.meshes[R];if(R===M.lightMeshIndex)continue;let z=Hg(w,r,C,F.aabb);z!=null&&(l=Math.min(z,l))}if(M.children)for(let R of M.children)S(R)};if(S(u),l===Number.MAX_VALUE)return;let E=new Yt(0,0);return Py(p.tileID.canonical,E,s.node.anchor[0],s.node.anchor[1]),{intersectionZ:l,position:E,feature:s.feature}}let uT={circle:class extends ir{constructor(n,e,i,r){super(n,{layout:se||(se=new wi({"circle-sort-key":new Ze(he.layout_circle["circle-sort-key"]),"circle-elevation-reference":new qe(he.layout_circle["circle-elevation-reference"]),visibility:new qe(he.layout_circle.visibility)})),paint:K||(K=new wi({"circle-radius":new Ze(he.paint_circle["circle-radius"]),"circle-color":new Ze(he.paint_circle["circle-color"]),"circle-blur":new Ze(he.paint_circle["circle-blur"]),"circle-opacity":new Ze(he.paint_circle["circle-opacity"]),"circle-translate":new qe(he.paint_circle["circle-translate"]),"circle-translate-anchor":new qe(he.paint_circle["circle-translate-anchor"]),"circle-pitch-scale":new qe(he.paint_circle["circle-pitch-scale"]),"circle-pitch-alignment":new qe(he.paint_circle["circle-pitch-alignment"]),"circle-stroke-width":new Ze(he.paint_circle["circle-stroke-width"]),"circle-stroke-color":new Ze(he.paint_circle["circle-stroke-color"]),"circle-stroke-opacity":new Ze(he.paint_circle["circle-stroke-opacity"]),"circle-emissive-strength":new qe(he.paint_circle["circle-emissive-strength"]),"circle-color-use-theme":new Ze({type:"string",default:"default","property-type":"data-driven"}),"circle-stroke-color-use-theme":new Ze({type:"string",default:"default","property-type":"data-driven"})}))},e,i,r)}createBucket(n){return new o(n)}queryRadius(n){let e=n;return Z("circle-radius",this,e)+Z("circle-stroke-width",this,e)+G(this.paint.get("circle-translate"))}queryIntersectsFeature(n,e,i,r,s,l,u,p){let f=te(this.paint.get("circle-translate"),this.paint.get("circle-translate-anchor"),l.angle,n.pixelToTileUnitsFactor),g=this.paint.get("circle-radius").evaluate(e,i)+this.paint.get("circle-stroke-width").evaluate(e,i);return Qt(n,r,l,u,p,this.paint.get("circle-pitch-alignment")==="map",this.paint.get("circle-pitch-scale")==="map",f,g)}getProgramIds(){return["circle"]}getDefaultProgramParams(n,e,i){let r=Di(this);return{config:new is(this,{zoom:e,lut:i}
vendor: 14,284 bytes, line 7
7),defines:r,overrideFog:!1}}is3D(n){return!n&&!!this.layout&&this.layout.get("circle-elevation-reference")!=="none"}hasElevation(){return this.layout&&this.layout.get("circle-elevation-reference")!=="none"}},heatmap:class extends ir{createBucket(n){return new Bt(n)}constructor(n,e,i,r){super(n,{layout:Yi||(Yi=new wi({visibility:new qe(he.layout_heatmap.visibility)})),paint:Nn||(Nn=new wi({"heatmap-radius":new Ze(he.paint_heatmap["heatmap-radius"]),"heatmap-weight":new Ze(he.paint_heatmap["heatmap-weight"]),"heatmap-intensity":new qe(he.paint_heatmap["heatmap-intensity"]),"heatmap-color":new La(he.paint_heatmap["heatmap-color"]),"heatmap-opacity":new qe(he.paint_heatmap["heatmap-opacity"]),"heatmap-color-use-theme":new Ze({type:"string",default:"default","property-type":"data-driven"})}))},e,i,r),this._updateColorRamp()}_handleSpecialPaintPropertyUpdate(n){n==="heatmap-color"&&this._updateColorRamp()}_updateColorRamp(){this.colorRamp=ei({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(n){return Z("heatmap-radius",this,n)}queryIntersectsFeature(n,e,i,r,s,l,u,p){let f=this.paint.get("heatmap-radius").evaluate(e,i);return Qt(n,r,l,u,p,!0,!0,new ke(0,0),f)}hasOffscreenPass(){return this.paint.get("heatmap-opacity")!==0&&this.visibility!=="none"}getProgramIds(){return["heatmap","heatmapTexture"]}getDefaultProgramParams(n,e,i){return n==="heatmap"?{config:new is(this,{zoom:e,lut:i}),overrideFog:!1}:{}}},hillshade:class extends ir{constructor(n,e,i,r){super(n,{layout:fn||(fn=new wi({visibility:new qe(he.layout_hillshade.visibility)})),paint:An||(An=new wi({"hillshade-illumination-direction":new qe(he.paint_hillshade["hillshade-illumination-direction"]),"hillshade-illumination-anchor":new qe(he.paint_hillshade["hillshade-illumination-anchor"]),"hillshade-exaggeration":new qe(he.paint_hillshade["hillshade-exaggeration"]),"hillshade-shadow-color":new qe(he.paint_hillshade["hillshade-shadow-color"]),"hillshade-highlight-color":new qe(he.paint_hillshade["hillshade-highlight-color"]),"hillshade-accent-color":new qe(he.paint_hillshade["hillshade-accent-color"]),"hillshade-emissive-strength":new qe(he.paint_hillshade["hillshade-emissive-strength"]),"hillshade-shadow-color-use-theme":new Ze({type:"string",default:"default","property-type":"data-driven"}),"hillshade-highlight-color-use-theme":new Ze({type:"string",default:"default","property-type":"data-driven"}),"hillshade-accent-color-use-theme":new Ze({type:"string",default:"default","property-type":"data-driven"})}))},e,i,r)}shouldRedrape(){return this.hasOffscreenPass()&&this.paint.get("hillshade-illumination-anchor")==="viewport"}hasOffscreenPass(){return this.paint.get("hillshade-exaggeration")!==0&&this.visibility!=="none"}getProgramIds(){return["hillshade","hillshadePrepare"]}getDefaultProgramParams(n,e,i){return{overrideFog:!1}}},fill:class extends ir{constructor(n,e,i,r){super(n,{layout:a0||(a0=new wi({"fill-sort-key":new Ze(he.layout_fill["fill-sort-key"]),visibility:new qe(he.layout_fill.visibility),"fill-elevation-reference":new qe(he.layout_fill["fill-elevation-reference"]),"fill-construct-bridge-guard-rail":new Ze(he.layout_fill["fill-construct-bridge-guard-rail"])})),paint:l0||(l0=new wi({"fill-antialias":new qe(he.paint_fill["fill-antialias"]),"fill-opacity":new Ze(he.paint_fill["fill-opacity"]),"fill-color":new Ze(he.paint_fill["fill-color"]),"fill-outline-color":new Ze(he.paint_fill["fill-outline-color"]),"fill-translate":new qe(he.paint_fill["fill-translate"]),"fill-translate-anchor":new qe(he.paint_fill["fill-translate-anchor"]),"fill-pattern":new Ze(he.paint_fill["fill-pattern"]),"fill-pattern-cross-fade":new qe(he.paint_fill["fill-pattern-cross-fade"]),"fill-emissive-strength":new qe(he.paint_fill["fill-emissive-strength"]),"fill-z-offset":new Ze(he.paint_fill["fill-z-offset"]),"fill-bridge-guard-rail-color":new Ze(he.paint_fill["fill-bridge-guard-rail-color"]),"fill-tunnel-structure-color":new Ze(he.paint_fill["fill-tunnel-structure-color"]),"fill-color-use-theme":new Ze({type:"string",default:"default","property-type":"data-driven"}),"fill-outline-color-use-theme":new Ze({type:"string",default:"default","property-type":"data-driven"}),"fill-bridge-guard-rail-color-use-theme":new Ze({type:"string",default:"default","property-type":"data-driven"}),"fill-tunnel-structure-color-use-theme":new Ze({type:"string",default:"default","property-type":"data-driven"})}))},e,i,r)}getProgramIds(){let n=this.paint.get("fill-pattern"),e=n&&n.constantOr(1),i=[e?"fillPattern":"fill"];return this.paint.get("fill-antialias")&&i.push(e&&!this.getPaintProperty("fill-outline-color")?"fillOutlinePattern":"fillOutline"),i}getDefaultProgramParams(n,e,i){return{config:new is(this,{zoom:e,lut:i}),overrideFog:!1}}recalculate(n,e){super.recalculate(n,e);let i=this.paint._values["fill-outline-color"];i.value.kind==="constant"&&i.value.value===void 0&&(this.paint._values["fill-outline-color"]=this.paint._values["fill-color"])}createBucket(n){return new Nm(n)}queryRadius(){return G(this.paint.get("fill-translate"))}queryIntersectsFeature(n,e,i,r,s,l){return!n.queryGeometry.isAboveHorizon&&m(re(n.tilespaceGeometry,this.paint.get("fill-translate"),this.paint.get("fill-translate-anchor"),l.angle,n.pixelToTileUnitsFactor),r)}isTileClipped(){return this.paint.get("fill-z-offset").constantOr(1)===0}is3D(n){if(this.paint.get("fill-z-offset").constantOr(1)!==0)return!0;let e=this.layout&&this.layout.get("fill-elevation-reference")!=="none";return n!=null?e&&!n:e}hasElevation(){return this.layout&&this.layout.get("fill-elevation-reference")!=="none"}hasShadowPass(){return this.layout&&this.layout.get("fill-elevation-reference")!=="none"}},"fill-extrusion":class extends ir{constructor(n,e,i,r){super(n,{layout:M0||(M0=new wi({visibility:new qe(he["layout_fill-extrusion"].visibility),"fill-extrusion-edge-radius":new qe(he["layout_fill-extrusion"]["fill-extrusion-edge-radius"]),"source-max-zoom":new qe(he["layout_fill-extrusion"]["source-max-zoom"])})),paint:C0||(C0=new wi({"fill-extrusion-opacity":new qe(he["paint_fill-extrusion"]["fill-extrusion-opacity"]),"fill-extrusion-color":new Ze(he["paint_fill-extrusion"]["fill-extrusion-color"]),"fill-extrusion-translate":new qe(he["paint_fill-extrusion"]["fill-extrusion-translate"]),"fill-extrusion-translate-anchor":new qe(he["paint_fill-extrusion"]["fill-extrusion-translate-anchor"]),"fill-extrusion-pattern":new Ze(he["paint_fill-extrusion"]["fill-extrusion-pattern"]),"fill-extrusion-pattern-cross-fade":new qe(he["paint_fill-extrusion"]["fill-extrusion-pattern-cross-fade"]),"fill-extrusion-height":new Ze(he["paint_fill-extrusion"]["fill-extrusion-height"]),"fill-extrusion-base":new Ze(he["paint_fill-extrusion"]["fill-extrusion-base"]),"fill-extrusion-height-alignment":new qe(he["paint_fill-extrusion"]["fill-extrusion-height-alignment"]),"fill-extrusion-base-alignment":new qe(he["paint_fill-extrusion"]["fill-extrusion-base-alignment"]),"fill-extrusion-vertical-gradient":new qe(he["paint_fill-extrusion"]["fill-extrusion-vertical-gradient"]),"fill-extrusion-ambient-occlusion-intensity":new qe(he["paint_fill-extrusion"]["fill-extrusion-ambient-occlusion-intensity"]),"fill-extrusion-ambient-occlusion-radius":new qe(he["paint_fill-extrusion"]["fill-extrusion-ambient-occlusion-radius"]),"fill-extrusion-ambient-occlusion-wall-radius":new qe(he["paint_fill-extrusion"]["fill-extrusion-ambient-occlusion-wall-radius"]),"fill-extrusion-ambient-occlusion-ground-radius":new qe(he["paint_fill-extrusion"]["fill-extrusion-ambient-occlusion-ground-radius"]),"fill-extrusion-ambient-occlusion-ground-attenuation":new qe(he["paint_fill-extrusion"]["fill-extrusion-ambient-occlusion-ground-attenuation"]),"fill-extrusion-flood-light-color":new qe(he["paint_fill-extrusion"]["fill-extrusion-flood-light-color"]),"fill-extrusion-flood-light-intensity":new qe(he["paint_fill-extrusion"]["fill-extrusion-flood-light-intensity"]),"fill-extrusion-flood-light-wall-radius":new Ze(he["paint_fill-extrusion"]["fill-extrusion-flood-light-wall-radius"]),"fill-extrusion-flood-light-ground-radius":new Ze(he["paint_fill-extrusion"]["fill-extrusion-flood-light-ground-radius"]),"fill-extrusion-flood-light-ground-attenuation":new qe(he["paint_fill-extrusion"]["fill-extrusion-flood-light-ground-attenuation"]),"fill-extrusion-vertical-scale":new qe(he["paint_fill-extrusion"]["fill-extrusion-vertical-scale"]),"fill-extrusion-rounded-roof":new qe(he["paint_fill-extrusion"]["fill-extrusion-rounded-roof"]),"fill-extrusion-cutoff-fade-range":new qe(he["paint_fill-extrusion"]["fill-extrusion-cutoff-fade-range"]),"fill-extrusion-front-cutoff":new qe(he["paint_fill-extrusion"]["fill-extrusion-front-cutoff"]),"fill-extrusion-emissive-strength":new Ze(he["paint_fill-extrusion"]["fill-extrusion-emissive-strength"]),"fill-extrusion-line-width":new Ze(he["paint_fill-extrusion"]["fill-extrusion-line-width"]),"fill-extrusion-cast-shadows":new qe(he["paint_fill-extrusion"]["fill-extrusion-cast-shadows"]),"fill-extrusion-color-use-theme":new Ze({type:"string",default:"default","property-type":"data-driven"}),"fill-extrusion-flood-light-color-use-theme":new Ze({type:"string",default:"default","property-type":"data-driven"})}))},e,i,r),this._stats={numRenderedVerticesInShadowPass:0,numRenderedVerticesInTransparentPass:0}}createBucket(n){return new Ym(n)}queryRadius(){return G(this.paint.get("fill-extrusion-translate"))}is3D(n){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(n,e,i,r,s,l,u,p,f){let g=te(this.paint.get("fill-extrusion-translate"),this.paint.get("fill-extrusion-translate-anchor"),l.angle,n.pixelToTileUnitsFactor),x=this.paint.get("fill-extrusion-height").evaluate(e,i),b=this.paint.get("fill-extrusion-base").evaluate(e,i),w=[0,0],S=p&&l.elevation,E=l.elevation?l.elevation.exaggeration():1,M=n.tile.getBucket(this);if(M instanceof Ym){let j=M.centroidData.find($=>f>=$.vertexArrayOffset&&f<$.vertexArrayOffset+$.vertexCount);if(j&&j.flags&Hm)return!1;if(S){let $=M.centroidVertexArray,H=f+1;H<$.length&&(w[0]=$.geta_centroid_pos0(H),w[1]=$.geta_centroid_pos1(H))}}if(w[0]===0&&w[1]===1)return!1;l.projection.name==="globe"&&(r=A0([r],[new ke(0,0),new ke(Xe,Xe)],n.tileID.canonical).map(j=>j.polygon).flat());let C=S?p:null,[R,F]=k0(l,r,b,x,g,u,C,w,E,l.center.lat,n.tileID.canonical),z=n.queryGeometry;return B0(R,F,z.isPointQuery()?z.screenBounds:z.screenGeometry)}},building:class extends ir{constructor(n,e,i,r){super(n,{layout:P0||(P0=new wi({visibility:new qe(he.layout_building.visibility),"building-facade":new Ze(he.layout_building["building-facade"]),"building-facade-floors":new Ze(he.layout_building["building-facade-floors"]),"building-facade-unit-width":new Ze(he.layout_building["building-facade-unit-width"]),"building-facade-window":new Ze(he.layout_building["building-facade-window"]),"building-roof-shape":new Ze(he.layout_building["building-roof-shape"]),"building-height":new Ze(he.layout_building["building-height"]),"building-base":new Ze(he.layout_building["building-base"]),"building-flood-light-wall-radius":new Ze(he.layout_building["building-flood-light-wall-radius"]),"building-flood-light-ground-radius":new Ze(he.layout_building["building-flood-light-ground-radius"]),"building-flip-roof-orientation":new Ze(he.layout_building["building-flip-roof-orientation"])})),paint:D0||(D0=new wi({"building-opacity":new qe(he.paint_building["building-opacity"]),"building-ambient-occlusion-intensity":new qe(he.paint_building["building-ambient-occlusion-intensity"]),"building-ambient-occlusion-ground-intensity":new qe(he.paint_building["building-ambient-occlusion-ground-intensity"]),"building-ambient-occlusion-ground-radius":new qe(he.paint_building["building-ambient-occlusion-ground-radius"]),"building-ambient-occlusion-ground-attenuation":new qe(he.paint_building["building-ambient-occlusion-ground-attenuation"]),"building-vertical-scale":new qe(he.paint_building["building-vertical-scale"]),"building-cast-shadows":new qe(he.paint_building["building-cast-shadows"]),"building-color":new Ze(he.paint_building["building-color"]),"building-emissive-strength":new Ze(he.paint_building["building-emissive-strength"]),"building-facade-emissive-chance":new qe(he.paint_building["building-facade-emissive-chance"]),"building-cutoff-fade-range":new qe(he.paint_building["building-cutoff-fade-range"]),"building-front-cutoff":new qe(he.paint_building["building-front-cutoff"]),"building-flood-light-color":new qe(he.paint_building["building-flood-light-color"]),"building-flood-light-intensity":new qe(he.paint_building["building-flood-light-intensity"]),"building-flood-light-ground-attenuation":new qe(he.paint_building["building-flood-light-ground-attenuation"]),"building-color-use-theme":new Ze({type:"string",default:"default","property-type":"data-driven"}),"building-flood-light-color-use-theme":new Ze({type:"string",default:"default","property-type":"data-driven"})}))},e,i,r),this._stats={numRenderedVerticesInShadowPass:0,numRenderedVerticesInTransparentPass:0}}prepare(){return mx()}createBucket(n){return new fx(n)}cutoffRange(){return this.paint.get("building-cutoff-fade-range")}hasShadowPass(){return this.paint.get("building-cast-shadows")}hasLightBeamPass(){return!0}canCastShadows(){return!0}is3D(n){return!0}queryRadius(n){return 0}queryIntersectsFeature(n,e,i,r,s,l,u,p,f,g){let x=this.layout.get("building-height").evaluate(e,i),b=this.layout.get("building-base").evaluate(e,i),w=n.tile.getBucket(this).getFootprint(e);if(w){if(w.hiddenFlags!==0)return!1;x=w.height}let[S,E]=k0(l,r,b,x,new ke(0,0),u,null,[0,0],1,l.center.lat,n.tileID.canonical),M=n.queryGeometry;return B0(S,E,M.isPointQuery()?M.screenBounds:M.screenGeometry)}}
7,line:class extends ir{constructor(n,e,i,r){let s=Ix();super(n,s,e,i,r),s.layout&&(this.layout=new es(s.layout)),this.gradientVersion=0,this.hasElevatedBuckets=!1,this.hasNonElevatedBuckets=!1,this.lineBlendFbos=null,this.lineBlendDensityReadback=null}_handleSpecialPaintPropertyUpdate(n){if(n==="line-gradient"){let e=this._transitionablePaint._values["line-gradient"].value.expression;this.stepInterpolant=e._styleExpression&&e._styleExpression.expression instanceof gl,this.gradientVersion=(this.gradientVersion+1)%Number.MAX_SAFE_INTEGER}}gradientExpression(){return this._transitionablePaint._values["line-gradient"].value.expression}widthExpression(){return this._transitionablePaint._values["line-width"].value.expression}emissiveStrengthExpression(){return this._transitionablePaint._values["line-emissive-strength"].value.expression}recalculate(n,e){super.recalculate(n,e),this.paint._values["line-floorwidth"]=(()=>{if(Ap)return Ap;let i=Ix();return Ap=new ew(i.paint.properties["line-width"].specification),Ap.useIntegerZoom=!0,Ap})().possiblyEvaluate(this._transitioningPaint._values["line-width"].value,n)}createBucket(n){return new l_(n)}getProgramIds(){let n=[this.paint.get("line-pattern").constantOr(1)?"linePattern":"line"];return this.paint.get("line-blend-mode")!=="default"&&n.push("lineBlendComposite"),n}getDefaultProgramParams(n,e,i){if(n==="lineBlendComposite")return{};let r=Tx(this);return{config:new is(this,{zoom:e,lut:i}),defines:r,overrideFog:!1}}queryRadius(n){let e=n,i=Ex(Z("line-width",this,e),Z("line-gap-width",this,e)),r=Z("line-offset",this,e);return i/2+Math.abs(r)+G(this.paint.get("line-translate"))}queryIntersectsFeature(n,e,i,r,s,l){if(n.queryGeometry.isAboveHorizon)return!1;let u=re(n.tilespaceGeometry,this.paint.get("line-translate"),this.paint.get("line-translate-anchor"),l.angle,n.pixelToTileUnitsFactor),p=n.pixelToTileUnitsFactor/2*Ex(this.paint.get("line-width").evaluate(e,i),this.paint.get("line-gap-width").evaluate(e,i)),f=this.paint.get("line-offset").evaluate(e,i);return f&&(r=function(g,x){let b=[],w=new ke(0,0);for(let S=0;S<g.length;S++){let E=g[S],M=[];for(let C=0;C<E.length;C++){let R=E[C],F=E[C+1],z=C===0?w:R.sub(E[C-1])._unit()._perp(),j=C===E.length-1?w:F.sub(R)._unit()._perp(),$=z._add(j)._unit();$._mult(1/($.x*j.x+$.y*j.y)),M.push($._mult(x)._add(R))}b.push(M)}return b}(r,f*n.pixelToTileUnitsFactor)),function(g,x,b){for(let w=0;w<x.length;w++){let S=x[w];if(g.length>=3){for(let E=0;E<S.length;E++)if(L(g,S[E]))return!0}if(_(g,S,b))return!0}return!1}(u,r,p)}isTileClipped(){return this.hasNonElevatedBuckets}isDraped(n){return!this.hasElevatedBuckets||this.layout&&this.layout.get("line-elevation-reference")==="hd-road-markup"}hasElevation(){return this.layout&&this.layout.get("line-elevation-reference")!=="none"}hasOffscreenPass(){return this.paint.get("line-blend-mode")!=="default"&&this.paint.get("line-opacity").constantOr(1)!==0&&this.paint.get("line-width").constantOr(1)!==0&&this.visibility!=="none"}resize(){this._destroyLineBlendFbo()}onRemove(n){this._destroyLineBlendFbo(n.painter&&n.painter.context&&n.painter.context.gl||void 0)}_clear(){this._destroyLineBlendFbo()}_destroyLineBlendFbo(n){this.lineBlendFbos&&(this.lineBlendFbos.destroy(),this.lineBlendFbos=null),n&&this.lineBlendDensityReadback&&this.lineBlendDensityReadback.destroy(n),this.lineBlendDensityReadback=null}},symbol:T_,background:class extends ir{constructor(n,e,i,r){super(n,{layout:vv||(vv=new wi({visibility:new qe(he.layout_background.visibility)})),paint:bv||(bv=new wi({"background-pitch-alignment":new qe(he.paint_background["background-pitch-alignment"]),"background-color":new qe(he.paint_background["background-color"]),"background-pattern":new qe(he.paint_background["background-pattern"]),"background-opacity":new qe(he.paint_background["background-opacity"]),"background-emissive-strength":new qe(he.paint_background["background-emissive-strength"]),"background-color-use-theme":new Ze({type:"string",default:"default","property-type":"data-driven"})}))},e,i,r)}getProgramIds(){return[this.paint.get("background-pattern")?"backgroundPattern":"background"]}getDefaultProgramParams(n,e,i){return{overrideFog:!1}}is3D(n){return this.paint.get("background-pitch-alignment")==="viewport"}},raster:Ev,"raster-particle":Lv,sky:class extends ir{constructor(n,e,i,r){super(n,{layout:Cv||(Cv=new wi({visibility:new qe(he.layout_sky.visibility)})),paint:Pv||(Pv=new wi({"sky-type":new qe(he.paint_sky["sky-type"]),"sky-atmosphere-sun":new qe(he.paint_sky["sky-atmosphere-sun"]),"sky-atmosphere-sun-intensity":new qe(he.paint_sky["sky-atmosphere-sun-intensity"]),"sky-gradient-center":new qe(he.paint_sky["sky-gradient-center"]),"sky-gradient-radius":new qe(he.paint_sky["sky-gradient-radius"]),"sky-gradient":new La(he.paint_sky["sky-gradient"]),"sky-atmosphere-halo-color":new qe(he.paint_sky["sky-atmosphere-halo-color"]),"sky-atmosphere-color":new qe(he.paint_sky["sky-atmosphere-color"]),"sky-opacity":new qe(he.paint_sky["sky-opacity"]),"sky-gradient-use
7-theme":new Ze({type:"string",default:"default","property-type":"data-driven"}),"sky-atmosphere-halo-color-use-theme":new Ze({type:"string",default:"default","property-type":"data-driven"}),"sky-atmosphere-color-use-theme":new Ze({type:"string",default:"default","property-type":"data-driven"})}))},e,i,r),this._updateColorRamp()}_clear(){this.skyboxFbo&&(this.skyboxFbo.destroy(),this.skyboxFbo=null),this.colorRampTexture&&(this.colorRampTexture.destroy(),this.colorRampTexture=null),this._skyboxInvalidated=!0}_handleSpecialPaintPropertyUpdate(n){n==="sky-gradient"?this._updateColorRamp():n!=="sky-atmosphere-sun"&&n!=="sky-atmosphere-halo-color"&&n!=="sky-atmosphere-color"&&n!=="sky-atmosphere-sun-intensity"||(this._skyboxInvalidated=!0)}_updateColorRamp(){this.colorRamp=ei({expression:this._transitionablePaint._values["sky-gradient"].value.expression,evaluationKey:"skyRadialProgress"}),this.colorRampTexture&&(this.colorRampTexture.destroy(),this.colorRampTexture=null)}needsSkyboxCapture(n){if(this._skyboxInvalidated||!this.skyboxTexture||!this.skyboxGeometry)return!0;if(!this.paint.get("sky-atmosphere-sun")){let e=n.style.light.properties.get("position");return this._lightPosition.azimuthal!==e.azimuthal||this._lightPosition.polar!==e.polar}return!1}getCenter(n,e){if(this.paint.get("sky-type")==="atmosphere"){let r=this.paint.get("sky-atmosphere-sun"),s=!r,l=n.style.light,u=l.properties.get("position");return s&&l.properties.get("anchor")==="viewport"&&Ot("The sun direction is attached to a light with viewport anchor, lighting may behave unexpectedly."),s?Ay(u.azimuthal,90-u.polar,e):Ay(r[0],90-r[1],e)}let i=this.paint.get("sky-gradient-center");return Ay(i[0],90-i[1],e)}isSky(){return!0}markSkyboxValid(n){this._skyboxInvalidated=!1,this._lightPosition=n.style.light.properties.get("position")}hasOffscreenPass(){return!0}getProgramIds(){let n=this.paint.get("sky-type");return n==="atmosphere"?["skyboxCapture","skybox"]:n==="gradient"?["skyboxGradient"]:null}},slot:class extends ir{constructor(n,e,i,r){super(n,{paint:Dv||(Dv=new wi({}))},e,null)}},model:class extends ir{constructor(n,e,i,r){super(n,{layout:Rv||(Rv=new wi({visibility:new qe(he.layout_model.visibility),"model-id":new Ze(he.layout_model["model-id"]),"model-allow-density-reduction":new qe(he.layout_model["model-allow-density-reduction"])})),paint:zv||(zv=new wi({"model-opacity":new Ze(he.paint_model["model-opacity"]),"model-rotation":new Ze(he.paint_model["model-rotation"]),"model-scale":new Ze(he.paint_model["model-scale"]),"model-translation":new Ze(he.paint_model["model-translation"]),"model-color":new Ze(he.paint_model["model-color"]),"model-color-mix-intensity":new Ze(he.paint_model["model-color-mix-intensity"]),"model-type":new qe(he.paint_model["model-type"]),"model-cast-shadows":new qe(he.paint_model["model-cast-shadows"]),"model-receive-shadows":new qe(he.paint_model["model-receive-shadows"]),"model-ambient-occlusion-intensity":new qe(he.paint_model["model-ambient-occlusion-intensity"]),"model-emissive-strength":new Ze(he.paint_model["model-emissive-strength"]),"model-roughness":new Ze(he.paint_model["model-roughness"]),"model-height-based-emissive-strength-multiplier":new Ze(he.paint_model["model-height-based-emissive-strength-multiplier"]),"model-cutoff-fade-range":new qe(he.paint_model["model-cutoff-fade-range"]),"model-front-cutoff":new qe(he.paint_model["model-front-cutoff"]),"model-elevation-reference":new qe(he.paint_model["model-elevation-reference"]),"model-ignore-line-cutout":new qe(he.paint_model["model-ignore-line-cutout"]),"model-color-use-theme":new Ze({type:"string",default:"default","property-type":"data-driven"})}))},e,i,r),this.layer=n,this._stats={numRenderedVerticesInShadowPass:0,numRenderedVerticesInTransparentPass:0}}createBucket(n){return new My(n)}getProgramIds(){return["model"]}is3D(n){return!0}hasShadowPass(){return!0}canCastShadows(){return!0}hasLightBeamPass(){return!0}cutoffRange(){return this.paint.get("model-cutoff-fade-range")}queryRadius(n){return n instanceof C_?8191:0}queryRenderedFeatures(n,e,i){let r=e.getSource();if(!(r&&r instanceof cu))return{};let s=r,l={};l[this.id]=[];let u=l[this.id],p=0;for(let f of s.models){let g=e.getFeatureState(this.sourceLayer,f.id),x={type:"Unknown",id:f.id,properties:f.featureProperties},b=this.paint.get("model-rotation").evaluate(x,g),w=this.paint.get("model-scale").evaluate(x,g),S=this.paint.get("model-translation").evaluate(x,g),E=this.paint.get("model-elevation-reference"),M=[];o_(M,f,i,f.position,b,w,S,E==="ground",E==="ground",!1),i.projection.name==="globe"&&(M=r_(M,i));let C=xi([],i.projMatrix,M),R=Hg(n.isPointQuery()?n.screenBounds:n.screenGeometry,i,C,f.aabb);if(R!=null){let F=new lu(void 0,0,0,0,f.id);F.layer=this.layer,F.properties=structuredClone(f.featureProperties),F.properties.layer=this.id,F.properties.uri=f.uri,F.properties.orientation=f.orientation,F.sourceLayer=this.sourceLayer,F.geometry={type:"Point",coordinates:[f.position.lng,f.position.lat]},F.state=g,F.source=this.source,u.push({featureIndex:p,feature:F,intersectionZ:R})}++p}return l}queryIntersectsFeature(n,e,i,r,s,l,u,p,f,g){if(!this.modelManager)return!1;let x=this.modelManager,b=n.tile.getBucket(this);if(!(b&&b instanceof My))return!1;for(let w in b.instancesPerModel){let S=b.instancesPerModel[w],E=e.id!==void 0?e.id:e.properties&&Object.hasOwn(e.properties,"id")?e.properties.id:void 0;if(Object.hasOwn(S.idToFeaturesIndex,E)){let M=S.features[S.idToFeaturesIndex[E]],C=x.getModel(w,g||this.scope);if(!C)return!1;let R=[],F=new Yt(0,0),z=b.canonical,j=Number.MAX_VALUE;for(let $=0;$<M.instancedDataCount;++$){let H=16*(M.instancedDataOffset+$),ie=S.instancedDataArray.float32,W=[ie[H+4],ie[H+5],ie[H+6]];Py(z,F,Math.floor(ie[H]),Math.floor(ie[H+1])),o_(R,C,l,F,M.rotation,M.scale,W,!1,!1,!1),l.projection.name==="globe"&&(R=r_(R,l));let Q=xi([],l.projMatrix,R),Y=n.queryGeometry,ee=Hg(Y.isPointQuery()?Y.screenBounds:Y.screenGeometry,l,Q,C.aabb);ee!=null&&(j=Math.min(ee,j))}return j!==Number.MAX_VALUE&&j}}return!1}_handleOverridablePaintPropertyUpdate(n,e,i){return!(!this.layout||e.isDataDriven()||i.isDataDriven()||n!=="model-color"&&n!=="model-color-mix-intensity"&&n!=="model-rotation"&&n!=="model-scale"&&n!=="model-translation"&&n!=="model-emissive-strength")}_isPropertyZoomDependent(n){let e=this._transitionablePaint._values[n];return e!=null&&e.value!=null&&e.value.expression!=null&&e.value.expression instanceof bl}isZoomDependent(){return this._isPropertyZoomDependent("model-scale")||this._isPropertyZoomDependent("model-rotation")||this._isPropertyZoomDependent("model-translation")}},clip:class extends ir{constructor(n,e,i,r){super(n,{layout:c0||(c0=new wi({"clip-layer-types":ne
7w qe(he.layout_clip["clip-layer-types"]),"clip-layer-scope":new qe(he.layout_clip["clip-layer-scope"]),visibility:new qe(he.layout_clip.visibility)})),paint:u0||(u0=new wi({}))},e,i,r)}recalculate(n,e){super.recalculate(n,e)}createBucket(n){return new h0(n)}is3D(n){return!0}}};class Dy{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)}}Qe(Dy,"LRUCache");class hT{constructor(e){this._callback=e,this._triggered=!1,typeof MessageChannel<"u"&&(this._channel=new MessageChannel,this._channel.port2.onmessage=()=>{this._triggered=!1,this._callback()})}trigger(){this._triggered||(this._triggered=!0,this._channel?this._channel.port1.postMessage(!0):setTimeout(()=>{this._triggered=!1,this._callback()},0))}remove(){this._channel=void 0,this._callback=()=>{}}}class jv{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]}}class Gv{constructor(e,i){this.tileID=e,this.x=e.canonical.x,this.y=e.canonical.y,this.z=e.canonical.z,this.grid=new Ra(Xe,Xe,512),this.featureIndexArray=new dm,this.promoteId=i,this.is3DTile=!1,this.serializedLayersCache=new Map}insert(e,i,r,s,l,u=0,p=0){let f=this.featureIndexArray.length;this.featureIndexArray.emplaceBack(r,s,l,u);let g=this.grid;for(let x=0;x<i.length;x++){let b=i[x],w=[1/0,1/0,-1/0,-1/0];for(let S=0;S<b.length;S++){let E=b[S];w[0]=Math.min(w[0],E.x),w[1]=Math.min(w[1],E.y),w[2]=Math.max(w[2],E.x),w[3]=Math.max(w[3],E.y)}p!==0&&(w[0]-=p,w[1]-=p,w[2]+=p,w[3]+=p),w[0]<Xe&&w[1]<Xe&&w[2]>=0&&w[3]>=0&&g.insert(f,w[0],w[1],w[2],w[3])}}loadVTLayers(){if(!this.vtLayers){this.vtLayers=new cp(new c_(this.rawTileData)).layers,this.sourceLayerCoder=new jv(this.vtLayers?Object.keys(this.vtLayers).sort():["_geojsonTileLayer"]),this.vtFeatures={};for(let e in this.vtLayers)this.vtFeatures[e]=[]}return this.vtLayers}query(e,i){let{tilespaceGeometry:r,transform:s,tileTransform:l,pixelPosMatrix:u,availableImages:p,worldview:f}=i;this.loadVTLayers(),this.serializedLayersCache.clear();let g=i.queryRadius?i.queryRadius:0,x=r.bufferedTilespaceBounds,b=this.grid.queryKeys(x.min.x,x.min.y,x.max.x,x.max.y,(M,C,R,F)=>O(r.bufferedTilespaceGeometry,M-g,C-g,R+g,F+g));b.sort(dT);let w=null;s.elevation&&b.length>0&&(w=Ch.create(s.elevation,this.tileID));let S={},E;for(let M=0;M<b.length;M++){let C=b[M];if(C===E)continue;E=C;let R=this.featureIndexArray.get(C),F=null;this.is3DTile?this.loadMatchingModelFeature(S,R,e,r,s,f):this.loadMatchingFeature(S,R,e,p,f,(z,j,$,H=0)=>(F||(F=jr(z,this.tileID.canonical,l)),j.queryIntersectsFeature(r,z,$,F,this.z,s,u,w,H,i.scope)))}return S}loadMatchingFeature(e,i,r,s,l,u){let{featureIndex:p,bucketIndex:f,sourceLayerIndex:g,layoutVertexArrayOffset:x}=i,b=this.bucketLayerIDs[f],w=r.layers,S=Object.keys(w);if(S.length&&!$i(S,b))return;let E=r.sourceCache,M=this.sourceLayerCoder.decode(g),C=this.vtLayers[M].feature(p),R=this.getId(C,M);for(let F=0;F<b.length;F++){let z=b[F];if(!w[z])continue;let{styleLayer:j,targets:$}=w[z],H={};R!==void 0&&(H=E.getFeatureState(j.sourceLayer,R));let ie=!u||u(C,j,H,x);if(!ie)continue;let W=new lu(C,this.z,this.x,this.y,R);W.tile=this.tileID.canonical,W.state=H;let Q=this.serializedLayersCache.get(z);Q||(Q=j.serialize(),Q.id=z,this.serializedLayersCache.set(z,Q)),W.source=Q.source,W.sourceLayer=Q["source-layer"],W.layer=Object.assign({},Q),W.layer.paint=$v(Q.paint,j.paint,C,H,s),W.layer.layout=$v(Q.layout,j.layout,C,H,s);let Y=!1;for(let ee of $){this.updateFeatureProperties(W,ee);let{filter:me}=ee;if(me){if(C.properties=W.properties,me.needGeometry){let ge=Gr(C,!0);if(!me.filter(new Xt(this.tileID.overscaledZ,{worldview:l}),ge,this.tileID.canonical))continue}else if(!me.filter(new Xt(this.tileID.overscaledZ,{worldview:l}),C))continue}Y=!0,ee.targetId&&this.addFeatureVariant(W,ee)}Y&&this.appendToResult(e,z,p,W,ie)}}
7loadMatchingModelFeature(e,i,r,s,l,u){let{featureIndex:p,bucketIndex:f}=i,g=this.bucketLayerIDs[f],x=r.layers,b=Object.keys(x);if(!b.length||$i(b,g))for(let w=0;w<g.length;w++){let S=g[w],{styleLayer:E,targets:M}=x[S];if(E.type!=="model")continue;let C=s.tile,R=C.getBucket(E);if(!(R&&R instanceof C_))continue;let F=cT(R,p,s,l);if(!F)continue;let{z,x:j,y:$}=C.tileID.canonical,{feature:H,intersectionZ:ie,position:W}=F,Q={};H.id!==void 0&&(Q=r.sourceCache.getFeatureState(E.sourceLayer,H.id));let Y=new lu({},z,j,$,H.id);Y.tile=this.tileID.canonical,Y.state=Q,Y.properties=H.properties,Y.geometry={type:"Point",coordinates:[W.lng,W.lat]};let ee=this.serializedLayersCache.get(S);ee||(ee=E.serialize(),ee.id=S,this.serializedLayersCache.set(S,ee)),Y.source=ee.source,Y.sourceLayer=ee["source-layer"],Y.layer=Object.assign({},ee);let me=!1;for(let ge of M){this.updateFeatureProperties(Y,ge);let{filter:Te}=ge;if(Te){if(H.properties=Y.properties,Te.needGeometry){if(!Te.filter(new Xt(this.tileID.overscaledZ,{worldview:u}),H,this.tileID.canonical))continue}else if(!Te.filter(new Xt(this.tileID.overscaledZ,{worldview:u}),H))continue}me=!0,ge.targetId&&this.addFeatureVariant(Y,ge)}me&&this.appendToResult(e,S,p,Y,ie)}}updateFeatureProperties(e,i,r){if(i.properties){let s={};for(let l in i.properties){let u=i.properties[l].evaluate({zoom:this.z},e._vectorTileFeature,e.state,e.tile,r);u!=null&&(s[l]=u)}e.properties=s}}addFeatureVariant(e,i,r){let s={target:i.target,namespace:i.namespace,uniqueFeatureID:i.uniqueFeatureID};i.properties&&(s.properties=e.properties),e.variants=e.variants||{},e.variants[i.targetId]=e.variants[i.targetId]||[],e.variants[i.targetId].push(s)}appendToResult(e,i,r,s,l){let u=e[i];u===void 0&&(u=e[i]=[]),u.push({featureIndex:r,feature:s,intersectionZ:l})}lookupSymbolFeatures(e,i,r,s,l,u){let p={};this.loadVTLayers();for(let f of e)this.loadMatchingFeature(p,{bucketIndex:i,sourceLayerIndex:r,featureIndex:f,layoutVertexArrayOffset:0},s,l,u);return p}loadFeature(e){let{featureIndex:i,sourceLayerIndex:r}=e;this.loadVTLayers();let s=this.sourceLayerCoder.decode(r),l=this.vtFeatures[s];if(l[i])return l[i];let u=this.vtLayers[s].feature(i);return l[i]=u,u}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 s=Array.isArray(this.promoteId)||typeof this.promoteId!="object"?this.promoteId:this.promoteId[i];if(s!=null)if(Array.isArray(s)){if(!this.promoteIdExpression){let l=Pa(s);if(l.result!=="success"){let u=l.value.map(p=>`${p.key}: ${p.message}`).join(", ");return void Ot(`Failed to create expression for promoteId: ${u}`)}this.promoteIdExpression=l.value}r=this.promoteIdExpression.evaluate({zoom:0},e)}else r=e.properties[s];typeof r=="boolean"&&(r=Number(r))}return r}}function $v(n,e,i,r,s){return Mt(n,(l,u)=>{let p=e instanceof es?e.get(u):null;return p&&p.evaluate?p.evaluate(i,r,void 0,s):p})}function dT(n,e){return e-n}function Hv(n,e){let i={};if(!e)return i;for(let r of n){let s=r.layerIds.map(l=>e.getLayer(l)).filter(Boolean);if(s.length!==0){r.layers=s,r.stateDependentLayerIds&&(r.stateDependentLayers=r.stateDependentLayerIds.map(l=>s.filter(u=>u.id===l)[0])),r.updateExpressions&&r.updateExpressions(s);for(let l of s)i[l.fqid]=r}}return i}Qe(Gv,"FeatureIndex",{omit:["rawTileData","sourceLayerCoder"]});let ko=32,Ys=33,ql=new Uint16Array(8184);for(let n=0;n<2046;n++){let e=n+2,i=0,r=0,s=0,l=0,u=0,p=0;for(1&e?s=l=u=ko:i=r=p=ko;(e>>=1)>1;){let g=i+s>>1,x=r+l>>1;1&e?(s=i,l=r,i=u,r=p):(i=s,r=l,s=u,l=p),u=g,p=x}let f=4*n;ql[f+0]=i,ql[f+1]=r,ql[f+2]=s,ql[f+3]=l}
7let Js=new Uint16Array(2178),Zl=new Uint8Array(1089),P_=new Uint16Array(1089);function qv(n){return n===0?-.03125:n===32?.03125:0}let Zv={Other:0,Symbol:1,FillExtrusion:2},Wv={type:2,extent:Xe,loadGeometry:()=>[[new ke(0,0),new ke(8193,0),new ke(8193,8193),new ke(0,8193),new ke(0,0)]]};class pT{constructor(){this.tasks={},this.taskQueue=[],St(["process"],this),this.invoker=new hT(this.process),this.nextId=0}add(e,i){let r=this.nextId++,s=function({type:l,renderSourceType:u,zoom:p}){p=p||0;let f=u===Zv.Symbol;return l==="message"?0:l!=="maybePrepare"||f?l!=="parseTile"||f?l==="parseTile"&&f?300-p:l==="maybePrepare"&&f?400-p:500:200-p:100-p}(i);if(s===0){try{e()}finally{}return null}return this.tasks[r]={fn:e,metadata:i,priority:s,id:r},this.taskQueue.push(r),this.invoker.trigger(),{cancel:()=>{delete this.tasks[r]}}}process(){try{if(this.taskQueue=this.taskQueue.filter(r=>!!this.tasks[r]),!this.taskQueue.length)return;let e=this.pick();if(e===null)return;let i=this.tasks[e];if(delete this.tasks[e],this.taskQueue.length&&this.invoker.trigger(),!i)return;i.fn()}finally{}}pick(){let e=null,i=1/0;for(let s=0;s<this.taskQueue.length;s++){let l=this.tasks[this.taskQueue[s]];l.priority<i&&(i=l.priority,e=s)}if(e===null)return null;let r=this.taskQueue[e];return this.taskQueue.splice(e,1),r}remove(){this.invoker.remove()}}function Xv(n,e,i){try{e=function(s){if(!s.variants)return s;if(!Array.isArray(s.variants))throw new Error("variants must be an array");for(let l of s.variants){if(l==null||typeof l!="object"||l.constructor!==Object)throw new Error("variant must be an object");if(!Array.isArray(l.capabilities))throw new Error("capabilities must be an array");if(l.capabilities.length===1&&l.capabilities[0]==="meshopt")return Object.assign(s,l)}return s}(e)}catch(s){return new Error("Failed to process TileJSON variants",{cause:s})}let r=Ke(Object.assign({},e,n),["tilejson","tiles","minzoom","maxzoom","attribution","mapbox_logo","bounds","extra_bounds","scheme","tileSize","encoding","vector_layers","raster_layers","worldview_options","worldview_default","worldview"]);return n.url&&e.tiles&&n.tiles&&(r.tiles=e.tiles),r.tiles=i.canonicalizeTileset(r,n.url),r}let Ry=new Map,Yv=new Map;class Jv{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 Kv(n,e,i,r){let s=0,l=Number.MAX_VALUE;for(let u=0;u<3;u++)if(Math.abs(r[u])<1e-15){if(i[u]<n[u]||i[u]>e[u])return null}else{let p=1/r[u],f=(n[u]-i[u])*p,g=(e[u]-i[u])*p;if(f>g){let x=f;f=g,g=x}if(f>s&&(s=f),g<l&&(l=g),s>l)return null}return s}function Qv(n,e,i,r,s,l,u,p,f,g,x){let b=r-n,w=s-e,S=l-i,E=u-n,M=p-e,C=f-i,R=x[1]*C-x[2]*M,F=x[2]*E-x[0]*C,z=x[0]*M-x[1]*E,j=b*R+w*F+S*z;if(Math.abs(j)<1e-15)return null;let $=1/j,H=g[0]-n,ie=g[1]-e,W=g[2]-i,Q=(H*R+ie*F+W*z)*$;if(Q<0||Q>1)return null;let Y=ie*S-W*w,ee=W*b-H*S,me=H*w-ie*b,ge=(x[0]*Y+x[1]*ee+x[2]*me)*$;return ge<0||Q+ge>1?null:(E*Y+M*ee+C*me)*$}function e1(n,e,i){return(n-e)/(i-e)}function t1(n,e,i,r,s,l,u,p,f){let g=1<<i,x=l-r,b=u-s,w=(n+1)/g*x+r,S=(e+0)/g*b+s,E=(e+1)/g*b+s;p[0]=(n+0)/g*x+r,p[1]=S,f[0]=w,f[1]=E}class i1{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(l){let u=Math.ceil(Math.log2(l.dim/8)),p=[],f=Math.ceil(Math.pow(2,u)),g=1/f,x=(S,E,M,C,R)=>{let F=C?1:0,z=(S+1)*M-F,j=E*M,$=(E+1)*M-F;R[0]=S*M,R[1]=j,R[2]=z,R[3]=$},b=new Jv(f),w=[];for(let S=0;S<f*f;S++){x(S%f,Math.floor(S/f),g,!1,w);let E=Wl(w[0],w[1],l),M=Wl(w[2],w[1],l),C=Wl(w[2],w[3],l),R=Wl(w[0],w[3],l);b.minimums.push(Math.min(E,M,C,R)),b.maximums.push(Math.max(E,M,C,R)),b.leaves.push(1)}for(p.push(b),f/=2;f>=1;f/=2){let S=p.at(-1);b=new Jv(f);for(let E=0;E<f*f;E++){x(E%f,Math.floor(E/f),2,!0,w);let M=S.getElevation(w[0],w[1]),C=S.getElevation(w[2],w[1]),R=S.getElevation(w[2],w[3]),F=S.getElevation(w[0],w[3]),z=S.isLeaf(w[0],w[1]),j=S.isLeaf(w[2],w[1]),$=S.isLeaf(w[2],w[3]),H=S.isLeaf(w[0],w[3]),ie=Math.min(M.min,C.min,R.min,F.min),W=Math.max(M.max,C.max,R.max,F.max),Q=z&&j&&$&&H;b.maximums.push(W),b.minimums.push(ie),b.leaves.push(W-ie<=5&&Q?1:0)}p.push(b)}return p}(this.dem),r=i.length-1,s=i[r];this._addNode(s.minimums[0],s.maximums[0],s.leaves[0]),this._construct(i,
70,0,r,0)}raycastRoot(e,i,r,s,l,u,p=1){return Kv([e,i,-100],[r,s,this.maximums[0]*p],l,u)}raycast(e,i,r,s,l,u,p=1){if(!this.nodeCount)return null;let f=this.raycastRoot(e,i,r,s,l,u,p);if(f==null)return null;let g=[],x=[],b=[],w=[],S=[{idx:0,t:f,nodex:0,nodey:0,depth:0}];for(;S.length>0;){let{idx:E,t:M,nodex:C,nodey:R,depth:F}=S.pop();if(this.leaves[E]){t1(C,R,F,e,i,r,s,b,w);let j=1<<F,$=(C+0)/j,H=(C+1)/j,ie=(R+0)/j,W=(R+1)/j,Q=Wl($,ie,this.dem)*p,Y=Wl(H,ie,this.dem)*p,ee=Wl(H,W,this.dem)*p,me=Wl($,W,this.dem)*p,ge=Qv(b[0],b[1],Q,w[0],b[1],Y,w[0],w[1],ee,l,u),Te=Qv(w[0],w[1],ee,b[0],w[1],me,b[0],b[1],Q,l,u),Ae=Math.min(ge!==null?ge:Number.MAX_VALUE,Te!==null?Te:Number.MAX_VALUE);if(Ae!==Number.MAX_VALUE)return Ae;{let Ee=Dr([],l,u,M);if(n1(Q,Y,me,ee,e1(Ee[0],b[0],w[0]),e1(Ee[1],b[1],w[1]))>=Ee[2])return M}continue}let z=0;for(let j=0;j<this._siblingOffset.length;j++){t1((C<<1)+this._siblingOffset[j][0],(R<<1)+this._siblingOffset[j][1],F+1,e,i,r,s,b,w),b[2]=-100,w[2]=this.maximums[this.childOffsets[E]+j]*p;let $=Kv(b,w,l,u);if($!=null){let H=$;g[j]=H;let ie=!1;for(let W=0;W<z&&!ie;W++)H>=g[x[W]]&&(x.splice(W,0,j),ie=!0);ie||(x[z]=j),z++}}for(let j=0;j<z;j++){let $=x[j];S.push({idx:this.childOffsets[E]+$,t:g[$],nodex:(C<<1)+this._siblingOffset[$][0],nodey:(R<<1)+this._siblingOffset[$][1],depth:F+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,s,l){if(e[s].isLeaf(i,r)===1)return;this.childOffsets[l]||(this.childOffsets[l]=this.nodeCount);let u=s-1,p=e[u],f=0,g=0;for(let x=0;x<this._siblingOffset.length;x++){let b=2*i+this._siblingOffset[x][0],w=2*r+this._siblingOffset[x][1],S=p.getElevation(b,w),E=p.isLeaf(b,w),M=this._addNode(S.min,S.max,E);E&&(f|=1<<x),g||(g=M)}for(let x=0;x<this._siblingOffset.length;x++)f&1<<x||this._construct(e,2*i+this._siblingOffset[x][0],2*r+this._siblingOffset[x][1],u,g+x)}}function n1(n,e,i,r,s,l){return ft(ft(n,i,l),ft(e,r,l),s)}function Wl(n,e,i){let r=i.dim,s=ne(n*r-.5,0,r-1),l=ne(e*r-.5,0,r-1),u=Math.floor(s),p=Math.floor(l),f=Math.min(u+1,r-1),g=Math.min(p+1,r-1);return n1(i.get(u,p),i.get(f,p),i.get(u,g),i.get(f,g),s-u,l-p)}let fT={mapbox:[6553.6,25.6,.1,1e4],terrarium:[256,1,1/256,32768]};function mT(n,e,i){return(256*n*256+256*e+i)/10-1e4}function _T(n,e,i){return 256*n+e+i/256-32768}class D_{get tree(){return this._tree||this._buildQuadTree(),this._tree}constructor(e,i,r,s=!1){if(this.uid=e,i.height!==i.width)throw new RangeError("DEM tiles must be square");if(r&&r!=="mapbox"&&r!=="terrarium")return void Ot(`"${r}" is not a valid encoding type. Valid types include "mapbox" and "terrarium".`);this.stride=i.height;let l=this.dim=i.height-2,u=new Uint32Array(i.data.buffer);if(this.pixels=new Uint8Array(i.data.buffer),this.floatView=new Float32Array(i.data.buffer),this.borderReady=s,this._modifiedForSources={},!s){for(let f=0;f<l;f++)u[this._idx(-1,f)]=u[this._idx(0,f)],u[this._idx(l,f)]=u[this._idx(l-1,f)],u[this._idx(f,-1)]=u[this._idx(f,0)],u[this._idx(f,l)]=u[this._idx(f,l-1)];u[this._idx(-1,-1)]=u[this._idx(0,0)],u[this._idx(l,-1)]=u[this._idx(l-1,0)],u[this._idx(-1,l)]=u[this._idx(0,l-1)],u[this._idx(l,l)]=u[this._idx(l-1,l-1)]}let p=r==="terrarium"?_T:mT;for(let f=0;f<u.length;++f){let g=4*f;this.floatView[f]=p(this.pixels[g],this.pixels[g+1],this.pixels[g+2])}this._timestamp=xn.now()}_buildQuadTree(){this._tree=new i1(this)}get(e,i,r=!1){r&&(e=ne(e,-1,this.dim),i=ne(i,-1,this.dim));let s=this._idx(e,i);return this.floatView[s]}set(e,i,r){let s=this._idx(e,i),l=this.floatView[s];return this.floatView[s]=r,r-l}static getUnpackVector(e){return fT[e]}_idx(e,i){if(e<-1||e>=this.dim+1||i<-1||i>=this.dim+1)throw new 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],s=D_.getUnpackVector(i),l=Math.floor((e+s[3])/s[2]);return r[2]=l%256,l=Math.floor(l/256),r[1]=l%256,l=Math.floor(l/256),r[0]=l,r}getPixels(){return new Ii({width:this.stride,height:this.stride},this.pixels)}backfillBorder(e,i,r){if(this.dim!==e.dim)throw new Error("dem dimension mismatch");let s=i*this.dim,l=i*this.dim+this.dim,u=r*this.dim,p=r*this.dim+this.dim;switch(i){case-1:s=l-1;break;case 1:l=s+1}switch(r){case-1:u=p-1;break;case 1:p=u+1}let f=-i*this.dim,g=-r*this.dim;for(let x=u;x<p;x++)for(let b=s;b<l;b++){let w=4*this._idx(b,x),S=4*this._idx(b+f,x+g);this.pixels[w+0]=e.pixels[S+0],this.pixels[w+1]=e.pixels[S+1],this.pixels[w+2]=e.pixels[S+2],this.pixels[w+3]=e.pixels[S+3]}}onDeserialize(){this._tree&&(this._tree.dem=this)}}function gT(n,e,i){n===1?e.headerLength=i.readFixed32():n===2?e.x=i.readVarint():n===3?e.y=i.readVarint():n===4?e.z=i.readVarint():n===5&&e.layers.push(function(r,s){return r.readFields(wT,{version:0,name:"",units:"",tileSize:0,buffer:0,pixelFormat:0,dataIndex:[]},s)}(i,i.readVarint()+i.pos))}function yT(n,e,i){n===1?(e.delta_filter=function(r,s){return r.readFields(xT,{blockSize:0},s)}(i,i.readVarint()+i.pos),e.filter="delta_filter"):n===2?(i.readVarint(),e.filter="zigzag_filter"):n===3?
7(i.readVarint(),e.filter="bitshuffle_filter"):n===4&&(i.readVarint(),e.filter="byteshuffle_filter")}function xT(n,e,i){n===1&&(e.blockSize=i.readVarint())}function vT(n,e,i){n===1?(i.readVarint(),e.codec="gzip_data"):n===2?(i.readVarint(),e.codec="jpeg_image"):n===3?(i.readVarint(),e.codec="webp_image"):n===4&&(i.readVarint(),e.codec="png_image")}function bT(n,e,i){let r=0,s=0;n===1?e.firstByte=i.readFixed64():n===2?e.lastByte=i.readFixed64():n===3?e.filters.push(function(l,u){return l.readFields(yT,{},u)}(i,i.readVarint()+i.pos)):n===4?e.codec=function(l,u){return l.readFields(vT,{},u)}(i,i.readVarint()+i.pos):n===5?s=i.readFloat():n===6?r=i.readFloat():n===7?e.bands.push(i.readString()):n===8?e.offset=i.readDouble():n===9&&(e.scale=i.readDouble()),e.offset===0&&(e.offset=s),e.scale===0&&(e.scale=r)}function wT(n,e,i){n===1?e.version=i.readVarint():n===2?e.name=i.readString():n===3?e.units=i.readString():n===4?e.tileSize=i.readVarint():n===5?e.buffer=i.readVarint():n===6?e.pixelFormat=i.readVarint():n===7&&e.dataIndex.push(function(r,s){return r.readFields(bT,{firstByte:0,lastByte:0,filters:[],codec:null,offset:0,scale:0,bands:[]},s)}(i,i.readVarint()+i.pos))}function TT(n,e,i){if(n===2)(function(r,s,l){r.readFields(ST,l,s)})(i,i.readVarint()+i.pos,e);else if(n===3)throw new Error("Not implemented")}function ST(n,e,i){if(n===1){let r=0,s=i.readVarint()+i.pos;for(;i.pos<s;)e[r++]=i.readVarint()}}function IT(n,e){if(e.length!==4)throw new Error(`Expected data of dimension 4 but got ${e.length}.`);let i=e[3];for(let r=2;r>=1;r--){let s=r===1?1:0,l=r===2?1:0;for(let u=0;u<e[0];u++){let p=e[1]*u;for(let f=s;f<e[1];f++){let g=e[2]*(f+p);for(let x=l;x<e[2];x++){let b=e[3]*(x+g);for(let w=0;w<e[3];w++){let S=b+w;n[S]+=n[S-i]}}}}i*=e[r]}return n}function ET(n){for(let e=0,i=n.length;e<i;e++)n[e]=n[e]>>>1^-(1&n[e]);return n}function AT(n,e){switch(e){case"uint32":return n;case"uint16":for(let i=0;i<n.length;i+=2){let r=n[i],s=n[i+1];n[i]=(240&r)>>4|(61440&r)>>8|(240&s)<<4|61440&s,n[i+1]=15&r|(3840&r)>>4|(15&s)<<8|(3840&s)<<4}return n;case"uint8":for(let i=0;i<n.length;i+=4){let r=n[i],s=n[i+1],l=n[i+2],u=n[i+3];n[i+0]=(192&r)>>6|(192&s)>>4|(192&l)>>2|192&u,n[i+1]=(48&r)>>4|(48&s)>>2|48&l|(48&u)<<2,n[i+2]=(12&r)>>2|12&s|(12&l)<<2|(12&u)<<4,n[i+3]=3&r|(3&s)<<2|(3&l)<<4|(3&u)<<6}return n;default:throw new Error(`Invalid pixel format, "${e}"`)}}Qe(D_,"DEMData"),Qe(i1,"DemMinMaxQuadTree",{omit:["dem"]});var Io=Uint8Array,jp=Uint16Array,MT=Int32Array,r1=new Io([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]),o1=new Io([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]),CT=new Io([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),s1=function(n,e){for(var i=new jp(31),r=0;r<31;++r)i[r]=e+=1<<n[r-1];var s=new MT(i[30]);for(r=1;r<30;++r)for(var l=i[r];l<i[r+1];++l)s[l]=l-i[r]<<5|r;return{b:i,r:s}},a1=s1(r1,2),l1=a1.b,PT=a1.r;l1[28]=258,PT[258]=28;for(var DT=s1(o1,0).b,c1=new jp(32768),mn=0;mn<32768;++mn){var Ph=(43690&mn)>>1|(21845&mn)<<1;c1[mn]=((65280&(Ph=(61680&(Ph=(52428&Ph)>>2|(13107&Ph)<<2))>>4|(3855&Ph)<<4))>>8|(255&Ph)<<8)>>1}var Gp=function(n,e,i){for(var r=n.length,s=0,l=new jp(e);s<r;++s)n[s]&&++l[n[s]-1];var u,p=new jp(e);for(s=1;s<e;++s)p[s]=p[s-1]+l[s-1]<<1;u=new jp(1<<e);var f=15-e;for(s=0;s<r;++s)if(n[s])for(var g=s<<4|n[s],x=e-n[s],b=p[n[s]-1]++<<x,w=b|(1<<x)-1;b<=w;++b)u[c1[b]>>f]=g;return u},$p=new Io(288);for(mn=0;mn<144;++mn)$p[mn]=8;for(mn=144;mn<256;++mn)$p[mn]=9;for(mn=256;mn<280;++mn)$p[mn]=7;for(mn=280;mn<288;++mn)$p[mn]=8;var u1=new Io(32);for(mn=0;mn<32;++mn)u1[mn]=5;var RT=Gp($p,9),zT=Gp(u1,5),zy=function(n){for(var e=n[0],i=1;i<n.length;++i)n[i]>e&&(e=n[i]);return e},hs=function(n,e,i){var r=e/8|0;return(n[r]|n[r+1]<<8)>>(7&e)&i},Ly=function(n,e){var i=e/8|0;return(n[i]|n[i+1]<<8|n[i+2]<<16)>>(7&e)},LT=function(n){return(n+7)/8|0}
7,OT=["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"],ds=function(n,e,i){var r=new Error(e||OT[n]);if(r.code=n,Error.captureStackTrace&&Error.captureStackTrace(r,ds),!i)throw r;return r},FT=new Io(0),BT=typeof TextDecoder<"u"&&new TextDecoder;try{BT.decode(FT,{stream:!0})}catch{}let kT={gzip_data:"gzip"};class No extends Error{constructor(e){super(e),this.name="MRTError"}}let NT={0:"uint32",1:"uint32",2:"uint16",3:"uint8"},h1={uint32:1,uint16:2,uint8:4},UT={uint32:Uint32Array,uint16:Uint16Array,uint8:Uint8Array},Oy;class R_{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 No(`Layer '${e}' not found`);return i}getHeaderLength(e){let i=new Uint8Array(e),r=new DataView(e);if(i[0]!==13)throw new No("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 No(`Expected header with length >= ${r} but got buffer of length ${i.length}`);let s=new Oy(i.subarray(0,r)).readFields(gT,{headerLength:0,x:0,y:0,z:0,layers:[]},void 0);if(!isNaN(this.x)&&(this.x!==s.x||this.y!==s.y||this.z!==s.z))throw new No(`Invalid attempt to parse header ${s.z}/${s.x}/${s.y} for tile ${this.z}/${this.x}/${this.y}`);this.x=s.x,this.y=s.y,this.z=s.z;for(let l of s.layers)this.layers[l.name]=new d1(l,{cacheSize:this._cacheSize});return this}createDecodingTask(e){let i=[],r=this.getLayer(e.layerName);for(let s of e.blockIndices){let l=r.dataIndex[s],u=l.firstByte-e.firstByte,p=l.lastByte-e.firstByte;if(r._blocksInProgress.has(s))continue;let f={layerName:r.name,firstByte:u,lastByte:p,pixelFormat:r.pixelFormat,blockIndex:s,blockShape:[l.bands.length].concat(r.bandShape),buffer:r.buffer,codec:l.codec.codec,filters:l.filters.map(g=>g.filter)};r._blocksInProgress.add(s),i.push(f)}return new p1(i,()=>{i.forEach(s=>r._blocksInProgress.delete(s.blockIndex))},(s,l)=>{if(i.forEach(u=>r._blocksInProgress.delete(u.blockIndex)),s)throw s;l.forEach(u=>{this.getLayer(u.layerName).processDecodedData(u)})})}}class d1{constructor({version:e,name:i,units:r,tileSize:s,pixelFormat:l,buffer:u,dataIndex:p},f){if(this.version=e,this.version!==1)throw new No(`Cannot parse raster layer encoded with MRT version ${e}`);this.name=i,this.units=r,this.tileSize=s,this.buffer=u,this.pixelFormat=NT[l],this.dataIndex=p,this.bandShape=[s+2*u,s+2*u,h1[this.pixelFormat]],this._decodedBlocks=new Dy(f?f.cacheSize:5),this._blocksInProgress=new Set}get dimension(){return h1[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,s]of this.dataIndex.entries()){for(let[l,u]of s.bands.entries())if(u===e)return{bandIndex:i+l,blockIndex:r,blockBandIndex:l};i+=s.bands.length}break;case"number":for(let[r,s]of this.dataIndex.entries()){if(e>=i&&e<i+s.bands.length)return{bandIndex:e,blockIndex:r,blockBandIndex:e-i};i+=s.bands.length}break;default:throw new No(`Invalid band \`${JSON.stringify(e)}\`. Expected string or integer.`)}return{blockIndex:-1,blockBandIndex:-1}}getDataRange(e){let i=1/0,r=-1/0,s=[],l=new Set;for(let u of e){let{blockIndex:p}=this.getBlockForBand(u);if(p<0)throw new No(`Invalid band: ${JSON.stringify(u)}`);let f=this.dataIndex[p];s.includes(p)||s.push(p),l.add(p),i=Math.min(i,f.firstByte),r=Math.max(r,f.lastByte)}if(l.size>this.cacheSize)throw new No(`Number of blocks to decode (${l.size}) exceeds cache size (${this.cacheSize}).`);return{layerName:this.name,firstByte:i,lastByte:r,blockIndices:s}}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 No(`Band not found: ${JSON.stringify(e)}`);let s=this._decodedBlocks.get(i.toString());if(!s)throw new No(`Data for band ${JSON.stringify(e)} of layer "${this.name}" not decoded.`);let l=this.dataIndex[i],u=this.bandShape.reduce((g,x)=>g*x,1),p=r*u,f=s.subarray(p,p+u);return{data:f,bytes:new Uint8Array(f.buffer).subarray(f.byteOffset,f.byteOffset+f.byteLength),tileSize:this.tileSize,buffer:this.buffer,pixelFormat:this.pixelFormat,dimension:this.dimension,offset:l.offset,scale:l.scale}}}R_.setPbf=function(n){Oy=n};class p1{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)}}R_.performDecoding=function(n,e){let i=new Uint8Array(n);return Promise.all(e.tasks.map(r=>
7{let{layerName:s,firstByte:l,lastByte:u,pixelFormat:p,blockShape:f,blockIndex:g,filters:x,codec:b}=r,w=i.subarray(l,u+1),S=new Uint32Array(f[0]*f[1]*f[2]),E;if(b!=="gzip_data")throw new No(`Unhandled codec: ${b}`);return E=function(M,C){if(!globalThis.DecompressionStream&&C==="gzip_data")return Promise.resolve(($=function(W){W[0]==31&&W[1]==139&&W[2]==8||ds(6,"invalid gzip data");var Q=W[3],Y=10;4&Q&&(Y+=2+(W[10]|W[11]<<8));for(var ee=(Q>>3&1)+(Q>>4&1);ee>0;ee-=!W[Y++]);return Y+(2&Q)}(R=M),$+8>R.length&&ds(6,"invalid gzip data"),function(W,Q,Y,ee){var me=W.length;if(!me||Q.f&&!Q.l)return Y||new Io(0);var ge=!Y,Te=ge||Q.i!=2,Ae=Q.i;ge&&(Y=new Io(3*me));var Ee=function(zi){var _n=Y.length;if(zi>_n){var Mr=new Io(Math.max(2*_n,zi));Mr.set(Y),Y=Mr}},Be=Q.f||0,xe=Q.p||0,Se=Q.b||0,Me=Q.l,ze=Q.d,Le=Q.m,We=Q.n,De=8*me;do{if(!Me){Be=hs(W,xe,1);var Ge=hs(W,xe+1,3);if(xe+=3,!Ge){var He=W[(Jt=LT(xe)+4)-4]|W[Jt-3]<<8,Je=Jt+He;if(Je>me){Ae&&ds(0);break}Te&&Ee(Se+He),Y.set(W.subarray(Jt,Je),Se),Q.b=Se+=He,Q.p=xe=8*Je,Q.f=Be;continue}if(Ge==1)Me=RT,ze=zT,Le=9,We=5;else if(Ge==2){var tt=hs(W,xe,31)+257,lt=hs(W,xe+10,15)+4,rt=tt+hs(W,xe+5,31)+1;xe+=14;for(var pt=new Io(rt),Ht=new Io(19),wt=0;wt<lt;++wt)Ht[CT[wt]]=hs(W,xe+3*wt,7);xe+=3*lt;var kt=zy(Ht),At=(1<<kt)-1,Ui=Gp(Ht,kt);for(wt=0;wt<rt;){var Jt,Gt=Ui[hs(W,xe,At)];if(xe+=15&Gt,(Jt=Gt>>4)<16)pt[wt++]=Jt;else{var ui=0,Mi=0;for(Jt==16?(Mi=3+hs(W,xe,3),xe+=2,ui=pt[wt-1]):Jt==17?(Mi=3+hs(W,xe,7),xe+=3):Jt==18&&(Mi=11+hs(W,xe,127),xe+=7);Mi--;)pt[wt++]=ui}}var Sn=pt.subarray(0,tt),mi=pt.subarray(tt);Le=zy(Sn),We=zy(mi),Me=Gp(Sn,Le),ze=Gp(mi,We)}else ds(1);if(xe>De){Ae&&ds(0);break}}Te&&Ee(Se+131072);for(var Vi=(1<<Le)-1,un=(1<<We)-1,en=xe;;en=xe){var hn=(ui=Me[Ly(W,xe)&Vi])>>4;if((xe+=15&ui)>De){Ae&&ds(0);break}if(ui||ds(2),hn<256)Y[Se++]=hn;else{if(hn==256){en=xe,Me=null;break}var Pt=hn-254;hn>264&&(Pt=hs(W,xe,(1<<(Ki=r1[wt=hn-257]))-1)+l1[wt],xe+=Ki);var Un=ze[Ly(W,xe)&un],lr=Un>>4;if(Un||ds(3),xe+=15&Un,mi=DT[lr],lr>3){var Ki=o1[lr];mi+=Ly(W,xe)&(1<<Ki)-1,xe+=Ki}if(xe>De){Ae&&ds(0);break}Te&&Ee(Se+131072);var Cn=Se+Pt;if(Se<mi){var Qn=0-mi,Vn=Math.min(mi,Cn);for(Qn+Se<0&&ds(3);Se<Vn;++Se)Y[Se]=ee[Qn+Se]}for(;Se<Cn;++Se)Y[Se]=Y[Se-mi]}}Q.l=Me,Q.p=en,Q.b=Se,Q.f=Be,Me&&(Be=1,Q.m=Le,Q.d=ze,Q.n=We)}while(!Be);return Se!=Y.length&&ge?function(zi,_n,Mr){return(Mr==null||Mr>zi.length)&&(Mr=zi.length),new Io(zi.subarray(0,Mr))}(Y,0,Se):Y.subarray(0,Se)}(R.subarray($,-8),{i:2},new Io(((z=R)[(j=z.length)-4]|z[j-3]<<8|z[j-2]<<16|z[j-1]<<24)>>>0),F)));var R,F,z,j,$;let H=kT[C];if(!H)throw new Error(`Unhandled codec: ${C}`);let ie=new globalThis.DecompressionStream(H);return new Response(new Blob([M]).stream().pipeThrough(ie)).arrayBuffer().then(W=>new Uint8Array(W))}(w,b).then(M=>(function(C,R){C.readFields(TT,R)}(new Oy(M),S),new UT[p](S.buffer))),E.then(M=>{for(let C=x.length-1;C>=0;C--)switch(x[C]){case"delta_filter":IT(M,f);break;case"zigzag_filter":ET(M);break;case"bitshuffle_filter":AT(M,p);break;default:throw new No(`Unhandled filter "${x[C]}"`)}return{layerName:s,blockIndex:g,data:M}}).catch(M=>{throw M})}))},Qe(p1,"MRTDecodingBatch",{omit:["_onCancel","_onComplete"]}),Qe(R_,"MapboxRasterTile"),Qe(d1,"MapboxRasterLayer",{omit:["_blocksInProgress"]});let f1=[Int8Array,Uint8Array,Uint8ClampedArray,Int16Array,Uint16Array,Int32Array,Uint32Array,Float32Array,Float64Array];class Fy{static from(e){if(!(e instanceof ArrayBuffer))throw new Error("Data must be an instance of ArrayBuffer.");let[i,r]=new Uint8Array(e,0,2);if(i!==219)throw new Error("Data does not appear to be in a KDBush format.");let s=r>>4;if(s!==1)throw new Error(`Got v${s} data when expected v1.`);let l=f1[15&r];if(!l)throw new Error("Unrecognized array type.");let[u]=new Uint16Array(e,2,1),[p]=new Uint32Array(e,4,1);return new Fy(p,u,l,e)}constructor(e,i=64,r=Float64Array,s){if(isNaN(e)||e<0)throw new 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 l=f1.indexOf(this.ArrayType),u=2*e*this.ArrayType.BYTES_PER_ELEMENT,p=e*this.IndexArrayType.BYTES_PER_ELEMENT,f=(8-p%8)%8;if(l<0)throw new Error(`Unexpected typed array class: ${r}.`);s&&s instanceof ArrayBuffer?(this.data=s,this.ids=new this.IndexArrayType(this.data,8,e),this.coords=new this.ArrayType(this.data,8+p+f,2*e),this._pos=2*e,this._finished=!0):(this.data=new ArrayBuffer(8+u+p+f),this.ids=new this.IndexArrayType(this.data,8,e),this.coords=new this.ArrayType(this.data,8+p+f,2*e),this._pos=0,this._finished=!1,new Uint8Array(this.data,0,2).set([219,16+l]),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 new Error(`Added ${e} items when expected ${this.numItems}.`);return By(this.ids,this.coords,this.nodeSize,0,this.numItems-1,0),this._finished=!0,this}
7range(e,i,r,s){if(!this._finished)throw new Error("Data not yet indexed - call index.finish().");let{ids:l,coords:u,nodeSize:p}=this,f=[0,l.length-1,0],g=[];for(;f.length;){let x=f.pop()||0,b=f.pop()||0,w=f.pop()||0;if(b-w<=p){for(let C=w;C<=b;C++){let R=u[2*C],F=u[2*C+1];R>=e&&R<=r&&F>=i&&F<=s&&g.push(l[C])}continue}let S=w+b>>1,E=u[2*S],M=u[2*S+1];E>=e&&E<=r&&M>=i&&M<=s&&g.push(l[S]),(x===0?e<=E:i<=M)&&(f.push(w),f.push(S-1),f.push(1-x)),(x===0?r>=E:s>=M)&&(f.push(S+1),f.push(b),f.push(1-x))}return g}within(e,i,r){if(!this._finished)throw new Error("Data not yet indexed - call index.finish().");let{ids:s,coords:l,nodeSize:u}=this,p=[0,s.length-1,0],f=[],g=r*r;for(;p.length;){let x=p.pop()||0,b=p.pop()||0,w=p.pop()||0;if(b-w<=u){for(let C=w;C<=b;C++)_1(l[2*C],l[2*C+1],e,i)<=g&&f.push(s[C]);continue}let S=w+b>>1,E=l[2*S],M=l[2*S+1];_1(E,M,e,i)<=g&&f.push(s[S]),(x===0?e-r<=E:i-r<=M)&&(p.push(w),p.push(S-1),p.push(1-x)),(x===0?e+r>=E:i+r>=M)&&(p.push(S+1),p.push(b),p.push(1-x))}return f}}function By(n,e,i,r,s,l){if(s-r<=i)return;let u=r+s>>1;m1(n,e,u,r,s,l),By(n,e,i,r,u-1,1-l),By(n,e,i,u+1,s,1-l)}function m1(n,e,i,r,s,l){for(;s>r;){if(s-r>600){let g=s-r+1,x=i-r+1,b=Math.log(g),w=.5*Math.exp(2*b/3),S=.5*Math.sqrt(b*w*(g-w)/g)*(x-g/2<0?-1:1);m1(n,e,i,Math.max(r,Math.floor(i-x*w/g+S)),Math.min(s,Math.floor(i+(g-x)*w/g+S)),l)}let u=e[2*i+l],p=r,f=s;for(Hp(n,e,r,i),e[2*s+l]>u&&Hp(n,e,r,s);p<f;){for(Hp(n,e,p,f),p++,f--;e[2*p+l]<u;)p++;for(;e[2*f+l]>u;)f--}e[2*r+l]===u?Hp(n,e,r,f):(f++,Hp(n,e,f,s)),f<=i&&(r=f+1),i<=f&&(s=f-1)}}function Hp(n,e,i,r){ky(n,i,r),ky(e,2*i,2*r),ky(e,2*i+1,2*r+1)}function ky(n,e,i){let r=n[e];n[e]=n[i],n[i]=r}function _1(n,e,i,r){let s=n-i,l=e-r;return s*s+l*l}U.$=Yh,U.A=xr,U.B=2,U.C=jt,U.D=Pp,U.E=ol,U.F=Hx,U.G=Xh,U.H=Vc,U.I=yr,U.J=Iu,U.K=xc,U.L=Dy,U.M=yd,U.N=qu,U.O=Rf,U.P=ke,U.Q=Zu,U.R=bs,U.S=jc,U.T=Xs,U.U=Pa,U.V=Da,U.W=tr,U.X=Ma,U.Y=fl,U.Z=ur,U._=Jh,U.a=function(n){return di.API_CDN_URL_REGEX.test(n)},U.a$=cu,U.a0=mc,U.a1=Gc,U.a2=/^(.*)-use-theme$/,U.a3=/^(.*)-transition$/,U.a4=xd,U.a5=Df,U.a6=he,U.a7=Jf,U.a8=wi,U.a9=qe,U.aA=function(n){let e=1/0,i=1/0,r=-1/0,s=-1/0;for(let l of n)e=Math.min(e,l.x),i=Math.min(i,l.y),r=Math.max(r,l.x),s=Math.max(s,l.y);return{min:new ke(e,i),max:new ke(r,s)}},U.aB=ne,U.aC=xi,U.aD=_r,U.aE=Jn,U.aF=L,U.aG=wo,U.aH=xm,U.aI=os,U.aJ=Fo,U.aK=Ke,U.aL=class{constructor(n){this.entries={},this.scheduler=n}request(n,e,i,r){let s=this.entries[n]=this.entries[n]||{callbacks:[]};if(s.result){let[l,u]=s.result;return this.scheduler?this.scheduler.add(()=>{r(l,u)},e):r(l,u),()=>{}}return s.callbacks.push(r),s.cancel||(s.cancel=i((l,u)=>{s.result=[l,u];for(let p of s.callbacks)this.scheduler?this.scheduler.add(()=>{p(l,u)},e):p(l,u);setTimeout(()=>delete this.entries[n],3e3)})),()=>{s.result||(s.callbacks=s.callbacks.filter(l=>l!==r),s.callbacks.length||(s.cancel(),delete this.entries[n]))}}},U.aM=function(n){if("provider"in n&&!n.provider)return null;let e=n.provider;if(!e&&"url"in n&&n.url&&(e=function(s){try{let l=new URL(s).pathname.split("/").pop()||"",u=l.lastIndexOf(".");return u>=0?l.slice(u+1):""}catch{return""}}(n.url)),!e)return null;let i=di.TILE_PROVIDER_URLS[e];if(!i)return null;let r;try{r=new URL(i,di.API_URL).href}catch{return new Error(`TileProvider "${e}" has an invalid URL: "${i}"`)}return{name:e,url:r}},U.aN=function(n,e,i,r,s){let l=function(p,f){if(p)return s(p);if(f){n.url&&f.tiles&&n.tiles&&delete n.tiles;let g=Xv(n,f,e);if(g instanceof Error)return s(g);s(null,g)}},u=function(p,f,g){if(!p)return null;if(!f&&!g)return p;g=g||p.worldview_default;let x=Object.values(p.language||{});if(x.length===0)return null;let b=Object.values(p.worldview||{});if(b.length===0)return null;let w=x.every(E=>E===f),S=b.every(E=>E===g);return w&&S?p:f in(p.language_options||{})||g in(p.worldview_options||{})?null:p.language_options&&p.worldview_options?p:null}(n.data,i,r);return u?xn.frame(()=>l(null,u)):n.url?sf(e.transformRequest(e.normalizeSourceURL(n.url,null,i,r),bs.Source),l):xn.frame(()=>{let{data:p,...f}=n;l(null,f)})},U.aO=function(n,e){let i=n.url&&!n.tiles?e.transformRequest(n.url,bs.Source):void 0;return{request:i,options:i?Object.assign({},n,{url:i.url}):n}},U.aP=function(n,e,i){return e?Xv(n,e,i):n.tiles&&n.tiles.length>0?{tiles:n.tiles}:new Error('TileJSON is missing required "tiles" property')},U.aQ=function(n,e,i){let r=JSON.stringify(n.request);
7return n.data&&(this.deduped.entries[r]={result:[null,n.data]}),this.deduped.request(r,{type:"parseTile",renderSourceType:n.renderSourceType,zoom:n.tileZoom},s=>{let l=nl(n.request,(u,p,f)=>{u?ws(u)?s(null,null):s(u):p&&s(null,{rawData:p,vectorTile:i?void 0:new cp(new c_(p)),responseHeaders:new Map(f.entries())})});return()=>{l.cancel(),s(null,null)}},e)},U.aR=function(n){return n?{cacheControl:n.get("cache-control"),expires:n.get("expires")}:{cacheControl:void 0,expires:void 0}},U.aS=function(n){Nh++,Nh>ef&&(n.getActor().send("enforceCacheSizeLimit",Qp),Nh=0)},U.aT=async function(n,e){let i=Yv.get(n);if(i)return i;let r=Ry.get(n);if(r!==void 0)return r;let s=import(e).catch(l=>{throw new Error(`TileProvider "${n}" failed to load: ${l instanceof Error?l.message:String(l)}`)}).then(l=>{let u=l.default;if(typeof u!="function")throw new Error(`TileProvider "${n}" module must default-export a class`);if(typeof u.prototype.loadTile!="function")throw new Error(`TileProvider "${n}" class must have a loadTile method`);return Yv.set(n,u),u}).finally(()=>{Ry.delete(n)});return Ry.set(n,s),s},U.aU=ue,U.aV=Ev,U.aW=Lv,U.aX=Yt,U.aY=Iv,U.aZ=function(n,e){let i=document.createElement("video");i.muted=!0,i.onloadstart=function(){e(null,i)};for(let r=0;r<n.length;r++){let s=document.createElement("source");af(n[r])||(i.crossOrigin="Anonymous"),s.src=n[r],i.appendChild(s)}return{cancel:()=>{}}},U.a_=Ip,U.aa=class{constructor(n){this.specification=n}possiblyEvaluate(n,e){return nn(n.expression.evaluate(e))}interpolate(n,e,i){return{x:ft(n.x,e.x,i),y:ft(n.y,e.y,i),z:ft(n.z,e.z,i),azimuthal:ft(n.azimuthal,e.azimuthal,i),polar:ft(n.polar,e.polar,i)}}},U.ab=Xt,U.ac=bl,U.ad=qn,U.ae=Oi,U.af=Dn,U.ag=ye,U.ah=es,U.ai=$t,U.aj=ft,U.ak=Xe,U.al=Zh,U.am=V,U.an=ht,U.ao=Oe,U.ap=class{constructor(n,e,i){this.target=n,this.parent=e,this.mapId=i,this.callbacks={},this.cancelCallbacks={},St(["receive"],this),this.target.addEventListener("message",this.receive,!1),this.scheduler=new pT}send(n,e,i,r,s=!1,l){let u=Math.round(1e18*Math.random()).toString(36).substring(0,10);i&&(i.metadata=l,this.callbacks[u]=i);let p=new Set;return this.target.postMessage({id:u,type:n,hasCallback:!!i,targetMapId:r,mustQueue:s,sourceMapId:this.mapId,data:Ls(e,p)},p),{cancel:()=>{i&&delete this.callbacks[u],this.target.postMessage({id:u,type:"<cancel>",targetMapId:r,sourceMapId:this.mapId})}}}receive(n){let e=n.data;if(!e)return;let i=e.id;if(i&&(!e.targetMapId||this.mapId===e.targetMapId))if(e.type==="<cancel>"){let r=this.cancelCallbacks[i];delete this.cancelCallbacks[i],r&&r.cancel()}else if(e.mustQueue||ii(self)){let r=this.callbacks[i],s=this.scheduler.add(()=>this.processTask(i,e),r&&r.metadata||{type:"message"});s&&(this.cancelCallbacks[i]=s)}else this.processTask(i,e)}processTask(n,e){if(delete this.cancelCallbacks[n],e.type==="<response>"){let i=this.callbacks[n];delete this.callbacks[n],i&&(e.error?i(Ko(e.error)):i(null,Ko(e.data)))}else{let i=new Set,r=e.hasCallback?(l,u)=>{this.target.postMessage({id:n,type:"<response>",sourceMapId:this.mapId,error:l?Ls(l):null,data:Ls(u,i)},i)}:()=>{},s=Ko(e.data);if(this.parent[e.type])this.parent[e.type](e.sourceMapId,s,r);else if(this.parent.getWorkerSource){let l=e.type.split("."),{source:u,scope:p}=s;this.parent.getWorkerSource(e.sourceMapId,{type:l[0],source:u,scope:p,uid:0})[l[1]](s,r)}else r(new Error(`Could not find function ${e.type}`))}}remove(){this.scheduler.remove(),this.target.removeEventListener("message",this.receive,!1)}},U.aq=class{constructor(n){this.specification=n}possiblyEvaluate(n,e){return function([i,r]){let s=nn([1,i,r]);return{x:s.x,y:s.y,z:s.z}}(n.expression.evaluate(e))}interpolate(n,e,i){return{x:ft(n.x,e.x,i),y:ft(n.y,e.y,i),z:ft(n.z,e.z,i)}}},U.ar=function(n,e,i=0,r=!0){let s=new ke(i,i),l=n.sub(s),u=e.add(s),p=[l,new ke(u.x,l.y),u,new ke(l.x,u.y)];return r&&p.push(l.clone()),p},U.as=function(n,e){let i=[];for(let r=0;r<n.length;r++){let s=Ne(r-1,-1,n.length-1),l=Ne(r+1,-1,n.length-1),u=n[r],p=n[l],f=n[s].sub(u).unit(),g=p.sub(u).unit(),x=g.angleWithSep(f.x,f.y),b=f.add(g).unit().mult(-1*e/Math.sin(x/2));i.push(u.add(b))}return i},U.at=uv,U.au=O,U.av=function(n,e,i=0){return Fn(((e.x-i)*n.scale-n.x)*Xe,(e.y*n.scale-n.y)*Xe,hh(e.z,e.y
7))},U.aw=Gi,U.ax=hi,U.ay=Jc,U.az=xx,U.b=function(n){return di.API_FONTS_REGEX.test(n)},U.b$=ch,U.b0=St,U.b1=R_,U.b2=c_,U.b3=class{constructor(n,e,i,r,s,l){this.tileID=n,this.uid=ht(),this.uses=0,this.tileSize=e,this.tileZoom=i,this.buckets={},this.expirationTime=null,this.queryPadding=0,this.hasSymbolBuckets=!1,this.hasTunnelGeometry=!1,this.hasRTLText=!1,this.dependencies={},this.isRaster=s,r&&r.style&&(this._lastUpdatedBrightness=r.style.getBrightness()),this._lastAvailableImagesCount=0,this._firstPrepareComplete=!1,this.expiredRequestCount=0,this.state="loading",r&&r.transform&&(this.projection=r.transform.projection),this.worldview=l,this._hasAppearances=null}registerFadeDuration(n){let e=n+this.timeAdded;e<xn.now()||this.fadeEndTime!==void 0&&e<this.fadeEndTime||(this.fadeEndTime=e)}wasRequested(){return this.state==="errored"||this.state==="loaded"||this.state==="reloading"}get tileTransform(){return this._tileTransform||(this._tileTransform=su(this.tileID.canonical,this.projection)),this._tileTransform}loadVectorData(n,e,i){if(this.unloadVectorData(),this.state="loaded",n){n.featureIndex&&(this.latestFeatureIndex=n.featureIndex,n.rawTileData?(this.latestRawTileData=n.rawTileData,this.latestFeatureIndex.rawTileData=n.rawTileData):this.latestRawTileData&&(this.latestFeatureIndex.rawTileData=this.latestRawTileData)),this.collisionBoxArray=n.collisionBoxArray,this.buckets=Hv(n.buckets,e.style),this.hasSymbolBuckets=!1,this.hasTunnelGeometry=!!n.hasTunnelGeometry;for(let r in this.buckets){let s=this.buckets[r];if(s instanceof Bo){if(this.hasSymbolBuckets=!0,!i)break;s.justReloaded=!0}}if(this.hasRTLText=!1,this.hasSymbolBuckets)for(let r in this.buckets){let s=this.buckets[r];if(s instanceof Bo&&s.hasRTLText){this.hasRTLText=!0,Fd();break}}this.queryPadding=0;for(let r in this.buckets){let s=this.buckets[r],l=e.style.getOwnLayer(r);if(!l)continue;let u=l.queryRadius(s)||0;this.queryPadding=Math.max(this.queryPadding,u)}n.imageAtlas&&(this.imageAtlas=e.style.imageManager.imageAtlasCache.getOrCache(n.imageAtlas)),n.glyphAtlasImage&&(this.glyphAtlasImage=n.glyphAtlasImage),n.lineAtlas&&(this.lineAtlas=n.lineAtlas),this._lastUpdatedBrightness=n.brightness}else this.collisionBoxArray=new qc}unloadVectorData(){if(this.hasData()){for(let n in this.buckets)this.buckets[n].destroy();this.buckets={},this.imageAtlas&&(this.imageAtlas=null),this.lineAtlas&&(this.lineAtlas=null),this.imageAtlasTexture&&(this.imageAtlasTexture=null),this.glyphAtlasTexture&&this.glyphAtlasTexture.destroy(),this.lineAtlasTexture&&this.lineAtlasTexture.destroy(),this._tileBoundsBuffer&&(this._tileBoundsBuffer.destroy(),this._tileBoundsIndexBuffer.destroy(),this._tileBoundsSegments.destroy(),this._tileBoundsBuffer=null),this._tileDebugBuffer&&(this._tileDebugBuffer.destroy(),this._tileDebugSegments.destroy(),this._tileDebugBuffer=null),this._tileDebugIndexBuffer&&(this._tileDebugIndexBuffer.destroy(),this._tileDebugIndexBuffer=null),this._globeTileDebugBorderBuffer&&(this._globeTileDebugBorderBuffer.destroy(),this._globeTileDebugBorderBuffer=null),this._tileDebugTextBuffer&&(this._tileDebugTextBuffer.destroy(),this._tileDebugTextSegments.destroy(),this._tileDebugTextIndexBuffer.destroy(),this._tileDebugTextBuffer=null),this._globeTileDebugTextBuffer&&(this._globeTileDebugTextBuffer.destroy(),this._globeTileDebugTextBuffer=null),this.latestFeatureIndex=null,this.state="unloaded"}}loadModelData(n,e,i){n&&(n.resourceTiming&&(this.resourceTiming=n.resourceTiming),this.buckets=Object.assign({},this.buckets,Hv(n.buckets,e.style)),n.featureIndex&&(this.latestFeatureIndex=n.featureIndex))}getBucket(n){return this.buckets[n.fqid]}upload(n,e){for(let s in this.buckets){let l=this.buckets[s];if(l.uploadPending()){let u={},p=[],f={zoom:0,pitch:0,brightness:0,worldview:""};if(e){if(e.style){p=e.style.listImages();let g=l.layers[0],x=g.sourceLayer||"_geojsonTileLayer",b=e.style.getLayerSourceCache(g);b&&(u=b._state.getState(x,void 0))}f={zoom:e.transform.zoom||0,pitch:e.transform.pitch||0,brightness:e.style.getBrightness()||0,worldview:e.worldview||""}}l.upload(n,this.tileID.canonical,u,p,f)}}let i=n.gl,r=this.imageAtlas;!r||this.imageAtlasTexture&&r.uploaded||(this.imageAtlasTexture=null,this.imageAtlasTexture=e.style.imageManager.imageAtlasCache.getTextureForAtlas(r,n,i.RGBA8),r.uploaded=!0),this.glyphAtlasImage&&(this.glyphAtlasTexture=new Xs(n,this.glyphAtlasImage,i.R8),this.glyphAtlasImage=null),this.lineAtlas&&!this.lineAtlas.uploaded&&(this.lineAtlasTexture=new Xs(n,this.lineAtlas.image,i.R8),this.lineAtlas.uploaded=!0)}prepare(n,e,i){if(this.imageAtlas&&this.imageAtlasTexture&&e){let b=e.style.getLut(i);this.imageAtlas.patchUpdatedImages(n,this.imageAtlasTexture,i,b)}if(!e||!this.latestFeatureIndex||!this.latestFeatureIndex.rawTileData)return;let r=e.style.getBrightness(),s=e.style.listImages(),l=s.length,u=e.style._changes.getUpd
7atedPaintProperties(),p=Object.keys(this.buckets).some(b=>this.buckets[b].layers.some(w=>u.has(w.fqid))),f=Object.keys(this.buckets).some(b=>this.buckets[b].layers.some(w=>w.hasTransition&&w.hasTransition())),g=this._firstPrepareComplete&&l!==this._lastAvailableImagesCount;this._hasAppearances===null&&(this._hasAppearances=this.hasAppearances(e));let x=this._lastUpdatedBrightness!==r;this._lastAvailableImagesCount=l,this._firstPrepareComplete=!0,(this._lastUpdatedBrightness||r||this._hasAppearances||p||f||g)&&(!(this._hasAppearances||p||f||g)&&this._lastUpdatedBrightness&&r&&Math.abs(this._lastUpdatedBrightness-r)<.001||(this.updateBuckets(e,x,void 0,g||p||f,u,s),this._lastUpdatedBrightness=r))}evaluateQueryRenderedFeaturePadding(){let n=0;for(let e in this.buckets){let i=this.buckets[e];i.evaluateQueryRenderedFeaturePadding&&(n=Math.max(n,i.evaluateQueryRenderedFeaturePadding()))}return n}queryRenderedFeatures(n,e,i,r,s,l,u){if(!this.latestFeatureIndex||!this.latestFeatureIndex.rawTileData&&!this.latestFeatureIndex.is3DTile)return{};let p=this.evaluateQueryRenderedFeaturePadding(),f=function(g,x){let b=Go([],[.5*g.width,.5*-g.height,1]);return Gn(b,b,[1,-1,0]),xi(b,b,g.calculateProjMatrix(x.toUnwrapped())),Float32Array.from(b)}(s,this.tileID);return this.latestFeatureIndex.query(n,{tilespaceGeometry:e,pixelPosMatrix:f,transform:r,availableImages:i,tileTransform:this.tileTransform,worldview:this.worldview,queryRadius:p,scope:u})}querySourceFeatures(n,e){let i=this.latestFeatureIndex;if(!i||!i.rawTileData)return;let r=i.loadVTLayers(),s=e?e.sourceLayer:"",l=r._geojsonTileLayer||r[s];if(!l)return;let u=io(e&&e.filter),{z:p,x:f,y:g}=this.tileID.canonical,x={z:p,x:f,y:g};for(let b=0;b<l.length;b++){let w=l.feature(b);if(u.needGeometry){let M=Gr(w,!0);if(!u.filter(new Xt(this.tileID.overscaledZ,{worldview:this.worldview}),M,this.tileID.canonical))continue}else if(!u.filter(new Xt(this.tileID.overscaledZ,{worldview:this.worldview}
7),w))continue;let S=i.getId(w,s),E=new lu(w,p,f,g,S);E.tile=x,n.push(E)}}loaded(){return this.state==="loaded"||this.state==="errored"}hasData(){return this.state==="loaded"||this.state==="reloading"||this.state==="expired"}patternsLoaded(){return!!this.imageAtlas&&!!this.imageAtlas.patternPositions.size}setExpiryData(n){let e=this.expirationTime;if(n.cacheControl){let i=Ai(n.cacheControl);i["max-age"]&&(this.expirationTime=Date.now()+1e3*i["max-age"])}else n.expires&&(this.expirationTime=new Date(n.expires).getTime());if(this.expirationTime){let i=Date.now(),r=!1;if(this.expirationTime>i)r=!1;else if(e)if(this.expirationTime<e)r=!0;else{let s=this.expirationTime-e;s?this.expirationTime=i+Math.max(s,3e4):r=!0}else r=!0;r?(this.expiredRequestCount++,this.state="expired"):this.expiredRequestCount=0}}getExpiryTimeout(){if(this.expirationTime)return this.expiredRequestCount?1e3*(1<<Math.min(this.expiredRequestCount-1,31)):Math.min(this.expirationTime-Date.now(),Math.pow(2,31)-1)}refreshFeatureState(n,e){if(!this.latestFeatureIndex||!this.latestFeatureIndex.rawTileData&&!this.latestFeatureIndex.is3DTile||!n)return;let i=n.style.listImages();this.updateBuckets(n,!1,e,void 0,void 0,i)}hasAppearances(n){for(let e in this.buckets)if(n.style.hasLayer(e)&&this.buckets[e].layers.some(i=>i.appearances&&i.appearances.length>0))return!0;return!1}updateBuckets(n,e,i,r,s,l){if(!this.latestFeatureIndex||!n.style)return;let u=l||n.style.listImages(),p=n.style.getBrightness(),f=s||new Set;for(let g in this.buckets){if(!n.style.hasLayer(g))continue;let x=this.buckets[g],b=x.layers[0],w=b.sourceLayer||"_geojsonTileLayer",S=n.style.getLayerSourceCache(b),E=x.layers.some($=>f.has($.fqid)),M=(r||E)&&x instanceof Bo?n.style.getOwnLayer(g):void 0,C=i&&i[w]||{};S&&!i&&(C=S._state.getState(w,void 0));let R=this.imageAtlas?Object.fromEntries(this.imageAtlas.patternPositions):{},F=Object.keys(C).length>0&&!e;x.hasAppearances=x.layers.some($=>$.appearances&&$.appearances.length>0);let z=F?x.stateDependentLayers:x.layers;if(F&&x.stateDependentLayers.length!==0||e||E||r){let $=this.latestFeatureIndex.loadVTLayers()[w];if(x.update(C,$,u,R,z,e,p,this.tileID.canonical),(r||E)&&(!e||e&&x instanceof Bo&&(!x.text.uboBinder||x.text.uboBinder.isLightConstant||!x.icon.uboBinder||x.icon.uboBinder.isLightConstant))&&x instanceof Bo&&M&&M.type==="symbol"){let H=x;H.text&&H.text.uboBinder&&H.text.uboBinder.updateDynamicExpressions(M,$,this.tileID.canonical,u,C,p),H.icon&&H.icon.uboBinder&&H.icon.uboBinder.updateDynamicExpressions(M,$,this.tileID.canonical,u,C,p)}if(x instanceof Bo){let H=x,ie=n.context;H.text&&H.text.uboBinder&&H.text.uboBinder.upload(ie),H.icon&&H.icon.uboBinder&&H.icon.uboBinder.upload(ie)}}if(F&&x.stateDependentLayers.length!==0||e||x.hasAppearances){let $={zoom:n.transform.zoom,pitch:n.transform.pitch,brightness:n.style.getBrightness()||0,worldview:n.worldview},H=x.updateAppearances(this.tileID.canonical,C,u,$,n.imageManager,F&&x.stateDependentLayers.length!==0);if(H&&H.hasUboChanges){let ie=n.context;x instanceof Bo&&x.text&&x.text.uboBinder&&x.text.uboBinder.upload(ie),x instanceof Bo&&x.icon&&x.icon.uboBinder&&x.icon.uboBinder.upload(ie)}}(x instanceof l_||x instanceof Nm)&&n._terrain&&n._terrain.enabled&&S&&x.uploadPending()&&n._terrain._clearRenderCacheForTile(S.id,this.tileID);let j=n&&n.style&&n.style.getOwnLayer(g);j&&(this.queryPadding=Math.max(this.queryPadding,j.queryRadius(x)||0))}}holdingForFade(){return this.symbolFadeHoldUntil!==void 0}symbolFadeFinished(){return!this.symbolFadeHoldUntil||this.symbolFadeHoldUntil<xn.now()}clearFadeHold(){this.symbolFadeHoldUntil=void 0}setHoldDuration(n){this.symbolFadeHoldUntil=xn.now()+n}setTexture(n,e){let i=e.context,r=i.gl;this.texture=this.texture||e.getTileTexture(n.width),this.texture&&this.texture instanceof Xs?this.texture.update(n):(this.texture=new Xs(i,n,r.RGBA8,{useMipmap:!0}),this.texture.bind(r.LINEAR,r.CLAMP_TO_EDGE))}setDependencies(n,e){let i={};for(let r of e)i[r]=!0;this.dependencies[n]=i}hasDependency(n,e){for(let i of n){let r=this.dependencies[i];if(r){for(let s of e)if(r[s])return!0}}return!1}clearQueryDebugViz(){}_makeDebugTileBoundsBuffers(n,e){if(!e||e.name==="mercator"||this._tileDebugBuffer)return;let i=jr(Wv,this.tileID.canonical,this.tileTransform)[0],r=new Hn,s=new Cl;for(let l=0;l<i.length;l++){let{x:u,y:p}=i[l];r.emplaceBack(u,p),s.emplaceBack(l)}s.emplaceBack(0),this._tileDebugIndexBuffer=n.createIndexBuffer(s),this._tileDebugBuffer=n.createVertexBuffer(r,Ie.members),this._tileDebugSegments=pi.simpleSegment(0,0,r.length,s.length)}_makeTileBoundsBuffers(n,e){if(this._tileBoundsBuffer||!e||e.name==="mercator")return;let i=jr(Wv,this.tileID.canonical,this.tileTransform)[0],r,s;if(this.isRaster){let l=function(u,p){let f=su(u,p),g=Math.pow(2,u.z);for(let M=0;M<Ys;M++)for(let C=0;C<Ys;C++){let R=Ir((u.x+(C+qv(C))/ko)/g),F=Ln((u.y+(M+qv(M))/ko)/g),z=p.project(R,F),j=M*Ys+C;Js[2*j+0]=Math.round((z.x*f.scale-f.x)*Xe),Js[2*j+1]=Math.round((z.y*f.scale-f.y)*Xe)}Zl.fill(0),P_.fill(0);for(let M=2045;M>=0;M--){let C=4*M,R=ql[C+0],F=ql[C+1],z=ql[C+2],j=ql[C+3],$=R+z>>
71,H=F+j>>1,ie=$+H-F,W=H+R-$,Q=F*Ys+R,Y=j*Ys+z,ee=H*Ys+$,me=Math.hypot((Js[2*Q+0]+Js[2*Y+0])/2-Js[2*ee+0],(Js[2*Q+1]+Js[2*Y+1])/2-Js[2*ee+1])>=16;Zl[ee]=Zl[ee]||(me?1:0),M<1022&&(Zl[ee]=Zl[ee]||Zl[(F+W>>1)*Ys+(R+ie>>1)]||Zl[(j+W>>1)*Ys+(z+ie>>1)])}let x=new Ba,b=new Xi,w=0;function S(M,C){let R=C*Ys+M;return P_[R]===0&&(x.emplaceBack(Js[2*R+0],Js[2*R+1],M*Xe/ko,C*Xe/ko),P_[R]=++w),P_[R]-1}function E(M,C,R,F,z,j){let $=M+R>>1,H=C+F>>1;if(Math.abs(M-z)+Math.abs(C-j)>1&&Zl[H*Ys+$])E(z,j,M,C,$,H),E(R,F,z,j,$,H);else{let ie=S(M,C),W=S(R,F),Q=S(z,j);b.emplaceBack(ie,W,Q)}}return E(0,0,ko,ko,ko,0),E(ko,ko,0,0,0,ko),{vertices:x,indices:b}}(this.tileID.canonical,e);r=l.vertices,s=l.indices}else{r=new Ba,s=new Xi;for(let{x:u,y:p}of i)r.emplaceBack(u,p,0,0);let l=wn(r.int16.subarray(0,4*r.length),void 0,4);for(let u=0;u<l.length;u+=3)s.emplaceBack(l[u],l[u+1],l[u+2])}this._tileBoundsBuffer=n.createVertexBuffer(r,S_.members),this._tileBoundsIndexBuffer=n.createIndexBuffer(s),this._tileBoundsSegments=pi.simpleSegment(0,0,r.length,s.length)}_makeGlobeTileDebugBuffers(n,e){let i=e.projection;if(!i||i.name!=="globe"||e.freezeTileCoverage)return;let r=this.tileID.canonical,s=Tt(Ue(r,e)),l=$t(e.zoom),u;l>0&&(u=mr(new Float64Array(16),e.globeMatrix)),this._makeGlobeTileDebugBorderBuffer(n,r,e,s,u,l),this._makeGlobeTileDebugTextBuffer(n,r,e,s,u,l)}_globePoint(n,e,i,r,s,l,u){let p=ut(n,e,i);if(l){let f=1<<i.z,g=wo(r.center.lng),x=Fo(r.center.lat),b=(i.x+.5)/f-g,w=0;b>.5?w=-1:b<-.5&&(w=1);let S=(n/Xe+i.x)/f+w,E=(e/Xe+i.y)/f;S=(S-g)*r._pixelsPerMercatorPixel+g,E=(E-x)*r._pixelsPerMercatorPixel+x;let M=[S*r.worldSize,E*r.worldSize,0];Oi(M,M,l),p=je(p,M,u)}return Oi(p,p,s)}_makeGlobeTileDebugBorderBuffer(n,e,i,r,s,l){let u=new Hn,p=new Cl,f=new Ns,g=(b,w,S,E,M)=>{let C=(S-b)/(M-1),R=(E-w)/(M-1),F=u.length;for(let z=0;z<M;z++){let j=b+z*C,$=w+z*R;u.emplaceBack(j,$);let H=this._globePoint(j,$,e,i,r,s,l);f.emplaceBack(H[0],H[1],H[2]),p.emplaceBack(F+z)}},x=Xe;g(0,0,x,0,16),g(x,0,x,x,16),g(x,x,0,x,16),g(0,x,0,0,16),this._tileDebugIndexBuffer=n.createIndexBuffer(p),this._tileDebugBuffer=n.createVertexBuffer(u,Ie.members),this._globeTileDebugBorderBuffer=n.createVertexBuffer(f,pe.members),this._tileDebugSegments=pi.simpleSegment(0,0,u.length,p.length)}_makeGlobeTileDebugTextBuffer(n,e,i,r,s,l){let u=new Hn,p=new Xi,f=new Ns,g=25;p.reserve(32),u.reserve(g),f.reserve(g);let x=(b,w)=>g*b+w;for(let b=0;b<g;b++){let w=2048*b;for(let S=0;S<g;S++){let E=2048*S;u.emplaceBack(E,w);let M=this._globePoint(E,w,e,i,r,s,l);f.emplaceBack(M[0],M[1],M[2])}}for(let b=0;b<4;b++)for(let w=0;w<4;w++){let S=x(b,w),E=x(b,w+1),M=x(b+1,w),C=x(b+1,w+1);p.emplaceBack(S,E,M),p.emplaceBack(M,E,C)}this._tileDebugTextIndexBuffer=n.createIndexBuffer(p),this._tileDebugTextBuffer=n.createVertexBuffer(u,Ie.members),this._globeTileDebugTextBuffer=n.createVertexBuffer(f,pe.members),this._tileDebugTextSegments=pi.simpleSegment(0,0,g,32)}destroy(n=!0){for(let e in this.buckets)this.buckets[e].destroy(n);this.buckets={},this.imageAtlas&&(this.imageAtlas=null),this.lineAtlas&&(this.lineAtlas=null),this.imageAtlasTexture&&delete this.imageAtlasTexture,this.glyphAtlasTexture&&(this.glyphAtlasTexture.destroy(),delete this.glyphAtlasTexture),this.lineAtlasTexture&&(this.lineAtlasTexture.destroy(),delete this.lineAtlasTexture),this._tileBoundsBuffer&&(this._tileBoundsBuffer.destroy(),this._tileBoundsIndexBuffer.destroy(),this._tileBoundsSegments.destroy(),this._tileBoundsBuffer=null),this._tileDebugBuffer&&(this._tileDebugBuffer.destroy(),this._tileDebugSegments.destroy(),this._tileDebugBuffer=null),this._tileDebugIndexBuffer&&(this._tileDebugIndexBuffer.destroy(),this._tileDebugIndexBuffer=null),this._globeTileDebugBorderBuffer&&(this._globeTileDebugBorderBuffer.destroy(),this._globeTileDebugBorderBuffer=null),this._tileDebugTextBuffer&&(this._tileDebugTextBuffer.destroy(),this._tileDebugTextSegments.destroy(),this._tileDebugTextIndexBuffer.destroy(),this._tileDebugTextBuffer=null),this._globeTileDebugTextBuffer&&(this._globeTileDebugTextBuffer.destroy(),this._globeTileDebugTextBuffer=null),n&&this.texture&&this.texture instanceof Xs&&(this.texture.destroy(),delete this.texture),this.emissiveTexture&&this.emissiveTexture instanceof Xs&&(this.emissiveTexture.destroy(),delete this.emissiveTexture),this.hillshadeFBO&&(this.hillshadeFBO.destroy(),delete this.hillshadeFBO),this.dem&&delete this.dem,this.neighboringTiles&&delete this.neighboringTiles,this.demTexture&&(this.demTexture.destroy(),delete this.demTexture),this.rasterParticleState&&(this.rasterParticleState.destroy(),delete this.rasterParticleState),this.latestFeatureIndex=null,this.state="unloaded"}},U.b4=nl,U.b5=ws,U.b6=function(n,e){let i=[];for(let r in n)r in e||i.push(r);return i},U.b7=Zv,U.b8=["type","source","source-layer","minzoom","maxzoom","filter","layout"],U.b9=Zo,U.bA=Rt,U.bB=Gn,U.bC=Tn,U.bD=d0,U.bE=Gm,U.bF=_0,U.bG=g0,U.bH=Gr,U.bI=Ya,U.bJ=sy,U.bK=tv,U.bL=yy,U.bM=Fy,U.bN=Li,U.bO=ra,U.bP=ys,U.bQ=function(n,e,i){i*=.5;var r=e[0],s=e[1],l=e[2],u=e[3],p=Math.sin(i),f=Math.cos(i);return n[0]=r*f+s*p,n[1]=s*f-r*p,n[2]=l*f+u*p,n[3]=u*f-l*p,n},U.bR=Ja,U.bS=Wi,U.bT=Go,U.bU=function(n,e){return n[0]=-e[0],n[1]=-e[1],n[2]=-e[2],n[3]=e[3],n},U.bV=ec,U.bW=function(n,e,i,r,s){var l=1/Math.tan(e/2);if(n[0]=l/i,n[1]=0,n[2]=0,n[3]=0,n[4]=0,n[5]=l,n[6]=0,n[7]=0,n[8]=0,n[9]=0,n[11]=-1,n[12]=0,n[13]=0,n[15]=0,s!=null&&s!==1/0){var u=1/(r-s);n[10]=(s+r)*u,n[14]=2*s*r*u}else n[10]=-1,n[14]=-2*r;return n},U.bX=function(n,e,i,r,s,l,u){var p=1/(e-i),f=1/(r-s),g=1/(l-u);return n[0]=-2*p,n[1]=0,n[2]=0,n[3]=0,n[4]=0,n[5]=-2*f,n[6]=0,n[7]=0,n[8]=0,n[9]=0,n[10]=2*g,n[11]=0,n[12]=(e+i)*p,n[13]=(s+r)*f,n[14]=(u+l)*g,n[15]=1,n},U.bY=or,U.bZ=Ln,U.b_=function(n,e,i){n[4*e+0]=i[0],n[4*e+1]=i[1],n[4*e+2]=i[2],n[4*e+3]=i[3]},U.ba=mr,U.bb=Kl,U.bc=ho,U.bd=fs,U.be=function(n,e){let{x:i,y:r}=n.point,s=Nt(i,r,n.worldSize/n._pixelsPerMercatorPixel,0,0);return xi(s,s,yt($e(e)))},U.bf=Cr,U.bg=Wa,U.bh=ia,U.bi=Dr,U.bj=Wn,U.bk=Qi,U.bl=Sh,U.bm=Zr,U.bn=cy,U.bo=function(n,e,i,r,s){let l=5*e+2;n.float32[l+0]=i,n.float32[l+1]=r,n.float32[l+2]=s},U.bp=Ah,U.bq=Ra,U.br=mo,U.bs=la,U.bt=aa,U.bu=Ka,U.bv=Ne,U.bw=function(n,e,i,r){var s=new gi(4);return s[0]=n,s[1]=e,s[2]=i,s[3]=r,s},U.bx=class{isDataAvailableAtPoint(n){let e=this._source();if(this.isUsingMockSource()||!e||n.y<0||n.y>1)return!1;let i=e.getSource().maxzoom,r=1<<i,s=Math.floor(n.x),l=Math.floor((n.x-s)*r),u=Math.floor(n.y*r),p=this.findDEMTileFor(new ue(i,s,i,l,u));return!(!p||!p.dem)}getAtPointOrZero(n,e=0){return this.getAtPoint(n,e)||0}getAtPoint(n,e,i=!0){if(this.isUsingMockSource())return null;e==null&&(e=null);let r=this._source();if(!r||n.y<0||n.y>1)return e;let s=r.getSource().maxzoom,l=1<<s,u=Math.floor(n.x),p=n.x-u,f=new ue(s,u,s,Math.floor(p*l),Math.floor(n.y*l)),g=this.findDEMTileFor(f);if(!g||!g.dem)return e;let x=g.dem,b=1<<g.tileID.canonical.z,w=(p*b-g.tileID.canonical.x)*x.dim,S=(n.y*b-g.tileID.canonical.y)*x.dim,E=Math.floor(w),M=Math.floor(S);return(i?this.exaggeration():1)*ft(ft(x.get(E,M),x.get(E,M+1),S-M),ft(x.get(E+1,M),x.get(E+1,M+1),S-M),w-E)}static getAtTileOffset(n,e,i,r){let s=1<<n.canonical.z;return r?r.pointElevation(e):i?i.getAtPointOrZero(new qn(n.wrap+(n.canonical.x+e.x/Xe)/s,(n.canonical.y+e.
7y/Xe)/s)):0}static getAtTileOffsetFunc(n,e,i,r){return(s,l,u)=>{let p=this.getAtTileOffset(n,s,l,u),f=r.upVector(n.canonical,s.x,s.y);return Li(f,f,p*r.upVectorScale(n.canonical,e,i).metersToTile),f}}getForTilePoints(n,e,i,r){if(this.isUsingMockSource())return!1;let s=Ch.create(this,n,r);return!!s&&(e.forEach(l=>{l[2]=this.exaggeration()*s.getElevationAt(l[0],l[1],i,!0)}),!0)}getMinMaxForTile(n){if(this.isUsingMockSource())return null;let e=this.findDEMTileFor(n);if(!e||!e.dem)return null;let i=e.dem.tree,r=e.tileID,s=1<<n.canonical.z-r.canonical.z,l=n.canonical.x/s-r.canonical.x,u=n.canonical.y/s-r.canonical.y,p=0;for(let f=0;f<n.canonical.z-r.canonical.z&&!i.leaves[p];f++){l*=2,u*=2;let g=2*Math.floor(u)+Math.floor(l);p=i.childOffsets[p]+g,l%=1,u%=1}return{min:this.exaggeration()*i.minimums[p],max:this.exaggeration()*i.maximums[p]}}getMinElevationBelowMSL(){throw new Error("Pure virtual method called.")}raycast(n,e,i){throw new Error("Pure virtual method called.")}pointCoordinate(n){throw new Error("Pure virtual method called.")}_source(){throw new Error("Pure virtual method called.")}isUsingMockSource(){throw new Error("Pure virtual method called.")}exaggeration(){throw new Error("Pure virtual method called.")}findDEMTileFor(n){throw new Error("Pure virtual method called.")}get visibleDemTiles(){throw new Error("Getter must be implemented in subclass.")}getMinMaxForVisibleTiles(){let n=this.visibleDemTiles;if(n.length===0)return null;let e=!1,i=Number.MAX_VALUE,r=Number.MIN_VALUE;for(let s of n){let l=this.getMinMaxForTile(s.tileID);l&&(i=Math.min(i,l.min),r=Math.max(r,l.max),e=!0)}return e?{min:i,max:r}:null}},U.by=Jm,U.bz=c,U.c=tl,U.c$=K0,U.c0=Wc,U.c1=an,U.c2=dr,U.c3=Xc,U.c4=mv,U.c5=function(n,e){return n[0]===e[0]&&n[1]===e[1]&&n[2]===e[2]&&n[3]===e[3]},U.c6=Mo,U.c7=function(n){var e=n[0],i=n[1],r=n[2],s=n[3];return Math.sqrt(e*e+i*i+r*r+s*s)},U.c8=uu,U.c9=Za,U.cA=i_,U.cB=tc,U.cC=Q0,U.cD=function(n){let e=Q0(n,!0);return Cr([],[e[0],e[1],e[4],e[5]])},U.cE=Zn,U.cF=up,U.cG=Vo,U.cH=function(n,e){return n[0]=e[0],n[1]=e[1],n[2]=e[2],n[3]=e[3],n[4]=e[4],n[5]=e[5],n[6]=e[6],n[7]=e[7],n[8]=e[8],n[9]=e[9],n[10]=e[10],n[11]=e[11],n[12]=e[12],n[13]=e[13],n[14]=e[14],n[15]=e[15],n},U.cI=function(n){let{x:e,y:i}=n.point,{lng:r,lat:s}=n._center;return Nt(e,i,n.worldSize,r,s)},U.cJ=nc,U.cK=ms,U.cL=X,U.cM=k,U.cN=5,U.cO=function(n,e,i){let r=0;for(let s=0;s<2;++s)n[s]>0&&(r+=(n[s]-0)*(n[s]-0)),e[s]<0&&(r+=(0-e[s])*(0-e[s]));return r},U.cP=function(n){return n*n*n*n*n},U.cQ=op,U.cR=45,U.cS=ip,U.cT=function(n,e,i){let r=Math.sqrt(n*n+e*e+i*i),s=r>0?Math.acos(i/r)*ua:0,l=n!==0||e!==0?Math.atan2(-e,-n)*ua+90:0;return l<0&&(l+=360),[r,l,s]},U.cU=Fn,U.cV=nn,U.cW=Vr,U.cX=tn,U.cY=Si,U.cZ=po,U.c_=function(n){return[Math.pow(n[0],1/2.2),Math.pow(n[1],1/2.2),Math.pow(n[2],1/2.2)]},U.ca=oe,U.cb=3,U.cc=2,U.cd=7,U.ce=6,U.cf=na,U.cg=si,U.ch=ic,U.ci=0,U.cj=1,U.ck=4,U.cl=5,U.cm=de,U.cn=hp,U.co=ex,U.cp=J,U.cq=ot,U.cr=function(n,e,i,r,s,l,u,p,f){if(f.name==="globe")return ot(n,e,new J(i,r,s),!1);let g=su({z:i,x:r,y:s},f);return new Si([(l+g.x/g.scale)*e,e*(g.y/g.scale),u],[(l+g.x2/g.scale)*e,e*(g.y2/g.scale),p])},U.cs=function(n,e,i){return n[0]=Math.min(e[0],i[0]),n[1]=Math.min(e[1],i[1]),n[2]=Math.min(e[2],i[2]),n[3]=Math.min(e[3],i[3]),n},U.ct=function(n,e,i){return n[0]=Math.max(e[0],i[0]),n[1]=Math.max(e[1],i[1]),n[2]=Math.max(e[2],i[2]),n[3]=Math.max(e[3],i[3]),n},U.cu=function(n){let e=Math.round((n+45+360)%360/90)%4;return ae[e]},U.cv=Er,U.cw=oa,U.cx=6,U.cy=function(n){let e=Rt(new Float64Array(16));xi(e,n.pixelMatrix,n.globeMatrix);let i=[0,Nr,0],r=[0,Ur,0];return Oi(i,i,e),Oi(r,r,e),[i[0]>0&&i[0]<=n.width&&i[1]>0&&i[1]<=n.height&&!ai(n,new Yt(n.center.lat,90)),r[0]>0&&r[0]<=n.width&&r[1]>0&&r[1]<=n.height&&!ai(n,new Yt(n.center.lat,-90))]},U.cz=function(n,e){let{scale:i}=n.tileTransform,r=i*Xe/(n.tileSize*Math.pow(2,e.zoom-n.tileID.overscaledZ+n.tileID.canonical.z)),s=e.inverseAdjustmentMatrix;return new Float32Array([s[0]*r,s[1]*r,s[2]*r,s[3]*r])},U.d=function(n){return di.API_TILEJSON_REGEX.test(n)},U.d$=Lt,U.d0=Jg,U.d1=nx,U.d2=m,U.d3=class{static calculate(n,e,i){let r=new Set,s=new Map,l=new Set,u=new Set;for(let f of Object.values(n))for(let[g,x]of Object.entries(f.floors)){l.add(g),x.isDefault&&u.add(g),x.conflicts&&s.set(g,x.conflicts);let b=g===e,w=x.connections&&e&&x.connections.has(e);(b||w)&&r.add(g)}let p=f=>{let g=s.get(f)||new Set;for(let x of r)if((s.get(x)||new Set).has(f)||g.has(x))return!0;return!1};if(i)for(let f of i)l.has(f)&&(p(f)||r.add(f));for(let f of u)r.has(f)||p(f)||r.add(f);return r}},U.d4=p_,U.d5=my,U.d6=il,U.d7=function(){return{API_URL:di.API_URL,DRACO_URL:di.DRACO_URL,MESHOPT_URL:di.MESHOPT_URL,MESHOPT_SIMD_URL:di.MESHOPT_SIMD_URL,BUILDING_GEN_URL:di.BUILDING_GEN_URL}}
7,U.d8=Bc,U.d9=kh,U.dA=Ie,U.dB=pi,U.dC=Ii,U.dD=fe,U.dE=Hn,U.dF=Xi,U.dG=function(n,e){return[Math.pow(n[0],2.2)*e,Math.pow(n[1],2.2)*e,Math.pow(n[2],2.2)*e]},U.dH=Yr,U.dI=function(n,e){var i=Math.sin(e),r=Math.cos(e);return n[0]=r,n[1]=i,n[2]=0,n[3]=-i,n[4]=r,n[5]=0,n[6]=0,n[7]=0,n[8]=1,n},U.dJ=_s,U.dK=bt,U.dL=zn,U.dM=zr,U.dN=Ey,U.dO=function(n,e){let i=[0,0,0];return Oi(i,i,Tt($e(e.canonical))),Oi(i,i,n),i},U.dP=n=>({u_matrix:new Xc(n),u_texsize:new dr(n),u_pixels_to_tile_units:new Bl(n),u_device_pixel_ratio:new an(n),u_width_scale:new an(n),u_floor_width_scale:new an(n),u_image:new ch(n),u_units_to_pixels:new dr(n),u_tile_units_to_pixels:new an(n),u_alpha_discard_threshold:new an(n),u_trim_offset:new dr(n),u_trim_fade_range:new dr(n),u_trim_gradient_mix_range:new dr(n),u_trim_color:new ip(n),u_zbias_factor:new an(n),u_tile_to_meter:new an(n),u_ground_shadow_factor:new Wc(n),u_pattern_transition:new an(n)}),U.dQ=n=>({u_matrix:new Xc(n),u_pixels_to_tile_units:new Bl(n),u_device_pixel_ratio:new an(n),u_width_scale:new an(n),u_floor_width_scale:new an(n),u_units_to_pixels:new dr(n),u_dash_image:new ch(n),u_gradient_image:new ch(n),u_image_height:new an(n),u_texsize:new dr(n),u_tile_units_to_pixels:new an(n),u_alpha_discard_threshold:new an(n),u_trim_offset:new dr(n),u_trim_fade_range:new dr(n),u_trim_gradient_mix_range:new dr(n),u_trim_color:new ip(n),u_zbias_factor:new an(n),u_tile_to_meter:new an(n),u_ground_shadow_factor:new Wc(n)}),U.dR=n=>({u_camera_to_center_distance:new an(n),u_extrude_scale:new Bl(n),u_device_pixel_ratio:new an(n),u_matrix:new Xc(n),u_inv_rot_matrix:new Xc(n),u_merc_center:new dr(n),u_tile_id:new Wc(n),u_zoom_transition:new an(n),u_up_dir:new Wc(n),u_emissive_strength:new an(n)}),U.dS=$d,U.dT=uw,U.dU=class{constructor(n,e,i,r){this.context=n,this.format=r,this.size=i,this.texture=n.gl.createTexture();let[s,l,u]=this.size,{gl:p}=n;p.bindTexture(p.TEXTURE_3D,this.texture),n.pixelStoreUnpackFlipY.set(!1),n.pixelStoreUnpack.set(1),n.pixelStoreUnpackPremultiplyAlpha.set(!1),"data"in e&&e.data&&p.texImage3D(p.TEXTURE_3D,0,this.format,s,l,u,0,jg(this.format),Gg(this.format),e.data)}bind(n,e){let{context:i}=this,{gl:r}=i;r.bindTexture(r.TEXTURE_3D,this.texture),n!==this.minFilter&&(r.texParameteri(r.TEXTURE_3D,r.TEXTURE_MAG_FILTER,n),r.texParameteri(r.TEXTURE_3D,r.TEXTURE_MIN_FILTER,n),this.minFilter=n),e!==this.wrapS&&(r.texParameteri(r.TEXTURE_3D,r.TEXTURE_WRAP_S,e),r.texParameteri(r.TEXTURE_3D,r.TEXTURE_WRAP_T,e),this.wrapS=e)}destroy(){let{gl:n}=this.context;n.deleteTexture(this.texture),this.texture=null}},U.dV=Di,U.dW=(n,e,i,r,s,l)=>{let u=n.transform,p=u.projection.name==="globe",f;if(l.paint.get("circle-pitch-alignment")==="map")if(p){let x=bt(u.zoom,e.canonical)*u._pixelsPerMercatorPixel;f=Float32Array.from([x,0,0,x])}else f=u.calculatePixelsToTileUnitsMatrix(i);else f=new Float32Array([u.pixelsToGLUnits[0],0,0,u.pixelsToGLUnits[1]]);let g={u_camera_to_center_distance:n.transform.getCameraToCenterDistance(u.projection),u_matrix:n.translatePosMatrix(e.projMatrix,i,l.paint.get("circle-translate"),l.paint.get("circle-translate-anchor")),u_device_pixel_ratio:xn.devicePixelRatio,u_extrude_scale:f,u_inv_rot_matrix:li,u_merc_center:[0,0],u_tile_id:[0,0,0],u_zoom_transition:0,u_up_dir:[0,0,0],u_emissive_strength:l.paint.get("circle-emissive-strength")};if(p){g.u_inv_rot_matrix=r,g.u_merc_center=s,g.u_tile_id=[e.canonical.x,e.canonical.y,1<<e.canonical.z],g.u_zoom_transition=$t(u.zoom);let x=s[0]*Xe,b=s[1]*Xe;g.u_up_dir=u.projection.upVector(new J(0,0,0),x,b)}return g},U.dX=Tx,U.dY=cr,U.dZ=(n,e,i,r,s,l,u,p,f,g)=>{let x=n.transform,b=x.pitch<15?vx(.07,.7,ne((14-x.zoom)/5,0,1)):.07,w=i.paint.get("line-trim-color-use-theme").constantOr("default")==="none";return{u_matrix:wx(n,e,i,r),u_texsize:e.imageAtlasTexture?e.imageAtlasTexture.size:[0,0],u_pixels_to_tile_units:x.calculatePixelsToTileUnitsMatrix(e),u_device_pixel_ratio:s,u_width_scale:l,u_floor_width_scale:u,u_image:0,u_tile_units_to_pixels:bx(e,x),u_units_to_pixels:[1/x.pixelsToGLUnits[0],1/x.pixelsToGLUnits[1]],u_alpha_discard_threshold:0,u_trim_offset:p,u_trim_fade_range:i.paint.get("line-trim-fade-range"),u_trim_gradient_mix_range:[1,1],u_trim_color:i.paint.get("line-trim-color").toPremultipliedRenderColor(w?null:i.lut).toArray01(),u_zbias_factor:b,u_tile_to_meter:Vr(e.tileID.canonical,0),u_ground_shadow_factor:f,u_pattern_transition:g}},U.d_=(n,e,i,r,s,l,u,p,f,g)=>{let x=n.transform,b=x.calculatePixelsToTileUnitsMatrix(e),w=i.paint.get("line-trim-color-use-theme").
7constantOr("default")==="none",S=x.pitch<15?vx(.07,.7,ne((14-x.zoom)/5,0,1)):.07;return{u_matrix:wx(n,e,i,r),u_pixels_to_tile_units:b,u_device_pixel_ratio:l,u_width_scale:u,u_floor_width_scale:p,u_units_to_pixels:[1/x.pixelsToGLUnits[0],1/x.pixelsToGLUnits[1]],u_dash_image:0,u_gradient_image:1,u_image_height:s,u_texsize:Sx(i)&&e.lineAtlasTexture?e.lineAtlasTexture.size:[0,0],u_tile_units_to_pixels:bx(e,n.transform),u_alpha_discard_threshold:0,u_trim_offset:f,u_trim_fade_range:i.paint.get("line-trim-fade-range"),u_trim_gradient_mix_range:[1,1],u_trim_color:i.paint.get("line-trim-color").toPremultipliedRenderColor(w?null:i.lut).toArray01(),u_zbias_factor:S,u_tile_to_meter:Vr(e.tileID.canonical,0),u_ground_shadow_factor:g}},U.da=fc,U.db=Ut,U.dc=function(n){let e=n.indexOf(El);return e>=0?n.slice(0,e):n},U.dd=mx,U.de=function(n){return n.includes(El)},U.df=function(n){let e=n.lastIndexOf(El);return e>=0?n.slice(e+1):""},U.dg=function(n){let e=[],i=n.id;return i===void 0&&e.push({message:`layers.${i}: missing required property "id"`}),n.render===void 0&&e.push({message:`layers.${i}: missing required method "render"`}),n.renderingMode&&n.renderingMode!=="2d"&&n.renderingMode!=="3d"&&e.push({message:`layers.${i}: property "renderingMode" must be either "2d" or "3d"`}),e},U.dh=function(n,e,i,r){return n.type==="custom"?new sT(n,e):new uT[n.type](n,e,i,r)},U.di=Ve,U.dj=io,U.dk=im,U.dl=class extends lu{constructor(n,e){super(n._vectorTileFeature,n._z,n._x,n._y,n.id),n.state&&(this.state=Object.assign({},n.state)),this.target=e.target,this.namespace=e.namespace,e.properties&&(this.properties=e.properties),this.target&&("featuresetId"in this.target&&!this.target.importId||"layerId"in this.target)&&(this.source=n.source,this.sourceLayer=n.sourceLayer,this.layer=n.layer)}toJSON(){let n=super.toJSON();return n.target=this.target,n.namespace=this.namespace,n}},U.dm=Tl,U.dn=function(n){return n({pluginStatus:En,pluginURL:Fs}),Tl.on("pluginStateChange",n),n},U.dp=mm,U.dq=class extends zo{constructor(n){super(n),this.current=new Float32Array(9)}set(n,e,i){if(!this.fetchUniformLocation(n,e))return;let r=this.current;for(let s=0;s<9;s++)if(i[s]!==r[s]){r.set(i),this.gl.uniformMatrix3fv(this.location,!1,r);break}}},U.dr=le,U.ds=function(n,e,i){let r=$t(i.zoom),s=n.style.map._antialias,l=n.terrain&&n.terrain.exaggeration()>0;return r===0&&!s&&!l},U.dt=function(n){let e=n.pixelsPerMeter,i=e/or(1,n.center.lat),r=Rt(new Float64Array(16));return Gn(r,r,[n.point.x,n.point.y,0]),Zn(r,r,[i,i,e]),Float32Array.from(r)},U.du=et,U.dv=function(n){let e=80.051129;n=ne(n,-80.051129,e)/e*90;let i=Math.pow(Math.abs(Math.sin(V(n))),3);return Math.round(i*(rp.length-1))},U.dw=function(n,e,i,r){let s=e.getNorth(),l=e.getSouth(),u=e.getWest(),p=e.getEast(),f=1<<n.z,g=p-u,x=s-l,b=g/Gs,w=-x/rp[i],S=[0,b,0,w,0,0,s,u,0];if(n.z>0){let E=180/r;Jr(S,S,[E/g+1,0,0,0,E/x+1,0,-.5*E/b,.5*E/w,1])}return S[2]=f,S[5]=n.x,S[8]=n.y,S},U.dx=Tt,U.dy=$e,U.dz=function(n,e,i){let r=Rt(new Float64Array(16)),s=(e/(1<<n)-.5)*Math.PI*2;return jo(r,i.globeMatrix,s),Float32Array.from(r)},U.e=function(n){return n.indexOf("mapbox:")===0},U.e$=$g,U.e0=ei,U.e1=hh,U.e2=be,U.e3=Ym,U.e4=E0,U.e5=Ga,U.e6=450,U.e7=7,U.e8=Ua,U.e9=function(n,e){if(n===e){var i=e[1],r=e[2],s=e[3],l=e[6],u=e[7],p=e[11];n[1]=e[4],n[2]=e[8],n[3]=e[12],n[4]=i,n[6]=e[9],n[7]=e[13],n[8]=r,n[9]=l,n[11]=e[14],n[12]=s,n[13]=u,n[14]=p}else n[0]=e[0],n[1]=e[4],n[2]=e[8],n[3]=e[12],n[4]=e[1],n[5]=e[5],n[6]=e[9],n[7]=e[13],n[8]=e[2],n[9]=e[6],n[10]=e[10],n[11]=e[14],n[12]=e[3],n[13]=e[7],n[14]=e[11],n[15]=e[15];return n},U.eA=function(n,e){var i=2*Math.acos(e[3]),r=Math.sin(i/2);return r>ln?(n[0]=e[0]/r,n[1]=e[1]/r,n[2]=e[2]/r):(n[0]=1,n[1]=0,n[2]=0),i},U.eB=Py,U.eC=o_,U.eD=r_,U.eE=[1,1,1],U.eF=Ch,U.eG=function(n,e,i,r){var s=e[0],l=e[1],u=e[2],p=e[3];return n[0]=s+r*(i[0]-s),n[1]=l+r*(i[1]-l),n[2]=u+r*(i[2]-u),n[3]=p+r*(i[3]-p),n},U.eH=vh,U.eI=kr,U.eJ=class{constructor(){this._updateTime=0,this._sourceIds=[],this._activeRegions=[],this._prevRegions=[],this._globalClipBounds={min:new ke(1/0,1/0),max:new ke(-1/0,-1/0)}}clear(){this._activeRegions.length>0&&++this._updateTime,this._activeRegions=[],this._prevRegions=[]}get updateTime(){return this._updateTime}getReplacementRegionsForTile(n,e=!1){let i=f0(new ke(0,0),new ke(Xe,Xe),n),r=[];if(e&&!zg(i,this._globalClipBounds))return r;for(let s of this._activeRegions){if(s.hiddenByOverlap||!zg(i,s))continue;let l=K1(s.min,s.max,n);r.push({min:l.min,max:l.max,sourceId:this._sourceIds[s.priority],footprint:s.footprint,footprintTileId:s.tileId,order:s.order,clipMask:s.clipMask,clipScope:s.clipScope})}return r}setSources(n){this._setSources(n.map(e=>({getSourceId:()=>e.cache.id,getFootprints:()=>{let i=[];for(let r of e.cache.getVisibleCoordinates()){let s=e.cache.getTile(r).buckets[e.layer];s&&s.updateFootprints(r.toUnwrapped(),i)}return i},getOrder:()=>e.order,getClipMask:()=>e.clipMask,getClipScope:()=>e.clipScope})))}_addSource(n){let e=n.getFootprints();if(e.length===0)return;let i=n.getOrder(),r=n.getClipMask(),s=n.getClipScope();for(let l of e){if(!l.footprint)continue;let u=f0(l.footprint.min,l.footprint.max,l.id);this._activeRegions.push({min:u.min,max:u.max,hiddenByOverlap:!1,priority:this._sourceIds.length,tileId:l.id,footprint:l.footprint,order:i,clipMask:r,clipScope:s})}
7this._sourceIds.push(n.getSourceId())}_computeReplacement(){this._activeRegions.sort((e,i)=>e.priority-i.priority||Vm(e.min,i.min)||Vm(e.max,i.max)||e.order-i.order||e.clipMask-i.clipMask||function(r,s){let l=(u,p)=>u+p;return r.length-s.length||r.reduce(l,"").localeCompare(s.reduce(l,""))}(e.clipScope,i.clipScope));let n=this._activeRegions.length!==this._prevRegions.length;if(!n){let e=0;for(;!n&&e!==this._activeRegions.length;){let i=this._activeRegions[e],r=this._prevRegions[e];n=i.priority!==r.priority||!p0(i,r)||i.order!==r.order||i.clipMask!==r.clipMask||!Zo(i.clipScope,r.clipScope),this._activeRegions[e].hiddenByOverlap=r.hiddenByOverlap,++e}}if(n){++this._updateTime;for(let i of this._activeRegions)i.order!==xp&&(this._globalClipBounds.min.x=Math.min(this._globalClipBounds.min.x,i.min.x),this._globalClipBounds.min.y=Math.min(this._globalClipBounds.min.y,i.min.y),this._globalClipBounds.max.x=Math.max(this._globalClipBounds.max.x,i.max.x),this._globalClipBounds.max.y=Math.max(this._globalClipBounds.max.y,i.max.y));let e=i=>{let r=this._activeRegions;if(i>=r.length)return i;let s=r[i].priority;for(;i<r.length&&r[i].priority===s;)++i;return i};if(this._sourceIds.length>1){let i=0,r=e(i);for(;i!==r;){let s=i,l=i;for(;s!==r;){let u=this._activeRegions[s];u.hiddenByOverlap=!1;for(let p=0;p<l;p++){let f=this._activeRegions[p];if(!f.hiddenByOverlap&&u.order===xp&&zg(u,f)&&(u.hiddenByOverlap=m0(u.footprint,u.tileId,f.footprint,f.tileId),u.hiddenByOverlap))break}++s}i=r,r=e(i)}}}}_setSources(n){[this._prevRegions,this._activeRegions]=[this._activeRegions,[]],this._sourceIds=[];for(let e=n.length-1;e>=0;e--)this._addSource(n[e]);this._computeReplacement()}},U.eK=Ba,U.eL=S_,U.eM=Cl,U.eN=xp,U.eO=class{constructor(n){this._createGrid(n),this._createPoles(n)}destroy(){this._poleIndexBuffer.destroy(),this._gridBuffer.destroy(),this._gridIndexBuffer.destroy(),this._poleNorthVertexBuffer.destroy(),this._poleSouthVertexBuffer.destroy();for(let n of this._poleSegments)n.destroy();for(let n of this._gridSegments)n.withSkirts.destroy(),n.withoutSkirts.destroy()}_fillGridMeshWithLods(n,e){let i=new Hn,r=new Xi,s=[],l=n+1+2,u=e[0]+1,p=e[0]+1+(1+e.length),f=(g,x,b)=>{let w=g===l-1?g-2:g===0?g:g-1;return w+=b?24575:0,[w,x]};for(let g=0;g<l;++g)i.emplaceBack(...f(g,0,!0));for(let g=0;g<u;++g)for(let x=0;x<l;++x)i.emplaceBack(...f(x,g,(x===0||x===l-1)&&!0));for(let g=0;g<e.length;++g){let x=e[g];for(let b=0;b<l;++b)i.emplaceBack(...f(b,x,!0))}for(let g=0;g<e.length;++g){let x=r.length,b=e[g]+1+2,w=new Xi;for(let M=0;M<b-1;M++){let C=M===b-2,R=C?l*(p-e.length+g-M):l;for(let F=0;F<l-1;F++){let z=M*l+F;M===0||C||F===0||F===l-2?(w.emplaceBack(z+1,z,z+R),w.emplaceBack(z+R,z+R+1,z+1)):(r.emplaceBack(z+1,z,z+R),r.emplaceBack(z+R,z+R+1,z+1))}}let S=pi.simpleSegment(0,x,i.length,r.length-x);for(let M=0;M<w.uint16.length;M+=3)r.emplaceBack(w.uint16[M],w.uint16[M+1],w.uint16[M+2]);let E=pi.simpleSegment(0,x,i.length,r.length-x);s.push({withoutSkirts:S,withSkirts:E})}return{vertices:i,indices:r,segments:s}}_createGrid(n){let e=this._fillGridMeshWithLods(Gs,rp);this._gridSegments=e.segments,this._gridBuffer=n.createVertexBuffer(e.vertices,Ie.members),this._gridIndexBuffer=n.createIndexBuffer(e.indices,!0)}_createPoles(n){let e=new Xi;for(let u=0;u<=Gs;u++)e.emplaceBack(0,u+1,u+2);this._poleIndexBuffer=n.createIndexBuffer(e,!0);let i=new ka,r=new ka,s=new ka,l=new ka;this._poleSegments=[];for(let u=0,p=0;u<6;u++){let f=360/(1<<u);i.emplaceBack(0,-Jn,0,.5,0),r.emplaceBack(0,-Jn,0,.5,1),s.emplaceBack(0,-Jn,0,.5,.5),l.emplaceBack(0,-Jn,0,.5,.5);for(let g=0;g<=Gs;g++){let x=g/Gs,b=0,w=ft(0,f,x),[S,E,M]=Nl(It,Et,w,Jn);i.emplaceBack(S,E,M,x,b),r.emplaceBack(S,E,M,x,1-b);let C=V(w);x=.5+.5*Math.sin(C),b=.5+.5*Math.cos(C),s.emplaceBack(S,E,M,x,b),l.emplaceBack(S,E,M,x,1-b)}this._poleSegments.push(pi.simpleSegment(p,0,66,64)),p+=66}this._poleNorthVertexBuffer=n.createVertexBuffer(i,Fe,!1),this._poleSouthVertexBuffer=n.createVertexBuffer(r,Fe,!1),this._texturedPoleNorthVertexBuffer=n.createVertexBuffer(s,Fe,!1),this._texturedPoleSouthVertexBuffer=n.createVertexBuffer(l,Fe,!1)}getGridBuffers(n,e){return[this._gridBuffer,this._gridIndexBuffer,e?this._gridSegments[n].withSkirts:this._gridSegments[n].withoutSkirts]}getPoleBuffers(n,e){return[e?this._texturedPoleNorthVertexBuffer:this._poleNorthVertexBuffer,e?this._texturedPoleSouthVertexBuffer:this._poleSouthVertexBuffer,this._poleIndexBuffer,this._poleSegments[n]]}},U.eP=J1,U.eQ=ce,U.eR=function(){return!!document.fullscreenElement||!!document.webkitFullscreenElement},U.eS=we,U.eT=ym,U.eU=function(n,e,i){return n[0]=e[0]/i[0],n[1]=e[1]/i[1],n[2]=e[2]/i[2],n},U.eV=Xa,U.eW=ns,U.eX=rc,U.eY=Ei,U.eZ=function([n,e,i]){let r=Math.hypot(n,e,i),s=Math.atan2(n,i),l=.5*Math.PI-Math.acos(-e/r);return new Yt(X(s),X(l))},U.e_=Ho,U.ea=Ct,U.eb=Rl,U.ec=256,U.ed=function(n){return n>>>=0,n=Math.imul(2747636419^n,2654435769)>>>0,n=Math.imul(n^n>>>16,2654435769)>>>0,(n=Math.imul(n^n>>>16,2654435769)>>>0)/4294967296},U.ee=nr,U.ef=md,U.eg=rs,U.eh=hr,U.ei=Wd,U.ej=oT,U.ek=Ue,U.el=yt,U.em=Br,U.en=function(n,e){var i=Math.sin(e),r=Math.cos(e);return n[0]=r,n[1]=0,n[2]=-i,n[3]=0,n[4]=0,n[5]=1,n[6]=0,n[7]=0,n[8]=i,n[9]=0,n[10]=r,n[11]=0,n[12]=0,n[13]=0,n[14]=0,n[15]=1,n},U.eo=function(n,e){var i=Math.sin(e),r=Math.cos(e);return n[0]=1,n[1]=0,n[2]=0,n[3]=0,n[4]=0,n[5]=r,n[6]=i,n[7]=0,n[8]=0,n[9]=-i,n[10]=r,n[11]=0,n[12]=0,n[13]=0,n[14]=0,n[15]=1,n},U.ep=function(n,e){return n[0]=e[0],n[1]=e[1],n[2]=e[2],n[3]=e[4],n[4]=e[5],n[5]=e[6],n[6]=e[8],n[7]=e[9],n[8]=e[10],n},U.eq=ka,U.er=Zd,U.es=function(n,e,i,r,s){return ne((n-e)/(i-e)*(s-r)+r,r,s)},U.et=sa,U.eu=function(n,e){var i=e[0],r=e[1],s=e[2],l=e[3],u=e[4],p=e[5],f=e[6],g=e[7],x=e[8],b=x*u-p*g,w=-x*l+p*f,S=g*l-u*f,E=i*b+r*w+s*S;return E?(n[0]=b*(E=1/E),n[1]=(-x*r+s*g)*E,n[2]=(p*r-s*u)*E,n[3]=w*E,n[4]=(x*i-s*f)*E,n[5]=(-p*i+s*l)*E,n[6]=S*E,n[7]=(-g*i+r*f)*E,n[8]=(u*i-r*l)*E,n):null},U.ev=2,U.ew=fo,U.ex=gs,U.ey=Ql,U.ez=function(n,e){var i=new gi(3);Ql(i,e);var r=1/i[0],s=1/i[1],l=1/i[2],u=e[0]*r,p=e[1]*s,f=e[2]*l,g=e[4]*r,x=e[5]*s,b=e[6]*l,w=e[8]*r,S=e[9]*s,E=e[10]*l,M=u+x+E,C=0;return M>0?(C=2*Math.sqrt(M+1),n[3]=.25*C,n[0]=(b-S)/C,n[1]=(w-f)/C,n[2]=(p-g)/C):u>x&&u>E?(C=2*Math.sqrt(1+u-x-E),n[3]=(b-S)/C,n[0]=.25*C,n[1]=(p+g)/C,n[2]=(w+f)/C):x>E?(C=2*Math.sqrt(1+x-u-E),n[3]=(w-f)/C,n[0]=(p+g)/C,n[1]=.25*C,n[2]=(b+S)/C):(C=2*Math.sqrt(1+E-u-x),n[3]=(p-g)/C,n[0]=(w+f)/C,n[1]=(b+S)/C,n[2]=.25*C),n},U.f=vs,U.f0=function(n){let e=n.navigator?n.navigator.userAgent:null;return!!function(i){if(vi==null){let r=i.navigator?i.navigator.userAgent:null;vi=!!i.safari||!(!r||!(_e.test(r)||r.match("Safari")&&!r.match("Chrome")))}return vi}(n)&&!(!e||!(e.match("Version/15.4")||e.match("Version/15.5")||e.match(B)))},U.f1=function(n,e){Qp=n,ef=e},U.f2=ai,U.f3=bi,U.f4=function(n){let e=[0,0,0],i=Rt(new Float64Array(16));return xi(i,n.pixelMatrix,n.globeMatrix),Oi(e,e,i),new ke(e[0],e[1])},U.f5=function(n,e){if(!n||!e)throw new Error("TileProvider name and URL are required");di.TILE_PROVIDER_URLS[n]=xn.resolveURL(e)},U.f6=eh,U.f7=function(n,e,i=!1){if(En===Sr.deferred||En===Sr.loading||En===Sr.loaded)throw new Error("setRTLTextPlugin cannot be called multiple times.");Fs=xn.resolveURL(n),En=Sr.deferred,Od=e,Qu(),i||Yf()},U.f8=pa,U.f9=da,U.fA=l_,U.fB=cp,U.fC=function(n){return n<=1?1:Math.pow(2,Math.floor(Math.log2(n)))},U.fD=D_,U.fE=$s,U.fF=function(n){let e=0;
7if(new Uint32Array(n,0,1)[0]!==Z0){let i=new Uint32Array(n,0,7),[,,r,s,l,u]=i;e=i.byteLength+s+l+u+l,(r!==n.byteLength||e>=n.byteLength)&&Ot("Invalid b3dm header information.")}return J0(n,e)},U.fG=function(n,e){let i=n.json.extensionsUsed&&n.json.extensionsUsed.includes("mbx_bvh"),r=Jg(n);for(let s of r){if(!i)for(let l of s.meshes)Mb(l);s.lights&&(s.lightMeshIndex=s.meshes.length,s.meshes.push(Cb(s.lights,e)))}return r},U.fH=C_,U.fI=ii,U.fJ=Qo,U.fK=Sr,U.fL=function(n){fa(),Wo?.then(e=>{e.keys().then(i=>{for(let r=0;r<i.length-n;r++)e.delete(i[r]).catch(s=>Ot(s.message))}).catch(i=>Ot(i.message))}).catch(e=>Ot(e.message))},U.fa=ha,U.fb=function(n){let e=nf();if(!e)return;let i=e.delete(Kp);n&&i.then(()=>n()).catch(n)},U.fc=Qe,U.fd=Ri,U.fe=2,U.ff=Sc,U.fg=su,U.fh=qc,U.fi=jv,U.fj=Gv,U.fk=_x,U.fl=Hs,U.fm="hd_road_elevation",U.fn=_h,U.fo=Mt,U.fp=Nm,U.fq=ja,U.fr=dy,U.fs=1,U.ft=Bo,U.fu=function(n,e,i,r,s,l,u,p=1,f,g,x,b){n.createArrays(),n.tilePixelRatio=Xe/(512*n.overscaling),n.compareText={},n.iconsNeedLinear=!1;let w=n.layers[0].layout,S=n.layers[0]._unevaluatedLayout._values,E={};E.scaleFactor=p,E.textSizeScaleRange=w.get("text-size-scale-range"),E.iconSizeScaleRange=w.get("icon-size-scale-range");let[M,C]=E.textSizeScaleRange,[R,F]=E.iconSizeScaleRange;E.textScaleFactor=ne(E.scaleFactor,M,C),E.iconScaleFactor=ne(E.scaleFactor,R,F);let z=S["text-size"],j=S["icon-size"];if(n.textSizeData.kind==="composite"){let{minZoom:Y,maxZoom:ee}=n.textSizeData;E.compositeTextSizes=[z.possiblyEvaluate(new Xt(Y,{worldview:x}),l),z.possiblyEvaluate(new Xt(ee,{worldview:x}),l)]}if(n.iconSizeData.kind==="composite"){let{minZoom:Y,maxZoom:ee}=n.iconSizeData;E.compositeIconSizes=[j.possiblyEvaluate(new Xt(Y,{worldview:x}),l,b),j.possiblyEvaluate(new Xt(ee,{worldview:x}),l,b)]}E.layoutTextSize=z.possiblyEvaluate(new Xt(u+1,{worldview:x}),l),E.layoutIconSize=j.possiblyEvaluate(new Xt(u+1,{worldview:x}),l,b),E.textMaxSize=z.possiblyEvaluate(new Xt(18,{worldview:x}),l);let $=w.get("symbol-placement"),H=w.get("text-rotation-alignment")==="map"&&$!=="point",ie=w.get("text-size"),W=!1,Q=[];for(let Y of n.features){let ee=w.get("text-font").evaluate(Y,{},l).join(","),me=ie.evaluate(Y,{},l)*E.textScaleFactor,ge=E.layoutTextSize.evaluate(Y,{},l)*E.textScaleFactor,Te=E.layoutIconSize.evaluate(Y,{},l,b)*E.iconScaleFactor,Ae={horizontal:{},vertical:void 0},Ee=Y.text,Be,xe=[0,0];if(Ee){let At=Ee.toString(),Ui=w.get("text-letter-spacing").evaluate(Y,{},l)*Tn,Jt=w.get("text-line-height").evaluate(Y,{},l)*Tn,Gt=ig(At)?Ui:0,ui=w.get("text-anchor").evaluate(Y,{},l),Mi=w.get("text-variable-anchor");if(!Mi){let en=w.get("text-radial-offset").evaluate(Y,{},l);if(en)xe=tv(ui,[en*Tn,gy]);else{let hn=w.get("text-offset").evaluate(Y,{},l);xe=[hn[0]*Tn,hn[1]*Tn]}}let Sn=H?"center":w.get("text-justify").evaluate(Y,{},l),mi=$==="point",Vi=mi?w.get("text-max-width").evaluate(Y,{},l)*Tn:1/0,un=en=>{n.allowVerticalPlacement&&Yu(At)&&(Ae.vertical=oy(Ee,e,i,s,ee,Vi,Jt,ui,en,Gt,xe,Zr.vertical,!0,ge,me,f,E.textScaleFactor))};if(!H&&Mi){let en=Sn==="auto"?Mi.map(Pt=>yy(Pt)):[Sn],hn=!1;for(let Pt=0;Pt<en.length;Pt++){let Un=en[Pt];if(!Ae.horizontal[Un])if(hn)Ae.horizontal[Un]=Ae.horizontal[0];else{let lr=oy(Ee,e,i,s,ee,Vi,Jt,"center",Un,Gt,xe,Zr.horizontal,!1,ge,me,f,E.textScaleFactor);lr&&(Ae.horizontal[Un]=lr,hn=lr.positionedLines.length===1)}}un("left")}else{if(Sn==="auto"&&(Sn=yy(ui)),mi||w.get("text-writing-mode").includes("horizontal")||!Yu(At)){let en=oy(Ee,e,i,s,ee,Vi,Jt,ui,Sn,Gt,xe,Zr.horizontal,!1,ge,me,f,E.textScaleFactor);en&&(Ae.horizontal[Sn]=en)}un(mi?"left":Sn)}}let Se,Me,ze,Le,We,De,Ge=!1,He=w.get("icon-text-fit").evaluate(Y,{},l);if(Y.icon&&Y.icon.hasPrimary()){let At=zp(Y.icon,n.iconSizeData,S["icon-size"],l,n.zoom,Y,f,E.iconScaleFactor,x,b);Se=At.iconPrimary,ze=At.iconSecondary;let Ui=Se.toString();if(Me=r.get(Ui),Me&&(We=w.get("icon-offset").evaluate(Y,{},l),De=w.get("icon-anchor").evaluate(Y,{},l),Be=h_(s.get(Ui),ze?s.get(ze.toString()):void 0,We,De),Ge=Me.sdf,n.sdfIcons===void 0?n.sdfIcons=Me.sdf:n.sdfIcons!==Me.sdf&&Ot("Style sheet warning: Cannot mix SDF and non-SDF icons in one buffer"),(Me.pixelRatio!==n.pixelRatio||w.get("icon-rotate").constantOr(1)!==0)&&(n.iconsNeedLinear=!0)),ze){let Jt=ze.toString();Le=r.get(Jt)}}W=W||!(!Y.icon||!Y.icon.hasSecondary());let Je=y_(Ae.horizontal)||Ae.vertical;n.iconsInText||(n.iconsInText=!!Je&&Je.iconsInText);let tt=ge*E.textScaleFactor/Tn,{defaultShapedIcon:lt,verticallyShapedIcon:rt}=$w(n,Be,w,Y,l,Ae,tt,We,He);He!=="none"&&Be&&(Bx(Be)||kx(Be))&&(g_(0,Me,Se,Be,lt,He,g,r,s),g_(0,Le,ze,Be,lt,He,g,r,s),rt&&(g_(0,Me,Se,Be,rt,He,g,r,s),g_(0,Le,ze,Be,rt,He,g,r,s))),Be=lt;let{iconBBox:pt,iconVerticalBBox:Ht,textBBox:wt,textVerticalBBox:kt}=Nw(n,Be,rt,w,Y,l,Te,We,E,s,De,Ae,ge,xe,b);Q.push({feature:Y,shapedTextOrientations:Ae,shapedText:Je,shapedIcon:Be,iconPrimary:Se,iconSecondary:ze,iconOffset:We,iconAnchor:De,verticallyShapedIcon:rt,layoutTextSize:ge,layoutIconSize:Te,textOffset:xe,isSDFIcon:Ge,iconTextFit:He,iconCollisionBounds:pt,iconVerticalCollisionBounds:Ht,textCollisionBounds:wt,textVerticalCollisionBounds:kt})}return{featureData:Q,sizes:E,hasAnySecondaryIcon:W,textAlongLine:H,symbolPlacement:$}},U.fv=py,U.fw=hy,U.fx=Zx,U.fy=Wx,U.fz=function(n,e,i,r,s,l,u,p,f,g){n.iconAtlasPositions=g.iconPositions;let{featureData:x,hasAnySecondaryIcon:b,sizes:w,textAlongLine:S,symbolPlacement:E}=e;for(let M of x){let{shapedIcon:C,verticallyShapedIcon:R,feature:F,shapedTextOrientations:z,shapedText:j,layoutTextSize:$,textOffset:H,isSDFIcon:ie,iconPrimary:W,iconSecondary:Q,iconTextFit:Y,iconOffset:ee,iconCollisionBounds:me,iconVerticalCollisionBounds:ge,textCollisionBounds:Te}=M;ov(C,g.iconPositions,W,Q),ov(R,g.iconPositions,W,Q),Gw(z,g.iconPositions),jw(W,Q,g.iconPositions),(j||C)&&Hw(n,F,z,C,R,f,w,$,0,H,ie,r,s,u,p,b,Y,ee,S,E,me,ge,Te)}i&&n.generateCollisionDebugBuffers(l,n.collisionBoxArray,w.textScaleFactor)},U.g=di,U.h=function(n,e){return Lr(Object.assign(n,{method:"GET"}),e)},U.i=function(n){return di.API_STYLE_REGEX.test(n)&&!tl(n)},U.j=function(n){return btoa(encodeURIComponent(n).replace(/%([0-9A-F]{2})/g,(e,i)=>String.fromCharCode(+("0x"+i))))},U.k=Uh,U.l=function(n){return decodeURIComponent(atob(n).split("").map(e=>"%"+("00"+e.charCodeAt(0).toString(16)).slice(-2)).join(""))},U.m=sf,U.n=Kr,U.o=xn,U.p=function(n,e){return Lr(Object.assign(n,{method:"POST"}),e)},U.q=Ni,U.r=Bh,U.s=function(n){try{let e=self[n];return e.setItem("_mapbox_test_",1),e.removeItem("_mapbox_test_"),!0}catch{return!1}},U.t=ks,U.u=function(){return function n(e){return e?(e^Math.random()*(16>>e/4)).toString(16):([1e7]+-[1e3]+-4e3+-8e3+-1e11).replace(/[018]/g,n)}()},U.v=function(n){return!!n&&el.test(n)},U.w=Ot,U.x=class{constructor(n){this.cache=new Map,this.textures=new Map,this.textureAccessTimes=new Map,this.textureMemoryUsed=0,this.maxTextureMemory=1024*(n&&n.maxTextureMemoryMB?n.maxTextureMemoryMB:256)*1024,this.finalizationRegistry=new FinalizationRegistry(e=>{this.cache.delete(e),this.clearExpiredTextures()})}calculateTextureMemory(n){return n.image?Math.ceil(n.image.width*n.image.height*4*(n.patternPositions.size>0?1.33:1)):0}evictTexture(n){let e=this.textures.get(n);if(e){let i=this.calculateTextureMemory(n);e.destroy(),this.textures.delete(n),this.textureAccessTimes.delete(n),this.textureMemoryUsed-=i,n.uploaded=!1}}evictTexturesIfNeeded(n){for(;this.textureMemoryUsed+n>this.maxTextureMemory&&this.textures.size>0;){let e=null,i=1/0;for(let[r]of this.textures.entries()){let s=this.textureAccessTimes.get(r)||0;s<i&&(i=s,e=r)}if(!e)break;this.evictTexture(e)}}findCachedAtlas(n){let e=this.cache.get(n.hash);if(e){let i=e.deref();if(i&&i.contentDescriptor&&this.isMipmapCompatible(n,i.contentDescriptor))return i}for(let[,i]of this.cache.entries()){let r=i.deref();if(r&&r.contentDescriptor){let s=n.subsetOf(r.contentDescriptor),l=this.isMipmapCompatible(n,r.contentDescriptor);if(s&&l)return r}}}getTextureForAtlas(n,e,i){this.textureAccessTimes.set(n,performance.now());let r=this.textures.get(n);if(r)return r;if(n.image){let s=this.calculateTextureMemory(n);return this.evictTexturesIfNeeded(s),r=new Xs(e,n.image,i,{useMipmap:!!n.patternPositions.size}),this.textures.set(n,r),this.textureMemoryUsed+=s,r}return null}clearExpiredTextures(){for(let[n]of this.textures.entries())if(!this.isAtlasCached(n)){let e=this.textures.get(n);if(e){let i=this.calculateTextureMemory(n);e.destroy(),this.textureMemoryUsed-=i}this.textures.delete(n),this.textureAccessTimes.delete(n)}}isAtlasCached(n){if(!n.contentDescriptor)return!1;let e=this.cache.get(n.contentDescriptor.hash);return!!e&&e.deref()===n}getOrCache(n){if(!("image"in n)){let s=this.cache.get(n.sourceAtlasHash);if(s){let l=s.deref();if(l)return l}return Ot("ImageAtlasReference points to GC'd atlas - atlas may have been evicted"),null}if(!n.contentDescriptor)return n;
7let e=n.contentDescriptor,i=e.hash,r=this.cache.get(i);if(r){let s=r.deref();if(s&&s.contentDescriptor&&this.isMipmapCompatible(e,s.contentDescriptor))return s}return this.cache.set(i,new WeakRef(n)),this.finalizationRegistry.register(n,i,n),n}isMipmapCompatible(n,e){return!n.requiresMipMaps||e.requiresMipMaps}destroyTextures(){for(let n of this.textures.values())n&&n.destroy();this.textures.clear(),this.textureAccessTimes.clear(),this.textureMemoryUsed=0}clear(){for(let n of this.textures.values())n&&n.destroy();this.cache.clear(),this.textures.clear(),this.textureAccessTimes.clear(),this.textureMemoryUsed=0}},U.y=rl,U.z=Xo}),Zi(["require","./shared"],function(h,U){function ln(_e){let B=_e?_e.url.toString():void 0;return B?performance.getEntriesByName(B):[]}function gi(_e){if(typeof _e=="number"||typeof _e=="boolean"||typeof _e=="string"||_e==null)return JSON.stringify(_e);if(Array.isArray(_e)){let V="[";for(let X of _e)V+=`${gi(X)},`;return`${V}]`}let B="{";for(let V of Object.keys(_e).sort())B+=`${V}:${gi(_e[V])},`;return`${B}}`}function Cr(_e){let B="";for(let V of U.b8)B+=`/${gi(_e[V])}`;return B}function Yr(_e,B){return function V(X){return typeof X=="string"&&X===B||(Array.isArray(X)?X.some(V):!(!X||typeof X!="object")&&Object.values(X).some(V))}(_e)}class uo{constructor(B){this.keyCache=Object.create(null),this._layers=Object.create(null),this._layerConfigs=Object.create(null),B&&this.replace(B)}replace(B,V){this._layerConfigs=Object.create(null),this._layers=Object.create(null),this.update(B,[],V)}update(B,V,X){this._options=X;for(let le of B)this._layerConfigs[le.id]=le,(this._layers[le.id]=U.dh(le,this.scope,null,this._options)).compileFilter(X),this.keyCache[le.id]&&delete this.keyCache[le.id];for(let le of V)delete this.keyCache[le],delete this._layerConfigs[le],delete this._layers[le];this.familiesBySource=Object.create(null);let ae=function(le,ce){let we=Object.create(null);for(let ye=0;ye<le.length;ye++){let Ne=le[ye],Oe=ce&&ce[Ne.id];Oe||(Ne.type==="symbol"?Oe=Ne.id:(Oe=Cr(Ne),Ne.type==="line"&&Ne.paint&&Yr(Ne.paint["line-width"],"line-progress")&&(Oe+=`/${gi(Ne.paint["line-width"])}`))),ce&&(ce[Ne.id]=Oe);let Ke=we[Oe];Ke||(Ke=we[Oe]=[]),Ke.push(Ne)}let ne=[];for(let ye in we)ne.push(we[ye]);return ne}(Object.values(this._layerConfigs),this.keyCache);for(let le of ae){let ce=le.map(Ke=>this._layers[Ke.id]),we=ce[0];if(we.visibility==="none")continue;let ne=we.source||"",ye=this.familiesBySource[ne];ye||(ye=this.familiesBySource[ne]=Object.create(null));let Ne=we.sourceLayer||"_geojsonTileLayer",Oe=ye[Ne];Oe||(Oe=ye[Ne]=[]),Oe.push(ce)}}}let Jr=1*U.fe;class fs{constructor(B){let V={},X=[];for(let we in B){let ne=B[we],ye=V[we]={};for(let Ne in ne.glyphs){let Oe=ne.glyphs[+Ne];if(!Oe||Oe.bitmap.width===0||Oe.bitmap.height===0)continue;let Ke=Oe.metrics.localGlyph?Jr:1,ct={x:0,y:0,w:Oe.bitmap.width+2*Ke,h:Oe.bitmap.height+2*Ke};X.push(ct),ye[Ne]=ct}}let{w:ae,h:le}=U.F(X),ce=new U.fd({width:ae||1,height:le||1});for(let we in B){let ne=B[we];for(let ye in ne.glyphs){let Ne=ne.glyphs[+ye];if(!Ne||Ne.bitmap.width===0||Ne.bitmap.height===0)continue;let Oe=V[we][ye],Ke=Ne.metrics.localGlyph?Jr:1;U.fd.copy(Ne.bitmap,ce,{x:0,y:0},{x:Oe.x+Ke,y:Oe.y+Ke},Ne.bitmap)}}this.image=ce,this.positions=V}}function Kl(_e,B,V){_e[B]?V&&(_e[B].center=V):_e[B]={floorIds:new Set,center:V||[0,0],floors:{}}}function Rt(_e,B,V,X){for(let ae of B)Kl(_e,ae),_e[ae].floors[V]=X,_e[ae].floorIds.add(V)}function mr(_e){return{id:_e.properties.id.toString(),center:[_e.properties.center_lon||0,_e.properties.center_lat||0]}}function xi(_e,B){let V=_e.properties.id.toString(),X=!!_e.properties.is_default&&_e.properties.is_default,ae=_e.properties.connected_floor_ids?new Set(_e.properties.connected_floor_ids.toString().split(";")):new Set,le=_e.properties.conflicted_floor_ids?new Set(_e.properties.conflicted_floor_ids.toString().split(";")):new Set,ce=_e.properties.structure_ids?new Set(_e.properties.structure_ids.toString().split(";")):new Set,we=_e.properties.name.toString(),ne=_e.properties.z_index,ye=function(Ne,Oe){let Ke=Ne.loadGeometry();if(!Ke||Ke.length===0)return;let ct=Ke.map(ht=>ht.map(Lt=>U.ff(Lt,Oe,Ne.extent)));return ct.length===0?void 0:{type:"Polygon",coordinates:[ct[0]]}}(_e,B);return{id:V,isDefault:X,connections:ae,conflicts:le,buildings:ce,name:we,zIndex:ne,geometry:ye}}function Gn(_e,B){return B.every(V=>_e.properties&&_e.properties[V]!=null)}function Zn(_e){return Gn(_e,["type","id","name"])&&_e.properties.type==="structure"}function Vo(_e){return Gn(_e,["type","id","name","z_index"])&&_e.properties.type==="floor"}U.fc(fs,"GlyphAtlas");class jo{constructor(B){this.tileID=new U.aU(B.tileID.overscaledZ,B.tileID.wrap,B.tileID.canonical.z,B.tileID.canonical.x,B.tileID.canonical.y),this.tileZoom=B.tileZoom,this.uid=B.uid,this.zoom=B.zoom,this.lut=B.lut,this.canonical=B.tileID.canonical,this.pixelRatio=B.pixelRatio,this.tileSize=B.tileSize,this.source=B.source,this.scope=B.scope,this.overscaling=this.tileID.overscaleFactor(),this.showCollisionBoxes=B.showCollisionBoxes,this.showElevationIdDebug=B.showElevationIdDebug,this.collectResourceTiming=!!B.request&&B.request.collectResourceTiming,this.promoteId=B.promoteId,this.renderSourceType=B.renderSourceType,this.tileTransform=U.fg(B.tileID.canonical,B.projection),this.projection=B.projection,this.worldview=B.worldview,this.localizableLayerIds=B.localizableLayerIds,this.brightness=B.brightness,this.extraShadowCaster=!!B.extraShadowCaster,this.tessellationStep=B.tessellationStep,this.scaleFactor=B.scaleFactor,this.worldview=B.worldview,this.indoor=B.indoor}parse(B,V,X,ae,le,ce){this.status="parsing",this.data=B,this.collisionBoxArray=new U.fh;let we=new U.fi(Object.keys(B.layers).sort()),ne=new U.fj(this.tileID,this.promoteId);ne.bucketLayerIDs=[];let ye={},Ne=new U.fk(256,256),Oe={featureIndex:ne,iconDependencies:new Map,patternDependencies:new Map,glyphDependencies:{},lineAtlas:Ne,availableImages:X,brightness:this.brightness,scaleFactor:this.scaleFactor,showElevationIdDebug:this.showElevationIdDebug,elevationFeatures:void 0,activeFloors:void 0};this.indoor&&(Oe.activeFloors=function(Lt,St,Mt,Ve){let Ut=St.indoorState.activeFloorsVisible;if(!St.sourceLayers)return Ut?St.indoorState.activeFloors:void 0;let $i=function(ti,Ci){if(!ti)return U.w("No source layers defined in indoor specification"),Ci;if(ti.size===0)return Ci;let nn=ti.difference(Ci);for(let ii of nn)U.w(`Missing source layer required in indoor specification: ${ii}`);return Ci.intersection(Ci)}(St.sourceLayers,new Set(Object.keys(Lt.layers))),Hi=St.indoorState,Ot=function(ti,Ci,nn,ii,Ai){let Bi={};for(let vi of Ci){let Wi=ti.layers[vi];if(Wi)for(let Bn=0;Bn<Wi.length;Bn++){let yn=Wi.feature(Bn);if(Zn(yn)){let{id:zn,center:zr}=mr(yn);Kl(Bi,zn,zr);continue}if(Vo(yn)){let zn=xi(yn,Ai);Rt(Bi,zn.buildings,zn.id,zn)}}else U.w(`indoor source layer not found: ${vi}`)}return{buildings:Bi,activeFloors:U.d3.calculate(Bi,ii,nn)}}(Lt,$i,Hi.activeFloors,Hi.selectedFloorId,Ve);return Mt.send("setIndoorData",Ot),Ut?Ot.activeFloors:void 0}(B,this.indoor,le,this.canonical));let Ke=[],ct=V.familiesBySource[this.source];for(let Lt in ct){let St=B.layers[Lt];
7if(!St)continue;let Mt=!1,Ve=!1,Ut=!1,$i=!1;for(let nn of ct[Lt])nn[0].type==="symbol"?Mt=!0:nn[0].type==="fill-extrusion"?Ve=!0:Ut=!0,nn[0].is3D()&&nn[0].type!=="model"&&($i=!0);if(this.extraShadowCaster&&!$i||this.renderSourceType===U.b7.Symbol&&!Mt||this.renderSourceType===U.b7.FillExtrusion&&!Ve||this.renderSourceType===U.b7.Other&&!Ut)continue;St.version===1&&U.w(`Vector tile source "${this.source}" layer "${Lt}" does not use vector tile spec v2 and therefore may have some rendering errors.`);let Hi=we.encode(Lt),Ot=[],ti=this.localizableLayerIds&&this.localizableLayerIds.has(Lt),Ci=!1;for(let nn=0,ii=0;nn<St.length;nn++){let Ai=St.feature(nn),Bi=ne.getId(Ai,Lt),vi=Ai.properties?Ai.properties.worldview:null;if(ti&&this.worldview&&typeof vi=="string")if(vi==="all")Ai.properties.$localized=!0;else{if(!vi.split(",").includes(this.worldview))continue;Ai.properties.$localized=!0,Ai.properties.worldview=this.worldview}!Ci&&Ai.properties&&Object.hasOwn(Ai.properties,U.fl)&&(Ci=!0),Ot.push({feature:Ai,id:Bi,index:ii,sourceLayerIndex:Hi}),ii++}Ci&&!Oe.elevationFeatures&&Object.hasOwn(B.layers,U.fm)&&(Oe.elevationFeatures=U.fn.parseFrom(B.layers[U.fm],this.canonical));for(let nn of ct[Lt]){let ii=nn[0];if(this.extraShadowCaster&&(!ii.is3D()||ii.type==="model")||this.renderSourceType===U.b7.Symbol&&ii.type!=="symbol"||this.renderSourceType===U.b7.FillExtrusion&&ii.type!=="fill-extrusion"||this.renderSourceType===U.b7.Other&&(ii.type==="symbol"||ii.type==="fill-extrusion")||ii.minzoom&&this.zoom<Math.floor(ii.minzoom)||ii.maxzoom&&this.zoom>=ii.maxzoom||ii.visibility==="none")continue;ho(nn,this.zoom,Oe.brightness,X,this.worldview,Oe.activeFloors);let Ai=()=>{let Bi=ye[ii.id]=ii.createBucket({index:ne.bucketLayerIDs.length,layers:nn,zoom:this.zoom,lut:this.lut,canonical:this.canonical,pixelRatio:this.pixelRatio,overscaling:this.overscaling,collisionBoxArray:this.collisionBoxArray,sourceLayerIndex:Hi,sourceID:this.source,projection:this.projection.spec,tessellationStep:this.tessellationStep,styleDefinedModelURLs:ae,worldview:this.worldview,localizable:ti,availableImages:X,maxUniformBufferBindings:this.maxUniformBufferBindings,maxUniformBlockSizeDwords:this.maxUniformBlockSizeDwords,disableSymbolUBO:this.disableSymbolUBO});ne.bucketLayerIDs.push(nn.map(vi=>U.t(vi.id,vi.scope))),Bi.populate(Ot,Oe,this.tileID.canonical,this.tileTransform)};if("prepare"in ii){let Bi=ii.prepare().then(()=>Ai());Ke.push(Bi)}else Ai()}}let ht=()=>{Ne.trim();let Lt=!(!Oe.elevationFeatures||!Oe.elevationFeatures.some(ii=>ii.heightRange.min<0)),St,Mt,Ve,Ut,$i,Hi,Ot,ti={type:"maybePrepare",renderSourceType:this.renderSourceType,zoom:this.zoom},Ci=()=>{if(St)return this.status="done",ce(St);if(this.extraShadowCaster)this.status="done",ce(null,{buckets:Object.values(ye).filter(ii=>!ii.isEmpty()),featureIndex:ne,collisionBoxArray:null,hasTunnelGeometry:Lt,glyphAtlasImage:null,lineAtlas:null,imageAtlas:null,brightness:Oe.brightness,glyphMap:null,iconMap:null,glyphPositions:null});else if(Mt&&Ve&&Ut&&Ot){let Ai=new fs(Mt),Bi=new Map;for(let[Wi,Bn]of Ve.entries()){let{imagePosition:yn}=U.fr(Wi,Bn,U.fs);Bi.set(Wi,yn)}let vi={};for(let Wi in ye){let Bn=ye[Wi];Bn instanceof U.ft&&(ho(Bn.layers,this.zoom,Oe.brightness,X,this.worldview,Oe.activeFloors),vi[Wi]=U.fu(Bn,Mt,Ai.positions,Ve,Bi,this.tileID.canonical,this.tileZoom,this.scaleFactor,this.pixelRatio,$i,this.worldview,X))}$i.size||Hi.size?this.rasterizeTask=le.send("rasterizeImages",{scope:this.scope,iconTasks:$i,patternTasks:Hi},(Wi,Bn)=>{if(!Wi)for(let[yn,zn]of Bn.entries())Ve.has(yn)&&Ve.set(yn,Object.assign(Ve.get(yn),{data:zn})),Ut.has(yn)&&Ut.set(yn,Object.assign(Ut.get(yn),{data:zn}));nn(vi,Ai,void 0,Ot)}):nn(vi,Ai,void 0,Ot)}},nn=(ii,Ai,Bi,vi)=>{let Wi=Ve.size>0||Ut.size>0,Bn=Object.keys(ii).length>0;if(!Wi&&!Bn)return this.status="done",void ce(null,{buckets:Object.values(ye).filter(zn=>!zn.isEmpty()),featureIndex:ne,collisionBoxArray:this.collisionBoxArray,hasTunnelGeometry:Lt,glyphAtlasImage:Ai.image,lineAtlas:Ne,imageAtlas:null,brightness:Oe.brightness});let yn=(zn,zr)=>{for(let go in ye){let di=ye[go];if(go in ii)U.fz(di,ii[go],this.showCollisionBoxes,X,this.tileID.canonical,this.tileZoom,this.projection,this.brightness,Ve,zr);else if(di.hasPattern&&(di instanceof U.fA||di instanceof U.fp||di instanceof U.e3)){ho(di.layers,this.zoom,Oe.brightness,X,this.worldview,Oe.activeFloors);let ha=Object.fromEntries(zr.patternPositions);di.addFeatures(Oe,this.tileID.canonical,ha,X,this.tileTransform,this.brightness)}}this.status="done",ce(null,{buckets:Object.values(ye).filter(go=>!go.isEmpty()),featureIndex:ne,collisionBoxArray:this.collisionBoxArray,hasTunnelGeometry:Lt,glyphAtlasImage:Ai.image,lineAtlas:Ne,imageAtlas:zn,brightness:Oe.brightness})};if(Wi){let zn=new Map,zr=U.fv(Ve,zn),go=U.fv(Ut,zn),di=new U.fw(zr,go,vi,this.lut,zn);le.send("checkAtlasCache",{descriptor:di,scope:this.scope},(ha,da)=>{let pa,vs;if(ha&&U.w(`[Worker] Error checking atlas cache: ${ha.message}`),da)pa=new U.fx(da.sourceHash),vs=da;
7else{let tl=new U.fy(Ve,Ut,this.lut,vi);pa=tl,vs=tl}yn(pa,vs)})}else yn(null,{iconPositions:new Map,patternPositions:new Map})};if(!this.extraShadowCaster){let ii=U.fo(Oe.glyphDependencies,vi=>Object.keys(vi).map(Number));Object.keys(ii).length?le.send("getGlyphs",{uid:this.uid,stacks:ii},(vi,Wi)=>{St||(St=vi,Mt=Wi,Ci())},void 0,!1,ti):Mt={},Ot=new Map;let Ai=Array.from(Oe.iconDependencies.keys()).map(vi=>U.I.parse(vi)),Bi=Array.from(Oe.patternDependencies.keys()).map(vi=>U.I.parse(vi));Ai.length||Bi.length?le.send("getImages",{icons:Ai,patterns:Bi,source:this.source,scope:this.scope,tileID:this.tileID},(vi,Wi)=>{if(!St){St=vi,Ve=new Map,Ut=new Map,$i=this.updateImageMapAndGetImageTaskQueue(Ve,Wi.images,Oe.iconDependencies),Hi=this.updateImageMapAndGetImageTaskQueue(Ut,Wi.images,Oe.patternDependencies);for(let[Bn,yn]of Wi.versions.entries())Ot.set(Bn,yn);Ci()}},void 0,!1,ti):(Ve=new Map,Ut=new Map,$i=new Map,Hi=new Map)}if(Oe.elevationFeatures&&Oe.elevationFeatures.length>0){let ii=[];for(let Bi of Object.values(ye))if(Bi instanceof U.fp){let vi=Bi.getUnevaluatedPortalGraph();vi&&ii.push(vi)}let Ai=U.fq.evaluate(ii);for(let Bi of Object.values(ye))if(Bi instanceof U.fp){let vi=B.layers[we.decode(Bi.sourceLayerIndex)];Bi.setEvaluatedPortalGraph(Ai,vi,this.tileID.canonical,Oe.availableImages,Oe.brightness)}}Ci()};Ke.length>0?Promise.allSettled(Ke).then(ht).catch(ce):ht()}updateParameters(B){this.scaleFactor=B.scaleFactor,this.showCollisionBoxes=B.showCollisionBoxes,this.showElevationIdDebug=B.showElevationIdDebug,this.projection=B.projection,this.brightness=B.brightness,this.tileTransform=U.fg(B.tileID.canonical,B.projection),this.extraShadowCaster=B.extraShadowCaster,this.lut=B.lut,this.worldview=B.worldview,this.indoor=B.indoor}updateImageMapAndGetImageTaskQueue(B,V,X){let ae=new Map;for(let le of V.keys()){let ce=X.get(le)||[];for(let we of ce){let ne=we.toString(),ye=V.get(we.id.toString());ye.usvg?ae.has(ne)||(ae.set(ne,we),B.set(ne,Object.assign({},ye))):B.set(ne,ye)}}return ae}cancelRasterize(){this.rasterizeTask&&this.rasterizeTask.cancel()}}function ho(_e,B,V,X,ae,le){let ce=new U.ab(B,{brightness:V,worldview:ae,activeFloors:le});for(let we of _e)we.recalculate(ce,X)}class ms extends U.E{constructor({actor:B,layerIndex:V,availableImages:X,availableModels:ae,isSpriteLoaded:le,tileProvider:ce,brightness:we,maxUniformBufferBindings:ne,maxUniformBlockSizeDwords:ye,disableSymbolUBO:Ne}){super(),this.actor=B,this.layerIndex=V,this.availableImages=X,this.availableModels=ae,this.loadVectorData=U.aQ,this.tileProvider=ce,this.loading={},this.loaded={},this.deduped=new U.aL(B.scheduler),this.isSpriteLoaded=le,this.scheduler=B.scheduler,this.brightness=we,this.maxUniformBufferBindings=ne,this.maxUniformBlockSizeDwords=ye,this.disableSymbolUBO=Ne}loadTileData(B,V){if(!this.tileProvider)return this.loadVectorData(B,V);let X=new AbortController;return this.loadTileWithProvider(this.tileProvider,B,X,V),()=>X.abort()}async loadTileWithProvider(B,V,X,ae){let{z:le,x:ce,y:we}=V.tileID.canonical;try{let ne=await B.loadTile({z:le,x:ce,y:we},{request:V.request,signal:X.signal});if(X.signal.aborted)return;if(ne==null){let Ne=new Error("Tile not found");return Ne.status=404,ae(Ne)}if(ne.data==null)return ae(null,null);let ye=new Map;ne.expires&&ye.set("expires",ne.expires),ne.cacheControl&&ye.set("cache-control",ne.cacheControl),ae(null,{rawData:ne.data,responseHeaders:ye})}catch(ne){if(X.signal.aborted)return;ae(ne instanceof Error?ne:new Error(String(ne)))}}loadTile(B,V){let X=B.uid,ae=B&&B.request,le=ae&&ae.collectResourceTiming,ce=this.loading[X]=new jo(B);ce.maxUniformBufferBindings=this.maxUniformBufferBindings,ce.maxUniformBlockSizeDwords=this.maxUniformBlockSizeDwords,ce.disableSymbolUBO=this.disableSymbolUBO,ce.abort=this.loadTileData(B,(we,ne)=>{let ye=!this.loading[X];if(delete this.loading[X],ce.cancelRasterize(),ye||we||!ne)return ce.status="done",ye||(this.loaded[X]=ce),V(we);let Ne=ne.rawData,Oe={},Ke=U.aR(ne.responseHeaders);Ke&&Ke.expires&&(Oe.expires=Ke.expires),Ke&&Ke.cacheControl&&(Oe.cacheControl=Ke.cacheControl),ce.vectorTile=ne.vectorTile||new U.fB(new U.b2(Ne));let ct=()=>{ce.parse(ce.vectorTile,this.layerIndex,this.availableImages,this.availableModels,this.actor,(ht,Lt)=>{if(ht||!Lt)return V(ht);let St={};if(le){let Mt=ln(ae);Mt.length>0&&(St.resourceTiming=JSON.parse(JSON.stringify(Mt)))}V(null,Object.assign({rawTileData:Ne.slice(0),responseHeaders:ne.responseHeaders},Lt,Oe,St))})};this.isSpriteLoaded?ct():this.once("isSpriteLoaded",()=>{this.scheduler?this.scheduler.add(ct,{type:"parseTile",renderSourceType:B.renderSourceType,zoom:B.tileZoom}):ct()}),this.loaded=this.loaded||{},this.loaded[X]=ce})}reloadTile(B,V){let X=this.loaded,ae=B.uid;if(X&&X[ae]){let le=X[ae];le.updateParameters(B);let ce=(we,ne)=>{let ye=le.reloadCallback;ye&&(delete le.reloadCallback,le.parse(le.vectorTile,this.layerIndex,this.availableImages,this.availableModels,this.actor,ye)),V(we,ne)};le.status==="parsing"?le.reloadCallback=ce:le.status==="done"&&(le.vectorTile?le.parse(le.vectorTile,this.layerIndex,this.availableImages,this.availableModels,this.actor,ce):ce())}else V(null,void 0)}abortTile(B,V){let X=B.uid,ae=this.loading[X];ae&&(ae.abort&&ae.abort(),delete this.loading[X]),V()}removeTile(B,V){let X=this.loaded,ae=B.uid;X&&X[ae]&&delete X[ae],V()}}class Go{constructor(B){this.tileProvider=B.tileProvider,this.loading={}}loadTile(B,V){let X=B.uid;if(this.tileProvider){let le=new AbortController;return this.loading[X]={cancel:()=>le.abort()},void this.loadTileWithProvider(this.tileProvider,X,B,le,V)}let{cancel:ae}=U.b4(B.request,(le,ce,we)=>{let ne=!this.loading[X];if(delete this.loading[X],ne||le||!ce)return V(le);this.decodeTile(X,ce,B.encoding).then(ye=>{let{expires:Ne,cacheControl:Oe}=U.aR(we);V(null,Object.assign(ye,{expires:Ne,cacheControl:Oe}))}).catch(ye=>V(ye))});this.loading[X]={cancel:ae}}
7async decodeTile(B,V,X){let ae=await createImageBitmap(new Blob([new Uint8Array(V)],{type:"image/png"})),le=1-(ae.width-U.fC(ae.width))/2,ce=le<1,we=this.getImageData(ae,le);return ae.close(),{dem:new U.fD(B,we,X,ce),borderReady:ce}}async loadTileWithProvider(B,V,X,ae,le){let{z:ce,x:we,y:ne}=X.tileID.canonical;try{let ye=await B.loadTile({z:ce,x:we,y:ne},{request:X.request,signal:ae.signal});if(ae.signal.aborted)return le(null,null);if(ye==null){let Oe=new Error("Tile not found");return Oe.status=404,le(Oe)}if(ye.data==null)return le(null,null);let Ne=await this.decodeTile(V,ye.data,X.encoding);if(ae.signal.aborted)return le(null,null);le(null,Object.assign(Ne,{expires:ye.expires,cacheControl:ye.cacheControl}))}catch(ye){if(ae.signal.aborted||ye instanceof DOMException&&ye.name==="AbortError")return le(null,null);le(ye instanceof Error?ye:new Error(String(ye)))}finally{delete this.loading[V]}}reloadTile(B,V){V(null,null)}abortTile(B,V){let X=B.uid,ae=this.loading[X];ae&&(ae.cancel(),delete this.loading[X]),V()}removeTile(B,V){V()}getImageData(B,V){this.offscreenCanvas&&this.offscreenCanvasContext||(this.offscreenCanvas=new OffscreenCanvas(B.width,B.height),this.offscreenCanvasContext=this.offscreenCanvas.getContext("2d",{willReadFrequently:!0})),this.offscreenCanvas.width=B.width,this.offscreenCanvas.height=B.height,this.offscreenCanvasContext.drawImage(B,0,0,B.width,B.height);let X=this.offscreenCanvasContext.getImageData(-V,-V,B.width+2*V,B.height+2*V);return this.offscreenCanvasContext.clearRect(0,0,this.offscreenCanvas.width,this.offscreenCanvas.height),X}}U.b1.setPbf(U.b2);class ta{constructor(B){this._mrt=new U.b1(B.partial?30:1/0),this._isHeaderLoaded=!1,this.uid=B.uid,this.tileID=B.tileID,this.source=B.source}parse(B,V){let X=this._mrt;this.status="parsing",this._entireBuffer=B;try{X.parseHeader(B),this._isHeaderLoaded=!0;let ae=[];for(let le in X.layers){let ce=X.getLayer(le),we=ce.getDataRange(ce.getBandList()),ne=X.createDecodingTask(we),ye=B.slice(we.firstByte,we.lastByte+1),Ne=U.b1.performDecoding(ye,ne).then(Oe=>ne.complete(null,Oe)).catch(Oe=>ne.complete(Oe,null));ae.push(Ne)}Promise.allSettled(ae).then(()=>V(null,X)).catch(le=>V(le))}catch(ae){V(ae)}}}class Ql{constructor({actor:B}){this.actor=B,this.loading={},this.loaded={}}loadTile(B,V){let X=B.uid,ae=B.request,le=this.loading[X]=new ta(B),{cancel:ce}=U.b4(ae,(we,ne,ye)=>{let Ne=!this.loading[X];if(delete this.loading[X],Ne||we||!ne)return le.status="done",Ne||(this.loaded[X]=le),V(we);le.parse(ne,(Oe,Ke)=>{if(Oe||!Ke)return V(Oe);V(null,Ke,ye)}),this.loaded[X]=le});le.abort=ce}reloadTile(B,V){V(null,void 0)}abortTile(B,V){let X=B.uid,ae=this.loading[X];ae&&(ae.abort&&ae.abort(),delete this.loading[X]),V()}removeTile(B,V){let X=B.uid;this.loaded[X]&&delete this.loaded[X],V()}decodeRasterArray(B,V){U.b1.performDecoding(B.buffer,B.task).then(X=>V(null,X)).catch(X=>V(X))}}let ec=U.fE.prototype.toGeoJSON;class tc{constructor(B){this._feature=B,this.extent=U.ak,this.type=B.type,this.properties=B.tags,"id"in B&&!isNaN(B.id)&&(this.id=parseInt(B.id,10))}loadGeometry(){if(this._feature.type===1){let B=[];for(let V of this._feature.geometry)B.push([new U.P(V[0],V[1])]);return B}{let B=[];for(let V of this._feature.geometry){let X=[];for(let ae of V)X.push(new U.P(ae[0],ae[1]));B.push(X)}return B}}toGeoJSON(B,V,X){return ec.call(this,B,V,X)}}class si{constructor(B,V){this.name=B,this.extent=U.ak,this.length=V.length,this._jsonFeatures=V}feature(B){return new tc(this._jsonFeatures[B])}}class ic{constructor(B){this.layers={},this.extent=U.ak;for(let V of Object.keys(B))this.layers[V]=new si(V,B[V])}}let Dn=64/4096;class Fn{constructor(){this.features=new Map}clear(){this.features.clear()}load(B=[],V){for(let X of B){let ae=X.id;if(ae==null)continue;let le=this.features.get(ae);le&&this.updateCache(le,V),X.geometry?(le=tn(X),this.updateCache(le,V),this.features.set(ae,le)):this.features.delete(ae),this.updateCache(le,V)}}updateCache(B,V){for(let{canonical:X,uid:ae}of Object.values(V)){let{z:le,x:ce,y:we}=X;Ei(B,Math.pow(2,le),ce,we)&&delete V[ae]}}getTile(B,V,X){let ae=Math.pow(2,B),le=[];for(let ce of this.features.values())Ei(ce,ae,V,X)&&le.push(Pr(ce,ae,V,X));return{features:le}}getFeatures(){return[...this.features.values()]}}function Ei({minX:_e,minY:B,maxX:V,maxY:X},ae,le,ce){return _e<(le+1+Dn)/ae&&B<(ce+1+Dn)/ae&&V>(le-Dn)/ae&&X>(ce-Dn)/ae}function tn(_e){let{id:B,geometry:V,properties:X}=_e;if(!V)return;
7if(V.type==="GeometryCollection")throw new Error("GeometryCollection not supported in dynamic mode.");let{type:ae,coordinates:le}=V,ce={id:B,type:1,geometry:[],tags:X,minX:1/0,minY:1/0,maxX:-1/0,maxY:-1/0},we=ce.geometry;if(ae==="Point")po(le,we,ce);else if(ae==="MultiPoint")for(let ne of le)po(ne,we,ce);else if(ae==="LineString")ce.type=2,nc(le,we,ce);else if(ae==="MultiLineString")ce.type=2,Rn(le,we,ce);else if(ae==="Polygon")ce.type=3,Rn(le,we,ce,!0);else{if(ae!=="MultiPolygon")throw new Error("Input data is not a valid GeoJSON object.");ce.type=3;for(let ne of le)Rn(ne,we,ce,!0)}return ce}function po([_e,B],V,X){let ae=U.aG(_e),le=U.aJ(B);le=le<0?0:le>1?1:le,V.push(ae,le),X.minX=Math.min(X.minX,ae),X.minY=Math.min(X.minY,le),X.maxX=Math.max(X.maxX,ae),X.maxY=Math.max(X.maxY,le)}function nc(_e,B,V,X=!1,ae=!1){let le=[];for(let ce of _e)po(ce,le,V);B.push(le),X&&function(ce,we){let ne=0;for(let ye=0,Ne=ce.length,Oe=Ne-2;ye<Ne;Oe=ye,ye+=2)ne+=(ce[ye]-ce[Oe])*(ce[ye+1]+ce[Oe+1]);if(ne>0===we)for(let ye=0,Ne=ce.length;ye<Ne/2;ye+=2){let Oe=ce[ye],Ke=ce[ye+1];ce[ye]=ce[Ne-2-ye],ce[ye+1]=ce[Ne-1-ye],ce[Ne-2-ye]=Oe,ce[Ne-1-ye]=Ke}}(le,ae)}function Rn(_e,B,V,X=!1){for(let ae=0;ae<_e.length;ae++)nc(_e[ae],B,V,X,ae===0)}function Pr(_e,B,V,X){let{id:ae,type:le,geometry:ce,tags:we}=_e,ne=[];if(le===1)(function(ye,Ne,Oe,Ke,ct){for(let ht=0;ht<ye.length;ht+=2){let Lt=Math.round(U.ak*(ye[ht+0]*Ne-Oe)),St=Math.round(U.ak*(ye[ht+1]*Ne-Ke));ct.push([Lt,St])}})(ce,B,V,X,ne);else if(le===2)for(let ye of ce)Li(ye,B,V,X,ne);else if(le===3)for(let ye of ce)Dr(ye,B,V,X,ne);return{id:ae,type:le,geometry:ne,tags:we}}function Li(_e,B,V,X,ae){let ce=U.ak+128,we;for(let ne=0;ne<_e.length-2;ne+=2){let ye=Math.round(U.ak*(_e[ne+0]*B-V)),Ne=Math.round(U.ak*(_e[ne+1]*B-X)),Oe=Math.round(U.ak*(_e[ne+2]*B-V)),Ke=Math.round(U.ak*(_e[ne+3]*B-X)),ct=Oe-ye,ht=Ke-Ne;ye<-128&&Oe<-128||(ye<-128?(Ne+=Math.round(ht*((-128-ye)/ct)),ye=-128):Oe<-128&&(Ke=Ne+Math.round(ht*((-128-ye)/ct)),Oe=-128),Ne<-128&&Ke<-128||(Ne<-128?(ye+=Math.round(ct*((-128-Ne)/ht)),Ne=-128):Ke<-128&&(Oe=ye+Math.round(ct*((-128-Ne)/ht)),Ke=-128),ye>=ce&&Oe>=ce||(ye>=ce?(Ne+=Math.round(ht*((ce-ye)/ct)),ye=ce):Oe>=ce&&(Ke=Ne+Math.round(ht*((ce-ye)/ct)),Oe=ce),Ne>=ce&&Ke>=ce||(Ne>=ce?(ye+=Math.round(ct*((ce-Ne)/ht)),Ne=ce):Ke>=ce&&(Oe=ye+Math.round(ct*((ce-Ne)/ht)),Ke=ce),we&&ye===we.at(-1)[0]&&Ne===we.at(-1)[1]||(we=[[ye,Ne]],ae.push(we)),we.push([Oe,Ke])))))}}function Dr(_e,B,V,X,ae){let le=(V-Dn)/B,ce=(X-Dn)/B,we=(V+1+Dn)/B,ne=(X+1+Dn)/B;function ye(Ke,ct){let ht=0;return Ke<le?ht|=1:Ke>we&&(ht|=2),ct<ce?ht|=4:ct>ne&&(ht|=8),ht}let Ne=[];for(let Ke=1;Ke<=8;Ke*=2){let ct=_e[_e.length-2],ht=_e.at(-1),Lt=!(ye(ct,ht)&Ke);for(let St=0;St<_e.length;St+=2){let Mt=_e[St],Ve=_e[St+1],Ut=!(ye(Mt,Ve)&Ke);Ut!==Lt&&(8&Ke?Ne.push(ct+(Mt-ct)*(ne-ht)/(Ve-ht),ne):4&Ke?Ne.push(ct+(Mt-ct)*(ce-ht)/(Ve-ht),ce):2&Ke?Ne.push(we,ht+(Ve-ht)*(we-ct)/(Mt-ct)):1&Ke&&Ne.push(le,ht+(Ve-ht)*(le-ct)/(Mt-ct))),Ut&&Ne.push(Mt,Ve),ct=Mt,ht=Ve,Lt=Ut}if(!(_e=Ne).length||Ke===8)break;Ne=[]}let Oe=[];for(let Ke=0;Ke<Ne.length;Ke+=2)Oe.push([Math.round(U.ak*(Ne[Ke]*B-V)),Math.round(U.ak*(Ne[Ke+1]*B-X))]);Oe.length&&ae.push(Oe)}function ia({name:_e,features:B},V){V.writeStringField(1,_e),V.writeVarintField(5,U.ak);let X=new Map,ae=new Map,le={keys:X,values:ae,feature:null};for(let ce of B)le.feature=ce,V.writeMessage(2,$o,le);for(let ce of X.keys())V.writeStringField(3,ce);for(let ce of ae.keys())V.writeMessage(4,Wn,ce)}function $o(_e,B){let V=_e.feature;V.id!==void 0&&Number.isSafeInteger(+V.id)&&B.writeVarintField(1,+V.id),V.tags&&B.writeMessage(2,rc,_e),B.writeVarintField(3,V.type),B.writeMessage(4,Qi,V)}function rc({keys:_e,values:B,feature:V},X){for(let ae of Object.keys(V.tags)){let le=V.tags[ae];if(le===null)continue;let ce=_e.get(ae);ce===void 0&&(ce=_e.size,_e.set(ae,ce)),X.writeVarint(ce);let we=typeof le;we!=="string"&&we!=="boolean"&&we!=="number"&&(le=JSON.stringify(le));let ne=B.get(le);ne===void 0&&(ne=B.size,B.set(le,ne)),X.writeVarint(ne)}}function fo(_e,B){return(B<<3)+(7&_e)}function hi(_e){return _e<<1^_e>>31}function Qi(_e,B){let{geometry:V,type:X}=_e,ae=0,le=0;if(X===1){B.writeVarint(fo(1,V.length));for(let ce of V){let we=ce[0]-ae,ne=ce[1]-le;B.writeVarint(hi(we)),B.writeVarint(hi(ne)),ae+=we,le+=ne}}else for(let ce of V){if(ce.length===0)continue;B.writeVarint(fo(1,1));let we=ce.length-(X===3?1:0);for(let ne=0;ne<we;ne++){ne===1&&B.writeVarint(fo(2,we-1));let ye=ce[ne][0]-ae,Ne=ce[ne][1]-le;B.writeVarint(hi(ye)),B.writeVarint(hi(Ne)),ae+=ye,le+=Ne}X===3&&B.writeVarint(fo(7,1))}}function Wn(_e,B){let V=typeof _e;
7V==="string"?B.writeStringField(1,_e):V==="boolean"?B.writeBooleanField(7,_e):V==="number"&&(_e%1!=0?B.writeDoubleField(3,_e):_e<0?B.writeSVarintField(6,_e):B.writeVarintField(5,_e))}let na={minZoom:0,maxZoom:16,minPoints:2,radius:40,extent:512,nodeSize:64,log:!1,generateId:!1,reduce:null,map:_e=>_e},Oi=Math.fround||(_s=new Float32Array(1),_e=>(_s[0]=+_e,_s[0]));var _s;class Za{constructor(B){this.options=Object.assign(Object.create(na),B),this.trees=new Array(this.options.maxZoom+1),this.stride=this.options.reduce?7:6,this.clusterProps=[]}load(B){let{log:V,minZoom:X,maxZoom:ae}=this.options;V&&console.time("total time");let le=`prepare ${B.length} points`;V&&console.time(le),this.points=B;let ce=[];for(let ne=0;ne<B.length;ne++){let ye=B[ne];if(!ye.geometry)continue;let[Ne,Oe]=ye.geometry.coordinates,Ke=Oi(Gi(Ne)),ct=Oi(Xa(Oe));ce.push(Ke,ct,1/0,ne,-1,1),this.options.reduce&&ce.push(0)}let we=this.trees[ae+1]=this._createTree(ce);V&&console.timeEnd(le);for(let ne=ae;ne>=X;ne--){let ye=+Date.now();we=this.trees[ne]=this._createTree(this._cluster(we,ne)),V&&console.log("z%d: %d clusters in %dms",ne,we.numItems,+Date.now()-ye)}return V&&console.timeEnd("total time"),this}getClusters(B,V){let X=((B[0]+180)%360+360)%360-180,ae=Math.max(-90,Math.min(90,B[1])),le=B[2]===180?180:((B[2]+180)%360+360)%360-180,ce=Math.max(-90,Math.min(90,B[3]));if(B[2]-B[0]>=360)X=-180,le=180;else if(X>le){let Oe=this.getClusters([X,ae,180,ce],V),Ke=this.getClusters([-180,ae,le,ce],V);return Oe.concat(Ke)}let we=this.trees[this._limitZoom(V)],ne=we.range(Gi(X),Xa(ce),Gi(le),Xa(ae)),ye=we.data,Ne=[];for(let Oe of ne){let Ke=this.stride*Oe;Ne.push(ye[Ke+5]>1?Wa(ye,Ke,this.clusterProps):this.points[ye[Ke+3]])}return Ne}getChildren(B){let V=this._getOriginId(B),X=this._getOriginZoom(B),ae="No cluster with the specified id.",le=this.trees[X];if(!le)throw new Error(ae);let ce=le.data;if(V*this.stride>=ce.length)throw new Error(ae);let we=this.options.radius/(this.options.extent*Math.pow(2,X-1)),ne=le.within(ce[V*this.stride],ce[V*this.stride+1],we),ye=[];for(let Ne of ne){let Oe=Ne*this.stride;ce[Oe+4]===B&&ye.push(ce[Oe+5]>1?Wa(ce,Oe,this.clusterProps):this.points[ce[Oe+3]])}if(ye.length===0)throw new Error(ae);return ye}getLeaves(B,V,X){let ae=[];return this._appendLeaves(ae,B,V=V||10,X=X||0,0),ae}getTile(B,V,X){let ae=this.trees[this._limitZoom(B)],le=Math.pow(2,B),{extent:ce,radius:we}=this.options,ne=we/ce,ye=(X-ne)/le,Ne=(X+1+ne)/le,Oe={features:[]};return this._addTileFeatures(ae.range((V-ne)/le,ye,(V+1+ne)/le,Ne),ae.data,V,X,le,Oe),V===0&&this._addTileFeatures(ae.range(1-ne/le,ye,1,Ne),ae.data,le,X,le,Oe),V===le-1&&this._addTileFeatures(ae.range(0,ye,ne/le,Ne),ae.data,-1,X,le,Oe),Oe.features.length?Oe:null}getClusterExpansionZoom(B){let V=this._getOriginZoom(B)-1;for(;V<=this.options.maxZoom;){let X=this.getChildren(B);if(V++,X.length!==1)break;B=X[0].properties.cluster_id}return V}_appendLeaves(B,V,X,ae,le){let ce=this.getChildren(V);for(let we of ce){let ne=we.properties;if(ne&&ne.cluster?le+ne.point_count<=ae?le+=ne.point_count:le=this._appendLeaves(B,ne.cluster_id,X,ae,le):le<ae?le++:B.push(we),B.length===X)break}return le}_createTree(B){let V=new U.bM(B.length/this.stride|0,this.options.nodeSize,Float32Array);for(let X=0;X<B.length;X+=this.stride)V.add(B[X],B[X+1]);return V.finish(),V.data=B,V}_addTileFeatures(B,V,X,ae,le,ce){for(let we of B){let ne=we*this.stride,ye=V[ne+5]>1,Ne,Oe,Ke;if(ye)Ne=Mo(V,ne,this.clusterProps),Oe=V[ne],Ke=V[ne+1];else{let Lt=this.points[V[ne+3]];Ne=Lt.properties;let[St,Mt]=Lt.geometry.coordinates;Oe=Gi(St),Ke=Xa(Mt)}let ct={type:1,geometry:[[Math.round(this.options.extent*(Oe*le-X)),Math.round(this.options.extent*(Ke*le-ae))]],tags:Ne},ht;ht=ye||this.options.generateId?V[ne+3]:this.points[V[ne+3]].id,ht!==void 0&&(ct.id=ht),ce.features.push(ct)}}_limitZoom(B){return Math.max(this.options.minZoom,Math.min(Math.floor(+B),this.options.maxZoom+1))}_cluster(B,V){let{radius:X,extent:ae,reduce:le,minPoints:ce}=this.options,we=X/(ae*Math.pow(2,V)),ne=B.data,ye=[],Ne=this.stride;for(let Oe=0;Oe<ne.length;Oe+=Ne){if(ne[Oe+2]<=V)continue;ne[Oe+2]=V;let Ke=ne[Oe],ct=ne[Oe+1],ht=B.within(ne[Oe],ne[Oe+1],we),Lt=ne[Oe+5],St=Lt;for(let Mt of ht){let Ve=Mt*Ne;ne[Ve+2]>V&&(St+=ne[Ve+5])}if(St>Lt&&St>=ce){let Mt,Ve=Ke*Lt,Ut=ct*Lt,$i=-1,Hi=(Oe/Ne<<5)+(V+1)+this.points.length;for(let Ot of ht){let ti=Ot*Ne;if(ne[ti+2]<=V)continue;ne[ti+2]=V;let Ci=ne[ti+5];Ve+=ne[ti]*Ci,Ut+=ne[ti+1]*Ci,ne[ti+4]=Hi,le&&(Mt||(Mt=this._map(ne,Oe,!0),$i=this.clusterProps.length,this.clusterProps.push(Mt)),le(Mt,this._map(ne,ti)))}ne[Oe+4]=Hi,ye.push(Ve/St,Ut/St,1/0,Hi,-1,St),le&&ye.push($i)}else{for(let Mt=0;Mt<Ne;Mt++)ye.push(ne[Oe+Mt]);if(St>1)for(let Mt of ht){let Ve=Mt*Ne;if(!(ne[Ve+2]<=V)){ne[Ve+2]=V;for(let Ut=0;Ut<Ne;Ut++)ye.push(ne[Ve+Ut])}}}}return ye}_getOriginId(B){return B-this.points.length>>5}_getOriginZoom(B){return(B-this.points.length)%32}_map(B,V,X){if(B[V+5]>1){let ce=this.clusterProps[B[V+6]];return X?Object.assign({},ce):ce}let ae=this.points[B[V+3]].properties,le=this.options.map(ae);return X&&le===ae?Object.assign({},le):le}}function Wa(_e,B,V){return{type:"Feature",id:_e[B+3],properties:Mo(_e,B,V),geometry:{type:"Point",coordinates:[(X=_e[B],360*(X-.5)),ra(_e[B+1])]}};var X}
7function Mo(_e,B,V){let X=_e[B+5],ae=X>=1e4?`${Math.round(X/1e3)}k`:X>=1e3?Math.round(X/100)/10+"k":X,le=_e[B+6],ce=le===-1?{}:Object.assign({},V[le]);return Object.assign(ce,{cluster:!0,cluster_id:_e[B+3],point_count:X,point_count_abbreviated:ae})}function Gi(_e){return _e/360+.5}function Xa(_e){let B=Math.sin(_e*Math.PI/180),V=.5-.25*Math.log((1+B)/(1-B))/Math.PI;return V<0?0:V>1?1:V}function ra(_e){let B=(180-360*_e)*Math.PI/180;return 360*Math.atan(Math.exp(B))/Math.PI-90}function Ya(_e,B,V,X){let ae=X,le=B+(V-B>>1),ce,we=V-B,ne=_e[B],ye=_e[B+1],Ne=_e[V],Oe=_e[V+1];for(let Ke=B+3;Ke<V;Ke+=3){let ct=oa(_e[Ke],_e[Ke+1],ne,ye,Ne,Oe);if(ct>ae)ce=Ke,ae=ct;else if(ct===ae){let ht=Math.abs(Ke-le);ht<we&&(ce=Ke,we=ht)}}ae>X&&(ce-B>3&&Ya(_e,B,ce,X),_e[ce+2]=ae,V-ce>3&&Ya(_e,ce,V,X))}function oa(_e,B,V,X,ae,le){let ce=ae-V,we=le-X;if(ce!==0||we!==0){let ne=((_e-V)*ce+(B-X)*we)/(ce*ce+we*we);ne>1?(V=ae,X=le):ne>0&&(V+=ce*ne,X+=we*ne)}return ce=_e-V,we=B-X,ce*ce+we*we}function Ho(_e,B,V,X){let ae={id:_e??null,type:B,geometry:V,tags:X,minX:1/0,minY:1/0,maxX:-1/0,maxY:-1/0};if(B==="Point"||B==="MultiPoint"||B==="LineString")_r(ae,V);else if(B==="Polygon")_r(ae,V[0]);else if(B==="MultiLineString")for(let le of V)_r(ae,le);else if(B==="MultiPolygon")for(let le of V)_r(ae,le[0]);return ae}function _r(_e,B){for(let V=0;V<B.length;V+=3)_e.minX=Math.min(_e.minX,B[V]),_e.minY=Math.min(_e.minY,B[V+1]),_e.maxX=Math.max(_e.maxX,B[V]),_e.maxY=Math.max(_e.maxY,B[V+1])}function gs(_e,B,V,X){if(!B.geometry)return;let ae=B.geometry.coordinates;if(ae&&ae.length===0)return;let le=B.geometry.type,ce=Math.pow(V.tolerance/((1<<V.maxZoom)*V.extent),2),we=[],ne=B.id;if(V.promoteId?ne=B.properties[V.promoteId]:V.generateId&&(ne=X||0),le==="Point")ys(ae,we);else if(le==="MultiPoint")for(let ye of ae)ys(ye,we);else if(le==="LineString")Ja(ae,we,ce,!1);else if(le==="MultiLineString"){if(V.lineMetrics){for(let ye of ae)we=[],Ja(ye,we,ce,!1),_e.push(Ho(ne,"LineString",we,B.properties));return}sa(ae,we,ce,!1)}else if(le==="Polygon")sa(ae,we,ce,!0);else{if(le!=="MultiPolygon"){if(le==="GeometryCollection"){for(let ye of B.geometry.geometries)gs(_e,{id:ne,geometry:ye,properties:B.properties},V,X);return}throw new Error("Input data is not a valid GeoJSON object.")}for(let ye of ae){let Ne=[];sa(ye,Ne,ce,!0),we.push(Ne)}}_e.push(Ho(ne,le,we,B.properties))}function ys(_e,B){B.push(gr(_e[0]),oc(_e[1]),0)}function Ja(_e,B,V,X){let ae,le,ce=0;for(let ne=0;ne<_e.length;ne++){let ye=gr(_e[ne][0]),Ne=oc(_e[ne][1]);B.push(ye,Ne,0),ne>0&&(ce+=X?(ae*Ne-ye*le)/2:Math.sqrt(Math.pow(ye-ae,2)+Math.pow(Ne-le,2))),ae=ye,le=Ne}let we=B.length-3;B[2]=1,Ya(B,0,we,V),B[we+2]=1,B.size=Math.abs(ce),B.start=0,B.end=B.size}function sa(_e,B,V,X){for(let ae=0;ae<_e.length;ae++){let le=[];Ja(_e[ae],le,V,X),B.push(le)}}function gr(_e){return _e/360+.5}function oc(_e){let B=Math.sin(_e*Math.PI/180),V=.5-.25*Math.log((1+B)/(1-B))/Math.PI;return V<0?0:V>1?1:V}function Rr(_e,B,V,X,ae,le,ce,we){if(X/=B,le>=(V/=B)&&ce<X)return _e;if(ce<V||le>=X)return null;let ne=[];for(let ye of _e){let Ne=ye.geometry,Oe=ye.type,Ke=ae===0?ye.minX:ye.minY,ct=ae===0?ye.maxX:ye.maxY;if(Ke>=V&&ct<X){ne.push(ye);continue}if(ct<V||Ke>=X)continue;let ht=[];if(Oe==="Point"||Oe==="MultiPoint")uu(Ne,ht,V,X,ae);else if(Oe==="LineString")sc(Ne,ht,V,X,ae,!1,we.lineMetrics);else if(Oe==="MultiLineString")mo(Ne,ht,V,X,ae,!1);else if(Oe==="Polygon")mo(Ne,ht,V,X,ae,!0);else if(Oe==="MultiPolygon")for(let Lt of Ne){let St=[];mo(Lt,St,V,X,ae,!0),St.length&&ht.push(St)}if(ht.length){if(we.lineMetrics&&Oe==="LineString"){for(let Lt of ht)ne.push(Ho(ye.id,Oe,Lt,ye.tags));continue}Oe!=="LineString"&&Oe!=="MultiLineString"||(ht.length===1?(Oe="LineString",ht=ht[0]):Oe="MultiLineString"),Oe!=="Point"&&Oe!=="MultiPoint"||(Oe=ht.length===3?"Point":"MultiPoint"),ne.pu
7sh(Ho(ye.id,Oe,ht,ye.tags))}}return ne.length?ne:null}function uu(_e,B,V,X,ae){for(let le=0;le<_e.length;le+=3){let ce=_e[le+ae];ce>=V&&ce<=X&&qo(B,_e[le],_e[le+1],_e[le+2])}}function sc(_e,B,V,X,ae,le,ce){let we=Xn(_e),ne=ae===0?aa:_o,ye,Ne,Oe=_e.start;for(let St=0;St<_e.length-3;St+=3){let Mt=_e[St],Ve=_e[St+1],Ut=_e[St+2],$i=_e[St+3],Hi=_e[St+4],Ot=ae===0?Mt:Ve,ti=ae===0?$i:Hi,Ci=!1;ce&&(ye=Math.sqrt(Math.pow(Mt-$i,2)+Math.pow(Ve-Hi,2))),Ot<V?ti>V&&(Ne=ne(we,Mt,Ve,$i,Hi,V),ce&&(we.start=Oe+ye*Ne)):Ot>X?ti<X&&(Ne=ne(we,Mt,Ve,$i,Hi,X),ce&&(we.start=Oe+ye*Ne)):qo(we,Mt,Ve,Ut),ti<V&&Ot>=V&&(Ne=ne(we,Mt,Ve,$i,Hi,V),Ci=!0),ti>X&&Ot<=X&&(Ne=ne(we,Mt,Ve,$i,Hi,X),Ci=!0),!le&&Ci&&(ce&&(we.end=Oe+ye*Ne),B.push(we),we=Xn(_e)),ce&&(Oe+=ye)}let Ke=_e.length-3,ct=_e[Ke],ht=_e[Ke+1],Lt=ae===0?ct:ht;Lt>=V&&Lt<=X&&qo(we,ct,ht,_e[Ke+2]),Ke=we.length-3,le&&Ke>=3&&(we[Ke]!==we[0]||we[Ke+1]!==we[1])&&qo(we,we[0],we[1],we[2]),we.length&&B.push(we)}function Xn(_e){let B=[];return B.size=_e.size,B.start=_e.start,B.end=_e.end,B}function mo(_e,B,V,X,ae,le){for(let ce of _e)sc(ce,B,V,X,ae,le,!1)}function qo(_e,B,V,X){_e.push(B,V,X)}function aa(_e,B,V,X,ae,le){let ce=(le-B)/(X-B);return qo(_e,le,V+(ae-V)*ce,1),ce}function _o(_e,B,V,X,ae,le){let ce=(le-V)/(ae-V);return qo(_e,B+(X-B)*ce,le,1),ce}function la(_e,B){let V=[];for(let X=0;X<_e.length;X++){let ae=_e[X],le=ae.type,ce;if(le==="Point"||le==="MultiPoint"||le==="LineString")ce=ca(ae.geometry,B);else if(le==="MultiLineString"||le==="Polygon"){ce=[];for(let we of ae.geometry)ce.push(ca(we,B))}else if(le==="MultiPolygon"){ce=[];for(let we of ae.geometry){let ne=[];for(let ye of we)ne.push(ca(ye,B));ce.push(ne)}}V.push(Ho(ae.id,le,ce,ae.tags))}return V}function ca(_e,B){let V=[];V.size=_e.size,_e.start!==void 0&&(V.start=_e.start,V.end=_e.end);for(let X=0;X<_e.length;X+=3)V.push(_e[X]+B,_e[X+1],_e[X+2]);return V}function ac(_e,B){if(_e.transformed)return _e;let V=1<<_e.z,X=_e.x,ae=_e.y;for(let le of _e.features){let ce=le.geometry,we=le.type;if(le.geometry=[],we===1)for(let ne=0;ne<ce.length;ne+=2)le.geometry.push(Co(ce[ne],ce[ne+1],B,V,X,ae));else for(let ne=0;ne<ce.length;ne++){let ye=[];for(let Ne=0;Ne<ce[ne].length;Ne+=2)ye.push(Co(ce[ne][Ne],ce[ne][Ne+1],B,V,X,ae));le.geometry.push(ye)}}return _e.transformed=!0,_e}function Co(_e,B,V,X,ae,le){return[Math.round(V*(_e*X-ae)),Math.round(V*(B*X-le))]}function lc(_e,B,V,X,ae){let le=B===ae.maxZoom?0:ae.tolerance/((1<<B)*ae.extent),ce={features:[],numPoints:0,numSimplified:0,numFeatures:_e.length,source:null,x:V,y:X,z:B,transformed:!1,minX:2,minY:1,maxX:-1,maxY:0};for(let we of _e)hu(ce,we,le,ae);return ce}function hu(_e,B,V,X){let ae=B.geometry,le=B.type,ce=[];if(_e.minX=Math.min(_e.minX,B.minX),_e.minY=Math.min(_e.minY,B.minY),_e.maxX=Math.max(_e.maxX,B.maxX),_e.maxY=Math.max(_e.maxY,B.maxY),le==="Point"||le==="MultiPoint")for(let we=0;we<ae.length;we+=3)ce.push(ae[we],ae[we+1]),_e.numPoints++,_e.numSimplified++;else if(le==="LineString")Ka(ce,ae,_e,V,!1,!1);else if(le==="MultiLineString"||le==="Polygon")for(let we=0;we<ae.length;we++)Ka(ce,ae[we],_e,V,le==="Polygon",we===0);else if(le==="MultiPolygon")for(let we=0;we<ae.length;we++){let ne=ae[we];for(let ye=0;ye<ne.length;ye++)Ka(ce,ne[ye],_e,V,!0,ye===0)}if(ce.length){let we=B.tags||null;if(le==="LineString"&&X.lineMetrics){we={};for(let ye in B.tags)we[ye]=B.tags[ye];we.mapbox_clip_start=ae.start/ae.size,we.mapbox_clip_end=ae.end/ae.size}let ne={geometry:ce,type:le==="Polygon"||le==="MultiPolygon"?3:le==="LineString"||le==="MultiLineString"?2:1,tags:we};B.id!==null&&(ne.id=B.id),_e.features.push(ne)}}function Ka(_e,B,V,X,ae,le){let ce=X*X;if(X>0&&B.size<(ae?ce:X))return void(V.numPoints+=B.length/3);let we=[];for(let ne=0;ne<B.length;ne+=3)(X===0||B[ne+2]>ce)&&(V.numSimplified++,we.push(B[ne],B[ne+1])),V.numPoints++;ae&&function(ne,ye){let Ne=0;for(let Oe=0,Ke=ne.length,ct=Ke-2;Oe<Ke;ct=Oe,Oe+=2)Ne+=(ne[Oe]-ne[ct])*(ne[Oe+1]+ne[ct+1]);if(Ne>0===ye)for(let Oe=0,Ke=ne.length;Oe<Ke/2;Oe+=2){let ct=ne[Oe],ht=ne[Oe+1];ne[Oe]=ne[Ke-2-Oe],ne[Oe+1]=ne[Ke-1-Oe],ne[Ke-2-Oe]=ct,ne[Ke-1-Oe]=ht}}(we,le),_e.push(we)}let du={maxZoom:14,indexMaxZoom:5,indexMaxPoints:1e5,tolerance:3,extent:4096,buffer:64,lineMetrics:!1,promoteId:null,generateId:!1,debug:0};class Fh{constructor(B,V){let X=(V=this.options=function(le,ce){for(let we in ce)le[we]=ce[we];return le}(Object.create(du),V)).debug;if(X&&console.time("preprocess data"),V.maxZoom<0||V.maxZoom>24)throw new Error("maxZoom should be in the 0-24 range");if(V.promoteId&&V.generateId)throw new Error("promoteId and generateId cannot be used together.");let ae=function(le,ce){let we=[];if(le.type==="FeatureCollection")for(let ne=0;ne<le.features.length;ne++)gs(we,le.features[ne],ce,ne);else gs(we,le.type==="Feature"?le:{geometry:le},ce);return we}(B,V);this.tiles={}
7,this.tileCoords=[],X&&(console.timeEnd("preprocess data"),console.log("index: maxZoom: %d, maxPoints: %d",V.indexMaxZoom,V.indexMaxPoints),console.time("generate tiles"),this.stats={},this.total=0),ae=function(le,ce){let we=ce.buffer/ce.extent,ne=le,ye=Rr(le,1,-1-we,we,0,-1,2,ce),Ne=Rr(le,1,1-we,2+we,0,-1,2,ce);return(ye||Ne)&&(ne=Rr(le,1,-we,1+we,0,-1,2,ce)||[],ye&&(ne=la(ye,1).concat(ne)),Ne&&(ne=ne.concat(la(Ne,-1)))),ne}(ae,V),ae.length&&this.splitTile(ae,0,0,0),X&&(ae.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(B,V,X,ae,le,ce,we){let ne=[B,V,X,ae],ye=this.options,Ne=ye.debug;for(;ne.length;){ae=ne.pop(),X=ne.pop(),V=ne.pop(),B=ne.pop();let Oe=1<<V,Ke=Qa(V,X,ae),ct=this.tiles[Ke];if(!ct&&(Ne>1&&console.time("creation"),ct=this.tiles[Ke]=lc(B,V,X,ae,ye),this.tileCoords.push({z:V,x:X,y:ae}),Ne)){Ne>1&&(console.log("tile z%d-%d-%d (features: %d, points: %d, simplified: %d)",V,X,ae,ct.numFeatures,ct.numPoints,ct.numSimplified),console.timeEnd("creation"));let Ci=`z${V}`;this.stats[Ci]=(this.stats[Ci]||0)+1,this.total++}if(ct.source=B,le==null){if(V===ye.indexMaxZoom||ct.numPoints<=ye.indexMaxPoints)continue}else{if(V===ye.maxZoom||V===le)continue;if(le!=null){let Ci=le-V;if(X!==ce>>Ci||ae!==we>>Ci)continue}}if(ct.source=null,B.length===0)continue;Ne>1&&console.time("clipping");let ht=.5*ye.buffer/ye.extent,Lt=.5-ht,St=.5+ht,Mt=1+ht,Ve=null,Ut=null,$i=null,Hi=null,Ot=Rr(B,Oe,X-ht,X+St,0,ct.minX,ct.maxX,ye),ti=Rr(B,Oe,X+Lt,X+Mt,0,ct.minX,ct.maxX,ye);B=null,Ot&&(Ve=Rr(Ot,Oe,ae-ht,ae+St,1,ct.minY,ct.maxY,ye),Ut=Rr(Ot,Oe,ae+Lt,ae+Mt,1,ct.minY,ct.maxY,ye),Ot=null),ti&&($i=Rr(ti,Oe,ae-ht,ae+St,1,ct.minY,ct.maxY,ye),Hi=Rr(ti,Oe,ae+Lt,ae+Mt,1,ct.minY,ct.maxY,ye),ti=null),Ne>1&&console.timeEnd("clipping"),ne.push(Ve||[],V+1,2*X,2*ae),ne.push(Ut||[],V+1,2*X,2*ae+1),ne.push($i||[],V+1,2*X+1,2*ae),ne.push(Hi||[],V+1,2*X+1,2*ae+1)}}getTile(B,V,X){B=+B,V=+V,X=+X;let ae=this.options,{extent:le,debug:ce}=ae;if(B<0||B>24)return null;let we=1<<B,ne=Qa(B,V=V+we&we-1,X);if(this.tiles[ne])return ac(this.tiles[ne],le);ce>1&&console.log("drilling down to z%d-%d-%d",B,V,X);let ye,Ne=B,Oe=V,Ke=X;for(;!ye&&Ne>0;)Ne--,Oe>>=1,Ke>>=1,ye=this.tiles[Qa(Ne,Oe,Ke)];return ye&&ye.source?(ce>1&&(console.log("found parent tile z%d-%d-%d",Ne,Oe,Ke),console.time("drilling down")),this.splitTile(ye.source,Ne,Oe,Ke,B,V,X),ce>1&&console.timeEnd("drilling down"),this.tiles[ne]?ac(this.tiles[ne],le):null):null}}function Qa(_e,B,V){return 32*((1<<_e)*V+B)+_e}function ke(_e,B){let V=_e.tileID.canonical;if(!this._geoJSONIndex)return void B(null,null);let X=this._geoJSONIndex.getTile(V.z,V.x,V.y);if(!X)return void B(null,null);let ae=ye=>ye.tags&&"3d_elevation_id"in ye.tags&&"source"in ye.tags&&ye.tags.source==="elevation",le=X.features.filter(ye=>ae(ye)),ce={_geojsonTileLayer:X.features};le.length>0&&(ce={_geojsonTileLayer:X.features.filter(ye=>!ae(ye)),hd_road_elevation:le});let we=new ic(ce),ne=function(ye){let Ne=new U.b2;for(let Oe of Object.keys(ye))Ne.writeMessage(3,ia,{name:Oe,features:ye[Oe]});return Ne.finish()}(ce).buffer;B(null,{vectorTile:we,rawData:ne})}class Zo extends ms{constructor(B){super(B),this.loadVectorData=ke,this._dynamicIndex=new Fn}loadData(B,V){let X=B&&B.request,ae=X&&X.collectResourceTiming;this._geoJSONIndex=null,this.loadGeoJSON(B,(le,ce)=>{if(le||!ce)return V(le);if(typeof ce!="object")return V(new Error(`Input data given to '${B.source}' is not a valid GeoJSON object.`));{try{if(B.filter){let ne=U.U(B.filter,{type:"boolean","property-type":"data-driven",overridable:!1,transition:!1});if(ne.result==="error")throw new Error(ne.value.map(ye=>`${ye.key}: ${ye.message}`).join(", "));ce.features=ce.features.filter(ye=>ne.value.evaluate({zoom:0},ye))}B.dynamic?(ce.type==="Feature"&&(ce={type:"FeatureCollection",features:[ce]}),B.append||(this._dynamicIndex.clear(),this.loaded={}),this._dynamicIndex.load(ce.features,this.loaded),B.cluster&&(ce.features=this._dynamicIndex.getFeatures())):this.loaded={},this._geoJSONIndex=B.cluster?new Za(function({superclusterOptions:ne,clusterProperties:ye}){if(!ye||!ne)return ne;let Ne={},Oe={},Ke={accumulated:null,zoom:0},ct={properties:null},ht=Object.keys(ye);for(let Lt of ht){let[St,Mt]=ye[Lt],Ve=U.U(Mt),Ut=U.U(typeof St=="string"?[St,["accumulated"],["get",Lt]]:St);Ne[Lt]=Ve.value,Oe[Lt]=Ut.value}return ne.map=Lt=>{ct.properties=Lt;let St={};for(let Mt of ht)St[Mt]=Ne[Mt].evaluate(Ke,ct);return St},ne.reduce=(Lt,St)=>{ct.properties=St;for(let Mt of ht)Ke.accumulated=Lt[Mt],Lt[Mt]=Oe[Mt].evaluate(Ke,ct)},ne}(B)).load(ce.features):B.dynamic?this._dynamicIndex:function(ne,ye){return new Fh(ne,ye)}(ce,B.geojsonVtOptions)}catch(ne){return V(ne)}let we={};if(ae){let ne=ln(X);ne&&(we.resourceTiming={},we.resourceTiming[B.source]=JSON.parse(JSON.stringify(ne)))}V(null,we)}})}reloadTile(B,V){let X=this.loaded;return X&&X[B.uid]?B.partial?V(null,void 0):super.reloadTile(B,V):this.loadTile(B,V)}loadGeoJSON(B,V){if(B.request)U.m(B.request,V);else{if(typeof B.data!="string")return V(new Error(`Input data given to '${B.source}' is not a valid GeoJSON object.`));setTimeout(()=>{try{return V(null,JSON.parse(B.data))}catch{return V(new Error(`Input data given to '${B.source}' is not a valid GeoJSON object.`))}},0)}}
7getClusterExpansionZoom(B,V){try{V(null,this._geoJSONIndex.getClusterExpansionZoom(B.clusterId))}catch(X){V(X)}}getClusterChildren(B,V){try{V(null,this._geoJSONIndex.getChildren(B.clusterId))}catch(X){V(X)}}getClusterLeaves(B,V){try{V(null,this._geoJSONIndex.getLeaves(B.clusterId,B.limit,B.offset))}catch(X){V(X)}}}class xs{constructor(B,V,X){this.tileID=new U.aU(B.tileID.overscaledZ,B.tileID.wrap,B.tileID.canonical.z,B.tileID.canonical.x,B.tileID.canonical.y),this.tileZoom=B.tileZoom,this.uid=B.uid,this.zoom=B.zoom,this.canonical=B.tileID.canonical,this.pixelRatio=B.pixelRatio,this.tileSize=B.tileSize,this.source=B.source,this.overscaling=this.tileID.overscaleFactor(),this.projection=B.projection,this.brightness=V,this.worldview=X}parse(B,V,X,ae){this.status="parsing";let le=new U.aU(X.tileID.overscaledZ,X.tileID.wrap,X.tileID.canonical.z,X.tileID.canonical.x,X.tileID.canonical.y),ce=[],we=V.familiesBySource[X.source],ne=new U.fj(le,X.promoteId);ne.bucketLayerIDs=[],ne.is3DTile=!0,U.fF(B).then(ye=>{let Ne=ye.json.extensionsUsed&&ye.json.extensionsUsed.includes("MAPBOX_mesh_features")||ye.json.asset.extras&&ye.json.asset.extras.MAPBOX_mesh_features,Oe=ye.json.extensionsUsed&&ye.json.extensionsUsed.includes("EXT_meshopt_compression"),Ke=new U.ab(this.zoom,{brightness:this.brightness,worldview:this.worldview});for(let ct in we)for(let ht of we[ct]){let Lt=ht[0];ne.bucketLayerIDs.push(ht.map(Ve=>U.t(Ve.id,Ve.scope))),Lt.recalculate(Ke,[]);let St=U.fG(ye,1/U.cW(X.tileID.canonical)),Mt=new U.fH(ht,St,le,Ne,Oe,this.brightness,ne,this.worldview);Ne||(Mt.needsUpload=!0),ce.push(Mt),Mt.evaluate(Lt)}this.status="done",ae(null,{buckets:ce,featureIndex:ne,collisionBoxArray:null,glyphAtlasImage:null,lineAtlas:null,imageAtlas:null,brightness:null})}).catch(ye=>ae(new Error(ye.message)))}}class ua{constructor({actor:B,layerIndex:V,availableImages:X,availableModels:ae,brightness:le,worldview:ce}){this.actor=B,this.layerIndex=V,this.availableImages=X,this.availableModels=ae,this.brightness=le,this.loading={},this.loaded={},this.worldview=ce}loadTile(B,V){let X=B.uid,ae=this.loading[X]=new xs(B,this.brightness,this.worldview);U.b4(B.request,(le,ce)=>{let we=!this.loading[X];return delete this.loading[X],we||le?(ae.status="done",we||(this.loaded[X]=ae),V(le)):ce&&ce.byteLength!==0?void ae.parse(ce,this.layerIndex,B,(ne,ye)=>{ae.status="done",this.loaded=this.loaded||{},this.loaded[X]=ae,ne||!ye?V(ne):V(null,ye)}):(ae.status="done",this.loaded[X]=ae,V())})}reloadTile(B,V){let X=this.loaded,ae=B.uid;if(X&&X[ae]){let le=X[ae];le.projection=B.projection,le.brightness=B.brightness;let ce=(we,ne)=>{le.reloadCallback&&(delete le.reloadCallback,this.loadTile(B,V)),V(we,ne)};le.status==="parsing"?le.reloadCallback=ce:le.status==="done"&&this.loadTile(B,V)}}abortTile(B,V){let X=B.uid;this.loading[X]&&delete this.loading[X],V()}removeTile(B,V){let X=this.loaded,ae=B.uid;X&&X[ae]&&delete X[ae],V()}}class el{constructor(B){this.self=B,this.actor=new U.ap(B,this),this.layerIndexes={},this.availableImages={},this.availableModels={},this.isSpriteLoaded={},this.rtlPluginParsingListeners=[],this.projections={},this.defaultProjection=U.c4({name:"mercator"}),this.workerSourceTypes={vector:ms,geojson:Zo,"raster-dem":Go,"raster-array":Ql,"batched-model":ua},this.workerSources={},this.self.registerWorkerSource=(V,X)=>{if(this.workerSourceTypes[V])throw new Error(`Worker source with name "${V}" already registered.`);this.workerSourceTypes[V]=X}
7,this.self.registerRTLTextPlugin=V=>{if(U.fJ.isParsed())throw new Error("RTL text plugin already registered.");U.fJ.setState({pluginStatus:U.fK.parsed,pluginURL:U.fJ.getPluginURL()}),U.fJ.applyArabicShaping=V.applyArabicShaping,U.fJ.processBidirectionalText=V.processBidirectionalText,U.fJ.processStyledBidirectionalText=V.processStyledBidirectionalText;for(let X of this.rtlPluginParsingListeners)X(null,!0);this.rtlPluginParsingListeners=[]}}clearCaches(B,V,X){delete this.layerIndexes[B],delete this.availableImages[B],delete this.availableModels[B],delete this.workerSources[B],X()}checkIfReady(B,V,X){X()}setReferrer(B,V){this.referrer=V}spriteLoaded(B,V){this.isSpriteLoaded[B]||(this.isSpriteLoaded[B]={});let{scope:X,isLoaded:ae}=V;if(this.isSpriteLoaded[B][X]=ae,this.workerSources[B]&&this.workerSources[B][X])for(let le in this.workerSources[B][X]){let ce=this.workerSources[B][X][le];for(let we in ce){let ne=ce[we];ne instanceof ms&&(ne.isSpriteLoaded=ae,ne.fire(new U.z("isSpriteLoaded")))}}}setImages(B,V,X){this.availableImages[B]||(this.availableImages[B]={});let{scope:ae,images:le}=V;if(this.availableImages[B][ae]=le,this.workerSources[B]&&this.workerSources[B][ae]){for(let ce in this.workerSources[B][ae]){let we=this.workerSources[B][ae][ce];for(let ne in we)we[ne].availableImages=le}X()}else X()}setModels(B,{scope:V,models:X},ae){if(this.availableModels[B]||(this.availableModels[B]={}),this.availableModels[B][V]=X,this.workerSources[B]&&this.workerSources[B][V]){for(let le in this.workerSources[B][V]){let ce=this.workerSources[B][V][le];for(let we in ce)ce[we].availableModels=X}ae()}else ae()}setProjection(B,V){this.projections[B]=U.c4(V)}setBrightness(B,V,X){this.brightness=V,X()}setContextParams(B,V,X){this.maxUniformBufferBindings=V.maxBindingPoints,this.maxUniformBlockSizeDwords=V.maxUniformBlockSizeDwords,this.disableSymbolUBO=V.disableSymbolUBO,X()}setWorldview(B,V,X){this.worldview=V,X()}setLayers(B,V,X){this.getLayerIndex(B,V.scope).replace(V.layers,V.options),X()}updateLayers(B,V,X){this.getLayerIndex(B,V.scope).update(V.layers,V.removedIds,V.options),X()}loadTile(B,V,X){V.projection=this.projections[B]||this.defaultProjection,this.getWorkerSource(B,V).loadTile(V,X)}decodeRasterArray(B,V,X){this.getWorkerSource(B,V).decodeRasterArray(V,X)}reloadTile(B,V,X){V.projection=this.projections[B]||this.defaultProjection,this.getWorkerSource(B,V).reloadTile(V,X)}abortTile(B,V,X){this.getWorkerSource(B,V).abortTile(V,X)}removeTile(B,V,X){this.getWorkerSource(B,V).removeTile(V,X)}removeSource(B,V,X){if(!(this.workerSources[B]&&this.workerSources[B][V.scope]&&this.workerSources[B][V.scope][V.type]&&this.workerSources[B][V.scope][V.type][V.source]))return;let ae=this.workerSources[B][V.scope][V.type][V.source];delete this.workerSources[B][V.scope][V.type][V.source],ae.removeSource!==void 0?ae.removeSource(V,X):X()}loadTileProvider(B,V,X){U.aT(V.name,V.url).then(ae=>{let le=new ae(V.options);return this.getWorkerSource(B,{type:V.type,source:V.source,scope:V.scope},le),le.load&&V.request?le.load({request:V.request}):null}).then(ae=>X(null,ae)).catch(ae=>X(ae instanceof Error?ae:new Error(String(ae))))}async syncRTLPluginState(B,V,X){if(U.fJ.isParsed())return void X(null,!0);if(U.fJ.isParsing())return void this.rtlPluginParsingListeners.push(X);U.fJ.setState(V);let ae=U.fJ.getPluginURL();if(!U.fJ.isLoaded()||U.fJ.isParsed()||U.fJ.isParsing())X(null,!1);else{U.fJ.setState({pluginStatus:U.fK.parsing,pluginURL:ae});try{await import(ae),U.fJ.isParsed()?X(null,!0):this.rtlPluginParsingListeners.push(X)}catch(le){U.fJ.setState({pluginStatus:U.fK.error,pluginURL:ae}),X(le);for(let ce of this.rtlPluginParsingListeners)ce(le);this.rtlPluginParsingListeners=[]}}}setConfig(B,V){Object.assign(U.g,V)}getAvailableImages(B,V){this.availableImages[B]||(this.availableImages[B]={});let X=this.availableImages[B][V];return X||(X=[]),X}getAvailableModels(B,V){this.availableModels[B]||(this.availableModels[B]={});let X=this.availableModels[B][V];return X||(X={}),X}getLayerIndex(B,V){this.layerIndexes[B]||(this.layerIndexes[B]={});let X=this.layerIndexes[B][V];return X||(X=this.layerIndexes[B][V]=new uo,X.scope=V),X}getWorkerSource(B,V,X){let{type:ae,source:le,scope:ce}=V,we=this.workerSources;if(we[B]||(we[B]={}),we[B][ce]||(we[B][ce]={}),we[B][ce][ae]||(we[B][ce][ae]={}),this.isSpriteLoaded[B]||(this.isSpriteLoaded[B]={}),we[B][ce][ae][le])X&&(we[B][ce][ae][le].tileProvider=X);else{let ne={send:(Ne,Oe,Ke,ct,ht,Lt)=>this.actor.send(Ne,Oe,Ke,B,ht,Lt),scheduler:this.actor.scheduler},ye=this.workerSourceTypes[ae];if(!ye)throw new Error(`Unknown worker source type "${ae}".`);we[B][ce][ae][le]=new ye({actor:ne,layerIndex:this.getLayerIndex(B,ce),availableImages:this.getAvailableImages(B,ce),availableModels:this.getAvailableModels(B,ce),isSpriteLoaded:this.isSpriteLoaded[B][ce],tileProvider:X,brightness:this.brightness,worldview:this.worldview,maxUniformBufferBindings:this.maxUniformBufferBindings,maxUniformBlockSizeDwords:this.maxUniformBlockSizeDwords,disableSymbolUBO:this.disableSymbolUBO})}return we[B][ce][ae][le]}enforceCacheSizeLimit(B,V){U.fL(V)}getWorkerPerformanceMetrics(B,V,X){X(void 0,void 0)}}return U.fI(self)&&(self.worker=new el(self)),el}),Zi(["./shared"],function(h){var U="3.24.1";let ln={create:"create",load:"load",fullLoad:"fullLoad"},gi={mark(a){performance.mark(a)},measure(a,t,o){performance.measure(a,t,o)}};function Cr(a){let t=a.name.split("?")[0];return h.a(t)&&t.includes("mapbox-gl.js")?"javascript":h.a(t)&&t.includes("mapbox-gl.css")?"css":h.b(t)?"fontRange":h.c(t)?"sprite":h.i(t)?"style":h.d(t)?"tilejson":"other"}var Yr,uo={},Jr=function(){if(Yr)return uo;function a(c){return!t(c)}function t(c){return typeof window>"u"||typeof document>"u"?"not a browser":function(){if(!("Worker"in window&&"Blob"in window&&"URL"in window))return!1;var m,_,y=new Blob([""],{type:"text/javascript"}),v=URL.createObjectURL(y);try{_=new Worker(v),m=!0}catch{m=!1}return _&&_.terminate(),URL.revokeObjectURL(v),m}()?function(){var m=document.createElement("canvas");m.width=m.height=1;var _=m.getContext("2d");if(!_)return!1;var y=_.getImageData(0,0,1,1);return y&&y.width===m.width}()?(o[d=c&&c.failIfMajorPerformanceCaveat]===void 0&&(o[d]=function(m){var _,y=function(v){var T=document.createElement("canvas"),I=Object.create(a.webGLContextAttributes);return I.failIfMajorPerformanceCaveat=v,T.getContext("webgl2",I)}(m);if(!y)return!1;try{_=y.createShader(y.VERTEX_SHADER)}catch{return!1}return!(!_||y.isContextLost())&&(y.shaderSource(_,"void main() {}"),y.compileShader(_),y.getShaderParameter(_,y.COMPILE_STATUS)===!0)}(d)),o[d]?document.documentMode?"insufficient ECMAScript 6 support":void 0:"insufficient WebGL2 support"):"insufficient Canvas/getImageData support":"insufficient worker support";var d}Yr=1,uo.supported=a,uo.notSupportedReason=t;var o={};return a.webGLContextAttributes={antialias:!1,alpha:!0,stencil:!0,depth:!0},uo}();let fs=/firefox/i,Kl=/macintosh/i;function Rt(a,t,o){let c=document.createElement(a);return t!=null&&(c.className=t),o&&o.appendChild(c),c}function mr(a,t,o){let c=document.createElementNS("http://www.w3.org/2000/svg",a);for(let d of Object.keys(t))c.setAttributeNS(null,d,String(t[d]));return o&&o.appendChild(c),c}let xi=typeof document<"u"?document.documentElement&&document.documentElement.style:null,Gn=xi&&xi.userSelect!==void 0?"userSelect":"WebkitUserSelect",Zn;function Vo(){xi&&Gn&&(Zn=xi[Gn],xi[Gn]="none")}function jo(){xi&&Gn&&(xi[Gn]=Zn)}function ho(a){a.preventDefault(),a.stopPropagation(),window.removeEventListener("click",ho,!0)}function ms(){window.addEventListener("click",ho,!0),window.setTimeout(()=>{window.removeEventListener("click",ho,!0)},0)}function Go(a,t){let o=a.getBoundingClientRect();return ec(a,o,t)}function ta(a,t){let o=a.getBoundingClientRect(),c=[];for(let d=0;d<t.length;d++)c.push(ec(a,o,t[d]));return c}function Ql(a){return fs.test(navigator.userAgent)&&Kl.test(navigator.userAgent)&&a.button===2&&a.ctrlKey?0:a.button}function ec(a,t,o){let c=a.offsetWidth===t.width?1:a.offsetWidth/t.width;return new h.P((o.clientX-t.left)*c,(o.clientY-t.top)*c)}let tc="01",si=/(\.(png|jpg)\d*)(?=$)/,ic=/^.+\/v4\//,Dn=/\.[\w]+$/,Fn=/^(\/v4\/|\/(raster|rasterarrays)\/v1\/)/,Ei=/^access_token=(.*)$/,tn="NO_ACCESS_TOKEN";class po{constructor(t,o,c){this._transformRequestFn=t,this._customAccessToken=o,this._silenceAuthErrors=!!c,this._createSkuToken()}_createSkuToken(){let t=function(){let o="";for(let c=0;c<10;c++)o+="0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"[Math.floor(62*Math.random())];return{token:["1",tc,o].join(""),tokenExpiresAt:Date.now()+432e5}}();this._skuToken=t.token,this._skuTokenExpiresAt=t.tokenExpiresAt}_isSkuTokenExpired(){return Date.now()>this._skuTokenExpiresAt}transformRequest(t,o){return this._transformRequestFn&&this._transformRequestFn(t,o)||{url:t}}
7normalizeStyleURL(t,o){if(!h.e(t))return t;let c=Rn(t);return c.params.push(`sdk=js-${U}`),c.path=`/styles/v1${c.path}`,this._makeAPIURL(c,this._customAccessToken||o)}normalizeGlyphsURL(t,o){if(!h.e(t))return t;let c=Rn(t);return c.path=`/fonts/v1${c.path}`,this._makeAPIURL(c,this._customAccessToken||o)}normalizeModelURL(t,o){if(!h.e(t))return t;let c=Rn(t);return c.path=`/models/v1${c.path}`,this._makeAPIURL(c,this._customAccessToken||o)}normalizeSourceURL(t,o,c,d){if(!h.e(t))return t;let m=Rn(t);return m.path=`/v4/${m.authority}.json`,m.params.push("secure"),c&&m.params.push(`language=${c}`),d&&m.params.push(`worldview=${d}`),this._makeAPIURL(m,this._customAccessToken||o)}normalizeIconsetURL(t,o){let c=Rn(t);return h.e(t)?(c.path=`/styles/v1${c.path}/iconset.pbf`,this._makeAPIURL(c,this._customAccessToken||o)):Pr(c)}normalizeSpriteURL(t,o,c,d){let m=Rn(t);return h.e(t)?(m.path=`/styles/v1${m.path}/sprite${o}${c}`,this._makeAPIURL(m,this._customAccessToken||d)):(m.path+=`${o}${c}`,Pr(m))}normalizeTileURL(t,o,c){if(this._isSkuTokenExpired()&&this._createSkuToken(),t&&!h.e(t))return t;let d=Rn(t);d.path=d.path.replace(si,`${o||c&&d.authority!=="raster"&&c===512?"@2x":""}${h.k.supported?".webp":"$1"}`),d.authority==="raster"?d.path=`/${h.g.RASTER_URL_PREFIX}${d.path}`:d.authority==="rasterarrays"?d.path=`/${h.g.RASTERARRAYS_URL_PREFIX}${d.path}`:d.authority==="3dtiles"?d.path=`/${h.g.TILES3D_URL_PREFIX}${d.path}`:(d.path=d.path.replace(ic,"/"),d.path=`/${h.g.TILE_URL_VERSION}${d.path}`);let m=this._customAccessToken||function(_){for(let y of _){let v=y.match(Ei);if(v)return v[1]}return null}(d.params)||h.g.ACCESS_TOKEN;return h.g.REQUIRE_ACCESS_TOKEN&&m&&this._skuToken&&d.params.push(`sku=${this._skuToken}`),this._makeAPIURL(d,m)}canonicalizeTileURL(t,o){let c=Rn(t);if(!Fn.test(c.path)||!Dn.test(c.path))return t;let d="mapbox://";c.path.startsWith("/raster/v1/")?d+=`raster/${c.path.replace(`/${h.g.RASTER_URL_PREFIX}/`,"")}`:c.path.startsWith("/rasterarrays/v1/")?d+=`rasterarrays/${c.path.replace(`/${h.g.RASTERARRAYS_URL_PREFIX}/`,"")}`:d+=`tiles/${c.path.replace(`/${h.g.TILE_URL_VERSION}/`,"")}`;let m=c.params;return o&&(m=m.filter(_=>!_.match(Ei))),m.length&&(d+=`?${m.join("&")}`),d}canonicalizeTileset(t,o){let c=!!o&&h.e(o),d=[];for(let m of t.tiles||[])h.f(m)?d.push(this.canonicalizeTileURL(m,c)):d.push(m);return d}_makeAPIURL(t,o){let c="See https://docs.mapbox.com/api/overview/#access-tokens-and-token-scopes",d=Rn(h.g.API_URL);if(t.protocol=d.protocol,t.authority=d.authority,t.protocol==="http"){let m=t.params.indexOf("secure");m>=0&&t.params.splice(m,1)}if(d.path!=="/"&&(t.path=`${d.path}${t.path}`),!h.g.REQUIRE_ACCESS_TOKEN)return Pr(t);if(o=o||h.g.ACCESS_TOKEN,!this._silenceAuthErrors){if(!o)throw new Error(`An API access token is required to use Mapbox GL. ${c}`);if(o[0]==="s")throw new Error(`Use a public access token (pk.*) with Mapbox GL, not a secret access token (sk.*). ${c}`)}return t.params=t.params.filter(m=>!m.includes("access_token")),t.params.push(`access_token=${o||""}`),Pr(t)}}let nc=/^(\w+):\/\/([^/?]*)(\/[^?]+)?\??(.+)?/;function Rn(a){let t=a.match(nc);if(!t)throw new Error("Unable to parse URL object");return{protocol:t[1],authority:t[2],path:t[3]||"/",params:t[4]?t[4].split("&"):[]}}function Pr(a){let t=a.params.length?`?${a.params.join("&")}`:"";return`${a.protocol}://${a.authority}${a.path}${t}`}let Li="mapbox.eventData";function Dr(a){if(!a)return null;let t=a.split(".");if(!t||t.length!==3)return null;try{return JSON.parse(h.l(t[1]))}catch{return null}}function ia(a){return!(!h.g.EVENTS_URL||!a&&!h.g.ACCESS_TOKEN)}class $o{constructor(t){this.type=t,this.anonId=null,this.anonIdTimestamp=null,this.eventData={},this.queue=[],this.pendingRequest=null}getStorageKey(t){let o=Dr(h.g.ACCESS_TOKEN),c="";return c=o&&o.u?h.j(o.u):h.g.ACCESS_TOKEN||"",t?`${Li}.${t}:${c}`:`${Li}:${c}`}fetchEventData(){let t=h.s("localStorage"),o=this.getStorageKey(),c=this.getStorageKey("uuid"),d=this.getStorageKey("uuidTimestamp");if(t)try{let m=localStorage.getItem(o);m&&(this.eventData=JSON.parse(m));let _=localStorage.getItem(c);_&&(this.anonId=_);let y=localStorage.getItem(d);y&&(this.anonIdTimestamp=Number(y));let v=Date.now()-864e5;(!this.anonIdTimestamp||this.anonIdTimestamp<v)&&this.refreshUUID()}catch{h.w("Unable to read from LocalStorage")}}refreshUUID(){this.anonId=h.u(),this.anonIdTimestamp=Date.now()}saveEventData(){let t=h.s("localStorage"),o=this.getStorageKey(),c=this.getStorageKey("uuid"),d=this.getStorageKey("uuidTimestamp"),m=this.anonId,_=this.anonIdTimestamp;if(t&&m)try{localStorage.setItem(c,m),Object.keys(this.eventData).length>=1&&localStorage.setItem(o,JSON.stringify(this.eventData)),_&&localStorage.setItem(d,_.toString())}catch{h.w("Unable to write to LocalStorage")}}processRequests(t){}postEvent(t,o,c,d){if(!h.g.EVENTS_URL)return;let m=Rn(h.g.EVENTS_URL);m.params.push(`access_token=${d||h.g.ACCESS_TOKEN||""}`);let _={event:this.type,created:new Date(t).toISOString()},y=o?Object.assign(_,o):_,v={url:Pr(m),headers:{"Content-Type":"text/plain"},body:JSON.stringify([y])};this.pendingRequest=h.p(v,T=>{this.pendingRequest=null,c(T),this.saveEventData(),this.processRequests(d)})}queueRequest(t,o){this.queue.push(t),this.processRequests(o)}}class rc extends $o{constructor(t){super("metrics"),t&&(this.data=t)}postMetricsEvent(t){if(!ia(t))return;this.anonId||this.fetchEventData(),h.v(this.anonId)||this.refreshUUID();let o=Object.assign({},this.data,{sessionId:this.anonId});this.queueRequest({timestamp:Date.now(),payload:o},t)}processRequests(t){if(this.pendingRequest||this.queue.length===0)return;let{timestamp:o,payload:c}=this.queue.shift();this.postEvent(o,c,()=>{},t)}}
7let fo=new class extends $o{constructor(a){super("appUserTurnstile"),this._customAccessToken=a}postTurnstileEvent(a,t){ia(t)&&Array.isArray(a)&&a.some(o=>h.e(o)||h.f(o))&&this.queueRequest(Date.now(),t)}processRequests(a){if(this.pendingRequest||this.queue.length===0)return;this.anonId&&this.anonIdTimestamp&&this.eventData.lastSuccess&&this.eventData.tokenU||this.fetchEventData();let t=Dr(h.g.ACCESS_TOKEN),o=t?t.u:h.g.ACCESS_TOKEN,c=o!==this.eventData.tokenU;h.v(this.anonId)||(this.refreshUUID(),c=!0);let d=this.queue.shift();if(this.eventData.lastSuccess){let m=new Date(this.eventData.lastSuccess),_=new Date(d),y=(d-this.eventData.lastSuccess)/864e5;c=c||y>=1||y<-1||m.getDate()!==_.getDate()}else c=!0;c?this.postEvent(d,{sdkIdentifier:"mapbox-gl-js",sdkVersion:U,skuId:tc,"enabled.telemetry":!1,userId:this.anonId},m=>{m||(this.eventData.lastSuccess=d,this.eventData.tokenU=o)},a):this.processRequests()}},hi=fo.postTurnstileEvent.bind(fo),Qi=new class extends $o{constructor(){super("map.load"),this.success={},this.skuToken=""}postMapLoadEvent(a,t,o,c){this.skuToken=t,this.errorCb=c,h.g.EVENTS_URL&&(o||h.g.ACCESS_TOKEN?this.queueRequest({id:a,timestamp:Date.now()},o):this.errorCb(new Error(tn)))}processRequests(a){if(this.pendingRequest||this.queue.length===0)return;let{id:t,timestamp:o}=this.queue.shift();t&&this.success[t]||(this.anonId&&this.anonIdTimestamp||this.fetchEventData(),h.v(this.anonId)||this.refreshUUID(),this.postEvent(o,{sdkIdentifier:"mapbox-gl-js",sdkVersion:U,skuId:tc,skuToken:this.skuToken,userId:this.anonId},c=>{c?this.errorCb(c):t&&(this.success[t]=!0)},a))}remove(){this.errorCb=null}},Wn=Qi.postMapLoadEvent.bind(Qi),na=new class extends $o{constructor(){super("style.load"),this.eventIdPerMapInstanceMap=new Map,this.mapInstanceIdMap=new WeakMap}getMapInstanceId(a){let t=this.mapInstanceIdMap.get(a);return t||(t=h.u(),this.mapInstanceIdMap.set(a,t)),t}getEventId(a){let t=this.eventIdPerMapInstanceMap.get(a)||0;return this.eventIdPerMapInstanceMap.set(a,t+1),t}postStyleLoadEvent(a,t){let{map:o,style:c,importedStyles:d}=t;if(!ia(a))return;let m=this.getMapInstanceId(o),_={mapInstanceId:m,eventId:this.getEventId(m),style:c};d.length&&(_.importedStyles=d),this.queueRequest({timestamp:Date.now(),payload:_},a)}processRequests(a){if(this.pendingRequest||this.queue.length===0)return;let{timestamp:t,payload:o}=this.queue.shift();this.postEvent(t,o,()=>{},a)}},Oi=na.postStyleLoadEvent.bind(na),_s=new rc({attributes:[{name:"maps/js/layer-animations/style-with-appearances"}]}),Za=_s.postMetricsEvent.bind(_s),Wa=new rc({attributes:[{name:"maps/js/layer-animations/runtime-appearances"}]}),Mo=Wa.postMetricsEvent.bind(Wa),Gi=new class extends $o{constructor(){super("gljs.performance")}postPerformanceEvent(a,t){ia(a)&&this.queueRequest({timestamp:Date.now(),performanceData:t},a)}processRequests(a){if(this.pendingRequest||this.queue.length===0)return;let{timestamp:t,performanceData:o}=this.queue.shift(),c=function(d){let m=performance.getEntriesByType("resource"),_=performance.getEntriesByType("mark"),y=function(D){let L={};if(D){for(let O in D)if(O!=="other")for(let k of D[O]){let N=`${O}ResolveRangeMin`,q=`${O}ResolveRangeMax`,Z=`${O}RequestCount`,G=`${O}RequestCachedCount`;L[N]=Math.min(L[N]||1/0,k.startTime),L[q]=Math.max(L[q]||-1/0,k.responseEnd);let re=te=>{L[te]===void 0&&(L[te]=0),++L[te]};k.transferSize!==void 0&&k.transferSize===0&&re(G),re(Z)}}return L}(function(D,L){let O={};if(D)for(let k of D){let N=L(k);O[N]===void 0&&(O[N]=[]),O[N].push(k)}return O}(m,Cr)),v=window.devicePixelRatio,T=navigator.connection||navigator.mozConnection||navigator.webkitConnection,I=T?T.effectiveType:void 0,P={counters:[],metadata:[],attributes:[]},A=(D,L,O)=>{O!=null&&D.push({name:L,value:O.toString()})};for(let D in y)A(P.counters,D,y[D]);if(d.interactionRange[0]!==1/0&&d.interactionRange[1]!==-1/0&&(A(P.counters,"interactionRangeMin",d.interactionRange[0]),A(P.counters,"interactionRangeMax",d.interactionRange[1])),_)for(let D of Object.values(ln)){let L=_.find(O=>O.name===D);L&&A(P.counters,D,L.startTime)}return A(P.counters,"visibilityHidden",d.visibilityHidden),A(P.attributes,"style",function(D){if(D)for(let L of D){let O=L.name.split("?")[0];if(h.i(O)){let k=O.split("/").slice(-2);if(k.length===2)return`mapbox://styles/${k[0]}/${k[1]}`}}}(m)),A(P.attributes,"terrainEnabled",d.terrainEnabled?"true":"false"),A(P.attributes,"fogEnabled",d.fogEnabled?"true":"false"),A(P.attributes,"projection",d.projection),A(P.attributes,"zoom",d.zoom),A(P.metadata,"devicePixelRatio",v),A(P.metadata,"connectionEffectiveType",I),A(P.metadata,"navigatorUserAgent",navigator.userAgent),A(P.metadata,"screenWidth",window.screen.width),A(P.metadata,"screenHeight",window.screen.height),A(P.metadata,"windowWidth",window.innerWidth),A(P.metadata,"windowHeight",window.innerHeight),A(P.metadata,"mapWidth",d.width/v),A(P.metadata,"mapHeight",d.height/v),A(P.metadata,"webglRenderer",d.renderer),A(P.metadata,"webglVendor",d.vendor),A(P.metadata,"sdkVersion",U),A(P.metadata,"sdkIdentifier","mapbox-gl-js"),P}(o);for(let d of c.metadata);for(let d of c.counters);for(let d of c.attributes);this.postEvent(t,c,()=>{},a)}},Xa=Gi.postPerformanceEvent.bind(Gi),ra=new class extends $o{constructor(){super("map.auth"),this.success={},this.skuToken=""}getSession(a,t,o,c){if(!h.g.API_URL||!h.g.SESSION_PATH)return;let d=Rn(h.g.API_URL+h.g.SESSION_PATH);d.params.push(`sku=${t||""}`),d.params.push(`access_token=${c||h.g.ACCESS_TOKEN||""}`);let m={url:Pr(d),headers:{"Content-Type":"text/plain"}};this.pendingRequest=h.h(m,_=>{this.pendingRequest=null,o(_),this.saveEventData(),this.processRequests(c)})}getSessionAPI(a,t,o,c){this.skuToken=t,this.errorCb=c,h.g.EVENTS_URL&&h.g.SESSION_PATH&&h.g.API_URL&&(o||h.g.ACCESS_TOKEN?this.queueRequest({id:a,timestamp:Date.now()},o):this.errorCb(new Error(tn)))}processRequests(a){if(this.pendingRequest||this.queue.length===0)return;let{id:t,timestamp:o}=this.queue.shift();
7t&&this.success[t]||this.getSession(o,this.skuToken,c=>{c?this.errorCb(c):t&&(this.success[t]=!0)},a)}remove(){this.errorCb=null}},Ya=ra.getSessionAPI.bind(ra),oa=new Set;function Ho(a,t){t?oa.add(a):oa.delete(a)}class _r{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(t,o){this._updatedSourceCaches[t]=o,this.setDirty()}discardSourceCacheUpdate(t){delete this._updatedSourceCaches[t]}updateLayer(t){let o=t.scope;this._updatedLayers[o]=this._updatedLayers[o]||new Set,this._updatedLayers[o].add(t.id),this.setDirty()}removeLayer(t){let o=t.scope;this._removedLayers[o]=this._removedLayers[o]||{},this._updatedLayers[o]=this._updatedLayers[o]||new Set,this._removedLayers[o][t.id]=t,this._updatedLayers[o].delete(t.id),this._updatedPaintProps.delete(t.fqid),this.setDirty()}getRemovedLayer(t){return this._removedLayers[t.scope]?this._removedLayers[t.scope][t.id]:null}discardLayerRemoval(t){this._removedLayers[t.scope]&&delete this._removedLayers[t.scope][t.id]}getLayerUpdatesByScope(){let t={};for(let o in this._updatedLayers)t[o]=t[o]||{},t[o].updatedIds=Array.from(this._updatedLayers[o].values());for(let o in this._removedLayers)t[o]=t[o]||{},t[o].removedIds=Object.keys(this._removedLayers[o]);return t}getUpdatedPaintProperties(){return this._updatedPaintProps}updatePaintProperties(t){this._updatedPaintProps.add(t.fqid),this.setDirty()}getUpdatedImages(t){return this._updatedImages[t]?Array.from(this._updatedImages[t].values()):[]}updateImage(t,o){this._updatedImages[o]=this._updatedImages[o]||new Set,this._updatedImages[o].add(h.I.toString(t)),this.setDirty()}resetUpdatedImages(t){this._updatedImages[t]&&this._updatedImages[t].clear()}reset(){this._changed=!1,this._updatedLayers={},this._removedLayers={},this._updatedSourceCaches={},this._updatedPaintProps.clear(),this._updatedImages={}}}function gs(a){let{userImage:t}=a;return!!(t&&t.render&&t.render())&&(a.data.replace(new Uint8Array(t.data.buffer)),!0)}let ys=new h.C(0,0,0);function Ja(a,t,o){a===1&&t.icons.push(function(c,d){return function(m){if(m.usvg_tree.height||(m.usvg_tree.height=m.usvg_tree.width),!m.metadata)return m;let{metadata:_}=m;if(_.content_area){let{content_area:y}=_;y.left==null&&(y.left=0),y.top==null&&(y.top=y.left),y.width==null&&(y.width=m.usvg_tree.width),y.height==null&&(y.height=y.width)}if(_.text_placeholder){let{text_placeholder:y}=_;y.top==null&&(y.top=y.left),y.height==null&&(y.height=y.width)}return _.stretch_x&&_.stretch_x.length&&sa(_,"x"),_.stretch_y&&_.stretch_y.length&&sa(_,"y"),m}(c.readFields(gr,{name:void 0},d))}(o,o.readVarint()+o.pos))}function sa(a,t){let o=[],c=a[`stretch_${t}`],d=null;for(let m=0;m<c.length;m++)d===null?d=o.length===0?c[0]:o.at(-1)[1]+c[m]:(o.push([d,d+c[m]]),d=null);a[`stretch_${t}_areas`]=o}function gr(a,t,o){a===1?t.name=o.readString():a===2?t.metadata=function(c,d){return c.readFields(oc,{stretch_x:null,stretch_y:null,stretch_x_areas:null,stretch_y_areas:null,variables:[]},d)}(o,o.readVarint()+o.pos):a===3&&(t.usvg_tree=function(c,d){return c.readFields(Xn,{width:20,children:[],linear_gradients:[],radial_gradients:[],clip_paths:[],masks:[]},d)}(o,o.readVarint()+o.pos),t.data="usvg_tree")}function oc(a,t,o){a===1?t.stretch_x=o.readPackedVarint():a===2?t.stretch_y=o.readPackedVarint():a===3?t.content_area=Rr(o,o.readVarint()+o.pos):a===4?t.variables.push(function(c,d){return c.readFields(sc,{name:void 0},d)}(o,o.readVarint()+o.pos)):a===5&&(t.text_placeholder=Rr(o,o.readVarint()+o.pos))}function Rr(a,t){return a.readFields(uu,{},t)}function uu(a,t,o){a===1?t.left=o.readVarint():a===2?t.width=o.readVarint():a===3?t.top=o.readVarint():a===4&&(t.height=o.readVarint())}function sc(a,t,o){a===1?t.name=o.readString():a===2&&(t.rgb_color=Co(o.readVarint()),t.value="rgb_color")}function Xn(a,t,o){a===1?t.width=t.height=o.readVarint():a===2?t.height=o.readVarint():a===3?t.children.push(mo(o,o.readVarint()+o.pos)):a===4?t.linear_gradients.push(function(c,d){return c.readFields(hu,{spread_method:1,stops:[],x1:0,y1:0,x2:1,y2:0},d)}(o,o.readVarint()+o.pos)):a===5?t.radial_gradients.push(function(c,d){return c.readFields(Fh,{spread_method:1,stops:[],cx:.5,cy:.5,r:.5,fx:.5,fy:.5,fr:0},d)}(o,o.readVarint()+o.pos)):a===7?t.clip_paths.push(function(c,d){return c.readFields(Qa,{children:[]},d)}(o,o.readVarint()+o.pos)):a===8&&t.masks.push(function(c,d){let m=c.readFields(ke,{left:0,width:20,mask_type:1,children:[]},d);return m.height==null&&(m.height=m.width),m.top==null&&(m.top=m.left),m}(o,o.readVarint()+o.pos))}function mo(a,t){return a.readFields(qo,{},t)}function qo(a,t,o){a===1?(t.group=function(c,d){return c.readFields(aa,{opacity:255,children:[]},d)}(o,o.readVarint()+o.pos),t.node="group"):a===2&&(t.path=function(c,d){return c.readFields(ca,{paint_order:1,commands:[],step:1,diffs:[],rule:1},d)}(o,o.readVarint()+o.pos),t.node="path")}function aa(a,t,o){a===1?t.transform=_o(o,o.readVarint()+o.pos):a===2?t.opacity=o.readVarint():a===5?t.clip_path_idx=o.readVarint():a===6?t.mask_idx=o.readVarint():a===7&&t.children.push(mo(o,o.readVarint()+o.pos))}function _o(a,t){return a.readFields(la,{sx:1,ky:0,kx:0,sy:1,tx:0,ty:0},t)}function la(a,t,o){a===1?t.sx=o.readFloat():a===2?t.ky=o.readFloat():a===3?t.kx=o.readFloat():a===4?t.sy=o.readFloat():a===5?t.tx=o.readFloat():a===6&&(t.ty=o.readFloat())}function ca(a,t,o){a===1?t.fill=function(c,d){return c.readFields(ac,{rgb_color:ys,paint:"rgb_color",opacity:255},d)}(o,o.readVarint()+o.pos):a===2?t.stroke=function(c,d){return c.readFields(lc,{rgb_color:ys,paint:"rgb_color",dasharray:[],dashoffset:0,miterlimit:4,opacity:255,width:1,linecap:1,linejoin:1},d)}(o,o.readVarint()+o.pos):a===3?t.paint_order=o.readVarint():a===5?o.readPackedVarint(t.commands):a===6?t.step=o.readFloat():a===7?o.readPackedSVarint(t.diffs):a===8&&(t.rule=o.readVarint())}function ac(a,t,o){a===1?(t.rgb_color=Co(o.readVarint()),t.paint="rgb_color"):a===2?(t.linear_gradient_idx=o.readVarint(),t.paint="linear_gradient_idx"):a===3?(t.radial_gradient_idx=o.readVarint(),t.paint="radial_gradient_idx"):a===5&&(t.opacity=o.readVarint())}function Co(a){return new h.C((a>>16&255)/255,(a>>8&255)/255,(255&a)/255,1)}function lc(a,t,o){a===1?(t.rgb_color=Co(o.readVarint()),t.paint="rgb_color"):a===2?(t.linear_gradient_idx=o.readVarint(),t.paint="linear_gradient_idx"):a===3?(t.radial_gradient_idx=o.readVarint(),t.paint="radial_gradient_idx"):a===5?o.readPackedFloat(t.dasharray):a===6?t.dashoffset=o.readFloat():a===7?t.miterlimit=o.readFloat():a===8?t.opacity=o.readVarint():a===9?t.width=o.readFloat():a===10?t.linecap=o.readVarint():a===11&&(t.linejoin=o.readVarint())}function hu(a,t,o){a===1?t.transform=_o(o,o.readVarint()+o.pos):a===2?t.spread_method=o.readVarint():a===3?t.stops.push(Ka(o,o.readVarint()+o.pos)):a===4?t.x1=o.readFloat():a===5?t.y1=o.readFloat():a===6?t.x2=o.readFloat():a===7&&(t.y2=o.readFloat())}function Ka(a,t){return a.readFields(du,{offset:0,opacity:255,rgb_color:ys},t)}function du(a,t,o){a===1?t.offset=o.readFloat():a===2?t.opacity=o.readVarint():a===3&&(t.rgb_color=Co(o.readVarint()))}function Fh(a,t,o){a===1?t.transform=_o(o,o.readVarint()+o.pos):a===2?t.spread_method=o.readVarint():a===3?t.stops.push(Ka(o,o.readVarint()+o.pos)):a===4?t.cx=o.readFloat():a===5?t.cy=o.readFloat():a===6?t.r=o.readFloat():a===7?t.fx=o.readFloat():a===8?t.fy=o.readFloat():a===9&&(t.fr=o.readFloat())}function Qa(a,t,o){a===1?t.transform=_o(o,o.readVarint()+o.pos):a===2?t.clip_path_idx=o.readVarint():a===3&&t.children.push(mo(o,o.readVarint()+o.pos))}function ke(a,t,o){a===1?t.left=t.top=o.readFloat():a===2?t.width=t.height=o.readFloat():a===3?t.top=o.readFloat():a===4?t.height=o.readFloat():a===5?t.mask_type=o.readVarint():a===6?t.mask_idx=o.readVarint():a===7&&t.children.push(mo(o,o.readVarint()+o.pos))}class Zo{static calculate(t={},o=[]){let c=new Map,d=new Map;if(Object.keys(t).length===0)return c;o.forEach(m=>{d.set(m.name,m.rgb_color||new h.C(0,0,0))});for(let[m,_]of Object.entries(t))d.has(m)?c.set(d.get(m).toString(),_):console.warn(`Ignoring unknown image variable "${m}"`);return c}}function xs(a,t=255,o){let c=o.get(a.toString())||a;if(t===255)return c.toString();let d=c.clone();return d.a*=t/255,d.toString()}let ua=[],el=0;function _e(a,t){if(el>=ua.length){let c=h.r()?new OffscreenCanvas(a,t):document.createElement("canvas");ua.push(c.getContext("2d",{willReadFrequently:!0}))}let o=ua[el++];return o.canvas.width=a,o.canvas.height=t,o}function B(){el--}
7function V(a,t,o,c,d){for(let m of c.children)X(a,t,o,m,d)}function X(a,t,o,c,d){c.group?(a.save(),function(m,_,y,v,T){let I=v.mask_idx!=null?y.masks[v.mask_idx]:null,P=v.clip_path_idx!=null?y.clip_paths[v.clip_path_idx]:null;if(v.transform&&(_=Ke(v.transform).preMultiplySelf(_)),!function(D,L,O){return D.opacity!==255||L||O}(v,P!=null,I!=null))return void V(m,_,y,v,T);let A=_e(m.canvas.width,m.canvas.height);V(A,_,y,v,T),P&&Ne(A,_,y,P),I&&Oe(A,_,y,I,T),m.globalAlpha=v.opacity/255,m.drawImage(A.canvas,0,0),B()}(a,t,o,c.group,d),a.restore()):c.path&&(a.save(),function(m,_,y,v,T){m.setTransform(_),v.paint_order===1?(ae(m,y,v,T),ce(m,y,v,T)):(ce(m,y,v,T),ae(m,y,v,T))}(a,t,o,c.path,d),a.restore())}function ae(a,t,o,c){let d=o.fill;if(!d)return;let m=d.opacity/255;switch(a.save(),a.beginPath(),ct(o,a),d.paint){case"rgb_color":a.fillStyle=xs(d.rgb_color,d.opacity,c);break;case"linear_gradient_idx":{let _=t.linear_gradients[d.linear_gradient_idx];_.transform&&a.setTransform(Ke(_.transform).preMultiplySelf(a.getTransform())),a.fillStyle=we(a,_,m,c);break}case"radial_gradient_idx":{let _=t.radial_gradients[d.radial_gradient_idx];_.transform&&a.setTransform(Ke(_.transform).preMultiplySelf(a.getTransform())),a.fillStyle=ne(a,_,m,c)}}a.fill(le(o)),a.restore()}function le(a){return a.rule===1?"nonzero":a.rule===2?"evenodd":void 0}function ce(a,t,o,c){let d=o.stroke;if(!d)return;let m=ht(o);a.lineWidth=d.width,a.miterLimit=d.miterlimit,a.setLineDash(d.dasharray),a.lineDashOffset=d.dashoffset;let _=d.opacity/255;switch(d.paint){case"rgb_color":a.strokeStyle=xs(d.rgb_color,d.opacity,c);break;case"linear_gradient_idx":a.strokeStyle=we(a,t.linear_gradients[d.linear_gradient_idx],_,c,!0);break;case"radial_gradient_idx":a.strokeStyle=ne(a,t.radial_gradients[d.radial_gradient_idx],_,c,!0)}switch(d.linejoin){case 2:case 1:a.lineJoin="miter";break;case 3:a.lineJoin="round";break;case 4:a.lineJoin="bevel"}switch(d.linecap){case 1:a.lineCap="butt";break;case 2:a.lineCap="round";break;case 3:a.lineCap="square"}a.stroke(m)}function we(a,t,o,c,d=!1){if(t.stops.length===1){let A=t.stops[0];return xs(A.rgb_color,A.opacity*o,c)}let{x1:m,y1:_,x2:y,y2:v}=t,T=new DOMPoint(m,_),I=new DOMPoint(y,v);if(d){let A=Ke(t.transform);T=A.transformPoint(T),I=A.transformPoint(I)}let P=a.createLinearGradient(T.x,T.y,I.x,I.y);for(let A of t.stops)P.addColorStop(A.offset,xs(A.rgb_color,A.opacity*o,c));return P}function ne(a,t,o,c,d=!1){if(t.stops.length===1){let N=t.stops[0];return xs(N.rgb_color,N.opacity*o,c)}let m=Ke(t.transform),{fx:_,fy:y,fr:v,cx:T,cy:I,r:P}=t,A=new DOMPoint(_,y),D=new DOMPoint(T,I),L=v,O=P;if(d){A=m.transformPoint(A),D=m.transformPoint(D);let N=(m.a+m.d)/2;L=v*N,O=t.r*N}let k=a.createRadialGradient(A.x,A.y,L,D.x,D.y,O);for(let N of t.stops)k.addColorStop(N.offset,xs(N.rgb_color,N.opacity*o,c));return k}function ye(a,t,o,c){let d=c.transform?Ke(c.transform).preMultiplySelf(t):t,m=_e(a.canvas.width,a.canvas.height);for(let y of c.children)if(y.group)ye(m,d,o,y.group);else if(y.path){let v=y.path,T=new Path2D;T.addPath(ht(v),d),m.fill(T,le(v))}let _=c.clip_path_idx!=null?o.clip_paths[c.clip_path_idx]:null;_&&Ne(m,d,o,_),a.globalCompositeOperation="source-over",a.drawImage(m.canvas,0,0),B()}function Ne(a,t,o,c){let d=_e(a.canvas.width,a.canvas.height);ye(d,t,o,c),a.globalCompositeOperation="destination-in",a.drawImage(d.canvas,0,0),B()}function Oe(a,t,o,c,d){if(c.children.length===0)return;let m=c.mask_idx!=null?o.masks[c.mask_idx]:null;m&&Oe(a,t,o,m,d);let _=a.canvas.width,y=a.canvas.height,v=_e(_,y),T=c.width,I=c.height,P=c.left,A=c.top,D=new Path2D,L=new Path2D;L.rect(P,A,T,I),D.addPath(L,t),v.clip(D);for(let N of c.children)X(v,t,o,N,d);let O=v.getImageData(0,0,_,y),k=O.data;if(c.mask_type===1)for(let N=0;N<k.length;N+=4)k[N+3]=k[N+3]/255*(.2126*k[N]+.7152*k[N+1]+.0722*k[N+2]);v.putImageData(O,0,0),a.globalCompositeOperation="destination-in",a.drawImage(v.canvas,0,0),B()}function Ke(a){return a?new DOMMatrix([a.sx,a.ky,a.kx,a.sy,a.tx,a.ty]):new DOMMatrix}function ct(a,t){let o=a.step,c=a.diffs[0]*o,d=a.diffs[1]*o;t.moveTo(c,d);for(let m=0,_=2;m<a.commands.length;m++)switch(a.commands[m]){case 1:c+=a.diffs[_++]*o,d+=a.diffs[_++]*o,t.moveTo(c,d);break;case 2:c+=a.diffs[_++]*o,d+=a.diffs[_++]*o,t.lineTo(c,d);break;case 3:{let y=c+a.diffs[_++]*o,v=d+a.diffs[_++]*o;c=y+a.diffs[_++]*o,d=v+a.diffs[_++]*o,t.quadraticCurveTo(y,v,c,d);break}case 4:{let y=c+a.diffs[_++]*o,v=d+a.diffs[_++]*o,T=y+a.diffs[_++]*o,I=v+a.diffs[_++]*o;c=T+a.diffs[_++]*o,d=I+a.diffs[_++]*o,t.bezierCurveTo(y,v,T,I,c,d);break}case 5:t.closePath();break;default:}return t}function ht(a){return ct(a,new Path2D)}function Lt(a,t){}class St{constructor(){this.cacheMap=new Map,this.cacheDependenciesMap=new Map}static _getImage(t){return new h.q(t,t.data)}getFromCache(t,o,c){return this.cacheMap.has(c)||this.cacheMap.set(c,new h.L(150)),this.cacheMap.get(c).get(h.t(t.toString(),o))}setInCache(t,o,c,d){this.cacheDependenciesMap.has(d)||this.cacheDependenciesMap.set(d,new Map),this.cacheMap.has(d)||this.cacheMap.set(d,new h.L(150));let m=this.cacheDependenciesMap.get(d),_=h.t(t.id.toString(),c);m.get(_)||m.set(_,new Set);let y=this.cacheMap.get(d),v=t.toString();m.get(_).add(v),y.put(h.t(t.toString(),c),o)}removeImagesFromCacheByIds(t,o,c=0){if(!this.cacheMap.has(c)||!this.cacheDependenciesMap.has(c))return;let d=this.cacheMap.get(c),m=this.cacheDependenciesMap.get(c);for(let _ of t){let y=h.t(_.toString(),o);if(m.has(y)){for(let v of m.get(y))d.delete(v);m.delete(y)}}}rasterize(t,o,c,d){let m=this.getFromCache(t,c,d);if(m)return m.clone();let _=function(v,T){let I=Zo.calculate(T.params,v.metadata?v.metadata.variables:[]),P=v.usvg_tree,A=P.width,D=P.height,L=Math.max(1,Math.round(A*T.sx)),O=Math.max(1,Math.round(D*T.sy)),k=new DOMMatrix([L/A,0,0,O/D,0,0]),N=_e(L,O);V(N,k,P,P,I);let q=N.getImageData(0,0,L,O);return B(),q}(o.icon,t),y=St._getImage(_);return this.setInCache(t,y,c,d),y.clone()}}class Mt extends h.E{constructor(t){super(),this.imageProviders=new Map,this.images=new Map,this.updatedImages=new Map,this.callbackDispatchedThisFrame=new Map,this.imageVersions=new Map,this.loaded=new Map,this.requestors=[],this.patterns=new Map,this.patternsInFlight=new Set,this.atlasImage=new Map,this.atlasTexture=new Map,this.imageAtlasCache=new h.x,this.dirty=!0,this.spriteFormat=t,this.imageRasterizer=new St}addScope(t){this.loaded.set(t,!1),this.imageProviders.set(t,new Map),this.images.set(t,new Map),this.updatedImages.set(t,new Set),this.callbackDispatchedThisFrame.set(t,new Set),this.imageVersions.set(t,new Map),this.patterns.set(t,new Map),this.atlasImage.set(t,new h.q({width:1,height:1}))}removeScope(t){this.loaded.delete(t),this.imageProviders.delete(t),this.images.delete(t),this.updatedImages.delete(t),this.callbackDispatchedThisFrame.delete(t),this.imageVersions.delete(t),this.patterns.delete(t),this.atlasImage.delete(t);let o=this.atlasTexture.get(t);o&&(o.destroy(),this.atlasTexture.delete(t))}addImageProvider(t,o){this.imageProviders.has(o)||this.imageProviders.set(o,new Map),this.imageProviders.get(o).set(t.id,t)}removeImageProvider(t,o){this.imageProviders.has(o)&&this.imageProviders.get(o).delete(t)}getPendingImageProviders(){let t=[];for(let o of this.imageProviders.values())for(let c of o.values())c.hasPendingRequests()&&t.push(c);return t}isLoaded(){for(let t of this.loaded.keys())if(!this.loaded.get(t))return!1;return!0}setLoaded(t,o){if(this.loaded.get(o)!==t&&(this.loaded.set(o,t),t)){for(let{ids:c,callback:d}of this.requestors)this._notify(c,o,d);this.requestors=[]}}hasImage(t,o){return!!this.getImage(t,o)}getImage(t,o){return this.images.get(o).get(t.toString())}
7addImage(t,o,c){if(this._validate(t,c)){this.images.get(o).set(t.toString(),c);let d=this.imageVersions.get(o),m=d.get(t.toString())||0;d.set(t.toString(),m+1)}}_validate(t,o){let c=!0;return this._validateStretch(o.stretchX,o.data&&o.data.width)||(this.fire(new h.y(new Error(`Image "${t.name}" has invalid "stretchX" value`))),c=!1),this._validateStretch(o.stretchY,o.data&&o.data.height)||(this.fire(new h.y(new Error(`Image "${t.name}" has invalid "stretchY" value`))),c=!1),this._validateContent(o.content,o)||(this.fire(new h.y(new Error(`Image "${t.name}" has invalid "content" value`))),c=!1),c}_validateStretch(t,o){if(!t)return!0;let c=0;for(let d of t){if(d[0]<c||d[1]<d[0]||o<d[1])return!1;c=d[1]}return!0}_validateContent(t,o){return t?t.length!==4||!o.usvg&&(t[0]<0||o.data.width<t[0]||t[1]<0||o.data.height<t[1]||t[2]<0||o.data.width<t[2]||t[3]<0||o.data.height<t[3])?!1:!(t[2]<t[0]||t[3]<t[1]):!0}updateImage(t,o,c){let d=this.images.get(o).get(t.toString());c.version=d.version+1,this.images.get(o).set(t.toString(),c),this.updatedImages.get(o).add(t);let m=this.imageVersions.get(o),_=m.get(t.toString())||0;m.set(t.toString(),_+1),this.removeFromImageRasterizerCache(t,o)}clearUpdatedImages(t){this.updatedImages.get(t).clear()}removeFromImageRasterizerCache(t,o){this.spriteFormat!=="raster"&&this.imageRasterizer.removeImagesFromCacheByIds([t],o)}removeImage(t,o){let c=this.images.get(o),d=c.get(t.toString());c.delete(t.toString());let m=this.imageVersions.get(o),_=m.get(t.toString())||0;m.set(t.toString(),_+1),this.patterns.get(o).delete(t.toString()),this.removeFromImageRasterizerCache(t,o),d.userImage&&d.userImage.onRemove&&d.userImage.onRemove()}listImages(t){return Array.from(this.images.get(t).keys()).map(o=>h.I.from(o))}getImageVersions(t){let o=this.imageVersions.get(t);if(o)return o}getImages(t,o,c){let d=[],m=[],_=this.imageProviders.get(o);for(let I of t){if(!I.iconsetId){d.push(I);continue}let P=_.get(I.iconsetId);P&&(this.getImage(I,o)?m.push(I):P.addPendingRequest(I))}if(d.length===0)return void this._notify(m,o,c);let y=!0,v=!!this.loaded.get(o),T=this.images.get(o);if(!v)for(let I of d)T.has(I.toString())||(y=!1);v||y?this._notify(d,o,c):this.requestors.push({ids:d,scope:o,callback:c})}rasterizeImages(t,o){let c=new Map,{iconTasks:d,patternTasks:m,scope:_}=t;for(let y of[d,m])for(let[v,T]of y.entries()){let I=this.getImage(T.id,_);I&&c.set(v,{image:I,imageVariant:T})}o(null,this._rasterizeImages(_,c))}_rasterizeImages(t,o){let c=new Map;for(let[d,{image:m,imageVariant:_}]of o.entries())c.set(d,this.imageRasterizer.rasterize(_,m,t,0));return c}getUpdatedImages(t){return this.updatedImages.get(t)||new Set}_notify(t,o,c){let d=this.images.get(o),m=new Map;for(let _ of t){if(!d.get(_.toString())){if(_.iconsetId)continue;this.fire(new h.z("styleimagemissing",{id:_.name}))}let y=d.get(_.toString());if(!y){h.w(`Image "${_.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 v={data:y.usvg?null:y.data.clone(),pixelRatio:y.pixelRatio,sdf:y.sdf,usvg:y.usvg,stretchX:y.stretchX,stretchY:y.stretchY,content:y.content,hasRenderCallback:!!(y.userImage&&y.userImage.render)};y.usvg&&Object.assign(v,{width:y.icon.usvg_tree.width,height:y.icon.usvg_tree.height}),m.set(h.I.toString(_),v)}c(null,{images:m,versions:this.getImageVersions(o)})}getPixelSize(t){let{width:o,height:c}=this.atlasImage.get(t);return{width:o,height:c}}getPattern(t,o,c){let d=t.toString(),m=this.patterns.get(o),_=m.get(d),y=this.getImage(t,o);if(!y)return null;if(_){if(_.position.version===y.version)return _.position;_.position.version=y.version}else{if(y.usvg&&!y.data){let v=this.getPatternInFlightId(d,o);if(this.patternsInFlight.has(v))return null;this.patternsInFlight.add(v);let T=new h.A(t).scaleSelf(h.o.devicePixelRatio),I=new Map([[T.toString(),{image:y,imageVariant:T}]]),P=this._rasterizeImages(o,I);return this.storePatternImage(T,o,y,c,P),null}this.storePattern(t,o,y)}return this._updatePatternAtlas(o,c),m.get(d).position}getPatternInFlightId(t,o){return h.t(t,o)}hasPatternsInFlight(){return this.patternsInFlight.size!==0}storePatternImage(t,o,c,d,m){let _=t.toString(),y=m?m.get(_):void 0;y&&(c.data=y,this.storePattern(t.id,o,c),this._updatePatternAtlas(o,d),this.patternsInFlight.delete(this.getPatternInFlightId(t.id.toString(),o)))}storePattern(t,o,c){let d={w:c.data.width+2*h.B,h:c.data.height+2*h.B,x:0,y:0},m=new h.D(d,c,h.B);this.patterns.get(o).set(t.toString(),{bin:d,position:m})}destroyAtlasTextures(){for(let t of this.atlasTexture.values())t&&t.destroy();this.atlasTexture.clear()}bind(t,o){let c=t.gl,d=this.atlasTexture.get(o);d?this.dirty&&(d.update(this.atlasImage.get(o)),this.dirty=!1):(d=new h.T(t,this.atlasImage.get(o),c.RGBA8),this.atlasTexture.set(o,d)),d.bind(c.LINEAR,c.CLAMP_TO_EDGE)}_updatePatternAtlas(t,o){let c=this.patterns.get(t),d=Array.from(c.values()).map(({bin:T})=>T),{w:m,h:_}=h.F(d),y=this.atlasImage.get(t);y.resize({width:m||1,height:_||1});let v=this.images.get(t);for(let[T,{bin:I,position:P}]of c.entries()){let A=P.padding,D=I.x+A,L=I.y+A,O=v.get(T).data,k=O.width,N=O.height;A=A>1?A-1:A,h.q.copy(O,y,{x:0,y:0},{x:D,y:L},{width:k,height:N},o),h.q.copy(O,y,{x:0,y:N-A},{x:D,y:L-A},{width:k,height:A},o),h.q.copy(O,y,{x:0,y:0},{x:D,y:L+N},{width:k,height:A},o),h.q.copy(O,y,{x:k-A,y:0},{x:D-A,y:L},{width:A,height:N},o),h.q.copy(O,y,{x:0,y:0},{x:D+k,y:L},{width:A,height:N},o),h.q.copy(O,y,{x:k-A,y:N-A},{x:D-A,y:L-A},{width:A,height:A},o),h.q.copy(O,y,{x:0,y:N-A},{x:D+k,y:L-A},{width:A,height:A},o),h.q.copy(O,y,{x:0,y:0},{x:D+k,y:L+N},{width:A,height:A},o),h.q.copy(O,y,{x:k-A,y:0},{x:D-A,y:L+N},{width:A,height:A},o)}this.dirty=!0}beginFrame(){for(let t of this.images.keys())this.callbackDispatchedThisFrame.set(t,new Set)}
vendor: 6,508 bytes, line 7
7dispatchRenderCallbacks(t,o){let c=this.images.get(o);for(let d of t){if(this.callbackDispatchedThisFrame.get(o).has(d.toString()))continue;this.callbackDispatchedThisFrame.get(o).add(d.toString());let m=c.get(d.toString());gs(m)&&this.updateImage(d,o,m)}}}class Ve{constructor(t,o,c,d){this.message=(t?`${t}: `:"")+c,d&&(this.identifier=d),o!=null&&o.__line__&&(this.line=o.__line__)}}class Ut extends Ve{}function $i(a){let t=a.value,o=a.valueSpec,c=a.style,d=a.styleSpec,m=a.key,_=a.arrayElementValidator||Pi;if(!Array.isArray(t))return[new Ve(m,t,`array expected, ${h.J(t)} found`)];if(o.length&&t.length!==o.length)return[new Ve(m,t,`array length ${o.length} expected, length ${t.length} found`)];if(o["min-length"]&&t.length<o["min-length"])return[new Ve(m,t,`array length at least ${o["min-length"]} expected, length ${t.length} found`)];let y={type:o.value,values:o.values,minimum:o.minimum,maximum:o.maximum,function:void 0};d.$version<7&&(y.function=o.function),h.G(o.value)&&(y=o.value);let v=[];for(let T=0;T<t.length;T++)v=v.concat(_({array:t,arrayIndex:T,value:t[T],valueSpec:y,style:c,styleSpec:d,key:`${m}[${T}]`},!0));return v}function Hi(a){let t=a.key,o=a.value,c=a.valueSpec;if(!h.K(o))return[new Ve(t,o,`number expected, ${h.J(o)} found`)];if(o!=o)return[new Ve(t,o,"number expected, NaN found")];if("minimum"in c){let d=c.minimum;if(Array.isArray(c.minimum)&&(d=c.minimum[a.arrayIndex]),o<d)return[new Ve(t,o,`${o} is less than the minimum value ${d}`)]}if("maximum"in c){let d=c.maximum;if(Array.isArray(c.maximum)&&(d=c.maximum[a.arrayIndex]),o>d)return[new Ve(t,o,`${o} is greater than the maximum value ${d}`)]}return[]}function Ot(a){let t=a.key,o=a.value;if(!h.G(o))return[new Ve(t,o,`object expected, ${h.J(o)} found`)];let c=a.valueSpec,d=h.H(o.type),m,_,y,v={},T=d!=="categorical"&&o.property===void 0,I=!T,P=function(O){let k=O.stops;return Array.isArray(k)&&Array.isArray(k[0])&&h.G(k[0][0])}(o),A=In({key:a.key,value:a.value,valueSpec:a.styleSpec.function,style:a.style,styleSpec:a.styleSpec,objectElementValidators:{stops:function(O){if(d==="identity")return[new Ve(O.key,O.value,'identity function may not have a "stops" property')];let k=[],N=O.value;return k=k.concat($i({key:O.key,value:N,valueSpec:O.valueSpec,style:O.style,styleSpec:O.styleSpec,arrayElementValidator:D})),Array.isArray(N)&&N.length===0&&k.push(new Ve(O.key,N,"array must have at least one stop")),k},default:function(O){return Pi({key:O.key,value:O.value,valueSpec:c,style:O.style,styleSpec:O.styleSpec})}}});return d==="identity"&&T&&A.push(new Ve(a.key,a.value,'missing required property "property"')),d==="identity"||o.stops||A.push(new Ve(a.key,a.value,'missing required property "stops"')),d==="exponential"&&c.expression&&!h.M(c)&&A.push(new Ve(a.key,a.value,"exponential functions not supported")),a.styleSpec.$version>=8&&(I&&!h.N(c)?A.push(new Ve(a.key,a.value,"property functions not supported")):T&&!h.O(c)&&A.push(new Ve(a.key,a.value,"zoom functions not supported"))),d!=="categorical"&&!P||o.property!==void 0||A.push(new Ve(a.key,a.value,'"property" property is required')),A;function D(O){let k=[],N=O.value,q=O.key;if(!Array.isArray(N))return[new Ve(q,N,`array expected, ${h.J(N)} found`)];if(N.length!==2)return[new Ve(q,N,`array length 2 expected, length ${N.length} found`)];if(P){if(!h.G(N[0]))return[new Ve(q,N,`object expected, ${h.J(N[0])} found`)];let Z=N[0];if(Z.zoom===void 0)return[new Ve(q,N,"object stop key must have zoom")];if(Z.value===void 0)return[new Ve(q,N,"object stop key must have value")];let G=h.H(Z.zoom);if(typeof G!="number")return[new Ve(q,Z.zoom,"stop zoom values must be numbers")];if(y&&y>G)return[new Ve(q,Z.zoom,"stop zoom values must appear in ascending order")];G!==y&&(y=G,_=void 0,v={}),k=k.concat(In({key:`${q}[0]`,value:N[0],valueSpec:{zoom:{}},style:O.style,styleSpec:O.styleSpec,objectElementValidators:{zoom:Hi,value:L}}))}else k=k.concat(L({key:`${q}[0]`,value:N[0],style:O.style,styleSpec:O.styleSpec},N));return h.Q(h.S(N[1]))?k.concat([new Ve(`${q}[1]`,N[1],"expressions are not allowed in function stops.")]):k.concat(Pi({key:`${q}[1]`,value:N[1],valueSpec:c,style:O.style,styleSpec:O.styleSpec}))}function L(O,k){let N=h.J(O.value),q=h.H(O.value),Z=O.value!==null?O.value:k;if(m){if(N!==m)return[new Ve(O.key,Z,`${N} stop domain type must match previous stop domain type ${m}`)]}else m=N;if(N!=="number"&&N!=="string"&&N!=="boolean"&&typeof q!="number"&&typeof q!="string"&&typeof q!="boolean")return[new Ve(O.key,Z,"stop domain value must be a number, string, or boolean")];if(N!=="number"&&d!=="categorical"){let G=`number expected, ${N} found`;return h.N(c)&&d===void 0&&(G+='\nIf you intended to use a categorical function, specify `"type": "categorical"`.'),[new Ve(O.key,Z,G)]}return d!=="categorical"||N!=="number"||typeof q=="number"&&isFinite(q)&&Math.floor(q)===q?d!=="categorical"&&N==="number"&&typeof q=="number"&&typeof _=="number"&&_!==void 0&&q<_?[new Ve(O.key,Z,"stop domain values must appear in ascending order")]:(_=q,d==="categorical"&&q in v?[new Ve(O.key,Z,"stop domain values must be unique")]:(v[q]=!0,[])):[new Ve(O.key,Z,`integer expected, found ${String(q)}`)]}}function ti(a){let t=(a.expressionContext==="property"?h.V:h.U)(h.S(a.value),a.valueSpec);if(t.result==="error")return t.value.map(c=>new Ve(`${a.key}${c.key}`,a.value,c.message));let o=t.value.expression||t.value._styleExpression.expression;if(a.expressionContext==="property"&&a.propertyKey==="text-font"&&!o.outputDefined())return[new Ve(a.key,a.value,`Invalid data expression for "${a.propertyKey}". Output values must be contained as literals within the expression.`)];if(a.expressionContext==="property"&&a.propertyType==="layout"&&!h.Y(o))return[new Ve(a.key,a.value,'"feature-state" data expressions are not supported with layout properties.')];if(a.expressionContext==="filter")return Ci(o,a);if(a.expressionContext==="appearance")return nn(o,a);if(a.expressionContext&&a.expressionContext.indexOf("cluster")===0){if(!h.W(o,["zoom","feature-state"]))return[new Ve(a.key,a.value,'"zoom" and "feature-state" expressions are not supported with cluster properties.')];if(a.expressionContext==="cluster-initial"&&!h.X(o))return[new Ve(a.key,a.value,"Feature data expressions are not supported with initial expression part of cluster properties.")]}return[]}function Ci(a,t){let o=new Set(["zoom","feature-state","pitch","distance-from-center"]);if(t.valueSpec&&t.valueSpec.expression)for(let d of t.valueSpec.expression.parameters)o.delete(
7d);if(o.size===0)return[];let c=[];return a instanceof h.Z&&o.has(a.name)?[new Ve(t.key,t.value,`["${a.name}"] expression is not supported in a filter for a ${t.object.type} layer with id: ${t.object.id}`)]:(a.eachChild(d=>{c.push(...Ci(d,t))}),c)}function nn(a,t){let o=new Set;if(t.valueSpec&&t.valueSpec.expression)for(let d of t.valueSpec.expression.parameters)o.add(d);if(o.size===0)return[];let c=[];return a instanceof h.Z&&!o.has(a.name)?[new Ve(t.key,t.value,`["${a.name}"] is not an allowed parameter`)]:(a.eachChild(d=>{c.push(...nn(d,t))}),c)}function ii(a){let t=a.key,o=a.value,c=a.valueSpec,d=[];return Array.isArray(c.values)?c.values.includes(h.H(o))||d.push(new Ve(t,o,`expected one of [${c.values.join(", ")}], ${JSON.stringify(o)} found`)):Object.keys(c.values).includes(h.H(o))||d.push(new Ve(t,o,`expected one of [${Object.keys(c.values).join(", ")}], ${JSON.stringify(o)} found`)),d}function Ai(a){return h.a1(h.S(a.value))?ti(Object.assign({},a,{expressionContext:"filter",valueSpec:a.styleSpec[`filter_${a.layerType||"fill"}`]})):Bi(a)}function Bi(a){let t=a.value,o=a.key;if(!Array.isArray(t))return[new Ve(o,t,`array expected, ${h.J(t)} found`)];if(t.length<1)return[new Ve(o,t,"filter array must have at least 1 element")];let c=a.styleSpec,d=ii({key:`${o}[0]`,value:t[0],valueSpec:c.filter_operator}),m=()=>{t.length>=2&&(h.$(t[1])||d.push(new Ve(`${o}[1]`,t[1],`string expected, ${h.J(t[1])} found`)));for(let _=2;_<t.length;_++)h.H(t[1])==="$type"?d=d.concat(ii({key:`${o}[${_}]`,value:t[_],valueSpec:c.geometry_type})):h.$(t[_])||h.K(t[_])||h._(t[_])||d.push(new Ve(`${o}[${_}]`,t[_],`string, number, or boolean expected, ${h.J(t[_])} found.`))};switch(h.H(t[0])){case"<":case"<=":case">":case">=":t.length>=2&&h.H(t[1])==="$type"&&d.push(new Ve(o,t,`"$type" cannot be use with operator "${t[0]}"`)),t.length!==3&&d.push(new Ve(o,t,`filter array for operator "${t[0]}" must have 3 elements`)),m();break;case"==":case"!=":t.length!==3&&d.push(new Ve(o,t,`filter array for operator "${t[0]}" must have 3 elements`)),m();break;case"in":case"!in":m();break;case"any":case"all":case"none":for(let _=1;_<t.length;_++)d=d.concat(Bi({key:`${o}[${_}]`,value:t[_],style:a.style,styleSpec:a.styleSpec}));break;case"has":case"!has":t.length!==2?d.push(new Ve(o,t,`filter array for "${t[0]}" operator must have 2 elements`)):h.$(t[1])||d.push(new Ve(`${o}[1]`,t[1],`string expected, ${h.J(t[1])} found`))}return d}let vi=/^{([^}]+)}$/;function Wi(a,t){let o=a.key,c=a.style,d=a.layer,m=a.styleSpec,_=a.value,y=a.objectKey,v=m[`${t}_${a.layerType}`];if(!v)return[];let T=y.match(h.a2);if(T&&v[T[1]])return h.Q(h.S(_))?[].concat(Pi({key:o,value:_,valueSpec:{type:"string",expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"data-driven"},style:c,styleSpec:m,expressionContext:"property",propertyType:t,propertyKey:y})):Pi({key:o,value:_,valueSpec:{type:"string"},style:c,styleSpec:m});let I=y.match(h.a3);if(t==="paint"&&I&&v[I[1]]&&v[I[1]].transition)return Pi({key:o,value:_,valueSpec:m.transition,style:c,styleSpec:m});let P=a.valueSpec||v[y];if(!P)return[new Ut(o,_,`unknown property "${y}"`)];let A;if(h.$(_)&&h.N(P)&&!P.tokens&&(A=vi.exec(_))){let L=`\`{ "type": "identity", "property": ${A?JSON.stringify(A[1]):'"_"'} }\``;return[new Ve(o,_,`"${y}" does not support interpolation syntax 8Use an identity property function instead: ${L}.`)]}let D=[];if(a.layerType==="symbol")y!=="text-field"||!c||c.glyphs||c.imports||D.push(new Ve(o,_,'use of "text-field" requires a style "glyphs" property')),y==="text-font"&&h.a4(h.S(_))&&h.H(_.type)==="identity"&&D.push(new Ve(o,_,'"text-font" does not support identity functions'));else if(a.layerType==="model"&&t==="paint"&&d&&d.layout&&Object.hasOwn(d.layout,"model-id")&&h.N(P)&&(h.a5(P)||h.O(P))){let L=h.V(h.S(_),P).value,O="expression"in L&&L.expression||"_styleExpression"in L&&L._styleExpression&&L._styleExpression.expression;O&&!h.W(O,["measure-light"])&&(y==="model-emissive-strength"&&h.X(O)&&h.Y(O)||D.push(new Ve(o,_,`${y} does not support measure-light expressions when the model layer source is vector tile or GeoJSON.`)))}return D.concat(Pi({key:a.key,value:_,valueSpec:P,style:c,styleSpec:m,expressionContext:"property",propertyType:t,propertyKey:y}))}function Bn(a){return Wi(a,"paint")}function yn(a){return Wi(a,"layout")}function zn(a){let t=[],o=a.value,c=a.key,d=a.style,m=a.styleSpec;if(!h.G(o))return[new Ve(c,o,"object expected")];o.type||o.ref||t.push(new Ve(c,o,'either "type" or "ref" is required'));let _=h.H(o.type),y=h.H(o.ref);
8if(o.id){let v=h.H(o.id);for(let T=0;T<a.arrayIndex;T++){let I=d.layers[T];h.H(I.id)===v&&t.push(new Ve(c,o.id,`duplicate layer id "${v}", previously used at line ${I.id.__line__}`))}}if("ref"in o){let v;["type","source","source-layer","filter","layout"].forEach(T=>{T in o&&t.push(new Ve(c,o[T],`"${T}" is prohibited for ref layers`))}),d.layers.forEach(T=>{h.H(T.id)===y&&(v=T)}),v?v.ref?t.push(new Ve(c,o.ref,"ref cannot reference another ref layer")):_=h.H(v.type):typeof y=="string"&&t.push(new Ve(c,o.ref,`ref layer "${y}" not found`))}else if(_!=="background"&&_!=="sky"&&_!=="slot")if(o.source)if(h.$(o.source)){let v=d.sources&&d.sources[o.source],T=v&&h.H(v.type);v?T==="vector"&&_==="raster"?t.push(new Ve(c,o.source,`layer "${o.id}" requires a raster source`)):T==="raster"&&_!=="raster"?t.push(new Ve(c,o.source,`layer "${o.id}" requires a vector source`)):T!=="vector"||o["source-layer"]?T==="raster-dem"&&_!=="hillshade"?t.push(new Ve(c,o.source,"raster-dem source can only be used with layer type 'hillshade'.")):T!=="raster-array"||["raster","raster-particle"].includes(_)?_==="line"&&o.paint&&o.paint["line-gradient"]&&T==="geojson"&&!v.lineMetrics?t.push(new Ve(c,o,`layer "${o.id}" specifies a line-gradient, which requires the GeoJSON source to have \`lineMetrics\` enabled.`)):_==="line"&&o.paint&&o.paint["line-trim-offset"]&&T==="geojson"&&!v.lineMetrics?t.push(new Ve(c,o,`layer "${o.id}" specifies a line-trim-offset, which requires the GeoJSON source to have \`lineMetrics\` enabled.`)):_==="raster-particle"&&T!=="raster-array"&&t.push(new Ve(c,o.source,`layer "${o.id}" requires a 'raster-array' source.`)):t.push(new Ve(c,o.source,"raster-array source can only be used with layer type 'raster'.")):t.push(new Ve(c,o,`layer "${o.id}" must specify a "source-layer"`)):t.push(new Ve(c,o.source,`source "${o.source}" not found`))}else t.push(new Ve(`${c}.source`,o.source,'"source" must be a string'));else t.push(new Ve(c,o,'missing required property "source"'));return t=t.concat(In({key:c,value:o,valueSpec:m.layer,style:a.style,styleSpec:a.styleSpec,objectElementValidators:{"*":()=>[],type:()=>Pi({key:`${c}.type`,value:o.type,valueSpec:m.layer.type,style:a.style,styleSpec:a.styleSpec,object:o,objectKey:"type"}),filter:v=>Ai(Object.assign({layerType:_},v)),layout:v=>In({layer:o,key:v.key,value:v.value,valueSpec:{},style:v.style,styleSpec:v.styleSpec,objectElementValidators:{"*":T=>yn(Object.assign({layerType:_},T))}}),paint:v=>In({layer:o,key:v.key,value:v.value,valueSpec:{},style:v.style,styleSpec:v.styleSpec,objectElementValidators:{"*":T=>Bn(Object.assign({layerType:_,layer:o},T))}}),appearances(v){let T=$i({key:v.key,value:v.value,valueSpec:v.valueSpec,style:v.style,styleSpec:v.styleSpec,arrayElementValidator:A=>function(D){let{key:L,layer:O,layerType:k}=D,N=h.H(D.value),q=h.H(N.name),Z=h.H(N.condition),G=In({key:L,value:N,valueSpec:D.styleSpec.appearance,style:D.style,styleSpec:D.styleSpec,objectElementValidators:{condition:re=>function(te){let se=[];return se.push(...ti({key:te.key,value:te.object.condition,valueSpec:h.a6.appearance.condition,expressionContext:"appearance"})),se}(Object.assign({layer:O,layerType:k},re)),properties:re=>function(te){let se=[],{styleSpec:K,layer:J,layerType:oe}=te,ue=K[`paint_${oe}`],de=K[`layout_${oe}`],be=te.object[te.objectKey];for(let ve in be){let Fe=ve in ue?"paint":ve in de?"layout":void 0;if(!Fe){se.push(new Ve(te.key,ve,`unknown property "${ve}" for layer type "${oe}"`));continue}let pe=Object.assign({},te,{key:`${te.key}.${ve}`,object:be,objectKey:ve,layer:J,layerType:oe,value:be[ve],valueSpec:Fe==="paint"?ue[ve]:de[ve]});se.push(...Wi(pe,Fe))}return se}(Object.assign({layer:O,layerType:k},re))}});return q!=="hidden"&&Z===void 0&&G.push(new Ve(D.key,"name",'Appearance with name different than "hidden" must have a condition')),G}(Object.assign({layerType:_,layer:o},A))}),I=Array.isArray(v.value)?v.value:[],P=new Set;return I.forEach((A,D)=>{let L=h.H(A.name);if(L)if(P.has(L)){let O=h.H(o.id);T.push(new Ve(v.key,L,`Duplicated appearance name "${L}" for layer "${O}"`))}else P.add(L)}),T}}})),t}function zr({key:a,value:t}){return h.$(t)?[]:[new Ve(a,t,`string expected, ${h.J(t)}
8 found`)]}let go={promoteId:function a({key:t,value:o}){if(h.$(o))return zr({key:t,value:o});if(Array.isArray(o)){let d=[],m=h.S(o),_=h.U(m);return _.result==="error"?(_.value.forEach(y=>{d.push(new Ve(`${t}${y.key}`,null,`${y.message}`))}),d):(h.W(_.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"])||d.push(new Ve(`${t}`,null,"promoteId expression should be only feature dependent")),d)}if(!h.G(o))return[new Ve(t,o,`string, expression or object expected, "${h.J(o)}" found`)];let c=[];for(let d in o)c.push(...a({key:`${t}.${d}`,value:o[d]}));return c}};function di(a){let t=a.value,o=a.key,c=a.styleSpec,d=a.style;if(!h.G(t))return[new Ve(o,t,`object expected, ${h.J(t)} found`)];if(!("type"in t))return[new Ve(o,t,'"type" is required')];let m=h.H(t.type),_=[];switch(["vector","raster","raster-dem","raster-array"].includes(m)&&("url"in t||"tiles"in t||_.push(new Ut(o,t,'Either "url" or "tiles" is required.'))),m){case"vector":case"raster":case"raster-dem":case"raster-array":return _=_.concat(In({key:o,value:t,valueSpec:c[`source_${m.replace("-","_")}`],style:a.style,styleSpec:c,objectElementValidators:go})),_;case"geojson":if(_=In({key:o,value:t,valueSpec:c.source_geojson,style:d,styleSpec:c,objectElementValidators:go}),"cluster"in t&&"clusterProperties"in t){if(!h.G(t.clusterProperties))return[new Ve(`${o}.clusterProperties`,t,`object expected, ${h.J(t)} found`)];for(let y in t.clusterProperties){let v=t.clusterProperties[y];if(!Array.isArray(v))return[new Ve(`${o}.clusterProperties.${y}`,v,"array expected")];let[T,I]=v,P=typeof T=="string"?[T,["accumulated"],["get",y]]:T;_.push(...ti({key:`${o}.${y}.map`,value:I,expressionContext:"cluster-map"})),_.push(...ti({key:`${o}.${y}.reduce`,value:P,expressionContext:"cluster-reduce"}))}}return _;case"video":return In({key:o,value:t,valueSpec:c.source_video,style:d,styleSpec:c});case"image":return In({key:o,value:t,valueSpec:c.source_image,style:d,styleSpec:c});case"canvas":return[new Ve(o,null,"Please use runtime APIs to add canvas sources, rather than including them in stylesheets.","source.canvas")];default:return ii({key:`${o}.type`,value:t.type,valueSpec:{values:ha(c)}})}}function ha(a){return a.source.reduce((t,o)=>{let c=a[o];return c.type.type==="enum"&&(t=t.concat(Object.keys(c.type.values||{}))),t},[])}function da(a,t){let o=!a.includes("://");try{return new URL(a,o&&t?"http://example.com":void 0),!0}catch{return!1}}function pa(a){let t=a.value;return t?h.$(t)?da(t,!0)?[]:[new Ve(a.key,t,`invalid url "${t}"`)]:[new Ve(a.key,t,`string expected, "${h.J(t)}" found`)]:[]}function vs(a){let t=a.value,o=a.styleSpec,c=o.light,d=a.style;if(t===void 0)return[];if(!h.G(t))return[new Ve("light",t,`object expected, ${h.J(t)} found`)];let m=[];for(let _ in t){let y=_.match(h.a3),v=_.match(h.a2);m=m.concat(v&&c[v[1]]?Pi({key:_,value:t[_],valueSpec:{type:"string"},style:d,styleSpec:o}):y&&c[y[1]]&&c[y[1]].transition?Pi({key:_,value:t[_],valueSpec:o.transition,style:d,styleSpec:o}):c[_]?Pi({key:_,value:t[_],valueSpec:c[_],style:d,styleSpec:o}):[new Ve(_,t[_],`unknown property "${_}"`)])}return m}function tl(a){let t=a.value;if(!t)return[];let o=a.key;if(!h.G(t))return[new Ve(o,t,`object expected, ${h.J(t)} found`)];let c=[],d=a.styleSpec,m=d["light-3d"],_=a.style,y=a.style.lights;for(let I of["type","id"])if(!(I in t))return c=c.concat([new Ve(o,t,`missing property "${I}"`)]),c;if(!h.$(t.type))return c=c.concat([new Ve(`${o}.type`,t.type,"string expected")]),c;if(y)for(let I=0;I<a.arrayIndex;I++){let P=h.H(t.type),A=y[I];h.H(A.type)===P&&c.push(new Ve(o,t.id,`duplicate light type "${t.type}", previously defined at line ${A.id.__line__}`))}let v=`properties_light_${t.type}`;if(!(v in d))return c=c.concat([new Ve(`${o}.type`,t,`Invalid light type ${t.type}`)]),c;let T=d[v];for(let I in t)if(I==="properties"){let P=t[I];if(!h.G(P))return c=c.concat([new Ve("properties",P,`object expected, ${h.J(P)} found`)]),c;for(let A in P){let D=A.match(h.a3),L=A.match(h.a2);
8c=c.concat(L&&T[L[1]]?Pi({key:I,value:P[A],valueSpec:{type:"string"},style:_,styleSpec:d}):D&&T[D[1]]&&T[D[1]].transition?Pi({key:I,value:t[I],valueSpec:d.transition,style:_,styleSpec:d}):T[A]?Pi({key:A,value:P[A],valueSpec:T[A],style:_,styleSpec:d}):[new Ut(a.key,P[A],`unknown property "${A}"`)])}}else c=c.concat(m[I]?Pi({key:I,value:t[I],valueSpec:m[I],style:_,styleSpec:d}):[new Ut(I,t[I],`unknown property "${I}"`)]);return c}function pu(a){let t=a.value,o=a.key,c=a.style,d=a.styleSpec,m=d.terrain;if(t==null)return[];if(!h.G(t))return[new Ve("terrain",t,`object expected, ${h.J(t)} found`)];let _=[];for(let y in t){let v=y.match(h.a3),T=y.match(h.a2);_=_.concat(T&&m[T[1]]?Pi({key:y,value:t[y],valueSpec:{type:"string"},style:c,styleSpec:d}):v&&m[v[1]]&&m[v[1]].transition?Pi({key:y,value:t[y],valueSpec:d.transition,style:c,styleSpec:d}):m[y]?Pi({key:y,value:t[y],valueSpec:m[y],style:c,styleSpec:d}):[new Ut(y,t[y],`unknown property "${y}"`)])}if(t.source)if(h.$(t.source)){let y=c.sources&&c.sources[t.source],v=y&&h.H(y.type);y?v!=="raster-dem"&&_.push(new Ve(`${o}.source`,t.source,`terrain cannot be used with a source of type ${v}, it only be used with a "raster-dem" source type`)):_.push(new Ve(`${o}.source`,t.source,`source "${t.source}" not found`))}else _.push(new Ve(`${o}.source`,t.source,"source must be a string"));else _.push(new Ve(o,t,'terrain is missing required property "source"'));return _}function cc(a){let t=a.value,o=a.style,c=a.styleSpec,d=c.fog;if(t===void 0)return[];if(!h.G(t))return[new Ve("fog",t,`object expected, ${h.J(t)} found`)];let m=[];for(let _ in t){let y=_.match(h.a3),v=_.match(h.a2);m=m.concat(v&&d[v[1]]?Pi({key:_,value:t[_],valueSpec:{type:"string"},style:o,styleSpec:c}):y&&d[y[1]]&&d[y[1]].transition?Pi({key:_,value:t[_],valueSpec:c.transition,style:o,styleSpec:c}):d[_]?Pi({key:_,value:t[_],valueSpec:d[_],style:o,styleSpec:c}):[new Ut(_,t[_],`unknown property "${_}"`)])}return m}let fu={"*":()=>[],array:$i,boolean:function(a){let t=a.value,o=a.key;return h._(t)?[]:[new Ve(o,t,`boolean expected, ${h.J(t)} found`)]},number:Hi,color:function({key:a,value:t}){return h.$(t)?h.a0.parseCSSColor(t)===null?[new Ve(a,t,`color expected, "${t}" found`)]:[]:[new Ve(a,t,`color expected, ${h.J(t)} found`)]},enum:ii,filter:Ai,function:Ot,layer:zn,object:In,source:di,model:pa,light:vs,"light-3d":tl,terrain:pu,fog:cc,string:zr,formatted:function(a){return zr(a).length===0?[]:ti(a)},resolvedImage:function(a){return zr(a).length===0?[]:ti(a)},projection:function(a){let t=a.value,o=a.styleSpec,c=o.projection,d=a.style;if(h.G(t)){let m=[];for(let _ in t)m=m.concat(Pi({key:_,value:t[_],valueSpec:c[_],style:d,styleSpec:o}));return m}return h.$(t)?[]:[new Ve("projection",t,`object or string expected, ${h.J(t)} found`)]},import:function(a){let t=a.key,{value:o,styleSpec:c}=a;if(!h.G(o))return[new Ve(t,o,"import must be an object")];let{data:d,...m}=o;Object.defineProperty(m,"__line__",{value:o.__line__,enumerable:!1});let _=In(Object.assign({},a,{value:m,valueSpec:c.import}));return h.H(m.id)===""&&_.push(new Ve(`${a.key}.id`,m,"import id can't be an empty string")),d&&(_=_.concat(Bh(d,c,{key:`${a.key}.data`}))),_},iconset:function(a){let t=a.value,o=a.key,c=a.styleSpec,d=a.style;if(!h.G(t))return[new Ve(o,t,"object expected")];if(!t.type)return[new Ve(o,t,'"type" is required')];let m=h.H(t.type),_=[];if(_=_.concat(In({key:o,value:t,valueSpec:c[`iconset_${m}`],style:d,styleSpec:c})),function(y,v){return!(y!=="source"||!v.source)}(m,t)){let y=d.sources&&d.sources[t.source],v=y&&h.H(y.type);y?v!=="raster-array"&&_.push(new Ve(o,t.source,`iconset cannot be used with a source of type ${String(v)}, it only be used with a "raster-array" source type`)):_.push(new Ve(o,t.source,`source "${t.source}" not found`))}return _}};function Pi(a,t=!1){let o=a.value,c=a.valueSpec,d=a.styleSpec;if(c.expression){if(h.a4(h.H(o)))return Ot(a);if(h.Q(h.S(o)))return ti(a)}if(c.type&&fu[c.type]){let m=fu[c.type](a);return t===!0&&m.length>0&&Array.isArray(a.value)?ti(a):m}return In(Object.assign({},a,{valueSpec:c.type?d[c.type]:c}))}function In(a){let t=a.key,o=a.value,c=a.valueSpec||{},d=a.objectElementValidators||{},m=a.style,_=a.styleSpec;if(!h.G(o))return[new Ve(t,o,`object expected, ${h.J(o)} found`)];let y=[];for(let v in o){let T=v.split(".")[0],I;d[T]?I=d[T]:c[T]?I=Pi:d["*"]?I=d["*"]:c["*"]&&(I=Pi),I?y=y.concat(I({key:(t&&`${t}.`)+v,value:o[v],valueSpec:c[T]||c["*"],style:m,styleSpec:_,object:o,objectKey:v},o)):y.push(new Ut(t,o[v],`unknown property "${v}"`))}for(let v in c){if(d[v])continue;let T=c[v];T.required&&T.default===void 0&&o[v]===void 0&&y.push(new Ve(t,o,`missing required property "${v}"`))}return y}function uc({key:a,value:t}){let o=zr({key:a,value:t});if(o.length)return o;let c=t;return c.includes("{fontstack}")||o.push(new Ve(a,t,'"glyphs" url must include a "{fontstack}" token')),c.includes("{range}")||o.push(new Ve(a,t,'"glyphs" url must include a "{range}" token')),o}function Bh(a,t=h.a6,o={}){return In({key:o.key||"",value:a,valueSpec:Object.assign({},t.$root,{"*":{type:"*"}}),styleSpec:t,style:a,objectElementValidators:{glyphs:uc}})}function xn(a,t=h.a6){return $n(Bh(a,t))}let Jp=a=>$n(di(a)),kh=a=>$n(vs(a)),Kp=a=>$n(tl(a)),Qp=a=>$n(pu(a)),ef=a=>$n(cc(a)),tf=a=>$n(function(t){let o=t.value,c=t.style,d=t.styleSpec,m=d.snow;if(o===void 0)return[];if(!h.G(o))return[new Ve("snow",o,`object expected, ${h.J(o)} found`)];let _=[];for(let y in o){let v=y.match(h.a3);_=_.concat(v&&m[v[1]]&&m[v[1]].transition?Pi({key:y,value:o[y],valueSpec:d.transition,style:c,styleSpec:d}
8):m[y]?Pi({key:y,value:o[y],valueSpec:m[y],style:c,styleSpec:d}):[new Ut(y,o[y],`unknown property "${y}"`)])}return _}(a)),Wo=a=>$n(function(t){let o=t.value,c=t.style,d=t.styleSpec,m=d.rain;if(o===void 0)return[];if(!h.G(o))return[new Ve("rain",o,`object expected, ${h.J(o)} found`)];let _=[];for(let y in o){let v=y.match(h.a3);_=_.concat(v&&m[v[1]]&&m[v[1]].transition?Pi({key:y,value:o[y],valueSpec:d.transition,style:c,styleSpec:d}):m[y]?Pi({key:y,value:o[y],valueSpec:m[y],style:c,styleSpec:d}):[new Ut(y,o[y],`unknown property "${y}"`)])}return _}(a)),nf=a=>$n(zn(a)),fa=a=>$n(Ai(a)),Nh=a=>$n(Bn(a)),Uh=a=>$n(yn(a)),hc=a=>$n(pa(a));function $n(a){return a.slice().sort((t,o)=>t.line&&o.line?t.line-o.line:0)}function ma(a,t){let o=!1;if(t&&t.length)for(let c of t)c instanceof Ut?h.w(c.message):(a.fire(new h.y(new Error(c.message))),o=!0);return o}let dc=h.a6.light,Vh;class jh extends h.E{constructor(t,o="flat"){super(),this._transitionable=new h.a7(Vh||(Vh=new h.a8({anchor:new h.a9(dc.anchor),position:new h.aa(dc.position),color:new h.a9(dc.color),intensity:new h.a9(dc.intensity)}))),this.setLight(t,o),this._transitioning=this._transitionable.untransitioned()}getLight(){return this._transitionable.serialize()}setLight(t,o,c={}){this._validate(kh,t,c)||(this._transitionable.setTransitionOrValue(t),this.id=o)}updateTransitions(t){this._transitioning=this._transitionable.transitioned(t,this._transitioning)}hasTransition(){return this._transitioning.hasTransition()}recalculate(t){this.properties=this._transitioning.possiblyEvaluate(t)}_validate(t,o,c){return(!c||c.validate!==!1)&&ma(this,t.call(xn,Object.assign({value:o,style:{glyphs:!0,sprite:!0},styleSpec:h.a6})))}}let bs=h.a6.terrain,Gh=class extends h.E{constructor(a,t,o,c,d){super(),this.scope=o,this._transitionable=new h.a7(new h.a8({source:new h.a9(bs.source),exaggeration:new h.a9(bs.exaggeration)}),o,c),this._transitionable.setTransitionOrValue(a,c),this._transitioning=this._transitionable.untransitioned(),this.drapeRenderMode=t,this.worldview=d}get(){return this._transitionable.serialize()}set(a,t){this._transitionable.setTransitionOrValue(a,t)}updateTransitions(a){this._transitioning=this._transitionable.transitioned(a,this._transitioning)}hasTransition(){return this._transitioning.hasTransition()}recalculate(a){this.properties=this._transitioning.possiblyEvaluate(a)}getExaggeration(a){return this._transitioning.possiblyEvaluate(new h.ab(a,{worldview:this.worldview})).get("exaggeration")}getAttenuationRange(){if(!this.isZoomDependent())return null;let a=this._transitionable._values.exaggeration;if(!a)return null;let t=a.value.expression;if(!t)return null;let o=-1,c=-1,d=1;for(let m of t.zoomStops)d=t.evaluate(new h.ab(m,{worldview:this.worldview})),d>.01?(o=m,c=-1):c=m;return d<.01&&o>0&&c>o?[o,c]:null}isZoomDependent(){let a=this._transitionable._values.exaggeration;return a!=null&&a.value!=null&&a.value.expression!=null&&a.value.expression instanceof h.ac}},ws=.05;function il(a,t,o){let c=h.ag(45,65,o),[d,m]=a.range,_=1-Math.min(1,Math.exp((t-d)/(m-d)*-6));return _*=_*_,_=Math.min(1,1.00747*_),_*c*a.alpha}function rf(a,t,o,c,d){let m=h.ae([],[t,o,c],d.mercatorFogMatrix);return il(a,h.af(m),d.pitch)}function of(a,t,o,c,d,m,_){let y=[[o,c,0],[d,c,0],[d,m,0],[o,m,0]],v=Number.MAX_VALUE,T=-Number.MAX_VALUE;for(let I of y){let P=h.ae([],I,t),A=h.af(P);v=Math.min(v,A),T=Math.max(T,A)}return[il(a,v,_.pitch),il(a,T,_.pitch)]}let Lr=h.a6.fog;class sf extends h.E{constructor(t,o,c,d){super();let m=new h.a8({range:new h.a9(Lr.range),color:new h.a9(Lr.color),"color-use-theme":new h.a9({type:"string","property-type":"data-constant",default:"default"}),"high-color":new h.a9(Lr["high-color"]),"high-color-use-theme":new h.a9({type:"string","property-type":"data-constant",default:"default"}),"space-color":new h.a9(Lr["space-color"]),"space-color-use-theme":new h.a9({type:"string","property-type":"data-constant",default:"default"}),"horizon-blend":new h.a9(Lr["horizon-blend"]),"star-intensity":new h.a9(Lr["star-intensity"]),"vertical-range":new h.a9(Lr["vertical-range"])});this._transitionable=new h.a7(m,c,d),this.set(t,d),this._transitioning=this._transitionable.untransitioned(),this._transform=o,this.properties=new h.ah(m),this.scope=c}get state(){let t=this._transform,o=t.projection.name==="globe",c=h.ai(t.zoom),d=this.properties.get("range"),m=[2,4.5],_=.5/Math.tan(.5*t._fov),y=[d[0]+_,d[1]+_];return{range:o?[h.aj(m[0],y[0],c),h.aj(m[1],y[1],c)]:y,horizonBlend:this.properties.get("horizon-blend"),alpha:this.properties.get("color").a}}get(){return this._transitionable.serialize()}set(t,o,c={}
8){if(this._validate(ef,t,c))return;let d=Object.assign({},t);for(let m of Object.keys(Lr))d[m]===void 0&&(d[m]=Lr[m].default);this._options=d,this._transitionable.setTransitionOrValue(this._options,o)}getOpacity(t){if(!this._transform.projection.supportsFog)return 0;let o=this.properties&&this.properties.get("color")||1;return(this._transform.projection.name==="globe"?1:h.ag(45,65,t))*o.a}getOpacityAtLatLng(t,o){return this._transform.projection.supportsFog?function(c,d,m){let _=h.ad.fromLngLat(d),y=m.elevation?m.elevation.getAtPointOrZero(_):0;return rf(c,_.x,_.y,y,m)}(this.state,t,o):0}getOpacityForTile(t){if(!this._transform.projection.supportsFog)return[1,1];let o=this._transform.calculateFogTileMatrix(t.toUnwrapped());return of(this.state,o,0,0,h.ak,h.ak,this._transform)}getOpacityForBounds(t,o,c,d,m){return this._transform.projection.supportsFog?of(this.state,t,o,c,d,m,this._transform):[1,1]}getRangeForProjection(){return this._transform.projection.supportsFog?this.state.range:[0,1]}isVisibleOnFrustum(t){if(!this._transform.projection.supportsFog)return!1;let o=[4,5,6,7];for(let c of o){let d=t.points[c],m;if(d[2]>=0)m=d;else{let _=t.points[c-4];m=h.al(_,d,_[2]/(_[2]-d[2]))}if(rf(this.state,m[0],m[1],0,this._transform)>=ws)return!0}return!1}updateConfig(t){this._transitionable.setTransitionOrValue(this._options,t)}updateTransitions(t){this._transitioning=this._transitionable.transitioned(t,this._transitioning)}hasTransition(){return this._transitioning.hasTransition()}recalculate(t){this.properties=this._transitioning.possiblyEvaluate(t)}_validate(t,o,c){return(!c||c.validate!==!1)&&ma(this,t.call(xn,Object.assign({value:o,style:{glyphs:!0,sprite:!0},styleSpec:h.a6})))}}let nl,af,mu=class extends h.E{constructor(a,t,o,c){super();let d=nl||(nl=new h.a8({density:new h.a9(h.a6.snow.density),intensity:new h.a9(h.a6.snow.intensity),color:new h.a9(h.a6.snow.color),opacity:new h.a9(h.a6.snow.opacity),vignette:new h.a9(h.a6.snow.vignette),"vignette-color":new h.a9(h.a6.snow["vignette-color"]),"center-thinning":new h.a9(h.a6.snow["center-thinning"]),direction:new h.a9(h.a6.snow.direction),"flake-size":new h.a9(h.a6.snow["flake-size"])}));this._transitionable=new h.a7(d,o,c),this.set(a,c),this._transitioning=this._transitionable.untransitioned(),this.properties=new h.ah(d),this.scope=o}get state(){let a=this.properties.get("opacity"),t=this.properties.get("color"),o=this.properties.get("direction"),c=h.am(o[0]),d=-Math.max(h.am(o[1]),.01),m=[Math.cos(c)*Math.cos(d),Math.sin(c)*Math.cos(d),Math.sin(d)],_=this.properties.get("vignette"),y=this.properties.get("vignette-color");return y.a=_,{density:this.properties.get("density"),intensity:this.properties.get("intensity"),color:new h.C(t.r,t.g,t.b,t.a*a),direction:m,centerThinning:this.properties.get("center-thinning"),flakeSize:this.properties.get("flake-size"),vignetteColor:y}}get(){return this._transitionable.serialize()}set(a,t,o={}){if(this._validate(tf,a,o))return;let c=Object.assign({},a),d=h.a6.snow;for(let m of Object.keys(d))c[m]===void 0&&(c[m]=d[m].default);this._options=c,this._transitionable.setTransitionOrValue(this._options,t)}updateConfig(a){this._transitionable.setTransitionOrValue(this._options,a)}updateTransitions(a){this._transitioning=this._transitionable.transitioned(a,this._transitioning)}hasTransition(){return this._transitioning.hasTransition()}recalculate(a){this.properties=this._transitioning.possiblyEvaluate(a)}_validate(a,t,o){return(!o||o.validate!==!1)&&ma(this,a.call(xn,Object.assign({value:t,style:{glyphs:!0,sprite:!0},styleSpec:h.a6})))}},pc=class extends h.E{constructor(a,t,o,c){super();let d=af||(af=new h.a8({density:new h.a9(h.a6.rain.density),intensity:new h.a9(h.a6.rain.intensity),color:new h.a9(h.a6.rain.color),opacity:new h.a9(h.a6.rain.opacity),vignette:new h.a9(h.a6.rain.vignette),"vignette-color":new h.a9(h.a6.rain["vignette-color"]),"center-thinning":new h.a9(h.a6.rain["center-thinning"]),direction:new h.a9(h.a6.rain.direction),"droplet-size":new h.a9(h.a6.rain["droplet-size"]),"distortion-strength":new h.a9(h.a6.rain["distortion-strength"])}));this._transitionable=new h.a7(d,o,c),this.set(a,c),this._transitioning=this._transitionable.untransitioned(),this.properties=new h.ah(d),this.scope=o}get state(){let a=this.properties.get("opacity"),t=this.properties.get("color"),o=this.properties.get("direction"),c=h.am(o[0]),d=-Math.max(h.am(o[1]),.01),m=[Math.cos(c)*Math.cos(d),Math.sin(c)*Math.cos(d),Math.sin(d)],_=this.properties.get("vignette-color");return _.a=this.properties.get("vignette"),{density:this.properties.get("density"),intensity:this.properties.get("intensity"),color:new h.C(t.r,t.g,t.b,t.a*a),direction:m,centerThinning:this.properties.get("center-thinning"),droplet
8Size:this.properties.get("droplet-size"),distortionStrength:this.properties.get("distortion-strength"),vignetteColor:_}}get(){return this._transitionable.serialize()}set(a,t,o={}){if(this._validate(Wo,a,o))return;let c=Object.assign({},a),d=h.a6.rain;for(let m of Object.keys(d))c[m]===void 0&&(c[m]=d[m].default);this._options=c,this._transitionable.setTransitionOrValue(this._options,t)}updateConfig(a){this._transitionable.setTransitionOrValue(this._options,a)}updateTransitions(a){this._transitioning=this._transitionable.transitioned(a,this._transitioning)}hasTransition(){return this._transitioning.hasTransition()}recalculate(a){this.properties=this._transitioning.possiblyEvaluate(a)}_validate(a,t,o){return(!o||o.validate!==!1)&&ma(this,a.call(xn,Object.assign({value:t,style:{glyphs:!0,sprite:!0},styleSpec:h.a6})))}},Kr={workerUrl:"",workerClass:null,workerParams:void 0};function lf(a){return Kr.workerClass!=null?new Kr.workerClass:new self.Worker(Kr.workerUrl,Object.assign({name:a},Kr.workerParams))}let _u="mapboxgl_preloaded_worker_pool";class Ts{constructor(t){this.active={},this.name=t}acquire(t,o=Ts.workerCount){if(!this.workers)for(this.workers=[];this.workers.length<o;){let c=lf(`${this.name||""}WorkerPool: ${t}-${this.workers.length}`);this.workers.push(c)}return this.active[t]=!0,this.workers.slice()}release(t){delete this.active[t],this.workers&&this.numActive()===0&&(this.workers.forEach(o=>{o.terminate()}),this.workers=null)}isPreloaded(){return!!this.active[_u]}numActive(){return Object.keys(this.active).length}}Ts.workerCount=2;class Ss{constructor(t,o,c="Worker",d=Ts.workerCount){this.workerPool=t,this.actors=[],this.currentActor=0,this.id=h.an();let m=this.workerPool.acquire(this.id,d);for(let _=0;_<m.length;_++){let y=new Ss.Actor(m[_],o,this.id);y.name=`${c} ${_}`,this.actors.push(y)}this.ready=!1,this.broadcast("checkIfReady",null,()=>{this.ready=!0})}broadcast(t,o,c){h.ao(this.actors,(d,m)=>{d.send(t,o,m)},c=c||function(){})}getActor(){return this.currentActor=(this.currentActor+1)%this.actors.length,this.actors[this.currentActor]}remove(){this.actors.forEach(t=>{t.remove()}),this.actors=[],this.workerPool.release(this.id)}}Ss.Actor=h.ap;class $h extends h.E{constructor(t,o,c,d){super(),this.scope=c,this._options=t,this.properties=new h.ah(o),this._transitionable=new h.a7(o,c,d),this._transitionable.setTransitionOrValue(t.properties),this._transitioning=this._transitionable.untransitioned()}updateConfig(t){this._transitionable.setTransitionOrValue(this._options.properties,t)}updateTransitions(t){this._transitioning=this._transitionable.transitioned(t,this._transitioning)}hasTransition(){return this._transitioning.hasTransition()}recalculate(t){this.properties=this._transitioning.possiblyEvaluate(t)}get(){return this._options.properties=this._transitionable.serialize(),this._options}set(t,o){this._options=t,this._transitionable.setTransitionOrValue(t.properties,o)}shadowsEnabled(){return!!this.properties&&this.properties.get("cast-shadows")===!0}}let Hh,O_=()=>Hh||(Hh=new h.a8({color:new h.a9(h.a6.properties_light_ambient.color),"color-use-theme":new h.a9({type:"string",default:"default","property-type":"data-constant"}),intensity:new h.a9(h.a6.properties_light_ambient.intensity)})),fc,Xo=()=>fc||(fc=new h.a8({direction:new h.aq(h.a6.properties_light_directional.direction),color:new h.a9(h.a6.properties_light_directional.color),"color-use-theme":new h.a9({type:"string",default:"default","property-type":"data-constant"}),intensity:new h.a9(h.a6.properties_light_directional.intensity),"cast-shadows":new h.a9(h.a6.properties_light_directional["cast-shadows"]),"shadow-quality":new h.a9(h.a6.properties_light_directional["shadow-quality"]),"shadow-intensity":new h.a9(h.a6.properties_light_directional["shadow-intensity"]),"shadow-draw-before-layer":new h.a9(h.a6.properties_light_directional["shadow-draw-before-layer"])}));class rl{constructor(t,o,c){this.screenBounds=t,this.cameraPoint=c.getCameraPoint(),this._screenRaycastCache={},this._cameraRaycastCache={},this.isAboveHorizon=o,this.screenGeometry=this.bufferedScreenGeometry(0),this.screenGeometryMercator=this._bufferedScreenMercator(0,c)}static createFromScreenPoints(t,o){let c,d;if(t instanceof h.P||typeof t[0]=="number"){let m=h.P.convert(t);c=[m],d=o.isPointAboveHorizon(m)}else{let m=h.P.convert(t[0]),_=h.P.convert(t[1]),y=m.add(_)._div(2);c=[m,_],d=h.ar(m,_).every(v=>o.isPointAboveHorizon(v))&&o.isPointAboveHorizon(y)}return new rl(c,d,o)}isPointQuery(){return this.screenBounds.length===1}bufferedScreenGeometry(t){return h.ar(this.screenBounds[0],this.screenBounds.length===1?this.screenBounds[0]:this.screenBounds[1],t)}bufferedCameraGeometry(t){let o=this.screenBounds[0],c=this.screenBounds.length===1?this.screenBounds[0].add(new h.P(1,1)):this.screenBounds[1],d=h.ar(o,c,0,!1);return this.cameraPoint.y>c.y&&(this.cameraPoint.x>o.x&&this.cameraPoint.x<c.x?d.splice(3,0,this.cameraPoint):this.cameraPoint.x>=c.x?d[2]=this.cameraPoint:this.cameraPoint.x<=o.x&&(d[3]=this.cameraPoint)),h.as(d,t)}bufferedCameraGeometryGlobe(t){let o=this.screenBounds[0],c=this.screenBounds.length===1?this.screenBounds[0].add(new h.P(1,1)):this.screenBounds[1],d=h.ar(o,c,t),m=this.cameraPoint.clone(),_=+(m.x>o.x)+ +(m.x>c.x);switch(3*(+(m.y>o.y)+ +(m.y>c.y))+_){case 0:d[0]=m,d[4]=m.clone();break;case 1:d.splice(1,0,m);break;case 2:d[1]=m;break;case 3:d.splice(4,0,m);break;case 5:d.splice(2,0,m);break;case 6:d[3]=m;break;case 7:d.splice(3,0,m);break;case 8:d[2]=m}return d}containsTile(t,o,c,d=0){let m=Math.max(t.queryPadding,t.evaluateQueryRenderedFeaturePadding())/o._pixelsPerMercatorPixel+1,_=c?this._bufferedCameraMercator(m,o):this._bufferedScreenMercator(m,o),y=t.t
8ileID.wrap+(_.unwrapped?d:0),v=_.polygon.map(k=>h.at(t.tileTransform,k,y));if(!h.au(v,0,0,h.ak,h.ak))return;y=t.tileID.wrap+(this.screenGeometryMercator.unwrapped?d:0);let T=this.screenGeometryMercator.polygon.map(k=>h.av(t.tileTransform,k,y)),I=T.map(k=>new h.P(k[0],k[1])),P=o.getFreeCameraOptions().position||new h.ad(0,0,0),A=h.av(t.tileTransform,P,y),D=T.map(k=>{let N=h.aw(k,k,A);return h.ax(N,N),new h.ay(A,N)}),L=h.az(t,1,o.zoom)*o._pixelsPerMercatorPixel;return{queryGeometry:this,tilespaceGeometry:I,tilespaceRays:D,bufferedTilespaceGeometry:v,bufferedTilespaceBounds:(O=h.aA(v),O.min.x=h.aB(O.min.x,0,h.ak),O.min.y=h.aB(O.min.y,0,h.ak),O.max.x=h.aB(O.max.x,0,h.ak),O.max.y=h.aB(O.max.y,0,h.ak),O),tile:t,tileID:t.tileID,pixelToTileUnitsFactor:L};var O}_bufferedScreenMercator(t,o){let c=ol(t);if(this._screenRaycastCache[c])return this._screenRaycastCache[c];{let d;return d=o.projection.name==="globe"?this._projectAndResample(this.bufferedScreenGeometry(t),o):{polygon:this.bufferedScreenGeometry(t).map(m=>o.pointCoordinate3D(m)),unwrapped:!0},this._screenRaycastCache[c]=d,d}}_bufferedCameraMercator(t,o){let c=ol(t);if(this._cameraRaycastCache[c])return this._cameraRaycastCache[c];{let d;return d=o.projection.name==="globe"?this._projectAndResample(this.bufferedCameraGeometryGlobe(t),o):{polygon:this.bufferedCameraGeometry(t).map(m=>o.pointCoordinate3D(m)),unwrapped:!0},this._cameraRaycastCache[c]=d,d}}_projectAndResample(t,o){let c=function(m,_){let y=h.aC([],_.pixelMatrix,_.globeMatrix),v=[0,-h.aE,0,1],T=[0,h.aE,0,1],I=[0,0,0,1];h.aD(v,v,y),h.aD(T,T,y),h.aD(I,I,y);let P=new h.P(v[0]/v[3],v[1]/v[3]),A=new h.P(T[0]/T[3],T[1]/T[3]),D=h.aF(m,P)&&v[3]<I[3],L=h.aF(m,A)&&T[3]<I[3];if(!D&&!L)return null;let O=function(K,J,oe){for(let ue=1;ue<K.length;ue++){let de=_a(J.pointCoordinate3D(K[ue-1]).x),be=_a(J.pointCoordinate3D(K[ue]).x);if(oe<0){if(de<be)return{idx:ue,t:-de/(be-1-de)}}else if(be<de)return{idx:ue,t:(1-de)/(be+1-de)}}return null}(m,_,D?-1:1);if(!O)return null;let{idx:k,t:N}=O,q=k>1?gu(m.slice(0,k),_):[],Z=k<m.length?gu(m.slice(k),_):[];q=q.map(K=>new h.P(_a(K.x),K.y)),Z=Z.map(K=>new h.P(_a(K.x),K.y));let G=[...q];G.length===0&&G.push(Z.at(-1));let re=G.at(-1),te=h.aj(re.y,(Z.length===0?q[0]:Z[0]).y,N),se;return se=D?[new h.P(0,te),new h.P(0,0),new h.P(1,0),new h.P(1,te)]:[new h.P(1,te),new h.P(1,1),new h.P(0,1),new h.P(0,te)],G.push(...se),Z.length===0?G.push(q[0]):G.push(...Z),{polygon:G.map(K=>new h.ad(K.x,K.y)),unwrapped:!1}}(t,o);if(c)return c;let d=function(m,_){let y=!1,v=-1/0,T=0;for(let P=0;P<m.length-1;P++)m[P].x>v&&(v=m[P].x,T=P);for(let P=0;P<m.length-1;P++){let A=(T+P)%(m.length-1),D=m[A],L=m[A+1];Math.abs(D.x-L.x)>.5&&(D.x<L.x?(D.x+=1,A===0&&(m.at(-1).x+=1)):(L.x+=1,A+1===m.length-1&&(m[0].x+=1)),y=!0)}let I=h.aG(_.center.lng);return y&&I<Math.abs(I-1)&&m.forEach(P=>{P.x-=1}),{polygon:m,unwrapped:y}}(gu(t,o).map(m=>new h.P(_a(m.x),m.y)),o);return{polygon:d.polygon.map(m=>new h.ad(m.x,m.y)),unwrapped:d.unwrapped}}}function gu(a,t){return h.aH(a,o=>{let c=t.pointCoordinate3D(o);o.x=c.x,o.y=c.y},1/256)}function _a(a){return a<0?1+a%1:a%1}function ol(a){return 100*a|0}function yr(a,t){let o=Math.pow(2,t.z),c=Math.floor(h.aG(a.getWest())*o),d=Math.floor(h.aJ(a.getNorth())*o),m=Math.ceil(h.aG(a.getEast())*o),_=Math.ceil(h.aJ(a.getSouth())*o);return t.x>=c&&t.x<m&&t.y>=d&&t.y<_}class ga{constructor(t,o,c){this.bounds=t?h.aI.convert(this.validateBounds(t)):null,this.minzoom=o||0,this.maxzoom=c||24}validateBounds(t){return Array.isArray(t)&&t.length===4?[Math.max(-180,t[0]),Math.max(-90,t[1]),Math.min(180,t[2]),Math.min(90,t[3])]:[-180,-90,180,90]}addExtraBounds(t){if(t){this.extraBounds||(this.extraBounds=[]);for(let o of t)this.extraBounds.push(h.aI.convert(this.validateBounds(o)))}}contains(t){if(t.z>this.maxzoom||t.z<this.minzoom||this.bounds&&!yr(this.bounds,t))return!1;if(!this.extraBounds)return!0;for(let o of this.extraBounds)if(yr(o,t))return!0;return!1}static fromTileJSON(t){if(!t.bounds&&!t.extra_bounds)return null;let o=new ga(t.bounds,t.minzoom,t.maxzoom);return o.addExtraBounds(t.extra_bounds),o}}class yu extends h.E{constructor(t,o,c,d){if(super(),this.id=t,this.dispatcher=c,this.type="vector",this.provider=o.provider,this.minzoom=0,this.maxzoom=22,this.scheme="xyz",this.tileSize=512,this.reparseOverscaled=!0,this.isTileClipped=!0,this._loaded=!1,Object.assign(this,h.aK(o,["url","scheme","tileSize","promoteId"])),this._options=Object.assign({type:"vector"},o),this._collectResourceTiming=!!o.collectResourceTiming,this.tileSize!==512)throw new Error("vector tile sources must have a tileSize of 512");this.setEventedParent(d),this._tileWorkers={},this._deduped=new h.aL}load(t){this._loaded=!1,this.fire(new h.z("dataloading",{dataType:"source"}));let o=Array.isArray(this.map._language)?this.map._language.join():this.map._language,c=this.map.getWorldview(),d=(_,y)=>{this._tileJSONRequest=null,this._loaded=!0,_?(o&&console.warn(`Ensure that your requested language string is a valid BCP-47 code or list of codes. Found: ${o}`),c&&console.warn(`Requested worldview strings must be a valid ISO alpha-2 code. Found: ${c}`),this.fire(new h.y(_))):y&&(this._setTileJSON(y),hi(y.tiles,this.map._requestManager._customAccessToken),this.fire(new h.z("data",{dataType:"source",sourceDataType:"metadata"})),this.fire(new h.z("data",{dataType:"source",sourceDataType:"content"}))),t&&t(_)};this.provider=this._options.provider;let m=h.aM(this._options);return m instanceof Error?(this._loaded=!0,this.fire(new h.y(m)),void(t&&t())):this.provider&&!m?(this._loaded=!0,this.fire(new h.y(new Error(`TileProvider "${this.provider}" is not registered`))),void(t&&t())):void(this._tileJSONRequest=m?this.loadTileJSONWithProvider(m,d):h.aN(this._options,this.map._requestManager,o,c,d))}loadTileJSONWithProvider(t,o){this.provider=t.name;let{request:c,options:d}=h.aO(this._options,this.map._requestManager),m=new AbortController;return this.dispatcher.broadcast("loadTileProvider",{name:t.name,url:t.url,source:this.id,scope:this.scope,type:this.t
8ype,options:d,request:c},(_,y)=>{if(m.signal.aborted)return;if(_)return void o(_);let v=y?y.find(I=>I!=null):null,T=h.aP(this._options,v,this.map._requestManager);T instanceof Error?o(T):o(null,T)}),{cancel:()=>m.abort()}}_setTileJSON(t){if(Object.assign(this,t),this.hasWorldviews=!!t.worldview_options,t.worldview_default&&(this.worldviewDefault=t.worldview_default),t.vector_layers){this.vectorLayers=t.vector_layers,this.vectorLayerIds=[],this.localizableLayerIds=new Set;for(let o of t.vector_layers)this.vectorLayerIds.push(o.id),t.worldview&&t.worldview[o.source]&&this.localizableLayerIds.add(o.id)}this.tileBounds=ga.fromTileJSON(t)}loaded(){return this._loaded}hasTile(t){return!this.tileBounds||this.tileBounds.contains(t.canonical)}onAdd(t){this.map=t,this.load()}reload(){this.cancelTileJSONRequest();let t=h.t(this.id,this.scope);this.load(()=>this.map.style.clearSource(t))}setTiles(t){return this._options.tiles=t,this.reload(),this}setUrl(t){return this.url=t,this._options.url=t,this.reload(),this}onRemove(t){this.cancelTileJSONRequest()}serialize(){return Object.assign({},this._options)}loadTile(t,o){let c=t.tileID.canonical.url(this.tiles,this.scheme),d=this.map._requestManager.normalizeTileURL(c),m=this.map._requestManager.transformRequest(d,h.R.Tile),_=this.map.style?this.map.style.getLut(this.scope):null,y=_?{image:_.image.clone()}:null,v={request:m,data:void 0,uid:t.uid,tileID:t.tileID,tileZoom:t.tileZoom,zoom:t.tileID.overscaledZ,maxZoom:this.maxzoom,lut:y,tileSize:this.tileSize*t.tileID.overscaleFactor(),type:this.t
8ype,source:this.id,scope:this.scope,pixelRatio:h.o.devicePixelRatio,showCollisionBoxes:this.map.showCollisionBoxes,showElevationIdDebug:!!this.map.painter&&this.map.painter._debugParams.showElevationIdDebug,promoteId:this.promoteId,renderSourceType:t.renderSourceType,brightness:this.map.style&&this.map.style.getBrightness()||0,extraShadowCaster:t.isExtraShadowCaster,tessellationStep:this.map._tessellationStep,scaleFactor:this.map.getScaleFactor(),worldview:this.map.getWorldview()||this.worldviewDefault,indoor:this.map.getIndoorTileOptions(this.id,this.scope)};if(this.hasWorldviews&&h.e(c)&&(v.localizableLayerIds=this.localizableLayerIds),v.request.collectResourceTiming=this._collectResourceTiming,t.actor&&t.state!=="expired")t.state==="loading"?t.reloadCallback=o:t.request=t.actor.send("reloadTile",v,T.bind(this));else if(t.actor=this._tileWorkers[d]=this._tileWorkers[d]||this.dispatcher.getActor(),this.dispatcher.ready||this.provider)t.request=t.actor.send("loadTile",v,T.bind(this),void 0,!0);else{let I=h.aQ.call({deduped:this._deduped},v,(P,A)=>{if(P||!A)T.call(this,P);else{let D=h.aR(A.responseHeaders);v.data={rawData:A.rawData.slice(0),expires:D.expires,cacheControl:D.cacheControl},t.actor&&t.actor.send("loadTile",v,T.bind(this),void 0,!0)}},!0);t.request={cancel:I}}function T(I,P){return delete t.request,t.aborted?o(null):I?o(I):(P&&P.resourceTiming&&(t.resourceTiming=P.resourceTiming),this.map._refreshExpiredTiles&&P&&t.setExpiryData(P),t.loadVectorData(P,this.map.painter),h.aS(this.dispatcher),o(null,P),void(t.reloadCallback&&(this.loadTile(t,t.reloadCallback),t.reloadCallback=null)))}}abortTile(t){t.request&&(t.request.cancel(),delete t.request),t.actor&&t.actor.send("abortTile",{uid:t.uid,type:this.t
8ype,source:this.id,scope:this.scope})}unloadTile(t,o){t.actor&&t.actor.send("removeTile",{uid:t.uid,type:this.type,source:this.id,scope:this.scope}),t.destroy()}hasTransition(){return!1}afterUpdate(){this._tileWorkers={}}cancelTileJSONRequest(){this._tileJSONRequest&&(this._tileJSONRequest.cancel(),this._tileJSONRequest=null)}}class mc extends h.E{constructor(t,o,c,d){super(),this.id=t,this.dispatcher=c,this.setEventedParent(d),this.type="raster",this.minzoom=0,this.maxzoom=22,this.roundZoom=!0,this.scheme="xyz",this.tileSize=512,this._loaded=!1,this._options=Object.assign({type:"raster"},o),Object.assign(this,h.aK(o,["url","scheme","tileSize"]))}load(t){this._loaded=!1,this.fire(new h.z("dataloading",{dataType:"source"}));let o=this.map.getWorldview(),c=(m,_)=>{this._tileJSONRequest=null,this._loaded=!0,m?this.fire(new h.y(m)):_&&(Object.assign(this,_),_.raster_layers&&(this.rasterLayers=_.raster_layers,this.rasterLayerIds=this.rasterLayers.map(y=>y.id)),this.tileBounds=ga.fromTileJSON(_),hi(_.tiles),this.fire(new h.z("data",{dataType:"source",sourceDataType:"metadata"})),this.fire(new h.z("data",{dataType:"source",sourceDataType:"content"}))),t&&t(m)};this.provider=typeof this._options.provider=="string"?this._options.provider:void 0,this._tileProvider=void 0;let d=h.aM(this._options);return d instanceof Error?(this._loaded=!0,this.fire(new h.y(d)),void(t&&t())):this.provider&&!d?(this._loaded=!0,this.fire(new h.y(new Error(`TileProvider "${this.provider}" is not registered`))),void(t&&t())):void(this._tileJSONRequest=d?this.loadTileJSONWithProvider(d,c):h.aN(this._options,this.map._requestManager,null,o,c))}loadTileJSONWithProvider(t,o){this.provider=t.name;let{request:c,options:d}=h.aO(this._options,this.map._requestManager),m=new AbortController;return h.aT(t.name,t.url).then(_=>{if(m.signal.aborted)return;let y=new _(d);return y.load&&c?y.load({request:c}).then(v=>(this._tileProvider=y,v)):(this._tileProvider=y,null)}).then(_=>{if(m.signal.aborted)return;let y=h.aP(this._options,_,this.map._requestManager);y instanceof Error?o(y):o(null,y)}).catch(_=>{m.signal.aborted||o(_ instanceof Error?_:new Error(String(_)))}),{cancel:()=>m.abort()}}loaded(){return this._loaded}onAdd(t){this.map=t,this.load()}reload(){this.cancelTileJSONRequest();let t=h.t(this.id,this.scope);this.load(()=>this.map.style.clearSource(t))}setTiles(t){return this._options.tiles=t,this.reload(),this}setUrl(t){return this.url=t,this._options.url=t,this.reload(),this}onRemove(t){this.cancelTileJSONRequest()}serialize(){return Object.assign({},this._options)}hasTile(t){return!this.tileBounds||this.tileBounds.contains(t.canonical)}loadTile(t,o){let c=h.o.devicePixelRatio>=2,d=this.map._requestManager.normalizeTileURL(t.tileID.canonical.url(this.tiles,this.scheme),c,this.tileSize),m=this.map._requestManager.transformRequest(d,h.R.Tile);if(this._tileProvider){let _=new AbortController;t.request={cancel:()=>_.abort()},this.loadTileWithProvider(t,this._tileProvider,m,_,o)}else t.request=h.n(m,(_,y,v)=>{if(delete t.request,t.aborted)return t.state="unloaded",o(null);if(_)return t.state="errored",o(_);if(!y)return o(null);let T=h.aR(v);this.map._refreshExpiredTiles&&t.setExpiryData(T),t.setTexture(y,this.map.painter),t.state="loaded",h.aS(this.dispatcher),o(null)})}async loadTileWithProvider(t,o,c,d,m){let{z:_,x:y,y:v}=t.tileID.canonical;try{let T=await o.loadTile({z:_,x:y,y:v},{request:c,signal:d.signal});if(d.signal.aborted)return t.state="unloaded",m(null);if(T==null){let P=new Error("Tile not found");return P.status=404,t.state="errored",m(P)}if(T.data==null)return t.state="loaded",m(null);let I=await createImageBitmap(new Blob([T.data]));if(d.signal.aborted)return t.state="unloaded",m(null);t.setTexture(I,this.map.painter),t.state="loaded",this.map._refreshExpiredTiles&&t.setExpiryData({cacheControl:T.cacheControl,expires:T.expires}),m(null)}catch(T){if(d.signal.aborted||T instanceof DOMException&&T.name==="AbortError")return t.state="unloaded",m(null);t.state="errored",m(T instanceof Error?T:new Error(String(T)))}finally{delete t.request}}abortTile(t,o){t.request&&(t.request.cancel(),delete t.request),o&&o()}unloadTile(t,o){t.texture&&t.texture instanceof h.T?(t.destroy(!1),t.texture&&t.texture instanceof h.T&&this.map.painter.saveTileTexture(t.texture)):t.destroy(),o&&o()}hasTransition(){return!1}cancelTileJSONRequest(){this._tileJSONRequest&&(this._tileJSONRequest.cancel(),this._tileJSONRequest=null)}}function ft([a,t],o,c,{scaled:d=!0}={}){let{tileSize:m,buffer:_}=c,{x:y,y:v,z:T}=o;if(!isFinite(y)||!isFinite(v)||!isFinite(T))throw new Error("Invalid MRT header");let I=2**T,P=I*h.aG(a),A=I*h.aJ(t);return function([D,L],O,{scaled:k=!0}
8={}){if(!O)throw new Error("bandView is undefined");let{data:N,tileSize:q,buffer:Z,offset:G,scale:re,dimension:te}=O;if(D<-Z||D>q+Z||L<-Z||L>q+Z)throw new Error(`Point (${D}, ${L}) out of bounds for tileSize=${q}, buffer=${Z}`);let se=(L+Z)*(q+2*Z)+(D+Z);if(new Uint32Array(N.buffer)[se]===4294967295)return null;let K=[];K=k?[]:new O.data.constructor(te);for(let J=0;J<te;J++)K[J]=Math.round(1e12*(N[te*se+J]*re+G))/1e12;return K}([Math.min(Math.max(-_,Math.floor((P-y)*m)),m-1+_),Math.min(Math.max(-_,Math.floor((A-v)*m)),m-1+_)],c,{scaled:d})}class jt extends mc{constructor(t,o,c,d){super(t,o,c,d),this.type="raster-array",this.maxzoom=22,this.partial=!0,this._loadTilePending={},this._loadTileLoaded={},this._options=Object.assign({type:"raster-array"},o)}triggerRepaint(t){let o=this.map.painter._terrain,c=this.map.style.getSourceCache(this.id);o&&o.enabled&&c&&o._clearRenderCacheForTile(c.id,t.tileID),this.map.triggerRepaint()}loadTile(t,o){let c=this.map._requestManager.normalizeTileURL(t.tileID.canonical.url(this.tiles,this.scheme),!1,this.tileSize),d=this.map._requestManager.transformRequest(c,h.R.Tile),m={request:d,uid:t.uid,tileID:t.tileID,type:this.t
8ype,source:this.id,scope:this.scope,partial:this.partial};t.source=this.id,t.scope=this.scope,t.requestParams=d,t.actor||(t.actor=this.dispatcher.getActor());let _=(y,v,T)=>{if(delete t.request,t.aborted)return t.state="unloaded",o(null);if(y)return y.name==="AbortError"?void 0:(t.state="errored",o(y));if(this.map._refreshExpiredTiles&&v){let I=h.aR(T);t.setExpiryData(I)}if(this.partial&&t.state!=="expired")t.state="empty";else if(!this.partial){if(!v)return o(null);t.state="loaded",t._isHeaderLoaded=!0,t._mrt=v}o(null)};t.request=this.partial?t.fetchHeader(void 0,_.bind(this)):t.actor.send("loadTile",m,_.bind(this),void 0,!0)}abortTile(t){t.request&&(t.request.cancel(),delete t.request),t.actor&&t.actor.send("abortTile",{uid:t.uid,type:this.type,source:this.id,scope:this.scope})}unloadTile(t,o){let c=t.texturePerLayer;if(t.flushAllQueues(),c.size){t.destroy(!1);for(let d of c.values())this.map.painter.saveTileTexture(d)}else t.destroy()}prepareTile(t,o,c,d){t._isHeaderLoaded&&(t.state!=="empty"&&(t.state="reloading"),t.fetchBandForRender(o,c,d,(m,_)=>{m?(t.state="errored",this.fire(new h.y(m))):_&&(t._isHeaderLoaded=!0,t.setTexturePerLayer(c,_,this.map.painter),t.state="loaded"),this.triggerRepaint(t)}))}getInitialBand(t){if(!this.rasterLayers)return 0;let o=this.rasterLayers.find(({id:m})=>m===t),c=o&&o.fields,d=c&&c.bands&&c.bands;return d?d[0]:0}getTextureDescriptor(t,o,c){if(!t)return;let d=o.sourceLayer||this.rasterLayerIds&&this.rasterLayerIds[0];if(!d)return;let m=null;o instanceof h.aV?m=o.paint.get("raster-array-band"):o instanceof h.aW&&(m=o.paint.get("raster-particle-array-band"));let _=m||this.getInitialBand(d);if(_==null)return;if(!t.textureDescriptorPerLayer.get(o.id))return void this.prepareTile(t,d,o.id,_);
8if(t.updateNeeded(o.id,_)&&!c)return;let y=t.textureDescriptorPerLayer.get(o.id);return Object.assign({},y,{texture:t.texturePerLayer.get(o.id)})}getImages(t,o){let c=new Map;for(let d of t)for(let m of o){let[_,y]=m.split("/"),v=d.getLayer(_);if(!v||!v.hasBand(y)||!v.hasDataForBand(y))continue;let{bytes:T,tileSize:I,buffer:P}=v.getBandView(y),A=I+2*P,D={data:new h.q({width:A,height:A},T),pixelRatio:2,sdf:!1,usvg:!1,version:0};c.set(m,D)}return c}queryRasterArrayValueByBandId(t,o,c){let d=o._mrt;return new Promise(m=>{let _={},y=new Set;for(let[v,T]of Object.entries(d.layers)){if(c.layerName&&v!==c.layerName)continue;let I={};_[v]=I;for(let{bands:P}of T.dataIndex)for(let A of P)c.bands&&!c.bands.includes(A)||(y.add(h.t(v,A)),o.fetchBand(v,null,A,D=>{h.o.frame(()=>{I[A]=D?null:ft([t.lng,t.lat],d,T.getBandView(A)),y.delete(h.t(v,A)),y.size===0&&m(_)})},!1))}y.size===0&&m(_)})}_loadTileForQuery(t,o){if(this._loadTileLoaded[t.uid])return void o(null,t._mrt);if(this._loadTilePending[t.uid])return void this._loadTilePending[t.uid].push(o);this._loadTilePending[t.uid]=[o];let c=this.map._requestManager.normalizeTileURL(t.tileID.canonical.url(this.tiles,this.scheme),!1,this.tileSize),d=this.map._requestManager.transformRequest(c,h.R.Tile);t.actor.send("loadTile",{request:d,uid:t.uid,tileID:t.tileID,type:this.t
8ype,source:this.id,scope:this.scope,partial:!1},(m,_,y)=>{if(m)return this._loadTilePending[t.uid].forEach(v=>v(m,null)),void delete this._loadTilePending[t.uid];if(!_)return this._loadTilePending[t.uid].forEach(v=>v(null,null)),void delete this._loadTilePending[t.uid];if(this.map._refreshExpiredTiles&&_){let v=h.aR(y);t.setExpiryData(v)}t._mrt=_,t._isHeaderLoaded=!0,t.state="loaded",this._loadTilePending[t.uid].forEach(v=>v(null,_)),this._loadTileLoaded[t.uid]=!0,delete this._loadTilePending[t.uid]},void 0,!0)}queryRasterArrayValueByAllBands(t,o,c){return new Promise((d,m)=>{this._loadTileForQuery(o,(_,y)=>{_?m(_):d(y?this.queryRasterArrayValueByBandId(t,o,c):null)})})}queryRasterArrayValue(t,o){let c=h.aX.convert(t),d=this.findLoadedParent(c);return d&&d._mrt?o.bands||!this.partial?this.queryRasterArrayValueByBandId(c,d,o):this.queryRasterArrayValueByAllBands(c,d,o):Promise.resolve(null)}findLoadedParent(t){let o=h.ad.fromLngLat(t,this.map.transform.tileSize),c=this.maxzoom+1,d=1<<c,m=Math.floor(o.x),_=Math.floor((o.x-m)*d),y=Math.floor(o.y*d),v=this.map.style.getSourceCache(this.id),T=new h.aU(c,m,c,_,y);return v.findLoadedParent(T,this.minzoom)}}let xu={vector:yu,raster:mc,"raster-dem":class extends mc{constructor(a,t,o,c){super(a,t,o,c),this.type="raster-dem",this.maxzoom=22,this._options=Object.assign({type:"raster-dem"},t),this.encoding=t.encoding||"mapbox"}loadTileJSONWithProvider(a,t){this.provider=a.name;let{request:o,options:c}=h.aO(this._options,this.map._requestManager),d=new AbortController;return this.dispatcher.broadcast("loadTileProvider",{name:a.name,url:a.url,source:this.id,scope:this.scope,type:this.type,options:c,request:o},(m,_)=>{if(d.signal.aborted)return;if(m)return void t(m);let y=_?_.find(T=>T!=null):null,v=h.aP(this._options,y,this.map._requestManager);v instanceof Error?t(v):t(null,v)}),{cancel:()=>d.abort()}}loadTile(a,t){let o=this.map._requestManager.normalizeTileURL(a.tileID.canonical.url(this.tiles,this.scheme),!1,this.tileSize),c=this.map._requestManager.transformRequest(o,h.R.Tile),d={uid:a.uid,tileID:a.tileID,source:this.id,type:this.t
8ype,scope:this.scope,request:c,encoding:this.encoding};a.actor&&a.state!=="expired"||(a.actor=this.dispatcher.getActor(),a.request=a.actor.send("loadTile",d,function(m,_){return delete a.request,a.aborted?(a.state="unloaded",t(null)):m?(a.state="errored",t(m)):(_&&(this.map._refreshExpiredTiles&&a.setExpiryData(_),_.borderReady||a.neighboringTiles||(a.neighboringTiles=this._getNeighboringTiles(a.tileID)),a.dem=_.dem,a.dem.onDeserialize(),a.needsHillshadePrepare=!0,a.needsDEMTextureUpload=!0),a.state="loaded",void t(null))}.bind(this),void 0,!0))}abortTile(a,t){a.request&&(a.request.cancel(),delete a.request),a.actor&&a.actor.send("abortTile",{uid:a.uid,type:this.type,source:this.id,scope:this.scope}),t&&t()}_getNeighboringTiles(a){let t=a.canonical,o=Math.pow(2,t.z),c=(t.x-1+o)%o,d=t.x===0?a.wrap-1:a.wrap,m=(t.x+1+o)%o,_=t.x+1===o?a.wrap+1:a.wrap,y={};return y[new h.aU(a.overscaledZ,d,t.z,c,t.y).key]={backfilled:!1},y[new h.aU(a.overscaledZ,_,t.z,m,t.y).key]={backfilled:!1},t.y>0&&(y[new h.aU(a.overscaledZ,d,t.z,c,t.y-1).key]={backfilled:!1},y[new h.aU(a.overscaledZ,a.wrap,t.z,t.x,t.y-1).key]={backfilled:!1},y[new h.aU(a.overscaledZ,_,t.z,m,t.y-1).key]={backfilled:!1}),t.y+1<o&&(y[new h.aU(a.overscaledZ,d,t.z,c,t.y+1).key]={backfilled:!1},y[new h.aU(a.overscaledZ,a.wrap,t.z,t.x,t.y+1).key]={backfilled:!1},y[new h.aU(a.overscaledZ,_,t.z,m,t.y+1).key]={backfilled:!1}),y}},"raster-array":jt,geojson:class extends h.E{constructor(a,t,o,c){super(),this.id=a,this.type="geojson",this.minzoom=0,this.maxzoom=18,this.tileSize=512,this.isTileClipped=!0,this.reparseOverscaled=!0,this._loaded=!1,this.actor=o.getActor(),this.setEventedParent(c),this._data=t.data,this._options=Object.assign({},t),this._collectResourceTiming=t.collectResourceTiming,t.maxzoom!==void 0&&(this.maxzoom=t.maxzoom),t.minzoom!==void 0&&(this.minzoom=t.minzoom),t.type&&(this.type=t.type),t.attribution&&(this.attribution=t.attribution),this.promoteId=t.promoteId;let d=h.ak/this.tileSize;this.workerOptions=Object.assign({source:this.id,scope:this.scope,cluster:t.cluster||!1,geojsonVtOptions:{buffer:(t.buffer!==void 0?t.buffer:128)*d,tolerance:(t.tolerance!==void 0?t.tolerance:.375)*d,extent:h.ak,maxZoom:this.maxzoom,lineMetrics:t.lineMetrics||!1,generateId:t.generateId||!1},superclusterOptions:{maxZoom:t.clusterMaxZoom!==void 0?t.clusterMaxZoom:this.maxzoom-1,minPoints:Math.max(2,t.clusterMinPoints||2),extent:h.ak,radius:(t.clusterRadius!==void 0?t.clusterRadius:50)*d,log:!1,generateId:t.generateId||!1},clusterProperties:t.clusterProperties,filter:t.filter,dynamic:t.dynamic},t.workerOptions)}onAdd(a){this.map=a,this.setData(this._data)}setData(a){return this._data=a,this._updateWorkerData(),this}
8updateData(a){if(!this._options.dynamic)return this.fire(new h.y(new Error("Can't call updateData on a GeoJSON source with dynamic set to false.")));if(typeof a!="string"&&(a.type==="Feature"&&(a={type:"FeatureCollection",features:[a]}),a.type!=="FeatureCollection"))return this.fire(new h.y(new Error("Data to update should be a feature or a feature collection.")));if(this._coalesce&&typeof a!="string"&&typeof this._data!="string"&&this._data.type==="FeatureCollection"){let t=new Map;for(let o of this._data.features)t.set(o.id,o);for(let o of a.features)t.set(o.id,o);this._data.features=[...t.values()]}else this._data=a;return this._updateWorkerData(!0),this}getClusterExpansionZoom(a,t){return this.actor.send("geojson.getClusterExpansionZoom",{clusterId:a,source:this.id,scope:this.scope},t),this}getClusterChildren(a,t){return this.actor.send("geojson.getClusterChildren",{clusterId:a,source:this.id,scope:this.scope},t),this}getClusterLeaves(a,t,o,c){return this.actor.send("geojson.getClusterLeaves",{source:this.id,scope:this.scope,clusterId:a,limit:t,offset:o},c),this}_updateWorkerData(a=!1){if(this._pendingLoad)return void(this._coalesce=!0);this.fire(new h.z("dataloading",{dataType:"source"})),this._loaded=!1;let t=Object.assign({append:a},this.workerOptions);t.scope=this.scope;let o=this._data;typeof o=="string"?(t.request=this.map._requestManager.transformRequest(h.o.resolveURL(o),h.R.Source),t.request.collectResourceTiming=this._collectResourceTiming):t.data=JSON.stringify(o),this._pendingLoad=this.actor.send(`${this.type}.loadData`,t,(c,d)=>{if(this._loaded=!0,this._pendingLoad=null,c)this.fire(new h.y(c));else{let m={dataType:"source",sourceDataType:this._metadataFired?"content":"metadata"};this._collectResourceTiming&&d&&d.resourceTiming&&d.resourceTiming[this.id]&&(m.resourceTiming=d.resourceTiming[this.id]),a&&(this._partialReload=!0),this.fire(new h.z("data",m)),this._partialReload=!1,this._metadataFired=!0}this._coalesce&&(this._updateWorkerData(a),this._coalesce=!1)})}loaded(){return this._loaded}reload(){let a=h.t(this.id,this.scope);this.map.style.clearSource(a),this._updateWorkerData()}loadTile(a,t){let o=a.actor?"reloadTile":"loadTile";a.actor=this.actor;let c=this.map.style?this.map.style.getLut(this.scope):null,d=c?{image:c.image.clone()}:null,m=this._partialReload,_={type:this.type,uid:a.uid,tileID:a.tileID,tileZoom:a.tileZoom,zoom:a.tileID.overscaledZ,maxZoom:this.maxzoom,tileSize:this.tileSize,source:this.id,lut:d,scope:this.scope,pixelRatio:h.o.devicePixelRatio,showCollisionBoxes:this.map.showCollisionBoxes,showElevationIdDebug:!!this.map.painter&&this.map.painter._debugParams.showElevationIdDebug,promoteId:this.promoteId,brightness:this.map.style&&this.map.style.getBrightness()||0,extraShadowCaster:a.isExtraShadowCaster,scaleFactor:this.map.getScaleFactor(),partial:m,worldview:this.map.getWorldview(),indoor:this.map.getIndoorTileOptions(this.id,this.scope)};a.request=this.actor.send(o,_,(y,v)=>m&&!v?(a.state="loaded",t(null)):(delete a.request,a.destroy(!1),a.aborted?t(null):y?t(y):(a.loadVectorData(v,this.map.painter,o==="reloadTile"),t(null))),void 0,o==="loadTile")}abortTile(a){a.request&&(a.request.cancel(),delete a.request),a.aborted=!0}unloadTile(a,t){this.actor.send("removeTile",{uid:a.uid,type:this.t
8ype,source:this.id,scope:this.scope}),a.destroy()}onRemove(a){this._pendingLoad&&this._pendingLoad.cancel()}serialize(){return Object.assign({},this._options,{type:this.type,data:this._data})}hasTransition(){return!1}},video:class extends h.aY{constructor(a,t,o,c){super(a,t,o,c),this.roundZoom=!0,this.type="video",this.options=t}load(){this._loaded=!1;let a=this.options;this.urls=[];for(let t of a.urls)this.urls.push(this.map._requestManager.transformRequest(t,h.R.Source).url);h.aZ(this.urls,(t,o)=>{this._loaded=!0,t?this.fire(new h.y(t)):o&&(this.video=o,this.video.loop=!0,this.video.setAttribute("playsinline",""),this.video.addEventListener("playing",()=>{this.map.triggerRepaint()}),this.map&&this.video.play(),this._finishLoading())})}pause(){this.video&&this.video.pause()}play(){this.video&&this.video.play()}seek(a){if(this.video){let t=this.video.seekable;a<t.start(0)||a>t.end(0)?this.fire(new h.y(new Ve(`sources.${this.id}`,null,`Playback for this video can be set only between the ${t.start(0)} and ${t.end(0)}-second mark.`))):this.video.currentTime=a}}getVideo(){return this.video}
8onAdd(a){this.map||(this.map=a,this.load(),this.video&&(this.video.play(),this.setCoordinates(this.coordinates)))}prepare(){if(Object.keys(this.tiles).length===0||this.video.readyState<2)return;let a=this.map.painter.context,t=a.gl;this.texture?this.video.paused||(this.texture.bind(t.LINEAR,t.CLAMP_TO_EDGE),t.texSubImage2D(t.TEXTURE_2D,0,0,0,t.RGBA,t.UNSIGNED_BYTE,this.video)):(this.texture=new h.T(a,this.video,t.RGBA8),this.texture.bind(t.LINEAR,t.CLAMP_TO_EDGE),this.width=this.video.videoWidth,this.height=this.video.videoHeight),this._prepareData(a)}serialize(){return{type:"video",urls:this.urls,coordinates:this.coordinates}}hasTransition(){return this.video&&!this.video.paused}},image:h.aY,model:h.a$,"batched-model":class extends h.E{constructor(a,t,o,c){super(),this.type="batched-model",this.id=a,this.tileSize=512,this._options=t,this.tiles=this._options.tiles,this.maxzoom=t.maxzoom||19,this.minzoom=t.minzoom||0,this.roundZoom=!0,this.usedInConflation=!0,this.dispatcher=o,this.reparseOverscaled=!1,this.scheme="xyz",this._loaded=!1,this.setEventedParent(c)}onAdd(a){this.map=a,this.load()}reload(){this.cancelTileJSONRequest();let a=h.t(this.id,this.scope);this.load(()=>this.map.style.clearSource(a))}cancelTileJSONRequest(){this._tileJSONRequest&&(this._tileJSONRequest.cancel(),this._tileJSONRequest=null)}load(a){this._loaded=!1,this.fire(new h.z("dataloading",{dataType:"source"}));let t=Array.isArray(this.map._language)?this.map._language.join():this.map._language,o=this.map.getWorldview();this._tileJSONRequest=h.aN(this._options,this.map._requestManager,t,o,(c,d)=>{this._tileJSONRequest=null,this._loaded=!0,c?(t&&console.warn(`Ensure that your requested language string is a valid BCP-47 code or list of codes. Found: ${t}`),o&&o.length!==2&&console.warn(`Requested worldview strings must be a valid ISO alpha-2 code. Found: ${o}`),this.fire(new h.y(c))):d&&(Object.assign(this,d),d.bounds&&(this.tileBounds=new ga(d.bounds,this.minzoom,this.maxzoom)),hi(d.tiles,this.map._requestManager._customAccessToken),this.fire(new h.z("data",{dataType:"source",sourceDataType:"metadata"})),this.fire(new h.z("data",{dataType:"source",sourceDataType:"content"}))),a&&a(c)})}hasTransition(){return!1}hasTile(a){return!this.tileBounds||this.tileBounds.contains(a.canonical)}loaded(){return this._loaded}loadTile(a,t){let o=this.map._requestManager.normalizeTileURL(a.tileID.canonical.url(this.tiles,this.scheme)),c={request:this.map._requestManager.transformRequest(o,h.R.Tile),data:void 0,uid:a.uid,tileID:a.tileID,tileZoom:a.tileZoom,zoom:a.tileID.overscaledZ,tileSize:this.tileSize*a.tileID.overscaleFactor(),type:this.t
8ype,source:this.id,scope:this.scope,showCollisionBoxes:this.map.showCollisionBoxes,renderSourceType:a.renderSourceType,brightness:this.map.style&&this.map.style.getBrightness()||0,pixelRatio:h.o.devicePixelRatio,promoteId:this.promoteId};if(a.actor&&a.state!=="expired")if(a.state==="loading")a.reloadCallback=t;else{if(a.buckets){let m=Object.values(a.buckets);for(let _ of m)_.dirty=!0;return void(a.state="loaded")}a.request=a.actor.send("reloadTile",c,d.bind(this))}else a.actor=this.dispatcher.getActor(),a.request=a.actor.send("loadTile",c,d.bind(this),void 0,!0);function d(m,_){return a.aborted?t(null):m&&m.status!==404?t(m):(this.map._refreshExpiredTiles&&_&&a.setExpiryData(_),a.loadModelData(_,this.map.painter),a.state="loaded",void t(null))}}serialize(){return Object.assign({},this._options)}},canvas:class extends h.aY{constructor(a,t,o,c){super(a,t,o,c),t.coordinates?Array.isArray(t.coordinates)&&t.coordinates.length===4&&!t.coordinates.some(d=>!Array.isArray(d)||d.length!==2||d.some(m=>typeof m!="number"))||this.fire(new h.y(new Ve(`sources.${a}`,null,'"coordinates" property must be an array of 4 longitude/latitude array pairs'))):this.fire(new h.y(new Ve(`sources.${a}`,null,'missing required property "coordinates"'))),t.animate&&typeof t.animate!="boolean"&&this.fire(new h.y(new Ve(`sources.${a}`,null,'optional "animate" property must be a boolean value'))),t.canvas?typeof t.canvas=="string"||t.canvas instanceof HTMLCanvasElement||this.fire(new h.y(new Ve(`sources.${a}`,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 h.y(new Ve(`sources.${a}`,null,'missing required property "canvas"'))),this.options=t,this.animate=t.animate===void 0||t.animate}load(){this._loaded=!0,this.canvas||(this.canvas=this.options.canvas instanceof HTMLCanvasElement?this.options.canvas:document.getElementById(this.options.canvas)),this.width=this.canvas.width,this.height=this.canvas.height,this._hasInvalidDimensions()?this.fire(new h.y(new Error("Canvas dimensions cannot be less than or equal to zero."))):(this.play=function(){this._playing=!0,this.map.triggerRepaint()},this.pause=function(){this._playing&&(this.prepare(),this._playing=!1)},this._finishLoading())}getCanvas(){return this.canvas}onAdd(a){this.map=a,this.load(),this.canvas&&this.animate&&this.play()}onRemove(a){this.pause()}prepare(){let a=!1;if(this.canvas.width!==this.width&&(this.width=this.canvas.width,a=!0),this.canvas.height!==this.height&&(this.height=this.canvas.height,a=!0),this._hasInvalidDimensions()||Object.keys(this.tiles).length===0)return;let t=this.map.painter.context;this.texture?!a&&!this._playing||this.texture instanceof h.a_||this.texture.update(this.canvas,{premultiply:!0}):this.texture=new h.T(t,this.canvas,t.gl.RGBA8,{premultiply:!0}),this._prepareData(t)}serialize(){return{type:"canvas",coordinates:this.coordinates}}hasTransition(){return this._playing}_hasInvalidDimensions(){for(let a of[this.canvas.width,this.canvas.height])if(isNaN(a)||a<=0)return!0;return!1}},custom:class extends h.E{constructor(a,t,o,c){super(),this.id=a,this.type="custom",this._dataType="raster",this._dispatcher=o,this._implementation=t,this.setEventedParent(c),this.scheme="xyz",this.minzoom=0,this.maxzoom=22,this.tileSize=512,this._loaded=!1,this.roundZoom=!0,this._implementation||this.fire(new h.y(new Error(`Missing implementation for ${this.id} custom source`))),this._implementation.loadTile||this.fire(new h.y(new Error(`Missing loadTile implementation for ${this.id} custom source`))),this._implementation.bounds&&(this.tileBounds=new ga(this._implementation.bounds,this.minzoom,this.maxzoom));let d=t;d.update=this._update.bind(this),d.clearTiles=this._clearTiles.bind(this),d.coveringTiles=this._coveringTiles.bind(this),Object.assign(this,h.aK(t,["dataType","scheme","minzoom","maxzoom","tileSize","attribution","minTileCacheSize","maxTileCacheSize"]))}serialize(){return h.aK(this,["type","scheme","minzoom","maxzoom","tileSize","attribution"])}load(){this._loaded=!0,this.fire(new h.z("data",{dataType:"source",sourceDataType:"metadata"})),this.fire(new h.z("data",{dataType:"source",sourceDataType:"content"}))}loaded(){return this._loaded}onAdd(a){this.map=a,this._loaded=!1,this.fire(new h.z("dataloading",{dataType:"source"})),this._implementation.onAdd&&this._implementation.onAdd(a),this.load()}onRemove(a){this._implementation.onRemove&&this._implementation.onRemove(a)}hasTile(a){if(this._implementation.hasTile){let{x:t,y:o,z:c}=a.canonical;return this._implementation.hasTile({x:t,y:o,z:c})}return!this.tileBounds||this.tileBounds.contains(a.canonical)}loadTile(a,t){let{x:o,y:c,z:d}
8=a.tileID.canonical,m=new AbortController,_=Promise.resolve(this._implementation.loadTile({x:o,y:c,z:d},{signal:m.signal})).then(function(y){return delete a.request,a.aborted?(a.state="unloaded",t(null)):y===void 0?(a.state="errored",t(null)):y===null?(this.loadTileData(a,{width:this.tileSize,height:this.tileSize,data:null}),a.state="loaded",t(null)):function(v){return v instanceof ImageData||v instanceof HTMLCanvasElement||v instanceof ImageBitmap||v instanceof HTMLImageElement}(y)?(this.loadTileData(a,y),a.state="loaded",void t(null)):(a.state="errored",t(new Error(`Can't infer data type for ${this.id}, only raster data supported at the moment`)))}.bind(this)).catch(y=>{y.name!=="AbortError"&&(a.state="errored",t(y))});_.cancel=()=>m.abort(),a.request=_}loadTileData(a,t){a.setTexture(t,this.map.painter)}unloadTile(a,t){if(a.texture&&a.texture instanceof h.T?(a.destroy(!1),a.texture&&a.texture instanceof h.T&&this.map.painter.saveTileTexture(a.texture)):a.destroy(),this._implementation.unloadTile){let{x:o,y:c,z:d}=a.tileID.canonical;this._implementation.unloadTile({x:o,y:c,z:d})}t&&t()}abortTile(a,t){a.request&&a.request.cancel&&(a.request.cancel(),delete a.request),t&&t()}hasTransition(){return!1}_coveringTiles(){return this.map.transform.coveringTiles({tileSize:this.tileSize,minzoom:this.minzoom,maxzoom:this.maxzoom,roundZoom:this.roundZoom}).map(a=>({x:a.canonical.x,y:a.canonical.y,z:a.canonical.z}))}_clearTiles(){let a=h.t(this.id,this.scope);this.map.style.clearSource(a)}_update(){this.fire(new h.z("data",{dataType:"source",sourceDataType:"content"}))}}},qh=function(a,t,o,c){let d=new xu[t.type](a,t,o,c);if(d.id!==a)throw new Error(`Expected Source id to be ${a} instead of ${d.id}`);return h.b0(["load","abort","unload","serialize","prepare"],d),d};function cf(a,t,o=""){return`${o}:${t.id||""}:${t.layer.id}:${function(c){if("layerId"in c)return`layer:${c.layerId}`;{let{featuresetId:d,importId:m}=c;return`featureset:${d}${m?`:import:${m}`:""}`}}(a.target)}`}function Zh(a,t,o,c=""){if(a.uniqueFeatureID){let d=cf(a,t,c);if(o.has(d))return!0;o.add(d)}return!1}function vu(a,t,o,c,d=!1,m=void 0){let _=t.sourceCache.transform,y=t.sourceCache.tilesIn(a,t.has3DLayers,d);y.sort(ya);let v=[];for(let T of y){let I=T.tile.queryRenderedFeatures(t,T,o,c,_,d,m);Object.keys(I).length&&v.push({wrappedTileID:T.tile.tileID.wrapped().key,queryResults:I})}for(let T in t.layers){let I=t.layers[T];if(I.styleLayer){let P=I.styleLayer.queryRenderedFeatures(a,t.sourceCache,c);Object.keys(P).length&&v.push({wrappedTileID:0,queryResults:P})}}return v.length===0?{}:function(T){let I={},P={};for(let A of T){let D=A.queryResults,L=A.wrappedTileID,O=P[L]=P[L]||{};for(let k in D){let N=D[k],q=O[k]=O[k]||{},Z=I[k]=I[k]||[];for(let G of N)q[G.featureIndex]||(q[G.featureIndex]=!0,Z.push(G))}}return I}(v)}function yo(a,t,o,c,d,m){let _={},y=c.queryRenderedSymbols(a),v=[];for(let T of Object.keys(y).map(Number))v.push(d[T]);v.sort(ya);for(let T of v){let I=T.featureIndex.lookupSymbolFeatures(y[T.bucketInstanceId],T.bucketIndex,T.sourceLayerIndex,t,o,m);for(let P in I){let A=_[P]=_[P]||[],D=I[P];D.sort((L,O)=>{let k=T.featureSortOrder;if(k){let N=k.indexOf(L.featureIndex);return k.indexOf(O.featureIndex)-N}return O.featureIndex-L.featureIndex});for(let L of D)A.push(L)}}return _}function Wh(a,t){let o=a.getRenderableIds().map(m=>a.getTileByID(m)),c=[],d={};for(let m=0;m<o.length;m++){let _=o[m],y=_.tileID.canonical.key;d[y]||(d[y]=!0,_.querySourceFeatures(c,t))}return c}function ya(a,t){let o=a.tileID,c=t.tileID;return o.overscaledZ-c.overscaledZ||o.canonical.y-c.canonical.y||o.wrap-c.wrap||o.canonical.x-c.canonical.x}h.b1.setPbf(h.b2);class st extends h.b3{constructor(t,o,c,d,m){super(t,o,c,d,m),this._workQueuePerLayer=new Map,this._fetchQueuePerLayer=new Map,this._taskQueue=new Map,this._isHeaderLoaded=!1,this.textureDescriptorPerLayer=new Map,this.texturePerLayer=new Map}getLayers(){return this._mrt?Object.values(this._mrt.layers):[]}getLayer(t){return this._mrt&&this._mrt.getLayer(t)}setTexturePerLayer(t,o,c){let d=c.context,m=d.gl,_=this.texturePerLayer.get(t)||c.getTileTexture(o.width);_&&_ instanceof h.T?_.update(o,{premultiply:!1}):_=new h.T(d,o,m.RGBA8,{premultiply:!1}),this.texturePerLayer.has(t)||this.texturePerLayer.set(t,_)}flushQueues(t){let o=this._workQueuePerLayer.get(t)||[],c=this._fetchQueuePerLayer.get(t)||[];for(;o.length;)o.pop()();for(;c.length;)c.pop()()}flushAllQueues(){for(let t of this._workQueuePerLayer.keys()){let o=this._workQueuePerLayer.get(t)||[];for(;o.length;)o.pop()()}for(let t of this._fetchQueuePerLayer.keys()){let o=this._fetchQueuePerLayer.get(t)||[];for(;o.length;)o.pop()()}}fetchHeader(t=16384,o){let c=this._mrt=new h.b1(30),d=Object.assign({}
8,this.requestParams,{headers:{Range:"bytes=0-"+(t-1)}});return this.entireBuffer=null,this.request=h.b4(d,(m,_,y)=>{if(m)o(m);else try{let v=c.getHeaderLength(_);if(v>t)return void(this.request=this.fetchHeader(v,o));c.parseHeader(_),this._isHeaderLoaded=!0;let T=0;for(let I of Object.values(c.layers))T=Math.max(T,I.dataIndex.at(-1).lastByte);_.byteLength>=T&&(this.entireBuffer=_),o(null,this.entireBuffer||_,y)}catch(v){o(v)}}),this.request}fetchBandForRender(t,o,c,d){this.fetchBand(t,o,c,m=>{if(m)return void d(m);this.updateTextureDescriptor(t,o,c);let _=this.textureDescriptorPerLayer.get(o);d(null,_?_.img:null)})}fetchBand(t,o,c,d,m=!0){let _=this._mrt;if(!this._isHeaderLoaded||!_)return void d(new Error("Tile header is not ready"));let y=this.actor;if(!y)return void d(new Error("Can't fetch tile band without an actor"));let v,T=h.t(String(c),h.t(this.tileID.key,t)),I=this._taskQueue.get(T);I?I.add(d):(I=new Set,I.add(d),this._taskQueue.set(T,I));let P=(O,k)=>{v.complete(O,k),O?d(O):(I.forEach(N=>N(null,k)),this._taskQueue.delete(T))},A=(O,k)=>{if(O)return d(O);let N=y.send("decodeRasterArray",{type:"raster-array",source:this.source,scope:this.scope,tileID:this.tileID,uid:this.uid,buffer:k,task:v},P,void 0,!0);if(o!==null){let q=this._workQueuePerLayer.get(o)||[];q.push(()=>{N&&N.cancel(),v.cancel()}),this._workQueuePerLayer.has(o)||this._workQueuePerLayer.set(o,q)}},D;try{D=_.getLayer(t)}catch(O){if(this.state==="reloading")return;throw O}if(!D)return void d(new Error(`Unknown sourceLayer "${t}"`));if(D.hasDataForBand(c))return I.forEach(O=>O(null,null)),void this._taskQueue.delete(T);let L=D.getDataRange([c]);if(v=_.createDecodingTask(L),!v||v.tasks.length)if(o!==null&&this.flushQueues(o),this.entireBuffer)A(null,this.entireBuffer.slice(L.firstByte,L.lastByte+1));else{let O=Object.assign({},this.requestParams,{headers:{Range:`bytes=${L.firstByte}-${L.lastByte}`}}),k=h.b4(O,A);if(o!==null){let N=this._fetchQueuePerLayer.get(o)||[];N.push(()=>{k.cancel(),v.cancel()}),this._fetchQueuePerLayer.has(o)||this._fetchQueuePerLayer.set(o,N)}}}updateNeeded(t,o){return(!this.textureDescriptorPerLayer.get(t)||this.textureDescriptorPerLayer.get(t).band!==o||this.refreshedUponExpiration)&&this.state!=="errored"}updateTextureDescriptor(t,o,c){if(!this._mrt)return;let d=this._mrt.getLayer(t);if(!d||!d.hasBand(c)||!d.hasDataForBand(c))return;let{bytes:m,tileSize:_,buffer:y,offset:v,scale:T}=d.getBandView(c),I=_+2*y,P=new h.q({width:I,height:I},m),A=this.texturePerLayer.get(o);A&&A instanceof h.T&&A.update(P,{premultiply:!1}),this.textureDescriptorPerLayer.set(o,{layer:t,band:c,img:P,buffer:y,offset:v,tileSize:_,format:d.pixelFormat,mix:[T,256*T,65536*T,16777216*T]})}destroy(t=!1){if(super.destroy(t),delete this._mrt,!t)for(let o of this.texturePerLayer.values())o&&o instanceof h.T&&o.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 Kt{constructor(t,o){this.max=t,this.onRemove=o,this.reset()}reset(){for(let t in this.data)for(let o of this.data[t])o.timeout&&clearTimeout(o.timeout),this.onRemove(o.value);return this.data={},this.order=[],this}add(t,o,c){let d=t.wrapped().key;this.data[d]===void 0&&(this.data[d]=[]);let m={value:o,timeout:void 0};if(c!==void 0&&(m.timeout=setTimeout(()=>{this.remove(t,m)},c)),this.data[d].push(m),this.order.push(d),this.order.length>this.max){let _=this._getAndRemoveByKey(this.order[0]);_&&this.onRemove(_)}return this}has(t){return t.wrapped().key in this.data}getAndRemove(t){return this.has(t)?this._getAndRemoveByKey(t.wrapped().key):null}_getAndRemoveByKey(t){let o=this.data[t].shift();return o.timeout&&clearTimeout(o.timeout),this.data[t].length===0&&delete this.data[t],this.order.splice(this.order.indexOf(t),1),o.value}getByKey(t){let o=this.data[t];return o?o[0].value:null}get(t){return this.has(t)?this.data[t.wrapped().key][0].value:null}remove(t,o){if(!this.has(t))return this;let c=t.wrapped().key,d=o===void 0?0:this.data[c].indexOf(o),m=this.data[c][d];return this.data[c].splice(d,1),m.timeout&&clearTimeout(m.timeout),this.data[c].length===0&&delete this.data[c],this.onRemove(m.value),this.order.splice(this.order.indexOf(c),1),this}setMaxSize(t){for(this.max=t;this.order.length>this.max;){let o=this._getAndRemoveByKey(this.order[0]);o&&this.onRemove(o)}return this}filter(t){let o=[];for(let c in this.data)for(let d of this.data[c])t(d.value)||o.push(d);for(let c of o)this.remove(c.value.tileID,c)}}class ni{constructor(){this.state={},this.stateChanges={},this.deletedStates={}}updateState(t,o,c){let d=String(o);if(this.stateChanges[t]=this.stateChanges[t]||{},this.stateChanges[t][d]=this.stateChanges[t][d]||{},Object.assign(this.stateChanges[t][d],c),this.deletedStates[t]===null){this.deletedStates[t]={};for(let m in this.state[t])m!==d&&(this.deletedStates[t][m]=null)}else if(this.deletedStates[t]&&this.deletedStates[t][d]===null){this.deletedStates[t][d]={};for(let m in this.state[t][d])c[m]||(this.deletedStates[t][d][m]=null)}else for(let m in c)this.deletedStates[t]&&this.deletedStates[t][d]&&this.deletedStates[t][d][m]===null&&delete this.deletedStates[t][d][m]}removeFeatureState(t,o,c){if(this.deletedStates[t]===null)return;let d=String(o);if(this.deletedStates[t]=this.deletedStates[t]||{},c&&o!==void 0)this.deletedStates[t][d]!==null&&(this.deletedStates[t][d]=this.deletedStates[t][d]||{},this.deletedStates[t][d][c]=null);else if(o!==void 0)if(this.stateChanges[t]&&this.stateChanges[t][d])for(c in this.deletedStates[t][d]={},this.stateChanges[t][d])this.deletedStates[t][d][c]=null;else this.deletedStates[t][d]=null;else this.deletedStates[t]=null}getState(t,o){let c=this.state[t]||{},d=this.stateChanges[t]||{},m=this.deletedStates[t];if(m===null)return{};if(o!==void 0){let y=String(o),v=Object.assign({},c[y],d[y]);if(m){let T=m[o];if(T===null)return{};for(let I in T)delete v[I]}return v}let _=Object.assign({},c,d);if(m)for(let y in m)delete _[y];return _}
8initializeTileState(t,o){t.refreshFeatureState(o)}coalesceChanges(t,o){let c={};for(let d in this.stateChanges){this.state[d]=this.state[d]||{};let m={};for(let _ in this.stateChanges[d])this.state[d][_]||(this.state[d][_]={}),Object.assign(this.state[d][_],this.stateChanges[d][_]),m[_]=this.state[d][_];c[d]=m}for(let d in this.deletedStates){this.state[d]=this.state[d]||{};let m={};if(this.deletedStates[d]===null)for(let _ in this.state[d])m[_]={},this.state[d][_]={};else for(let _ in this.deletedStates[d]){if(this.deletedStates[d][_]===null)this.state[d][_]={};else if(this.state[d][_])for(let y of Object.keys(this.deletedStates[d][_]))delete this.state[d][_][y];m[_]=this.state[d][_]}c[d]=c[d]||{},Object.assign(c[d],m)}if(this.stateChanges={},this.deletedStates={},Object.keys(c).length!==0)for(let d in t)t[d].refreshFeatureState(o,c)}}class rn extends h.E{constructor(t,o,c){super(),this.id=t,this._renderSourceType=c,this._maxzoomOverride=null,o.on("data",d=>{d.dataType==="source"&&d.sourceDataType==="metadata"&&(this._sourceLoaded=!0),this._sourceLoaded&&!this._paused&&d.dataType==="source"&&d.sourceDataType==="content"&&(this.reload(),this.transform&&this.update(this.transform))}),o.on("error",()=>{this._sourceErrored=!0}),this._source=o,this._tiles={},this._cache=new Kt(0,this._unloadTile.bind(this)),this._timers={},this._cacheTimers={},this._minTileCacheSize=o.minTileCacheSize,this._maxTileCacheSize=o.maxTileCacheSize,this._loadedParentTiles={},this.castsShadows=!1,this.tileCoverLift=0,this._coveredTiles={},this._shadowCasterTiles={},this._state=new ni,this._isRaster=this._source.type==="raster"||this._source.type==="raster-dem"||this._source.type==="raster-array"||this._source.type==="custom"&&"_dataType"in this._source&&this._source._dataType==="raster",this._supportsFading=this._source.type==="raster"||this._source.type==="raster-array"||this._source.type==="image"||this._source.type==="video"||this._source.type==="custom",this._isRasterElevatedOverTerrain=!1}onAdd(t){this.map=t,this._minTileCacheSize=this._minTileCacheSize===void 0&&t?t._minTileCacheSize:this._minTileCacheSize,this._maxTileCacheSize=this._maxTileCacheSize===void 0&&t?t._maxTileCacheSize:this._maxTileCacheSize}loaded(){if(this._sourceErrored)return!0;if(!this._sourceLoaded||!this._source.loaded())return!1;for(let t in this._tiles)if(!this._tiles[t].loaded())return!1;return!0}getSource(){return this._source}pause(){this._paused=!0}resume(){if(!this._paused)return;let t=this._shouldReloadOnResume;this._paused=!1,this._shouldReloadOnResume=!1,t&&this.reload(),this.transform&&this.update(this.transform)}setMaxzoomOverride(t){this._maxzoomOverride=t}_loadTile(t,o){return t.renderSourceType=this._renderSourceType,t.isExtraShadowCaster=this._shadowCasterTiles[t.tileID.key],this._source.loadTile(t,o)}_unloadTile(t){if(this._source.unloadTile)return this._source.unloadTile(t)}_abortTile(t){if(this._source.abortTile)return this._source.abortTile(t)}serialize(){return this._source.serialize()}prepare(t){this._source.prepare&&this._source.prepare(),this._state.coalesceChanges(this._tiles,this.map?this.map.painter:null);for(let o in this._tiles){let c=this._tiles[o];c.upload(t,this.map?this.map.painter:void 0),c.prepare(this.map.style.imageManager,this.map?this.map.painter:null,this._source.scope)}}getIds(){return Object.values(this._tiles).map(t=>t.tileID).sort(xa).map(t=>t.key)}getRenderableIds(t,o){let c=[];for(let d in this._tiles)this._isIdRenderable(+d,t,o)&&c.push(this._tiles[d]);return t?c.sort((d,m)=>{let _=d.tileID,y=m.tileID,v=new h.P(_.canonical.x,_.canonical.y)._rotate(this.transform.angle),T=new h.P(y.canonical.x,y.canonical.y)._rotate(this.transform.angle);return _.overscaledZ-y.overscaledZ||T.y-v.y||T.x-v.x}).map(d=>d.tileID.key):c.map(d=>d.tileID).sort(xa).map(d=>d.key)}hasRenderableParent(t){let o=this.findLoadedParent(t,0);return!!o&&this._isIdRenderable(o.tileID.key)}_isIdRenderable(t,o,c){return this._tiles[t]&&this._tiles[t].hasData()&&!this._coveredTiles[t]&&(o||!this._tiles[t].holdingForFade())&&(c||!this._shadowCasterTiles[t])}reload(){if(this._paused)this._shouldReloadOnResume=!0;else{this._cache.reset();for(let t in this._tiles)this._tiles[t].state!=="errored"&&this._reloadTile(+t,"reloading")}}_reloadTile(t,o){let c=this._tiles[t];c&&(c.state!=="loading"&&(c.state=o),this._loadTile(c,this._tileLoaded.bind(this,c,t,o)))}_tileLoaded(t,o,c,d,m){if(d){if(t.state="errored",h.b5(d)){if(this._source.fire(new h.z("data",{dataType:"source",sourceDataType:"error",sourceId:this._source.id,tile:t})),!(t.tileID.key in this._loadedParentTiles))return;if(this._source.type==="raster-dem"&&this.usedForTerrain&&this.map.painter.terrain){let y=this.map.painter.terrain;this.update(this.transform,y.getScaledDemTileSize(),!0),y.resetTileLookupCache(this.id
8)}else this.update(this.transform)}else this._source.fire(new h.y(d,{tile:t}));return}t.timeAdded=h.o.now(),c==="expired"&&(t.refreshedUponExpiration=!0),this._setTileReloadTimer(o,t),this._source.type==="raster-dem"&&t.dem&&this._backfillDEM(t),this._state.initializeTileState(t,this.map?this.map.painter:null);let _=new Map;m&&m.responseHeaders&&(_=m.responseHeaders),this._source.fire(new h.z("data",{dataType:"source",tile:t,coord:t.tileID,sourceCacheId:this.id,responseHeaders:_}))}_hasTunnelGeometry(){for(let t in this._tiles){let o=this._tiles[t];if(o&&o.hasTunnelGeometry)return!0}return!1}_backfillDEM(t){let o=this.getRenderableIds();for(let d=0;d<o.length;d++){let m=o[d];if(t.neighboringTiles&&t.neighboringTiles[m]){let _=this.getTileByID(m);c(t,_),c(_,t)}}function c(d,m){if(!d.dem||d.dem.borderReady)return;d.needsHillshadePrepare=!0,d.needsDEMTextureUpload=!0;let _=m.tileID.canonical.x-d.tileID.canonical.x,y=m.tileID.canonical.y-d.tileID.canonical.y,v=Math.pow(2,d.tileID.canonical.z),T=m.tileID.key;_===0&&y===0||Math.abs(y)>1||(Math.abs(_)>1&&(Math.abs(_+v)===1?_+=v:Math.abs(_-v)===1&&(_-=v)),m.dem&&d.dem&&(d.dem.backfillBorder(m.dem,_,y),d.neighboringTiles&&d.neighboringTiles[T]&&(d.neighboringTiles[T].backfilled=!0)))}}getTile(t){return this.getTileByID(t.key)}getTileByID(t){return this._tiles[t]}_retainLoadedChildren(t,o,c,d){for(let m in this._tiles){let _=this._tiles[m];if(d[m]||!_.hasData()||_.tileID.overscaledZ<=o||_.tileID.overscaledZ>c)continue;let y=_.tileID;for(;_&&_.tileID.overscaledZ>o+1;){let T=_.tileID.scaledTo(_.tileID.overscaledZ-1);_=this._tiles[T.key],_&&_.hasData()&&(y=T)}let v=y;for(;v.overscaledZ>o;)if(v=v.scaledTo(v.overscaledZ-1),t[v.key]){d[y.key]=y;break}}}findLoadedParent(t,o){if(t.key in this._loadedParentTiles){let c=this._loadedParentTiles[t.key];return c&&c.tileID.overscaledZ>=o?c:null}for(let c=t.overscaledZ-1;c>=o;c--){let d=t.scaledTo(c),m=this._getLoadedTile(d);if(m)return m}}_getLoadedTile(t){let o=this._tiles[t.key];return o&&o.hasData()?o:this._cache.getByKey(this._source.reparseOverscaled?t.wrapped().key:t.canonical.key)}updateCacheSize(t,o){o=o||this._source.tileSize;let c=Math.ceil(t.width/o)+1,d=Math.ceil(t.height/o)+1,m=Math.floor(c*d*5),_=typeof this._minTileCacheSize=="number"?Math.max(this._minTileCacheSize,m):m,y=typeof this._maxTileCacheSize=="number"?Math.min(this._maxTileCacheSize,_):_;this._cache.setMaxSize(y)}handleWrapJump(t){let o=Math.round((t-(this._prevLng===void 0?t:this._prevLng))/360);if(this._prevLng=t,o){let c={};for(let d in this._tiles){let m=this._tiles[d];m.tileID=m.tileID.unwrapTo(m.tileID.wrap+o),c[m.tileID.key]=m}this._tiles=c;for(let d in this._timers)clearTimeout(this._timers[d]),delete this._timers[d];for(let d in this._tiles)this._setTileReloadTimer(+d,this._tiles[d])}}update(t,o,c,d,m){if(this.transform=t,!this._sourceLoaded||this._paused||this.transform.freezeTileCoverage||this.usedForTerrain&&!c)return;this.updateCacheSize(t,o),this.transform.projection.name!=="globe"&&this.handleWrapJump(this.transform.center.lng),this._shadowCasterTiles={},this._coveredTiles={};let _=this._source.type==="batched-model",y,v=this._source.maxzoom;this._maxzoomOverride!==null&&(v=Math.min(v,this._maxzoomOverride));let T=this.map&&this.map.painter?this.map.painter._terrain:null;if(T&&T.sourceCache===this&&T.attenuationRange()){let D=T.attenuationRange()[0],L=Math.floor(D)-Math.log2(T.getDemUpscale());v>L&&(v=L)}let I=this._maxzoomOverride===null&&this._source.reparseOverscaled;if(this.used||this.usedForTerrain){if(this._source.tileID)y=t.getVisibleUnwrappedCoordinates(this._source.tileID).map(D=>new h.aU(D.canonical.z,D.wrap,D.canonical.z,D.canonical.x,D.canonical.y));else if(this.tileCoverLift!==0){let D=t.clone();D.tileCoverLift=this.tileCoverLift,y=D.coveringTiles({tileSize:o||this._source.tileSize,minzoom:this._source.minzoom,maxzoom:v,roundZoom:this._source.roundZoom&&!c,reparseOverscaled:I,isTerrainDEM:this.usedForTerrain,calculateQuadrantVisibility:_}),this._source.minzoom<=1&&t.projection.name==="globe"&&(y.push(new h.aU(1,0,1,0,0)),y.push(new h.aU(1,0,1,1,0)),y.push(new h.aU(1,0,1,0,1)),y.push(new h.aU(1,0,1,1,1)))}else if(y=t.coveringTiles({tileSize:o||this._source.tileSize,minzoom:this._source.minzoom,maxzoom:v,roundZoom:this._source.roundZoom&&!c,reparseOverscaled:I,isTerrainDEM:this.usedForTerrain,calculateQuadrantVisibility:_}),this._source.hasTile){let D=this._source.hasTile.bind(this._source);y=y.filter(L=>D(L))}}else y=[];if(y.length>0&&this.transform.projection.name!=="globe"&&!this.usedForTerrain&&!this._supportsFading){let D=t.coveringZoomLevel({tileSize:o||this._source.tileSize,roundZoom:this._source.roundZoom&&!c}),L=Math.min(D,v);if(_){let O=t.extendTileCover(y,L);for(let k of O)y.push(k)}else if(m){let O=this.transform.getFrustum(L),k=t.extendTileCoverToNearPlane(y,O,L);for(let N of k)y.push(N);if(L>=18&&this._hasTunnelGeometry()){let N=t.extendTileCoverForTunnels(y,O,L,20);for(let q of N)y.push(q)}}else if(this.castsShadows&&d){let O=t.extendTileCover(y,L,d,16);for(let k of O)this._shadowCasterTiles[k.key]=!0,y.push(k)}}let P=this._updateRetainedTiles(y);if(this._supportsFading&&y.length!==0){let D={},L={},O=h.o.now(),k=Object.keys(P);
8for(let q of k){let Z=P[q],G=this._tiles[q];if(!G||G.fadeEndTime!==void 0&&G.fadeEndTime<=O)continue;let re=this.findLoadedParent(Z,Math.max(Z.overscaledZ-rn.maxOverzooming,this._source.minzoom));re&&(this._addTile(re.tileID),D[re.tileID.key]=re.tileID),L[q]=Z}let N=y.at(-1).overscaledZ;for(let q in this._tiles){let Z=this._tiles[q];if(P[q]||!Z.hasData())continue;let G=Z.tileID;for(;G.overscaledZ>N;){G=G.scaledTo(G.overscaledZ-1);let re=this._tiles[G.key];if(re&&re.hasData()&&L[G.key]){P[q]=Z.tileID;break}}}for(let q in D)P[q]||(this._coveredTiles[q]=!0,P[q]=D[q])}for(let D in P)this._tiles[D].clearFadeHold();let A=h.b6(this._tiles,P);for(let D of A){let L=this._tiles[D];L.hasSymbolBuckets&&!L.holdingForFade()?L.setHoldDuration(this.map._fadeDuration):L.hasSymbolBuckets&&!L.symbolFadeFinished()||this._removeTile(+D)}this._updateLoadedParentTileCache(),this._renderSourceType===h.b7.Symbol&&this._source.afterUpdate&&this._source.afterUpdate()}releaseSymbolFadeTiles(){for(let t in this._tiles)this._tiles[t].holdingForFade()&&this._removeTile(+t)}_updateRetainedTiles(t){let o={};if(t.length===0)return o;let c={},d=t.reduce((T,I)=>Math.min(T,I.overscaledZ),1/0),m=t[0].overscaledZ,_=Math.max(m-rn.maxOverzooming,this._source.minzoom),y=Math.max(m+rn.maxUnderzooming,this._source.minzoom),v={};for(let T of t){let I=this._addTile(T);o[T.key]=T,I.hasData()||d<this._source.maxzoom&&(v[T.key]=T)}this._retainLoadedChildren(v,d,y,o);for(let T of t){let I=this._tiles[T.key];if(I.hasData())continue;if(T.canonical.z>=this._source.maxzoom){let A=T.children(this._source.maxzoom)[0],D=this.getTile(A);if(D&&D.hasData()){o[A.key]=A;continue}}else{let A=T.children(this._source.maxzoom);if(o[A[0].key]&&o[A[1].key]&&o[A[2].key]&&o[A[3].key])continue}let P=I.wasRequested();for(let A=T.overscaledZ-1;A>=_;--A){let D=T.scaledTo(A);if(c[D.key]||(c[D.key]=!0,I=this.getTile(D),!I&&P&&(I=this._addTile(D)),I&&(o[D.key]=D,P=I.wasRequested(),I.hasData())))break}}return o}_updateLoadedParentTileCache(){this._loadedParentTiles={};for(let t in this._tiles){let o=[],c,d=this._tiles[t].tileID;for(;d.overscaledZ>0;){if(d.key in this._loadedParentTiles){c=this._loadedParentTiles[d.key];break}o.push(d.key);let m=d.scaledTo(d.overscaledZ-1);if(c=this._getLoadedTile(m),c)break;d=m}for(let m of o)this._loadedParentTiles[m]=c}}_addTile(t){let o=this._tiles[t.key];if(o)return o.isExtraShadowCaster!==!0||this._shadowCasterTiles[t.key]||this._reloadTile(t.key,"reloading"),o;o=this._cache.getAndRemove(t),o&&(this._setTileReloadTimer(t.key,o),o.tileID=t,this._state.initializeTileState(o,this.map?this.map.painter:null),this._cacheTimers[t.key]&&(clearTimeout(this._cacheTimers[t.key]),delete this._cacheTimers[t.key],this._setTileReloadTimer(t.key,o)));let c=!!o;if(!c){let d=this.map?this.map.painter:null,m=this._source.tileSize*t.overscaleFactor();o=this._source.type==="raster-array"?new st(t,m,this.transform.tileZoom,d,this._isRaster):new h.b3(t,m,this.transform.tileZoom,d,this._isRaster,this._source.worldview),this._loadTile(o,this._tileLoaded.bind(this,o,t.key,o.state))}return o.uses++,this._tiles[t.key]=o,c||this._source.fire(new h.z("dataloading",{tile:o,coord:o.tileID,dataType:"source"})),o}_setTileReloadTimer(t,o){t in this._timers&&(clearTimeout(this._timers[t]),delete this._timers[t]);let c=o.getExpiryTimeout();c&&(this._timers[t]=setTimeout(()=>{this._reloadTile(t,"expired"),delete this._timers[t]},c))}_removeTile(t){let o=this._tiles[t];o&&(o.uses--,delete this._tiles[t],this._timers[t]&&(clearTimeout(this._timers[t]),delete this._timers[t]),o.uses>0||(o.hasData()&&o.state!=="reloading"||o.state==="empty"?this._cache.add(o.tileID,o,o.getExpiryTimeout()):(o.aborted=!0,this._abortTile(o),this._unloadTile(o))))}clearTiles(){this._shouldReloadOnResume=!1,this._paused=!1;for(let t in this._tiles)this._removeTile(+t);this._source._clear&&this._source._clear(),this._cache.reset(),this.map&&this.usedForTerrain&&this.map.painter.terrain&&this.map.painter.terrain.resetTileLookupCache(this.id)}tilesIn(t,o,c){let d=[],m=this.transform;if(!m)return d;let _=m.projection.name==="globe",y=h.aG(m.center.lng);for(let v in this._tiles){let T=this._tiles[v];if(c&&T.clearQueryDebugViz(),T.holdingForFade())continue;let I;if(_){let P=T.tileID.canonical;if(P.z===0){let A=[Math.abs(h.aB(y,...qt(P,-1))-y),Math.abs(h.aB(y,...qt(P,1))-y)];I=[0,2*A.indexOf(Math.min(...A))-1]}else{let A=[Math.abs(h.aB(y,...qt(P,-1))-y),Math.abs(h.aB(y,...qt(P,0))-y),Math.abs(h.aB(y,...qt(P,1))-y)];I=[A.indexOf(Math.min(...A))-1]}}else I=[0];for(let P of I){let A=t.containsTile(T,m,o,P);A&&d.push(A)}}return d}getShadowCasterCoordinates(){return this._getRenderableCoordinates(!1,!0)}getVisibleCoordinates(t){return this._getRenderableCoordinates(t)}_getRenderableCoordinates(t,o){let c=this.getRenderableIds(t,o).map(m=>this._tiles[m].tileID),d=this.transform.projection.name==="globe";for(let m of c)m.projMatrix=this.transform.calculateProjMatrix(m.toUnwrapped()),m.expandedProjMatrix=d?this.transform.calculateProjMatrix(m.toUnwrapped(),!1,!0):m.projMatrix;return c}sortCoordinatesByDistance(t){let o=t.slice(),c=this.transform._camera.position,d=this.transform._camera.forward(),m={};for(let _ of o){let y=1/(1<<_.canonical.z);m[_.key]=((_.canonical.x+.5)*y+_.wrap-c[0])*d[0]+((_.canonical.y+.5)*y-c[1])*d[1]-c[2]*d[2]}return o.sort((_,y)=>m[_.key]-m[y.key]),o}hasTransition(){if(this._source.hasTransition())return!0;
8if(this._supportsFading){let t=h.o.now();for(let o in this._tiles){let c=this._tiles[o];if(c.fadeEndTime!==void 0&&c.fadeEndTime>=t)return!0}}return!1}setFeatureState(t,o,c){this._state.updateState(t=t||"_geojsonTileLayer",o,c)}removeFeatureState(t,o,c){this._state.removeFeatureState(t=t||"_geojsonTileLayer",o,c)}getFeatureState(t,o){return this._state.getState(t=t||"_geojsonTileLayer",o)}setDependencies(t,o,c){let d=this._tiles[t];d&&d.setDependencies(o,c)}reloadTilesForDependencies(t,o){for(let c in this._tiles)this._tiles[c].hasDependency(t,o)&&this._reloadTile(+c,"reloading");this._cache.filter(c=>!c.hasDependency(t,o))}_preloadTiles(t,o){if(!this._sourceLoaded){let v=()=>{this._sourceLoaded&&(this._source.off("data",v),this._preloadTiles(t,o))};return void this._source.on("data",v)}let c=new Map,d=Array.isArray(t)?t:[t],m=this.map.painter.terrain,_=this.usedForTerrain&&m?m.getScaledDemTileSize():this._source.tileSize;for(let v of d){let T=v.coveringTiles({tileSize:_,minzoom:this._source.minzoom,maxzoom:this._source.maxzoom,roundZoom:this._source.roundZoom&&!this.usedForTerrain,reparseOverscaled:this._source.reparseOverscaled,isTerrainDEM:this.usedForTerrain});for(let I of T)c.set(I.key,I);this.usedForTerrain&&v.updateElevation(!1)}let y=Array.from(c.values());h.ao(y,(v,T)=>{let I=new h.b3(v,this._source.tileSize*v.overscaleFactor(),this.transform.tileZoom,this.map.painter,this._isRaster,this._source.worldview);this._loadTile(I,P=>{this._source.type==="raster-dem"&&I.dem&&this._backfillDEM(I),T(P,I)})},o)}}function xa(a,t){let o=Math.abs(2*a.wrap)-+(a.wrap<0),c=Math.abs(2*t.wrap)-+(t.wrap<0);return a.overscaledZ-t.overscaledZ||c-o||t.canonical.y-a.canonical.y||t.canonical.x-a.canonical.x}function qt(a,t){let o=1<<a.z;return[a.x/o+t,(a.x+1)/o+t]}rn.maxOverzooming=10,rn.maxUnderzooming=3;class bu{constructor(t){this.style=t,this.layersGotHidden=!1,this.layers=[]}processLayersChanged(){this.layers=[];let t=!1,o=!1;for(let c in this.style._mergedLayers){let d=this.style._mergedLayers[c];if(d.type==="fill-extrusion"||d.type==="building")this.layers.push({layer:d,visible:t,visibilityChanged:o});else if(d.type==="model"){let m=this.style.getLayerSource(d);m&&m.type==="batched-model"&&this.layers.push({layer:d,visible:t,visibilityChanged:o})}}}onNewFrame(t){this.layersGotHidden=!1;for(let o of this.layers){let c=o.layer,d=!1;c.type==="fill-extrusion"?d=!c.isHidden(t)&&c.paint.get("fill-extrusion-opacity")>0:c.type==="building"?d=!c.isHidden(t)&&c.paint.get("building-opacity")>0:c.type==="model"&&(d=!c.isHidden(t)&&c.paint.get("model-opacity").constantOr(1)>0),this.layersGotHidden=this.layersGotHidden||!d&&o.visible,o.visible=d}}updateZOffset(t,o){this.currentBuildingBuckets=[];for(let d of this.layers){let m=d.layer,_=this.style.getLayerSourceCache(m),y=1;m.type==="fill-extrusion"?y=d.visible?m.paint.get("fill-extrusion-vertical-scale"):0:m.type==="building"&&(y=d.visible?m.paint.get("building-vertical-scale"):0);let v=_?_.getTile(o):null;if(!v&&_)for(let T in _._tiles){let I=_._tiles[T];if(o.canonical.isChildOf(I.tileID.canonical)){v=I;break}}this.currentBuildingBuckets.push({bucket:v?v.getBucket(m):null,tileID:v?v.tileID:o,verticalScale:y})}t.hasAnyZOffset=!1;let c=!1;for(let d=0;d<t.symbolInstances.length;d++){let m=t.symbolInstances.get(d),_=m.zOffset,y=this._getHeightAtTileOffset(o,m.tileAnchorX,m.tileAnchorY);m.zOffset=y!==Number.NEGATIVE_INFINITY?y:_,c||_===m.zOffset||(c=!0),t.hasAnyZOffset||m.zOffset===0||(t.hasAnyZOffset=!0)}c&&(t.zOffsetBuffersNeedUpload=!0,t.zOffsetSortDirty=!0)}_mapCoordToOverlappingTile(t,o,c,d){let m=o,_=c;if(t.canonical.z!==d.canonical.z){let y=d.canonical,v=1/(1<<t.canonical.z-y.z);m=(o+t.canonical.x*h.ak)*v-y.x*h.ak|0,_=(c+t.canonical.y*h.ak)*v-y.y*h.ak|0}return{tileX:m,tileY:_}}_getHeightAtTileOffset(t,o,c){let d,m;for(let _=0;_<this.layers.length;++_){let y=this.layers[_].layer;if(y.type!=="fill-extrusion"&&y.type!=="building")continue;let{bucket:v,tileID:T,verticalScale:I}=this.currentBuildingBuckets[_];if(!v)continue;let{tileX:P,tileY:A}=this._mapCoordToOverlappingTile(t,o,c,T),D=v.getHeightAtTileCoord(P,A);D&&D.height!==void 0&&(D.hidden?d=D.height:m=Math.max(D.height*I,m||0))}if(m!==void 0)return m;for(let _=0;_<this.layers.length;++_){let y=this.layers[_];if(y.layer.type!=="model"||!y.visible)continue;let{bucket:v,tileID:T}=this.currentBuildingBuckets[_];if(!v)continue;let{tileX:I,tileY:P}=this._mapCoordToOverlappingTile(t,o,c,T),A=v.getHeightAtTileCoord(I,P);if(A&&!A.hidden)return A.height===void 0&&d!==void 0?Math.min(A.maxHeight,d)*A.verticalScale:A.height?A.height*A.verticalScale:Number.NEGATIVE_INFINITY}return this.layersGotHidden?0:Number.NEGATIVE_INFINITY}}let Yo;function sl(){return Yo||(Yo=new Ts),Yo}function Yn(a,t){let o={};for(let c in a)c!=="ref"&&(o[c]=a[c]);return h.b8.forEach(c=>
8{c in t&&(o[c]=t[c])}),o}function on(a){a=a.slice();let t=Object.create(null);for(let o of a)t[o.id]=o;for(let o=0;o<a.length;o++){let c=a[o];if(c&&"ref"in c){let d=t[c.ref];d&&(a[o]=Yn(c,d))}}return a}let Wt={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 al(a,t,o){o.push({command:Wt.addSource,args:[a,t[a]]})}function wu(a,t,o){t.push({command:Wt.removeSource,args:[a]}),o[a]=!0}function _c(a,t,o,c){wu(a,o,c),al(a,t,o)}function Tu(a,t,o){let c;for(c in a[o])if(Object.hasOwn(a[o],c)&&c!=="data"&&!h.b9(a[o][c],t[o][c]))return!1;for(c in t[o])if(Object.hasOwn(t[o],c)&&c!=="data"&&!h.b9(a[o][c],t[o][c]))return!1;return!0}function ll(a,t,o,c,d,m){let _;for(_ in t=t||{},a=a||{})Object.hasOwn(a,_)&&(h.b9(a[_],t[_])||o.push({command:m,args:[c,_,t[_],d]}));for(_ in t)Object.hasOwn(t,_)&&!Object.hasOwn(a,_)&&(h.b9(a[_],t[_])||o.push({command:m,args:[c,_,t[_],d]}))}function va(a){return a.id}function kn(a,t){return a[t.id]=t,a}function xr(a,t,o){let c=t.createTileMatrix(a,a.worldSize,o.toUnwrapped());return h.aC(new Float32Array(16),a.projMatrix,c)}function cr(a,t,o){if(t.projection.name===o.projection.name)return a.projMatrix;let c=o.clone();return c.setProjection(t.projection),xr(c,t.getProjection(),a)}function Su(a,t,o){return t.name===o.projection.name?a.projMatrix:xr(o,t,a)}class cl{constructor(t,o){this.reset(t,o)}reset(t,o){this.points=t||[],this._distances=[0];for(let c=1;c<this.points.length;c++)this._distances[c]=this._distances[c-1]+this.points[c].dist(this.points[c-1]);this.length=this._distances.at(-1),this.padding=Math.min(o||0,.5*this.length),this.paddedLength=this.length-2*this.padding}lerp(t){if(this.points.length===1)return this.points[0];t=h.aB(t,0,1);let o=1,c=this._distances[o],d=t*this.paddedLength+this.padding;for(;c<d&&o<this._distances.length;)c=this._distances[++o];let m=o-1,_=this._distances[m],y=c-_,v=y>0?(d-_)/y:0;return this.points[m].mult(1-v).add(this.points[o].mult(v))}}let vn=Math.tan(85*Math.PI/180);function vr(a,t,o,c,d,m,_){let y=h.bd();if(o)if(m.name==="globe"){let v=h.be(d,t);h.aC(y,y,v)}else{let v=h.bf([],_);y[0]=v[0],y[1]=v[1],y[4]=v[2],y[5]=v[3],c||h.bc(y,y,d.angle)}else h.aC(y,d.labelPlaneMatrix,a);return y}function xo(a,t,o,c,d,m,_){let y=vr(a,t,o,c,d,m,_);return m.name==="globe"&&o||(y[2]=y[6]=y[10]=y[14]=0),y}function sn(a,t,o,c,d,m,_){if(o){if(m.name==="globe"){let y=vr(a,t,o,c,d,m,_);return h.ba(y,y),h.aC(y,a,y),y}{let y=h.bb(a),[v,T,I,P]=_,[A,D,L,O,k,N,q,Z]=y;return y[0]=v*A+T*k,y[1]=v*D+T*N,y[2]=v*L+T*q,y[3]=v*O+T*Z,y[4]=I
8*A+P*k,y[5]=I*D+P*N,y[6]=I*L+P*q,y[7]=I*O+P*Z,c||h.bc(y,y,-d.angle),y}}return d.glCoordMatrix}function Or(a,t,o,c){let d=[a,t,o,1];o?h.aD(d,d,c):uf(d,d,c);let m=d[3];return d[0]/=m,d[1]/=m,d[2]/=m,d}function Qr(a,t){return Math.min(.5+a/t*.5,1.5)}function gc(a,t){let o=a[0]/a[3],c=a[1]/a[3];return o>=-t[0]&&o<=t[0]&&c>=-t[1]&&c<=t[1]}function yc(a,t,o,c,d,m,_,y,v,T,I=1){let P=o.transform,A=c?a.textSizeData:a.iconSizeData,D=h.bl(A,o.transform.zoom,I),L=P.projection.name==="globe",O=[256/o.width*2+1,256/o.height*2+1],k=c?a.text.dynamicLayoutVertexArray:a.icon.dynamicLayoutVertexArray;k.clear();let N=null;L&&(N=c?a.text.globeExtVertexArray:a.icon.globeExtVertexArray);let q=a.lineVertexArray,Z=c?a.text.placedSymbolArray:a.icon.placedSymbolArray,G=o.transform.width/o.transform.height,re,te=!1;for(let se=0;se<Z.length;se++){let K=Z.get(se),{numGlyphs:J,writingMode:oe}=K;if(oe!==h.bm.vertical||te||re===h.bm.horizontal||(te=!0),re=oe,(K.hidden||oe===h.bm.vertical)&&!te){br(J,k);continue}te=!1;let ue=new h.P(K.tileAnchorX,K.tileAnchorY),de=a.elevationType==="road",be=!!P.elevation||de,{x:ve,y:Fe,z:pe}=P.projection.projectTilePoint(ue.x,ue.y,T.canonical),Ie=null;if(be){let it=de?a.getElevationFeatureForText(se):null;Ie={getElevation:v,elevation:P.elevation,elevationFeature:it};let[ut,xt,_t]=v(ue,P.elevation,it);ve+=ut,Fe+=xt,pe+=_t}let fe=[ve,Fe,pe,1];if(h.aD(fe,fe,t),!gc(fe,O)){br(J,k);continue}let Pe=fe[3],Ce=Qr(o.transform.getCameraToCenterDistance(P.projection),Pe),Re=h.bn(A,D,K),Ye=_?Re/Ce:Re*Ce,$e=Or(ve,Fe,pe,d);if($e[3]<=0){br(J,k);continue}let je={},Ue=h.am(a.layers[0].layout.get("text-max-angle")),at=Math.cos(Ue),ot=_?null:
8Ie,et=Yh(K,Ye,!1,y,t,d,m,a.glyphOffsetArray,q,k,N,$e,ue,je,G,ot,P.projection,T,_,at);te=et.useVertical,ot&&et.needsFlipping&&(je={}),(et.notEnoughRoom||te||et.needsFlipping&&Yh(K,Ye,!0,y,t,d,m,a.glyphOffsetArray,q,k,N,$e,ue,je,G,ot,P.projection,T,_,at).notEnoughRoom)&&br(J,k)}c?(a.text.dynamicLayoutVertexBuffer.updateData(k),N&&a.text.globeExtVertexBuffer&&a.text.globeExtVertexBuffer.updateData(N)):(a.icon.dynamicLayoutVertexBuffer.updateData(k),N&&a.icon.globeExtVertexBuffer&&a.icon.globeExtVertexBuffer.updateData(N))}function Iu(a,t,o,c,d,m,_,y,v,T,I,P,A,D,L,O,k){let{lineStartIndex:N,glyphStartIndex:q,segment:Z}=y,G=q+y.numGlyphs,re=N+y.lineLength,te=t.getoffsetX(q),se=t.getoffsetX(G-1),K=Eu(a*te,o,c,d,m,_,Z,N,re,v,T,I,P,A,!0,D,L,O,k);if(!K)return null;let J=Eu(a*se,o,c,d,m,_,Z,N,re,v,T,I,P,A,!0,D,L,O,k);return J?{first:K,last:J}:null}function Xh(a,t,o,c){return a===h.bm.horizontal&&Math.abs(c)>Math.abs(o)?{useVertical:!0}:a===h.bm.vertical?c>0?{needsFlipping:!0}:null:t!==0&&function(d,m){return d===0||Math.abs(m/d)>vn}(o,c)?t===1?{needsFlipping:!0}:null:o<0?{needsFlipping:!0}:null}function Yh(a,t,o,c,d,m,_,y,v,T,I,P,A,D,L,O,k,N,q,Z){let G=t/24,re=a.lineOffsetX*G,te=a.lineOffsetY*G,{lineStartIndex:se,glyphStartIndex:K,numGlyphs:J,segment:oe,writingMode:ue,flipState:de}=a,be=se+a.lineLength,ve=Fe=>{if(I){let[Pe,Ce,Re]=Fe.up,Ye=T.length;h.bo(I,Ye+0,Pe,Ce,Re),h.bo(I,Ye+1,Pe,Ce,Re),h.bo(I,Ye+2,Pe,Ce,Re),h.bo(I,Ye+3,Pe,Ce,Re)}let[pe,Ie,fe]=Fe.point;h.bp(T,pe,Ie,fe,Fe.angle)};if(J>1){let Fe=Iu(G,y,re,te,o,P,A,a,v,m,D,O,!1,k,N,q,Z);if(!Fe)return{notEnoughRoom:!0};if(c&&!o){let[pe,Ie,fe]=Fe.first.point,[Pe,Ce,Re]=Fe.last.point;[pe,Ie]=Or(pe,Ie,fe,_),[Pe,Ce]=Or(Pe,Ce,Re,_);let Ye=Xh(ue,de,(Pe-pe)*L,Ce-Ie);if(a.flipState=Ye&&Ye.needsFlipping?1:2,Ye)return Ye}ve(Fe.first);for(let pe=K+1;pe<K+J-1;pe++){let Ie=Eu(G*y.getoffsetX(pe),re,te,o,P,A,oe,se,be,v,m,D,O,!1,!1,k,N,q,Z);if(!Ie)return T.length-=4*(pe-K),{notEnoughRoom:!0};ve(Ie)}ve(Fe.last)}else{if(c&&!o){let pe=Or(A.x,A.y,0,d),Ie=se+oe+1,fe=new h.P(v.getx(Ie),v.gety(Ie)),Pe=Or(fe.x,fe.y,0,d),Ce=Pe[3]>0?Pe:Jh(A,fe,pe,1,d,void 0,k,N.canonical),Re=Xh(ue,de,(Ce[0]-pe[0])*L,Ce[1]-pe[1]);if(a.flipState=Re&&Re.needsFlipping?1:2,Re)return Re}let Fe=Eu(G*y.getoffsetX(K),re,te,o,P,A,oe,se,be,v,m,D,O,!1,!1,k,N,q,Z);if(!Fe)return{notEnoughRoom:!0};ve(Fe)}return{}}function xc(a,t,o,c,d){let{x:m,y:_,z:y}=c.projectTilePoint(a.x,a.y,t);if(!d)return Or(m,_,y,o);let[v,T,I]=d.getElevation(a,d.elevation,d.elevationFeature);return Or(m+v,_+T,y+I,o)}function Jh(a,t,o,c,d,m,_,y){let v=xc(a.sub(t)._unit()._add(a),y,d,_,m);return h.aw(v,o,v),h.ax(v,v),h.bi(v,o,v,c)}function Eu(a,t,o,c,d,m,_,y,v,T,I,P,A,D,L,O,k,N,q){let Z=c?a-t:a+t,G=Z>0?1:-1,re=0;c&&(G*=-1,re=Math.PI),G<0&&(re+=Math.PI);let te=y+_+(G>0?0:1)|0,se=d,K=d,J=0,oe=0,ue=Math.abs(Z),de=[],be=[],ve=m,Fe=ve,pe=h.bg([]),Ie=()=>Jh(Fe,ve,K,ue-J+1,I,A,O,k.canonical);for(;J+oe<=ue;){if(te+=G,te<y||te>=v)return null;if(K=se,Fe=ve,de.push(K),D&&be.push(Fe),ve=new h.P(T.getx(te),T.gety(te)),se=P[te],!se){let ot=xc(ve,k.canonical,I,O,A);se=ot[3]>0?P[te]=ot:Ie()}J+=oe;let Ue=h.aw([],se,K),at=h.bh(K,se);if(o&&at>0&&oe>0&&h.bk(pe,Ue)/(oe*at)<q)return null;oe=at,pe=Ue}L&&A&&(P[te]&&(se=Ie(),oe=h.bh(K,se),pe=h.aw([],se,K)),P[te]=se);let fe=(ue-J)/oe,Pe=ve.sub(Fe)._mult(fe)._add(Fe),Ce=h.bi([],K,pe,fe),Re=[0,0,1],Ye=pe[0],$e=pe[1];if(N&&(Re=O.upVector(k.canonical,Pe.x,Pe.y),Re[0]!==0||Re[1]!==0||Re[2]!==1)){let Ue=[Re[2],0,-Re[0]],at=h.bj([],Re,Ue);h.ax(Ue,Ue),h.ax(at,at),Ye=h.bk(pe,Ue),$e=h.bk(pe,at)}if(o){let Ue=h.bj([],Re,pe);h.ax(Ue,Ue),h.bi(Ce,Ce,Ue,o*G)}let je=re+Math.atan2($e,Ye);return de.push(Ce),D&&be.push(Pe),{point:Ce,angle:je,path:de,tilePath:be,up:Re}}function br(a,t){let o=t.length,c=o+4*a;t.resize(c),t.float32.fill(-1/0,4*o,4*c)}function uf(a,t,o){let c=t[0],d=t[1];return a[0]=o[0]*c+o[4]*d+o[12],a[1]=o[1]*c+o[5]*d+o[13],a[3]=o[3]*c+o[7]*d+o[15],a}let eo=100;class ur{constructor(t,o,c=new h.bq(t.width+200,t.height+200,25),d=new h.bq(t.width+200,t.height+200,25)){this.transform=t,this.grid=c,this.ignoredGrid=d,this.pitchfactor=Math.cos(t._pitch)*t.cameraToCenterDistance,this.screenRightBoundary=t.width+eo,this.screenBottomBoundary=t.height+eo,this.gridRightBoundary=t.width+200,this.gridBottomBoundary=t.height+200,this.fogState=o,this.clippedSymbol
8s=new Map}clearClippedSymbolsForBucket(t){this.clippedSymbols.delete(t)}markSymbolAsClipped(t,o){let c=this.clippedSymbols.get(t);c||(c=new Set,this.clippedSymbols.set(t,c)),c.add(o)}placeCollisionBox(t,o,c,d,m,_,y,v,T,I,P){let A=c.projectedAnchorX,D=c.projectedAnchorY,L=c.projectedAnchorZ,O=c.tileAnchorX,k=c.tileAnchorY,N=c.elevation,q=c.tileID,Z=t.getProjection();if(N&&q){let[be,ve,Fe]=Z.upVector(q.canonical,c.tileAnchorX,c.tileAnchorY),pe=Z.upVectorScale(q.canonical,this.transform.center.lat,this.transform.worldSize).metersToTile;A+=be*N*pe,D+=ve*N*pe,L+=Fe*N*pe}let G=t.projection.name==="globe",re=t.projection.name==="globe"?h.ai(this.transform.zoom):0;if(q&&G&&re<1&&!_){let be=1<<q.canonical.z,ve=h.br(O,k);h.bs(ve,ve,1/h.ak),h.bt(ve,ve,h.br(q.canonical.x,q.canonical.y)),h.bs(ve,ve,1/be),h.bu(ve,ve,h.br(d[0],d[1])),ve[0]=h.bv(ve[0],-.5,.5),h.bs(ve,ve,h.ak);let Fe=h.bw(ve[0],ve[1],h.ak/(2*Math.PI),1);h.aD(Fe,Fe,m),A=h.aj(A,Fe[0],re),D=h.aj(D,Fe[1],re),L=h.aj(L,Fe[2],re)}let te=this.projectAndGetPerspectiveRatio(I,A,D,L,c.tileID,Z.name==="globe"||!!N||this.transform.pitch>0,Z),se=T*te.perspectiveRatio,K=(c.x1*o+y.x-c.padding)*se+te.point.x,J=(c.y1*o+y.y-c.padding)*se+te.point.y,oe=(c.x2*o+y.x+c.padding)*se+te.point.x,ue=(c.y2*o+y.y+c.padding)*se+te.point.y,de=te.perspectiveRatio<=.55||te.occluded;return!this.isInsideGrid(K,J,oe,ue)||!v&&this.grid.hitTest(K,J,oe,ue,P)||de?{box:[],offscreen:!1,occluded:te.occluded}:{box:[K,J,oe,ue],offscreen:this.isOffscreen(K,J,oe,ue),occluded:!1}}placeCollisionCircles(t,o,c,d,m,_,y,v,T,I,P,A,D,L,O,k){let N=[],q=this.transform.elevation,Z=t.getProjection(),G=t.elevationType==="road",re=!!q||G,te=h.bx.getAtTileOffsetFunc(k,this.transform.center.lat,this.transform.worldSize,Z),se=new h.P(c.tileAnchorX,c.tileAnchorY),K=new h.P(c.tileAnchorX,c.tileAnchorY),{x:J,y:oe,z:ue}=Z.projectTilePoint(K.x,K.y,k.canonical),de=null;if(re){let at=G?t.getElevationFeatureForText(d):null;de={getElevation:te,elevation:q,elevationFeature:at};let[ot,et,it]=te(se,q,at);J+=ot,oe+=et,ue+=it}let be=Z.name==="globe",ve=this.projectAndGetPerspectiveRatio(v,J,oe,ue,k,be||!!q||this.transform.pitch>0,Z),{perspectiveRatio:Fe}=ve,pe=(A?y/Fe:y*Fe)/h.bC,Ie=Or(J,oe,ue,T),fe=c.lineOffsetX*pe,Pe=c.lineOffsetY*pe,Ce=h.am(t.layers[0].layout.get("text-max-angle")),Re=Math.cos(Ce),Ye=ve.signedDistanceFromCamera>0?Iu(pe,_,fe,Pe,G&&c.flipState===1,Ie,K,c,m,T,{},re&&!A?de:null,A&&re,Z,k,A,Re):null,$e=!1,je=!1,Ue=!0;if(Ye&&!ve.occluded){let at=.5*L*Fe+O,ot=new h.P(-100,-100),et=new h.P(this.screenRightBoundary,this.screenBottomBoundary),it=new cl,{first:ut,last:xt}=Ye,_t=ut.path.length,Tt=[];for(let bt=_t-1;bt>=1;bt--)Tt.push(ut.path[bt]);for(let bt=1;bt<xt.path.length;bt++)Tt.push(xt.path[bt]);let yt=2.5*at;I&&(Tt=Tt.map(([bt,Nt,$t],bi)=>(re&&!be&&($t=te(bi<_t-1?ut.tilePath[_t-1-bi]:xt.tilePath[bi-_t+2],q,de.elevationFeature)[2]),Or(bt,Nt,$t,I))),Tt.some(bt=>bt[3]<=0)&&(Tt=[]));let Ft=[];if(Tt.length>0){let bt=1/0,Nt=-1/0,$t=1/0,bi=-1/0;for(let ai of Tt)bt=Math.min(bt,ai[0]),$t=Math.min($t,ai[1]),Nt=Math.max(Nt,ai[0]),bi=Math.max(bi,ai[1]);Nt>=ot.x&&bt<=et.x&&bi>=ot.y&&$t<=et.y&&(Ft=[Tt.map(ai=>new h.P(ai[0],ai[1]))],(bt<ot.x||Nt>et.x||$t<ot.y||bi>et.y)&&(Ft=h.by(Ft,ot.x,ot.y,et.x,et.y)))}for(let bt of Ft){it.reset(bt,.25*at);let Nt=0;Nt=it.length<=.5*at?1:Math.ceil(it.paddedLength/yt)+1;for(let $t=0;$t<Nt;$t++){let bi=$t/Math.max(Nt-1,1),ai=it.lerp(bi),Zt=ai.x+eo,It=ai.y+eo;N.push(Zt,It,at,0);let Et=Zt-at,li=It-at,Di=Zt+at,Qt=It+at;if(Ue=Ue&&this.isOffscreen(Et,li,Di,Qt),je=je||this.isInsideGrid(Et,li,Di,Qt),!o&&this.grid.hitTestCircle(Zt,It,at,D)&&($e=!0,!P))return{circles:[],offscreen:!1,collisionDetected:$e,occluded:!1}}}}return{circles:!P&&$e||!je?[]:N,offscreen:Ue,collisionDetected:$e,occluded:ve.occluded}}queryRenderedSymbols(t){if(t.length===0||this.grid.keysLength()===0&&this.ignoredGrid.keysLength()===0)return{};let o=[],c=1/0,d=1/0,m=-1/0,_=-1/0;for(let I of t){let P=new h.P(I.x+eo,I.y+eo);c=Math.min(c,P.x),d=Math.min(d,P.y),m=Math.max(m,P.x),_=Math.max(_,P.y),o.push(P)}let y=this.grid.query(c,d,m,_).concat(this.ignoredGrid.query(c,d,m,_)),v={},T={};for(let I of y){let P=I.key;if(v[P.bucketInstanceId]===void 0&&(v[P.bucketInstanceId]={}),v[P.bucketInstanceId][P.featureIndex])continue;
8let A=this.clippedSymbols.get(P.bucketInstanceId);if(A&&A.has(P.featureIndex))continue;let D=[new h.P(I.x1,I.y1),new h.P(I.x2,I.y1),new h.P(I.x2,I.y2),new h.P(I.x1,I.y2)];h.bz(o,D)&&(v[P.bucketInstanceId][P.featureIndex]=!0,T[P.bucketInstanceId]===void 0&&(T[P.bucketInstanceId]=[]),T[P.bucketInstanceId].push(P.featureIndex))}return T}insertCollisionBox(t,o,c,d,m){(o?this.ignoredGrid:this.grid).insert({bucketInstanceId:c,featureIndex:d,collisionGroupID:m},t[0],t[1],t[2],t[3])}insertCollisionCircles(t,o,c,d,m){let _=o?this.ignoredGrid:this.grid,y={bucketInstanceId:c,featureIndex:d,collisionGroupID:m};for(let v=0;v<t.length;v+=4)_.insertCircle(y,t[v],t[v+1],t[v+2])}projectAndGetPerspectiveRatio(t,o,c,d,m,_,y){let v=[o,c,d,1],T=!1;d||this.transform.pitch>0?(h.aD(v,v,t),this.fogState&&m&&y.name!=="globe"&&(T=function(A,D,L,O,k,N){let q=N.calculateFogTileMatrix(k),Z=[D,L,O];return h.ae(Z,Z,q),il(A,h.af(Z),N.pitch)}(this.fogState,o,c,d,m.toUnwrapped(),this.transform)>.9)):uf(v,v,t);let I=v[3];return{point:new h.P((v[0]/I+1)/2*this.transform.width+eo,(-v[1]/I+1)/2*this.transform.height+eo),perspectiveRatio:Math.min(.5+this.transform.getCameraToCenterDistance(y)/I*.5,1.5),signedDistanceFromCamera:I,occluded:_&&v[2]>I||T}}isOffscreen(t,o,c,d){return c<eo||t>=this.screenRightBoundary||d<eo||o>this.screenBottomBoundary}isInsideGrid(t,o,c,d){return c>=0&&t<this.gridRightBoundary&&d>=0&&o<this.gridBottomBoundary}getViewportMatrix(){let t=h.bA([]);return h.bB(t,t,[-100,-100,0]),t}}class hf{constructor(t,o,c,d){this.opacity=t?Math.max(0,Math.min(1,t.opacity+(t.placed?o:-o))):d&&c?1:0,this.placed=c}isHidden(){return this.opacity===0&&!this.placed}}class Is{constructor(t,o,c,d,m,_=!1){this.text=new hf(t?t.text:null,o,c,m),this.icon=new hf(t?t.icon:null,o,d,m),this.clipped=_}isHidden(){return this.text.isHidden()&&this.icon.isHidden()}}class vc{constructor(t,o,c,d=!1){this.text=t,this.icon=o,this.skipFade=c,this.clipped=d}}class bc{constructor(){this.invProjMatrix=h.bd(),this.viewportMatrix=h.bd(),this.circles=[]}}class F_{constructor(t,o,c,d,m){this.bucketInstanceId=t,this.featureIndex=o,this.sourceLayerIndex=c,this.bucketIndex=d,this.tileID=m}}class B_{constructor(t){this.crossSourceCollisions=t,this.maxGroupID=0,this.collisionGroups={}}get(t){if(this.crossSourceCollisions)return{ID:0,predicate:null};if(!this.collisionGroups[t]){let o=++this.maxGroupID;this.collisionGroups[t]={ID:o,predicate:c=>c.collisionGroupID===o}}return this.collisionGroups[t]}}function ul(a,t,o,c,d){let{horizontalAlign:m,verticalAlign:_}=h.bJ(a),y=-(m-.5)*t,v=-(_-.5)*o,T=h.bK(a,c);return new h.P(y+T[0]*d,v+T[1]*d)}function ba(a,t,o,c,d){let m=new h.P(a,t);return o&&m._rotate(c?d:-d),m}class k_{constructor(t,o,c,d,m,_){this.transform=t.clone(),this.projection=t.projection.name,this.collisionIndex=new ur(this.transform,m),this.buildingIndex=_,this.frontCutoffStart=0,this.placements={},this.opacities={},this.variableOffsets={},this.stale=!1,this.commitTime=0,this.fadeDuration=o,this.retainedQueryData={},this.collisionGroups=new B_(c),this.collisionCircleArrays={},this.prevPlacement=d,d&&(d.prevPlacement=void 0),this.placedOrientations={},this.lastReplacementSourceUpdateTime=0}getBucketParts(t,o,c,d,m=1){let _=c.getBucket(o),y=c.latestFeatureIndex;if(!_||!y||o.fqid!==_.layerIds[0])return;let v=_.layers[0].layout,T=_.layers[0].paint,I=c.collisionBoxArray,P=Math.pow(2,this.transform.zoom-c.tileID.overscaledZ),A=c.tileSize/h.ak,D=c.tileID.toUnwrapped();this.transform.setProjection(_.projection);let L=(O=c.tileID,k=_.getProjection(),N=this.transform,k.name===this.projection?N.calculateProjMatrix(O.toUnwrapped()):xr(N,k,O));var O,k,N;let q=v.get("text-pitch-alignment")==="map",Z=v.get("text-rotation-alignment")==="map";o.compileFilter(o.options);let G=o.dynamicFilter(),re=o.dynamicFilterNeedsFeature(),te=o.dynamicFilterNeedsGeometry(),se=this.transform.calculatePixelsToTileUnitsMatrix(c),K=xo(L,c.tileID.canonical,q,Z,this.transform,_.getProjection(),se),J=null,oe=_.getProjection().createInversionMatrix(this.transform,c.tileID.canonical);if(q){let Pe=sn(L,c.tileID.canonical,q,Z,this.transform,_.getProjection(),se);
8J=h.aC([],this.transform.labelPlaneMatrix,Pe)}let ue=null;G&&c.latestFeatureIndex&&(ue={unwrappedTileID:D,dynamicFilter:G,dynamicFilterNeedsFeature:re,needGeometry:te}),this.retainedQueryData[_.bucketInstanceId]=new F_(_.bucketInstanceId,y,_.sourceLayerIndex,_.index,c.tileID);let[de,be]=_.layers[0].layout.get("text-size-scale-range"),ve=h.aB(m,de,be),[Fe,pe]=v.get("icon-size-scale-range"),Ie=h.aB(m,Fe,pe),fe={bucket:_,layout:v,paint:T,posMatrix:L,invMatrix:oe,mercatorCenter:[h.aG(this.transform.center.lng),h.aJ(this.transform.center.lat)],textLabelPlaneMatrix:K,labelToScreenMatrix:J,clippingData:ue,scale:P,textPixelRatio:A,holdingForFade:c.holdingForFade(),collisionBoxArray:I,partiallyEvaluatedTextSize:h.bl(_.textSizeData,this.transform.zoom,ve),partiallyEvaluatedIconSize:h.bl(_.iconSizeData,this.transform.zoom,Ie),collisionGroup:this.collisionGroups.get(_.sourceID),latestFeatureIndex:c.latestFeatureIndex};if(d)for(let Pe of _.sortKeyRanges){let{sortKey:Ce,symbolInstanceStart:Re,symbolInstanceEnd:Ye}=Pe;t.push({sortKey:Ce,symbolInstanceStart:Re,symbolInstanceEnd:Ye,parameters:fe})}else t.push({symbolInstanceStart:0,symbolInstanceEnd:_.symbolInstances.length,parameters:fe})}attemptAnchorPlacement(t,o,c,d,m,_,y,v,T,I,P,A,D,L,O,k,N,q,Z,G,re){let{textOffset0:te,textOffset1:se,crossTileID:K}=O,J=[te,se],oe=ul(t,_,y,J,v),ue=this.collisionIndex.placeCollisionBox(N,v,o,c,d,m,ba(oe.x,oe.y,T,I,this.transform.angle),L,P,A,D.predicate);if(Z){let de=N.getSymbolInstanceIconSize(re,this.transform.zoom,O.placedIconSymbolIndex);if(this.collisionIndex.placeCollisionBox(N,de,Z,c,d,m,ba(oe.x,oe.y,T,I,this.transform.angle),L,P,A,D.predicate).box.length===0)return}if(ue.box.length>0){let de;return this.prevPlacement&&this.prevPlacement.variableOffsets[K]&&this.prevPlacement.placements[K]&&this.prevPlacement.placements[K].text&&(de=this.prevPlacement.variableOffsets[K].anchor),this.variableOffsets[K]={textOffset:J,width:_,height:y,anchor:t,textScale:v,prevAnchor:de},this.markUsedJustification(N,t,O,q),N.allowVerticalPlacement&&(this.markUsedOrientation(N,q,O),this.placedOrientations[K]=q),{shift:oe,placedGlyphBoxes:ue}}}placeLayerBucketPart(t,o,c,d,m=1){let{bucket:_,layout:y,paint:v,posMatrix:T,textLabelPlaneMatrix:I,labelToScreenMatrix:P,clippingData:A,textPixelRatio:D,mercatorCenter:L,invMatrix:O,holdingForFade:k,collisionBoxArray:N,partiallyEvaluatedTextSize:q,partiallyEvaluatedIconSize:Z,collisionGroup:G,latestFeatureIndex:re}=t.parameters,te=y.get("text-optional"),se=y.get("icon-optional"),K=y.get("text-allow-overlap"),J=y.get("icon-allow-overlap"),oe=y.get("text-rotation-alignment")==="map",ue=y.get("icon-rotation-alignment")==="map",de=y.get("text-pitch-alignment")==="map",be=v.get("symbol-z-offset"),ve=y.get("symbol-elevation-reference")==="sea",Fe=y.get("symbol-placement"),[pe,Ie]=y.get("text-size-scale-range"),[fe,Pe]=y.get("icon-size-scale-range"),Ce=h.aB(m,pe,Ie),Re=h.aB(m,fe,Pe),Ye=y.get("text-variable-anchor"),$e=oe&&Fe!=="point",je=ue&&Fe!=="point",Ue=Ye&&_.hasTextData(),at=_.hasIconTextFit()&&Ue&&_.hasIconData();this.transform.setProjection(_.projection);let ot=Ue||$e,et=je||at,it=K&&(J||!_.hasIconData()||se),ut=J&&(K||!_.hasTextData()||te),xt=!be.isConstant();!_.collisionArrays&&N&&_.deserializeCollisionBoxes(N),c&&d&&_.updateCollisionDebugBuffers(this.transform.zoom,N,Ce,Re);let _t=(yt,Ft,bt)=>{let{crossTileID:Nt,numVerticalGlyphVertices:$t}=yt,bi=null;if(A&&A.dynamicFilterNeedsFeature||xt){let Ii=this.retainedQueryData[_.bucketInstanceId],ei=re.loadFeature({featureIndex:yt.featureIndex,bucketIndex:Ii.bucketIndex,sourceLayerIndex:Ii.sourceLayerIndex,layoutVertexArrayOffset:0}),oi=ei.properties?ei.properties.worldview:null;if(_.localizable&&_.worldview&&typeof oi=="string")if(oi==="all")ei.properties.$localized=!0;else{if(!oi.split(",").includes(_.worldview))return;ei.properties.$localized=!0,ei.properties.worldview=_.worldview}bi=A&&A.needGeometry?h.bH(ei,!0):ei}if(A&&!(0,A.dynamicFilter)({zoom:this.transform.zoom,pitch:this.transform.pitch,worldview:_.worldview},bi,this.retainedQueryData[_.bucketInstanceId].tileID.canonical,new h.P(yt.tileAnchorX,yt.tileAnchorY),this.transform.calculateDistanceTileData(A.unwrappedTileID)))return this.placements[Nt]=new vc(!1,!1,!1,!0),void o.add(Nt);let ai=be.evaluate(bi,{});if((yt.zOffset||0)+(ai||0)>
80&&this.frontCutoffStart>0){let Ii=2*this.frontCutoffStart-1,ei=[yt.tileAnchorX,yt.tileAnchorY,0,1],oi=h.aD(h.bI(),ei,T);if(oi[1]/oi[3]<Ii)return this.placements[Nt]=new vc(!1,!1,!1,!0),void o.add(Nt)}if(o.has(Nt))return;if(k)return void(this.placements[Nt]=new vc(!1,!1,!1));let Zt=!1,It=!1,Et=!0,li=!1,Di=!1,Qt=null,vt={box:null,offscreen:null,occluded:null},yi={box:null},fi=null,ki=null,Bt=null,Yi=0,Nn=0,fn=0;bt.textFeatureIndex?Yi=bt.textFeatureIndex:yt.useRuntimeCollisionCircles&&(Yi=yt.featureIndex),bt.verticalTextFeatureIndex&&(Nn=bt.verticalTextFeatureIndex);let An=_.elevationFeatures?_.elevationFeatures[yt.elevationFeatureIndex]:void 0,cn=Ii=>{Ii.tileID=this.retainedQueryData[_.bucketInstanceId].tileID;let ei=this.transform.elevation;Ii.elevation=ve?ai:ai+h.bx.getAtTileOffset(Ii.tileID,new h.P(Ii.tileAnchorX,Ii.tileAnchorY),ei,An),Ii.elevation+=yt.zOffset},sr=bt.textBox;if(sr){cn(sr);let Ii=oi=>{let Ji=h.bm.horizontal;if(_.allowVerticalPlacement&&!oi&&this.prevPlacement){let bn=this.prevPlacement.placedOrientations[Nt];bn&&(this.placedOrientations[Nt]=bn,Ji=bn,this.markUsedOrientation(_,Ji,yt))}return Ji},ei=(oi,Ji)=>{if(_.allowVerticalPlacement&&$t>0&&bt.verticalTextBox){for(let bn of _.writingModes)if(bn===h.bm.vertical?(vt=Ji(),yi=vt):vt=oi(),vt&&vt.box&&vt.box.length)break}else vt=oi()};if(Ye){let oi=Ye;if(this.prevPlacement&&this.prevPlacement.variableOffsets[Nt]){let Fi=this.prevPlacement.variableOffsets[Nt];oi.indexOf(Fi.anchor)>0&&(oi=oi.filter(wn=>wn!==Fi.anchor),oi.unshift(Fi.anchor))}let Ji=(Fi,wn,$r)=>{let ar=_.getSymbolInstanceTextSize(q,yt,this.transform.zoom,Ft),oo=(Fi.x2-Fi.x1)*ar+2*Fi.padding,as=(Fi.y2-Fi.y1)*ar+2*Fi.padding,ls=yt.hasIconTextFit&&!J?wn:null;ls&&cn(ls);let To={box:[],offscreen:!1,occluded:!1},Kc=K?2*oi.length:oi.length;for(let qs=0;qs<Kc;++qs){let Va=this.attemptAnchorPlacement(oi[qs%oi.length],Fi,L,O,ot,oo,as,ar,oe,de,D,T,G,qs>=oi.length,yt,Ft,_,$r,ls,q,Z);if(Va&&(To=Va.placedGlyphBoxes,To&&To.box&&To.box.length)){Zt=!0,Qt=Va.shift;break}}return To};ei(()=>Ji(sr,bt.iconBox,h.bm.horizontal),()=>{let Fi=bt.verticalTextBox;return Fi&&cn(Fi),_.allowVerticalPlacement&&!(vt&&vt.box&&vt.box.length)&&$t>0&&Fi?Ji(Fi,bt.verticalIconBox,h.bm.vertical):{box:null,offscreen:null,occluded:null}}),vt&&(Zt=vt.box,Et=vt.offscreen,li=vt.occluded);let bn=Ii(!(!vt||!vt.box));if(!Zt&&this.prevPlacement){let Fi=this.prevPlacement.variableOffsets[Nt];Fi&&(this.variableOffsets[Nt]=Fi,this.markUsedJustification(_,Fi.anchor,yt,bn))}}else{let oi=(Ji,bn)=>{let Fi=_.getSymbolInstanceTextSize(q,yt,this.transform.zoom,Ft),wn=this.collisionIndex.placeCollisionBox(_,Fi,Ji,L,O,ot,new h.P(0,0),K,D,T,G.predicate);return wn&&wn.box&&wn.box.length&&(this.markUsedOrientation(_,bn,yt),this.placedOrientations[Nt]=bn),wn};ei(()=>oi(sr,h.bm.horizontal),()=>{let Ji=bt.verticalTextBox;return _.allowVerticalPlacement&&$t>0&&Ji?(cn(Ji),oi(Ji,h.bm.vertical)):{box:null,offscreen:null,occluded:null}}),Ii(!!(vt&&vt.box&&vt.box.length))}}if(fi=vt,Zt=fi&&fi.box&&fi.box.length>0,Et=fi&&fi.offscreen,li=fi&&fi.occluded,yt.useRuntimeCollisionCircles){let Ii=yt.centerJustifiedTextSymbolIndex>=0?yt.centerJustifiedTextSymbolIndex:yt.verticalPlacedTextSymbolIndex,ei=_.text.placedSymbolArray.get(Ii),oi=h.bn(_.textSizeData,q,ei),Ji=y.get("text-padding");ki=this.collisionIndex.placeCollisionCircles(_,K,ei,Ii,_.lineVertexArray,_.glyphOffsetArray,oi,T,I,P,c,de,G.predicate,yt.collisionCircleDiameter*oi/h.bC,Ji,this.retainedQueryData[_.bucketInstanceId].tileID),Zt=K||ki.circles.length>0&&!ki.collisionDetected,Et=Et&&ki.offscreen,li=ki.occluded}if(bt.iconFeatureIndex&&(fn=bt.iconFeatureIndex),bt.iconBox){let Ii=ei=>{cn(ei);let oi=yt.hasIconTextFit&&Qt?ba(Qt.x,Qt.y,oe,de,this.transform.angle):new h.P(0,0),Ji=_.getSymbolInstanceIconSize(Z,this.transform.zoom,yt.placedIconSymbolIndex);return this.collisionIndex.placeCollisionBox(_,Ji,ei,L,O,et,oi,J,D,T,G.predicate)};yi&&yi.box&&yi.box.length&&bt.verticalIconBox?(Bt=Ii(bt.verticalIconBox),It=Bt.box.length>0):(Bt=Ii(bt.iconBox),It=Bt.box.length>0),Et=Et&&Bt.offscreen,Di=Bt.occluded}let Kn=te||yt.numHorizontalGlyphVertices===0&&$t===0,Ri=se||yt.numIconVertices===0;if(Kn||Ri?Ri?Kn||(It=It&&Zt):Zt=It&&Zt:It=Zt=It&&Zt,Zt&&fi&&fi.box&&this.collisionIndex.insertCollisionBox(fi.box,y.get("text-ignore-placement"),_.bucketInstanceId,yi&&yi.box&&Nn?Nn:Yi,G.ID),It&&Bt&&this.collisionIndex.insertCollisionBox(Bt.box,y.get("icon-ignore-placement"),_.bucketInstanceId,fn,G.ID),ki&&(Zt&&this.collisionIndex.insertCollisionCircles(ki.circles,y.get("text-ignore-placement"),_.bucketInstanceId,Yi,G.ID),c)){let Ii=_.bucketInstanceId,ei=this.collisionCircleArrays[Ii];ei===void 0&&(ei=this.collisionCircleArrays[Ii]=new bc);for(let oi=0;oi<ki.circles.length;oi+=4)ei.circles.push(ki.circles[oi+0]),ei.circles.push(ki.circles[oi+1]),ei.circles.push(ki.circles[oi+2]),ei.circles.push(ki.collisionDetected?1:0)}let Ni=_.projection.name!=="globe";it=it&&(Ni||!li),ut=ut&&(Ni||!Di),this.placements[Nt]=new vc(Zt||it,It||ut,Et||_.justReloaded),o.add(Nt)},Tt=this.retainedQueryData[_.bucketInstanceId].tileID;if(_.elevationType==="offset"&&this.buildingIndex&&this.buildingIndex.updateZOffset(_,Tt),_.elevationType==="road"&&_.updateRoadElevation(Tt.canonical),_.updateZOffset(),_.sortFeaturesByY){let yt=_.getSortedSymbolIndexe
8s(this.transform.angle);for(let Ft=yt.length-1;Ft>=0;--Ft){let bt=yt[Ft];_t(_.symbolInstances.get(bt),bt,_.collisionArrays[bt])}_.hasAnyZOffset&&h.w(`${_.layerIds[0]} layer symbol-z-elevate: symbols are not sorted by elevation if symbol-z-order is evaluated to viewport-y`)}else if(_.hasAnyZOffset){let yt=_.getSortedIndexesByZOffset();for(let Ft=0;Ft<yt.length;++Ft){let bt=yt[Ft];_t(_.symbolInstances.get(bt),bt,_.collisionArrays[bt])}}else for(let yt=t.symbolInstanceStart;yt<t.symbolInstanceEnd;yt++)_t(_.symbolInstances.get(yt),yt,_.collisionArrays[yt]);if(c&&_.bucketInstanceId in this.collisionCircleArrays){let yt=this.collisionCircleArrays[_.bucketInstanceId];h.ba(yt.invProjMatrix,T),yt.viewportMatrix=this.collisionIndex.getViewportMatrix()}_.justReloaded=!1}markUsedJustification(t,o,c,d){let{leftJustifiedTextSymbolIndex:m,centerJustifiedTextSymbolIndex:_,rightJustifiedTextSymbolIndex:y,verticalPlacedTextSymbolIndex:v,crossTileID:T}=c,I=h.bL(o),P=d===h.bm.vertical?v:I==="left"?m:I==="center"?_:I==="right"?y:-1;m>=0&&(t.text.placedSymbolArray.get(m).crossTileID=P>=0&&m!==P?0:T),_>=0&&(t.text.placedSymbolArray.get(_).crossTileID=P>=0&&_!==P?0:T),y>=0&&(t.text.placedSymbolArray.get(y).crossTileID=P>=0&&y!==P?0:T),v>=0&&(t.text.placedSymbolArray.get(v).crossTileID=P>=0&&v!==P?0:T)}markUsedOrientation(t,o,c){let d=o===h.bm.horizontal||o===h.bm.horizontalOnly?o:0,m=o===h.bm.vertical?o:0,{leftJustifiedTextSymbolIndex:_,centerJustifiedTextSymbolIndex:y,rightJustifiedTextSymbolIndex:v,verticalPlacedTextSymbolIndex:T}=c,I=t.text.placedSymbolArray;_>=0&&(I.get(_).placedOrientation=d),y>=0&&(I.get(y).placedOrientation=d),v>=0&&(I.get(v).placedOrientation=d),T>=0&&(I.get(T).placedOrientation=m)}commit(t){this.commitTime=t,this.zoomAtLastRecencyCheck=this.transform.zoom;let o=this.prevPlacement,c=!1;this.prevZoomAdjustment=o?o.zoomAdjustment(this.transform.zoom):0;let d=o?o.symbolFadeChange(t):1,m=o?o.opacities:{},_=o?o.variableOffsets:{},y=o?o.placedOrientations:{};for(let v in this.placements){let T=this.placements[v],I=m[v];I?(this.opacities[v]=new Is(I,d,T.text,T.icon,null,T.clipped),c=c||T.text!==I.text.placed||T.icon!==I.icon.placed):(this.opacities[v]=new Is(null,d,T.text,T.icon,T.skipFade,T.clipped),c=c||T.text||T.icon)}for(let v in m){let T=m[v];if(!this.opacities[v]){let I=new Is(T,d,!1,!1);I.isHidden()||(this.opacities[v]=I,c=c||T.text.placed||T.icon.placed)}}for(let v in _)this.variableOffsets[v]||!this.opacities[v]||this.opacities[v].isHidden()||(this.variableOffsets[v]=_[v]);for(let v in y)this.placedOrientations[v]||!this.opacities[v]||this.opacities[v].isHidden()||(this.placedOrientations[v]=y[v]);c?this.lastPlacementChangeTime=t:typeof this.lastPlacementChangeTime!="number"&&(this.lastPlacementChangeTime=o?o.lastPlacementChangeTime:t)}updateLayerOpacities(t,o,c,d){d&&(this.lastReplacementSourceUpdateTime=d.updateTime);let m=new Set;for(let _ of o){let y=_.getBucket(t);y&&_.latestFeatureIndex&&t.fqid===y.layerIds[0]&&(this.updateBucketOpacities(y,m,_,_.collisionBoxArray,c,d,_.tileID,t.scope),y.elevationType==="offset"&&this.buildingIndex&&this.buildingIndex.updateZOffset(y,_.tileID),y.elevationType==="road"&&y.updateRoadElevation(_.tileID.canonical),y.updateZOffset())}}updateBucketOpacities(t,o,c,d,m,_,y,v){t.hasTextData()&&t.text.opacityVertexArray.clear(),t.hasIconData()&&t.icon.opacityVertexArray.clear(),t.hasIconCollisionBoxData()&&t.iconCollisionBox.collisionVertexArray.clear(),t.hasTextCollisionBoxData()&&t.textCollisionBox.collisionVertexArray.clear();let T=t.layers[0].layout,I=t.layers[0].paint,P=!!t.layers[0].dynamicFilter(),A=new Is(null,0,!1,!1,!0),D=T.get("text-allow-overlap"),L=T.get("icon-allow-overlap"),O=T.get("text-variable-anchor"),k=T.get("text-rotation-alignment")==="map",N=T.get("text-pitch-alignment")==="map",q=I.get("symbol-z-offset"),Z=T.get("symbol-elevation-reference")==="sea",G=!q.isConstant(),re=new Is(null,0,D&&(L||!t.hasIconData()||T.get("icon-optional")),L&&(D||!t.hasTextData()||T.get("text-optional")),!0);!t.collisionArrays&&d&&(t.hasIconCollisionBoxData()||t.hasTextCollisionBoxData())&&t.deserializeCollisionBoxes(d);let te=(K,J,oe)=>{for(let ue=0;ue<J/4;ue++)K.opacityVertexArray.emplaceBack(oe)},se=0;_&&t.updateReplacement(y,_),this.collisionIndex.clearClippedSymbol
8sForBucket(t.bucketInstanceId);for(let K=0;K<t.symbolInstances.length;K++){let J=t.symbolInstances.get(K),{numHorizontalGlyphVertices:oe,numVerticalGlyphVertices:ue,crossTileID:de,numIconVertices:be,tileAnchorX:ve,tileAnchorY:Fe}=J,pe=null,Ie=this.retainedQueryData[t.bucketInstanceId];G&&J&&Ie&&(pe=c.latestFeatureIndex.loadFeature({featureIndex:J.featureIndex,bucketIndex:Ie.bucketIndex,sourceLayerIndex:Ie.sourceLayerIndex,layoutVertexArrayOffset:0}));let fe=q.evaluate(pe,{}),Pe=o.has(de),Ce=this.opacities[de];Pe?Ce=A:Ce||(Ce=re,this.opacities[de]=Ce),o.add(de);let Re=oe>0||ue>0,Ye=be>0,$e=this.placedOrientations[de],je=$e===h.bm.vertical,Ue=$e===h.bm.horizontal||$e===h.bm.horizontalOnly;!Re&&!Ye||Ce.isHidden()||se++;let at=!1;if((Re||Ye)&&_)for(let ot of t.activeReplacements){if(h.bD(ot,m,h.bE.Symbol,v)||ot.min.x>ve||ve>ot.max.x||ot.min.y>Fe||Fe>ot.max.y)continue;let et=h.bF(ve,Fe,y.canonical,ot.footprintTileId.canonical);if(at=h.bG(et,ot.footprint),at)break}if(at&&this.collisionIndex.markSymbolAsClipped(t.bucketInstanceId,J.featureIndex),Re){let ot=at?wa:pf(Ce.text);te(t.text,oe,je?wa:ot),te(t.text,ue,Ue?wa:ot);let et=Ce.text.isHidden(),{leftJustifiedTextSymbolIndex:it,centerJustifiedTextSymbolIndex:ut,rightJustifiedTextSymbolIndex:xt,verticalPlacedTextSymbolIndex:_t}=J,Tt=t.text.placedSymbolArray,yt=et||je?1:0;it>=0&&(Tt.get(it).hidden=yt),ut>=0&&(Tt.get(ut).hidden=yt),xt>=0&&(Tt.get(xt).hidden=yt),_t>=0&&(Tt.get(_t).hidden=et||Ue?1:0);let Ft=this.variableOffsets[de];Ft&&this.markUsedJustification(t,Ft.anchor,J,$e);let bt=this.placedOrientations[de];bt&&(this.markUsedJustification(t,"left",J,bt),this.markUsedOrientation(t,bt,J))}if(Ye){let ot=at?wa:pf(Ce.icon),{placedIconSymbolIndex:et,verticalPlacedIconSymbolIndex:it}=J,ut=t.icon.placedSymbolArray,xt=Ce.icon.isHidden()?1:0;et>=0&&(te(t.icon,be,je?wa:ot),ut.get(et).hidden=xt),it>=0&&(te(t.icon,J.numVerticalIconVertices,Ue?wa:ot),ut.get(it).hidden=xt)}if(t.hasIconCollisionBoxData()||t.hasTextCollisionBoxData()){let ot=t.collisionArrays[K];if(ot){let et=new h.P(0,0),it=!0;if(ot.textBox||ot.verticalTextBox){if(O){let xt=this.variableOffsets[de];xt?(et=ul(xt.anchor,xt.width,xt.height,xt.textOffset,xt.textScale),k&&et._rotate(N?this.transform.angle:-this.transform.angle)):it=!1}P&&(it=!Ce.clipped),ot.textBox&&Au(t.textCollisionBox.collisionVertexArray,Ce.text.placed,!it||je,fe,Z,et.x,et.y),ot.verticalTextBox&&Au(t.textCollisionBox.collisionVertexArray,Ce.text.placed,!it||Ue,fe,Z,et.x,et.y)}let ut=it&&!!(!Ue&&ot.verticalIconBox);ot.iconBox&&Au(t.iconCollisionBox.collisionVertexArray,Ce.icon.placed,ut,fe,Z,J.hasIconTextFit?et.x:0,J.hasIconTextFit?et.y:0),ot.verticalIconBox&&Au(t.iconCollisionBox.collisionVertexArray,Ce.icon.placed,!ut,fe,Z,J.hasIconTextFit?et.x:0,J.hasIconTextFit?et.y:0)}}}if(t.fullyClipped=se===0,t.sortFeatures(this.transform.angle),this.retainedQueryData[t.bucketInstanceId]&&(this.retainedQueryData[t.bucketInstanceId].featureSortOrder=t.featureSortOrder),t.hasTextData()&&t.text.opacityVertexBuffer&&t.text.opacityVertexBuffer.updateData(t.text.opacityVertexArray),t.hasIconData()&&t.icon.opacityVertexBuffer&&t.icon.opacityVertexBuffer.updateData(t.icon.opacityVertexArray),t.hasIconCollisionBoxData()&&t.iconCollisionBox.collisionVertexBuffer&&t.iconCollisionBox.collisionVertexBuffer.updateData(t.iconCollisionBox.collisionVertexArray),t.hasTextCollisionBoxData()&&t.textCollisionBox.collisionVertexBuffer&&t.textCollisionBox.collisionVertexBuffer.updateData(t.textCollisionBox.collisionVertexArray),t.bucketInstanceId in this.collisionCircleArrays){let K=this.collisionCircleArrays[t.bucketInstanceId];t.placementInvProjMatrix=K.invProjMatrix,t.placementViewportMatrix=K.viewportMatrix,t.collisionCircleArray=K.circles,delete this.collisionCircleArrays[t.bucketInstanceId]}}symbolFadeChange(t){return this.fadeDuration===0?1:(t-this.commitTime)/this.fadeDuration+this.prevZoomAdjustment}zoomAdjustment(t){return Math.max(0,(this.transform.zoom-t)/1.5)}hasTransitions(t){return t-this.lastPlacementChangeTime<this.fadeDuration}stillRecent(t,o){let c=this.zoomAtLastRecencyCheck===o?1-this.zoomAdjustment(o):1;return this.zoomAtLastRecencyCheck=o,this.commitTime+this.fadeDuration*c>t}isStale(){return this.stale}setStale(){this.stale=!0}}function Au(a,t,o,c,d,m,_){a.emplaceBack(t?1:0,o?1:0,m||0,_||0,c,d?1:0),a.emplaceBack(t?1:0,o?1:0,m||0,_||0,c,d?1:0),a.emplaceBack(t?1:0,o?1:0,m||0,_||0,c,d?1:0),a.emplaceBack(t?1:0,o?1:0,m||0,_||0,c,d?1:0)}let hl=Math.pow(2,25),df=Math.pow(2,24),Mu=Math.pow(2,17),Kh=Math.pow(2,16),Es=Math.pow(2,9),N_=Math.pow(2,8),U_=Math.pow(2,1);function pf(a){if(a.opacity===0&&!a.placed)return 0;if(a.opacity===1&&a.placed)return 4294967295;let t=a.placed?1:0,o=Math.floor(127*a.opacity);return o*hl+t*df+o*Mu+t*Kh+o*Es+t*N_+o*U_+t}let wa=0;class V_{constructor(t){this._sortAcrossTiles=t.layout.get("symbol-z-order")!=="viewport-y"&&t.layout.get("symbol-sort-key").constantOr(1)!==void 0,this._currentTileIndex=0,this._currentPartIndex=0,this._seenCrossTileIDs=new Set,this._bucketParts=[]}continuePlacement(t,o,c,d,m,_){let y=this._bucketParts;for(;this._currentTileIndex<t.length;)if(o.getBucketParts(y,d,t[this._currentTileIndex],this._sortAcrossTiles,_),this._currentTileIndex++,m())return!0;for(this._sortAcrossTiles&&(this._sortAcrossTiles=!1,y.sort((v,T)=>
8v.sortKey-T.sortKey));this._currentPartIndex<y.length;){let v=y[this._currentPartIndex];if(o.placeLayerBucketPart(v,this._seenCrossTileIDs,c,v.symbolInstanceStart===0,_),this._currentPartIndex++,m())return!0}return!1}}class Cu{startNewPlacement(t,o,c,d,m,_,y,v){return this.placement=new k_(t,d,m,_,y,v),this._currentPlacementIndex=o.length-1,this._forceFullPlacement=!1,this._showCollisionBoxes=c,this._fadeDuration=d,this._done=!1,this._inProgressLayer=null,this}requestFullPlacement(){this._forceFullPlacement=!0}isFullPlacementRequested(){return this._forceFullPlacement}setStale(){this.placement&&(this.placement.stale=!0)}isStale(){return!!this.placement&&this.placement.stale}isDone(){return this._done}continuePlacement(t,o,c,d,m){let _=h.o.now(),y=()=>{let v=h.o.now()-_;return!this.isFullPlacementRequested()&&this._fadeDuration!==0&&v>2};for(;this._currentPlacementIndex>=0;){let v=o[t[this._currentPlacementIndex]],T=this.placement.collisionIndex.transform.zoom;if(v.type==="symbol"&&v.visibility!=="none"&&(!v.minzoom||v.minzoom<=T)&&(!v.maxzoom||v.maxzoom>T)){let I=v,P=I.layout.get("symbol-z-elevate"),A=I.layout.get("symbol-sort-key").constantOr(1)!==void 0,D=I.layout.get("symbol-z-order"),L=D==="viewport-y"||D==="auto"&&!(D!=="viewport-y"&&A),O=I.layout.get("text-allow-overlap")||I.layout.get("icon-allow-overlap")||I.layout.get("text-ignore-placement")||I.layout.get("icon-ignore-placement"),k=L&&O,N=this._inProgressLayer=this._inProgressLayer||new V_(I),q=h.t(v.source,v.scope);if(N.continuePlacement(P||k?d[q]:c[q],this.placement,this._showCollisionBoxes,v,y,m))return;delete this._inProgressLayer}this._currentPlacementIndex--}this._forceFullPlacement=!1,this._done=!0}commit(t){return this.placement.commit(t),this.placement}}let Pu=512/h.ak/2;class ff{constructor(t,o,c){this.tileID=t,this.bucketInstanceId=c,this.index=new h.bM(o.length,16,Int32Array),this.keys=[],this.crossTileIDs=[];let d=t.canonical.x*h.ak,m=t.canonical.y*h.ak;for(let _=0;_<o.length;_++){let{key:y,crossTileID:v,tileAnchorX:T,tileAnchorY:I}=o.get(_),P=Math.floor((d+T)*Pu),A=Math.floor((m+I)*Pu);this.index.add(P,A),this.keys.push(y),this.crossTileIDs.push(v)}this.index.finish()}findMatches(t,o,c){let d=this.tileID.canonical.z<o.canonical.z?1:Math.pow(2,this.tileID.canonical.z-o.canonical.z),m=Pu/Math.pow(2,o.canonical.z-this.tileID.canonical.z),_=o.canonical.x*h.ak,y=o.canonical.y*h.ak;for(let v=0;v<t.length;v++){let T=t.get(v);if(T.crossTileID)continue;let{key:I,tileAnchorX:P,tileAnchorY:A}=T,D=Math.floor((_+P)*m),L=Math.floor((y+A)*m),O=this.index.range(D-d,L-d,D+d,L+d).sort((k,N)=>k-N);for(let k of O){let N=this.crossTileIDs[k];if(this.keys[k]===I&&!c.has(N)){c.add(N),T.crossTileID=N;break}}}}}class mf{constructor(){this.maxCrossTileID=0}generate(){return++this.maxCrossTileID}}class _f{constructor(){this.indexes={},this.usedCrossTileIDs={},this.lng=0}handleWrapJump(t){let o=Math.round((t-this.lng)/360);if(o!==0)for(let c in this.indexes){let d=this.indexes[c],m={};for(let _ in d){let y=d[_];y.tileID=y.tileID.unwrapTo(y.tileID.wrap+o),m[y.tileID.key]=y}this.indexes[c]=m}this.lng=t}addBucket(t,o,c){if(this.indexes[t.overscaledZ]&&this.indexes[t.overscaledZ][t.key]){if(this.indexes[t.overscaledZ][t.key].bucketInstanceId===o.bucketInstanceId)return!1;this.removeBucketCrossTileIDs(t.overscaledZ,this.indexes[t.overscaledZ][t.key])}for(let m=0;m<o.symbolInstances.length;m++)o.symbolInstances.get(m).crossTileID=0;this.usedCrossTileIDs[t.overscaledZ]||(this.usedCrossTileIDs[t.overscaledZ]=new Set);let d=this.usedCrossTileIDs[t.overscaledZ];for(let m in this.indexes){let _=this.indexes[m];if(Number(m)>t.overscaledZ)for(let y in _){let v=_[y];v.tileID.isChildOf(t)&&v.findMatches(o.symbolInstances,t,d)}else{let y=_[t.scaledTo(Number(m)).key];y&&y.findMatches(o.symbolInstances,t,d)}}for(let m=0;m<o.symbolInstances.length;m++){let _=o.symbolInstances.get(m);_.crossTileID||(_.crossTileID=c.generate(),d.add(_.crossTileID))}return this.indexes[t.overscaledZ]===void 0&&(this.indexes[t.overscaledZ]={}),this.indexes[t.overscaledZ][t.key]=new ff(t,o.symbolInstances,o.bucketInstanceId),!0}removeBucketCrossTileIDs(t,o){for(let c of o.crossTileIDs)this.usedCrossTileIDs[t].delete(c)}removeStaleBuckets(t){let o=!1;for(let c in this.indexes){let d=this.indexes[c];for(let m in d)t[d[m].bucketInstanceId]||(this.removeBucketCrossTileIDs(c,d[m]),delete d[m],o=!0)}return o}}class Ta{constructor(){this.layerIndexes={},this.crossTileIDs=new mf,this.maxBucketInstanceId=0,this.bucketsInCurrentPlacement={}}addLayer(t,o,c,d){let m=this.layerIndexes[t.fqid];m===void 0&&(m=this.layerIndexes[t.fqid]=new _f);let _=!1,y={};d.name!=="globe"&&m.handleWrapJump(c);for(let v of o){let T=v.getBucket(t);T&&t.fqid===T.layerIds[0]&&(T.bucketInstanceId||(T.bucketInstanceId=++this.maxBucketInstanceId),m.addBucket(v.tileID,T,this.crossTileIDs)&&(_=!0),y[T.bucketInstanceId]=!0)}return m.removeStaleBuckets(y)&&(_=!0),_}pruneUnusedLayers(t){let o={};t.forEach(c=>{o[c]=!0});for(let c in this.layerIndexes)o[c]||delete this.layerIndexes[c]}}let Sa=770,As=771;class mt{constructor(t,o,c,d){this.blendFunction=t,this.blendColor=o.toNonPremultipliedRenderColor(null),this.mask=c,this.blendEquation=d}}mt.Replace=[1,0,1,0],mt.disabled=new mt(mt.Replace,h.C.transparent,[!1,!1,!1,!1]),mt.unblended=new mt(mt.Replace,h.C.transparent,[!0,!0,!0,!0]),mt.alphaBlended=new mt([1,As,1,As],h.C.transparent,[!0,!0,!0,!0]),mt.alphaBlendedNonPremultiplied=new mt([Sa,As,Sa,As],h.C.transparent,[!0,!0,!0,!0]),mt.multiply=new mt([774,0,774,0],h.C.transparent,[!0,!0,!0,!0]),mt.multiplyAccumulateAlpha=new mt([774,0,1,As],h.C.transparent,[!0,!0,!0,!0]),mt.additive=new mt([1,1,1,1],h.C.transparent,[!0,!0,!0,!0]),mt.additiveAlphaWeighted=new mt([Sa,1,773,1],h.C.transparent,[!0,!0,!0,!0]),mt.additiveAlphaWeightedUnboundedAlpha=new mt([Sa,1,1,1],h.C.transparent,[!0,!0,!0,!0]);
8class nt{constructor(t,o,c){this.func=t,this.mask=o,this.range=c}}nt.ReadOnly=!1,nt.ReadWrite=!0,nt.disabled=new nt(519,nt.ReadOnly,[0,1]);let Ia=7680;class gt{constructor(t,o,c,d,m,_){this.test=t,this.ref=o,this.mask=c,this.fail=d,this.depthFail=m,this.pass=_}}gt.disabled=new gt({func:519,mask:0},0,0,Ia,Ia,Ia);let wc=1029,wr=2305;class dt{constructor(t,o,c){this.enable=t,this.mode=o,this.frontFace=c}}function Xe(a,t){let o=h.bS(a,3);h.bV(a,t),h.b_(a,3,o)}function Du(a,t){let o=h.bP([]);return h.bQ(o,o,-t),h.bR(o,o,-a),o}function Qh(a,t){let o=[a[0],a[1],0],c=[t[0],t[1],0];if(h.af(o)>=1e-15){let _=h.ax([],o);h.bN(c,_,h.bk(c,_)),t[0]=c[0],t[1]=c[1]}let d=h.bj([],t,a);if(h.bO(d)<1e-15)return null;let m=Math.atan2(-d[1],d[0]);return Du(Math.atan2(Math.sqrt(a[0]*a[0]+a[1]*a[1]),-a[2]),m)}dt.disabled=new dt(!1,wc,wr),dt.backCCW=new dt(!0,wc,wr),dt.backCW=new dt(!0,wc,2304),dt.frontCW=new dt(!0,1028,2304),dt.frontCCW=new dt(!0,1028,wr);class Tc{constructor(t,o){this.position=t,this.orientation=o}get position(){return this._position}set position(t){if(t){let o=t instanceof h.ad?t:new h.ad(t[0],t[1],t[2]);
8this._renderWorldCopies&&(o.x=h.bv(o.x,0,1)),this._position=o}else this._position=null}lookAtPoint(t,o,c){if(this.orientation=null,!this.position)return;let d=this.position,m=c||(this._elevation?this._elevation.getAtPointOrZero(h.ad.fromLngLat(t)):0),_=h.ad.fromLngLat(t,m),y=[_.x-d.x,_.y-d.y,_.z-d.z];o||(o=[0,0,1]),o[2]=Math.abs(o[2]),this.orientation=Qh(y,o)}setPitchBearing(t,o){this.orientation=Du(h.am(t),h.am(-o))}}class to{constructor(t,o){this._transform=h.bA([]),this.orientation=o,this.position=t}get mercatorPosition(){let t=this.position;return new h.ad(t[0],t[1],t[2])}get position(){let t=h.bS(this._transform,3);return[t[0],t[1],t[2]]}set position(t){var o;t&&h.b_(this._transform,3,[(o=t)[0],o[1],o[2],1])}get orientation(){return this._orientation}set orientation(t){this._orientation=t||h.bP([]),t&&Xe(this._transform,this._orientation)}getPitchBearing(){let t=this.forward(),o=this.right();return{bearing:Math.atan2(-o[1],o[0]),pitch:Math.atan2(Math.sqrt(t[0]*t[0]+t[1]*t[1]),-t[2])}}setPitchBearing(t,o){this._orientation=Du(t,o),Xe(this._transform,this._orientation)}forward(){let t=h.bS(this._transform,2);return[-t[0],-t[1],-t[2]]}up(){let t=h.bS(this._transform,1);return[-t[0],-t[1],-t[2]]}right(){let t=h.bS(this._transform,0);return[t[0],t[1],t[2]]}getCameraToWorld(t,o){let c=new Float64Array(16);return h.ba(c,this.getWorldToCamera(t,o)),c}getCameraToWorldMercator(){return this._transform}getWorldToCameraPosition(t,o,c){let d=this.position;h.bN(d,d,-t);let m=new Float64Array(16);return h.bT(m,[c,c,c]),h.bB(m,m,d),m[10]*=o,m}getWorldToCamera(t,o){let c=new Float64Array(16),d=new Float64Array(4),m=this.position;return h.bU(d,this._orientation),h.bN(m,m,-t),h.bV(c,d),h.bB(c,c,m),c[1]*=-1,c[5]*=-1,c[9]*=-1,c[13]*=-1,c[8]*=o,c[9]*=o,c[10]*=o,c[11]*=o,c}getCameraToClipPerspective(t,o,c,d){let m=new Float64Array(16);return h.bW(m,t,o,c,d),m}getCameraToClipOrthographic(t,o,c,d,m,_){let y=new Float64Array(16);return h.bX(y,t,o,c,d,m,_),y}getDistanceToElevation(t,o=!1){let c=t===0?0:h.bY(t,o?h.bZ(this.position[1]):this.position[1]),d=this.forward();return(c-this.position[2])/d[2]}clone(){return new to([...this.position],[...this.orientation])}}let ed=(a,t)=>({u_matrix:a,u_ground_shadow_factor:t});class Jo{constructor(t=0,o=0,c=0,d=0){if(isNaN(t)||t<0||isNaN(o)||o<0||isNaN(c)||c<0||isNaN(d)||d<0)throw new Error("Invalid value for edge-insets, top, bottom, left and right must all be numbers");this.top=t,this.bottom=o,this.left=c,this.right=d}interpolate(t,o,c){return o.top!=null&&t.top!=null&&(this.top=h.aj(t.top,o.top,c)),o.bottom!=null&&t.bottom!=null&&(this.bottom=h.aj(t.bottom,o.bottom,c)),o.left!=null&&t.left!=null&&(this.left=h.aj(t.left,o.left,c)),o.right!=null&&t.right!=null&&(this.right=h.aj(t.right,o.right,c)),this}getCenter(t,o){let c=h.aB((this.left+t-this.right)/2,0,t),d=h.aB((this.top+o-this.bottom)/2,0,o);return new h.P(c,d)}equals(t){return this.top===t.top&&this.bottom===t.bottom&&this.left===t.left&&this.right===t.right}clone(){return new Jo(this.top,this.bottom,this.left,this.right)}toJSON(){return{top:this.top,bottom:this.bottom,left:this.left,right:this.right}}}let Po=15;class Ms{constructor(t,o,c,d,m,_,y){this.tileSize=512,this._renderWorldCopies=m===void 0||m,this._minZoom=t||0,this._maxZoom=o||22,this._minPitch=c??0,this._maxPitch=d??60,this.setProjection(_),this.setMaxBounds(y),this.width=0,this.height=0,this._center=new h.aX(0,0),this.zoom=0,this.angle=0,this._fov=.6435011087932844,this._pitch=0,this._nearZ=0,this._farZ=0,this._nearClipOffset=0,this._unmodified=!0,this._edgeInsets=new Jo,this._projMatrixCache={},this._alignedProjMatrixCache={},this._fogTileMatrixCache={},this._expandedProjMatrixCache={},this._distanceTileDataCache={},this._camera=new to,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,this.mercatorMatrix=new Float64Array(16),this.mercatorFogMatrix=new Float32Array(16),this.invProjMatrix=new Float64Array(16),this._expandedFarZProjMatrixBuf=new Float64Array(16),this.expandedFarZProjMatrix=this._expandedFarZProjMatrixBuf,this.starsProjMatrix=new Float32Array(16),this.skyboxMatrix=new Float32Array(16),this._mat4Scratch=new Float64Array(16),this.alignedProjMatrix=new Float64Array(16),this.labelPlaneMatr
8ix=new Float32Array(16),this.glCoordMatrix=new Float32Array(16),this.pixelMatrix=new Float64Array(16),this.pixelMatrixInverse=new Float64Array(16)}clone(){let t=new Ms(this._minZoom,this._maxZoom,this._minPitch,this.maxPitch,this._renderWorldCopies,this.getProjection(),this.maxBounds);return t._elevation=this._elevation,t._centerAltitude=this._centerAltitude,t._centerAltitudeValidForExaggeration=this._centerAltitudeValidForExaggeration,t.tileSize=this.tileSize,t.mercatorFromTransition=this.mercatorFromTransition,t.width=this.width,t.height=this.height,t.cameraElevationReference=this.cameraElevationReference,t._center=this._center,t._setZoom(this.zoom),t._seaLevelZoom=this._seaLevelZoom,t.angle=this.angle,t._fov=this._fov,t._pitch=this._pitch,t._nearZ=this._nearZ,t._farZ=this._farZ,t._nearClipOffset=this._nearClipOffset,t._averageElevation=this._averageElevation,t._orthographicProjectionAtLowPitch=this._orthographicProjectionAtLowPitch,t._unmodified=this._unmodified,t._edgeInsets=this._edgeInsets.clone(),t._camera=this._camera.clone(),t._calcMatrices(),t.freezeTileCoverage=this.freezeTileCoverage,t.frustumCorners=this.frustumCorners,t._allowWorldUnderZoom=this._allowWorldUnderZoom,t}get isOrthographic(){return this.projection.name!=="globe"&&this._orthographicProjectionAtLowPitch&&this.pitch<Po}get elevation(){return this._elevation}set elevation(t){this._elevation!==t&&(this._elevation=t,this._updateCameraOnTerrain(),this._calcMatrices())}get nearClipOffset(){return this._nearClipOffset}set nearClipOffset(t){this._nearClipOffset=t,this._calcMatrices()}get depthOcclusionForSymbolsAndCircles(){return this.projection.name!=="globe"&&!this.isOrthographic}updateElevation(t,o=!1){let c=this._elevation&&this._elevation.exaggeration()!==this._centerAltitudeValidForE
8xaggeration;(this._seaLevelZoom==null||c)&&this._updateCameraOnTerrain(),(t||c)&&this._constrainCamera(o),this._calcMatrices()}getProjection(){return h.aK(this.projection,["name","center","parallels"])}setProjection(t){this.projectionOptions=t||{name:"mercator"};let o=this.projection?this.getProjection():void 0;this.projection=h.c4(this.projectionOptions);let c=this.getProjection(),d=!h.b9(o,c);return d&&this._calcMatrices(),this.mercatorFromTransition=!1,d}setOrthographicProjectionAtLowPitch(t){return this._orthographicProjectionAtLowPitch!==t&&(this._orthographicProjectionAtLowPitch=t,this._calcMatrices(),!0)}setMercatorFromTransition(){let t=this.projection.name;this.mercatorFromTransition=!0,this.projectionOptions={name:"mercator"},this.projection=h.c4({name:"mercator"});let o=t!==this.projection.name;return o&&this._calcMatrices(),o}get minZoom(){return this._minZoom}set minZoom(t){this._minZoom!==t&&(this._minZoom=t,this.zoom=Math.max(this.zoom,t))}get maxZoom(){return this._maxZoom}set maxZoom(t){this._maxZoom!==t&&(this._maxZoom=t,this.zoom=Math.min(this.zoom,t))}get minPitch(){return this._minPitch}set minPitch(t){this._minPitch!==t&&(this._minPitch=t,this.pitch=Math.max(this.pitch,t))}get maxPitch(){return this._maxPitch}set maxPitch(t){this._maxPitch!==t&&(this._maxPitch=t,this.pitch=Math.min(this.pitch,t))}get renderWorldCopies(){return this._renderWorldCopies&&this.projection.supportsWorldCopies===!0}set renderWorldCopies(t){t===void 0?t=!0:t===null&&(t=!1),this._renderWorldCopies=t}get worldSize(){return this.tileSize*this.scale}get cameraWorldSizeForFog(){let t=Math.max(this._camera.getDistanceToElevation(this._averageElevation),Number.EPSILON);return this._worldSizeFromZoom(this._zoomFromMercatorZ(t))}get cameraWorldSize(){let t=Math.max(this._camera.getDistanceToElevation(this._averageElevation,!0),Number.EPSILON);return this._worldSizeFromZoom(this._zoomFromMercatorZ(t))}get pixelsPerMeter(){return this.projection.pixelsPerMeter(this.center.lat,this.worldSize)}get cameraPixelsPerMeter(){return h.bY(1,this.center.lat)*this.cameraWorldSizeForFog}get centerOffset(){return this.centerPoint._sub(this.size._div(2))}get size(){return new h.P(this.width,this.height)}get bearing(){return h.bv(this.rotation,-180,180)}set bearing(t){this.rotation=t}get rotation(){return-this.angle/Math.PI*180}set rotation(t){let o=-t*Math.PI/180;if(this.angle===o)return;this._unmodified=!1,this.angle=o,this._calcMatrices();let c=Math.sin(this.angle),d=Math.cos(this.angle);this.rotationMatrix=[d,c,-c,d]}get pitch(){return this._pitch/Math.PI*180}set pitch(t){let o=h.aB(t,this.minPitch,this.maxPitch)/180*Math.PI;this._pitch!==o&&(this._unmodified=!1,this._pitch=o,this._calcMatrices())}get aspect(){return this.width/this.height}get fov(){return this._fov/Math.PI*180}set fov(t){t=Math.max(.01,Math.min(60,t)),this._fov!==t&&(this._unmodified=!1,this._fov=h.am(t),this._calcMatrices())}get fovX(){return this._fov}get fovY(){let t=1/Math.tan(.5*this.fovX);return 2*Math.atan(1/this.aspect/t)}get averageElevation(){return this._averageElevation}set averageElevation(t){this._averageElevation=t,this._calcFogMatrices(),this._distanceTileDataCache={}}get zoom(){return this._zoom}set zoom(t){let o=Math.min(Math.max(t,this.minZoom),this.maxZoom);this._zoom!==o&&(this._unmodified=!1,this._setZoom(o),this._updateSeaLevelZoom(),this._constrain(),this._calcMatrices())}_setZoom(t){this._zoom=t,this.scale=this.zoomScale(t),this.tileZoom=Math.floor(t),this.zoomFraction=t-this.tileZoom}get tileCoverLift(){return this._tileCoverLift}set tileCoverLift(t){this._tileCoverLift!==t&&(this._tileCoverLift=t)}_updateCameraOnTerrain(){let t=this.elevation?this.elevation.getAtPoint(this.locationCoordinate(this.center),Number.NEGATIVE_INFINITY):Number.NEGATIVE_INFINITY,o=this.elevation&&t===Number.NEGATIVE_INFINITY&&this.elevation.visibleDemTiles.length>0&&this.elevation.exaggeration()>
80&&this._centerAltitudeValidForExaggeration;if(!this._elevation||t===Number.NEGATIVE_INFINITY&&(!o||!this._centerAltitude))return this._centerAltitude=0,this._seaLevelZoom=null,void(this._centerAltitudeValidForExaggeration=void 0);let c=this._elevation;o||this._centerAltitude&&this._centerAltitudeValidForExaggeration&&c.exaggeration()&&this._centerAltitudeValidForExaggeration!==c.exaggeration()?(this._centerAltitude=this._centerAltitude/this._centerAltitudeValidForExaggeration*c.exaggeration(),this._centerAltitudeValidForExaggeration=c.exaggeration()):(this._centerAltitude=t||0,this._centerAltitudeValidForExaggeration=c.exaggeration()),this._updateSeaLevelZoom()}_updateSeaLevelZoom(){if(this._centerAltitudeValidForExaggeration===void 0)return;let t=Math.max(0,(this.pixelsPerMeter*this._centerAltitude+this.cameraToCenterDistance)/this.worldSize);this._seaLevelZoom=this._zoomFromMercatorZ(t)}sampleAverageElevation(){if(!this._elevation)return 0;let t=this._elevation,o=[[.5,.2],[.3,.5],[.5,.5],[.7,.5],[.5,.8]],c=this.horizonLineFromTop(),d=0,m=0;for(let _=0;_<o.length;_++){let y=new h.P(o[_][0]*this.width,c+o[_][1]*(this.height-c)),v=t.pointCoordinate(y);if(!v)continue;let T=1/Math.hypot(v[0]-this._camera.position[0],v[1]-this._camera.position[1]);d+=v[3]*T,m+=T}return m===0?NaN:d/m}get center(){return this._center}set center(t){t.lat===this._center.lat&&t.lng===this._center.lng||(this._unmodified=!1,this._center=t,this._terrainEnabled()&&(this.cameraElevationReference==="ground"?this._updateCameraOnTerrain():this._updateZoomFromElevation()),this._constrain(),this._calcMatrices())}_updateZoomFromElevation(){if(this._seaLevelZoom==null||!this._elevation)return;let t=this._seaLevelZoom,o=this._elevation.getAtPointOrZero(this.locationCoordinate(this.center)),c=this.pixelsPerMeter/this.worldSize*o,d=this._mercatorZfromZoom(t),m=this._mercatorZfromZoom(this._maxZoom),_=Math.max(d-c,m);this._setZoom(this._zoomFromMercatorZ(_))}get padding(){return this._edgeInsets.toJSON()}set padding(t){this._edgeInsets.equals(t)||(this._unmodified=!1,this._edgeInsets.interpolate(this._edgeInsets,t,1),this._calcMatrices())}equals(t){let o=this.elevation,c=t.elevation,d=o!=null!=(c!=null)||o&&c&&o.exaggeration()!==c.exaggeration();return this.width===t.width&&this.height===t.height&&this.center.lng===t.center.lng&&this.center.lat===t.center.lat&&this.zoom===t.zoom&&this.bearing===t.bearing&&this.pitch===t.pitch&&this.fov===t.fov&&this.projection.name===t.projection.name&&this._edgeInsets.equals(t.padding)&&!d}computeZoomRelativeTo(t){let o=this.rayIntersectionCoordinate(this.pointRayIntersection(this.centerPoint,t.toAltitude())),c;c=t.z<this._camera.position[2]?[o.x,o.y,o.z]:[t.x,t.y,t.z];let d=h.af(h.aw([],this._camera.position,c));return h.aB(this._zoomFromMercatorZ(d),this._minZoom,this._maxZoom)}setFreeCameraOptions(t){if(!this.height||!t.position&&!t.orientation)return;this._updateCameraState();let o=!1;if(t.orientation&&!h.c5(t.orientation,this._camera.orientation)&&(o=this._setCameraOrientation(t.orientation)),t.position){let c=[t.position.x,t.position.y,t.position.z];h.c6(c,this._camera.position)||(this._setCameraPosition(c),o=!0)}o&&(this._updateStateFromCamera(),this.recenterOnTerrain())}getFreeCameraOptions(){this._updateCameraState();let t=this._camera.position,o=new Tc;return o.position=new h.ad(t[0],t[1],t[2]),o.orientation=this._camera.orientation,o._elevation=this.elevation,o._renderWorldCopies=this.renderWorldCopies,o}_setCameraOrientation(t){if(!h.c7(t))return!1;h.c8(t,t);let o=h.c9([],[0,0,-1],t),c=h.c9([],[0,-1,0],t);if(c[2]<0)return!1;let d=Qh(o,c);return!!d&&(this._camera.orientation=d,!0)}_setCameraPosition(t){let o=this.zoomScale(this.minZoom)*this.tileSize,c=this.zoomScale(this.maxZoom)*this.tileSize,d=this.cameraToCenterDistance;t[2]=h.aB(t[2],d/c,d/o),this._camera.position=t}get centerPoint(){return this._edgeInsets.getCenter(this.width,this.height)}get fovAboveCenter(){return this._fov*(.5+this.centerOffset.y/this.height)}isPaddingEqual(t){return this._edgeInsets.equals(t)}interpolatePadding(t,o,c){this._unmodified=!1,this._edgeInsets.interpolate(t,o,c),this._constrain(),this._calcMatrices()}coveringZoomLevel(t){let o=(t.roundZoom?Math.round:Math.floor)(this.zoom+this.scaleZoom(this.tileSize/t.tileSize));return Math.max(0,o)}getVisibleUnwrappedCoordinates(t){let o=[new h.ca(0,t)];if(this.renderWorldCopies){let c=this.pointCoordinate(new h.P(0,0)),d=this.pointCoordinate(new h.P(this.width,0)),m=this.pointCoordinate(new h.P(this.width,this.height)),_=this.pointCoordinate(new h.P(0,this.height)),y=Math.floor(Math.min(c.x,d.x,m.x,_.x)),v=Math.floor(Math.max(c.x,d.x,m.x,_.x)),T=1;for(let I=y-T;I<=v+T;I++)I!==0&&o.push(new h.ca(I,t))}return o}isLODDisabled(t){return(!t||this.pitch<=60)&&this._edgeInsets.top<=this._edgeInsets.bottom&&!this._elevation&&!this.projection.isReprojectedInTileSpace}extendTileCover(t,o,c,d){let m=[],_=c!=null,y=!_;if(y&&this.zoom<o||_&&c[0]===0&&c[1]===0)return m;let v=new Set,T=(P,A,D,L,O)=>{let k=h.cm(A,P,D,L,O);v.has(k)||(m.push(new h.aU(P,A,D,L,O)),v.add(k))};for(let P=0;P<t.length;P++){let A=t[P];if(y&&A.canonical.z!==o||_&&d!==void 0&&d>A.canonical.z)continue;let D=A.canonical,L=A.overscaledZ,O=A.wrap,k=1<<D.z,N=D.x+1<k,q=D.x>0,Z=D.y+1<k,G=D.y>0,re=A.wrap-(q?0:1),te=A.wrap+(N?0:1),se=q?D.x-1:k-1,K=N?D.x+1:0;if(_)c[0]<0?(T(L,te,D.z,K,D.y),c[1]<0&&Z&&(T(L,O,D.z,D.x,D.y+1),T(L,te,D.z,K,D.y+1)),c[1]>0&&G&&(T(L,O,D.z,D.x,D.y-1),T(L,te,D.z,K,D.y-1))):c[0]>0?(T(L,re,D.z,se,D.y),c[1]<0&&Z&&(T(L,O,D.z,D.x,D.y+1),T(L,re,D.z,se,D.y+1)),c[1]>0&&G&&(T(L,O,D.z,D.x,D.y-1),T(L,re,D.z,se,D.y-1))):c[1]<0&&Z?T(L,O,D.z,D.x,D.y+1):G&&T(L,O,D.z,D.x,D.y-1);else{let J=A.visibleQuadrants;1&J&&(T(L,re,D.z,se,D.y),G&&(T(L,O,D.z,D.x,D.y-1),T(L,re,D.z,se,D.y-1))),2&J&&(T(L,te,D.z,K,D.y),G&&(T(L,O,D.z,D.x,D.y-1),T(L,te,D.z,K,D.y-1))),4&J&&(T(L,re,D.z,se,D.y),Z&&(T(L,O,D.z,D.x,D.y+1),T(L,re,D.z,se,D.y+1))),8&J&&(T(L,te,D.z,K,D.y),Z&&(T(L,O,D.z,D.x,D.y+1),T(L,te,D.z,K,D.y+1)))}}let I=[];for(let P of m)m.some(A=>P.isChildOf(A))||I.push(P);if(m=I.filter(P=>!t.some(A=>!!(P.overscaledZ<o&&A.isChildOf(P))||P.equals(A)||P.isChildOf(A))),y){let P=1<<o,A=this.projection.name==="globe"?this._camera.mercatorPosition:this.pointCoordinate(this.getCameraPoint()),D=[P*A.x,P*A.y],L=4,O=L*L;m=m.filter(k=>{let N=k.canonical.x+.5-D[0],q=k.canonical.y+.5-D[1];return N*N+q*q<O})}return m}extendTileCoverToNearPlane(t,o,c){let d=[],m=new Set;for(let q of t)m.add(q.key);let _=(q,Z,G,re,te)=>{let se=h.cm(Z,q,G,re,te);m.has(se)||(d.push(new h.aU(q,Z,G,re,te)),m.add(se))},y=t.reduce((q,Z)=>
8Math.max(q,Z.overscaledZ),c),v=1<<c,T=[new h.P(0,0),new h.P(h.ak,0),new h.P(h.ak,h.ak),new h.P(0,h.ak)],I=new h.P(0,0),P=new h.P(0,0),A=(q,Z)=>{let G=Math.floor(q[0]),re=Math.floor(q[1]),te=(q[0]-G)*h.ak,se=(q[1]-re)*h.ak,K=Math.floor(Z[0]),J=Math.floor(Z[1]),oe=(Z[0]-K)*h.ak,ue=(Z[1]-J)*h.ak;for(let de=-1;de<=1;de++){let be=G+de;if(!(be<0||be>=v)){I.x=te-de*h.ak,P.x=oe-(be-K)*h.ak;for(let ve=-1;ve<=1;ve++){let Fe=re+ve;I.y=se-ve*h.ak,P.y=ue-(Fe-J)*h.ak,h.cM(I,P,T)&&_(y,0,c,be,Fe)}}}},D=o.points,L=D[h.cb],O=D[h.cc],k=this._projectToGround(L,D[h.cd]),N=this._projectToGround(O,D[h.ce]);return A(L,k),A(O,N),d}_projectToGround(t,o){return h.cf(h.cg(),t,o,t[2]/(t[2]-o[2]))}_projectToZ(t,o,c){let d=t[2]-o[2];return Math.abs(d)<1e-6?h.ch(t):h.cf(h.cg(),t,o,(t[2]-c)/d)}extendTileCoverForTunnels(t,o,c,d){if(c<18)return[];let m=o.points,_=m[h.ci],y=m[h.cj],v=m[h.ck],T=m[h.cl];if(v[2]>=0&&T[2]>=0||_[2]<=0||y[2]<=0)return[];let I=v[2]<0?this._projectToZ(_,v,0):v,P=T[2]<0?this._projectToZ(y,T,0):T,A=-d,D=v[2]<A?this._projectToZ(_,v,A):v,L=T[2]<A?this._projectToZ(y,T,A):T,O=this._findExtensionTilesInQuad(t,c,[L,D,P,I],[.5*(I[0]+P[0]),.5*(I[1]+P[1])]);return O.length>3&&(O.length=3),O}_findExtensionTilesInQuad(t,o,c,d){let m=[],_=new Set;for(let K of t)_.add(K.key);let y=t.reduce((K,J)=>Math.max(K,J.overscaledZ),o),v=1<<o,T=[new h.P(c[0][0],c[0][1]),new h.P(c[1][0],c[1][1]),new h.P(c[3][0],c[3][1]),new h.P(c[2][0],c[2][1]),new h.P(c[0][0],c[0][1])],I=c[0][0],P=c[1][0],A=c[2][0],D=c[3][0],L=c[0][1],O=c[1][1],k=c[2][1],N=c[3][1],q=Math.max(0,Math.floor(Math.min(I,P,A,D))),Z=Math.min(v-1,Math.ceil(Math.max(I,P,A,D))-1),G=Math.max(0,Math.floor(Math.min(L,O,k,N))),re=Math.min(v-1,Math.ceil(Math.max(L,O,k,N))-1);for(let K=G;K<=re;K++)for(let J=q;J<=Z;J++){if(!h.au(T,J,K,J+1,K+1))continue;let oe=h.cm(0,y,o,J,K);_.has(oe)||(m.push(new h.aU(y,0,o,J,K)),_.add(oe))}let te=d[0],se=d[1];return m.sort((K,J)=>{let oe=K.canonical.x+.5-te,ue=K.canonical.y+.5-se,de=J.canonical.x+.5-te,be=J.canonical.y+.5-se;return oe*oe+ue*ue-(de*de+be*be)||K.canonical.x-J.canonical.x||K.canonical.y-J.canonical.y}),m}coveringTiles(t){let o=this.coveringZoomLevel(t),c=o,d=this.elevation&&this.elevation.exaggeration(),m=d&&!t.isTerrainDEM,_=this.projection.name==="mercator";if(t.minzoom!==void 0&&o<t.minzoom)return[];t.maxzoom!==void 0&&o>t.maxzoom&&(o=t.maxzoom);let y=this.locationCoordinate(this.center),v=this.center.lat,T=1<<o,I=[T*y.x,T*y.y,0],P=this.projection.name==="globe",A=!P,D=h.cn.fromInvProjectionMatrix(this.invProjMatrix,this.worldSize,o,A),L=P?this._camera.mercatorPosition:this.pointCoordinate(this.getCameraPoint()),O=T*h.bY(1,this.center.lat),k=this._camera.position[2]/h.bY(1,this.center.lat),N=[T*L.x,T*L.y,k*(A?1:O)],q=P||d,Z=this.cameraToCenterDistance/t.tileSize*(t.roundZoom?1:.502),G=this.isLODDisabled(!0)?o:0,re;if(this._elevation&&t.isTerrainDEM)re=1e4*this._elevation.exaggeration();else if(this._elevation){let fe=this._elevation.getMinMaxForVisibleTiles();re=fe?fe.max:this._centerAltitude}else re=this._centerAltitude;let te=t.isTerrainDEM?-re:this._elevation?this._elevation.getMinElevationBelowMSL():0,se=this.projection.isReprojectedInTileSpace?h.co(this):1,K=fe=>{let Ce=new h.ad(fe.x+25e-6,fe.y,fe.z),Re=new h.ad(fe.x,fe.y+25e-6,fe.z),Ye=fe.toLngLat(),$e=Ce.toLngLat(),je=Re.toLngLat(),Ue=this.locationCoordinate(Ye),at=this.locationCoordinate($e),ot=this.locationCoordinate(je),et=Math.hypot(at.x-Ue.x,at.y-Ue.y),it=Math.hypot(ot.x-Ue.x,ot.y-Ue.y);return Math.sqrt(et*it)*se/25e-6},J=fe=>{let Pe=re,Ce=te;return{aabb:h.cr(this,T,0,0,0,fe,Ce,Pe,this.projection),zoom:0,x:0,y:0,minZ:Ce,maxZ:Pe,wrap:fe,fullyVisible:!1}},oe=[],ue=[],de=o,be=t.reparseOverscaled?c:o,ve=(k-this._centerAltitude)*O,Fe=fe=>{if(!this._elevation||!fe.tileID||!_)return;let Pe=this._elevation.getMinMaxForTile(fe.tileID),Ce=fe.aabb;Pe?(Ce.min[2]=Pe.min,Ce.max[2]=Pe.max,Ce.center[2]=(Ce.min[2]+Ce.max[2])/2):(fe.shouldSplit=Ie(fe),fe.shouldSplit||(Ce.min[2]=Ce.max[2]=Ce.center[2]=this._centerAltitude))},pe=(fe,Pe)=>{if(.707*Pe<fe)return 1;let Ce=Pe/fe;return Ce/(1.4144271570014144+(Math.pow(1.1,Ce-1.4144271570014144+1)-1)/(1.1-1)-1)},Ie=fe=>{if(fe.zoom<G)return!0;
8if(fe.zoom===de)return!1;if(fe.shouldSplit!=null)return fe.shouldSplit;let Pe=fe.aabb.distanceX(N),Ce=fe.aabb.distanceY(N),Re=ve,Ye=1;if(P){Re=fe.aabb.distanceZ(N);let it=Math.pow(2,fe.zoom),ut=h.bZ((fe.y+1)/it),xt=h.bZ(fe.y/it),_t=Math.min(Math.max(v,ut),xt),Tt=h.cQ(_t)/h.cQ(v);if(Ye=_t===v?1/Math.max(1,this._mercatorScaleRatio-.3):Math.min(1,Tt/this._mercatorScaleRatio),this.zoom<=h.cN&&fe.zoom===de-1&&Tt>=.9)return!0}else if(m&&(Re=fe.aabb.distanceZ(N)*O),this.projection.isReprojectedInTileSpace&&c<=5){let it=Math.pow(2,fe.zoom),ut=K(new h.ad((fe.x+.5)/it,(fe.y+.5)/it));Ye=ut>.85?1:ut}if(!_&&!P){let it=Math.sqrt(Pe*Pe+Ce*Ce+Re*Re),ut=(1<<de-fe.zoom)*Z*Ye;return ut*=pe(Math.max(Re,ve),it),it<ut}let $e=Number.MAX_VALUE,je=0,Ue=fe.aabb.getCorners(),at=[0,0,0];for(let it of Ue){h.aw(at,it,N),P||(m?at[2]*=O:at[2]=ve);let ut=h.bk(at,this._camera.forward());ut<$e&&($e=ut,je=Math.abs(at[2]))}let ot=(1<<de-fe.zoom)*Z*Ye;if(ot*=pe(Math.max(je,ve),$e),$e<ot)return!0;let et=fe.aabb.closestPoint(I);return et[0]===I[0]&&et[1]===I[1]};if(this.renderWorldCopies)for(let fe=1;fe<=3;fe++)oe.push(J(-fe)),oe.push(J(fe));for(oe.push(J(0));oe.length>0;){let fe=oe.pop(),Pe=fe.x,Ce=fe.y,Re=fe.fullyVisible,Ye=()=>this.projection.name==="globe"&&(fe.y===0||fe.y===(1<<fe.zoom)-1);if(!Re){let $e=q?fe.aabb.intersects(D):fe.aabb.intersectsFlat(D);if($e===0&&Ye()){let je=new h.cp(fe.zoom,Pe,Ce);$e=h.cq(this,T,je,!0).intersects(D)}if($e===0)continue;Re=$e===2}if(fe.zoom===de||!Ie(fe)){let $e=fe.zoom===de?be:fe.zoom;if(t.minzoom&&t.minzoom>$e)continue;let je=0;if(!Re){let et=q?fe.aabb.intersectsPrecise(D):fe.aabb.intersectsPreciseFlat(D);if(et===0&&Ye()){let it=new h.cp(fe.zoom,Pe,Ce);et=h.cq(this,T,it,!0).intersectsPrecise(D)}if(et===0)continue;if(t.calculateQuadrantVisibility)if(D.containsPoint(fe.aabb.center))je=15;else for(let it=0;it<4;it++)fe.aabb.quadrant(it).intersects(D)!==0&&(je|=1<<it)}let Ue=I[0]-(.5+Pe+(fe.wrap<<fe.zoom))*(1<<o-fe.zoom),at=I[1]-.5-Ce,ot=fe.tileID?fe.tileID:new h.aU($e,fe.wrap,fe.zoom,Pe,Ce);t.calculateQuadrantVisibility&&(ot.visibleQuadrants=je),ue.push({tileID:ot,distanceSq:Ue*Ue+at*at});continue}for(let $e=0;$e<4;$e++){let je=(Pe<<1)+$e%2,Ue=(Ce<<1)+($e>>1),at={aabb:_?fe.aabb.quadrant($e):h.cr(this,T,fe.zoom+1,je,Ue,fe.wrap,fe.minZ,fe.maxZ,this.projection),zoom:fe.zoom+1,x:je,y:Ue,wrap:fe.wrap,fullyVisible:Re,tileID:void 0,shouldSplit:void 0,minZ:fe.minZ,maxZ:fe.maxZ};m&&!P&&(at.tileID=new h.aU(fe.zoom+1===de?be:fe.zoom+1,fe.wrap,fe.zoom+1,je,Ue),Fe(at)),oe.push(at)}}if(this.fogCullDistSq){let fe=this.fogCullDistSq,Pe=this.horizonLineFromTop();ue=ue.filter(Ce=>{let Re=[0,0,0,1],Ye=[h.ak,h.ak,0,1],$e=this.calculateFogTileMatrix(Ce.tileID.toUnwrapped());h.aD(Re,Re,$e),h.aD(Ye,Ye,$e);let je=h.cs([],Re,Ye),Ue=h.ct([],Re,Ye),at=h.cO(je,Ue);if(at===0)return!0;let ot=!1,et=this._elevation;if(et&&at>fe&&Pe!==0){let it=this.calculateProjMatrix(Ce.tileID.toUnwrapped()),ut;t.isTerrainDEM||(ut=et.getMinMaxForTile(Ce.tileID)),ut||(ut={min:te,max:re});let xt=h.cu(this.rotation),_t=[xt[0]*h.ak,xt[1]*h.ak,ut.max];h.ae(_t,_t,it),ot=(1-_t[1])*this.height*.5<Pe}return at<fe||ot})}return ue.sort((fe,Pe)=>fe.distanceSq-Pe.distanceSq).map(fe=>fe.tileID)}resize(t,o){this.width=t,this.height=o,this.pixelsToGLUnits=[2/t,-2/o],this._constrain(),this._calcMatrices()}get unmodified(){return this._unmodified}zoomScale(t){return Math.pow(2,t)}scaleZoom(t){return Math.log2(t)}project(t){let o=h.aB(t.lat,-h.cv,h.cv),c=this.projection.project(t.lng,o);return new h.P(c.x*this.worldSize,c.y*this.worldSize)}unproject(t){return this.projection.unproject(t.x/this.worldSize,t.y/this.worldSize)}get point(){return this.project(this.center)}get pointMerc(){return this.point._div(this.worldSize)}get pixelsPerMeterRatio(){return this.pixelsPerMeter/h.bY(1,this.center.lat)/this.worldSize}setLocationAtPoint(t,o){let c,d,m=this.centerPoint;if(this.projection.name==="globe"){let y=this.worldSize;c=(o.x-m.x)/y,d=(o.y-m.y)/y}else{let y=this.pointCoordinate(o),v=this.pointCoordinate(m);c=y.x-v.x,d=y.y-v.y}let _=this.locationCoordinate(t);this.setLocation(new h.ad(_.x-c,_.y-d))}setLocation(t){this.center=this.coordinateLocation(t),this.projection.wrap&&(this.center=this.center.wrap())}locationPoint(t,o){return this.projection.locationPoint(this,t,o)}locationPoint3D(t,o){return this.projection.locationPoint(this,t,o,!0)}pointLocation(t){return this.coordinateLocation(this.pointCoordinate(t))}pointLocation3D(t,o){return this.coordinateLocation(this.pointCoordinate3D(t,o))}locationCoordinate(t,o){let c=o?h.bY(o,t.lat):void 0,d=this.projection.project(t.lng,t.lat);return new h.ad(d.x,d.y,c)}coordinateLocation(t){return this.projection.unproject(t.x,t.y)}pointRayIntersection(t,o){let c=o??this._centerAltitude,d=[t.x,t.y,0,1],m=[t.x,t.y,1,1];h.aD(d,d,this.pixelMatrixInverse),h.aD(m,m,this.pixelMatrixInverse);let _=m[3];h.cw(d,d,1/d[3]),h.cw(m,m,1/_);let y=d[2],v=m[2];return{p0:d,p1:m,t:y===v?0:(c-y)/(v-y)}}screenPointToMercatorRay(t){let o=[t.x,t.y,0,1],c=[t.x,t.y,1,1];return h.aD(o,o,this.pixelMatrixInverse),h.aD(c,c,this.pixelMatrixInverse),h.
8cw(o,o,1/o[3]),h.cw(c,c,1/c[3]),o[2]=h.bY(o[2],this._center.lat)*this.worldSize,c[2]=h.bY(c[2],this._center.lat)*this.worldSize,h.cw(o,o,1/this.worldSize),h.cw(c,c,1/this.worldSize),new h.ay([o[0],o[1],o[2]],h.ax([],h.aw([],c,o)))}rayIntersectionCoordinate(t){let{p0:o,p1:c,t:d}=t,m=h.bY(o[2],this._center.lat),_=h.bY(c[2],this._center.lat);return new h.ad(h.aj(o[0],c[0],d)/this.worldSize,h.aj(o[1],c[1],d)/this.worldSize,h.aj(m,_,d))}pointCoordinate(t,o=this._centerAltitude){return this.projection.pointCoordinate(this,t.x,t.y,o)}pointCoordinate3D(t,o){if(!this.elevation)return this.pointCoordinate(t,o);let c=this.projection.pointCoordinate3D(this,t.x,t.y);if(c)return new h.ad(c[0],c[1],c[2]);let d=0,m=this.horizonLineFromTop();if(t.y>m)return this.pointCoordinate(t,o);let _=.02*m,y=t.clone();for(let v=0;v<10&&m-d>_;v++){y.y=h.aj(d,m,.66);let T=this.projection.pointCoordinate3D(this,y.x,y.y);T?(m=y.y,c=T):d=y.y}return c?new h.ad(c[0],c[1],c[2]):this.pointCoordinate(t)}isPointAboveHorizon(t){return this.projection.isPointAboveHorizon(this,t)}isPointOnSurface(t){if(t.y<0||t.y>this.height||t.x<0||t.x>this.width)return!1;if(this.elevation||this.zoom>=h.cx)return!this.isPointAboveHorizon(t);let o=this.pointCoordinate(t);return o.y>=0&&o.y<=1}_coordinatePoint(t,o){let c=o&&this.elevation?this.elevation.getAtPointOrZero(t,this._centerAltitude):this._centerAltitude,d=[t.x*this.worldSize,t.y*this.worldSize,c+t.toAltitude(),1];return h.aD(d,d,this.pixelMatrix),d[3]>0?new h.P(d[0]/d[3],d[1]/d[3]):new h.P(Number.MAX_VALUE,Number.MAX_VALUE)}_getBoundsNonRectangular(){let{top:t,left:o}=this._edgeInsets,c=this.height-this._edgeInsets.bottom,d=this.width-this._edgeInsets.right,m=this.pointLocation3D(new h.P(o,t)),_=this.pointLocation3D(new h.P(d,t)),y=this.pointLocation3D(new h.P(d,c)),v=this.pointLocation3D(new h.P(o,c)),T=Math.min(m.lng,_.lng,y.lng,v.lng),I=Math.max(m.lng,_.lng,y.lng,v.lng),P=Math.min(m.lat,_.lat,y.lat,v.lat),A=Math.max(m.lat,_.lat,y.lat,v.lat),D=Math.pow(2,-this.zoom)/16*270,L=this.projection.name==="globe"?1:4,O=(k,N,q,Z,G)=>{let re=(k+q)/2,te=(N+Z)/2,se=new h.P(re,te),{lng:K,lat:J}=this.pointLocation3D(se),oe=Math.max(0,T-K,P-J,K-I,J-A);T=Math.min(T,K),I=Math.max(I,K),P=Math.min(P,J),A=Math.max(A,J),(G<L||oe>D)&&(O(k,N,re,te,G+1),O(re,te,q,Z,G+1))};if(O(o,t,d,t,1),O(d,t,d,c,1),O(d,c,o,c,1),O(o,c,o,t,1),this.projection.name==="globe"){let[k,N]=h.cy(this);k?(A=90,I=180,T=-180):N&&(P=-90,I=180,T=-180)}return new h.aI(new h.aX(T,P),new h.aX(I,A))}_getBoundsRectangular(t,o){let{top:c,left:d}=this._edgeInsets,m=this.height-this._edgeInsets.bottom,_=this.width-this._edgeInsets.right,y=new h.P(d,c),v=new h.P(_,c),T=new h.P(_,m),I=new h.P(d,m),P=this.pointCoordinate(y,t),A=this.pointCoordinate(v,t),D=this.pointCoordinate(T,o),L=this.pointCoordinate(I,o),O=(k,N)=>(N.y-k.y)/(N.x-k.x);return P.y>1&&A.y>=0?P=new h.ad((1-L.y)/O(L,P)+L.x,1):P.y<0&&A.y<=1&&(P=new h.ad(-L.y/O(L,P)+L.x,0)),A.y>1&&P.y>=0?A=new h.ad((1-D.y)/O(D,A)+D.x,1):A.y<0&&P.y<=1&&(A=new h.ad(-D.y/O(D,A)+D.x,0)),new h.aI().extend(this.coordinateLocation(P)).extend(this.coordinateLocation(A)).extend(this.coordinateLocation(L)).extend(this.coordinateLocation(D))}_getBoundsRectangularTerrain(){let t=this.elevation;if(!t.visibleDemTiles.length||t.isUsingMockSource())return this._getBoundsRectangular(0,0);let o=t.visibleDemTiles.reduce((c,d)=>{if(d.dem){let m=d.dem.tree;c.min=Math.min(c.min,m.minimums[0]),c.max=Math.max(c.max,m.maximums[0])}return c},{min:Number.MAX_VALUE,max:0});return this._getBoundsRectangular(o.min*t.exaggeration(),o.max*t.exaggeration())}getBounds(){return this.projection.name==="mercator"||this.projection.name==="equirectangular"?this._terrainEnabled()?this._getBoundsRectangularTerrain():this._getBoundsRectangular(0,0):this._getBoundsNonRectangular()}horizonLineFromTop(t=!0){let o=this.height/2/Math.tan(this._fov/2)/Math.tan(Math.max(this._pitch,.1))-this.centerOffset.y,c=this.height/2-o*(1-this._horizonShift);return t?Math.max(0,c):c}getMaxBounds(){return this.maxBounds}setMaxBounds(t){this.maxBounds=t,this.minLat=-h.cv,this.maxLat=h.cv,this.minLng=-180,this.maxLng=180,t&&(this.minLat=t.getSouth(),this.maxLat=t.getNorth(),this.minLng=t.getWest(),this.maxLng=t.getEast(),this.maxLng<this.minLng&&(this.maxLng+=360)),this.worldMinX=h.aG(this.minLng)*this.tileSize,this.worldMaxX=h.aG(this.maxLng)*this.tileSize,this.worldMinY=h.aJ(this.maxLat)*this.tileSize,this.worldMaxY=h.aJ(this.minLat)*this.tileSize,this._constrain()}calculatePosMatrix(t,o){return this.projection.createTileMatrix(this,o,t)}calculateDistanceTileData(t){let o=t.key,c=this._distanceTileDataCache;if(c[o])return c[o];let d=t.canonical,m=1/this.height,_=this.cameraWorldSize,y=_/this.zoomScale(d.z),v=(d.x+Math.pow(2,d.z)*t.wrap)*y,T=d.y*y,I=this.point;I.x*=_/this.worldSize,I.y*=_/this.worldSize;let P=this.angle,A=Math.sin(-P),D=-Math.cos(-P);return c[o]={bearing:[A,D],center:[(I.x-v)*m,(I.y-T)*m],scale:y/h.ak*m},c[o]}calculateFogTileMatrix(t){let o=t.key,c=this._fogTileMatrixCache;if(c[o])return c[o];let d=this.projection.createTileMatrix(this,this.cameraWorldSizeForFog,t);return h.aC(d,this.worldToFogMatrix,d),c[o]=new Float32Array(d),c[o]}calculateProjMatrix(t,o=!1,c=!1){let d=t.key,m;if(m=c?this._expandedProjMatrixCache:o?this._alignedProjMatrixCache:this._projMatrixCache,m[d])return m[d];let _=this.calculatePosMatrix(t,this.worldSize),y;return y=this.projection.isReprojectedInTileSpace?this.mercatorMatrix:c?this.expandedFarZProjMatrix:o?this.alignedProjMatrix:this.projMatrix,h.aC(_,y,_),m[d]=new Float32Array(_),m[d]}calculatePixelsToTileUnitsMatrix(t){let o=t.tileID.key,c=this._pixelsToTileUnitsCache;if(c[o])return c[o];let d=h.cz(t,this);return c[o]=d,c[o]}customLayerMatrix(){return this.mercatorMatrix.slice()}globeToMercatorMatrix(){if(this.projection.name==="globe"){let t=1/this.worldSize,o=h.bT([],[t,t,t]);return h.aC(o,o,this.globeMatrix),o}}recenterOnTerrain(){if(!this._elevation||this.projection.name==="globe")return;let t=this._elevation;this._updateCameraState();let o=h.bY(1,this._center.lat)*this.worldSize,c=this._computeCameraPosition(o),d=this._camera.forward(),m=h.bY(1,this._center.lat);c[2]/=m,d[2]/=m,h.ax(d,d);let _=t.raycast(c,d,t.exaggeration());if(_){let y=h.bi([],c,d,_),v=new h.ad(y[0],y[1],h.bY(y[2],h.bZ(y[1]))),T=(v.z+h.af([v.x-c[0],v.y-c[1],v.z-c[2]*m]))*this._pixelsPerMercatorPixel;this._seaLevelZoom=this._zoomFromMercatorZ(T),this._centerAltitude=v.toAltitude(),this._center=this.coordinateLocation(v),this._updateZoomFromElevation(),this._constrain(),this._calcMatrices()}}_constrainCamera(t=!1){if(!this._elevation)return;let o=this._elevation,c=h.bY(1,this._center.lat)*this.worldSize,d=this._computeCameraPosition(c),m=o.getAtPointOrZero(new h.ad(...d)),_=this.pixelsPerMeter/this.worldSize*m,y=this._minimumHeightOverTerrain(),v=d[2]-_;if(v<=y)if(v<0||t){let T=this.locationCoordinate(this._center,this._centerAltitude),I=[d[0],d[1],T.z-d[2]],P=h.af(I);I[2]-=(y-v)/this._pixelsPerMercatorPixel;let A=h.af(I);if(A===0)return;h.bN(I,I,P/A*this._pixelsPerMercatorPixel),this._camera.position=[d[0],d[1],T.z*this._pixelsPerMercatorPixel-
8I[2]],this._updateStateFromCamera()}else this._isCameraConstrained=!0}_constrain(){if(!this.center||!this.width||!this.height||this._constraining)return;this._constraining=!0;let t=this.projection.name==="globe"||this.mercatorFromTransition;if(this.projection.isReprojectedInTileSpace||t){let A=this.center;return A.lat=h.aB(A.lat,this.minLat,this.maxLat),(this.maxBounds||!this.renderWorldCopies&&!t)&&(A.lng=h.aB(A.lng,this.minLng,this.maxLng)),this.center=A,void(this._constraining=!1)}let o=this._unmodified,{x:c,y:d}=this.point,m=0,_=c,y=d,v=this.width/2,T=this.height/2,I=this.worldMinY*this.scale,P=this.worldMaxY*this.scale;if(d-T<I&&(y=I+T),d+T>P&&(y=P-T),P-I<this.height&&(m=Math.max(m,this.height/(P-I)),y=(P+I)/2),this.maxBounds||!this._renderWorldCopies||!this.projection.wrap){let A=this.worldMinX*this.scale,D=this.worldMaxX*this.scale,L=this.worldSize/2-(A+D)/2;_=(c+L+this.worldSize)%this.worldSize-L,_-v<A&&(_=A+v),_+v>D&&(_=D-v),D-A<this.width&&(m=Math.max(m,this.width/(D-A)),_=(D+A)/2)}_===c&&y===d||this._allowWorldUnderZoom||(this.center=this.unproject(new h.P(_,y))),m&&!this._allowWorldUnderZoom&&(this.zoom+=this.scaleZoom(m)),this._constrainCamera(),this._unmodified=o,this._constraining=!1}_minZoomForBounds(){let t=Math.max(0,this.scaleZoom(Math.max(0,this.height)/(this.worldMaxY-this.worldMinY)));return this.maxBounds&&(t=Math.max(t,this.scaleZoom(this.width/(this.worldMaxX-this.worldMinX)))),t}_maxCameraBoundsDistance(){return this._mercatorZfromZoom(this._minZoomForBounds())}_calcMatrices(){if(!this.height)return;let t=this.centerOffset,o=this.projection.name==="globe",c=this.pixelsPerMeter;this.projection.name==="globe"&&(this._mercatorScaleRatio=h.bY(1,this.center.lat)/h.bY(1,h.cR));let d=h.cA(this.projection,this.zoom,this.width,this.height,1024);this._pixelsPerMercatorPixel=this.projection.pixelSpaceConversion(this.center.lat,this.worldSize,d),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 m=this.projection.zAxisUnit==="meters"?c:1,_=this._camera.getWorldToCamera(this.worldSize,m),y,v=this._camera.getCameraToClipPerspective(this._fov,this.width/this.height,this._nearZ,this._farZ);if(v[8]=2*-t.x/this.width,v[9]=2*t.y/this.height,this.isOrthographic){let re=.5*this.height/Math.tan(this._fov/2)*1*Math.tan(.5*this._fov),te=re*this.aspect,se=-te,K=-re;te-=t.x,se-=t.x,re+=t.y,K+=t.y,y=this._camera.getCameraToClipOrthographic(se,te,K,re,this._nearZ+this._nearClipOffset,this._farZ),((J,oe,ue,de)=>{for(let be=0;be<16;be++)J[be]=h.aj(oe[be],ue[be],de)})(y,y,v,h.cP(this.pitch>=Po?1:this.pitch/Po))}else y=v;let T=h.cB([],v,_),I=h.cB([],y,_);if(this.projection.isReprojectedInTileSpace){let re=this.locationCoordinate(this.center);h.bA(this._mat4Scratch);let te=this._mat4Scratch;h.bB(te,te,[re.x*this.worldSize,re.y*this.worldSize,0]),h.aC(te,te,h.cC(this)),h.bB(te,te,[-re.x*this.worldSize,-re.y*this.worldSize,0]),h.aC(I,I,te),h.aC(T,T,te),this.inverseAdjustmentMatrix=h.cD(this)}else this.inverseAdjustmentMatrix=[1,0,0,1];if(h.cE(this.mercatorMatrix,I,[this.worldSize,this.worldSize,this.worldSize/m,1]),this.projMatrix=I,h.ba(this.invProjMatrix,this.projMatrix),o){let re=this._camera.getCameraToClipPerspective(this._fov,this.width/this.height,this._nearZ,1/0);re[8]=2*-t.x/this.width,re[9]=2*t.y/this.height,h.cB(this._expandedFarZProjMatrixBuf,re,_),this.expandedFarZProjMatrix=this._expandedFarZProjMatrixBuf}else this.expandedFarZProjMatrix=this.projMatrix;h.ba(this._mat4Scratch,y),this.frustumCorners=h.cF.fromInvProjectionMatrix(this._mat4Scratch,this.horizonLineFromTop(),this.height),this.cameraFrustum=h.cn.fromInvProjectionMatrix(this.invProjMatrix,this.worldSize,0,!o),h.bT(this.skyboxMatrix,[1,-1,1]),h.cG(this.skyboxMatrix,this.skyboxMatrix,this._pitch),h.bc(this.skyboxMatrix,this.skyboxMatrix,this.angle),h.bW(this.starsProjMatrix,this._fov,this.width/this.height,this._nearZ,this._farZ);let P=(Math.PI/2-this._pitch)*(this.height/this._fov)*this._horizonShift;h.cH(this._mat4Scratch,this.starsProjMatrix),this._mat4Scratch[8]=2*-t.x/this.width,this._mat4Scratch[9]=2*(t.y+P)/this.height,h.aC(this.skyboxMatrix,this._mat4Scratch,this.skyboxMatrix);let A=this.point,D=A.x,L=A.y,O=this.width%2/2,k=this.height%2/2,N=Math.cos(this.angle),q=Math.sin(this.angle),Z=D-Math.round(D)+N*O+q*k,G=L-Math.round(L)+N*k+q*O;if(h.cH(this.alignedProjMatrix,I),h.bB(this.alignedProjMatrix,this.alignedProjMatrix,[Z>.5?Z-1:Z,G>
8.5?G-1:G,0]),h.bT(this.labelPlaneMatrix,[this.width/2,-this.height/2,1]),h.bB(this.labelPlaneMatrix,this.labelPlaneMatrix,[1,-1,0]),h.bT(this.glCoordMatrix,[1,-1,1]),h.bB(this.glCoordMatrix,this.glCoordMatrix,[-1,-1,0]),h.cE(this.glCoordMatrix,this.glCoordMatrix,[2/this.width,2/this.height,1]),h.aC(this.pixelMatrix,this.labelPlaneMatrix,T),this._calcFogMatrices(),this._distanceTileDataCache={},!h.ba(this.pixelMatrixInverse,this.pixelMatrix))throw new Error("failed to invert matrix");if(this.projection.name==="globe"||this.mercatorFromTransition){this.globeMatrix=h.cI(this);let re=[this.globeMatrix[12],this.globeMatrix[13],this.globeMatrix[14]];this.globeCenterInViewSpace=h.ae(re,re,_),this.globeRadius=this.worldSize/2/Math.PI-1}else this.globeMatrix=this.pixelMatrixInverse;this._projMatrixCache={},this._alignedProjMatrixCache={},this._pixelsToTileUnitsCache={},this._expandedProjMatrixCache={}}_calcFogMatrices(){this._fogTileMatrixCache={};let t=this.cameraWorldSizeForFog,o=this.cameraPixelsPerMeter,c=this._camera.position,d=1/this.height/this._pixelsPerMercatorPixel,m=[t,t,o];h.bN(m,m,d),h.bN(c,c,-1),h.cJ(c,c,m),h.cK(this.mercatorFogMatrix,c),h.cE(this.mercatorFogMatrix,this.mercatorFogMatrix,m),this.worldToFogMatrix=this._camera.getWorldToCameraPosition(t,o,d)}_computeCameraPosition(t){let o=(t=t||this.pixelsPerMeter)/this.pixelsPerMeter,c=this._camera.forward(),d=this.point,m=this._mercatorZfromZoom(this._seaLevelZoom?this._seaLevelZoom:this._zoom)*o-t/this.worldSize*this._centerAltitude;return[d.x/this.worldSize-c[0]*m,d.y/this.worldSize-c[1]*m,t/this.worldSize*this._centerAltitude-c[2]*m]}_updateCameraState(){this.height&&(this._camera.setPitchBearing(this._pitch,this.angle),this._camera.position=this._computeCameraPosition())}_translateCameraConstrained(t){let o=this._maxCameraBoundsDistance()*Math.cos(this._pitch),c=this._camera.position[2],d=t[2],m=1;this.projection.wrap&&(this.center=this.center.wrap()),d>0&&(m=Math.min((o-c)/d,1)),this._camera.position=h.bi([],this._camera.position,t,m),this._updateStateFromCamera()}_updateStateFromCamera(){let t=this._camera.position,o=this._camera.forward(),{pitch:c,bearing:d}=this._camera.getPitchBearing(),m=h.bY(this._centerAltitude,this.center.lat)*this._pixelsPerMercatorPixel,_=this._mercatorZfromZoom(this._maxZoom)*Math.cos(h.am(this._maxPitch)),y=Math.max((t[2]-m)/Math.cos(c),_),v=this._zoomFromMercatorZ(y);h.bi(t,t,o,y),this._pitch=h.aB(c,h.am(this.minPitch),h.am(this.maxPitch)),this.angle=h.bv(d,-Math.PI,Math.PI),this._setZoom(h.aB(v,this._minZoom,this._maxZoom)),this._updateSeaLevelZoom(),this._center=this.coordinateLocation(new h.ad(t[0],t[1],t[2])),this._unmodified=!1,this._constrain(),this._calcMatrices()}_worldSizeFromZoom(t){return Math.pow(2,t)*this.tileSize}_mercatorZfromZoom(t){return this.cameraToCenterDistance/this._worldSizeFromZoom(t)}_minimumHeightOverTerrain(){let t=Math.min(this._seaLevelZoom!=null?this._seaLevelZoom:this._zoom,this._maxZoom)+4;return this._mercatorZfromZoom(t)}_zoomFromMercatorZ(t){return this.scaleZoom(this.cameraToCenterDistance/(Math.max(0,t)*this.tileSize))}zoomFromMercatorZAdjusted(t){let o=0,c=h.cx,d=0,m=1/0;for(;c-o>1e-6&&c>o;){let _=o+.5*(c-o),y=this.tileSize*Math.pow(2,_),v=this.getCameraToCenterDistance(this.projection,_,y),T=this.scaleZoom(v/(Math.max(0,t)*this.tileSize)),I=Math.abs(_-T);I<m&&(m=I,d=_),_<T?o=_:c=_}return d}_terrainEnabled(){return!(!this._elevation||!this.projection.supportsTerrain&&(h.w("Terrain is not yet supported with alternate projections. Use mercator or globe to enable terrain."),1))}anyCornerOffEdge(t,o){let c=Math.min(t.x,o.x),d=Math.max(t.x,o.x),m=Math.min(t.y,o.y),_=Math.max(t.y,o.y);if(m<this.horizonLineFromTop(!1))return!0;if(this.projection.name!=="mercator")return!1;let y=[new h.P(c,m),new h.P(d,_),new h.P(c,_),new h.P(d,m)],v=this.renderWorldCopies?-3:0,T=this.renderWorldCopies?4:1;for(let I of y){let P=this.pointRayIntersection(I);if(P.t<0)return!0;let A=this.rayIntersectionCoordinate(P);if(A.x<v||A.y<0||A.x>T||A.y>1)return!0}return!1}isHorizonVisible(){return this.pitch+h.cL(this.fovAboveCenter)>88||this.anyCornerOffEdge(new h.P(0,0),new h.P(this.width,this.height))}zoomDeltaToMovement(t,o){let c=h.af(h.aw([],this._camera.position,t)),d=this._zoomFromMercatorZ(c)+o;return c-this._mercatorZfromZoom(d)}getCameraPoint(){if(this.projection.name==="globe"){let t=function([o,c,d],m){let _=[o,c,d,1];h.aD(_,_,m);let y=_[3]=Math.max(_[3],1e-6);return _[0]/=y,_[1]/=y,_[2]/=y,_}([this.globeMatrix[12],this.globeMatrix[13],this.globeMatrix[14]],this.pixelMatrix);return new h.P(t[0],t[1])}{let t=Math.tan(this._pitch)*(this.cameraToCenterDistance||1);return this.centerPoint.add(new h.P(0,t))}}getCameraToCenterDistance(t,o=this.zoom,c=this.worldSize){let d=h.cA(t,o,this.width,this.height,1024),m=t.pixelSpaceConversion(this.center.lat,c,d),_=.5/Math.tan(.5*this._fov)*this.height*m;return this.isOrthographic&&(_=h.aj(1,_,h.cP(this.pitch>=Po?1:this.pitch/Po))),_}getWorldToCameraMatrix(){let t=this._camera.getWorldToCamera(this.worldSize,this.projection.zAxisUnit==="meters"?this.pixelsPerMeter:1);return this.projection.name==="globe"&&h.aC(t,t,this.globeMatrix),t}getFrustum(t){return h.cn.fromInvProjectionMatrix(this.invProjMatrix,this.worldSize,t,this.projection.zAxisUnit==="meters")}}let Cs=(a,t)=>{if(t>0&&a.terrain&&h.w("Cutoff is currently disabled on terrain"),t<=0||a.terrain)return{shouldRenderCutoff:!1,uniformValues:{u_cutoff_params:[0,0,0,1]}};let o=a.transform,c=o.pitch,d=o.isLODDisabled(!1)?60:30;if(c<d-15)return{shouldRenderCutoff:!1,uniformValues:{u_cutoff_params:[0,0,0,1]}};let m=o._farZ-o._nearZ,_=t*o.height*1.3,y=Math.pow(2,.85*Math.max(o._zoom-a.minCutoffZoom,0)),v=1.4*o.cameraToCenterDistance*y,T=h.ag(d-15,d,c),I=(1-(P=T))*(o._farZ+_)+P*v;var P;let A=Math.min(_,I-o._nearZ);return{shouldRenderCutoff:T>0,uniformValues:{u_cutoff_params:[o._nearZ,o._farZ,(I-o._nearZ)/m,(I-A-o._nearZ)/m]}}},gf=[];function Sc(a){return gf[a]=gf[a]||new Float64Array(16)}class j_{constructor(t,o){this.aabb=t,this.lastCascade=o}}class yf{add(t,o){let c=this.receivers[t.key];c!==void 0?(c.aabb.min[0]=Math.min(c.aabb.min[0],o.min[0]),c.aabb.min[1]=Math.min(c.aabb.min[1],o.min[1]),c.aabb.min[2]=Math.min(c.aabb.min[2],o.min[2]),c.aabb.max[0]=Math.max(c.aabb.max[0],o.max[0]),c.aabb.max[1]=Math.max(c.aabb.max[1],o.max[1]),c.aabb.max[2]=Math.max(c.aabb.max[2],o.max[2])):this.receivers[t.key]=new j_(o,null)}clear(){this.receivers={}}get(t){return this.receivers[t.key]}computeRequiredCascades(t,o,c){let d=h.cY.fromPoints(t.points),m=0;for(let _ in this.receivers){let y=this.receivers[_];if(!y||!d.intersectsAabb(y.aabb))continue;y.aabb.min=d.closestPoint(y.aabb.min),y.aabb.max=d.closestPoint(y.aabb.max);let v=y.aabb.getCorners();for(let T=0;T<c.length;T++){let I=!0;for(let P of v){let A=[P[0]*o,P[1]*o,P[2]];
8if(h.ae(A,A,c[T].matrix),A[0]<-1||A[0]>1||A[1]<-1||A[1]>1){I=!1;break}}if(y.lastCascade=T,m=Math.max(m,T),I)break}}return m+1}}class xf{constructor(t){this.painter=t,this._enabled=!1,this._drawShadowAfterLayer=-1,this._numCascadesToRender=0,this._cascades=[],this._groundShadowTiles=[],this._receivers=new yf,this._depthMode=new nt(t.context.gl.LEQUAL,nt.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._devtoolsFolder=null,this.useNormalOffset=!1,this._shadowParameters={cascadeCount:2,normalOffset:3,shadowMapResolution:2048}}destroy(){for(let t of this._cascades)t.texture.destroy(),t.framebuffer.destroy();this._cascades=[]}updateShadowParameters(t,o){let c=this.painter;if(this._enabled=!1,this._drawShadowAfterLayer=-1,this._receivers.clear(),!o||!o.properties)return;let d=o.properties.get("shadow-intensity"),m=o.properties.get("shadow-draw-before-layer");if(!o.shadowsEnabled()||d<=0)return;let _=-1,y=0;for(let N of c.style.order){let q=c.style._mergedLayers[N];q.hasShadowPass()&&!q.isHidden(t.zoom)&&(_=y),!m||m!==N&&m!==q.slot||(this._drawShadowAfterLayer=y>0?y-1:0),y+=1}if(this._enabled=_>=0,!this.enabled)return;this._drawShadowAfterLayer<0&&(this._drawShadowAfterLayer=_);let v=c.context,T=this._shadowParameters.shadowMapResolution,I=this._shadowParameters.shadowMapResolution;if(this._cascades.length===0||this._shadowParameters.shadowMapResolution!==this._cascades[0].texture.size[0]){this._cascades=[];for(let N=0;N<this._shadowParameters.cascadeCount;++N){let q=v.gl,Z=v.createFramebuffer(T,I,0,"texture"),G=new h.T(v,{width:T,height:I,data:null},q.DEPTH_COMPONENT16);Z.depthAttachment.set(G.texture),this._cascades.push({framebuffer:Z,texture:G,matrix:[],far:0,boundingSphereRadius:0,frustum:new h.cn,scale:0})}}this.shadowDirection=vf(o);let P=0;if(t.elevation){let N=t.elevation,q=[1e4,-1e4];N.visibleDemTiles.filter(Z=>Z.dem).forEach(Z=>{let G=Z.dem.tree;q[0]=Math.min(q[0],G.minimums[0]),q[1]=Math.max(q[1],G.maximums[0])}),q[0]!==1e4&&(P=(q[1]-q[0])*N.exaggeration())}let A=1.5*t.cameraToCenterDistance,D=3*A,L=new Float64Array(16);for(let N=0;N<this._cascades.length;++N){let q=this._cascades[N],Z=t.height/50,G=1;this._shadowParameters.cascadeCount===1?G=D:N===0?G=A:(Z=A,G=D);let[re,te]=G_(t,this.shadowDirection,Z,G,this._shadowParameters.shadowMapResolution,P);q.scale=t.scale,q.matrix=re,q.boundingSphereRadius=te,h.ba(L,q.matrix),q.frustum=h.cn.fromInvProjectionMatrix(L,1,0,!0),q.far=G}let O=this._cascades.length-1;this._uniformValues.u_fade_range=[.75*this._cascades[O].far,this._cascades[O].far],this._uniformValues.u_shadow_intensity=d,this._uniformValues.u_shadow_direction=[this.shadowDirection[0],this.shadowDirection[1],this.shadowDirection[2]],this._uniformValues.u_shadow_texel_size=1/this._shadowParameters.shadowMapResolution,this._uniformValues.u_shadow_map_resolution=this._shadowParameters.shadowMapResolution,this._uniformValues.u_shadowmap_0=11,this._uniformValues.u_shadowmap_1=12,this._groundShadowTiles=c.transform.coveringTiles({tileSize:512,renderWorldCopies:!0});let k=c.transform.elevation;for(let N of this._groundShadowTiles){let q={min:0,max:0};if(k){let Z=k.getMinMaxForTile(N);Z&&(q=Z)}this.addShadowReceiver(N.toUnwrapped(),q.min,q.max)}}get enabled(){return this._enabled&&!this._forceDisable}set enabled(t){this._enabled=t}drawShadowPass(t,o){if(!this.enabled)return;let c=this.painter,d=c.context;this._numCascadesToRender=this._receivers.computeRequiredCascades(c.transform.getFrustum(0),c.transform.worldSize,this._cascades),d.viewport.set([0,0,this._shadowParameters.shadowMapResolution,this._shadowParameters.shadowMapResolution]);for(let m=0;m<this._numCascadesToRender;++m){c.currentShadowCascade=m,d.bindFramebuffer.set(this._cascades[m].framebuffer.framebuffer),d.clear({color:h.C.white,depth:1});for(let _ of t.order){let y=t._mergedLayers[_];if(!y.hasShadowPass()||y.isHidden(c.transform.zoom))continue;let v=t.getLayerSourceCache(y),T=v?o[v.id]:void 0;(y.type==="model"||T&&T.length)&&c.renderLayer(c,v,y,T)}}c.currentShadowCascade=0}drawGroundShadows(){if(!this.enabled)return;let t=this.painter,o=t.style,c=t.context,d=c.gl,m=o.directionalLight,_=o.ambientLight;if(!m||!_)return;let y=[],v=Cs(t,t.longestCutoffRange);v.shouldRenderCutoff&&y.push("RENDER_CUTOFF"),y.push("RENDER_SHADOWS"),this.useNormalOffset&&y.push("NORMAL_OFFSET");let T=Ea(o,m,_),I=new nt(d.LEQUAL,nt.ReadOnly,t.depthRangeFor3D),P=new gt({func:d.EQUAL,mask:255},0,255,d.KEEP,d.KEEP,d.KEEP);for(let A of this._groundShadowTiles){let D=A.toUnwrapped(),L=t.isTileAffectedByFog(A),O=t.getOrCreateProgram("groundShadow",{defines:y,overrideFog:L});this.setupShadows(D,O),t.uploadCommonUniforms(c,O,D,null,v);let k=ed(t.transform.calculateProjMatrix(D),T);O.draw(t,d.TRIANGLES,I,P,mt.multiply,dt.disabled,k,"ground_shadow",t.tileExtentBuffer,t.quadTriangleIndexBuffer,t.tileExtentSegments,null,t.transform.zoom,null,null)}}getShadowPassDepthMode(){return this._depthMode}getGroundShadowLayerIndex(){return this._drawShadowAfterLayer}calculateShadowPassMatrixFromTile(t){let o=this.painter.transform,c=o.calculatePosMatrix(t,o.worldSize);return h.aC(c,this._cascades[this.painter.currentShadowCascade].matrix,c),Float32Array.from(c)}
8calculateShadowPassMatrixFromMatrix(t){let o=h.bb(t);return h.aC(o,this._cascades[this.painter.currentShadowCascade].matrix,t),o}setupShadows(t,o,c){if(!this.enabled)return;let d=this.painter.transform,m=this.painter.context,_=m.gl,y=this._uniformValues,v=d.calculatePosMatrix(t,d.worldSize);for(let T=0;T<this._cascades.length;T++){let I=Sc(T);h.aC(I,this._cascades[T].matrix,v),y[T===0?"u_light_matrix_0":"u_light_matrix_1"]=I,m.activeTexture.set(_.TEXTURE0+11+T),this._cascades[T].texture.bindExtraParam(_.LINEAR,_.LINEAR,_.CLAMP_TO_EDGE,_.CLAMP_TO_EDGE,_.GREATER)}if(this.useNormalOffset=!!c,this.useNormalOffset){let T=h.cW(t.canonical),I=2/d.tileSize*h.ak/this._shadowParameters.shadowMapResolution,P=I*this._cascades[0].boundingSphereRadius,A=I*this._cascades.at(-1).boundingSphereRadius,D=(c==="vector-tile"?1:3)*function(L){let O=h.aB((L-22)/-22,0,1);return .125*(1-O)+4*O}(d.zoom);y.u_shadow_normal_offset=[T,P*D,A*D],y.u_shadow_bias=[1e-4,.0012,.012]}else y.u_shadow_bias=[36e-5,.0012,.012];o.setShadowUniformValues(m,y)}setupShadowsFromMatrix(t,o,c=!1){if(!this.enabled)return;let d=this.painter.context,m=d.gl,_=this._uniformValues;for(let y=0;y<this._shadowParameters.cascadeCount;y++){let v=Sc(y);h.aC(v,this._cascades[y].matrix,t),_[y===0?"u_light_matrix_0":"u_light_matrix_1"]=v,d.activeTexture.set(m.TEXTURE0+11+y),this._cascades[y].texture.bindExtraParam(m.LINEAR,m.LINEAR,m.CLAMP_TO_EDGE,m.CLAMP_TO_EDGE,m.GREATER)}if(this.useNormalOffset=c,c){let y=this._shadowParameters.normalOffset;_.u_shadow_normal_offset=[1,y,y],_.u_shadow_bias=[6e-5,.0012,.012]}else _.u_shadow_bias=[36e-5,.0012,.012];o.setShadowUniformValues(d,_)}getShadowUniformValues(){return this._uniformValues}getCurrentCascadeFrustum(){return this._cascades[this.painter.currentShadowCascade].frustum}computeSimplifiedTileShadowVolume(t,o,c,d){if(d[2]>=0)return{};let m=function(v,T,I){let P=I/(1<<v.canonical.z);return new h.cY([v.canonical.x*P+v.wrap*I,v.canonical.y*P+v.wrap*I,0],[(v.canonical.x+1)*P+v.wrap*I,(v.canonical.y+1)*P+v.wrap*I,T])}(t,o,c).getCorners(),_=o/-d[2];d[0]<0?(h.cX(m[0],m[0],[d[0]*_,0,0]),h.cX(m[3],m[3],[d[0]*_,0,0])):d[0]>0&&(h.cX(m[1],m[1],[d[0]*_,0,0]),h.cX(m[2],m[2],[d[0]*_,0,0])),d[1]<0?(h.cX(m[0],m[0],[0,d[1]*_,0]),h.cX(m[1],m[1],[0,d[1]*_,0])):d[1]>0&&(h.cX(m[2],m[2],[0,d[1]*_,0]),h.cX(m[3],m[3],[0,d[1]*_,0]));let y={};return y.vertices=m,y.planes=[dl(m[1],m[0],m[4]),dl(m[2],m[1],m[5]),dl(m[3],m[2],m[6]),dl(m[0],m[3],m[7])],y}addShadowReceiver(t,o,c){this._receivers.add(t,h.cY.fromTileIdAndHeight(t,o,c))}getMaxCascadeForTile(t){let o=this._receivers.get(t);return o&&o.lastCascade?o.lastCascade:0}}function dl(a,t,o){let c=h.aw([],o,t),d=h.aw([],a,t),m=h.bj([],c,d),_=h.af(m);return _===0?[0,0,1,0]:(h.bN(m,m,1/_),[m[0],m[1],m[2],-h.bk(m,t)])}function vf(a){let t=a.properties.get("direction"),o=h.cT(t.x,t.y,t.z);o[2]=h.aB(o[2],0,75);let c=h.cV([o[0],o[1],o[2]]);return h.cU(c.x,c.y,c.z)}function Ea(a,t,o){let c=t.properties.get("color-use-theme")==="none",d=t.properties.get("color"),m=t.properties.get("intensity"),_=t.properties.get("direction"),y=[_.x,_.y,_.z],v=o.properties.get("color-use-theme")==="none",T=o.properties.get("color"),I=o.properties.get("intensity"),P=Math.max(h.bk([0,0,1],y),0),A=[0,0,0];h.bN(A,T.toPremultipliedRenderColor(v?null:a.getLut(t.scope)).toArray01Linear().slice(0,3),I);let D=[0,0,0];return h.bN(D,d.toPremultipliedRenderColor(c?null:a.getLut(o.scope)).toArray01Linear().slice(0,3),P*m),h.c_([A[0]>0?A[0]/(A[0]+D[0]):0,A[1]>0?A[1]/(A[1]+D[1]):0,A[2]>0?A[2]/(A[2]+D[2]):0])}function G_(a,t,o,c,d,m){let _=a.zoom,y=a.scale,v=a.worldSize,T=1/v,I=a.aspect,P=Math.sqrt(1+I*I)*Math.tan(.5*a.fovX),A=P*P,D=c-o,L=c+o,O,k;A>D/L?(O=c,k=c*P):(O=.5*L*(1+A),k=.5*Math.sqrt(D*D+2*(c*c+o*o)*A+L*L*A*A));let N=a.projection.pixelsPerMeter(a.center.lat,v),q=a._camera.getCameraToWorldMercator(),Z=[0,0,-O*T];h.ae(Z,Z,q);let G=k*T,re=function(Re){return Re[0]/=y,Re[1]/=y,Re[2]=h.bY(Re[2],a._center.lat),Re},te=a._edgeInsets;if(!(te.left===0&&te.top===0&&te.right===0&&te.bottom===0||te.left===te.right&&te.top===te.bottom)){let Re=a._camera.getWorldToCamera(a.worldSize,a.projection.zAxisUnit==="meters"?N:1),Ye=a._camera.getCameraToClipPerspective(a._fov,a.width/a.height,o,c);Ye[8]=2*-a.centerOffset.x/a.width,Ye[9]=2*a.centerOffset.y/a.height;let $e=new Float64Array(16);h.cB($e,Ye,Re);let je=new Float64Array(16);h.ba(je,$e);let Ue=h.cn.fromInvProjectionMatrix(je,v,_,!0);for(let at of Ue.points){let ot=re(at);G=Math.max(G,h.bO(h.cZ([],Z,ot)))}}G*=d/(d-1);let se=Math.acos(t[2]),K=Math.atan2(-t[0],-t[1]),J=new to;J.position=Z,J.setPitchBearing(se,K);let oe=J.getWorldToCamera(v,N),ue=G*v,de=Math.min(a._mercatorZfromZoom(17)*v*-2,-2*ue),be=J.getCameraToClipOrthographic(-ue,ue,-ue,ue,de,(ue+m*N)/t[2]),ve=new Float64Array(16);h.aC(ve,be,oe);let Fe=h.cU(Math.floor(1e6*Z[0])/1e6*v,Math.floor(1e6*Z[1])/1e6*v,0),pe=.5*d,Ie=[0,0,0];h.ae(Ie,Fe,ve),h.bN(Ie,Ie,pe);let fe=[Math.floor(Ie[0]),Math.floor(Ie[1]),Math.floor(Ie[2])],Pe=[0,0,0];h.aw(Pe,Ie,fe),h.bN(Pe,Pe,-1/pe);let Ce=new Float64Array(16);return h.bA(Ce),h.bB(Ce,Ce,Pe),h.aC(ve,Ce,ve),[ve,ue]}class $_ extends h.E{constructor(t){super(),this.requestManager=t,this.models={"":{}},this.modelUris={"":{}},this.modelByURL={},this.numModelsLoading={}}loadModel(t,o){return h.c$(this.requestManager.transformRequest(o,h.R.Model).url).then(c=>{let d=h.d0(c),m=new h.d1(t,o,void 0,void 0,d);return m.computeBoundsAndApplyParent(),m}).catch(c=>{if(c&&c.status===404)return null;this.fire(new h.y(new Error(`Could not load model ${t} from ${o}: ${c.message}`)))})}load(t,o,c={forceReload:!1}){this.models[o]||(this.models[o]={});let d=Object.keys(t),m=[],_=[];for(let y of d){let v=t[y];this.hasURLBeenRequested(v)&&!c.forceReload||(this.modelByURL[v]={modelId:y,scope:o},m.push(this.loadModel(y,v)),_.push(y)),this.models[o][y]||(this.models[o][y]={model:null,numReferences:1})}this.numModelsLoading[o]=(this.numModelsLoading[o]||0)+_.length,Promise.allSettled(m).then(y=>{for(let v=0;v<y.length;v++){let{status:T}=y[v];if(T==="rejected")continue;let{value:I}=y[v];this.models[o][_[v]]||(this.models[o][_[v]]={model:null,numReferences:1}),this.models[o][_[v]].model=I}this.numModelsLoading[o]-=_.length,this.fire(new h.z("data",{dataType:"style"}))}).catch(y=>{this.fire(new h.y(new Error(`Could not load models: ${y.message}`)))})}isLoaded(){for(let t in this.numModelsLoading)if(this.numModelsLoading[t]>0)return!1;return!0}hasModel(t,o,c={exactIdMatch:!1}){return!!(c.exactIdMatch?this.getModel(t,o):this.getModelByURL(this.modelUris[o][t]))}getModel(t,o){return this.models[o]||(this.models[o]={}),this.models[o][t]?this.models[o][t].model:void 0}getModelByURL(t){if(!t)return null;let o=this.modelByURL[t];return o?this.models[o.scope][o.modelId].model:null}hasModelBeenAdded(t,o){return this.models[o]&&this.models[o][t]!==void 0}getModelURIs(t){return this.modelUris[t]||{}}addModel(t,o,c){this.models[c]||(this.models[c]={}),this.modelUris[c]||(this.modelUris[c]={});let d=this.requestManager.normalizeModelURL(o);if((this.hasModel(t,c,{exactIdMatch:!0})||this.hasModelBeenAdded(t,c))&&this.modelUris[c][t]===d)this.models[c][t].numReferences++;else if(this.hasURLBeenRequested(d)){let{scope:m,modelId:_}=this.modelByURL[d];this.models[m][_].numReferences++}else this.modelUris[c][t]=d,this.load({[t]:this.modelUris[c][t]},c)}addModelURLs(t,o){this.models[o]||(this.models[o]={}),this.modelUris[o]||(this.modelUris[o]={});let c=this.modelUris[o];for(let d in t)c[d]=this.requestManager.normalizeModelURL(t[d])}
8reloadModels(t){this.load(this.modelUris[t],t,{forceReload:!0})}addModelsFromBucket(t,o){this.models[o]||(this.models[o]={}),this.modelUris[o]||(this.modelUris[o]={});let c={};for(let d of t)this.hasModel(d,o,{exactIdMatch:!0})||this.hasURLBeenRequested(d)?this.models[o][d].numReferences++:this.modelUris[o][d]&&!this.hasURLBeenRequested(d)?c[d]=this.modelUris[o][d]:!this.hasURLBeenRequested(d)&&da(d,!1)&&(this.modelUris[o][d]=this.requestManager.normalizeModelURL(d),c[d]=this.modelUris[o][d]);this.load(c,o)}hasURLBeenRequested(t){return this.modelByURL[t]!==void 0}removeModel(t,o,c=!1,d=!1){if(this.models[o]&&this.models[o][t]&&(this.models[o][t].numReferences--,this.models[o][t].numReferences===0||d)){let m=this.modelUris[o][t];c||delete this.modelUris[o][t],delete this.modelByURL[m];let _=this.models[o][t].model;if(!_)return;delete this.models[o][t],_.destroy()}}destroy(){for(let t of Object.keys(this.models))for(let o of Object.keys(this.models[t])){let c=this.models[t][o].model;delete this.models[t][o],c&&c.destroy()}this.models={"":{}},this.modelUris={"":{}},this.modelByURL={},this.numModelsLoading={}}listModels(t){return this.models[t]||(this.models[t]={}),Object.keys(this.models[t])}upload(t,o){this.models[o]||(this.models[o]={});for(let c in this.models[o])this.models[o][c].model&&this.models[o][c].model.upload(t.context)}}let bf=["RENDER_SHADOWS","NORMAL_OFFSET"],H_=new Set(["symbol","circle"]),pl=class Gy{constructor(){this._queue=[],this._needsBuild=!0,this._idleHandle=null}needsBuild(){return this._needsBuild}buildQueue(t,o,c){this._idleHandle!=null&&typeof cancelIdleCallback<"u"&&cancelIdleCallback(this._idleHandle),this._idleHandle=null,this._queue=[],this._needsBuild=!1;let d=c.stylesheet,m=!!c.fog,_=!!(c.getTerrain()||d&&d.terrain),y=!(!c.projection||c.projection.name!=="globe"),v=_||y,T=!(!c.directionalLight||!c.directionalLight.shadowsEnabled()),I=c.map&&c.map.painter,P=!I||!I.context.extParallelShaderCompile,A=!!I&&I.emissiveMode==="mrt-fallback",D=(L,O=[],k={})=>{this._queue.push({programId:L,params:Object.assign({},k.params,{defines:O,overrideFog:!!k.fog,overrideTerrain:!!k.terrain,overrideGlobe:!!k.globe,overrideRtt:!!k.rtt,precompiled:!0})})};for(let L of t){if(L.visibility==="none")continue;let O=L.getProgramIds();if(O)for(let k of O){if(H_.has(k))continue;let N=L.getDefaultProgramParams(k,o.zoom,c._styleColorTheme.lut);if(!N)continue;let q=I?I.getShaderSource(k):null,Z=v&&(!q||q.usedDefines.has("RENDER_TO_TEXTURE")),G=A&&Z?(N.defines||[]).concat("USE_MRT1"):N.defines;if(P){D(k,N.defines,{params:N}),Z&&D(k,G,{params:N,rtt:!0});continue}let re=m&&(!q||q.usedDefines.has("FOG")),te=_&&!L.isDraped()&&(!q||q.usedDefines.has("TERRAIN")),se=y&&(!q||q.usedDefines.has("GLOBE")),K=T&&L.hasElevation()&&(!q||q.usedDefines.has("RENDER_SHADOWS"));for(let J of K?[!1,!0]:[!1]){let oe=J?(N.defines||[]).concat(bf):N.defines||[];for(let ue of te?[!1,!0]:[!1])for(let de of se?[!1,!0]:[!1])for(let be of re?[!1,!0]:[!1])D(k,oe,{params:N,fog:be,terrain:ue,globe:de})}Z&&D(k,G,{params:N,rtt:!0})}}if(D("clippingMask"),_)for(let L of[!1,!0])D("terrainRaster",L?["TERRAIN_VERTEX_MORPHING"]:[],{terrain:!0,fog:m});if(!P){if(t.some(L=>L.type==="hillshade")&&D("hillshadePrepare"),T)for(let L of[!1,!0])for(let O of[!1,!0]){let k=[];L&&k.push("RENDER_CUTOFF"),k.push("RENDER_SHADOWS"),O&&k.push("NORMAL_OFFSET"),D("groundShadow",k),m&&D("groundShadow",k,{fog:!0})}if(y){for(let L of[[],["TERRAIN_VERTEX_MORPHING"],["GLOBE_POLES"]])for(let O of[!1,!0]){let k=[...L,"PROJECTION_GLOBE_VIEW"];O&&k.push("CUSTOM_ANTIALIASING"),D("globeRaster",k,{terrain:_,globe:!0,fog:m})}for(let L of[!1,!0]){let O=L?["PROJECTION_GLOBE_VIEW","FOG"]:["FOG"];D("globeAtmosphere",O,{fog:!0,terrain:_,globe:L}),D("globeAtmosphere",[...O,"ALPHA_PASS"],{fog:!0,terrain:_,globe:L})}D("stars",[],{fog:m,terrain:_,globe:!0})}}}_executeBatch(t,o,c){if(c.map&&c.map.isMoving())return void(this._idleHandle=h.o.requestIdleCallback(y=>this._executeBatch(y,o,c)));o.context.sweepPendingPrograms();let d=o.context.extParallelShaderCompile?Gy.DEADLINE_MARGIN_KHR_MS:Gy.DEADLINE_MARGIN_SYNC_MS,m=0;for(;this._queue.length>0;){let y=this._queue.shift();if(!y||(o.style=c,o._fogVisible=!!y.params.overrideFog,o.getOrCreateProgram(y.programId,y.params),m++,t.timeRemaining()<=d))break}let _=this._queue.length===0||t.timeRemaining()>d;m>0&&_&&o.context.gl.flush(),this._idleHandle=this._queue.length>0||o.context._pendingPrograms.size>0?h.o.requestIdleCallback(y=>this._executeBatch(y,o,c)):null}processQueue(t,o){this._queue.length!==0&&(this._idleHandle!=null&&typeof cancelIdleCallback<"u"&&cancelIdleCallback(this._idleHandle),this._idleHandle=h.o.requestIdleCallback(c=>this._executeBatch(c,t,o)))}reset(){this._idleHandle!=null&&typeof cancelIdleCallback<"u"&&cancelIdleCallback(this._idleHandle),this._queue=[],this._idleHandle=null,this._needsBuild=!0}};pl.DEADLINE_MARGIN_KHR_MS=5,pl.DEADLINE_MARGIN_SYNC_MS=25;let q_=pl,Ru=h.a6.colorTheme,td=new h.a8({data:new h.a9(Ru.data)});function zu(a){if(!a.metadata||!a.metadata.content_area)return;let t=h.o.devicePixelRatio,{left:o,top:c,width:d,height:m}=a.metadata.content_area,_=o*t,y=c*t;return[_,y,_+d*t,y+m*t]}function Lu(a){if(a)return a.map(([t,o])=>[t*h.o.devicePixelRatio,o*h.o.devicePixelRatio])}class Aa{constructor(t,o,c){this.id=t,this.scope=o,this.sourceCache=c,this.pendingRequests=new Set,this.missingRequests=new Set}addPendingRequest(t){this.missingRequests.has(t.name)||this.pendingRequests.has(t.name)||this.pendingRequests.add(t.name)}hasPendingRequests(){return this.pendingRequests.size>0}resolvePendingRequests(){let t=new Map;if(!this.sourceCache.loaded())return t;let o=this.sourceCache.getVisibleCoordinates();if(o.length===0)return t;let c=this.sourceCache.getSource();if(!(c instanceof jt))return t;let d=o.map(_=>this.sourceCache.getTile(_)),m=c.getImages(d,Array.from(this.pendingRequests));for(let[_,y]of m)t.set(h.I.from({name:_,iconsetId:this.id}),y),this.pendingRequests.delete(_);for(let _ of this.pendingRequests)this.missingRequests.add(_);return this.pendingRequests.clear(),t}}class Ma{constructor(){this._previousClosestBuildingId=null,this._hysteresisRatio=.8,this._indo
8orMinimumZoom=16}findClosestBuilding(t,o,c,d,m){if(c<this._indoorMinimumZoom)return this._previousClosestBuildingId=null,null;let _=null,y=Number.MAX_VALUE,v=Number.MAX_VALUE,T=!1,I=this._previousClosestBuildingId?t[this._previousClosestBuildingId]:null;this._previousClosestBuildingId&&I&&this._isBuildingVisible(I,d,m)&&(T=!0,v=this._calculateDistance(o,I));for(let[P,A]of Object.entries(t)){if(!this._isBuildingVisible(A,d,m))continue;let D=this._calculateDistance(o,A);D<y&&(y=D,_=P)}return T&&_&&this._previousClosestBuildingId&&_!==this._previousClosestBuildingId?y>v*this._hysteresisRatio&&(_=this._previousClosestBuildingId):T&&!_&&(_=this._previousClosestBuildingId),this._previousClosestBuildingId=_,_}_calculateDistance(t,o){if(!o.center)return Number.MAX_VALUE;let c=t.lat-o.center[1],d=t.lng-o.center[0];return c*c+d*d}_isBuildingVisible(t,o,c){if(!c)return!1;for(let d of t.floorIds){let m=t.floors[d];if(!m.geometry)continue;let _=m.geometry;if(_.type==="Polygon"){let y=this._convertRingToPoints(_.coordinates[0]);if(h.bz(y,c))return!0}else if(_.type==="MultiPolygon"){let y=this._convertMultiPolygonToPoints(_.coordinates);if(h.d2(c,y))return!0}}return!1}_convertRingToPoints(t){return t.map(o=>new h.P(o[0],o[1]))}_convertMultiPolygonToPoints(t){return t.map(o=>o.length===0?[]:o[0].map(c=>new h.P(c[0],c[1])))}}class fl extends h.E{constructor(t){super(),this._style=t,this._buildings={},this._activeFloors=new Set,this._closestBuildingId=null,this._indoorState={selectedFloorId:null,activeFloorsVisible:!0,activeFloors:this._activeFloors},this._buildingDetectionStrategy=new Ma,this._initialLoadDone=!1,h.b0(["_updateUI"],this),this._style.on("style.load",()=>{this._style.isIndoorEnabled()&&(this._style.map.on("load",()=>{this._initialLoadDone=!0,this._indoorState&&this._indoorState.needsUpdate&&(this._indoorState.needsUpdate=!1,this._style.updateIndoorDependentLayers()),this._updateUI()}),this._style.map.on("move",this._updateUI),this._style.map.on("idle",this._updateUI))})}destroy(){this._buildings={},this._activeFloors=new Set,this._indoorState=null}selectFloor(t){t===this._selectedFloorId&&this._indoorState&&this._indoorState.activeFloorsVisible||(this._selectedFloorId=t,this._recalculateActiveFloors())}setActiveFloorsVisibility(t){this._updateActiveFloors(t),this._updateIndoorSelector()}setIndoorData(t){let o=!1;for(let[c,d]of Object.entries(t.buildings))if(this._buildings[c])for(let m of d.floorIds)this._buildings[c].floorIds.add(m),this._buildings[c].floors[m]?this._mergeFloors(this._buildings[c].floors[m],d.floors[m]):(this._buildings[c].floors[m]=d.floors[m],o=!0);else this._buildings[c]=d,o=!0;o&&this._recalculateActiveFloors()}getIndoorTileOptions(t,o){return this._indoorState?{sourceLayers:this._style.getIndoorSourceLayers(t,o),indoorState:this._indoorState}:null}getControlState(){let t=this._buildings,o=this._closestBuildingId,c=o&&t?t[o]:void 0;if(!c)return{selectedFloorId:null,activeFloorsVisible:!!this._indoorState&&this._indoorState.activeFloorsVisible,floors:[]};let d=null;for(let _ of c.floorIds)if(this._activeFloors&&this._activeFloors.has(_)){d=_;break}let m=Array.from(c.floorIds).map(_=>({id:_,name:c.floors[_].name,zIndex:c.floors[_].zIndex})).sort((_,y)=>y.zIndex-_.zIndex).filter((_,y,v)=>y===0||_.zIndex!==v[y-1].zIndex);return{selectedFloorId:d,activeFloorsVisible:!!this._indoorState&&this._indoorState.activeFloorsVisible,floors:m}}_updateUI(){this._initialLoadDone=!0;let t=this._style.map.transform,o=this._buildingDetectionStrategy.findClosestBuilding(this._buildings,t.center,t.zoom,t.getBounds(),this._makeViewportPolygon());if(o!==this._closestBuildingId){let c=this._closestBuildingId;this._closestBuildingId=o,this._onBuildingTransition(c,o),this._updateIndoorSelector()}}_onBuildingTransition(t,o){if(!this._indoorState)return;!o&&t?(this._indoorState.activeFloors=new Set,this._indoorState.activeFloorsVisible=!1,this._style.updateIndoorDependentLayers()):!!o&&!t&&(this._recalculateActiveFloors(),this._updateActiveFloors(!0))}_updateIndoorSelector(){this.fire(new h.z("selector-update",this.getControlState()))}
8_updateActiveFloors(t){this._indoorState={selectedFloorId:this._selectedFloorId,activeFloorsVisible:t,activeFloors:this._activeFloors},this._initialLoadDone?this._style.updateIndoorDependentLayers():this._indoorState.needsUpdate=!0}_recalculateActiveFloors(){if(!this._buildings)return;let t=h.d3.calculate(this._buildings,this._selectedFloorId,this._activeFloors);(function(o,c){if(o===c)return!0;if(!o||!c||o.size!==c.size)return!1;for(let d of o)if(!c.has(d))return!1;return!0})(t,this._activeFloors)||(this._activeFloors=t,this._updateActiveFloors(!!this._indoorState&&this._indoorState.activeFloorsVisible),this._updateIndoorSelector())}_mergeFloors(t,o){o.geometry&&(t.geometry?(t.geometry.type==="Polygon"&&(t.geometry={type:"MultiPolygon",coordinates:[t.geometry.coordinates]}),o.geometry.type==="Polygon"?t.geometry.coordinates.push(o.geometry.coordinates):o.geometry.type==="MultiPolygon"&&t.geometry.coordinates.push(...o.geometry.coordinates)):t.geometry=o.geometry)}_makeViewportPolygon(){let t=this._style.map.transform,o=t.width,c=t.height;return[t.pointLocation(new h.P(0,0)),t.pointLocation(new h.P(o,0)),t.pointLocation(new h.P(o,c)),t.pointLocation(new h.P(0,c))].map(d=>new h.P(d.lng,d.lat))}}let tr=(a,t)=>ma(a,t&&t.filter(o=>o.identifier!=="source.canvas")),wf=h.aK(Wt,["addLayer","removeLayer","setLights","setPaintProperty","setLayoutProperty","setLayerProperty","setSlot","setFilter","addSource","removeSource","setLayerZoomRange","setLight","setTransition","setGeoJSONSourceData","setTerrain","setFog","setSnow","setRain","setProjection","setCamera","addImport","removeImport","updateImport","addIconset","removeIconset"]),id=h.aK(Wt,["setCenter","setZoom","setBearing","setPitch"]),Ou=new Set(["background","sky","slot","custom"]),ml=new Set(["building"]),Ic={version:8,layers:[],sources:{}},Ec={duration:300,delay:0};class Fr extends h.E{constructor(t,o={}){if(super(),this.map=t,this.scope=o.scope||"",this.globalId=null,this.fragments=[],this.importDepth=o.importDepth||0,this.importsCache=o.importsCache||new Map,this.resolvedImports=o.resolvedImports||new Set,this.transition=Object.assign({},Ec),this._buildingIndex=new bu(this),this.crossTileSymbolIndex=new Ta,this._mergedOrder=[],this._drapedFirstOrder=[],this._mergedLayers={},this._mergedIndoor={},this._mergedSourceCaches={},this._mergedOtherSourceCaches={},this._mergedSymbolSourceCaches={},this._mergedFillExtrusionSourceCaches={},this._clipLayerPresent=!1,this._hasAppearances=!1,this._has3DLayers=!1,this._hasCircleLayers=!1,this._hasSymbolLayers=!1,this._importedAsBasemap=!1,this._changes=o.styleChanges||new _r,this._hasDataDrivenEmissive=!1,this.indoorManager=new fl(this),this.dispatcher=o.dispatcher?o.dispatcher:new Ss(sl(),this),this.map.painter&&this.map.painter.context){let d=this.map.painter.context.maxUniformBufferBindings,m=Math.floor(this.map.painter.context.maxUniformBlockSize/4);this.dispatcher.broadcast("setContextParams",{maxBindingPoints:d,maxUniformBlockSizeDwords:m,disableSymbolUBO:this.map.painter.context.disableSymbolUBO})}o.imageManager?this.imageManager=o.imageManager:(this.imageManager=new Mt(this.map._spriteFormat),this.imageManager.setEventedParent(this)),this.imageManager.addScope(this.scope),this.glyphManager=o.glyphManager?o.glyphManager:new h.d4(t._requestManager,o.localFontFamily?h.d5.all:o.localIdeographFontFamily?h.d5.ideographs:h.d5.none,o.localFontFamily||o.localIdeographFontFamily,o.fontstackCompositing),o.modelManager?this.modelManager=o.modelManager:(this.modelManager=new $_(t._requestManager),this.modelManager.setEventedParent(this)),this._layers={},this._sourceCaches={},this._otherSourceCaches={},this._symbolSourceCaches={},this._fillExtrusionSourceCaches={},this._loaded=!1,this._initialBroadcastDone=!1,this._programPrecompiler=this.map._precompilePrograms&&this.isRootStyle()?new q_:null,this._availableImages=[],this._availableModels={},this._order=[],this._markersNeedUpdate=!1,this.options=o.configOptions?o.configOptions:new Map,this._configDependentLayers=o.configDependentLayers?o.configDependentLayers:new Set,this._indoorDependentLayers=o.indoorDependentLayers?o.indoorDependentLayers:new Set,this._config=o.config,this._styleColorTheme={lut:null,lutLoading:!1,lutLoadingCorrelationID:0,colorTheme:null,colorThemeOverride:o.colorThemeOverride},this._styleColorThemeForScope={},this._initialConfig=o.initialConfig,this.dispatcher.broadcast("setReferrer",h.d6()),this.dispatcher.broadcast("setConfig",h.d7());let c=this;this._rtlTextPluginCallback=Fr.registerForPluginStateChange(d=>{c.dispatcher.broadcast("syncRTLPluginState",{pluginStatus:d.pluginStatus,pluginURL:d.pluginURL},(m,_)=>{if(h.d8(m),_&&_.every(y=>y))for(let y in c._sourceCaches){let v=c._sourceCaches[y],T=v.getSource().type;T!=="vector"&&T!=="geojson"||v.reload()}})}),this.on("data",d=>{if(d.dataType!=="source"||d.sourceDataType!=="metadata")return;let m=this.getOwnSource(d.sourceId);if(m&&m.vectorLayerIds)for(let _ in this._layers){let y=this._layers[_];
8y.source===m.id&&this._validateLayer(y)}})}load(t){return t?(typeof t=="string"?this.loadURL(t):this.loadJSON(t),this):this}_getGlobalId(t){if(!t)return null;if(typeof t=="string"){if(h.e(t))return t;let o=h.d9(t);if(!o.startsWith("http"))try{return new URL(o,location.href).toString()}catch{return o}return o}return`json://${h.da(JSON.stringify(t))}`}_diffStyle(t,o,c){this.globalId=this._getGlobalId(t);let d=(m,_)=>{try{_(null,this.setState(m,c))}catch(y){_(y,!1)}};if(typeof t=="string"){let m=this.map._requestManager.normalizeStyleURL(t),_=this.map._requestManager.transformRequest(m,h.R.Style);h.m(_,(y,v)=>{y?this.fire(new h.y(y)):v&&d(v,o)})}else typeof t=="object"&&d(t,o)}loadURL(t,o={}){this.fire(new h.z("dataloading",{dataType:"style"}));let c=typeof o.validate=="boolean"?o.validate:!h.e(t);this.globalId=this._getGlobalId(t),t=this.map._requestManager.normalizeStyleURL(t,o.accessToken),this.resolvedImports.add(t);let d=this.importsCache.get(t);if(d)return this._load(d,c);let m=this.map._requestManager.transformRequest(t,h.R.Style);this._request=h.m(m,(_,y)=>{if(this._request=null,_)this.fire(new h.y(_));else if(y)return this.importsCache.set(t,y),this._load(y,c)})}loadJSON(t,o={}){this.fire(new h.z("dataloading",{dataType:"style"})),this.globalId=this._getGlobalId(t),this._request=h.o.frame(()=>{this._request=null,this._load(t,o.validate!==!1)})}loadEmpty(){this.fire(new h.z("dataloading",{dataType:"style"})),this._load(Ic,!1)}_loadImports(t,o,c){if(this.importDepth>=4)return h.w("Style doesn't support nesting deeper than 5"),Promise.resolve();let d=[];for(let m of t){let _=this._createFragmentStyle(m),y=new Promise(I=>{_.once("style.import.load",I),_.once("error",I)}).then(()=>{this.mergeAll(),this.fire(new h.z("data",{dataType:"style"}))});if(d.push(y),this.resolvedImports.has(m.url)){_.loadEmpty();continue}let v=m.data||this.importsCache.get(m.url);v?(m.data?(_.fire(new h.z("dataloading",{dataType:"style"})),_.globalId=_._getGlobalId(v),queueMicrotask(()=>_._load(v,o))):_.loadJSON(v,{validate:o}),this._isInternalStyle(v)&&(_.globalId=null)):m.url?_.loadURL(m.url,{validate:o}):_.loadEmpty();let T={style:_,id:m.id,config:m.config};if(c){let I=this.fragments.findIndex(({id:P})=>P===c);this.fragments=this.fragments.slice(0,I).concat(T).concat(this.fragments.slice(I))}else this.fragments.push(T)}return Promise.allSettled(d)}getImportGlobalIds(t=this,o=new Set){for(let c of t.fragments)c.style.globalId&&o.add(c.style.globalId),this.getImportGlobalIds(c.style,o);return[...o.values()]}_createFragmentStyle(t){let o=this.scope?h.t(t.id,this.scope):t.id,c,d=this._initialConfig&&this._initialConfig[o];(t.config||d)&&(c=Object.assign({},t.config,d));let m=new Fr(this.map,{scope:o,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:c,configOptions:this.options,colorThemeOverride:t["color-theme"],configDependentLayers:this._configDependentLayers,indoorDependentLayers:this._indoorDependentLayers});return m.setEventedParent(this.map,{style:m}),m}_reloadImports(t=!1){this.mergeAll(),this._updateMapProjection(),t||this.updateConfigDependencies(),this._updateLayers(this._indoorDependentLayers),this.map._triggerCameraUpdate(this.camera),(!t||this.isRootStyle()||this.map.style._initialBroadcastDone)&&(t&&this.isRootStyle()?(this.forEachFragmentStyle(o=>{this.dispatcher.broadcast("setLayers",{layers:o._serializeLayers(o._order),scope:o.scope,options:o.options})}),this._initialBroadcastDone=!0):this.dispatcher.broadcast("setLayers",{layers:this._serializeLayers(this._order),scope:this.scope,options:this.options}))}_isInternalStyle(t){return this.isRootStyle()&&(t.fragment||!!t.schema&&t.fragment!==!1)}_load(t,o){if(this._isInternalStyle(t)){let m=Object.assign({},Ic,{imports:[{id:"basemap",data:t,url:""}]},t.center?{center:t.center}:{},t.bearing?{bearing:t.bearing}:{},t.pitch?{pitch:t.pitch}:{},t.zoom?{zoom:t.zoom}:{},t.light?{light:t.light}:{});return this._importedAsBasemap=!0,void this._load(m,o)}
8if(this.updateConfig(this._config,t.schema),o&&tr(this,xn(t)))return;this._loaded=!0;for(let m in t.sources)this.addSource(m,t.sources[m],{validate:!1,isInitialLoad:!0});this.stylesheet=h.db(t);let c=()=>{if(t.iconsets)for(let v in t.iconsets)this.addIconset(v,t.iconsets[v]);t.sprite?this._loadIconset(t.sprite):(this.imageManager.setLoaded(!0,this.scope),this.dispatcher.broadcast("spriteLoaded",{scope:this.scope,isLoaded:!0})),!this.glyphManager.url&&t.glyphs&&this.glyphManager.setURL(t.glyphs);let m=on(this.stylesheet.layers);if(this._order=m.map(v=>v.id),this.stylesheet.light&&h.w("The `light` root property is deprecated, prefer using `lights` with `flat` light type instead."),this.stylesheet.lights)if(this.stylesheet.lights.length===1&&this.stylesheet.lights[0].type==="flat"){let v=this.stylesheet.lights[0];this.light=new jh(v.properties,v.id)}else this.setLights(this.stylesheet.lights);this.light||(this.light=new jh(this.stylesheet.light)),this._layers={};for(let v of m){let T=h.dh(v,this.scope,this._styleColorTheme.lut,this.options);T.expressionDependencies.configDependencies.size!==0&&this._configDependentLayers.add(T.fqid),T.expressionDependencies.isIndoorDependent&&this._indoorDependentLayers.add(T.fqid),this._hasAppearances=this._hasAppearances||T.getAppearances().length!==0,T.setEventedParent(this,{layer:{id:T.id}}),this._layers[T.id]=T;let I=this.getOwnLayerSourceCache(T),P=!!this.directionalLight&&this.directionalLight.shadowsEnabled();I&&T.canCastShadows()&&P&&(I.castsShadows=!0)}if(this.glyphManager.url){let v=new Set;for(let T in this._layers){let I=this._layers[T];if(I.type==="symbol"&&I.layout){let P=I.layout.get("text-font");P&&P.value&&P.value.kind==="constant"&&v.add(P.value.value.join(","))}}for(let T of v)this.glyphManager.prefetchRange(T,0)}this.stylesheet.featuresets&&this.setFeaturesetSelectors(this.stylesheet.featuresets),this.stylesheet.models&&this.addModelURLs(this.stylesheet.models);let _=this.stylesheet.terrain;_&&(this.checkCanvasFingerprintNoise(),this.disableElevatedTerrain||this.terrainSetForDrapingOnly()||this._createTerrain(_,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 h.z("data",{dataType:"style"}));let y=this.isRootStyle();t.imports?this._loadImports(t.imports,o).then(()=>{this._reloadImports(!0),this.fire(new h.z(y?"style.load":"style.import.load"))}).catch(v=>{this.fire(new h.y(new Error("Failed to load imports",v))),this.fire(new h.z(y?"style.load":"style.import.load"))}):(this._reloadImports(!0),this.fire(new h.z(y?"style.load":"style.import.load")))};this._styleColorTheme.colorTheme=this.stylesheet["color-theme"];let d=this._styleColorTheme.colorThemeOverride?this._styleColorTheme.colorThemeOverride:this._styleColorTheme.colorTheme;if(d){let m=this._evaluateColorThemeData(d);this._loadColorTheme(m).then(()=>{c()}).catch(_=>{h.w(`Couldn't load color theme from the stylesheet: ${_}`),c()})}else this._styleColorTheme.lut=null,c()}isRootStyle(){return this.importDepth===0}hasAppearances(){return this._hasAppearances||this.fragments.some(t=>t.style.hasAppearances())}mergeAll(){let t,o,c,d,m,_,y,v,T,I,P={};this.terrain&&this.terrain.scope!==this.scope&&delete this.terrain,this.forEachFragmentStyle(A=>{if(A.stylesheet){if(A.disableElevatedTerrain&&(this.disableElevatedTerrain=!0),A.light!=null&&(t=A.light),A.stylesheet.lights)for(let D of A.stylesheet.lights)D.type==="ambient"&&A.ambientLight!=null&&(o=A.ambientLight),D.type==="directional"&&A.directionalLight!=null&&(c=A.directionalLight);d=this._prioritizeTerrain(d,A.terrain,A.stylesheet.terrain),A.stylesheet.fog&&A.fog!=null&&(m=A.fog),A.stylesheet.snow&&A.snow!=null&&(_=A.snow),A.stylesheet.rain&&A.rain!=null&&(y=A.rain),A.stylesheet.camera!=null&&(I=A.stylesheet.camera),A.stylesheet.projection!=null&&(v=A.stylesheet.projection),A.stylesheet.transition!=null&&(T=A.stylesheet.transition),P[A.scope]=A._styleColorTheme}}),this.light=t,this.ambientLight=o,this.directionalLight=c,this.fog=m,this.snow=_,this.rain=y,this._styleColorThemeForScope=P,d===null?delete this.terrain:this.terrain=d,this.camera=I||{"camera-projection":"perspective"},this.projection=v||{name:"mercator"},this.transition=Object.assign({},Ec,T),this.mergeSources(),this.mergeLayers(),this.mergeIndoor(),this._programPrecompiler&&this._programPrecompiler.reset()}forEachFragmentStyle(t){let o=c=>
8{for(let d of c.fragments)o(d.style);t(c)};o(this)}_prioritizeTerrain(t,o,c){let d=t&&t.drapeRenderMode===0;return c===null?o&&o.drapeRenderMode===0?o:d?t:null:o!=null&&(!t||d||o&&o.drapeRenderMode===1)?o:t}mergeTerrain(){let t;this.terrain&&this.terrain.scope!==this.scope&&delete this.terrain,this.forEachFragmentStyle(o=>{t=this._prioritizeTerrain(t,o.terrain,o.stylesheet.terrain)}),t===null?delete this.terrain:this.terrain=t,this._programPrecompiler&&this._programPrecompiler.reset()}mergeProjection(){let t;this.forEachFragmentStyle(o=>{o.stylesheet.projection!=null&&(t=o.stylesheet.projection)}),this.projection=t||{name:"mercator"},this._programPrecompiler&&this._programPrecompiler.reset()}mergeSources(){let t={},o={},c={},d={};this.forEachFragmentStyle(m=>{for(let _ in m._sourceCaches){let y=h.t(_,m.scope);t[y]=m._sourceCaches[_]}for(let _ in m._otherSourceCaches){let y=h.t(_,m.scope);o[y]=m._otherSourceCaches[_]}for(let _ in m._symbolSourceCaches){let y=h.t(_,m.scope);c[y]=m._symbolSourceCaches[_]}for(let _ in m._fillExtrusionSourceCaches){let y=h.t(_,m.
8scope);d[y]=m._fillExtrusionSourceCaches[_]}}),this._mergedSourceCaches=t,this._mergedOtherSourceCaches=o,this._mergedSymbolSourceCaches=c,this._mergedFillExtrusionSourceCaches=d}mergeIndoor(){this.forEachFragmentStyle(t=>{if(t.stylesheet&&t.stylesheet.indoor)for(let o of Object.values(t.stylesheet.indoor)){let c=o,d=h.t(c.sourceId,t.scope);this._mergedIndoor[d]=new Set(c.sourceLayers||[])}})}mergeLayers(){let t={},o=[],c={};this._mergedSlots=[],this._has3DLayers=!1,this._hasCircleLayers=!1,this._hasSymbolLayers=!1,this.forEachFragmentStyle(_=>{for(let y of _._order){let v=_._layers[y];if(v.type==="slot"){let T=h.dc(y);if(t[T])continue;t[T]=[]}v.slot&&t[v.slot]?t[v.slot].push(v):o.push(v)}}),this._mergedOrder=[];let d=-1,m=(_=[])=>{for(let y of _)if(y.type==="slot"){let v=h.dc(y.id);t[v]&&m(t[v]),this._mergedSlots.push(v)}else{let v=h.t(y.id,y.scope);this._mergedOrder.push(v),c[v]=y,y.is3D(!!this.terrain)&&(this._has3DLayers=!0,d=this._mergedOrder.length-1),y.type==="circle"&&(this._hasCircleLayers=!0),y.type==="symbol"&&(this._hasSymbolLayers=!0),y.type==="clip"&&(this._clipLayerPresent=!0)}};if(m(o),this._has3DLayers){let _={};for(let y=0;y<this._mergedOrder.length;++y){let v=this._mergedOrder[y];_[v]=y===d?1:y<d?c[v].hasOcclusionOpacityProperties?2:0:4}this._mergedOrder.sort((y,v)=>_[y]-_[v])}this._mergedLayers=c,this.updateDrapeFirstLayers(),this._buildingIndex.processLayersChanged(),this._updateDataDrivenEmissiveStrength()}terrainSetForDrapingOnly(){return!!this.terrain&&this.terrain.drapeRenderMode===0}getCamera(){return this.stylesheet.camera}setCamera(t){return this.stylesheet.camera=Object.assign({},this.stylesheet.camera,t),this.camera=this.stylesheet.camera,this}_evaluateColorThemeData(t){return t.data?function(o,c,d){let m=Object.assign({},c);for(let y of Object.keys(Ru))m[y]===void 0&&(m[y]=Ru[y].default);let _=new h.a7(td,o,new Map(d));return _.setTransitionOrValue(m,d),_.untransitioned().possiblyEvaluate(new h.ab(0,{worldview:void 0}))}(this.scope,t,this.options).get("data"):null}_loadColorTheme(t){this._styleColorTheme.lutLoading=!0,this._styleColorTheme.lutLoadingCorrelationID+=1;let o=this._styleColorTheme.lutLoadingCorrelationID;return new Promise((c,d)=>{let m="data:image/png;base64,";if(!t||t.length===0)return this._styleColorTheme.lut=null,this._styleColorTheme.lutLoading=!1,void c();let _=t;_.startsWith(m)||(_=m+_);let y=h.I.from("mapbox-reserved-lut"),v=new Image;v.src=_,v.onerror=()=>{this._styleColorTheme.lutLoading=!1,d(new Error("Failed to load image data"))},v.onload=()=>{if(this._styleColorTheme.lutLoadingCorrelationID!==o)return void c();this._styleColorTheme.lutLoading=!1;let{width:T,height:I,data:P}=h.o.getImageData(v);if(I>32)return void d(new Error("The height of the image must be less than or equal to 32 pixels."));if(T!==I*I)return void d(new Error("The width of the image must be equal to the height squared."));this.getImage(y)&&this.removeImage(y),this.addImage(y,{data:new h.q({width:T,height:I},P),pixelRatio:1,sdf:!1,usvg:!1,version:0});let A=this.imageManager.getImage(y,this.scope);A?(this._styleColorTheme.lut={image:A.data,data:t},c()):d(new Error("Missing LUT image."))}})}getLut(t){let o=this._styleColorThemeForScope[t];return o?o.lut:null}setProjection(t){t?this.stylesheet.projection=t:delete this.stylesheet.projection,this.mergeProjection(),this._updateMapProjection()}applyProjectionUpdate(){this._loaded&&(this.dispatcher.broadcast("setProjection",this.map.transform.projectionOptions),this.map.transform.projection.requiresDraping?(this.getTerrain()||this.stylesheet.terrain)&&!this.disableElevatedTerrain||this.setTerrainForDraping():this.terrainSetForDrapingOnly()&&this.setTerrain(null,0))}_updateMapProjection(){this.isRootStyle()&&(this.map._useExplicitProjection?this.applyProjectionUpdate():this.map._prioritizeAndUpdateProjection(null,this.projection))}_loadSprite(t){this._spriteRequest=function(o,c,d){let m,_,y,v=h.o.devicePixelRatio>1?"@2x":"",T=h.m(c.transformRequest(c.normalizeSpriteURL(o,v,".json"),h.R.SpriteJSON),(A,D)=>{T=null,y||(y=A,m=D,P())}),I=h.n(c.transformRequest(c.normalizeSpriteURL(o,v,".png"),h.R.SpriteImage),(A,D)=>{I=null,y||(y=A,_=D,P())});function P(){if(y)d(y);else if(m&&_){let A=h.o.getImageData(_),D={};for(let L in m){let{width:O,height:k,x:N,y:q,sdf:Z,pixelRatio:G,stretchX:re,stretchY:te,content:se}=m[L],K=new h.q({width:O,height:k});h.q.copy(A,K,{x:N,y:q},{x:0,y:0},{width:O,height:k},null),D[L]={data:K,pixelRatio:G!==void 0?G:1,sdf:Z!==void 0&&Z,stretchX:re,stretchY:te,content:se,usvg:!1,version:0}}d(null,D)}}return{cancel(){T&&(T.cancel(),T=null),I&&(I.cancel(),I=null)}}}(t,this.map._requestManager,(o,c)=>{if(this._spriteRequest=null,o)this.fire(new h.y(o));else if(c){let d=new Map;for(let m in c)d.set(h.I.from(m),c[m]);this.addImages(d)}this.imageManager.setLoaded(!0,this.scope),this.dispatcher.broadcast("spriteLoaded",{scope:this.scope,isLoaded:!0}),this.fire(new h.z("data",{dataType:"style"}))})}
8addIconset(t,o){if(o.type==="sprite")return void this._loadSprite(o.url);let c=this.getOwnSourceCache(o.source);if(!c)return void this.fire(new h.y(new Error(`Source "${o.source}" as specified by iconset "${t}" does not exist and cannot be used as an iconset source`)));let d=c.getSource();if(d.type!=="raster-array")return void this.fire(new h.y(new Error(`Source "${o.source}" as specified by iconset "${t}" is not a "raster-array" source and cannot be used as an iconset source`)));d.partial=!1;let m=new Aa(t,this.scope,c);this.imageManager.addImageProvider(m,this.scope)}removeIconset(t){this.imageManager.removeImageProvider(t,this.scope)}_loadIconset(t){if(!h.e(t)&&this.map._spriteFormat!=="icon_set"||this.map._spriteFormat==="raster")return void this._loadSprite(t);let o=this.map._spriteFormat==="auto";var c,d;this._spriteRequest=(d=(m,_)=>{if(this._spriteRequest=null,m)o?this._loadSprite(t):this.fire(new h.y(m));else if(_){let y=new Map;for(let v in _)y.set(h.I.from(v),_[v]);this.addImages(y)}this.imageManager.setLoaded(!0,this.scope),this.dispatcher.broadcast("spriteLoaded",{scope:this.scope,isLoaded:!0}),this.fire(new h.z("data",{dataType:"style"}))},h.b4((c=this.map._requestManager).transformRequest(c.normalizeIconsetURL(t),h.R.Iconset),(m,_)=>{if(m)return void d(m);let y={},v=new h.b2(_).readFields(Ja,{icons:[]},void 0);for(let T of v.icons){let I={version:1,pixelRatio:h.o.devicePixelRatio,content:zu(T),stretchX:T.metadata?Lu(T.metadata.stretch_x_areas):void 0,stretchY:T.metadata?Lu(T.metadata.stretch_y_areas):void 0,sdf:!1,usvg:!0,icon:T};y[T.name]=I}d(null,y)}))}_validateLayer(t){let o=this.getOwnSource(t.source);if(!o)return;let c=t.sourceLayer;c&&(o.type==="geojson"||o.vectorLayerIds&&!o.vectorLayerIds.includes(c))&&this.fire(new h.y(new Error(`Source layer "${c}" does not exist on source "${o.id}" as specified by style layer "${t.id}"`)))}loaded(){if(!this._loaded||Object.keys(this._changes.getUpdatedSourceCaches()).length)return!1;for(let t in this._sourceCaches)if(!this._sourceCaches[t].loaded())return!1;if(!this.imageManager.isLoaded()||this.imageManager.hasPatternsInFlight()||!this.modelManager.isLoaded()||this._styleColorTheme.lutLoading)return!1;for(let{style:t}of this.fragments)if(!t.loaded())return!1;return!0}_serializeImports(){if(this.stylesheet.imports)return this.stylesheet.imports.map((t,o)=>{let c=this.fragments[o];return c&&c.style&&(t.data=c.style.serialize()),t})}_serializeSources(){let t={};for(let o in this._sourceCaches){let c=this._sourceCaches[o].getSource();t[c.id]||(t[c.id]=c.serialize())}return t}_serializeLayers(t){let o=[];for(let c of t){let d=this._layers[c];d&&d.type!=="custom"&&o.push(d.serialize())}return o}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 t in this._sourceCaches)if(this._sourceCaches[t].hasTransition())return!0;for(let t in this._layers)if(this._layers[t].hasTransition())return!0;return!1}_updateDataDrivenEmissiveStrength(){for(let t in this._mergedLayers){let o=this._mergedLayers[t];if(o._transitionablePaint&&o._transitionablePaint._values){let c=o._transitionablePaint._values["line-emissive-strength"];if(c&&c.value&&c.value.isDataDriven())return void(this._hasDataDrivenEmissive=!0)}}this._hasDataDrivenEmissive=!1}hasDataDrivenEmissiveStrength(){return this._hasDataDrivenEmissive}get order(){return this.terrain?this._drapedFirstOrder:this._mergedOrder}_getOrder(t){return t?this.order:this._mergedOrder}isLayerDraped(t){return!!this.terrain&&t.isDraped(this.getLayerSourceCache(t))}_checkLoaded(){if(!this._loaded)throw new Error("Style is not done loading")}_checkLayer(t){let o=this.getOwnLayer(t);if(o)return o;this.fire(new h.y(new Error(`The layer '${t}' does not exist in the map's style.`)))}_checkSource(t){let o=this.getOwnSource(t);if(o)return o;this.fire(new h.y(new Error(`The source '${t}' does not exist in the map's style.`)))}handleIdle(){let t=this.map.painter;t&&(t.context.sweepPendingPrograms(),this._programPrecompiler&&this._programPrecompiler.processQueue(t,this))}handleContextLost(){this._programPrecompiler&&this._programPrecompiler.reset()}update(t){if(!this._loaded)return;this.ambientLight&&this.ambientLight.recalculate(t),this.directionalLight&&this.directionalLight.recalculate(t);let o=this.calculateLightsBrightness();t.brightness=o||0,o!==this._brightness&&(this._brightness=o,this.dispatcher.broadcast("setBrightness",o)),t.worldview!==this._worldview&&(this._worldview=t.worldview,this.dispatcher.broadcast("setWorldview",this._worldview));let c=this._changes.isDirty(),d=!1;if(this._changes.isDirty()){let v=this._changes.getLayerUpdatesByScope();for(let T in v){let{updatedIds:I,removedIds:P}=v[T];(I||P)&&(this._updateWorkerLayers(T,I,P),d=!0)}this.updateSourceCaches(),this._updateTilesForChangedImages(),this.updateLayers(t),this.light&&this.light.updateTransitions(t),this.ambientLight&&this.ambientLight.updateTransitions(t),this.directionalLight&&this.directionalLight.updateTransitions(t),this.fog&&this.fog.updateTransitions(t),this.snow&&this.snow.updateTransitions(t),this.rain&&this.rain.updateTransitions(t),this._changes.reset()}let m={};for(let v in this._mergedSourceCaches){let T=this._mergedSourceCaches[v];
8m[v]=T.used,T.used=!1,T.tileCoverLift=0}let _={};for(let v of this._mergedOrder){let T=this._mergedLayers[v];if((T.visibility!=="none"||T.hasTransition())&&T.recalculate(t,this._availableImages),!T.isHidden(t.zoom)){ml.has(T.type)&&h.dd();let I=this.getLayerSourceCache(T);I&&(I.used=!0,I.tileCoverLift=Math.max(I.tileCoverLift,T.tileCoverLift()))}if(T.type==="fill-extrusion"){let I=h.t(T.source,T.scope);if(I in this._mergedFillExtrusionSourceCaches){let P=T.layout&&T.layout.get("source-max-zoom");if(P!=null){let A=_[I];_[I]=A==null?P:Math.min(A,P)}}}}if(this._programPrecompiler&&this._programPrecompiler.needsBuild()){let v=this._mergedOrder.map(T=>this._mergedLayers[T]);this._programPrecompiler.buildQueue(v,t,this)}for(let v in this._mergedFillExtrusionSourceCaches)this._mergedFillExtrusionSourceCaches[v].setMaxzoomOverride(_[v]!=null?_[v]:null);this.terrain&&d&&this.mergeLayers();let y=this.imageManager.getPendingImageProviders();for(let v of y)v.sourceCache.used=!0;for(let v in m){let T=this._mergedSourceCaches[v];m[v]!==T.used&&T.getSource().fire(new h.z("data",{sourceDataType:"visibility",dataType:"source",sourceId:T.getSource().id}))}this.light&&this.light.recalculate(t),this.terrain&&this.terrain.recalculate(t),this.fog&&this.fog.recalculate(t),this.snow&&this.snow.recalculate(t),this.rain&&this.rain.recalculate(t),this.z=t.zoom,this._markersNeedUpdate&&(this._updateMarkersOpacity(),this._markersNeedUpdate=!1),this.imageManager.clearUpdatedImages(this.scope),c&&this.fire(new h.z("data",{dataType:"style"}))}updateImageProviders(){let t=this.imageManager.getPendingImageProviders();for(let o of t){let c=o.resolvePendingRequests(),d=this.getFragmentStyle(o.scope);d&&d.addImages(c)}}_updateTilesForChangedImages(){let t={};for(let o in this._mergedSourceCaches){let c=this._mergedSourceCaches[o].getSource().scope;t[c]=t[c]||this._changes.getUpdatedImages(c),t[c].length!==0&&this._mergedSourceCaches[o].reloadTilesForDependencies(["icons","patterns"],t[c])}for(let o in t)this._changes.resetUpdatedImages(o)}_updateWorkerLayers(t,o,c){let d=this.getFragmentStyle(t);d&&this.dispatcher.broadcast("updateLayers",{layers:o?d._serializeLayers(o):[],scope:t,removedIds:c||[],options:d.options})}setState(t,o){if(this._checkLoaded(),tr(this,xn(t)))return!1;(t=h.db(t)).layers=on(t.layers);let c=function(_,y){if(!_)return[{command:Wt.setStyle,args:[y]}];let v=[];try{if(!h.b9(_.version,y.version))return[{command:Wt.setStyle,args:[y]}];if(h.b9(_.center,y.center)||v.push({command:Wt.setCenter,args:[y.center]}),h.b9(_.zoom,y.zoom)||v.push({command:Wt.setZoom,args:[y.zoom]}),h.b9(_.bearing,y.bearing)||v.push({command:Wt.setBearing,args:[y.bearing]}),h.b9(_.pitch,y.pitch)||v.push({command:Wt.setPitch,args:[y.pitch]}),h.b9(_.sprite,y.sprite)||v.push({command:Wt.setSprite,args:[y.sprite]}),h.b9(_.glyphs,y.glyphs)||v.push({command:Wt.setGlyphs,args:[y.glyphs]}),h.b9(_.imports,y.imports)||function(D=[],L=[],O){L=L||[];let k=(D=D||[]).map(va),N=L.map(va),q=D.reduce(kn,{}),Z=L.reduce(kn,{}),G=k.slice(),re,te,se,K;for(re=0,te=0;re<k.length;re++)se=k[re],Object.hasOwn(Z,se)?te++:(O.push({command:Wt.removeImport,args:[se]}),G.splice(G.indexOf(se,te),1));for(re=0,te=0;re<N.length;re++)se=N[N.length-1-re],G[G.length-1-re]!==se&&(Object.hasOwn(q,se)?(O.push({command:Wt.removeImport,args:[se]}),G.splice(G.lastIndexOf(se,G.length-te),1)):te++,K=G[G.length-re],O.push({command:Wt.addImport,args:[Z[se],K]}),G.splice(G.length-re,0,se));for(let J of L){let oe=q[J.id];oe&&(delete oe.data,h.b9(oe,J)||O.push({command:Wt.updateImport,args:[J.id,J]}))}}(_.imports,y.imports,v),h.b9(_.transition,y.transition)||v.push({command:Wt.setTransition,args:[y.transition]}),h.b9(_.light,y.light)||v.push({command:Wt.setLight,args:[y.light]}),h.b9(_.fog,y.fog)||v.push({command:Wt.setFog,args:[y.fog]}),h.b9(_.snow,y.snow)||v.push({command:Wt.setSnow,args:[y.snow]}),h.b9(_.rain,y.rain)||v.push({command:Wt.setRain,args:[y.rain]}),h.b9(_.projection,y.projection)||v.push({command:Wt.setProjection,args:[y.projection]}),h.b9(_.lights,y.lights)||v.push({command:Wt.setLights,args:[y.lights]}),h.b9(_.camera,y.camera)||v.push({command:Wt.setCamera,args:[y.camera]}),h.b9(_.iconsets,y.iconsets)||function(D,L,O){let k;for(k in L=L||{},D=D||{}
8)Object.hasOwn(D,k)&&(Object.hasOwn(L,k)||O.push({command:Wt.removeIconset,args:[k]}));for(k in L){if(!Object.hasOwn(L,k))continue;let N=L[k];Object.hasOwn(D,k)?h.b9(D[k],N)||(O.push({command:Wt.removeIconset,args:[k]}),O.push({command:Wt.addIconset,args:[k,N]})):O.push({command:Wt.addIconset,args:[k,N]})}}(_.iconsets,y.iconsets,v),!h.b9(_["color-theme"],y["color-theme"]))return[{command:Wt.setStyle,args:[y]}];let T={},I=[];(function(D,L,O,k){let N;for(N in L=L||{},D=D||{})Object.hasOwn(D,N)&&(Object.hasOwn(L,N)||wu(N,O,k));for(N in L){if(!Object.hasOwn(L,N))continue;let q=L[N];Object.hasOwn(D,N)?h.b9(D[N],q)||(D[N].type==="geojson"&&q.type==="geojson"&&Tu(D,L,N)?O.push({command:Wt.setGeoJSONSourceData,args:[N,q.data]}):_c(N,L,O,k)):al(N,L,O)}})(_.sources,y.sources,I,T);let P=[];_.layers&&_.layers.forEach(D=>{D.source&&T[D.source]?v.push({command:Wt.removeLayer,args:[D.id]}):P.push(D)});let A=_.terrain;A&&T[A.source]&&(v.push({command:Wt.setTerrain,args:[void 0]}),A=void 0),v=v.concat(I),h.b9(A,y.terrain)||v.push({command:Wt.setTerrain,args:[y.terrain]}),function(D,L,O){L=L||[];let k=(D=D||[]).map(va),N=L.map(va),q=D.reduce(kn,{}),Z=L.reduce(kn,{}),G=k.slice(),re=Object.create(null),te,se,K,J,oe,ue,de;for(te=0,se=0;te<k.length;te++)K=k[te],Object.hasOwn(Z,K)?se++:(O.push({command:Wt.removeLayer,args:[K]}),G.splice(G.indexOf(K,se),1));for(te=0,se=0;te<N.length;te++)K=N[N.length-1-te],G[G.length-1-te]!==K&&(Object.hasOwn(q,K)?(O.push({command:Wt.removeLayer,args:[K]}),G.splice(G.lastIndexOf(K,G.length-se),1)):se++,ue=G[G.length-te],O.push({command:Wt.addLayer,args:[Z[K],ue]}),G.splice(G.length-te,0,K),re[K]=!0);for(te=0;te<N.length;te++)if(K=N[te],J=q[K],oe=Z[K],!re[K]&&!h.b9(J,oe))if(h.b9(J.source,oe.source)&&h.b9(J["source-layer"],oe["source-layer"])&&h.b9(J.type,oe.type)){for(de in ll(J.layout,oe.layout,O,K,null,Wt.setLayoutProperty),ll(J.paint,oe.paint,O,K,null,Wt.setPaintProperty),h.b9(J.slot,oe.slot)||O.push({command:Wt.setSlot,args:[K,oe.slot]}),h.b9(J.filter,oe.filter)||O.push({command:Wt.setFilter,args:[K,oe.filter]}),h.b9(J.minzoom,oe.minzoom)&&h.b9(J.maxzoom,oe.maxzoom)||O.push({command:Wt.setLayerZoomRange,args:[K,oe.minzoom,oe.maxzoom]}),J)Object.hasOwn(J,de)&&de!=="layout"&&de!=="paint"&&de!=="filter"&&de!=="metadata"&&de!=="minzoom"&&de!=="maxzoom"&&de!=="slot"&&(de.indexOf("paint.")===0?ll(J[de],oe[de],O,K,de.slice(6),Wt.setPaintProperty):h.b9(J[de],oe[de])||O.push({command:Wt.setLayerProperty,args:[K,de,oe[de]]}));for(de in oe)Object.hasOwn(oe,de)&&!Object.hasOwn(J,de)&&de!=="layout"&&de!=="paint"&&de!=="filter"&&de!=="metadata"&&de!=="minzoom"&&de!=="maxzoom"&&de!=="slot"&&(de.indexOf("paint.")===0?ll(J[de],oe[de],O,K,de.slice(6),Wt.setPaintProperty):h.b9(J[de],oe[de])||O.push({command:Wt.setLayerProperty,args:[K,de,oe[de]]}))}else O.push({command:Wt.removeLayer,args:[K]}),ue=G[G.lastIndexOf(K)+1],O.push({command:Wt.addLayer,args:[oe,ue]})}(P,y.layers,v)}catch(T){console.warn("Unable to compute style diff:",T),v=[{command:Wt.setStyle,args:[y]}]}return v}(this.serialize(),t).filter(_=>!(_.command in id));if(c.length===0)return!1;let d=c.filter(_=>!(_.command in wf));if(d.length>0)throw new Error(`Unimplemented: ${d.map(_=>_.command).join(", ")}.`);let m=[];return c.forEach(_=>{m.push(this[_.command](..._.args))}),o&&Promise.all(m).then(o).catch(o),this.stylesheet=t,this.mergeAll(),this.dispatcher.broadcast("setLayers",{layers:this._serializeLayers(this._order),scope:this.scope,options:this.options}),!0}_updateWorkerImages(){this._availableImages=this.imageManager.listImages(this.scope),this.dispatcher.broadcast("setImages",{scope:this.scope,images:this._availableImages})}_updateWorkerModels(){this._availableModels=this.modelManager.getModelURIs(this.scope),this.dispatcher.broadcast("setModels",{scope:this.scope,models:this._availableModels})}addImages(t){if(t.size===0)return this;for(let[o,c]of t.entries()){if(this.getImage(o))return this.fire(new h.y(new Error(`An image with the name "${o.name}" already exists.`)));this.imageManager.addImage(o,this.scope,c),this._changes.updateImage(o,this.scope)}return this._updateWorkerImages(),this.fire(new h.z("data",{dataType:"style"})),this}addImage(t,o){return this.getImage(t)?this.fire(new h.y(new Error(`An image with the name "${t.name}" already exists.`))):(this.imageManager.addImage(t,this.scope,o),this._changes.updateImage(t,this.scope),this._updateWorkerImages(),this.fire(new h.z("data",{dataType:"style"})),this)}updateImage(t,o,c=!1){this.imageManager.updateImage(t,this.scope,o),c&&(this._changes.updateImage(t,this.scope),this._updateWorkerImages(),this.fire(new h.z("data",{dataType:"style"})))}getImage(t){return this.imageManager.getImage(t,this.scope)}removeImage(t){return this.getImage(t)?(this.imageManager.removeImage(t,this.scope),this._changes.updateImage(t,this.scope),this._updateWorkerImages(),this.fire(new h.z("data",{dataType:"style"})),this):this.fire(new h.y(new Error("No image with this name exists.")))}listImages(){return this._checkLoaded(),this._availableImages.slice()}getActualScope(){return this._importedAsBasemap?"basemap":this.scope}addModelURLs(t){return this.modelManager.addModelURLs(t,this.getActualScope()),this._updateWorkerModels(),this.fire(new h.z("data",{dataType:"style"})),this}addModel(t,o,c={}
8){return this._checkLoaded(),this._validate(hc,`models.${t}`,o,null,c)||(this.modelManager.addModel(t,o,this.getActualScope()),this.fire(new h.z("data",{dataType:"style"}))),this}hasModel(t){return this.modelManager.hasModel(t,this.getActualScope())}removeModel(t){return this.hasModel(t)?(this.modelManager.removeModel(t,this.getActualScope(),!1,!0),this.fire(new h.z("data",{dataType:"style"})),this):this.fire(new h.y(new Error("No model with this ID exists.")))}listModels(){return this._checkLoaded(),this.modelManager.listModels(this.getActualScope())}addSource(t,o,c={}){if(this._checkLoaded(),this.getOwnSource(t)!==void 0)throw new Error(`There is already a source with ID "${t}".`);if(!o.type)throw new Error(`The type property must be defined, but only the following properties were given: ${Object.keys(o).join(", ")}.`);if(["vector","raster","geojson","video","image"].includes(o.type)&&this._validate(Jp,`sources.${t}`,o,null,c))return;this.map&&this.map._collectResourceTiming&&(o.collectResourceTiming=!0);let d=qh(t,o,this.dispatcher,this);d.scope=this.scope,d.setEventedParent(this,()=>({isSourceLoaded:this._isSourceCacheLoaded(d.id),source:d.serialize(),sourceId:d.id}));let m=_=>{let y=(_===h.b7.Symbol?"symbol:":_===h.b7.FillExtrusion?"fill-extrusion:":"other:")+d.id,v=h.t(y,this.scope),T=this._sourceCaches[y]=new rn(v,d,_);_===h.b7.Symbol?this._symbolSourceCaches[d.id]=T:_===h.b7.FillExtrusion?this._fillExtrusionSourceCaches[d.id]=T:this._otherSourceCaches[d.id]=T,T.onAdd(this.map)};m(h.b7.Other),o.type!=="vector"&&o.type!=="geojson"||(m(h.b7.Symbol),o.type==="vector"&&m(h.b7.FillExtrusion)),d.onAdd&&d.onAdd(this.map),c.isInitialLoad||(this.mergeSources(),this._changes.setDirty())}removeSource(t){this._checkLoaded();let o=this.getOwnSource(t);if(!o)throw new Error("There is no source with this ID");for(let d in this._layers)if(this._layers[d].source===t)return this.fire(new h.y(new Error(`Source "${t}" cannot be removed while layer "${d}" is using it.`)));if(this.terrain&&this.terrain.scope===this.scope&&this.terrain.get().source===t)return this.fire(new h.y(new Error(`Source "${t}" cannot be removed while terrain is using it.`)));if(this.stylesheet.iconsets){let d=Object.entries(this.stylesheet.iconsets).find(([m,_])=>_.type==="source"&&_.source===t);if(d)return this.fire(new h.y(new Error(`Source "${t}" cannot be removed while iconset "${d[0]}" is using it.`)))}let c=this.getOwnSourceCaches(t);for(let d of c){let m=h.dc(d.id);delete this._sourceCaches[m],this._changes.discardSourceCacheUpdate(d.id),d.fire(new h.z("data",{sourceDataType:"metadata",dataType:"source",sourceId:d.getSource().id})),d.setEventedParent(null),d.clearTiles()}return delete this._otherSourceCaches[t],delete this._symbolSourceCaches[t],delete this._fillExtrusionSourceCaches[t],this.mergeSources(),o.setEventedParent(null),o.onRemove&&o.onRemove(this.map),this._changes.setDirty(),this}setGeoJSONSourceData(t,o){this._checkLoaded(),this.getOwnSource(t).setData(o),this._changes.setDirty()}getOwnSource(t){let o=this.getOwnSourceCache(t);return o&&o.getSource()}getOwnSources(){let t=[];for(let o in this._otherSourceCaches){let c=this.getOwnSourceCache(o);c&&t.push(c.getSource())}return t}areTilesLoaded(){let t=this._mergedSourceCaches;for(let o in t){let c=t[o]._tiles;for(let d in c){let m=c[d];if(m.state!=="loaded"&&m.state!=="errored")return!1}}return!0}setLights(t){if(this._checkLoaded(),this._programPrecompiler&&this._programPrecompiler.reset(),!t)return delete this.ambientLight,void delete this.directionalLight;let o=this._getTransitionParameters();for(let m of t){if(this._validate(Kp,"lights",m))return;switch(m.type){case"ambient":if(this.ambientLight){let _=this.ambientLight;_.set(m),_.updateTransitions(o)}else this.ambientLight=new $h(m,O_(),this.scope,this.options);break;case"directional":if(this.directionalLight){let _=this.directionalLight;_.set(m),_.updateTransitions(o)}else this.directionalLight=new $h(m,Xo(),this.scope,this.options)}}let c=Object.assign(o,{worldview:this.map.getWorldview()}),d=new h.ab(this.z||0,c);this.ambientLight&&this.ambientLight.recalculate(d),this.directionalLight&&this.directionalLight.recalculate(d),this._brightness=this.calculateLightsBrightness(),this.dispatcher.broadcast("setBrightness",this._brightness)}calculateLightsBrightness(){let t=this.directionalLight,o=this.ambientLight;if(!t||!o)return;let c=A=>.2126*(A[0]<=.03928?A[0]/12.92:Math.pow((A[0]+.055)/1.055,2.4))+.7152*(A[1]<=.03928?A[1]/12.92:Math.pow((A[1]+.055)/1.055,2.4))+.0722*(A[2]<=.03928?A[2]/12.92:Math.pow((A[2]+.055)/1.055,2.4)),d=t.properties.get("color").toNonPremultipliedRenderColor(null).toArray01(),m=t.properties.get("intensity"),_=t.properties.get("direction"),y=1-h.cT(_.x,_.y,_.z)[2]/90,v=c(d)*m*y,T=o.properties.get("color").toNonPremultipliedRenderColor(null).toArray01(),I=o.properties.get("intensity"),P=c(T)*I;return Number(((v+P)/2).toFixed(6))}getBrightness(){return this._brightness}getLights(){if(!this.enable3dLights())return null;let t=[];return this.directionalLight&&t.push(this.directionalLight.get()),this.ambientLight&&t.push(this.ambientLight.get()),t}enable3dLights(){return!!this.ambientLight&&!!this.directionalLight}getFragmentStyle(t){if(t==null||t===""&&this.isRootStyle())return this;if(h.de(t)){let o=h.df(t),c=this.fragments.find(({id:m})=>m===o);if(!c)return;let d=h.dc(t);return c.style.getFragmentStyle(d)}{let o=this.fragments.find(({id:c})=>c===t);return o?o.style:void 0}}setFeaturesetSelectors(t){if(!t)return;let o=(c,d="")=>`${c}::${d}`;this._featuresetSelectors={};for(let c in t){let d={},m=this._featuresetSelectors[c]=[];
8for(let _ of t[c].selectors){if(_.featureNamespace){let v=this.getOwnLayer(_.layer);if(!v){h.w(`Layer is undefined for selector: ${_.layer}`);continue}let T=o(v.source,v.sourceLayer);if(T in d&&d[T]!==_.featureNamespace){h.w(`"featureNamespace ${_.featureNamespace} of featureset ${c}'s selector is not associated to the same source, skip this selector`);continue}d[T]=_.featureNamespace}let y;if(_.properties)for(let v in _.properties){let T=h.U(_.properties[v]);T.result==="success"&&(y=y||{},y[v]=T.value)}m.push({layerId:_.layer,namespace:_.featureNamespace,properties:y,uniqueFeatureID:_._uniqueFeatureID})}}}getFeaturesetDescriptors(t){let o=this.getFragmentStyle(t);if(!o||!o.stylesheet.featuresets)return[];let c=[];for(let d in o.stylesheet.featuresets)c.push({featuresetId:d,importId:o.scope?o.scope:void 0});return c}getFeaturesetLayers(t,o){let c=this.getFragmentStyle(o),d=c.stylesheet.featuresets;if(!d||!d[t])return this.fire(new h.y(new Error(`The featureset '${t}' does not exist in the map's style and cannot be queried.`))),[];let m=[];for(let _ of d[t].selectors){let y=c.getOwnLayer(_.layer);y&&m.push(y)}return m}getConfigProperty(t,o){let c=this.getFragmentStyle(t);if(!c)return null;let d=h.t(o,c.scope),m=c.options.get(d),_=m?m.value||m.default:null;return _?_.serialize():null}isIndoorEnabled(){return Object.keys(this._mergedIndoor).length>0}getIndoorSourceLayers(t,o){let c=h.t(t,o);return this._mergedIndoor[c]}setIndoorData(t,o){this.indoorManager.setIndoorData(o)}updateIndoorDependentLayers(){this._updateLayers(this._indoorDependentLayers),this.map._styleDirty=!0,this.map.triggerRepaint()}setConfigProperty(t,o,c){let d=this.getFragmentStyle(t);if(!d)return;let m=d.stylesheet.schema;if(!m||!m[o])return;let _=h.U(c);if(_.result!=="success")return void tr(this,_.value);let y=_.value.expression,v=h.t(o,d.scope),T=d.options.get(v);if(!T)return;let I,{minValue:P,maxValue:A,stepValue:D,type:L,values:O}=m[o],k=h.U(m[o].default);k.result==="success"&&(I=k.value.expression),I?(this.options.set(v,Object.assign({},T,{value:y,default:I,minValue:P,maxValue:A,stepValue:D,type:L,values:O})),this.updateConfigDependencies(o)):this.fire(new h.y(new Error(`No schema defined for the config option "${o}" in the "${t}" fragment.`)))}getConfig(t){let o=this.getFragmentStyle(t);if(!o)return null;let c=o.stylesheet.schema;if(!c)return null;let d={};for(let m in c){let _=h.t(m,o.scope),y=o.options.get(_),v=y?y.value||y.default:null;d[m]=v?v.serialize():null}return d}setConfig(t,o){let c=this.getFragmentStyle(t);c&&(c.updateConfig(o,c.stylesheet.schema),this.updateConfigDependencies())}getSchema(t){let o=this.getFragmentStyle(t);return o?o.stylesheet.schema:null}setSchema(t,o){let c=this.getFragmentStyle(t);c&&(c.stylesheet.schema=o,c.updateConfig(c._config,o),this.updateConfigDependencies())}updateConfig(t,o){if(this._config=t,t||o)if(o)for(let c in o){let d,m,_=h.U(o[c].default);if(_.result==="success"&&(d=_.value.expression),t&&t[c]!==void 0){let A=h.U(t[c]);A.result==="success"&&(m=A.value.expression)}let{minValue:y,maxValue:v,stepValue:T,type:I,values:P}=o[c];if(d){let A=h.t(c,this.scope);this.options.set(A,{default:d,value:m,minValue:y,maxValue:v,stepValue:T,type:I,values:P})}else this.fire(new h.y(new Error(`No schema defined for config option "${c}".`)))}else this.fire(new h.y(new Error("Attempting to set config for a style without schema.")))}_updateLayers(t,o=()=>!0){for(let c of t){let d=this.getLayer(c);d&&o(d)&&(d.possiblyEvaluateVisibility(),this._updateLayer(d),this._changes.setDirty())}}updateConfigDependencies(t){this._updateLayers(this._configDependentLayers,o=>!t||o.expressionDependencies.configDependencies.has(t)),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(o=>{let c=o._styleColorTheme.colorThemeOverride?o._styleColorTheme.colorThemeOverride:o._styleColorTheme.colorTheme;if(c){let d=o._evaluateColorThemeData(c);(!o._styleColorTheme.lut&&d!==""||o._styleColorTheme.lut&&d!==o._styleColorTheme.lut.data)&&o.setColorTheme(c)}}),this._changes.setDirty()}addLayer(t,o,c={}){this._checkLoaded();let d=t.id;if(this._layers[d])return void this.fire(new h.y(new Error(`Layer with i
8d "${d}" already exists on this map`)));let m;if(t.type==="custom"){if(tr(this,h.dg(t)))return;m=h.dh(t,this.scope,this._styleColorTheme.lut,this.options)}else{if(typeof t.source=="object"&&(this.addSource(d,t.source),t=h.db(t),t=Object.assign(t,{source:d})),this._validate(nf,`layers.${d}`,t,{arrayIndex:-1},c))return;m=h.dh(t,this.scope,this._styleColorTheme.lut,this.options),this._validateLayer(m),m.setEventedParent(this,{layer:{id:d}})}let _=h.t(m.source,m.scope);m.expressionDependencies.configDependencies.size!==0&&this._configDependentLayers.add(_),m.expressionDependencies.isIndoorDependent&&this._indoorDependentLayers.add(_);let y=this._order.length;if(o){let P=this._order.indexOf(o);if(P===-1)return void this.fire(new h.y(new Error(`Layer with id "${o}" does not exist on this map.`)));m.slot&&m.slot!==this._layers[o].slot?h.w(`Layer with id "${o}" has a different slot. Layers can only be rearranged within the same slot.`):y=P}this._order.splice(y,0,d),this._handleLayerOrderChange(),this._layers[d]=m;let v=this.getOwnLayerSourceCache(m),T=!!this.directionalLight&&this.directionalLight.shadowsEnabled();v&&m.canCastShadows()&&T&&(v.castsShadows=!0);let I=this._changes.getRemovedLayer(m);if(I&&m.source&&v&&m.type!=="custom"){this._changes.discardLayerRemoval(m);let P=h.t(m.source,m.scope);I.type!==m.type?this._changes.updateSourceCache(P,"clear"):(this._changes.updateSourceCache(P,"reload"),v.pause())}this._updateLayer(m),m.onAdd&&m.onAdd(this.map),m.scope=this.scope,this.mergeLayers()}moveLayer(t,o){this._checkLoaded();let c=this._checkLayer(t);if(!c||t===o)return;let d=this._order.indexOf(t);this._order.splice(d,1);let m=this._order.length;if(o){let _=this._order.indexOf(o);
8if(_===-1)return void this.fire(new h.y(new Error(`Layer with id "${o}" does not exist on this map.`)));c.slot&&c.slot!==this._layers[o].slot?h.w(`Layer with id "${o}" has a different slot. Layers can only be rearranged within the same slot.`):m=_}this._order.splice(m,0,t),this._changes.setDirty(),this._handleLayerOrderChange(),this.mergeLayers()}removeLayer(t){this._checkLoaded();let o=this._checkLayer(t);if(!o)return;o.setEventedParent(null);let c=this._order.indexOf(t);this._order.splice(c,1),delete this._layers[t],this._changes.setDirty(),this._handleLayerOrderChange(),this._configDependentLayers.delete(o.fqid),this._indoorDependentLayers.delete(o.fqid),this._changes.removeLayer(o);let d=this.getOwnLayerSourceCache(o);if(d&&d.castsShadows){let m=!1;for(let _ in this._layers)if(this._layers[_].source===o.source&&this._layers[_].canCastShadows()){m=!0;break}d.castsShadows=m}o.onRemove&&o.onRemove(this.map),this.mergeLayers()}getOwnLayer(t){return this._layers[t]}hasLayer(t){return t in this._mergedLayers}hasLayerType(t){for(let o in this._layers)if(this._layers[o].type===t)return!0;return!1}setLayerZoomRange(t,o,c){this._checkLoaded();let d=this._checkLayer(t);d&&(d.minzoom===o&&d.maxzoom===c||(o!=null&&(d.minzoom=o),c!=null&&(d.maxzoom=c),this._updateLayer(d)))}getSlots(){return this._checkLoaded(),this._mergedSlots}setSlot(t,o){this._checkLoaded();let c=this._checkLayer(t);c&&c.slot!==o&&(c.slot=o,this._updateLayer(c))}setFilter(t,o,c={}){this._checkLoaded();let d=this._checkLayer(t);if(d&&!h.b9(d.filter,o))return o==null?(d.filter=void 0,void this._updateLayer(d)):void(this._validate(fa,`layers.${d.id}.filter`,o,{layerType:d.type},c)||(d.filter=h.db(o),this._updateLayer(d)))}getFilter(t){let o=this._checkLayer(t);if(o)return h.db(o.filter)}setLayoutProperty(t,o,c,d={}){this._checkLoaded();let m=this._checkLayer(t);if(m&&!h.b9(m.getLayoutProperty(o),c)){if(c!=null&&(!d||d.validate!==!1)&&tr(m,Uh.call(xn,{key:`layers.${t}.layout.${o}`,layerType:m.type,objectKey:o,value:c,styleSpec:h.a6,style:{glyphs:!0,sprite:!0}})))return;m.setLayoutProperty(o,c),m.expressionDependencies.configDependencies.size!==0&&this._configDependentLayers.add(m.fqid),m.expressionDependencies.isIndoorDependent&&this._indoorDependentLayers.add(m.fqid),this._updateLayer(m)}}setLayerProperty(t,o,c,d={}){this._checkLoaded();let m=this._checkLayer(t);m&&(o==="appearances"?(m.setAppearances(c),this._updateLayer(m)):m.isPaintProperty(o)?this.setPaintProperty(t,o,c,d):this.setLayoutProperty(t,o,c,d))}getLayoutProperty(t,o){let c=this._checkLayer(t);if(c)return c.getLayoutProperty(o)}setPaintProperty(t,o,c,d={}){this._checkLoaded();let m=this._checkLayer(t);if(!m||h.b9(m.getPaintProperty(o),c)||c!=null&&(!d||d.validate!==!1)&&tr(m,Nh.call(xn,{key:`layers.${t}.paint.${o}`,layerType:m.type,objectKey:o,value:c,styleSpec:h.a6})))return;let _=m.setPaintProperty(o,c);m.expressionDependencies.configDependencies.size!==0&&this._configDependentLayers.add(m.fqid),m.expressionDependencies.isIndoorDependent&&this._indoorDependentLayers.add(m.fqid),_&&this._updateLayer(m),this._changes.updatePaintProperties(m)}getPaintProperty(t,o){let c=this._checkLayer(t);if(c)return c.getPaintProperty(o)}setFeatureState(t,o){if(this._checkLoaded(),"target"in t){if("featuresetId"in t.target){let{featuresetId:v,importId:T}=t.target,I=this.getFragmentStyle(T),P=I.getFeaturesetLayers(v);for(let{source:A,sourceLayer:D}of P)I.setFeatureState({id:t.id,source:A,sourceLayer:D},o)}else if("layerId"in t.target){let{layerId:v}=t.target,T=this.getLayer(v);this.setFeatureState({id:t.id,source:T.source,sourceLayer:T.sourceLayer},o)}return}let c=t.source,d=t.sourceLayer,m=this._checkSource(c);if(!m)return;let _=m.type;if(_==="geojson"&&d)return void this.fire(new h.y(new Error("GeoJSON sources cannot have a sourceLayer parameter.")));if(_==="vector"&&!d)return void this.fire(new h.y(new Error("The sourceLayer parameter must be provided for vector source types.")));t.id===void 0&&this.fire(new h.y(new Error("The feature id parameter must be provided.")));let y=this.getOwnSourceCaches(c);for(let v of y)v.setFeatureState(d,t.id,o)}removeFeatureState(t,o){if(this._checkLoaded(),"target"in t){if("featuresetId"in t.target){let{featuresetId:v,importId:T}=t.target,I=this.getFragmentStyle(T),P=I.getFeaturesetLayers(v);for(let{source:A,sourceLayer:D}of P)I.removeFeatureState({id:t.id,source:A,sourceLayer:D},o)}else if("layerId"in t.target){let{layerId:v}=t.target,T=this.getLayer(v);this.removeFeatureState({id:t.id,source:T.source,sourceLayer:T.sourceLayer},o)}return}let c=t.source,d=this._checkSource(c);if(!d)return;let m=d.type,_=m==="vector"?t.sourceLayer:void 0;if(m==="vector"&&!_)return void this.fire(new h.y(new Error("The sourceLayer parameter must be provided for vector source types.")));if(o&&typeof t.id!="string"&&typeof t.id!="number")return void this.fire(new h.y(new Error("A feature id is required to remove its specific state property.")));let y=this.getOwnSourceCaches(c);for(let v of y)v.removeFeatureState(_,t.id,o)}getFeatureState(t){if(this._checkLoaded(),"target"in t){let m;if("featuresetId"in t.target){let{featuresetId:_,importId:y}=t.target,v=this.getFragmentStyle(y),T=v.getFeaturesetLayers(_);for(let{source:I,sourceLayer:P}of T){let A=v.getFeatureState({id:t.id,source:I,sourceLayer:P});if(A&&!m)m=A;else if(!h.b9(m,A))return void this.fire(new h.y(new Error("The same feature id exists in multiple sources in the featureset, but their feature states are not consistent through the sources.")))}}else if("layerId"in t.target){let{layerId:_}=t.target,y=this.getLayer(_);m=this.getFeatureState({id:t.id,source:y.source,sourceLayer:y.sourceLayer})}return m}let o=t.source,c=t.sourceLayer,d=this._checkSource(o);if(d){if(d.type!=="vector"||c)return t.id===void 0&&this.fire(new h.y(new Error("The feature id parameter must be provided."))),this.getOwnSourceCaches(o)[0].getFeatureState(c,t.id);this.fire(new h.y(new Error("The sourceLayer parameter must be provided for vector source types.")))}}setTransition(t){return this.stylesheet.transition=Object.assign({},this.stylesheet.transition,t),this.transition=this.stylesheet.transition,this}getTransition(){return Object.assign({},this.stylesheet.transition)}setWorldview(t){t!==this._worldview&&(this._worldview=t,this.dispatcher.broadcast("setWorldview",this._worldview),this.reloadSources())}serialize(){this._checkLoaded();let t=this.getTerrain(),o=t&&this.terrain&&this.terrain.scope===this.scope?t:this.stylesheet.terrain;return h.di({version:this.stylesheet.version,name:this.stylesheet.name,metadata:this.stylesheet.metadata,fragment:this.stylesheet.fragment,iconsets:this.stylesheet.iconsets,featuresets:this.stylesheet.featuresets,imports:this._serializeImports(),schema:this.stylesheet.schema,camera:this.stylesheet.camera,light:this.stylesheet.light,lights:this.stylesheet.lights,terrain:o,fog:this.stylesheet.fog,snow:this.stylesheet.snow,rain:this.stylesheet.rain,indoor:this.stylesheet.indoor,center:this.stylesheet.center,"color-theme":this.stylesheet["color-theme"],zoom:this.stylesheet.zoom,bearing:this.stylesheet.bearing,pitch:this.stylesheet.pitch,sprite:this.stylesheet.sprite,glyphs:this.stylesheet.glyphs,transition:this.stylesheet.transition,projection:this.stylesheet.projection,sources:this._serializeSources(),layers:this._serializeLayers(this._order)},c=>c!==void 0)}_updateFilteredLayers(t){for(let o of Object.values(this._mergedLayers))t(o)&&this._updateLayer(o)}_updateLayer(t){this._changes.updateLayer(t);let o=this.getLayerSourceCache(t),c=h.t(t.source,t.scope),d=this._changes.getUpd
8atedSourceCaches();t.source&&!d[c]&&o&&o.getSource().type!=="raster"&&(this._changes.updateSourceCache(c,"reload"),o.pause()),t.invalidateCompiledFilter()}_flattenAndSortRenderedFeatures(t){let o=y=>this._mergedLayers[y].is3D(!!this.terrain),c=this.order,d={},m=[];for(let y=c.length-1;y>=0;y--){let v=c[y];if(o(v)){d[v]=y;for(let T of t){let I=T[v];if(I)for(let P of I)m.push(P)}}}m.sort((y,v)=>v.intersectionZ-y.intersectionZ);let _=[];for(let y=c.length-1;y>=0;y--){let v=c[y];if(o(v))for(let T=m.length-1;T>=0;T--){let I=m[T].feature;if(I.layer&&d[I.layer.id]<y)break;_.push(I),m.pop()}else for(let T of t){let I=T[v];if(I)for(let P of I)_.push(P.feature)}}return _}queryRasterValue(t,o,c){let d=this.getOwnSource(t);return d?d.type!=="raster-array"?(this.fire(new h.y(new Error('queryRasterValue support only "raster-array" sources.'))),Promise.resolve(null)):d.queryRasterArrayValue(o,c):(this.fire(new h.y(new Error(`Source with id "${t}" does not exist in the style.`))),Promise.resolve(null))}queryRenderedFeatures(t,o,c){let d;o&&!Array.isArray(o)&&o.filter&&(this._validate(fa,"queryRenderedFeatures.filter",o.filter,null,o),d=h.dj(o.filter));let m={},_=I=>{if(Ou.has(I.type))return;let P=this.getOwnLayerSourceCache(I),A=m[P.id]=m[P.id]||{sourceCache:P,layers:{},has3DLayers:!1};I.is3D(!!this.terrain)&&(A.has3DLayers=!0),A.layers[I.fqid]=A.layers[I.fqid]||{styleLayer:I,targets:[]},A.layers[I.fqid].targets.push({filter:d})};if(o&&o.layers){if(!Array.isArray(o.layers))return this.fire(new h.y(new Error("parameters.layers must be an Array."))),[];for(let I of o.layers){let P=this._layers[I];if(!P)return this.fire(new h.y(new Error(`The layer '${I}' does not exist in the map's style and cannot be queried for features.`))),[];_(P)}}else for(let I in this._layers)_(this._layers[I]);let y=this._queryRenderedFeatures(t,m,c),v=this._flattenAndSortRenderedFeatures(y),T=[];for(let I of v)h.dk(I.layer.id)===this.scope&&T.push(I);return T}queryRenderedFeatureset(t,o,c){let d;o&&!Array.isArray(o)&&o.filter&&(this._validate(fa,"queryRenderedFeatures.filter",o.filter,null,o),d=h.dj(o.filter));let m="mock",_=[];if(o&&o.target)_.push(Object.assign({},o,{targetId:m,filter:d}));else{let I=this.getFeaturesetDescriptors();for(let P of I)_.push({targetId:m,filter:d,target:P});for(let{style:P}of this.fragments){let A=P.getFeaturesetDescriptors();for(let D of A)_.push({targetId:m,filter:d,target:D})}}let y=this.queryRenderedTargets(t,_,c),v=[],T=new Set;for(let I of y)for(let P of I.variants[m])Zh(P,I,T)||v.push(new h.dl(I,P));return v}queryRenderedTargets(t,o,c){let d={},m=(y,v,T,I)=>{let P=d[v.id]=d[v.id]||{sourceCache:v,layers:{},has3DLayers:!1};if(P.layers[y.fqid]=P.layers[y.fqid]||{styleLayer:y,targets:[]},y.is3D(!!this.terrain)&&(P.has3DLayers=!0),!I)return T.uniqueFeatureID=!1,void P.layers[y.fqid].targets.push(T);P.layers[y.fqid].targets.push(Object.assign({},T,{namespace:I.namespace,properties:I.properties,uniqueFeatureID:I.uniqueFeatureID}))};for(let y of o)if("featuresetId"in y.target){let{featuresetId:v,importId:T}=y.target,I=this.getFragmentStyle(T);if(!I||!I._featuresetSelectors)continue;let P=I._featuresetSelectors[v];if(!P){this.fire(new h.y(new Error(`The featureset '${v}' does not exist in the map's style and cannot be queried for features.`)));continue}for(let A of P){let D=I.getOwnLayer(A.layerId);D&&!Ou.has(D.type)&&m(D,I.getOwnLayerSourceCache(D),y,A)}}else if("layerId"in y.target){let{layerId:v}=y.target,T=this.getLayer(v);if(!T||Ou.has(T.type))continue;m(T,this.getLayerSourceCache(T),y)}let _=this._queryRenderedFeatures(t,d,c);return this._flattenAndSortRenderedFeatures(_)}_queryRenderedFeatures(t,o,c){let d=[],m=!!this.map._showQueryGeometry,_=rl.createFromScreenPoints(t,c);for(let y in o){let v=vu(_,o[y],this._availableImages,c,m,this.getActualScope());Object.keys(v).length&&d.push(v)}if(this.placement)for(let y in o){if(o[y].sourceCache._renderSourceType!==h.b7.Symbol)continue;let v=yo(_.screenGeometry,o[y],this._availableImages,this.placement.collisionIndex,this.placement.retainedQueryData,this.map.getWorldview());Object.keys(v).length&&d.push(v)}return d}querySourceFeatures(t,o){let c=o&&o.filter;
8c&&this._validate(fa,"querySourceFeatures.filter",c,null,o);let d=[],m=this.getOwnSourceCaches(t);for(let _ of m)d=d.concat(Wh(_,o));return d}addSourceType(t,o,c){return Fr.getSourceType(t)?c(new Error(`A source type called "${t}" already exists.`)):(Fr.setSourceType(t,o),c(null,null))}getFlatLight(){return this.light.getLight()}setFlatLight(t,o,c={}){this._checkLoaded();let d=this.light.getLight(),m=!1;for(let y in t)if(!h.b9(t[y],d[y])){m=!0;break}if(!m)return;let _=this._getTransitionParameters();this.light.setLight(t,o,c),this.light.updateTransitions(_)}getTerrain(){return this.terrain&&this.terrain.drapeRenderMode===1?this.terrain.get():null}setTerrainForDraping(){this.setTerrain({source:"",exaggeration:0},0)}checkCanvasFingerprintNoise(){this.disableElevatedTerrain===void 0&&(this.disableElevatedTerrain=h.o.hasCanvasFingerprintNoise(),this.disableElevatedTerrain&&h.w("Terrain and hillshade are disabled because of Canvas2D limitations when fingerprinting protection is enabled (e.g. in private browsing mode)."))}setTerrain(t,o=1){if(this._checkLoaded(),!t)return this.terrainSetForDrapingOnly()||(delete this.terrain,this.map.transform.projection.requiresDraping&&this.setTerrainForDraping()),o===0&&delete this.terrain,t===null?this.stylesheet.terrain=null:delete this.stylesheet.terrain,this._force3DLayerUpdate(),void(this._markersNeedUpdate=!0);this.checkCanvasFingerprintNoise();let c=t,d=!("source"in t)||t.source==null;if(o===1){if(this.disableElevatedTerrain)return;if("source"in c&&typeof c.source=="object"){let y="terrain-dem-src";this.addSource(y,c.source),c=h.db(c),c=Object.assign(c,{source:y})}let m=Object.assign({},c),_={};if(this.terrain&&d){m.source=this.terrain.get().source;let y=this.terrain?this.getFragmentStyle(this.terrain.scope):null;y&&(_.style=y.serialize())}if(this._validate(Qp,"terrain",m,_))return}if(!this.terrain||this.terrain.scope!==this.scope&&!d||this.terrain&&o!==this.terrain.drapeRenderMode){if(!c)return;this._createTerrain(c,o),this.fire(new h.z("data",{dataType:"style"}))}else{let m=this.terrain,_=m.get();for(let y of Object.keys(h.a6.terrain))!Object.hasOwn(c,y)&&h.a6.terrain[y].default&&(c[y]=h.a6.terrain[y].default);for(let y in t)if(!h.b9(t[y],_[y])){m.set(t,this.options),this.stylesheet.terrain=t;let v=this._getTransitionParameters({duration:0});m.updateTransitions(v),this.fire(new h.z("data",{dataType:"style"}));break}}this.mergeTerrain(),this.updateDrapeFirstLayers(),this._markersNeedUpdate=!0}_createFog(t){let o=this.fog=new sf(t,this.map.transform,this.scope,this.options);this.stylesheet.fog=o.get();let c=this._getTransitionParameters({duration:0});o.updateTransitions(c)}_createSnow(t){let o=this.snow=new mu(t,this.map.transform,this.scope,this.options);this.stylesheet.snow=o.get();let c=this._getTransitionParameters({duration:0});o.updateTransitions(c)}_createRain(t){let o=this.rain=new pc(t,this.map.transform,this.scope,this.options);this.stylesheet.rain=o.get();let c=this._getTransitionParameters({duration:0});o.updateTransitions(c)}_updateMarkersOpacity(){this.map._markers.length!==0&&this.map._requestDomTask(()=>{for(let t of this.map._markers)t._evaluateOpacity()})}getFog(){return this.fog?this.fog.get():null}setFog(t){if(this._checkLoaded(),t)if(this.fog){let o=this.fog;if(!h.b9(o.get(),t)){o.set(t,this.options),this.stylesheet.fog=o.get();let c=this._getTransitionParameters({duration:0});o.updateTransitions(c)}}else this._createFog(t);else delete this.fog,delete this.stylesheet.fog;this._markersNeedUpdate=!0,this._programPrecompiler&&this._programPrecompiler.reset()}getSnow(){return this.snow?this.snow.get():null}setSnow(t){if(this._checkLoaded(),!t)return delete this.snow,void delete this.stylesheet.snow;if(this.snow){let o=this.snow;if(!h.b9(o.get(),t)){o.set(t,this.options),this.stylesheet.snow=o.get();let c=this._getTransitionParameters({duration:0});o.updateTransitions(c)}}else this._createSnow(t);this._markersNeedUpdate=!0}getRain(){return this.rain?this.rain.get():null}setRain(t){if(this._checkLoaded(),!t)return delete this.rain,void delete this.stylesheet.rain;if(this.rain){let o=this.rain;if(!h.b9(o.get(),t)){o.set(t,this.options),this.stylesheet.rain=o.get();let c=this._getTransitionParameters({duration:0});o.updateTransitions(c)}}else this._createRain(t);
8this._markersNeedUpdate=!0}_reloadColorTheme(){let t=()=>{for(let d in this._layers)this._layers[d].lut=this._styleColorTheme.lut;for(let d in this._sourceCaches)this._sourceCaches[d].clearTiles()},o=this._styleColorTheme.colorThemeOverride?this._styleColorTheme.colorThemeOverride:this._styleColorTheme.colorTheme;if(!o)return this._styleColorTheme.lut=null,void t();let c=this._evaluateColorThemeData(o);this._loadColorTheme(c).then(()=>{this.fire(new h.z("colorthemeset")),t()}).catch(d=>{h.w(`Couldn't set color theme: ${d}`)})}setColorTheme(t){this._checkLoaded(),this._styleColorTheme.colorThemeOverride&&h.w("Note: setColorTheme is called on a style with a color-theme override, the passed color-theme won't be visible."),this._styleColorTheme.colorTheme=t,this._reloadColorTheme()}setImportColorTheme(t,o){let c=this.getFragmentStyle(t);c&&(c._styleColorTheme.colorThemeOverride=o,c._reloadColorTheme())}_getTransitionParameters(t){return{now:h.o.now(),transition:Object.assign(this.transition,t)}}updateDrapeFirstLayers(){if(!this.terrain)return;let t=[],o=[];for(let c of this._mergedOrder)this.isLayerDraped(this._mergedLayers[c])?t.push(c):o.push(c);this._drapedFirstOrder=[],this._drapedFirstOrder.push(...t),this._drapedFirstOrder.push(...o)}_createTerrain(t,o){let c=this.terrain=new Gh(t,o,this.scope,this.options,this.map.getWorldview());o===1&&(this.stylesheet.terrain=t),this.mergeTerrain(),this.updateDrapeFirstLayers(),this._force3DLayerUpdate();let d=this._getTransitionParameters({duration:0});c.updateTransitions(d)}_force3DLayerUpdate(){for(let t in this._layers){let o=this._layers[t];o.type==="fill-extrusion"&&this._updateLayer(o)}}_forceSymbolLayerUpdate(){for(let t in this._layers){let o=this._layers[t];o.type==="symbol"&&this._updateLayer(o)}}_validate(t,o,c,d,m={}){if(m&&m.validate===!1)return!1;let _=Object.assign({},this.serialize());return tr(this,t.call(xn,Object.assign({key:o,style:_,value:c,styleSpec:h.a6},d)))}_remove(){this._programPrecompiler&&(this._programPrecompiler.reset(),this._programPrecompiler=null),this._request&&(this._request.cancel(),this._request=null),this._spriteRequest&&(this._spriteRequest.cancel(),this._spriteRequest=null),h.dm.off("pluginStateChange",this._rtlTextPluginCallback);for(let t in this._mergedLayers)this._mergedLayers[t].setEventedParent(null);for(let t in this._mergedSourceCaches){let o=this._mergedSourceCaches[t];o.clearTiles(),o.setEventedParent(null);let c=o.getSource();c&&c.onRemove&&c.onRemove(this.map)}this.imageManager.removeScope(this.scope),this.imageManager.imageAtlasCache.clear(),this.setEventedParent(null),delete this.fog,delete this.snow,delete this.rain,delete this.terrain,delete this.ambientLight,delete this.directionalLight,this.indoorManager.destroy(),this.isRootStyle()&&(this.imageManager.setEventedParent(null),this.modelManager.setEventedParent(null),this.modelManager.destroy(),this.dispatcher.remove())}clearSource(t){let o=this.getSourceCaches(t);for(let c of o)c.clearTiles()}clearSources(){for(let t in this._mergedSourceCaches)this._mergedSourceCaches[t].clearTiles()}clearLayers(){for(let t in this._mergedLayers){let o=this._mergedLayers[t];o._clear&&o._clear()}}reloadSource(t){let o=this.getSourceCaches(t);for(let c of o)c.resume(),c.reload()}reloadSources(){for(let t of this.getSources())t.reload&&t.reload()}reloadModels(){this.modelManager.reloadModels(""),this.forEachFragmentStyle(t=>{t.modelManager.reloadModels(t.scope)})}updateSources(t){let o;this.directionalLight&&(o=vf(this.directionalLight));let c=new Set,d=new Set,m=new Set;for(let _ in this._mergedLayers){let y=this._mergedLayers[_];y.type==="building"?c.add(y.source):y.type==="raster"&&y.paint&&y.paint.get("raster-elevation-reference")==="ground"&&m.add(y.source),y.hasElevation()&&
8!d.has(y.source)&&d.add(y.source)}for(let _ in this._mergedSourceCaches){let y=this._mergedSourceCaches[_],v=d.has(y._source.id);y._isRasterElevatedOverTerrain=m.has(y._source.id),c.has(y._source.id)&&(y._source.reparseOverscaled=!1),y.update(t,void 0,void 0,o,v)}}_reloadSources(){for(let t in this._sourceCaches){let o=this._sourceCaches[t];o.resume(),o.reload()}}_handleLayerOrderChange(){this._requestFullLabelPlacement(),this.fire(new h.z("neworder"))}_requestFullLabelPlacement(){this.pauseablePlacement||(this.pauseablePlacement=new Cu),this.pauseablePlacement.requestFullPlacement()}_setLabelPlacementStale(){this.placement&&this.placement.setStale()}_updatePlacement(t,o,c,d,m){this.pauseablePlacement||(this.pauseablePlacement=new Cu);let _=!1,y=!1,v={},T={};for(let O of this._mergedOrder){let k=this._mergedLayers[O];if(k.type!=="symbol")continue;let N=h.t(k.source,k.scope),q=v[N];if(!q){let G=this.getLayerSourceCache(k);if(!G)continue;let re=G.getRenderableIds(!0).map(te=>G.getTileByID(te));T[N]=re.slice(),q=v[N]=re.sort((te,se)=>se.tileID.overscaledZ-te.tileID.overscaledZ||(te.tileID.isLessThan(se.tileID)?-1:1))}let Z=this.crossTileSymbolIndex.addLayer(k,q,t.center.lng,t.projection);_=_||Z}this.crossTileSymbolIndex.pruneUnusedLayers(this._mergedOrder);let I=!!(this.placement&&!t.equals(this.placement.transform)),P=!!(this.placement&&(this.placement.lastReplacementSourceUpdateTime!==0&&!m||this.placement.lastReplacementSourceUpdateTime!==m.updateTime)),A=I||P||_,D=(A||this.pauseablePlacement.isStale())&&c===0,L=this.pauseablePlacement.isDone()&&!this.placement.stillRecent(h.o.now(),t.zoom)&&c!==0;if((this.pauseablePlacement.isFullPlacementRequested()||!this.pauseablePlacement.placement||D||L)&&(this.pauseablePlacement=this.pauseablePlacement.startNewPlacement(t,this._mergedOrder,o,c,d,this.placement,this.fog&&t.projection.supportsFog?this.fog.state:null,this._buildingIndex),this.map.painter)){let O=this.map.painter.maxFrontCutoffRawStart;if(O>0){let k=180*t.pitch/Math.PI;if(k>=15){let N=Math.min(1,Math.max(0,(k-15)/5)),q=N*N*(3-2*N);this.pauseablePlacement.placement.frontCutoffStart=-.5*(1-q)+O*q}}}if(this.pauseablePlacement.isDone()?A&&c!==0&&this.pauseablePlacement.setStale():(this.pauseablePlacement.continuePlacement(this._mergedOrder,this._mergedLayers,v,T,this.map.painter.scaleFactor),this.pauseablePlacement.isDone()&&(this.placement=this.pauseablePlacement.commit(h.o.now()),y=!0),_&&this.pauseablePlacement.setStale()),y||_){this._buildingIndex.onNewFrame(t.zoom);for(let O=0;O<this._mergedOrder.length;O++){let k=this._mergedLayers[this._mergedOrder[O]];if(k.type!=="symbol"||k.visibility==="none")continue;let N=this.isLayerClipped(k);this.placement.updateLayerOpacities(k,v[h.t(k.source,k.scope)],O,N?m:null)}}return!this.pauseablePlacement.isDone()||this.placement.isStale()||this.placement.hasTransitions(h.o.now())}_releaseSymbolFadeTiles(){for(let t in this._sourceCaches)this._sourceCaches[t].releaseSymbolFadeTiles()}addImport(t,o){this._checkLoaded();let c=this.stylesheet.imports=this.stylesheet.imports||[];if(c.findIndex(({id:m})=>m===t.id)!==-1)return void this.fire(new h.y(new Error(`Import with id '${t.id}' already exists in the map's style.`)));if(!o)return c.push(t),this._loadImports([t],!0);let d=c.findIndex(({id:m})=>m===o);return d===-1&&this.fire(new h.y(new Error(`Import with id "${o}" does not exist on this map.`))),this.stylesheet.imports=c.slice(0,d).concat(t).concat(c.slice(d)),this._loadImports([t],!0,o)}updateImport(t,o){this._checkLoaded();let c=this.stylesheet.imports||[],d=this.getImportIndex(t);return d===-1?this:typeof o=="string"?(this.setImportUrl(t,o),this):(o.url&&o.url!==c[d].url&&this.setImportUrl(t,o.url),h.b9(o.config,c[d].config)||this.setImportConfig(t,o.config,o.data.schema),h.b9(o.data,c[d].data)||this.setImportData(t,o.data),this)}moveImport(t,o){this._checkLoaded();let c=this.stylesheet.imports||[],d=this.getImportIndex(t);if(d===-1)return this;let m=this.getImportIndex(o);if(m===-1)return this;let _=c[d],y=this.fragments[d];return c=c.filter(({id:v})=>v!==t),this.fragments=this.fragments.filter(({id:v})=>v!==t),this.stylesheet.imports=c.slice(0,m).concat(_).concat(c.slice(m)),this.fragments=this.fragments.slice(0,m).concat(y).concat(this.fragments.slice(m)),this.mergeLayers(),this}setImportUrl(t,o){this._checkLoaded();let c=this.stylesheet.imports||[],d=this.getImportIndex(t);if(d===-1)return this;c[d].url=o;let m=this.fragments[d];return m.style=this._createFragmentStyle(c[d]),m.style.on("style.import.load",()=>this.mergeAll()),m.style.loadURL(o),this}setImportData(t,o){this._checkLoaded();let c=this.getImportIndex(t),d=this.stylesheet.imports||[];return c===-1?this:o?(this.fragments[c].style.setState(o),this._reloadImports(),this):(delete d[c].data,this.setImportUrl(t,d[c].url))}setImportConfig(t,o,c){this._checkLoaded();let d=this.getImportIndex(t),m=this.stylesheet.imports||[];if(d===-1)return this;o?m[d].config=o:delete m[d].config;let _=this.fragments[d];c&&_.style.stylesheet&&(_.style.stylesheet.schema=c);let y=_.style.stylesheet&&_.style.stylesheet.schema;return _.config=o,_.style.updateConfig(o,y),this.updateConfigDependencies(),this}removeImport(t){this._checkLoaded();let o=this.stylesheet.imports||[],c=this.getImportIndex(t);c!==-1&&(o.splice(c,1),this.fragments[c].style._remove(),this.fragments.splice(c,1),this._reloadImports())}getImportIndex(t){let o=(this.stylesheet.imports||[]).findIndex(c=>c.id===t);return o===-1&&this.fire(new h.y(new Error(`Import '${t}' does not exist in the map's style and cannot be updated.`))),o}
8getLayer(t){return this._mergedLayers[t]}getSources(){let t=[];for(let o in this._mergedOtherSourceCaches){let c=this._mergedOtherSourceCaches[o];c&&t.push(c.getSource())}return t}getSource(t,o){let c=this.getSourceCache(t,o);return c&&c.getSource()}getLayerSource(t){let o=this.getLayerSourceCache(t);return o&&o.getSource()}getSourceCache(t,o){let c=h.t(t,o);return this._mergedOtherSourceCaches[c]}getLayerSourceCache(t){let o=h.t(t.source,t.scope);return t.type==="symbol"?this._mergedSymbolSourceCaches[o]:t.type==="fill-extrusion"&&this._mergedFillExtrusionSourceCaches[o]||this._mergedOtherSourceCaches[o]}getSourceCaches(t){if(t==null)return Object.values(this._mergedSourceCaches);let o=[];return this._mergedOtherSourceCaches[t]&&o.push(this._mergedOtherSourceCaches[t]),this._mergedSymbolSourceCaches[t]&&o.push(this._mergedSymbolSourceCaches[t]),this._mergedFillExtrusionSourceCaches[t]&&o.push(this._mergedFillExtrusionSourceCaches[t]),o}updateSourceCaches(){let t=this._changes.getUpdatedSourceCaches();for(let o in t){let c=t[o];c==="reload"?this.reloadSource(o):c==="clear"&&this.clearSource(o)}}updateLayers(t){let o=this._changes.getUpdatedPaintProperties();for(let c of o){let d=this.getLayer(c);d&&d.updateTransitions(t)}}getGlyphsUrl(){return this.stylesheet.glyphs}setGlyphsUrl(t){this.stylesheet.glyphs=t,this.glyphManager.setURL(t)}getImages(t,o,c){this.imageManager.getImages(o.icons.concat(o.patterns),o.scope,c),this._updateTilesForChangedImages();let d=o.icons.map(v=>h.I.toString(v)),m=o.patterns.map(v=>h.I.toString(v)),_=v=>{v&&(v.setDependencies(o.tileID.key,"icons",d),v.setDependencies(o.tileID.key,"patterns",m))},y=h.t(o.source,o.scope);_(this._mergedOtherSourceCaches[y]),_(this._mergedSymbolSourceCaches[y]),(o.icons.some(v=>v.iconsetId)||o.patterns.some(v=>v.iconsetId))&&this.fire(new h.z("data",{dataType:"style"}))}rasterizeImages(t,o,c){this.imageManager.rasterizeImages(o,c)}checkAtlasCache(t,o,c){let d=this.imageManager.imageAtlasCache.findCachedAtlas(o.descriptor);c(null,d&&d.contentDescriptor?{iconPositions:d.iconPositions,patternPositions:d.patternPositions,sourceHash:d.contentDescriptor.hash}:null)}getGlyphs(t,o,c){this.glyphManager.getGlyphs(o.stacks,c)}getOwnSourceCache(t){return this._otherSourceCaches[t]}getOwnLayerSourceCache(t){return t.type==="symbol"?this._symbolSourceCaches[t.source]:t.type==="fill-extrusion"&&this._fillExtrusionSourceCaches[t.source]||this._otherSourceCaches[t.source]}getOwnSourceCaches(t){let o=[];return this._otherSourceCaches[t]&&o.push(this._otherSourceCaches[t]),this._symbolSourceCaches[t]&&o.push(this._symbolSourceCaches[t]),this._fillExtrusionSourceCaches[t]&&o.push(this._fillExtrusionSourceCaches[t]),o}_isSourceCacheLoaded(t){let o=this.getOwnSourceCaches(t);return o.length===0?(this.fire(new h.y(new Error(`There is no source with ID '${t}'`))),!1):o.every(c=>c.loaded())}has3DLayers(){return this._has3DLayers}hasSymbolLayers(){return this._hasSymbolLayers}hasCircleLayers(){return this._hasCircleLayers}isLayerClipped(t,o){if(!this._clipLayerPresent&&t.type!=="fill-extrusion"&&t.type!=="building")return!1;let c=t.type==="fill-extrusion"&&(t.sourceLayer==="building"||t.sourceLayer==="procedural_buildings"),d=t.type==="building";if(t.is3D(!!this.terrain)){if(c||d||o&&o.type==="batched-model"||t.type==="model")return!0}else if(t.type==="symbol")return!0;return!1}_clearWorkerCaches(){this.dispatcher.broadcast("clearCaches")}getBOMObject(){}destroy(){this._clearWorkerCaches(),this.imageManager.imageAtlasCache.clear(),this.fragments.forEach(t=>{t.style._remove()}),this.terrainSetForDrapingOnly()&&(delete this.terrain,delete this.stylesheet.terrain)}}Fr.getSourceType=function(a){return xu[a]},Fr.setSourceType=function(a,t){xu[a]=t},Fr.registerForPluginStateChange=h.dn;var _l=` 9#define EPSILON 0.0000001 10#define PI 3.141592653589793 11#ifdef RENDER_CUTOFF 12float 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);} 13#endif`,gl=` 14#ifdef DUAL_SOURCE_BLENDING 15layout(location=0,index=0) out vec4 glFragColor;layout(location=0,index=1) out vec4 glFragColorSrc1; 16#elif defined(FLOAT_RENDER_TARGET) 17layout(location=0) out highp vec4 glFragColor; 18#else 19layout(location=0) out vec4 glFragColor; 20#endif 21#ifdef USE_MRT1 22layout(location=1) out vec4 out_Target1; 23#endif 24highp float unpack_depth(highp vec4 rgba_depth) 25{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;} 26#ifdef INDICATOR_CUTOUT 27uniform vec3 u_indicator_cutout_centers;uniform vec4 u_indicator_cutout_params; 28#endif 29const float DITHER_THRESHOLDS[16]=float[16]( 301.0/17.0, 9.0/17.0, 3.0/17.0,11.0/17.0,13.0/17.0, 5.0/17.0,15.0/17.0, 7.0/17.0,4.0/17.0,12.0/17.0, 2.0/17.0,10.0/17.0,16.0
30/17.0, 8.0/17.0,14.0/17.0, 6.0/17.0 31);vec4 applyCutout(vec4 color,float height) { 32#ifdef INDICATOR_CUTOUT 33float verticalFadeRange=u_indicator_cutout_centers.z*0.25;float holeMinOpacity=mix(1.0,u_indicator_cutout_params.x,smoothstep(u_indicator_cutout_centers.z,u_indicator_cutout_centers.z+verticalFadeRange,height));float holeRadius=max(u_indicator_cutout_params.y,0.0);float holeAspectRatio=u_indicator_cutout_params.z;float fadeStart=u_indicator_cutout_params.w;float distA=distance(vec2(gl_FragCoord.x,gl_FragCoord.y*holeAspectRatio),vec2(u_indicator_cutout_centers[0],u_indicator_cutout_centers[1]*holeAspectRatio));return color*min(smoothstep(fadeStart,holeRadius,distA)+holeMinOpacity,1.0); 34#else 35return color; 36#endif 37}float cutoutGroundRoofOpacity(vec4 groundRoof) { 38#ifdef INDICATOR_CUTOUT 39float fadeStartX=u_indicator_cutout_params.w;float holeRadius=u_indicator_cutout_params.y;float holeMinOpacity=mix(u_indicator_cutout_params.x,1.0,smoothstep(u_indicator_cutout_params.z,u_indicator_cutout_centers.z,groundRoof.y));float distX=abs(u_indicator_cutout_centers.x-groundRoof.x);float roofOpacity=mix(holeMinOpacity,1.0,smoothstep(fadeStartX,holeRadius,u_indicator_cutout_centers.y-groundRoof.w));float groundOpacity=min(smoothstep(fadeStartX,holeRadius,distX)+holeMinOpacity,1.0);return max(roofOpacity,groundOpacity); 40#else 41return 1.0; 42#endif 43} 44#ifdef DEBUG_WIREFRAME 45#define HANDLE_WIREFRAME_DEBUG \\ 46glFragColor=vec4(0.7,0.0,0.0,0.7); \\ 47gl_FragDepth=gl_FragCoord.z-0.0001; 48#else 49#define HANDLE_WIREFRAME_DEBUG 50#endif 51#ifdef RENDER_CUTOFF 52uniform highp vec4 u_cutoff_params;in float v_cutoff_opacity; 53#endif 54vec4 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 premultiplyColor(vec3 nonPremultipliedColor,float a) {return vec4(nonPremultipliedColor*a,a);}vec3 unpremultiplyColor(vec4 premultipliedColor) {if (premultipliedColor.a > 0.0) {return premultipliedColor.rgb/premultipliedColor.a;}return premultipliedColor.rgb;}vec3 applyLUT(highp sampler3D lut,vec3 col) {vec3 size=vec3(textureSize(lut,0));vec3 uvw=(col.rbg*float(size-1.0)+0.5)/size;return texture(lut,uvw).rgb;}vec4 applyLUT(highp sampler3D lut,vec4 premultipliedColor) {return premultiplyColor(applyLUT(lut,unpremultiplyColor(premultipliedColor)),premultipliedColor.a);}`,nd=` 55#define EXTENT 8192.0 56#define RAD_TO_DEG 180.0/PI 57#define DEG_TO_RAD PI/180.0 58#define GLOBE_RADIUS EXTENT/PI/2.0 59float 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;} 60#ifdef PROJECTION_GLOBE_VIEW 61vec3 mercator_tile_position(mat4 matrix,vec2 tile_anchor,vec3 tile_id,vec2 mercator_center) { 62#ifndef PROJECTED_POS_ON_VIEWPORT 63float 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; 64#else 65return vec3(0.0); 66#endif 67}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);} 68#endif 69vec2 unpack_float(const float packedValue) {int packedIntValue=int(packedValue);int v0=packedIntValue/256;return vec2(v0,packedIntValue-v0*256);}vec4 decode_color(const vec2 encodedColor) {return vec4( 70unpack_float(encodedColor[0])/255.0,unpack_float(encodedColor[1])/255.0 71);}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);
71return (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);} 72#ifdef RENDER_CUTOFF 73uniform vec4 u_cutoff_params;out float v_cutoff_opacity; 74#endif 75const vec4 AWAY=vec4(-1000.0,-1000.0,-1000.0,1);const float skirtOffset=24575.0;vec3 decomposeToPosAndSkirt(ivec2 posWithComposedSkirt) 76{float skirt=float(float(posWithComposedSkirt.x) >=skirtOffset);vec2 pos=vec2(posWithComposedSkirt)-vec2(skirt*skirtOffset,0.0);return vec3(pos,skirt);} 77#ifndef HAS_SHADER_STORAGE_BLOCK_material_buffer 78#define GET_ATTRIBUTE_float(attrib,matInfo,attrib_id) attrib 79#define GET_ATTRIBUTE_vec4(attrib,matInfo,attrib_id) attrib 80#define GET_ATTRIBUTE_vec2(attrib,matInfo,attrib_id) attrib 81#define DECLARE_MATERIAL_TABLE_INFO 82#endif`,rd="in highp vec3 a_pos_3f;uniform lowp mat4 u_matrix;out highp vec3 v_uv;void main() {const mat3 half_neg_pi_around_x=mat3(1.0,0.0, 0.0,0.0,0.0,-1.0,0.0,1.0, 0.0);v_uv=half_neg_pi_around_x*a_pos_3f;vec4 pos=u_matrix*vec4(a_pos_3f,1.0);gl_Position=pos.xyww;}",od=` 83#define ELEVATION_SCALE 7.0 84#define ELEVATION_OFFSET 450.0 85#ifdef PROJECTION_GLOBE_VIEW 86uniform 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( 87mix(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;} 88#else 89vec3 elevationVector(vec2 pos) { return vec3(0,0,1); } 90#endif 91#ifdef TERRAIN 92uniform 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) { 93#ifdef TERRAIN_DEM_FLOAT_FORMAT 94vec2 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; 95#else 96float 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); 97#endif 98}float prevElevation(vec2 apos) { 99#ifdef TERRAIN_DEM_FLOAT_FORMAT 100vec2 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; 101#else 102float 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); 103#endif 104} 105#ifdef TERRAIN_VERTEX_MORPHING 106float elevation(vec2 apos) { 107#ifdef ZERO_EXAGGERATION 108return 0.0; 109#endif 110float nextElevation=currentElevation(apos);float prevElevation=prevElevation(apos);return mix(prevElevation,nextElevation,u_dem_lerp);} 111#else 112float elevation(vec2 apos) { 113#ifdef ZERO_EXAGGERATION 114return 0.0; 115#endif 116return currentElevation(apos);} 117#endif 118vec4 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);} 119#else 120float elevation(vec2 pos) { return 0.0; } 121#endif 122#ifdef DEPTH_OCCLUSION 123uniform 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; 124#ifdef DEPTH_D24 125float 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);} 126#else 127highp float unpack_depth_rgba(vec4 rgba_depth) 128{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;} 129#endif 130bool isOccluded(vec4 frag) {vec3 coord=frag.xyz/frag.w; 131#ifdef CLIP_ZERO_TO_ONE 132coord.z=-1.0+2.0*coord.z; 133#endif 134#ifdef DEPTH_D24 135float depth=unpack_depth(texture(u_depth,(coord.xy+1.0)*0.5).r); 136#else 137float depth=unpack_depth_rgba(texture(u_depth,(coord.xy+1.0)*0.5)); 138#endif 139return coord.z+u_occlusion_depth_offset > depth;}highp vec4 getCornerDepths(vec2 coord) {highp vec3 df=vec3(u_occluder_half_size*u_depth_
139size_inv,0.0);highp vec2 uv=0.5*coord.xy+0.5; 140#ifdef DEPTH_D24 141highp vec4 depth=vec4( 142texture(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 143);depth=unpack_depth4(depth); 144#else 145highp vec4 depth=vec4( 146unpack_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)) 147); 148#endif 149return depth;}highp float occlusionFadeMultiSample(vec4 frag) {highp vec3 coord=frag.xyz/frag.w;highp vec2 uv=0.5*coord.xy+0.5; 150#ifdef CLIP_ZERO_TO_ONE 151coord.z=-1.0+2.0*coord.z; 152#endif 153int 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) { 154#ifdef DEPTH_D24 155highp float depth=unpack_depth(texture(u_depth,uv-df+vec2(float(x)*oneStep.x,float(y)*oneStep.y)).r); 156#else 157highp float depth=unpack_depth_rgba(texture(u_depth,uv-df+vec2(float(x)*oneStep.x,float(y)*oneStep.y))); 158#endif 159res+=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; 160#ifdef CLIP_ZERO_TO_ONE 161coord.z=-1.0+2.0*coord.z; 162#endif 163highp 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));} 164#else 165bool isOccluded(vec4 frag) { return false; }highp float occlusionFade(vec4 frag) { return 1.0; }highp float occlusionFadeMultiSample(vec4 frag) { return 1.0; } 166#endif`,Ca=`#ifdef FOG 167uniform 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);} 168#endif`,sd=`#ifdef FOG 169uniform 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; 170#ifdef FLIP_Y 171uv.y=1.0-uv.y; 172#endif 173highp vec3 ray_dir=mix( 174mix(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;}
174vec3 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);} 175#endif`,ad=` 176#ifdef LIGHTING_3D_MODE 177uniform mediump vec3 u_lighting_ambient_color;uniform mediump vec3 u_lighting_directional_dir;uniform mediump vec3 u_lighting_directional_color;uniform mediump vec3 u_ground_radiance;float calculate_ambient_directional_factor(vec3 normal) {float NdotL=dot(normal,u_lighting_directional_dir);const float factor_reduction_max=0.3;float dir_luminance=dot(u_lighting_directional_color,vec3(0.2126,0.7152,0.0722));float directional_factor_min=1.0-factor_reduction_max*min(dir_luminance,1.0);float ambient_directional_factor=mix(directional_factor_min,1.0,min((NdotL+1.0),1.0));const float vertical_factor_min=0.92;float vertical_factor=mix(vertical_factor_min,1.0,normal.z*0.5+0.5);return vertical_factor*ambient_directional_factor;}vec3 linearProduct(vec3 srgbIn,vec3 k) {return srgbIn*pow(k,vec3(1./2.2));}vec3 apply_lighting(vec3 color,vec3 normal,float dir_factor) {float ambient_directional_factor=calculate_ambient_directional_factor(normal);vec3 ambient_contrib=ambient_directional_factor*u_lighting_ambient_color;vec3 directional_contrib=u_lighting_directional_color*dir_factor;return linearProduct(color,ambient_contrib+directional_contrib);}vec4 apply_lighting(vec4 color,vec3 normal,float dir_factor) {return vec4(apply_lighting(color.rgb,normal,dir_factor),color.a);}vec3 apply_lighting(vec3 color,vec3 normal) {float dir_factor=max(dot(normal,u_lighting_directional_dir),0.0);return apply_lighting(color.rgb,normal,dir_factor);}vec4 apply_lighting(vec4 color,vec3 normal) {float dir_factor=max(dot(normal,u_lighting_directional_dir),0.0);return vec4(apply_lighting(color.rgb,normal,dir_factor),color.a);}vec3 apply_lighting_ground(vec3 color) {return color*u_ground_radiance;}vec4 apply_lighting_ground(vec4 color) {return vec4(apply_lighting_ground(color.rgb),color.a);}float calculate_NdotL(vec3 normal) {const float ext=0.70710678118;return (clamp(dot(normal,u_lighting_directional_dir),-ext,1.0)+ext)/(1.0+ext);}vec4 apply_lighting_with_emission_ground(vec4 color,float emissive_strength) {return mix(apply_lighting_ground(color),color,emissive_strength);}vec3 compute_flood_lighting(vec3 flood_light_color,float fully_occluded_factor,float occlusion,vec3 ground_shadow_factor) {vec3 fully_occluded_color=flood_light_color*mix(ground_shadow_factor,vec3(1.0),fully_occluded_factor);float occlusion_ramp=smoothstep(0.0,0.2,1.0-occlusion);return mix(fully_occluded_color,flood_light_color,occlusion_ramp);}vec3 compute_emissive_draped(vec3 unlit_color,float fully_occluded_factor,float occlusion,vec3 ground_shadow_factor) {vec3 fully_occluded_color=unlit_color*mix(ground_shadow_factor,vec3(1.0),fully_occluded_factor);return mix(fully_occluded_color,unlit_color,1.0-occlusion);} 178#endif`,Tf=`#ifdef RASTER_ARRAY 179uniform 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);}
179vec2 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) 180);}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) 181);}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);} 182#endif`,Sf=`#ifdef RENDER_SHADOWS 183uniform 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];} 184#endif`,Fu=`#ifdef RENDER_SHADOWS 185precision 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) { 186#ifdef CLIP_ZERO_TO_ONE 187highp vec3 coord=vec3(pos.xy*0.5+0.5,pos.z-bias); 188#else 189highp vec3 coord=vec3(pos.xy*0.5+0.5,pos.z*0.5+0.5-bias); 190#endif 191return 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; 192#ifdef SHADOWS_SINGLE_CASCADE 193vec2 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); 194#else 195light_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); 196#endif 197}highp float calculate_shadow_bias(float NDotL) { 198#ifdef NORMAL_OFFSET 199return 0.5*u_shadow_bias.x; 200#else 201return 0.5*(u_shadow_bias.x+clamp(u_shadow_bias.y*tan(acos(NDotL)),0.0,u_shadow_bias.z)); 202#endif 203}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) 204{highp vec2 biasUV=vec2( 205pos_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);} 206#endif`;
206let Bu=/#include\s+"([^"]+)"/g,ku=/#pragma mapbox: ([\w\-]+) ([\w]+) ([\w]+) ([\w]+)/g,ld=/\b[A-Za-z_][A-Za-z0-9_]*\b/g,If=new Set(["ifdef","ifndef","elif","if","defined"]),Ac=new Set;Ds(_l,Ac),Ds(nd,Ac),Ds(gl,Ac);let Mc={"_prelude_fog.vertex.glsl":Ca,"_prelude_terrain.vertex.glsl":od,"_prelude_shadow.vertex.glsl":Sf,"_prelude_material_table.vertex.glsl":`#ifdef HAS_SHADER_STORAGE_BLOCK_material_buffer 207#define MATERIAL_TABLE_DEBUG 0 208uniform int u_material_offset;uniform int u_vertex_offset;layout(std140,binding=0)readonly buffer material_buffer{uvec4 material_data[];};struct MaterialInfo{uint dataOffset; 209#if MATERIAL_TABLE_DEBUG 210vec4 colorDebug; 211#endif 212};uint read_buf_no_offset(uint iDword) {return material_data[iDword/4u][iDword % 4u];}uint read_buf(uint iDword) {iDword+=uint(u_material_offset/4);return read_buf_no_offset(iDword);}float read_buf_float(uint iDword){return uintBitsToFloat(read_buf(iDword));}uint read_buf_uint8(uint iDword,uint iUint8){uint dwordOffset=iDword+(iUint8/4u);uint byteOffset=iUint8 & 3u;uint bitOffset=8u*byteOffset;uint mask=0xffu << bitOffset;uint dwordVal=read_buf(dwordOffset);return (dwordVal & mask) >> bitOffset;}uint read_buf_uint16(uint iDword,uint iUint16){uint dwordOffset=iDword+(iUint16 >> 1u);uint bitOffset=(iUint16 & 1u)*16u;uint mask=0xffffu << bitOffset;uint dwordVal=read_buf(dwordOffset);return (dwordVal & mask) >> bitOffset;}uint nrDwordsForVertexIdEntries(uint nrMaterialLookupEntries) {return nrMaterialLookupEntries;}uint nrDwordsForMaterialIdEntries(uint nrMaterialLookupEntries) {return (nrMaterialLookupEntries*2u+3u)/4u;}uint findRangeBinarySearch(uint vertexId,uint numRanges,uint dwordOffset) {uint left=0u;uint right=numRanges-1u;for (uint i=0u; i < 16u; i++) { 213if (left > right) {break;}uint mid=(left+right)/2u;uint start=read_buf(dwordOffset+mid);uint nextStart=(mid+1u < numRanges) ? read_buf(dwordOffset+mid+1u) : 0xffffffffu;if (vertexId >=start && vertexId < nextStart) {return mid;} else if (vertexId < start) {if (mid==0u) {break;}right=mid-1u;} else {left=mid+1u;}}return 0u; 214}uint readVertexId(uint dwordOffset,uint iMaterialLookupEntry) {return read_buf(dwordOffset+iMaterialLookupEntry);}uint findRange(uint vertexId,uint numRanges,uint dwordOffset) {uint iRange;if(numRanges <=64u){uint vertexBegin;for(iRange=0u; iRange < numRanges;++iRange) {vertexBegin=readVertexId(dwordOffset,iRange);if(vertexBegin > vertexId) {break;}}iRange=iRange==0u? 0u : iRange-1u;} else { 215iRange=findRangeBinarySearch(vertexId,numRanges,dwordOffset);}return iRange;}MaterialInfo read_material_info(uint vertex_id) {MaterialInfo info; 216#if MATERIAL_TABLE_DEBUG 217const vec4 red=vec4(1.0,0.0,0.0,1.0);const vec4 orange=vec4(1.0,0.5,0.0,1.0);const vec4 yellow=vec4(1.0,1.0,0.0,1.0);const vec4 green=vec4(0.0,1.0,0.0,1.0);const vec4 indigo=vec4(0.294,0.0,0.510,1.0);const vec4 blue=vec4(0.0,0.0,1.0,1.0);const vec4 purple=vec4(0.5,0.0,0.5,1.0);const vec4 pink=vec4(1.0,0.0,1.0,1.0);info.colorDebug=green; 218#endif 219uint offset=0u; 220#if MATERIAL_TABLE_DEBUG 221bool keepFinding=true;uint magic=read_buf(offset);if(magic !=0xCAFEBABEu) {info.colorDebug=red;keepFinding=false;return info;} 222#endif 223offset++; 224#if MATERIAL_TABLE_DEBUG 225uint nrMaterials=read_buf(offset);uint nrVertices=read_buf(offset+1u);if(keepFinding && vertex_id >=nrVertices) {info.colorDebug=red;keepFinding=false;} 226#endif 227offset+=2u;uint nrMaterialLookupEntries=read_buf(offset++);uint perMaterialEntrySizeDwords=read_buf(offset++); 228#if MATERIAL_TABLE_DEBUG 229if(keepFinding && perMaterialEntrySizeDwords !=1u) {info.colorDebug=red;keepFinding=false;} 230#endif 231uint iMaterialLookup=findRange(vertex_id,nrMaterialLookupEntries,offset); 232#if MATERIAL_TABLE_DEBUG 233if(keepFinding) 234{uint vertexBeginCheck=readVertexId(offset,iMaterialLookup);if(vertexBeginCheck > vertex_id) {info.colorDebug=red;keepFinding=false;}if(iMaterialLookup < nrMaterialLookupEntries-1u) {uint vertexEndCheck=readVertexId(offset,iMaterialLookup+1u);if(vertexEndCheck <=vertex_id) {info.colorDebug=red;keepFinding=false;}}} 235#endif 236offset+=nrDwordsForVertexIdEntries(nrMaterialLookupEntries);uint materialId=iMaterialLookup; 237#if MATERIAL_TABLE_DEBUG 238if(keepFinding) {if(materialId >=nrMaterialLookupEntries) {info.colorDebug=red;}} 239#endif 240info.dataOffset=offset+materialId*perMaterialEntrySizeDwords;return info;}uint get_data_location(const MaterialInfo matInfo,uint attribOffsetBytes) 241{uint attribFieldOffsetDwords=attribOffsetBytes/4u;return matInfo.dataOffset+attribFieldOffsetDwords;}vec4 read_material_vec4(const MaterialInfo matInfo,uint attribOffsetBytes){uint loc=get_data_location(matInfo,attribOffsetBytes);return vec4(read_buf_float(loc),read_buf_float(loc+1u),read_buf_float(loc+2u),read_buf_float(loc+3u));}vec2 read_material_vec2(const MaterialInfo matInfo,uint attribOffsetBytes){uint loc=get_data_location(matInfo,attribOffsetBytes);return vec2(read_buf_float(loc),read_buf_float(loc+1u));}float read_material_float(const MaterialInfo matInfo,uint attribOffsetBytes){uint loc=get_data_location(matInfo,attribOffsetBytes);return read_buf_float(loc);} 242#define GET_ATTRIBUTE_float(attrib,matInfo,attrib_offset) read_material_float(matInfo,attrib_offset) 243#define GET_ATTRIBUTE_vec4(attrib,matInfo,attrib_offset) read_material_vec4(matInfo,attrib_offset) 244#define GET_ATTRIBUTE_vec2(attrib,matInfo,attrib_offset) read_material_vec2(matInfo,attrib_offset) 245#define DECLARE_MATERIAL_TABLE_INFO MaterialInfo materialInfo=read_material_info(uint(gl_VertexID)); 246#define DECLARE_MATERIAL_TABLE_INFO_DEBUG(dbgColor) MaterialInfo materialInfo=read_material_info(uint(gl_VertexID)); dbgColor=materialInfo.colorDebug; 247#endif`,"_prelude_fog.fragment.glsl":sd,"_prelude_shadow.fragment.glsl":Fu,"_prelude_lighting.glsl":ad,"_prelude_raster_array.glsl":Tf},Ps={},yl="precision highp float;",cd="precision mediump float;",Tr=` 248#if defined(GL_EXT_blend_func_extended) && defined(DUAL_SOURCE_BLENDING) 249#extension GL_EXT_blend_func_extended : require 250#endif`,Nu={preludeTerrain:zt("",od),preludeFog:zt(sd,Ca),preludeShadow:zt(Fu,
250Sf),preludeRasterArray:zt(Tf,""),preludeLighting:zt(ad,ad),preludePrecisionQualifiers:zt(cd,yl),prelude:zt(gl,nd),preludeExtensions:zt(Tr,"")},Uu=[Tr,cd,_l,Nu.prelude.fragmentSource].join(` 251`),Z_=[yl,_l,Nu.prelude.vertexSource].join(` 252`);var Vu={background:zt(`#include "_prelude_fog.fragment.glsl" 253#include "_prelude_lighting.glsl" 254uniform vec4 u_color;uniform float u_opacity;uniform mediump float u_emissive_strength; 255#ifdef LIGHTING_3D_MODE 256in vec4 v_color; 257#endif 258void main() {vec4 out_color; 259#ifdef FEATURE_CUTOUT 260vec2 uv=gl_FragCoord.xy*u_inv_viewport_size.xy; 261#ifdef FLIP_Y 262uv.y=1.0-uv.y; 263#endif 264float factorTex=min(texture(u_cutout_factor_image,uv).r,1.0);float cutoutFactor=(1.0-u_feature_cutout_params.x)*factorTex;out_color=u_color*(1.0-cutoutFactor); 265#else 266#ifdef LIGHTING_3D_MODE 267out_color=v_color; 268#else 269out_color=u_color; 270#endif 271#ifdef FOG 272out_color=fog_dither(fog_apply_premultiplied(out_color,v_fog_pos)); 273#endif 274#endif 275glFragColor=out_color*u_opacity; 276#ifdef USE_MRT1 277out_Target1=vec4(u_emissive_strength*glFragColor.a,0.0,0.0,glFragColor.a); 278#endif 279#ifdef OVERDRAW_INSPECTOR 280glFragColor=vec4(1.0); 281#endif 282HANDLE_WIREFRAME_DEBUG;}`,`#include "_prelude_fog.vertex.glsl" 283#include "_prelude_lighting.glsl" 284in ivec2 a_pos;uniform mat4 u_matrix;uniform mediump float u_emissive_strength; 285#ifdef LIGHTING_3D_MODE 286uniform mediump vec4 u_color;out vec4 v_color; 287#endif 288void main() {gl_Position=u_matrix*vec4(a_pos,0,1); 289#ifndef FEATURE_CUTOUT 290#ifdef LIGHTING_3D_MODE 291v_color=apply_lighting_with_emission_ground(u_color,u_emissive_strength); 292#endif 293#ifdef FOG 294v_fog_pos=fog_position(vec2(a_pos)); 295#endif 296#endif 297}`),backgroundPattern:zt(`#include "_prelude_fog.fragment.glsl" 298#include "_prelude_lighting.glsl" 299uniform 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); 300#ifdef LIGHTING_3D_MODE 301out_color=apply_lighting_with_emission_ground(out_color,u_emissive_strength); 302#endif 303#ifdef FOG 304out_color=fog_dither(fog_apply_premultiplied(out_color,v_fog_pos)); 305#endif 306glFragColor=out_color*u_opacity; 307#ifdef USE_MRT1 308out_Target1=vec4(u_emissive_strength*glFragColor.a,0.0,0.0,glFragColor.a); 309#endif 310#ifdef OVERDRAW_INSPECTOR 311glFragColor=vec4(1.0); 312#endif 313HANDLE_WIREFRAME_DEBUG;}`,`#include "_prelude_fog.vertex.glsl" 314uniform mat4 u_matrix;uniform vec2 u_pattern_size;uniform vec2 u_pixel_coord_upper;uniform vec2 u_pixel_coord_lower;uniform vec2 u_pattern_units_to_pixels;in ivec2 a_pos;out highp vec2 v_pos;void main() {vec2 pos=vec2(a_pos);gl_Position=u_matrix*vec4(pos,0,1);v_pos=get_pattern_pos(u_pixel_coord_upper,u_pixel_coord_lower,u_pattern_size,u_pattern_units_to_pixels,pos); 315#ifdef FOG 316v_fog_pos=fog_position(pos); 317#endif 318}`),circle:zt(`#include "_prelude_fog.fragment.glsl" 319#include "_prelude_lighting.glsl" 320in vec3 v_data;in float v_visibility; 321#pragma mapbox: define highp vec4 color 322#pragma mapbox: define mediump float radius 323#pragma mapbox: define lowp float blur 324#pragma mapbox: define lowp float opacity 325#pragma mapbox: define highp vec4 stroke_color 326#pragma mapbox: define mediump float stroke_width 327#pragma mapbox: define lowp float stroke_opacity 328uniform float u_emissive_strength;void main() { 329#pragma mapbox: initialize highp vec4 color 330#pragma mapbox: initialize mediump float radius 331#pragma mapbox: initialize lowp float blur 332#pragma mapbox: initialize lowp float opacity 333#pragma mapbox: initialize highp vec4 stroke_color 334#pragma mapbox: initialize mediump float stroke_width 335#pragma mapbox: initialize lowp float stroke_opacity 336vec2 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 ? 337smoothstep(0.0,-antialiased_blur,1.0-extrude_length) : 338smoothstep(antialiased_blur,0.0,extrude_length-1.0)-antialiase_blur_op
338acity;float color_t=stroke_width < 0.01 ? 0.0 : smoothstep( 339antialiased_blur,0.0,extrude_length-radius/(radius+stroke_width) 340);vec4 out_color=mix(color*opacity,stroke_color*stroke_opacity,color_t); 341#ifdef LIGHTING_3D_MODE 342out_color=apply_lighting_with_emission_ground(out_color,u_emissive_strength); 343#endif 344#ifdef FOG 345out_color=fog_apply_premultiplied(out_color,v_fog_pos); 346#endif 347glFragColor=out_color*(v_visibility*opacity_t); 348#ifdef OVERDRAW_INSPECTOR 349glFragColor=vec4(1.0); 350#endif 351}`,`#include "_prelude_fog.vertex.glsl" 352#include "_prelude_terrain.vertex.glsl" 353#define NUM_VISIBILITY_RINGS 2 354#define INV_SQRT2 0.70710678 355#define ELEVATION_BIAS 0.0001 356#define NUM_SAMPLES_PER_RING 16 357uniform mat4 u_matrix;uniform mat2 u_extrude_scale;uniform lowp float u_device_pixel_ratio;uniform highp float u_camera_to_center_distance;in ivec2 a_pos; 358#ifdef PROJECTION_GLOBE_VIEW 359in ivec4 a_pos_3;in ivec4 a_pos_normal_3;uniform mat4 u_inv_rot_matrix;uniform vec2 u_merc_center;uniform vec3 u_tile_id;uniform float u_zoom_transition;uniform vec3 u_up_dir; 360#endif 361#ifdef ELEVATED_ROADS 362in float a_circle_z_offset; 363#endif 364out vec3 v_data;out float v_visibility; 365#pragma mapbox: define highp vec4 color 366#pragma mapbox: define mediump float radius 367#pragma mapbox: define lowp float blur 368#pragma mapbox: define lowp float opacity 369#pragma mapbox: define highp vec4 stroke_color 370#pragma mapbox: define mediump float stroke_width 371#pragma mapbox: define lowp float stroke_opacity 372vec2 calc_offset(vec2 extrusion,float radius,float stroke_width, float view_scale) {return extrusion*(radius+stroke_width)*u_extrude_scale*view_scale;}float cantilevered_elevation(vec2 pos,float radius,float stroke_width,float view_scale) {vec2 c1=pos+calc_offset(vec2(-1.0,-1.0),radius,stroke_width,view_scale);vec2 c2=pos+calc_offset(vec2(1.0,-1.0),radius,stroke_width,view_scale);vec2 c3=pos+calc_offset(vec2(1.0,1.0),radius,stroke_width,view_scale);vec2 c4=pos+calc_offset(vec2(-1.0,1.0),radius,stroke_width,view_scale);float h1=elevation(c1)+ELEVATION_BIAS;float h2=elevation(c2)+ELEVATION_BIAS;float h3=elevation(c3)+ELEVATION_BIAS;float h4=elevation(c4)+ELEVATION_BIAS;return max(h4,max(h3,max(h1,h2)));}float circle_elevation(vec2 pos) { 373#if defined(TERRAIN) 374return elevation(pos)+ELEVATION_BIAS; 375#else 376return 0.0; 377#endif 378}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); 379#ifdef PITCH_WITH_MAP 380#ifdef PROJECTION_GLOBE_VIEW 381return u_matrix*( world_center+vec4(sample_offset.x*surface_vectors[0]+sample_offset.y*surface_vectors[1],0) ); 382#else 383return u_matrix*( world_center+vec4(sample_offset,0,0) ); 384#endif 385#else 386return projected_center+vec4(sample_offset,0,0); 387#endif 388}float get_sample_step() { 389#ifdef PITCH_WITH_MAP 390return 2.0*PI/float(NUM_SAMPLES_PER_RING); 391#else 392return PI/float(NUM_SAMPLES_PER_RING); 393#endif 394}void main() { 395#pragma mapbox: initialize highp vec4 color 396#pragma mapbox: initialize mediump float radius 397#pragma mapbox: initialize lowp float blur 398#pragma mapbox: initialize lowp float opacity 399#pragma mapbox: initialize highp vec4 stroke_color 400#pragma mapbox: initialize mediump float stroke_width 401#pragma mapbox: initialize lowp float stroke_opacity 402vec2 pos2=vec2(a_pos);vec2 extrude=vec2(mod(pos2,2.0)*2.0-1.0);vec2 circle_center=floor(pos2*0.5);float height=circle_elevation(circle_center);vec4 world_center;mat3 surface_vectors; 403#ifdef PROJECTION_GLOBE_VIEW 404surface_vectors=globe_mercator_surface_vectors(vec3(a_pos_normal_3)/16384.0,u_up_dir,u_zoom_transition);vec3 surface_extrusion=extrude.x*surface_vectors[0]+extrude.y*surface_vectors[1];vec3 globe_elevation=elevationVector(circle_center)*height;vec3 globe_pos=vec3(a_pos_3)+surface_extrusion+globe_elevation;vec3 mercator_elevation=u_up_dir*u_tile_up_scale*height;vec3 merc_pos=mercator_tile_position(u_inv_rot_matrix,circle_center,u_tile_id,u_merc_center)+surface_extrusion+mercator_elevation;vec3 pos=mix_globe_mercator(globe_pos,merc_pos,u_zoom_transition);world_center=vec4(pos,1); 405#else
406surface_vectors=mat3(1.0);world_center=vec4(circle_center,height,1); 407#endif 408#ifdef ELEVATED_ROADS 409world_center.z+=a_circle_z_offset+ELEVATION_BIAS; 410#endif 411vec4 projected_center=u_matrix*world_center;float view_scale=0.0; 412#ifdef PITCH_WITH_MAP 413#ifdef SCALE_WITH_MAP 414view_scale=1.0; 415#else 416view_scale=projected_center.w/u_camera_to_center_distance; 417#endif 418#else 419#ifdef SCALE_WITH_MAP 420view_scale=u_camera_to_center_distance; 421#else 422view_scale=projected_center.w; 423#endif 424#endif 425gl_Position=project_vertex(extrude,world_center,projected_center,radius,stroke_width,view_scale,surface_vectors);float visibility=0.0; 426#ifdef TERRAIN 427float step=get_sample_step();vec4 occlusion_world_center;vec4 occlusion_projected_center; 428#ifdef PITCH_WITH_MAP 429float 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; 430#else 431occlusion_world_center=world_center;occlusion_projected_center=projected_center; 432#endif 433for(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); 434#else 435visibility=1.0; 436#endif 437#ifdef PROJECTION_GLOBE_VIEW 438visibility=1.0; 439#endif 440v_visibility=visibility;lowp float antialiasblur=1.0/u_device_pixel_ratio/(radius+stroke_width);v_data=vec3(extrude.x,extrude.y,antialiasblur); 441#ifdef FOG 442v_fog_pos=fog_position(world_center.xyz); 443#endif 444}`),clippingMask:zt("void main() {glFragColor=vec4(1.0);}","in ivec2 a_pos;uniform mat4 u_matrix;void main() {gl_Position=u_matrix*vec4(a_pos,0,1);}"),heatmap:zt(`#include "_prelude_fog.fragment.glsl" 445uniform highp float u_intensity;in vec2 v_extrude; 446#pragma mapbox: define highp float weight 447#define GAUSS_COEF 0.3989422804014327 448void main() { 449#pragma mapbox: initialize highp float weight 450float 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); 451#ifdef FOG 452if (u_is_globe==0) {glFragColor.r*=pow(1.0-fog_opacity(v_fog_pos),2.0);} 453#endif 454#ifdef OVERDRAW_INSPECTOR 455glFragColor=vec4(1.0); 456#endif 457HANDLE_WIREFRAME_DEBUG;}`,`#include "_prelude_terrain.vertex.glsl" 458#include "_prelude_fog.vertex.glsl" 459uniform mat4 u_matrix;uniform float u_extrude_scale;uniform float u_opacity;uniform float u_intensity;in ivec2 a_pos; 460#ifdef PROJECTION_GLOBE_VIEW 461in ivec4 a_pos_3;in ivec4 a_pos_normal_3;uniform mat4 u_inv_rot_matrix;uniform vec2 u_merc_center;uniform vec3 u_tile_id;uniform float u_zoom_transition;uniform vec3 u_up_dir; 462#endif 463out vec2 v_extrude; 464#pragma mapbox: define highp float weight 465#pragma mapbox: define mediump float radius 466const highp float ZERO=1.0/255.0/16.0; 467#define GAUSS_COEF 0.3989422804014327 468void main() { 469#pragma mapbox: initialize highp float weight 470#pragma mapbox: initialize mediump float radius 471vec2 unscaled_extrude=vec2(mod(vec2(a_pos),2.0)*2.0-1.0);float S=sqrt(-2.0*log(ZERO/weight/u_intensity/GAUSS_COEF))/3.0;v_extrude=S*unscaled_extrude;vec2 extrude=v_extrude*radius*u_extrude_scale;vec2 tilePos=floor(vec2(a_pos)*0.5);vec3 pos; 472#ifdef PROJECTION_GLOBE_VIEW 473vec3 pos_normal_3=vec3(a_pos_normal_3)/16384.0;mat3 surface_vectors=globe_mercator_surface_vectors(pos_normal_3,u_up_dir,u_zoom_transition);vec3 surface_extrusion=extrude.x*surface_vectors[0]+extrude.y*surface_vectors[1];vec3 globe_elevation=elevationVector(tilePos)*elevation(tilePos);vec3 globe_pos=vec3(a_pos_3)+surface_extrusion+globe_elevation;vec3 mercator_elevation=u_up_dir*u_tile_up_scale*elevation(tilePos);vec3 merc_pos=mercator_tile_position(u_inv_rot_matrix,tilePos,u_tile_id,u_merc_center)+surface_extrusion+mercator_elevation;pos=mix_globe_mercator(globe_pos,merc_pos,u_zoom_transition); 474#else 475pos=vec3(tilePos+extrude,elevation(tilePos)); 476#endif 477gl_Position=u_matrix*vec4(pos,1); 478#ifdef FOG 479v_fog_pos=fog_position(pos); 480#endif 481}`),heatmapTexture:zt(`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; 482#ifdef OVERDRAW_INSPECTOR 483glFragColor=vec4(0.0); 484#endif 485HANDLE_WIREFRAME_DEBUG;}`,"in ivec2 a_pos;out vec2 v_pos;void main() {gl_Position=vec4(a_pos,0,1);v_pos=vec2(a_pos)*0.5+0.5;}"),collisionBox:zt("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" 486in ivec4 a_pos;in ivec2 a_anchor_pos;in ivec2 a_extrude;in uvec2 a_placed;in vec2 a_shift;in vec2 a_elevation_from_sea;in float a_size_scale;in vec2 a_padding;in float a_auto_z_offset;uniform mat4 u_matrix;uniform vec2 u_extrude_scale;uniform float u_camera_to_center_distance; 487#ifdef PROJECTION_GLOBE_VIEW 488uniform vec3 u_tile_id;uniform mat4 u_inv_rot_matrix;uniform vec2 u_merc_center;uniform float u_zoom_transition; 489#endif 490out float v_placed;out float v_notUsed;void main() {vec2 anchor_pos=vec2(a_anchor_pos);float feature_elevation=a_elevation_from_sea.x+a_auto_z_offset;float terrain_elevation=(a_elevation_from_sea.y==1.0 ? 0.0 : elevation(anchor_pos));vec3 proj_pos=vec3(a_pos)+elevationVector(anchor_pos)*(feature_elevation+terrain_elevation); 491#ifdef PROJECTION_GLOBE_VIEW 492#ifndef PROJECTED_POS_ON_VIEWPORT 493vec3 globe_pos=proj_pos;vec3 mercator_pos=mercator_tile_position(u_inv_rot_matrix,anchor_pos,u_tile_id,u_merc_center);proj_pos=mix_globe_mercator(globe_pos,mercator_pos,u_zoom_transition); 494#endif 495#endif 496vec4 projectedPoint=u_matrix*vec4(proj_pos,1);highp float camera_to_anchor_distance=projectedPoint.w;highp float collision_perspective_ratio=clamp( 4970.5+0.5*(u_camera_to_center_distance/camera_to_anchor_distance),0.0,1.5);gl_Position=projectedPoint;gl_Position.xy+=(vec2(a_extrude)*a_size_scale+a_shift+a_padding)*u_extrude_scale*gl_Position.w*collision_perspective_ratio;v_placed=float(a_placed.x);v_notUsed=float(a_placed.y);}`),collisionCircle:zt("in float v_radius;in vec2 v_extrude;in float v_perspective_ratio;in float v_collision;void main() {float alpha=0.5*min(v_perspective_ratio,1.0);float stroke_radius=0.9*max(v_perspective_ratio,1.0);float distance_to_center=length(v_extrude);float distance_to_edge=abs(distance_to_center-v_radius);float opacity_t=smoothstep(-stroke_radius,0.0,-distance_to_edge);vec4 color=mix(vec4(0.0,0.0,1.0,0.5),vec4(1.0,0.0,0.0,1.0),v_collision);glFragColor=color*alpha*opacity_t;}",`in vec2 a_pos_2f;in float a_radius;in ivec2 a_flags;uniform mat4 u_matrix;uniform mat4 u_inv_matrix;uniform vec2 u_viewport_size;uniform float u_camera_to_center_distance;out float v_radius;out vec2 v_extrude;out float v_perspective_ratio;out float v_collision;vec3 toTilePosition(vec2 screenPos) {vec4 rayStart=u_inv_matrix*vec4(screenPos,-1.0,1.0);vec4 rayEnd =u_inv_matrix*vec4(screenPos, 1.0,1.0);rayStart.xyz/=rayStart.w;rayEnd.xyz /=rayEnd.w;highp float t=(0.0-rayStart.z)/(rayEnd.z-rayStart.z);return mix(rayStart.xyz,rayEnd.xyz,t);}void main() {vec2 quadCenterPos=a_pos_2f;float radius=a_radius;int vertexIdx=a_flags.y;vec2 quadVertexOffset=vec2( 498mix(-1.0,1.0,float(vertexIdx >=2)),mix(-1.0,1.0,float(vertexIdx >=1 && vertexIdx <=2)));vec2 quadVertexExtent=quadVertexOffset*radius;vec3 tilePos=toTilePosition(quadCenterPos);vec4 clipPos=u_matrix*vec4(tilePos,1.0);highp float camera_to_anchor_distance=clipPos.w;highp float collision_perspective_ratio=clamp( 4990.5+0.5*(u_camera_to_center_distance/camera_to_anchor_distance),0.0,4.0);float padding_factor=1.2;v_radius=radius;v_extrude=quadVertexExtent*padding_factor;v_perspective_ratio=collision_perspective_ratio;v_collision=float(a_flags.x);gl_Position=vec4(clipPos.xyz/clipPos.w,1.0)+vec4(quadVertexExtent*padding_factor/u_viewport_size*2.0,0.0,0.0);}`),debug:zt("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" 500in ivec2 a_pos; 501#ifdef PROJECTION_GLOBE_VIEW 502in ivec4 a_pos_3; 503#endif 504out vec2 v_uv;uniform mat4 u_matrix;uniform float u_overlay_scale;void main() {vec2 pos=vec2(a_pos);float h=elevation(pos);v_uv=pos/8192.0; 505#ifdef PROJECTION_GLOBE_VIEW
506gl_Position=u_matrix*vec4(vec3(a_pos_3)+elevationVector(pos)*h,1); 507#else 508gl_Position=u_matrix*vec4(pos*u_overlay_scale,h,1); 509#endif 510}`),elevatedStructuresDepth:zt("void main() {}","in ivec2 a_pos;in float a_height;uniform mat4 u_matrix;uniform float u_depth_bias;void main() {gl_Position=u_matrix*vec4(a_pos,a_height,1);gl_Position.z=gl_Position.z+u_depth_bias;}"),elevatedStructuresDepthReconstruct:zt(`#ifdef DEPTH_RECONSTRUCTION 511in float v_height; 512#endif 513void main() { 514#ifdef DEPTH_RECONSTRUCTION 515if (v_height >=0.0) 516discard; 517#else 518#ifdef FEATURE_CUTOUT 519apply_feature_cutout(vec4(0.0,0.0,0.0,1.0),gl_FragCoord,get_cutout_factors(gl_FragCoord).x); 520#endif 521#endif 522glFragColor=vec4(1.0,0.0,0.0,1.0);}`,`in ivec2 a_pos;in float a_height;uniform mat4 u_matrix;uniform vec3 u_camera_pos;uniform highp float u_depth_bias;uniform lowp float u_height_scale;uniform lowp float u_reset_depth; 523#ifdef DEPTH_RECONSTRUCTION 524out float v_height; 525#endif 526void main() {vec3 vpos=vec3(a_pos,a_height*u_height_scale); 527#ifdef DEPTH_RECONSTRUCTION 528if (u_camera_pos.z > vpos.z) {vpos-=(u_camera_pos-vpos)*(vpos.z/(u_camera_pos.z-vpos.z));}v_height=a_height; 529#endif 530gl_Position=u_matrix*vec4(vpos,1);gl_Position.z=u_reset_depth==1.0 ? gl_Position.w : gl_Position.z+u_depth_bias;}`),elevatedStructures:zt(`#include "_prelude_fog.fragment.glsl" 531#include "_prelude_lighting.glsl" 532#include "_prelude_shadow.fragment.glsl" 533in vec3 v_normal;in float v_height; 534#ifdef RENDER_SHADOWS 535in highp vec4 v_pos_light_view_0;in highp vec4 v_pos_light_view_1;in float v_depth; 536#endif 537vec3 linearTosRGB(vec3 color) {return pow(color,vec3(1./2.2));}vec3 sRGBToLinear(vec3 srgbIn) {return pow(srgbIn,vec3(2.2));}
537vec3 compute_view_dependent_emissive_color(float ndotl,float emissive_strength,vec3 color) 538{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; 539#pragma mapbox: define highp vec4 structure_color 540void main() { 541#pragma mapbox: initialize highp vec4 structure_color 542vec3 color=structure_color.xyz;vec2 cutout_factors=vec2(0.0); 543#ifdef FEATURE_CUTOUT 544cutout_factors=get_cutout_factors(gl_FragCoord); 545#endif 546#ifdef LIGHTING_3D_MODE 547vec3 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); 548#ifdef RENDER_SHADOWS 549float light=shadowed_light_factor_normal(transformed_normal,v_pos_light_view_0,v_pos_light_view_1,v_depth);light=mix(light,1.0,cutout_factors.y);color.rgb=apply_lighting(color.rgb,transformed_normal,light); 550#else 551color=apply_lighting(color,transformed_normal); 552#endif 553color=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);} 554#endif 555#ifdef FOG 556color=fog_apply(color,v_fog_pos); 557#endif 558vec4 out_color=vec4(color,1.0); 559#ifdef INDICATOR_CUTOUT 560out_color=applyCutout(out_color,v_height); 561#endif 562#ifdef FEATURE_CUTOUT 563out_color=apply_feature_cutout(out_color,gl_FragCoord,cutout_factors.x); 564#endif 565glFragColor=out_color;HANDLE_WIREFRAME_DEBUG;}`,`#include "_prelude_fog.vertex.glsl" 566#include "_prelude_shadow.vertex.glsl" 567in ivec2 a_pos;in float a_height;in ivec4 a_pos_normal_3;uniform mat4 u_matrix;out vec3 v_normal;out float v_height; 568#ifdef RENDER_SHADOWS 569uniform 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; 570#endif 571#pragma mapbox: define highp vec4 structure_color 572void main() { 573#pragma mapbox: initialize highp vec4 structure_color 574v_normal=vec3(a_pos_normal_3)/16384.0;v_height=a_height;vec3 pos=vec3(vec2(a_pos),a_height);gl_Position=u_matrix*vec4(pos,1); 575#ifdef RENDER_SHADOWS 576vec3 shd_pos0=pos;vec3 shd_pos1=pos; 577#ifdef NORMAL_OFFSET 578vec3 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(); 579#endif 580v_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; 581#endif 582#ifdef FOG 583v_fog_pos=fog_position(vec2(a_pos)); 584#endif 585}`),fill:zt(`#include "_prelude_fog.fragment.glsl" 586#include "_prelude_lighting.glsl" 587#include "_prelude_shadow.fragment.glsl" 588#pragma mapbox: define highp vec4 color 589#pragma mapbox: define lowp float opacity 590uniform float u_emissive_strength; 591#ifdef RENDER_SHADOWS 592uniform 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; 593#endif 594#ifdef ELEVATED_ROADS 595in highp float v_road_z_offset; 596#endif 597#ifdef INDICATOR_CUTOUT 598in highp float v_z_offset; 599#endif 600void main() { 601#pragma mapbox: initialize highp vec4 color 602#pragma mapbox: initialize lowp float opacity 603vec2 cutout_factors=vec2(0.0); 604#ifdef FEATURE_CUTOUT 605cutout_factors=get_cutout_factors(gl_FragCoord); 606#endif 607vec4 out_color=color; 608#ifdef LIGHTING_3D_MODE 609out_color=apply_lighting_with_emission_ground(out_color,u_emissive_strength); 610#ifdef RENDER_SHADOWS 611float light=shadowed_light_factor(v_pos_light_view_0,v_pos_light_view_1,v_depth);light=mix(light,1.0,cutout_factors.y);out_color.rgb*=mix(u_ground_shadow_factor,vec3(1.0),light); 612#endif 613#endif 614#ifdef FOG 615out_color=fog_dither(fog_apply_premultiplied(out_color,v_fog_pos)); 616#endif 617out_color*=opacity; 618#ifdef INDICATOR_CUTOUT 619if (v_z_offset >=0.0) {out_color=applyCutout(out_color,v_z_offset);} 620#endif 621#ifdef FEATURE_CUTOUT 622out_color=apply_feature_cutout(out_color,gl_FragCoord,cutout_factors.x); 623#endif 624glFragColor=out_color; 625#ifdef USE_MRT1 626out_Target1=vec4(u_emissive_strength*glFragColor.a,0.0,0.0,glFragColor.a); 627#endif 628#ifdef OVERDRAW_INSPECTOR 629glFragColor=vec4(1.0); 630#endif 631HANDLE_WIREFRAME_DEBUG;}`,`#include "_prelude_fog.vertex.glsl" 632#include "_prelude_shadow.vertex.glsl" 633in ivec2 a_pos; 634#ifdef ELEVATED_ROADS 635in float a_road_z_offset;out highp float v_road_z_offset; 636#endif 637#ifdef RENDER_SHADOWS 638uniform 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; 639#endif 640#ifdef INDICATOR_CUTOUT 641out highp float v_z_offset; 642#endif 643uniform mat4 u_matrix; 644#pragma mapbox: define highp vec4 color 645#pragma mapbox: define lowp float opacity 646#pragma mapbox: define highp float z_offset 647void main() { 648#pragma mapbox: initialize highp vec4 color 649#pragma mapbox: initialize lowp float opacity 650#pragma mapbox: initialize highp float z_offset 651#ifdef ELEVATED_ROADS 652z_offset+=a_road_z_offset;v_road_z_offset=z_offset; 653#endif 654float hidden=float(opacity==0.0);gl_Position=mix(u_matrix*vec4(a_pos,z_offset,1),AWAY,hidden); 655#ifdef RENDER_SHADOWS 656vec3 shd_pos0=vec3(a_pos,z_offset);vec3 shd_pos1=vec3(a_pos,z_offset); 657#ifdef NORMAL_OFFSET 658vec3 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(); 659#endif 660v_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; 661#endif 662#ifdef FOG 663v_fog_pos=fog_position(vec2(a_pos)); 664#endif 665#ifdef INDICATOR_CUTOUT 666v_z_offset=z_offset; 667#endif 668}`),fillOutline:zt(`#include "_prelude_fog.fragment.glsl" 669#include "_prelude_lighting.glsl" 670#include "_prelude_shadow.fragment.glsl" 671in highp vec2 v_pos;uniform float u_emissive_strength; 672#ifdef RENDER_SHADOWS 673uniform 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; 674#endif 675#pragma mapbox: define highp vec4 outline_color 676#pragma mapbox: define lowp float opacity 677void main() { 678#pragma mapbox: initialize highp vec4 outline_color 679#pragma mapbox: initialize lowp float opacity 680float dist=length(v_pos-gl_FragCoord.xy);float alpha=1.0-smoothstep(0.0,1.0,dist);vec4 out_color=outline_color;vec2 cutout_factors=vec2(0.0); 681#ifdef FEATURE_CUTOUT 682cutout_factors=get_cutout_factors(gl_FragCoord); 683#endif 684#ifdef LIGHTING_3D_MODE 685out_color=apply_lighting_with_emission_ground(out_color,u_emissive_strength); 686#ifdef RENDER_SHADOWS 687float light=shadowed_light_factor(v_pos_light_view_0,v_pos_light_view_1,v_depth);light=mix(light,1.0,cutout_factors.y);out_color.rgb*=mix(u_ground_shadow_factor,vec3(1.0),light); 688#endif 689#endif 690#ifdef FOG 691out_color=fog_dither(fog_apply_premultiplied(out_color,v_fog_pos)); 692#endif 693#ifdef FEATURE_CUTOUT 694out_color=apply_feature_cutout(out_color,gl_FragCoord,cutout_factors.x); 695#endif 696glFragColor=out_color*(alpha*opacity); 697#ifdef USE_MRT1 698out_Target1=vec4(u_emissive_strength*glFragColor.a,0.0,0.0,glFragColor.a); 699#endif 700#ifdef OVERDRAW_INSPECTOR 701glFragColor=vec4(1.0); 702#endif 703HANDLE_WIREFRAME_DEBUG;}`,`#include "_prelude_fog.vertex.glsl" 704#include "_prelude_shadow.vertex.glsl" 705in ivec2 a_pos; 706#ifdef ELEVATED_ROADS 707in float a_road_z_offset; 708#endif 709#ifdef RENDER_SHADOWS 710uniform 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; 711#endif 712uniform mat4 u_matrix;uniform vec2 u_world;out highp vec2 v_pos; 713#pragma mapbox: define highp vec4 outline_color 714#pragma mapbox: define lowp float opacity 715#pragma mapbox: define highp float z_offset 716void main() { 717#pragma mapbox: initialize highp vec4 outline_color 718#pragma mapbox: initialize lowp float opacity 719#pragma mapbox: initialize highp float z_offset 720#ifdef ELEVATED_ROADS 721z_offset+=a_road_z_offset; 722#endif 723float hidden=float(opacity==0.0);gl_Position=mix(u_matrix*vec4(a_pos,z_offset,1),AWAY,hidden); 724#ifdef FLIP_Y 725v_pos=(vec2(gl_Position.x,-gl_Position.y)/gl_Position.w+1.0)/2.0*u_world; 726#else 727v_pos=(gl_Position.xy/gl_Position.w+1.0)/2.0*u_world; 728#endif 729#ifdef RENDER_SHADOWS 730vec3 shd_pos0=vec3(a_pos,z_offset);vec3 shd_pos1=vec3(a_pos,z_offset); 731#ifdef NORMAL_OFFSET 732vec3 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(); 733#endif 734v_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; 735#endif 736#ifdef FOG 737v_fog_pos=fog_position(vec2(a_pos)); 738#endif 739}`),fillOutlinePattern:zt(`#include "_prelude_fog.fragment.glsl" 740#include "_prelude_lighting.glsl" 741#include "_prelude_shadow.fragment.glsl" 742uniform vec2 u_texsize;uniform sampler2D u_image; 743#ifdef FILL_PATTERN_TRANSITION 744uniform float u_pattern_transition; 745#endif 746uniform float u_emissive_strength; 747#ifdef APPLY_LUT_ON_GPU 748uniform highp sampler3D u_lutTexture; 749#endif 750#ifdef RENDER_SHADOWS 751uniform 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; 752#endif 753in highp vec2 v_pos;in highp vec2 v_pos_world; 754#pragma mapbox: define lowp float opacity 755#pragma mapbox: define lowp uvec4 pattern 756#ifdef FILL_PATTERN_TRANSITION 757#pragma mapbox: define mediump uvec4 pattern_b 758#endif 759void main() { 760#pragma mapbox: initialize lowp float opacity 761#pragma mapbox: initialize mediump uvec4 pattern 762#ifdef FILL_PATTERN_TRANSITION 763#pragma mapbox: initialize mediump uvec4 pattern_b 764#endif 765vec2 pattern_tl=vec2(pattern.xy);vec2 pattern_br=vec2(pattern.zw);highp vec2 imagecoord=mod(v_pos,1.0);highp vec2 pos=mix(pattern_tl/u_texsize,pattern_br/u_texsize,imagecoord);highp vec2 lod_pos=mix(pattern_tl/u_texsize,pattern_br/u_texsize,v_pos);float dist=length(v_pos_world-gl_FragCoord.xy);float alpha=1.0-smoothstep(0.0,1.0,dist);vec4 out_color=textureLodCustom(u_image,pos,lod_pos); 766#ifdef APPLY_LUT_ON_GPU 767out_color=applyLUT(u_lutTexture,out_color); 768#endif 769#ifdef FILL_PATTERN_TRANSITION 770vec2 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; 771#endif 772vec2 cutout_factors=vec2(0.0); 773#ifdef FEATURE_CUTOUT 774cutout_factors=get_cutout_factors(gl_FragCoord); 775#endif 776#ifdef LIGHTING_3D_MODE 777out_color=apply_lighting_with_emission_ground(out_color,u_emissive_strength); 778#ifdef RENDER_SHADOWS 779float light=shadowed_light_factor(v_pos_light_view_0,v_pos_light_view_1,v_depth);light=mix(light,1.0,cutout_factors.y);out_color.rgb*=mix(u_ground_shadow_factor,vec3(1.0),light); 780#endif 781#endif 782#ifdef FEATURE_CUTOUT 783out_color=apply_feature_cutout(out_color,gl_FragCoord,cutout_factors.x); 784#endif 785#ifdef FOG 786out_color=fog_dither(fog_apply_premultiplied(out_color,v_fog_pos)); 787#endif 788glFragColor=out_color*(alpha*opacity); 789#ifdef USE_MRT1 790out_Target1=vec4(u_emissive_strength*glFragColor.a,0.0,0.0,glFragColor.a); 791#endif 792#ifdef OVERDRAW_INSPECTOR 793glFragColor=vec4(1.0); 794#endif 795HANDLE_WIREFRAME_DEBUG;}`,`#include "_prelude_fog.vertex.glsl" 796#include "_prelude_shadow.vertex.glsl" 797uniform mat4 u_matrix;uniform vec2 u_world;uniform vec2 u_pixel_coord_upper;uniform vec2 u_pixel_coord_lower;uniform float u_tile_units_to_pixels;in ivec2 a_pos; 798#ifdef ELEVATED_ROADS 799in float a_road_z_offset; 800#endif 801#ifdef RENDER_SHADOWS 802uniform 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; 803#endif 804out highp vec2 v_pos;out highp vec2 v_pos_world; 805#pragma mapbox: define lowp float opacity 806#pragma mapbox: define lowp uvec4 pattern 807#ifdef FILL_PATTERN_TRANSITION 808#pragma mapbox: define mediump uvec4 pattern_b 809#endif 810#pragma mapbox: define lowp float pixel_ratio 811#pragma mapbox: define highp float z_offset 812void main() { 813#pragma mapbox: initialize lowp float opacity 814#pragma mapbox: initialize mediump uvec4 pattern 815#ifdef FILL_PATTERN_TRANSITION 816#pragma mapbox: initialize mediump uvec4 pattern_b 817#endif 818#pragma mapbox: initialize lowp float pixel_ratio 819#pragma mapbox: initialize highp float z_offset 820vec2 pattern_tl=vec2(pattern.xy);vec2 pattern_br=vec2(pattern.zw); 821#ifdef ELEVATED_ROADS 822z_offset+=a_road_z_offset; 823#endif 824float hidden=float(opacity==0.0);vec2 pos=vec2(a_pos);gl_Position=mix(u_matrix*vec4(pos,z_offset,1),AWAY,hidden);vec2 display_size=(pattern_br-pattern_tl)/pixel_ratio;v_pos=get_pattern_pos(u_pixel_coord_upper,u_pixel_coord_lower,display_size,u_tile_units_to_pixels,pos); 825#ifdef FLIP_Y 826v_pos_world=(vec2(gl_Position.x,-gl_Position.y)/gl_Position.w+1.0)/2.0*u_world; 827#else 828v_pos_world=(gl_Position.xy/gl_Position.w+1.0)/2.0*u_world; 829#endif 830#ifdef RENDER_SHADOWS 831vec3 shd_pos0=vec3(pos,z_offset);vec3 shd_pos1=vec3(pos,z_offset); 832#ifdef NORMAL_OFFSET 833vec3 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(); 834#endif 835v_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; 836#endif 837#ifdef FOG 838v_fog_pos=fog_position(pos); 839#endif 840}`),fillPattern:zt(`#include "_prelude_fog.fragment.glsl" 841#include "_prelude_lighting.glsl" 842#include "_prelude_shadow.fragment.glsl" 843uniform vec2 u_texsize;uniform sampler2D u_image; 844#ifdef FILL_PATTERN_TRANSITION 845uniform float u_pattern_transition; 846#endif 847in highp vec2 v_pos;uniform float u_emissive_strength; 848#ifdef RENDER_SHADOWS 849uniform 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; 850#endif 851#ifdef ELEVATED_ROADS 852in highp float v_road_z_offset; 853#endif 854#ifdef APPLY_LUT_ON_GPU 855uniform highp sampler3D u_lutTexture; 856#endif 857#pragma mapbox: define lowp float opacity 858#pragma mapbox: define lowp uvec4 pattern 859#ifdef FILL_PATTERN_TRANSITION 860#pragma mapbox: define mediump uvec4 pattern_b 861#endif 862void main() { 863#pragma mapbox: initialize lowp float opacity 864#pragma mapbox: initialize mediump uvec4 pattern 865#ifdef FILL_PATTERN_TRANSITION 866#pragma mapbox: initialize mediump uvec4 pattern_b 867#endif 868vec2 pattern_tl=vec2(pattern.xy);vec2 pattern_br=vec2(pattern.zw);highp vec2 imagecoord=mod(v_pos,1.0);highp vec2 pos=mix(pattern_tl/u_texsize,pattern_br/u_texsize,imagecoord);highp vec2 lod_pos=mix(pattern_tl/u_texsize,pattern_br/u_texsize,v_pos);vec4 out_color=textureLodCustom(u_image,pos,lod_pos); 869#ifdef APPLY_LUT_ON_GPU 870out_color=applyLUT(u_lutTexture,out_color); 871#endif 872#ifdef FILL_PATTERN_TRANSITION 873vec2 pattern_b_tl=vec2(pattern_b.xy);vec2 pattern_b_br=vec2(pattern_b.zw);highp vec2 pos_b=mix(pattern_b_tl/u_texsize,pattern_b_br/u_texsize,imagecoord);vec4 color_b=textureLodCustom(u_image,pos_b,lod_pos);out_color=out_color*(1.0-u_pattern_transition)+color_b*u_pattern_transition; 874#endif 875vec2 cutout_factors=vec2(0.0); 876#ifdef FEATURE_CUTOUT 877cutout_factors=get_cutout_factors(gl_FragCoord); 878#endif 879#ifdef LIGHTING_3D_MODE 880out_color=apply_lighting_with_emission_ground(out_color,u_emissive_strength); 881#ifdef RENDER_SHADOWS 882float light=shadowed_light_factor(v_pos_light_view_0,v_pos_light_view_1,v_depth);light=mix(light,1.0,cutout_factors.y); 883#ifdef ELEVATED_ROADS 884out_color.rgb*=mix(v_road_z_offset !=0.0 ? u_ground_shadow_factor : vec3(1.0),vec3(1.0),light); 885#else 886out_color.rgb*=mix(u_ground_shadow_factor,vec3(1.0),light); 887#endif 888#endif 889#endif 890#ifdef FEATURE_CUTOUT 891out_color=apply_feature_cutout(out_color,gl_FragCoord,cutout_factors.x); 892#endif 893#ifdef FOG 894out_color=fog_dither(fog_apply_premultiplied(out_color,v_fog_pos)); 895#endif 896glFragColor=out_color*opacity; 897#ifdef USE_MRT1 898out_Target1=vec4(u_emissive_strength*glFragColor.a,0.0,0.0,glFragColor.a); 899#endif 900#ifdef OVERDRAW_INSPECTOR 901glFragColor=vec4(1.0); 902#endif 903HANDLE_WIREFRAME_DEBUG;}`,`#include "_prelude_fog.vertex.glsl" 904#include "_prelude_shadow.vertex.glsl" 905uniform mat4 u_matrix;uniform vec2 u_pixel_coord_upper;uniform vec2 u_pixel_coord_lower;uniform float u_tile_units_to_pixels;in ivec2 a_pos; 906#ifdef ELEVATED_ROADS 907in float a_road_z_offset;out highp float v_road_z_offset; 908#endif 909#ifdef RENDER_SHADOWS 910uniform 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 floa
910t v_depth; 911#endif 912out highp vec2 v_pos; 913#pragma mapbox: define lowp float opacity 914#pragma mapbox: define lowp uvec4 pattern 915#ifdef FILL_PATTERN_TRANSITION 916#pragma mapbox: define mediump uvec4 pattern_b 917#endif 918#pragma mapbox: define lowp float pixel_ratio 919#pragma mapbox: define highp float z_offset 920void main() { 921#pragma mapbox: initialize lowp float opacity 922#pragma mapbox: initialize mediump uvec4 pattern 923#pragma mapbox: initialize lowp float pixel_ratio 924#pragma mapbox: initialize highp float z_offset 925#ifdef FILL_PATTERN_TRANSITION 926#pragma mapbox: initialize mediump uvec4 pattern_b 927#endif 928vec2 pattern_tl=vec2(pattern.xy);vec2 pattern_br=vec2(pattern.zw);vec2 display_size=(pattern_br-pattern_tl)/pixel_ratio; 929#ifdef ELEVATED_ROADS 930z_offset+=a_road_z_offset;v_road_z_offset=z_offset; 931#endif 932float hidden=float(opacity==0.0);vec2 pos=vec2(a_pos);gl_Position=mix(u_matrix*vec4(pos,z_offset,1),AWAY,hidden);v_pos=get_pattern_pos(u_pixel_coord_upper,u_pixel_coord_lower,display_size,u_tile_units_to_pixels,pos); 933#ifdef RENDER_SHADOWS 934vec3 shd_pos0=vec3(pos,z_offset);vec3 shd_pos1=vec3(pos,z_offset); 935#ifdef NORMAL_OFFSET 936vec3 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(); 937#endif 938v_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; 939#endif 940#ifdef FOG 941v_fog_pos=fog_position(pos); 942#endif 943}`),lineBlendComposite:zt(`uniform highp sampler2D u_image;uniform float u_opacity;uniform int u_blend_mode;uniform highp float u_max_density;in vec2 v_pos; 944#define ADDITIVE 1 945void main() {vec4 color=texture(u_image,v_pos);if (u_blend_mode==ADDITIVE) {if (color.a <=0.0) {discard;}highp float density=color.a;vec3 avgColor=color.rgb/max(density,0.001);highp float n=density/max(u_max_density,0.001);highp float t=sqrt(n/(n+1.0));glFragColor=vec4(avgColor*t,t);} else {vec3 multiplyFactor=color.rgb*u_opacity+(1.0-u_opacity);glFragColor=vec4(multiplyFactor,1.0);} 946#ifdef OVERDRAW_INSPECTOR 947glFragColor=vec4(0.0); 948#endif 949HANDLE_WIREFRAME_DEBUG;}`,"in ivec2 a_pos;out vec2 v_pos;void main() {gl_Position=vec4(a_pos,0,1);v_pos=vec2(a_pos)*0.5+0.5;}"),lineBlendReduce:zt("uniform highp sampler2D u_image;uniform vec2 u_texel_size;uniform bool u_first_pass;in vec2 v_pos;void main() {vec2 o=u_texel_size*0.5;vec4 s0=texture(u_image,v_pos+vec2(-o.x,-o.y));vec4 s1=texture(u_image,v_pos+vec2( o.x,-o.y));vec4 s2=texture(u_image,v_pos+vec2(-o.x, o.y));vec4 s3=texture(u_image,v_pos+vec2( o.x, o.y));float r0; float g0;float r1; float g1;float r2; float g2;float r3; float g3;if (u_first_pass) {float a0=s0.a;float a1=s1.a;float a2=s2.a;float a3=s3.a;r0=a0; g0=a0 > 0.0 ? 1.0 : 0.0;r1=a1; g1=a1 > 0.0 ? 1.0 : 0.0;r2=a2; g2=a2 > 0.0 ? 1.0 : 0.0;r3=a3; g3=a3 > 0.0 ? 1.0 : 0.0;} else {r0=s0.r; g0=s0.g;r1=s1.r; g1=s1.g;r2=s2.r; g2=s2.g;r3=s3.r; g3=s3.g;}glFragColor=vec4((r0+r1+r2+r3)*0.25,(g0+g1+g2+g3)*0.25,0.0,0.0);}","in ivec2 a_pos;out vec2 v_pos;void main() {gl_Position=vec4(a_pos,0,1);v_pos=vec2(a_pos)*0.5+0.5;}"),fillExtrusion:zt(`#include "_prelude_fog.fragment.glsl" 950#include "_prelude_shadow.fragment.glsl" 951#include "_prelude_lighting.glsl" 952in vec4 v_color;in vec4 v_flat; 953#ifdef RENDER_SHADOWS 954in highp vec4 v_pos_light_view_0;in highp vec4 v_pos_light_view_1; 955#endif 956uniform lowp float u_opacity; 957#ifdef RENDER_FRONT_CUTOFF 958in float v_front_cutoff_opacity; 959#endif 960#ifdef INDICATOR_CUTOUT 961#ifdef FEATURE_CUTOUT 962in vec4 v_ground_roof; 963#endif 964#endif 965#ifdef FAUX_AO 966uniform lowp vec2 u_ao;in vec2 v_ao; 967#endif 968#if defined(ZERO_ROOF_RADIUS) && !defined(LIGHTING_3D_MODE) 969in vec4 v_roof_color; 970#endif 971#if defined(ZERO_ROOF_RADIUS) || defined(RENDER_SHADOWS) || defined(LIGHTING_3D_MODE) 972in highp vec3 v_normal; 973#endif 974uniform vec3 u_flood_light_color;uniform highp float u_vertical_scale;uniform float u_flood_light_intensity;uniform vec3 u_ground_shadow_factor; 975#if defined(LIGHTING_3D_MODE) && defined(FLOOD_LIGHT) 976in float v_flood_radius;in float v_has_floodlight; 977#endif 978in float v_height; 979#pragma mapbox: define highp float emissive_strength 980void main() { 981#pragma mapbox: initialize highp float emissive_strength 982#if defined(ZERO_ROOF_RADIUS) || defined(RENDER_SHADOWS) || defined(LIGHTING_3D_MODE) 983vec3 normal=normalize(v_normal); 984#endif 985float z;vec4 color=v_color; 986#ifdef ZERO_ROOF_RADIUS 987z=float(normal.z > 0.00001); 988#ifdef LIGHTING_3D_MODE 989normal=mix(normal,vec3(0.0,0.0,1.0),z); 990#else 991color=mix(v_color,v_roof_color,z); 992#endif 993#endif 994float h=max(0.0,v_height);float ao_shade=1.0; 995#ifdef FAUX_AO 996float 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
996),16.0)))+0.08*intensity*min(h_floors/160.0,1.0);float concave=v_ao.x*v_ao.x; 997#ifdef ZERO_ROOF_RADIUS 998concave*=(1.0-z); 999#endif 1000float 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); 1001#ifdef LIGHTING_3D_MODE 1002#ifdef FLOOD_LIGHT 1003color.rgb*=mix(ao_shade,1.0,v_has_floodlight); 1004#else 1005color.rgb*=ao_shade; 1006#endif 1007#else 1008color.rgb*=ao_shade; 1009#endif 1010#endif 1011#ifdef LIGHTING_3D_MODE 1012float flood_radiance=0.0; 1013#ifdef FLOOD_LIGHT 1014flood_radiance=(1.0-min(h/v_flood_radius,1.0))*u_flood_light_intensity*v_has_floodlight; 1015#endif 1016#ifdef RENDER_SHADOWS 1017#ifdef FLOOD_LIGHT 1018float 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); 1019#else 1020float shadowed_lighting_factor; 1021#ifdef RENDER_CUTOFF 1022shadowed_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;} 1023#else 1024shadowed_lighting_factor=shadowed_light_factor_normal(normal,v_pos_light_view_0,v_pos_light_view_1,1.0/gl_FragCoord.w); 1025#endif 1026color.rgb=apply_lighting(color.rgb,normal,shadowed_lighting_factor); 1027#endif 1028#else 1029color.rgb=apply_lighting(color.rgb,normal); 1030#ifdef FLOOD_LIGHT 1031color.rgb=mix(color.rgb,u_flood_light_color*u_opacity,flood_radiance); 1032#endif 1033#endif 1034color.rgb=mix(color.rgb,v_flat.rgb,emissive_strength);color*=u_opacity; 1035#endif 1036#ifdef FOG 1037color=fog_dither(fog_apply_premultiplied(color,v_fog_pos,h)); 1038#endif 1039#ifdef INDICATOR_CUTOUT 1040#ifdef FEATURE_CUTOUT 1041{float ditherOpacity=cutoutGroundRoofOpacity(v_ground_roof);if (ditherOpacity < 1.0) {int index=(int(gl_FragCoord.x) % 4)*4+(int(gl_FragCoord.y) % 4);if (ditherOpacity < DITHER_THRESHOLDS[index]) {discard;}}} 1042#else 1043color=applyCutout(color,h); 1044#endif 1045#endif 1046#ifdef RENDER_FRONT_CUTOFF 1047if (v_front_cutoff_opacity < 1.0) {int index=(int(gl_FragCoord.x) % 4)*4+(int(gl_FragCoord.y) % 4);if (v_front_cutoff_opacity < DITHER_THRESHOLDS[index]) {discard;}} 1048#endif 1049#ifdef FEATURE_CUTOUT 1050color=apply_feature_cutout(color,gl_FragCoord,get_cutout_factors(gl_FragCoord).x); 1051#endif 1052glFragColor=color; 1053#ifdef OVERDRAW_INSPECTOR 1054glFragColor=vec4(1.0); 1055#endif 1056HANDLE_WIREFRAME_DEBUG;}`,`#include "_prelude_fog.vertex.glsl" 1057#include "_prelude_terrain.vertex.glsl" 1058#include "_prelude_shadow.vertex.glsl" 1059#include "_prelude_lighting.glsl" 1060#include "_prelude_material_table.vertex.glsl" 1061uniform mat4 u_matrix;uniform vec3 u_lightcolor;uniform lowp vec3 u_lightpos;uniform lowp float u_lightintensity;uniform float u_vertical_gradient;uniform lowp float u_opacity;uniform float u_edge_radius;uniform float u_width_scale;in ivec4 a_pos_normal_ed; 1062#if defined(HAS_CENTROID) || defined(TERRAIN) 1063in uvec2 a_centroid_pos; 1064#endif 1065#ifdef RENDER_WALL_MODE 1066in ivec4 a_join_normal_inside; 1067#endif 1068#ifdef PROJECTION_GLOBE_VIEW 1069in ivec4 a_pos_3;in ivec4 a_pos_normal_3;uniform mat4 u_inv_rot_matrix;uniform vec2 u_merc_center;uniform vec3 u_tile_id;uniform float u_zoom_transition;uniform vec3 u_up_dir;uniform float u_height_lift; 1070#endif 1071#ifdef TERRAIN 1072uniform int u_height_type;uniform int u_base_type; 1073#endif 1074uniform highp float u_vertical_scale; 1075#ifdef RENDER_FRONT_CUTOFF 1076uniform vec3 u_front_cutoff_params;out float v_front_cutoff_opacity; 1077#endif 1078out vec4 v_color;out vec4 v_flat; 1079#ifdef RENDER_SHADOWS 1080uniform 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; 1081#endif 1082#if defined(ZERO_ROOF_RADIUS) && !defined(LIGHTING_3D_MODE) 1083out vec4 v_roof_color; 1084#endif 1085#if defined(ZERO_ROOF_RADIUS) || defined(RENDER_SHADOWS) || defined(LIGHTING_3D_MODE) 1086out highp vec3 v_normal; 1087#endif 1088#ifdef FAUX_AO 1089uniform lowp vec2 u_ao;out vec2 v_ao; 1090#endif 1091#if defined(LIGHTING_3D_MODE) && defined(FLOOD_LIGHT)
1092out float v_flood_radius;out float v_has_floodlight; 1093#endif 1094out float v_height; 1095#ifdef INDICATOR_CUTOUT 1096#ifdef FEATURE_CUTOUT 1097out vec4 v_ground_roof; 1098#endif 1099#endif 1100vec3 linearTosRGB(vec3 color) {return pow(color,vec3(1./2.2));}vec3 sRGBToLinear(vec3 srgbIn) {return pow(srgbIn,vec3(2.2));} 1101#pragma mapbox: define highp float base 1102#pragma mapbox: define highp float height 1103#pragma mapbox: define highp vec4 color 1104#pragma mapbox: define highp float flood_light_wall_radius 1105#pragma mapbox: define highp float line_width 1106#pragma mapbox: define highp float emissive_strength 1107void main() {DECLARE_MATERIAL_TABLE_INFO 1108#pragma mapbox: initialize highp float base 1109#pragma mapbox: initialize highp float height 1110#pragma mapbox: initialize highp vec4 color 1111#pragma mapbox: initialize highp float flood_light_wall_radius 1112#pragma mapbox: initialize highp float line_width 1113#pragma mapbox: initialize highp float emissive_strength 1114base*=u_vertical_scale;height*=u_vertical_scale;vec4 top_up_ny_start=vec4(a_pos_normal_ed & 1);vec4 pos_nx=vec4(a_pos_normal_ed >> 1);float x_normal=pos_nx.z/8192.0;vec3 normal=top_up_ny_start.y==1.0 ? vec3(0.0,0.0,1.0) : normalize(vec3(x_normal,(2.0*top_up_ny_start.z-1.0)*(1.0-abs(x_normal)),0.0)); 1115#if defined(ZERO_ROOF_RADIUS) || defined(RENDER_SHADOWS) || defined(LIGHTING_3D_MODE) 1116v_normal=normal; 1117#endif 1118base=max(0.0,base);float attr_height=height;height=max(0.0,top_up_ny_start.y==0.0 && top_up_ny_start.x==1.0 ? height-u_edge_radius : height);float t=top_up_ny_start.x;vec2 centroid_pos=vec2(0.0); 1119#if defined(HAS_CENTROID) || defined(TERRAIN) 1120centroid_pos=vec2(a_centroid_pos); 1121#endif 1122float ele=0.0;float h=0.0;float c_ele=0.0;vec3 pos; 1123#ifdef TERRAIN 1124bool is_flat_height=centroid_pos.x !=0.0 && u_height_type==1;bool is_flat_base=centroid_pos.x !=0.0 && u_base_type==1;ele=elevation(pos_nx.xy);bool is_elevation_encoded=centroid_pos.y==0.0 || (centroid_pos.y > 0.0 && (int(centroid_pos.y) & 7)==7);c_ele=is_flat_height || is_flat_base ? (is_elevation_encoded ? elevationFromUint16(centroid_pos.x) : flatElevation(centroid_pos)) : ele;float h_height=is_flat_height ? max(c_ele+height,ele+base+2.0) : ele+height;float h_base=is_flat_base ? max(c_ele+base,ele+base) : ele+(base==0.0 ?-5.0 : base);h=t > 0.0 ? max(h_base,h_height) : h_base; 1125#else 1126h=t > 0.0 ? height : base; 1127#endif 1128pos=vec3(pos_nx.xy,h); 1129#ifdef PROJECTION_GLOBE_VIEW 1130float lift=float((t+base) > 0.0)*u_height_lift;h+=lift;vec3 globe_normal=normalize(mix(vec3(a_pos_normal_3)/16384.0,u_up_dir,u_zoom_transition));vec3 globe_pos=vec3(a_pos_3)+globe_normal*(u_tile_up_scale*h);vec3 merc_pos=mercator_tile_position(u_inv_rot_matrix,pos.xy,u_tile_id,u_merc_center)+u_up_dir*u_tile_up_scale*pos.z;pos=mix_globe_mercator(globe_pos,merc_pos,u_zoom_transition); 1131#endif 1132float cutoff=1.0;vec3 scaled_pos=pos; 1133#if defined(RENDER_CUTOFF) || defined(RENDER_FRONT_CUTOFF) 1134vec2 centroid_decoded=pos.xy;bool isBorderCentroid=false;if (centroid_pos.x > 0.0 && centroid_pos.y > 0.0) {int iy=int(centroid_pos.y);int spanYbits=iy & 7;if (spanYbits==7) {isBorderCentroid=true;int borderID=(iy >> 3) & 3;float coordAlongBorder=float(iy >> 5)*4.0;if (borderID==0) centroid_decoded=vec2(0.0,coordAlongBorder);else if (borderID==1) centroid_decoded=vec2(EXTENT,coordAlongBorder);else if (borderID==2) centroid_decoded=vec2(coordAlongBorder,0.0);else centroid_decoded=vec2(coordAlongBorder,EXTENT);} else {centroid_decoded=floor(centroid_pos/8.0);}} 1135#endif 1136#if defined(RENDER_CUTOFF) || defined(RENDER_FRONT_CUTOFF) 1137vec4 ground=u_matrix*vec4(centroid_decoded,ele,1.0); 1138#endif 1139#ifdef RENDER_CUTOFF 1140#ifdef CLIP_ZERO_TO_ONE 1141cutoff=cutoff_opacity(u_cutoff_params,ground.z*2.0-ground.w); 1142#else 1143cutoff=cutoff_opacity(u_cutoff_params,ground.z); 1144#endif 1145if (centroid_pos.y !=0.0 && centroid_pos.x !=0.0) {vec3 centroid_random=vec3(centroid_pos.xy,centroid_pos.x+centroid_pos.y+1.0);vec3 ground_pos=centroid_random/8.0;vec3 g=floor(ground_pos);vec3 mod_=centroid_random-g*8.0;float seed=min(1.0,0.1*(min(3.5,max(mod_.x+mod_.y,0.2*attr_height))*0.35+mod_.z));if (cutoff < 0.8-seed) {cutoff=0.0;}}float cutoff_scale=cutoff;v_cutoff_opacity=cutoff;scaled_pos.z=mix(c_ele,h,cutoff_scale); 1146#endif 1147float hidden=float((centroid_pos.x==0.0 && centroid_pos.y==1.0) || (cutoff==0.0 && centroid_pos.x !=0.0) || (color.a==0.0)); 1148#ifdef RENDER_FRONT_CUTOFF 1149v_front_cutoff_opacity=1.0;if (centroid_pos.x > 0.0 && centroid_pos.y > 0.0) {hidden=max(hidden,float(ground.w <=0.0));
1149float ndc_y=ground.y/max(ground.w,0.001);float threshold=u_front_cutoff_params.x*2.0-1.0;float range_ndc=u_front_cutoff_params.y*2.0;if (!isBorderCentroid) {hidden=max(hidden,float(ndc_y < threshold-range_ndc));}float t=clamp((ndc_y-(threshold-range_ndc))/max(range_ndc,0.001),0.0,1.0);v_front_cutoff_opacity=mix(u_front_cutoff_params.z,1.0,t);} 1150#endif 1151#ifdef RENDER_WALL_MODE 1152vec3 join_normal_inside=vec3(a_join_normal_inside);vec2 wall_offset=u_width_scale*line_width*(join_normal_inside.xy/EXTENT);scaled_pos.xy+=(1.0-join_normal_inside.z)*wall_offset*0.5;scaled_pos.xy-=join_normal_inside.z*wall_offset*0.5; 1153#endif 1154gl_Position=mix(u_matrix*vec4(scaled_pos,1),AWAY,hidden);h=h-ele;v_height=h; 1155#ifdef RENDER_SHADOWS 1156vec3 shd_pos0=pos;vec3 shd_pos1=pos; 1157#ifdef NORMAL_OFFSET 1158vec3 offset=shadow_normal_offset(normal);shd_pos0+=offset*shadow_normal_offset_multiplier0();shd_pos1+=offset*shadow_normal_offset_multiplier1(); 1159#endif 1160v_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); 1161#endif 1162float NdotL=0.0;float colorvalue=0.0; 1163#ifndef LIGHTING_3D_MODE 1164colorvalue=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*=( 1165(1.0-u_vertical_gradient)+(u_vertical_gradient*clamp((t+base)*pow(height/150.0,0.5),r,1.0)));} 1166#endif 1167#ifdef FAUX_AO 1168float 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; 1169#ifdef TERRAIN 1170top_height=mix(max(c_ele+height,ele+base+2.0),ele+height,float(ce
1170ntroid_pos.x==0.0))-ele;y_ground+=y_ground*5.0/max(3.0,top_height); 1171#endif 1172v_ao=vec2(mix(concave,-concave,start),y_ground);NdotL*=(1.0+0.05*(1.0-top_up_ny_start.y)*u_ao[0]); 1173#ifdef PROJECTION_GLOBE_VIEW 1174top_height+=u_height_lift; 1175#endif 1176gl_Position.z-=(0.0000006*(min(top_height,500.)+2.0*min(base,500.0)+60.0*concave+3.0*start))*gl_Position.w; 1177#endif 1178#ifdef LIGHTING_3D_MODE 1179#ifdef FLOOD_LIGHT 1180float is_wall=1.0-float(t > 0.0 && top_up_ny_start.y > 0.0);v_has_floodlight=float(flood_light_wall_radius > 0.0 && is_wall > 0.0);v_flood_radius=flood_light_wall_radius*u_vertical_scale; 1181#endif 1182v_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); 1183#else 1184v_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; 1185#endif 1186#if defined(ZERO_ROOF_RADIUS) && !defined(LIGHTING_3D_MODE) 1187float 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; 1188#endif 1189#ifdef FOG 1190v_fog_pos=fog_position(pos); 1191#endif 1192#ifdef INDICATOR_CUTOUT 1193#ifdef FEATURE_CUTOUT 1194vec4 pos_ground=u_matrix*vec4(pos.xy,ele,1.0);vec4 pos_roof=u_matrix*vec4(pos.xy,ele+height,1.0);v_ground_roof=vec4(pos_ground.xy/pos_ground.w,pos_roof.xy/pos_roof.w); 1195#endif 1196#endif 1197}`),fillExtrusionDepth:zt("void main() {}",`#include "_prelude_terrain.vertex.glsl" 1198#include "_prelude_material_table.vertex.glsl" 1199uniform mat4 u_matrix;uniform float u_edge_radius;uniform float u_width_scale;uniform float u_vertical_scale; 1200#ifdef TERRAIN 1201uniform int u_height_type;uniform int u_base_type; 1202#endif 1203in ivec4 a_pos_normal_ed; 1204#if defined(HAS_CENTROID) || defined(TERRAIN) 1205in uvec2 a_centroid_pos; 1206#endif 1207#ifdef RENDER_WALL_MODE 1208in ivec4 a_join_normal_inside; 1209#endif 1210#pragma mapbox: define highp float base 1211#pragma mapbox: define highp float height 1212#pragma mapbox: define highp float line_width 1213#pragma mapbox: define highp vec4 color 1214void main() {DECLARE_MATERIAL_TABLE_INFO 1215#pragma mapbox: initialize highp float base 1216#pragma mapbox: initialize highp float height 1217#pragma mapbox: initialize highp float line_width 1218#pragma mapbox: initialize highp vec4 color 1219base*=u_vertical_scale;height*=u_vertical_scale;vec3 top_up_ny=vec3(a_pos_normal_ed.xyz & 1);vec3 pos_nx=vec3(a_pos_normal_ed.xyz >> 1);base=max(0.0,base);height=max(0.0,top_up_ny.y==0.0 && top_up_ny.x==1.0 ? height-u_edge_radius : height);float t=top_up_ny.x;vec2 centroid_pos=vec2(0.0); 1220#if defined(HAS_CENTROID) || defined(TERRAIN) 1221centroid_pos=vec2(a_centroid_pos); 1222#endif 1223vec3 pos; 1224#ifdef TERRAIN 1225bool is_flat_height=centroid_pos.x !=0.0 && u_height_type==1;bool is_flat_base=centroid_pos.x !=0.0 && u_base_type==1;float ele=elevation(pos_nx.xy);bool is_elevation_encoded=centroid_pos.y==0.0 || (centroid_pos.y > 0.0 && int(centroid_pos.y)-(int(centroid_pos.y)/8)*8==7);float c_ele=is_flat_height || is_flat_base ? (is_elevation_encoded ? elevationFromUint16(centroid_pos.x) : flatElevation(centroid_pos)) : ele;float h_height=is_flat_height ? max(c_ele+height,ele+base+2.0) : ele+height;float h_base=is_flat_base ? max(c_ele+base,ele+base) : ele+(base==0.0 ?-5.0 : base);float h=t > 0.0 ? max(h_base,h_height) : h_base;pos=vec3(pos_nx.xy,h); 1226#else 1227pos=vec3(pos_nx.xy,t > 0.0 ? height : base); 1228#endif 1229#ifdef RENDER_WALL_MODE 1230vec3 join_normal_inside=vec3(a_join_normal_inside);vec2 wall_offset=u_width_scale*line_width*(join_normal_inside.xy/EXTENT);pos.xy+=(1.0-join_normal_inside.z)*wall_offset*0.5;pos.xy-=join_normal_inside.z*wall_offset*0.5; 1231#endif 1232float hidden=float((centroid_pos.x==0.0 && centroid_pos.y==1.0) || (color.a==0.0));gl_Position=mix(u_matrix*vec4(pos,1),AWAY,hidden);}`),fillExtrusionPattern:zt(`#include "_prelude_fog.fragment.glsl" 1233#include "_prelude_lighting.glsl" 1234uniform vec2 u_texsize;uniform sampler2D u_image; 1235#ifdef FILL_EXTRUSION_PATTERN_TRANSITION 1236uniform float u_pattern_transition; 1237#endif 1238#ifdef FAUX_AO 1239uniform lowp vec2 u_ao;in vec3 v_ao; 1240#endif 1241#ifdef LIGHTING_3D_MODE 1242in vec3 v_normal; 1243#endif 1244#ifdef APPLY_LUT_ON_GPU 1245uniform highp sampler3D u_lutTexture; 1246#endif 1247in highp vec2 v_pos;in vec4 v_lighting;uniform lowp float u_opacity; 1248#pragma mapbox: define highp float base 1249#pragma mapbox: define highp float height 1250#pragma mapbox: define mediump uvec4 pattern 1251#ifdef FILL_EXTRUSION_PATTERN_TRANSITION 1252#pragma mapbox: define mediump uvec4 pattern_b 1253#endif 1254#pragma mapbox: define highp float pixel_ratio 1255void main() { 1256#pragma mapbox: initialize highp float base 1257#pragma mapbox: initialize highp float height 1258#pragma mapbox: initialize mediump uvec4 pattern 1259#ifdef FILL_EXTRUSION_PATTERN_TRANSITION 1260#pragma mapbox: initialize mediump uvec4 pattern_b 1261#endif 1262#pragma mapbox: initialize highp float pixel_ratio 1263vec2 pattern_tl=vec2(pattern.xy);vec2 pattern_br=vec2(pattern.zw);highp vec2 imagecoord=mod(v_pos,1.0);highp vec2 pos=mix(pattern_tl/u_texsize,pattern_br/u_texsize,imagecoord);highp vec2 lod_pos=mix(pattern_tl/u_texsize,pattern_br/u_texsize,v_pos);vec4 out_color=textureLodCustom(u_image,pos,lod_pos); 1264#ifdef APPLY_LUT_ON_GPU 1265out_color=applyLUT(u_lutTexture,out_color); 1266#endif 1267#ifdef FILL_EXTRUSION_PATTERN_TRANSITION 1268vec2 pattern_b_tl=vec2(pattern_b.xy);vec2 pattern_b_br=vec2(pattern_b.zw);highp vec2 pos_b=mix(pattern_b_tl/u_texsize,pattern_b_br/u_texsize,imagecoord);vec4 color_b=textureLodCustom(u_image,pos_b,lod_pos);out_color=out_color*(1.0-u_pattern_transition)+color_b*u_pattern_transition; 1269#endif 1270#ifdef LIGHTING_3D_MODE 1271out_color=apply_lighting(out_color,normalize(v_normal))*u_opacity; 1272#else 1273out_color=out_color*v_lighting; 1274#endif 1275#ifdef FAUX_AO 1276float 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
1276),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; 1277#endif 1278#ifdef FOG 1279out_color=fog_dither(fog_apply_premultiplied(out_color,v_fog_pos)); 1280#endif 1281#ifdef INDICATOR_CUTOUT 1282out_color=applyCutout(out_color,height); 1283#endif 1284glFragColor=out_color; 1285#ifdef OVERDRAW_INSPECTOR 1286glFragColor=vec4(1.0); 1287#endif 1288HANDLE_WIREFRAME_DEBUG;}`,`#include "_prelude_fog.vertex.glsl" 1289#include "_prelude_terrain.vertex.glsl" 1290#include "_prelude_lighting.glsl" 1291#include "_prelude_material_table.vertex.glsl" 1292uniform mat4 u_matrix;uniform vec2 u_pixel_coord_upper;uniform vec2 u_pixel_coord_lower;uniform float u_height_factor;uniform float u_tile_units_to_pixels;uniform float u_vertical_gradient;uniform lowp float u_opacity;uniform float u_width_scale;uniform vec3 u_lightcolor;uniform lowp vec3 u_lightpos;uniform lowp float u_lightintensity;in ivec4 a_pos_normal_ed; 1293#if defined(HAS_CENTROID) || defined(TERRAIN) 1294in uvec2 a_centroid_pos; 1295#endif 1296#ifdef RENDER_WALL_MODE 1297in ivec4 a_join_normal_inside; 1298#endif 1299#ifdef PROJECTION_GLOBE_VIEW 1300in ivec4 a_pos_3;in ivec4 a_pos_normal_3;uniform mat4 u_inv_rot_matrix;uniform vec2 u_merc_center;uniform vec3 u_tile_id;uniform float u_zoom_transition;uniform vec3 u_up_dir;uniform float u_height_lift; 1301#endif 1302#ifdef TERRAIN 1303uniform int u_height_type;uniform int u_base_type; 1304#endif 1305out highp vec2 v_pos;out vec4 v_lighting; 1306#ifdef FAUX_AO 1307uniform lowp vec2 u_ao;out vec3 v_ao; 1308#endif 1309#ifdef LIGHTING_3D_MODE 1310out vec3 v_normal; 1311#endif 1312#pragma mapbox: define highp float base 1313#pragma mapbox: define highp float height 1314#pragma mapbox: define highp vec4 color 1315#pragma mapbox: define mediump uvec4 pattern 1316#ifdef FILL_EXTRUSION_PATTERN_TRANSITION 1317#pragma mapbox: define mediump uvec4 pattern_b 1318#endif 1319#pragma mapbox: define highp float pixel_ratio 1320#pragma mapbox: define highp float line_width 1321void main() {DECLARE_MATERIAL_TABLE_INFO 1322#pragma mapbox: initialize highp float base 1323#pragma mapbox: initialize highp float height 1324#pragma mapbox: initialize highp vec4 color 1325#pragma mapbox: initialize mediump uvec4 pattern 1326#ifdef FILL_EXTRUSION_PATTERN_TRANSITION 1327#pragma mapbox: initialize mediump uvec4 pattern_b 1328#endif 1329#pragma mapbox: initialize highp float pixel_ratio 1330#pragma mapbox: initialize highp float line_width 1331vec2 pattern_tl=vec2(pattern.xy);vec2 pattern_br=vec2(pattern.zw);vec4 top_up_ny_start=vec4(a_pos_normal_ed & 1);vec4 pos_nx=vec4(a_pos_normal_ed >> 1);float x_normal=pos_nx.z/8192.0;vec3 normal=top_up_ny_start.y==1.0 ? vec3(0.0,0.0,1.0) : normalize(vec3(x_normal,(2.0*top_up_ny_start.z-1.0)*(1.0-abs(x_normal)),0.0));float edgedistance=float(a_pos_normal_ed.w);vec2 display_size=(pattern_br-pattern_tl)/pixel_ratio;base=max(0.0,base);height=max(0.0,height);float t=top_up_ny_start.x;float z=t > 0.0 ? height : base;vec2 centroid_pos=vec2(0.0); 1332#if defined(HAS_CENTROID) || defined(TERRAIN) 1333centroid_pos=vec2(a_centroid_pos); 1334#endif 1335float ele=0.0;float h=z;vec3 p;float c_ele; 1336#ifdef TERRAIN 1337bool is_flat_height=centroid_pos.x !=0.0 && u_height_type==1;bool is_flat_base=centroid_pos.x !=0.0 && u_base_type==1;ele=elevation(pos_nx.xy);bool is_elevation_encoded=centroid_pos.y==0.0 || (centroid_pos.y > 0.0 && int(centroid_pos.y)-(int(centroid_pos.y)/8)*8==7);c_ele=is_flat_height || is_flat_base ? (is_elevation_encoded ? elevationFromUint16(centroid_pos.x) : flatElevation(centroid_pos)) : ele;float h_height=is_flat_height ? max(c_ele+height,ele+base+2.0) : ele+height;float h_base=is_flat_base ? max(c_ele+base,ele+base) : ele+(base==0.0 ?-5.0 : base);h=t > 0.0 ? max(h_base,h_height) : h_base;p=vec3(pos_nx.xy,h); 1338#else 1339p=vec3(pos_nx.xy,z); 1340#endif 1341#ifdef PROJECTION_GLOBE_VIEW 1342float lift=float((t+base) > 0.0)*u_height_lift;h+=lift;vec3 globe_normal=normalize(mix(vec3(a_pos_normal_3)/16384.0,u_up_dir,u_zoom_transition));vec3 globe_pos=vec3(a_pos_3)+globe_normal*(u_tile_up_scale*(p.z+lift));vec3 merc_pos=mercator_tile_position(u_inv_rot_matrix,p.xy,u_tile_id,u_merc_center)+u_up_dir*u_tile_up_scale*p.z;p=mix_globe_mercator(globe_pos,merc_pos,u_zoom_transition); 1343#endif 1344#ifdef RENDER_WALL_MODE 1345vec3 join_normal_inside=vec3(a_join_normal_inside);vec2 wall_offset=u_width_scale*line_width*(join_normal_inside.xy/EXTENT);p.xy+=(1.0-join_normal_inside.z)*wall_offset*0.5;p.xy-=join_normal_inside.z*wall_offset*0.5; 1346#endif 1347float 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 1348? pos_nx.xy 1349: 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; 1350#ifdef LIGHTING_3D_MODE 1351NdotL=calculate_NdotL(normal); 1352#else 1353NdotL=clamp(dot(normal,u_lightpos),0.0,1.0);NdotL=mix((1.0-u_lightintensity),max((0.5+u_lightintensity),1.0),NdotL); 1354#endif 1355if (normal.y !=0.0) {float r=0.84; 1356#ifndef LIGHTING_3D_MODE 1357r=mix(0.7,0.98,1.0-u_lightintensity); 1358#endif 1359NdotL*=( 1360(1.0-u_vertical_gradient)+(u_vertical_gradient*clamp((t+base)*pow(height/150.0,0.5),r,1.0)));} 1361#ifdef FAUX_AO
1362float 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; 1363#ifdef TERRAIN 1364top_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); 1365#endif 1366v_ao=vec3(mix(concave,-concave,start),y_ground,h-ele);NdotL*=(1.0+0.05*(1.0-top_up_ny_start.y)*u_ao[0]); 1367#ifdef PROJECTION_GLOBE_VIEW 1368top_height+=u_height_lift; 1369#endif 1370gl_Position.z-=(0.0000006*(min(top_height,500.)+2.0*min(base,500.0)+60.0*concave+3.0*start))*gl_Position.w; 1371#endif 1372#ifdef LIGHTING_3D_MODE 1373v_normal=normal; 1374#else 1375v_lighting.rgb+=clamp(NdotL*u_lightcolor,mix(vec3(0.0),vec3(0.3),1.0-u_lightcolor),vec3(1.0));v_lighting*=u_opacity; 1376#endif 1377#ifdef FOG 1378v_fog_pos=fog_position(p); 1379#endif 1380}`),groundShadow:zt(`#include "_prelude_shadow.fragment.glsl" 1381precision highp float;uniform vec3 u_ground_shadow_factor;in vec4 v_pos_light_view_0;in vec4 v_pos_light_view_1; 1382#ifdef FOG 1383in float v_fog_opacity; 1384#endif 1385void 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); 1386#ifdef RENDER_CUTOFF 1387shadow=mix(vec3(1.0),shadow,cutoff_opacity(u_cutoff_params,1.0/gl_FragCoord.w)); 1388#endif 1389#ifdef FOG 1390shadow=mix(shadow,vec3(1.0),v_fog_opacity); 1391#endif 1392#ifdef INDICATOR_CUTOUT 1393shadow=mix(shadow,vec3(1.0),1.0-applyCutout(vec4(1.0),0.0).r); 1394#endif 1395#ifdef FEATURE_CUTOUT 1396shadow=mix(shadow,vec3(1.0),get_cutout_factors(gl_FragCoord).y); 1397#endif 1398glFragColor=vec4(shadow,1.0);}`,`#include "_prelude_fog.vertex.glsl" 1399uniform mat4 u_matrix;uniform mat4 u_light_matrix_0;uniform mat4 u_light_matrix_1;in ivec2 a_pos;out vec4 v_pos_light_view_0;out vec4 v_pos_light_view_1; 1400#ifdef FOG 1401out float v_fog_opacity; 1402#endif 1403void 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); 1404#ifdef FOG 1405v_fog_pos=fog_position(vec2(a_pos));v_fog_opacity=fog(v_fog_pos); 1406#endif 1407}`),fillExtrusionGroundEffect:zt(`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; 1408#ifdef SDF_SUBPASS 1409in 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);} 1410#ifdef FOG 1411in highp float v_fog; 1412#endif 1413#endif 1414void main() { 1415#ifdef CLEAR_SUBPASS 1416vec4 color=vec4(1.0); 1417#ifdef CLEAR_FROM_TEXTURE 1418color=texture(u_fb,gl_FragCoord.xy/vec2(u_fb_size)); 1419#endif 1420glFragColor=color; 1421#else 1422#ifdef SDF_SUBPASS 1423highp 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; 1424#ifdef FOG 1425fog=v_fog; 1426#endif 1427#ifdef RENDER_CUTOFF 1428fog*=v_cutoff_opacity; 1429#endif 1430glFragColor=vec4(vec3(0.0),mix(1.0,d,effect_intensity*u_opacity*fog)); 1431#else 1432#ifdef USE_MRT1 1433out_Target1=vec4(1.0-texture(u_fb,gl_FragCoord.xy/vec2(u_fb_size)).a,0.0,0.0,0.0); 1434#else 1435vec4 color=mix(vec4(u_flood_light_color,1.0),vec4(vec3(0.0),1.0),u_ao_pass); 1436#ifdef OVERDRAW_INSPECTOR 1437color=vec4(1.0); 1438#endif 1439glFragColor=color; 1440#endif 1441#endif 1442HANDLE_WIREFRAME_DEBUG; 1443#endif 1444}`,`#include "_prelude_fog.vertex.glsl" 1445in highp ivec4 a_pos_end;in highp int a_angular_offset_factor;in highp uint a_hidden_by_landmark; 1446#ifdef SDF_SUBPASS 1447out highp vec2 v_pos;out highp vec4 v_line_segment;out highp float v_flood_light_radius_tile;out highp vec2 v_ao; 1448#ifdef FOG 1449out highp float v_fog; 1450#endif 1451#endif 1452uniform 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;
1453#pragma mapbox: define highp float flood_light_ground_radius 1454const float TANGENT_CUTOFF=4.0;const float NORM=32767.0;void main() { 1455#pragma mapbox: initialize highp float flood_light_ground_radius 1456vec4 pos_end=vec4(a_pos_end);vec2 p=pos_end.xy;vec2 q=floor(pos_end.zw*0.5);vec2 start_bottom=pos_end.zw-q*2.0;float fl_ground_radius=abs(flood_light_ground_radius);float direction=flood_light_ground_radius < 0.0 ?-1.0 : 1.0;float flood_radius_tile=fl_ground_radius*u_meter_to_tile;vec2 v=normalize(q-p);float ao_radius=u_ao.y/3.5;float effect_radius=mix(flood_radius_tile,ao_radius,u_ao_pass)+u_edge_radius;float angular_offset_factor=float(a_angular_offset_factor)/NORM*TANGENT_CUTOFF;float angular_offset=direction*angular_offset_factor*effect_radius;float top=1.0-start_bottom.y;float side=(0.5-start_bottom.x)*2.0;vec2 extrusion_parallel=v*side*mix(u_dynamic_offset,angular_offset,top);vec2 perp=vec2(v.y,-v.x);vec2 extrusion_perp=direction*perp*effect_radius*top;vec3 pos=vec3(mix(q,p,start_bottom.x),0.0);pos.xy+=extrusion_parallel+extrusion_perp; 1457#ifdef SDF_SUBPASS 1458v_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); 1459#ifdef FOG 1460v_fog_pos=fog_position(pos);v_fog=1.0-fog(v_fog_pos); 1461#endif 1462#endif 1463float hidden_by_landmark=0.0; 1464#ifdef HAS_CENTROID 1465hidden_by_landmark=float(a_hidden_by_landmark); 1466#endif 1467float 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)); 1468#ifdef RENDER_CUTOFF 1469v_cutoff_opacity=cutoff_opacity(u_cutoff_params,gl_Position.z); 1470#endif 1471}`),hillshadePrepare:zt(`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( 1472(c+e+e+h)-(a+d+d+f),(f+g+g+h)-(a+b+b+c) 1473)/pow(2.0,exaggeration+(19.2562-u_zoom));glFragColor=clamp(vec4( 1474deriv.x/2.0+0.5,deriv.y/2.0+0.5,1.0,1.0),0.0,1.0);}`,"uniform mat4 u_matrix;uniform vec2 u_dimension;in ivec2 a_pos;in uvec2 a_texture_pos;out vec2 v_pos;void main() {gl_Position=u_matrix*vec4(a_pos,0,1);highp vec2 epsilon=1.0/u_dimension;float scale=(u_dimension.x-2.0)/u_dimension.x;v_pos=(vec2(a_texture_pos)/8192.0)*scale+epsilon;}"),hillshade:zt(`#include "_prelude_fog.fragment.glsl" 1475#include "_prelude_lighting.glsl" 1476uniform 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; 1477#ifdef LIGHTING_3D_MODE 1478glFragColor=apply_lighting_with_emission_ground(glFragColor,u_emissive_strength); 1479#endif 1480#ifdef FOG 1481glFragColor=fog_dither(fog_apply_premultiplied(glFragColor,v_fog_pos)); 1482#endif 1483#ifdef USE_MRT1 1484out_Target1=vec4(u_emissive_strength*glFragColor.a,0.0,0.0,glFragColor.a); 1485#endif 1486#ifdef OVERDRAW_INSPECTOR 1487glFragColor=vec4(1.0); 1488#endif 1489HANDLE_WIREFRAME_DEBUG;}`,`#include "_prelude_fog.vertex.glsl" 1490uniform mat4 u_matrix;in ivec2 a_pos;in uvec2 a_texture_pos;out vec2 v_pos;void main() {gl_Position=u_matrix*vec4(a_pos,0,1);v_pos=vec2(a_texture_pos)/8192.0; 1491#ifdef FOG 1492v_fog_pos=fog_position(vec2(a_pos)); 1493#endif 1494}`),line:zt(`#include "_prelude_fog.fragment.glsl" 1495#include "_prelude_lighting.glsl" 1496#include "_prelude_shadow.fragment.glsl" 1497uniform lowp float u_device_pixel_ratio;uniform highp float u_width_scale;uniform highp float u_floor_width_scale;
1497uniform float u_alpha_discard_threshold;uniform highp vec2 u_trim_offset;uniform highp vec2 u_trim_fade_range;uniform highp vec2 u_trim_gradient_mix_range;uniform lowp vec4 u_trim_color;uniform bool u_emissive_in_shadows;uniform bool u_clip_to_tile_borders;in vec4 v_width2_dilute;in vec2 v_normal;in float v_gamma_scale;in highp vec3 v_uv;in vec2 v_tile_pos; 1498#ifdef ELEVATED_ROADS 1499in highp float v_road_z_offset; 1500#endif 1501#ifdef VARIABLE_LINE_WIDTH 1502in float stub_side; 1503#endif 1504#ifdef RENDER_LINE_DASH 1505uniform sampler2D u_dash_image;in vec2 v_tex; 1506#endif 1507#ifdef DEBUG_ELEVATION_ID 1508in vec3 v_elevation_id_col; 1509#endif 1510#ifdef RENDER_LINE_GRADIENT 1511uniform sampler2D u_gradient_image; 1512#endif 1513#ifdef INDICATOR_CUTOUT 1514in highp float v_z_offset; 1515#endif 1516#ifdef RENDER_SHADOWS 1517uniform 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; 1518#endif 1519float luminance(vec3 c) {return (c.r+c.r+c.b+c.g+c.g+c.g)*0.1667;} 1520#pragma mapbox: define highp vec4 color 1521#pragma mapbox: define lowp float floorwidth 1522#pragma mapbox: define mediump uvec4 dash 1523#pragma mapbox: define lowp float blur 1524#pragma mapbox: define lowp float opacity 1525#pragma mapbox: define mediump float side_z_offset 1526#pragma mapbox: define lowp float border_width 1527#pragma mapbox: define lowp vec4 border_color 1528#pragma mapbox: define lowp float emissive_strength 1529float linearstep(float edge0,float edge1,float x) {return clamp((x-edge0)/(edge1-edge0),0.0,1.0);}void main() { 1530#pragma mapbox: initialize highp vec4 color 1531#pragma mapbox: initialize lowp float floorwidth 1532#pragma mapbox: initialize mediump uvec4 dash 1533#pragma mapbox: initialize lowp float blur 1534#pragma mapbox: initialize lowp float opacity 1535#pragma mapbox: initialize mediump float side_z_offset 1536#pragma mapbox: initialize lowp float border_width 1537#pragma mapbox: initialize lowp vec4 border_color 1538#pragma mapbox: initialize lowp float emissive_strength 1539float dist=length(v_normal)*v_width2_dilute.x; 1540#ifdef VARIABLE_LINE_WIDTH 1541blur=mix(blur,0.0,stub_side); 1542#endif 1543float diluted_opacity=opacity*v_width2_dilute.z;float blur2=(u_width_scale*blur+1.0/u_device_pixel_ratio)*v_gamma_scale;float alpha=clamp(min(dist-(v_width2_dilute.y-blur2),v_width2_dilute.x-dist)/blur2,0.0,1.0); 1544#ifdef VARIABLE_LINE_WIDTH 1545alpha=mix(alpha,1.0,stub_side); 1546#endif 1547alpha=side_z_offset > 0.0 ? 1.0-alpha : alpha; 1548#ifdef RENDER_LINE_DASH 1549float sdfdist=texture(u_dash_image,v_tex).r;
1549float sdfgamma=1.0/(2.0*u_device_pixel_ratio)/(float(dash.z)+float(dash.w)/65535.0);float scaled_floorwidth=(floorwidth*u_floor_width_scale);alpha*=linearstep(0.5-sdfgamma/scaled_floorwidth,0.5+sdfgamma/scaled_floorwidth,sdfdist); 1550#endif 1551highp vec4 out_color; 1552#ifdef RENDER_LINE_GRADIENT 1553out_color=texture(u_gradient_image,v_uv.xy); 1554#else 1555out_color=color; 1556#endif 1557float trim_alpha=1.0; 1558#ifdef RENDER_LINE_TRIM_OFFSET 1559highp float trim_start=u_trim_offset[0];highp float trim_end=u_trim_offset[1];highp float line_progress=v_uv[2];if (trim_end > trim_start) {highp float start_transition=max(0.0,min(1.0,(line_progress-trim_start)/max(u_trim_fade_range[0],1.0e-9)));highp float end_transition=max(0.0,min(1.0,(trim_end-line_progress)/max(u_trim_fade_range[1],1.0e-9)));highp float transition_factor=min(start_transition,end_transition);highp float gradient_trim_color_mix_factor=0.0; 1560#ifdef RENDER_LINE_GRADIENT 1561gradient_trim_color_mix_factor=smoothstep(u_trim_gradient_mix_range.x,u_trim_gradient_mix_range.y,line_progress); 1562#endif 1563highp vec4 trim_color=mix(u_trim_color,out_color,gradient_trim_color_mix_factor);out_color=mix(u_trim_gradient_mix_range.x < 1.0 ? color : out_color,trim_color,transition_factor);trim_alpha=1.0-transition_factor;} 1564#endif 1565if (u_alpha_discard_threshold !=0.0) {if (alpha < u_alpha_discard_threshold) {discard;}} 1566#ifdef RENDER_LINE_BORDER 1567#ifndef VARIABLE_LINE_WIDTH 1568float edgeBlur=((border_width*u_width_scale)+1.0/u_device_pixel_ratio);float alpha2=clamp(min(dist-(v_width2_dilute.y-edgeBlur),v_width2_dilute.x-dist)/edgeBlur,0.0,1.0);if (alpha2 < 1.) {float smoothAlpha=smoothstep(0.6,1.0,alpha2);if (border_color.a==0.0) {float Y=(out_color.a > 0.01) ? luminance(out_color.rgb/out_color.a) : 1.;float adjustment=(Y > 0.) ? 0.5/Y : 0.45;if (out_color.a > 0.25 && Y < 0.25) {vec3 borderColor=(Y > 0.) ? out_color.rgb : vec3(1,1,1)*out_color.a;out_color.rgb=out_color.rgb+borderColor*(adjustment*(1.0-smoothAlpha));} else {out_color.rgb*=(0.6 +0.4*smoothAlpha);}} else {out_color=mix(border_color*trim_alpha,out_color,smoothAlpha);}out_color*=v_width2_dilute.w;} 1569#endif 1570#endif 1571vec2 cutout_factors=vec2(0.0); 1572#ifdef FEATURE_CUTOUT 1573cutout_factors=get_cutout_factors(gl_FragCoord); 1574#endif 1575#ifdef LIGHTING_3D_MODE 1576out_color=apply_lighting_with_emission_ground(out_color,emissive_strength); 1577#ifdef RENDER_SHADOWS 1578float light=shadowed_light_factor(v_pos_light_view_0,v_pos_light_view_1,v_depth);light=mix(light,1.0,cutout_factors.y);light=u_emissive_in_shadows ? mix(light,1.0,emissive_strength) : light; 1579#ifdef ELEVATED_ROADS 1580out_color.rgb*=mix(v_road_z_offset !=0.0 ? u_ground_shadow_factor : vec3(1.0),vec3(1.0),light); 1581#else 1582out_color.rgb*=mix(u_ground_shadow_factor,vec3(1.0),light); 1583#endif 1584#endif 1585#endif 1586#ifdef FOG 1587out_color=fog_dither(fog_apply_premultiplied(out_color,v_fog_pos)); 1588#endif 1589out_color*=(alpha*diluted_opacity); 1590#ifdef INDICATOR_CUTOUT 1591out_color=applyCutout(out_color,v_z_offset); 1592#endif 1593#ifdef FEATURE_CUTOUT 1594out_color=apply_feature_cutout(out_color,gl_FragCoord,cutout_factors.x); 1595#endif 1596#ifdef LINE_BLEND_ADDITIVE 1597{float cov=alpha*diluted_opacity;glFragColor=vec4(cov > 0.0 ? out_color.rgb/cov : vec3(0.0),cov);} 1598#else 1599#ifdef LINE_BLEND_MULTIPLY 1600glFragColor=vec4(out_color.rgb+(1.0-out_color.a),1.0); 1601#else 1602glFragColor=out_color; 1603#endif 1604#endif 1605#ifdef DUAL_SOURCE_BLENDING 1606glFragColorSrc1=vec4(vec3(0.0),emissive_strength); 1607#else 1608#ifdef USE_MRT1 1609out_Target1=vec4(emissive_strength*glFragColor.a,0.0,0.0,glFragColor.a); 1610#endif 1611#endif 1612#ifdef OVERDRAW_INSPECTOR 1613glFragColor=vec4(1.0); 1614#endif 1615#ifdef DEBUG_ELEVATION_ID 1616glFragColor=vec4(v_elevation_id_col,1.0); 1617#endif 1618if (u_clip_to_tile_borders) {if (v_tile_pos.x > 1.0 || v_tile_pos.y > 1.0 || v_tile_pos.x < 0.0 || v_tile_pos.y < 0.0) {discard;}}HANDLE_WIREFRAME_DEBUG;}`,`#include "_prelude_fog.vertex.glsl" 1619#include "_prelude_shadow.vertex.glsl" 1620#include "_prelude_terrain.vertex.glsl" 1621#define EXTRUDE_SCALE 0.015873016 1622in ivec2 a_pos_normal;in uvec4 a_data; 1623#if defined(ELEVATED) || defined(ELEVATED_ROADS) || defined(VARIABLE_LINE_WIDTH) 1624in vec3 a_z_offset_width; 1625#endif 1626#ifdef DEBUG_ELEVATION_ID 1627in vec3 a_elevation_id_col; 1628#endif 1629#ifdef DEBUG_ELEVATION_ID 1630out vec3 v_elevation_id_col; 1631#endif 1632#ifdef ELEVATION_GROUND_SCALE 1633in float a_elevation_ground_scale; 1634#endif 1635#if defined(RENDER_LINE_GRADIENT) || defined(RENDER_LINE_TRIM_OFFSET) || defined(RENDER_LINE_CURVE) 1636in highp vec3 a_packed; 1637#endif 1638#ifdef RENDER_LINE_DASH 1639in float a_linesofar; 1640#endif 1641uniform 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 float u_z_offset;uniform highp float u_floor_width_scale; 1642#ifdef RENDER_LINE_CURVE 1643uniform mat3 u_curve_points_x;uniform mat3 u_curve_points_y;uniform mat3 u_curve_points_z;uniform float u_curve_point_count; 1644#endif 1645#ifdef ELEVATED 1646uniform lowp float u_zbias_factor;uniform lowp float u_tile_to_meter;float sample_elevation(vec2 apos) { 1647#ifdef ELEVATION_REFERENCE_SEA 1648return 0.0; 1649#else 1650return elevation(apos); 1651#endif 1652} 1653#endif 1654out vec2 v_normal;out vec4 v_width2_dilute;out float v_gamma_scale;out highp vec3 v_uv;out vec2 v_tile_pos; 1655#ifdef ELEVATED_ROADS 1656out highp float v_road_z_offset; 1657#endif 1658#ifdef VARIABLE_LINE_WIDTH 1659out float stub_side; 1660#endif 1661#ifdef RENDER_LINE_DASH 1662uniform vec2 u_texsize;uniform float u_tile_units_to_pixels;out vec2 v_tex; 1663#endif 1664#ifdef RENDER_LINE_GRADIENT 1665uniform float u_image_height; 1666#endif 1667#ifdef INDICATOR_CUTOUT 1668out highp float v_z_offset; 1669#endif 1670#ifdef RENDER_SHADOWS 1671uniform 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; 1672#endif 1673#pragma mapbox: define highp vec4 color 1674#pragma mapbox: define lowp float floorwidth 1675#pragma mapbox: define mediump uvec4 dash 1676#pragma mapbox: define lowp float blur 1677#pragma mapbox: define lowp float opacity 1678#pragma mapbox: define mediump float gapwidth 1679#pragma mapbox: define lowp float offset 1680#pragma mapbox: define mediump float width 1681#pragma mapbox: define mediump float side_z_offset 1682#pragma mapbox: define lowp float border_width 1683#pragma mapbox: define lowp vec4 border_color 1684#pragma mapbox: define lowp float emissive_strength 1685#ifdef RENDER_LINE_CURVE 1686vec3 getCurvePoint(int index) {int row=index/3;int col=index-row*3;float x=u_curve_points_x[row][col];float y=u_curve_points_y[row][col];float z=u_curve_points_z[row][col];return vec3(x,y,z);}vec3 catmullRom(vec3 p0,vec3 p1,vec3 p2,vec3 p3,float t) {float t2
1686=t*t;float t3=t2*t;return 0.5*( 16872.0*p1+(-p0+p2)*t+(2.0*p0-5.0*p1+4.0*p2-p3)*t2+(-p0+3.0*p1-3.0*p2+p3)*t3 1688);}vec2 catmullRomTangent(vec2 p0,vec2 p1,vec2 p2,vec2 p3,float t) {float t2=t*t;return 0.5*( 1689(-p0+p2)+(2.0*p0-5.0*p1+4.0*p2-p3)*2.0*t+(-p0+3.0*p1-3.0*p2+p3)*3.0*t2 1690);}struct CurveResult {vec3 point;vec2 tangent;};CurveResult calculateCurve(float line_progress) {float curve_progress=line_progress*(u_curve_point_count-1.0);float curve_progress_local=fract(curve_progress);float curve_segment=floor(curve_progress);int seg=int(curve_segment);vec3 p1=getCurvePoint(seg);vec3 p2=getCurvePoint(seg+1);float is_first_seg=step(curve_segment,0.5);vec3 p0_extrapolated=p1-(p2-p1);vec3 p0_fetched=getCurvePoint(max(seg-1,0));vec3 p0=mix(p0_fetched,p0_extrapolated,is_first_seg);int last_seg=int(u_curve_point_count)-2;float is_last_seg=step(float(last_seg)-0.5,curve_segment);vec3 p3_extrapolated=p2+(p2-p1);vec3 p3_fetched=getCurvePoint(min(seg+2,int(u_curve_point_count)-1));vec3 p3=mix(p3_fetched,p3_extrapolated,is_last_seg);vec3 point=catmullRom(p0,p1,p2,p3,curve_progress_local);vec2 tangent=catmullRomTangent(p0.xy,p1.xy,p2.xy,p3.xy,curve_progress_local)*(u_curve_point_count-1.0);CurveResult result;result.point=point;result.tangent=tangent;return result;} 1691#endif 1692void main() { 1693#pragma mapbox: initialize highp vec4 color 1694#pragma mapbox: initialize lowp float floorwidth 1695#pragma mapbox: initialize mediump uvec4 dash 1696#pragma mapbox: initialize lowp float blur 1697#pragma mapbox: initialize lowp float opacity 1698#pragma mapbox: initialize mediump float gapwidth 1699#pragma mapbox: initialize lowp float offset 1700#pragma mapbox: initialize mediump float width 1701#pragma mapbox: initialize mediump float side_z_offset 1702#pragma mapbox: initialize lowp float border_width 1703#pragma mapbox: initialize lowp vec4 border_color 1704#pragma mapbox: initialize lowp float emissive_strength 1705float a_z_offset=u_z_offset; 1706#if defined(ELEVATED) || defined(ELEVATED_ROADS) 1707a_z_offset+=a_z_offset_width.x; 1708#endif 1709#ifdef DEBUG_ELEVATION_ID 1710v_elevation_id_col=a_elevation_id_col; 1711#endif 1712highp float line_progress=0.0; 1713#if defined(RENDER_LINE_GRADIENT) || defined(RENDER_LINE_TRIM_OFFSET) || defined(RENDER_LINE_CURVE) 1714line_progress=a_packed[2]; 1715#endif 1716float ANTIALIASING=1.0/u_device_pixel_ratio/2.0;vec2 a_extrude=vec2(a_data.xy)-128.0;float a_direction=float(a_data.z & 3u)-1.0;vec2 pos_normal=vec2(a_pos_normal);vec2 pos=floor(pos_normal*0.5);mediump vec2 normal=pos_normal-2.0*pos;normal.y=normal.y*2.0-1.0;v_normal=normal;offset=-1.0*offset*u_width_scale;bool left=normal.y==1.0; 1717#ifdef RENDER_LINE_CURVE 1718CurveResult curve=calculateCurve(line_progress);pos=curve.point.xy*8192.0;a_extrude=length(a_extrude)*normalize(curve.tangent);a_extrude=left ? vec2(-a_extrude.y,a_extrude.x) : vec2(a_extrude.y,-a_extrude.x);a_z_offset+=curve.point.z; 1719#endif 1720gapwidth=gapwidth/2.0;float halfwidth;float dilute_scale=1.0;float dilute_border_scale=1.0; 1721#ifdef VARIABLE_LINE_WIDTH 1722float left_width=a_z_offset_width.y;float right_width=a_z_offset_width.z;halfwidth=(u_width_scale*(left ? left_width : right_width))/2.0;if (side_z_offset !=0.0) {float left_f=step(1.0,normal.y);float is_negative=step(side_z_offset,0.0);float apply=mix(1.0-left_f,left_f,is_negative);a_extrude*=apply;a_z_offset+=abs(side_z_offset)*apply;v_normal*=left_f;}offset=border_width > 0.0 ? (left_width+right_width)*u_width_scale*0.5 : offset;halfwidth=border_width > 0.0 ? border_width*u_width_scale*0.5 : halfwidth;bool zero_right_width=border_width==0.0 && right_width==0.0;stub_side=zero_right_width ?-normal.y : 0.0;v_normal=!left && zero_right_width ? vec2(0.0) : v_normal;ANTIALIASING=!left && zero_right_width ? 0.0 : ANTIALIASING; 1723#else 1724halfwidth=(u_width_scale*width)/2.0; 1725#endif 1726float 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;
1726vec4 projected_extrude=u_matrix*vec4(extrude,0.0,0.0);vec2 projected_extrude_xy=projected_extrude.xy; 1727#ifdef ELEVATED_ROADS 1728v_road_z_offset=a_z_offset;v_tile_pos=pos+offset2*u_pixels_to_tile_units;gl_Position=u_matrix*vec4(v_tile_pos,a_z_offset,1.0); 1729#else 1730#ifdef ELEVATED 1731vec2 offsetTile=offset2*u_pixels_to_tile_units;vec2 offset_pos=pos+offsetTile;float ele=0.0;float scaled_z_offset=a_z_offset; 1732#ifdef ELEVATION_GROUND_SCALE 1733scaled_z_offset=a_z_offset*mix(1.0,u_exaggeration,a_elevation_ground_scale); 1734#endif 1735#ifdef CROSS_SLOPE_VERTICAL 1736float top=pos_normal.y-2.0*floor(pos_normal.y*0.5);float line_height=2.0*u_tile_to_meter*outset*top*u_pixels_to_tile_units[1][1]+scaled_z_offset;ele=sample_elevation(offset_pos)+line_height;projected_extrude=vec4(0); 1737#else 1738#ifdef CROSS_SLOPE_HORIZONTAL 1739float ele0=sample_elevation(offset_pos);float ele1=max(sample_elevation(offset_pos+extrude),sample_elevation(offset_pos+extrude/2.0));float ele2=max(sample_elevation(offset_pos-extrude),sample_elevation(offset_pos-extrude/2.0));float ele_max=max(ele0,max(ele1,ele2));ele=ele_max+scaled_z_offset; 1740#else 1741float ele0=sample_elevation(offset_pos);float ele1=max(sample_elevation(offset_pos+extrude),sample_elevation(offset_pos+extrude/2.0));float ele2=max(sample_elevation(offset_pos-extrude),sample_elevation(offset_pos-extrude/2.0));float ele_max=max(ele0,0.5*(ele1+ele2));ele=ele_max-ele0+ele1+scaled_z_offset; 1742#endif 1743#endif 1744v_tile_pos=offset_pos;gl_Position=u_matrix*vec4(v_tile_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); 1745#else 1746v_tile_pos=pos+offset2*u_pixels_to_tile_units;gl_Position=u_matrix*vec4(v_tile_pos,0.0,1.0); 1747#endif 1748#endif 1749#ifndef ELEVATED 1750#ifndef VARIABLE_LINE_WIDTH 1751#ifndef RENDER_TO_TEXTURE 1752float base_w=gl_Position.w;vec2 screen_width=abs(projected_extrude.xy/base_w*u_units_to_pixels);float max_extrude_component=max(screen_width.x,screen_width.y);if (width >=1.0 && base_w > 0.0 && max_extrude_component > 0.0001) {float min_pixel=1.05;if (max_extrude_component < min_pixel) {vec2 abs_pos=abs(gl_Position.xy);float is_out=max(abs_pos.x,abs_pos.y)/base_w;dilute_scale=mix(max_extrude_component/min_pixel,1.0,smoothstep(2.5,4.5,is_out));projected_extrude/=dilute_scale;}else if (gapwidth > 0.0) {float visible_ratio=(halfwidth+ANTIALIASING)/outset;vec2 visible_screen_width=screen_width*visible_ratio;float max_visible_component=max(visible_screen_width.x,visible_screen_width.y);dilute_scale=min(1.0,max_visible_component/min_pixel);}else 1753{ 1754#ifdef RENDER_LINE_BORDER 1755float border_ratio=(border_width*u_width_scale+ANTIALIASING)/outset;screen_width*=border_ratio;float max_border_component=max(screen_width.x,screen_width.y);dilute_border_scale=min(1.0,max_border_component/min_pixel); 1756#endif 1757}} 1758#endif 1759#endif 1760v_tile_pos=(v_tile_pos+extrude)/EXTENT; 1761#ifdef ELEVATED_ROADS 1762gl_Position=gl_Position+projected_extrude; 1763#else 1764gl_Position=mix(gl_Position+projected_extrude,AWAY,hidden); 1765#endif 1766#endif 1767#ifdef ELEVATED_ROADS 1768#ifdef RENDER_SHADOWS 1769vec3 shd_pos=vec3(pos+(offset2+dist)*u_pixels_to_tile_units,a_z_offset);vec3 shd_pos0=shd_pos;vec3 shd_pos1=shd_pos; 1770#ifdef NORMAL_OFFSET 1771vec3 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(); 1772#endif 1773v_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; 1774#endif 1775#endif 1776#ifndef RENDER_TO_TEXTURE 1777float 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)); 1778#else 1779v_gamma_scale=1.0; 1780#endif 1781#if defined(RENDER_LINE_GRADIENT) || defined(RENDER_LINE_TRIM_OFFSET) 1782highp float a_uv_x=a_packed[0];float a_split_index=a_packed[1]; 1783#ifdef RENDER_LINE_GRADIENT 1784highp 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); 1785#else 1786v_uv=vec3(a_uv_x,0.0,line_progress); 1787#endif 1788#endif 1789#ifdef RENDER_LINE_DASH 1790vec4 dashf=vec4(dash);float totalLength=dashf.z+dashf.w/65535.0;float scale=totalLength==0.0 ? 0.0 : u_tile_units_to_pixels/totalLength;v_tex=vec2(a_linesofar*scale/(floorwidth*u_floor_width_scale),(-normal.y*dashf.y+dashf.x+0.5)/u_texsize.y); 1791#endif 1792v_width2_dilute=vec4(outset,inset,dilute_scale,dilute_border_scale); 1793#ifdef FOG 1794v_fog_pos=fog_position(pos); 1795#endif 1796#ifdef INDICATOR_CUTOUT 1797v_z_offset=a_z_offset; 1798#endif 1799}`),linePattern:zt(`#include "_prelude_fog.fragment.glsl" 1800#include "_prelude_lighting.glsl" 1801#include "_prelude_shadow.fragment.glsl" 1802uniform highp float u_device_pixel_ratio;uniform highp float u_width_scale;
1802uniform 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; 1803#ifdef APPLY_LUT_ON_GPU 1804uniform highp sampler3D u_lutTexture; 1805#endif 1806#ifdef LINE_PATTERN_TRANSITION 1807uniform float u_pattern_transition; 1808#endif 1809in vec2 v_normal;in vec2 v_width2;in highp float v_linesofar;in float v_gamma_scale;in float v_width; 1810#ifdef RENDER_LINE_TRIM_OFFSET 1811in highp vec3 v_uv; 1812#endif 1813#ifdef ELEVATED_ROADS 1814in highp float v_road_z_offset; 1815#endif 1816#ifdef LINE_JOIN_NONE 1817in vec2 v_pattern_data; 1818#endif 1819#ifdef INDICATOR_CUTOUT 1820in highp float v_z_offset; 1821#endif 1822#ifdef RENDER_SHADOWS 1823uniform 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; 1824#endif 1825#pragma mapbox: define mediump uvec4 pattern 1826#ifdef LINE_PATTERN_TRANSITION 1827#pragma mapbox: define mediump uvec4 pattern_b 1828#endif 1829#pragma mapbox: define mediump float pixel_ratio 1830#pragma mapbox: define mediump float blur 1831#pragma mapbox: define mediump float opacity 1832#pragma mapbox: define lowp float emissive_strength 1833void main() { 1834#pragma mapbox: initialize mediump uvec4 pattern 1835#ifdef LINE_PATTERN_TRANSITION 1836#pragma mapbox: initialize mediump uvec4 pattern_b 1837#endif 1838#pragma mapbox: initialize mediump float pixel_ratio 1839#pragma mapbox: initialize mediump float blur 1840#pragma mapbox: initialize mediump float opacity 1841#pragma mapbox: initialize lowp float emissive_strength 1842vec2 pattern_tl=vec2(pattern.xy);vec2 pattern_br=vec2(pattern.zw);vec2 display_size=(pattern_br-pattern_tl)/pixel_ratio;highp float pattern_size=display_size.x/u_tile_units_to_pixels;float aspect=display_size.y/v_width;float dist=length(v_normal)*v_width2.s;float blur2=(u_width_scale*blur+1.0/u_device_pixel_ratio)*v_gamma_scale;float alpha=clamp(min(dist-(v_width2.t-blur2),v_width2.s-dist)/blur2,0.0,1.0);highp float pattern_x=v_linesofar/pattern_size*aspect;highp float x=mod(pattern_x,1.0);highp float y=0.5*v_normal.y+0.5;vec2 texel_size=1.0/u_texsize;highp vec2 pos=mix(pattern_tl*texel_size-texel_size,pattern_br*texel_size+texel_size,vec2(x,y));highp vec2 lod_pos=mix(pattern_tl*texel_size-texel_size,pattern_br*texel_size+texel_size,vec2(pattern_x,y));vec4 color=textureLodCustom(u_image,pos,lod_pos); 1843#ifdef APPLY_LUT_ON_GPU 1844color=applyLUT(u_lutTexture,color); 1845#endif 1846#ifdef LINE_PATTERN_TRANSITION 1847vec2 pattern_b_tl=vec2(pattern_b.xy);vec2 pattern_b_br=vec2(pattern_b.zw);highp vec2 pos_b=mix(pattern_b_tl*texel_size-texel_size,pattern_b_br*texel_size+texel_size,vec2(x,y));vec4 color_b=textureLodCustom(u_image,pos_b,lod_pos);color=color*(1.0-u_pattern_transition)+color_b*u_pattern_transition; 1848#endif 1849#ifdef RENDER_LINE_TRIM_OFFSET 1850highp 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);} 1851#endif 1852#ifdef LINE_JOIN_NONE 1853highp 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);} 1854#endif 1855#ifdef LIGHTING_3D_MODE 1856color=apply_lighting_with_emission_ground(color,emissive_strength); 1857#ifdef RENDER_SHADOWS 1858float light=shadowed_light_factor(v_pos_light_view_0,v_pos_light_view_1,v_depth); 1859#ifdef ELEVATED_ROADS 1860color.rgb*=mix(v_road_z_offset !=0.0 ? u_ground_shadow_factor : vec3(1.0),vec3(1.0),light); 1861#else 1862color.rgb*=mix(u_ground_shadow_factor,vec3(1.0),light); 1863#endif 1864#endif 1865#endif 1866#ifdef FOG 1867color=fog_dither(fog_apply_premultiplied(color,v_fog_pos)); 1868#endif 1869color*=(alpha*opacity);if (u_alpha_discard_threshold !=0.0) {if (color.a < u_alpha_discard_threshold) {discard;}} 1870#ifdef INDICATOR_CUTOUT 1871color=applyCutout(color,v_z_offset); 1872#endif 1873glFragColor=color; 1874#ifdef DUAL_SOURCE_BLENDING 1875glFragColorSrc1=vec4(vec3(0.0),emissive_strength); 1876#else 1877#ifdef USE_MRT1 1878out_Target1=vec4(emissive_strength*glFragColor.a,0.0,0.0,glFragColor.a); 1879#endif 1880#endif 1881#ifdef OVERDRAW_INSPECTOR 1882glFragColor=vec4(1.0); 1883#endif 1884HANDLE_WIREFRAME_DEBUG;}`,`#include "_prelude_fog.vertex.glsl" 1885#include "_prelude_shadow.vertex.glsl" 1886#include "_prelude_terrain.vertex.glsl" 1887#define scale 0.015873016 1888in ivec2 a_pos_normal;in uvec4 a_data; 1889#if defined(ELEVATED) || defined(ELEVATED_ROADS) 1890in vec3 a_z_offset_width; 1891#endif 1892#ifdef ELEVATION_GROUND_SCALE 1893in float a_elevation_ground_scale; 1894#endif 1895#ifdef RENDER_LINE_TRIM_OFFSET 1896in highp vec3 a_packed; 1897#endif 1898in highp float a_linesofar; 1899#ifdef LINE_JOIN_NONE 1900in highp vec3 a_pattern_data;out vec2 v_pattern_data; 1901#endif 1902#ifdef INDICATOR_CUTOUT 1903out highp float v_z_offset; 1904#endif 1905uniform 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; 1906#ifdef ELEVATED 1907uniform lowp float u_zbias_factor;uniform lowp float u_tile_to_meter;float sample_elevation(vec2 apos) { 1908#ifdef ELEVATION_REFERENCE_SEA 1909return 0.0; 1910#else 1911return elevation(apos); 1912#endif 1913} 1914#endif 1915out vec2 v_normal;out vec2 v_width2;out highp float v_linesofar;out float v_gamma_scale;out float v_width; 1916#ifdef RENDER_LINE_TRIM_OFFSET 1917out highp vec3 v_uv; 1918#endif 1919#ifdef ELEVATED_ROADS 1920out highp float v_road_z_offset; 1921#endif 1922#ifdef RENDER_SHADOWS 1923uniform 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; 1924#endif 1925#pragma mapbox: define mediump float blur 1926#pragma mapbox: define mediump float opacity 1927#pragma mapbox: define mediump float offset 1928#pragma mapbox: define mediump float gapwidth 1929#pragma mapbox: define mediump float width 1930#pragma mapbox: define mediump float floorwidth 1931#pragma mapbox: define mediump uvec4 pattern 1932#ifdef LINE_PATTERN_TRANSITION 1933#pragma mapbox: define mediump uvec4 pattern_b 1934#endif 1935#pragma mapbox: define mediump float pixel_ratio 1936#pragma mapbox: define lowp float emissive_strength 1937void main() { 1938#pragma mapbox: initialize mediump float blur 1939#pragma mapbox: initialize mediump float opacity 1940#pragma mapbox: initialize mediump float offset 1941#pragma mapbox: initialize mediump float gapwidth 1942#pragma mapbox: initialize mediump float width 1943#pragma mapbox: initialize mediump float floorwidth 1944#pragma mapbox: initialize mediump uvec4 pattern 1945#ifdef LINE_PATTERN_TRANSITION 1946#pragma mapbox: initialize mediump uvec4 pattern_b 1947#endif 1948#pragma mapbox: initialize mediump float pixel_ratio 1949#pragma mapbox: initialize lowp float emissive_strength 1950float a_z_offset; 1951#if defined(ELEVATED) || defined(ELEVATED_ROADS) 1952a_z_offset=a_z_offset_width.x; 1953#endif 1954float ANTIALIASING=1.0/u_device_pixel_ratio/2.0;vec2 a_extrude=vec2(a_data.xy)-128.0;float a_direction=float(a_data.z & 3u)-1.0;vec2 pos_normal=vec2(a_pos_normal);vec2 pos=floor(pos_normal*0.5);vec2 normal=pos_normal-2.0*pos;normal.y=normal.y*2.0-1.0;v_normal=normal;gapwidth=gapwidth/2.0;float halfwidth=(u_width_scale*width)/2.0;offset=-1.0*offset*u_width_scale;float inset=gapwidth+(gapwidth > 0.0 ? ANTIALIASING : 0.0);float outset=gapwidth+halfwidth*(gapwidth > 0.0 ? 2.0 : 1.0)+(halfwidth==0.0 ? 0.0 : ANTIALIASING);vec2 dist=outset*a_extrude*scale;float u=0.5*a_direction;float t=1.0-abs(u);vec2 offset2=offset*a_extrude*scale*normal.y*mat2(t,-u,u,t);float hidden=float(opacity==0.0);vec2 extrude=dist*u_pixels_to_tile_units;
1954vec4 projected_extrude=u_matrix*vec4(extrude,0.0,0.0);vec2 projected_extrude_xy=projected_extrude.xy; 1955#ifdef ELEVATED_ROADS 1956v_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; 1957#else 1958#ifdef ELEVATED 1959vec2 offsetTile=offset2*u_pixels_to_tile_units;vec2 offset_pos=pos+offsetTile;float ele=0.0;float scaled_z_offset=a_z_offset; 1960#ifdef ELEVATION_GROUND_SCALE 1961scaled_z_offset=a_z_offset*mix(1.0,u_exaggeration,a_elevation_ground_scale); 1962#endif 1963#ifdef CROSS_SLOPE_VERTICAL 1964float top=pos_normal.y-2.0*floor(pos_normal.y*0.5);float line_height=2.0*u_tile_to_meter*outset*top*u_pixels_to_tile_units[1][1]+scaled_z_offset;ele=sample_elevation(offset_pos)+line_height;projected_extrude=vec4(0); 1965#else 1966#ifdef CROSS_SLOPE_HORIZONTAL 1967float ele0=sample_elevation(offset_pos);float ele1=max(sample_elevation(offset_pos+extrude),sample_elevation(offset_pos+extrude/2.0));float ele2=max(sample_elevation(offset_pos-extrude),sample_elevation(offset_pos-extrude/2.0));float ele_max=max(ele0,max(ele1,ele2));ele=ele_max+scaled_z_offset; 1968#else 1969float ele0=sample_elevation(offset_pos);float ele1=max(sample_elevation(offset_pos+extrude),sample_elevation(offset_pos+extrude/2.0));float ele2=max(sample_elevation(offset_pos-extrude),sample_elevation(offset_pos-extrude/2.0));float ele_max=max(ele0,0.5*(ele1+ele2));ele=ele_max-ele0+ele1+scaled_z_offset; 1970#endif 1971#endif 1972gl_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); 1973#else 1974gl_Position=mix(u_matrix*vec4(pos+offset2*u_pixels_to_tile_units,0.0,1.0)+projected_extrude,AWAY,hidden); 1975#endif 1976#endif 1977#ifdef ELEVATED_ROADS 1978#ifdef RENDER_SHADOWS 1979vec3 shd_pos=vec3(pos+(offset2+dist)*u_pixels_to_tile_units,a_z_offset);vec3 shd_pos0=shd_pos;vec3 shd_pos1=shd_pos; 1980#ifdef NORMAL_OFFSET 1981vec3 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(); 1982#endif 1983v_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; 1984#endif 1985#endif 1986#ifndef RENDER_TO_TEXTURE 1987float 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)); 1988#else 1989v_gamma_scale=1.0; 1990#endif 1991#ifdef RENDER_LINE_TRIM_OFFSET 1992highp float a_uv_x=a_packed[0];highp float line_progress=a_packed[2];v_uv=vec3(a_uv_x,0.0,line_progress); 1993#endif 1994v_linesofar=a_linesofar;v_width2=vec2(outset,inset);v_width=(floorwidth*u_floor_width_scale); 1995#ifdef LINE_JOIN_NONE 1996v_width=(floorwidth*u_floor_width_scale)+ANTIALIASING;mediump float pixels_to_tile_units=1.0/u_tile_units_to_pixels;mediump float pixel_ratio_inverse=1.0/pixel_ratio;mediump float aspect=v_width/(float(pattern.w-pattern.y)*pixel_ratio_inverse);highp float subt_multiple=float(pattern.z-pattern.x)*pixel_ratio_inverse*pixels_to_tile_units*aspect*32.0;highp float subt=floor(a_pattern_data.z/subt_multiple)*subt_multiple;float offset_sign=(fract(a_pattern_data.x)-0.5)*4.0;float line_progress_offset=offset_sign*v_width*0.5*pixels_to_tile_units;v_linesofar=(a_pattern_data.z-subt)+a_linesofar+line_progress_offset;v_pattern_data=vec2(a_pattern_data.x+line_progress_offset,a_pattern_data.y); 1997#endif 1998#ifdef FOG 1999v_fog_pos=fog_position(pos); 2000#endif 2001#ifdef INDICATOR_CUTOUT 2002v_z_offset=a_z_offset; 2003#endif 2004}`),raster:zt(`#include "_prelude_fog.fragment.glsl" 2005#include "_prelude_lighting.glsl" 2006#include "_prelude_raster_array.glsl" 2007uniform 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; 2008#ifdef PROJECTION_GLOBE_VIEW 2009in float v_split_fade; 2010#endif 2011uniform 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; 2012#ifndef RASTER_ARRAY 2013uniform highp sampler2D u_image0;uniform sampler2D u_image1; 2014#endif 2015#ifdef RASTER_COLOR 2016uniform sampler2D u_color_ramp;uniform highp vec4 u_colorization_mix;uniform highp float u_colorization_offset;uniform vec2 u_texture_res; 2017#endif 2018void main() {vec4 color0,color1,color;vec2 value; 2019#ifdef RASTER_COLOR 2020#ifdef RASTER_ARRAY 2021#ifdef RASTER_ARRAY_LINEAR 2022value=mix( 2023raTexture2D_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 2024); 2025#else 2026value=mix( 2027raTexture2D_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 2028); 2029#endif 2030if (value.y > 0.0) value.x/=value.y; 2031#else 2032color=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); 2033#endif 2034color=texture(u_color_ramp,vec2(value.x,0.5));if (color.a > 0.0) color.rgb/=color.a;color.a*=value.y; 2035#else 2036color0=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); 2037#endif 2038color.a*=u_opacity; 2039#ifdef GLOBE_POLES 2040color.a*=1.0-smoothstep(0.0,0.05,u_zoom_transition); 2041#endif 2042vec3 rgb=color.rgb;rgb=vec3( 2043dot(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); 2044#ifdef LIGHTING_3D_MODE 2045out_color=apply_lighting_with_emission_ground(vec4(out_color,1.0),u_emissive_strength).rgb; 2046#endif 2047#ifdef FOG 2048highp 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)); 2049#endif 2050glFragColor=vec4(out_color*color.a,color.a); 2051#ifdef PROJECTION_GLOBE_VIEW 2052glFragColor*=mix(1.0,1.0-smoothstep(0.0,0.05,u_zoom_transition),smoothstep(0.8,0.9,v_split_fade)); 2053#endif 2054#ifdef RENDER_CUTOFF 2055glFragColor=glFragColor*cutoff_opacity(u_cutoff_params,v_depth); 2056#endif 2057#ifdef OVERDRAW_INSPECTOR 2058glFragColor=vec4(1.0); 2059#endif 2060#ifdef USE_MRT1 2061out_Target1=vec4(u_emissive_strength*glFragColor.a,0.0,0.0,glFragColor.a); 2062#endif 2063HANDLE_WIREFRAME_DEBUG;}`,`#include "_prelude_fog.vertex.glsl" 2064#include "_prelude_terrain.vertex.glsl" 2065uniform 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; 2066#ifdef ELEVATED 2067uniform lowp float u_zbias_factor; 2068#endif 2069#define GLOBE_UPSCALE GLOBE_RADIUS/6371008.8 2070#ifdef GLOBE_POLES 2071in vec3 a_globe_pos;in vec2 a_uv; 2072#else 2073in ivec2 a_pos;in uvec2 a_texture_pos; 2074#endif 2075out vec2 v_pos0;out vec2 v_pos1;out float v_depth; 2076#ifdef PROJECTION_GLOBE_VIEW 2077out float v_split_fade; 2078#endif 2079void main() {vec2 uv; 2080#ifdef GLOBE_POLES 2081vec3 globe_pos=a_globe_pos;uv=a_uv;float ele=u_raster_elevation; 2082#ifdef ELEVATION_REFERENCE_GROUND 2083ele+=elevation(uv*EXTENT); 2084#endif 2085globe_pos+=normalize(globe_pos)*ele*GLOBE_UPSCALE;gl_Position=u_matrix*u_globe_matrix*vec4(globe_pos,1.0); 2086#ifdef FOG 2087v_fog_pos=fog_position((u_normalize_matrix*vec4(a_globe_pos,1.0)).xyz); 2088#endif 2089#else 2090vec4 world_pos; 2091#ifdef PROJECTION_GLOBE_VIEW 2092vec2 texture_pos=vec2(a_texture_pos);uv=texture_pos/8192.0;vec3 decomposed_pos_and_skirt=decomposeToPosAndSkirt(a_pos);vec3 latLng=u_grid_matrix*vec3(decomposed_pos_and_skirt.xy,1.0);float mercatorY=mercatorYfromLat(latLng[0]);float mercatorX=mercatorXfromLng(latLng[1]); 2093float tiles=u_grid_matrix[0][2];
2093if (tiles > 0.0) {float idx=u_grid_matrix[1][2];float idy=u_grid_matrix[2][2];float uvY=mercatorY*tiles-idy;float uvX=mercatorX*tiles-idx;uv=vec2(uvX,uvY);}float ele=u_raster_elevation; 2094#ifdef ELEVATION_REFERENCE_GROUND 2095ele+=elevation(uv*EXTENT)-decomposed_pos_and_skirt.z; 2096#endif 2097vec4 merc_world_pos=vec4(0.0); 2098v_split_fade=0.0;if (u_zoom_transition > 0.0) {vec2 merc_pos=vec2(mercatorX,mercatorY);merc_world_pos=vec4(merc_pos,ele,1.0);merc_world_pos.xy-=u_merc_center;merc_world_pos.x=wrap(merc_world_pos.x,-0.5,0.5);merc_world_pos=u_merc_matrix*merc_world_pos;float opposite_merc_center=mod(u_merc_center.x+0.5,1.0);float dist_from_poles=(abs(mercatorY-0.5)*2.0);float range=0.1;v_split_fade=abs(opposite_merc_center-mercatorX);v_split_fade=clamp(1.0-v_split_fade,0.0,1.0);v_split_fade=max(smoothstep(1.0-range,1.0,dist_from_poles),max(smoothstep(1.0-range,1.0,v_split_fade),smoothstep(1.0-range,1.0,1.0-v_split_fade)));}vec3 globe_pos=latLngToECEF(latLng.xy);globe_pos+=normalize(globe_pos)*ele*GLOBE_UPSCALE;vec4 globe_world_pos=u_globe_matrix*vec4(globe_pos,1.0);world_pos=vec4(mix(globe_world_pos.xyz,merc_world_pos.xyz,u_zoom_transition),1.0); 2099#ifdef FOG 2100v_fog_pos=fog_position((u_normalize_matrix*vec4(globe_pos,1.0)).xyz); 2101#endif 2102#else 2103float ele=0.0;vec2 decodedPos=vec2(a_pos); 2104#ifdef ELEVATION_REFERENCE_GROUND 2105vec3 decomposedPosAndSkirt=decomposeToPosAndSkirt(a_pos);float skirt=decomposedPosAndSkirt.z;decodedPos=decomposedPosAndSkirt.xy;uv=decodedPos/8192.0;ele=elevation(decodedPos)-skirt; 2106#else 2107uv=vec2(a_texture_pos)/8192.0; 2108#endif 2109world_pos=vec4(decodedPos,(u_raster_elevation+ele),1.0); 2110#ifdef FOG 2111v_fog_pos=fog_position(decodedPos); 2112#endif 2113#endif 2114float w=1.0+dot(uv*EXTENT,u_perspective_transform);gl_Position=u_matrix*world_pos*w; 2115#endif 2116v_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; 2117#ifdef ELEVATED 2118float z=clamp(gl_Position.z/gl_Position.w,0.5,1.0);float zbias=max(0.00005,(pow(z,0.8)-z)*u_zbias_factor);gl_Position.z-=(gl_Position.w*zbias); 2119#endif 2120#ifdef RENDER_CUTOFF 2121v_depth=gl_Position.z; 2122#endif 2123}`),symbol:zt(`#include "_prelude_lighting.glsl" 2124#include "_prelude_shadow.fragment.glsl" 2125#define SDF_PX 8.0 2126#define SDF 1.0 2127#define ICON 0.0 2128uniform 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; 2129#ifdef ICON_TRANSITION 2130uniform float u_icon_transition; 2131#endif 2132#ifdef COLOR_ADJUSTMENT 2133uniform mat4 u_color_adj_mat; 2134#endif 2135#ifdef INDICATOR_CUTOUT 2136in highp float v_z_offset; 2137#else 2138#ifdef RENDER_SHADOWS 2139in highp float v_z_offset; 2140#endif 2141#endif 2142in vec2 v_tex_a; 2143#ifdef ICON_TRANSITION 2144in vec2 v_tex_b; 2145#endif 2146in float v_draw_halo;in vec3 v_gamma_scale_size_fade_opacity; 2147#ifdef RENDER_TEXT_AND_SYMBOL 2148in float is_sdf;in vec2 v_tex_a_icon; 2149#endif 2150#ifdef RENDER_SHADOWS 2151uniform 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; 2152#endif 2153#ifdef APPLY_LUT_ON_GPU 2154uniform highp sampler3D u_lutTexture; 2155#endif 2156#ifdef USE_PAINT_PROPERTIES_UBO 2157in lowp float v_opacity; 2158#ifdef RENDER_SDF 2159in lowp vec4 v_fill_np_color;in lowp vec4 v_halo_np_color;in lowp float v_halo_width;in lowp float v_halo_blur; 2160#endif 2161#ifdef LIGHTING_3D_MODE 2162in lowp float v_emissive_strength; 2163#endif 2164#else 2165#pragma mapbox: define highp vec4 fill_color 2166#pragma mapbox: define highp vec4 halo_color 2167#pragma mapbox: define lowp float opacity 2168#pragma mapbox: define lowp float halo_width 2169#pragma mapbox: define lowp float halo_blur 2170#pragma mapbox: define lowp float emissive_strength 2171#endif 2172void main() { 2173#ifdef USE_PAINT_PROPERTIES_UBO 2174lowp float opacity=v_opacity;lowp vec4 fill_color=vec4(0.0);lowp vec4 halo_color=vec4(0.0);lowp float halo_width=0.0;lowp float halo_blur=0.0; 2175#ifdef RENDER_SDF 2176fill_color=vec4(v_fill_np_color.rgb*v_fill_np_color.a,v_fill_np_color.a);halo_color=vec4(v_halo_np_color.rgb*v_halo_np_color.a,v_halo_np_color.a);halo_width=v_halo_width;halo_blur=v_halo_blur; 2177#endif 2178lowp float emissive_strength=0.0; 2179#ifdef LIGHTING_3D_MODE 2180emissive_strength=v_emissive_strength; 2181#endif 2182#else 2183#pragma mapbox: initialize highp vec4 fill_color 2184#pragma mapbox: initialize highp vec4 halo_color 2185#pragma mapbox: initialize lowp float opacity 2186#pragma mapbox: initialize lowp float halo_width 2187#pragma mapbox: initialize lowp float halo_blur 2188#pragma mapbox: initialize lowp float emissive_strength 2189#endif 2190vec4 out_color;float fade_opacity=v_gamma_scale_size_fade_opacity[2]; 2191#ifdef RENDER_TEXT_AND_SYMBOL 2192if (is_sdf==ICON) {vec2 tex_icon=v_tex_a_icon;lowp float alpha=opacity*fade_opacity;
2192glFragColor=texture(u_texture_icon,tex_icon)*alpha; 2193#ifdef OVERDRAW_INSPECTOR 2194glFragColor=vec4(1.0); 2195#endif 2196return;} 2197#endif 2198vec2 cutout_factors=vec2(0.0); 2199#ifdef FEATURE_CUTOUT 2200cutout_factors=get_cutout_factors(gl_FragCoord); 2201#endif 2202#ifdef RENDER_SDF 2203float 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; 2204#else 2205#ifdef ICON_TRANSITION 2206vec4 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); 2207#else 2208out_color=texture(u_texture,v_tex_a); 2209#endif 2210#ifdef APPLY_LUT_ON_GPU 2211out_color=applyLUT(u_lutTexture,out_color); 2212#endif 2213#ifdef COLOR_ADJUSTMENT 2214out_color=u_color_adj_mat*out_color; 2215#endif 2216#endif 2217out_color*=opacity*fade_opacity; 2218#ifdef LIGHTING_3D_MODE 2219out_color=apply_lighting_with_emission_ground(out_color,emissive_strength); 2220#ifdef RENDER_SHADOWS 2221float light=shadowed_light_factor(v_pos_light_view_0,v_pos_light_view_1,v_depth);light=mix(light,1.0,cutout_factors.y); 2222#ifdef TERRAIN 2223out_color.rgb*=mix(u_ground_shadow_factor,vec3(1.0),light); 2224#else 2225out_color.rgb*=mix(v_z_offset !=0.0 ? u_ground_shadow_factor : vec3(1.0),vec3(1.0),light); 2226#endif 2227#endif 2228#endif 2229#ifdef INDICATOR_CUTOUT 2230out_color=applyCutout(out_color,v_z_offset); 2231#endif 2232#ifdef FEATURE_CUTOUT 2233out_color=apply_feature_cutout(out_color,gl_FragCoord,cutout_factors.x); 2234#endif 2235glFragColor=out_color; 2236#ifdef OVERDRAW_INSPECTOR 2237glFragColor=vec4(1.0); 2238#endif 2239HANDLE_WIREFRAME_DEBUG;}`,`#include "_prelude_terrain.vertex.glsl" 2240#include "_prelude_shadow.vertex.glsl" 2241#define USING_APPEARANCE 1.0 2242in ivec4 a_pos_offset;in uvec4 a_tex_size;in ivec4 a_pixeloffset;in vec4 a_projected_pos;in uint a_fade_opacity; 2243#ifdef Z_OFFSET 2244in float a_auto_z_offset; 2245#endif 2246#ifdef PROJECTION_GLOBE_VIEW 2247in ivec4 a_globe_anchor;in vec3 a_globe_normal; 2248#endif 2249#ifdef ICON_TRANSITION 2250in uvec2 a_texb; 2251#endif 2252#ifdef OCCLUSION_QUERIES 2253in float a_occlusion_query_opacity; 2254#endif 2255#ifdef ELEVATED_ROADS 2256in vec3 a_x_axis;in vec3 a_y_axis;uniform float u_normal_scale; 2257#endif 2258#ifdef INDICATOR_CUTOUT 2259out highp float v_z_offset; 2260#else 2261#ifdef RENDER_SHADOWS 2262out highp float v_z_offset; 2263#endif 2264#endif 2265uniform 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; 2266#ifdef PROJECTION_GLOBE_VIEW 2267uniform 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; 2268#endif 2269out vec2 v_tex_a; 2270#ifdef ICON_TRANSITION 2271out vec2 v_tex_b; 2272#endif 2273out float v_draw_halo;out vec3 v_gamma_scale_size_fade_opacity; 2274#ifdef RENDER_TEXT_AND_SYMBOL 2275out float is_sdf;out vec2 v_tex_a_icon; 2276#endif 2277#ifdef RENDER_SHADOWS 2278uniform 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; 2279#endif 2280#ifdef USE_PAINT_PROPERTIES_UBO 2281#ifndef MAX_UBO_SIZE_VEC4 2282#define MAX_UBO_SIZE_VEC4 1024u 2283#endif 2284#define SPP_HEADER_SIZE_VEC4 3u 2285#define DWORDS_PER_VEC4 4u 2286struct SymbolPaintProperties {vec4 fill_np_color;vec4 halo_np_color;float opacity;float halo_width;float halo_blur;float emissive_strength;float occlusion_opacity;float z_offset;vec2 translate;};struct PropertyType {bool isDataDriven;bool isZoomDependent;uint offsetDwords;};struct SymbolPropertyHeader {uint dataDrivenBlockSizeVec4;PropertyType fill_np_color;PropertyType halo_np_color;PropertyType opacity;PropertyType halo_width;PropertyType halo_blur;PropertyType emissive_strength;PropertyType occlusion_opacity;PropertyType z_offset;PropertyType translate;};uniform float u_zoom;uniform lowp vec4 u_spp_fill_np_color;uniform lowp vec4 u_spp_halo_np_color;uniform lowp float u_spp_opacity;uniform lowp float u_spp_halo_width;uniform lowp float u_spp_halo_blur;uniform lowp float u_spp_emissive_strength;uniform lowp float u_spp_occlusion_opacity;uniform highp float u_spp_z_offset;uniform lowp vec2 u_spp_translate_rotation;in float a_feature_index;layout(std140) uniform SymbolPaintPropertiesHeaderUniform {uvec4 header[SPP_HEADER_SIZE_VEC4];} u_spp_header;layout(std140) uniform SymbolPaintPropertiesUniform {vec4 properties[MAX_UBO_SIZE_VEC4];} u_spp_properties;layout(std140) uniform SymbolPaintPropertiesIndexUniform {uvec4 block_indices[MAX_UBO_SIZE_VEC4];} u_spp_index;out lowp float v_opacity; 2287#ifdef RENDER_SDF 2288out lowp vec4 v_fill_np_color;out lowp vec4 v_halo_np_color;out lowp float v_halo_width;out lowp float v_halo_blur; 2289#endif 2290#ifdef LIGHTING_3D_MODE 2291out lowp float v_emissive_strength; 2292#endif 2293PropertyType getPropertyType(uint propertyIndex,uint dataDrivenMask,uint zoomDependentMask,uint offsetDwords) {PropertyType type;type.isDataDriven=(dataDrivenMask & (1u << propertyIndex)) !=0u;type.isZoomDependent=(zoomDependentMask & (1u << propertyIndex)) !=0u;type.offsetDwords=offsetDwords;return type;}SymbolPropertyHeader readSymbolPropertiesHeader() {SymbolPropertyHeader header;uint dataDrivenMask=u_spp_header.header[0][0];uint zoomDependentMask=u_spp_header.header[0][1];header.dataDrivenBlockSizeVec4=u_spp_header.header[0][2];header.fill_np_color =getPropertyType(0u,dataDrivenMask,zoomDependentMask,u_spp_header.header[0][3]);header.halo_np_color =getPropertyType(1u,dataDrivenMask,zoomDependentMask,u_spp_header.header[1][0]);header.opacity =getPropertyType(2u,dataDrivenMask,zoomDependentMask,u_spp_header.header[1][1]);header.halo_width =getPropertyType(3u,dataDrivenMask,zoomDependentMask,u_spp_header.header[1][2]);header.halo_blur =getPropertyType(4u,dataDrivenMask,zoomDependentMask,u_spp_header.header[1][3]);header.emissive_strength =getPropertyType(5u,dataDrivenMask,zoomDependentMask,u_spp_header.header[2][0]);header.occlusion_opacity =getPropertyType(6u,dataDrivenMask,zoomDependentMask,u_spp_header.header[2][1]);header.z_offset =getPropertyType(7u,dataDrivenMask,zoomDependentMask,u_spp_header.header[2][2]);header.translate =getPropertyType(8u,dataDrivenMask,zoomDependentMask,u_spp_header.header[2][3]);return header;}uint uvec4At(uvec4 v,uint index) {return (index==0u) ? v.x : 2294(index==1u) ? v.y : 2295(index==2u) ? v.z : v.w;}float vec4At(vec4 v,uint index) {return (index==0u) ? v.x : 2296(index==1u) ? v.y : 2297(index==2u) ? v.z : v.w;}vec4 readVec4(uint baseOffsetVec4,uint propertyOffsetDwords) {return u_spp_properties.properties[baseOffsetVec4+propertyOffsetDwords/DWORDS_PER_VEC4];}float readFloat(vec4 slot,uint propertyOffsetDwords) {return slot[propertyOffsetDwords % DWORDS_PER_VEC4];}uint readUint(uvec4 slot,uint offset) {return slot[offset % DWORDS_PER_VEC4];}vec2 readVec2(vec4 slot,uint propertyOffsetDwords) {float x=vec4At(slot,propertyOffsetDwords % DWORDS_PER_VEC4);float y=vec4At(slot,propertyOffsetDwords % DWORDS_PER_VEC4+1u);return vec2(x,y);}uint getDataDrivenBlockOffsetVec4(uint dataDrivenBlockSizeVec4) {uint featureIndex=uint(a_feature_index);uvec4 slot=u_spp_index.block_indices[featureIndex/DWORDS_PER_VEC4];uint blockIndex=uvec4At(slot,featureIndex % DWORDS_PER_VEC4);return blockIndex*dataDrivenBlockSizeVec4;}vec4 readColorProperty(PropertyType propertyType,uint dataDrivenBlockSizeVec4) {uint blockOffsetVec4=getDataDrivenBlockOffsetVec4(dataDrivenBlockSizeVec4);vec4 color=readVec4(blockOffsetVec4,propertyType.offsetDwords);if (propertyType.isZoomDependent) {color=unpack_mix_color(color,u_zoom);} else {vec2 packedColor=readVec2(color,propertyType.offsetDwords);color=decode_color(packedColor);}return color;}vec2 readVec2Property(PropertyType propertyType,uint dataDrivenBlockSizeVec4) {uint blockOffsetVec4=getDataDrivenBlockOffsetVec4(dataDrivenBlockSizeVec4);vec4 slot=readVec4(blockOffsetVec4,propertyType.offsetDwords);if (propertyType.isZoomDependent) {vec2 minVal=slot.xy;vec2 maxVal=slot.zw;return mix(minVal,maxVal,u_zoom);}return readVec2(slot,propertyType.offsetDwords);}float readFloatProperty(PropertyType propertyType,uint dataDrivenBlockSizeVec4) {uint blockOffsetVec4=getDataDrivenBlockOffsetVec4(dataDrivenBlockSizeVec4);vec4 slot=readVec4(blockOffsetVec4,propertyType.offsetDwords);float value;if (propertyType.isZoomDependent) {vec2 packedValues=readVec2(slot,propertyType.offsetDwords);value=unpack_mix_vec2(packedValues,u_zoom);} else {value=readFloat(slot,propertyType.offsetDwords);}return value;}SymbolPaintProperties readSymbolPaintProperties() {SymbolPropertyHeader header=readSymbolPropertiesHeader();uint sizeVec4=header.dataDrivenBlockSizeVec4;SymbolPaintProperties props;props.fill_np_color =header.fill_np_color.isDataDriven ? readColorProperty(header.fill_np_color,sizeVec4) : u_spp_fill_np_color;props.halo_np_color =header.halo_np_color.isDataDriven ? readColorProperty(header.halo_np_color,sizeVec4) : u_spp_halo_np_color;props.opacity =header.opacity.isDataDriven ? readFloatProperty(header.opacity,sizeVec4) : u_spp_opacity;props.halo_width =header.halo_width.isDataDriven ? readFloatProperty(header.halo_width,sizeVec4) : u_spp_halo_width;props.halo_blur =header.halo_blur.isDataDriven ? readFloatProperty(header.halo_blur,sizeVec4) : u_spp_halo_blur;props.emissive_strength =header.emissive_strength.isDataDriven ? readFloatProperty(header.emissive_strength,sizeVec4) : u_spp_emissive_strength;props.occlusion_opacity =header.occlusion_opacity.isDataDriven ? readFloatProperty(header.occlusion_opacity,sizeVec4) : u_spp_occlusion_opacity;props.z_offset =header.z_offset.isDataDriven ? readFloatProperty(header.z_offset,sizeVec4) : u_spp_z_offset;props.translate =header.translate.isDataDriven ? readVec2Property(header.translate,sizeVec4) : vec2(0.0);return props;} 2298#else 2299#pragma mapbox: define highp vec4 fill_color 2300#pragma mapbox: define highp vec4 halo_color 2301#pragma mapbox: define lowp float opacity 2302#pragma mapbox: define lowp float halo_width 2303#pragma mapbox: define lowp float halo_blur 2304#pragma mapbox: define lowp float emissive_strength 2305#pragma mapbox: define lowp float occlusion_opacity 2306#pragma mapbox: define highp float z_offset 2307#endif 2308vec2 unpack_opacity(uint packedOpacity) {return vec2(float(packedOpacity/2u)/127.0,float(packedOpacity & 1u));}void main() { 2309#ifdef USE_PAINT_PROPERTIES_UBO 2310SymbolPaintProperties paint_properties=readSymbolPaintProperties();lowp float opacity=paint_properties.opacity;v_opacity=opacity; 2311#ifdef RENDER_SDF 2312v_fill_np_color=paint_properties.fill_np_color;v_halo_np_color=paint_properties.halo_np_color;v_halo_width=paint_properties.halo_width;v_halo_blur=paint_properties.halo_blur; 2313#endif 2314#ifdef LIGHTING_3D_MODE 2315v_emissive_strength=paint_properties.emissive_strength; 2316#endif 2317lowp float occlusion_opacity=paint_properties.occlusion_opacity;highp float z_offset=paint_properties.z_offset; 2318#else 2319#pragma mapbox: initialize highp vec4 fill_color 2320#pragma mapbox: initialize highp vec4 halo_color 2321#pragma mapbox: initialize lowp float opacity 2322#pragma mapbox: initialize lowp float halo_width 2323#pragma mapbox: initialize lowp float halo_blur 2324#pragma mapbox: initialize lowp float emissive_strength 2325#pragma mapbox: initialize lowp float occlusion_opacity 2326#pragma mapbox: initialize highp float z_offset 2327#endif 2328vec2 a_pos=vec2(a_pos_offset.xy);vec2 a_offset=vec2(a_pos_offset.zw);vec2 a_tex=vec2(a_tex_size.xy);vec2 a_size=vec2(a_tex_size.zw);float a_size_min=floor(a_size[0]*0.5);float a_size_max= floor(a_size[1]*0.5);float a_apperance=a_size[1]-2.0*a_size_max;vec2 a_pxoffset=vec2(a_pixeloffset.xy);vec2 a_min_font_scale=vec2(a_pixeloffset.zw)/256.0;highp float segment_angle=-a_projected_pos[3];float size;if (a_apperance==USING_APPEARANCE) {size=a_size_max/128.0;} else if (!u_is_size_zoom_constant && !u_is_size_feature_constant) {size=mix(a_size_min,a_size_max,u_size_t)/128.0;} else if (u_is_size_zoom_constant && !u_is_size_feature_constant) {size=a_size_min/128.0;} else {size=u_size;}vec2 tile_anchor=a_pos;float e=u_elevation_from_sea ? z_offset : z_offset+elevation(tile_anchor); 2329#ifdef Z_OFFSET 2330e+=a_auto_z_offset; 2331#endif 2332vec3 h=elevationVector(tile_anchor)*e;float globe_occlusion_fade;vec3 world_pos;vec3 mercator_pos;vec3 world_pos_globe; 2333#ifdef PROJECTION_GLOBE_VIEW 2334mercator_pos=mercator_tile_position(u_inv_rot_matrix,tile_anchor,u_tile_id,u_merc_center);world_pos_globe=vec3(a_globe_anchor)+h;world_pos=mix_globe_mercator(world_pos_globe,mercator_pos,u_zoom_transition);vec4 ecef_point=u_tile_matrix*vec4(world_pos,1.0);vec3 origin_to_point=ecef_point.xyz-u_ecef_origin;globe_occlusion_fade=dot(origin_to_point,u_camera_forward) >=0.0 ? 0.0 : 1.0; 2335#else 2336world_pos=vec3(tile_anchor,0)+h;globe_occlusion_fade=1.0; 2337#endif 2338vec4 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 ? 2339camera_to_anchor_distance/u_camera_to_center_distance : 2340u_camera_to_center_distance/camera_to_anchor_distance;highp float perspective_ratio=clamp( 23410.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; 2342#ifdef PROJECTION_GLOBE_VIEW 2343vec3 displacement=vec3(a_globe_normal.z,0,-a_globe_normal.x);
2343offsetprojected_point=u_matrix*vec4(vec3(a_globe_anchor)+displacement,1);vec4 projected_point_globe=u_matrix*vec4(world_pos_globe,1);a=projected_point_globe.xy/projected_point_globe.w; 2344#else 2345offsetprojected_point=u_matrix*vec4(tile_anchor+vec2(1,0),0,1);a=projected_point.xy/projected_point.w; 2346#endif 2347vec2 b=offsetprojected_point.xy/offsetprojected_point.w;symbol_rotation=atan((b.y-a.y)/u_aspect_ratio,b.x-a.x);}vec4 projected_pos; 2348#ifdef PROJECTION_GLOBE_VIEW 2349#ifdef PROJECTED_POS_ON_VIEWPORT 2350projected_pos=u_label_plane_matrix*vec4(a_projected_pos.xyz+h,1.0); 2351#else 2352vec3 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); 2353#endif 2354#else 2355projected_pos=u_label_plane_matrix*vec4(a_projected_pos.xy,h.z,1.0); 2356#endif 2357highp 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); 2358#ifdef TERRAIN 2359#ifdef PITCH_WITH_MAP_TERRAIN 2360vec4 tile_pos=u_label_plane_matrix_inv*vec4(a_projected_pos.xy+offset,0.0,1.0);z=elevation(tile_pos.xy); 2361#endif 2362#endif 2363#ifdef Z_OFFSET 2364z+=u_pitch_with_map ? a_auto_z_offset+z_offset : 0.0; 2365#else 2366z+=u_pitch_with_map ? z_offset : 0.0; 2367#endif 2368float 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)); 2369#ifdef DEPTH_OCCLUSION 2370float depth_occlusion=occlusionFadeMultiSample(projected_point);float depth_occlusion_multplier=mix(occlusion_opacity,1.0,depth_occlusion);out_fade_opacity*=depth_occlusion_multplier; 2371#endif 2372#ifdef OCCLUSION_QUERIES 2373float occludedFadeMultiplier=mix(occlusion_opacity,1.0,a_occlusion_query_opacity);out_fade_opacity*=occludedFadeMultiplier; 2374#endif 2375#ifdef Z_TEST_OCCLUSION 2376out_fade_opacity*=occlusion_opacity; 2377#endif 2378float alpha=opacity*out_fade_opacity;float hidden=float(alpha==0.0 || projected_point.w <=0.0 || occlusion_fade==0.0);vec3 pos; 2379#ifdef PROJECTION_GLOBE_VIEW 2380vec3 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; 2381#else 2382#ifdef ELEVATED_ROADS 2383vec3 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; 2384#else 2385pos=vec3(projected_pos.xy/projected_pos.w+offset,z); 2386#endif 2387#endif 2388gl_Position=mix(u_coord_matrix*vec4(pos,1.0),AWAY,hidden); 2389#ifdef USE_PAINT_PROPERTIES_UBO 2390{vec2 tr=paint_properties.translate;vec2 rotated_tr=vec2( 2391u_spp_translate_rotation.x*tr.x-u_spp_translate_rotation.y*tr.y,u_spp_translate_rotation.y*tr.x+u_spp_translate_rotation.x*tr.y 2392);gl_Position.xy+=(u_coord_matrix*vec4(rotated_tr,0.0,0.0)).xy;} 2393#endif 2394float 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; 2395#ifdef RENDER_TEXT_AND_SYMBOL 2396is_sdf=a_size[0]-2.0*a_size_min;v_tex_a_icon=a_tex/u_texsize_icon; 2397#endif 2398#ifdef ICON_TRANSITION 2399v_tex_b=vec2(a_texb)/u_texsize; 2400#endif 2401#ifdef RENDER_SHADOWS 2402vec4 shd_pos=u_inv_matrix*vec4(pos,1.0);vec3 shd_pos0=shd_pos.xyz;vec3 shd_pos1=shd_pos.xyz; 2403#ifdef NORMAL_OFFSET 2404vec3 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(); 2405#endif 2406v_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; 2407#endif 2408#ifdef INDICATOR_CUTOUT 2409v_z_offset=e; 2410#else 2411#ifdef RENDER_SHADOWS 2412v_z_offset=e; 2413#endif 2414#endif 2415}`),terrainRaster:zt(`#include "_prelude_fog.fragment.glsl" 2416#include "_prelude_shadow.fragment.glsl" 2417#include "_prelude_lighting.glsl" 2418uniform sampler2D u_image0; 2419#ifdef LIGHTING_3D_ALPHA_EMISSIVENESS
2420uniform sampler2D u_image1;uniform float u_emissive_texture_available; 2421#endif 2422in vec2 v_pos0; 2423#ifdef FOG 2424in float v_fog_opacity; 2425#endif 2426#ifdef RENDER_SHADOWS 2427in vec4 v_pos_light_view_0;in vec4 v_pos_light_view_1; 2428#endif 2429uniform vec3 u_ground_shadow_factor;void main() {vec4 image_color=texture(u_image0,v_pos0);vec4 color; 2430#ifdef LIGHTING_3D_MODE 2431const vec3 normal=vec3(0.0,0.0,1.0); 2432#ifdef RENDER_SHADOWS 2433float cutoffOpacity=1.0; 2434#ifdef RENDER_CUTOFF 2435cutoffOpacity=cutoff_opacity(u_cutoff_params,1.0/gl_FragCoord.w); 2436#endif 2437#ifdef LIGHTING_3D_ALPHA_EMISSIVENESS 2438float emissive_strength=u_emissive_texture_available > 0.5 ? texture(u_image1,v_pos0).r : image_color.a;vec3 unlit_base=image_color.rgb*(1.0-emissive_strength);vec3 emissive_base=image_color.rgb*emissive_strength;float ndotl=u_shadow_direction.z;float occlusion=ndotl < 0.0 ? 1.0 : shadow_occlusion(v_pos_light_view_0,v_pos_light_view_1,1.0/gl_FragCoord.w,0.0);ndotl=max(0.0,ndotl);vec3 lit=apply_lighting(unlit_base,normal,mix(1.0,(1.0-(u_shadow_intensity*occlusion))*ndotl,cutoffOpacity));vec3 emissive=compute_emissive_draped(emissive_base,1.0-u_shadow_intensity,occlusion,u_ground_shadow_factor);color.rgb=lit+emissive;color.a=1.0; 2439#else 2440float 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)); 2441#endif 2442#else 2443float lighting_factor=u_lighting_directional_dir.z;color=apply_lighting(image_color,normal,lighting_factor); 2444#ifdef LIGHTING_3D_ALPHA_EMISSIVENESS 2445float emissive_strength=u_emissive_texture_available > 0.5 ? texture(u_image1,v_pos0).r : image_color.a;color.rgb=mix(color.rgb,image_color.rgb,emissive_strength);color.a=1.0; 2446#endif 2447#endif 2448#else 2449color=image_color; 2450#endif 2451#ifdef FOG 2452#ifdef ZERO_EXAGGERATION 2453color=fog_dither(fog_apply_premultiplied(color,v_fog_pos)); 2454#else 2455color=fog_dither(fog_apply_from_vert(color,v_fog_opacity)); 2456#endif 2457#endif 2458glFragColor=color; 2459#ifdef OVERDRAW_INSPECTOR 2460glFragColor=vec4(1.0); 2461#endif 2462HANDLE_WIREFRAME_DEBUG;}`,`#include "_prelude_fog.vertex.glsl" 2463#include "_prelude_terrain.vertex.glsl" 2464uniform mat4 u_matrix;uniform float u_skirt_height;in ivec2 a_pos;out vec2 v_pos0; 2465#ifdef FOG 2466out float v_fog_opacity; 2467#endif 2468#ifdef RENDER_SHADOWS 2469uniform 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; 2470#endif 2471void 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); 2472#ifdef FOG 2473#ifdef ZERO_EXAGGERATION 2474v_fog_pos=fog_position(decodedPos); 2475#else 2476v_fog_opacity=fog(fog_position(vec3(decodedPos,elevation))); 2477#endif 2478#endif 2479#ifdef RENDER_SHADOWS 2480vec3 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.); 2481#endif 2482}`),terrainDepth:zt("precision highp float;in float v_depth;void main() {glFragColor=pack_depth(v_depth);}",`#include "_prelude_terrain.vertex.glsl" 2483uniform mat4 u_matrix;in ivec2 a_pos;out float v_depth;void main() {float elevation=elevation(vec2(a_pos));gl_Position=u_matrix*vec4(a_pos,elevation,1.0);v_depth=gl_Position.z/gl_Position.w;}`),skybox:zt(`#include "_prelude_fog.fragment.glsl" 2484in 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( 2485cos_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
2485nd-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; 2486#ifdef FOG 2487sky_color=fog_apply_sky_gradient(v_uv.xzy,sky_color); 2488#endif 2489sky_color+=0.1*sun_disk(v_uv,u_sun_direction);glFragColor=vec4(sky_color*u_opacity,u_opacity); 2490#ifdef OVERDRAW_INSPECTOR 2491glFragColor=vec4(1.0); 2492#endif 2493}`,rd),skyboxGradient:zt(`#include "_prelude_fog.fragment.glsl" 2494in 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)); 2495#ifdef FOG 2496color.rgb=fog_apply_sky_gradient(v_uv.xzy,color.rgb/color.a)*color.a; 2497#endif 2498color*=u_opacity;glFragColor=color; 2499#ifdef OVERDRAW_INSPECTOR 2500glFragColor=vec4(1.0); 2501#endif 2502}`,rd),skyboxCapture:zt
vendor: 3,792 bytes, lines 2502-2513
2502(` 2503in 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; 2504#define BETA_R vec3(5.5e-6,13.0e-6,22.4e-6) 2505#define BETA_M vec3(21e-6,21e-6,21e-6) 2506#define MIE_G 0.76 2507#define DENSITY_HEIGHT_SCALE_R 8000.0 2508#define DENSITY_HEIGHT_SCALE_M 1200.0 2509#define PLANET_RADIUS 6360e3 2510#define ATMOSPHERE_RADIUS 6420e3 2511#define SAMPLE_STEPS 10 2512#define DENSITY_STEPS 4 2513float ray_sphere_exit(vec3 orig,vec3 dir,float radius) {float a=dot(dir,dir);float b=2.0*dot(dir,orig);float c=dot(orig,orig)-radius*radius;float d=sqrt(b*b-4.0*a*c);return (-b+d)/(2.0*a);}vec3 extinction(vec2 density) {return exp(-vec3(BETA_R*u_color_tint_r.a*density.x+BETA_M*u_color_tint_m.a*density.y));}vec2 local_density(vec3 point) {float height=max(length(point)-PLANET_RADIUS,0.0);float exp_r=exp(-height/DENSITY_HEIGHT_SCALE_R);float exp_m=exp(-height/DENSITY_HEIGHT_SCALE_M);return vec2(exp_r,exp_m);}float phase_ray(float cos_angle) {return (3.0/(16.0*PI))*(1.0+cos_angle*cos_angle);}float phase_mie(float cos_angle) {return (3.0/(8.0*PI))*((1.0-MIE_G*MIE_G)*(1.0+cos_angle*cos_angle))/((2.0+MIE_G*MIE_G)*pow(1.0+MIE_G*MIE_G-2.0*MIE_G*cos_angle,1.5));}vec2 density_to_atmosphere(vec3 point,vec3 light_dir) {float ray_len=ray_sphere_exit(point,light_dir,ATMOSPHERE_RADIUS);float step_len=ray_len/float(DENSITY_STEPS);vec2 density_point_to_atmosphere=vec2(0.0);for (int i=0; i < DENSITY_STEPS;++i) {vec3 point_on_ray=point+light_dir*((float(i)+0.5)*step_len);density_point_to_atmosphere+=local_density(point_on_ray)*step_len;;}return density_point_to_atmosphere;}vec3 atmosphere(vec3 ray_dir,vec3 sun_direction,float sun_intensity) {vec2 density_orig_to_point=vec2(0.0);vec3 scatter_r=vec3(0.0);vec3 scatter_m=vec3(0.0);vec3 origin=vec3(0.0,PLANET_RADIUS,0.0);float ray_len=ray_sphere_exit(origin,ray_dir,ATMOSPHERE_RADIUS);float step_len=ray_len/float(SAMPLE_STEPS);for (int i=0; i < SAMPLE_STEPS;++i) {vec3 point_on_ray=origin+ray_dir*((float(i)+0.5)*step_len);vec2 density=local_density(point_on_ray)*step_len;density_orig_to_point+=density;vec2 density_point_to_atmosphere=density_to_atmosphere(point_on_ray,sun_direction);vec2 density_orig_to_atmosphere=density_orig_to_point+density_point_to_atmosphere;vec3 extinction=extinction(density_orig_to_atmosphere);scatter_r+=density.x*extinction;scatter_m+=density.y*extinction;}float cos_angle=dot(ray_dir,sun_direction);float phase_r=phase_ray(cos_angle);float phase_m=phase_mie(cos_angle);vec3 beta_r=BETA_R*u_color_tint_r.rgb*u_color_tint_r.a;vec3 beta_m=BETA_M*u_color_tint_m.rgb*u_color_tint_m.a;return (scatter_r*phase_r*beta_r+scatter_m*phase_m*beta_m)*sun_intensity;}const float A=0.15;const float B=0.50;const float C=0.10;const float D=0.20;const float E=0.02;const float F=0.30;vec3 uncharted2_tonemap(vec3 x) {return ((x*(A*x+C*B)+D*E)/(x*(A*x+B)+D*F))-E/F;}void main() {vec3 ray_direction=v_position;ray_direction.y=pow(ray_direction.y,5.0);const float y_bias=0.015;ray_direction.y+=y_bias;vec3 color=atmosphere(normalize(ray_direction),u_sun_direction,u_sun_intensity);float white_scale=1.0748724675633854;color=uncharted2_tonemap((log2(2.0/pow(u_luminance,4.0)))*color)*white_scale;glFragColor=vec4(color,1.0);}`,"in highp vec3 a_pos_3f;uniform mat3 u_matrix_3f;out highp vec3 v_position;float map(float value,float start,float end,float new_start,float new_end) {return ((value-start)*(new_end-new_start))/(end-start)+new_start;}void main() {vec4 pos=vec4(u_matrix_3f*a_pos_3f,1.0);v_position=pos.xyz;v_position.y*=-1.0;v_position.y=map(v_position.y,-1.0,1.0,0.0,1.0);gl_Position=vec4(a_pos_3f.xy,0.0,1.0);}"),globe
2513Raster:zt(`#include "_prelude_fog.fragment.glsl" 2514#include "_prelude_lighting.glsl" 2515uniform sampler2D u_image0; 2516#ifdef LIGHTING_3D_ALPHA_EMISSIVENESS 2517uniform sampler2D u_image1;uniform float u_emissive_texture_available; 2518#endif 2519uniform float u_far_z_cutoff;in vec2 v_pos0; 2520#ifndef FOG 2521uniform 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; 2522#endif 2523void main() {vec4 color; 2524#ifdef CUSTOM_ANTIALIASING 2525highp vec2 uv=gl_FragCoord.xy/u_viewport; 2526#ifdef FLIP_Y 2527uv.y=1.0-uv.y; 2528#endif 2529highp vec3 ray_dir=mix( 2530mix(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); 2531#ifdef LIGHTING_3D_MODE 2532#ifdef LIGHTING_3D_ALPHA_EMISSIVENESS 2533float emissive_strength=u_emissive_texture_available > 0.5 ? texture(u_image1,v_pos0).r : raster.a;raster=apply_lighting_with_emission_ground(raster,emissive_strength);color=vec4(clamp(raster.rgb,vec3(0),vec3(1))*antialias,antialias); 2534#else 2535raster=apply_lighting_ground(raster);color=vec4(raster.rgb*antialias,raster.a*antialias); 2536#endif 2537#else 2538color=vec4(raster.rgb*antialias,raster.a*antialias); 2539#endif 2540#else 2541color=texture(u_image0,v_pos0); 2542#ifdef LIGHTING_3D_MODE 2543#ifdef LIGHTING_3D_ALPHA_EMISSIVENESS 2544float emissive_strength=u_emissive_texture_available > 0.5 ? texture(u_image1,v_pos0).r : color.a;color=apply_lighting_with_emission_ground(color,emissive_strength);color.a=1.0; 2545#else 2546color=apply_lighting_ground(color); 2547#endif 2548#endif 2549#endif 2550#ifdef FOG 2551color=fog_dither(fog_apply_premultiplied(color,v_fog_pos)); 2552#endif 2553color*=1.0-step(u_far_z_cutoff,1.0/gl_FragCoord.w);glFragColor=color; 2554#ifdef OVERDRAW_INSPECTOR 2555glFragColor=vec4(1.0); 2556#endif 2557HANDLE_WIREFRAME_DEBUG;}`,`#include "_prelude_fog.vertex.glsl" 2558#include "_prelude_terrain.vertex.glsl" 2559uniform 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; 2560#ifdef GLOBE_POLES 2561in vec3 a_globe_pos;in vec2 a_uv; 2562#else 2563in ivec2 a_pos; 2564#endif 2565out vec2 v_pos0;void main() { 2566#ifdef GLOBE_POLES 2567vec3 globe_pos=a_globe_pos;vec2 uv=a_uv; 2568#else 2569float 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); 2570#endif 2571v_pos0=uv;vec2 tile_pos=uv*EXTENT;vec3 globe_derived_up_vector=normalize(globe_pos)*u_tile_up_scale; 2572#ifdef GLOBE_POLES 2573vec3 up_vector=globe_derived_up_vector; 2574#else 2575vec3 up_vector=elevationVector(tile_pos); 2576#endif 2577float height=elevation(tile_pos);globe_pos+=up_vector*height; 2578#ifndef GLOBE_POLES 2579globe_pos-=globe_derived_up_vector*u_skirt_height*decomposed_pos_and_skirt.z; 2580#endif 2581#ifdef GLOBE_POLES 2582vec4 interpolated_pos=u_globe_matrix*vec4(globe_pos,1.0); 2583#else 2584vec4 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); 2585#endif 2586gl_Position=u_proj_matrix*interpolated_pos; 2587#ifdef FOG 2588v_fog_pos=fog_position((u_normalize_matrix*vec4(globe_pos,1.0)).xyz); 2589#endif 2590}`),globeAtmosphere:zt(`#include "_prelude_fog.fragment.glsl" 2591uniform 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; 2592#ifdef PROJECTION_GLOBE_VIEW 2593globe_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) { 2594#ifdef ALPHA_PASS 2595glFragColor=vec4(0,0,0,0);return; 2596#else 2597#ifdef NATIVE 2598glFragColor=vec4(1,1,1,1); 2599#else 2600glFragColor=vec4(0,0,0,1); 2601#endif 2602return; 2603#endif 2604} 2605#endif 2606highp vec3 horizon_dir=normalize(v_horizon_dir);float horizon_angle_mercator=dir.y < horizon_dir.y ? 26070.0 : max(acos(clamp(dot(dir,horizon_dir),-1.0,1.0)),0.0);float horizon_angle; 2608#ifdef PROJECTION_GLOBE_VIEW 2609highp 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 ? 2610PI-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); 2611#else 2612horizon_angle=horizon_angle_mercator; 2613#endif 2614horizon_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;
2614vec3 color_stop_2=u_space_color.rgb; 2615#ifdef ALPHA_PASS 2616float 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); 2617#else 2618vec3 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); 2619#endif 2620}`,`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( 2621mix(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( 2622mix(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:zt(`#include "_prelude_fog.fragment.glsl" 2623#include "_prelude_shadow.fragment.glsl" 2624#include "_prelude_lighting.glsl" 2625uniform float u_opacity; 2626#ifdef DITHERED_DISCARD 2627uniform float u_dithered_discard_threshold; 2628#endif 2629uniform 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; 2630#ifdef RENDER_SHADOWS 2631in highp vec4 v_pos_light_view_0;in highp vec4 v_pos_light_view_1;in float v_depth_shadows; 2632#endif 2633#ifdef OCCLUSION_TEXTURE_TRANSFORM 2634uniform vec4 u_occlusionTextureTransform; 2635#endif 2636#pragma mapbox: define-attribute highp vec3 normal_3f 2637#pragma mapbox: define-attribute highp vec3 color_3f 2638#pragma mapbox: define-attribute highp vec4 color_4f 2639#pragma mapbox: define-attribute highp vec2 uv_2f 2640#pragma mapbox: initialize-attribute highp vec3 normal_3f 2641#pragma mapbox: initialize-attribute highp vec3 color_3f 2642#pragma mapbox: initialize-attribute highp vec4 color_4f 2643#pragma mapbox: initialize-attribute highp vec2 uv_2f 2644#ifdef HAS_ATTRIBUTE_a_pbr 2645in lowp vec4 v_roughness_metallic_emissive_alpha;in mediump vec4 v_height_based_emission_params; 2646#endif 2647#ifdef HAS_TEXTURE_u_baseColorTexture 2648uniform sampler2D u_baseColorTexture;uniform bool u_baseTextureIsAlpha;uniform bool u_alphaMask;uniform float u_alphaCutoff; 2649#endif 2650#ifdef HAS_TEXTURE_u_metallicRoughnessTexture 2651uniform sampler2D u_metallicRoughnessTexture; 2652#endif 2653#ifdef HAS_TEXTURE_u_occlusionTexture 2654uniform sampler2D u_occlusionTexture;uniform float u_aoIntensity; 2655#endif 2656#ifdef HAS_TEXTURE_u_normalTexture 2657uniform sampler2D u_normalTexture; 2658#endif 2659#ifdef HAS_TEXTURE_u_emissionTexture 2660uniform sampler2D u_emissionTexture; 2661#endif 2662#ifdef APPLY_LUT_ON_GPU 2663uniform highp sampler3D u_lutTexture; 2664#endif 2665#ifdef TERRAIN_FRAGMENT_OCCLUSION 2666in highp float v_depth;uniform highp sampler2D u_depthTexture;uniform highp vec2 u_inv_depth_size;uniform highp vec2 u_depth_range_unpack; 2667#ifdef DEPTH_D24 2668highp float unpack_depth(highp float depth) {return depth*u_depth_range_unpack.x+u_depth_range_unpack.y;} 2669#else 2670highp float unpack_depth_rgba(highp vec4 rgba_depth) 2671{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;} 2672#endif 2673bool isOccluded() {highp vec2 coord=gl_FragCoord.xy*u_inv_depth_size; 2674#ifdef FLIP_Y 2675coord.y=1.0-coord.y; 2676#endif 2677#ifdef DEPTH_D24 2678highp float depth=unpack_depth(texture(u_depthTexture,coord).r); 2679#else 2680highp float depth=unpack_depth_rgba(texture(u_depthTexture,coord)); 2681#endif 2682return v_depth > depth+0.0005;} 2683#endif 2684#define saturate(_x) clamp(_x,0.,1.) 2685vec3 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) 2686{ 2687#ifdef LIGHTING_3D_MODE 2688vec3 transformed_normal=vec3(-normal.xy,normal.z);float lighting_factor; 2689#ifdef RENDER_SHADOWS 2690lighting_factor=shadowed_light_factor_normal(transformed_normal,v_pos_light_view_0,v_pos_light_view_1,v_depth_shadows); 2691#else 2692lighting_factor=saturate(dot(transformed_normal,u_lighting_directional_dir)); 2693#endif 2694return apply_lighting(albedo,transformed_normal,lighting_factor); 2695#else 2696vec3 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
2696Color),vec3(1.0));return c3; 2697#endif 2698}vec4 getBaseColor() {vec4 albedo=u_baseColorFactor; 2699#ifdef HAS_ATTRIBUTE_a_color_3f 2700albedo*=vec4(color_3f,1.0); 2701#endif 2702#ifdef HAS_ATTRIBUTE_a_pbr 2703#else 2704#ifdef HAS_ATTRIBUTE_a_color_4f 2705albedo*=color_4f; 2706#endif 2707#endif 2708#if defined (HAS_TEXTURE_u_baseColorTexture) && defined (HAS_ATTRIBUTE_a_uv_2f) 2709vec4 texColor=texture(u_baseColorTexture,uv_2f);if(u_alphaMask) {if (texColor.w < u_alphaCutoff) {discard;}} 2710#ifdef UNPREMULT_TEXTURE_IN_SHADER 2711texColor=vec4(unpremultiplyColor(texColor),1.0); 2712#endif 2713if(u_baseTextureIsAlpha) {if (texColor.r < 0.5) {discard;}} else {texColor.rgb=sRGBToLinear(texColor.rgb);albedo*=texColor;} 2714#endif 2715vec4 color=vec4(mix(albedo.rgb,v_color_mix.rgb,v_color_mix.a),albedo.a); 2716#ifdef APPLY_LUT_ON_GPU 2717color=applyLUT(u_lutTexture,color); 2718#endif 2719return color;}highp mat3 cotangentFrame(highp vec3 N,highp vec3 p,highp vec2 uv ) { 2720#ifdef HAS_TEXTURE_u_normalTexture 2721highp 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; 2722#ifdef FLIP_Y 2723T=-T;B=-B; 2724#endif 2725highp 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; 2726#else 2727return mat3(1.0); 2728#endif 2729}highp vec3 getNormal(){highp vec3 n; 2730#ifdef HAS_ATTRIBUTE_a_normal_3f 2731n=normalize(normal_3f); 2732#else 2733highp 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)); 2734#ifdef FLIP_Y 2735n=normalize(cross(fdx,fdy)); 2736#else 2737n=normalize(cross(fdx,fdy))*-1.0; 2738#endif 2739#endif 2740#if defined(HAS_TEXTURE_u_normalTexture) && defined(HAS_ATTRIBUTE_a_uv_2f) 2741vec3 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); 2742#endif 2743return 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; 2744#ifdef HAS_ATTRIBUTE_a_pbr 2745mat.perceptualRoughness=v_roughness_metallic_emissive_alpha.x;mat.metallic=v_roughness_metallic_emissive_alpha.y;mat.baseColor.w*=v_roughness_metallic_emissive_alpha.w; 2746#endif 2747#if defined(HAS_TEXTURE_u_metallicRoughnessTexture) && defined(HAS_ATTRIBUTE_a_uv_2f) 2748vec4 mrSample=texture(u_metallicRoughnessTexture,uv_2f);mat.perceptualRoughness*=mrSample.g;mat.metallic*=mrSample.b; 2749#endif 2750const 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) 2751{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) 2752{return specularColor+(f90-specularColor)*pow(clamp(1.0-VdotH,0.0,1.0),5.0);}vec3 F_SchlickFast(vec3 specularColor,float VdotH) 2753{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) 2754{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) 2755{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) 2756{ 2757#ifdef LIGHTING_3D_MODE 2758return mat.diffuseColor; 2759#else 2760return mat.diffuseColor/PI; 2761#endif 2762}vec3 EnvBRDFApprox(vec3 specularColor,float roughness,highp float NdotV) 2763{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) 2764{vec3 env_light=vec3(0.65,0.65,0.65); 2765#ifdef LIGHTING_3D_MODE 2766float ambient_factor=calculate_ambient_directional_factor(normal);env_light=u_lighting_ambient_color*ambient_factor; 2767#endif 2768vec3 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) 2769{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; 2770#ifdef RENDER_SHADOWS 2771lighting_factor=shadowed_light_factor_normal(transformed_normal,v_pos_light_view_0,v_pos_light_view_1,v_depth_shadows); 2772#else 2773lighting_factor=NdotL; 2774#endif 2775vec3 directLightColor=(specularTerm+diffuseTerm)*lighting_factor*light
2775Color;vec3 indirectLightColor=computeIndirectLightContribution(mat,NdotV,transformed_normal);vec3 color=(saturate(directLightColor)+indirectLightColor);float intensityFactor=1.0; 2776#if !defined(LIGHTING_3D_MODE) 2777const 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); 2778#endif 2779color*=intensityFactor;return color;}void main() { 2780#ifdef TERRAIN_FRAGMENT_OCCLUSION 2781if (isOccluded()) {discard;} 2782#endif 2783vec3 lightDir=u_lightpos;vec3 lightColor=u_lightcolor; 2784#ifdef LIGHTING_3D_MODE 2785lightDir=u_lighting_directional_dir;lightDir.xy=-lightDir.xy;lightColor=u_lighting_directional_color; 2786#endif 2787vec4 finalColor; 2788#ifdef DIFFUSE_SHADED 2789vec3 N=getNormal();vec3 baseColor=getBaseColor().rgb;vec3 diffuse=getDiffuseShadedColor(baseColor,N,lightDir,lightColor); 2790#ifdef HAS_TEXTURE_u_occlusionTexture 2791float ao=(texture(u_occlusionTexture,uv_2f).r-1.0)*u_aoIntensity+1.0;diffuse*=ao; 2792#endif 2793finalColor=vec4(mix(diffuse,baseColor,u_emissive_strength),1.0)*u_opacity; 2794#else 2795Material mat=getPBRMaterial();vec3 color=computeLightContribution(mat,lightDir,lightColor);float ao=1.0; 2796#if defined (HAS_TEXTURE_u_occlusionTexture) && defined(HAS_ATTRIBUTE_a_uv_2f) 2797#ifdef OCCLUSION_TEXTURE_TRANSFORM 2798vec2 uv=uv_2f.xy*u_occlusionTextureTransform.zw+u_occlusionTextureTransform.xy; 2799#else 2800vec2 uv=uv_2f; 2801#endif 2802ao=(texture(u_occlusionTexture,uv).x-1.0)*u_aoIntensity+1.0;color*=ao; 2803#endif 2804vec4 emissive=u_emissiveFactor; 2805#if defined(HAS_TEXTURE_u_emissionTexture) && defined(HAS_ATTRIBUTE_a_uv_2f) 2806emissive.rgb*=sRGBToLinear(texture(u_emissionTexture,uv_2f).rgb); 2807#endif 2808#ifdef APPLY_LUT_ON_GPU 2809float emissiveFactorLength=max(length(u_emissiveFactor.rgb),0.001);emissive.rgb=sRGBToLinear(applyLUT(u_lutTexture,linearTosRGB(emissive.rgb/emissiveFactorLength).rbg))*emissiveFactorLength; 2810#endif 2811color+=emissive.rgb;float opacity=mat.baseColor.w*u_opacity; 2812#ifdef HAS_ATTRIBUTE_a_pbr 2813float 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; 2814#ifdef APPLY_LUT_ON_GPU 2815color_mix=applyLUT(u_lutTexture,color_mix); 2816#endif 2817color=mix(color,color_mix,min(1.0,resEmission)); 2818#ifdef HAS_ATTRIBUTE_a_color_4f 2819float distance=length(vec2(1.3*max(0.0,abs(color_4f.x)-color_4f.z),color_4f.
2819y));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); 2820#endif 2821#endif 2822vec3 unlitColor=mat.baseColor.rgb*ao+emissive.rgb;color=mix(color,unlitColor,u_emissive_strength);color=linearTosRGB(color);color*=opacity;finalColor=vec4(color,opacity); 2823#endif 2824#ifdef DITHERED_DISCARD 2825if (abs(u_dithered_discard_threshold) < 1.0) {float ditherValue=fract(52.9829189*fract(0.06711056*gl_FragCoord.x+0.00583715*gl_FragCoord.y));float compareValue=mix(1.0-ditherValue,ditherValue,step(0.0,u_dithered_discard_threshold));if (abs(u_dithered_discard_threshold) < compareValue) {discard;}} 2826#endif 2827#ifdef FOG 2828finalColor=fog_dither(fog_apply_premultiplied(finalColor,v_fog_pos,v_position_height.w)); 2829#endif 2830#ifdef RENDER_CUTOFF 2831finalColor*=v_cutoff_opacity; 2832#endif 2833#ifdef INDICATOR_CUTOUT 2834finalColor=applyCutout(finalColor,v_position_height.w); 2835#endif 2836#ifdef FEATURE_CUTOUT 2837finalColor=apply_feature_cutout(finalColor,gl_FragCoord,get_cutout_factors(gl_FragCoord).x); 2838#endif 2839glFragColor=finalColor; 2840#ifdef OVERDRAW_INSPECTOR 2841glFragColor=vec4(1.0); 2842#endif 2843HANDLE_WIREFRAME_DEBUG;}`,`#include "_prelude_fog.vertex.glsl" 2844#include "_prelude_shadow.vertex.glsl" 2845in vec3 a_pos_3f; 2846#pragma mapbox: define-attribute highp vec3 normal_3f 2847#pragma mapbox: define-attribute highp vec2 uv_2f 2848#pragma mapbox: define-attribute highp vec3 color_3f 2849#pragma mapbox: define-attribute highp vec4 color_4f 2850#pragma mapbox: define-attribute-vertex-shader-only highp uvec4 pbr 2851#pragma mapbox: define-attribute-vertex-shader-only highp vec3 heightBasedEmissiveStrength 2852uniform mat4 u_matrix;uniform mat4 u_node_matrix;uniform mat4 u_lighting_matrix;uniform vec3 u_camera_pos;uniform vec4 u_color_mix; 2853#ifdef INSTANCED_ARRAYS 2854in vec4 a_normal_matrix0;in vec4 a_normal_matrix1;in vec4 a_normal_matrix2;in vec4 a_normal_matrix3; 2855#else 2856uniform highp mat4 u_normal_matrix; 2857#endif 2858#ifdef RENDER_SHADOWS 2859uniform 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; 2860#endif 2861out vec4 v_position_height;out lowp vec4 v_color_mix; 2862#ifdef TERRAIN_FRAGMENT_OCCLUSION 2863out highp float v_depth; 2864#endif 2865#ifdef HAS_ATTRIBUTE_a_pbr 2866out lowp vec4 v_roughness_metallic_emissive_alpha;out mediump vec4 v_height_based_emission_params; 2867#endif 2868vec3 sRGBToLinear(vec3 srgbIn) {return pow(srgbIn,vec3(2.2));}void main() { 2869#pragma mapbox: initialize-attribute highp vec3 normal_3f 2870#pragma mapbox: initialize-attribute highp vec2 uv_2f 2871#pragma mapbox: initialize-attribute highp vec3 color_3f 2872#pragma mapbox: initialize-attribute highp vec4 color_4f 2873#pragma mapbox: initialize-attribute-custom highp uvec4 pbr 2874#pragma mapbox: initialize-attribute-custom highp vec3 heightBasedEmissiveStrength 2875highp mat4 normal_matrix; 2876#ifdef INSTANCED_ARRAYS 2877normal_matrix=mat4(a_normal_matrix0,a_normal_matrix1,a_normal_matrix2,a_normal_matrix3); 2878#else 2879normal_matrix=u_normal_matrix; 2880#endif 2881vec3 local_pos;mat3 rs; 2882#ifdef MODEL_POSITION_ON_GPU 2883vec3 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; 2884#else 2885local_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); 2886#endif 2887v_position_height.w=a_pos_3f.z; 2888#ifdef HAS_ATTRIBUTE_a_pbr 2889vec4 albedo_c=decode_color(vec2(pbr.xy));vec2 e_r_m=unpack_float(float(pbr.z));vec2 r_m= unpack_float(e_r_m.y*16.0);r_m.r=r_m.r*16.0;v_color_mix=vec4(albedo_c.rgb,1.0);v_roughness_metallic_emissive_alpha=vec4(vec3(r_m,e_r_m.x)/255.0,albedo_c.a);v_roughness_metallic_emissive_alpha.z*=2.0;float heightBasedRelativeIntepolation=a_pos_3f.z*heightBasedEmissiveStrength.x+heightBasedEmissiveStrength.y;v_height_based_emission_params.x=heightBasedRelativeIntepolation;v_height_based_emission_params.y=heightBasedEmissiveStrength.z;vec2 emissionMultiplierValues=unpack_float(float(pbr.w))/256.0;v_height_based_emission_params.z=emissionMultiplierValues.x;v_height_based_emission_params.w=emissionMultiplierValues.y-emissionMultiplierValues.x; 2890#endif 2891#ifdef FOG 2892v_fog_pos=fog_position(local_pos); 2893#endif 2894#ifdef RENDER_CUTOFF 2895v_cutoff_opacity=cutoff_opacity(u_cutoff_params,gl_Position.z); 2896#endif 2897#ifdef TERRAIN_FRAGMENT_OCCLUSION 2898v_depth=gl_Position.z/gl_Position.w; 2899#ifdef CLIP_ZERO_TO_ONE 2900v_depth=-1.0+2.0*v_depth; 2901#endif 2902#endif 2903#ifdef HAS_ATTRIBUTE_a_normal_3f 2904#ifdef MODEL_POSITION_ON_GPU 2905float 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); 2906#else
2907normal_3f=vec3(normal_matrix*vec4(normal_3f,0)); 2908#endif 2909#endif 2910#ifdef HAS_ATTRIBUTE_a_pbr 2911#ifdef HAS_ATTRIBUTE_a_color_4f 2912v_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); 2913#endif 2914#endif 2915#ifdef RENDER_SHADOWS 2916vec4 shadow_pos=u_node_matrix*vec4(local_pos,1.0); 2917#ifdef NORMAL_OFFSET 2918#ifdef HAS_ATTRIBUTE_a_normal_3f 2919#ifdef MODEL_POSITION_ON_GPU 2920vec3 offset=shadow_normal_offset(vec3(-normal_3f.xy,normal_3f.z));shadow_pos.xyz+=offset*shadow_normal_offset_multiplier0(); 2921#else 2922vec3 offset=shadow_normal_offset_model(normal_3f);shadow_pos.xyz+=offset*shadow_normal_offset_multiplier0(); 2923#endif 2924#endif 2925#endif 2926v_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; 2927#endif 2928}`),modelDepth:zt("void main() {}",`in vec3 a_pos_3f;uniform mat4 u_matrix; 2929#ifdef MODEL_POSITION_ON_GPU 2930#ifdef INSTANCED_ARRAYS 2931in vec4 a_normal_matrix0;in vec4 a_normal_matrix1;in vec4 a_normal_matrix2;in vec4 a_normal_matrix3; 2932#else 2933uniform highp mat4 u_instance; 2934#endif 2935uniform highp mat4 u_node_matrix; 2936#endif 2937void main() { 2938#ifdef MODEL_POSITION_ON_GPU 2939highp mat4 instance; 2940#ifdef INSTANCED_ARRAYS 2941instance=mat4(a_normal_matrix0,a_normal_matrix1,a_normal_matrix2,a_normal_matrix3); 2942#else 2943instance=u_instance; 2944#endif 2945vec3 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;
2945rs[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); 2946#else 2947gl_Position=u_matrix*vec4(a_pos_3f,1); 2948#endif 2949}`),stars:zt(`in highp vec2 v_uv;in mediump float v_intensity;float shapeCircle(in vec2 uv) 2950{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;}`,` 2951in vec3 a_pos_3f;in vec2 a_uv;in float a_size_scale;in float a_opacity;uniform mat4 u_matrix;uniform vec3 u_up;uniform vec3 u_right;uniform float u_intensity_multiplier;out highp vec2 v_uv;out mediump float v_intensity;void main() {v_uv=a_uv;v_intensity=a_opacity*u_intensity_multiplier;vec3 pos=a_pos_3f;pos+=a_uv.x*u_right*a_size_scale;pos+=a_uv.y*u_up*a_size_scale;gl_Position=u_matrix*vec4(pos,1.0);}`),occlusion:zt("uniform vec4 u_color;void main() {glFragColor=u_color;}",`#include "_prelude_terrain.vertex.glsl" 2952in 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; 2953#ifdef TERRAIN 2954float e=elevation(world_pos.xy);world_pos.z+=e; 2955#endif 2956vec4 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 Ds(a,t){let o=a.split(` 2957`);for(let c of o){if(c=c.trimStart(),c[0]!=="#"||!c.includes("if")||c.startsWith("#endif"))continue;let d=c.match(ld);if(d)for(let m of d)If.has(m)||t.add(m)}}function ju(a){return new Set(["uint","int","uvec2","ivec2","uvec3","ivec3","uvec4","ivec4"]).has(a)}function zt(a,t){let o=new Set,c=[],d=[];a=a.replace(Bu,(_,y)=>(d.push(y),"")),t=t.replace(Bu,(_,y)=>(c.push(y),""));let m=new Set(Ac);Ds(a,m),Ds(t,m);for(let _ of[...c,...d])Ps[_]||(Ps[_]=new Set,Ds(Mc[_],Ps[_])),m=new Set([...m,...Ps[_]]);return{fragmentSource:a=a.replace(ku,(_,y,v,T,I)=>(o.add(I),y==="define"?` 2958#ifndef HAS_UNIFORM_u_${I} 2959${ju(T)?"flat ":""}in ${v} ${T} ${I}; 2960#else 2961uniform ${v} ${T} u_${I}; 2962#endif 2963`:y==="initialize"?` 2964#ifdef HAS_UNIFORM_u_${I} 2965 ${v} ${T} ${I} = u_${I}; 2966#endif 2967`:y==="define-attribute"?` 2968#ifdef HAS_ATTRIBUTE_a_${I} 2969 in ${v} ${T} ${I}; 2970#endif 2971`:y==="initialize-attribute"?"":void 0)),vertexSource:t=t.replace(ku,(_,y,v,T,I)=>{let P=`MATERIAL_ATTRIBUTE_OFFSET_${I}`,A=T==="float"?"vec2":T,D=`GET_ATTRIBUTE_${A}(a_${I}, materialInfo, ${P})`,L=I.includes("color")?"color":A;return y==="define-attribute-vertex-shader-only"?` 2972#ifdef HAS_ATTRIBUTE_a_${I} 2973in ${v} ${T} a_${I}; 2974#endif 2975`:o.has(I)?y==="define"?` 2976#ifndef HAS_UNIFORM_u_${I} 2977uniform lowp float u_${I}_t; 2978 #if !defined(${P}) 2979 in ${v} ${A} a_${I}; 2980 #endif 2981${ju(T)?"flat ":""}out ${v} ${T} ${I}; 2982#else 2983uniform ${v} ${T} u_${I}; 2984#endif 2985`:y==="initialize"?L==="vec4"||L==="uvec4"?` 2986#ifndef HAS_UNIFORM_u_${I} 2987 ${I} = a_${I}; 2988#else 2989 ${v} ${T} ${I} = u_${I}; 2990#endif 2991`:` 2992#if !defined(HAS_UNIFORM_u_${I}) 2993 #ifdef ${P} 2994 ${I} = unpack_mix_${L}(${D}, u_${I}_t); 2995 #else 2996 ${I} = unpack_mix_${L}(a_${I}, u_${I}_t); 2997 #endif 2998#else 2999 ${v} ${T} ${I} = u_${I}; 3000#endif 3001`:y==="define-attribute"?` 3002#ifdef HAS_ATTRIBUTE_a_${I} 3003 in ${v} ${T} a_${I}; 3004 out ${v} ${T} ${I}; 3005#endif 3006`:y==="initialize-attribute"?` 3007#ifdef HAS_ATTRIBUTE_a_${I} 3008 ${I} = a_${I}; 3009#endif 3010`:void 0:y==="define"?` 3011#ifndef HAS_UNIFORM_u_${I} 3012uniform lowp float u_${I}_t; 3013 #if !defined(${P}) 3014 in ${v} ${A} a_${I}; 3015 #endif 3016#else 3017uniform ${v} ${T} u_${I}; 3018#endif 3019`:y==="define-instanced"?L==="mat4"?` 3020#ifdef INSTANCED_ARRAYS 3021in vec4 a_${I}0; 3022in vec4 a_${I}1; 3023in vec4 a_${I}2; 3024in vec4 a_${I}3; 3025#else 3026uniform ${v} ${T} u_${I}; 3027#endif 3028`:` 3029#ifdef INSTANCED_ARRAYS 3030in ${v} ${A} a_${I}; 3031#else 3032uniform ${v} ${T} u_${I}; 3033#endif 3034`:y==="initialize-attribute-custom"?` 3035#ifdef HAS_ATTRIBUTE_a_${I} 3036 ${v} ${T} ${I} = a_${I}; 3037#endif 3038`:L==="vec4"||L==="uvec4"?` 3039#ifndef HAS_UNIFORM_u_${I} 3040 #ifdef ${P} 3041 ${v} ${T} ${I} = ${D}; 3042 #else 3043 ${v} ${T} ${I} = a_${I}; 3044 #endif 3045#else 3046 ${v} ${T} ${I} = u_${I}; 3047#endif 3048`:` 3049#ifndef HAS_UNIFORM_u_${I} 3050 #ifdef ${P} 3051 ${v} ${T} ${I} = unpack_mix_${L}(${D}, u_${I}_t); 3052 #else 3053 ${v} ${T} ${I} = unpack_mix_${L}(a_${I}, u_${I}_t); 3054 #endif 3055#else 3056 ${v} ${T} ${I} = u_${I}; 3057#endif 3058`}),usedDefines:m,vertexIncludes:c,fragmentIncludes:d}}class Gu{constructor(){this.boundProgram=null,this.boundLayoutVertexBuffer=null,this.boundPaintVertexBuffers=[],this.boundIndexBuffer=null,this.boundVertexOffset=null,this.boundDynamicVertexBuffers=[],this.vao=null}bind(t,o,c,d,m,_,y,v){this.context=t;let T=this.boundPaintVertexBuffers.length!==d.length;for(let P=0;!T&&P<d.length;P++)this.boundPaintVertexBuffers[P]!==d[P]&&(T=!0);let I=this.boundDynamicVertexBuffers.length!==y.length;for(let P=0;!I&&P<y.length;P++)this.boundDynamicVertexBuffers[P]!==y[P]&&(I=!0);if(!this.vao||this.boundProgram!==o||this.boundLayoutVertexBuffer!==c||T||I||this.boundIndexBuffer!==m||this.boundVertexOffset!==_)this.freshBind(o,c,d,m,_,y,v);else{t.bindVertexArrayOES.set(this.vao);for(let P of y)P&&(P.bind(),v&&P.instanceCount&&P.setVertexAttribDivisor(t.gl,o,v));m&&m.dynamicDraw&&m.bind()}}freshBind(t,o,c,d,m,_,y){let v=this.context,T=v.gl;this.vao&&this.destroy(),this.vao=v.gl.createVertexArray(),v.bindVertexArrayOES.set(this.vao),this.boundProgram=t,this.boundLayoutVertexBuffer=o,this.boundPaintVertexBuffers=c,this.boundIndexBuffer=d,this.boundVertexOffset=m,this.boundDynamicVertexBuffers=_,o.enableAttributes(T,t),o.bind(),o.setVertexAttribPointers(T,t,m);for(let I of c)I.enableAttributes(T,t),I.bind(),I.setVertexAttribPointers(T,t,m);for(let I of _)I&&(I.enableAttributes(T,t),I.bind(),I.setVertexAttribPointers(T,t,m),y&&I.instanceCount&&I.setVertexAttribDivisor(T,t,y));d&&d.bind()}destroy(){this.vao&&(this.context.gl.deleteVertexArray(this.vao),this.vao=null)}}function ud(a,t){let o=Math.pow(2,t.canonical.z),c=t.canonical.y;return[new h.ad(0,c/o).toLngLat().lat,new h.ad(0,(c+1)/o).toLngLat().lat]}function hd(a,t,o,c,d,m,_){let y=a.context,v=y.gl,T=o.hillshadeFBO;if(!T)return;a.prepareDrawTile();let I=a.isTileAffectedByFog(t),P=[];a.terrain&&a.terrain.renderingToTexture&&a.emissiveMode==="mrt-fallback"&&P.push("USE_MRT1");let A=a.getOrCreateProgram("hillshade",{overrideFog:I,defines:P});y.activeTexture.set(v.TEXTURE0),v.bindTexture(v.TEXTURE_2D,T.colorAttachment0.get());let D=((N,q,Z,G)=>{let re=Z.paint.get("hillshade-shadow-color"),te=Z.paint.get("hillshade-shadow-color-use-theme").
3058constantOr("default")==="none",se=Z.paint.get("hillshade-highlight-color"),K=Z.paint.get("hillshade-highlight-color-use-theme").constantOr("default")==="none",J=Z.paint.get("hillshade-accent-color"),oe=Z.paint.get("hillshade-accent-color-use-theme").constantOr("default")==="none",ue=Z.paint.get("hillshade-emissive-strength"),de=h.am(Z.paint.get("hillshade-illumination-direction"));if(Z.paint.get("hillshade-illumination-anchor")==="viewport")de-=N.transform.angle;else if(N.style&&N.style.enable3dLights()&&N.style.directionalLight){let ve=N.style.directionalLight.properties.get("direction"),Fe=h.cT(ve.x,ve.y,ve.z);de=h.am(Fe[1])}let be=!N.options.moving;return{u_matrix:G||N.transform.calculateProjMatrix(q.tileID.toUnwrapped(),be),u_image:0,u_latrange:ud(0,q.tileID),u_light:[Z.paint.get("hillshade-exaggeration"),de],u_shadow:re.toPremultipliedRenderColor(te?null:Z.lut),u_highlight:se.toPremultipliedRenderColor(K?null:Z.lut),u_emissive_strength:ue,u_accent:J.toPremultipliedRenderColor(oe?null:Z.lut)}})(a,o,c,a.terrain?t.projMatrix:null);a.uploadCommonUniforms(y,A,t.toUnwrapped());let{tileBoundsBuffer:L,tileBoundsIndexBuffer:O,tileBoundsSegments:k}=a.getTileBoundsBuffers(o);A.draw(a,v.TRIANGLES,d,m,_,dt.disabled,D,c.id,L,O,k)}function Cc(a,t,o){if(!t.needsDEMTextureUpload)return;let c=a.context,d=c.gl;c.pixelStoreUnpackPremultiplyAlpha.set(!1),t.demTexture=t.demTexture||a.getTileTexture(o.stride);let m=o.getPixels();t.demTexture?t.demTexture.update(m,{premultiply:!1}):t.demTexture=new h.T(c,m,d.R32F,{premultiply:!1}),t.needsDEMTextureUpload=!1}function dd(a,t,o){let c=a.context,d=c.gl;if(!t.dem)return;let m=t.dem;if(c.activeTexture.set(d.TEXTURE1),Cc(a,t,m),!t.demTexture)return;t.demTexture.bind(d.NEAREST,d.CLAMP_TO_EDGE);let _=m.dim;c.activeTexture.set(d.TEXTURE0);let y=t.hillshadeFBO;if(!y){let A=new h.T(c,{width:_,height:_,data:null},d.RGBA8);A.bind(d.LINEAR,d.CLAMP_TO_EDGE),y=t.hillshadeFBO=c.createFramebuffer(_,_,1,"renderbuffer"),y.colorAttachment0.set(A.texture)}c.bindFramebuffer.set(y.framebuffer),c.viewport.set([0,0,_,_]);let{tileBoundsBuffer:v,tileBoundsIndexBuffer:T,tileBoundsSegments:I}=a.getMercatorTileBoundsBuffers(),P=[];a.linearFloatFilteringSupported()&&P.push("TERRAIN_DEM_FLOAT_FORMAT"),a.terrain&&a.terrain.renderingToTexture&&a.emissiveMode==="mrt-fallback"&&P.push("USE_MRT1"),a.getOrCreateProgram("hillshadePrepare",{defines:P}).draw(a,d.TRIANGLES,nt.disabled,gt.disabled,mt.unblended,dt.disabled,((A,D)=>{let L=D.stride,O=h.bd();return h.bX(O,0,h.ak,-h.ak,0,0,1),h.bB(O,O,[0,-h.ak,0]),{u_matrix:O,u_image:1,u_dimension:[L,L],u_zoom:A.overscaledZ}})(t.tileID,m),o.id,v,T,I),t.needsHillshadePrepare=!1}class Ti{constructor(t){this.gl=t.gl,this.default=this.getDefault(),this.current=this.default,this.dirty=!1}get(){return this.current}set(t){}getDefault(){return this.default}setDefault(){this.set(this.default)}}class Ef extends Ti{getDefault(){return h.C.transparent.toNonPremultipliedRenderColor(null)}set(t){let o=this.current;(t.r!==o.r||t.g!==o.g||t.b!==o.b||t.a!==o.a||this.dirty)&&(this.gl.clearColor(t.r,t.g,t.b,t.a),this.current=t,this.dirty=!1)}}class xl extends Ti{getDefault(){return 1}set(t){(t!==this.current||this.dirty)&&(this.gl.clearDepth(t),this.current=t,this.dirty=!1)}}class W_ extends Ti{getDefault(){return 0}set(t){(t!==this.current||this.dirty)&&(this.gl.clearStencil(t),this.current=t,this.dirty=!1)}}class X_ extends Ti{getDefault(){return[!0,!0,!0,!0]}set(t){let o=this.current;(t[0]!==o[0]||t[1]!==o[1]||t[2]!==o[2]||t[3]!==o[3]||this.dirty)&&(this.gl.colorMask(t[0],t[1],t[2],t[3]),this.current=t,this.dirty=!1)}}class Y_ extends Ti{getDefault(){return!0}set(t){(t!==this.current||this.dirty)&&(this.gl.depthMask(t),this.current=t,this.dirty=!1)}}class J_ extends Ti{getDefault(){return 255}set(t){(t!==this.current||this.dirty)&&(this.gl.stencilMask(t),this.current=t,this.dirty=!1)}}class K_ extends Ti{getDefault(){return{func:this.gl.ALWAYS,ref:0,mask:255}}set(t){let o=this.current;(t.func!==o.func||t.ref!==o.ref||t.mask!==o.mask||this.dirty)&&(this.gl.stencilFunc(t.func,t.ref,t.mask),this.current=t,this.dirty=!1)}}class Q_ extends Ti{getDefault(){let t=this.gl;return[t.KEEP,t.KEEP,t.KEEP]}set(t){let o=this.current;(t[0]!==o[0]||t[1]!==o[1]||t[2]!==o[2]||this.dirty)&&(this.gl.stencilOp(t[0],t[1],t[2]),this.current=t,this.dirty=!1)}}class pd extends Ti{getDefault(){return!1}set(t){if(t===this.current&&!this.dirty)return;let o=this.gl;t?o.enable(o.STENCIL_TEST):o.disable(o.STENCIL_TEST),this.current=t,this.dirty=!1}}class fd extends Ti{getDefault(){return[0,1]}set(t){let o=this.current;(t[0]!==o[0]||t[1]!==o[1]||this.dirty)&&(this.gl.depthRange(t[0],t[1]),this.current=t,this.dirty=!1)}}class md extends Ti{getDefault(){return!1}set(t){if(t===this.current&&!this.dirty)return;let o=this.gl;t?o.enable(o.DEPTH_TEST):o.disable(o.DEPTH_TEST),this.current=t,this.dirty=!1}}class vl extends Ti{getDefault(){return this.gl.LESS}set(t){(t!==this.current||this.dirty)&&(this.gl.depthFunc(t),this.current=t,this.dirty=!1)}}class Af extends Ti{getDefault(){return!1}set(t){if(t===this.current&&!this.dirty)return;let o=this.gl;t?o.enable(o.BLEND):o.disable(o.BLEND),this.current=t,this.dirty=!1}}class Mf extends Ti{getDefault(){let t=this.gl;return[t.ONE,t.ZERO,t.ONE,t.ZERO]}set(t){let o=this.current;(t[0]!==o[0]||t[1]!==o[1]||t[2]!==o[2]||t[3]!==o[3]||this.dirty)&&(this.gl.blendFuncSeparate(t[0],t[1],t[2],t[3]),this.current=t,this.dirty=!1)}}class Cf extends Ti{getDefault(){return h.C.transparent.toNonPremultipliedRenderColor(null)}set(t){let o=this.current;(t.r!==o.r||t.g!==o.g||t.b!==o.b||t.a!==o.a||this.dirty)&&(this.gl.blendColor
vendor: 4,746 bytes, line 3058
3058(t.r,t.g,t.b,t.a),this.current=t,this.dirty=!1)}}class _d extends Ti{getDefault(){return this.gl.FUNC_ADD}set(t){(t!==this.current||this.dirty)&&(this.gl.blendEquationSeparate(t,t),this.current=t,this.dirty=!1)}}class Rs extends Ti{getDefault(){return!1}set(t){if(t===this.current&&!this.dirty)return;let o=this.gl;t?o.enable(o.CULL_FACE):o.disable(o.CULL_FACE),this.current=t,this.dirty=!1}}class $u extends Ti{getDefault(){return this.gl.BACK}set(t){(t!==this.current||this.dirty)&&(this.gl.cullFace(t),this.current=t,this.dirty=!1)}}class Hu extends Ti{getDefault(){return this.gl.CCW}set(t){(t!==this.current||this.dirty)&&(this.gl.frontFace(t),this.current=t,this.dirty=!1)}}let Pf=class extends Ti{getDefault(){return null}set(a){(a!==this.current||this.dirty)&&(this.gl.useProgram(a),this.current=a,this.dirty=!1)}};class zs extends Ti{getDefault(){return this.gl.TEXTURE0}set(t){(t!==this.current||this.dirty)&&(this.gl.activeTexture(t),this.current=t,this.dirty=!1)}}class gd extends Ti{getDefault(){let t=this.gl;return[0,0,t.drawingBufferWidth,t.drawingBufferHeight]}set(t){let o=this.current;(t[0]!==o[0]||t[1]!==o[1]||t[2]!==o[2]||t[3]!==o[3]||this.dirty)&&(this.gl.viewport(t[0],t[1],t[2],t[3]),this.current=t,this.dirty=!1)}}class qu extends Ti{getDefault(){return null}set(t){if(t===this.current&&!this.dirty)return;let o=this.gl;o.bindFramebuffer(o.FRAMEBUFFER,t),this.current=t,this.dirty=!1}}class Df extends Ti{getDefault(){return null}set(t){if(t===this.current&&!this.dirty)return;let o=this.gl;o.bindRenderbuffer(o.RENDERBUFFER,t),this.current=t,this.dirty=!1}}class Rf extends Ti{getDefault(){return null}set(t){if(t===this.current&&!this.dirty)return;let o=this.gl;o.bindTexture(o.TEXTURE_2D,t),this.current=t,this.dirty=!1}}class yd extends Ti{getDefault(){return null}set(t){if(t===this.current&&!this.dirty)return;let o=this.gl;o.bindBuffer(o.ARRAY_BUFFER,t),this.current=t,this.dirty=!1}}class xd extends Ti{getDefault(){return null}set(t){let o=this.gl;o.bindBuffer(o.ELEMENT_ARRAY_BUFFER,t),this.current=t,this.dirty=!1}}class eg extends Ti{getDefault(){return null}set(t){this.gl&&(t!==this.current||this.dirty)&&(this.gl.bindVertexArray(t),this.current=t,this.dirty=!1)}}class zf extends Ti{getDefault(){return 4}set(t){if(t===this.current&&!this.dirty)return;let o=this.gl;o.pixelStorei(o.UNPACK_ALIGNMENT,t),this.current=t,this.dirty=!1}}class Pc extends Ti{getDefault(){return!1}set(t){if(t===this.current&&!this.dirty)return;let o=this.gl;o.pixelStorei(o.UNPACK_PREMULTIPLY_ALPHA_WEBGL,t),this.current=t,this.dirty=!1}}class tg extends Ti{getDefault(){return!1}set(t){if(t===this.current&&!this.dirty)return;let o=this.gl;o.pixelStorei(o.UNPACK_FLIP_Y_WEBGL,t),this.current=t,this.dirty=!1}}class vd extends Ti{constructor(t,o){super(t),this.context=t,this.parent=o}getDefault(){return null}}class Dc extends vd{constructor(t,o,c=0){super(t,o),this.attachmentPoint=t.gl.COLOR_ATTACHMENT0+c}setDirty(){this.dirty=!0}set(t){if(t===this.current&&!this.dirty)return;this.context.bindFramebuffer.set(this.parent);let o=this.gl;o.framebufferTexture2D(o.FRAMEBUFFER,this.attachmentPoint,o.TEXTURE_2D,t,0),this.current=t,this.dirty=!1}}class Lf extends vd{attachment(){return this.gl.DEPTH_ATTACHMENT}set(t){if(t===this.current&&!this.dirty)return;this.context.bindFramebuffer.set(this.parent);let o=this.gl;o.framebufferRenderbuffer(o.FRAMEBUFFER,this.attachment(),o.RENDERBUFFER,t),this.current=t,this.dirty=!1}}class bd extends vd{attachment(){return this.gl.DEPTH_ATTACHMENT}set(t){if(t===this.current&&!this.dirty)return;this.context.bindFramebuffer.set(this.parent);let o=this.gl;o.framebufferTexture2D(o.FRAMEBUFFER,this.attachment(),o.TEXTURE_2D,t,0),this.current=t,this.dirty=!1}}class Zu extends Lf{attachment(){return this.gl.DEPTH_STENCIL_ATTACHMENT}}let Pa=(a,t,o,c)=>({u_matrix:a,u_image0:0,u_image1:1,u_skirt_height:t,u_ground_shadow_factor:o,u_emissive_texture_available:c}),Rc=(a,t,o,c,d,m,_,y,v,T,I,P,A,D,L,O,k)=>({u_proj_matrix:Float32Array.from(a),u_globe_matrix:t,u_normalize_matrix:Float32Array.from(c),u_merc_matrix:o,u_zoom_transition:d,u_merc_center:m,u_image0:0,u_image1:1,u_frustum_tl:_,u_frustum_tr:y,u_frustum_br:v,u_frustum_bl:T,u_globe_pos:I,u_globe_radius:P,u_viewport:A,u_grid_matrix:k?Float32Array.from(k):new Float32Array(9),u_skirt_height:D,u_far_z_cutoff:L,u_emissive_texture_available:O});function bl(a,t){return a!=null&&t!=null&&!(!a.hasData()||!t.hasData())&&a.demTexture!=null&&t.demTexture!=null&&a.tileID.key!==t.tileID.key}let Da=new class{constructor(){this.operations={}}newMorphing(a,t,o,c,d){if(a in this.operations){let m=this.operations[a];m.to.tileID.key!==o.tileID.key&&(m.queued=o)}else this.operations[a]={startTime:c,phase:0,duration:d,from:t,to:o,queued:null}}
3058getMorphValuesForProxy(a){if(!(a in this.operations))return null;let t=this.operations[a];return{from:t.from,to:t.to,phase:t.phase}}update(a){for(let t in this.operations){let o=this.operations[t];for(o.phase=(a-o.startTime)/o.duration;o.phase>=1||!this._validOp(o);)if(!this._nextOp(o,a)){delete this.operations[t];break}}}_nextOp(a,t){return!!a.queued&&(a.from=a.to,a.to=a.queued,a.queued=null,a.phase=0,a.startTime=t,!0)}_validOp(a){return a.from.hasData()&&a.to.hasData()}};function zc(a,t,o){if(t===0)return 0;let c=t<1&&o===514?.25/t:1;return 6*Math.pow(1.5,22-a)*Math.max(t,1)*c}function Wu(a,t){let o=1<<a.z;return!t&&(a.x===0||a.x===o-1)||a.y===0||a.y===o-1}function Ra(a,t){if(!a.style||!a.style.enable3dLights())return;let o=a.context,c=o.gl;o.activeTexture.set(c.TEXTURE1),t?t.bind(c.LINEAR,c.CLAMP_TO_EDGE):a.emptyTexture.bind(c.LINEAR,c.CLAMP_TO_EDGE)}let wl=a=>({u_matrix:a});function Qe(a,t,o,c,d){if(d>0){let m=h.o.now(),_=(m-a.timeAdded)/d,y=t?(m-t.timeAdded)/d:-1,v=o.getSource(),T=c.coveringZoomLevel({tileSize:v.tileSize,roundZoom:v.roundZoom}),I=!t||Math.abs(t.tileID.overscaledZ-T)>Math.abs(a.tileID.overscaledZ-T),P=I&&a.refreshedUponExpiration?1:h.aB(I?_:1-y,0,1);return t?{opacity:1,mix:1-P,isFading:_<1}:{opacity:P,mix:0,isFading:_<1}}return{opacity:1,mix:0,isFading:!1}}class Of extends rn{constructor(t){let o={type:"raster-dem",maxzoom:Math.ceil(t.transform.maxZoom)},c=qh("mock-dem",o,t.style.dispatcher,t.style);super("mock-dem",c,null),c.setEventedParent(this),this._sourceLoaded=!0}_loadTile(t,o){t.state="loaded",o(null)}}class Ls extends rn{constructor(t){let o=qh("proxy",{type:"geojson",maxzoom:Math.ceil(t.transform.maxZoom)},t.style.dispatcher,t.style);super("proxy",o,null),o.setEventedParent(this),this.map=this.getSource().map=t,this.used=this._sourceLoaded=!0,this.renderCache=[],this.renderCachePool=[],this.proxyCachedFBO={}}update(t,o,c){if(t.freezeTileCoverage)return;this.transform=t;let d=t.coveringTiles({tileSize:this._source.tileSize,minzoom:this._source.minzoom,maxzoom:this._source.maxzoom,roundZoom:this._source.roundZoom,reparseOverscaled:this._source.reparseOverscaled}).reduce((m,_)=>{if(m[_.key]="",!this._tiles[_.key]){let y=new h.b3(_,this._source.tileSize*_.overscaleFactor(),t.tileZoom,void 0,void 0,this._source.worldview);y.state="loaded",this._tiles[_.key]=y}return m},{});for(let m in this._tiles)m in d||(this.freeFBO(m),this._tiles[m].unloadVectorData(),delete this._tiles[m])}freeFBO(t){let o=this.proxyCachedFBO[t];if(o!==void 0){let c=Object.values(o);this.renderCachePool.push(...c),delete this.proxyCachedFBO[t]}}deallocRenderCache(){this.renderCache.forEach(t=>t.fb.destroy()),this.renderCache=[],this.renderCachePool=[],this.proxyCachedFBO={}}}class Ko extends h.aU{constructor(t,o,c){super(t.overscaledZ,t.wrap,t.canonical.z,t.canonical.x,t.canonical.y),this.proxyTileKey=o,this.projMatrix=c}}class wd extends h.bx{constructor(t,o){super(),this.painter=t,this.terrainTileForTile={},this.prevTerrainTileForTile={};let[c,d,m]=function(){let v=new h.dE,T=new h.dF,I=131;v.reserve(17161),T.reserve(33800);let P=h.ak/128,A=h.ak+P/2,D=A+P;for(let O=-P;O<D;O+=P)for(let k=-P;k<D;k+=P){let N=k<0||k>A||O<0||O>A?24575:0,q=h.aB(Math.round(k),0,h.ak),Z=h.aB(Math.round(O),0,h.ak);v.emplaceBack(q+N,Z)}let L=(O,k)=>{let N=k*I+O;T.emplaceBack(N+1,N,N+I),T.emplaceBack(N+I,N+I+1,N+1)};for(let O=1;O<129;O++)for(let k=1;k<129;k++)L(k,O);return[0,129].forEach(O=>{for(let k=0;k<130;k++)L(k,O),L(O,k)}),[v,T,32768]}(),_=t.context;this.gridBuffer=_.createVertexBuffer(c,h.dA.members),this.gridIndexBuffer=_.createIndexBuffer(d),this.gridSegments=h.dB.simpleSegment(0,0,c.length,d.length),this.gridNoSkirtSegments=h.dB.simpleSegment(0,0,c.length,m),this.proxyCoords=[],this.proxiedCoords={},this._visibleDemTiles=[],this._drapedRenderBatches=[],this._sourceTilesOverlap={},this.proxySourceCache=new Ls(o.map),this.orthoMatrix=h.bd(),h.bX(this.orthoMatrix,this.painter.transform.projection.name==="globe"?.015:0,h.ak,0,h.ak,0,1);let y=_.gl;this._overlapStencilMode=new gt({func:y.GEQUAL,mask:255},0,255,y.KEEP,y.KEEP,y.REPLACE),this._previousZoom=t.transform.zoom,this.pool=[],this._findCoveringTileCache={},this._tilesDirty={},this.style=o,this._useVertexMorphing=!0,this._exaggeration=1,this._mockSourceCache=new Of(o.map),this._pendingGroundEffectLayers=[],this._emissiveTexture=!1,this._devtoolsFolder=null}set style(t){t.on("data",this._onStyleDataEvent.bind(this)),this._style=t,this._style.map.on("moveend",()=>{this._clearLineLayersFromRenderCache()})}update(t,o,c){if(t&&t.terrain){this._style!==t&&(this.style=t,this._evaluationZoom=void 0);let d=t.terrain.properties,m=t.terrain.drapeRenderMode===0,_=t.terrain.isZoomDependent();this._previousUpdateTimestamp=this.enabled?this._updateTimestamp:void 0,this._updateTimestamp=h.o.now();let y=t.terrain&&t.terrain.scope,v=d.get("source"),T=m?this._mockSourceCache:t.getSourceCache(v,y);if(!T)return void h.w(`Couldn't find terrain source "${v}".`);if(this.sourceCache=T,this._attenuationRange=t.terrain.getAttenuationRange(),this._exaggeration=_?this.calculateExaggeration(o):d.get("exaggeration"),!o.projection.requiresDraping&&_&&this._exaggeration===0)return void this._disable();this.enabled=!0;let I=()=>{this.sourceCache.used&&h.w(`Raster DEM source '${this.sourceCache.id}' is used both for terrain and as layer source. 3059This leads to lower resolution of hillshade. For full hillshade resolution but higher memory consumption, define another raster DEM source.`);let P=this.getScaledDemTileSize();this.sourceCache.update(o,P,!0),this.resetTileLookupCache(this.sourceCache.id)};this.sourceCache.usedForTerrain||(this.resetTileLookupCache(this.sourceCache.id),this.sourceCache.usedForTerrain=!0,I(),this._initializing=!0),I(),o.updateElevation(!0,c),this.resetTileLookupCache(this.proxySourceCache.id),this.proxySourceCache.update(o),this._emptyDEMTextureDirty=!0,this._previousZoom=
3059o.zoom}else this._disable()}calculateExaggeration(t){if(this._attenuationRange&&t.zoom>=Math.ceil(this._attenuationRange[1]))return this._style.terrain.getExaggeration(t.zoom);let o=this._previousCameraAltitude,c=t.getFreeCameraOptions().position.z/t.pixelsPerMeter*t.worldSize;this._previousCameraAltitude=c;let d=o!=null?c-o:Number.MAX_VALUE;if(Math.abs(d)<2)return this._exaggeration;let m=t.zoom,_=this._style.terrain;if(!this._previousUpdateTimestamp)return _.getExaggeration(m);let y=m-this._previousZoom,v=this._previousUpdateTimestamp,T=m;this._evaluationZoom!=null&&(T=this._evaluationZoom,Math.abs(m-T)>.5&&(y=.5*(m-T+y)),y*d<0&&(T+=y)),this._evaluationZoom=T;let I=_.getExaggeration(T),P=I===_.getExaggeration(Math.max(0,T-.1));if(P&&Math.abs(I-this._exaggeration)<.01)return I;let A=Math.min(.1,.00375*(this._updateTimestamp-v));return(P||I<.1||Math.abs(y)<1e-4)&&(A=Math.min(.2,4*A)),h.aj(this._exaggeration,I,A)}resetTileLookupCache(t){this._findCoveringTileCache[t]={}}attenuationRange(){return this._attenuationRange}getDemUpscale(){return this.proxySourceCache.getSource().tileSize/128}getScaledDemTileSize(){return this.sourceCache.getSource().tileSize/128*this.proxySourceCache.getSource().tileSize}_onStyleDataEvent(t){t.dataType==="source"&&t.coord?this._clearRenderCacheForTile(t.sourceCacheId,t.coord):t.dataType==="style"&&(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 t in this._style._mergedSourceCaches)this._style._mergedSourceCaches[t].usedForTerrain=!1}destroy(){this._disable(),this._emptyDEMTexture&&this._emptyDEMTexture.destroy(),this.pool.forEach(t=>t.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 t=2*this.proxySourceCache.getSource().tileSize;return[t,t]}set useVertexMorphing(t){this._useVertexMorphing=t}updateTileBinding(t){if(!this.enabled)return;this.prevTerrainTileForTile=this.terrainTileForTile;let o=this.proxySourceCache,c=this.painter.transform;this._initializing&&(this._initializing=c._centerAltitude===0&&this.getAtPointOrZero(h.ad.fromLngLat(c.center),-1)===-1,this._emptyDEMTextureDirty=!this._initializing);let d=this.proxyCoords=o.getIds().map(v=>{let T=o.getTileByID(v).tileID;return T.projMatrix=c.calculateProjMatrix(T.toUnwrapped()),T});(function(v,T){let I=T.transform.pointCoordinate(T.transform.getCameraPoint()),P=new h.P(I.x,I.y);v.sort((A,D)=>{if(D.overscaledZ-A.overscaledZ)return D.overscaledZ-A.overscaledZ;let L=new h.P(A.canonical.x+(1<<A.canonical.z)*A.wrap,A.canonical.y),O=new h.P(D.canonical.x+(1<<D.canonical.z)*D.wrap,D.canonical.y),k=P.mult(1<<A.canonical.z);return k.x-=.5,k.y-=.5,k.distSqr(L)-k.distSqr(O)})})(d,this.painter);let m=this.proxyToSource||{};this.proxyToSource={},d.forEach(v=>{this.proxyToSource[v.key]={}}),this.terrainTileForTile={};let _=this._style._mergedSourceCaches;for(let v in _){let T=_[v];if(!T.used||(T!==this.sourceCache&&this.resetTileLookupCache(T.id),this._setupProxiedCoordsForOrtho(T,t[v],m),T.usedForTerrain))continue;let I=t[v];(T.getSource().reparseOverscaled||T._isRasterElevatedOverTerrain)&&this._assignTerrainTiles(I)}this.proxiedCoords[o.id]=d.map(v=>new Ko(v,v.key,this.orthoMatrix)),this._assignTerrainTiles(d),this._prepareDEMTextures(),this._setupDrapedRenderBatches(),this._initFBOPool(),this._setupRenderCache(m),this.renderingToTexture=!1;let y={};this._visibleDemTiles=[];for(let v of this.proxyCoords){let T=this.terrainTileForTile[v.key];if(!T)continue;let I=T.tileID.key;I in y||(this._visibleDemTiles.push(T),y[I]=I)}}_assignTerrainTiles(t){this._initializing||t.forEach(o=>{if(this.terrainTileForTile[o.key])return;let c=this._findTileCoveringTileID(o,this.sourceCache);c&&(this.terrainTileForTile[o.key]=c)})}_prepareDEMTextures(){let t=this.painter.context,o=t.gl;for(let c in this.terrainTileForTile){let d=this.terrainTileForTile[c],m=d.dem;!m||d.demTexture&&!d.needsDEMTextureUpload||(t.activeTexture.set(o.TEXTURE1),Cc(this.painter,d,m))}}_prepareDemTileUniforms(t,o,c,d){if(!o||o.demTexture==null)return!1;let m=t.tileID.canonical,_=Math.pow(2,o.tileID.canonical.z-m.z),y=d||"";return c[`u_dem_tl${y}`]=[m.x*_%1,m.y*_%1],c[`u_dem_scale${y}`]=_,!0}
3059get emptyDEMTexture(){return!this._emptyDEMTextureDirty&&this._emptyDEMTexture?this._emptyDEMTexture:this._updateEmptyDEMTexture()}_getLoadedAreaMinimum(){if(!this.enabled)return 0;let t=0,o=this._visibleDemTiles.reduce((c,d)=>{if(!d.dem)return c;let m=d.dem.tree.minimums[0];return m>0&&t++,c+m},0);return t?o/t:0}_updateEmptyDEMTexture(){let t=this.painter.context,o=t.gl;t.activeTexture.set(o.TEXTURE2);let c=this._getLoadedAreaMinimum(),d=new h.dC({width:1,height:1},new Float32Array([c]));this._emptyDEMTextureDirty=!1;let m=this._emptyDEMTexture;return m?m.update(d,{premultiply:!1}):m=this._emptyDEMTexture=new h.T(t,d,o.R32F,{premultiply:!1}),m}setupElevationDraw(t,o,c){let d=this.painter.context,m=d.gl,_={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};_.u_exaggeration=this.exaggeration();let y=null,v=null,T=1;if(c&&c.morphing&&this._useVertexMorphing){let D=c.morphing.srcDemTile,L=c.morphing.dstDemTile;T=c.morphing.phase,D&&L&&(this._prepareDemTileUniforms(t,D,_,"_prev")&&(v=D),this._prepareDemTileUniforms(t,L,_)&&(y=L))}let I=D=>D&&D.demTexture&&this.painter.linearFloatFilteringSupported()?m.LINEAR:m.NEAREST,P=null;var A;if(this.enabled?v&&y?(P=y.demTexture,d.activeTexture.set(m.TEXTURE4),v.demTexture.bind(I(v),m.CLAMP_TO_EDGE),_.u_dem_lerp=T):(y=this.terrainTileForTile[t.tileID.key],P=this._prepareDemTileUniforms(t,y,_)?y.demTexture:this.emptyDEMTexture):P=this.emptyDEMTexture,d.activeTexture.set(m.TEXTURE2),P&&(_.u_dem_size=(A=P).size[0]===1?1:A.size[0]-2,P.bind(I(y),m.CLAMP_TO_EDGE)),this.painter.setupDepthForOcclusion(c&&c.useDepthForOcclusion,o,_),
3059c&&c.useMeterToDem&&y){let D=(1<<y.tileID.canonical.z)*h.bY(1,this.painter.transform.center.lat)*this.sourceCache.getSource().tileSize;_.u_meter_to_dem=D}if(c&&c.labelPlaneMatrixInv&&(_.u_label_plane_matrix_inv=c.labelPlaneMatrixInv),o.setTerrainUniformValues(d,_),this.painter.transform.projection.name==="globe"){let D=this.globeUniformValues(this.painter.transform,t.tileID.canonical,c&&c.useDenormalizedUpVectorScale);o.setGlobeUniformValues(d,D)}}globeUniformValues(t,o,c){let d=t.projection;return{u_tile_tl_up:d.upVector(o,0,0),u_tile_tr_up:d.upVector(o,h.ak,0),u_tile_br_up:d.upVector(o,h.ak,h.ak),u_tile_bl_up:d.upVector(o,0,h.ak),u_tile_up_scale:c?h.dD(1):d.upVectorScale(o,t.center.lat,t.worldSize).metersToTile}}renderToBackBuffer(t){let o=this.painter,c=this.painter.context;t.length!==0&&(c.bindFramebuffer.set(null),c.viewport.set([0,0,o.width,o.height]),o.gpuTimingDeferredRenderStart(),this.renderingToTexture=!1,function(d,m,_,y,v){if(d.transform.projection.name==="globe")(function(T,I,P,A,D){let L=T.context,O=L.gl,k,N,q=T.transform,Z=h.ds(T,L,q),G=(be,ve)=>{if(N===ve)return;let Fe=[];ve===1&&Fe.push("TERRAIN_VERTEX_MORPHING"),Fe.push("PROJECTION_GLOBE_VIEW"),Z&&Fe.push("CUSTOM_ANTIALIASING");let pe=T.isTileAffectedByFog(be);k=T.getOrCreateProgram("globeRaster",{defines:Fe,overrideFog:pe}),N=ve},re=T.colorModeForRenderPass(),te=new nt(O.LEQUAL,nt.ReadWrite,T.depthRangeFor3D);Da.update(D);let se=h.dt(q),K=[h.aG(q.center.lng),h.aJ(q.center.lat)],J=T.globeSharedBuffers,oe=[q.width*h.o.devicePixelRatio,q.height*h.o.devicePixelRatio],ue=Float32Array.from(q.globeMatrix),de={useDenormalizedUpVectorScale:!0};{let be=T.transform,ve=zc(be.zoom,I.exaggeration(),I.sourceCache._source.tileSize);N=-1;let Fe=O.TRIANGLES;for(let pe of A){let Ie=P.getTile(pe),fe=gt.disabled,Pe=I.prevTerrainTileForTile[pe.key],Ce=I.terrainTileForTile[pe.key];bl(Pe,Ce)&&Da.newMorphing(pe.key,Pe,Ce,D,250),Ra(T,Ie.emissiveTexture),L.activeTexture.set(O.TEXTURE0),Ie.texture&&Ie.texture.bind(O.LINEAR,O.CLAMP_TO_EDGE);let Re=Da.getMorphValuesForProxy(pe.key),Ye=Re?1:0;Re&&Object.assign(de,{morphing:{srcDemTile:Re.from,dstDemTile:Re.to,phase:h.dr(Re.phase)}});let $e=h.du(pe.canonical),je=h.dv($e.getCenter().lat),Ue=h.dw(pe.canonical,$e,je,be.worldSize/be._pixelsPerMercatorPixel),at=h.dx(h.dy(pe.canonical)),ot=T.emissiveMode==="mrt-fallback"?1:0,et=Rc(be.expandedFarZProjMatrix,ue,se,at,h.ai(be.zoom),K,be.frustumCorners.TL,be.frustumCorners.TR,be.frustumCorners.BR,be.frustumCorners.BL,be.globeCenterInViewSpace,be.globeRadius,oe,ve,be._farZ,ot,Ue);if(G(pe,Ye),k&&(I.setupElevationDraw(Ie,k,de),T.uploadCommonUniforms(L,k,pe.toUnwrapped()),J)){let[it,ut,xt]=J.getGridBuffers(je,ve!==0);k.draw(T,Fe,te,fe,re,dt.backCCW,et,"globe_raster",it,ut,xt)}}}if(J&&(T.renderDefaultNorthPole||T.renderDefaultSouthPole)){let be=["GLOBE_POLES","PROJECTION_GLOBE_VIEW"];Z&&be.push("CUSTOM_ANTIALIASING"),k=T.getOrCreateProgram("globeRaster",{defines:be});for(let ve of A){let{x:Fe,y:pe,z:Ie}=ve.canonical,fe=pe===0,Pe=pe===(1<<Ie)-1,[Ce,Re,Ye,$e]=J.getPoleBuffers(Ie,!1);if($e&&(fe||Pe)){let je=P.getTile(ve);Ra(T,je.emissiveTexture),L.activeTexture.set(O.TEXTURE0),je.texture&&je.texture.bind(O.LINEAR,O.CLAMP_TO_EDGE);let Ue=h.dz(Ie,Fe,q),at=h.dx(h.dy(ve.canonical)),ot=T.emissiveMode==="mrt-fallback"?1:0,et=(it,ut)=>it.draw(T,O.TRIANGLES,te,gt.disabled,re,dt.disabled,Rc(q.expandedFarZProjMatrix,Ue,Ue,at,0,K,q.frustumCorners.TL,q.frustumCorners.TR,q.frustumCorners.BR,q.frustumCorners.BL,q.globeCenterInViewSpace,q.globeRadius,oe,0,q._farZ,ot),"globe_pole_raster",ut,Ye,$e);I.setupElevationDraw(je,k,de),T.uploadCommonUniforms(L,k,ve.toUnwrapped()),fe&&T.renderDefaultNorthPole&&et(k,Ce),Pe&&T.renderDefaultSouthPole&&(Ue=h.cE(h.bd(),Ue,[1,-1,1]),et(k,Re))}}}})(d,m,_,y,v);else{let T=d.context,I=T.gl,P,A,D=d.shadowRenderer,L=Cs(d,d.longestCutoffRange),O=re=>{if(A===re)return;let te=[];re===1&&te.push("TERRAIN_VERTEX_MORPHING"),L.shouldRenderCutoff&&te.push("RENDER_CUTOFF"),D&&(te.push("RENDER_SHADOWS"),D.useNormalOffset&&te.push("NORMAL_OFFSET")),P=d.getOrCreateProgram("terrainRaster",{defines:te}),A=re},k=d.colorModeForRenderPass(),N=new nt(I.LEQUAL,nt.ReadWrite,d.depthRangeFor3D);Da.update(v);let q=d.transform,Z=zc(q.zoom,m.exaggeration(),m.sourceCache._source.tileSize),G=[0,0,0];if(D){let re=d.style.directionalLight,te=d.style.ambientLight;re&&te&&(G=Ea(d.style,re,te))}{A=-1;let re=I.TRIANGLES,[te,se]=[m.gridIndexBuffer,m.gridSegments];for(let K of y){let J=_.getTile(K),oe=gt.disabled,ue=m.prevTerrainTileForTile[K.key],de=m.terrainTileForTile[K.key];bl(ue,de)&&Da.newMorphing(K.key,ue,de,v,250),Ra(d,J.emissiveTexture),T.activeTexture.set(I.TEXTURE0),J.texture&&J.texture.bind(I.LINEAR,I.CLAMP_TO_EDGE);let be=Da.getMorphValuesForProxy(K.key),ve=be?1:0,Fe;be&&(Fe={morphing:{srcDemTile:be.from,dstDemTile:be.to,phase:h.dr(be.phase)}});let pe=d.emissiveMode==="mrt-fallback"?1:0,Ie=Pa(K.projMatrix,Wu(K.canonical,q.renderWorldCopies)?Z/10:Z,G,pe);if(O(ve),!P)continue;m.setupElevationDraw(J,P,Fe);let fe=K.toUnwrapped();D&&D.setupShadows(fe,P),d.uploadCommonUniforms(T,P,fe,null,L),P.draw(d,re,N,oe,k,dt.backCCW,Ie,"terrain_raster",m.gridBuffer,te,se)}}}}(o,this,this.proxySourceCache,t,this._updateTimestamp),this.renderingToTexture=!0,o.gpuTimingDeferredRenderEnd(),t.splice(0,t.length))}renderBatch(t){if(this._drapedRenderBatches.length===0)return t+1;this.renderingToTexture=!0;let o=this.painter,c=this.painter.context,d=this.proxySourceCache,m=this.proxiedCoords[d.id],_=this._drapedRenderBatches.shift(),y=o.style.order,v=[];this._updateFBOs(o.emissiveMode==="mrt-fallback");let T=0;for(let I of m){let P=d.getTileByID(I.proxyTileKey),A=d.proxyCachedFBO[I.key]?d.proxyCachedFBO[I.key][t]:void 0,D=A!==void 0?d.renderCache[A]:this.pool[T++],L=A!==void 0;
3059if(P.texture=D.tex,P.emissiveTexture=D.emissiveTex,L&&!D.dirty){v.push(P.tileID);continue}c.bindFramebuffer.set(D.fb.framebuffer);let O=c.gl,k;O.drawBuffers(o.emissiveMode==="mrt-fallback"?[O.COLOR_ATTACHMENT0,O.COLOR_ATTACHMENT1]:[O.COLOR_ATTACHMENT0]),this.renderedToTile=!1,D.dirty&&(c.clear({color:h.C.transparent,stencil:0}),D.dirty=!1);for(let N=_.start;N<=_.end;++N){let q=o.style._mergedLayers[y[N]];if(q.isHidden(o.transform.zoom))continue;let Z=o.style.getLayerSourceCache(q),G=Z?this.proxyToSource[I.key][Z.id]:[I];if(!G)continue;let re=G;c.viewport.set([0,0,D.fb.width,D.fb.height]),k!==(Z?Z.id:null)&&(this._setupStencil(D,G,q,Z),k=Z?Z.id:null),o.renderLayer(o,Z,q,re)}if(O.drawBuffers([O.COLOR_ATTACHMENT0]),this._drapedRenderBatches.length===0)for(let N of this._pendingGroundEffectLayers){let q=o.style._mergedLayers[y[N]];if(q.isHidden(o.transform.zoom))continue;let Z=o.style.getLayerSourceCache(q),G=Z?this.proxyToSource[I.key][Z.id]:[I];if(!G)continue;let re=G;c.viewport.set([0,0,D.fb.width,D.fb.height]),k!==(Z?Z.id:null)&&(this._setupStencil(D,G,q,Z),k=Z?Z.id:null),o.renderLayer(o,Z,q,re)}this.renderedToTile?(D.dirty=!0,v.push(P.tileID)):L||--T,T===5&&(T=0,this.renderToBackBuffer(v))}return this.renderToBackBuffer(v),this.renderingToTexture=!1,c.bindFramebuffer.set(null),c.viewport.set([0,0,o.width,o.height]),_.end+1}postRender(){}isLayerOrderingCorrect(t){let o=t.order.length,c=-1,d=o;for(let m=0;m<o;++m)this._style.isLayerDraped(t._mergedLayers[t.order[m]])?c=Math.max(c,m):d=Math.min(d,m);return d>c}getMinElevationBelowMSL(){let t=0;return this._visibleDemTiles.filter(o=>o.dem).forEach(o=>{t=Math.min(t,o.dem.tree.minimums[0])}),t===0?t:(t-30)*this._exaggeration}raycast(t,o,c){if(!this._visibleDemTiles)return null;let d=this._visibleDemTiles.filter(m=>m.dem).map(m=>{let _=m.tileID,y=1<<_.overscaledZ,{x:v,y:T}=_.canonical,I=v/y,P=(v+1)/y,A=T/y,D=(T+1)/y;return{minx:I,miny:A,maxx:P,maxy:D,t:m.dem.tree.raycastRoot(I,A,P,D,t,o,c),tile:m}});d.sort((m,_)=>(m.t!==null?m.t:Number.MAX_VALUE)-(_.t!==null?_.t:Number.MAX_VALUE));for(let m of d){if(m.t==null)return null;let _=m.tile.dem.tree.raycast(m.minx,m.miny,m.maxx,m.maxy,t,o,c);if(_!=null)return _}return null}_createFBO(){let t=this.painter.context,o=t.gl,c=this.drapeBufferSize;t.activeTexture.set(o.TEXTURE0);let d=new h.T(t,{width:c[0],height:c[1],data:null},o.RGBA8);d.bind(o.LINEAR,o.CLAMP_TO_EDGE);let m=t.createFramebuffer(c[0],c[1],1,null),_;return m.colorAttachment0.set(d.texture),this._emissiveTexture&&(_=new h.T(t,{width:c[0],height:c[1],data:null},o.R8),_.bind(o.LINEAR,o.CLAMP_TO_EDGE),m.createColorAttachment(t,1),m.colorAttachment1.set(_.texture)),m.depthAttachment=new Zu(t,m.framebuffer),this._sharedDepthStencil===void 0?(this._sharedDepthStencil=t.createRenderbuffer(t.gl.DEPTH_STENCIL,c[0],c[1]),this._stencilRef=0,m.depthAttachment.set(this._sharedDepthStencil),t.clear({stencil:0})):m.depthAttachment.set(this._sharedDepthStencil),t.extTextureFilterAnisotropic&&o.texParameterf(o.TEXTURE_2D,t.extTextureFilterAnisotropic.TEXTURE_MAX_ANISOTROPY_EXT,t.extTextureFilterAnisotropicMax),{fb:m,tex:d,emissiveTex:_,dirty:!1}}_updateFBOs(t){if(this._emissiveTexture!==t){for(let o of this.pool)this._updateFBO(o,t);for(let o of this.proxySourceCache.renderCache)this._updateFBO(o,t);this._emissiveTexture=t}}_updateFBO(t,o){let c=t.fb,d=this.painter.context,m=d.gl,_=this.drapeBufferSize;if(o){let y=new h.T(d,{width:_[0],height:_[1],data:null},m.R8);y.bind(m.LINEAR,m.CLAMP_TO_EDGE),t.emissiveTex=y,c.createColorAttachment(d,1),c.colorAttachment1.set(y.texture)}else t.emissiveTex=void 0,c.removeColorAttachment(d,1);t.dirty=!0}_initFBOPool(){for(;this.pool.length<Math.min(5,this.proxyCoords.length);)this.pool.push(this._createFBO())}_shouldDisableRenderCache(){if(this._style.hasLightTransitions())return!0;for(let t in this._style._mergedSourceCaches)if(this._style._mergedSourceCaches[t].hasTransition())return!0;return this._style.order.some(t=>{let o=this._style._mergedLayers[t],c=o.isHidden(this.painter.transform.zoom);return o.type==="hillshade"||o.type==="custom"?!c&&o.shouldRedrape():!c&&o.hasTransition()})}_clearLineLayersFromRenderCache(){let t=!1;for(let c of this._style.getSources())if(c instanceof yu){t=!0;break}if(!t)return;let o={};for(let c=0;c<this._style.order.length;++c){let d=this._style._mergedLayers[this._style.order[c]],m=this._style.getLayerSourceCache(d);if(!m||o[m.id]||d.isHidden(this.painter.transform.zoom)||d.type!=="line")continue;let _=d.widthExpression(),y=d.emissiveStrengthExpression();if(_ instanceof h.ac||y instanceof h.ac){o[m.id]=!0;for(let v of this.proxyCoords){let T=this.proxyToSource[v.key][m.id];if(T)for(let I of T)this._clearRenderCacheForTile(m.id,I)}}}}_clearRasterLayersFromRenderCache(){let t=!1;for(let c in this._style._mergedSourceCaches)if(this._style._mergedSourceCaches[c]._source instanceof mc){t=!0;break}if(!t)return;let o={};for(let c=0;c<this._style.order.length;++c){let d=this._style._mergedLayers[this._style.order[c]],m=this._style.getLayerSourceCache(d);if(!m||o[m.id]||d.isHidden(this.painter.transform.zoom)||d.type!=="raster")continue;let _=d.paint.get("raster-fade-duration");for(let y of this.proxyCoords){let v=this.proxyToSource[y.key][m.id];if(v)for(let T of v){let I=Qe(m.getTile(T),m.findLoadedParent(T,0),m,this.painter.transform,_);(I.opacity!==1||I.mix!==0)&&this._clearRenderCacheForTile(m.id,T)}}}}_setupDrapedRenderBatches(){this._style.updateDrapeFirstLayers();let t=this._style.order,o=t.length;if(o===0)return;let c=[];this._pendingGroundEffectLayers=[];let d,m=0,_=this._style._mergedLayers[t[m]];for(;!this._style.isLayerDraped(_)&&_.isHidden(this.painter.transform.zoom)&&++m<o;)_=this._style._mergedLayers[t[m]];for(;m<o;++m){let y=this._style._mergedLayers[t[m]];y.isHidden(this.painter.transform.zoom)||(this._style.isLayerDraped(y)?d===void 0&&(d=m):(y.t
3059ype==="fill-extrusion"&&this._pendingGroundEffectLayers.push(m),d!==void 0&&(c.push({start:d,end:m-1}),d=void 0)))}if(d!==void 0&&c.push({start:d,end:m-1}),c.length!==0){let y=c.at(-1);this._pendingGroundEffectLayers.every(v=>v>y.end)||h.w("fill-extrusion with flood lighting and/or ground ambient occlusion should be moved to be on top of all draped layers.")}this._drapedRenderBatches=c}_setupRenderCache(t){let o=this.proxySourceCache;if(this._shouldDisableRenderCache()||this.invalidateRenderCache){if(this.invalidateRenderCache=!1,o.renderCache.length>o.renderCachePool.length){let _=Object.values(o.proxyCachedFBO);o.proxyCachedFBO={};for(let y=0;y<_.length;++y){let v=Object.values(_[y]);o.renderCachePool.push(...v)}}return}this._clearRasterLayersFromRenderCache();let c=this.proxyCoords,d=this._tilesDirty;for(let _=c.length-1;_>=0;_--){let y=c[_];if(o.getTileByID(y.key),o.proxyCachedFBO[y.key]!==void 0){let v=t[y.key],T=this.proxyToSource[y.key],I=0;for(let P in T){let A=T[P],D=v[P];if(!D||D.length!==A.length||A.some((L,O)=>L!==D[O]||d[P]&&Object.hasOwn(d[P],L.key))){I=-1;break}++I}for(let P in o.proxyCachedFBO[y.key])o.renderCache[o.proxyCachedFBO[y.key][P]].dirty=I<0||I!==Object.values(v).length}}let m=[...this._drapedRenderBatches];m.sort((_,y)=>y.end-y.start-(_.end-_.start));for(let _ of m)for(let y of c){if(o.proxyCachedFBO[y.key])continue;let v=o.renderCachePool.pop();v===void 0&&o.renderCache.length<50&&(v=o.renderCache.length,o.renderCache.push(this._createFBO())),v!==void 0&&(o.proxyCachedFBO[y.key]={},o.proxyCachedFBO[y.key][_.start]=v,o.renderCache[v].dirty=!0)}this._tilesDirty={}}_setupStencil(t,o,c,d){if(!d||!this._sourceTilesOverlap[d.id])return void(this._overlapStencilType&&(this._overlapStencilType=!1));let m=this.painter.context,_=m.gl;if(o.length<=1)return void(this._overlapStencilType=!1);let y;if(c.isTileClipped())y=o.length,this._overlapStencilMode.test={func:_.EQUAL,mask:255},this._overlapStencilType="Clip";else{if(!(o[0].overscaledZ>o.at(-1).overscaledZ))return void(this._overlapStencilType=!1);y=1,this._overlapStencilMode.test={func:_.GREATER,mask:255},this._overlapStencilType="Mask"}this._stencilRef+y>255&&(m.clear({stencil:0}),this._stencilRef=0),this._stencilRef+=y,this._overlapStencilMode.ref=this._stencilRef,c.isTileClipped()&&this._renderTileClippingMasks(o,this._overlapStencilMode.ref)}clipOrMaskOverlapStencilType(){return this._overlapStencilType==="Clip"||this._overlapStencilType==="Mask"}stencilModeForRTTOverlap(t){return this.renderingToTexture&&this._overlapStencilType?(this._overlapStencilType==="Clip"&&(this._overlapStencilMode.ref=this.painter._tileClippingMaskIDs[t.key]),this._overlapStencilMode):gt.disabled}_renderTileClippingMasks(t,o){let c=this.painter,d=this.painter.context,m=d.gl;c._tileClippingMaskIDs={},d.setColorMode(mt.disabled),d.setDepthMode(nt.disabled);let _=c.getOrCreateProgram("clippingMask");for(let y of t){let v=c._tileClippingMaskIDs[y.key]=--o;_.draw(c,m.TRIANGLES,nt.disabled,new gt({func:m.ALWAYS,mask:0},v,255,m.KEEP,m.KEEP,m.REPLACE),mt.disabled,dt.disabled,wl(y.projMatrix),"$clipping",c.tileExtentBuffer,c.quadTriangleIndexBuffer,c.tileExtentSegments)}}pointCoordinate(t){let o=this.painter.transform;if(t.x<0||t.x>o.width||t.y<0||t.y>o.height)return null;let c=[t.x,t.y,1,1];h.aD(c,c,o.pixelMatrixInverse),h.cw(c,c,1/c[3]),c[0]/=o.worldSize,c[1]/=o.worldSize;let d=o._camera.position,m=h.bY(1,o.center.lat),_=[d[0],d[1],d[2]/m,0],y=h.cZ([],c.slice(0,3),_);h.ax(y,y);let v=this.raycast(_,y,this._exaggeration);return v!==null&&v?(h.bi(_,_,y,v),_[3]=_[2],_[2]*=m,_):null}_setupProxiedCoordsForOrtho(t,o,c){if(t.getSource()instanceof h.aY)return this._setupProxiedCoordsForImageSource(t,o,c);this._findCoveringTileCache[t.id]=this._findCoveringTileCache[t.id]||{};let d=this.proxiedCoords[t.id]=[],m=this.proxyCoords;for(let v=0;v<m.length;v++){let T=m[v],I=this._findTileCoveringTileID(T,t);if(I){let P=this._createProxiedId(T,I,c[T.key]&&c[T.key][t.id]);d.push(P),this.proxyToSource[T.key][t.id]=[P]}}let _=!1,y=new Set;for(let v=0;v<o.length;v++){let T=t.getTile(o[v]);if(!T||!T.hasData())continue;let I=this._findTileCoveringTileID(T.tileID,this.proxySourceCache);
3059if(I&&I.tileID.canonical.z!==T.tileID.canonical.z){let P=this.proxyToSource[I.tileID.key][t.id],A=this._createProxiedId(I.tileID,T,c[I.tileID.key]&&c[I.tileID.key][t.id]);P?P.splice(P.length-1,0,A):this.proxyToSource[I.tileID.key][t.id]=[A];let D=this.proxyToSource[I.tileID.key][t.id];y.has(D)||y.add(D),d.push(A),_=!0}}if(this._sourceTilesOverlap[t.id]=_,_)for(let v of y)v.sort((T,I)=>I.overscaledZ-T.overscaledZ)}_setupProxiedCoordsForImageSource(t,o,c){if(!t.getSource().loaded())return;let d=this.proxiedCoords[t.id]=[],m=this.proxyCoords,_=t.getSource(),y=_.tileID;if(!y)return;let v=new h.P(y.x,y.y)._div(1<<y.z),T=_.coordinates.map(h.ad.fromLngLat).reduce((P,A)=>(P.min.x=Math.min(P.min.x,A.x-v.x),P.min.y=Math.min(P.min.y,A.y-v.y),P.max.x=Math.max(P.max.x,A.x-v.x),P.max.y=Math.max(P.max.y,A.y-v.y),P),{min:new h.P(Number.MAX_VALUE,Number.MAX_VALUE),max:new h.P(-Number.MAX_VALUE,-Number.MAX_VALUE)}),I=(P,A)=>{let D=P.wrap+P.canonical.x/(1<<P.canonical.z),L=P.canonical.y/(1<<P.canonical.z),O=h.ak/(1<<P.canonical.z),k=A.wrap+A.canonical.x/(1<<A.canonical.z),N=A.canonical.y/(1<<A.canonical.z);return D+O<k+T.min.x||D>k+T.max.x||L+O<N+T.min.y||L>N+T.max.y};for(let P=0;P<m.length;P++){let A=m[P];for(let D=0;D<o.length;D++){let L=t.getTile(o[D]);if(!L||!L.hasData()||I(A,L.tileID))continue;let O=this._createProxiedId(A,L,c[A.key]&&c[A.key][t.id]),k=this.proxyToSource[A.key][t.id];k?k.push(O):this.proxyToSource[A.key][t.id]=[O],d.push(O)}}}_createProxiedId(t,o,c){let d=this.orthoMatrix;if(c){let m=c.find(_=>_.key===o.tileID.key);if(m)return m}if(o.tileID.key!==t.key){let m=t.canonical.z-o.tileID.canonical.z,_,y,v;d=h.bd();let T=o.tileID.wrap-t.wrap<<t.overscaledZ;m>0?(_=h.ak>>m,y=_*((o.tileID.canonical.x<<m)-t.canonical.x+T),v=_*((o.tileID.canonical.y<<m)-t.canonical.y)):(_=h.ak<<-m,y=h.ak*(o.tileID.canonical.x-(t.canonical.x+T<<-m)),v=h.ak*(o.tileID.canonical.y-(t.canonical.y<<-m))),h.bX(d,0,_,0,_,0,1),h.bB(d,d,[y,v,0])}return new Ko(o.tileID,t.key,d)}_findTileCoveringTileID(t,o){let c=o.getTile(t);if(c&&c.hasData())return c;let d=this._findCoveringTileCache[o.id],m=d[t.key];if(c=m?o.getTileByID(m):null,c&&c.hasData()||m===null)return c;let _=c?c.tileID:t,y=_.overscaledZ,v=o.getSource().minzoom,T=[];if(!m){let P=o.getSource().maxzoom;if(t.canonical.z>=P){let A=t.canonical.z-P;o.getSource().reparseOverscaled?(y=Math.max(t.canonical.z+2,o.transform.tileZoom),_=new h.aU(y,t.wrap,P,t.canonical.x>>A,t.canonical.y>>A)):A!==0&&(y=P,_=new h.aU(y,t.wrap,P,t.canonical.x>>A,t.canonical.y>>A))}_.key!==t.key&&(T.push(_.key),c=o.getTile(_))}let I=P=>{T.forEach(A=>{d[A]=P}),T.length=0};for(y-=1;y>=v&&(!c||!c.hasData());y--){c&&I(c.tileID.key);let P=_.calculateScaledKey(y);if(c=o.getTileByID(P),c&&c.hasData())break;let A=d[P];if(A===null)break;A===void 0?T.push(P):c=o.getTileByID(A)}return I(c?c.tileID.key:null),c&&c.hasData()?c:null}findDEMTileFor(t){return this.enabled?this._findTileCoveringTileID(t,this.sourceCache):null}prepareDrawTile(){this.renderedToTile=!0}_clearRenderCacheForTile(t,o){let c=this._tilesDirty[t];c||(c=this._tilesDirty[t]={}),c[o.key]=!0}}function Ff(a,t,o){let c=function(y,v,T){let I=h.bk(v,y),P=h.bk(T,[.2126,.7152,.0722]),A=(L,O,k)=>(1-k)*L+k*O,D=A(1-.3*Math.min(P,1),1,Math.min(I+1,1));return A(.92,1,Math.asin(h.aB(v[2],-1,1))/Math.PI+.5)*D}(a,[0,0,1],t),d=[0,0,0];h.bN(d,o.slice(0,3),c);let m=[0,0,0];h.bN(m,t.slice(0,3),a[2]);let _=[0,0,0];return h.cX(_,d,m),h.c_(_)}let Bf=["fill","fillOutline","fillPattern","line","linePattern","background","backgroundPattern","hillshade","raster"],kf=["stars","rainParticle","snowParticle","fillExtrusion","fillExtrusionGroundEffect","building","buildingBloom","elevatedStructures","model","symbol"];class Td{static cacheKey(t,o,c,d){let m=[o];d&&m.push(d.cacheKey);for(let _ of c)(typeof _=="string"&&_.includes(" ")||t.usedDefines.has(_))&&m.push(_);return m.join("/")}constructor(t,o,c,d,m,_,y=!1){let v=t.gl;this.program=v.createProgram(),this._context=t,this._fixedUniformsFn=m,this._pending=!0,this._precompiled=y,this.attributes={},this.configuration=d,this.name=o,this.fixedDefines=[..._],y?t._compileStats.precompiled++:t._compileStats.onDemand++;let T=`#version 300 es 3060${(d?d.defines():[]).concat(_.map(k=>`#define ${k}`)).join(` 3061`)}`,I=[T,Uu];for(let k of c.fragmentIncludes)I.push(Mc[k]);I.push(c.fragmentSource);let P=I.join(` 3062`),A=[T,Z_];
3062for(let k of c.vertexIncludes)A.push(Mc[k]);this.forceManualRenderingForInstanceIDShaders=t.forceManualRenderingForInstanceIDShaders&&c.vertexSource.includes("gl_InstanceID"),this.forceManualRenderingForInstanceIDShaders&&A.push("uniform int u_instanceID;"),A.push(c.vertexSource);let D=A.join(` 3063`);this.forceManualRenderingForInstanceIDShaders&&(D=D.replaceAll("gl_InstanceID","u_instanceID"));let L=v.createShader(v.FRAGMENT_SHADER);if(v.isContextLost())return this.failedToCreate=!0,void(this._pending=!1);v.shaderSource(L,P),v.compileShader(L),v.attachShader(this.program,L);let O=v.createShader(v.VERTEX_SHADER);if(v.isContextLost())return this.failedToCreate=!0,void(this._pending=!1);v.shaderSource(O,D),v.compileShader(O),v.attachShader(this.program,O),v.linkProgram(this.program),this._fragmentShader=L,this._vertexShader=O,t.extParallelShaderCompile?t._pendingPrograms.add(this):this._finalize()}_finalize(){if(!this._pending)return;this._pending=!1;let t=this._context,o=t.gl;t._pendingPrograms.delete(this);let c=h.o.now(),d=o.getProgramParameter(this.program,o.LINK_STATUS),m=h.o.now()-c,_=t._compileStats;if(_.totalStallMs+=m,m>_.maxStallMs&&(_.maxStallMs=m),m>1){_.framesMissed+=Math.floor(60*m/1e3);let T=this.fixedDefines.join(",");_.stalls.push({name:`${this.name}${T?"/":""}${T}`,ms:m,timestamp:c})}if(this._fragmentShader&&(d||h.w(`Fragment shader '${this.name}': ${o.getShaderInfoLog(this._fragmentShader)}`),o.deleteShader(this._fragmentShader),this._fragmentShader=null),this._vertexShader&&(d||h.w(`Vertex shader '${this.name}': ${o.getShaderInfoLog(this._vertexShader)}`),o.deleteShader(this._vertexShader),this._vertexShader=null),!d)return h.w(`Failed to link program '${this.name}': ${o.getProgramInfoLog(this.program)}`),void(this.failedToCreate=!0);this.fixedUniforms=this._fixedUniformsFn(t),this.fixedUniformsEntries=Object.entries(this.fixedUniforms),this.binderUniforms=this.configuration?this.configuration.getUniforms(t):[],this.forceManualRenderingForInstanceIDShaders&&(this.instancingUniforms=(T=>({u_instanceID:new h.b$(T)}))(t));let y=this.fixedDefines,v=this.name;(y.includes("TERRAIN")||y.includes("ELEVATED")||v.includes("symbol")||v.includes("circle"))&&(this.terrainUniforms=(T=>({u_dem:new h.b$(T),u_dem_prev:new h.b$(T),u_dem_tl:new h.c2(T),u_dem_scale:new h.c1(T),u_dem_tl_prev:new h.c2(T),u_dem_scale_prev:new h.c1(T),u_dem_size:new h.c1(T),u_dem_lerp:new h.c1(T),u_exaggeration:new h.c1(T),u_depth:new h.b$(T),u_depth_size_inv:new h.c2(T),u_depth_range_unpack:new h.c2(T),u_occluder_half_size:new h.c1(T),u_occlusion_depth_offset:new h.c1(T),u_meter_to_dem:new h.c1(T),u_label_plane_matrix_inv:new h.c3(T)}))(t)),y.includes("GLOBE")&&(this.globeUniforms=(T=>({u_tile_tl_up:new h.c0(T),u_tile_tr_up:new h.c0(T),u_tile_br_up:new h.c0(T),u_tile_bl_up:new h.c0(T),u_tile_up_scale:new h.c1(T)}))(t)),y.includes("FOG")&&(this.fogUniforms=(T=>({u_fog_matrix:new h.c3(T),u_fog_range:new h.c2(T),u_fog_color:new h.cS(T),u_fog_horizon_blend:new h.c1(T),u_fog_vertical_limit:new h.c2(T),u_fog_temporal_offset:new h.c1(T),u_frustum_tl:new h.c0(T),u_frustum_tr:new h.c0(T),u_frustum_br:new h.c0(T),u_frustum_bl:new h.c0(T),u_globe_pos:new h.c0(T),u_globe_radius:new h.c1(T),u_globe_transition:new h.c1(T),u_is_globe:new h.b$(T),u_viewport:new h.c2(T)}))(t)),y.includes("RENDER_CUTOFF")&&(this.cutoffUniforms=(T=>({u_cutoff_params:new h.cS(T)}))(t)),y.includes("LIGHTING_3D_MODE")&&(this.lightsUniforms=(T=>({u_lighting_ambient_color:new h.c0(T),u_lighting_directional_dir:new h.c0(T),u_lighting_directional_color:new h.c0(T),u_ground_radiance:new h.c0(T)}))(t)),y.includes("RENDER_SHADOWS")&&(this.shadowUniforms=(T=>({u_light_matrix_0:new h.c3(T),u_light_matrix_1:new h.c3(T),u_fade_range:new h.c2(T),u_shadow_normal_offset:new h.c0(T),u_shadow_intensity:new h.c1(T),u_shadow_texel_size:new h.c1(T),u_shadow_map_resolution:new h.c1(T),u_shadow_direction:new h.c0(T),u_shadow_bias:new h.c0(T),u_shadowmap_0:new h.b$(T),u_shadowmap_1:new h.b$(T)}))(t))}maybeFinalize(){if(!this._pending)return;let t=this._context.extParallelShaderCompile;t&&!this._context.gl.getProgramParameter(this.program,t.COMPLETION_STATUS_KHR
3063)||this._finalize()}_ensureReady(){this._pending&&(this._finalize(),this._context.sweepPendingPrograms())}getAttributeLocation(t,o){this._ensureReady();let c=this.attributes[o];return c===void 0&&(c=this.attributes[o]=t.getAttribLocation(this.program,o)),c}setTerrainUniformValues(t,o){if(this._ensureReady(),!this.terrainUniforms)return;let c=this.terrainUniforms;if(!this.failedToCreate){t.program.set(this.program);for(let d in o)c[d]&&c[d].set(this.program,d,o[d])}}setGlobeUniformValues(t,o){if(this._ensureReady(),!this.globeUniforms)return;let c=this.globeUniforms;if(!this.failedToCreate){t.program.set(this.program);for(let d in o)c[d]&&c[d].set(this.program,d,o[d])}}setFogUniformValues(t,o){if(this._ensureReady(),!this.fogUniforms)return;let c=this.fogUniforms;if(!this.failedToCreate){t.program.set(this.program);for(let d in o)c[d].set(this.program,d,o[d])}}setCutoffUniformValues(t,o){if(this._ensureReady(),!this.cutoffUniforms)return;let c=this.cutoffUniforms;if(!this.failedToCreate){t.program.set(this.program);for(let d in o)c[d].set(this.program,d,o[d])}}setLightsUniformValues(t,o){if(this._ensureReady(),!this.lightsUniforms)return;let c=this.lightsUniforms;if(!this.failedToCreate){t.program.set(this.program);for(let d in o)c[d].set(this.program,d,o[d])}}setShadowUniformValues(t,o){if(this._ensureReady(),this.failedToCreate||!this.shadowUniforms)return;let c=this.shadowUniforms;t.program.set(this.program);for(let d in o)c[d].set(this.program,d,o[d])}_drawDebugWireframe(t,o,c,d,m,_,y,v,T,I){let P=t.options.wireframe;if(P.terrain===!1&&P.layers2D===!1&&P.layers3D===!1)return;let A=t.context;if(!(!(!P.terrain||this.name!=="terrainRaster"&&this.name!=="globeRaster")||!(!P.layers2D||t._terrain&&t._terrain.renderingToTexture||!Bf.includes(this.name))||!(!P.layers3D||!kf.includes(this.name))))return;let D=A.gl,L=t.wireframeDebugCache.getLinesFromTrianglesBuffer(t.frameCounter,m,A);if(!L)return;let O=[...this.fixedDefines,"DEBUG_WIREFRAME"],k=t.getOrCreateProgram(this.name,{config:this.configuration,defines:O});k._ensureReady(),A.program.set(k.program);let N=(G,re,te)=>{if(re[G]&&te[G])for(let se in re[G])te[G][se]&&te[G][se].set(te.program,se,re[G][se].current)};T&&T.setUniforms(k.program,A,k.binderUniforms,y,{zoom:v}),N("fixedUniforms",this,k),N("terrainUniforms",this,k),N("globeUniforms",this,k),N("fogUniforms",this,k),N("lightsUniforms",this,k),N("shadowUniforms",this,k),L.bind(),A.setColorMode(new mt([D.ONE,D.ONE_MINUS_SRC_ALPHA,D.ZERO,D.ONE],h.C.transparent,[!0,!0,!0,!1])),A.setDepthMode(new nt(o.func===D.LESS?D.LEQUAL:o.func,nt.ReadOnly,o.range)),A.setStencilMode(gt.disabled);let q=3*_.primitiveLength*2,Z=3*_.primitiveOffset*2*2;if(this.forceManualRenderingForInstanceIDShaders){let G=I||1;for(let re=0;re<G;++re)k.instancingUniforms.u_instanceID.set(this.program,"u_instanceID",re),D.drawElements(D.LINES,q,D.UNSIGNED_SHORT,Z)}else I&&I>1?D.drawElementsInstanced(D.LINES,q,D.UNSIGNED_SHORT,Z,I):D.drawElements(D.LINES,q,D.UNSIGNED_SHORT,Z);m.bind(),A.program.set(this.program),A.setDepthMode(o),A.setStencilMode(c),A.setColorMode(d)}checkUniforms(t,o,c){if(this.fixedDefines.includes(o)){for(let d of Object.keys(c))if(!c[d].initialized)throw new Error(`Program '${this.name}', from draw '${t}': uniform ${d} not set but required by ${o} being defined`)}}draw(t,o,c,d,m,_,y,v,T,I,P,A,D,L,O,k){let N=t.context,q=N.gl;if(this._ensureReady(),this.failedToCreate)return;N.program.set(this.program),N.setDepthMode(c),N.setStencilMode(d),N.setColorMode(m),N.setCullFace(_);for(let[K,J]of this.fixedUniformsEntries)J.set(this.program,K,y[K]);L&&L.setUniforms(this.program,N,this.binderUniforms,A,{zoom:D});let Z={[q.POINTS]:1,[q.LINES]:2,[q.TRIANGLES]:3,[q.LINE_STRIP]:1}[o];this.checkUniforms(v,"RENDER_SHADOWS",this.shadowUniforms);let G=O||[],re=L?L.getPaintVertexBuffers():[],te=o===q.TRIANGLES&&I,se=k&&k>0?1:void 0;for(let K of P.get()){let J=K.vaos||(K.vaos={});if((J[v]||(J[v]=new Gu)).bind(N,this,T,re,I,K.vertexOffset,G,se),this.forceManualRenderingForInstanceIDShaders){let oe=k||1;for(let ue=0;ue<oe;++ue)this.instancingUniforms.u_instanceID.set(this.program,"u_instanceID",ue),I?q.drawElements(o,K.primitiveLength*Z,q.UNSIGNED_SHORT,K.primitiveOffset*Z*2):q.drawArrays(o,K.vertexOffset,K.vertexLength)}else k&&k>1?q.drawElementsInstanced(o,K.primitiveLength*Z,q.UNSIGNED_SHORT,K.primitiveOffset*Z*2,k):I?q.drawElements(o,K.primitiveLength*Z,q.UNSIGNED_SHORT,K.primitiveOffset*Z*2):q.drawArrays(o,K.vertexOffset,K.vertexLength);te&&this._drawDebugWireframe(t,c,d,m,I,K,A,D,L,k)}}}
3063function Sd(a,t,o=0){let c=Math.pow(2,t.tileID.overscaledZ),d=t.tileSize*Math.pow(2,a.transform.tileZoom)/c,m=d*(t.tileID.canonical.x+t.tileID.wrap*c),_=d*t.tileID.canonical.y;return{u_image:0,u_texsize:t.imageAtlasTexture?t.imageAtlasTexture.size:[0,0],u_tile_units_to_pixels:1/h.az(t,1,a.transform.tileZoom),u_pixel_coord_upper:[m>>16,_>>16],u_pixel_coord_lower:[65535&m,65535&_],u_pattern_transition:o}}let za={terrain:0,flat:1},Id=h.bd(),Lc=(a,t,o,c,d,m,_,y,v,T,I,P,A,D,L,O,k,N,q=[0,0,1])=>{let Z=t.style.light,G=Z.properties.get("position"),re=[G.x,G.y,G.z],te=h.dH();Z.properties.get("anchor")==="viewport"&&(h.dI(te,-t.transform.angle),h.dJ(re,re,te));let se=Z.properties.get("color").toPremultipliedRenderColor(null),K=t.transform,J={u_matrix:a,u_lightpos:re,u_lightintensity:Z.properties.get("intensity"),u_lightcolor:[se.r,se.g,se.b],u_vertical_gradient:+o,u_opacity:c,u_tile_id:[0,0,0],u_zoom_transition:0,u_inv_rot_matrix:Id,u_merc_center:[0,0],u_up_dir:[0,0,0],u_height_lift:0,u_height_type:za[T],u_base_type:za[I],u_ao:d,u_edge_radius:m,u_width_scale:_,u_flood_light_color:L,u_vertical_scale:O,u_flood_light_intensity:k,u_ground_shadow_factor:N,u_front_cutoff_params:q};return K.projection.name==="globe"&&(J.u_tile_id=[y.canonical.x,y.canonical.y,1<<y.canonical.z],J.u_zoom_transition=P,J.u_inv_rot_matrix=D,J.u_merc_center=A,J.u_up_dir=K.projection.upVector(new h.cp(0,0,0),A[0]*h.ak,A[1]*h.ak),J.u_height_lift=v),J},Nf=(a,t,o,c,d,m)=>({u_matrix:a,u_edge_radius:t,u_width_scale:o,u_vertical_scale:c,u_height_type:za[d],u_base_type:za[m]}),Uf=(a,t,o,c,d,m,_,y,v,T,I,P,A,D,L,O,k,N)=>{let q=Lc(a,t,o,c,d,m,_,y,T,I,P,A,D,L,O,k,1,[0,0,0]),Z={u_height_factor:-Math.pow(2,y.overscaledZ)/v.tileSize/8};return Object.assign(q,Sd(t,v,N),Z)},Ed=(a,t,o)=>({u_matrix:a,u_emissive_strength:t,u_ground_shadow_factor:o}),Ad=(a,t,o,c,d,m=0)=>Object.assign(Ed(a,t,d),Sd(o,c,m)),Vf=(a,t,o,c)=>({u_matrix:a,u_world:o,u_emissive_strength:t,u_ground_shadow_factor:c}),jf=(a,t,o,c,d,m,_=0)=>Object.assign(Ad(a,t,o,c,m,_),{u_world:d}),Md=(a,t)=>({u_matrix:a,u_depth_bias:t}),Cd=(a,t)=>({u_matrix:a,u_ground_shadow_factor:t}),Oc=(a,t,o,c,d)=>({u_matrix:a,u_camera_pos:[t[0],t[1],t[2]],u_depth_bias:o,u_height_scale:c,u_reset_depth:d}),Gf=(a,t,o)=>({u_image:a,u_texel_size:t,u_first_pass:o?1:0}),$f=(a,t,o,c,d,m,_,y)=>{let v=h.ak/m.tileSize;return{u_matrix:a,u_inv_rot_matrix:t,u_camera_to_center_distance:o.getCameraToCenterDistance(y),u_extrude_scale:[o.pixelsToGLUnits[0]/v,o.pixelsToGLUnits[1]/v],u_zoom_transition:c,u_tile_id:_,u_merc_center:d}},Hf=(a,t,o,c)=>({u_matrix:a,u_inv_matrix:t,u_camera_to_center_distance:o.getCameraToCenterDistance(c),u_viewport_size:[o.width,o.height]}),Fc=(a,t,o=1)=>({u_matrix:a,u_color:t,u_overlay:0,u_overlay_scale:o}),qf=h.bd(),Pd=(a,t,o,c,d,m,_)=>{let y=a.transform,v=y.projection.name==="globe",T=v?h.dK(y.zoom,t.canonical)*y._pixelsPerMercatorPixel:h.az(o,1,m),I={u_matrix:t.projMatrix,u_extrude_scale:T,u_intensity:_,u_inv_rot_matrix:qf,u_merc_center:[0,0],u_tile_id:[0,0,0],u_zoom_transition:0,u_up_dir:[0,0,0]};if(v){I.u_inv_rot_matrix=c,I.u_merc_center=d,I.u_tile_id=[t.canonical.x,t.canonical.y,1<<t.canonical.z],I.u_zoom_transition=h.ai(y.zoom);let P=d[0]*h.ak,A=d[1]*h.ak;I.u_up_dir=y.projection.upVector(new h.cp(0,0,0),P,A)}return I};function Dd(a,[t,o,c,d],[m,_]){if(m===_)return[0,0,0,0];let y=255*(a-1)/(a*(_-m));return[t*y,o*y,c*y,d*y]}function Xu(a,t,[o,c]){return o===c?0:.5/a+(t-o)*(a-1)/(a*(c-o))}function Rd(a){let t=a.terrain?a.terrain.exaggeration():1;var o;return(a.transform.pitch<15?.07*(1-(o=h.aB((14-a.transform.zoom)/5,0,1)))+.7*o:.07)*t}let Yu=(a,t,o,c,d,m,_,y,v,T,I,P,A,D,L,O,k,N,q,Z,G,re)=>({u_matrix:t,u_normalize_matrix:o,u_globe_matrix:c,u_merc_matrix:d,u_grid_matrix:m,u_tl_parent:_,u_scale_parent:I,u_fade_t:P.mix,u_opacity:P.opacity*A.paint.get("raster-opacity"),u_image0:0,u_image1:1,u_brightness_low:A.paint.get("raster-brightness-min"),u_brightness_high:A.paint.get("raster-brightness-max"),u_saturation_factor:h.dM(A.paint.get("raster-saturation")),u_contrast_factor:h.dL(A.paint.get("raster-contrast")),u_spin_weights:ig(A.paint.get("raster-hue-rotate")),u_perspective_transform:D,u_raster_elevation:L,u_zoom_transition:y,u_merc_center:v,u_cutoff_params:T,u_colorization_mix:Dd(h.dN,k,q),u_colorization_offset:Xu(h.dN,N,q),u_color_ramp:O,u_texture_offset:[G/(Z+2*G),Z/(Z+2*G)],u_texture_res:[Z+2*G,Z+2*G],u_emissive_strength:re,u_zbias_factor:Rd(a)});function ig(a){a*=Math.PI/180;let t=Math.sin(a),o=Math.cos(a);return[(2*o+1)/3,(-Math.sqrt(3)*t-o+1)/3,(Math.sqrt(3)*t-o+1)/3]}let Zf=h.bd(),Wf=(a,t,o,c,d,m,_,y,v,T,I,P,A,D,L,O,k,N,q,Z,G,re,te,se)=>{let K=d.transform,J={u_is_size_zoom_constant:+(a==="constant"||a==="source"),u_is_size_feature_constant:+(a==="constant"||a==="c
3063amera"),u_size_t:t?t.uSizeT:0,u_size:t?t.uSize:0,u_camera_to_center_distance:K.getCameraToCenterDistance(q),u_rotate_symbol:+o,u_aspect_ratio:K.width/K.height,u_fade_change:d.options.fadeDuration?d.symbolFadeChange:1,u_matrix:m,u_label_plane_matrix:_,u_coord_matrix:y,u_is_text:+T,u_elevation_from_sea:v?1:0,u_pitch_with_map:+c,u_texsize:I,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:Zf,u_merc_center:[0,0],u_camera_forward:[0,0,0],u_ecef_origin:[0,0,0],u_tile_matrix:Zf,u_up_vector:[0,-1,0],u_color_adj_mat:re,u_icon_transition:te||0,u_gamma_scale:c?d.transform.getCameraToCenterDistance(q)*Math.cos(d.terrain?0:d.transform._pitch):1,u_device_pixel_ratio:h.o.devicePixelRatio,u_is_halo:1,u_scale_factor:se||1,u_ground_shadow_factor:Z,u_inv_matrix:h.ba(h.bd(),_),u_normal_scale:G,u_lutTexture:10,u_zoom:K.zoom-Math.floor(K.zoom),u_spp_fill_np_color:[0,0,0,1],u_spp_halo_np_color:[0,0,0,0],u_spp_opacity:1,u_spp_halo_width:0,u_spp_halo_blur:0,u_spp_emissive_strength:0,u_spp_occlusion_opacity:1,u_spp_z_offset:0,u_spp_translate_rotation:[1,0]};return q.name==="globe"&&(J.u_tile_id=[D.canonical.x,D.canonical.y,1<<D.canonical.z],J.u_zoom_transition=L,J.u_inv_rot_matrix=k,J.u_merc_center=O,J.u_camera_forward=K._camera.forward(),J.u_ecef_origin=h.dO(K.globeMatrix,D.toUnwrapped()),J.u_tile_matrix=K.globeMatrix,J.u_up_vector=N),J},Ju=(a,t,o,c)=>({u_matrix:a,u_emissive_strength:t,u_opacity:o,u_color:c}),Xf=(a,t,o,c,d,m,_,y,v)=>Object.assign(function(T,I,P,A,D,L){let{width:O,height:k}=A.imageManager.getPixelSize(I),N=Math.pow(2,L.tileID.overscaledZ),q=L.tileSize*Math.pow(2,A.transform.tileZoom)/N,Z=q*(L.tileID.canonical.x+L.tileID.wrap*N),G=q*L.tileID.canonical.y;return{u_image:0,u_pattern_tl:P.tl,u_pattern_br:P.br,u_texsize:[O,k],u_pattern_size:P.displaySize,u_pattern_units_to_pixels:D?[A.transform.width,-1*A.transform.height]:[1/h.az(L,1,A.transform.tileZoom),1/h.az(L,1,A.transform.tileZoom)],u_pixel_coord_upper:[Z>>16,G>>16],u_pixel_coord_lower:[65535&Z,65535&G]}}(0,m,_,c,y,v),{u_matrix:a,u_emissive_strength:t,u_opacity:o}),Ku=new Float32Array(h.bA([])),zd=(a,t,o,c,d,m,_,y,v,T,I,P,A,D=[0,0,0],L,O,k,N=1)=>{let q=d.style.light,Z=q.properties.get("position"),G=[-Z.x,-Z.y,Z.z],re=h.dH();q.properties.get("anchor")==="viewport"&&(h.dI(re,-d.transform.angle),h.dJ(G,G,re));let te=I.alphaMode==="MASK",se=q.properties.get("color").toNonPremultipliedRenderColor(null),K=A.paint.get("model-ambient-occlusion-intensity"),J=A.paint.get("model-color").constantOr(h.C.white).toNonPremultipliedRenderColor(null);return J.a=A.paint.get("model-color-mix-intensity").constantOr(0),k&&(J.r=k[0],J.g=k[1],J.b=k[2],J.a=k[3]),O&&(J.r=O.color.r,J.g=O.color.g,J.b=O.color.b,J.a=O.colorMix,P=O.emissionStrength,m*=O.opacity),{u_matrix:a,u_lighting_matrix:t,u_normal_matrix:o,u_node_matrix:c||Ku,u_lightpos:G,u_lightintensity:q.properties.get("intensity"),u_lightcolor:[se.r,se.g,se.b],u_camera_pos:D,u_opacity:m,u_baseTextureIsAlpha:0,u_alphaMask:+te,u_alphaCutoff:I.alphaCutoff,u_baseColorFactor:_.toNonPremultipliedRenderColor(null).toArray01(),u_emissiveFactor:y.toNonPremultipliedRenderColor(null).toArray01(),u_metallicFactor:v,u_roughnessFactor:T,u_baseColorTexture:5,u_metallicRoughnessTexture:6,u_normalTexture:7,u_occlusionTexture:8,u_emissionTexture:9,u_lutTexture:10,u_color_mix:J.toArray01(),u_aoIntensity:K,u_emissive_strength:P,u_occlusionTextureTransform:L||[0,0,0,0],u_dithered_discard_threshold:N}},Ld=(a,t=Ku,o=Ku)=>({u_matrix:a,u_instance:t,u_node_matrix:o}),ng={fillExtrusion:a=>({u_matrix:new h.c3(a),u_lightpos:new h.c0(a),u_lightintensity:new h.c1(a),u_lightcolor:new h.c0(a),u_vertical_gradient:new h.c1(a),u_opacity:new h.c1(a),u_edge_radius:new h.c1(a),u_width_scale:new h.c1(a),u_ao:new h.c2(a),u_height_type:new h.b$(a),u_base_type:new h.b$(a),u_tile_id:new h.c0(a),u_zoom_transition:new h.c1(a),u_inv_rot_matrix:new h.c3(a),u_merc_center:new h.c2(a),u_up_dir:new h.c0(a),u_height_lift:new h.c1(a),u_flood_light_color:new h.c0(a),u_vertical_scale:new h.c1(a),u_flood_light_intensity:new h.c1(a),u_ground_shadow_factor:new h.c0(a),u_front_cutoff_params:new h.c0(a)}),fillExtrusionDepth:a=>({u_matrix:new h.c3(a),u_edge_radius:new h.c1(a),u_width_scale:new h.c1(a),u_vertical_scale:new h.c1(a),u_height_type:new h.b$(a),u_base_type:new h.b$(a)}),fillExtrusionPattern:a=>({u_matrix:new h.c3(a),u_lightpos:new h.c0(a),u_lightintensity:new h.c1(a),u_lightcolor:new h.c0(a),u_vertical_gradient:new h.c1(a),u_height_factor:new h.c1(a),u_edge_radius:new h.c1(a),u_width_scale:new h.c1(a),u_ao:new h.c2(a),u_height_type:new h.b$(a),u_base_type:new h.b$(a),u_tile_id:new h.c0(a),u_zoom_transition:new h.c1(a),u_inv_rot_matrix:new h.c3(a),u_merc_center:new h.c2(a),u_up_dir:new h.c0(a),u_height_lift:new h.c1(a),u_image:new h.b$(a),u_texsize:new h.c2(a),u_pixel_coord_upper:new h.c2(a),u_pixel_coord_lower:new h.c2(a),u_tile_units_to_pixels:new h.c1(a),u_opacity:new h.c1(a),u_pattern_transition:new h.c1(a)}),fillExtrusionGroundEffect:a=>({u_matrix:new h.c3(a),u_opacity:new h.c1(a),u_ao_pass:new h.c1(a),u_meter_to_tile:new h.c1(a),u_ao:new h.c2(a),u_flood_light_intensity:new h.c1(a),u_flood_light_color:new h.c0(a),u_attenuation:new h.c1(a),u_edge_radius:new h.c1(a),u_fb:new h.b$(a),u_fb_size:new h.c1(a),u_dynamic_offset:new h.c1(a)}),fill:a=>({u_matrix:new h.c3(a),u_emissive_strength:new h.c1(a),u_ground_shadow_factor:new h.c0(a)}),fillPattern:a=>({u_matrix:new h.c3(a),u_emissive_strength:new h.c1(a),u_image:new h.b$(a),u_texsize:new h.c2(a),u_pixel_coord_upper:new h.c2(a),u_pixel_coord_lower:new h.c2(a),u_tile_units_to_pixels:new h.c1(a),u_ground_shadow_factor:new h.c0(a),u_pattern_transition:new h.c1(a)}),fillOutline:a=>({u_matrix:new h.c3(a),u_emissive_strength:new h.c1(a),u_world:new h.c2(a),u_ground_shadow_factor:new h.c0(a)}),fillOutlinePattern:a=>({u_matrix:new h.c3(a),u_emissive_strength:new h.c1(a),u_world:new h.c2(a),u_image:new h.b$(a),u_texsize:new h.c2(a),u_pixel_coord_upper:new h.c2(a),u_pixel_coord_lower:new h.c2(a),u_tile_units_to_pixels:new h.c1(a),u_ground_shadow_factor:new h.c0(a),u_pattern_transition:new h.c1(a)}),lineBlendComposite:a=>({u_image:new h.b$(a),u_opacity:new h.c1(a),u_blend_mode:new h.b$(a),u_max_density:new h.c1(a)}),lineBlendReduce:a=>({u_image:new h.b$(a),u_texel_size:new h.c2(a),u_first_pass:new h.b$(a)}),elevatedStructuresDepth:a=>({u_matrix:new h.c3(a),u_depth_bias:new h.c1(a)}),elevatedStructures:a=>({u_matrix:new h.c3(a),u_ground_shadow_factor:new h.c0(a)}),elevatedStructuresDepthReconstruct:a=>({u_matrix:new h.c3(a),u_camera_pos:new h.c0(a),u_depth_bias:new h.c1(a),u_height_scale:new h.c1(a),u_reset_depth:new h.c1(a)}),circle:h.dR,collisionBox:a=>({u_matrix:new h.c3(a),u_inv_rot_matrix:new h.c3(a),u_camera_to_center_distance:new h.c1(a),u_extrude_scale:new h.c2(a),u_zoom_transition:new h.c1(a),u_merc_center:new h.c2(a),u_tile_id:new h.c0(a)}),collisionCircle:a=>({u_matrix:new h.c3(a),u_inv_matrix:new h.c3(a),u_camera_to_center_distance:new h.c1(a),u_viewport_size:new h.c2(a)}
3063),debug:a=>({u_color:new h.dp(a),u_matrix:new h.c3(a),u_overlay:new h.b$(a),u_overlay_scale:new h.c1(a)}),clippingMask:a=>({u_matrix:new h.c3(a)}),heatmap:a=>({u_extrude_scale:new h.c1(a),u_intensity:new h.c1(a),u_matrix:new h.c3(a),u_inv_rot_matrix:new h.c3(a),u_merc_center:new h.c2(a),u_tile_id:new h.c0(a),u_zoom_transition:new h.c1(a),u_up_dir:new h.c0(a)}),heatmapTexture:a=>({u_image:new h.b$(a),u_color_ramp:new h.b$(a),u_opacity:new h.c1(a)}),hillshade:a=>({u_matrix:new h.c3(a),u_image:new h.b$(a),u_latrange:new h.c2(a),u_light:new h.c2(a),u_shadow:new h.dp(a),u_highlight:new h.dp(a),u_emissive_strength:new h.c1(a),u_accent:new h.dp(a)}),hillshadePrepare:a=>({u_matrix:new h.c3(a),u_image:new h.b$(a),u_dimension:new h.c2(a),u_zoom:new h.c1(a)}),line:h.dQ,linePattern:h.dP,raster:a=>({u_matrix:new h.c3(a),u_normalize_matrix:new h.c3(a),u_globe_matrix:new h.c3(a),u_merc_matrix:new h.c3(a),u_grid_matrix:new h.dq(a),u_tl_parent:new h.c2(a),u_scale_parent:new h.c1(a),u_fade_t:new h.c1(a),u_opacity:new h.c1(a),u_image0:new h.b$(a),u_image1:new h.b$(a),u_brightness_low:new h.c1(a),u_brightness_high:new h.c1(a),u_saturation_factor:new h.c1(a),u_contrast_factor:new h.c1(a),u_spin_weights:new h.c0(a),u_perspective_transform:new h.c2(a),u_raster_elevation:new h.c1(a),u_zoom_transition:new h.c1(a),u_merc_center:new h.c2(a),u_cutoff_params:new h.cS(a),u_colorization_mix:new h.cS(a),u_colorization_offset:new h.c1(a),u_color_ramp:new h.b$(a),u_texture_offset:new h.c2(a),u_texture_res:new h.c2(a),u_emissive_strength:new h.c1(a),u_zbias_factor:new h.c1(a)}),symbol:a=>({u_is_size_zoom_constant:new h.b$(a),u_is_size_feature_constant:new h.b$(a),u_size_t:new h.c1(a),u_size:new h.c1(a),u_camera_to_center_distance:new h.c1(a),u_rotate_symbol:new h.b$(a),u_aspect_ratio:new h.c1(a),u_fade_change:new h.c1(a),u_matrix:new h.c3(a),u_label_plane_matrix:new h.c3(a),u_coord_matrix:new h.c3(a),u_is_text:new h.b$(a),u_elevation_from_sea:new h.b$(a),u_pitch_with_map:new h.b$(a),u_texsize:new h.c2(a),u_texsize_icon:new h.c2(a),u_texture:new h.b$(a),u_texture_icon:new h.b$(a),u_gamma_scale:new h.c1(a),u_device_pixel_ratio:new h.c1(a),u_tile_id:new h.c0(a),u_zoom_transition:new h.c1(a),u_inv_rot_matrix:new h.c3(a),u_merc_center:new h.c2(a),u_camera_forward:new h.c0(a),u_tile_matrix:new h.c3(a),u_up_vector:new h.c0(a),u_ecef_origin:new h.c0(a),u_is_halo:new h.b$(a),u_icon_transition:new h.c1(a),u_color_adj_mat:new h.c3(a),u_scale_factor:new h.c1(a),u_ground_shadow_factor:new h.c0(a),u_inv_matrix:new h.c3(a),u_normal_scale:new h.c1(a),u_lutTexture:new h.b$(a),u_zoom:new h.c1(a),u_spp_fill_np_color:new h.cS(a),u_spp_halo_np_color:new h.cS(a),u_spp_opacity:new h.c1(a),u_spp_halo_width:new h.c1(a),u_spp_halo_blur:new h.c1(a),u_spp_emissive_strength:new h.c1(a),u_spp_occlusion_opacity:new h.c1(a),u_spp_z_offset:new h.c1(a),u_spp_translate_rotation:new h.c2(a)}),background:a=>({u_matrix:new h.c3(a),u_emissive_strength:new h.c1(a),u_opacity:new h.c1(a),u_color:new h.dp(a)}),backgroundPattern:a=>({u_matrix:new h.c3(a),u_emissive_strength:new h.c1(a),u_opacity:new h.c1(a),u_image:new h.b$(a),u_pattern_tl:new h.c2(a),u_pattern_br:new h.c2(a),u_texsize:new h.c2(a),u_pattern_size:new h.c2(a),u_pixel_coord_upper:new h.c2(a),u_pixel_coord_lower:new h.c2(a),u_pattern_units_to_pixels:new h.c2(a)}),terrainRaster:a=>({u_matrix:new h.c3(a),u_image0:new h.b$(a),u_image1:new h.b$(a),u_skirt_height:new h.c1(a),u_ground_shadow_factor:new h.c0(a),u_emissive_texture_available:new h.c1(a)}),skybox:a=>({u_matrix:new h.c3(a),u_sun_direction:new h.c0(a),u_cubemap:new h.b$(a),u_opacity:new h.c1(a),u_temporal_offset:new h.c1(a)}),skyboxGradient:a=>({u_matrix:new h.c3(a),u_color_ramp:new h.b$(a),u_center_direction:new h.c0(a),u_radius:new h.c1(a),u_opacity:new h.c1(a),u_temporal_offset:new h.c1(a)}),skyboxCapture:a=>({u_matrix_3f:new h.dq(a),u_sun_direction:new h.c0(a),u_sun_intensity:new h.c1(a),u_color_tint_r:new h.cS(a),u_color_tint_m:new h.cS(a),u_luminance:new h.c1(a)}),globeRaster:a=>({u_proj_matrix:new h.c3(a),u_globe_matrix:new h.c3(a),u_normalize_matrix:new h.c3(a),u_merc_matrix:new h.c3(a),u_zoom_transition:new h.c1(a),u_merc_center:new h.c2(a),u_image0:new h.b$(a),u_image1:new h.b$(a),u_grid_matrix:new h.dq(a),u_skirt_height:new h.c1(a),u_far_z_cutoff:new h.c1(a),u_frustum_tl:new h.c0(a),u_frustum_tr:new h.c0(a),u_frustum_br:new h.c0(a),u_frustum_bl:new h.c0(a),u_globe_pos:new h.c0(a),u_globe_radius:new h.c1(a),u_viewport:new h.c2(a),u_emissive_texture_available:new h.c1(a)}),globeAtmosphere:a=>({u_frustum_tl:new h.c0(a),u_frustum_tr:new h.c0(a),u_frustum_br:new h.c0(a),u_frustum_bl:new h.c0(a),u_horizon:new h.c1(a),u_transition:new h.c1(a),u_fadeout_range:new h.c1(a),u_atmosphere_fog_color:new h.cS(a),u_high_color:new h.cS(a),u_space_color:new h.cS(a),u_temporal_offset:new h.c1(a),u_horizon_angle:new h.c1(a)}),model:a=>({u_matrix:new h.c3(a),u_lighting_matrix:new h.c3(a),u_normal_matrix:new h.c3(a),u_node_matrix:new h.c3(a),u_lightpos:new h.c0(a),u_lightintensity:new h.c1(a),u_lightcolor:new h.c0(a),u_camera_pos:new h.c0(a),u_opacity:new h.c1(a),u_baseColorFactor:new h.cS(a),u_emissiveFactor:new h.cS(a),u_metallicFactor:new h.c1(a),u_roughnessFactor:new h.c1(a),u_baseTextureIsAlpha:new h.b$(a),u_alph
3063aMask:new h.b$(a),u_alphaCutoff:new h.c1(a),u_baseColorTexture:new h.b$(a),u_metallicRoughnessTexture:new h.b$(a),u_normalTexture:new h.b$(a),u_occlusionTexture:new h.b$(a),u_emissionTexture:new h.b$(a),u_lutTexture:new h.b$(a),u_color_mix:new h.cS(a),u_aoIntensity:new h.c1(a),u_emissive_strength:new h.c1(a),u_occlusionTextureTransform:new h.cS(a),u_dithered_discard_threshold:new h.c1(a)}),modelDepth:a=>({u_matrix:new h.c3(a),u_instance:new h.c3(a),u_node_matrix:new h.c3(a)}),groundShadow:a=>({u_matrix:new h.c3(a),u_ground_shadow_factor:new h.c0(a)}),stars:a=>({u_matrix:new h.c3(a),u_up:new h.c0(a),u_right:new h.c0(a),u_intensity_multiplier:new h.c1(a)}),occlusion:a=>({u_matrix:new h.c3(a),u_anchorPos:new h.c0(a),u_screenSizePx:new h.c2(a),u_occluderSizePx:new h.c2(a),u_color:new h.cS(a)})};class Os{constructor(t,o,c,d){this.id=Os.uniqueIdxCounter,Os.uniqueIdxCounter++,this.context=t;let m=t.gl;this.buffer=m.createBuffer(),this.dynamicDraw=!!c,this.context.unbindVAO(),t.bindElementBuffer.set(this.buffer),m.bufferData(m.ELEMENT_ARRAY_BUFFER,o.arrayBuffer,this.dynamicDraw?m.DYNAMIC_DRAW:m.STATIC_DRAW),this.dynamicDraw||d||o.destroy()}bind(){this.context.bindElementBuffer.set(this.buffer)}updateData(t){this.id=Os.uniqueIdxCounter,Os.uniqueIdxCounter++;let o=this.context.gl;this.context.unbindVAO(),this.bind(),o.bufferSubData(o.ELEMENT_ARRAY_BUFFER,0,t.arrayBuffer)}destroy(){this.buffer&&(this.context.gl.deleteBuffer(this.buffer),delete this.buffer)}}Os.uniqueIdxCounter=0;let Sr={Int8:"BYTE",Uint8:"UNSIGNED_BYTE",Int16:"SHORT",Uint16:"UNSIGNED_SHORT",Int32:"INT",Uint32:"UNSIGNED_INT",Float32:"FLOAT"};class Od{constructor(t,o,c,d,m,_){this.length=o.length,this.attributes=c,this.itemSize=o.bytesPerElement,this.dynamicDraw=d,this.instanceCount=_,this.context=t;let y=t.gl;this.buffer=y.createBuffer(),t.bindVertexBuffer.set(this.buffer),y.bufferData(y.ARRAY_BUFFER,o.arrayBuffer,this.dynamicDraw?y.DYNAMIC_DRAW:y.STATIC_DRAW),this.dynamicDraw||m||o.destroy()}bind(){this.context.bindVertexBuffer.set(this.buffer)}updateData(t){let o=this.context.gl;this.bind(),o.bufferSubData(o.ARRAY_BUFFER,0,t.arrayBuffer)}enableAttributes(t,o){for(let c of this.attributes){let d=o.getAttributeLocation(t,c.name);d!==-1&&t.enableVertexAttribArray(d)}}setVertexAttribPointers(t,o,c){for(let d of this.attributes){let m=o.getAttributeLocation(t,d.name);if(m!==-1){let _=d.offset+this.itemSize*(c||0);d.type==="Float32"?t.vertexAttribPointer(m,d.components,t.FLOAT,!1,this.itemSize,_):t.vertexAttribIPointer(m,d.components,t[Sr[d.type]],this.itemSize,_)}}}setVertexAttribDivisor(t,o,c){for(let d=0;d<this.attributes.length;d++){let m=o.getAttributeLocation(t,this.attributes[d].name);m!==-1&&this.instanceCount&&this.instanceCount>0&&t.vertexAttribDivisor(m,c)}}destroy(){this.buffer&&(this.context.gl.deleteBuffer(this.buffer),delete this.buffer)}}class En{constructor(t,o,c,d,m){this.context=t,this.width=o,this.height=c;let _=this.framebuffer=t.gl.createFramebuffer();d>0&&(this.colorAttachment0=new Dc(t,_,0)),d>1&&(this.colorAttachment1=new Dc(t,_,1)),m&&(this.depthAttachmentType=m,this.depthAttachment=m==="renderbuffer"?new Lf(t,_):new bd(t,_))}static createWithTexture(t,o,c,d,m){let _=t.gl;if(t.activeTexture.set(_.TEXTURE1),t.viewport.set([0,0,c,d]),o&&o.width===c&&o.height===d)return _.bindTexture(_.TEXTURE_2D,o.colorAttachment0.get()),t.bindFramebuffer.set(o.framebuffer),o;o&&o.destroy();let y=t.extRenderToTextureHalfFloat||t.extColorBufferFloat?t.gl.RGBA16F:t.gl.RGBA8,v=new h.T(t,{width:c,height:d,data:null},y);v.bind(_.LINEAR,_.CLAMP_TO_EDGE);let T=t.createFramebuffer(c,d,1,null);if(T.format=y,T.colorAttachment0.set(v.texture),m){let I=t.createRenderbuffer(_.DEPTH24_STENCIL8,c,d);t.bindFramebuffer.set(T.framebuffer),_.framebufferRenderbuffer(_.FRAMEBUFFER,_.DEPTH_STENCIL_ATTACHMENT,_.RENDERBUFFER,I),T._stencilRbo=I}return T}createColorAttachment(t,o){o===0?this.colorAttachment0=new Dc(t,this.framebuffer,0):o===1&&(this.colorAttachment1=new Dc(t,this.framebuffer,1))}removeColorAttachment(t,o){let c=this.context.gl,d;o===0?(d=this.colorAttachment0.get(),this.colorAttachment0=void 0):o===1&&(
3063d=this.colorAttachment1.get(),this.colorAttachment1=void 0),d&&c.deleteTexture(d)}destroy(){let t=this.context.gl;if(this.colorAttachment0){let o=this.colorAttachment0.get();o&&t.deleteTexture(o)}if(this.colorAttachment1){let o=this.colorAttachment1.get();o&&t.deleteTexture(o)}if(this.depthAttachment&&this.depthAttachmentType)if(this.depthAttachmentType==="renderbuffer"){let o=this.depthAttachment.get();o&&t.deleteRenderbuffer(o)}else{let o=this.depthAttachment.get();o&&t.deleteTexture(o)}this._stencilRbo&&(t.deleteRenderbuffer(this._stencilRbo),this._stencilRbo=null),t.deleteFramebuffer(this.framebuffer)}}class Fs{constructor(t,o){this.gl=t,this._pendingPrograms=new Set,this._compileStats={precompiled:0,onDemand:0,totalStallMs:0,maxStallMs:0,framesMissed:0,stalls:[]},this.clearColor=new Ef(this),this.clearDepth=new xl(this),this.clearStencil=new W_(this),this.colorMask=new X_(this),this.depthMask=new Y_(this),this.stencilMask=new J_(this),this.stencilFunc=new K_(this),this.stencilOp=new Q_(this),this.stencilTest=new pd(this),this.depthRange=new fd(this),this.depthTest=new md(this),this.depthFunc=new vl(this),this.blend=new Af(this),this.blendFunc=new Mf(this),this.blendColor=new Cf(this),this.blendEquation=new _d(this),this.cullFace=new Rs(this),this.cullFaceSide=new $u(this),this.frontFace=new Hu(this),this.program=new Pf(this),this.activeTexture=new zs(this),this.viewport=new gd(this),this.bindFramebuffer=new qu(this),this.bindRenderbuffer=new Df(this),this.bindTexture=new Rf(this),this.bindVertexBuffer=new yd(this),this.bindElementBuffer=new xd(this),this.bindVertexArrayOES=new eg(this),this.pixelStoreUnpack=new zf(this),this.pixelStoreUnpackPremultiplyAlpha=new Pc(this),this.pixelStoreUnpackFlipY=new tg(this),this.options=o?Object.assign({},o):{},this.options.extTextureFilterAnisotropicForceOff||(this.extTextureFilterAnisotropic=t.getExtension("EXT_texture_filter_anisotropic")||t.getExtension("MOZ_EXT_texture_filter_anisotropic")||t.getExtension("WEBKIT_EXT_texture_filter_anisotropic"),this.extTextureFilterAnisotropic&&(this.extTextureFilterAnisotropicMax=t.getParameter(this.extTextureFilterAnisotropic.MAX_TEXTURE_MAX_ANISOTROPY_EXT))),this.extDebugRendererInfo=t.getExtension("WEBGL_debug_renderer_info"),this.extDebugRendererInfo&&(this.renderer=t.getParameter(this.extDebugRendererInfo.UNMASKED_RENDERER_WEBGL),this.vendor=t.getParameter(this.extDebugRendererInfo.UNMASKED_VENDOR_WEBGL)),this.forceManualRenderingForInstanceIDShaders=o&&!!o.forceManualRenderingForInstanceIDShaders||this.renderer&&this.renderer.includes("PowerVR"),this.disableSymbolUBO=o&&!!o.forceDisableSymbolUBO,this.options.extTextureFloatLinearForceOff||(this.extTextureFloatLinear=t.getExtension("OES_texture_float_linear")),this.extRenderToTextureHalfFloat=t.getExtension("EXT_color_buffer_half_float"),this.extColorBufferFloat=t.getExtension("EXT_color_buffer_float"),this.extTimerQuery=t.getExtension("EXT_disjoint_timer_query_webgl2"),this.maxTextureSize=t.getParameter(t.MAX_TEXTURE_SIZE),this.maxUniformBlockSize=Math.min(t.getParameter(t.MAX_UNIFORM_BLOCK_SIZE),32768),this.maxUniformBufferBindings=t.getParameter(t.MAX_UNIFORM_BUFFER_BINDINGS),this.extBlendFuncExtended=t.getExtension("WEBGL_blend_func_extended"),this.extParallelShaderCompile=t.getExtension("KHR_parallel_shader_compile")}sweepPendingPrograms(){if(this._pendingPrograms.size!==0)for(let t of this._pendingPrograms)t.maybeFinalize()}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(t,o,c){return new Os(this,t,o,c)}createVertexBuffer(t,o,c,d,m){return new Od(this,t,o,c,d,m)}createRenderbuffer(t,o,c){let d=this.gl,m=d.createRenderbuffer();return this.bindRenderbuffer.set(m),d.renderbufferStorage(d.RENDERBUFFER,t,o,c),this.bindRenderbuffer.set(null),m}createFramebuffer(t,o,c,d){return new En(this,t,o,c,d)}clear({color:t,depth:o,stencil:c,colorMask:d}){let m=this.gl,_=0;t&&(_|=m.COLOR_BUFFER_BIT,this.clearColor.set(t.toNonPremultipliedRenderColor(null)),this.colorMask.set(d||[!0,!0,!0,!0])),o!==void 0&&(_|=m.DEPTH_BUFFER_BIT,this.depthRange.set([0,1]),this.clearDepth.set(o),this.depthMask.set(!0)),c!==void 0&&(_|=m.STENCIL_BUFFER_BIT,this.clearStencil.set(c),this.stencilMask.set(255)),m.clear(_)}setCullFace(t){t.enable===!1?this.cullFace.set(!1):(this.cullFace.set(!0),this.cullFaceSide.set(t.mode),this.frontFace.set(t.frontFace))}setDepthMode(t){t.func!==this.gl.ALWAYS||t.mask?(this.depthTest.set(!0),this.depthFunc.set(t.func),this.depthMask.set(t.mask),this.depthRange.set(t.range)):this.depthTest.set(!1)}setStencilMode(t){t.test.func!==this.gl.ALWAYS||t.mask?(this.stencilTest.set(!0),this.stencilMask.set(t.mask),this.stencilOp.set([t.fail,t.depthFail,t.pass]),this.stencilFunc.set({func:t.test.func,ref:t.ref,mask:t.test.mask})):this.stencilTest.set(!1)}setColorMode(t){h.b9(t.blendFunction,mt.Replace)?this.blend.set(!1):(this.blend.set(!0),this.blendFunc.set(t.blendFunction),this.blendColor.set(t.blendColor),t.blendEquation?this.blendEquation.set(t.blendEquation):this.blendEquation.setDefault()),this.colorMask.set(t.mask)}unbindVAO(){this.bindVertexArrayOES.set(null)}}let Bc;function Qu(a,t,o,c,d,m,_){let y=a.context,v=y.gl,T=a.transform,I=[h.aG(T.center.lng),h.aJ(T.center.lat)],P=o.layout.get("symbol-placement"),A=o.layout.get("text-variable-anchor"),D=o.layout.get("icon-rotation-alignment")==="map",L=o.layout.get("text-rotation-alignment")==="map",O=P!=="point",k=[],N=0,q=0;for(let K=0;K<c.length;K++){let J=c[K],oe=t.getTile(J),ue=oe.getBucket(o);if(!ue)continue;let de=ue.getProjection().createInversionMatrix(T,J.canonical),be=[],ve=cr(J,ue,T),Fe=!_&&D&&O,pe=_&&L&&O,Ie=A&&ue.hasTextData(),fe=ue.hasIconTextFit()&&Ie&&ue.hasIconData(),Pe=Fe||pe||_&&Ie||fe,Ce=ue.projection.name==="globe",Re=Ce?h.ai(T.zoom):0;Ce&&(be.push("PROJECTION_GLOBE_VIEW"),Pe&&be.push("PROJECTED_POS_ON_VIEWPORT"));let Ye=a.getOrCreateProgram("collisionBox",{defines:be}),$e=ve;d[0]===0&&d[1]===0||($e=a.translatePosMatrix(ve,oe,d,m));let je=_?ue.textCollisionBox:ue.iconCollisionBox,Ue=ue.collisionCircleArray;
3063if(Ue.length>0){let ot=h.bd(),et=$e;h.cB(ot,ue.placementInvProjMatrix,T.glCoordMatrix),h.cB(ot,ot,ue.placementViewportMatrix),k.push({circleArray:Ue,circleOffset:q,transform:et,invTransform:ot,projection:ue.getProjection()}),N+=Ue.length/4,q=N}if(!je)continue;a.terrain&&a.terrain.setupElevationDraw(oe,Ye);let at=Ce?[J.canonical.x,J.canonical.y,1<<J.canonical.z]:[0,0,0];Ye.draw(a,v.LINES,nt.disabled,gt.disabled,a.colorModeForRenderPass(),dt.disabled,$f($e,de,T,Re,I,oe,at,ue.getProjection()),o.id,je.layoutVertexBuffer,je.indexBuffer,je.segments,null,T.zoom,null,[je.collisionVertexBuffer,je.collisionVertexBufferExt])}if(!_||!k.length)return;let Z=a.getOrCreateProgram("collisionCircle"),G=new h.dS;G.resize(4*N),G._trim();let re=0;for(let K of k)for(let J=0;J<K.circleArray.length/4;J++){let oe=4*J,ue=K.circleArray[oe+0],de=K.circleArray[oe+1],be=K.circleArray[oe+2],ve=K.circleArray[oe+3];G.emplace(re++,ue,de,be,ve,0),G.emplace(re++,ue,de,be,ve,1),G.emplace(re++,ue,de,be,ve,2),G.emplace(re++,ue,de,be,ve,3)}(!Bc||Bc.length<2*N)&&(Bc=function(K){let J=2*K,oe=new h.dF;oe.resize(J),oe._trim();for(let ue=0;ue<J;ue++){let de=6*ue;oe.uint16[de+0]=4*ue+0,oe.uint16[de+1]=4*ue+1,oe.uint16[de+2]=4*ue+2,oe.uint16[de+3]=4*ue+2,oe.uint16[de+4]=4*ue+3,oe.uint16[de+5]=4*ue+0}return oe}(N));let te=y.createIndexBuffer(Bc,!0),se=y.createVertexBuffer(G,h.dT.members,!0);for(let K of k){let J=Hf(K.transform,K.invTransform,T,K.projection);Z.draw(a,v.TRIANGLES,nt.disabled,gt.disabled,a.colorModeForRenderPass(),dt.disabled,J,o.id,se,te,h.dB.simpleSegment(0,2*K.circleOffset,K.circleArray.length,K.circleArray.length/2),null,T.zoom)}se.destroy(),te.destroy()}let Tl=h.bd();function eh(a){let t=a._camera.getWorldToCamera(a.worldSize,1),o=h.aC([],t,a.globeMatrix);h.ba(o,o);let c=[0,0,0],d=[0,1,0,0];return h.aD(d,d,o),c[0]=d[0],c[1]=d[1],c[2]=d[2],h.ax(c,c),c}function Yf({width:a,height:t,anchor:o,textOffset:c,textScale:d},m){let{horizontalAlign:_,verticalAlign:y}=h.bJ(o),v=-(_-.5)*a,T=-(y-.5)*t,I=h.bK(o,c);return new h.P((v/d+I[0])*m,(T/d+I[1])*m)}function Qo(a,t,o,c,d,m,_,y,v,T){let I=a.text.placedSymbolArray,P=a.text.dynamicLayoutVertexArray,A=a.icon.dynamicLayoutVertexArray,D={},L=a.getProjection(),O=Su(_,L,d),k=d.elevation,N=L.upVectorScale(_.canonical,d.center.lat,d.worldSize).metersToTile;P.clear();for(let q=0;q<I.length;q++){let Z=I.get(q),{tileAnchorX:G,tileAnchorY:re,numGlyphs:te}=Z,se=Z.hidden||!Z.crossTileID||a.allowVerticalPlacement&&!Z.placedOrientation?null:c[Z.crossTileID];if(se){let K=0,J=0,oe=0,ue=a.elevationType==="road";if(k||ue){let Ce=ue?a.getElevationFeatureForText(q):null,Re=h.bx.getAtTileOffset(_,new h.P(G,re),k,Ce),[Ye,$e,je]=L.upVector(_.canonical,G,re);K=Re*Ye*N,J=Re*$e*N,oe=Re*je*N}let[de,be,ve,Fe]=Or(Z.projectedAnchorX+K,Z.projectedAnchorY+J,Z.projectedAnchorZ+oe,o?O:m),pe=Qr(d.getCameraToCenterDistance(L),Fe),Ie=h.bn(a.textSizeData,v,Z)*pe/h.bC;o&&(Ie*=a.tilePixelRatio/y);let fe=Yf(se,Ie);o?({x:de,y:be,z:ve}=L.projectTilePoint(G+fe.x,re+fe.y,_.canonical),[de,be,ve]=Or(de+K,be+J,ve+oe,m)):(t&&fe._rotate(-d.angle),de+=fe.x,be+=fe.y,ve=0);let Pe=a.allowVerticalPlacement&&Z.placedOrientation===h.bm.vertical?Math.PI/2:0;for(let Ce=0;Ce<te;Ce++)h.bp(P,de,be,ve,Pe);T&&Z.associatedIconIndex>=0&&(D[Z.associatedIconIndex]={x:de,y:be,z:ve,angle:Pe})}else br(te,P)}if(T){A.clear();let q=a.icon.placedSymbolArray;for(let Z=0;Z<q.length;Z++){let G=q.get(Z),{numGlyphs:re}=G,te=D[Z];if(G.hidden||!te)br(re,A);else{let{x:se,y:K,z:J,angle:oe}=te;for(let ue=0;ue<re;ue++)h.bp(A,se,K,J,oe)}}a.icon.dynamicLayoutVertexBuffer.updateData(A)}a.text.dynamicLayoutVertexBuffer.updateData(P)}function Fd(a,t,o,c,d,m,_={}){let y=o.paint.get("icon-translate"),v=o.paint.get("text-translate"),T=o.paint.get("icon-translate-anchor"),I=o.paint.get("text-translate-anchor"),P=o.layout.get("icon-rotation-alignment"),A=o.layout.get("text-rotation-alignment"),D=o.layout.get("icon-pitch-alignment"),L=o.layout.get("text-pitch-alignment"),O=o.layout.get("icon-keep-upright"),k=o.layout.get("text-keep-upright"),N=o.paint.get("icon-color-saturation"),q=o.paint.get("icon-color-contrast"),Z=o.paint.get("icon-color-brightness-min"),G=o.paint.get("icon-color-brightness-max"),re=o.layout.get("symbol-elevation-reference")==="sea",te=o.layout.get("icon-image-use-theme")==="none",se=a.context,K=se.gl,J=a.transform,oe=P==="map",ue=A==="map",de=D==="map",be=L==="map",ve=o.layout.get("symbol-sort-key").constantOr(1)!==void 0,Fe=!1,pe=a.depthModeForSublayer(0,nt.ReadOnly),Ie=new nt(a.context.gl.LEQUAL,nt.ReadOnly,a.depthRangeFor3D),fe=[h.aG(J.center.lng),h.aJ(J.center.lat)],Pe=o.layout.get("text-variable-anchor"),Ce=J.projection.name==="globe",Re=[],Ye=[0,-1,0];for(let $e of c){let je=t.getTile($e),Ue=je.getBucket(o);if(!Ue||Ue.projection.name==="mercator"&&Ce||Ue.fullyClipped)continue;let at=Ue.projection.name==="globe",ot=at?h.ai(J.zoom):0,et=Su($e,Ue.getProjection(),J),it=J.calculatePixelsToTileUnitsMatrix(je),ut=Pe&&Ue.hasTextData(),xt=Ue.hasIconTextFit()&&ut&&Ue.hasIconData(),_t=Ue.getProjection().createInversionMatrix(J,$e.canonical),Tt=(1<<je.tileID.canonical.z)*h.ak/a.transform.worldSize,yt=Qt=>{let vt=[0,0,0];if(Qt){let yi=a.style.directionalLight,fi=a.style.ambientLight;yi&&fi&&(vt=Ea(a.style,yi,fi))}return vt},Ft=Qt=>{if(a.context.disableSymbolUBO)return;Qt.push("USE_PAINT_PROPERTIES_UBO");let vt=Math.floor(a.context.maxUniformBlockSize/4),yi=Math.floor(vt/4);Qt.push(`MAX_UBO_SIZE_VEC4 ${yi}u`)},bt=Qt=>{J.depthOcclusionForSymbolsAndCircles&&(o.hasOcclusionOpacityProperties||a.terrain)&&(Qt.push("DEPTH_D24"),Qt.push("DEPTH_OCCLUSION"))},Nt=Qt=>{o.lut&&!te&&(o.lut.texture||(o.lut.texture=new h.dU(a.context,o.lut.image,[o.lut.image.height,o.lut.image.height,o.lut.image.height],se.gl.RGBA8)),se.activeTexture.set(se.gl.TEXTURE0+10),o.lut.texture&&o.lut.texture.bind(se.gl.LINEAR,se.gl.CLAMP_TO_EDGE),Qt.push("APPLY_LUT_ON_GPU"))},$t=()=>{let Qt=oe&&o.layout.get("symbol-placement")!=="point",vt=[];bt(vt),Nt(vt);let yi=Qt||xt,fi=Ue.elevationType==="road",ki=a.shadowRenderer,Bt=fi&&de&&!!ki&&ki.enabled,Yi=yt(Bt),Nn=fi&&de&&!a.terrain?Ie:pe,fn=o.paint.get("icon-image-cross-fade");a.terrainRenderModeElevated()&&de&&vt.push("PITCH_WITH_MAP_TERRAIN"),at&&(vt.push("PROJECTION_GLOBE_VIEW"),yi&&vt.push("PROJECTED_POS_ON_VIEWPORT")),fn>0&&Ue.hasAnySecondaryIcon&&vt.push("ICON_TRANSITION"),!Ue.icon.zOffsetVertexBuffer||fi&&a.terrain||vt.push("Z_OFFSET"),N===0&&q===0&&Z===0&&G===1||vt.push("COLOR_ADJUSTMENT"),Ue.sdfIcons&&vt.push("RENDER_SDF"),Bt&&vt.push("RENDER_SHADOWS","NORMAL_OFFSET"),fi&&de&&!a.terrain&&Ue.icon.orientationVertexBuffer&&vt.push("ELEVATED_ROADS"),Ft(vt);let An=se.disableSymbolUBO?Ue.icon.programConfigurations.get(o.id):null,cn=a.getOrCreateProgram("symbol",{c
3063onfig:An,defines:vt}),sr=je.imageAtlasTexture?je.imageAtlasTexture.size:[0,0],Kn=Ue.iconSizeData,Ri=h.bl(Kn,J.zoom),Ni=de||!J.isOrthographic,Ii=vr(et,je.tileID.canonical,de,oe,J,Ue.getProjection(),it),ei=sn(et,je.tileID.canonical,de,oe,J,Ue.getProjection(),it),oi=Ue.icon.uboBinder&&Ue.icon.uboBinder.cachedHeader&&256&Ue.icon.uboBinder.cachedHeader.dataDrivenMask?[0,0]:y,Ji=a.translatePosMatrix(ei,je,oi,T,!0),bn=a.translatePosMatrix(et,je,oi,T),Fi=yi?Tl:Ii,wn=oe&&!de&&!Qt,$r=Ye;!Ce&&!J.mercatorFromTransition||oe||($r=eh(J));let ar=at?$r:Ye,oo=o.getColorAdjustmentMatrix(N,q,Z,G),as=Wf(Kn.kind,Ri,wn,de,a,bn,Fi,Ji,re,!1,sr,[0,0],0,$e,ot,fe,_t,ar,Ue.getProjection(),Yi,Tt,oo,fn,null),ls=je.imageAtlasTexture?je.imageAtlasTexture:null,To=o.layout.get("icon-size").constantOr(0)!==1||Ue.iconsNeedLinear,Kc=Ue.sdfIcons||a.options.rotating||a.options.zooming||To||Ni?K.LINEAR:K.NEAREST,qs=Ue.sdfIcons&&o.paint.get("icon-halo-width").constantOr(1)!==0,Va=a.terrain&&de&&Qt?h.ba(h.bd(),Ii):Tl;if(Qt&&Ue.icon){let dp=h.bx.getAtTileOffsetFunc($e,J.center.lat,J.worldSize,Ue.getProjection()),Qc=xo(et,je.tileID.canonical,de,oe,J,Ue.getProjection(),it),Dm=o.layout.get("icon-size-scale-range"),Rm=h.aB(a.scaleFactor,Dm[0],Dm[1]);yc(Ue,et,a,!1,Qc,ei,de,O,dp,$e,Rm)}return{program:cn,buffers:Ue.icon,uniformValues:as,atlasTexture:ls,atlasTextureIcon:null,atlasInterpolation:Kc,atlasInterpolationIcon:null,isSDF:Ue.sdfIcons,hasHalo:qs,depthMode:Nn,tile:je,renderWithShadows:Bt,labelPlaneMatrixInv:Va}},bi=()=>{let Qt=ue&&o.layout.get("symbol-placement")!=="point",vt=[],yi=Qt||Pe||xt,fi=Ue.elevationType==="road",ki=a.shadowRenderer,Bt=fi&&be&&!!ki&&ki.enabled,Yi=yt(Bt),Nn=fi&&be&&!a.terrain?Ie:pe;a.terrainRenderModeElevated()&&be&&vt.push("PITCH_WITH_MAP_TERRAIN"),at&&(vt.push("PROJECTION_GLOBE_VIEW"),yi&&vt.push("PROJECTED_POS_ON_VIEWPORT")),!Ue.text.zOffsetVertexBuffer||fi&&a.terrain||vt.push("Z_OFFSET"),Ue.iconsInText&&vt.push("RENDER_TEXT_AND_SYMBOL"),vt.push("RENDER_SDF"),Bt&&vt.push("RENDER_SHADOWS","NORMAL_OFFSET"),fi&&be&&!a.terrain&&Ue.text.orientationVertexBuffer&&vt.push("ELEVATED_ROADS"),bt(vt),Ft(vt);let fn=se.disableSymbolUBO?Ue.text.programConfigurations.get(o.id):null,An=a.getOrCreateProgram("symbol",{config:fn,defines:vt}),cn,sr=[0,0],Kn=null,Ri=Ue.textSizeData;Ue.iconsInText&&(sr=je.imageAtlasTexture?je.imageAtlasTexture.size:[0,0],Kn=je.imageAtlasTexture?je.imageAtlasTexture:null,cn=be||!J.isOrthographic||a.options.rotating||a.options.zooming||Ri.kind==="composite"||Ri.kind==="camera"?K.LINEAR:K.NEAREST);let Ni=je.glyphAtlasTexture?je.glyphAtlasTexture.size:[0,0],Ii=o.layout.get("text-size-scale-range"),ei=h.aB(a.scaleFactor,Ii[0],Ii[1]),oi=h.bl(Ri,J.zoom,ei),Ji=vr(et,je.tileID.canonical,be,ue,J,Ue.getProjection(),it),bn=sn(et,je.tileID.canonical,be,ue,J,Ue.getProjection(),it),Fi=Ue.text.uboBinder&&Ue.text.uboBinder.cachedHeader&&256&Ue.text.uboBinder.cachedHeader.dataDrivenMask?[0,0]:v,wn=a.translatePosMatrix(bn,je,Fi,I,!0),$r=a.translatePosMatrix(et,je,Fi,I),ar=yi?Tl:Ji,oo=ue&&!be&&!Qt,as=Ye;!Ce&&!J.mercatorFromTransition||ue||(as=eh(J));let ls=Wf(Ri.kind,oi,oo,be,a,$r,ar,wn,re,!0,Ni,sr,0,$e,ot,fe,_t,at?as:Ye,Ue.getProjection(),Yi,Tt,null,null,ei),To=je.glyphAtlasTexture?je.glyphAtlasTexture:null,Kc=K.LINEAR,qs=o.paint.get("text-halo-width").constantOr(1)!==0,Va=a.terrain&&be&&Qt?h.ba(h.bd(),Ji):Tl;if(Qt&&Ue.text){let dp=h.bx.getAtTileOffsetFunc($e,J.center.lat,J.worldSize,Ue.getProjection()),Qc=xo(et,je.tileID.canonical,be,ue,J,Ue.getProjection(),it);yc(Ue,et,a,!0,Qc,bn,be,k,dp,$e,ei)}return{program:An,buffers:Ue.text,uniformValues:ls,atlasTexture:To,atlasTextureIcon:Kn,atlasInterpolation:Kc,atlasInterpolationIcon:cn,isSDF:!0,hasHalo:qs,depthMode:Nn,tile:je,renderWithShadows:Bt,labelPlaneMatrixInv:Va}},ai=Ue.icon.segments.get().length,Zt=Ue.text.segments.get().length,It=ai&&!_.onlyText?$t():null,Et=Zt&&!_.onlyIcons?bi():null,li=o.paint.get("icon-opacity").constantOr(1),Di=o.paint.get("text-opacity").constantOr(1);if(ve&&Ue.canOverlap){Fe=!0;let Qt=li&&!_.onlyText?Ue.icon.segments.get():[],vt=Di&&!_.onlyIcons?Ue.text.segments.get():[];for(let yi of Qt)Re.push({segments:new h.dB([yi]),sortKey:yi.sortKey,state:It});for(let yi of vt)Re.push({segments:new h.dB([yi]),sortKey:yi.sortKey,state:Et})}else _.onlyText||Re.push({segments:li?Ue.icon.segments:new h.dB([]),sortKey:0,state:It}),_.onlyIcons||Re.push({segments:Di?Ue.text.segments:new h.dB([]),sortKey:0,state:Et})}Fe&&Re.sort(($e,je)=>$e.sortKey-je.sortKey);for(let $e of Re){let je=$e.state;if(je)if(a.terrain?a.terrain.setupElevationDraw(je.tile,je.program,{useDepthForOcclusion:J.depthOcclusionForSymbolsAndCircles,labelPlaneMatr
3063ixInv:je.labelPlaneMatrixInv}):a.setupDepthForOcclusion(J.depthOcclusionForSymbolsAndCircles,je.program),se.activeTexture.set(K.TEXTURE0),je.atlasTexture&&je.atlasTexture.bind(je.atlasInterpolation,K.CLAMP_TO_EDGE,!0),je.atlasTextureIcon&&(se.activeTexture.set(K.TEXTURE1),je.atlasTextureIcon&&je.atlasTextureIcon.bind(je.atlasInterpolationIcon,K.CLAMP_TO_EDGE,!0)),je.renderWithShadows&&a.shadowRenderer.setupShadows(je.tile.tileID.toUnwrapped(),je.program,"vector-tile"),a.uploadCommonLightUniforms(a.context,je.program),je.hasHalo){let Ue=je.uniformValues;Ue.u_is_halo=1,Xt(je.buffers,$e.segments,o,a,je.program,je.depthMode,d,m,Ue,2),Ue.u_is_halo=0}else{if(je.isSDF){let Ue=je.uniformValues;je.hasHalo&&(Ue.u_is_halo=1,Xt(je.buffers,$e.segments,o,a,je.program,je.depthMode,d,m,Ue,1)),Ue.u_is_halo=0}Xt(je.buffers,$e.segments,o,a,je.program,je.depthMode,d,m,je.uniformValues,1)}}}function Xt(a,t,o,c,d,m,_,y,v,T){let I=c.context,P=I.gl,A=[a.dynamicLayoutVertexBuffer,a.opacityVertexBuffer,a.iconTransitioningVertexBuffer,a.globeExtVertexBuffer,a.zOffsetVertexBuffer,a.orientationVertexBuffer];a.featureIdBuffer&&A.push(a.featureIdBuffer);let D=a.uboBinder?null:a.programConfigurations.get(o.id);if(a.uboBinder){a.uboBinder.layer=o;let k=c.transform.zoom,N=c.style.getBrightness?c.style.getBrightness():null,q=a.uboBinder.getConstantUniformValues(k,N);v.u_spp_fill_np_color=q.fill_np_color,v.u_spp_halo_np_color=q.halo_np_color,v.u_spp_opacity=q.opacity,v.u_spp_halo_width=q.halo_width,v.u_spp_halo_blur=q.halo_blur,v.u_spp_emissive_strength=q.emissive_strength,v.u_spp_occlusion_opacity=q.occlusion_opacity,v.u_spp_z_offset=q.z_offset;let Z=o.paint.get(a.uboBinder.isText?"text-translate-anchor":"icon-translate-anchor"),G=a.uboBinder.cachedHeader&&256&a.uboBinder.cachedHeader.dataDrivenMask&&Z==="map"?c.transform.angle:0;v.u_spp_translate_rotation=[Math.cos(G),Math.sin(G)]}let{batchIndices:L,batchSegments:O}=a.getBatchGrouping(t);for(let k of L){let N=O.get(k);a.uboBinder&&a.uboBinder.bind(I,d.program,k),d.draw(c,P.TRIANGLES,m,_,y,dt.disabled,v,o.id,a.layoutVertexBuffer,a.indexBuffer,N,o.paint,c.transform.zoom,D,A,T)}}function Sl(a,t,o,c,d,m){let _=o.paint.get("line-width"),y=o.paint.get("line-emissive-strength").isConstant(),v=o.paint.get("line-emissive-strength").constantOr(0),T=o.paint.get("line-occlusion-opacity"),I=o.layout.get("line-elevation-reference"),P=o.layout.get("line-width-unit")==="meters",A=I==="sea",D=!(!a.terrain||!a.terrain.enabled),L=a.context,O=L.gl;if(o.hasElevatedBuckets&&a.transform.projection.name==="globe")return;let k=o.layout.get("line-cross-slope"),N=k!==void 0,q=k<1,Z=d||a.colorModeForDrapableLayerRenderPass(y?v:null),G=a.terrain&&a.terrain.renderingToTexture||m,re=G?1:h.o.devicePixelRatio,te=o.paint.get("line-dasharray"),se=te.constantOr(1),K=o.layout.get("line-cap"),J=te.constantOr(null),oe=K.constantOr(null),ue=o.paint.get("line-pattern"),de=ue.constantOr(1),be=o.paint.get("line-pattern-cross-fade"),ve=ue.constantOr(null),Fe=o.paint.get("line-opacity").constantOr(1),pe=!de&&Fe!==1||a.depthOcclusion&&T>0&&T<1,Ie=o.paint.get("line-gradient"),fe=de?"linePattern":"line",Pe=h.dX(o),Ce;if(G&&a.terrain&&a.terrain.clipOrMaskOverlapStencilType()&&(pe=!1),T!==0&&a.depthOcclusion){let Ue=o.paint._values["line-opacity"];Ue&&Ue.value&&Ue.value.kind==="constant"?Ce=Ue.value:h.w(`Occlusion opacity for layer ${o.id} is supported only when line-opacity isn't data-driven.`)}_.value.kind!=="constant"&&_.value.isLineProgressConstant===!1&&Pe.push("VARIABLE_LINE_WIDTH"),a._debugParams.showElevationIdDebug&&Pe.push("DEBUG_ELEVATION_ID"),G&&(a.emissiveMode!=="dual-source-blending"||y?a.emissiveMode==="mrt-fallback"&&Pe.push("USE_MRT1"):Pe.push("DUAL_SOURCE_BLENDING"));let Re={},Ye=(Ue,at,ot,et,it,ut)=>{for(let xt of Ue){let _t=t.getTile(xt);if(de&&!_t.patternsLoaded())continue;let Tt=_t.getBucket(o);if(!Tt||Tt.elevationType!=="none"&&!it||Tt.elevationType==="none"&&it)continue;a.prepareDrawTile();let yt=[...at],Ft=a.shadowRenderer,bt=Tt.elevationType==="road"&&!!Ft&&Ft.enabled,Nt=[0,0,0];if(bt){let Bt=a.style.directionalLight,Yi=a.style.ambientLight;Bt&&Yi&&(Nt=Ea(a.style,Bt,Yi)),yt.push("RENDER_SHADOWS","NORMAL_OFFSET")}let $t=Tt.programConfigurations.get(o.id),bi=!1;if(ve&&_t.imageAtlas){let Bt=h.dY.from(ve),Yi=Bt.getPrimary().scaleSelf(re).toString(),Nn=_t.imageAtlas.patternPositions.get(Yi),fn=Bt.getSecondary(),An=fn?_t.imageAtlas.patternPositions.get(fn.scaleSelf(re).toString()):null;bi=!!Nn&&!!An,Nn&&$t.setConstantPatternPositions(Nn,An)}be>0&&(bi||$t.getPatternTransitionVertexBuffer("line-pattern"))&&yt.push("LINE_PATTERN_TRANSITION"),Tt.elevationGroundScaleVertexBuffer&&yt.push("ELEVATION_GROUND_SCALE");let ai=a.isTileAffectedByFog(xt),Zt=a.getOrCreateProgram(fe,{config:$t,defines:yt,overrideFog:ai});if(!de&&J&&oe&&_t.lineAtlas){let Bt=_t.lineAtlas.getDash(J,oe);Bt&&$t.setConstantPatternPositions(Bt)}bt&&Ft.setupShadows(_t.tileID.toUnwrapped(),Zt,"vector-tile");let[It,Et]=o.paint.get("line-trim-offset");(oe==="round"||oe==="square")&&It!==Et&&(It===0&&(It-=1),Et===1&&(Et+=1));let li=G?xt.projMatrix:null,Di=P?1/Tt.tileToMeter/h.az(_t,1,a.transform.zoom):1,Qt=P?1/Tt.tileToMeter/h.az(_t,1,Math.floor(a.transform.zoom)):1,vt=se?o.paint._values["line-floorwidth"]:null,yi;if(vt&&vt.value.kind==="constant"){let Bt=Tt.zoom;Bt in Re||(Re[Bt]=Math.max(.01,o.widthExpression().evaluate({zoom:Bt}))),yi=vt.value.value;let Yi=Math.floor(a.transform.zoom);
3063vt.value.value=Re[Bt]*Math.pow(2,Yi-_t.tileID.overscaledZ)}let fi=de?h.dZ(a,_t,o,li,re,Di,Qt,[It,Et],Nt,be):h.d_(a,_t,o,li,Tt.lineClipsArray.length,re,Di,Qt,[It,Et],Nt);if(Ie){let Bt=Tt.gradients[o.id],Yi=Bt.texture;if(o.gradientVersion!==Bt.version){let Nn=256;if(o.stepInterpolant){let fn=t.getSource().maxzoom,An=xt.canonical.z===fn?Math.ceil(1<<a.transform.maxZoom-xt.canonical.z):1;Nn=h.aB(h.d$(Tt.maxLineLength/h.ak*1024*An),256,L.maxTextureSize)}Bt.gradient=h.e0({expression:o.gradientExpression(),evaluationKey:"lineProgress",resolution:Nn,image:Bt.gradient||void 0,clips:Tt.lineClipsArray}),Bt.texture?Bt.texture.update(Bt.gradient):Bt.texture=new h.T(L,Bt.gradient,O.RGBA8),Bt.version=o.gradientVersion,Yi=Bt.texture}L.activeTexture.set(O.TEXTURE1),Yi.bind(o.stepInterpolant?O.NEAREST:O.LINEAR,O.CLAMP_TO_EDGE)}se&&(L.activeTexture.set(O.TEXTURE0),_t.lineAtlasTexture&&_t.lineAtlasTexture.bind(O.LINEAR,O.REPEAT),$t.updatePaintBuffers()),de&&(L.activeTexture.set(O.TEXTURE0),_t.imageAtlasTexture&&_t.imageAtlasTexture.bind(O.LINEAR,O.CLAMP_TO_EDGE),$t.updatePaintBuffers()),it&&a.terrain.setupElevationDraw(_t,Zt),a.uploadCommonUniforms(L,Zt,xt.toUnwrapped());let ki=Bt=>{Ce!=null&&(Ce.value=Fe*T),Zt.draw(a,O.TRIANGLES,ot,Bt,Z,dt.disabled,fi,o.id,Tt.layoutVertexBuffer,Tt.indexBuffer,Tt.segments,o.paint,a.transform.zoom,$t,[Tt.layoutVertexBuffer2,Tt.patternVertexBuffer,Tt.zOffsetVertexBuffer,Tt.elevationIdColVertexBuffer,Tt.elevationGroundScaleVertexBuffer]),Ce!=null&&(Ce.value=Fe)};if(pe&&!it){let Bt=a.stencilModeForClipping(xt).ref;Bt===0&&G&&L.clear({stencil:0});let Yi={func:O.EQUAL,mask:255};
3063fi.u_alpha_discard_threshold=.8,ki(new gt(Yi,Bt,255,O.KEEP,O.KEEP,O.INVERT)),fi.u_alpha_discard_threshold=0,ki(new gt(Yi,Bt,255,O.KEEP,O.KEEP,O.KEEP))}else fi.u_alpha_discard_threshold=pe&&it&&ut?.8:0,ki(it?et:a.stencilModeForClipping(xt));yi!==void 0&&(vt.value.value=yi)}},$e=a.depthModeForSublayer(0,nt.ReadOnly),je=new nt(a.depthOcclusion?O.GREATER:O.LEQUAL,nt.ReadOnly,a.depthRangeFor3D);if(o.hasNonElevatedBuckets){let Ue=!G&&a.terrain;T!==0&&Ue?h.w(`Occlusion opacity for layer ${o.id} is supported on terrain only if the layer has line-z-offset enabled.`):Ue?h.w(`Cannot render non-elevated lines in immediate mode when terrain is enabled. Layer: ${o.id}.`):Ye(c,Pe,$e,gt.disabled,!1,!0)}if(o.hasElevatedBuckets){I==="hd-road-markup"?D||($e=je,Pe.push("ELEVATED_ROADS")):(Pe.push("ELEVATED"),$e=je,N&&Pe.push(q?"CROSS_SLOPE_HORIZONTAL":"CROSS_SLOPE_VERTICAL"),A&&Pe.push("ELEVATION_REFERENCE_SEA"));let Ue=pe?a.stencilModeFor3D():gt.disabled;a.forceTerrainMode=!0,Ye(c,Pe,$e,Ue,!0,!0),pe&&Ye(c,Pe,$e,Ue,!0,!1),a.forceTerrainMode=!1}pe&&(a.resetStencilClippingMasks(),G&&L.clear({stencil:0})),T===0||a.depthOcclusion||G||a.layersWithOcclusionOpacity.push(a.currentLayer)}class th{destroy(){this.fbo&&(this.fbo.destroy(),this.fbo=null),this.drapeFbo&&(this.drapeFbo.destroy(),this.drapeFbo=null)}}class Jf{constructor(t){this.pbo=t.createBuffer(),this.sync=null,this.fboA=null,this.fboB=null,this.maxDensity=0}destroy(t){this.sync&&(t.deleteSync(this.sync),this.sync=null),t.deleteBuffer(this.pbo),this.fboA&&(this.fboA.destroy(),this.fboA=null),this.fboB&&(this.fboB.destroy(),this.fboB=null)}}let kc={additive:{clearColor:new h.C(0,0,0,0),colorMode:mt.additiveAlphaWeighted,compositeUniformValue:1},multiply:{clearColor:new h.C(1,1,1,1),colorMode:mt.multiply,compositeUniformValue:0}};function Nc(a){return!(!a.extRenderToTextureHalfFloat&&!a.extColorBufferFloat)}function Uc(a,t){return a==="additive"&&Nc(t)?mt.additiveAlphaWeightedUnboundedAlpha:kc[a].colorMode}function Bs(a,t,o){let c=a.context,d=c.gl,m=o.width,_=o.height,y=o.colorAttachment0.get();t.lineBlendDensityReadback||(t.lineBlendDensityReadback=new Jf(d));let v=t.lineBlendDensityReadback,T=0,I=!0;for(;m>1||_>1;){let D=Math.max(1,Math.floor(m/2)),L=Math.max(1,Math.floor(_/2)),O=T===0?"fboA":"fboB";v[O]=En.createWithTexture(c,v[O],D,L,!1);let k=v[O];c.bindFramebuffer.set(k.framebuffer),c.viewport.set([0,0,D,L]),c.activeTexture.set(d.TEXTURE0),d.bindTexture(d.TEXTURE_2D,y),a.getOrCreateProgram("lineBlendReduce").draw(a,d.TRIANGLES,nt.disabled,gt.disabled,mt.unblended,dt.disabled,Gf(0,[1/m,1/_],I),t.id,a.viewportBuffer,a.quadTriangleIndexBuffer,a.viewportSegments,t.paint,a.transform.zoom),m=D,_=L,y=k.colorAttachment0.get(),T=1-T,I=!1}let P=Nc(c),A=P?16:4;v.sync&&(d.deleteSync(v.sync),v.sync=null),d.bindBuffer(d.PIXEL_PACK_BUFFER,v.pbo),d.bufferData(d.PIXEL_PACK_BUFFER,A,d.STREAM_READ),d.readPixels(0,0,1,1,d.RGBA,P?d.FLOAT:d.UNSIGNED_BYTE,0),d.bindBuffer(d.PIXEL_PACK_BUFFER,null),v.sync=d.fenceSync(d.SYNC_GPU_COMMANDS_COMPLETE,0),c.viewport.set([0,0,a.width,a.height])}function es(a,t,o){if(!Nc(a.context))return;let c=t.lineBlendDensityReadback;c&&c.sync?(function(d,m,_){if(d.sync&&m.getSyncParameter(d.sync,m.SYNC_STATUS)===m.SIGNALED){if(m.deleteSync(d.sync),d.sync=null,m.bindBuffer(m.PIXEL_PACK_BUFFER,d.pbo),Nc(_)){let y=new Float32Array(4);m.getBufferSubData(m.PIXEL_PACK_BUFFER,0,y);let v=y[1];d.maxDensity=Math.max(2*(v>0?y[0]/v:0),1)}else d.maxDensity=1;m.bindBuffer(m.PIXEL_PACK_BUFFER,null)}}(c,a.context.gl,a.context),c.sync||(Bs(a,t,o),a.style.map.triggerRepaint())):(Bs(a,t,o),a.style.map.triggerRepaint())}function qe(a,t,o,c,d,m){let _=a.context,y=_.gl,v=o==="additive"?1:t.paint.get("line-opacity").constantOr(1),T=o==="additive"?function(P,A){let D=A.paint.get("line-blend-additive-clamp");if(D>0)return D;let L=A.lineBlendDensityReadback;return L&&L.maxDensity!==0?L.maxDensity:null}(0,t):1;if(T===null)return;_.bindFramebuffer.set(d),m&&_.viewport.set([0,0,m[0],m[1]]),_.activeTexture.set(y.TEXTURE0),y.bindTexture(y.TEXTURE_2D,c.colorAttachment0.get());let I=Uc(o,a.context);a.getOrCreateProgram("lineBlendComposite").draw(a,y.TRIANGLES,nt.disabled,gt.disabled,I,dt.disabled,((P,A,D,L)=>({u_image:0,u_opacity:A,u_blend_mode:D,u_max_density:L}))(0,v,kc[o].compositeUniformValue,T),t.id,a.viewportBuffer,a.quadTriangleIndexBuffer,a.viewportSegments,t.paint,a.transform.zoom)}function Ze(a,t){let o=1<<a.canonical.z,c=(t.x*o-a.canonical.x-a.wrap*o)*h.ak,d=(t.y*o-a.canonical.y)*h.ak,m=h.e1(t.z,t.y);return h.cU(c,d,m)}function La(a,t,o,c,d){if(!o.layout||o.layout.get("fill-elevation-reference")==="none"||o.paint.get("fill-opacity").constantOr(1)===0)return;
3063let m=a.context.gl,_=new nt(a.context.gl.LEQUAL,nt.ReadWrite,a.depthRangeFor3D),y=new nt(a.context.gl.GREATER,nt.ReadWrite,a.depthRangeFor3D),v=function(D){let L=.01;return D.isOrthographic&&(L=h.aj(1e-4,L,h.cP(D.pitch>=Po?1:D.pitch/Po))),2*L}(a.transform),T=a.transform.getFreeCameraOptions().position,I="elevatedStructuresDepthReconstruct",P=a.getOrCreateProgram(I,{defines:["DEPTH_RECONSTRUCTION"]}),A=a.getOrCreateProgram(I);for(let D of c){let L=t.getTile(D),O=L.getBucket(o);if(!O)continue;let k=O.elevatedStructures;if(!k||!k.depthSegments)continue;let N=O.elevationBufferData.heightRange,q=Ze(D.toUnwrapped(),T),Z=a.translatePosMatrix(D.projMatrix,L,o.paint.get("fill-translate"),o.paint.get("fill-translate-anchor")),G,re,te,se;if(d==="initialize"){if(!N||N.min>=1||k.depthSegments.segments[0].primitiveLength===0)continue;G=Oc(Z,q,v,1,0),re=_,te=k.depthSegments,se=P}else if(d==="reset"){if(!N||N.min>=0||k.maskSegments.segments[0].primitiveLength===0)continue;G=Oc(Z,q,0,0,1),re=y,te=k.maskSegments,se=P}else if(d==="geometry"){if(k.depthSegments.segments[0].primitiveLength===0)continue;G=Oc(Z,q,v,1,0),re=_,te=k.depthSegments,se=A}se.draw(a,m.TRIANGLES,re,gt.disabled,mt.disabled,dt.disabled,G,o.id,k.vertexBuffer,k.indexBuffer,te,o.paint,a.transform.zoom)}}function wi(a,t,o,c){let{painter:d,sourceCache:m,layer:_,coords:y,colorMode:v,elevationType:T,terrainEnabled:I,pass:P}=a,A=d.context.gl,D=_.paint.get("fill-pattern"),L=_.paint.get("fill-pattern-cross-fade"),O=D.constantOr(null),k=T;T!=="road"||t&&!I||(k="none");let N=k==="road",q=a.painter.shadowRenderer,Z=N&&!!q&&q.enabled,G=new nt(d.context.gl.LEQUAL,nt.ReadOnly,d.depthRangeFor3D),re=[0,0,0];if(Z){let J=d.style.directionalLight,oe=d.style.ambientLight;J&&oe&&(re=Ea(d.style,J,oe))}let te=D&&D.constantOr(1),se=d.terrain&&d.terrain.renderingToTexture,K=(J,oe)=>{let ue,de,be,ve,Fe;oe?(ue=te&&!_.getPaintProperty("fill-outline-color")?"fillOutlinePattern":"fillOutline",be=A.LINES):(ue=te?"fillPattern":"fill",be=A.TRIANGLES);for(let pe of y){let Ie=m.getTile(pe);if(te&&!Ie.patternsLoaded())continue;let fe=Ie.getBucket(_);if(!fe)continue;let Pe=t?fe.elevationBufferData:fe.bufferData;if(Pe.isEmpty())continue;d.prepareDrawTile();let Ce=Pe.programConfigurations.get(_.id),Re=d.isTileAffectedByFog(pe),Ye=[],$e=[];N&&(Ye.push("ELEVATED_ROADS"),$e.push(Pe.elevatedLayoutVertexBuffer)),Z&&Ye.push("RENDER_SHADOWS","NORMAL_OFFSET"),se&&o&&Ye.push("USE_MRT1"),te&&(d.context.activeTexture.set(A.TEXTURE0),Ie.imageAtlasTexture&&Ie.imageAtlasTexture.bind(A.LINEAR,A.CLAMP_TO_EDGE),Ce.updatePaintBuffers());let je=!1;if(O&&Ie.imageAtlas){let it=Ie.imageAtlas,ut=h.dY.from(O),xt=ut.getPrimary().scaleSelf(h.o.devicePixelRatio).toString(),_t=ut.getSecondary(),Tt=it.patternPositions.get(xt),yt=_t?it.patternPositions.get(_t.scaleSelf(h.o.devicePixelRatio).toString()):null;je=!!Tt&&!!yt,Tt&&Ce.setConstantPatternPositions(Tt,yt)}L>0&&(je||Ce.getPatternTransitionVertexBuffer("fill-pattern"))&&Ye.push("FILL_PATTERN_TRANSITION");let Ue=d.getOrCreateProgram(ue,{config:Ce,overrideFog:Re,defines:Ye}),at=d.translatePosMatrix(pe.projMatrix,Ie,_.paint.get("fill-translate"),_.paint.get("fill-translate-anchor"));Z&&q.setupShadows(Ie.tileID.toUnwrapped(),Ue,"vector-tile");let ot=_.paint.get("fill-emissive-strength");if(oe){ve=Pe.lineIndexBuffer,Fe=Pe.lineSegments;let it=d.terrain&&d.terrain.renderingToTexture?d.terrain.drapeBufferSize:[A.drawingBufferWidth,A.drawingBufferHeight];de=ue==="fillOutlinePattern"&&te?jf(at,ot,d,Ie,it,re,L):Vf(at,ot,it,re)}else ve=Pe.indexBuffer,Fe=Pe.triangleSegments,de=te?Ad(at,ot,d,Ie,re,L):Ed(at,ot,re);d.uploadCommonUniforms(d.context,Ue,pe.toUnwrapped());let et=J;(T==="road"&&!I||T==="offset")&&(et=G),Ue.draw(d,be,et,c||d.stencilModeForClipping(pe),v,dt.disabled,de,_.id,Pe.layoutVertexBuffer,ve,Fe,_.paint,d.transform.zoom,Ce,$e)}};d.renderPass===P&&K(d.depthModeForSublayer(1,d.renderPass==="opaque"?nt.ReadWrite:nt.ReadOnly),!1),k==="none"&&d.renderPass==="translucent"&&_.paint.get("fill-antialias")&&K(d.depthModeForSublayer(_.getPaintProperty("fill-outline-color")?2:0,nt.ReadOnly),!0)}let he=new Float32Array(16);function Vc(a,t,o,c,d,m,_,y){o.resetLayerRenderingStats(a);let v=a.context,T=v.gl,I=a.transform,P=o.paint.get("fill-extrusion-pattern"),A=o.paint.get("fill-extrusion-pattern-cross-fade"),D=P.constantOr(null),L=P.constantOr(1),O=o.paint.get("fill-extrusion-opacity"),k=a.style.enable3dLights(),N=o.paint.get(k&&!L?"fill-extrusion-ambient-occlusion-wall-radius":"fill-extrusion-ambient-occlusion-radius"),q=[o.paint.get("fill-extrusion-ambient-occlusion-intensity"),N],Z=o.layout.get("fill-extrusion-edge-radius"),G=Z>0&&!o.paint.get("fill-extrusion-rounded-roof"),re=G?0:Z,te=I.projection.name==="globe"?h.e4():0,se=I.projection.name==="globe",K=se?h.ai(I.zoom):0,J=[h.aG(I.center.lng),h.aJ(I.center.lat)],oe=o.paint.get("fill-extrusion-flood-light-color-use-theme").
3063constantOr("default")==="none",ue=o.paint.get("fill-extrusion-flood-light-color").toNonPremultipliedRenderColor(oe?null:o.lut).toArray01().slice(0,3),de=o.paint.get("fill-extrusion-flood-light-intensity"),be=o.paint.get("fill-extrusion-vertical-scale"),ve=o.paint.get("fill-extrusion-line-width").constantOr(1)!==0,Fe=o.paint.get("fill-extrusion-height-alignment"),pe=o.paint.get("fill-extrusion-base-alignment"),Ie=Cs(a,o.paint.get("fill-extrusion-cutoff-fade-range")),fe=o.paint.get("fill-extrusion-front-cutoff"),Pe=Gc(I.pitch,fe,!!a.terrain),Ce=Pe[2]<1;Ce&&(a.maxFrontCutoffRawStart=Math.max(a.maxFrontCutoffRawStart,fe[0]));let Re=[],Ye;se&&Re.push("PROJECTION_GLOBE_VIEW"),q[0]>0&&Re.push("FAUX_AO"),G&&Re.push("ZERO_ROOF_RADIUS"),y&&Re.push("HAS_CENTROID"),de>0&&Re.push("FLOOD_LIGHT"),Ie.shouldRenderCutoff&&Re.push("RENDER_CUTOFF"),Ce&&Re.push("RENDER_FRONT_CUTOFF"),ve&&Re.push("RENDER_WALL_MODE");let $e=a.renderPass==="shadow",je=a.shadowRenderer,Ue=$e&&!!je,at=$e?dt.disabled:dt.backCCW;a.shadowRenderer&&(a.shadowRenderer.useNormalOffset=!0);let ot=[0,0,0];if(je){let ut=a.style.directionalLight,xt=a.style.ambientLight;ut&&xt&&(ot=Ea(a.style,ut,xt)),$e||(Re.push("RENDER_SHADOWS"),je.useNormalOffset&&Re.push("NORMAL_OFFSET")),Ye=Re.concat(["SHADOWS_SINGLE_CASCADE"])}let et=Ue?"fillExtrusionDepth":L?"fillExtrusionPattern":"fillExtrusion",it=o.getLayerRenderingStats();for(let ut of c){let xt=t.getTile(ut),_t=xt.getBucket(o);if(!_t||_t.projection.name!==I.projection.name)continue;let Tt=!1;je&&(Tt=je.getMaxCascadeForTile(ut.toUnwrapped())===0);let yt=a.isTileAffectedByFog(ut),Ft=_t.programConfigurations.get(o.id),bt=!1;if(D&&xt.imageAtlas){let Et=xt.imageAtlas,li=h.dY.from(D),Di=li.getPrimary().scaleSelf(h.o.devicePixelRatio).toString(),Qt=li.getSecondary(),vt=Et.patternPositions.get(Di),yi=Qt?Et.patternPositions.get(Qt.scaleSelf(h.o.devicePixelRatio).toString()):null;bt=!!vt&&!!yi,vt&&Ft.setConstantPatternPositions(vt,yi)}A>0&&(bt||Ft.getPatternTransitionVertexBuffer("fill-extrusion-pattern"))&&Re.push("FILL_EXTRUSION_PATTERN_TRANSITION");
3063let Nt=a.getOrCreateProgram(et,{config:Ft,defines:Tt?Ye:Re,overrideFog:yt});if(a.terrain&&a.terrain.setupElevationDraw(xt,Nt,{useMeterToDem:!0}),!_t.centroidVertexBuffer){let Et=Nt.getAttributeLocation(T,"a_centroid_pos");Et!==-1&&T.vertexAttribI4ui(Et,0,0,0,0)}!$e&&je&&je.setupShadows(xt.tileID.toUnwrapped(),Nt,"vector-tile"),L&&(a.context.activeTexture.set(T.TEXTURE0),xt.imageAtlasTexture&&xt.imageAtlasTexture.bind(T.LINEAR,T.CLAMP_TO_EDGE),Ft.updatePaintBuffers());let $t=o.paint.get("fill-extrusion-vertical-gradient"),bi=1/_t.tileToMeter,ai;if($e&&je){if(em(xt.tileID,_t.maxHeight,a))continue;let Et=je.calculateShadowPassMatrixFromTile(xt.tileID.toUnwrapped());ai=Nf(Et,re,bi,be,Fe,pe)}else{let Et=a.translatePosMatrix(ut.expandedProjMatrix,xt,o.paint.get("fill-extrusion-translate"),o.paint.get("fill-extrusion-translate-anchor")),li=I.projection.createInversionMatrix(I,ut.canonical);ai=L?Uf(Et,a,$t,O,q,re,bi,ut,xt,te,Fe,pe,K,J,li,ue,be,A):Lc(Et,a,$t,O,q,re,bi,ut,te,Fe,pe,K,J,li,ue,be,de,ot,Pe)}a.uploadCommonUniforms(v,Nt,ut.toUnwrapped(),null,Ie);let Zt=_t.segments;if(I.projection.name==="mercator"&&!$e&&(Zt=_t.getVisibleSegments(xt.tileID,a.terrain,a.transform.getFrustum(0)),!Zt.get().length))continue;if(it)if($e)for(let Et of Zt.get())it.numRenderedVerticesInShadowPass+=Et.primitiveLength;else for(let Et of Zt.get())it.numRenderedVerticesInTransparentPass+=Et.primitiveLength;let It=[];(a.terrain||y)&&It.push(_t.centroidVertexBuffer),se&&It.push(_t.layoutVertexExtBuffer),ve&&It.push(_t.wallVertexBuffer),Nt.draw(a,v.gl.TRIANGLES,d,m,_,at,ai,o.id,_t.layoutVertexBuffer,_t.indexBuffer,Zt,o.paint,a.transform.zoom,Ft,It)}a.shadowRenderer&&(a.shadowRenderer.useNormalOffset=!1)}class jc{constructor(){this.translate=[0,0],this.translateAnchor="map",this.edgeRadius=0,this.cutoffFadeRange=0}}function Gc(a,t,o){if(!(t[2]<1)||o)return[0,0,1];let c=180*a/Math.PI;if(c<15)return[-.5,t[1],t[2]];let d=Math.min(1,Math.max(0,(c-15)/5)),m=d*d*(3-2*d);return[-.5*(1-m)+t[0]*m,t[1],t[2]]}function io(a,t,o,c,d,m,_,y,v,T,I,P,A,D,L,O,k,N,q,Z,G){let re=t.context,te=re.gl,se=t.transform,K=t.transform.zoom,J=[],oe=a.translate,ue=a.translateAnchor,de=a.edgeRadius,be=Cs(t,a.cutoffFadeRange);I==="clear"?(J.push("CLEAR_SUBPASS"),Z&&(J.push("CLEAR_FROM_TEXTURE"),re.activeTexture.set(te.TEXTURE0),Z.bind(te.LINEAR,te.CLAMP_TO_EDGE))):I==="sdf"?J.push("SDF_SUBPASS"):I==="emissive"&&(J.push("USE_MRT1"),re.activeTexture.set(te.TEXTURE0),Z.bind(te.LINEAR,te.CLAMP_TO_EDGE)),N&&J.push("HAS_CENTROID"),be.shouldRenderCutoff&&J.push("RENDER_CUTOFF");let ve=(Fe,pe,Ie,fe,Pe)=>{let Ce=J;pe.groundRadiusBuffer!=null&&(Ce=J.concat("HAS_ATTRIBUTE_a_flood_light_ground_radius"));let Re=pe.programConfigurations.get(c.id),Ye=t.isTileAffectedByFog(Fe),$e=t.getOrCreateProgram("fillExtrusionGroundEffect",{config:Re,defines:Ce,overrideFog:Ye}),je=((at,ot,et,it,ut,xt,_t,Tt,yt,Ft,bt)=>({u_matrix:ot,u_opacity:et,u_ao_pass:it?1:0,u_meter_to_tile:ut,u_ao:xt,u_flood_light_intensity:_t,u_flood_light_color:Tt,u_attenuation:yt,u_edge_radius:Ft,u_fb:0,u_fb_size:bt,u_dynamic_offset:1}))(0,fe,P,T,Pe,[A,D*Pe],L,O,k,K>=17?0:de*Pe,Z?Z.size[0]:0),Ue=[];N&&Ue.push(pe.hiddenByLandmarkVertexBuffer),pe.groundRadiusBuffer!=null&&Ue.push(pe.groundRadiusBuffer),t.uploadCommonUniforms(re,$e,Fe.toUnwrapped(),null,be),$e.draw(t,re.gl.TRIANGLES,m,_,y,v,je,c.id,pe.vertexBuffer,pe.indexBuffer,Ie,c.paint,K,Re,Ue)};for(let Fe of d){let pe=o.getTile(Fe),Ie=pe.getBucket(c);if(!Ie||Ie.projection.name!==se.projection.name||!Ie.groundEffect||Ie.groundEffect&&!Ie.groundEffect.hasData())continue;let fe=Ie.groundEffect,Pe=1/Ie.tileToMeter;{let Ce=t.translatePosMatrix(Fe.projMatrix,pe,oe,ue),Re=fe.getDefaultSegment();ve(Fe,fe,Re,Ce,Pe)}if(q)for(let Ce=0;Ce<4;Ce++){let Re=h.e2[Ce](Fe),Ye=o.getTile(Re);if(!Ye)continue;let $e=Ye.getBucket(c);if(!$e||$e.projection.name!==se.projection.name||!$e.groundEffect||$e.groundEffect&&!$e.groundEffect.hasData())continue;let je=$e.groundEffect,Ue,at;Ce===0?(Ue=[-h.ak,0,0],at=1):Ce===1?(Ue=[h.ak,0,0],at=0):Ce===2?(Ue=[0,-h.ak,0],at=3):(Ue=[0,h.ak,0],at=2);let ot=je.regionSegments[at];ot&&(h.bB(he,Fe.projMatrix,Ue),ve(Fe,je,ot,t.translatePosMatrix(he,pe,oe,ue),Pe))}}}
3063function Kf(a,t,o,c,d,m,_){c.centroidVertexArray.length===0&&c.createCentroidsBuffer();let y=m?m.findDEMTileFor(o):null;if(!(y&&y.dem||_))return;m&&y&&y.dem&&c.selfDEMTileTimestamp!==y.dem._timestamp&&(c.borderDoneWithNeighborZ=[-1,-1,-1,-1],c.selfDEMTileTimestamp=y.dem._timestamp);let v=(N,q)=>{(N.flags|q.flags)&h.e5?(N.flags|=h.e5,q.flags|=h.e5):(N.flags&=~h.e5,q.flags&=~h.e5)},T=N=>new h.P(Math.ceil((N+h.e6)*h.e7),0),I=(N,q,Z)=>{let G=Math.ceil((N+h.e6)*h.e7),re=Math.floor(Math.max(0,Math.min(h.ak-1,Z))/4);return new h.P(G,re<<5|(3&q)<<3|7)},P=N=>{let q=t.getSource().minzoom,Z=re=>{let te=t.getTileByID(re);if(te&&te.hasData())return te.getBucket(d)},G=[0,-1,1];for(let re of G){if(N.overscaledZ+re<q)continue;let te=Z(N.calculateScaledKey(N.overscaledZ+re));if(te)return te}},A=[0,0,0],D=(N,q)=>(A[0]=Math.min(N.min.y,q.min.y),A[1]=Math.max(N.max.y,q.max.y),A[2]=h.ak-q.min.x>N.max.x?q.min.x-h.ak:N.max.x,A),L=(N,q)=>(A[0]=Math.min(N.min.x,q.min.x),A[1]=Math.max(N.max.x,q.max.x),A[2]=h.ak-q.min.y>N.max.y?q.min.y-h.ak:N.max.y,A),O=[(N,q)=>D(N,q),(N,q)=>D(q,N),(N,q)=>L(N,q),(N,q)=>L(q,N)],k=(N,q,Z,G,re,te,se)=>{if(!m)return 0;let K=[[te?Z:N,te?N:Z,0],[te?Z:q,te?q:Z,0]],J=se<0?h.ak+se:se,oe=[te?J:(N+q)/2,te?(N+q)/2:J,0];return Z===0&&se<0||Z!==0&&se>0?m.getForTilePoints(re,[oe],!0,G):K.push(oe),m.getForTilePoints(o,K,!0,y),Math.max(K[0][2],K[1][2],oe[2])/m.exaggeration()};for(let N=0;N<4;N++){let q=c.borderFeatureIndices[N];if(q.length===0)continue;let Z=h.e2[N](o),G=P(Z);if(!(G&&G instanceof h.e3))continue;let re=m?m.findDEMTileFor(Z):null;if(!(re&&re.dem||_)||(m&&re&&re.dem&&c.borderDEMTileTimestamp[N]!==re.dem._timestamp&&(c.borderDoneWithNeighborZ[N]=-1,c.borderDEMTileTimestamp[N]=re.dem._timestamp),c.borderDoneWithNeighborZ[N]===G.canonical.z))continue;G.centroidVertexArray.length===0&&G.createCentroidsBuffer();let te=(N<2?1:5)-N,se=G.borderDoneWithNeighborZ[te]!==c.canonical.z,K=G.borderFeatureIndices[te],J=0;if(c.canonical.z!==G.canonical.z){for(let be of q)c.showCentroid(c.featuresOnBorder[be]);if(se)for(let be of K)G.showCentroid(G.featuresOnBorder[be]);c.borderDoneWithNeighborZ[N]=G.canonical.z,G.borderDoneWithNeighborZ[te]=c.canonical.z;continue}let oe=new Map,ue=new Set,de=new Set;for(let be=0;be<K.length;be++){let ve=G.featuresOnBorder[K[be]];ve.buildingId!==void 0&&oe.set(ve.buildingId,be)}for(let be of q){let ve=c.featuresOnBorder[be],Fe=c.centroidData.get(ve.centroidDataIndex);if(ve.buildingId===void 0)continue;let pe=oe.get(ve.buildingId);if(pe===void 0)continue;let Ie=G.featuresOnBorder[K[pe]],fe=G.centroidData.get(Ie.centroidDataIndex);ue.add(be),de.add(pe),_&&v(Fe,fe);let Pe=Fe.groupCentroidPos.x!==0||Fe.groupCentroidPos.y!==0?Fe.groupCentroidPos:ve.centroid(),Ce=fe.groupCentroidPos.x!==0||fe.groupCentroidPos.y!==0?fe.groupCentroidPos:Ie.centroid(),Re=N<2?Math.round((Pe.y+Ce.y)/2):Math.round((Pe.x+Ce.x)/2),Ye=ve.intersectsCount()>1||Ie.intersectsCount()>1;{let $e=0;if(re&&re.dem&&!Ye){let je=O[N](Fe,fe),Ue=N%2?h.ak-1:0;$e=k(je[0],Math.min(h.ak-1,je[1]),Ue,re,Z,N<2,je[2])}Fe.centroidXY=I($e,N,Re),fe.centroidXY=I($e,te,Re)}if(c.writeCentroidToBuffer(Fe),G.writeCentroidToBuffer(fe),ve.buildingId!==void 0){for(let $e of c.centroidData)$e.buildingId===ve.buildingId&&$e!==Fe&&($e.centroidXY=Fe.centroidXY,c.writeCentroidToBuffer($e));for(let $e of G.centroidData)$e.buildingId===ve.buildingId&&$e!==fe&&($e.centroidXY=fe.centroidXY,G.writeCentroidToBuffer($e))}}for(let be of q){if(ue.has(be))continue;let ve=c.featuresOnBorder[be],Fe=c.centroidData.get(ve.centroidDataIndex),pe=ve.borders[N],Ie;for(;J<K.length;){if(de.has(J)){J++;continue}Ie=G.featuresOnBorder[K[J]];let fe=Ie.borders[te];if(fe[1]>pe[0]+3||fe[0]>pe[0]-3)break;G.showCentroid(Ie),J++}if(Ie&&J<K.length){let fe=J,Pe=0;for(;;)if(de.has(J)){if(++J===K.length)break;Ie=G.featuresOnBorder[K[J]]}else{if(Ie.borders[te][0]>pe[1]-3||(Pe++,++J===K.length))break;Ie=G.featuresOnBorder[K[J]]}for(;fe<K.length&&de.has(fe);)fe++;if(fe>=K.length){c.showCentroid(ve);continue}Ie=G.featuresOnBorder[K[fe]];let Ce=!1;if(Pe>=1){let $e=Ie.borders[te];Math.abs(pe[0]-$e[0])<3&&Math.abs(pe[1]-$e[1])<3&&(Pe=1,Ce=!0,J=fe+1)}else if(Pe===0){c.showCentroid(ve);continue}let Re=G.centroidData.get(Ie.centroidDataIndex);_&&Ce&&v(Fe,Re);let Ye=ve.intersectsCount()>1||Ie.intersectsCount()>1;
3063if(Pe>1)J=fe,Fe.centroidXY=Re.centroidXY=new h.P(0,0);else if(re&&re.dem&&!Ye){let $e=O[N](Fe,Re),je=N%2?h.ak-1:0,Ue=k($e[0],Math.min(h.ak-1,$e[1]),je,re,Z,N<2,$e[2]);Fe.centroidXY=Re.centroidXY=T(Ue)}else Ye?Fe.centroidXY=Re.centroidXY=new h.P(0,0):(Fe.centroidXY=c.encodeBorderCentroid(ve),Re.centroidXY=G.encodeBorderCentroid(Ie));c.writeCentroidToBuffer(Fe),G.writeCentroidToBuffer(Re)}else c.showCentroid(ve)}c.borderDoneWithNeighborZ[N]=G.canonical.z,G.borderDoneWithNeighborZ[te]=c.canonical.z}(c.needsCentroidUpdate||!c.centroidVertexBuffer&&c.centroidVertexArray.length!==0)&&c.uploadCentroid(a)}let Qf=[1,0,0],Il=[0,1,0],rg=[0,0,1];function em(a,t,o){let c=o.transform,d=o.shadowRenderer;if(!d)return!0;let m=o.frameCounter,_=o.currentShadowCascade,y=o._shadowCullCache;if(!y||y.frame!==m||y.cascade!==_){let N=c.tileSize*d._cascades[_].scale,q=c.scaleZoom(N),Z=d.shadowDirection,G=[Z[0],Z[1],-Z[2]],re=[Qf,Il,rg,G,[G[0],0,G[2]],[0,G[1],G[2]]];y={frame:m,cascade:_,cameraFrustum:h.cn.fromInvProjectionMatrix(c.invProjMatrix,c.worldSize,q,c.projection.name!=="globe"),edges:re,shadowDir:G,ws:N,zoom:q},o._shadowCullCache=y}let{cameraFrustum:v,edges:T,shadowDir:I,ws:P,zoom:A}=y,D=t;if(c.elevation){let N=c.elevation.getMinMaxForTile(a);N&&(D+=N.max)}D/=h.e8(c.center.lat,A);let L=d.computeSimplifiedTileShadowVolume(a.toUnwrapped(),D,P,I);if(!L)return!1;let{vertices:O,planes:k}=L;return v.intersectsPrecise(O,k,T)===0||d.getCurrentCascadeFrustum().intersectsPrecise(O,k,T)===0}let tm=(a,t,o,c,d,m,_,y,v,T=[0,0,1])=>({u_matrix:a,u_normal_matrix:t,u_opacity:o,u_faux_facade_ao_intensity:c,u_camera_pos:d,u_tile_to_meter:m,u_facade_emissive_chance:_,u_flood_light_color:y,u_flood_light_intensity:v,u_front_cutoff_params:T}),ih=a=>({u_matrix:a}),Bd=a=>({u_matrix:a}),kd=new Float32Array(16),Oa=new Float32Array(16);function Fa(a){let{painter:t,source:o,layer:c,coords:d}=a,m=a.defines,_=t.context,y=t.renderPass==="shadow",v=t.renderPass==="light-beam",T=t.shadowRenderer,I=h.e8(t.transform.center.lat,t.transform.zoom),P=Cs(t,c.paint.get("building-cutoff-fade-range"));P.shouldRenderCutoff&&(m=m.concat("RENDER_CUTOFF"));let A=c.paint.get("building-front-cutoff"),D=A[2]<1&&!t.terrain,L=Gc(t.transform.pitch,A,!!t.terrain);D&&(m=m.concat("RENDER_FRONT_CUTOFF"),t.maxFrontCutoffRawStart=Math.max(t.maxFrontCutoffRawStart,A[0])),a.floodLightIntensity>0&&(m=m.concat("FLOOD_LIGHT"));for(let O of d){let k=o.getTile(O),N=k.getBucket(c);if(!N)continue;T&&T.getMaxCascadeForTile(O.toUnwrapped())===0&&(m=m.concat("SHADOWS_SINGLE_CASCADE"));let q=N.programConfigurations.get(c.id),Z,G,re=t.translatePosMatrix(O.expandedProjMatrix,k,[0,0],"map");h.cE(kd,re,[1,1,a.verticalScale]);let te=kd,se;if(y&&T){if(em(k.tileID,N.maxHeight*I,t))continue;let J=T.calculateShadowPassMatrixFromTile(k.tileID.toUnwrapped());h.cE(J,J,[1,1,a.verticalScale]),se=Bd(J),Z=G=t.getOrCreateProgram("buildingDepth",{config:q,defines:m,overrideFog:!1})}else if(v)Z=G=t.getOrCreateProgram("buildingBloom",{config:q,defines:m,overrideFog:!1}),se=ih(te);else{let J=t.transform.calculatePosMatrix(O.toUnwrapped(),t.transform.worldSize);h.cE(J,J,[1,1,a.verticalScale]),h.cE(Oa,J,[1,-1,1/I]),h.ba(Oa,Oa),h.e9(Oa,Oa);let oe=Oa,ue=t.transform.getFreeCameraOptions().position,de=1<<O.canonical.z;if(se=tm(te,oe,a.opacity,a.facadeAOIntensity,[((ue.x-O.wrap)*de-O.canonical.x)*h.ak,(ue.y*de-O.canonical.y)*h.ak,ue.z*de*h.ak],N.tileToMeter,a.facadeEmissiveChance,a.floodLightColor,a.floodLightIntensity,L),G=t.getOrCreateProgram("building",{config:q,defines:m,overrideFog:!1}),a.depthOnly===!0)Z=G;else{let be=m.concat(["BUILDING_FAUX_FACADE","HAS_ATTRIBUTE_a_faux_facade_color_emissive"]);Z=t.getOrCreateProgram("building",{config:q,defines:be,overrideFog:!1})}T&&(T.setupShadowsFromMatrix(J,G,!0),Z!==G&&T.setupShadowsFromMatrix(J,Z,!0))}let K=(J,oe)=>{if(v){let ue=J.entranceBloom;oe.draw(t,_.gl.TRIANGLES,a.depthMode,gt.disabled,a.blendMode,dt.disabled,se,c.id,ue.layoutVertexBuffer,ue.indexBuffer,ue.segmentsBucket,c.paint,t.transform.zoom,q,[ue.layoutAttenuationBuffer,ue.layoutColorBuffer])}else{let ue=J.segmentsBucket,de=[J.layoutNormalBuffer,J.layoutCentroidBuffer,J.layoutColorBuffer,J.layoutFloodLightDataBuffer];J.layoutFacadePaintBuffer&&(de=de.concat([J.layoutFacadeDataBuffer,J.layoutFacadeVerticalRangeBuffer,J.layoutFacadePaintBuffer])),oe.draw(t,_.gl.TRIANGLES,a.depthMode,gt.disabled,a.blendMode,y?dt.disabled:dt.backCW,se,c.id,J.layoutVertexBuffer,J.indexBuffer,ue,c.paint,t.transform.zoom,q,de)}};t.uploadCommonUniforms(_,G,O.toUnwrapped(),null,P),N.buildingWithoutFacade&&K(N.buildingWithoutFacade,G),N.buildingWithFacade&&(Z!==G&&t.uploadCommonUniforms(_,Z,O.toUnwrapped(),null,P),K(N.buildingWithFacade,Z))}}function El(a,t,o,c,d,m,_,y,v,T,I,P,A,D){let L=a.context.gl,O=a.depthModeForSublayer(1,nt.ReadOnly,L.LEQUAL,!0),k=.1*(1-(N=I))+3*N;var N;let q=a._showOverdrawInspector,Z=P,G=new jc;q||io(G,a,t,o,c,O,new gt({func:L.ALWAYS,mask:255},255,255,L.KEEP,L.KEEP,L.REPLACE),new mt([L.ONE,L.ONE,L.ONE,L.ONE],h.C.transparent,[!1,!1,!1,!0],L.MIN),dt.disabled,d,"sdf",m,_,y,v,T,k,Z,!1,void 0);{let re=q?gt.disabled:new gt({func:L.EQUAL,mask:255},255,255,L.KEEP,L.DECR,L.DECR),te=q?a.colorModeForRenderPass():new mt([L.ONE_MINUS_DST_ALPHA,L.DST_ALPHA,L.ONE,L.ONE],h.C.transparent,[!0,!0,!0,!0]);io(G,a,t,o,c,O,re,te,dt.disabled,d,"color",m,_,y,v,T,k,Z,!1,void 0)}}let ks=.05,im=(a,t,o,c,d,m,_,y,v,T,I,P)=>({u_matrix:a,u_normalize_matrix:t,u_globe_matrix:o,u_merc_matrix:c,u_grid_matrix:d,u_tl_parent:m,u_scale_parent:T,u_fade_t:I.mix,u_opacity:I.opacity,u_image0:0,u_image1:1,u_raster_elevation:P,u_zoom_transition:_,u_merc_center:y,u_cutoff_params:v}),nm=(a,t,o,c,d,m,_,y,v,T)=>({u_particle_texture:a,u_particle_texture_side_len:t,u_tile_offset:o,u_velocity:c,u_color_ramp:m,u_velocity_res:d,u_max_speed:_,u_uv_offset:y,u_data_scale:[255*v[0],255*v[1]],u_data_offset:T,u_particle_pos_scale:1.1,u_particle_pos_offset:[ks,ks]}),rm=(a,t,o,c,d,m,_,y,v,T)=>({u_particle_texture:a,u_particle_texture_side_len:t,u_velocity:o,u_velocity_res:c,u_max_speed:d,u_speed_factor:m,u_reset_rate:_,u_rand_seed:Math.random(),u_uv_offset:y,u_data_scale:[255*v[0],255*v[1]],u_data_offset:T,u_particle_pos_scale:1.1,u_particle_pos_offset:[ks,ks]});var om=h.ea([{name:"a_index",type:"Int16",components:1}]);
3063class sm{constructor(t,o,c,d){let m={width:c[0],height:c[1],data:null},_=t.gl;this.targetColorTexture=new h.T(t,m,_.RGBA8,{useMipmap:!1}),this.backgroundColorTexture=new h.T(t,m,_.RGBA8,{useMipmap:!1}),this.context=t,this.updateParticleTexture(o,d),this.lastInvalidatedAt=0}updateParticleTexture(t,o){if(this.particleTextureDimension===o.width)return;(this.particleTexture0||this.particleTexture1||this.particleIndexBuffer||this.particleSegment)&&(this.particleTexture0.destroy(),this.particleTexture1.destroy(),this.particleIndexBuffer.destroy(),this.particleSegment.destroy());let c=this.context.gl,d=o.width*o.height;this.particleTexture0=new h.T(this.context,o,c.RGBA8,{premultiply:!1,useMipmap:!1}),this.particleTexture1=new h.T(this.context,o,c.RGBA8,{premultiply:!1,useMipmap:!1});let m=new h.eb;m.reserve(d);for(let _=0;_<d;_++)m.emplaceBack(_);this.particleIndexBuffer=this.context.createVertexBuffer(m,om.members,!0),this.particleSegment=h.dB.simpleSegment(0,0,this.particleIndexBuffer.length,0),this.particleTextureDimension=o.width}update(t){return!(this.lastInvalidatedAt<t&&(this.lastInvalidatedAt=h.o.now(),1))}destroy(){this.targetColorTexture.destroy(),this.backgroundColorTexture.destroy(),this.particleIndexBuffer.destroy(),this.particleTexture0.destroy(),this.particleTexture1.destroy(),this.particleSegment.destroy()}}function og(a,t,o){if(!a)return null;let c=t.getTextureDescriptor(a,o,!0);if(!c)return null;let{texture:d,mix:m,offset:_,tileSize:y,buffer:v,format:T}=c;if(!d||!T)return null;let I=!1;return T==="uint32"&&(I=!0,m[3]=0,m=Dd(h.ec,m,[0,o.paint.get("raster-particle-max-speed")]),_=Xu(h.ec,_,[0,o.paint.get("raster-particle-max-speed")])),{texture:d,textureOffset:[v/(y+2*v),y/(y+2*v)],tileSize:y,scalarData:I,scale:m,offset:_,defines:["RASTER_ARRAY",{uint8:"DATA_FORMAT_UINT8",uint16:"DATA_FORMAT_UINT16",uint32:"DATA_FORMAT_UINT32"}[T]]}}function am(a){let t=a._nearZ,o=a.projection.farthestPixelDistance(a),c=o-t,d=.2*a.height,m=t+d;return[t,o,(m-d-t)/c,(m-t)/c]}var lm=`#ifdef RASTER_ARRAY 3064uniform 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;} 3065#endif 3066uniform 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;}`;Mc["_prelude_raster_particle.glsl"]||(Mc["_prelude_raster_particle.glsl"]=lm);var ir={building:zt(`#include "_prelude_fog.fragment.glsl" 3067#include "_prelude_shadow.fragment.glsl" 3068#include "_prelude_lighting.glsl" 3069const 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; 3070#ifdef RENDER_FRONT_CUTOFF 3071in float v_front_cutoff_opacity; 3072#endif 3073#ifdef INDICATOR_CUTOUT 3074#ifdef FEATURE_CUTOUT 3075in vec4 v_ground_roof; 3076#endif 3077#endif 3078#ifdef BUILDING_FAUX_FACADE 3079in 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; 3080#endif 3081#ifdef RENDER_SHADOWS 3082in highp vec4 v_pos_light_view_0;in highp vec4 v_pos_light_view_1; 3083#endif 3084#ifdef FLOOD_LIGHT
3085in highp float v_flood_radius;in float v_has_flood_light; 3086#endif 3087uniform lowp float u_opacity;uniform vec3 u_camera_pos;uniform highp float u_tile_to_meter;uniform float u_facade_emissive_chance;uniform vec3 u_flood_light_color;uniform float u_flood_light_intensity;vec3 linearTosRGB(in vec3 color) {return pow(color,vec3(1./2.2));} 3088#ifdef BUILDING_FAUX_FACADE 3089highp float hash12(in highp vec2 p) {highp vec3 p3 =fract(vec3(p.xyx)*0.1031);p3+=dot(p3,p3.yzx+33.33);return fract((p3.x+p3.y)*p3.z);}float min3(in vec3 v) {return min(min(v.x,v.y),v.z);}highp vec2 get_uv_mask_id(in highp vec2 q,out highp float mask,out highp vec2 id) {highp vec2 p=q;mask=step(v_faux_facade_range.x,p.y)*step(p.y,v_faux_facade_range.y);p.y=p.y-v_faux_facade_range.x;highp vec2 uv=modf(p/v_faux_facade_floor,id);highp vec4 d=(v_faux_facade_floor.xyxy+vec4(-v_faux_facade_window,v_faux_facade_window))*0.5;highp vec4 edge=d/v_faux_facade_floor.xyxy;highp vec2 m=step(edge.xy,uv)*step(uv,edge.zw);mask*=m.x*m.y;uv-=vec2(0.5);uv*=vec2(0.5)/(vec2(0.5)-edge.xy);uv+=vec2(0.5);return uv;}highp float ray_unit_box(in highp vec3 ray_o,in highp vec3 ray_d,in highp vec3 bmin,in highp vec3 bmax) {highp vec3 planes=mix(bmin,bmax,step(0.0,ray_d));highp vec3 t=(planes-ray_o)/ray_d;return min3(t);}float get_emissive(in vec2 id) {if (u_facade_emissive_chance > 0.0) {return (step(hash12(id),u_facade_emissive_chance)+0.05)*v_faux_color_emissive.a;}return 0.0;}vec3 get_shade_info(in highp vec3 v,in highp vec3 v_normalized,in vec3 color,in vec2 id,in mat3 tbn,inout vec3 out_normal,inout float out_emissive) {vec3 out_color=color;highp vec3 abs_v=abs(v_normalized);bool x_major=abs_v.x >=abs_v.y && abs_v.x >=abs_v.z;bool y_major=abs_v.y >=abs_v.x && abs_v.y >=abs_v.z;bool z_major=abs_v.z >=abs_v.x && abs_v.z >=abs_v.y; 3090#if 0 3091if (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; 3092#else 3093if (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; 3094#endif 3095return out_color;} 3096#endif 3097vec3 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; 3098#ifdef BUILDING_FAUX_FACADE 3099if (v_faux_facade > 0.0) {highp mat3 tbn=mat3(v_tbn_0,v_tbn_1,v_tbn_2);highp vec3 v=vec3(v_pos.xy,v_pos.z/u_tile_to_meter)-u_camera_pos;highp vec3 view_tangent=transpose(tbn)*v;highp vec2 q=vec2(v_faux_facade_ed,v_pos.z);float mask=0.0;vec2 id=vec2(0.0);highp vec2 uv=get_uv_mask_id(q,mask,id);uv*=v_faux_facade_window;highp vec3 bmin=vec3(0.0,0.0,-window_depth);highp vec3 bmax=bmin+vec3(v_faux_facade_window,window_depth);highp vec3 ray_o=vec3(uv,0.0);highp vec3 ray_d=normalize(view_tangent);highp float t_min=ray_unit_box(ray_o,ray_d,bmin,bmax);highp vec3 hit=ray_o+t_min*ray_d;highp vec3 r=vec3(v_faux_facade_window,-window_depth);hit-=r*0.5;highp vec3 normalized=hit/r;vec3 out_normal=normal;float out_emissive=emissive;vec3 room_color=get_shade_info(hit,normalized,base_color,id,tbn,out_normal,out_emissive);base_color=mix(base_color,room_color,mask);normal=mix(normal,out_normal,mask);emissive=mix(emissive,out_emissive,mask);} 3100#endif 3101vec4 color=vec4(base_color,1.0);vec3 xy_flipped_normal=vec3(-normal.xy,normal.z);float shadowed_lighting_factor=0.0; 3102#ifdef RENDER_SHADOWS 3103#ifdef RENDER_CUTOFF 3104shadowed_lighting_factor=shadowed_light_factor_normal_opacity(xy_flipped_normal,v_pos_light_view_0,v_pos_light_view_1,1.0/gl_FragCoord.w,v_cutoff_opacity);if (v_cutoff_opacity==0.0) {discard;} 3105#else 3106shadowed_lighting_factor=shadowed_light_factor_normal(xy_flipped_normal,v_pos_light_view_0,v_pos_light_view_1,1.0/gl_FragCoord.w); 3107#endif 3108#else 3109shadowed_lighting_factor=max(0.0,dot(xy_flipped_normal,u_lighting_directional_dir)); 3110#endif 3111color.rgb=apply_lighting_linear(color.rgb,xy_flipped_normal,shadowed_lighting_factor);color.rgb=linearTosRGB(color.rgb); 3112#ifdef FLOOD_LIGHT
3113float flood_radiance=(1.0-min(v_pos.z/v_flood_radius,1.0))*u_flood_light_intensity*v_has_flood_light;color.rgb=mix(color.rgb,u_flood_light_color,flood_radiance); 3114#endif 3115color.rgb=mix(color.rgb,linearTosRGB(base_color.rgb),emissive); 3116#ifdef FOG 3117color=fog_dither(fog_apply_premultiplied(color,v_fog_pos,v_pos.z)); 3118#endif 3119color*=u_opacity; 3120#ifdef INDICATOR_CUTOUT 3121#ifdef FEATURE_CUTOUT 3122{float ditherOpacity=cutoutGroundRoofOpacity(v_ground_roof);if (ditherOpacity < 1.0) {int index=(int(gl_FragCoord.x) % 4)*4+(int(gl_FragCoord.y) % 4);if (ditherOpacity < DITHER_THRESHOLDS[index]) {discard;}}} 3123#else 3124color=applyCutout(color,v_pos.z); 3125#endif 3126#endif 3127#ifdef RENDER_FRONT_CUTOFF 3128if (v_front_cutoff_opacity < 1.0) {int index=(int(gl_FragCoord.x) % 4)*4+(int(gl_FragCoord.y) % 4);if (v_front_cutoff_opacity < DITHER_THRESHOLDS[index]) {discard;}} 3129#endif 3130#ifdef FEATURE_CUTOUT 3131color=apply_feature_cutout(color,gl_FragCoord,get_cutout_factors(gl_FragCoord).x); 3132#endif 3133glFragColor=color; 3134#ifdef DEBUG_SHOW_NORMALS 3135color.rgb=xy_flipped_normal*0.5+vec3(0.5,0.5,0.5);color.a=1.0;glFragColor=color; 3136#endif 3137#ifdef OVERDRAW_INSPECTOR 3138glFragColor=vec4(1.0); 3139#endif 3140HANDLE_WIREFRAME_DEBUG;}`,`#include "_prelude_fog.vertex.glsl" 3141#include "_prelude_shadow.vertex.glsl" 3142in vec3 a_pos_3f;in ivec4 a_normal_3;in ivec4 a_centroid_3; 3143#ifdef FLOOD_LIGHT 3144in int a_flood_light_wall_radius_1i16; 3145#endif 3146#ifdef BUILDING_FAUX_FACADE 3147in uvec4 a_faux_facade_data;in uvec2 a_faux_facade_vertical_range; 3148#endif 3149uniform mat4 u_matrix;uniform mat4 u_normal_matrix;uniform highp float u_tile_to_meter; 3150#ifdef RENDER_FRONT_CUTOFF 3151uniform vec3 u_front_cutoff_params;out float v_front_cutoff_opacity; 3152#endif 3153#ifdef INDICATOR_CUTOUT 3154#ifdef FEATURE_CUTOUT 3155out vec4 v_ground_roof; 3156#endif 3157#endif 3158out vec4 v_color;out vec3 v_normal;out highp vec3 v_pos; 3159#ifdef BUILDING_FAUX_FACADE 3160out 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; 3161#endif 3162#ifdef RENDER_SHADOWS 3163uniform 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; 3164#endif 3165#ifdef FLOOD_LIGHT 3166out highp float v_flood_radius;out float v_has_flood_light; 3167#endif 3168const float MAX_UINT_16=65535.0;const float MAX_INT_16=32767.0;const float MAX_UINT_8=255.0;const float TWO_POW_8=256.0;const float FLOOD_LIGHT_MAX_RADIUS_METER=2048.0;vec3 sRGBToLinear(vec3 srgbIn) {return pow(srgbIn,vec3(2.2));} 3169#ifdef BUILDING_FAUX_FACADE 3170mat3 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);} 3171#endif 3172#pragma mapbox: define-attribute-vertex-shader-only highp uvec2 part_color_emissive 3173#pragma mapbox: define-attribute-vertex-shader-only highp uvec2 faux_facade_color_emissive 3174void main() { 3175#pragma mapbox: initialize-attribute-custom highp uvec2 part_color_emissive 3176#pragma mapbox: initialize-attribute-custom highp uvec2 faux_facade_color_emissive 3177#ifdef FLOOD_LIGHT 3178v_flood_radius=(float(a_flood_light_wall_radius_1i16)/MAX_INT_16*FLOOD_LIGHT_MAX_RADIUS_METER);v_has_flood_light=step(0.0,v_flood_radius); 3179#endif 3180vec4 color_emissive=decode_color(vec2(part_color_emissive));v_color=vec4(sRGBToLinear(color_emissive.rgb),color_emissive.a);vec3 a_normal_3f=vec3(a_normal_3)/MAX_INT_16;v_normal=vec3(u_normal_matrix*vec4(a_normal_3f,0.0));float hidden=0.0;float depth_offset=0.0;vec2 centroid_xy=vec2(a_centroid_3.xy >> 2);vec2 spanBits=vec2(a_centroid_3.xy & 3); 3181#ifdef BUILDING_FAUX_FACADE 3182vec4 faux_facade_data=vec4(a_faux_facade_data);v_faux_facade=faux_facade_data.x;if (v_faux_facade > 0.0) {v_faux_facade_ed=faux_facade_data.x *u_tile_to_meter;float window_x_perc=floor(faux_facade_data.y/TWO_POW_8);float window_y_perc=faux_facade_data.y-TWO_POW_8*window_x_perc;vec2 window_perc=vec2(window_x_perc,window_y_perc)/MAX_UINT_8;v_faux_facade_floor=(faux_facade_data.zw/MAX_UINT_16*EXTENT)*u_tile_to_meter;v_faux_facade_window=window_perc*v_faux_facade_floor;v_faux_facade_range=(vec2(a_faux_facade_vertical_range)/MAX_UINT_16*EXTENT)*u_tile_to_meter;v_aspect=v_faux_facade_window.x/v_faux_facade_window.y;mat3 tbn=get_tbn(normalize(v_normal));v_tbn_0=tbn[0];v_tbn_1=tbn[1];v_tbn_2=tbn[2];v_faux_color_emissive=decode_color(vec2(faux_facade_color_emissive));v_faux_color_emissive.rgb=sRGBToLinear(v_faux_color_emissive.rgb);depth_offset=min(1000.0,float(a_centroid_3.z))*0.0000002;} 3183#endif 3184v_pos=a_pos_3f; 3185#if defined(RENDER_CUTOFF) || defined(RENDER_FRONT_CUTOFF) 3186float halfSpanX=spanBits.x*10.0/u_tile_to_meter;float halfSpanY=spanBits.y*10.0/u_tile_to_meter;
3186vec2 screenUpInTile=vec2(u_matrix[0][1],u_matrix[1][1]);vec2 spanOffset=vec2(halfSpanX,halfSpanY)*sign(screenUpInTile);vec2 cutoff_highestCorner=centroid_xy+spanOffset;vec2 cutoff_lowestCorner=centroid_xy-spanOffset; 3187#endif 3188#if defined(RENDER_CUTOFF) || defined(RENDER_FRONT_CUTOFF) 3189vec4 ground=u_matrix*vec4(centroid_xy,0.0,1.0); 3190#endif 3191#ifdef RENDER_CUTOFF 3192v_cutoff_opacity=cutoff_opacity(u_cutoff_params,ground.z);hidden=float(v_cutoff_opacity==0.0);v_pos.z*=v_cutoff_opacity; 3193#endif 3194#ifdef RENDER_SHADOWS 3195vec3 shadow_pos=v_pos; 3196#ifdef NORMAL_OFFSET 3197vec3 offset=shadow_normal_offset_model(v_normal);shadow_pos+=offset*shadow_normal_offset_multiplier0(); 3198#endif 3199v_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); 3200#endif 3201#ifdef FOG 3202v_fog_pos=fog_position(v_pos); 3203#endif 3204#ifdef RENDER_FRONT_CUTOFF 3205v_front_cutoff_opacity=1.0;{hidden=max(hidden,float(ground.w <=0.0));float ndc_y=ground.y/max(ground.w,0.001);float threshold=u_front_cutoff_params.x*2.0-1.0;float range_ndc=u_front_cutoff_params.y*2.0;hidden=max(hidden,float(ndc_y < threshold-range_ndc));float t=clamp((ndc_y-(threshold-range_ndc))/max(range_ndc,0.001),0.0,1.0);v_front_cutoff_opacity=mix(u_front_cutoff_params.z,1.0,t);} 3206#endif 3207gl_Position=mix(u_matrix*vec4(v_pos,1),AWAY,hidden);gl_Position.z-=depth_offset*gl_Position.w; 3208#ifdef INDICATOR_CUTOUT 3209#ifdef FEATURE_CUTOUT 3210vec4 ic_ground=u_matrix*vec4(v_pos.xy,0.0,1.0);vec4 ic_roof=u_matrix*vec4(v_pos.xy,v_pos.z,1.0);v_ground_roof=vec4(ic_ground.xy/ic_ground.w,ic_roof.xy/ic_roof.w); 3211#endif 3212#endif 3213}`),buildingBloom:zt(`in vec4 v_color_emissive; 3214#pragma mapbox: define-attribute highp vec4 bloom_attenuation 3215#pragma mapbox: initialize-attribute highp vec4 bloom_attenuation 3216float saturate(float val) {return clamp(val,0.0,1.0);}void main() {float emission=v_color_emissive.a;float opacity=1.0; 3217#ifdef HAS_ATTRIBUTE_a_bloom_attenuation 3218float distance=length(vec2(1.3*max(0.0,abs(bloom_attenuation.x)-bloom_attenuation.z),bloom_attenuation.y));distance+= mix(0.5,0.0,clamp(emission-1.0,0.0,1.0));opacity*=saturate(1.0-distance*distance); 3219#endif 3220#ifdef RENDER_CUTOFF 3221opacity*=v_cutoff_opacity; 3222#endif 3223glFragColor=vec4(v_color_emissive.rgb,1.0)*opacity;}`,`in vec3 a_pos_3f; 3224#pragma mapbox: define-attribute-vertex-shader-only highp uvec2 part_color_emissive 3225#pragma mapbox: define-attribute highp vec4 bloom_attenuation 3226out vec4 v_color_emissive;uniform mat4 u_matrix;vec3 sRGBToLinear(vec3 srgbIn) {return pow(srgbIn,vec3(2.2));}void main() { 3227#pragma mapbox: initialize-attribute-custom highp uvec2 part_color_emissive 3228#pragma mapbox: initialize-attribute highp vec4 bloom_attenuation 3229#ifdef HAS_ATTRIBUTE_a_part_color_emissive 3230vec4 color_emissive=decode_color(vec2(part_color_emissive));float part_emissive=color_emissive.a*5.0;v_color_emissive=vec4(sRGBToLinear(color_emissive.rgb),part_emissive); 3231#else 3232v_color_emissive=vec4(1.0); 3233#endif 3234gl_Position=u_matrix*vec4(a_pos_3f,1.0); 3235#ifdef RENDER_CUTOFF 3236v_cutoff_opacity=cutoff_opacity(u_cutoff_params,gl_Position.z); 3237#endif 3238}`),buildingDepth:zt("void main() {}","in vec3 a_pos_3f;uniform mat4 u_matrix;void main() {gl_Position=u_matrix*vec4(a_pos_3f,1.0);}"),rasterParticle:zt(`#include "_prelude_fog.fragment.glsl" 3239#include "_prelude_lighting.glsl" 3240uniform 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; 3241#ifdef LIGHTING_3D_MODE 3242out_color=apply_lighting_with_emission_ground(vec4(out_color,1.0),1.0).rgb; 3243#endif 3244#ifdef FOG 3245highp 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)); 3246#endif 3247glFragColor=vec4(out_color*color.a,color.a); 3248#ifdef OVERDRAW_INSPECTOR 3249glFragColor=vec4(1.0); 3250#endif 3251HANDLE_WIREFRAME_DEBUG;}`,`#include "_prelude_fog.vertex.glsl" 3252uniform 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; 3253#define GLOBE_UPSCALE GLOBE_RADIUS/6371008.8 3254in ivec2 a_pos;in uvec2 a_texture_pos;out vec2 v_pos0;out vec2 v_pos1;void main() {float w=1.0;vec2 uv; 3255#ifdef PROJECTION_GLOBE_VIEW 3256vec3 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; 3257#ifdef FOG 3258v_fog_pos=fog_position((u_normalize_matrix*vec4(globe_pos,1.0)).xyz); 3259#endif 3260#else 3261uv=vec2(a_texture_pos)/8192.0;
3261gl_Position=u_matrix*vec4(vec2(a_pos)*w,u_raster_elevation*w,w); 3262#ifdef FOG 3263v_fog_pos=fog_position(vec2(a_pos)); 3264#endif 3265#endif 3266v_pos0=uv;v_pos1=(v_pos0*u_scale_parent)+u_tl_parent;}`),rasterParticleDraw:zt("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" 3267in int a_index;uniform sampler2D u_particle_texture;uniform float u_particle_texture_side_len;uniform vec2 u_tile_offset;out float v_particle_speed;void main() {ivec2 pixel_coord=ivec2( 3268mod(float(a_index),u_particle_texture_side_len),float(a_index)/u_particle_texture_side_len);vec4 pixel=texelFetch(u_particle_texture,pixel_coord,0);vec2 pos=unpack_pos_from_rgba(pixel)+u_tile_offset;vec2 tex_coord=fract(pos);vec2 velocity=lookup_velocity(tex_coord);if (velocity==INVALID_VELOCITY) {gl_Position=AWAY;v_particle_speed=0.0;} else {gl_Position=vec4(2.0*pos-1.0,0,1);v_particle_speed=length(velocity);}gl_PointSize=1.0;}`),rasterParticleTexture:zt("uniform sampler2D u_texture;uniform float u_opacity;in vec2 v_tex_pos;void main() {vec4 color=texture(u_texture,v_tex_pos);glFragColor=vec4(floor(255.0*color*u_opacity)/255.0);}","in ivec2 a_pos;out vec2 v_tex_pos;void main() {vec2 uv=0.5*vec2(a_pos)+vec2(0.5);v_tex_pos=uv;gl_Position=vec4(a_pos,0.0,1.0);}"),rasterParticleUpdate:zt(`#include "_prelude_raster_particle.glsl" 3269uniform sampler2D u_particle_texture;uniform mediump float u_particle_texture_side_len;uniform mediump float u_speed_factor;uniform highp float u_reset_rate;uniform highp float u_rand_seed;in highp vec2 v_tex_coord;vec2 linearstep(vec2 edge0,vec2 edge1,vec2 x) {return clamp((x-edge0)/(edge1-edge0),vec2(0),vec2(1));}const highp vec3 rand_constants=vec3(12.9898,78.233,4375.85453);highp float rand(const highp vec2 co) {highp float t=dot(rand_constants.xy,co);return fract(sin(t)*(rand_constants.z+t));}void main() {ivec2 pixel_coord=ivec2(v_tex_coord*u_particle_texture_side_len);highp vec4 pixel=texelFetch(u_particle_texture,pixel_coord,0);highp vec2 pos=unpack_pos_from_rgba(pixel);highp vec2 velocity=lookup_velocity(clamp(pos,0.0,1.0));highp vec2 dp=velocity==INVALID_VELOCITY ? vec2(0) : velocity*u_speed_factor;pos=pos+dp;highp vec2 seed=(pos+v_tex_coord)*u_rand_seed;highp vec2 random_pos=vec2(rand(seed+1.3),rand(seed+2.1));highp vec2 persist_rate=pow( 3270linearstep(vec2(-u_particle_pos_offset),vec2(0),pos)*linearstep(vec2(1.0+u_particle_pos_offset),vec2(1),pos),vec2(4) 3271);highp vec2 per_frame_persist=pow(persist_rate,abs(dp)/u_particle_pos_offset);highp float drop_rate=1.0-per_frame_persist.x*per_frame_persist.y;drop_rate=any(greaterThanEqual(abs(pos-0.5),vec2(0.5+u_particle_pos_offset))) ? 1.0 : drop_rate;highp float drop=step(1.0-drop_rate-u_reset_rate,rand(seed));highp vec2 next_pos=mix(pos,random_pos,drop);glFragColor=pack_pos_to_rgba(next_pos);}`,"in ivec2 a_pos;out vec2 v_tex_coord;void main() {v_tex_coord=0.5*vec2(a_pos+ivec2(1));gl_Position=vec4(a_pos,0.0,1.0);}"),snowParticle:zt("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;}",` 3272in 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; 3273uniform float u_velocity;uniform vec3 u_direction;uniform float u_horizontalOscillationRadius; 3274uniform float u_horizontalOscillationRate; 3275uniform 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);
3275simPosLocal.xy+=horizontalOscillationRadius*vec2(cos(horizontalOscillationAngle),sin(horizontalOscillationAngle));vec3 simPos=localX*simPosLocal.x+ 3276localY*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:zt("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;}",` 3277in 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; 3278uniform float u_velocity; 3279uniform vec2 u_rainDropletSize;uniform vec3 u_rainDirection;out highp vec2 uv;out highp float particleRandomValue;void main() {vec3 pos=a_pos_3f;float halfBoxSize=0.5*u_boxSize;pos*=halfBoxSize; 3280pos+=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+ 3281localY*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:zt("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);}")};zt(lm,"");let sg=h.ea([{type:"Float32",name:"a_pos_3f",components:3},{type:"Float32",name:"a_uv",components:2},{type:"Float32",name:"a_rainParticleData",components:4}]),$c=h.ea([{type:"Float32",name:"a_pos_2f",components:2}]);class ag{destroy(){this.vignetteVx&&this.vignetteVx.destroy(),this.vignetteIdx&&this.vignetteIdx.destroy()}draw(t,o){let c=t.getOrCreateProgram("vignette");
3281if(!this.vignetteVx||!this.vignetteIdx){let _=new h.ee,y=new h.dF;_.emplaceBack(-1,-1),_.emplaceBack(1,-1),_.emplaceBack(1,1),_.emplaceBack(-1,1),y.emplaceBack(0,1,2),y.emplaceBack(0,2,3),this.vignetteVx=t.context.createVertexBuffer(_,$c.members),this.vignetteIdx=t.context.createIndexBuffer(y)}let d=h.dB.simpleSegment(0,0,4,6);if(this.vignetteVx&&this.vignetteIdx){t.uploadCommonUniforms(t.context,c);let _={u_vignetteShape:(m={vignetteShape:[o.start,o.range,Math.pow(10,o.fadePower)],vignetteColor:[o.color.r,o.color.g,o.color.b,o.color.a*o.strength]}).vignetteShape,u_vignetteColor:m.vignetteColor};c.draw(t,t.context.gl.TRIANGLES,nt.disabled,gt.disabled,mt.alphaBlended,dt.disabled,_,"vignette",this.vignetteVx,this.vignetteIdx,d)}var m}}class _i{constructor(){this._accumulatedOffsetX=0,this._accumulatedOffsetY=0,this._accumulatedElevation=0}update(t,o){let c=t.getFreeCameraOptions().position,d=c.toAltitude(),m=c.toLngLat(),_=h.am(m.lng),y=h.am(m.lat),v=t.pixelsPerMeter/o,T=_*h.eg,I=h.eg*Math.log(Math.tan(Math.PI/4+y/2));if(this._offsetXPrev===void 0)this._offsetXPrev=0,this._offsetYPrev=0,this._elevationPrev=0,this._accumulatedOffsetX=0,this._accumulatedOffsetY=0,this._accumulatedElevation=0;else{let P=-this._offsetYPrev+I,A=-this._elevationPrev+d;this._accumulatedOffsetX+=(-this._offsetXPrev+T)*v,this._accumulatedOffsetY+=P*v,this._accumulatedElevation+=A*v,this._offsetXPrev=T,this._offsetYPrev=I,this._elevationPrev=d}}getPosition(){return[this._accumulatedOffsetX,this._accumulatedOffsetY,this._accumulatedElevation]}}function Ct(a,t){return[-(a[0]-Math.floor(a[0]/t)*t),-(a[1]-Math.floor(a[1]/t)*t),-(a[2]-Math.floor(a[2]/t)*t)]}function Nd(a){let t=h.ef(1323123451230),o=[];for(let c=0;c<a;++c){let d=2*t()-1,m=2*t()-1,_=2*t()-1;o.push(h.cU(d,m,_))}return o}function Hn(a,t,o,c,d){let m=h.aB((d-o)/(c-o),0,1);return(1-m)*a+m*t}class Ns{constructor(t){this._movement=new _i,this._accumulatedTimeFromStart=0,this._prevTime=Date.now()/1e3,this._vignette=new ag,this._ppmScaleFactor=t}destroy(){this.particlesVx&&this.particlesVx.destroy(),this.particlesIdx&&this.particlesIdx.destroy(),this._vignette&&this._vignette.destroy()}updateOnRender(t,o){let c=t.transform;this._movement.update(c,this._ppmScaleFactor);let d=c.starsProjMatrix,m=h.bP([]);h.bR(m,m,h.am(90)-c._pitch),h.bQ(m,m,-c.angle);let _=h.bV(new Float32Array(16),m),y=new Float32Array([1,0,0,0,0,0,1,0,0,-1,0,0,0,0,0,1]),v=h.e9([],y),T=h.aC([],v,_),I=Date.now()/1e3;return this._accumulatedTimeFromStart+=(I-this._prevTime)*o,this._prevTime=I,{projectionMatrix:d,modelviewMatrix:T}}}let Ba=h.ea([{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}]),Do={building:a=>({u_matrix:new h.c3(a),u_normal_matrix:new h.c3(a),u_opacity:new h.c1(a),u_faux_facade_ao_intensity:new h.c1(a),u_camera_pos:new h.c0(a),u_tile_to_meter:new h.c1(a),u_facade_emissive_chance:new h.c1(a),u_flood_light_color:new h.c0(a),u_flood_light_intensity:new h.c1(a),u_front_cutoff_params:new h.c0(a)}),buildingBloom:a=>({u_matrix:new h.c3(a)}),buildingDepth:a=>({u_matrix:new h.c3(a)}),rasterParticle:a=>({u_matrix:new h.c3(a),u_normalize_matrix:new h.c3(a),u_globe_matrix:new h.c3(a),u_merc_matrix:new h.c3(a),u_grid_matrix:new h.dq(a),u_tl_parent:new h.c2(a),u_scale_parent:new h.c1(a),u_fade_t:new h.c1(a),u_opacity:new h.c1(a),u_image0:new h.b$(a),u_image1:new h.b$(a),u_raster_elevation:new h.c1(a),u_zoom_transition:new h.c1(a),u_merc_center:new h.c2(a),u_cutoff_params:new h.cS(a)}),rasterParticleTexture:a=>({u_texture:new h.b$(a),u_opacity:new h.c1(a)}),rasterParticleDraw:a=>({u_particle_texture:new h.b$(a),u_particle_texture_side_len:new h.c1(a),u_tile_offset:new h.c2(a),u_velocity:new h.b$(a),u_color_ramp:new h.b$(a),u_velocity_res:new h.c2(a),u_max_speed:new h.c1(a),u_uv_offset:new h.c2(a),u_data_scale:new h.c2(a),u_data_offset:new h.c1(a),u_particle_pos_scale:new h.c1(a),u_particle_pos_offset:new h.c2(a)}),rasterParticleUpdate:a=>({u_particle_texture:new h.b$(a),u_particle_texture_side_len:new h.c1(a),u_velocity:new h.b$(a),u_velocity_res:new h.c2(a),u_max_speed:new h.c1(a),u_speed_factor:new h.c1(a),u_reset_rate:new h.c1(a),u_rand_seed:new h.c1(a),u_uv_offset:new h.c2(a),u_data_scale:new h.c2(a),u_data_offset:new h.c1(a),u_particle_pos_scale:new h.c1(a),u_particle_pos_offset:new h.c2(a)}),snowParticle:a=>({u_modelview:new h.c3(a),u_projection:new h.c3(a),u_time:new h.c1(a),u_cam_pos:new h.c0(a),u_velocityConeAperture:new h.c1(a),u_velocity:new h.c1(a),u_horizontalOscillationRadius:new h.c1(a),u_horizontalOscillationRate:new h.c1(a),u_boxSize:new h.c1(a),u_billboardSize:new h.c1(a),u_simpleShapeParameters:new h.c2(a),u_screenSize:new h.c2(a),u_thinningCenterPos:new h.c2(a),u_thinningShape:new h.c0(a),u_thinningAffectedRatio:new h.c1(a),u_thinningParticleOffset:new h.c1(a),u_particleColor:new h.cS(a),u_direction:new h.c0(a)}),rainParticle:a=>({u_modelview:new h.c3(a),u_projection:new h.c3(a),u_time:new h.c1(a),u_cam_pos:new h.c0(a),u_texScreen:new h.b$(a),u_velocityConeAperture:new h.c1(a),u_velocity:new h.c1(a),u_boxSize:new h.c1(a),u_rainDropletSize:new h.c2(a),u_distortionStrength:new h.c1(a),u_rainDirection:new h.c0(a),u_color:new h.cS(a),u_screenSize:new h.c2(a),u_thinningCenterPos:new h.c2(a),u_thinningShape:new h.c0(a),u_thinningAffectedRatio:new h.c1(a),u_thinningParticleOffset:new h.c1(a),u_shapeDirectionalPower:new h.c1(a),u_shapeNormalPower:new h.c1(a),u_mode:new h.c1(a)}),vignette:a=>({u_vignetteShape:new h.c0(a),u_vignetteColor:new h.cS(a)})},no={drawBuilding:function(a,t,o,c){a.currentLayer<a.firstLightBeamLayer&&(a.firstLightBeamLayer=a.currentLayer);let d=o.paint.get("building-ambient-occlusion-ground-intensity"),m=o.paint.get("building-ambient-occlusion-ground-radius"),_=o.paint.get("building-ambient-occlusion-ground-attenuation"),y=o.paint.get("building-opacity");if(y<=0)return;let v=d>0&&m>0,T=!0,I=o.paint.get("building-vertical-scale");if(I<=0)return;a.shadowRenderer||(T=!1);let P=a.conflationActive&&a.style.isLayerClipped(o,t.getSource()),A=a.style.order.indexOf(o.fqid);if(function(D,L,O,k,N,q){for(let Z of q){let G=L.getTile(Z).getBucket(O);G&&(N&&G.updateReplacement(Z,D.replacementSource,k),G.uploadUpdatedIndexBuffer(D.context))}}(a,t,o,A,P,c),function(D,L,O,k){for(let N of k){let q=L.getTile(N).getBucket(O);q&&q.needsEvaluation()&&q.uploadUpdatedColorBuffer(D.context)}}(a,t,o,c),o.resetLayerRenderingStats(a),a.shadowRenderer&&(a.shadowRenderer.useNormalOffset=!0),a.renderPass==="shadow"&&a.shadowRenderer){let D=[],L=a.shadowRenderer.getShadowPassDepthMode();Fa({painter:a,source:t,layer:o,coords:c,defines:D,blendMode:mt.disabled,depthMode:L,opacity:y,verticalScale:I,facadeEmissiveChance:0,facadeAOIntensity:0,floodLightIntensity:0,floodLightColor:[0,0,0]})}else if(a.renderPass==="translucent"){let D=["HAS_ATTRIBUTE_a_part_color_emissive","LIGHTING_3D_MODE"];T&&(D=D.concat("RENDER_SHADOWS")),a.shadowRenderer&&a.shadowRenderer.useNormalOffset&&(D=D.concat("NORMAL_OFFSET"));let L=o.paint.get("building-facade-emissive-chance"),O=o.paint.get("building-ambient-occlusion-intensity"),k=o.paint.get("building-flood-light-intensity"),N=o.paint.get("building-flood-light-color-use-theme").
3281constantOr("default")==="none",q=o.paint.get("building-flood-light-color").toNonPremultipliedRenderColor(N?null:o.lut).toArray01().slice(0,3),Z=o.paint.get("building-flood-light-ground-attenuation"),G=k>0,re=new nt(a.context.gl.LEQUAL,nt.ReadWrite,a.depthRangeFor3D);y<1&&Fa({painter:a,source:t,layer:o,coords:c,defines:D,blendMode:mt.disabled,depthMode:re,opacity:y,verticalScale:I,facadeEmissiveChance:L,facadeAOIntensity:O,floodLightIntensity:k,floodLightColor:q,depthOnly:!0});let te=a.colorModeForRenderPass();Fa({painter:a,source:t,layer:o,coords:c,defines:D,blendMode:te,depthMode:re,opacity:y,verticalScale:I,facadeEmissiveChance:L,facadeAOIntensity:O,floodLightIntensity:k,floodLightColor:q});let se=o.paint.get("building-front-cutoff");Gc(a.transform.pitch,se,!!a.terrain),v&&El(a,t,o,c,!0,y,d,m,k,q,_,P),G&&El(a,t,o,c,!1,y,d,m,k,q,Z,P)}else if(a.renderPass==="light-beam"){let D=["HAS_ATTRIBUTE_a_part_color_emissive","HAS_ATTRIBUTE_a_bloom_attenuation"],L=new nt(a.context.gl.LEQUAL,nt.ReadOnly,a.depthRangeFor3D);Fa({painter:a,source:t,layer:o,coords:c,defines:D,blendMode:mt.alphaBlended,depthMode:L,opacity:y,verticalScale:I,facadeEmissiveChance:0,facadeAOIntensity:0,floodLightIntensity:0,floodLightColor:[0,0,0]})}a.shadowRenderer&&(a.shadowRenderer.useNormalOffset=!1),a.resetStencilClippingMasks()},drawRasterParticle:function(a,t,o,c,d,m){a.renderPass==="offscreen"&&function(_,y,v,T){if(!T.length)return;let I=_.context,P=I.gl,A=y.getSource();if(!(A instanceof jt))return;let D=Math.ceil(Math.sqrt(v.paint.get("raster-particle-count"))),L=v.particlePositionRGBAImage;if(!L||L.width!==D){let Z=function(G){let re=G*G,te=new Uint8Array(4*re),se=.9090909090909091;for(let K=0;K<re;K++){let J=se*(h.ed(2*K+0)+ks),oe=se*(h.ed(2*K+1)+ks),ue=255*J%1,de=255*oe%1,be=ue,ve=oe-de/255,Fe=de;te[4*K+0]=255*(J-ue/255),te[4*K+1]=255*be,te[4*K+2]=255*ve,te[4*K+3]=255*Fe}return te}(D);L=v.particlePositionRGBAImage=new h.q({width:D,height:D},Z)}let O=v.particleFramebuffer;O?O.width!==D&&(O.destroy(),O=v.particleFramebuffer=I.createFramebuffer(D,D,1,null)):O=v.particleFramebuffer=I.createFramebuffer(D,D,1,null);let k=[];for(let Z of T){let G=y.getTile(Z);if(!(G instanceof st))continue;let re=og(G,A,v);if(!re)continue;let te=[G.tileSize,G.tileSize],se=v.tileFramebuffer;se||(se=v.tileFramebuffer=I.createFramebuffer(te[0],te[1],1,null));let K=G.rasterParticleState;K||(K=G.rasterParticleState=new sm(I,Z,te,L));let J=K.update(v.lastInvalidatedAt);K.particleTextureDimension!==D&&K.updateParticleTexture(Z,L);let oe=K.targetColorTexture;K.targetColorTexture=K.backgroundColorTexture,K.backgroundColorTexture=oe;let ue=K.particleTexture0;K.particleTexture0=K.particleTexture1,K.particleTexture1=ue,k.push([Z,re,K,J])}if(k.length===0)return;let N=h.o.now(),q=v.previousDrawTimestamp?.001*(N-v.previousDrawTimestamp):.0167;if(v.previousDrawTimestamp=N,v.hasColorMap()){I.activeTexture.set(P.TEXTURE0+2);let Z=v.colorRampTexture;Z||(Z=v.colorRampTexture=new h.T(I,v.colorRamp,P.RGBA8)),Z.bind(P.LINEAR,P.CLAMP_TO_EDGE)}I.bindFramebuffer.set(v.tileFramebuffer.framebuffer),function(Z,G,re){let te=Z.context,se=te.gl,K=G.tileFramebuffer;te.activeTexture.set(se.TEXTURE0);let J={u_texture:0,u_opacity:1.05*(ue=G.paint.get("raster-particle-fade-opacity-factor"))/(ue+.05)},oe=Z.getOrCreateProgram("rasterParticleTexture",{defines:[],overrideFog:!1});var ue;for(let de of re){let[,,be,ve]=de;K.colorAttachment0.set(be.targetColorTexture.texture),te.viewport.set([0,0,K.width,K.height]),te.clear({color:h.C.transparent}),ve&&(be.backgroundColorTexture.bind(se.NEAREST,se.CLAMP_TO_EDGE),oe.draw(Z,se.TRIANGLES,nt.disabled,gt.disabled,mt.alphaBlended,dt.disabled,J,G.id,Z.viewportBuffer,Z.quadTriangleIndexBuffer,Z.viewportSegments))}}(_,v,k),function(Z,G,re,te){let se=Z.context,K=se.gl,J=re.tileFramebuffer,oe=Z.transform.projection.name==="globe",ue=re.paint.get("raster-particle-max-speed");for(let de of te){let[be,ve,Fe]=de;se.activeTexture.set(K.TEXTURE0+0),ve.texture.bind(K.LINEAR,K.CLAMP_TO_EDGE),J.colorAttachment0.set(Fe.targetColorTexture.texture);let pe=Z.getOrCreateProgram("rasterParticleDraw",{defines:ve.defines,overrideFog:!1});se.activeTexture.set(K.TEXTURE0+1);let Ie=ve.scalarData?[]:[0,1,2,3].map(Ce=>h.e2[Ce](be));Ie.push(be);let fe=be.canonical.x,Pe=be.canonical.y;for(let Ce of Ie){let Re=G.getTile(oe?Ce.wrapped():Ce);if(!Re)continue;let Ye=Re.rasterParticleState;if(!Ye)continue;let $e=Ce.canonical.x+(1<<Ce.canonical.z)*(Ce.wrap-be.wrap),je=Ce.canonical.y;Ye.particleTexture0.bind(K.NEAREST,K.CLAMP_TO_EDGE);let Ue=nm(1,Ye.particleTexture0.size[0],[$e-fe,je-Pe],0,ve.texture.size,2,ue,ve.textureOffset,ve.scale,ve.offset);pe.draw(Z,K.POINTS,nt.disabled,gt.disabled,mt.alphaBlended,dt.disabled,Ue,re.id,Ye.particleIndexBuffer,void 0,Ye.particleSegment)}}}(_,y,v,k),I.bindFramebuffer.set(v.particleFramebuffer.framebuffer),function(Z,G,re,te){let se=Z.context,K=se.gl,J=G.paint.get("raster-particle-max-speed"),oe=te*G.paint.get("raster-particle-speed-factor")*.15,ue=function(be){return Math.pow(be,6)}(.01+1*G.paint.get("raster-particle-reset-rate-factor")),de=G.particleFramebuffer;se.viewport.set([0,0,de.width,de.height]);for(let be of re){let[,ve,Fe]=be;se.activeTexture.set(K.TEXTURE0+0),ve.texture.bind(K.LINEAR,K.CLAMP_TO_EDGE),se.activeTexture.set(K.TEXTURE0+1);let pe=Fe.particleTexture0;
3281pe.bind(K.NEAREST,K.CLAMP_TO_EDGE);let Ie=rm(1,pe.size[0],0,ve.texture.size,J,oe,ue,ve.textureOffset,ve.scale,ve.offset);de.colorAttachment0.set(Fe.particleTexture1.texture),se.clear({color:h.C.transparent}),Z.getOrCreateProgram("rasterParticleUpdate",{defines:ve.defines}).draw(Z,K.TRIANGLES,nt.disabled,gt.disabled,mt.unblended,dt.disabled,Ie,G.id,Z.viewportBuffer,Z.quadTriangleIndexBuffer,Z.viewportSegments)}}(_,v,k,q)}(a,t,o,c),a.renderPass==="translucent"&&(function(_,y,v,T){let I=_.context,P=I.gl,A=y.getSource().tileSize,D=5*(1-h.ag(h.cx,h.cx+1,_.transform.zoom))*A+v.paint.get("raster-particle-elevation"),L=!_.options.moving,O=_.transform.projection.name==="globe";if(!T.length)return;let[k,N]=_.stencilConfigForOverlap(T),q=[];O&&q.push("PROJECTION_GLOBE_VIEW");let Z=_.stencilModeFor3D();for(let G of N){let re=G.toUnwrapped(),te=y.getTile(G);if(!te.rasterParticleState)continue;let se=te.rasterParticleState,K=100;te.registerFadeDuration(K);let J=y.findLoadedParent(G,0),oe=Qe(te,J,y,_.transform,K),ue,de;_.terrain&&_.terrain.prepareDrawTile(),I.activeTexture.set(P.TEXTURE0),se.targetColorTexture.bind(P.LINEAR,P.CLAMP_TO_EDGE),I.activeTexture.set(P.TEXTURE1),J&&J.rasterParticleState?(J.rasterParticleState.targetColorTexture.bind(P.LINEAR,P.CLAMP_TO_EDGE),ue=Math.pow(2,J.tileID.overscaledZ-te.tileID.overscaledZ),de=[te.tileID.canonical.x*ue%1,te.tileID.canonical.y*ue%1]):se.targetColorTexture.bind(P.LINEAR,P.CLAMP_TO_EDGE);let be=O?_.transform.expandedFarZProjMatrix:_.transform.calculateProjMatrix(re,L),ve=_.transform,Fe=am(ve),pe=h.du(G.canonical),Ie=h.dv(pe.getCenter().lat),fe,Pe,Ce,Re,Ye;O?(fe=Float32Array.from(h.dx(h.dy(G.canonical))),Pe=Float32Array.from(ve.globeMatrix),Ce=Float32Array.from(h.dt(ve)),Re=[h.aG(ve.center.lng),h.aJ(ve.center.lat)],Ye=Float32Array.from(h.dw(G.canonical,pe,Ie,ve.worldSize/ve._pixelsPerMercatorPixel))):(fe=new Float32Array(16),Pe=new Float32Array(9),Ce=new Float32Array(16),Re=[0,0],Ye=new Float32Array(9));let $e=im(be,fe,Pe,Ce,Ye,de||[0,0],h.ai(_.transform.zoom),Re,Fe,ue||1,oe,D),je=_.isTileAffectedByFog(G),Ue=_.getOrCreateProgram("rasterParticle",{defines:q,overrideFog:je});if(_.uploadCommonUniforms(I,Ue,re),O){let at=new nt(P.LEQUAL,nt.ReadOnly,_.depthRangeFor3D),ot=0,et=_.globeSharedBuffers;if(et){let[it,ut,xt]=et.getGridBuffers(Ie,ot!==0);Ue.draw(_,P.TRIANGLES,at,Z,mt.alphaBlended,_.renderElevatedRasterBackface?dt.frontCCW:dt.backCCW,$e,v.id,it,ut,xt)}}else{let at=_.depthModeForSublayer(0,nt.ReadOnly),ot=k[G.overscaledZ],{tileBoundsBuffer:et,tileBoundsIndexBuffer:it,tileBoundsSegments:ut}=_.getTileBoundsBuffers(te);Ue.draw(_,P.TRIANGLES,at,ot,mt.alphaBlended,dt.disabled,$e,v.id,et,it,ut)}}_.resetStencilClippingMasks()}(a,t,o,c),a.style.map.triggerRepaint())},prepareRasterParticle:function(a,t,o){let c=t.getSource();if(!(c instanceof jt&&c.loaded()))return;let d=a.sourceLayer||c.rasterLayerIds&&c.rasterLayerIds[0];if(!d)return;let m=a.paint.get("raster-particle-array-band")||c.getInitialBand(d);if(m==null)return;let _=t.getIds().map(y=>t.getTileByID(y));for(let y of _)y.updateNeeded(a.id,m)&&c.prepareTile(y,d,a.id,m)},Rain:class extends Ns{constructor(){super(4.25),this._params={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._vignetteParams={strength:1,start:.7,range:1,fadePower:.4,color:{r:.27,g:.27,b:.27,a:1}},this.particlesCount=16e3,this._devtoolsFolder=null,this._painter=null}destroy(){super.destroy()}update(a){let t=a.context;if(!this.particlesVx){let o=Nd(this.particlesCount),c=new h.eh,d=new h.dF,m=0,_=h.ef(1323123451230);for(let y=0;y<o.length;++y){let v=o[y],T=[2*_()-1,_(),_(),_()];c.emplaceBack(v[0],v[1],v[2],-1,-1,...T),c.emplaceBack(v[0],v[1],v[2],1,-1,...T),c.emplaceBack(v[0],v[1],v[2],1,1,...T),c.emplaceBack(v[0],v[1],v[2],-1,1,...T),d.emplaceBack(m+0,m+1,m+2),d.emplaceBack(m+0,m+2,m+3),m+=4}this.particlesVx=t.createVertexBuffer(c,sg.members),this.particlesIdx=t.createIndexBuffer(d)}}getDrawParams(a){if(!a.style.rain)return null;let t=a.style.rain.state,o=structuredClone(this._params);o.intensity=t.density,o.timeFactor=t.intensity,o.color=structuredClone(t.color),o.screenThinning.intensity=t.centerThinning,o.droplet
3281SizeX=t.dropletSize[0],o.dropletSizeYScale=t.dropletSize[1]/t.dropletSize[0],o.distortionStrength=100*t.distortionStrength;let c=structuredClone(this._vignetteParams);return c.strength=1,c.color=structuredClone(t.vignetteColor),{params:o,vignetteParams:c,revealParams:{revealStart:0,revealRange:.01},direction:structuredClone(t.direction)}}draw(a){let t=this.getDrawParams(a);if(!t)return;let{params:o,revealParams:c,direction:d,vignetteParams:m}=t,_=a.transform.zoom;if(c.revealStart>_)return;let y=Hn(0,1,c.revealStart,c.revealStart+c.revealRange,_);if(!this.particlesVx||!this.particlesIdx)return;m.strength*=y;let v=this.updateOnRender(a,o.timeFactor),T=a.context,I=T.gl,P=a.transform;this.screenTexture&&this.screenTexture.size[0]===a.width&&this.screenTexture.size[1]===a.height||(this.screenTexture=new h.T(T,{width:a.width,height:a.height,data:null},I.RGBA8)),o.distortionStrength>0&&(T.activeTexture.set(I.TEXTURE0),this.screenTexture.bind(I.LINEAR,I.CLAMP_TO_EDGE),I.copyTexSubImage2D(I.TEXTURE_2D,0,0,0,0,0,a.width,a.height));let A=a.getOrCreateProgram("rainParticle");a.uploadCommonUniforms(T,A),T.activeTexture.set(I.TEXTURE0),this.screenTexture.bind(I.LINEAR,I.CLAMP_TO_EDGE);let D=[o.color.r,o.color.g,o.color.b,o.color.a],L=(O,k)=>{let N=Ct(this._movement.getPosition(),O),q=o.dropletSizeX,Z=o.dropletSizeX*o.dropletSizeYScale,G=a.width/2,re=a.height/2,te=Hn(0,o.screenThinning.start,0,1,o.screenThinning.intensity),se=Hn(.001,o.screenThinning.range,0,1,o.screenThinning.intensity),K=Hn(0,o.screenThinning.particleOffset,0,1,o.screenThinning.intensity),J=(oe={modelview:v.modelviewMatrix,projection:v.projectionMatrix,time:this._accumulatedTimeFromStart,camPos:N,velocityConeAperture:o.velocityConeAperture,velocity:o.velocity,boxSize:O,rainDropletSize:[q,Z],distortionStrength:o.distortionStrength,rainDirection:d,color:D,screenSize:[P.width,P.height],thinningCenterPos:[G,re],thinningShape:[te,se,Math.pow(10,o.screenThinning.fadePower)],thinningAffectedRatio:o.screenThinning.affectedRatio,thinningParticleOffset:K,shapeDirectionalPower:o.shapeDirPower,shapeNormalPower:o.shapeNormalPower,mode:k?0:1},{u_modelview:Float32Array.from(oe.modelview),u_projection:Float32Array.from(oe.projection),u_time:oe.time,u_cam_pos:oe.camPos,u_texScreen:0,u_velocityConeAperture:oe.velocityConeAperture,u_velocity:oe.velocity,u_boxSize:oe.boxSize,u_rainDropletSize:oe.rainDropletSize,u_distortionStrength:oe.distortionStrength,u_rainDirection:oe.rainDirection,u_color:oe.color,u_screenSize:oe.screenSize,u_thinningCenterPos:oe.thinningCenterPos,u_thinningShape:oe.thinningShape,u_thinningAffectedRatio:oe.thinningAffectedRatio,u_thinningParticleOffset:oe.thinningParticleOffset,u_shapeDirectionalPower:oe.shapeDirectionalPower,u_shapeNormalPower:oe.shapeNormalPower,u_mode:oe.mode});var oe;let ue=Math.round(o.intensity*this.particlesCount),de=h.dB.simpleSegment(0,0,4*ue,2*ue);A.draw(a,I.TRIANGLES,nt.disabled,gt.disabled,mt.alphaBlended,dt.disabled,J,"rain_particles",this.particlesVx,this.particlesIdx,de)};o.distortionStrength>0&&L(o.boxSize,!0),L(o.boxSize,!1),this._vignette.draw(a,m)}},Snow:class extends Ns{constructor(){super(2.25),this._params={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._vignetteParams={strength:.3,start:.78,range:.46,fadePower:.2,color:{r:1,g:1,b:1,a:1}},this.particlesCount=16e3,this._devtoolsFolder=null,this._painter=null}destroy(){super.destroy()}update(a){let t=a.context;if(!this.particlesVx){let o=Nd(this.particlesCount),c=new h.ei,d=new h.dF,m=0,_=h.ef(1323123451230);for(let y=0;y<o.length;++y){let v=o[y],T=_(),I=_(),P=_(),A=[y/o.length,T,I,P],D=[_(),_()];c.emplaceBack(v[0],v[1],v[2],-1,-1,...A,...D),c.emplaceBack(v[0],v[1],v[2],1,-1,...A,...D),c.emplaceBack(v[0],v[1],v[2],1,1,...A,...D),c.emplaceBack(v[0],v[1],v[2],-1,1,...A,...D),d.emplaceBack(m+0,m+1,m+2),d.emplaceBack(m+0,m+2,m+3),m
3281+=4}this.particlesVx=t.createVertexBuffer(c,Ba.members),this.particlesIdx=t.createIndexBuffer(d)}}getDrawParams(a){if(!a.style.snow)return null;let t=a.style.snow.state,o=structuredClone(this._params);o.intensity=t.density,o.timeFactor=t.intensity,o.color=structuredClone(t.color),o.screenThinning.intensity=t.centerThinning,o.billboardSize=2.79*t.flakeSize;let c=structuredClone(this._vignetteParams);return c.strength=1,c.color=structuredClone(t.vignetteColor),{params:o,vignetteParams:c,revealParams:{revealStart:0,revealRange:.01},direction:structuredClone(t.direction)}}draw(a){let t=this.getDrawParams(a);if(!t)return;let{params:o,revealParams:c,direction:d,vignetteParams:m}=t,_=a.transform.zoom;if(c.revealStart>_)return;let y=Hn(0,1,c.revealStart,c.revealStart+c.revealRange,_);m.strength*=y;let v=this.updateOnRender(a,o.timeFactor);if(!this.particlesVx||!this.particlesIdx)return;let T=a.context,I=T.gl,P=a.transform,A=a.getOrCreateProgram("snowParticle");a.uploadCommonUniforms(T,A),((D,L,O)=>{let k=Ct(this._movement.getPosition(),D),N=P.width/2,q=P.height/2,Z=Hn(0,O.screenThinning.start,0,1,O.screenThinning.intensity),G=Hn(.001,O.screenThinning.range,0,1,O.screenThinning.intensity),re=Hn(0,O.screenThinning.particleOffset,0,1,O.screenThinning.intensity),te=(se={modelview:v.modelviewMatrix,projection:v.projectionMatrix,time:this._accumulatedTimeFromStart,camPos:k,velocityConeAperture:O.velocityConeAperture,velocity:O.velocity,horizontalOscillationRadius:O.horizontalOscillationRadius,horizontalOscillationRate:O.horizontalOscillationRate,boxSize:D,billboardSize:1*O.billboardSize,simpleShapeParameters:[O.shapeFadeStart,O.shapeFadePower],screenSize:[P.width,P.height],thinningCenterPos:[N,q],thinningShape:[Z,G,Math.pow(10,O.screenThinning.fadePower)],thinningAffectedRatio:O.screenThinning.affectedRatio,thinningParticleOffset:re,color:[O.color.r,O.color.g,O.color.b,O.color.a],direction:d},{u_modelview:Float32Array.from(se.modelview),u_projection:Float32Array.from(se.projection),u_time:se.time,u_cam_pos:se.camPos,u_velocityConeAperture:se.velocityConeAperture,u_velocity:se.velocity,u_horizontalOscillationRadius:se.horizontalOscillationRadius,u_horizontalOscillationRate:se.horizontalOscillationRate,u_boxSize:se.boxSize,u_billboardSize:se.billboardSize,u_simpleShapeParameters:se.simpleShapeParameters,u_screenSize:se.screenSize,u_thinningCenterPos:se.thinningCenterPos,u_thinningShape:se.thinningShape,u_thinningAffectedRatio:se.thinningAffectedRatio,u_thinningParticleOffset:se.thinningParticleOffset,u_particleColor:se.color,u_direction:se.direction});var se;let K=Math.round(O.intensity*this.particlesCount),J=h.dB.simpleSegment(0,0,4*K,2*K);this.particlesVx&&this.particlesIdx&&A.draw(a,I.TRIANGLES,nt.disabled,gt.disabled,mt.alphaBlended,dt.disabled,te,"snow_particles",this.particlesVx,this.particlesIdx,J)})(o.boxSize,0,o),this._vignette.draw(a,m)}},shaders:ir,programUniforms:Do};function nh(a){return[a[0]*h.ej,a[1]*h.ej,a[2]*h.ej,0]}function Hc(a,t,o,c,d,m,_,y,v){let T=c.getSource(),I=o.globeSharedBuffers;if(!I)return;let P,A,D;if(t&&(P=c.getTile(t)),T instanceof h.aY?(A=T.texture,D=h.dz(0,0,o.transform)):P&&t&&(A=P.texture,D=h.dz(t.canonical.z,t.canonical.x,o.transform)),!A||!D)return;a||(D=h.cE(h.bd(),D,[1,-1,1]));let L=o.context,O=L.gl,k=d.paint.get("raster-resampling")==="nearest"?O.NEAREST:O.LINEAR,N=o.colorModeForDrapableLayerRenderPass(m),q=_.defines;q.push("GLOBE_POLES");let Z=new nt(O.LEQUAL,nt.ReadWrite,o.depthRangeFor3D),G=o.transform.expandedFarZProjMatrix,re=Float32Array.from(h.dx(h.dy(new h.cp(0,0,0))));o.terrain&&o.terrain.prepareDrawTile(),L.activeTexture.set(O.TEXTURE0),A.bind(k,O.CLAMP_TO_EDGE),L.activeTexture.set(O.TEXTURE1),A.bind(k,O.CLAMP_TO_EDGE),"useMipmap"in A&&L.extTextureFilterAnisotropic&&o.transform.pitch>20&&O.texParameterf(O.TEXTURE_2D,L.extTextureFilterAnisotropic.TEXTURE_MAX_ANISOTROPY_EXT,L.extTextureFilterAnisotropicMax);let[te,se,K,J]=t?I.getPoleBuffers(t.canonical.z,!1):I.getPoleBuffers(0,!0),oe=d.paint.get("raster-elevation"),ue;a?(ue=te,o.renderDefaultNorthPole=oe!==0):(ue=se,o.renderDefaultSouthPole=oe!==0);let de=nh(_.mix),be=((Fe,pe,Ie,fe,Pe,Ce,Re,Ye,$e,je,Ue,at,ot,et)=>Yu(Fe,pe,Ie,fe,new Float32Array(16),new Float32Array(9),[0,0],Pe,[0,0],[0,0,0,0],1,{opacity:1,mix:0},Re,[0,0],$e,2,Ue,at,ot,1,0,et))(o,G,re,D,h.ai(o.transform.zoom),0,d,0,oe,0,de,_.offset,_.range,m),ve=o.getOrCreateProgram("raster",{defines:q});o.uploadCommonUniforms(L,ve,null),ve.draw(o,O.TRIANGLES,Z,v,N,y,be,d.id,ue,K,J)}function Ud(a){if(a.isOrthographic)return[0,0,0,0];let t=a._nearZ,o=a.projection.farthestPixelDistance(a),c=o-t,d=.2*a.height,m=t+d;
3281return[t,o,(m-d-t)/c,(m-t)/c]}function Vd(a,t,o,c){if(a)return t instanceof jt&&a instanceof st?t.getTextureDescriptor(a,o,!0):{texture:a.texture,mix:nh(c.mix),offset:c.offset,buffer:0,tileSize:1}}let Br=h.bA(new Float32Array(16)),Us=new h.C(1,0,0,1),Al=new h.C(0,1,0,1),rh=new h.C(0,0,1,1),jd=new h.C(1,0,1,1),Gd=new h.C(0,1,1,1);function Vs(a,t,o,c,d,m,_){let y=a.context,v=a.transform,T=y.gl,I=v.projection.name==="globe",P=I?["PROJECTION_GLOBE_VIEW"]:[],A=h.bb(o.projMatrix);if(I&&h.ai(v.zoom)>0){let de=h.ek(o.canonical,v),be=h.el(de);A=h.aC(new Float32Array(16),v.globeMatrix,be),h.aC(A,v.projMatrix,A)}let D=h.bd();D[12]+=2*d/(h.o.devicePixelRatio*v.width),D[13]+=2*m/(h.o.devicePixelRatio*v.height),h.aC(A,D,A);let L=a.getOrCreateProgram("debug",{defines:P}),O=t.getTileByID(o.key);a.terrain&&a.terrain.setupElevationDraw(O,L);let k=nt.disabled,N=gt.disabled,q=a.colorModeForRenderPass(),Z="$debug";y.activeTexture.set(T.TEXTURE0),a.emptyTexture.bind(T.LINEAR,T.CLAMP_TO_EDGE),I?O._makeGlobeTileDebugBuffers(a.context,v):O._makeDebugTileBoundsBuffers(a.context,v.projection);let G=O._tileDebugBuffer||a.debugBuffer,re=O._tileDebugIndexBuffer||a.debugIndexBuffer,te=O._tileDebugSegments||a.debugSegments;if(L.draw(a,T.LINE_STRIP,k,N,q,dt.disabled,Fc(A,c.toPremultipliedRenderColor(null)),Z,G,re,te,null,null,null,[O._globeTileDebugBorderBuffer]),_){let de=O.latestRawTileData,be=Math.floor((de&&de.byteLength||0)/1024),ve=o.canonical.toString();o.overscaledZ!==o.canonical.z&&(ve+=` => ${o.overscaledZ}`),ve+=` ${O.state}`,ve+=` ${be}kb`,function(Fe,pe){Fe.initDebugOverlayCanvas();let Ie=Fe.debugOverlayCanvas,fe=Fe.context.gl,Pe=Fe.debugOverlayCanvas.getContext("2d");Pe.clearRect(0,0,Ie.width,Ie.height),Pe.shadowColor="white",Pe.shadowBlur=2,Pe.lineWidth=1.5,Pe.strokeStyle="white",Pe.textBaseline="top",Pe.font="bold 36px Open Sans, sans-serif",Pe.fillText(pe,5,5),Pe.strokeText(pe,5,5),Fe.debugOverlayTexture.update(Ie),Fe.debugOverlayTexture.bind(fe.LINEAR,fe.CLAMP_TO_EDGE)}(a,ve)}let se=t.getTile(o).tileSize,K=512/Math.min(se,512)*(o.overscaledZ/v.zoom)*.5,J=O._tileDebugTextBuffer||a.debugBuffer,oe=O._tileDebugTextIndexBuffer||a.quadTriangleIndexBuffer,ue=O._tileDebugTextSegments||a.debugSegments;L.draw(a,T.TRIANGLES,k,N,mt.alphaBlended,dt.disabled,Fc(A,h.C.transparent.toPremultipliedRenderColor(null),K),Z,J,oe,ue,null,null,null,[O._globeTileDebugTextBuffer])}function oh(a,t,o,c){Ml(a,0,t+o/2,a.transform.width,o,c)}function kr(a,t,o,c){Ml(a,t-o/2,0,o,a.transform.height,c)}function Ml(a,t,o,c,d,m){let _=a.context,y=_.gl;y.enable(y.SCISSOR_TEST),y.scissor(t*h.o.devicePixelRatio,o*h.o.devicePixelRatio,c*h.o.devicePixelRatio,d*h.o.devicePixelRatio),_.clear({color:m}),y.disable(y.SCISSOR_TEST)}let sh=h.ea([{name:"a_pos_3f",components:3,type:"Float32"}]),{members:$d}=sh;function Ro(a,t,o,c){a.emplaceBack(t,o,c)}class Xi{constructor(t){this.vertexArray=new h.em,this.indices=new h.dF,Ro(this.vertexArray,-1,-1,1),Ro(this.vertexArray,1,-1,1),Ro(this.vertexArray,-1,1,1),Ro(this.vertexArray,1,1,1),Ro(this.vertexArray,-1,-1,-1),Ro(this.vertexArray,1,-1,-1),Ro(this.vertexArray,-1,1,-1),Ro(this.vertexArray,1,1,-1),this.indices.emplaceBack(5,1,3),this.indices.emplaceBack(3,7,5),this.indices.emplaceBack(6,2,0),this.indices.emplaceBack(0,4,6),this.indices.emplaceBack(2,6,7),this.indices.emplaceBack(7,3,2),this.indices.emplaceBack(5,4,0),this.indices.emplaceBack(0,1,5),this.indices.emplaceBack(0,2,3),this.indices.emplaceBack(3,1,0),this.indices.emplaceBack(7,6,4),this.indices.emplaceBack(4,5,7),this.vertexBuffer=t.createVertexBuffer(this.vertexArray,$d),this.indexBuffer=t.createIndexBuffer(this.indices),this.segment=h.dB.simpleSegment(0,0,36,12)}}function js(a,t,o,c,d,m){let _=a.context.gl,y=t.paint.get("sky-atmosphere-color"),v=t.paint.get("sky-atmosphere-halo-color"),T=t.paint.get("sky-atmosphere-sun-intensity"),I=((P,A,D,L,O)=>({u_matrix_3f:P,u_sun_direction:A,u_sun_intensity:D,u_color_tint_r:[L.r,L.g,L.b,L.a],u_color_tint_m:[O.r,O.g,O.b,O.a],u_luminance:5e-5}))(h.ep(h.dH(),c),d,T,y.toPremultipliedRenderColor(null),v.toPremultipliedRenderColor(null));_.framebufferTexture2D(_.FRAMEBUFFER,_.COLOR_ATTACHMENT0,_.TEXTURE_CUBE_MAP_POSITIVE_X+m,t.skyboxTexture,0),o.draw(a,_.TRIANGLES,nt.disabled,gt.disabled,mt.unblended,dt.frontCW,I,"skyboxCapture",t.skyboxGeometry.vertexBuffer,t.skyboxGeometry.indexBuffer,t.skyboxGeometry.segment)}let Hd=h.ea([{type:"Float32",name:"a_pos",components:3},{type:"Float32",name:"a_uv",components:2}]);class qd{constructor(t){let o=new h.eq;o.emplaceBack(-1,1,1,0,0),o.emplaceBack(1,1,1,1,0),o.emplaceBack(1,-1,1,1,1),o.emplaceBack(-1,-1,1,0,1);let c=new h.dF;c.emplaceBack(0,1,2),c.emplaceBack(2,3,0),this.vertexBuffer=t.createVertexBuffer(o,Hd.members),this.indexBuffer=t.createIndexBuffer(c),this.segments=h.dB.simpleSegment(0,0,4,2)}destroy(){this.vertexBuffer.destroy(),this.indexBuffer.destroy(),this.segments.destroy()}}let ka=h.ea([{type:"Float32",name:"a_pos_3f",components:3},{type:"Float32",name:"a_uv",components:2},{type:"Float32",name:"a_size_scale",components:1},{type:"Float32",name:"a_opacity",components:1}]);class Zd{constructor(){this.colorModeAlphaBlendedWriteRGB=new mt([1,As,1,As],h.C.transparent,[!0,!0,!0,!1]),this.colorModeWriteAlpha=new mt([1,0,1,0],h.C.transparent,[!1,!1,!1,!0]),this.params={starsCount:16e3,sizeMultiplier:.15,sizeRange:100,intensityRange:200},this.updateNeeded=!0,this._painter=null,this._devtoolsFolder=null}update(t){this._painter=t;let o=t.context;if(!this.atmosphereBuffer||this.updateNeeded){this.updateNeeded=!1,this.atmosphereBuffer=new qd(o);let c=this.params,d=c.sizeRange,m=c.intensityRange,_=function(P){let A=h.ef(30),D=[];for(let L=0;L<P;
3281++L){let O=2*Math.PI*A(),k=Math.acos(1-2*A())-.5*Math.PI;D.push(h.cU(Math.cos(k)*Math.cos(O),Math.cos(k)*Math.sin(O),Math.sin(k)))}return D}(c.starsCount),y=h.ef(300),v=new h.er,T=new h.dF,I=0;for(let P=0;P<_.length;++P){let A=h.bN([],_[P],200),D=Math.max(0,1+.01*d*(1*y()-.5)),L=Math.max(0,1+.01*m*(1*y()-.5));v.emplaceBack(A[0],A[1],A[2],-1,-1,D,L),v.emplaceBack(A[0],A[1],A[2],1,-1,D,L),v.emplaceBack(A[0],A[1],A[2],1,1,D,L),v.emplaceBack(A[0],A[1],A[2],-1,1,D,L),T.emplaceBack(I+0,I+1,I+2),T.emplaceBack(I+0,I+2,I+3),I+=4}this.starsVx=o.createVertexBuffer(v,ka.members),this.starsIdx=o.createIndexBuffer(T),this.starsSegments=h.dB.simpleSegment(0,0,v.length,T.length)}}destroy(){this.atmosphereBuffer&&this.atmosphereBuffer.destroy(),this.starsVx&&this.starsVx.destroy(),this.starsIdx&&this.starsIdx.destroy(),this._painter=null}drawAtmosphereGlow(t,o){let c=t.context,d=c.gl,m=t.transform,_=new nt(d.LEQUAL,nt.ReadOnly,[0,1]),y=h.ai(m.zoom),v=t.style.getLut(o.scope),T=o.properties.get("color-use-theme")==="none",I=o.properties.get("color").toNonPremultipliedRenderColor(T?null:v),P=o.properties.get("high-color-use-theme")==="none",A=o.properties.get("high-color").toNonPremultipliedRenderColor(P?null:v),D=o.properties.get("space-color-use-theme")==="none",L=o.properties.get("space-color").toNonPremultipliedRenderColor(D?null:v),O=5e-4,k=h.es(o.properties.get("horizon-blend"),0,1,O,.25),N=h.ds(t,c,m)&&k===O?m.worldSize/(2*Math.PI*1.025)-1:m.globeRadius,q=t.frameCounter/1e3%1,Z=h.af(m.globeCenterInViewSpace),G=Math.sqrt(Math.pow(Z,2)-Math.pow(N,2)),re=Math.acos(G/Z),te=se=>{let K=m.projection.name==="globe"?["PROJECTION_GLOBE_VIEW","FOG"]:["FOG"];se&&K.push("ALPHA_PASS");let J=t.getOrCreateProgram("globeAtmosphere",{defines:K}),oe=((de,be,ve,Fe,pe,Ie,fe,Pe,Ce,Re,Ye,$e)=>({u_frustum_tl:de,u_frustum_tr:be,u_frustum_br:ve,u_frustum_bl:Fe,u_horizon:pe,u_transition:Ie,u_fadeout_range:fe,u_atmosphere_fog_color:Pe.toArray01(),u_high_color:Ce.toArray01(),u_space_color:Re.toArray01(),u_temporal_offset:Ye,u_horizon_angle:$e}))(m.frustumCorners.TL,m.frustumCorners.TR,m.frustumCorners.BR,m.frustumCorners.BL,m.frustumCorners.horizon,y,k,I,A,L,q,re);t.uploadCommonUniforms(c,J);let ue=this.atmosphereBuffer;ue&&J.draw(t,d.TRIANGLES,_,gt.disabled,se?this.colorModeWriteAlpha:this.colorModeAlphaBlendedWriteRGB,dt.backCW,oe,se?"atmosphere_glow_alpha":"atmosphere_glow",ue.vertexBuffer,ue.indexBuffer,ue.segments)};te(!1),te(!0)}drawStars(t,o){let c=h.aB(o.properties.get("star-intensity"),0,1);if(c===0)return;let d=t.context,m=d.gl,_=t.transform,y=t.getOrCreateProgram("stars"),v=h.bP([]);h.bR(v,v,-_._pitch),h.bQ(v,v,-_.angle),h.bR(v,v,h.am(_._center.lat)),h.et(v,v,-h.am(_._center.lng));let T=h.bV(new Float32Array(16),v),I=h.aC([],_.starsProjMatrix,T),P=h.ep([],T),A=h.eu([],P),D=this.params.sizeMultiplier,L=[0,1,0];h.dJ(L,L,A),h.bN(L,L,D);let O=[1,0,0];h.dJ(O,O,A),h.bN(O,O,D);let k=(N=L,q=O,Z=c,{u_matrix:Float32Array.from(I),u_up:N,u_right:q,u_intensity_multiplier:Z});var N,q,Z;t.uploadCommonUniforms(d,y),this.starsVx&&this.starsIdx&&y.draw(t,m.TRIANGLES,nt.disabled,gt.disabled,this.colorModeAlphaBlendedWriteRGB,dt.disabled,k,"atmosphere_stars",this.starsVx,this.starsIdx,this.starsSegments)}}class Wd{constructor(){this.visibleTiles=[]}updateBorders(t,o){let c=[],d=[],m=t._getRenderableCoordinates(!1,!0);for(let v of m){let T=t.getTile(v);if(!T.hasData())continue;let I=T.getBucket(o);I&&(I.isEmpty()||(c.push(v.key),d.push({bucket:I,tileID:v.canonical})))}let _=c.length!==this.visibleTiles.length;if(!_){c.sort();for(let v=0;v<c.length;v++)if(c[v]!==this.visibleTiles[v]){_=!0;break}}if(!_)return;let y=new Set;this.visibleTiles=c,d.sort((v,T)=>v.tileID.z-T.tileID.z||v.tileID.x-T.tileID.x||v.tileID.y-T.tileID.y);for(let v of d){let T=new Array,I=new Array,P=v.bucket;for(let A of P.featuresOnBorder)y.has(A.featureId)?I.push(A.footprintIndex):(y.add(A.featureId),T.push(A.footprintIndex));P.updateFootprintHiddenFlags(T,h.ev,!1),P.updateFootprintHiddenFlags(I,h.ev,!0)}}}let hr=new Float64Array(16),nr=new Float64Array(16),ah=new Float64Array(16),Cl=new Float32Array(16),Pl=[0,0,0];function Dl(a,t,o){let c=o.cameraWorldSizeForFog/o.worldSize;return h.cE(a,o.worldToFogMatrix,[c,c,1]),h.aC(a,a,t),a}function Rl(a,t,o,c,d){let m=o.material,_=c.context,{baseColorTexture:y,metallicRoughnessTexture:v}=m.pbrMetallicRoughness,{normalTexture:T,occlusionTexture:I,emissionTexture:P}=m;function A(L,O,k){if(L&&(a.push(O),_.activeTexture.set(_.gl.TEXTURE0+k),L.gfxTexture)){let{minFilter:N,magFilter:q,wrapS:Z,wrapT:G}=L.sampler;L.gfxTexture.bindExtraParam(N,q,Z,G)}}A(y,"HAS_TEXTURE_u_baseColorTexture",5),A(v,"HAS_TEXTURE_u_metallicRoughnessTexture",6),A(T,"HAS_TEXTURE_u_normalTexture",7),A(I,"HAS_TEXTURE_u_occlusionTexture",8),A(P,"HAS_TEXTURE_u_emissionTexture",9),d&&(d.texture||(d.texture=new h.dU(c.context,d.image,[d.image.height,d.image.height,d.image.height],_.gl.RGBA8)),_.activeTexture.set(_.gl.TEXTURE0+10),d.texture&&d.texture.bind(_.gl.LINEAR,_.gl.CLAMP_TO_EDGE),a.push("APPLY_LUT_ON_GPU")),o.texcoordBuffer&&(a.push("HAS_ATTRIBUTE_a_uv_2f"),t.push(o.texcoordBuffer)),o.colorBuffer&&(a.push(o.colorBuffer.itemSize===12?"HAS_ATTRIBUTE_a_color_3f":"HAS_ATTRIBUTE_a_color_4f"),t.push(o.colorBuffer)),o.normalBuffer&&(a.push("HAS_ATTRIBUTE_a_normal_3f"),t.push(o.normalBuffer)),o.pbrBuffer&&(a.push("HAS_ATTRIBUTE_a_pbr"),a.push("HAS_ATTRIBUTE_a_heightBasedEmissiveStrength"),t.push(o.pbrBuffer)),m.alphaMode!=="OPAQUE"&&m.alphaMode!=="MASK"||a.push("UNPREMULT_TEXTURE_IN_SHADER"),m.defined||a.push("DIFFUSE_SHADED");let D=c.shadowRenderer;D&&(a.push("RENDER_SHADOWS"),D.useNormalOffset&&a.push("NORMAL_OFFSET"))}function zl(a,t,o,c,d,m){let _=a.modelOpacity,y=t.context,v=new nt(t.context.gl.LEQUAL,a.isLightMesh?nt.ReadOnly:nt.ReadWrite,t.depthRangeFor3D),T=t.transform,I=a.mesh,P=I.material,A=P.pbrMetallicRoughness,D=t.style.fog;t.transform.projection.zAxisUnit==="pixels"?hr.set(a.nodeModelMatrix):h.aC(hr,c.zScaleMatrix,a.nodeModelMatrix),h.aC(hr,c.negCameraPosMatrix,hr),h.ba(nr,hr),h.e9(nr,nr);
3281let L=o.paint.get("model-color-use-theme").constantOr("default")==="none",O=o.paint.get("model-emissive-strength").constantOr(0),k=zd(a.worldViewProjection,hr,nr,null,t,_,A.baseColorFactor,P.emissiveFactor,A.metallicFactor,A.roughnessFactor,P,O,o,void 0,void 0,a.materialOverride,a.modelColor),N={defines:[]},q=[],Z=t.shadowRenderer;Z&&(Z.useNormalOffset=!1),Rl(N.defines,q,I,t,L?null:o.lut);let G=null;if(D&&(G=Dl(ah,a.nodeModelMatrix,t.transform),T.projection.name!=="globe")){let se=I.aabb.min,K=I.aabb.max,[J,oe]=D.getOpacityForBounds(G,se[0],se[1],K[0],K[1]);N.overrideFog=J>=ws||oe>=ws}let re=Cs(t,o.paint.get("model-cutoff-fade-range"));re.shouldRenderCutoff&&N.defines.push("RENDER_CUTOFF");let te=t.getOrCreateProgram("model",N);t.uploadCommonUniforms(y,te,null,G,re),t.renderPass!=="shadow"&&Z&&Z.setupShadowsFromMatrix(a.nodeModelMatrix,te),te.draw(t,y.gl.TRIANGLES,v,d,m,I.material.doubleSided?dt.disabled:dt.backCCW,k,o.id,I.vertexBuffer,I.indexBuffer,I.segments,o.paint,t.transform.zoom,void 0,q)}function Xd(a,t){return a.style._importedAsBasemap?"basemap":t.scope}function qc(a,t,o,c,d,m,_,y,v,T){let I=a.transform,P=!!t.isGeometryBloom&&t.isGeometryBloom;if(P&&a.renderPass==="shadow")return;let A=I.projection.name==="globe"?h.eD(o,I):[...o];h.aC(A,A,t.globalMatrix);let D=h.aC([],c,A);if(t.meshes)for(let L of t.meshes){let O=y.get(L.material.name);if(O&&O.opacity<=0)continue;if(L.material.alphaMode!=="BLEND"){_.push({mesh:L,depth:0,modelIndex:d,worldViewProjection:D,nodeModelMatrix:A,isLightMesh:P,materialOverride:O,modelOpacity:v,modelColor:T,node:t,modelMatrix:o});continue}let k=h.ae([],L.centroid,D);!I.isOrthographic&&k[2]<=0||m.push({mesh:L,depth:k[2],modelIndex:d,worldViewProjection:D,nodeModelMatrix:A,isLightMesh:P,materialOverride:O,modelOpacity:v,modelColor:T,node:t,modelMatrix:o})}if(t.children)for(let L of t.children)qc(a,L,o,c,d,m,_,y,v,T)}function Ll(a,t,o,c){let d=o.shadowRenderer;if(!d)return;let m=d.getShadowPassDepthMode(),_=d.calculateShadowPassMatrixFromMatrix(t),y=Ld(_);o.getOrCreateProgram("modelDepth").draw(o,o.context.gl.TRIANGLES,m,gt.disabled,mt.disabled,dt.disabled,y,c.id,a.vertexBuffer,a.indexBuffer,a.segments,c.paint,o.transform.zoom,void 0,void 0)}function Yd(a,t,o,c){let d=function(I,P){if(P.footprintDebugMesh)return P.footprintDebugMesh;if(!P.footprint)return null;let A=I.context,D=P.footprint.vertices,L=P.footprint.indices,O=new h.dE;O.reserve(D.length);for(let oe of D)O.emplaceBack(oe.x,oe.y);let k=new h.dF;k.reserve(L.length);for(let oe=0;oe<L.length;oe+=3)k.emplaceBack(L[oe],L[oe+1],L[oe+2]);let N=A.createVertexBuffer(O,h.dA.members),q=A.createIndexBuffer(k),Z=h.dB.simpleSegment(0,0,D.length,L.length),G=P.id||P.name||"footprint",re,te=parseInt(G,10);re=isNaN(te)?function(oe){let ue=0;for(let de=0;de<oe.length;de++)ue=(ue<<5)-ue+oe.charCodeAt(de)|0;return ue}(G):te;let se=h.ed(re),K=h.ed(re+1),J=h.ed(re+2);return P.footprintDebugMesh={vertexBuffer:N,indexBuffer:q,segments:Z,color:new h.C(se,K,J,.5)},P.footprintDebugMesh}(a,o);if(!d)return;let m=a.context,_=m.gl,y=a.getOrCreateProgram("debug"),v=d.color,T=nt.disabled;m.activeTexture.set(_.TEXTURE0),a.emptyTexture.bind(_.LINEAR,_.CLAMP_TO_EDGE),y.draw(a,_.TRIANGLES,T,gt.disabled,mt.alphaBlended,dt.disabled,Fc(c,v.toPremultipliedRenderColor(null)),"$debug",d.vertexBuffer,d.indexBuffer,d.segments)}function cm(a,t,o,c,d,m){for(let _ of d){let y=Object.assign({},c);y.part=_;let v={type:"Unknown",id:t,properties:y},T={orientation:a.paint.get("model-rotation").evaluate(v,o)};m.set(_,T)}}function um(a,t,o,c,d,m){for(let _ of d){let y=Object.assign({},c);y.part=_;let v={type:"Unknown",id:t,properties:y},T={color:a.paint.get("model-color").evaluate(v,o),colorMix:a.paint.get("model-color-mix-intensity").evaluate(v,o),opacity:a.paint.get("model-opacity").evaluate(v,o),emissionStrength:a.paint.get("model-emissive-strength").evaluate(v,o)};m.set(_,T)}}function Jd(a,t,o,c,d){let m=!1;for(let y of c)y.modelOpacity!==1&&(zl(y,a,t,d[y.modelIndex],gt.disabled,mt.disabled),m=!0);for(let y of c)zl(y,a,t,d[y.modelIndex],y.modelOpacity!==1?a.stencilModeFor3D():gt.disabled,a.colorModeForRenderPass());m&&a.resetStencilClippingMasks();let _=mt.additive;for(let y of o)zl(y,a,t,d[y.modelIndex],gt.disabled,y.isLightMesh?_:a.colorModeForRenderPass())}function hm(a,t,o){let c=t.updateZoomBasedPaintProperties(),d=function(m,_,y){let v,T,I,P=m.terrain?m.terrain.exaggeration():0;if(m.terrain&&P>0){let A=m.terrain,D=A.findDEMTileFor(y);D&&D.dem?v=h.eF.create(A,y,D):P=0}if(P===0&&(_.terrainElevationMin=0,_.terrainElevationMax=0),P===_.validForExaggeration&&(P===0||v&&v._demTile&&v._demTile.tileID===_.validForDEMTile.id&&v._dem._timestamp===_.validForDEMTile.timestamp))return!1;for(let A in _.instancesPerModel){let D=_.instancesPerModel[A];for(let L=0;L<D.instancedDataArray.length;++L){let O=(v?P*v.getElevationAt(0|D.instancedDataArray.float32[16*L],0|D.instancedDataArray.float32[16*L+1],!0,!0):0)+D.instancesEvaluatedElevation[L];D.instancedDataArray.float32[16*L+6]=O,T=T?Math.min(_.terrainElevationMin,O):O,I=I?Math.max(_.terrainElevationMax,O):O}}return _.terrainElevationMin=T||0,_.terrainElevationMax=I||0,_.validForExaggeration=P,_.validForDEMTile=v&&v._demTile?{id:v._demTile.tileID,timestamp:v._dem._timestamp}:{id:void 0,timestamp:0},!0}(a,t,o);(c||d)&&(t.uploaded=!1,t.upload(a.context))}let vo={shadowUniformsInitialized:!1,useSingleShadowCascade:!1,tileMatrix:new Float64Array(16),shadowTileMatrix:new Float32Array(16),aabb:new h.cY([0,0,0],[h.ak,h.ak,0])};function dm(a,t){let o=1<<a.canonical.z,c=t.getFreeCameraOptions().position,d=t.elevation,m=a.canonical.x/o,_=(a.canonical.x+1)/o,y=a.canonical.y/o,v=(a.canonical.y+1)/o,T=t._centerAltitude;if(d){let D=d.getMinMaxForTile(a);D&&D.max>T&&(T=D.max)}let I=h.aB(c.x,m,_)-c.x,P=h.aB(c.y,y,v)-c.y,A=h.bY(T,t.center.lat)-c.z;return t._zoomFromMercatorZ(Math.sqrt(I*I+P*P+A*A))}function Kd(a,t,o,c,d,m,_){let y=a.context,v=a.renderPass==="shadow",T=a.shadowRenderer,I=v&&T?T.getShadowPassDepthMode():new nt(y.gl.LEQUAL,nt.ReadWrite,a.depthRangeFor3D),P=a.isTileAffectedByFog(m),A=a.transform.projection.name==="globe";if(o.meshes)for(let D of o.meshes){let L=A?[]:["MODEL_POSITION_ON_GPU"],O=[],k,N,q,Z=!A&&c.instancedDataArray.length>20;Z&&L.push("INSTANCED_ARRAYS");let G=Cs(a,t.paint.get("model-cutoff-fade-range"));if(G.shouldRenderCutoff&&L.push("RENDER_CUTOFF"),v&&T)k=a.getOrCreateProgram("modelDepth",{defines:L}),N=Ld(_.shadowTileMatrix,_.shadowTileMatrix,o.globalMatrix),q=mt.disabled;
3281else{Rl(L,O,D,a,t.paint.get("model-color-use-theme").constantOr("default")==="none"?null:t.lut),k=a.getOrCreateProgram("model",{defines:L,overrideFog:P});let te=D.material,se=te.pbrMetallicRoughness,K=t.paint.get("model-opacity").constantOr(1),J=t.paint.get("model-emissive-strength").constantOr(0);N=zd(m.expandedProjMatrix,o.globalMatrix,Cl,null,a,K,se.baseColorFactor,te.emissiveFactor,se.metallicFactor,se.roughnessFactor,te,J,t,d),T&&(_.shadowUniformsInitialized?k.setShadowUniformValues(y,T.getShadowUniformValues()):(T.setupShadows(m.toUnwrapped(),k,"model-tile"),_.shadowUniformsInitialized=!0)),q=G.shouldRenderCutoff||K<1||te.alphaMode!=="OPAQUE"?mt.alphaBlended:mt.unblended}a.uploadCommonUniforms(y,k,m.toUnwrapped(),null,G);let re=D.material.doubleSided?dt.disabled:dt.backCCW;if(Z)O.push(c.instancedDataBuffer),k.draw(a,y.gl.TRIANGLES,I,gt.disabled,q,re,N,t.id,D.vertexBuffer,D.indexBuffer,D.segments,t.paint,a.transform.zoom,void 0,O,c.instancedDataArray.length);else{let te=v?"u_instance":"u_normal_matrix";for(let se=0;se<c.instancedDataArray.length;++se)N[te]=new Float32Array(c.instancedDataArray.arrayBuffer,64*se,16),k.draw(a,y.gl.TRIANGLES,I,gt.disabled,q,re,N,t.id,D.vertexBuffer,D.indexBuffer,D.segments,t.paint,a.transform.zoom,void 0,O)}}if(o.children)for(let D of o.children)Kd(a,t,D,c,d,m,_)}let pm=[1,-1,1];function fm(a,t,o,c){let d=a.node;if(d.lodMeshes&&d.lodMeshes.length>0)if(a.targetLod<0)a.targetLod=t>c?1:0;else{let m=o/1e3;a.targetLod=t>c?Math.min(a.targetLod+m,1):Math.max(a.targetLod-m,0)}else a.targetLod=0}function lg(a,t,o,c){if(!o.modelManager)return!0;let d=o.modelManager;if(!o.shadowRenderer)return!0;let m=o.shadowRenderer,_=t.aabb,y=!0,v=a.maxHeight;if(v===0){let I=0;for(let P in a.instancesPerModel){let A=d.getModel(P,c);A?I=Math.max(I,Math.max(Math.max(A.aabb.max[0],A.aabb.max[1]),A.aabb.max[2])):y=!1}v=a.maxScale*I*1.41+a.maxVerticalOffset,y&&(a.maxHeight=v)}_.max[2]=v,_.min[2]+=a.terrainElevationMin,_.max[2]+=a.terrainElevationMax,h.ae(_.min,_.min,t.tileMatrix),h.ae(_.max,_.max,t.tileMatrix);let T=_.intersects(m.getCurrentCascadeFrustum());return o.currentShadowCascade===0&&(a.isInsideFirstShadowMapFrustum=T===2),T===0}function cg(a,t){let o=a.uniformValues.u_cutoff_params[0],c=a.uniformValues.u_cutoff_params[1],d=a.uniformValues.u_cutoff_params[2],m=a.uniformValues.u_cutoff_params[3];return c===o||m===d?1:h.aB(((t-o)/(c-o)-d)/(m-d),0,1)}function ug(a,t,o,c){if(t.pitch<20)return 1;let d=t.getWorldToCameraMatrix();h.aC(d,d,a);let m=h.bw(o.min[0],o.min[1],o.min[2],1),_=h.aD(h.bI(),m,d),y=_,v=_;m[1]=o.max[1],_=h.aD(h.bI(),m,d),y=_[1]<y[1]?_:y,v=_[1]>v[1]?_:v,m[0]=o.max[0],_=h.aD(h.bI(),m,d),y=_[1]<y[1]?_:y,v=_[1]>v[1]?_:v,m[1]=o.min[1],_=h.aD(h.bI(),m,d),y=_[1]<y[1]?_:y,v=_[1]>v[1]?_:v;let T=h.aB(c[0],0,1),I=100*t.pixelsPerMeter*h.aB(c[1],0,1),P=h.aB(c[2],0,1),A=h.eG(h.bI(),y,v,T),D=Math.tan(.5*t.fovX),L=-A[2]*D;if(I===0)return A[1]<-Math.abs(L)?P:1;let O=(-Math.abs(L)-A[1])/I,k=(q,Z,G)=>(1-G)*q+G*Z,N=h.aB(k(1,P,O),P,1);return k(1,N,h.aB((t.pitch-20)/20,0,1))}class pi{}class Ol{constructor(){this._storage=new Map}getLinesFromTrianglesBuffer(t,o,c){{let P=this._storage.get(o.id);if(P)return P.lastUsedFrameIdx=t,P.buf}let d=c.gl,m=d.getBufferParameter(d.ELEMENT_ARRAY_BUFFER,d.BUFFER_SIZE),_=new ArrayBuffer(m),y=new Int16Array(_);d.getBufferSubData(d.ELEMENT_ARRAY_BUFFER,0,new Int16Array(_));let v=new h.eI;for(let P=0;P<m/2;P+=3){let A=y[P],D=y[P+1],L=y[P+2];v.emplaceBack(A,D),v.emplaceBack(D,L),v.emplaceBack(L,A)}let T=c.bindVertexArrayOES.current,I=new pi;return I.buf=new Os(c,v),I.lastUsedFrameIdx=t,this._storage.set(o.id,I),c.bindVertexArrayOES.set(T),I.buf}update(t){for(let[o,c]of this._storage)t-c.lastUsedFrameIdx>30&&(c.buf.destroy(),this._storage.delete(o))}destroy(){for(let[t,o]of this._storage)o.buf.destroy(),this._storage.delete(t)}}class hg{constructor(){this.occluderSize=30,this.depthOffset=-1e-4}}let lh={symbol:function(a,t,o,c,d){if(a.renderPass!=="translucent")return;let m=gt.disabled,_=a.colorModeForRenderPass(),y=o.layout.get("text-variable-anchor"),v=o.layout.get("text-size-scale-range"),T=h.aB(a.scaleFactor,v[0],v[1]);y&&function(A,D,L,O,k,N,q,Z){let G=D.transform,re=k==="map",te=N==="map";for(let se of A){let K=O.getTile(se),J=K.getBucket(L);if(!J||!J.text||!J.text.segments.get().length)continue;let oe=h.bl(J.textSizeData,G.zoom,Z),ue=Su(se,J.getProjection(),G),de=G.calculatePixelsToTileUnitsMatrix(K),be=vr(ue,K.tileID.canonical,te,re,G,J.getProjection(),de),ve=J.hasIconTextFit()&&J.hasIconData();
3281oe&&Qo(J,re,te,q,G,be,se,Math.pow(2,G.zoom-K.tileID.overscaledZ),oe,ve)}}(c,a,o,t,o.layout.get("text-rotation-alignment"),o.layout.get("text-pitch-alignment"),d,T);let I=o.paint.get("icon-opacity").constantOr(1)!==0,P=o.paint.get("text-opacity").constantOr(1)!==0;o.layout.get("symbol-sort-key").constantOr(1)!==void 0&&(I||P)?Fd(a,t,o,c,m,_):(I&&Fd(a,t,o,c,m,_,{onlyIcons:!0}),P&&Fd(a,t,o,c,m,_,{onlyText:!0})),t.map.showCollisionBoxes&&(Qu(a,t,o,c,o.paint.get("text-translate"),o.paint.get("text-translate-anchor"),!0),Qu(a,t,o,c,o.paint.get("icon-translate"),o.paint.get("icon-translate-anchor"),!1))},circle:function(a,t,o,c){if(a.renderPass!=="translucent")return;let d=o.paint.get("circle-opacity"),m=o.paint.get("circle-stroke-width"),_=o.paint.get("circle-stroke-opacity"),y=o.layout.get("circle-sort-key").constantOr(1)!==void 0,v=o.paint.get("circle-emissive-strength");if(d.constantOr(1)===0&&(m.constantOr(1)===0||_.constantOr(1)===0))return;let T=a.context,I=T.gl,P=a.transform,A=!(!a.terrain||!a.terrain.enabled),D=o.layout.get("circle-elevation-reference"),L=a.depthModeForSublayer(0,nt.ReadOnly),O=new nt(a.context.gl.LEQUAL,nt.ReadOnly,a.depthRangeFor3D),k=D==="none"||A?L:O,N=gt.disabled,q=a.colorModeForDrapableLayerRenderPass(v),Z=P.projection.name==="globe",G=[h.aG(P.center.lng),h.aJ(P.center.lat)],re=[];for(let se=0;se<c.length;se++){let K=c[se],J=t.getTile(K),oe=J.getBucket(o);if(!oe||oe.projection.name!==P.projection.name)continue;let ue=oe.programConfigurations.get(o.id),de=oe.layoutVertexBuffer,be=oe.globeExtVertexBuffer,ve=oe.indexBuffer,Fe=h.dV(o),pe=[be],Ie=a.isTileAffectedByFog(K);Z&&Fe.push("PROJECTION_GLOBE_VIEW"),Fe.push("DEPTH_D24"),a.terrain&&P.depthOcclusionForSymbolsAndCircles&&Fe.push("DEPTH_OCCLUSION"),oe.hasElevation&&!a.terrain&&(Fe.push("ELEVATED_ROADS"),pe.push(oe.elevatedLayoutVertexBuffer));let fe=a.getOrCreateProgram("circle",{config:ue,defines:Fe,overrideFog:Ie}),Pe=P.projection.createInversionMatrix(P,K.canonical),Ce={programConfiguration:ue,program:fe,layoutVertexBuffer:de,dynamicBuffers:pe,indexBuffer:ve,uniformValues:h.dW(a,K,J,Pe,G,o),tile:J};if(y){let Re=oe.segments.get();for(let Ye of Re)re.push({segments:new h.dB([Ye]),sortKey:Ye.sortKey,state:Ce})}else re.push({segments:oe.segments,sortKey:0,state:Ce})}y&&re.sort((se,K)=>se.sortKey-K.sortKey);let te={useDepthForOcclusion:P.depthOcclusionForSymbolsAndCircles};for(let se of re){let{programConfiguration:K,program:J,layoutVertexBuffer:oe,dynamicBuffers:ue,indexBuffer:de,uniformValues:be,tile:ve}=se.state,Fe=se.segments;a.terrain&&a.terrain.setupElevationDraw(ve,J,te),a.uploadCommonUniforms(T,J,ve.tileID.toUnwrapped()),J.draw(a,I.TRIANGLES,k,N,q,dt.disabled,be,o.id,oe,de,Fe,o.paint,P.zoom,K,ue)}},heatmap:function(a,t,o,c){if(o.paint.get("heatmap-opacity")!==0)if(a.renderPass==="offscreen"){let d=a.context,m=d.gl,_=gt.disabled,y=new mt([m.ONE,m.ONE,m.ONE,m.ONE],h.C.transparent,[!0,!0,!0,!0]),v=a.transform.projection.name==="globe"?.5:.25;o.heatmapFbo=En.createWithTexture(d,o.heatmapFbo,a.width*v,a.height*v),d.clear({color:h.C.transparent});let T=a.transform,I=T.projection.name==="globe",P=I?["PROJECTION_GLOBE_VIEW"]:[],A=I?dt.frontCCW:dt.disabled,D=[h.aG(T.center.lng),h.aJ(T.center.lat)];for(let L=0;L<c.length;L++){let O=c[L];if(t.hasRenderableParent(O))continue;let k=t.getTile(O),N=k.getBucket(o);if(!N||N.projection.name!==T.projection.name)continue;let q=a.isTileAffectedByFog(O),Z=N.programConfigurations.get(o.id),G=a.getOrCreateProgram("heatmap",{config:Z,defines:P,overrideFog:q}),{zoom:re}=a.transform;a.terrain&&a.terrain.setupElevationDraw(k,G),a.uploadCommonUniforms(d,G,O.toUnwrapped());let te=T.projection.createInversionMatrix(T,O.canonical);G.draw(a,m.TRIANGLES,nt.disabled,_,y,A,Pd(a,O,k,te,D,re,o.paint.get("heatmap-intensity")),o.id,N.layoutVertexBuffer,N.indexBuffer,N.segments,o.paint,a.transform.zoom,Z,I?[N.globeExtVertexBuffer]:null)}d.viewport.set([0,0,a.width,a.height])}else a.renderPass==="translucent"&&(a.context.setColorMode(a.colorModeForRenderPass()),function(d,m){let _=d.context,y=_.gl,v=m.heatmapFbo;if(!v)return;_.activeTexture.set(y.TEXTURE0),y.bindTexture(y.TEXTURE_2D,v.colorAttachment0.get()),_.activeTexture.set(y.TEXTURE1);let T=m.colorRampTexture;T||(T=m.colorRampTexture=new h.T(_,m.colorRamp,y.RGBA8)),T.bind(y.LINEAR,y.CLAMP_TO_EDGE),d.getOrCreateProgram("heatmapTexture").draw(d,y.TRIANGLES,nt.disabled,gt.disabled,d.colorModeForRenderPass(),dt.disabled,((I,P)=>({u_image:0,u_color_ramp:1,u_opacity:P.paint.get("heatmap-opacity")}))(0,m),m.id,d.viewportBuffer,d.quadTriangleIndexBuffer,d.viewportSegments,m.paint,d.transform.zoom)}(a,o))},line:function(a,t,o,c){let d=o.paint.get("line-opacity"),m=o.paint.get("line-width");if(d.constantOr(1)===0||m.constantOr(1)===0)return;let _=o.paint.get("line-blend-mode"),y=a.terrain&&a.terrain.renderingToTexture;if(_==="default"||a.transform.projection.name==="globe")a.renderPass==="translucent"&&Sl(a,t,o,c);else{if(y)return void function(v,T,I,P,A){if(v.renderPass!=="translucent")return;let D=v.context,L=D.gl,O=v.terrain;if(!O)return;let k=D.bindFramebuffer.current,N=v.emissiveMode==="mrt-fallback",q=O.drapeBufferSize[0],Z=O.drapeBufferSize[1];I.lineBlendFbos||(I.lineBlendFbos=new th),I.lineBlendFbos.drapeFbo=En.createWithTexture(D,I.lineBlendFbos.drapeFbo,q,Z,!0),N&&L.drawBuffers([L.COLOR_ATTACHMENT0]),D.clear({color:kc[A].clearColor,depth:1,stencil:0});let G=v.currentStencilSource,re=v._tileClippingMaskIDs,te=v.nextStencilID;v.currentStencilSource=void 0,v._tileClippingMaskIDs={},v.nextStencilID=1;let se=v._terrain;v._terrain=null,v._renderTileClippingMasks(I,T,P),Sl(v,T,I,P,Uc(A,v.context),!0),v._terrain=se,v.currentStencilSource=G,v._tileClippingMaskIDs=re,v.nextStencilID=te,N&&L.drawBuffers([L.COLOR_ATTACHMENT0,L.COLOR_ATTACHMENT1]);let K=O.drapeBufferSize,J=I.lineBlendFbos&&I.lineBlendFbos.drapeFbo;J&&(A==="additive"&&es(v,I,J),qe(v,I,A,J,k,K))}(a,t,o,c,_);if(a.renderPass==="offscreen")return void function(v,T,I,P,A){let D=v.context,L=Math.ceil(v.width),O=Math.ceil(v.height);I.lineBlendFbos||(I.lineBlendFbos=new th),I.lineBlendFbos.fbo=En.createWithTexture(D,I.lineBlendFbos.fbo,L,O,!0),D.clear({color:kc[A].clearColor,depth:1,stencil:0});let k=v.currentStencilSource,N=v._tileClippingMaskIDs,q=v.nextStencilID;v.currentStencilSource=void 0,v._tileClippingMaskIDs={},v.nextStencilID=1,v._renderTileClippingMasks(I,T,P);let Z=v.renderPass;v.renderPass="translucent",Sl(v,T,I,P,Uc(A,v.context)),v.renderPass=Z,v.currentStencilSource=k,v._tileClippingMaskIDs=N,v.nextStencilID=q,D.viewport.set([0,0,v.width,v.height]),A==="additive"&&es(v,I,I.lineBlendFbos.fbo)}(a,t,o,c,_);if(a.renderPass==="translucent"){let v=o.lineBlendFbos&&o.lineBlendFbos.fbo;return void(v&&qe(a,o,_,v,null))}}},fill:function(a,t,o,c){let d=o.paint.get("fill-color"),m=o.paint.get("fill-opacity");if(m.constantOr(1)===0)return;let _=o.paint.get("fill-emissive-strength"),y=a.colorModeForDrapableLayerRenderPass(_),v=o.paint.get("fill-pattern"),T=a.opaquePassEnabledForLayer()&&!v.constantOr(1)&&d.constantOr(h.C.transparent).a===1&&m.constantOr(0)===1?"opaque":"translucent",I="none";o.layout.get("fill-elevation-reference")!=="none"?I="road":o.paint.get("fill-z-offset").constantOr(1)!==0&&(I="offset");let P=!(!a.terrain||!a.terrain.enabled),A={painter:a,sourceCache:t,layer:o,coords:c,colorMode:y,elevationType:I,terrainEnabled:P,pass:T};
3281if(a.renderPass==="shadow")return void(a.shadowRenderer&&I==="road"&&!P&&function(L){let{painter:O,sourceCache:k,layer:N,coords:q}=L,Z=O.context.gl,G=L.painter.shadowRenderer;for(let re of q){let te=k.getTile(re),se=te.getBucket(N);if(!se)continue;let K=se.elevatedStructures;if(!K||!K.shadowCasterSegments||K.shadowCasterSegments.segments[0].primitiveLength===0)continue;O.prepareDrawTile();let J=se.bufferData.programConfigurations.get(N.id),oe=O.isTileAffectedByFog(re),ue=O.getOrCreateProgram("elevatedStructuresDepth",{config:J,overrideFog:oe}),de=G.calculateShadowPassMatrixFromTile(te.tileID.toUnwrapped());O.uploadCommonUniforms(O.context,ue,re.toUnwrapped());let be=Md(de,0);ue.draw(O,Z.TRIANGLES,G.getShadowPassDepthMode(),gt.disabled,mt.disabled,dt.disabled,be,N.id,K.vertexBuffer,K.indexBuffer,K.shadowCasterSegments,N.paint,O.transform.zoom,J)}}(A));let D=a.emissiveMode==="mrt-fallback";if(I!=="offset"){if(wi(A,!1,D),I==="road"){let L=!P&&a.renderPass==="translucent";L&&La(a,t,o,c,"geometry"),wi(A,!0,D,gt.disabled),L&&function(O){let{painter:k,sourceCache:N,layer:q,coords:Z,colorMode:G}=O,re=k.context.gl,te=O.painter.shadowRenderer,se=!!te&&te.enabled,K=new nt(k.context.gl.LEQUAL,nt.ReadOnly,k.depthRangeFor3D),J=[0,0,0];if(se){let ue=k.style.directionalLight,de=k.style.ambientLight;ue&&de&&(J=Ea(k.style,ue,de))}let oe=ue=>{for(let de of Z){let be=N.getTile(de),ve=be.getBucket(q);if(!ve)continue;let Fe=ve.elevatedStructures;if(!Fe)continue;let pe,Ie;if(ue?(pe=Fe.renderableBridgeSegments,Ie=Fe.bridgeProgramConfigurations.get(q.id)):(pe=Fe.renderableTunnelSegments,Ie=Fe.tunnelProgramConfigurations.get(q.id)),!pe||pe.segments[0].primitiveLength===0)continue;Ie.updatePaintBuffers(),k.prepareDrawTile();let fe=k.isTileAffectedByFog(de),Pe=[];se&&Pe.push("RENDER_SHADOWS","NORMAL_OFFSET");let Ce=k.getOrCreateProgram("elevatedStructures",{config:Ie,overrideFog:fe,defines:Pe}),Re=k.translatePosMatrix(de.projMatrix,be,q.paint.get("fill-translate"),q.paint.get("fill-translate-anchor"));se&&te.setupShadows(be.tileID.toUnwrapped(),Ce,"vector-tile");let Ye=Cd(Re,J);k.uploadCommonUniforms(k.context,Ce,de.toUnwrapped()),Ce.draw(k,re.TRIANGLES,K,gt.disabled,G,dt.backCCW,Ye,q.id,Fe.vertexBuffer,Fe.indexBuffer,pe,q.paint,k.transform.zoom,Ie,[Fe.vertexBufferNormal])}};oe(!0),oe(!1)}(A)}}else wi(A,!1,D,a.stencilModeFor3D())},"fill-extrusion":function(a,t,o,c){let d=o.paint.get("fill-extrusion-opacity"),m=a.context,_=m.gl,y=a.terrain,v=y&&y.renderingToTexture;if(d===0)return;let T=a.emissiveMode==="mrt-fallback",I=a.conflationActive&&a.style.isLayerClipped(o,t.getSource()),P=a.style.order.indexOf(o.fqid);if(I&&function(A,D,L,O,k){for(let N of O){let q=D.getTile(N).getBucket(L);q&&(q.updateReplacement(N,A.replacementSource,k),q.uploadCentroid(A.context))}}(a,t,o,c,P),y||I)for(let A of c){let D=t.getTile(A).getBucket(o);D&&Kf(a.context,t,A,D,o,y,I)}if(a.renderPass==="shadow"&&a.shadowRenderer){if(y&&d<.65&&o._transitionablePaint._values["fill-extrusion-opacity"].value.expression instanceof h.ac)return;let A=a.shadowRenderer.getShadowPassDepthMode();Vc(a,t,o,c,A,gt.disabled,mt.disabled,I)}else if(a.renderPass==="translucent"){let A=!o.paint.get("fill-extrusion-pattern").constantOr(1),D=o.paint.get("fill-extrusion-color").constantOr(h.C.white);if(!v&&D.a!==0){let L=new nt(a.context.gl.LEQUAL,nt.ReadWrite,a.depthRangeFor3D);d===1&&A?Vc(a,t,o,c,L,gt.disabled,mt.unblended,I):(Vc(a,t,o,c,L,gt.disabled,mt.disabled,I),Vc(a,t,o,c,L,a.stencilModeFor3D(),a.colorModeForRenderPass(),I),a.resetStencilClippingMasks())}if(a.style.enable3dLights()&&A&&(!y&&a.transform.projection.name!=="globe"||v)){let L=o.paint.get("fill-extrusion-opacity"),O=o.paint.get("fill-extrusion-ambient-occlusion-intensity"),k=o.paint.get("fill-extrusion-ambient-occlusion-ground-radius"),N=o.paint.get("fill-extrusion-flood-light-intensity"),q=o.paint.get("fill-extrusion-flood-light-color-use-theme").constantOr("default")==="none",Z=o.paint.get("fill-extrusion-flood-light-color").toNonPremultipliedRenderColor(q?null:o.lut).toArray01().slice(0,3),G=O>0&&k>0,re=N>0,te=(J,oe,ue)=>(1-ue)*J+ue*oe,se=new jc;se.translate=o.paint.get("fill-extrusion-translate"),se.translateAnchor=o.paint.get("fill-extrusion-translate-anchor"),se.edgeRadius=o.layout.get("fill-extrusion-edge-radius"),se.cutoffFadeRange=o.paint.get("fill-extrusion-cutoff-fade-range");let K=J=>{let oe=a.depthModeForSublayer(1,nt.ReadOnly,_.LEQUAL,!0),ue=o.paint.get(J?"fill-extrusion-ambient-occlusion-ground-attenuation":"fill-extrusion-flood-light-ground-attenuation"),de=te(.1,3,ue),be=a._showOverdrawInspector;if(!be){let ve=new gt({func:_.ALWAYS,mask:255},255,255,_.KEEP,_.KEEP,_.REPLACE),Fe=new mt([_.ONE,_.ONE,_.ONE,_.ONE],h.C.transparent,[!1,!1,!1,!0],_.MIN);io(se,a,t,o,c,oe,ve,Fe,dt.disabled,J,"sdf",L,O,k,N,Z,de,I,!1)}{let ve=be?gt.disabled:new gt({func:_.EQUAL,mask:255},255,255,_.KEEP,_.DECR,_.DECR),Fe=be?a.colorModeForRenderPass():new mt([_.ONE_MINUS_DST_ALPHA,_.DST_ALPHA,_.ONE,_.ONE],h.C.transparent,[!0,!0,!0,!0]);io(se,a,t,o,c,oe,ve,Fe,dt.disabled,J,"color",L,O,k,N,Z,de,I,!1)}};if(v){let J=()=>{let ue=y.drapeBufferSize[0],de=y.drapeBufferSize[1],be=y.framebufferCopyTexture;
3281return be&&(!be||be.size[0]===ue&&be.size[1]===de)||(be&&be.destroy(),be=y.framebufferCopyTexture=new h.T(m,new h.q({width:ue,height:de}),_.RGBA8)),be.bind(_.LINEAR,_.CLAMP_TO_EDGE),_.copyTexSubImage2D(_.TEXTURE_2D,0,0,0,0,0,ue,de),be},oe=(ue,de,be)=>{let ve=a.depthModeForSublayer(1,nt.ReadOnly,_.LEQUAL,!1),Fe=o.paint.get(ue?"fill-extrusion-ambient-occlusion-ground-attenuation":"fill-extrusion-flood-light-ground-attenuation"),pe=te(.1,3,Fe);{let Ie=new mt([_.ONE,_.ONE,_.ONE,_.ONE],h.C.transparent,[!1,!1,!1,!0]);io(se,a,t,o,c,ve,gt.disabled,Ie,dt.disabled,ue,"clear",L,O,k,N,Z,pe,I,de)}{let Ie=new gt({func:_.ALWAYS,mask:255},255,255,_.KEEP,_.KEEP,_.REPLACE),fe=new mt([_.ONE,_.ONE,_.ONE,_.ONE],h.C.transparent,[!1,!1,!1,!0],_.MIN);io(se,a,t,o,c,ve,Ie,fe,dt.disabled,ue,"sdf",L,O,k,N,Z,pe,I,de)}T&&!ue&&(be=J());{let Ie=ue?_.ZERO:_.ONE_MINUS_DST_ALPHA,fe=new gt({func:_.EQUAL,mask:255},255,255,_.KEEP,_.DECR,_.DECR),Pe=new mt([Ie,_.DST_ALPHA,_.ONE_MINUS_DST_ALPHA,_.ZERO],h.C.transparent,[!0,!0,!0,!0]);io(se,a,t,o,c,ve,fe,Pe,dt.disabled,ue,"color",L,O,k,N,Z,pe,I,de)}if(!T||ue){let Ie=new mt([_.ONE,_.ONE,_.ONE,ue?_.ZERO:_.ONE],h.C.transparent,[!1,!1,!1,!0],ue?_.FUNC_ADD:_.MAX);io(se,a,t,o,c,ve,gt.disabled,Ie,dt.disabled,ue,"clear",L,O,k,N,Z,pe,I,de,be)}else{_.drawBuffers([_.NONE,_.COLOR_ATTACHMENT1]);let Ie=new gt({func:_.EQUAL,mask:255},254,255,_.KEEP,_.DECR,_.DECR),fe=new mt([_.ONE,_.ONE,_.ONE,_.ONE],h.C.transparent,[!0,!1,!1,!1],_.MAX);io(se,a,t,o,c,ve,Ie,fe,dt.disabled,ue,"emissive",L,O,k,N,Z,pe,I,de,be),_.drawBuffers([_.COLOR_ATTACHMENT0])}};if(G||re){let ue;a.prepareDrawTile(),T&&!G||(ue=J()),G&&oe(!0,!1,ue),re&&oe(!1,!0,ue)}}else G&&K(!0),re&&K(!1),(G||re)&&a.resetStencilClippingMasks()}}},hillshade:function(a,t,o,c){if(a.renderPass!=="offscreen"&&a.renderPass!=="translucent"||a.style.disableElevatedTerrain)return;let d=a.context,m=a.terrain&&a.terrain.renderingToTexture,[_,y]=a.renderPass!=="translucent"||m?[{},c]:a.stencilConfigForOverlap(c);for(let v of y){let T=t.getTile(v);if(T.needsHillshadePrepare&&a.renderPass==="offscreen")dd(a,T,o);else if(a.renderPass==="translucent"){let I=a.depthModeForSublayer(0,nt.ReadOnly),P=o.paint.get("hillshade-emissive-strength"),A=a.colorModeForDrapableLayerRenderPass(P),D=m&&a.terrain?a.terrain.stencilModeForRTTOverlap(v):_[v.overscaledZ];hd(a,v,T,o,I,D,A)}}d.viewport.set([0,0,a.width,a.height]),a.resetStencilClippingMasks()},raster:function(a,t,o,c,d,m){if(a.renderPass!=="translucent")return;let _=o.paint.get("raster-opacity");if(_===0)return;let y=a.transform.projection.name==="globe",v=o.paint.get("raster-elevation")!==0,T=v&&y,I=a.terrain&&a.terrain.exaggeration()>0&&v&&o.paint.get("raster-elevation-reference")==="ground",P=!y&&I;if(a.renderElevatedRasterBackface&&!T)return;let A=a.context,D=A.gl,L=t.getSource(),O=function(J,oe,ue,de,be){let ve=oe.paint.get("raster-color"),Fe
3281=J.type==="raster-array",pe=[],Ie=oe.paint.get("raster-resampling"),fe=oe.paint.get("raster-color-mix"),Pe=oe.paint.get("raster-color-range"),Ce=[fe[0],fe[1],fe[2],0],Re=fe[3],Ye=Ie==="nearest"?de.NEAREST:de.LINEAR;if(Fe&&(pe.push("RASTER_ARRAY"),ve||pe.push("RASTER_COLOR"),Ie==="linear"&&pe.push("RASTER_ARRAY_LINEAR"),Ye=de.NEAREST,!Pe&&J.rasterLayers)){let $e=J.rasterLayers.find(({id:je})=>je===oe.sourceLayer);$e&&$e.fields&&$e.fields.range&&(Pe=$e.fields.range)}if(Pe=Pe||[0,1],ve){pe.push("RASTER_COLOR"),ue.activeTexture.set(de.TEXTURE2),oe.updateColorRamp(Pe);let $e=oe.colorRampTexture;$e||($e=oe.colorRampTexture=new h.T(ue,oe.colorRamp,de.RGBA8)),$e.bind(Ye,de.CLAMP_TO_EDGE)}return be&&pe.push("USE_MRT1"),{mix:Ce,range:Pe,offset:Re,defines:pe,resampling:Ye}}(L,o,A,D,a.terrain&&a.terrain.renderingToTexture&&a.emissiveMode==="mrt-fallback");if(L instanceof h.aY&&!c.length&&!y)return;let k=o.paint.get("raster-emissive-strength"),N=a.colorModeForDrapableLayerRenderPass(k),q=a.terrain&&a.terrain.renderingToTexture,Z=!a.options.moving,G=o.paint.get("raster-resampling")==="nearest"?D.NEAREST:D.LINEAR;if(L instanceof h.aY&&!c.length&&(L.onNorthPole||L.onSouthPole)){let J=v?a.stencilModeFor3D():gt.disabled;return void Hc(!!L.onNorthPole,null,a,t,o,k,O,dt.disabled,J)}if(!c.length)return;let[re,te]=L instanceof h.aY||q?[{},c]:a.stencilConfigForOverlap(c),se=te.at(-1).overscaledZ;T&&O.defines.push("PROJECTION_GLOBE_VIEW"),v&&O.defines.push("RENDER_CUTOFF","ELEVATED"),I&&O.defines.push("ELEVATION_REFERENCE_GROUND");let K=(J,oe,ue)=>{for(let de of J){let be=de.toUnwrapped(),ve=t.getTile(de);if(q&&(!ve||!ve.hasData()))continue;A.activeTexture.set(D.TEXTURE0);let Fe=Vd(ve,L,o,O);if(!Fe||!Fe.texture)continue;let{texture:pe,mix:Ie,offset:fe,tileSize:Pe,buffer:Ce}=Fe,Re,Ye;q?(Re=nt.disabled,Ye=de.projMatrix):v?(Re=new nt(D.LEQUAL,nt.ReadWrite,a.depthRangeFor3D),Ye=y?a.transform.expandedFarZProjMatrix:a.transform.calculateProjMatrix(be,Z)):(Re=a.depthModeForSublayer(de.overscaledZ-se,_===1?nt.ReadWrite:nt.ReadOnly,D.LESS),Ye=a.transform.calculateProjMatrix(be,Z));let $e=a.terrain&&q?a.terrain.stencilModeForRTTOverlap(de):re[de.overscaledZ],je=m?0:o.paint.get("raster-fade-duration");ve.registerFadeDuration(je);let Ue=t.findLoadedParent(de,0),at=Qe(ve,Ue,t,a.transform,je),ot,et;!at.isFading&&ve.refreshedUponExpiration&&(ve.refreshedUponExpiration=!1),a.terrain&&a.terrain.prepareDrawTile(),A.activeTexture.set(D.TEXTURE0),pe.bind(G,D.CLAMP_TO_EDGE),A.activeTexture.set(D.TEXTURE1),Ue?(Ue.texture&&Ue.texture.bind(G,D.CLAMP_TO_EDGE),ot=Math.pow(2,Ue.tileID.overscaledZ-ve.tileID.overscaledZ),et=[ve.tileID.canonical.x*ot%1,ve.tileID.canonical.y*ot%1]):pe.bind(G,D.CLAMP_TO_EDGE),"useMipmap"in pe&&A.extTextureFilterAnisotropic&&a.transform.pitch>20&&D.texParameterf(D.TEXTURE_2D,A.extTextureFilterAnisotropic.TEXTURE_MAX_ANISOTROPY_EXT,A.extTextureFilterAnisotropicMax);let it=a.transform,ut,xt=v?Ud(it):[0,0,0,0],_t,Tt,yt,Ft,bt,Nt=0;if(T&&L instanceof h.aY&&L.coordinates.length>3)_t=Float32Array.from(h.dx(h.dy(new h.cp(0,0,0)))),Tt=Float32Array.from(it.globeMatrix),yt=Float32Array.from(h.dt(it)),Ft=[h.aG(it.center.lng),h.aJ(it.center.lat)],ut=L.elevatedGlobePerspectiveTransform,bt=L.elevatedGlobeGridMatrix||new Float32Array(9);else if(T){let Zt=h.du(de.canonical);Nt=h.dv(Zt.getCenter().lat),_t=Float32Array.from(h.dx(h.dy(de.canonical))),Tt=Float32Array.from(it.globeMatrix),yt=Float32Array.from(h.dt(it)),Ft=[h.aG(it.center.lng),h.aJ(it.center.lat)],ut=[0,0],bt=Float32Array.from(h.dw(de.canonical,Zt,Nt,it.worldSize/it._pixelsPerMercatorPixel))}else ut=L instanceof h.aY?L.perspectiveTransform:[0,0],_t=new Float32Array(16),Tt=new Float32Array(9),yt=new Float32Array(16),Ft=[0,0],bt=new Float32Array(9);let $t=Yu(a,Ye,_t,Tt,yt,bt,et||[0,0],h.ai(a.transform.zoom),Ft,xt,ot||1,at,o,ut,v?o.paint.get("raster-elevation"):0,2,Ie,fe,O.range,Pe,Ce,k),bi=a.isTileAffectedByFog(de),ai=a.getOrCreateProgram("raster",{defines:O.defines,overrideFog:bi});if(a.uploadCommonUniforms(A,ai,be),L instanceof h.aY){let Zt=L.elevatedGlobeVertexBuffer,It=L.elevatedGlobeIndexBuffer;if(q||!y)L.boundsBuffer&&L.boundsSegments&&ai.draw(a,D.TRIANGLES,Re,gt.disabled,N,dt.disabled,$t,o.id,L.boundsBuffer,a.quadTriangleIndexBuffer,L.boundsSegments);else if(Zt&&It){let Et=it.zoom<=h.cN?L.elevatedGlobeSegments:L.getSegmentsForLongitude(it.center.lng);Et&&ai.draw(a,D.TRIANGLES,Re,gt.disabled,N,oe,$t,o.id,Zt,It,Et)}}else if(T){Re=new nt(D.LEQUAL,nt.ReadOnly,a.depthRangeFor3D);let Zt=a.globeSharedBuffers;if(Zt){I&&(a.terrain.setupElevationDraw(ve,ai),a.uploadCommonUniforms(A,ai,ve.tileID.toUnwrapped()));let[It,Et,li]=Zt.getGridBuffers(Nt,!1),Di=ai.getAttributeLocation(D,"a_texture_pos");Di!==-1&&D.vertexAttribI4ui(Di,0,0,0,0),ai.draw(a,D.TRIANGLES,Re,ue||$e,a.colorModeForRenderPass(),oe,$t,o.id,It,Et,li)}}else if(P)Re=new nt(D.LEQUAL,nt.ReadWrite,a.depthRangeFor3D),a.terrain.setupElevationDraw(ve,ai),a.uploadCommonUniforms(A,ai,ve.tileID.toUnwrapped()),it.pitch>20&&ai.draw(a,D.TRIANGLES,Re,gt.disabled,mt.disabled,dt.frontCCW,$t,o.id,a.terrain.gridBuffer,a.terrain.gridIndexBuffer,a.terrain.gridSegments),ai.draw(a,D.TRIANGLES,Re,$e,N,dt.backCCW,$t,o.id,a.terrain.gridBuffer,a.terrain.gridIndexBuffer,a.terrain.gridSegments);else{let{tileBoundsBuffer:Zt,tileBoundsIndexBuffer:It,tileBoundsSegments:Et}=a.getTileBoundsBuffers(ve);ai.draw(a,D.TRIANGLES,Re,$e,N,dt.disabled,$t,o.id,Zt,It,Et)}}if(!(L instanceof h.aY)&&T)for(let de of J){let be=de.canonical.y===(1<<de.canonical.z)-1;de.canonical.y===0&&Hc(!0,de,a,t,o,k,O,oe,ue||gt.disabled),be&&Hc(!1,de,a,t,o,k,O,oe===dt.frontCW?dt.backCW:dt.frontCW,ue||gt.disabled)}};T?K(te,a.renderElevatedRasterBackface?dt.backCW:dt.frontCW,a.stencilModeFor3D()):K(te,dt.disabled,void 0),a.resetStencilClippingMasks()},background:function(a,t,o,c){let d=o.paint.get("background-color"),m=o.paint.get("background-color-use-theme").
3281constantOr("default")==="none",_=o.paint.get("background-opacity"),y=o.paint.get("background-emissive-strength"),v=o.paint.get("background-pitch-alignment")==="viewport";if(_===0)return;let T=a.context,I=T.gl,P=a.transform,A=P.tileSize,D=o.paint.get("background-pattern"),L;if(D!==void 0&&(D===null||(L=a.imageManager.getPattern(h.I.from(D.toString()),o.scope,a.style.getLut(o.scope)),!L)))return;let O=!D&&d.a===1&&_===1&&a.opaquePassEnabledForLayer()?"opaque":"translucent";if(a.renderPass!==O)return;let k=gt.disabled,N=a.depthModeForSublayer(0,O==="opaque"?nt.ReadWrite:nt.ReadOnly),q=a.colorModeForDrapableLayerRenderPass(y),Z=D?"backgroundPattern":"background",G,re=c;re||(G=a.getBackgroundTiles(),re=Object.values(G).map(se=>se.tileID)),D&&(T.activeTexture.set(I.TEXTURE0),a.imageManager.bind(a.context,o.scope));let te=[];if(a.terrain&&a.terrain.renderingToTexture&&a.emissiveMode==="mrt-fallback"&&te.push("USE_MRT1"),v){let se=a.getOrCreateProgram(Z,{overrideFog:!1,overrideRtt:!0,defines:te}),K=Br,J=new h.aU(0,0,0,0,0),oe=D?Xf(K,y,_,a,0,o.scope,L,v,{tileID:J,tileSize:A}):Ju(K,y,_,d.toPremultipliedRenderColor(m?null:o.lut));return void se.draw(a,I.TRIANGLES,N,k,q,dt.disabled,oe,o.id,a.viewportBuffer,a.quadTriangleIndexBuffer,a.viewportSegments)}for(let se of re){let K=a.isTileAffectedByFog(se),J=a.getOrCreateProgram(Z,{overrideFog:K,defines:te}),oe=se.toUnwrapped(),ue=c?se.projMatrix:a.transform.calculateProjMatrix(oe);a.prepareDrawTile();let de=t?t.getTile(se):G?G[se.key]:new h.b3(se,A,P.zoom,a),be=D?Xf(ue,y,_,a,0,o.scope,L,v,{tileID:se,tileSize:A}):Ju(ue,y,_,d.toPremultipliedRenderColor(m?null:o.lut));a.uploadCommonUniforms(T,J,oe);let{tileBoundsBuffer:ve,tileBoundsIndexBuffer:Fe,tileBoundsSegments:pe}=a.getTileBoundsBuffers(de);J.draw(a,I.TRIANGLES,N,k,q,dt.disabled,be,o.id,ve,Fe,pe)}},sky:function(a,t,o){let c=a._atmosphere?h.ai(a.transform.zoom):1,d=o.paint.get("sky-opacity")*c;if(d===0)return;let m=a.context,_=o.paint.get("sky-type"),y=new nt(m.gl.LEQUAL,nt.ReadOnly,[0,1]),v=a.frameCounter/1e3%1;_==="atmosphere"?a.renderPass==="offscreen"?o.needsSkyboxCapture(a)&&(function(T,I){let P=T.context,A=P.gl,D=I.skyboxFbo;if(!D){D=I.skyboxFbo=P.createFramebuffer(32,32,1,null),I.skyboxGeometry=new Xi(P),I.skyboxTexture=P.gl.createTexture(),A.bindTexture(A.TEXTURE_CUBE_MAP,I.skyboxTexture),A.texParameteri(A.TEXTURE_CUBE_MAP,A.TEXTURE_WRAP_S,A.CLAMP_TO_EDGE),A.texParameteri(A.TEXTURE_CUBE_MAP,A.TEXTURE_WRAP_T,A.CLAMP_TO_EDGE),A.texParameteri(A.TEXTURE_CUBE_MAP,A.TEXTURE_MIN_FILTER,A.LINEAR),A.texParameteri(A.TEXTURE_CUBE_MAP,A.TEXTURE_MAG_FILTER,A.LINEAR);for(let N=0;N<6;++N)A.texImage2D(A.TEXTURE_CUBE_MAP_POSITIVE_X+N,0,A.RGBA,32,32,0,A.RGBA,A.UNSIGNED_BYTE,null)}P.bindFramebuffer.set(D.framebuffer),P.viewport.set([0,0,32,32]);let L=I.getCenter(T,!0),O=T.getOrCreateProgram("skyboxCapture"),k=new Float64Array(16);h.en(k,.5*-Math.PI),js(T,I,O,k,L,0),h.en(k,.5*Math.PI),js(T,I,O,k,L,1),h.eo(k,.5*-Math.PI),js(T,I,O,k,L,2),h.eo(k,.5*Math.PI),js(T,I,O,k,L,3),h.bA(k),js(T,I,O,k,L,4),h.en(k,Math.PI),js(T,I,O,k,L,5),P.viewport.set([0,0,T.width,T.height])}(a,o),o.markSkyboxValid(a)):a.renderPass==="sky"&&function(T,I,P,A,D){let L=T.context,O=L.gl,k=T.transform,N=T.getOrCreateProgram("skybox");L.activeTexture.set(O.TEXTURE0),O.bindTexture(O.TEXTURE_CUBE_MAP,I.skyboxTexture);let q=((Z,G,re,te,se)=>({u_matrix:Z,u_sun_direction:G,u_cubemap:0,u_opacity:te,u_temporal_offset:se}))(k.skyboxMatrix,I.getCenter(T,!1),0,A,D);T.uploadCommonUniforms(L,N),N.draw(T,O.TRIANGLES,P,gt.disabled,T.colorModeForRenderPass(),dt.backCW,q,"skybox",I.skyboxGeometry.vertexBuffer,I.skyboxGeometry.indexBuffer,I.skyboxGeometry.segment)}(a,o,y,d,v):_==="gradient"&&a.renderPass==="sky"&&function(T,I,P,A,D){let L=T.context,O=L.gl,k=T.transform,N=T.getOrCreateProgram("skyboxGradient");I.skyboxGeometry||(I.skyboxGeometry=new Xi(L)),L.activeTexture.set(O.TEXTURE0);let q=I.colorRampTexture;q||(q=I.colorRampTexture=new h.T(L,I.colorRamp,O.RGBA8)),q.bind(O.LINEAR,O.CLAMP_TO_EDGE);let Z=((G,re,te,se,K)=>({u_matrix:G,u_color_ramp:0,u_center_direction:re,u_radius:h.am(te),u_opacity:se,u_temporal_offset:K}))(k.skyboxMatrix,I.getCenter(T,!1),I.paint.get("sky-gradient-radius"),A,D);T.uploadCommonUniforms(L,N),N.draw(T,O.TRIANGLES,P,gt.disabled,T.colorModeForRenderPass(),dt.backCW,Z,"skyboxGradient",I.skyboxGeometry.vertexBuffer,I.skyboxGeometry.indexBuffer,I.skyboxGeometry.segment)}(a,o,y,d,v)},custom:function(a,t,o,c){let d=a.context,m=o.implementation;if(!a.transform.projection.unsupportedLayers||!a.transform.projection.unsupportedLayers.includes("custom")||a.terrain&&(a.terrain.renderingToTexture||a.renderPass==="offscreen")&&o.isDraped(t)){if(a.renderPass==="offscreen"){let _=m.prerender;if(_){if(a.setCustomLayerDefaults(),d.setColorMode(a.colorModeForRenderPass()),a.transform.projection.name==="globe"){let y=a.transform.pointMerc;_.call(m,d.gl,a.transform.customLayerMatrix(),a.transform.getProjection(),a.transform.globeToMercatorMatrix(),h.ai(a.transform.zoom),[y.x,y.y],a.transform.pixelsPerMeterRatio)}else _.call(m,d.gl,a.transform.customLayerMatrix());d.setDirty(),a.setBaseState()}}else if(a.renderPass==="translucent"){if(a.terrain&&a.terrain.renderingToTexture){let y=m.renderToTile;if(y){let v=c[0].canonical,T={x:v.x+c[0].wrap*(m.wrapTileId?0:1<<v.z),y:v.y,z:v.z};d.setDepthMode(nt.disabled),d.setStencilMode(gt.disabled),d.setColorMode(a.colorModeForRenderPass()),a.setCustomLayerDefaults();let I=d.gl;a.emissiveMode==="mrt-fallback"&&I.drawBuffers([I.COLOR_ATTACHMENT0]),y.call(m,d.gl,T),a.emissiveMode==="mrt-fallback"&&I.drawBuffers([I.COLOR_ATTACHMENT0,I.COLOR_ATTACHMENT1]),d.setDirty(),a.setBaseState()}return}a.setCustomLayerDefaults(),d.setColorMode(a.colorModeForRenderPass()),d.setStencilMode(gt.disabled);let _=m.renderingMode==="3d"?new nt(a.context.gl.LEQUAL,nt.ReadWrite,a.depthRangeFor3D):a.depthModeForSublayer(0,nt.ReadOnly);if(d.setDepthMode(_),a.transform.projection.name==="globe"){let y=a.transform.pointMerc;m.render(d.gl,a.transform.customLayerMatrix(),a.transform.getProjection(),a.transform.globeToMercatorMatrix(),h.ai(a.transform.zoom),[y.x,y.y],a.transform.pixelsPerMeterRatio)}else m.render(d.gl,a.transform.customLayerMatrix());d.setDirty(),a.setBaseState(),d.bindFramebuffer.set(null)}}else h.w("Custom layers are not yet supported with this projection. Use mercator or globe to enable usage of custom layers.")},model:function(a,t,o,c){if(a.renderPass==="opaque")return;let d=o.paint.get("model-opacity").constantOr(1),m=o.paint.get("model-elevation-reference"),_=m==="ground",y=m==="ground";if(d===0)return;let v=o.paint.get("model-cast-shadows");
3281if(a.renderPass==="shadow"&&(!v||a.terrain&&d<.65&&o._transitionablePaint._values["model-opacity"].value.expression instanceof h.ac))return;let T=a.shadowRenderer,I=o.paint.get("model-receive-shadows");T&&(T.useNormalOffset=!0,I||(T.enabled=!1));let P=()=>{T&&(T.useNormalOffset=!0,I||(T.enabled=!0))},A=t.getSource();if(a.renderPass==="light-beam"&&A.type!=="batched-model")return;if(A.type==="vector"||A.type==="geojson")return function(G,re,te,se,K){let J=G.transform,oe=J.projection.name==="globe",ue=J.getFreeCameraOptions().position;if(!G.modelManager)return;let de=G.modelManager;te.modelManager=de;let be=G.shadowRenderer;if(!Object.hasOwn(te._unevaluatedLayout._values,"model-id"))return;let ve=te._unevaluatedLayout._values["model-id"],Fe=Object.assign({},te.layout.get("model-id").parameters),pe=G.style.order.indexOf(te.fqid),Ie=te.paint.get("model-opacity").constantOr(1);for(let fe of se){let Pe=re.getTile(fe).getBucket(te);if(!Pe||Pe.projection.name!==J.projection.name)continue;let Ce=Pe.getModelUris();if(Ce&&!Pe.modelsRequested&&(de.addModelsFromBucket(Ce,K),Pe.modelsRequested=!0),oe)Fe.zoom=fe.overscaledZ;else{let et=dm(fe,J);Fe.zoom=et}let Re=ve.possiblyEvaluate(Fe);if(hm(G,Pe,fe),vo.shadowUniformsInitialized=!1,vo.useSingleShadowCascade=!!be&&be.getMaxCascadeForTile(fe.toUnwrapped())===0,G.renderPass==="shadow"&&be){if(G.currentShadowCascade===1&&Pe.isInsideFirstShadowMapFrustum)continue;let et=J.calculatePosMatrix(fe.toUnwrapped(),J.worldSize);if(vo.tileMatrix.set(et),vo.shadowTileMatrix.set(be.calculateShadowPassMatrixFromMatrix(et)),vo.aabb.min=[0,0,0],vo.aabb.max[0]=vo.aabb.max[1]=h.ak,vo.aabb.max[2]=0,lg(Pe,vo,G,te.scope))continue}let Ye=1<<fe.canonical.z,$e=[((ue.x-fe.wrap)*Ye-fe.canonical.x)*h.ak,(ue.y*Ye-fe.canonical.y)*h.ak,ue.z*Ye*h.ak];G.conflationActive&&Object.keys(Pe.instancesPerModel).length>0&&G.style.isLayerClipped(te,re.getSource())&&Pe.updateReplacement(fe,G.replacementSource,pe,te.scope)&&(Pe.uploaded=!1,Pe.upload(G.context));let je=0,Ue=new Array,at=new Array,ot=new Array;for(let et in Pe.instancesPerModel){let it=Pe.instancesPerModel[et];it.features.length>0&&!oe&&(et=Re.evaluate(it.features[0].feature,{}));let ut=de.getModel(et,K);if(ut||de.hasURLBeenRequested(et)||Pe.modelUris.includes(et)||(Pe.modelUris.push(et),Pe.modelsRequested=!1),ut&&ut.uploaded)if(oe){let xt=h.bN([],[ue.x,ue.y,ue.z],G.transform.worldSize);h.ew(xt,xt);for(let _t=0;_t<it.instancedDataArray.length;++_t){let Tt=[0,0,0],yt=[1,1,1],Ft=h.ex(),bt=it.tileCoordinatesForInstance(_t),Nt=it.transformForInstance(_t);h.ey(yt,Nt),h.ez(Ft,Nt),h.eA(Tt,Ft);let $t=it.translationForInstance(_t),bi=new h.aX(0,0);h.eB(Pe.canonical,bi,bt.x,bt.y);let ai=h.bd();h.eC(ai,ut,G.transform,bi,Tt,yt,$t,!0,!1,!1);let Zt=it.colorForInstance(_t),It=h.cK([],xt),Et=h.e8(bi.lat,G.transform.zoom),li=h.bT([],[1,1,1/Et]);ot.push({zScaleMatrix:li,negCameraPosMatrix:It});for(let Di of ut.nodes)qc(G,Di,ai,G.transform.expandedFarZProjMatrix,je,Ue,at,ut.materialOverrides,Ie,Zt);++je}}else for(let xt of ut.nodes)Kd(G,te,xt,it,$e,fe,vo)}if(oe)if(G.renderPass==="shadow"){for(let et of at)Ll(et.mesh,et.nodeModelMatrix,G,te);for(let et of Ue)Ll(et.mesh,et.nodeModelMatrix,G,te)}else Jd(G,te,Ue,at,ot)}}(a,t,o,c,Xd(a,o)),void P();if(!A.loaded())return;if(A.type==="batched-model")return function(G,re,te,se){te.resetLayerRenderingStats(G);let K=G.context,J=G.transform,oe=G.style.fog,ue=G.shadowRenderer;if(J.projection.name!=="mercator")return void h.w(`Drawing 3D landmark models for ${J.projection.name} projection is not yet implemented`);let de=G.transform.getFreeCameraOptions().position,be=h.bN([],[de.x,de.y,de.z],G.transform.worldSize),ve=h.ew([],be),Fe=h.cK([],ve),pe=h.e8(J.center.lat,J.zoom),Ie=h.bT([],[1,1,1/pe]),fe=te.paint.get("model-opacity").constantOr(1),Pe=new nt(K.gl.LEQUAL,nt.ReadWrite,G.depthRangeFor3D),Ce=new nt(K.gl.LEQUAL,nt.ReadOnly,G.depthRangeFor3D),Re=new h.cY([1/0,1/0,1/0],[-1/0,-1/0,-1/0]),Ye=G.renderPass==="shadow",$e=Ye&&ue?ue.getCurrentCascadeFrustum():J.getFrustum(J.scaleZoom(J.worldSize)),je=te.paint.get("model-front-cutoff"),Ue=je[2]<1,at=Cs(G,te.paint.get("model-cutoff-fade-range")),ot=te.getLayerRenderingStats();(function(et,it,ut,xt){let _t=et.terrain?et.terrain.exaggeration():0,Tt=et.transform.zoom;for(let yt of xt){let Ft=it.getTile(yt).getBucket(ut);Ft&&(Ft.setFilter(ut.filter),et.conflationActive&&Ft.updateReplacement(yt,et.replacementSource),Ft.evaluateTransform(et,ut),et.terrain&&_t>0&&Ft.elevationUpdate(et.terrain,_t,yt,ut.source),Ft.needsReEvaluation(et,Tt,ut)&&Ft.evaluate(ut))}})(G,re,te,se),function(){let et=new Map,it,ut,xt;Ue?(it=se.length-1,ut=-1,xt=-1):(it=0,ut=se.length,xt=1);
3281let _t=new Float64Array(16),Tt=h.cg(),yt=new h.P(0,0);for(let Ft=it;Ft!==ut;Ft+=xt){let bt=se[Ft],Nt=re.getTile(bt).getBucket(te);if(!Nt||!Nt.uploaded)continue;let $t=!1;ue&&($t=ue.getMaxCascadeForTile(bt.toUnwrapped())===0);let bi=J.calculatePosMatrix(bt.toUnwrapped(),J.worldSize),ai=Nt.modelTraits;!Ye&&Ue&&(h.ba(_t,bi),h.ae(Tt,be,_t),yt.x=Tt[0],yt.y=Tt[1]);let Zt=[];Nt.setFilter(te.filter);for(let It of Nt.getNodesInfo()){if(It.hiddenByReplacement||!It.node.meshes)continue;let Et=It.node,li=0;G.terrain&&Et.elevation&&(li=Et.elevation*G.terrain.exaggeration());let Di=(()=>{let cn=It.aabb;return Re.min=[...cn.min],Re.max=[...cn.max],Re.min[2]+=li,Re.max[2]+=li,h.ae(Re.min,Re.min,bi),h.ae(Re.max,Re.max,bi),Re})(),Qt=It.evaluatedScale;if(Qt[0]<=1&&Qt[1]<=1&&Qt[2]<=1&&Di.intersects($e)===0)continue;if(!Ye){let cn=Di.min,sr=Di.max;Pl[0]=.5*(cn[0]+sr[0]),Pl[1]=.5*(cn[1]+sr[1]),Pl[2]=.5*(cn[2]+sr[2]);let Kn=h.bh(be,Pl)*pe;fm(It,Kn,Math.min(G._debugParams.dt,1e3/30),G._debugParams.lodSwitchDistance)}if(!Ye&&Ue){let cn=.16666666666666666;It.cameraCollisionOpacity=be[0]>Di.min[0]&&be[0]<Di.max[0]&&be[1]>Di.min[1]&&be[1]<Di.max[1]&&be[2]*pe<Di.max[2]&&Et.footprint&&h.bG(yt,Et.footprint)?Math.max(It.cameraCollisionOpacity-cn,0):Math.min(1,It.cameraCollisionOpacity+cn)}let vt=[...bi],yi=1/h.cW(bt.canonical),fi=Et.anchor?Et.anchor[0]:0,ki=Et.anchor?Et.anchor[1]:0;h.bB(vt,vt,[fi*(Qt[0]-1)+It.evaluatedTranslation[0]*yi,ki*(Qt[1]-1)+It.evaluatedTranslation[1]*yi,li+It.evaluatedTranslation[2]]),h.c6(Qt,h.eE)||h.cE(vt,vt,Qt);let Bt=h.aC([],vt,Et.globalMatrix),Yi=h.aC([],J.expandedFarZProjMatrix,Bt),Nn=h.aC([],J.expandedFarZProjMatrix,vt),fn=h.aD([],[fi,ki,li,1],Yi)[2];Et.hidden=!1;let An=fe;Ye||(Ue&&(An*=It.cameraCollisionOpacity,An*=ug(vt,J,It.aabb,je)),An*=cg(at,fn)),An!==0?Zt.push({nodeInfo:It,depth:fn,opacity:An,wvpForNode:Yi,wvpForTile:Nn,nodeModelMatrix:Bt,tileModelMatrix:vt}):Et.hidden=!0}Ye||Zt.sort((It,Et)=>!Ue||It.opacity===1&&Et.opacity===1?It.depth<Et.depth?-1:1:It.opacity===1?-1:Et.opacity===1?1:It.depth>Et.depth?-1:1);for(let It of Zt){let Et=It.nodeInfo,li=Et.node;if(G._debugParams.show3DModelFootprints&&li.footprint){let fn=li.id||li.name||"footprint";et.has(fn)||et.set(fn,{node:li,mvp:It.wvpForTile})}h.aC(hr,Ie,It.tileModelMatrix),h.aC(hr,Fe,hr),h.ba(nr,hr),h.e9(nr,nr),h.cE(nr,nr,pm),h.aC(hr,hr,li.globalMatrix);let Di=G.renderPass==="light-beam",Qt=te.paint.get("model-color-use-theme").constantOr("default")==="none",vt=ai&h.eH.HasMapboxMeshFeatures,yi=vt?0:Et.evaluatedRMEA[0][2],fi=Et.targetLod,ki=li.lodMeshes&&li.lodMeshes.length>0,Bt=ki&&fi>0&&fi<1;if(Ye&&ki&&Math.round(fi)===1)continue;let Yi=Bt?2:1,Nn=ki&&Math.round(fi)===1;for(let fn=0;fn<Yi;++fn){let An=Bt?fn===1:Nn,cn=An?li.lodMeshes:li.meshes,sr=Bt?An?-fi:1-fi:1;for(let Kn=0;Kn<cn.length;++Kn){let Ri=cn[Kn],Ni=!An&&Kn===li.lightMeshIndex,Ii=It.wvpForNode;if(Ni){if(!Di&&!G.terrain&&G.shadowRenderer){G.currentLayer<G.firstLightBeamLayer&&(G.firstLightBeamLayer=G.currentLayer);continue}Ii=It.wvpForTile}else if(Di)continue;let ei={defines:[]},oi=[];if(!Ye&&ue&&(ue.useNormalOffset=!!Ri.normalBuffer),Rl(ei.defines,oi,Ri,G,Qt?null:te.lut),vt||ei.defines.push("DIFFUSE_SHADED"),$t&&ei.defines.push("SHADOWS_SINGLE_CASCADE"),ot&&(Ye?ot.numRenderedVerticesInShadowPass+=Ri.vertexArray.length:ot.numRenderedVerticesInTransparentPass+=Ri.vertexArray.length),Ye){Ll(Ri,It.nodeModelMatrix,G,te);continue}let Ji=null;if(oe&&(Ji=Dl(ah,It.nodeModelMatrix,G.transform),J.projection.name!=="globe")){let oo=Ri.aabb.min,as=Ri.aabb.max,[ls,To]=oe.getOpacityForBounds(Ji,oo[0],oo[1],as[0],as[1]);ei.overrideFog=ls>=ws||To>=ws}let bn=Ri.material,Fi;bn.occlusionTexture&&bn.occlusionTexture.offsetScale&&(Fi=bn.occlusionTexture.offsetScale,ei.defines.push("OCCLUSION_TEXTURE_TRANSFORM")),Bt&&ei.defines.push("DITHERED_DISCARD");let wn=G.getOrCreateProgram("model",ei);!Ye&&ue&&ue.setupShadowsFromMatrix(It.tileModelMatrix,wn,ue.useNormalOffset),G.uploadCommonUniforms(K,wn,null,Ji);let $r=bn.pbrMetallicRoughness;$r.metallicFactor=.9,$r.roughnessFactor=.5;let ar=zd(Ii,hr,nr,li.globalMatrix,G,It.opacity,$r.baseColorFactor,bn.emissiveFactor,$r.metallicFactor,$r.roughnessFactor,bn,yi,te,[0,0,0],Fi,void 0,void 0,sr);!Ni&&(Et.hasTranslucentParts||It.opacity<1)&&wn.draw(G,K.gl.TRIANGLES,Pe,gt.disabled,mt.disabled,dt.backCCW,ar,te.id,Ri.vertexBuffer,Ri.indexBuffer,Ri.segments,te.paint,G.transform.zoom,void 0,oi),wn.draw(G,K.gl.TRIANGLES,Ni?Ce:Pe,gt.disabled,Ni||It.o
3281pacity<1||Et.hasTranslucentParts?mt.alphaBlended:mt.unblended,dt.backCCW,ar,te.id,Ri.vertexBuffer,Ri.indexBuffer,Ri.segments,te.paint,G.transform.zoom,void 0,oi)}}}}if(G._debugParams.show3DModelFootprints&&et.size>0){let Ft=Array.from(et.keys()).sort();for(let bt of Ft){let{node:Nt,mvp:$t}=et.get(bt);Yd(G,0,Nt,$t)}}}()}(a,t,o,c),void P();if(A.type!=="model")return;let D=A.getModels(),L=[],O=a.transform.getFreeCameraOptions().position,k=h.bN([],[O.x,O.y,O.z],a.transform.worldSize);h.ew(k,k);let N=[],q=[],Z=0;for(let G of D){let re=t.getFeatureState("",G.id),te={type:"Unknown",id:G.id,properties:G.featureProperties},se=o.paint.get("model-rotation").evaluate(te,re),K=o.paint.get("model-scale").evaluate(te,re),J=o.paint.get("model-translation").evaluate(te,re),oe=o.paint.get("model-opacity").evaluate(te,re);cm(o,G.id,re,G.featureProperties,G.nodeOverrideNames,G.nodeOverrides),um(o,G.id,re,G.featureProperties,G.materialOverrideNames,G.materialOverrides),G.nodeOverrides.size>0&&G.computeBoundsAndApplyParent(),G.computeModelMatrix(a,se,K,J,y,_,!1);let ue=h.cK([],k),de=h.e8(G.position.lat,a.transform.zoom),be=h.bT([],[1,1,1/de]);L.push({zScaleMatrix:be,negCameraPosMatrix:ue});for(let ve of G.nodes)qc(a,ve,G.matrix,a.transform.expandedFarZProjMatrix,Z,N,q,G.materialOverrides,oe);Z++}if(N.sort((G,re)=>re.depth-G.depth),a.renderPass!=="shadow"){if(a._debugParams.show3DModelFootprints){let G=a.transform.projMatrix,re=new Map,te=(K,J)=>{if(K.footprint){let oe=K.id||K.name||"footprint";if(!re.has(oe)){let ue=h.aC([],G,J);re.set(oe,{node:K,mvp:ue})}}};for(let K of q)te(K.node,K.modelMatrix);for(let K of N)te(K.node,K.modelMatrix);let se=Array.from(re.keys()).sort();for(let K of se){let{node:J,mvp:oe}=re.get(K);Yd(a,0,J,oe)}}Jd(a,o,N,q,L),P()}else{for(let G of q)Ll(G.mesh,G.nodeModelMatrix,a,o);for(let G of N)Ll(G.mesh,G.nodeModelMatrix,a,o);P()}}},Qd={line:function(a,t,o){if(a.hasElevatedBuckets=!1,a.hasNonElevatedBuckets=!1,a._unevaluatedLayout.getValue("line-elevation-reference")!==void 0||a._unevaluatedLayout.getValue("line-z-offset")!==void 0){if(t){let c=t.getVisibleCoordinates();for(let d of c){let m=t.getTile(d).getBucket(a);if(m&&(m.elevationType!=="none"?a.hasElevatedBuckets=!0:a.hasNonElevatedBuckets=!0,a.hasElevatedBuckets&&a.hasNonElevatedBuckets))break}}}else a.hasNonElevatedBuckets=!0},model:function(a,t,o){let c=t.getSource();if(!c.loaded())return;if(c.type==="vector"||c.type==="geojson")return void(o.modelManager&&o.modelManager.upload(o,Xd(o,a)));if(c.type==="batched-model"||c.type!=="model")return;let d=c.getModels();for(let m of d)m.upload(o.context)},raster:function(a,t,o){let c=t.getSource();if(!(c instanceof jt&&c.loaded()))return;let d=a.sourceLayer||c.rasterLayerIds&&c.rasterLayerIds[0];if(!d)return;let m=a.paint.get("raster-array-band")||c.getInitialBand(d);if(m==null)return;let _=t.getIds().map(y=>t.getTileByID(y));for(let y of _)y.updateNeeded(a.id,m)&&c.prepareTile(y,d,a.id,m)}},Fl={fill:La},ep={fill:function(a,t,o,c){if(!o.layout||o.layout.get("fill-elevation-reference")==="none"||o.paint.get("fill-opacity").constantOr(1)===0)return;let d=a.context.gl,m=new nt(d.LEQUAL,nt.ReadOnly,a.depthRangeFor3D),_=new gt({func:d.ALWAYS,mask:255},255,255,d.KEEP,d.KEEP,d.REPLACE),y=a.transform.getFreeCameraOptions().position,v=a.getOrCreateProgram("elevatedStructuresDepthReconstruct");for(let T of c){let I=t.getTile(T),P=I.getBucket(o);if(!P)continue;let A=P.elevatedStructures;if(!A||!A.depthSegments||A.depthSegments.segments[0].primitiveLength===0)continue;let D=Ze(T.toUnwrapped(),y),L=a.translatePosMatrix(T.projMatrix,I,o.paint.get("fill-translate"),o.paint.get("fill-translate-anchor")),O=Oc(L,D,0,1,0);v.draw(a,d.TRIANGLES,m,_,mt.disabled,dt.disabled,O,o.id,A.vertexBuffer,A.indexBuffer,A.depthSegments,o.paint,a.transform.zoom)}}};class tp{constructor(t,o,c,d,m){this.context=new Fs(t,o),this.transform=c,this._tileTextures={},this.frameCopies=[],this.loadTimeStamps=[],this._debugParams={averageFPS:0,fpsHistory:[],fpsWindow:30,dt:0,timeStamp:h.o.now(),continousRedraw:!1,enabledLayers:{},buildingsShowNormals:!1,buildingsDrawGroundAO:!0,buildingsDrawShadowPass:!0,buildingsDrawTranslucentPass:!0,showTerrainProxyTiles:!1,terrainSortTilesHiZFirst:!0,terrainDisableRenderCache:!1,forceEnablePrecipitation:!1,overrideSnowParams:!1,snowParamsOverride:null,snowRevealParamsOverride:null,snowVignetteParam
3281sOverride:null,overrideRainParams:!1,rainParamsOverride:null,rainRevealParamsOverride:null,rainVignetteParamsOverride:null,overrideStarsParams:!1,starsParamsOverride:null,show3DModelFootprints:!1,showElevationIdDebug:!1,lodSwitchDistance:3e3},this.occlusionParams=new hg,this.setup(),this.numSublayers=rn.maxUnderzooming+rn.maxOverzooming+1,this.depthEpsilon=1/Math.pow(2,16),this.deferredRenderGpuTimeQueries=[],this.gpuTimers={},this.frameCounter=0,this._shadowCullCache=null,this._backgroundTiles={},this.conflationActive=!1,this.replacementSource=new h.eJ,this.longestCutoffRange=0,this.minCutoffZoom=0,this._fogVisible=!1,this._cachedTileFogOpacities={},this._shadowRenderer=new xf(this),this._wireframeDebugCache=new Ol,this.renderDefaultNorthPole=!0,this.renderDefaultSouthPole=!0,this.layersWithOcclusionOpacity=[];let _=new h.q({width:1,height:1},Uint8Array.of(0,0,0,0));this.emptyDepthTexture=new h.T(this.context,_,t.RGBA8),this._clippingActiveLastFrame=!1,this.scaleFactor=d,this.maxFrontCutoffRawStart=0,this.worldview=m,this._forceEmissiveMode=!1,this.emissiveMode="constant"}updateTerrain(t,o){let c=!!t&&!!t.terrain&&this.transform.projection.supportsTerrain;if(!(c||this._terrain&&this._terrain.enabled))return;this._terrain||(this._terrain=new wd(this,t));let d=this._terrain;this.transform.elevation=c?d:null,d.update(t,this.transform,o),this.transform.elevation&&!d.enabled&&(this.transform.elevation=null)}_updateFog(t){let o=t.fog;if(!o||this.transform.projection.name==="globe"||o.getOpacity(this.transform.pitch)<1||o.properties.get("horizon-blend")<.03)return void(this.transform.fogCullDistSq=null);let[c,d]=o.getRangeForProjection();if(c>d)return void(this.transform.fogCullDistSq=null);let m=c+.78*(d-c);this.transform.fogCullDistSq=m*m}get terrain(){return this.transform._terrainEnabled()&&this._terrain&&this._terrain.enabled||this._forceTerrainMode?this._terrain:null}get forceTerrainMode(){return this._forceTerrainMode}set forceTerrainMode(t){t&&!this._terrain&&(this._terrain=new wd(this,this.style)),this._forceTerrainMode=t}get shadowRenderer(){return this._shadowRenderer&&this._shadowRenderer.enabled?this._shadowRenderer:null}get wireframeDebugCache(){return this._wireframeDebugCache}resize(t,o){if(this.width=t*h.o.devicePixelRatio,this.height=o*h.o.devicePixelRatio,this.context.viewport.set([0,0,this.width,this.height]),this.style)for(let c of this.style.order)this.style._mergedLayers[c].resize()}setup(){let t=this.context,o=new h.dE;o.emplaceBack(0,0),o.emplaceBack(h.ak,0),o.emplaceBack(0,h.ak),o.emplaceBack(h.ak,h.ak),this.tileExtentBuffer=t.createVertexBuffer(o,h.dA.members),this.tileExtentSegments=h.dB.simpleSegment(0,0,4,2);let c=new h.dE;c.emplaceBack(0,0),c.emplaceBack(h.ak,0),c.emplaceBack(0,h.ak),c.emplaceBack(h.ak,h.ak),this.debugBuffer=t.createVertexBuffer(c,h.dA.members),this.debugSegments=h.dB.simpleSegment(0,0,4,5);let d=new h.dE;d.emplaceBack(-1,-1),d.emplaceBack(1,-1),d.emplaceBack(-1,1),d.emplaceBack(1,1),this.viewportBuffer=t.createVertexBuffer(d,h.dA.members),this.viewportSegments=h.dB.simpleSegment(0,0,4,2);let m=new h.eK;m.emplaceBack(0,0,0,0),m.emplaceBack(h.ak,0,h.ak,0),m.emplaceBack(0,h.ak,0,h.ak),m.emplaceBack(h.ak,h.ak,h.ak,h.ak),this.mercatorBoundsBuffer=t.createVertexBuffer(m,h.eL.members),this.mercatorBoundsSegments=h.dB.simpleSegment(0,0,4,2);let _=new h.dF;_.emplaceBack(0,1,2),_.emplaceBack(2,1,3),this.quadTriangleIndexBuffer=t.createIndexBuffer(_);let y=new h.eM;for(let T of[0,1,3,2,0])y.emplaceBack(T);this.debugIndexBuffer=t.createIndexBuffer(y),this.emptyTexture=new h.T(t,new h.q({width:1,height:1},Uint8Array.of(0,0,0,0)),t.gl.RGBA8),this.identityMat=h.bd();let v=this.context.gl;this.stencilClearMode=new gt({func:v.ALWAYS,mask:0},0,255,v.ZERO,v.ZERO,v.ZERO),this.loadTimeStamps.push(performance.now())}getMercatorTileBoundsBuffers(){return{tileBoundsBuffer:this.mercatorBoundsBuffer,tileBoundsIndexBuffer:this.quadTriangleIndexBuffer,tileBoundsSegments:this.mercatorBoundsSegments}}getTileBoundsBuffers(t){return t._makeTileBoundsBuffers(this.context,this.transform.projection),t._tileBoundsBuffer?{tileBoundsBuffer:t._tileBoundsBuffer,tileBoundsIndexBuffer:t._tileBoundsIndexBuffer,tileBoundsSegments:t._tileBoundsSegments}:this.getMercatorTileBoundsBuffers()}clearStencil(){let t=this.context.gl;this.nextStencilID=1,this.currentStencilSource=void 0,this._tileClippingMaskIDs={},this.getOrCreateProgram("clippingMask").draw(this,t.TRIANGLES,nt.disabled,this.stencilClearMode,mt.disabled,dt.disabled,wl(this.identityMat),"$clipping",this.viewportBuffer,this.quadTriangleIndexBuffer,this.viewportSegments)}resetStencilClippingMasks(){this.terrain||(this.currentStencilSource=void 0,this._tileClippingMaskIDs={})}_renderTileClippingMasks(t,o,c){if(!o||this.currentStencilSource===o.id||!t.isTileClipped()||!c||c.length===0)return;if(this._tileClippingMaskIDs&&!this.terrain){let y=!1;for(let v of c)if(this._tileClippingMaskIDs[v.key]===void 0){y=!0;break}if(!y)return}this.currentStencilSource=o.id;let d=this.context,m=d.gl;this.nextStencilID+c.length>256&&this.clearStencil(),d.setColorMode(mt.disabled),d.setDepthMode(nt.disabled);let _=this.getOrCreateProgram("clippingMask");this._tileClippingMaskIDs={};for(let y of c){let v=o.getTile(y),T=this._tileClippingMaskIDs[y.key]=this.nextStencilID++,{tileBoundsBuffer:I,tileBoundsIndexBuffer:P,tileBoundsSegments:A}=this.getTileBoundsBuffers(v);_.draw(this,m.TRIANGLES,nt.disabled,new gt({func:m.ALWAYS,mask:0},T,255,m.KEEP,m.KEEP,m.REPLACE),mt.disabled,dt.disabled,wl(y.projMatrix),"$clipping",I,P,A)}}stencilModeFor3D(){this.currentStencilSource=void 0,this.nextStencilID+1>256&&this.clearStencil();let t=this.nextStencilID++,o=this.context.gl;return new gt({func:o.NOTEQUAL,mask:255},t,255,o.KEEP,o.KEEP,o.REPLACE)}stencilModeForClipping(t){if(this.terrain)return this.terrain.stencilModeForRTTOverlap(t);let o=this.context.gl;return new gt({func:o.EQUAL,mask:255},this._tileClippingMaskIDs[t.key],0,o.KEEP,o.KEEP,o.REPLACE)}stencilConfigForOverlap(t){let o=this.context.gl,c=t.sort((_,y)=>
3281y.overscaledZ-_.overscaledZ),d=c.at(-1).overscaledZ,m=c[0].overscaledZ-d+1;if(m>1){this.currentStencilSource=void 0,this.nextStencilID+m>256&&this.clearStencil();let _={};for(let y=0;y<m;y++)_[y+d]=new gt({func:o.GEQUAL,mask:255},y+this.nextStencilID,255,o.KEEP,o.KEEP,o.REPLACE);return this.nextStencilID+=m,[_,c]}return[{[d]:gt.disabled},c]}colorModeForRenderPass(){let t=this.context.gl;return this._showOverdrawInspector?new mt([t.CONSTANT_COLOR,t.ONE,t.CONSTANT_COLOR,t.ONE],new h.C(.125,.125,.125,0),[!0,!0,!0,!0]):this.renderPass==="opaque"?mt.unblended:mt.alphaBlended}colorModeForDrapableLayerRenderPass(t){let o=this.context.gl;return this.style&&this.style.enable3dLights()&&this.terrain&&this.terrain.renderingToTexture&&this.renderPass==="translucent"?t!=null&&this.emissiveMode!=="mrt-fallback"||this.emissiveMode==="constant"?new mt([o.ONE,o.ONE_MINUS_SRC_ALPHA,o.CONSTANT_ALPHA,o.ONE_MINUS_SRC_ALPHA],new h.C(0,0,0,t??0),[!0,!0,!0,!0]):this.emissiveMode==="dual-source-blending"?new mt([o.ONE,o.ONE_MINUS_SRC_ALPHA,this.context.extBlendFuncExtended.SRC1_ALPHA_WEBGL,o.ONE_MINUS_SRC_ALPHA],h.C.transparent,[!0,!0,!0,!0]):this.colorModeForRenderPass():this.colorModeForRenderPass()}depthModeForSublayer(t,o,c,d=!1){if(this.depthOcclusion)return new nt(this.context.gl.GREATER,nt.ReadOnly,this.depthRangeFor3D);if(!this.opaquePassEnabledForLayer()&&!d)return nt.disabled;let m=1-((1+this.currentLayer)*this.numSublayers+t)*this.depthEpsilon;return new nt(c||this.context.gl.LEQUAL,o,[m,m])}opaquePassEnabledForLayer(){return this.currentLayer<this.opaquePassCutoff}blitDepth(){let t=this.context.gl,o=Math.ceil(this.width),c=Math.ceil(this.height),d=this.context.bindFramebuffer.get(),m=t.getParameter(t.TEXTURE_BINDING_2D);this.depthFBO&&this.depthFBO.width===o&&this.depthFBO.height===c||(this.depthFBO&&(this.depthFBO.destroy(),this.depthFBO=void 0,this.depthTexture=void 0),o!==0&&c!==0&&(this.depthFBO=new En(this.context,o,c,0,"texture"),this.depthTexture=new h.T(this.context,{width:o,height:c,data:null},t.DEPTH24_STENCIL8),this.depthFBO.depthAttachment.set(this.depthTexture.texture))),this.context.bindFramebuffer.set(d),t.bindTexture(t.TEXTURE_2D,m),this.depthFBO&&(t.bindFramebuffer(t.READ_FRAMEBUFFER,null),t.bindFramebuffer(t.DRAW_FRAMEBUFFER,this.depthFBO.framebuffer),t.blitFramebuffer(0,0,o,c,0,0,o,c,t.DEPTH_BUFFER_BIT,t.NEAREST),t.bindFramebuffer(t.FRAMEBUFFER,this.context.bindFramebuffer.current))}render(t,o){this.context.sweepPendingPrograms(),this._wireframeDebugCache.update(this.frameCounter),this.style=t,this.options=o;let c=this.style._mergedLayers,d=!(!this.terrain||!this.terrain.enabled),m=()=>this.style._getOrder(d),_=m(),y=!1,v=!1,T=null,I=0,P=!1;for(let pe of _){let Ie=c[pe];Ie.visibility!=="none"&&(Ie.type==="circle"?y=!0:Ie.type==="building"?(T=Ie,++I):Ie.type==="symbol"&&(Ie.hasOcclusionOpacityProperties?v=!0:y=!0))}this.updateEmissiveMode();let A=_.map(pe=>c[pe]),D=this.style._mergedSourceCaches;this.imageManager=t.imageManager,this.modelManager=t.modelManager,this.symbolFadeChange=t.placement.symbolFadeChange(h.o.now()),this.imageManager.beginFrame();for(let pe in D){let Ie=D[pe];Ie.used&&(Ie.prepare(this.context),Ie.getSource().usedInConflation&&++I)}let L=!1;for(let pe of A)pe.isHidden(this.transform.zoom)||(pe.type==="clip"&&(L=!0),this.prepareLayer(pe));let O={},k={},N={},q={},Z={};for(let pe in D){let Ie=D[pe];O[pe]=Ie.getVisibleCoordinates(),k[pe]=O[pe].slice().reverse(),N[pe]=Ie.getVisibleCoordinates(!0).reverse(),q[pe]=Ie.getShadowCasterCoordinates(),Z[pe]=Ie.sortCoordinatesByDistance(O[pe])}let G=pe=>{let Ie=this.style.getLayerSourceCache(pe);return Ie&&Ie.used?Ie.getSource():null};if(I||L||this._clippingActiveLastFrame){let pe=[],Ie=[],fe=0;for(let Pe of A)this.isSourceForClippingOrConflation(Pe,G(Pe))&&(pe.push(Pe),Ie.push(fe)),fe++;if(pe&&(L||pe.length>1)||this._clippingActiveLastFrame){L=!1;let Pe=[];for(let Ce=0;Ce<pe.length;Ce++){let Re=pe[Ce],Ye=Ie[Ce],$e=this.style.getLayerSourceCache(Re);if(!$e||!$e.used||!$e.getSource().usedInConflation&&Re.type!=="clip"&&Re.type!=="building")continue;let je=h.eN,Ue=h.bE.None,at=[],ot=!0;if(Re.type==="building")je=h.eP;else if(Re.type==="clip")if(je=Ye,Re.isHidden(this.transform.zoom))ot=!1;else{if(!Re.layout){ot=!1;continue}
3281for(let et of Re.layout.get("clip-layer-types"))Ue|=et==="model"?h.bE.Model:et==="symbol"?h.bE.Symbol:h.bE.FillExtrusion;for(let et of Re.layout.get("clip-layer-scope"))at.push(h.t(et,Re.scope));L=!0}ot&&Pe.push({layer:Re.fqid,cache:$e,order:je,clipMask:Ue,clipScope:at})}this.replacementSource.setSources(Pe),P=!0}}this._clippingActiveLastFrame=L,P||this.replacementSource.clear(),this.conflationActive=P,this.minCutoffZoom=0,this.longestCutoffRange=0,this.maxFrontCutoffRawStart=0,this.opaquePassCutoff=1/0,this._lastOcclusionLayer=-1,this.layersWithOcclusionOpacity=[];for(let pe=0;pe<A.length;pe++){let Ie=A[pe];if(Ie.visibility==="none")continue;let fe=Ie.cutoffRange();if(this.longestCutoffRange=Math.max(fe,this.longestCutoffRange),fe>0){let Pe=G(Ie);Pe&&(this.minCutoffZoom=Math.max(Pe.minzoom,this.minCutoffZoom)),Ie.minzoom&&(this.minCutoffZoom=Math.max(Ie.minzoom,this.minCutoffZoom))}Ie.is3D(d)&&(this.opaquePassCutoff===1/0&&(this.opaquePassCutoff=pe),this._lastOcclusionLayer=pe)}let re=this.style&&this.style.fog;re?(this._fogVisible=re.getOpacity(this.transform.pitch)!==0,this._fogVisible&&this.transform.projection.name!=="globe"&&(this._fogVisible=re.isVisibleOnFrustum(this.transform.cameraFrustum))):this._fogVisible=!1,this._cachedTileFogOpacities={},this.terrain&&(this.terrain.updateTileBinding(N),this.opaquePassCutoff=0,_=m(),A=_.map(pe=>c[pe]));let te=this._shadowRenderer;if(te){te.updateShadowParameters(this.transform,this.style.directionalLight);for(let pe in D)for(let Ie of O[pe]){let fe={min:0,max:0};this.terrain&&(fe=this.terrain.getMinMaxForTile(Ie)||fe),te.addShadowReceiver(Ie.toUnwrapped(),fe.min,fe.max)}}this.transform.projection.name!=="globe"||this.globeSharedBuffers||(this.globeSharedBuffers=new h.eO(this.context)),this.style.fog&&this.transform.projection.supportsFog?(this._atmosphere||(this._atmosphere=new Zd),this._atmosphere.update(this)):this._atmosphere&&(this._atmosphere.destroy(),this._atmosphere=void 0);let se=!(!this.style||!this.style.snow),K=!(!this.style||!this.style.rain);if(se&&!this._snow&&no.Snow&&(this._snow=new no.Snow),!se&&this._snow&&(this._snow.destroy(),delete this._snow),K&&!this._rain&&no.Rain&&(this._rain=new no.Rain),!K&&this._rain&&(this._rain.destroy(),delete this._rain),this._snow&&this._snow.update(this),this._rain&&this._rain.update(this),T){this.buildingTileBorderManager||(this.buildingTileBorderManager=new Wd);let pe=this.style.getLayerSourceCache(T);this.buildingTileBorderManager.updateBorders(pe,T)}if(!oa.has(this.context.gl))return;this.renderPass="offscreen";for(let pe of A){let Ie=t.getLayerSourceCache(pe);if(!pe.hasOffscreenPass()||pe.isHidden(this.transform.zoom))continue;let fe=Ie?k[Ie.id]:void 0;(pe.type==="custom"||pe.type==="raster"||pe.type==="raster-particle"||pe.isSky()||fe&&fe.length)&&this.renderLayer(this,Ie,pe,fe)}this.depthRangeFor3D=[0,1-(A.length+2)*this.numSublayers*this.depthEpsilon],this._shadowRenderer&&(this.renderPass="shadow",this._shadowRenderer.drawShadowPass(this.style,q)),this.context.bindFramebuffer.set(null),this.context.viewport.set([0,0,this.width,this.height]);let J=this.transform.projection.name==="globe"||this.transform.isHorizonVisible(),oe=(()=>{if(o.showOverdrawInspector)return h.C.black;let pe=this.style.fog;if(pe&&this.transform.projection.supportsFog){let Ie=this.style.getLut(pe.scope);if(!J){let fe=pe.properties.get("color-use-theme")==="none",Pe=pe.properties.get("color").toNonPremultipliedRenderColor(fe?null:Ie).toArray01();return new h.C(...Pe)}if(J){let fe=pe.properties.get("space-color-use-theme")==="none",Pe=pe.properties.get("space-color").toNonPremultipliedRenderColor(fe?null:Ie).toArray01();return new h.C(...Pe)}}return h.C.transparent})();if(this.context.clear({color:oe,depth:1}),this.clearStencil(),this._showOverdrawInspector=o.showOverdrawInspector,this.renderPass="opaque",this.style.fog&&this.transform.projection.supportsFog&&this._atmosphere&&!this._showOverdrawInspector&&J&&this._atmosphere.drawStars(this,this.style.fog),!this.terrain)for(this.currentLayer=_.length-1;this.currentLayer>=0;this.currentLayer--){let pe=A[this.currentLayer],Ie=t.getLayerSourceCache(pe);if(pe.isSky())continue;let fe=Ie?(pe.is3D(d)?Z:k)[Ie.id]:void 0;this._renderTileClippingMasks(pe,Ie,fe),this.renderLayer(this,Ie,pe,fe)}if(this.style.fog&&this.transform.projection.supportsFog&&this._atmosphere&&!this._showOverdrawInspector&&J&&this._atmosphere.drawAtmosphereGlow(this,this.style.fog),this.renderPass="sky",(!this._atmosphere||h.ai(this.transform.zoom)>0)&&(this.transform.projection.name==="globe"||this.transform.isH
3281orizonVisible()))for(this.currentLayer=0;this.currentLayer<_.length;this.currentLayer++){let pe=A[this.currentLayer],Ie=t.getLayerSourceCache(pe);pe.isSky()&&this.renderLayer(this,Ie,pe,Ie?k[Ie.id]:void 0)}function ue(pe,Ie){let fe;return Ie&&(fe=(pe.type==="symbol"?N:pe.is3D(d)?Z:k)[Ie.id]),fe}if(this.renderPass="translucent",this.transform.projection.name==="globe"){for(this.renderElevatedRasterBackface=!0,this.currentLayer=0;this.currentLayer<_.length;){let pe=A[this.currentLayer];if(pe.type==="raster"||pe.type==="raster-particle"){let Ie=t.getLayerSourceCache(pe);this.renderLayer(this,Ie,pe,ue(pe,Ie))}++this.currentLayer}this.renderElevatedRasterBackface=!1}this.currentLayer=0,this.firstLightBeamLayer=Number.MAX_SAFE_INTEGER;let de=te?te.getGroundShadowLayerIndex():-1,be=!1,ve=-1;for(let pe=0;pe<_.length;++pe){let Ie=A[pe];Ie.isHidden(this.transform.zoom)||Ie.is3D(d)&&(ve=pe)}v&&ve===-1&&(y=!0);let Fe=!1;for(;this.currentLayer<_.length;){let pe=A[this.currentLayer],Ie=t.getLayerSourceCache(pe);if(pe.isSky())++this.currentLayer;else if(this.terrain&&this.style.isLayerDraped(pe)){if(pe.isHidden(this.transform.zoom)){++this.currentLayer;continue}this.currentLayer=this.terrain.renderBatch(this.currentLayer),this._lastOcclusionLayer=Math.max(this.currentLayer,this._lastOcclusionLayer)}else{if(!Fe&&pe.is3D(d)&&!d){let fe=this.currentLayer,Pe=Ce=>{for(this.currentLayer=0;this.currentLayer<A.length;this.currentLayer++){let Re=A[this.currentLayer];if(Fl[Re.type]){let Ye=this.style.getLayerSourceCache(Re);Fl[Re.type](this,Ye,Re,ue(Re,Ye),Ce)}}};Pe("initialize"),Pe("reset"),this.currentLayer=fe,Fe=!0}if(y&&!be&&this.terrain&&!this.transform.isOrthographic&&(be=!0,this.blitDepth()),v&&ve!==-1&&this.currentLayer===ve+1&&!this.transform.isOrthographic&&this.blitDepth(),this.terrain||this._renderTileClippingMasks(pe,Ie,Ie?O[Ie.id]:void 0),this.renderLayer(this,Ie,pe,ue(pe,Ie)),!this.terrain&&te&&this.currentLayer===de){{this.clearStencil(),this.resetStencilClippingMasks();let fe=this.currentLayer;for(this.currentLayer=0;this.currentLayer<A.length;this.currentLayer++){let Pe=A[this.currentLayer];if(ep[Pe.type]){let Ce=this.style.getLayerSourceCache(Pe);ep[Pe.type](this,Ce,Pe,ue(Pe,Ce))}}this.currentLayer=fe}if(te.drawGroundShadows(),this.firstLightBeamLayer<=this.currentLayer){let fe=this.currentLayer;for(this.renderPass="light-beam",this.currentLayer=this.firstLightBeamLayer;this.currentLayer<=fe;this.currentLayer++){let Pe=A[this.currentLayer];if(!Pe.hasLightBeamPass())continue;let Ce=t.getLayerSourceCache(Pe);this.renderLayer(this,Ce,Pe,Ce?k[Ce.id]:void 0)}this.currentLayer=fe,this.renderPass="translucent"}}if(this.currentLayer>=this._lastOcclusionLayer&&this.layersWithOcclusionOpacity.length>0){let fe=this.currentLayer;this.depthOcclusion=!0;for(let Pe of this.layersWithOcclusionOpacity){this.currentLayer=Pe;let Ce=A[this.currentLayer],Re=t.getLayerSourceCache(Ce),Ye=Re?k[Re.id]:void 0;this.terrain||this._renderTileClippingMasks(Ce,Re,Re?O[Re.id]:void 0),this.renderLayer(this,Re,Ce,Ye)}this.depthOcclusion=!1,this.currentLayer=fe,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 pe=null;A.forEach(Ie=>{let fe=t.getLayerSourceCache(Ie);fe&&!Ie.isHidden(this.transform.zoom)&&fe.getVisibleCoordinates().length&&(!pe||pe.getSource().maxzoom<fe.getSource().maxzoom)&&(pe=fe)}),pe&&this.options.showTileBoundaries&&function(Ie,fe,Pe,Ce,Re,Ye){for(let $e=0;$e<Pe.length;$e++)Vs(Ie,fe,Pe[$e],Ce,0,0,Ye)}(this,pe,pe.getVisibleCoordinates(),h.C.red,0,this.options.showParseStatus)}this.options.showPadding&&function(pe){let Ie=pe.transform.padding;oh(pe,pe.transform.height-(Ie.top||0),3,Us),oh(pe,Ie.bottom||0,3,Al),kr(pe,Ie.left||0,3,rh),kr(pe,pe.transform.width-(Ie.right||0),3,jd);let fe=pe.transform.centerPoint;(function(Pe,Ce,Re,Ye){Ml(Pe,Ce-1,Re-10,2,20,Ye),Ml(Pe,Ce-10,Re-1,20,2,Ye)})(pe,fe.x,pe.transform.height-fe.y,Gd)}(this),this.context.setDefault(),this.frameCounter=(this.frameCounter+1)%Number.MAX_SAFE_INTEGER,this.tileLoaded&&this.options.speedIndexTiming&&(this.loadTimeStamps.push(performance.now()),this.saveC
3281anvasCopy()),P||(this.conflationActive=!1)}prepareLayer(t){this.gpuTimingStart(t);let{unsupportedLayers:o}=this.transform.projection,c=!o||!o.includes(t.type);if(Qd[t.type]&&(c||this.terrain&&t.type==="custom")){let d=this.style.getLayerSourceCache(t);Qd[t.type](t,d,this)}this.gpuTimingEnd()}renderLayer(t,o,c,d){c.isHidden(this.transform.zoom)||(c.type==="background"||c.type==="sky"||c.type==="custom"||c.type==="model"||c.type==="raster"||c.type==="raster-particle"||d&&d.length)&&(this.id=c.id,this.gpuTimingStart(c),(!t.transform.projection.unsupportedLayers||!t.transform.projection.unsupportedLayers.includes(c.type)||t.terrain&&c.type==="custom")&&c.type!=="clip"&&c.type!=="slot"&&lh[c.type]&&lh[c.type](t,o,c,d,this.style.placement.variableOffsets,this.options.isInitialLoad),lh[c.type]||async function(){await async function(){return Promise.resolve()}(),Object.assign(lh,{building:no.drawBuilding,"raster-particle":no.drawRasterParticle}),Object.assign(Qd,{"raster-particle":no.prepareRasterParticle})}(),this.gpuTimingEnd())}gpuTimingStart(t){if(!this.options.gpuTiming)return;let o=this.context.extTimerQuery,c=this.context.gl,d=this.gpuTimers[t.id];d||(d=this.gpuTimers[t.id]={calls:0,cpuTime:0,query:c.createQuery()}),d.calls++,c.beginQuery(o.TIME_ELAPSED_EXT,d.query)}gpuTimingDeferredRenderStart(){if(this.options.gpuTimingDeferredRender){let t=this.context.extTimerQuery,o=this.context.gl,c=o.createQuery();this.deferredRenderGpuTimeQueries.push(c),o.beginQuery(t.TIME_ELAPSED_EXT,c)}}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 t=this.gpuTimers;return this.gpuTimers={},t}collectDeferredRenderGpuQueries(){let t=this.deferredRenderGpuTimeQueries;return this.deferredRenderGpuTimeQueries=[],t}queryGpuTimers(t){let o={};for(let c in t){let d=t[c],m=this.context.extTimerQuery,_=m.getQueryParameter(d.query,this.context.gl.QUERY_RESULT)/1e6;
3281m.deleteQueryEXT(d.query),o[c]=_}return o}queryGpuTimeDeferredRender(t){if(!this.options.gpuTimingDeferredRender)return 0;let o=this.context.gl,c=0;for(let d of t)c+=o.getQueryParameter(d,o.QUERY_RESULT)/1e6,o.deleteQuery(d);return c}translatePosMatrix(t,o,c,d,m){if(!c[0]&&!c[1])return t;let _=m?d==="map"?this.transform.angle:0:d==="viewport"?-this.transform.angle:0;if(_){let T=Math.sin(_),I=Math.cos(_);c=[c[0]*I-c[1]*T,c[0]*T+c[1]*I]}let y=[m?c[0]:h.az(o,c[0],this.transform.zoom),m?c[1]:h.az(o,c[1],this.transform.zoom),0],v=new Float32Array(16);return h.bB(v,t,y),v}saveTileTexture(t){if(t.context!==this.context)return;let o=t.size[0],c=this._tileTextures[o];c?c.push(t):this._tileTextures[o]=[t]}getTileTexture(t){let o=this._tileTextures[t];return o&&o.length>0?o.pop():null}terrainRenderModeElevated(){return this.style&&!!this.style.getTerrain()&&!!this.terrain&&!this.terrain.renderingToTexture||this.forceTerrainMode}linearFloatFilteringSupported(){return this.context.extTextureFloatLinear!=null}currentGlobalDefines(t,o,c,d,m){let _=c===void 0?this.terrain&&this.terrain.renderingToTexture:c,y=d===void 0?this.terrainRenderModeElevated():d,v=m===void 0?this.transform.projection.name==="globe":m,T=[];return this.style&&this.style.enable3dLights()&&(t==="globeRaster"||t==="terrainRaster"?(T.push("LIGHTING_3D_MODE"),T.push("LIGHTING_3D_ALPHA_EMISSIVENESS")):_||T.push("LIGHTING_3D_MODE")),y&&(T.push("TERRAIN"),this.linearFloatFilteringSupported()&&T.push("TERRAIN_DEM_FLOAT_FORMAT")),v&&T.push("GLOBE"),!this._fogVisible||_||o!==void 0&&!o||T.push("FOG"),_&&T.push("RENDER_TO_TEXTURE"),this._showOverdrawInspector&&T.push("OVERDRAW_INSPECTOR"),T}getOrCreateProgram(t,o){this.cache=this.cache||{};let{defines:c,config:d,overrideFog:m,overrideRtt:_,overrideTerrain:y,overrideGlobe:v,precompiled:T}=o||{},I=this.currentGlobalDefines(t,m,_,y,v).concat(c||[]),P=this.getShaderSource(t),A=ng[t]||no.programUniforms[t],D=Td.cacheKey(P,t,I,d);return this.cache[D]||(this.cache[D]=new Td(this.context,t,P,d,A,I,T)),this.cache[D]}getShaderSource(t){return Vu[t]||no.shaders&&no.shaders[t]}setCustomLayerDefaults(){this.context.unbindVAO(),this.context.cullFace.setDefault(),this.context.frontFace.setDefault(),this.context.cullFaceSide.setDefault(),this.context.activeTexture.setDefault(),this.context.pixelStoreUnpack.setDefault(),this.context.pixelStoreUnpackPremultiplyAlpha.setDefault(),this.context.pixelStoreUnpackFlipY.setDefault()}setBaseState(){let t=this.context.gl;this.context.cullFace.set(!1),this.context.viewport.set([0,0,this.width,this.height]),this.context.blendEquation.set(t.FUNC_ADD)}initDebugOverlayCanvas(){this.debugOverlayCanvas==null&&(this.debugOverlayCanvas=document.createElement("canvas"),this.debugOverlayCanvas.width=512,this.debugOverlayCanvas.height=512,this.debugOverlayTexture=new h.T(this.context,this.debugOverlayCanvas,this.context.gl.RGBA8))}destroy(){this._terrain&&this._terrain.destroy(),this._atmosphere&&(this._atmosphere.destroy(),this._atmosphere=void 0),this.globeSharedBuffers&&this.globeSharedBuffers.destroy(),this.emptyTexture.destroy(),this.debugOverlayTexture&&this.debugOverlayTexture.destroy(),this._wireframeDebugCache.destroy(),this.depthFBO&&(this.depthFBO.destroy(),this.depthFBO=void 0,this.depthTexture=void 0),this.emptyDepthTexture&&this.emptyDepthTexture.destroy()}prepareDrawTile(){this.terrain&&this.terrain.prepareDrawTile()}uploadCommonLightUniforms(t,o){if(this.style.enable3dLights()){let c=this.style.directionalLight,d=this.style.ambientLight;if(c&&d){let m=((_,y,v)=>{let T=_.properties.get("direction"),I=_.properties.get("color-use-theme")==="none",P=_.properties.get("color").toNonPremultipliedRenderColor(I?null:v.getLut(_.scope)).toArray01(),A=_.properties.get("intensity"),D=y.properties.get("color-use-theme")==="none",L=y.properties.get("color").toNonPremultipliedRenderColor(D?null:v.getLut(y.scope)).toArray01(),O=y.properties.get("intensity"),k=[T.x,T.y,T.z],N=h.dG(L,O),q=h.dG(P,A);return{u_lighting_ambient_color:N,u_lighting_directional_dir:k,u_lighting_directional_color:q,u_ground_radiance:Ff(k,q,N)}})(c,d,this.style);o.setLightsUniformValues(t,m)}}}uploadCommonUniforms(t,o,c,d,m){if(this.uploadCommonLightUniforms(t,o),this.terrain&&this.terrain.renderingToTexture)return;let _=this.style.fog;if(_){let y=_.getOpacity(this.transform.pitch),v=((T,I,P,A,D,L,O,k,N,q,Z,G)=>{let re=T.transform,te=I.properties.get("color-use-theme")==="none",se=I.properties.get("color").toNonPremultipliedRenderColor(te?null:T.style.getLut(I.scope)).toArray01();se[3]=A;let K=T.frameCounter/1e3%1,[J,oe]=I.properties.get("vertical-range");return{u_fog_matrix:P?re.calculateFogTileMatrix(P):G||T.identityMat,u_fog_range:I.getRangeForProjection(),u_fog_color:se,u_fog_horizon_blend:I.properties.get("horizon-blend"),u_fog_vertical_limit:[Math.min(J,oe),oe],u_fog_temporal_offset:K,u_frustum_tl:D,u_frustum_tr:L,u_frustum_br:O,u_frustum_bl:k,u_globe_pos:N,u_globe_radius:q,u_viewport:Z,u_globe_transition:h.ai(re.zoom),u_is_globe:+(re.projection.name==="globe")}})(this,_,c,y,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*h.o.devicePixelRatio,this.transform.height*h.o.devicePixelRatio],d);o.setFogUniformValues(t,v)}m&&o.setCutoffUniformValues(t,m.uniformValues)}setTileLoadedFlag(t){this.tileLoaded=t}saveCanvasCopy(){let t=this.canvasCopy();t&&(this.frameCopies.push(t),this.tileLoaded=!1)}canvasCopy(){let t=this.context.gl,o=t.createTexture();return t.bindTexture(t.TEXTURE_2D,o),t.copyTexImage2D(t.TEXTURE_2D,0,t.RGBA,0,0,t.drawingBufferWidth,t.drawingBufferHeight,0),o}getCanvasCopiesAndTimestamps(){return{canvasCopies:this.frameCopies,timeStamps:this.loadTimeStamps}}averageElevationNeedsEasing(){if(!this.transform._elevation)return!1;let t=this.style&&this.style.fog;return!!t&&t.getOpacity(this.transform.pitch)!==0}
3281getBackgroundTiles(){let t=this._backgroundTiles,o=this._backgroundTiles={},c=this.transform.coveringTiles({tileSize:512});for(let d of c)o[d.key]=t[d.key]||new h.b3(d,512,this.transform.tileZoom,this,void 0,this.worldview);return o}clearBackgroundTiles(){this._backgroundTiles={}}isSourceForClippingOrConflation(t,o){return!(!t.is3D(!(!this.terrain||!this.terrain.enabled))||t.type!=="clip"&&t.type!=="building"&&(t.minzoom&&t.minzoom>this.transform.zoom||(this.style._clipLayerPresent||t.sourceLayer!=="building"&&t.sourceLayer!=="procedural_buildings")&&(!o||o.type!=="batched-model")))}isTileAffectedByFog(t){if(!this.style||!this.style.fog)return!1;if(this.transform.projection.name==="globe")return!0;let o=this._cachedTileFogOpacities[t.key];return o||(this._cachedTileFogOpacities[t.key]=o=this.style.fog.getOpacityForTile(t)),o[0]>=ws||o[1]>=ws}setupDepthForOcclusion(t,o,c){let d=this.context,m=d.gl,_=!!c;var y;c||(c={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}),d.activeTexture.set(m.TEXTURE3),t&&this.depthFBO&&this.depthTexture?(this.depthTexture.bind(m.NEAREST,m.CLAMP_TO_EDGE),c.u_depth_size_inv=[1/this.depthFBO.width,1/this.depthFBO.height],c.u_depth_range_unpack=[2/((y=this.depthRangeFor3D)[1]-y[0]),-1-2*y[0]/(y[1]-y[0])],c.u_occluder_half_size=.5*this.occlusionParams.occluderSize,c.u_occlusion_depth_offset=this.occlusionParams.depthOffset):this.emptyDepthTexture.bind(m.NEAREST,m.CLAMP_TO_EDGE),d.activeTexture.set(m.TEXTURE0),_||o.setTerrainUniformValues(d,c)}updateEmissiveMode(){if(this._forceEmissiveMode)return;let t=this.style.hasDataDrivenEmissiveStrength();this.emissiveMode=t?this.context.extBlendFuncExtended?"dual-source-blending":"mrt-fallback":"constant"}}function Zc(a,t){let o=!1,c=null,d=()=>{c=null,o&&(a(),c=setTimeout(d,t),o=!1)};return()=>(o=!0,c||d(),c)}let zo=/(#.+)?$/;class ch{constructor(t){this._hashName=t&&encodeURIComponent(t),h.b0(["_getCurrentHash","_onHashChange","_updateHash"],this),this._updateHash=Zc(this._updateHashUnthrottled.bind(this),300)}addTo(t){return this._map=t,window.addEventListener("hashchange",this._onHashChange,!1),t.on("moveend",this._updateHash),this}remove(){return this._map?(this._map.off("moveend",this._updateHash),window.removeEventListener("hashchange",this._onHashChange,!1),clearTimeout(this._updateHash()),this._map=void 0,this):this}getHashString(){let t=this._map;if(!t)return"";let o=an(t);if(this._hashName){let c=this._hashName,d=!1,m=location.hash.slice(1).split("&").map(_=>{let y=_.split("=")[0];return y===c?(d=!0,`${y}=${o}`):_}).filter(_=>_);return d||m.push(`${c}=${o}`),`#${m.join("&")}`}return`#${o}`}_getCurrentHash(){let t=location.hash.replace("#","");if(this._hashName){let o;return t.split("&").map(c=>c.split("=")).forEach(c=>{c[0]===this._hashName&&(o=c)}),(o&&o[1]||"").split("/")}return t.split("/")}_onHashChange(){let t=this._map;if(!t)return!1;let o=this._getCurrentHash();if(o.length>=3&&!o.some(c=>isNaN(Number(c)))){let c=t.dragRotate.isEnabled()&&t.touchZoomRotate.isEnabled()?+(o[3]||0):t.getBearing();return t.jumpTo({center:[+o[2],+o[1]],zoom:+o[0],bearing:c,pitch:+(o[4]||0)}),!0}return!1}_updateHashUnthrottled(){history.replaceState(history.state,"",location.href.replace(zo,this.getHashString()))}}function an(a,t){let o=a.getCenter(),c=Math.round(100*a.getZoom())/100,d=Math.ceil((c*Math.LN2+Math.log(512/360/.5))/Math.LN10),m=Math.pow(10,d),_=Math.round(o.lng*m)/m,y=Math.round(o.lat*m)/m,v=a.getBearing(),T=a.getPitch(),I=t?`/${_}/${y}/${c}`:`${c}/${y}/${_}`;return(v||T)&&(I+="/"+Math.round(10*v)/10),T&&(I+=`/${Math.round(T)}`),I}let dr={linearity:.3,easing:h.eQ(0,0,.3,1)},Wc=Object.assign({deceleration:2500,maxSpeed:1400},dr),dg=Object.assign({deceleration:20,maxSpeed:1400},dr),ip=Object.assign({deceleration:1e3,maxSpeed:360},dr),mm=Object.assign({deceleration:1e3,maxSpeed:90},dr);class Xc{constructor(t){this._map=t,this.clear()}clear(){this._inertiaBuffer=[]}record(t){this._drainInertiaBuffer(),this._inertiaBuffer.push({time:h.o.now(),settings:t})}_drainInertiaBuffer(){let t=this._inertiaBuffer,o=h.o.now();for(;t.length>0&&o-t[0].time>160;)t.shift()}_onMoveEnd(t){if(this._map._prefersReducedMotion()||(this._drainInertiaBuffer(),this._inertiaBuffer.length<2))return;let o={zoom:0,bearing:0,pitch:0,pan:new h.P(0,0),pinchAround:void 0,around:void 0};for(let{settings:m}of this._inertiaBuffer)o.zoom+=m.zoomDelta||0,o.bearing+=m.bearingDelta||0,o.pitch+=m.pitchDelta||0,m.panDelta&&o.pan._add(m.panDelta),m.around&&(o.around=m.around),m.pinchAround&&(o.pinchAround=m.pinchAround);let c=this._inertiaBuffer.at(-1).time-this._inertiaBuffer[0].time,d={};if(o.pan.mag()){let m=kl(o.pan.mag(),c,Object.assign({},Wc,t||{}));d.offset=o.pan.mult(m.amount/o.pan.mag()),d.center=this._map.transform.center,Bl(d,m)}if(o.zoom){let m=kl(o.zoom,c,dg);d.zoom=this._map.transform.zoom+m.amount,Bl(d,m)}if(o.bearing){let m=kl(o.bearing,c,ip);
vendor: 17,585 bytes, line 3281
3281d.bearing=this._map.transform.bearing+h.aB(m.amount,-179,179),Bl(d,m)}if(o.pitch){let m=kl(o.pitch,c,mm);d.pitch=this._map.transform.pitch+m.amount,Bl(d,m)}if(d.zoom||d.bearing){let m=o.pinchAround===void 0?o.around:o.pinchAround;d.around=m?this._map.unproject(m):this._map.getCenter()}return this.clear(),d.noMoveStart=!0,d}}function Bl(a,t){(!a.duration||a.duration<t.duration)&&(a.duration=t.duration,a.easing=t.easing)}function kl(a,t,o){let{maxSpeed:c,linearity:d,deceleration:m}=o,_=h.aB(a*d/(t/1e3),-c,c),y=Math.abs(_)/(m*d);return{easing:o.easing,duration:1e3*y,amount:_*(y/2)}}class rr extends h.z{preventDefault(){this._defaultPrevented=!0}get defaultPrevented(){return this._defaultPrevented}constructor(t,o,c,d={}){let m=Go(o.getCanvasContainer(),c),_=o.unproject(m);super(t,Object.assign({point:m,lngLat:_,originalEvent:c},d)),this._defaultPrevented=!1,this.target=o}}class Na extends h.z{preventDefault(){this._defaultPrevented=!0}get defaultPrevented(){return this._defaultPrevented}constructor(t,o,c){let d=t==="touchend"?c.changedTouches:c.touches,m=ta(o.getCanvasContainer(),d),_=m.map(v=>o.unproject(v)),y=m.reduce((v,T,I,P)=>v.add(T.div(P.length)),new h.P(0,0));super(t,{points:m,point:y,lngLats:_,lngLat:o.unproject(y),originalEvent:c}),this._defaultPrevented=!1}}class Yc extends h.z{preventDefault(){this._defaultPrevented=!0}get defaultPrevented(){return this._defaultPrevented}constructor(t,o){super("wheel",{originalEvent:o}),this._defaultPrevented=!1}}class ts{constructor(t,o){this._map=t,this._clickTolerance=o.clickTolerance}reset(){this._mousedownPos=void 0}wheel(t){return this._firePreventable(new Yc(this._map,t))}mousedown(t,o){return this._mousedownPos=o,this._firePreventable(new rr(t.type,this._map,t))}mouseup(t){this._map.fire(new rr(t.type,this._map,t))}preclick(t){let o=new MouseEvent("preclick",t);this._map.fire(new rr(o.type,this._map,o))}click(t,o){this._mousedownPos&&this._mousedownPos.dist(o)>=this._clickTolerance||(this.preclick(t),this._map.fire(new rr(t.type,this._map,t)))}dblclick(t){return this._firePreventable(new rr(t.type,this._map,t))}mouseover(t){this._map.fire(new rr(t.type,this._map,t))}mouseout(t){this._map.fire(new rr(t.type,this._map,t))}touchstart(t){return this._firePreventable(new Na(t.type,this._map,t))}touchmove(t){this._map.fire(new Na(t.type,this._map,t))}touchend(t){this._map.fire(new Na(t.type,this._map,t))}touchcancel(t){this._map.fire(new Na(t.type,this._map,t))}_firePreventable(t){if(this._map.fire(t),t.defaultPrevented)return{}}isEnabled(){return!0}isActive(){return!1}enable(){}disable(){}}class Lo{constructor(t){this._map=t}reset(){this._delayContextMenu=!1,this._contextMenuEvent=void 0}mousemove(t){this._map.fire(new rr(t.type,this._map,t))}mousedown(){this._delayContextMenu=!0}mouseup(){this._delayContextMenu=!1,this._contextMenuEvent&&(this._map.fire(new rr("contextmenu",this._map,this._contextMenuEvent)),delete this._contextMenuEvent)}contextmenu(t){this._delayContextMenu?this._contextMenuEvent=t:this._map.fire(new rr(t.type,this._map,t)),this._map.listens("contextmenu")&&t.preventDefault()}isEnabled(){return!0}isActive(){return!1}enable(){}disable(){}}class Oo{constructor(t,o){this._map=t,this._el=t.getCanvasContainer(),this._container=t.getContainer(),this._clickTolerance=o.clickTolerance||1}isEnabled(){return!!this._enabled}isActive(){return!!this._active}enable(){this.isEnabled()||(this._enabled=!0)}disable(){this.isEnabled()&&(this._enabled=!1)}mousedown(t,o){this.isEnabled()&&t.shiftKey&&t.button===0&&(Vo(),this._startPos=this._lastPos=o,this._active=!0)}mousemoveWindow(t,o){if(!this._active)return;let c=o,d=this._startPos,m=this._lastPos;if(!d||!m||m.equals(c)||!this._box&&c.dist(d)<this._clickTolerance)return;this._lastPos=c,this._box||(this._box=Rt("div","mapboxgl-boxzoom",this._container),this._container.classList.add("mapboxgl-crosshair"),this._fireEvent("boxzoomstart",t));let _=Math.min(d.x,c.x),y=Math.max(d.x,c.x),v=Math.min(d.y,c.y),T=Math.max(d.y,c.y);this._map._requestDomTask(()=>{this._box&&(this._box.style.transform=`translate(${_}px,${v}px)`,this._box.style.width=y-_+"px",this._box.style.height=T-v+"px")})}mouseupWindow(t,o){if(!this._active)return;let c=this._startPos,d=o;if(c&&t.button===0){if(this.reset(),ms(),c.x!==d.x||c.y!==d.y)return this._map.fire(new h.z("boxzoomend",{originalEvent:t})),{cameraAnimation:m=>m.fitScreenCoordinates(c,d,this._map.getBearing(),{linear:!1})};this._fireEvent("boxzoomcancel",t)}}keydown(t){this._active&&t.keyCode===27&&(this.reset(),this._fireEvent("boxzoomcancel",t))}blur(){this.reset()}reset(){this._active=!1,this._container.classList.remove("mapboxgl-crosshair"),this._box&&(this._box.remove(),this._box=null),jo(),delete this._startPos,delete this._lastPos}_fireEvent(t,o){return this._map.fire(new h.z(t,{originalEvent:o}))}}function is(a,t){let o={};for(let c=0;c<a.length;c++)o[a[c].identifier]=t[c];return o}class bo{constructor(t){this.reset(),this.numTouches=t.numTouches}reset(){this.centroid=void 0,this.startTime=0,this.touches={},this.aborted=!1}touchstart(t,o,c){(this.centroid||c.length>this.numTouches)&&(this.aborted=!0),this.aborted||(this.startTime===0&&(this.startTime=t.timeStamp),c.length===this.numTouches&&(this.centroid=function(d){let m=new h.P(0,0);for(let _ of d)m._add(_);return m.div(d.length)}(o),this.touches=is(c,o)))}touchmove(t,o,c){if(this.aborted||!this.centroid)return;let d=is(c,o);for(let m in this.touches){let _=d[m];(!_||_.dist(this.touches[m])>30)&&(this.aborted=!0)}}touchend(t,o,c){if((!this.centroid||t.timeStamp-this.startTime>500)&&(this.aborted=!0),c.length===0){let d=!this.aborted&&this.centroid;if(this.reset(),d)return d}}}class np{constructor(t){this.singleTap=new bo(t),this.numTaps=t.numTaps,this.reset()}reset(){this.lastTime=1/0,this.lastTap=void 0,this.count=0,this.singleTap.reset()}touchstart(t,o,c){this.singleTap.touchstart(t,o,c)}touchmove(t,o,c){this.singleTap.touchmove(t,o,c)}touchend(t,o,c){let d=this.singleTap.touchend(t,o,c);if(d){let m=t.timeStamp-this.lastTime<500,_=!this.lastTap||this.lastTap.dist(d)<30;if(m&&_||this.reset(),this.count++,this.lastTime=t.timeStamp,this.lastTap=d,this.count===this.numTaps)return this.reset(),d}}}class pg{constructor(){this._zoomIn=new np({numTouches:1,numTaps:2}),this._zoomOut=new np({numTouches:2,numTaps:1}),this.reset()}reset(){this._active=!1,this._zoomIn.reset(),this._zoomOut.reset()}touchstart(t,o,c){this._zoomIn.touchstart(t,o,c),this._zoomOut.touchstart(t,o,c)}touchmove(t,o,c){this._zoomIn.touchmove(t,o,c),this._zoomOut.touchmove(t,o,c)}touchend(t,o,c){let d=this._zoomIn.touchend(t,o,c),m=this._zoomOut.touchend(t,o,c);return d?(this._active=!0,t.preventDefault(),setTimeout(()=>this.reset(),0),{cameraAnimation:_=>_.easeTo({duration:300,zoom:_.getZoom()+1,around:_.unproject(d)},{originalEvent:t})}):m?(this._active=!0,t.preventDefault(),setTimeout(()=>this.reset(),0),{cameraAnimation:_=>_.easeTo({duration:300,zoom:_.getZoom()-1,around:_.unproject(m)},{originalEvent:t})}):void 0}touchcancel(){this.reset()}enable(){this._enabled=!0}disable(){this._enabled=!1,this.reset()}isEnabled(){return this._enabled}isActive(){return this._active}}let fg=0,mg=2,_m={[fg]:1,[mg]:2},Jn={Control:"ctrlKey",Alt:"altKey",Shift:"shiftKey",Meta:"metaKey"};class Gs{constructor(t){this.reset(),this._clickTolerance=t.clickTolerance||1}blur(){this.reset()}reset(){this._active=!1,this._moved=!1,this._lastPoint=void 0,this._eventButton=void 0}_correctButton(t,o){return!1}_move(t,o){return{}}mousedown(t,o){if(this._lastPoint)return;let c=Ql(t);this._correctButton(t,c)&&(this._lastPoint=o,this._eventButton=c)}mousemoveWindow(t,o){let c=this._lastPoint;if(c){if(t.preventDefault(),this._eventButton!=null&&function(d,m){let _=_m[m];return d.buttons===void 0||(d.buttons&_)!==_}(t,this._eventButton))this.reset();else if(this._moved||!(o.dist(c)<this._clickTolerance))return this._moved=!0,this._lastPoint=o,this._move(c,o)}}mouseupWindow(t){this._lastPoint&&Ql(t)===this._eventButton&&(this._moved&&ms(),this.reset())}enable(){this._enabled=!0}disable(){this._enabled=!1,this.reset()}isEnabled(){return this._enabled}isActive(){return this._active}}class rp extends Gs{mousedown(t,o){super.mousedown(t,o),this._lastPoint&&(this._active=!0)}_correctButton(t,o){return o===0&&!t.ctrlKey}_move(t,o){return{around:o,panDelta:o.sub(t)}}}class Nr extends Gs{constructor(t){super(t),this._pitchRotateKey=t.pitchRotateKey?Jn[t.pitchRotateKey]:void 0}_correctButton(t,o){return this._pitchRotateKey?o===0&&t[this._pitchRotateKey]:o===0&&t.ctrlKey||o===2}_move(t,o){let c=.8*(o.x-t.x);if(c)return this._active=!0,{bearingDelta:c}}contextmenu(t){this._pitchRotateKey||t.preventDefault()}}class Ur extends Gs{constructor(t){super(t),this._pitchRotateKey=t.pitchRotateKey?Jn[t.pitchRotateKey]:void 0}_correctButton(t,o){return this._pitchRotateKey?o===0&&t[this._pitchRotateKey]:o===0&&t.ctrlKey||o===2}_move(t,o){let c=-.5*(o.y-t.y);if(c)return this._active=!0,{pitchDelta:c}}contextmenu(t){this._pitchRotateKey||t.preventDefault()}}class Nl{constructor(t,o){this._map=t,this._el=t.getCanvasContainer(),this._minTouches=1,this._clickTolerance=o.clickTolerance||1,this.reset(),h.b0(["_addTouchPanBlocker","_showTouchPanBlockerAlert"],this)}reset(){this._active=!1,this._touches={},this._sum=new h.P(0,0)}touchstart(t,o,c){return this._calculateTransform(t,o,c)}touchmove(t,o,c){if(this._active&&!(c.length<this._minTouches)){if(this._map._cooperativeGestures&&!this._map.isMoving()){if(c.length===1&&!h.eR())return void this._showTouchPanBlockerAlert();this._alertContainer.style.visibility!=="hidden"&&(this._alertContainer.style.visibility="hidden",clearTimeout(this._alertTimer))}return t.cancelable&&t.preventDefault(),this._calculateTransform(t,o,c)}}touchend(t,o,c){this._calculateTransform(t,o,c),this._active&&c.length<this._minTouches&&this.reset()}touchcancel(){this.reset()}_calculateTransform(t,o,c){c.length>0&&(this._active=!0);let d=is(c,o),m=new h.P(0,0),_=new h.P(0,0),y=0;for(let T in d){let I=d[T],P=this._touches[T];P&&(m._add(I),_._add(I.sub(P)),y++,d[T]=I)}if(this._touches=d,y<this._minTouches||!_.mag())return;let v=_.div(y);return this._sum._add(v),this._sum.mag()<this._clickTolerance?void 0:{around:m.div(y),panDelta:v}}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=Rt("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 ns{constructor(){this.reset()}reset(){this._active=!1,this._firstTwoTouches=void 0}_start(t){}_move(t,o,c){return{}}touchstart(t,o,c){this._firstTwoTouches||c.length<2||(this._firstTwoTouches=[c[0].identifier,c[1].identifier],this._start([o[0],o[1]]))}touchmove(t,o,c){let d=this._firstTwoTouches;if(!d)return;t.preventDefault();let[m,_]=d,y=rs(c,o,m),v=rs(c,o,_);if(!y||!v)return;let T=this._aroundCenter?null:y.add(v).div(2);return this._move([y,v],T,t)}touchend(t,o,c){if(!this._firstTwoTouches)return;let[d,m]=this._firstTwoTouches,_=rs(c,o,d),y=rs(c,o,m);_&&y||(this._active&&ms(),this.reset())}touchcancel(){this.reset()}enable(t){this._enabled=!0,this._aroundCenter=!!t&&t.around==="center"}disable(){this._enabled=!1,this.reset()}isEnabled(){return this._enabled}isActive(){return this._active}}function rs(a,t,o){for(let c=0;c<a.length;c++)if(a[c].identifier===o)return t[c]}function uh(a,t){return Math.log2(a/t)}class Yt extends ns{reset(){super.reset(),this._distance=0,this._startDistance=0}_start(t){this._startDistance=this._distance=t[0].dist(t[1])}_move(t,o){let c=this._distance;if(this._distance=t[0].dist(t[1]),this._active||!(Math.abs(uh(this._distance,this._startDistance))<.1))return this._active=!0,{zoomDelta:uh(this._distance,c),pinchAround:o}}}function os(a,t){return 180*a.angleWith(t)/Math.PI}class op extends ns{reset(){super.reset(),this._minDiameter=0,this._startVector=void 0,this._vector=void 0}_start(t){this._startVector=this._vector=t[0].sub(t[1]),this._minDiameter=t[0].dist(t[1])}_move(t,o){let c=this._vector;if(this._vector=t[0].sub(t[1]),c&&(this._active||!this._isBelowThreshold(this._vector)))return this._active=!0,{bearingDelta:os(this._vector,c),pinchAround:o}}_isBelowThreshold(t){this._minDiameter=Math.min(this._minDiameter,t.mag());let o=25/(Math.PI*this._minDiameter)*360,c=this._startVector;if(!c)return!1;let d=os(t,c);return Math.abs(d)<o}}function wo(a){return Math.abs(a.y)>Math.abs(a.x)}class Fo extends ns{constructor(t){super(),this._map=t}reset(){super.reset(),this._valid=void 0,this._firstMove=void 0,this._lastPoints=void 0}_start(t){this._lastPoints=t,wo(t[0].sub(t[1]))&&(this._valid=!1)}_move(t,o,c){let d=this._lastPoints;if(!d)return;let m=t[0].sub(d[0]),_=t[1].sub(d[1]);return this._map._cooperativeGestures&&!h.eR()&&c.touches.length<3||(this._valid=this.gestureBeginsVertically(m,_,c.timeStamp),!this._valid)?void 0:(this._lastPoints=t,this._active=!0,{pitchDelta:(m.y+_.y)/2*-.5})}gestureBeginsVertically(t,o,c){if(this._valid!==void 0)return this._valid;let d=t.mag()>=2,m=o.mag()>=2;if(!d&&!m)return;if(!d||!m)return this._firstMove==null&&(this._firstMove=c),c-this._firstMove<100&&void 0;let _=t.y>0==o.y>0;return wo(t)&&wo(o)&&_}}let or={panStep:100,bearingStep:15,pitchStep:10};class Ir{constructor(){let t=or;this._panStep=t.panStep,this._bearingStep=t.bearingStep,this._pitchStep=t.pitchStep,this._rotationDisabled=!1}blur(){this.reset()}reset(){this._active=!1}keydown(t){if(t.altKey||t.ctrlKey||t.metaKey)return;let o=0,c=0,d=0,m=0,_=0;switch(t.keyCode){case 61:case 107:case 171:case 187:o=1;break;case 189:case 109:case 173:o=-1;break;case 37:t.shiftKey?c=-1:(t.preventDefault(),m=-1);break;case 39:t.shiftKey?c=1:(t.preventDefault(),m=1);break;case 38:t.shiftKey?d=1:(t.preventDefault(),_=-1);break;case 40:t.shiftKey?d=-1:(t.preventDefault(),_=1);break;default:return}return this._rotationDisabled&&(c=0,d=0),{cameraAnimation:y=>{let v=y.getZoom();y.easeTo({duration:300,easeId:"keyboardHandler",easing:Ln,zoom:o?Math.round(v)+o*(t.shiftKey?2:1):v,bearing:y.getBearing()+c*this._bearingStep,pitch:y.getPitch()+d*this._pitchStep,offset:[-m*this._panStep,-_*this._panStep],center:y.getCenter()},{originalEvent:t})}}}enable(){this._enabled=!0}disable(){this._enabled=!1,this.reset()}isEnabled(){return this._enabled}isActive(){return this._active}disableRotation(){this._rotationDisabled=!0}enableRotation(){this._rotationDisabled=!1}}function Ln(a){return a*(2-a)}let hh=4.000244140625,Er=1/450,gm=/(Mac|iPad)/i;class Ua{constructor(t,o){this._map=t,this._el=t.getCanvasContainer(),this._handler=o,this._delta=0,this._lastDelta=0,this._defaultZoomRate=.01,this._wheelZoomRate=Er,h.b0(["_onTimeout","_addScrollZoomBlocker","_showBlockerAlert"],this)}setZoomRate(t){this._defaultZoomRate=t}setWheelZoomRate(t){this._wheelZoomRate=t}isEnabled(){return!!this._enabled}isActive(){return this._active||this._finishTimeout!==void 0}isZooming(){return!!this._zooming}enable(t){this.isEnabled()||(this._enabled=!0,this._aroundCenter=!!t&&t.around==="center",this._map._cooperativeGestures&&this._addScrollZoomBlocker())}disable(){this.isEnabled()&&(this._enabled=!1,this._map._cooperativeGestures&&(clearTimeout(this._alertTimer),this._alertContainer.remove()))}wheel(t){if(!this.isEnabled())return;if(this._map._cooperativeGestures){if(!(t.ctrlKey||t.metaKey||this.isZooming()||h.eR()))return void this._showBlockerAlert();this._alertContainer.style.visibility!=="hidden"&&(this._alertContainer.style.visibility="hidden",clearTimeout(this._alertTimer))}let o=t.deltaMode===WheelEvent.DOM_DELTA_LINE?40*t.deltaY:t.deltaY,c=h.o.now(),d=c-(this._lastWheelEventTime||0);this._lastWheelEventTime=c,o!==0&&o%hh===0?this._type="wheel":o!==0&&Math.abs(o)<4?this._type="trackpad":d>400?(this._type=null,this._lastValue=o,this._timeout=window.setTimeout(this._onTimeout,40,t)):this._type||(this._type=Math.abs(d*o)<200?"trackpad":"wheel",this._timeout&&(clearTimeout(this._timeout),this._timeout=null,o+=this._lastValue)),t.shiftKey&&o&&(o/=4),this._type&&(this._lastWheelEvent=t,this._delta-=o,this._active||this._start(t)),t.preventDefault()}_onTimeout(t){this._type="wheel",this._delta-=this._lastValue,this._active||this._start(t)}_start(t){if(!this._delta)return;this._frameId&&(this._frameId=null),this._active=!0,this.isZooming()||(this._zooming=!0),this._finishTimeout&&(clearTimeout(this._finishTimeout),delete this._finishTimeout);let o=Go(this._el,t);this._aroundPoint=this._aroundCenter?this._map.transform.centerPoint:o,this._aroundCoord=this._map.transform.pointCoordinate3D(this._aroundPoint),this._targetZoom=void 0,this._frameId||(this._frameId=!0,this._handler._triggerRe
3281nderFrame())}renderFrame(){if(!this._frameId||(this._frameId=null,!this.isActive()))return;let t=this._map.transform;this._type==="wheel"&&t.projection.wrap&&(t._center.lng>=180||t._center.lng<=-180)&&(this._prevEase=null,this._easing=null,this._lastWheelEvent=null,this._lastWheelEventTime=0);let o=()=>t._terrainEnabled()&&this._aroundCoord?t.computeZoomRelativeTo(this._aroundCoord):t.zoom;if(this._delta!==0){let T=this._type==="wheel"&&Math.abs(this._delta)>hh?this._wheelZoomRate:this._defaultZoomRate,I=2/(1+Math.exp(-Math.abs(this._delta*T)));this._delta<0&&I!==0&&(I=1/I);let P=o(),A=Math.pow(2,P),D=typeof this._targetZoom=="number"?t.zoomScale(this._targetZoom):A;this._targetZoom=Math.min(t.maxZoom,Math.max(t.minZoom,t.scaleZoom(D*I))),this._type==="wheel"&&(this._startZoom=P,this._easing=this._smoothOutEasing(200)),this._lastDelta=this._delta,this._delta=0}let c=typeof this._targetZoom=="number"?this._targetZoom:o(),d=this._startZoom,m=this._easing,_,y=!1;if(this._type==="wheel"&&d&&m){let T=Math.min((h.o.now()-this._lastWheelEventTime)/200,1),I=m(T);_=h.aj(d,c,I),T<1?this._frameId||(this._frameId=!0):y=!0}else _=c,y=!0;this._active=!0,y&&(this._active=!1,this._finishTimeout=window.setTimeout(()=>{this._zooming=!1,this._handler._triggerRenderFrame(),delete this._targetZoom,delete this._finishTimeout},200));let v=_-o();return v*this._lastDelta<0&&(v=0),{noInertia:!0,needsRenderFrame:!y,zoomDelta:v,around:this._aroundPoint,aroundCoord:this._aroundCoord,originalEvent:this._lastWheelEvent}}_smoothOutEasing(t){let o=h.eS;if(this._prevEase){let c=this._prevEase,d=(h.o.now()-c.start)/c.duration,m=c.easing(d+.01)-c.easing(d),_=.27/Math.sqrt(m*m+1e-4)*.01,y=Math.sqrt(.0729-_*_);o=h.eQ(_,y,.25,1)}return this._prevEase={start:h.o.now(),duration:t,easing:o},o}blur(){this.reset()}reset(){this._active=!1}_addScrollZoomBlocker(){this._map&&!this._alertContainer&&(this._alertContainer=Rt("div","mapboxgl-scroll-zoom-blocker",this._map._container),this._alertContainer.textContent=gm.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 ym{constructor(t,o){this._clickZoom=t,this._tapZoom=o}enable(){this._clickZoom.enable(),this._tapZoom.enable()}disable(){this._clickZoom.disable(),this._tapZoom.disable()}isEnabled(){return this._clickZoom.isEnabled()&&this._tapZoom.isEnabled()}isActive(){return this._clickZoom.isActive()||this._tapZoom.isActive()}}class Vr{constructor(){this.reset()}reset(){this._active=!1}blur(){this.reset()}dblclick(t,o){return t.preventDefault(),{cameraAnimation:c=>{c.easeTo({duration:300,zoom:c.getZoom()+(t.shiftKey?-1:1),around:c.unproject(o)},{originalEvent:t})}}}enable(){this._enabled=!0}disable(){this._enabled=!1,this.reset()}isEnabled(){return this._enabled}isActive(){return this._active}}class qn{constructor(){this._tap=new np({numTouches:1,numTaps:1}),this.reset()}reset(){this._active=!1,this._swipePoint=void 0,this._swipeTouch=0,this._tapTime=0,this._tap.reset()}touchstart(t,o,c){this._swipePoint||(this._tapTime&&t.timeStamp-this._tapTime>500&&this.reset(),this._tapTime?c.length>0&&(this._swipePoint=o[0],this._swipeTouch=c[0].identifier):this._tap.touchstart(t,o,c))}touchmove(t,o,c){if(this._tapTime){if(this._swipePoint){if(c[0].identifier!==this._swipeTouch)return;let d=o[0],m=d.y-this._swipePoint.y;return this._swipePoint=d,t.preventDefault(),this._active=!0,{zoomDelta:m/128}}}else this._tap.touchmove(t,o,c)}touchend(t,o,c){this._tapTime?this._swipePoint&&c.length===0&&this.reset():this._tap.touchend(t,o,c)&&(this._tapTime=t.timeStamp)}touchcancel(){this.reset()}enable(){this._enabled=!0}disable(){this._enabled=!1,this.reset()}isEnabled(){return this._enabled}isActive(){return this._active}}class sp{constructor(t,o,c){this._el=t,this._mousePan=o,this._touchPan=c}enable(t){this._inertiaOptions=t||{},this._mousePan.enable(),this._touchPan.enable(),this._el.classList.add("mapboxgl-touch-drag-pan")}disable(){this._mousePan.disable(),this._touchPan.disable(),this._el.classList.remove("mapboxgl-touch-drag-pan")}isEnabled(){return this._mousePan.isEnabled()&&this._touchPan.isEnabled()}isActive(){return this._mousePan.isActive()||this._touchPan.isActive()}}class xm{constructor(t,o,c){this._pitchWithRotate=t.pitchWithRotate,this._mouseRotate=o,this._mousePitch=c}enable(){this._mouseRotate.enable(),this._pitchWithRotate&&this._mousePitch.enable()}disable(){this._mouseRotate.disable(),this._mousePitch.disable()}isEnabled(){return this._mouseRotate.isEnabled()&&(!this._pitchWithRotate||this._mousePitch.isEnabled())}isActive(){return this._mouseRotate.isActive()||this._mousePitch.isActive()}}class ap{constructor(t,o,c,d){this._el=t,this._touchZoom=o,this._touchRotate=c,this._tapDragZoom=d,this._rotationDisabled=!1,this._enabled=!0}enable(t){this._touchZoom.enable(t),this._rotationDisabled||this._touchRotate.enable(t),this._tapDragZoom.enable(),this._el.classList.add("mapboxgl-touch-zoom-rotate")}disable(){this._touchZoom.disable(),this._touchRotate.disable(),this._tapDragZoom.disable(),this._el.classList.remove("mapboxgl-touch-zoom-rotate")}isEnabled(){return this._touchZoom.isEnabled()&&(this._rotationDisabled||this._touchRotate.isEnabled())&&this._tapDragZoom.isEnabled()}isActive(){return this._touchZoom.isActive()||this._touchRotate.isActive()||this._tapDragZoom.isActive()}disableRotation(){this._rotationDisabled=!0,this._touchRotate.disable()}enableRotation(){this._rotationDisabled=!1,this._touchZoom.isEnabled()&&this._touchRotate.enable()}}let dh=a=>a.zoom||a.drag||a.pitch||a.rotate;class lp extends h.z{}class vm{constructor(){this.constants=[1,1,.01],this.radius=0}setup(t,o){let c=h.aw([],o,t);
3281this.radius=h.af(c[2]<0?h.eU([],c,this.constants):[c[0],c[1],0])}projectRay(t){h.eU(t,t,this.constants),h.ax(t,t),h.eV(t,t,this.constants);let o=h.bN([],t,this.radius);if(o[2]>0){let c=h.bN([],[0,0,1],h.bk(o,[0,0,1])),d=h.bN([],h.ax([],[o[0],o[1],0]),this.radius),m=h.cX([],o,h.bN([],h.aw([],h.cX([],d,c),o),2));o[0]=m[0],o[1]=m[1]}return o}}function ph(a){return a.panDelta&&a.panDelta.mag()||a.zoomDelta||a.bearingDelta||a.pitchDelta}class jr{constructor(t,o){this._map=t,this._el=this._map.getCanvasContainer(),this._handlers=[],this._handlersById={},this._changes=[],this._inertia=new Xc(t),this._bearingSnap=o.bearingSnap,this._previousActiveHandlers={},this._trackingEllipsoid=new vm,this._dragOrigin=null,this._eventsInProgress={},this._addDefaultHandlers(o),h.b0(["handleEvent","handleWindowEvent"],this);let c=this._el;this._listeners=[[c,"touchstart",{passive:!0}],[c,"touchmove",{passive:!1}],[c,"touchend",void 0],[c,"touchcancel",void 0],[c,"mousedown",void 0],[c,"mousemove",void 0],[c,"mouseup",void 0],[document,"mousemove",{capture:!0}],[document,"mouseup",void 0],[c,"mouseover",void 0],[c,"mouseout",void 0],[c,"dblclick",void 0],[c,"click",void 0],[c,"keydown",{capture:!1}],[c,"keyup",void 0],[c,"wheel",{passive:!1}],[c,"contextmenu",void 0],[window,"blur",void 0]];for(let[d,m,_]of this._listeners){let y=d===document?this.handleWindowEvent:this.handleEvent;d.addEventListener(m,y,_)}}destroy(){for(let[t,o,c]of this._listeners){let d=t===document?this.handleWindowEvent:this.handleEvent;t.removeEventListener(o,d,c)}}_addDefaultHandlers(t){let o=this._map,c=o.getCanvasContainer();this._add("mapEvent",new ts(o,t));let d=o.boxZoom=new Oo(o,t);this._add("boxZoom",d);let m=new pg,_=new Vr;o.doubleClickZoom=new ym(_,m),this._add("tapZoom",m),this._add("clickZoom",_);let y=new qn;this._add("tapDragZoom",y);let v=o.touchPitch=new Fo(o);this._add("touchPitch",v);let T=new Nr(t),I=new Ur(t);o.dragRotate=new xm(t,T,I),this._add("mouseRotate",T,["mousePitch"]),this._add("mousePitch",I,["mouseRotate"]);let P=new rp(t),A=new Nl(o,t);o.dragPan=new sp(c,P,A),this._add("mousePan",P),this._add("touchPan",A,["touchZoom","touchRotate"]);let D=new op,L=new Yt;o.touchZoomRotate=new ap(c,L,D,y),this._add("touchRotate",D,["touchPan","touchZoom"]),this._add("touchZoom",L,["touchPan","touchRotate"]),this._add("blockableMapEvent",new Lo(o));let O=o.scrollZoom=new Ua(o,this);this._add("scrollZoom",O,["mousePan"]);let k=o.keyboard=new Ir;this._add("keyboard",k);for(let N of["boxZoom","doubleClickZoom","tapDragZoom","touchPitch","dragRotate","dragPan","touchZoomRotate","scrollZoom","keyboard"])t.interactive&&t[N]&&o[N].enable(t[N])}_add(t,o,c){this._handlers.push({handlerName:t,handler:o,allowed:c}),this._handlersById[t]=o}stop(t){if(!this._updatingCamera){for(let{handler:o}of this._handlers)o.reset();this._inertia.clear(),this._fireEvents({},{},t),this._changes=[],this._originalZoom=void 0}}isActive(){for(let{handler:t}of this._handlers)if(t.isActive())return!0;return!1}isZooming(){return!!this._eventsInProgress.zoom||this._map.scrollZoom.isZooming()}isRotating(){return!!this._eventsInProgress.rotate}isMoving(){return!!dh(this._eventsInProgress)||this.isZooming()}_isDragging(){return!!this._eventsInProgress.drag}_blockedByActive(t,o,c){for(let d in t)if(!(d===c||o&&o.includes(d)))return!0;return!1}handleWindowEvent(t){this.handleEvent(t,`${t.type}Window`)}_getMapTouches(t){let o=[];for(let c of t)this._el.contains(c.target)&&o.push(c);return o}handleEvent(t,o){this._updatingCamera=!0;let c=t.type==="renderFrame",d=c?void 0:t,m={needsRenderFrame:!1},_={},y={},v=t.touches?this._getMapTouches(t.touches):void 0,T=v?ta(this._el,v):c?void 0:Go(this._el,t);for(let{handlerName:A,handler:D,allowed:L}of this._handlers){if(!D.isEnabled())continue;let O;this._blockedByActive(y,L,A)?D.reset():D[o||t.type]&&(O=D[o||t.type](t,T,v),this.mergeHandlerResult(m,_,O,A,d),O&&O.needsRenderFrame&&this._triggerRenderFrame()),(O||D.isActive())&&(y[A]=D)}let I={};for(let A in this._previousActiveHandlers)y[A]||(I[A]=d);this._previousActiveHandlers=y,(Object.keys(I).length||ph(m))&&(this._changes.push([m,_,I]),this._triggerRe
3281nderFrame()),(Object.keys(y).length||ph(m))&&this._map._stop(!0),this._updatingCamera=!1;let{cameraAnimation:P}=m;P&&(this._inertia.clear(),this._fireEvents({},{},!0),this._changes=[],P(this._map))}mergeHandlerResult(t,o,c,d,m){if(!c)return;Object.assign(t,c);let _={handlerName:d,originalEvent:c.originalEvent||m};c.zoomDelta!==void 0&&(o.zoom=_),c.panDelta!==void 0&&(o.drag=_),c.pitchDelta!==void 0&&(o.pitch=_),c.bearingDelta!==void 0&&(o.rotate=_)}_applyChanges(){let t={},o={},c={};for(let[d,m,_]of this._changes)d.panDelta&&(t.panDelta=(t.panDelta||new h.P(0,0))._add(d.panDelta)),d.zoomDelta&&(t.zoomDelta=(t.zoomDelta||0)+d.zoomDelta),d.bearingDelta&&(t.bearingDelta=(t.bearingDelta||0)+d.bearingDelta),d.pitchDelta&&(t.pitchDelta=(t.pitchDelta||0)+d.pitchDelta),d.around!==void 0&&(t.around=d.around),d.aroundCoord!==void 0&&(t.aroundCoord=d.aroundCoord),d.pinchAround!==void 0&&(t.pinchAround=d.pinchAround),d.noInertia&&(t.noInertia=d.noInertia),Object.assign(o,m),Object.assign(c,_);this._updateMapTransform(t,o,c),this._changes=[]}_updateMapTransform(t,o,c){let d=this._map,m=d.transform,_=q=>[q.x,q.y,q.z];if((()=>{let q=this._eventsInProgress.drag;return q&&!this._handlersById[q.handlerName].isActive()})()&&!ph(t)){let q=m.zoom;m.cameraElevationReference="sea",this._originalZoom!=null&&m._orthographicProjectionAtLowPitch&&m.projection.name!=="globe"&&m.pitch===0?(m.cameraElevationReference="ground",m.zoom=this._originalZoom):(m.recenterOnTerrain(),m.cameraElevationReference="ground"),q!==m.zoom&&this._map._update(!0)}if(m._isCameraConstrained&&d._stop(!0),!ph(t))return void this._fireEvents(o,c,!0);let{panDelta:y,zoomDelta:v,bearingDelta:T,pitchDelta:I,around:P,aroundCoord:A,pinchAround:D}=t;m._isCameraConstrained&&(v>0&&(v=0),m._isCameraConstrained=!1),D!==void 0&&(P=D),(v||(q=>o[q]&&!this._eventsInProgress[q])("drag"))&&P&&(this._dragOrigin=_(m.pointCoordinate3D(P)),this._originalZoom=m.zoom,this._trackingEllipsoid.setup(m._camera.position,this._dragOrigin)),m.cameraElevationReference="sea",d._stop(!0),P=P||d.transform.centerPoint,T&&(m.bearing+=T),I&&(m.pitch+=I),m._updateCameraState();let L=[0,0,0];if(y)if(m.projection.name==="mercator"){let q=this._trackingEllipsoid.projectRay(m.screenPointToMercatorRay(P).dir),Z=this._trackingEllipsoid.projectRay(m.screenPointToMercatorRay(P.sub(y)).dir);L[0]=Z[0]-q[0],L[1]=Z[1]-q[1]}else{let q=m.pointCoordinate(P);if(m.projection.name==="globe"){y=y.rotate(-m.angle);let Z=m._pixelsPerMercatorPixel/m.worldSize;L[0]=-y.x*h.eT(h.bZ(q.y))*Z,L[1]=-y.y*h.eT(m.center.lat)*Z}else{let Z=m.pointCoordinate(P.sub(y));q&&Z&&(L[0]=Z.x-q.x,L[1]=Z.y-q.y)}}let O=m.zoom,k=[0,0,0];if(v){let q=_(A||m.pointCoordinate3D(P)),Z={dir:h.ax([],h.aw([],q,m._camera.position))};if(Z.dir[2]<0){let G=m.zoomDeltaToMovement(q,v);h.bN(k,Z.dir,G)}}let N=h.cX(L,L,k);m._translateCameraConstrained(N),v&&Math.abs(m.zoom-O)>1e-4&&m.recenterOnTerrain(),m.cameraElevationReference="ground",this._map._update(),t.noInertia||this._inertia.record(t),this._fireEvents(o,c,!0)}_fireEvents(t,o,c){let d=dh(this._eventsInProgress),m=dh(t),_={};for(let I in t){let{originalEvent:P}=t[I];this._eventsInProgress[I]||(_[`${I}start`]=P),this._eventsInProgress[I]=t[I]}!d&&m&&this._fireEvent("movestart",m.originalEvent);for(let I in _)this._fireEvent(I,_[I]);m&&this._fireEvent("move",m.originalEvent);for(let I in t){let{originalEvent:P}=t[I];this._fireEvent(I,P)}let y={},v;for(let I in this._eventsInProgress){let{handlerName:P,originalEvent:A}=this._eventsInProgress[I];this._handlersById[P].isActive()||(delete this._eventsInProgress[I],v=o[P]||A,y[`${I}end`]=v)}for(let I in y)this._fireEvent(I,y[I]);let T=dh(this._eventsInProgress);if(c&&(d||m)&&!T){this._updatingCamera=!0;let I=this._inertia._onMoveEnd(this._map.dragPan._inertiaOptions),P=A=>A!==0&&-this._bearingSnap<A&&A<this._bearingSnap;I?(P(I.bearing||this._map.getBearing())&&(I.bearing=0),this._map.easeTo(I,{originalEvent:v})):(this._map.fire(new h.z("moveend",{originalEvent:v})),P(this._map.getBearing())&&this._map.resetNorth()),this._updatingCamera=!1}}_fireEvent(t,o){this._map.fire(new h.z(t,o?{originalEvent:o}:{}))}_requestFrame(){return this._map.triggerRepaint(),this._map._renderTaskQueue.add(t=>{this._frameId=void 0,this.handleEvent(new lp("renderFrame",{timeStamp:t})),this._applyChanges()})}
3281_triggerRenderFrame(){this._frameId===void 0&&(this._frameId=this._requestFrame())}}let Gr="map.setFreeCameraOptions(...) and map.getFreeCameraOptions() are not yet supported for non-mercator projections.";class $s extends h.E{constructor(t,o){super(),this._moving=!1,this._zooming=!1,this.transform=t,this._bearingSnap=o.bearingSnap,this._respectPrefersReducedMotion=o.respectPrefersReducedMotion!==!1,h.b0(["_renderFrameCallback"],this)}getCenter(){return new h.aX(this.transform.center.lng,this.transform.center.lat)}setCenter(t,o){return this.jumpTo({center:t},o)}panBy(t,o,c){return t=h.P.convert(t).mult(-1),this.panTo(this.transform.center,Object.assign({offset:t},o),c)}panTo(t,o,c){return this.easeTo(Object.assign({center:t},o),c)}getZoom(){return this.transform.zoom}setZoom(t,o){return this.jumpTo({zoom:t},o),this}zoomTo(t,o,c){return this.easeTo(Object.assign({zoom:t},o),c)}zoomIn(t,o){return this.zoomTo(this.getZoom()+1,t,o),this}zoomOut(t,o){return this.zoomTo(this.getZoom()-1,t,o),this}getBearing(){return this.transform.bearing}setBearing(t,o){return this.jumpTo({bearing:t},o),this}getPadding(){return this.transform.padding}setPadding(t,o){return this.jumpTo({padding:t},o),this}rotateTo(t,o,c){return this.easeTo(Object.assign({bearing:t},o),c)}resetNorth(t,o){return this.rotateTo(0,Object.assign({duration:1e3},t),o),this}resetNorthPitch(t,o){return this.easeTo(Object.assign({bearing:0,pitch:0,duration:1e3},t),o),this}snapToNorth(t,o){return Math.abs(this.getBearing())<this._bearingSnap?this.resetNorth(t,o):this}getPitch(){return this.transform.pitch}setPitch(t,o){return this.jumpTo({pitch:t},o),this}cameraForBounds(t,o){t=h.aI.convert(t);let c=o&&o.bearing||0,d=o&&o.pitch||0,m=t.getNorthWest(),_=t.getSouthEast();return this._cameraForBounds(this.transform,m,_,c,d,o)}_extendPadding(t){let o={top:0,right:0,bottom:0,left:0};return t==null?Object.assign({},o,this.transform.padding):typeof t=="number"?{top:t,bottom:t,right:t,left:t}:Object.assign({},o,t)}_extendCameraOptions(t){return(t=Object.assign({offset:[0,0],maxZoom:this.transform.maxZoom},t)).padding=this._extendPadding(t.padding),t}_minimumAABBFrustumDistance(t,o){let c=o.max[0]-o.min[0],d=o.max[1]-o.min[1];return c/d>t.aspect?c/(2*Math.tan(.5*t.fovX)*t.aspect):d/(2*Math.tan(.5*t.fovY)*t.aspect)}_cameraForBoundsOnGlobe(t,o,c,d,m,_){let y=t.clone(),v=this._extendCameraOptions(_);y.bearing=d,y.pitch=m;let T=h.aX.convert(o),I=h.aX.convert(c),P=.5*(T.lat+I.lat),A=.5*(T.lng+I.lng),D=h.eW(P,A),L=h.ax([],D),O=h.ax([],h.bj([],L,[0,1,0])),k=h.bj([],O,L),N=[O[0],O[1],O[2],0,k[0],k[1],k[2],0,L[0],L[1],L[2],0,0,0,0,1],q=[D,h.eW(T.lat,T.lng),h.eW(I.lat,T.lng),h.eW(I.lat,I.lng),h.eW(T.lat,I.lng),h.eW(P,T.lng),h.eW(P,I.lng),h.eW(T.lat,A),h.eW(I.lat,A)],Z=h.cY.fromPoints(q.map(Ce=>[h.bk(O,Ce),h.bk(k,Ce),h.bk(L,Ce)])),G=h.ae([],Z.center,N);h.eX(G)===0&&h.eY(G,0,0,1),h.ax(G,G),h.bN(G,G,h.aE),y.center=h.eZ(G);let re=y.getWorldToCameraMatrix(),te=h.ba(new Float64Array(16),re);Z=h.cY.applyTransform(Z,h.aC([],re,N));let se=this._extendAABB(Z,y,v,d);if(!se)return void h.w("Map cannot fit within canvas with the given bounds, padding, and/or offset.");Z=se,h.ae(G,G,re);let K=.5*(Z.max[2]-Z.min[2]),J=this._minimumAABBFrustumDistance(y,Z),oe=h.bN([],[0,0,1],K),ue=h.cX(oe,G,oe),de=J+(y.pitch===0?0:h.bh(G,ue)),be=y.globeCenterInViewSpace,ve=h.aw([],G,[be[0],be[1],be[2]]);h.ax(ve,ve),h.bN(ve,ve,de);let Fe=h.cX([],G,ve);h.ae(Fe,Fe,te);let pe=h.eg/h.aE,Ie=h.af(Fe),fe=h.bY(Math.max(Ie*pe-h.eg,Number.EPSILON),0),Pe=Math.min(y.zoomFromMercatorZAdjusted(fe),v.maxZoom);return Pe>.5*(h.cN+h.cx)?(y.setProjection({name:"mercator"}),y.zoom=Pe,this._cameraForBounds(y,o,c,d,m,_)):{center:y.center,zoom:Pe,bearing:d,pitch:m}}_extendAABB(t,o,c,d){let m=.5*((c.padding.left||0)+(c.padding.right||0)),_=.5*((c.padding.top||0)+(c.padding.bottom||0)),y=_,v=m,T=m,I=_,P=o.width-(v+T),A=o.height-(y+I),D=h.aw([],t.max,t.min),L=Math.min(P/D[0],A/D[1]),O=Math.min(o.scaleZoom(o.scale*L),c.maxZoom);if(isNaN(O))return null;let k=o.scale/o.zoomScale(O),N=new h.cY([t.min[0]-v*k,t.min[1]-I*k,t.min[2]],[t.max[0]+T*k,t.max[1]+y*k,t.max[2]]),q=(typeof c.offset.x=="number"&&typeof c.offset.y=="number"?new h.P(c.offset.x,c.offset.y):h.P.convert(c.offset)).rotate(-h.am(d));return N.center[0]-=q.x*k,N.center[1]+=q.y*k,N}queryTerrainElevation(t,o){let c=this.transform.elevation;return c?(o=Object.assign({},{exaggerated:!0},o),c.getAtPoint(h.ad.fromLngLat(t),null,o.exaggerated)):null}_cameraForBounds(t,o,c,d,m,_){if(t.projection.name==="globe")return this._cameraForBoundsOnGlobe(t,o,c,d,m,_);let y=t.clone(),v=this._extendCameraOptions(_);y.bearing=d,y.pitch=m;let T=h.aX.convert(o),I=h.aX.convert(c),P=new h.aX(T.lng,I.lat),A=new h.aX(I.lng,T.lat),D=y.project(T),L=y.project(I),O=this.queryTerrainElevation(T),k=this.queryTerrainElevation(I),N=this.queryTerrainElevation(P),q=this.queryTerrainElevation(A),Z=[[D.x,D.y,Math.min(O||0,k||0,N||0,q||0)],[L.x,L.y,Math.max(O||0,k||0,N||0,q||0)]],G=h.cY.fromPoints(Z),re=y.getWorldToCameraMatrix(),te=h.ba(new Float64Array(16),re);G=h.cY.applyTransform(G,re);let se=this._extendAABB(G,y,v,d);if(!se)return void h.w("Map cannot fit within canvas with the given bounds, padding, and/or offset.");G=se;let K=.5*h.aw([],G.max,G.min)[2],J=this._minimumAABBFrustumDistance(y,G),oe=[0,0,1,0];h.aD(oe,oe,re),h.e_(oe,oe);let ue=h.bN([],oe,J+K),de=h.cX([],G.center,ue);h.ae(G.center,G.center,te),h.ae(de,de,te);let be=y.unproject(new h.P(G.center[0],G.center[1])),ve=h.e$(y.projection,be),Fe=Math.pow(2,ve),pe=M
3281ath.min(y._zoomFromMercatorZ(de[2]*y.pixelsPerMeter*Fe/y.worldSize),v.maxZoom);return y.mercatorFromTransition&&pe<.5*(h.cN+h.cx)?(y.setProjection({name:"globe"}),y.zoom=pe,this._cameraForBounds(y,o,c,d,m,_)):{center:be,zoom:pe,bearing:d,pitch:m}}fitBounds(t,o,c){let d=this.cameraForBounds(t,o);return this._fitInternal(d,o,c)}fitScreenCoordinates(t,o,c,d,m){let _=h.P.convert(t),y=h.P.convert(o),v=new h.P(Math.min(_.x,y.x),Math.min(_.y,y.y)),T=new h.P(Math.max(_.x,y.x),Math.max(_.y,y.y));if(this.transform.projection.name==="mercator"&&this.transform.anyCornerOffEdge(_,y))return this;let I=this.transform.pointLocation3D(v),P=this.transform.pointLocation3D(T),A=this.transform.pointLocation3D(new h.P(v.x,T.y)),D=this.transform.pointLocation3D(new h.P(T.x,v.y)),L=[Math.min(I.lng,P.lng,A.lng,D.lng),Math.min(I.lat,P.lat,A.lat,D.lat)],O=[Math.max(I.lng,P.lng,A.lng,D.lng),Math.max(I.lat,P.lat,A.lat,D.lat)],k=d&&d.pitch?d.pitch:this.getPitch(),N=this._cameraForBounds(this.transform,L,O,c,k,d);return this._fitInternal(N,d,m)}_fitInternal(t,o,c){return t?(o=Object.assign(t,o)).linear?this.easeTo(o,c):this.flyTo(o,c):this}jumpTo(t,o){this.stop();let c=t.preloadOnly?this.transform.clone():this.transform,d=!1,m=!1,_=!1;"zoom"in t&&c.zoom!==+t.zoom&&(d=!0,c.zoom=+t.zoom),t.center!==void 0&&(c.center=h.aX.convert(t.center)),"bearing"in t&&c.bearing!==+t.bearing&&(m=!0,c.bearing=+t.bearing),"pitch"in t&&c.pitch!==+t.pitch&&(_=!0,c.pitch=+t.pitch);let y=typeof t.padding=="number"?this._extendPadding(t.padding):t.padding;if(t.padding!=null&&!c.isPaddingEqual(y))if(t.retainPadding===!1){let v=c.clone();v.padding=y,c.setLocationAtPoint(c.center,v.centerPoint)}else c.padding=y;return t.preloadOnly?(this._preloadTiles(c),this):(this.fire(new h.z("movestart",o)).fire(new h.z("move",o)),d&&this.fire(new h.z("zoomstart",o)).fire(new h.z("zoom",o)).fire(new h.z("zoomend",o)),m&&this.fire(new h.z("rotatestart",o)).fire(new h.z("rotate",o)).fire(new h.z("rotateend",o)),_&&this.fire(new h.z("pitchstart",o)).fire(new h.z("pitch",o)).fire(new h.z("pitchend",o)),this.fire(new h.z("moveend",o)))}getFreeCameraOptions(){return this.transform.projection.supportsFreeCamera||h.w(Gr),this.transform.getFreeCameraOptions()}setFreeCameraOptions(t,o){let c=this.transform;if(!c.projection.supportsFreeCamera)return h.w(Gr),this;this.stop();let d=c.zoom,m=c.pitch,_=c.bearing;c.setFreeCameraOptions(t);let y=d!==c.zoom,v=m!==c.pitch,T=_!==c.bearing;return this.fire(new h.z("movestart",o)).fire(new h.z("move",o)),y&&this.fire(new h.z("zoomstart",o)).fire(new h.z("zoom",o)).fire(new h.z("zoomend",o)),T&&this.fire(new h.z("rotatestart",o)).fire(new h.z("rotate",o)).fire(new h.z("rotateend",o)),v&&this.fire(new h.z("pitchstart",o)).fire(new h.z("pitch",o)).fire(new h.z("pitchend",o)),this.fire(new h.z("moveend",o)),this}easeTo(t,o){this._stop(!1,t.easeId),((t=Object.assign({offset:[0,0],duration:500,easing:h.eS},t)).animate===!1||this._prefersReducedMotion(t))&&(t.duration=0);let c=this.transform,d=this.getZoom(),m=this.getBearing(),_=this.getPitch(),y=this.getPadding(),v="zoom"in t?+t.zoom:d,T="bearing"in t?this._normalizeBearing(t.bearing,m):m,I="pitch"in t?+t.pitch:_,P=this._extendPadding(t.padding),A=h.P.convert(t.offset),D,L,O;if(c.projection.name==="globe"){let oe=h.ad.fromLngLat(c.center),ue=A.rotate(-c.angle);oe.x+=ue.x/c.worldSize,oe.y+=ue.y/c.worldSize;let de=oe.toLngLat(),be=h.aX.convert(t.center||de);this._normalizeCenter(be),D=c.centerPoint.add(ue),L=new h.P(oe.x,oe.y).mult(c.worldSize),O=new h.P(h.aG(be.lng),h.aJ(be.lat)).mult(c.worldSize).sub(L)}else{D=c.centerPoint.add(A);let oe=c.pointLocation(D),ue=h.aX.convert(t.center||oe);this._normalizeCenter(ue),L=c.project(oe),O=c.project(ue).sub(L)}let k=c.zoomScale(v-d),N,q;t.around&&(N=h.aX.convert(t.around),q=c.locationPoint(N));let Z=this._zooming||v!==d,G=this._rotating||m!==T,re=this._pitching||I!==_,te=!c.isPaddingEqual(P),se=t.retainPadding===!1?c.clone():c,K=oe=>ue=>{if(Z&&(oe.zoom=h.aj(d,v,ue)),G&&(oe.bearing=h.aj(m,T,ue)),re&&(oe.pitch=h.aj(_,I,ue)),te&&(se.interpolatePadding(y,P,ue),D=se.centerPoint.add(A)),N)oe.setLocationAtPoint(N,q);else{let de=oe.zoomScale(oe.zoom-d),be=v>d?Math.min(2,k):Math.max(.5,k),ve=Math.pow(be,1-ue),Fe=oe.unproject(L.add(O.mult(ue*ve)).mult(de));oe.setLocationAtPoint(oe.renderWorldCopies?Fe.wrap():Fe,D)}return t.preloadOnly||this._fireMoveEvents(o),oe};if(t.preloadOnly){let oe=this._emulate(K,t.duration,c);return this._preloadTiles(oe),this}let J={moving:this._moving,zooming:this._zooming,rotating:this._rotating,pitching:this._pitching};return this._zooming=Z,this._rotating=G,this._pitching=re,this._padding=te,this._easeId=t.easeId,this._prepareEase(o,t.noMoveStart,J),this._ease(K(c),oe=>{c.cameraElevationReference==="sea"&&c.recenterOnTerrain(),this._afterEase(o,oe)},t),this}_prepareEase(t,o,c={}){this._moving=!0,this.transform.cameraElevationReference="sea",this.transform._orthographicProjectionAtLowPitch&&this.transform.pitch===0&&this.transform.projection.name!=="globe"&&(this.transform.cameraElevationReference="ground"),o||c.moving||this.fire(new h.z("movestart",t)),this._zooming&&!c.zooming&&this.fire(new h.z("zoomstart",t)),this._rotating&&!c.rotating&&this.fire(new h.z("rotatestart",t)),this._pitching&&!c.pitching&&this.fire(new h.z("pitchstart",t))}_fireMoveEvents(t){this.fire(new h.z("move",t)),this._zooming&&this.fire(new h.z("zoom",t)),this._rotating&&this.fire(new h.z("rotate",t)),this._pitching&&this.fire(new h.z("pitch",t))}
3281_afterEase(t,o){if(this._easeId&&o&&this._easeId===o)return;this._easeId=void 0,this.transform.cameraElevationReference="ground";let c=this._zooming,d=this._rotating,m=this._pitching;this._moving=!1,this._zooming=!1,this._rotating=!1,this._pitching=!1,this._padding=!1,c&&this.fire(new h.z("zoomend",t)),d&&this.fire(new h.z("rotateend",t)),m&&this.fire(new h.z("pitchend",t)),this.fire(new h.z("moveend",t))}flyTo(t,o){if(this._prefersReducedMotion(t)){let Ce=h.aK(t,["center","zoom","bearing","pitch","around","padding","retainPadding"]);return this.jumpTo(Ce,o)}this.stop(),t=Object.assign({offset:[0,0],speed:1.2,curve:1.42,easing:h.eS},t);let c=this.transform,d=this.getZoom(),m=this.getBearing(),_=this.getPitch(),y=this.getPadding(),v="zoom"in t?h.aB(+t.zoom,c.minZoom,c.maxZoom):d,T="bearing"in t?this._normalizeBearing(t.bearing,m):m,I="pitch"in t?+t.pitch:_,P=this._extendPadding(t.padding),A=c.zoomScale(v-d),D=h.P.convert(t.offset),L=c.centerPoint.add(D),O=c.pointLocation(L),k=h.aX.convert(t.center||O);this._normalizeCenter(k);let N=c.project(O),q=c.project(k).sub(N),Z=t.curve,G=Math.max(c.width,c.height),re=G/A,te=q.mag();if("minZoom"in t){let Ce=h.aB(Math.min(t.minZoom,d,v),c.minZoom,c.maxZoom),Re=G/c.zoomScale(Ce-d);Z=Math.sqrt(Re/te*2)}let se=Z*Z;function K(Ce){let Re=(re*re-G*G+(Ce?-1:1)*se*se*te*te)/(2*(Ce?re:G)*se*te);return Math.log(Math.sqrt(Re*Re+1)-Re)}function J(Ce){return(Math.exp(Ce)-Math.exp(-Ce))/2}function oe(Ce){return(Math.exp(Ce)+Math.exp(-Ce))/2}let ue=K(0),de=function(Ce){return oe(ue)/oe(ue+Z*Ce)},be=function(Ce){return G*((oe(ue)*(J(Re=ue+Z*Ce)/oe(Re))-J(ue))/se)/te;var Re},ve=(K(1)-ue)/Z;
3281if(Math.abs(te)<1e-6||!isFinite(ve)){if(Math.abs(G-re)<1e-6)return this.easeTo(t,o);let Ce=re<G?-1:1;ve=Math.abs(Math.log(re/G))/Z,be=function(){return 0},de=function(Re){return Math.exp(Ce*Z*Re)}}t.duration="duration"in t?+t.duration:1e3*ve/("screenSpeed"in t?+t.screenSpeed/Z:+t.speed),t.maxDuration&&t.duration>t.maxDuration&&(t.duration=0);let Fe=m!==T,pe=I!==_,Ie=!c.isPaddingEqual(P),fe=t.retainPadding===!1?c.clone():c,Pe=Ce=>Re=>{let Ye=Re*ve,$e=1/de(Ye);Ce.zoom=Re===1?v:d+Ce.scaleZoom($e),Fe&&(Ce.bearing=h.aj(m,T,Re)),pe&&(Ce.pitch=h.aj(_,I,Re)),Ie&&(fe.interpolatePadding(y,P,Re),L=fe.centerPoint.add(D));let je=Re===1?k:Ce.unproject(N.add(q.mult(be(Ye))).mult($e));return Ce.setLocationAtPoint(Ce.renderWorldCopies?je.wrap():je,L),Ce._updateCameraOnTerrain(),t.preloadOnly||this._fireMoveEvents(o),Ce};if(t.preloadOnly){let Ce=this._emulate(Pe,t.duration,c);return this._preloadTiles(Ce),this}return this._zooming=!0,this._rotating=Fe,this._pitching=pe,this._padding=Ie,this._prepareEase(o,!1),this._ease(Pe(c),()=>this._afterEase(o),t),this}isEasing(){return!!this._easeFrameId}stop(){return this._stop()}_requestRenderFrame(t){}_cancelRenderFrame(t){}_stop(t,o){if(this._easeFrameId&&(this._cancelRenderFrame(this._easeFrameId),this._easeFrameId=void 0,this._onEaseFrame=void 0),this._onEaseEnd){let c=this._onEaseEnd;this._onEaseEnd=void 0,c.call(this,o)}if(!t){let c=this.handlers;c&&c.stop(!1)}return this}_ease(t,o,c){c.animate===!1||c.duration===0?(t(1),o()):(this._easeStart=h.o.now(),this._easeOptions=c,this._onEaseFrame=t,this._onEaseEnd=o,this._easeFrameId=this._requestRenderFrame(this._renderFrameCallback))}_renderFrameCallback(){let t=Math.min((h.o.now()-this._easeStart)/this._easeOptions.duration,1),o=this._onEaseFrame;o&&o(this._easeOptions.easing(t)),t<1?this._easeFrameId=this._requestRenderFrame(this._renderFrameCallback):this.stop()}_normalizeBearing(t,o){t=h.bv(t,-180,180);let c=Math.abs(t-o);return Math.abs(t-360-o)<c&&(t-=360),Math.abs(t+360-o)<c&&(t+=360),t}_normalizeCenter(t){let o=this.transform;
3281if(o.maxBounds||o.projection.name!=="globe"&&!o.renderWorldCopies)return;let c=t.lng-o.center.lng;t.lng+=c>180?-360:c<-180?360:0}_prefersReducedMotion(t){return this._respectPrefersReducedMotion&&h.o.prefersReducedMotion&&!(t&&t.essential)}_emulate(t,o,c){let d=Math.ceil(15*o/1e3),m=[],_=t(c.clone());for(let y=0;y<=d;y++){let v=_(y/d);m.push(v.clone())}return m}_preloadTiles(t,o){}}let _g=/^(https?:|mailto:)/i;class bm{constructor(t={}){this.options=t,h.b0(["_toggleAttribution","_updateEditLink","_updateData","_updateCompact"],this)}getDefaultPosition(){return"bottom-right"}onAdd(t){let o=this.options&&this.options.compact,c=t._getUIString("AttributionControl.ToggleAttribution");this._map=t,this._container=Rt("div","mapboxgl-ctrl mapboxgl-ctrl-attrib"),this._compactButton=Rt("button","mapboxgl-ctrl-attrib-button",this._container),this._compactButton.type="button",this._compactButton.addEventListener("click",this._toggleAttribution),this._compactButton.setAttribute("aria-label",c);let d=Rt("span","mapboxgl-ctrl-icon",this._compactButton);return d.setAttribute("aria-hidden","true"),d.setAttribute("title",c),this._innerContainer=Rt("div","mapboxgl-ctrl-attrib-inner",this._container),o&&this._container.classList.add("mapboxgl-compact"),this._updateAttributions(),this._updateEditLink(),this._map.on("styledata",this._updateData),this._map.on("sourcedata",this._updateData),this._map.on("moveend",this._updateEditLink),o===void 0&&(this._map.on("resize",this._updateCompact),this._updateCompact()),this._container}onRemove(){this._container.remove(),this._map.off("styledata",this._updateData),this._map.off("sourcedata",this._updateData),this._map.off("moveend",this._updateEditLink),this._map.off("resize",this._updateCompact),this._map=void 0,this._attribHTML=void 0}_toggleAttribution(){this._container.classList.contains("mapboxgl-compact-show")?(this._container.classList.remove("mapboxgl-compact-show"),this._compactButton.setAttribute("aria-expanded","false")):(this._container.classList.add("mapboxgl-compact-show"),this._compactButton.setAttribute("aria-expanded","true"))}_updateEditLink(){let t=this._editLink;t||(t=this._editLink=this._container.querySelector(".mapbox-improve-map"));let o=[{key:"owner",value:this.styleOwner},{key:"id",value:this.styleId},{key:"access_token",value:this._map._requestManager._customAccessToken||h.g.ACCESS_TOKEN}];if(t){let c=o.reduce((d,m,_)=>(m.value&&(d+=`${m.key}=${m.value}${_<o.length-1?"&":""}`),d),"?");t.href=`${h.g.FEEDBACK_URL}/${c}#${an(this._map,!0)}`,t.rel="noopener nofollow"}}_updateData(t){!t||(t.dataType!=="source"||t.sourceDataType!=="metadata"&&t.sourceDataType!=="visibility")&&t.dataType!=="style"||(this._updateAttributions(),this._updateEditLink())}_updateAttributions(){if(!this._map.style)return;let t=[];if(this._map.style.stylesheet){let d=this._map.style.stylesheet;this.styleOwner=d.owner,this.styleId=d.id}let o=this._map.style._mergedSourceCaches;for(let d in o){let m=o[d];if(m.used){let _=m.getSource();_.attribution&&!t.includes(_.attribution)&&t.push(_.attribution)}}t.sort((d,m)=>d.length-m.length),t=t.filter((d,m)=>{for(let _=m+1;_<t.length;_++)if(t[_].includes(d))return!1;return!0}),this.options.customAttribution&&(Array.isArray(this.options.customAttribution)?t=[...this.options.customAttribution,...t]:t.unshift(this.options.customAttribution));let c=t.map(d=>function(m){let _=new DOMParser().parseFromString(m,"text/html");return Array.from(_.body.querySelectorAll("*")).reverse().forEach(y=>{let v=y.textContent||"";if(y.tagName!=="A")return void y.replaceWith(...y.childNodes);let T=y.getAttribute("href");if(!T||!_g.test(T))return void y.replaceWith(_.createTextNode(v));let I=_.createElement("a");I.href=T,I.textContent=v,I.rel="noopener nofollow";let P=y.getAttribute("class");P&&(I.className=P),y.replaceWith(I)}),_.body.innerHTML}(d)).join(" | ");c!==this._attribHTML&&(this._attribHTML=c,t.length?(this._innerContainer.innerHTML=c,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 wm{constructor(){h.b0(["_updateLogo","_updateCompact"],this)}onAdd(t){this._map=t,this._container=Rt("div","mapboxgl-ctrl");let o=Rt("a","mapboxgl-ctrl-logo");return o.target="_blank",o.rel="noopener nofollow",o.href="https://www.mapbox.com/",o.setAttribute("aria-label",this._map._getUIString("LogoControl.Title")),o.setAttribute("rel","noopener nofollow"),this._container.appendChild(o),this._container.style.display="none",this._map.on("sourcedata",this._updateLogo),this._updateLogo(),this._map.on("resize",this._updateCompact),this._updateCompact(),this._container}onRemove(){this._container.remove(),this._map.off("sourcedata",this._updateLogo),this._map.off("resize",this._updateCompact)}getDefaultPosition(){return"bottom-left"}_updateLogo(t){t&&t.sourceDataType!=="metadata"||(this._container.style.display=this._logoRequired()?"block":"none")}_logoRequired(){if(!this._map.style)return!0;let t=this._map.style._sourceCaches;if(Object.entries(t).length===0)return!0;for(let o in t){let c=t[o].getSource();if(Object.hasOwn(c,"mapbox_logo")&&!c.mapbox_logo)return!1}return!0}_updateCompact(){let t=this._container.children;if(t.length){let o=t[0];this._map.getCanvasContainer().offsetWidth<250?o.classList.add("mapboxgl-compact"):o.classList.remove("mapboxgl-compact")}}}class Tm{constructor(){this._queue=[],this._id=0,this._cleared=!1,this._currentlyRunning=!1}add(t){let o=++this._id;return this._queue.push({callback:t,id:o,cancelled:!1}),o}remove(t){let o=this._currentlyRunning,c=o?this._queue.concat(o):this._queue;
3281for(let d of c)if(d.id===t)return void(d.cancelled=!0)}run(t=0){let o=this._currentlyRunning=this._queue;this._queue=[];for(let c of o)if(!c.cancelled&&(c.callback(t),this._cleared))break;this._cleared=!1,this._currentlyRunning=!1}clear(){this._currentlyRunning&&(this._cleared=!0),this._queue=[]}}class cp{constructor(t){this.jumpTo(t)}getValue(t){if(t<=this._startTime)return this._start;if(t>=this._endTime)return this._end;let o=h.dr((t-this._startTime)/(this._endTime-this._startTime));return this._start*(1-o)+this._end*o}isEasing(t){return t>=this._startTime&&t<=this._endTime}jumpTo(t){this._startTime=-1/0,this._endTime=-1/0,this._start=t,this._end=t}easeTo(t,o,c){this._start=this.getValue(o),this._end=t,this._startTime=o,this._endTime=o+c}}let gg={"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 \u2318 + scroll to zoom the map","TouchPanBlocker.Message":"Use two fingers to move the map"};class Hs extends h.z{constructor(t,o,c,d){let{point:m,lngLat:_,originalEvent:y,target:v}=t;super(t.type,{point:m,lngLat:_,originalEvent:y,target:v}),this.preventDefault=()=>{t.preventDefault()},this.id=o,this.interaction=c,this.feature=d}}class Sm{constructor(t){this.map=t,this.interactionsByType=new Map,this.delegatedInteractions=new Map,this.typeById=new Map,this.filters=new Map,this.handleType=this.handleType.bind(this),this.handleMove=this.handleMove.bind(this),this.handleOut=this.handleOut.bind(this),this.hoveredFeatures=new Map,this.prevHoveredFeatures=new Map}add(t,o){if(this.typeById.has(t))throw new Error(`Interaction id "${t}" already exists.`);let c=o.filter,d=o.type;c&&this.filters.set(t,h.dj(c)),d==="mouseover"&&(d="mouseenter"),d==="mouseout"&&(d="mouseleave");let m=this.interactionsByType.get(d)||new Map;d==="mouseenter"||d==="mouseleave"?(this.delegatedInteractions.size===0&&(this.map.on("mousemove",this.handleMove),this.map.on("mouseout",this.handleOut)),this.delegatedInteractions.set(t,o)):m.size===0&&this.map.on(d,this.handleType),m.size===0&&this.interactionsByType.set(d,m),m.set(t,o),this.typeById.set(t,d)}get(t){let o=this.typeById.get(t);if(!o)return;let c=this.interactionsByType.get(o);return c?c.get(t):void 0}remove(t){let o=this.typeById.get(t);if(!o)return;this.typeById.delete(t),this.filters.delete(t);let c=this.interactionsByType.get(o);c&&(c.delete(t),o==="mouseenter"||o==="mouseleave"?(this.delegatedInteractions.delete(t),this.delegatedInteractions.size===0&&(this.map.off("mousemove",this.handleMove),this.map.off("mouseout",this.handleOut))):c.size===0&&this.map.off(o,this.handleType))}queryTargets(t,o){let c=[];for(let[d,m]of o)m.target&&c.push({targetId:d,target:m.target,filter:this.filters.get(d)});return this.map.style.queryRenderedTargets(t,c,this.map.transform)}handleMove(t){this.prevHoveredFeatures=this.hoveredFeatures,this.hoveredFeatures=new Map;let o=this.queryTargets(t.point,Array.from(this.delegatedInteractions).reverse());o.length&&(t.type="mouseenter",this.handleType(t,o));let c=new Map;for(let[d,{feature:m}]of this.prevHoveredFeatures)this.hoveredFeatures.has(d)||c.set(m.id,m);c.size&&(t.type="mouseleave",this.handleType(t,Array.from(c.values())))}handleOut(t){let o=Array.from(this.hoveredFeatures.values()).map(({feature:c})=>c);o.length&&(t.type="mouseleave",this.handleType(t,o)),this.hoveredFeatures.clear()}handleType(t,o){let c=t.type==="mouseenter";if(c&&!this.interactionsByType.has(t.type))return void h.w("mouseenter interaction required for mouseleave to work.");let d=Array.from(this.interactionsByType.get(t.type)).reverse(),m=!!o;o=o||this.queryTargets(t.point,d);let _=!1,y=new Set;for(let v of o){for(let[T,I]of d){if(!I.target)continue;let P=v.variants?v.variants[T]:null;if(P){for(let A of P){if(Zh(A,v,y,T))continue;let D=new h.dl(v,A),L=cf(A,v,T);m&&D.id!==void 0&&(D.state=this.map.getFeatureState(D));let O=c?this.prevHoveredFeatures.get(L):null,k=new Hs(t,T,I,D),N=O?O.stop:I.handler(k);if(c&&this.hoveredFeatures.set(L,{feature:v,stop:N}),N!==!1){_=!0;break}}if(_)break}}if(_)break}if(!_)for(let[v,T]of d){let{handler:I,target:P}=T;if(!P&&I(new Hs(t,v,T,null))!==!1)break}}}function yg(a,t){if(Array.isArray(a)&&Array.isArray(t)){let o=new Set(a
3281),c=new Set(t);return o.size===c.size&&a.every(d=>c.has(d))}return h.b9(a,t)}let Im=/matrix.*\((.+)\)/,xg={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,fontstackCompositing:"client",transformRequest:null,accessToken:null,fadeDuration:300,respectPrefersReducedMotion:!0,crossSourceCollisions:!0,collectResourceTiming:!1,testMode:!1,precompilePrograms:!0,scaleFactor:1},vg={showCompass:!0,showZoom:!0,visualizePitch:!1};class ss{constructor(t,o,c=!1){this._clickTolerance=10,this.element=o,this.mouseRotate=new Nr({clickTolerance:t.dragRotate._mouseRotate._clickTolerance}),this.map=t,c&&(this.mousePitch=new Ur({clickTolerance:t.dragRotate._mousePitch._clickTolerance})),h.b0(["mousedown","mousemove","mouseup","touchstart","touchmove","touchend","reset"],this),o.addEventListener("mousedown",this.mousedown),o.addEventListener("touchstart",this.touchstart,{passive:!1}),o.addEventListener("touchmove",this.touchmove),o.addEventListener("touchend",this.touchend),o.addEventListener("touchcancel",this.reset)}down(t,o){this.mouseRotate.mousedown(t,o),this.mousePitch&&this.mousePitch.mousedown(t,o),Vo()}move(t,o){let c=this.map,d=this.mouseRotate.mousemoveWindow(t,o),m=d&&d.bearingDelta;if(m&&c.setBearing(c.getBearing()+m),this.mousePitch){let _=this.mousePitch.mousemoveWindow(t,o),y=_&&_.pitchDelta;y&&c.setPitch(c.getPitch()+y)}}off(){let t=this.element;t.removeEventListener("mousedown",this.mousedown),t.removeEventListener("touchstart",this.touchstart),t.removeEventListener("touchmove",this.touchmove),t.removeEventListener("touchend",this.touchend),t.removeEventListener("touchcancel",this.reset),this.offTemp()}offTemp(){jo(),window.removeEventListener("mousemove",this.mousemove),window.removeEventListener("mouseup",this.mouseup)}mousedown(t){this.down(Object.assign({},t,{button:t.button,type:t.type,ctrlKey:!0,preventDefault:()=>t.preventDefault()}),Go(this.element,t)),window.addEventListener("mousemove",this.mousemove),window.addEventListener("mouseup",this.mouseup)}mousemove(t){this.move(t,Go(this.element,t))}mouseup(t){this.mouseRotate.mouseupWindow(t),this.mousePitch&&this.mousePitch.mouseupWindow(t),this.offTemp()}touchstart(t){t.targetTouches.length!==1?this.reset():(this._startPos=this._lastPos=ta(this.element,t.targetTouches)[0],this.down({type:"mousedown",button:0,ctrlKey:!0,preventDefault:()=>t.preventDefault()},this._startPos))}touchmove(t){t.targetTouches.length!==1?this.reset():(this._lastPos=ta(this.element,t.targetTouches)[0],this.move({buttons:1,preventDefault:()=>t.preventDefault()},this._lastPos))}touchend(t){t.targetTouches.length===0&&this._startPos&&this._lastPos&&this._startPos.dist(this._lastPos)<this._clickTolerance&&this.element.click(),this.reset()}reset(){this.mouseRotate.reset(),this.mousePitch&&this.mousePitch.reset(),delete this._startPos,delete this._lastPos,this.offTemp()}}function Em(a,t,o){if(a=new h.aX(a.lng,a.lat),t){let c=new h.aX(a.lng-360,a.lat),d=new h.aX(a.lng+360,a.lat),m=360*Math.ceil(Math.abs(a.lng-o.center.lng)/360),_=o.locationPoint3D(a).distSqr(t),y=t.x<0||t.y<0||t.x>o.width||t.y>o.height;o.locationPoint3D(c).distSqr(t)<_&&(y||Math.abs(c.lng-o.center.lng)<m)?a=c:o.locationPoint3D(d).distSqr(t)<_&&(y||Math.abs(d.lng-o.center.lng)<m)&&(a=d)}for(;Math.abs(a.lng-o.center.lng)>180;){let c=o.locationPoint3D(a);if(c.x>=0&&c.y>=0&&c.x<=o.width&&c.y<=o.height)break;a.lng>o.center.lng?a.lng-=360:a.lng+=360}return a}let Jc={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%)"},up=/\s+/,ro={rotation:0,rotationAlignment:"auto",pitchAlignment:"auto",occludedOpacity:.2,altitude:0};class fh extends h.E{constructor(t,o){super(),(t instanceof HTMLElement||o)&&(t=Object.assign({element:t},o)),h.b0(["_update","_onMove","_onUp","_addDragHandler","_onMapClick","_onKeyPress","_clearFadeTimer"],this);let{anchor:c="center",color:d="#3FB1CE",scale:m=1,draggable:_=!1,clickTolerance:y=0,rotation:v=ro.rotation,rotationAlignment:T=ro.rotationAlignment,pitchAlignment:I=ro.pitchAlignment,occludedOpacity:P=ro.occludedOpacity,altitude:A=ro.altitude}=t||{};this._anchor=c,this._color=d,this._scale=m,this._draggable=_,this._clickTolerance=y,this._rotation=v,this._rotationAlignment=T,this._pitchAlignment=I,this._occludedOpacity=P,this._altitude=A,this._state="inactive",this._isDragging=!1,this._updateMoving=()=>this._update(!0),t&&t.element?(this._element=t.element,this._offset=h.P.convert(t&&t.offset||[0,0])):(this._defaultMarker=!0,this._element=this._createDefaultMarker(),this._offset=h.P.convert(t&&t.offset||[0,-14])),this._element.hasAttribute("aria-label")||this._element.setAttribute("aria-label","Map marker"),this._element.hasAttribute("role")||this._element.setAttribute("role","img"),this._element.classList.add("mapboxgl-marker"),this._element.addEventListener("dragstart",O=>{O.preventDefault()}),this._element.addEventListener("mousedown",O=>{O.preventDefault()});let D=this._element.classList;for(let O in Jc)D.remove(`mapboxgl-marker-anchor-${O}`);D.add(`mapboxgl-marker-anchor-${this._anchor}`);let L=t&&t.className?t.className.trim().split(up):[];D.add(...L),this._popup=null}_createDefaultMarker(){let t=Rt("div"),o=mr("svg",{display:"block",height:41*this._scale+"px",width:27*this._scale+"px",viewBox:"0 0 27 41"},t);if(this._altitude===0){let c=mr("radialGradient",{id:"shadowGradient"},mr("defs",{},o));
3281mr("stop",{offset:"10%","stop-opacity":.4},c),mr("stop",{offset:"100%","stop-opacity":.05},c),mr("ellipse",{cx:13.5,cy:34.8,rx:10.5,ry:5.25,fill:"url(#shadowGradient)"},o)}return mr("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"},o),mr("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"},o),mr("circle",{fill:"white",cx:13.5,cy:13.5,r:5.5},o),t}addTo(t){return t===this._map||(this.remove(),this._map=t,t.getCanvasContainer().appendChild(this._element),t.on("move",this._updateMoving),t.on("moveend",this._update),t.on("remove",this._clearFadeTimer),t._addMarker(this),this.setDraggable(this._draggable),this._update(),t.on("click",this._onMapClick)),this}remove(){let t=this._map;return t&&(t.off("click",this._onMapClick),t.off("move",this._updateMoving),t.off("moveend",this._update),t.off("mousedown",this._addDragHandler),t.off("touchstart",this._addDragHandler),t.off("mouseup",this._onUp),t.off("touchend",this._onUp),t.off("mousemove",this._onMove),t.off("touchmove",this._onMove),t.off("remove",this._clearFadeTimer),t._removeMarker(this),this._map=void 0),this._clearFadeTimer(),this._element.remove(),this._popup&&this._popup.remove(),this}getLngLat(){return this._lngLat}setLngLat(t){return this._lngLat=h.aX.convert(t),this._pos=null,this._popup&&this._popup.setLngLat(this._lngLat),this._update(!0),this}setAltitude(t){return t===this._altitude||(this._defaultMarker&&(this._altitude===0&&t!==0||this._altitude!==0&&t===0)&&(this._element=this._createDefaultMarker()),this._altitude=t||ro.altitude,this._update()),this}getAltitude(){return this._altitude}getElement(){return this._element}setPopup(t){if(this._popup&&(this._popup.remove(),this._popup=null,this._element.removeAttribute("role"),this._element.removeEventListener("keypress",this._onKeyPress),this._originalTabIndex||this._element.removeAttribute("tabindex")),t){if(!("offset"in t.options)){let d=Math.sqrt(Math.pow(13.5,2)/2);t.options.offset=this._defaultMarker?{top:[0,0],"top-left":[0,0],"top-right":[0,0],bottom:[0,-38.1],"bottom-left":[d,-1*(38.1-13.5+d)],"bottom-right":[-d,-1*(38.1-13.5+d)],left:[13.5,-1*(38.1-13.5)],right:[-13.5,-1*(38.1-13.5)]}:this._offset}this._popup=t,t._marker=this,t._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(t){let o=t.code,c=t.charCode||t.keyCode;o!=="Space"&&o!=="Enter"&&c!==32&&c!==13||this.togglePopup()}_onMapClick(t){let o=t.originalEvent.target,c=this._element;this._popup&&(o===c||c.contains(o))&&this.togglePopup()}getPopup(){return this._popup}togglePopup(){let t=this._popup;return t?(t.isOpen()?(t.remove(),this._element.setAttribute("aria-expanded","false")):this._map&&(t.addTo(this._map),this._element.setAttribute("aria-expanded","true")),this):this}_behindTerrain(){let t=this._map,o=this._pos;if(!t||!o)return!1;let c=t.unproject(o,this._altitude),d=t.getFreeCameraOptions();if(!d.position)return!1;let m=d.position.toLngLat();return m.distanceTo(c)<.9*m.distanceTo(this._lngLat)}_evaluateOpacity(){let t=this._map;if(!t)return;let o=this._pos;if(!o||o.x<0||o.x>t.transform.width||o.y<0||o.y>t.transform.height)return void this._clearFadeTimer();let c=t.unproject(o,this._altitude),d;t._showingGlobe()&&h.f2(t.transform,this._lngLat)?d=0:(d=1-t._queryFogOpacity(c),t.transform._terrainEnabled()&&t.getTerrain()&&this._behindTerrain()&&(d*=this._occludedOpacity)),this._element.style.opacity=`${d}`,this._element.style.pointerEvents=d>0?"auto":"none",this._popup&&this._popup._setOpacity(d),this._fadeTimer=null}_clearFadeTimer(){this._fadeTimer&&(clearTimeout(this._fadeTimer),this._fadeTimer=null)}_updateDOM(){let t=this._pos;if(!t||!this._map)return;let o=this._offset.mult(this._scale);this._element.style.transform=` 3282 translate(${t.x}px,${t.y}px) 3283 ${Jc[this._anchor]} 3284 ${this._calculateXYTransform()} ${this._calculateZTransform()} 3285 translate(${o.x}px,${o.y}px) 3286 `}_calculateXYTransform(){let t=this._pos,o=this._map,c=this.getPitchAlignment();if(!o||!t||c!=="map")return"";if(!o._showingGlobe()){let v=o.getPitch();return v?`rotateX(${v}deg)`:""}let d=h.cL(h.f3(o.transform,this._lngLat)),m=t.sub(h.f4(o.transform)),_=Math.abs(m.x)+Math.abs(m.y);if(_===0)return"";let y=d/_;return`rotateX(${-m.y*y}deg) rotateY(${m.x*y}deg)`}_calculateZTransform(){let t=this._pos,o=this._map;if(!o||!t)return"";let c=0,d=this.getRotationAlignment();if(d==="map")if(o._showingGlobe()){let m=o.project(new h.aX(this._lngLat.lng,this._lngLat.lat+.001),this._altitude),_=o.project(new h.aX(this._lngLat.lng,this._lngLat.lat-.001),this._altitude).sub(m);c=h.cL(Math.atan2(_.y,_.x))-90}else c=-o.getBearing();else if(d==="horizon"){let m=h.ag(4,6,o.getZoom()),_=h.f4(o.transform);_.y+=m*o.transform.height;let y=t.sub(_),v=h.cL(Math.atan2(y.y,y.x));c=(v>90?v-270:v+90)*(1-m)}return c+=this._rotation,c?`rotateZ(${c}deg)`:""}_update(t){cancelAnimationFrame(this._updateFrameId);let o=this._map;
3286o&&(o.transform.renderWorldCopies&&(this._lngLat=Em(this._lngLat,this._pos,o.transform)),this._pos=o.project(this._lngLat,this._altitude),t===!0?this._updateFrameId=requestAnimationFrame(()=>{this._element&&this._pos&&this._anchor&&(this._pos=this._pos.round(),this._updateDOM())}):this._pos=this._pos.round(),o._requestDomTask(()=>{this._map&&(this._element&&this._pos&&this._anchor&&this._updateDOM(),(o._showingGlobe()||o.getTerrain()||o.getFog())&&!this._fadeTimer&&(this._fadeTimer=window.setTimeout(this._evaluateOpacity.bind(this),60)))}))}getOffset(){return this._offset}setOffset(t){return this._offset=h.P.convert(t),this._update(),this}addClassName(t){return this._element.classList.add(t),this}removeClassName(t){return this._element.classList.remove(t),this}toggleClassName(t){return this._element.classList.toggle(t)}_onMove(t){let o=this._map;if(!o)return;let c=this._pointerdownPos,d=this._positionDelta;if(c&&d){if(!this._isDragging){let m=this._clickTolerance||o._clickTolerance;if(t.point.dist(c)<m)return;this._isDragging=!0}this._pos=t.point.sub(d),this._lngLat=o.unproject(this._pos,this._altitude),this.setLngLat(this._lngLat),this._element.style.pointerEvents="none",this._state==="pending"&&(this._state="active",this.fire(new h.z("dragstart"))),this.fire(new h.z("drag"))}}_onUp(){this._element.style.pointerEvents="auto",this._positionDelta=null,this._pointerdownPos=null,this._isDragging=!1;let t=this._map;t&&(t.off("mousemove",this._onMove),t.off("touchmove",this._onMove)),this._state==="active"&&this.fire(new h.z("dragend")),this._state="inactive"}_addDragHandler(t){let o=this._map,c=this._pos;o&&c&&this._element.contains(t.originalEvent.target)&&(t.preventDefault(),this._positionDelta=t.point.sub(c),this._pointerdownPos=t.point,this._state="pending",o.on("mousemove",this._onMove),o.on("touchmove",this._onMove),o.once("mouseup",this._onUp),o.once("touchend",this._onUp))}setDraggable(t){this._draggable=!!t;let o=this._map;return o&&(t?(o.on("mousedown",this._addDragHandler),o.on("touchstart",this._addDragHandler)):(o.off("mousedown",this._addDragHandler),o.off("touchstart",this._addDragHandler))),this}isDraggable(){return this._draggable}setRotation(t){return this._rotation=t||ro.rotation,this._update(),this}getRotation(){return this._rotation}setRotationAlignment(t){return this._rotationAlignment=t||ro.rotationAlignment,this._update(),this}getRotationAlignment(){return this._rotationAlignment==="auto"||this._rotationAlignment==="horizon"&&this._map&&!this._map._showingGlobe()?"viewport":this._rotationAlignment}setPitchAlignment(t){return this._pitchAlignment=t||ro.pitchAlignment,this._update(),this}getPitchAlignment(){return this._pitchAlignment==="auto"?this.getRotationAlignment():this._pitchAlignment}setOccludedOpacity(t){return this._occludedOpacity=t||ro.occludedOpacity,this._update(),this}getOccludedOpacity(){return this._occludedOpacity}}let Am={positionOptions:{enableHighAccuracy:!1,maximumAge:0,timeout:6e3},fitBoundsOptions:{maxZoom:15},trackUserLocation:!1,showAccuracyCircle:!0,showUserLocation:!0,showUserHeading:!1,showButton:!0,followUserLocation:!0},Mm={maxWidth:100,unit:"metric"},Cm={kilometer:"km",meter:"m",mile:"mi",foot:"ft","nautical-mile":"nm"},hp=/\s+/,Si={closeButton:!0,closeOnClick:!0,focusAfterOpen:!0,className:"",maxWidth:"240px",altitude:0},Pm=["a[href]","[tabindex]:not([tabindex='-1'])","[contenteditable]:not([contenteditable='false'])","button:not([disabled])","input:not([disabled])","select:not([disabled])","textarea:not([disabled])"].join(", ");function mh(a=new h.P(0,0),t="bottom"){if(typeof a=="number"){let o=Math.round(Math.sqrt(.5*Math.pow(a,2)));switch(t){case"top":return new h.P(0,a);case"top-left":return new h.P(o,o);case"top-right":return new h.P(-o,o);case"bottom":return new h.P(0,-a);case"bottom-left":return new h.P(o,-o);case"bottom-right":return new h.P(-o,-o);case"left":return new h.P(a,0);case"right":return new h.P(-a,0)}return new h.P(0,0)}return a instanceof h.P||Array.isArray(a)?h.P.convert(a):h.P.convert(a[t]||[0,0])}return{version:U,supported:Jr.supported,setRTLTextPlugin:h.f7,getRTLTextPluginStatus:h.f6,addTileProvider:h.f5,Map:class extends $s{constructor(a){gi.mark(ln.create);let t=a;if((a=Object.assign({},xg,a)).minZoom!=null&&a.maxZoom!=null&&a.minZoom>a.maxZoom)throw new Error("maxZoom must be greater than or equal to minZoom");if(a.minPitch!=null&&a.maxPitch!=null&&a.minPitch>a.maxPitch)throw new Error("maxPitch must be greater than or equal to minPitch");if(a.minPitch!=null&&a.minPitch<0)throw new Error("minPitch must be greater than or equal to 0");if(a.maxPitch!=null&&a.maxPitch>85)throw new Error("maxPitch must be less than or equal to 85");a.antialias&&h.f0(window)&&(a.antialias=!1,h.w("Antialiasing is disabled for this WebGL context to avoid browser bug: https://github.com/mapbox/mapbox-gl-js/issues/11609")),super(new Ms(a.minZ
3286oom,a.maxZoom,a.minPitch,a.maxPitch,a.renderWorldCopies,null,null),a),this._repaint=!!a.repaint,this._interactive=a.interactive,this._minTileCacheSize=a.minTileCacheSize,this._maxTileCacheSize=a.maxTileCacheSize,this._failIfMajorPerformanceCaveat=a.failIfMajorPerformanceCaveat,this._preserveDrawingBuffer=a.preserveDrawingBuffer,this._antialias=a.antialias,this._trackResize=a.trackResize,this._bearingSnap=a.bearingSnap,this._refreshExpiredTiles=a.refreshExpiredTiles,this._fadeDuration=a.fadeDuration,this._isInitialLoad=!0,this._crossSourceCollisions=a.crossSourceCollisions,this._collectResourceTiming=a.collectResourceTiming,this._language=this._parseLanguage(a.language),this._worldview=a.worldview,this._renderTaskQueue=new Tm,this._domRenderTaskQueue=new Tm,this._controls=[],this._markers=[],this._popups=[],this._mapId=h.an(),this._locale=Object.assign({},gg,a.locale),this._clickTolerance=a.clickTolerance,this._cooperativeGestures=a.cooperativeGestures,this._performanceMetricsCollection=a.performanceMetricsCollection,this._tessellationStep=a.tessellationStep,this._containerWidth=0,this._containerHeight=0,this._showParseStatus=!0,this._precompilePrograms=a.precompilePrograms,this._averageElevationLastSampledAt=-1/0,this._averageElevationExaggeration=0,this._averageElevation=new cp(0),this._interactionRange=[1/0,-1/0],this._visibilityHidden=0,this._useExplicitProjection=!1,this._frameId=0,this._scaleFactor=a.scaleFactor,this._requestManager=new po(a.transformRequest,a.accessToken,a.testMode);let o=Dr(a.accessToken||h.g.ACCESS_TOKEN);if(o&&"atlas"in o&&typeof o.atlas=="number"&&(this._tokenExpiration=o.atlas),this._silenceAuthErrors=!!a.testMode,this._contextCreateOptions=a.contextCreateOptions?Object.assign({},a.contextCreateOptions):{},typeof a.container=="string"){let c=document.getElementById(a.container);if(!c)throw new Error(`Container '${a.container.toString()}' not found.`);this._container=c}else{if(!(a.container instanceof HTMLElement))throw new Error("Invalid type: 'container' must be a String or HTMLElement.");this._container=a.container}if(this._container.childNodes.length>0&&h.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."),a.maxBounds&&this.setMaxBounds(a.maxBounds),this._spriteFormat="auto",h.b0(["_onWindowOnline","_onWindowResize","_onVisibilityChange","_onMapScroll","_contextLost","_contextRestored"],this),this._setupContainer(),this._setupPainter(),this.painter===void 0)throw new Error("Failed to initialize WebGL.");if(this.on("move",()=>this._update(!1)),this.on("moveend",()=>this._update(!1)),this.on("zoom",()=>this._update(!0)),this._fullscreenchangeEvent="onfullscreenchange"in document?"fullscreenchange":"webkitfullscreenchange",window.addEventListener("online",this._onWindowOnline,!1),window.addEventListener("resize",this._onWindowResize,!1),window.addEventListener("orientationchange",this._onWindowResize,!1),window.addEventListener(this._fullscreenchangeEvent,this._onWindowResize,!1),window.addEventListener("visibilitychange",this._onVisibilityChange,!1),this.handlers=new jr(this,a),this._localFontFamily=a.localFontFamily,this._localIdeographFontFamily=a.localIdeographFontFamily,this._fontstackCompositing=a.fontstackCompositing,(a.style||!a.testMode)&&this.setStyle(a.style||h.g.DEFAULT_STYLE,{config:a.config,localFontFamily:this._localFontFamily,localIdeographFontFamily:this._localIdeographFontFamily,fontstackCompositing:this._fontstackCompositing}),a.projection&&this.setProjection(a.projection),a.hash&&(this._hash=new ch(typeof a.hash=="string"&&a.hash||void 0).addTo(this)),!this._hash||!this._hash._onHashChange()){t.center==null&&t.zoom==null||(this.transform._unmodified=!1),this.jumpTo({center:a.center,zoom:a.zoom,bearing:a.bearing,pitch:a.pitch});let c=a.bounds;c&&(this.resize(),this.fitBounds(c,Object.assign({},a.fitBoundsOptions,{duration:0})))}this.resize(),a.attributionControl&&this.addControl(new bm({customAttribution:a.customAttribution}
vendor: 4,791 bytes, line 3286
3286)),this._logoControl=new wm,this.addControl(this._logoControl,a.logoPosition),this.on("style.load",()=>{this.transform.unmodified&&this.jumpTo(this.style.stylesheet),this._postStyleLoadEvent(),this._postStyleWithAppearanceEvent()}),this.on("data",c=>{this._update(c.dataType==="style"),this.fire(new h.z(`${c.dataType}data`,c))}),this.on("dataloading",c=>{this.fire(new h.z(`${c.dataType}dataloading`,c))}),this._interactions=new Sm(this)}_getMapId(){return this._mapId}addControl(a,t){if(t===void 0&&(t=a.getDefaultPosition?a.getDefaultPosition():"top-right"),!a||!a.onAdd)return this.fire(new h.y(new Error("Invalid argument to map.addControl(). Argument must be a control with onAdd and onRemove methods.")));let o=a.onAdd(this);this._controls.push(a);let c=this._controlPositions[t];return t.includes("bottom")?c.insertBefore(o,c.firstChild):c.appendChild(o),this}removeControl(a){if(!a||!a.onRemove)return this.fire(new h.y(new Error("Invalid argument to map.removeControl(). Argument must be a control with onAdd and onRemove methods.")));let t=this._controls.indexOf(a);return t>-1&&this._controls.splice(t,1),a.onRemove(this),this}hasControl(a){return this._controls.includes(a)}getContainer(){return this._container}getCanvasContainer(){return this._canvasContainer}getCanvas(){return this._canvas}resize(a){if(this._updateContainerDimensions(),this._containerWidth===this.transform.width&&this._containerHeight===this.transform.height)return this;this._resizeCanvas(this._containerWidth,this._containerHeight),this.transform.resize(this._containerWidth,this._containerHeight),this.painter.resize(Math.ceil(this._containerWidth),Math.ceil(this._containerHeight));let t=!this._moving;return t&&this.fire(new h.z("movestart",a)).fire(new h.z("move",a)),this.fire(new h.z("resize",a)),t&&this.fire(new h.z("moveend",a)),this}getBounds(){return this.transform.getBounds()}getMaxBounds(){return this.transform.getMaxBounds()||null}setMaxBounds(a){return this.transform.setMaxBounds(h.aI.convert(a)),this._update()}setMinZoom(a){if((a=a??-2)>=-2&&a<=this.transform.maxZoom)return this.transform.minZoom=a,this._update(),this.getZoom()<a?this.setZoom(a):this.fire(new h.z("zoomstart")).fire(new h.z("zoom")).fire(new h.z("zoomend")),this;throw new Error("minZoom must be between -2 and the current maxZoom, inclusive")}getMinZoom(){return this.transform.minZoom}setMaxZoom(a){if((a=a??22)>=this.transform.minZoom)return this.transform.maxZoom=a,this._update(),this.getZoom()>a?this.setZoom(a):this.fire(new h.z("zoomstart")).fire(new h.z("zoom")).fire(new h.z("zoomend")),this;throw new Error("maxZoom must be greater than the current minZoom")}getMaxZoom(){return this.transform.maxZoom}setMinPitch(a){if((a=a??0)<0)throw new Error("minPitch must be greater than or equal to 0");if(a>=0&&a<=this.transform.maxPitch)return this.transform.minPitch=a,this._update(),this.getPitch()<a?this.setPitch(a):this.fire(new h.z("pitchstart")).fire(new h.z("pitch")).fire(new h.z("pitchend")),this;throw new Error("minPitch must be between 0 and the current maxPitch, inclusive")}getMinPitch(){return this.transform.minPitch}setMaxPitch(a){if((a=a??85)>85)throw new Error("maxPitch must be less than or equal to 85");if(a>=this.transform.minPitch)return this.transform.maxPitch=a,this._update(),this.getPitch()>a?this.setPitch(a):this.fire(new h.z("pitchstart")).fire(new h.z("pitch")).fire(new h.z("pitchend")),this;throw new Error("maxPitch must be greater than or equal to minPitch")}getMaxPitch(){return this.transform.maxPitch}getScaleFactor(){return this._scaleFactor}setScaleFactor(a){return this._scaleFactor=a,this.painter.scaleFactor=a,this.style&&this.style._setLabelPlacementStale(),this.style._updateFilteredLayers(t=>t.type==="symbol"),this._update(!0),this}getRenderWorldCopies(){return this.transform.renderWorldCopies}setRenderWorldCopies(a){return this.transform.renderWorldCopies=a,this.transform.renderWorldCopies||this._forceMarkerAndPopupUpdate(!0),this._update()}getLanguage(){return this._language}_parseLanguage(a){return a==="auto"?navigator.language:Array.isArray(a)?a.length===0?void 0:a.map(t=>t==="auto"?navigator.language:t):a}setLanguage(a){let t=this._parseLanguage(a);if(!this.style||t===this._language)return this;this._language=t,this.style.reloadSources();for(let o of this._controls)o._setLanguage&&o._setLanguage(this._language);return this}getWorldview(){return this._worldview}setWorldview(a){return this.style&&a!==this._worldview?(this._worldview=a,this._styleDirty=!0,this.style.setWorldview(a),this):this}getProjection(){return this.transform.mercatorFromTransition?{name:"globe",center:[0,0]}:this.transform.getProjection()}_showingGlobe(){return this.transform.projection.name==="globe"}setProjection(a){return this._lazyInitEmptyStyle(),a?typeof a=="str
3286ing"&&(a={name:a}):a=null,this._useExplicitProjection=!!a,this._prioritizeAndUpdateProjection(a,this.style.projection)}_updateProjectionTransition(){if(this.getProjection().name!=="globe")return;let a=this.transform,t=a.projection.name,o;t==="globe"&&a.zoom>=h.cx?(a.setMercatorFromTransition(),o=!0):t==="mercator"&&a.zoom<h.cx&&(a.setProjection({name:"globe"}),o=!0),o&&(this.style.applyProjectionUpdate(),this.style._forceSymbolLayerUpdate(),this._update(!0))}_prioritizeAndUpdateProjection(a,t){return this._updateProjection(a||t||{name:"mercator"})}_updateProjection(a){let t,o=this.transform.mercatorFromTransition;t=a.name==="globe"&&this.transform.zoom>=h.cx?this.transform.setMercatorFromTransition():this.transform.setProjection(a),this.style.applyProjectionUpdate();let c=this.transform.getProjection().name==="mercator"&&o!==this.transform.mercatorFromTransition;return(t||c)&&(this.painter.clearBackgroundTiles(),this.style.clearSources(),this._update(!0),this._forceMarkerAndPopupUpdate(!0)),this}project(a,t){return this.transform.locationPoint3D(h.aX.convert(a),t)}unproject(a,t){return this.transform.pointLocation3D(h.P.convert(a),t)}isMoving(){return this._moving||this.handlers&&this.handlers.isMoving()||!1}isZooming(){return this._zooming||this.handlers&&this.handlers.isZooming()||!1}isRotating(){return this._rotating||this.handlers&&this.handlers.isRotating()||!1}_isDragging(){return this.handlers&&this.handlers._isDragging()||!1}_createDelegatedListener(a,t,o){let c=d=>{let m=[];if(Array.isArray(t)){let _=t.filter(y=>this.getLayer(y));m=_.length?this.queryRenderedFeatures(d,{layers:_}):[]}else m=this.queryRenderedFeatures(d,{target:t});return m};if(a==="mouseenter"||a==="mouseover"){let d=!1;return{listener:o,targets:t,delegates:{mousemove:_=>{let y=c(_.point);y.length?d||(d=!0,o.call(this,new rr(a,this,_.originalEvent,{features:y}))):d=!1},mouseout:()=>{d=!1}}}}if(a==="mouseleave"||a==="mouseout"){let d=!1;return{listener:o,targets:t,delegates:{mousemove:y=>{c(y.point).length?d=!0:d&&(d=!1,o.call(this,new rr(a,this,y.originalEvent)))},mouseout:y=>{d&&(d=!1,o.call(this,new rr(a,this,y.originalEvent)))}}}}{let d=m=>{let _=c(m.point);_.length&&(m.features=_,o.call(this,m),delete m.features)};return{listener:o,targets:t,delegates:{[a]:d}}}}on(a,t,o){if(typeof t=="function"||o===void 0)return super.on(a,t);if(typeof t=="string"&&(t=[t]),!this._areTargetsValid(t))return this;let c=this._createDelegatedListener(a,t,o);this._delegatedListeners=this._delegatedListeners||{},this._delegatedListeners[a]=this._delegatedListeners[a]||[],this._delegatedListeners[a].push(c);for(let d in c.delegates)this.on(d,c.delegates[d]);return this}once(a,t,o){if(typeof t=="function"||o===void 0)return super.once(a,t);if(typeof t=="string"&&(t=[t]),!this._areTargetsValid(t))return this;let c=this._createDelegatedListener(a,t,o);for(let d in c.delegates)this.once(d,c.delegates[d]);return this}off(a,t,o){if(typeof t=="function"||o===void 0)return super.off(a,t);if(typeof t=="string"&&(t=[t]),!this._areTargetsValid(t))return this;let c=this._delegatedListeners?this._delegatedListeners[a]:void 0;return c&&(d=>{for(let m=0;m<d.length;m++){let _=d[m];if(_.listener===o&&yg(_.targets,t)){for(let y in _.delegates)this.off(y,_.delegates[y]);return d.splice(m,1),this}}})(c),this}queryRenderedFeatures(a,t){if(!this.style)return[];if(a===void 0||a instanceof h.P||Array.isArray(a)||t!==void 0||(t=a,a=void 0),a=a||[[0,0],[this.transform.width,this.transform.height]],!t){let m=this.style.queryRenderedFeatures(a,void 0,this.transform),_=this.style.queryRenderedFeatureset(a,void 0,this.transform);return m.concat(_)}let o=!0;if(t.target&&(o=this._isTargetValid(t.target),o&&!t.layers))return this.style.queryRenderedFeatureset(a,t,this.transform);let c=!0;if(t.layers&&Array.isArray(t.layers)){for(let m of t.layers)if(!this._isValidId(m)){c=!1;break}if(c&&!t.target)return this.style.queryRenderedFeatures(a,t,this.transform)}let d=[];return c&&(d=d.concat(this.style.queryRenderedFeatures(a,t,this.transform))),o&&(d=d.concat(this.style.queryRenderedFeatureset(a,t,this.transform))),d}
3286querySourceFeatures(a,t){return!a||typeof a=="string"&&!this._isValidId(a)?[]:this.style.querySourceFeatures(a,t)}queryRasterValue(a,t,o){return this._isValidId(a)?this.style.queryRasterValue(a,t,o):Promise.resolve(null)}isPointOnSurface(a){let{name:t}=this.transform.projection;return t!=="globe"&&t!=="mercator"&&h.w(`${t} projection does not support isPointOnSurface, this API may behave unexpectedly.`),this.transform.isPointOnSurface(h.P.convert(a))}addInteraction(a,t){return this._interactions.add(a,t),this}removeInteraction(a){return this._interactions.remove(a),this}getCooperativeGestures(){return this._cooperativeGestures}setCooperativeGestures(a){return this._cooperativeGestures=a,this}setStyle(a,t){return t=Object.assign({},{localIdeographFontFamily:this._localIdeographFontFamily,localFontFamily:this._localFontFamily,fontstackCompositing:this._fontstackCompositing},t),this.style&&a&&t.diff!==!1&&t.localFontFamily===this._localFontFamily&&t.localIdeographFontFamily===this._localIdeographFontFamily&&t.fontstackCompositing===this._fontstackCompositing&&!t.config?(this.style._diffStyle(a,(o,c)=>{if(o){let d=typeof o=="string"?o:o instanceof Error?o.message:o.error;h.w(`Unable to perform style diff: ${d}. Rebuilding the style from scratch.`),this._updateStyle(a,t)}else c&&this._update(!0)},()=>this._postStyleLoadEvent()),this):(this._localIdeographFontFamily=t.localIdeographFontFamily,this._localFontFamily=t.localFontFamily,this._fontstackCompositing=t.fontstackCompositing,this._updateStyle(a,t))}_getUIString(a){let t=this._locale[a];if(t==null)throw new Error(`Missing UI string '${a}'`);return t}_updateStyle(a,t){if(this.style&&(this.style.setEventedParent(null),this.style._remove(),this.style=void 0),a){let o=Object.assign({},t);t&&t.config&&(o.initialConfig=t.config,delete o.config),this.style=new Fr(this,o).load(a),this.style.setEventedParent(this,{style:this.style})}return this._updateTerrain(),this}_lazyInitEmptyStyle(){this.style||(this.style=new Fr(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():(h.w("There is no style added to the map."),!1)}_isValidId(a){return a==null?(this.fire(new h.y(new Error("IDs can't be empty."))),!1):!h.de(a)||(this.fire(new h.y(new Error(`IDs can't contain special symbols: "${a}".`))),!1)}_isTargetValid(a){return"featuresetId"in a?this._isValidId("importId"in a?a.importId:a.featuresetId):"layerId"in a&&this._isValidId(a.layerId)}_areTargetsValid(a){if(Array.isArray(a)){for(let t of a)if(!this._isValidId(t))return!1;return!0}return this._isTargetValid(a)}addSource(a,t){return this._isValidId(a)?(this._lazyInitEmptyStyle(),this.style.addSource(a,t),this._update(!0)):this}isSourceLoaded(a){return!!this._isValidId(a)&&!!this.style&&this.style._isSourceCacheLoaded(a)}areTilesLoaded(){return this.style.areTilesLoaded()}addSourceType(a,t,o){this._lazyInitEmptyStyle(),this.style.addSourceType(a,t,o)}removeSource(a){return this._isValidId(a)?(this.style.removeSource(a),this._updateTerrain(),this._update(!0)):this}getSource(a){return this._isValidId(a)?this.style.getOwnSource(a):null}addImage(a,t,{pixelRatio:o=1,sdf:c=!1,stretchX:d,stretchY:m,content:_}={}){this._lazyInitEmptyStyle();let y=h.I.from(a);if(t instanceof HTMLImageElement||ImageBitmap&&t instanceof ImageBitmap){let{width:v,height:T,data:I}=h.o.getImageData(t);this.style.addImage(y,{data:new h.q({width:v,height:T},I),pixelRatio:o,stretchX:d,stretchY:m,content:_,sdf:c,version:0,usvg:!1})}else if(t.width===void 0||t.height===void 0)this.fire(new h.y(new Error("Invalid arguments to map.addImage(). The second argument must be an `HTMLImageElement`, `ImageData`, `ImageBitmap`, or object with `width`, `height`, and `data` properties with the same format as `ImageData`")));else{let{width:v,height:T}=t,I=t;this.style.addImage(y,{data:new h.q({width:v,height:T},new Uint8Array(I.data)),pixelRatio:o,stretchX:d,stretchY:m,content:_,sdf:c,usvg:!1,version:0,userImage:I}),I.onAdd&&I.onAdd(this,a)}}updateImage(a,t){this._lazyInitEmptyStyle();let o=h.I.from(a),c=this.style.getImage(o);if(!c)return void this.fire(new h.y(new Error("The map has no image with that id. If you are adding a new image use `map.addImage(...)` instead.")));let d=t instanceof HTMLImageElement||ImageBitmap&&t instanceof ImageBitmap?h.o.getImageData(t):t,{width:m,height:_,data:y}=d;if(m===void 0||_===void 0)return void this.fire(new h.y(new Error("Invalid arguments to map.updateImage(). The second argument must be an `HTMLImageElement`, `ImageData`, `ImageBitmap`, or object with `width`, `height`, and `data` properties with the same format as `ImageData`")));if(m!==(c.usvg?c.icon.usvg_tree.width:c.data.width)||_!==(c.usvg?c.icon.usvg_tree.height:c.data.height))return void this.fire(new h.y(new Error(`The width and height of the updated image (${m}, ${_}) 3287 must be that same as the previous version of the image 3288 (${c.data.width}, ${c.data.height})`)));let v=!(t instanceof HTMLImageElement||ImageBitmap&&t instanceof ImageBitmap),T=!1;c.usvg?(c.data=new h.q({width:m,height:_},new Uint8Array(y)),c.usvg=!1,c.icon=void 0,T=!0):c.data.replace(y,v),this.style.updateImage(o,c,T)}hasImage(a){return a?!!this.style&&!!this.style.getImage(h.I.from(a)):(this.fire(new h.y(new Error("Missing required image id"))),!1)}removeImage(a){this.style.removeImage(h.I.from(a))}loadImage(a,t){h.n(this._requestManager.transformRequest(a,h.R.Image),(o,c)=>{t(o,c)})}listImages(){return this.style.listImages().map(a=>a.name)}addModel(a,t){this._lazyInitEmptyStyle(),this.style.addModel(a,t)}hasModel(a){return a?this.style.hasModel(a):(this.fire(new h.y(new Error("Missing required model id"))),!1)}removeModel(a){this.style.removeModel(a)}listModels(){return this.style.listModels()}addLayer(a,t){return this._isValidId(a.id)?(this._lazyInitEmptyStyle(),this.style.addLayer(a,t),this._update(!0)):this}getSlot(a){let t=this.getLayer(a);return t&&t.slot||null}setSlot(a,t){return this.style.setSlot(a,t),this.style.mergeLayers(),this._update(!0)}
3288addImport(a,t){return this.style.addImport(a,t).catch(o=>this.fire(new h.y(new Error("Failed to add import",o)))),this}updateImport(a,t){return typeof t!="string"&&t.id!==a?(this.removeImport(a),this.addImport(t)):(this.style.updateImport(a,t),this._update(!0))}removeImport(a){return this.style.removeImport(a),this}moveImport(a,t){return this.style.moveImport(a,t),this._update(!0)}moveLayer(a,t){return this._isValidId(a)?(this.style.moveLayer(a,t),this._update(!0)):this}removeLayer(a){return this._isValidId(a)?(this.style.removeLayer(a),this._update(!0)):this}getLayer(a){if(!this._isValidId(a))return null;let t=this.style.getOwnLayer(a);return t?t.type==="custom"?t.implementation:t.serialize():void 0}getSlots(){return this.style.getSlots()}setLayerZoomRange(a,t,o){return this._isValidId(a)?(this.style.setLayerZoomRange(a,t,o),this._update(!0)):this}setFilter(a,t,o={}){return this._isValidId(a)?(this.style.setFilter(a,t,o),this._update(!0)):this}getFilter(a){return this._isValidId(a)?this.style.getFilter(a):null}setPaintProperty(a,t,o,c={}){return this._isValidId(a)?(this.style.setPaintProperty(a,t,o,c),this._update(!0)):this}getPaintProperty(a,t){return this._isValidId(a)?this.style.getPaintProperty(a,t):null}setLayoutProperty(a,t,o,c={}){return this._isValidId(a)?(this.style.setLayoutProperty(a,t,o,c),this._update(!0)):this}getLayoutProperty(a,t){return this._isValidId(a)?this.style.getLayoutProperty(a,t):null}setLayerProperty(a,t,o,c={}){return this._isValidId(a)?(t==="appearances"&&this._postAddingAppearancesToStyleEvent(),this.style.setLayerProperty(a,t,o,c),this._update(!0)):this}getGlyphsUrl(){return this.style.getGlyphsUrl()}setGlyphsUrl(a){return this.style.setGlyphsUrl(a),this._update(!0)}getSchema(a){return this.style.getSchema(a)}setSchema(a,t){return this.style.setSchema(a,t),this._update(!0)}getConfig(a){return this.style.getConfig(a)}setConfig(a,t){return this.style.setConfig(a,t),this._update(!0)}getConfigProperty(a,t){return this.style.getConfigProperty(a,t)}setConfigProperty(a,t,o){return this.style.setConfigProperty(a,t,o),this._update(!0)}getFeaturesetDescriptors(a){return this.style.getFeaturesetDescriptors(a)}setLights(a){if(this._lazyInitEmptyStyle(),a&&a.length===1&&a[0].type==="flat"){let t=a[0];t.properties?this.style.setFlatLight(t.properties,t.id,{}):this.style.setFlatLight({},"flat")}else this.style.setLights(a),this.painter.terrain&&(this.painter.terrain.invalidateRenderCache=!0);return this._update(!0)}getLights(){let a=this.style.getLights()||[];return a.length===0&&a.push({id:this.style.light.id,type:"flat",properties:this.style.getFlatLight()}),a}setLight(a,t={}){return console.log("The `map.setLight` function is deprecated, prefer using `map.setLights` with `flat` light type instead."),this.setLights([{id:"flat",type:"flat",properties:a}])}getLight(){return console.log("The `map.getLight` function is deprecated, prefer using `map.getLights` instead."),this.style.getFlatLight()}setTerrain(a){return this._lazyInitEmptyStyle(),!a&&this.transform.projection.requiresDraping?this.style.setTerrainForDraping():this.style.setTerrain(a),this._averageElevationLastSampledAt=-1/0,this._update(!0)}getTerrain(){return this.style?this.style.getTerrain():null}setFog(a){return this._lazyInitEmptyStyle(),this.style.setFog(a),this._update(!0)}getFog(){return this.style?this.style.getFog():null}setSnow(a){return this._lazyInitEmptyStyle(),this.style.setSnow(a),this._update(!0)}getSnow(){return this.style?this.style.getSnow():null}setRain(a){return this._lazyInitEmptyStyle(),this.style.setRain(a),this._update(!0)}getRain(){return this.style?this.style.getRain():null}setColorTheme(a){return this._lazyInitEmptyStyle(),this.style.setColorTheme(a),this._update(!0)}setImportColorTheme(a,t){return this._lazyInitEmptyStyle(),this.style.setImportColorTheme(a,t),this._update(!0)}setCamera(a){return this.style.setCamera(a),this._triggerCameraUpdate(a)}getNearClipOffset(){return this.transform.nearClipOffset}setNearClipOffset(a){let t=this.transform.nearClipOffset!==a;return this.transform.nearClipOffset=a,this._update(t)}_triggerCameraUpdate(a){return this._update(this.transform.setOrthogra
3288phicProjectionAtLowPitch(a["camera-projection"]==="orthographic"))}getCamera(){return this.style.camera}_queryFogOpacity(a){return this.style&&this.style.fog?this.style.fog.getOpacityAtLatLng(h.aX.convert(a),this.transform):0}setFeatureState(a,t){return a.source&&!this._isValidId(a.source)?this:(this.style.setFeatureState(a,t),this._update())}removeFeatureState(a,t){return a.source&&!this._isValidId(a.source)?this:(this.style.removeFeatureState(a,t),this._update())}getFeatureState(a){return a.source&&!this._isValidId(a.source)?null:this.style.getFeatureState(a)}_selectIndoorFloor(a){this.style.indoorManager.selectFloor(a)}_setIndoorActiveFloorsVisibility(a){this.style.indoorManager.setActiveFloorsVisibility(a)}getIndoorTileOptions(a,t){return this.style&&this.style.isIndoorEnabled()?this.style.indoorManager.getIndoorTileOptions(a,t):null}_updateContainerDimensions(){if(!this._container)return;let a=this._container.getBoundingClientRect().width||400,t=this._container.getBoundingClientRect().height||300,o,c,d,m=this._container;for(;m&&(!c||!d);){let _=window.getComputedStyle(m).transform;_&&_!=="none"&&(o=_.match(Im)[1].split(", "),o[0]&&o[0]!=="0"&&o[0]!=="1"&&(c=o[0]),o[3]&&o[3]!=="0"&&o[3]!=="1"&&(d=o[3])),m=m.parentElement}this._containerWidth=c?Math.abs(a/c):a,this._containerHeight=d?Math.abs(t/d):t}_detectMissingCSS(){window.getComputedStyle(this._missingCSSCanary).getPropertyValue("background-color")!=="rgb(250, 128, 114)"&&h.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 a=this._container;a.classList.add("mapboxgl-map"),(this._missingCSSCanary=Rt("div","mapboxgl-canary",a)).style.visibility="hidden",this._detectMissingCSS();let t=this._canvasContainer=Rt("div","mapboxgl-canvas-container",a);this._canvas=Rt("canvas","mapboxgl-canvas",t),this._interactive&&(t.classList.add("mapboxgl-interactive"),this._canvas.setAttribute("tabindex","0")),this._canvas.addEventListener("webglcontextlost",this._contextLost,!1),this._canvas.addEventListener("webglcontextrestored",this._contextRestored,!1),this._canvas.setAttribute("aria-label",this._getUIString("Map.Title")),this._canvas.setAttribute("role","region"),this._updateContainerDimensions(),this._resizeCanvas(this._containerWidth,this._containerHeight);let o=this._controlContainer=Rt("div","mapboxgl-control-container",a),c=this._controlPositions={};["top-left","top","top-right","right","bottom-right","bottom","bottom-left","left"].forEach(d=>{c[d]=Rt("div",`mapboxgl-ctrl-${d}`,o)}),this._container.addEventListener("scroll",this._onMapScroll,!1)}_resizeCanvas(a,t){let o=h.o.devicePixelRatio||1;this._canvas.width=o*Math.ceil(a),this._canvas.height=o*Math.ceil(t),this._canvas.style.width=`${a}px`,this._canvas.style.height=`${t}px`}_addMarker(a){this._markers.push(a)}_removeMarker(a){let t=this._markers.indexOf(a);t!==-1&&this._markers.splice(t,1)}_addPopup(a){this._popups.push(a)}_removePopup(a){let t=this._popups.indexOf(a);t!==-1&&this._popups.splice(t,1)}_setupPainter(){let a=Object.assign({},Jr.supported.webGLContextAttributes,{failIfMajorPerformanceCaveat:this._failIfMajorPerformanceCaveat,preserveDrawingBuffer:this._preserveDrawingBuffer,antialias:this._antialias||!1}),t=this._canvas.getContext("webgl2",a);t?(Ho(t,!0),this.painter=new tp(t,this._contextCreateOptions,this.transform,this._scaleFactor,this._worldview),this.on("data",o=>{if(o.dataType==="source"){let c=this.transform.elevation?this.transform.elevation._source():null;c&&o.sourceCacheId===c.id&&this.style&&this.style._setLabelPlacementStale(),this.painter.setTileLoadedFlag(!0)}}),h.k.testSupport(t)):this.fire(new h.y(new Error("Failed to initialize WebGL")))}_contextLost(a){a.preventDefault(),this._frame&&(this._frame.cancel(),this._frame=null),this.style&&this.style.handleContextLost(),this.fire(new h.z("webglcontextlost",{originalEvent:a}))}_contextRestored(a){this._setupPainter(),this.painter.resize(Math.ceil(this._containerWidth),Math.ceil(this._containerHeight)),this._updateTerrain(),this.style&&(this.style.clearLayers(),this.style.imageManager.destroyAtlasTextures(),this.style.imageManager.imageAtlasCache.destroyTextures(),this.style.reloadModels(),this.style.clearSources()),this._update(),this.fire(new h.z("webglcontextrestored",{originalEvent:a}))}_onMapScroll(a){if(a.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(a){return this.style?(this._styleDirty=this._styleDirty||a,this._sourcesDirty=!0,this.triggerRepaint(),this):this}_requestRenderFrame(a){return this._update(),this._renderTaskQueue.add(a)}_cancelRenderFrame(a){this._renderTaskQueue.remove(a)}_requestDomTask(a){!this.loaded()||this.loaded()&&!this.isMoving()?a():this._domRenderTaskQueue.add(a)}_render(a){let t;this.fire(new h.z("renderstart")),++this._frameId;let o=this.painter.context.extTimerQuery,c=h.o.now(),d=this.painter.context.gl;if(this.listens("gpu-timing-frame")&&(t=d.createQuery(),d.beginQuery(o.TIME_ELAPSED_EXT,t)),this.painter.context.setDirty(),this.painter.setBaseState(),(this.isMoving()||this.isRotating()||this.isZooming())&&
3288(this._interactionRange[0]=Math.min(this._interactionRange[0],performance.now()),this._interactionRange[1]=Math.max(this._interactionRange[1],performance.now())),this._renderTaskQueue.run(a),this._domRenderTaskQueue.run(a),this._removed)return;this._updateProjectionTransition();let m=this._isInitialLoad?0:this._fadeDuration;if(this.style&&this._styleDirty){this._styleDirty=!1;let v=this.transform.zoom,T=this.transform.pitch,I=h.o.now(),P=new h.ab(v,{now:I,fadeDuration:m,pitch:T,transition:this.style.transition,worldview:this._worldview});this.style.update(P)}this.style&&this.style.hasFogTransition()&&(this.style._markersNeedUpdate=!0,this._sourcesDirty=!0);let _=!1;if(this.style&&this._sourcesDirty?(this._sourcesDirty=!1,this.painter._updateFog(this.style),this._updateTerrain(),_=this._updateAverageElevation(c),this.style.updateSources(this.transform),this.style.updateImageProviders(),this.isMoving()||this._forceMarkerAndPopupUpdate()):_=this._updateAverageElevation(c),this.style&&(this._placementDirty=this.style._updatePlacement(this.painter.transform,this.showCollisionBoxes,m,this._crossSourceCollisions,this.painter.replacementSource)),this.style&&this.painter.render(this.style,{showTileBoundaries:this.showTileBoundaries,showParseStatus:this.showParseStatus,wireframe:{terrain:this.showTerrainWireframe,layers2D:this.showLayers2DWireframe,layers3D:this.showLayers3DWireframe},showOverdrawInspector:this._showOverdrawInspector,showQueryGeometry:!!this._showQueryGeometry,showTileAABBs:this.showTileAABBs,rotating:this.isRotating(),zooming:this.isZooming(),moving:this.isMoving(),fadeDuration:m,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 h.z("render")),this.loaded()&&!this._loaded&&(this._loaded=!0,gi.mark(ln.load),this.fire(new h.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(),t){let v=h.o.now()-c;d.endQuery(o.TIME_ELAPSED_EXT),setTimeout(()=>{let T=d.getQueryParameter(t,d.QUERY_RESULT)/1e6;d.deleteQuery(t),this.fire(new h.z("gpu-timing-frame",{cpuTime:v,gpuTime:T}))},50)}if(this.listens("gpu-timing-layer")){let v=this.painter.collectGpuTimers();setTimeout(()=>{let T=this.painter.queryGpuTimers(v);this.fire(new h.z("gpu-timing-layer",{layerTimes:T}))},50)}if(this.listens("gpu-timing-deferred-render")){let v=this.painter.collectDeferredRenderGpuQueries();setTimeout(()=>{let T=this.painter.queryGpuTimeDeferredRender(v);this.fire(new h.z("gpu-timing-deferred-render",{gpuTime:T}))},50)}let y=this._sourcesDirty||this._styleDirty||this._placementDirty||_;if(y||this._repaint)this.triggerRepaint();else{let v=this.idle();if(v&&(_=this._updateAverageElevation(c,!0)),_)this.triggerRepaint();else{if(this._triggerFrame(!1),v&&(this.fire(new h.z("idle")),this._isInitialLoad=!1,this.speedIndexTiming)){let T=this._calculateSpeedIndex();this.fire(new h.z("speedindexcompleted",{speedIndex:T})),this.speedIndexTiming=!1}v&&this.style&&this.style.handleIdle()}}!this._loaded||this._fullyLoaded||y||(this._fullyLoaded=!0,gi.mark(ln.fullLoad),this._performanceMetricsCollection&&Xa(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(a){for(let t of this._markers)a&&!this.getRenderWorldCopies()&&(t._lngLat=t._lngLat.wrap()),t._update();for(let t of this._popups)!a||this.getRenderWorldCopies()||t._trackPointer||(t._lngLat=t._lngLat.wrap()),t._update()}_updateAverageElevation(a,t=!1){let o=d=>(this.transform.averageElevation=d,this._update(!1),!0);if(!this.painter.averageElevationNeedsEasing())return this.transform.averageElevation!==0&&o(0);let c=this.transform.elevation&&this.transform.elevation.exaggeration()!==this._averageElevationExaggeration;if(c||(t||a-this._averageElevationLastSampledAt>500)&&!this._averageElevation.isEasing(a)){let d=this.transform.averageElevation,m=this.transform.sampleAverageElevation();this.transform.elevation!=null&&(this._averageElevationExaggeration=this.transform.elevation.exaggeration()),isNaN(m)?m=0:this._averageElevationLastSampledAt=a;let _=Math.abs(d-m);if(_>1){if(this._isInitialLoad||c)return this._averageElevation.jumpTo(m),o(m);this._averageElevation.easeTo(m,a,300)}else if(_>1e-4)return this._averageElevation.jumpTo(m),o(m)}return!!this._averageElevation.isEasing(a)&&o(this._averageElevation.getValue(a))}_isTokenExpired(){return this._tokenExpiration!=null&&Date.now()>this._tokenExpiration}_revokeAuth(){let a=this.painter.context.gl;Ho(a,!1),this._logoControl instanceof wm&&this._logoControl._updateLogo(),a&&a.clear(a.DEPTH_BUFFER_BIT|a.COLOR_BUFFER_BIT|a.STENCIL_BUFFER_BIT),this._silenceAuthErrors||this.fire(new h.y(new Error("A valid Mapbox access token is required to use Mapbox GL JS. To create an account or a new access token, visit https://account.mapbox.com/")))}_authenticate(){Ya(this._getMapId(),this._requestManager._skuToken,this._requestManager._customAccessToken,a=>{a&&(a.message!==tn&&a.status!==401||this._revokeAuth())}),this._isTokenExpired()&&this._revokeAuth(),Wn(this._getMapId(),this._requestManager._skuToken,this._requestManager._customAccessToken,()=>{})}_postStyleLoadEvent(){this.style.globalId&&Oi(this._requestManager._customAccessToken,{map:this,style:this.style.globalId,importedStyles:this.style.getImportGlobalIds()})}_postStyleWithAppearanceEvent(){this.style.globalId&&this.style.hasAppearances()&&Za(this._requestManager._customAccessToken)}_postAddingAppearancesToStyleEvent(){Mo(this._requestManager._customAccessToken)}_updateTerrain(){let a=this._isDragging();this.painter.updateTerrain(this.style,a)}_calculateSpeedIndex(){let a=this.painter.canvasCopy(),t=this.painter.getCanvasCopiesAndTimestamps();t.timeStamps.push(performance.now());let o=this.painter.context.gl,c=o.createFramebuffer();function d(m){o.framebufferTexture2D(o.FRAMEBUFFER,o.COLOR_ATTACHMENT0,o.TEXTURE_2D,m,0);let _=new Uint8Array(o.drawingBufferWidth*o.drawingBufferHeight*4);return o.readPixels(0,0,o.drawingBufferWidth,o.drawingBufferHeight,o.RGBA,o.UNSIGNED_BYTE,_),_}return o.bindFramebuffer(o.FRAMEBUFFER,c),this._canvasPixelComparison(d(a),t.canvasCopies.map(d),t.timeStamps)}_canvasPixelComparison(a,t,o){let c=o[1]-o[0],d=a.length/4;for(let m=0;m<t.length;m++){let _=t[m],y=0;for(let v=0;v<_.length;v+=4)_[v]===a[v]&&_[v+1]===a[v+1]&&_[v+2]===a[v+2]&&_[v+3]===a[v+3]&&(y+=1);c+=(o[m+2]-o[m+1])*(1-y/d)}return c}remove(){if(this._removed)return;this._hash&&this._hash.remove();for(let t of this._controls)t.onRemove(this);this._controls=[],this._frame&&(this._frame.cancel(),this._frame=null),this._renderTaskQueue.clear(),this._domRenderTaskQueue.clear(),this.style&&this.style.destroy(),this.painter.destroy(),this.handlers&&this.handlers.destroy(),this.handlers=void 0,this.setStyle(null),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 a=this.painter.context.gl.getExtension("WEBGL_lose_context");a&&a.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),oa.delete(this.painter.context.gl),ra.remove(),Qi.remove(),this._removed=!0,this.fire(new h.z("remove"))}triggerRepaint(){this._triggerFrame(!0)}_triggerFrame(a){this._renderNextFrame=this._renderNextFrame||a,this.style&&!this._frame&&(this._frame=h.o.frame(t=>{let o=!!this._renderNextFrame;this._frame=null,this._renderNextFrame=null,o&&this._render(t)}))}_preloadTiles(a){let t=this.style?this.style.getSourceCaches():[];return h.ao(t,(o,c)=>o._preloadTiles(a,c),()=>{this.triggerRepaint()}),this}_onWindowOnline(){this._update()}_onWindowResize(a){this._trackResize&&this.resize({originalEvent:a})._update()}_onVisibilityChange(){document.visibilityState==="hidden"&&this._visibilityHidden++}get showTileBoundaries(){return!!this._showTileBoundaries}set showTileBoundaries(a){this._showTileBoundaries!==a&&(this._showTileBoundaries=a,this._update())}get showParseStatus(){return!!this._showParseStatus}set showParseStatus(a){this._showParseStatus!==a&&(this._showParseStatus=a,this._update())}get showTerrainWireframe(){return!!this._showTerrainWireframe}set showTerrainWireframe(a){this._showTerrainWireframe!==a&&(this._showTerrainWireframe=a,this._update())}get showLayers2DWireframe(){return!!this._showLayers2DWireframe}set showLayers2DWireframe(a){this._showLayers2DWireframe!==a&&(this._showLayers2DWireframe=a,this._update())}get showLayers3DWireframe(){return!!this._showLayers3DWireframe}set showLayers3DWireframe(a){this._showLayers3DWireframe!==a&&(this._showLayers3DWireframe=a,this._update())}get showElevationIdDebug(){return!!this.painter&&this.painter._debugParams.showElevationIdDebug}set showElevationIdDebug(a){this.painter&&this.painter._debugParams.showElevationIdDebug!==a&&(this.painter._debugParams.showElevationIdDebug=a,this.style&&a?this.style._reloadSources():this._update())}get speedIndexTiming(){return!!this._speedIndexTiming}set speedIndexTiming(a){this._speedIndexTiming!==a&&(this._speedIndexTiming=a,this._update())}get showPadding(){return!!this._showPadding}set showPadding(a){this._showPadding!==a&&(this._showPadding=a,this._update())}get showCollisionBoxes(){return!!this._showCollisionBoxes}set showCollisionBoxes(a){this._showCollisionBoxes!==a&&(this._showCollisionBoxes=a,this.style&&a?this.style._reloadSources():this._update())}get showOverdrawInspector(){return!!this._showOverdrawInspector}set showOverdrawInspector(a){this._showOverdrawInspector!==a&&(this._showOverdrawInspector=a,this._update())}get repaint(){return!!this._repaint}set repaint(a){this._repaint!==a&&(this._repaint=a,this.triggerRepaint())}get vertices(){return!!this._vertices}set vertices(a){this._vertices=a,this._update()}get showTileAABBs(){return!!this._showTileAABBs}set showTileAABBs(a){this._showTileAABBs!==a&&(this._showTileAABBs=a,a&&this._update())}_setCacheLimits(a,t){h.f1(a,t)}get version(){return U}},NavigationControl:class{constructor(a={}){this.options=Object.assign({},vg,a),this._container=Rt("div","mapboxgl-ctrl mapboxgl-ctrl-group"),this._container.addEventListener("contextmenu",t=>t.preventDefault()),this.options.showZoom&&(h.b0(["_setButtonTitle","_updateZoomButtons"],this),this._zoomInButton=this._createButton("mapboxgl-ctrl-zoom-in",t=>{this._map&&this._map.zoomIn({},{originalEvent:t})}),Rt("span","mapboxgl-ctrl-icon",this._zoomInButton).setAttribute("aria-hidden","true"),this._zoomOutButton=this._createButton("mapboxgl-ctrl-zoom-out",t=>{this._map&&this._map.zoomOut({},{originalEvent:t})}),Rt("span","mapboxgl-ctrl-icon",this._zoomOutButton).setAttribute("aria-hidden","true")),this.options.showCompass&&(h.b0(["_rotateCompassArrow"],this),this._compass=this._createButton("mapboxgl-ctrl-compass",t=>{let o=this._map;o&&(this.options.visualizePitch?o.resetNorthPitch({},{originalEvent:t}):o.resetNorth({},{originalEvent:t}))}),this._compassIcon=Rt("span","mapboxgl-ctrl-icon",this._compass),this._compassIcon.setAttribute("aria-hidden","true"))}_updateZoomButtons(){let a=this._map;if(!a)return;let t=a.getZoom(),o=t===a.getMaxZoom(),c=t===a.getMinZoom();this._zoomInButton.disabled=o,this._zoomOutButton.disabled=c,this._zoomInButton.setAttribute("aria-disabled",o.toString()),this._zoomOutButton.setAttribute("aria-disabled",c.toString())}_rotateCompassArrow(){let a=this._map;if(!a)return;let t=this.options.visualizePitch?`scale(${1/Math.pow(Math.cos(a.transform.pitch*(Math.PI/180)
3288),.5)}) rotateX(${a.transform.pitch}deg) rotateZ(${a.transform.angle*(180/Math.PI)}deg)`:`rotate(${a.transform.angle*(180/Math.PI)}deg)`;a._requestDomTask(()=>{this._compassIcon&&(this._compassIcon.style.transform=t)})}onAdd(a){return this._map=a,this.options.showZoom&&(this._setButtonTitle(this._zoomInButton,"ZoomIn"),this._setButtonTitle(this._zoomOutButton,"ZoomOut"),a.on("zoom",this._updateZoomButtons),this._updateZoomButtons()),this.options.showCompass&&(this._setButtonTitle(this._compass,"ResetBearing"),this.options.visualizePitch&&a.on("pitch",this._rotateCompassArrow),a.on("rotate",this._rotateCompassArrow),this._rotateCompassArrow(),this._handler=new ss(a,this._compass,this.options.visualizePitch)),this._container}onRemove(){let a=this._map;a&&(this._container.remove(),this.options.showZoom&&a.off("zoom",this._updateZoomButtons),this.options.showCompass&&(this.options.visualizePitch&&a.off("pitch",this._rotateCompassArrow),a.off("rotate",this._rotateCompassArrow),this._handler&&this._handler.off(),this._handler=void 0),this._map=void 0)}_createButton(a,t){let o=Rt("button",a,this._container);return o.type="button",o.addEventListener("click",t),o}_setButtonTitle(a,t){if(!this._map)return;let o=this._map._getUIString(`NavigationControl.${t}`);a.setAttribute("aria-label",o),a.firstElementChild&&a.firstElementChild.setAttribute("title",o)}},GeolocateControl:class extends h.E{constructor(a={}){super();let t=navigator.geolocation;this.options=Object.assign({geolocation:t},Am,a),h.b0(["_onSuccess","_onError","_onZoom","_finish","_setupUI","_updateCamera","_updateMarker","_updateMarkerRotation","_onDeviceOrientation"],this),this._updateMarkerRotationThrottled=Zc(this._updateMarkerRotation,20),this._numberOfWatches=0}onAdd(a){return this._map=a,this._container=Rt("div","mapboxgl-ctrl mapboxgl-ctrl-group"),this._checkGeolocationSupport(this._setupUI),this._container}onRemove(){this._clearRequestTimeout(),this._geolocationWatchID!==void 0&&(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(a){let t=(o=!!this.options.geolocation)=>{this._supportsGeolocation=o,a(o)};this._supportsGeolocation!==void 0?a(this._supportsGeolocation):navigator.permissions!==void 0?navigator.permissions.query({name:"geolocation"}).then(o=>t(o.state!=="denied")).catch(()=>t()):t()}_isOutOfMapMaxBounds(a){let t=this._map.getMaxBounds(),o=a.coords;return!!t&&(o.longitude<t.getWest()||o.longitude>t.getEast()||o.latitude<t.getSouth()||o.latitude>t.getNorth())}_setErrorState(){switch(this._watchState){case"WAITING_ACTIVE":this._watchState="ACTIVE_ERROR",this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-active"),this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-active-error");break;case"ACTIVE_LOCK":this._watchState="ACTIVE_ERROR",this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-active"),this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-active-error"),this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-waiting");break;case"BACKGROUND":this._watchState="BACKGROUND_ERROR",this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-background"),this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-background-error"),this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-waiting")}}_onSuccess(a){if(this._map){if(this._clearRequestTimeout(),this._isOutOfMapMaxBounds(a))return this._setErrorState(),this.fire(new h.z("outofmaxbounds",a)),this._updateMarker(),void this._finish();if(this.options.trackUserLocation)switch(this._lastKnownPosition=a,this._watchState){case"WAITING_ACTIVE":case"ACTIVE_LOCK":case"ACTIVE_ERROR":this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-waiting"),this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-active-error"),this.options.followUserLocation?(this._watchState="ACTIVE_LOCK",this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-active")):(this._watchState="BACKGROUND",this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-background"));break;case"BACKGROUND":case"BACKGROUND_ERROR":this._watchState="BACKGROUND",this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-waiting"),this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-background-error"),this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-background")}this.options.showUserLocation&&this._watchState!=="OFF"&&this._updateMarker(a),this.options.followUserLocation&&(!this.options.trackUserLocation||this._watchState==="ACTIVE_LOCK")&&this._updateCamera(a),this.options.showUserLocation&&this._userLocationDotMarker.removeClassName("mapboxgl-user-location-dot-stale"),this.fire(new h.z("geolocate",Object.assign({coords:a.coords,timestamp:a.timestamp},a.toJSON?{toJSON:a.toJSON.bind(a)}:{}))),this._finish()}}_updateCamera(a){let t=new h.aX(a.coords.longitude,a.coords.latitude),o=a.coords.accuracy,c=this._map.getBearing(),d=Object.assign({bearing:c},this.options.fitBoundsOptions);this._map.fitBounds(t.toBounds(o),d,{geolocateSource:!0})}_updateMarker(a){if(a){let t=new h.aX(a.coords.longitude,a.coords.latitude);this._accuracyCircleMarker.setLngLat(t).addTo(this._map),this._userLocationDotMarker.setLngLat(t).addTo(this._map),this._accuracy=a.coords.accuracy,this.options.showUserLocation&&this.options.showAccuracyCircle&&this._updateCircleRadius()}else this._userLocationDotMarker.remove(),this._accuracyCircleMarker.remove()}_updateCircleRadius(){let a=this._map.transform,t=h.bY(1,a._center.lat)*a.worldSize,o=Math.ceil(2*this._accuracy*t);this._circleElement.style.width=`${o}px`,this._circleElement.style.height=`${o}px`}_onZoom(){this.options.showUserLocation&&this.options.showAccuracyCircle&&this._updateCircleRadius()}_updateMarkerRotation(){this._userLocationDotMarker&&typeof this._heading=="number"?(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(a){if(this._map){if(this._clearRequestTimeout(),this.options.trackUserLocation)if(
3288a.code===1){this._watchState="OFF",this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-waiting"),this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-active"),this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-active-error"),this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-background"),this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-background-error"),this._geolocateButton.disabled=!0;let t=this._map._getUIString("GeolocateControl.LocationNotAvailable");this._geolocateButton.setAttribute("aria-label",t),this._geolocateButton.firstElementChild&&this._geolocateButton.firstElementChild.setAttribute("title",t),this._geolocationWatchID!==void 0&&this._clearWatch()}else{if(a.code===3&&this._noTimeout)return;this._setErrorState()}this._watchState!=="OFF"&&this.options.showUserLocation&&this._userLocationDotMarker.addClassName("mapboxgl-user-location-dot-stale"),this.fire(new h.z("error",{code:a.code,message:a.message,PERMISSION_DENIED:a.PERMISSION_DENIED,POSITION_UNAVAILABLE:a.POSITION_UNAVAILABLE,TIMEOUT:a.TIMEOUT})),this._finish()}}_finish(){this._timeoutId&&clearTimeout(this._timeoutId),this._timeoutId=void 0}_startRequestTimeout(){this._clearRequestTimeout();let a=this.options.positionOptions.timeout;a&&(this._requestTimeoutId=window.setTimeout(()=>{this._onError({code:3,message:"Geolocation request timed out"})},a))}_clearRequestTimeout(){this._requestTimeoutId!==void 0&&(clearTimeout(this._requestTimeoutId),this._requestTimeoutId=void 0)}_setupUI(a){if(this._map!==void 0){if(this._container.addEventListener("contextmenu",t=>t.preventDefault()),this._geolocateButton=Rt("button","mapboxgl-ctrl-geolocate",this._container),Rt("span","mapboxgl-ctrl-icon",this._geolocateButton).setAttribute("aria-hidden","true"),this._geolocateButton.type="button",a===!1){h.w("Geolocation support is not available so the GeolocateControl will be disabled.");let t=this._map._getUIString("GeolocateControl.LocationNotAvailable");this._geolocateButton.disabled=!0,this._geolocateButton.setAttribute("aria-label",t),this._geolocateButton.firstElementChild&&this._geolocateButton.firstElementChild.setAttribute("title",t)}else{let t=this._map._getUIString("GeolocateControl.FindMyLocation");this._geolocateButton.setAttribute("aria-label",t),this._geolocateButton.firstElementChild&&this._geolocateButton.firstElementChild.setAttribute("title",t)}this.options.trackUserLocation&&(this._geolocateButton.setAttribute("aria-pressed","false"),this._watchState="OFF"),this.options.showUserLocation&&(this._dotElement=Rt("div","mapboxgl-user-location"),this._dotElement.appendChild(Rt("div","mapboxgl-user-location-dot")),this._dotElement.appendChild(Rt("div","mapboxgl-user-location-heading")),this._userLocationDotMarker=new fh({element:this._dotElement,rotationAlignment:"map",pitchAlignment:"map"}),this._circleElement=Rt("div","mapboxgl-user-location-accuracy-circle"),this._accuracyCircleMarker=new fh({element:this._circleElement,pitchAlignment:"map"}),this.options.trackUserLocation&&(this._watchState="OFF"),this._map.on("zoom",this._onZoom)),this._geolocateButton.addEventListener("click",this.trigger.bind(this)),this._setup=!0,this.options.showButton||(this._container.style.display="none"),this.options.trackUserLocation&&this._map.on("movestart",t=>{t.geolocateSource||this._watchState!=="ACTIVE_LOCK"||t.originalEvent&&t.originalEvent.type==="resize"||(this._watchState="BACKGROUND",this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-background"),this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-active"),this.fire(new h.z("trackuserlocationend")))})}}_onDeviceOrientation(a){this._userLocationDotMarker&&(a.webkitCompassHeading?this._heading=a.webkitCompassHeading:a.absolute===!0&&(this._heading=-1*a.alpha),this._updateMarkerRotationThrottled())}trigger(){if(!this._setup)return h.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 h.z("trackuserlocationstart"));break;
3288case"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 h.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 h.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(this._watchState==="OFF"&&this._geolocationWatchID!==void 0)this._clearWatch();else if(this._geolocationWatchID===void 0){let a;this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-waiting"),this._geolocateButton.setAttribute("aria-pressed","true"),this._numberOfWatches++,this._numberOfWatches>1?(a={maximumAge:6e5,timeout:0},this._noTimeout=!0):(a=this.options.positionOptions,this._noTimeout=!1),this._geolocationWatchID=this.options.geolocation.watchPosition(this._onSuccess,this._onError,a),this._startRequestTimeout(),this.options.showUserHeading&&this._addDeviceOrientationListener()}}else this.options.geolocation.getCurrentPosition(this._onSuccess,this._onError,this.options.positionOptions),this._startRequestTimeout(),this._timeoutId=window.setTimeout(this._finish,1e4);return!0}setFollowUserLocation(a){return this.options.followUserLocation=a??Am.followUserLocation,this.options.trackUserLocation&&this._watchState!=="OFF"&&(this.options.followUserLocation?this._watchState!=="BACKGROUND"&&this._watchState!=="BACKGROUND_ERROR"||(this._watchState="ACTIVE_LOCK",this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-background"),this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-background-error"),this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-active"),this._lastKnownPosition&&this._updateCamera(this._lastKnownPosition),this.fire(new h.z("trackuserlocationstart"))):this._watchState!=="ACTIVE_LOCK"&&this._watchState!=="ACTIVE_ERROR"||(this._watchState="BACKGROUND",this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-active"),this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-active-error"),this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-background"),this.fire(new h.z("trackuserlocationend")))),this}_addDeviceOrientationListener(){let a=()=>{let t="ondeviceorientationabsolute"in window?"deviceorientationabsolute":"deviceorientation";window.addEventListener(t,this._onDeviceOrientation)};typeof DeviceOrientationEvent.requestPermission=="function"?DeviceOrientationEvent.requestPermission().then(t=>{t==="granted"&&a()}).catch(console.error):a()}_clearWatch(){this._clearRequestTimeout(),this.options.geolocation.clearWatch(this._geolocationWatchID),window.removeEventListener("deviceorientation",this._onDeviceOrientation),window.removeEventListener("deviceorientationabsolute",this._onDeviceOrientation),this._geolocationWatchID=void 0,this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-waiting"),this._geolocateButton.setAttribute("aria-pressed","fal
3288se"),this.options.showUserLocation&&this._updateMarker(null)}},AttributionControl:bm,ScaleControl:class{constructor(a={}){this.options=Object.assign({},Mm,a),h.b0(["_update","_setScale","setUnit"],this)}getDefaultPosition(){return"bottom-left"}_update(){let a=this.options.maxWidth||100,t=this._map,o=t._containerHeight/2,c=t._containerWidth/2-a/2,d=t.unproject([c,o]),m=t.unproject([c+a,o]),_=d.distanceTo(m);if(this.options.unit==="imperial"){let y=3.2808*_;y>5280?this._setScale(a,y/5280,"mile"):this._setScale(a,y,"foot")}else this.options.unit==="nautical"?this._setScale(a,_/1852,"nautical-mile"):_>=1e3?this._setScale(a,_/1e3,"kilometer"):this._setScale(a,_,"meter")}_setScale(a,t,o){this._map._requestDomTask(()=>{let c=function(m){let _=Math.pow(10,`${Math.floor(m)}`.length-1),y=m/_;return y=y>=10?10:y>=5?5:y>=3?3:y>=2?2:y>=1?1:function(v){let T=Math.pow(10,Math.ceil(-Math.log(v)/Math.LN10));return Math.round(v*T)/T}(y),_*y}(t),d=c/t;this._container.innerHTML=o!=="nautical-mile"?new Intl.NumberFormat(this._language,{style:"unit",unitDisplay:"short",unit:o}).format(c):`${c} ${Cm[o]}`,this._container.style.width=a*d+"px"})}onAdd(a){return this._map=a,this._language=a.getLanguage(),this._container=Rt("div","mapboxgl-ctrl mapboxgl-ctrl-scale",a.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(a){this._language=a,this._update()}setUnit(a){this.options.unit=a,this._update()}},FullscreenControl:class{constructor(a={}){this._fullscreen=!1,a&&a.container&&(a.container instanceof HTMLElement?this._container=a.container:h.w("Full screen control 'container' must be a DOM element.")),h.b0(["_onClickFullscreen","_changeIcon"],this),"onfullscreenchange"in document?this._fullscreenchange="fullscreenchange":"onwebkitfullscreenchange"in document&&(this._fullscreenchange="webkitfullscreenchange")}onAdd(a){return this._map=a,this._container||(this._container=this._map.getContainer()),this._controlContainer=Rt("div","mapboxgl-ctrl mapboxgl-ctrl-group"),this._checkFullscreenSupport()?this._setupUI():(this._controlContainer.style.display="none",h.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 a=this._fullscreenButton=Rt("button","mapboxgl-ctrl-fullscreen",this._controlContainer);Rt("span","mapboxgl-ctrl-icon",a).setAttribute("aria-hidden","true"),a.type="button",this._updateTitle(),this._fullscreenButton.addEventListener("click",this._onClickFullscreen),document.addEventListener(this._fullscreenchange,this._changeIcon)}_updateTitle(){let a=this._getTitle();this._fullscreenButton.setAttribute("aria-label",a),this._fullscreenButton.firstElementChild&&this._fullscreenButton.firstElementChild.setAttribute("title",a)}_getTitle(){return this._map._getUIString(this._isFullscreen()?"FullscreenControl.Exit":"FullscreenControl.Enter")}_isFullscreen(){return this._fullscreen}_changeIcon(){(document.fullscreenElement||document.webkitFullscreenElement)===this._container!==this._fullscreen&&(this._fullscreen=!this._fullscreen,this._fullscreenButton.classList.toggle("mapboxgl-ctrl-shrink"),this._fullscreenButton.classList.toggle("mapboxgl-ctrl-fullscreen"),this._updateTitle())}_onClickFullscreen(){this._isFullscreen()?document.exitFullscreen?document.exitFullscreen():document.webkitCancelFullScreen&&document.webkitCancelFullScreen():this._container.requestFullscreen?this._container.requestFullscreen():this._container.webkitRequestFullscreen&&this._container.webkitRequestFullscreen()}},IndoorControl:class{constructor(){h.b0(["_onIndoorUpdate","_onStyleData","_scrollUp","_scrollDown","_toggleIndoor"],this),this._visibleFloorStart=0,this._lastSelectedFloorId=null}onAdd(a){return this._map=a,this._container=Rt("div","mapboxgl-ctrl mapboxgl-ctrl-group"),this._container.style.display="none",this._map.on("styledata",this._onStyleData),this._updateConnection(),this._container}_onStyleData(){this._updateConnection()}_updateConnection(){if(this._map&&this._map.style&&this._map.style.indoorManager){let a=this._map.style.indoorManager;a.off("selector-update",this._onIndoorUpdate),a.on("selector-update",this._onIndoorUpdate),this._onIndoorUpdate(a.getControlState())}}_createButton(a,t){let o=Rt("button",a,this._container);return o.type="button",o.addEventListener("click",t),o}_setButtonTitle(a,t){a.setAttribute("aria-label",t),a.textContent=t}onRemove(){this._container&&this._container.remove(),this._map&&(this._map.off("styledata",this._onStyleData),this._map.style&&this._map.style.indoorManager.off("selector-update",this._onIndoorUpdate),this._map=null)}getDefaultPosition(){return"top-right"}_onIndoorUpdate(a){if(!a||!a.floors||a.floors.length===0)return this._model=a,void(this._container.style.display="none");let t=this._model;this._model=a,this._container.style.display="inline-block";let o=!t||t.floors.length!==a.floors.length||t.floors.some((c,d)=>c.id!==a.floors[d].id);if(o&&(this._visibleFloorStart=0,this._lastSelectedFloorId=null),a.selectedFloorId){if(a.selectedFloorId!==this._lastSelectedFloorId||o){let c=a.floors.findIndex(d=>d.id===a.selectedFloorId);if(c!==-1){let d=a.floors.length,m,_;d<=5?(m=0,_=d-1):this._visibleFloorStart===0?(m=0,_=3):this._visibleFloorStart>=d-3?(m=d-3-1,_=d-1):(m=this._visibleFloorStart,_=this._visibleFloorStart+3-1),c<m?this._visibleFloorStart=c:c>_&&(this._visibleFloorStart=c-2)}}this._lastSelectedFloorId=a.selectedFloorId}this._render()}
3288_render(){if(!this._container||!this._model||!this._model.floors)return;this._container.innerHTML="";let a=this._createButton("mapboxgl-ctrl-indoor-toggle",this._toggleIndoor);Rt("span","mapboxgl-ctrl-icon",a).setAttribute("aria-hidden","true"),this._model.activeFloorsVisible||a.classList.add("mapboxgl-ctrl-level-button-selected"),this._container.appendChild(a);let t=this._model.floors,o=t.length;if(o<=5)return void t.forEach(_=>this._createFloorButton(_));let c=this._visibleFloorStart===0,d=this._visibleFloorStart>=o-3;if(c)this._createFloorButton(t[0]);else{let _=this._createButton("mapboxgl-ctrl-arrow-up",this._scrollUp);Rt("span","mapboxgl-ctrl-icon",_).setAttribute("aria-hidden","true"),this._container.appendChild(_)}let m=[];if(m=c?t.slice(1,4):d?t.slice(this._visibleFloorStart-1,this._visibleFloorStart+3-1):t.slice(this._visibleFloorStart,this._visibleFloorStart+3),m.forEach(_=>this._createFloorButton(_)),d)this._createFloorButton(t[o-1]);else{let _=this._createButton("mapboxgl-ctrl-arrow-down",this._scrollDown);Rt("span","mapboxgl-ctrl-icon",_).setAttribute("aria-hidden","true"),this._container.appendChild(_)}}_createFloorButton(a){let t=this._createButton("mapboxgl-ctrl-level-button",()=>{let m=a.id;this._model&&this._model.selectedFloorId===m&&this._model.activeFloorsVisible||this._map&&(this._model&&!this._model.activeFloorsVisible&&this._map.style&&this._map.style.indoorManager&&this._map.style.indoorManager.setActiveFloorsVisibility(!0),this._map._selectIndoorFloor(m))}),o=(a.name||"").trim(),c=a.zIndex.toString(),d=o?Array.from(o).slice(0,3).join(""):c;this._setButtonTitle(t,d),this._model&&this._model.activeFloorsVisible&&a.id===this._model.selectedFloorId&&t.classList.add("mapboxgl-ctrl-level-button-selected"),this._container&&this._container.appendChild(t)}_toggleIndoor(){this._map&&this._map.style&&this._map.style.indoorManager&&this._model&&this._model.activeFloorsVisible&&this._map.style.indoorManager.setActiveFloorsVisibility(!1)}_scrollUp(){if(this._visibleFloorStart>0){this._visibleFloorStart--,this._visibleFloorStart===1&&(this._visibleFloorStart=0);let a=this._model&&this._model.floors||[];if(a.length>3){let t=a.length-3;this._visibleFloorStart===t-1&&(this._visibleFloorStart=t-2)}this._render()}}_scrollDown(){if(this._model&&this._model.floors){let a=this._model.floors.length-3;this._visibleFloorStart<a&&(this._visibleFloorStart++,this._visibleFloorStart===1&&(this._visibleFloorStart=2),this._visibleFloorStart===a-1&&(this._visibleFloorStart=a),this._visibleFloorStart>a&&(this._visibleFloorStart=a),this._render())}}},Popup:class extends h.E{constructor(a){super(),this.options=Object.assign(Object.create(Si),a),this._altitude=this.options.altitude,h.b0(["_update","_onClose","remove","_onMouseEvent"],this),this._classList=new Set(a&&a.className?a.className.trim().split(hp):[])}addTo(a){return this._map&&this.remove(),this._map=a,this.options.closeOnClick&&a.on("preclick",this._onClose),this.options.closeOnMove&&a.on("move",this._onClose),a.on("remove",this.remove),this._update(),a._addPopup(this),this._focusFirstElement(),this._trackPointer?(a.on("mousemove",this._onMouseEvent),a.on("mouseup",this._onMouseEvent),a._canvasContainer.classList.add("mapboxgl-track-pointer")):a.on("move",this._update),this.fire(new h.z("open")),this}isOpen(){return!!this._map}remove(){this._content&&this._content.remove(),this._container&&(this._container.remove(),this._container=void 0);let a=this._map;return a&&(a.off("move",this._update),a.off("move",this._onClose),a.off("preclick",this._onClose),a.off("click",this._onClose),a.off("remove",this.remove),a.off("mousemove",this._onMouseEvent),a.off("mouseup",this._onMouseEvent),a.off("drag",this._onMouseEvent),a._canvasContainer&&a._canvasContainer.classList.remove("mapboxgl-track-pointer"),a._removePopup(this),this._map=void 0),this.fire(new h.z("close")),this}getLngLat(){return this._lngLat}setLngLat(a){this._lngLat=h.aX.convert(a),this._pos=null,this._trackPointer=!1,this._update();let t=this._map;return t&&(t.on("move",this._update),t.off("mousemove",this._onMouseEvent),t._canvasContainer.classList.remove("mapboxgl-track-pointer")),this}getAltitude(){return this._altitude}setAltitude(a){return this._altitude=a,this._update(),this}trackPointer(){this._trackPointer=!0,this._pos=null,this._update();let a=this._map;return a&&(a.off("move",this._update),a.on("mousemove",this._onMouseEvent),a.on("drag",this._onMouseEvent),a._canvasContainer.classList.add("mapboxgl-track-pointer")),this}getElement(){return this._container}setText(a){return this.setDOMContent(document.createTextNode(a))}setHTML(a){let t=document.createDocumentFragment(),o=document.createElement("body"),c;for(o.innerHTML=a;c=o.firstChild,c;
3288)t.appendChild(c);return this.setDOMContent(t)}getMaxWidth(){return this._container&&this._container.style.maxWidth}setMaxWidth(a){return this.options.maxWidth=a,this._update(),this}setDOMContent(a){let t=this._content;if(t)for(;t.hasChildNodes();)t.firstChild&&t.removeChild(t.firstChild);else t=this._content=Rt("div","mapboxgl-popup-content",this._container||void 0);if(t.appendChild(a),this.options.closeButton){let o=this._closeButton=Rt("button","mapboxgl-popup-close-button",t);o.type="button",o.setAttribute("aria-label","Close popup"),o.innerHTML='<span aria-hidden="true">×</span>',o.addEventListener("click",this._onClose)}return this._update(),this._focusFirstElement(),this}addClassName(a){return this._classList.add(a),this._updateClassList(),this}removeClassName(a){return this._classList.delete(a),this._updateClassList(),this}setOffset(a){return this.options.offset=a,this._update(),this}toggleClassName(a){let t;return this._classList.delete(a)?t=!1:(this._classList.add(a),t=!0),this._updateClassList(),t}_onMouseEvent(a){this._update(a.point)}_getAnchor(a){if(this.options.anchor)return this.options.anchor;let t=this._map,o=this._container,c=this._pos;if(!t||!o||!c)return"bottom";let d=o.offsetWidth,m=o.offsetHeight,_=c.x<d/2,y=c.x>t.transform.width-d/2;if(c.y+a<m)return _?"top-left":y?"top-right":"top";if(c.y>t.transform.height-m){if(_)return"bottom-left";if(y)return"bottom-right"}return _?"left":y?"right":"bottom"}_updateClassList(){let a=this._container;if(!a)return;let t=[...this._classList];t.push("mapboxgl-popup"),this._anchor&&t.push(`mapboxgl-popup-anchor-${this._anchor}`),this._trackPointer&&t.push("mapboxgl-popup-track-pointer"),a.className=t.join(" ")}_update(a){let t=this._map,o=this._content;if(!t||!this._lngLat&&!this._trackPointer||!o)return;let c=this._container;if(c||(c=this._container=Rt("div","mapboxgl-popup",t.getContainer()),this._tip=Rt("div","mapboxgl-popup-tip",c),c.appendChild(o)),this.options.maxWidth&&c.style.maxWidth!==this.options.maxWidth&&(c.style.maxWidth=this.options.maxWidth),t.transform.renderWorldCopies&&!this._trackPointer&&(this._lngLat=Em(this._lngLat,this._pos,t.transform)),!this._trackPointer||a){let d=this._pos=this._trackPointer&&a instanceof h.P?a:t.project(this._lngLat,this._altitude),m=mh(this.options.offset),_=this._anchor=this._getAnchor(m.y),y=mh(this.options.offset,_),v=d.add(y).round();t._requestDomTask(()=>{this._container&&_&&(this._container.style.transform=`${Jc[_]} translate(${v.x}px,${v.y}px)`)})}if(!this._marker&&t._showingGlobe()){let d=h.f2(t.transform,this._lngLat)?0:1;this._setOpacity(d)}this._updateClassList()}_focusFirstElement(){if(!this.options.focusAfterOpen||!this._container)return;let a=this._container.querySelector(Pm);a&&a.focus()}_onClose(){this.remove()}_setOpacity(a){this._container&&(this._container.style.opacity=`${a}`),this._content&&(this._content.style.pointerEvents=a?"auto":"none")}},Marker:fh,Style:Fr,LngLat:h.aX,LngLatBounds:h.aI,Point:h.P,MercatorCoordinate:h.ad,FreeCameraOptions:Tc,Evented:h.E,config:h.g,prewarm:function(){sl().acquire(_u)},clearPrewarmedResources:function(){let a=Yo;a&&(a.isPreloaded()&&a.numActive()===1?(a.release(_u),Yo=null):console.warn("Could not clear WebWorkers since there are active Map instances that still reference it. The pre-warmed WebWorker pool can only be cleared when all map instances have been removed with map.remove()"))},get accessToken(){return h.g.ACCESS_TOKEN},set accessToken(a){h.g.ACCESS_TOKEN=a},get baseApiUrl(){return h.g.API_URL},set baseApiUrl(a){h.g.API_URL=a},get workerCount(){return Ts.workerCount},set workerCount(a){Ts.workerCount=a},get maxParallelImageRequests(){return h.g.MAX_PARALLEL_IMAGE_REQUESTS},set maxParallelImageRequests(a){h.g.MAX_PARALLEL_IMAGE_REQUESTS=a},clearStorage(a){h.fb(a)},get workerUrl(){return Kr.workerUrl},set workerUrl(a){Kr.workerUrl=a},get workerClass(){return Kr.workerClass},set workerClass(a){Kr.workerClass=a},get workerParams(){return Kr.workerParams},set workerParams(a){Kr.workerParams=a},get dracoUrl(){return h.fa()},set dracoUrl(a){h.g.DRACO_URL=h.o.resolveURL(a)},get meshoptUrl(){return h.f9()},set meshoptUrl(a){let t=h.o.resolveURL(a);h.g.MESHOPT_URL=t,h.g.MESHOPT_SIMD_URL=t},get buildingGenUrl(){return h.f8()},set buildingGenUrl(a){h.g.BUILDING_GEN_URL=h.o.resolveURL(a)},setNow:h.o.setNow,restoreNow:h.o.restoreNow}});var pn=ri;return pn})});var ea=t2(M1());var C1=Vt=>!Vt||!Vt.trim();var qy=Vt=>!(Vt==null||typeof Vt=="string"&&C1(Vt));var i2={top:60,right:30,bottom:30,left:30},Yp=new Map,P1=(Vt,ci)=>{let ri=Cr=>Cr*Math.PI/180,Zi=ea.default.LngLat.convert(Vt),pn=ea.default.LngLat.convert(ci),h=6371e3,U=ri(pn.lat-Zi.lat),ln=ri(pn.lng-Zi.lng),gi=Math.sin(U/2)**2+Math.cos(ri(Zi.lat))*Math.cos(ri(pn.lat))*Math.sin(ln/2)**2;return 2*h*Math.asin(Math.sqrt(gi))},D1=(Vt,ci)=>{let ri=Yp.get(Vt);if(!ri)throw`mapId "${Vt}" does not exist`;let{currentPositionMarker:Zi,map:pn,markers:h}=ri,U=Zi?.getLngLat()??pn.getCenter();if(U){let ln=[],gi;if(ci==="closest"){let Yr=h.map(Jr=>Jr.getLngLat()).filter(qy);Yr.sort((Jr,fs)=>P1(U,Jr)-P1(U,fs));let uo=Yr[0];uo&&(ln=[uo]),gi={top:120,right:50,bottom:80,left:50}}else ln=h.map(Yr=>Yr.getLngLat()).filter(qy),gi=i2;if(ln.length===0)return;let Cr=new ea.default.LngLatBounds;Zi&&Cr.extend(Zi.getLngLat());for(let Yr of ln)Cr.extend(Yr);ri.bounds=Cr,pn.fitBounds(Cr,{padding:gi,maxZoom:14})}},uS=Vt=>{ea.default.accessToken=Vt},hS=(Vt,ci,ri=0,Zi=0,pn=5)=>{let h=new ea.default.Map({container:Vt,style:"mapbox://styles/mapbox/streets-v12",center:[Zi,ri],zoom:pn,minZoom:3,maxZoom:16,boxZoom:!1,projection:"mercator"});return h.dragRotate.disable(),h.touchZoomRotate.disableRotation(),h.addControl(new ea.default.NavigationControl({showCompass:!1}),"bottom-right"),Yp.set(ci,{bounds:new ea.default.LngLatBounds,map:h,markers:[]}),h},dS=()=>new Promise((Vt,ci)=>
3288{if(navigator.geolocation)navigator.geolocation.getCurrentPosition(ri=>Vt({latitude:ri.coords.latitude,longitude:ri.coords.longitude}),ri=>{ri.PERMISSION_DENIED?console.warn("Access to user location has been denied"):ri.TIMEOUT?console.error("Timeout when fetching user location"):ri.POSITION_UNAVAILABLE?console.error("User location is unavailable"):console.error(`Unhandled exception when fetching user location: ${ri.code}`,ri.message),ci(`[Error code ${ri.code}] ${ri.message}`)});else{let ri="Geolocation not supported";console.error(ri),ci(ri)}}),pS=(Vt,ci)=>{let ri=Yp.get(Vt);if(!ri)throw`mapId "${Vt}" does not exist`;let{currentPositionMarker:Zi,map:pn}=ri;if(Zi)Zi.setLngLat(ci);else{let h=document.getElementById("user-position-marker"),U=new ea.default.Marker({element:h??void 0}).setLngLat(ci).addTo(pn);ri.currentPositionMarker=U}D1(Vt,"closest")},fS=Vt=>{let ci=Yp.get(Vt);if(!ci)throw`mapId "${Vt}" does not exist`;for(let ri of ci.markers){let Zi=ri.getElement();Zi&&(Zi.id=""),ri.remove()}ci.markers=[]},n2=(Vt,ci,ri)=>{let Zi=ri?.x??0,pn=ri?.y??0;if(Zi===0&&pn===0)return ci;let h=Vt.project(ci);return Vt.unproject([h.x-Zi,h.y-pn])},mS=(Vt,ci,ri=!0)=>{let Zi=Yp.get(Vt);if(!Zi)throw`mapId "${Vt}" does not exist`;let{map:pn}=Zi;for(let h of ci){let U=h.element?{element:h.element}:{},ln=new ea.default.Marker(U).setLngLat([h.position.lng,h.position.lat]).addTo(pn),gi=ln.getElement();h.element&&(gi.style.transitionProperty="background-color, color, border-color, box-shadow, outline-color, opacity, visibility, text-decoration-color"),gi.addEventListener("click",()=>{let Cr=[h.position.lng,h.position.lat];pn.panTo(n2(pn,Cr,h.panOffset))}),Zi.markers.push(ln)}ri&&D1(Vt,"all")};})(); 3289//# sourceMappingURL=mapbox.js.map
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.