@qratilabs/qrati-connect 2.30.1 → 2.31.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/element/{CrmNzHcR.js → 2RASYw2m.js} +3 -3
- package/element/{BMqLaOlf.js → 9E5bMl4h.js} +1 -1
- package/element/{bhQvNZ6X.js → B1PRJBoi.js} +2 -2
- package/element/B2ryYFFr.js +4 -0
- package/element/{R0EfjB8a.js → B4_a0yK9.js} +2 -2
- package/element/B5UCbssB2.js +36 -0
- package/element/{4cGOeNKJ.js → B6VNWZAH.js} +1 -1
- package/element/{rPRWiyD72.js → BHZLezAf2.js} +2 -2
- package/element/{4oHgfxjP.js → BHa93rAe.js} +1 -1
- package/element/{D29TjIxe2.js → BJPxuSLA2.js} +1 -1
- package/element/{Bo2w_JaR.js → BVxovwox.js} +1 -1
- package/element/{BwwxqSTC2.js → BYM2GyVF2.js} +1 -1
- package/element/Be3fjihP2.js +3 -0
- package/element/{CHZkFcYR.js → BhSnOrEj.js} +1 -1
- package/element/{CirXBSjF2.js → Bon1RRdW2.js} +21 -21
- package/element/{5bOrOtEp.js → BxQf2Aj9.js} +1 -1
- package/element/{DaRDxhWU.js → CHOgSp57.js} +3 -3
- package/element/CLnFGdWV.js +2 -0
- package/element/{BOx0cQps2.js → CQMPBmQq2.js} +1 -1
- package/element/{DFN3BTNf.js → CS8uERGc.js} +1 -1
- package/element/{HZ-pN9la.js → CXRH3zmy.js} +1 -1
- package/element/CdivXyOP.js +41 -0
- package/element/{D6aS4JIi.js → CuX3CHnz.js} +85 -85
- package/element/D6q-D1kv.js +5 -0
- package/element/{DKNkaohw.js → DIWjXG_0.js} +1 -1
- package/element/{BK-Qpeej2.js → DKxH7j1t2.js} +1 -1
- package/element/{CsXYImrD2.js → DLHvSz1a2.js} +1 -1
- package/element/{V_AyEifr2.js → DLlq90qS2.js} +1 -1
- package/element/DMTh6mDu.js +4 -0
- package/element/{DtE36mUY.js → DT0jsFeS.js} +1 -1
- package/element/D_uU1Yt72.js +16 -0
- package/element/DgRZv6hc2.js +14 -0
- package/element/{BrPNl7T5.js → Dng1_dLU.js} +1 -1
- package/element/{sqfBNWKt.js → DqAzUQcH.js} +1 -1
- package/element/{DDcMOfts.js → QxKjlE-j.js} +1 -1
- package/element/WYFR_OYu.js +4 -0
- package/element/{-yT__8Qm.js → cBUXG_uS.js} +1 -1
- package/element/{DkC6kDkj.js → fb68GFFw.js} +8 -8
- package/element/{CUXN8AXD2.js → mZxLLxIK2.js} +1 -1
- package/element/oZRYetXV.js +3 -0
- package/element/web.es.js +7 -7
- package/element/{BJc3_IFY.js → ydzHqf5r.js} +1 -1
- package/package.json +1 -1
- package/element/2UMuxiHx.js +0 -2
- package/element/Bm8666WE.js +0 -4
- package/element/BxAzHKo-2.js +0 -3
- package/element/C2ksbxMB2.js +0 -36
- package/element/C_Ur_JpP.js +0 -5
- package/element/CeXZmrQu.js +0 -4
- package/element/CgDpKQkL2.js +0 -16
- package/element/D1FCdk40.js +0 -3
- package/element/DYkEsdph.js +0 -4
- package/element/DuD5AV1D2.js +0 -13
- package/element/xvMv72y9.js +0 -41
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
var e,t,i=Object.create,r=Object.defineProperty,a=Object.getOwnPropertyDescriptor,n=Object.getOwnPropertyNames,s=Object.getPrototypeOf,o=Object.prototype.hasOwnProperty,l=(e,t)=>()=>(t||(e((t={exports:{}}).exports,t),e=null),t.exports),h=(e,t,i,s)=>{if(t&&"object"==typeof t||"function"==typeof t)for(var l,h=n(t),u=0,c=h.length;u<c;u++)l=h[u],!o.call(e,l)&&l!==i&&r(e,l,{get:(e=>t[e]).bind(null,l),enumerable:!(s=a(t,l))||s.enumerable});return e};function u(e,t){this.x=e,this.y=t}function c(){return e??=typeof OffscreenCanvas<"u"&&new OffscreenCanvas(1,1).getContext("2d")&&"function"==typeof createImageBitmap,e}u.prototype={clone(){return new u(this.x,this.y)},add(e){return this.clone()._add(e)},sub(e){return this.clone()._sub(e)},multByPoint(e){return this.clone()._multByPoint(e)},divByPoint(e){return this.clone()._divByPoint(e)},mult(e){return this.clone()._mult(e)},div(e){return this.clone()._div(e)},rotate(e){return this.clone()._rotate(e)},rotateAround(e,t){return this.clone()._rotateAround(e,t)},matMult(e){return this.clone()._matMult(e)},unit(){return this.clone()._unit()},perp(){return this.clone()._perp()},round(){return this.clone()._round()},mag(){return Math.sqrt(this.x*this.x+this.y*this.y)},equals(e){return this.x===e.x&&this.y===e.y},dist(e){return Math.sqrt(this.distSqr(e))},distSqr(e){let t=e.x-this.x,i=e.y-this.y;return t*t+i*i},angle(){return Math.atan2(this.y,this.x)},angleTo(e){return Math.atan2(this.y-e.y,this.x-e.x)},angleWith(e){return this.angleWithSep(e.x,e.y)},angleWithSep(e,t){return Math.atan2(this.x*t-this.y*e,this.x*e+this.y*t)},_matMult(e){let t=e[0]*this.x+e[1]*this.y,i=e[2]*this.x+e[3]*this.y;return this.x=t,this.y=i,this},_add(e){return this.x+=e.x,this.y+=e.y,this},_sub(e){return this.x-=e.x,this.y-=e.y,this},_mult(e){return this.x*=e,this.y*=e,this},_div(e){return this.x/=e,this.y/=e,this},_multByPoint(e){return this.x*=e.x,this.y*=e.y,this},_divByPoint(e){return this.x/=e.x,this.y/=e.y,this},_unit(){return this._div(this.mag()),this},_perp(){let e=this.y;return this.y=this.x,this.x=-e,this},_rotate(e){let t=Math.cos(e),i=Math.sin(e),r=t*this.x-i*this.y,a=i*this.x+t*this.y;return this.x=r,this.y=a,this},_rotateAround(e,t){let i=Math.cos(e),r=Math.sin(e),a=t.x+i*(this.x-t.x)-r*(this.y-t.y),n=t.y+r*(this.x-t.x)+i*(this.y-t.y);return this.x=a,this.y=n,this},_round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this},constructor:u},u.convert=function(e){if(e instanceof u)return e;if(Array.isArray(e))return new u(+e[0],+e[1]);if(void 0!==e.x&&void 0!==e.y)return new u(+e.x,+e.y);throw Error("Expected [x, y] or {x, y} point format")};var p=typeof Float32Array<"u"?Float32Array:Array;function d(){var e=new p(9);return p!=Float32Array&&(e[1]=0,e[2]=0,e[3]=0,e[5]=0,e[6]=0,e[7]=0),e[0]=1,e[4]=1,e[8]=1,e}function f(){var e=new p(16);return p!=Float32Array&&(e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[6]=0,e[7]=0,e[8]=0,e[9]=0,e[11]=0,e[12]=0,e[13]=0,e[14]=0),e[0]=1,e[5]=1,e[10]=1,e[15]=1,e}function m(e){var t=new p(16);return t[0]=e[0],t[1]=e[1],t[2]=e[2],t[3]=e[3],t[4]=e[4],t[5]=e[5],t[6]=e[6],t[7]=e[7],t[8]=e[8],t[9]=e[9],t[10]=e[10],t[11]=e[11],t[12]=e[12],t[13]=e[13],t[14]=e[14],t[15]=e[15],t}function _(e){return e[0]=1,e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[5]=1,e[6]=0,e[7]=0,e[8]=0,e[9]=0,e[10]=1,e[11]=0,e[12]=0,e[13]=0,e[14]=0,e[15]=1,e}function g(e,t){var i=t[0],r=t[1],a=t[2],n=t[3],s=t[4],o=t[5],l=t[6],h=t[7],u=t[8],c=t[9],p=t[10],d=t[11],f=t[12],m=t[13],_=t[14],g=t[15],y=i*o-r*s,v=i*l-a*s,x=i*h-n*s,b=r*l-a*o,w=r*h-n*o,T=a*h-n*l,S=u*m-c*f,P=u*_-p*f,I=u*g-d*f,M=c*_-p*m,E=c*g-d*m,A=p*g-d*_,C=y*A-v*E+x*M+b*I-w*P+T*S;return C?(C=1/C,e[0]=(o*A-l*E+h*M)*C,e[1]=(a*E-r*A-n*M)*C,e[2]=(m*T-_*w+g*b)*C,e[3]=(p*w-c*T-d*b)*C,e[4]=(l*I-s*A-h*P)*C,e[5]=(i*A-a*I+n*P)*C,e[6]=(_*x-f*T-g*v)*C,e[7]=(u*T-p*x+d*v)*C,e[8]=(s*E-o*I+h*S)*C,e[9]=(r*I-i*E-n*S)*C,e[10]=(f*w-m*x+g*y)*C,e[11]=(c*x-u*w-d*y)*C,e[12]=(o*P-s*M-l*S)*C,e[13]=(i*M-r*P+a*S)*C,e[14]=(m*v-f*b-_*y)*C,e[15]=(u*b-c*v+p*y)*C,e):null}function y(e,t,i){var r=t[0],a=t[1],n=t[2],s=t[3],o=t[4],l=t[5],h=t[6],u=t[7],c=t[8],p=t[9],d=t[10],f=t[11],m=t[12],_=t[13],g=t[14],y=t[15],v=i[0],x=i[1],b=i[2],w=i[3];return e[0]=v*r+x*o+b*c+w*m,e[1]=v*a+x*l+b*p+w*_,e[2]=v*n+x*h+b*d+w*g,e[3]=v*s+x*u+b*f+w*y,v=i[4],x=i[5],b=i[6],w=i[7],e[4]=v*r+x*o+b*c+w*m,e[5]=v*a+x*l+b*p+w*_,e[6]=v*n+x*h+b*d+w*g,e[7]=v*s+x*u+b*f+w*y,v=i[8],x=i[9],b=i[10],w=i[11],e[8]=v*r+x*o+b*c+w*m,e[9]=v*a+x*l+b*p+w*_,e[10]=v*n+x*h+b*d+w*g,e[11]=v*s+x*u+b*f+w*y,v=i[12],x=i[13],b=i[14],w=i[15],e[12]=v*r+x*o+b*c+w*m,e[13]=v*a+x*l+b*p+w*_,e[14]=v*n+x*h+b*d+w*g,e[15]=v*s+x*u+b*f+w*y,e}function v(e,t,i){var r,a,n,s,o,l,h,u,c,p,d,f,m=i[0],_=i[1],g=i[2];return t===e?(e[12]=t[0]*m+t[4]*_+t[8]*g+t[12],e[13]=t[1]*m+t[5]*_+t[9]*g+t[13],e[14]=t[2]*m+t[6]*_+t[10]*g+t[14],e[15]=t[3]*m+t[7]*_+t[11]*g+t[15]):(r=t[0],a=t[1],n=t[2],s=t[3],o=t[4],l=t[5],h=t[6],u=t[7],c=t[8],p=t[9],d=t[10],f=t[11],e[0]=r,e[1]=a,e[2]=n,e[3]=s,e[4]=o,e[5]=l,e[6]=h,e[7]=u,e[8]=c,e[9]=p,e[10]=d,e[11]=f,e[12]=r*m+o*_+c*g+t[12],e[13]=a*m+l*_+p*g+t[13],e[14]=n*m+h*_+d*g+t[14],e[15]=s*m+u*_+f*g+t[15]),e}function x(e,t,i){var r=i[0],a=i[1],n=i[2];return e[0]=t[0]*r,e[1]=t[1]*r,e[2]=t[2]*r,e[3]=t[3]*r,e[4]=t[4]*a,e[5]=t[5]*a,e[6]=t[6]*a,e[7]=t[7]*a,e[8]=t[8]*n,e[9]=t[9]*n,e[10]=t[10]*n,e[11]=t[11]*n,e[12]=t[12],e[13]=t[13],e[14]=t[14],e[15]=t[15],e}function b(e,t,i){var r=Math.sin(i),a=Math.cos(i),n=t[4],s=t[5],o=t[6],l=t[7],h=t[8],u=t[9],c=t[10],p=t[11];return t!==e&&(e[0]=t[0],e[1]=t[1],e[2]=t[2],e[3]=t[3],e[12]=t[12],e[13]=t[13],e[14]=t[14],e[15]=t[15]),e[4]=n*a+h*r,e[5]=s*a+u*r,e[6]=o*a+c*r,e[7]=l*a+p*r,e[8]=h*a-n*r,e[9]=u*a-s*r,e[10]=c*a-o*r,e[11]=p*a-l*r,e}function w(e,t,i){var r=Math.sin(i),a=Math.cos(i),n=t[0],s=t[1],o=t[2],l=t[3],h=t[8],u=t[9],c=t[10],p=t[11];return t!==e&&(e[4]=t[4],e[5]=t[5],e[6]=t[6],e[7]=t[7],e[12]=t[12],e[13]=t[13],e[14]=t[14],e[15]=t[15]),e[0]=n*a-h*r,e[1]=s*a-u*r,e[2]=o*a-c*r,e[3]=l*a-p*r,e[8]=n*r+h*a,e[9]=s*r+u*a,e[10]=o*r+c*a,e[11]=l*r+p*a,e}function T(e,t,i){var r=Math.sin(i),a=Math.cos(i),n=t[0],s=t[1],o=t[2],l=t[3],h=t[4],u=t[5],c=t[6],p=t[7];return t!==e&&(e[8]=t[8],e[9]=t[9],e[10]=t[10],e[11]=t[11],e[12]=t[12],e[13]=t[13],e[14]=t[14],e[15]=t[15]),e[0]=n*a+h*r,e[1]=s*a+u*r,e[2]=o*a+c*r,e[3]=l*a+p*r,e[4]=h*a-n*r,e[5]=u*a-s*r,e[6]=c*a-o*r,e[7]=p*a-l*r,e}Math.PI,Math.PI;var S=function(e,t,i,r,a){var n=1/Math.tan(t/2);if(e[0]=n/i,e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[5]=n,e[6]=0,e[7]=0,e[8]=0,e[9]=0,e[11]=-1,e[12]=0,e[13]=0,e[15]=0,null!=a&&a!==1/0){var s=1/(r-a);e[10]=(a+r)*s,e[14]=2*a*r*s}else e[10]=-1,e[14]=-2*r;return e},P=function(e,t,i,r,a,n,s){var o=1/(t-i),l=1/(r-a),h=1/(n-s);return e[0]=-2*o,e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[5]=-2*l,e[6]=0,e[7]=0,e[8]=0,e[9]=0,e[10]=2*h,e[11]=0,e[12]=(t+i)*o,e[13]=(a+r)*l,e[14]=(s+n)*h,e[15]=1,e};function I(){var e=new p(3);return p!=Float32Array&&(e[0]=0,e[1]=0,e[2]=0),e}function M(e){var t=new p(3);return t[0]=e[0],t[1]=e[1],t[2]=e[2],t}function E(e){var t=e[0],i=e[1],r=e[2];return Math.sqrt(t*t+i*i+r*r)}function A(e,t,i){var r=new p(3);return r[0]=e,r[1]=t,r[2]=i,r}function C(e,t,i){return e[0]=t[0]+i[0],e[1]=t[1]+i[1],e[2]=t[2]+i[2],e}function D(e,t,i){return e[0]=t[0]*i,e[1]=t[1]*i,e[2]=t[2]*i,e}function z(e,t,i,r){return e[0]=t[0]+i[0]*r,e[1]=t[1]+i[1]*r,e[2]=t[2]+i[2]*r,e}function R(e,t){var i=t[0],r=t[1],a=t[2],n=i*i+r*r+a*a;return n>0&&(n=1/Math.sqrt(n)),e[0]=t[0]*n,e[1]=t[1]*n,e[2]=t[2]*n,e}function k(e,t){return e[0]*t[0]+e[1]*t[1]+e[2]*t[2]}function L(e,t,i){var r=t[0],a=t[1],n=t[2],s=i[0],o=i[1],l=i[2];return e[0]=a*l-n*o,e[1]=n*s-r*l,e[2]=r*o-a*s,e}function F(e,t,i){var r=i[0],a=i[1],n=i[2],s=i[3],o=t[0],l=t[1],h=t[2],u=a*h-n*l,c=n*o-r*h,p=r*l-a*o;return u+=u,c+=c,p+=p,e[0]=o+s*u+a*p-n*c,e[1]=l+s*c+n*u-r*p,e[2]=h+s*p+r*c-a*u,e}function B(e,t,i,r){var a=[],n=[];return a[0]=t[0]-i[0],a[1]=t[1]-i[1],a[2]=t[2]-i[2],n[0]=a[0],n[1]=a[1]*Math.cos(r)-a[2]*Math.sin(r),n[2]=a[1]*Math.sin(r)+a[2]*Math.cos(r),e[0]=n[0]+i[0],e[1]=n[1]+i[1],e[2]=n[2]+i[2],e}function O(e,t,i,r){var a=[],n=[];return a[0]=t[0]-i[0],a[1]=t[1]-i[1],a[2]=t[2]-i[2],n[0]=a[2]*Math.sin(r)+a[0]*Math.cos(r),n[1]=a[1],n[2]=a[2]*Math.cos(r)-a[0]*Math.sin(r),e[0]=n[0]+i[0],e[1]=n[1]+i[1],e[2]=n[2]+i[2],e}function V(e,t,i,r){var a=[],n=[];return a[0]=t[0]-i[0],a[1]=t[1]-i[1],a[2]=t[2]-i[2],n[0]=a[0]*Math.cos(r)-a[1]*Math.sin(r),n[1]=a[0]*Math.sin(r)+a[1]*Math.cos(r),n[2]=a[2],e[0]=n[0]+i[0],e[1]=n[1]+i[1],e[2]=n[2]+i[2],e}var j=function(e,t,i){return e[0]=t[0]-i[0],e[1]=t[1]-i[1],e[2]=t[2]-i[2],e},N=E;function U(e,t,i){var r=t[0],a=t[1],n=t[2],s=t[3];return e[0]=i[0]*r+i[4]*a+i[8]*n+i[12]*s,e[1]=i[1]*r+i[5]*a+i[9]*n+i[13]*s,e[2]=i[2]*r+i[6]*a+i[10]*n+i[14]*s,e[3]=i[3]*r+i[7]*a+i[11]*n+i[15]*s,e}I();function G(){var e=new p(4);return p!=Float32Array&&(e[0]=0,e[1]=0,e[2]=0),e[3]=1,e}function $(e,t,i,r){var a=arguments.length>4&&void 0!==arguments[4]?arguments[4]:"zyx",n=Math.PI/360;t*=n,r*=n,i*=n;var s=Math.sin(t),o=Math.cos(t),l=Math.sin(i),h=Math.cos(i),u=Math.sin(r),c=Math.cos(r);switch(a){case"xyz":e[0]=s*h*c+o*l*u,e[1]=o*l*c-s*h*u,e[2]=o*h*u+s*l*c,e[3]=o*h*c-s*l*u;break;case"xzy":e[0]=s*h*c-o*l*u,e[1]=o*l*c-s*h*u,e[2]=o*h*u+s*l*c,e[3]=o*h*c+s*l*u;break;case"yxz":e[0]=s*h*c+o*l*u,e[1]=o*l*c-s*h*u,e[2]=o*h*u-s*l*c,e[3]=o*h*c+s*l*u;break;case"yzx":e[0]=s*h*c+o*l*u,e[1]=o*l*c+s*h*u,e[2]=o*h*u-s*l*c,e[3]=o*h*c-s*l*u;break;case"zxy":e[0]=s*h*c-o*l*u,e[1]=o*l*c+s*h*u,e[2]=o*h*u+s*l*c,e[3]=o*h*c-s*l*u;break;case"zyx":e[0]=s*h*c-o*l*u,e[1]=o*l*c+s*h*u,e[2]=o*h*u-s*l*c,e[3]=o*h*c+s*l*u;break;default:throw Error("Unknown angle order "+a)}return e}!function(){var e=new p(4);p!=Float32Array&&(e[0]=0,e[1]=0,e[2]=0,e[3]=0)}();var Z=function(e,t,i,r){var a=new p(4);return a[0]=e,a[1]=t,a[2]=i,a[3]=r,a};function q(){var e=new p(2);return p!=Float32Array&&(e[0]=0,e[1]=0),e}function W(e,t){var i=new p(2);return i[0]=e,i[1]=t,i}function H(e,t,i){return e[0]=t[0]*i,e[1]=t[1]*i,e}function X(e){var t=e[0],i=e[1];return Math.sqrt(t*t+i*i)}function Y(e){return e[0]=0,e[1]=0,e}I(),A(1,0,0),A(0,1,0),G(),G(),d();var K=function(e){var t=e[0],i=e[1];return t*t+i*i};q();var J=8192;function Q(e,t,i){return t*(J/(e.tileSize*2**(i-e.tileID.overscaledZ)))}function ee(e){return e instanceof Error?e:Error("string"==typeof e?e:String(e))}function te(){/* @__PURE__ */
|
|
2
|
+
return new Float64Array(4)}function ie(){/* @__PURE__ */
|
|
3
|
+
return new Float64Array(3)}function re(){/* @__PURE__ */
|
|
4
|
+
return new Float64Array(16)}function ae(){let e=/* @__PURE__ */new Float64Array(16);return _(e),e}function ne(){let e=/* @__PURE__ */new Float32Array(16);return _(e),e}function se(e,t,i,r,a=!1){if(!i[0]&&!i[1])return[0,0];let n=a?"map"===r?-e.bearingInRadians:0:"viewport"===r?e.bearingInRadians:0;if(n){let e=Math.sin(n),t=Math.cos(n);i=[i[0]*t-i[1]*e,i[0]*e+i[1]*t]}return[a?i[0]:Q(t,i[0],e.zoom),a?i[1]:Q(t,i[1],e.zoom)]}function oe(e,t){return e[0]*t[0]+e[1]*t[1]+e[2]*t[2]+e[3]}function le(e,t,i){let r=function(e){var t=e[3],i=e[4],r=e[5],a=e[6],n=e[7],s=e[8];return e[0]*(s*i-r*n)+e[1]*(-s*t+r*a)+e[2]*(n*t-i*a)}([e[0],e[1],e[2],t[0],t[1],t[2],i[0],i[1],i[2]]);if(0===r)return null;let a=L([],[t[0],t[1],t[2]],[i[0],i[1],i[2]]),n=L([],[i[0],i[1],i[2]],[e[0],e[1],e[2]]),s=L([],[e[0],e[1],e[2]],[t[0],t[1],t[2]]),o=D([],a,-e[3]);return C(o,o,D([],n,-t[3])),C(o,o,D([],s,-i[3])),D(o,o,1/r),o}function he(e,t,i){let r=e[0]*i[0]+e[1]*i[1]+e[2]*i[2],a=t[0]*i[0]+t[1]*i[1]+t[2]*i[2];return 0===a?null:(-r-i[3])/a}function ue(e,t,i,r){let a=Math.sqrt(e*e+t*t),n=Math.sqrt(i*i+r*r),s=(e/=a)*(i/=n)+(t/=a)*(r/=n),o=Math.acos(s);return-t*i+e*r>0?o:-o}function ce(e,t){let i=de(e,360),r=de(t,360),a=r-i,n=r>i?a-360:a+360;return Math.abs(a)<Math.abs(n)?a:n}function pe(e,t){let i=de(e,2*Math.PI),r=de(t,2*Math.PI);return Math.min(Math.abs(i-r),Math.abs(i-r+2*Math.PI),Math.abs(i-r-2*Math.PI))}function de(e,t){return(e%t+t)%t}function fe(e,t,i,r,a){return me(r,a,ve((e-t)/(i-t),0,1))}function me(e,t,i){return e*(1-i)+t*i}function _e(e){let t=1/0,i=1/0,r=-1/0,a=-1/0;for(let n of e)t=Math.min(t,n.x),i=Math.min(i,n.y),r=Math.max(r,n.x),a=Math.max(a,n.y);return[t,i,r,a]}function ge(e,t,i,r){return function(e,t,i,r){let a=3*e,n=3*(i-e)-a,s=1-a-n,o=3*t,l=3*(r-t)-o,h=1-o-l;return function(e,t=1e-6){if(e<=0)return 0;if(e>=1)return 1;let i=e;for(let c=0;c<8;c++){let r=((s*i+n)*i+a)*i-e;if(Math.abs(r)<t)return((h*i+l)*i+o)*i;let u=(3*s*i+2*n)*i+a;if(Math.abs(u)<1e-6)break;i-=r/u}let r=0,u=1;i=e;for(let o=0;o<20;o++){let o=((s*i+n)*i+a)*i;if(Math.abs(o-e)<t)break;e>o?r=i:u=i,i=.5*(r+u)}return((h*i+l)*i+o)*i}}(e,t,i,r)}var ye=ge(.25,.1,.25,1);function ve(e,t,i){return Math.min(i,Math.max(t,e))}function xe(e,t,i){let r=i-t,a=((e-t)%r+r)%r+t;return a===t?i:a}function be(e,...t){for(let i of t)for(let t in i)e[t]=i[t];return e}function we(e,t){let i={};for(let r of t)r in e&&(i[r]=e[r]);return i}var Te=1;function Se(){return Te++}function Pe(e){return 2**e}function Ie(e){return Math.log(e)/Math.LN2}function Me(e,t,i){if(t<=0)return e;let r=1/t;return void 0===i||Math.abs(i)<1e-10?Math.round(e*r)/r:(i>0?Math.ceil(e*r-1e-9):Math.floor(e*r+1e-10))/r}function Ee(e,t,i){let r={};for(let a in e)r[a]=t.call(i||this,e[a],a,e);return r}function Ae(e,t,i){let r={};for(let a in e)t.call(i||this,e[a],a,e)&&(r[a]=e[a]);return r}function Ce(e,t){if(Array.isArray(e)){if(!Array.isArray(t)||e.length!==t.length)return!1;for(let i=0;i<e.length;i++)if(!Ce(e[i],t[i]))return!1;return!0}if("object"==typeof e&&e&&null!==t){if("object"!=typeof t||Object.keys(e).length!==Object.keys(t).length)return!1;for(let i in e)if(!Ce(e[i],t[i]))return!1;return!0}return e===t}function De(e){return Array.isArray(e)?e.map(De):"object"==typeof e&&e?Ee(e,De):e}var ze={};function Re(e){ze[e]||(typeof console<"u"&&console.warn(e),ze[e]=!0)}function ke(e,t,i){return(i.y-e.y)*(t.x-e.x)>(t.y-e.y)*(i.x-e.x)}function Le(e,t,i,r){let a=t.y-e.y,n=t.x-e.x,s=r.y-i.y,o=r.x-i.x,l=s*n-o*a;if(0===l)return null;let h=(o*(e.y-i.y)-s*(e.x-i.x))/l;return new u(e.x+h*n,e.y+h*a)}function Fe(e){return typeof WorkerGlobalScope<"u"&&void 0!==e&&e instanceof WorkerGlobalScope}var Be=null;function Oe(e){return typeof ImageBitmap<"u"&&e instanceof ImageBitmap}var Ve="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAAC0lEQVQYV2NgAAIAAAUAAarVyFEAAAAASUVORK5CYII=";function je(e,t,i,r){return e.addEventListener(t,i,r),{unsubscribe:()=>{e.removeEventListener(t,i,r)}}}function Ne(e){return e*Math.PI/180}function Ue(e){return e/Math.PI*180}function Ge(e,t){return e.roll==t.roll&&e.pitch==t.pitch&&e.bearing==t.bearing}function $e(e,t,i){let r=W(t.x-i.x,t.y-i.y),a=W(e.x-i.x,e.y-i.y),n=r[0]*a[1]-r[1]*a[0];return Ue(Math.atan2(n,function(e,t){return e[0]*t[0]+e[1]*t[1]}(r,a)))}function Ze(e,t,i){let r=/* @__PURE__ */new Float64Array(4);return $(r,e,t-90,i),r}var qe=85.051129,We={touchstart:!0,touchmove:!0,touchmoveWindow:!0,touchend:!0,touchcancel:!0},He={dblclick:!0,click:!0,mouseover:!0,mouseout:!0,mousedown:!0,mousemove:!0,mousemoveWindow:!0,mouseup:!0,mouseupWindow:!0,contextmenu:!0,wheel:!0};function Xe(e,t){return We[t]&&"touches"in e}function Ye(e,t){if(!He[t])return!1;let i=e,r=(i?.target)?.ownerDocument?.defaultView||window;return i instanceof r.MouseEvent||i instanceof r.WheelEvent}function Ke(e){return We[e]||He[e]}var Je="AbortError",Qe=class extends Error{constructor(e=Je){super(e instanceof Error?e.message:e),this.name=Je,e instanceof Error&&e.stack&&(this.stack=e.stack)}};function et(e){return e instanceof Error&&"AbortError"===e.name}function tt(e){if(e.aborted)throw new Qe(e.reason)}var it={MAX_PARALLEL_IMAGE_REQUESTS:16,MAX_PARALLEL_IMAGE_REQUESTS_PER_FRAME:8,MAX_TILE_CACHE_ZOOM_LEVELS:5,REGISTERED_PROTOCOLS:{},WORKER_URL:""};function rt(e){return it.REGISTERED_PROTOCOLS[e.substring(0,e.indexOf("://"))]}function at(e,t){it.REGISTERED_PROTOCOLS[e]=t}function nt(e){delete it.REGISTERED_PROTOCOLS[e]}var st="global-dispatcher",ot=class extends Error{constructor(e,t,i,r){super(`AJAXError: ${t} (${e}): ${i}`),this.status=e,this.statusText=t,this.url=i,this.body=r}};function lt(){if(Fe(self))return self.worker?.referrer;if("blob:"===window.location.protocol)try{return window.parent.location.href}catch{}return window.location.href}var ht=async function(e,t){if(e.url.includes("://")&&!/^https?:|^file:/.test(e.url)){let i=rt(e.url);if(i){let r=await i(e,t);return r.data||"arrayBuffer"!==e.type?r:be(r,{data:/* @__PURE__ */new ArrayBuffer(0)})}if(Fe(self)&&self.worker?.actor)return self.worker.actor.sendAsync({type:"GR",data:e,targetMapId:st},t)}if(!(e=>e.startsWith("file:")||lt()?.startsWith("file:")&&!/^\w+:/.test(e))(e.url)){if(fetch&&Request&&AbortController&&Object.hasOwn(Request.prototype,"signal"))return async function(e,t){let i,r,a=new Request(e.url,{method:e.method||"GET",body:e.body,credentials:e.credentials,headers:e.headers,cache:e.cache,referrer:lt(),referrerPolicy:e.referrerPolicy,signal:t.signal});"json"===e.type&&!a.headers.has("Accept")&&a.headers.set("Accept","application/json");try{i=await fetch(a)}catch(t){throw et(t)?t:new ot(0,ee(t).message,e.url,new Blob)}if(!i.ok){let t=await i.blob();throw new ot(i.status,i.statusText,e.url,t)}r="arrayBuffer"===e.type||"image"===e.type?i.arrayBuffer():"json"===e.type?i.json():i.text();let n=await r;return tt(t.signal),{data:n,cacheControl:i.headers.get("Cache-Control"),expires:i.headers.get("Expires"),etag:i.headers.get("ETag")}}(e,t);if(Fe(self)&&self.worker?.actor)return self.worker.actor.sendAsync({type:"GR",data:e,mustQueue:!0,targetMapId:st},t)}return function(e,t){return new Promise((i,r)=>{let a=new XMLHttpRequest;a.open(e.method||"GET",e.url,!0),("arrayBuffer"===e.type||"image"===e.type)&&(a.responseType="arraybuffer");for(let t in e.headers)a.setRequestHeader(t,e.headers[t]);"json"===e.type&&(a.responseType="text",e.headers?.Accept||a.setRequestHeader("Accept","application/json")),a.withCredentials="include"===e.credentials,a.onerror=()=>{r(Error(a.statusText))},a.onload=()=>{if(!t.signal.aborted)if((a.status>=200&&a.status<300||0===a.status)&&null!==a.response){let t=a.response;if("json"===e.type)try{t=JSON.parse(a.response)}catch(e){return void r(e)}i({data:t,cacheControl:a.getResponseHeader("Cache-Control"),expires:a.getResponseHeader("Expires"),etag:a.getResponseHeader("ETag")})}else{let t=new Blob([a.response],{type:a.getResponseHeader("Content-Type")});r(new ot(a.status,a.statusText,e.url,t))}},t.signal.addEventListener("abort",()=>{a.abort(),r(new Qe(t.signal.reason))}),a.send(e.body)})}(e,t)},ut=(e,t)=>ht(be(e,{type:"json"}),t);function ct(e){if(!e||e.startsWith("data:image/"))return!0;if(e.startsWith("blob:")&&(e=e.slice(5)).startsWith("null"))return!1;if(e.indexOf("://")<=0)return!0;let t=new URL(e),i=window.location;return t.protocol===i.protocol&&t.host===i.host}function pt(e,t,i){i[e]?.includes(t)||(i[e]||=[],i[e].push(t))}function dt(e,t,i){if(i?.[e]){let r=i[e].indexOf(t);-1!==r&&i[e].splice(r,1)}}var ft=class{constructor(e,t={}){be(this,t),this.type=e}},mt=class extends ft{constructor(e,t={}){super("error",be({error:e},t))}},_t=class{on(e,t){return this._listeners||={},pt(e,t,this._listeners),{unsubscribe:()=>{this.off(e,t)}}}off(e,t){return dt(e,t,this._listeners),dt(e,t,this._oneTimeListeners),this}once(e,t){return t?(this._oneTimeListeners||={},pt(e,t,this._oneTimeListeners),this):new Promise(t=>this.once(e,t))}fire(e,t){let i="string"==typeof e?new ft(e,t||{}):e,r=i.type;if(this.listens(r)){i.target=this;let e=this._listeners?.[r]?.slice()??[];for(let r of e)r.call(this,i);let t=this._oneTimeListeners?.[r]?.slice()??[];for(let n of t)dt(r,n,this._oneTimeListeners),n.call(this,i);let a=this._eventedParent;a&&(be(i,"function"==typeof this._eventedParentData?this._eventedParentData():this._eventedParentData),a.fire(i))}else i instanceof mt&&console.error(i.error);return this}listens(e){return!!(this._listeners?.[e]?.length||this._oneTimeListeners?.[e]?.length||this._eventedParent?.listens(e))}setEventedParent(e,t){return this._eventedParent=e,this._eventedParentData=t,this}},gt={$version:8,$root:{version:{required:!0,type:"enum",values:[8]},name:{type:"string"},metadata:{type:"*"},center:{type:"array",value:"number",length:2},centerAltitude:{type:"number"},zoom:{type:"number"},bearing:{type:"number",default:0,period:360,units:"degrees"},pitch:{type:"number",default:0,units:"degrees"},roll:{type:"number",default:0,units:"degrees"},state:{type:"state",default:{}},light:{type:"light"},sky:{type:"sky"},projection:{type:"projection"},terrain:{type:"terrain"},sources:{required:!0,type:"sources"},sprite:{type:"sprite"},glyphs:{type:"string"},"font-faces":{type:"fontFaces"},transition:{type:"transition"},layers:{required:!0,type:"array",value:"layer"}},sources:{"*":{type:"source"}},source:["source_vector","source_raster","source_raster_dem","source_geojson","source_video","source_image"],source_vector:{type:{required:!0,type:"enum",values:{vector:{}}},url:{type:"string"},tiles:{type:"array",value:"string"},bounds:{type:"array",value:"number",length:4,default:[-180,-85.051129,180,85.051129]},scheme:{type:"enum",values:{xyz:{},tms:{}},default:"xyz"},minzoom:{type:"number",default:0},maxzoom:{type:"number",default:22},attribution:{type:"string"},promoteId:{type:"promoteId"},volatile:{type:"boolean",default:!1},encoding:{type:"enum",values:{mvt:{},mlt:{}},default:"mvt"},"*":{type:"*"}},source_raster:{type:{required:!0,type:"enum",values:{raster:{}}},url:{type:"string"},tiles:{type:"array",value:"string"},bounds:{type:"array",value:"number",length:4,default:[-180,-85.051129,180,85.051129]},minzoom:{type:"number",default:0},maxzoom:{type:"number",default:22},tileSize:{type:"number",default:512,units:"pixels"},scheme:{type:"enum",values:{xyz:{},tms:{}},default:"xyz"},attribution:{type:"string"},volatile:{type:"boolean",default:!1},"*":{type:"*"}},source_raster_dem:{type:{required:!0,type:"enum",values:{"raster-dem":{}}},url:{type:"string"},tiles:{type:"array",value:"string"},bounds:{type:"array",value:"number",length:4,default:[-180,-85.051129,180,85.051129]},minzoom:{type:"number",default:0},maxzoom:{type:"number",default:22},tileSize:{type:"number",default:512,units:"pixels"},attribution:{type:"string"},encoding:{type:"enum",values:{terrarium:{},mapbox:{},custom:{}},default:"mapbox"},redFactor:{type:"number",default:1},blueFactor:{type:"number",default:1},greenFactor:{type:"number",default:1},baseShift:{type:"number",default:0},volatile:{type:"boolean",default:!1},"*":{type:"*"}},source_geojson:{type:{required:!0,type:"enum",values:{geojson:{}}},data:{required:!0,type:"*"},maxzoom:{type:"number",default:18},attribution:{type:"string"},buffer:{type:"number",default:128,maximum:512,minimum:0},filter:{type:"filter"},tolerance:{type:"number",default:.375},cluster:{type:"boolean",default:!1},clusterRadius:{type:"number",default:50,minimum:0},clusterMaxZoom:{type:"number"},clusterMinPoints:{type:"number"},clusterProperties:{type:"*"},lineMetrics:{type:"boolean",default:!1},generateId:{type:"boolean",default:!1},promoteId:{type:"promoteId"}},source_video:{type:{required:!0,type:"enum",values:{video:{}}},urls:{required:!0,type:"array",value:"string"},coordinates:{required:!0,type:"array",length:4,value:{type:"array",length:2,value:"number"}}},source_image:{type:{required:!0,type:"enum",values:{image:{}}},url:{required:!0,type:"string"},coordinates:{required:!0,type:"array",length:4,value:{type:"array",length:2,value:"number"}}},layer:{id:{type:"string",required:!0},type:{type:"enum",values:{fill:{},line:{},symbol:{},circle:{},heatmap:{},"fill-extrusion":{},raster:{},hillshade:{},"color-relief":{},background:{}},required:!0},metadata:{type:"*"},source:{type:"string"},"source-layer":{type:"string"},minzoom:{type:"number",minimum:0,maximum:24},maxzoom:{type:"number",minimum:0,maximum:24},filter:{type:"filter"},layout:{type:"layout"},paint:{type:"paint"}},layout:["layout_fill","layout_line","layout_circle","layout_heatmap","layout_fill-extrusion","layout_symbol","layout_raster","layout_hillshade","layout_color-relief","layout_background"],layout_background:{visibility:{type:"enum",values:{visible:{},none:{}},default:"visible",expression:{interpolated:!1,parameters:["global-state"]},"property-type":"data-constant"}},layout_fill:{"fill-sort-key":{type:"number",expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"data-driven"},visibility:{type:"enum",values:{visible:{},none:{}},default:"visible",expression:{interpolated:!1,parameters:["global-state"]},"property-type":"data-constant"}},layout_circle:{"circle-sort-key":{type:"number",expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"data-driven"},visibility:{type:"enum",values:{visible:{},none:{}},default:"visible",expression:{interpolated:!1,parameters:["global-state"]},"property-type":"data-constant"}},layout_heatmap:{visibility:{type:"enum",values:{visible:{},none:{}},default:"visible",expression:{interpolated:!1,parameters:["global-state"]},"property-type":"data-constant"}},"layout_fill-extrusion":{visibility:{type:"enum",values:{visible:{},none:{}},default:"visible",expression:{interpolated:!1,parameters:["global-state"]},"property-type":"data-constant"},"fill-extrusion-rounded-corner-distance":{type:"number",default:0,minimum:0,units:"meters","property-type":"constant"}},layout_line:{"line-cap":{type:"enum",values:{butt:{},round:{},square:{}},default:"butt",expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"data-driven"},"line-join":{type:"enum",values:{bevel:{},round:{},miter:{}},default:"miter",expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"data-driven"},"line-miter-limit":{type:"number",default:2,requires:[{"line-join":"miter"}],expression:{interpolated:!0,parameters:["zoom","feature"]},"property-type":"data-driven"},"line-round-limit":{type:"number",default:1.05,requires:[{"line-join":"round"}],expression:{interpolated:!0,parameters:["zoom","feature"]},"property-type":"data-driven"},"line-sort-key":{type:"number",expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"data-driven"},visibility:{type:"enum",values:{visible:{},none:{}},default:"visible",expression:{interpolated:!1,parameters:["global-state"]},"property-type":"data-constant"}},layout_symbol:{"symbol-placement":{type:"enum",values:{point:{},line:{},"line-center":{}},default:"point",expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"symbol-spacing":{type:"number",default:250,minimum:1,units:"pixels",requires:[{"symbol-placement":"line"}],expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"symbol-avoid-edges":{type:"boolean",default:!1,expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"symbol-sort-key":{type:"number",expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"data-driven"},"symbol-z-order":{type:"enum",values:{auto:{},"viewport-y":{},source:{}},default:"auto",expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"icon-allow-overlap":{type:"boolean",default:!1,requires:["icon-image",{"!":"icon-overlap"}],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"icon-overlap":{type:"enum",values:{never:{},always:{},cooperative:{}},requires:["icon-image"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"icon-ignore-placement":{type:"boolean",default:!1,requires:["icon-image"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"icon-optional":{type:"boolean",default:!1,requires:["icon-image","text-field"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"icon-rotation-alignment":{type:"enum",values:{map:{},viewport:{},auto:{}},default:"auto",requires:["icon-image"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"icon-size":{type:"number",default:1,minimum:0,units:"factor of the original icon size",requires:["icon-image"],expression:{interpolated:!0,parameters:["zoom","feature"]},"property-type":"data-driven"},"icon-text-fit":{type:"enum",values:{none:{},width:{},height:{},both:{}},default:"none",requires:["icon-image","text-field"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"icon-text-fit-padding":{type:"array",value:"number",length:4,default:[0,0,0,0],units:"pixels",requires:["icon-image","text-field",{"icon-text-fit":["both","width","height"]}],expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"icon-image":{type:"resolvedImage",tokens:!0,expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"data-driven"},"icon-rotate":{type:"number",default:0,period:360,units:"degrees",requires:["icon-image"],expression:{interpolated:!0,parameters:["zoom","feature"]},"property-type":"data-driven"},"icon-padding":{type:"padding",default:[2],units:"pixels",requires:["icon-image"],expression:{interpolated:!0,parameters:["zoom","feature"]},"property-type":"data-driven"},"icon-keep-upright":{type:"boolean",default:!1,requires:["icon-image",{"icon-rotation-alignment":"map"},{"symbol-placement":["line","line-center"]}],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"icon-offset":{type:"array",value:"number",length:2,default:[0,0],requires:["icon-image"],expression:{interpolated:!0,parameters:["zoom","feature"]},"property-type":"data-driven"},"icon-anchor":{type:"enum",values:{center:{},left:{},right:{},top:{},bottom:{},"top-left":{},"top-right":{},"bottom-left":{},"bottom-right":{}},default:"center",requires:["icon-image"],expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"data-driven"},"icon-pitch-alignment":{type:"enum",values:{map:{},viewport:{},auto:{}},default:"auto",requires:["icon-image"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"text-pitch-alignment":{type:"enum",values:{map:{},viewport:{},auto:{}},default:"auto",requires:["text-field"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"text-rotation-alignment":{type:"enum",values:{map:{},viewport:{},"viewport-glyph":{},auto:{}},default:"auto",requires:["text-field"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"text-field":{type:"formatted",default:"",tokens:!0,expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"data-driven"},"text-font":{type:"array",value:"string",default:["Open Sans Regular","Arial Unicode MS Regular"],requires:["text-field"],expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"data-driven"},"text-size":{type:"number",default:16,minimum:0,units:"pixels",requires:["text-field"],expression:{interpolated:!0,parameters:["zoom","feature"]},"property-type":"data-driven"},"text-max-width":{type:"number",default:10,minimum:0,units:"ems",requires:["text-field"],expression:{interpolated:!0,parameters:["zoom","feature"]},"property-type":"data-driven"},"text-line-height":{type:"number",default:1.2,units:"ems",requires:["text-field"],expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"text-letter-spacing":{type:"number",default:0,units:"ems",requires:["text-field"],expression:{interpolated:!0,parameters:["zoom","feature"]},"property-type":"data-driven"},"text-justify":{type:"enum",values:{auto:{},left:{},center:{},right:{}},default:"center",requires:["text-field"],expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"data-driven"},"text-radial-offset":{type:"number",units:"ems",default:0,requires:["text-field"],"property-type":"data-driven",expression:{interpolated:!0,parameters:["zoom","feature"]}},"text-variable-anchor":{type:"array",value:"enum",values:{center:{},left:{},right:{},top:{},bottom:{},"top-left":{},"top-right":{},"bottom-left":{},"bottom-right":{}},requires:["text-field",{"symbol-placement":["point"]}],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"text-variable-anchor-offset":{type:"variableAnchorOffsetCollection",requires:["text-field",{"symbol-placement":["point"]}],expression:{interpolated:!0,parameters:["zoom","feature"]},"property-type":"data-driven"},"text-anchor":{type:"enum",values:{center:{},left:{},right:{},top:{},bottom:{},"top-left":{},"top-right":{},"bottom-left":{},"bottom-right":{}},default:"center",requires:["text-field",{"!":"text-variable-anchor"}],expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"data-driven"},"text-max-angle":{type:"number",default:45,units:"degrees",requires:["text-field",{"symbol-placement":["line","line-center"]}],expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"text-writing-mode":{type:"array",value:"enum",values:{horizontal:{},vertical:{}},requires:["text-field",{"symbol-placement":["point"]}],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"text-rotate":{type:"number",default:0,period:360,units:"degrees",requires:["text-field"],expression:{interpolated:!0,parameters:["zoom","feature"]},"property-type":"data-driven"},"text-padding":{type:"number",default:2,minimum:0,units:"pixels",requires:["text-field"],expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"text-keep-upright":{type:"boolean",default:!0,requires:["text-field",{"text-rotation-alignment":"map"},{"symbol-placement":["line","line-center"]}],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"text-transform":{type:"enum",values:{none:{},uppercase:{},lowercase:{}},default:"none",requires:["text-field"],expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"data-driven"},"text-offset":{type:"array",value:"number",units:"ems",length:2,default:[0,0],requires:["text-field",{"!":"text-radial-offset"}],expression:{interpolated:!0,parameters:["zoom","feature"]},"property-type":"data-driven"},"text-allow-overlap":{type:"boolean",default:!1,requires:["text-field",{"!":"text-overlap"}],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"text-overlap":{type:"enum",values:{never:{},always:{},cooperative:{}},requires:["text-field"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"text-ignore-placement":{type:"boolean",default:!1,requires:["text-field"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"text-optional":{type:"boolean",default:!1,requires:["text-field","icon-image"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},visibility:{type:"enum",values:{visible:{},none:{}},default:"visible",expression:{interpolated:!1,parameters:["global-state"]},"property-type":"data-constant"}},layout_raster:{visibility:{type:"enum",values:{visible:{},none:{}},default:"visible",expression:{interpolated:!1,parameters:["global-state"]},"property-type":"data-constant"}},layout_hillshade:{visibility:{type:"enum",values:{visible:{},none:{}},default:"visible",expression:{interpolated:!1,parameters:["global-state"]},"property-type":"data-constant"}},"layout_color-relief":{visibility:{type:"enum",values:{visible:{},none:{}},default:"visible",expression:{interpolated:!1,parameters:["global-state"]},"property-type":"data-constant"}},filter:{type:"boolean",expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"data-driven"},filter_operator:{type:"enum",values:{"==":{},"!=":{},">":{},">=":{},"<":{},"<=":{},in:{},"!in":{},all:{},any:{},none:{},has:{},"!has":{}}},geometry_type:{type:"enum",values:{Point:{},LineString:{},Polygon:{}}},function:{expression:{type:"expression"},stops:{type:"array",value:"function_stop"},base:{type:"number",default:1,minimum:0},property:{type:"string",default:"$zoom"},type:{type:"enum",values:{identity:{},exponential:{},interval:{},categorical:{}},default:"exponential"},colorSpace:{type:"enum",values:{rgb:{},lab:{},hcl:{}},default:"rgb"},default:{type:"*",required:!1}},function_stop:{type:"array",minimum:0,maximum:24,value:["number","color"],length:2},expression:{type:"array",value:"expression_name",minimum:1},light:{anchor:{type:"enum",default:"viewport",values:{map:{},viewport:{}},"property-type":"data-constant",transition:!1,expression:{interpolated:!1,parameters:["zoom"]}},position:{type:"array",default:[1.15,210,30],length:3,value:"number","property-type":"data-constant",transition:!0,expression:{interpolated:!0,parameters:["zoom"]}},color:{type:"color","property-type":"data-constant",default:"#ffffff",expression:{interpolated:!0,parameters:["zoom"]},transition:!0},intensity:{type:"number","property-type":"data-constant",default:.5,minimum:0,maximum:1,expression:{interpolated:!0,parameters:["zoom"]},transition:!0}},sky:{"sky-color":{type:"color","property-type":"data-constant",default:"#88C6FC",expression:{interpolated:!0,parameters:["zoom"]},transition:!0},"horizon-color":{type:"color","property-type":"data-constant",default:"#ffffff",expression:{interpolated:!0,parameters:["zoom"]},transition:!0},"fog-color":{type:"color","property-type":"data-constant",default:"#ffffff",expression:{interpolated:!0,parameters:["zoom"]},transition:!0},"fog-ground-blend":{type:"number","property-type":"data-constant",default:.5,minimum:0,maximum:1,expression:{interpolated:!0,parameters:["zoom"]},transition:!0},"horizon-fog-blend":{type:"number","property-type":"data-constant",default:.8,minimum:0,maximum:1,expression:{interpolated:!0,parameters:["zoom"]},transition:!0},"sky-horizon-blend":{type:"number","property-type":"data-constant",default:.8,minimum:0,maximum:1,expression:{interpolated:!0,parameters:["zoom"]},transition:!0},"atmosphere-blend":{type:"number","property-type":"data-constant",default:.8,minimum:0,maximum:1,expression:{interpolated:!0,parameters:["zoom"]},transition:!0}},terrain:{source:{type:"string",required:!0},exaggeration:{type:"number",minimum:0,default:1}},projection:{type:{type:"projectionDefinition",default:"mercator","property-type":"data-constant",transition:!1,expression:{interpolated:!0,parameters:["zoom"]}}},paint:["paint_fill","paint_line","paint_circle","paint_heatmap","paint_fill-extrusion","paint_symbol","paint_raster","paint_hillshade","paint_color-relief","paint_background"],paint_fill:{"fill-antialias":{type:"boolean",default:!0,expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"fill-opacity":{type:"number",default:1,minimum:0,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"fill-layer-opacity":{type:"number",default:1,minimum:0,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom","global-state"]},"property-type":"data-constant"},"fill-color":{type:"color",default:"#000000",transition:!0,expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"fill-outline-color":{type:"color",transition:!0,requires:[{"!":"fill-pattern"},{"fill-antialias":!0}],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"fill-translate":{type:"array",value:"number",length:2,default:[0,0],transition:!0,units:"pixels",expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"fill-translate-anchor":{type:"enum",values:{map:{},viewport:{}},default:"map",requires:["fill-translate"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"fill-pattern":{type:"resolvedImage",transition:!0,expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"cross-faded-data-driven"}},"paint_fill-extrusion":{"fill-extrusion-opacity":{type:"number",default:1,minimum:0,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"fill-extrusion-color":{type:"color",default:"#000000",transition:!0,requires:[{"!":"fill-extrusion-pattern"}],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"fill-extrusion-translate":{type:"array",value:"number",length:2,default:[0,0],transition:!0,units:"pixels",expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"fill-extrusion-translate-anchor":{type:"enum",values:{map:{},viewport:{}},default:"map",requires:["fill-extrusion-translate"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"fill-extrusion-pattern":{type:"resolvedImage",transition:!0,expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"cross-faded-data-driven"},"fill-extrusion-height":{type:"number",default:0,minimum:0,units:"meters",transition:!0,expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"fill-extrusion-base":{type:"number",default:0,minimum:0,units:"meters",transition:!0,requires:["fill-extrusion-height"],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"fill-extrusion-vertical-gradient":{type:"boolean",default:!0,transition:!1,expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"}},paint_line:{"line-opacity":{type:"number",default:1,minimum:0,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"line-layer-opacity":{type:"number",default:1,minimum:0,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom","global-state"]},"property-type":"data-constant"},"line-color":{type:"color",default:"#000000",transition:!0,requires:[{"!":"line-pattern"}],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"line-translate":{type:"array",value:"number",length:2,default:[0,0],transition:!0,units:"pixels",expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"line-translate-anchor":{type:"enum",values:{map:{},viewport:{}},default:"map",requires:["line-translate"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"line-width":{type:"number",default:1,minimum:0,transition:!0,units:"pixels",expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"line-gap-width":{type:"number",default:0,minimum:0,transition:!0,units:"pixels",expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"line-offset":{type:"number",default:0,transition:!0,units:"pixels",expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"line-blur":{type:"number",default:0,minimum:0,transition:!0,units:"pixels",expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"line-dasharray":{type:"array",value:"number",minimum:0,transition:!0,units:"line widths",requires:[{"!":"line-pattern"}],expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"cross-faded-data-driven"},"line-pattern":{type:"resolvedImage",transition:!0,expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"cross-faded-data-driven"},"line-gradient":{type:"color",transition:!1,requires:[{"!":"line-dasharray"},{"!":"line-pattern"},{source:"geojson",has:{lineMetrics:!0}}],expression:{interpolated:!0,parameters:["line-progress"]},"property-type":"color-ramp"}},paint_circle:{"circle-radius":{type:"number",default:5,minimum:0,transition:!0,units:"pixels",expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"circle-color":{type:"color",default:"#000000",transition:!0,expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"circle-blur":{type:"number",default:0,transition:!0,expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"circle-opacity":{type:"number",default:1,minimum:0,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"circle-translate":{type:"array",value:"number",length:2,default:[0,0],transition:!0,units:"pixels",expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"circle-translate-anchor":{type:"enum",values:{map:{},viewport:{}},default:"map",requires:["circle-translate"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"circle-pitch-scale":{type:"enum",values:{map:{},viewport:{}},default:"map",expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"circle-pitch-alignment":{type:"enum",values:{map:{},viewport:{}},default:"viewport",expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"circle-stroke-width":{type:"number",default:0,minimum:0,transition:!0,units:"pixels",expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"circle-stroke-color":{type:"color",default:"#000000",transition:!0,expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"circle-stroke-opacity":{type:"number",default:1,minimum:0,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"}},paint_heatmap:{"heatmap-radius":{type:"number",default:30,minimum:1,transition:!0,units:"pixels",expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"heatmap-weight":{type:"number",default:1,minimum:0,transition:!1,expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"heatmap-intensity":{type:"number",default:1,minimum:0,transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"heatmap-color":{type:"color",default:["interpolate",["linear"],["heatmap-density"],0,"rgba(0, 0, 255, 0)",.1,"royalblue",.3,"cyan",.5,"lime",.7,"yellow",1,"red"],transition:!1,expression:{interpolated:!0,parameters:["heatmap-density"]},"property-type":"color-ramp"},"heatmap-opacity":{type:"number",default:1,minimum:0,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"}},paint_symbol:{"icon-opacity":{type:"number",default:1,minimum:0,maximum:1,transition:!0,requires:["icon-image"],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"icon-color":{type:"color",default:"#000000",transition:!0,requires:["icon-image"],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"icon-halo-color":{type:"color",default:"rgba(0, 0, 0, 0)",transition:!0,requires:["icon-image"],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"icon-halo-width":{type:"number",default:0,minimum:0,transition:!0,units:"pixels",requires:["icon-image"],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"icon-halo-blur":{type:"number",default:0,minimum:0,transition:!0,units:"pixels",requires:["icon-image"],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"icon-translate":{type:"array",value:"number",length:2,default:[0,0],transition:!0,units:"pixels",requires:["icon-image"],expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"icon-translate-anchor":{type:"enum",values:{map:{},viewport:{}},default:"map",requires:["icon-image","icon-translate"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"text-opacity":{type:"number",default:1,minimum:0,maximum:1,transition:!0,requires:["text-field"],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"text-color":{type:"color",default:"#000000",transition:!0,overridable:!0,requires:["text-field"],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"text-halo-color":{type:"color",default:"rgba(0, 0, 0, 0)",transition:!0,requires:["text-field"],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"text-halo-width":{type:"number",default:0,minimum:0,transition:!0,units:"pixels",requires:["text-field"],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"text-halo-blur":{type:"number",default:0,minimum:0,transition:!0,units:"pixels",requires:["text-field"],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"text-translate":{type:"array",value:"number",length:2,default:[0,0],transition:!0,units:"pixels",requires:["text-field"],expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"text-translate-anchor":{type:"enum",values:{map:{},viewport:{}},default:"map",requires:["text-field","text-translate"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"}},paint_raster:{"raster-opacity":{type:"number",default:1,minimum:0,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"raster-hue-rotate":{type:"number",default:0,period:360,transition:!0,units:"degrees",expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"raster-brightness-min":{type:"number",default:0,minimum:0,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"raster-brightness-max":{type:"number",default:1,minimum:0,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"raster-saturation":{type:"number",default:0,minimum:-1,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"raster-contrast":{type:"number",default:0,minimum:-1,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},resampling:{type:"enum",values:{linear:{},nearest:{}},default:"linear",expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"raster-resampling":{type:"enum",values:{linear:{},nearest:{}},default:"linear",expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"raster-fade-duration":{type:"number",default:300,minimum:0,transition:!1,units:"milliseconds",expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"}},paint_hillshade:{"hillshade-illumination-direction":{type:"numberArray",default:335,minimum:0,maximum:359,transition:!1,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"hillshade-illumination-altitude":{type:"numberArray",default:45,minimum:0,maximum:90,transition:!1,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"hillshade-illumination-anchor":{type:"enum",values:{map:{},viewport:{}},default:"viewport",expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"hillshade-exaggeration":{type:"number",default:.5,minimum:0,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"hillshade-shadow-color":{type:"colorArray",default:"#000000",transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"hillshade-highlight-color":{type:"colorArray",default:"#FFFFFF",transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"hillshade-accent-color":{type:"color",default:"#000000",transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"hillshade-method":{type:"enum",values:{standard:{},basic:{},combined:{},igor:{},multidirectional:{}},default:"standard",expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},resampling:{type:"enum",values:{linear:{},nearest:{}},default:"linear",expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"}},"paint_color-relief":{"color-relief-opacity":{type:"number",default:1,minimum:0,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"color-relief-color":{type:"color",transition:!1,expression:{interpolated:!0,parameters:["elevation"]},"property-type":"color-ramp"},resampling:{type:"enum",values:{linear:{},nearest:{}},default:"linear",expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"}},paint_background:{"background-color":{type:"color",default:"#000000",transition:!0,requires:[{"!":"background-pattern"}],expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"background-pattern":{type:"resolvedImage",transition:!0,expression:{interpolated:!1,parameters:["zoom"]},"property-type":"cross-faded"},"background-opacity":{type:"number",default:1,minimum:0,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"}},transition:{duration:{type:"number",default:300,minimum:0,units:"milliseconds"},delay:{type:"number",default:0,minimum:0,units:"milliseconds"}},"property-type":{"data-driven":{type:"property-type"},"cross-faded":{type:"property-type"},"cross-faded-data-driven":{type:"property-type"},"color-ramp":{type:"property-type"},"data-constant":{type:"property-type"},constant:{type:"property-type"}},promoteId:{"*":{type:"string"}},interpolation:{type:"array",value:"interpolation_name",minimum:1},interpolation_name:{type:"enum",values:{linear:{syntax:{overloads:[{parameters:[],"output-type":"interpolation"}],parameters:[]}},exponential:{syntax:{overloads:[{parameters:["base"],"output-type":"interpolation"}],parameters:[{name:"base",type:"number literal"}]}},"cubic-bezier":{syntax:{overloads:[{parameters:["x1","y1","x2","y2"],"output-type":"interpolation"}],parameters:[{name:"x1",type:"number literal"},{name:"y1",type:"number literal"},{name:"x2",type:"number literal"},{name:"y2",type:"number literal"}]}}}}},yt=["type","source","source-layer","minzoom","maxzoom","filter","layout"];function vt(e,t){let i={};for(let r in e)"ref"!==r&&(i[r]=e[r]);return yt.forEach(e=>{e in t&&(i[e]=t[e])}),i}function xt(e){e=e.slice();let t=Object.create(null);for(let i=0;i<e.length;i++)t[e[i].id]=e[i];for(let i=0;i<e.length;i++)"ref"in e[i]&&(e[i]=vt(e[i],t[e[i].ref]));return e}function bt(e,t){if(Array.isArray(e)){if(!Array.isArray(t)||e.length!==t.length)return!1;for(let i=0;i<e.length;i++)if(!bt(e[i],t[i]))return!1;return!0}if("object"==typeof e&&e&&null!==t){if("object"!=typeof t||Object.keys(e).length!==Object.keys(t).length)return!1;for(let i in e)if(!bt(e[i],t[i]))return!1;return!0}return e===t}function wt(e,t){e.push(t)}function Tt(e,t,i){wt(i,{command:"addSource",args:[e,t[e]]})}function St(e,t,i){wt(t,{command:"removeSource",args:[e]}),i[e]=!0}function Pt(e,t,i,r){St(e,i,r),Tt(e,t,i)}function It(e,t,i){let r;for(r in e[i])if(Object.prototype.hasOwnProperty.call(e[i],r)&&"data"!==r&&!bt(e[i][r],t[i][r]))return!1;for(r in t[i])if(Object.prototype.hasOwnProperty.call(t[i],r)&&"data"!==r&&!bt(e[i][r],t[i][r]))return!1;return!0}function Mt(e,t,i,r,a,n){e||={},t||={};for(let s in e)Object.prototype.hasOwnProperty.call(e,s)&&(bt(e[s],t[s])||i.push({command:n,args:[r,s,t[s],a]}));for(let s in t)!Object.prototype.hasOwnProperty.call(t,s)||Object.prototype.hasOwnProperty.call(e,s)||bt(e[s],t[s])||i.push({command:n,args:[r,s,t[s],a]})}function Et(e){return e.id}function At(e,t){return e[t.id]=t,e}var Ct=class{constructor(e,t,i,r,a="error"){this.message=(e?`${e}: `:"")+i,r&&(this.identifier=r),this.severity=a,null!=t&&t.__line__&&(this.line=t.__line__)}},Dt=class extends Error{constructor(e,t){super(t),this.message=t,this.key=e}},zt=class e{constructor(e,t=[]){this.parent=e,this.bindings={};for(let[i,r]of t)this.bindings[i]=r}concat(t){return new e(this,t)}get(e){if(this.bindings[e])return this.bindings[e];if(this.parent)return this.parent.get(e);throw Error(`${e} not found in scope.`)}has(e){return!!this.bindings[e]||!!this.parent&&this.parent.has(e)}},Rt={kind:"null"},kt={kind:"number"},Lt={kind:"string"},Ft={kind:"boolean"},Bt={kind:"color"},Ot={kind:"projectionDefinition"},Vt={kind:"object"},jt={kind:"value"},Nt={kind:"collator"},Ut={kind:"formatted"},Gt={kind:"padding"},$t={kind:"colorArray"},Zt={kind:"numberArray"},qt={kind:"resolvedImage"},Wt={kind:"variableAnchorOffsetCollection"};function Ht(e,t){return{kind:"array",itemType:e,N:t}}function Xt(e){if("array"===e.kind){let t=Xt(e.itemType);return"number"==typeof e.N?`array<${t}, ${e.N}>`:"value"===e.itemType.kind?"array":`array<${t}>`}return e.kind}var Yt=[Rt,kt,Lt,Ft,Bt,Ot,Ut,Vt,Ht(jt),Gt,Zt,$t,qt,Wt];function Kt(e,t){if("error"===t.kind)return null;if("array"===e.kind){if("array"===t.kind&&(0===t.N&&"value"===t.itemType.kind||!Kt(e.itemType,t.itemType))&&("number"!=typeof e.N||e.N===t.N))return null}else{if(e.kind===t.kind)return null;if("value"===e.kind)for(let e of Yt)if(!Kt(e,t))return null}return`Expected ${Xt(e)} but found ${Xt(t)} instead.`}function Jt(e,t){return t.some(t=>t.kind===e.kind)}function Qt(e,t){return t.some(t=>"null"===t?null===e:"array"===t?Array.isArray(e):"object"===t?e&&!Array.isArray(e)&&"object"==typeof e:t===typeof e)}function ei(e,t){return"array"===e.kind&&"array"===t.kind?e.itemType.kind===t.itemType.kind&&"number"==typeof e.N:e.kind===t.kind}var ti=.96422,ii=.82521,ri=4/29,ai=6/29,ni=3*ai*ai,si=Math.PI/180,oi=180/Math.PI;function li(e){return(e%=360)<0&&(e+=360),e}function hi([e,t,i,r]){let a,n,s=ci((.2225045*(e=ui(e))+.7168786*(t=ui(t))+.0606169*(i=ui(i)))/1);e===t&&t===i?a=n=s:(a=ci((.4360747*e+.3850649*t+.1430804*i)/ti),n=ci((.0139322*e+.0971045*t+.7141733*i)/ii));let o=116*s-16;return[o<0?0:o,500*(a-s),200*(s-n),r]}function ui(e){return e<=.04045?e/12.92:((e+.055)/1.055)**2.4}function ci(e){return e>.008856451679035631?e**(1/3):e/ni+ri}function pi([e,t,i,r]){let a=(e+16)/116,n=isNaN(t)?a:a+t/500,s=isNaN(i)?a:a-i/200;return a=1*fi(a),n=ti*fi(n),s=ii*fi(s),[di(3.1338561*n-1.6168667*a-.4906146*s),di(-.9787684*n+1.9161415*a+.033454*s),di(.0719453*n-.2289914*a+1.4052427*s),r]}function di(e){return(e=e<=.00304?12.92*e:1.055*e**(1/2.4)-.055)<0?0:e>1?1:e}function fi(e){return e>ai?e*e*e:ni*(e-ri)}var mi=Object.hasOwn||function(e,t){return Object.prototype.hasOwnProperty.call(e,t)};function _i(e,t){return mi(e,t)?e[t]:void 0}function gi(e){return parseInt(e.padEnd(2,e),16)/255}function yi(e,t){return vi(t?e/100:e,0,1)}function vi(e,t,i){return Math.min(Math.max(t,e),i)}function xi(e){return!e.some(Number.isNaN)}var bi={aliceblue:[240,248,255],antiquewhite:[250,235,215],aqua:[0,255,255],aquamarine:[127,255,212],azure:[240,255,255],beige:[245,245,220],bisque:[255,228,196],black:[0,0,0],blanchedalmond:[255,235,205],blue:[0,0,255],blueviolet:[138,43,226],brown:[165,42,42],burlywood:[222,184,135],cadetblue:[95,158,160],chartreuse:[127,255,0],chocolate:[210,105,30],coral:[255,127,80],cornflowerblue:[100,149,237],cornsilk:[255,248,220],crimson:[220,20,60],cyan:[0,255,255],darkblue:[0,0,139],darkcyan:[0,139,139],darkgoldenrod:[184,134,11],darkgray:[169,169,169],darkgreen:[0,100,0],darkgrey:[169,169,169],darkkhaki:[189,183,107],darkmagenta:[139,0,139],darkolivegreen:[85,107,47],darkorange:[255,140,0],darkorchid:[153,50,204],darkred:[139,0,0],darksalmon:[233,150,122],darkseagreen:[143,188,143],darkslateblue:[72,61,139],darkslategray:[47,79,79],darkslategrey:[47,79,79],darkturquoise:[0,206,209],darkviolet:[148,0,211],deeppink:[255,20,147],deepskyblue:[0,191,255],dimgray:[105,105,105],dimgrey:[105,105,105],dodgerblue:[30,144,255],firebrick:[178,34,34],floralwhite:[255,250,240],forestgreen:[34,139,34],fuchsia:[255,0,255],gainsboro:[220,220,220],ghostwhite:[248,248,255],gold:[255,215,0],goldenrod:[218,165,32],gray:[128,128,128],green:[0,128,0],greenyellow:[173,255,47],grey:[128,128,128],honeydew:[240,255,240],hotpink:[255,105,180],indianred:[205,92,92],indigo:[75,0,130],ivory:[255,255,240],khaki:[240,230,140],lavender:[230,230,250],lavenderblush:[255,240,245],lawngreen:[124,252,0],lemonchiffon:[255,250,205],lightblue:[173,216,230],lightcoral:[240,128,128],lightcyan:[224,255,255],lightgoldenrodyellow:[250,250,210],lightgray:[211,211,211],lightgreen:[144,238,144],lightgrey:[211,211,211],lightpink:[255,182,193],lightsalmon:[255,160,122],lightseagreen:[32,178,170],lightskyblue:[135,206,250],lightslategray:[119,136,153],lightslategrey:[119,136,153],lightsteelblue:[176,196,222],lightyellow:[255,255,224],lime:[0,255,0],limegreen:[50,205,50],linen:[250,240,230],magenta:[255,0,255],maroon:[128,0,0],mediumaquamarine:[102,205,170],mediumblue:[0,0,205],mediumorchid:[186,85,211],mediumpurple:[147,112,219],mediumseagreen:[60,179,113],mediumslateblue:[123,104,238],mediumspringgreen:[0,250,154],mediumturquoise:[72,209,204],mediumvioletred:[199,21,133],midnightblue:[25,25,112],mintcream:[245,255,250],mistyrose:[255,228,225],moccasin:[255,228,181],navajowhite:[255,222,173],navy:[0,0,128],oldlace:[253,245,230],olive:[128,128,0],olivedrab:[107,142,35],orange:[255,165,0],orangered:[255,69,0],orchid:[218,112,214],palegoldenrod:[238,232,170],palegreen:[152,251,152],paleturquoise:[175,238,238],palevioletred:[219,112,147],papayawhip:[255,239,213],peachpuff:[255,218,185],peru:[205,133,63],pink:[255,192,203],plum:[221,160,221],powderblue:[176,224,230],purple:[128,0,128],rebeccapurple:[102,51,153],red:[255,0,0],rosybrown:[188,143,143],royalblue:[65,105,225],saddlebrown:[139,69,19],salmon:[250,128,114],sandybrown:[244,164,96],seagreen:[46,139,87],seashell:[255,245,238],sienna:[160,82,45],silver:[192,192,192],skyblue:[135,206,235],slateblue:[106,90,205],slategray:[112,128,144],slategrey:[112,128,144],snow:[255,250,250],springgreen:[0,255,127],steelblue:[70,130,180],tan:[210,180,140],teal:[0,128,128],thistle:[216,191,216],tomato:[255,99,71],turquoise:[64,224,208],violet:[238,130,238],wheat:[245,222,179],white:[255,255,255],whitesmoke:[245,245,245],yellow:[255,255,0],yellowgreen:[154,205,50]};function wi(e,t,i){return e+i*(t-e)}function Ti(e,t,i){return e.map((e,r)=>wi(e,t[r],i))}var Si=class e{constructor(e,t,i,r=1,a=!0){this.r=e,this.g=t,this.b=i,this.a=r,a||(this.r*=r,this.g*=r,this.b*=r,r||this.overwriteGetter("rgb",[e,t,i,r]))}static{this.black=new e(0,0,0,1)}static{this.white=new e(1,1,1,1)}static{this.transparent=new e(0,0,0,0)}static{this.red=new e(1,0,0,1)}static parse(t){if(t instanceof e)return t;if("string"!=typeof t)return;let i=function(e){if("transparent"===(e=e.toLowerCase().trim()))return[0,0,0,0];let t=_i(bi,e);if(t){let[e,i,r]=t;return[e/255,i/255,r/255,1]}if(e.startsWith("#")&&/^#(?:[0-9a-f]{3,4}|[0-9a-f]{6}|[0-9a-f]{8})$/.test(e)){let t=e.length<6?1:2,i=1;return[gi(e.slice(i,i+=t)),gi(e.slice(i,i+=t)),gi(e.slice(i,i+=t)),gi(e.slice(i,i+t)||"ff")]}if(e.startsWith("rgb")){let t=e.match(/^rgba?\(\s*([\de.+-]+)(%)?(?:\s+|\s*(,)\s*)([\de.+-]+)(%)?(?:\s+|\s*(,)\s*)([\de.+-]+)(%)?(?:\s*([,\/])\s*([\de.+-]+)(%)?)?\s*\)$/);if(t){let[e,i,r,a,n,s,o,l,h,u,c,p]=t,d=[a||" ",o||" ",u].join("");if(" "===d||" /"===d||",,"===d||",,,"===d){let e=[r,s,h].join(""),t="%%%"===e?100:""===e?255:0;if(t){let e=[vi(+i/t,0,1),vi(+n/t,0,1),vi(+l/t,0,1),c?yi(+c,p):1];if(xi(e))return e}}return}}let i=e.match(/^hsla?\(\s*([\de.+-]+)(?:deg)?(?:\s+|\s*(,)\s*)([\de.+-]+)%(?:\s+|\s*(,)\s*)([\de.+-]+)%(?:\s*([,\/])\s*([\de.+-]+)(%)?)?\s*\)$/);if(i){let[e,t,r,a,n,s,o,l,h]=i,u=[r||" ",n||" ",o].join("");if(" "===u||" /"===u||",,"===u||",,,"===u){let e=[+t,vi(+a,0,100),vi(+s,0,100),l?yi(+l,h):1];if(xi(e))return function([e,t,i,r]){function a(r){let a=(r+e/30)%12,n=t*Math.min(i,1-i);return i-n*Math.max(-1,Math.min(a-3,9-a,1))}return e=li(e),t/=100,i/=100,[a(0),a(8),a(4),r]}(e)}}}(t);return i?new e(...i,!1):void 0}get rgb(){let{r:e,g:t,b:i,a:r}=this,a=r||1/0;return this.overwriteGetter("rgb",[e/a,t/a,i/a,r])}get hcl(){return this.overwriteGetter("hcl",function(e){let[t,i,r,a]=hi(e),n=Math.sqrt(i*i+r*r);return[Math.round(1e4*n)?li(Math.atan2(r,i)*oi):NaN,n,t,a]}(this.rgb))}get lab(){return this.overwriteGetter("lab",hi(this.rgb))}overwriteGetter(e,t){return Object.defineProperty(this,e,{value:t}),t}toString(){let[e,t,i,r]=this.rgb;return`rgba(${[e,t,i].map(e=>Math.round(255*e)).join(",")},${r})`}static interpolate(t,i,r,a="rgb"){switch(a){case"rgb":{let[a,n,s,o]=Ti(t.rgb,i.rgb,r);return new e(a,n,s,o,!1)}case"hcl":{let a,n,[s,o,l,h]=t.hcl,[u,c,p,d]=i.hcl;if(isNaN(s)||isNaN(u))isNaN(s)?isNaN(u)?a=NaN:(a=u,(1===l||0===l)&&(n=c)):(a=s,(1===p||0===p)&&(n=o));else{let e=u-s;u>s&&e>180?e-=360:u<s&&s-u>180&&(e+=360),a=s+r*e}let[f,m,_,g]=function([e,t,i,r]){return e=isNaN(e)?0:e*si,pi([i,Math.cos(e)*t,Math.sin(e)*t,r])}([a,n??wi(o,c,r),wi(l,p,r),wi(h,d,r)]);return new e(f,m,_,g,!1)}case"lab":{let[a,n,s,o]=pi(Ti(t.lab,i.lab,r));return new e(a,n,s,o,!1)}}}},Pi=class{constructor(e,t,i){this.sensitivity=e?t?"variant":"case":t?"accent":"base",this.locale=i,this.collator=new Intl.Collator(this.locale?this.locale:[],{sensitivity:this.sensitivity,usage:"search"})}compare(e,t){return this.collator.compare(e,t)}resolvedLocale(){return new Intl.Collator(this.locale?this.locale:[]).resolvedOptions().locale}},Ii=["bottom","center","top"],Mi=class{constructor(e,t,i,r,a,n){this.text=e,this.image=t,this.scale=i,this.fontStack=r,this.textColor=a,this.verticalAlign=n}},Ei=class e{constructor(e){this.sections=e}static fromString(t){return new e([new Mi(t,null,null,null,null,null)])}isEmpty(){return 0===this.sections.length||!this.sections.some(e=>0!==e.text.length||e.image&&0!==e.image.name.length)}static factory(t){return t instanceof e?t:e.fromString(t)}toString(){return 0===this.sections.length?"":this.sections.map(e=>e.text).join("")}},Ai=class e{constructor(e){this.values=e.slice()}static parse(t){if(t instanceof e)return t;if("number"==typeof t)return new e([t,t,t,t]);if(Array.isArray(t)&&!(t.length<1||t.length>4)){for(let e of t)if("number"!=typeof e)return;switch(t.length){case 1:t=[t[0],t[0],t[0],t[0]];break;case 2:t=[t[0],t[1],t[0],t[1]];break;case 3:t=[t[0],t[1],t[2],t[1]]}return new e(t)}}toString(){return JSON.stringify(this.values)}static interpolate(t,i,r){return new e(Ti(t.values,i.values,r))}},Ci=class e{constructor(e){this.values=e.slice()}static parse(t){if(t instanceof e)return t;if("number"==typeof t)return new e([t]);if(Array.isArray(t)){for(let e of t)if("number"!=typeof e)return;return new e(t)}}toString(){return JSON.stringify(this.values)}static interpolate(t,i,r){return new e(Ti(t.values,i.values,r))}},Di=class e{constructor(e){this.values=e.slice()}static parse(t){if(t instanceof e)return t;if("string"==typeof t){let i=Si.parse(t);return i?new e([i]):void 0}if(!Array.isArray(t))return;let i=[];for(let e of t){if("string"!=typeof e)return;let t=Si.parse(e);if(!t)return;i.push(t)}return new e(i)}toString(){return JSON.stringify(this.values)}static interpolate(t,i,r,a="rgb"){let n=[];if(t.values.length!=i.values.length)throw Error(`colorArray: Arrays have mismatched length (${t.values.length} vs. ${i.values.length}), cannot interpolate.`);for(let e=0;e<t.values.length;e++)n.push(Si.interpolate(t.values[e],i.values[e],r,a));return new e(n)}},zi=class extends Error{constructor(e,t){super(e),this.name="RuntimeError",this.path=t}toJSON(){return this.message}},Ri=/* @__PURE__ */new Set(["center","left","right","top","bottom","top-left","top-right","bottom-left","bottom-right"]),ki=class e{constructor(e){this.values=e.slice()}static parse(t){if(t instanceof e)return t;if(Array.isArray(t)&&!(t.length<1)&&t.length%2==0){for(let e=0;e<t.length;e+=2){let i=t[e],r=t[e+1];if("string"!=typeof i||!Ri.has(i)||!Array.isArray(r)||2!==r.length||"number"!=typeof r[0]||"number"!=typeof r[1])return}return new e(t)}}toString(){return JSON.stringify(this.values)}static interpolate(t,i,r,a){let n=t.values,s=i.values;if(n.length!==s.length)throw new zi(`Cannot interpolate values of different length. from: ${t.toString()}, to: ${i.toString()}`,a);let o=[];for(let e=0;e<n.length;e+=2){if(n[e]!==s[e])throw new zi(`Cannot interpolate values containing mismatched anchors. from[${e}]: ${n[e]}, to[${e}]: ${s[e]}`,a);o.push(n[e]);let[t,i]=n[e+1],[l,h]=s[e+1];o.push([wi(t,l,r),wi(i,h,r)])}return new e(o)}},Li=class e{constructor(e){this.name=e.name,this.available=e.available}toString(){return this.name}static fromString(t){return t?new e({name:t,available:!1}):null}},Fi=class e{constructor(e,t,i){this.from=e,this.to=t,this.transition=i}toString(){return this.from===this.to&&1===this.transition?this.from:JSON.stringify([this.from,this.to,this.transition])}static interpolate(t,i,r){return new e(t,i,r)}static parse(t){return t instanceof e?t:Array.isArray(t)&&3===t.length&&"string"==typeof t[0]&&"string"==typeof t[1]&&"number"==typeof t[2]?new e(t[0],t[1],t[2]):"object"==typeof t&&"string"==typeof t.from&&"string"==typeof t.to&&"number"==typeof t.transition?new e(t.from,t.to,t.transition):"string"==typeof t?new e(t,t,1):void 0}};function Bi(e,t,i,r){return"number"==typeof e&&e>=0&&e<=255&&"number"==typeof t&&t>=0&&t<=255&&"number"==typeof i&&i>=0&&i<=255?void 0===r||"number"==typeof r&&r>=0&&r<=1?null:`Invalid rgba value [${[e,t,i,r].join(", ")}]: 'a' must be between 0 and 1.`:`Invalid rgba value [${("number"==typeof r?[e,t,i,r]:[e,t,i]).join(", ")}]: 'r', 'g', and 'b' must be between 0 and 255.`}function Oi(e){if(null===e||"string"==typeof e||"boolean"==typeof e||"number"==typeof e||e instanceof Fi||e instanceof Si||e instanceof Pi||e instanceof Ei||e instanceof Ai||e instanceof Ci||e instanceof Di||e instanceof ki||e instanceof Li)return!0;if(Array.isArray(e)){for(let t of e)if(!Oi(t))return!1;return!0}if("object"==typeof e){for(let t in e)if(!Oi(e[t]))return!1;return!0}return!1}function Vi(e){if(null===e)return Rt;if("string"==typeof e)return Lt;if("boolean"==typeof e)return Ft;if("number"==typeof e)return kt;if(e instanceof Si)return Bt;if(e instanceof Fi)return Ot;if(e instanceof Pi)return Nt;if(e instanceof Ei)return Ut;if(e instanceof Ai)return Gt;if(e instanceof Ci)return Zt;if(e instanceof Di)return $t;if(e instanceof ki)return Wt;if(e instanceof Li)return qt;if(Array.isArray(e)){let t,i=e.length;for(let r of e){let e=Vi(r);if(t){if(t===e)continue;t=jt;break}t=e}return Ht(t||jt,i)}return Vt}function ji(e){let t=typeof e;return null===e?"":"string"===t||"number"===t||"boolean"===t?String(e):e instanceof Si||e instanceof Fi||e instanceof Ei||e instanceof Ai||e instanceof Ci||e instanceof Di||e instanceof ki||e instanceof Li?e.toString():JSON.stringify(e)}var Ni=class e{constructor(e,t){this.type=e,this.value=t}static parse(t,i){if(2!==t.length)return i.error(`'literal' expression requires exactly one argument, but found ${t.length-1} instead.`);if(!Oi(t[1]))return i.error("invalid value");let r=t[1],a=Vi(r),n=i.expectedType;return"array"===a.kind&&0===a.N&&n&&"array"===n.kind&&("number"!=typeof n.N||0===n.N)&&(a=n),new e(a,r)}evaluate(){return this.value}eachChild(){}outputDefined(){return!0}},Ui={string:Lt,number:kt,boolean:Ft,object:Vt},Gi=class e{constructor(e,t,i){this.type=e,this.args=t,this.key=i}static parse(t,i){if(t.length<2)return i.error("Expected at least one argument.");let r,a=1,n=t[0];if("array"===n){let e,n;if(t.length>2){let r=t[1];if("string"!=typeof r||!(r in Ui)||"object"===r)return i.error('The item type argument of "array" must be one of string, number, boolean',1);e=Ui[r],a++}else e=jt;if(t.length>3){if(null!==t[2]&&("number"!=typeof t[2]||t[2]<0||t[2]!==Math.floor(t[2])))return i.error('The length argument to "array" must be a positive integer literal',2);n=t[2],a++}r=Ht(e,n)}else{if(!Ui[n])throw Error(`Types doesn't contain name = ${n}`);r=Ui[n]}let s=[];for(;a<t.length;a++){let e=i.parse(t[a],a,jt);if(!e)return null;s.push(e)}return new e(r,s,i.key)}evaluate(e){for(let t=0;t<this.args.length;t++){let i=this.args[t].evaluate(e);if(!Kt(this.type,Vi(i)))return i;if(t===this.args.length-1)throw new zi(`Expected value to be of type ${Xt(this.type)}, but found ${Xt(Vi(i))} instead.`,this.key)}throw Error()}eachChild(e){this.args.forEach(e)}outputDefined(){return this.args.every(e=>e.outputDefined())}},$i={"to-boolean":Ft,"to-color":Bt,"to-number":kt,"to-string":Lt},Zi=class e{constructor(e,t,i){this.type=e,this.args=t,this.key=i}static parse(t,i){if(t.length<2)return i.error("Expected at least one argument.");let r=t[0];if(!$i[r])throw Error(`Can't parse ${r} as it is not part of the known types`);if(("to-boolean"===r||"to-string"===r)&&2!==t.length)return i.error("Expected one argument.");let a=$i[r],n=[];for(let e=1;e<t.length;e++){let r=i.parse(t[e],e,jt);if(!r)return null;n.push(r)}return new e(a,n,i.key)}evaluate(e){switch(this.type.kind){case"boolean":return!!this.args[0].evaluate(e);case"color":{let t,i;for(let r of this.args){if(t=r.evaluate(e),i=null,t instanceof Si)return t;if("string"==typeof t){let i=e.parseColor(t);if(i)return i}else if(Array.isArray(t)&&(i=t.length<3||t.length>4?`Invalid rgba value ${JSON.stringify(t)}: expected an array containing either three or four numeric values.`:Bi(t[0],t[1],t[2],t[3]),!i))return new Si(t[0]/255,t[1]/255,t[2]/255,t[3])}throw new zi(i||`Could not parse color from value '${"string"==typeof t?t:JSON.stringify(t)}'`,this.key)}case"padding":{let t;for(let i of this.args){t=i.evaluate(e);let r=Ai.parse(t);if(r)return r}throw new zi(`Could not parse padding from value '${"string"==typeof t?t:JSON.stringify(t)}'`,this.key)}case"numberArray":{let t;for(let i of this.args){t=i.evaluate(e);let r=Ci.parse(t);if(r)return r}throw new zi(`Could not parse numberArray from value '${"string"==typeof t?t:JSON.stringify(t)}'`,this.key)}case"colorArray":{let t;for(let i of this.args){t=i.evaluate(e);let r=Di.parse(t);if(r)return r}throw new zi(`Could not parse colorArray from value '${"string"==typeof t?t:JSON.stringify(t)}'`,this.key)}case"variableAnchorOffsetCollection":{let t;for(let i of this.args){t=i.evaluate(e);let r=ki.parse(t);if(r)return r}throw new zi(`Could not parse variableAnchorOffsetCollection from value '${"string"==typeof t?t:JSON.stringify(t)}'`,this.key)}case"number":{let t=null;for(let i of this.args){if(t=i.evaluate(e),null===t)return 0;let r=Number(t);if(!isNaN(r))return r}throw new zi(`Could not convert ${JSON.stringify(t)} to number.`,this.key)}case"formatted":return Ei.fromString(ji(this.args[0].evaluate(e)));case"resolvedImage":return Li.fromString(ji(this.args[0].evaluate(e)));case"projectionDefinition":{let t=this.args[0].evaluate(e);if(Fi.parse(t))return t;throw new zi(`Could not parse projectionDefinition from value '${"string"==typeof t?t:JSON.stringify(t)}'`,this.key)}default:return ji(this.args[0].evaluate(e))}}eachChild(e){this.args.forEach(e)}outputDefined(){return this.args.every(e=>e.outputDefined())}},qi=["Unknown","Point","LineString","Polygon"],Wi=class{constructor(){this.globals=null,this.feature=null,this.featureState=null,this.formattedSection=null,this._parseColorCache=/* @__PURE__ */new Map,this.availableImages=null,this.canonical=null}id(){return this.feature&&"id"in this.feature?this.feature.id:null}geometryType(){return this.feature?"number"==typeof this.feature.type?qi[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||{}}parseColor(e){let t=this._parseColorCache.get(e);return t||(t=Si.parse(e),this._parseColorCache.set(e,t)),t}},Hi=class e{constructor(e,t,i=[],r,a=new zt,n=[]){this.registry=e,this.path=i,this.key=i.map(e=>`[${e}]`).join(""),this.scope=a,this.errors=n,this.expectedType=r,this._isConstant=t}parse(e,t,i,r,a={}){return t?this.concat(t,i,r)._parse(e,a):this._parse(e,a)}_parse(e,t){(null===e||"string"==typeof e||"boolean"==typeof e||"number"==typeof e)&&(e=["literal",e]);let i=this.key;function r(e,t,r){return"assert"===r?new Gi(t,[e],i):"coerce"===r?new Zi(t,[e],i):e}if(Array.isArray(e)){if(0===e.length)return this.error('Expected an array with at least one element. If you wanted a literal array, use ["literal", []].');let i=e[0];if("string"!=typeof i)return this.error(`Expression name must be a string, but found ${typeof i} instead. If you wanted a literal array, use ["literal", [...]].`,0),null;let a=this.registry[i];if(a){let i=a.parse(e,this);if(!i)return null;if(this.expectedType){let e=this.expectedType,a=i.type;if("string"!==e.kind&&"number"!==e.kind&&"boolean"!==e.kind&&"object"!==e.kind&&"array"!==e.kind||"value"!==a.kind){if("projectionDefinition"===e.kind&&["string","array","value"].includes(a.kind)||["color","formatted","resolvedImage"].includes(e.kind)&&["value","string"].includes(a.kind)||["padding","numberArray"].includes(e.kind)&&["value","number","array"].includes(a.kind)||"colorArray"===e.kind&&["value","string","array"].includes(a.kind)||"variableAnchorOffsetCollection"===e.kind&&["value","array"].includes(a.kind))i=r(i,e,t.typeAnnotation||"coerce");else if(this.checkSubtype(e,a))return null}else i=r(i,e,t.typeAnnotation||"assert")}if(!(i instanceof Ni)&&"resolvedImage"!==i.type.kind&&this._isConstant(i)){let t=new Wi;try{i=new Ni(i.type,i.evaluate(t))}catch(e){return this.error(e.message),null}}return i}return this.error(`Unknown expression "${i}". If you wanted a literal array, use ["literal", [...]].`,0)}return void 0===e?this.error("'undefined' value invalid. Use null instead."):"object"==typeof e?this.error('Bare objects invalid. Use ["literal", {...}] instead.'):this.error(`Expected an array, but found ${typeof e} instead.`)}concat(t,i,r){let a="number"==typeof t?this.path.concat(t):this.path,n=r?this.scope.concat(r):this.scope;return new e(this.registry,this._isConstant,a,i||null,n,this.errors)}error(e,...t){let i=`${this.key}${t.map(e=>`[${e}]`).join("")}`;this.errors.push(new Dt(i,e))}checkSubtype(e,t){let i=Kt(e,t);return i&&this.error(i),i}},Xi=class e{constructor(e,t){this.type=t.type,this.bindings=[].concat(e),this.result=t}evaluate(e){return this.result.evaluate(e)}eachChild(e){for(let t of this.bindings)e(t[1]);e(this.result)}static parse(t,i){if(t.length<4)return i.error(`Expected at least 3 arguments, but found ${t.length-1} instead.`);let r=[];for(let e=1;e<t.length-1;e+=2){let a=t[e];if("string"!=typeof a)return i.error(`Expected string, but found ${typeof a} instead.`,e);if(/[^a-zA-Z0-9_]/.test(a))return i.error("Variable names must contain only alphanumeric characters or '_'.",e);let n=i.parse(t[e+1],e+1);if(!n)return null;r.push([a,n])}let a=i.parse(t[t.length-1],t.length-1,i.expectedType,r);return a?new e(r,a):null}outputDefined(){return this.result.outputDefined()}},Yi=class e{constructor(e,t){this.type=t.type,this.name=e,this.boundExpression=t}static parse(t,i){if(2!==t.length||"string"!=typeof t[1])return i.error("'var' expression requires exactly one string literal argument.");let r=t[1];return i.scope.has(r)?new e(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}};function Ki(e,t,i){let r,a,n=e.length-1,s=0,o=n,l=0;for(;s<=o;)if(l=Math.floor((s+o)/2),r=e[l],a=e[l+1],r<=t){if(l===n||t<a)return l;s=l+1}else{if(!(r>t))throw new zi("Input is not a number.",i);o=l-1}return 0}var Ji=class e{constructor(e,t,i,r){this.type=e,this.input=t,this.key=r,this.labels=[],this.outputs=[];for(let[a,n]of i)this.labels.push(a),this.outputs.push(n)}static parse(t,i){if(t.length-1<4)return i.error(`Expected at least 4 arguments, but found only ${t.length-1}.`);if((t.length-1)%2!=0)return i.error("Expected an even number of arguments.");let r=i.parse(t[1],1,kt);if(!r)return null;let a=[],n=null;i.expectedType&&"value"!==i.expectedType.kind&&(n=i.expectedType);for(let e=1;e<t.length;e+=2){let r=1===e?-1/0:t[e],s=t[e+1],o=e,l=e+1;if("number"!=typeof r)return i.error('Input/output pairs for "step" expressions must be defined using literal numeric values (not computed expressions) for the input values.',o);if(a.length&&a[a.length-1][0]>=r)return i.error('Input/output pairs for "step" expressions must be arranged with input values in strictly ascending order.',o);let h=i.parse(s,l,n);if(!h)return null;n||=h.type,a.push([r,h])}return new e(n,r,a,i.key)}evaluate(e){let t=this.labels,i=this.outputs;if(1===t.length)return i[0].evaluate(e);let r=this.input.evaluate(e);if(r<=t[0])return i[0].evaluate(e);let a=t.length;return r>=t[a-1]?i[a-1].evaluate(e):i[Ki(t,r,this.key)].evaluate(e)}eachChild(e){e(this.input);for(let t of this.outputs)e(t)}outputDefined(){return this.outputs.every(e=>e.outputDefined())}},Qi=class e{constructor(e,t,i,r,a,n){this.type=e,this.operator=t,this.interpolation=i,this.input=r,this.key=n,this.labels=[],this.outputs=[];for(let[s,o]of a)this.labels.push(s),this.outputs.push(o)}static interpolationFactor(e,t,i,r){let a=0;if("exponential"===e.name)a=er(t,e.base,i,r);else if("linear"===e.name)a=er(t,1,i,r);else if("cubic-bezier"===e.name){let n=e.controlPoints;a=function(e,t,i,r){let a=3*e,n=3*(i-e)-a,s=1-a-n,o=3*t,l=3*(r-t)-o,h=1-o-l;return function(e,t=1e-6){if(e<=0)return 0;if(e>=1)return 1;let i=e;for(let c=0;c<8;c++){let r=((s*i+n)*i+a)*i-e;if(Math.abs(r)<t)return((h*i+l)*i+o)*i;let u=(3*s*i+2*n)*i+a;if(Math.abs(u)<1e-6)break;i-=r/u}let r=0,u=1;i=e;for(let o=0;o<20;o++){let o=((s*i+n)*i+a)*i;if(Math.abs(o-e)<t)break;e>o?r=i:u=i,i=.5*(r+u)}return((h*i+l)*i+o)*i}}(n[0],n[1],n[2],n[3])(er(t,1,i,r))}return a}static parse(t,i){let[r,a,n,...s]=t;if(!Array.isArray(a)||0===a.length)return i.error("Expected an interpolation type expression.",1);if("linear"===a[0])a={name:"linear"};else if("exponential"===a[0]){let e=a[1];if("number"!=typeof e)return i.error("Exponential interpolation requires a numeric base.",1,1);a={name:"exponential",base:e}}else{if("cubic-bezier"!==a[0])return i.error(`Unknown interpolation type ${String(a[0])}`,1,0);{let e=a.slice(1);if(4!==e.length||e.some(e=>"number"!=typeof e||e<0||e>1))return i.error("Cubic bezier interpolation requires four numeric arguments with values between 0 and 1.",1);a={name:"cubic-bezier",controlPoints:e}}}if(t.length-1<4)return i.error(`Expected at least 4 arguments, but found only ${t.length-1}.`);if((t.length-1)%2!=0)return i.error("Expected an even number of arguments.");if(n=i.parse(n,2,kt),!n)return null;let o=[],l=null;"interpolate-hcl"!==r&&"interpolate-lab"!==r||i.expectedType==$t?i.expectedType&&"value"!==i.expectedType.kind&&(l=i.expectedType):l=Bt;for(let e=0;e<s.length;e+=2){let t=s[e],r=s[e+1],a=e+3,n=e+4;if("number"!=typeof t)return i.error('Input/output pairs for "interpolate" expressions must be defined using literal numeric values (not computed expressions) for the input values.',a);if(o.length&&o[o.length-1][0]>=t)return i.error('Input/output pairs for "interpolate" expressions must be arranged with input values in strictly ascending order.',a);let h=i.parse(r,n,l);if(!h)return null;l||=h.type,o.push([t,h])}return ei(l,kt)||ei(l,Ot)||ei(l,Bt)||ei(l,Gt)||ei(l,Zt)||ei(l,$t)||ei(l,Wt)||ei(l,Ht(kt))?new e(l,r,a,n,o,i.key):i.error(`Type ${Xt(l)} is not interpolatable.`)}evaluate(t){let i=this.labels,r=this.outputs;if(1===i.length)return r[0].evaluate(t);let a=this.input.evaluate(t);if(a<=i[0])return r[0].evaluate(t);let n=i.length;if(a>=i[n-1])return r[n-1].evaluate(t);let s=Ki(i,a,this.key),o=i[s],l=i[s+1],h=e.interpolationFactor(this.interpolation,a,o,l),u=r[s].evaluate(t),c=r[s+1].evaluate(t);switch(this.operator){case"interpolate":switch(this.type.kind){case"number":return wi(u,c,h);case"color":return Si.interpolate(u,c,h);case"padding":return Ai.interpolate(u,c,h);case"colorArray":return Di.interpolate(u,c,h);case"numberArray":return Ci.interpolate(u,c,h);case"variableAnchorOffsetCollection":return ki.interpolate(u,c,h,this.key);case"array":return Ti(u,c,h);case"projectionDefinition":return Fi.interpolate(u,c,h)}case"interpolate-hcl":switch(this.type.kind){case"color":return Si.interpolate(u,c,h,"hcl");case"colorArray":return Di.interpolate(u,c,h,"hcl")}case"interpolate-lab":switch(this.type.kind){case"color":return Si.interpolate(u,c,h,"lab");case"colorArray":return Di.interpolate(u,c,h,"lab")}}}eachChild(e){e(this.input);for(let t of this.outputs)e(t)}outputDefined(){return this.outputs.every(e=>e.outputDefined())}};function er(e,t,i,r){let a=r-i,n=e-i;return 0===a?0:1===t?n/a:(t**+n-1)/(t**+a-1)}var tr={color:Si.interpolate,number:wi,padding:Ai.interpolate,numberArray:Ci.interpolate,colorArray:Di.interpolate,variableAnchorOffsetCollection:ki.interpolate,array:Ti},ir=class e{constructor(e,t){this.type=e,this.args=t}static parse(t,i){if(t.length<2)return i.error("Expected at least one argument.");let r=null,a=i.expectedType;a&&"value"!==a.kind&&(r=a);let n=[];for(let e of t.slice(1)){let t=i.parse(e,1+n.length,r,void 0,{typeAnnotation:"omit"});if(!t)return null;r||=t.type,n.push(t)}if(!r)throw Error("No output type");return a&&n.some(e=>Kt(a,e.type))?new e(jt,n):new e(r,n)}evaluate(e){let t,i=null,r=0;for(let a of this.args)if(r++,i=a.evaluate(e),i&&i instanceof Li&&!i.available&&(t||=i.name,i=null,r===this.args.length&&(i=t)),null!==i)break;return i}eachChild(e){this.args.forEach(e)}outputDefined(){return this.args.every(e=>e.outputDefined())}};function rr(e,t){return"=="===e||"!="===e?"boolean"===t.kind||"string"===t.kind||"number"===t.kind||"null"===t.kind||"value"===t.kind:"string"===t.kind||"number"===t.kind||"value"===t.kind}function ar(e,t,i,r){return 0===r.compare(t,i)}function nr(e,t,i){let r="=="!==e&&"!="!==e;return class a{constructor(e,t,i,r){this.lhs=e,this.rhs=t,this.key=i,this.collator=r,this.type=Ft,this.hasUntypedArgument="value"===e.type.kind||"value"===t.type.kind}static parse(e,t){if(3!==e.length&&4!==e.length)return t.error("Expected two or three arguments.");let i=e[0],n=t.parse(e[1],1,jt);if(!n)return null;if(!rr(i,n.type))return t.concat(1).error(`"${i}" comparisons are not supported for type '${Xt(n.type)}'.`);let s=t.parse(e[2],2,jt);if(!s)return null;if(!rr(i,s.type))return t.concat(2).error(`"${i}" comparisons are not supported for type '${Xt(s.type)}'.`);if(n.type.kind!==s.type.kind&&"value"!==n.type.kind&&"value"!==s.type.kind)return t.error(`Cannot compare types '${Xt(n.type)}' and '${Xt(s.type)}'.`);r&&("value"===n.type.kind&&"value"!==s.type.kind?n=new Gi(s.type,[n],t.key):"value"!==n.type.kind&&"value"===s.type.kind&&(s=new Gi(n.type,[s],t.key)));let o=null;if(4===e.length){if("string"!==n.type.kind&&"string"!==s.type.kind&&"value"!==n.type.kind&&"value"!==s.type.kind)return t.error("Cannot use collator to compare non-string types.");if(o=t.parse(e[3],3,Nt),!o)return null}return new a(n,s,t.key,o)}evaluate(a){let n=this.lhs.evaluate(a),s=this.rhs.evaluate(a);if(r&&this.hasUntypedArgument){let t=Vi(n),i=Vi(s);if(t.kind!==i.kind||"string"!==t.kind&&"number"!==t.kind)throw new zi(`Expected arguments for "${e}" to be (string, string) or (number, number), but found (${t.kind}, ${i.kind}) instead.`,this.key)}if(this.collator&&!r&&this.hasUntypedArgument){let e=Vi(n),i=Vi(s);if("string"!==e.kind||"string"!==i.kind)return t(a,n,s)}return this.collator?i(a,n,s,this.collator.evaluate(a)):t(a,n,s)}eachChild(e){e(this.lhs),e(this.rhs),this.collator&&e(this.collator)}outputDefined(){return!0}}}var sr=nr("==",function(e,t,i){return t===i},ar),or=nr("!=",function(e,t,i){return t!==i},function(e,t,i,r){return!ar(0,t,i,r)}),lr=nr("<",function(e,t,i){return t<i},function(e,t,i,r){return r.compare(t,i)<0}),hr=nr(">",function(e,t,i){return t>i},function(e,t,i,r){return r.compare(t,i)>0}),ur=nr("<=",function(e,t,i){return t<=i},function(e,t,i,r){return r.compare(t,i)<=0}),cr=nr(">=",function(e,t,i){return t>=i},function(e,t,i,r){return r.compare(t,i)>=0}),pr=class e{constructor(e,t,i){this.type=Nt,this.locale=i,this.caseSensitive=e,this.diacriticSensitive=t}static parse(t,i){if(2!==t.length)return i.error("Expected one argument.");let r=t[1];if("object"!=typeof r||Array.isArray(r))return i.error("Collator options argument must be an object.");let a=i.parse(void 0!==r["case-sensitive"]&&r["case-sensitive"],1,Ft);if(!a)return null;let n=i.parse(void 0!==r["diacritic-sensitive"]&&r["diacritic-sensitive"],1,Ft);if(!n)return null;let s=null;return r.locale&&(s=i.parse(r.locale,1,Lt),!s)?null:new e(a,n,s)}evaluate(e){return new Pi(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}},dr=class e{constructor(e){this.type=Ut,this.sections=e}static parse(t,i){if(t.length<2)return i.error("Expected at least one argument.");let r=t[1];if(!Array.isArray(r)&&"object"==typeof r)return i.error("First argument must be an image or text section.");let a=[],n=!1;for(let e=1;e<=t.length-1;++e){let r=t[e];if(n&&"object"==typeof r&&!Array.isArray(r)){n=!1;let e=null;if(r["font-scale"]&&(e=i.parse(r["font-scale"],1,kt),!e))return null;let t=null;if(r["text-font"]&&(t=i.parse(r["text-font"],1,Ht(Lt)),!t))return null;let s=null;if(r["text-color"]&&(s=i.parse(r["text-color"],1,Bt),!s))return null;let o=null;if(r["vertical-align"]){if("string"==typeof r["vertical-align"]&&!Ii.includes(r["vertical-align"]))return i.error(`'vertical-align' must be one of: 'bottom', 'center', 'top' but found '${r["vertical-align"]}' instead.`);if(o=i.parse(r["vertical-align"],1,Lt),!o)return null}let l=a[a.length-1];l.scale=e,l.font=t,l.textColor=s,l.verticalAlign=o}else{let r=i.parse(t[e],1,jt);if(!r)return null;let s=r.type.kind;if("string"!==s&&"value"!==s&&"null"!==s&&"resolvedImage"!==s)return i.error("Formatted text type must be 'string', 'value', 'image' or 'null'.");n=!0,a.push({content:r,scale:null,font:null,textColor:null,verticalAlign:null})}}return new e(a)}evaluate(e){return new Ei(this.sections.map(t=>{let i=t.content.evaluate(e);return Vi(i)===qt?new Mi("",i,null,null,null,t.verticalAlign?t.verticalAlign.evaluate(e):null):new Mi(ji(i),null,t.scale?t.scale.evaluate(e):null,t.font?t.font.evaluate(e).join(","):null,t.textColor?t.textColor.evaluate(e):null,t.verticalAlign?t.verticalAlign.evaluate(e):null)}))}eachChild(e){for(let t of this.sections)e(t.content),t.scale&&e(t.scale),t.font&&e(t.font),t.textColor&&e(t.textColor),t.verticalAlign&&e(t.verticalAlign)}outputDefined(){return!1}},fr=8192;function mr(e,t){let i=function(e){return(180+e)/360}(e[0]),r=function(e){return(180-180/Math.PI*Math.log(Math.tan(Math.PI/4+e*Math.PI/360)))/360}(e[1]),a=2**t.z;return[Math.round(i*a*fr),Math.round(r*a*fr)]}function _r(e,t){let i=2**t.z,r=(e[0]/fr+t.x)/i,a=(e[1]/fr+t.y)/i;return[gr(r),yr(a)]}function gr(e){return 360*e-180}function yr(e){return 360/Math.PI*Math.atan(Math.exp((180-360*e)*Math.PI/180))-90}function vr(e,t){e[0]=Math.min(e[0],t[0]),e[1]=Math.min(e[1],t[1]),e[2]=Math.max(e[2],t[0]),e[3]=Math.max(e[3],t[1])}function xr(e,t){return!(e[0]<=t[0]||e[2]>=t[2]||e[1]<=t[1]||e[3]>=t[3])}function br(e,t,i){return t[1]>e[1]!=i[1]>e[1]&&e[0]<(i[0]-t[0])*(e[1]-t[1])/(i[1]-t[1])+t[0]}function wr(e,t,i){let r=e[0]-t[0],a=e[1]-t[1],n=e[0]-i[0],s=e[1]-i[1];return r*s-n*a===0&&r*n<=0&&a*s<=0}function Tr(e,t,i,r){let a=[t[0]-e[0],t[1]-e[1]];return 0!==function(e,t){return e[0]*t[1]-e[1]*t[0]}([r[0]-i[0],r[1]-i[1]],a)&&!(!Ar(e,t,i,r)||!Ar(i,r,e,t))}function Sr(e,t,i){for(let r of i)for(let i=0;i<r.length-1;++i)if(Tr(e,t,r[i],r[i+1]))return!0;return!1}function Pr(e,t,i=!1){let r=!1;for(let a of t)for(let t=0;t<a.length-1;t++){if(wr(e,a[t],a[t+1]))return i;br(e,a[t],a[t+1])&&(r=!r)}return r}function Ir(e,t){for(let i of t)if(Pr(e,i))return!0;return!1}function Mr(e,t){for(let i of e)if(!Pr(i,t))return!1;for(let i=0;i<e.length-1;++i)if(Sr(e[i],e[i+1],t))return!1;return!0}function Er(e,t){for(let i of t)if(Mr(e,i))return!0;return!1}function Ar(e,t,i,r){let a=e[0]-i[0],n=e[1]-i[1],s=t[0]-i[0],o=t[1]-i[1],l=r[0]-i[0],h=r[1]-i[1],u=a*h-l*n,c=s*h-l*o;return u>0&&c<0||u<0&&c>0}function Cr(e,t,i){let r=[];for(let a=0;a<e.length;a++){let n=[];for(let r=0;r<e[a].length;r++){let s=mr(e[a][r],i);vr(t,s),n.push(s)}r.push(n)}return r}function Dr(e,t,i){let r=[];for(let a=0;a<e.length;a++){let n=Cr(e[a],t,i);r.push(n)}return r}function zr(e,t,i,r){if(e[0]<i[0]||e[0]>i[2]){let t=.5*r,a=e[0]-i[0]>t?-r:i[0]-e[0]>t?r:0;0===a&&(a=e[0]-i[2]>t?-r:i[2]-e[0]>t?r:0),e[0]+=a}vr(t,e)}function Rr(e,t,i,r){let a=2**r.z*fr,n=[r.x*fr,r.y*fr],s=[];for(let o of e)for(let e of o){let r=[e.x+n[0],e.y+n[1]];zr(r,t,i,a),s.push(r)}return s}function kr(e,t,i,r){let a=2**r.z*fr,n=[r.x*fr,r.y*fr],s=[];for(let o of e){let e=[];for(let i of o){let r=[i.x+n[0],i.y+n[1]];vr(t,r),e.push(r)}s.push(e)}if(t[2]-t[0]<=a/2){!function(e){e[0]=e[1]=1/0,e[2]=e[3]=-1/0}(t);for(let e of s)for(let r of e)zr(r,t,i,a)}return s}var Lr=class e{constructor(e,t){this.type=Ft,this.geojson=e,this.geometries=t}static parse(t,i){if(2!==t.length)return i.error(`'within' expression requires exactly one argument, but found ${t.length-1} instead.`);if(Oi(t[1])){let i=t[1];if("FeatureCollection"===i.type){let t=[];for(let e of i.features){let{type:i,coordinates:r}=e.geometry;"Polygon"===i&&t.push(r),"MultiPolygon"===i&&t.push(...r)}if(t.length)return new e(i,{type:"MultiPolygon",coordinates:t})}else if("Feature"===i.type){let t=i.geometry.type;if("Polygon"===t||"MultiPolygon"===t)return new e(i,i.geometry)}else if("Polygon"===i.type||"MultiPolygon"===i.type)return new e(i,i)}return i.error("'within' expression requires valid geojson object that contains polygon geometry type.")}evaluate(e){if(null!=e.geometry()&&null!=e.canonicalID()){if("Point"===e.geometryType())return function(e,t){let i=[1/0,1/0,-1/0,-1/0],r=[1/0,1/0,-1/0,-1/0],a=e.canonicalID();if("Polygon"===t.type){let n=Cr(t.coordinates,r,a),s=Rr(e.geometry(),i,r,a);if(!xr(i,r))return!1;for(let e of s)if(!Pr(e,n))return!1}if("MultiPolygon"===t.type){let n=Dr(t.coordinates,r,a),s=Rr(e.geometry(),i,r,a);if(!xr(i,r))return!1;for(let e of s)if(!Ir(e,n))return!1}return!0}(e,this.geometries);if("LineString"===e.geometryType())return function(e,t){let i=[1/0,1/0,-1/0,-1/0],r=[1/0,1/0,-1/0,-1/0],a=e.canonicalID();if("Polygon"===t.type){let n=Cr(t.coordinates,r,a),s=kr(e.geometry(),i,r,a);if(!xr(i,r))return!1;for(let e of s)if(!Mr(e,n))return!1}if("MultiPolygon"===t.type){let n=Dr(t.coordinates,r,a),s=kr(e.geometry(),i,r,a);if(!xr(i,r))return!1;for(let e of s)if(!Er(e,n))return!1}return!0}(e,this.geometries)}return!1}eachChild(){}outputDefined(){return!0}},Fr=class{constructor(e=[],t=(e,t)=>e<t?-1:+(e>t)){if(this.data=e,this.length=this.data.length,this.compare=t,this.length>0)for(let i=(this.length>>1)-1;i>=0;i--)this._down(i)}push(e){this.data.push(e),this._up(this.length++)}pop(){if(0===this.length)return;let e=this.data[0],t=this.data.pop();return--this.length>0&&(this.data[0]=t,this._down(0)),e}peek(){return this.data[0]}_up(e){let{data:t,compare:i}=this,r=t[e];for(;e>0;){let a=e-1>>1,n=t[a];if(i(r,n)>=0)break;t[e]=n,e=a}t[e]=r}_down(e){let{data:t,compare:i}=this,r=this.length>>1,a=t[e];for(;e<r;){let r=1+(e<<1),n=r+1;if(n<this.length&&i(t[n],t[r])<0&&(r=n),i(t[r],a)>=0)break;t[e]=t[r],e=r}t[e]=a}};function Br(e,t,i=0,r=e.length-1,a=Vr){for(;r>i;){if(r-i>600){let n=r-i+1,s=t-i+1,o=Math.log(n),l=.5*Math.exp(2*o/3),h=.5*Math.sqrt(o*l*(n-l)/n)*(s-n/2<0?-1:1);Br(e,t,Math.max(i,Math.floor(t-s*l/n+h)),Math.min(r,Math.floor(t+(n-s)*l/n+h)),a)}let n=e[t],s=i,o=r;for(Or(e,i,t),a(e[r],n)>0&&Or(e,i,r);s<o;){for(Or(e,s,o),s++,o--;a(e[s],n)<0;)s++;for(;a(e[o],n)>0;)o--}0===a(e[i],n)?Or(e,i,o):(o++,Or(e,o,r)),o<=t&&(i=o+1),t<=o&&(r=o-1)}}function Or(e,t,i){let r=e[t];e[t]=e[i],e[i]=r}function Vr(e,t){return e<t?-1:+(e>t)}function jr(e,t){if(e.length<=1)return[e];let i,r,a=[];for(let n of e){let e=Ur(n);0!==e&&(n.area=Math.abs(e),void 0===r&&(r=e<0),r===e<0?(i&&a.push(i),i=[n]):i.push(n))}if(i&&a.push(i),t>1)for(let n=0;n<a.length;n++)a[n].length<=t||(Br(a[n],t,1,a[n].length-1,Nr),a[n]=a[n].slice(0,t));return a}function Nr(e,t){return t.area-e.area}function Ur(e){let t=0;for(let i,r,a=0,n=e.length,s=n-1;a<n;s=a++)i=e[a],r=e[s],t+=(r.x-i.x)*(i.y+r.y);return t}var Gr=Math.PI/180,$r=class{constructor(e){let t=6378.137*Gr*1e3,i=Math.cos(e*Gr),r=1/(1-.0066943799901413165*(1-i*i)),a=Math.sqrt(r);this.kx=t*a*i,this.ky=t*a*r*.9933056200098587}distance(e,t){let i=this.wrap(e[0]-t[0])*this.kx,r=(e[1]-t[1])*this.ky;return Math.sqrt(i*i+r*r)}pointOnLine(e,t){let i,r,a,n,s=1/0;for(let o=0;o<e.length-1;o++){let l=e[o][0],h=e[o][1],u=this.wrap(e[o+1][0]-l)*this.kx,c=(e[o+1][1]-h)*this.ky,p=0;(0!==u||0!==c)&&(p=(this.wrap(t[0]-l)*this.kx*u+(t[1]-h)*this.ky*c)/(u*u+c*c),p>1?(l=e[o+1][0],h=e[o+1][1]):p>0&&(l+=u/this.kx*p,h+=c/this.ky*p)),u=this.wrap(t[0]-l)*this.kx,c=(t[1]-h)*this.ky;let d=u*u+c*c;d<s&&(s=d,i=l,r=h,a=o,n=p)}return{point:[i,r],index:a,t:Math.max(0,Math.min(1,n))}}wrap(e){for(;e<-180;)e+=360;for(;e>180;)e-=360;return e}};function Zr(e,t){return t[0]-e[0]}function qr(e){return e[1]-e[0]+1}function Wr(e,t){return e[1]>=e[0]&&e[1]<t}function Hr(e,t){if(e[0]>e[1])return[null,null];let i=qr(e);if(t){if(2===i)return[e,null];let t=Math.floor(i/2);return[[e[0],e[0]+t],[e[0]+t,e[1]]]}if(1===i)return[e,null];let r=Math.floor(i/2)-1;return[[e[0],e[0]+r],[e[0]+r+1,e[1]]]}function Xr(e,t){if(!Wr(t,e.length))return[1/0,1/0,-1/0,-1/0];let i=[1/0,1/0,-1/0,-1/0];for(let r=t[0];r<=t[1];++r)vr(i,e[r]);return i}function Yr(e){let t=[1/0,1/0,-1/0,-1/0];for(let i of e)for(let e of i)vr(t,e);return t}function Kr(e){return e[0]!==-1/0&&e[1]!==-1/0&&e[2]!==1/0&&e[3]!==1/0}function Jr(e,t,i){if(!Kr(e)||!Kr(t))return NaN;let r=0,a=0;return e[2]<t[0]&&(r=t[0]-e[2]),e[0]>t[2]&&(r=e[0]-t[2]),e[1]>t[3]&&(a=e[1]-t[3]),e[3]<t[1]&&(a=t[1]-e[3]),i.distance([0,0],[r,a])}function Qr(e,t,i){let r=i.pointOnLine(t,e);return i.distance(e,r.point)}function ea(e,t,i,r,a){let n=Math.min(Qr(e,[i,r],a),Qr(t,[i,r],a)),s=Math.min(Qr(i,[e,t],a),Qr(r,[e,t],a));return Math.min(n,s)}function ta(e,t,i,r,a){if(!Wr(t,e.length)||!Wr(r,i.length))return 1/0;let n=1/0;for(let s=t[0];s<t[1];++s){let t=e[s],o=e[s+1];for(let e=r[0];e<r[1];++e){let r=i[e],s=i[e+1];if(Tr(t,o,r,s))return 0;n=Math.min(n,ea(t,o,r,s,a))}}return n}function ia(e,t,i,r,a){if(!Wr(t,e.length)||!Wr(r,i.length))return NaN;let n=1/0;for(let s=t[0];s<=t[1];++s)for(let t=r[0];t<=r[1];++t)if(n=Math.min(n,a.distance(e[s],i[t])),0===n)return n;return n}function ra(e,t,i){if(Pr(e,t,!0))return 0;let r=1/0;for(let a of t){let t=a[0],n=a[a.length-1];if(t!==n&&(r=Math.min(r,Qr(e,[n,t],i)),0===r))return r;let s=i.pointOnLine(a,e);if(r=Math.min(r,i.distance(e,s.point)),0===r)return r}return r}function aa(e,t,i,r){if(!Wr(t,e.length))return NaN;for(let n=t[0];n<=t[1];++n)if(Pr(e[n],i,!0))return 0;let a=1/0;for(let n=t[0];n<t[1];++n){let t=e[n],s=e[n+1];for(let e of i)for(let i=0,n=e.length,o=n-1;i<n;o=i++){let n=e[o],l=e[i];if(Tr(t,s,n,l))return 0;a=Math.min(a,ea(t,s,n,l,r))}}return a}function na(e,t){for(let i of e)for(let e of i)if(Pr(e,t,!0))return!0;return!1}function sa(e,t,i,r=1/0){let a=Yr(e),n=Yr(t);if(r!==1/0&&Jr(a,n,i)>=r)return r;if(xr(a,n)){if(na(e,t))return 0}else if(na(t,e))return 0;let s=1/0;for(let o of e)for(let e=0,r=o.length,a=r-1;e<r;a=e++){let r=o[a],n=o[e];for(let e of t)for(let t=0,a=e.length,o=a-1;t<a;o=t++){let a=e[o],l=e[t];if(Tr(r,n,a,l))return 0;s=Math.min(s,ea(r,n,a,l,i))}}return s}function oa(e,t,i,r,a,n){if(!n)return;let s=Jr(Xr(r,n),a,i);s<t&&e.push([s,n,[0,0]])}function la(e,t,i,r,a,n,s){if(!n||!s)return;let o=Jr(Xr(r,n),Xr(a,s),i);o<t&&e.push([o,n,s])}function ha(e,t,i,r,a=1/0){let n=Math.min(r.distance(e[0],i[0][0]),a);if(0===n)return n;let s=new Fr([[0,[0,e.length-1],[0,0]]],Zr),o=Yr(i);for(;s.length>0;){let a=s.pop();if(a[0]>=n)continue;let l=a[1],h=t?50:100;if(qr(l)<=h){if(!Wr(l,e.length))return NaN;if(t){let t=aa(e,l,i,r);if(isNaN(t)||0===t)return t;n=Math.min(n,t)}else for(let t=l[0];t<=l[1];++t){let a=ra(e[t],i,r);if(n=Math.min(n,a),0===n)return 0}}else{let i=Hr(l,t);oa(s,n,r,e,o,i[0]),oa(s,n,r,e,o,i[1])}}return n}function ua(e,t,i,r,a,n=1/0){let s=Math.min(n,a.distance(e[0],i[0]));if(0===s)return s;let o=new Fr([[0,[0,e.length-1],[0,i.length-1]]],Zr);for(;o.length>0;){let n=o.pop();if(n[0]>=s)continue;let l=n[1],h=n[2],u=t?50:100,c=r?50:100;if(qr(l)<=u&&qr(h)<=c){if(!Wr(l,e.length)&&Wr(h,i.length))return NaN;let n;if(t&&r)n=ta(e,l,i,h,a),s=Math.min(s,n);else if(t&&!r){let t=e.slice(l[0],l[1]+1);for(let e=h[0];e<=h[1];++e)if(n=Qr(i[e],t,a),s=Math.min(s,n),0===s)return s}else if(!t&&r){let t=i.slice(h[0],h[1]+1);for(let i=l[0];i<=l[1];++i)if(n=Qr(e[i],t,a),s=Math.min(s,n),0===s)return s}else n=ia(e,l,i,h,a),s=Math.min(s,n)}else{let n=Hr(l,t),u=Hr(h,r);la(o,s,a,e,i,n[0],u[0]),la(o,s,a,e,i,n[0],u[1]),la(o,s,a,e,i,n[1],u[0]),la(o,s,a,e,i,n[1],u[1])}}return s}function ca(e){return"MultiPolygon"===e.type?e.coordinates.map(e=>({type:"Polygon",coordinates:e})):"MultiLineString"===e.type?e.coordinates.map(e=>({type:"LineString",coordinates:e})):"MultiPoint"===e.type?e.coordinates.map(e=>({type:"Point",coordinates:e})):[e]}var pa=class e{constructor(e,t){this.type=kt,this.geojson=e,this.geometries=t}static parse(t,i){if(2!==t.length)return i.error(`'distance' expression requires exactly one argument, but found ${t.length-1} instead.`);if(Oi(t[1])){let i=t[1];if("FeatureCollection"===i.type)return new e(i,i.features.map(e=>ca(e.geometry)).flat());if("Feature"===i.type)return new e(i,ca(i.geometry));if("type"in i&&"coordinates"in i)return new e(i,ca(i))}return i.error("'distance' expression requires valid geojson object that contains polygon geometry type.")}evaluate(e){if(null!=e.geometry()&&null!=e.canonicalID()){if("Point"===e.geometryType())return function(e,t){let i=e.geometry(),r=i.flat().map(t=>_r([t.x,t.y],e.canonical));if(0===i.length)return NaN;let a=new $r(r[0][1]),n=1/0;for(let s of t){switch(s.type){case"Point":n=Math.min(n,ua(r,!1,[s.coordinates],!1,a,n));break;case"LineString":n=Math.min(n,ua(r,!1,s.coordinates,!0,a,n));break;case"Polygon":n=Math.min(n,ha(r,!1,s.coordinates,a,n))}if(0===n)return n}return n}(e,this.geometries);if("LineString"===e.geometryType())return function(e,t){let i=e.geometry(),r=i.flat().map(t=>_r([t.x,t.y],e.canonical));if(0===i.length)return NaN;let a=new $r(r[0][1]),n=1/0;for(let s of t){switch(s.type){case"Point":n=Math.min(n,ua(r,!0,[s.coordinates],!1,a,n));break;case"LineString":n=Math.min(n,ua(r,!0,s.coordinates,!0,a,n));break;case"Polygon":n=Math.min(n,ha(r,!0,s.coordinates,a,n))}if(0===n)return n}return n}(e,this.geometries);if("Polygon"===e.geometryType())return function(e,t){let i=e.geometry();if(0===i.length||0===i[0].length)return NaN;let r=jr(i,0).map(t=>t.map(t=>t.map(t=>_r([t.x,t.y],e.canonical)))),a=new $r(r[0][0][0][1]),n=1/0;for(let s of t)for(let e of r){switch(s.type){case"Point":n=Math.min(n,ha([s.coordinates],!1,e,a,n));break;case"LineString":n=Math.min(n,ha(s.coordinates,!0,e,a,n));break;case"Polygon":n=Math.min(n,sa(e,s.coordinates,a,n))}if(0===n)return n}return n}(e,this.geometries)}return NaN}eachChild(){}outputDefined(){return!0}},da=class e{constructor(e){this.key=e,this.type=jt}static parse(t,i){if(2!==t.length)return i.error(`Expected 1 argument, but found ${t.length-1} instead.`);let r=t[1];return null==r?i.error("Global state property must be defined."):"string"==typeof r?new e(r):i.error(`Global state property must be string, but found ${typeof t[1]} instead.`)}evaluate(e){let t=e.globals?.globalState;return t&&0!==Object.keys(t).length?_i(t,this.key)??null:null}eachChild(){}outputDefined(){return!1}},fa={"==":sr,"!=":or,">":hr,"<":lr,">=":cr,"<=":ur,array:Gi,at:class e{constructor(e,t,i,r){this.type=e,this.index=t,this.input=i,this.key=r}static parse(t,i){if(3!==t.length)return i.error(`Expected 2 arguments, but found ${t.length-1} instead.`);let r=i.parse(t[1],1,kt),a=i.parse(t[2],2,Ht(i.expectedType||jt));if(!r||!a)return null;let n=a.type;return new e(n.itemType,r,a,i.key)}evaluate(e){let t=this.index.evaluate(e),i=this.input.evaluate(e);if(t<0)throw new zi(`Array index out of bounds: ${t} < 0.`,this.key);if(t>=i.length)throw new zi(`Array index out of bounds: ${t} > ${i.length-1}.`,this.key);if(t!==Math.floor(t))throw new zi(`Array index must be an integer, but found ${t} instead.`,this.key);return i[t]}eachChild(e){e(this.index),e(this.input)}outputDefined(){return!1}},boolean:Gi,case:class e{constructor(e,t,i){this.type=e,this.branches=t,this.otherwise=i}static parse(t,i){if(t.length<4)return i.error(`Expected at least 3 arguments, but found only ${t.length-1}.`);if(t.length%2!=0)return i.error("Expected an odd number of arguments.");let r;i.expectedType&&"value"!==i.expectedType.kind&&(r=i.expectedType);let a=[];for(let e=1;e<t.length-1;e+=2){let n=i.parse(t[e],e,Ft);if(!n)return null;let s=i.parse(t[e+1],e+1,r);if(!s)return null;a.push([n,s]),r||=s.type}let n=i.parse(t[t.length-1],t.length-1,r);if(!n)return null;if(!r)throw Error("Can't infer output type");return new e(r,a,n)}evaluate(e){for(let[t,i]of this.branches)if(t.evaluate(e))return i.evaluate(e);return this.otherwise.evaluate(e)}eachChild(e){for(let[t,i]of this.branches)e(t),e(i);e(this.otherwise)}outputDefined(){return this.branches.every(([e,t])=>t.outputDefined())&&this.otherwise.outputDefined()}},coalesce:ir,collator:pr,format:dr,image:class e{constructor(e){this.type=qt,this.input=e}static parse(t,i){if(2!==t.length)return i.error("Expected two arguments.");let r=i.parse(t[1],1,Lt);return r?new e(r):i.error("No image name provided.")}evaluate(e){let t=this.input.evaluate(e),i=Li.fromString(t);return i&&e.availableImages&&(i.available=e.availableImages.indexOf(t)>-1),i}eachChild(e){e(this.input)}outputDefined(){return!1}},in:class e{constructor(e,t,i){this.needle=e,this.haystack=t,this.key=i,this.type=Ft}static parse(t,i){if(3!==t.length)return i.error(`Expected 2 arguments, but found ${t.length-1} instead.`);let r=i.parse(t[1],1,jt),a=i.parse(t[2],2,jt);return r&&a?Jt(r.type,[Ft,Lt,kt,Rt,jt])?new e(r,a,i.key):i.error(`Expected first argument to be of type boolean, string, number or null, but found ${Xt(r.type)} instead`):null}evaluate(e){let t=this.needle.evaluate(e),i=this.haystack.evaluate(e);if(!i)return!1;if(!Qt(t,["boolean","string","number","null"]))throw new zi(`Expected first argument to be of type boolean, string, number or null, but found ${Xt(Vi(t))} instead.`,this.key);if(!Qt(i,["string","array"]))throw new zi(`Expected second argument to be of type array or string, but found ${Xt(Vi(i))} instead.`,this.key);return i.indexOf(t)>=0}eachChild(e){e(this.needle),e(this.haystack)}outputDefined(){return!0}},"index-of":class e{constructor(e,t,i,r){this.needle=e,this.haystack=t,this.key=i,this.fromIndex=r,this.type=kt}static parse(t,i){if(t.length<=2||t.length>=5)return i.error(`Expected 2 or 3 arguments, but found ${t.length-1} instead.`);let r=i.parse(t[1],1,jt),a=i.parse(t[2],2,jt);if(!r||!a)return null;if(!Jt(r.type,[Ft,Lt,kt,Rt,jt]))return i.error(`Expected first argument to be of type boolean, string, number or null, but found ${Xt(r.type)} instead`);if(4===t.length){let n=i.parse(t[3],3,kt);return n?new e(r,a,i.key,n):null}return new e(r,a,i.key)}evaluate(e){let t,i=this.needle.evaluate(e),r=this.haystack.evaluate(e);if(!Qt(i,["boolean","string","number","null"]))throw new zi(`Expected first argument to be of type boolean, string, number or null, but found ${Xt(Vi(i))} instead.`,this.key);if(this.fromIndex&&(t=this.fromIndex.evaluate(e)),Qt(r,["string"])){let e=r.indexOf(i,t);return-1===e?-1:[...r.slice(0,e)].length}if(Qt(r,["array"]))return r.indexOf(i,t);throw new zi(`Expected second argument to be of type array or string, but found ${Xt(Vi(r))} instead.`,this.key)}eachChild(e){e(this.needle),e(this.haystack),this.fromIndex&&e(this.fromIndex)}outputDefined(){return!1}},interpolate:Qi,"interpolate-hcl":Qi,"interpolate-lab":Qi,length:class e{constructor(e,t){this.input=e,this.key=t,this.type=kt}static parse(t,i){if(2!==t.length)return i.error(`Expected 1 argument, but found ${t.length-1} instead.`);let r=i.parse(t[1],1);return r?"array"!==r.type.kind&&"string"!==r.type.kind&&"value"!==r.type.kind?i.error(`Expected argument of type string or array, but found ${Xt(r.type)} instead.`):new e(r,i.key):null}evaluate(e){let t=this.input.evaluate(e);if("string"==typeof t)return[...t].length;if(Array.isArray(t))return t.length;throw new zi(`Expected value to be of type string or array, but found ${Xt(Vi(t))} instead.`,this.key)}eachChild(e){e(this.input)}outputDefined(){return!1}},let:Xi,literal:Ni,match:class e{constructor(e,t,i,r,a,n){this.inputType=e,this.type=t,this.input=i,this.cases=r,this.outputs=a,this.otherwise=n}static parse(t,i){if(t.length<5)return i.error(`Expected at least 4 arguments, but found only ${t.length-1}.`);if(t.length%2!=1)return i.error("Expected an even number of arguments.");let r,a;i.expectedType&&"value"!==i.expectedType.kind&&(a=i.expectedType);let n={},s=[];for(let e=2;e<t.length-1;e+=2){let o=t[e],l=t[e+1];Array.isArray(o)||(o=[o]);let h=i.concat(e);if(0===o.length)return h.error("Expected at least one branch label.");for(let e of o){if("number"!=typeof e&&"string"!=typeof e)return h.error("Branch labels must be numbers or strings.");if("number"==typeof e&&Math.abs(e)>2**53-1)return h.error(`Branch labels must be integers no larger than ${2**53-1}.`);if("number"==typeof e&&Math.floor(e)!==e)return h.error("Numeric branch labels must be integer values.");if(r){if(h.checkSubtype(r,Vi(e)))return null}else r=Vi(e);if(void 0!==n[String(e)])return h.error("Branch labels must be unique.");n[String(e)]=s.length}let u=i.parse(l,e,a);if(!u)return null;a||=u.type,s.push(u)}let o=i.parse(t[1],1,jt);if(!o)return null;let l=i.parse(t[t.length-1],t.length-1,a);return!l||"value"!==o.type.kind&&i.concat(1).checkSubtype(r,o.type)?null:new e(r,a,o,n,s,l)}evaluate(e){let t=this.input.evaluate(e);return(Vi(t)===this.inputType&&this.outputs[this.cases[t]]||this.otherwise).evaluate(e)}eachChild(e){e(this.input),this.outputs.forEach(e),e(this.otherwise)}outputDefined(){return this.outputs.every(e=>e.outputDefined())&&this.otherwise.outputDefined()}},number:Gi,"number-format":class e{constructor(e,t,i,r,a,n){this.type=Lt,this.number=e,this.locale=t,this.currency=i,this.unit=r,this.minFractionDigits=a,this.maxFractionDigits=n}static parse(t,i){if(3!==t.length)return i.error("Expected two arguments.");let r=i.parse(t[1],1,kt);if(!r)return null;let a=t[2];if("object"!=typeof a||Array.isArray(a))return i.error("NumberFormat options argument must be an object.");let n=null;if(a.locale&&(n=i.parse(a.locale,1,Lt),!n))return null;let s=null;if(a.currency&&(s=i.parse(a.currency,1,Lt),!s))return null;let o=null;if(a.unit&&(o=i.parse(a.unit,1,Lt),!o))return null;if(s&&o)return i.error("NumberFormat options `currency` and `unit` are mutually exclusive");let l=null;if(a["min-fraction-digits"]&&(l=i.parse(a["min-fraction-digits"],1,kt),!l))return null;let h=null;return a["max-fraction-digits"]&&(h=i.parse(a["max-fraction-digits"],1,kt),!h)?null:new e(r,n,s,o,l,h)}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}},object:Gi,slice:class e{constructor(e,t,i,r,a){this.type=e,this.input=t,this.beginIndex=i,this.key=r,this.endIndex=a}static parse(t,i){if(t.length<=2||t.length>=5)return i.error(`Expected 2 or 3 arguments, but found ${t.length-1} instead.`);let r=i.parse(t[1],1,jt),a=i.parse(t[2],2,kt);if(!r||!a)return null;if(!Jt(r.type,[Ht(jt),Lt,jt]))return i.error(`Expected first argument to be of type array or string, but found ${Xt(r.type)} instead`);if(4===t.length){let n=i.parse(t[3],3,kt);return n?new e(r.type,r,a,i.key,n):null}return new e(r.type,r,a,i.key)}evaluate(e){let t,i=this.input.evaluate(e),r=this.beginIndex.evaluate(e);if(this.endIndex&&(t=this.endIndex.evaluate(e)),Qt(i,["string"]))return[...i].slice(r,t).join("");if(Qt(i,["array"]))return i.slice(r,t);throw new zi(`Expected first argument to be of type array or string, but found ${Xt(Vi(i))} instead.`,this.key)}eachChild(e){e(this.input),e(this.beginIndex),this.endIndex&&e(this.endIndex)}outputDefined(){return!1}},step:Ji,string:Gi,"to-boolean":Zi,"to-color":Zi,"to-number":Zi,"to-string":Zi,var:Yi,within:Lr,distance:pa,"global-state":da},ma=class e{constructor(e,t,i,r,a){this.name=e,this.type=t,this._evaluate=i,this.args=r,this.key=a}evaluate(e){return this._evaluate(e,this.args,this.key)}eachChild(e){this.args.forEach(e)}outputDefined(){return!1}static parse(t,i){let r=t[0],a=e.definitions[r];if(!a)return i.error(`Unknown expression "${r}". If you wanted a literal array, use ["literal", [...]].`,0);let n=Array.isArray(a)?a[0]:a.type,s=Array.isArray(a)?[[a[1],a[2]]]:a.overloads,o=s.filter(([e])=>!Array.isArray(e)||e.length===t.length-1),l=null;for(let[h,u]of o){l=new Hi(i.registry,xa,i.path,null,i.scope);let a=[],s=!1;for(let e=1;e<t.length;e++){let i=t[e],r=Array.isArray(h)?h[e-1]:h.type,n=l.parse(i,1+a.length,r);if(!n){s=!0;break}a.push(n)}if(!s){if(Array.isArray(h)&&h.length!==a.length){l.error(`Expected ${h.length} arguments, but found ${a.length} instead.`);continue}for(let e=0;e<a.length;e++){let t=Array.isArray(h)?h[e]:h.type,i=a[e];l.concat(e+1).checkSubtype(t,i.type)}if(0===l.errors.length)return new e(r,n,u,a,i.key)}}if(1===o.length)i.errors.push(...l.errors);else{let e=(o.length?o:s).map(([e])=>function(e){return Array.isArray(e)?`(${e.map(Xt).join(", ")})`:`(${Xt(e.type)}...)`}(e)).join(" | "),r=[];for(let a=1;a<t.length;a++){let e=i.parse(t[a],1+r.length);if(!e)return null;r.push(Xt(e.type))}i.error(`Expected arguments of type ${e}, but found (${r.join(", ")}) instead.`)}return null}static register(t,i){e.definitions=i;for(let r in i)t[r]=e}};function _a(e,[t,i,r,a],n){t=t.evaluate(e),i=i.evaluate(e),r=r.evaluate(e);let s=a?a.evaluate(e):1,o=Bi(t,i,r,s);if(o)throw new zi(o,n);return new Si(t/255,i/255,r/255,s,!1)}function ga(e,t){return e in t&&void 0!==t[e]}function ya(e,t){let i=t[e];return void 0===i?null:i}function va(e){return{type:e}}function xa(e){if(e instanceof Yi)return xa(e.boundExpression);if(e instanceof ma&&"error"===e.name||e instanceof pr||e instanceof Lr||e instanceof pa||e instanceof da)return!1;let t=e instanceof Zi||e instanceof Gi,i=!0;return e.eachChild(e=>{i&&=t?xa(e):e instanceof Ni}),!!i&&ba(e)&&Ta(e,["zoom","heatmap-density","elevation","line-progress","accumulated","is-supported-script"])}function ba(e){if(e instanceof ma&&("get"===e.name&&1===e.args.length||"feature-state"===e.name||"has"===e.name&&1===e.args.length||"properties"===e.name||"geometry-type"===e.name||"id"===e.name||/^filter-/.test(e.name))||e instanceof Lr||e instanceof pa)return!1;let t=!0;return e.eachChild(e=>{t&&!ba(e)&&(t=!1)}),t}function wa(e){if(e instanceof ma&&"feature-state"===e.name)return!1;let t=!0;return e.eachChild(e=>{t&&!wa(e)&&(t=!1)}),t}function Ta(e,t){if(e instanceof ma&&t.indexOf(e.name)>=0)return!1;let i=!0;return e.eachChild(e=>{i&&!Ta(e,t)&&(i=!1)}),i}function Sa(e){return{result:"success",value:e}}function Pa(e){return{result:"error",value:e}}function Ia(e){return"data-driven"===e["property-type"]||"cross-faded-data-driven"===e["property-type"]}function Ma(e){return!!e.expression&&e.expression.parameters.indexOf("zoom")>-1}function Ea(e){return!!e.expression&&e.expression.interpolated}function Aa(e,...t){for(let i of t)for(let t in i)e[t]=i[t];return e}function Ca(e){return e instanceof Number?"number":e instanceof String?"string":e instanceof Boolean?"boolean":Array.isArray(e)?"array":null===e?"null":typeof e}function Da(e){return"object"==typeof e&&!!e&&!Array.isArray(e)&&Vi(e)===Vt}function za(e){return e}function Ra(e,t){let i=e.stops&&"object"==typeof e.stops[0][0],r=i||void 0!==e.property,a=i||!r,n=e.type||(Ea(t)?"exponential":"interval"),s=function(e){switch(e.type){case"color":return Si.parse;case"padding":return Ai.parse;case"numberArray":return Ci.parse;case"colorArray":return Di.parse;default:return null}}(t);if(s&&((e=Aa({},e)).stops&&(e.stops=e.stops.map(e=>[e[0],s(e[1])])),e.default?e.default=s(e.default):e.default=s(t.default)),e.colorSpace&&!function(e){return"rgb"===e||"hcl"===e||"lab"===e}(e.colorSpace))throw Error(`Unknown color space: "${e.colorSpace}"`);let o,l,h=function(e){switch(e){case"exponential":return Ba;case"interval":return Fa;case"categorical":return La;case"identity":return Oa;default:throw Error(`Unknown function type "${e}"`)}}(n);if("categorical"===n){o=Object.create(null);for(let t of e.stops)o[t[0]]=t[1];l=typeof e.stops[0][0]}if(i){let i={},r=[];for(let t=0;t<e.stops.length;t++){let a=e.stops[t],n=a[0].zoom;void 0===i[n]&&(i[n]={zoom:n,type:e.type,property:e.property,default:e.default,stops:[]},r.push(n)),i[n].stops.push([a[0].value,a[1]])}let a=[];for(let e of r)a.push([i[e].zoom,Ra(i[e],t)]);let n={name:"linear"};return{kind:"composite",interpolationType:n,interpolationFactor:Qi.interpolationFactor.bind(void 0,n),zoomStops:a.map(e=>e[0]),evaluate:({zoom:i},r)=>Ba({stops:a,base:e.base},t,i).evaluate(i,r)}}if(a){let i="exponential"===n?{name:"exponential",base:void 0===e.base?1:e.base}:null;return{kind:"camera",interpolationType:i,interpolationFactor:Qi.interpolationFactor.bind(void 0,i),zoomStops:e.stops.map(e=>e[0]),evaluate:({zoom:i})=>h(e,t,i,o,l)}}return{kind:"source",evaluate(i,r){let a=r&&r.properties?r.properties[e.property]:void 0;return void 0===a?ka(e.default,t.default):h(e,t,a,o,l)}}}function ka(e,t,i){return void 0!==e?e:void 0!==t?t:void 0!==i?i:void 0}function La(e,t,i,r,a){return ka(typeof i===a?r[i]:void 0,e.default,t.default)}function Fa(e,t,i){if("number"!==Ca(i))return ka(e.default,t.default);let r=e.stops.length;if(1===r||i<=e.stops[0][0])return e.stops[0][1];if(i>=e.stops[r-1][0])return e.stops[r-1][1];let a=Ki(e.stops.map(e=>e[0]),i,"");return e.stops[a][1]}function Ba(e,t,i){let r=void 0===e.base?1:e.base;if("number"!==Ca(i))return ka(e.default,t.default);let a=e.stops.length;if(1===a||i<=e.stops[0][0])return e.stops[0][1];if(i>=e.stops[a-1][0])return e.stops[a-1][1];let n=Ki(e.stops.map(e=>e[0]),i,""),s=function(e,t,i,r){let a=r-i,n=e-i;return 0===a?0:1===t?n/a:(t**+n-1)/(t**+a-1)}(i,r,e.stops[n][0],e.stops[n+1][0]),o=e.stops[n][1],l=e.stops[n+1][1],h=tr[t.type]||za;return"function"==typeof o.evaluate?{evaluate(...t){let i=o.evaluate.apply(void 0,t),r=l.evaluate.apply(void 0,t);if(void 0!==i&&void 0!==r)return h(i,r,s,e.colorSpace)}}:h(o,l,s,e.colorSpace)}function Oa(e,t,i){switch(t.type){case"color":i=Si.parse(i);break;case"formatted":i=Ei.fromString(i.toString());break;case"resolvedImage":i=Li.fromString(i.toString());break;case"padding":i=Ai.parse(i);break;case"colorArray":i=Di.parse(i);break;case"numberArray":i=Ci.parse(i);break;default:Ca(i)!==t.type&&("enum"!==t.type||!t.values[i])&&(i=void 0)}return ka(i,e.default,t.default)}ma.register(fa,{error:[{kind:"error"},[Lt],(e,[t],i)=>{throw new zi(t.evaluate(e),i)}],typeof:[Lt,[jt],(e,[t])=>Xt(Vi(t.evaluate(e)))],"to-rgba":[Ht(kt,4),[Bt],(e,[t])=>{let[i,r,a,n]=t.evaluate(e).rgb;return[255*i,255*r,255*a,n]}],rgb:[Bt,[kt,kt,kt],_a],rgba:[Bt,[kt,kt,kt,kt],_a],has:{type:Ft,overloads:[[[Lt],(e,[t])=>ga(t.evaluate(e),e.properties())],[[Lt,Vt],(e,[t,i])=>ga(t.evaluate(e),i.evaluate(e))]]},get:{type:jt,overloads:[[[Lt],(e,[t])=>ya(t.evaluate(e),e.properties())],[[Lt,Vt],(e,[t,i])=>ya(t.evaluate(e),i.evaluate(e))]]},"feature-state":[jt,[Lt],(e,[t])=>ya(t.evaluate(e),e.featureState||{})],properties:[Vt,[],e=>e.properties()],"geometry-type":[Lt,[],e=>e.geometryType()],id:[jt,[],e=>e.id()],zoom:[kt,[],e=>e.globals.zoom],"heatmap-density":[kt,[],e=>e.globals.heatmapDensity||0],elevation:[kt,[],e=>e.globals.elevation||0],"line-progress":[kt,[],e=>e.globals.lineProgress||0],accumulated:[jt,[],e=>void 0===e.globals.accumulated?null:e.globals.accumulated],"+":[kt,va(kt),(e,t)=>{let i=0;for(let r of t)i+=r.evaluate(e);return i}],"*":[kt,va(kt),(e,t)=>{let i=1;for(let r of t)i*=r.evaluate(e);return i}],"-":{type:kt,overloads:[[[kt,kt],(e,[t,i])=>t.evaluate(e)-i.evaluate(e)],[[kt],(e,[t])=>-t.evaluate(e)]]},"/":[kt,[kt,kt],(e,[t,i])=>t.evaluate(e)/i.evaluate(e)],"%":[kt,[kt,kt],(e,[t,i])=>t.evaluate(e)%i.evaluate(e)],ln2:[kt,[],()=>Math.LN2],pi:[kt,[],()=>Math.PI],e:[kt,[],()=>Math.E],"^":[kt,[kt,kt],(e,[t,i])=>t.evaluate(e)**+i.evaluate(e)],sqrt:[kt,[kt],(e,[t])=>Math.sqrt(t.evaluate(e))],log10:[kt,[kt],(e,[t])=>Math.log(t.evaluate(e))/Math.LN10],ln:[kt,[kt],(e,[t])=>Math.log(t.evaluate(e))],log2:[kt,[kt],(e,[t])=>Math.log(t.evaluate(e))/Math.LN2],sin:[kt,[kt],(e,[t])=>Math.sin(t.evaluate(e))],cos:[kt,[kt],(e,[t])=>Math.cos(t.evaluate(e))],tan:[kt,[kt],(e,[t])=>Math.tan(t.evaluate(e))],asin:[kt,[kt],(e,[t])=>Math.asin(t.evaluate(e))],acos:[kt,[kt],(e,[t])=>Math.acos(t.evaluate(e))],atan:[kt,[kt],(e,[t])=>Math.atan(t.evaluate(e))],min:[kt,va(kt),(e,t)=>Math.min(...t.map(t=>t.evaluate(e)))],max:[kt,va(kt),(e,t)=>Math.max(...t.map(t=>t.evaluate(e)))],abs:[kt,[kt],(e,[t])=>Math.abs(t.evaluate(e))],round:[kt,[kt],(e,[t])=>{let i=t.evaluate(e);return i<0?-Math.round(-i):Math.round(i)}],floor:[kt,[kt],(e,[t])=>Math.floor(t.evaluate(e))],ceil:[kt,[kt],(e,[t])=>Math.ceil(t.evaluate(e))],"filter-==":[Ft,[Lt,jt],(e,[t,i])=>e.properties()[t.value]===i.value],"filter-id-==":[Ft,[jt],(e,[t])=>e.id()===t.value],"filter-type-==":[Ft,[Lt],(e,[t])=>e.geometryType()===t.value],"filter-<":[Ft,[Lt,jt],(e,[t,i])=>{let r=e.properties()[t.value],a=i.value;return typeof r==typeof a&&r<a}],"filter-id-<":[Ft,[jt],(e,[t])=>{let i=e.id(),r=t.value;return typeof i==typeof r&&i<r}],"filter->":[Ft,[Lt,jt],(e,[t,i])=>{let r=e.properties()[t.value],a=i.value;return typeof r==typeof a&&r>a}],"filter-id->":[Ft,[jt],(e,[t])=>{let i=e.id(),r=t.value;return typeof i==typeof r&&i>r}],"filter-<=":[Ft,[Lt,jt],(e,[t,i])=>{let r=e.properties()[t.value],a=i.value;return typeof r==typeof a&&r<=a}],"filter-id-<=":[Ft,[jt],(e,[t])=>{let i=e.id(),r=t.value;return typeof i==typeof r&&i<=r}],"filter->=":[Ft,[Lt,jt],(e,[t,i])=>{let r=e.properties()[t.value],a=i.value;return typeof r==typeof a&&r>=a}],"filter-id->=":[Ft,[jt],(e,[t])=>{let i=e.id(),r=t.value;return typeof i==typeof r&&i>=r}],"filter-has":[Ft,[jt],(e,[t])=>{let i=t.value,r=e.properties();return i in r&&void 0!==r[i]}],"filter-has-id":[Ft,[],e=>null!==e.id()&&void 0!==e.id()],"filter-type-in":[Ft,[Ht(Lt)],(e,[t])=>t.value.indexOf(e.geometryType())>=0],"filter-id-in":[Ft,[Ht(jt)],(e,[t])=>t.value.indexOf(e.id())>=0],"filter-in-small":[Ft,[Lt,Ht(jt)],(e,[t,i])=>i.value.indexOf(e.properties()[t.value])>=0],"filter-in-large":[Ft,[Lt,Ht(jt)],(e,[t,i])=>function(e,t,i,r){for(;i<=r;){let a=i+r>>1;if(t[a]===e)return!0;t[a]>e?r=a-1:i=a+1}return!1}(e.properties()[t.value],i.value,0,i.value.length-1)],all:{type:Ft,overloads:[[[Ft,Ft],(e,[t,i])=>t.evaluate(e)&&i.evaluate(e)],[va(Ft),(e,t)=>{for(let i of t)if(!i.evaluate(e))return!1;return!0}]]},any:{type:Ft,overloads:[[[Ft,Ft],(e,[t,i])=>t.evaluate(e)||i.evaluate(e)],[va(Ft),(e,t)=>{for(let i of t)if(i.evaluate(e))return!0;return!1}]]},"!":[Ft,[Ft],(e,[t])=>!t.evaluate(e)],"is-supported-script":[Ft,[Lt],(e,[t])=>{let i=e.globals&&e.globals.isSupportedScript;return!i||i(t.evaluate(e))}],upcase:[Lt,[Lt],(e,[t])=>t.evaluate(e).toUpperCase()],downcase:[Lt,[Lt],(e,[t])=>t.evaluate(e).toLowerCase()],concat:[Lt,va(jt),(e,t)=>t.map(t=>ji(t.evaluate(e))).join("")],split:[Ht(Lt),[Lt,Lt],(e,[t,i])=>t.evaluate(e).split(i.evaluate(e))],join:[Lt,[Ht(Lt),Lt],(e,[t,i])=>t.evaluate(e).join(i.evaluate(e))],"resolved-locale":[Lt,[Nt],(e,[t])=>t.evaluate(e).resolvedLocale()]});var Va=class{constructor(e,t,i,r){this.expression=e,this._warningHistory={},this._evaluator=new Wi,this._defaultValue=i?Ya(i):null,this._enumValues=i&&"enum"===i.type?i.values:null,this._globalState=r,this._rootKey=t}evaluateWithoutErrorHandling(e,t,i,r,a,n){return this._globalState&&(e=Ka(e,this._globalState)),this._evaluator.globals=e,this._evaluator.feature=t,this._evaluator.featureState=i,this._evaluator.canonical=r,this._evaluator.availableImages=a||null,this._evaluator.formattedSection=n,this.expression.evaluate(this._evaluator)}evaluate(e,t,i,r,a,n){this._globalState&&(e=Ka(e,this._globalState)),this._evaluator.globals=e,this._evaluator.feature=t||null,this._evaluator.featureState=i||null,this._evaluator.canonical=r,this._evaluator.availableImages=a||null,this._evaluator.formattedSection=n||null;try{let e=this.expression.evaluate(this._evaluator);if(null==e||"number"==typeof e&&e!=e)return this._defaultValue;if(this._enumValues&&!(e in this._enumValues))throw new zi(`Expected value to be one of ${Object.keys(this._enumValues).map(e=>JSON.stringify(e)).join(", ")}, but found ${JSON.stringify(e)} instead.`,"");return e}catch(e){let t=e instanceof zi?e.path:"",i=`${t}|${e.message}`;return this._warningHistory[i]||(this._warningHistory[i]=!0,typeof console<"u"&&console.warn(ja(this._rootKey,t,e.message,this._defaultValue))),this._defaultValue}}};function ja(e,t,i,r){return`${e}${t}: ${i}${null==r?"":` Falling back to ${String(r)}.`}`}function Na(e){if(!e)throw Error('rootKey must identify the location of the expression in the style JSON, e.g. "layers[3].paint.line-width".')}function Ua(e){return Array.isArray(e)&&e.length>0&&"string"==typeof e[0]&&e[0]in fa}function Ga(e,t,i,r){Na(t);let a=new Hi(fa,xa,[],i?function(e){let t={color:Bt,string:Lt,number:kt,enum:Lt,boolean:Ft,formatted:Ut,padding:Gt,numberArray:Zt,colorArray:$t,projectionDefinition:Ot,resolvedImage:qt,variableAnchorOffsetCollection:Wt};return"array"===e.type?Ht(t[e.value]||jt,e.length):t[e.type]}(i):void 0),n=a.parse(e,void 0,void 0,void 0,i&&"string"===i.type?{typeAnnotation:"coerce"}:void 0);return n?Sa(new Va(n,t,i,r)):Pa(a.errors)}var $a=class{constructor(e,t,i){this.kind=e,this._styleExpression=t,this.isStateDependent="constant"!==e&&!wa(t.expression),this.globalStateRefs=Xa(t.expression),this._globalState=i}evaluateWithoutErrorHandling(e,t,i,r,a,n){return this._globalState&&(e=Ka(e,this._globalState)),this._styleExpression.evaluateWithoutErrorHandling(e,t,i,r,a,n)}evaluate(e,t,i,r,a,n){return this._globalState&&(e=Ka(e,this._globalState)),this._styleExpression.evaluate(e,t,i,r,a,n)}},Za=class{constructor(e,t,i,r,a){this.kind=e,this.zoomStops=i,this._styleExpression=t,this.isStateDependent="camera"!==e&&!wa(t.expression),this.globalStateRefs=Xa(t.expression),this.interpolationType=r,this._globalState=a}evaluateWithoutErrorHandling(e,t,i,r,a,n){return this._globalState&&(e=Ka(e,this._globalState)),this._styleExpression.evaluateWithoutErrorHandling(e,t,i,r,a,n)}evaluate(e,t,i,r,a,n){return this._globalState&&(e=Ka(e,this._globalState)),this._styleExpression.evaluate(e,t,i,r,a,n)}interpolationFactor(e,t,i){return this.interpolationType?Qi.interpolationFactor(this.interpolationType,e,t,i):0}};function qa(e,t,i,r){let a=Ga(e,t,i,r);if("error"===a.result)return a;let n=a.value.expression,s=ba(n);if(!s&&!Ia(i))return Pa([new Dt("","data expressions not supported")]);let o=Ta(n,["zoom"]);if(!o&&!Ma(i))return Pa([new Dt("","zoom expressions not supported")]);let l=Ha(n);if(!l&&!o)return Pa([new Dt("",'"zoom" expression may only be used as input to a top-level "step" or "interpolate" expression.')]);if(l instanceof Dt)return Pa([l]);if(l instanceof Qi&&!Ea(i))return Pa([new Dt("",'"interpolate" expressions cannot be used with this property')]);if(!l)return Sa(new $a(s?"constant":"source",a.value,r));let h=l instanceof Qi?l.interpolation:void 0;return Sa(new Za(s?"camera":"composite",a.value,l.labels,h,r))}var Wa=class e{constructor(e,t,i){this.isStateDependent=!1,this.globalStateRefs=/* @__PURE__ */new Set,this._globalState=null,Na(t),this._parameters=e,this._specification=i,this._rootKey=t,this._defaultValue=Ya(i),this._warningHistory={};let r=Ra(this._parameters,this._specification);this.kind=r.kind,this.interpolationFactor=r.interpolationFactor,this.zoomStops=r.zoomStops,this.interpolationType=r.interpolationType,this._innerEvaluate=r.evaluate}evaluate(e,t){try{return this._innerEvaluate(e,t)}catch(e){let t=e instanceof Error?e.message:String(e),i=`|${t}`;return this._warningHistory[i]||(this._warningHistory[i]=!0,typeof console<"u"&&console.warn(ja(this._rootKey,"",t,this._defaultValue))),this._defaultValue}}static deserialize(t){return new e(t._parameters,t._rootKey,t._specification)}static serialize(e){return{_parameters:e._parameters,_specification:e._specification,_rootKey:e._rootKey}}};function Ha(e){let t=null;if(e instanceof Xi)t=Ha(e.result);else if(e instanceof ir){for(let i of e.args)if(t=Ha(i),t)break}else(e instanceof Ji||e instanceof Qi)&&e.input instanceof ma&&"zoom"===e.input.name&&(t=e);return t instanceof Dt||e.eachChild(e=>{let i=Ha(e);i instanceof Dt?t=i:!t&&i?t=new Dt("",'"zoom" expression may only be used as input to a top-level "step" or "interpolate" expression.'):t&&i&&t!==i&&(t=new Dt("",'Only one zoom-based "step" or "interpolate" subexpression may be used in an expression.'))}),t}function Xa(e,t=/* @__PURE__ */new Set){return e instanceof da&&t.add(e.key),e.eachChild(e=>{Xa(e,t)}),t}function Ya(e){if("color"===e.type&&Da(e.default))return new Si(0,0,0,0);switch(e.type){case"color":return Si.parse(e.default)||null;case"padding":return Ai.parse(e.default)||null;case"numberArray":return Ci.parse(e.default)||null;case"colorArray":return Di.parse(e.default)||null;case"variableAnchorOffsetCollection":return ki.parse(e.default)||null;case"projectionDefinition":return Fi.parse(e.default)||null;default:return void 0===e.default?null:e.default}}function Ka(e,t){let{zoom:i,heatmapDensity:r,elevation:a,lineProgress:n,isSupportedScript:s,accumulated:o}=e??{};return{zoom:i,heatmapDensity:r,elevation:a,lineProgress:n,isSupportedScript:s,accumulated:o,globalState:t}}function Ja(e){if("boolean"==typeof e)return"neutral";if(!Array.isArray(e)||0===e.length)return"legacy";switch(e[0]){case"has":return e.length<2||"$id"===e[1]||"$type"===e[1]?"legacy":2===e.length?"neutral":"expression";case"in":return e.length>=3&&("string"!=typeof e[1]||Array.isArray(e[2]))?"expression":"legacy";case"!in":case"!has":case"none":return"legacy";case"==":case"!=":case">":case">=":case"<":case"<=":return 3!==e.length||Array.isArray(e[1])||Array.isArray(e[2])?"expression":"legacy";case"any":case"all":return function(e){let t=!1;for(let i of e){let e=Ja(i);if("expression"===e)return"expression";"legacy"===e&&(t=!0)}return t?"legacy":"neutral"}(e.slice(1));default:return"expression"}}function Qa(e){return"legacy"!==Ja(e)}function en(e){return"$type"===e?["geometry-type"]:"$id"===e?["id"]:["get",e]}function tn(e){if(("<"===e[0]||"<="===e[0]||">"===e[0]||">="===e[0])&&"$type"===e[1])return`"$type" cannot be use with operator "${e[0]}"`;let t=function(e){switch(e[0]){case"==":case"!=":case"<":case"<=":case">":case">=":return 3!==e.length||"string"!=typeof e[1]?null:[e[0],en(e[1]),e[2]];case"in":case"!in":{if(e.length<2||"string"!=typeof e[1])return null;let t=["in",en(e[1]),["literal",e.slice(2)]];return"!in"===e[0]?["!",t]:t}case"has":case"!has":{if(2!==e.length||"string"!=typeof e[1]||"$type"===e[1]||"$id"===e[1])return null;let t=["has",e[1]];return"!has"===e[0]?["!",t]:t}default:return null}}(e);return t?`Mixing deprecated filter syntax with expression syntax is not supported. Replace ${JSON.stringify(e)} with ${JSON.stringify(t)}.`:`Mixing deprecated filter syntax with expression syntax is not supported. Convert ${JSON.stringify(e)} to expression syntax.`}function rn(e,t,i){let r=i[e];return Array.isArray(r)?Qa(r)?an(r,t.concat(e)):{path:t.concat(e),legacyFilter:r}:null}function an(e,t=[]){if(!Array.isArray(e)||e.length<1)return null;switch(e[0]){case"all":case"any":case"none":for(let i=1;i<e.length;i++){let r=rn(i,t,e);if(r)return r}break;case"!":{let i=rn(1,t,e);if(i)return i;break}case"case":for(let i=1;i<e.length-1;i+=2){let r=rn(i,t,e);if(r)return r}}return null}var nn={type:"boolean",default:!1,transition:!1,"property-type":"data-driven",expression:{interpolated:!1,parameters:["zoom","feature"]}};function sn(e,t,i){if(null==e)return{filter:()=>!0,needGeometry:!1,getGlobalStateRefs:()=>/* @__PURE__ */new Set};Qa(e)?function(e,t){let i=an(e);if(!i||typeof console>"u")return;let r=i.path.map(e=>`[${e}]`).join("");console.warn(`${t}${r}: ${tn(i.legacyFilter)}`)}(e,t):e=hn(e);let r=Ga(e,t,nn,i);if("error"===r.result)throw Error(r.value.map(e=>`${e.key}: ${e.message}`).join(", "));return{filter:(e,t,i)=>r.value.evaluate(e,t,{},i),needGeometry:ln(e),getGlobalStateRefs:()=>Xa(r.value.expression)}}function on(e,t){return e<t?-1:+(e>t)}function ln(e){if(!Array.isArray(e))return!1;if("within"===e[0]||"distance"===e[0])return!0;for(let t=1;t<e.length;t++)if(ln(e[t]))return!0;return!1}function hn(e){if(!e)return!0;let t=e[0];return e.length<=1?"any"!==t:"=="===t?un(e[1],e[2],"=="):"!="===t?dn(un(e[1],e[2],"==")):"<"===t||">"===t||"<="===t||">="===t?un(e[1],e[2],t):"any"===t?function(e){return["any"].concat(e.map(hn))}(e.slice(1)):"all"===t?["all"].concat(e.slice(1).map(hn)):"none"===t?["all"].concat(e.slice(1).map(hn).map(dn)):"in"===t?cn(e[1],e.slice(2)):"!in"===t?dn(cn(e[1],e.slice(2))):"has"===t?pn(e[1]):"!has"!==t||dn(pn(e[1]))}function un(e,t,i){switch(e){case"$type":return[`filter-type-${i}`,t];case"$id":return[`filter-id-${i}`,t];default:return[`filter-${i}`,e,t]}}function cn(e,t){if(0===t.length)return!1;switch(e){case"$type":return["filter-type-in",["literal",t]];case"$id":return["filter-id-in",["literal",t]];default:return t.length>200&&!t.some(e=>typeof e!=typeof t[0])?["filter-in-large",e,["literal",t.sort(on)]]:["filter-in-small",e,["literal",t]]}}function pn(e){switch(e){case"$type":return!0;case"$id":return["filter-has-id"];default:return["filter-has",e]}}function dn(e){return["!",e]}function fn(e){let t=e.key,i=e.value;return i?[new Ct(t,i,"constants have been deprecated as of v8")]:[]}function mn(e){return e instanceof Number||e instanceof String||e instanceof Boolean?e.valueOf():e}function _n(e){if(Array.isArray(e))return e.map(_n);if(e instanceof Object&&!(e instanceof Number||e instanceof String||e instanceof Boolean)){let t={};for(let i in e)t[i]=_n(e[i]);return t}return mn(e)}function gn(e){let t=e.key,i=e.value,r=e.valueSpec||{},a=e.objectElementValidators||{},n=e.style,s=e.styleSpec,o=e.validateSpec,l=[],h=Ca(i);if("object"!==h)return[new Ct(t,i,`object expected, ${h} found`)];for(let u in i){let e,h=u.split(".")[0],c=_i(r,h)||r["*"];if(_i(a,h))e=a[h];else if(_i(r,h)){if(void 0===i[u])continue;e=o}else if(a["*"])e=a["*"];else{if(!r["*"]){l.push(new Ct(t,i[u],`unknown property "${u}"`));continue}e=o}l=l.concat(e({key:(t&&`${t}.`)+u,value:i[u],valueSpec:c,style:n,styleSpec:s,object:i,objectKey:u,validateSpec:o},i))}for(let u in r)a[u]||r[u].required&&void 0===r[u].default&&void 0===i[u]&&l.push(new Ct(t,i,`missing required property "${u}"`));return l}function yn(e){let t=e.value,i=e.valueSpec,r=e.validateSpec,a=e.style,n=e.styleSpec,s=e.key,o=e.arrayElementValidator||r;if("array"!==Ca(t))return[new Ct(s,t,`array expected, ${Ca(t)} found`)];if(i.length&&t.length!==i.length)return[new Ct(s,t,`array length ${i.length} expected, length ${t.length} found`)];let l={type:i.value,values:i.values};n.$version<7&&(l.function=i.function),"object"===Ca(i.value)&&(l=i.value);let h=[];for(let u=0;u<t.length;u++)h=h.concat(o({array:t,arrayIndex:u,value:t[u],valueSpec:l,validateSpec:e.validateSpec,style:a,styleSpec:n,key:`${s}[${u}]`}));return h}function vn(e){let t=e.key,i=e.value,r=e.valueSpec,a=Ca(i);return"number"===a&&i!=i&&(a="NaN"),"number"===a?"minimum"in r&&i<r.minimum?[new Ct(t,i,`${i} is less than the minimum value ${r.minimum}`)]:"maximum"in r&&i>r.maximum?[new Ct(t,i,`${i} is greater than the maximum value ${r.maximum}`)]:[]:[new Ct(t,i,`number expected, ${a} found`)]}function xn(e){let t,i,r,a=e.valueSpec,n=mn(e.value.type),s={},o="categorical"!==n&&void 0===e.value.property,l=!o,h="array"===Ca(e.value.stops)&&"array"===Ca(e.value.stops[0])&&"object"===Ca(e.value.stops[0][0]),u=gn({key:e.key,value:e.value,valueSpec:e.styleSpec.function,validateSpec:e.validateSpec,style:e.style,styleSpec:e.styleSpec,objectElementValidators:{stops:function(e){if("identity"===n)return[new Ct(e.key,e.value,'identity function may not have a "stops" property')];let t=[],i=e.value;return t=t.concat(yn({key:e.key,value:i,valueSpec:e.valueSpec,validateSpec:e.validateSpec,style:e.style,styleSpec:e.styleSpec,arrayElementValidator:c})),"array"===Ca(i)&&0===i.length&&t.push(new Ct(e.key,i,"array must have at least one stop")),t},default:function(e){return e.validateSpec({key:e.key,value:e.value,valueSpec:a,validateSpec:e.validateSpec,style:e.style,styleSpec:e.styleSpec})}}});return"identity"===n&&o&&u.push(new Ct(e.key,e.value,'missing required property "property"')),"identity"!==n&&!e.value.stops&&u.push(new Ct(e.key,e.value,'missing required property "stops"')),"exponential"===n&&e.valueSpec.expression&&!Ea(e.valueSpec)&&u.push(new Ct(e.key,e.value,"exponential functions not supported")),e.styleSpec.$version>=8&&(l&&!Ia(e.valueSpec)?u.push(new Ct(e.key,e.value,"property functions not supported")):o&&!Ma(e.valueSpec)&&u.push(new Ct(e.key,e.value,"zoom functions not supported"))),("categorical"===n||h)&&void 0===e.value.property&&u.push(new Ct(e.key,e.value,'"property" property is required')),u;function c(e){let t=[],n=e.value,o=e.key;if("array"!==Ca(n))return[new Ct(o,n,`array expected, ${Ca(n)} found`)];if(2!==n.length)return[new Ct(o,n,`array length 2 expected, length ${n.length} found`)];if(h){if("object"!==Ca(n[0]))return[new Ct(o,n,`object expected, ${Ca(n[0])} found`)];if(void 0===n[0].zoom)return[new Ct(o,n,"object stop key must have zoom")];if(void 0===n[0].value)return[new Ct(o,n,"object stop key must have value")];if(r&&r>mn(n[0].zoom))return[new Ct(o,n[0].zoom,"stop zoom values must appear in ascending order")];mn(n[0].zoom)!==r&&(r=mn(n[0].zoom),i=void 0,s={}),t=t.concat(gn({key:`${o}[0]`,value:n[0],valueSpec:{zoom:{}},validateSpec:e.validateSpec,style:e.style,styleSpec:e.styleSpec,objectElementValidators:{zoom:vn,value:p}}))}else t=t.concat(p({key:`${o}[0]`,value:n[0],valueSpec:{},validateSpec:e.validateSpec,style:e.style,styleSpec:e.styleSpec},n));return Ua(_n(n[1]))?t.concat([new Ct(`${o}[1]`,n[1],"expressions are not allowed in function stops.")]):t.concat(e.validateSpec({key:`${o}[1]`,value:n[1],valueSpec:a,validateSpec:e.validateSpec,style:e.style,styleSpec:e.styleSpec}))}function p(e,r){let o=Ca(e.value),l=mn(e.value),h=null===e.value?r:e.value;if(t){if(o!==t)return[new Ct(e.key,h,`${o} stop domain type must match previous stop domain type ${t}`)]}else t=o;if("number"!==o&&"string"!==o&&"boolean"!==o)return[new Ct(e.key,h,"stop domain value must be a number, string, or boolean")];if("number"!==o&&"categorical"!==n){let t=`number expected, ${o} found`;return Ia(a)&&void 0===n&&(t+='\nIf you intended to use a categorical function, specify `"type": "categorical"`.'),[new Ct(e.key,h,t)]}return"categorical"!==n||"number"!==o||isFinite(l)&&Math.floor(l)===l?"categorical"!==n&&"number"===o&&void 0!==i&&l<i?[new Ct(e.key,h,"stop domain values must appear in ascending order")]:(i=l,"categorical"===n&&l in s?[new Ct(e.key,h,"stop domain values must be unique")]:(s[l]=!0,[])):[new Ct(e.key,h,`integer expected, found ${l}`)]}}function bn(e){let t=("property"===e.expressionContext?qa:Ga)(_n(e.value),e.key,e.valueSpec);if("error"===t.result)return t.value.map(t=>new Ct(`${e.key}${t.key}`,e.value,t.message));let i=t.value.expression||t.value._styleExpression.expression;if("property"===e.expressionContext&&"text-font"===e.propertyKey&&!i.outputDefined())return[new Ct(e.key,e.value,`Invalid data expression for "${e.propertyKey}". Output values must be contained as literals within the expression.`)];if("property"===e.expressionContext&&"layout"===e.propertyType&&!wa(i))return[new Ct(e.key,e.value,'"feature-state" data expressions are not supported with layout properties.')];if("filter"===e.expressionContext&&!wa(i))return[new Ct(e.key,e.value,'"feature-state" data expressions are not supported with filters.')];if(e.expressionContext&&0===e.expressionContext.indexOf("cluster")){if(!Ta(i,["zoom","feature-state"]))return[new Ct(e.key,e.value,'"zoom" and "feature-state" expressions are not supported with cluster properties.')];if("cluster-initial"===e.expressionContext&&!ba(i))return[new Ct(e.key,e.value,"Feature data expressions are not supported with initial expression part of cluster properties.")]}return[]}function wn(e){let t=e.key,i=e.value,r=Ca(i);return"string"===r?Si.parse(String(i))?[]:[new Ct(t,i,`color expected, "${i}" found`)]:[new Ct(t,i,`color expected, ${r} found`)]}function Tn(e){let t=e.key,i=e.value,r=e.valueSpec,a=[];return Array.isArray(r.values)?-1===r.values.indexOf(mn(i))&&a.push(new Ct(t,i,`expected one of [${r.values.join(", ")}], ${JSON.stringify(i)} found`)):-1===Object.keys(r.values).indexOf(mn(i))&&a.push(new Ct(t,i,`expected one of [${Object.keys(r.values).join(", ")}], ${JSON.stringify(i)} found`)),a}function Sn(e,t){let i=e;for(let r of t)i=i[r];return i}function Pn(e,t){let i=an(t);return i?[new Ct(`${e.key}${i.path.map(e=>`[${e}]`).join("")}`,Sn(e.value,i.path),tn(i.legacyFilter),null,"warning")]:[]}function In(e){let t=_n(e.value);return Qa(t)?[...Pn(e,t),...bn(Aa({},e,{expressionContext:"filter",valueSpec:{value:"boolean"}}))]:Mn(e)}function Mn(e){let t=e.value,i=e.key;if("array"!==Ca(t))return[new Ct(i,t,`array expected, ${Ca(t)} found`)];let r,a=e.styleSpec,n=[];if(t.length<1)return[new Ct(i,t,"filter array must have at least 1 element")];switch(n=n.concat(Tn({key:`${i}[0]`,value:t[0],valueSpec:a.filter_operator,style:e.style,styleSpec:e.styleSpec})),mn(t[0])){case"<":case"<=":case">":case">=":t.length>=2&&"$type"===mn(t[1])&&n.push(new Ct(i,t,`"$type" cannot be use with operator "${t[0]}"`));case"==":case"!=":3!==t.length&&n.push(new Ct(i,t,`filter array for operator "${t[0]}" must have 3 elements`));case"in":case"!in":t.length>=2&&(r=Ca(t[1]),"string"!==r&&n.push(new Ct(`${i}[1]`,t[1],`string expected, ${r} found`)));for(let s=2;s<t.length;s++)r=Ca(t[s]),"$type"===mn(t[1])?n=n.concat(Tn({key:`${i}[${s}]`,value:t[s],valueSpec:a.geometry_type,style:e.style,styleSpec:e.styleSpec})):"string"!==r&&"number"!==r&&"boolean"!==r&&n.push(new Ct(`${i}[${s}]`,t[s],`string, number, or boolean expected, ${r} found`));break;case"any":case"all":case"none":for(let r=1;r<t.length;r++)n=n.concat(Mn({key:`${i}[${r}]`,value:t[r],style:e.style,styleSpec:e.styleSpec}));break;case"has":case"!has":r=Ca(t[1]),2===t.length?"string"!==r&&n.push(new Ct(`${i}[1]`,t[1],`string expected, ${r} found`)):n.push(new Ct(i,t,`filter array for "${t[0]}" operator must have 2 elements`))}return n}function En(e,t){let i=e.key,r=e.validateSpec,a=e.style,n=e.styleSpec,s=e.value,o=e.objectKey,l=n[`${t}_${e.layerType}`];if(!l)return[];let h=o.match(/^(.*)-transition$/);if("paint"===t&&h&&l[h[1]]&&l[h[1]].transition)return r({key:i,value:s,valueSpec:n.transition,style:a,styleSpec:n});let u,c=e.valueSpec||l[o];if(!c)return[new Ct(i,s,`unknown property "${o}"`)];if("string"===Ca(s)&&Ia(c)&&!c.tokens&&(u=/^{([^}]+)}$/.exec(s)))return[new Ct(i,s,`"${o}" does not support interpolation syntax\nUse an identity property function instead: \`{ "type": "identity", "property": ${JSON.stringify(u[1])} }\`.`)];let p=[];return"symbol"===e.layerType&&"text-font"===o&&Da(_n(s))&&"identity"===mn(s.type)&&p.push(new Ct(i,s,'"text-font" does not support identity functions')),p.concat(r({key:e.key,value:s,valueSpec:c,style:a,styleSpec:n,expressionContext:"property",propertyType:t,propertyKey:o}))}function An(e){return En(e,"paint")}function Cn(e){return En(e,"layout")}function Dn(e){let t=[],i=e.value,r=e.key,a=e.style,n=e.styleSpec;if("object"!==Ca(i))return[new Ct(r,i,`object expected, ${Ca(i)} found`)];!i.type&&!i.ref&&t.push(new Ct(r,i,'either "type" or "ref" is required'));let s=mn(i.type),o=mn(i.ref);if(i.id){let n=mn(i.id);for(let s=0;s<e.arrayIndex;s++){let e=a.layers[s];mn(e.id)===n&&t.push(new Ct(r,i.id,`duplicate layer id "${i.id}", previously used at line ${e.id.__line__}`))}}if("ref"in i){let e;["type","source","source-layer","filter","layout"].forEach(e=>{e in i&&t.push(new Ct(r,i[e],`"${e}" is prohibited for ref layers`))}),a.layers.forEach(t=>{mn(t.id)===o&&(e=t)}),e?e.ref?t.push(new Ct(r,i.ref,"ref cannot reference another ref layer")):s=mn(e.type):t.push(new Ct(r,i.ref,`ref layer "${o}" not found`))}else if("background"!==s)if(i.source){let e=a.sources&&a.sources[i.source],n=e&&mn(e.type);e?"vector"===n&&"raster"===s?t.push(new Ct(r,i.source,`layer "${i.id}" requires a raster source`)):"raster-dem"!==n&&"hillshade"===s||"raster-dem"!==n&&"color-relief"===s?t.push(new Ct(r,i.source,`layer "${i.id}" requires a raster-dem source`)):"raster"===n&&"raster"!==s?t.push(new Ct(r,i.source,`layer "${i.id}" requires a vector source`)):"vector"!==n||i["source-layer"]?"raster-dem"===n&&"hillshade"!==s&&"color-relief"!==s?t.push(new Ct(r,i.source,"raster-dem source can only be used with layer type 'hillshade' or 'color-relief'.")):"line"===s&&i.paint&&i.paint["line-gradient"]&&("geojson"!==n||!e.lineMetrics)&&t.push(new Ct(r,i,`layer "${i.id}" specifies a line-gradient, which requires a GeoJSON source with \`lineMetrics\` enabled.`)):t.push(new Ct(r,i,`layer "${i.id}" must specify a "source-layer"`)):t.push(new Ct(r,i.source,`source "${i.source}" not found`))}else t.push(new Ct(r,i,'missing required property "source"'));return"raster"===s&&i.paint?.resampling&&i.paint?.["raster-resampling"]&&t.push(new Ct(r,i.paint,`layer "${i.id}" redundantly specifies "resampling" and "raster-resampling" paint properties, but only one is allowed. It is advised to use "resampling".`)),t=t.concat(gn({key:r,value:i,valueSpec:n.layer,style:e.style,styleSpec:e.styleSpec,validateSpec:e.validateSpec,objectElementValidators:{"*":()=>[],type:()=>e.validateSpec({key:`${r}.type`,value:i.type,valueSpec:n.layer.type,style:e.style,styleSpec:e.styleSpec,validateSpec:e.validateSpec,object:i,objectKey:"type"}),filter:In,layout:e=>gn({layer:i,key:e.key,value:e.value,style:e.style,styleSpec:e.styleSpec,validateSpec:e.validateSpec,objectElementValidators:{"*":e=>Cn(Aa({layerType:s},e))}}),paint:e=>gn({layer:i,key:e.key,value:e.value,style:e.style,styleSpec:e.styleSpec,validateSpec:e.validateSpec,objectElementValidators:{"*":e=>An(Aa({layerType:s},e))}})}})),t}function zn(e){let t=e.value,i=e.key,r=Ca(t);return"string"===r?[]:[new Ct(i,t,`string expected, ${r} found`)]}var Rn={promoteId:function({key:e,value:t}){if("string"===Ca(t))return zn({key:e,value:t});{let i=[];for(let r in t)i.push(...zn({key:`${e}.${r}`,value:t[r]}));return i}}};function kn(e){let t=e.value,i=e.key,r=e.styleSpec,a=e.style,n=e.validateSpec;if(!t.type)return[new Ct(i,t,'"type" is required')];let s,o=mn(t.type);switch(o){case"vector":case"raster":return s=gn({key:i,value:t,valueSpec:r[`source_${o.replace("-","_")}`],style:e.style,styleSpec:r,objectElementValidators:Rn,validateSpec:n}),s;case"raster-dem":return s=function(e){let t=e.sourceName??"",i=e.value,r=e.styleSpec,a=r.source_raster_dem,n=e.style,s=[],o=Ca(i);if(void 0===i)return s;if("object"!==o)return s.push(new Ct("source_raster_dem",i,`object expected, ${o} found`)),s;let l="custom"===mn(i.encoding),h=["redFactor","greenFactor","blueFactor","baseShift"],u=e.value.encoding?`"${e.value.encoding}"`:"Default";for(let c in i)!l&&h.includes(c)?s.push(new Ct(c,i[c],`In "${t}": "${c}" is only valid when "encoding" is set to "custom". ${u} encoding found`)):a[c]?s=s.concat(e.validateSpec({key:c,value:i[c],valueSpec:a[c],validateSpec:e.validateSpec,style:n,styleSpec:r})):s.push(new Ct(c,i[c],`unknown property "${c}"`));return s}({sourceName:i,value:t,style:e.style,styleSpec:r,validateSpec:n}),s;case"geojson":if(s=gn({key:i,value:t,valueSpec:r.source_geojson,style:a,styleSpec:r,validateSpec:n,objectElementValidators:Rn}),t.cluster)for(let e in t.clusterProperties){let[r,a]=t.clusterProperties[e],o="string"==typeof r?[r,["accumulated"],["get",e]]:r;s.push(...bn({key:`${i}.${e}.map`,value:a,validateSpec:n,expressionContext:"cluster-map"})),s.push(...bn({key:`${i}.${e}.reduce`,value:o,validateSpec:n,expressionContext:"cluster-reduce"}))}return s;case"video":return gn({key:i,value:t,valueSpec:r.source_video,style:a,validateSpec:n,styleSpec:r});case"image":return gn({key:i,value:t,valueSpec:r.source_image,style:a,validateSpec:n,styleSpec:r});case"canvas":return[new Ct(i,null,"Please use runtime APIs to add canvas sources, rather than including them in stylesheets.","source.canvas")];default:return Tn({key:`${i}.type`,value:t.type,valueSpec:{values:["vector","raster","raster-dem","geojson","video","image"]},style:a,validateSpec:n,styleSpec:r})}}function Ln(e){let t=e.value,i=e.styleSpec,r=i.light,a=e.style,n=[],s=Ca(t);if(void 0===t)return n;if("object"!==s)return n=n.concat([new Ct("light",t,`object expected, ${s} found`)]),n;for(let o in t){let s=o.match(/^(.*)-transition$/);n=s&&r[s[1]]&&r[s[1]].transition?n.concat(e.validateSpec({key:o,value:t[o],valueSpec:i.transition,validateSpec:e.validateSpec,style:a,styleSpec:i})):r[o]?n.concat(e.validateSpec({key:o,value:t[o],valueSpec:r[o],validateSpec:e.validateSpec,style:a,styleSpec:i})):n.concat([new Ct(o,t[o],`unknown property "${o}"`)])}return n}function Fn(e){let t=e.value,i=e.styleSpec,r=i.sky,a=e.style,n=Ca(t);if(void 0===t)return[];if("object"!==n)return[new Ct("sky",t,`object expected, ${n} found`)];let s=[];for(let o in t)s=r[o]?s.concat(e.validateSpec({key:o,value:t[o],valueSpec:r[o],style:a,styleSpec:i})):s.concat([new Ct(o,t[o],`unknown property "${o}"`)]);return s}function Bn(e){let t=e.value,i=e.styleSpec,r=i.terrain,a=e.style,n=[],s=Ca(t);if(void 0===t)return n;if("object"!==s)return n=n.concat([new Ct("terrain",t,`object expected, ${s} found`)]),n;for(let o in t)n=r[o]?n.concat(e.validateSpec({key:o,value:t[o],valueSpec:r[o],validateSpec:e.validateSpec,style:a,styleSpec:i})):n.concat([new Ct(o,t[o],`unknown property "${o}"`)]);return n}function On(e){let t=[],i=e.value,r=e.key;if(Array.isArray(i)){let a=[],n=[];for(let s in i)i[s].id&&a.includes(i[s].id)&&t.push(new Ct(r,i,`all the sprites' ids must be unique, but ${i[s].id} is duplicated`)),a.push(i[s].id),i[s].url&&n.includes(i[s].url)&&t.push(new Ct(r,i,`all the sprites' URLs must be unique, but ${i[s].url} is duplicated`)),n.push(i[s].url),t=t.concat(gn({key:`${r}[${s}]`,value:i[s],valueSpec:{id:{type:"string",required:!0},url:{type:"string",required:!0}},validateSpec:e.validateSpec}));return t}return zn({key:r,value:i})}function Vn(e){return!!e&&e.constructor===Object}function jn(e){return Vn(e.value)?[]:[new Ct(e.key,e.value,`object expected, ${Ca(e.value)} found`)]}var Nn={"*":()=>[],array:yn,boolean:function(e){let t=e.value,i=e.key,r=Ca(t);return"boolean"===r?[]:[new Ct(i,t,`boolean expected, ${r} found`)]},number:vn,color:wn,constants:fn,enum:Tn,filter:In,function:xn,layer:Dn,object:gn,source:kn,light:Ln,sky:Fn,terrain:Bn,projection:function(e){let t=e.value,i=e.styleSpec,r=i.projection,a=e.style,n=Ca(t);if(void 0===t)return[];if("object"!==n)return[new Ct("projection",t,`object expected, ${n} found`)];let s=[];for(let o in t)s=r[o]?s.concat(e.validateSpec({key:o,value:t[o],valueSpec:r[o],style:a,styleSpec:i})):s.concat([new Ct(o,t[o],`unknown property "${o}"`)]);return s},projectionDefinition:function(e){let t=e.key,i=e.value;i=i instanceof String?i.valueOf():i;let r=Ca(i);return"array"!==r||function(e){return Array.isArray(e)&&3===e.length&&"string"==typeof e[0]&&"string"==typeof e[1]&&"number"==typeof e[2]}(i)||function(e){return!!["interpolate","step","literal"].includes(e[0])}(i)?["array","string"].includes(r)?[]:[new Ct(t,i,`projection expected, invalid type "${r}" found`)]:[new Ct(t,i,`projection expected, invalid array ${JSON.stringify(i)} found`)]},string:zn,formatted:function(e){return 0===zn(e).length?[]:bn(e)},resolvedImage:function(e){return 0===zn(e).length?[]:bn(e)},padding:function(e){let t=e.key,i=e.value;if("array"===Ca(i)){if(i.length<1||i.length>4)return[new Ct(t,i,`padding requires 1 to 4 values; ${i.length} values found`)];let r={type:"number"},a=[];for(let n=0;n<i.length;n++)a=a.concat(e.validateSpec({key:`${t}[${n}]`,value:i[n],validateSpec:e.validateSpec,valueSpec:r}));return a}return vn({key:t,value:i,valueSpec:{}})},numberArray:function(e){let t=e.key,i=e.value;if("array"===Ca(i)){let r={type:"number"};if(i.length<1)return[new Ct(t,i,"array length at least 1 expected, length 0 found")];let a=[];for(let n=0;n<i.length;n++)a=a.concat(e.validateSpec({key:`${t}[${n}]`,value:i[n],validateSpec:e.validateSpec,valueSpec:r}));return a}return vn({key:t,value:i,valueSpec:{}})},colorArray:function(e){let t=e.key,i=e.value;if("array"===Ca(i)){if(i.length<1)return[new Ct(t,i,"array length at least 1 expected, length 0 found")];let e=[];for(let r=0;r<i.length;r++)e=e.concat(wn({key:`${t}[${r}]`,value:i[r],valueSpec:{}}));return e}return wn({key:t,value:i,valueSpec:{}})},variableAnchorOffsetCollection:function(e){let t=e.key,i=e.value,r=Ca(i),a=e.styleSpec;if("array"!==r||i.length<1||i.length%2!=0)return[new Ct(t,i,"variableAnchorOffsetCollection requires a non-empty array of even length")];let n=[];for(let s=0;s<i.length;s+=2)n=n.concat(Tn({key:`${t}[${s}]`,value:i[s],valueSpec:a.layout_symbol["text-anchor"]})),n=n.concat(yn({key:`${t}[${s+1}]`,value:i[s+1],valueSpec:{length:2,value:"number"},validateSpec:e.validateSpec,style:e.style,styleSpec:a}));return n},sprite:On,state:jn,fontFaces:function(e){let t=e.key,i=e.value,r=e.validateSpec,a=e.styleSpec,n=e.style;if(!Vn(i))return[new Ct(t,i,`object expected, ${Ca(i)} found`)];let s=[];for(let o in i){let e=i[o],l=Ca(e);if("string"===l)s.push(...zn({key:`${t}.${o}`,value:e}));else if("array"===l){let i={url:{type:"string",required:!0},"unicode-range":{type:"array",value:"string"}};for(let[l,h]of e.entries())s.push(...gn({key:`${t}.${o}[${l}]`,value:h,valueSpec:i,styleSpec:a,style:n,validateSpec:r}))}else s.push(new Ct(`${t}.${o}`,e,`string or array expected, ${l} found`))}return s}};function Un(e){let t=e.value,i=e.valueSpec,r=e.styleSpec;return e.validateSpec=Un,i.expression&&Da(mn(t))?xn(e):i.expression&&Ua(_n(t))?bn(e):i.type&&Nn[i.type]?Nn[i.type](e):gn(Aa({},e,{valueSpec:i.type?r[i.type]:i}))}function Gn(e){let t=e.value,i=e.key,r=zn(e);return r.length||(-1===t.indexOf("{fontstack}")&&r.push(new Ct(i,t,'"glyphs" url must include a "{fontstack}" token')),-1===t.indexOf("{range}")&&r.push(new Ct(i,t,'"glyphs" url must include a "{range}" token'))),r}function $n(e,t=gt){let i=[];return i=i.concat(Un({key:"",value:e,valueSpec:t.$root,styleSpec:t,style:e,validateSpec:Un,objectElementValidators:{glyphs:Gn,"*":()=>[]}})),e.constants&&(i=i.concat(fn({key:"constants",value:e.constants,style:e,styleSpec:t,validateSpec:Un}))),qn(i)}function Zn(e){return function(t){return e(Object.assign({},t,{validateSpec:Un}))}}function qn(e){return[].concat(e).sort((e,t)=>e.line-t.line)}function Wn(e){return function(...t){return qn(e.apply(this,t))}}$n.source=Wn(Zn(kn)),$n.sprite=Wn(Zn(On)),$n.glyphs=Wn(Zn(Gn)),$n.light=Wn(Zn(Ln)),$n.sky=Wn(Zn(Fn)),$n.terrain=Wn(Zn(Bn)),$n.state=Wn(Zn(jn)),$n.layer=Wn(Zn(Dn)),$n.filter=Wn(Zn(In)),$n.paintProperty=Wn(Zn(An)),$n.layoutProperty=Wn(Zn(Cn));var Hn={type:"enum","property-type":"data-constant",expression:{interpolated:!1,parameters:["global-state"]},values:{visible:{},none:{}},transition:!1,default:"visible"},Xn=class{constructor(e,t,i){this._rootKey=t,this._globalState=i,this.setValue(e)}evaluate(){return this._literalValue??this._compiledValue.evaluate({})}setValue(e){if(null==e||"visible"===e||"none"===e)return this._literalValue="none"===e?"none":"visible",this._compiledValue=void 0,void(this._globalStateRefs=/* @__PURE__ */new Set);let t=Ga(e,this._rootKey,Hn,this._globalState);if("error"===t.result)throw this._literalValue="visible",this._compiledValue=void 0,Error(t.value.map(e=>`${e.key}: ${e.message}`).join(", "));this._literalValue=void 0,this._compiledValue=t.value,this._globalStateRefs=Xa(t.value.expression)}getGlobalStateRefs(){return this._globalStateRefs}},Yn=$n,Kn=new Set(Object.keys(gt).filter(e=>e.startsWith("source_")).map(e=>e.slice(7).replaceAll("_","-")));function Jn(e,t){let i=function(e){return Object.entries(e.sources??{}).filter(([,e])=>!Kn.has(e.type)).map(([e])=>`sources.${e}`)}(t);return Qn(e,Yn(t).filter(({message:e})=>!i.some(t=>e.startsWith(`${t}:`)||e.startsWith(`${t}.`))))}function Qn(e,t){let i=!1;for(let r of t)"warning"!==r.severity?(e.fire(new mt(Error(r.message))),i=!0):Re(r.message);return i}function es(e,t,i,r){return!1!==r?.validate&&Qn(e,t({styleSpec:gt,...i}))}var ts=class e{constructor(e,t,i){let r=this.cells=[];if(e instanceof ArrayBuffer){this.arrayBuffer=e;let a=new Int32Array(this.arrayBuffer);e=a[0],t=a[1],i=a[2],this.d=t+2*i;for(let e=0;e<this.d*this.d;e++){let t=a[3+e],i=a[3+e+1];r.push(t===i?null:a.subarray(t,i))}let n=a[3+r.length],s=a[3+r.length+1];this.keys=a.subarray(n,s),this.bboxes=a.subarray(s),this.insert=this._insertReadonly}else{this.d=t+2*i;for(let e=0;e<this.d*this.d;e++)r.push([]);this.keys=[],this.bboxes=[]}this.n=t,this.extent=e,this.padding=i,this.scale=t/e,this.uid=0;let a=i/t*e;this.min=-a,this.max=e+a}insert(e,t,i,r,a){this._forEachCell(t,i,r,a,this._insertCell,this.uid++,void 0,void 0),this.keys.push(e),this.bboxes.push(t),this.bboxes.push(i),this.bboxes.push(r),this.bboxes.push(a)}_insertReadonly(){throw Error("Cannot insert into a GridIndex created from an ArrayBuffer.")}_insertCell(e,t,i,r,a,n){this.cells[a].push(n)}query(e,t,i,r,a){let n=this.min,s=this.max;if(e<=n&&t<=n&&s<=i&&s<=r&&!a)return[...this.keys];{let n=[];return this._forEachCell(e,t,i,r,this._queryCell,n,{},a),n}}_queryCell(e,t,i,r,a,n,s,o){let l=this.cells[a];if(null!==l){let a=this.keys,h=this.bboxes;for(let u of l)if(void 0===s[u]){let l=4*u;(o?o(h[l+0],h[l+1],h[l+2],h[l+3]):e<=h[l+2]&&t<=h[l+3]&&i>=h[l+0]&&r>=h[l+1])?(s[u]=!0,n.push(a[u])):s[u]=!1}}}_forEachCell(e,t,i,r,a,n,s,o){let l=this._convertToCellCoord(e),h=this._convertToCellCoord(t),u=this._convertToCellCoord(i),c=this._convertToCellCoord(r);for(let p=l;p<=u;p++)for(let l=h;l<=c;l++){let h=this.d*l+p;if((!o||o(this._convertFromCellCoord(p),this._convertFromCellCoord(l),this._convertFromCellCoord(p+1),this._convertFromCellCoord(l+1)))&&a.call(this,e,t,i,r,h,n,s,o))return}}_convertFromCellCoord(e){return(e-this.padding)/this.scale}_convertToCellCoord(e){return Math.max(0,Math.min(this.d-1,Math.floor(e*this.scale)+this.padding))}toArrayBuffer(){if(this.arrayBuffer)return this.arrayBuffer;let e=this.cells,t=3+this.cells.length+1+1,i=0;for(let n of this.cells)i+=n.length;let r=new Int32Array(t+i+this.keys.length+this.bboxes.length);r[0]=this.extent,r[1]=this.n,r[2]=this.padding;let a=t;for(let n=0;n<e.length;n++){let t=e[n];r[3+n]=a,r.set(t,a),a+=t.length}return r[3+e.length]=a,r.set(this.keys,a),a+=this.keys.length,r[3+e.length+1]=a,r.set(this.bboxes,a),a+=this.bboxes.length,r.buffer}static serialize(e,t){let i=e.toArrayBuffer();return t&&t.push(i),{buffer:i}}static deserialize(t){return new e(t.buffer)}},is={};function rs(e,t,i={}){if(is[e])throw Error(`${e} is already registered.`);Object.defineProperty(t,"_classRegistryKey",{value:e,writeable:!1}),is[e]={klass:t,omit:i.omit||[],shallow:i.shallow||[]}}rs("Object",Object),rs("Set",Set),rs("TransferableGridIndex",ts),rs("Color",Si),rs("Error",Error),rs("AJAXError",ot),rs("ResolvedImage",Li),rs("StylePropertyFunction",Wa),rs("StyleExpression",Va,{omit:["_evaluator"]}),rs("ZoomDependentExpression",Za),rs("ZoomConstantExpression",$a),rs("CompoundExpression",ma,{omit:["_evaluate"]});for(let gT in fa)fa[gT]._classRegistryKey||rs(`Expression_${gT}`,fa[gT]);function as(e){return e&&typeof ArrayBuffer<"u"&&(e instanceof ArrayBuffer||"ArrayBuffer"===e.constructor?.name)}function ns(e){let t=e.constructor;return e.$name||t._classRegistryKey}function ss(e){return!function(e){if("object"!=typeof e||!e)return!1;let t=ns(e);return t&&"Object"!==t}(e)&&(null==e||"boolean"==typeof e||"number"==typeof e||"string"==typeof e||e instanceof Boolean||e instanceof Number||e instanceof String||e instanceof Date||e instanceof RegExp||e instanceof Blob||e instanceof Error||as(e)||Oe(e)||ArrayBuffer.isView(e)||e instanceof ImageData)}function os(e,t){if(ss(e))return(as(e)||Oe(e))&&t&&t.push(e),ArrayBuffer.isView(e)&&t&&t.push(e.buffer),e instanceof ImageData&&t&&t.push(e.data.buffer),e;if(Array.isArray(e)){let i=[];for(let r of e)i.push(os(r,t));return i}if("object"!=typeof e)throw Error("can't serialize object of type "+typeof e);let i=ns(e);if(!i)throw Error(`can't serialize object of unregistered class ${e.constructor.name}`);if(!is[i])throw Error(`${i} is not registered.`);let{klass:r}=is[i],a=r.serialize?r.serialize(e,t):{};if(r.serialize){if(a===t?.[t.length-1])throw Error("statically serialized object won't survive transfer of $name property")}else{for(let r in e){if(!e.hasOwnProperty(r)||is[i].omit.includes(r))continue;let n=e[r];void 0!==n&&(a[r]=is[i].shallow.includes(r)?n:os(n,t))}e instanceof Error&&(a.message=e.message)}if(a.$name)throw Error("$name property is reserved for worker serialization logic.");return"Object"!==i&&(a.$name=i),a}function ls(e){if(ss(e))return e;if(Array.isArray(e))return e.map(ls);if("object"!=typeof e)throw Error("can't deserialize object of type "+typeof e);let t=ns(e)||"Object";if(!is[t])throw Error(`can't deserialize unregistered class ${t}`);let{klass:i}=is[t];if(!i)throw Error(`can't deserialize unregistered class ${t}`);if(i.deserialize)return i.deserialize(e);let r=Object.create(i.prototype);for(let a of Object.keys(e)){if("$name"===a)continue;let i=e[a];r[a]=is[t].shallow.includes(a)?i:ls(i)}return r}var hs=class{constructor(){this.first=!0}update(e,t){let i=Math.floor(e);return this.first?(this.first=!1,this.lastIntegerZoom=i,this.lastIntegerZoomTime=0,this.lastZoom=e,this.lastFloorZoom=i,!0):(this.lastFloorZoom>i?(this.lastIntegerZoom=i+1,this.lastIntegerZoomTime=t):this.lastFloorZoom<i&&(this.lastIntegerZoom=i,this.lastIntegerZoomTime=t),e!==this.lastZoom&&(this.lastZoom=e,this.lastFloorZoom=i,!0))}};function us(e){return/[\u02EA\u02EB\u1100-\u11FF\u1400-\u167F\u18B0-\u18F5\u2E80-\u2E99\u2E9B-\u2EF3\u2F00-\u2FD5\u2FF0-\u3007\u3012\u3013\u3020-\u302F\u3031-\u303F\u3041-\u3096\u309D-\u30FB\u30FD-\u30FF\u3105-\u312F\u3131-\u318E\u3190-\uA48C\uA490-\uA4C6\uA960-\uA97C\uAC00-\uD7A3\uD7B0-\uD7C6\uD7CB-\uD7FB\uF900-\uFA6D\uFA70-\uFAD9\uFE10-\uFE1F\uFE30-\uFE48\uFE50-\uFE57\uFE5F-\uFE62\uFE67-\uFE6F\uFF00-\uFF07\uFF0A-\uFF0C\uFF0E-\uFF19\uFF1F-\uFF3A\uFF3C\uFF3E\uFF40-\uFF5A\uFFE0-\uFFE2\uFFE4-\uFFE7]|\uD802[\uDD80-\uDD9F]|\uD805[\uDD80-\uDDFF]|\uD806[\uDE00-\uDEBF]|\uD811[\uDC00-\uDE7F]|\uD81B[\uDFE0-\uDFE4\uDFF0-\uDFF6]|[\uD81C-\uD822\uD83D\uD840-\uD868\uD86A-\uD86D\uD86F-\uD872\uD874-\uD879\uD880-\uD883\uD885-\uD88C][\uDC00-\uDFFF]|\uD823[\uDC00-\uDCD5\uDCFF-\uDD1E\uDD80-\uDDF2]|\uD82B[\uDFF0-\uDFF3\uDFF5-\uDFFB\uDFFD\uDFFE]|\uD82C[\uDC00-\uDD22\uDD30-\uDEFB]|\uD833[\uDEC0-\uDFCF]|\uD834[\uDC00-\uDDFF\uDEE0-\uDF7F]|\uD836[\uDC00-\uDEAF]|\uD83C[\uDC00-\uDE00\uDF00-\uDFFF]|\uD83E[\uDD00-\uDEFF]|\uD869[\uDC00-\uDEDF\uDF00-\uDFFF]|\uD86E[\uDC00-\uDC1D\uDC20-\uDFFF]|\uD873[\uDC00-\uDEAD\uDEB0-\uDFFF]|\uD87A[\uDC00-\uDFE0\uDFF0-\uDFFF]|\uD87B[\uDC00-\uDE5D]|\uD87E[\uDC00-\uDE1D]|\uD884[\uDC00-\uDF4A\uDF50-\uDFFF]|\uD88D[\uDC00-\uDC79]/gim.test(String.fromCodePoint(e))}function cs(e){for(let t of e)if(us(t.codePointAt(0)))return!0;return!1}function ps(e){let t=e.map(e=>{try{return RegExp(`\\p{sc=${e}}`,"u").source}catch{return null}}).filter(e=>e);return new RegExp(t.join("|"),"u")}ps(["Arab","Dupl","Mong","Ougr","Syrc"]);var ds=ps("Adlm.Arab.Armi.Avst.Chrs.Cprt.Egyp.Elym.Gara.Hatr.Hebr.Hung.Khar.Lydi.Mand.Mani.Mend.Merc.Mero.Narb.Nbat.Nkoo.Orkh.Palm.Phli.Phlp.Phnx.Prti.Rohg.Samr.Sarb.Sogo.Syrc.Thaa.Todr.Yezi".split("."));function fs(e){return ds.test(String.fromCodePoint(e))}function ms(e,t){return!(!t&&fs(e)||function(e){return/[\u0900-\u0DFF\u0F00-\u109F\u1780-\u17FF]/gim.test(String.fromCodePoint(e))}(e))}function _s(e){for(let t of e)if(fs(t.codePointAt(0)))return!0;return!1}var gs=new class{constructor(){this.TIMEOUT=5e3,this.applyArabicShaping=null,this.processBidirectionalText=null,this.processStyledBidirectionalText=null,this.pluginStatus="unavailable",this.pluginURL=null,this.loadScriptResolve=()=>{}}setState(e){this.pluginStatus=e.pluginStatus,this.pluginURL=e.pluginURL}getState(){return{pluginStatus:this.pluginStatus,pluginURL:this.pluginURL}}setMethods(e){if(gs.isParsed())throw Error("RTL text plugin already registered.");this.applyArabicShaping=e.applyArabicShaping,this.processBidirectionalText=e.processBidirectionalText,this.processStyledBidirectionalText=e.processStyledBidirectionalText,this.loadScriptResolve()}isParsed(){return null!=this.applyArabicShaping&&null!=this.processBidirectionalText&&null!=this.processStyledBidirectionalText}getRTLTextPluginStatus(){return this.pluginStatus}async syncState(e,t){if(this.isParsed())return this.getState();if("loading"!==e.pluginStatus)return this.setState(e),e;let i=e.pluginURL,r=new Promise(e=>{this.loadScriptResolve=e}),a=new Promise(e=>setTimeout(()=>e(),this.TIMEOUT));if(await t(i),await Promise.race([r,a]),this.isParsed()){let e={pluginStatus:"loaded",pluginURL:i};return this.setState(e),e}throw this.setState({pluginStatus:"error",pluginURL:""}),Error(`RTL Text Plugin failed to import scripts from ${i}`)}},ys=class{constructor(e,t){this.isSupportedScript=vs,this.zoom=e,t?(this.now=t.now||0,this.fadeDuration=t.fadeDuration||0,this.zoomHistory=t.zoomHistory||new hs,this.transition=t.transition||{}):(this.now=0,this.fadeDuration=0,this.zoomHistory=new hs,this.transition={})}crossFadingFactor(){return 0===this.fadeDuration?1:Math.min((this.now-this.zoomHistory.lastIntegerZoomTime)/this.fadeDuration,1)}getCrossfadeParameters(){let e=this.zoom,t=e-Math.floor(e),i=this.crossFadingFactor();return e>this.zoomHistory.lastIntegerZoom?{fromScale:2,toScale:1,t:t+(1-t)*i}:{fromScale:.5,toScale:1,t:1-(1-i)*t}}};function vs(e){return function(e,t){for(let i of e)if(!ms(i.codePointAt(0),t))return!1;return!0}(e,"loaded"===gs.getRTLTextPluginStatus())}var xs=class{constructor(e,t,i,r){this.property=e,this.value=t,this.expression=function(e,t,i,r){if(Da(e))return new Wa(e,t,i);if(Ua(e)){let a=qa(e,t,i,r);if("error"===a.result)throw Error(a.value.map(e=>`${e.key}: ${e.message}`).join(", "));return a.value}{let t=e;return"color"===i.type&&"string"==typeof e?t=Si.parse(e):"padding"!==i.type||"number"!=typeof e&&!Array.isArray(e)?"numberArray"!==i.type||"number"!=typeof e&&!Array.isArray(e)?"colorArray"!==i.type||"string"!=typeof e&&!Array.isArray(e)?"variableAnchorOffsetCollection"===i.type&&Array.isArray(e)?t=ki.parse(e):"projectionDefinition"===i.type&&"string"==typeof e&&(t=Fi.parse(e)):t=Di.parse(e):t=Ci.parse(e):t=Ai.parse(e),{globalStateRefs:/* @__PURE__ */new Set,_globalState:null,kind:"constant",evaluate:()=>t}}}(void 0===t?e.specification.default:t,i,e.specification,r)}isDataDriven(){return"source"===this.expression.kind||"composite"===this.expression.kind}getGlobalStateRefs(){return this.expression.globalStateRefs||/* @__PURE__ */new Set}possiblyEvaluate(e,t,i){return this.property.possiblyEvaluate(this,e,t,i)}},bs=class{constructor(e,t,i){this.property=e,this.value=new xs(e,void 0,t,i)}transitioned(e,t){return new Ts(this.property,this.value,t,be({},e.transition,this.transition),e.now)}untransitioned(){return new Ts(this.property,this.value,null,{},0)}},ws=class{constructor(e,t,i){this._properties=e,this._values=Object.create(e.defaultTransitionablePropertyValues),this._globalState=i,this._rootKey=t}_propertyRootKey(e){return`${this._rootKey}.${String(e)}`}hasProperty(e){return e in this._properties.defaultTransitionablePropertyValues}getValue(e){return De(this._values[e].value.value)}setValue(e,t){Object.hasOwn(this._values,e)||(this._values[e]=new bs(this._values[e].property,this._propertyRootKey(e),this._globalState)),this._values[e].value=new xs(this._values[e].property,null===t?void 0:De(t),this._propertyRootKey(e),this._globalState)}getTransition(e){return De(this._values[e].transition)}setTransition(e,t){Object.hasOwn(this._values,e)||(this._values[e]=new bs(this._values[e].property,this._propertyRootKey(e),this._globalState)),this._values[e].transition=De(t)||void 0}serialize(){let e={};for(let t of Object.keys(this._values)){let i=this.getValue(t);void 0!==i&&(e[t]=i);let r=this.getTransition(t);void 0!==r&&(e[`${t}-transition`]=r)}return e}transitioned(e,t){let i=new Ss(this._properties);for(let r of Object.keys(this._values))i._values[r]=this._values[r].transitioned(e,t._values[r]);return i}untransitioned(){let e=new Ss(this._properties);for(let t of Object.keys(this._values))e._values[t]=this._values[t].untransitioned();return e}},Ts=class{constructor(e,t,i,r,a){this.property=e,this.value=t,this.begin=a+r.delay||0,this.end=this.begin+r.duration||0,e.specification.transition&&(r.delay||r.duration)&&(this.prior=i)}possiblyEvaluate(e,t,i){let r=e.now||0,a=this.value.possiblyEvaluate(e,t,i),n=this.prior;if(!n)return a;if(r>this.end||this.value.isDataDriven())return this.prior=null,a;if(r<this.begin)return n.possiblyEvaluate(e,t,i);{let s=(r-this.begin)/(this.end-this.begin);return this.property.interpolate(n.possiblyEvaluate(e,t,i),a,function(e){if(e<=0)return 0;if(e>=1)return 1;let t=e*e,i=t*e;return 4*(e<.5?i:3*(e-t)+i-.75)}(s))}}},Ss=class{constructor(e){this._properties=e,this._values=Object.create(e.defaultTransitioningPropertyValues)}possiblyEvaluate(e,t,i){let r=new Ms(this._properties);for(let a of Object.keys(this._values))r._values[a]=this._values[a].possiblyEvaluate(e,t,i);return r}hasTransition(){for(let e of Object.keys(this._values))if(this._values[e].prior)return!0;return!1}},Ps=class{constructor(e,t,i){this._properties=e,this._values=Object.create(e.defaultPropertyValues),this._globalState=i,this._rootKey=t}_propertyRootKey(e){return`${this._rootKey}.${String(e)}`}hasValue(e){return void 0!==this._values[e].value}hasProperty(e){return e in this._properties.defaultPropertyValues}getValue(e){return De(this._values[e].value)}setValue(e,t){this._values[e]=new xs(this._values[e].property,null===t?void 0:De(t),this._propertyRootKey(e),this._globalState)}serialize(){let e={};for(let t of Object.keys(this._values)){let i=this.getValue(t);void 0!==i&&(e[t]=i)}return e}possiblyEvaluate(e,t,i){let r=new Ms(this._properties);for(let a of Object.keys(this._values))r._values[a]=this._values[a].possiblyEvaluate(e,t,i);return r}},Is=class{constructor(e,t,i){this.property=e,this.value=t,this.parameters=i}isConstant(){return"constant"===this.value.kind}constantOr(e){return"constant"===this.value.kind?this.value.value:e}evaluate(e,t,i,r){return this.property.evaluate(this.value,this.parameters,e,t,i,r)}},Ms=class{constructor(e){this._properties=e,this._values=Object.create(e.defaultPossiblyEvaluatedValues)}get(e){return this._values[e]}};function Es(e){if(Array.isArray(e))return e.length;let t=e?.values;return Array.isArray(t)?t.length:void 0}function As(e,t){let i=Es(e),r=Es(t);return void 0!==i&&void 0!==r&&i!==r}var Cs=class{constructor(e,t){this.specification=e,this.name=t}possiblyEvaluate(e,t){if(e.isDataDriven())throw Error("Value should not be data driven");return e.expression.evaluate(t)}interpolate(e,t,i){if(As(e,t))return Re(`Property "${this.name}" is trying to interpolate arrays of different lengths. Rendering may 'jump'.`),t;let r=this.specification.type,a=tr[r];return a?a(e,t,i):e}},Ds=class{constructor(e,t,i){this.specification=e,this.name=t,this.overrides=i}possiblyEvaluate(e,t,i,r){return"constant"===e.expression.kind||"camera"===e.expression.kind?new Is(this,{kind:"constant",value:e.expression.evaluate(t,null,{},i,r)},t):new Is(this,e.expression,t)}interpolate(e,t,i){if("constant"!==e.value.kind||"constant"!==t.value.kind)return e;if(void 0===e.value.value||void 0===t.value.value)return new Is(this,{kind:"constant",value:void 0},e.parameters);if(As(e.value.value,t.value.value))return Re(`Property "${this.name}" is trying to interpolate arrays of different lengths. Rendering may 'jump'.`),t;let r=this.specification.type,a=tr[r];if(a){let r=a(e.value.value,t.value.value,i);return new Is(this,{kind:"constant",value:r},e.parameters)}return e}evaluate(e,t,i,r,a,n){return"constant"===e.kind?e.value:e.evaluate(t,i,r,a,n)}},zs=class extends Ds{possiblyEvaluate(e,t,i,r){if(void 0===e.value)return new Is(this,{kind:"constant",value:void 0},t);if("constant"===e.expression.kind){let a=e.expression.evaluate(t,null,{},i,r),n="resolvedImage"===e.property.specification.type&&"string"!=typeof a?a.name:a,s=this._calculate(n,n,n,t);return new Is(this,{kind:"constant",value:s},t)}if("camera"===e.expression.kind){let i=this._calculate(e.expression.evaluate({zoom:t.zoom-1}),e.expression.evaluate({zoom:t.zoom}),e.expression.evaluate({zoom:t.zoom+1}),t);return new Is(this,{kind:"constant",value:i},t)}return new Is(this,e.expression,t)}evaluate(e,t,i,r,a,n){if("source"===e.kind){let s=e.evaluate(t,i,r,a,n);return this._calculate(s,s,s,t)}return"composite"===e.kind?this._calculate(e.evaluate({zoom:Math.floor(t.zoom)-1},i,r),e.evaluate({zoom:Math.floor(t.zoom)},i,r),e.evaluate({zoom:Math.floor(t.zoom)+1},i,r),t):e.value}_calculate(e,t,i,r){return r.zoom>r.zoomHistory.lastIntegerZoom?{from:e,to:t}:{from:i,to:t}}interpolate(e){return e}},Rs=class{constructor(e,t){this.specification=e,this.name=t}possiblyEvaluate(e,t,i,r){if(void 0!==e.value){if("constant"===e.expression.kind){let a=e.expression.evaluate(t,null,{},i,r);return this._calculate(a,a,a,t)}return this._calculate(e.expression.evaluate(new ys(Math.floor(t.zoom-1),t)),e.expression.evaluate(new ys(Math.floor(t.zoom),t)),e.expression.evaluate(new ys(Math.floor(t.zoom+1),t)),t)}}_calculate(e,t,i,r){return r.zoom>r.zoomHistory.lastIntegerZoom?{from:e,to:t}:{from:i,to:t}}interpolate(e){return e}},ks=class{constructor(e,t){this.specification=e,this.name=t}possiblyEvaluate(e,t,i,r){return!!e.expression.evaluate(t,null,{},i,r)}interpolate(){return!1}},Ls=class{constructor(e){this.properties=e,this.defaultPropertyValues={},this.defaultTransitionablePropertyValues={},this.defaultTransitioningPropertyValues={},this.defaultPossiblyEvaluatedValues={},this.overridableProperties=[];for(let t in e){let i=e[t];i.specification.overridable&&this.overridableProperties.push(t);let r=this.defaultPropertyValues[t]=new xs(i,void 0,i.name,void 0),a=this.defaultTransitionablePropertyValues[t]=new bs(i,i.name,void 0);this.defaultTransitioningPropertyValues[t]=a.untransitioned(),this.defaultPossiblyEvaluatedValues[t]=r.possiblyEvaluate({})}}};rs("DataDrivenProperty",Ds),rs("DataConstantProperty",Cs),rs("CrossFadedDataDrivenProperty",zs),rs("CrossFadedProperty",Rs),rs("ColorRampProperty",ks);var Fs,Bs=" is a PAINT property not a LAYOUT property. Use get/setPaintProperty instead?",Os=" is a LAYOUT property not a PAINT property. Use get/setLayoutProperty instead?",Vs=class extends _t{constructor(e,t,i){if(super(),this.id=e.id,this.type=e.type,this._globalState=i,this._featureFilter={filter:()=>!0,needGeometry:!1,getGlobalStateRefs:()=>/* @__PURE__ */new Set},this._visibilityExpression=function(e,t,i){return new Xn(e,t,i)}(this.visibility,`layers[${this.id}].layout.visibility`,i),"custom"!==e.type&&(this.metadata=e.metadata,this.minzoom=e.minzoom,this.maxzoom=e.maxzoom,"background"!==e.type&&(this.source=e.source,this.sourceLayer=e["source-layer"],this.filter=e.filter,this._featureFilter=sn(e.filter,`layers[${this.id}].filter`,i)),t.layout&&(this._unevaluatedLayout=new Ps(t.layout,`layers[${this.id}].layout`,i)),t.paint)){this._transitionablePaint=new ws(t.paint,`layers[${this.id}].paint`,i);for(let t in e.paint)this.setPaintProperty(t,e.paint[t],{validate:!1});for(let t in e.layout)this.setLayoutProperty(t,e.layout[t],{validate:!1});this._transitioningPaint=this._transitionablePaint.untransitioned(),this.paint=new Ms(t.paint)}}setFilter(e){this.filter=e,this._featureFilter=sn(e,`layers[${this.id}].filter`,this._globalState)}getCrossfadeParameters(){return this._crossfadeParameters}getLayoutProperty(e){if("visibility"===e)return this.visibility;if(this._transitionablePaint?.hasProperty(e))throw Error(e+Bs);if(!this._unevaluatedLayout)throw Error(`Cannot get layout property "${e}" on layer type "${this.type}" which has no layout properties.`);return this._unevaluatedLayout.getValue(e)}getLayoutAffectingGlobalStateRefs(){let e=/* @__PURE__ */new Set;for(let t of this._visibilityExpression.getGlobalStateRefs())e.add(t);if(this._unevaluatedLayout)for(let t in this._unevaluatedLayout._values){let i=this._unevaluatedLayout._values[t];for(let t of i.getGlobalStateRefs())e.add(t)}for(let t of this._featureFilter.getGlobalStateRefs())e.add(t);return e}getPaintAffectingGlobalStateRefs(){let e=new globalThis.Map;if(this._transitionablePaint)for(let t in this._transitionablePaint._values){let i=this._transitionablePaint._values[t].value;for(let r of i.getGlobalStateRefs()){let a=e.get(r)??[];a.push({name:t,value:i.value}),e.set(r,a)}}return e}getVisibilityAffectingGlobalStateRefs(){return this._visibilityExpression.getGlobalStateRefs()}setLayoutProperty(e,t,i={}){if("visibility"===e)return this.visibility=t,this._visibilityExpression.setValue(t),void this.recalculateVisibility();this._transitionablePaint?.hasProperty(e)?this.fire(new mt(Error(e+Bs))):null!=t&&this._validate(Yn.layoutProperty,`layers.${this.id}.layout.${e}`,e,t,i)||this._unevaluatedLayout.setValue(e,t)}getPaintProperty(e){if(e.endsWith("-transition")){let t=e.slice(0,-11);if("visibility"===t||this._unevaluatedLayout?.hasProperty(t))throw Error(e+Os);return this._transitionablePaint.getTransition(t)}if("visibility"===e||this._unevaluatedLayout?.hasProperty(e))throw Error(e+Os);return this._transitionablePaint.getValue(e)}setPaintProperty(e,t,i={}){if("visibility"===e||this._unevaluatedLayout?.hasProperty(e))return this.fire(new mt(Error(e+Os))),!1;if(null!=t&&this._validate(Yn.paintProperty,`layers.${this.id}.paint.${e}`,e,t,i))return!1;if(e.endsWith("-transition"))return this._transitionablePaint.setTransition(e.slice(0,-11),t||void 0),!1;{let i=this._transitionablePaint._values[e],r="cross-faded-data-driven"===i.property.specification["property-type"],a=i.value.isDataDriven(),n=i.value;this._transitionablePaint.setValue(e,t),this._handleSpecialPaintPropertyUpdate(e);let s=this._transitionablePaint._values[e].value;return s.isDataDriven()||a||r||this._handleOverridablePaintPropertyUpdate(e,n,s)}}_handleSpecialPaintPropertyUpdate(e){}_handleOverridablePaintPropertyUpdate(e,t,i){return!1}isHidden(e=this.minzoom,t=!1){return!!(this.minzoom&&e<(t?Math.floor(this.minzoom):this.minzoom)||this.maxzoom&&e>=this.maxzoom)||"none"===this._evaluatedVisibility}updateTransitions(e){this._transitioningPaint=this._transitionablePaint.transitioned(e,this._transitioningPaint)}hasTransition(){return this._transitioningPaint.hasTransition()}recalculateVisibility(){this._evaluatedVisibility=this._visibilityExpression.evaluate()}recalculate(e,t){e.getCrossfadeParameters&&(this._crossfadeParameters=e.getCrossfadeParameters()),this._unevaluatedLayout&&(this.layout=this._unevaluatedLayout.possiblyEvaluate(e,void 0,t)),this.paint=this._transitioningPaint.possiblyEvaluate(e,void 0,t)}serialize(){let e={id:this.id,type:this.type,source:this.source,"source-layer":this.sourceLayer,metadata:this.metadata,minzoom:this.minzoom,maxzoom:this.maxzoom,filter:this.filter,layout:this._unevaluatedLayout?.serialize(),paint:this._transitionablePaint?.serialize()};return this.visibility&&(e.layout||={},e.layout.visibility=this.visibility),Ae(e,(e,t)=>!(void 0===e||"layout"===t&&!Object.keys(e).length||"paint"===t&&!Object.keys(e).length))}_validate(e,t,i,r,a={}){return es(this,e,{key:t,layerType:this.type,objectKey:i,value:r},a)}is3D(){return!1}isTileClipped(){return!1}hasOffscreenPass(){return!1}resize(){}isStateDependent(){for(let e in this.paint._values){let t=this.paint.get(e);if(t instanceof Is&&Ia(t.property.specification)&&("source"===t.value.kind||"composite"===t.value.kind)&&t.value.isStateDependent)return!0}return!1}},js={get paint(){return Fs||=new Ls({"raster-opacity":new Cs(gt.paint_raster["raster-opacity"],"raster-opacity"),"raster-hue-rotate":new Cs(gt.paint_raster["raster-hue-rotate"],"raster-hue-rotate"),"raster-brightness-min":new Cs(gt.paint_raster["raster-brightness-min"],"raster-brightness-min"),"raster-brightness-max":new Cs(gt.paint_raster["raster-brightness-max"],"raster-brightness-max"),"raster-saturation":new Cs(gt.paint_raster["raster-saturation"],"raster-saturation"),"raster-contrast":new Cs(gt.paint_raster["raster-contrast"],"raster-contrast"),resampling:new Cs(gt.paint_raster.resampling,"resampling"),"raster-resampling":new Cs(gt.paint_raster["raster-resampling"],"raster-resampling"),"raster-fade-duration":new Cs(gt.paint_raster["raster-fade-duration"],"raster-fade-duration")})}},Ns=e=>"raster"===e.type,Us=class extends Vs{constructor(e,t){super(e,js,t)}},Gs={Int8:Int8Array,Uint8:Uint8Array,Int16:Int16Array,Uint16:Uint16Array,Int32:Int32Array,Uint32:Uint32Array,Float32:Float32Array},$s=class{constructor(e,t){this._structArray=e,this._pos1=t*this.size,this._pos2=this._pos1/2,this._pos4=this._pos1/4,this._pos8=this._pos1/8}},Zs=class{constructor(){this.isTransferred=!1,this.capacity=-1,this.resize(0)}static serialize(e,t){return e._trim(),t&&(e.isTransferred=!0,t.push(e.arrayBuffer)),{length:e.length,arrayBuffer:e.arrayBuffer}}static deserialize(e){let t=Object.create(this.prototype);return t.arrayBuffer=e.arrayBuffer,t.length=e.length,t.capacity=e.arrayBuffer.byteLength/t.bytesPerElement,t._refreshViews(),t}_trim(){this.length!==this.capacity&&(this.capacity=this.length,this.arrayBuffer=this.arrayBuffer.slice(0,this.length*this.bytesPerElement),this._refreshViews())}clear(){this.length=0}resize(e){this.reserve(e),this.length=e}reserve(e){if(e>this.capacity){this.capacity=Math.max(e,Math.floor(5*this.capacity),128),this.arrayBuffer=new ArrayBuffer(this.capacity*this.bytesPerElement);let t=this.uint8;this._refreshViews(),t&&this.uint8.set(t)}}_refreshViews(){throw Error("_refreshViews() must be implemented by each concrete StructArray layout")}freeBufferAfterUpload(){this.arrayBuffer=/* @__PURE__ */new ArrayBuffer(0),this._refreshViews()}};function qs(e,t=1){let i=0,r=0;return{members:e.map(e=>{let a=function(e){return Gs[e].BYTES_PER_ELEMENT}(e.type),n=i=Ws(i,Math.max(t,a)),s=e.components||1;return r=Math.max(r,a),i+=a*s,{name:e.name,type:e.type,components:s,offset:n}}),size:Ws(i,Math.max(r,t)),alignment:t}}function Ws(e,t){return Math.ceil(e/t)*t}var Hs=class extends Zs{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(e,t){let i=this.length;return this.resize(i+1),this.emplace(i,e,t)}emplace(e,t,i){let r=2*e;return this.int16[r+0]=t,this.int16[r+1]=i,e}};Hs.prototype.bytesPerElement=4,rs("StructArrayLayout2i4",Hs);var Xs=class extends Zs{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(e,t,i){let r=this.length;return this.resize(r+1),this.emplace(r,e,t,i)}emplace(e,t,i,r){let a=3*e;return this.int16[a+0]=t,this.int16[a+1]=i,this.int16[a+2]=r,e}};Xs.prototype.bytesPerElement=6,rs("StructArrayLayout3i6",Xs);var Ys=class extends Zs{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(e,t,i,r){let a=this.length;return this.resize(a+1),this.emplace(a,e,t,i,r)}emplace(e,t,i,r,a){let n=4*e;return this.int16[n+0]=t,this.int16[n+1]=i,this.int16[n+2]=r,this.int16[n+3]=a,e}};Ys.prototype.bytesPerElement=8,rs("StructArrayLayout4i8",Ys);var Ks=class extends Zs{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(e,t,i,r,a,n){let s=this.length;return this.resize(s+1),this.emplace(s,e,t,i,r,a,n)}emplace(e,t,i,r,a,n,s){let o=6*e;return this.int16[o+0]=t,this.int16[o+1]=i,this.int16[o+2]=r,this.int16[o+3]=a,this.int16[o+4]=n,this.int16[o+5]=s,e}};Ks.prototype.bytesPerElement=12,rs("StructArrayLayout2i4i12",Ks);var Js=class extends Zs{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(e,t,i,r,a,n){let s=this.length;return this.resize(s+1),this.emplace(s,e,t,i,r,a,n)}emplace(e,t,i,r,a,n,s){let o=4*e,l=8*e;return this.int16[o+0]=t,this.int16[o+1]=i,this.uint8[l+4]=r,this.uint8[l+5]=a,this.uint8[l+6]=n,this.uint8[l+7]=s,e}};Js.prototype.bytesPerElement=8,rs("StructArrayLayout2i4ub8",Js);var Qs=class extends Zs{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(e,t){let i=this.length;return this.resize(i+1),this.emplace(i,e,t)}emplace(e,t,i){let r=2*e;return this.float32[r+0]=t,this.float32[r+1]=i,e}};Qs.prototype.bytesPerElement=8,rs("StructArrayLayout2f8",Qs);var eo=class extends Zs{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(e,t,i,r,a,n,s,o,l,h){let u=this.length;return this.resize(u+1),this.emplace(u,e,t,i,r,a,n,s,o,l,h)}emplace(e,t,i,r,a,n,s,o,l,h,u){let c=10*e;return this.uint16[c+0]=t,this.uint16[c+1]=i,this.uint16[c+2]=r,this.uint16[c+3]=a,this.uint16[c+4]=n,this.uint16[c+5]=s,this.uint16[c+6]=o,this.uint16[c+7]=l,this.uint16[c+8]=h,this.uint16[c+9]=u,e}};eo.prototype.bytesPerElement=20,rs("StructArrayLayout10ui20",eo);var to=class extends Zs{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(e,t,i,r,a,n,s,o){let l=this.length;return this.resize(l+1),this.emplace(l,e,t,i,r,a,n,s,o)}emplace(e,t,i,r,a,n,s,o,l){let h=8*e;return this.uint16[h+0]=t,this.uint16[h+1]=i,this.uint16[h+2]=r,this.uint16[h+3]=a,this.uint16[h+4]=n,this.uint16[h+5]=s,this.uint16[h+6]=o,this.uint16[h+7]=l,e}};to.prototype.bytesPerElement=16,rs("StructArrayLayout8ui16",to);var io=class extends Zs{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(e,t,i,r,a,n,s,o,l,h,u,c){let p=this.length;return this.resize(p+1),this.emplace(p,e,t,i,r,a,n,s,o,l,h,u,c)}emplace(e,t,i,r,a,n,s,o,l,h,u,c,p){let d=12*e;return this.int16[d+0]=t,this.int16[d+1]=i,this.int16[d+2]=r,this.int16[d+3]=a,this.uint16[d+4]=n,this.uint16[d+5]=s,this.uint16[d+6]=o,this.uint16[d+7]=l,this.int16[d+8]=h,this.int16[d+9]=u,this.int16[d+10]=c,this.int16[d+11]=p,e}};io.prototype.bytesPerElement=24,rs("StructArrayLayout4i4ui4i24",io);var ro=class extends Zs{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(e,t,i){let r=this.length;return this.resize(r+1),this.emplace(r,e,t,i)}emplace(e,t,i,r){let a=3*e;return this.float32[a+0]=t,this.float32[a+1]=i,this.float32[a+2]=r,e}};ro.prototype.bytesPerElement=12,rs("StructArrayLayout3f12",ro);var ao=class extends Zs{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint32=new Uint32Array(this.arrayBuffer)}emplaceBack(e){let t=this.length;return this.resize(t+1),this.emplace(t,e)}emplace(e,t){let i=1*e;return this.uint32[i+0]=t,e}};ao.prototype.bytesPerElement=4,rs("StructArrayLayout1ul4",ao);var no=class extends Zs{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer),this.uint32=new Uint32Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(e,t,i,r,a,n,s,o,l){let h=this.length;return this.resize(h+1),this.emplace(h,e,t,i,r,a,n,s,o,l)}emplace(e,t,i,r,a,n,s,o,l,h){let u=10*e,c=5*e;return this.int16[u+0]=t,this.int16[u+1]=i,this.int16[u+2]=r,this.int16[u+3]=a,this.int16[u+4]=n,this.int16[u+5]=s,this.uint32[c+3]=o,this.uint16[u+8]=l,this.uint16[u+9]=h,e}};no.prototype.bytesPerElement=20,rs("StructArrayLayout6i1ul2ui20",no);var so=class extends Zs{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(e,t,i,r,a,n){let s=this.length;return this.resize(s+1),this.emplace(s,e,t,i,r,a,n)}emplace(e,t,i,r,a,n,s){let o=6*e;return this.int16[o+0]=t,this.int16[o+1]=i,this.int16[o+2]=r,this.int16[o+3]=a,this.int16[o+4]=n,this.int16[o+5]=s,e}};so.prototype.bytesPerElement=12,rs("StructArrayLayout2i2i2i12",so);var oo=class extends Zs{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(e,t,i,r,a){let n=this.length;return this.resize(n+1),this.emplace(n,e,t,i,r,a)}emplace(e,t,i,r,a,n){let s=4*e,o=8*e;return this.float32[s+0]=t,this.float32[s+1]=i,this.float32[s+2]=r,this.int16[o+6]=a,this.int16[o+7]=n,e}};oo.prototype.bytesPerElement=16,rs("StructArrayLayout2f1f2i16",oo);var lo=class extends Zs{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(e,t,i,r,a,n){let s=this.length;return this.resize(s+1),this.emplace(s,e,t,i,r,a,n)}emplace(e,t,i,r,a,n,s){let o=16*e,l=4*e,h=8*e;return this.uint8[o+0]=t,this.uint8[o+1]=i,this.float32[l+1]=r,this.float32[l+2]=a,this.int16[h+6]=n,this.int16[h+7]=s,e}};lo.prototype.bytesPerElement=16,rs("StructArrayLayout2ub2f2i16",lo);var ho=class extends Zs{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(e,t,i){let r=this.length;return this.resize(r+1),this.emplace(r,e,t,i)}emplace(e,t,i,r){let a=3*e;return this.uint16[a+0]=t,this.uint16[a+1]=i,this.uint16[a+2]=r,e}};ho.prototype.bytesPerElement=6,rs("StructArrayLayout3ui6",ho);var uo=class extends Zs{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer),this.uint32=new Uint32Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(e,t,i,r,a,n,s,o,l,h,u,c,p,d,f,m,_){let g=this.length;return this.resize(g+1),this.emplace(g,e,t,i,r,a,n,s,o,l,h,u,c,p,d,f,m,_)}emplace(e,t,i,r,a,n,s,o,l,h,u,c,p,d,f,m,_,g){let y=24*e,v=12*e,x=48*e;return this.int16[y+0]=t,this.int16[y+1]=i,this.uint16[y+2]=r,this.uint16[y+3]=a,this.uint32[v+2]=n,this.uint32[v+3]=s,this.uint32[v+4]=o,this.uint16[y+10]=l,this.uint16[y+11]=h,this.uint16[y+12]=u,this.float32[v+7]=c,this.float32[v+8]=p,this.uint8[x+36]=d,this.uint8[x+37]=f,this.uint8[x+38]=m,this.uint32[v+10]=_,this.int16[y+22]=g,e}};uo.prototype.bytesPerElement=48,rs("StructArrayLayout2i2ui3ul3ui2f3ub1ul1i48",uo);var co=class extends Zs{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer),this.uint32=new Uint32Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(e,t,i,r,a,n,s,o,l,h,u,c,p,d,f,m,_,g,y,v,x,b,w,T,S,P,I,M){let E=this.length;return this.resize(E+1),this.emplace(E,e,t,i,r,a,n,s,o,l,h,u,c,p,d,f,m,_,g,y,v,x,b,w,T,S,P,I,M)}emplace(e,t,i,r,a,n,s,o,l,h,u,c,p,d,f,m,_,g,y,v,x,b,w,T,S,P,I,M,E){let A=32*e,C=16*e;return this.int16[A+0]=t,this.int16[A+1]=i,this.int16[A+2]=r,this.int16[A+3]=a,this.int16[A+4]=n,this.int16[A+5]=s,this.int16[A+6]=o,this.int16[A+7]=l,this.uint16[A+8]=h,this.uint16[A+9]=u,this.uint16[A+10]=c,this.uint16[A+11]=p,this.uint16[A+12]=d,this.uint16[A+13]=f,this.uint16[A+14]=m,this.uint16[A+15]=_,this.uint16[A+16]=g,this.uint16[A+17]=y,this.uint16[A+18]=v,this.uint16[A+19]=x,this.uint16[A+20]=b,this.uint16[A+21]=w,this.uint16[A+22]=T,this.uint32[C+12]=S,this.float32[C+13]=P,this.float32[C+14]=I,this.uint16[A+30]=M,this.uint16[A+31]=E,e}};co.prototype.bytesPerElement=64,rs("StructArrayLayout8i15ui1ul2f2ui64",co);var po=class extends Zs{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(e){let t=this.length;return this.resize(t+1),this.emplace(t,e)}emplace(e,t){let i=1*e;return this.float32[i+0]=t,e}};po.prototype.bytesPerElement=4,rs("StructArrayLayout1f4",po);var fo=class extends Zs{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(e,t,i){let r=this.length;return this.resize(r+1),this.emplace(r,e,t,i)}emplace(e,t,i,r){let a=6*e,n=3*e;return this.uint16[a+0]=t,this.float32[n+1]=i,this.float32[n+2]=r,e}};fo.prototype.bytesPerElement=12,rs("StructArrayLayout1ui2f12",fo);var mo=class extends Zs{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint32=new Uint32Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(e,t,i){let r=this.length;return this.resize(r+1),this.emplace(r,e,t,i)}emplace(e,t,i,r){let a=2*e,n=4*e;return this.uint32[a+0]=t,this.uint16[n+2]=i,this.uint16[n+3]=r,e}};mo.prototype.bytesPerElement=8,rs("StructArrayLayout1ul2ui8",mo);var _o=class extends Zs{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(e,t){let i=this.length;return this.resize(i+1),this.emplace(i,e,t)}emplace(e,t,i){let r=2*e;return this.uint16[r+0]=t,this.uint16[r+1]=i,e}};_o.prototype.bytesPerElement=4,rs("StructArrayLayout2ui4",_o);var go=class extends Zs{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(e){let t=this.length;return this.resize(t+1),this.emplace(t,e)}emplace(e,t){let i=1*e;return this.uint16[i+0]=t,e}};go.prototype.bytesPerElement=2,rs("StructArrayLayout1ui2",go);var yo=class extends Zs{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(e,t,i,r){let a=this.length;return this.resize(a+1),this.emplace(a,e,t,i,r)}emplace(e,t,i,r,a){let n=4*e;return this.float32[n+0]=t,this.float32[n+1]=i,this.float32[n+2]=r,this.float32[n+3]=a,e}};yo.prototype.bytesPerElement=16,rs("StructArrayLayout4f16",yo);var vo=class extends $s{get anchorPointX(){return this._structArray.int16[this._pos2+0]}get anchorPointY(){return this._structArray.int16[this._pos2+1]}get x1(){return this._structArray.int16[this._pos2+2]}get y1(){return this._structArray.int16[this._pos2+3]}get x2(){return this._structArray.int16[this._pos2+4]}get y2(){return this._structArray.int16[this._pos2+5]}get featureIndex(){return this._structArray.uint32[this._pos4+3]}get sourceLayerIndex(){return this._structArray.uint16[this._pos2+8]}get bucketIndex(){return this._structArray.uint16[this._pos2+9]}get anchorPoint(){return new u(this.anchorPointX,this.anchorPointY)}};vo.prototype.size=20;var xo=class extends no{get(e){return new vo(this,e)}};rs("CollisionBoxArray",xo);var bo=class extends $s{get anchorX(){return this._structArray.int16[this._pos2+0]}get anchorY(){return this._structArray.int16[this._pos2+1]}get glyphStartIndex(){return this._structArray.uint16[this._pos2+2]}get numGlyphs(){return this._structArray.uint16[this._pos2+3]}get vertexStartIndex(){return this._structArray.uint32[this._pos4+2]}get lineStartIndex(){return this._structArray.uint32[this._pos4+3]}get lineLength(){return this._structArray.uint32[this._pos4+4]}get segment(){return this._structArray.uint16[this._pos2+10]}get lowerSize(){return this._structArray.uint16[this._pos2+11]}get upperSize(){return this._structArray.uint16[this._pos2+12]}get lineOffsetX(){return this._structArray.float32[this._pos4+7]}get lineOffsetY(){return this._structArray.float32[this._pos4+8]}get writingMode(){return this._structArray.uint8[this._pos1+36]}get placedOrientation(){return this._structArray.uint8[this._pos1+37]}set placedOrientation(e){this._structArray.uint8[this._pos1+37]=e}get hidden(){return this._structArray.uint8[this._pos1+38]}set hidden(e){this._structArray.uint8[this._pos1+38]=e}get crossTileID(){return this._structArray.uint32[this._pos4+10]}set crossTileID(e){this._structArray.uint32[this._pos4+10]=e}get associatedIconIndex(){return this._structArray.int16[this._pos2+22]}};bo.prototype.size=48;var wo=class extends uo{get(e){return new bo(this,e)}};rs("PlacedSymbolArray",wo);var To=class extends $s{get anchorX(){return this._structArray.int16[this._pos2+0]}get anchorY(){return this._structArray.int16[this._pos2+1]}get rightJustifiedTextSymbolIndex(){return this._structArray.int16[this._pos2+2]}get centerJustifiedTextSymbolIndex(){return this._structArray.int16[this._pos2+3]}get leftJustifiedTextSymbolIndex(){return this._structArray.int16[this._pos2+4]}get verticalPlacedTextSymbolIndex(){return this._structArray.int16[this._pos2+5]}get placedIconSymbolIndex(){return this._structArray.int16[this._pos2+6]}get verticalPlacedIconSymbolIndex(){return this._structArray.int16[this._pos2+7]}get key(){return this._structArray.uint16[this._pos2+8]}get textBoxStartIndex(){return this._structArray.uint16[this._pos2+9]}get textBoxEndIndex(){return this._structArray.uint16[this._pos2+10]}get verticalTextBoxStartIndex(){return this._structArray.uint16[this._pos2+11]}get verticalTextBoxEndIndex(){return this._structArray.uint16[this._pos2+12]}get iconBoxStartIndex(){return this._structArray.uint16[this._pos2+13]}get iconBoxEndIndex(){return this._structArray.uint16[this._pos2+14]}get verticalIconBoxStartIndex(){return this._structArray.uint16[this._pos2+15]}get verticalIconBoxEndIndex(){return this._structArray.uint16[this._pos2+16]}get featureIndex(){return this._structArray.uint16[this._pos2+17]}get numHorizontalGlyphVertices(){return this._structArray.uint16[this._pos2+18]}get numVerticalGlyphVertices(){return this._structArray.uint16[this._pos2+19]}get numIconVertices(){return this._structArray.uint16[this._pos2+20]}get numVerticalIconVertices(){return this._structArray.uint16[this._pos2+21]}get useRuntimeCollisionCircles(){return this._structArray.uint16[this._pos2+22]}get crossTileID(){return this._structArray.uint32[this._pos4+12]}set crossTileID(e){this._structArray.uint32[this._pos4+12]=e}get textBoxScale(){return this._structArray.float32[this._pos4+13]}get collisionCircleDiameter(){return this._structArray.float32[this._pos4+14]}get textAnchorOffsetStartIndex(){return this._structArray.uint16[this._pos2+30]}get textAnchorOffsetEndIndex(){return this._structArray.uint16[this._pos2+31]}};To.prototype.size=64;var So=class extends co{get(e){return new To(this,e)}};rs("SymbolInstanceArray",So);var Po=class extends po{getoffsetX(e){return this.float32[1*e+0]}};rs("GlyphOffsetArray",Po);var Io=class extends Xs{getx(e){return this.int16[3*e+0]}gety(e){return this.int16[3*e+1]}gettileUnitDistanceFromAnchor(e){return this.int16[3*e+2]}};rs("SymbolLineVertexArray",Io);var Mo=class extends $s{get textAnchor(){return this._structArray.uint16[this._pos2+0]}get textOffset0(){return this._structArray.float32[this._pos4+1]}get textOffset1(){return this._structArray.float32[this._pos4+2]}};Mo.prototype.size=12;var Eo=class extends fo{get(e){return new Mo(this,e)}};rs("TextAnchorOffsetArray",Eo);var Ao=class extends $s{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]}};Ao.prototype.size=8;var Co=class extends mo{get(e){return new Ao(this,e)}};rs("FeatureIndexArray",Co);var Do=class extends Hs{},zo=class extends Xs{},Ro=class extends Ys{},ko=class extends Hs{},Lo=class extends Hs{},Fo=class extends Ks{},Bo=class extends Js{},Oo=class extends Qs{},Vo=class extends eo{},jo=class extends to{},No=class extends io{},Uo=class extends ro{},Go=class extends ao{},$o=class extends so{},Zo=class extends oo{},qo=class extends lo{},Wo=class extends ho{},Ho=class extends ho{},Xo=class extends _o{},Yo=class extends go{},Ko=qs([{name:"a_pos",components:2,type:"Int16"}],4),Jo=Ko.members;Ko.size,Ko.alignment;var Qo=class e{constructor(e=[]){this._forceNewSegmentOnNextPrepare=!1,this.segments=e}prepareSegment(t,i,r,a){let n=this.segments[this.segments.length-1];return t>e.MAX_VERTEX_ARRAY_LENGTH&&Re(`Max vertices per segment is ${e.MAX_VERTEX_ARRAY_LENGTH}: bucket requested ${t}. Consider using the \`fillLargeMeshArrays\` function if you require meshes with more than ${e.MAX_VERTEX_ARRAY_LENGTH} vertices.`),this._forceNewSegmentOnNextPrepare||!n||n.vertexLength+t>e.MAX_VERTEX_ARRAY_LENGTH||n.sortKey!==a?this.createNewSegment(i,r,a):n}createNewSegment(e,t,i){let r={vertexOffset:e.length,primitiveOffset:t.length,vertexLength:0,primitiveLength:0,vaos:{}};return void 0!==i&&(r.sortKey=i),this._forceNewSegmentOnNextPrepare=!1,this.segments.push(r),r}getOrCreateLatestSegment(e,t,i){return this.prepareSegment(0,e,t,i)}forceNewSegmentOnNextPrepare(){this._forceNewSegmentOnNextPrepare=!0}get(){return this.segments}destroy(){for(let e of this.segments)for(let t in e.vaos)e.vaos[t].destroy()}static simpleSegment(t,i,r,a){return new e([{vertexOffset:t,primitiveOffset:i,vertexLength:r,primitiveLength:a,vaos:{},sortKey:0}])}};function el(e,t){return 256*(e=ve(Math.floor(e),0,255))+ve(Math.floor(t),0,255)}Qo.MAX_VERTEX_ARRAY_LENGTH=65535,rs("SegmentVector",Qo);var tl=qs([{name:"a_pattern_from",components:4,type:"Uint16"},{name:"a_pattern_to",components:4,type:"Uint16"},{name:"a_pixel_ratio_from",components:1,type:"Uint16"},{name:"a_pixel_ratio_to",components:1,type:"Uint16"}]),il=qs([{name:"a_dasharray_from",components:4,type:"Uint16"},{name:"a_dasharray_to",components:4,type:"Uint16"}]),rl=l((e,t)=>{void 0!==t&&(t.exports=function(e,t){for(var i,r,a=3&e.length,n=e.length-a,s=t,o=3432918353,l=461845907,h=0;h<n;)r=255&e.charCodeAt(h)|(255&e.charCodeAt(++h))<<8|(255&e.charCodeAt(++h))<<16|(255&e.charCodeAt(++h))<<24,++h,s=27492+(65535&(i=5*(65535&(s=(s^=r=(65535&(r=(r=(65535&r)*o+(((r>>>16)*o&65535)<<16)&4294967295)<<15|r>>>17))*l+(((r>>>16)*l&65535)<<16)&4294967295)<<13|s>>>19))+((5*(s>>>16)&65535)<<16)&4294967295))+(((i>>>16)+58964&65535)<<16);switch(r=0,a){case 3:r^=(255&e.charCodeAt(h+2))<<16;case 2:r^=(255&e.charCodeAt(h+1))<<8;case 1:s^=r=(65535&(r=(r=(65535&(r^=255&e.charCodeAt(h)))*o+(((r>>>16)*o&65535)<<16)&4294967295)<<15|r>>>17))*l+(((r>>>16)*l&65535)<<16)&4294967295}return s^=e.length,s=2246822507*(65535&(s^=s>>>16))+((2246822507*(s>>>16)&65535)<<16)&4294967295,s=3266489909*(65535&(s^=s>>>13))+((3266489909*(s>>>16)&65535)<<16)&4294967295,(s^=s>>>16)>>>0})}),al=l((e,t)=>{t.exports=function(e,t){for(var i,r=e.length,a=t^r,n=0;r>=4;)i=1540483477*(65535&(i=255&e.charCodeAt(n)|(255&e.charCodeAt(++n))<<8|(255&e.charCodeAt(++n))<<16|(255&e.charCodeAt(++n))<<24))+((1540483477*(i>>>16)&65535)<<16),a=1540483477*(65535&a)+((1540483477*(a>>>16)&65535)<<16)^(i=1540483477*(65535&(i^=i>>>24))+((1540483477*(i>>>16)&65535)<<16)),r-=4,++n;switch(r){case 3:a^=(255&e.charCodeAt(n+2))<<16;case 2:a^=(255&e.charCodeAt(n+1))<<8;case 1:a=1540483477*(65535&(a^=255&e.charCodeAt(n)))+((1540483477*(a>>>16)&65535)<<16)}return a=1540483477*(65535&(a^=a>>>13))+((1540483477*(a>>>16)&65535)<<16),(a^=a>>>15)>>>0}}),nl=((e,t,a)=>(a=null==e?{}:i(s(e)),h(r(a,"default",{value:e,enumerable:!0}),e)))(l((e,t)=>{var i=rl(),r=al();t.exports=i,t.exports.murmur3=i,t.exports.murmur2=r})()),sl=class e{constructor(){this.ids=[],this.positions=[],this.indexed=!1}add(e,t,i,r){this.ids.push(ol(e)),this.positions.push(t,i,r)}getPositions(e){if(!this.indexed)throw Error("Trying to get index, but feature positions are not indexed");let t=ol(e),i=0,r=this.ids.length-1;for(;i<r;){let e=i+r>>1;this.ids[e]>=t?r=e:i=e+1}let a=[];for(;this.ids[i]===t;){let e=this.positions[3*i],t=this.positions[3*i+1],r=this.positions[3*i+2];a.push({index:e,start:t,end:r}),i++}return a}static serialize(e,t){let i=new Float64Array(e.ids),r=new Uint32Array(e.positions);return ll(i,r,0,i.length-1),t&&t.push(i.buffer,r.buffer),{ids:i,positions:r}}static deserialize(t){let i=new e;return i.ids=t.ids,i.positions=t.positions,i.indexed=!0,i}};function ol(e){let t=+e;return!isNaN(t)&&t<=2**53-1?t:(0,nl.default)(String(e))}function ll(e,t,i,r){for(;i<r;){let a=e[i+r>>1],n=i-1,s=r+1;for(;;){do{n++}while(e[n]<a);do{s--}while(e[s]>a);if(n>=s)break;hl(e,n,s),hl(t,3*n,3*s),hl(t,3*n+1,3*s+1),hl(t,3*n+2,3*s+2)}s-i<r-s?(ll(e,t,i,s),i=s+1):(ll(e,t,s+1,r),r=s)}}function hl(e,t,i){let r=e[t];e[t]=e[i],e[i]=r}rs("FeaturePositionMap",sl);var ul=class{constructor(e,t){this.gl=e.gl,this.location=t}},cl=class extends ul{constructor(e,t){super(e,t),this.current=0}set(e){this.current!==e&&(this.current=e,this.gl.uniform1i(this.location,e))}},pl=class extends ul{constructor(e,t){super(e,t),this.current=0}set(e){this.current!==e&&(this.current=e,this.gl.uniform1f(this.location,e))}},dl=class extends ul{constructor(e,t){super(e,t),this.current=[0,0]}set(e){(e[0]!==this.current[0]||e[1]!==this.current[1])&&(this.current=e,this.gl.uniform2f(this.location,e[0],e[1]))}},fl=class extends ul{constructor(e,t){super(e,t),this.current=[0,0,0]}set(e){(e[0]!==this.current[0]||e[1]!==this.current[1]||e[2]!==this.current[2])&&(this.current=e,this.gl.uniform3f(this.location,e[0],e[1],e[2]))}},ml=class extends ul{constructor(e,t){super(e,t),this.current=[0,0,0,0]}set(e){(e[0]!==this.current[0]||e[1]!==this.current[1]||e[2]!==this.current[2]||e[3]!==this.current[3])&&(this.current=e,this.gl.uniform4f(this.location,e[0],e[1],e[2],e[3]))}},_l=class extends ul{constructor(e,t){super(e,t),this.current=Si.transparent}set(e){(e.r!==this.current.r||e.g!==this.current.g||e.b!==this.current.b||e.a!==this.current.a)&&(this.current=e,this.gl.uniform4f(this.location,e.r,e.g,e.b,e.a))}},gl=class extends ul{constructor(e,t){super(e,t),this.current=[]}set(e){if(e!=this.current){this.current=e;let t=new Float32Array(4*e.length);for(let i=0;i<e.length;i++)t[4*i]=e[i].r,t[4*i+1]=e[i].g,t[4*i+2]=e[i].b,t[4*i+3]=e[i].a;this.gl.uniform4fv(this.location,t)}}},yl=class extends ul{constructor(e,t){super(e,t),this.current=[]}set(e){if(e!=this.current){this.current=e;let t=new Float32Array(e);this.gl.uniform1fv(this.location,t)}}},vl=/* @__PURE__ */new Float32Array(16),xl=class extends ul{constructor(e,t){super(e,t),this.current=vl}set(e){if(e[12]!==this.current[12]||e[0]!==this.current[0])return this.current=e,void this.gl.uniformMatrix4fv(this.location,!1,e);for(let t=1;t<16;t++)if(e[t]!==this.current[t]){this.current=e,this.gl.uniformMatrix4fv(this.location,!1,e);break}}};function bl(e){return[el(255*e.r,255*e.g),el(255*e.b,255*e.a)]}var wl=class{constructor(e,t,i){this.value=e,this.uniformNames=t.map(e=>`u_${e}`),this.type=i}setUniform(e,t,i){e.set(i.constantOr(this.value))}getBinding(e,t,i){return"color"===this.type?new _l(e,t):new pl(e,t)}},Tl=class{constructor(e,t){this.uniformNames=t.map(e=>`u_${e}`),this.patternFrom=null,this.patternTo=null,this.pixelRatioFrom=1,this.pixelRatioTo=1}setConstantPatternPositions(e,t){this.pixelRatioFrom=t.pixelRatio,this.pixelRatioTo=e.pixelRatio,this.patternFrom=t.tlbr,this.patternTo=e.tlbr}setConstantDashPositions(e,t){this.dashTo=[0,e.y,e.height,e.width],this.dashFrom=[0,t.y,t.height,t.width]}setUniform(e,t,i,r){let a=null;"u_pattern_to"===r?a=this.patternTo:"u_pattern_from"===r?a=this.patternFrom:"u_dasharray_to"===r?a=this.dashTo:"u_dasharray_from"===r?a=this.dashFrom:"u_pixel_ratio_to"===r?a=this.pixelRatioTo:"u_pixel_ratio_from"===r&&(a=this.pixelRatioFrom),null!==a&&e.set(a)}getBinding(e,t,i){return i.startsWith("u_pattern")||i.startsWith("u_dasharray_")?new ml(e,t):new pl(e,t)}},Sl=class{constructor(e,t,i,r){this.expression=e,this.type=i,this.maxValue=0,this.paintVertexAttributes=t.map(e=>({name:`a_${e}`,type:"Float32",components:"color"===i?2:1,offset:0})),this.paintVertexArray=new r}populatePaintArray(e,t,i){let r=this.paintVertexArray.length,a=this.expression.evaluate(new ys(0,i),t,{},i.canonical,[],i.formattedSection);this.paintVertexArray.resize(e),this._setPaintValue(r,e,a)}updatePaintArray(e,t,i,r,a){let n=this.expression.evaluate(new ys(0,a),i,r);this._setPaintValue(e,t,n)}_setPaintValue(e,t,i){if("color"===this.type){let r=bl(i);for(let i=e;i<t;i++)this.paintVertexArray.emplace(i,r[0],r[1])}else{for(let r=e;r<t;r++)this.paintVertexArray.emplace(r,i);this.maxValue=Math.max(this.maxValue,Math.abs(i))}}upload(e){this.paintVertexArray?.arrayBuffer.byteLength&&(this.paintVertexBuffer?.buffer?this.paintVertexBuffer.updateData(this.paintVertexArray):this.paintVertexBuffer=e.createVertexBuffer(this.paintVertexArray,this.paintVertexAttributes,this.expression.isStateDependent))}destroy(){this.paintVertexBuffer&&this.paintVertexBuffer.destroy()}},Pl=class{constructor(e,t,i,r,a,n){this.expression=e,this.uniformNames=t.map(e=>`u_${e}_t`),this.type=i,this.useIntegerZoom=r,this.zoom=a,this.maxValue=0,this.paintVertexAttributes=t.map(e=>({name:`a_${e}`,type:"Float32",components:"color"===i?4:2,offset:0})),this.paintVertexArray=new n}populatePaintArray(e,t,i){let r=this.expression.evaluate(new ys(this.zoom,i),t,{},i.canonical,[],i.formattedSection),a=this.expression.evaluate(new ys(this.zoom+1,i),t,{},i.canonical,[],i.formattedSection),n=this.paintVertexArray.length;this.paintVertexArray.resize(e),this._setPaintValue(n,e,r,a)}updatePaintArray(e,t,i,r,a){let n=this.expression.evaluate(new ys(this.zoom,a),i,r),s=this.expression.evaluate(new ys(this.zoom+1,a),i,r);this._setPaintValue(e,t,n,s)}_setPaintValue(e,t,i,r){if("color"===this.type){let a=bl(i),n=bl(r);for(let i=e;i<t;i++)this.paintVertexArray.emplace(i,a[0],a[1],n[0],n[1])}else{for(let a=e;a<t;a++)this.paintVertexArray.emplace(a,i,r);this.maxValue=Math.max(this.maxValue,Math.abs(i),Math.abs(r))}}upload(e){this.paintVertexArray?.arrayBuffer.byteLength&&(this.paintVertexBuffer?.buffer?this.paintVertexBuffer.updateData(this.paintVertexArray):this.paintVertexBuffer=e.createVertexBuffer(this.paintVertexArray,this.paintVertexAttributes,this.expression.isStateDependent))}destroy(){this.paintVertexBuffer&&this.paintVertexBuffer.destroy()}setUniform(e,t){let i=this.useIntegerZoom?Math.floor(t.zoom):t.zoom,r=ve(this.expression.interpolationFactor(i,this.zoom,this.zoom+1),0,1);e.set(r)}getBinding(e,t,i){return new pl(e,t)}},Il=class{constructor(e,t,i,r,a,n){this.expression=e,this.type=t,this.useIntegerZoom=i,this.zoom=r,this.layerId=n,this.zoomInPaintVertexArray=new a,this.zoomOutPaintVertexArray=new a}populatePaintArray(e,t,i){let r=this.zoomInPaintVertexArray.length;this.zoomInPaintVertexArray.resize(e),this.zoomOutPaintVertexArray.resize(e),this._setPaintValues(r,e,this.getPositionIds(t),i)}updatePaintArray(e,t,i,r,a){this._setPaintValues(e,t,this.getPositionIds(i),a)}_setPaintValues(e,t,i,r){let a=this.getPositions(r);if(!a||!i)return;let n=a[i.min],s=a[i.mid],o=a[i.max];if(n&&s&&o)for(let l=e;l<t;l++)this.emplace(this.zoomInPaintVertexArray,l,n,s),this.emplace(this.zoomOutPaintVertexArray,l,o,s)}upload(e){if(this.zoomInPaintVertexArray?.arrayBuffer.byteLength&&this.zoomOutPaintVertexArray?.arrayBuffer.byteLength){let t=this.getVertexAttributes();this.zoomInPaintVertexBuffer=e.createVertexBuffer(this.zoomInPaintVertexArray,t,this.expression.isStateDependent),this.zoomOutPaintVertexBuffer=e.createVertexBuffer(this.zoomOutPaintVertexArray,t,this.expression.isStateDependent)}}destroy(){this.zoomOutPaintVertexBuffer&&this.zoomOutPaintVertexBuffer.destroy(),this.zoomInPaintVertexBuffer&&this.zoomInPaintVertexBuffer.destroy()}},Ml=class extends Il{getPositions(e){return e.imagePositions}getPositionIds(e){return e.patterns?.[this.layerId]}getVertexAttributes(){return tl.members}emplace(e,t,i,r){e.emplace(t,i.tlbr[0],i.tlbr[1],i.tlbr[2],i.tlbr[3],r.tlbr[0],r.tlbr[1],r.tlbr[2],r.tlbr[3],i.pixelRatio,r.pixelRatio)}},El=class extends Il{getPositions(e){return e.dashPositions}getPositionIds(e){return e.dashes?.[this.layerId]}getVertexAttributes(){return il.members}emplace(e,t,i,r){e.emplace(t,0,i.y,i.height,i.width,0,r.y,r.height,r.width)}},Al=class{constructor(e,t,i){this.binders={},this._buffers=[];let r=[];for(let a in e.paint._values){if(!i(a))continue;let n=e.paint.get(a);if(!(n instanceof Is&&Ia(n.property.specification)))continue;let s=Dl(a,e.type),o=n.value,l=n.property.specification.type,h=n.property.useIntegerZoom,u=n.property.specification["property-type"],c="cross-faded"===u||"cross-faded-data-driven"===u;if("constant"===o.kind)this.binders[a]=c?new Tl(o.value,s):new wl(o.value,s,l),r.push(`/u_${a}`);else if("source"===o.kind||c){let i=zl(a,l,"source");this.binders[a]=c?"line-dasharray"===a?new El(o,l,h,t,i,e.id):new Ml(o,l,h,t,i,e.id):new Sl(o,s,l,i),r.push(`/a_${a}`)}else{let e=zl(a,l,"composite");this.binders[a]=new Pl(o,s,l,h,t,e),r.push(`/z_${a}`)}}this.cacheKey=r.sort().join("")}getMaxValue(e){let t=this.binders[e];return t instanceof Sl||t instanceof Pl?t.maxValue:0}populatePaintArrays(e,t,i){for(let r in this.binders){let a=this.binders[r];(a instanceof Sl||a instanceof Pl||a instanceof Il)&&a.populatePaintArray(e,t,i)}}setConstantPatternPositions(e,t){for(let i in this.binders){let r=this.binders[i];r instanceof Tl&&r.setConstantPatternPositions(e,t)}}setConstantDashPositions(e,t){for(let i in this.binders){let r=this.binders[i];r instanceof Tl&&r.setConstantDashPositions(e,t)}}updatePaintArrays(e,t,i,r,a){let n=!1;for(let s of e){let e=t.getPositions(s.id);for(let t of e){let e=i.feature(t.index);for(let i in this.binders){let o=this.binders[i];(o instanceof Sl||o instanceof Pl||o instanceof Il)&&!0===o.expression.isStateDependent&&(o.expression=r.paint.get(i).value,o.updatePaintArray(t.start,t.end,e,s.state,a),n=!0)}}}return n}defines(){let e=[];for(let t in this.binders){let i=this.binders[t];(i instanceof wl||i instanceof Tl)&&e.push(...i.uniformNames.map(e=>`#define HAS_UNIFORM_${e}`))}return e}getBinderAttributes(){let e=[];for(let t in this.binders){let i=this.binders[t];if(i instanceof Sl||i instanceof Pl)for(let t of i.paintVertexAttributes)e.push(t.name);else if(i instanceof Il){let t=i.getVertexAttributes();for(let i of t)e.push(i.name)}}return e}getBinderUniforms(){let e=[];for(let t in this.binders){let i=this.binders[t];if(i instanceof wl||i instanceof Tl||i instanceof Pl)for(let t of i.uniformNames)e.push(t)}return e}getPaintVertexBuffers(){return this._buffers}getUniforms(e,t){let i=[];for(let r in this.binders){let a=this.binders[r];if(a instanceof wl||a instanceof Tl||a instanceof Pl)for(let n of a.uniformNames)if(t[n]){let s=a.getBinding(e,t[n],n);i.push({name:n,property:r,binding:s})}}return i}setUniforms(e,t,i,r){for(let{name:a,property:n,binding:s}of t)this.binders[n].setUniform(s,r,i.get(n),a)}updatePaintBuffers(e){this._buffers=[];for(let t in this.binders){let i=this.binders[t];if(e&&i instanceof Il){let t=2===e.fromScale?i.zoomInPaintVertexBuffer:i.zoomOutPaintVertexBuffer;t&&this._buffers.push(t)}else(i instanceof Sl||i instanceof Pl)&&i.paintVertexBuffer&&this._buffers.push(i.paintVertexBuffer)}}upload(e){for(let t in this.binders){let i=this.binders[t];(i instanceof Sl||i instanceof Pl||i instanceof Il)&&i.upload(e)}this.updatePaintBuffers()}destroy(){for(let e in this.binders){let t=this.binders[e];(t instanceof Sl||t instanceof Pl||t instanceof Il)&&t.destroy()}}},Cl=class{constructor(e,t,i=()=>!0){this.programConfigurations={};for(let r of e)this.programConfigurations[r.id]=new Al(r,t,i);this.needsUpload=!1,this._featureMap=new sl,this._bufferOffset=0}populatePaintArrays(e,t,i,r){for(let a in this.programConfigurations)this.programConfigurations[a].populatePaintArrays(e,t,r);void 0!==t.id&&this._featureMap.add(t.id,i,this._bufferOffset,e),this._bufferOffset=e,this.needsUpload=!0}updatePaintArrays(e,t,i,r){for(let a of i)this.needsUpload=this.programConfigurations[a.id].updatePaintArrays(e,this._featureMap,t,a,r)||this.needsUpload}get(e){return this.programConfigurations[e]}upload(e){if(this.needsUpload){for(let t in this.programConfigurations)this.programConfigurations[t].upload(e);this.needsUpload=!1}}destroy(){for(let e in this.programConfigurations)this.programConfigurations[e].destroy()}};function Dl(e,t){return{"text-opacity":["opacity"],"icon-opacity":["opacity"],"text-color":["fill_color"],"icon-color":["fill_color"],"text-halo-color":["halo_color"],"icon-halo-color":["halo_color"],"text-halo-blur":["halo_blur"],"icon-halo-blur":["halo_blur"],"text-halo-width":["halo_width"],"icon-halo-width":["halo_width"],"line-gap-width":["gapwidth"],"line-dasharray":["dasharray_to","dasharray_from"],"line-pattern":["pattern_to","pattern_from","pixel_ratio_to","pixel_ratio_from"],"fill-pattern":["pattern_to","pattern_from","pixel_ratio_to","pixel_ratio_from"],"fill-extrusion-pattern":["pattern_to","pattern_from","pixel_ratio_to","pixel_ratio_from"]}[e]||[e.replace(`${t}-`,"").replace(/-/g,"_")]}function zl(e,t,i){let r={color:{source:Qs,composite:yo},number:{source:po,composite:Qs}};return function(e){return{"line-pattern":{source:Vo,composite:Vo},"fill-pattern":{source:Vo,composite:Vo},"fill-extrusion-pattern":{source:Vo,composite:Vo},"line-dasharray":{source:jo,composite:jo}}[e]}(e)?.[i]||r[t][i]}rs("ConstantBinder",wl),rs("CrossFadedConstantBinder",Tl),rs("SourceExpressionBinder",Sl),rs("CrossFadedPatternBinder",Ml),rs("CrossFadedDasharrayBinder",El),rs("CompositeExpressionBinder",Pl),rs("ProgramConfiguration",Al,{omit:["_buffers"]}),rs("ProgramConfigurationSet",Cl);var Rl=-16384;function kl(e){let t=J/e.extent,i=e.loadGeometry();for(let r of i)for(let e of r){let i=Math.round(e.x*t),r=Math.round(e.y*t);e.x=ve(i,Rl,16383),e.y=ve(r,Rl,16383),(i<e.x||i>e.x+1||r<e.y||r>e.y+1)&&Re("Geometry exceeds allowed extent, reduce your vector tile buffer size")}return i}function Ll(e,t){return{type:e.type,id:e.id,properties:e.properties,geometry:t?kl(e):[]}}var Fl=-32768;function Bl(e,t,i,r,a){e.emplaceBack(Fl+8*t+r,Fl+8*i+a)}var Ol,Vl=class{constructor(e){this.zoom=e.zoom,this.overscaling=e.overscaling,this.layers=e.layers,this.layerIds=this.layers.map(e=>e.id),this.index=e.index,this.hasDependencies=!1,this.layoutVertexArray=new ko,this.indexArray=new Ho,this.segments=new Qo,this.programConfigurations=new Cl(e.layers,e.zoom),this.stateDependentLayerIds=this.layers.filter(e=>e.isStateDependent()).map(e=>e.id)}populate(e,t,i){let r=this.layers[0],a=[],n=null,s=!1,o="heatmap"===r.type;if("circle"===r.type){let e=r;n=e.layout.get("circle-sort-key"),s=!n.isConstant(),o||="map"===e.paint.get("circle-pitch-alignment")}let l=o?t.subdivisionGranularity.circle:1,h=new ys(this.zoom),u=this.layers[0]._featureFilter.needGeometry;for(let{feature:c,id:p,index:d,sourceLayerIndex:f}of e){let e=Ll(c,u);if(!this.layers[0]._featureFilter.filter(h,e,i))continue;let t=s?n.evaluate(e,{},i):void 0,r={id:p,properties:c.properties,type:c.type,sourceLayerIndex:f,index:d,geometry:u?e.geometry:kl(c),patterns:{},sortKey:t};a.push(r)}s&&a.sort((e,t)=>e.sortKey-t.sortKey);for(let c of a){let{geometry:r,index:a,sourceLayerIndex:n}=c,s=e[a].feature;this.addFeature(c,r,a,i,l),t.featureIndex.insert(s,r,a,n,this.index)}}update(e,t,i){this.stateDependentLayers.length&&this.programConfigurations.updatePaintArrays(e,t,this.stateDependentLayers,{imagePositions:i})}isEmpty(){return 0===this.layoutVertexArray.length}uploadPending(){return!this.uploaded||this.programConfigurations.needsUpload}upload(e){this.uploaded||(this.layoutVertexBuffer=e.createVertexBuffer(this.layoutVertexArray,Jo),this.indexBuffer=e.createIndexBuffer(this.indexArray)),this.programConfigurations.upload(e),this.uploaded=!0}destroy(){this.layoutVertexBuffer&&(this.layoutVertexBuffer.destroy(),this.indexBuffer.destroy(),this.programConfigurations.destroy(),this.segments.destroy())}addFeature(e,t,i,r,a=1){let n;switch(a){case 1:n=[0,7];break;case 3:n=[0,2,5,7];break;case 5:n=[0,1,3,4,6,7];break;case 7:n=[0,1,2,3,4,5,6,7];break;default:throw Error(`Invalid circle bucket granularity: ${a}; valid values are 1, 3, 5, 7.`)}let s=n.length;for(let o of t)for(let t of o){let i=t.x,r=t.y;if(i<0||i>=8192||r<0||r>=8192)continue;let a=this.segments.prepareSegment(s*s,this.layoutVertexArray,this.indexArray,e.sortKey),o=a.vertexLength;for(let e=0;e<s;e++)for(let t=0;t<s;t++)Bl(this.layoutVertexArray,i,r,n[t],n[e]);for(let e=0;e<s-1;e++)for(let t=0;t<s-1;t++){let i=o+e*s+t,r=o+(e+1)*s+t;this.indexArray.emplaceBack(i,r+1,i+1),this.indexArray.emplaceBack(i,r,r+1)}a.vertexLength+=s*s,a.primitiveLength+=(s-1)*(s-1)*2}this.programConfigurations.populatePaintArrays(this.layoutVertexArray.length,e,i,{imagePositions:{},canonical:r})}};function jl(e,t){for(let i of e)if(Xl(t,i))return!0;for(let i of t)if(Xl(e,i))return!0;return $l(e,t)}function Nl(e,t,i){return!!Xl(e,t)||ql(t,e,i)}function Ul(e,t){if(1===e.length)return Hl(t,e[0]);for(let i of t)for(let t of i)if(Xl(e,t))return!0;for(let i of e)if(Hl(t,i))return!0;for(let i of t)if($l(e,i))return!0;return!1}function Gl(e,t,i){if(e.length>1){if($l(e,t))return!0;for(let r of t)if(ql(r,e,i))return!0}for(let r of e)if(ql(r,t,i))return!0;return!1}function $l(e,t){if(0===e.length||0===t.length)return!1;for(let i=0;i<e.length-1;i++){let r=e[i],a=e[i+1];for(let e=0;e<t.length-1;e++)if(Zl(r,a,t[e],t[e+1]))return!0}return!1}function Zl(e,t,i,r){return ke(e,i,r)!==ke(t,i,r)&&ke(e,t,i)!==ke(e,t,r)}function ql(e,t,i){let r=i*i;if(1===t.length)return e.distSqr(t[0])<r;for(let a=1;a<t.length;a++)if(Wl(e,t[a-1],t[a])<r)return!0;return!1}function Wl(e,t,i){let r=t.distSqr(i);if(0===r)return e.distSqr(t);let a=((e.x-t.x)*(i.x-t.x)+(e.y-t.y)*(i.y-t.y))/r;return a<0?e.distSqr(t):a>1?e.distSqr(i):e.distSqr(i.sub(t)._mult(a)._add(t))}function Hl(e,t){let i,r,a,n=!1;for(let s of e){i=s;for(let e=0,s=i.length-1;e<i.length;s=e++)r=i[e],a=i[s],r.y>t.y!=a.y>t.y&&t.x<(a.x-r.x)*(t.y-r.y)/(a.y-r.y)+r.x&&(n=!n)}return n}function Xl(e,t){let i=!1;for(let r=0,a=e.length-1;r<e.length;a=r++){let n=e[r],s=e[a];n.y>t.y!=s.y>t.y&&t.x<(s.x-n.x)*(t.y-n.y)/(s.y-n.y)+n.x&&(i=!i)}return i}function Yl(e,t,i,r,a){for(let s of e)if(t<=s.x&&i<=s.y&&r>=s.x&&a>=s.y)return!0;let n=[new u(t,i),new u(t,a),new u(r,a),new u(r,i)];if(e.length>2)for(let s of n)if(Xl(e,s))return!0;for(let s=0;s<e.length-1;s++)if(Kl(e[s],e[s+1],n))return!0;return!1}function Kl(e,t,i){let r=i[0],a=i[2];if(e.x<r.x&&t.x<r.x||e.x>a.x&&t.x>a.x||e.y<r.y&&t.y<r.y||e.y>a.y&&t.y>a.y)return!1;let n=ke(e,t,i[0]);return n!==ke(e,t,i[1])||n!==ke(e,t,i[2])||n!==ke(e,t,i[3])}function Jl(e,t,i){let r=t.paint.get(e).value;return"constant"===r.kind?r.value:i.programConfigurations.get(t.id).getMaxValue(e)}function Ql(e){return Math.sqrt(e[0]*e[0]+e[1]*e[1])}function eh(e,t,i,r,a){if(!t[0]&&!t[1])return e;let n=u.convert(t)._mult(a);"viewport"===i&&n._rotate(-r);let s=[];for(let o of e)s.push(o.sub(n));return s}function th(e){let t=[];for(let i=0;i<e.length;i++){let r=e[i],a=t.at(-1);(0===i||a&&!r.equals(a))&&t.push(r)}return t}function ih({queryGeometry:e,size:t},i){return Nl(e,i,t)}function rh({queryGeometry:e,size:t,transform:i,unwrappedTileID:r,getElevation:a},n){return Nl(e,n,t*(i.projectTileCoordinates(n.x,n.y,r,a).signedDistanceFromCamera/i.cameraToCenterDistance))}function ah({queryGeometry:e,size:t,transform:i,unwrappedTileID:r,getElevation:a},n){let s=i.projectTileCoordinates(n.x,n.y,r,a).signedDistanceFromCamera,o=t*(i.cameraToCenterDistance/s);return Nl(e,oh(n,i,r,a),o)}function nh({queryGeometry:e,size:t,transform:i,unwrappedTileID:r,getElevation:a},n){return Nl(e,oh(n,i,r,a),t)}function sh({queryGeometry:e,size:t,transform:i,unwrappedTileID:r,getElevation:a,pitchAlignment:n="map",pitchScale:s="map"},o){let l="map"===n?"map"===s?ih:rh:"map"===s?ah:nh,h={queryGeometry:e,size:t,transform:i,unwrappedTileID:r,getElevation:a};for(let u of o)for(let e of u)if(l(h,e))return!0;return!1}function oh(e,t,i,r){let a=t.projectTileCoordinates(e.x,e.y,i,r).point;return new u((.5*a.x+.5)*t.width,(.5*-a.y+.5)*t.height)}rs("CircleBucket",Vl,{omit:["layers"]});var lh,hh,uh={get paint(){return lh||=new Ls({"circle-radius":new Ds(gt.paint_circle["circle-radius"],"circle-radius"),"circle-color":new Ds(gt.paint_circle["circle-color"],"circle-color"),"circle-blur":new Ds(gt.paint_circle["circle-blur"],"circle-blur"),"circle-opacity":new Ds(gt.paint_circle["circle-opacity"],"circle-opacity"),"circle-translate":new Cs(gt.paint_circle["circle-translate"],"circle-translate"),"circle-translate-anchor":new Cs(gt.paint_circle["circle-translate-anchor"],"circle-translate-anchor"),"circle-pitch-scale":new Cs(gt.paint_circle["circle-pitch-scale"],"circle-pitch-scale"),"circle-pitch-alignment":new Cs(gt.paint_circle["circle-pitch-alignment"],"circle-pitch-alignment"),"circle-stroke-width":new Ds(gt.paint_circle["circle-stroke-width"],"circle-stroke-width"),"circle-stroke-color":new Ds(gt.paint_circle["circle-stroke-color"],"circle-stroke-color"),"circle-stroke-opacity":new Ds(gt.paint_circle["circle-stroke-opacity"],"circle-stroke-opacity")})},get layout(){return Ol||=new Ls({"circle-sort-key":new Ds(gt.layout_circle["circle-sort-key"],"circle-sort-key")})}},ch=class extends Vs{constructor(e,t){super(e,uh,t)}createBucket(e){return new Vl(e)}queryRadius(e){let t=e;return Jl("circle-radius",this,t)+Jl("circle-stroke-width",this,t)+Ql(this.paint.get("circle-translate"))}queryIntersectsFeature({queryGeometry:e,feature:t,featureState:i,geometry:r,transform:a,pixelsToTileUnits:n,unwrappedTileID:s,getElevation:o}){let l,h,u=eh(e,this.paint.get("circle-translate"),this.paint.get("circle-translate-anchor"),-a.bearingInRadians,n),c=this.paint.get("circle-radius").evaluate(t,i)+this.paint.get("circle-stroke-width").evaluate(t,i),p=this.paint.get("circle-pitch-scale"),d=this.paint.get("circle-pitch-alignment");return"map"===d?(l=u,h=c*n):(l=function(e,t,i,r){return e.map(e=>oh(e,t,i,r))}(u,a,s,o),h=c),sh({queryGeometry:l,size:h,transform:a,unwrappedTileID:s,getElevation:o,pitchAlignment:d,pitchScale:p},r)}},ph=class extends Vl{};rs("HeatmapBucket",ph,{omit:["layers"]});var dh={get paint(){return hh||=new Ls({"heatmap-radius":new Ds(gt.paint_heatmap["heatmap-radius"],"heatmap-radius"),"heatmap-weight":new Ds(gt.paint_heatmap["heatmap-weight"],"heatmap-weight"),"heatmap-intensity":new Cs(gt.paint_heatmap["heatmap-intensity"],"heatmap-intensity"),"heatmap-color":new ks(gt.paint_heatmap["heatmap-color"],"heatmap-color"),"heatmap-opacity":new Cs(gt.paint_heatmap["heatmap-opacity"],"heatmap-opacity")})}};function fh(e,{width:t,height:i},r,a){if(a){if(a instanceof Uint8ClampedArray)a=new Uint8Array(a.buffer);else if(a.length!==t*i*r)throw RangeError(`mismatched image size. expected: ${a.length} but got: ${t*i*r}`)}else a=new Uint8Array(t*i*r);return e.width=t,e.height=i,e.data=a,e}function mh(e,{width:t,height:i},r){if(t===e.width&&i===e.height)return;let a=fh({},{width:t,height:i},r);_h(e,a,{x:0,y:0},{x:0,y:0},{width:Math.min(e.width,t),height:Math.min(e.height,i)},r),e.width=t,e.height=i,e.data=a.data}function _h(e,t,i,r,a,n){if(0===a.width||0===a.height)return t;if(a.width>e.width||a.height>e.height||i.x>e.width-a.width||i.y>e.height-a.height)throw RangeError("out of range source coordinates for image copy");if(a.width>t.width||a.height>t.height||r.x>t.width-a.width||r.y>t.height-a.height)throw RangeError("out of range destination coordinates for image copy");let s=e.data,o=t.data;if(s===o)throw Error("srcData equals dstData, so image is already copied");for(let l=0;l<a.height;l++){let h=((i.y+l)*e.width+i.x)*n,u=((r.y+l)*t.width+r.x)*n;for(let e=0;e<a.width*n;e++)o[u+e]=s[h+e]}return t}var gh=class e{constructor(e,t){fh(this,e,1,t)}resize(e){mh(this,e,1)}clone(){return new e({width:this.width,height:this.height},new Uint8Array(this.data))}static copy(e,t,i,r,a){_h(e,t,i,r,a,1)}},yh=class e{constructor(e,t){fh(this,e,4,t)}resize(e){mh(this,e,4)}replace(e,t){t?this.data.set(e):this.data=e instanceof Uint8ClampedArray?new Uint8Array(e.buffer):e}clone(){return new e({width:this.width,height:this.height},new Uint8Array(this.data))}static copy(e,t,i,r,a){_h(e,t,i,r,a,4)}setPixel(e,t,i){let r=4*(e*this.width+t);this.data[r+0]=Math.round(255*i.r/i.a),this.data[r+1]=Math.round(255*i.g/i.a),this.data[r+2]=Math.round(255*i.b/i.a),this.data[r+3]=Math.round(255*i.a)}};function vh(e){let t=new Uint8Array(e.length);for(let i=0;i<e.length;i+=4){let r=e[i+3];t[i+0]=Math.round(e[i+0]*r/255),t[i+1]=Math.round(e[i+1]*r/255),t[i+2]=Math.round(e[i+2]*r/255),t[i+3]=r}return t}function xh(e){let t={},i=e.resolution||256,r=e.clips?e.clips.length:1,a=e.image||new yh({width:i,height:r});if(!function(e){return Math.log(e)/Math.LN2%1==0}(i))throw Error(`width is not a power of 2 - ${i}`);let n=(r,n,s)=>{t[e.evaluationKey]=s;let o=e.expression.evaluate(t);a.setPixel(r/4/i,n/4,o)};if(e.clips)for(let s=0,o=0;s<r;++s,o+=4*i)for(let t=0,r=0;t<i;t++,r+=4){let a=t/(i-1),{start:l,end:h}=e.clips[s];n(o,r,l*(1-a)+h*a)}else for(let s=0,o=0;s<i;s++,o+=4)n(0,o,s/(i-1));return a}rs("AlphaImage",gh),rs("RGBAImage",yh);var bh,wh,Th="big-fb",Sh=class extends Vs{createBucket(e){return new ph(e)}constructor(e,t){super(e,dh,t),this.heatmapFbos=/* @__PURE__ */new Map,this._updateColorRamp()}_handleSpecialPaintPropertyUpdate(e){"heatmap-color"===e&&this._updateColorRamp()}_updateColorRamp(){let e=this._transitionablePaint._values["heatmap-color"].value.expression;this.colorRamp=xh({expression:e,evaluationKey:"heatmapDensity",image:this.colorRamp}),this.colorRampTexture=null}resize(){this.heatmapFbos.has("big-fb")&&this.heatmapFbos.delete(Th)}queryRadius(e){return Jl("heatmap-radius",this,e)}queryIntersectsFeature({queryGeometry:e,feature:t,featureState:i,geometry:r,transform:a,pixelsToTileUnits:n,unwrappedTileID:s,getElevation:o}){return sh({queryGeometry:e,size:this.paint.get("heatmap-radius").evaluate(t,i)*n,transform:a,unwrappedTileID:s,getElevation:o},r)}hasOffscreenPass(){return 0!==this.paint.get("heatmap-opacity")&&!this.isHidden()}},Ph={get paint(){return bh||=new Ls({"hillshade-illumination-direction":new Cs(gt.paint_hillshade["hillshade-illumination-direction"],"hillshade-illumination-direction"),"hillshade-illumination-altitude":new Cs(gt.paint_hillshade["hillshade-illumination-altitude"],"hillshade-illumination-altitude"),"hillshade-illumination-anchor":new Cs(gt.paint_hillshade["hillshade-illumination-anchor"],"hillshade-illumination-anchor"),"hillshade-exaggeration":new Cs(gt.paint_hillshade["hillshade-exaggeration"],"hillshade-exaggeration"),"hillshade-shadow-color":new Cs(gt.paint_hillshade["hillshade-shadow-color"],"hillshade-shadow-color"),"hillshade-highlight-color":new Cs(gt.paint_hillshade["hillshade-highlight-color"],"hillshade-highlight-color"),"hillshade-accent-color":new Cs(gt.paint_hillshade["hillshade-accent-color"],"hillshade-accent-color"),"hillshade-method":new Cs(gt.paint_hillshade["hillshade-method"],"hillshade-method"),resampling:new Cs(gt.paint_hillshade.resampling,"resampling")})}},Ih=class extends Vs{constructor(e,t){super(e,Ph,t),this.recalculate({zoom:0,zoomHistory:{}},void 0)}getIlluminationProperties(){let e=this.paint.get("hillshade-illumination-direction").values,t=this.paint.get("hillshade-illumination-altitude").values,i=this.paint.get("hillshade-highlight-color").values,r=this.paint.get("hillshade-shadow-color").values,a=Math.max(e.length,t.length,i.length,r.length);e=e.concat(Array(a-e.length).fill(e.at(-1))),t=t.concat(Array(a-t.length).fill(t.at(-1))),i=i.concat(Array(a-i.length).fill(i.at(-1))),r=r.concat(Array(a-r.length).fill(r.at(-1)));let n=t.map(Ne);return{directionRadians:e.map(Ne),altitudeRadians:n,shadowColor:r,highlightColor:i}}hasOffscreenPass(){return 0!==this.paint.get("hillshade-exaggeration")&&!this.isHidden()}},Mh={get paint(){return wh||=new Ls({"color-relief-opacity":new Cs(gt["paint_color-relief"]["color-relief-opacity"],"color-relief-opacity"),"color-relief-color":new ks(gt["paint_color-relief"]["color-relief-color"],"color-relief-color"),resampling:new Cs(gt["paint_color-relief"].resampling,"resampling")})}};function Eh(e){return"data"in e}var Ah=class{constructor(e,t,i,r){this.context=e,this.format=i,this.texture=e.gl.createTexture(),this._ownedHandle=this.texture,this.update(t,r)}update(e,t,i){let{width:r,height:a}=e,n=(this.size?.[0]!==r||this.size[1]!==a)&&!i,{context:s}=this,{gl:o}=s;this.useMipmap=!!t?.useMipmap,n&&this.size&&this.format===o.RGBA&&(o.deleteTexture(this.texture),this.texture=o.createTexture(),this._ownedHandle=this.texture,this.filter=void 0,this.wrap=void 0),o.bindTexture(o.TEXTURE_2D,this.texture),s.pixelStoreUnpackFlipY.set(!1),s.pixelStoreUnpack.set(1);let l=this.format===o.RGBA&&!1!==t?.premultiply;if(n)if(this.size=[r,a],this.format===o.RGBA&&r>0&&a>0){let t=this.useMipmap?Math.floor(Math.log2(Math.max(r,a)))+1:1;if(o.texStorage2D(o.TEXTURE_2D,t,o.RGBA8,r,a),Eh(e)){s.pixelStoreUnpackPremultiplyAlpha.set(!1);let{data:t}=e;l&&t&&(t=vh(t)),t&&o.texSubImage2D(o.TEXTURE_2D,0,0,0,r,a,o.RGBA,o.UNSIGNED_BYTE,t)}else s.pixelStoreUnpackPremultiplyAlpha.set(l),o.texSubImage2D(o.TEXTURE_2D,0,0,0,o.RGBA,o.UNSIGNED_BYTE,e)}else Eh(e)?(s.pixelStoreUnpackPremultiplyAlpha.set(!1),this._uploadRawData(e,l,r,a,o)):(s.pixelStoreUnpackPremultiplyAlpha.set(l),this._uploadDomImage(e,o));else{let{x:t,y:n}=i||{x:0,y:0};Eh(e)?(s.pixelStoreUnpackPremultiplyAlpha.set(!1),this._updateRawData(e,l,t,n,r,a,o)):(s.pixelStoreUnpackPremultiplyAlpha.set(l),this._updateDomImage(e,t,n,o))}this.useMipmap&&o.generateMipmap(o.TEXTURE_2D),s.pixelStoreUnpackFlipY.setDefault(),s.pixelStoreUnpack.setDefault(),s.pixelStoreUnpackPremultiplyAlpha.setDefault()}_uploadDomImage(e,t){t.texImage2D(t.TEXTURE_2D,0,this.format,this.format,t.UNSIGNED_BYTE,e)}_uploadRawData(e,t,i,r,a){let{data:n}=e;t&&n&&(n=vh(n)),a.texImage2D(a.TEXTURE_2D,0,this.format,i,r,0,this.format,a.UNSIGNED_BYTE,n)}_updateDomImage(e,t,i,r){r.texSubImage2D(r.TEXTURE_2D,0,t,i,r.RGBA,r.UNSIGNED_BYTE,e)}_updateRawData(e,t,i,r,a,n,s){let{data:o}=e;t&&o&&(o=vh(o)),s.texSubImage2D(s.TEXTURE_2D,0,i,r,a,n,s.RGBA,s.UNSIGNED_BYTE,o)}bind(e,t,i){let{context:r}=this,{gl:a}=r;this.texture!==this._ownedHandle&&(this.texture=this._ownedHandle),a.bindTexture(a.TEXTURE_2D,this.texture),i===a.LINEAR_MIPMAP_NEAREST&&!this.useMipmap&&(i=a.LINEAR),e!==this.filter&&(a.texParameteri(a.TEXTURE_2D,a.TEXTURE_MAG_FILTER,e),a.texParameteri(a.TEXTURE_2D,a.TEXTURE_MIN_FILTER,i||e),this.filter=e),t!==this.wrap&&(a.texParameteri(a.TEXTURE_2D,a.TEXTURE_WRAP_S,t),a.texParameteri(a.TEXTURE_2D,a.TEXTURE_WRAP_T,t),this.wrap=t)}destroy(){let{gl:e}=this.context;e.deleteTexture(this.texture),this.texture=null,this._ownedHandle=null}},Ch=class e{static{this.byteViewCache=/* @__PURE__ */new WeakMap}constructor(t,i,r,a=1,n=1,s=1,o=0){if(this.uid=t,i.height!==i.width)throw RangeError("DEM tiles must be square");if(r&&!["mapbox","terrarium","custom"].includes(r))return void Re(`"${r}" is not a valid encoding type. Valid types include "mapbox", "terrarium" and "custom".`);this.stride=i.height;let l=this.dim=i.height-2;switch(this.data=new Uint32Array(i.data.buffer),e.byteViewCache.set(this,new Uint8Array(this.data.buffer)),r){case"terrarium":this.redFactor=256,this.greenFactor=1,this.blueFactor=1/256,this.baseShift=32768;break;case"custom":this.redFactor=a,this.greenFactor=n,this.blueFactor=s,this.baseShift=o;break;default:this.redFactor=6553.6,this.greenFactor=25.6,this.blueFactor=.1,this.baseShift=1e4}for(let e=0;e<l;e++)this.data[this._idx(-1,e)]=this.data[this._idx(0,e)],this.data[this._idx(l,e)]=this.data[this._idx(l-1,e)],this.data[this._idx(e,-1)]=this.data[this._idx(e,0)],this.data[this._idx(e,l)]=this.data[this._idx(e,l-1)];this.data[this._idx(-1,-1)]=this.data[this._idx(0,0)],this.data[this._idx(l,-1)]=this.data[this._idx(l-1,0)],this.data[this._idx(-1,l)]=this.data[this._idx(0,l-1)],this.data[this._idx(l,l)]=this.data[this._idx(l-1,l-1)];let h=this._getByteView();this.min=2**53-1,this.max=-(2**53-1);for(let e=0;e<l;e++)for(let t=0;t<l;t++){let i=4*this._idx(e,t),r=this._unpackAtIndex(h,i);r>this.max&&(this.max=r),r<this.min&&(this.min=r)}}get(e,t){let i=this._getByteView(),r=4*this._idx(e,t);return this._unpackAtIndex(i,r)}sampleBilinear(e,t){let i=Math.floor(e),r=Math.floor(t);if(i<-1||i>=this.dim||r<-1||r>=this.dim)throw RangeError(`Out of range source coordinates for DEM data. x: ${e}, y: ${t}, dim: ${this.dim}`);let a=this._getByteView(),n=4*((r+1)*this.stride+i+1),s=4*this.stride,o=e-i,l=t-r;return this._unpackAtIndex(a,n)*(1-o)*(1-l)+this._unpackAtIndex(a,n+4)*o*(1-l)+this._unpackAtIndex(a,n+s)*(1-o)*l+this._unpackAtIndex(a,n+s+4)*o*l}getUnpackVector(){return[this.redFactor,this.greenFactor,this.blueFactor,this.baseShift]}_idx(e,t){if(e<-1||e>=this.dim+1||t<-1||t>=this.dim+1)throw RangeError(`Out of range source coordinates for DEM data. x: ${e}, y: ${t}, dim: ${this.dim}`);return(t+1)*this.stride+(e+1)}unpack(e,t,i){return e*this.redFactor+t*this.greenFactor+i*this.blueFactor-this.baseShift}pack(e){return Dh(e,this.getUnpackVector())}getPixels(){return new yh({width:this.stride,height:this.stride},this._getByteView())}backfillBorder(e,t,i){if(this.dim!==e.dim)throw Error("dem dimension mismatch");let r=t*this.dim,a=t*this.dim+this.dim,n=i*this.dim,s=i*this.dim+this.dim;switch(t){case-1:r=a-1;break;case 1:a=r+1}switch(i){case-1:n=s-1;break;case 1:s=n+1}let o=-t*this.dim,l=-i*this.dim;for(let h=n;h<s;h++)for(let t=r;t<a;t++)this.data[this._idx(t,h)]=e.data[this._idx(t+o,h+l)]}_getByteView(){let t=e.byteViewCache.get(this);return t?.buffer!==this.data.buffer&&(t=new Uint8Array(this.data.buffer),e.byteViewCache.set(this,t)),t}_unpackAtIndex(e,t){return this.unpack(e[t],e[t+1],e[t+2])}};function Dh(e,t){let i=t[0],r=t[1],a=t[2],n=t[3],s=Math.min(i,r,a),o=Math.round((e+n)/s);return{r:Math.floor(o*s/i)%256,g:Math.floor(o*s/r)%256,b:Math.floor(o*s/a)%256}}rs("DEMData",Ch);var zh=class extends Vs{constructor(e,t){super(e,Mh,t)}_createColorRamp(e){let t={elevationStops:[],colorStops:[]},i=this._transitionablePaint._values["color-relief-color"].value.expression;if(i instanceof $a&&i._styleExpression.expression instanceof Qi){this.colorRampExpression=i;let e=i._styleExpression.expression;t.elevationStops=e.labels,t.colorStops=[];for(let i of t.elevationStops)t.colorStops.push(e.evaluate({globals:{elevation:i}}))}if(t.elevationStops.length<1&&(t.elevationStops=[0],t.colorStops=[Si.transparent]),t.elevationStops.length<2&&(t.elevationStops.push(t.elevationStops[0]+1),t.colorStops.push(t.colorStops[0])),t.elevationStops.length<=e)return t;let r={elevationStops:[],colorStops:[]},a=(t.elevationStops.length-1)/(e-1);for(let n=0;n<t.elevationStops.length-.5;n+=a)r.elevationStops.push(t.elevationStops[Math.round(n)]),r.colorStops.push(t.colorStops[Math.round(n)]);return Re(`Too many colors in specification of ${this.id} color-relief layer, may not render properly. Max possible colors: ${e}, provided: ${t.elevationStops.length}`),r}_colorRampChanged(){return this.colorRampExpression!=this._transitionablePaint._values["color-relief-color"].value.expression}getColorRampTextures(e,t,i){if(this.colorRampTextures&&!this._colorRampChanged())return this.colorRampTextures;let r=this._createColorRamp(t),a=new yh({width:r.colorStops.length,height:1}),n=new yh({width:r.colorStops.length,height:1});for(let s=0;s<r.elevationStops.length;s++){let e=Dh(r.elevationStops[s],i);n.setPixel(0,s,new Si(e.r/255,e.g/255,e.b/255,1)),a.setPixel(0,s,r.colorStops[s])}return this.colorRampTextures={elevationTexture:new Ah(e,n,e.gl.RGBA),colorTexture:new Ah(e,a,e.gl.RGBA)},this.colorRampTextures}hasOffscreenPass(){return!this.isHidden()&&!!this.colorRampTextures}},Rh=qs([{name:"a_pos",components:2,type:"Int16"}],4),kh=Rh.members;function Lh(e,t,i){let r=i.patternDependencies,a=!1;for(let n of t){let t=n.paint.get(`${e}-pattern`);t.isConstant()||(a=!0);let i=t.constantOr(null);i&&(a=!0,r[i.to]=!0,r[i.from]=!0)}return a}function Fh(e,t,i,r,a){let{zoom:n}=r,s=a.patternDependencies;for(let o of t){let t=o.paint.get(`${e}-pattern`).value;if("constant"!==t.kind){let e=t.evaluate({zoom:n-1},i,{},a.availableImages),r=t.evaluate({zoom:n},i,{},a.availableImages),l=t.evaluate({zoom:n+1},i,{},a.availableImages);e=e?.name?e.name:e,r=r?.name?r.name:r,l=l?.name?l.name:l,s[e]=!0,s[r]=!0,s[l]=!0,i.patterns[o.id]={min:e,mid:r,max:l}}}return i}Rh.size,Rh.alignment;var Bh=/* @__PURE__ */new Set,Oh=!1;function Vh(e,t,i,r,a){let n=null;if(a===function(e,t,i,r){let a=0;for(let n=t,s=i-r;n<i;n+=r)a+=(e[s]-e[n])*(e[n+1]+e[s+1]),s=n;return a}(e,t,i,r)>0)for(let s=t;s<i;s+=r)n=vu(s/r|0,e[s],e[s+1],n);else for(let s=i-r;s>=t;s-=r)n=vu(s/r|0,e[s],e[s+1],n);return n&&fu(n,n.next)&&(xu(n),n=n.next),n}function jh(e,t=e){let i,r=t===e,a=e;do{i=!1,a===a.next||0!==Bh.size&&Bh.has(a)||!fu(a,a.next)&&0!==du(a.prev,a,a.next)?(r||a!==t)&&(a=a.next,i=!r):((r||a===t)&&(t=a.prev),Oh=!0,xu(a),a=a.prev,i=!0)}while(i||a!==t);return t}function Nh(e,t,i,r,a){a&&function(e,t,i,r){let a=e,n=0;do{a.z=hu(a.x,a.y,t,i,r),ru[n++]=a,a=a.next}while(a!==e);!function(e){if(e<=32)for(let t=1;t<e;t++){let e=ru[t],i=e.z,r=t-1;for(;r>=0&&ru[r].z>i;)ru[r+1]=ru[r],r--;ru[r+1]=e}else{nu.length<e&&(nu=new Uint32Array(e),su=new Uint32Array(e),au=Array(e));for(let t=0;t<e;t++)nu[t]=ru[t].z;lu(e,ru,nu,au,su,0),lu(e,au,su,ru,nu,8),lu(e,ru,nu,au,su,16),lu(e,au,su,ru,nu,24)}}(n);let s=null;for(let o=0;o<n;o++){let e=ru[o];e.prevZ=s,s&&(s.nextZ=e),s=e}s.nextZ=null}(e,i,r,a);let n=e,s=!1;for(;e.prev!==e.next;){let o=e.prev,l=e.next;if(du(o,e,l)<0&&(a?Gh(e,i,r,a):Uh(e)))t.push(o.i,e.i,l.i),xu(e),e=l,n=l;else if((e=l)===n){if(Oh=!1,e=jh(e),Oh){n=e;continue}if(!s){n=e=$h(e,t),s=!0;continue}Zh(e,t,i,r,a);break}}}function Uh(e){let t=e.prev,i=e,r=e.next,a=t.x,n=i.x,s=r.x,o=t.y,l=i.y,h=r.y,u=Math.min(a,n,s),c=Math.min(o,l,h),p=Math.max(a,n,s),d=Math.max(o,l,h),f=r.next;for(;f!==t;){if(f.x>=u&&f.x<=p&&f.y>=c&&f.y<=d&&(a!==f.x||o!==f.y)&&cu(a,o,n,l,s,h,f.x,f.y)&&du(f.prev,f,f.next)>=0)return!1;f=f.next}return!0}function Gh(e,t,i,r){let a=e.prev,n=e,s=e.next,o=a.x,l=n.x,h=s.x,u=a.y,c=n.y,p=s.y,d=Math.min(o,l,h),f=Math.min(u,c,p),m=Math.max(o,l,h),_=Math.max(u,c,p),g=hu(d,f,t,i,r),y=hu(m,_,t,i,r),v=e.prevZ;for(;v&&v.z>=g;){if(v.x>=d&&v.x<=m&&v.y>=f&&v.y<=_&&v!==s&&(o!==v.x||u!==v.y)&&cu(o,u,l,c,h,p,v.x,v.y)&&du(v.prev,v,v.next)>=0)return!1;v=v.prevZ}let x=e.nextZ;for(;x&&x.z<=y;){if(x.x>=d&&x.x<=m&&x.y>=f&&x.y<=_&&x!==s&&(o!==x.x||u!==x.y)&&cu(o,u,l,c,h,p,x.x,x.y)&&du(x.prev,x,x.next)>=0)return!1;x=x.nextZ}return!0}function $h(e,t){let i=e,r=!1;do{let a=i.prev,n=i.next.next;mu(a,i,i.next,n,!1)&&gu(a,n)&&gu(n,a)&&(t.push(a.i,i.i,n.i),xu(i),xu(i.next),i=e=n,r=!0),i=i.next}while(i!==e);return r?jh(i):i}function Zh(e,t,i,r,a){let n=e;do{let e=n.next.next;for(;e!==n.prev;){if(n.i!==e.i&&pu(n,e)){let s=yu(n,e);return n=jh(n,n.next),s=jh(s,s.next),Nh(n,t,i,r,a),void Nh(s,t,i,r,a)}e=e.next}n=n.next}while(n!==e)}var qh=!1;function Wh(e,t){return e.x-t.x||e.y-t.y||(e.next.y-e.y)/(e.next.x-e.x)-(t.next.y-t.y)/(t.next.x-t.x)}function Hh(e,t){let i=function(e,t){let i,r=t,a=e.x,n=e.y,s=-1/0;if(fu(e,r))return r;for(let p=0,d=0;p<Yh;p++,d+=4){if(n<Xh[d+1]||n>Xh[d+3]||Xh[d]>a||Xh[d+2]<=s)continue;let t=eu(p);r=tu(p);do{if(r.prev.next===r){if(fu(e,r.next))return r.next;if(n<=r.y&&n>=r.next.y&&r.next.y!==r.y){let e=r.x+(n-r.y)*(r.next.x-r.x)/(r.next.y-r.y);if(e<=a&&e>s&&(s=e,i=r.x<r.next.x?r:r.next,e===a))return i}}r=r.next}while(r!==t)}if(!i)return null;let o=i.x,l=i.y,h=Math.min(n,l),u=Math.max(n,l),c=1/0;for(let p=0,d=0;p<Yh;p++,d+=4){if(Xh[d+2]<o||Xh[d]>a||Xh[d+3]<h||Xh[d+1]>u)continue;let t=eu(p);r=tu(p);do{if(r.prev.next===r&&a>=r.x&&r.x>=o&&a!==r.x&&cu(n<l?a:s,n,o,l,n<l?s:a,n,r.x,r.y)){let t=Math.abs(n-r.y)/(a-r.x);(gu(r,e)||r.y===n&&r.next.y===n&&r.next.x>a)&&(t<c||t===c&&(r.x>i.x||r.x===i.x&&iu(i,r)))&&(i=r,c=t)}r=r.next}while(r!==t)}return i}(e,t);if(!i)return t;let r=yu(i,e);return Qh(i,r.next.next),jh(r,r.next),jh(i,i.next)}var Xh=/* @__PURE__ */new Float64Array,Yh=0,Kh=[],Jh=[];function Qh(e,t){let i=e;do{let e=Yh++;Kh[e]=i;let r=1/0,a=1/0,n=-1/0,s=-1/0,o=0;do{let t=i.next;i.z=e,i.x<r&&(r=i.x),i.x>n&&(n=i.x),i.y<a&&(a=i.y),i.y>s&&(s=i.y),t.x<r&&(r=t.x),t.x>n&&(n=t.x),t.y<a&&(a=t.y),t.y>s&&(s=t.y),i=t}while(++o<16&&i!==t);Jh[e]=i;let l=4*e;Xh[l]=r,Xh[l+1]=a,Xh[l+2]=n,Xh[l+3]=s}while(i!==t)}function eu(e){let t=Jh[e];for(;t.prev.next!==t;)t=t.next;return Jh[e]=t,t}function tu(e){let t=Kh[e];for(;t.prev.next!==t;)t=t.next;return Kh[e]=t,t}function iu(e,t){return du(e.prev,e,t.prev)<0&&du(t.next,e,e.next)<0}var ru=[],au=[],nu=/* @__PURE__ */new Uint32Array,su=/* @__PURE__ */new Uint32Array,ou=/* @__PURE__ */new Uint32Array(256);function lu(e,t,i,r,a,n){ou.fill(0);for(let o=0;o<e;o++)ou[i[o]>>>n&255]++;let s=0;for(let o=0;o<256;o++){let e=ou[o];ou[o]=s,s+=e}for(let o=0;o<e;o++){let e=i[o],s=ou[e>>>n&255]++;r[s]=t[o],a[s]=e}}function hu(e,t,i,r,a){return(e=1431655765&((e=858993459&((e=252645135&((e=16711935&((e=(e-i)*a|0)|e<<8))|e<<4))|e<<2))|e<<1))|(t=1431655765&((t=858993459&((t=252645135&((t=16711935&((t=(t-r)*a|0)|t<<8))|t<<4))|t<<2))|t<<1))<<1}function uu(e){let t=e,i=e;do{(t.x<i.x||t.x===i.x&&t.y<i.y)&&(i=t),t=t.next}while(t!==e);return i}function cu(e,t,i,r,a,n,s,o){return(a-s)*(t-o)>=(e-s)*(n-o)&&(e-s)*(r-o)>=(i-s)*(t-o)&&(i-s)*(n-o)>=(a-s)*(r-o)}function pu(e,t){let i=fu(e,t)&&du(e.prev,e,e.next)>0&&du(t.prev,t,t.next)>0;return e.next.i!==t.i&&(i||gu(e,t)&&gu(t,e)&&(0!==du(e.prev,e,t.prev)||0!==du(e,t.prev,t)))&&!function(e,t){let i=Math.min(e.x,t.x),r=Math.max(e.x,t.x),a=Math.min(e.y,t.y),n=Math.max(e.y,t.y),s=e;do{let o=s.next;if(s.x>r&&o.x>r||s.x<i&&o.x<i||s.y>n&&o.y>n||s.y<a&&o.y<a)s=o;else{if(s.i!==e.i&&o.i!==e.i&&s.i!==t.i&&o.i!==t.i&&mu(s,o,e,t))return!0;s=o}}while(s!==e);return!1}(e,t)&&(i||function(e,t){let i=e,r=!1,a=(e.x+t.x)/2,n=(e.y+t.y)/2;do{let e=i.next;i.y>n!=e.y>n&&a<(e.x-i.x)*(n-i.y)/(e.y-i.y)+i.x&&(r=!r),i=e}while(i!==e);return r}(e,t))}function du(e,t,i){return(t.y-e.y)*(i.x-t.x)-(t.x-e.x)*(i.y-t.y)}function fu(e,t){return e.x===t.x&&e.y===t.y}function mu(e,t,i,r,a=!0){let n=du(e,t,i),s=du(e,t,r),o=du(i,r,e),l=du(i,r,t);return(n>0&&s<0||n<0&&s>0)&&(o>0&&l<0||o<0&&l>0)||!!a&&!!(0===n&&_u(e,i,t)||0===s&&_u(e,r,t)||0===o&&_u(i,e,r)||0===l&&_u(i,t,r))}function _u(e,t,i){return t.x<=Math.max(e.x,i.x)&&t.x>=Math.min(e.x,i.x)&&t.y<=Math.max(e.y,i.y)&&t.y>=Math.min(e.y,i.y)}function gu(e,t){return du(e.prev,e,e.next)<0?du(e,t,e.next)>=0&&du(e,e.prev,t)>=0:du(e,t,e.prev)<0||du(e,e.next,t)<0}function yu(e,t){let i=bu(e.i,e.x,e.y),r=bu(t.i,t.x,t.y),a=e.next,n=t.prev;return e.next=t,t.prev=e,i.next=a,a.prev=i,r.next=i,i.prev=r,n.next=r,r.prev=n,r}function vu(e,t,i,r){let a=bu(e,t,i);return r?(a.next=r.next,a.prev=r,r.next.prev=a,r.next=a):(a.prev=a,a.next=a),a}function xu(e){e.next.prev=e.prev,e.prev.next=e.next,e.prevZ&&(e.prevZ.nextZ=e.nextZ),e.nextZ&&(e.nextZ.prevZ=e.prevZ),qh&&function(e,t){let i=4*e.z;t.x<Xh[i]&&(Xh[i]=t.x),t.y<Xh[i+1]&&(Xh[i+1]=t.y),t.x>Xh[i+2]&&(Xh[i+2]=t.x),t.y>Xh[i+3]&&(Xh[i+3]=t.y)}(e.prev,e.next)}function bu(e,t,i){return{i:e,x:t,y:i,prev:null,next:null,z:0,prevZ:null,nextZ:null}}var wu=class{constructor(e,t){if(t>e)throw Error("Min granularity must not be greater than base granularity.");this._baseZoomGranularity=e,this._minGranularity=t}getGranularityForZoomLevel(e){let t=1<<e;return Math.max(Math.floor(this._baseZoomGranularity/t),this._minGranularity,1)}},Tu=class e{constructor(e){this.fill=e.fill,this.line=e.line,this.tile=e.tile,this.stencil=e.stencil,this.circle=e.circle}static{this.noSubdivision=new e({fill:new wu(0,0),line:new wu(0,0),tile:new wu(0,0),stencil:new wu(0,0),circle:1})}};rs("SubdivisionGranularityExpression",wu),rs("SubdivisionGranularitySetting",Tu);var Su=class{constructor(e,t){this._vertexBuffer=[],this._vertexDictionary=/* @__PURE__ */new Map,this._used=!1,this._granularity=e,this._granularityCellSize=J/e,this._canonical=t}_getKey(e,t){return(e+=32768)<<16|t+32768}_vertexToIndex(e,t){if(e<-32768||t<-32768||e>32767||t>32767)throw Error("Vertex coordinates are out of signed 16 bit integer range.");let i=0|Math.round(e),r=0|Math.round(t),a=this._getKey(i,r);if(this._vertexDictionary.has(a))return this._vertexDictionary.get(a);let n=this._vertexBuffer.length/2;return this._vertexDictionary.set(a,n),this._vertexBuffer.push(i,r),n}_subdivideTrianglesScanline(e){if(this._granularity<2)return function(e,t){let i=[];for(let r=0;r<t.length;r+=3){let a=t[r],n=t[r+1],s=t[r+2],o=e[2*a],l=e[2*a+1],h=e[2*n],u=e[2*n+1],c=e[2*s];(h-o)*(e[2*s+1]-l)-(u-l)*(c-o)>0?(i.push(a),i.push(s),i.push(n)):(i.push(a),i.push(n),i.push(s))}return i}(this._vertexBuffer,e);let t=[],i=e.length;for(let r=0;r<i;r+=3){let i=[e[r+0],e[r+1],e[r+2]],a=[this._vertexBuffer[2*e[r+0]+0],this._vertexBuffer[2*e[r+0]+1],this._vertexBuffer[2*e[r+1]+0],this._vertexBuffer[2*e[r+1]+1],this._vertexBuffer[2*e[r+2]+0],this._vertexBuffer[2*e[r+2]+1]],n=1/0,s=1/0,o=-1/0,l=-1/0;for(let e=0;e<3;e++){let t=a[2*e],i=a[2*e+1];n=Math.min(n,t),o=Math.max(o,t),s=Math.min(s,i),l=Math.max(l,i)}if(n===o||s===l)continue;let h=Math.floor(n/this._granularityCellSize),u=Math.ceil(o/this._granularityCellSize),c=Math.floor(s/this._granularityCellSize),p=Math.ceil(l/this._granularityCellSize);if(h!==u||c!==p)for(let e=c;e<p;e++){let r=this._scanlineGenerateVertexRingForCellRow(e,a,i);Mu(this._vertexBuffer,r,t)}else t.push(...i)}return t}_scanlineGenerateVertexRingForCellRow(e,t,i){let r=e*this._granularityCellSize,a=r+this._granularityCellSize,n=[];for(let s=0;s<3;s++){let e=t[2*s],o=t[2*s+1],l=t[2*(s+1)%6],h=t[(2*(s+1)+1)%6],u=t[2*(s+2)%6],c=t[(2*(s+2)+1)%6],p=l-e,d=h-o,f=0===p,m=0===d,_=(r-o)/d,g=(a-o)/d,y=Math.min(_,g),v=Math.max(_,g);if(!m&&(y>=1||v<=0)||m&&(o<r||o>a)){h>=r&&h<=a&&n.push(i[(s+1)%3]);continue}if(!m&&y>0){let t=e+p*y,i=o+d*y;n.push(this._vertexToIndex(t,i))}let x=e+p*Math.max(y,0),b=e+p*Math.min(v,1);if(f||this._generateIntraEdgeVertices(n,e,o,l,h,x,b),!m&&v<1){let t=e+p*v,i=o+d*v;n.push(this._vertexToIndex(t,i))}(m||h>=r&&h<=a)&&n.push(i[(s+1)%3]),!m&&(h<=r||h>=a)&&this._generateInterEdgeVertices(n,e,o,l,h,u,c,b,r,a)}return n}_generateIntraEdgeVertices(e,t,i,r,a,n,s){let o=r-t,l=a-i,h=0===l,u=h?Math.min(t,r):Math.min(n,s),c=h?Math.max(t,r):Math.max(n,s),p=Math.floor(u/this._granularityCellSize)+1,d=Math.ceil(c/this._granularityCellSize)-1;if(h?t<r:n<s)for(let f=p;f<=d;f++){let r=f*this._granularityCellSize,a=i+l*(r-t)/o;e.push(this._vertexToIndex(r,a))}else for(let f=d;f>=p;f--){let r=f*this._granularityCellSize,a=i+l*(r-t)/o;e.push(this._vertexToIndex(r,a))}}_generateInterEdgeVertices(e,t,i,r,a,n,s,o,l,h){let u=a-i,c=n-r,p=s-a,d=(l-a)/p,f=(h-a)/p,m=Math.min(d,f),_=Math.max(d,f),g=r+c*m,y=Math.floor(Math.min(g,o)/this._granularityCellSize)+1,v=Math.ceil(Math.max(g,o)/this._granularityCellSize)-1,x=o<g,b=0===p;if(b&&(s===l||s===h))return;if(b||m>=1||_<=0){let e=i-s,r=(l-s)/e,a=(h-s)/e,u=n+(t-n)*Math.min(r,a);y=Math.floor(Math.min(u,o)/this._granularityCellSize)+1,v=Math.ceil(Math.max(u,o)/this._granularityCellSize)-1,x=o<u}let w=u>0?h:l;if(x)for(let T=y;T<=v;T++){let t=T*this._granularityCellSize;e.push(this._vertexToIndex(t,w))}else for(let T=v;T>=y;T--){let t=T*this._granularityCellSize;e.push(this._vertexToIndex(t,w))}}_generateOutline(e){let t=[];for(let i of e){let e=Iu(i,this._granularity,!0),r=this._pointArrayToIndices(e),a=[];for(let t=1;t<r.length;t++)a.push(r[t-1]),a.push(r[t]);t.push(a)}return t}_handlePoles(e){let t=!1,i=!1;this._canonical&&(0===this._canonical.y&&(t=!0),this._canonical.y===(1<<this._canonical.z)-1&&(i=!0)),(t||i)&&this._fillPoles(e,t,i)}_ensureNoPoleVertices(){let e=this._vertexBuffer;for(let t=0;t<e.length;t+=2){let i=e[t+1];-32768===i&&(e[t+1]=-32767),32767===i&&(e[t+1]=32766)}}_generatePoleQuad(e,t,i,r,a,n){r>a==(-32768===n)?(e.push(i),e.push(t),e.push(this._vertexToIndex(r,n)),e.push(this._vertexToIndex(a,n)),e.push(i),e.push(this._vertexToIndex(r,n))):(e.push(t),e.push(i),e.push(this._vertexToIndex(r,n)),e.push(i),e.push(this._vertexToIndex(a,n)),e.push(this._vertexToIndex(r,n)))}_fillPoles(e,t,i){let r=this._vertexBuffer,a=J,n=e.length;for(let s=2;s<n;s+=3){let n=e[s-2],o=e[s-1],l=e[s],h=r[2*n],u=r[2*n+1],c=r[2*o],p=r[2*o+1],d=r[2*l],f=r[2*l+1];t&&(0===u&&0===p&&this._generatePoleQuad(e,n,o,h,c,-32768),0===p&&0===f&&this._generatePoleQuad(e,o,l,c,d,-32768),0===f&&0===u&&this._generatePoleQuad(e,l,n,d,h,-32768)),i&&(u===a&&p===a&&this._generatePoleQuad(e,n,o,h,c,32767),p===a&&f===a&&this._generatePoleQuad(e,o,l,c,d,32767),f===a&&u===a&&this._generatePoleQuad(e,l,n,d,h,32767))}}_initializeVertices(e){for(let t=0;t<e.length;t+=2)this._vertexToIndex(e[t],e[t+1])}subdividePolygonInternal(e,t){if(this._used)throw Error("Subdivision: multiple use not allowed.");this._used=!0;let i,{flattened:r,holeIndices:a}=function(e){let t=[],i=[];for(let r of e)if(0!==r.length){r!==e[0]&&t.push(i.length/2);for(let e of r)i.push(e.x),i.push(e.y)}return{flattened:i,holeIndices:t}}(e);this._initializeVertices(r);try{let e=function(e,t,i=2){let r=t&&t.length,a=r?t[0]*i:e.length;Bh.size&&Bh.clear();let n=Vh(e,0,a,i,!0),s=[];if(!n||n.next===n.prev)return s;let o=0,l=0,h=0;if(r&&(n=function(e,t,i,r){let a=[];for(let n=0,s=t.length;n<s;n++){let i=Vh(e,t[n]*r,n<s-1?t[n+1]*r:e.length,r,!1);i===i.next&&Bh.add(i),a.push(uu(i))}a.sort(Wh),function(e,t){let i=Math.ceil((e+2*t)/16)+t+2;Xh.length<4*i&&(Xh=new Float64Array(4*i)),Yh=0}(e.length/r,t.length),Qh(i,i),qh=!0;for(let n=0;n<a.length;n++)i=Hh(a[n],i);return qh=!1,jh(i)}(e,t,n,i)),e.length>80*i){o=e[0],l=e[1];let t=o,r=l;for(let n=i;n<a;n+=i){let i=e[n],a=e[n+1];i<o&&(o=i),a<l&&(l=a),i>t&&(t=i),a>r&&(r=a)}h=Math.max(t-o,r-l),h=0===h?0:32767/h}return Nh(n,s,o,l,h),s}(r,a),t=this._convertIndices(r,e);i=this._subdivideTrianglesScanline(t)}catch(e){console.error(e)}let n=[];return t&&(n=this._generateOutline(e)),this._ensureNoPoleVertices(),this._handlePoles(i),this._granularity>=2&&0===this._canonical?.z&&(i=this._removeTrianglesOutsideTileX(i),n=n.map(e=>this._removeLinesOutsideTileX(e))),{verticesFlattened:this._vertexBuffer,indicesTriangles:i,indicesLineList:n}}_vertexOutsideTileX(e){let t=this._vertexBuffer[2*e];return t<0||t>8192}_removeTrianglesOutsideTileX(e){let t=[];for(let i=0;i<e.length;i+=3)this._vertexOutsideTileX(e[i])||this._vertexOutsideTileX(e[i+1])||this._vertexOutsideTileX(e[i+2])||t.push(e[i],e[i+1],e[i+2]);return t}_removeLinesOutsideTileX(e){let t=[];for(let i=0;i<e.length;i+=2)this._vertexOutsideTileX(e[i])||this._vertexOutsideTileX(e[i+1])||t.push(e[i],e[i+1]);return t}_convertIndices(e,t){let i=[];for(let r of t){let t=e[2*r],a=e[2*r+1];i.push(this._vertexToIndex(t,a))}return i}_pointArrayToIndices(e){let t=[];for(let i of e)t.push(this._vertexToIndex(i.x,i.y));return t}};function Pu(e,t,i,r=!0){return new Su(i,t).subdividePolygonInternal(e,r)}function Iu(e,t,i=!1){if(!e||e.length<1||e.length<2)return[];let r=e[0],a=e[e.length-1],n=i&&(r.x!==a.x||r.y!==a.y);if(t<2)return n?[...e,e[0]]:[...e];let s=Math.floor(J/t),o=[];o.push(new u(e[0].x,e[0].y));let l=e.length,h=n?l:l-1;for(let c=0;c<h;c++){let t=e[c],i=c<l-1?e[c+1]:e[0],r=t.x,a=t.y,n=i.x,h=i.y,p=r!==n,d=a!==h;if(!p&&!d)continue;let f=n-r,m=h-a,_=Math.abs(f),g=Math.abs(m),y=r,v=a;for(;;){let e=f>0?(Math.floor(y/s)+1)*s:(Math.ceil(y/s)-1)*s,t=m>0?(Math.floor(v/s)+1)*s:(Math.ceil(v/s)-1)*s,i=Math.abs(y-e),r=Math.abs(v-t),a=Math.abs(y-n),l=Math.abs(v-h),c=p?i/_:1/0,x=d?r/g:1/0;if((a<=i||!p)&&(l<=r||!d))break;if(c<x&&p||!d){y=e,v+=m*c;let t=new u(y,Math.round(v));(o[o.length-1].x!==t.x||o[o.length-1].y!==t.y)&&o.push(t)}else{y+=f*x,v=t;let e=new u(Math.round(y),v);(o[o.length-1].x!==e.x||o[o.length-1].y!==e.y)&&o.push(e)}}let x=new u(n,h);(o[o.length-1].x!==x.x||o[o.length-1].y!==x.y)&&o.push(x)}return o}function Mu(e,t,i){if(0===t.length)throw Error("Subdivision vertex ring is empty.");let r=0,a=e[2*t[0]];for(let l=1;l<t.length;l++){let i=e[2*t[l]];i<a&&(a=i,r=l)}let n=t.length,s=r,o=(s+1)%n;for(;;){let r=s-1>=0?s-1:n-1,a=(o+1)%n,l=e[2*t[r]],h=e[2*t[r]+1],u=e[2*t[a]],c=e[2*t[a]+1],p=e[2*t[s]],d=e[2*t[s]+1],f=e[2*t[o]],m=e[2*t[o]+1],_=!1;if(l<u)_=!0;else if(l>u)_=!1;else{let e=m-d,t=-(f-p),i=d<m?1:-1;((l-p)*e+(h-d)*t)*i>((u-p)*e+(c-d)*t)*i&&(_=!0)}if(_){let e=t[r],a=t[s],l=t[o];e!==a&&e!==l&&a!==l&&i.push(l,a,e),s--,s<0&&(s=n-1)}else{let e=t[a],r=t[s],l=t[o];e!==r&&e!==l&&r!==l&&i.push(l,r,e),o++,o>=n&&(o=0)}if(r===a)break}}function Eu(e,t,i,r,a,n,s,o,l){let h=a.length/2,u=s&&o&&l;if(h<Qo.MAX_VERTEX_ARRAY_LENGTH){let c,p,d=t.prepareSegment(h,i,r),f=d.vertexLength;for(let e=0;e<n.length;e+=3)r.emplaceBack(f+n[e],f+n[e+1],f+n[e+2]);d.vertexLength+=h,d.primitiveLength+=n.length/3,u&&(p=s.prepareSegment(h,i,o),c=p.vertexLength,p.vertexLength+=h);for(let t=0;t<a.length;t+=2)e(a[t],a[t+1]);if(u)for(let e of l){for(let t=1;t<e.length;t+=2)o.emplaceBack(c+e[t-1],c+e[t]);p.primitiveLength+=e.length/2}}else(function(e,t,i,r,a,n){let s=[];for(let c=0;c<r.length/2;c++)s.push(-1);let o={count:0},l=0,h=e.getOrCreateLatestSegment(t,i),u=h.vertexLength;for(let c=2;c<a.length;c+=3){let p=a[c-2],d=a[c-1],f=a[c],m=s[p]<l,_=s[d]<l,g=s[f]<l,y=+!!m+ +!!_+ +!!g;h.vertexLength+y>Qo.MAX_VERTEX_ARRAY_LENGTH&&(h=e.createNewSegment(t,i),l=o.count,m=!0,_=!0,g=!0,u=0);let v=Au(s,r,n,o,p,m,h),x=Au(s,r,n,o,d,_,h),b=Au(s,r,n,o,f,g,h);i.emplaceBack(u+v-l,u+x-l,u+b-l),h.primitiveLength++}})(t,i,r,a,n,e),u&&function(e,t,i,r,a,n){let s=[];for(let c=0;c<r.length/2;c++)s.push(-1);let o={count:0},l=0,h=e.getOrCreateLatestSegment(t,i),u=h.vertexLength;for(let c of a)for(let a=1;a<c.length;a+=2){let p=c[a-1],d=c[a],f=s[p]<l,m=s[d]<l,_=+!!f+ +!!m;h.vertexLength+_>Qo.MAX_VERTEX_ARRAY_LENGTH&&(h=e.createNewSegment(t,i),l=o.count,f=!0,m=!0,u=0);let g=Au(s,r,n,o,p,f,h),y=Au(s,r,n,o,d,m,h);i.emplaceBack(u+g-l,u+y-l),h.primitiveLength++}}(s,i,o,a,l,e),t.forceNewSegmentOnNextPrepare(),s?.forceNewSegmentOnNextPrepare()}function Au(e,t,i,r,a,n,s){if(n){let n=r.count;return i(t[2*a],t[2*a+1]),e[a]=r.count,r.count++,s.vertexLength++,n}return e[a]}var Cu,Du=class{constructor(e){this.zoom=e.zoom,this.overscaling=e.overscaling,this.layers=e.layers,this.layerIds=this.layers.map(e=>e.id),this.index=e.index,this.hasDependencies=!1,this.patternFeatures=[],this.layoutVertexArray=new Lo,this.indexArray=new Ho,this.indexArray2=new Xo,this.programConfigurations=new Cl(e.layers,e.zoom),this.segments=new Qo,this.segments2=new Qo,this.stateDependentLayerIds=this.layers.filter(e=>e.isStateDependent()).map(e=>e.id)}populate(e,t,i){this.hasDependencies=Lh("fill",this.layers,t);let r=this.layers[0].layout.get("fill-sort-key"),a=!r.isConstant(),n=[],s=new ys(this.zoom),o=this.layers[0]._featureFilter.needGeometry;for(let{feature:l,id:h,index:u,sourceLayerIndex:c}of e){let e=Ll(l,o);if(!this.layers[0]._featureFilter.filter(s,e,i))continue;let p=a?r.evaluate(e,{},i,t.availableImages):void 0,d={id:h,properties:l.properties,type:l.type,sourceLayerIndex:c,index:u,geometry:o?e.geometry:kl(l),patterns:{},sortKey:p};n.push(d)}a&&n.sort((e,t)=>e.sortKey-t.sortKey);for(let l of n){let{geometry:r,index:a,sourceLayerIndex:n}=l;if(this.hasDependencies){let e=Fh("fill",this.layers,l,{zoom:this.zoom},t);this.patternFeatures.push(e)}else this.addFeature(l,r,a,i,{},t.subdivisionGranularity);let s=e[a].feature;t.featureIndex.insert(s,r,a,n,this.index)}}update(e,t,i){this.stateDependentLayers.length&&this.programConfigurations.updatePaintArrays(e,t,this.stateDependentLayers,{imagePositions:i})}addFeatures(e,t,i){for(let r of this.patternFeatures)this.addFeature(r,r.geometry,r.index,t,i,e.subdivisionGranularity)}isEmpty(){return 0===this.layoutVertexArray.length}uploadPending(){return!this.uploaded||this.programConfigurations.needsUpload}upload(e){this.uploaded||(this.layoutVertexBuffer=e.createVertexBuffer(this.layoutVertexArray,kh),this.indexBuffer=e.createIndexBuffer(this.indexArray),this.indexBuffer2=e.createIndexBuffer(this.indexArray2)),this.programConfigurations.upload(e),this.uploaded=!0}destroy(){this.layoutVertexBuffer&&(this.layoutVertexBuffer.destroy(),this.indexBuffer.destroy(),this.indexBuffer2.destroy(),this.programConfigurations.destroy(),this.segments.destroy(),this.segments2.destroy())}addFeature(e,t,i,r,a,n){for(let s of jr(t,500)){let e=Pu(s,r,n.fill.getGranularityForZoomLevel(r.z)),t=this.layoutVertexArray;Eu((e,i)=>{t.emplaceBack(e,i)},this.segments,this.layoutVertexArray,this.indexArray,e.verticesFlattened,e.indicesTriangles,this.segments2,this.indexArray2,e.indicesLineList)}this.programConfigurations.populatePaintArrays(this.layoutVertexArray.length,e,i,{imagePositions:a,canonical:r})}};rs("FillBucket",Du,{omit:["layers","patternFeatures"]});var zu,Ru={get paint(){return zu||=new Ls({"fill-antialias":new Cs(gt.paint_fill["fill-antialias"],"fill-antialias"),"fill-opacity":new Ds(gt.paint_fill["fill-opacity"],"fill-opacity"),"fill-layer-opacity":new Cs(gt.paint_fill["fill-layer-opacity"],"fill-layer-opacity"),"fill-color":new Ds(gt.paint_fill["fill-color"],"fill-color"),"fill-outline-color":new Ds(gt.paint_fill["fill-outline-color"],"fill-outline-color"),"fill-translate":new Cs(gt.paint_fill["fill-translate"],"fill-translate"),"fill-translate-anchor":new Cs(gt.paint_fill["fill-translate-anchor"],"fill-translate-anchor"),"fill-pattern":new zs(gt.paint_fill["fill-pattern"],"fill-pattern")})},get layout(){return Cu||=new Ls({"fill-sort-key":new Ds(gt.layout_fill["fill-sort-key"],"fill-sort-key")})}},ku=class extends Vs{constructor(e,t){super(e,Ru,t)}recalculate(e,t){super.recalculate(e,t);let i=this.paint._values["fill-outline-color"];"constant"===i.value.kind&&void 0===i.value.value&&(this.paint._values["fill-outline-color"]=this.paint._values["fill-color"])}createBucket(e){return new Du(e)}queryRadius(){return Ql(this.paint.get("fill-translate"))}queryIntersectsFeature({queryGeometry:e,geometry:t,transform:i,pixelsToTileUnits:r}){return Ul(eh(e,this.paint.get("fill-translate"),this.paint.get("fill-translate-anchor"),-i.bearingInRadians,r),t)}isTileClipped(){return!0}},Lu=qs([{name:"a_pos",components:2,type:"Int16"},{name:"a_normal_ed",components:4,type:"Int16"}],4),Fu=qs([{name:"a_centroid",components:2,type:"Int16"}],4),Bu=Lu.members;Lu.size,Lu.alignment;var Ou=class e{constructor(){this.minX=1/0,this.maxX=-1/0,this.minY=1/0,this.maxY=-1/0}extend(e){return this.minX=Math.min(this.minX,e.x),this.minY=Math.min(this.minY,e.y),this.maxX=Math.max(this.maxX,e.x),this.maxY=Math.max(this.maxY,e.y),this}expandBy(e){return this.minX-=e,this.minY-=e,this.maxX+=e,this.maxY+=e,(this.minX>this.maxX||this.minY>this.maxY)&&(this.minX=1/0,this.maxX=-1/0,this.minY=1/0,this.maxY=-1/0),this}shrinkBy(e){return this.expandBy(-e)}map(t){let i=new e;return i.extend(t(new u(this.minX,this.minY))),i.extend(t(new u(this.maxX,this.minY))),i.extend(t(new u(this.minX,this.maxY))),i.extend(t(new u(this.maxX,this.maxY))),i}static fromPoints(t){let i=new e;for(let e of t)i.extend(e);return i}contains(e){return e.x>=this.minX&&e.x<=this.maxX&&e.y>=this.minY&&e.y<=this.maxY}empty(){return this.minX>this.maxX}width(){return this.maxX-this.minX}height(){return this.maxY-this.minY}covers(e){return!this.empty()&&!e.empty()&&e.minX>=this.minX&&e.maxX<=this.maxX&&e.minY>=this.minY&&e.maxY<=this.maxY}intersects(e){return!this.empty()&&!e.empty()&&e.minX<=this.maxX&&e.maxX>=this.minX&&e.minY<=this.maxY&&e.maxY>=this.minY}},Vu=Ou.fromPoints([new u(0,0),new u(J,J)]);function ju(e,t){return e.x===t.x&&(e.x<0||e.x>8192)||e.y===t.y&&(e.y<0||e.y>8192)}function Nu(e){return e.every(e=>e.x<0)||e.every(e=>e.x>8192)||e.every(e=>e.y<0)||e.every(e=>e.y>8192)}var Uu=class{constructor(e,t,i,r,a){for(this.properties=Object.create(null),this.extent=i,this.type=0,this.id=void 0,this._pbf=e,this._geometry=-1,this._keys=r,this._values=a;e.pos<t;){let t=e.readVarint();if(8===t)this.id=e.readVarint();else if(18===t){let t=e.readVarint()+e.pos;for(;e.pos<t;){let t=r[e.readVarint()],i=a[e.readVarint()];this.properties[t]=i}}else 24===t?this.type=e.readVarint():(34===t&&(this._geometry=e.pos),e.skip(t))}}loadGeometry(){if(this._geometry<0)throw Error("feature has no geometry");let e=this._pbf;e.pos=this._geometry;let t,i=e.readVarint()+e.pos,r=[],a=1,n=0,s=0,o=0;for(;e.pos<i;){if(n<=0){let t=e.readVarint();if(a=7&t,n=t>>3,0===n)continue}if(n--,1===a)s+=e.readSVarint(),o+=e.readSVarint(),t&&r.push(t),t=[new u(s,o)];else if(2===a)s+=e.readSVarint(),o+=e.readSVarint(),t&&t.push(new u(s,o));else{if(7!==a)throw Error(`unknown command ${a}`);t&&t.push(t[0].clone())}}return t&&r.push(t),r}bbox(){if(this._geometry<0)throw Error("feature has no geometry");let e=this._pbf;e.pos=this._geometry;let t=e.readVarint()+e.pos,i=1,r=0,a=0,n=0,s=1/0,o=-1/0,l=1/0,h=-1/0;for(;e.pos<t;){if(r<=0){let t=e.readVarint();if(i=7&t,r=t>>3,0===r)continue}if(r--,1===i||2===i)a+=e.readSVarint(),n+=e.readSVarint(),a<s&&(s=a),a>o&&(o=a),n<l&&(l=n),n>h&&(h=n);else if(7!==i)throw Error(`unknown command ${i}`)}return[s,l,o,h]}toGeoJSON(e,t,i){let r,a=this.extent*2**i,n=this.extent*e,s=this.extent*t,o=this.loadGeometry();function l(e){return[360*(e.x+n)/a-180,360/Math.PI*Math.atan(Math.exp((1-2*(e.y+s)/a)*Math.PI))-90]}function h(e){return e.map(l)}if(1===this.type){let e=[];for(let i of o)e.push(i[0]);let t=h(e);r=1===e.length?{type:"Point",coordinates:t[0]}:{type:"MultiPoint",coordinates:t}}else if(2===this.type){let e=o.map(h);r=1===e.length?{type:"LineString",coordinates:e[0]}:{type:"MultiLineString",coordinates:e}}else{if(3!==this.type)throw Error("unknown feature type");{let e=Gu(o),t=[];for(let i of e)t.push(i.map(h));r=1===t.length?{type:"Polygon",coordinates:t[0]}:{type:"MultiPolygon",coordinates:t}}}let u={type:"Feature",geometry:r,properties:this.properties};return null!=this.id&&(u.id=this.id),u}};function Gu(e){let t=e.length;if(t<=1)return[e];let i,r,a=[];for(let n=0;n<t;n++){let t=$u(e[n]);0!==t&&(void 0===r&&(r=t<0),r===t<0?(i&&a.push(i),i=[e[n]]):i&&i.push(e[n]))}return i&&a.push(i),a}function $u(e){let t=0;for(let i,r,a=0,n=e.length,s=n-1;a<n;s=a++)i=e[a],r=e[s],t+=(r.x-i.x)*(i.y+r.y);return t}Uu.types=["Unknown","Point","LineString","Polygon"];var Zu=class{constructor(e,t){for(this.version=1,this.name="",this.extent=4096,this.length=0,this._pbf=e,this._keys=[],this._values=[],this._features=[],void 0===t&&(t=e.length);e.pos<t;){let t=e.readVarint();10===t?this.name=e.readString():18===t?(this._features.push(e.pos),e.skip(t)):26===t?this._keys.push(e.readString()):34===t?this._values.push(qu(e)):40===t?this.extent=e.readVarint():120===t?this.version=e.readVarint():e.skip(t)}this.length=this._features.length}feature(e){if(e<0||e>=this._features.length)throw Error("feature index out of bounds");this._pbf.pos=this._features[e];let t=this._pbf.readVarint()+this._pbf.pos;return new Uu(this._pbf,t,this.extent,this._keys,this._values)}};function qu(e){let t=null,i=e.readVarint()+e.pos;for(;e.pos<i;){let i=e.readVarint();t=10===i?e.readString():21===i?e.readFloat():25===i?e.readDouble():32===i?e.readVarint(!0):40===i?e.readVarint():48===i?e.readSVarint():56===i?e.readBoolean():(e.skip(i),null)}if(null==t)throw Error("unknown feature value");return t}var Wu=class{constructor(e,t=e.length){let i=Object.create(null);for(;e.pos<t;){let t=e.readVarint();if(26===t){let t=new Zu(e,e.readVarint()+e.pos);t.length&&(i[t.name]=t)}else e.skip(t)}this.layers=i}},Hu=6371008.8,Xu=class e{constructor(e,t){if(isNaN(e)||isNaN(t))throw Error(`Invalid LngLat object: (${e}, ${t})`);if(this.lng=+e,this.lat=+t,this.lat>90||this.lat<-90)throw Error("Invalid LngLat latitude value: must be between -90 and 90")}wrap(){return new e(xe(this.lng,-180,180),this.lat)}toArray(){return[this.lng,this.lat]}toString(){return`LngLat(${this.lng}, ${this.lat})`}distanceTo(e){let t=Math.PI/180,i=this.lat*t,r=e.lat*t,a=Math.sin(i)*Math.sin(r)+Math.cos(i)*Math.cos(r)*Math.cos((e.lng-this.lng)*t);return Hu*Math.acos(Math.min(a,1))}static convert(t){if(t instanceof e)return t;if(Array.isArray(t)&&(2===t.length||3===t.length))return new e(Number(t[0]),Number(t[1]));if(!Array.isArray(t)&&"object"==typeof t&&t)return new e(Number("lng"in t?t.lng:t.lon),Number(t.lat));throw Error("`LngLatLike` argument must be specified as a LngLat instance, an object {lng: <lng>, lat: <lat>}, an object {lon: <lng>, lat: <lat>}, or an array of [<lng>, <lat>]")}},Yu=2*Math.PI*Hu;function Ku(e){return Yu*Math.cos(e*Math.PI/180)}function Ju(e){return(180+e)/360}function Qu(e){return(180-180/Math.PI*Math.log(Math.tan(Math.PI/4+e*Math.PI/360)))/360}function ec(e,t){return e/Ku(t)}function tc(e){return 360*e-180}function ic(e){let t=180-360*e;return 360/Math.PI*Math.atan(Math.exp(t*Math.PI/180))-90}function rc(e,t){return e*Ku(ic(t))}var ac=class e{constructor(e,t,i=0){this.x=+e,this.y=+t,this.z=+i}static fromLngLat(t,i=0){let r=Xu.convert(t);return new e(Ju(r.lng),Qu(r.lat),ec(i,r.lat))}toLngLat(){return new Xu(tc(this.x),ic(this.y))}toAltitude(){return rc(this.z,this.y)}meterInMercatorCoordinateUnits(){return 1/Yu*function(e){return 1/Math.cos(e*Math.PI/180)}(ic(this.y))}},nc=89.25;function sc(e,t,i){let r=1/(1<<i.z);return new ac(e/J*r+i.x*r,t/J*r+i.y*r)}function oc(e,t){let i=ve(t.lat,-85.051129,qe);return new u(Ju(t.lng)*e,Qu(i)*e)}function lc(e,t){return new ac(t.x/e,t.y/e).toLngLat()}function hc(e){return e.cameraToCenterDistance*Math.min(.85*Math.tan(Ne(90-e.pitch)),Math.tan(Ne(nc-e.pitch)))}function uc(e,t){let i=e.canonical,r=t/Pe(i.z),a=i.x+2**i.z*e.wrap,n=/* @__PURE__ */new Float64Array(16);return _(n),v(n,n,[a*r,i.y*r,0]),x(n,n,[r/J,r/J,1]),n}function cc(e,t,i,r,a){let n=ac.fromLngLat(e,t),s=a*ec(1,e.lat),{x:o,y:l,z:h}=pc(i,r),u=s*-o,c=s*-l,p=s*-h;return new ac(n.x+u,n.y+c,n.z+p)}function pc(e,t){let i=Ne(e),r=Ne(t),a=Math.cos(-i),n=Math.sin(i);return{x:n*Math.sin(r),y:-n*Math.cos(r),z:a}}function dc(e,t,i){if(t<=0||!e||0===e.length)return e;let r=function(e,t){let i=function(e,t,i){return sc(4096,4096,i).toLngLat()}(0,0,t);return e*ac.fromLngLat(i).meterInMercatorCoordinateUnits()*((1<<t.z)*J)}(t,i);return e.map(e=>function(e,t){if(!e||e.length<3)return e;let i=e[0].x===e[e.length-1].x&&e[0].y===e[e.length-1].y,r=i?e.length-1:e.length;if(r<3)return e;let a=[];for(let s=0;s<r;s++){let i=e[(s-1+r)%r],n=e[s],o=e[(s+1)%r];ju(i,n)||ju(n,o)?a.push(n.clone()):fc(a,i,n,o,t)}let n=function(e){let t=[];for(let i of e){let e=i.round(),r=t[t.length-1];(r?.x!==e.x||r?.y!==e.y)&&t.push(e)}for(;t.length>1&&t[0].x===t[t.length-1].x&&t[0].y===t[t.length-1].y;)t.pop();return t}(a);return n.length<3?e:(i&&n.push(n[0].clone()),n)}(e,r))}function fc(e,t,i,r,a){let n=t.sub(i),s=r.sub(i),o=n.mag(),l=s.mag();if(o<1e-6||l<1e-6)return void e.push(i.clone());n._div(o),s._div(l);let h=n.x*s.x+n.y*s.y;if(Math.abs(h)>Math.cos(5*Math.PI/180))return void e.push(i.clone());let u=Math.min(a,.2*o,.2*l),c=i.add(n.mult(u)),p=i.add(s.mult(u)),d=Math.sqrt((1+h)/2),f=i.add(n.add(s)._unit()._mult(u/d)),m=c.sub(f).angleWith(p.sub(f)),_=Math.max(2,Math.ceil(Math.abs(m)/(Math.PI/6)-1e-6));for(let g=0;g<=_;g++)e.push(c.rotateAround(g/_*m,f))}var mc=8192;function _c(e,t,i,r,a,n,s,o){e.emplaceBack(t,i,2*Math.floor(r*mc)+s,a*mc*2,n*mc*2,Math.round(o))}var gc,yc=class{constructor(e){this.zoom=e.zoom,this.overscaling=e.overscaling,this.layers=e.layers,this.layerIds=this.layers.map(e=>e.id),this.index=e.index,this.hasDependencies=!1,this.layoutVertexArray=new Fo,this.centroidVertexArray=new Do,this.indexArray=new Ho,this.programConfigurations=new Cl(e.layers,e.zoom),this.segments=new Qo,this.stateDependentLayerIds=this.layers.filter(e=>e.isStateDependent()).map(e=>e.id)}populate(e,t,i){this.features=[],this.hasDependencies=Lh("fill-extrusion",this.layers,t);let r=new ys(this.zoom),a=this.layers[0],n=a.layout.get("fill-extrusion-rounded-corner-distance"),s=a._featureFilter.needGeometry;for(let{feature:o,id:l,index:h,sourceLayerIndex:u}of e){let e=Ll(o,s);if(!a._featureFilter.filter(r,e,i))continue;let c=s?e.geometry:kl(o),p={id:l,sourceLayerIndex:u,index:h,geometry:n>0?dc(c,n,i):c,properties:o.properties,type:o.type,patterns:{}};this.hasDependencies?this.features.push(Fh("fill-extrusion",this.layers,p,{zoom:this.zoom},t)):this.addFeature(p,p.geometry,h,i,{},t.subdivisionGranularity),t.featureIndex.insert(o,p.geometry,h,u,this.index,!0)}}addFeatures(e,t,i){for(let r of this.features){let{geometry:a}=r;this.addFeature(r,a,r.index,t,i,e.subdivisionGranularity)}}update(e,t,i){this.stateDependentLayers.length&&this.programConfigurations.updatePaintArrays(e,t,this.stateDependentLayers,{imagePositions:i})}isEmpty(){return 0===this.layoutVertexArray.length&&0===this.centroidVertexArray.length}uploadPending(){return!this.uploaded||this.programConfigurations.needsUpload}upload(e){this.uploaded||(this.layoutVertexBuffer=e.createVertexBuffer(this.layoutVertexArray,Bu),this.centroidVertexBuffer=e.createVertexBuffer(this.centroidVertexArray,Fu.members,!0),this.indexBuffer=e.createIndexBuffer(this.indexArray)),this.programConfigurations.upload(e),this.uploaded=!0}destroy(){this.layoutVertexBuffer&&(this.layoutVertexBuffer.destroy(),this.indexBuffer.destroy(),this.programConfigurations.destroy(),this.segments.destroy(),this.centroidVertexBuffer.destroy())}addFeature(e,t,i,r,a,n){let s=this.layers[0],o=s.layout?s.layout.get("fill-extrusion-rounded-corner-distance"):0,l=o>0?dc(t,o,r):t;for(let h of jr(l,500)){let t={x:0,y:0,sampleCount:0},i=this.layoutVertexArray.length;this.processPolygon(t,r,e,h,n);let a=this.layoutVertexArray.length-i,s=Math.floor(t.x/t.sampleCount),o=Math.floor(t.y/t.sampleCount);for(let e=0;e<a;e++)this.centroidVertexArray.emplaceBack(s,o)}this.programConfigurations.populatePaintArrays(this.layoutVertexArray.length,e,i,{imagePositions:a,canonical:r})}processPolygon(e,t,i,r,a){if(r.length<1||Nu(r[0]))return;for(let u of r)0!==u.length&&vc(e,u);let n={segment:this.segments.prepareSegment(4,this.layoutVertexArray,this.indexArray)},s=a.fill.getGranularityForZoomLevel(t.z),o="Polygon"===Uu.types[i.type];for(let u of r){if(0===u.length||Nu(u))continue;let e=Iu(u,s,o);this._generateSideFaces(e,n)}if(!o)return;let l=Pu(r,t,s,!1),h=this.layoutVertexArray;Eu((e,t)=>{_c(h,e,t,0,0,1,1,0)},this.segments,this.layoutVertexArray,this.indexArray,l.verticesFlattened,l.indicesTriangles)}_generateSideFaces(e,t){let i=0;for(let r=1;r<e.length;r++){let a=e[r],n=e[r-1];if(ju(a,n))continue;t.segment.vertexLength+4>Qo.MAX_VERTEX_ARRAY_LENGTH&&(t.segment=this.segments.prepareSegment(4,this.layoutVertexArray,this.indexArray));let s=a.sub(n)._perp()._unit(),o=n.dist(a);i+o>32768&&(i=0),_c(this.layoutVertexArray,a.x,a.y,s.x,s.y,0,0,i),_c(this.layoutVertexArray,a.x,a.y,s.x,s.y,0,1,i),i+=o,_c(this.layoutVertexArray,n.x,n.y,s.x,s.y,0,0,i),_c(this.layoutVertexArray,n.x,n.y,s.x,s.y,0,1,i);let l=t.segment.vertexLength;this.indexArray.emplaceBack(l,l+2,l+1),this.indexArray.emplaceBack(l+1,l+2,l+3),t.segment.vertexLength+=4,t.segment.primitiveLength+=2}}};function vc(e,t){for(let i=0;i<t.length;i++){let r=t[i];(i!==t.length-1||t[0].x!==r.x||t[0].y!==r.y)&&(e.x+=r.x,e.y+=r.y,e.sampleCount++)}}rs("FillExtrusionBucket",yc,{omit:["layers","features"]});var xc,bc={get paint(){return xc||=new Ls({"fill-extrusion-opacity":new Cs(gt["paint_fill-extrusion"]["fill-extrusion-opacity"],"fill-extrusion-opacity"),"fill-extrusion-color":new Ds(gt["paint_fill-extrusion"]["fill-extrusion-color"],"fill-extrusion-color"),"fill-extrusion-translate":new Cs(gt["paint_fill-extrusion"]["fill-extrusion-translate"],"fill-extrusion-translate"),"fill-extrusion-translate-anchor":new Cs(gt["paint_fill-extrusion"]["fill-extrusion-translate-anchor"],"fill-extrusion-translate-anchor"),"fill-extrusion-pattern":new zs(gt["paint_fill-extrusion"]["fill-extrusion-pattern"],"fill-extrusion-pattern"),"fill-extrusion-height":new Ds(gt["paint_fill-extrusion"]["fill-extrusion-height"],"fill-extrusion-height"),"fill-extrusion-base":new Ds(gt["paint_fill-extrusion"]["fill-extrusion-base"],"fill-extrusion-base"),"fill-extrusion-vertical-gradient":new Cs(gt["paint_fill-extrusion"]["fill-extrusion-vertical-gradient"],"fill-extrusion-vertical-gradient")})},get layout(){return gc||=new Ls({"fill-extrusion-rounded-corner-distance":new Cs(gt["layout_fill-extrusion"]["fill-extrusion-rounded-corner-distance"],"fill-extrusion-rounded-corner-distance")})}},wc=class extends Vs{constructor(e,t){super(e,bc,t)}createBucket(e){return new yc(e)}queryRadius(){return Ql(this.paint.get("fill-extrusion-translate"))}is3D(){return!0}queryIntersectsFeature({queryGeometry:e,feature:t,featureState:i,geometry:r,transform:a,pixelsToTileUnits:n,pixelPosMatrix:s}){let o=eh(e,this.paint.get("fill-extrusion-translate"),this.paint.get("fill-extrusion-translate-anchor"),-a.bearingInRadians,n),l=this.paint.get("fill-extrusion-height").evaluate(t,i),h=this.paint.get("fill-extrusion-base").evaluate(t,i),u=Ic(o,s,0),c=Pc(r,h,l,s);return function(e,t,i){let r=1/0;Ul(i,t)&&(r=Sc(i,t[0]));for(let a=0;a<t.length;a++){let n=t[a],s=e[a];for(let e=0;e<n.length-1;e++){let t=n[e],a=n[e+1],o=s[e],l=[t,a,s[e+1],o,t];jl(i,l)&&(r=Math.min(r,Sc(i,l)))}}return r!==1/0&&r}(c[0],c[1],u)}};function Tc(e,t){return e.x*t.x+e.y*t.y}function Sc(e,t){if(1===e.length){let i,r=0,a=t[r++];for(;!i||a.equals(i);)if(i=t[r++],!i)return 1/0;for(;r<t.length;r++){let n=t[r],s=e[0],o=i.sub(a),l=n.sub(a),h=s.sub(a),u=Tc(o,o),c=Tc(o,l),p=Tc(l,l),d=Tc(h,o),f=Tc(h,l),m=u*p-c*c,_=(p*d-c*f)/m,g=(u*f-c*d)/m,y=1-_-g,v=a.z*y+i.z*_+n.z*g;if(isFinite(v))return v}return 1/0}{let e=1/0;for(let i of t)e=Math.min(e,i.z);return e}}function Pc(e,t,i,r){let a=[],n=[],s=r[8]*t,o=r[9]*t,l=r[10]*t,h=r[11]*t,c=r[8]*i,p=r[9]*i,d=r[10]*i,f=r[11]*i;for(let m of e){let e=[],t=[];for(let i of m){let a=i.x,n=i.y,m=r[0]*a+r[4]*n+r[12],_=r[1]*a+r[5]*n+r[13],g=r[2]*a+r[6]*n+r[14],y=r[3]*a+r[7]*n+r[15],v=g+l,x=y+h,b=m+c,w=_+p,T=g+d,S=y+f,P=new u((m+s)/x,(_+o)/x);P.z=v/x,e.push(P);let I=new u(b/S,w/S);I.z=T/S,t.push(I)}a.push(e),n.push(t)}return[a,n]}function Ic(e,t,i){let r=[];for(let a of e){let e=[a.x,a.y,i,1];U(e,e,t),r.push(new u(e[0]/e[3],e[1]/e[3]))}return r}var Mc=qs([{name:"a_pos_normal",components:2,type:"Int16"},{name:"a_data",components:4,type:"Uint8"}],4),Ec=Mc.members;Mc.size,Mc.alignment;var Ac=qs([{name:"a_uv_x",components:1,type:"Float32"},{name:"a_split_index",components:1,type:"Float32"}]),Cc=Ac.members;Ac.size,Ac.alignment;var Dc,zc=Math.cos(Math.PI/180*37.5),Rc=class{constructor(e){this.zoom=e.zoom,this.overscaling=e.overscaling,this.layers=e.layers,this.layerIds=this.layers.map(e=>e.id),this.index=e.index,this.hasDependencies=!1,this.patternFeatures=[],this.lineClipsArray=[],this.gradients={};for(let t of this.layers)this.gradients[t.id]={};this.layoutVertexArray=new Bo,this.layoutVertexArray2=new Oo,this.indexArray=new Ho,this.programConfigurations=new Cl(e.layers,e.zoom),this.segments=new Qo,this.maxLineLength=0,this.stateDependentLayerIds=this.layers.filter(e=>e.isStateDependent()).map(e=>e.id)}populate(e,t,i){this.hasDependencies=Lh("line",this.layers,t)||this.hasLineDasharray(this.layers);let r=this.layers[0].layout.get("line-sort-key"),a=!r.isConstant(),n=[],s=new ys(this.zoom),o=this.layers[0]._featureFilter.needGeometry;for(let{feature:l,id:h,index:u,sourceLayerIndex:c}of e){let e=Ll(l,o);if(!this.layers[0]._featureFilter.filter(s,e,i))continue;let t=a?r.evaluate(e,{},i):void 0,p={id:h,properties:l.properties,type:l.type,sourceLayerIndex:c,index:u,geometry:o?e.geometry:kl(l),patterns:{},dashes:{},sortKey:t};n.push(p)}a&&n.sort((e,t)=>e.sortKey-t.sortKey);for(let l of n){let{geometry:r,index:a,sourceLayerIndex:n}=l;this.hasDependencies?(Lh("line",this.layers,t)?Fh("line",this.layers,l,{zoom:this.zoom},t):this.hasLineDasharray(this.layers)&&this.addLineDashDependencies(this.layers,l,this.zoom,t),this.patternFeatures.push(l)):this.addFeature(l,r,a,i,{},{},t.subdivisionGranularity);let s=e[a].feature;t.featureIndex.insert(s,r,a,n,this.index)}}update(e,t,i,r){this.stateDependentLayers.length&&this.programConfigurations.updatePaintArrays(e,t,this.stateDependentLayers,{imagePositions:i,dashPositions:r})}addFeatures(e,t,i,r){for(let a of this.patternFeatures)this.addFeature(a,a.geometry,a.index,t,i,r,e.subdivisionGranularity)}isEmpty(){return 0===this.layoutVertexArray.length}uploadPending(){return!this.uploaded||this.programConfigurations.needsUpload}upload(e){this.uploaded||(0!==this.layoutVertexArray2.length&&(this.layoutVertexBuffer2=e.createVertexBuffer(this.layoutVertexArray2,Cc)),this.layoutVertexBuffer=e.createVertexBuffer(this.layoutVertexArray,Ec),this.indexBuffer=e.createIndexBuffer(this.indexArray)),this.programConfigurations.upload(e),this.uploaded=!0}destroy(){this.layoutVertexBuffer&&(this.layoutVertexBuffer.destroy(),this.indexBuffer.destroy(),this.programConfigurations.destroy(),this.segments.destroy())}lineFeatureClips(e){if(e.properties&&Object.hasOwn(e.properties,"geojsonvt_clip_start")&&Object.hasOwn(e.properties,"geojsonvt_clip_end"))return{start:+e.properties.geojsonvt_clip_start,end:+e.properties.geojsonvt_clip_end}}addFeature(e,t,i,r,a,n,s){let o=this.layers[0].layout,l=o.get("line-join").evaluate(e,{}),h=o.get("line-cap").evaluate(e,{}),u=o.get("line-miter-limit").evaluate(e,{}),c=o.get("line-round-limit").evaluate(e,{});this.lineClips=this.lineFeatureClips(e);for(let p of t)this.addLine(p,e,l,h,u,c,r,s);this.programConfigurations.populatePaintArrays(this.layoutVertexArray.length,e,i,{imagePositions:a,dashPositions:n,canonical:r})}addLine(e,t,i,r,a,n,s,o){if(this.distance=0,this.scaledDistance=0,this.totalDistance=0,e=Iu(e,s?o.line.getGranularityForZoomLevel(s.z):1),this.lineClips){this.lineClipsArray.push(this.lineClips);for(let t=0;t<e.length-1;t++)this.totalDistance+=e[t].dist(e[t+1]);this.updateScaledDistance(),this.maxLineLength=Math.max(this.maxLineLength,this.totalDistance)}let l="Polygon"===Uu.types[t.type],h=e.length;for(;h>=2&&e[h-1].equals(e[h-2]);)h--;let u=0;for(;u<h-1&&e[u].equals(e[u+1]);)u++;if(h-u<(l?3:2))return;"bevel"===i&&(a=1.05);let c,p,d,f,m,_=this.overscaling<=16?15*J/(512*this.overscaling):0,g=this.segments.prepareSegment(10*h,this.layoutVertexArray,this.indexArray);this.e1=this.e2=-1,l&&(c=e[h-2],m=e[u].sub(c)._unit()._perp());for(let y=u;y<h;y++){if(d=y===h-1?l?e[u+1]:void 0:e[y+1],d&&e[y].equals(d))continue;m&&(f=m),c&&(p=c),c=e[y],m=d?d.sub(c)._unit()._perp():f,f||=m;let t=f.add(m);(0!==t.x||0!==t.y)&&t._unit();let s=f.x*m.x+f.y*m.y,o=t.x*m.x+t.y*m.y,v=0===o?1/0:1/o,x=2*Math.sqrt(2-2*o),b=o<zc&&p&&d,w=f.x*m.y-f.y*m.x>0;if(b&&y>u){let e=c.dist(p);if(e>2*_){let t=c.sub(c.sub(p)._mult(_/e)._round());this.updateDistance(p,t),this.addCurrentVertex(t,f,0,0,g),p=t}}let T=p&&d,S=T?i:l?"butt":r;if(T&&"round"===S&&(v<n?S="miter":v<=2&&(S="fakeround")),"miter"===S&&v>a&&(S="bevel"),"bevel"===S&&(v>2&&(S="flipbevel"),v<a&&(S="miter")),p&&this.updateDistance(p,c),"miter"===S)t._mult(v),this.addCurrentVertex(c,t,0,0,g);else if("flipbevel"===S){if(v>100)t=m.mult(-1);else{let e=v*f.add(m).mag()/f.sub(m).mag();t._perp()._mult(e*(w?-1:1))}this.addCurrentVertex(c,t,0,0,g),this.addCurrentVertex(c,t.mult(-1),0,0,g)}else if("bevel"===S||"fakeround"===S){let e=-Math.sqrt(v*v-1),t=w?e:0,i=w?0:e;if(p&&this.addCurrentVertex(c,f,t,i,g),"fakeround"===S){let e=Math.round(180*x/Math.PI/20);for(let t=1;t<e;t++){let i=t/e;if(.5!==i){let e=i-.5;i+=i*e*(i-1)*((1.0904+s*(s*(3.55645-1.43519*s)-3.2452))*e*e+(.848013+s*(.215638*s-1.06021)))}let r=m.sub(f)._mult(i)._add(f)._unit()._mult(w?-1:1);this.addHalfVertex(c,r.x,r.y,!1,w,0,g)}}d&&this.addCurrentVertex(c,m,-t,-i,g)}else if("butt"===S)this.addCurrentVertex(c,t,0,0,g);else if("square"===S){let e=p?1:-1;this.addCurrentVertex(c,t,e,e,g)}else"round"===S&&(p&&(this.addCurrentVertex(c,f,0,0,g),this.addCurrentVertex(c,f,1,1,g,!0)),d&&(this.addCurrentVertex(c,m,-1,-1,g,!0),this.addCurrentVertex(c,m,0,0,g)));if(b&&y<h-1){let e=c.dist(d);if(e>2*_){let t=c.add(d.sub(c)._mult(_/e)._round());this.updateDistance(c,t),this.addCurrentVertex(t,m,0,0,g),c=t}}}}addCurrentVertex(e,t,i,r,a,n=!1){let s=t.x+t.y*i,o=t.y-t.x*i,l=-t.x+t.y*r,h=-t.y-t.x*r;this.addHalfVertex(e,s,o,n,!1,i,a),this.addHalfVertex(e,l,h,n,!0,-r,a),this.distance>16384&&0===this.totalDistance&&(this.distance=0,this.updateScaledDistance(),this.addCurrentVertex(e,t,i,r,a,n))}addHalfVertex({x:e,y:t},i,r,a,n,s,o){let l=.5*(this.lineClips?32767*this.scaledDistance:this.scaledDistance);if(this.layoutVertexArray.emplaceBack(+!!a+(e<<1),+!!n+(t<<1),Math.round(63*i)+128,Math.round(63*r)+128,1+(0===s?0:s<0?-1:1)|(63&l)<<2,l>>6),this.lineClips){let e=(this.scaledDistance-this.lineClips.start)/(this.lineClips.end-this.lineClips.start);this.layoutVertexArray2.emplaceBack(e,this.lineClipsArray.length)}let h=o.vertexLength++;this.e1>=0&&this.e2>=0&&(this.indexArray.emplaceBack(this.e1,h,this.e2),o.primitiveLength++),n?this.e2=h:this.e1=h}updateScaledDistance(){this.scaledDistance=this.lineClips?this.lineClips.start+(this.lineClips.end-this.lineClips.start)*this.distance/this.totalDistance:this.distance}updateDistance(e,t){this.distance+=e.dist(t),this.updateScaledDistance()}hasLineDasharray(e){for(let t of e){let e=t.paint.get("line-dasharray");if(e&&!e.isConstant())return!0}return!1}addLineDashDependencies(e,t,i,r){for(let a of e){let e=a.paint.get("line-dasharray");if(!e||"constant"===e.value.kind)continue;let n="round"===a.layout.get("line-cap").evaluate(t,{}),s={dasharray:e.value.evaluate({zoom:i-1},t,{}),round:n},o={dasharray:e.value.evaluate({zoom:i},t,{}),round:n},l={dasharray:e.value.evaluate({zoom:i+1},t,{}),round:n},h=`${s.dasharray.join(",")},${s.round}`,u=`${o.dasharray.join(",")},${o.round}`,c=`${l.dasharray.join(",")},${l.round}`;r.dashDependencies[h]=s,r.dashDependencies[u]=o,r.dashDependencies[c]=l,t.dashes[a.id]={min:h,mid:u,max:c}}}};rs("LineBucket",Rc,{omit:["layers","patternFeatures"]});var kc,Lc,Fc={get paint(){return kc||=new Ls({"line-opacity":new Ds(gt.paint_line["line-opacity"],"line-opacity"),"line-layer-opacity":new Cs(gt.paint_line["line-layer-opacity"],"line-layer-opacity"),"line-color":new Ds(gt.paint_line["line-color"],"line-color"),"line-translate":new Cs(gt.paint_line["line-translate"],"line-translate"),"line-translate-anchor":new Cs(gt.paint_line["line-translate-anchor"],"line-translate-anchor"),"line-width":new Ds(gt.paint_line["line-width"],"line-width"),"line-gap-width":new Ds(gt.paint_line["line-gap-width"],"line-gap-width"),"line-offset":new Ds(gt.paint_line["line-offset"],"line-offset"),"line-blur":new Ds(gt.paint_line["line-blur"],"line-blur"),"line-dasharray":new zs(gt.paint_line["line-dasharray"],"line-dasharray"),"line-pattern":new zs(gt.paint_line["line-pattern"],"line-pattern"),"line-gradient":new ks(gt.paint_line["line-gradient"],"line-gradient")})},get layout(){return Dc||=new Ls({"line-cap":new Ds(gt.layout_line["line-cap"],"line-cap"),"line-join":new Ds(gt.layout_line["line-join"],"line-join"),"line-miter-limit":new Ds(gt.layout_line["line-miter-limit"],"line-miter-limit"),"line-round-limit":new Ds(gt.layout_line["line-round-limit"],"line-round-limit"),"line-sort-key":new Ds(gt.layout_line["line-sort-key"],"line-sort-key")})}},Bc=class extends Ds{possiblyEvaluate(e,t){return t=new ys(Math.floor(t.zoom),{now:t.now,fadeDuration:t.fadeDuration,zoomHistory:t.zoomHistory,transition:t.transition}),super.possiblyEvaluate(e,t)}evaluate(e,t,i,r){return t=be({},t,{zoom:Math.floor(t.zoom)}),super.evaluate(e,t,i,r)}},Oc=class extends Vs{constructor(e,t){super(e,Fc,t),this.gradientVersion=0,Lc||((Lc=new Bc(Fc.paint.properties["line-width"].specification,"line-floorwidth")).useIntegerZoom=!0)}_handleSpecialPaintPropertyUpdate(e){if("line-gradient"===e){let e=this.gradientExpression();this.stepInterpolant=!!function(e){return void 0!==e._styleExpression}(e)&&e._styleExpression.expression instanceof Ji,this.gradientVersion=(this.gradientVersion+1)%(2**53-1)}}gradientExpression(){return this._transitionablePaint._values["line-gradient"].value.expression}recalculate(e,t){super.recalculate(e,t),this.paint._values["line-floorwidth"]=Lc.possiblyEvaluate(this._transitioningPaint._values["line-width"].value,e)}createBucket(e){return new Rc(e)}queryRadius(e){let t=e,i=Vc(Jl("line-width",this,t),Jl("line-gap-width",this,t)),r=Jl("line-offset",this,t);return i/2+Math.abs(r)+Ql(this.paint.get("line-translate"))}queryIntersectsFeature({queryGeometry:e,feature:t,featureState:i,geometry:r,transform:a,pixelsToTileUnits:n}){let s=eh(e,this.paint.get("line-translate"),this.paint.get("line-translate-anchor"),-a.bearingInRadians,n),o=n/2*Vc(this.paint.get("line-width").evaluate(t,i),this.paint.get("line-gap-width").evaluate(t,i)),l=this.paint.get("line-offset").evaluate(t,i);return l&&(r=function(e,t){let i=[];for(let r of e){let e=th(r),a=[];for(let i=0;i<e.length;i++){let r=e[i],n=e[i-1],s=e[i+1],o=0===i?new u(0,0):r.sub(n)._unit()._perp(),l=i===e.length-1?new u(0,0):s.sub(r)._unit()._perp(),h=o._add(l)._unit(),c=h.x*l.x+h.y*l.y;0!==c&&h._mult(1/c),a.push(h._mult(t)._add(r))}i.push(a)}return i}(r,l*n)),function(e,t,i){for(let r of t){if(e.length>=3)for(let t of r)if(Xl(e,t))return!0;if(Gl(e,r,i))return!0}return!1}(s,r,o)}isTileClipped(){return!0}};function Vc(e,t){return t>0?t+2*e:e}var jc=qs([{name:"a_pos_offset",components:4,type:"Int16"},{name:"a_data",components:4,type:"Uint16"},{name:"a_pixeloffset",components:4,type:"Int16"}],4),Nc=qs([{name:"a_projected_pos",components:3,type:"Float32"}],4);qs([{name:"a_fade_opacity",components:1,type:"Uint32"}],4);var Uc=qs([{name:"a_placed",components:2,type:"Uint8"},{name:"a_shift",components:2,type:"Float32"},{name:"a_box_real",components:2,type:"Int16"}]);qs([{type:"Int16",name:"anchorPointX"},{type:"Int16",name:"anchorPointY"},{type:"Int16",name:"x1"},{type:"Int16",name:"y1"},{type:"Int16",name:"x2"},{type:"Int16",name:"y2"},{type:"Uint32",name:"featureIndex"},{type:"Uint16",name:"sourceLayerIndex"},{type:"Uint16",name:"bucketIndex"}]);var Gc=qs([{name:"a_pos",components:2,type:"Int16"},{name:"a_anchor_pos",components:2,type:"Int16"},{name:"a_extrude",components:2,type:"Int16"}],4),$c=qs([{name:"a_pos",components:2,type:"Float32"},{name:"a_radius",components:1,type:"Float32"},{name:"a_flags",components:2,type:"Int16"}],4);function Zc(e,t,i){let r=t.layout.get("text-transform").evaluate(i,{});return"uppercase"===r?e=e.toLocaleUpperCase():"lowercase"===r&&(e=e.toLocaleLowerCase()),gs.applyArabicShaping&&(e=gs.applyArabicShaping(e)),e}function qc(e,t,i){for(let r of e.sections)r.text=Zc(r.text,t,i);return e}qs([{name:"triangle",components:3,type:"Uint16"}]),qs([{type:"Int16",name:"anchorX"},{type:"Int16",name:"anchorY"},{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"}]),qs([{type:"Int16",name:"anchorX"},{type:"Int16",name:"anchorY"},{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",name:"textBoxScale"},{type:"Float32",name:"collisionCircleDiameter"},{type:"Uint16",name:"textAnchorOffsetStartIndex"},{type:"Uint16",name:"textAnchorOffsetEndIndex"}]),qs([{type:"Float32",name:"offsetX"}]),qs([{type:"Int16",name:"x"},{type:"Int16",name:"y"},{type:"Int16",name:"tileUnitDistanceFromAnchor"}]),qs([{type:"Uint16",name:"textAnchor"},{type:"Float32",components:2,name:"textOffset"}]);var Wc={"!":"︕","#":"#",$:"$","%":"%","&":"&","(":"︵",")":"︶","*":"*","+":"+",",":"︐","-":"︲",".":"・","/":"/",":":"︓",";":"︔","<":"︿","=":"=",">":"﹀","?":"︖","@":"@","[":"﹇","\\":"\","]":"﹈","^":"^",_:"︳","`":"`","{":"︷","|":"―","}":"︸","~":"~","¢":"¢","£":"£","¥":"¥","¦":"¦","¬":"¬","¯":" ̄","–":"︲","—":"︱","‘":"﹃","’":"﹄","“":"﹁","”":"﹂","…":"︙","⋯":"︙","‧":"・","₩":"₩","、":"︑","。":"︒","〈":"︿","〉":"﹀","《":"︽","》":"︾","「":"﹁","」":"﹂","『":"﹃","』":"﹄","【":"︻","】":"︼","〔":"︹","〕":"︺","〖":"︗","〗":"︘","!":"︕","(":"︵",")":"︶",",":"︐","-":"︲",".":"・",":":"︓",";":"︔","<":"︿",">":"﹀","?":"︖","[":"﹇","]":"﹈","_":"︳","{":"︷","|":"―","}":"︸","⦅":"︵","⦆":"︶","。":"︒","「":"﹁","」":"﹂"},Hc=4294967296,Xc=typeof TextDecoder>"u"?null:new TextDecoder("utf-8"),Yc=class{constructor(e){this.buf=ArrayBuffer.isView(e)?e:new Uint8Array(e),this.dataView=new DataView(this.buf.buffer,this.buf.byteOffset,this.buf.byteLength),this.pos=0,this.type=0,this._valueStart=-1,this.length=this.buf.length}readFields(e,t,i=this.length){let r;for(;r=this.nextField(i);)e(r,t,this);return t}readMessage(e,t){return this.readFields(e,t,this.readVarint()+this.pos)}readFixed32(){let e=this.dataView.getUint32(this.pos,!0);return this.pos+=4,e}readSFixed32(){let e=this.dataView.getInt32(this.pos,!0);return this.pos+=4,e}readFixed64(){let e=this.dataView.getUint32(this.pos,!0)+this.dataView.getUint32(this.pos+4,!0)*Hc;return this.pos+=8,e}readSFixed64(){let e=this.dataView.getUint32(this.pos,!0)+this.dataView.getInt32(this.pos+4,!0)*Hc;return this.pos+=8,e}readFloat(){let e=this.dataView.getFloat32(this.pos,!0);return this.pos+=4,e}readDouble(){let e=this.dataView.getFloat64(this.pos,!0);return this.pos+=8,e}readVarint(e){let t=this.buf,i=t[this.pos++];if(i<128)return i;let r,a=127&i;return r=t[this.pos++],a|=(127&r)<<7,r<128||(r=t[this.pos++],a|=(127&r)<<14,r<128)||(r=t[this.pos++],a|=(127&r)<<21,r<128)?a:(r=t[this.pos],a|=(15&r)<<28,function(e,t,i){let r,a,n=i.buf;if(a=n[i.pos++],r=(112&a)>>4,a<128||(a=n[i.pos++],r|=(127&a)<<3,a<128)||(a=n[i.pos++],r|=(127&a)<<10,a<128)||(a=n[i.pos++],r|=(127&a)<<17,a<128)||(a=n[i.pos++],r|=(127&a)<<24,a<128)||(a=n[i.pos++],r|=(1&a)<<31,a<128))return function(e,t,i){return i?4294967296*t+(e>>>0):4294967296*(t>>>0)+(e>>>0)}(e,r,t);throw Error("Expected varint not more than 10 bytes")}(a,e,this))}readSVarint(){let e=this.readVarint();return e%2==1?(e+1)/-2:e/2}readBoolean(){return!!this.readVarint()}readString(){let e=this.readVarint()+this.pos,t=this.pos;return this.pos=e,e-t>=12&&Xc?Xc.decode(this.buf.subarray(t,e)):function(e,t,i){let r="",a=t;for(;a<i;){let t,n,s,o=e[a],l=null,h=o>239?4:o>223?3:o>191?2:1;if(a+h>i)break;1===h?o<128&&(l=o):2===h?(t=e[a+1],128==(192&t)&&(l=(31&o)<<6|63&t,l<=127&&(l=null))):3===h?(t=e[a+1],n=e[a+2],128==(192&t)&&128==(192&n)&&(l=(15&o)<<12|(63&t)<<6|63&n,(l<=2047||l>=55296&&l<=57343)&&(l=null))):4===h&&(t=e[a+1],n=e[a+2],s=e[a+3],128==(192&t)&&128==(192&n)&&128==(192&s)&&(l=(15&o)<<18|(63&t)<<12|(63&n)<<6|63&s,(l<=65535||l>=1114112)&&(l=null))),null===l?(l=65533,h=1):l>65535&&(l-=65536,r+=String.fromCharCode(l>>>10&1023|55296),l=56320|1023&l),r+=String.fromCharCode(l),a+=h}return r}(this.buf,t,e)}readBytes(){let e=this.readVarint()+this.pos,t=this.buf.subarray(this.pos,e);return this.pos=e,t}readPackedVarint(e=[],t){let i=this.readPackedEnd();for(;this.pos<i;)e.push(this.readVarint(t));return e}readPackedSVarint(e=[]){let t=this.readPackedEnd();for(;this.pos<t;)e.push(this.readSVarint());return e}readPackedBoolean(e=[]){let t=this.readPackedEnd();for(;this.pos<t;)e.push(this.readBoolean());return e}readPackedFloat(e=[]){let t=this.readPackedEnd();for(;this.pos<t;)e.push(this.readFloat());return e}readPackedDouble(e=[]){let t=this.readPackedEnd();for(;this.pos<t;)e.push(this.readDouble());return e}readPackedFixed32(e=[]){let t=this.readPackedEnd();for(;this.pos<t;)e.push(this.readFixed32());return e}readPackedSFixed32(e=[]){let t=this.readPackedEnd();for(;this.pos<t;)e.push(this.readSFixed32());return e}readPackedFixed64(e=[]){let t=this.readPackedEnd();for(;this.pos<t;)e.push(this.readFixed64());return e}readPackedSFixed64(e=[]){let t=this.readPackedEnd();for(;this.pos<t;)e.push(this.readSFixed64());return e}readPackedEnd(){return 2===this.type?this.readVarint()+this.pos:this.pos+1}nextField(e=this.length){if(this.pos===this._valueStart&&this.skip(this.type),this.pos>=e)return 0;let t=this.readVarint();return this.type=7&t,this._valueStart=this.pos,t>>>3}skip(e){let t=7&e;if(0===t)for(;this.buf[this.pos++]>127;);else if(2===t)this.pos=this.readVarint()+this.pos;else if(5===t)this.pos+=4;else{if(1!==t)throw Error(`Unimplemented type: ${t}`);this.pos+=8}}};function Kc(e,t,i){1===e&&i.readMessage(Jc,t)}function Jc(e,t,i){if(3===e){let{id:e,bitmap:r,width:a,height:n,left:s,top:o,advance:l}=i.readMessage(Qc,{});t.push({id:e,bitmap:new gh({width:a+6,height:n+6},r),metrics:{width:a,height:n,left:s,top:o,advance:l}})}}function Qc(e,t,i){1===e?t.id=i.readVarint():2===e?t.bitmap=i.readBytes():3===e?t.width=i.readVarint():4===e?t.height=i.readVarint():5===e?t.left=i.readSVarint():6===e?t.top=i.readSVarint():7===e&&(t.advance=i.readVarint())}function ep(e){return"function"==typeof e?.renderWithWebGL}function tp(e){let{userImage:t}=e;return!(!t?.render||!t.render()||(ep(t.data)||e.data.replace(new Uint8Array(t.data.buffer)),0))}function ip(e){let t=0,i=0;for(let s of e)t+=s.w*s.h,i=Math.max(i,s.w);e.sort((e,t)=>t.h-e.h);let r=[{x:0,y:0,w:Math.max(Math.ceil(Math.sqrt(t/.95)),i),h:1/0}],a=0,n=0;for(let s of e)for(let e=r.length-1;e>=0;e--){let t=r[e];if(!(s.w>t.w||s.h>t.h)){if(s.x=t.x,s.y=t.y,n=Math.max(n,s.y+s.h),a=Math.max(a,s.x+s.w),s.w===t.w&&s.h===t.h){let t=r.pop();t&&e<r.length&&(r[e]=t)}else s.h===t.h?(t.x+=s.w,t.w-=s.w):s.w===t.w?(t.y+=s.h,t.h-=s.h):(r.push({x:t.x+s.w,y:t.y,w:t.w-s.w,h:s.h}),t.y+=s.h,t.h-=s.h);break}}return{w:a,h:n,fill:t/(a*n)||0}}var rp=class{constructor(e,{pixelRatio:t,version:i,isWebGLImage:r=!1,stretchX:a,stretchY:n,content:s,textFitWidth:o,textFitHeight:l}){this.paddedRect=e,this.pixelRatio=t,this.stretchX=a,this.stretchY=n,this.content=s,this.version=i,this.needsFirstWebGLRender=r,this.textFitWidth=o,this.textFitHeight=l}get tl(){return[this.paddedRect.x+1,this.paddedRect.y+1]}get br(){return[this.paddedRect.x+this.paddedRect.w-1,this.paddedRect.y+this.paddedRect.h-1]}get tlbr(){return this.tl.concat(this.br)}get displaySize(){return[(this.paddedRect.w-2)/this.pixelRatio,(this.paddedRect.h-2)/this.pixelRatio]}};rs("ImagePosition",rp),rs("ImageAtlas",class{constructor(e,t){let i={},r={};this.haveRenderCallbacks=[],this.patchedUpdateVersion=-1;let a=[];this.addImages(e,i,a),this.addImages(t,r,a);let{w:n,h:s}=ip(a),o=new yh({width:n||1,height:s||1});for(let l in e){let t=e[l];if(t.isWebGLImage)continue;let r=i[l].paddedRect;yh.copy(t.data,o,{x:0,y:0},{x:r.x+1,y:r.y+1},t.data)}for(let l in t){let e=t[l],i=r[l].paddedRect,a=i.x+1,n=i.y+1,s=e.data.width,h=e.data.height;yh.copy(e.data,o,{x:0,y:0},{x:a,y:n},e.data),yh.copy(e.data,o,{x:0,y:h-1},{x:a,y:n-1},{width:s,height:1}),yh.copy(e.data,o,{x:0,y:0},{x:a,y:n+h},{width:s,height:1}),yh.copy(e.data,o,{x:s-1,y:0},{x:a-1,y:n},{width:1,height:h}),yh.copy(e.data,o,{x:0,y:0},{x:a+s,y:n},{width:1,height:h})}this.image=o,this.iconPositions=i,this.patternPositions=r}addImages(e,t,i){for(let r in e){let a=e[r],n={x:0,y:0,w:a.data.width+2,h:a.data.height+2};i.push(n),t[r]=new rp(n,a),a.hasRenderCallback&&this.haveRenderCallbacks.push(r)}}patchUpdatedImages(e,t){if(e.dispatchRenderCallbacks(this.haveRenderCallbacks),this.patchedUpdateVersion!==e.updateVersion){this.patchedUpdateVersion=e.updateVersion;for(let i in this.iconPositions)this.patchUpdatedImage(this.iconPositions[i],e.getImage(i),t);for(let i in this.patternPositions)this.patchUpdatedImage(this.patternPositions[i],e.getImage(i),t)}}patchUpdatedImage(e,t,i){if(!e||!t||!e.needsFirstWebGLRender&&e.version===t.version)return;e.needsFirstWebGLRender=!1,e.version=t.version;let[r,a]=e.tl,n=t.userImage?.data;if(!ep(n))return void i.update(t.data,void 0,{x:r,y:a});let{width:s,height:o}=t.data;i.context.setCustomLayerDefaults(),n.renderWithWebGL({gl:i.context.gl,texture:i.texture,x:r,y:a,width:s,height:o}),i.context.setDirty()}});var ap=function(e){return e[e.none=0]="none",e[e.horizontal=1]="horizontal",e[e.vertical=2]="vertical",e[e.horizontalOnly=3]="horizontalOnly",e}(ap||{});function np(e){let t=.5,i=.5;switch(e){case"right":case"top-right":case"bottom-right":t=1;break;case"left":case"top-left":case"bottom-left":t=0}switch(e){case"bottom":case"bottom-right":case"bottom-left":i=1;break;case"top":case"top-right":case"top-left":i=0}return{horizontalAlign:t,verticalAlign:i}}function sp(e,t){let{expression:i}=t;if("constant"===i.kind)return{kind:"constant",layoutSize:i.evaluate(new ys(e+1))};if("source"===i.kind)return{kind:"source"};{let{zoomStops:t,interpolationType:r}=i,a=0;for(;a<t.length&&t[a]<=e;)a++;a=Math.max(0,a-1);let n=a;for(;n<t.length&&t[n]<e+1;)n++;n=Math.min(t.length-1,n);let s=t[a],o=t[n];return"composite"===i.kind?{kind:"composite",minZoom:s,maxZoom:o,interpolationType:r}:{kind:"camera",minZoom:s,maxZoom:o,minSize:i.evaluate(new ys(s)),maxSize:i.evaluate(new ys(o)),interpolationType:r}}}function op(e,{uSize:t,uSizeT:i},{lowerSize:r,upperSize:a}){return"source"===e.kind?r/128:"composite"===e.kind?tr.number(r/128,a/128,i):t}function lp(e,t){let i=0,r=0;if("constant"===e.kind)r=e.layoutSize;else if("source"!==e.kind){let{interpolationType:a,minZoom:n,maxZoom:s}=e,o=a?ve(Qi.interpolationFactor(a,t,n,s),0,1):0;"camera"===e.kind?r=tr.number(e.minSize,e.maxSize,o):i=o}return{uSizeT:i,uSize:r}}function hp(e,t,i){let r="never",a=e.get(t);return a?r=a:e.get(i)&&(r="always"),r}var up=[{name:"a_fade_opacity",components:1,type:"Uint8",offset:0}];function cp(e,t,i,r,a,n,s,o,l,h,u,c,p){let d=o?Math.min(32640,Math.round(o[0])):0,f=o?Math.min(32640,Math.round(o[1])):0;e.emplaceBack(t,i,Math.round(32*r),Math.round(32*a),n,s,+!!l+(d<<1),f,16*h,16*u,256*c,256*p)}function pp(e,t,i){e.emplaceBack(t.x,t.y,i),e.emplaceBack(t.x,t.y,i),e.emplaceBack(t.x,t.y,i),e.emplaceBack(t.x,t.y,i)}function dp(e){for(let t of e.sections)if(_s(t.text))return!0;return!1}var fp=class{constructor(e){this.layoutVertexArray=new No,this.indexArray=new Ho,this.programConfigurations=e,this.segments=new Qo,this.dynamicLayoutVertexArray=new Uo,this.opacityVertexArray=new Go,this.hasVisibleVertices=!1,this.placedSymbolArray=new wo}isEmpty(){return 0===this.layoutVertexArray.length&&0===this.indexArray.length&&0===this.dynamicLayoutVertexArray.length&&0===this.opacityVertexArray.length}upload(e,t,i,r){this.isEmpty()||(i&&(this.layoutVertexBuffer=e.createVertexBuffer(this.layoutVertexArray,jc.members),this.indexBuffer=e.createIndexBuffer(this.indexArray,t),this.dynamicLayoutVertexBuffer=e.createVertexBuffer(this.dynamicLayoutVertexArray,Nc.members,!0),this.opacityVertexBuffer=e.createVertexBuffer(this.opacityVertexArray,up,!0),this.opacityVertexBuffer.itemSize=1),(i||r)&&this.programConfigurations.upload(e))}destroy(){this.layoutVertexBuffer&&(this.layoutVertexBuffer.destroy(),this.indexBuffer.destroy(),this.programConfigurations.destroy(),this.segments.destroy(),this.dynamicLayoutVertexBuffer.destroy(),this.opacityVertexBuffer.destroy())}};rs("SymbolBuffers",fp);var mp=class{constructor(e,t,i){this.layoutVertexArray=new e,this.layoutAttributes=t,this.indexArray=new i,this.segments=new Qo,this.collisionVertexArray=new qo}upload(e){this.layoutVertexBuffer=e.createVertexBuffer(this.layoutVertexArray,this.layoutAttributes),this.indexBuffer=e.createIndexBuffer(this.indexArray),this.collisionVertexBuffer=e.createVertexBuffer(this.collisionVertexArray,Uc.members,!0)}destroy(){this.layoutVertexBuffer&&(this.layoutVertexBuffer.destroy(),this.indexBuffer.destroy(),this.segments.destroy(),this.collisionVertexBuffer.destroy())}};rs("CollisionBuffers",mp);var _p,gp=class{constructor(e){this.collisionBoxArray=e.collisionBoxArray,this.zoom=e.zoom,this.overscaling=e.overscaling,this.layers=e.layers,this.layerIds=this.layers.map(e=>e.id),this.index=e.index,this.pixelRatio=e.pixelRatio,this.sourceLayerIndex=e.sourceLayerIndex,this.hasDependencies=!1,this.hasRTLText=!1,this.sortKeyRanges=[],this.collisionCircleArray=[];let t=this.layers[0]._unevaluatedLayout._values;this.textSizeData=sp(this.zoom,t["text-size"]),this.iconSizeData=sp(this.zoom,t["icon-size"]);let i=this.layers[0].layout,r=i.get("symbol-sort-key"),a=i.get("symbol-z-order");this.canOverlap="never"!==hp(i,"text-overlap","text-allow-overlap")||"never"!==hp(i,"icon-overlap","icon-allow-overlap")||i.get("text-ignore-placement")||i.get("icon-ignore-placement"),this.sortFeaturesByKey="viewport-y"!==a&&!r.isConstant();let n="viewport-y"===a||"auto"===a&&!this.sortFeaturesByKey;this.sortFeaturesByY=n&&this.canOverlap,"point"===i.get("symbol-placement")&&(this.writingModes=i.get("text-writing-mode").map(e=>ap[e])),this.stateDependentLayerIds=this.layers.filter(e=>e.isStateDependent()).map(e=>e.id),this.sourceID=e.sourceID}createArrays(){this.text=new fp(new Cl(this.layers,this.zoom,e=>e.startsWith("text"))),this.icon=new fp(new Cl(this.layers,this.zoom,e=>e.startsWith("icon"))),this.glyphOffsetArray=new Po,this.lineVertexArray=new Io,this.symbolInstances=new So,this.textAnchorOffsets=new Eo}calculateGlyphDependencies(e,t,i,r,a){for(let n of e)if(t[n.codePointAt(0)]=!0,(i||r)&&a){let e=Wc[n];e&&(t[e.codePointAt(0)]=!0)}}populate(e,t,i){let r=this.layers[0],a=r.layout,n=a.get("text-font"),s=a.get("text-field"),o=a.get("icon-image"),l=("constant"!==s.value.kind||s.value.value instanceof Ei&&!s.value.value.isEmpty()||s.value.value.toString().length>0)&&("constant"!==n.value.kind||n.value.value.length>0),h="constant"!==o.value.kind||!!o.value.value||Object.keys(o.parameters).length>0,u=a.get("symbol-sort-key");if(this.features=[],!l&&!h)return;let c=t.iconDependencies,p=t.glyphDependencies,d=t.availableImages,f=new ys(this.zoom);for(let{feature:m,id:_,index:g,sourceLayerIndex:y}of e){let e,t,s=r._featureFilter.needGeometry,o=Ll(m,s);if(!r._featureFilter.filter(f,o,i))continue;if(s||(o.geometry=kl(m)),l){let t=r.getValueAndResolveTokens("text-field",o,i,d),a=Ei.factory(t);this.hasRTLText||=dp(a),(!this.hasRTLText||"unavailable"===gs.getRTLTextPluginStatus()||this.hasRTLText&&gs.isParsed())&&(e=qc(a,r,o))}if(h){let e=r.getValueAndResolveTokens("icon-image",o,i,d);t=e instanceof Li?e:Li.fromString(e)}if(!e&&!t)continue;let v=this.sortFeaturesByKey?u.evaluate(o,{},i):void 0,x={id:_,text:e,icon:t,index:g,sourceLayerIndex:y,geometry:o.geometry,properties:m.properties,type:Uu.types[m.type],sortKey:v};if(this.features.push(x),t&&(c[t.name]=!0),e){let t=n.evaluate(o,{},i).join(","),r="viewport"!==a.get("text-rotation-alignment")&&"point"!==a.get("symbol-placement");this.allowVerticalPlacement=this.writingModes?.includes(2);for(let i of e.sections)if(i.image)c[i.image.name]=!0;else{let a=cs(e.toString()),n=i.fontStack||t;p[n]||={},this.calculateGlyphDependencies(i.text,p[n],r,this.allowVerticalPlacement,a)}}}"line"===a.get("symbol-placement")&&(this.features=function(e){let t={},i={},r=[],a=0;function n(t){r.push(e[t]),a++}function s(e,t,a){let n=i[e];return delete i[e],i[t]=n,r[n].geometry[0].pop(),r[n].geometry[0]=r[n].geometry[0].concat(a[0]),n}function o(e,i,a){let n=t[i];return delete t[i],t[e]=n,r[n].geometry[0].shift(),r[n].geometry[0]=a[0].concat(r[n].geometry[0]),n}function l(e,t,i){let r=i?t[0][t[0].length-1]:t[0][0];return`${e}:${r.x}:${r.y}`}for(let h=0;h<e.length;h++){let u=e[h],c=u.geometry,p=u.text?u.text.toString():null;if(!p){n(h);continue}let d=l(p,c),f=l(p,c,!0);if(d in i&&f in t&&i[d]!==t[f]){let e=o(d,f,c),a=s(d,f,r[e].geometry);delete t[d],delete i[f],i[l(p,r[a].geometry,!0)]=a,r[e].geometry=null}else d in i?s(d,f,c):f in t?o(d,f,c):(n(h),t[d]=a-1,i[f]=a-1)}return r.filter(e=>e.geometry)}(this.features)),this.sortFeaturesByKey&&this.features.sort((e,t)=>e.sortKey-t.sortKey)}update(e,t,i){this.stateDependentLayers.length&&(this.text.programConfigurations.updatePaintArrays(e,t,this.layers,{imagePositions:i}),this.icon.programConfigurations.updatePaintArrays(e,t,this.layers,{imagePositions:i}))}isEmpty(){return 0===this.symbolInstances.length&&!this.hasRTLText}uploadPending(){return!this.uploaded||this.text.programConfigurations.needsUpload||this.icon.programConfigurations.needsUpload}upload(e){!this.uploaded&&this.hasDebugData()&&(this.textCollisionBox.upload(e),this.iconCollisionBox.upload(e)),this.text.upload(e,this.sortFeaturesByY,!this.uploaded,this.text.programConfigurations.needsUpload),this.icon.upload(e,this.sortFeaturesByY,!this.uploaded,this.icon.programConfigurations.needsUpload),this.uploaded=!0}destroyDebugData(){this.textCollisionBox.destroy(),this.iconCollisionBox.destroy()}destroy(){this.text.destroy(),this.icon.destroy(),this.hasDebugData()&&this.destroyDebugData()}addToLineVertexArray(e,t){let i=this.lineVertexArray.length;if(void 0!==e.segment){let i=e.dist(t[e.segment+1]),r=e.dist(t[e.segment]),a={};for(let n=e.segment+1;n<t.length;n++)a[n]={x:t[n].x,y:t[n].y,tileUnitDistanceFromAnchor:i},n<t.length-1&&(i+=t[n+1].dist(t[n]));for(let n=e.segment||0;n>=0;n--)a[n]={x:t[n].x,y:t[n].y,tileUnitDistanceFromAnchor:r},n>0&&(r+=t[n-1].dist(t[n]));for(let e=0;e<t.length;e++){let t=a[e];this.lineVertexArray.emplaceBack(t.x,t.y,t.tileUnitDistanceFromAnchor)}}return{lineStartIndex:i,lineLength:this.lineVertexArray.length-i}}addSymbols(e,t,i,r,a,n,s,o,l,h,u,c){let p=e.indexArray,d=e.layoutVertexArray,f=e.segments.prepareSegment(4*t.length,d,p,this.canOverlap?n.sortKey:void 0),m=this.glyphOffsetArray.length,_=f.vertexLength,g=this.allowVerticalPlacement&&2===s?Math.PI/2:0,y=n.text&&n.text.sections;for(let v=0;v<t.length;v++){let{tl:r,tr:a,bl:s,br:l,tex:h,pixelOffsetTL:u,pixelOffsetBR:m,minFontScaleX:_,minFontScaleY:x,glyphOffset:b,isSDF:w,sectionIndex:T}=t[v],S=f.vertexLength,P=b[1];cp(d,o.x,o.y,r.x,P+r.y,h.x,h.y,i,w,u.x,u.y,_,x),cp(d,o.x,o.y,a.x,P+a.y,h.x+h.w,h.y,i,w,m.x,u.y,_,x),cp(d,o.x,o.y,s.x,P+s.y,h.x,h.y+h.h,i,w,u.x,m.y,_,x),cp(d,o.x,o.y,l.x,P+l.y,h.x+h.w,h.y+h.h,i,w,m.x,m.y,_,x),pp(e.dynamicLayoutVertexArray,o,g),p.emplaceBack(S,S+2,S+1),p.emplaceBack(S+1,S+2,S+3),f.vertexLength+=4,f.primitiveLength+=2,this.glyphOffsetArray.emplaceBack(b[0]),(v===t.length-1||T!==t[v+1].sectionIndex)&&e.programConfigurations.populatePaintArrays(d.length,n,n.index,{imagePositions:{},canonical:c,formattedSection:y?.[T]})}e.placedSymbolArray.emplaceBack(o.x,o.y,m,this.glyphOffsetArray.length-m,_,l,h,o.segment,i?i[0]:0,i?i[1]:0,r[0],r[1],s,0,!1,0,u)}_addCollisionDebugVertex(e,t,i,r,a,n){return t.emplaceBack(0,0),e.emplaceBack(i.x,i.y,r,a,Math.round(n.x),Math.round(n.y))}addCollisionDebugVertices(e,t,i,r,a,n,s){let o=a.segments.prepareSegment(4,a.layoutVertexArray,a.indexArray),l=o.vertexLength,h=a.layoutVertexArray,c=a.collisionVertexArray,p=s.anchorX,d=s.anchorY;this._addCollisionDebugVertex(h,c,n,p,d,new u(e,t)),this._addCollisionDebugVertex(h,c,n,p,d,new u(i,t)),this._addCollisionDebugVertex(h,c,n,p,d,new u(i,r)),this._addCollisionDebugVertex(h,c,n,p,d,new u(e,r)),o.vertexLength+=4;let f=a.indexArray;f.emplaceBack(l,l+1),f.emplaceBack(l+1,l+2),f.emplaceBack(l+2,l+3),f.emplaceBack(l+3,l),o.primitiveLength+=4}addDebugCollisionBoxes(e,t,i,r){for(let a=e;a<t;a++){let e=this.collisionBoxArray.get(a),t=e.x1,n=e.y1,s=e.x2,o=e.y2;this.addCollisionDebugVertices(t,n,s,o,r?this.textCollisionBox:this.iconCollisionBox,e.anchorPoint,i)}}generateCollisionDebugBuffers(){this.hasDebugData()&&this.destroyDebugData(),this.textCollisionBox=new mp($o,Gc.members,Xo),this.iconCollisionBox=new mp($o,Gc.members,Xo);for(let e=0;e<this.symbolInstances.length;e++){let t=this.symbolInstances.get(e);this.addDebugCollisionBoxes(t.textBoxStartIndex,t.textBoxEndIndex,t,!0),this.addDebugCollisionBoxes(t.verticalTextBoxStartIndex,t.verticalTextBoxEndIndex,t,!0),this.addDebugCollisionBoxes(t.iconBoxStartIndex,t.iconBoxEndIndex,t,!1),this.addDebugCollisionBoxes(t.verticalIconBoxStartIndex,t.verticalIconBoxEndIndex,t,!1)}}_deserializeCollisionBoxesForSymbol(e,t,i,r,a,n,s,o,l){let h={};for(let u=t;u<i;u++){let t=e.get(u);h.textBox={x1:t.x1,y1:t.y1,x2:t.x2,y2:t.y2,anchorPointX:t.anchorPointX,anchorPointY:t.anchorPointY},h.textFeatureIndex=t.featureIndex;break}for(let u=r;u<a;u++){let t=e.get(u);h.verticalTextBox={x1:t.x1,y1:t.y1,x2:t.x2,y2:t.y2,anchorPointX:t.anchorPointX,anchorPointY:t.anchorPointY},h.verticalTextFeatureIndex=t.featureIndex;break}for(let u=n;u<s;u++){let t=e.get(u);h.iconBox={x1:t.x1,y1:t.y1,x2:t.x2,y2:t.y2,anchorPointX:t.anchorPointX,anchorPointY:t.anchorPointY},h.iconFeatureIndex=t.featureIndex;break}for(let u=o;u<l;u++){let t=e.get(u);h.verticalIconBox={x1:t.x1,y1:t.y1,x2:t.x2,y2:t.y2,anchorPointX:t.anchorPointX,anchorPointY:t.anchorPointY},h.verticalIconFeatureIndex=t.featureIndex;break}return h}deserializeCollisionBoxes(e){this.collisionArrays=[];for(let t=0;t<this.symbolInstances.length;t++){let i=this.symbolInstances.get(t);this.collisionArrays.push(this._deserializeCollisionBoxesForSymbol(e,i.textBoxStartIndex,i.textBoxEndIndex,i.verticalTextBoxStartIndex,i.verticalTextBoxEndIndex,i.iconBoxStartIndex,i.iconBoxEndIndex,i.verticalIconBoxStartIndex,i.verticalIconBoxEndIndex))}}hasTextData(){return this.text.segments.get().length>0}hasIconData(){return this.icon.segments.get().length>0}hasDebugData(){return this.textCollisionBox&&this.iconCollisionBox}hasTextCollisionBoxData(){return this.hasDebugData()&&this.textCollisionBox.segments.get().length>0}hasIconCollisionBoxData(){return this.hasDebugData()&&this.iconCollisionBox.segments.get().length>0}addIndicesForPlacedSymbol(e,t){let i=e.placedSymbolArray.get(t),r=i.vertexStartIndex+4*i.numGlyphs;for(let a=i.vertexStartIndex;a<r;a+=4)e.indexArray.emplaceBack(a,a+2,a+1),e.indexArray.emplaceBack(a+1,a+2,a+3)}getSortedSymbolIndexes(e){if(this.sortedAngle===e&&void 0!==this.symbolInstanceIndexes)return this.symbolInstanceIndexes;let t=Math.sin(e),i=Math.cos(e),r=[],a=[],n=[];for(let s=0;s<this.symbolInstances.length;++s){n.push(s);let e=this.symbolInstances.get(s);r.push(0|Math.round(t*e.anchorX+i*e.anchorY)),a.push(e.featureIndex)}return n.sort((e,t)=>r[e]-r[t]||a[t]-a[e]),n}addToSortKeyRanges(e,t){let i=this.sortKeyRanges[this.sortKeyRanges.length-1];i?.sortKey===t?i.symbolInstanceEnd=e+1:this.sortKeyRanges.push({sortKey:t,symbolInstanceStart:e,symbolInstanceEnd:e+1})}sortFeatures(e){if(this.sortFeaturesByY&&this.sortedAngle!==e&&!(this.text.segments.get().length>1||this.icon.segments.get().length>1)){this.symbolInstanceIndexes=this.getSortedSymbolIndexes(e),this.sortedAngle=e,this.text.indexArray.clear(),this.icon.indexArray.clear(),this.featureSortOrder=[];for(let e of this.symbolInstanceIndexes){let t=this.symbolInstances.get(e);this.featureSortOrder.push(t.featureIndex);let i=[t.rightJustifiedTextSymbolIndex,t.centerJustifiedTextSymbolIndex,t.leftJustifiedTextSymbolIndex];for(let e=0;e<i.length;e++){let t=i[e];t>=0&&i.indexOf(t)===e&&this.addIndicesForPlacedSymbol(this.text,t)}t.verticalPlacedTextSymbolIndex>=0&&this.addIndicesForPlacedSymbol(this.text,t.verticalPlacedTextSymbolIndex),t.placedIconSymbolIndex>=0&&this.addIndicesForPlacedSymbol(this.icon,t.placedIconSymbolIndex),t.verticalPlacedIconSymbolIndex>=0&&this.addIndicesForPlacedSymbol(this.icon,t.verticalPlacedIconSymbolIndex)}this.text.indexBuffer&&this.text.indexBuffer.updateData(this.text.indexArray),this.icon.indexBuffer&&this.icon.indexBuffer.updateData(this.icon.indexArray)}}};rs("SymbolBucket",gp,{omit:["layers","collisionBoxArray","features","compareText"]}),gp.MAX_GLYPHS=65535,gp.addDynamicAttributes=pp;var yp,vp={get paint(){return yp||=new Ls({"icon-opacity":new Ds(gt.paint_symbol["icon-opacity"],"icon-opacity"),"icon-color":new Ds(gt.paint_symbol["icon-color"],"icon-color"),"icon-halo-color":new Ds(gt.paint_symbol["icon-halo-color"],"icon-halo-color"),"icon-halo-width":new Ds(gt.paint_symbol["icon-halo-width"],"icon-halo-width"),"icon-halo-blur":new Ds(gt.paint_symbol["icon-halo-blur"],"icon-halo-blur"),"icon-translate":new Cs(gt.paint_symbol["icon-translate"],"icon-translate"),"icon-translate-anchor":new Cs(gt.paint_symbol["icon-translate-anchor"],"icon-translate-anchor"),"text-opacity":new Ds(gt.paint_symbol["text-opacity"],"text-opacity"),"text-color":new Ds(gt.paint_symbol["text-color"],"text-color",{runtimeType:Bt,getOverride:e=>e.textColor,hasOverride:e=>!!e.textColor}),"text-halo-color":new Ds(gt.paint_symbol["text-halo-color"],"text-halo-color"),"text-halo-width":new Ds(gt.paint_symbol["text-halo-width"],"text-halo-width"),"text-halo-blur":new Ds(gt.paint_symbol["text-halo-blur"],"text-halo-blur"),"text-translate":new Cs(gt.paint_symbol["text-translate"],"text-translate"),"text-translate-anchor":new Cs(gt.paint_symbol["text-translate-anchor"],"text-translate-anchor")})},get layout(){return _p||=new Ls({"symbol-placement":new Cs(gt.layout_symbol["symbol-placement"],"symbol-placement"),"symbol-spacing":new Cs(gt.layout_symbol["symbol-spacing"],"symbol-spacing"),"symbol-avoid-edges":new Cs(gt.layout_symbol["symbol-avoid-edges"],"symbol-avoid-edges"),"symbol-sort-key":new Ds(gt.layout_symbol["symbol-sort-key"],"symbol-sort-key"),"symbol-z-order":new Cs(gt.layout_symbol["symbol-z-order"],"symbol-z-order"),"icon-allow-overlap":new Cs(gt.layout_symbol["icon-allow-overlap"],"icon-allow-overlap"),"icon-overlap":new Cs(gt.layout_symbol["icon-overlap"],"icon-overlap"),"icon-ignore-placement":new Cs(gt.layout_symbol["icon-ignore-placement"],"icon-ignore-placement"),"icon-optional":new Cs(gt.layout_symbol["icon-optional"],"icon-optional"),"icon-rotation-alignment":new Cs(gt.layout_symbol["icon-rotation-alignment"],"icon-rotation-alignment"),"icon-size":new Ds(gt.layout_symbol["icon-size"],"icon-size"),"icon-text-fit":new Cs(gt.layout_symbol["icon-text-fit"],"icon-text-fit"),"icon-text-fit-padding":new Cs(gt.layout_symbol["icon-text-fit-padding"],"icon-text-fit-padding"),"icon-image":new Ds(gt.layout_symbol["icon-image"],"icon-image"),"icon-rotate":new Ds(gt.layout_symbol["icon-rotate"],"icon-rotate"),"icon-padding":new Ds(gt.layout_symbol["icon-padding"],"icon-padding"),"icon-keep-upright":new Cs(gt.layout_symbol["icon-keep-upright"],"icon-keep-upright"),"icon-offset":new Ds(gt.layout_symbol["icon-offset"],"icon-offset"),"icon-anchor":new Ds(gt.layout_symbol["icon-anchor"],"icon-anchor"),"icon-pitch-alignment":new Cs(gt.layout_symbol["icon-pitch-alignment"],"icon-pitch-alignment"),"text-pitch-alignment":new Cs(gt.layout_symbol["text-pitch-alignment"],"text-pitch-alignment"),"text-rotation-alignment":new Cs(gt.layout_symbol["text-rotation-alignment"],"text-rotation-alignment"),"text-field":new Ds(gt.layout_symbol["text-field"],"text-field"),"text-font":new Ds(gt.layout_symbol["text-font"],"text-font"),"text-size":new Ds(gt.layout_symbol["text-size"],"text-size"),"text-max-width":new Ds(gt.layout_symbol["text-max-width"],"text-max-width"),"text-line-height":new Cs(gt.layout_symbol["text-line-height"],"text-line-height"),"text-letter-spacing":new Ds(gt.layout_symbol["text-letter-spacing"],"text-letter-spacing"),"text-justify":new Ds(gt.layout_symbol["text-justify"],"text-justify"),"text-radial-offset":new Ds(gt.layout_symbol["text-radial-offset"],"text-radial-offset"),"text-variable-anchor":new Cs(gt.layout_symbol["text-variable-anchor"],"text-variable-anchor"),"text-variable-anchor-offset":new Ds(gt.layout_symbol["text-variable-anchor-offset"],"text-variable-anchor-offset"),"text-anchor":new Ds(gt.layout_symbol["text-anchor"],"text-anchor"),"text-max-angle":new Cs(gt.layout_symbol["text-max-angle"],"text-max-angle"),"text-writing-mode":new Cs(gt.layout_symbol["text-writing-mode"],"text-writing-mode"),"text-rotate":new Ds(gt.layout_symbol["text-rotate"],"text-rotate"),"text-padding":new Cs(gt.layout_symbol["text-padding"],"text-padding"),"text-keep-upright":new Cs(gt.layout_symbol["text-keep-upright"],"text-keep-upright"),"text-transform":new Ds(gt.layout_symbol["text-transform"],"text-transform"),"text-offset":new Ds(gt.layout_symbol["text-offset"],"text-offset"),"text-allow-overlap":new Cs(gt.layout_symbol["text-allow-overlap"],"text-allow-overlap"),"text-overlap":new Cs(gt.layout_symbol["text-overlap"],"text-overlap"),"text-ignore-placement":new Cs(gt.layout_symbol["text-ignore-placement"],"text-ignore-placement"),"text-optional":new Cs(gt.layout_symbol["text-optional"],"text-optional")})}},xp=class{constructor(e){if(void 0===e.property.overrides)throw Error("overrides must be provided to instantiate FormatSectionOverride class");this.type=e.property.overrides?e.property.overrides.runtimeType:Rt,this.defaultValue=e}evaluate(e){if(e.formattedSection){let t=this.defaultValue.property.overrides;if(t?.hasOverride(e.formattedSection))return t.getOverride(e.formattedSection)}return e.feature&&e.featureState?this.defaultValue.evaluate(e.feature,e.featureState):this.defaultValue.property.specification.default}eachChild(e){this.defaultValue.isConstant()||e(this.defaultValue.value._styleExpression.expression)}outputDefined(){return!1}serialize(){return null}};rs("FormatSectionOverride",xp,{omit:["defaultValue"]});var bp,wp=e=>"symbol"===e.type,Tp=class e extends Vs{constructor(e,t){super(e,vp,t)}recalculate(e,t){if(super.recalculate(e,t),"auto"===this.layout.get("icon-rotation-alignment")&&("point"===this.layout.get("symbol-placement")?this.layout._values["icon-rotation-alignment"]="viewport":this.layout._values["icon-rotation-alignment"]="map"),"auto"===this.layout.get("text-rotation-alignment")&&("point"===this.layout.get("symbol-placement")?this.layout._values["text-rotation-alignment"]="viewport":this.layout._values["text-rotation-alignment"]="map"),"auto"===this.layout.get("text-pitch-alignment")&&(this.layout._values["text-pitch-alignment"]="map"===this.layout.get("text-rotation-alignment")?"map":"viewport"),"auto"===this.layout.get("icon-pitch-alignment")&&(this.layout._values["icon-pitch-alignment"]=this.layout.get("icon-rotation-alignment")),"point"===this.layout.get("symbol-placement")){let e=this.layout.get("text-writing-mode");if(e){let t=[];for(let i of e)t.includes(i)||t.push(i);this.layout._values["text-writing-mode"]=t}else this.layout._values["text-writing-mode"]=["horizontal"]}this._setPaintOverrides()}getValueAndResolveTokens(e,t,i,r){let a=this.layout.get(e).evaluate(t,{},i,r),n=this._unevaluatedLayout._values[e];return n.isDataDriven()||Ua(n.value)||!a?a:function(e,t){return t.replace(/{([^{}]+)}/g,(t,i)=>e&&i in e?String(e[i]):"")}(t.properties,a)}createBucket(e){return new gp(e)}queryRadius(){return 0}queryIntersectsFeature(){throw Error("Should take a different path in FeatureIndex")}_setPaintOverrides(){for(let t of vp.paint.overridableProperties){if(!e.hasPaintOverride(this.layout,t))continue;let i=this.paint.get(t),r=new Va(new xp(i),`layers[${this.id}].paint.${i.property.name}`,i.property.specification),a=null;a="constant"===i.value.kind||"source"===i.value.kind?new $a("source",r):new Za("composite",r,i.value.zoomStops),this.paint._values[t]=new Is(i.property,a,i.parameters)}}_handleOverridablePaintPropertyUpdate(t,i,r){return!(!this.layout||i.isDataDriven()||r.isDataDriven())&&e.hasPaintOverride(this.layout,t)}static hasPaintOverride(e,t){let i=e.get("text-field"),r=vp.paint.properties[t],a=!1,n=e=>{for(let t of e)if(r.overrides?.hasOverride(t))return void(a=!0)};if("constant"===i.value.kind&&i.value.value instanceof Ei)n(i.value.value.sections);else if("source"===i.value.kind||"composite"===i.value.kind){let e=t=>{if(!a)if(t instanceof Ni&&Vi(t.value)===Ut){let e=t.value;n(e.sections)}else t instanceof dr?n(t.sections):t.eachChild(e)},t=i.value;t._styleExpression&&e(t._styleExpression.expression)}return a}},Sp={get paint(){return bp||=new Ls({"background-color":new Cs(gt.paint_background["background-color"],"background-color"),"background-pattern":new Rs(gt.paint_background["background-pattern"],"background-pattern"),"background-opacity":new Cs(gt.paint_background["background-opacity"],"background-opacity")})}},Pp=class extends Vs{constructor(e,t){super(e,Sp,t)}},Ip=class extends Vs{constructor(e,t){super(e,{},t),this.onAdd=e=>{this.implementation.onAdd&&this.implementation.onAdd(e,e.painter.context.gl)},this.onRemove=e=>{this.implementation.onRemove&&this.implementation.onRemove(e,e.painter.context.gl)},this.implementation=e}is3D(){return"3d"===this.implementation.renderingMode}hasOffscreenPass(){return void 0!==this.implementation.prerender}recalculate(){}updateTransitions(){}hasTransition(){return!1}serialize(){throw Error("Custom layers cannot be serialized")}};function Mp(e,t){if("custom"===e.type)return new Ip(e,t);switch(e.type){case"background":return new Pp(e,t);case"circle":return new ch(e,t);case"color-relief":return new zh(e,t);case"fill":return new ku(e,t);case"fill-extrusion":return new wc(e,t);case"heatmap":return new Sh(e,t);case"hillshade":return new Ih(e,t);case"line":return new Oc(e,t);case"raster":return new Us(e,t);case"symbol":return new Tp(e,t)}}var Ep=class{constructor(e){this._methodToThrottle=e,this._triggered=!1,this._channel=new MessageChannel,this._channel.port2.onmessage=()=>{this._triggered=!1,this._methodToThrottle()}}trigger(){this._triggered||(this._triggered=!0,this._channel?.port1.postMessage(!0))}remove(){delete this._channel,this._methodToThrottle=()=>{}}},Ap={once:!0},Cp=class{constructor(e,t){this.target=e,this.mapId=t,this.resolveRejects={},this.tasks={},this.taskQueue=[],this.abortControllers={},this.messageHandlers={},this.invoker=new Ep(()=>this.process()),this.subscription=je(this.target,"message",e=>this.receive(e),!1),this.globalScope=Fe(self)?e:window}registerMessageHandler(e,t){this.messageHandlers[e]=t}unregisterMessageHandler(e){delete this.messageHandlers[e]}sendAsync(e,t){return new Promise((i,r)=>{let a=Math.round(1e18*Math.random()).toString(36).substring(0,10),n=t?je(t.signal,"abort",()=>{n?.unsubscribe(),delete this.resolveRejects[a];let i={id:a,type:"<cancel>",origin:location.origin,targetMapId:e.targetMapId,sourceMapId:this.mapId};this.target.postMessage(i),r(new Qe(t.signal.reason))},Ap):null;this.resolveRejects[a]={resolve:e=>{n?.unsubscribe(),i(e)},reject:e=>{n?.unsubscribe(),r(e)}};let s=[],o={...e,id:a,sourceMapId:this.mapId,origin:location.origin,data:os(e.data,s)};this.target.postMessage(o,{transfer:s})})}receive(e){let t=e.data,i=t.id,r=["file://","resource://android","null"],a=[t.origin,location.origin],n=t.origin===location.origin,s=a.some(e=>r.includes(e));if((n||s)&&(!t.targetMapId||this.mapId===t.targetMapId)){if("<cancel>"===t.type){delete this.tasks[i];let e=this.abortControllers[i];return delete this.abortControllers[i],void(e&&e.abort())}if(Fe(self)||t.mustQueue)return this.tasks[i]=t,this.taskQueue.push(i),void this.invoker.trigger();this.processTask(i,t)}}process(){if(0===this.taskQueue.length)return;let e=this.taskQueue.shift(),t=this.tasks[e];delete this.tasks[e],this.taskQueue.length>0&&this.invoker.trigger(),t&&this.processTask(e,t)}async processTask(e,t){if("<response>"===t.type){let i=this.resolveRejects[e];if(delete this.resolveRejects[e],!i)return;return void(t.error?i.reject(ee(ls(t.error))):i.resolve(ls(t.data)))}if(!this.messageHandlers[t.type])return void this.completeTask(e,null,null);let i=ls(t.data),r=new AbortController;this.abortControllers[e]=r;try{let a=await this.messageHandlers[t.type](t.sourceMapId,i,r);this.completeTask(e,null,a)}catch(t){this.completeTask(e,ee(t))}}completeTask(e,t,i){let r=[];delete this.abortControllers[e];let a={id:e,type:"<response>",sourceMapId:this.mapId,origin:location.origin,error:t?os(t):null,data:os(i,r)};this.target.postMessage(a,{transfer:r})}remove(){this.invoker.remove(),this.subscription.unsubscribe()}};function Dp(e,t){let{x:i,y:r}=ac.fromLngLat(t);return!(e<0||e>25||r<0||r>=1||i<0||i>=1)}var zp=class{constructor(e,t,i){if(!function(e,t,i){return!(e<0||e>25||i<0||i>=2**e||t<0||t>=2**e)}(e,t,i))throw Error(`x=${t}, y=${i}, z=${e} outside of bounds. 0<=x<${2**e}, 0<=y<${2**e} 0<=z<=25 `);this.z=e,this.x=t,this.y=i,this.key=Lp(0,e,e,t,i)}equals(e){return this.z===e.z&&this.x===e.x&&this.y===e.y}url(e,t,i){let r=function(e,t,i){let r=Bp(256*e,256*(t=2**i-t-1),i),a=Bp(256*(e+1),256*(t+1),i);return`${r[0]},${r[1]},${a[0]},${a[1]}`}(this.x,this.y,this.z),a=function(e,t,i){let r="";for(let a=e;a>0;a--){let e=1<<a-1;r+=(t&e?1:0)+(i&e?2:0)}return r}(this.z,this.x,this.y);return e[(this.x+this.y)%e.length].replace(/{prefix}/g,(this.x%16).toString(16)+(this.y%16).toString(16)).replace(/{z}/g,String(this.z)).replace(/{x}/g,String(this.x)).replace(/{y}/g,String("tms"===i?2**this.z-this.y-1:this.y)).replace(/{ratio}/g,t>1?"@2x":"").replace(/{quadkey}/g,a).replace(/{bbox-epsg-3857}/g,r)}isChildOf(e){let t=this.z-e.z;return t>0&&e.x===this.x>>t&&e.y===this.y>>t}getTilePoint(e){let t=2**this.z;return new u((e.x*t-this.x)*J,(e.y*t-this.y)*J)}toString(){return`${this.z}/${this.x}/${this.y}`}},Rp=class{constructor(e,t){this.wrap=e,this.canonical=t,this.key=Lp(e,t.z,t.z,t.x,t.y)}},kp=class e{constructor(e,t,i,r,a){if(this.terrainRttPosMatrix32f=null,e<i)throw Error(`overscaledZ should be >= z; overscaledZ = ${e}; z = ${i}`);this.overscaledZ=e,this.wrap=t,this.canonical=new zp(i,+r,+a),this.key=Lp(t,e,i,r,a)}clone(){return new e(this.overscaledZ,this.wrap,this.canonical.z,this.canonical.x,this.canonical.y)}equals(e){return this.overscaledZ===e.overscaledZ&&this.wrap===e.wrap&&this.canonical.equals(e.canonical)}scaledTo(t){if(t>this.overscaledZ)throw Error(`targetZ > this.overscaledZ; targetZ = ${t}; overscaledZ = ${this.overscaledZ}`);let i=this.canonical.z-t;return t>this.canonical.z?new e(t,this.wrap,this.canonical.z,this.canonical.x,this.canonical.y):new e(t,this.wrap,t,this.canonical.x>>i,this.canonical.y>>i)}isOverscaled(){return this.overscaledZ>this.canonical.z}calculateScaledKey(e,t){if(e>this.overscaledZ)throw Error(`targetZ > this.overscaledZ; targetZ = ${e}; overscaledZ = ${this.overscaledZ}`);let i=this.canonical.z-e;return e>this.canonical.z?Lp(this.wrap*+t,e,this.canonical.z,this.canonical.x,this.canonical.y):Lp(this.wrap*+t,e,e,this.canonical.x>>i,this.canonical.y>>i)}isChildOf(e){if(e.wrap!==this.wrap||this.overscaledZ-e.overscaledZ<=0)return!1;if(0===e.overscaledZ)return this.overscaledZ>0;let t=this.canonical.z-e.canonical.z;return!(t<0)&&e.canonical.x===this.canonical.x>>t&&e.canonical.y===this.canonical.y>>t}children(t){if(this.overscaledZ>=t)return[new e(this.overscaledZ+1,this.wrap,this.canonical.z,this.canonical.x,this.canonical.y)];let i=this.canonical.z+1,r=2*this.canonical.x,a=2*this.canonical.y;return[new e(i,this.wrap,i,r,a),new e(i,this.wrap,i,r+1,a),new e(i,this.wrap,i,r,a+1),new e(i,this.wrap,i,r+1,a+1)]}isLessThan(e){return this.wrap<e.wrap||!(this.wrap>e.wrap)&&(this.overscaledZ<e.overscaledZ||!(this.overscaledZ>e.overscaledZ)&&(this.canonical.x<e.canonical.x||!(this.canonical.x>e.canonical.x)&&this.canonical.y<e.canonical.y))}wrapped(){return new e(this.overscaledZ,0,this.canonical.z,this.canonical.x,this.canonical.y)}unwrapTo(t){return new e(this.overscaledZ,t,this.canonical.z,this.canonical.x,this.canonical.y)}overscaleFactor(){return 2**(this.overscaledZ-this.canonical.z)}toUnwrapped(){return new Rp(this.wrap,this.canonical)}toString(){return`${this.overscaledZ}/${this.canonical.x}/${this.canonical.y}`}getTilePoint(e){return this.canonical.getTilePoint(new ac(e.x-this.wrap,e.y))}normalizeCoordinates(t,i,r=J){if(t>=0&&t<r&&i>=0&&i<r)return{tileID:this,x:t,y:i};let a=Math.floor(t/r),n=Math.floor(i/r),s=t-a*r,o=i-n*r,l=this.canonical.z,h=1<<l,u=this.canonical.y+n;if(u<0||u>=h)return null;let c=this.canonical.x+a,p=this.wrap;return c<0?(p-=Math.ceil(-c/h),c=(c%h+h)%h):c>=h&&(p+=Math.floor(c/h),c%=h),{tileID:new e(this.overscaledZ,p,l,c,u),x:s,y:o}}};function Lp(e,t,i,r,a){(e*=2)<0&&(e=-1*e-1);let n=1<<i;return(n*n*e+n*a+r).toString(36)+i.toString(36)+t.toString(36)}var Fp=6378137*Math.PI;function Bp(e,t,i){let r=2*Fp/256/2**i;return[e*r-Fp,t*r-Fp]}function Op(e,t){let i=Math.abs(2*e.wrap)-+(e.wrap<0),r=Math.abs(2*t.wrap)-+(t.wrap<0);return e.overscaledZ-t.overscaledZ||r-i||t.canonical.y-e.canonical.y||t.canonical.x-e.canonical.x}rs("CanonicalTileID",zp),rs("OverscaledTileID",kp,{omit:["terrainRttPosMatrix32f"]});var Vp,jp,Np="_geojsonTileLayer",Up=class{constructor(e){this._stringToNumber={},this._numberToString=[];for(let t=0;t<e.length;t++){let i=e[t];this._stringToNumber[i]=t,this._numberToString[t]=i}}encode(e){return this._stringToNumber[e]}decode(e){if(e>=this._numberToString.length)throw Error(`Out of bounds. Index requested n=${e} can't be >= this._numberToString.length ${this._numberToString.length}`);return this._numberToString[e]}},Gp=class{constructor(e,t,i,r,a){this.type="Feature",this._vectorTileFeature=e,this._x=i,this._y=r,this._z=t;for(let n in e.properties)"string"!=typeof e.properties[n]||!e.properties[n].startsWith("__$json__:")||(e.properties[n]=JSON.parse(e.properties[n].slice(10)));this.properties=e.properties,this.id=a}projectPoint(e,t,i,r){return[360*(e.x+t)/r-180,360/Math.PI*Math.atan(Math.exp((1-2*(e.y+i)/r)*Math.PI))-90]}projectLine(e,t,i,r){return e.map(e=>this.projectPoint(e,t,i,r))}get geometry(){if(this._geometry)return this._geometry;let e=this._vectorTileFeature,t=e.extent*2**this._z,i=e.extent*this._x,r=e.extent*this._y,a=e.loadGeometry();switch(e.type){case 1:{let e=[];for(let t of a)e.push(t[0]);let n=this.projectLine(e,i,r,t);this._geometry=1===e.length?{type:"Point",coordinates:n[0]}:{type:"MultiPoint",coordinates:n};break}case 2:{let e=a.map(e=>this.projectLine(e,i,r,t));this._geometry=1===e.length?{type:"LineString",coordinates:e[0]}:{type:"MultiLineString",coordinates:e};break}case 3:{let e=Gu(a),n=[];for(let a of e)n.push(a.map(e=>this.projectLine(e,i,r,t)));this._geometry=1===n.length?{type:"Polygon",coordinates:n[0]}:{type:"MultiPolygon",coordinates:n};break}default:throw Error(`unknown feature type: ${e.type}`)}return this._geometry}set geometry(e){this._geometry=e}toJSON(){let e={geometry:this.geometry};for(let t in this)"_geometry"!==t&&"_vectorTileFeature"!==t&&"_x"!==t&&"_y"!==t&&"_z"!==t&&(e[t]=this[t]);return e}},$p=class{constructor(e,t,i){this._name=e,this.dataBuffer=t,"number"==typeof i?this._size=i:(this.nullabilityBuffer=i,this._size=i.size())}getValue(e){return this.nullabilityBuffer&&!this.nullabilityBuffer.get(e)?null:this.getValueFromBuffer(e)}has(e){return this.nullabilityBuffer?.get(e)||!this.nullabilityBuffer}get name(){return this._name}get size(){return this._size}},Zp=class extends $p{},qp=class extends Zp{getValueFromBuffer(e){return this.dataBuffer[e]}},Wp=class extends Zp{getValueFromBuffer(e){return this.dataBuffer[e]}},Hp=class extends $p{constructor(e,t,i,r){super(e,t,r),this.delta=i}},Xp=class extends Hp{constructor(e,t,i,r){super(e,Int32Array.of(t),i,r)}getValueFromBuffer(e){return this.dataBuffer[0]+e*this.delta}},Yp=class extends $p{constructor(e,t,i,r){super(e,r?Int32Array.of(t):Uint32Array.of(t),i)}getValueFromBuffer(e){return this.dataBuffer[0]}},Kp=class{constructor(e,t,i,r,a=4096){if(this._name=e,this._geometryVector=t,this._idVector=i,this._propertyVectors=r,this._extent=a,0===e.length)throw Error("Missing layer name")}get name(){return this._name}get idVector(){return this._idVector}get geometryVector(){return this._geometryVector}get propertyVectors(){return this._propertyVectors}getPropertyVector(e){return this.propertyVectorsMap||=new Map(this._propertyVectors.map(e=>[e.name,e])),this.propertyVectorsMap.get(e)}get numFeatures(){return this.geometryVector.numGeometries}get extent(){return this._extent}getFeatures(){let e=[],t=this.geometryVector.getGeometries();for(let i=0;i<this.numFeatures;i++){let r;if(this.idVector){let e=this.idVector.getValue(i);r=this.containsMaxSafeIntegerValues(this.idVector)&&null!==e?Number(e):e}let a={coordinates:t[i],type:this.geometryVector.geometryType(i)},n={};for(let e of this.propertyVectors){if(!e)continue;let t=e.name,r=e.getValue(i);null!==r&&(n[t]=r)}e.push({id:r,geometry:a,properties:n})}return e}containsMaxSafeIntegerValues(e){return e instanceof qp||e instanceof Yp||e instanceof Xp||e instanceof Wp}},Jp=class{constructor(e){this.value=e}get(){return this.value}set(e){this.value=e}increment(){return this.value++}add(e){this.value+=e}};!function(e){e.NONE="NONE",e.DELTA="DELTA",e.COMPONENTWISE_DELTA="COMPONENTWISE_DELTA",e.RLE="RLE",e.MORTON="MORTON",e.PDE="PDE"}(Vp||={}),function(e){e.NONE="NONE",e.FAST_PFOR="FAST_PFOR",e.VARINT="VARINT"}(jp||={});var Qp=/* @__PURE__ */new Uint32Array(33);Qp[0]=0;for(let gT=1;gT<=32;gT++)Qp[gT]=32===gT?4294967295:4294967295>>>32-gT;var ed=Qp;function td(e,t){return e-e%t}function id(e){return td(e+31,32)}function rd(e){let t=e>>>0;return((255&t)<<24|(65280&t)<<8|t>>>8&65280|t>>>24&255)>>>0}var ad,nd,sd,od,ld=function(e){if(!Number.isFinite(e))return 65536;let t=td(Math.floor(e),256);return 0===t?256:t}(65536),hd=3*ld/256+ld|0;function ud(){let e=new Uint8Array(hd);return{dataToBePacked:Array(33),dataPointers:/* @__PURE__ */new Int32Array(33),byteContainer:e,byteContainerI32:new Int32Array(e.buffer,e.byteOffset,e.byteLength>>>2),exceptionSizes:/* @__PURE__ */new Int32Array(33)}}function cd(e,t,i,r,a){switch(a){case 1:!function(e,t,i,r){let a=r,n=t;for(let s=0;s<8;s++){let t=e[n++]>>>0;i[a++]=t>>>0&1,i[a++]=t>>>1&1,i[a++]=t>>>2&1,i[a++]=t>>>3&1,i[a++]=t>>>4&1,i[a++]=t>>>5&1,i[a++]=t>>>6&1,i[a++]=t>>>7&1,i[a++]=t>>>8&1,i[a++]=t>>>9&1,i[a++]=t>>>10&1,i[a++]=t>>>11&1,i[a++]=t>>>12&1,i[a++]=t>>>13&1,i[a++]=t>>>14&1,i[a++]=t>>>15&1,i[a++]=t>>>16&1,i[a++]=t>>>17&1,i[a++]=t>>>18&1,i[a++]=t>>>19&1,i[a++]=t>>>20&1,i[a++]=t>>>21&1,i[a++]=t>>>22&1,i[a++]=t>>>23&1,i[a++]=t>>>24&1,i[a++]=t>>>25&1,i[a++]=t>>>26&1,i[a++]=t>>>27&1,i[a++]=t>>>28&1,i[a++]=t>>>29&1,i[a++]=t>>>30&1,i[a++]=t>>>31&1}}(e,t,i,r);break;case 2:!function(e,t,i,r){let a=r,n=t;for(let s=0;s<8;s++){let t=e[n++]>>>0,r=e[n++]>>>0;i[a++]=t>>>0&3,i[a++]=t>>>2&3,i[a++]=t>>>4&3,i[a++]=t>>>6&3,i[a++]=t>>>8&3,i[a++]=t>>>10&3,i[a++]=t>>>12&3,i[a++]=t>>>14&3,i[a++]=t>>>16&3,i[a++]=t>>>18&3,i[a++]=t>>>20&3,i[a++]=t>>>22&3,i[a++]=t>>>24&3,i[a++]=t>>>26&3,i[a++]=t>>>28&3,i[a++]=t>>>30&3,i[a++]=r>>>0&3,i[a++]=r>>>2&3,i[a++]=r>>>4&3,i[a++]=r>>>6&3,i[a++]=r>>>8&3,i[a++]=r>>>10&3,i[a++]=r>>>12&3,i[a++]=r>>>14&3,i[a++]=r>>>16&3,i[a++]=r>>>18&3,i[a++]=r>>>20&3,i[a++]=r>>>22&3,i[a++]=r>>>24&3,i[a++]=r>>>26&3,i[a++]=r>>>28&3,i[a++]=r>>>30&3}}(e,t,i,r);break;case 3:!function(e,t,i,r){let a=r,n=t;for(let s=0;s<8;s++){let t=e[n++]>>>0,r=e[n++]>>>0,s=e[n++]>>>0;i[a++]=t>>>0&7,i[a++]=t>>>3&7,i[a++]=t>>>6&7,i[a++]=t>>>9&7,i[a++]=t>>>12&7,i[a++]=t>>>15&7,i[a++]=t>>>18&7,i[a++]=t>>>21&7,i[a++]=t>>>24&7,i[a++]=t>>>27&7,i[a++]=7&(t>>>30|(1&r)<<2),i[a++]=r>>>1&7,i[a++]=r>>>4&7,i[a++]=r>>>7&7,i[a++]=r>>>10&7,i[a++]=r>>>13&7,i[a++]=r>>>16&7,i[a++]=r>>>19&7,i[a++]=r>>>22&7,i[a++]=r>>>25&7,i[a++]=r>>>28&7,i[a++]=7&(r>>>31|(3&s)<<1),i[a++]=s>>>2&7,i[a++]=s>>>5&7,i[a++]=s>>>8&7,i[a++]=s>>>11&7,i[a++]=s>>>14&7,i[a++]=s>>>17&7,i[a++]=s>>>20&7,i[a++]=s>>>23&7,i[a++]=s>>>26&7,i[a++]=s>>>29&7}}(e,t,i,r);break;case 4:!function(e,t,i,r){let a=r,n=t;for(let s=0;s<8;s++){let t=e[n++]>>>0,r=e[n++]>>>0,s=e[n++]>>>0,o=e[n++]>>>0;i[a++]=t>>>0&15,i[a++]=t>>>4&15,i[a++]=t>>>8&15,i[a++]=t>>>12&15,i[a++]=t>>>16&15,i[a++]=t>>>20&15,i[a++]=t>>>24&15,i[a++]=t>>>28&15,i[a++]=r>>>0&15,i[a++]=r>>>4&15,i[a++]=r>>>8&15,i[a++]=r>>>12&15,i[a++]=r>>>16&15,i[a++]=r>>>20&15,i[a++]=r>>>24&15,i[a++]=r>>>28&15,i[a++]=s>>>0&15,i[a++]=s>>>4&15,i[a++]=s>>>8&15,i[a++]=s>>>12&15,i[a++]=s>>>16&15,i[a++]=s>>>20&15,i[a++]=s>>>24&15,i[a++]=s>>>28&15,i[a++]=o>>>0&15,i[a++]=o>>>4&15,i[a++]=o>>>8&15,i[a++]=o>>>12&15,i[a++]=o>>>16&15,i[a++]=o>>>20&15,i[a++]=o>>>24&15,i[a++]=o>>>28&15}}(e,t,i,r);break;case 5:!function(e,t,i,r){let a=r,n=t;for(let s=0;s<8;s++){let t=e[n++]>>>0,r=e[n++]>>>0,s=e[n++]>>>0,o=e[n++]>>>0,l=e[n++]>>>0;i[a++]=t>>>0&31,i[a++]=t>>>5&31,i[a++]=t>>>10&31,i[a++]=t>>>15&31,i[a++]=t>>>20&31,i[a++]=t>>>25&31,i[a++]=31&(t>>>30|(7&r)<<2),i[a++]=r>>>3&31,i[a++]=r>>>8&31,i[a++]=r>>>13&31,i[a++]=r>>>18&31,i[a++]=r>>>23&31,i[a++]=31&(r>>>28|(1&s)<<4),i[a++]=s>>>1&31,i[a++]=s>>>6&31,i[a++]=s>>>11&31,i[a++]=s>>>16&31,i[a++]=s>>>21&31,i[a++]=s>>>26&31,i[a++]=31&(s>>>31|(15&o)<<1),i[a++]=o>>>4&31,i[a++]=o>>>9&31,i[a++]=o>>>14&31,i[a++]=o>>>19&31,i[a++]=o>>>24&31,i[a++]=31&(o>>>29|(3&l)<<3),i[a++]=l>>>2&31,i[a++]=l>>>7&31,i[a++]=l>>>12&31,i[a++]=l>>>17&31,i[a++]=l>>>22&31,i[a++]=l>>>27&31}}(e,t,i,r);break;case 6:!function(e,t,i,r){let a=r,n=t;for(let s=0;s<8;s++){let t=e[n++]>>>0,r=e[n++]>>>0,s=e[n++]>>>0,o=e[n++]>>>0,l=e[n++]>>>0,h=e[n++]>>>0;i[a++]=t>>>0&63,i[a++]=t>>>6&63,i[a++]=t>>>12&63,i[a++]=t>>>18&63,i[a++]=t>>>24&63,i[a++]=63&(t>>>30|(15&r)<<2),i[a++]=r>>>4&63,i[a++]=r>>>10&63,i[a++]=r>>>16&63,i[a++]=r>>>22&63,i[a++]=63&(r>>>28|(3&s)<<4),i[a++]=s>>>2&63,i[a++]=s>>>8&63,i[a++]=s>>>14&63,i[a++]=s>>>20&63,i[a++]=s>>>26&63,i[a++]=o>>>0&63,i[a++]=o>>>6&63,i[a++]=o>>>12&63,i[a++]=o>>>18&63,i[a++]=o>>>24&63,i[a++]=63&(o>>>30|(15&l)<<2),i[a++]=l>>>4&63,i[a++]=l>>>10&63,i[a++]=l>>>16&63,i[a++]=l>>>22&63,i[a++]=63&(l>>>28|(3&h)<<4),i[a++]=h>>>2&63,i[a++]=h>>>8&63,i[a++]=h>>>14&63,i[a++]=h>>>20&63,i[a++]=h>>>26&63}}(e,t,i,r);break;case 7:!function(e,t,i,r){let a=r,n=t;for(let s=0;s<8;s++){let t=e[n++]>>>0,r=e[n++]>>>0,s=e[n++]>>>0,o=e[n++]>>>0,l=e[n++]>>>0,h=e[n++]>>>0,u=e[n++]>>>0;i[a++]=t>>>0&127,i[a++]=t>>>7&127,i[a++]=t>>>14&127,i[a++]=t>>>21&127,i[a++]=127&(t>>>28|(7&r)<<4),i[a++]=r>>>3&127,i[a++]=r>>>10&127,i[a++]=r>>>17&127,i[a++]=r>>>24&127,i[a++]=127&(r>>>31|(63&s)<<1),i[a++]=s>>>6&127,i[a++]=s>>>13&127,i[a++]=s>>>20&127,i[a++]=127&(s>>>27|(3&o)<<5),i[a++]=o>>>2&127,i[a++]=o>>>9&127,i[a++]=o>>>16&127,i[a++]=o>>>23&127,i[a++]=127&(o>>>30|(31&l)<<2),i[a++]=l>>>5&127,i[a++]=l>>>12&127,i[a++]=l>>>19&127,i[a++]=127&(l>>>26|(1&h)<<6),i[a++]=h>>>1&127,i[a++]=h>>>8&127,i[a++]=h>>>15&127,i[a++]=h>>>22&127,i[a++]=127&(h>>>29|(15&u)<<3),i[a++]=u>>>4&127,i[a++]=u>>>11&127,i[a++]=u>>>18&127,i[a++]=u>>>25&127}}(e,t,i,r);break;case 8:!function(e,t,i,r){let a=r,n=t;for(let s=0;s<8;s++){let t=e[n++]>>>0,r=e[n++]>>>0,s=e[n++]>>>0,o=e[n++]>>>0,l=e[n++]>>>0,h=e[n++]>>>0,u=e[n++]>>>0,c=e[n++]>>>0;i[a++]=t>>>0&255,i[a++]=t>>>8&255,i[a++]=t>>>16&255,i[a++]=t>>>24&255,i[a++]=r>>>0&255,i[a++]=r>>>8&255,i[a++]=r>>>16&255,i[a++]=r>>>24&255,i[a++]=s>>>0&255,i[a++]=s>>>8&255,i[a++]=s>>>16&255,i[a++]=s>>>24&255,i[a++]=o>>>0&255,i[a++]=o>>>8&255,i[a++]=o>>>16&255,i[a++]=o>>>24&255,i[a++]=l>>>0&255,i[a++]=l>>>8&255,i[a++]=l>>>16&255,i[a++]=l>>>24&255,i[a++]=h>>>0&255,i[a++]=h>>>8&255,i[a++]=h>>>16&255,i[a++]=h>>>24&255,i[a++]=u>>>0&255,i[a++]=u>>>8&255,i[a++]=u>>>16&255,i[a++]=u>>>24&255,i[a++]=c>>>0&255,i[a++]=c>>>8&255,i[a++]=c>>>16&255,i[a++]=c>>>24&255}}(e,t,i,r);break;case 16:!function(e,t,i,r){let a=r,n=t;for(let s=0;s<128;s++){let t=e[n++]>>>0;i[a++]=65535&t,i[a++]=t>>>16&65535}}(e,t,i,r);break;default:!function(e,t,i,r,a){let n=ed[a]>>>0,s=t,o=0,l=e[s]>>>0,h=r;for(let u=0;u<8;u++){for(let t=0;t<32;t++)if(o+a<=32){let r=l>>>o&n;i[h+t]=0|r,o+=a,32===o&&(o=0,s++,31!==t&&(l=e[s]>>>0))}else{let r=32-o,u=l>>>o;s++,l=e[s]>>>0;let c=a-r,p=(u|(l&-1>>>32-c>>>0)<<r)&n;i[h+t]=0|p,o=c}h+=32,o=0,u<7&&(l=e[s]>>>0)}}(e,t,i,r,a)}return t+(a<<3)|0}function pd(e,t,i,r){if(i+2>t)throw Error(`FastPFOR decode: byteContainer underflow at block=${r} (need 2 bytes for [bitWidth, exceptionCount], bytePos=${i}, byteSize=${t})`);let a=e[i++],n=e[i++];if(a>32)throw Error(`FastPFOR decode: invalid bitWidth=${a} at block=${r} (expected 0..32). This likely indicates corrupted or truncated input.`);return{bitWidth:a,exceptionCount:n,bytePosIn:i}}function dd(e,t,i,r,a,n,s,o,l){let{maxBits:h,exceptionBitWidth:u,bytePosIn:c}=function(e,t,i,r,a,n){if(i+1>t)throw Error(`FastPFOR decode: exception header underflow at block=${n} (need 1 byte for maxBits, bytePos=${i}, byteSize=${t})`);let s=e[i++];if(s<r||s>32)throw Error(`FastPFOR decode: invalid maxBits=${s} at block=${n} (bitWidth=${r}, expected ${r}..32)`);let o=s-r|0;if(o<1||o>32)throw Error(`FastPFOR decode: invalid exceptionBitWidth=${o} at block=${n} (bitWidth=${r}, maxBits=${s})`);if(i+a>t)throw Error(`FastPFOR decode: exception positions underflow at block=${n} (need=${a}, have=${t-i})`);return{maxBits:s,exceptionBitWidth:o,bytePosIn:i}}(a,n,s,i,r,l);if(s=c,1===u){let n=1<<i;for(let i=0;i<r;i=i+1|0)e[a[s++]+t|0]|=n;return s}let p=o.dataToBePacked[u];if(!p)throw Error(`FastPFOR decode: missing exception stream for exceptionBitWidth=${u} (bitWidth=${i}, maxBits=${h}) at block ${l}`);let d=o.dataPointers,f=0|d[u],m=0|o.exceptionSizes[u];if(f+r>m)throw Error(`FastPFOR decode: exception stream overflow for exceptionBitWidth=${u} (ptr=${f}, need ${r}, size=${m}) at block ${l}`);for(let _=0;_<r;_=_+1|0){let r=a[s++],n=0|p[f++];e[r+t|0]|=n<<i}return d[u]=f,s}function fd(e,t,i,r,a,n){let s=0|i,o=0|e[s];if(o<=0||s+o>e.length-1)throw Error(`FastPFOR decode: invalid whereMeta=${o} at pageStart=${s} (expected > 0 and pageStart+whereMeta < encoded.length=${e.length})`);let l=s+1|0,h=s+o|0,u=e[h]>>>0,c=u+3>>>2,p=h+1,d=p+c;if(d>=e.length)throw Error(`FastPFOR decode: invalid byteSize=${u} (metaInts=${c}, pageStart=${s}, packedEnd=${h}, byteContainerStart=${p}) causes bitmapPos=${d} out of bounds (encoded.length=${e.length})`);let f=function(e,t,i,r){r.byteContainer.length<i&&(r.byteContainer=new Uint8Array(2*i),r.byteContainerI32=void 0);let a=r.byteContainer,n=i>>>2;if(3&a.byteOffset)for(let o=0;o<n;o=o+1|0){let i=0|e[t+o|0],r=o<<2;a[r]=255&i,a[r+1|0]=i>>>8&255,a[r+2|0]=i>>>16&255,a[r+3|0]=i>>>24&255}else{let i=r.byteContainerI32;(!i||i.buffer!==a.buffer||i.byteOffset!==a.byteOffset||i.length<n)&&(i=r.byteContainerI32=new Int32Array(a.buffer,a.byteOffset,a.byteLength>>>2)),i.set(e.subarray(t,t+n))}let s=3&i;if(s>0){let i=0|e[t+n|0],r=n<<2;for(let e=0;e<s;e=e+1|0)a[r+e|0]=i>>>(e<<3)&255}return a}(e,p,u,n),m=u,_=function(e,t,i){let r=0|e[t++],a=i.dataToBePacked;for(let n=2;n<=32;n=n+1|0){if(!(r>>>n-1&1))continue;if(t>=e.length)throw Error(`FastPFOR decode: truncated exception stream header (bitWidth=${n}, streamWordIndex=${t}, needWords=1, availableWords=${e.length-t}, encodedWords=${e.length})`);let s=e[t++]>>>0,o=id(s),l=s*n+31>>>5;if(t+l>e.length)throw Error(`FastPFOR decode: truncated exception stream (bitWidth=${n}, size=${s}, streamWordIndex=${t}, needWords=${l}, availableWords=${e.length-t}, encodedWords=${e.length})`);let h=a[n];(!h||h.length<o)&&(h=a[n]=new Uint32Array(o));let u=0;for(;u<s;u=u+32|0)md(e,t,h,u,n),t=t+n|0;t=t-((u-s|0)*n>>>5)|0,i.exceptionSizes[n]=s}return t}(e,d,n);return n.dataPointers.fill(0),function(e,t,i,r,a,n,s,o,l,h){let u=0|i,c=0;for(let p=0;p<s;p=p+1|0){let t=pd(o,l,c,p);c=t.bytePosIn;let i=t.bitWidth,r=t.exceptionCount,s=n+256*p|0;switch(i){case 0:a.fill(0,s,s+256);break;case 32:for(let t=0;t<256;t=t+1|0)a[s+t|0]=0|e[u+t|0];u=u+256|0;break;default:u=cd(e,u,a,s,i)}r>0&&(c=dd(a,s,i,r,o,l,c,h,p))}if(u!==r)throw Error(`FastPFOR decode: packed region mismatch (pageStart=${t}, packedStart=${i}, consumedPackedEnd=${u}, expectedPackedEnd=${r}, packedWords=${r-i}, encoded.length=${e.length})`)}(e,s,l,h,t,0|r,a/256|0,f,m,n),_}function md(e,t,i,r,a){switch(a){case 2:return void function(e,t,i,r){let a=r,n=e[t]>>>0,s=e[t+1]>>>0;i[a++]=n>>>0&3,i[a++]=n>>>2&3,i[a++]=n>>>4&3,i[a++]=n>>>6&3,i[a++]=n>>>8&3,i[a++]=n>>>10&3,i[a++]=n>>>12&3,i[a++]=n>>>14&3,i[a++]=n>>>16&3,i[a++]=n>>>18&3,i[a++]=n>>>20&3,i[a++]=n>>>22&3,i[a++]=n>>>24&3,i[a++]=n>>>26&3,i[a++]=n>>>28&3,i[a++]=n>>>30&3,i[a++]=s>>>0&3,i[a++]=s>>>2&3,i[a++]=s>>>4&3,i[a++]=s>>>6&3,i[a++]=s>>>8&3,i[a++]=s>>>10&3,i[a++]=s>>>12&3,i[a++]=s>>>14&3,i[a++]=s>>>16&3,i[a++]=s>>>18&3,i[a++]=s>>>20&3,i[a++]=s>>>22&3,i[a++]=s>>>24&3,i[a++]=s>>>26&3,i[a++]=s>>>28&3,i[a]=s>>>30&3}(e,t,i,r);case 3:return void function(e,t,i,r){let a=r,n=e[t]>>>0,s=e[t+1]>>>0,o=e[t+2]>>>0;i[a++]=n>>>0&7,i[a++]=n>>>3&7,i[a++]=n>>>6&7,i[a++]=n>>>9&7,i[a++]=n>>>12&7,i[a++]=n>>>15&7,i[a++]=n>>>18&7,i[a++]=n>>>21&7,i[a++]=n>>>24&7,i[a++]=n>>>27&7,i[a++]=7&(n>>>30|(1&s)<<2),i[a++]=s>>>1&7,i[a++]=s>>>4&7,i[a++]=s>>>7&7,i[a++]=s>>>10&7,i[a++]=s>>>13&7,i[a++]=s>>>16&7,i[a++]=s>>>19&7,i[a++]=s>>>22&7,i[a++]=s>>>25&7,i[a++]=s>>>28&7,i[a++]=7&(s>>>31|(3&o)<<1),i[a++]=o>>>2&7,i[a++]=o>>>5&7,i[a++]=o>>>8&7,i[a++]=o>>>11&7,i[a++]=o>>>14&7,i[a++]=o>>>17&7,i[a++]=o>>>20&7,i[a++]=o>>>23&7,i[a++]=o>>>26&7,i[a]=o>>>29&7}(e,t,i,r);case 4:return void function(e,t,i,r){let a=r,n=e[t]>>>0,s=e[t+1]>>>0,o=e[t+2]>>>0,l=e[t+3]>>>0;i[a++]=n>>>0&15,i[a++]=n>>>4&15,i[a++]=n>>>8&15,i[a++]=n>>>12&15,i[a++]=n>>>16&15,i[a++]=n>>>20&15,i[a++]=n>>>24&15,i[a++]=n>>>28&15,i[a++]=s>>>0&15,i[a++]=s>>>4&15,i[a++]=s>>>8&15,i[a++]=s>>>12&15,i[a++]=s>>>16&15,i[a++]=s>>>20&15,i[a++]=s>>>24&15,i[a++]=s>>>28&15,i[a++]=o>>>0&15,i[a++]=o>>>4&15,i[a++]=o>>>8&15,i[a++]=o>>>12&15,i[a++]=o>>>16&15,i[a++]=o>>>20&15,i[a++]=o>>>24&15,i[a++]=o>>>28&15,i[a++]=l>>>0&15,i[a++]=l>>>4&15,i[a++]=l>>>8&15,i[a++]=l>>>12&15,i[a++]=l>>>16&15,i[a++]=l>>>20&15,i[a++]=l>>>24&15,i[a]=l>>>28&15}(e,t,i,r);case 5:return void function(e,t,i,r){let a=r,n=e[t]>>>0,s=e[t+1]>>>0,o=e[t+2]>>>0,l=e[t+3]>>>0,h=e[t+4]>>>0;i[a++]=n>>>0&31,i[a++]=n>>>5&31,i[a++]=n>>>10&31,i[a++]=n>>>15&31,i[a++]=n>>>20&31,i[a++]=n>>>25&31,i[a++]=31&(n>>>30|(7&s)<<2),i[a++]=s>>>3&31,i[a++]=s>>>8&31,i[a++]=s>>>13&31,i[a++]=s>>>18&31,i[a++]=s>>>23&31,i[a++]=31&(s>>>28|(1&o)<<4),i[a++]=o>>>1&31,i[a++]=o>>>6&31,i[a++]=o>>>11&31,i[a++]=o>>>16&31,i[a++]=o>>>21&31,i[a++]=o>>>26&31,i[a++]=31&(o>>>31|(15&l)<<1),i[a++]=l>>>4&31,i[a++]=l>>>9&31,i[a++]=l>>>14&31,i[a++]=l>>>19&31,i[a++]=l>>>24&31,i[a++]=31&(l>>>29|(3&h)<<3),i[a++]=h>>>2&31,i[a++]=h>>>7&31,i[a++]=h>>>12&31,i[a++]=h>>>17&31,i[a++]=h>>>22&31,i[a]=h>>>27&31}(e,t,i,r);case 6:return void function(e,t,i,r){let a=r,n=e[t]>>>0,s=e[t+1]>>>0,o=e[t+2]>>>0,l=e[t+3]>>>0,h=e[t+4]>>>0,u=e[t+5]>>>0;i[a++]=n>>>0&63,i[a++]=n>>>6&63,i[a++]=n>>>12&63,i[a++]=n>>>18&63,i[a++]=n>>>24&63,i[a++]=63&(n>>>30|(15&s)<<2),i[a++]=s>>>4&63,i[a++]=s>>>10&63,i[a++]=s>>>16&63,i[a++]=s>>>22&63,i[a++]=63&(s>>>28|(3&o)<<4),i[a++]=o>>>2&63,i[a++]=o>>>8&63,i[a++]=o>>>14&63,i[a++]=o>>>20&63,i[a++]=o>>>26&63,i[a++]=l>>>0&63,i[a++]=l>>>6&63,i[a++]=l>>>12&63,i[a++]=l>>>18&63,i[a++]=l>>>24&63,i[a++]=63&(l>>>30|(15&h)<<2),i[a++]=h>>>4&63,i[a++]=h>>>10&63,i[a++]=h>>>16&63,i[a++]=h>>>22&63,i[a++]=63&(h>>>28|(3&u)<<4),i[a++]=u>>>2&63,i[a++]=u>>>8&63,i[a++]=u>>>14&63,i[a++]=u>>>20&63,i[a]=u>>>26&63}(e,t,i,r);case 7:return void function(e,t,i,r){let a=r,n=e[t]>>>0,s=e[t+1]>>>0,o=e[t+2]>>>0,l=e[t+3]>>>0,h=e[t+4]>>>0,u=e[t+5]>>>0,c=e[t+6]>>>0;i[a++]=n>>>0&127,i[a++]=n>>>7&127,i[a++]=n>>>14&127,i[a++]=n>>>21&127,i[a++]=127&(n>>>28|(7&s)<<4),i[a++]=s>>>3&127,i[a++]=s>>>10&127,i[a++]=s>>>17&127,i[a++]=s>>>24&127,i[a++]=127&(s>>>31|(63&o)<<1),i[a++]=o>>>6&127,i[a++]=o>>>13&127,i[a++]=o>>>20&127,i[a++]=127&(o>>>27|(3&l)<<5),i[a++]=l>>>2&127,i[a++]=l>>>9&127,i[a++]=l>>>16&127,i[a++]=l>>>23&127,i[a++]=127&(l>>>30|(31&h)<<2),i[a++]=h>>>5&127,i[a++]=h>>>12&127,i[a++]=h>>>19&127,i[a++]=127&(h>>>26|(1&u)<<6),i[a++]=u>>>1&127,i[a++]=u>>>8&127,i[a++]=u>>>15&127,i[a++]=u>>>22&127,i[a++]=127&(u>>>29|(15&c)<<3),i[a++]=c>>>4&127,i[a++]=c>>>11&127,i[a++]=c>>>18&127,i[a]=c>>>25&127}(e,t,i,r);case 8:return void function(e,t,i,r){let a=r,n=e[t]>>>0,s=e[t+1]>>>0,o=e[t+2]>>>0,l=e[t+3]>>>0,h=e[t+4]>>>0,u=e[t+5]>>>0,c=e[t+6]>>>0,p=e[t+7]>>>0;i[a++]=n>>>0&255,i[a++]=n>>>8&255,i[a++]=n>>>16&255,i[a++]=n>>>24&255,i[a++]=s>>>0&255,i[a++]=s>>>8&255,i[a++]=s>>>16&255,i[a++]=s>>>24&255,i[a++]=o>>>0&255,i[a++]=o>>>8&255,i[a++]=o>>>16&255,i[a++]=o>>>24&255,i[a++]=l>>>0&255,i[a++]=l>>>8&255,i[a++]=l>>>16&255,i[a++]=l>>>24&255,i[a++]=h>>>0&255,i[a++]=h>>>8&255,i[a++]=h>>>16&255,i[a++]=h>>>24&255,i[a++]=u>>>0&255,i[a++]=u>>>8&255,i[a++]=u>>>16&255,i[a++]=u>>>24&255,i[a++]=c>>>0&255,i[a++]=c>>>8&255,i[a++]=c>>>16&255,i[a++]=c>>>24&255,i[a++]=p>>>0&255,i[a++]=p>>>8&255,i[a++]=p>>>16&255,i[a]=p>>>24&255}(e,t,i,r);case 9:return void function(e,t,i,r){let a=r,n=e[t]>>>0,s=e[t+1]>>>0,o=e[t+2]>>>0,l=e[t+3]>>>0,h=e[t+4]>>>0,u=e[t+5]>>>0,c=e[t+6]>>>0,p=e[t+7]>>>0,d=e[t+8]>>>0;i[a++]=n>>>0&511,i[a++]=n>>>9&511,i[a++]=n>>>18&511,i[a++]=511&(n>>>27|(15&s)<<5),i[a++]=s>>>4&511,i[a++]=s>>>13&511,i[a++]=s>>>22&511,i[a++]=511&(s>>>31|(255&o)<<1),i[a++]=o>>>8&511,i[a++]=o>>>17&511,i[a++]=511&(o>>>26|(7&l)<<6),i[a++]=l>>>3&511,i[a++]=l>>>12&511,i[a++]=l>>>21&511,i[a++]=511&(l>>>30|(127&h)<<2),i[a++]=h>>>7&511,i[a++]=h>>>16&511,i[a++]=511&(h>>>25|(3&u)<<7),i[a++]=u>>>2&511,i[a++]=u>>>11&511,i[a++]=u>>>20&511,i[a++]=511&(u>>>29|(63&c)<<3),i[a++]=c>>>6&511,i[a++]=c>>>15&511,i[a++]=511&(c>>>24|(1&p)<<8),i[a++]=p>>>1&511,i[a++]=p>>>10&511,i[a++]=p>>>19&511,i[a++]=511&(p>>>28|(31&d)<<4),i[a++]=d>>>5&511,i[a++]=d>>>14&511,i[a]=d>>>23&511}(e,t,i,r);case 10:return void function(e,t,i,r){let a=r,n=e[t]>>>0,s=e[t+1]>>>0,o=e[t+2]>>>0,l=e[t+3]>>>0,h=e[t+4]>>>0,u=e[t+5]>>>0,c=e[t+6]>>>0,p=e[t+7]>>>0,d=e[t+8]>>>0,f=e[t+9]>>>0;i[a++]=n>>>0&1023,i[a++]=n>>>10&1023,i[a++]=n>>>20&1023,i[a++]=1023&(n>>>30|(255&s)<<2),i[a++]=s>>>8&1023,i[a++]=s>>>18&1023,i[a++]=1023&(s>>>28|(63&o)<<4),i[a++]=o>>>6&1023,i[a++]=o>>>16&1023,i[a++]=1023&(o>>>26|(15&l)<<6),i[a++]=l>>>4&1023,i[a++]=l>>>14&1023,i[a++]=1023&(l>>>24|(3&h)<<8),i[a++]=h>>>2&1023,i[a++]=h>>>12&1023,i[a++]=h>>>22&1023,i[a++]=u>>>0&1023,i[a++]=u>>>10&1023,i[a++]=u>>>20&1023,i[a++]=1023&(u>>>30|(255&c)<<2),i[a++]=c>>>8&1023,i[a++]=c>>>18&1023,i[a++]=1023&(c>>>28|(63&p)<<4),i[a++]=p>>>6&1023,i[a++]=p>>>16&1023,i[a++]=1023&(p>>>26|(15&d)<<6),i[a++]=d>>>4&1023,i[a++]=d>>>14&1023,i[a++]=1023&(d>>>24|(3&f)<<8),i[a++]=f>>>2&1023,i[a++]=f>>>12&1023,i[a]=f>>>22&1023}(e,t,i,r);case 11:return void function(e,t,i,r){let a=r,n=e[t]>>>0,s=e[t+1]>>>0,o=e[t+2]>>>0,l=e[t+3]>>>0,h=e[t+4]>>>0,u=e[t+5]>>>0,c=e[t+6]>>>0,p=e[t+7]>>>0,d=e[t+8]>>>0,f=e[t+9]>>>0,m=e[t+10]>>>0;i[a++]=n>>>0&2047,i[a++]=n>>>11&2047,i[a++]=2047&(n>>>22|(1&s)<<10),i[a++]=s>>>1&2047,i[a++]=s>>>12&2047,i[a++]=2047&(s>>>23|(3&o)<<9),i[a++]=o>>>2&2047,i[a++]=o>>>13&2047,i[a++]=2047&(o>>>24|(7&l)<<8),i[a++]=l>>>3&2047,i[a++]=l>>>14&2047,i[a++]=2047&(l>>>25|(15&h)<<7),i[a++]=h>>>4&2047,i[a++]=h>>>15&2047,i[a++]=2047&(h>>>26|(31&u)<<6),i[a++]=u>>>5&2047,i[a++]=u>>>16&2047,i[a++]=2047&(u>>>27|(63&c)<<5),i[a++]=c>>>6&2047,i[a++]=c>>>17&2047,i[a++]=2047&(c>>>28|(127&p)<<4),i[a++]=p>>>7&2047,i[a++]=p>>>18&2047,i[a++]=2047&(p>>>29|(255&d)<<3),i[a++]=d>>>8&2047,i[a++]=d>>>19&2047,i[a++]=2047&(d>>>30|(511&f)<<2),i[a++]=f>>>9&2047,i[a++]=f>>>20&2047,i[a++]=2047&(f>>>31|(1023&m)<<1),i[a++]=m>>>10&2047,i[a]=m>>>21&2047}(e,t,i,r);case 12:return void function(e,t,i,r){let a=r,n=e[t]>>>0,s=e[t+1]>>>0,o=e[t+2]>>>0,l=e[t+3]>>>0,h=e[t+4]>>>0,u=e[t+5]>>>0,c=e[t+6]>>>0,p=e[t+7]>>>0,d=e[t+8]>>>0,f=e[t+9]>>>0,m=e[t+10]>>>0,_=e[t+11]>>>0;i[a++]=n>>>0&4095,i[a++]=n>>>12&4095,i[a++]=4095&(n>>>24|(15&s)<<8),i[a++]=s>>>4&4095,i[a++]=s>>>16&4095,i[a++]=4095&(s>>>28|(255&o)<<4),i[a++]=o>>>8&4095,i[a++]=o>>>20&4095,i[a++]=l>>>0&4095,i[a++]=l>>>12&4095,i[a++]=4095&(l>>>24|(15&h)<<8),i[a++]=h>>>4&4095,i[a++]=h>>>16&4095,i[a++]=4095&(h>>>28|(255&u)<<4),i[a++]=u>>>8&4095,i[a++]=u>>>20&4095,i[a++]=c>>>0&4095,i[a++]=c>>>12&4095,i[a++]=4095&(c>>>24|(15&p)<<8),i[a++]=p>>>4&4095,i[a++]=p>>>16&4095,i[a++]=4095&(p>>>28|(255&d)<<4),i[a++]=d>>>8&4095,i[a++]=d>>>20&4095,i[a++]=f>>>0&4095,i[a++]=f>>>12&4095,i[a++]=4095&(f>>>24|(15&m)<<8),i[a++]=m>>>4&4095,i[a++]=m>>>16&4095,i[a++]=4095&(m>>>28|(255&_)<<4),i[a++]=_>>>8&4095,i[a]=_>>>20&4095}(e,t,i,r);case 16:return void function(e,t,i,r){let a=r,n=e[t]>>>0,s=e[t+1]>>>0,o=e[t+2]>>>0,l=e[t+3]>>>0,h=e[t+4]>>>0,u=e[t+5]>>>0,c=e[t+6]>>>0,p=e[t+7]>>>0,d=e[t+8]>>>0,f=e[t+9]>>>0,m=e[t+10]>>>0,_=e[t+11]>>>0,g=e[t+12]>>>0,y=e[t+13]>>>0,v=e[t+14]>>>0,x=e[t+15]>>>0;i[a++]=n>>>0&65535,i[a++]=n>>>16&65535,i[a++]=s>>>0&65535,i[a++]=s>>>16&65535,i[a++]=o>>>0&65535,i[a++]=o>>>16&65535,i[a++]=l>>>0&65535,i[a++]=l>>>16&65535,i[a++]=h>>>0&65535,i[a++]=h>>>16&65535,i[a++]=u>>>0&65535,i[a++]=u>>>16&65535,i[a++]=c>>>0&65535,i[a++]=c>>>16&65535,i[a++]=p>>>0&65535,i[a++]=p>>>16&65535,i[a++]=d>>>0&65535,i[a++]=d>>>16&65535,i[a++]=f>>>0&65535,i[a++]=f>>>16&65535,i[a++]=m>>>0&65535,i[a++]=m>>>16&65535,i[a++]=_>>>0&65535,i[a++]=_>>>16&65535,i[a++]=g>>>0&65535,i[a++]=g>>>16&65535,i[a++]=y>>>0&65535,i[a++]=y>>>16&65535,i[a++]=v>>>0&65535,i[a++]=v>>>16&65535,i[a++]=x>>>0&65535,i[a]=x>>>16&65535}(e,t,i,r);case 32:for(let a=0;a<32;a=a+1|0)i[r+a|0]=0|e[t+a|0];return}let n=ed[a]>>>0,s=t,o=0,l=e[s]>>>0;for(let h=0;h<32;h++)if(o+a<=32){let t=l>>>o&n;i[r+h]=0|t,o+=a,32===o&&(o=0,s++,31!==h&&(l=e[s]>>>0))}else{let t=32-o,u=l>>>o;s++,l=e[s]>>>0;let c=(u|(l&ed[a-t]>>>0)<<t)&n;i[r+h]=0|c,o=a-t}}function _d(e,t,i){let r=new Uint32Array(i),a=0,n=t.get();for(let s=0;s<r.length;s++){let t=e[n++],i=127&t;t<128||(t=e[n++],i|=(127&t)<<7,t<128||(t=e[n++],i|=(127&t)<<14,t<128||(t=e[n++],i|=(127&t)<<21,t<128||(t=e[n++],i|=(15&t)<<28)))),r[a++]=i}return t.set(n),r}function gd(e,t,i){let r=new BigUint64Array(i);for(let a=0;a<r.length;a++)r[a]=yd(e,t);return r}function yd(e,t){let i=0n,r=0,a=t.get();for(;a<e.length;){let t=e[a++];if(i|=BigInt(127&t)<<BigInt(r),!(128&t))break;if(r+=7,r>=64)throw Error("Varint too long")}return t.set(a),i}function vd(e,t){let i,r;return r=e[t.get()],t.increment(),i=127&r,r<128||(r=e[t.get()],t.increment(),i|=(127&r)<<7,r<128)||(r=e[t.get()],t.increment(),i|=(127&r)<<14,r<128)||(r=e[t.get()],t.increment(),i|=(127&r)<<21,r<128)?i:(r=e[t.get()],i|=(15&r)<<28,function(e,t,i){let r,a;if(a=t[i.get()],i.increment(),r=(112&a)>>4,a<128||(a=t[i.get()],i.increment(),r|=(127&a)<<3,a<128)||(a=t[i.get()],i.increment(),r|=(127&a)<<10,a<128)||(a=t[i.get()],i.increment(),r|=(127&a)<<17,a<128)||(a=t[i.get()],i.increment(),r|=(127&a)<<24,a<128)||(a=t[i.get()],i.increment(),r|=(1&a)<<31,a<128))return 4294967296*r+(e>>>0);throw Error("Expected varint not more than 10 bytes")}(i,e,t))}function xd(e,t,i,r){return function(e,t,i,r,a){let n=r.get();if(3&i)throw Error(`FastPFOR: invalid encodedByteLength=${i} at offset=${n} (encodedBytes.length=${e.length}; expected a multiple of 4 bytes for an int32 big-endian word stream)`);let s=i>>>2,o=function(e,t){if(t<=e.encodedWords.length)return e.encodedWords;let i=new Uint32Array(Math.max(16,2*t));return e.encodedWords=i,i}(a,s);!function(e,t,i,r){if(t<0||i<0||t+i>e.length)throw RangeError(`decodeBigEndianInt32sInto: out of bounds (offset=${t}, byteLength=${i}, bytes.length=${e.length})`);let a=Math.floor(i/4),n=i%4!=0,s=n?a+1:a;if(r.length<s)throw RangeError(`decodeBigEndianInt32sInto: out.length=${r.length} < ${s}`);if(a>0){let i=e.byteOffset+t;if(3&i)for(let n=0;n<a;n++){let i=t+4*n;r[n]=e[i]<<24|e[i+1]<<16|e[i+2]<<8|e[i+3]}else{let t=new Uint32Array(e.buffer,i,a);for(let e=0;e<a;e++)r[e]=0|rd(t[e])}}if(n){let n=t+4*a,s=i-4*a,o=0;for(let t=0;t<s;t++)o|=e[n+t]<<24-8*t;r[a]=0|o}}(e,n,i,o);let l=function(e,t,i){let r=0,a=0,n=new Uint32Array(t),s=i??ud();if(e.length>0){let t=0|e[r];if(r=r+1|0,255&t)throw Error(`FastPFOR decode: invalid alignedLength=${t} (expected multiple of 256)`);if(a+t>n.length)throw Error(`FastPFOR decode: output buffer too small (outPos=${a}, alignedLength=${t}, out.length=${n.length})`);r=function(e,t,i,r,a,n){let s=r+td(a,256),o=r,l=i;for(;o!==s;){let i=Math.min(ld,s-o);l=fd(e,t,l,o,i,n),o=o+i|0}return l}(e,n,r,a,t,s),a=a+t|0}return function(e,t,i,r,a,n){if(0===n)return t;let s=0,o=t,l=t+i,h=a,u=a,c=a+n,p=0,d=0;for(;o<l&&u<c;){let t=e[o]>>>s&255;if(s+=8,o+=s>>>5,s&=31,p|=(127&t)<<d,128&t)r[u++]=0|p,p=0,d=0;else if(d+=7,d>28)throw Error(`FastPFOR VByte: unterminated value (expected MSB=1 terminator within 5 bytes; shift=${d}, partial=${p}, decoded=${u-h}/${n}, inPos=${o}, inEnd=${l})`)}if(u!==c)throw Error(`FastPFOR VByte: truncated stream (decoded=${u-h}, expected=${n}, consumedWords=${o-t}/${i}, vbyteStart=${t}, vbyteEnd=${l})`)}(e,r,e.length-r|0,n,a,t-a|0),n}(o.subarray(0,s),t,a.decoderWorkspace);return r.add(i),l}(e,t,i,r,function(e=16){if(e<0)throw RangeError(`initialEncodedWordCapacity must be >= 0, got ${e}`);let t=Math.max(16,0|e);return{encodedWords:new Uint32Array(t),decoderWorkspace:ud()}}(i>>>2))}function bd(e){return e>>>1^-(1&e)}function wd(e){return e>>1n^-(1n&e)}function Td(e){return e%2==1?(e+1)/-2:e/2}function Sd(e,t,i){if(void 0===i){i=0;for(let r=0;r<t;r++)i+=e[r]}let r=new Uint32Array(i),a=0;for(let n=0;n<t;n++){let i=e[n],s=e[n+t];r.fill(s,a,a+i),a+=i}return r}function Pd(e,t,i){if(void 0===i){i=0;for(let r=0;r<t;r++)i+=Number(e[r])}let r=new BigUint64Array(i),a=0;for(let n=0;n<t;n++){let i=Number(e[n]),s=e[n+t];r.fill(s,a,a+i),a+=i}return r}function Id(e,t,i){let r=new Float64Array(i),a=0;for(let n=0;n<t;n++){let i=e[n],s=e[n+t];r.fill(s,a,a+i),a+=i}return r}function Md(e){let t=new Int32Array(e.length);t[0]=bd(e[0]);let i=e.length/4*4,r=1;if(i>=4)for(;r<i-4;r+=4){let i=e[r],a=e[r+1],n=e[r+2],s=e[r+3];t[r]=bd(i)+t[r-1],t[r+1]=bd(a)+t[r],t[r+2]=bd(n)+t[r+1],t[r+3]=bd(s)+t[r+2]}for(;r!==e.length;++r)t[r]=bd(e[r])+t[r-1];return t}function Ed(e){let t=new BigInt64Array(e.length);t[0]=wd(e[0]);let i=e.length/4*4,r=1;if(i>=4)for(;r<i-4;r+=4){let i=e[r],a=e[r+1],n=e[r+2],s=e[r+3];t[r]=wd(i)+t[r-1],t[r+1]=wd(a)+t[r],t[r+2]=wd(n)+t[r+1],t[r+3]=wd(s)+t[r+2]}for(;r!==t.length;++r)t[r]=wd(e[r])+t[r-1];return t}function Ad(e){let t=e.length/4*4,i=1;if(t>=4)for(let r=e[0];i<t-4;i+=4)r=e[i]+=r,r=e[i+1]+=r,r=e[i+2]+=r,r=e[i+3]+=r;for(;i!==e.length;)e[i]+=e[i-1],++i}function Cd(e,t,i,r){if(e.length<2)return new Int32Array(e);let a=new Int32Array(e.length),n=bd(e[0]),s=bd(e[1]);a[0]=Dd(Math.round(n*t),i,r),a[1]=Dd(Math.round(s*t),i,r);let o=e.length/16,l=2;if(o>=4)for(;l<o-4;l+=4){let o=e[l],h=e[l+1],u=bd(o)+n,c=bd(h)+s;a[l]=Dd(Math.round(u*t),i,r),a[l+1]=Dd(Math.round(c*t),i,r);let p=e[l+2],d=e[l+3];n=bd(p)+u,s=bd(d)+c,a[l+2]=Dd(Math.round(n*t),i,r),a[l+3]=Dd(Math.round(s*t),i,r)}for(;l!==e.length;l+=2)n+=bd(e[l]),s+=bd(e[l+1]),a[l]=Dd(Math.round(n*t),i,r),a[l+1]=Dd(Math.round(s*t),i,r);return a}function Dd(e,t,i){return Math.min(i,Math.max(t,e))}function zd(e){let t=new Uint32Array(e.length);t[0]=bd(e[0])>>>0;for(let i=1;i<e.length;i++)t[i]=t[i-1]+bd(e[i])>>>0;return t}function Rd(e){let t=new BigUint64Array(e.length);t[0]=BigInt.asUintN(64,wd(e[0]));for(let i=1;i<e.length;i++)t[i]=BigInt.asUintN(64,t[i-1]+wd(e[i]));return t}!function(e){e.PRESENT="PRESENT",e.DATA="DATA",e.OFFSET="OFFSET",e.LENGTH="LENGTH"}(ad||={}),function(e){e.NONE="NONE",e.SINGLE="SINGLE",e.SHARED="SHARED",e.VERTEX="VERTEX",e.MORTON="MORTON",e.FSST="FSST"}(nd||={}),function(e){e.VERTEX="VERTEX",e.INDEX="INDEX",e.STRING="STRING",e.KEY="KEY"}(sd||={}),function(e){e.VAR_BINARY="VAR_BINARY",e.GEOMETRIES="GEOMETRIES",e.PARTS="PARTS",e.RINGS="RINGS",e.TRIANGLES="TRIANGLES",e.SYMBOL="SYMBOL",e.DICTIONARY="DICTIONARY"}(od||={});var kd,Ld=[ad.PRESENT,ad.DATA,ad.OFFSET,ad.LENGTH],Fd=[Vp.NONE,Vp.DELTA,Vp.COMPONENTWISE_DELTA,Vp.RLE,Vp.MORTON,Vp.PDE],Bd=[jp.NONE,jp.FAST_PFOR,jp.VARINT],Od=[nd.NONE,nd.SINGLE,nd.SHARED,nd.VERTEX,nd.MORTON,nd.FSST],Vd=[sd.VERTEX,sd.INDEX,sd.STRING,sd.KEY],jd=[od.VAR_BINARY,od.GEOMETRIES,od.PARTS,od.RINGS,od.TRIANGLES,od.SYMBOL,od.DICTIONARY];function Nd(e,t){let i=function(e,t){let i=e[t.get()],r=Ld[i>>4],a={};switch(r){case ad.DATA:a={dictionaryType:Od[15&i]};break;case ad.OFFSET:a={offsetType:Vd[15&i]};break;case ad.LENGTH:a={lengthType:jd[15&i]}}t.increment();let n=e[t.get()],s=Fd[n>>5],o=Fd[n>>2&7],l=Bd[3&n];t.increment();let h=_d(e,t,2),u=h[0];return{physicalStreamType:r,logicalStreamType:a,logicalLevelTechnique1:s,logicalLevelTechnique2:o,physicalLevelTechnique:l,numValues:u,byteLength:h[1],decompressedCount:u}}(e,t);return i.logicalLevelTechnique1===Vp.MORTON?function(e,t,i){let r=_d(t,i,2);return{physicalStreamType:e.physicalStreamType,logicalStreamType:e.logicalStreamType,logicalLevelTechnique1:e.logicalLevelTechnique1,logicalLevelTechnique2:e.logicalLevelTechnique2,physicalLevelTechnique:e.physicalLevelTechnique,numValues:e.numValues,byteLength:e.byteLength,decompressedCount:e.decompressedCount,numBits:r[0],coordinateShift:r[1]}}(i,e,t):Vp.RLE!==i.logicalLevelTechnique1&&Vp.RLE!==i.logicalLevelTechnique2||jp.NONE===i.physicalLevelTechnique?i:function(e,t,i){let r=_d(t,i,2);return{physicalStreamType:e.physicalStreamType,logicalStreamType:e.logicalStreamType,logicalLevelTechnique1:e.logicalLevelTechnique1,logicalLevelTechnique2:e.logicalLevelTechnique2,physicalLevelTechnique:e.physicalLevelTechnique,numValues:e.numValues,byteLength:e.byteLength,decompressedCount:r[1],runs:r[0],numRleValues:r[1]}}(i,e,t)}!function(e){e[e.FLAT=0]="FLAT",e[e.CONST=1]="CONST",e[e.SEQUENCE=2]="SEQUENCE",e[e.DICTIONARY=3]="DICTIONARY",e[e.FSST_DICTIONARY=4]="FSST_DICTIONARY"}(kd||={});var Ud=class{constructor(e,t){this.values=e,this._size=t}get(e){let t=Math.floor(e/8),i=e%8;return 1==(this.values[t]>>i&1)}set(e,t){let i=Math.floor(e/8),r=e%8;this.values[i]=this.values[i]|+!!t<<r}getInt(e){let t=Math.floor(e/8),i=e%8;return this.values[t]>>i&1}size(){return this._size}getBuffer(){return this.values}};function Gd(e,t,i){if(!t)return e;let r=t.size(),a=new(0,e.constructor)(r),n=0;for(let s=0;s<r;s++)a[s]=t.get(s)?e[n++]:i;return a}function $d(e,t,i,r,a){return function(e,t,i,r){let a;switch(t.logicalLevelTechnique1){case Vp.DELTA:if(t.logicalLevelTechnique2===Vp.RLE){let i=t;if(!r)return function(e,t,i){let r=new Int32Array(i),a=0,n=0;for(let s=0;s<t;s++){let i=e[s],o=bd(e[s+t]);for(let e=0;e<i;e++)n+=o,r[a++]=n}return r}(e,i.runs,i.numRleValues);a=Md(e=Sd(e,i.runs,i.numRleValues))}else a=Md(e);break;case Vp.RLE:a=function(e,t,i){if(void 0===i){i=0;for(let r=0;r<t;r++)i+=e[r]}let r=new Int32Array(i),a=0;for(let n=0;n<t;n++){let i=e[n],s=e[n+t];s=bd(s),r.fill(s,a,a+i),a+=i}return r}(e,t.runs,t.numRleValues);break;case Vp.MORTON:Ad(e),a=new Int32Array(e);break;case Vp.COMPONENTWISE_DELTA:if(i&&!r)return Cd(e,i.scale,i.min,i.max);a=function(e){if(e.length<2)return new Int32Array(e);let t=new Int32Array(e.length);t[0]=bd(e[0]),t[1]=bd(e[1]);let i=e.length/4*4,r=2;if(i>=4)for(;r<i-4;r+=4){let i=e[r],a=e[r+1],n=e[r+2],s=e[r+3];t[r]=bd(i)+t[r-2],t[r+1]=bd(a)+t[r-1],t[r+2]=bd(n)+t[r],t[r+3]=bd(s)+t[r+1]}for(;r!==e.length;r+=2)t[r]=bd(e[r])+t[r-2],t[r+1]=bd(e[r+1])+t[r-1];return t}(e);break;case Vp.NONE:a=function(e){let t=new Int32Array(e.length);for(let i=0;i<e.length;i++)t[i]=bd(e[i]);return t}(e);break;default:throw Error(`The specified Logical level technique is not supported: ${t.logicalLevelTechnique1}`)}return r?Gd(a,r,0):a}(Wd(e,t,i),i,r,a)}function Zd(e,t,i,r,a){return function(e,t,i,r){let a;switch(t.logicalLevelTechnique1){case Vp.DELTA:if(t.logicalLevelTechnique2===Vp.RLE){let i=t;a=zd(Sd(e,i.runs,i.numRleValues))}else a=zd(e);break;case Vp.RLE:a=Sd(e,t.runs,t.numRleValues);break;case Vp.MORTON:Ad(e),a=e;break;case Vp.COMPONENTWISE_DELTA:a=i&&!r?function(e,t,i,r){let a=Cd(e,t,i,r);return new Uint32Array(a)}(e,i.scale,i.min,i.max):function(e){if(e.length<2)return new Uint32Array(e);let t=new Uint32Array(e.length);t[0]=bd(e[0])>>>0,t[1]=bd(e[1])>>>0;for(let i=2;i<e.length;i+=2)t[i]=t[i-2]+bd(e[i])>>>0,t[i+1]=t[i-1]+bd(e[i+1])>>>0;return t}(e);break;case Vp.NONE:a=e;break;default:throw Error(`The specified Logical level technique is not supported: ${t.logicalLevelTechnique1}`)}return r?Gd(a,r,0):a}(Wd(e,t,i),i,r,a)}function qd(e,t,i){return function(e,t){if(t.logicalLevelTechnique1===Vp.DELTA&&t.logicalLevelTechnique2===Vp.NONE)return function(e){let t=new Int32Array(e.length+1);t[0]=0,t[1]=bd(e[0]);let i=t[1];for(let r=2;r!==t.length;++r)i+=bd(e[r-1]),t[r]=t[r-1]+i;return new Uint32Array(t)}(e);if(t.logicalLevelTechnique1===Vp.RLE&&t.logicalLevelTechnique2===Vp.NONE){let i=t;return function(e,t,i){let r=new Uint32Array(i+1);r[0]=0;let a=1,n=r[0];for(let s=0;s<t;s++){let i=e[s],o=e[s+t];for(let e=a;e<a+i;e++)r[e]=o+n,n=r[e];a+=i}return r}(e,i.runs,i.numRleValues)}if(t.logicalLevelTechnique1===Vp.NONE&&t.logicalLevelTechnique2===Vp.NONE){!function(e){let t=0;for(let i=0;i<e.length;i++)e[i]+=t,t=e[i]}(e);let i=new Uint32Array(t.numValues+1);return i[0]=0,i.set(e,1),i}if(t.logicalLevelTechnique1===Vp.DELTA&&t.logicalLevelTechnique2===Vp.RLE){let i=t,r=function(e,t,i){let r=new Int32Array(i+1);r[0]=0;let a=1,n=r[0];for(let s=0;s<t;s++){let i=e[s],o=e[s+t];o=bd(o);for(let e=a;e<a+i;e++)r[e]=o+n,n=r[e];a+=i}return r}(e,i.runs,i.numRleValues);return Ad(r),new Uint32Array(r)}throw Error("Only delta encoding is supported for transforming length to offset streams yet.")}(Wd(e,t,i),i)}function Wd(e,t,i){let r=i.physicalLevelTechnique;switch(r){case jp.FAST_PFOR:return xd(e,i.numValues,i.byteLength,t);case jp.VARINT:return _d(e,t,i.numValues);case jp.NONE:{let r=t.get(),a=i.byteLength;t.add(a);let n=e.subarray(r,t.get());return new Uint32Array(n)}default:throw Error(`Specified physicalLevelTechnique ${r} is not supported (yet).`)}}function Hd(e,t,i){let r=Wd(e,t,i);return 1===r.length?i.logicalLevelTechnique1===Vp.DELTA?bd(r[0]):r[0]:function(e){return e[1]}(r)}function Xd(e,t,i){return function(e){if(2===e.length){let t=bd(e[1]);return[t,t]}return[bd(e[2]),bd(e[3])]}(Wd(e,t,i))}function Yd(e,t,i){return function(e){if(2===e.length){let t=wd(e[1]);return[t,t]}return[wd(e[2]),wd(e[3])]}(gd(e,t,i.numValues))}function Kd(e,t,i,r){return function(e,t,i){let r;switch(t.logicalLevelTechnique1){case Vp.DELTA:if(t.logicalLevelTechnique2===Vp.RLE){let i=t;r=Rd(Pd(e,i.runs,i.numRleValues))}else r=Rd(e);break;case Vp.RLE:r=Pd(e,t.runs,t.numRleValues);break;case Vp.NONE:r=e;break;default:throw Error(`The specified Logical level technique is not supported: ${t.logicalLevelTechnique1}`)}return i?Gd(r,i,0n):r}(gd(e,t,i.numValues),i,r)}function Jd(e,t,i){let r=gd(e,t,i.numValues);return 1===r.length?i.logicalLevelTechnique1===Vp.DELTA?wd(r[0]):r[0]:function(e){return e[1]}(r)}function Qd(e,t,i,r,a="int32"){let n=e.logicalLevelTechnique1;if(n===Vp.RLE)return 1===e.runs?kd.CONST:kd.FLAT;if(n!==Vp.DELTA||e.logicalLevelTechnique2!==Vp.RLE)return 1===e.numValues?kd.CONST:kd.FLAT;let s=t instanceof Ud?t.size():t,o=e;if(o.numRleValues!==s)return kd.FLAT;if(1===o.runs)return kd.SEQUENCE;if(2!==o.runs)return 1===e.numValues?kd.CONST:kd.FLAT;let l=r.get();if(e.physicalLevelTechnique===jp.VARINT)return function(e,t,i){let r=new Jp(t.get());if("int64"===i){let t=gd(e,r,4);return 2n===t[2]&&2n===t[3]}let a=_d(e,r,4);return 2===a[2]&&2===a[3]}(i,r,a)?kd.SEQUENCE:1===e.numValues?kd.CONST:kd.FLAT;let h=r.get(),u=new Int32Array(i.buffer,i.byteOffset+h,4);return r.set(l),2===u[2]&&2===u[3]?kd.SEQUENCE:1===e.numValues?kd.CONST:kd.FLAT}var ef,tf,rf,af=class extends Zp{getValueFromBuffer(e){return this.dataBuffer[e]}},nf=class extends Hp{constructor(e,t,i,r){super(e,BigInt64Array.of(t),i,r)}getValueFromBuffer(e){return this.dataBuffer[0]+BigInt(e)*this.delta}};function sf(e,t,i){return{x:of(e,t)-i,y:of(e>>1,t)-i}}function of(e,t){let i=0;for(let r=0;r<t;r++)i|=(e&1<<2*r)>>r;return i}function lf(e,t,i,r,a,n,s){return e===rf.MORTON?function(e,t,i,r,a,n){let s=Array(a?r+1:r);for(let o=0;o<r;o++){let r=sf(e[t[i+o]],n.numBits,n.coordinateShift);s[o]=new u(r.x,r.y)}return a&&(s[s.length-1]=s[0]),s}(t,i,r,a,n,s):function(e,t,i,r,a){let n=Array(a?r+1:r);for(let s=0;s<2*r;s+=2){let r=2*t[i+s/2],a=e[r],o=e[r+1];n[s/2]=new u(a,o)}return a&&(n[n.length-1]=n[0]),n}(t,i,r,a,n)}function hf(e,t,i,r){let a=Array(r?i+1:i);for(let n=0;n<2*i;n+=2){let i=e[t+n],r=e[t+n+1];a[n/2]=new u(i,r)}return r&&(a[a.length-1]=a[0]),a}!function(e){e[e.POINT=0]="POINT",e[e.LINESTRING=1]="LINESTRING",e[e.POLYGON=2]="POLYGON",e[e.MULTIPOINT=3]="MULTIPOINT",e[e.MULTILINESTRING=4]="MULTILINESTRING",e[e.MULTIPOLYGON=5]="MULTIPOLYGON"}(ef||={}),function(e){e[e.POINT=0]="POINT",e[e.LINESTRING=1]="LINESTRING",e[e.POLYGON=2]="POLYGON"}(tf||={}),function(e){e[e.MORTON=0]="MORTON",e[e.VEC_2=1]="VEC_2",e[e.VEC_3=2]="VEC_3"}(rf||={});var uf=class{constructor(e,t,i,r,a){this._vertexBufferType=e,this._topologyVector=t,this._vertexOffsets=i,this._vertexBuffer=r,this._mortonSettings=a}get vertexBufferType(){return this._vertexBufferType}get topologyVector(){return this._topologyVector}get vertexOffsets(){return this._vertexOffsets}get vertexBuffer(){return this._vertexBuffer}getSimpleEncodedVertex(e){let t=this.vertexOffsets?2*this.vertexOffsets[e]:2*e;return[this.vertexBuffer[t],this.vertexBuffer[t+1]]}getVertex(e){if(this.vertexOffsets&&this.mortonSettings){let t=this.vertexOffsets[e],i=sf(this.vertexBuffer[t],this.mortonSettings.numBits,this.mortonSettings.coordinateShift);return[i.x,i.y]}let t=this.vertexOffsets?2*this.vertexOffsets[e]:2*e;return[this.vertexBuffer[t],this.vertexBuffer[t+1]]}getGeometries(){return function(e){let t=Array(e.numGeometries),i=1,r=1,a=1,n=0,s=0,o=0,l=e.mortonSettings,h=e.topologyVector,c=h.geometryOffsets,p=h.partOffsets,d=h.ringOffsets,f=e.vertexOffsets,m=!f||0===f.length,_=e.containsPolygonGeometry(),g=e.vertexBuffer;for(let y=0;y<e.numGeometries;y++){let h=e.geometryType(y);switch(h){case ef.POINT:{let h,_;if(m)h=g[s++],_=g[s++];else if(e.vertexBufferType===rf.MORTON){let e=sf(g[f[o++]],l.numBits,l.coordinateShift);h=e.x,_=e.y}else{let e=2*f[o++];h=g[e],_=g[e+1]}t[n++]=[[new u(h,_)]],c&&a++,p&&i++,d&&r++}break;case ef.MULTIPOINT:{let e=c[a]-c[a-1];a++;let l=Array(e);if(m)for(let t=0;t<e;t++){let e=g[s++],i=g[s++];l[t]=new u(e,i)}else for(let t=0;t<e;t++){let e=2*f[o++],i=g[e],r=g[e+1];l[t]=new u(i,r)}t[n++]=l.map(e=>[e]),i+=e,r+=e}break;case ef.LINESTRING:{let h,u;_?(h=d[r]-d[r-1],r++):h=p[i]-p[i-1],i++,m?(u=hf(g,s,h,!1),s+=2*h):(u=lf(e.vertexBufferType,g,f,o,h,!1,l),o+=h),t[n++]=[u],c&&a++}break;case ef.POLYGON:{let h=p[i]-p[i-1];i++;let u,_=Array(h-1),y=d[r]-d[r-1];if(r++,m){u=hf(g,s,y,!0),s+=2*y;for(let e=0;e<_.length;e++)y=d[r]-d[r-1],r++,_[e]=hf(g,s,y,!0),s+=2*y}else{u=lf(e.vertexBufferType,g,f,o,y,!0,l),o+=y;for(let t=0;t<_.length;t++)y=d[r]-d[r-1],r++,_[t]=lf(e.vertexBufferType,g,f,o,y,!0,l),o+=y}t[n++]=[u].concat(_),c&&a++}break;case ef.MULTILINESTRING:{let h=c[a]-c[a-1];a++;let u=Array(h);for(let t=0;t<h;t++){let a;_?(a=d[r]-d[r-1],r++):a=p[i]-p[i-1],i++,m?(u[t]=hf(g,s,a,!1),s+=2*a):(u[t]=lf(e.vertexBufferType,g,f,o,a,!1,l),o+=a)}t[n++]=u}break;case ef.MULTIPOLYGON:{let h=c[a]-c[a-1];a++;let u=Array(h);for(let t=0;t<h;t++){let a=p[i]-p[i-1];i++;let n,h=Array(a-1),c=d[r]-d[r-1];r++,m?(n=hf(g,s,c,!0),s+=2*c):(n=lf(e.vertexBufferType,g,f,o,c,!0,l),o+=c);for(let t=0;t<h.length;t++){let i=d[r]-d[r-1];r++,m?(h[t]=hf(g,s,i,!0),s+=2*i):(h[t]=lf(e.vertexBufferType,g,f,o,i,!0,l),o+=i)}u[t]=[n].concat(h)}t[n++]=u.flat()}break;default:throw Error(`The specified geometry type (${h}) is currently not supported.`)}}return t}(this)}get mortonSettings(){return this._mortonSettings}},cf=class extends uf{constructor(e,t,i,r,a,n,s){super(i,r,a,n,s),this._numGeometries=e,this._geometryType=t}geometryType(e){return this._geometryType}get numGeometries(){return this._numGeometries}containsPolygonGeometry(){return this._geometryType===ef.POLYGON||this._geometryType===ef.MULTIPOLYGON}containsSingleGeometryType(){return!0}},pf=class extends uf{constructor(e,t,i,r,a,n){super(e,i,r,a,n),this._geometryTypes=t}geometryType(e){return this._geometryTypes[e]}get numGeometries(){return this._geometryTypes.length}containsPolygonGeometry(){for(let e=0;e<this.numGeometries;e++)if(this.geometryType(e)===ef.POLYGON||this.geometryType(e)===ef.MULTIPOLYGON)return!0;return!1}containsSingleGeometryType(){return!1}},df=class{constructor(e,t,i,r){this._triangleOffsets=e,this._indexBuffer=t,this._vertexBuffer=i,this._topologyVector=r}get triangleOffsets(){return this._triangleOffsets}get indexBuffer(){return this._indexBuffer}get vertexBuffer(){return this._vertexBuffer}get topologyVector(){return this._topologyVector}getGeometries(){if(!this._topologyVector)throw Error("Cannot convert GpuVector to coordinates without topology information");let e=Array(this.numGeometries),t=this._topologyVector,i=t.partOffsets,r=t.ringOffsets,a=t.geometryOffsets,n=0,s=1,o=1,l=1;for(let h=0;h<this.numGeometries;h++)switch(this.geometryType(h)){case ef.POLYGON:{let t=i[s]-i[s-1];s++;let c=[];for(let e=0;e<t;e++){let e=r[o]-r[o-1];o++;let t=[];for(let i=0;i<e;i++){let e=this._vertexBuffer[n++],i=this._vertexBuffer[n++];t.push(new u(e,i))}t.length>0&&t.push(t[0]),c.push(t)}e[h]=c,a&&l++}break;case ef.MULTIPOLYGON:{let t=a[l]-a[l-1];l++;let c=[];for(let e=0;e<t;e++){let e=i[s]-i[s-1];s++;for(let t=0;t<e;t++){let e=r[o]-r[o-1];o++;let t=[];for(let i=0;i<e;i++){let e=this._vertexBuffer[n++],i=this._vertexBuffer[n++];t.push(new u(e,i))}t.length>0&&t.push(t[0]),c.push(t)}}e[h]=c}}return e}[Symbol.iterator](){return null}};function ff(e,t,i,r,a,n){return new mf(e,t,i,r,a,n)}var mf=class extends df{constructor(e,t,i,r,a,n){super(i,r,a,n),this._numGeometries=e,this._geometryType=t}geometryType(e){return this._geometryType}get numGeometries(){return this._numGeometries}containsSingleGeometryType(){return!0}};function _f(e,t,i,r,a){return new gf(e,t,i,r,a)}var gf=class extends df{constructor(e,t,i,r,a){super(t,i,r,a),this._geometryTypes=e}geometryType(e){return this._geometryTypes[e]}get numGeometries(){return this._geometryTypes.length}containsSingleGeometryType(){return!1}};function yf(e,t,i,r,a){let n,s,o,l,h=Nd(e,i);if(Qd(h,r,e,i)===kd.CONST){let u,c,p,d,f=Hd(e,i,h);for(let r=0;r<t-1;r++){let t=Nd(e,i);switch(t.physicalStreamType){case ad.LENGTH:switch(t.logicalStreamType.lengthType){case od.GEOMETRIES:u=qd(e,i,t);break;case od.PARTS:c=qd(e,i,t);break;case od.RINGS:p=qd(e,i,t);break;case od.TRIANGLES:d=qd(e,i,t)}break;case ad.OFFSET:switch(t.logicalStreamType.offsetType){case sd.VERTEX:n=Zd(e,i,t);break;case sd.INDEX:l=Zd(e,i,t)}break;case ad.DATA:if(nd.VERTEX===t.logicalStreamType.dictionaryType)s=$d(e,i,t,a);else{let r=t;o={numBits:r.numBits,coordinateShift:r.coordinateShift},s=Zd(e,i,t,a)}}}return l?void 0!==u||void 0!==c?ff(r,f,d,l,s,{geometryOffsets:u,partOffsets:c,ringOffsets:p}):ff(r,f,d,l,s):void 0===o?function(e,t,i,r,a){return new cf(e,t,rf.VEC_2,i,r,a)}(r,f,{geometryOffsets:u,partOffsets:c,ringOffsets:p},n,s):function(e,t,i,r,a,n){return new cf(e,t,rf.MORTON,i,r,a,n)}(r,f,{geometryOffsets:u,partOffsets:c,ringOffsets:p},n,s,o)}let u,c,p,d,f,m,_,g=Zd(e,i,h);for(let y=0;y<t-1;y++){let t=Nd(e,i);switch(t.physicalStreamType){case ad.LENGTH:switch(t.logicalStreamType.lengthType){case od.GEOMETRIES:u=Zd(e,i,t);break;case od.PARTS:c=Zd(e,i,t);break;case od.RINGS:p=Zd(e,i,t);break;case od.TRIANGLES:d=qd(e,i,t)}break;case ad.OFFSET:switch(t.logicalStreamType.offsetType){case sd.VERTEX:n=Zd(e,i,t);break;case sd.INDEX:l=Zd(e,i,t)}break;case ad.DATA:if(nd.VERTEX===t.logicalStreamType.dictionaryType)s=$d(e,i,t,a);else{let r=t;o={numBits:r.numBits,coordinateShift:r.coordinateShift},s=Zd(e,i,t,a)}}}return u?(f=vf(g,u,2),c&&p?(m=xf(g,f,c,!1),_=function(e,t,i,r){let a=new Uint32Array(i[i.length-1]+1),n=0;a[0]=n;let s=1,o=1,l=0;for(let h=0;h<e.length;h++){let u=e[h],c=t[h+1]-t[h];if(0!==u&&3!==u)for(let e=0;e<c;e++){let e=i[s]-i[s-1];s++;for(let t=0;t<e;t++)n=a[o++]=n+r[l++]}else for(let e=0;e<c;e++)a[o++]=++n,s++}return a}(g,f,m,p)):c&&(m=function(e,t,i){let r=new Uint32Array(t[t.length-1]+1),a=0;r[0]=a;let n=1,s=0;for(let o=0;o<e.length;o++){let l=e[o],h=t[o+1]-t[o];if(4===l||1===l)for(let e=0;e<h;e++)a=r[n++]=a+i[s++];else for(let e=0;e<h;e++)r[n++]=++a}return r}(g,f,c))):c&&p?(m=vf(g,c,1),_=xf(g,m,p,!0)):c&&(m=vf(g,c,0)),l&&!m?_f(g,d,l,s):l?_f(g,d,l,s,{geometryOffsets:f,partOffsets:m,ringOffsets:_}):void 0===o?function(e,t,i,r){return new pf(rf.VEC_2,e,t,i,r)}(g,{geometryOffsets:f,partOffsets:m,ringOffsets:_},n,s):function(e,t,i,r,a){return new pf(rf.MORTON,e,t,i,r,a)}(g,{geometryOffsets:f,partOffsets:m,ringOffsets:_},n,s,o)}function vf(e,t,i){let r=new Uint32Array(e.length+1),a=0;r[0]=a;let n=0;for(let s=0;s<e.length;s++)a=r[s+1]=a+(e[s]>i?t[n++]:1);return r}function xf(e,t,i,r){let a=new Uint32Array(t[t.length-1]+1),n=0;a[0]=n;let s=1,o=0;for(let l=0;l<e.length;l++){let h=e[l],u=t[l+1]-t[l];if(5===h||2===h||r&&(4===h||1===h))for(let e=0;e<u;e++)n=a[s++]=n+i[o++];else for(let e=0;e<u;e++)a[s++]=++n}return a}var bf=class extends $p{constructor(e,t,i){super(e,t.getBuffer(),i),this.dataVector=t}getValueFromBuffer(e){return this.dataVector.get(e)}},wf=class extends Zp{getValueFromBuffer(e){return this.dataBuffer[e]}},Tf=class extends $p{constructor(e,t,i,r){super(e,r?BigInt64Array.of(t):BigUint64Array.of(t),i)}getValueFromBuffer(e){return this.dataBuffer[0]}};function Sf(e,t,i){for(let r=0;r<e;r++){let e=Nd(t,i);i.add(e.byteLength)}}function Pf(e,t,i,r,a){let n=function(e,t,i,r){let a=new Uint8Array(t),n=0,s=r.get()+i;for(;n<t&&!(r.get()>=s);){let i=e[r.increment()];if(i<=127){let s=i+3,o=e[r.increment()],l=Math.min(n+s,t);a.fill(o,n,l),n=l}else{let s=256-i;for(let i=0;i<s&&n<t;i++)a[n++]=e[r.increment()]}}return r.set(s),a}(e,Math.ceil(t/8),i,r);return a?function(e,t,i){if(!i)return e;let r=i.size(),a=new Ud(e,t),n=new Ud(new Uint8Array(Math.ceil(r/8)),r),s=0;for(let o=0;o<r;o++){let e=!!i.get(o)&&a.get(s++);n.set(o,e)}return n.getBuffer()}(n,t,a):n}var If=new TextDecoder;function Mf(e,t,i){return i-t>=12?If.decode(e.subarray(t,i)):function(e,t,i){let r="",a=t;for(;a<i;){let t,n,s,o=e[a],l=null,h=o>239?4:o>223?3:o>191?2:1;if(a+h>i)break;1===h?o<128&&(l=o):2===h?(t=e[a+1],128==(192&t)&&(l=(31&o)<<6|63&t,l<=127&&(l=null))):3===h?(t=e[a+1],n=e[a+2],128==(192&t)&&128==(192&n)&&(l=(15&o)<<12|(63&t)<<6|63&n,(l<=2047||l>=55296&&l<=57343)&&(l=null))):4===h&&(t=e[a+1],n=e[a+2],s=e[a+3],128==(192&t)&&128==(192&n)&&128==(192&s)&&(l=(15&o)<<18|(63&t)<<12|(63&n)<<6|63&s,(l<=65535||l>=1114112)&&(l=null))),null===l?(l=65533,h=1):l>65535&&(l-=65536,r+=String.fromCharCode(l>>>10&1023|55296),l=56320|1023&l),r+=String.fromCharCode(l),a+=h}return r}(e,t,i)}var Ef=class extends $p{constructor(e,t,i,r){super(e,i,r),this.offsetBuffer=t}},Af=class extends Ef{constructor(e,t,i,r){super(e,t,i,r??t.length-1)}getValueFromBuffer(e){let t=this.offsetBuffer[e],i=this.offsetBuffer[e+1];return Mf(this.dataBuffer,t,i)}},Cf=class extends Ef{constructor(e,t,i,r,a){super(e,i,r,a??t.length),this.indexBuffer=t,this.indexBuffer=t}getValueFromBuffer(e){let t=this.indexBuffer[e],i=this.offsetBuffer[t],r=this.offsetBuffer[t+1];return Mf(this.dataBuffer,i,r)}},Df=class extends Ef{constructor(e,t,i,r,a,n,s){super(e,i,r,s??t.length),this.indexBuffer=t,this.symbolOffsetBuffer=a,this.symbolTableBuffer=n}getValueFromBuffer(e){this.decodedDictionary??=(this.symbolLengthBuffer??=this.offsetToLengthBuffer(this.symbolOffsetBuffer),function(e,t,i){let r=[],a=Array(t.length).fill(0);for(let n=1;n<t.length;n++)a[n]=a[n-1]+t[n-1];for(let n=0;n<i.length;n++)if(255===i[n])r.push(i[++n]);else{let s=t[i[n]],o=a[i[n]];for(let t=0;t<s;t++)r.push(e[o+t])}return new Uint8Array(r)}(this.symbolTableBuffer,this.symbolLengthBuffer,this.dataBuffer));let t=this.indexBuffer[e],i=this.offsetBuffer[t],r=this.offsetBuffer[t+1];return Mf(this.decodedDictionary,i,r)}offsetToLengthBuffer(e){let t=new Uint32Array(e.length-1),i=e[0];for(let r=1;r<e.length;r++){let a=e[r];t[r-1]=a-i,i=a}return t}};function zf(e,t,i,r,a,n){return"scalarType"===i.type?n&&!n.has(i.name)?(Sf(r,e,t),null):function(e,t,i,r,a,n){let s=null;if(0===e)return null;if(n.nullable){let e=Nd(t,i),r=e.numValues,a=i.get(),n=Pf(t,r,e.byteLength,i);i.set(a+e.byteLength),s=new Ud(n,e.numValues)}let o=s??r;switch(a.physicalType){case 4:case 3:return function(e,t,i,r,a){let n=Nd(e,t),s=Qd(n,a,e,t),o=3===r.physicalType;if(s===kd.FLAT){let r=Rf(a)?a:void 0,s=o?$d(e,t,n,void 0,r):Zd(e,t,n,void 0,r);return new qp(i.name,s,a)}if(s===kd.SEQUENCE){let r=Xd(e,t,n);return new Xp(i.name,r[0],r[1],n.numRleValues)}let l=o?function(e,t,i){let r=Wd(e,t,i);return 1===r.length?bd(r[0]):function(e){return bd(e[1])}(r)}(e,t,n):Hd(e,t,n);return new Yp(i.name,l,a,o)}(t,i,n,a,o);case 9:{let r=n.nullable?e-1:e;return function(e,t,i,r,a){let n=null,s=null,o=null,l=null,h=null,u=a??null,c=null,p=null;for(let d=0;d<r;d++){let e=Nd(t,i);switch(e.physicalStreamType){case ad.PRESENT:{let r=new Ud(Pf(t,e.numValues,e.byteLength,i),e.numValues);u=a??r;break}case ad.OFFSET:s=Zd(t,i,e,void 0,u);break;case ad.LENGTH:{let r=qd(t,i,e);od.DICTIONARY===e.logicalStreamType.lengthType?n=r:od.SYMBOL===e.logicalStreamType.lengthType?l=r:c=r;break}case ad.DATA:{let r=t.subarray(i.get(),i.get()+e.byteLength);i.add(e.byteLength);let a=e.logicalStreamType.dictionaryType;nd.FSST===a?h=r:nd.SINGLE===a||nd.SHARED===a?o=r:nd.NONE===a&&(p=r);break}}}return function(e,t,i,r,a,n,s){return t?new Df(e,i,r,a,n,t,s):null}(e,h,s,n,o,l,u)??function(e,t,i,r,a){return t?a?new Cf(e,i,r,t,a):new Cf(e,i,r,t):null}(e,o,s,n,u)??function(e,t,i,r,a){if(!t||!i)return null;if(r)return a?new Cf(e,r,t,i,a):new Cf(e,r,t,i);if(a&&a.size()!==t.length-1){let r=new Uint32Array(a.size()),n=0;for(let e=0;e<a.size();e++)a.get(e)?r[e]=n++:r[e]=0;return new Cf(e,r,t,i,a)}return a?new Af(e,t,i,a):new Af(e,t,i)}(e,c,p,s,u)}(n.name,t,i,r,s)}case 0:return function(e,t,i,r,a){let n=Nd(e,t),s=n.numValues,o=t.get(),l=Rf(a)?a:void 0,h=Pf(e,s,n.byteLength,t,l);t.set(o+n.byteLength);let u=new Ud(h,s);return new bf(i.name,u,a)}(t,i,n,0,o);case 6:case 5:return function(e,t,i,r,a){let n=Nd(e,t),s=Qd(n,r,e,t,"int64"),o=5===a.physicalType;if(s===kd.FLAT){let a=Rf(r)?r:void 0,s=o?function(e,t,i,r){return function(e,t,i){let r;switch(t.logicalLevelTechnique1){case Vp.DELTA:if(t.logicalLevelTechnique2===Vp.RLE){let a=t;if(!i)return function(e,t,i){let r=new BigInt64Array(i),a=0,n=0n;for(let s=0;s<t;s++){let i=Number(e[s]),o=wd(e[s+t]);for(let e=0;e<i;e++)n+=o,r[a++]=n}return r}(e,a.runs,a.numRleValues);r=Ed(e=Pd(e,a.runs,a.numRleValues))}else r=Ed(e);break;case Vp.RLE:r=function(e,t,i){if(void 0===i){i=0;for(let r=0;r<t;r++)i+=Number(e[r])}let r=new BigInt64Array(i),a=0;for(let n=0;n<t;n++){let i=Number(e[n]),s=e[n+t];s=wd(s),r.fill(s,a,a+i),a+=i}return r}(e,t.runs,t.numRleValues);break;case Vp.NONE:r=function(e){let t=new BigInt64Array(e.length);for(let i=0;i<e.length;i++)t[i]=wd(e[i]);return t}(e);break;default:throw Error(`The specified Logical level technique is not supported: ${t.logicalLevelTechnique1}`)}return i?Gd(r,i,0n):r}(gd(e,t,i.numValues),i,r)}(e,t,n,a):Kd(e,t,n,a);return new af(i.name,s,r)}if(s===kd.SEQUENCE){let r=Yd(e,t,n);return new nf(i.name,r[0],r[1],n.numRleValues)}let l=o?function(e,t,i){let r=gd(e,t,i.numValues);return 1===r.length?wd(r[0]):function(e){return wd(e[1])}(r)}(e,t,n):Jd(e,t,n);return new Tf(i.name,l,r,o)}(t,i,n,o,a);case 7:return function(e,t,i,r){let a=Nd(e,t),n=Rf(r)?r:void 0,s=function(e,t,i,r){let a=t.get(),n=a+i*Float32Array.BYTES_PER_ELEMENT,s=new Uint8Array(e.subarray(a,n)).buffer,o=new Float32Array(s);return t.set(n),r?Gd(o,r,0):o}(e,t,a.numValues,n);return new wf(i.name,s,r)}(t,i,n,o);case 8:return function(e,t,i,r){let a=Nd(e,t),n=Rf(r)?r:void 0,s=function(e,t,i,r){let a=t.get(),n=a+i*Float64Array.BYTES_PER_ELEMENT,s=new Uint8Array(e.subarray(a,n)).buffer,o=new Float64Array(s);return t.set(n),r?Gd(o,r,0):o}(e,t,a.numValues,n);return new Wp(i.name,s,r)}(t,i,n,o);default:throw Error(`The specified data type for the field is currently not supported: ${a}`)}}(r,e,t,a,i.scalarType,i):0===r?null:function(e,t,i,r){let a=null,n=null,s=null,o=null,l=!1;for(;!l;){let i=Nd(e,t);switch(i.physicalStreamType){case ad.LENGTH:od.DICTIONARY===i.logicalStreamType.lengthType?a=qd(e,t,i):s=qd(e,t,i);break;case ad.DATA:nd.SINGLE===i.logicalStreamType.dictionaryType||nd.SHARED===i.logicalStreamType.dictionaryType?(n=e.subarray(t.get(),t.get()+i.byteLength),l=!0):o=e.subarray(t.get(),t.get()+i.byteLength),t.add(i.byteLength)}}let h=i.complexType.children,u=[],c=0;for(let p of h){let l=_d(e,t,1)[0];if(0===l)continue;let h,d=p.name?`${i.name}${p.name}`:i.name;if(r&&!r.has(d)){Sf(l,e,t);continue}if("scalarField"!==p.type||9!==p.scalarField.physicalType)throw Error("Currently only scalar string fields are implemented for a struct.");if(l>1&&!p.nullable||1===l&&p.nullable)throw Error(`The number of streams for the child field ${p.name} does not match its nullability. nullibilty: ${p.nullable}, numStreams: ${l}`);if(p.nullable){let i=Nd(e,t);h=new Ud(Pf(e,i.numValues,i.byteLength,t),i.numValues)}let f=Zd(e,t,Nd(e,t),void 0,h);u[c++]=o?new Df(d,f,a,n,s,o,h):new Cf(d,f,a,n,h)}return u}(e,t,i,n)}function Rf(e){return e instanceof Ud}function kf(e){switch(e){case 0:case 1:case 2:case 3:{let t={};t.nullable=!!(1&e),t.columnScope=0;let i={type:"logicalType",logicalType:0};return i.longID=!!(2&e),t.scalarType=i,t.type="scalarType",t}case 4:{let e={nullable:!1,columnScope:0},t={type:"physicalType",physicalType:0};return e.type="complexType",e.complexType=t,e}case 30:{let e={nullable:!1,columnScope:0},t={type:"physicalType",physicalType:1};return e.type="complexType",e.complexType=t,e}default:return function(e){let t;switch(e){case 10:case 11:t=0;break;case 12:case 13:t=1;break;case 14:case 15:t=2;break;case 16:case 17:t=3;break;case 18:case 19:t=4;break;case 20:case 21:t=5;break;case 22:case 23:t=6;break;case 24:case 25:t=7;break;case 26:case 27:t=8;break;case 28:case 29:t=9;break;default:return null}let i={};i.nullable=!!(1&e),i.columnScope=0;let r={type:"physicalType"};return r.physicalType=t,i.type="scalarType",i.scalarType=r,i}(e)}}function Lf(e){return e>=10}function Ff(e){return 30===e}function Bf(e){if("scalarType"===e.type){let t=e.scalarType;if("physicalType"===t.type)switch(t.physicalType){case 0:case 1:case 2:case 3:case 4:case 5:case 6:case 7:case 8:default:return!1;case 9:return!0}if("logicalType"===t.type)return!1}else if("complexType"===e.type){let t=e.complexType;if("physicalType"===t.type)switch(t.physicalType){case 0:case 1:return!0;default:return!1}}return console.warn("Unexpected column type in hasStreamCount",e),!1}function Of(e){return"scalarType"===e.type&&"logicalType"===e.scalarType?.type&&0===e.scalarType.logicalType}function Vf(e){return"complexType"===e.type&&"physicalType"===e.complexType?.type&&0===e.complexType.physicalType}var jf=new TextDecoder;function Nf(e,t){let i=_d(e,t,1)[0];if(0===i)return"";let r=t.get(),a=r+i,n=e.subarray(r,a);return t.add(i),jf.decode(n)}function Uf(e,t){let i=_d(e,t,1)[0]>>>0;if(i<10||i>30)throw Error(`Unsupported field type code ${i}. Supported: 10-29(scalars), 30(STRUCT)`);let r=kf(i);if(Lf(i)&&(r.name=Nf(e,t)),Ff(i)){let i=_d(e,t,1)[0]>>>0;r.complexType.children=Array(i);for(let a=0;a<i;a++)r.complexType.children[a]=Uf(e,t)}return function(e){return{name:e.name,nullable:e.nullable,scalarField:e.scalarType,complexField:e.complexType,type:"scalarType"===e.type?"scalarField":"complexField"}}(r)}function Gf(e,t){let i=_d(e,t,1)[0]>>>0,r=kf(i);if(!r)throw Error(`Unsupported column type code ${i}. Supported: 0-3(ID), 4(GEOMETRY), 10-29(scalars), 30(STRUCT)`);if(Lf(i)?r.name=Nf(e,t):i>=0&&i<=3?r.name="id":4===i&&(r.name="geometry"),Ff(i)){let i=_d(e,t,1)[0]>>>0,a=r.complexType;a.children=Array(i);for(let r=0;r<i;r++)a.children[r]=Uf(e,t)}return r}function $f(e,t){let i={featureTables:[]},r={};if(r.name=Nf(e,t),0===r.name.length)throw Error("Missing layer name");let a=_d(e,t,1)[0]>>>0,n=_d(e,t,1)[0]>>>0;r.columns=Array(n);for(let s=0;s<n;s++)r.columns[s]=Gf(e,t);return i.featureTables.push(r),[i,a]}function Zf(e,t,i,r,a,n,s=!1){let o=t.scalarType;if("logicalType"!==o?.type||0!==o.logicalType)throw Error(`ID column must be a logical ID scalar type: ${r}`);let l=o.longID?6:4,h="number"==typeof n?void 0:n,u=Qd(a,n,e,i,6===l?"int64":"int32");if(4===l)switch(u){case kd.FLAT:return new qp(r,Zd(e,i,a,void 0,h),n);case kd.SEQUENCE:{let t=Xd(e,i,a);return new Xp(r,t[0],t[1],a.numRleValues)}case kd.CONST:return new Yp(r,Hd(e,i,a),n,!1)}switch(u){case kd.FLAT:return s?new Wp(r,function(e,t,i){return function(e,t){switch(t.logicalLevelTechnique1){case Vp.DELTA:if(t.logicalLevelTechnique2===Vp.RLE){let i=t;e=Id(e,i.runs,i.numRleValues)}return function(e){e[0]=Td(e[0]);let t=e.length/4*4,i=1;if(t>=4)for(;i<t-4;i+=4){let t=e[i],r=e[i+1],a=e[i+2],n=e[i+3];e[i]=Td(t)+e[i-1],e[i+1]=Td(r)+e[i],e[i+2]=Td(a)+e[i+1],e[i+3]=Td(n)+e[i+2]}for(;i!==e.length;++i)e[i]=Td(e[i])+e[i-1]}(e),e;case Vp.RLE:return function(e,t){return Id(e,t.runs,t.numRleValues)}(e,t);case Vp.NONE:return e;default:throw Error(`The specified Logical level technique is not supported: ${t.logicalLevelTechnique1}`)}}(function(e,t,i){let r=new Float64Array(i);for(let a=0;a<i;a++)r[a]=vd(e,t);return r}(e,t,i.numValues),i)}(e,i,a),n):new af(r,Kd(e,i,a,h),n);case kd.SEQUENCE:{let t=Yd(e,i,a);return new nf(r,t[0],t[1],a.numRleValues)}case kd.CONST:return new Tf(r,Jd(e,i,a),n,!1)}throw Error("Vector type not supported for id column.")}var qf=class{constructor(e,t){switch(this._featureData=e,this.properties=this._featureData.properties||{},this._featureData.geometry?.type){case ef.POINT:case ef.MULTIPOINT:this.type=1;break;case ef.LINESTRING:case ef.MULTILINESTRING:this.type=2;break;case ef.POLYGON:case ef.MULTIPOLYGON:this.type=3;break;default:this.type=0}this.extent=t,this.id=Number(this._featureData.id)}loadGeometry(){let e=[];for(let t of this._featureData.geometry.coordinates){let i=[];for(let e of t)i.push(new u(e.x,e.y));e.push(i)}return e}},Wf=class{constructor(e){this.features=[],this.featureTable=e,this.name=e.name,this.extent=e.extent,this.version=2,this.features=e.getFeatures(),this.length=this.features.length}feature(e){return new qf(this.features[e],this.extent)}},Hf=class{constructor(e){this.layers={};let t=function(e,t,i=!0){let r=new Jp(0),a=[];for(;r.get()<e.length;){let n=_d(e,r,1)[0]>>>0,s=r.get()+n;if(s>e.length)throw Error(`Block overruns tile: ${s} > ${e.length}`);if(_d(e,r,1)[0]>>>0!=1){r.set(s);continue}let[o,l]=$f(e,r),h=o.featureTables[0],u=null,c=null,p=[],d=0;for(let a of h.columns){let n=a.name;if(Of(a)){let t=null;if(a.nullable){let i=Nd(e,r),a=r.get(),n=Pf(e,i.numValues,i.byteLength,r);r.set(a+i.byteLength),t=new Ud(n,i.numValues)}let s=Nd(e,r);d=t?t.size():s.decompressedCount,u=Zf(e,a,r,n,s,t??d,i)}else if(Vf(a)){let i=_d(e,r,1)[0];if(0===d){let t=r.get();d=Nd(e,r).decompressedCount,r.set(t)}t&&(t.scale=t.extent/l),c=yf(e,i,r,d,t)}else{let t=Bf(a)?_d(e,r,1)[0]:1;if(0===t)continue;let i=zf(e,r,a,t,d,void 0);if(i)if(Array.isArray(i))for(let e of i)p.push(e);else p.push(i)}}let f=new Kp(h.name,c,u,p,l);a.push(f),r.set(s)}return a}(new Uint8Array(e));this.layers=t.reduce((e,t)=>({...e,[t.name]:new Wf(t)}),{})}};function Xf(e,t,i,r,a){return Ee(e,(e,n)=>{let s=t instanceof Ms?t.get(n):null;return s?.evaluate?s.evaluate(i,r,a):s})}function Yf(e,t){return t-e}rs("FeatureIndex",class{constructor(e,t){this.tileID=e,this.x=e.canonical.x,this.y=e.canonical.y,this.z=e.canonical.z,this.grid=new ts(J,16,0),this.grid3D=new ts(J,16,0),this.featureIndexArray=new Co,this.promoteId=t}insert(e,t,i,r,a,n){let s=this.featureIndexArray.length;this.featureIndexArray.emplaceBack(i,r,a);let o=n?this.grid3D:this.grid;for(let l of t){let e=[1/0,1/0,-1/0,-1/0];for(let t of l)e[0]=Math.min(e[0],t.x),e[1]=Math.min(e[1],t.y),e[2]=Math.max(e[2],t.x),e[3]=Math.max(e[3],t.y);e[0]<8192&&e[1]<8192&&e[2]>=0&&e[3]>=0&&o.insert(s,e[0],e[1],e[2],e[3])}}loadVTLayers(){return this.vtLayers||("mlt"===this.encoding?this.vtLayers=new Hf(this.rawTileData).layers:this.vtLayers=new Wu(new Yc(this.rawTileData)).layers,this.sourceLayerCoder=new Up(this.vtLayers?Object.keys(this.vtLayers).sort():[Np])),this.vtLayers}query(e,t,i,r){this.loadVTLayers();let a=e.params,n=J/e.tileSize/e.scale,s=sn(a.filter,"queryRenderedFeatures filter",a.globalState),o=e.queryGeometry,l=e.queryPadding*n,h=Ou.fromPoints(o),u=this.grid.query(h.minX-l,h.minY-l,h.maxX+l,h.maxY+l),c=Ou.fromPoints(e.cameraQueryGeometry).expandBy(l),p=this.grid3D.query(c.minX,c.minY,c.maxX,c.maxY,(t,i,r,a)=>Yl(e.cameraQueryGeometry,t-l,i-l,r+l,a+l));for(let m of p)u.push(m);u.sort(Yf);let d,f={};for(let m of u){if(m===d)continue;d=m;let l=this.featureIndexArray.get(m),h=null;this.loadMatchingFeature(f,l.bucketIndex,l.sourceLayerIndex,l.featureIndex,s,a.layers,a.availableImages,t,i,r,(t,i,r)=>(h||=kl(t),i.queryIntersectsFeature({queryGeometry:o,feature:t,featureState:r,geometry:h,zoom:this.z,transform:e.transform,pixelsToTileUnits:n,pixelPosMatrix:e.pixelPosMatrix,unwrappedTileID:this.tileID.toUnwrapped(),getElevation:e.getElevation})))}return f}loadMatchingFeature(e,t,i,r,a,n,s,o,l,h,u){let c=this.bucketLayerIDs[t];if(n&&!c.some(e=>n.has(e)))return;let p=this.sourceLayerCoder.decode(i),d=this.vtLayers[p].feature(r);if(a.needGeometry){let e=Ll(d,!0);if(!a.filter(new ys(this.tileID.overscaledZ),e,this.tileID.canonical))return}else if(!a.filter(new ys(this.tileID.overscaledZ),d))return;let f=this.getId(d,p);for(let m of c){if(n&&!n.has(m))continue;let t=o[m];if(!t)continue;let i={};f&&h&&(i=h.getState(t.sourceLayer||"_geojsonTileLayer",f));let a=be({},l[m]);a.paint=Xf(a.paint,t.paint,d,i,s),a.layout=Xf(a.layout,t.layout,d,i,s);let c=!u||u(d,t,i);if(!c)continue;let p=new Gp(d,this.z,this.x,this.y,f);p.layer=a;let _=e[m];void 0===_&&(_=e[m]=[]),_.push({featureIndex:r,feature:p,intersectionZ:c})}}lookupSymbolFeatures(e,t,i,r,a,n,s,o){let l={};this.loadVTLayers();let h=sn(a.filterSpec,"queryRenderedFeatures symbol filter",a.globalState);for(let u of e)this.loadMatchingFeature(l,i,r,u,h,n,s,o,t);return l}hasLayer(e){for(let t of this.bucketLayerIDs)for(let i of t)if(e===i)return!0;return!1}getId(e,t){let i=e.id;if(this.promoteId){let r="string"==typeof this.promoteId?this.promoteId:this.promoteId[t];i=e.properties[r],"boolean"==typeof i&&(i=Number(i)),void 0===i&&e.properties?.cluster&&this.promoteId&&(i=Number(e.properties.cluster_id))}return i}},{omit:["rawTileData","sourceLayerCoder"]});var Kf=class{constructor(e,t){this.max=e,this.onRemove=t,this.reset()}reset(){for(let e in this.data)for(let t of this.data[e])t.timeout&&clearTimeout(t.timeout),this.onRemove(t.value);return this.data={},this.order=[],this}add(e,t,i){let r=e.wrapped().key;void 0===this.data[r]&&(this.data[r]=[]);let a={value:t,timeout:void 0};if(void 0!==i&&(a.timeout=setTimeout(()=>{this.remove(e,a)},i)),this.data[r].push(a),this.order.push(r),this.order.length>this.max){let e=this._getAndRemoveByKey(this.order[0]);e&&this.onRemove(e)}return this}has(e){return e.wrapped().key in this.data}getAndRemove(e){return this.has(e)?this._getAndRemoveByKey(e.wrapped().key):null}_getAndRemoveByKey(e){let t=this.data[e].shift();return t.timeout&&clearTimeout(t.timeout),0===this.data[e].length&&delete this.data[e],this.order.splice(this.order.indexOf(e),1),t.value}getByKey(e){let t=this.data[e];return t?t[0].value:null}get(e){return this.has(e)?this.data[e.wrapped().key][0].value:null}remove(e,t){if(!this.has(e))return this;let i=e.wrapped().key,r=void 0===t?0:this.data[i].indexOf(t),a=this.data[i][r];return this.data[i].splice(r,1),a.timeout&&clearTimeout(a.timeout),0===this.data[i].length&&delete this.data[i],this.onRemove(a.value),this.order.splice(this.order.indexOf(i),1),this}setMaxSize(e){for(this.max=e;this.order.length>this.max;){let e=this._getAndRemoveByKey(this.order[0]);e&&this.onRemove(e)}return this}filter(e){let t=[];for(let i in this.data)for(let r of this.data[i])e(r.value)||t.push(r);for(let i of t)this.remove(i.value.tileID,i)}};rs("Anchor",class e extends u{constructor(e,t,i,r){super(e,t),this.angle=i,void 0!==r&&(this.segment=r)}clone(){return new e(this.x,this.y,this.angle,this.segment)}});var Jf,Qf,em,tm=function(e){return e[e.center=1]="center",e[e.left=2]="left",e[e.right=3]="right",e[e.top=4]="top",e[e.bottom=5]="bottom",e[e["top-left"]=6]="top-left",e[e["top-right"]=7]="top-right",e[e["bottom-left"]=8]="bottom-left",e[e["bottom-right"]=9]="bottom-right",e}({}),im="6.4.1";function rm(){var e=new p(4);return p!=Float32Array&&(e[1]=0,e[2]=0),e[0]=1,e[3]=1,e}var am={frame(e,t,i,r){let a=r||window,n=a.requestAnimationFrame(e=>{s(),t(e)}),{unsubscribe:s}=je(e.signal,"abort",()=>{s(),a.cancelAnimationFrame(n),i(new Qe(e.signal.reason))},!1)},frameAsync(e,t){return new Promise((i,r)=>{this.frame(e,i,r,t)})},getImageData(e,t=0){return this.getImageCanvasContext(e).getImageData(-t,-t,e.width+2*t,e.height+2*t)},getImageCanvasContext(e){let t=window.document.createElement("canvas"),i=t.getContext("2d",{willReadFrequently:!0});if(!i)throw Error("failed to create canvas 2d context");return t.width=e.width,t.height=e.height,i.drawImage(e,0,0,e.width,e.height),i},resolveURL:e=>(Jf||=document.createElement("a"),Jf.href=e,Jf.href),get hardwareConcurrency(){return typeof navigator<"u"&&navigator.hardwareConcurrency||4},get prefersReducedMotion(){return void 0===em?!!matchMedia&&(Qf??=matchMedia("(prefers-reduced-motion: reduce)"),Qf.matches):em},set prefersReducedMotion(e){em=e}},nm=new class{constructor(){this._frozenAt=null}getCurrentTime(){return null===this._frozenAt?performance.now():this._frozenAt}setNow(e){this._frozenAt=e}restoreNow(){this._frozenAt=null}isFrozen(){return null!==this._frozenAt}};function sm(){return nm.getCurrentTime()}function om(e){nm.setNow(e)}function lm(){nm.restoreNow()}function hm(){return nm.isFrozen()}var um,cm=class e{static{this.docStyle=typeof window<"u"&&window.document?.documentElement.style}static{this.selectProp=!e.docStyle||"userSelect"in e.docStyle?"userSelect":"webkitUserSelect"}static create(e,t,i){let r=window.document.createElement(e);return void 0!==t&&(r.className=t),i&&i.appendChild(r),r}static createNS(e,t){return window.document.createElementNS(e,t)}static disableDrag(){e.docStyle&&e.selectProp&&(e.userSelect=e.docStyle[e.selectProp],e.docStyle[e.selectProp]="none")}static enableDrag(){e.docStyle&&e.selectProp&&(e.docStyle[e.selectProp]=e.userSelect)}static suppressClickInternal(t){t.preventDefault(),t.stopPropagation(),window.removeEventListener("click",e.suppressClickInternal,!0)}static suppressClick(){window.addEventListener("click",e.suppressClickInternal,!0),window.setTimeout(()=>{window.removeEventListener("click",e.suppressClickInternal,!0)},0)}static getScale(e){let t=e.getBoundingClientRect();return{x:t.width/e.offsetWidth||1,y:t.height/e.offsetHeight||1,boundingClientRect:t}}static getPoint(e,t,i){let r=t.boundingClientRect;return new u((i.clientX-r.left)/t.x-e.clientLeft,(i.clientY-r.top)/t.y-e.clientTop)}static mousePos(t,i){let r=e.getScale(t);return e.getPoint(t,r,i)}static touchPos(t,i){let r=[],a=e.getScale(t);for(let n of i)r.push(e.getPoint(t,a,n));return r}static sanitize(t){let i=(new DOMParser).parseFromString(t,"text/html").body||document.createElement("body"),r=i.querySelectorAll("script");for(let e of r)e.remove();return e.clean(i),i.innerHTML}static isPossiblyDangerous(e,t){let i=t.replace(/\s+/g,"").toLowerCase();if(["src","href","xlink:href"].includes(e)&&(i.includes("javascript:")||i.includes("data:"))||e.startsWith("on"))return!0}static clean(t){let i=t.children;for(let r of i)e.removeAttributes(r),e.clean(r)}static removeAttributes(t){for(let{name:i,value:r}of Array.from(t.attributes))e.isPossiblyDangerous(i,r)&&t.removeAttribute(i)}};(function(e){let t,i,r,a;e.resetRequestQueue=()=>{t=[],i=0,r=0,a={}},e.addThrottleControl=e=>{let t=r++;return a[t]=e,t},e.removeThrottleControl=e=>{delete a[e],o()},e.transformAndGetImage=async function(e,t,i,r,a=!0,n){let s=await e.transformRequest(t,i);return tt(r.signal),um.getImage(s,r,a,n)},e.getImage=(e,i,r=!0,a)=>new Promise((n,s)=>{e.headers||={},e.headers.accept="image/webp,*/*",be(e,{type:"image"});let l={abortController:i,requestParameters:e,supportImageRefresh:r,imageBitmapOptions:a,state:"queued",onError:e=>{s(e)},onSuccess:e=>{n(e)}};t.push(l),o()});let n=(e,t)=>"function"==typeof createImageBitmap?(async(e,t)=>{if(0===e.byteLength)return createImageBitmap(new ImageData(1,1),t);let i=new Blob([new Uint8Array(e)],{type:"image/png"});try{return createImageBitmap(i,t)}catch(e){throw Error(`Could not load image because of ${ee(e).message}. Please make sure to use a supported image type such as PNG or JPEG. Note that SVGs are not supported.`)}})(e,t):(e=>new Promise((t,i)=>{let r=new Image;r.onload=()=>{t(r),URL.revokeObjectURL(r.src),r.onload=null,window.requestAnimationFrame(()=>r.src=Ve)},r.onerror=()=>i(Error("Could not load image. Please make sure to use a supported image type such as PNG or JPEG. Note that SVGs are not supported."));let a=new Blob([new Uint8Array(e)],{type:"image/png"});r.src=e.byteLength?URL.createObjectURL(a):Ve}))(e),s=async e=>{e.state="running";let{requestParameters:t,supportImageRefresh:r,imageBitmapOptions:a,onError:s,onSuccess:h,abortController:u}=e,c=!1===r&&!a&&!Fe(self)&&!rt(t.url)&&(!t.headers||Object.keys(t.headers).reduce((e,t)=>e&&"accept"===t,!0));i++;let p=c?l(t,u):ht(t,u);try{let t=await p;delete e.abortController,e.state="completed",t.data instanceof HTMLImageElement||Oe(t.data)?h(t):t.data&&h({data:await n(t.data,a),cacheControl:t.cacheControl,expires:t.expires})}catch(t){delete e.abortController,s(ee(t))}finally{i--,o()}},o=()=>{let e=(()=>{for(let e of Object.keys(a))if(a[e]())return!0;return!1})()?it.MAX_PARALLEL_IMAGE_REQUESTS_PER_FRAME:it.MAX_PARALLEL_IMAGE_REQUESTS;for(let r=i;r<e&&t.length>0;r++){let e=t.shift();e.abortController.signal.aborted?r--:s(e)}},l=(e,t)=>new Promise((i,r)=>{let a=new Image,n=e.url,s=e.credentials;s&&"include"===s?a.crossOrigin="use-credentials":(s&&"same-origin"===s||!ct(n))&&(a.crossOrigin="anonymous"),t.signal.addEventListener("abort",()=>{a.src="",r(new Qe(t.signal.reason))}),a.fetchPriority="high",a.onload=()=>{a.onerror=a.onload=null,i({data:a})},a.onerror=()=>{a.onerror=a.onload=null,!t.signal.aborted&&r(Error("Could not load image. Please make sure to use a supported image type such as PNG or JPEG. Note that SVGs are not supported."))},a.src=n})})(um||={}),um.resetRequestQueue();var pm=class{constructor(e){this._transformRequestFn=e??null}transformRequest(e,t){return this._transformRequestFn&&this._transformRequestFn(e,t)||{url:e}}setTransformRequest(e){this._transformRequestFn=e}},dm=class extends ft{},fm=class extends dm{},mm=class extends dm{constructor(e={}){super("style.load",e)}},_m=class extends dm{constructor(e,t={}){super(e,t),this.dataType="style"}},gm=class extends dm{constructor(e,t={}){super(e,t),this.dataType="source"}},ym=class extends dm{preventDefault(){this._defaultPrevented=!0}get defaultPrevented(){return this._defaultPrevented}constructor(e,t,i,r={}){i=i instanceof MouseEvent?i:new MouseEvent(e,i);let a=cm.mousePos(t.getCanvas(),i);super(e,be({point:a,lngLat:t.unproject(a),originalEvent:i},r)),this._defaultPrevented=!1,this.target=t}},vm=class extends dm{preventDefault(){this._defaultPrevented=!0}get defaultPrevented(){return this._defaultPrevented}constructor(e,t,i){let r="touchend"===e?i.changedTouches:i.touches,a=cm.touchPos(t.getCanvasContainer(),r),n=a.map(e=>t.unproject(e)),s=a.reduce((e,t,i,r)=>e.add(t.div(r.length)),new u(0,0));super(e,{points:a,point:s,lngLats:n,lngLat:t.unproject(s),originalEvent:i}),this._defaultPrevented=!1}},xm=class extends dm{preventDefault(){this._defaultPrevented=!0}get defaultPrevented(){return this._defaultPrevented}constructor(e,t){super("wheel",{originalEvent:t}),this._defaultPrevented=!1}},bm=class extends dm{},wm=class extends dm{constructor(e={}){super("terrain",e)}},Tm=class extends dm{constructor(e={}){super("projectiontransition",e)}},Sm=class extends dm{},Pm=class extends dm{constructor(e={}){super("styleimagemissing",e)}};function Im(e){let t=[];if("string"==typeof e)t.push({id:"default",url:e});else if(e&&e.length>0){let i=[];for(let{id:r,url:a}of e){let e=`${r}${a}`;i.includes(e)||(i.push(e),t.push({id:r,url:a}))}}return t}function Mm(e,t,i){try{let r=new URL(e);return r.pathname+=`${t}${i}`,r.toString()}catch{throw Error(`Invalid sprite URL "${e}", must be absolute. Modify style specification directly or use TransformStyleFunction to correct the issue dynamically`)}}var Em=class extends _t{constructor(){super(),this.images={},this.updateVersion=0,this.loaded=!1,this.requestors=[],this.missingImageResolver=null,this._spriteImagesIds={},this._imagesIds=null,this._renderCallbacksDispatchedThisFrame={}}destroy(){for(let e of Object.keys(this.images))this.removeImage(e);this._spriteImagesIds={}}isLoaded(){return this.loaded}setLoaded(e){if(this.loaded!==e&&(this.loaded=e,e)){for(let{ids:e,promiseResolve:t}of this.requestors)t(this._getImagesForIds(e));this.requestors=[]}}getImage(e){let t=this.images[e];if(t&&!t.data&&t.spriteData){let e=t.spriteData;t.data=new yh({width:e.width,height:e.height},e.context.getImageData(e.x,e.y,e.width,e.height).data),t.spriteData=null}return t}addImage(e,t){if(this.images[e])throw Error(`Image id ${e} already exist, use updateImage instead`);this._validate(e,t)&&(this.images[e]=t,this._imagesIds=null,t.isWebGLImage&&this.updateImage(e,t,!1))}_validate(e,t){let i=!0,r=t.data||t.spriteData;return this._validateStretch(t.stretchX,r?.width)||(this.fire(new mt(Error(`Image "${e}" has invalid "stretchX" value`))),i=!1),this._validateStretch(t.stretchY,r?.height)||(this.fire(new mt(Error(`Image "${e}" has invalid "stretchY" value`))),i=!1),this._validateContent(t.content,t)||(this.fire(new mt(Error(`Image "${e}" has invalid "content" value`))),i=!1),i}_validateStretch(e,t){if(!e)return!0;let i=0;for(let r of e){if(r[0]<i||r[1]<r[0]||t<r[1])return!1;i=r[1]}return!0}_validateContent(e,t){if(!e)return!0;if(4!==e.length)return!1;let i=t.spriteData,r=i?.width||t.data.width,a=i?.height||t.data.height;return!(e[0]<0||r<e[0]||e[1]<0||a<e[1]||e[2]<0||r<e[2]||e[3]<0||a<e[3]||e[2]<e[0])&&e[3]>=e[1]}updateImage(e,t,i=!0){let r=this.images[e];if(i){let e=r.data||r.spriteData;if(e.width!==t.data.width||e.height!==t.data.height)throw Error(`size mismatch between old image (${e.width}x${e.height}) and new image (${t.data.width}x${t.data.height}).`)}t.version=(r.version??0)+1,this.images[e]=t,this.updateVersion++}removeImage(e){let t=this.images[e];t&&(delete this.images[e],this._imagesIds=null,t.userImage?.onRemove&&t.userImage.onRemove())}listImages(){return this._imagesIds??=Object.keys(this.images),this._imagesIds}_getSpriteImageId(e,t){return"default"===e?t:`${e}:${t}`}setSpriteImages(e,t){let i=this._spriteImagesIds[e]??[],r=[];for(let s in t){let i=this._getSpriteImageId(e,s);r.push(i),i in this.images?this.updateImage(i,t[s],!1):this.addImage(i,t[s])}let a=new Set(r),n=i.filter(e=>!a.has(e));for(let s of n)this.removeImage(s);return this._spriteImagesIds[e]=r,{loaded:r,removed:n}}removeSpriteImages(e){let t=this._spriteImagesIds[e]??[];for(let i of t)this.removeImage(i);return delete this._spriteImagesIds[e],t}removeAllSpriteImages(){let e=Object.values(this._spriteImagesIds).flat();for(let t of e)this.removeImage(t);return this._spriteImagesIds={},e}setMissingImageResolver(e){this.missingImageResolver=e}getImages(e){return new Promise((t,i)=>{let r=!0;if(!this.isLoaded())for(let a of e)this.images[a]||(r=!1);this.isLoaded()||r?t(this._getImagesForIds(e)):this.requestors.push({ids:e,promiseResolve:t})})}async _getImagesForIds(e){let t=new Set(e.filter(e=>!this.getImage(e))),i=this.missingImageResolver;i&&await Promise.allSettled(Array.from(t,e=>i(e)));let r={};for(let a of e){let e=this.getImage(a);e&&(t.delete(a),r[a]={data:e.data.clone(),pixelRatio:e.pixelRatio,sdf:e.sdf,version:e.version,stretchX:e.stretchX,stretchY:e.stretchY,content:e.content,textFitWidth:e.textFitWidth,textFitHeight:e.textFitHeight,hasRenderCallback:!!e.userImage?.render,isWebGLImage:e.isWebGLImage})}for(let a of t)this.fire(new Pm({id:a})),Re(`Image "${a}" could not be loaded. Please make sure you have added the image before it is needed with map.addImage(), resolved it with map.setMissingStyleImageResolver(), or included it in a "sprite" property in your style.`);return r}beginFrame(){this._renderCallbacksDispatchedThisFrame={}}dispatchRenderCallbacks(e){for(let t of e){if(this._renderCallbacksDispatchedThisFrame[t])continue;this._renderCallbacksDispatchedThisFrame[t]=!0;let e=this.getImage(t);e||Re(`Image with ID: "${t}" was not found`),tp(e)&&this.updateImage(t,e)}}cloneImages(){let e={};for(let t in this.images){let i=this.images[t];e[t]={...i,data:i.data?i.data.clone():null}}return e}},Am=class{constructor(e){this._imageManager=e,this._entries={},this._image=new yh({width:1,height:1}),this._dirty=!0}destroy(){this._texture&&=(this._texture.destroy(),null),this._entries={},this._image=new yh({width:1,height:1}),this._dirty=!0}getPixelSize(){let{width:e,height:t}=this._image;return{width:e,height:t}}getPattern(e){let t=this._imageManager.getImage(e);if(!t)return null;let i=this._entries[e];if(i?.image!==t){let i={w:t.data.width+2,h:t.data.height+2,x:0,y:0};this._entries[e]={bin:i,position:new rp(i,t),image:t}}else{if(i.position.version===t.version)return i.position;i.position.version=t.version}return this._update(),this._entries[e].position}bind(e){let t=e.gl;this._texture?this._dirty&&=(this._texture.update(this._image),!1):(this._texture=new Ah(e,this._image,t.RGBA),this._dirty=!1),this._texture.bind(t.LINEAR,t.CLAMP_TO_EDGE)}_update(){for(let a in this._entries)this._imageManager.getImage(a)||delete this._entries[a];let e=[];for(let a in this._entries)e.push(this._entries[a].bin);let{w:t,h:i}=ip(e),r=this._image;r.resize({width:t||1,height:i||1});for(let a in this._entries){let{bin:e}=this._entries[a],t=e.x+1,i=e.y+1,n=this._entries[a].image.data,s=n.width,o=n.height;yh.copy(n,r,{x:0,y:0},{x:t,y:i},{width:s,height:o}),yh.copy(n,r,{x:0,y:o-1},{x:t,y:i-1},{width:s,height:1}),yh.copy(n,r,{x:0,y:0},{x:t,y:i+o},{width:s,height:1}),yh.copy(n,r,{x:s-1,y:0},{x:t-1,y:i},{width:1,height:o}),yh.copy(n,r,{x:0,y:0},{x:t+s,y:i},{width:1,height:o})}this._dirty=!0}};async function Cm(e,t,i,r){let a=256*t,n=a+255,s=await((e,t)=>ht(be(e,{type:"arrayBuffer"}),t))(await r.transformRequest(i.replace("{fontstack}",e).replace("{range}",`${a}-${n}`),"Glyphs"),new AbortController);if(!s?.data)throw Error(`Could not load glyph range. range: ${t}, ${a}-${n}`);let o={};for(let l of function(e){return new Yc(e).readFields(Kc,[])}(s.data))o[l.id]=l;return o}var Dm=1e20,zm=/* @__PURE__ */new Float64Array(256);for(let gT=0;gT<256;gT++){let e=.5-(gT/255)**(1/2.2);zm[gT]=e*Math.abs(e)}zm[255]=-1e20;var Rm=class{constructor({fontSize:e=24,buffer:t=3,radius:i=8,cutoff:r=.25,fontFamily:a="sans-serif",fontWeight:n="normal",fontStyle:s="normal",lang:o=null}={}){this.buffer=t,this.radius=i,this.cutoff=r,this.lang=o;let l=this.size=e+4*t,h=this._createCanvas(l),u=this.ctx=h.getContext("2d",{willReadFrequently:!0});u.font=`${s} ${n} ${e}px ${a}`,u.textBaseline="alphabetic",u.textAlign="left",u.fillStyle="black",this.gridOuter=new Float64Array(l*l),this.gridInner=new Float64Array(l*l),this.f=new Float64Array(l),this.z=new Float64Array(l+1),this.v=new Uint16Array(l)}_createCanvas(e){if(typeof OffscreenCanvas<"u")return new OffscreenCanvas(e,e);let t=document.createElement("canvas");return t.width=t.height=e,t}draw(e){let{width:t,actualBoundingBoxAscent:i,actualBoundingBoxDescent:r,actualBoundingBoxLeft:a,actualBoundingBoxRight:n}=this.ctx.measureText(e),s=Math.ceil(i),o=Math.floor(-a),l=Math.max(0,Math.min(this.size-this.buffer,Math.ceil(n)-o)),h=Math.max(0,Math.min(this.size-this.buffer,s+Math.ceil(r))),u=l+2*this.buffer,c=h+2*this.buffer,p=Math.max(u*c,0),d=new Uint8ClampedArray(p),f={data:d,width:u,height:c,glyphWidth:l,glyphHeight:h,glyphTop:s,glyphLeft:o,glyphAdvance:t};if(0===l||0===h)return f;let{ctx:m,buffer:_,gridInner:g,gridOuter:y}=this;this.lang&&(m.lang=this.lang),m.clearRect(_,_,l,h),m.fillText(e,_-o,_+s);let v=m.getImageData(_,_,l,h);y.fill(Dm,0,p),g.fill(0,0,p);let x=3;for(let S=0;S<h;S++){let e=(S+_)*u+_;for(let t=0;t<l;t++,x+=4,e++){let t=v.data[x];if(0===t)continue;let i=zm[t];y[e]=Math.max(0,i),g[e]=Math.max(0,-i)}}km(y,0,0,u,c,u,this.f,this.v,this.z);let b=Math.min(_,1);km(g,_-b,_-b,l+2*b,h+2*b,u,this.f,this.v,this.z);let w=255/this.radius,T=255*(1-this.cutoff);for(let S=0;S<p;S++){let e=Math.sqrt(y[S])-Math.sqrt(g[S]);d[S]=Math.round(T-w*e)}return f}};function km(e,t,i,r,a,n,s,o,l){for(let h=t;h<t+r;h++)Lm(e,i*n+h,n,a,s,o,l);for(let h=i;h<i+a;h++)Lm(e,h*n+t,1,r,s,o,l)}function Lm(e,t,i,r,a,n,s){n[0]=0,s[0]=-1e20,s[1]=Dm,a[0]=e[t];for(let o=1,l=0,h=0;o<r;o++){a[o]=e[t+o*i];let r=o*o;do{let e=n[l];h=(a[o]-a[e]+r-e*e)/(o-e)/2}while(h<=s[l]&&--l>-1);l++,n[l]=o,s[l]=h,s[l+1]=Dm}for(let o=0,l=0;o<r;o++){for(;s[l+1]<o;)l++;let r=n[l],h=o-r;e[t+o*i]=a[r]+h*h}}var Fm,Bm,Om=gt.layout_symbol["text-font"].default.join(","),Vm=class e{static{this.loadGlyphRange=Cm}static{this.TinySDF=Rm}constructor(e,t,i){this.requestManager=e,this.localIdeographFontFamily=t,this.entries={},this.lang=i}setURL(e){this.url=e}async getGlyphs(e){let t=[];for(let a in e)for(let i of e[a])t.push(this._getAndCacheGlyphsPromise(a,i));let i=await Promise.all(t),r={};for(let{stack:a,id:n,glyph:s}of i)r[a]||={},r[a][n]=s&&{id:s.id,bitmap:s.bitmap.clone(),metrics:s.metrics};return r}async _getAndCacheGlyphsPromise(e,t){this.entries[e]??={glyphs:{},requests:{},ranges:{}};let i=this.entries[e],r=i.glyphs[t];return void 0===r?!this.url||this._charUsesLocalIdeographFontFamily(t)?(r=i.glyphs[t]=await this._drawGlyph(i,e,t),{stack:e,id:t,glyph:r}):await this._downloadAndCacheRangePromise(e,t):{stack:e,id:t,glyph:r}}async _downloadAndCacheRangePromise(t,i){let r=this.entries[t],a=Math.floor(i/256);if(r.ranges[a])return{stack:t,id:i,glyph:null};r.requests[a]||=e.loadGlyphRange(t,a,this.url,this.requestManager);try{let e=await r.requests[a];for(let t in e)r.glyphs[+t]=e[+t];return r.ranges[a]=!0,{stack:t,id:i,glyph:e[i]||null}}catch(e){let s=r.glyphs[i]=await this._drawGlyph(r,t,i);return this._warnOnMissingGlyphRange(s,a,i,ee(e)),{stack:t,id:i,glyph:s}}}_warnOnMissingGlyphRange(e,t,i,r){let a=256*t;Re(`Unable to load glyph range ${t}, ${a}-${a+255}. Rendering codepoint U+${i.toString(16).padStart(4,"0").toUpperCase()} locally instead. ${r}`)}_charUsesLocalIdeographFontFamily(e){return!!this.localIdeographFontFamily&&function(e){return/[\u02EA\u02EB\u1100-\u11FF\u2E80-\u2FDF\u3000-\u30FF\u3105-\u312F\u3131-\u318E\u31A0-\u4DBF\u4E00-\uA48C\uA490-\uA4C6\uA960-\uA97C\uAC00-\uD7C6\uD7CB-\uD7FB\uF900-\uFA6D\uFA70-\uFAD9\uFE10-\uFE1F\uFE30-\uFE4F\uFF00-\uFFEF]|\uD81B[\uDFE0-\uDFFF]|[\uD81C-\uD822\uD840-\uD868\uD86A-\uD86D\uD86F-\uD872\uD874-\uD879\uD880-\uD883\uD885-\uD88C][\uDC00-\uDFFF]|\uD823[\uDC00-\uDCD5\uDCFF-\uDD1E\uDD80-\uDDF2]|\uD82B[\uDFF0-\uDFFF]|\uD82C[\uDC00-\uDEFB]|\uD83C[\uDE00-\uDEFF]|\uD869[\uDC00-\uDEDF\uDF00-\uDFFF]|\uD86E[\uDC00-\uDC1D\uDC20-\uDFFF]|\uD873[\uDC00-\uDEAD\uDEB0-\uDFFF]|\uD87A[\uDC00-\uDFE0\uDFF0-\uDFFF]|\uD87B[\uDC00-\uDE5D]|\uD87E[\uDC00-\uDE1D]|\uD884[\uDC00-\uDF4A\uDF50-\uDFFF]|\uD88D[\uDC00-\uDC79]/gim.test(String.fromCodePoint(e))}(e)}async _drawGlyph(e,t,i){let r=t===Om&&""!==this.localIdeographFontFamily&&this._charUsesLocalIdeographFontFamily(i),a=r?"ideographTinySDF":"tinySDF";e[a]||=this._createTinySDF(r?this.localIdeographFontFamily:t);let n=(await e[a]).draw(String.fromCodePoint(i)),s=/^\p{gc=Cf}+$/u.test(String.fromCodePoint(i));return{id:i,bitmap:new gh({width:n.width||60,height:n.height||60},n.data),metrics:{width:s?0:n.glyphWidth/2||24,height:n.glyphHeight/2||24,left:n.glyphLeft/2+.5||0,top:n.glyphTop/2-27.5||-8,advance:s?0:n.glyphAdvance/2||24,isDoubleResolution:!0}}}async _createTinySDF(t){let i=t?t.split(","):[];i.push("sans-serif");let r=i.map(e=>/[-\w]+/.test(e)?e:`'${CSS.escape(e)}'`).join(","),a=this._fontWeight(i[0]),n=this._fontStyle(i[0]);if(typeof document<"u"&&document.fonts?.load)try{await document.fonts.load(`${n} ${a||"normal"} 48px ${r}`)}catch(e){Re(`Failed to load font "${r}": ${ee(e).message}`)}return new e.TinySDF({fontSize:48,buffer:6,radius:16,cutoff:.25,fontFamily:r,fontWeight:a,fontStyle:n,lang:this.lang})}_fontStyle(e){return/italic/i.test(e)?"italic":/oblique/i.test(e)?"oblique":"normal"}_fontWeight(e){let t,i={thin:100,hairline:100,"extra light":200,"ultra light":200,light:300,normal:400,regular:400,medium:500,semibold:600,demibold:600,bold:700,"extra bold":800,"ultra bold":800,black:900,heavy:900,"extra black":950,"ultra black":950};for(let[r,a]of Object.entries(i))RegExp(`\\b${r}\\b`,"i").test(e)&&(t=`${a}`);return t}destroy(){for(let e in this.entries){let t=this.entries[e];t.tinySDF=null,t.ideographTinySDF=null,t.glyphs={},t.requests={},t.ranges={}}this.entries={}}},jm=class extends _t{constructor(e,t){super(),this._transitionable=new ws(Fm||=new Ls({anchor:new Cs(gt.light.anchor,"anchor"),position:new Cs(gt.light.position,"position"),color:new Cs(gt.light.color,"color"),intensity:new Cs(gt.light.intensity,"intensity")}),"light",t),this.setLight(e),this._transitioning=this._transitionable.untransitioned()}getLight(){return this._transitionable.serialize()}getCartesianPosition(){return function([e,t,i]){return t+=90,t*=Math.PI/180,i*=Math.PI/180,[e*Math.cos(t)*Math.sin(i),e*Math.sin(t)*Math.sin(i),e*Math.cos(i)]}(this.properties.get("position"))}setLight(e,t={}){if(!this._validate(Yn.light,e,t))for(let i in e){let t=e[i];i.endsWith("-transition")?this._transitionable.setTransition(i.slice(0,-11),t):this._transitionable.setValue(i,t)}}updateTransitions(e){this._transitioning=this._transitionable.transitioned(e,this._transitioning)}hasTransition(){return this._transitioning.hasTransition()}recalculate(e){this.properties=this._transitioning.possiblyEvaluate(e)}_validate(e,t,i){return es(this,e,{value:t},i)}},Nm=class extends _t{constructor(e,t){super(),this._transitionable=new ws(Bm||=new Ls({"sky-color":new Cs(gt.sky["sky-color"],"sky-color"),"horizon-color":new Cs(gt.sky["horizon-color"],"horizon-color"),"fog-color":new Cs(gt.sky["fog-color"],"fog-color"),"fog-ground-blend":new Cs(gt.sky["fog-ground-blend"],"fog-ground-blend"),"horizon-fog-blend":new Cs(gt.sky["horizon-fog-blend"],"horizon-fog-blend"),"sky-horizon-blend":new Cs(gt.sky["sky-horizon-blend"],"sky-horizon-blend"),"atmosphere-blend":new Cs(gt.sky["atmosphere-blend"],"atmosphere-blend")}),"sky",t),this.setSky(e),this._transitioning=this._transitionable.untransitioned(),this.recalculate(new ys(0))}setSky(e,t={}){if(!this._validate(Yn.sky,e,t)){e||={"sky-color":"transparent","horizon-color":"transparent","fog-color":"transparent","fog-ground-blend":1,"atmosphere-blend":0};for(let t in e){let i=e[t];t.endsWith("-transition")?this._transitionable.setTransition(t.slice(0,-11),i):this._transitionable.setValue(t,i)}}}getSky(){return this._transitionable.serialize()}updateTransitions(e){this._transitioning=this._transitionable.transitioned(e,this._transitioning)}hasTransition(){return this._transitioning.hasTransition()}recalculate(e){this.properties=this._transitioning.possiblyEvaluate(e)}_validate(e,t,i={}){return es(this,e,{value:t},i)}calculateFogBlendOpacity(e){return e<60?0:e<70?(e-60)/10:1}},Um=class{constructor(e,t){this.width=e,this.height=t,this.nextRow=0,this.data=new Uint8Array(this.width*this.height),this.dashEntry={}}getDash(e,t){let i=e.join(",")+String(t);return this.dashEntry[i]||=this.addDash(e,t),this.dashEntry[i]}getDashRanges(e,t,i){let r=[],a=e.length%2==1?-e[e.length-1]*i:0,n=e[0]*i,s=!0;r.push({left:a,right:n,isDash:s,zeroLength:0===e[0]});let o=e[0];for(let l=1;l<e.length;l++){s=!s;let t=e[l];a=o*i,o+=t,n=o*i,r.push({left:a,right:n,isDash:s,zeroLength:0===t})}return r}addRoundDash(e,t,i){let r=t/2;for(let a=-i;a<=i;a++){let t=this.nextRow+i+a,n=this.width*t,s=0,o=e[s];for(let l=0;l<this.width;l++){l/o.right>1&&(o=e[++s]);let t,h=Math.abs(l-o.left),u=Math.abs(l-o.right),c=Math.min(h,u),p=a/i*(r+1);if(o.isDash){let e=r-Math.abs(p);t=Math.sqrt(c*c+e*e)}else t=r-Math.sqrt(c*c+p*p);this.data[n+l]=Math.max(0,Math.min(255,t+128))}}}addRegularDash(e){for(let s=e.length-1;s>=0;--s){let t=e[s],i=e[s+1];t.zeroLength?e.splice(s,1):i?.isDash===t.isDash&&(i.left=t.left,e.splice(s,1))}let t=e[0],i=e[e.length-1];t.isDash===i.isDash&&(t.left=i.left-this.width,i.right=t.right+this.width);let r=this.width*this.nextRow,a=0,n=e[a];for(let s=0;s<this.width;s++){s/n.right>1&&(n=e[++a]);let t=Math.abs(s-n.left),i=Math.abs(s-n.right),o=Math.min(t,i),l=n.isDash?o:-o;this.data[r+s]=Math.max(0,Math.min(255,l+128))}}addDash(e,t){let i=t?7:0,r=2*i+1;if(this.nextRow+r>this.height)return Re("LineAtlas out of space"),null;let a=0;for(let s of e)a+=s;if(0!==a){let r=this.width/a,n=this.getDashRanges(e,this.width,r);t?this.addRoundDash(n,r,i):this.addRegularDash(n)}let n={y:this.nextRow+i,height:2*i,width:a};return this.nextRow+=r,this.dirty=!0,n}bind(e){let t=e.gl;this.texture?(t.bindTexture(t.TEXTURE_2D,this.texture),this.dirty&&(this.dirty=!1,t.texSubImage2D(t.TEXTURE_2D,0,0,0,this.width,this.height,t.ALPHA,t.UNSIGNED_BYTE,this.data))):(this.texture=t.createTexture(),t.bindTexture(t.TEXTURE_2D,this.texture),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_WRAP_S,t.REPEAT),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_WRAP_T,t.REPEAT),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_MIN_FILTER,t.LINEAR),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_MAG_FILTER,t.LINEAR),t.texImage2D(t.TEXTURE_2D,0,t.ALPHA,this.width,this.height,0,t.ALPHA,t.UNSIGNED_BYTE,this.data))}};function Gm(e,t){if(t)try{return new Worker(e,{type:"module"})}catch(e){console.warn("Module worker not supported, falling back to classic worker",e)}return new Worker(e)}async function $m(){let e=it.WORKER_URL||function(){let e=import.meta.url;if(!/^https?:/.test(e))return"";let t=e.endsWith("-dev.mjs")?"maplibre-gl-worker-dev.mjs":"maplibre-gl-worker.mjs";return new URL(`./${t}`,e).href}(),t=!e?.endsWith(".cjs");if(!function(e){if(!e)return!1;let t=globalThis.location;if(!t)return!1;try{return new URL(e,t.href).origin!==t.origin}catch{return!1}}(e))return Gm(e,t);if(t){let i=function(e){let t=new Blob([`import ${JSON.stringify(new URL(e,import.meta.url).href)}`],{type:"text/javascript"});return URL.createObjectURL(t)}(e);try{return Gm(i,t)}finally{URL.revokeObjectURL(i)}}let i=await async function(e){let t=await fetch(e);if(!t.ok)throw Error(`Failed to fetch worker script (${t.status}): ${e}`);let i=await t.text(),r=new Blob([i],{type:"text/javascript"});return URL.createObjectURL(r)}(e);try{return Gm(i,t)}finally{URL.revokeObjectURL(i)}}var Zm,qm="maplibre_preloaded_worker_pool",Wm=class e{constructor(){this.active={},this.workersPromise=null}async acquire(t){if(this.active[t]=!0,!this.workersPromise){let t=[];for(;t.length<e.workerCount;)t.push($m());this.workersPromise=Promise.all(t)}return(await this.workersPromise).slice()}release(e){if(delete this.active[e],0===this.numActive()&&this.workersPromise){let e=this.workersPromise;this.workersPromise=null,e.then(e=>{for(let t of e)t.terminate()})}}isPreloaded(){return!!this.active[qm]}numActive(){return Object.keys(this.active).length}},Hm=Math.floor(am.hardwareConcurrency/2);function Xm(){return Zm||=new Wm,Zm}function Ym(){Xm().acquire(qm)}function Km(){let e=Zm;e&&(e.isPreloaded()&&1===e.numActive()?(e.release(qm),Zm=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()"))}Wm.workerCount=function(e){if(null==Be){let t=e.navigator?e.navigator.userAgent:null;Be=!!e.safari||!(!t||!(/\b(iPad|iPhone|iPod)\b/.test(t)||t.match("Safari")&&!t.match("Chrome")))}return Be}(globalThis)?Math.max(Math.min(Hm,3),1):1;var Jm,Qm=class{constructor(e,t){this.workerPool=e,this.actors=[],this.currentActor=0,this.id=t,this.removed=!1,this.actorsPromise=this.initActors(t)}async initActors(e){let t=await this.workerPool.acquire(e);if(this.removed)return[];if(this.actors=t.map((t,i)=>{let r=new Cp(t,e);return r.name=`Worker ${i}`,r}),!this.actors.length)throw Error("No actors found");return this.actors}async broadcast(e,t){let i=await this.actorsPromise;return Promise.all(i.map(i=>i.sendAsync({type:e,data:t})))}async getActor(){let e=await this.actorsPromise;return this.currentActor=(this.currentActor+1)%e.length,e[this.currentActor]}async waitForInitComplete(){0===this.actors.length&&await this.actorsPromise}getReadyActor(){return this.currentActor=(this.currentActor+1)%this.actors.length,this.actors[this.currentActor]}remove(e=!0){this.removed=!0;for(let t of this.actors)t.remove();this.actors=[],e&&this.workerPool.release(this.id)}async registerMessageHandler(e,t){let i=await this.actorsPromise;for(let r of i)r.registerMessageHandler(e,t)}async unregisterMessageHandler(e){let t=await this.actorsPromise;for(let i of t)i.unregisterMessageHandler(e)}};function e_(){return Jm||(Jm=new Qm(Xm(),st)).registerMessageHandler("GR",(e,t,i)=>ht(t,i)),Jm}function t_(e,t){let i=f();return v(i,i,[1,1,0]),x(i,i,[.5*e.width,.5*e.height,1]),e.calculatePosMatrix?y(i,i,e.calculatePosMatrix(t.toUnwrapped())):i}function i_(e,t,i,r,a,n,s){let o=function(e,t,i){if(e)for(let r of e){let e=t[r];if(e?.source===i&&"fill-extrusion"===e.type)return!0}else for(let r in t){let e=t[r];if(e.source===i&&"fill-extrusion"===e.type)return!0}return!1}(a?.layers??null,t,e.id),l=n.maxPitchScaleFactor(),h=e.tilesIn(r,l,o);h.sort(r_);let u=[];for(let c of h)u.push({wrappedTileID:c.tileID.wrapped().key,queryResults:c.tile.queryRenderedFeatures(t,i,e.getState(),c.queryGeometry,c.cameraQueryGeometry,c.scale,a,n,l,t_(n,c.tileID),s?(e,t)=>s(c.tileID,e,t):void 0)});return function(e,t){for(let i in e)for(let r of e[i])a_(r,t);return e}(function(e){let t={},i={};for(let{queryResults:r,wrappedTileID:a}of e){i[a]||={};let e=i[a];for(let i in r){let a=r[i];e[i]||={};let n=e[i];t[i]||=[];for(let e of a)n[e.featureIndex]||(n[e.featureIndex]=!0,t[i].push(e))}}return t}(u),e)}function r_(e,t){let i=e.tileID,r=t.tileID;return i.overscaledZ-r.overscaledZ||i.canonical.y-r.canonical.y||i.wrap-r.wrap||i.canonical.x-r.canonical.x}function a_(e,t){let i=e.feature,r=t.getFeatureState(i.layer["source-layer"],i.id);i.source=i.layer.source,i.layer["source-layer"]&&(i.sourceLayer=i.layer["source-layer"]),i.state=r}async function n_(e,t,i,r){let a=e;if(e.url?a=(await ut(await t.transformRequest(e.url,"Source"),i)).data:await am.frameAsync(i,r),!a)return null;let n=we(be(a,e),["tiles","minzoom","maxzoom","attribution","bounds","scheme","tileSize","encoding"]);return"vector_layers"in a&&a.vector_layers&&(n.vectorLayerIds=a.vector_layers.map(e=>e.id)),n}var s_=class e{constructor(e,t){e&&(t?this.setSouthWest(e).setNorthEast(t):Array.isArray(e)&&(4===e.length?this.setSouthWest([e[0],e[1]]).setNorthEast([e[2],e[3]]):this.setSouthWest(e[0]).setNorthEast(e[1])))}setNorthEast(e){return this._ne=e instanceof Xu?new Xu(e.lng,e.lat):Xu.convert(e),this}setSouthWest(e){return this._sw=e instanceof Xu?new Xu(e.lng,e.lat):Xu.convert(e),this}extend(t){let i,r,a=this._sw,n=this._ne;if(t instanceof Xu)i=t,r=t;else{if(!(t instanceof e)){if(Array.isArray(t)){if(4===t.length||t.every(Array.isArray)){let i=t;return this.extend(e.convert(i))}{let e=t;return this.extend(Xu.convert(e))}}return t&&("lng"in t||"lon"in t)&&"lat"in t?this.extend(Xu.convert(t)):this}if(i=t._sw,r=t._ne,!i||!r)return this}return a||n?(a.lng=Math.min(i.lng,a.lng),a.lat=Math.min(i.lat,a.lat),n.lng=Math.max(r.lng,n.lng),n.lat=Math.max(r.lat,n.lat)):(this._sw=new Xu(i.lng,i.lat),this._ne=new Xu(r.lng,r.lat)),this}getCenter(){return new Xu((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 Xu(this.getWest(),this.getNorth())}getSouthEast(){return new Xu(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:t,lat:i}=Xu.convert(e),r=this._sw.lat<=i&&i<=this._ne.lat,a=this._sw.lng<=t&&t<=this._ne.lng;return this._sw.lng>this._ne.lng&&(a=this._sw.lng>=t&&t>=this._ne.lng),r&&a}intersects(t){if(!((t=e.convert(t)).getNorth()>=this.getSouth()&&t.getSouth()<=this.getNorth()))return!1;let i=Math.abs(this.getEast()-this.getWest()),r=Math.abs(t.getEast()-t.getWest());if(i>=360||r>=360)return!0;let a=xe(this.getWest(),-180,180),n=xe(this.getEast(),-180,180),s=xe(t.getWest(),-180,180),o=xe(t.getEast(),-180,180),l=a>n,h=s>o;return!(!l||!h)||(l?o>=a||s<=n:h?n>=s||a<=o:s<=n&&o>=a)}static convert(t){return t instanceof e||!t?t:new e(t)}static fromLngLat(t,i=0){let r=360*i/40075017,a=r/Math.cos(Math.PI/180*t.lat);return new e(new Xu(t.lng-a,t.lat-r),new Xu(t.lng+a,t.lat+r))}adjustAntiMeridian(){let t=new Xu(this._sw.lng,this._sw.lat),i=new Xu(this._ne.lng,this._ne.lat);return t.lng>i.lng?new e(t,new Xu(i.lng+360,i.lat)):new e(t,i)}},o_=class{constructor(e,t,i){this.bounds=s_.convert(this.validateBounds(e)),this.minzoom=t||0,this.maxzoom=i||24}validateBounds(e){return Array.isArray(e)&&4===e.length?[Math.max(-180,e[0]),Math.max(-90,e[1]),Math.min(180,e[2]),Math.min(90,e[3])]:[-180,-90,180,90]}contains(e){let t=2**e.z,i=Math.floor(Ju(this.bounds.getWest())*t),r=Math.floor(Qu(this.bounds.getNorth())*t),a=Math.ceil(Ju(this.bounds.getEast())*t),n=Math.ceil(Qu(this.bounds.getSouth())*t);return e.x>=i&&e.x<a&&e.y>=r&&e.y<n}},l_=class extends _t{constructor(e,t,i,r){if(super(),this.id=e,this.dispatcher=i,this.type="vector",this.minzoom=0,this.maxzoom=22,this.scheme="xyz",this.tileSize=512,this.reparseOverscaled=!0,this.isTileClipped=!0,this._loaded=!1,be(this,we(t,["url","scheme","tileSize","promoteId","encoding"])),this._options=be({type:"vector"},t),this._collectResourceTiming=t.collectResourceTiming,512!==this.tileSize)throw Error("vector tile sources must have a tileSize of 512");this.setEventedParent(r)}async load(e=!1){this._loaded=!1,this.fire(new gm("dataloading")),this._tileJSONRequest=new AbortController;try{let t=await n_(this._options,this.map._requestManager,this._tileJSONRequest,this.map._ownerWindow);this._tileJSONRequest=null,this._loaded=!0,t&&(be(this,t),t.bounds&&(this.tileBounds=new o_(t.bounds,this.minzoom,this.maxzoom)),this.fire(new gm("data",{sourceDataType:"metadata"})),this.fire(new gm("data",{sourceDataType:"content",sourceDataChanged:e})))}catch(e){this._tileJSONRequest=null,this._loaded=!0,et(e)||this.fire(new mt(ee(e)))}}loaded(){return this._loaded}hasTile(e){return!this.tileBounds||this.tileBounds.contains(e.canonical)}onAdd(e){this.map=e,this.load()}setSourceProperty(e){this._tileJSONRequest&&this._tileJSONRequest.abort(),e(),this.load(!0)}setTiles(e){return this.setSourceProperty(()=>{this._options.tiles=e}),this}setUrl(e){return this.setSourceProperty(()=>{this.url=e,this._options.url=e}),this}onRemove(){this._tileJSONRequest&&=(this._tileJSONRequest.abort(),null)}serialize(){return be({},this._options)}async loadTile(e){let t=e.tileID.canonical.url(this.tiles,this.map.getPixelRatio(),this.scheme),i={request:await this.map._requestManager.transformRequest(t,"Tile"),uid:e.uid,tileID:e.tileID,zoom:e.tileID.overscaledZ,tileSize:this.tileSize*e.tileID.overscaleFactor(),type:this.type,source:this.id,pixelRatio:this.map.getPixelRatio(),showCollisionBoxes:this.map.showCollisionBoxes,promoteId:this.promoteId,subdivisionGranularity:this.map.style.projection.subdivisionGranularity,encoding:this.encoding,overzoomParameters:await this._getOverzoomParameters(e),etag:e.etag};i.request.collectResourceTiming=this._collectResourceTiming,await this.dispatcher.waitForInitComplete();let r="RT";if(e.actor&&"expired"!==e.state){if("loading"===e.state)return new Promise((t,i)=>{e.reloadPromise={resolve:t,reject:i}})}else e.actor=this.dispatcher.getReadyActor(),r="LT";e.abortController=new AbortController;try{let t=await e.actor.sendAsync({type:r,data:i},e.abortController);if(delete e.abortController,e.aborted)return;this._afterTileLoadWorkerResponse(e,t);let a={};return t?.etagUnmodified&&(a.unmodified=!0),a}catch(t){if(delete e.abortController,e.aborted||et(t))return;if(t&&404!==t.status)throw t;this._afterTileLoadWorkerResponse(e,null)}}async _getOverzoomParameters(e){if(e.tileID.canonical.z<=this.maxzoom||void 0===this.map._zoomLevelsToOverscale)return;let t=e.tileID.scaledTo(this.maxzoom).canonical,i=t.url(this.tiles,this.map.getPixelRatio(),this.scheme);return{maxZoomTileID:t,overzoomRequest:await this.map._requestManager.transformRequest(i,"Tile")}}_afterTileLoadWorkerResponse(e,t){if(t?.resourceTiming&&(e.resourceTiming=t.resourceTiming),t&&this.map._refreshExpiredTiles&&e.setExpiryData(t),e.etag=t?.etag,e.loadVectorData(t,this.map.painter),e.reloadPromise){let t=e.reloadPromise;e.reloadPromise=null,this.loadTile(e).then(t.resolve).catch(t.reject)}}async abortTile(e){e.abortController&&(e.abortController.abort(),delete e.abortController),e.actor&&await e.actor.sendAsync({type:"AT",data:{uid:e.uid,type:this.type,source:this.id}})}async unloadTile(e){e.unloadVectorData(),e.actor&&await e.actor.sendAsync({type:"RMT",data:{uid:e.uid,type:this.type,source:this.id}})}hasTransition(){return!1}},h_=class extends _t{constructor(e,t,i,r){super(),this.id=e,this.dispatcher=i,this.setEventedParent(r),this.type="raster",this.minzoom=0,this.maxzoom=22,this.roundZoom=!0,this.scheme="xyz",this.tileSize=512,this._loaded=!1,this._premultiplyAlpha=!0,this._options=be({type:"raster"},t),be(this,we(t,["url","scheme","tileSize"]))}async load(e=!1){this._loaded=!1,this.fire(new gm("dataloading")),this._tileJSONRequest=new AbortController;try{let t=await n_(this._options,this.map._requestManager,this._tileJSONRequest,this.map._ownerWindow);this._tileJSONRequest=null,this._loaded=!0,t&&(be(this,t),t.bounds&&(this.tileBounds=new o_(t.bounds,this.minzoom,this.maxzoom)),this.fire(new gm("data",{sourceDataType:"metadata"})),this.fire(new gm("data",{sourceDataType:"content",sourceDataChanged:e})))}catch(e){this._tileJSONRequest=null,this._loaded=!0,et(e)||this.fire(new mt(ee(e)))}}loaded(){return this._loaded}onAdd(e){this.map=e,this.load()}onRemove(){this._tileJSONRequest&&=(this._tileJSONRequest.abort(),null)}setSourceProperty(e){this._tileJSONRequest&&=(this._tileJSONRequest.abort(),null),e(),this.load(!0)}setTiles(e){return this.setSourceProperty(()=>{this._options.tiles=e}),this}setUrl(e){return this.setSourceProperty(()=>{this.url=e,this._options.url=e}),this}serialize(){return be({},this._options)}setPremultiplyAlpha(e){return this._premultiplyAlpha===e||this.setSourceProperty(()=>{this._premultiplyAlpha=e}),this}hasTile(e){return!this.tileBounds||this.tileBounds.contains(e.canonical)}async loadTile(e){let t=e.tileID.canonical.url(this.tiles,this.map.getPixelRatio(),this.scheme),i=this._premultiplyAlpha,r=i?void 0:{premultiplyAlpha:"none"};e.abortController=new AbortController;try{let a=await um.transformAndGetImage(this.map._requestManager,t,"Tile",e.abortController,this.map._refreshExpiredTiles,r);if(delete e.abortController,e.aborted)return void(e.state="unloaded");if(a?.data){this.map._refreshExpiredTiles&&(a.cacheControl||a.expires)&&e.setExpiryData({cacheControl:a.cacheControl,expires:a.expires});let t=this.map.painter.context,r=t.gl,n=a.data;e.texture=this.map.painter.getTileTexture(n.width),e.texture?e.texture.update(n,{useMipmap:!0,premultiply:i}):(e.texture=new Ah(t,n,r.RGBA,{useMipmap:!0,premultiply:i}),e.texture.bind(r.LINEAR,r.CLAMP_TO_EDGE,r.LINEAR_MIPMAP_NEAREST)),e.state="loaded"}}catch(t){if(delete e.abortController,e.aborted)e.state="unloaded";else if(t)throw e.state="errored",t}}async abortTile(e){e.abortController&&(e.abortController.abort(),delete e.abortController)}async unloadTile(e){e.texture&&this.map.painter.saveTileTexture(e.texture)}hasTransition(){return!1}},u_=class extends h_{constructor(e,t,i,r){super(e,t,i,r),this.type="raster-dem",this.maxzoom=22,this._options=be({type:"raster-dem"},t),this.encoding=t.encoding||"mapbox",this.redFactor=t.redFactor,this.greenFactor=t.greenFactor,this.blueFactor=t.blueFactor,this.baseShift=t.baseShift}async loadTile(e){let t=e.tileID.canonical.url(this.tiles,this.map.getPixelRatio(),this.scheme);e.neighboringTiles=this._getNeighboringTiles(e.tileID),e.abortController=new AbortController;try{let i=await um.transformAndGetImage(this.map._requestManager,t,"Tile",e.abortController,this.map._refreshExpiredTiles,{colorSpaceConversion:"none"});if(delete e.abortController,e.aborted)return void(e.state="unloaded");if(i?.data){let t=i.data;this.map._refreshExpiredTiles&&(i.cacheControl||i.expires)&&e.setExpiryData({cacheControl:i.cacheControl,expires:i.expires});let r=Oe(t)&&c()?t:await this.readImageNow(t),a={type:this.type,uid:e.uid,source:this.id,rawImageData:r,encoding:this.encoding,redFactor:this.redFactor,greenFactor:this.greenFactor,blueFactor:this.blueFactor,baseShift:this.baseShift};if(e.actor&&"expired"!==e.state&&"reloading"!==e.state)return;await this.dispatcher.waitForInitComplete(),(!e.actor||"expired"===e.state)&&(e.actor=this.dispatcher.getReadyActor()),e.dem=await e.actor.sendAsync({type:"LDT",data:a}),e.needsHillshadePrepare=!0,e.needsTerrainPrepare=!0,e.state="loaded"}}catch(t){if(delete e.abortController,e.aborted)e.state="unloaded";else if(t)throw e.state="errored",t}}async readImageNow(e){if(typeof VideoFrame<"u"&&function(){if(null==t&&(t=!1,c())){let e=new OffscreenCanvas(5,5).getContext("2d",{willReadFrequently:!0});if(e){for(let t=0;t<25;t++){let i=4*t;e.fillStyle=`rgb(${i},${i+1},${i+2})`,e.fillRect(t%5,Math.floor(t/5),1,1)}let i=e.getImageData(0,0,5,5).data;for(let e=0;e<100;e++)if(e%4!=3&&i[e]!==e){t=!0;break}}}return t||!1}()){let t=e.width+2,i=e.height+2;try{return new yh({width:t,height:i},await async function(e,t,i,r,a){if(typeof VideoFrame>"u")throw Error("VideoFrame not supported");let n=new VideoFrame(e,{timestamp:0});try{let s=n?.format;if(!s||!s.startsWith("BGR")&&!s.startsWith("RGB"))throw Error(`Unrecognized format ${s}`);let o=s.startsWith("BGR"),l=new Uint8ClampedArray(r*a*4);if(await n.copyTo(l,function(e,t,i,r,a){let n=4*Math.max(-t,0),s=(Math.max(0,i)-i)*r*4+n,o=4*r,l=Math.max(0,t),h=Math.max(0,i);return{rect:{x:l,y:h,width:Math.min(e.width,t+r)-l,height:Math.min(e.height,i+a)-h},layout:[{offset:s,stride:o}]}}(e,t,i,r,a)),o)for(let e=0;e<l.length;e+=4){let t=l[e];l[e]=l[e+2],l[e+2]=t}return l}finally{n.close()}}(e,-1,-1,t,i))}catch{}}return am.getImageData(e,1)}_getNeighboringTiles(e){let t=e.canonical,i=2**t.z,r=(t.x-1+i)%i,a=0===t.x?e.wrap-1:e.wrap,n=(t.x+1+i)%i,s=t.x+1===i?e.wrap+1:e.wrap,o={};return o[new kp(e.overscaledZ,a,t.z,r,t.y).key]={backfilled:!1},o[new kp(e.overscaledZ,s,t.z,n,t.y).key]={backfilled:!1},t.y>0&&(o[new kp(e.overscaledZ,a,t.z,r,t.y-1).key]={backfilled:!1},o[new kp(e.overscaledZ,e.wrap,t.z,t.x,t.y-1).key]={backfilled:!1},o[new kp(e.overscaledZ,s,t.z,n,t.y-1).key]={backfilled:!1}),t.y+1<i&&(o[new kp(e.overscaledZ,a,t.z,r,t.y+1).key]={backfilled:!1},o[new kp(e.overscaledZ,e.wrap,t.z,t.x,t.y+1).key]={backfilled:!1},o[new kp(e.overscaledZ,s,t.z,n,t.y+1).key]={backfilled:!1}),o}async unloadTile(e){e.demTexture&&this.map.painter.saveTileTexture(e.demTexture),e.fbo&&(e.fbo.destroy(),delete e.fbo),e.dem&&delete e.dem,delete e.neighboringTiles,e.state="unloaded",e.actor&&await e.actor.sendAsync({type:"RDT",data:{type:this.type,uid:e.uid,source:this.id}})}};function c_(e,t){return t?e.properties[t]:e.id}function p_(e,t){let i={id:e.id};if(t.removeAllProperties&&(delete e.removeProperties,delete e.addOrUpdateProperties,delete t.removeProperties),t.removeProperties)for(let r of t.removeProperties){let t=e.addOrUpdateProperties.findIndex(e=>e.key===r);t>-1&&e.addOrUpdateProperties.splice(t,1)}return(e.removeAllProperties||t.removeAllProperties)&&(i.removeAllProperties=!0),(e.removeProperties||t.removeProperties)&&(i.removeProperties=[...e.removeProperties||[],...t.removeProperties||[]]),(e.addOrUpdateProperties||t.addOrUpdateProperties)&&(i.addOrUpdateProperties=[...e.addOrUpdateProperties||[],...t.addOrUpdateProperties||[]]),(e.newGeometry||t.newGeometry)&&(i.newGeometry=t.newGeometry||e.newGeometry),i}function d_(e,t){if(e)for(let i of e){let e=c_(i,t);null!=e&&(i.id=e)}}function f_(e){if(!e)return{};let t={};return t.removeAll=e.removeAll,t.remove=new Set(e.remove||[]),t.add=new Map(e.add?.map(e=>[e.id,e])),t.update=new Map(e.update?.map(e=>[e.id,e])),t}function m_(e){return e&&0!==e.length?"number"==typeof e[0]?[e]:e.flatMap(e=>m_(e)):[]}function __(e){return"GeometryCollection"===e.type?e.geometries.flatMap(e=>__(e)):m_(e.coordinates)}function g_(e){let t,i=new s_;switch(e.type){case"FeatureCollection":t=e.features.flatMap(e=>__(e.geometry));break;case"Feature":t=__(e.geometry);break;default:t=__(e)}if(0===t.length)return i;for(let r of t){let[e,t]=r;i.extend([e,t])}return i}var y_=class extends _t{constructor(e,t,i,r){super(),this.id=e,this.type="geojson",this.minzoom=0,this.maxzoom=18,this.tileSize=512,this.isTileClipped=!0,this.reparseOverscaled=!0,this._removed=!1,this._isUpdatingWorker=!1,this._pendingWorkerUpdate={data:t.data},this.actorPromise=i.getActor(),this.setEventedParent(r),this._data="string"==typeof t.data?{url:t.data}:{geojson:t.data},this._options=be({},t),this._collectResourceTiming=t.collectResourceTiming,void 0!==t.maxzoom&&(this.maxzoom=t.maxzoom),t.type&&(this.type=t.type),t.attribution&&(this.attribution=t.attribution),this.promoteId=t.promoteId,void 0!==t.clusterMaxZoom&&this.maxzoom<=t.clusterMaxZoom&&Re(`The maxzoom value "${this.maxzoom}" is expected to be greater than the clusterMaxZoom value "${t.clusterMaxZoom}".`),this.workerOptions=be({source:this.id,geojsonVtOptions:{buffer:this._pixelsToTileUnits(void 0===t.buffer?128:t.buffer),tolerance:this._pixelsToTileUnits(void 0===t.tolerance?.375:t.tolerance),extent:J,maxZoom:this.maxzoom,lineMetrics:t.lineMetrics||!1,generateId:t.generateId||!1,promoteId:"string"==typeof t.promoteId?t.promoteId:void 0,cluster:t.cluster||!1,clusterOptions:{maxZoom:this._getClusterMaxZoom(t.clusterMaxZoom),minPoints:Math.max(2,t.clusterMinPoints||2),extent:J,radius:this._pixelsToTileUnits(t.clusterRadius||50),log:!1,generateId:t.generateId||!1}},clusterProperties:t.clusterProperties,filter:t.filter},t.workerOptions)}_hasPendingWorkerUpdate(){return void 0!==this._pendingWorkerUpdate.data||void 0!==this._pendingWorkerUpdate.diff||this._pendingWorkerUpdate.updateCluster}_pixelsToTileUnits(e){return e*(J/this.tileSize)}_tileUnitsToPixels(e){return e/(J/this.tileSize)}_getClusterMaxZoom(e){let t=e?Math.round(e):this.maxzoom-1;return Number.isInteger(e)||void 0===e||Re(`Integer expected for option 'clusterMaxZoom': provided value "${e}" rounded to "${t}"`),t}async load(){await this._updateWorkerData()}onAdd(e){this.map=e,this.load()}setData(e){return this._data="string"==typeof e?{url:e}:{geojson:e},this._pendingWorkerUpdate={data:e},this._updateWorkerData()}updateData(e){return this._pendingWorkerUpdate.diff=function(e,t,i){if(!e)return t||{};if(!t)return e||{};i&&(d_(e.add,i),d_(t.add,i));let r=f_(e),a=f_(t);!function(e,t){t.removeAll&&(e.add.clear(),e.update.clear(),e.remove.clear(),t.remove.clear());for(let i of t.remove)e.add.delete(i),e.update.delete(i);for(let[i,r]of t.update){let a=e.update.get(i);a&&(t.update.set(i,p_(a,r)),e.update.delete(i))}}(r,a);let n={};if((r.removeAll||a.removeAll)&&(n.removeAll=!0),n.remove=/* @__PURE__ */new Set([...r.remove,...a.remove]),n.add=new Map([...r.add,...a.add]),n.update=new Map([...r.update,...a.update]),n.remove.size&&n.add.size)for(let o of n.add.keys())n.remove.delete(o);let s=function(e){let t={};return e.removeAll&&(t.removeAll=e.removeAll),e.remove&&(t.remove=Array.from(e.remove)),e.add&&(t.add=Array.from(e.add.values())),e.update&&(t.update=Array.from(e.update.values())),t}(n);return i&&function(e,t){if(e)for(let i of e)null!=c_(i,t)&&delete i.id}(s.add,i),s}(this._pendingWorkerUpdate.diff,e),this._updateWorkerData()}async getData(){return this._data.url&&await this.once("data"),this._data.geojson?this._data.geojson:{type:"FeatureCollection",features:Array.from(this._data.updateable.values())}}async getBounds(){return g_(await this.getData())}setClusterOptions(e){return this.workerOptions.geojsonVtOptions.cluster=e.cluster,void 0!==e.clusterRadius&&(this.workerOptions.geojsonVtOptions.clusterOptions.radius=this._pixelsToTileUnits(e.clusterRadius)),void 0!==e.clusterMaxZoom&&(this.workerOptions.geojsonVtOptions.clusterOptions.maxZoom=this._getClusterMaxZoom(e.clusterMaxZoom)),this._pendingWorkerUpdate.updateCluster=!0,this._updateWorkerData()}getClusterOptions(){let{cluster:e,clusterOptions:t}=this.workerOptions.geojsonVtOptions;return{cluster:e,clusterMaxZoom:t.maxZoom,clusterRadius:this._tileUnitsToPixels(t.radius)}}async getClusterExpansionZoom(e){return(await this.actorPromise).sendAsync({type:"GCEZ",data:{type:this.type,clusterId:e,source:this.id}})}async getClusterChildren(e){return(await this.actorPromise).sendAsync({type:"GCC",data:{type:this.type,clusterId:e,source:this.id}})}async getClusterLeaves(e,t,i){return(await this.actorPromise).sendAsync({type:"GCL",data:{type:this.type,source:this.id,clusterId:e,limit:t,offset:i}})}async _updateWorkerData(){if(this._isUpdatingWorker)return this._updatePromise;if(!this._hasPendingWorkerUpdate())return void Re(`No pending worker updates for GeoJSONSource ${this.id}.`);let{data:e,diff:t,updateCluster:i}=this._pendingWorkerUpdate,r=this._getLoadGeoJSONParameters(e,t,i);void 0===e?t?this._pendingWorkerUpdate.diff=void 0:i&&(this._pendingWorkerUpdate.updateCluster=void 0):this._pendingWorkerUpdate.data=void 0,this._updatePromise=this._dispatchWorkerUpdate(r),await this._updatePromise}async _getLoadGeoJSONParameters(e,t,i){let r=be({type:this.type,source:this.id},this.workerOptions);return"string"==typeof e?(r.request=await this.map._requestManager.transformRequest(am.resolveURL(e),"Source"),r.request.collectResourceTiming=this._collectResourceTiming,r):void 0!==e?(r.data=e,r):t?(r.dataDiff=t,r):i?(r.updateCluster=!0,r):void 0}async _dispatchWorkerUpdate(e){this._isUpdatingWorker=!0,this.fire(new gm("dataloading"));try{let t=await e,i=await(await this.actorPromise).sendAsync({type:"LD",data:t});if(this._isUpdatingWorker=!1,this._removed||i.abandoned)return void this.fire(new gm("dataabort"));i.data&&(this._data={geojson:i.data});let r=this._applyDiffToSource(t.dataDiff),a=this._getShouldReloadTileOptions(r),n={};this._applyResourceTiming(n,i),this.fire(new gm("data",{...n,sourceDataType:"metadata"})),this.fire(new gm("data",{...n,sourceDataType:"content",shouldReloadTileOptions:a}))}catch(e){if(this._isUpdatingWorker=!1,this._removed)return void this.fire(new gm("dataabort"));this.fire(new mt(ee(e)))}finally{this._hasPendingWorkerUpdate()&&await this._updateWorkerData()}}_applyResourceTiming(e,t){if(!this._collectResourceTiming)return;let i=t.resourceTiming?.[this.id];if(!i)return;let r=i.slice(0);r?.length&&be(e,{resourceTiming:r})}_applyDiffToSource(e){if(!e)return;let t="string"==typeof this.promoteId?this.promoteId:void 0;if(!this._data.url&&!this._data.updateable){let e=function(e,t){let i=/* @__PURE__ */new Map;if(null==e||null==e.type)return i;if("Feature"===e.type){let r=c_(e,t);return null==r?void 0:(i.set(r,e),i)}if("FeatureCollection"===e.type){let r=/* @__PURE__ */new Set;for(let a of e.features){let e=c_(a,t);if(null==e||r.has(e))return;r.add(e),i.set(e,a)}return i}}(this._data.geojson,t);if(!e)throw Error(`GeoJSONSource "${this.id}": GeoJSON data is not compatible with updateData`);this._data={updateable:e}}if(!this._data.updateable)return;let i=function(e,t,i){let r=[];if(t.removeAll)e.clear();else if(t.remove)for(let a of t.remove){let t=e.get(a);t&&(r.push(t.geometry),e.delete(a))}if(t.add)for(let a of t.add){let t=c_(a,i);if(null==t)continue;let n=e.get(t);n&&r.push(n.geometry),r.push(a.geometry),e.set(t,a)}if(t.update)for(let a of t.update){let t=e.get(a.id);if(!t)continue;let i=!!a.newGeometry,n=a.removeAllProperties||a.removeProperties?.length>0||a.addOrUpdateProperties?.length>0;if(!i&&!n)continue;r.push(t.geometry);let s={...t};if(e.set(a.id,s),i&&(r.push(a.newGeometry),s.geometry=a.newGeometry),n){if(s.properties=a.removeAllProperties?{}:{...s.properties||{}},a.removeProperties)for(let e of a.removeProperties)delete s.properties[e];if(a.addOrUpdateProperties)for(let{key:e,value:t}of a.addOrUpdateProperties)s.properties[e]=t}}return r}(this._data.updateable,e,t);return e.removeAll||this._options.cluster?void 0:i}_getShouldReloadTileOptions(e){if(e)return{affectedBounds:e.filter(Boolean).map(e=>g_(e))}}shouldReloadTile(e,{affectedBounds:t}){if("loading"===e.state)return!0;if("unloaded"===e.state)return!1;let{buffer:i,extent:r}=this.workerOptions.geojsonVtOptions,a=function({x:e,y:t,z:i},r=0){let a=tc((e-r)/2**i),n=ic((t+1+r)/2**i),s=tc((e+1+r)/2**i),o=ic((t-r)/2**i);return new s_([a,n],[s,o])}(e.tileID.canonical,i/r);for(let n of t)if(a.intersects(n))return!0;return!1}loaded(){return!this._isUpdatingWorker&&!this._hasPendingWorkerUpdate()}async loadTile(e){let t=e.actor?"RT":"LT";e.actor=await this.actorPromise;let i={type:this.type,uid:e.uid,tileID:e.tileID,zoom:e.tileID.overscaledZ,maxZoom:this.maxzoom,tileSize:this.tileSize,source:this.id,pixelRatio:this.map.getPixelRatio(),showCollisionBoxes:this.map.showCollisionBoxes,promoteId:this.promoteId,subdivisionGranularity:this.map.style.projection.subdivisionGranularity};e.abortController=new AbortController;try{let r=await(await this.actorPromise).sendAsync({type:t,data:i},e.abortController);delete e.abortController,e.unloadVectorData(),e.aborted||e.loadVectorData(r,this.map.painter,"RT"===t)}catch(t){if(delete e.abortController,e.aborted||et(t))return;throw t}}async abortTile(e){e.abortController&&(e.abortController.abort(),delete e.abortController),e.aborted=!0}async unloadTile(e){e.unloadVectorData(),await(await this.actorPromise).sendAsync({type:"RMT",data:{uid:e.uid,type:this.type,source:this.id}})}onRemove(){this._removed=!0,this.actorPromise.then(e=>e.sendAsync({type:"RS",data:{type:this.type,source:this.id}}))}serialize(){return be({},this._options,{type:this.type,data:this._data.updateable?{type:"FeatureCollection",features:Array.from(this._data.updateable.values())}:this._data.url||this._data.geojson})}hasTransition(){return!1}},v_=[0,0,1],x_=(e,t,i,r,a,n)=>({u_tl_parent:e,u_scale_parent:t,u_buffer_scale:1,u_perspective_transform:n,u_fade_t:i.mix,u_opacity:i.opacity*r.paint.get("raster-opacity"),u_image0:0,u_image1:1,u_brightness_low:r.paint.get("raster-brightness-min"),u_brightness_high:r.paint.get("raster-brightness-max"),u_saturation_factor:T_(r.paint.get("raster-saturation")),u_contrast_factor:w_(r.paint.get("raster-contrast")),u_spin_weights:b_(r.paint.get("raster-hue-rotate")),u_coords_top:[a[0].x,a[0].y,a[1].x,a[1].y],u_coords_bottom:[a[3].x,a[3].y,a[2].x,a[2].y]});function b_(e){e*=Math.PI/180;let t=Math.sin(e),i=Math.cos(e);return[(2*i+1)/3,(-Math.sqrt(3)*t-i+1)/3,(Math.sqrt(3)*t-i+1)/3]}function w_(e){return e>0?1/(1-e):1+e}function T_(e){return e>0?1-1/(1.001-e):-e}var S_=class extends _t{constructor(e,t,i,r){super(),this.perspectiveTransform=v_,this.flippedWindingOrder=!1,this._imageDirty=!1,this.id=e,this.dispatcher=i,this.coordinates=t.coordinates,this.type="image",this.minzoom=0,this.maxzoom=22,this.tileSize=512,this.tiles={},this._loaded=!1,this.setEventedParent(r),this.options=t}async load(e){this._loaded=!1,this.fire(new gm("dataloading")),this.url=this.options.url,this._abortController=new AbortController;try{let t=await um.transformAndGetImage(this.map._requestManager,this.url,"Image",this._abortController);this._abortController=null,this._loaded=!0,t?.data&&(this._setImage(t.data),e&&(this.coordinates=e),this._finishLoading())}catch(e){if(et(e))return;this._abortController=null,this._loaded=!0,this.fire(new mt(ee(e)))}}loaded(){return this._loaded}updateImage(e){return this._abortController&&=(this._abortController.abort(),null),"image"in e?(this._loaded=!0,this._setImage(e.image),e.coordinates&&(this.coordinates=e.coordinates),this._finishLoading(),this):e.url?(this.options.url=e.url,this.load(e.coordinates),this):this}_setImage(e){this.image=e,this._imageDirty=!0}_disposeTexture(){this.texture?.destroy(),this.texture=null}_finishLoading(){this.map&&(this.setCoordinates(this.coordinates),this.fire(new gm("data",{sourceDataType:"metadata"})))}onAdd(e){this.map=e,this.load()}onRemove(){this._abortController&&=(this._abortController.abort(),null),this._disposeTexture(),this.image=null,this.tiles={}}setCoordinates(e){this.coordinates=e;let t=e.map(ac.fromLngLat);return this.tileID=function(e){let t=Ou.fromPoints(e),i=t.width(),r=t.height(),a=Math.max(0,Math.floor(-Math.log(Math.max(i,r))/Math.LN2)),n=2**a;return new zp(a,Math.floor((t.minX+t.maxX)/2*n),Math.floor((t.minY+t.maxY)/2*n))}(t),this.terrainTileRanges=this._getOverlappingTileRanges(t),this.minzoom=this.maxzoom=this.tileID.z,this.tileCoords=t.map(e=>this.tileID.getTilePoint(e)._round()),this.perspectiveTransform=function(e){if(function(e){let[t,i,r,a]=e;return Math.abs(t.x+r.x-i.x-a.x)<P_&&Math.abs(t.y+r.y-i.y-a.y)<P_}(e))return v_;let[t,i,r,a]=e,n=t.x-i.x+r.x-a.x,s=t.y-i.y+r.y-a.y,o=i.x-r.x,l=i.y-r.y,h=a.x-r.x,u=a.y-r.y,c=function(e){return e[0]*e[3]-e[2]*e[1]}([o,l,h,u]);if(Math.abs(c)<P_)return v_;let p=(n*u-h*s)/c,d=(o*s-n*l)/c,f=[1,1+p,1+p+d,1+d],m=Math.max(...f.map(e=>Math.abs(e))),_=f.some(e=>!Number.isFinite(e)||e<=8*P_*m);if(!Number.isFinite(m)||0===m||_)return v_;let g=i.x-t.x+p*i.x,y=a.x-t.x+d*a.x,v=i.y-t.y+p*i.y,x=a.y-t.y+d*a.y,b=[0,0,0];L(b,[g,v,p],[y,x,d]);let w=Math.max(...b.map(e=>Math.abs(e))),T=e.map(({x:e,y:t})=>k(b,[e,t,1])),S=e.map(({x:e,y:t})=>8*P_*(Math.abs(b[0]*e)+Math.abs(b[1]*t)+Math.abs(b[2]))),P=Math.max(...T.map(e=>Math.abs(e))),I=Math.sign(T[0]),M=T.some((e,t)=>!Number.isFinite(e)||Math.abs(e)<=Math.max(P_*P,S[t])||Math.sign(e)!==I);if(!Number.isFinite(w)||0===w||!Number.isFinite(P)||0===P||M)return v_;let E=b.map(e=>e/w);return E.every(Number.isFinite)?E:v_}(this.tileCoords),this.flippedWindingOrder=function(e){let t=e[1].x-e[0].x,i=e[1].y-e[0].y,r=e[2].x-e[0].x;return t*(e[2].y-e[0].y)-i*r<0}(this.tileCoords),this.fire(new gm("data",{sourceDataType:"content"})),this}prepare(){if(0===Object.keys(this.tiles).length||!this.image)return;let e=this.map.painter.context,t=e.gl;this.texture?this._imageDirty&&(this.texture.update(this.image),this.texture.bind(t.LINEAR,t.CLAMP_TO_EDGE)):(this.texture=new Ah(e,this.image,t.RGBA),this.texture.bind(t.LINEAR,t.CLAMP_TO_EDGE)),this._imageDirty=!1;let i=!1;for(let r in this.tiles){let e=this.tiles[r];"loaded"!==e.state&&(e.state="loaded",e.texture=this.texture,i=!0)}i&&this.fire(new gm("data",{sourceDataType:"idle",sourceId:this.id}))}async loadTile(e){this.tileID?.equals(e.tileID.canonical)?(this.tiles[String(e.tileID.wrap)]=e,e.buckets={}):e.state="errored"}serialize(){return{type:"image",url:this.options.url,coordinates:this.coordinates}}hasTransition(){return!1}_getOverlappingTileRanges(e){let{minX:t,minY:i,maxX:r,maxY:a}=Ou.fromPoints(e),n={};for(let s=0;s<=25;s++){let e=2**s,o=Math.floor(t*e),l=Math.floor(i*e),h=Math.floor(r*e),u=Math.floor(a*e),c=(o%e+e)%e,p=h%e;n[s]={minWrap:Math.floor(o/e),maxWrap:Math.floor(h/e),minTileXWrapped:c,maxTileXWrapped:p,minTileY:l,maxTileY:u}}return n}},P_=2**-52,I_=class extends S_{constructor(e,t,i,r){super(e,t,i,r),this._onPlayingHandler=()=>{this.map?.triggerRepaint()},this.roundZoom=!0,this.type="video",this.options=t}async load(){this._loaded=!1;let e=this.options;this.urls=[];for(let t of e.urls)this.urls.push((await this.map._requestManager.transformRequest(t,"Source")).url);try{let e=await(e=>{let t=window.document.createElement("video");return t.muted=!0,new Promise(i=>{t.onloadstart=()=>{i(t)};for(let r of e){let e=window.document.createElement("source");ct(r)||(t.crossOrigin="Anonymous"),e.src=r,t.appendChild(e)}})})(this.urls);if(this._loaded=!0,!e)return;this.video=e,this.video.loop=!0,this.video.addEventListener("playing",this._onPlayingHandler),this.map&&this.video.play(),this._finishLoading()}catch(e){this.fire(new mt(ee(e)))}}pause(){this.video&&this.video.pause()}play(){this.video&&this.video.play()}seek(e){if(this.video){let t=this.video.seekable;e<t.start(0)||e>t.end(0)?this.fire(new mt(new Ct(`sources.${this.id}`,null,`Playback for this video can be set only between the ${t.start(0)} and ${t.end(0)}-second mark.`))):this.video.currentTime=e}}getVideo(){return this.video}onAdd(e){this.map||(this.map=e,this.load(),this.video&&(this.video.play(),this.setCoordinates(this.coordinates)))}onRemove(){super.onRemove(),this.video&&(this.video.removeEventListener("playing",this._onPlayingHandler),this.video.pause())}prepare(){if(0===Object.keys(this.tiles).length||this.video.readyState<2)return;let e=this.map.painter.context,t=e.gl;this.texture?this.video.paused||(this.texture.bind(t.LINEAR,t.CLAMP_TO_EDGE),t.texSubImage2D(t.TEXTURE_2D,0,0,0,t.RGBA,t.UNSIGNED_BYTE,this.video)):(this.texture=new Ah(e,this.video,t.RGBA),this.texture.bind(t.LINEAR,t.CLAMP_TO_EDGE));let i=!1;for(let r in this.tiles){let e=this.tiles[r];"loaded"!==e.state&&(e.state="loaded",e.texture=this.texture,i=!0)}i&&this.fire(new gm("data",{sourceDataType:"idle",sourceId:this.id}))}serialize(){return{type:"video",urls:this.urls,coordinates:this.coordinates}}hasTransition(){return this.video&&!this.video.paused}},M_=class extends S_{constructor(e,t,i,r){super(e,t,i,r),t.coordinates?(!Array.isArray(t.coordinates)||4!==t.coordinates.length||t.coordinates.some(e=>!Array.isArray(e)||2!==e.length||e.some(e=>"number"!=typeof e)))&&this.fire(new mt(new Ct(`sources.${e}`,null,'"coordinates" property must be an array of 4 longitude/latitude array pairs'))):this.fire(new mt(new Ct(`sources.${e}`,null,'missing required property "coordinates"'))),t.animate&&"boolean"!=typeof t.animate&&this.fire(new mt(new Ct(`sources.${e}`,null,'optional "animate" property must be a boolean value'))),t.canvas?"string"!=typeof t.canvas&&!(t.canvas instanceof HTMLCanvasElement)&&this.fire(new mt(new Ct(`sources.${e}`,null,'"canvas" must be either a string representing the ID of the canvas element from which to read, or an HTMLCanvasElement instance'))):this.fire(new mt(new Ct(`sources.${e}`,null,'missing required property "canvas"'))),this.options=t,this.animate=void 0===t.animate||t.animate}async load(){this._loaded=!0,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 mt(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(),!1)},this._finishLoading())}getCanvas(){return this.canvas}onAdd(e){this.map=e,this.load(),this.canvas&&this.animate&&this.play()}onRemove(){this._playing=!1,super.onRemove()}prepare(){let e=!1;if(this.canvas.width!==this.width&&(this.width=this.canvas.width,e=!0),this.canvas.height!==this.height&&(this.height=this.canvas.height,e=!0),this._hasInvalidDimensions()||0===Object.keys(this.tiles).length)return;let t=this.map.painter.context,i=t.gl;this.texture?(e||this._playing)&&this.texture.update(this.canvas,{premultiply:!0}):(this.texture=new Ah(t,this.canvas,i.RGBA,{premultiply:!0}),this.texture.bind(i.LINEAR,i.CLAMP_TO_EDGE));let r=!1;for(let a in this.tiles){let e=this.tiles[a];"loaded"!==e.state&&(e.state="loaded",e.texture=this.texture,r=!0)}r&&this.fire(new gm("data",{sourceDataType:"idle",sourceId:this.id}))}serialize(){return{type:"canvas",animate:this.animate,canvas:this.options.canvas,coordinates:this.coordinates}}hasTransition(){return this._playing}_hasInvalidDimensions(){for(let e of[this.canvas.width,this.canvas.height])if(isNaN(e)||e<=0)return!0;return!1}},E_={},A_=e=>{switch(e){case"geojson":return y_;case"image":return S_;case"raster":return h_;case"raster-dem":return u_;case"vector":return l_;case"video":return I_;case"canvas":return M_}return E_[e]},C_=async(e,t)=>{if(A_(e))throw Error(`A source type called "${e}" already exists.`);((e,t)=>{E_[e]=t})(e,t)},D_="RTLPluginLoaded",z_=class extends _t{constructor(...e){super(...e),this.status="unavailable",this.url=null,this.dispatcher=e_()}_syncState(e){return this.status=e,this.dispatcher.broadcast("SRPS",{pluginStatus:e,pluginURL:this.url}).catch(e=>{throw this.status="error",e})}getRTLTextPluginStatus(){return this.status}clearRTLTextPlugin(){this.status="unavailable",this.url=null}async setRTLTextPlugin(e,t=!1){if(this.url)throw Error("setRTLTextPlugin cannot be called multiple times.");if(this.url=am.resolveURL(e),!this.url)throw Error(`requested url ${e} is invalid`);if("unavailable"===this.status){if(!t)return this._requestImport();this.status="deferred",this._syncState(this.status)}else if("requested"===this.status)return this._requestImport()}async _requestImport(){await this._syncState("loading"),this.status="loaded",this.fire(new ft(D_))}lazyLoad(){"unavailable"===this.status?this.status="requested":"deferred"===this.status&&this._requestImport()}},R_=null;function k_(){return R_||=new z_,R_}var L_=class{constructor(e,t){this.timeAdded=0,this.fadeEndTime=0,this.fadeOpacity=1,this.tileID=e,this.uid=Se(),this.uses=0,this.tileSize=t,this.buckets={},this.expirationTime=null,this.queryPadding=0,this.hasSymbolBuckets=!1,this.hasRTLText=!1,this.dependencies={},this.rttObjects=[],this.rttFingerprint={},this.expiredRequestCount=0,this.state="loading",this.featureStateRevision=-1}isRenderable(e){return this.hasData()&&(!this.fadeEndTime||this.fadeOpacity>0)&&(e||!this.holdingForSymbolFade())}setCrossFadeLogic({fadingRole:e,fadingDirection:t,fadingParentID:i,fadeEndTime:r}){this.resetFadeLogic(),this.fadingRole=e,this.fadingDirection=t,this.fadingParentID=i,this.fadeEndTime=r}setSelfFadeLogic(e){this.resetFadeLogic(),this.selfFading=!0,this.fadeEndTime=e}resetFadeLogic(){this.fadingRole=null,this.fadingDirection=null,this.fadingParentID=null,this.selfFading=!1,this.timeAdded=sm(),this.fadeEndTime=0,this.fadeOpacity=1}wasRequested(){return"errored"===this.state||"loaded"===this.state||"reloading"===this.state}clearTextures(e){this.demTexture&&e.saveTileTexture(this.demTexture),this.demTexture=null}getRTT(e){return this.rttObjects[e]}acquireRTT(e,t,i){return this.rttObjects[t]=e.acquireRTT(i)}releaseRTT(e){if(0!==this.rttObjects.length){for(let t of this.rttObjects)t&&e.releaseRTT(t);this.rttObjects.length=0}}loadVectorData(e,t,i){if(!0!==e?.etagUnmodified)if(this.hasData()&&this.unloadVectorData(),this.state="loaded",e){e.featureIndex&&(this.latestFeatureIndex=e.featureIndex,e.rawTileData?(this.latestRawTileData=e.rawTileData,this.latestEncoding=e.encoding,this.latestFeatureIndex.rawTileData=e.rawTileData,this.latestFeatureIndex.encoding=e.encoding):this.latestRawTileData&&(this.latestFeatureIndex.rawTileData=this.latestRawTileData,this.latestFeatureIndex.encoding=this.latestEncoding)),this.collisionBoxArray=e.collisionBoxArray,this.buckets=function(e,t){let i={};if(!t)return i;for(let r of e){let e=r.layerIds.map(e=>t.getLayer(e)).filter(Boolean);if(0!==e.length){r.layers=e,r.stateDependentLayerIds&&(r.stateDependentLayers=r.stateDependentLayerIds.map(t=>e.filter(e=>e.id===t)[0]));for(let t of e)i[t.id]=r}}return i}(e.buckets,t?.style),this.hasSymbolBuckets=!1;for(let e in this.buckets){let t=this.buckets[e];if(t instanceof gp){if(this.hasSymbolBuckets=!0,!i)break;t.justReloaded=!0}}if(this.hasRTLText=!1,this.hasSymbolBuckets)for(let e in this.buckets){let t=this.buckets[e];if(t instanceof gp&&t.hasRTLText){this.hasRTLText=!0,k_().lazyLoad();break}}this.queryPadding=0;for(let e in this.buckets){let i=this.buckets[e];this.queryPadding=Math.max(this.queryPadding,t.style.getLayer(e).queryRadius(i))}e.imageAtlas&&(this.imageAtlas=e.imageAtlas),e.glyphAtlasImage&&(this.glyphAtlasImage=e.glyphAtlasImage),this.dashPositions=e.dashPositions}else this.collisionBoxArray=new xo;else this.state="loaded"}unloadVectorData(){for(let e in this.buckets)this.buckets[e].destroy();this.buckets={},this.imageAtlasTexture&&this.imageAtlasTexture.destroy(),this.glyphAtlasTexture&&this.glyphAtlasTexture.destroy(),this.imageAtlas=null,this.dashPositions=null,this.latestFeatureIndex=null,this.state="unloaded"}getBucket(e){return this.buckets[e.id]}upload(e){for(let i in this.buckets){let t=this.buckets[i];t.uploadPending()&&t.upload(e)}let t=e.gl;this.imageAtlas&&!this.imageAtlas.uploaded&&(this.imageAtlasTexture=new Ah(e,this.imageAtlas.image,t.RGBA),this.imageAtlas.uploaded=!0),this.glyphAtlasImage&&=(this.glyphAtlasTexture=new Ah(e,this.glyphAtlasImage,t.ALPHA),null)}prepare(e){this.imageAtlas&&this.imageAtlas.patchUpdatedImages(e,this.imageAtlasTexture)}queryRenderedFeatures(e,t,i,r,a,n,s,o,l,h,u){return this.latestFeatureIndex?.rawTileData?this.latestFeatureIndex.query({queryGeometry:r,cameraQueryGeometry:a,scale:n,tileSize:this.tileSize,pixelPosMatrix:h,transform:o,params:s,queryPadding:this.queryPadding*l,getElevation:u},e,t,i):{}}querySourceFeatures(e,t){let i=this.latestFeatureIndex;if(!i?.rawTileData)return;let r=i.loadVTLayers(),a=t?.sourceLayer?t.sourceLayer:"",n=r._geojsonTileLayer||r[a];if(!n)return;let s=sn(t?.filter,`querySourceFeatures[${a}].filter`,t?.globalState),{z:o,x:l,y:h}=this.tileID.canonical,u={z:o,x:l,y:h};for(let c=0;c<n.length;c++){let t=n.feature(c);if(s.needGeometry){let e=Ll(t,!0);if(!s.filter(new ys(this.tileID.overscaledZ),e,this.tileID.canonical))continue}else if(!s.filter(new ys(this.tileID.overscaledZ),t))continue;let r=new Gp(t,o,l,h,i.getId(t,a));r.tile=u,e.push(r)}}hasData(){return"loaded"===this.state||"reloading"===this.state||"expired"===this.state}patternsLoaded(){return this.imageAtlas&&!!Object.keys(this.imageAtlas.patternPositions).length}setExpiryData(e){let t=this.expirationTime;if(e.cacheControl){let t=function(e){let t={};if(e.replace(/(?:^|(?:\s*\,\s*))([^\x00-\x20\(\)<>@\,;\:\\"\/\[\]\?\=\{\}\x7F]+)(?:\=(?:([^\x00-\x20\(\)<>@\,;\:\\"\/\[\]\?\=\{\}\x7F]+)|(?:\"((?:[^"\\]|\\.)*)\")))?/g,(e,i,r,a)=>{let n=r||a;return t[i]=!n||n.toLowerCase(),""}),t["max-age"]){let e=parseInt(t["max-age"],10);isNaN(e)?delete t["max-age"]:t["max-age"]=e}return t}(e.cacheControl);t["max-age"]&&(this.expirationTime=Date.now()+1e3*t["max-age"])}else e.expires&&(this.expirationTime=new Date(e.expires).getTime());if(this.expirationTime){let e=Date.now(),i=!1;if(this.expirationTime>e)i=!1;else if(t)if(this.expirationTime<t)i=!0;else{let r=this.expirationTime-t;r?this.expirationTime=e+Math.max(r,3e4):i=!0}else i=!0;i?(this.expiredRequestCount++,this.state="expired"):this.expiredRequestCount=0}}getExpiryTimeout(){if(this.expirationTime)return this.expiredRequestCount?1e3*(1<<Math.min(this.expiredRequestCount-1,31)):Math.min(this.expirationTime-/* @__PURE__ */(new Date).getTime(),2**31-1)}setFeatureState(e,t,i){if(!this.latestFeatureIndex?.rawTileData||0===Object.keys(e).length||this.featureStateRevision===i)return;this.featureStateRevision=i;let r=this.latestFeatureIndex.loadVTLayers();for(let a in this.buckets){if(!t.style.hasLayer(a))continue;let i=this.buckets[a],n=i.layers[0].sourceLayer||"_geojsonTileLayer",s=r[n],o=e[n];if(!s||!o||0===o.length)continue;i.update(o,s,this.imageAtlas?.patternPositions||{},this.dashPositions||{});let l=t?.style?.getLayer(a);l&&(this.queryPadding=Math.max(this.queryPadding,l.queryRadius(i)))}}holdingForSymbolFade(){return void 0!==this.symbolFadeHoldUntil}symbolFadeFinished(){return!this.symbolFadeHoldUntil||this.symbolFadeHoldUntil<sm()}clearSymbolFadeHold(){this.symbolFadeHoldUntil=void 0}setSymbolHoldDuration(e){this.symbolFadeHoldUntil=sm()+e}setDependencies(e,t){let i={};for(let r of t)i[r]=!0;this.dependencies[e]=i}hasDependency(e,t){for(let i of e){let e=this.dependencies[i];if(e)for(let i of t)if(e[i])return!0}return!1}};function F_(e){let t=[];for(let i in e)t.push({id:i,state:e[i]});return t}var B_=class{constructor(){this.state={},this.stateChanges={},this.deletedStates={},this.revision=0}updateState(e,t,i){let r=String(t);if(this.stateChanges[e]||={},this.stateChanges[e][r]||={},be(this.stateChanges[e][r],i),null===this.deletedStates[e]){this.deletedStates[e]={};for(let t in this.state[e])if(t===r){this.deletedStates[e][r]={};for(let a in this.state[e][t])void 0===i[a]&&(this.deletedStates[e][r][a]=null)}else this.deletedStates[e][t]=null}else if(null===this.deletedStates[e]?.[r]){this.deletedStates[e][r]={};for(let t in this.state[e][r])void 0===i[t]&&(this.deletedStates[e][r][t]=null)}else for(let a in i)null===this.deletedStates[e]?.[r]?.[a]&&delete this.deletedStates[e][r][a]}removeFeatureState(e,t,i){if(null===this.deletedStates[e])return;let r=String(t);if(this.deletedStates[e]||={},i&&void 0!==t)null!==this.deletedStates[e][r]&&(this.deletedStates[e][r]||={},this.deletedStates[e][r][i]=null);else if(void 0!==t)if(this.stateChanges[e]?.[r])for(i in this.deletedStates[e][r]={},this.stateChanges[e][r])this.deletedStates[e][r][i]=null;else this.deletedStates[e][r]=null;else this.deletedStates[e]=null}getState(e,t){let i=String(t),r=this.state[e]||{},a=this.stateChanges[e]||{},n=be({},r[i],a[i]);if(null===this.deletedStates[e])return{};if(this.deletedStates[e]){let i=this.deletedStates[e][t];if(null===i)return{};for(let e in i)delete n[e]}return n}initializeTileState(e,t){let i={};for(let r in this.state)i[r]=F_(this.state[r]);e.setFeatureState(i,t,this.revision)}coalesceChanges(e,t){let i={};for(let a in this.stateChanges){this.state[a]||={},i[a]||={};for(let e in this.stateChanges[a])this.state[a][e]||={},be(this.state[a][e],this.stateChanges[a][e]),i[a][e]=this.state[a][e]}for(let a in this.deletedStates)if(this.state[a]||={},i[a]||={},null===this.deletedStates[a])for(let e in this.state[a])this.state[a][e]={},i[a][e]={};else for(let e in this.deletedStates[a]){if(null===this.deletedStates[a][e])this.state[a][e]={};else for(let t of Object.keys(this.deletedStates[a][e]))delete this.state[a][e][t];i[a][e]=this.state[a][e]}if(this.stateChanges={},this.deletedStates={},0===Object.keys(i).length)return;this.revision++;let r={};for(let a in i)r[a]=F_(i[a]);e.setFeatureState(r,t,this.revision)}};function O_(e,t,i){let r=t.intersectsFrustum(e);if(!i||0===r)return r;let a=t.intersectsPlane(i);return 0===a?0:2===r&&2===a?2:1}function V_(e,t,i){let r=0,a=(i-t)/10;for(let n=0;n<10;n++){let s=t+(n+.5)/10*(i-t);r+=a*Math.cos(s)**+e}return r}function j_(e,t){return function(i,r,a,n,s){let o=2*((e-1)/Ie(Math.cos(Ne(nc-s))/Math.cos(Ne(nc)))-1),l=Math.acos(a/n),h=2*V_(o-1,0,Ne(s/2)),u=Math.min(Ne(nc),l+Ne(s/2)),c=V_(o-1,Math.min(u,l-Ne(s/2)),u),p=Math.atan(r/a),d=i;return d+=Ie(n/Math.hypot(r,a)/Math.max(.5,Math.cos(Ne(s/2)))),d+=o*Ie(Math.cos(p))/2,d-=Ie(Math.max(1,c/h/t))/2,d}}var N_=j_(9.314,3);function U_(e,t){let i=(t.roundZoom?Math.round:Math.floor)(e.zoom+Ie(e.tileSize/t.tileSize));return Math.max(0,i)}function G_(e,t){let i=e.getCameraFrustum(),r=e.getClippingPlane(),a=e.screenPointToMercatorCoordinate(e.getCameraPoint()),n=ac.fromLngLat(e.center,e.elevation);a.z=n.z+Math.cos(e.pitchInRadians)*e.cameraToCenterDistance/e.worldSize;let s=function(e){let t=ve((15-(nc-e.pitch-e.fov/2))/15,0,1);return e.elevation+500*t}(e),o=e.getCoveringTilesDetailsProvider(),l=o.allowVariableZoom(e,t),h=U_(e,t),u=t.minzoom||0,c=void 0===t.maxzoom?e.maxZoom:t.maxzoom,p=Math.min(Math.max(0,h),c),d=2**p,f=[d*a.x,d*a.y,0],m=[d*n.x,d*n.y,0],_=Math.hypot(n.x-a.x,n.y-a.y),g=Math.abs(n.z-a.z),y=Math.hypot(_,g),v=e=>({zoom:0,x:0,y:0,wrap:e,fullyVisible:!1}),x=[],b=[];if(e.renderWorldCopies&&o.allowWorldCopies())for(let w=1;w<=3;w++)x.push(v(-w)),x.push(v(w));for(x.push(v(0));x.length>0;){let d=x.pop(),_=d.x,v=d.y,w=d.fullyVisible,T={x:_,y:v,z:d.zoom},S=o.getTileBoundingVolume(T,d.wrap,s,t);if(!w){let e=O_(i,S,r);if(0===e)continue;w=2===e}let P=o.distanceToTile2d(a.x,a.y,T,S),I=h;l&&(I=(t.calculateTileZoom||N_)(e.zoom+Ie(e.tileSize/t.tileSize),P,g,y,e.fov)),I=(t.roundZoom?Math.round:Math.floor)(I),I=Math.max(0,I);let M=Math.min(I,c);if(d.wrap=o.getWrap(n,T,d.wrap),d.zoom>=M){if(d.zoom<u)continue;let e=p-d.zoom,i=f[0]-.5-(_<<e),r=f[1]-.5-(v<<e),a=t.reparseOverscaled?Math.max(d.zoom,I):d.zoom;b.push({tileID:new kp(d.zoom===c?a:d.zoom,d.wrap,d.zoom,_,v),distanceSq:K([m[0]-.5-_,m[1]-.5-v]),tileDistanceToCamera:Math.sqrt(i*i+r*r)});continue}for(let e=0;e<4;e++){let t=(_<<1)+e%2,i=(v<<1)+(e>>1),r=d.zoom+1;x.push({zoom:r,x:t,y:i,wrap:d.wrap,fullyVisible:w})}}return b.sort((e,t)=>e.distanceSq-t.distanceSq).map(e=>e.tileID)}function $_(e){return"raster"===e||"image"===e||"video"===e}function Z_(e,t,i,r,a,n,s){if(!t.hasData())return!1;let{tileID:o,fadingRole:l,fadingDirection:h,fadingParentID:u}=t;if(0===l&&1===h&&u)return i[u.key]=u,!0;let c=Math.max(o.overscaledZ-a,n);for(let p=o.overscaledZ-1;p>=c;p--){let a=o.scaledTo(p),n=e.getLoadedTile(a);if(n)return t.setCrossFadeLogic({fadingRole:0,fadingDirection:1,fadingParentID:n.tileID,fadeEndTime:r+s}),n.setCrossFadeLogic({fadingRole:1,fadingDirection:0,fadeEndTime:r+s}),i[a.key]=a,!0}return!1}function q_(e,t,i,r,a,n){if(!t.hasData())return!1;let s=t.tileID.children(a),o=W_(e,t,s,i,r,a,n);if(o)return!0;for(let l of s)W_(e,t,l.children(a),i,r,a,n)&&(o=!0);return o}function W_(e,t,i,r,a,n,s){if(i[0].overscaledZ>=n)return!1;let o=!1;for(let l of i){let i=e.getLoadedTile(l);if(!i)continue;let{fadingRole:n,fadingDirection:h,fadingParentID:u}=i;(0!==n||0!==h||!u)&&(i.setCrossFadeLogic({fadingRole:0,fadingDirection:0,fadingParentID:t.tileID,fadeEndTime:a+s}),t.setCrossFadeLogic({fadingRole:1,fadingDirection:1,fadeEndTime:a+s})),r[l.key]=l,o=!0}return o}function H_(e,t,i,r){let a=e.tileID;if(e.selfFading)return!0;if(e.hasData())return!1;if(t.has(a)){let t=i+r;return e.setSelfFadeLogic(t),!0}return!1}function X_(e,t){e.needsHillshadePrepare=!0,e.needsTerrainPrepare=!0;let i=t.tileID.canonical.x-e.tileID.canonical.x,r=t.tileID.canonical.y-e.tileID.canonical.y,a=2**e.tileID.canonical.z,n=t.tileID.key;(0!==i||0!==r)&&(Math.abs(r)>1||(Math.abs(i)>1&&(1===Math.abs(i+a)?i+=a:1===Math.abs(i-a)&&(i-=a)),t.dem&&e.dem&&(e.dem.backfillBorder(t.dem,i,r),e.neighboringTiles?.[n]&&(e.neighboringTiles[n].backfilled=!0))))}var Y_=class{constructor(){this._tiles={}}handleWrapJump(e){let t={};for(let i in this._tiles){let r=this._tiles[i];r.tileID=r.tileID.unwrapTo(r.tileID.wrap+e),t[r.tileID.key]=r}this._tiles=t}setFeatureState(e,t,i){for(let r in this._tiles)this._tiles[r].setFeatureState(e,t,i)}getAllTiles(){return Object.values(this._tiles)}getAllIds(e=!1){return e?Object.values(this._tiles).map(e=>e.tileID).sort(Op).map(e=>e.key):Object.keys(this._tiles)}getTileById(e){return this._tiles[e]}setTile(e,t){this._tiles[e]=t}deleteTileById(e){delete this._tiles[e]}getLoadedTile(e){let t=this.getTileById(e.key);return t?.hasData()?t:null}isIdRenderable(e,t=!1){return this.getTileById(e)?.isRenderable(t)}getRenderableIds(e=0,t){let i=[];for(let r of this.getAllIds())this.isIdRenderable(r,t)&&i.push(this.getTileById(r));return t?i.sort((t,i)=>{let r=t.tileID,a=i.tileID,n=new u(r.canonical.x,r.canonical.y)._rotate(-e),s=new u(a.canonical.x,a.canonical.y)._rotate(-e);return r.overscaledZ-a.overscaledZ||s.y-n.y||s.x-n.x}).map(e=>e.tileID.key):i.map(e=>e.tileID).sort(Op).map(e=>e.key)}},K_=class e extends _t{static{this.maxUnderzooming=10}static{this.maxOverzooming=3}constructor(e,t,i){super(),this.id=e,this.dispatcher=i,this.on("data",e=>{this._dataHandler(e)}),this.on("dataloading",()=>{this._sourceErrored=!1}),this.on("error",()=>{this._sourceErrored=this._source.loaded()}),this._source=((e,t,i,r)=>{let a=new(A_(t.type))(e,t,i,r);if(a.id!==e)throw Error(`Expected Source id to be ${e} instead of ${a.id}`);return a})(e,t,i,this),this._inViewTiles=new Y_,this._outOfViewCache=new Kf(0,e=>this._unloadTile(e)),this._timers={},this._maxTileCacheSize=null,this._maxTileCacheZoomLevels=null,this._rasterFadeDuration=0,this._maxFadingAncestorLevels=5,this._state=new B_,this._didEmitContent=!1,this._updated=!1}onAdd(e){this.map=e,this._maxTileCacheSize=e?e._maxTileCacheSize:null,this._maxTileCacheZoomLevels=e?e._maxTileCacheZoomLevels:null,this._source?.onAdd&&this._source.onAdd(e)}onRemove(e){for(let t of this._inViewTiles.getAllTiles())t.unloadVectorData();this.clearTiles(),this._source?.onRemove&&this._source.onRemove(e),this._inViewTiles=new Y_}loaded(){if(this._sourceErrored)return!0;if(!this._sourceLoaded||!this._source.loaded())return!1;if(!(void 0===this.used&&void 0===this.usedForTerrain||this.used||this.usedForTerrain))return!0;if(!this._updated)return!1;for(let e of this._inViewTiles.getAllTiles())if("loaded"!==e.state&&"errored"!==e.state)return!1;return!0}getSource(){return this._source}getState(){return this._state}pause(){this._paused=!0}resume(){if(!this._paused)return;let e=this._shouldReloadOnResume;this._paused=!1,this._shouldReloadOnResume=!1,e&&this.reload(),this.transform&&this.update(this.transform,this.terrain)}async _loadTile(e,t,i,r){try{let a=await this._source.loadTile(e);this._tileLoaded(e,t,i,r,a)}catch(t){e.state="errored",404===t.status?this.update(this.transform,this.terrain):this._source.fire(new mt(ee(t),{tile:e}))}}_unloadTile(e){this._source.unloadTile&&this._source.unloadTile(e)}_abortTile(e){this._source.abortTile&&this._source.abortTile(e),this._source.fire(new gm("dataabort",{tile:e,coord:e.tileID}))}serialize(){return this._source.serialize()}prepare(e){this._source.prepare&&this._source.prepare(),this._state.coalesceChanges(this._inViewTiles,this.map?this.map.painter:null);for(let t of this._inViewTiles.getAllTiles())t.upload(e),t.prepare(this.map.style.imageManager)}getIds(){return this._inViewTiles.getAllIds(!0)}getRenderableIds(e){return this._inViewTiles.getRenderableIds(this.transform?.bearingInRadians,e)}hasRenderableParent(e){let t=e.overscaledZ-1;if(t>=this._source.minzoom){let i=this.getLoadedTile(e.scaledTo(t));if(i)return this._inViewTiles.isIdRenderable(i.tileID.key)}return!1}reload(e,t=void 0){if(this._paused)this._shouldReloadOnResume=!0;else{this._outOfViewCache.reset();for(let i of this._inViewTiles.getAllIds()){let r=this._inViewTiles.getTileById(i);t&&!this._source.shouldReloadTile(r,t)||(e?this._reloadTile(i,"errored"===r.state?"loading":"expired"):"errored"!==r.state&&this._reloadTile(i,"reloading"))}}}async _reloadTile(e,t){let i=this._inViewTiles.getTileById(e);if(!i)return;let r=i.hasData();"loading"!==i.state&&(i.state=t),await this._loadTile(i,e,t,r)}_tileLoaded(e,t,i,r,a){r||(e.timeAdded=sm(),e.selfFading&&(e.fadeEndTime=e.timeAdded+this._rasterFadeDuration)),"expired"===i&&(e.refreshedUponExpiration=!0),this._setTileReloadTimer(t,e),!a?.unmodified&&("raster-dem"===this.getSource().type&&e.dem&&function(e,t){let i=t.getRenderableIds();for(let r of i){if(!e.neighboringTiles?.[r])continue;let i=t.getTileById(r);e.neighboringTiles[r].backfilled||X_(e,i),!i.neighboringTiles?.[e.tileID.key]?.backfilled&&X_(i,e)}}(e,this._inViewTiles),e.featureStateRevision=-1,this._state.initializeTileState(e,this.map?this.map.painter:null),e.aborted||this._source.fire(new gm("data",{tile:e,coord:e.tileID})))}getTile(e){return this.getTileByID(e.key)}getTileByID(e){return this._inViewTiles.getTileById(e)}_retainLoadedChildren(t,i){let r=this._getLoadedDescendents(i),a=/* @__PURE__ */new Set;for(let n of i){let i=r[n.key];if(!i?.length){a.add(n);continue}let s=n.overscaledZ+e.maxOverzooming,o=i.filter(e=>e.tileID.overscaledZ<=s);if(!o.length){a.add(n);continue}let l=Math.min(...o.map(e=>e.tileID.overscaledZ)),h=o.filter(e=>e.tileID.overscaledZ===l).map(e=>e.tileID);for(let e of h)t[e.key]=e;this._areDescendentsComplete(h,l,n.overscaledZ)||a.add(n)}return a}_getLoadedDescendents(e){let t={};for(let i of this._inViewTiles.getAllTiles().filter(e=>e.hasData()))for(let r of e)i.tileID.isChildOf(r)&&(t[r.key]||=[],t[r.key].push(i));return t}_areDescendentsComplete(e,t,i){return 1===e.length&&e[0].isOverscaled()?e[0].overscaledZ===t:4**(t-i)===e.length}getLoadedTile(e){return this._inViewTiles.getLoadedTile(e)}updateCacheSize(e){let t=(Math.ceil(e.width/this._source.tileSize)+1)*(Math.ceil(e.height/this._source.tileSize)+1),i=null===this._maxTileCacheZoomLevels?it.MAX_TILE_CACHE_ZOOM_LEVELS:this._maxTileCacheZoomLevels,r=Math.floor(t*i),a="number"==typeof this._maxTileCacheSize?Math.min(this._maxTileCacheSize,r):r;this._outOfViewCache.setMaxSize(a)}handleWrapJump(e){let t=(e-(void 0===this._prevLng?e:this._prevLng))/360,i=Math.round(t);this._prevLng=e,i&&(this._inViewTiles.handleWrapJump(i),this._resetTileReloadTimers())}update(e,t){if(!this._sourceLoaded||this._paused)return;let i;this.transform=e,this.terrain=t,this.updateCacheSize(e),this.handleWrapJump(this.transform.center.lng),this.used||this.usedForTerrain?this._source.tileID?i=e.getVisibleUnwrappedCoordinates(this._source.tileID).map(e=>new kp(e.canonical.z,e.wrap,e.canonical.z,e.canonical.x,e.canonical.y)):(i=G_(e,{tileSize:this.usedForTerrain?this.tileSize:this._source.tileSize,minzoom:this._source.minzoom,maxzoom:"vector"===this._source.type&&void 0!==this.map._zoomLevelsToOverscale?Math.max(this._source.maxzoom,e.maxZoom-this.map._zoomLevelsToOverscale):this._source.maxzoom,roundZoom:!this.usedForTerrain&&this._source.roundZoom,reparseOverscaled:this._source.reparseOverscaled,terrain:t,calculateTileZoom:this._source.calculateTileZoom}),this._source.hasTile&&(i=i.filter(e=>this._source.hasTile(e)))):i=[],this.usedForTerrain&&(i=this._addTerrainIdealTiles(i));let r=0===i.length&&!this._updated&&this._didEmitContent;this._updated=!0,r&&this.fire(new gm("data",{sourceDataType:"idle",sourceId:this.id}));let a=U_(e,this._source),n=this._updateRetainedTiles(i,a),s=$_(this._source.type);s&&this._rasterFadeDuration>0&&!t&&function(e,t,i,r,a,n,s){let o=sm(),l=function(e){if(!e.length)/* @__PURE__ */return new Set;let t=Math.max(...e.map(e=>e.canonical.z)),i=1/0,r=-1/0,a=1/0,n=-1/0,s=[];for(let l of e){let{x:e,y:o,z:h}=l.canonical,u=2**(t-h),c=e*u,p=o*u;s.push({id:l,x:c,y:p}),c<i&&(i=c),c>r&&(r=c),p<a&&(a=p),p>n&&(n=p)}let o=/* @__PURE__ */new Set;for(let l of s)(l.x===i||l.x===r||l.y===a||l.y===n)&&o.add(l.id);return o}(t);for(let h of t){let t=e.getTileById(h.key);(0===t.fadingDirection||0===t.fadeOpacity)&&t.resetFadeLogic(),!Z_(e,t,i,o,r,a,s)&&(q_(e,t,i,o,n,s)||H_(t,l,o,s)||t.resetFadeLogic())}}(this._inViewTiles,i,n,this._maxFadingAncestorLevels,this._source.minzoom,this._source.maxzoom,this._rasterFadeDuration),s?this._cleanUpRasterTiles(n):this._cleanUpVectorTiles(n)}_cleanUpRasterTiles(e){for(let t of this._inViewTiles.getAllIds())e[t]||this._removeTile(t)}_cleanUpVectorTiles(e){for(let t of this._inViewTiles.getAllIds()){let i=this._inViewTiles.getTileById(t);e[t]?i.clearSymbolFadeHold():i.hasSymbolBuckets?i.holdingForSymbolFade()?i.symbolFadeFinished()&&this._removeTile(t):i.setSymbolHoldDuration(this.map._fadeDuration):this._removeTile(t)}}_addTerrainIdealTiles(e){let t=[];for(let i of e)if(i.canonical.z>this._source.minzoom){let e=i.scaledTo(i.canonical.z-1);t.push(e);let r=i.scaledTo(Math.max(this._source.minzoom,Math.min(i.canonical.z,5)));t.push(r)}return e.concat(t)}releaseSymbolFadeTiles(){for(let e of this._inViewTiles.getAllIds())this._inViewTiles.getTileById(e).holdingForSymbolFade()&&this._removeTile(e)}_updateRetainedTiles(t,i){let r=/* @__PURE__ */new Set;for(let e of t)this._addTile(e).hasData()||r.add(e);let a=t.reduce((e,t)=>(e[t.key]=t,e),{}),n=this._retainLoadedChildren(a,r),s={},o=Math.max(i-e.maxUnderzooming,this._source.minzoom);for(let e of n){let t=this._inViewTiles.getTileById(e.key),i=t?.wasRequested();for(let r=e.overscaledZ-1;r>=o;--r){let n=e.scaledTo(r);if(s[n.key])break;if(s[n.key]=!0,t=this.getTile(n),!t&&i&&(t=this._addTile(n)),t){let e=t.hasData();if((e||!this.map?.cancelPendingTileRequestsWhileZooming||i)&&(a[n.key]=n),i=t.wasRequested(),e)break}}}return a}_addTile(e){let t=this._inViewTiles.getTileById(e.key);if(t)return t;t=this._outOfViewCache.getAndRemove(e),t&&(t.resetFadeLogic(),this._setTileReloadTimer(e.key,t),t.tileID=e,this._state.initializeTileState(t,this.map?this.map.painter:null));let i=t;return t||(t=new L_(e,this._source.tileSize*e.overscaleFactor()),this._loadTile(t,e.key,t.state,!1)),t.uses++,this._inViewTiles.setTile(e.key,t),i||this._source.fire(new gm("dataloading",{tile:t,coord:t.tileID})),t}_setTileReloadTimer(e,t){this._clearTileReloadTimer(e);let i=t.getExpiryTimeout();if(i){let t=()=>{this._reloadTile(e,"expired"),delete this._timers[e]};this._timers[e]=setTimeout(t,i)}}_clearTileReloadTimer(e){let t=this._timers[e];t&&(clearTimeout(t),delete this._timers[e])}_resetTileReloadTimers(){for(let e in this._timers)clearTimeout(this._timers[e]),delete this._timers[e];for(let e of this._inViewTiles.getAllIds()){let t=this._inViewTiles.getTileById(e);this._setTileReloadTimer(e,t)}}refreshTiles(e){for(let t of this._inViewTiles.getAllIds()){let i=this._inViewTiles.getTileById(t);!this._inViewTiles.isIdRenderable(t)&&"errored"!=i.state||e.some(e=>e.equals(i.tileID.canonical))&&this._reloadTile(t,"expired")}}_removeTile(e){let t=this._inViewTiles.getTileById(e);t&&(t.uses--,this._inViewTiles.deleteTileById(e),this._clearTileReloadTimer(e),!(t.uses>0)&&(t.hasData()&&"reloading"!==t.state?this._outOfViewCache.add(t.tileID,t,t.getExpiryTimeout()):(t.aborted=!0,this._abortTile(t),this._unloadTile(t))))}_dataHandler(e){if("source"===e.dataType){if("metadata"===e.sourceDataType)return void(this._sourceLoaded=!0);"content"!==e.sourceDataType||!this._sourceLoaded||this._paused||(this.reload(e.sourceDataChanged,e.shouldReloadTileOptions),this.transform&&this.update(this.transform,this.terrain),this._didEmitContent=!0)}}clearTiles(){this._shouldReloadOnResume=!1,this._paused=!1;for(let e of this._inViewTiles.getAllIds())this._removeTile(e);this._outOfViewCache.reset()}tilesIn(e,t,i){let r=[],a=this.transform;if(!a)return r;let n=a.getCoveringTilesDetailsProvider().allowWorldCopies(),s=i?a.getCameraQueryGeometry(e):e,o=e=>a.screenPointToMercatorCoordinate(e,this.terrain),l=this.transformBbox(e,o,!n),h=this.transformBbox(s,o,!n),u=this.getIds(),c=Ou.fromPoints(h);for(let p of u){let e=this._inViewTiles.getTileById(p);if(e.holdingForSymbolFade())continue;let i=n?[e.tileID]:[e.tileID.unwrapTo(-1),e.tileID.unwrapTo(0)],s=2**(a.zoom-e.tileID.overscaledZ),o=t*e.queryPadding*J/e.tileSize/s;for(let t of i){let i=c.map(e=>t.getTilePoint(new ac(e.x,e.y)));if(i.expandBy(o),i.intersects(Vu)){let i=l.map(e=>t.getTilePoint(e)),a=h.map(e=>t.getTilePoint(e));r.push({tile:e,tileID:n?t:t.unwrapTo(0),queryGeometry:i,cameraQueryGeometry:a,scale:s})}}}return r}transformBbox(e,t,i){let r=e.map(t);if(i){let i=Ou.fromPoints(e);i.shrinkBy(.001*Math.min(i.width(),i.height()));let a=i.map(t);Ou.fromPoints(r).covers(a)||(r=r.map(e=>e.x>.5?new ac(e.x-1,e.y,e.z):e))}return r}getVisibleCoordinates(e){let t=this.getRenderableIds(e).map(e=>this._inViewTiles.getTileById(e).tileID);return this.transform&&this.transform.populateCache(t),t}hasTransition(){return!!this._source.hasTransition()||$_(this._source.type)&&function(e,t){if(t<=0)return!1;let i=sm();for(let r of e.getAllTiles())if(r.fadeEndTime>=i)return!0;return!1}(this._inViewTiles,this._rasterFadeDuration)}setRasterFadeDuration(e){this._rasterFadeDuration=e}setFeatureState(e,t,i){e||=Np,this._state.updateState(e,t,i)}removeFeatureState(e,t,i){e||=Np,this._state.removeFeatureState(e,t,i)}getFeatureState(e,t){return e||=Np,this._state.getState(e,t)}setDependencies(e,t,i){let r=this._inViewTiles.getTileById(e);r&&r.setDependencies(t,i)}reloadTilesForDependencies(e,t){for(let i of this._inViewTiles.getAllIds())this._inViewTiles.getTileById(i).hasDependency(e,t)&&this._reloadTile(i,"reloading");this._outOfViewCache.filter(i=>!i.hasDependency(e,t))}areTilesLoaded(){for(let e of this._inViewTiles.getAllTiles())if("loaded"!==e.state&&"errored"!==e.state)return!1;return!0}},J_=class{constructor(e,t){this.reset(e,t)}reset(e,t){this.points=e||[],this._distances=[0];for(let i=1;i<this.points.length;i++)this._distances[i]=this._distances[i-1]+this.points[i].dist(this.points[i-1]);this.length=this._distances[this._distances.length-1],this.padding=Math.min(t||0,.5*this.length),this.paddedLength=this.length-2*this.padding}lerp(e){if(1===this.points.length)return this.points[0];e=ve(e,0,1);let t=1,i=this._distances[t],r=e*this.paddedLength+this.padding;for(;i<r&&t<this._distances.length;)i=this._distances[++t];let a=t-1,n=this._distances[a],s=i-n,o=s>0?(r-n)/s:0;return this.points[a].mult(1-o).add(this.points[t].mult(o))}};function Q_(e,t){let i=!0;return"always"===e||("never"===e||"never"===t)&&(i=!1),i}var eg=class{constructor(e,t,i){let r=this.boxCells=[],a=this.circleCells=[];this.xCellCount=Math.ceil(e/i),this.yCellCount=Math.ceil(t/i);for(let n=0;n<this.xCellCount*this.yCellCount;n++)r.push([]),a.push([]);this.circleKeys=[],this.boxKeys=[],this.bboxes=[],this.circles=[],this.width=e,this.height=t,this.xScale=this.xCellCount/e,this.yScale=this.yCellCount/t,this.boxUid=0,this.circleUid=0}keysLength(){return this.boxKeys.length+this.circleKeys.length}insert(e,t,i,r,a){this._forEachCell(t,i,r,a,this._insertBoxCell,this.boxUid++),this.boxKeys.push(e),this.bboxes.push(t),this.bboxes.push(i),this.bboxes.push(r),this.bboxes.push(a)}insertCircle(e,t,i,r){this._forEachCell(t-r,i-r,t+r,i+r,this._insertCircleCell,this.circleUid++),this.circleKeys.push(e),this.circles.push(t),this.circles.push(i),this.circles.push(r)}_insertBoxCell(e,t,i,r,a,n){this.boxCells[a].push(n)}_insertCircleCell(e,t,i,r,a,n){this.circleCells[a].push(n)}_query(e,t,i,r,a,n,s){if(i<0||e>this.width||r<0||t>this.height)return[];let o=[];if(e<=0&&t<=0&&this.width<=i&&this.height<=r){if(a)return[{key:null,x1:e,y1:t,x2:i,y2:r}];for(let e=0;e<this.boxKeys.length;e++)o.push({key:this.boxKeys[e],x1:this.bboxes[4*e],y1:this.bboxes[4*e+1],x2:this.bboxes[4*e+2],y2:this.bboxes[4*e+3]});for(let e=0;e<this.circleKeys.length;e++){let t=this.circles[3*e],i=this.circles[3*e+1],r=this.circles[3*e+2];o.push({key:this.circleKeys[e],x1:t-r,y1:i-r,x2:t+r,y2:i+r})}}else{let l={hitTest:a,overlapMode:n,seenUids:{box:{},circle:{}}};this._forEachCell(e,t,i,r,this._queryCell,o,l,s)}return o}query(e,t,i,r){return this._query(e,t,i,r,!1,null)}hitTest(e,t,i,r,a,n){return this._query(e,t,i,r,!0,a,n).length>0}hitTestCircle(e,t,i,r,a){let n=e-i,s=e+i,o=t-i,l=t+i;if(s<0||n>this.width||l<0||o>this.height)return!1;let h=[],u={hitTest:!0,overlapMode:r,circle:{x:e,y:t,radius:i},seenUids:{box:{},circle:{}}};return this._forEachCell(n,o,s,l,this._queryCellCircle,h,u,a),h.length>0}_queryCell(e,t,i,r,a,n,s,o){let{seenUids:l,hitTest:h,overlapMode:u}=s,c=this.boxCells[a],p=1e-6;if(null!==c){let a=this.bboxes;for(let s of c)if(!l.box[s]){l.box[s]=!0;let c=4*s,d=this.boxKeys[s];if(e<=a[c+2]+p&&t<=a[c+3]+p&&i>=a[c+0]-p&&r>=a[c+1]-p&&(!o||o(d))&&(!h||!Q_(u,d.overlapMode))&&(n.push({key:d,x1:a[c],y1:a[c+1],x2:a[c+2],y2:a[c+3]}),h))return!0}}let d=this.circleCells[a];if(null!==d){let a=this.circles;for(let s of d)if(!l.circle[s]){l.circle[s]=!0;let c=3*s,p=this.circleKeys[s];if(this._circleAndRectCollide(a[c],a[c+1],a[c+2],e,t,i,r)&&(!o||o(p))&&(!h||!Q_(u,p.overlapMode))){let e=a[c],t=a[c+1],i=a[c+2];if(n.push({key:p,x1:e-i,y1:t-i,x2:e+i,y2:t+i}),h)return!0}}}return!1}_queryCellCircle(e,t,i,r,a,n,s,o){let{circle:l,seenUids:h,overlapMode:u}=s,c=this.boxCells[a];if(null!==c){let e=this.bboxes;for(let t of c)if(!h.box[t]){h.box[t]=!0;let i=4*t,r=this.boxKeys[t];if(this._circleAndRectCollide(l.x,l.y,l.radius,e[i+0],e[i+1],e[i+2],e[i+3])&&(!o||o(r))&&!Q_(u,r.overlapMode))return n.push(!0),!0}}let p=this.circleCells[a];if(null!==p){let e=this.circles;for(let t of p)if(!h.circle[t]){h.circle[t]=!0;let i=3*t,r=this.circleKeys[t];if(this._circlesCollide(e[i],e[i+1],e[i+2],l.x,l.y,l.radius)&&(!o||o(r))&&!Q_(u,r.overlapMode))return n.push(!0),!0}}}_forEachCell(e,t,i,r,a,n,s,o){let l=this._convertToXCellCoord(e),h=this._convertToYCellCoord(t),u=this._convertToXCellCoord(i),c=this._convertToYCellCoord(r);for(let p=l;p<=u;p++)for(let l=h;l<=c;l++){let h=this.xCellCount*l+p;if(a.call(this,e,t,i,r,h,n,s,o))return}}_convertToXCellCoord(e){return Math.max(0,Math.min(this.xCellCount-1,Math.floor(e*this.xScale)))}_convertToYCellCoord(e){return Math.max(0,Math.min(this.yCellCount-1,Math.floor(e*this.yScale)))}_circlesCollide(e,t,i,r,a,n){let s=r-e,o=a-t,l=i+n;return l*l>s*s+o*o}_circleAndRectCollide(e,t,i,r,a,n,s){let o=(n-r)/2,l=Math.abs(e-(r+o));if(l>o+i)return!1;let h=(s-a)/2,u=Math.abs(t-(a+h));if(u>h+i)return!1;if(l<=o||u<=h)return!0;let c=l-o,p=u-h;return c*c+p*p<=i*i}};function tg(e,t){let i=1/(t[0]*t[0]+t[1]*t[1]+t[2]*t[2]),r=1/(t[8]*t[8]+t[9]*t[9]+t[10]*t[10]),a=t[0]*i,n=t[4]*i,s=t[8]*r,o=t[1]*i,l=t[5]*i,h=t[9]*r,u=t[2]*i,c=t[6]*i,p=t[10]*r;e[0]=a,e[1]=n,e[2]=s,e[4]=o,e[5]=l,e[6]=h,e[8]=u,e[9]=c,e[10]=p;let d=t[12],f=t[13],m=t[14];return e[12]=-a*d-o*f-u*m,e[13]=-n*d-l*f-c*m,e[14]=-s*d-h*f-p*m,e[3]=0,e[7]=0,e[11]=0,e[15]=1,e}var ig=f();function rg(e,t,i){let r=f();if(!e){let{vecSouth:e,vecEast:i}=ng(t),a=rm();a[0]=i[0],a[1]=i[1],a[2]=e[0],a[3]=e[1],function(e,t){var i=t[0],r=t[1],a=t[2],n=t[3],s=i*n-a*r;s&&(s=1/s,e[0]=n*s,e[1]=-r*s,e[2]=-a*s,e[3]=i*s)}(a,a),r[0]=a[0],r[1]=a[1],r[4]=a[2],r[5]=a[3]}return x(r,r,[1/i,1/i,1]),r}function ag(e,t,i,r){if(e){let e=f();if(!t){let{vecSouth:t,vecEast:r}=ng(i);e[0]=r[0],e[1]=r[1],e[4]=t[0],e[5]=t[1]}return x(e,e,[r,r,1]),e}return i.pixelsToClipSpaceMatrix}function ng(e){let t=Math.cos(e.rollInRadians),i=Math.sin(e.rollInRadians),r=Math.cos(e.pitchInRadians),a=Math.cos(e.bearingInRadians),n=Math.sin(e.bearingInRadians),s=q();s[0]=-a*r*i-n*t,s[1]=-n*r*i+a*t;let o=X(s);o<1e-9?Y(s):H(s,s,1/o);let l=q();l[0]=a*r*t-n*i,l[1]=n*r*t+a*i;let h=X(l);return h<1e-9?Y(l):H(l,l,1/h),{vecEast:l,vecSouth:s}}function sg(e,t,i,r){let a;r?(a=[e,t,r(e,t),1],U(a,a,i)):(a=[e,t,0,1],Tg(a,a,i));let n=a[3];return{point:new u(a[0]/n,a[1]/n),signedDistanceFromCamera:n,isOccluded:!1}}function og(e,t){return.5+e/t*.5}function lg(e,t){return e.x>=-t[0]&&e.x<=t[0]&&e.y>=-t[1]&&e.y<=t[1]}function hg(e,t,i,r,a,n,s,o,l,h,c,p,d){let f=i?e.textSizeData:e.iconSizeData,m=lp(f,t.transform.zoom),_=[256/t.width*2+1,256/t.height*2+1],g=i?e.text.dynamicLayoutVertexArray:e.icon.dynamicLayoutVertexArray;g.clear();let y=e.lineVertexArray,v=i?e.text.placedSymbolArray:e.icon.placedSymbolArray,x=t.transform.width/t.transform.height,b=!1;for(let w=0;w<v.length;w++){let i=v.get(w);if(i.hidden||2===i.writingMode&&!b){wg(i.numGlyphs,g);continue}b=!1;let T=new u(i.anchorX,i.anchorY),S={getElevation:d,pitchedLabelPlaneMatrix:r,lineVertexArray:y,pitchWithMap:n,projectionCache:{projections:{},offsets:{},cachedAnchorPoint:void 0,anyProjectionOccluded:!1},transform:t.transform,tileAnchorPoint:T,unwrappedTileID:l,width:h,height:c,translation:p},P=gg(i.anchorX,i.anchorY,S);if(!lg(P.point,_)){wg(i.numGlyphs,g);continue}let I=P.signedDistanceFromCamera,M=og(t.transform.cameraToCenterDistance,I),E=op(f,m,i),A=n?E*t.transform.getPitchedTextCorrection(i.anchorX,i.anchorY,l)/M:E*M,C=pg({projectionContext:S,pitchedLabelPlaneMatrixInverse:a,symbol:i,fontSize:A,flip:!1,keepUpright:s,glyphOffsetArray:e.glyphOffsetArray,dynamicLayoutVertexArray:g,aspectRatio:x,rotateToLine:o});b=C.useVertical,(C.notEnoughRoom||b||C.needsFlipping&&pg({projectionContext:S,pitchedLabelPlaneMatrixInverse:a,symbol:i,fontSize:A,flip:!0,keepUpright:s,glyphOffsetArray:e.glyphOffsetArray,dynamicLayoutVertexArray:g,aspectRatio:x,rotateToLine:o}).notEnoughRoom)&&wg(i.numGlyphs,g)}i?e.text.dynamicLayoutVertexBuffer.updateData(g):e.icon.dynamicLayoutVertexBuffer.updateData(g)}function ug(e,t,i,r,a,n,s,o){let l=n.glyphStartIndex+n.numGlyphs,h=n.lineStartIndex,u=n.lineStartIndex+n.lineLength,c=t.getoffsetX(n.glyphStartIndex),p=t.getoffsetX(l-1),d=xg(e*c,i,r,a,n.segment,h,u,o,s);if(!d)return null;let f=xg(e*p,i,r,a,n.segment,h,u,o,s);return!f||o.projectionCache.anyProjectionOccluded?null:{first:d,last:f}}function cg(e,t,i,r){return 1===e&&Math.abs(i.y-t.y)>Math.abs(i.x-t.x)*r?{useVertical:!0}:(2===e?t.y<i.y:t.x>i.x)?{needsFlipping:!0}:null}function pg(e){let t,{projectionContext:i,pitchedLabelPlaneMatrixInverse:r,symbol:a,fontSize:n,flip:s,keepUpright:o,glyphOffsetArray:l,dynamicLayoutVertexArray:h,aspectRatio:c,rotateToLine:p}=e,d=n/24,f=a.lineOffsetX*d,m=a.lineOffsetY*d;if(a.numGlyphs>1){let e=a.glyphStartIndex+a.numGlyphs,n=a.lineStartIndex,h=a.lineStartIndex+a.lineLength,u=ug(d,l,f,m,s,a,p,i);if(!u)return{notEnoughRoom:!0};let _=_g(u.first.point.x,u.first.point.y,i,r),g=_g(u.last.point.x,u.last.point.y,i,r);if(o&&!s){let e=cg(a.writingMode,_,g,c);if(e)return e}t=[u.first];for(let r=a.glyphStartIndex+1;r<e-1;r++){let e=xg(d*l.getoffsetX(r),f,m,s,a.segment,n,h,i,p);if(!e)return{notEnoughRoom:!0};t.push(e)}t.push(u.last)}else{if(o&&!s){let e=mg(i.tileAnchorPoint.x,i.tileAnchorPoint.y,i).point,t=a.lineStartIndex+a.segment+1,n=new u(i.lineVertexArray.getx(t),i.lineVertexArray.gety(t)),s=mg(n.x,n.y,i),o=s.signedDistanceFromCamera>0?s.point:dg(i.tileAnchorPoint,n,e,1,i),l=_g(e.x,e.y,i,r),h=_g(o.x,o.y,i,r),p=cg(a.writingMode,l,h,c);if(p)return p}let e=xg(d*l.getoffsetX(a.glyphStartIndex),f,m,s,a.segment,a.lineStartIndex,a.lineStartIndex+a.lineLength,i,p);if(!e||i.projectionCache.anyProjectionOccluded)return{notEnoughRoom:!0};t=[e]}for(let u of t)pp(h,u.point,u.angle);return{}}function dg(e,t,i,r,a){let n=e.add(e.sub(t)._unit()),s=mg(n.x,n.y,a).point,o=i.sub(s);return i.add(o._mult(r/o.mag()))}function fg(e,t,i){let r=t.projectionCache;if(r.projections[e])return r.projections[e];let a=new u(t.lineVertexArray.getx(e),t.lineVertexArray.gety(e)),n=mg(a.x,a.y,t);if(n.signedDistanceFromCamera>0)return r.projections[e]=n.point,r.anyProjectionOccluded||=n.isOccluded,n.point;let s=e-i.direction,o=0===i.distanceFromAnchor?t.tileAnchorPoint:new u(t.lineVertexArray.getx(s),t.lineVertexArray.gety(s)),l=i.absOffsetX-i.distanceFromAnchor+1;return dg(o,a,i.previousVertex,l,t)}function mg(e,t,i){let r,a=e+i.translation[0],n=t+i.translation[1];return i.pitchWithMap?(r=sg(a,n,i.pitchedLabelPlaneMatrix,i.getElevation),r.isOccluded=!1):(r=i.transform.projectTileCoordinates(a,n,i.unwrappedTileID,i.getElevation),r.point.x=(.5*r.point.x+.5)*i.width,r.point.y=(.5*-r.point.y+.5)*i.height),r}function _g(e,t,i,r){if(i.pitchWithMap){let a=[e,t,0,1];return U(a,a,r),i.transform.projectTileCoordinates(a[0]/a[3],a[1]/a[3],i.unwrappedTileID,i.getElevation).point}return{x:e/i.width*2-1,y:1-t/i.height*2}}function gg(e,t,i){return i.transform.projectTileCoordinates(e,t,i.unwrappedTileID,i.getElevation)}function yg(e,t,i){return e._unit()._perp()._mult(t*i)}function vg(e,t,i,r,a,n,s,o,l){if(o.projectionCache.offsets[e])return o.projectionCache.offsets[e];let h=i.add(t);if(e+l.direction<r||e+l.direction>=a)return o.projectionCache.offsets[e]=h,h;let u=fg(e+l.direction,o,l),c=yg(u.sub(i),s,l.direction),p=i.add(c),d=u.add(c);return o.projectionCache.offsets[e]=Le(n,h,p,d)||h,o.projectionCache.offsets[e]}function xg(e,t,i,r,a,n,s,o,l){let h=r?e-t:e+t,u=h>0?1:-1,c=0;r&&(u*=-1,c=Math.PI),u<0&&(c+=Math.PI);let p,d=u>0?n+a:n+a+1;o.projectionCache.cachedAnchorPoint?p=o.projectionCache.cachedAnchorPoint:(p=mg(o.tileAnchorPoint.x,o.tileAnchorPoint.y,o).point,o.projectionCache.cachedAnchorPoint=p);let f,m,_,g=p,y=p,v=0,x=0,b=Math.abs(h),w=[];for(;v+x<=b;){if(d+=u,d<n||d>=s)return null;v+=x,y=g,m=f;let e={absOffsetX:b,direction:u,distanceFromAnchor:v,previousVertex:y};if(g=fg(d,o,e),0===i)w.push(y),_=g.sub(y);else{let t,r=g.sub(y);t=0===r.mag()?yg(fg(d+u,o,e).sub(g),i,u):yg(r,i,u),m||=y.add(t),f=vg(d,t,g,n,s,m,i,o,e),w.push(m),_=f.sub(m)}x=_.mag()}let T=(b-v)/x,S=_._mult(T)._add(m||y),P=c+Math.atan2(g.y-y.y,g.x-y.x);return w.push(S),{point:S,angle:l?P:0,path:w}}var bg=new Float32Array([-1/0,-1/0,0,-1/0,-1/0,0,-1/0,-1/0,0,-1/0,-1/0,0]);function wg(e,t){for(let i=0;i<e;i++){let e=t.length;t.resize(e+4),t.float32.set(bg,3*e)}}function Tg(e,t,i){let r=t[0],a=t[1];return e[0]=i[0]*r+i[4]*a+i[12],e[1]=i[1]*r+i[5]*a+i[13],e[3]=i[3]*r+i[7]*a+i[15],e}var Sg=class{constructor(e,t=new eg(e.width+200,e.height+200,25),i=new eg(e.width+200,e.height+200,25)){this.transform=e,this.grid=t,this.ignoredGrid=i,this.pitchFactor=Math.cos(e.pitch*Math.PI/180)*e.cameraToCenterDistance,this.screenRightBoundary=e.width+100,this.screenBottomBoundary=e.height+100,this.gridRightBoundary=e.width+200,this.gridBottomBoundary=e.height+200,this.perspectiveRatioCutoff=.6}placeCollisionBox(e,t,i,r,a,n,s,o,l,h,u,c){let p,d=e.anchorPointX+o[0],f=e.anchorPointY+o[1],m=this.projectAndGetPerspectiveRatio(d,f,a,h,c),_=i*m.perspectiveRatio;if(n||s)p=this._projectCollisionBox(e,_,r,a,n,s,o,m,h,u,c);else{let t=m.x+(u?u.x*_:0),i=m.y+(u?u.y*_:0);p={allPointsOccluded:!1,box:[t+e.x1*_,i+e.y1*_,t+e.x2*_,i+e.y2*_]}}let[g,y,v,x]=p.box,b=n?p.allPointsOccluded:m.isOccluded,w=b;return w||=m.perspectiveRatio<this.perspectiveRatioCutoff,w||=!this.isInsideGrid(g,y,v,x),w||"always"!==t&&this.grid.hitTest(g,y,v,x,t,l)?{box:[g,y,v,x],placeable:!1,offscreen:!1,occluded:b}:{box:[g,y,v,x],placeable:!0,offscreen:this.isOffscreen(g,y,v,x),occluded:b}}placeCollisionCircles(e,t,i,r,a,n,s,o,l,h,c,p,d,f){let m=[],_=new u(t.anchorX,t.anchorY),g=this.getPerspectiveRatio(_.x,_.y,n,f),y=(l?a*this.transform.getPitchedTextCorrection(t.anchorX,t.anchorY,n)/g:a*g)/24,v=t.lineOffsetX*y,x=t.lineOffsetY*y,b={getElevation:f,pitchedLabelPlaneMatrix:s,lineVertexArray:i,pitchWithMap:l,projectionCache:{projections:{},offsets:{},cachedAnchorPoint:void 0,anyProjectionOccluded:!1},transform:this.transform,tileAnchorPoint:_,unwrappedTileID:n,width:this.transform.width,height:this.transform.height,translation:d},w=ug(y,r,v,x,!1,t,!1,b),T=!1,S=!1,P=!0;if(w){let t=.5*c*g+p,i=new u(-100,-100),r=new u(this.screenRightBoundary,this.screenBottomBoundary),a=new J_,n=w.first,s=w.last,d=[];for(let e=n.path.length-1;e>=1;e--)d.push(n.path[e]);for(let e=1;e<s.path.length;e++)d.push(s.path[e]);let f=2.5*t;if(l){let e=this.projectPathToScreenSpace(d,b);d=e.some(e=>e.signedDistanceFromCamera<=0)?[]:e.map(e=>e.point)}let _=[];if(d.length>0){let e=d[0].clone(),t=d[0].clone();for(let i=1;i<d.length;i++)e.x=Math.min(e.x,d[i].x),e.y=Math.min(e.y,d[i].y),t.x=Math.max(t.x,d[i].x),t.y=Math.max(t.y,d[i].y);_=e.x>=i.x&&t.x<=r.x&&e.y>=i.y&&t.y<=r.y?[d]:t.x<i.x||e.x>r.x||t.y<i.y||e.y>r.y?[]:function(e,t,i,r,a){let n=[];for(let s of e){let e;for(let o=0;o<s.length-1;o++){let l=s[o],h=s[o+1];l.x<t&&h.x<t||(l.x<t?l=new u(t,l.y+(h.y-l.y)*((t-l.x)/(h.x-l.x)))._round():h.x<t&&(h=new u(t,l.y+(h.y-l.y)*((t-l.x)/(h.x-l.x)))._round()),!(l.y<i&&h.y<i)&&(l.y<i?l=new u(l.x+(h.x-l.x)*((i-l.y)/(h.y-l.y)),i)._round():h.y<i&&(h=new u(l.x+(h.x-l.x)*((i-l.y)/(h.y-l.y)),i)._round()),!(l.x>=r&&h.x>=r)&&(l.x>=r?l=new u(r,l.y+(h.y-l.y)*((r-l.x)/(h.x-l.x)))._round():h.x>=r&&(h=new u(r,l.y+(h.y-l.y)*((r-l.x)/(h.x-l.x)))._round()),!(l.y>=a&&h.y>=a)&&(l.y>=a?l=new u(l.x+(h.x-l.x)*((a-l.y)/(h.y-l.y)),a)._round():h.y>=a&&(h=new u(l.x+(h.x-l.x)*((a-l.y)/(h.y-l.y)),a)._round()),(!e||!l.equals(e[e.length-1]))&&(e=[l],n.push(e)),e.push(h)))))}}return n}([d],i.x,i.y,r.x,r.y)}for(let l of _){a.reset(l,.25*t);let i=0;i=a.length<=.5*t?1:Math.ceil(a.paddedLength/f)+1;for(let r=0;r<i;r++){let n=r/Math.max(i-1,1),s=a.lerp(n),l=s.x+100,u=s.y+100;m.push(l,u,t,0);let c=l-t,p=u-t,d=l+t,f=u+t;if(P&&=this.isOffscreen(c,p,d,f),S||=this.isInsideGrid(c,p,d,f),"always"!==e&&this.grid.hitTestCircle(l,u,t,e,h)&&(T=!0,!o))return{circles:[],offscreen:!1,collisionDetected:T}}}}return{circles:!o&&T||!S||g<this.perspectiveRatioCutoff?[]:m,offscreen:P,collisionDetected:T}}projectPathToScreenSpace(e,t){return function(e){let t=0,i=0,r=0,a=0;for(let n=0;n<e.length;n++)e[n].isOccluded?(r=n+1,a=0):(a++,a>i&&(i=a,t=r));return e.slice(t,t+i)}(function(e,t){let i=ig;return function(e,t){let i=1/(t[0]*t[5]-t[1]*t[4]);e[0]=t[5]*i,e[1]=-t[1]*i,e[2]=0,e[3]=0,e[4]=-t[4]*i,e[5]=t[0]*i,e[6]=0,e[7]=0,e[8]=0,e[9]=0,e[10]=1/t[10],e[11]=0,e[12]=0,e[13]=0,e[14]=0,e[15]=1/t[15]}(i,t.pitchedLabelPlaneMatrix),e.map(e=>{let r=sg(e.x,e.y,i,t.getElevation),a=t.transform.projectTileCoordinates(r.point.x,r.point.y,t.unwrappedTileID,t.getElevation);return a.point.x=(.5*a.point.x+.5)*t.width,a.point.y=(.5*-a.point.y+.5)*t.height,a})}(e,t))}queryRenderedSymbols(e){if(0===e.length||0===this.grid.keysLength()&&0===this.ignoredGrid.keysLength())return{};let t=[],i=new Ou;for(let c of e){let e=new u(c.x+100,c.y+100);i.extend(e),t.push(e)}let{minX:r,minY:a,maxX:n,maxY:s}=i,o=this.grid.query(r,a,n,s).concat(this.ignoredGrid.query(r,a,n,s)),l={},h={};for(let c of o){let e=c.key;void 0===l[e.bucketInstanceId]&&(l[e.bucketInstanceId]={}),l[e.bucketInstanceId][e.featureIndex]||jl(t,[new u(c.x1,c.y1),new u(c.x2,c.y1),new u(c.x2,c.y2),new u(c.x1,c.y2)])&&(l[e.bucketInstanceId][e.featureIndex]=!0,void 0===h[e.bucketInstanceId]&&(h[e.bucketInstanceId]=[]),h[e.bucketInstanceId].push(e.featureIndex))}return h}insertCollisionBox(e,t,i,r,a,n){let s={bucketInstanceId:r,featureIndex:a,collisionGroupID:n,overlapMode:t};(i?this.ignoredGrid:this.grid).insert(s,e[0],e[1],e[2],e[3])}insertCollisionCircles(e,t,i,r,a,n){let s=i?this.ignoredGrid:this.grid,o={bucketInstanceId:r,featureIndex:a,collisionGroupID:n,overlapMode:t};for(let l=0;l<e.length;l+=4)s.insertCircle(o,e[l],e[l+1],e[l+2])}projectAndGetPerspectiveRatio(e,t,i,r,a){if(a){let i;r?(i=[e,t,r(e,t),1],U(i,i,a)):(i=[e,t,0,1],Tg(i,i,a));let n=i[3];return{x:(i[0]/n+1)/2*this.transform.width+100,y:(-i[1]/n+1)/2*this.transform.height+100,perspectiveRatio:.5+this.transform.cameraToCenterDistance/n*.5,isOccluded:!1,signedDistanceFromCamera:n}}{let a=this.transform.projectTileCoordinates(e,t,i,r);return{x:(a.point.x+1)/2*this.transform.width+100,y:(1-a.point.y)/2*this.transform.height+100,perspectiveRatio:.5+this.transform.cameraToCenterDistance/a.signedDistanceFromCamera*.5,isOccluded:a.isOccluded,signedDistanceFromCamera:a.signedDistanceFromCamera}}}getPerspectiveRatio(e,t,i,r){let a=this.transform.projectTileCoordinates(e,t,i,r);return.5+this.transform.cameraToCenterDistance/a.signedDistanceFromCamera*.5}isOffscreen(e,t,i,r){return i<100||e>=this.screenRightBoundary||r<100||t>this.screenBottomBoundary}isInsideGrid(e,t,i,r){return i>=0&&e<this.gridRightBoundary&&r>=0&&t<this.gridBottomBoundary}getViewportMatrix(){let e=_([]);return v(e,e,[-100,-100,0]),e}_projectCollisionBox(e,t,i,r,a,n,s,o,l,h,c){let p=1,d=0,f=0,m=1,_=e.anchorPointX+s[0],g=e.anchorPointY+s[1];if(n&&!a){let e=this.projectAndGetPerspectiveRatio(_+1,g,r,l,c),t=e.x-o.x,i=e.y-o.y,a=Math.atan(i/t)+(t<0?Math.PI:0),n=Math.sin(a),s=Math.cos(a);p=s,d=n,f=-n,m=s}else if(!n&&a){let e=ng(this.transform);p=e.vecEast[0],d=e.vecEast[1],f=e.vecSouth[0],m=e.vecSouth[1]}let y=o.x,v=o.y,x=t;a&&(y=_,v=g,x=2**-(this.transform.zoom-i.overscaledZ),x*=this.transform.getPitchedTextCorrection(_,g,r),!h)&&(x*=ve(.5+o.signedDistanceFromCamera/this.transform.cameraToCenterDistance*.5,0,4)),h&&(y+=p*h.x*x+f*h.y*x,v+=d*h.x*x+m*h.y*x);let b=e.x1*x,w=e.x2*x,T=(b+w)/2,S=e.y1*x,P=e.y2*x,I=(S+P)/2,M=[{offsetX:b,offsetY:S},{offsetX:T,offsetY:S},{offsetX:w,offsetY:S},{offsetX:w,offsetY:I},{offsetX:w,offsetY:P},{offsetX:T,offsetY:P},{offsetX:b,offsetY:P},{offsetX:b,offsetY:I}],E=[];for(let{offsetX:C,offsetY:D}of M)E.push(new u(y+p*C+f*D,v+d*C+m*D));let A=!1;if(a){let e=E.map(e=>this.projectAndGetPerspectiveRatio(e.x,e.y,r,l,c));A=e.some(e=>!e.isOccluded),E=e.map(e=>new u(e.x,e.y))}else A=!0;return{box:_e(E),allPointsOccluded:!A}}},Pg=class{constructor(e,t,i,r){this.opacity=e?Math.max(0,Math.min(1,e.opacity+(e.placed?t:-t))):r&&i?1:0,this.placed=i}isHidden(){return 0===this.opacity&&!this.placed}},Ig=class{constructor(e,t,i,r,a){this.text=new Pg(e?e.text:null,t,i,a),this.icon=new Pg(e?e.icon:null,t,r,a)}isHidden(){return this.text.isHidden()&&this.icon.isHidden()}},Mg=class{constructor(e,t,i){this.text=e,this.icon=t,this.skipFade=i}},Eg=class{constructor(e,t,i,r,a){this.bucketInstanceId=e,this.featureIndex=t,this.sourceLayerIndex=i,this.bucketIndex=r,this.tileID=a}},Ag=class{constructor(e){this.crossSourceCollisions=e,this.maxGroupID=0,this.collisionGroups={}}get(e){if(this.crossSourceCollisions)return{ID:0,predicate:null};if(!this.collisionGroups[e]){let t=++this.maxGroupID;this.collisionGroups[e]={ID:t,predicate:e=>e.collisionGroupID===t}}return this.collisionGroups[e]}};function Cg(e,t,i,r,a){let{horizontalAlign:n,verticalAlign:s}=np(e),o=-(s-.5)*i;return new u(-(n-.5)*t+r[0]*a,o+r[1]*a)}var Dg=class{constructor(e,t,i,r,a){this.transform=e.clone(),this.terrain=t,this.collisionIndex=new Sg(this.transform),this.placements={},this.opacities={},this.variableOffsets={},this.stale=!1,this.commitTime=0,this.fadeDuration=i,this.retainedQueryData={},this.collisionGroups=new Ag(r),this.collisionCircleArrays={},this.collisionBoxArrays=/* @__PURE__ */new Map,this.prevPlacement=a,a&&(a.prevPlacement=void 0),this.placedOrientations={}}_getTerrainElevationFunc(e){let t=this.terrain;return t?(i,r)=>t.getElevation(e,i,r):null}getBucketParts(e,t,i,r){let a=i.getBucket(t),n=i.latestFeatureIndex;if(!a||!n||t.id!==a.layerIds[0])return;let s=i.collisionBoxArray,o=a.layers[0].layout,l=a.layers[0].paint,h=2**(this.transform.zoom-i.tileID.overscaledZ),u=i.tileSize/J,c=i.tileID.toUnwrapped(),p="map"===o.get("text-rotation-alignment"),d=Q(i,1,this.transform.zoom),f=se(this.collisionIndex.transform,i,l.get("text-translate"),l.get("text-translate-anchor")),m=se(this.collisionIndex.transform,i,l.get("icon-translate"),l.get("icon-translate-anchor")),_=rg(p,this.transform,d);this.retainedQueryData[a.bucketInstanceId]=new Eg(a.bucketInstanceId,n,a.sourceLayerIndex,a.index,i.tileID);let g={bucket:a,layout:o,translationText:f,translationIcon:m,unwrappedTileID:c,pitchedLabelPlaneMatrix:_,scale:h,textPixelRatio:u,holdingForFade:i.holdingForSymbolFade(),collisionBoxArray:s,partiallyEvaluatedTextSize:lp(a.textSizeData,this.transform.zoom),collisionGroup:this.collisionGroups.get(a.sourceID)};if(r)for(let y of a.sortKeyRanges){let{sortKey:t,symbolInstanceStart:i,symbolInstanceEnd:r}=y;e.push({sortKey:t,symbolInstanceStart:i,symbolInstanceEnd:r,parameters:g})}else e.push({symbolInstanceStart:0,symbolInstanceEnd:a.symbolInstances.length,parameters:g})}attemptAnchorPlacement(e,t,i,r,a,n,s,o,l,h,u,c,p,d,f,m,_,g,y,v){let x=tm[e.textAnchor],b=[e.textOffset0,e.textOffset1],w=Cg(x,i,r,b,a),T=this.collisionIndex.placeCollisionBox(t,c,o,l,h,s,n,m,u.predicate,y,w,v);if((!g||this.collisionIndex.placeCollisionBox(g,c,o,l,h,s,n,_,u.predicate,y,w,v).placeable)&&T.placeable){let e;if(this.prevPlacement?.variableOffsets[p.crossTileID]&&this.prevPlacement?.placements[p.crossTileID]?.text&&(e=this.prevPlacement.variableOffsets[p.crossTileID].anchor),0===p.crossTileID)throw Error("symbolInstance.crossTileID can't be 0");return this.variableOffsets[p.crossTileID]={textOffset:b,width:i,height:r,anchor:x,textBoxScale:a,prevAnchor:e},this.markUsedJustification(d,x,p,f),d.allowVerticalPlacement&&(this.markUsedOrientation(d,f,p),this.placedOrientations[p.crossTileID]=f),{shift:w,placedGlyphBoxes:T}}}placeLayerBucketPart(e,t,i){let{bucket:r,layout:a,translationText:n,translationIcon:s,unwrappedTileID:o,pitchedLabelPlaneMatrix:l,textPixelRatio:h,holdingForFade:u,collisionBoxArray:c,partiallyEvaluatedTextSize:p,collisionGroup:d}=e.parameters,f=a.get("text-optional"),m=a.get("icon-optional"),_=hp(a,"text-overlap","text-allow-overlap"),g="always"===_,y=hp(a,"icon-overlap","icon-allow-overlap"),v="always"===y,x="map"===a.get("text-rotation-alignment"),b="map"===a.get("text-pitch-alignment"),w="none"!==a.get("icon-text-fit"),T="viewport-y"===a.get("symbol-z-order"),S=g&&(v||!r.hasIconData()||m),P=v&&(g||!r.hasTextData()||f);!r.collisionArrays&&c&&r.deserializeCollisionBoxes(c);let I=this.retainedQueryData[r.bucketInstanceId].tileID,M=this._getTerrainElevationFunc(I),E=this.transform.getFastPathSimpleProjectionMatrix(I),A=(e,c,v)=>{if(t[e.crossTileID])return;if(u)return void(this.placements[e.crossTileID]=new Mg(!1,!1,!1));let T=!1,A=!1,C=!0,D=null,z={box:null,placeable:!1,offscreen:null,occluded:!1},R={box:null,placeable:!1,offscreen:null},k=null,L=null,F=null,B=0,O=0,V=0;c.textFeatureIndex?B=c.textFeatureIndex:e.useRuntimeCollisionCircles&&(B=e.featureIndex),c.verticalTextFeatureIndex&&(O=c.verticalTextFeatureIndex);let j=c.textBox;if(j){let t=t=>{let i=1;if(r.allowVerticalPlacement&&!t&&this.prevPlacement){let t=this.prevPlacement.placedOrientations[e.crossTileID];t&&(this.placedOrientations[e.crossTileID]=t,i=t,this.markUsedOrientation(r,i,e))}return i},a=(t,i)=>{if(r.allowVerticalPlacement&&e.numVerticalGlyphVertices>0&&c.verticalTextBox){for(let e of r.writingModes)if(2===e?(z=i(),R=z):z=t(),z?.placeable)break}else z=t()},l=e.textAnchorOffsetStartIndex,u=e.textAnchorOffsetEndIndex;if(u===l){let i=(t,i)=>{let a=this.collisionIndex.placeCollisionBox(t,_,h,I,o,b,x,n,d.predicate,M,void 0,E);return a?.placeable&&(this.markUsedOrientation(r,i,e),this.placedOrientations[e.crossTileID]=i),a};a(()=>i(j,1),()=>{let t=c.verticalTextBox;return r.allowVerticalPlacement&&e.numVerticalGlyphVertices>0&&t?i(t,2):{box:null,offscreen:null}}),t(z?.placeable)}else{let p=tm[this.prevPlacement?.variableOffsets[e.crossTileID]?.anchor],f=(t,a,c)=>{let f=t.x2-t.x1,m=t.y2-t.y1,g=e.textBoxScale,v=w&&"never"===y?a:null,S=null,P="never"===_?1:2,A="never";p&&P++;for(let i=0;i<P;i++){for(let i=l;i<u;i++){let a=r.textAnchorOffsets.get(i);if(p&&a.textAnchor!==p)continue;let l=this.attemptAnchorPlacement(a,t,f,m,g,x,b,h,I,o,d,A,e,r,c,n,s,v,M);if(l&&(S=l.placedGlyphBoxes,S?.placeable))return T=!0,D=l.shift,S}p?p=null:A=_}return i&&!S&&(S={box:this.collisionIndex.placeCollisionBox(j,"always",h,I,o,b,x,n,d.predicate,M,void 0,E).box,offscreen:!1,placeable:!1,occluded:!1}),S};a(()=>f(j,c.iconBox,1),()=>{let t=c.verticalTextBox,i=z?.placeable;return r.allowVerticalPlacement&&!i&&e.numVerticalGlyphVertices>0&&t?f(t,c.verticalIconBox,2):{box:null,occluded:!0,offscreen:null}}),z&&(T=z.placeable,C=z.offscreen);let m=t(z?.placeable);if(!T&&this.prevPlacement){let t=this.prevPlacement.variableOffsets[e.crossTileID];t&&(this.variableOffsets[e.crossTileID]=t,this.markUsedJustification(r,t.anchor,e,m))}}}if(k=z,T=k?.placeable,C=k?.offscreen,e.useRuntimeCollisionCircles&&e.centerJustifiedTextSymbolIndex>=0){let t=r.text.placedSymbolArray.get(e.centerJustifiedTextSymbolIndex),s=op(r.textSizeData,p,t),h=a.get("text-padding"),u=e.collisionCircleDiameter;L=this.collisionIndex.placeCollisionCircles(_,t,r.lineVertexArray,r.glyphOffsetArray,s,o,l,i,b,d.predicate,u,h,n,M),L.circles.length&&L.collisionDetected&&!i&&Re("Collisions detected, but collision boxes are not shown"),T=g||L.circles.length>0&&!L.collisionDetected,C&&=L.offscreen}if(c.iconFeatureIndex&&(V=c.iconFeatureIndex),c.iconBox){let e=e=>this.collisionIndex.placeCollisionBox(e,y,h,I,o,b,x,s,d.predicate,M,w&&D?D:void 0,E);R&&R.placeable&&c.verticalIconBox?(F=e(c.verticalIconBox),A=F.placeable):(F=e(c.iconBox),A=F.placeable),C&&=F.offscreen}let N=f||0===e.numHorizontalGlyphVertices&&0===e.numVerticalGlyphVertices,U=m||0===e.numIconVertices;N||U?U?N||(A&&=T):T=A&&T:A=T=A&&T;let G=T&&k.placeable,$=A&&F.placeable;if(G&&(R&&R.placeable&&O?this.collisionIndex.insertCollisionBox(k.box,_,a.get("text-ignore-placement"),r.bucketInstanceId,O,d.ID):this.collisionIndex.insertCollisionBox(k.box,_,a.get("text-ignore-placement"),r.bucketInstanceId,B,d.ID)),$&&this.collisionIndex.insertCollisionBox(F.box,y,a.get("icon-ignore-placement"),r.bucketInstanceId,V,d.ID),L&&T&&this.collisionIndex.insertCollisionCircles(L.circles,_,a.get("text-ignore-placement"),r.bucketInstanceId,B,d.ID),i&&this.storeCollisionData(r.bucketInstanceId,v,c,k,F,L),0===e.crossTileID)throw Error("symbolInstance.crossTileID can't be 0");if(0===r.bucketInstanceId)throw Error("bucket.bucketInstanceId can't be 0");let Z=(T||S)&&!k?.occluded,q=(A||P)&&!F?.occluded;this.placements[e.crossTileID]=new Mg(Z,q,C||r.justReloaded),t[e.crossTileID]=!0};if(T){if(0!==e.symbolInstanceStart)throw Error("bucket.bucketInstanceId should be 0");let t=r.getSortedSymbolIndexes(-this.transform.bearingInRadians);for(let e=t.length-1;e>=0;--e){let i=t[e];A(r.symbolInstances.get(i),r.collisionArrays[i],i)}}else for(let C=e.symbolInstanceStart;C<e.symbolInstanceEnd;C++)A(r.symbolInstances.get(C),r.collisionArrays[C],C);r.justReloaded=!1}storeCollisionData(e,t,i,r,a,n){if(i.textBox||i.iconBox){let n,s;this.collisionBoxArrays.has(e)?n=this.collisionBoxArrays.get(e):(n=/* @__PURE__ */new Map,this.collisionBoxArrays.set(e,n)),n.has(t)?s=n.get(t):(s={text:null,icon:null},n.set(t,s)),i.textBox&&(s.text=r.box),i.iconBox&&(s.icon=a.box)}if(n){let t=this.collisionCircleArrays[e];void 0===t&&(t=this.collisionCircleArrays[e]=[]);for(let e=0;e<n.circles.length;e+=4)t.push(n.circles[e+0]-100),t.push(n.circles[e+1]-100),t.push(n.circles[e+2]),t.push(+!!n.collisionDetected)}}markUsedJustification(e,t,i,r){let a,n={left:i.leftJustifiedTextSymbolIndex,center:i.centerJustifiedTextSymbolIndex,right:i.rightJustifiedTextSymbolIndex};a=2===r?i.verticalPlacedTextSymbolIndex:n[function(e){switch(e){case"right":case"top-right":case"bottom-right":return"right";case"left":case"top-left":case"bottom-left":return"left"}return"center"}(t)];let s=[i.leftJustifiedTextSymbolIndex,i.centerJustifiedTextSymbolIndex,i.rightJustifiedTextSymbolIndex,i.verticalPlacedTextSymbolIndex];for(let o of s)o>=0&&(e.text.placedSymbolArray.get(o).crossTileID=a>=0&&o!==a?0:i.crossTileID)}markUsedOrientation(e,t,i){let r=1===t||3===t?t:0,a=2===t?t:0,n=[i.leftJustifiedTextSymbolIndex,i.centerJustifiedTextSymbolIndex,i.rightJustifiedTextSymbolIndex];for(let s of n)e.text.placedSymbolArray.get(s).placedOrientation=r;i.verticalPlacedTextSymbolIndex&&(e.text.placedSymbolArray.get(i.verticalPlacedTextSymbolIndex).placedOrientation=a)}commit(e){this.commitTime=e,this.zoomAtLastRecencyCheck=this.transform.zoom;let t=this.prevPlacement,i=!1;this.prevZoomAdjustment=t?t.zoomAdjustment(this.transform.zoom):0;let r=t?t.symbolFadeChange(e):1,a=t?t.opacities:{},n=t?t.variableOffsets:{},s=t?t.placedOrientations:{};for(let o in this.placements){let e=this.placements[o],t=a[o];t?(this.opacities[o]=new Ig(t,r,e.text,e.icon),i||=e.text!==t.text.placed,i||=e.icon!==t.icon.placed):(this.opacities[o]=new Ig(null,r,e.text,e.icon,e.skipFade),i||=e.text||e.icon)}for(let o in a){let e=a[o];if(!this.opacities[o]){let t=new Ig(e,r,!1,!1);t.isHidden()||(this.opacities[o]=t,i||=e.text.placed,i||=e.icon.placed)}}for(let o in n)!this.variableOffsets[o]&&this.opacities[o]&&!this.opacities[o].isHidden()&&(this.variableOffsets[o]=n[o]);for(let o in s)!this.placedOrientations[o]&&this.opacities[o]&&!this.opacities[o].isHidden()&&(this.placedOrientations[o]=s[o]);if(t&&void 0===t.lastPlacementChangeTime)throw Error("Last placement time for previous placement is not defined");i?this.lastPlacementChangeTime=e:"number"!=typeof this.lastPlacementChangeTime&&(this.lastPlacementChangeTime=t?t.lastPlacementChangeTime:e)}updateLayerOpacities(e,t){let i={};for(let r of t){let t=r.getBucket(e);t&&r.latestFeatureIndex&&e.id===t.layerIds[0]&&this.updateBucketOpacities(t,r.tileID,i,r.collisionBoxArray)}}updateBucketOpacities(e,t,i,r){e.hasTextData()&&(e.text.opacityVertexArray.clear(),e.text.hasVisibleVertices=!1),e.hasIconData()&&(e.icon.opacityVertexArray.clear(),e.icon.hasVisibleVertices=!1),e.hasIconCollisionBoxData()&&e.iconCollisionBox.collisionVertexArray.clear(),e.hasTextCollisionBoxData()&&e.textCollisionBox.collisionVertexArray.clear();let a=e.layers[0],n=a.layout,s=new Ig(null,0,!1,!1,!0),o=n.get("text-allow-overlap"),l=n.get("icon-allow-overlap"),h=a._unevaluatedLayout.hasValue("text-variable-anchor")||a._unevaluatedLayout.hasValue("text-variable-anchor-offset"),c="map"===n.get("text-rotation-alignment"),p="map"===n.get("text-pitch-alignment"),d="none"!==n.get("icon-text-fit"),f=new Ig(null,0,o&&(l||!e.hasIconData()||n.get("icon-optional")),l&&(o||!e.hasTextData()||n.get("text-optional")),!0);!e.collisionArrays&&r&&(e.hasIconCollisionBoxData()||e.hasTextCollisionBoxData())&&e.deserializeCollisionBoxes(r);let m=(e,t,i)=>{for(let r=0;r<t/4;r++)e.opacityVertexArray.emplaceBack(i);e.hasVisibleVertices||=i!==Og},_=this.collisionBoxArrays.get(e.bucketInstanceId);for(let g=0;g<e.symbolInstances.length;g++){let t=e.symbolInstances.get(g),{numHorizontalGlyphVertices:r,numVerticalGlyphVertices:a,crossTileID:n}=t,o=i[n],l=this.opacities[n];o?l=s:l||(l=f,this.opacities[n]=l),i[n]=!0;let y=r>0||a>0,v=t.numIconVertices>0,x=this.placedOrientations[t.crossTileID],b=2===x,w=1===x||3===x;if(y){let i=Bg(l.text),n=b?Og:i;m(e.text,r,n);let s=w?Og:i;m(e.text,a,s);let o=l.text.isHidden(),h=[t.rightJustifiedTextSymbolIndex,t.centerJustifiedTextSymbolIndex,t.leftJustifiedTextSymbolIndex];for(let t of h)t>=0&&(e.text.placedSymbolArray.get(t).hidden=o||b?1:0);t.verticalPlacedTextSymbolIndex>=0&&(e.text.placedSymbolArray.get(t.verticalPlacedTextSymbolIndex).hidden=o||w?1:0);let u=this.variableOffsets[t.crossTileID];u&&this.markUsedJustification(e,u.anchor,t,x);let c=this.placedOrientations[t.crossTileID];c&&(this.markUsedJustification(e,"left",t,c),this.markUsedOrientation(e,c,t))}if(v){let i=Bg(l.icon),r=!(d&&t.verticalPlacedIconSymbolIndex&&b);if(t.placedIconSymbolIndex>=0){let a=r?i:Og;m(e.icon,t.numIconVertices,a),e.icon.placedSymbolArray.get(t.placedIconSymbolIndex).hidden=l.icon.isHidden()}if(t.verticalPlacedIconSymbolIndex>=0){let a=r?Og:i;m(e.icon,t.numVerticalIconVertices,a),e.icon.placedSymbolArray.get(t.verticalPlacedIconSymbolIndex).hidden=l.icon.isHidden()}}let T=_?.has(g)?_.get(g):{text:null,icon:null};if(e.hasIconCollisionBoxData()||e.hasTextCollisionBoxData()){let t=e.collisionArrays[g];if(t){let i=new u(0,0);if(t.textBox||t.verticalTextBox){let r=!0;if(h){let e=this.variableOffsets[n];e?(i=Cg(e.anchor,e.width,e.height,e.textOffset,e.textBoxScale),c&&i._rotate(p?-this.transform.bearingInRadians:this.transform.bearingInRadians)):r=!1}if(t.textBox||t.verticalTextBox){let a;t.textBox&&(a=b),t.verticalTextBox&&(a=w),zg(e.textCollisionBox.collisionVertexArray,l.text.placed,!r||a,T.text,i.x,i.y)}}if(t.iconBox||t.verticalIconBox){let r,a=!(w||!t.verticalIconBox);t.iconBox&&(r=a),t.verticalIconBox&&(r=!a),zg(e.iconCollisionBox.collisionVertexArray,l.icon.placed,r,T.icon,d?i.x:0,d?i.y:0)}}}}if(e.sortFeatures(-this.transform.bearingInRadians),this.retainedQueryData[e.bucketInstanceId]&&(this.retainedQueryData[e.bucketInstanceId].featureSortOrder=e.featureSortOrder),e.hasTextData()&&e.text.opacityVertexBuffer&&e.text.opacityVertexBuffer.updateData(e.text.opacityVertexArray),e.hasIconData()&&e.icon.opacityVertexBuffer&&e.icon.opacityVertexBuffer.updateData(e.icon.opacityVertexArray),e.hasIconCollisionBoxData()&&e.iconCollisionBox.collisionVertexBuffer&&e.iconCollisionBox.collisionVertexBuffer.updateData(e.iconCollisionBox.collisionVertexArray),e.hasTextCollisionBoxData()&&e.textCollisionBox.collisionVertexBuffer&&e.textCollisionBox.collisionVertexBuffer.updateData(e.textCollisionBox.collisionVertexArray),e.text.opacityVertexArray.length!==e.text.layoutVertexArray.length/4)throw Error(`bucket.text.opacityVertexArray.length (= ${e.text.opacityVertexArray.length}) !== bucket.text.layoutVertexArray.length (= ${e.text.layoutVertexArray.length}) / 4`);if(e.icon.opacityVertexArray.length!==e.icon.layoutVertexArray.length/4)throw Error(`bucket.icon.opacityVertexArray.length (= ${e.icon.opacityVertexArray.length}) !== bucket.icon.layoutVertexArray.length (= ${e.icon.layoutVertexArray.length}) / 4`);e.bucketInstanceId in this.collisionCircleArrays&&(e.collisionCircleArray=this.collisionCircleArrays[e.bucketInstanceId],delete this.collisionCircleArrays[e.bucketInstanceId])}symbolFadeChange(e){return 0===this.fadeDuration?1:(e-this.commitTime)/this.fadeDuration+this.prevZoomAdjustment}zoomAdjustment(e){return Math.max(0,(this.transform.zoom-e)/1.5)}hasTransitions(e){return this.stale||e-this.lastPlacementChangeTime<this.fadeDuration}stillRecent(e,t){let i=this.zoomAtLastRecencyCheck===t?1-this.zoomAdjustment(t):1;return this.zoomAtLastRecencyCheck=t,this.commitTime+this.fadeDuration*i>e}setStale(){this.stale=!0}};function zg(e,t,i,r,a,n){(!r||0===r.length)&&(r=[0,0,0,0]);let s=r[0]-100,o=r[1]-100,l=r[2]-100,h=r[3]-100;e.emplaceBack(+!!t,+!!i,a||0,n||0,s,o),e.emplaceBack(+!!t,+!!i,a||0,n||0,l,o),e.emplaceBack(+!!t,+!!i,a||0,n||0,l,h),e.emplaceBack(+!!t,+!!i,a||0,n||0,s,h)}var Rg=2**25,kg=2**24,Lg=2**17,Fg=65536;function Bg(e){if(0===e.opacity&&!e.placed)return 0;if(1===e.opacity&&e.placed)return 4294967295;let t=+!!e.placed,i=Math.floor(127*e.opacity);return i*Rg+t*kg+i*Lg+t*Fg+512*i+256*t+2*i+t}var Og=0,Vg=class{constructor(e){this._sortAcrossTiles="viewport-y"!==e.layout.get("symbol-z-order")&&!e.layout.get("symbol-sort-key").isConstant(),this._currentTileIndex=0,this._currentPartIndex=0,this._seenCrossTileIDs={},this._bucketParts=[]}continuePlacement(e,t,i,r,a){let n=this._bucketParts;for(;this._currentTileIndex<e.length;){let i=e[this._currentTileIndex];if(t.getBucketParts(n,r,i,this._sortAcrossTiles),this._currentTileIndex++,a())return!0}for(this._sortAcrossTiles&&(this._sortAcrossTiles=!1,n.sort((e,t)=>e.sortKey-t.sortKey));this._currentPartIndex<n.length;){let e=n[this._currentPartIndex];if(t.placeLayerBucketPart(e,this._seenCrossTileIDs,i),this._currentPartIndex++,a())return!0}return!1}},jg=class{constructor(e,t,i,r,a,n,s,o){this.placement=new Dg(e,t,n,s,o),this._currentPlacementIndex=i.length-1,this._forceFullPlacement=r,this._showCollisionBoxes=a,this._done=!1}isDone(){return this._done}continuePlacement(e,t,i){let r=sm(),a=()=>!this._forceFullPlacement&&sm()-r>2;for(;this._currentPlacementIndex>=0;){let r=t[e[this._currentPlacementIndex]],n=this.placement.collisionIndex.transform.zoom;if(wp(r)&&r.layout&&(!r.minzoom||r.minzoom<=n)&&(!r.maxzoom||r.maxzoom>n)){if(this._inProgressLayer||=new Vg(r),this._inProgressLayer.continuePlacement(i[r.source],this.placement,this._showCollisionBoxes,r,a))return;delete this._inProgressLayer}this._currentPlacementIndex--}this._done=!0}commit(e){return this.placement.commit(e),this.placement}},Ng=[Int8Array,Uint8Array,Uint8ClampedArray,Int16Array,Uint16Array,Int32Array,Uint32Array,Float32Array,Float64Array],Ug=/* @__PURE__ */new Uint32Array(96),Gg=class e{static from(t){if(!t||void 0===t.byteLength||t.buffer)throw Error("Data must be an instance of ArrayBuffer or SharedArrayBuffer.");let[i,r]=new Uint8Array(t,0,2);if(219!==i)throw Error("Data does not appear to be in a KDBush format.");let a=r>>4;if(1!==a)throw Error(`Got v${a} data when expected v1.`);let n=Ng[15&r];if(!n)throw Error("Unrecognized array type.");let[s]=new Uint16Array(t,2,1),[o]=new Uint32Array(t,4,1);return new e(o,s,n,void 0,t)}constructor(e,t=64,i=Float64Array,r=ArrayBuffer,a){if(isNaN(e)||e<0)throw Error(`Unexpected numItems value: ${e}.`);this.numItems=+e,this.nodeSize=Math.min(Math.max(+t,2),65535),this.ArrayType=i,this.IndexArrayType=e<65536?Uint16Array:Uint32Array;let n=Ng.indexOf(this.ArrayType),s=2*e*this.ArrayType.BYTES_PER_ELEMENT,o=e*this.IndexArrayType.BYTES_PER_ELEMENT,l=(8-o%8)%8;if(n<0)throw Error(`Unexpected typed array class: ${i}.`);if(a)this.data=a,this.ids=new this.IndexArrayType(a,8,e),this.coords=new i(a,8+o+l,2*e),this._pos=2*e,this._finished=!0;else{let a=this.data=new r(8+s+o+l);this.ids=new this.IndexArrayType(a,8,e),this.coords=new i(a,8+o+l,2*e),this._pos=0,this._finished=!1,new Uint8Array(a,0,2).set([219,16+n]),new Uint16Array(a,2,1)[0]=t,new Uint32Array(a,4,1)[0]=e}}add(e,t){let i=this._pos>>1;return this.ids[i]=i,this.coords[this._pos++]=e,this.coords[this._pos++]=t,i}finish(){let e=this._pos>>1;if(e!==this.numItems)throw Error(`Added ${e} items when expected ${this.numItems}.`);return $g(this.ids,this.coords,this.nodeSize,0,this.numItems-1,0),this._finished=!0,this}range(e,t,i,r){if(!this._finished)throw Error("Data not yet indexed - call index.finish().");let{ids:a,coords:n,nodeSize:s}=this;Ug[0]=0,Ug[1]=a.length-1,Ug[2]=0;let o=3,l=[];for(;o>0;){let h=Ug[--o],u=Ug[--o],c=Ug[--o];if(u-c<=s){for(let s=c;s<=u;s++){let o=n[2*s],h=n[2*s+1];o>=e&&o<=i&&h>=t&&h<=r&&l.push(a[s])}continue}let p=c+u>>1,d=n[2*p],f=n[2*p+1];d>=e&&d<=i&&f>=t&&f<=r&&l.push(a[p]),(0===h?e<=d:t<=f)&&(Ug[o++]=c,Ug[o++]=p-1,Ug[o++]=1-h),(0===h?i>=d:r>=f)&&(Ug[o++]=p+1,Ug[o++]=u,Ug[o++]=1-h)}return l}within(e,t,i){let r=[];return this.withinInto(e,t,i,r),r}withinInto(e,t,i,r){if(!this._finished)throw Error("Data not yet indexed - call index.finish().");let{ids:a,coords:n,nodeSize:s}=this;Ug[0]=0,Ug[1]=a.length-1,Ug[2]=0;let o=3,l=0,h=i*i;for(;o>0;){let u=Ug[--o],c=Ug[--o],p=Ug[--o];if(c-p<=s){for(let i=p;i<=c;i++)Hg(n[2*i],n[2*i+1],e,t)<=h&&(r[l++]=a[i]);continue}let d=p+c>>1,f=n[2*d],m=n[2*d+1];Hg(f,m,e,t)<=h&&(r[l++]=a[d]),(0===u?e-i<=f:t-i<=m)&&(Ug[o++]=p,Ug[o++]=d-1,Ug[o++]=1-u),(0===u?e+i>=f:t+i>=m)&&(Ug[o++]=d+1,Ug[o++]=c,Ug[o++]=1-u)}return l}};function $g(e,t,i,r,a,n){if(a-r<=i)return;let s=r+a>>1;Zg(e,t,s,r,a,n),$g(e,t,i,r,s-1,1-n),$g(e,t,i,s+1,a,1-n)}function Zg(e,t,i,r,a,n){for(;a>r;){if(a-r>600){let s=a-r+1,o=i-r+1,l=Math.log(s),h=.5*Math.exp(2*l/3),u=.5*Math.sqrt(l*h*(s-h)/s)*(o-s/2<0?-1:1);Zg(e,t,i,Math.max(r,Math.floor(i-o*h/s+u)),Math.min(a,Math.floor(i+(s-o)*h/s+u)),n)}let s=t[2*i+n],o=r,l=a;for(qg(e,t,r,i),t[2*a+n]>s&&qg(e,t,r,a);o<l;){for(qg(e,t,o,l),o++,l--;t[2*o+n]<s;)o++;for(;t[2*l+n]>s;)l--}t[2*r+n]===s?qg(e,t,r,l):(l++,qg(e,t,l,a)),l<=i&&(r=l+1),i<=l&&(a=l-1)}}function qg(e,t,i,r){Wg(e,i,r),Wg(t,2*i,2*r),Wg(t,2*i+1,2*r+1)}function Wg(e,t,i){let r=e[t];e[t]=e[i],e[i]=r}function Hg(e,t,i,r){let a=e-i,n=t-r;return a*a+n*n}var Xg=.03125,Yg=class{constructor(e,t,i){this.tileID=e,this.bucketInstanceId=i,this._symbolsByKey={};let r=/* @__PURE__ */new Map;for(let a=0;a<t.length;a++){let e=t.get(a),i=e.key,n=r.get(i);n?n.push(e):r.set(i,[e])}for(let[a,n]of r){let e={positions:n.map(e=>({x:Math.floor(e.anchorX*Xg),y:Math.floor(e.anchorY*Xg)})),crossTileIDs:n.map(e=>e.crossTileID)};if(e.positions.length>128){let t=new Gg(e.positions.length,16,Uint16Array);for(let{x:i,y:r}of e.positions)t.add(i,r);t.finish(),delete e.positions,e.index=t}this._symbolsByKey[a]=e}}getScaledCoordinates(e,t){let{x:i,y:r,z:a}=this.tileID.canonical,{x:n,y:s,z:o}=t.canonical,l=Xg/2**(o-a),h=(n*J+e.anchorX)*l,u=(s*J+e.anchorY)*l,c=i*J*Xg,p=r*J*Xg;return{x:Math.floor(h-c),y:Math.floor(u-p)}}findMatches(e,t,i){let r=this.tileID.canonical.z<t.canonical.z?1:2**(this.tileID.canonical.z-t.canonical.z);for(let a=0;a<e.length;a++){let n=e.get(a);if(n.crossTileID)continue;let s=this._symbolsByKey[n.key];if(!s)continue;let o=this.getScaledCoordinates(n,t);s.index?this.findMatchesForIndexedEntry(s,n,o,r,i):s.positions&&this.findMatchesForNonIndexedEntry(s,n,o,r,i)}}findMatchesForIndexedEntry(e,t,i,r,a){let n=e.index.range(i.x-r,i.y-r,i.x+r,i.y+r),s=1/0;for(let o of n)o<s&&!a[e.crossTileIDs[o]]&&(s=o);if(s!==1/0){let i=e.crossTileIDs[s];a[i]=!0,t.crossTileID=i}}findMatchesForNonIndexedEntry(e,t,i,r,a){for(let n=0;n<e.positions.length;n++){let s=e.positions[n],o=e.crossTileIDs[n];if(Math.abs(s.x-i.x)<=r&&Math.abs(s.y-i.y)<=r&&!a[o]){a[o]=!0,t.crossTileID=o;break}}}getCrossTileIDsLists(){return Object.values(this._symbolsByKey).map(({crossTileIDs:e})=>e)}},Kg=class{constructor(){this.maxCrossTileID=0}generate(){return++this.maxCrossTileID}},Jg=class{constructor(){this.indexes={},this.usedCrossTileIDs={},this.lng=0}handleWrapJump(e){let t=Math.round((e-this.lng)/360);if(0!==t)for(let i in this.indexes){let e=this.indexes[i],r={};for(let i in e){let a=e[i];a.tileID=a.tileID.unwrapTo(a.tileID.wrap+t),r[a.tileID.key]=a}this.indexes[i]=r}this.lng=e}addBucket(e,t,i){if(this.indexes[e.overscaledZ]?.[e.key]){if(this.indexes[e.overscaledZ][e.key].bucketInstanceId===t.bucketInstanceId)return!1;this.removeBucketCrossTileIDs(e.overscaledZ,this.indexes[e.overscaledZ][e.key])}for(let a=0;a<t.symbolInstances.length;a++)t.symbolInstances.get(a).crossTileID=0;this.usedCrossTileIDs[e.overscaledZ]||={};let r=this.usedCrossTileIDs[e.overscaledZ];for(let a in this.indexes){let i=this.indexes[a];if(Number(a)>e.overscaledZ)for(let a in i){let n=i[a];n.tileID.isChildOf(e)&&n.findMatches(t.symbolInstances,e,r)}else{let n=i[e.scaledTo(Number(a)).key];n&&n.findMatches(t.symbolInstances,e,r)}}for(let a=0;a<t.symbolInstances.length;a++){let e=t.symbolInstances.get(a);e.crossTileID||(e.crossTileID=i.generate(),r[e.crossTileID]=!0)}return void 0===this.indexes[e.overscaledZ]&&(this.indexes[e.overscaledZ]={}),this.indexes[e.overscaledZ][e.key]=new Yg(e,t.symbolInstances,t.bucketInstanceId),!0}removeBucketCrossTileIDs(e,t){for(let i of t.getCrossTileIDsLists())for(let t of i)delete this.usedCrossTileIDs[e][t]}removeStaleBuckets(e){let t=!1;for(let i in this.indexes){let r=this.indexes[i];for(let a in r)e[r[a].bucketInstanceId]||(this.removeBucketCrossTileIDs(i,r[a]),delete r[a],t=!0)}return t}},Qg=class{constructor(){this.layerIndexes={},this.crossTileIDs=new Kg,this.maxBucketInstanceId=0,this.bucketsInCurrentPlacement={}}addLayer(e,t,i){let r=this.layerIndexes[e.id];void 0===r&&(r=this.layerIndexes[e.id]=new Jg);let a=!1,n={};r.handleWrapJump(i);for(let s of t){let t=s.getBucket(e);e.id===t?.layerIds[0]&&(t.bucketInstanceId||=(this.maxBucketInstanceId+=1,this.maxBucketInstanceId),r.addBucket(s.tileID,t,this.crossTileIDs)&&(a=!0),n[t.bucketInstanceId]=!0)}return r.removeStaleBuckets(n)&&(a=!0),a}pruneUnusedLayers(e){let t={};for(let i of e)t[i]=!0;for(let i in this.layerIndexes)t[i]||delete this.layerIndexes[i]}},ey="void main() {fragColor=vec4(1.0);}",ty={prelude:iy("#ifdef GL_ES\nprecision mediump float;\n#else\n#if !defined(lowp)\n#define lowp\n#endif\n#if !defined(mediump)\n#define mediump\n#endif\n#if !defined(highp)\n#define highp\n#endif\n#endif\nout highp vec4 fragColor;","#ifdef GL_ES\nprecision highp float;\n#else\n#if !defined(lowp)\n#define lowp\n#endif\n#if !defined(mediump)\n#define mediump\n#endif\n#if !defined(highp)\n#define highp\n#endif\n#endif\nvec2 unpack_float(const float packedValue) {int packedIntValue=int(packedValue);int v0=packedIntValue/256;return vec2(v0,packedIntValue-v0*256);}vec2 unpack_opacity(const uint packedOpacity) {return vec2(float(packedOpacity >> 1u)/127.0,float(packedOpacity & 1u));}vec4 decode_color(const vec2 encodedColor) {return vec4(unpack_float(encodedColor[0])/255.0,unpack_float(encodedColor[1])/255.0\n);}float unpack_mix_vec2(const vec2 packedValue,const float t) {return mix(packedValue[0],packedValue[1],t);}vec4 unpack_mix_color(const vec4 packedColors,const float t) {vec4 minColor=decode_color(vec2(packedColors[0],packedColors[1]));vec4 maxColor=decode_color(vec2(packedColors[2],packedColors[3]));return mix(minColor,maxColor,t);}vec2 get_pattern_pos(const vec2 pixel_coord_upper,const vec2 pixel_coord_lower,const vec2 pattern_size,const float tile_units_to_pixels,const vec2 pos) {vec2 offset=mod(mod(mod(pixel_coord_upper,pattern_size)*256.0,pattern_size)*256.0+pixel_coord_lower,pattern_size);return (tile_units_to_pixels*pos+offset)/pattern_size;}mat3 rotationMatrixFromAxisAngle(vec3 u,float angle) {float c=cos(angle);float s=sin(angle);float c2=1.0-c;return mat3(u.x*u.x*c2+ c,u.x*u.y*c2-u.z*s,u.x*u.z*c2+u.y*s,u.y*u.x*c2+u.z*s,u.y*u.y*c2+ c,u.y*u.z*c2-u.x*s,u.z*u.x*c2-u.y*s,u.z*u.y*c2+u.x*s,u.z*u.z*c2+ c\n);}\n#ifdef TERRAIN3D\nuniform sampler2D u_terrain;uniform float u_terrain_dim;uniform mat4 u_terrain_matrix;uniform vec4 u_terrain_unpack;uniform float u_terrain_exaggeration;uniform highp sampler2D u_depth;\n#endif\nconst highp vec4 bitSh=vec4(256.*256.*256.,256.*256.,256.,1.);const highp vec4 bitShifts=vec4(1.)/bitSh;highp float unpack(highp vec4 color) {return dot(color,bitShifts);}highp float depthOpacity(vec3 frag) {\n#ifdef TERRAIN3D\nhighp float d=unpack(texture(u_depth,frag.xy*0.5+0.5))+0.0001-frag.z;return 1.0-max(0.0,min(1.0,-d*500.0));\n#else\nreturn 1.0;\n#endif\n}float calculate_visibility(vec4 pos) {\n#ifdef TERRAIN3D\nvec3 frag=pos.xyz/pos.w;highp float d=depthOpacity(frag);if (d > 0.95) return 1.0;return (d+depthOpacity(frag+vec3(0.0,0.01,0.0)))/2.0;\n#else\nreturn 1.0;\n#endif\n}float ele(ivec2 pos) {\n#ifdef TERRAIN3D\nvec4 rgb=(texelFetch(u_terrain,pos,0)*255.0)*u_terrain_unpack;return rgb.r+rgb.g+rgb.b-u_terrain_unpack.a;\n#else\nreturn 0.0;\n#endif\n}float get_elevation(vec2 pos) {\n#ifdef TERRAIN3D\n#ifdef GLOBE\nif ((pos.y <-32767.5) || (pos.y > 32766.5)) {return 0.0;}\n#endif\nvec2 coord=(u_terrain_matrix*vec4(pos,0.0,1.0)).xy*u_terrain_dim+1.0;vec2 f=fract(coord);ivec2 c=ivec2(floor(coord));ivec2 hi=textureSize(u_terrain,0)-1;float tl=ele(clamp(c,ivec2(0),hi));float tr=ele(clamp(c+ivec2(1,0),ivec2(0),hi));float bl=ele(clamp(c+ivec2(0,1),ivec2(0),hi));float br=ele(clamp(c+ivec2(1,1),ivec2(0),hi));float elevation=mix(mix(tl,tr,f.x),mix(bl,br,f.x),f.y);return elevation*u_terrain_exaggeration;\n#else\nreturn 0.0;\n#endif\n}const float PI=3.141592653589793;uniform mat4 u_projection_matrix;"),projectionMercator:iy("\nvoid clipAntimeridian() {}","float projectLineThickness(float tileY) {return 1.0;}float projectCircleRadius(float tileY) {return 1.0;}vec4 projectTile(vec2 p) {vec4 result=u_projection_matrix*vec4(p,0.0,1.0);return result;}vec4 projectTile(vec2 p,vec2 rawPos) {vec4 result=u_projection_matrix*vec4(p,0.0,1.0);if (rawPos.y <-32767.5 || rawPos.y > 32766.5) {result.z=-10000000.0;}return result;}vec4 projectTileWithElevation(vec2 posInTile,float elevation) {return u_projection_matrix*vec4(posInTile,elevation,1.0);}vec4 projectTileFor3D(vec2 posInTile,float elevation) {return projectTileWithElevation(posInTile,elevation);}"),projectionGlobe:iy("uniform bool u_projection_clip_antimeridian;in highp float v_projection_tile_x;void clipAntimeridian() {if (u_projection_clip_antimeridian && (v_projection_tile_x < 0.0 || v_projection_tile_x >=8192.0)) {discard;}}","#define GLOBE_RADIUS 6371008.8\nuniform highp vec4 u_projection_tile_mercator_coords;uniform highp vec4 u_projection_clipping_plane;uniform highp float u_projection_transition;uniform mat4 u_projection_fallback_matrix;out highp float v_projection_tile_x;vec3 globeRotateVector(vec3 vec,vec2 angles) {vec3 axisRight=vec3(vec.z,0.0,-vec.x);vec3 axisUp=cross(axisRight,vec);axisRight=normalize(axisRight);axisUp=normalize(axisUp);vec2 t=tan(angles);return normalize(vec+axisRight*t.x+axisUp*t.y);}mat3 globeGetRotationMatrix(vec3 spherePos) {vec3 axisRight=vec3(spherePos.z,0.0,-spherePos.x);vec3 axisDown=cross(axisRight,spherePos);axisRight=normalize(axisRight);axisDown=normalize(axisDown);return mat3(axisRight,axisDown,spherePos\n);}float circumferenceRatioAtTileY(float tileY) {float mercator_pos_y=u_projection_tile_mercator_coords.y+u_projection_tile_mercator_coords.w*tileY;float t=exp(PI-(mercator_pos_y*PI*2.0));return (2.0*t)/(t*t+1.0);}float projectLineThickness(float tileY) {float thickness=1.0/circumferenceRatioAtTileY(tileY);if (u_projection_transition < 0.999) {return mix(1.0,thickness,u_projection_transition);} else {return thickness;}}vec3 projectToSphere(vec2 translatedPos,vec2 rawPos) {vec2 mercator_pos=u_projection_tile_mercator_coords.xy+u_projection_tile_mercator_coords.zw*translatedPos;float spherical_x=mercator_pos.x*PI*2.0+PI;float t=exp(PI-(mercator_pos.y*PI*2.0));float t2=t*t;float denom=t2+1.0;float sin_sy=(t2-1.0)/denom;float cos_sy=(2.0*t)/denom;vec3 pos=vec3(sin(spherical_x)*cos_sy,sin_sy,cos(spherical_x)*cos_sy\n);if (rawPos.y <-32767.5) {pos=vec3(0.0,1.0,0.0);}if (rawPos.y > 32766.5) {pos=vec3(0.0,-1.0,0.0);}return pos;}vec3 projectToSphere(vec2 posInTile) {return projectToSphere(posInTile,vec2(0.0,0.0));}float globeComputeClippingZ(vec3 spherePos) {return (1.0-(dot(spherePos,u_projection_clipping_plane.xyz)+u_projection_clipping_plane.w));}vec4 interpolateProjection(vec2 posInTile,vec3 spherePos,float elevation) {v_projection_tile_x=posInTile.x;vec3 elevatedPos=spherePos*(1.0+elevation/GLOBE_RADIUS);vec4 globePosition=u_projection_matrix*vec4(elevatedPos,1.0);globePosition.z=globeComputeClippingZ(elevatedPos)*globePosition.w;if (u_projection_transition > 0.999) {return globePosition;}vec4 flatPosition=u_projection_fallback_matrix*vec4(posInTile,elevation,1.0);const float z_globeness_threshold=0.2;vec4 result=globePosition;result.z=mix(0.0,globePosition.z,clamp((u_projection_transition-z_globeness_threshold)/(1.0-z_globeness_threshold),0.0,1.0));result.xyw=mix(flatPosition.xyw,globePosition.xyw,u_projection_transition);if ((posInTile.y <-32767.5) || (posInTile.y > 32766.5)) {result=globePosition;const float poles_hidden_anim_percentage=0.02;result.z=mix(globePosition.z,100.0,pow(max((1.0-u_projection_transition)/poles_hidden_anim_percentage,0.0),8.0));}return result;}vec4 interpolateProjectionFor3D(vec2 posInTile,vec3 spherePos,float elevation) {v_projection_tile_x=posInTile.x;vec3 elevatedPos=spherePos*(1.0+elevation/GLOBE_RADIUS);vec4 globePosition=u_projection_matrix*vec4(elevatedPos,1.0);if (u_projection_transition > 0.999) {return globePosition;}vec4 fallbackPosition=u_projection_fallback_matrix*vec4(posInTile,elevation,1.0);return mix(fallbackPosition,globePosition,u_projection_transition);}vec4 projectTile(vec2 posInTile) {return interpolateProjection(posInTile,projectToSphere(posInTile),0.0);}vec4 projectTile(vec2 posInTile,vec2 rawPos) {return interpolateProjection(posInTile,projectToSphere(posInTile,rawPos),0.0);}vec4 projectTileWithElevation(vec2 posInTile,float elevation) {return interpolateProjection(posInTile,projectToSphere(posInTile),elevation);}vec4 projectTileFor3D(vec2 posInTile,float elevation) {vec3 spherePos=projectToSphere(posInTile,posInTile);return interpolateProjectionFor3D(posInTile,spherePos,elevation);}"),background:iy("uniform vec4 u_color;uniform float u_opacity;void main() {fragColor=u_color*u_opacity;\n#ifdef OVERDRAW_INSPECTOR\nfragColor=vec4(1.0);\n#endif\n}","layout(location=0) in vec2 a_pos;void main() {gl_Position=projectTile(a_pos);}"),backgroundPattern:iy("uniform vec2 u_pattern_tl_a;uniform vec2 u_pattern_br_a;uniform vec2 u_pattern_tl_b;uniform vec2 u_pattern_br_b;uniform vec2 u_texsize;uniform float u_mix;uniform float u_opacity;uniform sampler2D u_image;in vec2 v_pos_a;in vec2 v_pos_b;void main() {vec2 imagecoord=mod(v_pos_a,1.0);vec2 pos=mix(u_pattern_tl_a/u_texsize,u_pattern_br_a/u_texsize,imagecoord);vec4 color1=texture(u_image,pos);vec2 imagecoord_b=mod(v_pos_b,1.0);vec2 pos2=mix(u_pattern_tl_b/u_texsize,u_pattern_br_b/u_texsize,imagecoord_b);vec4 color2=texture(u_image,pos2);fragColor=mix(color1,color2,u_mix)*u_opacity;\n#ifdef OVERDRAW_INSPECTOR\nfragColor=vec4(1.0);\n#endif\n}","uniform vec2 u_pattern_size_a;uniform vec2 u_pattern_size_b;uniform vec2 u_pixel_coord_upper;uniform vec2 u_pixel_coord_lower;uniform float u_scale_a;uniform float u_scale_b;uniform float u_tile_units_to_pixels;layout(location=0) in vec2 a_pos;out vec2 v_pos_a;out vec2 v_pos_b;void main() {gl_Position=projectTile(a_pos);v_pos_a=get_pattern_pos(u_pixel_coord_upper,u_pixel_coord_lower,u_scale_a*u_pattern_size_a,u_tile_units_to_pixels,a_pos);v_pos_b=get_pattern_pos(u_pixel_coord_upper,u_pixel_coord_lower,u_scale_b*u_pattern_size_b,u_tile_units_to_pixels,a_pos);}"),circle:iy("in vec3 v_data;flat in float v_visibility;\n#pragma maplibre: define highp vec4 color\n#pragma maplibre: define mediump float radius\n#pragma maplibre: define lowp float blur\n#pragma maplibre: define lowp float opacity\n#pragma maplibre: define highp vec4 stroke_color\n#pragma maplibre: define mediump float stroke_width\n#pragma maplibre: define lowp float stroke_opacity\nvoid main() {\n#pragma maplibre: initialize highp vec4 color\n#pragma maplibre: initialize mediump float radius\n#pragma maplibre: initialize lowp float blur\n#pragma maplibre: initialize lowp float opacity\n#pragma maplibre: initialize highp vec4 stroke_color\n#pragma maplibre: initialize mediump float stroke_width\n#pragma maplibre: initialize lowp float stroke_opacity\nvec2 extrude=v_data.xy;float extrude_length=length(extrude);float antialiased_blur=v_data.z;float opacity_t=smoothstep(0.0,antialiased_blur,extrude_length-1.0);float color_t=stroke_width < 0.01 ? 0.0 : smoothstep(antialiased_blur,0.0,extrude_length-radius/(radius+stroke_width));fragColor=v_visibility*opacity_t*mix(color*opacity,stroke_color*stroke_opacity,color_t);const float epsilon=0.5/255.0;if (fragColor.r < epsilon && fragColor.g < epsilon && fragColor.b < epsilon && fragColor.a < epsilon) {discard;}\n#ifdef OVERDRAW_INSPECTOR\nfragColor=vec4(1.0);\n#endif\n}","uniform bool u_scale_with_map;uniform bool u_pitch_with_map;uniform vec2 u_extrude_scale;uniform highp float u_globe_extrude_scale;uniform lowp float u_device_pixel_ratio;uniform highp float u_camera_to_center_distance;uniform vec2 u_translate;layout(location=0) in ivec2 a_pos;out vec3 v_data;flat out float v_visibility;\n#pragma maplibre: define highp vec4 color\n#pragma maplibre: define mediump float radius\n#pragma maplibre: define lowp float blur\n#pragma maplibre: define lowp float opacity\n#pragma maplibre: define highp vec4 stroke_color\n#pragma maplibre: define mediump float stroke_width\n#pragma maplibre: define lowp float stroke_opacity\nvoid main(void) {\n#pragma maplibre: initialize highp vec4 color\n#pragma maplibre: initialize mediump float radius\n#pragma maplibre: initialize lowp float blur\n#pragma maplibre: initialize lowp float opacity\n#pragma maplibre: initialize highp vec4 stroke_color\n#pragma maplibre: initialize mediump float stroke_width\n#pragma maplibre: initialize lowp float stroke_opacity\nivec2 pos_raw=a_pos+32768;vec2 extrude=vec2(pos_raw & 7)/7.0*2.0-1.0;vec2 circle_center=vec2(pos_raw >> 3)+u_translate;float ele=get_elevation(circle_center);v_visibility=calculate_visibility(projectTileWithElevation(circle_center,ele));if (u_pitch_with_map) {\n#ifdef GLOBE\nvec3 center_vector=projectToSphere(circle_center);\n#endif\nfloat angle_scale=u_globe_extrude_scale;vec2 corner_position=circle_center;if (u_scale_with_map) {angle_scale*=(radius+stroke_width);corner_position+=extrude*u_extrude_scale*(radius+stroke_width);} else {\n#ifdef GLOBE\nvec4 projected_center=interpolateProjection(circle_center,center_vector,ele);\n#else\nvec4 projected_center=projectTileWithElevation(circle_center,ele);\n#endif\ncorner_position+=extrude*u_extrude_scale*(radius+stroke_width)*(projected_center.w/u_camera_to_center_distance);angle_scale*=(radius+stroke_width)*(projected_center.w/u_camera_to_center_distance);}\n#ifdef GLOBE\nvec2 angles=extrude*angle_scale;vec3 corner_vector=globeRotateVector(center_vector,angles);gl_Position=interpolateProjection(corner_position,corner_vector,ele);\n#else\ngl_Position=projectTileWithElevation(corner_position,ele);\n#endif\n} else {gl_Position=projectTileWithElevation(circle_center,ele);if (gl_Position.z/gl_Position.w > 1.0) {gl_Position.xy=vec2(10000.0);}if (u_scale_with_map) {gl_Position.xy+=extrude*(radius+stroke_width)*u_extrude_scale*u_camera_to_center_distance;} else {gl_Position.xy+=extrude*(radius+stroke_width)*u_extrude_scale*gl_Position.w;}}float antialiasblur=-max(1.0/u_device_pixel_ratio/(radius+stroke_width),blur);v_data=vec3(extrude.x,extrude.y,antialiasblur);}"),clippingMask:iy(ey,"layout(location=0) in vec2 a_pos;void main() {gl_Position=projectTile(a_pos);}"),heatmap:iy("uniform highp float u_intensity;in vec2 v_extrude;\n#pragma maplibre: define highp float weight\n#define GAUSS_COEF 0.3989422804014327\nvoid main() {\n#pragma maplibre: initialize highp float weight\nfloat d=-0.5*3.0*3.0*dot(v_extrude,v_extrude);float val=weight*u_intensity*GAUSS_COEF*exp(d);fragColor=vec4(val,1.0,1.0,1.0);\n#ifdef OVERDRAW_INSPECTOR\nfragColor=vec4(1.0);\n#endif\n}","uniform float u_extrude_scale;uniform float u_opacity;uniform float u_intensity;uniform highp float u_globe_extrude_scale;layout(location=0) in ivec2 a_pos;out vec2 v_extrude;\n#pragma maplibre: define highp float weight\n#pragma maplibre: define mediump float radius\nconst highp float ZERO=1.0/255.0/16.0;\n#define GAUSS_COEF 0.3989422804014327\nvoid main(void) {\n#pragma maplibre: initialize highp float weight\n#pragma maplibre: initialize mediump float radius\nivec2 pos_raw=a_pos+32768;vec2 unscaled_extrude=vec2(pos_raw & 7)/7.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 circle_center=vec2(pos_raw >> 3);\n#ifdef GLOBE\nvec2 angles=v_extrude*radius*u_globe_extrude_scale;vec3 center_vector=projectToSphere(circle_center);vec3 corner_vector=globeRotateVector(center_vector,angles);gl_Position=interpolateProjection(circle_center+extrude,corner_vector,0.0);\n#else\ngl_Position=projectTileFor3D(circle_center+extrude,get_elevation(circle_center));\n#endif\n}"),heatmapTexture:iy("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));fragColor=color*u_opacity;\n#ifdef OVERDRAW_INSPECTOR\nfragColor=vec4(0.0);\n#endif\n}","uniform mat4 u_matrix;uniform vec2 u_world;layout(location=0) in vec2 a_pos;out vec2 v_pos;void main() {gl_Position=u_matrix*vec4(a_pos*u_world,0,1);v_pos.x=a_pos.x;v_pos.y=1.0-a_pos.y;}"),collisionBox:iy("flat in float v_placed;flat in float v_notUsed;void main() {float alpha=0.5;fragColor=vec4(1.0,0.0,0.0,1.0)*alpha;if (v_placed > 0.5) {fragColor=vec4(0.0,0.0,1.0,0.5)*alpha;}if (v_notUsed > 0.5) {fragColor*=.1;}}","layout(location=0) in vec2 a_anchor_pos;layout(location=1) in vec2 a_placed;layout(location=2) in vec2 a_box_real;uniform vec2 u_pixel_extrude_scale;flat out float v_placed;flat out float v_notUsed;void main() {gl_Position=projectTileWithElevation(a_anchor_pos,get_elevation(a_anchor_pos));gl_Position.xy=((a_box_real+0.5)*u_pixel_extrude_scale*2.0-1.0)*vec2(1.0,-1.0)*gl_Position.w;if (gl_Position.z/gl_Position.w < 1.1) {gl_Position.z=0.5;}v_placed=a_placed.x;v_notUsed=a_placed.y;}"),collisionCircle:iy("flat in float v_radius;in vec2 v_extrude;flat in float v_collision;void main() {float alpha=0.5;float stroke_radius=0.9;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);fragColor=color*alpha*opacity_t;}","layout(location=0) in vec2 a_pos;layout(location=1) in float a_radius;layout(location=2) in vec2 a_flags;uniform vec2 u_viewport_size;flat out float v_radius;out vec2 v_extrude;flat out float v_collision;void main() {float radius=a_radius;float collision=a_flags.x;float vertexIdx=a_flags.y;vec2 quadVertexOffset=vec2(mix(-1.0,1.0,float(vertexIdx >=2.0)),mix(-1.0,1.0,float(vertexIdx >=1.0 && vertexIdx <=2.0)));vec2 quadVertexExtent=quadVertexOffset*radius;float padding_factor=1.2;v_radius=radius;v_extrude=quadVertexExtent*padding_factor;v_collision=collision;gl_Position=vec4((a_pos/u_viewport_size*2.0-1.0)*vec2(1.0,-1.0),0.0,1.0)+vec4(quadVertexExtent*padding_factor/u_viewport_size*2.0,0.0,0.0);}"),colorRelief:iy("#ifdef GL_ES\nprecision highp float;\n#endif\nuniform sampler2D u_image;uniform vec4 u_unpack;uniform sampler2D u_elevation_stops;uniform sampler2D u_color_stops;uniform int u_color_ramp_size;uniform float u_opacity;in vec2 v_pos;float getElevation(vec2 coord) {vec4 data=texture(u_image,coord)*255.0;data.a=-1.0;return dot(data,u_unpack);}float getElevationStop(int stop) {vec4 data=texelFetch(u_elevation_stops,ivec2(stop,0),0)*255.0;data.a=-1.0;return dot(data,u_unpack);}void main() {float el=getElevation(v_pos);int r=(u_color_ramp_size-1);int l=0;float el_l=getElevationStop(l);float el_r=getElevationStop(r);while(r-l > 1){int m=(r+l)/2;float el_m=getElevationStop(m);if(el < el_m){r=m;el_r=el_m;}else\n{l=m;el_l=el_m;}}float x=(float(l)+(el-el_l)/(el_r-el_l)+0.5)/float(u_color_ramp_size);fragColor=u_opacity*texture(u_color_stops,vec2(x,0));\n#ifdef OVERDRAW_INSPECTOR\nfragColor=vec4(1.0);\n#endif\n}","uniform vec2 u_dimension;layout(location=0) in vec2 a_pos;out vec2 v_pos;void main() {gl_Position=projectTile(a_pos,a_pos);highp vec2 epsilon=1.0/u_dimension;float scale=(u_dimension.x-2.0)/u_dimension.x;v_pos=(a_pos/8192.0)*scale+epsilon;if (a_pos.y <-32767.5) {v_pos.y=0.0;}if (a_pos.y > 32766.5) {v_pos.y=1.0;}}"),debug:iy("uniform highp vec4 u_color;uniform sampler2D u_overlay;in vec2 v_uv;void main() {vec4 overlay_color=texture(u_overlay,v_uv);fragColor=mix(u_color,overlay_color,overlay_color.a);}","layout(location=0) in vec2 a_pos;out vec2 v_uv;uniform float u_overlay_scale;void main() {v_uv=a_pos/8192.0;gl_Position=projectTileWithElevation(a_pos*u_overlay_scale,get_elevation(a_pos));}"),depth:iy(ey,"layout(location=0) in vec2 a_pos;void main() {\n#ifdef GLOBE\ngl_Position=projectTileFor3D(a_pos,0.0);\n#else\ngl_Position=u_projection_matrix*vec4(a_pos,0.0,1.0);\n#endif\n}"),fill:iy("#pragma maplibre: define highp vec4 color\n#pragma maplibre: define lowp float opacity\nvoid main() {\n#pragma maplibre: initialize highp vec4 color\n#pragma maplibre: initialize lowp float opacity\nfragColor=color*opacity;\n#ifdef OVERDRAW_INSPECTOR\nfragColor=vec4(1.0);\n#endif\n}","uniform vec2 u_fill_translate;layout(location=0) in vec2 a_pos;\n#pragma maplibre: define highp vec4 color\n#pragma maplibre: define lowp float opacity\nvoid main() {\n#pragma maplibre: initialize highp vec4 color\n#pragma maplibre: initialize lowp float opacity\nif (opacity < 0.01) {gl_Position=vec4(-2.0,-2.0,-2.0,1.0);return;}gl_Position=projectTile(a_pos+u_fill_translate,a_pos);}"),fillOutline:iy("in vec2 v_pos;\n#ifdef GLOBE\nin float v_depth;\n#endif\n#pragma maplibre: define highp vec4 outline_color\n#pragma maplibre: define lowp float opacity\nvoid main() {\n#pragma maplibre: initialize highp vec4 outline_color\n#pragma maplibre: initialize lowp float opacity\nfloat dist=length(v_pos-gl_FragCoord.xy);float alpha=1.0-smoothstep(0.0,1.0,dist);fragColor=outline_color*(alpha*opacity);\n#ifdef GLOBE\nif (v_depth > 1.0) {discard;}\n#endif\n#ifdef OVERDRAW_INSPECTOR\nfragColor=vec4(1.0);\n#endif\n}","uniform vec2 u_world;uniform vec2 u_fill_translate;layout(location=0) in vec2 a_pos;out vec2 v_pos;\n#ifdef GLOBE\nout float v_depth;\n#endif\n#pragma maplibre: define highp vec4 outline_color\n#pragma maplibre: define lowp float opacity\nvoid main() {\n#pragma maplibre: initialize highp vec4 outline_color\n#pragma maplibre: initialize lowp float opacity\nif (opacity < 0.01) {gl_Position=vec4(-2.0,-2.0,-2.0,1.0);return;}gl_Position=projectTile(a_pos+u_fill_translate,a_pos);v_pos=(gl_Position.xy/gl_Position.w+1.0)/2.0*u_world;\n#ifdef GLOBE\nv_depth=gl_Position.z/gl_Position.w;\n#endif\n}"),fillOutlinePattern:iy("uniform vec2 u_texsize;uniform sampler2D u_image;uniform float u_fade;in vec2 v_pos_a;in vec2 v_pos_b;in vec2 v_pos;\n#ifdef GLOBE\nin float v_depth;\n#endif\n#pragma maplibre: define lowp float opacity\n#pragma maplibre: define lowp vec4 pattern_from\n#pragma maplibre: define lowp vec4 pattern_to\nvoid main() {\n#pragma maplibre: initialize lowp float opacity\n#pragma maplibre: initialize mediump vec4 pattern_from\n#pragma maplibre: initialize mediump vec4 pattern_to\nvec2 pattern_tl_a=pattern_from.xy;vec2 pattern_br_a=pattern_from.zw;vec2 pattern_tl_b=pattern_to.xy;vec2 pattern_br_b=pattern_to.zw;vec2 imagecoord=mod(v_pos_a,1.0);vec2 pos=mix(pattern_tl_a/u_texsize,pattern_br_a/u_texsize,imagecoord);vec4 color1=texture(u_image,pos);vec2 imagecoord_b=mod(v_pos_b,1.0);vec2 pos2=mix(pattern_tl_b/u_texsize,pattern_br_b/u_texsize,imagecoord_b);vec4 color2=texture(u_image,pos2);float dist=length(v_pos-gl_FragCoord.xy);float alpha=1.0-smoothstep(0.0,1.0,dist);fragColor=mix(color1,color2,u_fade)*alpha*opacity;\n#ifdef GLOBE\nif (v_depth > 1.0) {discard;}\n#endif\n#ifdef OVERDRAW_INSPECTOR\nfragColor=vec4(1.0);\n#endif\n}","uniform vec2 u_world;uniform vec2 u_pixel_coord_upper;uniform vec2 u_pixel_coord_lower;uniform vec3 u_scale;uniform vec2 u_fill_translate;layout(location=0) in vec2 a_pos;out vec2 v_pos_a;out vec2 v_pos_b;out vec2 v_pos;\n#ifdef GLOBE\nout float v_depth;\n#endif\n#pragma maplibre: define lowp float opacity\n#pragma maplibre: define lowp vec4 pattern_from\n#pragma maplibre: define lowp vec4 pattern_to\n#pragma maplibre: define lowp float pixel_ratio_from\n#pragma maplibre: define lowp float pixel_ratio_to\nvoid main() {\n#pragma maplibre: initialize lowp float opacity\n#pragma maplibre: initialize mediump vec4 pattern_from\n#pragma maplibre: initialize mediump vec4 pattern_to\n#pragma maplibre: initialize lowp float pixel_ratio_from\n#pragma maplibre: initialize lowp float pixel_ratio_to\nif (opacity < 0.01) {gl_Position=vec4(-2.0,-2.0,-2.0,1.0);return;}vec2 pattern_tl_a=pattern_from.xy;vec2 pattern_br_a=pattern_from.zw;vec2 pattern_tl_b=pattern_to.xy;vec2 pattern_br_b=pattern_to.zw;float tileRatio=u_scale.x;float fromScale=u_scale.y;float toScale=u_scale.z;gl_Position=projectTile(a_pos+u_fill_translate,a_pos);vec2 display_size_a=(pattern_br_a-pattern_tl_a)/pixel_ratio_from;vec2 display_size_b=(pattern_br_b-pattern_tl_b)/pixel_ratio_to;v_pos_a=get_pattern_pos(u_pixel_coord_upper,u_pixel_coord_lower,fromScale*display_size_a,tileRatio,a_pos);v_pos_b=get_pattern_pos(u_pixel_coord_upper,u_pixel_coord_lower,toScale*display_size_b,tileRatio,a_pos);v_pos=(gl_Position.xy/gl_Position.w+1.0)/2.0*u_world;\n#ifdef GLOBE\nv_depth=gl_Position.z/gl_Position.w;\n#endif\n}"),fillPattern:iy("#ifdef GL_ES\nprecision highp float;\n#endif\nuniform vec2 u_texsize;uniform float u_fade;uniform sampler2D u_image;in vec2 v_pos_a;in vec2 v_pos_b;\n#pragma maplibre: define lowp float opacity\n#pragma maplibre: define lowp vec4 pattern_from\n#pragma maplibre: define lowp vec4 pattern_to\nvoid main() {\n#pragma maplibre: initialize lowp float opacity\n#pragma maplibre: initialize mediump vec4 pattern_from\n#pragma maplibre: initialize mediump vec4 pattern_to\nvec2 pattern_tl_a=pattern_from.xy;vec2 pattern_br_a=pattern_from.zw;vec2 pattern_tl_b=pattern_to.xy;vec2 pattern_br_b=pattern_to.zw;vec2 imagecoord=mod(v_pos_a,1.0);vec2 pos=mix(pattern_tl_a/u_texsize,pattern_br_a/u_texsize,imagecoord);vec4 color1=texture(u_image,pos);vec2 imagecoord_b=mod(v_pos_b,1.0);vec2 pos2=mix(pattern_tl_b/u_texsize,pattern_br_b/u_texsize,imagecoord_b);vec4 color2=texture(u_image,pos2);fragColor=mix(color1,color2,u_fade)*opacity;\n#ifdef OVERDRAW_INSPECTOR\nfragColor=vec4(1.0);\n#endif\n}","uniform vec2 u_pixel_coord_upper;uniform vec2 u_pixel_coord_lower;uniform vec3 u_scale;uniform vec2 u_fill_translate;layout(location=0) in vec2 a_pos;out vec2 v_pos_a;out vec2 v_pos_b;\n#pragma maplibre: define lowp float opacity\n#pragma maplibre: define lowp vec4 pattern_from\n#pragma maplibre: define lowp vec4 pattern_to\n#pragma maplibre: define lowp float pixel_ratio_from\n#pragma maplibre: define lowp float pixel_ratio_to\nvoid main() {\n#pragma maplibre: initialize lowp float opacity\n#pragma maplibre: initialize mediump vec4 pattern_from\n#pragma maplibre: initialize mediump vec4 pattern_to\n#pragma maplibre: initialize lowp float pixel_ratio_from\n#pragma maplibre: initialize lowp float pixel_ratio_to\nif (opacity < 0.01) {gl_Position=vec4(-2.0,-2.0,-2.0,1.0);return;}vec2 pattern_tl_a=pattern_from.xy;vec2 pattern_br_a=pattern_from.zw;vec2 pattern_tl_b=pattern_to.xy;vec2 pattern_br_b=pattern_to.zw;float tileZoomRatio=u_scale.x;float fromScale=u_scale.y;float toScale=u_scale.z;vec2 display_size_a=(pattern_br_a-pattern_tl_a)/pixel_ratio_from;vec2 display_size_b=(pattern_br_b-pattern_tl_b)/pixel_ratio_to;gl_Position=projectTile(a_pos+u_fill_translate,a_pos);v_pos_a=get_pattern_pos(u_pixel_coord_upper,u_pixel_coord_lower,fromScale*display_size_a,tileZoomRatio,a_pos);v_pos_b=get_pattern_pos(u_pixel_coord_upper,u_pixel_coord_lower,toScale*display_size_b,tileZoomRatio,a_pos);}"),fillExtrusion:iy("in vec4 v_color;void main() {fragColor=v_color;\n#ifdef OVERDRAW_INSPECTOR\nfragColor=vec4(1.0);\n#endif\n}","uniform vec3 u_lightcolor;uniform lowp vec3 u_lightpos;uniform lowp vec3 u_lightpos_globe;uniform lowp float u_lightintensity;uniform float u_vertical_gradient;uniform lowp float u_opacity;uniform vec2 u_fill_translate;layout(location=0) in vec2 a_pos;layout(location=1) in ivec4 a_normal_ed;\n#ifdef TERRAIN3D\nlayout(location=2) in vec2 a_centroid;\n#endif\nout vec4 v_color;\n#pragma maplibre: define highp float base\n#pragma maplibre: define highp float height\n#pragma maplibre: define highp vec4 color\nvoid main() {\n#pragma maplibre: initialize highp float base\n#pragma maplibre: initialize highp float height\n#pragma maplibre: initialize highp vec4 color\nvec3 normal=vec3(a_normal_ed.xyz);\n#ifdef TERRAIN3D\nfloat height_terrain3d_offset=get_elevation(a_centroid);float base_terrain3d_offset=height_terrain3d_offset-(base > 0.0 ? 0.0 : 10.0);\n#else\nfloat height_terrain3d_offset=0.0;float base_terrain3d_offset=0.0;\n#endif\nbase=max(0.0,base)+base_terrain3d_offset;height=max(0.0,height)+height_terrain3d_offset;float t=float(a_normal_ed.x & 1);float elevation=t > 0.0 ? height : base;vec2 posInTile=a_pos+u_fill_translate;\n#ifdef GLOBE\nvec3 spherePos=projectToSphere(posInTile,a_pos);gl_Position=interpolateProjectionFor3D(posInTile,spherePos,elevation);\n#else\ngl_Position=u_projection_matrix*vec4(posInTile,elevation,1.0);\n#endif\nfloat colorvalue=color.r*0.2126+color.g*0.7152+color.b*0.0722;v_color=vec4(0.0,0.0,0.0,1.0);vec4 ambientlight=vec4(0.03,0.03,0.03,1.0);color+=ambientlight;vec3 normalForLighting=normal/16384.0;float directional=clamp(dot(normalForLighting,u_lightpos),0.0,1.0);\n#ifdef GLOBE\nmat3 rotMatrix=globeGetRotationMatrix(spherePos);normalForLighting=rotMatrix*normalForLighting;directional=mix(directional,clamp(dot(normalForLighting,u_lightpos_globe),0.0,1.0),u_projection_transition);\n#endif\ndirectional=mix((1.0-u_lightintensity),max((1.0-colorvalue+u_lightintensity),1.0),directional);if (normal.y !=0.0) {directional*=((1.0-u_vertical_gradient)+(u_vertical_gradient*clamp((t+base)*pow(height/150.0,0.5),mix(0.7,0.98,1.0-u_lightintensity),1.0)));}v_color.r+=clamp(color.r*directional*u_lightcolor.r,mix(0.0,0.3,1.0-u_lightcolor.r),1.0);v_color.g+=clamp(color.g*directional*u_lightcolor.g,mix(0.0,0.3,1.0-u_lightcolor.g),1.0);v_color.b+=clamp(color.b*directional*u_lightcolor.b,mix(0.0,0.3,1.0-u_lightcolor.b),1.0);v_color*=u_opacity;}"),fillExtrusionPattern:iy("uniform vec2 u_texsize;uniform float u_fade;uniform sampler2D u_image;in vec2 v_pos_a;in vec2 v_pos_b;in vec4 v_lighting;\n#pragma maplibre: define lowp float base\n#pragma maplibre: define lowp float height\n#pragma maplibre: define lowp vec4 pattern_from\n#pragma maplibre: define lowp vec4 pattern_to\n#pragma maplibre: define lowp float pixel_ratio_from\n#pragma maplibre: define lowp float pixel_ratio_to\nvoid main() {\n#pragma maplibre: initialize lowp float base\n#pragma maplibre: initialize lowp float height\n#pragma maplibre: initialize mediump vec4 pattern_from\n#pragma maplibre: initialize mediump vec4 pattern_to\n#pragma maplibre: initialize lowp float pixel_ratio_from\n#pragma maplibre: initialize lowp float pixel_ratio_to\nvec2 pattern_tl_a=pattern_from.xy;vec2 pattern_br_a=pattern_from.zw;vec2 pattern_tl_b=pattern_to.xy;vec2 pattern_br_b=pattern_to.zw;vec2 imagecoord=mod(v_pos_a,1.0);vec2 pos=mix(pattern_tl_a/u_texsize,pattern_br_a/u_texsize,imagecoord);vec4 color1=texture(u_image,pos);vec2 imagecoord_b=mod(v_pos_b,1.0);vec2 pos2=mix(pattern_tl_b/u_texsize,pattern_br_b/u_texsize,imagecoord_b);vec4 color2=texture(u_image,pos2);vec4 mixedColor=mix(color1,color2,u_fade);fragColor=mixedColor*v_lighting;\n#ifdef OVERDRAW_INSPECTOR\nfragColor=vec4(1.0);\n#endif\n}","uniform vec2 u_pixel_coord_upper;uniform vec2 u_pixel_coord_lower;uniform float u_height_factor;uniform vec3 u_scale;uniform float u_vertical_gradient;uniform lowp float u_opacity;uniform vec2 u_fill_translate;uniform vec3 u_lightcolor;uniform lowp vec3 u_lightpos;uniform lowp vec3 u_lightpos_globe;uniform lowp float u_lightintensity;layout(location=0) in vec2 a_pos;layout(location=1) in ivec4 a_normal_ed;\n#ifdef TERRAIN3D\nlayout(location=2) in vec2 a_centroid;\n#endif\n#ifdef GLOBE\nout vec3 v_sphere_pos;\n#endif\nout vec2 v_pos_a;out vec2 v_pos_b;out vec4 v_lighting;\n#pragma maplibre: define lowp float base\n#pragma maplibre: define lowp float height\n#pragma maplibre: define lowp vec4 pattern_from\n#pragma maplibre: define lowp vec4 pattern_to\n#pragma maplibre: define lowp float pixel_ratio_from\n#pragma maplibre: define lowp float pixel_ratio_to\nvoid main() {\n#pragma maplibre: initialize lowp float base\n#pragma maplibre: initialize lowp float height\n#pragma maplibre: initialize mediump vec4 pattern_from\n#pragma maplibre: initialize mediump vec4 pattern_to\n#pragma maplibre: initialize lowp float pixel_ratio_from\n#pragma maplibre: initialize lowp float pixel_ratio_to\nvec2 pattern_tl_a=pattern_from.xy;vec2 pattern_br_a=pattern_from.zw;vec2 pattern_tl_b=pattern_to.xy;vec2 pattern_br_b=pattern_to.zw;float tileRatio=u_scale.x;float fromScale=u_scale.y;float toScale=u_scale.z;vec3 normal=vec3(a_normal_ed.xyz);float edgedistance=float(a_normal_ed.w);vec2 display_size_a=(pattern_br_a-pattern_tl_a)/pixel_ratio_from;vec2 display_size_b=(pattern_br_b-pattern_tl_b)/pixel_ratio_to;\n#ifdef TERRAIN3D\nfloat height_terrain3d_offset=get_elevation(a_centroid);float base_terrain3d_offset=height_terrain3d_offset-(base > 0.0 ? 0.0 : 10.0);\n#else\nfloat height_terrain3d_offset=0.0;float base_terrain3d_offset=0.0;\n#endif\nbase=max(0.0,base)+base_terrain3d_offset;height=max(0.0,height)+height_terrain3d_offset;float t=float(a_normal_ed.x & 1);float elevation=t > 0.0 ? height : base;vec2 posInTile=a_pos+u_fill_translate;\n#ifdef GLOBE\nvec3 spherePos=projectToSphere(posInTile,a_pos);vec3 elevatedPos=spherePos*(1.0+elevation/GLOBE_RADIUS);v_sphere_pos=elevatedPos;gl_Position=interpolateProjectionFor3D(posInTile,spherePos,elevation);\n#else\ngl_Position=u_projection_matrix*vec4(posInTile,elevation,1.0);\n#endif\nvec2 pos=a_normal_ed.x==1 && a_normal_ed.y==0 && a_normal_ed.z==16384\n? a_pos\n: vec2(edgedistance,elevation*u_height_factor);v_pos_a=get_pattern_pos(u_pixel_coord_upper,u_pixel_coord_lower,fromScale*display_size_a,tileRatio,pos);v_pos_b=get_pattern_pos(u_pixel_coord_upper,u_pixel_coord_lower,toScale*display_size_b,tileRatio,pos);v_lighting=vec4(0.0,0.0,0.0,1.0);float directional=clamp(dot(normal/16383.0,u_lightpos),0.0,1.0);directional=mix((1.0-u_lightintensity),max((0.5+u_lightintensity),1.0),directional);if (normal.y !=0.0) {directional*=((1.0-u_vertical_gradient)+(u_vertical_gradient*clamp((t+base)*pow(height/150.0,0.5),mix(0.7,0.98,1.0-u_lightintensity),1.0)));}v_lighting.rgb+=clamp(directional*u_lightcolor,mix(vec3(0.0),vec3(0.3),1.0-u_lightcolor),vec3(1.0));v_lighting*=u_opacity;}"),hillshadePrepare:iy("#ifdef GL_ES\nprecision highp float;\n#endif\nuniform sampler2D u_image;in vec2 v_pos;uniform vec2 u_dimension;uniform float u_zoom;uniform vec4 u_unpack;float getElevation(ivec2 texel) {vec4 data=texelFetch(u_image,texel,0)*255.0;data.a=-1.0;return dot(data,u_unpack);}void main() {ivec2 pos=ivec2(gl_FragCoord.xy)+ivec2(1);float tileSize=u_dimension.x-2.0;float a=getElevation(pos+ivec2(-1,-1));float b=getElevation(pos+ivec2(0,-1));float c=getElevation(pos+ivec2(1,-1));float d=getElevation(pos+ivec2(-1,0));float e=getElevation(pos);float f=getElevation(pos+ivec2(1,0));float g=getElevation(pos+ivec2(-1,1));float h=getElevation(pos+ivec2(0,1));float i=getElevation(pos+ivec2(1,1));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((c+f+f+i)-(a+d+d+g),(g+h+h+i)-(a+b+b+c))*tileSize/pow(2.0,exaggeration+(28.2562-u_zoom));fragColor=clamp(vec4(deriv.x/8.0+0.5,deriv.y/8.0+0.5,1.0,1.0),0.0,1.0);\n#ifdef OVERDRAW_INSPECTOR\nfragColor=vec4(1.0);\n#endif\n}","uniform mat4 u_matrix;uniform vec2 u_dimension;layout(location=0) in vec2 a_pos;layout(location=1) in vec2 a_texture_pos;out vec2 v_pos;void main() {gl_Position=u_matrix*vec4(a_pos,0,1);highp vec2 epsilon=1.0/u_dimension;float scale=(u_dimension.x-2.0)/u_dimension.x;v_pos=(a_texture_pos/8192.0)*scale+epsilon;}"),hillshade:iy("uniform sampler2D u_image;in vec2 v_pos;uniform vec2 u_latrange;uniform float u_exaggeration;uniform vec4 u_accent;uniform int u_method;uniform float u_altitudes[NUM_ILLUMINATION_SOURCES];uniform float u_azimuths[NUM_ILLUMINATION_SOURCES];uniform vec4 u_shadows[NUM_ILLUMINATION_SOURCES];uniform vec4 u_highlights[NUM_ILLUMINATION_SOURCES];\n#define PI 3.141592653589793\n#define STANDARD 0\n#define COMBINED 1\n#define IGOR 2\n#define MULTIDIRECTIONAL 3\n#define BASIC 4\nfloat get_aspect(vec2 deriv){return deriv.x !=0.0 ? atan(deriv.y,-deriv.x) : PI/2.0*(deriv.y > 0.0 ? 1.0 :-1.0);}void igor_hillshade(vec2 deriv){deriv=deriv*u_exaggeration*2.0;float aspect=get_aspect(deriv);float azimuth=u_azimuths[0]+PI;float slope_stength=atan(length(deriv))*2.0/PI;float aspect_strength=1.0-abs(mod((aspect+azimuth)/PI+0.5,2.0)-1.0);float shadow_strength=slope_stength*aspect_strength;float highlight_strength=slope_stength*(1.0-aspect_strength);fragColor=u_shadows[0]*shadow_strength+u_highlights[0]*highlight_strength;}void standard_hillshade(vec2 deriv){float azimuth=u_azimuths[0]+PI;float slope=atan(0.625*length(deriv));float aspect=get_aspect(deriv);float intensity=u_exaggeration;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_shadows[0],u_highlights[0],shade)*sin(scaledSlope)*clamp(intensity*2.0,0.0,1.0);fragColor=accent_color*(1.0-shade_color.a)+shade_color;}void basic_hillshade(vec2 deriv){deriv=deriv*u_exaggeration*2.0;float azimuth=u_azimuths[0]+PI;float cos_az=cos(azimuth);float sin_az=sin(azimuth);float cos_alt=cos(u_altitudes[0]);float sin_alt=sin(u_altitudes[0]);float cang=(sin_alt-(deriv.y*cos_az*cos_alt-deriv.x*sin_az*cos_alt))/sqrt(1.0+dot(deriv,deriv));float shade=clamp(cang,0.0,1.0);if(shade > 0.5){fragColor=u_highlights[0]*(2.0*shade-1.0);}else\n{fragColor=u_shadows[0]*(1.0-2.0*shade);}}void multidirectional_hillshade(vec2 deriv){deriv=deriv*u_exaggeration*2.0;fragColor=vec4(0,0,0,0);for(int i=0; i < NUM_ILLUMINATION_SOURCES; i++){float cos_alt=cos(u_altitudes[i]);float sin_alt=sin(u_altitudes[i]);float cos_az=-cos(u_azimuths[i]);float sin_az=-sin(u_azimuths[i]);float cang=(sin_alt-(deriv.y*cos_az*cos_alt-deriv.x*sin_az*cos_alt))/sqrt(1.0+dot(deriv,deriv));float shade=clamp(cang,0.0,1.0);if(shade > 0.5){fragColor+=u_highlights[i]*(2.0*shade-1.0)/float(NUM_ILLUMINATION_SOURCES);}else\n{fragColor+=u_shadows[i]*(1.0-2.0*shade)/float(NUM_ILLUMINATION_SOURCES);}}}void combined_hillshade(vec2 deriv){deriv=deriv*u_exaggeration*2.0;float azimuth=u_azimuths[0]+PI;float cos_az=cos(azimuth);float sin_az=sin(azimuth);float cos_alt=cos(u_altitudes[0]);float sin_alt=sin(u_altitudes[0]);float cang=acos((sin_alt-(deriv.y*cos_az*cos_alt-deriv.x*sin_az*cos_alt))/sqrt(1.0+dot(deriv,deriv)));cang=clamp(cang,0.0,PI/2.0);float shade=cang*atan(length(deriv))*4.0/PI/PI;float highlight=(PI/2.0-cang)*atan(length(deriv))*4.0/PI/PI;fragColor=u_shadows[0]*shade+u_highlights[0]*highlight;}void main() {vec4 pixel=texture(u_image,v_pos);float scaleFactor=cos(radians((u_latrange[0]-u_latrange[1])*(1.0-v_pos.y)+u_latrange[1]));vec2 deriv=((pixel.rg*8.0)-4.0)/scaleFactor;if (u_method==BASIC) {basic_hillshade(deriv);} else if (u_method==COMBINED) {combined_hillshade(deriv);} else if (u_method==IGOR) {igor_hillshade(deriv);} else if (u_method==MULTIDIRECTIONAL) {multidirectional_hillshade(deriv);} else if (u_method==STANDARD) {standard_hillshade(deriv);} else {standard_hillshade(deriv);}\n#ifdef OVERDRAW_INSPECTOR\nfragColor=vec4(1.0);\n#endif\n}","uniform mat4 u_matrix;layout(location=0) in vec2 a_pos;out vec2 v_pos;void main() {gl_Position=projectTile(a_pos,a_pos);v_pos=a_pos/8192.0;if (a_pos.y <-32767.5) {v_pos.y=0.0;}if (a_pos.y > 32766.5) {v_pos.y=1.0;}}"),line:iy("uniform lowp float u_device_pixel_ratio;flat in vec2 v_width2;in vec2 v_normal;in float v_gamma_scale;\n#ifdef GLOBE\nin float v_depth;\n#endif\n#pragma maplibre: define highp vec4 color\n#pragma maplibre: define lowp float blur\n#pragma maplibre: define lowp float opacity\nvoid main() {\n#pragma maplibre: initialize highp vec4 color\n#pragma maplibre: initialize lowp float blur\n#pragma maplibre: initialize lowp float opacity\nclipAntimeridian();float dist=length(v_normal)*v_width2.s;float blur2=(blur+1.0/u_device_pixel_ratio)*v_gamma_scale;float alpha=clamp(min(dist-(v_width2.t-blur2),v_width2.s-dist)/blur2,0.0,1.0);fragColor=color*(alpha*opacity);\n#ifdef GLOBE\nif (v_depth > 1.0) {discard;}\n#endif\n#ifdef OVERDRAW_INSPECTOR\nfragColor=vec4(1.0);\n#endif\n}","\n#define scale 0.015873016\nlayout(location=0) in ivec2 a_pos_normal;layout(location=1) in uvec4 a_data;uniform vec2 u_translation;uniform mediump float u_ratio;uniform vec2 u_units_to_pixels;uniform lowp float u_device_pixel_ratio;out vec2 v_normal;flat out vec2 v_width2;out float v_gamma_scale;out highp float v_linesofar;\n#ifdef GLOBE\nout float v_depth;\n#endif\n#pragma maplibre: define highp vec4 color\n#pragma maplibre: define lowp float blur\n#pragma maplibre: define lowp float opacity\n#pragma maplibre: define mediump float gapwidth\n#pragma maplibre: define lowp float offset\n#pragma maplibre: define mediump float width\nvoid main() {\n#pragma maplibre: initialize highp vec4 color\n#pragma maplibre: initialize lowp float blur\n#pragma maplibre: initialize lowp float opacity\n#pragma maplibre: initialize mediump float gapwidth\n#pragma maplibre: initialize lowp float offset\n#pragma maplibre: initialize mediump float width\nif (opacity < 0.01) {gl_Position=vec4(-2.0,-2.0,-2.0,1.0);return;}float ANTIALIASING=1.0/u_device_pixel_ratio/2.0;vec2 a_extrude=vec2(ivec2(a_data.xy)-128);float a_direction=float(int(a_data.z & 3u)-1);v_linesofar=float((a_data.z >> 2u)+a_data.w*64u)*2.0;vec2 pos=vec2(a_pos_normal >> 1);mediump vec2 normal=vec2(a_pos_normal & 1);normal.y=normal.y*2.0-1.0;v_normal=normal;gapwidth=gapwidth/2.0;float halfwidth=width/2.0;offset=-1.0*offset;float inset=gapwidth+(gapwidth > 0.0 ? ANTIALIASING : 0.0);float outset=gapwidth+halfwidth*(gapwidth > 0.0 ? 2.0 : 1.0)+(halfwidth==0.0 ? 0.0 : ANTIALIASING);mediump vec2 dist=outset*a_extrude*scale;mediump float u=0.5*a_direction;mediump float t=1.0-abs(u);mediump vec2 offset2=offset*a_extrude*scale*normal.y*mat2(t,-u,u,t);float adjustedThickness=projectLineThickness(pos.y);vec4 projected_no_extrude=projectTile(pos+offset2/u_ratio*adjustedThickness+u_translation);vec4 projected_with_extrude=projectTile(pos+offset2/u_ratio*adjustedThickness+u_translation+dist/u_ratio*adjustedThickness);gl_Position=projected_with_extrude;\n#ifdef GLOBE\nv_depth=gl_Position.z/gl_Position.w;\n#endif\n#ifdef TERRAIN3D\nv_gamma_scale=1.0;\n#else\nfloat extrude_length_without_perspective=length(dist);float extrude_length_with_perspective=length((projected_with_extrude.xy-projected_no_extrude.xy)/projected_with_extrude.w*u_units_to_pixels);v_gamma_scale=extrude_length_without_perspective/extrude_length_with_perspective;\n#endif\nv_width2=vec2(outset,inset);}"),lineGradient:iy("uniform lowp float u_device_pixel_ratio;uniform sampler2D u_image;flat in vec2 v_width2;in vec2 v_normal;in float v_gamma_scale;in highp vec2 v_uv;\n#ifdef GLOBE\nin float v_depth;\n#endif\n#pragma maplibre: define lowp float blur\n#pragma maplibre: define lowp float opacity\nvoid main() {\n#pragma maplibre: initialize lowp float blur\n#pragma maplibre: initialize lowp float opacity\nclipAntimeridian();float dist=length(v_normal)*v_width2.s;float blur2=(blur+1.0/u_device_pixel_ratio)*v_gamma_scale;float alpha=clamp(min(dist-(v_width2.t-blur2),v_width2.s-dist)/blur2,0.0,1.0);vec4 color=texture(u_image,v_uv);fragColor=color*(alpha*opacity);\n#ifdef GLOBE\nif (v_depth > 1.0) {discard;}\n#endif\n#ifdef OVERDRAW_INSPECTOR\nfragColor=vec4(1.0);\n#endif\n}","\n#define scale 0.015873016\nlayout(location=0) in ivec2 a_pos_normal;layout(location=1) in uvec4 a_data;layout(location=2) in float a_uv_x;layout(location=3) in float a_split_index;uniform vec2 u_translation;uniform mediump float u_ratio;uniform lowp float u_device_pixel_ratio;uniform vec2 u_units_to_pixels;uniform float u_image_height;out vec2 v_normal;flat out vec2 v_width2;out float v_gamma_scale;out highp vec2 v_uv;\n#ifdef GLOBE\nout float v_depth;\n#endif\n#pragma maplibre: define lowp float blur\n#pragma maplibre: define lowp float opacity\n#pragma maplibre: define mediump float gapwidth\n#pragma maplibre: define lowp float offset\n#pragma maplibre: define mediump float width\nvoid main() {\n#pragma maplibre: initialize lowp float blur\n#pragma maplibre: initialize lowp float opacity\n#pragma maplibre: initialize mediump float gapwidth\n#pragma maplibre: initialize lowp float offset\n#pragma maplibre: initialize mediump float width\nif (opacity < 0.01) {gl_Position=vec4(-2.0,-2.0,-2.0,1.0);return;}float ANTIALIASING=1.0/u_device_pixel_ratio/2.0;vec2 a_extrude=vec2(ivec2(a_data.xy)-128);float a_direction=float(int(a_data.z & 3u)-1);highp float texel_height=1.0/u_image_height;highp float half_texel_height=0.5*texel_height;v_uv=vec2(a_uv_x,a_split_index*texel_height-half_texel_height);vec2 pos=vec2(a_pos_normal >> 1);mediump vec2 normal=vec2(a_pos_normal & 1);normal.y=normal.y*2.0-1.0;v_normal=normal;gapwidth=gapwidth/2.0;float halfwidth=width/2.0;offset=-1.0*offset;float inset=gapwidth+(gapwidth > 0.0 ? ANTIALIASING : 0.0);float outset=gapwidth+halfwidth*(gapwidth > 0.0 ? 2.0 : 1.0)+(halfwidth==0.0 ? 0.0 : ANTIALIASING);mediump vec2 dist=outset*a_extrude*scale;mediump float u=0.5*a_direction;mediump float t=1.0-abs(u);mediump vec2 offset2=offset*a_extrude*scale*normal.y*mat2(t,-u,u,t);float adjustedThickness=projectLineThickness(pos.y);vec4 projected_no_extrude=projectTile(pos+offset2/u_ratio*adjustedThickness+u_translation);vec4 projected_with_extrude=projectTile(pos+offset2/u_ratio*adjustedThickness+u_translation+dist/u_ratio*adjustedThickness);gl_Position=projected_with_extrude;\n#ifdef GLOBE\nv_depth=gl_Position.z/gl_Position.w;\n#endif\n#ifdef TERRAIN3D\nv_gamma_scale=1.0;\n#else\nfloat extrude_length_without_perspective=length(dist);float extrude_length_with_perspective=length((projected_with_extrude.xy-projected_no_extrude.xy)/projected_with_extrude.w*u_units_to_pixels);v_gamma_scale=extrude_length_without_perspective/extrude_length_with_perspective;\n#endif\nv_width2=vec2(outset,inset);}"),linePattern:iy("#ifdef GL_ES\nprecision highp float;\n#endif\nuniform lowp float u_device_pixel_ratio;uniform vec2 u_texsize;uniform float u_fade;uniform mediump vec3 u_scale;uniform sampler2D u_image;in vec2 v_normal;flat in vec2 v_width2;in float v_linesofar;in float v_gamma_scale;flat in float v_width;\n#ifdef GLOBE\nin float v_depth;\n#endif\n#pragma maplibre: define lowp vec4 pattern_from\n#pragma maplibre: define lowp vec4 pattern_to\n#pragma maplibre: define lowp float pixel_ratio_from\n#pragma maplibre: define lowp float pixel_ratio_to\n#pragma maplibre: define lowp float blur\n#pragma maplibre: define lowp float opacity\nvoid main() {\n#pragma maplibre: initialize mediump vec4 pattern_from\n#pragma maplibre: initialize mediump vec4 pattern_to\n#pragma maplibre: initialize lowp float pixel_ratio_from\n#pragma maplibre: initialize lowp float pixel_ratio_to\n#pragma maplibre: initialize lowp float blur\n#pragma maplibre: initialize lowp float opacity\nclipAntimeridian();vec2 pattern_tl_a=pattern_from.xy;vec2 pattern_br_a=pattern_from.zw;vec2 pattern_tl_b=pattern_to.xy;vec2 pattern_br_b=pattern_to.zw;float tileZoomRatio=u_scale.x;float fromScale=u_scale.y;float toScale=u_scale.z;vec2 display_size_a=(pattern_br_a-pattern_tl_a)/pixel_ratio_from;vec2 display_size_b=(pattern_br_b-pattern_tl_b)/pixel_ratio_to;vec2 pattern_size_a=vec2(display_size_a.x*fromScale/tileZoomRatio,display_size_a.y);vec2 pattern_size_b=vec2(display_size_b.x*toScale/tileZoomRatio,display_size_b.y);float aspect_a=display_size_a.y/v_width;float aspect_b=display_size_b.y/v_width;float dist=length(v_normal)*v_width2.s;float blur2=(blur+1.0/u_device_pixel_ratio)*v_gamma_scale;float alpha=clamp(min(dist-(v_width2.t-blur2),v_width2.s-dist)/blur2,0.0,1.0);float x_a=mod(v_linesofar/pattern_size_a.x*aspect_a,1.0);float x_b=mod(v_linesofar/pattern_size_b.x*aspect_b,1.0);float y=0.5*v_normal.y+0.5;vec2 texel_size=1.0/u_texsize;vec2 pos_a=mix(pattern_tl_a*texel_size-texel_size,pattern_br_a*texel_size+texel_size,vec2(x_a,y));vec2 pos_b=mix(pattern_tl_b*texel_size-texel_size,pattern_br_b*texel_size+texel_size,vec2(x_b,y));vec4 color=mix(texture(u_image,pos_a),texture(u_image,pos_b),u_fade);fragColor=color*alpha*opacity;\n#ifdef GLOBE\nif (v_depth > 1.0) {discard;}\n#endif\n#ifdef OVERDRAW_INSPECTOR\nfragColor=vec4(1.0);\n#endif\n}","\n#define scale 0.015873016\n#define LINE_DISTANCE_SCALE 2.0\nlayout(location=0) in ivec2 a_pos_normal;layout(location=1) in uvec4 a_data;uniform vec2 u_translation;uniform vec2 u_units_to_pixels;uniform mediump float u_ratio;uniform lowp float u_device_pixel_ratio;out vec2 v_normal;flat out vec2 v_width2;out float v_linesofar;out float v_gamma_scale;flat out float v_width;\n#ifdef GLOBE\nout float v_depth;\n#endif\n#pragma maplibre: define lowp float blur\n#pragma maplibre: define lowp float opacity\n#pragma maplibre: define lowp float offset\n#pragma maplibre: define mediump float gapwidth\n#pragma maplibre: define mediump float width\n#pragma maplibre: define lowp float floorwidth\n#pragma maplibre: define lowp vec4 pattern_from\n#pragma maplibre: define lowp vec4 pattern_to\n#pragma maplibre: define lowp float pixel_ratio_from\n#pragma maplibre: define lowp float pixel_ratio_to\nvoid main() {\n#pragma maplibre: initialize lowp float blur\n#pragma maplibre: initialize lowp float opacity\n#pragma maplibre: initialize lowp float offset\n#pragma maplibre: initialize mediump float gapwidth\n#pragma maplibre: initialize mediump float width\n#pragma maplibre: initialize lowp float floorwidth\n#pragma maplibre: initialize mediump vec4 pattern_from\n#pragma maplibre: initialize mediump vec4 pattern_to\n#pragma maplibre: initialize lowp float pixel_ratio_from\n#pragma maplibre: initialize lowp float pixel_ratio_to\nif (opacity < 0.01) {gl_Position=vec4(-2.0,-2.0,-2.0,1.0);return;}float ANTIALIASING=1.0/u_device_pixel_ratio/2.0;vec2 a_extrude=vec2(ivec2(a_data.xy)-128);float a_direction=float(int(a_data.z & 3u)-1);float a_linesofar=float((a_data.z >> 2u)+a_data.w*64u)*LINE_DISTANCE_SCALE;vec2 pos=vec2(a_pos_normal >> 1);mediump vec2 normal=vec2(a_pos_normal & 1);normal.y=normal.y*2.0-1.0;v_normal=normal;gapwidth=gapwidth/2.0;float halfwidth=width/2.0;offset=-1.0*offset;float inset=gapwidth+(gapwidth > 0.0 ? ANTIALIASING : 0.0);float outset=gapwidth+halfwidth*(gapwidth > 0.0 ? 2.0 : 1.0)+(halfwidth==0.0 ? 0.0 : ANTIALIASING);mediump vec2 dist=outset*a_extrude*scale;mediump float u=0.5*a_direction;mediump float t=1.0-abs(u);mediump vec2 offset2=offset*a_extrude*scale*normal.y*mat2(t,-u,u,t);float adjustedThickness=projectLineThickness(pos.y);vec4 projected_no_extrude=projectTile(pos+offset2/u_ratio*adjustedThickness+u_translation);vec4 projected_with_extrude=projectTile(pos+offset2/u_ratio*adjustedThickness+u_translation+dist/u_ratio*adjustedThickness);gl_Position=projected_with_extrude;\n#ifdef GLOBE\nv_depth=gl_Position.z/gl_Position.w;\n#endif\n#ifdef TERRAIN3D\nv_gamma_scale=1.0;\n#else\nfloat extrude_length_without_perspective=length(dist);float extrude_length_with_perspective=length((projected_with_extrude.xy-projected_no_extrude.xy)/projected_with_extrude.w*u_units_to_pixels);v_gamma_scale=extrude_length_without_perspective/extrude_length_with_perspective;\n#endif\nv_linesofar=a_linesofar;v_width2=vec2(outset,inset);v_width=floorwidth;}"),lineSDF:iy("uniform lowp float u_device_pixel_ratio;uniform lowp float u_lineatlas_width;uniform sampler2D u_image;uniform float u_mix;in vec2 v_normal;flat in vec2 v_width2;in vec2 v_tex_a;in vec2 v_tex_b;in float v_gamma_scale;\n#ifdef GLOBE\nin float v_depth;\n#endif\n#pragma maplibre: define highp vec4 color\n#pragma maplibre: define lowp float blur\n#pragma maplibre: define lowp float opacity\n#pragma maplibre: define mediump float width\n#pragma maplibre: define lowp float floorwidth\n#pragma maplibre: define mediump vec4 dasharray_from\n#pragma maplibre: define mediump vec4 dasharray_to\nvoid main() {\n#pragma maplibre: initialize highp vec4 color\n#pragma maplibre: initialize lowp float blur\n#pragma maplibre: initialize lowp float opacity\n#pragma maplibre: initialize mediump float width\n#pragma maplibre: initialize lowp float floorwidth\n#pragma maplibre: initialize mediump vec4 dasharray_from\n#pragma maplibre: initialize mediump vec4 dasharray_to\nclipAntimeridian();float dist=length(v_normal)*v_width2.s;float blur2=(blur+1.0/u_device_pixel_ratio)*v_gamma_scale;float alpha=clamp(min(dist-(v_width2.t-blur2),v_width2.s-dist)/blur2,0.0,1.0);float sdfdist_a=texture(u_image,v_tex_a).a;float sdfdist_b=texture(u_image,v_tex_b).a;float sdfdist=mix(sdfdist_a,sdfdist_b,u_mix);float sdfgamma=(u_lineatlas_width/256.0/u_device_pixel_ratio)/min(dasharray_from.w,dasharray_to.w);alpha*=smoothstep(0.5-sdfgamma/floorwidth,0.5+sdfgamma/floorwidth,sdfdist);fragColor=color*(alpha*opacity);\n#ifdef GLOBE\nif (v_depth > 1.0) {discard;}\n#endif\n#ifdef OVERDRAW_INSPECTOR\nfragColor=vec4(1.0);\n#endif\n}","\n#define scale 0.015873016\n#define LINE_DISTANCE_SCALE 2.0\nlayout(location=0) in ivec2 a_pos_normal;layout(location=1) in uvec4 a_data;uniform vec2 u_translation;uniform mediump float u_ratio;uniform lowp float u_device_pixel_ratio;uniform vec2 u_units_to_pixels;uniform float u_tileratio;uniform float u_crossfade_from;uniform float u_crossfade_to;uniform float u_lineatlas_height;out vec2 v_normal;flat out vec2 v_width2;out vec2 v_tex_a;out vec2 v_tex_b;out float v_gamma_scale;\n#ifdef GLOBE\nout float v_depth;\n#endif\n#pragma maplibre: define highp vec4 color\n#pragma maplibre: define lowp float blur\n#pragma maplibre: define lowp float opacity\n#pragma maplibre: define mediump float gapwidth\n#pragma maplibre: define lowp float offset\n#pragma maplibre: define mediump float width\n#pragma maplibre: define lowp float floorwidth\n#pragma maplibre: define mediump vec4 dasharray_from\n#pragma maplibre: define mediump vec4 dasharray_to\nvoid main() {\n#pragma maplibre: initialize highp vec4 color\n#pragma maplibre: initialize lowp float blur\n#pragma maplibre: initialize lowp float opacity\n#pragma maplibre: initialize mediump float gapwidth\n#pragma maplibre: initialize lowp float offset\n#pragma maplibre: initialize mediump float width\n#pragma maplibre: initialize lowp float floorwidth\n#pragma maplibre: initialize mediump vec4 dasharray_from\n#pragma maplibre: initialize mediump vec4 dasharray_to\nif (opacity < 0.01) {gl_Position=vec4(-2.0,-2.0,-2.0,1.0);return;}float ANTIALIASING=1.0/u_device_pixel_ratio/2.0;vec2 a_extrude=vec2(ivec2(a_data.xy)-128);float a_direction=float(int(a_data.z & 3u)-1);float a_linesofar=float((a_data.z >> 2u)+a_data.w*64u)*LINE_DISTANCE_SCALE;vec2 pos=vec2(a_pos_normal >> 1);mediump vec2 normal=vec2(a_pos_normal & 1);normal.y=normal.y*2.0-1.0;v_normal=normal;gapwidth=gapwidth/2.0;float halfwidth=width/2.0;offset=-1.0*offset;float inset=gapwidth+(gapwidth > 0.0 ? ANTIALIASING : 0.0);float outset=gapwidth+halfwidth*(gapwidth > 0.0 ? 2.0 : 1.0)+(halfwidth==0.0 ? 0.0 : ANTIALIASING);mediump vec2 dist=outset*a_extrude*scale;mediump float u=0.5*a_direction;mediump float t=1.0-abs(u);mediump vec2 offset2=offset*a_extrude*scale*normal.y*mat2(t,-u,u,t);float adjustedThickness=projectLineThickness(pos.y);vec4 projected_no_extrude=projectTile(pos+offset2/u_ratio*adjustedThickness+u_translation);vec4 projected_with_extrude=projectTile(pos+offset2/u_ratio*adjustedThickness+u_translation+dist/u_ratio*adjustedThickness);gl_Position=projected_with_extrude;\n#ifdef GLOBE\nv_depth=gl_Position.z/gl_Position.w;\n#endif\n#ifdef TERRAIN3D\nv_gamma_scale=1.0;\n#else\nfloat extrude_length_without_perspective=length(dist);float extrude_length_with_perspective=length((projected_with_extrude.xy-projected_no_extrude.xy)/projected_with_extrude.w*u_units_to_pixels);v_gamma_scale=extrude_length_without_perspective/extrude_length_with_perspective;\n#endif\nfloat u_patternscale_a_x=u_tileratio/dasharray_from.w/u_crossfade_from;float u_patternscale_a_y=-dasharray_from.z/2.0/u_lineatlas_height;float u_patternscale_b_x=u_tileratio/dasharray_to.w/u_crossfade_to;float u_patternscale_b_y=-dasharray_to.z/2.0/u_lineatlas_height;v_tex_a=vec2(a_linesofar*u_patternscale_a_x/floorwidth,normal.y*u_patternscale_a_y+(float(dasharray_from.y)+0.5)/u_lineatlas_height);v_tex_b=vec2(a_linesofar*u_patternscale_b_x/floorwidth,normal.y*u_patternscale_b_y+(float(dasharray_to.y)+0.5)/u_lineatlas_height);v_width2=vec2(outset,inset);}"),lineGradientSDF:iy("uniform lowp float u_device_pixel_ratio;uniform sampler2D u_image;uniform sampler2D u_image_dash;uniform float u_mix;uniform lowp float u_lineatlas_width;in vec2 v_normal;flat in vec2 v_width2;in vec2 v_tex_a;in vec2 v_tex_b;in float v_gamma_scale;in highp vec2 v_uv;\n#ifdef GLOBE\nin float v_depth;\n#endif\n#pragma maplibre: define lowp float blur\n#pragma maplibre: define lowp float opacity\n#pragma maplibre: define mediump float width\n#pragma maplibre: define lowp float floorwidth\n#pragma maplibre: define mediump vec4 dasharray_from\n#pragma maplibre: define mediump vec4 dasharray_to\nvoid main() {\n#pragma maplibre: initialize lowp float blur\n#pragma maplibre: initialize lowp float opacity\n#pragma maplibre: initialize mediump float width\n#pragma maplibre: initialize lowp float floorwidth\n#pragma maplibre: initialize mediump vec4 dasharray_from\n#pragma maplibre: initialize mediump vec4 dasharray_to\nclipAntimeridian();float dist=length(v_normal)*v_width2.s;float blur2=(blur+1.0/u_device_pixel_ratio)*v_gamma_scale;float alpha=clamp(min(dist-(v_width2.t-blur2),v_width2.s-dist)/blur2,0.0,1.0);vec4 color=texture(u_image,v_uv);float sdfdist_a=texture(u_image_dash,v_tex_a).a;float sdfdist_b=texture(u_image_dash,v_tex_b).a;float sdfdist=mix(sdfdist_a,sdfdist_b,u_mix);float sdfgamma=(u_lineatlas_width/256.0)/min(dasharray_from.w,dasharray_to.w);float dash_alpha=smoothstep(0.5-sdfgamma/floorwidth,0.5+sdfgamma/floorwidth,sdfdist);fragColor=color*(alpha*dash_alpha*opacity);\n#ifdef GLOBE\nif (v_depth > 1.0) {discard;}\n#endif\n#ifdef OVERDRAW_INSPECTOR\nfragColor=vec4(1.0);\n#endif\n}","\n#define scale 0.015873016\n#define LINE_DISTANCE_SCALE 2.0\nlayout(location=0) in ivec2 a_pos_normal;layout(location=1) in uvec4 a_data;layout(location=2) in float a_uv_x;layout(location=3) in float a_split_index;uniform vec2 u_translation;uniform mediump float u_ratio;uniform lowp float u_device_pixel_ratio;uniform vec2 u_units_to_pixels;uniform float u_image_height;uniform float u_tileratio;uniform float u_crossfade_from;uniform float u_crossfade_to;uniform float u_lineatlas_height;out vec2 v_normal;flat out vec2 v_width2;out float v_gamma_scale;out highp vec2 v_uv;out vec2 v_tex_a;out vec2 v_tex_b;\n#ifdef GLOBE\nout float v_depth;\n#endif\n#pragma maplibre: define lowp float blur\n#pragma maplibre: define lowp float opacity\n#pragma maplibre: define mediump float gapwidth\n#pragma maplibre: define lowp float offset\n#pragma maplibre: define mediump float width\n#pragma maplibre: define lowp float floorwidth\n#pragma maplibre: define mediump vec4 dasharray_from\n#pragma maplibre: define mediump vec4 dasharray_to\nvoid main() {\n#pragma maplibre: initialize lowp float blur\n#pragma maplibre: initialize lowp float opacity\n#pragma maplibre: initialize mediump float gapwidth\n#pragma maplibre: initialize lowp float offset\n#pragma maplibre: initialize mediump float width\n#pragma maplibre: initialize lowp float floorwidth\n#pragma maplibre: initialize mediump vec4 dasharray_from\n#pragma maplibre: initialize mediump vec4 dasharray_to\nif (opacity < 0.01) {gl_Position=vec4(-2.0,-2.0,-2.0,1.0);return;}float ANTIALIASING=1.0/u_device_pixel_ratio/2.0;vec2 a_extrude=vec2(ivec2(a_data.xy)-128);float a_direction=float(int(a_data.z & 3u)-1);float a_linesofar=float((a_data.z >> 2u)+a_data.w*64u)*LINE_DISTANCE_SCALE;float texel_height=1.0/u_image_height;float half_texel_height=0.5*texel_height;v_uv=vec2(a_uv_x,a_split_index*texel_height-half_texel_height);vec2 pos=vec2(a_pos_normal >> 1);mediump vec2 normal=vec2(a_pos_normal & 1);normal.y=normal.y*2.0-1.0;v_normal=normal;gapwidth=gapwidth/2.0;float halfwidth=width/2.0;offset=-1.0*offset;float inset=gapwidth+(gapwidth > 0.0 ? ANTIALIASING : 0.0);float outset=gapwidth+halfwidth*(gapwidth > 0.0 ? 2.0 : 1.0)+(halfwidth==0.0 ? 0.0 : ANTIALIASING);mediump vec2 dist=outset*a_extrude*scale;mediump float u=0.5*a_direction;mediump float t=1.0-abs(u);mediump vec2 offset2=offset*a_extrude*scale*normal.y*mat2(t,-u,u,t);float adjustedThickness=projectLineThickness(pos.y);vec4 projected_no_extrude=projectTile(pos+offset2/u_ratio*adjustedThickness+u_translation);vec4 projected_with_extrude=projectTile(pos+offset2/u_ratio*adjustedThickness+u_translation+dist/u_ratio*adjustedThickness);gl_Position=projected_with_extrude;\n#ifdef GLOBE\nv_depth=gl_Position.z/gl_Position.w;\n#endif\n#ifdef TERRAIN3D\nv_gamma_scale=1.0;\n#else\nfloat extrude_length_without_perspective=length(dist);float extrude_length_with_perspective=length((projected_with_extrude.xy-projected_no_extrude.xy)/projected_with_extrude.w*u_units_to_pixels);v_gamma_scale=extrude_length_without_perspective/extrude_length_with_perspective;\n#endif\nfloat u_patternscale_a_x=u_tileratio/dasharray_from.w/u_crossfade_from;float u_patternscale_a_y=-dasharray_from.z/2.0/u_lineatlas_height;float u_patternscale_b_x=u_tileratio/dasharray_to.w/u_crossfade_to;float u_patternscale_b_y=-dasharray_to.z/2.0/u_lineatlas_height;v_tex_a=vec2(a_linesofar*u_patternscale_a_x/floorwidth,normal.y*u_patternscale_a_y+(float(dasharray_from.y)+0.5)/u_lineatlas_height);v_tex_b=vec2(a_linesofar*u_patternscale_b_x/floorwidth,normal.y*u_patternscale_b_y+(float(dasharray_to.y)+0.5)/u_lineatlas_height);v_width2=vec2(outset,inset);}"),layerOpacity:iy("uniform sampler2D u_image;uniform float u_opacity;in vec2 v_pos;void main() {fragColor=texture(u_image,v_pos)*u_opacity;\n#ifdef OVERDRAW_INSPECTOR\nfragColor=vec4(0.0);\n#endif\n}","layout(location=0) in vec2 a_pos;out vec2 v_pos;void main() {gl_Position=vec4(a_pos.x*2.0-1.0,1.0-a_pos.y*2.0,0.0,1.0);v_pos.x=a_pos.x;v_pos.y=1.0-a_pos.y;}"),raster:iy("uniform float u_fade_t;uniform float u_opacity;uniform sampler2D u_image0;uniform sampler2D u_image1;in vec3 v_pos0;in vec3 v_pos1;uniform float u_brightness_low;uniform float u_brightness_high;uniform float u_saturation_factor;uniform float u_contrast_factor;uniform vec3 u_spin_weights;void main() {vec4 color0=texture(u_image0,v_pos0.xy/v_pos0.z);vec4 color1=texture(u_image1,v_pos1.xy/v_pos1.z);if (color0.a > 0.0) {color0.rgb=color0.rgb/color0.a;}if (color1.a > 0.0) {color1.rgb=color1.rgb/color1.a;}vec4 color=mix(color0,color1,u_fade_t);color.a*=u_opacity;vec3 rgb=color.rgb;rgb=vec3(dot(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);fragColor=vec4(mix(u_high_vec,u_low_vec,rgb)*color.a,color.a);\n#ifdef OVERDRAW_INSPECTOR\nfragColor=vec4(1.0);\n#endif\n}","uniform vec2 u_tl_parent;uniform float u_scale_parent;uniform float u_buffer_scale;uniform vec3 u_perspective_transform;uniform vec4 u_coords_top;uniform vec4 u_coords_bottom;layout(location=0) in vec2 a_pos;out vec3 v_pos0;out vec3 v_pos1;void main() {vec2 fractionalPos=a_pos/8192.0;vec2 position=mix(mix(u_coords_top.xy,u_coords_top.zw,fractionalPos.x),mix(u_coords_bottom.xy,u_coords_bottom.zw,fractionalPos.x),fractionalPos.y);gl_Position=projectTile(position,position);vec2 texturePos=((fractionalPos-0.5)/u_buffer_scale)+0.5;\n#ifdef GLOBE\nif (a_pos.y <-32767.5) {texturePos.y=0.0;}if (a_pos.y > 32766.5) {texturePos.y=1.0;}\n#endif\nfloat perspectiveRatio=dot(u_perspective_transform,vec3(position,1.0));v_pos0=vec3(texturePos*perspectiveRatio,perspectiveRatio);vec2 parentPos=(texturePos*u_scale_parent)+u_tl_parent;v_pos1=vec3(parentPos*perspectiveRatio,perspectiveRatio);}"),symbolIcon:iy("uniform sampler2D u_texture;in vec2 v_tex;flat in float v_total_opacity;void main() {fragColor=texture(u_texture,v_tex)*v_total_opacity;\n#ifdef OVERDRAW_INSPECTOR\nfragColor=vec4(1.0);\n#endif\n}","layout(location=0) in vec4 a_pos_offset;layout(location=1) in uvec4 a_data;layout(location=2) in vec4 a_pixeloffset;layout(location=3) in vec3 a_projected_pos;layout(location=4) in uint a_fade_opacity;uniform bool u_is_size_zoom_constant;uniform bool u_is_size_feature_constant;uniform highp float u_size_t;uniform highp float u_size;uniform highp float u_camera_to_center_distance;uniform highp float u_pitch;uniform bool u_rotate_symbol;uniform highp float u_aspect_ratio;uniform float u_fade_change;uniform mat4 u_label_plane_matrix;uniform mat4 u_coord_matrix;uniform bool u_is_text;uniform bool u_pitch_with_map;uniform vec2 u_texsize;uniform bool u_is_along_line;uniform bool u_is_variable_anchor;uniform vec2 u_translation;uniform float u_pitched_scale;uniform bool u_is_offset;out vec2 v_tex;flat out float v_total_opacity;\n#pragma maplibre: define lowp float opacity\nvoid main() {\n#pragma maplibre: initialize lowp float opacity\nvec2 a_pos=a_pos_offset.xy;vec2 a_offset=a_pos_offset.zw;vec2 a_tex=vec2(a_data.xy);vec2 a_size=vec2(a_data.zw);float a_size_min=float(a_data.z >> 1u);vec2 a_pxoffset=a_pixeloffset.xy;vec2 a_minFontScale=a_pixeloffset.zw/256.0;float ele=get_elevation(a_pos);highp float segment_angle=-a_projected_pos[2];float size;if (!u_is_size_zoom_constant && !u_is_size_feature_constant) {size=mix(a_size_min,a_size[1],u_size_t)/128.0;} else if (u_is_size_zoom_constant && !u_is_size_feature_constant) {size=a_size_min/128.0;} else {size=u_size;}vec2 translated_a_pos=a_pos+u_translation;vec4 projectedPoint=projectTileWithElevation(translated_a_pos,ele);vec2 fade_opacity=unpack_opacity(a_fade_opacity);float fade_change=fade_opacity[1] > 0.5 ? u_fade_change :-u_fade_change;float visibility=calculate_visibility(projectedPoint);v_total_opacity=opacity*max(0.0,min(visibility,fade_opacity[0]+fade_change));if (v_total_opacity < 0.1){gl_Position=vec4(-2.,-2.,-2.,1.);return;}highp float camera_to_anchor_distance=projectedPoint.w;highp float distance_ratio=u_pitch_with_map ?\ncamera_to_anchor_distance/u_camera_to_center_distance :\nu_camera_to_center_distance/camera_to_anchor_distance;highp float perspective_ratio=clamp(0.5+0.5*distance_ratio,0.0,4.0);if (!u_is_offset) {size*=perspective_ratio;}float fontScale=u_is_text ? size/24.0 : size;highp float symbol_rotation=0.0;if (u_rotate_symbol) {vec4 offsetProjectedPoint=projectTileWithElevation(translated_a_pos+vec2(1,0),ele);vec2 a=projectedPoint.xy/projectedPoint.w;vec2 b=offsetProjectedPoint.xy/offsetProjectedPoint.w;symbol_rotation=atan((b.y-a.y)/u_aspect_ratio,b.x-a.x);}highp 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);vec4 projected_pos;if (u_is_along_line || u_is_variable_anchor) {projected_pos=vec4(a_projected_pos.xy,ele,1.0);} else if (u_pitch_with_map) {projected_pos=u_label_plane_matrix*vec4(a_projected_pos.xy+u_translation,ele,1.0);} else {projected_pos=u_label_plane_matrix*projectTileWithElevation(a_projected_pos.xy+u_translation,ele);}float z=float(u_pitch_with_map)*projected_pos.z/projected_pos.w;float projectionScaling=1.0;\n#ifdef GLOBE\nif(u_pitch_with_map) {float anchor_pos_tile_y=(u_coord_matrix*vec4(projected_pos.xy/projected_pos.w,z,1.0)).y;projectionScaling=mix(projectionScaling,1.0/circumferenceRatioAtTileY(anchor_pos_tile_y)*u_pitched_scale,u_projection_transition);}\n#endif\nvec4 finalPos=u_coord_matrix*vec4(projected_pos.xy/projected_pos.w+rotation_matrix*(a_offset/32.0*max(a_minFontScale,fontScale)+a_pxoffset/16.0)*projectionScaling,z,1.0);if(u_pitch_with_map) {finalPos=projectTileWithElevation(finalPos.xy,finalPos.z);}gl_Position=finalPos;v_tex=a_tex/u_texsize;}"),symbolSDF:iy("#define SDF_PX 8.0\nuniform bool u_is_halo;uniform bool u_is_plain;uniform sampler2D u_texture;uniform highp float u_gamma_scale;uniform lowp float u_device_pixel_ratio;uniform bool u_is_text;in vec2 v_data0;in vec3 v_data1;\n#pragma maplibre: define highp vec4 fill_color\n#pragma maplibre: define highp vec4 halo_color\n#pragma maplibre: define lowp float halo_width\n#pragma maplibre: define lowp float halo_blur\nvoid main() {\n#pragma maplibre: initialize highp vec4 fill_color\n#pragma maplibre: initialize highp vec4 halo_color\n#pragma maplibre: initialize lowp float halo_width\n#pragma maplibre: initialize lowp float halo_blur\nfloat EDGE_GAMMA=0.105/u_device_pixel_ratio;vec2 tex=v_data0.xy;float gamma_scale=v_data1.x;float size=v_data1.y;float total_opacity=v_data1[2];float fontScale=u_is_text ? size/24.0 : size;highp float gamma=EDGE_GAMMA/(fontScale*u_gamma_scale);lowp float inner_edge=(256.0-64.0)/256.0;lowp float dist=texture(u_texture,tex).a;lowp vec4 color_alpha_out_text,color_alpha_out_halo;if (u_is_plain){highp float gamma_scaled=gamma*gamma_scale;highp float alpha=smoothstep(inner_edge-gamma_scaled,inner_edge+gamma_scaled,dist);color_alpha_out_text=total_opacity*alpha*fill_color;}if (u_is_halo) {float gamma_halo=(halo_blur*1.19/SDF_PX+EDGE_GAMMA)/(fontScale*u_gamma_scale);float inner_edge_halo=inner_edge+gamma_halo*gamma_scale;highp float gamma_scaled_halo=gamma_halo*gamma_scale;highp float alpha_halo=smoothstep(inner_edge_halo-gamma_scaled_halo,inner_edge_halo+gamma_scaled_halo,dist);highp float halo_edge=(6.0-halo_width/fontScale)/SDF_PX;alpha_halo= min(smoothstep(halo_edge-gamma_scaled_halo,halo_edge+gamma_scaled_halo,dist),1.0-alpha_halo);color_alpha_out_halo=total_opacity*alpha_halo*halo_color;}if (u_is_plain && u_is_halo) {fragColor=color_alpha_out_text+(1.-color_alpha_out_text.a)*color_alpha_out_halo;} else if (u_is_halo){fragColor=color_alpha_out_halo;} else {fragColor=color_alpha_out_text;}\n#ifdef OVERDRAW_INSPECTOR\nfragColor=vec4(1.0);\n#endif\n}","layout(location=0) in vec4 a_pos_offset;layout(location=1) in uvec4 a_data;layout(location=2) in vec4 a_pixeloffset;layout(location=3) in vec3 a_projected_pos;layout(location=4) in uint a_fade_opacity;uniform bool u_is_size_zoom_constant;uniform bool u_is_size_feature_constant;uniform highp float u_size_t;uniform highp float u_size;uniform mat4 u_label_plane_matrix;uniform mat4 u_coord_matrix;uniform bool u_is_text;uniform bool u_pitch_with_map;uniform bool u_is_along_line;uniform bool u_is_variable_anchor;uniform highp float u_pitch;uniform bool u_rotate_symbol;uniform highp float u_aspect_ratio;uniform highp float u_camera_to_center_distance;uniform float u_fade_change;uniform vec2 u_texsize;uniform vec2 u_translation;uniform float u_pitched_scale;uniform bool u_is_offset;out vec2 v_data0;out vec3 v_data1;\n#pragma maplibre: define highp vec4 fill_color\n#pragma maplibre: define highp vec4 halo_color\n#pragma maplibre: define lowp float opacity\n#pragma maplibre: define lowp float halo_width\n#pragma maplibre: define lowp float halo_blur\nvoid main() {\n#pragma maplibre: initialize highp vec4 fill_color\n#pragma maplibre: initialize highp vec4 halo_color\n#pragma maplibre: initialize lowp float opacity\n#pragma maplibre: initialize lowp float halo_width\n#pragma maplibre: initialize lowp float halo_blur\nvec2 a_pos=a_pos_offset.xy;vec2 a_offset=a_pos_offset.zw;vec2 a_tex=vec2(a_data.xy);vec2 a_size=vec2(a_data.zw);float a_size_min=float(a_data.z >> 1u);vec2 a_pxoffset=a_pixeloffset.xy/16.0;vec2 a_minFontScale=a_pixeloffset.zw/256.0;float ele=get_elevation(a_pos);highp float segment_angle=-a_projected_pos[2];float size;if (!u_is_size_zoom_constant && !u_is_size_feature_constant) {size=mix(a_size_min,a_size[1],u_size_t)/128.0;} else if (u_is_size_zoom_constant && !u_is_size_feature_constant) {size=a_size_min/128.0;} else {size=u_size;}vec2 translated_a_pos=a_pos+u_translation;vec4 projectedPoint=projectTileWithElevation(translated_a_pos,ele);vec2 fade_opacity=unpack_opacity(a_fade_opacity);float visibility=calculate_visibility(projectedPoint);float fade_change=fade_opacity[1] > 0.5 ? u_fade_change :-u_fade_change;float interpolated_fade_opacity=max(0.0,min(visibility,fade_opacity[0]+fade_change));float total_opacity=opacity*interpolated_fade_opacity;if (total_opacity < 0.1){gl_Position=vec4(-2.,-2.,-2.,1.);return;}highp float camera_to_anchor_distance=projectedPoint.w;highp float distance_ratio=u_pitch_with_map ?\ncamera_to_anchor_distance/u_camera_to_center_distance :\nu_camera_to_center_distance/camera_to_anchor_distance;highp float perspective_ratio=clamp(0.5+0.5*distance_ratio,0.0,4.0);if (!u_is_offset) {size*=perspective_ratio;}float fontScale=u_is_text ? size/24.0 : size;highp float symbol_rotation=0.0;if (u_rotate_symbol) {vec4 offsetProjectedPoint=projectTileWithElevation(translated_a_pos+vec2(1,0),ele);vec2 a=projectedPoint.xy/projectedPoint.w;vec2 b=offsetProjectedPoint.xy/offsetProjectedPoint.w;symbol_rotation=atan((b.y-a.y)/u_aspect_ratio,b.x-a.x);}highp 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);vec4 projected_pos;if (u_is_along_line || u_is_variable_anchor) {projected_pos=vec4(a_projected_pos.xy,ele,1.0);} else if (u_pitch_with_map) {projected_pos=u_label_plane_matrix*vec4(a_projected_pos.xy+u_translation,ele,1.0);} else {projected_pos=u_label_plane_matrix*projectTileWithElevation(a_projected_pos.xy+u_translation,ele);}float z=float(u_pitch_with_map)*projected_pos.z/projected_pos.w;float projectionScaling=1.0;\n#ifdef GLOBE\nif(u_pitch_with_map) {float anchor_pos_tile_y=(u_coord_matrix*vec4(projected_pos.xy/projected_pos.w,z,1.0)).y;projectionScaling=mix(projectionScaling,1.0/circumferenceRatioAtTileY(anchor_pos_tile_y)*u_pitched_scale,u_projection_transition);}\n#endif\nvec4 finalPos=u_coord_matrix*vec4(projected_pos.xy/projected_pos.w+rotation_matrix*(a_offset/32.0*max(a_minFontScale,fontScale)+a_pxoffset)*projectionScaling,z,1.0);if(u_pitch_with_map) {finalPos=projectTileWithElevation(finalPos.xy,finalPos.z);}float gamma_scale=finalPos.w;gl_Position=finalPos;v_data0=a_tex/u_texsize;v_data1=vec3(gamma_scale,size,total_opacity);}"),symbolTextAndIcon:iy("#define SDF_PX 8.0\n#define SDF 1.0\n#define ICON 0.0\nuniform bool u_is_halo;uniform bool u_is_text;uniform sampler2D u_texture;uniform sampler2D u_texture_icon;uniform highp float u_gamma_scale;uniform lowp float u_device_pixel_ratio;in vec4 v_data0;in vec3 v_data1;flat in float v_is_sdf;\n#pragma maplibre: define highp vec4 fill_color\n#pragma maplibre: define highp vec4 halo_color\n#pragma maplibre: define lowp float halo_width\n#pragma maplibre: define lowp float halo_blur\nvoid main() {\n#pragma maplibre: initialize highp vec4 fill_color\n#pragma maplibre: initialize highp vec4 halo_color\n#pragma maplibre: initialize lowp float halo_width\n#pragma maplibre: initialize lowp float halo_blur\nfloat total_opacity=v_data1[2];if (v_is_sdf==ICON) {vec2 tex_icon=v_data0.zw;fragColor=texture(u_texture_icon,tex_icon)*total_opacity;\n#ifdef OVERDRAW_INSPECTOR\nfragColor=vec4(1.0);\n#endif\nreturn;}vec2 tex=v_data0.xy;float EDGE_GAMMA=0.105/u_device_pixel_ratio;float gamma_scale=v_data1.x;float size=v_data1.y;float fontScale=size/24.0;highp float gamma=EDGE_GAMMA/(fontScale*u_gamma_scale);lowp float buff=(256.0-64.0)/256.0;lowp float dist=texture(u_texture,tex).a;lowp vec4 color_alpha_out,color_alpha_out_halo;if (u_is_text) {highp float gamma_scaled=gamma*gamma_scale;highp float alpha=smoothstep(buff-gamma_scaled,buff+gamma_scaled,dist);color_alpha_out=fill_color*(alpha*total_opacity);}if (u_is_halo) {highp float gamma_halo=(halo_blur*1.19/SDF_PX+EDGE_GAMMA)/(fontScale*u_gamma_scale);lowp float buff_halo=(6.0-halo_width/fontScale)/SDF_PX;highp float gamma_scaled_halo=gamma_halo*gamma_scale;highp float alpha_halo=smoothstep(buff_halo-gamma_scaled_halo,buff_halo+gamma_scaled_halo,dist);color_alpha_out_halo=halo_color*(alpha_halo*total_opacity);}if (u_is_text && u_is_halo) {fragColor=color_alpha_out+(1.-color_alpha_out.a)*color_alpha_out_halo;} else if (u_is_halo) {fragColor=color_alpha_out_halo;} else {fragColor=color_alpha_out;}\n#ifdef OVERDRAW_INSPECTOR\nfragColor=vec4(1.0);\n#endif\n}","layout(location=0) in vec4 a_pos_offset;layout(location=1) in uvec4 a_data;layout(location=2) in vec3 a_projected_pos;layout(location=3) in uint a_fade_opacity;uniform bool u_is_size_zoom_constant;uniform bool u_is_size_feature_constant;uniform highp float u_size_t;uniform highp float u_size;uniform mat4 u_label_plane_matrix;uniform mat4 u_coord_matrix;uniform bool u_is_text;uniform bool u_pitch_with_map;uniform highp float u_pitch;uniform bool u_rotate_symbol;uniform highp float u_aspect_ratio;uniform highp float u_camera_to_center_distance;uniform float u_fade_change;uniform vec2 u_texsize;uniform vec2 u_texsize_icon;uniform bool u_is_along_line;uniform bool u_is_variable_anchor;uniform vec2 u_translation;uniform float u_pitched_scale;uniform bool u_is_offset;out vec4 v_data0;out vec3 v_data1;flat out float v_is_sdf;\n#pragma maplibre: define highp vec4 fill_color\n#pragma maplibre: define highp vec4 halo_color\n#pragma maplibre: define lowp float opacity\n#pragma maplibre: define lowp float halo_width\n#pragma maplibre: define lowp float halo_blur\nvoid main() {\n#pragma maplibre: initialize highp vec4 fill_color\n#pragma maplibre: initialize highp vec4 halo_color\n#pragma maplibre: initialize lowp float opacity\n#pragma maplibre: initialize lowp float halo_width\n#pragma maplibre: initialize lowp float halo_blur\nvec2 a_pos=a_pos_offset.xy;vec2 a_offset=a_pos_offset.zw;vec2 a_tex=vec2(a_data.xy);vec2 a_size=vec2(a_data.zw);float a_size_min=float(a_data.z >> 1u);float is_sdf=float(a_data.z & 1u);float ele=get_elevation(a_pos);highp float segment_angle=-a_projected_pos[2];float size;if (!u_is_size_zoom_constant && !u_is_size_feature_constant) {size=mix(a_size_min,a_size[1],u_size_t)/128.0;} else if (u_is_size_zoom_constant && !u_is_size_feature_constant) {size=a_size_min/128.0;} else {size=u_size;}vec2 translated_a_pos=a_pos+u_translation;vec4 projectedPoint=projectTileWithElevation(translated_a_pos,ele);vec2 fade_opacity=unpack_opacity(a_fade_opacity);float visibility=calculate_visibility(projectedPoint);float fade_change=fade_opacity[1] > 0.5 ? u_fade_change :-u_fade_change;float interpolated_fade_opacity=max(0.0,min(visibility,fade_opacity[0]+fade_change));float total_opacity=opacity*interpolated_fade_opacity;if (total_opacity < 0.1){gl_Position=vec4(-2.,-2.,-2.,1.);return;}highp float camera_to_anchor_distance=projectedPoint.w;highp float distance_ratio=u_pitch_with_map ?\ncamera_to_anchor_distance/u_camera_to_center_distance :\nu_camera_to_center_distance/camera_to_anchor_distance;highp float perspective_ratio=clamp(0.5+0.5*distance_ratio,0.0,4.0);if (!u_is_offset) {size*=perspective_ratio;}float fontScale=size/24.0;highp float symbol_rotation=0.0;if (u_rotate_symbol) {vec4 offsetProjectedPoint=projectTileWithElevation(translated_a_pos+vec2(1,0),ele);vec2 a=projectedPoint.xy/projectedPoint.w;vec2 b=offsetProjectedPoint.xy/offsetProjectedPoint.w;symbol_rotation=atan((b.y-a.y)/u_aspect_ratio,b.x-a.x);}highp 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);vec4 projected_pos;if (u_is_along_line || u_is_variable_anchor) {projected_pos=vec4(a_projected_pos.xy,ele,1.0);} else if (u_pitch_with_map) {projected_pos=u_label_plane_matrix*vec4(a_projected_pos.xy+u_translation,ele,1.0);} else {projected_pos=u_label_plane_matrix*projectTileWithElevation(a_projected_pos.xy+u_translation,ele);}float z=float(u_pitch_with_map)*projected_pos.z/projected_pos.w;float projectionScaling=1.0;\n#ifdef GLOBE\nif(u_pitch_with_map && !u_is_along_line) {float anchor_pos_tile_y=(u_coord_matrix*vec4(projected_pos.xy/projected_pos.w,z,1.0)).y;projectionScaling=mix(projectionScaling,1.0/circumferenceRatioAtTileY(anchor_pos_tile_y)*u_pitched_scale,u_projection_transition);}\n#endif\nvec4 finalPos=u_coord_matrix*vec4(projected_pos.xy/projected_pos.w+rotation_matrix*(a_offset/32.0*fontScale)*projectionScaling,z,1.0);if(u_pitch_with_map) {finalPos=projectTileWithElevation(finalPos.xy,finalPos.z);}float gamma_scale=finalPos.w;gl_Position=finalPos;v_data0.xy=a_tex/u_texsize;v_data0.zw=a_tex/u_texsize_icon;v_data1=vec3(gamma_scale,size,total_opacity);v_is_sdf=is_sdf;}"),terrain:iy("uniform sampler2D u_texture;uniform vec4 u_fog_color;uniform vec4 u_horizon_color;uniform float u_fog_ground_blend;uniform float u_fog_ground_blend_opacity;uniform float u_horizon_fog_blend;uniform bool u_is_globe_mode;in vec2 v_texture_pos;in float v_fog_depth;const float gamma=2.2;vec4 gammaToLinear(vec4 color) {return pow(color,vec4(gamma));}vec4 linearToGamma(vec4 color) {return pow(color,vec4(1.0/gamma));}void main() {vec4 surface_color=texture(u_texture,vec2(v_texture_pos.x,1.0-v_texture_pos.y));if (!u_is_globe_mode && u_fog_ground_blend_opacity > 0.0 && v_fog_depth > u_fog_ground_blend) {vec4 surface_color_linear=gammaToLinear(surface_color);float blend_color=smoothstep(0.0,1.0,max((v_fog_depth-u_horizon_fog_blend)/(1.0-u_horizon_fog_blend),0.0));vec4 fog_horizon_color_linear=mix(gammaToLinear(u_fog_color),gammaToLinear(u_horizon_color),blend_color);float factor_fog=max(v_fog_depth-u_fog_ground_blend,0.0)/(1.0-u_fog_ground_blend);fragColor=linearToGamma(mix(surface_color_linear,fog_horizon_color_linear,pow(factor_fog,2.0)*u_fog_ground_blend_opacity));} else {fragColor=surface_color;}}","layout(location=0) in vec3 a_pos3d;uniform mat4 u_fog_matrix;uniform float u_ele_delta;out vec2 v_texture_pos;out float v_fog_depth;void main() {float ele=get_elevation(a_pos3d.xy);float ele_delta=a_pos3d.z==1.0 ? u_ele_delta : 0.0;v_texture_pos=a_pos3d.xy/8192.0;gl_Position=projectTileFor3D(a_pos3d.xy,ele-ele_delta);vec4 pos=u_fog_matrix*vec4(a_pos3d.xy,ele,1.0);v_fog_depth=pos.z/pos.w*0.5+0.5;}"),terrainDepth:iy("in float v_depth;const highp vec4 bitSh=vec4(256.*256.*256.,256.*256.,256.,1.);const highp vec4 bitMsk=vec4(0.,vec3(1./256.0));highp vec4 pack(highp float value) {highp vec4 comp=fract(value*bitSh);comp-=comp.xxyz*bitMsk;return comp;}void main() {fragColor=pack(v_depth);}","layout(location=0) in vec3 a_pos3d;uniform float u_ele_delta;out float v_depth;void main() {float ele=get_elevation(a_pos3d.xy);float ele_delta=a_pos3d.z==1.0 ? u_ele_delta : 0.0;gl_Position=projectTileFor3D(a_pos3d.xy,ele-ele_delta);v_depth=gl_Position.z/gl_Position.w;}"),terrainCoords:iy("precision mediump float;uniform sampler2D u_texture;uniform float u_terrain_coords_id;in vec2 v_texture_pos;void main() {vec4 rgba=texture(u_texture,v_texture_pos);fragColor=vec4(rgba.r,rgba.g,rgba.b,u_terrain_coords_id);}","layout(location=0) in vec3 a_pos3d;uniform float u_ele_delta;out vec2 v_texture_pos;void main() {float ele=get_elevation(a_pos3d.xy);float ele_delta=a_pos3d.z==1.0 ? u_ele_delta : 0.0;v_texture_pos=a_pos3d.xy/8192.0;gl_Position=projectTileFor3D(a_pos3d.xy,ele-ele_delta);}"),atmosphere:iy("#ifdef GL_ES\nprecision highp float;\n#endif\nin vec3 view_direction;uniform vec3 u_sun_pos;uniform vec3 u_globe_position;uniform float u_globe_radius;uniform float u_atmosphere_blend;/**Shader use from https:*Made some change to adapt to MapLibre Globe geometry*/const float PI=3.141592653589793;const int iSteps=5;const int jSteps=3;/*radius of the planet*/const float EARTH_RADIUS=6371e3;/*radius of the atmosphere*/const float ATMOS_RADIUS=6471e3;vec2 rsi(vec3 r0,vec3 rd,float sr) {float a=dot(rd,rd);float b=2.0*dot(rd,r0);float c=dot(r0,r0)-(sr*sr);float d=(b*b)-4.0*a*c;if (d < 0.0) return vec2(1e5,-1e5);return vec2((-b-sqrt(d))/(2.0*a),(-b+sqrt(d))/(2.0*a));}vec4 atmosphere(vec3 r,vec3 r0,vec3 pSun,float iSun,float rPlanet,float rAtmos,vec3 kRlh,float kMie,float shRlh,float shMie,float g) {pSun=normalize(pSun);r=normalize(r);vec2 p=rsi(r0,r,rAtmos);if (p.x > p.y) {return vec4(0.0,0.0,0.0,1.0);}if (p.x < 0.0) {p.x=0.0;}vec3 pos=r0+r*p.x;vec2 p2=rsi(r0,r,rPlanet);if (p2.x <=p2.y && p2.x > 0.0) {p.y=min(p.y,p2.x);}float iStepSize=(p.y-p.x)/float(iSteps);float iTime=p.x+iStepSize*0.5;vec3 totalRlh=vec3(0,0,0);vec3 totalMie=vec3(0,0,0);float iOdRlh=0.0;float iOdMie=0.0;float mu=dot(r,pSun);float mumu=mu*mu;float gg=g*g;float pRlh=3.0/(16.0*PI)*(1.0+mumu);float pMie=3.0/(8.0*PI)*((1.0-gg)*(mumu+1.0))/(pow(1.0+gg-2.0*mu*g,1.5)*(2.0+gg));for (int i=0; i < iSteps; i++) {vec3 iPos=r0+r*iTime;float iHeight=length(iPos)-rPlanet;float odStepRlh=exp(-iHeight/shRlh)*iStepSize;float odStepMie=exp(-iHeight/shMie)*iStepSize;iOdRlh+=odStepRlh;iOdMie+=odStepMie;float jStepSize=rsi(iPos,pSun,rAtmos).y/float(jSteps);float jTime=jStepSize*0.5;float jOdRlh=0.0;float jOdMie=0.0;for (int j=0; j < jSteps; j++) {vec3 jPos=iPos+pSun*jTime;float jHeight=length(jPos)-rPlanet;jOdRlh+=exp(-jHeight/shRlh)*jStepSize;jOdMie+=exp(-jHeight/shMie)*jStepSize;jTime+=jStepSize;}vec3 attn=exp(-(kMie*(iOdMie+jOdMie)+kRlh*(iOdRlh+jOdRlh)));totalRlh+=odStepRlh*attn;totalMie+=odStepMie*attn;iTime+=iStepSize;}float opacity=exp(-(length(kRlh)*length(totalRlh)+kMie*length(totalMie)));vec3 color=iSun*(pRlh*kRlh*totalRlh+pMie*kMie*totalMie);return vec4(color,opacity);}void main() {vec3 scale_camera_pos=-u_globe_position*EARTH_RADIUS/u_globe_radius;vec4 color=atmosphere(normalize(view_direction),scale_camera_pos,u_sun_pos,22.0,EARTH_RADIUS,ATMOS_RADIUS,vec3(5.5e-6,13.0e-6,22.4e-6),21e-6,8e3,1.2e3,0.758\n);color.rgb=1.0-exp(-1.0*color.rgb);color=pow(color,vec4(1.0/2.2));fragColor=vec4(color.rgb,1.0-color.a)*u_atmosphere_blend;}","layout(location=0) in vec2 a_pos;uniform mat4 u_inv_proj_matrix;out vec3 view_direction;void main() {view_direction=(u_inv_proj_matrix*vec4(a_pos,0.0,1.0)).xyz;gl_Position=vec4(a_pos,0.0,1.0);}"),sky:iy("uniform vec4 u_sky_color;uniform vec4 u_horizon_color;uniform vec2 u_horizon;uniform vec2 u_horizon_normal;uniform float u_sky_horizon_blend;uniform float u_sky_blend;void main() {float x=gl_FragCoord.x;float y=gl_FragCoord.y;float blend=(y-u_horizon.y)*u_horizon_normal.y+(x-u_horizon.x)*u_horizon_normal.x;if (blend > 0.0) {if (blend < u_sky_horizon_blend) {fragColor=mix(u_sky_color,u_horizon_color,pow(1.0-blend/u_sky_horizon_blend,2.0));} else {fragColor=u_sky_color;}}fragColor=mix(fragColor,vec4(vec3(0.0),0.0),u_sky_blend);}","layout(location=0) in vec2 a_pos;void main() {gl_Position=vec4(a_pos,1.0,1.0);}")};function iy(e,t){let i=/#pragma maplibre: ([\w]+) ([\w]+) ([\w]+) ([\w]+)/g,r=t.match(/in ([\w]+) ([\w]+)/g),a=e.match(/uniform ([\w]+) ([\w]+)([\s]*)([\w]*)/g),n=t.match(/uniform ([\w]+) ([\w]+)([\s]*)([\w]*)/g),s=n?n.concat(a):a,o=r?r.length:0,l={};return e=e.replace(i,(e,t,i,r,a)=>(l[a]=!0,"define"===t?`\n#ifndef HAS_UNIFORM_u_${a}\nin ${i} ${r} ${a};\n#else\nuniform ${i} ${r} u_${a};\n#endif\n`:`\n#ifdef HAS_UNIFORM_u_${a}\n ${i} ${r} ${a} = u_${a};\n#endif\n`)),t=t.replace(i,(e,t,i,r,a)=>{let n="float"===r?"vec2":"vec4",s=a.match(/color/)?"color":n;return l[a]?"define"===t?`\n#ifndef HAS_UNIFORM_u_${a}\nuniform lowp float u_${a}_t;\nlayout(location = ${o++}) in ${i} ${n} a_${a};\nout ${i} ${r} ${a};\n#else\nuniform ${i} ${r} u_${a};\n#endif\n`:"vec4"===s?`\n#ifndef HAS_UNIFORM_u_${a}\n ${a} = a_${a};\n#else\n ${i} ${r} ${a} = u_${a};\n#endif\n`:`\n#ifndef HAS_UNIFORM_u_${a}\n ${a} = unpack_mix_${s}(a_${a}, u_${a}_t);\n#else\n ${i} ${r} ${a} = u_${a};\n#endif\n`:"define"===t?`\n#ifndef HAS_UNIFORM_u_${a}\nuniform lowp float u_${a}_t;\nlayout(location = ${o++}) in ${i} ${n} a_${a};\n#else\nuniform ${i} ${r} u_${a};\n#endif\n`:"vec4"===s?`\n#ifndef HAS_UNIFORM_u_${a}\n ${i} ${r} ${a} = a_${a};\n#else\n ${i} ${r} ${a} = u_${a};\n#endif\n`:`\n#ifndef HAS_UNIFORM_u_${a}\n ${i} ${r} ${a} = unpack_mix_${s}(a_${a}, u_${a}_t);\n#else\n ${i} ${r} ${a} = u_${a};\n#endif\n`}),{fragmentSource:e,vertexSource:t,staticAttributes:r,staticUniforms:s}}var ry=class{constructor(e,t,i){this.vertexBuffer=e,this.indexBuffer=t,this.segments=i}destroy(){this.vertexBuffer.destroy(),this.indexBuffer.destroy(),this.segments.destroy(),this.vertexBuffer=null,this.indexBuffer=null,this.segments=null}},ay=qs([{name:"a_pos",type:"Int16",components:2}]),ny="#define PROJECTION_MERCATOR",sy="mercator",oy=class{constructor(){this._cachedMesh=null}get name(){return"mercator"}get useSubdivision(){return!1}get shaderVariantName(){return sy}get shaderDefine(){return ny}get shaderPreludeCode(){return ty.projectionMercator}get vertexShaderPreludeCode(){return ty.projectionMercator.vertexSource}get subdivisionGranularity(){return Tu.noSubdivision}get useGlobeControls(){return!1}get transitionState(){return 0}destroy(){}getMeshFromTileID(e,t,i,r,a){if(this._cachedMesh)return this._cachedMesh;let n=new Do;n.emplaceBack(0,0),n.emplaceBack(J,0),n.emplaceBack(0,J),n.emplaceBack(J,J);let s=e.createVertexBuffer(n,ay.members),o=Qo.simpleSegment(0,0,4,2),l=new Ho;l.emplaceBack(1,0,2),l.emplaceBack(1,2,3);let h=e.createIndexBuffer(l);return this._cachedMesh=new ry(s,h,o),this._cachedMesh}recalculate(){}hasTransition(){return!1}},ly=class e{constructor(e=0,t=0,i=0,r=0){if(isNaN(e)||e<0||isNaN(t)||t<0||isNaN(i)||i<0||isNaN(r)||r<0)throw Error("Invalid value for edge-insets, top, bottom, left and right must all be numbers");this.top=e,this.bottom=t,this.left=i,this.right=r}interpolate(e,t,i){return null!=t.top&&null!=e.top&&(this.top=tr.number(e.top,t.top,i)),null!=t.bottom&&null!=e.bottom&&(this.bottom=tr.number(e.bottom,t.bottom,i)),null!=t.left&&null!=e.left&&(this.left=tr.number(e.left,t.left,i)),null!=t.right&&null!=e.right&&(this.right=tr.number(e.right,t.right,i)),this}getCenter(e,t){return new u(ve((this.left+e-this.right)/2,0,e),ve((this.top+t-this.bottom)/2,0,t))}equals(e){return this.top===e.top&&this.bottom===e.bottom&&this.left===e.left&&this.right===e.right}clone(){return new e(this.top,this.bottom,this.left,this.right)}toJSON(){return{top:this.top,bottom:this.bottom,left:this.left,right:this.right}}};function hy(e,t){if(!e.renderWorldCopies||e.lngRange)return;let i=t.lng-e.center.lng;t.lng+=i>180?-360:i<-180?360:0}function uy(e){return Math.max(0,Math.floor(e))}var cy=class{constructor(e,t){this.applyConstrain=(e,t)=>null===this._constrainOverride?this._callbacks.defaultConstrain(e,t):this._constrainOverride(e,t),this._callbacks=e,this._tileSize=512,this._renderWorldCopies=void 0===t?.renderWorldCopies||!!t?.renderWorldCopies,this._minZoom=t?.minZoom||0,this._maxZoom=t?.maxZoom||22,this._minPitch=null==t?.minPitch?0:t?.minPitch,this._maxPitch=null==t?.maxPitch?60:t?.maxPitch,this._constrainOverride=t?.constrainOverride??null,this.setMaxBounds(),this._width=0,this._height=0,this._center=new Xu(0,0),this._elevation=0,this._zoom=0,this._tileZoom=uy(this._zoom),this._scale=Pe(this._zoom),this._bearingInRadians=0,this._fovInRadians=.6435011087932844,this._pitchInRadians=0,this._rollInRadians=0,this._unmodified=!0,this._edgeInsets=new ly,this._minElevationForCurrentTile=0,this._autoCalculateNearFarZ=!0}apply(e,t,i){this._constrainOverride=e.constrainOverride,this._latRange=e.latRange,this._lngRange=e.lngRange,this._width=e.width,this._height=e.height,this._center=e.center,this._elevation=e.elevation,this._minElevationForCurrentTile=e.minElevationForCurrentTile,this._zoom=e.zoom,this._tileZoom=uy(this._zoom),this._scale=Pe(this._zoom),this._bearingInRadians=e.bearingInRadians,this._fovInRadians=e.fovInRadians,this._pitchInRadians=e.pitchInRadians,this._rollInRadians=e.rollInRadians,this._unmodified=e.unmodified,this._edgeInsets=new ly(e.padding.top,e.padding.bottom,e.padding.left,e.padding.right),this._minZoom=e.minZoom,this._maxZoom=e.maxZoom,this._minPitch=e.minPitch,this._maxPitch=e.maxPitch,this._renderWorldCopies=e.renderWorldCopies,this._cameraToCenterDistance=e.cameraToCenterDistance,this._nearZ=e.nearZ,this._farZ=e.farZ,this._autoCalculateNearFarZ=!i&&e.autoCalculateNearFarZ,t&&this.constrainInternal(),this._calcMatrices()}get pixelsToClipSpaceMatrix(){return this._pixelsToClipSpaceMatrix}get clipSpaceToPixelsMatrix(){return this._clipSpaceToPixelsMatrix}get minElevationForCurrentTile(){return this._minElevationForCurrentTile}setMinElevationForCurrentTile(e){this._minElevationForCurrentTile=e}get tileSize(){return this._tileSize}get tileZoom(){return this._tileZoom}get scale(){return this._scale}get width(){return this._width}get height(){return this._height}get bearingInRadians(){return this._bearingInRadians}get lngRange(){return this._lngRange}get latRange(){return this._latRange}get pixelsToGLUnits(){return this._pixelsToGLUnits}get minZoom(){return this._minZoom}setMinZoom(e){this._minZoom!==e&&(this._minZoom=e,this.setZoom(this.applyConstrain(this._center,this.zoom).zoom))}get maxZoom(){return this._maxZoom}setMaxZoom(e){this._maxZoom!==e&&(this._maxZoom=e,this.setZoom(this.applyConstrain(this._center,this.zoom).zoom))}get minPitch(){return this._minPitch}setMinPitch(e){this._minPitch!==e&&(this._minPitch=e,this.setPitch(Math.max(this.pitch,e)))}get maxPitch(){return this._maxPitch}setMaxPitch(e){this._maxPitch!==e&&(this._maxPitch=e,this.setPitch(Math.min(this.pitch,e)))}get renderWorldCopies(){return this._renderWorldCopies}setRenderWorldCopies(e){void 0===e?e=!0:null===e&&(e=!1),this._renderWorldCopies=e}get constrainOverride(){return this._constrainOverride}setConstrainOverride(e){void 0===e&&(e=null),this._constrainOverride!==e&&(this._constrainOverride=e,this.constrainInternal(),this._calcMatrices())}get worldSize(){return this._tileSize*this._scale}get centerOffset(){return this.centerPoint._sub(this.size._div(2))}get size(){return new u(this._width,this._height)}get bearing(){return this._bearingInRadians/Math.PI*180}setBearing(e){let t=xe(e,-180,180)*Math.PI/180;this._bearingInRadians!==t&&(this._unmodified=!1,this._bearingInRadians=t,this._calcMatrices(),this._rotationMatrix=rm(),function(e,t,i){var r=t[0],a=t[1],n=t[2],s=t[3],o=Math.sin(i),l=Math.cos(i);e[0]=r*l+n*o,e[1]=a*l+s*o,e[2]=r*-o+n*l,e[3]=a*-o+s*l}(this._rotationMatrix,this._rotationMatrix,-this._bearingInRadians))}get rotationMatrix(){return this._rotationMatrix}get pitchInRadians(){return this._pitchInRadians}get pitch(){return this._pitchInRadians/Math.PI*180}setPitch(e){let t=ve(e,this.minPitch,this.maxPitch)/180*Math.PI;this._pitchInRadians!==t&&(this._unmodified=!1,this._pitchInRadians=t,this._calcMatrices())}get rollInRadians(){return this._rollInRadians}get roll(){return this._rollInRadians/Math.PI*180}setRoll(e){let t=e/180*Math.PI;this._rollInRadians!==t&&(this._unmodified=!1,this._rollInRadians=t,this._calcMatrices())}get fovInRadians(){return this._fovInRadians}get fov(){return Ue(this._fovInRadians)}setFov(e){e=ve(e,.1,150),this.fov!==e&&(this._unmodified=!1,this._fovInRadians=Ne(e),this._calcMatrices())}get zoom(){return this._zoom}setZoom(e){let t=this.applyConstrain(this._center,e).zoom;this._zoom!==t&&(this._unmodified=!1,this._zoom=t,this._tileZoom=Math.max(0,Math.floor(t)),this._scale=Pe(t),this.constrainInternal(),this._calcMatrices())}get center(){return this._center}setCenter(e){(e.lat!==this._center.lat||e.lng!==this._center.lng)&&(this._unmodified=!1,this._center=e,this.constrainInternal(),this._calcMatrices())}get elevation(){return this._elevation}setElevation(e){e!==this._elevation&&(this._elevation=e,this.constrainInternal(),this._calcMatrices())}get padding(){return this._edgeInsets.toJSON()}setPadding(e){this._edgeInsets.equals(e)||(this._unmodified=!1,this._edgeInsets.interpolate(this._edgeInsets,e,1),this._calcMatrices())}get centerPoint(){return this._edgeInsets.getCenter(this._width,this._height)}get pixelsPerMeter(){return this._pixelPerMeter}get unmodified(){return this._unmodified}get cameraToCenterDistance(){return this._cameraToCenterDistance}get nearZ(){return this._nearZ}get farZ(){return this._farZ}get autoCalculateNearFarZ(){return this._autoCalculateNearFarZ}overrideNearFarZ(e,t){this._autoCalculateNearFarZ=!1,this._nearZ=e,this._farZ=t,this._calcMatrices()}clearNearFarZOverride(){this._autoCalculateNearFarZ=!0,this._calcMatrices()}isPaddingEqual(e){return this._edgeInsets.equals(e)}interpolatePadding(e,t,i){this._unmodified=!1,this._edgeInsets.interpolate(e,t,i),this.constrainInternal(),this._calcMatrices()}resize(e,t,i=!0){this._width=e,this._height=t,i&&this.constrainInternal(),this._calcMatrices()}getMaxBounds(){return 2!==this._latRange?.length||2!==this._lngRange?.length?null:new s_([this._lngRange[0],this._latRange[0]],[this._lngRange[1],this._latRange[1]])}setMaxBounds(e){e?(this._lngRange=[e.getWest(),e.getEast()],this._latRange=[e.getSouth(),e.getNorth()],this.constrainInternal()):(this._lngRange=null,this._latRange=[-qe,qe])}getCameraQueryGeometry(e,t){if(1===t.length)return[t[0],e];{let{minX:i,minY:r,maxX:a,maxY:n}=Ou.fromPoints(t).extend(e);return[new u(i,r),new u(a,r),new u(a,n),new u(i,n),new u(i,r)]}}constrainInternal(){if(!this.center||!this._width||!this._height||this._constraining)return;this._constraining=!0;let e=this._unmodified,{center:t,zoom:i}=this.applyConstrain(this.center,this.zoom);this.setCenter(t),this.setZoom(i),this._unmodified=e,this._constraining=!1}_calcMatrices(){if(this._width&&this._height){this._pixelsToGLUnits=[2/this._width,-2/this._height];let e=_(/* @__PURE__ */new Float64Array(16));x(e,e,[this._width/2,-this._height/2,1]),v(e,e,[1,-1,0]),this._clipSpaceToPixelsMatrix=e,e=_(/* @__PURE__ */new Float64Array(16)),x(e,e,[1,-1,1]),v(e,e,[-1,-1,0]),x(e,e,[2/this._width,2/this._height,1]),this._pixelsToClipSpaceMatrix=e;let t=this.fovInRadians/2;this._cameraToCenterDistance=.5/Math.tan(t)*this._height}this._callbacks.calcMatrices()}calculateCenterFromCameraLngLatAlt(e,t,i,r){let a,n,s=void 0===i?this.bearing:i,o=r=void 0===r?this.pitch:r,{distanceToCenter:l,clampedElevation:h}=this._distanceToCenterFromAltElevationPitch(t,this.elevation,o),{x:u,y:c}=pc(o,s),p=ac.fromLngLat(e,t),d=rc(1,p.y),f=0;do{if(f+=1,f>10)break;n=l/d;let e=u*n,t=c*n;a=new ac(p.x+e,p.y+t),d=1/a.meterInMercatorCoordinateUnits()}while(Math.abs(l-n*d)>1e-12);return{center:a.toLngLat(),elevation:h,zoom:Ie(this.height/2/Math.tan(this.fovInRadians/2)/n/this.tileSize)}}recalculateZoomAndCenter(e){if(this.elevation-e===0)return;let t=1/this.worldSize,i=ec(1,this.center.lat)*this.worldSize,r=ac.fromLngLat(this.center,this.elevation),a=r.x/t,n=r.y/t,s=r.z/t,o=this.pitch,l=this.bearing,{x:h,y:u,z:c}=pc(o,l),p=this.cameraToCenterDistance,d=a+p*-h,f=n+p*-u,m=s+p*c,{distanceToCenter:_,clampedElevation:g}=this._distanceToCenterFromAltElevationPitch(m/i,e,o),y=_*i,v=new ac((d+h*y)*t,(f+u*y)*t,0).toLngLat(),x=ec(1,v.lat),b=Ie(this.height/2/Math.tan(this.fovInRadians/2)/_/x/this.tileSize);this._elevation=g,this._center=v,this.setZoom(b)}_distanceToCenterFromAltElevationPitch(e,t,i){let r,a=-Math.cos(Ne(i)),n=e-t,s=t;return a*n>=0||Math.abs(a)<.1?(r=1e4,s=e+r*a):r=-n/a,{distanceToCenter:r,clampedElevation:s}}getCameraPoint(){let e=this.pitchInRadians,t=Math.tan(e)*(this.cameraToCenterDistance||1);return this.centerPoint.add(new u(t*Math.sin(this.rollInRadians),t*Math.cos(this.rollInRadians)))}getCameraAltitude(){return Math.cos(this.pitchInRadians)*this._cameraToCenterDistance/this._pixelPerMeter+this.elevation}getCameraLngLat(){let e=ec(1,this.center.lat)*this.worldSize,t=this.cameraToCenterDistance/e;return cc(this.center,this.elevation,this.pitch,this.bearing,t).toLngLat()}getMercatorTileCoordinates(e){if(!e)return[0,0,1,1];let t=e.canonical.z>=0?1<<e.canonical.z:2**e.canonical.z;return[e.canonical.x/t,e.canonical.y/t,1/t/J,1/t/J]}},py=class e{constructor(e,t){this.min=e,this.max=t,this.center=D([],C([],this.min,this.max),.5)}quadrant(t){let i=[t%2==0,t<2],r=M(this.min),a=M(this.max);for(let e=0;e<i.length;e++)r[e]=i[e]?this.min[e]:this.center[e],a[e]=i[e]?this.center[e]:this.max[e];return a[2]=this.max[2],new e(r,a)}distanceX(e){return Math.max(Math.min(this.max[0],e[0]),this.min[0])-e[0]}distanceY(e){return Math.max(Math.min(this.max[1],e[1]),this.min[1])-e[1]}intersectsFrustum(e){let t=!0;for(let i of e.planes){let e=this.intersectsPlane(i);if(0===e)return 0;1===e&&(t=!1)}return t?2:e.aabb.min[0]>this.max[0]||e.aabb.min[1]>this.max[1]||e.aabb.min[2]>this.max[2]||e.aabb.max[0]<this.min[0]||e.aabb.max[1]<this.min[1]||e.aabb.max[2]<this.min[2]?0:1}intersectsPlane(e){let t=e[3],i=e[3];for(let r=0;r<3;r++)e[r]>0?(t+=e[r]*this.min[r],i+=e[r]*this.max[r]):(i+=e[r]*this.min[r],t+=e[r]*this.max[r]);return t>=0?2:i<0?0:1}},dy=class{distanceToTile2d(e,t,i,r){let a=r,n=a.distanceX([e,t]),s=a.distanceY([e,t]);return Math.hypot(n,s)}getWrap(e,t,i){return i}getTileBoundingVolume(e,t,i,r){let a=Math.min(0,i),n=Math.max(0,i);if(r?.terrain){let i=new kp(e.z,t,e.z,e.x,e.y),s=r.terrain.getMinMaxElevation(i);a=s.minElevation??a,n=s.maxElevation??n}let s=1<<e.z;return new py([t+e.x/s,e.y/s,a],[t+(e.x+1)/s,(e.y+1)/s,n])}allowVariableZoom(e,t){let i=ve(78.5-e.fov*(Math.abs(Math.cos(e.rollInRadians))*e.height+Math.abs(Math.sin(e.rollInRadians))*e.width)/e.height/2,0,60);return!!t.terrain||e.pitch>i}allowWorldCopies(){return!0}prepareNextFrame(){}},fy=class e{constructor(e,t,i){this.points=e,this.planes=t,this.aabb=i}static fromInvProjectionMatrix(t,i=1,r=0,a,n){let s=n?[[6,5,4],[0,1,2],[0,3,7],[2,1,5],[3,2,6],[0,4,5]]:[[0,1,2],[6,5,4],[0,3,7],[2,1,5],[3,2,6],[0,4,5]],o=2**r,l=[[-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(e=>function(e,t,i,r){let a=U([],e,t),n=1/a[3]/i*r;return function(e,t,i){return e[0]=t[0]*i[0],e[1]=t[1]*i[1],e[2]=t[2]*i[2],e[3]=t[3]*i[3],e}(a,a,[n,n,1/a[3],n])}(e,t,i,o));a&&function(e,t,i,r){let a=r?4:0,n=r?0:4,s=0,o=[],l=[];for(let c=0;c<4;c++){let t=j([],e[c+n],e[c+a]),i=E(t);D(t,t,1/i),o.push(i),l.push(t)}for(let c=0;c<4;c++){let t=he(e[c+a],l[c],i);s=null!==t&&t>=0?Math.max(s,t):Math.max(s,o[c])}let h=function(e,t){let i=[0,0,0,0];return R(i,L([],j([],e[t[0]],e[t[1]]),j([],e[t[2]],e[t[1]]))),i[3]=-k(i,e[t[0]]),i}(e,t),u=function(e,t){let i=function(e,t,i){return e[0]=t[0]*i,e[1]=t[1]*i,e[2]=t[2]*i,e[3]=t[3]*i,e}([],e,1/N(e)),r=j([],t,D([],i,k(t,i))),a=N(r);if(a>0){let e=Math.sqrt(1-i[3]*i[3]);return oe(t,C([],D([],i,-i[3]),D([],r,e/a)))}return null}(i,h);if(null!==u){let e=u/k(l[0],h);s=Math.min(s,e)}for(let c=0;c<4;c++){let t=Math.min(s,o[c]);e[c+n]=[e[c+a][0]+l[c][0]*t,e[c+a][1]+l[c][1]*t,e[c+a][2]+l[c][2]*t,1]}}(l,s[0],a,n);let h=s.map(e=>{let t=R([],L([],j([],l[e[0]],l[e[1]]),j([],l[e[2]],l[e[1]]))),i=-k(t,l[e[1]]);return t.concat(i)}),u=[1/0,1/0,1/0],c=[-1/0,-1/0,-1/0];for(let e of l)for(let t=0;t<3;t++)u[t]=Math.min(u[t],e[t]),c[t]=Math.max(c[t],e[t]);return new e(l,h,new py(u,c))}},my=class e{get pixelsToClipSpaceMatrix(){return this._helper.pixelsToClipSpaceMatrix}get clipSpaceToPixelsMatrix(){return this._helper.clipSpaceToPixelsMatrix}get pixelsToGLUnits(){return this._helper.pixelsToGLUnits}get centerOffset(){return this._helper.centerOffset}get size(){return this._helper.size}get rotationMatrix(){return this._helper.rotationMatrix}get centerPoint(){return this._helper.centerPoint}get pixelsPerMeter(){return this._helper.pixelsPerMeter}setMinZoom(e){this._helper.setMinZoom(e)}setMaxZoom(e){this._helper.setMaxZoom(e)}setMinPitch(e){this._helper.setMinPitch(e)}setMaxPitch(e){this._helper.setMaxPitch(e)}setRenderWorldCopies(e){this._helper.setRenderWorldCopies(e)}setBearing(e){this._helper.setBearing(e)}setPitch(e){this._helper.setPitch(e)}setRoll(e){this._helper.setRoll(e)}setFov(e){this._helper.setFov(e)}setZoom(e){this._helper.setZoom(e)}setCenter(e){this._helper.setCenter(e)}setElevation(e){this._helper.setElevation(e)}setMinElevationForCurrentTile(e){this._helper.setMinElevationForCurrentTile(e)}setPadding(e){this._helper.setPadding(e)}interpolatePadding(e,t,i){this._helper.interpolatePadding(e,t,i)}isPaddingEqual(e){return this._helper.isPaddingEqual(e)}resize(e,t,i=!0){this._helper.resize(e,t,i)}getMaxBounds(){return this._helper.getMaxBounds()}setMaxBounds(e){this._helper.setMaxBounds(e)}setConstrainOverride(e){this._helper.setConstrainOverride(e)}overrideNearFarZ(e,t){this._helper.overrideNearFarZ(e,t)}clearNearFarZOverride(){this._helper.clearNearFarZOverride()}getCameraQueryGeometry(e){return this._helper.getCameraQueryGeometry(this.getCameraPoint(),e)}get tileSize(){return this._helper.tileSize}get tileZoom(){return this._helper.tileZoom}get scale(){return this._helper.scale}get worldSize(){return this._helper.worldSize}get width(){return this._helper.width}get height(){return this._helper.height}get lngRange(){return this._helper.lngRange}get latRange(){return this._helper.latRange}get minZoom(){return this._helper.minZoom}get maxZoom(){return this._helper.maxZoom}get zoom(){return this._helper.zoom}get center(){return this._helper.center}get minPitch(){return this._helper.minPitch}get maxPitch(){return this._helper.maxPitch}get pitch(){return this._helper.pitch}get pitchInRadians(){return this._helper.pitchInRadians}get roll(){return this._helper.roll}get rollInRadians(){return this._helper.rollInRadians}get bearing(){return this._helper.bearing}get bearingInRadians(){return this._helper.bearingInRadians}get fov(){return this._helper.fov}get fovInRadians(){return this._helper.fovInRadians}get elevation(){return this._helper.elevation}get minElevationForCurrentTile(){return this._helper.minElevationForCurrentTile}get padding(){return this._helper.padding}get unmodified(){return this._helper.unmodified}get renderWorldCopies(){return this._helper.renderWorldCopies}get cameraToCenterDistance(){return this._helper.cameraToCenterDistance}get constrainOverride(){return this._helper.constrainOverride}get nearZ(){return this._helper.nearZ}get farZ(){return this._helper.farZ}get autoCalculateNearFarZ(){return this._helper.autoCalculateNearFarZ}setTransitionState(e){}constructor(e){this._posMatrixCache=/* @__PURE__ */new Map,this._alignedPosMatrixCache=/* @__PURE__ */new Map,this._fogMatrixCacheF32=/* @__PURE__ */new Map,this.defaultConstrain=(e,t)=>{t=ve(+t,this.minZoom,this.maxZoom);let i={center:new Xu(e.lng,e.lat),zoom:t},r=this._helper._lngRange;!this._helper._renderWorldCopies&&null===r&&(r=[-179.9999999999,179.9999999999]);let a=this.tileSize*Pe(i.zoom),n=0,s=a,o=0,l=a,h=0,c=0,{x:p,y:d}=this.size;if(this._helper._latRange){let e=this._helper._latRange;n=Qu(e[1])*a,s=Qu(e[0])*a,s-n<d&&(h=d/(s-n))}r&&(o=xe(Ju(r[0])*a,0,a),l=xe(Ju(r[1])*a,0,a),l<o&&(l+=a),l-o<p&&(c=p/(l-o)));let f,m,{x:_,y:g}=oc(a,e),y=Math.max(c||0,h||0);if(y)return i.center=lc(a,new u(c?(l+o)/2:_,h?(s+n)/2:g)).wrap(),i.zoom+=Ie(y),i;if(this._helper._latRange){let e=d/2;g-e<n&&(m=n+e),g+e>s&&(m=s-e)}if(r){let e=(o+l)/2,t=_;this._helper._renderWorldCopies&&(t=xe(_,e-a/2,e+a/2));let i=p/2;t-i<o&&(f=o+i),t+i>l&&(f=l-i)}return void 0===f&&void 0===m||(i.center=lc(a,new u(f??_,m??g)).wrap()),i},this.applyConstrain=(e,t)=>this._helper.applyConstrain(e,t),this._helper=new cy({calcMatrices:()=>this._calcMatrices(),defaultConstrain:(e,t)=>this.defaultConstrain(e,t)},e),this._coveringTilesDetailsProvider=new dy}clone(){let t=new e;return t.apply(this,!1),t}apply(e,t,i){this._helper.apply(e,t,i)}get cameraPosition(){return this._cameraPosition}get projectionMatrix(){return this._projectionMatrix}get modelViewProjectionMatrix(){return this._viewProjMatrix}get inverseProjectionMatrix(){return this._invProjMatrix}get mercatorMatrix(){return this._mercatorMatrix}getVisibleUnwrappedCoordinates(e){let t=[new Rp(0,e)];if(this._helper._renderWorldCopies){let i=this.screenPointToMercatorCoordinate(new u(0,0)),r=this.screenPointToMercatorCoordinate(new u(this._helper._width,0)),a=this.screenPointToMercatorCoordinate(new u(this._helper._width,this._helper._height)),n=this.screenPointToMercatorCoordinate(new u(0,this._helper._height)),s=Math.floor(Math.min(i.x,r.x,a.x,n.x)),o=Math.floor(Math.max(i.x,r.x,a.x,n.x));for(let l=s-1;l<=o+1;l++)0!==l&&t.push(new Rp(l,e))}return t}getCameraFrustum(){return fy.fromInvProjectionMatrix(this._invViewProjMatrix,this.worldSize)}getClippingPlane(){return null}getCoveringTilesDetailsProvider(){return this._coveringTilesDetailsProvider}recalculateZoomAndCenter(e){let t=this.screenPointToLocation(this.centerPoint,e),i=e?e.getElevationForLngLatZoom(t,this._helper._tileZoom):0;this._helper.recalculateZoomAndCenter(i)}setLocationAtPoint(e,t,i=this.elevation){let r=i-this.elevation,a=this.screenPointToMercatorCoordinateAtZ(t,r),n=this.screenPointToMercatorCoordinateAtZ(this.centerPoint,0),s=ac.fromLngLat(e),o=new ac(s.x-(a.x-n.x),s.y-(a.y-n.y));this.setCenter(o?.toLngLat()),this._helper._renderWorldCopies&&this.setCenter(this.center.wrap())}locationToScreenPoint(e,t){return t?this.coordinatePoint(ac.fromLngLat(e),t.getElevationForLngLat(e,this),this._pixelMatrix3D):this.coordinatePoint(ac.fromLngLat(e))}screenPointToLocation(e,t){return this.screenPointToMercatorCoordinate(e,t)?.toLngLat()}screenPointToLocationAtElevation(e,t){return this.screenPointToMercatorCoordinateAtZ(e,t-this.elevation)?.toLngLat()}screenPointToMercatorCoordinate(e,t){if(t){let i=t.pointCoordinate(e);if(null!=i)return i}return this.screenPointToMercatorCoordinateAtZ(e)}screenPointToMercatorCoordinateAtZ(e,t){let i=t||0,r=[e.x,e.y,0,1],a=[e.x,e.y,1,1];U(r,r,this._pixelMatrixInverse),U(a,a,this._pixelMatrixInverse);let n=r[3],s=a[3],o=r[0]/n,l=a[0]/s,h=r[1]/n,u=a[1]/s,c=r[2]/n,p=a[2]/s,d=c===p?0:(i-c)/(p-c);return new ac(tr.number(o,l,d)/this.worldSize,tr.number(h,u,d)/this.worldSize,i)}coordinatePoint(e,t=0,i=this._pixelMatrix){let r=[e.x*this.worldSize,e.y*this.worldSize,t,1];return U(r,r,i),new u(r[0]/r[3],r[1]/r[3])}getBounds(){let e=Math.max(0,this._helper._height/2-hc(this));return(new s_).extend(this.screenPointToLocation(new u(0,e))).extend(this.screenPointToLocation(new u(this._helper._width,e))).extend(this.screenPointToLocation(new u(this._helper._width,this._helper._height))).extend(this.screenPointToLocation(new u(0,this._helper._height)))}isPointOnMapSurface(e,t){return t?null!=t.pointCoordinate(e):e.y>this.height/2-hc(this)}calculatePosMatrix(e,t=!1,i=!1){let r=e.key??Lp(e.wrap,e.canonical.z,e.canonical.z,e.canonical.x,e.canonical.y),a=t?this._alignedPosMatrixCache:this._posMatrixCache;if(a.has(r)){let e=a.get(r);return i?e.f32:e.f64}let n=uc(e,this.worldSize);y(n,t?this._alignedProjMatrix:this._viewProjMatrix,n);let s={f64:n,f32:new Float32Array(n)};return a.set(r,s),i?s.f32:s.f64}calculateFogMatrix(e){let t=e.key,i=this._fogMatrixCacheF32;if(i.has(t))return i.get(t);let r=uc(e,this.worldSize);return y(r,this._fogMatrix,r),i.set(t,new Float32Array(r)),i.get(t)}calculateCenterFromCameraLngLatAlt(e,t,i,r){return this._helper.calculateCenterFromCameraLngLatAlt(e,t,i,r)}_calculateNearFarZIfNeeded(e,t,i){if(!this._helper.autoCalculateNearFarZ)return;let r=Math.min(this.elevation,this.minElevationForCurrentTile,this.getCameraAltitude()-100),a=e-r*this._helper._pixelPerMeter/Math.cos(t),n=r<0?a:e,s=Math.PI/2+this.pitchInRadians,o=Ne(this.fov)*(Math.abs(Math.cos(Ne(this.roll)))*this.height+Math.abs(Math.sin(Ne(this.roll)))*this.width)/this.height*(.5+i.y/this.height),l=Math.sin(o)*n/Math.sin(ve(Math.PI-s-o,.01,Math.PI-.01)),h=hc(this),u=Math.atan(h/this._helper.cameraToCenterDistance),c=Ne(.75),p=u>c?2*u*(.5+i.y/(2*h)):c,d=Math.sin(p)*n/Math.sin(ve(Math.PI-s-p,.01,Math.PI-.01)),f=Math.min(l,d);this._helper._farZ=1.01*(Math.cos(Math.PI/2-t)*f+n),this._helper._nearZ=this._helper._height/50}_calcMatrices(){if(!this._helper._height)return;let e=this.centerOffset,t=oc(this.worldSize,this.center),i=t.x,r=t.y;this._helper._pixelPerMeter=ec(1,this.center.lat)*this.worldSize;let a,n=Ne(Math.min(this.pitch,nc)),s=Math.max(this._helper.cameraToCenterDistance/2,this._helper.cameraToCenterDistance+this._helper._elevation*this._helper._pixelPerMeter/Math.cos(n));this._calculateNearFarZIfNeeded(s,n,e),a=/* @__PURE__ */new Float64Array(16),S(a,this.fovInRadians,this._helper._width/this._helper._height,this._helper._nearZ,this._helper._farZ),this._invProjMatrix=/* @__PURE__ */new Float64Array(16),function(e,t){e[0]=1/t[0],e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[5]=1/t[5],e[6]=0,e[7]=0,e[8]=0,e[9]=0,e[10]=0,e[11]=1/t[14],e[12]=0,e[13]=0,e[14]=-1,e[15]=t[10]/t[14]}(this._invProjMatrix,a),a[8]=2*-e.x/this._helper._width,a[9]=2*e.y/this._helper._height,this._projectionMatrix=m(a),x(a,a,[1,-1,1]),v(a,a,[0,0,-this._helper.cameraToCenterDistance]),T(a,a,-this.rollInRadians),b(a,a,this.pitchInRadians),T(a,a,-this.bearingInRadians),v(a,a,[-i,-r,0]),this._mercatorMatrix=x([],a,[this.worldSize,this.worldSize,this.worldSize]),x(a,a,[1,1,this._helper._pixelPerMeter]),this._pixelMatrix=y(/* @__PURE__ */new Float64Array(16),this.clipSpaceToPixelsMatrix,a),v(a,a,[0,0,-this.elevation]),this._viewProjMatrix=a,this._invViewProjMatrix=g([],a);let o=[0,0,-1,1];U(o,o,this._invViewProjMatrix),this._cameraPosition=[o[0]/o[3],o[1]/o[3],o[2]/o[3]],this._fogMatrix=/* @__PURE__ */new Float64Array(16),S(this._fogMatrix,this.fovInRadians,this.width/this.height,s,this._helper._farZ),this._fogMatrix[8]=2*-e.x/this.width,this._fogMatrix[9]=2*e.y/this.height,x(this._fogMatrix,this._fogMatrix,[1,-1,1]),v(this._fogMatrix,this._fogMatrix,[0,0,-this.cameraToCenterDistance]),T(this._fogMatrix,this._fogMatrix,-this.rollInRadians),b(this._fogMatrix,this._fogMatrix,this.pitchInRadians),T(this._fogMatrix,this._fogMatrix,-this.bearingInRadians),v(this._fogMatrix,this._fogMatrix,[-i,-r,0]),x(this._fogMatrix,this._fogMatrix,[1,1,this._helper._pixelPerMeter]),v(this._fogMatrix,this._fogMatrix,[0,0,-this.elevation]),this._pixelMatrix3D=y(/* @__PURE__ */new Float64Array(16),this.clipSpaceToPixelsMatrix,a);let l=this._helper._width%2/2,h=this._helper._height%2/2,u=Math.cos(this.bearingInRadians),c=Math.sin(-this.bearingInRadians),p=i-Math.round(i)+u*l+c*h,d=r-Math.round(r)+u*h+c*l,f=new Float64Array(a);if(v(f,f,[p>.5?p-1:p,d>.5?d-1:d,0]),this._alignedProjMatrix=f,a=g(/* @__PURE__ */new Float64Array(16),this._pixelMatrix),!a)throw Error("failed to invert matrix");this._pixelMatrixInverse=a,this._clearMatrixCaches()}_clearMatrixCaches(){this._posMatrixCache.clear(),this._alignedPosMatrixCache.clear(),this._fogMatrixCacheF32.clear()}maxPitchScaleFactor(){if(!this._pixelMatrixInverse)return 1;let e=this.screenPointToMercatorCoordinate(new u(0,0)),t=[e.x*this.worldSize,e.y*this.worldSize,0,1];return U(t,t,this._pixelMatrix)[3]/this._helper.cameraToCenterDistance}getCameraPoint(){return this._helper.getCameraPoint()}getCameraAltitude(){return this._helper.getCameraAltitude()}getCameraLngLat(){let e=ec(1,this.center.lat)*this.worldSize,t=this._helper.cameraToCenterDistance/e;return cc(this.center,this.elevation,this.pitch,this.bearing,t).toLngLat()}lngLatToCameraDepth(e,t){let i=ac.fromLngLat(e),r=[i.x*this.worldSize,i.y*this.worldSize,t,1];return U(r,r,this._viewProjMatrix),r[2]/r[3]}getProjectionData(e){let t,{overscaledTileID:i,aligned:r,applyTerrainMatrix:a}=e,n=this._helper.getMercatorTileCoordinates(i),s=i?this.calculatePosMatrix(i,r,!0):null;return t=i?.terrainRttPosMatrix32f&&a?i.terrainRttPosMatrix32f:s||ne(),{mainMatrix:t,tileMercatorCoords:n,clippingPlane:[0,0,0,0],projectionTransition:0,fallbackMatrix:t,clipAntimeridian:!1}}isLocationOccluded(e){return!1}getPixelScale(){return 1}getCircleRadiusCorrection(){return 1}getPitchedTextCorrection(e,t,i){return 1}transformLightDirection(e){return M(e)}getRayDirectionFromPixel(e){throw Error("Not implemented.")}projectTileCoordinates(e,t,i,r){let a,n=this.calculatePosMatrix(i);r?(a=[e,t,r(e,t),1],U(a,a,n)):(a=[e,t,0,1],Tg(a,a,n));let s=a[3];return{point:new u(a[0]/s,a[1]/s),signedDistanceFromCamera:s,isOccluded:!1}}populateCache(e){for(let t of e)this.calculatePosMatrix(t)}getProjectionDataForCustomLayer(e=!0){let t=new kp(0,0,0,0,0),i=this.getProjectionData({overscaledTileID:t,applyGlobeMatrix:e}),r=uc(t,this.worldSize);y(r,this._viewProjMatrix,r);let a=[J,J,this.worldSize/this._helper.pixelsPerMeter],n=re();return x(n,r,a),{...i,tileMercatorCoords:[0,0,1,1],fallbackMatrix:n,mainMatrix:n}}getFastPathSimpleProjectionMatrix(e){return this.calculatePosMatrix(e)}};function _y(){Re("Map cannot fit within canvas with the given bounds, padding, and/or offset.")}function gy(e){if(e.useSlerp)if(e.k<1){let t=Ze(e.startEulerAngles.roll,e.startEulerAngles.pitch,e.startEulerAngles.bearing),i=Ze(e.endEulerAngles.roll,e.endEulerAngles.pitch,e.endEulerAngles.bearing),r=/* @__PURE__ */new Float64Array(4);!function(e,t,i,r){var a,n,s,o,l=t[0],h=t[1],u=t[2],c=t[3],p=i[0],d=i[1],f=i[2],m=i[3],_=l*p+h*d+u*f+c*m;_<0&&(_=-_,p=-p,d=-d,f=-f,m=-m),1-_>1e-6?(a=Math.acos(_),n=Math.sin(a),s=Math.sin((1-r)*a)/n,o=Math.sin(r*a)/n):(s=1-r,o=r),e[0]=s*l+o*p,e[1]=s*h+o*d,e[2]=s*u+o*f,e[3]=s*c+o*m}(r,t,i,e.k);let a=function(e){let t=/* @__PURE__ */new Float64Array(9);!function(e,t){var i=t[0],r=t[1],a=t[2],n=t[3],s=i+i,o=r+r,l=a+a,h=i*s,u=r*s,c=r*o,p=a*s,d=a*o,f=a*l,m=n*s,_=n*o,g=n*l;e[0]=1-c-f,e[3]=u-g,e[6]=p+_,e[1]=u+g,e[4]=1-h-f,e[7]=d-m,e[2]=p-_,e[5]=d+m,e[8]=1-h-c}(t,e);let i,r,a=Ue(-Math.asin(ve(t[2],-1,1)));return Math.hypot(t[5],t[8])<.001?(i=0,r=-Ue(Math.atan2(t[3],t[4]))):(i=Ue(0===t[5]&&0===t[8]?0:Math.atan2(t[5],t[8])),r=Ue(0===t[1]&&0===t[0]?0:Math.atan2(t[1],t[0]))),{roll:i,pitch:a+90,bearing:r}}(r);e.tr.setRoll(a.roll),e.tr.setPitch(a.pitch),e.tr.setBearing(a.bearing)}else e.tr.setRoll(e.endEulerAngles.roll),e.tr.setPitch(e.endEulerAngles.pitch),e.tr.setBearing(e.endEulerAngles.bearing);else e.tr.setRoll(tr.number(e.startEulerAngles.roll,e.endEulerAngles.roll,e.k)),e.tr.setPitch(tr.number(e.startEulerAngles.pitch,e.endEulerAngles.pitch,e.k)),e.tr.setBearing(tr.number(e.startEulerAngles.bearing,e.endEulerAngles.bearing,e.k))}function yy(e,t,i,r,a){let n=a.padding,s=oc(a.worldSize,i.getNorthWest()),o=oc(a.worldSize,i.getNorthEast()),l=oc(a.worldSize,i.getSouthEast()),h=oc(a.worldSize,i.getSouthWest()),c=Ne(-r),p=s.rotate(c),d=o.rotate(c),f=l.rotate(c),m=h.rotate(c),_=new u(Math.max(p.x,d.x,m.x,f.x),Math.max(p.y,d.y,m.y,f.y)),g=new u(Math.min(p.x,d.x,m.x,f.x),Math.min(p.y,d.y,m.y,f.y)),y=_.sub(g),v=a.width-(n.left+n.right+t.left+t.right),x=a.height-(n.top+n.bottom+t.top+t.bottom),b=v/y.x,w=x/y.y;if(w<0||b<0)return void _y();let T=Math.min(Ie(a.scale*Math.min(b,w)),e.maxZoom),S=u.convert(e.offset),P=new u((t.left-t.right)/2,(t.top-t.bottom)/2).rotate(Ne(r)),I=S.add(P).mult(a.scale/Pe(T));return{center:lc(a.worldSize,s.add(l).div(2).sub(I)),zoom:T,bearing:r}}var vy,xy=class{get useGlobeControls(){return!1}handlePanInertia(e,t){let i=e.mag(),r=Math.abs(hc(t));return{easingOffset:e.mult(Math.min(.75*r/i,1)),easingCenter:t.center}}handleMapControlsRollPitchBearingZoom(e,t){e.bearingDelta&&t.setBearing(t.bearing+e.bearingDelta),e.pitchDelta&&t.setPitch(t.pitch+e.pitchDelta),e.rollDelta&&t.setRoll(t.roll+e.rollDelta),e.zoomDelta&&t.setZoom(t.zoom+e.zoomDelta)}handleMapControlsPan(e,t,i){e.around.distSqr(t.centerPoint)<.01||t.setLocationAtPoint(i,e.around,e.aroundElevation)}cameraForBoxAndBearing(e,t,i,r,a){return yy(e,t,i,r,a)}handleJumpToCenterZoom(e,t){let i=void 0===t.zoom?e.zoom:+t.zoom;e.zoom!==i&&e.setZoom(+t.zoom),void 0!==t.center&&e.setCenter(Xu.convert(t.center))}handleEaseTo(e,t){let i=e.zoom,r=e.padding,a={roll:e.roll,pitch:e.pitch,bearing:e.bearing},n={roll:void 0===t.roll?e.roll:t.roll,pitch:void 0===t.pitch?e.pitch:t.pitch,bearing:void 0===t.bearing?e.bearing:t.bearing},s=void 0!==t.zoom,o=!e.isPaddingEqual(t.padding),l=!1,h=s?+t.zoom:e.zoom,u=e.centerPoint.add(t.offsetAsPoint),c=e.screenPointToLocation(u),{center:p,zoom:d}=e.applyConstrain(Xu.convert(t.center||c),h??i);hy(e,p);let f=oc(e.worldSize,c),m=oc(e.worldSize,p).sub(f),_=Pe(d-i);return l=d!==i,{easeFunc:s=>{if(l&&e.setZoom(tr.number(i,d,s)),Ge(a,n)||gy({startEulerAngles:a,endEulerAngles:n,tr:e,k:s,useSlerp:a.roll!=n.roll}),o&&(e.interpolatePadding(r,t.padding,s),u=e.centerPoint.add(t.offsetAsPoint)),t.around)e.setLocationAtPoint(t.around,t.aroundPoint);else{let t=Pe(e.zoom-i),r=(d>i?Math.min(2,_):Math.max(.5,_))**(1-s),a=lc(e.worldSize,f.add(m.mult(s*r)).mult(t));e.setLocationAtPoint(e.renderWorldCopies?a.wrap():a,u)}},isZooming:l,elevationCenter:p}}handleFlyTo(e,t){let i=void 0!==t.zoom,r=e.zoom,a=e.applyConstrain(Xu.convert(t.center||t.locationAtOffset),i?+t.zoom:r),n=a.center,s=a.zoom;hy(e,n);let o=e.worldSize,l=oc(o,t.locationAtOffset),h=oc(o,n).sub(l),u=h.mag(),c=Pe(s-r),p=void 0===t.minZoom?e.minZoom:+t.minZoom,d=Math.max(p,e.minZoom),f=Math.min(d,r,s),m=e.applyConstrain(n,f).zoom;return{easeFunc:(t,i,a,u)=>{e.setZoom(1===t?s:r+Ie(i));let c=1===t?n:lc(o,l.add(h.mult(a)));e.setLocationAtPoint(e.renderWorldCopies?c.wrap():c,u)},scaleOfZoom:c,targetCenter:n,scaleOfMinZoom:Pe(m-r),pixelPathLength:u}}};function by(e,t){let i=void 0===e.granularity?1:Math.max(e.granularity,1),r=i+(e.generateBorders?2:0),a=i+(e.extendToNorthPole||e.generateBorders?1:0)+(e.extendToSouthPole||e.generateBorders?1:0),n=r+1,s=a+1,o=e.generateBorders?-1:0,l=e.generateBorders||e.extendToNorthPole?-1:0,h=i+ +!!e.generateBorders,u=i+(e.generateBorders||e.extendToSouthPole?1:0),c=n*s,p=r*a*6,d=n*s>65536;if(d&&"16bit"===t)throw Error("Granularity is too large and meshes would not fit inside 16 bit vertex indices.");let f=d||"32bit"===t,m=new Int16Array(2*c),_=0;for(let v=l;v<=u;v++)for(let t=o;t<=h;t++){let r=t/i*J;-1===t&&(r=-64),t===i+1&&(r=8256);let a=v/i*J;-1===v&&(a=e.extendToNorthPole?-32768:-64),v===i+1&&(a=e.extendToSouthPole?32767:8256),m[_++]=r,m[_++]=a}let g=f?new Uint32Array(p):new Uint16Array(p),y=0;for(let v=0;v<a;v++)for(let e=0;e<r;e++){let t=e+v*n,i=e+1+v*n,r=e+(v+1)*n,a=e+1+(v+1)*n;g[y++]=t,g[y++]=r,g[y++]=i,g[y++]=i,g[y++]=r,g[y++]=a}return{vertices:m.buffer.slice(0),indices:g.buffer.slice(0),uses32bitIndices:f}}var wy=new Tu({fill:new wu(128,2),line:new wu(512,0),tile:new wu(128,32),stencil:new wu(128,1),circle:3}),Ty=class{constructor(){this._tileMeshCache={}}get name(){return"vertical-perspective"}get transitionState(){return 1}get useSubdivision(){return!0}get shaderVariantName(){return"globe"}get shaderDefine(){return"#define GLOBE"}get shaderPreludeCode(){return ty.projectionGlobe}get vertexShaderPreludeCode(){return ty.projectionMercator.vertexSource}get subdivisionGranularity(){return wy}get useGlobeControls(){return!0}destroy(){}_getMeshKey(e){return`${e.granularity.toString(36)}_${e.generateBorders?"b":""}${e.extendToNorthPole?"n":""}${e.extendToSouthPole?"s":""}`}getMeshFromTileID(e,t,i,r,a){let n=("stencil"===a?wy.stencil:wy.tile).getGranularityForZoomLevel(t.z),s=0===t.y&&r,o=t.y===(1<<t.z)-1&&r;return this._getMesh(e,{granularity:n,generateBorders:i,extendToNorthPole:s,extendToSouthPole:o})}_getMesh(e,t){let i=this._getMeshKey(t);if(i in this._tileMeshCache)return this._tileMeshCache[i];let r=function(e,t){let i=by(t,"16bit"),r=Do.deserialize({arrayBuffer:i.vertices,length:i.vertices.byteLength/2/2}),a=Ho.deserialize({arrayBuffer:i.indices,length:i.indices.byteLength/2/3});return new ry(e.createVertexBuffer(r,ay.members),e.createIndexBuffer(a),Qo.simpleSegment(0,0,r.length,a.length))}(e,t);return this._tileMeshCache[i]=r,r}recalculate(e){}hasTransition(){return!1}},Sy=class extends _t{constructor(e,t){super(),this._transitionable=new ws(vy||=new Ls({type:new Cs(gt.projection.type,"type")}),"projection",t),this.setProjection(e),this._transitioning=this._transitionable.untransitioned(),this.recalculate(new ys(0)),this._mercatorProjection=new oy,this._verticalPerspectiveProjection=new Ty}get transitionState(){let e=this.properties.get("type");if("string"==typeof e&&"mercator"===e)return 0;if("string"==typeof e&&"vertical-perspective"===e)return 1;if(e instanceof Fi){if(e.from===e.to)return"mercator"===e.from?0:1;if("vertical-perspective"===e.from&&"mercator"===e.to)return 1-e.transition;if("mercator"===e.from&&"vertical-perspective"===e.to)return e.transition}return 1}get useGlobeRendering(){return this.transitionState>0}get currentProjection(){return this.useGlobeRendering?this._verticalPerspectiveProjection:this._mercatorProjection}get name(){return"globe"}get useSubdivision(){return this.currentProjection.useSubdivision}get shaderVariantName(){return this.currentProjection.shaderVariantName}get shaderDefine(){return this.currentProjection.shaderDefine}get shaderPreludeCode(){return this.currentProjection.shaderPreludeCode}get vertexShaderPreludeCode(){return this.currentProjection.vertexShaderPreludeCode}get subdivisionGranularity(){return this.currentProjection.subdivisionGranularity}get useGlobeControls(){return this.transitionState>0}destroy(){this._mercatorProjection.destroy(),this._verticalPerspectiveProjection.destroy()}getMeshFromTileID(e,t,i,r,a){return this.currentProjection.getMeshFromTileID(e,t,i,r,a)}setProjection(e){this._transitionable.setValue("type",e?.type||"mercator")}updateTransitions(e){this._transitioning=this._transitionable.transitioned(e,this._transitioning)}hasTransition(){return this._transitioning.hasTransition()||this.currentProjection.hasTransition()}recalculate(e){this.properties=this._transitioning.possiblyEvaluate(e)}};function Py(e){let t=Ey(e.worldSize,e.center.lat);return 2*Math.PI*t}function Iy(e,t,i,r,a){let n=1/(1<<a),s=t/J*n+r*n,o=de((e/J*n+i*n)*Math.PI*2+Math.PI,2*Math.PI),l=2*Math.atan(Math.exp(Math.PI-s*Math.PI*2))-.5*Math.PI,h=Math.cos(l),u=/* @__PURE__ */new Float64Array(3);return u[0]=Math.sin(o)*h,u[1]=Math.sin(l),u[2]=Math.cos(o)*h,u}function My(e){return function(e,t){let i=Math.cos(t),r=/* @__PURE__ */new Float64Array(3);return r[0]=Math.sin(e)*i,r[1]=Math.sin(t),r[2]=Math.cos(e)*i,r}(e.lng*Math.PI/180,e.lat*Math.PI/180)}function Ey(e,t){return e/(2*Math.PI)/Math.cos(t*Math.PI/180)}function Ay(e){let t=Math.asin(e[1])/Math.PI*180,i=Math.sqrt(e[0]*e[0]+e[2]*e[2]);if(i>1e-6){let r=e[0]/i,a=e[2]/i,n=Math.acos(a);return new Xu(xe((r>0?n:-n)/Math.PI*180,-180,180),t)}return new Xu(0,t)}var Cy=.98*Math.PI;function Dy(e,t){let i=e.cameraPosition,r=E(i);if(r<=1)return e.screenPointToLocation(t);let a=ie();R(a,i);let n=e.getRayDirectionFromPixel(t),s=-k(n,a),o=ie();z(o,n,a,s);let l=E(o);if(l<1e-9)return e.screenPointToLocation(t);let h=Math.atan2(l,s),u=.9*Math.asin(1/r);if(h<u)return e.screenPointToLocation(t);let c=r*Math.sin(u),p=Math.asin(ve(c,-1,1))-u,d=r*Math.cos(u)/Math.sqrt(Math.max(1-c*c,1e-12))-1,f=Cy-p,m=h-u,_=p+d*m*f/(f+d*m),g=ie();D(g,o,1/l);let y=ie();return D(y,a,Math.cos(ve(_,0,Cy))),z(y,y,g,Math.sin(ve(_,0,Cy))),R(y,y),Ay(y)}function zy(e){return Math.cos(e*Math.PI/180)}function Ry(e,t){let i=zy(e);return Ie(zy(t)/i)}function ky(e){let t=.5*e,i=Math.sin(t),r=Math.cos(t);return Math.log(i+r)-Math.log(r-i)}function Ly(e,t,i,r){let a=e.lat+i*r;if(Math.abs(i)>1){let n=e.lat+i,s=(Math.sign(n)===Math.sign(e.lat)?Math.abs(e.lat):-Math.abs(e.lat))*Math.PI/180,o=Math.abs(e.lat+i)*Math.PI/180,l=ky(s+r*(o-s)),h=ky(s),u=(l-h)/(ky(o)-h);return new Xu(e.lng+t*u,a)}return new Xu(e.lng+t*r,a)}var Fy=class{constructor(e){this._cachePrevious=/* @__PURE__ */new Map,this._cache=/* @__PURE__ */new Map,this._hadAnyChanges=!1,this._boundingVolumeFactory=e}swapBuffers(){if(!this._hadAnyChanges)return;let e=this._cachePrevious;this._cachePrevious=this._cache,this._cache=e,this._cache.clear(),this._hadAnyChanges=!1}getTileBoundingVolume(e,t,i,r){let a=`${e.z}_${e.x}_${e.y}_${r?.terrain?"t":""}_${Math.round(i)}`,n=this._cache.get(a);if(n)return n;let s=this._cachePrevious.get(a);if(s)return this._cache.set(a,s),s;let o=this._boundingVolumeFactory(e,t,i,r);return this._cache.set(a,o),this._hadAnyChanges=!0,o}},By=class e{constructor(e,t,i,r){this.min=i,this.max=r,this.points=e,this.planes=t}static fromAabb(t,i){let r=[];for(let e=0;e<8;e++)r.push([1&~e?t[0]:i[0],1==(e>>1&1)?i[1]:t[1],1==(e>>2&1)?i[2]:t[2]]);return new e(r,[[-1,0,0,i[0]],[1,0,0,-t[0]],[0,-1,0,i[1]],[0,1,0,-t[1]],[0,0,-1,i[2]],[0,0,1,-t[2]]],t,i)}static fromCenterSizeAngles(t,i,r){let a=$([],r[0],r[1],r[2]),n=F([],[i[0],0,0],a),s=F([],[0,i[1],0],a),o=F([],[0,0,i[2]],a),l=[...t],h=[...t];for(let e=0;e<8;e++)for(let i=0;i<3;i++){let r=t[i]+n[i]*(1&~e?-1:1)+s[i]*(1==(e>>1&1)?1:-1)+o[i]*(1==(e>>2&1)?1:-1);l[i]=Math.min(l[i],r),h[i]=Math.max(h[i],r)}let u=[];for(let e=0;e<8;e++){let i=[...t];C(i,i,D([],n,1&~e?-1:1)),C(i,i,D([],s,1==(e>>1&1)?1:-1)),C(i,i,D([],o,1==(e>>2&1)?1:-1)),u.push(i)}return new e(u,[[...n,-k(n,u[0])],[...s,-k(s,u[0])],[...o,-k(o,u[0])],[-n[0],-n[1],-n[2],-k(n,u[7])],[-s[0],-s[1],-s[2],-k(s,u[7])],[-o[0],-o[1],-o[2],-k(o,u[7])]],l,h)}intersectsFrustum(e){let t=!0,i=this.points.length,r=this.planes.length,a=e.planes.length,n=e.points.length;for(let s=0;s<a;s++){let r=e.planes[s],a=0;for(let e=0;e<i;e++){let t=this.points[e];r[0]*t[0]+r[1]*t[1]+r[2]*t[2]+r[3]>=0&&a++}if(0===a)return 0;a<i&&(t=!1)}if(t)return 2;for(let s=0;s<r;s++){let t=this.planes[s],i=0;for(let r=0;r<n;r++){let a=e.points[r];t[0]*a[0]+t[1]*a[1]+t[2]*a[2]+t[3]>=0&&i++}if(0===i)return 0}return 1}intersectsPlane(e){let t=this.points.length,i=0;for(let r=0;r<t;r++){let t=this.points[r];e[0]*t[0]+e[1]*t[1]+e[2]*t[2]+e[3]>=0&&i++}return i===t?2:0===i?0:1}};function Oy(e,t,i){let r=e-t;return r<0?-r:Math.max(0,r-i)}function Vy(e,t,i,r,a){let n,s=e-i;return n=s<0?Math.min(-s,1+s-a):s>a?Math.min(Math.max(s-a,0),1-s):0,Math.max(n,Oy(t,r,a))}var jy=class{constructor(){this._boundingVolumeCache=new Fy(this._computeTileBoundingVolume)}prepareNextFrame(){this._boundingVolumeCache.swapBuffers()}distanceToTile2d(e,t,i,r){let a=1<<i.z,n=1/a,s=i.x/a,o=i.y/a,l=2;return l=Math.min(l,Vy(e,t,s,o,n)),l=Math.min(l,Vy(e,t,s+.5,-o-n,n)),l=Math.min(l,Vy(e,t,s+.5,2-o-n,n)),l}getWrap(e,t,i){let r=1<<t.z,a=1/r,n=t.x/r,s=Oy(e.x,n,a),o=Oy(e.x,n-1,a),l=Oy(e.x,n+1,a),h=Math.min(s,o,l);return h===l?1:h===o?-1:0}allowVariableZoom(e,t){return U_(e,t)>4}allowWorldCopies(){return!1}getTileBoundingVolume(e,t,i,r){return this._boundingVolumeCache.getTileBoundingVolume(e,t,i,r)}_computeTileBoundingVolume(e,t,i,r){let a=Math.min(0,i),n=Math.max(0,i);if(r?.terrain){let i=new kp(e.z,t,e.z,e.x,e.y),s=r.terrain.getMinMaxElevation(i);a=s.minElevation??a,n=s.maxElevation??n}if(a/=6371008.8,n/=6371008.8,a+=1,n+=1,e.z<=0)return By.fromAabb([-n,-n,-n],[n,n,n]);if(1===e.z)return By.fromAabb([0===e.x?-n:0,0===e.y?0:-n,-n],[0===e.x?0:n,0===e.y?n:0,n]);{let t=[Iy(0,0,e.x,e.y,e.z),Iy(J,0,e.x,e.y,e.z),Iy(J,J,e.x,e.y,e.z),Iy(0,J,e.x,e.y,e.z)],i=[];for(let e of t)i.push(D([],e,n));if(n!==a)for(let e of t)i.push(D([],e,a));0===e.y&&i.push([0,1,0]),e.y===(1<<e.z)-1&&i.push([0,-1,0]);let r=[1,1,1],s=[-1,-1,-1];for(let e of i)for(let t=0;t<3;t++)r[t]=Math.min(r[t],e[t]),s[t]=Math.max(s[t],e[t]);let o=Iy(J/2,J/2,e.x,e.y,e.z),l=L([],[0,1,0],o);R(l,l);let h=L([],o,l);R(h,h);let u=L([],t[2],t[1]);R(u,u);let c=L([],t[0],t[3]);R(c,c),i.push(D([],o,n)),e.y>=(1<<e.z)/2&&i.push(D([],Iy(4096,0,e.x,e.y,e.z),n)),e.y<(1<<e.z)/2&&i.push(D([],Iy(4096,8192,e.x,e.y,e.z),n));let p=Ny(o,i),d=Ny(h,i),f=[-o[0],-o[1],-o[2],p.max],m=[o[0],o[1],o[2],-p.min],_=[-h[0],-h[1],-h[2],d.max],g=[h[0],h[1],h[2],-d.min],y=[...u,0],v=[...c,0],x=[];return 0===e.y?x.push(le(v,y,f),le(v,y,m)):x.push(le(_,y,f),le(_,y,m),le(_,v,f),le(_,v,m)),e.y===(1<<e.z)-1?x.push(le(v,y,f),le(v,y,m)):x.push(le(g,y,f),le(g,y,m),le(g,v,f),le(g,v,m)),new By(x,[f,m,_,g,y,v],r,s)}}};function Ny(e,t){let i=1/0,r=-1/0;for(let a of t){let t=k(e,a);i=Math.min(i,t),r=Math.max(r,t)}return{min:i,max:r}}var Uy=class e{get pixelsToClipSpaceMatrix(){return this._helper.pixelsToClipSpaceMatrix}get clipSpaceToPixelsMatrix(){return this._helper.clipSpaceToPixelsMatrix}get pixelsToGLUnits(){return this._helper.pixelsToGLUnits}get centerOffset(){return this._helper.centerOffset}get size(){return this._helper.size}get rotationMatrix(){return this._helper.rotationMatrix}get centerPoint(){return this._helper.centerPoint}get pixelsPerMeter(){return this._helper.pixelsPerMeter}setMinZoom(e){this._helper.setMinZoom(e)}setMaxZoom(e){this._helper.setMaxZoom(e)}setMinPitch(e){this._helper.setMinPitch(e)}setMaxPitch(e){this._helper.setMaxPitch(e)}setRenderWorldCopies(e){this._helper.setRenderWorldCopies(e)}setBearing(e){this._helper.setBearing(e)}setPitch(e){this._helper.setPitch(e)}setRoll(e){this._helper.setRoll(e)}setFov(e){this._helper.setFov(e)}setZoom(e){this._helper.setZoom(e)}setCenter(e){this._helper.setCenter(e)}setElevation(e){this._helper.setElevation(e)}setMinElevationForCurrentTile(e){this._helper.setMinElevationForCurrentTile(e)}setPadding(e){this._helper.setPadding(e)}interpolatePadding(e,t,i){this._helper.interpolatePadding(e,t,i)}isPaddingEqual(e){return this._helper.isPaddingEqual(e)}resize(e,t){this._helper.resize(e,t)}getMaxBounds(){return this._helper.getMaxBounds()}setMaxBounds(e){this._helper.setMaxBounds(e)}setConstrainOverride(e){this._helper.setConstrainOverride(e)}overrideNearFarZ(e,t){this._helper.overrideNearFarZ(e,t)}clearNearFarZOverride(){this._helper.clearNearFarZOverride()}getCameraQueryGeometry(e){return this._helper.getCameraQueryGeometry(this.getCameraPoint(),e)}get tileSize(){return this._helper.tileSize}get tileZoom(){return this._helper.tileZoom}get scale(){return this._helper.scale}get worldSize(){return this._helper.worldSize}get width(){return this._helper.width}get height(){return this._helper.height}get lngRange(){return this._helper.lngRange}get latRange(){return this._helper.latRange}get minZoom(){return this._helper.minZoom}get maxZoom(){return this._helper.maxZoom}get zoom(){return this._helper.zoom}get center(){return this._helper.center}get minPitch(){return this._helper.minPitch}get maxPitch(){return this._helper.maxPitch}get pitch(){return this._helper.pitch}get pitchInRadians(){return this._helper.pitchInRadians}get roll(){return this._helper.roll}get rollInRadians(){return this._helper.rollInRadians}get bearing(){return this._helper.bearing}get bearingInRadians(){return this._helper.bearingInRadians}get fov(){return this._helper.fov}get fovInRadians(){return this._helper.fovInRadians}get elevation(){return this._helper.elevation}get minElevationForCurrentTile(){return this._helper.minElevationForCurrentTile}get padding(){return this._helper.padding}get unmodified(){return this._helper.unmodified}get renderWorldCopies(){return this._helper.renderWorldCopies}get constrainOverride(){return this._helper.constrainOverride}get nearZ(){return this._helper.nearZ}get farZ(){return this._helper.farZ}get autoCalculateNearFarZ(){return this._helper.autoCalculateNearFarZ}setTransitionState(e){}constructor(e){this._cachedClippingPlane=te(),this._projectionMatrix=ae(),this._globeViewProjMatrix32f=ne(),this._globeViewProjMatrixF64=ae(),this._globeViewProjMatrixF64Inverted=ae(),this._globeProjMatrixInverted=ae(),this._cameraPosition=ie(),this.defaultConstrain=(e,t)=>{let i=ve(e.lat,-qe,qe),r=ve(+t,this.minZoom+Ry(0,i),this.maxZoom);return{center:new Xu(e.lng,i),zoom:r}},this.applyConstrain=(e,t)=>this._helper.applyConstrain(e,t),this._helper=new cy({calcMatrices:()=>this._calcMatrices(),defaultConstrain:(e,t)=>this.defaultConstrain(e,t)},e),this._coveringTilesDetailsProvider=new jy}clone(){let t=new e;return t.apply(this,!1),t}apply(e,t){this._helper.apply(e,t)}get projectionMatrix(){return this._projectionMatrix}get modelViewProjectionMatrix(){return this._globeViewProjMatrixF64}get inverseProjectionMatrix(){return this._globeProjMatrixInverted}get cameraPosition(){let e=ie();return e[0]=this._cameraPosition[0],e[1]=this._cameraPosition[1],e[2]=this._cameraPosition[2],e}get cameraToCenterDistance(){return this._helper.cameraToCenterDistance}getProjectionData(e){let{overscaledTileID:t,applyGlobeMatrix:i}=e,r=this._helper.getMercatorTileCoordinates(t);return{mainMatrix:this._globeViewProjMatrix32f,tileMercatorCoords:r,clippingPlane:this._cachedClippingPlane,projectionTransition:+!!i,fallbackMatrix:this._globeViewProjMatrix32f,clipAntimeridian:0===t?.canonical.z}}_computeClippingPlane(e){let t=this.pitchInRadians,i=this.cameraToCenterDistance/e,r=Math.sin(t)*i,a=Math.cos(t)*i+1,n=1/Math.sqrt(r*r+a*a)*1,s=-r,o=a,l=Math.sqrt(s*s+o*o);s/=l,o/=l;let h=[0,s,o];V(h,h,[0,0,0],-this.bearingInRadians),B(h,h,[0,0,0],-1*this.center.lat*Math.PI/180),O(h,h,[0,0,0],this.center.lng*Math.PI/180);let u=1/E(h);return D(h,h,u),[...h,-n*u]}isLocationOccluded(e){return!this.isSurfacePointVisible(My(e))}transformLightDirection(e){let t=this._helper._center.lng*Math.PI/180,i=this._helper._center.lat*Math.PI/180,r=Math.cos(i),a=[Math.sin(t)*r,Math.sin(i),Math.cos(t)*r],n=[a[2],0,-a[0]],s=[0,0,0];L(s,n,a),R(n,n),R(s,s);let o=[0,0,0];return R(o,[n[0]*e[0]+s[0]*e[1]+a[0]*e[2],n[1]*e[0]+s[1]*e[1]+a[1]*e[2],n[2]*e[0]+s[2]*e[1]+a[2]*e[2]]),o}getPixelScale(){return 1/Math.cos(this._helper._center.lat*Math.PI/180)}getCircleRadiusCorrection(){return Math.cos(this._helper._center.lat*Math.PI/180)}getPitchedTextCorrection(e,t,i){let r=sc(e,t,i.canonical),a=function(e,t){return[de(e*Math.PI*2+Math.PI,2*Math.PI),2*Math.atan(Math.exp(Math.PI-t*Math.PI*2))-.5*Math.PI]}(r.x,r.y);return this.getCircleRadiusCorrection()/Math.cos(a[1])}projectTileCoordinates(e,t,i,r){let a=i.canonical,n=Iy(e,t,a.x,a.y,a.z),s=1+(r?r(e,t):0)/Hu,o=[n[0]*s,n[1]*s,n[2]*s,1];U(o,o,this._globeViewProjMatrixF64);let l=this._cachedClippingPlane,h=l[0]*n[0]+l[1]*n[1]+l[2]*n[2]+l[3]<0;return{point:new u(o[0]/o[3],o[1]/o[3]),signedDistanceFromCamera:o[3],isOccluded:h}}_calcMatrices(){if(!this._helper._width||!this._helper._height)return;let e=Ey(this.worldSize,this.center.lat),t=re();this._helper.autoCalculateNearFarZ&&(this._helper._nearZ=.5,this._helper._farZ=this.cameraToCenterDistance+2*e),S(t,this.fovInRadians,this.width/this.height,this._helper._nearZ,this._helper._farZ);let i=this.centerOffset;t[8]=2*-i.x/this._helper._width,t[9]=2*i.y/this._helper._height,this._projectionMatrix=m(t),this._globeProjMatrixInverted=re(),g(this._globeProjMatrixInverted,t),v(t,t,[0,0,-this.cameraToCenterDistance]),T(t,t,this.rollInRadians),b(t,t,-this.pitchInRadians),T(t,t,this.bearingInRadians),v(t,t,[0,0,-e]);let r=ie();r[0]=e,r[1]=e,r[2]=e,b(t,t,this.center.lat*Math.PI/180),w(t,t,-this.center.lng*Math.PI/180),x(t,t,r),this._globeViewProjMatrixF64=t,this._globeViewProjMatrix32f=new Float32Array(t),this._globeViewProjMatrixF64Inverted=re(),g(this._globeViewProjMatrixF64Inverted,t);let a=ie();this._cameraPosition=ie(),this._cameraPosition[2]=this.cameraToCenterDistance/e,V(this._cameraPosition,this._cameraPosition,a,-this.rollInRadians),B(this._cameraPosition,this._cameraPosition,a,this.pitchInRadians),V(this._cameraPosition,this._cameraPosition,a,-this.bearingInRadians),C(this._cameraPosition,this._cameraPosition,[0,0,1]),B(this._cameraPosition,this._cameraPosition,a,-this.center.lat*Math.PI/180),O(this._cameraPosition,this._cameraPosition,a,this.center.lng*Math.PI/180),this._cachedClippingPlane=this._computeClippingPlane(e);let n=m(this._globeViewProjMatrixF64Inverted);x(n,n,[1,1,-1]),this._cachedFrustum=fy.fromInvProjectionMatrix(n,1,0,this._cachedClippingPlane,!0)}calculateFogMatrix(e){Re("calculateFogMatrix is not supported on globe projection.");let t=re();return _(t),t}getVisibleUnwrappedCoordinates(e){return[new Rp(0,e)]}getCameraFrustum(){return this._cachedFrustum}getClippingPlane(){return this._cachedClippingPlane}getCoveringTilesDetailsProvider(){return this._coveringTilesDetailsProvider}recalculateZoomAndCenter(e){e?Re("terrain is not fully supported on vertical perspective projection."):this._helper.recalculateZoomAndCenter(0)}maxPitchScaleFactor(){return 1}getCameraPoint(){return this._helper.getCameraPoint()}getCameraAltitude(){return this._helper.getCameraAltitude()}getCameraLngLat(){return this._helper.getCameraLngLat()}lngLatToCameraDepth(e,t){if(!this._globeViewProjMatrixF64)return 1;let i=My(e);D(i,i,1+t/Hu);let r=te();return U(r,[i[0],i[1],i[2],1],this._globeViewProjMatrixF64),r[2]/r[3]}populateCache(e){}getBounds(){let e=.5*this.width,t=.5*this.height,i=[new u(0,0),new u(e,0),new u(this.width,0),new u(this.width,t),new u(this.width,this.height),new u(e,this.height),new u(0,this.height),new u(0,t)],r=[];for(let u of i)r.push(this.unprojectScreenPoint(u));let a=0,n=0,s=0,o=0,l=this.center;for(let u of r){let e=ce(l.lng,u.lng),t=ce(l.lat,u.lat);e<n&&(n=e),e>a&&(a=e),t<o&&(o=t),t>s&&(s=t)}let h=[l.lng+n,l.lat+o,l.lng+a,l.lat+s];return this.isSurfacePointOnScreen([0,1,0])&&(h[3]=90,h[0]=-180,h[2]=180),this.isSurfacePointOnScreen([0,-1,0])&&(h[1]=-90,h[0]=-180,h[2]=180),new s_(h)}calculateCenterFromCameraLngLatAlt(e,t,i,r){return this._helper.calculateCenterFromCameraLngLatAlt(e,t,i,r)}setLocationAtPoint(e,t,i){let r=My(this.unprojectScreenPoint(t)),a=My(e),n=ie();!function(e){e[0]=0,e[1]=0,e[2]=0}(n);let s=ie();O(s,r,n,-this.center.lng*Math.PI/180),B(s,s,n,this.center.lat*Math.PI/180);let o=a[0]*a[0]+a[2]*a[2],l=s[0]*s[0];if(o<l)return;let h=Math.sqrt(o-l),u=-h,c=ue(a[0],a[2],s[0],h),p=ue(a[0],a[2],s[0],u),d=ie();O(d,a,n,-c);let f=ue(d[1],d[2],s[1],s[2]),m=ie();O(m,a,n,-p);let _,g,y=ue(m[1],m[2],s[1],s[2]),v=.5*Math.PI,x=f>=-v&&f<=v,b=y>=-v&&y<=v;if(x&&b){let e=this.center.lng*Math.PI/180,t=this.center.lat*Math.PI/180;pe(c,e)+pe(f,t)<pe(p,e)+pe(y,t)?(_=c,g=f):(_=p,g=y)}else if(x)_=c,g=f;else{if(!b)return;_=p,g=y}let w=_/Math.PI*180,T=g/Math.PI*180,S=this.center.lat;this.setCenter(new Xu(w,ve(T,-90,90))),this.setZoom(this.zoom+Ry(S,this.center.lat))}locationToScreenPoint(e,t){let i=My(e);return t&&D(i,i,1+t.getElevationForLngLatZoom(e,this._helper._tileZoom)/Hu),this._projectSurfacePointToScreen(i)}_projectSurfacePointToScreen(e){let t=te();return U(t,[...e,1],this._globeViewProjMatrixF64),t[0]/=t[3],t[1]/=t[3],new u((.5*t[0]+.5)*this.width,(.5*-t[1]+.5)*this.height)}screenPointToMercatorCoordinate(e,t){if(t){let i=t.pointCoordinate(e);if(i)return i}return ac.fromLngLat(this.unprojectScreenPoint(e))}screenPointToLocation(e,t){return this.screenPointToMercatorCoordinate(e,t)?.toLngLat()}screenPointToLocationAtElevation(e,t){return this.screenPointToLocation(e)}isPointOnMapSurface(e,t){let i=this._cameraPosition,r=this.getRayDirectionFromPixel(e);return!!this.rayPlanetIntersection(i,r)}getRayDirectionFromPixel(e){let t=te();t[0]=e.x/this.width*2-1,t[1]=-1*(e.y/this.height*2-1),t[2]=1,t[3]=1,U(t,t,this._globeViewProjMatrixF64Inverted),t[0]/=t[3],t[1]/=t[3],t[2]/=t[3];let i=ie();i[0]=t[0]-this._cameraPosition[0],i[1]=t[1]-this._cameraPosition[1],i[2]=t[2]-this._cameraPosition[2];let r=ie();return R(r,i),r}isSurfacePointVisible(e){let t=this._cachedClippingPlane;return t[0]*e[0]+t[1]*e[1]+t[2]*e[2]+t[3]>=0}isSurfacePointOnScreen(e){if(!this.isSurfacePointVisible(e))return!1;let t=te();return U(t,[...e,1],this._globeViewProjMatrixF64),t[0]/=t[3],t[1]/=t[3],t[2]/=t[3],t[0]>-1&&t[0]<1&&t[1]>-1&&t[1]<1&&t[2]>-1&&t[2]<1}rayPlanetIntersection(e,t){let i=k(e,t),r=ie(),a=ie();D(a,t,i),j(r,e,a);let n=1-k(r,r);if(n<0)return null;let s=k(e,e)-1,o=-i+(i<0?1:-1)*Math.sqrt(n),l=s/o,h=o;return{tMin:Math.min(l,h),tMax:Math.max(l,h)}}unprojectScreenPoint(e){let t=this._cameraPosition,i=this.getRayDirectionFromPixel(e),r=this.rayPlanetIntersection(t,i);if(r){let e=ie();C(e,t,[i[0]*r.tMin,i[1]*r.tMin,i[2]*r.tMin]);let a=ie();return R(a,e),Ay(a)}let a=this._cachedClippingPlane,n=a[0]*i[0]+a[1]*i[1]+a[2]*i[2],s=-oe(a,t)/n,o=ie();if(s>0)C(o,t,[i[0]*s,i[1]*s,i[2]*s]);else{let e=ie();C(e,t,[2*i[0],2*i[1],2*i[2]]);let r=oe(this._cachedClippingPlane,e);j(o,e,[this._cachedClippingPlane[0]*r,this._cachedClippingPlane[1]*r,this._cachedClippingPlane[2]*r])}let l=function(e){let t=ie();return t[0]=e[0]*-e[3],t[1]=e[1]*-e[3],t[2]=e[2]*-e[3],{center:t,radius:Math.sqrt(1-e[3]*e[3])}}(a);return Ay(function(e,t,i){let r=ie();j(r,i,e);let a=ie();return z(a,e,r,t/N(r)),a}(l.center,l.radius,o))}getProjectionDataForCustomLayer(e=!0){let t=this.getProjectionData({overscaledTileID:new kp(0,0,0,0,0),applyGlobeMatrix:e});return t.tileMercatorCoords=[0,0,1,1],t}getFastPathSimpleProjectionMatrix(e){}},Gy=class e{get pixelsToClipSpaceMatrix(){return this._helper.pixelsToClipSpaceMatrix}get clipSpaceToPixelsMatrix(){return this._helper.clipSpaceToPixelsMatrix}get pixelsToGLUnits(){return this._helper.pixelsToGLUnits}get centerOffset(){return this._helper.centerOffset}get size(){return this._helper.size}get rotationMatrix(){return this._helper.rotationMatrix}get centerPoint(){return this._helper.centerPoint}get pixelsPerMeter(){return this._helper.pixelsPerMeter}setMinZoom(e){this._helper.setMinZoom(e)}setMaxZoom(e){this._helper.setMaxZoom(e)}setMinPitch(e){this._helper.setMinPitch(e)}setMaxPitch(e){this._helper.setMaxPitch(e)}setRenderWorldCopies(e){this._helper.setRenderWorldCopies(e)}setBearing(e){this._helper.setBearing(e)}setPitch(e){this._helper.setPitch(e)}setRoll(e){this._helper.setRoll(e)}setFov(e){this._helper.setFov(e)}setZoom(e){this._helper.setZoom(e)}setCenter(e){this._helper.setCenter(e)}setElevation(e){this._helper.setElevation(e)}setMinElevationForCurrentTile(e){this._helper.setMinElevationForCurrentTile(e)}setPadding(e){this._helper.setPadding(e)}interpolatePadding(e,t,i){this._helper.interpolatePadding(e,t,i)}isPaddingEqual(e){return this._helper.isPaddingEqual(e)}resize(e,t,i=!0){this._helper.resize(e,t,i)}getMaxBounds(){return this._helper.getMaxBounds()}setMaxBounds(e){this._helper.setMaxBounds(e)}setConstrainOverride(e){this._helper.setConstrainOverride(e)}overrideNearFarZ(e,t){this._helper.overrideNearFarZ(e,t)}clearNearFarZOverride(){this._helper.clearNearFarZOverride()}getCameraQueryGeometry(e){return this._helper.getCameraQueryGeometry(this.getCameraPoint(),e)}get tileSize(){return this._helper.tileSize}get tileZoom(){return this._helper.tileZoom}get scale(){return this._helper.scale}get worldSize(){return this._helper.worldSize}get width(){return this._helper.width}get height(){return this._helper.height}get lngRange(){return this._helper.lngRange}get latRange(){return this._helper.latRange}get minZoom(){return this._helper.minZoom}get maxZoom(){return this._helper.maxZoom}get zoom(){return this._helper.zoom}get center(){return this._helper.center}get minPitch(){return this._helper.minPitch}get maxPitch(){return this._helper.maxPitch}get pitch(){return this._helper.pitch}get pitchInRadians(){return this._helper.pitchInRadians}get roll(){return this._helper.roll}get rollInRadians(){return this._helper.rollInRadians}get bearing(){return this._helper.bearing}get bearingInRadians(){return this._helper.bearingInRadians}get fov(){return this._helper.fov}get fovInRadians(){return this._helper.fovInRadians}get elevation(){return this._helper.elevation}get minElevationForCurrentTile(){return this._helper.minElevationForCurrentTile}get padding(){return this._helper.padding}get unmodified(){return this._helper.unmodified}get renderWorldCopies(){return this._helper.renderWorldCopies}get cameraToCenterDistance(){return this._helper.cameraToCenterDistance}get constrainOverride(){return this._helper.constrainOverride}get nearZ(){return this._helper.nearZ}get farZ(){return this._helper.farZ}get autoCalculateNearFarZ(){return this._helper.autoCalculateNearFarZ}get isGlobeRendering(){return this._globeness>0}setTransitionState(e){this._globeness=e,this._calcMatrices(),this._verticalPerspectiveTransform.getCoveringTilesDetailsProvider().prepareNextFrame(),this._mercatorTransform.getCoveringTilesDetailsProvider().prepareNextFrame()}get currentTransform(){return this.isGlobeRendering?this._verticalPerspectiveTransform:this._mercatorTransform}constructor(e){this._globeness=1,this.defaultConstrain=(e,t)=>this.currentTransform.defaultConstrain(e,t),this.applyConstrain=(e,t)=>this._helper.applyConstrain(e,t),this._helper=new cy({calcMatrices:()=>this._calcMatrices(),defaultConstrain:(e,t)=>this.defaultConstrain(e,t)},e),this._globeness=1,this._mercatorTransform=new my,this._verticalPerspectiveTransform=new Uy}clone(){let t=new e;return t._globeness=this._globeness,t.apply(this,!1),t}apply(e,t){this._helper.apply(e,t),this._mercatorTransform.apply(this,!1),this._verticalPerspectiveTransform.apply(this,!1)}get projectionMatrix(){return this.currentTransform.projectionMatrix}get modelViewProjectionMatrix(){return this.currentTransform.modelViewProjectionMatrix}get inverseProjectionMatrix(){return this.currentTransform.inverseProjectionMatrix}get cameraPosition(){return this.currentTransform.cameraPosition}getProjectionData(e){let t=this._mercatorTransform.getProjectionData(e),i=this._verticalPerspectiveTransform.getProjectionData(e);return{mainMatrix:this.isGlobeRendering?i.mainMatrix:t.mainMatrix,clippingPlane:i.clippingPlane,tileMercatorCoords:i.tileMercatorCoords,projectionTransition:e.applyGlobeMatrix?this._globeness:0,fallbackMatrix:t.fallbackMatrix,clipAntimeridian:i.clipAntimeridian}}isLocationOccluded(e){return this.currentTransform.isLocationOccluded(e)}transformLightDirection(e){return this.currentTransform.transformLightDirection(e)}getPixelScale(){return me(this._mercatorTransform.getPixelScale(),this._verticalPerspectiveTransform.getPixelScale(),this._globeness)}getCircleRadiusCorrection(){return me(this._mercatorTransform.getCircleRadiusCorrection(),this._verticalPerspectiveTransform.getCircleRadiusCorrection(),this._globeness)}getPitchedTextCorrection(e,t,i){return me(this._mercatorTransform.getPitchedTextCorrection(e,t,i),this._verticalPerspectiveTransform.getPitchedTextCorrection(e,t,i),this._globeness)}projectTileCoordinates(e,t,i,r){return this.currentTransform.projectTileCoordinates(e,t,i,r)}_calcMatrices(){!this._helper._width||!this._helper._height||(this._verticalPerspectiveTransform.apply(this,!1),this._helper._nearZ=this._verticalPerspectiveTransform.nearZ,this._helper._farZ=this._verticalPerspectiveTransform.farZ,this._mercatorTransform.apply(this,!0,this.isGlobeRendering),this._helper._nearZ=this._mercatorTransform.nearZ,this._helper._farZ=this._mercatorTransform.farZ)}calculateFogMatrix(e){return this.currentTransform.calculateFogMatrix(e)}getVisibleUnwrappedCoordinates(e){return this.currentTransform.getVisibleUnwrappedCoordinates(e)}getCameraFrustum(){return this.currentTransform.getCameraFrustum()}getClippingPlane(){return this.currentTransform.getClippingPlane()}getCoveringTilesDetailsProvider(){return this.currentTransform.getCoveringTilesDetailsProvider()}recalculateZoomAndCenter(e){this.currentTransform.recalculateZoomAndCenter(e)}maxPitchScaleFactor(){return this._mercatorTransform.maxPitchScaleFactor()}getCameraPoint(){return this._helper.getCameraPoint()}getCameraAltitude(){return this._helper.getCameraAltitude()}getCameraLngLat(){return this._helper.getCameraLngLat()}lngLatToCameraDepth(e,t){return this.currentTransform.lngLatToCameraDepth(e,t)}populateCache(e){this._mercatorTransform.populateCache(e),this._verticalPerspectiveTransform.populateCache(e)}getBounds(){return this.currentTransform.getBounds()}calculateCenterFromCameraLngLatAlt(e,t,i,r){return this._helper.calculateCenterFromCameraLngLatAlt(e,t,i,r)}setLocationAtPoint(e,t,i){if(!this.isGlobeRendering)return this._mercatorTransform.setLocationAtPoint(e,t,i),void this.apply(this._mercatorTransform,!1);this._verticalPerspectiveTransform.setLocationAtPoint(e,t,i),this.apply(this._verticalPerspectiveTransform,!1)}locationToScreenPoint(e,t){return this.currentTransform.locationToScreenPoint(e,t)}screenPointToMercatorCoordinate(e,t){return this.currentTransform.screenPointToMercatorCoordinate(e,t)}screenPointToLocation(e,t){return this.currentTransform.screenPointToLocation(e,t)}screenPointToLocationAtElevation(e,t){return this.currentTransform.screenPointToLocationAtElevation(e,t)}isPointOnMapSurface(e,t){return this.currentTransform.isPointOnMapSurface(e,t)}getRayDirectionFromPixel(e){return this._verticalPerspectiveTransform.getRayDirectionFromPixel(e)}getProjectionDataForCustomLayer(e=!0){let t=this._mercatorTransform.getProjectionDataForCustomLayer(e);if(!this.isGlobeRendering)return t;let i=this._verticalPerspectiveTransform.getProjectionDataForCustomLayer(e);return i.fallbackMatrix=t.mainMatrix,i.projectionTransition=this._globeness,i}getFastPathSimpleProjectionMatrix(e){return this.currentTransform.getFastPathSimpleProjectionMatrix(e)}},$y=class e{get useGlobeControls(){return!0}handlePanInertia(e,t){let i=function(e,t){let i=e.rotate(t.bearingInRadians),r=t.zoom+Ry(t.center.lat,0),a=me(1/zy(t.center.lat),1/zy(Math.min(Math.abs(t.center.lat),60)),fe(r,7,3,0,1)),n=function(e,t){return 360/Py({worldSize:e,center:{lat:t}})}(t.worldSize,t.center.lat);return new Xu(t.center.lng-i.x*n*a,ve(t.center.lat+i.y*n,-qe,qe))}(e,t);return Math.abs(i.lng-t.center.lng)>180&&(i.lng=t.center.lng+179.5*Math.sign(i.lng-t.center.lng)),{easingCenter:i,easingOffset:new u(0,0)}}handleMapControlsRollPitchBearingZoom(e,t){let i=e.around,r=t.screenPointToLocation(i);e.bearingDelta&&t.setBearing(t.bearing+e.bearingDelta),e.pitchDelta&&t.setPitch(t.pitch+e.pitchDelta),e.rollDelta&&t.setRoll(t.roll+e.rollDelta);let a=t.zoom;e.zoomDelta&&t.setZoom(t.zoom+e.zoomDelta);let n=t.zoom-a;if(0===n)return;let s=ce(t.center.lng,r.lng),o=s/(Math.abs(s/180)+1),l=ce(t.center.lat,r.lat),h=t.getRayDirectionFromPixel(i),u=t.cameraPosition,c=-1*k(u,h),p=ie();C(p,u,[h[0]*c,h[1]*c,h[2]*c]);let d=E(p),f=d-1,m=Math.exp(.5*-Math.max(f-.3,0)),_=fe(d,.95,.999,0,1),g=fe(Ey(t.worldSize,t.center.lat)/Math.min(t.width,t.height),.9,.5,1,.25),y=Math.min(m,me(1,g,_)),v=(1-Pe(-n))*y,x=t.center.lat,b=t.zoom,w=new Xu(t.center.lng+o*v,ve(t.center.lat+l*v,-qe,qe));t.setLocationAtPoint(r,i);let T=t.center,S=fe(Math.abs(s),45,85,0,1),P=Math.max(S,_)**.25,I=ce(T.lng,w.lng),M=ce(T.lat,w.lat);t.setCenter(new Xu(T.lng+I*P,T.lat+M*P).wrap()),t.setZoom(b+Ry(x,t.center.lat))}handleMapControlsPan(e,t,i){e.panDelta&&function(e,t,i,r,a=!0){let n=Dy(e,i),s=t;if(r)s=Dy(e,i.sub(r));else if(!e.isPointOnMapSurface(i))return;let o=My(n),l=My(s),h=function(e,t){return $(te(),-e.lng,-e.lat,t)}(e.center,e.bearing),u=L(ie(),l,o),c=Math.sqrt(k(u,u)),p=Math.acos(ve(k(l,o),-1,1))/2,d=Math.sin(p),f=c?Z(u[1]/c*d,-u[0]/c*d,u[2]/c*d,Math.cos(p)):Z(0,0,0,1),{lng:m,lat:_,bearing:g}=function(e){let t=e[0],i=e[1],r=e[2],a=e[3];return{lng:180*-Math.atan2(2*(a*t+i*r),1-2*(t*t+i*i))/Math.PI,lat:180*-Math.asin(ve(2*(a*i-r*t),-1,1))/Math.PI,bearing:180*Math.atan2(2*(a*r+t*i),1-2*(i*i+r*r))/Math.PI}}(function(e,t,i){var r=t[0],a=t[1],n=t[2],s=t[3],o=i[0],l=i[1],h=i[2],u=i[3];return e[0]=r*u+s*o+a*h-n*l,e[1]=a*u+s*l+n*o-r*h,e[2]=n*u+s*h+r*l-a*o,e[3]=s*u-r*o-a*l-n*h,e}(te(),h,f)),y=e.center.lat,v=ve(_,-90,90),x=a?function(e,t,i,r){let a=e.center.lng,n=e.center.lat,s=n>=0?90:-90,o=e.locationToScreenPoint(new Xu(0,s)),l=t.x-o.x,h=t.y-o.y,u=l*l+h*h,c=ve(1-(qe-Math.abs(n))/12,0,1),p=c*c*(3-2*c),d=de(r-a+180,360)-180,f=0;return p>0&&i&&(f=(s>0?1:-1)*((l*i.y-h*i.x)/Math.max(u,400))*180/Math.PI),a+(1-p)*d+p*f}(e,i,r,m):m;e.setCenter(new Xu(xe(x,-180,180),v)),a||e.setBearing(g),e.setZoom(e.zoom+Ry(y,e.center.lat))}(t,i,e.around,e.panDelta)}cameraForBoxAndBearing(t,i,r,a,n){let s=yy(t,i,r,a,n),o=i.left/n.width*2-1,l=(n.width-i.right)/n.width*2-1,h=i.top/n.height*-2+1,u=(n.height-i.bottom)/n.height*-2+1,c=ce(r.getWest(),r.getEast())<0,p=c?r.getEast():r.getWest(),d=c?r.getWest():r.getEast(),f=Math.max(r.getNorth(),r.getSouth()),m=Math.min(r.getNorth(),r.getSouth()),_=p+.5*ce(p,d),g=f+.5*ce(f,m),y=n.clone();y.setCenter(s.center),y.setBearing(s.bearing),y.setPitch(0),y.setRoll(0),y.setZoom(s.zoom);let v=y.modelViewProjectionMatrix,x=[My(r.getNorthWest()),My(r.getNorthEast()),My(r.getSouthWest()),My(r.getSouthEast()),My(new Xu(d,g)),My(new Xu(p,g)),My(new Xu(_,f)),My(new Xu(_,m))],b=My(s.center),w=1/0;for(let T of x)o<0&&(w=e.getLesserNonNegativeNonNull(w,e.solveVectorScale(T,b,v,"x",o))),l>0&&(w=e.getLesserNonNegativeNonNull(w,e.solveVectorScale(T,b,v,"x",l))),h>0&&(w=e.getLesserNonNegativeNonNull(w,e.solveVectorScale(T,b,v,"y",h))),u<0&&(w=e.getLesserNonNegativeNonNull(w,e.solveVectorScale(T,b,v,"y",u)));if(Number.isFinite(w)&&0!==w)return s.zoom=Math.min(y.zoom+Ie(w),t.maxZoom),s;_y()}handleJumpToCenterZoom(e,t){let i=e.center.lat,r=e.applyConstrain(t.center?Xu.convert(t.center):e.center,e.zoom).center;e.setCenter(r.wrap());let a=void 0===t.zoom?e.zoom+Ry(i,r.lat):+t.zoom;e.zoom!==a&&e.setZoom(a)}handleEaseTo(e,t){let i=e.zoom,r=e.center,a=e.padding,n={roll:e.roll,pitch:e.pitch,bearing:e.bearing},s={roll:void 0===t.roll?e.roll:t.roll,pitch:void 0===t.pitch?e.pitch:t.pitch,bearing:void 0===t.bearing?e.bearing:t.bearing},o=void 0!==t.zoom,l=!e.isPaddingEqual(t.padding),h=!1,c=t.center?Xu.convert(t.center):r,p=e.applyConstrain(c,i).center;hy(e,p);let d=e.clone();d.setCenter(p),d.setZoom(o?+t.zoom:i+Ry(r.lat,c.lat)),d.setBearing(t.bearing);let f=new u(ve(e.centerPoint.x+t.offsetAsPoint.x,0,e.width),ve(e.centerPoint.y+t.offsetAsPoint.y,0,e.height));d.setLocationAtPoint(p,f);let m=(t.offset&&t.offsetAsPoint.mag())>0?d.center:p,_=o?+t.zoom:i+Ry(r.lat,m.lat),g=i+Ry(r.lat,0),y=_+Ry(m.lat,0),v=ce(r.lng,m.lng),x=ce(r.lat,m.lat),b=Pe(y-g);return h=_!==i,{easeFunc:i=>{if(Ge(n,s)||gy({startEulerAngles:n,endEulerAngles:s,tr:e,k:i,useSlerp:n.roll!=s.roll}),l&&e.interpolatePadding(a,t.padding,i),t.around)Re("Easing around a point is not supported under globe projection."),e.setLocationAtPoint(t.around,t.aroundPoint);else{let t=i*(y>g?Math.min(2,b):Math.max(.5,b))**(1-i),a=Ly(r,v,x,t);e.setCenter(a.wrap())}if(h){let t=tr.number(g,y,i)+Ry(0,e.center.lat);e.setZoom(t)}},isZooming:h,elevationCenter:m}}handleFlyTo(e,t){let i=void 0!==t.zoom,r=e.center,a=e.zoom,n=e.padding,s=!e.isPaddingEqual(t.padding),o=e.applyConstrain(Xu.convert(t.center||t.locationAtOffset),a).center,l=i?+t.zoom:e.zoom+Ry(e.center.lat,o.lat),h=e.clone();h.setCenter(o),h.setZoom(l),h.setBearing(t.bearing);let c=new u(ve(e.centerPoint.x+t.offsetAsPoint.x,0,e.width),ve(e.centerPoint.y+t.offsetAsPoint.y,0,e.height));h.setLocationAtPoint(o,c);let p=h.center;hy(e,p);let d=function(e,t,i){let r=k(My(t),My(i)),a=Math.acos(r),n=Py(e);return a/(2*Math.PI)*n}(e,r,p),f=a+Ry(r.lat,0),m=l+Ry(p.lat,0),_=Pe(m-f),g="number"==typeof t.minZoom?+t.minZoom:e.minZoom,y=Math.max(g,e.minZoom)+Ry(p.lat,0),v=Math.min(y,f,m)+Ry(0,p.lat),x=Pe(e.applyConstrain(p,v).zoom+Ry(p.lat,0)-f),b=ce(r.lng,p.lng),w=ce(r.lat,p.lat);return{easeFunc:(i,a,o,h)=>{let u=Ly(r,b,w,o);s&&e.interpolatePadding(n,t.padding,i);let c=1===i?p:u;e.setCenter(c.wrap());let d=f+Ie(a);e.setZoom(1===i?l:d+Ry(0,c.lat))},scaleOfZoom:_,targetCenter:p,scaleOfMinZoom:x,pixelPathLength:d}}static solveVectorScale(e,t,i,r,a){let n=a,s="x"===r?[i[0],i[4],i[8],i[12]]:[i[1],i[5],i[9],i[13]],o=[i[3],i[7],i[11],i[15]],l=e[0]*s[0]+e[1]*s[1]+e[2]*s[2],h=e[0]*o[0]+e[1]*o[1]+e[2]*o[2],u=t[0]*s[0]+t[1]*s[1]+t[2]*s[2],c=t[0]*o[0]+t[1]*o[1]+t[2]*o[2];return u+n*h===l+n*c||o[3]*(l-u)+s[3]*(c-h)+l*c===u*h?null:(u+s[3]-n*c-n*o[3])/(u-l-n*c+n*h)}static getLesserNonNegativeNonNull(e,t){return null!==t&&t>=0&&t<e?t:e}},Zy=class{constructor(e){this._globe=e,this._mercatorCameraHelper=new xy,this._verticalPerspectiveCameraHelper=new $y}get useGlobeControls(){return this._globe.useGlobeRendering}get currentHelper(){return this.useGlobeControls?this._verticalPerspectiveCameraHelper:this._mercatorCameraHelper}handlePanInertia(e,t){return this.currentHelper.handlePanInertia(e,t)}handleMapControlsRollPitchBearingZoom(e,t){this.currentHelper.handleMapControlsRollPitchBearingZoom(e,t)}handleMapControlsPan(e,t,i){this.currentHelper.handleMapControlsPan(e,t,i)}cameraForBoxAndBearing(e,t,i,r,a){return this.currentHelper.cameraForBoxAndBearing(e,t,i,r,a)}handleJumpToCenterZoom(e,t){this.currentHelper.handleJumpToCenterZoom(e,t)}handleEaseTo(e,t){return this.currentHelper.handleEaseTo(e,t)}handleFlyTo(e,t){return this.currentHelper.handleFlyTo(e,t)}},qy=function(){let e={},t=gt.$version;for(let i in gt.$root){let r=gt.$root[i];if(r.required){let a=null;a="version"===i?t:"array"===r.type?[]:{},null!=a&&(e[i]=a)}}return e}(),Wy=class extends _t{constructor(e,t={}){super(),this._rtlPluginLoaded=()=>{for(let e in this.tileManagers){let t=this.tileManagers[e].getSource().type;("vector"===t||"geojson"===t)&&this.tileManagers[e].reload()}},this.map=e,this.dispatcher=new Qm(Xm(),e._getMapId()),this.dispatcher.registerMessageHandler("GG",(e,t)=>this.getGlyphs(e,t)),this.dispatcher.registerMessageHandler("GI",(e,t)=>this.getImages(e,t)),this.dispatcher.registerMessageHandler("GDA",(e,t)=>this.getDashes(e,t)),this.imageManager=new Em,this.imageManager.setEventedParent(this),this.imageManager.setMissingImageResolver(e._missingStyleImageResolver),this.patternAtlas=new Am(this.imageManager);let i=e._container?.lang||typeof document<"u"&&document.documentElement?.lang||void 0;this.glyphManager=new Vm(e._requestManager,t.localIdeographFontFamily,i),this.lineAtlas=new Um(256,512),this.crossTileSymbolIndex=new Qg,this._setInitialValues(),this._resetUpdates(),this.dispatcher.broadcast("SR",lt()),k_().on(D_,this._rtlPluginLoaded),this.on("data",e=>{if("source"!==e.dataType||"metadata"!==e.sourceDataType)return;let t=this.tileManagers[e.sourceId];if(!t)return;let i=t.getSource();if(i?.vectorLayerIds)for(let r in this._layers){let e=this._layers[r];e.source===i.id&&this._validateLayer(e)}})}_setInitialValues(){this._layers={},this._order=[],this.tileManagers={},this.zoomHistory=new hs,this._imagesListDirty=!1,this._globalState={},this._serializedLayers={},this.stylesheet=null,this.light=null,this.sky=null,this.projection&&(this.projection.destroy(),delete this.projection),this._loaded=!1,this._changed=!1,this._updatedLayers={},this._updatedSources={},this._changedImages={},this._glyphsDidChange=!1,this._updatedPaintProps={},this._layerOrderChanged=!1,this.crossTileSymbolIndex=new(this.crossTileSymbolIndex?.constructor||Object),this.pauseablePlacement=void 0,this.placement=void 0,this.z=0}setGlobalStateProperty(e,t){this._checkLoaded();let i=null===t?this.stylesheet.state?.[e]?.default??null:t;if(Ce(i,this._globalState[e]))return this;this._globalState[e]=i,this._applyGlobalStateChanges([e])}getGlobalState(){return this._globalState}setGlobalState(e){this._checkLoaded();let t=[];for(let i in e)Ce(this._globalState[i],e[i].default)||(t.push(i),this._globalState[i]=e[i].default);this._applyGlobalStateChanges(t)}_applyGlobalStateChanges(e){if(0===e.length)return;let t=/* @__PURE__ */new Set,i={};for(let r of e){i[r]=this._globalState[r];for(let e in this._layers){let i=this._layers[e],a=i.getLayoutAffectingGlobalStateRefs(),n=i.getPaintAffectingGlobalStateRefs(),s=i.getVisibilityAffectingGlobalStateRefs();if(a.has(r)&&t.add(i.source),n.has(r))for(let{name:e,value:t}of n.get(r))this._updatePaintProperty(i,e,t);s?.has(r)&&(i.recalculateVisibility(),this._updateLayer(i))}}this.dispatcher.broadcast("UGS",i);for(let r in this.tileManagers)t.has(r)&&(this._reloadSource(r),this._changed=!0)}async loadURL(e,t={},i){this.fire(new _m("dataloading")),t.validate="boolean"!=typeof t.validate||t.validate,this._loadStyleRequest=new AbortController;let r=this._loadStyleRequest;try{let a=await this.map._requestManager.transformRequest(e,"Style");tt(r.signal);let n=await ut(a,r);this._loadStyleRequest===r&&(this._loadStyleRequest=null),this._load(n.data,t,i)}catch(e){this._loadStyleRequest===r&&(this._loadStyleRequest=null),e&&!r.signal.aborted&&this.fire(new mt(ee(e)))}}loadJSON(e,t={},i){this.fire(new _m("dataloading")),this._frameRequest=new AbortController,am.frameAsync(this._frameRequest,this.map._ownerWindow).then(()=>{this._frameRequest=null,t.validate=!1!==t.validate,this._load(e,t,i)}).catch(()=>{})}loadEmpty(){this.fire(new _m("dataloading")),this._load(qy,{validate:!1})}_load(e,t,i){let r=t.transformStyle?t.transformStyle(i,e):e;if(!t.validate||!Jn(this,r)){r={...r},this._loaded=!0,this.stylesheet=r;for(let e in r.sources)this.addSource(e,r.sources[e],{validate:!1});r.sprite?this._loadSprite(r.sprite):this.imageManager.setLoaded(!0),this.glyphManager.setURL(r.glyphs),this._createLayers(),this.light=new jm(this.stylesheet.light??{},this._globalState),this._setProjectionInternal(this.stylesheet.projection?.type||"mercator"),this.sky=new Nm(this.stylesheet.sky,this._globalState),this.map.setTerrain(this.stylesheet.terrain??null,{validate:!1}),this.fire(new _m("data")),this.fire(new mm)}}_createLayers(){let e=xt(this.stylesheet.layers);this.setGlobalState(this.stylesheet.state??null),this.dispatcher.broadcast("SL",e),this._order=e.map(e=>e.id),this._layers={},this._serializedLayers=null;for(let t of e){let e=Mp(t,this._globalState);if(e.setEventedParent(this,{layer:{id:t.id}}),this._layers[t.id]=e,Ns(e)&&this.tileManagers[e.source]){let i=t.paint?.["raster-fade-duration"]??e.paint.get("raster-fade-duration");this.tileManagers[e.source].setRasterFadeDuration(i)}}}async _loadSprite(e,t=!1,i=void 0){this.imageManager.setLoaded(!1);let r,a=new AbortController;this._spriteRequest=a;try{let i=await async function(e,t,i,r){let a=Im(e),n=i>1?"@2x":"",s={},o={};for(let{id:l,url:h}of a){s[l]=ut(await t.transformRequest(Mm(h,n,".json"),"SpriteJSON"),r);let e=await t.transformRequest(Mm(h,n,".png"),"SpriteImage");o[l]=um.getImage(e,r)}return await Promise.all([...Object.values(s),...Object.values(o)]),async function(e,t){let i={};for(let r in e){i[r]={};let a=am.getImageCanvasContext((await t[r]).data),n=(await e[r]).data;for(let e in n){let{width:t,height:s,x:o,y:l,sdf:h,pixelRatio:u,stretchX:c,stretchY:p,content:d,textFitWidth:f,textFitHeight:m}=n[e],_={width:t,height:s,x:o,y:l,context:a};i[r][e]={data:null,pixelRatio:u,sdf:h,stretchX:c,stretchY:p,content:d,textFitWidth:f,textFitHeight:m,spriteData:_}}}return i}(s,o)}(e,this.map._requestManager,this.map.getPixelRatio(),a);if(!i)return;for(let e in i){let{loaded:r,removed:a}=this.imageManager.setSpriteImages(e,i[e]);this._markImagesChanged(a),t&&this._markImagesChanged(r)}}catch(e){r=e,a.signal.aborted||this.fire(new mt(r))}finally{this._spriteRequest=null,this.imageManager.setLoaded(!0),t&&(this._changed=!0),this.dispatcher.broadcast("SI",this.imageManager.listImages()),this.fire(new _m("data")),i?.(r)}}_unloadSprite(){this._markImagesChanged(this.imageManager.removeAllSpriteImages()),this._imagesListDirty=!0,this._changed=!0,this.fire(new _m("data"))}_validateLayer(e){let t=this.tileManagers[e.source];if(!t)return;let i=e.sourceLayer;if(!i)return;let r=t.getSource();("geojson"===r.type||r.vectorLayerIds&&!r.vectorLayerIds.includes(i))&&this.fire(new mt(Error(`Source layer "${i}" does not exist on source "${r.id}" as specified by style layer "${e.id}".`)))}loaded(){if(!this._loaded||Object.keys(this._updatedSources).length)return!1;for(let e in this.tileManagers)if(!this.tileManagers[e].loaded())return!1;return this.imageManager.isLoaded()}_serializeByIds(e,t=!1){let i=this._serializedAllLayers();if(!e||0===e.length)return Object.values(t?De(i):i);let r=[];for(let a of e)if(i[a]){let e=t?De(i[a]):i[a];r.push(e)}return r}_serializedAllLayers(){let e=this._serializedLayers;if(e)return e;e=this._serializedLayers={};let t=Object.keys(this._layers);for(let i of t){let t=this._layers[i];"custom"!==t.type&&(e[i]=t.serialize())}return e}hasTransitions(){if(this.light?.hasTransition()||this.sky?.hasTransition()||this.projection?.hasTransition())return!0;for(let e in this.tileManagers)if(this.tileManagers[e].hasTransition())return!0;for(let e in this._layers)if(this._layers[e].hasTransition())return!0;return!1}_checkLoaded(){if(!this._loaded)throw Error("Style is not done loading.")}update(e){if(!this._loaded)return;let t=this._changed;if(t){this._imagesListDirty&&=(this.dispatcher.broadcast("SI",this.imageManager.listImages()),!1);let t=Object.keys(this._updatedLayers),i=Object.keys(this._removedLayers);(t.length||i.length)&&this._updateWorkerLayers(t,i);for(let e in this._updatedSources){let t=this._updatedSources[e];if("reload"===t)this._reloadSource(e);else{if("clear"!==t)throw Error(`Invalid action ${t}`);this._clearSource(e)}}this._updateTilesForChangedImages(),this._updateTilesForChangedGlyphs();for(let r in this._updatedPaintProps)this._layers[r].updateTransitions(e);this.light.updateTransitions(e),this.sky.updateTransitions(e),this._resetUpdates()}let i={};for(let a in this.tileManagers){let e=this.tileManagers[a];i[a]=e.used,e.used=!1}let r=this.imageManager.listImages();for(let a of this._order){let t=this._layers[a];t.recalculate(e,r),!t.isHidden(e.zoom)&&t.source&&(this.tileManagers[t.source].used=!0)}for(let a in i){let e=this.tileManagers[a];!!i[a]!=!!e.used&&e.fire(new gm("data",{sourceDataType:"visibility",sourceId:a}))}this.light.recalculate(e),this.sky.recalculate(e),this.projection.recalculate(e),this.z=e.zoom,t&&this.fire(new _m("data"))}_updateTilesForChangedImages(){let e=Object.keys(this._changedImages);if(e.length){for(let t in this.tileManagers)this.tileManagers[t].reloadTilesForDependencies(["icons","patterns"],e);this._changedImages={}}}_updateTilesForChangedGlyphs(){if(this._glyphsDidChange){for(let e in this.tileManagers)this.tileManagers[e].reloadTilesForDependencies(["glyphs"],[""]);this._glyphsDidChange=!1}}_updateWorkerLayers(e,t){this.dispatcher.broadcast("UL",{layers:this._serializeByIds(e,!1),removedIds:t})}_resetUpdates(){this._changed=!1,this._updatedLayers={},this._removedLayers={},this._updatedSources={},this._updatedPaintProps={},this._changedImages={},this._glyphsDidChange=!1}setState(e,t={}){this._checkLoaded();let i=this.serialize();if(e=t.transformStyle?t.transformStyle(i,e):e,(t.validate??1)&&Jn(this,e))return!1;(e=De(e)).layers=xt(e.layers);let r=function(e,t){if(!e)return[{command:"setStyle",args:[t]}];let i=[];try{if(!bt(e.version,t.version))return[{command:"setStyle",args:[t]}];bt(e.center,t.center)||i.push({command:"setCenter",args:[t.center]}),bt(e.state,t.state)||i.push({command:"setGlobalState",args:[t.state]}),bt(e.centerAltitude,t.centerAltitude)||i.push({command:"setCenterAltitude",args:[t.centerAltitude]}),bt(e.zoom,t.zoom)||i.push({command:"setZoom",args:[t.zoom]}),bt(e.bearing,t.bearing)||i.push({command:"setBearing",args:[t.bearing]}),bt(e.pitch,t.pitch)||i.push({command:"setPitch",args:[t.pitch]}),bt(e.roll,t.roll)||i.push({command:"setRoll",args:[t.roll]}),bt(e.sprite,t.sprite)||i.push({command:"setSprite",args:[t.sprite]}),bt(e.glyphs,t.glyphs)||i.push({command:"setGlyphs",args:[t.glyphs]}),bt(e.transition,t.transition)||i.push({command:"setTransition",args:[t.transition]}),bt(e.light,t.light)||i.push({command:"setLight",args:[t.light]}),bt(e.terrain,t.terrain)||i.push({command:"setTerrain",args:[t.terrain]}),bt(e.sky,t.sky)||i.push({command:"setSky",args:[t.sky]}),bt(e.projection,t.projection)||i.push({command:"setProjection",args:[t.projection]});let r={},a=[];!function(e,t,i,r){let a;for(a in e||={},t||={},e)Object.prototype.hasOwnProperty.call(e,a)&&(Object.prototype.hasOwnProperty.call(t,a)||St(a,i,r));for(a in t)Object.prototype.hasOwnProperty.call(t,a)&&(Object.prototype.hasOwnProperty.call(e,a)?bt(e[a],t[a])||("geojson"===e[a].type&&"geojson"===t[a].type&&It(e,t,a)?wt(i,{command:"setGeoJSONSourceData",args:[a,t[a].data]}):Pt(a,t,i,r)):Tt(a,t,i))}(e.sources,t.sources,a,r);let n=[];e.layers&&e.layers.forEach(e=>{"source"in e&&r[e.source]?i.push({command:"removeLayer",args:[e.id]}):n.push(e)}),i=i.concat(a),function(e,t,i){e||=[],t||=[];let r,a,n,s,o,l=e.map(Et),h=t.map(Et),u=e.reduce(At,{}),c=t.reduce(At,{}),p=l.slice(),d=Object.create(null);for(let f=0,m=0;f<l.length;f++)r=l[f],Object.prototype.hasOwnProperty.call(c,r)?m++:(wt(i,{command:"removeLayer",args:[r]}),p.splice(p.indexOf(r,m),1));for(let f=0,m=0;f<h.length;f++)r=h[h.length-1-f],p[p.length-1-f]!==r&&(Object.prototype.hasOwnProperty.call(u,r)?(wt(i,{command:"removeLayer",args:[r]}),p.splice(p.lastIndexOf(r,p.length-m),1)):m++,s=p[p.length-f],wt(i,{command:"addLayer",args:[c[r],s]}),p.splice(p.length-f,0,r),d[r]=!0);for(let f=0;f<h.length;f++)if(r=h[f],a=u[r],n=c[r],!d[r]&&!bt(a,n)){if(!bt(a.source,n.source)||!bt(a["source-layer"],n["source-layer"])||!bt(a.type,n.type)){wt(i,{command:"removeLayer",args:[r]}),s=p[p.lastIndexOf(r)+1],wt(i,{command:"addLayer",args:[n,s]});continue}for(o in Mt(a.layout,n.layout,i,r,null,"setLayoutProperty"),Mt(a.paint,n.paint,i,r,null,"setPaintProperty"),bt(a.filter,n.filter)||wt(i,{command:"setFilter",args:[r,n.filter]}),(!bt(a.minzoom,n.minzoom)||!bt(a.maxzoom,n.maxzoom))&&wt(i,{command:"setLayerZoomRange",args:[r,n.minzoom,n.maxzoom]}),a)Object.prototype.hasOwnProperty.call(a,o)&&"layout"!==o&&"paint"!==o&&"filter"!==o&&"metadata"!==o&&"minzoom"!==o&&"maxzoom"!==o&&(0===o.indexOf("paint.")?Mt(a[o],n[o],i,r,o.slice(6),"setPaintProperty"):bt(a[o],n[o])||wt(i,{command:"setLayerProperty",args:[r,o,n[o]]}));for(o in n)!Object.prototype.hasOwnProperty.call(n,o)||Object.prototype.hasOwnProperty.call(a,o)||"layout"!==o&&"paint"!==o&&"filter"!==o&&"metadata"!==o&&"minzoom"!==o&&"maxzoom"!==o&&(0===o.indexOf("paint.")?Mt(a[o],n[o],i,r,o.slice(6),"setPaintProperty"):bt(a[o],n[o])||wt(i,{command:"setLayerProperty",args:[r,o,n[o]]}))}}(n,t.layers,i)}catch(e){console.warn("Unable to compute style diff:",e),i=[{command:"setStyle",args:[t]}]}return i}(i,e),a=this._getOperationsToPerform(r);if(a.unimplemented.length>0)throw Error(`Unimplemented: ${a.unimplemented.join(", ")}.`);if(0===a.operations.length)return!1;for(let n of a.operations)n();return this.stylesheet=e,this._serializedLayers=null,this.fire(new mm({style:this})),!0}_getOperationsToPerform(e){let t=[],i=[];for(let r of e)switch(r.command){case"setCenter":case"setZoom":case"setBearing":case"setPitch":case"setRoll":continue;case"addLayer":t.push(()=>this.addLayer.apply(this,r.args));break;case"removeLayer":t.push(()=>this.removeLayer.apply(this,r.args));break;case"setPaintProperty":t.push(()=>this.setPaintProperty.apply(this,r.args));break;case"setLayoutProperty":t.push(()=>this.setLayoutProperty.apply(this,r.args));break;case"setFilter":t.push(()=>this.setFilter.apply(this,r.args));break;case"addSource":t.push(()=>this.addSource.apply(this,r.args));break;case"removeSource":t.push(()=>this.removeSource.apply(this,r.args));break;case"setLayerZoomRange":t.push(()=>this.setLayerZoomRange.apply(this,r.args));break;case"setLight":t.push(()=>this.setLight.apply(this,r.args));break;case"setGeoJSONSourceData":t.push(()=>this.setGeoJSONSourceData.apply(this,r.args));break;case"setGlyphs":t.push(()=>this.setGlyphs.apply(this,r.args));break;case"setSprite":t.push(()=>this.setSprite.apply(this,r.args));break;case"setTerrain":t.push(()=>this.map.setTerrain.apply(this,r.args));break;case"setSky":t.push(()=>this.setSky.apply(this,r.args));break;case"setProjection":this.setProjection.apply(this,r.args);break;case"setGlobalState":t.push(()=>this.setGlobalState.apply(this,r.args));break;case"setTransition":t.push(()=>{});break;default:i.push(r.command)}return{operations:t,unimplemented:i}}addImage(e,t){this.getImage(e)?this.fire(new mt(Error(`An image named "${e}" already exists.`))):(this.imageManager.addImage(e,t),this._afterImageUpdated(e))}updateImage(e,t){this.imageManager.updateImage(e,t)}getImage(e){return this.imageManager.getImage(e)}setMissingImageResolver(e){this.imageManager.setMissingImageResolver(e)}removeImage(e){this.getImage(e)?(this.imageManager.removeImage(e),this._afterImageUpdated(e)):this.fire(new mt(Error(`An image named "${e}" does not exist.`)))}_markImagesChanged(e){for(let t of e)this._changedImages[t]=!0}_afterImageUpdated(e){this._changedImages[e]=!0,this._imagesListDirty=!0,this._changed=!0,this.fire(new _m("data"))}listImages(){return this._checkLoaded(),this.imageManager.listImages()}addSource(e,t,i={}){if(this._checkLoaded(),void 0!==this.tileManagers[e])throw Error(`Source "${e}" already exists.`);if(!t.type)throw Error(`The type property must be defined, but only the following properties were given: ${Object.keys(t).join(", ")}.`);if(Kn.has(t.type)&&this._validate(Yn.source,`sources.${e}`,t,null,i))return;this.map?._collectResourceTiming&&(t.collectResourceTiming=!0);let r=this.tileManagers[e]=new K_(e,t,this.dispatcher);r.style=this,r.setEventedParent(this,()=>({isSourceLoaded:r.loaded(),source:r.serialize(),sourceId:e})),r.onAdd(this.map),this._changed=!0}removeSource(e){if(this._checkLoaded(),void 0===this.tileManagers[e])throw Error(`There is no source with this ID=${e}`);for(let i in this._layers)if(this._layers[i].source===e)return this.fire(new mt(Error(`Source "${e}" cannot be removed while layer "${i}" is using it.`)));let t=this.tileManagers[e];delete this.tileManagers[e],delete this._updatedSources[e],t.fire(new gm("data",{sourceDataType:"metadata",sourceId:e})),t.setEventedParent(null),t.onRemove(this.map),this._changed=!0}setGeoJSONSourceData(e,t){if(this._checkLoaded(),void 0===this.tileManagers[e])throw Error(`There is no source with this ID=${e}`);let i=this.tileManagers[e].getSource();if("geojson"!==i.type)throw Error(`geojsonSource.type is ${i.type}, which is !== 'geojson`);i.setData(t),this._changed=!0}getSource(e){return this.tileManagers[e]?.getSource()}addLayer(e,t,i={}){this._checkLoaded();let r,a=e.id;if(this.getLayer(a))return void this.fire(new mt(Error(`Layer "${a}" already exists on this map.`)));if("custom"===e.type){if(Qn(this,function(e){let t=[],i=e.id;return void 0===i&&t.push(new Ct(`layers.${i}`,null,'missing required property "id"')),void 0===e.render&&t.push(new Ct(`layers.${i}`,null,'missing required method "render"')),e.renderingMode&&"2d"!==e.renderingMode&&"3d"!==e.renderingMode&&t.push(new Ct(`layers.${i}`,null,'property "renderingMode" must be either "2d" or "3d"')),t}(e)))return;r=Mp(e,this._globalState)}else{if("source"in e&&"object"==typeof e.source&&(this.addSource(a,e.source),e=be(e=De(e),{source:a})),this._validate(Yn.layer,`layers.${a}`,e,{arrayIndex:-1},i))return;r=Mp(e,this._globalState),this._validateLayer(r),r.setEventedParent(this,{layer:{id:a}})}let n=t?this._order.indexOf(t):this._order.length;if(t&&-1===n)this.fire(new mt(Error(`Cannot add layer "${a}" before non-existing layer "${t}".`)));else{if(this._order.splice(n,0,a),this._layerOrderChanged=!0,this._layers[a]=r,this._removedLayers[a]&&r.source&&"custom"!==r.type){let e=this._removedLayers[a];delete this._removedLayers[a],e.type===r.type?(this._updatedSources[r.source]="reload",this.tileManagers[r.source].pause()):this._updatedSources[r.source]="clear"}this._updateLayer(r),r.onAdd&&r.onAdd(this.map)}}moveLayer(e,t){if(this._checkLoaded(),this._changed=!0,!this._layers[e])return void this.fire(new mt(Error(`The layer '${e}' does not exist in the map's style and cannot be moved.`)));if(e===t)return;let i=this._order.indexOf(e);this._order.splice(i,1);let r=t?this._order.indexOf(t):this._order.length;t&&-1===r?this.fire(new mt(Error(`Cannot move layer "${e}" before non-existing layer "${t}".`))):(this._order.splice(r,0,e),this._layerOrderChanged=!0)}removeLayer(e){this._checkLoaded();let t=this._layers[e];if(!t)return void this.fire(new mt(Error(`Cannot remove non-existing layer "${e}".`)));t.setEventedParent(null);let i=this._order.indexOf(e);this._order.splice(i,1),this._layerOrderChanged=!0,this._changed=!0,this._removedLayers[e]=t,delete this._layers[e],this._serializedLayers&&delete this._serializedLayers[e],delete this._updatedLayers[e],delete this._updatedPaintProps[e],t.onRemove&&t.onRemove(this.map)}getLayer(e){return this._layers[e]}getLayersOrder(){return[...this._order]}hasLayer(e){return e in this._layers}setLayerZoomRange(e,t,i){this._checkLoaded();let r=this.getLayer(e);r?(r.minzoom!==t||r.maxzoom!==i)&&(null!=t&&(r.minzoom=t),null!=i&&(r.maxzoom=i),this._updateLayer(r)):this.fire(new mt(Error(`Cannot set the zoom range of non-existing layer "${e}".`)))}setFilter(e,t,i={}){this._checkLoaded();let r=this.getLayer(e);if(r){if(!Ce(r.filter,t)){if(null==t)return r.setFilter(void 0),void this._updateLayer(r);this._validate(Yn.filter,`layers.${r.id}.filter`,t,null,i)||(r.setFilter(De(t)),this._updateLayer(r))}}else this.fire(new mt(Error(`Cannot filter non-existing layer "${e}".`)))}getFilter(e){return De(this.getLayer(e).filter)}setLayoutProperty(e,t,i,r={}){this._checkLoaded();let a=this.getLayer(e);a?Ce(a.getLayoutProperty(t),i)||(a.setLayoutProperty(t,i,r),this._updateLayer(a)):this.fire(new mt(Error(`Cannot style non-existing layer "${e}".`)))}getLayoutProperty(e,t){let i=this.getLayer(e);if(i)return i.getLayoutProperty(t);this.fire(new mt(Error(`Cannot get style of non-existing layer "${e}".`)))}setPaintProperty(e,t,i,r={}){this._checkLoaded();let a=this.getLayer(e);a?Ce(a.getPaintProperty(t),i)||this._updatePaintProperty(a,t,i,r):this.fire(new mt(Error(`Cannot style non-existing layer "${e}".`)))}_updatePaintProperty(e,t,i,r={}){e.setPaintProperty(t,i,r)&&this._updateLayer(e),Ns(e)&&"raster-fade-duration"===t&&this.tileManagers[e.source].setRasterFadeDuration(i),this._changed=!0,this._updatedPaintProps[e.id]=!0,this._serializedLayers=null}getPaintProperty(e,t){return this.getLayer(e).getPaintProperty(t)}setFeatureState(e,t){this._checkLoaded();let i=e.source,r=e.sourceLayer,a=this.tileManagers[i];if(void 0===a)return void this.fire(new mt(Error(`The source '${i}' does not exist in the map's style.`)));let n=a.getSource().type;if("geojson"===n&&r)return void this.fire(new mt(Error("GeoJSON sources cannot have a sourceLayer parameter.")));if("vector"===n&&!r)return void this.fire(new mt(Error("The sourceLayer parameter must be provided for vector source types.")));if(void 0===e.id)return void this.fire(new mt(Error("The feature id parameter must be provided.")));let s=["__proto__","constructor","prototype"];t&&Object.keys(t).some(e=>s.includes(e))?this.fire(new mt(Error(`The feature state should not include one of the following keys: ${s}`))):a.setFeatureState(r,e.id,t)}removeFeatureState(e,t){this._checkLoaded();let i=e.source,r=this.tileManagers[i];if(void 0===r)return void this.fire(new mt(Error(`The source '${i}' does not exist in the map's style.`)));let a=r.getSource().type,n="vector"===a?e.sourceLayer:void 0;"vector"!==a||n?t&&"string"!=typeof e.id&&"number"!=typeof e.id?this.fire(new mt(Error("A feature id is required to remove its specific state property."))):r.removeFeatureState(n,e.id,t):this.fire(new mt(Error("The sourceLayer parameter must be provided for vector source types.")))}getFeatureState(e){this._checkLoaded();let t=e.source,i=e.sourceLayer,r=this.tileManagers[t];if(void 0!==r){if("vector"!==r.getSource().type||i)return void 0===e.id&&this.fire(new mt(Error("The feature id parameter must be provided."))),r.getFeatureState(i,e.id);this.fire(new mt(Error("The sourceLayer parameter must be provided for vector source types.")))}else this.fire(new mt(Error(`The source '${t}' does not exist in the map's style.`)))}getTransition(){return be({duration:300,delay:0},this.stylesheet?.transition)}serialize(){if(!this._loaded)return;let e=Ee(this.tileManagers,e=>e.serialize()),t=this._serializeByIds(this._order,!0),i=this.map.getTerrain()||void 0,r=this.stylesheet;return Ae({version:r.version,name:r.name,metadata:r.metadata,light:r.light,sky:r.sky,center:r.center,zoom:r.zoom,bearing:r.bearing,pitch:r.pitch,sprite:r.sprite,glyphs:r.glyphs,transition:r.transition,projection:r.projection,sources:e,layers:t,terrain:i},e=>void 0!==e)}_updateLayer(e){this._updatedLayers[e.id]=!0,e.source&&!this._updatedSources[e.source]&&"raster"!==this.tileManagers[e.source].getSource().type&&(this._updatedSources[e.source]="reload",this.tileManagers[e.source].pause()),this._serializedLayers=null,this._changed=!0}_flattenAndSortRenderedFeatures(e){let t=e=>"fill-extrusion"===this._layers[e].type,i={},r=[];for(let n=this._order.length-1;n>=0;n--){let a=this._order[n];if(t(a)){i[a]=n;for(let t of e){let e=t[a];if(e)for(let t of e)r.push(t)}}}r.sort((e,t)=>t.intersectionZ-e.intersectionZ);let a=[];for(let n=this._order.length-1;n>=0;n--){let s=this._order[n];if(t(s))for(let e=r.length-1;e>=0;e--){let t=r[e].feature;if(i[t.layer.id]<n)break;a.push(t),r.pop()}else for(let t of e){let e=t[s];if(e)for(let t of e)a.push(t.feature)}}return a}queryRenderedFeatures(e,t,i){t?.filter&&this._validate(Yn.filter,"queryRenderedFeatures.filter",t.filter,null,t);let r={};if(t?.layers){if(!(Array.isArray(t.layers)||t.layers instanceof Set))return this.fire(new mt(Error("parameters.layers must be an Array or a Set of strings"))),[];for(let e of t.layers){let t=this._layers[e];if(!t)return this.fire(new mt(Error(`The layer '${e}' does not exist in the map's style and cannot be queried for features.`))),[];r[t.source]=!0}}let a=[];t.availableImages=this.imageManager.listImages();let n=this._serializedAllLayers(),s=t.layers instanceof Set?t.layers:Array.isArray(t.layers)?new Set(t.layers):null,o={...t,layers:s,globalState:this._globalState};for(let l in this.tileManagers)t.layers&&!r[l]||a.push(i_(this.tileManagers[l],this._layers,n,e,o,i,this.map.terrain?(e,t,i)=>this.map.terrain.getElevation(e,t,i):void 0));return this.placement&&a.push(function(e,t,i,r,a,n,s){let o={},l=n.queryRenderedSymbols(r),h=[];for(let u of Object.keys(l).map(Number))h.push(s[u]);h.sort(r_);for(let u of h){let i=u.featureIndex.lookupSymbolFeatures(l[u.bucketInstanceId],t,u.bucketIndex,u.sourceLayerIndex,{filterSpec:a.filter,globalState:a.globalState},a.layers,a.availableImages,e);for(let e in i){o[e]||=[];let t=i[e];t.sort((e,t)=>{let i=u.featureSortOrder;if(i){let r=i.indexOf(e.featureIndex);return i.indexOf(t.featureIndex)-r}return t.featureIndex-e.featureIndex});for(let i of t)o[e].push(i)}}return function(e,t,i){for(let r in e)for(let a of e[r])a_(a,i[t[r].source]);return e}(o,e,i)}(this._layers,n,this.tileManagers,e,o,this.placement.collisionIndex,this.placement.retainedQueryData)),this._flattenAndSortRenderedFeatures(a)}querySourceFeatures(e,t){t?.filter&&this._validate(Yn.filter,"querySourceFeatures.filter",t.filter,null,t);let i=this.tileManagers[e];return i?function(e,t){let i=e.getRenderableIds().map(t=>e.getTileByID(t)),r=[],a={};for(let n of i){let e=n.tileID.canonical.key;a[e]||(a[e]=!0,n.querySourceFeatures(r,t))}return r}(i,t?{...t,globalState:this._globalState}:{globalState:this._globalState}):[]}getLight(){return this.light.getLight()}setLight(e,t={}){this._checkLoaded();let i=this.light.getLight(),r=!1;for(let n in e)if(!Ce(e[n],i[n])){r=!0;break}if(!r)return;let a={now:sm(),transition:be({duration:300,delay:0},this.stylesheet.transition)};this.light.setLight(e,t),this.light.updateTransitions(a)}getProjection(){return this.stylesheet?.projection}setProjection(e){this._checkLoaded();let t=e??{type:"mercator"};if(this.stylesheet.projection=e,this.projection){if(this.projection.name===t.type)return;this.projection.destroy(),delete this.projection}this._setProjectionInternal(t.type)}getSky(){return this.stylesheet?.sky}setSky(e,t={}){this._checkLoaded();let i=this.getSky(),r=!1;if(!e&&!i)return;if(e&&!i)r=!0;else if(!e&&i)r=!0;else for(let n in e)if(!Ce(e[n],i[n])){r=!0;break}if(!r)return;let a={now:sm(),transition:be({duration:300,delay:0},this.stylesheet.transition)};this.stylesheet.sky=e,this.sky.setSky(e,t),this.sky.updateTransitions(a)}_setProjectionInternal(e){let t=function(e,t,i){let r={constrainOverride:t};if(Array.isArray(e)){let t=new Sy({type:e},i);return{projection:t,transform:new Gy(r),cameraHelper:new Zy(t)}}switch(e){case"mercator":return{projection:new oy,transform:new my(r),cameraHelper:new xy};case"globe":{let e=new Sy({type:["interpolate",["linear"],["zoom"],11,"vertical-perspective",12,"mercator"]},{});return{projection:e,transform:new Gy(r),cameraHelper:new Zy(e)}}case"vertical-perspective":return{projection:new Ty,transform:new Uy(r),cameraHelper:new $y};default:return Re(`Unknown projection name: ${e}. Falling back to mercator projection.`),{projection:new oy,transform:new my(r),cameraHelper:new xy}}}(e,this.map._camera?.transform.constrainOverride,this._globalState);this.projection=t.projection,this.map.migrateProjection(t.transform,t.cameraHelper);for(let i in this.tileManagers)this.tileManagers[i].reload()}_validate(e,t,i,r,a={}){return es(this,e,{key:t,style:this.serialize(),value:i,...r},a)}_remove(e=!0){this._frameRequest&&=(this._frameRequest.abort(),null),this._loadStyleRequest&&=(this._loadStyleRequest.abort(),null),this._spriteRequest&&=(this._spriteRequest.abort(),null),k_().off(D_,this._rtlPluginLoaded);for(let t in this._layers)this._layers[t].setEventedParent(null);for(let t in this.tileManagers){let e=this.tileManagers[t];e.setEventedParent(null),e.onRemove(this.map)}this.imageManager.setEventedParent(null),this.setEventedParent(null),e&&this.dispatcher.broadcast("RM",void 0),this.dispatcher.remove(e)}_clearSource(e){this.tileManagers[e].clearTiles()}_reloadSource(e){this.tileManagers[e].resume(),this.tileManagers[e].reload()}_updateSources(e){for(let t in this.tileManagers)this.tileManagers[t].update(e,this.map.terrain)}_generateCollisionBoxes(){for(let e in this.tileManagers)this._reloadSource(e)}_updatePlacement(e,t,i,r,a=!1){let n=!1,s=!1,o={};for(let l of this._order){let t=this._layers[l];if("symbol"!==t.type)continue;if(!o[t.source]){let e=this.tileManagers[t.source];o[t.source]=e.getRenderableIds(!0).map(t=>e.getTileByID(t)).sort((e,t)=>t.tileID.overscaledZ-e.tileID.overscaledZ||(e.tileID.isLessThan(t.tileID)?-1:1))}let i=this.crossTileSymbolIndex.addLayer(t,o[t.source],e.center.lng);n||=i}if(this.crossTileSymbolIndex.pruneUnusedLayers(this._order),a||=this._layerOrderChanged||0===i,(a||!this.pauseablePlacement||this.pauseablePlacement.isDone()&&!this.placement.stillRecent(sm(),e.zoom))&&(this.pauseablePlacement=new jg(e,this.map.terrain,this._order,a,t,i,r,this.placement),this._layerOrderChanged=!1),this.pauseablePlacement.isDone()?this.placement.setStale():(this.pauseablePlacement.continuePlacement(this._order,this._layers,o),this.pauseablePlacement.isDone()&&(this.placement=this.pauseablePlacement.commit(sm()),s=!0),n&&this.pauseablePlacement.placement.setStale()),s||n)for(let l of this._order){let e=this._layers[l];"symbol"===e.type&&this.placement.updateLayerOpacities(e,o[e.source])}return!this.pauseablePlacement.isDone()||this.placement.hasTransitions(sm())}_releaseSymbolFadeTiles(){for(let e in this.tileManagers)this.tileManagers[e].releaseSymbolFadeTiles()}async getImages(e,t){let i=await this.imageManager.getImages(t.icons);this._updateTilesForChangedImages();let r=this.tileManagers[t.source];return r&&r.setDependencies(t.tileID.key,t.type,t.icons),i}async getGlyphs(e,t){let i=await this.glyphManager.getGlyphs(t.stacks),r=this.tileManagers[t.source];return r&&r.setDependencies(t.tileID.key,t.type,[""]),i}getGlyphsUrl(){return this.stylesheet.glyphs||null}setGlyphs(e,t={}){this._checkLoaded(),(!e||!this._validate(Yn.glyphs,"glyphs",e,null,t))&&(this._glyphsDidChange=!0,this.stylesheet.glyphs=e,this.glyphManager.entries={},this.glyphManager.setURL(e))}async getDashes(e,t){let i={};for(let[r,a]of Object.entries(t.dashes))i[r]=this.lineAtlas.getDash(a.dasharray,a.round);return i}addSprite(e,t,i={},r){this._checkLoaded();let a=[{id:e,url:t}],n=[...Im(this.stylesheet.sprite),...a];this._validate(Yn.sprite,"sprite",n,null,i)||(this.stylesheet.sprite=n,this._loadSprite(a,!0,r))}removeSprite(e){this._checkLoaded();let t=Im(this.stylesheet.sprite);if(!t.find(t=>t.id===e))return void this.fire(new mt(Error(`Sprite "${e}" doesn't exists on this map.`)));let i=this.imageManager.removeSpriteImages(e);this._markImagesChanged(i),t.splice(t.findIndex(t=>t.id===e),1),this.stylesheet.sprite=t.length>0?t:void 0,this._imagesListDirty=!0,this._changed=!0,this.fire(new _m("data"))}getSprite(){return Im(this.stylesheet.sprite)}setSprite(e,t={},i){this._checkLoaded(),(!e||!this._validate(Yn.sprite,"sprite",e,null,t))&&(this.stylesheet.sprite=e,e?this._loadSprite(e,!0,i):(this._unloadSprite(),i&&i(null)))}destroy(){this._frameRequest&&=(this._frameRequest.abort(),null),this._loadStyleRequest&&=(this._loadStyleRequest.abort(),null),this._spriteRequest&&=(this._spriteRequest.abort(),null);for(let e in this.tileManagers){let t=this.tileManagers[e];t.setEventedParent(null),t.onRemove(this.map)}this.tileManagers={},this.imageManager&&(this.imageManager.setEventedParent(null),this.imageManager.destroy(),this.patternAtlas.destroy()),this.glyphManager&&this.glyphManager.destroy();for(let e in this._layers){let t=this._layers[e];t.setEventedParent(null),t.onRemove&&t.onRemove(this.map)}this._setInitialValues(),this.setEventedParent(null),this.dispatcher.unregisterMessageHandler("GG"),this.dispatcher.unregisterMessageHandler("GI"),this.dispatcher.unregisterMessageHandler("GDA"),this.dispatcher.remove(!0),this._listeners={},this._oneTimeListeners={}}},Hy=qs([{name:"a_pos",type:"Int16",components:2},{name:"a_texture_pos",type:"Int16",components:2}]),Xy=class{constructor(){this.boundProgram=null,this.boundLayoutVertexBuffer=null,this.boundPaintVertexBuffers=[],this.boundIndexBuffer=null,this.boundVertexOffset=null,this.boundDynamicVertexBuffer=null,this.vao=null}bind(e,t,i,r,a,n,s,o,l){this.context=e;let h=this.boundPaintVertexBuffers.length!==r.length;for(let u=0;!h&&u<r.length;u++)this.boundPaintVertexBuffers[u]!==r[u]&&(h=!0);!this.vao||this.boundProgram!==t||this.boundLayoutVertexBuffer!==i||h||this.boundIndexBuffer!==a||this.boundVertexOffset!==n||this.boundDynamicVertexBuffer!==s||this.boundDynamicVertexBuffer2!==o||this.boundDynamicVertexBuffer3!==l?this.freshBind(t,i,r,a,n,s,o,l):(e.bindVertexArray.set(this.vao),s&&s.bind(),a?.dynamicDraw&&a.bind(),o&&o.bind(),l&&l.bind())}freshBind(e,t,i,r,a,n,s,o){let l=e.numAttributes,h=this.context,u=h.gl;this.vao&&this.destroy(),this.vao=h.createVertexArray(),h.bindVertexArray.set(this.vao),this.boundProgram=e,this.boundLayoutVertexBuffer=t,this.boundPaintVertexBuffers=i,this.boundIndexBuffer=r,this.boundVertexOffset=a,this.boundDynamicVertexBuffer=n,this.boundDynamicVertexBuffer2=s,this.boundDynamicVertexBuffer3=o,t.enableAttributes(u,e);for(let c of i)c.enableAttributes(u,e);n&&n.enableAttributes(u,e),s&&s.enableAttributes(u,e),o&&o.enableAttributes(u,e),t.bind(),t.setVertexAttribPointers(u,e,a);for(let c of i)c.bind(),c.setVertexAttribPointers(u,e,a);n&&(n.bind(),n.setVertexAttribPointers(u,e,a)),r&&r.bind(),s&&(s.bind(),s.setVertexAttribPointers(u,e,a)),o&&(o.bind(),o.setVertexAttribPointers(u,e,a)),h.currentNumAttributes=l}destroy(){this.vao&&=(this.context.deleteVertexArray(this.vao),null)}},Yy=(e,t,i,r,a)=>({u_texture:0,u_ele_delta:e,u_fog_matrix:t,u_fog_color:i?i.properties.get("fog-color"):Si.white,u_fog_ground_blend:i?i.properties.get("fog-ground-blend"):1,u_fog_ground_blend_opacity:a?0:i?i.calculateFogBlendOpacity(r):0,u_horizon_color:i?i.properties.get("horizon-color"):Si.white,u_horizon_fog_blend:i?i.properties.get("horizon-fog-blend"):1,u_is_globe_mode:+!!a}),Ky=e=>({u_ele_delta:e}),Jy=(e,t)=>({u_terrain_coords_id:e/255,u_texture:0,u_ele_delta:t});function Qy(e){let t=[];for(let i of e){if(null===i)continue;let e=i.split(" ");t.push(e.pop())}return t}var ev=class{constructor(e,t,i,r,a,n,s,o,l=[]){let h=e.gl;this.program=h.createProgram();let u=Qy(t.staticAttributes),c=i?i.getBinderAttributes():[],p=u.concat(c),d=ty.prelude.staticUniforms?Qy(ty.prelude.staticUniforms):[],f=s.staticUniforms?Qy(s.staticUniforms):[],m=t.staticUniforms?Qy(t.staticUniforms):[],_=i?i.getBinderUniforms():[],g=d.concat(f).concat(m).concat(_),y=[];for(let I of g)y.includes(I)||y.push(I);let v=i?i.defines():[];v.unshift("#version 300 es"),a&&v.push("#define OVERDRAW_INSPECTOR;"),n&&v.push("#define TERRAIN3D;"),o&&v.push(o),l&&v.push(...l);let x=v.concat(ty.prelude.fragmentSource,s.fragmentSource,t.fragmentSource).join("\n"),b=v.concat(ty.prelude.vertexSource,s.vertexSource,t.vertexSource).join("\n"),w=h.createShader(h.FRAGMENT_SHADER);if(h.isContextLost())return void(this.failedToCreate=!0);if(h.shaderSource(w,x),h.compileShader(w),!h.getShaderParameter(w,h.COMPILE_STATUS))throw Error(`Could not compile fragment shader: ${h.getShaderInfoLog(w)}`);h.attachShader(this.program,w);let T=h.createShader(h.VERTEX_SHADER);if(h.isContextLost())return void(this.failedToCreate=!0);if(h.shaderSource(T,b),h.compileShader(T),!h.getShaderParameter(T,h.COMPILE_STATUS))throw Error(`Could not compile vertex shader: ${h.getShaderInfoLog(T)}`);h.attachShader(this.program,T),this.attributes={};let S={};if(this.numAttributes=p.length,h.linkProgram(this.program),!h.getProgramParameter(this.program,h.LINK_STATUS))throw Error(`Program failed to link: ${h.getProgramInfoLog(this.program)}`);let P=function(e,t){let i=/* @__PURE__ */new Set([e.INT,e.INT_VEC2,e.INT_VEC3,e.INT_VEC4,e.UNSIGNED_INT,e.UNSIGNED_INT_VEC2,e.UNSIGNED_INT_VEC3,e.UNSIGNED_INT_VEC4]),r=/* @__PURE__ */new Set,a=e.getProgramParameter(t,e.ACTIVE_ATTRIBUTES);for(let n=0;n<a;n++){let a=e.getActiveAttrib(t,n);a&&i.has(a.type)&&r.add(a.name)}return r}(h,this.program);for(let I of p){if(!I)continue;let e=h.getAttribLocation(this.program,I);e>=0&&(this.attributes[I]={location:e,isInteger:P.has(I)})}h.deleteShader(T),h.deleteShader(w);for(let I of y)if(I&&!S[I]){let e=h.getUniformLocation(this.program,I);e&&(S[I]=e)}this.fixedUniforms=r(e,S),this.terrainUniforms=((e,t)=>({u_depth:new cl(e,t.u_depth),u_terrain:new cl(e,t.u_terrain),u_terrain_dim:new pl(e,t.u_terrain_dim),u_terrain_matrix:new xl(e,t.u_terrain_matrix),u_terrain_unpack:new ml(e,t.u_terrain_unpack),u_terrain_exaggeration:new pl(e,t.u_terrain_exaggeration)}))(e,S),this.projectionUniforms=((e,t)=>({u_projection_matrix:new xl(e,t.u_projection_matrix),u_projection_tile_mercator_coords:new ml(e,t.u_projection_tile_mercator_coords),u_projection_clipping_plane:new ml(e,t.u_projection_clipping_plane),u_projection_transition:new pl(e,t.u_projection_transition),u_projection_fallback_matrix:new xl(e,t.u_projection_fallback_matrix),u_projection_clip_antimeridian:new cl(e,t.u_projection_clip_antimeridian)}))(e,S),this.binderUniforms=i?i.getUniforms(e,S):[]}draw(e,t,i,r,a,n,s,o,l,h,u,c,p,d,f,m,_,g,y){let v=e.gl;if(this.failedToCreate)return;if(e.program.set(this.program),e.setDepthMode(i),e.setStencilMode(r),e.setColorMode(a),e.setCullFace(n),o){e.activeTexture.set(v.TEXTURE2),v.bindTexture(v.TEXTURE_2D,o.depthTexture),e.activeTexture.set(v.TEXTURE3),v.bindTexture(v.TEXTURE_2D,o.texture);for(let e in this.terrainUniforms)this.terrainUniforms[e].set(o[e])}if(l){let e=(e=>({u_projection_matrix:e.mainMatrix,u_projection_tile_mercator_coords:e.tileMercatorCoords,u_projection_clipping_plane:e.clippingPlane,u_projection_transition:e.projectionTransition,u_projection_fallback_matrix:e.fallbackMatrix,u_projection_clip_antimeridian:+!!e.clipAntimeridian}))(l);for(let t in this.projectionUniforms)this.projectionUniforms[t].set(e[t])}if(s)for(let b in this.fixedUniforms)this.fixedUniforms[b].set(s[b]);m&&m.setUniforms(e,this.binderUniforms,d,{zoom:f});let x=0;switch(t){case v.LINES:x=2;break;case v.TRIANGLES:x=3;break;case v.LINE_STRIP:x=1}for(let b of p.get())b.vaos||={},b.vaos[h]||=new Xy,b.vaos[h].bind(e,this,u,m?m.getPaintVertexBuffers():[],c,b.vertexOffset,_,g,y),v.drawElements(t,b.primitiveLength*x,v.UNSIGNED_SHORT,b.primitiveOffset*x*2)}};function tv(e,t,i){let r=1/Q(i,1,t.transform.tileZoom),a=2**i.tileID.overscaledZ,n=i.tileSize*2**t.transform.tileZoom/a,s=n*(i.tileID.canonical.x+i.tileID.wrap*a),o=n*i.tileID.canonical.y;return{u_image:0,u_texsize:i.imageAtlasTexture.size,u_scale:[r,e.fromScale,e.toScale],u_fade:e.t,u_pixel_coord_upper:[s>>16,o>>16],u_pixel_coord_lower:[65535&s,65535&o]}}var iv=(e,t,i,r)=>{let a=e.style.light,n=a.getCartesianPosition(),s=d();"viewport"===a.properties.get("anchor")&&function(e,t){var i=Math.sin(t),r=Math.cos(t);e[0]=r,e[1]=i,e[2]=0,e[3]=-i,e[4]=r,e[5]=0,e[6]=0,e[7]=0,e[8]=1}(s,e.transform.bearingInRadians),function(e,t,i){var r=t[0],a=t[1],n=t[2];e[0]=r*i[0]+a*i[3]+n*i[6],e[1]=r*i[1]+a*i[4]+n*i[7],e[2]=r*i[2]+a*i[5]+n*i[8]}(n,n,s);let o=e.transform.transformLightDirection(n),l=a.properties.get("color");return{u_lightpos:n,u_lightpos_globe:o,u_lightintensity:a.properties.get("intensity"),u_lightcolor:[l.r,l.g,l.b],u_vertical_gradient:+t,u_opacity:i,u_fill_translate:r}},rv=(e,t,i,r,a,n,s)=>be(iv(e,t,i,r),tv(n,e,s),{u_height_factor:-(2**a.overscaledZ)/s.tileSize/8}),av=(e,t,i,r)=>be(tv(t,e,i),{u_fill_translate:r}),nv=e=>({u_fill_translate:e}),sv=(e,t)=>({u_world:e,u_fill_translate:t}),ov=(e,t,i,r,a)=>be(av(e,t,i,a),{u_world:r}),lv=(e,t,i,r,a)=>{let n,s,o=e.transform,l=0;if("map"===i.paint.get("circle-pitch-alignment")){let e=Q(t,1,o.zoom);n=!0,s=[e,e],l=e/(J*2**t.tileID.overscaledZ)*2*Math.PI*a}else n=!1,s=o.pixelsToGLUnits;return{u_camera_to_center_distance:o.cameraToCenterDistance,u_scale_with_map:+("map"===i.paint.get("circle-pitch-scale")),u_pitch_with_map:+n,u_device_pixel_ratio:e.pixelRatio,u_extrude_scale:s,u_globe_extrude_scale:l,u_translate:r}},hv=e=>({u_pixel_extrude_scale:[1/e.width,1/e.height]}),uv=e=>({u_viewport_size:[e.width,e.height]}),cv=(e,t=1)=>({u_color:e,u_overlay:0,u_overlay_scale:t}),pv=(e,t,i,r)=>{let a=Q(e,1,t)/(J*2**e.tileID.overscaledZ)*2*Math.PI*r;return{u_extrude_scale:Q(e,1,t),u_intensity:i,u_globe_extrude_scale:a}},dv=(e,t,i,r)=>{let a=f();P(a,0,e.width,e.height,0,0,1);let n=e.context.gl;return{u_matrix:a,u_world:[n.drawingBufferWidth,n.drawingBufferHeight],u_image:i,u_color_ramp:r,u_opacity:t.paint.get("heatmap-opacity")}},fv=(e,t,i)=>{let r,a=i.paint.get("hillshade-accent-color");switch(i.paint.get("hillshade-method")){case"basic":r=4;break;case"combined":r=1;break;case"igor":r=2;break;case"multidirectional":r=3;break;default:r=0}let n=i.getIlluminationProperties();for(let s=0;s<n.directionRadians.length;s++)"viewport"===i.paint.get("hillshade-illumination-anchor")&&(n.directionRadians[s]+=e.transform.bearingInRadians);return{u_image:0,u_latrange:_v(0,t.tileID),u_exaggeration:i.paint.get("hillshade-exaggeration"),u_altitudes:n.altitudeRadians,u_azimuths:n.directionRadians,u_accent:a,u_method:r,u_highlights:n.highlightColor,u_shadows:n.shadowColor}},mv=(e,t)=>{let i=t.stride,r=f();return P(r,0,J,-J,0,0,1),v(r,r,[0,-J,0]),{u_matrix:r,u_image:1,u_dimension:[i,i],u_zoom:e.overscaledZ,u_unpack:t.getUnpackVector()}};function _v(e,t){let i=2**t.canonical.z,r=t.canonical.y;return[new ac(0,r/i).toLngLat().lat,new ac(0,(r+1)/i).toLngLat().lat]}var gv=(e,t,i=0)=>({u_image:0,u_unpack:t.getUnpackVector(),u_dimension:[t.stride,t.stride],u_elevation_stops:1,u_color_stops:4,u_color_ramp_size:i,u_opacity:e.paint.get("color-relief-opacity")}),yv=(e,t,i,r)=>{let a=e.transform;return{u_translation:Sv(e,t,i),u_ratio:r/Q(t,1,a.zoom),u_device_pixel_ratio:e.pixelRatio,u_units_to_pixels:[1/a.pixelsToGLUnits[0],1/a.pixelsToGLUnits[1]]}},vv=(e,t,i,r,a)=>be(yv(e,t,i,r),{u_image:0,u_image_height:a}),xv=(e,t,i,r,a)=>{let n=e.transform,s=Tv(t,n);return{u_translation:Sv(e,t,i),u_texsize:t.imageAtlasTexture.size,u_ratio:r/Q(t,1,n.zoom),u_device_pixel_ratio:e.pixelRatio,u_image:0,u_scale:[s,a.fromScale,a.toScale],u_fade:a.t,u_units_to_pixels:[1/n.pixelsToGLUnits[0],1/n.pixelsToGLUnits[1]]}},bv=(e,t,i,r,a)=>{let n=Tv(t,e.transform);return be(yv(e,t,i,r),{u_tileratio:n,u_crossfade_from:a.fromScale,u_crossfade_to:a.toScale,u_image:0,u_mix:a.t,u_lineatlas_width:e.lineAtlas.width,u_lineatlas_height:e.lineAtlas.height})},wv=(e,t,i,r,a,n)=>{let s=Tv(t,e.transform);return be(yv(e,t,i,r),{u_image:0,u_image_height:n,u_tileratio:s,u_crossfade_from:a.fromScale,u_crossfade_to:a.toScale,u_image_dash:1,u_mix:a.t,u_lineatlas_width:e.lineAtlas.width,u_lineatlas_height:e.lineAtlas.height})};function Tv(e,t){return 1/Q(e,1,t.tileZoom)}function Sv(e,t,i){return se(e.transform,t,i.paint.get("line-translate"),i.paint.get("line-translate-anchor"))}var Pv=(e,t,i,r,a,n,s,o,l,h,u,c,p,d)=>{let f=s.transform;return{u_is_size_zoom_constant:+("constant"===e||"source"===e),u_is_size_feature_constant:+("constant"===e||"camera"===e),u_size_t:t?t.uSizeT:0,u_size:t?t.uSize:0,u_camera_to_center_distance:f.cameraToCenterDistance,u_pitch:f.pitch/360*2*Math.PI,u_rotate_symbol:+i,u_aspect_ratio:f.width/f.height,u_fade_change:s.options.fadeDuration?s.symbolFadeChange:1,u_label_plane_matrix:o,u_coord_matrix:l,u_is_text:+u,u_pitch_with_map:+r,u_is_along_line:a,u_is_variable_anchor:n,u_texsize:c,u_texture:0,u_translation:h,u_pitched_scale:p,u_is_offset:d}},Iv=(e,t,i,r,a,n,s,o,l,h,u,c,p,d,f)=>{let m=s.transform;return be(Pv(e,t,i,r,a,n,s,o,l,h,u,c,d,f),{u_gamma_scale:r?Math.cos(m.pitch*Math.PI/180)*m.cameraToCenterDistance:1,u_device_pixel_ratio:s.pixelRatio,u_is_halo:+!!p,u_is_plain:1})},Mv=(e,t,i,r,a,n,s,o,l,h,u,c,p,d)=>be(Iv(e,t,i,r,a,n,s,o,l,h,!0,u,!0,p,d),{u_texsize_icon:c,u_texture_icon:1}),Ev=(e,t)=>({u_opacity:e,u_color:t}),Av=(e,t,i,r,a)=>be(function(e,t,i,r){let a=i.patternAtlas.getPattern(e.from.toString()),n=i.patternAtlas.getPattern(e.to.toString()),{width:s,height:o}=i.patternAtlas.getPixelSize(),l=2**r.tileID.overscaledZ,h=r.tileSize*2**i.transform.tileZoom/l,u=h*(r.tileID.canonical.x+r.tileID.wrap*l),c=h*r.tileID.canonical.y;return{u_image:0,u_pattern_tl_a:a.tl,u_pattern_br_a:a.br,u_pattern_tl_b:n.tl,u_pattern_br_b:n.br,u_texsize:[s,o],u_mix:t.t,u_pattern_size_a:a.displaySize,u_pattern_size_b:n.displaySize,u_scale_a:t.fromScale,u_scale_b:t.toScale,u_tile_units_to_pixels:1/Q(r,1,i.transform.tileZoom),u_pixel_coord_upper:[u>>16,c>>16],u_pixel_coord_lower:[65535&u,65535&c]}}(i,a,t,r),{u_opacity:e}),Cv=(e,t)=>{},Dv={fillExtrusion:(e,t)=>({u_lightpos:new fl(e,t.u_lightpos),u_lightpos_globe:new fl(e,t.u_lightpos_globe),u_lightintensity:new pl(e,t.u_lightintensity),u_lightcolor:new fl(e,t.u_lightcolor),u_vertical_gradient:new pl(e,t.u_vertical_gradient),u_opacity:new pl(e,t.u_opacity),u_fill_translate:new dl(e,t.u_fill_translate)}),fillExtrusionPattern:(e,t)=>({u_lightpos:new fl(e,t.u_lightpos),u_lightpos_globe:new fl(e,t.u_lightpos_globe),u_lightintensity:new pl(e,t.u_lightintensity),u_lightcolor:new fl(e,t.u_lightcolor),u_vertical_gradient:new pl(e,t.u_vertical_gradient),u_height_factor:new pl(e,t.u_height_factor),u_opacity:new pl(e,t.u_opacity),u_fill_translate:new dl(e,t.u_fill_translate),u_image:new cl(e,t.u_image),u_texsize:new dl(e,t.u_texsize),u_pixel_coord_upper:new dl(e,t.u_pixel_coord_upper),u_pixel_coord_lower:new dl(e,t.u_pixel_coord_lower),u_scale:new fl(e,t.u_scale),u_fade:new pl(e,t.u_fade)}),fill:(e,t)=>({u_fill_translate:new dl(e,t.u_fill_translate)}),fillPattern:(e,t)=>({u_image:new cl(e,t.u_image),u_texsize:new dl(e,t.u_texsize),u_pixel_coord_upper:new dl(e,t.u_pixel_coord_upper),u_pixel_coord_lower:new dl(e,t.u_pixel_coord_lower),u_scale:new fl(e,t.u_scale),u_fade:new pl(e,t.u_fade),u_fill_translate:new dl(e,t.u_fill_translate)}),fillOutline:(e,t)=>({u_world:new dl(e,t.u_world),u_fill_translate:new dl(e,t.u_fill_translate)}),fillOutlinePattern:(e,t)=>({u_world:new dl(e,t.u_world),u_image:new cl(e,t.u_image),u_texsize:new dl(e,t.u_texsize),u_pixel_coord_upper:new dl(e,t.u_pixel_coord_upper),u_pixel_coord_lower:new dl(e,t.u_pixel_coord_lower),u_scale:new fl(e,t.u_scale),u_fade:new pl(e,t.u_fade),u_fill_translate:new dl(e,t.u_fill_translate)}),circle:(e,t)=>({u_camera_to_center_distance:new pl(e,t.u_camera_to_center_distance),u_scale_with_map:new cl(e,t.u_scale_with_map),u_pitch_with_map:new cl(e,t.u_pitch_with_map),u_extrude_scale:new dl(e,t.u_extrude_scale),u_device_pixel_ratio:new pl(e,t.u_device_pixel_ratio),u_globe_extrude_scale:new pl(e,t.u_globe_extrude_scale),u_translate:new dl(e,t.u_translate)}),collisionBox:(e,t)=>({u_pixel_extrude_scale:new dl(e,t.u_pixel_extrude_scale)}),collisionCircle:(e,t)=>({u_viewport_size:new dl(e,t.u_viewport_size)}),debug:(e,t)=>({u_color:new _l(e,t.u_color),u_overlay:new cl(e,t.u_overlay),u_overlay_scale:new pl(e,t.u_overlay_scale)}),depth:Cv,clippingMask:Cv,heatmap:(e,t)=>({u_extrude_scale:new pl(e,t.u_extrude_scale),u_intensity:new pl(e,t.u_intensity),u_globe_extrude_scale:new pl(e,t.u_globe_extrude_scale)}),heatmapTexture:(e,t)=>({u_matrix:new xl(e,t.u_matrix),u_world:new dl(e,t.u_world),u_image:new cl(e,t.u_image),u_color_ramp:new cl(e,t.u_color_ramp),u_opacity:new pl(e,t.u_opacity)}),hillshade:(e,t)=>({u_image:new cl(e,t.u_image),u_latrange:new dl(e,t.u_latrange),u_exaggeration:new pl(e,t.u_exaggeration),u_altitudes:new yl(e,t.u_altitudes),u_azimuths:new yl(e,t.u_azimuths),u_accent:new _l(e,t.u_accent),u_method:new cl(e,t.u_method),u_shadows:new gl(e,t.u_shadows),u_highlights:new gl(e,t.u_highlights)}),hillshadePrepare:(e,t)=>({u_matrix:new xl(e,t.u_matrix),u_image:new cl(e,t.u_image),u_dimension:new dl(e,t.u_dimension),u_zoom:new pl(e,t.u_zoom),u_unpack:new ml(e,t.u_unpack)}),colorRelief:(e,t)=>({u_image:new cl(e,t.u_image),u_unpack:new ml(e,t.u_unpack),u_dimension:new dl(e,t.u_dimension),u_elevation_stops:new cl(e,t.u_elevation_stops),u_color_stops:new cl(e,t.u_color_stops),u_color_ramp_size:new cl(e,t.u_color_ramp_size),u_opacity:new pl(e,t.u_opacity)}),line:(e,t)=>({u_translation:new dl(e,t.u_translation),u_ratio:new pl(e,t.u_ratio),u_device_pixel_ratio:new pl(e,t.u_device_pixel_ratio),u_units_to_pixels:new dl(e,t.u_units_to_pixels)}),lineGradient:(e,t)=>({u_translation:new dl(e,t.u_translation),u_ratio:new pl(e,t.u_ratio),u_device_pixel_ratio:new pl(e,t.u_device_pixel_ratio),u_units_to_pixels:new dl(e,t.u_units_to_pixels),u_image:new cl(e,t.u_image),u_image_height:new pl(e,t.u_image_height)}),linePattern:(e,t)=>({u_translation:new dl(e,t.u_translation),u_texsize:new dl(e,t.u_texsize),u_ratio:new pl(e,t.u_ratio),u_device_pixel_ratio:new pl(e,t.u_device_pixel_ratio),u_image:new cl(e,t.u_image),u_units_to_pixels:new dl(e,t.u_units_to_pixels),u_scale:new fl(e,t.u_scale),u_fade:new pl(e,t.u_fade)}),lineSDF:(e,t)=>({u_translation:new dl(e,t.u_translation),u_ratio:new pl(e,t.u_ratio),u_device_pixel_ratio:new pl(e,t.u_device_pixel_ratio),u_units_to_pixels:new dl(e,t.u_units_to_pixels),u_image:new cl(e,t.u_image),u_mix:new pl(e,t.u_mix),u_tileratio:new pl(e,t.u_tileratio),u_crossfade_from:new pl(e,t.u_crossfade_from),u_crossfade_to:new pl(e,t.u_crossfade_to),u_lineatlas_width:new pl(e,t.u_lineatlas_width),u_lineatlas_height:new pl(e,t.u_lineatlas_height)}),lineGradientSDF:(e,t)=>({u_translation:new dl(e,t.u_translation),u_ratio:new pl(e,t.u_ratio),u_device_pixel_ratio:new pl(e,t.u_device_pixel_ratio),u_units_to_pixels:new dl(e,t.u_units_to_pixels),u_image:new cl(e,t.u_image),u_image_height:new pl(e,t.u_image_height),u_tileratio:new pl(e,t.u_tileratio),u_crossfade_from:new pl(e,t.u_crossfade_from),u_crossfade_to:new pl(e,t.u_crossfade_to),u_image_dash:new cl(e,t.u_image_dash),u_mix:new pl(e,t.u_mix),u_lineatlas_width:new pl(e,t.u_lineatlas_width),u_lineatlas_height:new pl(e,t.u_lineatlas_height)}),layerOpacity:(e,t)=>({u_image:new cl(e,t.u_image),u_opacity:new pl(e,t.u_opacity)}),raster:(e,t)=>({u_tl_parent:new dl(e,t.u_tl_parent),u_scale_parent:new pl(e,t.u_scale_parent),u_buffer_scale:new pl(e,t.u_buffer_scale),u_perspective_transform:new fl(e,t.u_perspective_transform),u_fade_t:new pl(e,t.u_fade_t),u_opacity:new pl(e,t.u_opacity),u_image0:new cl(e,t.u_image0),u_image1:new cl(e,t.u_image1),u_brightness_low:new pl(e,t.u_brightness_low),u_brightness_high:new pl(e,t.u_brightness_high),u_saturation_factor:new pl(e,t.u_saturation_factor),u_contrast_factor:new pl(e,t.u_contrast_factor),u_spin_weights:new fl(e,t.u_spin_weights),u_coords_top:new ml(e,t.u_coords_top),u_coords_bottom:new ml(e,t.u_coords_bottom)}),symbolIcon:(e,t)=>({u_is_size_zoom_constant:new cl(e,t.u_is_size_zoom_constant),u_is_size_feature_constant:new cl(e,t.u_is_size_feature_constant),u_size_t:new pl(e,t.u_size_t),u_size:new pl(e,t.u_size),u_camera_to_center_distance:new pl(e,t.u_camera_to_center_distance),u_pitch:new pl(e,t.u_pitch),u_rotate_symbol:new cl(e,t.u_rotate_symbol),u_aspect_ratio:new pl(e,t.u_aspect_ratio),u_fade_change:new pl(e,t.u_fade_change),u_label_plane_matrix:new xl(e,t.u_label_plane_matrix),u_coord_matrix:new xl(e,t.u_coord_matrix),u_is_text:new cl(e,t.u_is_text),u_pitch_with_map:new cl(e,t.u_pitch_with_map),u_is_along_line:new cl(e,t.u_is_along_line),u_is_variable_anchor:new cl(e,t.u_is_variable_anchor),u_texsize:new dl(e,t.u_texsize),u_texture:new cl(e,t.u_texture),u_translation:new dl(e,t.u_translation),u_pitched_scale:new pl(e,t.u_pitched_scale),u_is_offset:new cl(e,t.u_is_offset)}),symbolSDF:(e,t)=>({u_is_size_zoom_constant:new cl(e,t.u_is_size_zoom_constant),u_is_size_feature_constant:new cl(e,t.u_is_size_feature_constant),u_size_t:new pl(e,t.u_size_t),u_size:new pl(e,t.u_size),u_camera_to_center_distance:new pl(e,t.u_camera_to_center_distance),u_pitch:new pl(e,t.u_pitch),u_rotate_symbol:new cl(e,t.u_rotate_symbol),u_aspect_ratio:new pl(e,t.u_aspect_ratio),u_fade_change:new pl(e,t.u_fade_change),u_label_plane_matrix:new xl(e,t.u_label_plane_matrix),u_coord_matrix:new xl(e,t.u_coord_matrix),u_is_text:new cl(e,t.u_is_text),u_pitch_with_map:new cl(e,t.u_pitch_with_map),u_is_along_line:new cl(e,t.u_is_along_line),u_is_variable_anchor:new cl(e,t.u_is_variable_anchor),u_texsize:new dl(e,t.u_texsize),u_texture:new cl(e,t.u_texture),u_gamma_scale:new pl(e,t.u_gamma_scale),u_device_pixel_ratio:new pl(e,t.u_device_pixel_ratio),u_is_halo:new cl(e,t.u_is_halo),u_is_plain:new cl(e,t.u_is_plain),u_translation:new dl(e,t.u_translation),u_pitched_scale:new pl(e,t.u_pitched_scale),u_is_offset:new cl(e,t.u_is_offset)}),symbolTextAndIcon:(e,t)=>({u_is_size_zoom_constant:new cl(e,t.u_is_size_zoom_constant),u_is_size_feature_constant:new cl(e,t.u_is_size_feature_constant),u_size_t:new pl(e,t.u_size_t),u_size:new pl(e,t.u_size),u_camera_to_center_distance:new pl(e,t.u_camera_to_center_distance),u_pitch:new pl(e,t.u_pitch),u_rotate_symbol:new cl(e,t.u_rotate_symbol),u_aspect_ratio:new pl(e,t.u_aspect_ratio),u_fade_change:new pl(e,t.u_fade_change),u_label_plane_matrix:new xl(e,t.u_label_plane_matrix),u_coord_matrix:new xl(e,t.u_coord_matrix),u_is_text:new cl(e,t.u_is_text),u_pitch_with_map:new cl(e,t.u_pitch_with_map),u_is_along_line:new cl(e,t.u_is_along_line),u_is_variable_anchor:new cl(e,t.u_is_variable_anchor),u_texsize:new dl(e,t.u_texsize),u_texsize_icon:new dl(e,t.u_texsize_icon),u_texture:new cl(e,t.u_texture),u_texture_icon:new cl(e,t.u_texture_icon),u_gamma_scale:new pl(e,t.u_gamma_scale),u_device_pixel_ratio:new pl(e,t.u_device_pixel_ratio),u_is_halo:new cl(e,t.u_is_halo),u_translation:new dl(e,t.u_translation),u_pitched_scale:new pl(e,t.u_pitched_scale),u_is_offset:new cl(e,t.u_is_offset)}),background:(e,t)=>({u_opacity:new pl(e,t.u_opacity),u_color:new _l(e,t.u_color)}),backgroundPattern:(e,t)=>({u_opacity:new pl(e,t.u_opacity),u_image:new cl(e,t.u_image),u_pattern_tl_a:new dl(e,t.u_pattern_tl_a),u_pattern_br_a:new dl(e,t.u_pattern_br_a),u_pattern_tl_b:new dl(e,t.u_pattern_tl_b),u_pattern_br_b:new dl(e,t.u_pattern_br_b),u_texsize:new dl(e,t.u_texsize),u_mix:new pl(e,t.u_mix),u_pattern_size_a:new dl(e,t.u_pattern_size_a),u_pattern_size_b:new dl(e,t.u_pattern_size_b),u_scale_a:new pl(e,t.u_scale_a),u_scale_b:new pl(e,t.u_scale_b),u_pixel_coord_upper:new dl(e,t.u_pixel_coord_upper),u_pixel_coord_lower:new dl(e,t.u_pixel_coord_lower),u_tile_units_to_pixels:new pl(e,t.u_tile_units_to_pixels)}),terrain:(e,t)=>({u_texture:new cl(e,t.u_texture),u_ele_delta:new pl(e,t.u_ele_delta),u_fog_matrix:new xl(e,t.u_fog_matrix),u_fog_color:new _l(e,t.u_fog_color),u_fog_ground_blend:new pl(e,t.u_fog_ground_blend),u_fog_ground_blend_opacity:new pl(e,t.u_fog_ground_blend_opacity),u_horizon_color:new _l(e,t.u_horizon_color),u_horizon_fog_blend:new pl(e,t.u_horizon_fog_blend),u_is_globe_mode:new pl(e,t.u_is_globe_mode)}),terrainDepth:(e,t)=>({u_ele_delta:new pl(e,t.u_ele_delta)}),terrainCoords:(e,t)=>({u_texture:new cl(e,t.u_texture),u_terrain_coords_id:new pl(e,t.u_terrain_coords_id),u_ele_delta:new pl(e,t.u_ele_delta)}),atmosphere:(e,t)=>({u_sun_pos:new fl(e,t.u_sun_pos),u_atmosphere_blend:new pl(e,t.u_atmosphere_blend),u_globe_position:new fl(e,t.u_globe_position),u_globe_radius:new pl(e,t.u_globe_radius),u_inv_proj_matrix:new xl(e,t.u_inv_proj_matrix)}),sky:(e,t)=>({u_sky_color:new _l(e,t.u_sky_color),u_horizon_color:new _l(e,t.u_horizon_color),u_horizon:new dl(e,t.u_horizon),u_horizon_normal:new dl(e,t.u_horizon_normal),u_sky_horizon_blend:new pl(e,t.u_sky_horizon_blend),u_sky_blend:new pl(e,t.u_sky_blend)})},zv=class{constructor(e,t,i){this.context=e;let r=e.gl;this.buffer=r.createBuffer(),this.dynamicDraw=!!i,this.context.unbindVAO(),e.bindElementBuffer.set(this.buffer),r.bufferData(r.ELEMENT_ARRAY_BUFFER,t.arrayBuffer,this.dynamicDraw?r.DYNAMIC_DRAW:r.STATIC_DRAW),this.dynamicDraw||t.freeBufferAfterUpload()}bind(){this.context.bindElementBuffer.set(this.buffer)}updateData(e){let t=this.context.gl;if(!this.dynamicDraw)throw Error("Attempted to update data while not in dynamic mode.");this.context.unbindVAO(),this.bind(),t.bufferSubData(t.ELEMENT_ARRAY_BUFFER,0,e.arrayBuffer)}destroy(){let e=this.context.gl;this.buffer&&(e.deleteBuffer(this.buffer),delete this.buffer)}},Rv={Int8:"BYTE",Uint8:"UNSIGNED_BYTE",Int16:"SHORT",Uint16:"UNSIGNED_SHORT",Int32:"INT",Uint32:"UNSIGNED_INT",Float32:"FLOAT"},kv=class{constructor(e,t,i,r){this.length=t.length,this.attributes=i,this.itemSize=t.bytesPerElement,this.dynamicDraw=r,this.context=e;let a=e.gl;this.buffer=a.createBuffer(),e.bindVertexBuffer.set(this.buffer),a.bufferData(a.ARRAY_BUFFER,t.arrayBuffer,this.dynamicDraw?a.DYNAMIC_DRAW:a.STATIC_DRAW),this.dynamicDraw||t.freeBufferAfterUpload()}bind(){this.context.bindVertexBuffer.set(this.buffer)}updateData(e){if(e.length!==this.length)throw Error(`Length of new data is ${e.length}, which doesn't match current length of ${this.length}`);let t=this.context.gl;this.bind(),t.bufferSubData(t.ARRAY_BUFFER,0,e.arrayBuffer)}enableAttributes(e,t){for(let i of this.attributes){let r=t.attributes[i.name];void 0!==r&&e.enableVertexAttribArray(r.location)}}setVertexAttribPointers(e,t,i){for(let r of this.attributes){let a=t.attributes[r.name];if(void 0!==a){let t=r.offset+this.itemSize*(i||0);a.isInteger?e.vertexAttribIPointer(a.location,r.components,e[Rv[r.type]],this.itemSize,t):e.vertexAttribPointer(a.location,r.components,e[Rv[r.type]],!1,this.itemSize,t)}}}destroy(){let e=this.context.gl;this.buffer&&(e.deleteBuffer(this.buffer),delete this.buffer)}},Lv=class{constructor(e){this.gl=e.gl,this.default=this.getDefault(),this.current=this.default,this.dirty=!1}get(){return this.current}set(e){}getDefault(){return this.default}setDefault(){this.set(this.default)}},Fv=class extends Lv{getDefault(){return Si.transparent}set(e){let t=this.current;e.r===t.r&&e.g===t.g&&e.b===t.b&&e.a===t.a&&!this.dirty||(this.gl.clearColor(e.r,e.g,e.b,e.a),this.current=e,this.dirty=!1)}},Bv=class extends Lv{getDefault(){return 1}set(e){e===this.current&&!this.dirty||(this.gl.clearDepth(e),this.current=e,this.dirty=!1)}},Ov=class extends Lv{getDefault(){return 0}set(e){e===this.current&&!this.dirty||(this.gl.clearStencil(e),this.current=e,this.dirty=!1)}},Vv=class extends Lv{getDefault(){return[!0,!0,!0,!0]}set(e){let t=this.current;e[0]===t[0]&&e[1]===t[1]&&e[2]===t[2]&&e[3]===t[3]&&!this.dirty||(this.gl.colorMask(e[0],e[1],e[2],e[3]),this.current=e,this.dirty=!1)}},jv=class extends Lv{getDefault(){return!0}set(e){e===this.current&&!this.dirty||(this.gl.depthMask(e),this.current=e,this.dirty=!1)}},Nv=class extends Lv{getDefault(){return 255}set(e){e===this.current&&!this.dirty||(this.gl.stencilMask(e),this.current=e,this.dirty=!1)}},Uv=class extends Lv{getDefault(){return{func:this.gl.ALWAYS,ref:0,mask:255}}set(e){let t=this.current;e.func===t.func&&e.ref===t.ref&&e.mask===t.mask&&!this.dirty||(this.gl.stencilFunc(e.func,e.ref,e.mask),this.current=e,this.dirty=!1)}},Gv=class extends Lv{getDefault(){let e=this.gl;return[e.KEEP,e.KEEP,e.KEEP]}set(e){let t=this.current;e[0]===t[0]&&e[1]===t[1]&&e[2]===t[2]&&!this.dirty||(this.gl.stencilOp(e[0],e[1],e[2]),this.current=e,this.dirty=!1)}},$v=class extends Lv{getDefault(){return!1}set(e){if(e===this.current&&!this.dirty)return;let t=this.gl;e?t.enable(t.STENCIL_TEST):t.disable(t.STENCIL_TEST),this.current=e,this.dirty=!1}},Zv=class extends Lv{getDefault(){return[0,1]}set(e){let t=this.current;e[0]===t[0]&&e[1]===t[1]&&!this.dirty||(this.gl.depthRange(e[0],e[1]),this.current=e,this.dirty=!1)}},qv=class extends Lv{getDefault(){return!1}set(e){if(e===this.current&&!this.dirty)return;let t=this.gl;e?t.enable(t.DEPTH_TEST):t.disable(t.DEPTH_TEST),this.current=e,this.dirty=!1}},Wv=class extends Lv{getDefault(){return this.gl.LESS}set(e){e===this.current&&!this.dirty||(this.gl.depthFunc(e),this.current=e,this.dirty=!1)}},Hv=class extends Lv{getDefault(){return!1}set(e){if(e===this.current&&!this.dirty)return;let t=this.gl;e?t.enable(t.BLEND):t.disable(t.BLEND),this.current=e,this.dirty=!1}},Xv=class extends Lv{getDefault(){let e=this.gl;return[e.ONE,e.ZERO]}set(e){let t=this.current;e[0]===t[0]&&e[1]===t[1]&&!this.dirty||(this.gl.blendFunc(e[0],e[1]),this.current=e,this.dirty=!1)}},Yv=class extends Lv{getDefault(){return Si.transparent}set(e){let t=this.current;e.r===t.r&&e.g===t.g&&e.b===t.b&&e.a===t.a&&!this.dirty||(this.gl.blendColor(e.r,e.g,e.b,e.a),this.current=e,this.dirty=!1)}},Kv=class extends Lv{getDefault(){return this.gl.FUNC_ADD}set(e){e===this.current&&!this.dirty||(this.gl.blendEquation(e),this.current=e,this.dirty=!1)}},Jv=class extends Lv{getDefault(){return!1}set(e){if(e===this.current&&!this.dirty)return;let t=this.gl;e?t.enable(t.CULL_FACE):t.disable(t.CULL_FACE),this.current=e,this.dirty=!1}},Qv=class extends Lv{getDefault(){return this.gl.BACK}set(e){e===this.current&&!this.dirty||(this.gl.cullFace(e),this.current=e,this.dirty=!1)}},ex=class extends Lv{getDefault(){return this.gl.CCW}set(e){e===this.current&&!this.dirty||(this.gl.frontFace(e),this.current=e,this.dirty=!1)}},tx=class extends Lv{getDefault(){return null}set(e){e===this.current&&!this.dirty||(this.gl.useProgram(e),this.current=e,this.dirty=!1)}},ix=class extends Lv{getDefault(){return this.gl.TEXTURE0}set(e){e===this.current&&!this.dirty||(this.gl.activeTexture(e),this.current=e,this.dirty=!1)}},rx=class extends Lv{getDefault(){let e=this.gl;return[0,0,e.drawingBufferWidth,e.drawingBufferHeight]}set(e){let t=this.current;e[0]===t[0]&&e[1]===t[1]&&e[2]===t[2]&&e[3]===t[3]&&!this.dirty||(this.gl.viewport(e[0],e[1],e[2],e[3]),this.current=e,this.dirty=!1)}},ax=class extends Lv{getDefault(){return null}set(e){if(e===this.current&&!this.dirty)return;let t=this.gl;t.bindFramebuffer(t.FRAMEBUFFER,e),this.current=e,this.dirty=!1}},nx=class extends Lv{getDefault(){return null}set(e){if(e===this.current&&!this.dirty)return;let t=this.gl;t.bindRenderbuffer(t.RENDERBUFFER,e),this.current=e,this.dirty=!1}},sx=class extends Lv{getDefault(){return null}set(e){if(e===this.current&&!this.dirty)return;let t=this.gl;t.bindTexture(t.TEXTURE_2D,e),this.current=e,this.dirty=!1}},ox=class extends Lv{getDefault(){return null}set(e){if(e===this.current&&!this.dirty)return;let t=this.gl;t.bindBuffer(t.ARRAY_BUFFER,e),this.current=e,this.dirty=!1}},lx=class extends Lv{getDefault(){return null}set(e){let t=this.gl;t.bindBuffer(t.ELEMENT_ARRAY_BUFFER,e),this.current=e,this.dirty=!1}},hx=class extends Lv{getDefault(){return null}set(e){e===this.current&&!this.dirty||(this.gl.bindVertexArray(e),this.current=e,this.dirty=!1)}},ux=class extends Lv{getDefault(){return 4}set(e){if(e===this.current&&!this.dirty)return;let t=this.gl;t.pixelStorei(t.UNPACK_ALIGNMENT,e),this.current=e,this.dirty=!1}},cx=class extends Lv{getDefault(){return!1}set(e){if(e===this.current&&!this.dirty)return;let t=this.gl;t.pixelStorei(t.UNPACK_PREMULTIPLY_ALPHA_WEBGL,e),this.current=e,this.dirty=!1}},px=class extends Lv{getDefault(){return!1}set(e){if(e===this.current&&!this.dirty)return;let t=this.gl;t.pixelStorei(t.UNPACK_FLIP_Y_WEBGL,e),this.current=e,this.dirty=!1}},dx=class extends Lv{constructor(e,t){super(e),this.context=e,this.parent=t}getDefault(){return null}},fx=class extends dx{setDirty(){this.dirty=!0}set(e){if(e===this.current&&!this.dirty)return;this.context.bindFramebuffer.set(this.parent);let t=this.gl;t.framebufferTexture2D(t.FRAMEBUFFER,t.COLOR_ATTACHMENT0,t.TEXTURE_2D,e,0),this.current=e,this.dirty=!1}},mx=class extends dx{set(e){if(e===this.current&&!this.dirty)return;this.context.bindFramebuffer.set(this.parent);let t=this.gl;t.framebufferRenderbuffer(t.FRAMEBUFFER,t.DEPTH_ATTACHMENT,t.RENDERBUFFER,e),this.current=e,this.dirty=!1}},_x=class extends dx{set(e){if(e===this.current&&!this.dirty)return;this.context.bindFramebuffer.set(this.parent);let t=this.gl;t.framebufferRenderbuffer(t.FRAMEBUFFER,t.DEPTH_STENCIL_ATTACHMENT,t.RENDERBUFFER,e),this.current=e,this.dirty=!1}},gx=class{constructor(e,t,i,r,a){this.context=e,this.width=t,this.height=i;let n=e.gl,s=this.framebuffer=n.createFramebuffer();if(this.colorAttachment=new fx(e,s),r)this.depthAttachment=a?new _x(e,s):new mx(e,s);else if(a)throw Error("Stencil cannot be set without depth")}destroy(){let e=this.context.gl,t=this.colorAttachment.get();if(t&&e.deleteTexture(t),this.depthAttachment){let t=this.depthAttachment.get();t&&e.deleteRenderbuffer(t)}e.deleteFramebuffer(this.framebuffer)}},yx=class{constructor(e,t,i){this.blendFunction=e,this.blendColor=t,this.mask=i}};yx.Replace=[1,0],yx.disabled=new yx(yx.Replace,Si.transparent,[!1,!1,!1,!1]),yx.unblended=new yx(yx.Replace,Si.transparent,[!0,!0,!0,!0]),yx.alphaBlended=new yx([1,771],Si.transparent,[!0,!0,!0,!0]);var vx=class{constructor(e){this.gl=e,this.clearColor=new Fv(this),this.clearDepth=new Bv(this),this.clearStencil=new Ov(this),this.colorMask=new Vv(this),this.depthMask=new jv(this),this.stencilMask=new Nv(this),this.stencilFunc=new Uv(this),this.stencilOp=new Gv(this),this.stencilTest=new $v(this),this.depthRange=new Zv(this),this.depthTest=new qv(this),this.depthFunc=new Wv(this),this.blend=new Hv(this),this.blendFunc=new Xv(this),this.blendColor=new Yv(this),this.blendEquation=new Kv(this),this.cullFace=new Jv(this),this.cullFaceSide=new Qv(this),this.frontFace=new ex(this),this.program=new tx(this),this.activeTexture=new ix(this),this.viewport=new rx(this),this.bindFramebuffer=new ax(this),this.bindRenderbuffer=new nx(this),this.bindTexture=new sx(this),this.bindVertexBuffer=new ox(this),this.bindElementBuffer=new lx(this),this.bindVertexArray=new hx(this),this.pixelStoreUnpack=new ux(this),this.pixelStoreUnpackPremultiplyAlpha=new cx(this),this.pixelStoreUnpackFlipY=new px(this),this.extTextureFilterAnisotropic=e.getExtension("EXT_texture_filter_anisotropic"),this.extTextureFilterAnisotropic&&(this.extTextureFilterAnisotropicMax=e.getParameter(this.extTextureFilterAnisotropic.MAX_TEXTURE_MAX_ANISOTROPY_EXT)),this.maxTextureSize=e.getParameter(e.MAX_TEXTURE_SIZE),e.getExtension("EXT_color_buffer_half_float"),e.getExtension("EXT_color_buffer_float")}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.bindVertexArray.dirty=!0,this.pixelStoreUnpack.dirty=!0,this.pixelStoreUnpackPremultiplyAlpha.dirty=!0,this.pixelStoreUnpackFlipY.dirty=!0}setCustomLayerDefaults(){this.unbindVAO(),this.cullFace.setDefault(),this.activeTexture.setDefault(),this.pixelStoreUnpack.setDefault(),this.pixelStoreUnpackPremultiplyAlpha.setDefault(),this.pixelStoreUnpackFlipY.setDefault()}createIndexBuffer(e,t){return new zv(this,e,t)}createVertexBuffer(e,t,i){return new kv(this,e,t,i)}createRenderbuffer(e,t,i){let r=this.gl,a=r.createRenderbuffer();return this.bindRenderbuffer.set(a),r.renderbufferStorage(r.RENDERBUFFER,e,t,i),this.bindRenderbuffer.set(null),a}createFramebuffer(e,t,i,r){return new gx(this,e,t,i,r)}clear({color:e,depth:t,stencil:i}){let r=this.gl,a=0;e&&(a|=r.COLOR_BUFFER_BIT,this.clearColor.set(e),this.colorMask.set([!0,!0,!0,!0])),void 0!==t&&(a|=r.DEPTH_BUFFER_BIT,this.depthRange.set([0,1]),this.clearDepth.set(t),this.depthMask.set(!0)),void 0!==i&&(a|=r.STENCIL_BUFFER_BIT,this.clearStencil.set(i),this.stencilMask.set(255)),r.clear(a)}setCullFace(e){!1===e.enable?this.cullFace.set(!1):(this.cullFace.set(!0),this.cullFaceSide.set(e.mode),this.frontFace.set(e.frontFace))}setDepthMode(e){e.func!==this.gl.ALWAYS||e.mask?(this.depthTest.set(!0),this.depthFunc.set(e.func),this.depthMask.set(e.mask),this.depthRange.set(e.range)):this.depthTest.set(!1)}setStencilMode(e){e.test.func!==this.gl.ALWAYS||e.mask?(this.stencilTest.set(!0),this.stencilMask.set(e.mask),this.stencilOp.set([e.fail,e.depthFail,e.pass]),this.stencilFunc.set({func:e.test.func,ref:e.ref,mask:e.test.mask})):this.stencilTest.set(!1)}setColorMode(e){Ce(e.blendFunction,yx.Replace)?this.blend.set(!1):(this.blend.set(!0),this.blendFunc.set(e.blendFunction),this.blendColor.set(e.blendColor)),this.colorMask.set(e.mask)}createVertexArray(){return this.gl.createVertexArray()}deleteVertexArray(e){this.gl.deleteVertexArray(e)}unbindVAO(){this.bindVertexArray.set(null)}},xx=class{constructor(e,t,i){this.func=e,this.mask=t,this.range=i}};xx.ReadOnly=!1,xx.ReadWrite=!0,xx.disabled=new xx(519,xx.ReadOnly,[0,1]);var bx=7680,wx=class{constructor(e,t,i,r,a,n){this.test=e,this.ref=t,this.mask=i,this.fail=r,this.depthFail=a,this.pass=n}};wx.disabled=new wx({func:519,mask:0},0,0,bx,bx,bx);var Tx,Sx=2305,Px=class{constructor(e,t,i){this.enable=e,this.mode=t,this.frontFace=i}};function Ix(e,t,i,r,a){let n=e.context,s=e.transform,o=n.gl,l=e.useProgram("collisionBox"),h=[],u=0,c=0;for(let g of r){let r=t.getTile(g).getBucket(i);if(!r)continue;let p=a?r.textCollisionBox:r.iconCollisionBox,d=r.collisionCircleArray;d.length>0&&(h.push({circleArray:d,circleOffset:c,coord:g}),u+=d.length/4,c=u),p&&l.draw(n,o.LINES,xx.disabled,wx.disabled,e.colorModeForRenderPass(),Px.disabled,hv(e.transform),e.style.map.terrain?.getTerrainData(g),s.getProjectionData({overscaledTileID:g,applyGlobeMatrix:!0,applyTerrainMatrix:!0}),i.id,p.layoutVertexBuffer,p.indexBuffer,p.segments,null,e.transform.zoom,null,null,p.collisionVertexBuffer)}if(!a||!h.length)return;let p=e.useProgram("collisionCircle"),d=new Zo;d.resize(4*u),d._trim();let f=0;for(let g of h)for(let e=0;e<g.circleArray.length/4;e++){let t=4*e,i=g.circleArray[t+0],r=g.circleArray[t+1],a=g.circleArray[t+2],n=g.circleArray[t+3];d.emplace(f++,i,r,a,n,0),d.emplace(f++,i,r,a,n,1),d.emplace(f++,i,r,a,n,2),d.emplace(f++,i,r,a,n,3)}(!Tx||Tx.length<2*u)&&(Tx=function(e){let t=2*e,i=new Wo;i.resize(t),i._trim();for(let r=0;r<t;r++){let e=6*r;i.uint16[e+0]=4*r+0,i.uint16[e+1]=4*r+1,i.uint16[e+2]=4*r+2,i.uint16[e+3]=4*r+2,i.uint16[e+4]=4*r+3,i.uint16[e+5]=4*r+0}return i}(u));let m=n.createIndexBuffer(Tx,!0),_=n.createVertexBuffer(d,$c.members,!0);for(let g of h){let t=uv(e.transform);p.draw(n,o.TRIANGLES,xx.disabled,wx.disabled,e.colorModeForRenderPass(),Px.disabled,t,e.style.map.terrain?.getTerrainData(g.coord),null,i.id,_,m,Qo.simpleSegment(0,2*g.circleOffset,g.circleArray.length,g.circleArray.length/2),null,e.transform.zoom,null,null,null)}_.destroy(),m.destroy()}Px.disabled=new Px(!1,1029,Sx),Px.backCCW=new Px(!0,1029,Sx),Px.frontCCW=new Px(!0,1028,Sx);var Mx=_(/* @__PURE__ */new Float32Array(16));function Ex(e,t,i,r,a,n){let{horizontalAlign:s,verticalAlign:o}=np(e),l=-(o-.5)*i;return new u((-(s-.5)*t/a+r[0])*n,(l/a+r[1])*n)}function Ax(e,t,i,r,a,n){let s=t.tileAnchorPoint.add(new u(t.translation[0],t.translation[1]));if(t.pitchWithMap){let e=r.mult(n);i||(e=e.rotate(-a));let o=s.add(e);return sg(o.x,o.y,t.pitchedLabelPlaneMatrix,t.getElevation).point}if(i){let i=mg(t.tileAnchorPoint.x+1,t.tileAnchorPoint.y,t).point.sub(e),a=Math.atan(i.y/i.x)+(i.x<0?Math.PI:0);return e.add(r.rotate(a))}return e.add(r)}function Cx(e,t,i,r,a,n,s,o,l,h,c,p){let d=e.text.placedSymbolArray,f=e.text.dynamicLayoutVertexArray,m=e.icon.dynamicLayoutVertexArray,_={};f.clear();for(let g=0;g<d.length;g++){let m=d.get(g),y=e.allowVerticalPlacement&&!m.placedOrientation,v=m.hidden||!m.crossTileID||y?null:r[m.crossTileID];if(v){let r=new u(m.anchorX,m.anchorY),d={getElevation:p,width:a.width,height:a.height,pitchedLabelPlaneMatrix:n,lineVertexArray:null,pitchWithMap:i,transform:a,projectionCache:null,tileAnchorPoint:r,translation:h,unwrappedTileID:c},g=i?gg(r.x,r.y,d):mg(r.x,r.y,d),y=og(a.cameraToCenterDistance,g.signedDistanceFromCamera),x=op(e.textSizeData,o,m)*y/24;i&&(x*=e.tilePixelRatio/s);let{width:b,height:w,anchor:T,textOffset:S,textBoxScale:P}=v,I=Ex(T,b,w,S,P,x),M=a.getPitchedTextCorrection(r.x+h[0],r.y+h[1],c),E=Ax(g.point,d,t,I,-a.bearingInRadians,M),A=e.allowVerticalPlacement&&2===m.placedOrientation?Math.PI/2:0;for(let e=0;e<m.numGlyphs;e++)pp(f,E,A);l&&m.associatedIconIndex>=0&&(_[m.associatedIconIndex]={shiftedAnchor:E,angle:A})}else wg(m.numGlyphs,f)}if(l){m.clear();let t=e.icon.placedSymbolArray;for(let e=0;e<t.length;e++){let i=t.get(e);if(i.hidden)wg(i.numGlyphs,m);else{let t=_[e];if(t)for(let e=0;e<i.numGlyphs;e++)pp(m,t.shiftedAnchor,t.angle);else wg(i.numGlyphs,m)}}e.icon.dynamicLayoutVertexBuffer.updateData(m)}e.text.dynamicLayoutVertexBuffer.updateData(f)}function Dx(e,t,i){return i.iconsInText&&t?"symbolTextAndIcon":e?"symbolSDF":"symbolIcon"}function zx(e,t,i,r,a,n,s,o,l,h,u,c,p){let d=e.context,m=d.gl,_=e.transform,g="map"===o,y="map"===l,v="viewport"!==o&&"point"!==i.layout.get("symbol-placement"),x=g&&!y&&!v,b=!i.layout.get("symbol-sort-key").isConstant(),w=!1,T=e.getDepthModeForSublayer(0,xx.ReadOnly),S=i._unevaluatedLayout.hasValue("text-variable-anchor")||i._unevaluatedLayout.hasValue("text-variable-anchor-offset"),P=[],I=_.getCircleRadiusCorrection();for(let A of r){let r=t.getTile(A),o=r.getBucket(i);if(!o)continue;let l=a?o.text:o.icon;if(!l?.segments.get().length||!l.hasVisibleVertices)continue;let u,c,d,T,M=l.programConfigurations.get(i.id),E=a||o.sdfIcons,C=a?o.textSizeData:o.iconSizeData,D=y||0!==_.pitch,z=e.useProgram(Dx(E,a,o),M),R=lp(C,_.zoom),k=e.style.map.terrain?.getTerrainData(A),L=[0,0],F=null;if(a){if(c=r.glyphAtlasTexture,d=m.LINEAR,u=r.glyphAtlasTexture.size,o.iconsInText){L=r.imageAtlasTexture.size,F=r.imageAtlasTexture;let t="composite"===C.kind||"camera"===C.kind;T=D||e.options.rotating||e.options.zooming||t?m.LINEAR:m.NEAREST}}else{let t=1!==i.layout.get("icon-size").constantOr(0)||o.iconsNeedLinear;c=r.imageAtlasTexture,d=E||e.options.rotating||e.options.zooming||t||D?m.LINEAR:m.NEAREST,u=r.imageAtlasTexture.size}let B=Q(r,1,e.transform.zoom),O=rg(g,e.transform,B),V=ag(y,g,e.transform,B),j=se(_,r,n,s),N=_.getProjectionData({overscaledTileID:A,applyGlobeMatrix:!p,applyTerrainMatrix:!0}),U=S&&o.hasTextData(),G="none"!==i.layout.get("icon-text-fit")&&U&&o.hasIconData(),$=i._unevaluatedLayout.hasValue("icon-offset");if(v){let t=f();tg(t,O);let r=e.style.map.terrain?(t,i)=>e.style.map.terrain.getElevation(A,t,i):null;hg(o,e,a,O,t,y,h,"map"===i.layout.get("text-rotation-alignment"),A.toUnwrapped(),_.width,_.height,j,r)}let Z,q=a&&S||G,W=y?O:e.transform.clipSpaceToPixelsMatrix,H=v||q?Mx:W,X=E&&0!==i.paint.get(a?"text-halo-width":"icon-halo-width").constantOr(1);Z=E?o.iconsInText?Mv(C.kind,R,x,y,v,q,e,H,V,j,u,L,I,$):Iv(C.kind,R,x,y,v,q,e,H,V,j,a,u,X,I,$):Pv(C.kind,R,x,y,v,q,e,H,V,j,a,u,I,$);let Y={program:z,buffers:l,uniformValues:Z,projectionData:N,atlasTexture:c,atlasTextureIcon:F,atlasInterpolation:d,atlasInterpolationIcon:T,isSDF:E,hasHalo:X};if(b&&o.canOverlap){w=!0;let e=l.segments.get();for(let t of e)P.push({segments:new Qo([t]),sortKey:t.sortKey,state:Y,terrainData:k})}else P.push({segments:l.segments,sortKey:0,state:Y,terrainData:k})}w&&P.sort((e,t)=>e.sortKey-t.sortKey);let M=i.paint.get(a?"text-halo-width":"icon-halo-width").constantOr(null)??1/0,E=24*i.layout.get("text-letter-spacing").constantOr(0)<0||M>1;for(let f of P){let t=f.state;d.activeTexture.set(m.TEXTURE0),t.atlasTexture.bind(t.atlasInterpolation,m.CLAMP_TO_EDGE),t.atlasTextureIcon&&(d.activeTexture.set(m.TEXTURE1),t.atlasTextureIcon&&t.atlasTextureIcon.bind(t.atlasInterpolationIcon,m.CLAMP_TO_EDGE));let r=t.isSDF&&t.hasHalo;if(r){let r=t.uniformValues;r.u_is_halo=1,E&&(r.u_is_plain=0,Rx(t.buffers,f.segments,i,e,t.program,T,u,c,r,t.projectionData,f.terrainData),r.u_is_halo=0,r.u_is_plain=1)}Rx(t.buffers,f.segments,i,e,t.program,T,u,c,t.uniformValues,t.projectionData,f.terrainData),r&&!E&&(t.uniformValues.u_is_halo=0)}}function Rx(e,t,i,r,a,n,s,o,l,h,u){let c=r.context,p=c.gl;a.draw(c,p.TRIANGLES,n,s,o,Px.backCCW,l,u,h,i.id,e.layoutVertexBuffer,e.indexBuffer,t,i.paint,r.transform.zoom,e.programConfigurations.get(i.id),e.dynamicLayoutVertexBuffer,e.opacityVertexBuffer)}function kx(e,t,i,r,a){let n=e.context,s=n.gl,o=wx.disabled,l=new yx([s.ONE,s.ONE],Si.transparent,[!0,!0,!0,!0]),h=t.getBucket(i);if(!h)return;let u=r.key,c=i.heatmapFbos.get(u);c||(c=Fx(n,t.tileSize,t.tileSize),i.heatmapFbos.set(u,c)),n.bindFramebuffer.set(c.framebuffer),n.viewport.set([0,0,t.tileSize,t.tileSize]),n.clear({color:Si.transparent});let p=h.programConfigurations.get(i.id),d=e.useProgram("heatmap",p,!a),f=e.transform.getProjectionData({overscaledTileID:t.tileID,applyGlobeMatrix:!0,applyTerrainMatrix:!0}),m=e.style.map.terrain.getTerrainData(r);d.draw(n,s.TRIANGLES,xx.disabled,o,l,Px.disabled,pv(t,e.transform.zoom,i.paint.get("heatmap-intensity"),1),m,f,i.id,h.layoutVertexBuffer,h.indexBuffer,h.segments,i.paint,e.transform.zoom,p)}function Lx(e,t,i,r,a){let n=e.context,s=n.gl,o=e.transform;n.setColorMode(e.colorModeForRenderPass());let l=Bx(n,t),h=i.key,u=t.heatmapFbos.get(h);if(!u)return;n.activeTexture.set(s.TEXTURE0),s.bindTexture(s.TEXTURE_2D,u.colorAttachment.get()),n.activeTexture.set(s.TEXTURE1),l.bind(s.LINEAR,s.CLAMP_TO_EDGE);let c=o.getProjectionData({overscaledTileID:i,applyTerrainMatrix:a,applyGlobeMatrix:!r});e.useProgram("heatmapTexture").draw(n,s.TRIANGLES,xx.disabled,wx.disabled,e.colorModeForRenderPass(),Px.disabled,dv(e,t,0,1),null,c,t.id,e.rasterBoundsBuffer,e.quadTriangleIndexBuffer,e.rasterBoundsSegments,t.paint,o.zoom),u.destroy(),t.heatmapFbos.delete(h)}function Fx(e,t,i){let r=e.gl,a=r.createTexture();r.bindTexture(r.TEXTURE_2D,a),r.texParameteri(r.TEXTURE_2D,r.TEXTURE_WRAP_S,r.CLAMP_TO_EDGE),r.texParameteri(r.TEXTURE_2D,r.TEXTURE_WRAP_T,r.CLAMP_TO_EDGE),r.texParameteri(r.TEXTURE_2D,r.TEXTURE_MIN_FILTER,r.LINEAR),r.texParameteri(r.TEXTURE_2D,r.TEXTURE_MAG_FILTER,r.LINEAR),r.texStorage2D(r.TEXTURE_2D,1,r.RGBA16F,t,i);let n=e.createFramebuffer(t,i,!1,!1);return n.colorAttachment.set(a),n}function Bx(e,t){return t.colorRampTexture||=new Ah(e,t.colorRamp,e.gl.RGBA),t.colorRampTexture}function Ox(e,t,i,r){let a=e.context,n=a.bindFramebuffer.get(),s=a.viewport.get(),[,,o,l]=s;return function(e,t,i){let r=e.context.gl;if(!e.layerOpacityFbo){let a=e.context.createFramebuffer(t,i,!0,!0),n=r.createTexture();return r.bindTexture(r.TEXTURE_2D,n),r.texParameteri(r.TEXTURE_2D,r.TEXTURE_WRAP_S,r.CLAMP_TO_EDGE),r.texParameteri(r.TEXTURE_2D,r.TEXTURE_WRAP_T,r.CLAMP_TO_EDGE),r.texParameteri(r.TEXTURE_2D,r.TEXTURE_MIN_FILTER,r.LINEAR),r.texParameteri(r.TEXTURE_2D,r.TEXTURE_MAG_FILTER,r.LINEAR),r.texImage2D(r.TEXTURE_2D,0,r.RGBA,t,i,0,r.RGBA,r.UNSIGNED_BYTE,null),a.colorAttachment.set(n),a.depthAttachment.set(e.context.createRenderbuffer(r.DEPTH_STENCIL,t,i)),e.layerOpacityFbo=a,void e.context.bindFramebuffer.set(e.layerOpacityFbo.framebuffer)}if(e.layerOpacityFbo.width===t&&e.layerOpacityFbo.height===i)return void e.context.bindFramebuffer.set(e.layerOpacityFbo.framebuffer);let a=e.layerOpacityFbo;r.bindTexture(r.TEXTURE_2D,a.colorAttachment.get()),r.texImage2D(r.TEXTURE_2D,0,r.RGBA,t,i,0,r.RGBA,r.UNSIGNED_BYTE,null),e.context.bindRenderbuffer.set(a.depthAttachment.get()),r.renderbufferStorage(r.RENDERBUFFER,r.DEPTH_STENCIL,t,i),e.context.bindRenderbuffer.set(null),a.width=t,a.height=i,e.context.bindFramebuffer.set(a.framebuffer)}(e,o,l),a.viewport.set([0,0,o,l]),a.clear({color:Si.transparent,depth:1,stencil:0}),e.currentStencilSource=void 0,e.renderTileClippingMasks(t,i,r),{compositeTarget:n,compositeViewport:s}}function Vx(e,t,i,r){let a=e.context,n=a.gl;a.bindFramebuffer.set(i.compositeTarget),a.viewport.set(i.compositeViewport),a.activeTexture.set(n.TEXTURE0),n.bindTexture(n.TEXTURE_2D,e.layerOpacityFbo.colorAttachment.get()),e.useProgram("layerOpacity").draw(a,n.TRIANGLES,xx.disabled,wx.disabled,e.colorModeForRenderPass(),Px.disabled,(e=>({u_image:0,u_opacity:e}))(t),null,null,r.id,e.viewportBuffer,e.quadTriangleIndexBuffer,e.viewportSegments,r.paint,e.transform.zoom),e.currentStencilSource=void 0}function jx(e,t,i,r,a,n,s,o){let l=256;if(a.stepInterpolant){let r=t.getSource().maxzoom,a=s.canonical.z===r?Math.ceil(1<<e.transform.maxZoom-s.canonical.z):1;l=ve(function(e){return e<=1?1:2**Math.ceil(Math.log(e)/Math.LN2)}(n.maxLineLength/J*1024*a),256,i.maxTextureSize)}return o.gradient=xh({expression:a.gradientExpression(),evaluationKey:"lineProgress",resolution:l,image:o.gradient||void 0,clips:n.lineClipsArray}),o.texture?o.texture.update(o.gradient):o.texture=new Ah(i,o.gradient,r.RGBA),o.version=a.gradientVersion,o.texture}function Nx(e,t,i,r,a){e.activeTexture.set(t.TEXTURE0),i.imageAtlasTexture.bind(t.LINEAR,t.CLAMP_TO_EDGE),r.updatePaintBuffers(a)}function Ux(e,t,i,r,a,n){(a||e.lineAtlas.dirty)&&(t.activeTexture.set(i.TEXTURE0),e.lineAtlas.bind(t)),r.updatePaintBuffers(n)}function Gx(e,t,i,r,a,n,s){let o=n.gradients[a.id],l=o.texture;a.gradientVersion!==o.version&&(l=jx(e,t,i,r,a,n,s,o)),i.activeTexture.set(r.TEXTURE0),l.bind(a.stepInterpolant?r.NEAREST:r.LINEAR,r.CLAMP_TO_EDGE)}function $x(e,t,i,r,a,n,s,o,l){let h=n.gradients[a.id],u=h.texture;a.gradientVersion!==h.version&&(u=jx(e,t,i,r,a,n,s,h)),i.activeTexture.set(r.TEXTURE0),u.bind(a.stepInterpolant?r.NEAREST:r.LINEAR,r.CLAMP_TO_EDGE),i.activeTexture.set(r.TEXTURE1),e.lineAtlas.bind(i),o.updatePaintBuffers(l)}function Zx(e,t,i,r,a,n){let s,{isRenderingToTexture:o}=a,l=e.getDepthModeForSublayer(0,xx.ReadOnly),h=e.colorModeForRenderPass(),u=i.paint.get("line-dasharray"),c=u.constantOr(1),p=i.paint.get("line-pattern"),d=p.constantOr(1),f=i.paint.get("line-gradient"),m=i.getCrossfadeParameters();s=d?"linePattern":c&&f?"lineGradientSDF":c?"lineSDF":f?"lineGradient":"line";let _=e.context,g=_.gl,y=e.transform,v=!0;for(let x of r){let r=t.getTile(x);if(d&&!r.patternsLoaded())continue;let a=r.getBucket(i);if(!a)continue;let b=a.programConfigurations.get(i.id),w=e.context.program.get(),T=e.useProgram(s,b),S=v||T.program!==w,P=n?e.getTerrainDataForTile(x,o):null,I=p.constantOr(null),M=u?.constantOr(null);if(I&&r.imageAtlas){let e=r.imageAtlas,t=e.patternPositions[I.to.toString()],i=e.patternPositions[I.from.toString()];t&&i&&b.setConstantPatternPositions(t,i)}else if(M){let t="round"===i.layout.get("line-cap").constantOr(null),r=e.lineAtlas.getDash(M.to,t),a=e.lineAtlas.getDash(M.from,t);b.setConstantDashPositions(r,a)}let E,A=y.getProjectionData({overscaledTileID:x,applyGlobeMatrix:!o,applyTerrainMatrix:!0}),C=y.getPixelScale();d?(E=xv(e,r,i,C,m),Nx(_,g,r,b,m)):c&&f?(E=wv(e,r,i,C,m,a.lineClipsArray.length),$x(e,t,_,g,i,a,x,b,m)):c?(E=bv(e,r,i,C,m),Ux(e,_,g,b,S,m)):f?(E=vv(e,r,i,C,a.lineClipsArray.length),Gx(e,t,_,g,i,a,x)):E=yv(e,r,i,C);let D=e.stencilModeForClipping(x);T.draw(_,g.TRIANGLES,l,D,h,Px.disabled,E,P,A,i.id,a.layoutVertexBuffer,a.indexBuffer,a.segments,i.paint,e.transform.zoom,b,a.layoutVertexBuffer2),v=!1}}function qx(e,t,i,r,a){if(!i||!r?.imageAtlas)return;let n=r.imageAtlas.patternPositions,s=n[i.to.toString()],o=n[i.from.toString()];if(!s&&o&&(s=o),!o&&s&&(o=s),!s||!o){let e=a.getPaintProperty(t);s=n[e],o=n[e]}s&&o&&e.setConstantPatternPositions(s,o)}function Wx(e,t,i,r,a){let{isRenderingToTexture:n}=a,s=e.colorModeForRenderPass();Xx(e,t,i,r,e.getDepthModeForSublayer(1,xx.ReadOnly),s,!1,n),Hx(e,t,i,r,a)}function Hx(e,t,i,r,a){if(!i.paint.get("fill-antialias"))return;let{isRenderingToTexture:n}=a,s=e.colorModeForRenderPass();Xx(e,t,i,r,e.getDepthModeForSublayer(i.getPaintProperty("fill-outline-color")?2:0,xx.ReadOnly),s,!0,n)}function Xx(e,t,i,r,a,n,s,o){let l,h,u,c,p,d=e.context.gl,f="fill-pattern",m=i.paint.get(f),_=m?.constantOr(1),g=i.getCrossfadeParameters(),y=e.transform,v=i.paint.get("fill-translate"),x=i.paint.get("fill-translate-anchor");s?(h=_&&!i.getPaintProperty("fill-outline-color")?"fillOutlinePattern":"fillOutline",l=d.LINES):(h=_?"fillPattern":"fill",l=d.TRIANGLES);let b=m.constantOr(null);for(let w of r){let r=t.getTile(w);if(_&&!r.patternsLoaded())continue;let m=r.getBucket(i);if(!m)continue;let T=m.programConfigurations.get(i.id),S=e.useProgram(h,T),P=e.getTerrainDataForTile(w,o);_&&(e.context.activeTexture.set(d.TEXTURE0),r.imageAtlasTexture.bind(d.LINEAR,d.CLAMP_TO_EDGE),T.updatePaintBuffers(g)),qx(T,f,b,r,i);let I=y.getProjectionData({overscaledTileID:w,applyGlobeMatrix:!o,applyTerrainMatrix:!0}),M=se(y,r,v,x);if(s){c=m.indexBuffer2,p=m.segments2;let t=[d.drawingBufferWidth,d.drawingBufferHeight];u="fillOutlinePattern"===h&&_?ov(e,g,r,t,M):sv(t,M)}else c=m.indexBuffer,p=m.segments,u=_?av(e,g,r,M):nv(M);let E=e.stencilModeForClipping(w);S.draw(e.context,l,a,E,n,Px.backCCW,u,P,I,i.id,m.layoutVertexBuffer,c,p,i.paint,e.transform.zoom,T)}}function Yx(e,t,i,r,a,n,s,o){let l=e.context,h=l.gl,u="fill-extrusion-pattern",c=i.paint.get(u),p=c.constantOr(1),d=i.getCrossfadeParameters(),f=i.paint.get("fill-extrusion-opacity"),m=c.constantOr(null),_=e.transform;for(let g of r){let r=t.getTile(g),c=r.getBucket(i);if(!c)continue;let y=e.style.map.terrain?.getTerrainData(g),v=c.programConfigurations.get(i.id),x=e.useProgram(p?"fillExtrusionPattern":"fillExtrusion",v);p&&(e.context.activeTexture.set(h.TEXTURE0),r.imageAtlasTexture.bind(h.LINEAR,h.CLAMP_TO_EDGE),v.updatePaintBuffers(d));let b=_.getProjectionData({overscaledTileID:g,applyGlobeMatrix:!o,applyTerrainMatrix:!0});qx(v,u,m,r,i);let w=se(_,r,i.paint.get("fill-extrusion-translate"),i.paint.get("fill-extrusion-translate-anchor")),T=i.paint.get("fill-extrusion-vertical-gradient"),S=p?rv(e,T,f,w,g,d,r):iv(e,T,f,w);x.draw(l,l.gl.TRIANGLES,a,n,s,Px.backCCW,S,y,b,i.id,c.layoutVertexBuffer,c.indexBuffer,c.segments,i.paint,e.transform.zoom,v,e.style.map.terrain&&c.centroidVertexBuffer)}}function Kx(e,t,i,r,a,n,s,o,l){let h=e.style.projection,u=e.context,c=e.transform,p=u.gl,d=[`#define NUM_ILLUMINATION_SOURCES ${i.paint.get("hillshade-highlight-color").values.length}`],f=e.useProgram("hillshade",null,!1,d),m=!e.options.moving;for(let _ of r){let r=t.getTile(_),d=r.fbo;if(!d)continue;let g=h.getMeshFromTileID(u,_.canonical,o,!0,"raster"),y=e.getTerrainDataForTile(_,l);u.activeTexture.set(p.TEXTURE0),p.bindTexture(p.TEXTURE_2D,d.colorAttachment.get());let v=c.getProjectionData({overscaledTileID:_,aligned:m,applyGlobeMatrix:!l,applyTerrainMatrix:!0});f.draw(u,p.TRIANGLES,n,a[_.overscaledZ],s,Px.backCCW,fv(e,r,i),y,v,i.id,g.vertexBuffer,g.indexBuffer,g.segments)}}var Jx=0;function Qx(e,t,i,r,a,n,s,o,l){let h=e.style.projection,u=e.context,c=e.transform,p=u.gl,d=e.useProgram("colorRelief"),f=!e.options.moving,m="nearest"===i.paint.get("resampling")?p.NEAREST:p.LINEAR,_=!0,g=0;for(let y of r){let r=t.getTile(y),v=r.dem;if(_){Jx||=p.getParameter(p.MAX_TEXTURE_SIZE);let e=Jx,{elevationTexture:t,colorTexture:r}=i.getColorRampTextures(u,e,v.getUnpackVector());u.activeTexture.set(p.TEXTURE1),t.bind(p.NEAREST,p.CLAMP_TO_EDGE),u.activeTexture.set(p.TEXTURE4),r.bind(p.LINEAR,p.CLAMP_TO_EDGE),_=!1,g=t.size[0]}if(!v?.data)continue;let x=v.stride,b=v.getPixels();if(u.activeTexture.set(p.TEXTURE0),u.pixelStoreUnpackPremultiplyAlpha.set(!1),r.demTexture||=e.getTileTexture(x),r.demTexture){let e=r.demTexture;e.update(b,{premultiply:!1}),e.bind(m,p.CLAMP_TO_EDGE)}else r.demTexture=new Ah(u,b,p.RGBA,{premultiply:!1}),r.demTexture.bind(m,p.CLAMP_TO_EDGE);let w=h.getMeshFromTileID(u,y.canonical,o,!0,"raster"),T=e.getTerrainDataForTile(y,l),S=c.getProjectionData({overscaledTileID:y,aligned:f,applyGlobeMatrix:!l,applyTerrainMatrix:!0});d.draw(u,p.TRIANGLES,n,a[y.overscaledZ],s,Px.backCCW,gv(i,r.dem,g),T,S,i.id,w.vertexBuffer,w.indexBuffer,w.segments)}}var eb=[new u(0,0),new u(J,0),new u(J,J),new u(0,J)];function tb(e,t,i,r,a,n,s,o,l,h=!1,u=!1){let c=r[r.length-1].overscaledZ,p=e.context,d=p.gl,f=e.useProgram("raster"),m=e.transform,_=e.style.projection,g=e.colorModeForRenderPass(),y=!e.options.moving,v=i.paint.get("raster-opacity"),x="nearest"===i.paint.get("resampling")||"nearest"===i.paint.get("raster-resampling")?d.NEAREST:d.LINEAR,b=i.paint.get("raster-fade-duration"),w=!!e.style.map.terrain;for(let T of r){let r=e.getDepthModeForSublayer(T.overscaledZ-c,1===v?xx.ReadWrite:xx.ReadOnly,d.LESS),S=t.getTile(T);p.activeTexture.set(d.TEXTURE0),S.texture.bind(x,d.CLAMP_TO_EDGE,d.LINEAR_MIPMAP_NEAREST),p.activeTexture.set(d.TEXTURE1);let{parentTile:P,parentScaleBy:I,parentTopLeft:M,fadeValues:E}=ib(S,t,b,w);S.fadeOpacity=E.tileOpacity,P?(P.fadeOpacity=E.parentTileOpacity,P.texture.bind(x,d.CLAMP_TO_EDGE,d.LINEAR_MIPMAP_NEAREST)):S.texture.bind(x,d.CLAMP_TO_EDGE,d.LINEAR_MIPMAP_NEAREST),S.texture.useMipmap&&p.extTextureFilterAnisotropic&&e.transform.pitch>e.options.anisotropicFilterPitch&&d.texParameterf(d.TEXTURE_2D,p.extTextureFilterAnisotropic.TEXTURE_MAX_ANISOTROPY_EXT,p.extTextureFilterAnisotropicMax);let A=e.getTerrainDataForTile(T,u),C=m.getProjectionData({overscaledTileID:T,aligned:y,applyGlobeMatrix:!u,applyTerrainMatrix:!0}),D=x_(M,I,E.fadeMix,i,o,l),z=_.getMeshFromTileID(p,T.canonical,n,s,"raster"),R=a?a[T.overscaledZ]:wx.disabled;f.draw(p,d.TRIANGLES,r,R,g,h?Px.frontCCW:Px.backCCW,D,A,C,i.id,z.vertexBuffer,z.indexBuffer,z.segments)}}function ib(e,t,i,r){let a={parentTile:null,parentScaleBy:1,parentTopLeft:[0,0],fadeValues:{tileOpacity:1,parentTileOpacity:1,fadeMix:{opacity:1,mix:0}}};if(0===i||r)return a;if(e.fadingParentID){let r=t.getLoadedTile(e.fadingParentID);if(!r)return a;let n=2**(r.tileID.overscaledZ-e.tileID.overscaledZ);return{parentTile:r,parentScaleBy:n,parentTopLeft:[e.tileID.canonical.x*n%1,e.tileID.canonical.y*n%1],fadeValues:rb(e,r,i)}}return e.selfFading?{parentTile:null,parentScaleBy:1,parentTopLeft:[0,0],fadeValues:ab(e,i)}:a}function rb(e,t,i){let r=sm(),a=(r-e.timeAdded)/i,n=(r-t.timeAdded)/i,s=1===e.fadingDirection,o=ve(a,0,1),l=ve(1-n,0,1),h=s?o:l;return{tileOpacity:h,parentTileOpacity:s?l:o,fadeMix:{opacity:1,mix:1-h}}}function ab(e,t){let i=ve((sm()-e.timeAdded)/t,0,1);return{tileOpacity:i,fadeMix:{opacity:i,mix:0}}}var nb=new Si(1,0,0,1),sb=new Si(0,1,0,1),ob=new Si(0,0,1,1),lb=new Si(1,0,1,1),hb=new Si(0,1,1,1);function ub(e,t,i,r){pb(e,0,t+i/2,e.transform.width,i,r)}function cb(e,t,i,r){pb(e,t-i/2,0,i,e.transform.height,r)}function pb(e,t,i,r,a,n){let s=e.context,o=s.gl;o.enable(o.SCISSOR_TEST),o.scissor(t*e.pixelRatio,i*e.pixelRatio,r*e.pixelRatio,a*e.pixelRatio),s.clear({color:n}),o.disable(o.SCISSOR_TEST)}function db(e,t,i){let r=e.context,a=r.gl,n=e.useProgram("debug"),s=xx.disabled,o=wx.disabled,l=e.colorModeForRenderPass(),h="$debug",u=e.style.map.terrain?.getTerrainData(i);r.activeTexture.set(a.TEXTURE0);let c=t.getTileByID(i.key).latestRawTileData?.byteLength||0,p=Math.floor(c/1024),d=t.getTile(i).tileSize,f=512/Math.min(d,512)*(i.overscaledZ/e.transform.zoom)*.5,m=i.canonical.toString();i.overscaledZ!==i.canonical.z&&(m+=` => ${i.overscaledZ}`),function(e,t){e.initDebugOverlayCanvas();let i=e.debugOverlayCanvas,r=e.context.gl,a=e.debugOverlayCanvas.getContext("2d");a.clearRect(0,0,i.width,i.height),a.shadowColor="white",a.shadowBlur=2,a.lineWidth=1.5,a.strokeStyle="white",a.textBaseline="top",a.font="bold 36px Open Sans, sans-serif",a.fillText(t,5,5),a.strokeText(t,5,5),e.debugOverlayTexture.update(i),e.debugOverlayTexture.bind(r.LINEAR,r.CLAMP_TO_EDGE)}(e,`${m} ${p}kB`);let _=e.transform.getProjectionData({overscaledTileID:i,applyGlobeMatrix:!0,applyTerrainMatrix:!0});n.draw(r,a.TRIANGLES,s,o,yx.alphaBlended,Px.disabled,cv(Si.transparent,f),null,_,h,e.debugBuffer,e.quadTriangleIndexBuffer,e.debugSegments),n.draw(r,a.LINE_STRIP,s,o,l,Px.disabled,cv(Si.red),u,_,h,e.debugBuffer,e.tileBorderIndexBuffer,e.debugSegments)}function fb(e,t){if(!t.mesh){let i=new Do;i.emplaceBack(-1,-1),i.emplaceBack(1,-1),i.emplaceBack(1,1),i.emplaceBack(-1,1);let r=new Ho;r.emplaceBack(0,1,2),r.emplaceBack(0,2,3),t.mesh=new ry(e.createVertexBuffer(i,ay.members),e.createIndexBuffer(r),Qo.simpleSegment(0,0,i.length,r.length))}return t.mesh}var mb={symbol:function(e,t,i,r,a,n){if("translucent"!==e.renderPass)return;let{isRenderingToTexture:s}=n,o=wx.disabled,l=e.colorModeForRenderPass();(i._unevaluatedLayout.hasValue("text-variable-anchor")||i._unevaluatedLayout.hasValue("text-variable-anchor-offset"))&&function(e,t,i,r,a,n,s,o,l){let h=t.transform,u=t.style.map.terrain,c="map"===a,p="map"===n;for(let d of e){let e=r.getTile(d),a=e.getBucket(i);if(!a?.text?.segments.get().length)continue;let n=lp(a.textSizeData,h.zoom),f=Q(e,1,t.transform.zoom),m=rg(c,t.transform,f),_="none"!==i.layout.get("icon-text-fit")&&a.hasIconData();if(n){let t=2**(h.zoom-e.tileID.overscaledZ),i=u?(e,t)=>u.getElevation(d,e,t):null;Cx(a,c,p,l,h,m,t,n,_,se(h,e,s,o),d.toUnwrapped(),i)}}}(r,e,i,t,i.layout.get("text-rotation-alignment"),i.layout.get("text-pitch-alignment"),i.paint.get("text-translate"),i.paint.get("text-translate-anchor"),a),0!==i.paint.get("icon-opacity").constantOr(1)&&zx(e,t,i,r,!1,i.paint.get("icon-translate"),i.paint.get("icon-translate-anchor"),i.layout.get("icon-rotation-alignment"),i.layout.get("icon-pitch-alignment"),i.layout.get("icon-keep-upright"),o,l,s),0!==i.paint.get("text-opacity").constantOr(1)&&zx(e,t,i,r,!0,i.paint.get("text-translate"),i.paint.get("text-translate-anchor"),i.layout.get("text-rotation-alignment"),i.layout.get("text-pitch-alignment"),i.layout.get("text-keep-upright"),o,l,s),t.map.showCollisionBoxes&&(Ix(e,t,i,r,!0),Ix(e,t,i,r,!1))},circle:function(e,t,i,r,a){if("translucent"!==e.renderPass)return;let{isRenderingToTexture:n}=a,s=i.paint.get("circle-opacity"),o=i.paint.get("circle-stroke-width"),l=i.paint.get("circle-stroke-opacity"),h=!i.layout.get("circle-sort-key").isConstant();if(0===s.constantOr(1)&&(0===o.constantOr(1)||0===l.constantOr(1)))return;let u=e.context,c=u.gl,p=e.transform,d=e.getDepthModeForSublayer(0,xx.ReadOnly),f=wx.disabled,m=e.colorModeForRenderPass(),_=[],g=p.getCircleRadiusCorrection();for(let y of r){let r=t.getTile(y),a=r.getBucket(i);if(!a)continue;let s=se(p,r,i.paint.get("circle-translate"),i.paint.get("circle-translate-anchor")),o=a.programConfigurations.get(i.id),l=e.useProgram("circle",o),u=a.layoutVertexBuffer,c=a.indexBuffer,d=e.style.map.terrain?.getTerrainData(y),f={programConfiguration:o,program:l,layoutVertexBuffer:u,indexBuffer:c,uniformValues:lv(e,r,i,s,g),terrainData:d,projectionData:p.getProjectionData({overscaledTileID:y,applyGlobeMatrix:!n,applyTerrainMatrix:!0})};if(h){let e=a.segments.get();for(let t of e)_.push({segments:new Qo([t]),sortKey:t.sortKey,state:f})}else _.push({segments:a.segments,sortKey:0,state:f})}h&&_.sort((e,t)=>e.sortKey-t.sortKey);for(let y of _){let{programConfiguration:t,program:r,layoutVertexBuffer:a,indexBuffer:n,uniformValues:s,terrainData:o,projectionData:l}=y.state,h=y.segments;r.draw(u,c.TRIANGLES,d,f,m,Px.backCCW,s,o,l,i.id,a,n,h,i.paint,e.transform.zoom,t)}},heatmap:function(e,t,i,r,a){if(0===i.paint.get("heatmap-opacity"))return;let n=e.context,{isRenderingToTexture:s,isRenderingGlobe:o}=a;if(e.style.map.terrain){for(let a of r){let r=t.getTile(a);t.hasRenderableParent(a)||("offscreen"===e.renderPass?kx(e,r,i,a,o):"translucent"===e.renderPass&&Lx(e,i,a,s,o))}n.viewport.set([0,0,e.width,e.height])}else"offscreen"===e.renderPass?function(e,t,i,r){let a=e.context,n=a.gl,s=e.transform,o=wx.disabled,l=new yx([n.ONE,n.ONE],Si.transparent,[!0,!0,!0,!0]);(function(e,t,i){let r=e.gl;e.activeTexture.set(r.TEXTURE1),e.viewport.set([0,0,t.width/4,t.height/4]);let a=i.heatmapFbos.get(Th);a?(r.bindTexture(r.TEXTURE_2D,a.colorAttachment.get()),e.bindFramebuffer.set(a.framebuffer)):(a=Fx(e,t.width/4,t.height/4),i.heatmapFbos.set(Th,a))})(a,e,i),a.clear({color:Si.transparent});for(let h of r){if(t.hasRenderableParent(h))continue;let r=t.getTile(h),u=r.getBucket(i);if(!u)continue;let c=u.programConfigurations.get(i.id),p=e.useProgram("heatmap",c),d=s.getProjectionData({overscaledTileID:h,applyGlobeMatrix:!0,applyTerrainMatrix:!1}),f=s.getCircleRadiusCorrection();p.draw(a,n.TRIANGLES,xx.disabled,o,l,Px.backCCW,pv(r,s.zoom,i.paint.get("heatmap-intensity"),f),null,d,i.id,u.layoutVertexBuffer,u.indexBuffer,u.segments,i.paint,s.zoom,c)}a.viewport.set([0,0,e.width,e.height])}(e,t,i,r):"translucent"===e.renderPass&&function(e,t){let i=e.context,r=i.gl;i.setColorMode(e.colorModeForRenderPass());let a=t.heatmapFbos.get(Th);a&&(i.activeTexture.set(r.TEXTURE0),r.bindTexture(r.TEXTURE_2D,a.colorAttachment.get()),i.activeTexture.set(r.TEXTURE1),Bx(i,t).bind(r.LINEAR,r.CLAMP_TO_EDGE),e.useProgram("heatmapTexture").draw(i,r.TRIANGLES,xx.disabled,wx.disabled,e.colorModeForRenderPass(),Px.disabled,dv(e,t,0,1),null,null,t.id,e.viewportBuffer,e.quadTriangleIndexBuffer,e.viewportSegments,t.paint,e.transform.zoom))}(e,i)},line:function(e,t,i,r,a){if("translucent"!==e.renderPass)return;let n=i.paint.get("line-opacity"),s=i.paint.get("line-width"),o=i.paint.get("line-layer-opacity");if(0===n.constantOr(1)||0===s.constantOr(1)||0===o)return;let l=!!e.style.map.terrain;if(o<1){let n=Ox(e,i,r,l);return Zx(e,t,i,r,a,l),void Vx(e,o,n,i)}Zx(e,t,i,r,a,l)},fill:function(e,t,i,r,a){let n=i.paint.get("fill-color"),s=i.paint.get("fill-opacity"),o=i.paint.get("fill-layer-opacity");if(0===s.constantOr(1)||0===o)return;if(o<1){if("translucent"!==e.renderPass)return;let n=Ox(e,i,r,!!e.style.map.terrain);return Wx(e,t,i,r,a),void Vx(e,o,n,i)}let l=i.paint.get("fill-pattern"),h=e.opaquePassEnabledForLayer()&&!l.constantOr(1)&&1===n.constantOr(Si.transparent).a&&1===s.constantOr(0);if(h&&"opaque"===e.renderPass){let{isRenderingToTexture:n}=a,s=e.colorModeForRenderPass();return void Xx(e,t,i,r,e.getDepthModeForSublayer(1,xx.ReadWrite),s,!1,n)}h&&"translucent"===e.renderPass?Hx(e,t,i,r,a):"translucent"===e.renderPass&&Wx(e,t,i,r,a)},fillExtrusion:function(e,t,i,r,a){let n=i.paint.get("fill-extrusion-opacity");if(0===n)return;let{isRenderingToTexture:s}=a;if("translucent"===e.renderPass){let a=new xx(e.context.gl.LEQUAL,xx.ReadWrite,e.depthRangeFor3D);if(1!==n||i.paint.get("fill-extrusion-pattern").constantOr(1))Yx(e,t,i,r,a,wx.disabled,yx.disabled,s),Yx(e,t,i,r,a,e.stencilModeFor3D(),e.colorModeForRenderPass(),s);else{let n=e.colorModeForRenderPass();Yx(e,t,i,r,a,wx.disabled,n,s)}}},hillshade:function(e,t,i,r,a){if("offscreen"!==e.renderPass&&"translucent"!==e.renderPass)return;let{isRenderingToTexture:n}=a,s=e.context,o=e.style.projection.useSubdivision,l=e.getDepthModeForSublayer(0,xx.ReadOnly),h=e.colorModeForRenderPass();if("offscreen"===e.renderPass)(function(e,t,i,r,a,n,s){let o=e.context,l=o.gl,h="nearest"===r.paint.get("resampling")?l.NEAREST:l.LINEAR;for(let u of i){let i=t.getTile(u),c=i.dem;if(!c?.data||!i.needsHillshadePrepare)continue;let p=c.dim,d=c.stride,f=c.getPixels();if(o.activeTexture.set(l.TEXTURE1),o.pixelStoreUnpackPremultiplyAlpha.set(!1),i.demTexture||=e.getTileTexture(d),i.demTexture){let e=i.demTexture;e.update(f,{premultiply:!1}),e.bind(l.NEAREST,l.CLAMP_TO_EDGE)}else i.demTexture=new Ah(o,f,l.RGBA,{premultiply:!1}),i.demTexture.bind(l.NEAREST,l.CLAMP_TO_EDGE);o.activeTexture.set(l.TEXTURE0);let m=i.fbo;if(!m){let e=new Ah(o,{width:p,height:p,data:null},l.RGBA);e.bind(h,l.CLAMP_TO_EDGE),m=i.fbo=o.createFramebuffer(p,p,!0,!1),m.colorAttachment.set(e.texture)}o.bindFramebuffer.set(m.framebuffer),o.viewport.set([0,0,p,p]),e.useProgram("hillshadePrepare").draw(o,l.TRIANGLES,a,n,s,Px.disabled,mv(i.tileID,c),null,null,r.id,e.rasterBoundsBuffer,e.quadTriangleIndexBuffer,e.rasterBoundsSegments),i.needsHillshadePrepare=!1}})(e,t,r,i,l,wx.disabled,h),s.viewport.set([0,0,e.width,e.height]);else if("translucent"===e.renderPass)if(o){let[a,s,o]=e.stencilConfigForOverlapTwoPass(r);Kx(e,t,i,o,a,l,h,!1,n),Kx(e,t,i,o,s,l,h,!0,n)}else{let[a,s]=e.getStencilConfigForOverlapAndUpdateStencilID(r);Kx(e,t,i,s,a,l,h,!1,n)}},colorRelief:function(e,t,i,r,a){if("translucent"!==e.renderPass||!r.length)return;let{isRenderingToTexture:n}=a,s=e.style.projection.useSubdivision,o=e.getDepthModeForSublayer(0,xx.ReadOnly),l=e.colorModeForRenderPass();if(s){let[a,s,h]=e.stencilConfigForOverlapTwoPass(r);Qx(e,t,i,h,a,o,l,!1,n),Qx(e,t,i,h,s,o,l,!0,n)}else{let[a,s]=e.getStencilConfigForOverlapAndUpdateStencilID(r);Qx(e,t,i,s,a,o,l,!1,n)}},raster:function(e,t,i,r,a){if("translucent"!==e.renderPass||0===i.paint.get("raster-opacity")||!r.length)return;let{isRenderingToTexture:n}=a,s=t.getSource(),o=e.style.projection.useSubdivision;if(s instanceof S_)tb(e,t,i,r,null,!1,!1,s.tileCoords,s.perspectiveTransform,s.flippedWindingOrder,n);else if(o){let[a,s,o]=e.stencilConfigForOverlapTwoPass(r);tb(e,t,i,o,a,!1,!0,eb,v_,!1,n),tb(e,t,i,o,s,!0,!0,eb,v_,!1,n)}else{let[a,s]=e.getStencilConfigForOverlapAndUpdateStencilID(r);tb(e,t,i,s,a,!1,!0,eb,v_,!1,n)}},background:function(e,t,i,r,a){let n=i.paint.get("background-color"),s=i.paint.get("background-opacity");if(0===s)return;let{isRenderingToTexture:o}=a,l=e.context,h=l.gl,u=e.style.projection,c=e.transform,p=c.tileSize,d=i.paint.get("background-pattern");if(e.isPatternMissing(d))return;let f=!d&&1===n.a&&1===s&&e.opaquePassEnabledForLayer()?"opaque":"translucent";if(e.renderPass!==f)return;let m=wx.disabled,_=e.getDepthModeForSublayer(0,"opaque"===f?xx.ReadWrite:xx.ReadOnly),g=e.colorModeForRenderPass(),y=e.useProgram(d?"backgroundPattern":"background"),v=r||G_(c,{tileSize:p,terrain:e.style.map.terrain});d&&(l.activeTexture.set(h.TEXTURE0),e.patternAtlas.bind(e.context));let x=i.getCrossfadeParameters();for(let b of v){let t=c.getProjectionData({overscaledTileID:b,applyGlobeMatrix:!o,applyTerrainMatrix:!0}),r=d?Av(s,e,d,{tileID:b,tileSize:p},x):Ev(s,n),a=e.getTerrainDataForTile(b,o),f=u.getMeshFromTileID(l,b.canonical,!1,!0,"raster");y.draw(l,h.TRIANGLES,_,m,g,Px.backCCW,r,a,t,i.id,f.vertexBuffer,f.indexBuffer,f.segments)}},sky:function(e,t){let i=e.context,r=i.gl,a=((e,t,i)=>{let r=Math.cos(t.rollInRadians),a=Math.sin(t.rollInRadians),n=hc(t),s=t.getProjectionData({overscaledTileID:null,applyGlobeMatrix:!0,applyTerrainMatrix:!0}).projectionTransition;return{u_sky_color:e.properties.get("sky-color"),u_horizon_color:e.properties.get("horizon-color"),u_horizon:[(t.width/2-n*a)*i,(t.height/2+n*r)*i],u_horizon_normal:[-a,r],u_sky_horizon_blend:e.properties.get("sky-horizon-blend")*t.height/2*i,u_sky_blend:s}})(t,e.transform,e.pixelRatio),n=new xx(r.LEQUAL,xx.ReadWrite,[0,1]),s=wx.disabled,o=e.colorModeForRenderPass(),l=e.useProgram("sky"),h=fb(i,t);l.draw(i,r.TRIANGLES,n,s,o,Px.disabled,a,null,void 0,"sky",h.vertexBuffer,h.indexBuffer,h.segments)},atmosphere:function(e,t,i){let r=e.context,a=r.gl,n=e.useProgram("atmosphere"),s=new xx(a.LEQUAL,xx.ReadOnly,[0,1]),o=e.transform,l=function(e,t){let i=e.getCartesianPosition();!function(e,t){e[0]=-t[0],e[1]=-t[1],e[2]=-t[2]}(i,i);let r=_(/* @__PURE__ */new Float64Array(16));return"map"===e.properties.get("anchor")&&(T(r,r,t.rollInRadians),b(r,r,-t.pitchInRadians),T(r,r,t.bearingInRadians),b(r,r,t.center.lat*Math.PI/180),w(r,r,-t.center.lng*Math.PI/180)),function(e,t,i){var r=t[0],a=t[1],n=t[2],s=i[3]*r+i[7]*a+i[11]*n+i[15];s||=1,e[0]=(i[0]*r+i[4]*a+i[8]*n+i[12])/s,e[1]=(i[1]*r+i[5]*a+i[9]*n+i[13])/s,e[2]=(i[2]*r+i[6]*a+i[10]*n+i[14])/s}(i,i,r),i}(i,e.transform),h=o.getProjectionData({overscaledTileID:null,applyGlobeMatrix:!0,applyTerrainMatrix:!0}),u=t.properties.get("atmosphere-blend")*h.projectionTransition;if(0===u)return;let c=Ey(o.worldSize,o.center.lat),p=o.inverseProjectionMatrix,d=/* @__PURE__ */new Float64Array(4);d[3]=1,U(d,d,o.modelViewProjectionMatrix),d[0]/=d[3],d[1]/=d[3],d[2]/=d[3],d[3]=1,U(d,d,p),d[0]/=d[3],d[1]/=d[3],d[2]/=d[3],d[3]=1;let f=((e,t,i,r,a)=>({u_sun_pos:e,u_atmosphere_blend:t,u_globe_position:i,u_globe_radius:r,u_inv_proj_matrix:a}))(l,u,[d[0],d[1],d[2]],c,p),m=fb(r,t);n.draw(r,a.TRIANGLES,s,wx.disabled,yx.alphaBlended,Px.disabled,f,null,null,"atmosphere",m.vertexBuffer,m.indexBuffer,m.segments)},custom:function(e,t,i,r){let{isRenderingGlobe:a}=r,n=e.context,s=i.implementation,o=e.style.projection,l=e.transform,h=l.getProjectionDataForCustomLayer(a),u={farZ:l.farZ,nearZ:l.nearZ,fov:l.fov*Math.PI/180,modelViewProjectionMatrix:l.modelViewProjectionMatrix,projectionMatrix:l.projectionMatrix,shaderData:{variantName:o.shaderVariantName,vertexShaderPrelude:`const float PI = 3.141592653589793;\nuniform mat4 u_projection_matrix;\n${o.shaderPreludeCode.vertexSource}`,define:o.shaderDefine},defaultProjectionData:h,getProjectionData:e=>l.getProjectionData({overscaledTileID:new kp(e.tileID.canonical.z,e.tileID.wrap??0,e.tileID.canonical.z,e.tileID.canonical.x,e.tileID.canonical.y),aligned:e.aligned,applyGlobeMatrix:e.applyGlobeMatrix,applyTerrainMatrix:e.applyTerrainMatrix})},c=s.renderingMode?s.renderingMode:"2d";if("offscreen"===e.renderPass){let t=s.prerender;t&&(e.setCustomLayerDefaults(),n.setColorMode(e.colorModeForRenderPass()),t.call(s,n.gl,u),n.setDirty(),e.setBaseState())}else if("translucent"===e.renderPass){e.setCustomLayerDefaults(),n.setColorMode(e.colorModeForRenderPass()),n.setStencilMode(wx.disabled);let t="3d"===c?e.getDepthModeFor3D():e.getDepthModeForSublayer(0,xx.ReadOnly);n.setDepthMode(t),s.render(n.gl,u),n.setDirty(),e.setBaseState(),n.bindFramebuffer.set(null)}},debug:function(e,t,i){for(let r of i)db(e,t,r)},debugPadding:function(e){let t=e.transform.padding;ub(e,e.transform.height-(t.top||0),3,nb),ub(e,t.bottom||0,3,sb),cb(e,t.left||0,3,ob),cb(e,e.transform.width-(t.right||0),3,lb);let i=e.transform.centerPoint;!function(e,t,i,r){pb(e,t-1,i-10,2,20,r),pb(e,t-10,i-1,20,2,r)}(e,i.x,e.transform.height-i.y,hb)},terrainDepth:function(e,t){let i=e.context,r=i.gl,a=e.transform,n=yx.unblended,s=new xx(r.LEQUAL,xx.ReadWrite,[0,1]),o=t.tileManager.getRenderableTiles(),l=e.useProgram("terrainDepth");i.bindFramebuffer.set(t.getFramebuffer("depth").framebuffer),i.viewport.set([0,0,e.width/devicePixelRatio,e.height/devicePixelRatio]),i.clear({color:Si.transparent,depth:1});for(let h of o){let e=t.getTerrainMesh(h.tileID),o=t.getTerrainData(h.tileID),u=a.getProjectionData({overscaledTileID:h.tileID,applyTerrainMatrix:!1,applyGlobeMatrix:!0}),c=Ky(t.getSkirtLength(a.zoom));l.draw(i,r.TRIANGLES,s,wx.disabled,n,Px.backCCW,c,o,u,"terrain",e.vertexBuffer,e.indexBuffer,e.segments)}i.bindFramebuffer.set(null),i.viewport.set([0,0,e.width,e.height])},terrainCoords:function(e,t){let i=e.context,r=i.gl,a=e.transform,n=yx.unblended,s=new xx(r.LEQUAL,xx.ReadWrite,[0,1]),o=t.getCoordsTexture(),l=t.tileManager.getRenderableTiles(),h=e.useProgram("terrainCoords");i.bindFramebuffer.set(t.getFramebuffer("coords").framebuffer),i.viewport.set([0,0,e.width/devicePixelRatio,e.height/devicePixelRatio]),i.clear({color:Si.transparent,depth:1}),t.coordsIndex=[];for(let u of l){let e=t.getTerrainMesh(u.tileID),l=t.getTerrainData(u.tileID);i.activeTexture.set(r.TEXTURE0),r.bindTexture(r.TEXTURE_2D,o.texture);let c=Jy(255-t.coordsIndex.length,t.getSkirtLength(a.zoom)),p=a.getProjectionData({overscaledTileID:u.tileID,applyTerrainMatrix:!1,applyGlobeMatrix:!0});h.draw(i,r.TRIANGLES,s,wx.disabled,n,Px.backCCW,c,l,p,"terrain",e.vertexBuffer,e.indexBuffer,e.segments),t.coordsIndex.push(u.tileID.key)}i.bindFramebuffer.set(null),i.viewport.set([0,0,e.width,e.height])}},_b=class e{constructor(e,t){this.drawFunctions=mb,this.context=new vx(e),this.transform=t,this.layerOpacityFbo=null,this._tileTextures={},this._rttObjectRecyclePool=[],this._rttSharedFbo=null,this.terrainFacilitator={depthDirty:!0,coordsDirty:!1,matrix:_(/* @__PURE__ */new Float64Array(16)),renderTime:0},this.setup(),this.numSublayers=K_.maxOverzooming+K_.maxUnderzooming+1,this.depthEpsilon=1/65536,this.crossTileSymbolIndex=new Qg}resize(e,t,i){if(this.width=Math.floor(e*i),this.height=Math.floor(t*i),this.pixelRatio=i,this.context.viewport.set([0,0,this.width,this.height]),this.style)for(let r of this.style._order)this.style._layers[r].resize()}setup(){let e=this.context,t=new Do;t.emplaceBack(0,0),t.emplaceBack(J,0),t.emplaceBack(0,J),t.emplaceBack(J,J),this.tileExtentBuffer=e.createVertexBuffer(t,ay.members),this.tileExtentSegments=Qo.simpleSegment(0,0,4,2);let i=new Do;i.emplaceBack(0,0),i.emplaceBack(J,0),i.emplaceBack(0,J),i.emplaceBack(J,J),this.debugBuffer=e.createVertexBuffer(i,ay.members),this.debugSegments=Qo.simpleSegment(0,0,4,5);let r=new Ro;r.emplaceBack(0,0,0,0),r.emplaceBack(J,0,J,0),r.emplaceBack(0,J,0,J),r.emplaceBack(J,J,J,J),this.rasterBoundsBuffer=e.createVertexBuffer(r,Hy.members),this.rasterBoundsSegments=Qo.simpleSegment(0,0,4,2);let a=new Do;a.emplaceBack(0,0),a.emplaceBack(J,0),a.emplaceBack(0,J),a.emplaceBack(J,J),this.rasterBoundsBufferPosOnly=e.createVertexBuffer(a,ay.members),this.rasterBoundsSegmentsPosOnly=Qo.simpleSegment(0,0,4,5);let n=new Do;n.emplaceBack(0,0),n.emplaceBack(1,0),n.emplaceBack(0,1),n.emplaceBack(1,1),this.viewportBuffer=e.createVertexBuffer(n,ay.members),this.viewportSegments=Qo.simpleSegment(0,0,4,2);let s=new Yo;s.emplaceBack(0),s.emplaceBack(1),s.emplaceBack(3),s.emplaceBack(2),s.emplaceBack(0),this.tileBorderIndexBuffer=e.createIndexBuffer(s);let o=new Ho;o.emplaceBack(1,0,2),o.emplaceBack(1,2,3),this.quadTriangleIndexBuffer=e.createIndexBuffer(o);let l=this.context.gl;this.stencilClearMode=new wx({func:l.ALWAYS,mask:0},0,255,l.ZERO,l.ZERO,l.ZERO),this.tileExtentMesh=new ry(this.tileExtentBuffer,this.quadTriangleIndexBuffer,this.tileExtentSegments)}clearStencil(){let e=this.context,t=e.gl;this.nextStencilID=1,this.currentStencilSource=void 0;let i=f();P(i,0,this.width,this.height,0,0,1),x(i,i,[t.drawingBufferWidth,t.drawingBufferHeight,0]);let r={mainMatrix:i,tileMercatorCoords:[0,0,1,1],clippingPlane:[0,0,0,0],projectionTransition:0,fallbackMatrix:i,clipAntimeridian:!1};this.useProgram("clippingMask",null,!0).draw(e,t.TRIANGLES,xx.disabled,this.stencilClearMode,yx.disabled,Px.disabled,null,null,r,"$clipping",this.viewportBuffer,this.quadTriangleIndexBuffer,this.viewportSegments)}renderTileClippingMasks(e,t,i){if(this.currentStencilSource===e.source||!e.isTileClipped()||!t?.length)return;this.currentStencilSource=e.source,this.nextStencilID+t.length>256&&this.clearStencil();let r=this.context;r.setColorMode(yx.disabled),r.setDepthMode(xx.disabled);let a={};for(let n of t)a[n.key]=this.nextStencilID++;this.style.projection.useSubdivision&&this._renderTileMasks(a,t,i,!0),this._renderTileMasks(a,t,i,!1),this._tileClippingMaskIDs=a}_renderTileMasks(e,t,i,r){let a=this.context,n=a.gl,s=this.style.projection,o=this.transform,l=this.useProgram("clippingMask");for(let h of t){let t=e[h.key],u=this.getTerrainDataForTile(h,i),c=s.getMeshFromTileID(this.context,h.canonical,r,!0,"stencil"),p=o.getProjectionData({overscaledTileID:h,applyGlobeMatrix:!i,applyTerrainMatrix:!0});l.draw(a,n.TRIANGLES,xx.disabled,new wx({func:n.ALWAYS,mask:0},t,255,n.KEEP,n.KEEP,n.REPLACE),yx.disabled,i?Px.disabled:Px.backCCW,null,u,p,"$clipping",c.vertexBuffer,c.indexBuffer,c.segments)}}getTerrainDataForTile(e,t){return t&&"mercator"===this.style.projection?.name?null:this.style.map.terrain?.getTerrainData(e)||null}_renderTilesDepthBuffer(){let e=this.context,t=e.gl,i=this.style.projection,r=this.transform,a=this.useProgram("depth"),n=this.getDepthModeFor3D(),s=G_(r,{tileSize:r.tileSize});for(let o of s){let s=this.style.map.terrain?.getTerrainData(o),l=i.getMeshFromTileID(this.context,o.canonical,!0,!0,"raster"),h=r.getProjectionData({overscaledTileID:o,applyGlobeMatrix:!0,applyTerrainMatrix:!0});a.draw(e,t.TRIANGLES,n,wx.disabled,yx.disabled,Px.backCCW,null,s,h,"$clipping",l.vertexBuffer,l.indexBuffer,l.segments)}}stencilModeFor3D(){this.currentStencilSource=void 0,this.nextStencilID+1>256&&this.clearStencil();let e=this.nextStencilID++,t=this.context.gl;return new wx({func:t.NOTEQUAL,mask:255},e,255,t.KEEP,t.KEEP,t.REPLACE)}stencilModeForClipping(e){let t=this.context.gl;return new wx({func:t.EQUAL,mask:255},this._tileClippingMaskIDs[e.key],0,t.KEEP,t.KEEP,t.REPLACE)}getStencilConfigForOverlapAndUpdateStencilID(e){let t=this.context.gl,i=e.sort((e,t)=>t.overscaledZ-e.overscaledZ),r=i[i.length-1].overscaledZ,a=i[0].overscaledZ-r+1;if(a>1){this.currentStencilSource=void 0,this.nextStencilID+a>256&&this.clearStencil();let e={};for(let i=0;i<a;i++)e[i+r]=new wx({func:t.GEQUAL,mask:255},i+this.nextStencilID,255,t.KEEP,t.KEEP,t.REPLACE);return this.nextStencilID+=a,[e,i]}return[{[r]:wx.disabled},i]}stencilConfigForOverlapTwoPass(e){let t=this.context.gl,i=e.sort((e,t)=>t.overscaledZ-e.overscaledZ),r=i[i.length-1].overscaledZ,a=i[0].overscaledZ-r+1;if(this.clearStencil(),a>1){let e={},n={};for(let i=0;i<a;i++)e[i+r]=new wx({func:t.GREATER,mask:255},a+1+i,255,t.KEEP,t.KEEP,t.REPLACE),n[i+r]=new wx({func:t.GREATER,mask:255},1+i,255,t.KEEP,t.KEEP,t.REPLACE);return this.nextStencilID=2*a+1,[e,n,i]}return this.nextStencilID=3,[{[r]:new wx({func:t.GREATER,mask:255},2,255,t.KEEP,t.KEEP,t.REPLACE)},{[r]:new wx({func:t.GREATER,mask:255},1,255,t.KEEP,t.KEEP,t.REPLACE)},i]}colorModeForRenderPass(){let e=this.context.gl;if(this._showOverdrawInspector){let t=1/8;return new yx([e.CONSTANT_COLOR,e.ONE],new Si(t,t,t,0),[!0,!0,!0,!0])}return"opaque"===this.renderPass?yx.unblended:yx.alphaBlended}getDepthModeForSublayer(e,t,i){if(!this.opaquePassEnabledForLayer())return xx.disabled;let r=1-((1+this.currentLayer)*this.numSublayers+e)*this.depthEpsilon;return new xx(i||this.context.gl.LEQUAL,t,[r,r])}getDepthModeFor3D(){return new xx(this.context.gl.LEQUAL,xx.ReadWrite,this.depthRangeFor3D)}opaquePassEnabledForLayer(){return this.currentLayer<this.opaquePassCutoff}render(e,t){this.style=e,this.options=t,this.lineAtlas=e.lineAtlas,this.imageManager=e.imageManager,this.patternAtlas=e.patternAtlas,this.glyphManager=e.glyphManager,this.symbolFadeChange=e.placement.symbolFadeChange(sm()),this.imageManager.beginFrame();let i=this.style._order,r=this.style.tileManagers,a={},n={},s={},o={isRenderingToTexture:!1,isRenderingGlobe:e.projection?.transitionState>0};for(let h in r){let e=r[h];e.used&&e.prepare(this.context),a[h]=e.getVisibleCoordinates(!1),n[h]=a[h].slice().reverse(),s[h]=e.getVisibleCoordinates(!0).reverse()}this.opaquePassCutoff=1/0;for(let h=0;h<i.length;h++){let e=i[h];if(this.style._layers[e].is3D()){this.opaquePassCutoff=h;break}}this.maybeDrawDepth(!1),this.renderToTexture&&(this.renderToTexture.prepareForRender(this.style,this.transform.zoom),this.opaquePassCutoff=0),this.renderPass="offscreen";for(let h of i){let e=this.style._layers[h];if(!e.hasOffscreenPass()||e.isHidden(this.transform.zoom))continue;let t=n[e.source];"custom"!==e.type&&!t.length||this.renderLayer(this,r[e.source],e,t,o)}if(this.context.viewport.set([0,0,this.width,this.height]),this.context.bindFramebuffer.set(null),this.context.clear({color:t.showOverdrawInspector?Si.black:Si.transparent,depth:1}),this.clearStencil(),this.style.sky&&this.drawFunctions.sky(this,this.style.sky),this._showOverdrawInspector=t.showOverdrawInspector,this.depthRangeFor3D=[0,1-(e._order.length+2)*this.numSublayers*this.depthEpsilon],!this.renderToTexture)for(this.renderPass="opaque",this.currentLayer=i.length-1;this.currentLayer>=0;this.currentLayer--){let e=this.style._layers[i[this.currentLayer]],t=r[e.source],n=a[e.source];this.renderTileClippingMasks(e,n,!1),this.renderLayer(this,t,e,n,o)}this.renderPass="translucent";let l=!1;for(this.currentLayer=0;this.currentLayer<i.length;this.currentLayer++){let e=this.style._layers[i[this.currentLayer]],t=r[e.source];if(this.renderToTexture?.renderLayer(e,o))continue;!this.opaquePassEnabledForLayer()&&!l&&(l=!0,o.isRenderingGlobe&&!this.style.map.terrain&&this._renderTilesDepthBuffer());let h=("symbol"===e.type?s:n)[e.source];this.renderTileClippingMasks(e,a[e.source],!!this.renderToTexture),this.renderLayer(this,t,e,h,o)}if(o.isRenderingGlobe&&this.drawFunctions.atmosphere(this,this.style.sky,this.style.light),this.options.showTileBoundaries){let e=function(e,t){let i=null,r=Object.values(e._layers).flatMap(i=>i.source&&!i.isHidden(t)?[e.tileManagers[i.source]]:[]),a=r.filter(e=>"vector"===e.getSource().type),n=r.filter(e=>"vector"!==e.getSource().type),s=e=>{(!i||i.getSource().maxzoom<e.getSource().maxzoom)&&(i=e)};for(let o of a)s(o);if(!i)for(let o of n)s(o);return i}(this.style,this.transform.zoom);e&&this.drawFunctions.debug(this,e,e.getVisibleCoordinates())}this.options.showPadding&&this.drawFunctions.debugPadding(this),this.context.setDefault()}maybeDrawDepth(e){if(!this.style?.map?.terrain)return;let t=this.terrainFacilitator.matrix,i=this.transform.modelViewProjectionMatrix,r=this.terrainFacilitator.depthDirty;r||=e?!function(e,t){return e[0]===t[0]&&e[1]===t[1]&&e[2]===t[2]&&e[3]===t[3]&&e[4]===t[4]&&e[5]===t[5]&&e[6]===t[6]&&e[7]===t[7]&&e[8]===t[8]&&e[9]===t[9]&&e[10]===t[10]&&e[11]===t[11]&&e[12]===t[12]&&e[13]===t[13]&&e[14]===t[14]&&e[15]===t[15]}(t,i):!function(e,t){var i=e[0],r=e[1],a=e[2],n=e[3],s=e[4],o=e[5],l=e[6],h=e[7],u=e[8],c=e[9],p=e[10],d=e[11],f=e[12],m=e[13],_=e[14],g=e[15],y=t[0],v=t[1],x=t[2],b=t[3],w=t[4],T=t[5],S=t[6],P=t[7],I=t[8],M=t[9],E=t[10],A=t[11],C=t[12],D=t[13],z=t[14],R=t[15];return Math.abs(i-y)<=1e-6*Math.max(1,Math.abs(i),Math.abs(y))&&Math.abs(r-v)<=1e-6*Math.max(1,Math.abs(r),Math.abs(v))&&Math.abs(a-x)<=1e-6*Math.max(1,Math.abs(a),Math.abs(x))&&Math.abs(n-b)<=1e-6*Math.max(1,Math.abs(n),Math.abs(b))&&Math.abs(s-w)<=1e-6*Math.max(1,Math.abs(s),Math.abs(w))&&Math.abs(o-T)<=1e-6*Math.max(1,Math.abs(o),Math.abs(T))&&Math.abs(l-S)<=1e-6*Math.max(1,Math.abs(l),Math.abs(S))&&Math.abs(h-P)<=1e-6*Math.max(1,Math.abs(h),Math.abs(P))&&Math.abs(u-I)<=1e-6*Math.max(1,Math.abs(u),Math.abs(I))&&Math.abs(c-M)<=1e-6*Math.max(1,Math.abs(c),Math.abs(M))&&Math.abs(p-E)<=1e-6*Math.max(1,Math.abs(p),Math.abs(E))&&Math.abs(d-A)<=1e-6*Math.max(1,Math.abs(d),Math.abs(A))&&Math.abs(f-C)<=1e-6*Math.max(1,Math.abs(f),Math.abs(C))&&Math.abs(m-D)<=1e-6*Math.max(1,Math.abs(m),Math.abs(D))&&Math.abs(_-z)<=1e-6*Math.max(1,Math.abs(_),Math.abs(z))&&Math.abs(g-R)<=1e-6*Math.max(1,Math.abs(g),Math.abs(R))}(t,i),r||=this.style.map.terrain.tileManager.anyTilesAfterTime(this.terrainFacilitator.renderTime),r&&(function(e,t){e[0]=t[0],e[1]=t[1],e[2]=t[2],e[3]=t[3],e[4]=t[4],e[5]=t[5],e[6]=t[6],e[7]=t[7],e[8]=t[8],e[9]=t[9],e[10]=t[10],e[11]=t[11],e[12]=t[12],e[13]=t[13],e[14]=t[14],e[15]=t[15]}(t,i),this.terrainFacilitator.renderTime=sm(),this.terrainFacilitator.depthDirty=!1,this.terrainFacilitator.coordsDirty=!0,this.drawFunctions.terrainDepth(this,this.style.map.terrain))}maybeDrawCoords(){!this.style?.map?.terrain||!this.terrainFacilitator.coordsDirty||(this.terrainFacilitator.coordsDirty=!1,this.drawFunctions.terrainCoords(this,this.style.map.terrain))}renderLayer(e,t,i,r,a){if(i.isHidden(this.transform.zoom)||"background"!==i.type&&"custom"!==i.type&&!(r||[]).length)return;this.id=i.id;let n=this.drawFunctions;wp(i)?n.symbol(e,t,i,r,this.style.placement.variableOffsets,a):(e=>"circle"===e.type)(i)?n.circle(e,t,i,r,a):(e=>"heatmap"===e.type)(i)?n.heatmap(e,t,i,r,a):(e=>"line"===e.type)(i)?n.line(e,t,i,r,a):(e=>"fill"===e.type)(i)?n.fill(e,t,i,r,a):(e=>"fill-extrusion"===e.type)(i)?n.fillExtrusion(e,t,i,r,a):(e=>"hillshade"===e.type)(i)?n.hillshade(e,t,i,r,a):(e=>"color-relief"===e.type)(i)?n.colorRelief(e,t,i,r,a):Ns(i)?n.raster(e,t,i,r,a):(e=>"background"===e.type)(i)?n.background(e,t,i,r,a):(e=>"custom"===e.type)(i)&&n.custom(e,t,i,a)}static{this.MAX_TEXTURE_POOL_SIZE_PER_BUCKET=50}saveTileTexture(t){let i=this._tileTextures[t.size[0]];i?i.length<e.MAX_TEXTURE_POOL_SIZE_PER_BUCKET?i.push(t):t.destroy():this._tileTextures[t.size[0]]=[t]}getTileTexture(e){let t=this._tileTextures[e];return t&&t.length>0?t.pop():null}acquireRTT(e){let t=this.context.gl,i=this._rttObjectRecyclePool.pop();if(i)return i.size!==e&&(t.bindTexture(t.TEXTURE_2D,i.texture.texture),t.texImage2D(t.TEXTURE_2D,0,t.RGBA,e,e,0,t.RGBA,t.UNSIGNED_BYTE,null),i.texture.size=[e,e],i.size=e),i;let r=new Ah(this.context,{width:e,height:e,data:null},t.RGBA);return r.bind(t.LINEAR,t.CLAMP_TO_EDGE),this.context.extTextureFilterAnisotropic&&t.texParameterf(t.TEXTURE_2D,this.context.extTextureFilterAnisotropic.TEXTURE_MAX_ANISOTROPY_EXT,this.context.extTextureFilterAnisotropicMax),{texture:r,size:e}}bindRTT(e){let t=this.context.gl,i=e.size;if(!this._rttSharedFbo){let e=this.context.createFramebuffer(i,i,!0,!0),r=this.context.createRenderbuffer(t.DEPTH_STENCIL,i,i);e.depthAttachment.set(r),this._rttSharedFbo={fbo:e,depthRenderbuffer:r,size:i}}this._rttSharedFbo.size!==i&&(this.context.bindRenderbuffer.set(this._rttSharedFbo.depthRenderbuffer),t.renderbufferStorage(t.RENDERBUFFER,t.DEPTH_STENCIL,i,i),this.context.bindRenderbuffer.set(null),this._rttSharedFbo.fbo.width=i,this._rttSharedFbo.fbo.height=i,this._rttSharedFbo.size=i),this._rttSharedFbo.fbo.colorAttachment.set(e.texture.texture),this.context.bindFramebuffer.set(this._rttSharedFbo.fbo.framebuffer)}releaseRTT(e){this._rttObjectRecyclePool.push(e)}isPatternMissing(e){if(!e)return!1;if(!e.from||!e.to)return!0;let t=this.patternAtlas.getPattern(e.from.toString()),i=this.patternAtlas.getPattern(e.to.toString());return!t||!i}useProgram(e,t,i=!1,r=[]){this.cache||={};let a=!!this.style.map.terrain,n=this.style.projection,s=i?ty.projectionMercator:n.shaderPreludeCode,o=i?ny:n.shaderDefine,l=`/${i?sy:n.shaderVariantName}`,h=e+(t?t.cacheKey:"")+l+(this._showOverdrawInspector?"/overdraw":"")+(a?"/terrain":"")+(r?`/${r.join("/")}`:"");return this.cache[h]||=new ev(this.context,ty[e],t,Dv[e],this._showOverdrawInspector,a,s,o,r),this.cache[h]}setCustomLayerDefaults(){this.context.setCustomLayerDefaults()}setBaseState(){let e=this.context.gl;this.context.cullFace.set(!1),this.context.viewport.set([0,0,this.width,this.height]),this.context.blendEquation.set(e.FUNC_ADD)}initDebugOverlayCanvas(){if(null==this.debugOverlayCanvas){this.debugOverlayCanvas=document.createElement("canvas"),this.debugOverlayCanvas.width=512,this.debugOverlayCanvas.height=512;let e=this.context.gl;this.debugOverlayTexture=new Ah(this.context,this.debugOverlayCanvas,e.RGBA)}}destroy(){if(this._tileTextures){for(let e in this._tileTextures){let t=this._tileTextures[e];if(t)for(let e of t)e.destroy()}this._tileTextures={}}for(let e of this._rttObjectRecyclePool)e.texture.destroy();if(this._rttObjectRecyclePool=[],this._rttSharedFbo){this._rttSharedFbo.fbo.colorAttachment.set(null),this._rttSharedFbo.fbo.depthAttachment.set(null);let e=this.context.gl;e.deleteRenderbuffer(this._rttSharedFbo.depthRenderbuffer),e.deleteFramebuffer(this._rttSharedFbo.fbo.framebuffer),this._rttSharedFbo=null}if(this.layerOpacityFbo?.destroy(),this.layerOpacityFbo=null,this.tileExtentBuffer&&this.tileExtentBuffer.destroy(),this.debugBuffer&&this.debugBuffer.destroy(),this.rasterBoundsBuffer&&this.rasterBoundsBuffer.destroy(),this.rasterBoundsBufferPosOnly&&this.rasterBoundsBufferPosOnly.destroy(),this.viewportBuffer&&this.viewportBuffer.destroy(),this.tileBorderIndexBuffer&&this.tileBorderIndexBuffer.destroy(),this.quadTriangleIndexBuffer&&this.quadTriangleIndexBuffer.destroy(),this.tileExtentMesh&&this.tileExtentMesh.vertexBuffer?.destroy(),this.tileExtentMesh&&this.tileExtentMesh.indexBuffer?.destroy(),this.debugOverlayTexture&&this.debugOverlayTexture.destroy(),this.cache){for(let e in this.cache){let t=this.cache[e];t?.program&&this.context.gl.deleteProgram(t.program)}this.cache={}}this.context&&this.context.setDefault()}overLimit(){let{drawingBufferWidth:e,drawingBufferHeight:t}=this.context.gl;return this.width!==e||this.height!==t}},gb=class extends Error{constructor(e,t){super("WebGL2 is required to display this map. We are sorry, but it seems that your browser does not support WebGL2, a technology for rendering 3D graphics on the web. Read more on https://wiki.openstreetmap.org/wiki/This_map_requires_WebGL"),this.name="GPUInitializationError",this.requestedAttributes=e,this.statusMessage=t?.statusMessage??null}};function yb(e,t){let i,r=!1,a=null,n=()=>{a=null,r&&=(e(...i),a=setTimeout(n,t),!1)};return(...e)=>(r=!0,i=e,a||n(),a)}var vb=class{constructor(e){this._getHashParams=()=>new URLSearchParams(window.location.hash.replace("#","")),this._getCurrentHash=()=>{let e=this._getHashParams();return this._hashName?(e.get(this._hashName)||"").split("/"):([...e.keys()][0]??"").split("/")},this._onHashChange=()=>{let e=this._getCurrentHash();if(!this._isValidHash(e))return!1;let t=this._map.dragRotate.isEnabled()&&this._map.touchZoomRotate.isEnabled()?+(e[3]||0):this._map.getBearing();return this._map.jumpTo({center:[+e[2],+e[1]],zoom:+e[0],bearing:t,pitch:+(e[4]||0)}),!0},this._updateHashUnthrottled=()=>{let e=window.location.href.replace(/(#.*)?$/,this.getHashString());window.history.replaceState(window.history.state,null,e)},this._removeHash=()=>{let e=this._getHashParams();if(this._hashName)e.delete(this._hashName);else{let t=Array.from(e.keys());t.length>0&&e.delete(t[0])}let t=decodeURIComponent(e.toString()).replace(/=&/g,"&").replace(/=$/g,""),i=t?`#${t}`:"",r=window.location.href.replace(/(#.+)?$/,i);r=r.replace("&&","&"),window.history.replaceState(window.history.state,null,r)},this._updateHash=yb(this._updateHashUnthrottled,300),this._hashName=e&&encodeURIComponent(e)}addTo(e){return this._map=e,addEventListener("hashchange",this._onHashChange,!1),this._map.on("moveend",this._updateHash),this}remove(){return removeEventListener("hashchange",this._onHashChange,!1),this._map.off("moveend",this._updateHash),clearTimeout(this._updateHash()),this._removeHash(),delete this._map,this}getHashString(e){let t=this._map.getCenter(),i=Math.round(100*this._map.getZoom())/100,r=10**Math.ceil((i*Math.LN2+Math.log(512/360/.5))/Math.LN10),a=Math.round(t.lng*r)/r,n=Math.round(t.lat*r)/r,s=this._map.getBearing(),o=this._map.getPitch(),l="";if(l+=e?`/${a}/${n}/${i}`:`${i}/${n}/${a}`,(s||o)&&(l+="/"+Math.round(10*s)/10),o&&(l+=`/${Math.round(o)}`),this._hashName){let e=this._getHashParams();return e.set(this._hashName,l),`#${decodeURIComponent(e.toString()).replace(/=&/g,"&").replace(/=$/g,"")}`}return`#${l}`}_isValidHash(e){if(e.length<3||e.some(e=>isNaN(+e)))return!1;try{new Xu(+e[2],+e[1])}catch{return!1}let t=+e[0],i=+(e[3]||0),r=+(e[4]||0);return t>=this._map.getMinZoom()&&t<=this._map.getMaxZoom()&&i>=-180&&i<=180&&r>=this._map.getMinPitch()&&r<=this._map.getMaxPitch()}},xb={linearity:.3,easing:ge(0,0,.3,1)},bb=be({deceleration:2500,maxSpeed:1400},xb),wb=be({deceleration:20,maxSpeed:1400},xb),Tb=be({deceleration:1e3,maxSpeed:360},xb),Sb=be({deceleration:1e3,maxSpeed:90},xb),Pb=be({deceleration:1e3,maxSpeed:360},xb),Ib=class{constructor(e){this._map=e,this.clear()}clear(){this._inertiaBuffer=[]}record(e){this._drainInertiaBuffer(),this._inertiaBuffer.push({time:sm(),settings:e})}_drainInertiaBuffer(){let e=this._inertiaBuffer,t=sm();for(;e.length>0&&t-e[0].time>160;)e.shift()}_getVelocityEntries(){let e=this._inertiaBuffer,t=sm()-60,i=Math.max(0,e.length-2);for(;i>0&&e[i-1].time>=t;)i--;return e.slice(i)}_onMoveEnd(e){this._drainInertiaBuffer();let t=this._getVelocityEntries();if(t.length<2)return void this.clear();let i={zoom:0,bearing:0,pitch:0,roll:0,pan:new u(0,0),pinchAround:void 0,around:void 0};for(let{settings:n}of t)n.around&&(i.around=n.around),n.pinchAround&&(i.pinchAround=n.pinchAround);for(let{settings:n}of t.slice(1))i.zoom+=n.zoomDelta||0,i.bearing+=n.bearingDelta||0,i.pitch+=n.pitchDelta||0,i.roll+=n.rollDelta||0,n.panDelta&&i.pan._add(n.panDelta);if(!(i.pan.mag()||i.zoom||i.bearing||i.pitch||i.roll))return void this.clear();let r=sm()-t[0].time,a={};if(i.pan.mag()){let t=Eb(i.pan.mag(),r,be({},bb,e||{})),n=i.pan.mult(t.amount/i.pan.mag()),s=this._map._camera.cameraHelper.handlePanInertia(n,this._map._camera.transform);a.center=s.easingCenter,a.offset=s.easingOffset,Mb(a,t)}if(i.zoom){let e=Eb(i.zoom,r,wb);a.zoom=Me(this._map.getZoom()+e.amount,this._map.getZoomSnap(),e.amount),Mb(a,e)}if(i.bearing){let e=Eb(i.bearing,r,Tb);a.bearing=this._map.getBearing()+ve(e.amount,-179,179),Mb(a,e)}if(i.pitch){let e=Eb(i.pitch,r,Sb);a.pitch=this._map.getPitch()+e.amount,Mb(a,e)}if(i.roll){let e=Eb(i.roll,r,Pb);a.roll=this._map.getRoll()+ve(e.amount,-179,179),Mb(a,e)}if(a.zoom||a.bearing){let e=void 0===i.pinchAround?i.around:i.pinchAround;a.around=e?this._map.unproject(e):this._map.getCenter()}return this.clear(),be(a,{noMoveStart:!0})}};function Mb(e,t){(!e.duration||e.duration<t.duration)&&(e.duration=t.duration,e.easing=t.easing)}function Eb(e,t,i){let{maxSpeed:r,linearity:a,deceleration:n}=i,s=ve(e*a/(t/1e3),-r,r),o=Math.abs(s)/(n*a);return{easing:i.easing,duration:1e3*o,amount:o/2*s}}var Ab=class{constructor(e,t){this._map=e,this._clickTolerance=t.clickTolerance}reset(){delete this._mousedownPos}wheel(e){return this._firePreventable(new xm(this._map,e))}mousedown(e,t){return this._mousedownPos=t,this._firePreventable(new ym(e.type,this._map,e))}mouseup(e){this._map.fire(new ym(e.type,this._map,e))}click(e,t){this._mousedownPos&&this._mousedownPos.dist(t)>=this._clickTolerance||this._map.fire(new ym(e.type,this._map,e))}dblclick(e){return this._firePreventable(new ym(e.type,this._map,e))}mouseover(e){this._map.fire(new ym(e.type,this._map,e))}mouseout(e){this._map.fire(new ym(e.type,this._map,e))}touchstart(e){return this._firePreventable(new vm(e.type,this._map,e))}touchmove(e){this._map.fire(new vm(e.type,this._map,e))}touchend(e){this._map.fire(new vm(e.type,this._map,e))}touchcancel(e){this._map.fire(new vm(e.type,this._map,e))}_firePreventable(e){if(this._map.fire(e),e.defaultPrevented)return{}}isEnabled(){return!0}isActive(){return!1}enable(){}disable(){}},Cb=class{constructor(e){this._map=e}reset(){this._delayContextMenu=!1,this._ignoreContextMenu=!0,delete this._contextMenuEvent}mousemove(e){this._map.fire(new ym(e.type,this._map,e))}mousedown(){this._delayContextMenu=!0,this._ignoreContextMenu=!1}mouseup(){this._delayContextMenu=!1,this._contextMenuEvent&&(this._map.fire(new ym("contextmenu",this._map,this._contextMenuEvent)),delete this._contextMenuEvent)}contextmenu(e){this._delayContextMenu?this._contextMenuEvent=e:this._ignoreContextMenu||this._map.fire(new ym(e.type,this._map,e)),this._map.listens("contextmenu")&&e.preventDefault()}isEnabled(){return!0}isActive(){return!1}enable(){}disable(){}},Db=class{constructor(e,t,i){this._map=e,this._tr=i,this._el=e.getCanvasContainer(),this._container=e.getContainer(),this._clickTolerance=t.clickTolerance||1,t.boxZoom&&"object"==typeof t.boxZoom&&(this._boxZoomEnd=t.boxZoom.boxZoomEnd)}isEnabled(){return!!this._enabled}isActive(){return!!this._active}enable(){this.isEnabled()||(this._enabled=!0)}disable(){this.isEnabled()&&(this._enabled=!1)}mousedown(e,t){this.isEnabled()&&e.shiftKey&&0===e.button&&(cm.disableDrag(),this._startPos=this._lastPos=t,this._active=!0)}mousemoveWindow(e,t){if(!this._active)return;let i=t;if(this._lastPos.equals(i)||!this._box&&i.dist(this._startPos)<this._clickTolerance)return;let r=this._startPos;this._lastPos=i,this._box||(this._box=cm.create("div","maplibregl-boxzoom",this._container),this._container.classList.add("maplibregl-crosshair"),this._fireEvent("boxzoomstart",e));let a=Math.min(r.x,i.x),n=Math.max(r.x,i.x),s=Math.min(r.y,i.y),o=Math.max(r.y,i.y);this._box.style.transform=`translate(${a}px,${s}px)`,this._box.style.width=n-a+"px",this._box.style.height=o-s+"px"}mouseupWindow(e,t){if(!this._active||0!==e.button)return;let i=this._startPos,r=t;if(this.reset(),cm.suppressClick(),i.x!==r.x||i.y!==r.y)return this._map.fire(new bm("boxzoomend",{originalEvent:e})),this._boxZoomEnd?void this._boxZoomEnd(this._map,i,r,e):{cameraAnimation:e=>e.fitScreenCoordinates(i,r,this._tr.bearing,{linear:!0})};this._fireEvent("boxzoomcancel",e)}keydown(e){this._active&&27===e.keyCode&&(this.reset(),this._fireEvent("boxzoomcancel",e))}reset(){this._active=!1,this._container.classList.remove("maplibregl-crosshair"),this._box&&=(this._box.remove(),null),cm.enableDrag(),delete this._startPos,delete this._lastPos}_fireEvent(e,t){return this._map.fire(new bm(e,{originalEvent:t}))}};function zb(e,t){if(e.length!==t.length)throw Error(`The number of touches and points are not equal - touches ${e.length}, points ${t.length}`);let i={};for(let r=0;r<e.length;r++)i[e[r].identifier]=t[r];return i}var Rb=class{constructor(e){this.reset(),this.numTouches=e.numTouches}reset(){delete this.centroid,delete this.startTime,delete this.touches,this.aborted=!1}touchstart(e,t,i){(this.centroid||i.length>this.numTouches)&&(this.aborted=!0),!this.aborted&&(void 0===this.startTime&&(this.startTime=e.timeStamp),i.length===this.numTouches&&(this.centroid=function(e){let t=new u(0,0);for(let i of e)t._add(i);return t.div(e.length)}(t),this.touches=zb(i,t)))}touchmove(e,t,i){if(this.aborted||!this.centroid)return;let r=zb(i,t);for(let a in this.touches){let e=this.touches[a],t=r[a];(!t||t.dist(e)>30)&&(this.aborted=!0)}}touchend(e,t,i){if((!this.centroid||e.timeStamp-this.startTime>500)&&(this.aborted=!0),0===i.length){let e=!this.aborted&&this.centroid;if(this.reset(),e)return e}}},kb=class{constructor(e){this.singleTap=new Rb(e),this.numTaps=e.numTaps,this.reset()}reset(){this.lastTime=1/0,delete this.lastTap,this.count=0,this.singleTap.reset()}touchstart(e,t,i){this.singleTap.touchstart(e,t,i)}touchmove(e,t,i){this.singleTap.touchmove(e,t,i)}touchend(e,t,i){let r=this.singleTap.touchend(e,t,i);if(r){let t=e.timeStamp-this.lastTime<500,i=!this.lastTap||this.lastTap.dist(r)<30;if((!t||!i)&&this.reset(),this.count++,this.lastTime=e.timeStamp,this.lastTap=r,this.count===this.numTaps)return this.reset(),r}}},Lb=class{constructor(e,t){this._tr=t,this._zoomIn=new kb({numTouches:1,numTaps:2}),this._zoomOut=new kb({numTouches:2,numTaps:1}),this.reset()}reset(){this._active=!1,this._zoomIn.reset(),this._zoomOut.reset()}touchstart(e,t,i){this._zoomIn.touchstart(e,t,i),this._zoomOut.touchstart(e,t,i)}touchmove(e,t,i){this._zoomIn.touchmove(e,t,i),this._zoomOut.touchmove(e,t,i)}touchend(e,t,i){let r=this._zoomIn.touchend(e,t,i),a=this._zoomOut.touchend(e,t,i),n=this._tr;return r?(this._active=!0,e.preventDefault(),setTimeout(()=>this.reset(),0),{cameraAnimation:t=>t.easeTo({duration:300,zoom:Me(n.zoom+1,t.getZoomSnap()),around:n.unproject(r)},{originalEvent:e})}):a?(this._active=!0,e.preventDefault(),setTimeout(()=>this.reset(),0),{cameraAnimation:t=>t.easeTo({duration:300,zoom:Me(n.zoom-1,t.getZoomSnap()),around:n.unproject(a)},{originalEvent:e})}):void 0}touchcancel(){this.reset()}enable(){this._enabled=!0}disable(){this._enabled=!1,this.reset()}isEnabled(){return this._enabled}isActive(){return this._active}},Fb=class{constructor(e){this._enabled=!!e.enable,this._moveStateManager=e.moveStateManager,this._clickTolerance=e.clickTolerance||1,this._moveFunction=e.move,this._activateOnStart=!!e.activateOnStart,e.assignEvents(this),this.reset()}reset(e){this._active=!1,this._moved=!1,delete this._lastPoint,this._moveStateManager.endMove(e)}_move(...e){let t=this._moveFunction(...e);if(t.bearingDelta||t.pitchDelta||t.rollDelta||t.around||t.panDelta)return this._active=!0,t}dragStart(e,t){!this.isEnabled()||this._lastPoint||this._moveStateManager.isValidStartEvent(e)&&(this._moveStateManager.startMove(e),this._lastPoint=Array.isArray(t)?t[0]:t,this._activateOnStart&&this._lastPoint&&(this._active=!0))}dragMove(e,t){if(!this.isEnabled())return;let i=this._lastPoint;if(!i)return;if(e.preventDefault(),!this._moveStateManager.isValidMoveEvent(e))return void this.reset(e);let r=Array.isArray(t)?t[0]:t;return!this._moved&&r.dist(i)<this._clickTolerance?void 0:(this._moved=!0,this._lastPoint=r,this._move(i,r))}dragEnd(e){!this.isEnabled()||!this._lastPoint||this._moveStateManager.isValidEndEvent(e)&&(this._moved&&cm.suppressClick(),this.reset(e))}enable(){this._enabled=!0}disable(){this._enabled=!1,this.reset()}isEnabled(){return this._enabled}isActive(){return this._active}getClickTolerance(){return this._clickTolerance}},Bb={0:1,2:2},Ob=class{constructor(e){this._correctEvent=e.checkCorrectEvent}startMove(e){this._eventButton=e.button}endMove(e){delete this._eventButton}isValidStartEvent(e){return this._correctEvent(e)}isValidMoveEvent(e){return!function(e,t){let i=Bb[t];return void 0===e.buttons||(e.buttons&i)!==i}(e,this._eventButton)}isValidEndEvent(e){return e.button===this._eventButton}},Vb=class{constructor(){this._firstTouch=void 0}_isOneFingerTouch(e){return 1===e.targetTouches.length}_isSameTouchEvent(e){return e.targetTouches[0].identifier===this._firstTouch}startMove(e){this._firstTouch=e.targetTouches[0].identifier}endMove(e){delete this._firstTouch}isValidStartEvent(e){return this._isOneFingerTouch(e)}isValidMoveEvent(e){return this._isOneFingerTouch(e)&&this._isSameTouchEvent(e)}isValidEndEvent(e){return this._isOneFingerTouch(e)&&this._isSameTouchEvent(e)}},jb=class{constructor(e=new Ob({checkCorrectEvent:()=>!0}),t=new Vb){this.mouseMoveStateManager=e,this.oneFingerTouchMoveStateManager=t}_executeRelevantHandler(e,t,i){return e instanceof MouseEvent?t(e):typeof TouchEvent<"u"&&e instanceof TouchEvent?i(e):void 0}startMove(e){this._executeRelevantHandler(e,e=>{this.mouseMoveStateManager.startMove(e)},e=>{this.oneFingerTouchMoveStateManager.startMove(e)})}endMove(e){this._executeRelevantHandler(e,e=>{this.mouseMoveStateManager.endMove(e)},e=>{this.oneFingerTouchMoveStateManager.endMove(e)})}isValidStartEvent(e){return!!this._executeRelevantHandler(e,e=>this.mouseMoveStateManager.isValidStartEvent(e),e=>this.oneFingerTouchMoveStateManager.isValidStartEvent(e))}isValidMoveEvent(e){return!!this._executeRelevantHandler(e,e=>this.mouseMoveStateManager.isValidMoveEvent(e),e=>this.oneFingerTouchMoveStateManager.isValidMoveEvent(e))}isValidEndEvent(e){return!!this._executeRelevantHandler(e,e=>this.mouseMoveStateManager.isValidEndEvent(e),e=>this.oneFingerTouchMoveStateManager.isValidEndEvent(e))}},Nb=e=>{e.mousedown=e.dragStart,e.mousemoveWindow=e.dragMove,e.mouseup=e.dragEnd,e.contextmenu=e=>{e.preventDefault()}};function Ub({enable:e,clickTolerance:t,aroundCenter:i=!0,minPixelCenterThreshold:r=100,rotateSpeed:a=.8},n){return new Fb({clickTolerance:t,move:(e,t)=>{let s=n();if(i&&Math.abs(s.y-e.y)>r)return{bearingDelta:$e(new u(e.x,t.y),t,s)};let o=(t.x-e.x)*a;return i&&t.y<s.y&&(o=-o),{bearingDelta:o}},moveStateManager:new Ob({checkCorrectEvent:e=>0===e.button&&e.ctrlKey||2===e.button&&!e.ctrlKey}),enable:e,assignEvents:Nb})}var Gb=class{constructor(e,t){this._clickTolerance=e.clickTolerance||1,this._map=t,this.reset()}reset(){this._active=!1,this._touches={},this._sum=new u(0,0)}_shouldBePrevented(e){return e<(this._map.cooperativeGestures.isEnabled()?2:1)}touchstart(e,t,i){return this._calculateTransform(e,t,i)}touchmove(e,t,i){if(this._active)return this._shouldBePrevented(i.length)?void this._map.cooperativeGestures.notifyGestureBlocked("touch_pan",e):(e.preventDefault(),this._calculateTransform(e,t,i))}touchend(e,t,i){this._calculateTransform(e,t,i),this._active&&this._shouldBePrevented(i.length)&&this.reset()}touchcancel(){this.reset()}_calculateTransform(e,t,i){i.length>0&&(this._active=!0);let r=zb(i,t),a=new u(0,0),n=new u(0,0),s=0;for(let l in r){let e=r[l],t=this._touches[l];t&&(a._add(e),n._add(e.sub(t)),s++,r[l]=e)}if(this._touches=r,this._shouldBePrevented(s)||!n.mag())return;let o=n.div(s);return this._sum._add(o),this._sum.mag()<this._clickTolerance?void 0:{around:a.div(s),panDelta:o}}enable(){this._enabled=!0}disable(){this._enabled=!1,this.reset()}isEnabled(){return this._enabled}isActive(){return this._active}},$b=class{constructor(){this.reset()}reset(){this._active=!1,delete this._firstTwoTouches}touchstart(e,t,i){this._firstTwoTouches||i.length<2||(this._firstTwoTouches=[i[0].identifier,i[1].identifier],this._start([t[0],t[1]]))}touchmove(e,t,i){if(!this._firstTwoTouches)return;e.preventDefault();let[r,a]=this._firstTwoTouches,n=Zb(i,t,r),s=Zb(i,t,a);if(!n||!s)return;let o=this._aroundCenter?null:n.add(s).div(2);return this._move([n,s],o,e)}touchend(e,t,i){if(!this._firstTwoTouches)return;let[r,a]=this._firstTwoTouches,n=Zb(i,t,r),s=Zb(i,t,a);n&&s||(this._active&&cm.suppressClick(),this.reset())}touchcancel(){this.reset()}enable(e){this._enabled=!0,this._aroundCenter=!!e&&"center"===e.around}disable(){this._enabled=!1,this.reset()}isEnabled(){return!!this._enabled}isActive(){return!!this._active}};function Zb(e,t,i){for(let r=0;r<e.length;r++)if(e[r].identifier===i)return t[r]}function qb(e,t){return Math.log(e/t)/Math.LN2}var Wb=class extends $b{constructor(){super(),this._zoomRate=1,this._zoomThreshold=.1}setZoomRate(e){this._zoomRate=e??1}setZoomThreshold(e){this._zoomThreshold=e??.1}reset(){super.reset(),delete this._distance,delete this._startDistance}_start(e){this._startDistance=this._distance=e[0].dist(e[1])}_move(e,t){let i=this._distance;if(this._distance=e[0].dist(e[1]),this._active||!(Math.abs(qb(this._distance,this._startDistance))<this._zoomThreshold))return this._active=!0,{zoomDelta:qb(this._distance,i)*this._zoomRate,pinchAround:t}}};function Hb(e,t){return 180*e.angleWith(t)/Math.PI}var Xb=class extends $b{reset(){super.reset(),delete this._minDiameter,delete this._startVector,delete this._vector}_start(e){this._startVector=this._vector=e[0].sub(e[1]),this._minDiameter=e[0].dist(e[1])}_move(e,t,i){let r=this._vector;if(this._vector=e[0].sub(e[1]),this._active||!this._isBelowThreshold(this._vector))return this._active=!0,{bearingDelta:Hb(this._vector,r),pinchAround:t}}_isBelowThreshold(e){this._minDiameter=Math.min(this._minDiameter,e.mag());let t=25/(Math.PI*this._minDiameter)*360,i=Hb(e,this._startVector);return Math.abs(i)<t}};function Yb(e){return Math.abs(e.y)>Math.abs(e.x)}var Kb=class extends $b{constructor(e){super(),this._currentTouchCount=0,this._map=e}reset(){super.reset(),this._valid=void 0,delete this._firstMove,delete this._lastPoints}touchstart(e,t,i){super.touchstart(e,t,i),this._currentTouchCount=i.length}_start(e){this._lastPoints=e,Yb(e[0].sub(e[1]))&&(this._valid=!1)}_move(e,t,i){if(this._map.cooperativeGestures.isEnabled()&&this._currentTouchCount<3)return;let r=e[0].sub(this._lastPoints[0]),a=e[1].sub(this._lastPoints[1]);return this._valid=this.gestureBeginsVertically(r,a,i.timeStamp),this._valid?(this._lastPoints=e,this._active=!0,{pitchDelta:(r.y+a.y)/2*-.5}):void 0}gestureBeginsVertically(e,t,i){if(void 0!==this._valid)return this._valid;let r=e.mag()>=2,a=t.mag()>=2;if(!r&&!a)return;if(!r||!a)return void 0===this._firstMove&&(this._firstMove=i),i-this._firstMove<100&&void 0;let n=e.y>0==t.y>0;return Yb(e)&&Yb(t)&&n}},Jb={panStep:100,bearingStep:15,pitchStep:10},Qb=class{constructor(e,t){this._tr=t;let i=Jb;this._panStep=i.panStep,this._bearingStep=i.bearingStep,this._pitchStep=i.pitchStep,this._rotationDisabled=!1}reset(){this._active=!1}keydown(e){if(e.altKey||e.ctrlKey||e.metaKey)return;let t=0,i=0,r=0,a=0,n=0;switch(e.keyCode){case 61:case 107:case 171:case 187:t=1;break;case 189:case 109:case 173:t=-1;break;case 37:e.shiftKey?i=-1:(e.preventDefault(),a=-1);break;case 39:e.shiftKey?i=1:(e.preventDefault(),a=1);break;case 38:e.shiftKey?r=1:(e.preventDefault(),n=-1);break;case 40:e.shiftKey?r=-1:(e.preventDefault(),n=1);break;default:return}return this._rotationDisabled&&(i=0,r=0),{cameraAnimation:s=>{let o=this._tr;s.easeTo({duration:300,easeId:"keyboardHandler",easing:ew,zoom:t?Me(o.zoom+t*(e.shiftKey?2:1),s.getZoomSnap()):o.zoom,bearing:o.bearing+i*this._bearingStep,pitch:o.pitch+r*this._pitchStep,offset:[-a*this._panStep,-n*this._panStep],center:o.center},{originalEvent:e})}}}enable(){this._enabled=!0}disable(){this._enabled=!1,this.reset()}isEnabled(){return this._enabled}isActive(){return this._active}disableRotation(){this._rotationDisabled=!0}enableRotation(){this._rotationDisabled=!1}};function ew(e){return e*(2-e)}var tw=4.000244140625,iw=class{constructor(e,t,i){this._onTimeout=e=>{this._type="wheel",this._delta-=this._lastValue,this._active||this._start(e)},this._map=e,this._tr=i,this._triggerRenderFrame=t,this._delta=0,this._defaultZoomRate=.01,this._wheelZoomRate=.0022222222222222222}setZoomRate(e){this._defaultZoomRate=e}setWheelZoomRate(e){this._wheelZoomRate=e}isEnabled(){return!!this._enabled}isActive(){return!!this._active||void 0!==this._finishTimeout}isZooming(){return!!this._zooming}enable(e){this.isEnabled()||(this._enabled=!0,this._aroundCenter=!!e&&"center"===e.around)}disable(){this.isEnabled()&&(this._enabled=!1)}_shouldBePrevented(e){return!!this._map.cooperativeGestures.isEnabled()&&!(e.ctrlKey||this._map.cooperativeGestures.isBypassed(e))}wheel(e){if(!this.isEnabled())return;if(this._shouldBePrevented(e))return void this._map.cooperativeGestures.notifyGestureBlocked("wheel_zoom",e);let t=e.deltaMode===WheelEvent.DOM_DELTA_LINE?40*e.deltaY:e.deltaY,i=sm(),r=i-(this._lastWheelEventTime||0);this._lastWheelEventTime=i,0!==t&&t%tw==0?this._type="wheel":0!==t&&Math.abs(t)<4?this._type="trackpad":r>400?(this._type=null,this._lastValue=t,this._timeout=setTimeout(this._onTimeout,40,e)):this._type||(this._type=Math.abs(r*t)<200?"trackpad":"wheel",this._timeout&&(clearTimeout(this._timeout),this._timeout=null,t+=this._lastValue)),e.shiftKey&&t&&(t/=4),this._type&&(this._lastWheelEvent=e,this._delta-=t,this._active||this._start(e)),e.preventDefault()}_start(e){if(!this._delta)return;this._needsRerender=!1,this._active=!0,this.isZooming()||(this._zooming=!0),this._finishTimeout&&(clearTimeout(this._finishTimeout),delete this._finishTimeout);let t=cm.mousePos(this._map.getCanvas(),e),i=this._tr;this._aroundPoint=this._aroundCenter?i.transform.locationToScreenPoint(Xu.convert(i.center)):t,this._needsRerender||(this._needsRerender=!0,this._triggerRenderFrame())}renderFrame(){if(!this._needsRerender||(this._needsRerender=!1,!this.isActive()))return;let e=this._tr.transform;if("number"==typeof this._lastExpectedZoom){let t=e.zoom-this._lastExpectedZoom;"number"==typeof this._startZoom&&(this._startZoom+=t),"number"==typeof this._targetZoom&&(this._targetZoom+=t)}if(0!==this._delta){let t="wheel"===this._type&&Math.abs(this._delta)>tw?this._wheelZoomRate:this._defaultZoomRate,i=2/(1+Math.exp(-Math.abs(this._delta*t)));this._delta<0&&0!==i&&(i=1/i);let r="number"==typeof this._targetZoom?Pe(this._targetZoom):e.scale,a=e.applyConstrain(e.getCameraLngLat(),Ie(r*i)).zoom,n=this._map.getZoomSnap();if("wheel"===this._type&&n>0){let t=Me(e.zoom,n);this._targetZoom=Me(a,n,a-t)}else this._targetZoom=a;"wheel"===this._type&&(this._startZoom=e.zoom,this._easing=this._smoothOutEasing(200)),this._delta=0}let t,i="number"==typeof this._targetZoom?this._targetZoom:e.zoom,r=this._startZoom,a=this._easing,n=!1;if("wheel"===this._type&&r&&a){let e=sm()-this._lastWheelEventTime,s=Math.min((e+5)/200,1),o=a(s);t=tr.number(r,i,o),s<1?this._needsRerender=!0:n=!0}else t=i,n=!0;return this._active=!0,n&&(this._active=!1,this._finishTimeout=setTimeout(()=>{this._zooming=!1,this._triggerRenderFrame(),delete this._targetZoom,delete this._lastExpectedZoom,delete this._finishTimeout},200)),this._lastExpectedZoom=t,{noInertia:!0,needsRenderFrame:!n,zoomDelta:t-e.zoom,around:this._aroundPoint,originalEvent:this._lastWheelEvent}}_smoothOutEasing(e){let t=ye;if(this._prevEase){let e=this._prevEase,i=(sm()-e.start)/e.duration,r=e.easing(i+.01)-e.easing(i),a=.27/Math.sqrt(r*r+1e-4)*.01;t=ge(a,Math.sqrt(.0729-a*a),.25,1)}return this._prevEase={start:sm(),duration:e,easing:t},t}reset(){this._active=!1,this._zooming=!1,delete this._targetZoom,delete this._lastExpectedZoom,this._finishTimeout&&(clearTimeout(this._finishTimeout),delete this._finishTimeout)}},rw=class{constructor(e,t){this._clickZoom=e,this._tapZoom=t}enable(){this._clickZoom.enable(),this._tapZoom.enable()}disable(){this._clickZoom.disable(),this._tapZoom.disable()}isEnabled(){return this._clickZoom.isEnabled()&&this._tapZoom.isEnabled()}isActive(){return this._clickZoom.isActive()||this._tapZoom.isActive()}},aw=class{constructor(e,t){this._tr=t,this.reset()}reset(){this._active=!1}dblclick(e,t){return e.preventDefault(),{cameraAnimation:i=>{i.easeTo({duration:300,zoom:Me(this._tr.zoom+(e.shiftKey?-1:1),i.getZoomSnap()),around:this._tr.unproject(t)},{originalEvent:e})}}}enable(){this._enabled=!0}disable(){this._enabled=!1,this.reset()}isEnabled(){return this._enabled}isActive(){return this._active}},nw=class{constructor(){this._tap=new kb({numTouches:1,numTaps:1}),this._zoomRate=1,this.reset()}setZoomRate(e){this._zoomRate=e??1}reset(){this._active=!1,delete this._swipePoint,delete this._swipeTouch,delete this._tapTime,delete this._tapPoint,this._tap.reset()}touchstart(e,t,i){if(!this._swipePoint)if(this._tapTime){let r=t[0],a=e.timeStamp-this._tapTime<500,n=this._tapPoint.dist(r)<30;a&&n?i.length>0&&(this._swipePoint=r,this._swipeTouch=i[0].identifier):this.reset()}else this._tap.touchstart(e,t,i)}touchmove(e,t,i){if(this._tapTime){if(this._swipePoint){if(i[0].identifier!==this._swipeTouch)return;let r=t[0],a=r.y-this._swipePoint.y;return this._swipePoint=r,e.preventDefault(),this._active=!0,{zoomDelta:a/128*this._zoomRate}}}else this._tap.touchmove(e,t,i)}touchend(e,t,i){if(this._tapTime)this._swipePoint&&0===i.length&&this.reset();else{let r=this._tap.touchend(e,t,i);r&&(this._tapTime=e.timeStamp,this._tapPoint=r)}}touchcancel(){this.reset()}enable(){this._enabled=!0}disable(){this._enabled=!1,this.reset()}isEnabled(){return this._enabled}isActive(){return this._active}},sw=class{constructor(e,t,i){this._el=e,this._mousePan=t,this._touchPan=i}enable(e){this._inertiaOptions=e||{},this._mousePan.enable(),this._touchPan.enable(),this._el.classList.add("maplibregl-touch-drag-pan")}disable(){this._mousePan.disable(),this._touchPan.disable(),this._el.classList.remove("maplibregl-touch-drag-pan")}isEnabled(){return this._mousePan.isEnabled()&&this._touchPan.isEnabled()}isActive(){return this._mousePan.isActive()||this._touchPan.isActive()}},ow=class{constructor(e,t,i,r){this._pitchWithRotate=e.pitchWithRotate,this._rollEnabled=e.rollEnabled,this._mouseRotate=t,this._mousePitch=i,this._mouseRoll=r}enable(){this._mouseRotate.enable(),this._pitchWithRotate&&this._mousePitch.enable(),this._rollEnabled&&this._mouseRoll.enable()}disable(){this._mouseRotate.disable(),this._mousePitch.disable(),this._mouseRoll.disable()}isEnabled(){return this._mouseRotate.isEnabled()&&(!this._pitchWithRotate||this._mousePitch.isEnabled())&&(!this._rollEnabled||this._mouseRoll.isEnabled())}isActive(){return this._mouseRotate.isActive()||this._mousePitch.isActive()||this._mouseRoll.isActive()}},lw=class{constructor(e,t,i,r){this._el=e,this._touchZoom=t,this._touchRotate=i,this._tapDragZoom=r,this._rotationDisabled=!1,this._enabled=!0}enable(e){this._touchZoom.enable(e),this._rotationDisabled||this._touchRotate.enable(e),this._tapDragZoom.enable(),this._el.classList.add("maplibregl-touch-zoom-rotate")}disable(){this._touchZoom.disable(),this._touchRotate.disable(),this._tapDragZoom.disable(),this._el.classList.remove("maplibregl-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()}setZoomRate(e){this._touchZoom.setZoomRate(e),this._tapDragZoom.setZoomRate(e)}setZoomThreshold(e){this._touchZoom.setZoomThreshold(e)}disableRotation(){this._rotationDisabled=!0,this._touchRotate.disable()}enableRotation(){this._rotationDisabled=!1,this._touchZoom.isEnabled()&&this._touchRotate.enable()}},hw=class{constructor(e,t){this._bypassKey=navigator.userAgent.includes("Mac")?"metaKey":"ctrlKey",this._map=e,this._options=t,this._enabled=!1}isActive(){return!1}reset(){}_setupUI(){if(this._container)return;let e=this._map.getCanvasContainer();e.classList.add("maplibregl-cooperative-gestures"),this._container=cm.create("div","maplibregl-cooperative-gesture-screen",e);let t=this._map._getUIString("CooperativeGesturesHandler.WindowsHelpText");"metaKey"===this._bypassKey&&(t=this._map._getUIString("CooperativeGesturesHandler.MacHelpText"));let i=this._map._getUIString("CooperativeGesturesHandler.MobileHelpText"),r=document.createElement("div");r.className="maplibregl-desktop-message",r.textContent=t,this._container.appendChild(r);let a=document.createElement("div");a.className="maplibregl-mobile-message",a.textContent=i,this._container.appendChild(a),this._container.setAttribute("aria-hidden","true")}_destroyUI(){this._container&&(this._container.remove(),this._map.getCanvasContainer().classList.remove("maplibregl-cooperative-gestures")),delete this._container}enable(){this._setupUI(),this._enabled=!0}disable(){this._enabled=!1,this._destroyUI()}isEnabled(){return this._enabled}isBypassed(e){return e[this._bypassKey]}notifyGestureBlocked(e,t){this._enabled&&(this._map.fire(new dm("cooperativegestureprevented",{gestureType:e,originalEvent:t})),this._container.classList.add("maplibregl-show"),setTimeout(()=>{this._container.classList.remove("maplibregl-show")},100))}},uw=class{constructor(e){this._camera=e}get transform(){return this._camera._requestedCameraState||this._camera.transform}get center(){return{lng:this.transform.center.lng,lat:this.transform.center.lat}}get zoom(){return this.transform.zoom}get pitch(){return this.transform.pitch}get bearing(){return this.transform.bearing}unproject(e){return this.transform.screenPointToLocation(u.convert(e),this._camera.terrain)}},cw=e=>e.zoom||e.drag||e.roll||e.pitch||e.rotate,pw=class extends ft{};function dw(e){return e.panDelta?.mag()||e.zoomDelta||e.bearingDelta||e.pitchDelta||e.rollDelta}var fw,mw=class{get _ownerDocument(){return this._el?.ownerDocument||document}get _ownerWindow(){return this._el?.ownerDocument?.defaultView||window}constructor(e,t,i){this._terrainGestureAnchorElevation=null,this.handleWindowEvent=e=>{this.handleEvent(e,`${e.type}Window`)},this.handleEvent=(e,t)=>{if("blur"===e.type)return void this.stop(!0);this._updatingCamera=!0;let i="renderFrame"===e.type?void 0:e,r={needsRenderFrame:!1},a={},n={};for(let{handlerName:l,handler:h,allowed:u}of this._handlers){if(!h.isEnabled())continue;let s;if(this._blockedByActive(n,u,l))h.reset();else if(h[t||e.type]){if(Ye(e,t||e.type)){let i=cm.mousePos(this._map.getCanvas(),e);s=h[t||e.type](e,i)}else if(Xe(e,t||e.type)){let i=e.touches,r=this._getMapTouches(i),a=cm.touchPos(this._map.getCanvas(),r);s=h[t||e.type](e,a,r)}else Ke(t||e.type)||(s=h[t||e.type](e));this.mergeHandlerResult(r,a,s,l,i),s?.needsRenderFrame&&this._triggerRenderFrame()}(s||h.isActive())&&(n[l]=h)}let s={};for(let l in this._previousActiveHandlers)n[l]||(s[l]=i);this._previousActiveHandlers=n,(Object.keys(s).length||dw(r))&&(this._changes.push([r,a,s]),this._triggerRenderFrame()),(Object.keys(n).length||dw(r))&&this._camera.stop(!0),this._updatingCamera=!1;let{cameraAnimation:o}=r;o&&(this._inertia.clear(),this._fireEvents({},{},!0),this._changes=[],o(this._map))},this._map=e,this._camera=t,this._transformProvider=new uw(this._camera),this._el=this._map.getCanvasContainer(),this._handlers=[],this._handlersById={},this._changes=[],this._inertia=new Ib(e),this._bearingSnap=i.bearingSnap,this._previousActiveHandlers={},this._eventsInProgress={},this._addDefaultHandlers(i);let r=this._el;this._listeners=[[r,"touchstart",{passive:!0}],[r,"touchmove",{passive:!1}],[r,"touchend",void 0],[r,"touchcancel",void 0],[r,"mousedown",void 0],[r,"mousemove",void 0],[r,"mouseup",void 0],[this._ownerDocument,"mousemove",{capture:!0}],[this._ownerDocument,"mouseup",void 0],[r,"mouseover",void 0],[r,"mouseout",void 0],[r,"dblclick",void 0],[r,"click",void 0],[r,"keydown",{capture:!1}],[r,"keyup",void 0],[r,"wheel",{passive:!1}],[r,"contextmenu",void 0],[this._ownerWindow,"blur",void 0]];for(let[a,n,s]of this._listeners)a.addEventListener(n,a===this._ownerDocument?this.handleWindowEvent:this.handleEvent,s)}destroy(){for(let[e,t,i]of this._listeners)e.removeEventListener(t,e===this._ownerDocument?this.handleWindowEvent:this.handleEvent,i)}_addDefaultHandlers(e){let t=this._map,i=t.getCanvasContainer();this._add("mapEvent",new Ab(t,e));let r=t.boxZoom=new Db(t,e,this._transformProvider);this._add("boxZoom",r),e.interactive&&e.boxZoom&&r.enable();let a=t.cooperativeGestures=new hw(t,e.cooperativeGestures);this._add("cooperativeGestures",a),e.cooperativeGestures&&a.enable();let n=new Lb(t,this._transformProvider),s=new aw(t,this._transformProvider);t.doubleClickZoom=new rw(s,n),this._add("tapZoom",n),this._add("clickZoom",s),e.interactive&&e.doubleClickZoom&&t.doubleClickZoom.enable();let o=new nw;this._add("tapDragZoom",o);let l=t.touchPitch=new Kb(t);this._add("touchPitch",l),e.interactive&&e.touchPitch&&t.touchPitch.enable(e.touchPitch);let h=()=>t.project(t.getCenter()),u=Ub(e,h),c=function({enable:e,clickTolerance:t,pitchSpeed:i=-.5}){return new Fb({clickTolerance:t,move:(e,t)=>({pitchDelta:(t.y-e.y)*i}),moveStateManager:new Ob({checkCorrectEvent:e=>0===e.button&&e.ctrlKey||2===e.button}),enable:e,assignEvents:Nb})}(e),p=function({enable:e,clickTolerance:t,rollDegreesPerPixelMoved:i=.3},r){return new Fb({clickTolerance:t,move:(e,t)=>{let a=r(),n=(t.x-e.x)*i;return t.y<a.y&&(n=-n),{rollDelta:n}},moveStateManager:new Ob({checkCorrectEvent:e=>2===e.button&&e.ctrlKey}),enable:e,assignEvents:Nb})}(e,h);t.dragRotate=new ow(e,u,c,p),this._add("mouseRotate",u,["mousePitch"]),this._add("mousePitch",c,["mouseRotate","mouseRoll"]),this._add("mouseRoll",p,["mousePitch"]),e.interactive&&e.dragRotate&&t.dragRotate.enable();let d=function({enable:e,clickTolerance:t}){return new Fb({clickTolerance:t,move:(e,t)=>({around:t,panDelta:t.sub(e)}),activateOnStart:!0,moveStateManager:new Ob({checkCorrectEvent:e=>0===e.button&&!e.ctrlKey}),enable:e,assignEvents:Nb})}(e),f=new Gb(e,t);t.dragPan=new sw(i,d,f),this._add("mousePan",d),this._add("touchPan",f,["touchZoom","touchRotate"]),e.interactive&&e.dragPan&&t.dragPan.enable(e.dragPan);let m=new Xb,_=new Wb;t.touchZoomRotate=new lw(i,_,m,o),this._add("touchRotate",m,["touchPan","touchZoom"]),this._add("touchZoom",_,["touchPan","touchRotate"]),e.interactive&&e.touchZoomRotate&&t.touchZoomRotate.enable(e.touchZoomRotate),this._add("blockableMapEvent",new Cb(t));let g=t.scrollZoom=new iw(t,()=>this._triggerRenderFrame(),this._transformProvider);this._add("scrollZoom",g,["mousePan"]),e.interactive&&e.scrollZoom&&t.scrollZoom.enable(e.scrollZoom);let y=t.keyboard=new Qb(t,this._transformProvider);this._add("keyboard",y),e.interactive&&e.keyboard&&t.keyboard.enable()}_add(e,t,i){this._handlers.push({handlerName:e,handler:t,allowed:i}),this._handlersById[e]=t}stop(e){if(!this._updatingCamera){for(let{handler:e}of this._handlers)e.reset();this._inertia.clear(),this._fireEvents({},{},e),this._changes=[]}}isActive(){for(let{handler:e}of this._handlers)if(e.isActive())return!0;return!1}isZooming(){return!!this._eventsInProgress.zoom||this._map.scrollZoom.isZooming()}isRotating(){return!!this._eventsInProgress.rotate}isMoving(){return!!cw(this._eventsInProgress)||this.isZooming()}_blockedByActive(e,t,i){for(let r in e)if(r!==i&&!t?.includes(r))return!0;return!1}_getMapTouches(e){let t=[];for(let i of e){let e=i.target;this._el.contains(e)&&t.push(i)}return t}mergeHandlerResult(e,t,i,r,a){if(!i)return;be(e,i);let n={handlerName:r,originalEvent:i.originalEvent||a};void 0!==i.zoomDelta&&(t.zoom=n),void 0!==i.panDelta&&(t.drag=n),void 0!==i.rollDelta&&(t.roll=n),void 0!==i.pitchDelta&&(t.pitch=n),void 0!==i.bearingDelta&&(t.rotate=n)}_applyChanges(){let e={},t={},i={};for(let[r,a,n]of this._changes)r.panDelta&&(e.panDelta=(e.panDelta||new u(0,0))._add(r.panDelta)),r.zoomDelta&&(e.zoomDelta=(e.zoomDelta||0)+r.zoomDelta),r.bearingDelta&&(e.bearingDelta=(e.bearingDelta||0)+r.bearingDelta),r.pitchDelta&&(e.pitchDelta=(e.pitchDelta||0)+r.pitchDelta),r.rollDelta&&(e.rollDelta=(e.rollDelta||0)+r.rollDelta),void 0!==r.around&&(e.around=r.around),void 0!==r.pinchAround&&(e.pinchAround=r.pinchAround),r.noInertia&&(e.noInertia=r.noInertia),be(t,a),be(i,n);this._updateMapTransform(e,t,i),this._changes=[]}_updateMapTransform(e,t,i){let r=this._map,a=this._camera.getTransformForUpdate(),n=r.terrain;if(!(dw(e)||n&&this._terrainMovement))return void this._fireEvents(t,i,!0);this._camera.stop(!0);let{panDelta:s,zoomDelta:o,bearingDelta:l,pitchDelta:h,rollDelta:u}=e,{around:c,aroundOnSurface:p}=this._resolveAround(e,n,a),d=n?this._terrainGestureElevation(n,c,p,a,t):void 0,f={panDelta:s,zoomDelta:o,rollDelta:u,pitchDelta:h,bearingDelta:l,around:c,aroundElevation:d};this._camera.cameraHelper.useGlobeControls&&!a.isPointOnMapSurface(c)&&(c=a.centerPoint);let m=this._computePreZoomAroundLoc(a,c,s,d);this._handleMapControls({terrain:n,tr:a,deltasForHelper:f,preZoomAroundLoc:m,combinedEventsInProgress:t,panDelta:s}),this._camera.applyUpdatedTransform(a),this._map._update(),e.noInertia||this._inertia.record(e),this._fireEvents(t,i,!0)}_resolveAround(e,t,i){let r=void 0===e.pinchAround?e.around:e.pinchAround;return r||=this._camera.transform.centerPoint,t&&!i.isPointOnMapSurface(r)?{around:i.centerPoint,aroundOnSurface:!1}:{around:r,aroundOnSurface:!0}}_terrainGestureElevation(e,t,i,r,a){if(!i)return;if(!this._terrainMovement&&(a.drag||a.zoom)){let i=e.pointCoordinate(t);this._terrainGestureAnchorElevation=i?i.z:null}if(null===this._terrainGestureAnchorElevation)return;let n=this._terrainGestureAnchorElevation;return t.distSqr(r.centerPoint)<.01||n-r.elevation>=.9*(r.getCameraAltitude()-r.elevation)?void 0:n}_computePreZoomAroundLoc(e,t,i,r){if(t.distSqr(e.centerPoint)<.01)return e.center;let a=i?t.sub(i):t;return void 0===r?e.screenPointToLocation(a):e.screenPointToLocationAtElevation(a,r)}_handleMapControls({terrain:e,tr:t,deltasForHelper:i,preZoomAroundLoc:r,combinedEventsInProgress:a,panDelta:n}){let s=this._camera.cameraHelper;if(s.handleMapControlsRollPitchBearingZoom(i,t),e)return s.useGlobeControls?(!this._terrainMovement&&(a.drag||a.zoom)&&(this._terrainMovement=!0,this._camera.elevationFreeze=!0),void s.handleMapControlsPan(i,t,r)):this._terrainMovement||!a.drag&&!a.zoom?void(void 0===i.aroundElevation&&a.drag&&this._terrainMovement&&n?t.setCenter(t.screenPointToLocation(t.centerPoint.sub(n))):s.handleMapControlsPan(i,t,r)):(this._terrainMovement=!0,this._camera.elevationFreeze=!0,void s.handleMapControlsPan(i,t,r));s.handleMapControlsPan(i,t,r)}_fireEvents(e,t,i){let r=cw(this._eventsInProgress),a=cw(e),n={};for(let u in e){let{originalEvent:t}=e[u];this._eventsInProgress[u]||(n[`${u}start`]=t),this._eventsInProgress[u]=e[u]}!r&&a&&this._fireEvent("movestart",a.originalEvent);for(let u in n)this._fireEvent(u,n[u]);a&&this._fireEvent("move",a.originalEvent);for(let u in e){let{originalEvent:t}=e[u];this._fireEvent(u,t)}let s,o={};for(let u in this._eventsInProgress){let{handlerName:e,originalEvent:i}=this._eventsInProgress[u];this._handlersById[e].isActive()||(delete this._eventsInProgress[u],s=t[e]||i,o[`${u}end`]=s)}for(let u in o)this._fireEvent(u,o[u]);let l=cw(this._eventsInProgress),h=(r||a)&&!l;if(h&&this._terrainMovement){this._camera.elevationFreeze=!1,this._terrainMovement=!1,this._terrainGestureAnchorElevation=null;let e=this._camera.getTransformForUpdate();this._map.getCenterClampedToGround()&&e.recalculateZoomAndCenter(this._map.terrain),this._camera.applyUpdatedTransform(e)}if(i&&h){this._updatingCamera=!0;let e=this._inertia._onMoveEnd(this._map.dragPan._inertiaOptions),t=e=>0!==e&&-this._bearingSnap<e&&e<this._bearingSnap;!e||!e.essential&&am.prefersReducedMotion?(this._map.fire(new fm("moveend",{originalEvent:s})),t(this._map.getBearing())&&this._map.resetNorth()):(t(e.bearing||this._map.getBearing())&&(e.bearing=0),e.freezeElevation=!0,this._map.easeTo(e,{originalEvent:s})),this._updatingCamera=!1}}_fireEvent(e,t){this._map.fire(new fm(e,t?{originalEvent:t}:{}))}_requestFrame(){return this._map.triggerRepaint(),this._map._renderTaskQueue.add(e=>{delete this._frameId,this.handleEvent(new pw("renderFrame",{timeStamp:e})),this._applyChanges()})}_triggerRenderFrame(){void 0===this._frameId&&(this._frameId=this._requestFrame())}},_w=class extends _t{constructor(e){super(),this._renderFrameCallback=()=>{let e=Math.min((sm()-this._easeStart)/this._easeOptions.duration,1);this._onEaseFrame(this._easeOptions.easing(e)),e<1&&this._easeFrameId?this._easeFrameId=this._requestRenderFrame(this._renderFrameCallback):this.stop()},this.transform=new my,this.cameraHelper=new xy,void 0!==e.minZoom&&this.transform.setMinZoom(e.minZoom),void 0!==e.maxZoom&&this.transform.setMaxZoom(e.maxZoom),void 0!==e.minPitch&&this.transform.setMinPitch(e.minPitch),void 0!==e.maxPitch&&this.transform.setMaxPitch(e.maxPitch),void 0!==e.renderWorldCopies&&this.transform.setRenderWorldCopies(e.renderWorldCopies),null!==e.transformConstrain&&this.transform.setConstrainOverride(e.transformConstrain),this._moving=!1,this._zooming=!1,this._bearingSnap=e.bearingSnap,this._zoomSnap=e.zoomSnap,this._requestRenderFrame=e.requestRenderFrame,this._cancelRenderFrame=e.cancelRenderFrame,this.terrain=e.terrain,this._centerClampedToGround=e.centerClampedToGround??!0,this.transformCameraUpdate=e.transformCameraUpdate??null,this._stopHandlers=e.stopHandlers??(()=>{}),this.on("moveend",()=>{delete this._requestedCameraState})}migrateProjection(e,t){e.apply(this.transform,!0),this.transform=e,this.cameraHelper=t}getCenter(){return new Xu(this.transform.center.lng,this.transform.center.lat)}setCenter(e,t){return this.jumpTo({center:e},t)}getCenterElevation(){return this.transform.elevation}setCenterElevation(e,t){return this.jumpTo({elevation:e},t),this}getCenterClampedToGround(){return this._centerClampedToGround}setCenterClampedToGround(e){this._centerClampedToGround=e}panBy(e,t,i){return e=u.convert(e).mult(-1),this.panTo(this.transform.center,be({offset:e},t),i)}panTo(e,t,i){return this.easeTo(be({center:e},t),i)}getZoom(){return this.transform.zoom}setZoom(e,t){return this.jumpTo({zoom:e},t),this}zoomTo(e,t,i){return this.easeTo(be({zoom:e},t),i)}zoomIn(e,t){return this.zoomTo(Me(this.getZoom()+1,this._zoomSnap),e,t),this}zoomOut(e,t){return this.zoomTo(Me(this.getZoom()-1,this._zoomSnap),e,t),this}getVerticalFieldOfView(){return this.transform.fov}setVerticalFieldOfView(e,t){return e!=this.transform.fov&&(this.transform.setFov(e),this.fire(new fm("movestart",t)).fire(new fm("move",t)).fire(new fm("moveend",t))),this}getBearing(){return this.transform.bearing}setZoomSnap(e){return this._zoomSnap=e,this}getZoomSnap(){return this._zoomSnap}setBearing(e,t){return this.jumpTo({bearing:e},t),this}getPadding(){return this.transform.padding}setPadding(e,t){return this.jumpTo({padding:e},t),this}rotateTo(e,t,i){return this.easeTo(be({bearing:e},t),i)}resetNorth(e,t){return this.rotateTo(0,be({duration:1e3},e),t),this}resetNorthPitch(e,t){return this.easeTo(be({bearing:0,pitch:0,roll:0,duration:1e3},e),t),this}snapToNorth(e,t){return Math.abs(this.getBearing())<this._bearingSnap?this.resetNorth(e,t):this}getPitch(){return this.transform.pitch}setPitch(e,t){return this.jumpTo({pitch:e},t),this}getRoll(){return this.transform.roll}setRoll(e,t){return this.jumpTo({roll:e},t),this}cameraForBounds(e,t){e=s_.convert(e).adjustAntiMeridian();let i=t?.bearing||0;return this._cameraForBoxAndBearing(e.getNorthWest(),e.getSouthEast(),i,t)}_cameraForBoxAndBearing(e,t,i,r){let a={top:0,bottom:0,right:0,left:0};if("number"==typeof(r=be({padding:a,offset:[0,0],maxZoom:this.transform.maxZoom},r)).padding){let e=r.padding;r.padding={top:e,bottom:e,right:e,left:e}}let n=be(a,r.padding);r.padding=n;let s=this.transform,o=new s_(e,t),l=this.cameraHelper.cameraForBoxAndBearing(r,n,o,i,s);return l&&this._zoomSnap&&(l.zoom=Me(l.zoom,this._zoomSnap,-1)),l}fitBounds(e,t,i){return this._fitInternal(this.cameraForBounds(e,t),t,i)}fitScreenCoordinates(e,t,i,r,a){return this._fitInternal(this._cameraForBoxAndBearing(this.transform.screenPointToLocation(u.convert(e)),this.transform.screenPointToLocation(u.convert(t)),i,r),r,a)}_fitInternal(e,t,i){return e?(delete(t=be(e,t)).padding,t.linear?this.easeTo(t,i):this.flyTo(t,i)):this}jumpTo(e,t){this.stop(),"zoom"in e&&this._zoomSnap&&(e.zoom=Me(e.zoom,this._zoomSnap));let i=this.getTransformForUpdate(),r=!1,a=!1,n=!1,s=i.zoom;this.terrain&&i.setElevation(this.terrain.getElevationForLngLatZoom(e.center?Xu.convert(e.center):i.center,e.zoom||i.tileZoom)),this.cameraHelper.handleJumpToCenterZoom(i,e);let o=i.zoom!==s;return"elevation"in e&&i.elevation!==+e.elevation&&i.setElevation(+e.elevation),"bearing"in e&&i.bearing!==+e.bearing&&(r=!0,i.setBearing(+e.bearing)),"pitch"in e&&i.pitch!==+e.pitch&&(a=!0,i.setPitch(+e.pitch)),"roll"in e&&i.roll!==+e.roll&&(n=!0,i.setRoll(+e.roll)),null!=e.padding&&!i.isPaddingEqual(e.padding)&&i.setPadding(e.padding),this.applyUpdatedTransform(i),this.fire(new fm("movestart",t)).fire(new fm("move",t)),o&&this.fire(new fm("zoomstart",t)).fire(new fm("zoom",t)).fire(new fm("zoomend",t)),r&&this.fire(new fm("rotatestart",t)).fire(new fm("rotate",t)).fire(new fm("rotateend",t)),a&&this.fire(new fm("pitchstart",t)).fire(new fm("pitch",t)).fire(new fm("pitchend",t)),n&&this.fire(new fm("rollstart",t)).fire(new fm("roll",t)).fire(new fm("rollend",t)),this.fire(new fm("moveend",t))}calculateCameraOptionsFromTo(e,t,i,r=0){let a=ac.fromLngLat(e,t),n=ac.fromLngLat(i,r),s=n.x-a.x,o=n.y-a.y,l=n.z-a.z,h=Math.hypot(s,o,l);if(0===h)throw Error("Can't calculate camera options with same From and To");let u=Math.hypot(s,o),c=Ie(this.transform.cameraToCenterDistance/h/this.transform.tileSize),p=180*Math.atan2(s,-o)/Math.PI,d=180*Math.acos(u/h)/Math.PI;return d=l<0?90-d:90+d,{center:n.toLngLat(),elevation:r,zoom:c,pitch:d,bearing:p}}calculateCameraOptionsFromCameraLngLatAltRotation(e,t,i,r,a){let n=this.transform.calculateCenterFromCameraLngLatAlt(e,t,i,r);return{center:n.center,elevation:n.elevation,zoom:n.zoom,bearing:i,pitch:r,roll:a}}easeTo(e,t){this._stop(!1,e.easeId),"zoom"in(e=be({offset:[0,0],duration:500,easing:ye},e))&&this._zoomSnap&&(e.zoom=Me(e.zoom,this._zoomSnap)),(!1===e.animate||!e.essential&&am.prefersReducedMotion)&&(e.duration=0);let i,r,a=this.getTransformForUpdate(),n=this.getBearing(),s=a.pitch,o=a.roll,l="bearing"in e?this._normalizeBearing(e.bearing,n):n,h="pitch"in e?+e.pitch:s,c="roll"in e?this._normalizeBearing(e.roll,o):o,p="padding"in e?e.padding:a.padding,d=u.convert(e.offset);e.around&&(i=Xu.convert(e.around),r=a.locationToScreenPoint(i));let f={moving:this._moving,zooming:this._zooming,rotating:this._rotating,pitching:this._pitching,rolling:this._rolling},m=this.cameraHelper.handleEaseTo(a,{bearing:l,pitch:h,roll:c,padding:p,around:i,aroundPoint:r,offsetAsPoint:d,offset:e.offset,zoom:e.zoom,center:e.center});return this._rotating||=n!==l,this._pitching||=h!==s,this._rolling||=c!==o,this._padding=!a.isPaddingEqual(p),this._zooming||=m.isZooming,this._easeId=e.easeId,this._prepareEase(t,e.noMoveStart,f),this.terrain&&this._prepareElevation(m.elevationCenter),this._ease(i=>{m.easeFunc(i),this.terrain&&!e.freezeElevation&&this._updateElevation(i),this.applyUpdatedTransform(a),this._fireMoveEvents(t)},i=>{this.terrain&&e.freezeElevation&&this._finalizeElevation(),this._afterEase(t,i)},e),this}_prepareEase(e,t,i={}){this._moving=!0,!t&&!i.moving&&this.fire(new fm("movestart",e)),this._zooming&&!i.zooming&&this.fire(new fm("zoomstart",e)),this._rotating&&!i.rotating&&this.fire(new fm("rotatestart",e)),this._pitching&&!i.pitching&&this.fire(new fm("pitchstart",e)),this._rolling&&!i.rolling&&this.fire(new fm("rollstart",e))}_prepareElevation(e){this._elevationCenter=e,this._elevationStart=this.transform.elevation,this._elevationTarget=this.terrain.getElevationForLngLatZoom(e,this.transform.tileZoom),this.elevationFreeze=!0}_updateElevation(e){(void 0===this._elevationStart||void 0===this._elevationCenter)&&this._prepareElevation(this.transform.center),this.transform.setMinElevationForCurrentTile(this.terrain.getMinTileElevationForLngLatZoom(this._elevationCenter,this.transform.tileZoom));let t=this.terrain.getElevationForLngLatZoom(this._elevationCenter,this.transform.tileZoom);if(e<1&&t!==this._elevationTarget){let i=this._elevationTarget-this._elevationStart,r=(t-(i*e+this._elevationStart))/(1-e);this._elevationStart+=e*(i-r),this._elevationTarget=t}this.transform.setElevation(tr.number(this._elevationStart,this._elevationTarget,e))}_finalizeElevation(){this.elevationFreeze=!1,this.getCenterClampedToGround()&&this.transform.recalculateZoomAndCenter(this.terrain)}getTransformForUpdate(){return this.transformCameraUpdate||this.terrain?(this._requestedCameraState||=this.transform.clone(),this._requestedCameraState):this.transform}_elevateCameraIfInsideTerrain(e){if(!this.terrain&&e.elevation>=0&&e.pitch<=90)return{};let t=e.getCameraLngLat(),i=e.getCameraAltitude(),r=this.terrain?this.terrain.getElevationForLngLatZoom(t,e.zoom):0;if(i<r){let i=this.calculateCameraOptionsFromTo(t,r,e.center,e.elevation);return{pitch:i.pitch,zoom:i.zoom}}return{}}applyUpdatedTransform(e){let t=[];if(t.push(e=>this._elevateCameraIfInsideTerrain(e)),this.transformCameraUpdate&&t.push(e=>this.transformCameraUpdate(e)),!t.length)return;let i=e.clone();for(let r of t){let e=i.clone(),{center:t,zoom:a,roll:n,pitch:s,bearing:o,elevation:l}=r(e);t&&e.setCenter(t),void 0!==l&&e.setElevation(l),void 0!==a&&e.setZoom(a),void 0!==n&&e.setRoll(n),void 0!==s&&e.setPitch(s),void 0!==o&&e.setBearing(o),i.apply(e,!1)}this.transform.apply(i,!1)}_fireMoveEvents(e){this.fire(new fm("move",e)),this._zooming&&this.fire(new fm("zoom",e)),this._rotating&&this.fire(new fm("rotate",e)),this._pitching&&this.fire(new fm("pitch",e)),this._rolling&&this.fire(new fm("roll",e))}_afterEase(e,t){if(this._easeId&&t&&this._easeId===t)return;delete this._easeId;let i=this._zooming,r=this._rotating,a=this._pitching,n=this._rolling;this._moving=!1,this._zooming=!1,this._rotating=!1,this._pitching=!1,this._rolling=!1,this._padding=!1,i&&this.fire(new fm("zoomend",e)),r&&this.fire(new fm("rotateend",e)),a&&this.fire(new fm("pitchend",e)),n&&this.fire(new fm("rollend",e)),this.fire(new fm("moveend",e))}flyTo(e,t){if(!e.essential&&am.prefersReducedMotion){let i=we(e,["center","zoom","bearing","pitch","roll","elevation","padding"]);return this.jumpTo(i,t)}this.stop(),"zoom"in(e=be({offset:[0,0],speed:1.2,curve:1.42,easing:ye},e))&&this._zoomSnap&&(e.zoom=Me(e.zoom,this._zoomSnap));let i=this.getTransformForUpdate(),r=i.bearing,a=i.pitch,n=i.roll,s=i.padding,o="bearing"in e?this._normalizeBearing(e.bearing,r):r,l="pitch"in e?+e.pitch:a,h="roll"in e?this._normalizeBearing(e.roll,n):n,c="padding"in e?e.padding:i.padding,p=u.convert(e.offset),d=i.centerPoint.add(p),f=i.screenPointToLocation(d),m=this.cameraHelper.handleFlyTo(i,{bearing:o,pitch:l,roll:h,padding:c,locationAtOffset:f,offsetAsPoint:p,center:e.center,minZoom:e.minZoom,zoom:e.zoom}),_=e.curve,g=Math.max(i.width,i.height),y=g/m.scaleOfZoom,v=m.pixelPathLength,x=g/m.scaleOfMinZoom;_=Math.min(_,Math.sqrt(x/v*2));let b=_*_;function w(e){let t=(y*y-g*g+(e?-1:1)*b*b*v*v)/(2*(e?y:g)*b*v);return Math.log(Math.sqrt(t*t+1)-t)}function T(e){return(Math.exp(e)-Math.exp(-e))/2}function S(e){return(Math.exp(e)+Math.exp(-e))/2}let P=w(!1),I=function(e){return S(P)/S(P+_*e)},M=function(e){return g*((S(P)*function(e){return T(e)/S(e)}(P+_*e)-T(P))/b)/v},E=(w(!0)-P)/_;if(Math.abs(v)<2e-6||!isFinite(E)){if(Math.abs(g-y)<1e-6)return this.easeTo(e,t);let i=y<g?-1:1;E=Math.abs(Math.log(y/g))/_,M=()=>0,I=e=>Math.exp(i*_*e)}if("duration"in e)e.duration=+e.duration;else{let t="screenSpeed"in e?+e.screenSpeed/_:+e.speed;e.duration=1e3*E/t}return e.maxDuration&&e.duration>e.maxDuration&&(e.duration=0),this._zooming=!0,this._rotating=r!==o,this._pitching=l!==a,this._rolling=h!==n,this._padding=!i.isPaddingEqual(c),this._prepareEase(t,!1),this.terrain&&this._prepareElevation(m.targetCenter),this._ease(u=>{let f=u*E,_=1/I(f),g=M(f);this._rotating&&i.setBearing(tr.number(r,o,u)),this._pitching&&i.setPitch(tr.number(a,l,u)),this._rolling&&i.setRoll(tr.number(n,h,u)),this._padding&&(i.interpolatePadding(s,c,u),d=i.centerPoint.add(p)),m.easeFunc(u,_,g,d),this.terrain&&!e.freezeElevation&&this._updateElevation(u),this.applyUpdatedTransform(i),this._fireMoveEvents(t)},()=>{this.terrain&&e.freezeElevation&&this._finalizeElevation(),this._afterEase(t)},e),this}isEasing(){return!!this._easeFrameId}stop(e){return this._stop(e)}_stop(e,t){if(this._easeFrameId&&(this._cancelRenderFrame(this._easeFrameId),delete this._easeFrameId,delete this._onEaseFrame),this._onEaseEnd){let e=this._onEaseEnd;delete this._onEaseEnd,e.call(this,t)}return e||this._stopHandlers(),this}_ease(e,t,i){!1===i.animate||0===i.duration?(e(1),t()):(this._easeStart=sm(),this._easeOptions=i,this._onEaseFrame=e,this._onEaseEnd=t,this._easeFrameId=this._requestRenderFrame(this._renderFrameCallback))}_normalizeBearing(e,t){e=xe(e,-180,180);let i=Math.abs(e-t);return Math.abs(e-360-t)<i&&(e-=360),Math.abs(e+360-t)<i&&(e+=360),e}isMoving(){return this._moving}isZooming(){return this._zooming}isRotating(){return this._rotating}},gw={compact:!0,customAttribution:'<a href="https://maplibre.org/" target="_blank">MapLibre</a>'},yw=class{constructor(e=gw){this._toggleAttribution=()=>{this._container.classList.contains("maplibregl-compact")&&(this._container.classList.contains("maplibregl-compact-show")?(this._container.setAttribute("open",""),this._container.classList.remove("maplibregl-compact-show")):(this._container.classList.add("maplibregl-compact-show"),this._container.removeAttribute("open")))},this._updateData=e=>{e&&("terrain"===e.type||"style"===e.dataType||"source"===e.dataType&&("metadata"===e.sourceDataType||"visibility"===e.sourceDataType))&&this._updateAttributions()},this._updateCompact=()=>{this._map.getCanvasContainer().offsetWidth<=640||this._compact?!1===this._compact?this._container.setAttribute("open",""):!this._container.classList.contains("maplibregl-compact")&&!this._container.classList.contains("maplibregl-attrib-empty")&&(this._container.setAttribute("open",""),this._container.classList.add("maplibregl-compact","maplibregl-compact-show")):(this._container.setAttribute("open",""),this._container.classList.contains("maplibregl-compact")&&this._container.classList.remove("maplibregl-compact","maplibregl-compact-show"))},this._updateCompactMinimize=()=>{this._container.classList.contains("maplibregl-compact")&&this._container.classList.contains("maplibregl-compact-show")&&this._container.classList.remove("maplibregl-compact-show")},this.options=e}getDefaultPosition(){return"bottom-right"}onAdd(e){return this._map=e,this._compact=this.options.compact,this._container=cm.create("details","maplibregl-ctrl maplibregl-ctrl-attrib"),this._compactButton=cm.create("summary","maplibregl-ctrl-attrib-button",this._container),this._compactButton.addEventListener("click",this._toggleAttribution),this._setElementTitle(this._compactButton,"ToggleAttribution"),this._innerContainer=cm.create("div","maplibregl-ctrl-attrib-inner",this._container),this._updateAttributions(),this._updateCompact(),this._map.on("styledata",this._updateData),this._map.on("sourcedata",this._updateData),this._map.on("terrain",this._updateData),this._map.on("resize",this._updateCompact),this._map.on("drag",this._updateCompactMinimize),this._container}onRemove(){this._container.remove(),this._map.off("styledata",this._updateData),this._map.off("sourcedata",this._updateData),this._map.off("terrain",this._updateData),this._map.off("resize",this._updateCompact),this._map.off("drag",this._updateCompactMinimize),this._map=void 0,this._compact=void 0,this._attribHTML=void 0}_setElementTitle(e,t){let i=this._map._getUIString(`AttributionControl.${t}`);e.title=i,e.setAttribute("aria-label",i)}_updateAttributions(){if(!this._map.style)return;let e=[];if(this.options.customAttribution&&(Array.isArray(this.options.customAttribution)?e=e.concat(this.options.customAttribution.map(e=>"string"==typeof e?e:"")):"string"==typeof this.options.customAttribution&&e.push(this.options.customAttribution)),this._map.style.stylesheet){let e=this._map.style.stylesheet;this.styleOwner=e.owner,this.styleId=e.id}let t=this._map.style.tileManagers;for(let r in t){let i=t[r];if(i.used||i.usedForTerrain){let t=i.getSource();t.attribution&&!e.includes(t.attribution)&&e.push(t.attribution)}}e=e.filter(e=>String(e).trim()),e.sort((e,t)=>e.length-t.length),e=e.filter((t,i)=>{for(let r=i+1;r<e.length;r++)if(e[r].includes(t))return!1;return!0});let i=e.join(" | ");i!==this._attribHTML&&(this._attribHTML=i,e.length?(this._innerContainer.innerHTML=cm.sanitize(i),this._container.classList.remove("maplibregl-attrib-empty")):this._container.classList.add("maplibregl-attrib-empty"),this._updateCompact(),this._editLink=null)}},vw=class{constructor(e={}){this._updateCompact=()=>{let e=this._container.children;if(e.length){let t=e[0];this._map.getCanvasContainer().offsetWidth<=640||this._compact?!1!==this._compact&&t.classList.add("maplibregl-compact"):t.classList.remove("maplibregl-compact")}},this.options=e}getDefaultPosition(){return"bottom-left"}onAdd(e){this._map=e,this._compact=this.options?.compact,this._container=cm.create("div","maplibregl-ctrl");let t=cm.create("a","maplibregl-ctrl-logo");return t.target="_blank",t.rel="noopener nofollow",t.href="https://maplibre.org/",t.setAttribute("aria-label",this._map._getUIString("LogoControl.Title")),t.setAttribute("rel","noopener nofollow"),this._container.appendChild(t),this._container.style.display="block",this._map.on("resize",this._updateCompact),this._updateCompact(),this._container}onRemove(){this._container.remove(),this._map.off("resize",this._updateCompact),this._map=void 0,this._compact=void 0}},xw=class{constructor(){this._queue=[],this._id=0,this._cleared=!1,this._currentlyRunning=!1}add(e){let t=++this._id;return this._queue.push({callback:e,id:t,cancelled:!1}),t}remove(e){let t=this._currentlyRunning,i=t?this._queue.concat(t):this._queue;for(let r of i)if(r.id===e)return void(r.cancelled=!0)}run(e=0){if(this._currentlyRunning)throw Error("Attempting to run(), but is already running.");let t=this._currentlyRunning=this._queue;this._queue=[];for(let i of t)if(!i.cancelled&&(i.callback(e),this._cleared))break;this._cleared=!1,this._currentlyRunning=!1}clear(){this._currentlyRunning&&(this._cleared=!0),this._queue=[]}},bw=qs([{name:"a_pos3d",type:"Int16",components:3}]),ww=class extends _t{constructor(e){super(),this._lastTilesetChange=sm(),this.tileManager=e,this._tiles={},this._renderableTilesKeys=[],this._sourceTileCache={},this.minzoom=0,this.maxzoom=22,this.deltaZoom=1,this.tileSize=e._source.tileSize*2**this.deltaZoom,e.usedForTerrain=!0,e.tileSize=this.tileSize}destruct(){this.tileManager.usedForTerrain=!1,this.tileManager.tileSize=null,this.releaseAllRTT()}getSource(){return this.tileManager._source}update(e,t){this.tileManager.update(e,t),this._renderableTilesKeys=[];let i={};for(let r of G_(e,{tileSize:this.tileSize,minzoom:this.minzoom,maxzoom:this.maxzoom,reparseOverscaled:!1,terrain:t,calculateTileZoom:this.tileManager._source.calculateTileZoom}))i[r.key]=!0,this._renderableTilesKeys.push(r.key),this._tiles[r.key]||(r.terrainRttPosMatrix32f=/* @__PURE__ */new Float32Array(16),P(r.terrainRttPosMatrix32f,0,8192,8192,0,0,1),this._tiles[r.key]=new L_(r,this.tileSize),this._lastTilesetChange=sm());for(let r in this._tiles)i[r]||(this._tiles[r].releaseRTT(this.tileManager.map.painter),delete this._tiles[r])}releaseRTT(e){for(let t in this._tiles){let i=this._tiles[t];(i.tileID.equals(e)||i.tileID.isChildOf(e)||e.isChildOf(i.tileID))&&i.releaseRTT(this.tileManager.map.painter)}}releaseAllRTT(){for(let e in this._tiles)this._tiles[e].releaseRTT(this.tileManager.map.painter)}getRenderableTiles(){return this._renderableTilesKeys.map(e=>this.getTileByID(e))}getTileByID(e){return this._tiles[e]}getTerrainCoords(e,t){return t?this._getTerrainCoordsForTileRanges(e,t):this._getTerrainCoordsForRegularTile(e)}_getTerrainCoordsForRegularTile(e){let t={};for(let i of this._renderableTilesKeys){let r=this._tiles[i].tileID,a=e.clone(),n=re();if(r.canonical.equals(e.canonical))P(n,0,J,J,0,0,1);else if(r.canonical.isChildOf(e.canonical)){let t=r.canonical.z-e.canonical.z,i=r.canonical.x-(r.canonical.x>>t<<t),a=r.canonical.y-(r.canonical.y>>t<<t),s=J>>t;P(n,0,s,s,0,0,1),v(n,n,[-i*s,-a*s,0])}else{if(!e.canonical.isChildOf(r.canonical))continue;{let t=e.canonical.z-r.canonical.z,i=e.canonical.x-(e.canonical.x>>t<<t),a=e.canonical.y-(e.canonical.y>>t<<t),s=J>>t;P(n,0,J,J,0,0,1),v(n,n,[i*s,a*s,0]),x(n,n,[1/2**t,1/2**t,0])}}a.terrainRttPosMatrix32f=new Float32Array(n),t[i]=a}return t}_getTerrainCoordsForTileRanges(e,t){let i={};for(let r of this._renderableTilesKeys){let a=this._tiles[r].tileID;if(!this._isWithinTileRanges(a,t))continue;let n=e.clone(),s=re();if(a.canonical.z===e.canonical.z){let t=e.canonical.x-a.canonical.x+e.wrap*(1<<e.canonical.z),i=e.canonical.y-a.canonical.y;P(s,0,J,J,0,0,1),v(s,s,[t*J,i*J,0])}else if(a.canonical.z>e.canonical.z){let t=a.canonical.z-e.canonical.z,i=a.canonical.x-(a.canonical.x>>t<<t)+e.wrap*(1<<a.canonical.z),r=a.canonical.y-(a.canonical.y>>t<<t),n=e.canonical.x-(a.canonical.x>>t),o=e.canonical.y-(a.canonical.y>>t),l=J>>t;P(s,0,l,l,0,0,1),v(s,s,[-i*l+n*J,-r*l+o*J,0])}else{let t=e.canonical.z-a.canonical.z,i=e.canonical.x-(e.canonical.x>>t<<t)+e.wrap*(1<<e.canonical.z),r=e.canonical.y-(e.canonical.y>>t<<t),n=(e.canonical.x>>t)-a.canonical.x,o=(e.canonical.y>>t)-a.canonical.y,l=J<<t;P(s,0,l,l,0,0,1),v(s,s,[i*J+n*l,r*J+o*l,0])}n.terrainRttPosMatrix32f=new Float32Array(s),i[r]=n}return i}getSourceTile(e,t){let i=this.tileManager._source,r=e.overscaledZ-this.deltaZoom;if(r>i.maxzoom&&(r=i.maxzoom),r<i.minzoom)return;this._sourceTileCache[e.key]||=e.scaledTo(r).key;let a=this.findTileInCaches(this._sourceTileCache[e.key]);if(!a?.dem&&t)for(;r>=i.minzoom&&!a?.dem;)a=this.findTileInCaches(e.scaledTo(r--).key);return a}findTileInCaches(e){let t=this.tileManager.getTileByID(e);return t||(t=this.tileManager._outOfViewCache.getByKey(e),t)}anyTilesAfterTime(e=sm()){return this._lastTilesetChange>=e}_isWithinTileRanges(e,t){let i=t[e.canonical.z];return!!i&&(e.wrap>i.minWrap||e.wrap<i.maxWrap||e.canonical.x>=i.minTileXWrapped&&e.canonical.x<=i.maxTileXWrapped&&e.canonical.y>=i.minTileY&&e.canonical.y<=i.maxTileY)}},Tw=class{constructor(e,t,i,r="auto"){this._meshCache={},this.painter=e,this.tileManager=new ww(t),this.options=i,this.exaggeration="number"==typeof i.exaggeration?i.exaggeration:1,this._terrainSkirtLength=r,this.qualityFactor=2,this.meshSize=128,this._demMatrixCache=/* @__PURE__ */new Map,this._elevationSamplerCache=/* @__PURE__ */new Map,this.coordsIndex=[],this._coordsTextureSize=1024}destroy(){this._fbo&&=(this._fbo.destroy(),null),this._fboCoordsTexture&&=(this._fboCoordsTexture.destroy(),null),this._fboDepthTexture&&=(this._fboDepthTexture.destroy(),null),this._emptyDemTexture&&=(this._emptyDemTexture.destroy(),null),this._emptyDepthTexture&&=(this._emptyDepthTexture.destroy(),null),this._coordsTexture&&=(this._coordsTexture.destroy(),null);for(let e in this._meshCache)this._meshCache[e].destroy();this._meshCache={},this.tileManager.destruct()}getDEMElevation(e,t,i,r=J){let a=e.normalizeCoordinates(t,i,r);if(!a)return 0;let n=this._getElevationSampler(a.tileID);return n?n(a.x,a.y,r):0}getElevationForLngLatZoom(e,t){if(!Dp(t,e.wrap()))return 0;let{tileID:i,mercatorX:r,mercatorY:a}=this._getOverscaledTileIDFromLngLatZoom(e,t);return this.getElevation(i,r%J,a%J,J)}getElevationForLngLat(e,t){let i=G_(t,{maxzoom:this.tileManager.maxzoom,minzoom:this.tileManager.minzoom,tileSize:512,terrain:this}),r=0;for(let a of i)a.canonical.z>r&&(r=Math.min(a.canonical.z,this.tileManager.maxzoom));return this.getElevationForLngLatZoom(e,r)}getElevation(e,t,i,r=J){return this.getDEMElevation(e,t,i,r)*this.exaggeration}resetElevationCache(){this._elevationSamplerCache.clear()}_getElevationSampler(e){let t=e.key,i=this._elevationSamplerCache.get(t);if(i)return i;let r=this.tileManager.getSourceTile(e,!0),a=r?.dem;if(!r||!a)return null;let n=this._getDEMTileMatrix(e,r),s=n[0]*a.dim,o=n[5]*a.dim,l=n[12]*a.dim,h=n[13]*a.dim,u=(e,t,i)=>{let r=8192===i?1:J/i;return a.sampleBilinear(e*r*s+l,t*r*o+h)};return this._elevationSamplerCache.set(t,u),u}_getDEMTileMatrix(e,t){let i=`${t.tileID.key}/${e.key}`,r=this._demMatrixCache.get(i);if(r)return r;let a=this.tileManager.getSource().maxzoom,n=e.canonical.z-t.tileID.canonical.z;e.overscaledZ>e.canonical.z&&(e.canonical.z>=a?n=e.canonical.z-a:Re("cannot calculate elevation if elevation maxzoom > source.maxzoom"));let s=e.canonical.x-(e.canonical.x>>n<<n),o=e.canonical.y-(e.canonical.y>>n<<n),l=function(e,t){return e[0]=t[0],e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[5]=t[1],e[6]=0,e[7]=0,e[8]=0,e[9]=0,e[10]=t[2],e[11]=0,e[12]=0,e[13]=0,e[14]=0,e[15]=1,e}(/* @__PURE__ */new Float64Array(16),[1/(J<<n),1/(J<<n),0]);return v(l,l,[s*J,o*J,0]),this._demMatrixCache.set(i,l),l}getTerrainData(e){if(!this._emptyDemTexture){let e=this.painter.context,t=new yh({width:1,height:1},/* @__PURE__ */new Uint8Array(4));this._emptyDepthTexture=new Ah(e,t,e.gl.RGBA,{premultiply:!1}),this._emptyDemUnpack=[0,0,0,0],this._emptyDemTexture=new Ah(e,new yh({width:1,height:1}),e.gl.RGBA,{premultiply:!1}),this._emptyDemTexture.bind(e.gl.NEAREST,e.gl.CLAMP_TO_EDGE),this._emptyDemMatrix=_([])}let t=this.tileManager.getSourceTile(e,!0);if(t?.dem&&(!t.demTexture||t.needsTerrainPrepare)){let e=this.painter.context;t.demTexture||=this.painter.getTileTexture(t.dem.stride),t.demTexture?t.demTexture.update(t.dem.getPixels(),{premultiply:!1}):t.demTexture=new Ah(e,t.dem.getPixels(),e.gl.RGBA,{premultiply:!1}),t.demTexture.bind(e.gl.NEAREST,e.gl.CLAMP_TO_EDGE),t.needsTerrainPrepare=!1}let i=t?this._getDEMTileMatrix(e,t):this._emptyDemMatrix;return{u_depth:2,u_terrain:3,u_terrain_dim:t?.dem?.dim||1,u_terrain_matrix:i,u_terrain_unpack:t?.dem?.getUnpackVector()||this._emptyDemUnpack,u_terrain_exaggeration:this.exaggeration,texture:(t?.demTexture||this._emptyDemTexture).texture,depthTexture:(this._fboDepthTexture||this._emptyDepthTexture).texture,tile:t}}getFramebuffer(e){let t=this.painter,i=t.width/devicePixelRatio,r=t.height/devicePixelRatio;return this._fbo&&(this._fbo.width!==i||this._fbo.height!==r)&&(this._fbo.destroy(),this._fboCoordsTexture.destroy(),this._fboDepthTexture.destroy(),delete this._fbo,delete this._fboDepthTexture,delete this._fboCoordsTexture),this._fboCoordsTexture||(this._fboCoordsTexture=new Ah(t.context,{width:i,height:r,data:null},t.context.gl.RGBA,{premultiply:!1}),this._fboCoordsTexture.bind(t.context.gl.NEAREST,t.context.gl.CLAMP_TO_EDGE)),this._fboDepthTexture||(this._fboDepthTexture=new Ah(t.context,{width:i,height:r,data:null},t.context.gl.RGBA,{premultiply:!1}),this._fboDepthTexture.bind(t.context.gl.NEAREST,t.context.gl.CLAMP_TO_EDGE)),this._fbo||(this._fbo=t.context.createFramebuffer(i,r,!0,!1),this._fbo.depthAttachment.set(t.context.createRenderbuffer(t.context.gl.DEPTH_COMPONENT16,i,r))),this._fbo.colorAttachment.set("coords"===e?this._fboCoordsTexture.texture:this._fboDepthTexture.texture),this._fbo}getCoordsTexture(){let e=this.painter.context;if(this._coordsTexture)return this._coordsTexture;let t=new Uint8Array(this._coordsTextureSize*this._coordsTextureSize*4);for(let r=0,a=0;r<this._coordsTextureSize;r++)for(let e=0;e<this._coordsTextureSize;e++,a+=4)t[a+0]=255&e,t[a+1]=255&r,t[a+2]=e>>8<<4|r>>8,t[a+3]=0;let i=new Ah(e,new yh({width:this._coordsTextureSize,height:this._coordsTextureSize},new Uint8Array(t.buffer)),e.gl.RGBA,{premultiply:!1});return i.bind(e.gl.NEAREST,e.gl.CLAMP_TO_EDGE),this._coordsTexture=i,i}pointCoordinate(e){this.painter.maybeDrawDepth(!0),this.painter.maybeDrawCoords();let t=/* @__PURE__ */new Uint8Array(4),i=this.painter.context,r=i.gl,a=Math.round(e.x*this.painter.pixelRatio/devicePixelRatio),n=Math.round(e.y*this.painter.pixelRatio/devicePixelRatio),s=Math.round(this.painter.height/devicePixelRatio);i.bindFramebuffer.set(this.getFramebuffer("coords").framebuffer),r.readPixels(a,s-n-1,1,1,r.RGBA,r.UNSIGNED_BYTE,t),i.bindFramebuffer.set(null);let o=t[0]+(t[2]>>4<<8),l=t[1]+((15&t[2])<<8),h=this.coordsIndex[255-t[3]],u=h&&this.tileManager.getTileByID(h);if(!u)return null;let c=this._coordsTextureSize,p=(1<<u.tileID.canonical.z)*c;return new ac((u.tileID.canonical.x*c+o)/p+u.tileID.wrap,(u.tileID.canonical.y*c+l)/p,this.getElevation(u.tileID,o,l,c))}depthAtPoint(e){let t=/* @__PURE__ */new Uint8Array(4),i=this.painter.context,r=i.gl;return i.bindFramebuffer.set(this.getFramebuffer("depth").framebuffer),r.readPixels(e.x,this.painter.height/devicePixelRatio-e.y-1,1,1,r.RGBA,r.UNSIGNED_BYTE,t),i.bindFramebuffer.set(null),(t[0]/16777216+t[1]/65536+t[2]/256+t[3])/256}getTerrainMesh(e){let t=this.painter.style.projection?.transitionState>0,i=t&&0===e.canonical.y,r=t&&e.canonical.y===(1<<e.canonical.z)-1,a=`m_${i?"n":""}_${r?"s":""}`;if(this._meshCache[a])return this._meshCache[a];let n=this.painter.context,s=new zo,o=new Ho,l=this.meshSize,h=J/l,u=l*l;for(let p=0;p<=l;p++)for(let e=0;e<=l;e++)s.emplaceBack(e*h,p*h,0);for(let p=0;p<u;p+=l+1)for(let e=0;e<l;e++)o.emplaceBack(e+p,l+e+p+1,l+e+p+2),o.emplaceBack(e+p,l+e+p+2,e+p+1);"none"!==this._terrainSkirtLength&&this._buildSkirts(s,o,l,h,i,r);let c=new ry(n.createVertexBuffer(s,bw.members),n.createIndexBuffer(o),Qo.simpleSegment(0,0,s.length,o.length));return this._meshCache[a]=c,c}getSkirtLength(e){return 2*Math.PI*Hu/2**Math.max(e,0)/5}getMinTileElevationForLngLatZoom(e,t){if(!Dp(t,e.wrap()))return 0;let{tileID:i}=this._getOverscaledTileIDFromLngLatZoom(e,t);return this.getMinMaxElevation(i).minElevation??0}getMinMaxElevation(e){let t=this.tileManager.getSourceTile(e,!0),i={minElevation:null,maxElevation:null};return t?.dem&&(i.minElevation=t.dem.min*this.exaggeration,i.maxElevation=t.dem.max*this.exaggeration),i}_getOverscaledTileIDFromLngLatZoom(e,t){let i=ac.fromLngLat(e.wrap()),r=(1<<t)*J,a=i.x*r,n=i.y*r;return{tileID:new kp(t,0,t,Math.floor(a/J),Math.floor(n/J)),mercatorX:a,mercatorY:n}}_buildSkirts(e,t,i,r,a,n){let s=e.length,o=s+(i+1),l=(i+1)*i,h=a?-32768:0,u=+!a,c=n?32767:J,p=+!n;for(let m=0;m<=i;m++)e.emplaceBack(m*r,h,u);for(let m=0;m<=i;m++)e.emplaceBack(m*r,c,p);for(let m=0;m<i;m++)t.emplaceBack(l+m,o+m,o+m+1),t.emplaceBack(l+m,o+m+1,l+m+1),t.emplaceBack(0+m,s+m+1,s+m),t.emplaceBack(0+m,0+m+1,s+m+1);let d=e.length,f=d+2*(i+1);for(let m of[0,1])for(let t=0;t<=i;t++)for(let i of[0,1])e.emplaceBack(m*J,t*r,i);for(let m=0;m<2*i;m+=2)t.emplaceBack(d+m,d+m+1,d+m+3),t.emplaceBack(d+m,d+m+3,d+m+2),t.emplaceBack(f+m,f+m+3,f+m+1),t.emplaceBack(f+m,f+m+2,f+m+3)}},Sw={background:!0,fill:!0,line:!0,raster:!0,hillshade:!0,"color-relief":!0},Pw=class{constructor(e,t){this.painter=e,this.terrain=t,this.rttSize=t.tileManager.tileSize*t.qualityFactor}getTexture(e){return e.getRTT(this._stacks.length-1).texture}prepareForRender(e,t){this._stacks=[],this._prevType=null,this._rttTiles=[],this._renderableTiles=this.terrain.tileManager.getRenderableTiles(),this._renderableLayerIds=e._order.filter(i=>!e._layers[i].isHidden(t));let i=/* @__PURE__ */new Set;for(let r of this._renderableLayerIds){let t=e._layers[r],a=t.source;a&&Sw[t.type]&&i.add(a)}this._coordsAscending={},this._rttFingerprints={};for(let r of i){let t=e.tileManagers[r];if(!t)continue;this._coordsAscending[r]={};let i=this._coordsAscending[r],a=t.getSource(),n=a instanceof S_?a.terrainTileRanges:null;for(let e of t.getVisibleCoordinates()){let t=this.terrain.tileManager.getTerrainCoords(e,n);for(let e in t)i[e]||=[],i[e].push(t[e])}this._rttFingerprints[r]={};let s=this._rttFingerprints[r],o=t.getState().revision;for(let e in i)s[e]=`${i[e].map(e=>e.key).sort().join()}#${o}`}for(let r of this._renderableTiles)for(let e in this._rttFingerprints){let t=this._rttFingerprints[e][r.tileID.key];t&&t!==r.rttFingerprint[e]&&r.releaseRTT(this.painter)}}renderLayer(e,t){if(e.isHidden(this.painter.transform.zoom))return!1;let i={...t,isRenderingToTexture:!0},r=e.type,a=this.painter,n=this._renderableLayerIds[this._renderableLayerIds.length-1]===e.id;if(Sw[r]&&((!this._prevType||!Sw[this._prevType])&&this._stacks.push([]),this._prevType=r,this._stacks[this._stacks.length-1].push(e.id),!n))return!0;if(Sw[this._prevType]||Sw[r]&&n){this._prevType=r;let e=this._stacks.length-1,t=this._stacks[e]||[];for(let r of this._renderableTiles){if(this._rttTiles.push(r),r.getRTT(e))continue;let n=r.acquireRTT(a,e,this.rttSize);a.bindRTT(n),a.context.clear({color:Si.transparent,stencil:0}),a.currentStencilSource=void 0;for(let e of t){let t=a.style._layers[e],n=t.source?this._coordsAscending[t.source][r.tileID.key]:[r.tileID];a.context.viewport.set([0,0,this.rttSize,this.rttSize]),a.renderTileClippingMasks(t,n,!0),a.renderLayer(a,a.style.tileManagers[t.source],t,n,i),t.source&&(r.rttFingerprint[t.source]=this._rttFingerprints[t.source][r.tileID.key])}}return function(e,t,i,r){let{isRenderingGlobe:a}=r,n=e.context,s=n.gl,o=e.transform,l=e.colorModeForRenderPass(),h=e.getDepthModeFor3D(),u=e.useProgram("terrain");n.bindFramebuffer.set(null),n.viewport.set([0,0,e.width,e.height]);for(let c of i){let i=t.getTerrainMesh(c.tileID),r=e.renderToTexture.getTexture(c),p=t.getTerrainData(c.tileID);n.activeTexture.set(s.TEXTURE0),s.bindTexture(s.TEXTURE_2D,r.texture);let d=t.getSkirtLength(o.zoom),f=o.calculateFogMatrix(c.tileID.toUnwrapped()),m=Yy(d,f,e.style.sky,o.pitch,a),_=o.getProjectionData({overscaledTileID:c.tileID,applyTerrainMatrix:!1,applyGlobeMatrix:!0});u.draw(n,s.TRIANGLES,h,wx.disabled,l,Px.backCCW,m,p,_,"terrain",i.vertexBuffer,i.indexBuffer,i.segments)}}(this.painter,this.terrain,this._rttTiles,i),this._rttTiles=[],Sw[r]}return!1}},Iw={"AttributionControl.ToggleAttribution":"Toggle attribution","AttributionControl.MapFeedback":"Map feedback","FullscreenControl.Enter":"Enter fullscreen","FullscreenControl.Exit":"Exit fullscreen","GeolocateControl.FindMyLocation":"Find my location","GeolocateControl.LocationNotAvailable":"Location not available","LogoControl.Title":"MapLibre logo","Map.Title":"Map","Marker.Title":"Map marker","NavigationControl.ResetBearing":"Drag to rotate map, click to reset north","NavigationControl.ZoomIn":"Zoom in","NavigationControl.ZoomOut":"Zoom out","Popup.Close":"Close popup","ScaleControl.Feet":"ft","ScaleControl.Meters":"m","ScaleControl.Kilometers":"km","ScaleControl.Miles":"mi","ScaleControl.NauticalMiles":"nm","GlobeControl.Enable":"Enable globe","GlobeControl.Disable":"Disable globe","TerrainControl.Enable":"Enable terrain","TerrainControl.Disable":"Disable terrain","CooperativeGesturesHandler.WindowsHelpText":"Use Ctrl + scroll to zoom the map","CooperativeGesturesHandler.MacHelpText":"Use ⌘ + scroll to zoom the map","CooperativeGesturesHandler.MobileHelpText":"Use two fingers to move the map"},Mw=im,Ew={hash:!1,interactive:!0,bearingSnap:7,zoomSnap:0,attributionControl:gw,maplibreLogo:!1,refreshExpiredTiles:!0,canvasContextAttributes:{antialias:!1,preserveDrawingBuffer:!1,powerPreference:"high-performance",failIfMajorPerformanceCaveat:!1,desynchronized:!1,contextType:void 0},scrollZoom:!0,minZoom:-2,maxZoom:22,minPitch:0,maxPitch:60,boxZoom:!0,dragRotate:!0,dragPan:!0,keyboard:!0,doubleClickZoom:!0,touchZoomRotate:!0,touchPitch:!0,cooperativeGestures:!1,trackResize:!0,center:[0,0],elevation:0,zoom:0,bearing:0,pitch:0,roll:0,renderWorldCopies:!0,maxTileCacheSize:null,maxTileCacheZoomLevels:it.MAX_TILE_CACHE_ZOOM_LEVELS,transformRequest:null,transformCameraUpdate:null,transformConstrain:null,fadeDuration:300,crossSourceCollisions:!0,clickTolerance:3,localIdeographFontFamily:"sans-serif",pitchWithRotate:!0,rollEnabled:!1,rotateSpeed:.8,pitchSpeed:-.5,reduceMotion:void 0,validateStyle:!0,maxCanvasSize:[4096,4096],cancelPendingTileRequestsWhileZooming:!0,centerClampedToGround:!0,terrainSkirtLength:"auto",zoomLevelsToOverscale:4,anisotropicFilterPitch:20},Aw=class extends _t{get _ownerWindow(){return this._container?.ownerDocument?.defaultView||window}constructor(e){super(),this._idleTriggered=!1,this._crossFadingFactor=1,this._renderTaskQueue=new xw,this._controls=[],this._mapId=Se(),this._missingStyleImageResolver=null,this._lostContextStyle={style:null,images:null},this._contextLost=e=>{if(e.preventDefault(),this._frameRequest&&=(this._frameRequest.abort(),null),this.painter.destroy(),this._lostContextStyle=this._getStyleAndImages(),this.style){for(let e of Object.values(this.style._layers))if("custom"===e.type&&console.warn(`Custom layer with id '${e.id}' cannot be restored after WebGL context loss. You will need to re-add it manually after context restoration.`),e._listeners)for(let[t]of Object.entries(e._listeners))console.warn(`Custom layer with id '${e.id}' had event listeners for event '${t}' which cannot be restored after WebGL context loss. You will need to re-add them manually after context restoration.`);this.style.destroy(),this.style=null,this.fire(new Sm("webglcontextlost",{originalEvent:e}))}else this.fire(new Sm("webglcontextlost",{originalEvent:e}))},this._contextRestored=e=>{if(this._lostContextStyle.style&&this.setStyle(this._lostContextStyle.style,{diff:!1}),this._lostContextStyle.images&&this.style){this.style.imageManager.images=this._lostContextStyle.images;for(let e in this._lostContextStyle.images){let t=this._lostContextStyle.images[e];t.isWebGLImage&&this.style.imageManager.updateImage(e,t,!1)}}this._lostContextStyle={style:null,images:null},this._setupPainter(),this.painter&&(this.resize(),this._update(),this._resizeInternal(),this.fire(new Sm("webglcontextrestored",{originalEvent:e})))},this._onMapScroll=e=>{if(e.target===this._container)return this._container.scrollTop=0,this._container.scrollLeft=0,!1},this._onWindowOnline=()=>{this._update()};let t={...Ew,...e,canvasContextAttributes:{...Ew.canvasContextAttributes,...e.canvasContextAttributes}};if(null!=t.minZoom&&null!=t.maxZoom&&t.minZoom>t.maxZoom)throw Error("maxZoom must be greater than or equal to minZoom");if(null!=t.minPitch&&null!=t.maxPitch&&t.minPitch>t.maxPitch)throw Error("maxPitch must be greater than or equal to minPitch");if(null!=t.minPitch&&t.minPitch<0)throw Error("minPitch must be greater than or equal to 0");if(null!=t.maxPitch&&t.maxPitch>180)throw Error("maxPitch must be less than or equal to 180");if(this._camera=new _w({minZoom:t.minZoom,maxZoom:t.maxZoom,minPitch:t.minPitch,maxPitch:t.maxPitch,bearingSnap:t.bearingSnap,zoomSnap:t.zoomSnap,renderWorldCopies:t.renderWorldCopies,centerClampedToGround:t.centerClampedToGround,terrain:this.terrain,transformConstrain:t.transformConstrain,requestRenderFrame:e=>this._requestRenderFrame(e),cancelRenderFrame:e=>this._cancelRenderFrame(e),transformCameraUpdate:t.transformCameraUpdate,stopHandlers:()=>this._handlers?.stop(!1)}),this._camera.setEventedParent(this),this._interactive=t.interactive,this._maxTileCacheSize=t.maxTileCacheSize,this._maxTileCacheZoomLevels=t.maxTileCacheZoomLevels,this._canvasContextAttributes={...t.canvasContextAttributes},this._trackResize=!0===t.trackResize,this._terrainSkirtLength=t.terrainSkirtLength,this._refreshExpiredTiles=!0===t.refreshExpiredTiles,this._fadeDuration=t.fadeDuration,this._crossSourceCollisions=!0===t.crossSourceCollisions,this._collectResourceTiming=!0===t.collectResourceTiming,this._locale={...Iw,...t.locale},this._clickTolerance=t.clickTolerance,this._overridePixelRatio=t.pixelRatio,this._maxCanvasSize=t.maxCanvasSize,this._zoomLevelsToOverscale=t.zoomLevelsToOverscale,this.cancelPendingTileRequestsWhileZooming=!0===t.cancelPendingTileRequestsWhileZooming,this.setAnisotropicFilterPitch(t.anisotropicFilterPitch),void 0!==t.reduceMotion&&(am.prefersReducedMotion=t.reduceMotion),this._imageQueueHandle=um.addThrottleControl(()=>this.isMoving()),this._requestManager=new pm(t.transformRequest),this._container=this._resolveContainer(t.container),t.maxBounds&&this.setMaxBounds(t.maxBounds),this._setupContainer(),this._setupPainter(),!this.painter)return;this.on("move",()=>this._update(!1)),this.on("moveend",()=>this._update(!1)),this.on("zoom",()=>this._update(!0)),this.on("terrain",()=>{this.painter.terrainFacilitator.depthDirty=!0,this._update(!0)}),this.once("idle",()=>this._idleTriggered=!0),this._handlers=new mw(this,this._camera,t),typeof window<"u"&&(this._ownerWindow.addEventListener("online",this._onWindowOnline,!1),this._setupResizeObserver());let i="string"==typeof t.hash&&t.hash||void 0;this._hash=t.hash?new vb(i).addTo(this):void 0,this._hash?._onHashChange()||(this.jumpTo({center:t.center,elevation:t.elevation,zoom:t.zoom,bearing:t.bearing,pitch:t.pitch,roll:t.roll}),t.bounds&&(this.resize(),this.fitBounds(t.bounds,be({},t.fitBoundsOptions,{duration:0}))));let r="string"==typeof t.style||"globe"!==t.style?.projection?.type;this.resize(null,r),this._localIdeographFontFamily=t.localIdeographFontFamily,this._validateStyle=t.validateStyle,t.style&&this.setStyle(t.style,{localIdeographFontFamily:t.localIdeographFontFamily}),t.attributionControl&&this.addControl(new yw("boolean"==typeof t.attributionControl?void 0:t.attributionControl)),t.maplibreLogo&&this.addControl(new vw,t.logoPosition),this.on("style.load",()=>{if(r||this._resizeTransform(),this._camera.transform.unmodified){let e=we(this.style.stylesheet,["center","zoom","bearing","pitch","roll"]);this.jumpTo(e)}}),this.on("data",e=>{this._update("style"===e.dataType),this.fire("style"===e.dataType?new _m("styledata",e):new gm("sourcedata",e))}),this.on("dataloading",e=>{this.fire("style"===e.dataType?new _m("styledataloading",e):new gm("sourcedataloading",e))}),this.on("dataabort",e=>{this.fire(new gm("sourcedataabort",e))})}_getMapId(){return this._mapId}setGlobalStateProperty(e,t){return this.style.setGlobalStateProperty(e,t),this._update(!0)}getGlobalState(){return this.style.getGlobalState()}addControl(e,t){if(void 0===t&&(t=e.getDefaultPosition?e.getDefaultPosition():"top-right"),!e?.onAdd)return this.fire(new mt(Error("Invalid argument to map.addControl(). Argument must be a control with onAdd and onRemove methods.")));let i=e.onAdd(this);this._controls.push(e);let r=this._controlPositions[t];return t.includes("bottom")?r.insertBefore(i,r.firstChild):r.appendChild(i),this}removeControl(e){if(!e?.onRemove)return this.fire(new mt(Error("Invalid argument to map.removeControl(). Argument must be a control with onAdd and onRemove methods.")));let t=this._controls.indexOf(e);return t>-1&&this._controls.splice(t,1),e.onRemove(this),this}hasControl(e){return this._controls.includes(e)}coveringTiles(e){return G_(this._camera.transform,e)}setTransformCameraUpdate(e){this._camera.transformCameraUpdate=e}getCenter(){return new Xu(this._camera.transform.center.lng,this._camera.transform.center.lat)}setCenter(e,t){return this._camera.setCenter(e,t),this}getCenterElevation(){return this._camera.transform.elevation}setCenterElevation(e,t){return this._camera.setCenterElevation(e,t),this}setCenterClampedToGround(e){this._camera.setCenterClampedToGround(e)}panBy(e,t,i){return this._camera.panBy(e,t,i),this}panTo(e,t,i){return this._camera.panTo(e,t,i),this}getZoom(){return this._camera.transform.zoom}setZoom(e,t){return this._camera.setZoom(e,t),this}zoomTo(e,t,i){return this._camera.zoomTo(e,t,i),this}zoomIn(e,t){return this._camera.zoomIn(e,t),this}zoomOut(e,t){return this._camera.zoomOut(e,t),this}getVerticalFieldOfView(){return this._camera.transform.fov}setVerticalFieldOfView(e,t){return this._camera.setVerticalFieldOfView(e,t),this}getBearing(){return this._camera.transform.bearing}setBearing(e,t){return this._camera.setBearing(e,t),this}getZoomSnap(){return this._camera.getZoomSnap()}setZoomSnap(e){return this._camera.setZoomSnap(e),this}getPadding(){return this._camera.transform.padding}setPadding(e,t){return this._camera.setPadding(e,t),this}rotateTo(e,t,i){return this._camera.rotateTo(e,t,i),this}resetNorth(e,t){return this._camera.resetNorth(e,t),this}resetNorthPitch(e,t){return this._camera.resetNorthPitch(e,t),this}snapToNorth(e,t){return this._camera.snapToNorth(e,t),this}getPitch(){return this._camera.transform.pitch}setPitch(e,t){return this._camera.setPitch(e,t),this}getRoll(){return this._camera.transform.roll}setRoll(e,t){return this._camera.setRoll(e,t),this}cameraForBounds(e,t){return this._camera.cameraForBounds(e,t)}fitBounds(e,t,i){return this._camera.fitBounds(e,t,i),this}fitScreenCoordinates(e,t,i,r,a){return this._camera.fitScreenCoordinates(e,t,i,r,a),this}jumpTo(e,t){return this._camera.jumpTo(e,t),this}calculateCameraOptionsFromCameraLngLatAltRotation(e,t,i,r,a){return this._camera.calculateCameraOptionsFromCameraLngLatAltRotation(e,t,i,r,a)}easeTo(e,t){return this._camera.easeTo(e,t),this}flyTo(e,t){return this._camera.flyTo(e,t),this}stop(){return this._camera.stop(),this}queryTerrainElevation(e){return this.terrain?this.terrain.getElevationForLngLat(Xu.convert(e),this._camera.transform):null}getCenterClampedToGround(){return this._camera.getCenterClampedToGround()}calculateCameraOptionsFromTo(e,t,i,r){return null==r&&this.terrain&&(r=this.terrain.getElevationForLngLat(i,this._camera.transform)),this._camera.calculateCameraOptionsFromTo(e,t,i,r)}resize(e,t=!0){if(null!==this._lostContextStyle.style)return this;this._resizeInternal(t);let i=!this._camera._moving;return i&&(this.stop(),this.fire(new fm("movestart",e)).fire(new fm("move",e))),this.fire(new dm("resize",e)),i&&this.fire(new fm("moveend",e)),this}_resizeInternal(e=!0){let[t,i]=this._containerDimensions(),r=this._getClampedPixelRatio(t,i);if(this._resizeCanvas(t,i,r),this.painter.resize(t,i,r),this.painter.overLimit()){let e=this.painter.context.gl;this._maxCanvasSize=[e.drawingBufferWidth,e.drawingBufferHeight];let r=this._getClampedPixelRatio(t,i);this._resizeCanvas(t,i,r),this.painter.resize(t,i,r)}this._resizeTransform(e)}_resizeTransform(e=!0){let[t,i]=this._containerDimensions();this._camera.transform.resize(t,i,e),this._camera._requestedCameraState?.resize(t,i,e)}_getClampedPixelRatio(e,t){let{0:i,1:r}=this._maxCanvasSize,a=this.getPixelRatio(),n=e*a,s=t*a,o=n>i?i/n:1,l=s>r?r/s:1;return Math.min(o,l)*a}getPixelRatio(){return this._overridePixelRatio??devicePixelRatio}setPixelRatio(e){this._overridePixelRatio=e,this.resize()}getBounds(){return this._camera.transform.getBounds()}getMaxBounds(){return this._camera.transform.getMaxBounds()}setMaxBounds(e){return this._camera.transform.setMaxBounds(s_.convert(e)),this._update()}setMinZoom(e){if(e??=-2,e>=-2&&e<=this._camera.transform.maxZoom){let t=this._camera.transform.zoom,i=this._camera.getTransformForUpdate();return i.setMinZoom(e),this._camera.applyUpdatedTransform(i),this._update(),t!==this._camera.transform.zoom&&this.fire(new fm("zoomstart")).fire(new fm("zoom")).fire(new fm("zoomend")).fire(new fm("movestart")).fire(new fm("move")).fire(new fm("moveend")),this}throw Error("minZoom must be between -2 and the current maxZoom, inclusive")}getMinZoom(){return this._camera.transform.minZoom}setMaxZoom(e){if(e??=22,e>=this._camera.transform.minZoom){let t=this._camera.transform.zoom,i=this._camera.getTransformForUpdate();return i.setMaxZoom(e),this._camera.applyUpdatedTransform(i),this._update(),t!==this._camera.transform.zoom&&this.fire(new fm("zoomstart")).fire(new fm("zoom")).fire(new fm("zoomend")).fire(new fm("movestart")).fire(new fm("move")).fire(new fm("moveend")),this}throw Error("maxZoom must be greater than the current minZoom")}getMaxZoom(){return this._camera.transform.maxZoom}setMinPitch(e){if(e??=0,e<0)throw Error("minPitch must be greater than or equal to 0");if(e>=0&&e<=this._camera.transform.maxPitch){let t=this._camera.transform.pitch,i=this._camera.getTransformForUpdate();return i.setMinPitch(e),this._camera.applyUpdatedTransform(i),this._update(),t!==this._camera.transform.pitch&&this.fire(new fm("pitchstart")).fire(new fm("pitch")).fire(new fm("pitchend")).fire(new fm("movestart")).fire(new fm("move")).fire(new fm("moveend")),this}throw Error("minPitch must be between 0 and the current maxPitch, inclusive")}getMinPitch(){return this._camera.transform.minPitch}setMaxPitch(e){if(e??=60,e>180)throw Error("maxPitch must be less than or equal to 180");if(e>=this._camera.transform.minPitch){let t=this._camera.transform.pitch,i=this._camera.getTransformForUpdate();return i.setMaxPitch(e),this._camera.applyUpdatedTransform(i),this._update(),t!==this._camera.transform.pitch&&this.fire(new fm("pitchstart")).fire(new fm("pitch")).fire(new fm("pitchend")).fire(new fm("movestart")).fire(new fm("move")).fire(new fm("moveend")),this}throw Error("maxPitch must be greater than the current minPitch")}getMaxPitch(){return this._camera.transform.maxPitch}getAnisotropicFilterPitch(){return this._anisotropicFilterPitch}setAnisotropicFilterPitch(e){if(e??=20,e>180)throw Error("anisotropicFilterPitch must be less than or equal to 180");if(e<0)throw Error("anisotropicFilterPitch must be greater than or equal to 0");return this._anisotropicFilterPitch=e,this._update()}getRenderWorldCopies(){return this._camera.transform.renderWorldCopies}setRenderWorldCopies(e){return this._camera.transform.setRenderWorldCopies(e),this._update()}setTransformConstrain(e){return this._camera.transform.setConstrainOverride(e),this._update()}project(e){return this._camera.transform.locationToScreenPoint(Xu.convert(e),this.style&&this.terrain)}unproject(e){return this._camera.transform.screenPointToLocation(u.convert(e),this.terrain)}isMoving(){return this._camera.isMoving()||this._handlers?.isMoving()||!1}isZooming(){return this._camera.isZooming()||this._handlers?.isZooming()||!1}isRotating(){return this._camera.isRotating()||this._handlers?.isRotating()||!1}_createDelegatedListener(e,t,i){if("mouseenter"===e||"mouseover"===e){let r=!1;return{layers:t,listener:i,delegates:{mousemove:a=>{let n=t.filter(e=>this.getLayer(e)),s=0===n.length?[]:this.queryRenderedFeatures(a.point,{layers:n});s.length?r||(r=!0,i.call(this,new ym(e,this,a.originalEvent,{features:s}))):r=!1},mouseout:()=>{r=!1}}}}if("mouseleave"===e||"mouseout"===e){let r=!1;return{layers:t,listener:i,delegates:{mousemove:a=>{let n=t.filter(e=>this.getLayer(e));(0===n.length?[]:this.queryRenderedFeatures(a.point,{layers:n})).length?r=!0:r&&(r=!1,i.call(this,new ym(e,this,a.originalEvent)))},mouseout:t=>{r&&(r=!1,i.call(this,new ym(e,this,t.originalEvent)))}}}}{let r=e=>{let r=t.filter(e=>this.getLayer(e)),a=0===r.length?[]:this.queryRenderedFeatures(e.point,{layers:r});a.length&&(e.features=a,i.call(this,e),delete e.features)};return{layers:t,listener:i,delegates:{[e]:r}}}}_saveDelegatedListener(e,t){this._delegatedListeners||={},this._delegatedListeners[e]||=[],this._delegatedListeners[e].push(t)}_removeDelegatedListener(e,t,i){if(!this._delegatedListeners?.[e])return;let r=this._delegatedListeners[e];for(let a=0;a<r.length;a++){let e=r[a];if(e.listener===i&&e.layers.length===t.length&&e.layers.every(e=>t.includes(e))){for(let t in e.delegates)this.off(t,e.delegates[t]);return void r.splice(a,1)}}}on(e,t,i){if(void 0===i)return super.on(e,t);let r="string"==typeof t?[t]:t,a=this._createDelegatedListener(e,r,i);this._saveDelegatedListener(e,a);for(let n in a.delegates)this.on(n,a.delegates[n]);return{unsubscribe:()=>{this._removeDelegatedListener(e,r,i)}}}once(e,t,i){if(void 0===i)return super.once(e,t);let r="string"==typeof t?[t]:t,a=this._createDelegatedListener(e,r,i);for(let n in a.delegates){let t=a.delegates[n];a.delegates[n]=(...a)=>{this._removeDelegatedListener(e,r,i),t(...a)}}this._saveDelegatedListener(e,a);for(let n in a.delegates)this.once(n,a.delegates[n]);return this}off(e,t,i){if(void 0===i)return super.off(e,t);let r="string"==typeof t?[t]:t;return this._removeDelegatedListener(e,r,i),this}queryRenderedFeatures(e,t){if(!this.style)return[];let i,r=e instanceof u||Array.isArray(e),a=r?e:[[0,0],[this._camera.transform.width,this._camera.transform.height]];if(t||=(r?{}:e)||{},a instanceof u||"number"==typeof a[0])i=[u.convert(a)];else{let e=u.convert(a[0]),t=u.convert(a[1]);i=[e,new u(t.x,e.y),t,new u(e.x,t.y),e]}return this.style.queryRenderedFeatures(i,t,this._camera.transform)}querySourceFeatures(e,t){return this.style.querySourceFeatures(e,t)}setStyle(e,t){return!1!==(t=be({},{localIdeographFontFamily:this._localIdeographFontFamily,validate:this._validateStyle},t)).diff&&t.localIdeographFontFamily===this._localIdeographFontFamily&&this.style&&e?(this._diffStyle(e,t),this):(this._localIdeographFontFamily=t.localIdeographFontFamily,this._updateStyle(e,t))}setTransformRequest(e){return this._requestManager.setTransformRequest(e),this}_getUIString(e){let t=this._locale[e];if(null==t)throw Error(`Missing UI string '${e}'`);return t}_updateStyle(e,t){if(this._diffStyleRequest?.abort(),this._diffStyleRequest=null,t.transformStyle&&this.style&&!this.style._loaded)return void this.style.once("style.load",()=>this._updateStyle(e,t));let i=this.style&&t.transformStyle?this.style.serialize():void 0;return this.style&&(this.style.setEventedParent(null),this.style._remove(!e)),e?(this.style=new Wy(this,t||{}),this.style.setEventedParent(this,{style:this.style}),"string"==typeof e?this.style.loadURL(e,t,i):this.style.loadJSON(e,t,i),this):(this._frameRequest&&=(this._frameRequest.abort(),null),this.style?.projection?.destroy(),delete this.style,this)}_lazyInitEmptyStyle(){this.style||(this.style=new Wy(this,{}),this.style.setEventedParent(this,{style:this.style}),this.style.loadEmpty())}async _diffStyle(e,t){if(this._diffStyleRequest?.abort(),"string"==typeof e){let i=e;this._diffStyleRequest=new AbortController;let r=this._diffStyleRequest;try{let e=await this._requestManager.transformRequest(i,"Style");if(r.signal.aborted)return void(this._diffStyleRequest=null);let a=await ut(e,r);this._diffStyleRequest=null,this._updateDiff(a.data,t)}catch(e){this._diffStyleRequest=null,et(e)||this.fire(new mt(ee(e)))}}else"object"==typeof e&&(this._diffStyleRequest=null,this._updateDiff(e,t))}_updateDiff(e,t){try{this.style.setState(e,t)&&this._update(!0)}catch(a){Re(`Unable to perform style diff: ${ee(a).message}. Rebuilding the style from scratch.`),this._updateStyle(e,t)}}getStyle(){if(this.style)return this.style.serialize()}_getStyleAndImages(){return this.style?{style:this.style.serialize(),images:this.style.imageManager.cloneImages()}:{style:null,images:{}}}isStyleLoaded(){if(this.style)return this.style.loaded();Re("There is no style added to the map.")}addSource(e,t){return this._lazyInitEmptyStyle(),this.style.addSource(e,t),this._update(!0)}isSourceLoaded(e){let t=this.style?.tileManagers[e];if(void 0!==t)return t.loaded();this.fire(new mt(Error(`There is no tile manager with ID '${e}'`)))}setTerrain(e,t={}){if(this.style._checkLoaded(),e&&es(this,Yn.terrain,{value:e},t))return this;if(this._terrainDataCallback&&this.style.off("data",this._terrainDataCallback),e){let t=this.style.tileManagers[e.source];if(!t)throw Error(`cannot load terrain, because there exists no source with ID: ${e.source}`);null===this.terrain&&t.reload();for(let i in this.style._layers){let t=this.style._layers[i];"hillshade"===t.type&&t.source===e.source&&Re("You are using the same source for a hillshade layer and for 3D terrain. Please consider using two separate sources to improve rendering quality."),"color-relief"===t.type&&t.source===e.source&&Re("You are using the same source for a color-relief layer and for 3D terrain. Please consider using two separate sources to improve rendering quality.")}this.terrain&&this.terrain.destroy(),this.terrain=new Tw(this.painter,t,e,this._terrainSkirtLength),this.painter.renderToTexture=new Pw(this.painter,this.terrain),this._camera.terrain=this.terrain,this._camera.transform.setMinElevationForCurrentTile(this.terrain.getMinTileElevationForLngLatZoom(this._camera.transform.center,this._camera.transform.tileZoom)),this._camera.transform.setElevation(this.terrain.getElevationForLngLatZoom(this._camera.transform.center,this._camera.transform.tileZoom)),this._terrainDataCallback=t=>this._handleTerrainDataEvent(t,e.source),this.style.on("data",this._terrainDataCallback)}else this.terrain&&this.terrain.destroy(),this.terrain=null,this.painter.renderToTexture=null,this._camera.terrain=null,this._camera.transform.setMinElevationForCurrentTile(0),this.getCenterClampedToGround()&&this._camera.transform.setElevation(0);return this.fire(new wm({terrain:e})),this}_handleTerrainDataEvent(e,t){if("style"===e.dataType)return void this.terrain.tileManager.releaseAllRTT();let i=e.sourceId===t;if(i&&this.terrain.resetElevationCache(),i&&e.tile&&!this._camera.elevationFreeze&&(this._camera.transform.setMinElevationForCurrentTile(this.terrain.getMinTileElevationForLngLatZoom(this._camera.transform.center,this._camera.transform.tileZoom)),this.getCenterClampedToGround()&&this._camera.transform.setElevation(this.terrain.getElevationForLngLatZoom(this._camera.transform.center,this._camera.transform.tileZoom))),e.tile){if("image"===e.source?.type)return void this.terrain.tileManager.releaseAllRTT();this.terrain.tileManager.releaseRTT(e.tile.tileID)}}getTerrain(){return this.terrain?.options??null}areTilesLoaded(){let e=this.style?.tileManagers;for(let t of Object.values(e))if(!t.areTilesLoaded())return!1;return!0}removeSource(e){return this.style.removeSource(e),this._update(!0)}getSource(e){return this.style?.getSource(e)}setSourceTileLodParams(e,t,i){if(i){let r=this.getSource(i);if(!r)throw Error(`There is no source with ID "${i}", cannot set LOD parameters`);r.calculateTileZoom=j_(Math.max(1,e),Math.max(1,t))}else for(let r in this.style.tileManagers)this.style.tileManagers[r].getSource().calculateTileZoom=j_(Math.max(1,e),Math.max(1,t));return this._update(!0),this}refreshTiles(e,t){let i=this.style.tileManagers[e];if(!i)throw Error(`There is no tile manager with ID "${e}", cannot refresh tile`);void 0===t?i.reload(!0):i.refreshTiles(t.map(e=>new zp(e.z,e.x,e.y)))}addImage(e,t,i={}){this._lazyInitEmptyStyle();let r=this._createStyleImage(t,i);return r?(this.style.addImage(e,r),r.userImage?.onAdd&&r.userImage.onAdd(this,e),this):this}setMissingStyleImageResolver(e){return this._missingStyleImageResolver=e,this.style?.setMissingImageResolver(e),this}_createStyleImage(e,t={}){let{pixelRatio:i=1,sdf:r=!1,stretchX:a,stretchY:n,content:s,textFitWidth:o,textFitHeight:l}=t;if(e instanceof HTMLImageElement||Oe(e)){let{width:t,height:h,data:u}=am.getImageData(e);return{data:new yh({width:t,height:h},u),pixelRatio:i,stretchX:a,stretchY:n,content:s,textFitWidth:o,textFitHeight:l,sdf:r,version:0}}if(void 0===e.width||void 0===e.height)return this.fire(new mt(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`"))),null;{let{width:t,height:h,data:u}=e,c=e,p=ep(c.data);return{data:p?new yh({width:t,height:h}):new yh({width:t,height:h},new Uint8Array(u)),pixelRatio:i,stretchX:a,stretchY:n,content:s,textFitWidth:o,textFitHeight:l,sdf:r,version:0,isWebGLImage:p,userImage:c}}}updateImage(e,t){let i=this.style.getImage(e);if(!i)return this.fire(new mt(Error("The map has no image with that id. If you are adding a new image use `map.addImage(...)` instead.")));let{width:r,height:a,data:n}=t instanceof HTMLImageElement||Oe(t)?am.getImageData(t):t;if(void 0===r||void 0===a)return this.fire(new mt(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(r!==i.data.width||a!==i.data.height)return this.fire(new mt(Error("The width and height of the updated image must be that same as the previous version of the image")));if(i.isWebGLImage=ep(n),i.isWebGLImage)i.userImage=t;else{let e=!(t instanceof HTMLImageElement||Oe(t));i.data.replace(n,e)}return this.style.updateImage(e,i),this}getImage(e){return this.style.getImage(e)}hasImage(e){return e?!!this.style.getImage(e):(this.fire(new mt(Error("Missing required image id"))),!1)}removeImage(e){this.style.removeImage(e)}async loadImage(e){return um.getImage(await this._requestManager.transformRequest(e,"Image"),new AbortController)}listImages(){return this.style?.listImages()??[]}addLayer(e,t){return this._lazyInitEmptyStyle(),this.style.addLayer(e,t),this._update(!0)}moveLayer(e,t){return this.style.moveLayer(e,t),this._update(!0)}removeLayer(e){return this.style.removeLayer(e),this._update(!0)}getLayer(e){return this.style?.getLayer(e)}getLayersOrder(){return this.style?.getLayersOrder()??[]}setLayerZoomRange(e,t,i){return this.style.setLayerZoomRange(e,t,i),this._update(!0)}setFilter(e,t,i={}){return this.style?.setFilter(e,t,i),this._update(!0)}getFilter(e){return this.style.getFilter(e)}setPaintProperty(e,t,i,r={}){return this.style?.setPaintProperty(e,t,i,r),this._update(!0)}getPaintProperty(e,t){return this.style.getPaintProperty(e,t)}setLayoutProperty(e,t,i,r={}){return this.style.setLayoutProperty(e,t,i,r),this._update(!0)}getLayoutProperty(e,t){return this.style.getLayoutProperty(e,t)}setGlyphs(e,t={}){return this._lazyInitEmptyStyle(),this.style.setGlyphs(e,t),this._update(!0)}getGlyphs(){return this.style.getGlyphsUrl()}addSprite(e,t,i={}){return this._lazyInitEmptyStyle(),this.style.addSprite(e,t,i,e=>{e||this._update(!0)}),this}removeSprite(e){return this._lazyInitEmptyStyle(),this.style.removeSprite(e),this._update(!0)}getSprite(){return this.style.getSprite()}setSprite(e,t={}){return this._lazyInitEmptyStyle(),this.style.setSprite(e,t,e=>{e||this._update(!0)}),this}setLight(e,t={}){return this._lazyInitEmptyStyle(),this.style.setLight(e,t),this._update(!0)}getLight(){return this.style.getLight()}setSky(e,t={}){return this._lazyInitEmptyStyle(),this.style.setSky(e,t),this._update(!0)}getSky(){return this.style.getSky()}setFeatureState(e,t){return this.style.setFeatureState(e,t),this._update()}removeFeatureState(e,t){return this.style.removeFeatureState(e,t),this._update()}getFeatureState(e){return this.style.getFeatureState(e)}getContainer(){return this._container}getCanvasContainer(){return this._canvasContainer}getCanvas(){return this._canvas}_containerDimensions(){let e=0,t=0;return this._container&&(e=this._container.clientWidth||400,t=this._container.clientHeight||300),[e,t]}_setupResizeObserver(){let e=!1,t=yb(e=>{this._trackResize&&!this._removed&&(this.resize(e),this.redraw())},50),i=this._ownerWindow.ResizeObserver??ResizeObserver;this._resizeObserver=new i(i=>{e?t(i):e=!0}),this._resizeObserver.observe(this._container)}_resolveContainer(e){if("string"==typeof e){let t=document.getElementById(e);if(!t)throw Error(`Container '${e}' not found.`);return t}if(e instanceof HTMLElement||e&&"object"==typeof e&&1===e.nodeType)return e;throw Error("Invalid type: 'container' must be a String or HTMLElement.")}_setupContainer(){let e=this._container;e.classList.add("maplibregl-map");let t=this._canvasContainer=cm.create("div","maplibregl-canvas-container",e);this._interactive&&t.classList.add("maplibregl-interactive"),this._canvas=cm.create("canvas","maplibregl-canvas",t),this._canvas.addEventListener("webglcontextlost",this._contextLost,!1),this._canvas.addEventListener("webglcontextrestored",this._contextRestored,!1),this._canvas.setAttribute("tabindex",this._interactive?"0":"-1"),this._canvas.setAttribute("aria-label",this._getUIString("Map.Title")),this._canvas.setAttribute("role","region");let i=this._containerDimensions(),r=this._getClampedPixelRatio(i[0],i[1]);this._resizeCanvas(i[0],i[1],r);let a=this._controlContainer=cm.create("div","maplibregl-control-container",e),n=this._controlPositions={};for(let s of["top-left","top-right","bottom-left","bottom-right"])n[s]=cm.create("div",`maplibregl-ctrl-${s} `,a);this._container.addEventListener("scroll",this._onMapScroll,!1)}_resizeCanvas(e,t,i){this._canvas.width=Math.floor(i*e),this._canvas.height=Math.floor(i*t),this._canvas.style.width=`${e}px`,this._canvas.style.height=`${t}px`}_setupPainter(){let e={...this._canvasContextAttributes,alpha:!0,depth:!0,stencil:!0,premultipliedAlpha:!0},t=null;this._canvas.addEventListener("webglcontextcreationerror",e=>{t=e},{once:!0});let i=this._canvas.getContext("webgl2",e);i?this.painter=new _b(i,this._camera.transform):this.fire(new mt(new gb(e,t)))}migrateProjection(e,t){this._camera.migrateProjection(e,t),this.painter.transform=e,this.fire(new Tm({newProjection:this.style.projection.name}))}loaded(){return!this._styleDirty&&!this._sourcesDirty&&!!this.style&&this.style.loaded()}_update(e){return this.style?._loaded?(this._styleDirty||=e,this._sourcesDirty=!0,this.triggerRepaint(),this):this}_requestRenderFrame(e){return this._update(),this._renderTaskQueue.add(e)}_cancelRenderFrame(e){this._renderTaskQueue.remove(e)}_render(e){let t=this._idleTriggered?this._fadeDuration:0,i=this.style.projection?.transitionState>0;if(this.painter.context.setDirty(),this.painter.setBaseState(),this._renderTaskQueue.run(e),this._removed)return;let r=!1;if(this.style&&this._styleDirty){this._styleDirty=!1;let e=this._camera.transform.zoom,i=sm();this.style.zoomHistory.update(e,i);let a=new ys(e,{now:i,fadeDuration:t,zoomHistory:this.style.zoomHistory,transition:this.style.getTransition()}),n=a.crossFadingFactor();(1!==n||n!==this._crossFadingFactor)&&(r=!0,this._crossFadingFactor=n),this.style.update(a)}let a=this.style.projection?.transitionState>0!==i;this._camera.transform.setTransitionState(this.style.projection?.transitionState),this.style&&(this._sourcesDirty||a)&&(this._sourcesDirty=!1,this.style._updateSources(this._camera.transform)),this.terrain?(this.terrain.tileManager.update(this._camera.transform,this.terrain),this.terrain.resetElevationCache(),this._camera.transform.setMinElevationForCurrentTile(this.terrain.getMinTileElevationForLngLatZoom(this._camera.transform.center,this._camera.transform.tileZoom)),!this._camera.elevationFreeze&&this.getCenterClampedToGround()&&this._camera.transform.setElevation(this.terrain.getElevationForLngLatZoom(this._camera.transform.center,this._camera.transform.tileZoom))):(this._camera.transform.setMinElevationForCurrentTile(0),this.getCenterClampedToGround()&&this._camera.transform.setElevation(0)),this._placementDirty=this.style?._updatePlacement(this._camera.transform,this.showCollisionBoxes,t,this._crossSourceCollisions,a),this.painter.render(this.style,{showTileBoundaries:this.showTileBoundaries,showOverdrawInspector:this._showOverdrawInspector,rotating:this.isRotating(),zooming:this.isZooming(),moving:this.isMoving(),fadeDuration:t,showPadding:this.showPadding,anisotropicFilterPitch:this.getAnisotropicFilterPitch()}),this.fire(new dm("render")),this.loaded()&&!this._loaded&&(this._loaded=!0,this.fire(new dm("load"))),this.style&&(this.style.hasTransitions()||r)&&(this._styleDirty=!0),this.style&&!this._placementDirty&&this.style._releaseSymbolFadeTiles();let n=this._sourcesDirty||this._styleDirty||this._placementDirty;return n||this._repaint?this.triggerRepaint():!this.isMoving()&&this.loaded()&&this.fire(new dm("idle")),this._loaded&&!this._fullyLoaded&&!n&&(this._fullyLoaded=!0),this}redraw(){return this.style&&(this._frameRequest&&=(this._frameRequest.abort(),null),this._render(0)),this}remove(){this._hash&&this._hash.remove();for(let t of this._controls)t.onRemove(this);this._controls=[],this._frameRequest&&=(this._frameRequest.abort(),null),this._renderTaskQueue.clear(),this._diffStyleRequest?.abort(),this.painter.destroy(),this._handlers.destroy(),this.setStyle(null),typeof window<"u"&&this._ownerWindow.removeEventListener("online",this._onWindowOnline,!1),um.removeThrottleControl(this._imageQueueHandle),this._resizeObserver?.disconnect();let e=this.painter.context.gl.getExtension("WEBGL_lose_context");e?.loseContext&&e.loseContext(),this._canvas.removeEventListener("webglcontextrestored",this._contextRestored,!1),this._canvas.removeEventListener("webglcontextlost",this._contextLost,!1),this._canvasContainer.remove(),this._controlContainer.remove(),this._container.removeEventListener("scroll",this._onMapScroll,!1),this._container.classList.remove("maplibregl-map"),this._removed=!0,this.fire(new dm("remove"))}triggerRepaint(){this.style&&!this._frameRequest&&(this._frameRequest=new AbortController,am.frame(this._frameRequest,e=>{this._frameRequest=null;try{this._render(e)}catch(e){if(!et(e))throw e}},()=>{},this._ownerWindow))}get showTileBoundaries(){return!!this._showTileBoundaries}set showTileBoundaries(e){this._showTileBoundaries!==e&&(this._showTileBoundaries=e,this._update())}get showPadding(){return!!this._showPadding}set showPadding(e){this._showPadding!==e&&(this._showPadding=e,this._update())}get showCollisionBoxes(){return!!this._showCollisionBoxes}set showCollisionBoxes(e){this._showCollisionBoxes!==e&&(this._showCollisionBoxes=e,e?this.style._generateCollisionBoxes():this._update())}get showOverdrawInspector(){return!!this._showOverdrawInspector}set showOverdrawInspector(e){this._showOverdrawInspector!==e&&(this._showOverdrawInspector=e,this._update())}get repaint(){return!!this._repaint}set repaint(e){this._repaint!==e&&(this._repaint=e,this.triggerRepaint())}get vertices(){return!!this._vertices}set vertices(e){this._vertices=e,this._update()}get version(){return Mw}getCameraTargetElevation(){return this._camera.transform.elevation}getProjection(){return this.style.getProjection()}setProjection(e){return this._lazyInitEmptyStyle(),this.style.setProjection(e),this._update(!0)}},Cw={showCompass:!0,showZoom:!0,visualizePitch:!1,visualizeRoll:!0},Dw=class{constructor(e){this._updateZoomButtons=()=>{let e=this._map.getZoom(),t=e===this._map.getMaxZoom(),i=e===this._map.getMinZoom();this._zoomInButton.disabled=t,this._zoomOutButton.disabled=i,this._zoomInButton.setAttribute("aria-disabled",t.toString()),this._zoomOutButton.setAttribute("aria-disabled",i.toString())},this._rotateCompassArrow=()=>{let e=this._map.getPitch(),t=this._map.getRoll(),i=this._map.getBearing(),r=1/Math.cos(Ne(e))**.5;this.options.visualizePitch&&this.options.visualizeRoll?this._compassIcon.style.transform=`scale(${r}) rotateZ(${-t}deg) rotateX(${e}deg) rotateZ(${-i}deg)`:this.options.visualizePitch?this._compassIcon.style.transform=`scale(${r}) rotateX(${e}deg) rotateZ(${-i}deg)`:this.options.visualizeRoll?this._compassIcon.style.transform=`rotate(${-i-t}deg)`:this._compassIcon.style.transform=`rotate(${-i}deg)`},this._setButtonTitle=(e,t)=>{let i=this._map._getUIString(`NavigationControl.${t}`);e.title=i,e.setAttribute("aria-label",i)},this.options=be({},Cw,e),this._container=cm.create("div","maplibregl-ctrl maplibregl-ctrl-group"),this._container.addEventListener("contextmenu",e=>e.preventDefault()),this.options.showZoom&&(this._zoomInButton=this._createButton("maplibregl-ctrl-zoom-in",e=>this._map.zoomIn({},{originalEvent:e})),cm.create("span","maplibregl-ctrl-icon",this._zoomInButton).setAttribute("aria-hidden","true"),this._zoomOutButton=this._createButton("maplibregl-ctrl-zoom-out",e=>this._map.zoomOut({},{originalEvent:e})),cm.create("span","maplibregl-ctrl-icon",this._zoomOutButton).setAttribute("aria-hidden","true")),this.options.showCompass&&(this._compass=this._createButton("maplibregl-ctrl-compass",e=>{this.options.visualizePitch?this._map.resetNorthPitch({},{originalEvent:e}):this._map.resetNorth({},{originalEvent:e})}),this._compassIcon=cm.create("span","maplibregl-ctrl-icon",this._compass),this._compassIcon.setAttribute("aria-hidden","true"))}onAdd(e){return this._map=e,this.options.showZoom&&(this._setButtonTitle(this._zoomInButton,"ZoomIn"),this._setButtonTitle(this._zoomOutButton,"ZoomOut"),this._map.on("zoom",this._updateZoomButtons),this._updateZoomButtons()),this.options.showCompass&&(this._setButtonTitle(this._compass,"ResetBearing"),this.options.visualizePitch&&this._map.on("pitch",this._rotateCompassArrow),this.options.visualizeRoll&&this._map.on("roll",this._rotateCompassArrow),this._map.on("rotate",this._rotateCompassArrow),this._rotateCompassArrow(),this._handler=new zw(this._map,this._compass,this.options.visualizePitch)),this._container}onRemove(){this._container.remove(),this.options.showZoom&&this._map.off("zoom",this._updateZoomButtons),this.options.showCompass&&(this.options.visualizePitch&&this._map.off("pitch",this._rotateCompassArrow),this.options.visualizeRoll&&this._map.off("roll",this._rotateCompassArrow),this._map.off("rotate",this._rotateCompassArrow),this._handler.off(),delete this._handler),delete this._map}_createButton(e,t){let i=cm.create("button",e,this._container);return i.type="button",i.addEventListener("click",t),i}},zw=class{constructor(e,t,i=!1){this.mousedown=e=>{this.startMove(e,cm.mousePos(this.element,e)),window.addEventListener("mousemove",this.mousemove),window.addEventListener("mouseup",this.mouseup)},this.mousemove=e=>{this.move(e,cm.mousePos(this.element,e))},this.mouseup=e=>{this._rotatePitchHandler.dragEnd(e),this.offTemp()},this.touchstart=e=>{1===e.targetTouches.length?(this._startPos=this._lastPos=cm.touchPos(this.element,e.targetTouches)[0],this.startMove(e,this._startPos),window.addEventListener("touchmove",this.touchmove,{passive:!1}),window.addEventListener("touchend",this.touchend)):this.reset()},this.touchmove=e=>{1===e.targetTouches.length?(this._lastPos=cm.touchPos(this.element,e.targetTouches)[0],this.move(e,this._lastPos)):this.reset()},this.touchend=e=>{0===e.targetTouches.length&&this._startPos&&this._lastPos&&this._startPos.dist(this._lastPos)<this._clickTolerance&&this.element.click(),delete this._startPos,delete this._lastPos,this.offTemp()},this.reset=()=>{this._rotatePitchHandler.reset(),delete this._startPos,delete this._lastPos,this.offTemp()},this._clickTolerance=10,this.element=t;let r=new jb;this._rotatePitchHandler=new Fb({clickTolerance:3,move:(e,r)=>{let a=t.getBoundingClientRect(),n=new u((a.bottom-a.top)/2,(a.right-a.left)/2);return{bearingDelta:$e(new u(e.x,r.y),r,n),pitchDelta:i?-.5*(r.y-e.y):void 0}},moveStateManager:r,enable:!0,assignEvents:()=>{}}),this.map=e,t.addEventListener("mousedown",this.mousedown),t.addEventListener("touchstart",this.touchstart,{passive:!1}),t.addEventListener("touchcancel",this.reset)}startMove(e,t){this._rotatePitchHandler.dragStart(e,t),cm.disableDrag()}move(e,t){let i=this.map,{bearingDelta:r,pitchDelta:a}=this._rotatePitchHandler.dragMove(e,t)||{};r&&i.setBearing(i.getBearing()+r),a&&i.setPitch(i.getPitch()+a)}off(){let e=this.element;e.removeEventListener("mousedown",this.mousedown),e.removeEventListener("touchstart",this.touchstart),window.removeEventListener("touchmove",this.touchmove),window.removeEventListener("touchend",this.touchend),e.removeEventListener("touchcancel",this.reset),this.offTemp()}offTemp(){cm.enableDrag(),window.removeEventListener("mousemove",this.mousemove),window.removeEventListener("mouseup",this.mouseup),window.removeEventListener("touchmove",this.touchmove),window.removeEventListener("touchend",this.touchend)}};function Rw(e,t,i,r=!1){if(r||!i.getCoveringTilesDetailsProvider().allowWorldCopies())return e?.wrap();let a=new Xu(e.lng,e.lat);if(e=new Xu(e.lng,e.lat),t){let r=new Xu(e.lng-360,e.lat),a=new Xu(e.lng+360,e.lat),n=i.locationToScreenPoint(e).distSqr(t);i.locationToScreenPoint(r).distSqr(t)<n?e=r:i.locationToScreenPoint(a).distSqr(t)<n&&(e=a)}for(;Math.abs(e.lng-i.center.lng)>180;){let t=i.locationToScreenPoint(e);if(t.x>=0&&t.y>=0&&t.x<=i.width&&t.y<=i.height)break;e.lng>i.center.lng?e.lng-=360:e.lng+=360}return e.lng!==a.lng&&i.isPointOnMapSurface(i.locationToScreenPoint(e))?e:a}var kw={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%)"};function Lw(e,t,i){let r=e.classList;for(let a in kw)r.remove(`maplibregl-${i}-anchor-${a}`);r.add(`maplibregl-${i}-anchor-${t}`)}var Fw={ArrowLeft:[-1,0],ArrowRight:[1,0],ArrowUp:[0,-1],ArrowDown:[0,1]},Bw=class extends ft{},Ow=class extends ft{},Vw=class extends _t{constructor(e){if(super(),this._onClick=e=>{this.fire(new Ow("click",{originalEvent:e}))},this._onKeyPress=e=>{("Space"===e.code||"Enter"===e.code)&&this.togglePopup()},this._onKeyDown=e=>{if(!this._defaultMarker||!this._draggable||!this._map||!this._lngLat||e.composedPath()[0]!==this._element||e.altKey||e.ctrlKey||e.metaKey)return;let t=Fw[e.key];if(!t)return;e.preventDefault(),e.stopPropagation();let i=e.shiftKey?10:1,r=this._map.project(this._lngLat);this.setLngLat(this._map.unproject(new u(r.x+t[0]*i,r.y+t[1]*i))),this._keyboardDragActive||(this._keyboardDragActive=!0,this.fire(new Bw("dragstart"))),this.fire(new Bw("drag"))},this._onKeyUp=e=>{Fw[e.key]&&this._endKeyboardDrag()},this._onBlur=()=>{this._endKeyboardDrag()},this._onMapClick=e=>{let t=e.originalEvent.target,i=this._element;this._popup&&(t===i||i.contains(t))&&this.togglePopup()},this._update=e=>{if(!this._map)return;let t=this._map.loaded()&&!this._map.isMoving();("terrain"===e?.type||"render"===e?.type&&!t)&&this._map.once("render",this._update),this._lngLat=Rw(this._lngLat,this._flatPos,this._map._camera.transform),this._flatPos=this._pos=this._map.project(this._lngLat)._add(this._offset),this._map.terrain&&(this._flatPos=this._map._camera.transform.locationToScreenPoint(this._lngLat)._add(this._offset));let i="";"viewport"===this._rotationAlignment||"auto"===this._rotationAlignment?i=`rotateZ(${this._rotation}deg)`:"map"===this._rotationAlignment&&(i=`rotateZ(${this._rotation-this._map.getBearing()}deg)`);let r="";"viewport"===this._pitchAlignment||"auto"===this._pitchAlignment?r="rotateX(0deg)":"map"===this._pitchAlignment&&(r=`rotateX(${this._map.getPitch()}deg)`),!this._subpixelPositioning&&(!e||"moveend"===e.type)&&(this._pos=this._pos.round()),this._element.style.transform=`${kw[this._anchor]} translate(${this._pos.x}px, ${this._pos.y}px) ${r} ${i}`,am.frameAsync(new AbortController,this._map._ownerWindow).then(()=>{this._updateOpacity("moveend"===e?.type)}).catch(()=>{})},this._onMove=e=>{if(!this._isDragging){let t=this._clickTolerance||this._map._clickTolerance;this._isDragging=e.point.dist(this._pointerdownPos)>=t}this._isDragging&&(this._pos=e.point.sub(this._positionDelta),this._lngLat=this._map.unproject(this._pos),this.setLngLat(this._lngLat),this._element.style.pointerEvents="none","pending"===this._state&&(this._state="active",this.fire(new Bw("dragstart"))),this.fire(new Bw("drag")))},this._onUp=()=>{this._element.style.pointerEvents="auto",this._positionDelta=null,this._pointerdownPos=null,this._isDragging=!1,this._map.off("mousemove",this._onMove),this._map.off("touchmove",this._onMove),"active"===this._state&&this.fire(new Bw("dragend")),this._state="inactive"},this._addDragHandler=e=>{this._element.contains(e.originalEvent.target)&&(e.preventDefault(),this._positionDelta=e.point.sub(this._pos).add(this._offset),this._pointerdownPos=e.point,this._state="pending",this._map.on("mousemove",this._onMove),this._map.on("touchmove",this._onMove),this._map.once("mouseup",this._onUp),this._map.once("touchend",this._onUp))},this._anchor=e?.anchor||"center",this._color=e?.color||"#3FB1CE",this._scale=e?.scale||1,this._draggable=e?.draggable||!1,this._clickTolerance=e?.clickTolerance||0,this._subpixelPositioning=e?.subpixelPositioning||!1,this._isDragging=!1,this._roleManaged=!1,this._tabIndexManaged=!1,this._keyboardDragActive=!1,this._state="inactive",this._rotation=e?.rotation||0,this._rotationAlignment=e?.rotationAlignment||"auto",this._pitchAlignment=e?.pitchAlignment&&"auto"!==e.pitchAlignment?e.pitchAlignment:this._rotationAlignment,this.setOpacity(e?.opacity,e?.opacityWhenCovered),e?.element)this._element=e.element,this._offset=u.convert(e?.offset||[0,0]);else{this._defaultMarker=!0,this._element=cm.create("div");let t=cm.createNS("http://www.w3.org/2000/svg","svg");t.setAttributeNS(null,"display","block"),t.setAttributeNS(null,"height","41px"),t.setAttributeNS(null,"width","27px"),t.setAttributeNS(null,"viewBox","0 0 27 41");let i=cm.createNS("http://www.w3.org/2000/svg","g");i.setAttributeNS(null,"stroke","none"),i.setAttributeNS(null,"stroke-width","1"),i.setAttributeNS(null,"fill","none"),i.setAttributeNS(null,"fill-rule","evenodd");let r=cm.createNS("http://www.w3.org/2000/svg","g");r.setAttributeNS(null,"fill-rule","nonzero");let a=cm.createNS("http://www.w3.org/2000/svg","g");a.setAttributeNS(null,"transform","translate(3.0, 29.0)"),a.setAttributeNS(null,"fill","#000000");for(let e of[{rx:"10.5",ry:"5.25002273"},{rx:"10.5",ry:"5.25002273"},{rx:"9.5",ry:"4.77275007"},{rx:"8.5",ry:"4.29549936"},{rx:"7.5",ry:"3.81822308"},{rx:"6.5",ry:"3.34094679"},{rx:"5.5",ry:"2.86367051"},{rx:"4.5",ry:"2.38636864"}]){let t=cm.createNS("http://www.w3.org/2000/svg","ellipse");t.setAttributeNS(null,"opacity","0.04"),t.setAttributeNS(null,"cx","10.5"),t.setAttributeNS(null,"cy","5.80029008"),t.setAttributeNS(null,"rx",e.rx),t.setAttributeNS(null,"ry",e.ry),a.appendChild(t)}let n=cm.createNS("http://www.w3.org/2000/svg","g");n.setAttributeNS(null,"fill",this._color);let s=cm.createNS("http://www.w3.org/2000/svg","path");s.setAttributeNS(null,"d","M27,13.5 C27,19.074644 20.250001,27.000002 14.75,34.500002 C14.016665,35.500004 12.983335,35.500004 12.25,34.500002 C6.7499993,27.000002 0,19.222562 0,13.5 C0,6.0441559 6.0441559,0 13.5,0 C20.955844,0 27,6.0441559 27,13.5 Z"),n.appendChild(s);let o=cm.createNS("http://www.w3.org/2000/svg","g");o.setAttributeNS(null,"opacity","0.25"),o.setAttributeNS(null,"fill","#000000");let l=cm.createNS("http://www.w3.org/2000/svg","path");l.setAttributeNS(null,"d","M13.5,0 C6.0441559,0 0,6.0441559 0,13.5 C0,19.222562 6.7499993,27 12.25,34.5 C13,35.522727 14.016664,35.500004 14.75,34.5 C20.250001,27 27,19.074644 27,13.5 C27,6.0441559 20.955844,0 13.5,0 Z M13.5,1 C20.415404,1 26,6.584596 26,13.5 C26,15.898657 24.495584,19.181431 22.220703,22.738281 C19.945823,26.295132 16.705119,30.142167 13.943359,33.908203 C13.743445,34.180814 13.612715,34.322738 13.5,34.441406 C13.387285,34.322738 13.256555,34.180814 13.056641,33.908203 C10.284481,30.127985 7.4148684,26.314159 5.015625,22.773438 C2.6163816,19.232715 1,15.953538 1,13.5 C1,6.584596 6.584596,1 13.5,1 Z"),o.appendChild(l);let h=cm.createNS("http://www.w3.org/2000/svg","g");h.setAttributeNS(null,"transform","translate(6.0, 7.0)"),h.setAttributeNS(null,"fill","#FFFFFF");let c=cm.createNS("http://www.w3.org/2000/svg","g");c.setAttributeNS(null,"transform","translate(8.0, 8.0)");let p=cm.createNS("http://www.w3.org/2000/svg","circle");p.setAttributeNS(null,"fill","#000000"),p.setAttributeNS(null,"opacity","0.25"),p.setAttributeNS(null,"cx","5.5"),p.setAttributeNS(null,"cy","5.5"),p.setAttributeNS(null,"r","5.4999962");let d=cm.createNS("http://www.w3.org/2000/svg","circle");d.setAttributeNS(null,"fill","#FFFFFF"),d.setAttributeNS(null,"cx","5.5"),d.setAttributeNS(null,"cy","5.5"),d.setAttributeNS(null,"r","5.4999962"),c.appendChild(p),c.appendChild(d),r.appendChild(a),r.appendChild(n),r.appendChild(o),r.appendChild(h),r.appendChild(c),t.appendChild(r),t.setAttributeNS(null,"height",41*this._scale+"px"),t.setAttributeNS(null,"width",27*this._scale+"px"),this._element.appendChild(t),this._offset=u.convert(e?.offset||[0,-14])}if(this._element.classList.add("maplibregl-marker"),this._element.addEventListener("dragstart",e=>{e.preventDefault()}),this._element.addEventListener("mousedown",e=>{e.preventDefault()}),Lw(this._element,this._anchor,"marker"),e?.className)for(let t of e.className.split(" "))this._element.classList.add(t);this._popup=null}addTo(e){return this.remove(),this._map=e,this._defaultMarker&&!this._element.hasAttribute("aria-label")&&this._element.setAttribute("aria-label",e._getUIString("Marker.Title")),this._updateAccessibilityRole(),e.getCanvasContainer().appendChild(this._element),e.on("move",this._update),e.on("moveend",this._update),e.on("terrain",this._update),e.on("projectiontransition",this._update),this._element.addEventListener("click",this._onClick),this.setDraggable(this._draggable),this._update(),this._map.on("click",this._onMapClick),this}remove(){return this._opacityTimeout&&(clearTimeout(this._opacityTimeout),delete this._opacityTimeout),this._map&&(this._map.off("click",this._onMapClick),this._map.off("move",this._update),this._map.off("moveend",this._update),this._map.off("terrain",this._update),this._map.off("projectiontransition",this._update),this._map.off("mousedown",this._addDragHandler),this._map.off("touchstart",this._addDragHandler),this._map.off("mouseup",this._onUp),this._map.off("touchend",this._onUp),this._map.off("mousemove",this._onMove),this._map.off("touchmove",this._onMove),delete this._map),this._element.removeEventListener("click",this._onClick),this._element.removeEventListener("keydown",this._onKeyDown),this._element.removeEventListener("keyup",this._onKeyUp),this._element.removeEventListener("blur",this._onBlur),this._element.removeEventListener("keypress",this._onKeyPress),this._keyboardDragActive=!1,this._element.remove(),this._popup&&this._popup.remove(),this}getLngLat(){return this._lngLat}setLngLat(e){return this._lngLat=Xu.convert(e),this._pos=null,this._popup&&this._popup.setLngLat(this._lngLat),this._update(),this}getElement(){return this._element}setPopup(e){if(this._popup&&(this._popup.remove(),this._popup=null,this._element.removeEventListener("keypress",this._onKeyPress)),e){if(!("offset"in e.options)){let t=13.5/Math.SQRT2;e.options.offset=this._defaultMarker?{top:[0,0],"top-left":[0,0],"top-right":[0,0],bottom:[0,-38.1],"bottom-left":[t,-1*(24.6+t)],"bottom-right":[-t,-1*(24.6+t)],left:[13.5,-24.6],right:[-13.5,-24.6]}:this._offset}this._popup=e,this._element.addEventListener("keypress",this._onKeyPress)}return this._updateTabIndex(),this._updateAccessibilityRole(),this}setSubpixelPositioning(e){return this._subpixelPositioning=e,this}_endKeyboardDrag(){this._keyboardDragActive&&(this._keyboardDragActive=!1,this.fire(new Bw("dragend")))}getPopup(){return this._popup}togglePopup(){let e=this._popup;return this._element.style.opacity===this._opacityWhenCovered?this:e?(e.isOpen()?e.remove():(e.setLngLat(this._lngLat),e.addTo(this._map)),this):this}_updateOpacity(e=!1){let t=this._map?.terrain,i=this._map._camera.transform.isLocationOccluded(this._lngLat);if(!t||i){let e=i?this._opacityWhenCovered:this._opacity;return void(this._element.style.opacity!==e&&(this._element.style.opacity=e,this._element.classList.toggle("maplibregl-marker-covered",i)))}if(e)this._opacityTimeout=null;else{if(this._opacityTimeout)return;this._opacityTimeout=setTimeout(()=>{this._opacityTimeout=null},100)}let r=this._map,a=r.terrain.depthAtPoint(this._pos),n=r.terrain.getElevationForLngLat(this._lngLat,r._camera.transform);if(r._camera.transform.lngLatToCameraDepth(this._lngLat,n)-a<.006)return this._element.style.opacity=this._opacity,void this._element.classList.remove("maplibregl-marker-covered");let s=-this._offset.y/r._camera.transform.pixelsPerMeter,o=Math.sin(r.getPitch()*Math.PI/180)*s,l=r.terrain.depthAtPoint(new u(this._pos.x,this._pos.y-this._offset.y)),h=r._camera.transform.lngLatToCameraDepth(this._lngLat,n+o)-l>.006;this._popup?.isOpen()&&h&&this._popup.remove(),this._element.style.opacity=h?this._opacityWhenCovered:this._opacity,this._element.classList.toggle("maplibregl-marker-covered",h)}getOffset(){return this._offset}setOffset(e){return this._offset=u.convert(e),this._update(),this}addClassName(e){this._element.classList.add(e)}removeClassName(e){this._element.classList.remove(e)}toggleClassName(e){return this._element.classList.toggle(e)}setDraggable(e){return this._draggable=!!e,this._element.classList.toggle("maplibregl-marker-draggable",this._draggable),this._map&&(e?(this._map.on("mousedown",this._addDragHandler),this._map.on("touchstart",this._addDragHandler)):(this._map.off("mousedown",this._addDragHandler),this._map.off("touchstart",this._addDragHandler))),this._defaultMarker&&(this._draggable?(this._element.addEventListener("keydown",this._onKeyDown),this._element.addEventListener("keyup",this._onKeyUp),this._element.addEventListener("blur",this._onBlur)):(this._element.removeEventListener("keydown",this._onKeyDown),this._element.removeEventListener("keyup",this._onKeyUp),this._element.removeEventListener("blur",this._onBlur),this._endKeyboardDrag())),this._updateTabIndex(),this._updateAccessibilityRole(),this}isDraggable(){return this._draggable}_updateTabIndex(){this._popup||this._defaultMarker&&this._draggable?this._element.hasAttribute("tabindex")||(this._element.setAttribute("tabindex","0"),this._tabIndexManaged=!0):this._tabIndexManaged&&=("0"===this._element.getAttribute("tabindex")&&this._element.removeAttribute("tabindex"),!1)}_updateAccessibilityRole(){if(!this._defaultMarker||this._element.hasAttribute("role")&&!this._roleManaged)return;let e=this._draggable||this._popup?"button":"img";this._element.setAttribute("role",e),this._roleManaged=!0}setRotation(e){return this._rotation=e||0,this._update(),this}getRotation(){return this._rotation}setRotationAlignment(e){return this._rotationAlignment=e||"auto",this._update(),this}getRotationAlignment(){return this._rotationAlignment}setPitchAlignment(e){return this._pitchAlignment=e&&"auto"!==e?e:this._rotationAlignment,this._update(),this}getPitchAlignment(){return this._pitchAlignment}setOpacity(e,t){return(void 0===this._opacity||void 0===e&&void 0===t)&&(this._opacity="1",this._opacityWhenCovered="0.2"),void 0!==e&&(this._opacity=String(e)),void 0!==t&&(this._opacityWhenCovered=String(t)),this._map&&this._updateOpacity(!0),this}},jw={positionOptions:{enableHighAccuracy:!1,maximumAge:0,timeout:6e3},fitBoundsOptions:{maxZoom:15},trackUserLocation:!1,showAccuracyCircle:!0,showUserLocation:!0},Nw=0,Uw=!1,Gw=class extends ft{},$w=class extends ft{},Zw=class extends ft{},qw=class extends _t{constructor(e){super(),this._onSuccess=e=>{if(this._map){if(this._isOutOfMapMaxBounds(e))return this._setErrorState(),this.fire(new $w("outofmaxbounds",e)),this._updateMarker(),void this._finish();if(this.options.trackUserLocation)switch(this._lastKnownPosition=e,this._watchState){case"WAITING_ACTIVE":case"ACTIVE_LOCK":case"ACTIVE_ERROR":this._watchState="ACTIVE_LOCK",this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-waiting"),this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-active-error"),this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-active");break;case"BACKGROUND":case"BACKGROUND_ERROR":this._watchState="BACKGROUND",this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-waiting"),this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-background-error"),this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-background");break;default:throw Error(`Unexpected watchState ${this._watchState}`)}this.options.showUserLocation&&"OFF"!==this._watchState&&this._updateMarker(e),(!this.options.trackUserLocation||"ACTIVE_LOCK"===this._watchState)&&this._updateCamera(e),this.options.showUserLocation&&this._dotElement.classList.remove("maplibregl-user-location-dot-stale"),this.fire(new $w("geolocate",e)),this._finish()}},this._updateCamera=e=>{let t=new Xu(e.coords.longitude,e.coords.latitude),i=e.coords.accuracy,r=be({bearing:this._map.getBearing()},this.options.fitBoundsOptions),a=s_.fromLngLat(t,i);this._map.fitBounds(a,r,{geolocateSource:!0})},this._updateMarker=e=>{if(e){let t=new Xu(e.coords.longitude,e.coords.latitude);this._accuracyCircleMarker.setLngLat(t).addTo(this._map),this._userLocationDotMarker.setLngLat(t).addTo(this._map),this._accuracy=e.coords.accuracy,this._updateCircleRadiusIfNeeded()}else this._userLocationDotMarker.remove(),this._accuracyCircleMarker.remove()},this._onUpdate=()=>{this._updateCircleRadiusIfNeeded()},this._onError=e=>{if(this._map){if(1===e.code){this._watchState="OFF",this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-waiting"),this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-active"),this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-active-error"),this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-background"),this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-background-error"),this._geolocateButton.disabled=!0;let e=this._map._getUIString("GeolocateControl.LocationNotAvailable");this._geolocateButton.title=e,this._geolocateButton.setAttribute("aria-label",e),void 0!==this._geolocationWatchID&&this._clearWatch()}else{if(3===e.code&&Uw)return;this._setErrorState()}"OFF"!==this._watchState&&this.options.showUserLocation&&this._dotElement.classList.add("maplibregl-user-location-dot-stale"),this.fire(new Zw("error",e)),this._finish()}},this._finish=()=>{this._timeoutId&&clearTimeout(this._timeoutId),this._timeoutId=void 0},this._onMoveStart=e=>{if(!this._map)return;let t=e?.[0]instanceof ResizeObserverEntry;!e.geolocateSource&&"ACTIVE_LOCK"===this._watchState&&!t&&!this._map.isZooming()&&(this._watchState="BACKGROUND",this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-background"),this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-active"),this.fire(new Gw("trackuserlocationend")),this.fire(new Gw("userlocationlostfocus")))},this._setupUI=()=>{this._map&&(this._container.addEventListener("contextmenu",e=>{e.preventDefault()}),this._geolocateButton=cm.create("button","maplibregl-ctrl-geolocate",this._container),cm.create("span","maplibregl-ctrl-icon",this._geolocateButton).setAttribute("aria-hidden","true"),this._geolocateButton.type="button",this._geolocateButton.disabled=!0)},this._finishSetupUI=e=>{if(this._map){if(!1===e){Re("Geolocation support is not available so the GeolocateControl will be disabled.");let e=this._map._getUIString("GeolocateControl.LocationNotAvailable");this._geolocateButton.disabled=!0,this._geolocateButton.title=e,this._geolocateButton.setAttribute("aria-label",e)}else{let e=this._map._getUIString("GeolocateControl.FindMyLocation");this._geolocateButton.disabled=!1,this._geolocateButton.title=e,this._geolocateButton.setAttribute("aria-label",e)}this.options.trackUserLocation&&(this._geolocateButton.setAttribute("aria-pressed","false"),this._watchState="OFF"),this.options.showUserLocation&&(this._dotElement=cm.create("div","maplibregl-user-location-dot"),this._userLocationDotMarker=new Vw({element:this._dotElement}),this._circleElement=cm.create("div","maplibregl-user-location-accuracy-circle"),this._accuracyCircleMarker=new Vw({element:this._circleElement,pitchAlignment:"map"}),this.options.trackUserLocation&&(this._watchState="OFF"),this._map.on("zoom",this._onUpdate),this._map.on("move",this._onUpdate),this._map.on("rotate",this._onUpdate),this._map.on("pitch",this._onUpdate)),this._geolocateButton.addEventListener("click",()=>this.trigger()),this._setup=!0,this.options.trackUserLocation&&this._map.on("movestart",this._onMoveStart)}},this.options=be({},jw,e)}onAdd(e){return this._map=e,this._container=cm.create("div","maplibregl-ctrl maplibregl-ctrl-group"),this._setupUI(),async function(e=!1){if(void 0!==fw&&!e)return fw;if(void 0===window.navigator.permissions)return fw=!!window.navigator.geolocation;try{fw="denied"!==(await window.navigator.permissions.query({name:"geolocation"})).state}catch{fw=!!window.navigator.geolocation}return fw}().then(e=>this._finishSetupUI(e)),this._container}onRemove(){void 0!==this._geolocationWatchID&&(window.navigator.geolocation.clearWatch(this._geolocationWatchID),this._geolocationWatchID=void 0),this.options.showUserLocation&&this._userLocationDotMarker&&this._userLocationDotMarker.remove(),this.options.showAccuracyCircle&&this._accuracyCircleMarker&&this._accuracyCircleMarker.remove(),this._container.remove(),this._map.off("movestart",this._onMoveStart),this._map.off("zoom",this._onUpdate),this._map.off("move",this._onUpdate),this._map.off("rotate",this._onUpdate),this._map.off("pitch",this._onUpdate),this._map=void 0,Nw=0,Uw=!1}_isOutOfMapMaxBounds(e){let t=this._map.getMaxBounds(),i=e.coords;return t&&(i.longitude<t.getWest()||i.longitude>t.getEast()||i.latitude<t.getSouth()||i.latitude>t.getNorth())}_setErrorState(){switch(this._watchState){case"WAITING_ACTIVE":this._watchState="ACTIVE_ERROR",this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-active"),this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-active-error");break;case"ACTIVE_LOCK":this._watchState="ACTIVE_ERROR",this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-active"),this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-active-error"),this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-waiting");break;case"BACKGROUND":this._watchState="BACKGROUND_ERROR",this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-background"),this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-background-error"),this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-waiting");break;case"ACTIVE_ERROR":case"BACKGROUND_ERROR":case"OFF":case void 0:break;default:throw Error(`Unexpected watchState ${this._watchState}`)}}_updateCircleRadiusIfNeeded(){let e=this._userLocationDotMarker.getLngLat();if(!(this.options.showUserLocation&&this.options.showAccuracyCircle&&this._accuracy&&e))return;let t=this._map.project(e),i=this._map.unproject([t.x+100,t.y]),r=e.distanceTo(i)/100,a=2*this._accuracy/r;this._circleElement.style.width=`${a.toFixed(2)}px`,this._circleElement.style.height=`${a.toFixed(2)}px`}trigger(){if(!this._setup)return Re("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 Gw("trackuserlocationstart"));break;case"WAITING_ACTIVE":case"ACTIVE_LOCK":case"ACTIVE_ERROR":case"BACKGROUND_ERROR":Nw--,Uw=!1,this._watchState="OFF",this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-waiting"),this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-active"),this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-active-error"),this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-background"),this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-background-error"),this.fire(new Gw("trackuserlocationend"));break;case"BACKGROUND":this._watchState="ACTIVE_LOCK",this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-background"),this._lastKnownPosition&&this._updateCamera(this._lastKnownPosition),this.fire(new Gw("trackuserlocationstart")),this.fire(new Gw("userlocationfocus"));break;default:throw Error(`Unexpected watchState ${this._watchState}`)}switch(this._watchState){case"WAITING_ACTIVE":this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-waiting"),this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-active");break;case"ACTIVE_LOCK":this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-active");break;case"OFF":break;default:throw Error(`Unexpected watchState ${this._watchState}`)}if("OFF"===this._watchState&&void 0!==this._geolocationWatchID)this._clearWatch();else if(void 0===this._geolocationWatchID){let e;this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-waiting"),this._geolocateButton.setAttribute("aria-pressed","true"),++Nw>1?(e={maximumAge:6e5,timeout:0},Uw=!0):(e=this.options.positionOptions,Uw=!1),this._geolocationWatchID=window.navigator.geolocation.watchPosition(this._onSuccess,this._onError,e)}}else window.navigator.geolocation.getCurrentPosition(this._onSuccess,this._onError,this.options.positionOptions),this._timeoutId=setTimeout(this._finish,1e4);return!0}_clearWatch(){window.navigator.geolocation.clearWatch(this._geolocationWatchID),this._geolocationWatchID=void 0,this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-waiting"),this._geolocateButton.setAttribute("aria-pressed","false"),this.options.showUserLocation&&this._updateMarker(null)}},Ww={maxWidth:100,unit:"metric"},Hw=class{constructor(e){this._onMove=()=>{Xw(this._map,this._container,this.options)},this.setUnit=e=>{this.options.unit=e,Xw(this._map,this._container,this.options)},this.options={...Ww,...e}}getDefaultPosition(){return"bottom-left"}onAdd(e){return this._map=e,this._container=cm.create("div","maplibregl-ctrl maplibregl-ctrl-scale",e.getContainer()),this._map.on("move",this._onMove),this._onMove(),this._container}onRemove(){this._container.remove(),this._map.off("move",this._onMove),this._map=void 0}};function Xw(e,t,i){let r=i?.maxWidth||100,a=e._container.clientHeight/2,n=e._container.clientWidth/2,s=e.unproject([n-r/2,a]),o=e.unproject([n+r/2,a]),l=Math.round(e.project(o).x-e.project(s).x),h=Math.min(r,l,e._container.clientWidth),u=s.distanceTo(o);if("imperial"===i?.unit){let i=3.2808*u;i>5280?Yw(t,h,i/5280,e._getUIString("ScaleControl.Miles")):Yw(t,h,i,e._getUIString("ScaleControl.Feet"))}else"nautical"===i?.unit?Yw(t,h,u/1852,e._getUIString("ScaleControl.NauticalMiles")):u>=1e3?Yw(t,h,u/1e3,e._getUIString("ScaleControl.Kilometers")):Yw(t,h,u,e._getUIString("ScaleControl.Meters"))}function Yw(e,t,i,r){let a=function(e){let t=10**(`${Math.floor(e)}`.length-1),i=e/t;return i=i>=10?10:i>=5?5:i>=3?3:i>=2?2:i>=1?1:function(e){let t=10**Math.ceil(-Math.log(e)/Math.LN10);return Math.round(e*t)/t}(i),t*i}(i),n=a/i;e.style.width=t*n+"px",e.innerHTML=`${a} ${r}`}var Kw=class extends ft{},Jw=class extends _t{constructor(e={}){super(),this._onFullscreenChange=()=>{let e=window.document.fullscreenElement||window.document.webkitFullscreenElement;for(;e?.shadowRoot?.fullscreenElement;)e=e.shadowRoot.fullscreenElement;e===this._container!==this._fullscreen&&this._handleFullscreenChange()},this._onClickFullscreen=()=>{this._isFullscreen()?this._exitFullscreen():this._requestFullscreen()},this._fullscreen=!1,this._pseudo=e.pseudo??!1,e?.container&&(e.container instanceof HTMLElement?this._container=e.container:Re("Full screen control 'container' must be a DOM element.")),"onfullscreenchange"in document?this._fullscreenchange="fullscreenchange":"onmozfullscreenchange"in document?this._fullscreenchange="mozfullscreenchange":"onwebkitfullscreenchange"in document?this._fullscreenchange="webkitfullscreenchange":"onmsfullscreenchange"in document&&(this._fullscreenchange="MSFullscreenChange")}onAdd(e){return this._map=e,this._container||=this._map.getContainer(),this._controlContainer=cm.create("div","maplibregl-ctrl maplibregl-ctrl-group"),this._setupUI(),this._controlContainer}onRemove(){this._controlContainer.remove(),this._map=null,window.document.removeEventListener(this._fullscreenchange,this._onFullscreenChange)}_setupUI(){let e=this._fullscreenButton=cm.create("button","maplibregl-ctrl-fullscreen",this._controlContainer);cm.create("span","maplibregl-ctrl-icon",e).setAttribute("aria-hidden","true"),e.type="button",this._updateTitle(),this._fullscreenButton.addEventListener("click",this._onClickFullscreen),window.document.addEventListener(this._fullscreenchange,this._onFullscreenChange)}_updateTitle(){let e=this._getTitle();this._fullscreenButton.setAttribute("aria-label",e),this._fullscreenButton.title=e}_getTitle(){return this._map._getUIString(this._isFullscreen()?"FullscreenControl.Exit":"FullscreenControl.Enter")}_isFullscreen(){return this._fullscreen}_handleFullscreenChange(){this._fullscreen=!this._fullscreen,this._fullscreenButton.classList.toggle("maplibregl-ctrl-shrink"),this._fullscreenButton.classList.toggle("maplibregl-ctrl-fullscreen"),this._updateTitle(),this._fullscreen?(this.fire(new Kw("fullscreenstart")),this._prevCooperativeGesturesEnabled=this._map.cooperativeGestures.isEnabled(),this._map.cooperativeGestures.disable()):(this.fire(new Kw("fullscreenend")),this._prevCooperativeGesturesEnabled&&this._map.cooperativeGestures.enable())}_exitFullscreen(){this._pseudo?this._togglePseudoFullScreen():window.document.exitFullscreen?window.document.exitFullscreen():window.document.webkitCancelFullScreen?window.document.webkitCancelFullScreen():this._togglePseudoFullScreen()}_requestFullscreen(){this._pseudo?this._togglePseudoFullScreen():this._container.requestFullscreen?this._container.requestFullscreen():this._container.webkitRequestFullscreen?this._container.webkitRequestFullscreen():this._togglePseudoFullScreen()}_togglePseudoFullScreen(){this._container.classList.toggle("maplibregl-pseudo-fullscreen"),this._handleFullscreenChange(),this._map.resize()}},Qw=class{constructor(e){this._toggleTerrain=()=>{this._map.getTerrain()?this._map.setTerrain(null):this._map.setTerrain(this.options),this._updateTerrainIcon()},this._updateTerrainIcon=()=>{this._terrainButton.classList.remove("maplibregl-ctrl-terrain"),this._terrainButton.classList.remove("maplibregl-ctrl-terrain-enabled"),this._map.terrain?(this._terrainButton.classList.add("maplibregl-ctrl-terrain-enabled"),this._terrainButton.title=this._map._getUIString("TerrainControl.Disable")):(this._terrainButton.classList.add("maplibregl-ctrl-terrain"),this._terrainButton.title=this._map._getUIString("TerrainControl.Enable"))},this.options=e}onAdd(e){return this._map=e,this._container=cm.create("div","maplibregl-ctrl maplibregl-ctrl-group"),this._terrainButton=cm.create("button","maplibregl-ctrl-terrain",this._container),cm.create("span","maplibregl-ctrl-icon",this._terrainButton).setAttribute("aria-hidden","true"),this._terrainButton.type="button",this._terrainButton.addEventListener("click",this._toggleTerrain),this._updateTerrainIcon(),this._map.on("terrain",this._updateTerrainIcon),this._container}onRemove(){this._container.remove(),this._map.off("terrain",this._updateTerrainIcon),this._map=void 0}},eT=class{constructor(){this._toggleProjection=()=>{let e=this._map.getProjection()?.type;"mercator"!==e&&e?this._map.setProjection({type:"mercator"}):this._map.setProjection({type:"globe"}),this._updateGlobeIcon()},this._updateGlobeIcon=()=>{this._globeButton.classList.remove("maplibregl-ctrl-globe"),this._globeButton.classList.remove("maplibregl-ctrl-globe-enabled"),"globe"===this._map.getProjection()?.type?(this._globeButton.classList.add("maplibregl-ctrl-globe-enabled"),this._globeButton.title=this._map._getUIString("GlobeControl.Disable")):(this._globeButton.classList.add("maplibregl-ctrl-globe"),this._globeButton.title=this._map._getUIString("GlobeControl.Enable"))}}onAdd(e){return this._map=e,this._container=cm.create("div","maplibregl-ctrl maplibregl-ctrl-group"),this._globeButton=cm.create("button","maplibregl-ctrl-globe",this._container),cm.create("span","maplibregl-ctrl-icon",this._globeButton).setAttribute("aria-hidden","true"),this._globeButton.type="button",this._globeButton.addEventListener("click",this._toggleProjection),this._updateGlobeIcon(),this._map.on("styledata",this._updateGlobeIcon),this._map.on("projectiontransition",this._updateGlobeIcon),this._container}onRemove(){this._container.remove(),this._map.off("styledata",this._updateGlobeIcon),this._map.off("projectiontransition",this._updateGlobeIcon),this._globeButton.removeEventListener("click",this._toggleProjection),this._map=void 0}},tT={closeButton:!0,closeOnClick:!0,focusAfterOpen:!0,className:"",maxWidth:"240px",subpixelPositioning:!1,locationOccludedOpacity:void 0,padding:void 0},iT=["a[href]","[tabindex]:not([tabindex='-1'])","[contenteditable]:not([contenteditable='false'])","button:not([disabled])","input:not([disabled])","select:not([disabled])","textarea:not([disabled])"].join(", "),rT=class extends ft{},aT=class extends _t{constructor(e){super(),this._updateOpacity=()=>{void 0!==this.options.locationOccludedOpacity&&(this._map._camera.transform.isLocationOccluded(this.getLngLat())?this._container.style.opacity=`${this.options.locationOccludedOpacity}`:this._container.style.opacity="")},this.remove=()=>(this._content&&this._content.remove(),this._container&&(this._container.remove(),delete this._container),this._map&&(this._map.off("move",this._update),this._map.off("move",this._onClose),this._map.off("click",this._onClose),this._map.off("remove",this.remove),this._map.off("terrain",this._update),this._map.off("projectiontransition",this._update),this._map.off("mousemove",this._update),this._map.off("mouseup",this._update),this._map.off("drag",this._update),this._map._canvasContainer.classList.remove("maplibregl-track-pointer"),delete this._map,this.fire(new rT("close"))),this),this._update=e=>{let t,i=this._lngLat||this._trackPointer;if(!this._map||!i||!this._content)return;if(!this._container){if(this._container=cm.create("div","maplibregl-popup",this._map.getContainer()),this._tip=cm.create("div","maplibregl-popup-tip",this._container),this._container.appendChild(this._content),this.options.className)for(let e of this.options.className.split(" "))this._container.classList.add(e);this._closeButton&&this._closeButton.setAttribute("aria-label",this._map._getUIString("Popup.Close")),this._trackPointer&&this._container.classList.add("maplibregl-popup-track-pointer")}if(this.options.maxWidth&&this._container.style.maxWidth!==this.options.maxWidth&&(this._container.style.maxWidth=this.options.maxWidth),this._lngLat=Rw(this._lngLat,this._flatPos,this._map._camera.transform,this._trackPointer),e&&"point"in e&&e.point&&(t=e.point),this._trackPointer&&!t)return;let r=this._flatPos=this._pos=this._trackPointer&&t?t:this._map.project(this._lngLat);this._map.terrain&&(this._flatPos=this._trackPointer&&t?t:this._map._camera.transform.locationToScreenPoint(this._lngLat));let a=this.options.anchor,n=nT(this.options.offset);if(!a){let e,t=this._container.offsetWidth,i=this._container.offsetHeight,s=function(e){return e?{top:e.top??0,right:e.right??0,bottom:e.bottom??0,left:e.left??0}:{top:0,right:0,bottom:0,left:0}}(this.options.padding);e=r.y+n.bottom.y<i+s.top?["top"]:r.y>this._map._camera.transform.height-i-s.bottom?["bottom"]:[],r.x<t/2+s.left?e.push("left"):r.x>this._map._camera.transform.width-t/2-s.right&&e.push("right"),a=0===e.length?"bottom":e.join("-")}let s=r.add(n[a]);this.options.subpixelPositioning||(s=s.round()),this._container.style.transform=`${kw[a]} translate(${s.x}px,${s.y}px)`,Lw(this._container,a,"popup"),this._updateOpacity()},this._onClose=()=>{this.remove()},this.options=be(Object.create(tT),e)}addTo(e){return this._map&&this.remove(),this._map=e,this.options.closeOnClick&&this._map.on("click",this._onClose),this.options.closeOnMove&&this._map.on("move",this._onClose),this._map.on("remove",this.remove),this._map.on("terrain",this._update),this._map.on("projectiontransition",this._update),this._update(),this._focusFirstElement(),this._trackPointer?(this._map.on("mousemove",this._update),this._map.on("mouseup",this._update),this._container&&this._container.classList.add("maplibregl-popup-track-pointer"),this._map._canvasContainer.classList.add("maplibregl-track-pointer")):this._map.on("move",this._update),this.fire(new rT("open")),this}isOpen(){return!!this._map}getLngLat(){return this._lngLat}setLngLat(e){return this._lngLat=Xu.convert(e),this._pos=null,this._flatPos=null,this._trackPointer=!1,this._update(),this._map&&(this._map.on("move",this._update),this._map.off("mousemove",this._update),this._container&&this._container.classList.remove("maplibregl-popup-track-pointer"),this._map._canvasContainer.classList.remove("maplibregl-track-pointer")),this}trackPointer(){return this._trackPointer=!0,this._pos=null,this._flatPos=null,this._update(),this._map&&(this._map.off("move",this._update),this._map.on("mousemove",this._update),this._map.on("drag",this._update),this._container&&this._container.classList.add("maplibregl-popup-track-pointer"),this._map._canvasContainer.classList.add("maplibregl-track-pointer")),this}getElement(){return this._container}setText(e){return this.setDOMContent(document.createTextNode(e))}setHTML(e){let t,i=document.createDocumentFragment(),r=document.createElement("body");for(r.innerHTML=e;t=r.firstChild,t;)i.appendChild(t);return this.setDOMContent(i)}getMaxWidth(){return this._container?.style.maxWidth}setMaxWidth(e){return this.options.maxWidth=e,this._update(),this}setDOMContent(e){if(this._content)for(;this._content.hasChildNodes();)this._content.firstChild&&this._content.removeChild(this._content.firstChild);else this._content=cm.create("div","maplibregl-popup-content",this._container);return this._content.appendChild(e),this._createCloseButton(),this._update(),this._focusFirstElement(),this}addClassName(e){return this._container&&this._container.classList.add(e),this}removeClassName(e){return this._container&&this._container.classList.remove(e),this}setOffset(e){return this.options.offset=e,this._update(),this}toggleClassName(e){if(this._container)return this._container.classList.toggle(e)}setSubpixelPositioning(e){this.options.subpixelPositioning=e}setPadding(e){this.options.padding=e,this._update()}_createCloseButton(){this.options.closeButton&&(this._closeButton=cm.create("button","maplibregl-popup-close-button",this._content),this._closeButton.type="button",this._closeButton.innerHTML="×",this._closeButton.addEventListener("click",this._onClose))}_focusFirstElement(){if(!this.options.focusAfterOpen||!this._container)return;let e=this._container.querySelector(iT);e&&e.focus()}};function nT(e){if(!e)return nT(new u(0,0));if("number"==typeof e){let t=Math.round(Math.abs(e)/Math.SQRT2);return{center:new u(0,0),top:new u(0,e),"top-left":new u(t,t),"top-right":new u(-t,t),bottom:new u(0,-e),"bottom-left":new u(t,-t),"bottom-right":new u(-t,-t),left:new u(e,0),right:new u(-e,0)}}if(e instanceof u||Array.isArray(e)){let t=u.convert(e);return{center:t,top:t,"top-left":t,"top-right":t,bottom:t,"bottom-left":t,"bottom-right":t,left:t,right:t}}return{center:u.convert(e.center||[0,0]),top:u.convert(e.top||[0,0]),"top-left":u.convert(e["top-left"]||[0,0]),"top-right":u.convert(e["top-right"]||[0,0]),bottom:u.convert(e.bottom||[0,0]),"bottom-left":u.convert(e["bottom-left"]||[0,0]),"bottom-right":u.convert(e["bottom-right"]||[0,0]),left:u.convert(e.left||[0,0]),right:u.convert(e.right||[0,0])}}var sT=im;function oT(e,t){return k_().setRTLTextPlugin(e,t)}function lT(){return k_().getRTLTextPluginStatus()}function hT(){return sT}function uT(){return Wm.workerCount}function cT(e){Wm.workerCount=e}function pT(){return it.MAX_PARALLEL_IMAGE_REQUESTS}function dT(e){it.MAX_PARALLEL_IMAGE_REQUESTS=e}function fT(){return it.WORKER_URL}function mT(e){it.WORKER_URL=e}async function _T(e){await e_().broadcast("IS",e)}export{ot as AJAXError,yw as AttributionControl,Db as BoxZoomHandler,M_ as CanvasSource,hw as CooperativeGesturesHandler,rw as DoubleClickZoomHandler,sw as DragPanHandler,ow as DragRotateHandler,J as EXTENT,ly as EdgeInsets,mt as ErrorEvent,ft as Event,_t as Evented,Jw as FullscreenControl,Kw as FullscreenEvent,gb as GPUInitializationError,y_ as GeoJSONSource,qw as GeolocateControl,Zw as GeolocateErrorEvent,Gw as GeolocateEvent,$w as GeolocatePositionEvent,eT as GlobeControl,vb as Hash,S_ as ImageSource,Qb as KeyboardHandler,Xu as LngLat,s_ as LngLatBounds,vw as LogoControl,Aw as Map,Aw as MapLibreMap,bm as MapBoxZoomEvent,Sm as MapContextEvent,dm as MapLibreEvent,ym as MapMouseEvent,fm as MapMovementEvent,Tm as MapProjectionEvent,gm as MapSourceDataEvent,_m as MapStyleDataEvent,Pm as MapStyleImageMissingEvent,mm as MapStyleLoadEvent,wm as MapTerrainEvent,vm as MapTouchEvent,xm as MapWheelEvent,Vw as Marker,Ow as MarkerClickEvent,Bw as MarkerDragEvent,ac as MercatorCoordinate,Dw as NavigationControl,u as Point,aT as Popup,rT as PopupEvent,u_ as RasterDEMTileSource,h_ as RasterTileSource,Hw as ScaleControl,iw as ScrollZoomHandler,Wy as Style,Qw as TerrainControl,Kb as TwoFingersTouchPitchHandler,Xb as TwoFingersTouchRotateHandler,Wb as TwoFingersTouchZoomHandler,lw as TwoFingersTouchZoomRotateHandler,l_ as VectorTileSource,I_ as VideoSource,at as addProtocol,C_ as addSourceType,Km as clearPrewarmedResources,it as config,by as createTileMesh,e_ as getGlobalDispatcher,pT as getMaxParallelImageRequests,lT as getRTLTextPluginStatus,hT as getVersion,uT as getWorkerCount,fT as getWorkerUrl,_T as importScriptInWorkers,hm as isTimeFrozen,sm as now,Ym as prewarm,nt as removeProtocol,lm as restoreNow,dT as setMaxParallelImageRequests,om as setNow,oT as setRTLTextPlugin,cT as setWorkerCount,mT as setWorkerUrl};
|