@qratilabs/qrati-connect 2.32.2 → 2.33.1
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/{DiQrTagI2.js → 73mz8Fz4.js} +1 -1
- package/element/B60TJHpn.js +1 -0
- package/element/BC9KIhak.js +2 -0
- package/element/BCE50OwS.js +93 -0
- package/element/{CmcA5dp5.js → BFC2aU2J.js} +32 -32
- package/element/{BOsbbHJ0.js → BSGK1Ri1.js} +3 -3
- package/element/{DO2-BnvU.js → Bb_tv1V-.js} +3 -2
- package/element/BiNwD6VL.js +4 -0
- package/element/{DUS9pix12.js → BiZqzQNR.js} +1 -1
- package/element/BlsbPO0-.js +1 -0
- package/element/{CaTxtEbg.js → BlwHCgeI.js} +1 -1
- package/element/{BeaTNG7m.js → BxxWXMGe.js} +1 -1
- package/element/CTTFfh11.js +4 -0
- package/element/{DtBnBN-i.js → CW7Iwd96.js} +1 -1
- package/element/{XVFdeOm22.js → CX1SNDQH.js} +1 -1
- package/element/CYHy0vN3.js +1 -0
- package/element/CZJLtvF9.js +4 -0
- package/element/CeJICm77.js +5 -0
- package/element/CmtEFeGF.js +5 -0
- package/element/{BZSy_Rh42.js → CnxxYHOX.js} +18 -18
- package/element/Cs6qJQxX.js +8 -0
- package/element/{CE0UwtGX.js → Cx6rq6N5.js} +7 -7
- package/element/{DFRMtMLz.js → Czk6IR70.js} +1 -1
- package/element/{DRD9__VZ.js → D1TFBkCS.js} +1 -1
- package/element/{BOweSM9Y.js → DA0XxXKx.js} +1 -1
- package/element/{CDBzc1CZ.js → DB6HdxlA.js} +1 -1
- package/element/{GwDdmgYd.js → DHBHbWIA.js} +1 -1
- package/element/DKRKwBRc.js +8 -0
- package/element/DMPvw0Jw.js +3 -0
- package/element/DV8JHO97.js +16 -0
- package/element/DVDZfY1d.js +4 -0
- package/element/{DdQWa3ny.js → DdLLa5wm.js} +1 -1
- package/element/DjHszKev.js +14 -0
- package/element/{DjOFnmwA.js → DmaTYIJu.js} +1 -1
- package/element/{D-U23_J5.js → Dr2e01jA.js} +36 -36
- package/element/DuVfaq4G.js +3 -0
- package/element/Dubduzq7.js +2 -0
- package/element/DwhpFWNq.js +3 -0
- package/element/FE0pIRqe.js +207 -0
- package/element/{iDDlbtVI.js → HkakucIO.js} +1 -1
- package/element/{CoARa5_i.js → V6RGWsa9.js} +1 -1
- package/element/XIzy_5YD.js +1 -0
- package/element/hjsqLu1P.js +85 -0
- package/element/web.es.js +1 -1
- package/embed/embed.js +1 -1
- package/package.json +1 -1
- package/element/3CNVs83G2.js +0 -4
- package/element/B2ryYFFr.js +0 -4
- package/element/BNHdfdME.js +0 -1
- package/element/BP08t9Jp2.js +0 -8
- package/element/BRwZXuo82.js +0 -3
- package/element/BiCaKAmb.js +0 -4
- package/element/Bv4TkNQ42.js +0 -85
- package/element/BypLxR3J.js +0 -16
- package/element/C7zv6hcG.js +0 -1
- package/element/CD73UkPZ.js +0 -2
- package/element/CGlyix6P.js +0 -93
- package/element/Cr5o77zq.js +0 -199
- package/element/D3OYeY482.js +0 -8
- package/element/DVo8WBwP2.js +0 -4
- package/element/DXFmV-Ty2.js +0 -14
- package/element/Da6CorI52.js +0 -5
- package/element/DdACKOZr.js +0 -1
- package/element/DnnkdZ6w2.js +0 -3
- package/element/DsU4DxSM.js +0 -3
- package/element/OnH8Izqn.js +0 -1
- package/element/_d0Pbeg3.js +0 -5
- package/element/cjsXyqlO2.js +0 -1
- package/element/tvCSWnLG.js +0 -2
- /package/element/{BUDCYszs2.js → BUDCYszs.js} +0 -0
- /package/element/{CfMNBPpx2.js → CfMNBPpx.js} +0 -0
- /package/element/{DnIueBGr2.js → DnIueBGr.js} +0 -0
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
var e,t,i=Object.create,r=Object.defineProperty,a=Object.getOwnPropertyDescriptor,n=Object.getOwnPropertyNames,o=Object.getPrototypeOf,s=Object.prototype.hasOwnProperty,l=(e,t)=>()=>(t||(e((t={exports:{}}).exports,t,t.exports),e=null),t.exports),u=(e,t,i,o)=>{if(t&&"object"==typeof t||"function"==typeof t)for(var l,u=n(t),h=0,c=u.length;h<c;h++)l=u[h],!s.call(e,l)&&l!==i&&r(e,l,{get:(e=>t[e]).bind(null,l),enumerable:!(o=a(t,l))||o.enumerable});return e},h=(e,t,a)=>(a=null==e?{}:i(o(e)),u(!t&&e&&e.__esModule&&s.call(e,"default")?a:r(a,"default",{value:e,enumerable:!0}),e)),c="6.16.0";function d(e,t){this.x=e,this.y=t}function p(){return e??=typeof OffscreenCanvas<"u"&&!!new OffscreenCanvas(1,1).getContext("2d")&&"function"==typeof createImageBitmap,e}function f(){if(null==t&&(t=!1,p())){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}d.prototype={clone(){return new d(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:d},d.convert=function(e){if(e instanceof d)return e;if(Array.isArray(e))return new d(+e[0],+e[1]);if(void 0!==e.x&&void 0!==e.y)return new d(+e.x,+e.y);throw Error("Expected [x, y] or {x, y} point format")};var m=typeof Float32Array<"u"?Float32Array:Array;function _(){var e=new m(4);return m!=Float32Array&&(e[1]=0,e[2]=0),e[0]=1,e[3]=1,e}function g(){var e=new m(9);return m!=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 y(){var e=new m(16);return m!=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 v(e){var t=new m(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 x(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 b(e,t){var i=t[0],r=t[1],a=t[2],n=t[3],o=t[4],s=t[5],l=t[6],u=t[7],h=t[8],c=t[9],d=t[10],p=t[11],f=t[12],m=t[13],_=t[14],g=t[15],y=i*s-r*o,v=i*l-a*o,x=i*u-n*o,b=r*l-a*s,w=r*u-n*s,T=a*u-n*l,S=h*m-c*f,D=h*_-d*f,E=h*g-p*f,C=c*_-d*m,P=c*g-p*m,A=d*g-p*_,I=y*A-v*P+x*C+b*E-w*D+T*S;return I?(I=1/I,e[0]=(s*A-l*P+u*C)*I,e[1]=(a*P-r*A-n*C)*I,e[2]=(m*T-_*w+g*b)*I,e[3]=(d*w-c*T-p*b)*I,e[4]=(l*E-o*A-u*D)*I,e[5]=(i*A-a*E+n*D)*I,e[6]=(_*x-f*T-g*v)*I,e[7]=(h*T-d*x+p*v)*I,e[8]=(o*P-s*E+u*S)*I,e[9]=(r*E-i*P-n*S)*I,e[10]=(f*w-m*x+g*y)*I,e[11]=(c*x-h*w-p*y)*I,e[12]=(s*D-o*C-l*S)*I,e[13]=(i*C-r*D+a*S)*I,e[14]=(m*v-f*b-_*y)*I,e[15]=(h*b-c*v+d*y)*I,e):null}function w(e,t,i){var r=t[0],a=t[1],n=t[2],o=t[3],s=t[4],l=t[5],u=t[6],h=t[7],c=t[8],d=t[9],p=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*s+b*c+w*m,e[1]=v*a+x*l+b*d+w*_,e[2]=v*n+x*u+b*p+w*g,e[3]=v*o+x*h+b*f+w*y,v=i[4],x=i[5],b=i[6],w=i[7],e[4]=v*r+x*s+b*c+w*m,e[5]=v*a+x*l+b*d+w*_,e[6]=v*n+x*u+b*p+w*g,e[7]=v*o+x*h+b*f+w*y,v=i[8],x=i[9],b=i[10],w=i[11],e[8]=v*r+x*s+b*c+w*m,e[9]=v*a+x*l+b*d+w*_,e[10]=v*n+x*u+b*p+w*g,e[11]=v*o+x*h+b*f+w*y,v=i[12],x=i[13],b=i[14],w=i[15],e[12]=v*r+x*s+b*c+w*m,e[13]=v*a+x*l+b*d+w*_,e[14]=v*n+x*u+b*p+w*g,e[15]=v*o+x*h+b*f+w*y,e}function T(e,t,i){var r,a,n,o,s,l,u,h,c,d,p,f,m=i[0],_=i[1],g=i[2];return t===e?(e[12]=t[0]*m+t[4]*_+t[8]*g+t[12],e[13]=t[1]*m+t[5]*_+t[9]*g+t[13],e[14]=t[2]*m+t[6]*_+t[10]*g+t[14],e[15]=t[3]*m+t[7]*_+t[11]*g+t[15]):(r=t[0],a=t[1],n=t[2],o=t[3],s=t[4],l=t[5],u=t[6],h=t[7],c=t[8],d=t[9],p=t[10],f=t[11],e[0]=r,e[1]=a,e[2]=n,e[3]=o,e[4]=s,e[5]=l,e[6]=u,e[7]=h,e[8]=c,e[9]=d,e[10]=p,e[11]=f,e[12]=r*m+s*_+c*g+t[12],e[13]=a*m+l*_+d*g+t[13],e[14]=n*m+u*_+p*g+t[14],e[15]=o*m+h*_+f*g+t[15]),e}function S(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 D(e,t,i){var r=Math.sin(i),a=Math.cos(i),n=t[4],o=t[5],s=t[6],l=t[7],u=t[8],h=t[9],c=t[10],d=t[11];return t!==e&&(e[0]=t[0],e[1]=t[1],e[2]=t[2],e[3]=t[3],e[12]=t[12],e[13]=t[13],e[14]=t[14],e[15]=t[15]),e[4]=n*a+u*r,e[5]=o*a+h*r,e[6]=s*a+c*r,e[7]=l*a+d*r,e[8]=u*a-n*r,e[9]=h*a-o*r,e[10]=c*a-s*r,e[11]=d*a-l*r,e}function E(e,t,i){var r=Math.sin(i),a=Math.cos(i),n=t[0],o=t[1],s=t[2],l=t[3],u=t[8],h=t[9],c=t[10],d=t[11];return t!==e&&(e[4]=t[4],e[5]=t[5],e[6]=t[6],e[7]=t[7],e[12]=t[12],e[13]=t[13],e[14]=t[14],e[15]=t[15]),e[0]=n*a-u*r,e[1]=o*a-h*r,e[2]=s*a-c*r,e[3]=l*a-d*r,e[8]=n*r+u*a,e[9]=o*r+h*a,e[10]=s*r+c*a,e[11]=l*r+d*a,e}function C(e,t,i){var r=Math.sin(i),a=Math.cos(i),n=t[0],o=t[1],s=t[2],l=t[3],u=t[4],h=t[5],c=t[6],d=t[7];return t!==e&&(e[8]=t[8],e[9]=t[9],e[10]=t[10],e[11]=t[11],e[12]=t[12],e[13]=t[13],e[14]=t[14],e[15]=t[15]),e[0]=n*a+u*r,e[1]=o*a+h*r,e[2]=s*a+c*r,e[3]=l*a+d*r,e[4]=u*a-n*r,e[5]=h*a-o*r,e[6]=c*a-s*r,e[7]=d*a-l*r,e}var P=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 o=1/(r-a);e[10]=(a+r)*o,e[14]=2*a*r*o}else e[10]=-1,e[14]=-2*r;return e},A=function(e,t,i,r,a,n,o){var s=1/(t-i),l=1/(r-a),u=1/(n-o);return e[0]=-2*s,e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[5]=-2*l,e[6]=0,e[7]=0,e[8]=0,e[9]=0,e[10]=2*u,e[11]=0,e[12]=(t+i)*s,e[13]=(a+r)*l,e[14]=(o+n)*u,e[15]=1,e};function I(){var e=new m(3);return m!=Float32Array&&(e[0]=0,e[1]=0,e[2]=0),e}function M(e){var t=new m(3);return t[0]=e[0],t[1]=e[1],t[2]=e[2],t}function F(e){var t=e[0],i=e[1],r=e[2];return Math.sqrt(t*t+i*i+r*r)}function z(e,t,i){var r=new m(3);return r[0]=e,r[1]=t,r[2]=i,r}function k(e,t,i){return e[0]=t[0]+i[0],e[1]=t[1]+i[1],e[2]=t[2]+i[2],e}function R(e,t,i){return e[0]=t[0]-i[0],e[1]=t[1]-i[1],e[2]=t[2]-i[2],e}function L(e,t,i){return e[0]=t[0]*i,e[1]=t[1]*i,e[2]=t[2]*i,e}function B(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 O(e,t){var i=t[0]-e[0],r=t[1]-e[1],a=t[2]-e[2];return Math.sqrt(i*i+r*r+a*a)}function j(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 V(e,t){return e[0]*t[0]+e[1]*t[1]+e[2]*t[2]}function N(e,t,i){var r=t[0],a=t[1],n=t[2],o=i[0],s=i[1],l=i[2];return e[0]=a*l-n*s,e[1]=n*o-r*l,e[2]=r*s-a*o,e}function U(e,t,i){var r=i[0],a=i[1],n=i[2],o=i[3],s=t[0],l=t[1],u=t[2],h=a*u-n*l,c=n*s-r*u,d=r*l-a*s;return h+=h,c+=c,d+=d,e[0]=s+o*h+a*d-n*c,e[1]=l+o*c+n*h-r*d,e[2]=u+o*d+r*c-a*h,e}function $(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 G(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 Z(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 q=R,W=F;function H(e,t,i){var r=t[0],a=t[1],n=t[2],o=t[3];return e[0]=i[0]*r+i[4]*a+i[8]*n+i[12]*o,e[1]=i[1]*r+i[5]*a+i[9]*n+i[13]*o,e[2]=i[2]*r+i[6]*a+i[10]*n+i[14]*o,e[3]=i[3]*r+i[7]*a+i[11]*n+i[15]*o,e}I();function X(){var e=new m(4);return m!=Float32Array&&(e[0]=0,e[1]=0,e[2]=0),e[3]=1,e}function Y(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 o=Math.sin(t),s=Math.cos(t),l=Math.sin(i),u=Math.cos(i),h=Math.sin(r),c=Math.cos(r);switch(a){case"xyz":e[0]=o*u*c+s*l*h,e[1]=s*l*c-o*u*h,e[2]=s*u*h+o*l*c,e[3]=s*u*c-o*l*h;break;case"xzy":e[0]=o*u*c-s*l*h,e[1]=s*l*c-o*u*h,e[2]=s*u*h+o*l*c,e[3]=s*u*c+o*l*h;break;case"yxz":e[0]=o*u*c+s*l*h,e[1]=s*l*c-o*u*h,e[2]=s*u*h-o*l*c,e[3]=s*u*c+o*l*h;break;case"yzx":e[0]=o*u*c+s*l*h,e[1]=s*l*c+o*u*h,e[2]=s*u*h-o*l*c,e[3]=s*u*c-o*l*h;break;case"zxy":e[0]=o*u*c-s*l*h,e[1]=s*l*c+o*u*h,e[2]=s*u*h+o*l*c,e[3]=s*u*c-o*l*h;break;case"zyx":e[0]=o*u*c-s*l*h,e[1]=s*l*c+o*u*h,e[2]=s*u*h-o*l*c,e[3]=s*u*c+o*l*h;break;default:throw Error("Unknown angle order "+a)}return e}!function(){var e=new m(4);m!=Float32Array&&(e[0]=0,e[1]=0,e[2]=0,e[3]=0)}();function K(){var e=new m(2);return m!=Float32Array&&(e[0]=0,e[1]=0),e}function J(e,t){var i=new m(2);return i[0]=e,i[1]=t,i}function Q(e,t,i){return e[0]=t[0]*i,e[1]=t[1]*i,e}function ee(e){var t=e[0],i=e[1];return Math.sqrt(t*t+i*i)}function te(e){return e[0]=0,e[1]=0,e}I(),z(1,0,0),z(0,1,0),X(),X(),g();var ie=function(e){var t=e[0],i=e[1];return t*t+i*i};K();var re=8192;function ae(e,t,i){return t*(re/(e.tileSize*2**(i-e.tileID.overscaledZ)))}function ne(e){return e instanceof Error?e:Error("string"==typeof e?e:String(e))}function oe(){/* @__PURE__ */
|
|
2
|
+
return new Float64Array(4)}function se(){/* @__PURE__ */
|
|
3
|
+
return new Float64Array(3)}function le(){/* @__PURE__ */
|
|
4
|
+
return new Float64Array(16)}function ue(){let e=/* @__PURE__ */new Float64Array(16);return x(e),e}function he(){let e=/* @__PURE__ */new Float32Array(16);return x(e),e}function ce(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]:ae(t,i[0],e.zoom),a?i[1]:ae(t,i[1],e.zoom)]}function de(e,t){return e[0]*t[0]+e[1]*t[1]+e[2]*t[2]+e[3]}function pe(e,t,i){let r=function(e){var t=e[3],i=e[4],r=e[5],a=e[6],n=e[7],o=e[8];return e[0]*(o*i-r*n)+e[1]*(-o*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=N([],[t[0],t[1],t[2]],[i[0],i[1],i[2]]),n=N([],[i[0],i[1],i[2]],[e[0],e[1],e[2]]),o=N([],[e[0],e[1],e[2]],[t[0],t[1],t[2]]),s=L([],a,-e[3]);return k(s,s,L([],n,-t[3])),k(s,s,L([],o,-i[3])),L(s,s,1/r),s}function fe(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 me(e,t,i,r){let a=Math.sqrt(e*e+t*t),n=Math.sqrt(i*i+r*r),o=(e/=a)*(i/=n)+(t/=a)*(r/=n),s=Math.acos(o);return-t*i+e*r>0?s:-s}function _e(e,t){let i=ye(e,360),r=ye(t,360),a=r-i,n=r>i?a-360:a+360;return Math.abs(a)<Math.abs(n)?a:n}function ge(e,t){let i=ye(e,2*Math.PI),r=ye(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 ye(e,t){return(e%t+t)%t}function ve(e,t,i,r,a){return xe(r,a,Se((e-t)/(i-t),0,1))}function xe(e,t,i){return e*(1-i)+t*i}function be(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 we(e,t,i,r){return function(e,t,i,r){let a=3*e,n=3*(i-e)-a,o=1-a-n,s=3*t,l=3*(r-t)-s,u=1-s-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=((o*i+n)*i+a)*i-e;if(Math.abs(r)<t)return((u*i+l)*i+s)*i;let h=(3*o*i+2*n)*i+a;if(Math.abs(h)<1e-6)break;i-=r/h}let r=0,h=1;i=e;for(let s=0;s<20;s++){let s=((o*i+n)*i+a)*i;if(Math.abs(s-e)<t)break;e>s?r=i:h=i,i=.5*(r+h)}return((u*i+l)*i+s)*i}}(e,t,i,r)}var Te=we(.25,.1,.25,1);function Se(e,t,i){return Math.min(i,Math.max(t,e))}function De(e,t,i){let r=i-t,a=((e-t)%r+r)%r+t;return a===t?i:a}function Ee(e,...t){for(let i of t)for(let t in i)e[t]=i[t];return e}function Ce(e,t){let i={};for(let r of t)r in e&&(i[r]=e[r]);return i}var Pe=1;function Ae(){return Pe++}function Ie(e){return 2**e}function Me(e){return Math.log(e)/Math.LN2}function Fe(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 ze(e,t,i){let r={};for(let a in e)r[a]=t.call(i||this,e[a],a,e);return r}function ke(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 Re(e,t){if(Array.isArray(e)){if(!Array.isArray(t)||e.length!==t.length)return!1;for(let i=0;i<e.length;i++)if(!Re(e[i],t[i]))return!1;return!0}if("object"==typeof e&&e&&null!==t){if("object"!=typeof t||Object.keys(e).length!==Object.keys(t).length)return!1;for(let i in e)if(!Re(e[i],t[i]))return!1;return!0}return e===t}function Le(e){return Array.isArray(e)?e.map(Le):"object"==typeof e&&e?ze(e,Le):e}var Be={};function Oe(e){Be[e]||(typeof console<"u"&&console.warn(e),Be[e]=!0)}function je(e,t,i){return(i.y-e.y)*(t.x-e.x)>(t.y-e.y)*(i.x-e.x)}function Ve(e,t,i,r){let a=t.y-e.y,n=t.x-e.x,o=r.y-i.y,s=r.x-i.x,l=o*n-s*a;if(0===l)return null;let u=(s*(e.y-i.y)-o*(e.x-i.x))/l;return new d(e.x+u*n,e.y+u*a)}function Ne([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)]}function Ue(e){return typeof WorkerGlobalScope<"u"&&void 0!==e&&e instanceof WorkerGlobalScope}var $e=null;function Ge(e){return typeof ImageBitmap<"u"&&e instanceof ImageBitmap}function Ze(e,t,i,r){return e.addEventListener(t,i,r),{unsubscribe:()=>{e.removeEventListener(t,i,r)}}}function qe(e){return e*Math.PI/180}function We(e){return e/Math.PI*180}function He(e,t){return e.roll==t.roll&&e.pitch==t.pitch&&e.bearing==t.bearing}function Xe(e,t,i){let r=J(t.x-i.x,t.y-i.y),a=J(e.x-i.x,e.y-i.y),n=r[0]*a[1]-r[1]*a[0];return We(Math.atan2(n,function(e,t){return e[0]*t[0]+e[1]*t[1]}(r,a)))}function Ye(e,t,i){let r=/* @__PURE__ */new Float64Array(4);return Y(r,e,t-90,i),r}var Ke=85.051129,Je={touchstart:!0,touchmove:!0,touchmoveWindow:!0,touchend:!0,touchcancel:!0},Qe={dblclick:!0,click:!0,mouseover:!0,mouseout:!0,mousedown:!0,mousemove:!0,mousemoveWindow:!0,mouseup:!0,mouseupWindow:!0,contextmenu:!0,wheel:!0};function et(e,t){return Je[t]&&"touches"in e}function tt(e,t){if(!Qe[t])return!1;let i=e,r=(i?.target)?.ownerDocument?.defaultView||window;return i instanceof r.MouseEvent||i instanceof r.WheelEvent}function it(e){return Je[e]||Qe[e]}var rt,at,nt,ot="AbortError",st=class extends Error{constructor(e=ot){super(e instanceof Error?e.message:e),this.name=ot,e instanceof Error&&e.stack&&(this.stack=e.stack)}};function lt(e){return e instanceof Error&&"AbortError"===e.name}function ut(e){if(e.aborted)throw new st(e.reason)}var ht={frame(e,t,i,r){let a=r||window,n=a.requestAnimationFrame(e=>{o(),t(e)}),{unsubscribe:o}=Ze(e.signal,"abort",()=>{o(),a.cancelAnimationFrame(n),i(new st(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;if(p()&&!f())t=new OffscreenCanvas(e.width,e.height).getContext("2d",{willReadFrequently:!0});else{let i=window.document.createElement("canvas");i.width=e.width,i.height=e.height,t=i.getContext("2d",{willReadFrequently:!0})}if(!t)throw Error("failed to create canvas 2d context");return t.drawImage(e,0,0,e.width,e.height),t},resolveURL:e=>(rt||=document.createElement("a"),rt.href=e,rt.href),get hardwareConcurrency(){return typeof navigator<"u"&&navigator.hardwareConcurrency||4},get prefersReducedMotion(){return void 0===nt?!!matchMedia&&(at??=matchMedia("(prefers-reduced-motion: reduce)"),at.matches):nt},set prefersReducedMotion(e){nt=e}},ct=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 dt(){return ct.getCurrentTime()}function pt(e){ct.setNow(e)}function ft(){ct.restoreNow()}function mt(){return ct.isFrozen()}var _t,gt=/* @__PURE__ */new Set(/* @__PURE__ */"a.abbr.b.bdi.bdo.br.cite.code.del.div.em.i.img.ins.kbd.li.mark.ol.p.q.s.samp.small.span.strong.sub.sup.time.u.ul.var.wbr".split(".")),yt=/* @__PURE__ */new Set(["alt","class","datetime","dir","height","href","hreflang","lang","referrerpolicy","rel","role","src","target","title","translate","type","width"]),vt=/* @__PURE__ */new Set(["href","src"]),xt=/* @__PURE__ */new Set(["http:","https:","mailto:"]);function bt(){return _t??={getAttribute:Element.prototype.getAttribute,getAttributeNames:Element.prototype.getAttributeNames,querySelectorAll:Element.prototype.querySelectorAll,remove:Element.prototype.remove,removeAttribute:Element.prototype.removeAttribute,localName:Object.getOwnPropertyDescriptor(Element.prototype,"localName").get,namespaceURI:Object.getOwnPropertyDescriptor(Element.prototype,"namespaceURI").get},_t}var wt=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 d((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,{querySelectorAll:r,remove:a}=bt();for(let o of Array.from(r.call(i,"*")))e.isAllowedElement(o)?e.removeDisallowedAttributes(o):a.call(o);let n=document.createDocumentFragment();return n.append(...i.childNodes),n}static isAllowedElement(e){let{namespaceURI:t,localName:i}=bt();return"http://www.w3.org/1999/xhtml"===t.call(e)&>.has(i.call(e))}static removeDisallowedAttributes(t){let{getAttributeNames:i,getAttribute:r,removeAttribute:a}=bt();for(let n of i.call(t))e.isAllowedAttribute(n,r.call(t,n))||a.call(t,n)}static isAllowedAttribute(e,t){if(!yt.has(e)&&!e.startsWith("aria-"))return!1;if(!vt.has(e))return!0;try{return xt.has(new URL(t,"https://maplibre.invalid/").protocol)}catch{return!1}}},Tt={MAX_PARALLEL_IMAGE_REQUESTS:16,MAX_PARALLEL_IMAGE_REQUESTS_PER_FRAME:8,MAX_TILE_CACHE_ZOOM_LEVELS:5,REGISTERED_PROTOCOLS:{},WORKER_URL:""};function St(e){return Tt.REGISTERED_PROTOCOLS[e.substring(0,e.indexOf("://"))]}function Dt(e,t){Tt.REGISTERED_PROTOCOLS[e]=t}function Et(e){delete Tt.REGISTERED_PROTOCOLS[e]}var Ct="global-dispatcher",Pt=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 At(){if(Ue(self))return self.worker?.referrer;if("blob:"===window.location.protocol)try{return window.parent.location.href}catch{}return window.location.href}var It=async function(e,t){if(e.url.includes("://")&&!/^https?:|^file:/.test(e.url)){let i=St(e.url);if(i){let r=await i(e,t);return r.data||"arrayBuffer"!==e.type?r:Ee(r,{data:/* @__PURE__ */new ArrayBuffer(0)})}if(Ue(self)&&self.worker?.actor)return self.worker.actor.sendAsync({type:"GR",data:e,targetMapId:Ct},t)}if(!(e=>e.startsWith("file:")||At()?.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:At(),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 lt(t)?t:new Pt(0,ne(t).message,e.url,new Blob)}if(!i.ok){let t=await i.blob();throw new Pt(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 ut(t.signal),{data:n,cacheControl:i.headers.get("Cache-Control"),expires:i.headers.get("Expires"),etag:i.headers.get("ETag")}}(e,t);if(Ue(self)&&self.worker?.actor)return self.worker.actor.sendAsync({type:"GR",data:e,mustQueue:!0,targetMapId:Ct},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 Pt(a.status,a.statusText,e.url,t))}},t.signal.addEventListener("abort",()=>{a.abort(),r(new st(t.signal.reason))}),a.send(e.body)})}(e,t)},Mt=(e,t)=>It(Ee(e,{type:"json"}),t),Ft=(e,t)=>It(Ee(e,{type:"arrayBuffer"}),t);function zt(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 kt(e,t,i){i[e]?.includes(t)||(i[e]||=[],i[e].push(t))}function Rt(e,t,i){if(i?.[e]){let r=i[e].indexOf(t);-1!==r&&i[e].splice(r,1)}}var Lt=class{constructor(e,t={}){Ee(this,t),this.type=e}},Bt=class extends Lt{constructor(e,t={}){super("error",Ee({error:e},t))}},Ot=class{on(e,t){return this._listeners||={},kt(e,t,this._listeners),{unsubscribe:()=>{this.off(e,t)}}}off(e,t){return Rt(e,t,this._listeners),Rt(e,t,this._oneTimeListeners),this}once(e,t){return t?(this._oneTimeListeners||={},kt(e,t,this._oneTimeListeners),this):new Promise(t=>this.once(e,t))}fire(e,t){let i="string"==typeof e?new Lt(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)Rt(r,n,this._oneTimeListeners),n.call(this,i);let a=this._eventedParent;a&&(Ee(i,"function"==typeof this._eventedParentData?this._eventedParentData():this._eventedParentData),a.fire(i))}else i instanceof Bt&&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}},jt=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],o=a[3+r.length+1];this.keys=a.subarray(n,o),this.bboxes=a.subarray(o),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,o=this.max;if(e<=n&&t<=n&&o<=i&&o<=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,o,s){let l=this.cells[a];if(null!==l){let a=this.keys,u=this.bboxes;for(let h of l)if(void 0===o[h]){let l=4*h;(s?s(u[l+0],u[l+1],u[l+2],u[l+3]):e<=u[l+2]&&t<=u[l+3]&&i>=u[l+0]&&r>=u[l+1])?(o[h]=!0,n.push(a[h])):o[h]=!1}}}_forEachCell(e,t,i,r,a,n,o,s){let l=this._convertToCellCoord(e),u=this._convertToCellCoord(t),h=this._convertToCellCoord(i),c=this._convertToCellCoord(r);for(let d=l;d<=h;d++)for(let l=u;l<=c;l++){let u=this.d*l+d;if((!s||s(this._convertFromCellCoord(d),this._convertFromCellCoord(l),this._convertFromCellCoord(d+1),this._convertFromCellCoord(l+1)))&&a.call(this,e,t,i,r,u,n,o,s))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)}},Vt={$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:{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","feature"]},"property-type":"data-driven"},"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"},"symbol-height-offset":{type:"number",default:0,units:"meters",requires:[{"symbol-placement":["point"]}],expression:{interpolated:!0,parameters:["zoom","feature"]},"property-type":"data-driven"},"symbol-height-anchor":{type:"enum",values:{ground:{},absolute:{}},default:"ground",requires:["symbol-height-offset"],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,units:"meters",transition:!0,expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"fill-extrusion-base":{type:"number",default: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"}]}}}}},Nt=Vt,Ut=["type","source","source-layer","minzoom","maxzoom","filter","layout"];function $t(e,t){let i={};for(let r in e)"ref"!==r&&(i[r]=e[r]);return Ut.forEach(e=>{e in t&&(i[e]=t[e])}),i}function Gt(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]=$t(e[i],t[e[i].ref]));return e}function Zt(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(!Zt(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(!Zt(e[i],t[i]))return!1;return!0}return e===t}function qt(e,t){e.push(t)}function Wt(e,t,i){qt(i,{command:"addSource",args:[e,t[e]]})}function Ht(e,t,i){qt(t,{command:"removeSource",args:[e]}),i[e]=!0}function Xt(e,t,i,r){Ht(e,i,r),Wt(e,t,i)}function Yt(e,t,i){let r;for(r in e[i])if(Object.prototype.hasOwnProperty.call(e[i],r)&&"data"!==r&&!Zt(e[i][r],t[i][r]))return!1;for(r in t[i])if(Object.prototype.hasOwnProperty.call(t[i],r)&&"data"!==r&&!Zt(e[i][r],t[i][r]))return!1;return!0}function Kt(e,t,i,r,a){qt(t,{command:a,args:[i,r,e[r]]})}function Jt(e,t,i,r,a){e||={},t||={};for(let n in e)Object.prototype.hasOwnProperty.call(e,n)&&(Zt(e[n],t[n])||Kt(t,i,r,n,a));for(let n in t)Object.prototype.hasOwnProperty.call(t,n)&&!Object.prototype.hasOwnProperty.call(e,n)&&(Zt(e[n],t[n])||Kt(t,i,r,n,a))}function Qt(e){return e.id}function ei(e,t){return e[t.id]=t,e}var ti=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__)}},ii={kind:"null"},ri={kind:"number"},ai={kind:"string"},ni={kind:"boolean"},oi={kind:"color"},si={kind:"projectionDefinition"},li={kind:"object"},ui={kind:"value"},hi={kind:"collator"},ci={kind:"formatted"},di={kind:"padding"},pi={kind:"colorArray"},fi={kind:"numberArray"},mi={kind:"resolvedImage"},_i={kind:"variableAnchorOffsetCollection"};function gi(e,t){return{kind:"array",itemType:e,N:t}}function yi(e){if("array"===e.kind){let t=yi(e.itemType);return"number"==typeof e.N?`array<${t}, ${e.N}>`:"value"===e.itemType.kind?"array":`array<${t}>`}return e.kind}var vi=[ii,ri,ai,ni,oi,si,ci,li,gi(ui),di,fi,pi,mi,_i];function xi(e,t){if("error"===t.kind)return null;if("array"===e.kind){if("array"===t.kind&&(0===t.N&&"value"===t.itemType.kind||!xi(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 vi)if(!xi(e,t))return null}return`Expected ${yi(e)} but found ${yi(t)} instead.`}function bi(e,t){return t.some(t=>t.kind===e.kind)}function wi(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 Ti(e,t){return"array"===e.kind&&"array"===t.kind?e.itemType.kind===t.itemType.kind&&"number"==typeof e.N:e.kind===t.kind}var Si=.96422,Di=.82521,Ei=4/29,Ci=6/29,Pi=3*Ci*Ci,Ai=Math.PI/180,Ii=180/Math.PI;function Mi(e){return(e%=360)<0&&(e+=360),e}function Fi([e,t,i,r]){let a,n,o=ki((.2225045*(e=zi(e))+.7168786*(t=zi(t))+.0606169*(i=zi(i)))/1);e===t&&t===i?a=n=o:(a=ki((.4360747*e+.3850649*t+.1430804*i)/Si),n=ki((.0139322*e+.0971045*t+.7141733*i)/Di));let s=116*o-16;return[s<0?0:s,500*(a-o),200*(o-n),r]}function zi(e){return e<=.04045?e/12.92:((e+.055)/1.055)**2.4}function ki(e){return e>.008856451679035631?e**(1/3):e/Pi+Ei}function Ri([e,t,i,r]){let a=(e+16)/116,n=isNaN(t)?a:a+t/500,o=isNaN(i)?a:a-i/200;return a=1*Bi(a),n=Si*Bi(n),o=Di*Bi(o),[Li(3.1338561*n-1.6168667*a-.4906146*o),Li(-.9787684*n+1.9161415*a+.033454*o),Li(.0719453*n-.2289914*a+1.4052427*o),r]}function Li(e){return(e=e<=.00304?12.92*e:1.055*e**(1/2.4)-.055)<0?0:e>1?1:e}function Bi(e){return e>Ci?e*e*e:Pi*(e-Ei)}var Oi=Object.hasOwn||function(e,t){return Object.prototype.hasOwnProperty.call(e,t)};function ji(e,t){return Oi(e,t)?e[t]:void 0}function Vi(e){return parseInt(e.padEnd(2,e),16)/255}function Ni(e,t){return Ui(t?e/100:e,0,1)}function Ui(e,t,i){return Math.min(Math.max(t,e),i)}function $i(e){return!e.some(Number.isNaN)}var Gi={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 Zi(e,t,i){return e+i*(t-e)}function qi(e,t,i){return e.map((e,r)=>Zi(e,t[r],i))}var Wi=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=ji(Gi,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[Vi(e.slice(i,i+=t)),Vi(e.slice(i,i+=t)),Vi(e.slice(i,i+=t)),Vi(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,o,s,l,u,h,c,d]=t,p=[a||" ",s||" ",h].join("");if(" "===p||" /"===p||",,"===p||",,,"===p){let e=[r,o,u].join(""),t="%%%"===e?100:""===e?255:0;if(t){let e=[Ui(+i/t,0,1),Ui(+n/t,0,1),Ui(+l/t,0,1),c?Ni(+c,d):1];if($i(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,o,s,l,u]=i,h=[r||" ",n||" ",s].join("");if(" "===h||" /"===h||",,"===h||",,,"===h){let e=[+t,Ui(+a,0,100),Ui(+o,0,100),l?Ni(+l,u):1];if($i(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=Mi(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]=Fi(e),n=Math.sqrt(i*i+r*r);return[Math.round(1e4*n)?Mi(Math.atan2(r,i)*Ii):NaN,n,t,a]}(this.rgb))}get lab(){return this.overwriteGetter("lab",Fi(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,o,s]=qi(t.rgb,i.rgb,r);return new e(a,n,o,s,!1)}case"hcl":{let a,n,[o,s,l,u]=t.hcl,[h,c,d,p]=i.hcl;if(isNaN(o)||isNaN(h))isNaN(o)?isNaN(h)?a=NaN:(a=h,(1===l||0===l)&&(n=c)):(a=o,(1===d||0===d)&&(n=s));else{let e=h-o;h>o&&e>180?e-=360:h<o&&o-h>180&&(e+=360),a=o+r*e}let[f,m,_,g]=function([e,t,i,r]){return e=isNaN(e)?0:e*Ai,Ri([i,Math.cos(e)*t,Math.sin(e)*t,r])}([a,n??Zi(s,c,r),Zi(l,d,r),Zi(u,p,r)]);return new e(f,m,_,g,!1)}case"lab":{let[a,n,o,s]=Ri(qi(t.lab,i.lab,r));return new e(a,n,o,s,!1)}}}},Hi=["bottom","center","top"],Xi=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}},Yi=class e{constructor(e){this.sections=e}static fromString(t){return new e([new Xi(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("")}},Ki=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(qi(t.values,i.values,r))}},Ji=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(qi(t.values,i.values,r))}},Qi=class e{constructor(e){this.values=e.slice()}static parse(t){if(t instanceof e)return t;if("string"==typeof t){let i=Wi.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=Wi.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(Wi.interpolate(t.values[e],i.values[e],r,a));return new e(n)}},er=class extends Error{constructor(e,t){super(e),this.name="RuntimeError",this.path=t}toJSON(){return this.message}},tr=/* @__PURE__ */new Set(["center","left","right","top","bottom","top-left","top-right","bottom-left","bottom-right"]),ir=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||!tr.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,o=i.values;if(n.length!==o.length)throw new er(`Cannot interpolate values of different length. from: ${t.toString()}, to: ${i.toString()}`,a);let s=[];for(let e=0;e<n.length;e+=2){if(n[e]!==o[e])throw new er(`Cannot interpolate values containing mismatched anchors. from[${e}]: ${n[e]}, to[${e}]: ${o[e]}`,a);s.push(n[e]);let[t,i]=n[e+1],[l,u]=o[e+1];s.push([Zi(t,l,r),Zi(i,u,r)])}return new e(s)}},rr=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}},ar=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}},nr=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}};function or(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 sr(e){if(null===e||"string"==typeof e||"boolean"==typeof e||"number"==typeof e||e instanceof ar||e instanceof Wi||e instanceof nr||e instanceof Yi||e instanceof Ki||e instanceof Ji||e instanceof Qi||e instanceof ir||e instanceof rr)return!0;if(Array.isArray(e)){for(let t of e)if(!sr(t))return!1;return!0}if("object"==typeof e){for(let t in e)if(!sr(e[t]))return!1;return!0}return!1}function lr(e){if(null===e)return ii;if("string"==typeof e)return ai;if("boolean"==typeof e)return ni;if("number"==typeof e)return ri;if(e instanceof Wi)return oi;if(e instanceof ar)return si;if(e instanceof nr)return hi;if(e instanceof Yi)return ci;if(e instanceof Ki)return di;if(e instanceof Ji)return fi;if(e instanceof Qi)return pi;if(e instanceof ir)return _i;if(e instanceof rr)return mi;if(Array.isArray(e)){let t,i=e.length;for(let r of e){let e=lr(r);if(t){if(t===e)continue;t=ui;break}t=e}return gi(t||ui,i)}return li}function ur(e){let t=typeof e;return null===e?"":"string"===t||"number"===t||"boolean"===t?String(e):e instanceof Wi||e instanceof ar||e instanceof Yi||e instanceof Ki||e instanceof Ji||e instanceof Qi||e instanceof ir||e instanceof rr?e.toString():JSON.stringify(e)}var hr=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(!sr(t[1]))return i.error(`invalid value of type "${typeof t[1]}"`);let r=t[1],a=lr(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}},cr=["Unknown","Point","LineString","Polygon"],dr=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?cr[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=Wi.parse(e),this._parseColorCache.set(e,t)),t}};function pr(e,t,i){let r,a,n=e.length-1,o=0,s=n,l=0;for(;o<=s;)if(l=Math.floor((o+s)/2),r=e[l],a=e[l+1],r<=t){if(l===n||t<a)return l;o=l+1}else{if(!(r>t))throw new er("Input is not a number.",i);s=l-1}return 0}var fr=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,ri);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],o=t[e+1],s=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.',s);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.',s);let u=i.parse(o,l,n);if(!u)return null;n||=u.type,a.push([r,u])}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[pr(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())}},mr=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[o,s]of a)this.labels.push(o),this.outputs.push(s)}static interpolationFactor(e,t,i,r){let a=0;if("exponential"===e.name)a=_r(t,e.base,i,r);else if("linear"===e.name)a=_r(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,o=1-a-n,s=3*t,l=3*(r-t)-s,u=1-s-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=((o*i+n)*i+a)*i-e;if(Math.abs(r)<t)return((u*i+l)*i+s)*i;let h=(3*o*i+2*n)*i+a;if(Math.abs(h)<1e-6)break;i-=r/h}let r=0,h=1;i=e;for(let s=0;s<20;s++){let s=((o*i+n)*i+a)*i;if(Math.abs(s-e)<t)break;e>s?r=i:h=i,i=.5*(r+h)}return((u*i+l)*i+s)*i}}(n[0],n[1],n[2],n[3])(_r(t,1,i,r))}return a}static parse(t,i){let[r,a,n,...o]=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,ri),!n)return null;let s=[],l=null;"interpolate-hcl"!==r&&"interpolate-lab"!==r||i.expectedType==pi?i.expectedType&&"value"!==i.expectedType.kind&&(l=i.expectedType):l=oi;for(let e=0;e<o.length;e+=2){let t=o[e],r=o[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(s.length&&s[s.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 u=i.parse(r,n,l);if(!u)return null;l||=u.type,s.push([t,u])}return Ti(l,ri)||Ti(l,si)||Ti(l,oi)||Ti(l,di)||Ti(l,fi)||Ti(l,pi)||Ti(l,_i)||Ti(l,gi(ri))?new e(l,r,a,n,s,i.key):i.error(`Type ${yi(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 o=pr(i,a,this.key),s=i[o],l=i[o+1],u=e.interpolationFactor(this.interpolation,a,s,l),h=r[o].evaluate(t),c=r[o+1].evaluate(t);switch(this.operator){case"interpolate":switch(this.type.kind){case"number":return Zi(h,c,u);case"color":return Wi.interpolate(h,c,u);case"padding":return Ki.interpolate(h,c,u);case"colorArray":return Qi.interpolate(h,c,u);case"numberArray":return Ji.interpolate(h,c,u);case"variableAnchorOffsetCollection":return ir.interpolate(h,c,u,this.key);case"array":return qi(h,c,u);case"projectionDefinition":return ar.interpolate(h,c,u)}case"interpolate-hcl":switch(this.type.kind){case"color":return Wi.interpolate(h,c,u,"hcl");case"colorArray":return Qi.interpolate(h,c,u,"hcl")}case"interpolate-lab":switch(this.type.kind){case"color":return Wi.interpolate(h,c,u,"lab");case"colorArray":return Qi.interpolate(h,c,u,"lab")}}}eachChild(e){e(this.input);for(let t of this.outputs)e(t)}outputDefined(){return this.outputs.every(e=>e.outputDefined())}};function _r(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 gr={color:Wi.interpolate,number:Zi,padding:Ki.interpolate,numberArray:Ji.interpolate,colorArray:Qi.interpolate,variableAnchorOffsetCollection:ir.interpolate,array:qi},yr=class e{constructor(e){this.type=ci,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,ri),!e))return null;let t=null;if(r["text-font"]&&(t=i.parse(r["text-font"],1,gi(ai)),!t))return null;let o=null;if(r["text-color"]&&(o=i.parse(r["text-color"],1,oi),!o))return null;let s=null;if(r["vertical-align"]){if("string"==typeof r["vertical-align"]&&!Hi.includes(r["vertical-align"]))return i.error(`'vertical-align' must be one of: 'bottom', 'center', 'top' but found '${r["vertical-align"]}' instead.`);if(s=i.parse(r["vertical-align"],1,ai),!s)return null}let l=a[a.length-1];l.scale=e,l.font=t,l.textColor=o,l.verticalAlign=s}else{let r=i.parse(t[e],1,ui);if(!r)return null;let o=r.type.kind;if("string"!==o&&"value"!==o&&"null"!==o&&"resolvedImage"!==o)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 Yi(this.sections.map(t=>{let i=t.content.evaluate(e);return lr(i)===mi?new Xi("",i,null,null,null,t.verticalAlign?t.verticalAlign.evaluate(e):null):new Xi(ur(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}};function vr(e,t,i=0,r=e.length-1,a=br){for(;r>i;){if(r-i>600){let n=r-i+1,o=t-i+1,s=Math.log(n),l=.5*Math.exp(2*s/3),u=.5*Math.sqrt(s*l*(n-l)/n)*(o-n/2<0?-1:1);vr(e,t,Math.max(i,Math.floor(t-o*l/n+u)),Math.min(r,Math.floor(t+(n-o)*l/n+u)),a)}let n=e[t],o=i,s=r;for(xr(e,i,t),a(e[r],n)>0&&xr(e,i,r);o<s;){for(xr(e,o,s),o++,s--;a(e[o],n)<0;)o++;for(;a(e[s],n)>0;)s--}0===a(e[i],n)?xr(e,i,s):(s++,xr(e,s,r)),s<=t&&(i=s+1),t<=s&&(r=s-1)}}function xr(e,t,i){let r=e[t];e[t]=e[i],e[i]=r}function br(e,t){return e<t?-1:+(e>t)}function wr(e,t){if(e.length<=1)return[e];let i,r,a=[];for(let n of e){let e=Sr(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||(vr(a[n],t,1,a[n].length-1,Tr),a[n]=a[n].slice(0,t));return a}function Tr(e,t){return t.area-e.area}function Sr(e){let t=0;for(let i,r,a=0,n=e.length,o=n-1;a<n;o=a++)i=e[a],r=e[o],t+=(r.x-i.x)*(i.y+r.y);return t}var Dr={string:ai,number:ri,boolean:ni,object:li},Er=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 Dr)||"object"===r)return i.error('The item type argument of "array" must be one of string, number, boolean',1);e=Dr[r],a++}else e=ui;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=gi(e,n)}else{if(!Dr[n])throw Error(`Types doesn't contain name = ${n}`);r=Dr[n]}let o=[];for(;a<t.length;a++){let e=i.parse(t[a],a,ui);if(!e)return null;o.push(e)}return new e(r,o,i.key)}evaluate(e){for(let t=0;t<this.args.length;t++){let i=this.args[t].evaluate(e);if(!xi(this.type,lr(i)))return i;if(t===this.args.length-1)throw new er(`Expected value to be of type ${yi(this.type)}, but found ${yi(lr(i))} instead.`,this.key)}throw Error()}eachChild(e){this.args.forEach(e)}outputDefined(){return this.args.every(e=>e.outputDefined())}},Cr={"to-boolean":ni,"to-color":oi,"to-number":ri,"to-string":ai},Pr=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(!Cr[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=Cr[r],n=[];for(let e=1;e<t.length;e++){let r=i.parse(t[e],e,ui);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 Wi)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.`:or(t[0],t[1],t[2],t[3]),!i))return new Wi(t[0]/255,t[1]/255,t[2]/255,t[3])}throw new er(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=Ki.parse(t);if(r)return r}throw new er(`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=Ji.parse(t);if(r)return r}throw new er(`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=Qi.parse(t);if(r)return r}throw new er(`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=ir.parse(t);if(r)return r}throw new er(`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 er(`Could not convert ${JSON.stringify(t)} to number.`,this.key)}case"formatted":return Yi.fromString(ur(this.args[0].evaluate(e)));case"resolvedImage":return rr.fromString(ur(this.args[0].evaluate(e)));case"projectionDefinition":{let t=this.args[0].evaluate(e);if(ar.parse(t))return t;throw new er(`Could not parse projectionDefinition from value '${"string"==typeof t?t:JSON.stringify(t)}'`,this.key)}default:return ur(this.args[0].evaluate(e))}}eachChild(e){this.args.forEach(e)}outputDefined(){return this.args.every(e=>e.outputDefined())}},Ar=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()}},Ir=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}},Mr=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=>xi(a,e.type))?new e(ui,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 rr&&!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 Fr(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 zr(e,t,i,r){return 0===r.compare(t,i)}function kr(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=ni,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,ui);if(!n)return null;if(!Fr(i,n.type))return t.concat(1).error(`"${i}" comparisons are not supported for type '${yi(n.type)}'.`);let o=t.parse(e[2],2,ui);if(!o)return null;if(!Fr(i,o.type))return t.concat(2).error(`"${i}" comparisons are not supported for type '${yi(o.type)}'.`);if(n.type.kind!==o.type.kind&&"value"!==n.type.kind&&"value"!==o.type.kind)return t.error(`Cannot compare types '${yi(n.type)}' and '${yi(o.type)}'.`);r&&("value"===n.type.kind&&"value"!==o.type.kind?n=new Er(o.type,[n],t.key):"value"!==n.type.kind&&"value"===o.type.kind&&(o=new Er(n.type,[o],t.key)));let s=null;if(4===e.length){if("string"!==n.type.kind&&"string"!==o.type.kind&&"value"!==n.type.kind&&"value"!==o.type.kind)return t.error("Cannot use collator to compare non-string types.");if(s=t.parse(e[3],3,hi),!s)return null}return new a(n,o,t.key,s)}evaluate(a){let n=this.lhs.evaluate(a),o=this.rhs.evaluate(a);if(r&&this.hasUntypedArgument){let t=lr(n),i=lr(o);if(t.kind!==i.kind||"string"!==t.kind&&"number"!==t.kind)throw new er(`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=lr(n),i=lr(o);if("string"!==e.kind||"string"!==i.kind)return t(a,n,o)}return this.collator?i(a,n,o,this.collator.evaluate(a)):t(a,n,o)}eachChild(e){e(this.lhs),e(this.rhs),this.collator&&e(this.collator)}outputDefined(){return!0}}}var Rr=kr("==",function(e,t,i){return t===i},zr),Lr=kr("!=",function(e,t,i){return t!==i},function(e,t,i,r){return!zr(0,t,i,r)}),Br=kr("<",function(e,t,i){return t<i},function(e,t,i,r){return r.compare(t,i)<0}),Or=kr(">",function(e,t,i){return t>i},function(e,t,i,r){return r.compare(t,i)>0}),jr=kr("<=",function(e,t,i){return t<=i},function(e,t,i,r){return r.compare(t,i)<=0}),Vr=kr(">=",function(e,t,i){return t>=i},function(e,t,i,r){return r.compare(t,i)>=0}),Nr=class e{constructor(e,t,i){this.type=hi,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,ni);if(!a)return null;let n=i.parse(void 0!==r["diacritic-sensitive"]&&r["diacritic-sensitive"],1,ni);if(!n)return null;let o=null;return r.locale&&(o=i.parse(r.locale,1,ai),!o)?null:new e(a,n,o)}evaluate(e){return new nr(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}},Ur=8192;function $r(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*Ur),Math.round(r*a*Ur)]}function Gr(e,t){let i=2**t.z,r=(e[0]/Ur+t.x)/i,a=(e[1]/Ur+t.y)/i;return[Zr(r),qr(a)]}function Zr(e){return 360*e-180}function qr(e){return 360/Math.PI*Math.atan(Math.exp((180-360*e)*Math.PI/180))-90}function Wr(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 Hr(e,t){return!(e[0]<=t[0]||e[2]>=t[2]||e[1]<=t[1]||e[3]>=t[3])}function Xr(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 Yr(e,t,i){let r=e[0]-t[0],a=e[1]-t[1],n=e[0]-i[0],o=e[1]-i[1];return r*o-n*a===0&&r*n<=0&&a*o<=0}function Kr(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)&&!(!ra(e,t,i,r)||!ra(i,r,e,t))}function Jr(e,t,i){for(let r of i)for(let i=0;i<r.length-1;++i)if(Kr(e,t,r[i],r[i+1]))return!0;return!1}function Qr(e,t,i=!1){let r=!1;for(let a of t)for(let t=0;t<a.length-1;t++){if(Yr(e,a[t],a[t+1]))return i;Xr(e,a[t],a[t+1])&&(r=!r)}return r}function ea(e,t){for(let i of t)if(Qr(e,i))return!0;return!1}function ta(e,t){for(let i of e)if(!Qr(i,t))return!1;for(let i=0;i<e.length-1;++i)if(Jr(e[i],e[i+1],t))return!1;return!0}function ia(e,t){for(let i of t)if(ta(e,i))return!0;return!1}function ra(e,t,i,r){let a=e[0]-i[0],n=e[1]-i[1],o=t[0]-i[0],s=t[1]-i[1],l=r[0]-i[0],u=r[1]-i[1],h=a*u-l*n,c=o*u-l*s;return h>0&&c<0||h<0&&c>0}function aa(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 o=$r(e[a][r],i);Wr(t,o),n.push(o)}r.push(n)}return r}function na(e,t,i){let r=[];for(let a=0;a<e.length;a++){let n=aa(e[a],t,i);r.push(n)}return r}function oa(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}Wr(t,e)}function sa(e,t,i,r){let a=2**r.z*Ur,n=[r.x*Ur,r.y*Ur],o=[];for(let s of e)for(let e of s){let r=[e.x+n[0],e.y+n[1]];oa(r,t,i,a),o.push(r)}return o}function la(e,t,i,r){let a=2**r.z*Ur,n=[r.x*Ur,r.y*Ur],o=[];for(let s of e){let e=[];for(let i of s){let r=[i.x+n[0],i.y+n[1]];Wr(t,r),e.push(r)}o.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 o)for(let r of e)oa(r,t,i,a)}return o}var ua=class e{constructor(e,t){this.type=ni,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(sr(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=aa(t.coordinates,r,a),o=sa(e.geometry(),i,r,a);if(!Hr(i,r))return!1;for(let e of o)if(!Qr(e,n))return!1}if("MultiPolygon"===t.type){let n=na(t.coordinates,r,a),o=sa(e.geometry(),i,r,a);if(!Hr(i,r))return!1;for(let e of o)if(!ea(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=aa(t.coordinates,r,a),o=la(e.geometry(),i,r,a);if(!Hr(i,r))return!1;for(let e of o)if(!ta(e,n))return!1}if("MultiPolygon"===t.type){let n=na(t.coordinates,r,a),o=la(e.geometry(),i,r,a);if(!Hr(i,r))return!1;for(let e of o)if(!ia(e,n))return!1}return!0}(e,this.geometries)}return!1}eachChild(){}outputDefined(){return!0}},ha=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}},ca=Math.PI/180,da=class{constructor(e){let t=6378.137*ca*1e3,i=Math.cos(e*ca),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,o=1/0;for(let s=0;s<e.length-1;s++){let l=e[s][0],u=e[s][1],h=this.wrap(e[s+1][0]-l)*this.kx,c=(e[s+1][1]-u)*this.ky,d=0;(0!==h||0!==c)&&(d=(this.wrap(t[0]-l)*this.kx*h+(t[1]-u)*this.ky*c)/(h*h+c*c),d>1?(l=e[s+1][0],u=e[s+1][1]):d>0&&(l+=h/this.kx*d,u+=c/this.ky*d)),h=this.wrap(t[0]-l)*this.kx,c=(t[1]-u)*this.ky;let p=h*h+c*c;p<o&&(o=p,i=l,r=u,a=s,n=d)}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 pa(e,t){return t[0]-e[0]}function fa(e){return e[1]-e[0]+1}function ma(e,t){return e[1]>=e[0]&&e[1]<t}function _a(e,t){if(e[0]>e[1])return[null,null];let i=fa(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 ga(e,t){if(!ma(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)Wr(i,e[r]);return i}function ya(e){let t=[1/0,1/0,-1/0,-1/0];for(let i of e)for(let e of i)Wr(t,e);return t}function va(e){return e[0]!==-1/0&&e[1]!==-1/0&&e[2]!==1/0&&e[3]!==1/0}function xa(e,t,i){if(!va(e)||!va(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 ba(e,t,i){let r=i.pointOnLine(t,e);return i.distance(e,r.point)}function wa(e,t,i,r,a){let n=Math.min(ba(e,[i,r],a),ba(t,[i,r],a)),o=Math.min(ba(i,[e,t],a),ba(r,[e,t],a));return Math.min(n,o)}function Ta(e,t,i,r,a){if(!ma(t,e.length)||!ma(r,i.length))return 1/0;let n=1/0;for(let o=t[0];o<t[1];++o){let t=e[o],s=e[o+1];for(let e=r[0];e<r[1];++e){let r=i[e],o=i[e+1];if(Kr(t,s,r,o))return 0;n=Math.min(n,wa(t,s,r,o,a))}}return n}function Sa(e,t,i,r,a){if(!ma(t,e.length)||!ma(r,i.length))return NaN;let n=1/0;for(let o=t[0];o<=t[1];++o)for(let t=r[0];t<=r[1];++t)if(n=Math.min(n,a.distance(e[o],i[t])),0===n)return n;return n}function Da(e,t,i){if(Qr(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,ba(e,[n,t],i)),0===r))return r;let o=i.pointOnLine(a,e);if(r=Math.min(r,i.distance(e,o.point)),0===r)return r}return r}function Ea(e,t,i,r){if(!ma(t,e.length))return NaN;for(let n=t[0];n<=t[1];++n)if(Qr(e[n],i,!0))return 0;let a=1/0;for(let n=t[0];n<t[1];++n){let t=e[n],o=e[n+1];for(let e of i)for(let i=0,n=e.length,s=n-1;i<n;s=i++){let n=e[s],l=e[i];if(Kr(t,o,n,l))return 0;a=Math.min(a,wa(t,o,n,l,r))}}return a}function Ca(e,t){for(let i of e)for(let e of i)if(Qr(e,t,!0))return!0;return!1}function Pa(e,t,i,r=1/0){let a=ya(e),n=ya(t);if(r!==1/0&&xa(a,n,i)>=r)return r;if(Hr(a,n)){if(Ca(e,t))return 0}else if(Ca(t,e))return 0;let o=1/0;for(let s of e)for(let e=0,r=s.length,a=r-1;e<r;a=e++){let r=s[a],n=s[e];for(let e of t)for(let t=0,a=e.length,s=a-1;t<a;s=t++){let a=e[s],l=e[t];if(Kr(r,n,a,l))return 0;o=Math.min(o,wa(r,n,a,l,i))}}return o}function Aa(e,t,i,r,a,n){if(!n)return;let o=xa(ga(r,n),a,i);o<t&&e.push([o,n,[0,0]])}function Ia(e,t,i,r,a,n,o){if(!n||!o)return;let s=xa(ga(r,n),ga(a,o),i);s<t&&e.push([s,n,o])}function Ma(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 o=new ha([[0,[0,e.length-1],[0,0]]],pa),s=ya(i);for(;o.length>0;){let a=o.pop();if(a[0]>=n)continue;let l=a[1],u=t?50:100;if(fa(l)<=u){if(!ma(l,e.length))return NaN;if(t){let t=Ea(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=Da(e[t],i,r);if(n=Math.min(n,a),0===n)return 0}}else{let i=_a(l,t);Aa(o,n,r,e,s,i[0]),Aa(o,n,r,e,s,i[1])}}return n}function Fa(e,t,i,r,a,n=1/0){let o=Math.min(n,a.distance(e[0],i[0]));if(0===o)return o;let s=new ha([[0,[0,e.length-1],[0,i.length-1]]],pa);for(;s.length>0;){let n=s.pop();if(n[0]>=o)continue;let l=n[1],u=n[2],h=t?50:100,c=r?50:100;if(fa(l)<=h&&fa(u)<=c){if(!ma(l,e.length)&&ma(u,i.length))return NaN;let n;if(t&&r)n=Ta(e,l,i,u,a),o=Math.min(o,n);else if(t&&!r){let t=e.slice(l[0],l[1]+1);for(let e=u[0];e<=u[1];++e)if(n=ba(i[e],t,a),o=Math.min(o,n),0===o)return o}else if(!t&&r){let t=i.slice(u[0],u[1]+1);for(let i=l[0];i<=l[1];++i)if(n=ba(e[i],t,a),o=Math.min(o,n),0===o)return o}else n=Sa(e,l,i,u,a),o=Math.min(o,n)}else{let n=_a(l,t),h=_a(u,r);Ia(s,o,a,e,i,n[0],h[0]),Ia(s,o,a,e,i,n[0],h[1]),Ia(s,o,a,e,i,n[1],h[0]),Ia(s,o,a,e,i,n[1],h[1])}}return o}function za(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 ka=class e{constructor(e,t){this.type=ri,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(sr(t[1])){let i=t[1];if("FeatureCollection"===i.type)return new e(i,i.features.map(e=>za(e.geometry)).flat());if("Feature"===i.type)return new e(i,za(i.geometry));if("type"in i&&"coordinates"in i)return new e(i,za(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=>Gr([t.x,t.y],e.canonical));if(0===i.length)return NaN;let a=new da(r[0][1]),n=1/0;for(let o of t){switch(o.type){case"Point":n=Math.min(n,Fa(r,!1,[o.coordinates],!1,a,n));break;case"LineString":n=Math.min(n,Fa(r,!1,o.coordinates,!0,a,n));break;case"Polygon":n=Math.min(n,Ma(r,!1,o.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=>Gr([t.x,t.y],e.canonical));if(0===i.length)return NaN;let a=new da(r[0][1]),n=1/0;for(let o of t){switch(o.type){case"Point":n=Math.min(n,Fa(r,!0,[o.coordinates],!1,a,n));break;case"LineString":n=Math.min(n,Fa(r,!0,o.coordinates,!0,a,n));break;case"Polygon":n=Math.min(n,Ma(r,!0,o.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=wr(i,0).map(t=>t.map(t=>t.map(t=>Gr([t.x,t.y],e.canonical)))),a=new da(r[0][0][0][1]),n=1/0;for(let o of t)for(let e of r){switch(o.type){case"Point":n=Math.min(n,Ma([o.coordinates],!1,e,a,n));break;case"LineString":n=Math.min(n,Ma(o.coordinates,!0,e,a,n));break;case"Polygon":n=Math.min(n,Pa(e,o.coordinates,a,n))}if(0===n)return n}return n}(e,this.geometries)}return NaN}eachChild(){}outputDefined(){return!0}},Ra=class e{constructor(e){this.key=e,this.type=ui}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?ji(t,this.key)??null:null}eachChild(){}outputDefined(){return!1}},La={"==":Rr,"!=":Lr,">":Or,"<":Br,">=":Vr,"<=":jr,array:Er,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,ri),a=i.parse(t[2],2,gi(i.expectedType||ui));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 er(`Array index out of bounds: ${t} < 0.`,this.key);if(t>=i.length)throw new er(`Array index out of bounds: ${t} > ${i.length-1}.`,this.key);if(t!==Math.floor(t))throw new er(`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:Er,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,ni);if(!n)return null;let o=i.parse(t[e+1],e+1,r);if(!o)return null;a.push([n,o]),r||=o.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:Mr,collator:Nr,format:yr,image:class e{constructor(e){this.type=mi,this.input=e}static parse(t,i){if(2!==t.length)return i.error("Expected two arguments.");let r=i.parse(t[1],1,ai);return r?new e(r):i.error("No image name provided.")}evaluate(e){let t=this.input.evaluate(e),i=rr.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=ni}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,ui),a=i.parse(t[2],2,ui);return r&&a?bi(r.type,[ni,ai,ri,ii,ui])?new e(r,a,i.key):i.error(`Expected first argument to be of type boolean, string, number or null, but found ${yi(r.type)} instead`):null}evaluate(e){let t=this.needle.evaluate(e),i=this.haystack.evaluate(e);if(!i)return!1;if(!wi(t,["boolean","string","number","null"]))throw new er(`Expected first argument to be of type boolean, string, number or null, but found ${yi(lr(t))} instead.`,this.key);if(!wi(i,["string","array"]))throw new er(`Expected second argument to be of type array or string, but found ${yi(lr(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=ri}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,ui),a=i.parse(t[2],2,ui);if(!r||!a)return null;if(!bi(r.type,[ni,ai,ri,ii,ui]))return i.error(`Expected first argument to be of type boolean, string, number or null, but found ${yi(r.type)} instead`);if(4===t.length){let n=i.parse(t[3],3,ri);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(!wi(i,["boolean","string","number","null"]))throw new er(`Expected first argument to be of type boolean, string, number or null, but found ${yi(lr(i))} instead.`,this.key);if(this.fromIndex&&(t=this.fromIndex.evaluate(e)),wi(r,["string"])){let e=r.indexOf(i,t);return-1===e?-1:[...r.slice(0,e)].length}if(wi(r,["array"]))return r.indexOf(i,t);throw new er(`Expected second argument to be of type array or string, but found ${yi(lr(r))} instead.`,this.key)}eachChild(e){e(this.needle),e(this.haystack),this.fromIndex&&e(this.fromIndex)}outputDefined(){return!1}},interpolate:mr,"interpolate-hcl":mr,"interpolate-lab":mr,length:class e{constructor(e,t){this.input=e,this.key=t,this.type=ri}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 ${yi(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 er(`Expected value to be of type string or array, but found ${yi(lr(t))} instead.`,this.key)}eachChild(e){e(this.input)}outputDefined(){return!1}},let:Ar,literal:hr,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={},o=[];for(let e=2;e<t.length-1;e+=2){let s=t[e],l=t[e+1];Array.isArray(s)||(s=[s]);let u=i.concat(e);if(0===s.length)return u.error("Expected at least one branch label.");for(let e of s){if("number"!=typeof e&&"string"!=typeof e)return u.error("Branch labels must be numbers or strings.");if("number"==typeof e&&Math.abs(e)>2**53-1)return u.error(`Branch labels must be integers no larger than ${2**53-1}.`);if("number"==typeof e&&Math.floor(e)!==e)return u.error("Numeric branch labels must be integer values.");if(r){if(u.checkSubtype(r,lr(e)))return null}else r=lr(e);if(void 0!==n[String(e)])return u.error("Branch labels must be unique.");n[String(e)]=o.length}let h=i.parse(l,e,a);if(!h)return null;a||=h.type,o.push(h)}let s=i.parse(t[1],1,ui);if(!s)return null;let l=i.parse(t[t.length-1],t.length-1,a);return!l||"value"!==s.type.kind&&i.concat(1).checkSubtype(r,s.type)?null:new e(r,a,s,n,o,l)}evaluate(e){let t=this.input.evaluate(e);return(lr(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:Er,"number-format":class e{constructor(e,t,i,r,a,n){this.type=ai,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,ri);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,ai),!n))return null;let o=null;if(a.currency&&(o=i.parse(a.currency,1,ai),!o))return null;let s=null;if(a.unit&&(s=i.parse(a.unit,1,ai),!s))return null;if(o&&s)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,ri),!l))return null;let u=null;return a["max-fraction-digits"]&&(u=i.parse(a["max-fraction-digits"],1,ri),!u)?null:new e(r,n,o,s,l,u)}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:Er,semiliteral:class e{constructor(e){let t=null;for(let i of e){if(t){if(t===i.type)continue;t=ui;break}t=i.type}this.type=gi(t??ui,e.length),this.arr=e}static parse(t,i){if(2!==t.length)return i.error(`'semiliteral' expression requires exactly one argument, but found ${t.length-1} instead.`);if(!sr(t[1]))return i.error(`invalid value of type "${typeof t[1]}"`);let r=t[1],a=lr(r);if("array"===a.kind){let t=r,a=i.concat(1),n=[];for(let e=0;e<t.length;e++){let i=a.parse(t[e],e,ui);if(!i)return null;n.push(i)}return new e(n)}return new hr(a,r)}evaluate(e){return this.arr.map(t=>t.evaluate(e))}eachChild(e){this.arr.forEach(e)}outputDefined(){return this.arr.every(e=>e.outputDefined())}},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,ui),a=i.parse(t[2],2,ri);if(!r||!a)return null;if(!bi(r.type,[gi(ui),ai,ui]))return i.error(`Expected first argument to be of type array or string, but found ${yi(r.type)} instead`);if(4===t.length){let n=i.parse(t[3],3,ri);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)),wi(i,["string"]))return[...i].slice(r,t).join("");if(wi(i,["array"]))return i.slice(r,t);throw new er(`Expected first argument to be of type array or string, but found ${yi(lr(i))} instead.`,this.key)}eachChild(e){e(this.input),e(this.beginIndex),this.endIndex&&e(this.endIndex)}outputDefined(){return!1}},step:fr,string:Er,"to-boolean":Pr,"to-color":Pr,"to-number":Pr,"to-string":Pr,var:Ir,within:ua,distance:ka,"global-state":Ra},Ba=class extends Error{constructor(e,t){super(t),this.message=t,this.key=e}},Oa=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)}},ja=class e{constructor(e,t,i=[],r,a=new Oa,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 null==t?this._parse(e,a):this.concat(t,i,r)._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 Er(t,[e],i):"coerce"===r?new Pr(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 hr)&&"resolvedImage"!==i.type.kind&&this._isConstant(i)){let t=new dr;try{i=new hr(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 Ba(i,e))}checkSubtype(e,t){let i=xi(e,t);return i&&this.error(i),i}},Va=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,o=Array.isArray(a)?[[a[1],a[2]]]:a.overloads,s=o.filter(([e])=>!Array.isArray(e)||e.length===t.length-1),l=null;for(let[u,h]of s){l=new ja(i.registry,Za,i.path,null,i.scope);let a=[],o=!1;for(let e=1;e<t.length;e++){let i=t[e],r=Array.isArray(u)?u[e-1]:u.type,n=l.parse(i,1+a.length,r);if(!n){o=!0;break}a.push(n)}if(!o)if(Array.isArray(u)&&u.length!==a.length)l.error(`Expected ${u.length} arguments, but found ${a.length} instead.`);else{for(let e=0;e<a.length;e++){let t=Array.isArray(u)?u[e]:u.type,i=a[e];l.concat(e+1).checkSubtype(t,i.type)}if(0===l.errors.length)return new e(r,n,h,a,i.key)}}if(1===s.length)i.errors.push(...l.errors);else{let e=(s.length?s:o).map(([e])=>function(e){return Array.isArray(e)?`(${e.map(yi).join(", ")})`:`(${yi(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(yi(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 Na(e,[t,i,r,a],n){t=t.evaluate(e),i=i.evaluate(e),r=r.evaluate(e);let o=a?a.evaluate(e):1,s=or(t,i,r,o);if(s)throw new er(s,n);return new Wi(t/255,i/255,r/255,o,!1)}function Ua(e,t){return e in t&&void 0!==t[e]}function $a(e,t){let i=t[e];return void 0===i?null:i}function Ga(e){return{type:e}}function Za(e){if(e instanceof Ir)return Za(e.boundExpression);if(e instanceof Va&&"error"===e.name||e instanceof Nr||e instanceof ua||e instanceof ka||e instanceof Ra)return!1;let t=e instanceof Pr||e instanceof Er,i=!0;return e.eachChild(e=>{i&&=t?Za(e):e instanceof hr}),!!i&&qa(e)&&Ha(e,["zoom","heatmap-density","elevation","line-progress","accumulated","is-supported-script"])}function qa(e){if(e instanceof Va&&("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 ua||e instanceof ka)return!1;let t=!0;return e.eachChild(e=>{t&&!qa(e)&&(t=!1)}),t}function Wa(e){if(e instanceof Va&&"feature-state"===e.name)return!1;let t=!0;return e.eachChild(e=>{t&&!Wa(e)&&(t=!1)}),t}function Ha(e,t){if(e instanceof Va&&t.indexOf(e.name)>=0)return!1;let i=!0;return e.eachChild(e=>{i&&!Ha(e,t)&&(i=!1)}),i}function Xa(e){return"data-driven"===e["property-type"]||"cross-faded-data-driven"===e["property-type"]}function Ya(e){return!!e.expression&&e.expression.parameters.indexOf("zoom")>-1}function Ka(e){return!!e.expression&&e.expression.interpolated}Va.register(La,{error:[{kind:"error"},[ai],(e,[t],i)=>{throw new er(t.evaluate(e),i)}],typeof:[ai,[ui],(e,[t])=>yi(lr(t.evaluate(e)))],"to-rgba":[gi(ri,4),[oi],(e,[t])=>{let[i,r,a,n]=t.evaluate(e).rgb;return[255*i,255*r,255*a,n]}],rgb:[oi,[ri,ri,ri],Na],rgba:[oi,[ri,ri,ri,ri],Na],has:{type:ni,overloads:[[[ai],(e,[t])=>Ua(t.evaluate(e),e.properties())],[[ai,li],(e,[t,i])=>Ua(t.evaluate(e),i.evaluate(e))]]},get:{type:ui,overloads:[[[ai],(e,[t])=>$a(t.evaluate(e),e.properties())],[[ai,li],(e,[t,i])=>$a(t.evaluate(e),i.evaluate(e))]]},"feature-state":[ui,[ai],(e,[t])=>$a(t.evaluate(e),e.featureState||{})],properties:[li,[],e=>e.properties()],"geometry-type":[ai,[],e=>e.geometryType()],id:[ui,[],e=>e.id()],zoom:[ri,[],e=>e.globals.zoom],"heatmap-density":[ri,[],e=>e.globals.heatmapDensity||0],elevation:[ri,[],e=>e.globals.elevation||0],"line-progress":[ri,[],e=>e.globals.lineProgress||0],accumulated:[ui,[],e=>void 0===e.globals.accumulated?null:e.globals.accumulated],"+":[ri,Ga(ri),(e,t)=>{let i=0;for(let r of t)i+=r.evaluate(e);return i}],"*":[ri,Ga(ri),(e,t)=>{let i=1;for(let r of t)i*=r.evaluate(e);return i}],"-":{type:ri,overloads:[[[ri,ri],(e,[t,i])=>t.evaluate(e)-i.evaluate(e)],[[ri],(e,[t])=>-t.evaluate(e)]]},"/":[ri,[ri,ri],(e,[t,i])=>t.evaluate(e)/i.evaluate(e)],"%":[ri,[ri,ri],(e,[t,i])=>t.evaluate(e)%i.evaluate(e)],ln2:[ri,[],()=>Math.LN2],pi:[ri,[],()=>Math.PI],e:[ri,[],()=>Math.E],"^":[ri,[ri,ri],(e,[t,i])=>t.evaluate(e)**+i.evaluate(e)],sqrt:[ri,[ri],(e,[t])=>Math.sqrt(t.evaluate(e))],log10:[ri,[ri],(e,[t])=>Math.log(t.evaluate(e))/Math.LN10],ln:[ri,[ri],(e,[t])=>Math.log(t.evaluate(e))],log2:[ri,[ri],(e,[t])=>Math.log(t.evaluate(e))/Math.LN2],sin:[ri,[ri],(e,[t])=>Math.sin(t.evaluate(e))],cos:[ri,[ri],(e,[t])=>Math.cos(t.evaluate(e))],tan:[ri,[ri],(e,[t])=>Math.tan(t.evaluate(e))],asin:[ri,[ri],(e,[t])=>Math.asin(t.evaluate(e))],acos:[ri,[ri],(e,[t])=>Math.acos(t.evaluate(e))],atan:[ri,[ri],(e,[t])=>Math.atan(t.evaluate(e))],min:[ri,Ga(ri),(e,t)=>Math.min(...t.map(t=>t.evaluate(e)))],max:[ri,Ga(ri),(e,t)=>Math.max(...t.map(t=>t.evaluate(e)))],abs:[ri,[ri],(e,[t])=>Math.abs(t.evaluate(e))],round:[ri,[ri],(e,[t])=>{let i=t.evaluate(e);return i<0?-Math.round(-i):Math.round(i)}],floor:[ri,[ri],(e,[t])=>Math.floor(t.evaluate(e))],ceil:[ri,[ri],(e,[t])=>Math.ceil(t.evaluate(e))],"filter-==":[ni,[ai,ui],(e,[t,i])=>e.properties()[t.value]===i.value],"filter-id-==":[ni,[ui],(e,[t])=>e.id()===t.value],"filter-type-==":[ni,[ai],(e,[t])=>e.geometryType()===t.value],"filter-<":[ni,[ai,ui],(e,[t,i])=>{let r=e.properties()[t.value],a=i.value;return typeof r==typeof a&&r<a}],"filter-id-<":[ni,[ui],(e,[t])=>{let i=e.id(),r=t.value;return typeof i==typeof r&&i<r}],"filter->":[ni,[ai,ui],(e,[t,i])=>{let r=e.properties()[t.value],a=i.value;return typeof r==typeof a&&r>a}],"filter-id->":[ni,[ui],(e,[t])=>{let i=e.id(),r=t.value;return typeof i==typeof r&&i>r}],"filter-<=":[ni,[ai,ui],(e,[t,i])=>{let r=e.properties()[t.value],a=i.value;return typeof r==typeof a&&r<=a}],"filter-id-<=":[ni,[ui],(e,[t])=>{let i=e.id(),r=t.value;return typeof i==typeof r&&i<=r}],"filter->=":[ni,[ai,ui],(e,[t,i])=>{let r=e.properties()[t.value],a=i.value;return typeof r==typeof a&&r>=a}],"filter-id->=":[ni,[ui],(e,[t])=>{let i=e.id(),r=t.value;return typeof i==typeof r&&i>=r}],"filter-has":[ni,[ui],(e,[t])=>{let i=t.value,r=e.properties();return i in r&&void 0!==r[i]}],"filter-has-id":[ni,[],e=>null!==e.id()&&void 0!==e.id()],"filter-type-in":[ni,[gi(ai)],(e,[t])=>t.value.indexOf(e.geometryType())>=0],"filter-id-in":[ni,[gi(ui)],(e,[t])=>t.value.indexOf(e.id())>=0],"filter-in-small":[ni,[ai,gi(ui)],(e,[t,i])=>i.value.indexOf(e.properties()[t.value])>=0],"filter-in-large":[ni,[ai,gi(ui)],(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:ni,overloads:[[[ni,ni],(e,[t,i])=>t.evaluate(e)&&i.evaluate(e)],[Ga(ni),(e,t)=>{for(let i of t)if(!i.evaluate(e))return!1;return!0}]]},any:{type:ni,overloads:[[[ni,ni],(e,[t,i])=>t.evaluate(e)||i.evaluate(e)],[Ga(ni),(e,t)=>{for(let i of t)if(i.evaluate(e))return!0;return!1}]]},"!":[ni,[ni],(e,[t])=>!t.evaluate(e)],"is-supported-script":[ni,[ai],(e,[t])=>{let i=e.globals&&e.globals.isSupportedScript;return!i||i(t.evaluate(e))}],upcase:[ai,[ai],(e,[t])=>t.evaluate(e).toUpperCase()],downcase:[ai,[ai],(e,[t])=>t.evaluate(e).toLowerCase()],concat:[ai,Ga(ui),(e,t)=>t.map(t=>ur(t.evaluate(e))).join("")],split:[gi(ai),[ai,ai],(e,[t,i])=>t.evaluate(e).split(i.evaluate(e))],join:[ai,[gi(ai),ai],(e,[t,i])=>t.evaluate(e).join(i.evaluate(e))],"resolved-locale":[ai,[hi],(e,[t])=>t.evaluate(e).resolvedLocale()]});var Ja=/^(.*)-transition$/;function Qa(e,...t){for(let i of t)for(let t in i)e[t]=i[t];return e}function en(e){return e instanceof Number?"number":e instanceof String?"string":e instanceof Boolean?"boolean":Array.isArray(e)?"array":null===e?"null":typeof e}function tn(e){return"object"==typeof e&&!!e&&!Array.isArray(e)&&lr(e)===li}function rn(e){return e}function an(e,t){let i=e.stops&&"object"==typeof e.stops[0][0],r=i||void 0!==e.property,a=i||!r,n=e.type||(Ka(t)?"exponential":"interval"),o=function(e){switch(e.type){case"color":return Wi.parse;case"padding":return Ki.parse;case"numberArray":return Ji.parse;case"colorArray":return Qi.parse;default:return null}}(t);if(o&&((e=Qa({},e)).stops&&(e.stops=e.stops.map(e=>[e[0],o(e[1])])),e.default?e.default=o(e.default):e.default=o(t.default)),e.colorSpace&&!function(e){return"rgb"===e||"hcl"===e||"lab"===e}(e.colorSpace))throw Error(`Unknown color space: "${e.colorSpace}"`);let s,l,u=function(e){switch(e){case"exponential":return ln;case"interval":return sn;case"categorical":return on;case"identity":return un;default:throw Error(`Unknown function type "${e}"`)}}(n);if("categorical"===n){s=Object.create(null);for(let t of e.stops)s[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,an(i[e],t)]);let n={name:"linear"};return{kind:"composite",interpolationType:n,interpolationFactor:mr.interpolationFactor.bind(void 0,n),zoomStops:a.map(e=>e[0]),evaluate:({zoom:i},r)=>ln({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:mr.interpolationFactor.bind(void 0,i),zoomStops:e.stops.map(e=>e[0]),evaluate:({zoom:i})=>u(e,t,i,s,l)}}return{kind:"source",evaluate(i,r){let a=r&&r.properties?r.properties[e.property]:void 0;return void 0===a?nn(e.default,t.default):u(e,t,a,s,l)}}}function nn(e,t,i){return void 0!==e?e:void 0!==t?t:void 0!==i?i:void 0}function on(e,t,i,r,a){return nn(typeof i===a?r[i]:void 0,e.default,t.default)}function sn(e,t,i){if("number"!==en(i))return nn(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=pr(e.stops.map(e=>e[0]),i,"");return e.stops[a][1]}function ln(e,t,i){let r=void 0===e.base?1:e.base;if("number"!==en(i))return nn(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=pr(e.stops.map(e=>e[0]),i,""),o=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]),s=e.stops[n][1],l=e.stops[n+1][1],u=gr[t.type]||rn;return"function"==typeof s.evaluate?{evaluate(...t){let i=s.evaluate.apply(void 0,t),r=l.evaluate.apply(void 0,t);if(void 0!==i&&void 0!==r)return u(i,r,o,e.colorSpace)}}:u(s,l,o,e.colorSpace)}function un(e,t,i){switch(t.type){case"color":i=Wi.parse(i);break;case"formatted":i=Yi.fromString(i.toString());break;case"resolvedImage":i=rr.fromString(i.toString());break;case"padding":i=Ki.parse(i);break;case"colorArray":i=Qi.parse(i);break;case"numberArray":i=Ji.parse(i);break;default:en(i)!==t.type&&("enum"!==t.type||!t.values[i])&&(i=void 0)}return nn(i,e.default,t.default)}function hn(e){return{result:"success",value:e}}function cn(e){return{result:"error",value:e}}var dn=class{constructor(e,t,i,r){this.expression=e,this._warningHistory={},this._evaluator=new dr,this._defaultValue=i?Tn(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=Sn(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=Sn(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 er(`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 er?e.path:"",i=`${t}|${e.message}`;return this._warningHistory[i]||(this._warningHistory[i]=!0,typeof console<"u"&&console.warn(pn(this._rootKey,t,e.message,this._defaultValue))),this._defaultValue}}};function pn(e,t,i,r){return`${e}${t}: ${i}${null==r?"":` Falling back to ${String(r)}.`}`}function fn(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 mn(e){return Array.isArray(e)&&e.length>0&&"string"==typeof e[0]&&e[0]in La}function _n(e,t,i,r){fn(t);let a=new ja(La,Za,[],i?function(e){let t={color:oi,string:ai,number:ri,enum:ai,boolean:ni,formatted:ci,padding:di,numberArray:fi,colorArray:pi,projectionDefinition:si,resolvedImage:mi,variableAnchorOffsetCollection:_i};return"array"===e.type?gi(t[e.value]||ui,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?hn(new dn(n,t,i,r)):cn(a.errors)}var gn=class{constructor(e,t,i){this.kind=e,this._styleExpression=t,this.isStateDependent="constant"!==e&&!Wa(t.expression),this.globalStateRefs=wn(t.expression),this._globalState=i}evaluateWithoutErrorHandling(e,t,i,r,a,n){return this._globalState&&(e=Sn(e,this._globalState)),this._styleExpression.evaluateWithoutErrorHandling(e,t,i,r,a,n)}evaluate(e,t,i,r,a,n){return this._globalState&&(e=Sn(e,this._globalState)),this._styleExpression.evaluate(e,t,i,r,a,n)}},yn=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=wn(t.expression),this.interpolationType=r,this._globalState=a}evaluateWithoutErrorHandling(e,t,i,r,a,n){return this._globalState&&(e=Sn(e,this._globalState)),this._styleExpression.evaluateWithoutErrorHandling(e,t,i,r,a,n)}evaluate(e,t,i,r,a,n){return this._globalState&&(e=Sn(e,this._globalState)),this._styleExpression.evaluate(e,t,i,r,a,n)}interpolationFactor(e,t,i){return this.interpolationType?mr.interpolationFactor(this.interpolationType,e,t,i):0}};function vn(e,t,i,r){let a=_n(e,t,i,r);if("error"===a.result)return a;let n=a.value.expression,o=qa(n);if(!o&&!Xa(i))return cn([new Ba("","data expressions not supported")]);let s=Ha(n,["zoom"]);if(!s&&!Ya(i))return cn([new Ba("","zoom expressions not supported")]);let l=bn(n);if(!l&&!s)return cn([new Ba("",'"zoom" expression may only be used as input to a top-level "step" or "interpolate" expression.')]);if(l instanceof Ba)return cn([l]);if(l instanceof mr&&!Ka(i))return cn([new Ba("",'"interpolate" expressions cannot be used with this property')]);if(!l)return hn(new gn(o?"constant":"source",a.value,r));let u=l instanceof mr?l.interpolation:void 0;return hn(new yn(o?"camera":"composite",a.value,l.labels,u,r))}var xn=class e{constructor(e,t,i){this.isStateDependent=!1,this.globalStateRefs=/* @__PURE__ */new Set,this._globalState=null,fn(t),this._parameters=e,this._specification=i,this._rootKey=t,this._defaultValue=Tn(i),this._warningHistory={};let r=an(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(pn(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 bn(e){let t=null;if(e instanceof Ar)t=bn(e.result);else if(e instanceof Mr){for(let i of e.args)if(t=bn(i),t)break}else(e instanceof fr||e instanceof mr)&&e.input instanceof Va&&"zoom"===e.input.name&&(t=e);return t instanceof Ba||e.eachChild(e=>{let i=bn(e);i instanceof Ba?t=i:!t&&i?t=new Ba("",'"zoom" expression may only be used as input to a top-level "step" or "interpolate" expression.'):t&&i&&t!==i&&(t=new Ba("",'Only one zoom-based "step" or "interpolate" subexpression may be used in an expression.'))}),t}function wn(e,t=/* @__PURE__ */new Set){return e instanceof Ra&&t.add(e.key),e.eachChild(e=>{wn(e,t)}),t}function Tn(e){if("color"===e.type&&tn(e.default))return new Wi(0,0,0,0);switch(e.type){case"color":return Wi.parse(e.default)||null;case"padding":return Ki.parse(e.default)||null;case"numberArray":return Ji.parse(e.default)||null;case"colorArray":return Qi.parse(e.default)||null;case"variableAnchorOffsetCollection":return ir.parse(e.default)||null;case"projectionDefinition":return ar.parse(e.default)||null;default:return void 0===e.default?null:e.default}}function Sn(e,t){let{zoom:i,heatmapDensity:r,elevation:a,lineProgress:n,isSupportedScript:o,accumulated:s}=e??{};return{zoom:i,heatmapDensity:r,elevation:a,lineProgress:n,isSupportedScript:o,accumulated:s,globalState:t}}function Dn(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=Dn(i);if("expression"===e)return"expression";"legacy"===e&&(t=!0)}return t?"legacy":"neutral"}(e.slice(1));default:return"expression"}}function En(e){return"legacy"!==Dn(e)}function Cn(e){return"$type"===e?["geometry-type"]:"$id"===e?["id"]:["get",e]}function Pn(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],Cn(e[1]),e[2]];case"in":case"!in":{if(e.length<2||"string"!=typeof e[1])return null;let t=["in",Cn(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 An(e,t,i){let r=i[e];return Array.isArray(r)?En(r)?In(r,t.concat(e)):{path:t.concat(e),legacyFilter:r}:null}function In(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=An(i,t,e);if(r)return r}break;case"!":{let i=An(1,t,e);if(i)return i;break}case"case":for(let i=1;i<e.length-1;i+=2){let r=An(i,t,e);if(r)return r}}return null}var Mn={type:"boolean",default:!1,transition:!1,"property-type":"data-driven",expression:{interpolated:!1,parameters:["zoom","feature"]}};function Fn(e,t,i){if(null==e)return{filter:()=>!0,needGeometry:!1,getGlobalStateRefs:()=>/* @__PURE__ */new Set};En(e)?function(e,t){let i=In(e);if(!i||typeof console>"u")return;let r=i.path.map(e=>`[${e}]`).join("");console.warn(`${t}${r}: ${Pn(i.legacyFilter)}`)}(e,t):e=Rn(e);let r=_n(e,t,Mn,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:kn(e),getGlobalStateRefs:()=>wn(r.value.expression)}}function zn(e,t){return e<t?-1:+(e>t)}function kn(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(kn(e[t]))return!0;return!1}function Rn(e){if(!e)return!0;let t=e[0];return e.length<=1?"any"!==t:"=="===t?Ln(e[1],e[2],"=="):"!="===t?jn(Ln(e[1],e[2],"==")):"<"===t||">"===t||"<="===t||">="===t?Ln(e[1],e[2],t):"any"===t?function(e){return["any"].concat(e.map(Rn))}(e.slice(1)):"all"===t?["all"].concat(e.slice(1).map(Rn)):"none"===t?["all"].concat(e.slice(1).map(Rn).map(jn)):"in"===t?Bn(e[1],e.slice(2)):"!in"===t?jn(Bn(e[1],e.slice(2))):"has"===t?On(e[1]):"!has"!==t||jn(On(e[1]))}function Ln(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 Bn(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(zn)]]:["filter-in-small",e,["literal",t]]}}function On(e){switch(e){case"$type":return!0;case"$id":return["filter-has-id"];default:return["filter-has",e]}}function jn(e){return["!",e]}function Vn(e){let t=e.key,i=e.value;return i?[new ti(t,i,"constants have been deprecated as of v8")]:[]}function Nn(e){return e instanceof Number||e instanceof String||e instanceof Boolean?e.valueOf():e}function Un(e){if(Array.isArray(e))return e.map(Un);if(e instanceof Object&&!(e instanceof Number||e instanceof String||e instanceof Boolean)){let t={};for(let i in e)t[i]=Un(e[i]);return t}return Nn(e)}function $n(e){let t=e.key,i=e.value,r=e.valueSpec||{},a=e.objectElementValidators||{},n=e.style,o=e.styleSpec,s=e.validateSpec,l=[],u=en(i);if("object"!==u)return[new ti(t,i,`object expected, ${u} found`)];for(let h in i){let e,u=h.split(".")[0],c=ji(r,u)||r["*"];if(ji(a,u))e=a[u];else if(ji(r,u)){if(void 0===i[h])continue;e=s}else if(a["*"])e=a["*"];else{if(!r["*"]){l.push(new ti(t,i[h],`unknown property "${h}"`));continue}e=s}l=l.concat(e({key:(t&&`${t}.`)+h,value:i[h],valueSpec:c,style:n,styleSpec:o,object:i,objectKey:h,validateSpec:s},i))}for(let h in r)a[h]||r[h].required&&void 0===r[h].default&&void 0===i[h]&&l.push(new ti(t,i,`missing required property "${h}"`));return l}function Gn(e){let t=e.value,i=e.valueSpec,r=e.validateSpec,a=e.style,n=e.styleSpec,o=e.key,s=e.arrayElementValidator||r;if("array"!==en(t))return[new ti(o,t,`array expected, ${en(t)} found`)];if(i.length&&t.length!==i.length)return[new ti(o,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"===en(i.value)&&(l=i.value);let u=[];for(let h=0;h<t.length;h++)u=u.concat(s({array:t,arrayIndex:h,value:t[h],valueSpec:l,validateSpec:e.validateSpec,style:a,styleSpec:n,key:`${o}[${h}]`}));return u}function Zn(e){let t=e.key,i=e.value,r=e.valueSpec,a=en(i);return"number"===a&&i!=i&&(a="NaN"),"number"===a?"minimum"in r&&i<r.minimum?[new ti(t,i,`${i} is less than the minimum value ${r.minimum}`)]:"maximum"in r&&i>r.maximum?[new ti(t,i,`${i} is greater than the maximum value ${r.maximum}`)]:[]:[new ti(t,i,`number expected, ${a} found`)]}function qn(e){let t,i,r,a=e.valueSpec,n=Nn(e.value.type),o={},s="categorical"!==n&&void 0===e.value.property,l=!s,u="array"===en(e.value.stops)&&"array"===en(e.value.stops[0])&&"object"===en(e.value.stops[0][0]),h=$n({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 ti(e.key,e.value,'identity function may not have a "stops" property')];let t=[],i=e.value;return t=t.concat(Gn({key:e.key,value:i,valueSpec:e.valueSpec,validateSpec:e.validateSpec,style:e.style,styleSpec:e.styleSpec,arrayElementValidator:c})),"array"===en(i)&&0===i.length&&t.push(new ti(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&&s&&h.push(new ti(e.key,e.value,'missing required property "property"')),"identity"!==n&&!e.value.stops&&h.push(new ti(e.key,e.value,'missing required property "stops"')),"exponential"===n&&e.valueSpec.expression&&!Ka(e.valueSpec)&&h.push(new ti(e.key,e.value,"exponential functions not supported")),e.styleSpec.$version>=8&&(l&&!Xa(e.valueSpec)?h.push(new ti(e.key,e.value,"property functions not supported")):s&&!Ya(e.valueSpec)&&h.push(new ti(e.key,e.value,"zoom functions not supported"))),("categorical"===n||u)&&void 0===e.value.property&&h.push(new ti(e.key,e.value,'"property" property is required')),h;function c(e){let t=[],n=e.value,s=e.key;if("array"!==en(n))return[new ti(s,n,`array expected, ${en(n)} found`)];if(2!==n.length)return[new ti(s,n,`array length 2 expected, length ${n.length} found`)];if(u){if("object"!==en(n[0]))return[new ti(s,n,`object expected, ${en(n[0])} found`)];if(void 0===n[0].zoom)return[new ti(s,n,"object stop key must have zoom")];if(void 0===n[0].value)return[new ti(s,n,"object stop key must have value")];if(r&&r>Nn(n[0].zoom))return[new ti(s,n[0].zoom,"stop zoom values must appear in ascending order")];Nn(n[0].zoom)!==r&&(r=Nn(n[0].zoom),i=void 0,o={}),t=t.concat($n({key:`${s}[0]`,value:n[0],valueSpec:{zoom:{}},validateSpec:e.validateSpec,style:e.style,styleSpec:e.styleSpec,objectElementValidators:{zoom:Zn,value:d}}))}else t=t.concat(d({key:`${s}[0]`,value:n[0],valueSpec:{},validateSpec:e.validateSpec,style:e.style,styleSpec:e.styleSpec},n));return mn(Un(n[1]))?t.concat([new ti(`${s}[1]`,n[1],"expressions are not allowed in function stops.")]):t.concat(e.validateSpec({key:`${s}[1]`,value:n[1],valueSpec:a,validateSpec:e.validateSpec,style:e.style,styleSpec:e.styleSpec}))}function d(e,r){let s=en(e.value),l=Nn(e.value),u=null===e.value?r:e.value;if(t){if(s!==t)return[new ti(e.key,u,`${s} stop domain type must match previous stop domain type ${t}`)]}else t=s;if("number"!==s&&"string"!==s&&"boolean"!==s)return[new ti(e.key,u,"stop domain value must be a number, string, or boolean")];if("number"!==s&&"categorical"!==n){let t=`number expected, ${s} found`;return Xa(a)&&void 0===n&&(t+='\nIf you intended to use a categorical function, specify `"type": "categorical"`.'),[new ti(e.key,u,t)]}return"categorical"!==n||"number"!==s||isFinite(l)&&Math.floor(l)===l?"categorical"!==n&&"number"===s&&void 0!==i&&l<i?[new ti(e.key,u,"stop domain values must appear in ascending order")]:(i=l,"categorical"===n&&l in o?[new ti(e.key,u,"stop domain values must be unique")]:(o[l]=!0,[])):[new ti(e.key,u,`integer expected, found ${l}`)]}}function Wn(e){let t=("property"===e.expressionContext?vn:_n)(Un(e.value),e.key,e.valueSpec);if("error"===t.result)return t.value.map(t=>new ti(`${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 ti(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 ti(e.key,e.value,'"feature-state" data expressions are not supported with layout properties.')];if("filter"===e.expressionContext&&!Wa(i))return[new ti(e.key,e.value,'"feature-state" data expressions are not supported with filters.')];if(e.expressionContext&&0===e.expressionContext.indexOf("cluster")){if(!Ha(i,["zoom","feature-state"]))return[new ti(e.key,e.value,'"zoom" and "feature-state" expressions are not supported with cluster properties.')];if("cluster-initial"===e.expressionContext&&!qa(i))return[new ti(e.key,e.value,"Feature data expressions are not supported with initial expression part of cluster properties.")]}return[]}function Hn(e){let t=e.key,i=e.value,r=en(i);return"string"===r?Wi.parse(String(i))?[]:[new ti(t,i,`color expected, "${i}" found`)]:[new ti(t,i,`color expected, ${r} found`)]}function Xn(e){let t=e.key,i=e.value,r=e.valueSpec,a=[];return Array.isArray(r.values)?-1===r.values.indexOf(Nn(i))&&a.push(new ti(t,i,`expected one of [${r.values.join(", ")}], ${JSON.stringify(i)} found`)):-1===Object.keys(r.values).indexOf(Nn(i))&&a.push(new ti(t,i,`expected one of [${Object.keys(r.values).join(", ")}], ${JSON.stringify(i)} found`)),a}function Yn(e,t){let i=e;for(let r of t)i=i[r];return i}function Kn(e,t){let i=In(t);return i?[new ti(`${e.key}${i.path.map(e=>`[${e}]`).join("")}`,Yn(e.value,i.path),Pn(i.legacyFilter),null,"warning")]:[]}function Jn(e){let t=Un(e.value);return En(t)?[...Kn(e,t),...Wn(Qa({},e,{expressionContext:"filter",valueSpec:{value:"boolean"}}))]:Qn(e)}function Qn(e){let t=e.value,i=e.key;if("array"!==en(t))return[new ti(i,t,`array expected, ${en(t)} found`)];let r,a=e.styleSpec,n=[];if(t.length<1)return[new ti(i,t,"filter array must have at least 1 element")];switch(n=n.concat(Xn({key:`${i}[0]`,value:t[0],valueSpec:a.filter_operator,style:e.style,styleSpec:e.styleSpec})),Nn(t[0])){case"<":case"<=":case">":case">=":t.length>=2&&"$type"===Nn(t[1])&&n.push(new ti(i,t,`"$type" cannot be use with operator "${t[0]}"`));case"==":case"!=":3!==t.length&&n.push(new ti(i,t,`filter array for operator "${t[0]}" must have 3 elements`));case"in":case"!in":t.length>=2&&(r=en(t[1]),"string"!==r&&n.push(new ti(`${i}[1]`,t[1],`string expected, ${r} found`)));for(let o=2;o<t.length;o++)r=en(t[o]),"$type"===Nn(t[1])?n=n.concat(Xn({key:`${i}[${o}]`,value:t[o],valueSpec:a.geometry_type,style:e.style,styleSpec:e.styleSpec})):"string"!==r&&"number"!==r&&"boolean"!==r&&n.push(new ti(`${i}[${o}]`,t[o],`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(Qn({key:`${i}[${r}]`,value:t[r],style:e.style,styleSpec:e.styleSpec}));break;case"has":case"!has":r=en(t[1]),2===t.length?"string"!==r&&n.push(new ti(`${i}[1]`,t[1],`string expected, ${r} found`)):n.push(new ti(i,t,`filter array for "${t[0]}" operator must have 2 elements`))}return n}function eo(e,t){let i=e.key,r=e.validateSpec,a=e.style,n=e.styleSpec,o=e.value,s=e.objectKey,l=n[`${t}_${e.layerType}`];if(!l)return[];let u=s.match(Ja);if("paint"===t&&u&&l[u[1]]&&l[u[1]].transition)return r({key:i,value:o,valueSpec:n.transition,style:a,styleSpec:n});let h,c=e.valueSpec||l[s];if(!c)return[new ti(i,o,`unknown property "${s}"`)];if("string"===en(o)&&Xa(c)&&!c.tokens&&(h=/^{([^}]+)}$/.exec(o)))return[new ti(i,o,`"${s}" does not support interpolation syntax\nUse an identity property function instead: \`{ "type": "identity", "property": ${JSON.stringify(h[1])} }\`.`)];let d=[];return"symbol"===e.layerType&&"text-font"===s&&tn(Un(o))&&"identity"===Nn(o.type)&&d.push(new ti(i,o,'"text-font" does not support identity functions')),d.concat(r({key:e.key,value:o,valueSpec:c,style:a,styleSpec:n,expressionContext:"property",propertyType:t,propertyKey:s}))}function to(e){return eo(e,"paint")}function io(e){return eo(e,"layout")}function ro(e){let t=[],i=e.value,r=e.key,a=e.style,n=e.styleSpec;if("object"!==en(i))return[new ti(r,i,`object expected, ${en(i)} found`)];!i.type&&!i.ref&&t.push(new ti(r,i,'either "type" or "ref" is required'));let o=Nn(i.type),s=Nn(i.ref);if(i.id){let n=Nn(i.id);for(let o=0;o<e.arrayIndex;o++){let e=a.layers[o];Nn(e.id)===n&&t.push(new ti(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 ti(r,i[e],`"${e}" is prohibited for ref layers`))}),a.layers.forEach(t=>{Nn(t.id)===s&&(e=t)}),e?e.ref?t.push(new ti(r,i.ref,"ref cannot reference another ref layer")):o=Nn(e.type):t.push(new ti(r,i.ref,`ref layer "${s}" not found`))}else if("background"!==o)if(i.source){let e=a.sources&&a.sources[i.source],n=e&&Nn(e.type);e?"vector"===n&&"raster"===o?t.push(new ti(r,i.source,`layer "${i.id}" requires a raster source`)):"raster-dem"!==n&&"hillshade"===o||"raster-dem"!==n&&"color-relief"===o?t.push(new ti(r,i.source,`layer "${i.id}" requires a raster-dem source`)):"raster"===n&&"raster"!==o?t.push(new ti(r,i.source,`layer "${i.id}" requires a vector source`)):"vector"!==n||i["source-layer"]?"raster-dem"===n&&"hillshade"!==o&&"color-relief"!==o?t.push(new ti(r,i.source,"raster-dem source can only be used with layer type 'hillshade' or 'color-relief'.")):"line"===o&&i.paint&&i.paint["line-gradient"]&&("geojson"!==n||!e.lineMetrics)&&t.push(new ti(r,i,`layer "${i.id}" specifies a line-gradient, which requires a GeoJSON source with \`lineMetrics\` enabled.`)):t.push(new ti(r,i,`layer "${i.id}" must specify a "source-layer"`)):t.push(new ti(r,i.source,`source "${i.source}" not found`))}else t.push(new ti(r,i,'missing required property "source"'));return"raster"===o&&i.paint?.resampling&&i.paint?.["raster-resampling"]&&t.push(new ti(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($n({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:Jn,layout:e=>$n({layer:i,key:e.key,value:e.value,style:e.style,styleSpec:e.styleSpec,validateSpec:e.validateSpec,objectElementValidators:{"*":e=>io(Qa({layerType:o},e))}}),paint:e=>$n({layer:i,key:e.key,value:e.value,style:e.style,styleSpec:e.styleSpec,validateSpec:e.validateSpec,objectElementValidators:{"*":e=>to(Qa({layerType:o},e))}})}})),t}function ao(e){let t=e.value,i=e.key,r=en(t);return"string"===r?[]:[new ti(i,t,`string expected, ${r} found`)]}var no={promoteId:function({key:e,value:t}){if("string"===en(t))return ao({key:e,value:t});{let i=[];for(let r in t)i.push(...ao({key:`${e}.${r}`,value:t[r]}));return i}}};function oo(e){let t=e.value,i=e.key,r=e.styleSpec,a=e.style,n=e.validateSpec;if(!t.type)return[new ti(i,t,'"type" is required')];let o,s=Nn(t.type);switch(s){case"vector":case"raster":return o=$n({key:i,value:t,valueSpec:r[`source_${s.replace("-","_")}`],style:e.style,styleSpec:r,objectElementValidators:no,validateSpec:n}),o;case"raster-dem":return o=function(e){let t=e.sourceName??"",i=e.value,r=e.styleSpec,a=r.source_raster_dem,n=e.style,o=[],s=en(i);if(void 0===i)return o;if("object"!==s)return o.push(new ti("source_raster_dem",i,`object expected, ${s} found`)),o;let l="custom"===Nn(i.encoding),u=["redFactor","greenFactor","blueFactor","baseShift"],h=e.value.encoding?`"${e.value.encoding}"`:"Default";for(let c in i)!l&&u.includes(c)?o.push(new ti(c,i[c],`In "${t}": "${c}" is only valid when "encoding" is set to "custom". ${h} encoding found`)):a[c]?o=o.concat(e.validateSpec({key:c,value:i[c],valueSpec:a[c],validateSpec:e.validateSpec,style:n,styleSpec:r})):o.push(new ti(c,i[c],`unknown property "${c}"`));return o}({sourceName:i,value:t,style:e.style,styleSpec:r,validateSpec:n}),o;case"geojson":if(o=$n({key:i,value:t,valueSpec:r.source_geojson,style:a,styleSpec:r,validateSpec:n,objectElementValidators:no}),t.cluster)for(let e in t.clusterProperties){let[r,a]=t.clusterProperties[e],s="string"==typeof r?[r,["accumulated"],["get",e]]:r;o.push(...Wn({key:`${i}.${e}.map`,value:a,validateSpec:n,expressionContext:"cluster-map"})),o.push(...Wn({key:`${i}.${e}.reduce`,value:s,validateSpec:n,expressionContext:"cluster-reduce"}))}return o;case"video":return $n({key:i,value:t,valueSpec:r.source_video,style:a,validateSpec:n,styleSpec:r});case"image":return $n({key:i,value:t,valueSpec:r.source_image,style:a,validateSpec:n,styleSpec:r});case"canvas":return[new ti(i,null,"Please use runtime APIs to add canvas sources, rather than including them in stylesheets.","source.canvas")];default:return Xn({key:`${i}.type`,value:t.type,valueSpec:{values:["vector","raster","raster-dem","geojson","video","image"]},style:a,validateSpec:n,styleSpec:r})}}function so(e){let t=e.value,i=e.styleSpec,r=i.light,a=e.style,n=[],o=en(t);if(void 0===t)return n;if("object"!==o)return n=n.concat([new ti("light",t,`object expected, ${o} found`)]),n;for(let s in t){let o=s.match(Ja);n=o&&r[o[1]]&&r[o[1]].transition?n.concat(e.validateSpec({key:s,value:t[s],valueSpec:i.transition,validateSpec:e.validateSpec,style:a,styleSpec:i})):r[s]?n.concat(e.validateSpec({key:s,value:t[s],valueSpec:r[s],validateSpec:e.validateSpec,style:a,styleSpec:i})):n.concat([new ti(s,t[s],`unknown property "${s}"`)])}return n}function lo(e){let t=e.value,i=e.styleSpec,r=i.sky,a=e.style,n=en(t);if(void 0===t)return[];if("object"!==n)return[new ti("sky",t,`object expected, ${n} found`)];let o=[];for(let s in t){let n=s.match(Ja);o=n&&r[n[1]]&&r[n[1]].transition?o.concat(e.validateSpec({key:s,value:t[s],valueSpec:i.transition,style:a,styleSpec:i})):r[s]?o.concat(e.validateSpec({key:s,value:t[s],valueSpec:r[s],style:a,styleSpec:i})):o.concat([new ti(s,t[s],`unknown property "${s}"`)])}return o}function uo(e){let t=e.value,i=e.styleSpec,r=i.terrain,a=e.style,n=[],o=en(t);if(void 0===t)return n;if("object"!==o)return n=n.concat([new ti("terrain",t,`object expected, ${o} found`)]),n;for(let s in t)n=r[s]?n.concat(e.validateSpec({key:s,value:t[s],valueSpec:r[s],validateSpec:e.validateSpec,style:a,styleSpec:i})):n.concat([new ti(s,t[s],`unknown property "${s}"`)]);return n}function ho(e){let t=[],i=e.value,r=e.key;if(Array.isArray(i)){let a=[],n=[];for(let o in i)i[o].id&&a.includes(i[o].id)&&t.push(new ti(r,i,`all the sprites' ids must be unique, but ${i[o].id} is duplicated`)),a.push(i[o].id),i[o].url&&n.includes(i[o].url)&&t.push(new ti(r,i,`all the sprites' URLs must be unique, but ${i[o].url} is duplicated`)),n.push(i[o].url),t=t.concat($n({key:`${r}[${o}]`,value:i[o],valueSpec:{id:{type:"string",required:!0},url:{type:"string",required:!0}},validateSpec:e.validateSpec}));return t}return ao({key:r,value:i})}function co(e){return!!e&&e.constructor===Object}function po(e){return co(e.value)?[]:[new ti(e.key,e.value,`object expected, ${en(e.value)} found`)]}var fo=1114111,mo=/^u\+(?:([0-9a-f]{1,6})(?:-([0-9a-f]{1,6}))?|([0-9a-f]{0,5}\?{1,6}))$/i;function _o(e,t){if("string"!==en(t))return[];let i=`${t}`,r=()=>[new ti(e,t,'invalid unicode range, expected a value such as "U+26", "U+0-10FFFF" or "U+4??"')],a=i.match(mo);if(!a)return r();let[,n,o,s]=a;if(void 0!==s)return s.length>6?r():[];let l=parseInt(n,16),u=void 0===o?l:parseInt(o,16);return l>fo||u>fo?[new ti(e,t,"unicode range is out of bounds, the maximum code point is U+10FFFF")]:l>u?[new ti(e,t,`unicode range start must not be greater than its end, but ${i} is`)]:[]}function go(e){let t=e.key??"font-faces",i=e.value,r=e.validateSpec,a=e.styleSpec??Vt,n=e.style;if(!co(i))return[new ti(t,i,`object expected, ${en(i)} found`)];let o=[];for(let s in i){let e=i[s],l=en(e);if("string"===l)o.push(...ao({key:`${t}.${s}`,value:e}));else if("array"===l){let i={url:{type:"string",required:!0},"unicode-range":{type:"array",value:"string"}};for(let[l,u]of e.entries()){let e=`${t}.${s}[${l}]`;o.push(...$n({key:e,value:u,valueSpec:i,styleSpec:a,style:n,validateSpec:r}));let h=co(u)?u["unicode-range"]:void 0;if("array"===en(h))for(let[t,i]of h.entries())o.push(..._o(`${e}.unicode-range[${t}]`,i))}}else o.push(new ti(`${t}.${s}`,e,`string or array expected, ${l} found`))}return o}var yo={"*":()=>[],array:Gn,boolean:function(e){let t=e.value,i=e.key,r=en(t);return"boolean"===r?[]:[new ti(i,t,`boolean expected, ${r} found`)]},number:Zn,color:Hn,constants:Vn,enum:Xn,filter:Jn,function:qn,layer:ro,object:$n,source:oo,light:so,sky:lo,terrain:uo,projection:function(e){let t=e.value,i=e.styleSpec,r=i.projection,a=e.style,n=en(t);if(void 0===t)return[];if("object"!==n)return[new ti("projection",t,`object expected, ${n} found`)];let o=[];for(let s in t)o=r[s]?o.concat(e.validateSpec({key:s,value:t[s],valueSpec:r[s],style:a,styleSpec:i})):o.concat([new ti(s,t[s],`unknown property "${s}"`)]);return o},projectionDefinition:function(e){let t=e.key,i=e.value;i=i instanceof String?i.valueOf():i;let r=en(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 ti(t,i,`projection expected, invalid type "${r}" found`)]:[new ti(t,i,`projection expected, invalid array ${JSON.stringify(i)} found`)]},string:ao,formatted:function(e){return 0===ao(e).length?[]:Wn(e)},resolvedImage:function(e){return 0===ao(e).length?[]:Wn(e)},padding:function(e){let t=e.key,i=e.value;if("array"===en(i)){if(i.length<1||i.length>4)return[new ti(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 Zn({key:t,value:i,valueSpec:{}})},numberArray:function(e){let t=e.key,i=e.value;if("array"===en(i)){let r={type:"number"};if(i.length<1)return[new ti(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 Zn({key:t,value:i,valueSpec:{}})},colorArray:function(e){let t=e.key,i=e.value;if("array"===en(i)){if(i.length<1)return[new ti(t,i,"array length at least 1 expected, length 0 found")];let e=[];for(let r=0;r<i.length;r++)e=e.concat(Hn({key:`${t}[${r}]`,value:i[r],valueSpec:{}}));return e}return Hn({key:t,value:i,valueSpec:{}})},variableAnchorOffsetCollection:function(e){let t=e.key,i=e.value,r=en(i),a=e.styleSpec;if("array"!==r||i.length<1||i.length%2!=0)return[new ti(t,i,"variableAnchorOffsetCollection requires a non-empty array of even length")];let n=[];for(let o=0;o<i.length;o+=2)n=n.concat(Xn({key:`${t}[${o}]`,value:i[o],valueSpec:a.layout_symbol["text-anchor"]})),n=n.concat(Gn({key:`${t}[${o+1}]`,value:i[o+1],valueSpec:{length:2,value:"number"},validateSpec:e.validateSpec,style:e.style,styleSpec:a}));return n},sprite:ho,state:po,fontFaces:go};function vo(e){let t=e.value,i=e.valueSpec,r=e.styleSpec;return e.validateSpec=vo,i.expression&&tn(Nn(t))?qn(e):i.expression&&mn(Un(t))?Wn(e):i.type&&yo[i.type]?yo[i.type](e):$n(Qa({},e,{valueSpec:i.type?r[i.type]:i}))}function xo(e){let t=e.value,i=e.key,r=ao(e);return r.length||(-1===t.indexOf("{fontstack}")&&r.push(new ti(i,t,'"glyphs" url must include a "{fontstack}" token')),-1===t.indexOf("{range}")&&r.push(new ti(i,t,'"glyphs" url must include a "{range}" token'))),r}function bo(e,t=Nt){let i=[];return i=i.concat(vo({key:"",value:e,valueSpec:t.$root,styleSpec:t,style:e,validateSpec:vo,objectElementValidators:{glyphs:xo,"*":()=>[]}})),e.constants&&(i=i.concat(Vn({key:"constants",value:e.constants,style:e,styleSpec:t,validateSpec:vo}))),To(i)}function wo(e){return function(t){return e(Object.assign({},t,{validateSpec:vo}))}}function To(e){return[].concat(e).sort((e,t)=>e.line-t.line)}function So(e){return function(...t){return To(e.apply(this,t))}}bo.source=So(wo(oo)),bo.sprite=So(wo(ho)),bo.glyphs=So(wo(xo)),bo.fontFaces=So(wo(go)),bo.light=So(wo(so)),bo.sky=So(wo(lo)),bo.terrain=So(wo(uo)),bo.state=So(wo(po)),bo.layer=So(wo(ro)),bo.filter=So(wo(Jn)),bo.paintProperty=So(wo(to)),bo.layoutProperty=So(wo(io));var Do={type:"enum","property-type":"data-constant",expression:{interpolated:!1,parameters:["global-state"]},values:{visible:{},none:{}},transition:!1,default:"visible"},Eo=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=_n(e,this._rootKey,Do,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=wn(t.value.expression)}getGlobalStateRefs(){return this._globalStateRefs}},Co={};function Po(e,t,i={}){if(Co[e])throw Error(`${e} is already registered.`);Object.defineProperty(t,"_classRegistryKey",{value:e,writeable:!1}),Co[e]={klass:t,omit:i.omit||[],shallow:i.shallow||[]}}Po("Object",Object),Po("Set",Set),Po("TransferableGridIndex",jt),Po("Color",Wi),Po("Error",Error),Po("AJAXError",Pt),Po("ResolvedImage",rr),Po("StylePropertyFunction",xn),Po("StyleExpression",dn,{omit:["_evaluator"]}),Po("ZoomDependentExpression",yn),Po("ZoomConstantExpression",gn),Po("CompoundExpression",Va,{omit:["_evaluate"]});for(let bC in La)La[bC]._classRegistryKey||Po(`Expression_${bC}`,La[bC]);function Ao(e){return e&&typeof ArrayBuffer<"u"&&(e instanceof ArrayBuffer||"ArrayBuffer"===e.constructor?.name)}function Io(e){let t=e.constructor;return e.$name||t._classRegistryKey}function Mo(e){return!function(e){if("object"!=typeof e||!e)return!1;let t=Io(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||Ao(e)||Ge(e)||ArrayBuffer.isView(e)||e instanceof ImageData)}function Fo(e,t){if(Mo(e))return(Ao(e)||Ge(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(Fo(r,t));return i}if("object"!=typeof e)throw Error("can't serialize object of type "+typeof e);let i=Io(e);if(!i)throw Error(`can't serialize object of unregistered class ${e.constructor.name}`);if(!Co[i])throw Error(`${i} is not registered.`);let{klass:r}=Co[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)||Co[i].omit.includes(r))continue;let n=e[r];void 0!==n&&(a[r]=Co[i].shallow.includes(r)?n:Fo(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 zo(e){if(Mo(e))return e;if(Array.isArray(e))return e.map(zo);if("object"!=typeof e)throw Error("can't deserialize object of type "+typeof e);let t=Io(e)||"Object";if(!Co[t])throw Error(`can't deserialize unregistered class ${t}`);let{klass:i}=Co[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]=Co[t].shallow.includes(a)?i:zo(i)}return r}var ko=class{constructor(e){this._methodToThrottle=e,this._triggered=!1,this._channel=new MessageChannel,this._channel.port2.onmessage=()=>this._invoke()}trigger(){this._triggered||(this._triggered=!0,this._channel?.port1.postMessage(!0),setTimeout(()=>this._invoke(),0))}_invoke(){this._triggered&&(this._triggered=!1,this._methodToThrottle())}remove(){delete this._channel,this._methodToThrottle=()=>{}}},Ro={once:!0},Lo=class{constructor(e,t){this.target=e,this.mapId=t,this.resolveRejects={},this.tasks={},this.taskQueue=[],this.abortControllers={},this.messageHandlers={},this.invoker=new ko(()=>this.process()),this.subscription=Ze(this.target,"message",e=>this.receive(e),!1),this.globalScope=Ue(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?Ze(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 st(t.signal.reason))},Ro):null;this.resolveRejects[a]={resolve:e=>{n?.unsubscribe(),i(e)},reject:e=>{n?.unsubscribe(),r(e)}};let o=[],s={...e,id:a,sourceMapId:this.mapId,origin:location.origin,data:Fo(e.data,o)};this.target.postMessage(s,{transfer:o})})}receive(e){let t=e.data,i=t.id,r=["file://","resource://android","null"],a=[t.origin,location.origin],n=t.origin===location.origin,o=a.some(e=>r.includes(e));if((n||o)&&(!t.targetMapId||this.mapId===t.targetMapId))if("<cancel>"===t.type){delete this.tasks[i];let e=this.abortControllers[i];delete this.abortControllers[i],e&&e.abort()}else Ue(self)||t.mustQueue?(this.tasks[i]=t,this.taskQueue.push(i),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(ne(zo(t.error))):i.resolve(zo(t.data)))}if(!this.messageHandlers[t.type])return void this.completeTask(e,null,null);let i=zo(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,ne(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?Fo(t):null,data:Fo(i,r)};this.target.postMessage(a,{transfer:r})}remove(){this.invoker.remove(),this.subscription.unsubscribe()}};function Bo(e,t,i){let r=e.map(e=>Ze(e,"error",()=>{i.fire(new Bt(/* @__PURE__ */Error("Worker failed to load. Check that the worker URL is correct.")))},!1));return{actors:e.map((e,i)=>{let r=new Lo(e,t);return r.name=`Worker ${i}`,r}),workerErrorSubscriptions:r}}function Oo(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 jo(){let e=Tt.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",i=new URL(`./${t}`,e);return i.searchParams.set("v",c),i.href}(),t=!function(e){return e.endsWith(".cjs")||e.split(/[?#]/)[0].endsWith(".cjs")}(e);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 Oo(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 Oo(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 Oo(i,t)}finally{URL.revokeObjectURL(i)}}var Vo,No="maplibre_preloaded_worker_pool",Uo=class e extends Ot{constructor(){super(),this.active={},this.workersPromise=null}acquire(e){return this.active[e]=!0,this.start()}async start(){if(this.workersPromise)return(await this.workersPromise).slice();let t=[];for(;t.length<e.workerCount;)t.push(jo());let i=this.workersPromise=Promise.all(t),r=await i;return this.workersPromise===i&&this.fire("create"),r.slice()}async restart(){if(this.workersPromise){this.terminate();try{await this.start()}catch(e){return void Oe(`Failed to create replacement workers: ${e}`)}this.fire("restart")}}async release(e){delete this.active[e],0===this.numActive()&&await this.terminate()}async terminate(){let e=this.workersPromise;if(e){this.workersPromise=null,this.fire("terminate");try{for(let t of await e)t.terminate()}catch(e){Oe(`The terminated workers were never created: ${e}`)}}}isStarted(){return!!this.workersPromise}isPreloaded(){return!!this.active[No]}numActive(){return Object.keys(this.active).length}},$o=Math.floor(ht.hardwareConcurrency/2);function Go(){return Vo||=new Uo,Vo}function Zo(){Go().acquire(No)}function qo(){let e=Vo;e&&(e.isPreloaded()&&1===e.numActive()?e.release(No):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()"))}Uo.workerCount=function(e){if(null==$e){let t=e.navigator?e.navigator.userAgent:null;$e=!!e.safari||!(!t||!(/\b(iPad|iPhone|iPod)\b/.test(t)||t.match("Safari")&&!t.match("Chrome")))}return $e}(globalThis)?Math.max(Math.min($o,3),1):1;var Wo,Ho,Xo=class extends Ot{constructor(e){super(),this.importedScriptUrls=/* @__PURE__ */new Set,this.messageHandlers={},this.watchingWorkers=!1,this.workerPool=e,e.on("create",()=>this.buildActorsInBackground()),e.on("terminate",()=>this.handleWorkersTerminated()),e.isStarted()&&this.buildActorsInBackground()}async buildActorsInBackground(){try{await this.getActors()}catch(i){lt(i)||Oe(`Failed to connect to the workers: ${i}`)}}handleWorkersTerminated(){this.workersAbortController?.abort(/* @__PURE__ */Error("The workers were terminated while a message was in flight.")),this.actorsPromise=void 0}getActors(){return this.actorsPromise??=this.buildActors(),this.actorsPromise}async buildActors(){let e=new AbortController;this.workersAbortController=e;let t=await this.workerPool.start();ut(e.signal);let{actors:i,workerErrorSubscriptions:r}=Bo(t,Ct,this);e.signal.addEventListener("abort",()=>{for(let e of i)e.remove();for(let e of r)e.unsubscribe()},{once:!0});for(let a of i)for(let[e,t]of Object.entries(this.messageHandlers))a.registerMessageHandler(e,t);for(let a of this.importedScriptUrls)this.importScriptInto(i,e,a);return this.fire("workerscreate"),i}async getBuiltActors(){try{return await this.actorsPromise??[]}catch{return[]}}async importScriptInto(e,t,i){try{await Promise.all(e.map(e=>e.sendAsync({type:"IS",data:i},t)))}catch(e){Oe(`Failed to import script ${i} into the workers: ${e}`)}}async broadcast(e,t){let i=this.getActors(),r=this.workersAbortController,a=await i;return ut(r.signal),Promise.all(a.map(i=>i.sendAsync({type:e,data:t},r)))}async registerMessageHandler(e,t){this.messageHandlers[e]=t;for(let i of await this.getBuiltActors())i.registerMessageHandler(e,t)}async unregisterMessageHandler(e){delete this.messageHandlers[e];for(let t of await this.getBuiltActors())t.unregisterMessageHandler(e)}async importScript(e){this.importedScriptUrls.add(e),await this.broadcast("IS",e)}watchWorkers(){this.watchingWorkers||typeof document>"u"||(this.watchingWorkers=!0,document.addEventListener("visibilitychange",()=>{"visible"===document.visibilityState&&this.ensureWorkers()},!1))}ensureWorkers(){return this.ensureWorkersPromise??=this.ensureWorkersInternal(),this.ensureWorkersPromise}async ensureWorkersInternal(){try{await this.ping()||await this.workerPool.restart()}finally{this.ensureWorkersPromise=void 0}}async ping(e=500){if(!this.workerPool.isStarted())return!0;let t;try{return await Promise.race([this.answersPing(),new Promise(i=>{t=setTimeout(()=>i(!1),e)})])}finally{clearTimeout(t)}}async answersPing(){try{await this.broadcast("PI",void 0)}catch{}return!0}};function Yo(){return Wo||(Wo=new Xo(Go())).registerMessageHandler("GR",(e,t,i)=>It(t,i)),Wo}(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],s()},e.transformAndGetImage=async function(e,t,i,r,a=!0,n){let o=await e.transformRequest(t,i);return ut(r.signal),Ho.getImage(o,r,a,n)},e.getImage=(e,i,r=!0,a)=>new Promise((n,o)=>{e.headers||={},e.headers.accept="image/webp,*/*",Ee(e,{type:"image"});let l={abortController:i,requestParameters:e,supportImageRefresh:r,imageBitmapOptions:a,state:"queued",onError:e=>{o(e)},onSuccess:e=>{n(e)}};t.push(l),s()});let n=(e,t)=>"function"==typeof createImageBitmap?(async(e,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 ${ne(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="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAAC0lEQVQYV2NgAAIAAAUAAarVyFEAAAAASUVORK5CYII=")},r.onerror=()=>i(/* @__PURE__ */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=URL.createObjectURL(a)}))(e),o=async e=>{e.state="running";let{requestParameters:t,supportImageRefresh:r,imageBitmapOptions:a,onError:o,onSuccess:u,abortController:h}=e,c=!1===r&&!a&&!Ue(self)&&!St(t.url)&&(!t.headers||Object.keys(t.headers).reduce((e,t)=>e&&"accept"===t,!0));i++;let d=c?l(t,h):It(t,h);try{let t=await d;delete e.abortController,e.state="completed",t.data instanceof HTMLImageElement||Ge(t.data)?u(t):t.data&&0!==t.data.byteLength?u({data:await n(t.data,a),cacheControl:t.cacheControl,expires:t.expires}):u({data:null,cacheControl:t.cacheControl,expires:t.expires})}catch(t){delete e.abortController,o(ne(t))}finally{i--,s()}},s=()=>{let e=(()=>{for(let e of Object.keys(a))if(a[e]())return!0;return!1})()?Tt.MAX_PARALLEL_IMAGE_REQUESTS_PER_FRAME:Tt.MAX_PARALLEL_IMAGE_REQUESTS;for(let r=i;r<e&&t.length>0;r++){let e=t.shift();e.abortController.signal.aborted?r--:o(e)}},l=(e,t)=>new Promise((i,r)=>{let a=new Image,n=e.url,o=e.credentials;o&&"include"===o?a.crossOrigin="use-credentials":(o&&"same-origin"===o||!zt(n))&&(a.crossOrigin="anonymous"),t.signal.addEventListener("abort",()=>{a.src="",r(new st(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(/* @__PURE__ */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})})(Ho||={}),Ho.resetRequestQueue();var Ko=class{constructor(e){this._transformRequestFn=e??null}transformRequest(e,t){return this._transformRequestFn&&this._transformRequestFn(e,t)||{url:e}}setTransformRequest(e){this._transformRequestFn=e}},Jo=class extends Lt{},Qo=class extends Jo{},es=class extends Jo{constructor(e={}){super("style.load",e)}},ts=class extends Jo{constructor(e,t={}){super(e,t),this.dataType="style"}},is=class extends Jo{constructor(e,t={}){super(e,t),this.dataType="source"}},rs=class extends Jo{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=wt.mousePos(t.getCanvas(),i);super(e,Ee({point:a,lngLat:t.unproject(a),originalEvent:i},r)),this._defaultPrevented=!1,this.target=t}},as=class extends Jo{preventDefault(){this._defaultPrevented=!0}get defaultPrevented(){return this._defaultPrevented}constructor(e,t,i){let r="touchend"===e?i.changedTouches:i.touches,a=wt.touchPos(t.getCanvasContainer(),r),n=a.map(e=>t.unproject(e)),o=a.reduce((e,t,i,r)=>e.add(t.div(r.length)),new d(0,0));super(e,{points:a,point:o,lngLats:n,lngLat:t.unproject(o),originalEvent:i}),this._defaultPrevented=!1}},ns=class extends Jo{preventDefault(){this._defaultPrevented=!0}get defaultPrevented(){return this._defaultPrevented}constructor(e,t){super("wheel",{originalEvent:t}),this._defaultPrevented=!1}},os=class extends Jo{},ss=class extends Jo{constructor(e={}){super("terrain",e)}},ls=class extends Jo{constructor(e={}){super("projectiontransition",e)}},us=class extends Jo{},hs=class extends Jo{constructor(e={}){super("styleimagemissing",e)}},cs=bo,ds=new Set(Object.keys(Nt).filter(e=>e.startsWith("source_")).map(e=>e.slice(7).replaceAll("_","-")));function ps(e,t){let i=function(e){return Object.entries(e.sources??{}).filter(([,e])=>!ds.has(e.type)).map(([e])=>`sources.${e}`)}(t);return fs(e,cs(t).filter(({message:e})=>!i.some(t=>e.startsWith(`${t}:`)||e.startsWith(`${t}.`))))}function fs(e,t){let i=!1;for(let r of t)"warning"===r.severity?Oe(r.message):(e.fire(new Bt(Error(r.message))),i=!0);return i}function ms(e,t,i,r){return!1!==r?.validate&&fs(e,t({styleSpec:Nt,...i}))}var _s=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))}},gs=class{constructor(e,t){this.zoom=e,t?(this.now=t.now||0,this.fadeDuration=t.fadeDuration||0,this.zoomHistory=t.zoomHistory||new _s,this.transition=t.transition||{}):(this.now=0,this.fadeDuration=0,this.zoomHistory=new _s,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}}},ys=class{constructor(e,t,i,r){this.property=e,this.value=t,this.expression=function(e,t,i,r){if(tn(e))return new xn(e,t,i);if(mn(e)){let a=vn(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=Wi.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=ir.parse(e):"projectionDefinition"===i.type&&"string"==typeof e&&(t=ar.parse(e)):t=Qi.parse(e):t=Ji.parse(e):t=Ki.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}readsGlobalState(e){let t=this.getGlobalStateRefs();return e.some(e=>t.has(e))}possiblyEvaluate(e,t,i){return this.property.possiblyEvaluate(this,e,t,i)}},vs=class{constructor(e,t,i){this.property=e,this.value=new ys(e,void 0,t,i)}transitioned(e,t){return t.value===this.value?t:new bs(this.property,this.value,t,Ee({},e.transition,this.transition),e.now)}untransitioned(){return new bs(this.property,this.value,null,{},0)}},xs=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 Le(this._values[e].value.value)}setValue(e,t){Object.hasOwn(this._values,e)||(this._values[e]=new vs(this._values[e].property,this._propertyRootKey(e),this._globalState)),this._values[e].value=new ys(this._values[e].property,null===t?void 0:Le(t),this._propertyRootKey(e),this._globalState)}setValues(e){for(let t in e){let i=e[t];t.endsWith("-transition")?this.setTransition(t.slice(0,-11),i):Re(this._values[t].value.value,i)||this.setValue(t,i)}}getTransition(e){return Le(this._values[e].transition)}setTransition(e,t){Object.hasOwn(this._values,e)||(this._values[e]=new vs(this._values[e].property,this._propertyRootKey(e),this._globalState)),this._values[e].transition=Le(t)||void 0}retainPriorGlobalState(e,t,i){for(let r of Object.keys(i._values))for(let a=i._values[r];a;a=a.prior){let{value:i}=a;i.property.specification.transition&&!i.isDataDriven()&&i.expression._globalState===this._globalState&&i.readsGlobalState(e)&&(a.value=new ys(i.property,i.value,this._propertyRootKey(r),t))}}applyGlobalStateChange(e,t,i,r){this.retainPriorGlobalState(e,t,i);let a=!1;for(let n of Object.keys(this._values)){let{value:t}=this._values[n];t.readsGlobalState(e)&&(this.setValue(n,t.value),a=!0)}return a?this.transitioned(r,i):i}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 ws(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 ws(this._properties);for(let t of Object.keys(this._values))e._values[t]=this._values[t].untransitioned();return e}},bs=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 o=(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)}(o))}}},ws=class{constructor(e){this._properties=e,this._values=Object.create(e.defaultTransitioningPropertyValues)}possiblyEvaluate(e,t,i){let r=new Ds(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}},Ts=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 Le(this._values[e].value)}setValue(e,t){this._values[e]=new ys(this._values[e].property,null===t?void 0:Le(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 Ds(this._properties);for(let a of Object.keys(this._values))r._values[a]=this._values[a].possiblyEvaluate(e,t,i);return r}},Ss=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)}},Ds=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 Cs(e,t){let i=Es(e),r=Es(t);return void 0!==i&&void 0!==r&&i!==r}var Ps=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(Cs(e,t))return Oe(`Property "${this.name}" is trying to interpolate arrays of different lengths. Rendering may 'jump'.`),t;let r=this.specification.type,a=gr[r];return a?a(e,t,i):e}},As=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 Ss(this,{kind:"constant",value:e.expression.evaluate(t,null,{},i,r)},t):new Ss(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 Ss(this,{kind:"constant",value:void 0},e.parameters);if(Cs(e.value.value,t.value.value))return Oe(`Property "${this.name}" is trying to interpolate arrays of different lengths. Rendering may 'jump'.`),t;let r=this.specification.type,a=gr[r];if(a){let r=a(e.value.value,t.value.value,i);return new Ss(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)}},Is=class extends As{possiblyEvaluate(e,t,i,r){if(void 0===e.value)return new Ss(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,o=this._calculate(n,n,n,t);return new Ss(this,{kind:"constant",value:o},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 Ss(this,{kind:"constant",value:i},t)}return new Ss(this,e.expression,t)}evaluate(e,t,i,r,a,n){if("source"===e.kind){let o=e.evaluate(t,i,r,a,n);return this._calculate(o,o,o,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}},Ms=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 gs(Math.floor(t.zoom-1),t)),e.expression.evaluate(new gs(Math.floor(t.zoom),t)),e.expression.evaluate(new gs(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}},Fs=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}},zs=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 ys(i,void 0,i.name,void 0),a=this.defaultTransitionablePropertyValues[t]=new vs(i,i.name,void 0);this.defaultTransitioningPropertyValues[t]=a.untransitioned(),this.defaultPossiblyEvaluatedValues[t]=r.possiblyEvaluate({})}}};Po("DataDrivenProperty",As),Po("DataConstantProperty",Ps),Po("CrossFadedDataDrivenProperty",Is),Po("CrossFadedProperty",Ms),Po("ColorRampProperty",Fs);var ks,Rs=" is a PAINT property not a LAYOUT property. Use get/setPaintProperty instead?",Ls=" is a LAYOUT property not a PAINT property. Use get/setLayoutProperty instead?",Bs=class extends Ot{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 Eo(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=Fn(e.filter,`layers[${this.id}].filter`,i)),t.layout&&(this._unevaluatedLayout=new Ts(t.layout,`layers[${this.id}].layout`,i)),t.paint)){this._transitionablePaint=new xs(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 Ds(t.paint)}}setFilter(e){this.filter=e,this._featureFilter=Fn(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+Rs);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={}){"visibility"===e?(this.visibility=t,this._visibilityExpression.setValue(t),this.recalculateVisibility()):this._transitionablePaint?.hasProperty(e)?this.fire(new Bt(/* @__PURE__ */Error(e+Rs))):null!=t&&this._validate(cs.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+Ls);return this._transitionablePaint.getTransition(t)}if("visibility"===e||this._unevaluatedLayout?.hasProperty(e))throw Error(e+Ls);return this._transitionablePaint.getValue(e)}setPaintProperty(e,t,i={}){if("visibility"===e||this._unevaluatedLayout?.hasProperty(e))return this.fire(new Bt(/* @__PURE__ */Error(e+Ls))),!1;if(null!=t&&this._validate(cs.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 o=this._transitionablePaint._values[e].value;return o.isDataDriven()||a||r||this._handleOverridablePaintPropertyUpdate(e,n,o)}}_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)}retainPriorGlobalState(e,t){this._transitionablePaint?.retainPriorGlobalState(e,t,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),ke(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 ms(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 Ss&&Xa(t.property.specification)&&("source"===t.value.kind||"composite"===t.value.kind)&&t.value.isStateDependent)return!0}return!1}},Os={get paint(){return ks||=new zs({"raster-opacity":new Ps(Nt.paint_raster["raster-opacity"],"raster-opacity"),"raster-hue-rotate":new Ps(Nt.paint_raster["raster-hue-rotate"],"raster-hue-rotate"),"raster-brightness-min":new Ps(Nt.paint_raster["raster-brightness-min"],"raster-brightness-min"),"raster-brightness-max":new Ps(Nt.paint_raster["raster-brightness-max"],"raster-brightness-max"),"raster-saturation":new Ps(Nt.paint_raster["raster-saturation"],"raster-saturation"),"raster-contrast":new Ps(Nt.paint_raster["raster-contrast"],"raster-contrast"),resampling:new Ps(Nt.paint_raster.resampling,"resampling"),"raster-resampling":new Ps(Nt.paint_raster["raster-resampling"],"raster-resampling"),"raster-fade-duration":new Ps(Nt.paint_raster["raster-fade-duration"],"raster-fade-duration")})}},js=e=>"raster"===e.type,Vs=class extends Bs{constructor(e,t){super(e,Os,t)}},Ns={Int8:Int8Array,Uint8:Uint8Array,Int16:Int16Array,Uint16:Uint16Array,Int32:Int32Array,Uint32:Uint32Array,Float32:Float32Array},Us=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}},$s=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 Gs(e,t=1){let i=0,r=0;return{members:e.map(e=>{let a=function(e){return Ns[e].BYTES_PER_ELEMENT}(e.type),n=i=Zs(i,Math.max(t,a)),o=e.components||1;return r=Math.max(r,a),i+=a*o,{name:e.name,type:e.type,components:o,offset:n}}),size:Zs(i,Math.max(r,t)),alignment:t}}function Zs(e,t){return Math.ceil(e/t)*t}var qs=class extends $s{_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}};qs.prototype.bytesPerElement=4,Po("StructArrayLayout2i4",qs);var Ws=class extends $s{_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}};Ws.prototype.bytesPerElement=6,Po("StructArrayLayout3i6",Ws);var Hs=class extends $s{_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}};Hs.prototype.bytesPerElement=8,Po("StructArrayLayout4i8",Hs);var Xs=class extends $s{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(e,t,i,r,a,n){let o=this.length;return this.resize(o+1),this.emplace(o,e,t,i,r,a,n)}emplace(e,t,i,r,a,n,o){let s=6*e;return this.int16[s+0]=t,this.int16[s+1]=i,this.int16[s+2]=r,this.int16[s+3]=a,this.int16[s+4]=n,this.int16[s+5]=o,e}};Xs.prototype.bytesPerElement=12,Po("StructArrayLayout2i4i12",Xs);var Ys=class extends $s{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer),this.int8=new Int8Array(this.arrayBuffer)}emplaceBack(e,t,i,r,a,n,o,s){let l=this.length;return this.resize(l+1),this.emplace(l,e,t,i,r,a,n,o,s)}emplace(e,t,i,r,a,n,o,s,l){let u=5*e,h=10*e;return this.int16[u+0]=t,this.int16[u+1]=i,this.uint8[h+4]=r,this.uint8[h+5]=a,this.uint8[h+6]=n,this.uint8[h+7]=o,this.int8[h+8]=s,this.int8[h+9]=l,e}};Ys.prototype.bytesPerElement=10,Po("StructArrayLayout2i4ub2b10",Ys);var Ks=class extends $s{_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}};Ks.prototype.bytesPerElement=8,Po("StructArrayLayout2f8",Ks);var Js=class extends $s{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(e,t,i,r,a,n,o,s,l,u){let h=this.length;return this.resize(h+1),this.emplace(h,e,t,i,r,a,n,o,s,l,u)}emplace(e,t,i,r,a,n,o,s,l,u,h){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]=o,this.uint16[c+6]=s,this.uint16[c+7]=l,this.uint16[c+8]=u,this.uint16[c+9]=h,e}};Js.prototype.bytesPerElement=20,Po("StructArrayLayout10ui20",Js);var Qs=class extends $s{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(e,t,i,r,a,n,o,s){let l=this.length;return this.resize(l+1),this.emplace(l,e,t,i,r,a,n,o,s)}emplace(e,t,i,r,a,n,o,s,l){let u=8*e;return this.uint16[u+0]=t,this.uint16[u+1]=i,this.uint16[u+2]=r,this.uint16[u+3]=a,this.uint16[u+4]=n,this.uint16[u+5]=o,this.uint16[u+6]=s,this.uint16[u+7]=l,e}};Qs.prototype.bytesPerElement=16,Po("StructArrayLayout8ui16",Qs);var el=class extends $s{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(e,t,i,r,a,n,o,s,l,u,h,c,d){let p=this.length;return this.resize(p+1),this.emplace(p,e,t,i,r,a,n,o,s,l,u,h,c,d)}emplace(e,t,i,r,a,n,o,s,l,u,h,c,d,p){let f=14*e,m=7*e;return this.int16[f+0]=t,this.int16[f+1]=i,this.int16[f+2]=r,this.int16[f+3]=a,this.uint16[f+4]=n,this.uint16[f+5]=o,this.uint16[f+6]=s,this.uint16[f+7]=l,this.int16[f+8]=u,this.int16[f+9]=h,this.int16[f+10]=c,this.int16[f+11]=d,this.float32[m+6]=p,e}};el.prototype.bytesPerElement=28,Po("StructArrayLayout4i4ui4i1f28",el);var tl=class extends $s{_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}};tl.prototype.bytesPerElement=12,Po("StructArrayLayout3f12",tl);var il=class extends $s{_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}};il.prototype.bytesPerElement=4,Po("StructArrayLayout1ul4",il);var rl=class extends $s{_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,o,s,l){let u=this.length;return this.resize(u+1),this.emplace(u,e,t,i,r,a,n,o,s,l)}emplace(e,t,i,r,a,n,o,s,l,u){let h=10*e,c=5*e;return this.int16[h+0]=t,this.int16[h+1]=i,this.int16[h+2]=r,this.int16[h+3]=a,this.int16[h+4]=n,this.int16[h+5]=o,this.uint32[c+3]=s,this.uint16[h+8]=l,this.uint16[h+9]=u,e}};rl.prototype.bytesPerElement=20,Po("StructArrayLayout6i1ul2ui20",rl);var al=class extends $s{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(e,t,i,r,a,n){let o=this.length;return this.resize(o+1),this.emplace(o,e,t,i,r,a,n)}emplace(e,t,i,r,a,n,o){let s=6*e;return this.int16[s+0]=t,this.int16[s+1]=i,this.int16[s+2]=r,this.int16[s+3]=a,this.int16[s+4]=n,this.int16[s+5]=o,e}};al.prototype.bytesPerElement=12,Po("StructArrayLayout2i2i2i12",al);var nl=class extends $s{_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 o=4*e,s=8*e;return this.float32[o+0]=t,this.float32[o+1]=i,this.float32[o+2]=r,this.int16[s+6]=a,this.int16[s+7]=n,e}};nl.prototype.bytesPerElement=16,Po("StructArrayLayout2f1f2i16",nl);var ol=class extends $s{_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 o=this.length;return this.resize(o+1),this.emplace(o,e,t,i,r,a,n)}emplace(e,t,i,r,a,n,o){let s=16*e,l=4*e,u=8*e;return this.uint8[s+0]=t,this.uint8[s+1]=i,this.float32[l+1]=r,this.float32[l+2]=a,this.int16[u+6]=n,this.int16[u+7]=o,e}};ol.prototype.bytesPerElement=16,Po("StructArrayLayout2ub2f2i16",ol);var sl=class extends $s{_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}};sl.prototype.bytesPerElement=6,Po("StructArrayLayout3ui6",sl);var ll=class extends $s{_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,o,s,l,u,h,c,d,p,f,m,_,g){let y=this.length;return this.resize(y+1),this.emplace(y,e,t,i,r,a,n,o,s,l,u,h,c,d,p,f,m,_,g)}emplace(e,t,i,r,a,n,o,s,l,u,h,c,d,p,f,m,_,g,y){let v=26*e,x=13*e,b=52*e;return this.int16[v+0]=t,this.int16[v+1]=i,this.uint16[v+2]=r,this.uint16[v+3]=a,this.uint32[x+2]=n,this.uint32[x+3]=o,this.uint32[x+4]=s,this.uint16[v+10]=l,this.uint16[v+11]=u,this.uint16[v+12]=h,this.float32[x+7]=c,this.float32[x+8]=d,this.uint8[b+36]=p,this.uint8[b+37]=f,this.uint8[b+38]=m,this.uint32[x+10]=_,this.int16[v+22]=g,this.float32[x+12]=y,e}};ll.prototype.bytesPerElement=52,Po("StructArrayLayout2i2ui3ul3ui2f3ub1ul1i1f52",ll);var ul=class extends $s{_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,o,s,l,u,h,c,d,p,f,m,_,g,y,v,x,b,w,T,S,D,E,C,P){let A=this.length;return this.resize(A+1),this.emplace(A,e,t,i,r,a,n,o,s,l,u,h,c,d,p,f,m,_,g,y,v,x,b,w,T,S,D,E,C,P)}emplace(e,t,i,r,a,n,o,s,l,u,h,c,d,p,f,m,_,g,y,v,x,b,w,T,S,D,E,C,P,A){let I=34*e,M=17*e;return this.int16[I+0]=t,this.int16[I+1]=i,this.int16[I+2]=r,this.int16[I+3]=a,this.int16[I+4]=n,this.int16[I+5]=o,this.int16[I+6]=s,this.int16[I+7]=l,this.uint16[I+8]=u,this.uint16[I+9]=h,this.uint16[I+10]=c,this.uint16[I+11]=d,this.uint16[I+12]=p,this.uint16[I+13]=f,this.uint16[I+14]=m,this.uint16[I+15]=_,this.uint16[I+16]=g,this.uint16[I+17]=y,this.uint16[I+18]=v,this.uint16[I+19]=x,this.uint16[I+20]=b,this.uint16[I+21]=w,this.uint16[I+22]=T,this.uint32[M+12]=S,this.float32[M+13]=D,this.float32[M+14]=E,this.uint16[I+30]=C,this.uint16[I+31]=P,this.float32[M+16]=A,e}};ul.prototype.bytesPerElement=68,Po("StructArrayLayout8i15ui1ul2f2ui1f68",ul);var hl=class extends $s{_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}};hl.prototype.bytesPerElement=4,Po("StructArrayLayout1f4",hl);var cl=class extends $s{_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}};cl.prototype.bytesPerElement=12,Po("StructArrayLayout1ui2f12",cl);var dl=class extends $s{_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}};dl.prototype.bytesPerElement=8,Po("StructArrayLayout1ul2ui8",dl);var pl=class extends $s{_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}};pl.prototype.bytesPerElement=4,Po("StructArrayLayout2ui4",pl);var fl=class extends $s{_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}};fl.prototype.bytesPerElement=2,Po("StructArrayLayout1ui2",fl);var ml=class extends $s{_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}};ml.prototype.bytesPerElement=16,Po("StructArrayLayout4f16",ml);var _l=class extends Us{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 d(this.anchorPointX,this.anchorPointY)}};_l.prototype.size=20;var gl=class extends rl{get(e){return new _l(this,e)}};Po("CollisionBoxArray",gl);var yl=class extends Us{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]}get heightOffset(){return this._structArray.float32[this._pos4+12]}};yl.prototype.size=52;var vl=class extends ll{get(e){return new yl(this,e)}};Po("PlacedSymbolArray",vl);var xl=class extends Us{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]}get heightOffset(){return this._structArray.float32[this._pos4+16]}};xl.prototype.size=68;var bl=class extends ul{get(e){return new xl(this,e)}};Po("SymbolInstanceArray",bl);var wl=class extends hl{getoffsetX(e){return this.float32[1*e+0]}};Po("GlyphOffsetArray",wl);var Tl=class extends Ws{getx(e){return this.int16[3*e+0]}gety(e){return this.int16[3*e+1]}gettileUnitDistanceFromAnchor(e){return this.int16[3*e+2]}};Po("SymbolLineVertexArray",Tl);var Sl=class extends Us{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]}};Sl.prototype.size=12;var Dl=class extends cl{get(e){return new Sl(this,e)}};Po("TextAnchorOffsetArray",Dl);var El=class extends Us{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]}};El.prototype.size=8;var Cl=class extends dl{get(e){return new El(this,e)}};Po("FeatureIndexArray",Cl);var Pl=class extends qs{},Al=class extends Ws{},Il=class extends Hs{},Ml=class extends qs{},Fl=class extends qs{},zl=class extends Xs{},kl=class extends Ys{},Rl=class extends Ks{},Ll=class extends Js{},Bl=class extends Qs{},Ol=class extends el{},jl=class extends tl{},Vl=class extends il{},Nl=class extends al{},Ul=class extends nl{},$l=class extends ol{},Gl=class extends sl{},Zl=class extends sl{},ql=class extends pl{},Wl=class extends fl{},Hl=Gs([{name:"a_pos",components:2,type:"Int16"}],4),Xl=Hl.members;Hl.size,Hl.alignment;var Yl=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&&Oe(`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 Kl(e,t){return 256*(e=Se(Math.floor(e),0,255))+Se(Math.floor(t),0,255)}Yl.MAX_VERTEX_ARRAY_LENGTH=65535,Po("SegmentVector",Yl);var Jl=Gs([{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"}]),Ql=Gs([{name:"a_dasharray_from",components:4,type:"Uint16"},{name:"a_dasharray_to",components:4,type:"Uint16"}]),eu=/* @__PURE__ */l((e,t)=>{void 0!==t&&(t.exports=function(e,t){for(var i,r,a=3&e.length,n=e.length-a,o=t,s=3432918353,l=461845907,u=0;u<n;)r=255&e.charCodeAt(u)|(255&e.charCodeAt(++u))<<8|(255&e.charCodeAt(++u))<<16|(255&e.charCodeAt(++u))<<24,++u,o=27492+(65535&(i=5*(65535&(o=(o^=r=(65535&(r=(r=(65535&r)*s+(((r>>>16)*s&65535)<<16)|0)<<15|r>>>17))*l+(((r>>>16)*l&65535)<<16)|0)<<13|o>>>19))+((5*(o>>>16)&65535)<<16)|0))+(((i>>>16)+58964&65535)<<16);switch(r=0,a){case 3:r^=(255&e.charCodeAt(u+2))<<16;case 2:r^=(255&e.charCodeAt(u+1))<<8;case 1:o^=r=(65535&(r=(r=(65535&(r^=255&e.charCodeAt(u)))*s+(((r>>>16)*s&65535)<<16)|0)<<15|r>>>17))*l+(((r>>>16)*l&65535)<<16)|0}return o^=e.length,o=2246822507*(65535&(o^=o>>>16))+((2246822507*(o>>>16)&65535)<<16)|0,o=3266489909*(65535&(o^=o>>>13))+((3266489909*(o>>>16)&65535)<<16)|0,(o^=o>>>16)>>>0})}),tu=/* @__PURE__ */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}}),iu=/* @__PURE__ */h(/* @__PURE__ */l((e,t)=>{var i=eu(),r=tu();t.exports=i,t.exports.murmur3=i,t.exports.murmur2=r})(),1),ru=class e{constructor(){this.ids=[],this.positions=[],this.indexed=!1}add(e,t,i,r){this.ids.push(au(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=au(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 nu(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 au(e){let t=+e;return!isNaN(t)&&t<=2**53-1?t:(0,iu.default)(String(e))}function nu(e,t,i,r){for(;i<r;){let a=e[i+r>>1],n=i-1,o=r+1;for(;;){do{n++}while(e[n]<a);do{o--}while(e[o]>a);if(n>=o)break;ou(e,n,o),ou(t,3*n,3*o),ou(t,3*n+1,3*o+1),ou(t,3*n+2,3*o+2)}o-i<r-o?(nu(e,t,i,o),i=o+1):(nu(e,t,o+1,r),r=o)}}function ou(e,t,i){let r=e[t];e[t]=e[i],e[i]=r}Po("FeaturePositionMap",ru);var su=class{constructor(e,t){this.gl=e.gl,this.location=t}},lu=class extends su{constructor(e,t){super(e,t),this.current=0}set(e){this.current!==e&&(this.current=e,this.gl.uniform1i(this.location,e))}},uu=class extends su{constructor(e,t){super(e,t),this.current=0}set(e){this.current!==e&&(this.current=e,this.gl.uniform1f(this.location,e))}},hu=class extends su{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]))}},cu=class extends su{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]))}},du=class extends su{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]))}},pu=class extends su{constructor(e,t){super(e,t),this.current=Wi.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))}},fu=class extends su{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)}}},mu=class extends su{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)}}},_u=/* @__PURE__ */new Float32Array(16),gu=class extends su{constructor(e,t){super(e,t),this.current=_u}set(e){if(e[12]!==this.current[12]||e[0]!==this.current[0])this.current=e,this.gl.uniformMatrix4fv(this.location,!1,e);else 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 yu(e){return[Kl(255*e.r,255*e.g),Kl(255*e.b,255*e.a)]}var vu=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 pu(e,t):new uu(e,t)}},xu=class{constructor(e,t){this.uniformNames=t.map(e=>`u_${e}`),this.patternFrom=null,this.patternTo=null,this.dashFrom=null,this.dashTo=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 du(e,t):new uu(e,t)}},bu=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 gs(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 gs(0,a),i,r);this._setPaintValue(e,t,n)}_setPaintValue(e,t,i){if("color"===this.type){let r=yu(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()}},wu=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 gs(this.zoom,i),t,{},i.canonical,[],i.formattedSection),a=this.expression.evaluate(new gs(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 gs(this.zoom,a),i,r),o=this.expression.evaluate(new gs(this.zoom+1,a),i,r);this._setPaintValue(e,t,n,o)}_setPaintValue(e,t,i,r){if("color"===this.type){let a=yu(i),n=yu(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=Se(this.expression.interpolationFactor(i,this.zoom,this.zoom+1),0,1);e.set(r)}getBinding(e,t,i){return new uu(e,t)}},Tu=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],o=a[i.mid],s=a[i.max];if(n&&o&&s)for(let l=e;l<t;l++)this.emplace(this.zoomInPaintVertexArray,l,n,o),this.emplace(this.zoomOutPaintVertexArray,l,s,o)}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()}},Su=class extends Tu{getPositions(e){return e.imagePositions}getPositionIds(e){return e.patterns?.[this.layerId]}getVertexAttributes(){return Jl.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)}},Du=class extends Tu{getPositions(e){return e.dashPositions}getPositionIds(e){return e.dashes?.[this.layerId]}getVertexAttributes(){return Ql.members}emplace(e,t,i,r){e.emplace(t,0,i.y,i.height,i.width,0,r.y,r.height,r.width)}},Eu=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 Ss&&Xa(n.property.specification)))continue;let o=Pu(a,e.type),s=n.value,l=n.property.specification.type,u=n.property.useIntegerZoom,h=n.property.specification["property-type"],c="cross-faded"===h||"cross-faded-data-driven"===h;if("constant"===s.kind)this.binders[a]=c?new xu(s.value,o):new vu(s.value,o,l),r.push(`/u_${a}`);else if("source"===s.kind||c){let i=Au(a,l,"source");this.binders[a]=c?"line-dasharray"===a?new Du(s,l,u,t,i,e.id):new Su(s,l,u,t,i,e.id):new bu(s,o,l,i),r.push(`/a_${a}`)}else{let e=Au(a,l,"composite");this.binders[a]=new wu(s,o,l,u,t,e),r.push(`/z_${a}`)}}this.cacheKey=r.sort().join("")}getMaxValue(e){let t=this.binders[e];return t instanceof bu||t instanceof wu?t.maxValue:0}populatePaintArrays(e,t,i){for(let r in this.binders){let a=this.binders[r];(a instanceof bu||a instanceof wu||a instanceof Tu)&&a.populatePaintArray(e,t,i)}}setConstantPatternPositions(e,t){for(let i in this.binders){let r=this.binders[i];r instanceof xu&&r.setConstantPatternPositions(e,t)}}setConstantDashPositions(e,t){for(let i in this.binders){let r=this.binders[i];r instanceof xu&&r.setConstantDashPositions(e,t)}}updatePaintArrays(e,t,i,r,a){let n=!1;for(let o of e){let e=t.getPositions(o.id);for(let t of e){let e=i.feature(t.index);for(let i in this.binders){let s=this.binders[i];(s instanceof bu||s instanceof wu||s instanceof Tu)&&!0===s.expression.isStateDependent&&(s.expression=r.paint.get(i).value,s.updatePaintArray(t.start,t.end,e,o.state,a),n=!0)}}}return n}defines(){let e=[];for(let t in this.binders){let i=this.binders[t];(i instanceof vu||i instanceof xu)&&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 bu||i instanceof wu)for(let t of i.paintVertexAttributes)e.push(t.name);else if(i instanceof Tu){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 vu||i instanceof xu||i instanceof wu)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 vu||a instanceof xu||a instanceof wu)for(let n of a.uniformNames)if(t[n]){let o=a.getBinding(e,t[n],n);i.push({name:n,property:r,binding:o})}}return i}setUniforms(e,t,i,r){for(let{name:a,property:n,binding:o}of t)this.binders[n].setUniform(o,r,i.get(n),a)}updatePaintBuffers(e){this._buffers=[];for(let t in this.binders){let i=this.binders[t];if(e&&i instanceof Tu){let t=2===e.fromScale?i.zoomInPaintVertexBuffer:i.zoomOutPaintVertexBuffer;t&&this._buffers.push(t)}else(i instanceof bu||i instanceof wu)&&i.paintVertexBuffer&&this._buffers.push(i.paintVertexBuffer)}}upload(e){for(let t in this.binders){let i=this.binders[t];(i instanceof bu||i instanceof wu||i instanceof Tu)&&i.upload(e)}this.updatePaintBuffers()}destroy(){for(let e in this.binders){let t=this.binders[e];(t instanceof bu||t instanceof wu||t instanceof Tu)&&t.destroy()}}},Cu=class{constructor(e,t,i=()=>!0){this.programConfigurations={};for(let r of e)this.programConfigurations[r.id]=new Eu(r,t,i);this.needsUpload=!1,this._featureMap=new ru,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 Pu(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 Au(e,t,i){let r={color:{source:Ks,composite:ml},number:{source:hl,composite:Ks}};return function(e){return{"line-pattern":{source:Ll,composite:Ll},"fill-pattern":{source:Ll,composite:Ll},"fill-extrusion-pattern":{source:Ll,composite:Ll},"line-dasharray":{source:Bl,composite:Bl}}[e]}(e)?.[i]||r[t][i]}Po("ConstantBinder",vu),Po("CrossFadedConstantBinder",xu),Po("SourceExpressionBinder",bu),Po("CrossFadedPatternBinder",Su),Po("CrossFadedDasharrayBinder",Du),Po("CompositeExpressionBinder",wu),Po("ProgramConfiguration",Eu,{omit:["_buffers"]}),Po("ProgramConfigurationSet",Cu);var Iu=16383,Mu=-Iu-1;function Fu(e){let t=re/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=Se(i,Mu,Iu),e.y=Se(r,Mu,Iu),(i<e.x||i>e.x+1||r<e.y||r>e.y+1)&&Oe("Geometry exceeds allowed extent, reduce your vector tile buffer size")}return i}function zu(e,t){return{type:e.type,id:e.id,properties:e.properties,geometry:t?Fu(e):[]}}var ku=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 d(this.minX,this.minY))),i.extend(t(new d(this.maxX,this.minY))),i.extend(t(new d(this.minX,this.maxY))),i.extend(t(new d(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}},Ru=ku.fromPoints([new d(0,0),new d(re,re)]);function Lu(e,t){return e.x===t.x&&(e.x<0||e.x>8192)||e.y===t.y&&(e.y<0||e.y>8192)}function Bu(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)}function Ou(e){return e.x<0||e.x>=8192||e.y<0||e.y>=8192}var ju=-32768;function Vu(e,t,i,r,a){e.emplaceBack(ju+8*t+r,ju+8*i+a)}var Nu,Uu=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 Ml,this.indexArray=new Zl,this.segments=new Yl,this.programConfigurations=new Cu(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,o=!1,s="heatmap"===r.type;if("circle"===r.type){let e=r;n=e.layout.get("circle-sort-key"),o=!n.isConstant(),s||="map"===e.paint.get("circle-pitch-alignment")}let l=s?t.subdivisionGranularity.circle:1,u=new gs(this.zoom),h=this.layers[0]._featureFilter.needGeometry;for(let{feature:c,id:d,index:p,sourceLayerIndex:f}of e){let e=zu(c,h);if(!this.layers[0]._featureFilter.filter(u,e,i))continue;let t=o?n.evaluate(e,{},i):void 0,r={id:d,properties:c.properties,type:c.type,sourceLayerIndex:f,index:p,geometry:h?e.geometry:Fu(c),patterns:{},sortKey:t};a.push(r)}o&&a.sort((e,t)=>e.sortKey-t.sortKey);for(let c of a){let{geometry:r,index:a,sourceLayerIndex:n}=c,o=e[a].feature;this.addFeature(c,r,a,i,l),t.featureIndex.insert(o,r,a,n,this.index)}}update(e,t,i){this.stateDependentLayers.length&&this.programConfigurations.updatePaintArrays(e,t,this.stateDependentLayers,{imagePositions:i})}addFeatures(e){}isEmpty(){return 0===this.layoutVertexArray.length}uploadPending(){return!this.uploaded||this.programConfigurations.needsUpload}upload(e){this.uploaded||(this.layoutVertexBuffer=e.createVertexBuffer(this.layoutVertexArray,Xl),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 o=n.length;for(let s of t)for(let t of s){let i=t.x,r=t.y;if(Ou(t))continue;let a=this.segments.prepareSegment(o*o,this.layoutVertexArray,this.indexArray,e.sortKey),s=a.vertexLength;for(let e=0;e<o;e++)for(let t=0;t<o;t++)Vu(this.layoutVertexArray,i,r,n[t],n[e]);for(let e=0;e<o-1;e++)for(let t=0;t<o-1;t++){let i=s+e*o+t,r=s+(e+1)*o+t;this.indexArray.emplaceBack(i,r+1,i+1),this.indexArray.emplaceBack(i,r,r+1)}a.vertexLength+=o*o,a.primitiveLength+=(o-1)*(o-1)*2}this.programConfigurations.populatePaintArrays(this.layoutVertexArray.length,e,i,{imagePositions:{},canonical:r})}};function $u(e,t){for(let i of e)if(Ju(t,i))return!0;for(let i of t)if(Ju(e,i))return!0;return Wu(e,t)}function Gu(e,t,i){return!!Ju(e,t)||Xu(t,e,i)}function Zu(e,t){if(1===e.length)return Ku(t,e[0]);for(let i of t)for(let t of i)if(Ju(e,t))return!0;for(let i of e)if(Ku(t,i))return!0;for(let i of t)if(Wu(e,i))return!0;return!1}function qu(e,t,i){if(e.length>1){if(Wu(e,t))return!0;for(let r of t)if(Xu(r,e,i))return!0}for(let r of e)if(Xu(r,t,i))return!0;return!1}function Wu(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(Hu(r,a,t[e],t[e+1]))return!0}return!1}function Hu(e,t,i,r){return je(e,i,r)!==je(t,i,r)&&je(e,t,i)!==je(e,t,r)}function Xu(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(Yu(e,t[a-1],t[a])<r)return!0;return!1}function Yu(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 Ku(e,t){let i,r,a,n=!1;for(let o of e){i=o;for(let e=0,o=i.length-1;e<i.length;o=e++)r=i[e],a=i[o],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 Ju(e,t){let i=!1;for(let r=0,a=e.length-1;r<e.length;a=r++){let n=e[r],o=e[a];n.y>t.y!=o.y>t.y&&t.x<(o.x-n.x)*(t.y-n.y)/(o.y-n.y)+n.x&&(i=!i)}return i}function Qu(e,t,i,r,a){for(let o of e)if(t<=o.x&&i<=o.y&&r>=o.x&&a>=o.y)return!0;let n=[new d(t,i),new d(t,a),new d(r,a),new d(r,i)];if(e.length>2)for(let o of n)if(Ju(e,o))return!0;for(let o=0;o<e.length-1;o++)if(eh(e[o],e[o+1],n))return!0;return!1}function eh(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=je(e,t,i[0]);return n!==je(e,t,i[1])||n!==je(e,t,i[2])||n!==je(e,t,i[3])}function th(e,t,i){let r=t.paint.get(e).value;return"constant"===r.kind?r.value:i.programConfigurations.get(t.id).getMaxValue(e)}function ih(e){return Math.sqrt(e[0]*e[0]+e[1]*e[1])}function rh(e,t,i,r,a){if(!t[0]&&!t[1])return e;let n=d.convert(t)._mult(a);"viewport"===i&&n._rotate(-r);let o=[];for(let s of e)o.push(s.sub(n));return o}function ah(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 nh({queryGeometry:e,size:t},i){return Gu(e,i,t)}function oh({queryGeometry:e,size:t,transform:i,unwrappedTileID:r,getElevation:a},n){return Gu(e,n,t*(i.projectTileCoordinates(n.x,n.y,r,a?.(n.x,n.y)).signedDistanceFromCamera/i.cameraToCenterDistance))}function sh({queryGeometry:e,size:t,transform:i,unwrappedTileID:r,getElevation:a},n){let o=i.projectTileCoordinates(n.x,n.y,r,a?.(n.x,n.y)).signedDistanceFromCamera,s=t*(i.cameraToCenterDistance/o);return Gu(e,hh(n,i,r,a),s)}function lh({queryGeometry:e,size:t,transform:i,unwrappedTileID:r,getElevation:a},n){return Gu(e,hh(n,i,r,a),t)}function uh({queryGeometry:e,size:t,transform:i,unwrappedTileID:r,getElevation:a,pitchAlignment:n="map",pitchScale:o="map"},s){let l="map"===n?"map"===o?nh:oh:"map"===o?sh:lh,u={queryGeometry:e,size:t,transform:i,unwrappedTileID:r,getElevation:a};for(let h of s)for(let e of h)if(l(u,e))return!0;return!1}function hh(e,t,i,r){let a=t.projectTileCoordinates(e.x,e.y,i,r?.(e.x,e.y)).point;return new d((.5*a.x+.5)*t.width,(.5*-a.y+.5)*t.height)}Po("CircleBucket",Uu,{omit:["layers"]});var ch,dh,ph={get paint(){return ch||=new zs({"circle-radius":new As(Nt.paint_circle["circle-radius"],"circle-radius"),"circle-color":new As(Nt.paint_circle["circle-color"],"circle-color"),"circle-blur":new As(Nt.paint_circle["circle-blur"],"circle-blur"),"circle-opacity":new As(Nt.paint_circle["circle-opacity"],"circle-opacity"),"circle-translate":new Ps(Nt.paint_circle["circle-translate"],"circle-translate"),"circle-translate-anchor":new Ps(Nt.paint_circle["circle-translate-anchor"],"circle-translate-anchor"),"circle-pitch-scale":new Ps(Nt.paint_circle["circle-pitch-scale"],"circle-pitch-scale"),"circle-pitch-alignment":new Ps(Nt.paint_circle["circle-pitch-alignment"],"circle-pitch-alignment"),"circle-stroke-width":new As(Nt.paint_circle["circle-stroke-width"],"circle-stroke-width"),"circle-stroke-color":new As(Nt.paint_circle["circle-stroke-color"],"circle-stroke-color"),"circle-stroke-opacity":new As(Nt.paint_circle["circle-stroke-opacity"],"circle-stroke-opacity")})},get layout(){return Nu||=new zs({"circle-sort-key":new As(Nt.layout_circle["circle-sort-key"],"circle-sort-key")})}},fh=class extends Bs{constructor(e,t){super(e,ph,t)}createBucket(e){return new Uu(e)}queryRadius(e){let t=e;return th("circle-radius",this,t)+th("circle-stroke-width",this,t)+ih(this.paint.get("circle-translate"))}queryIntersectsFeature({queryGeometry:e,feature:t,featureState:i,geometry:r,transform:a,pixelsToTileUnits:n,unwrappedTileID:o,getElevation:s}){let l,u,h=rh(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),d=this.paint.get("circle-pitch-scale"),p=this.paint.get("circle-pitch-alignment");return"map"===p?(l=h,u=c*n):(l=function(e,t,i,r){return e.map(e=>hh(e,t,i,r))}(h,a,o,s),u=c),uh({queryGeometry:l,size:u,transform:a,unwrappedTileID:o,getElevation:s,pitchAlignment:p,pitchScale:d},r)}},mh=class extends Uu{};Po("HeatmapBucket",mh,{omit:["layers"]});var _h={get paint(){return dh||=new zs({"heatmap-radius":new As(Nt.paint_heatmap["heatmap-radius"],"heatmap-radius"),"heatmap-weight":new As(Nt.paint_heatmap["heatmap-weight"],"heatmap-weight"),"heatmap-intensity":new Ps(Nt.paint_heatmap["heatmap-intensity"],"heatmap-intensity"),"heatmap-color":new Fs(Nt.paint_heatmap["heatmap-color"],"heatmap-color"),"heatmap-opacity":new Ps(Nt.paint_heatmap["heatmap-opacity"],"heatmap-opacity")})}};function gh(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 yh(e,{width:t,height:i},r){if(t===e.width&&i===e.height)return;let a=gh({},{width:t,height:i},r);vh(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 vh(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 o=e.data,s=t.data;if(o===s)throw Error("srcData equals dstData, so image is already copied");for(let l=0;l<a.height;l++){let u=((i.y+l)*e.width+i.x)*n,h=((r.y+l)*t.width+r.x)*n;for(let e=0;e<a.width*n;e++)s[h+e]=o[u+e]}return t}var xh=class e{constructor(e,t){gh(this,e,1,t)}resize(e){yh(this,e,1)}clone(){return new e({width:this.width,height:this.height},new Uint8Array(this.data))}static copy(e,t,i,r,a){vh(e,t,i,r,a,1)}},bh=class e{constructor(e,t){gh(this,e,4,t)}resize(e){yh(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){vh(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 wh(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 Th(e){let t={},i=e.resolution||256,r=e.clips?e.clips.length:1,a=e.image||new bh({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,o)=>{t[e.evaluationKey]=o;let s=e.expression.evaluate(t);a.setPixel(r/4/i,n/4,s)};if(e.clips)for(let o=0,s=0;o<r;++o,s+=4*i)for(let t=0,r=0;t<i;t++,r+=4){let a=t/(i-1),{start:l,end:u}=e.clips[o];n(s,r,l*(1-a)+u*a)}else for(let o=0,s=0;o<i;o++,s+=4)n(0,s,o/(i-1));return a}Po("AlphaImage",xh),Po("RGBAImage",bh);var Sh,Dh,Eh="big-fb",Ch=class extends Bs{createBucket(e){return new mh(e)}constructor(e,t){super(e,_h,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=Th({expression:e,evaluationKey:"heatmapDensity",image:this.colorRamp}),this.colorRampTexture=null}resize(){this.heatmapFbos.has("big-fb")&&this.heatmapFbos.delete(Eh)}queryRadius(e){return th("heatmap-radius",this,e)}queryIntersectsFeature({queryGeometry:e,feature:t,featureState:i,geometry:r,transform:a,pixelsToTileUnits:n,unwrappedTileID:o,getElevation:s}){return uh({queryGeometry:e,size:this.paint.get("heatmap-radius").evaluate(t,i)*n,transform:a,unwrappedTileID:o,getElevation:s},r)}hasOffscreenPass(){return 0!==this.paint.get("heatmap-opacity")&&!this.isHidden()}},Ph={get paint(){return Sh||=new zs({"hillshade-illumination-direction":new Ps(Nt.paint_hillshade["hillshade-illumination-direction"],"hillshade-illumination-direction"),"hillshade-illumination-altitude":new Ps(Nt.paint_hillshade["hillshade-illumination-altitude"],"hillshade-illumination-altitude"),"hillshade-illumination-anchor":new Ps(Nt.paint_hillshade["hillshade-illumination-anchor"],"hillshade-illumination-anchor"),"hillshade-exaggeration":new Ps(Nt.paint_hillshade["hillshade-exaggeration"],"hillshade-exaggeration"),"hillshade-shadow-color":new Ps(Nt.paint_hillshade["hillshade-shadow-color"],"hillshade-shadow-color"),"hillshade-highlight-color":new Ps(Nt.paint_hillshade["hillshade-highlight-color"],"hillshade-highlight-color"),"hillshade-accent-color":new Ps(Nt.paint_hillshade["hillshade-accent-color"],"hillshade-accent-color"),"hillshade-method":new Ps(Nt.paint_hillshade["hillshade-method"],"hillshade-method"),resampling:new Ps(Nt.paint_hillshade.resampling,"resampling")})}},Ah=class extends Bs{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(qe);return{directionRadians:e.map(qe),altitudeRadians:n,shadowColor:r,highlightColor:i}}hasOffscreenPass(){return 0!==this.paint.get("hillshade-exaggeration")&&!this.isHidden()}},Ih={get paint(){return Dh||=new zs({"color-relief-opacity":new Ps(Nt["paint_color-relief"]["color-relief-opacity"],"color-relief-opacity"),"color-relief-color":new Fs(Nt["paint_color-relief"]["color-relief-color"],"color-relief-color"),resampling:new Ps(Nt["paint_color-relief"].resampling,"resampling")})}};function Mh(e){return"data"in e}var Fh=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:o}=this,{gl:s}=o;this.useMipmap=!!t?.useMipmap,n&&this.size&&this.format===s.RGBA&&(s.deleteTexture(this.texture),this.texture=s.createTexture(),this._ownedHandle=this.texture,this.magFilter=void 0,this.minFilter=void 0,this.wrap=void 0),s.bindTexture(s.TEXTURE_2D,this.texture),o.pixelStoreUnpackFlipY.set(!1),o.pixelStoreUnpack.set(1);let l=this.format===s.RGBA&&!1!==t?.premultiply;if(n)if(this.size=[r,a],this.format===s.RGBA&&r>0&&a>0){let t=this.useMipmap?Math.floor(Math.log2(Math.max(r,a)))+1:1;if(s.texStorage2D(s.TEXTURE_2D,t,s.RGBA8,r,a),Mh(e)){o.pixelStoreUnpackPremultiplyAlpha.set(!1);let{data:t}=e;l&&t&&(t=wh(t)),t&&s.texSubImage2D(s.TEXTURE_2D,0,0,0,r,a,s.RGBA,s.UNSIGNED_BYTE,t)}else o.pixelStoreUnpackPremultiplyAlpha.set(l),s.texSubImage2D(s.TEXTURE_2D,0,0,0,s.RGBA,s.UNSIGNED_BYTE,e)}else Mh(e)?(o.pixelStoreUnpackPremultiplyAlpha.set(!1),this._uploadRawData(e,l,r,a,s)):(o.pixelStoreUnpackPremultiplyAlpha.set(l),this._uploadDomImage(e,s));else{let{x:t,y:n}=i||{x:0,y:0};Mh(e)?(o.pixelStoreUnpackPremultiplyAlpha.set(!1),this._updateRawData(e,l,t,n,r,a,s)):(o.pixelStoreUnpackPremultiplyAlpha.set(l),this._updateDomImage(e,t,n,s))}this.useMipmap&&!(Mh(e)&&null===e.data)&&s.generateMipmap(s.TEXTURE_2D),o.pixelStoreUnpackFlipY.setDefault(),o.pixelStoreUnpack.setDefault(),o.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=wh(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,o){let{data:s}=e;t&&s&&(s=wh(s)),o.texSubImage2D(o.TEXTURE_2D,0,i,r,a,n,o.RGBA,o.UNSIGNED_BYTE,s)}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||i===a.LINEAR_MIPMAP_LINEAR)&&!this.useMipmap&&(i=a.LINEAR);let n=i||e;e!==this.magFilter&&(a.texParameteri(a.TEXTURE_2D,a.TEXTURE_MAG_FILTER,e),this.magFilter=e),n!==this.minFilter&&(a.texParameteri(a.TEXTURE_2D,a.TEXTURE_MIN_FILTER,n),this.minFilter=n),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)}generateMipmap(){if(!this.useMipmap)return;let{gl:e}=this.context;e.bindTexture(e.TEXTURE_2D,this.texture),e.generateMipmap(e.TEXTURE_2D)}destroy(){let{gl:e}=this.context;e.deleteTexture(this.texture),this.texture=null,this._ownedHandle=null}},zh=class e{static{this.byteViewCache=/* @__PURE__ */new WeakMap}constructor(t,i,r,a=1,n=1,o=1,s=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 Oe(`"${r}" is not a valid encoding type. Valid types include "mapbox", "terrarium" and "custom".`);this.stride=i.height;let l=this.dim=i.height-4;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=o,this.baseShift=s;break;default:this.redFactor=6553.6,this.greenFactor=25.6,this.blueFactor=.1,this.baseShift=1e4}for(let e=-2;e<l+2;e++){let t=this._idx(0,Math.max(0,Math.min(l-1,e)));(e<0||e>=l)&&this.data.copyWithin(this._idx(0,e),t,t+l),this.data.fill(this.data[t],this._idx(-2,e),this._idx(0,e)),this.data.fill(this.data[t+l-1],this._idx(l,e),this._idx(l+1,e)+1)}let u=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(u,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+2)*this.stride+i+2),o=4*this.stride,s=e-i,l=t-r;return this._unpackAtIndex(a,n)*(1-s)*(1-l)+this._unpackAtIndex(a,n+4)*s*(1-l)+this._unpackAtIndex(a,n+o)*(1-s)*l+this._unpackAtIndex(a,n+o+4)*s*l}getUnpackVector(){return[this.redFactor,this.greenFactor,this.blueFactor,this.baseShift]}_idx(e,t){if(e<-2||e>=this.dim+2||t<-2||t>=this.dim+2)throw RangeError(`Out of range source coordinates for DEM data. x: ${e}, y: ${t}, dim: ${this.dim}`);return(t+2)*this.stride+(e+2)}unpack(e,t,i){return e*this.redFactor+t*this.greenFactor+i*this.blueFactor-this.baseShift}pack(e){return kh(e,this.getUnpackVector())}getPixels(){return new bh({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,o=i*this.dim+this.dim;switch(t){case-1:r=a-2;break;case 1:a=r+2}switch(i){case-1:n=o-2;break;case 1:o=n+2}let s=-t*this.dim,l=-i*this.dim;for(let u=n;u<o;u++)for(let t=r;t<a;t++)this.data[this._idx(t,u)]=e.data[this._idx(t+s,u+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 kh(e,t){let i=t[0],r=t[1],a=t[2],n=t[3],o=[i,r,a].filter(e=>0!==e);if(0===o.length)return{r:0,g:0,b:0};let s=Math.min(...o),l=Math.round((e+n)/s),u=e=>0===e?0:Math.floor(l*s/e)%256;return{r:u(i),g:u(r),b:u(a)}}Po("DEMData",zh);var Rh=class extends Bs{constructor(e,t){super(e,Ih,t)}_createColorRamp(e){let t={elevationStops:[],colorStops:[]},i=this._transitionablePaint._values["color-relief-color"].value.expression;if(i instanceof gn&&i._styleExpression.expression instanceof mr){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=[Wi.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 Oe(`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 bh({width:r.colorStops.length,height:1}),n=new bh({width:r.colorStops.length,height:1});for(let o=0;o<r.elevationStops.length;o++){let e=kh(r.elevationStops[o],i);n.setPixel(0,o,new Wi(e.r/255,e.g/255,e.b/255,1)),a.setPixel(0,o,r.colorStops[o])}return this.colorRampTextures={elevationTexture:new Fh(e,n,e.gl.RGBA),colorTexture:new Fh(e,a,e.gl.RGBA)},this.colorRampTextures}hasOffscreenPass(){return!this.isHidden()&&!!this.colorRampTextures}},Lh=Gs([{name:"a_pos",components:2,type:"Int16"}],4),Bh=Lh.members;function Oh(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 jh(e,t,i,r,a){let{zoom:n}=r,o=a.patternDependencies;for(let s of t){let t=s.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,o[e]=!0,o[r]=!0,o[l]=!0,i.patterns[s.id]={min:e,mid:r,max:l}}}return i}Lh.size,Lh.alignment;var Vh=/* @__PURE__ */new Set,Nh=!1;function Uh(e,t,i,r,a){let n=null;if(a===function(e,t,i,r){let a=0;for(let n=t,o=i-r;n<i;n+=r)a+=(e[o]-e[n])*(e[n+1]+e[o+1]),o=n;return a}(e,t,i,r)>0)for(let o=t;o<i;o+=r)n=wc(o/r|0,e[o],e[o+1],n);else for(let o=i-r;o>=t;o-=r)n=wc(o/r|0,e[o],e[o+1],n);return n&&gc(n,n.next)&&(Tc(n),n=n.next),n}function $h(e,t=e){let i,r=t===e,a=e;do{i=!1,a===a.next||0!==Vh.size&&Vh.has(a)||!gc(a,a.next)&&0!==_c(a.prev,a,a.next)?(r||a!==t)&&(a=a.next,i=!r):((r||a===t)&&(t=a.prev),Nh=!0,Tc(a),a=a.prev,i=!0)}while(i||a!==t);return t}function Gh(e,t,i,r,a){a&&function(e,t,i,r){let a=e,n=0;do{a.z=dc(a.x,a.y,t,i,r),oc[n++]=a,a=a.next}while(a!==e);!function(e){if(e<=32)for(let t=1;t<e;t++){let e=oc[t],i=e.z,r=t-1;for(;r>=0&&oc[r].z>i;)oc[r+1]=oc[r],r--;oc[r+1]=e}else{lc.length<e&&(lc=new Uint32Array(e),uc=new Uint32Array(e),sc=Array(e));for(let t=0;t<e;t++)lc[t]=oc[t].z;cc(e,oc,lc,sc,uc,0),cc(e,sc,uc,oc,lc,8),cc(e,oc,lc,sc,uc,16),cc(e,sc,uc,oc,lc,24)}}(n);let o=null;for(let s=0;s<n;s++){let e=oc[s];e.prevZ=o,o&&(o.nextZ=e),o=e}o.nextZ=null,oc.fill(null,0,n),sc.fill(null,0,n)}(e,i,r,a);let n=e,o=!1;for(;e.prev!==e.next;){let s=e.prev,l=e.next;if(_c(s,e,l)<0&&(a?qh(e,i,r,a):Zh(e)))t.push(s.i,e.i,l.i),Tc(e),e=l,n=l;else if((e=l)===n){if(Nh=!1,e=$h(e),Nh){n=e;continue}if(!o){n=e=Wh(e,t),o=!0;continue}Hh(e,t,i,r,a);break}}}function Zh(e){let t=e.prev,i=e,r=e.next,a=t.x,n=i.x,o=r.x,s=t.y,l=i.y,u=r.y,h=Math.min(a,n,o),c=Math.min(s,l,u),d=Math.max(a,n,o),p=Math.max(s,l,u),f=r.next;for(;f!==t;){if(f.x>=h&&f.x<=d&&f.y>=c&&f.y<=p&&(a!==f.x||s!==f.y)&&fc(a,s,n,l,o,u,f.x,f.y)&&_c(f.prev,f,f.next)>=0)return!1;f=f.next}return!0}function qh(e,t,i,r){let a=e.prev,n=e,o=e.next,s=a.x,l=n.x,u=o.x,h=a.y,c=n.y,d=o.y,p=Math.min(s,l,u),f=Math.min(h,c,d),m=Math.max(s,l,u),_=Math.max(h,c,d),g=dc(p,f,t,i,r),y=dc(m,_,t,i,r),v=e.prevZ;for(;v&&v.z>=g;){if(v.x>=p&&v.x<=m&&v.y>=f&&v.y<=_&&v!==o&&(s!==v.x||h!==v.y)&&fc(s,h,l,c,u,d,v.x,v.y)&&_c(v.prev,v,v.next)>=0)return!1;v=v.prevZ}let x=e.nextZ;for(;x&&x.z<=y;){if(x.x>=p&&x.x<=m&&x.y>=f&&x.y<=_&&x!==o&&(s!==x.x||h!==x.y)&&fc(s,h,l,c,u,d,x.x,x.y)&&_c(x.prev,x,x.next)>=0)return!1;x=x.nextZ}return!0}function Wh(e,t){let i=e,r=!1;do{let a=i.prev,n=i.next.next;yc(a,i,i.next,n,!1)&&xc(a,n)&&xc(n,a)&&(t.push(a.i,i.i,n.i),Tc(i),Tc(i.next),i=e=n,r=!0),i=i.next}while(i!==e);return r?$h(i):i}function Hh(e,t,i,r,a){let n=e;do{let e=n.next.next;for(;e!==n.prev;){if(n.i!==e.i&&mc(n,e)){let o=bc(n,e);return n=$h(n,n.next),o=$h(o,o.next),Gh(n,t,i,r,a),void Gh(o,t,i,r,a)}e=e.next}n=n.next}while(n!==e)}var Xh=!1;function Yh(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 Kh(e,t){let i=function(e,t){let i,r=t,a=e.x,n=e.y,o=-1/0;if(gc(e,r))return r;for(let d=0,p=0;d<Qh;d++,p+=4){if(n<Jh[p+1]||n>Jh[p+3]||Jh[p]>a||Jh[p+2]<=o)continue;let t=rc(d);r=ac(d);do{if(r.prev.next===r){if(gc(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>o&&(o=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 s=i.x,l=i.y,u=Math.min(n,l),h=Math.max(n,l),c=1/0;for(let d=0,p=0;d<Qh;d++,p+=4){if(Jh[p+2]<s||Jh[p]>a||Jh[p+3]<u||Jh[p+1]>h)continue;let t=rc(d);r=ac(d);do{if(r.prev.next===r&&a>=r.x&&r.x>=s&&a!==r.x&&fc(n<l?a:o,n,s,l,n<l?o:a,n,r.x,r.y)){let t=Math.abs(n-r.y)/(a-r.x);(xc(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&&nc(i,r)))&&(i=r,c=t)}r=r.next}while(r!==t)}return i}(e,t);if(!i)return t;let r=bc(i,e);return ic(i,r.next.next),$h(r,r.next),$h(i,i.next)}var Jh=/* @__PURE__ */new Float64Array,Qh=0,ec=[],tc=[];function ic(e,t){let i=e;do{let e=Qh++;ec[e]=i;let r=i.x,a=i.y,n=i.x,o=i.y,s=0;do{let t=i.next;i.z=e,t.x<r&&(r=t.x),t.x>n&&(n=t.x),t.y<a&&(a=t.y),t.y>o&&(o=t.y),i=t}while(++s<16&&i!==t);tc[e]=i;let l=4*e;Jh[l]=r,Jh[l+1]=a,Jh[l+2]=n,Jh[l+3]=o}while(i!==t)}function rc(e){let t=tc[e];for(;t.prev.next!==t;)t=t.next;return tc[e]=t,t}function ac(e){let t=ec[e];for(;t.prev.next!==t;)t=t.next;return ec[e]=t,t}function nc(e,t){return _c(e.prev,e,t.prev)<0&&_c(t.next,e,e.next)<0}var oc=[],sc=[],lc=/* @__PURE__ */new Uint32Array,uc=/* @__PURE__ */new Uint32Array,hc=/* @__PURE__ */new Uint32Array(256);function cc(e,t,i,r,a,n){hc.fill(0);for(let s=0;s<e;s++)hc[i[s]>>>n&255]++;let o=0;for(let s=0;s<256;s++){let e=hc[s];hc[s]=o,o+=e}for(let s=0;s<e;s++){let e=i[s],o=hc[e>>>n&255]++;r[o]=t[s],a[o]=e}}function dc(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 pc(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 fc(e,t,i,r,a,n,o,s){return(a-o)*(t-s)>=(e-o)*(n-s)&&(e-o)*(r-s)>=(i-o)*(t-s)&&(i-o)*(n-s)>=(a-o)*(r-s)}function mc(e,t){let i=gc(e,t)&&_c(e.prev,e,e.next)>0&&_c(t.prev,t,t.next)>0;return e.next.i!==t.i&&(i||xc(e,t)&&xc(t,e)&&(0!==_c(e.prev,e,t.prev)||0!==_c(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),o=e;do{let s=o.next;if(o.x>r&&s.x>r||o.x<i&&s.x<i||o.y>n&&s.y>n||o.y<a&&s.y<a)o=s;else{if(o.i!==e.i&&s.i!==e.i&&o.i!==t.i&&s.i!==t.i&&yc(o,s,e,t))return!0;o=s}}while(o!==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 _c(e,t,i){return(t.y-e.y)*(i.x-t.x)-(t.x-e.x)*(i.y-t.y)}function gc(e,t){return e.x===t.x&&e.y===t.y}function yc(e,t,i,r,a=!0){let n=_c(e,t,i),o=_c(e,t,r),s=_c(i,r,e),l=_c(i,r,t);return(n>0&&o<0||n<0&&o>0)&&(s>0&&l<0||s<0&&l>0)||!!a&&!!(0===n&&vc(e,i,t)||0===o&&vc(e,r,t)||0===s&&vc(i,e,r)||0===l&&vc(i,t,r))}function vc(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 xc(e,t){return _c(e.prev,e,e.next)<0?_c(e,t,e.next)>=0&&_c(e,e.prev,t)>=0:_c(e,t,e.prev)<0||_c(e,e.next,t)<0}function bc(e,t){let i=Sc(e.i,e.x,e.y),r=Sc(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 wc(e,t,i,r){let a=Sc(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 Tc(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),Xh&&function(e,t){let i=4*e.z;t.x<Jh[i]&&(Jh[i]=t.x),t.y<Jh[i+1]&&(Jh[i+1]=t.y),t.x>Jh[i+2]&&(Jh[i+2]=t.x),t.y>Jh[i+3]&&(Jh[i+3]=t.y)}(e.prev,e.next)}function Sc(e,t,i){return{i:e,x:t,y:i,prev:null,next:null,z:0,prevZ:null,nextZ:null}}var Dc=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)}},Ec=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 Dc(0,0),line:new Dc(0,0),tile:new Dc(0,0),stencil:new Dc(0,0),circle:1})}};Po("SubdivisionGranularityExpression",Dc),Po("SubdivisionGranularitySetting",Ec);var Cc=-32768,Pc=32767,Ac=class{constructor(e,t){this._vertexBuffer=[],this._vertexDictionary=/* @__PURE__ */new Map,this._used=!1,this._granularity=e,this._granularityCellSize=re/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),n=this._vertexDictionary.get(a);if(void 0!==n)return n;let o=this._vertexBuffer.length/2;return this._vertexDictionary.set(a,o),this._vertexBuffer.push(i,r),o}_subdivideTrianglesScanline(e,t){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],o=t[r+2],s=e[2*a],l=e[2*a+1],u=e[2*n],h=e[2*n+1],c=e[2*o];(u-s)*(e[2*o+1]-l)-(h-l)*(c-s)>0?(i.push(a),i.push(o),i.push(n)):(i.push(a),i.push(n),i.push(o))}return i}(this._vertexBuffer,function(e,t){let i=Array(e.length);for(let r=0;r<e.length;r++)i[r]=t[e[r]];return i}(e,t));let i=[],r=e.length;for(let a=0;a<r;a+=3){let r=[t[e[a+0]],t[e[a+1]],t[e[a+2]]],n=[this._vertexBuffer[2*r[0]+0],this._vertexBuffer[2*r[0]+1],this._vertexBuffer[2*r[1]+0],this._vertexBuffer[2*r[1]+1],this._vertexBuffer[2*r[2]+0],this._vertexBuffer[2*r[2]+1]],o=1/0,s=1/0,l=-1/0,u=-1/0;for(let e=0;e<3;e++){let t=n[2*e],i=n[2*e+1];o=Math.min(o,t),l=Math.max(l,t),s=Math.min(s,i),u=Math.max(u,i)}if(o===l||s===u)continue;let h=Math.floor(o/this._granularityCellSize),c=Math.ceil(l/this._granularityCellSize),d=Math.floor(s/this._granularityCellSize),p=Math.ceil(u/this._granularityCellSize);if(h===c&&d===p)i.push(...r);else for(let e=d;e<p;e++){let t=this._scanlineGenerateVertexRingForCellRow(e,n,r);zc(this._vertexBuffer,t,i)}}return i}_scanlineGenerateVertexRingForCellRow(e,t,i){let r=e*this._granularityCellSize,a=r+this._granularityCellSize,n=[];for(let o=0;o<3;o++){let e=t[2*o],s=t[2*o+1],l=t[2*(o+1)%6],u=t[(2*(o+1)+1)%6],h=t[2*(o+2)%6],c=t[(2*(o+2)+1)%6],d=l-e,p=u-s,f=0===d,m=0===p,_=(r-s)/p,g=(a-s)/p,y=Math.min(_,g),v=Math.max(_,g);if(!m&&(y>=1||v<=0)||m&&(s<r||s>a)){u>=r&&u<=a&&n.push(i[(o+1)%3]);continue}if(!m&&y>0){let t=e+d*y,i=s+p*y;n.push(this._vertexToIndex(t,i))}let x=e+d*Math.max(y,0),b=e+d*Math.min(v,1);if(f||this._generateIntraEdgeVertices(n,e,s,l,u,x,b),!m&&v<1){let t=e+d*v,i=s+p*v;n.push(this._vertexToIndex(t,i))}(m||u>=r&&u<=a)&&n.push(i[(o+1)%3]),!m&&(u<=r||u>=a)&&this._generateInterEdgeVertices(n,e,s,l,u,h,c,b,r,a)}return n}_generateIntraEdgeVertices(e,t,i,r,a,n,o){let s=r-t,l=a-i,u=0===l,h=u?Math.min(t,r):Math.min(n,o),c=u?Math.max(t,r):Math.max(n,o),d=Math.floor(h/this._granularityCellSize)+1,p=Math.ceil(c/this._granularityCellSize)-1;if(u?t<r:n<o)for(let f=d;f<=p;f++){let r=f*this._granularityCellSize,a=i+l*(r-t)/s;e.push(this._vertexToIndex(r,a))}else for(let f=p;f>=d;f--){let r=f*this._granularityCellSize,a=i+l*(r-t)/s;e.push(this._vertexToIndex(r,a))}}_generateInterEdgeVertices(e,t,i,r,a,n,o,s,l,u){let h=a-i,c=n-r,d=o-a,p=(l-a)/d,f=(u-a)/d,m=Math.min(p,f),_=Math.max(p,f),g=r+c*m,y=Math.floor(Math.min(g,s)/this._granularityCellSize)+1,v=Math.ceil(Math.max(g,s)/this._granularityCellSize)-1,x=s<g,b=0===d;if(b&&(o===l||o===u))return;if(b||m>=1||_<=0){let e=i-o,r=(l-o)/e,a=(u-o)/e,h=n+(t-n)*Math.min(r,a);y=Math.floor(Math.min(h,s)/this._granularityCellSize)+1,v=Math.ceil(Math.max(h,s)/this._granularityCellSize)-1,x=s<h}let w=h>0?u: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,t){let i=[],r=0;for(let a of e){let e=this._granularity<2?this._ringPathIndices(a,r,t):this._pointArrayToIndices(Mc(a,this._granularity,!0));r+=a.length;let n=[];for(let t=1;t<e.length;t++)n.push(e[t-1]),n.push(e[t]);i.push(n)}return i}_ringPathIndices(e,t,i){let r=i.slice(t,t+e.length);return r.length>=2&&Fc(e)&&r.push(r[0]),r}_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=re,n=e.length;for(let o=2;o<n;o+=3){let n=e[o-2],s=e[o-1],l=e[o],u=r[2*n],h=r[2*n+1],c=r[2*s],d=r[2*s+1],p=r[2*l],f=r[2*l+1];t&&(0===h&&0===d&&this._generatePoleQuad(e,n,s,u,c,Cc),0===d&&0===f&&this._generatePoleQuad(e,s,l,c,p,Cc),0===f&&0===h&&this._generatePoleQuad(e,l,n,p,u,Cc)),i&&(h===a&&d===a&&this._generatePoleQuad(e,n,s,u,c,Pc),d===a&&f===a&&this._generatePoleQuad(e,s,l,c,p,Pc),f===a&&h===a&&this._generatePoleQuad(e,l,n,p,u,Pc))}}_initializeVertices(e){let t=[];for(let i=0;i<e.length;i+=2)t.push(this._vertexToIndex(e[i],e[i+1]));return t}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),n=this._initializeVertices(r);try{let e=function(e,t,i=2){let r=t&&t.length,a=r?t[0]*i:e.length;Vh.size&&Vh.clear();let n=Uh(e,0,a,i,!0),o=[];if(!n||n.next===n.prev)return o;let s=0,l=0,u=0;if(r&&(n=function(e,t,i,r){let a=[];for(let n=0,o=t.length;n<o;n++){let i=Uh(e,t[n]*r,n<o-1?t[n+1]*r:e.length,r,!1);i===i.next&&Vh.add(i),a.push(pc(i))}a.sort(Yh),function(e,t){let i=Math.ceil((e+2*t)/16)+t+2;Jh.length<4*i&&(Jh=new Float64Array(4*i)),Qh=0}(e.length/r,t.length),ic(i,i),Xh=!0;for(let n=0;n<a.length;n++)i=Kh(a[n],i);return Xh=!1,$h(i)}(e,t,n,i)),e.length>80*i){s=e[0],l=e[1];let t=s,r=l;for(let n=i;n<a;n+=i){let i=e[n],a=e[n+1];i<s&&(s=i),a<l&&(l=a),i>t&&(t=i),a>r&&(r=a)}u=Math.max(t-s,r-l),u=0===u?0:32767/u}return Gh(n,o,s,l,u),o}(r,a);i=this._subdivideTrianglesScanline(e,n)}catch(e){console.error(e)}let o=[];return t&&(o=this._generateOutline(e,n)),this._ensureNoPoleVertices(),this._handlePoles(i),this._granularity>=2&&0===this._canonical?.z&&(i=this._removeTrianglesOutsideTileX(i),o=o.map(e=>this._removeLinesOutsideTileX(e))),{verticesFlattened:this._vertexBuffer,indicesTriangles:i,indicesLineList:o}}_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}_pointArrayToIndices(e){let t=[];for(let i of e)t.push(this._vertexToIndex(i.x,i.y));return t}};function Ic(e,t,i,r=!0){return new Ac(i,t).subdividePolygonInternal(e,r)}function Mc(e,t,i=!1){if(!e||e.length<1||e.length<2)return[];let r=i&&Fc(e);if(t<2)return r?[...e,e[0]]:[...e];let a=Math.floor(re/t),n=[];n.push(new d(e[0].x,e[0].y));let o=e.length,s=r?o:o-1;for(let l=0;l<s;l++){let t=e[l],i=l<o-1?e[l+1]:e[0],r=t.x,s=t.y,u=i.x,h=i.y,c=r!==u,p=s!==h;if(!c&&!p)continue;let f=u-r,m=h-s,_=Math.abs(f),g=Math.abs(m),y=r,v=s;for(;;){let e=f>0?(Math.floor(y/a)+1)*a:(Math.ceil(y/a)-1)*a,t=m>0?(Math.floor(v/a)+1)*a:(Math.ceil(v/a)-1)*a,i=Math.abs(y-e),r=Math.abs(v-t),o=Math.abs(y-u),s=Math.abs(v-h),l=c?i/_:1/0,x=p?r/g:1/0;if((o<=i||!c)&&(s<=r||!p))break;if(l<x&&c||!p){y=e,v+=m*l;let t=new d(y,Math.round(v));(n[n.length-1].x!==t.x||n[n.length-1].y!==t.y)&&n.push(t)}else{y+=f*x,v=t;let e=new d(Math.round(y),v);(n[n.length-1].x!==e.x||n[n.length-1].y!==e.y)&&n.push(e)}}let x=new d(u,h);(n[n.length-1].x!==x.x||n[n.length-1].y!==x.y)&&n.push(x)}return n}function Fc(e){return!e[0].equals(e[e.length-1])}function zc(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,o=r,s=(o+1)%n;for(;;){let r=o-1>=0?o-1:n-1,a=(s+1)%n,l=e[2*t[r]],u=e[2*t[r]+1],h=e[2*t[a]],c=e[2*t[a]+1],d=e[2*t[o]],p=e[2*t[o]+1],f=e[2*t[s]],m=e[2*t[s]+1],_=!1;if(l<h)_=!0;else if(l>h)_=!1;else{let e=m-p,t=-(f-d),i=p<m?1:-1;((l-d)*e+(u-p)*t)*i>((h-d)*e+(c-p)*t)*i&&(_=!0)}if(_){let e=t[r],a=t[o],l=t[s];e!==a&&e!==l&&a!==l&&i.push(l,a,e),o--,o<0&&(o=n-1)}else{let e=t[a],r=t[o],l=t[s];e!==r&&e!==l&&r!==l&&i.push(l,r,e),s++,s>=n&&(s=0)}if(r===a)break}}function kc(e,t,i,r,a,n,o,s,l){let u=a.length/2,h=o&&s&&l;if(u<Yl.MAX_VERTEX_ARRAY_LENGTH){let c,d,p=t.prepareSegment(u,i,r),f=p.vertexLength;for(let e=0;e<n.length;e+=3)r.emplaceBack(f+n[e],f+n[e+1],f+n[e+2]);p.vertexLength+=u,p.primitiveLength+=n.length/3,h&&(d=o.prepareSegment(u,i,s),c=d.vertexLength,d.vertexLength+=u);for(let t=0;t<a.length;t+=2)e(a[t],a[t+1]);if(h)for(let e of l){for(let t=1;t<e.length;t+=2)s.emplaceBack(c+e[t-1],c+e[t]);d.primitiveLength+=e.length/2}}else(function(e,t,i,r,a,n){let o=[];for(let c=0;c<r.length/2;c++)o.push(-1);let s={count:0},l=0,u=e.getOrCreateLatestSegment(t,i),h=u.vertexLength;for(let c=2;c<a.length;c+=3){let d=a[c-2],p=a[c-1],f=a[c],m=o[d]<l,_=o[p]<l,g=o[f]<l,y=+!!m+ +!!_+ +!!g;u.vertexLength+y>Yl.MAX_VERTEX_ARRAY_LENGTH&&(u=e.createNewSegment(t,i),l=s.count,m=!0,_=!0,g=!0,h=0);let v=Rc(o,r,n,s,d,m,u),x=Rc(o,r,n,s,p,_,u),b=Rc(o,r,n,s,f,g,u);i.emplaceBack(h+v-l,h+x-l,h+b-l),u.primitiveLength++}})(t,i,r,a,n,e),h&&function(e,t,i,r,a,n){let o=[];for(let c=0;c<r.length/2;c++)o.push(-1);let s={count:0},l=0,u=e.getOrCreateLatestSegment(t,i),h=u.vertexLength;for(let c of a)for(let a=1;a<c.length;a+=2){let d=c[a-1],p=c[a],f=o[d]<l,m=o[p]<l,_=+!!f+ +!!m;u.vertexLength+_>Yl.MAX_VERTEX_ARRAY_LENGTH&&(u=e.createNewSegment(t,i),l=s.count,f=!0,m=!0,h=0);let g=Rc(o,r,n,s,d,f,u),y=Rc(o,r,n,s,p,m,u);i.emplaceBack(h+g-l,h+y-l),u.primitiveLength++}}(o,i,s,a,l,e),t.forceNewSegmentOnNextPrepare(),o?.forceNewSegmentOnNextPrepare()}function Rc(e,t,i,r,a,n,o){if(n){let n=r.count;return i(t[2*a],t[2*a+1]),e[a]=r.count,r.count++,o.vertexLength++,n}return e[a]}var Lc,Bc=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.sdfPatterns={},this.patternFeatures=[],this.layoutVertexArray=new Fl,this.indexArray=new Zl,this.indexArray2=new ql,this.programConfigurations=new Cu(e.layers,e.zoom),this.segments=new Yl,this.segments2=new Yl,this.stateDependentLayerIds=this.layers.filter(e=>e.isStateDependent()).map(e=>e.id)}populate(e,t,i){this.hasDependencies=Oh("fill",this.layers,t);let r=this.layers[0].layout.get("fill-sort-key"),a=!r.isConstant(),n=[],o=new gs(this.zoom),s=this.layers[0]._featureFilter.needGeometry;for(let{feature:l,id:u,index:h,sourceLayerIndex:c}of e){let e=zu(l,s);if(!this.layers[0]._featureFilter.filter(o,e,i))continue;let d=a?r.evaluate(e,{},i,t.availableImages):void 0,p={id:u,properties:l.properties,type:l.type,sourceLayerIndex:c,index:h,geometry:s?e.geometry:Fu(l),patterns:{},sortKey:d};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;if(this.hasDependencies){let e=jh("fill",this.layers,l,{zoom:this.zoom},t);this.patternFeatures.push(e)}else this.addFeature(l,r,a,i,{},t.subdivisionGranularity);let o=e[a].feature;t.featureIndex.insert(o,r,a,n,this.index)}}update(e,t,i){this.stateDependentLayers.length&&this.programConfigurations.updatePaintArrays(e,t,this.stateDependentLayers,{imagePositions:i})}addFeatures({options:e,canonical:t,patternPositions:i,patternMap:r}){this.detectSdfPatterns(r);for(let a of this.patternFeatures)this.addFeature(a,a.geometry,a.index,t,i,e.subdivisionGranularity)}detectSdfPatterns(e){for(let t of this.patternFeatures)for(let i in t.patterns){let r=t.patterns[i];this.recordSdfPattern(i,e[r.min]),this.recordSdfPattern(i,e[r.mid]),this.recordSdfPattern(i,e[r.max])}for(let t of this.layers){let i=t.paint.get("fill-pattern").constantOr(null);i&&(this.recordSdfPattern(t.id,e[i.from.toString()]),this.recordSdfPattern(t.id,e[i.to.toString()]))}}recordSdfPattern(e,t){if(!t)return;let i=!0===t.sdf,r=this.sdfPatterns[e];void 0===r?this.sdfPatterns[e]=i:r!==i&&Oe(`Style sheet warning: Cannot mix SDF and non-SDF fill patterns in layer "${e}"`)}isEmpty(){return 0===this.layoutVertexArray.length}uploadPending(){return!this.uploaded||this.programConfigurations.needsUpload}upload(e){this.uploaded||(this.layoutVertexBuffer=e.createVertexBuffer(this.layoutVertexArray,Bh),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 o of wr(t,500)){let e=Ic(o,r,n.fill.getGranularityForZoomLevel(r.z)),t=this.layoutVertexArray;kc((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})}};Po("FillBucket",Bc,{omit:["layers","patternFeatures"]});var Oc,jc={get paint(){return Oc||=new zs({"fill-antialias":new Ps(Nt.paint_fill["fill-antialias"],"fill-antialias"),"fill-opacity":new As(Nt.paint_fill["fill-opacity"],"fill-opacity"),"fill-layer-opacity":new Ps(Nt.paint_fill["fill-layer-opacity"],"fill-layer-opacity"),"fill-color":new As(Nt.paint_fill["fill-color"],"fill-color"),"fill-outline-color":new As(Nt.paint_fill["fill-outline-color"],"fill-outline-color"),"fill-translate":new Ps(Nt.paint_fill["fill-translate"],"fill-translate"),"fill-translate-anchor":new Ps(Nt.paint_fill["fill-translate-anchor"],"fill-translate-anchor"),"fill-pattern":new Is(Nt.paint_fill["fill-pattern"],"fill-pattern")})},get layout(){return Lc||=new zs({"fill-sort-key":new As(Nt.layout_fill["fill-sort-key"],"fill-sort-key")})}},Vc=class extends Bs{constructor(e,t){super(e,jc,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 Bc(e)}queryRadius(){return ih(this.paint.get("fill-translate"))}queryIntersectsFeature({queryGeometry:e,geometry:t,transform:i,pixelsToTileUnits:r}){return Zu(rh(e,this.paint.get("fill-translate"),this.paint.get("fill-translate-anchor"),-i.bearingInRadians,r),t)}isTileClipped(){return!0}},Nc=Gs([{name:"a_pos",components:2,type:"Int16"},{name:"a_normal_ed",components:4,type:"Int16"}],4),Uc=Gs([{name:"a_centroid",components:2,type:"Int16"}],4),$c=Nc.members;Nc.size,Nc.alignment;var Gc=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,o=0,s=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)o+=e.readSVarint(),s+=e.readSVarint(),t&&r.push(t),t=[new d(o,s)];else if(2===a)o+=e.readSVarint(),s+=e.readSVarint(),t&&t.push(new d(o,s));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,o=1/0,s=-1/0,l=1/0,u=-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<o&&(o=a),a>s&&(s=a),n<l&&(l=n),n>u&&(u=n);else if(7!==i)throw Error(`unknown command ${i}`)}return[o,l,s,u]}toGeoJSON(e,t,i){let r,a=this.extent*2**i,n=this.extent*e,o=this.extent*t,s=this.loadGeometry();function l(e){return[360*(e.x+n)/a-180,360/Math.PI*Math.atan(Math.exp((1-2*(e.y+o)/a)*Math.PI))-90]}function u(e){return e.map(l)}if(1===this.type){let e=[];for(let i of s)e.push(i[0]);let t=u(e);r=1===e.length?{type:"Point",coordinates:t[0]}:{type:"MultiPoint",coordinates:t}}else if(2===this.type){let e=s.map(u);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=Zc(s),t=[];for(let i of e)t.push(i.map(u));r=1===t.length?{type:"Polygon",coordinates:t[0]}:{type:"MultiPolygon",coordinates:t}}}let h={type:"Feature",geometry:r,properties:this.properties};return null!=this.id&&(h.id=this.id),h}};function Zc(e){let t=e.length;if(t<=1)return[e];let i,r,a=[];for(let n=0;n<t;n++){let t=qc(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 qc(e){let t=0;for(let i,r,a=0,n=e.length,o=n-1;a<n;o=a++)i=e[a],r=e[o],t+=(r.x-i.x)*(i.y+r.y);return t}Gc.types=["Unknown","Point","LineString","Polygon"];var Wc=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(Hc(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 Gc(this._pbf,t,this.extent,this._keys,this._values)}};function Hc(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 Xc=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 Wc(e,e.readVarint()+e.pos);t.length&&(i[t.name]=t)}else e.skip(t)}this.layers=i}},Yc=6371008.8,Kc=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(De(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 Yc*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>]")}},Jc=6378137,Qc={origin:[-Math.PI*Jc,Math.PI*Jc],extentAtZoom0:2*Math.PI*Jc},ed=2*Math.PI*Yc;function td(e){return ed*Math.cos(e*Math.PI/180)}function id(e){return(180+e)/360}function rd(e){return(180-180/Math.PI*Math.log(Math.tan(Math.PI/4+e*Math.PI/360)))/360}function ad(e,t){return e/td(t)}function nd(e){return 360*e-180}function od(e){let t=180-360*e;return 360/Math.PI*Math.atan(Math.exp(t*Math.PI/180))-90}function sd(e){return 1/Math.cos(e*Math.PI/180)}var ld=class e{constructor(e,t,i=0){this.x=+e,this.y=+t,this.z=+i}static fromLngLat(t,i=0){let r=Kc.convert(t);return new e(id(r.lng),rd(r.lat),ad(i,r.lat))}toLngLat(){return new Kc(nd(this.x),od(this.y))}toAltitude(){return function(e,t){return e*td(od(t))}(this.z,this.y)}meterInMercatorCoordinateUnits(){return 1/ed*sd(od(this.y))}},ud=new class{constructor(){this.name="mercator",this.wraps=!0,this.tileMatrixSet=Qc}worldFromLngLat(e,t,i){return new ld(id(e),rd(t),void 0===i?0:ad(i,t))}lngLatFromWorld(e,t){return new Kc(nd(e),od(t))}hasLngLat(e,t){return!0}metersPerWorldUnit(e,t){return 1/(1/ed*sd(od(t)))}worldZFromAltitude(e,t){return ad(e,t.lat)}},hd=89.25;function cd(e,t,i){let r=1/(1<<i.z);return new ld(e/re*r+i.x*r,t/re*r+i.y*r)}function dd(e,t,i){let r=i.wraps?Se(t.lat,-85.051129,Ke):t.lat,{x:a,y:n}=i.worldFromLngLat(t.lng,r);return new d(a*e,n*e)}function pd(e,t,i){return i.lngLatFromWorld(t.x/e,t.y/e)}function fd(e){return e.cameraToCenterDistance*Math.min(.85*Math.tan(qe(90-e.pitch)),Math.tan(qe(hd-e.pitch)))}function md(e,t){let i=e.canonical,r=t/Ie(i.z),a=i.x+2**i.z*e.wrap,n=/* @__PURE__ */new Float64Array(16);return x(n),T(n,n,[a*r,i.y*r,0]),S(n,n,[r/re,r/re,1]),n}function _d(e,t,i,r){let{x:a,y:n,z:o}=gd(t,i),s=r*-a,l=r*-n,u=r*o;return new ld(e.x+s,e.y+l,e.z+u)}function gd(e,t){let i=qe(e),r=qe(t),a=Math.cos(-i),n=Math.sin(i);return{x:n*Math.sin(r),y:-n*Math.cos(r),z:a}}function yd(e,t,i,r,a){let n=(t,i)=>{let{x:r,y:a}=e.worldFromLngLat(t,i);return new d(r,a)},o=e=>16===e?r:t+(r-t)*e/16,s=e=>16===e?i:a+(i-a)*e/16,l=[];for(let c=0;c<=16;c++)for(let e=0;e<=16;e++)l.push(n(o(e),s(c)));let u=(e,t)=>l[17*e+t],h=0;for(let c=0;c<16;c++){let e=(o(c)+o(c+1))/2,l=(s(c)+s(c+1))/2,d=[[u(0,c),u(0,c+1),n(e,a)],[u(16,c),u(16,c+1),n(e,i)],[u(c,0),u(c+1,0),n(t,l)],[u(c,16),u(c+1,16),n(r,l)]];for(let[t,i,r]of d){let e=i.sub(t),a=r.sub(t),n=e.mag(),o=n>0?Math.abs(e.x*a.y-e.y*a.x)/n:a.mag();o>h&&(h=o)}}return{points:l,bulge:h}}function vd(e,t,i,r,a){let{points:n,bulge:o}=yd(e,t,i,r,a),s=1/0,l=1/0,u=-1/0,h=-1/0;for(let{x:c,y:d}of n)c<s&&(s=c),d<l&&(l=d),c>u&&(u=c),d>h&&(h=d);return{minX:s-o,minY:l-o,maxX:u+o,maxY:h+o}}var xd=1e-4;function bd(e,t){return t<=0||!e||0===e.length?e: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=[],n=Lu(e[r-1],e[0]);for(let s=0;s<r;s++){let i=e[(s-1+r)%r],o=e[s],l=e[(s+1)%r],u=Lu(o,l);n||u?a.push(o.clone()):Sd(a,i,o,l,t),n=u}let o=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 o.length<3?e:(i&&o.push(o[0].clone()),o)}(e,t))}var wd=Math.cos(35*Math.PI/180);function Td(e,t){if(!t)return e.unit();let i=e.mag(),r=t.mag();return e.x*t.x+e.y*t.y<wd*i*r||i>=2*r?e.unit():r>=2*i?t.unit():e.add(t)._unit()}function Sd(e,t,i,r,a){let n=t.sub(i),o=r.sub(i),s=n.mag(),l=o.mag();if(s<1e-6||l<1e-6)return void e.push(i.clone());n._div(s),o._div(l);let u=n.x*o.x+n.y*o.y;if(Math.abs(u)>Math.cos(5*Math.PI/180))return void e.push(i.clone());let h=Math.min(a,.2*s,.2*l),c=i.add(n.mult(h)),d=i.add(o.mult(h)),p=Math.sqrt((1+u)/2),f=i.add(n.add(o)._unit()._mult(h/p)),m=c.sub(f).angleWith(d.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 Dd=8192;function Ed(e,t,i,r,a,n,o,s){e.emplaceBack(t,i,2*Math.floor(r*Dd)+o,a*Dd*2,n*Dd*2,Math.round(s))}var Cd,Pd=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 zl,this.centroidVertexArray=new Pl,this.indexArray=new Zl,this.programConfigurations=new Cu(e.layers,e.zoom),this.segments=new Yl,this.stateDependentLayerIds=this.layers.filter(e=>e.isStateDependent()).map(e=>e.id)}populate(e,t,i){this.features=[],this.hasDependencies=Oh("fill-extrusion",this.layers,t);let r=new gs(this.zoom),a=this.layers[0],n=a.layout.get("fill-extrusion-rounded-corner-distance"),o=n>0?function(e,t){let i=function(e,t,i){return cd(4096,4096,i).toLngLat()}(0,0,t);return e*ld.fromLngLat(i).meterInMercatorCoordinateUnits()*((1<<t.z)*re)}(n,i):0,s=a._featureFilter.needGeometry;for(let{feature:l,id:u,index:h,sourceLayerIndex:c}of e){let e=zu(l,s);if(!a._featureFilter.filter(r,e,i))continue;let n={id:u,sourceLayerIndex:c,index:h,geometry:bd(s?e.geometry:Fu(l),o),properties:l.properties,type:l.type,patterns:{}};this.hasDependencies?this.features.push(jh("fill-extrusion",this.layers,n,{zoom:this.zoom},t)):this.addFeature(n,n.geometry,h,i,{},t.subdivisionGranularity),t.featureIndex.insert(l,n.geometry,h,c,this.index,!0)}}addFeatures({options:e,canonical:t,patternPositions: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,$c),this.centroidVertexBuffer=e.createVertexBuffer(this.centroidVertexArray,Uc.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){for(let o of wr(t,500)){let t={x:0,y:0,sampleCount:0},i=this.layoutVertexArray.length;this.processPolygon(t,r,e,o,n);let a=this.layoutVertexArray.length-i,s=Math.floor(t.x/t.sampleCount),l=Math.floor(t.y/t.sampleCount);for(let e=0;e<a;e++)this.centroidVertexArray.emplaceBack(s,l)}this.programConfigurations.populatePaintArrays(this.layoutVertexArray.length,e,i,{imagePositions:a,canonical:r})}processPolygon(e,t,i,r,a){if(r.length<1||Bu(r[0]))return;for(let h of r)0!==h.length&&Ad(e,h);let n={segment:this.segments.prepareSegment(4,this.layoutVertexArray,this.indexArray)},o=a.fill.getGranularityForZoomLevel(t.z),s="Polygon"===Gc.types[i.type];for(let h of r){if(0===h.length||Bu(h))continue;let e=Mc(h,o,s);this._generateSideFaces(e,n)}if(!s)return;let l=Ic(r,t,o,!1),u=this.layoutVertexArray;kc((e,t)=>{Ed(u,e,t,0,0,1,1,0)},this.segments,this.layoutVertexArray,this.indexArray,l.verticesFlattened,l.indicesTriangles)}_generateSideFaces(e,t){let i=0,r=this.layers[0].layout.get("fill-extrusion-rounded-corner-distance")>0?function(e){let t=[null];for(let n=1;n<e.length;n++){let i=e[n].sub(e[n-1]),r=!Lu(e[n],e[n-1])&&i.mag()>0;t.push(r?i._perp():null)}let i=e.length-1,r=i>1&&e[0].equals(e[i]),a=[null];for(let n=1;n<=i;n++){let e=t[n];if(!e){a.push(null);continue}let o=r&&1===n?t[i]:t[n-1],s=r&&n===i?t[1]:t[n+1];a.push({start:Td(e,o),end:Td(e,s)})}return a}(e):null;for(let a=1;a<e.length;a++){let n=e[a],o=e[a-1];if(Lu(n,o)||r&&!r[a])continue;t.segment.vertexLength+4>Yl.MAX_VERTEX_ARRAY_LENGTH&&(t.segment=this.segments.prepareSegment(4,this.layoutVertexArray,this.indexArray));let s=n.sub(o)._perp()._unit(),{start:l,end:u}=r?r[a]:{start:s,end:s},h=o.dist(n);i+h>32768&&(i=0),Ed(this.layoutVertexArray,n.x,n.y,u.x,u.y,0,0,i),Ed(this.layoutVertexArray,n.x,n.y,u.x,u.y,0,1,i),i+=h,Ed(this.layoutVertexArray,o.x,o.y,l.x,l.y,0,0,i),Ed(this.layoutVertexArray,o.x,o.y,l.x,l.y,0,1,i);let c=t.segment.vertexLength;this.indexArray.emplaceBack(c,c+2,c+1),this.indexArray.emplaceBack(c+1,c+2,c+3),t.segment.vertexLength+=4,t.segment.primitiveLength+=2}}};function Ad(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++)}}Po("FillExtrusionBucket",Pd,{omit:["layers","features"]});var Id,Md={get paint(){return Id||=new zs({"fill-extrusion-opacity":new Ps(Nt["paint_fill-extrusion"]["fill-extrusion-opacity"],"fill-extrusion-opacity"),"fill-extrusion-color":new As(Nt["paint_fill-extrusion"]["fill-extrusion-color"],"fill-extrusion-color"),"fill-extrusion-translate":new Ps(Nt["paint_fill-extrusion"]["fill-extrusion-translate"],"fill-extrusion-translate"),"fill-extrusion-translate-anchor":new Ps(Nt["paint_fill-extrusion"]["fill-extrusion-translate-anchor"],"fill-extrusion-translate-anchor"),"fill-extrusion-pattern":new Is(Nt["paint_fill-extrusion"]["fill-extrusion-pattern"],"fill-extrusion-pattern"),"fill-extrusion-height":new As(Nt["paint_fill-extrusion"]["fill-extrusion-height"],"fill-extrusion-height"),"fill-extrusion-base":new As(Nt["paint_fill-extrusion"]["fill-extrusion-base"],"fill-extrusion-base"),"fill-extrusion-vertical-gradient":new Ps(Nt["paint_fill-extrusion"]["fill-extrusion-vertical-gradient"],"fill-extrusion-vertical-gradient")})},get layout(){return Cd||=new zs({"fill-extrusion-rounded-corner-distance":new Ps(Nt["layout_fill-extrusion"]["fill-extrusion-rounded-corner-distance"],"fill-extrusion-rounded-corner-distance")})}},Fd=class extends Bs{constructor(e,t){super(e,Md,t)}createBucket(e){return new Pd(e)}queryRadius(){return ih(this.paint.get("fill-extrusion-translate"))}is3D(){return!0}queryIntersectsFeature({queryGeometry:e,feature:t,featureState:i,geometry:r,transform:a,pixelsToTileUnits:n,pixelPosMatrix:o}){let s=rh(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),u=this.paint.get("fill-extrusion-base").evaluate(t,i),h=Ld(s,o,0),c=Rd(r,u,l,o);return function(e,t,i){let r=1/0;Zu(i,t)&&(r=kd(i,t[0]));for(let a=0;a<t.length;a++){let n=t[a],o=e[a];for(let e=0;e<n.length-1;e++){let t=n[e],a=n[e+1],s=o[e],l=[t,a,o[e+1],s,t];$u(i,l)&&(r=Math.min(r,kd(i,l)))}}return r!==1/0&&r}(c[0],c[1],h)}};function zd(e,t){return e.x*t.x+e.y*t.y}function kd(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],o=e[0],s=i.sub(a),l=n.sub(a),u=o.sub(a),h=zd(s,s),c=zd(s,l),d=zd(l,l),p=zd(u,s),f=zd(u,l),m=h*d-c*c,_=(d*p-c*f)/m,g=(h*f-c*p)/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 Rd(e,t,i,r){let a=[],n=[],o=r[8]*t,s=r[9]*t,l=r[10]*t,u=r[11]*t,h=r[8]*i,c=r[9]*i,p=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+u,b=m+h,w=_+c,T=g+p,S=y+f,D=new d((m+o)/x,(_+s)/x);D.z=v/x,e.push(D);let E=new d(b/S,w/S);E.z=T/S,t.push(E)}a.push(e),n.push(t)}return[a,n]}function Ld(e,t,i){let r=[];for(let a of e){let e=[a.x,a.y,i,1];H(e,e,t),r.push(new d(e[0]/e[3],e[1]/e[3]))}return r}new class{projectX(e){return e/360+.5}projectY(e){let t=Math.sin(e*Math.PI/180),i=.5-.25*Math.log((1+t)/(1-t))/Math.PI;return i<0?0:i>1?1:i}unprojectX(e){return 360*(e-.5)}unprojectY(e){let t=(180-360*e)*Math.PI/180;return 360*Math.atan(Math.exp(t))/Math.PI-90}},new class{projectX(e){return e}projectY(e){return e}unprojectX(e){return e}unprojectY(e){return e}};var Bd=Gs([{name:"a_pos_normal",components:2,type:"Int16"},{name:"a_data",components:4,type:"Uint8"},{name:"a_offset_normal",components:2,type:"Int8"}],2),Od=Bd.members;Bd.size,Bd.alignment;var jd=Gs([{name:"a_uv_x",components:1,type:"Float32"},{name:"a_split_index",components:1,type:"Float32"}]),Vd=jd.members;jd.size,jd.alignment;var Nd,Ud=Math.cos(Math.PI/180*37.5),$d=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 kl,this.layoutVertexArray2=new Rl,this.indexArray=new Zl,this.programConfigurations=new Cu(e.layers,e.zoom),this.segments=new Yl,this.maxLineLength=0,this.stateDependentLayerIds=this.layers.filter(e=>e.isStateDependent()).map(e=>e.id)}populate(e,t,i){this.hasDependencies=Oh("line",this.layers,t)||this.hasLineDasharray(this.layers);let r=this.layers[0].layout.get("line-sort-key"),a=!r.isConstant(),n=[],o=new gs(this.zoom),s=this.layers[0]._featureFilter.needGeometry;for(let{feature:l,id:u,index:h,sourceLayerIndex:c}of e){let e=zu(l,s);if(!this.layers[0]._featureFilter.filter(o,e,i))continue;let t=a?r.evaluate(e,{},i):void 0,d={id:u,properties:l.properties,type:l.type,sourceLayerIndex:c,index:h,geometry:s?e.geometry:Fu(l),patterns:{},dashes:{},sortKey:t};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;this.hasDependencies?(Oh("line",this.layers,t)?jh("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 o=e[a].feature;t.featureIndex.insert(o,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({options:e,canonical:t,patternPositions:i,dashPositions: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,Vd)),this.layoutVertexBuffer=e.createVertexBuffer(this.layoutVertexArray,Od),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,o){let s=this.layers[0].layout,l=s.get("line-join").evaluate(e,{}),u=s.get("line-cap").evaluate(e,{}),h=s.get("line-miter-limit").evaluate(e,{}),c=s.get("line-round-limit").evaluate(e,{});this.lineClips=this.lineFeatureClips(e);for(let d of t)this.addLine(d,e,l,u,h,c,r,o);this.programConfigurations.populatePaintArrays(this.layoutVertexArray.length,e,i,{imagePositions:a,dashPositions:n,canonical:r})}addLine(e,t,i,r,a,n,o,s){if(this.distance=0,this.scaledDistance=0,this.totalDistance=0,e=Mc(e,o?s.line.getGranularityForZoomLevel(o.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"===Gc.types[t.type],u=e.length;for(;u>=2&&e[u-1].equals(e[u-2]);)u--;let h=0;for(;h<u-1&&e[h].equals(e[h+1]);)h++;if(u-h<(l?3:2))return;"bevel"===i&&(a=1.05);let c,d,p,f,m,_=this.overscaling<=16?15*re/(512*this.overscaling):0,g=this.segments.prepareSegment(10*u,this.layoutVertexArray,this.indexArray);this.e1=this.e2=-1,l&&(c=e[u-2],m=e[h].sub(c)._unit()._perp());for(let y=h;y<u;y++){if(p=y===u-1?l?e[h+1]:void 0:e[y+1],p&&e[y].equals(p))continue;m&&(f=m),c&&(d=c),c=e[y],m=p?p.sub(c)._unit()._perp():f,f||=m;let t=f.add(m);(0!==t.x||0!==t.y)&&t._unit();let o=f.x*m.x+f.y*m.y,s=t.x*m.x+t.y*m.y,v=0===s?1/0:1/s,x=2*Math.sqrt(2-2*s),b=s<Ud&&d&&p,w=f.x*m.y-f.y*m.x>0,T=t.mult(Math.min(v,2)),S=Se((v-3)/5,0,1);if(b&&y>h){let e=c.dist(d);if(e>2*_){let t=c.sub(c.sub(d)._mult(_/e)._round());this.updateDistance(d,t),this.addCurrentVertex(t,f,0,0,g),d=t}}let D=d&&p,E=D?i:l?"butt":r;if(D&&"round"===E&&(v<n?E="miter":v<=2&&(E="fakeround")),"miter"===E&&v>a&&(E="bevel"),"bevel"===E&&(v>2&&(E="flipbevel"),v<a&&(E="miter")),d&&this.updateDistance(d,c),"miter"===E)t._mult(v),this.addCurrentVertex(c,t,0,0,g,!1,T);else if("flipbevel"===E){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,!1,T,S),this.addCurrentVertex(c,t.mult(-1),0,0,g,!1,T,S)}else if("bevel"===E||"fakeround"===E){let e=-Math.sqrt(v*v-1),t=w?e:0,i=w?0:e;if(d&&this.addCurrentVertex(c,f,t,i,g,!1,T),"fakeround"===E){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+o*(o*(3.55645-1.43519*o)-3.2452))*e*e+(.848013+o*(.215638*o-1.06021)))}let r=m.sub(f)._mult(i)._add(f)._unit()._mult(w?-1:1);this.addHalfVertex(c,r.x,r.y,w?-T.x:T.x,w?-T.y:T.y,!1,w,g)}}p&&this.addCurrentVertex(c,m,-t,-i,g,!1,T)}else if("butt"===E)this.addCurrentVertex(c,t,0,0,g,!1,T);else if("square"===E){let e=d?1:-1;this.addCurrentVertex(c,t,e,e,g,!1,T)}else"round"===E&&(d&&(this.addCurrentVertex(c,f,0,0,g,!1,T,S),this.addCurrentVertex(c,f,1,1,g,!0,T,S)),p&&(this.addCurrentVertex(c,m,-1,-1,g,!0,T,S),this.addCurrentVertex(c,m,0,0,g,!1,T,S)));if(b&&y<u-1){let e=c.dist(p);if(e>2*_){let t=c.add(p.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,o=t,s=0){let l=t.x+t.y*i,u=t.y-t.x*i,h=-t.x+t.y*r,c=-t.y-t.x*r,d=o.x+(t.x-o.x)*s,p=o.y+(t.y-o.y)*s;this.addHalfVertex(e,l,u,d,p,n,!1,a),this.addHalfVertex(e,h,c,-d,-p,n,!0,a),this.distance>16384&&0===this.totalDistance&&(this.distance=0,this.updateScaledDistance(),this.addCurrentVertex(e,t,i,r,a,n,o,s))}addHalfVertex({x:e,y:t},i,r,a,n,o,s,l){let u=.5*(this.lineClips?32767*this.scaledDistance:this.scaledDistance);if(this.layoutVertexArray.emplaceBack(+!!o+(e<<1),+!!s+(t<<1),Math.round(63*i)+128,Math.round(63*r)+128,(63&u)<<2,u>>6,Math.round(63*a),Math.round(63*n)),this.lineClips){let e=(this.scaledDistance-this.lineClips.start)/(this.lineClips.end-this.lineClips.start);this.layoutVertexArray2.emplaceBack(e,this.lineClipsArray.length)}let h=l.vertexLength++;this.e1>=0&&this.e2>=0&&(this.indexArray.emplaceBack(this.e1,h,this.e2),l.primitiveLength++),s?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,{}),o={dasharray:e.value.evaluate({zoom:i-1},t,{}),round:n},s={dasharray:e.value.evaluate({zoom:i},t,{}),round:n},l={dasharray:e.value.evaluate({zoom:i+1},t,{}),round:n},u=`${o.dasharray.join(",")},${o.round}`,h=`${s.dasharray.join(",")},${s.round}`,c=`${l.dasharray.join(",")},${l.round}`;r.dashDependencies[u]=o,r.dashDependencies[h]=s,r.dashDependencies[c]=l,t.dashes[a.id]={min:u,mid:h,max:c}}}};Po("LineBucket",$d,{omit:["layers","patternFeatures"]});var Gd,Zd,qd={get paint(){return Gd||=new zs({"line-opacity":new As(Nt.paint_line["line-opacity"],"line-opacity"),"line-layer-opacity":new Ps(Nt.paint_line["line-layer-opacity"],"line-layer-opacity"),"line-color":new As(Nt.paint_line["line-color"],"line-color"),"line-translate":new Ps(Nt.paint_line["line-translate"],"line-translate"),"line-translate-anchor":new Ps(Nt.paint_line["line-translate-anchor"],"line-translate-anchor"),"line-width":new As(Nt.paint_line["line-width"],"line-width"),"line-gap-width":new As(Nt.paint_line["line-gap-width"],"line-gap-width"),"line-offset":new As(Nt.paint_line["line-offset"],"line-offset"),"line-blur":new As(Nt.paint_line["line-blur"],"line-blur"),"line-dasharray":new Is(Nt.paint_line["line-dasharray"],"line-dasharray"),"line-pattern":new Is(Nt.paint_line["line-pattern"],"line-pattern"),"line-gradient":new Fs(Nt.paint_line["line-gradient"],"line-gradient")})},get layout(){return Nd||=new zs({"line-cap":new As(Nt.layout_line["line-cap"],"line-cap"),"line-join":new As(Nt.layout_line["line-join"],"line-join"),"line-miter-limit":new As(Nt.layout_line["line-miter-limit"],"line-miter-limit"),"line-round-limit":new As(Nt.layout_line["line-round-limit"],"line-round-limit"),"line-sort-key":new As(Nt.layout_line["line-sort-key"],"line-sort-key")})}},Wd=class extends As{possiblyEvaluate(e,t){return t=new gs(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=Ee({},t,{zoom:Math.floor(t.zoom)}),super.evaluate(e,t,i,r)}},Hd=class extends Bs{constructor(e,t){super(e,qd,t),this.gradientVersion=0,Zd||((Zd=new Wd(qd.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 fr,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"]=Zd.possiblyEvaluate(this._transitioningPaint._values["line-width"].value,e)}createBucket(e){return new $d(e)}queryRadius(e){let t=e,i=Xd(th("line-width",this,t),th("line-gap-width",this,t)),r=th("line-offset",this,t);return i/2+Math.abs(r)+ih(this.paint.get("line-translate"))}queryIntersectsFeature({queryGeometry:e,feature:t,featureState:i,geometry:r,transform:a,pixelsToTileUnits:n}){let o=rh(e,this.paint.get("line-translate"),this.paint.get("line-translate-anchor"),-a.bearingInRadians,n),s=n/2*Xd(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=ah(r),a=[];for(let i=0;i<e.length;i++){let r=e[i],n=e[i-1],o=e[i+1],s=0===i?new d(0,0):r.sub(n)._unit()._perp(),l=i===e.length-1?new d(0,0):o.sub(r)._unit()._perp(),u=s._add(l)._unit(),h=u.x*l.x+u.y*l.y;0!==h&&u._mult(1/h),a.push(u._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(Ju(e,t))return!0;if(qu(e,r,i))return!0}return!1}(o,r,s)}isTileClipped(){return!0}};function Xd(e,t){return t>0?t+2*e:e}var Yd=Gs([{name:"a_pos_offset",components:4,type:"Int16"},{name:"a_data",components:4,type:"Uint16"},{name:"a_pixeloffset",components:4,type:"Int16"},{name:"a_height_offset",components:1,type:"Float32"}],4),Kd=Gs([{name:"a_projected_pos",components:3,type:"Float32"}],4);Gs([{name:"a_fade_opacity",components:1,type:"Uint32"}],4);var Jd=Gs([{name:"a_placed",components:2,type:"Uint8"},{name:"a_shift",components:2,type:"Float32"},{name:"a_box_real",components:2,type:"Int16"}]);Gs([{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 Qd=Gs([{name:"a_pos",components:2,type:"Int16"},{name:"a_anchor_pos",components:2,type:"Int16"},{name:"a_extrude",components:2,type:"Int16"}],4),ep=Gs([{name:"a_pos",components:2,type:"Float32"},{name:"a_radius",components:1,type:"Float32"},{name:"a_flags",components:2,type:"Int16"}],4);Gs([{name:"triangle",components:3,type:"Uint16"}]),Gs([{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"},{type:"Float32",name:"heightOffset"}]);var tp=Gs([{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"},{type:"Float32",name:"heightOffset"}]);Gs([{type:"Float32",name:"offsetX"}]),Gs([{type:"Int16",name:"x"},{type:"Int16",name:"y"},{type:"Int16",name:"tileUnitDistanceFromAnchor"}]),Gs([{type:"Uint16",name:"textAnchor"},{type:"Float32",components:2,name:"textOffset"}]);var ip=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(ip.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}`)}};function rp(e){return/[\u02EA\u02EB\u2E80-\u2FDF\u2FF0-\u303F\u3041-\u3096\u309D-\u309F\u30A1-\u30FA\u30FD-\u30FF\u3105-\u312F\u31A0-\u4DBF\u4E00-\uA48C\uA490-\uA4C6\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))}function ap(e){return/[\u02EA\u02EB\u1100-\u11FF\u1401-\u167F\u18B0-\u18FF\u2065\u20DD-\u20E0\u20E2-\u20E4\u2B97\u2BF0-\u2BFF\u2E50\u2E51\u2E80-\u3007\u3012\u3013\u3020-\u302F\u3031-\u30FB\u30FD-\uA4CF\uA960-\uA97F\uAC00-\uD7FF\uF900-\uFAFF\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\uFFF0-\uFFF8]|\uD802[\uDD80-\uDD9F]|\uD805[\uDD80-\uDDFF]|\uD806[\uDE00-\uDEBF]|[\uD80C-\uD810\uD81C-\uD822\uD83C\uD83D\uD840-\uD87E\uD880-\uD8BE][\uDC00-\uDFFF]|\uD811[\uDC00-\uDE7F]|\uD81B[\uDFE0-\uDFFF]|\uD823[\uDC00-\uDDFF]|\uD82B[\uDFF0-\uDFFF]|\uD82C[\uDC00-\uDEFF]|\uD833[\uDEC0-\uDFCF]|\uD834[\uDC00-\uDDFF\uDEE0-\uDF7F]|\uD836[\uDC00-\uDEAF]|\uD83E[\uDD00-\uDEFF]|[\uD87F\uD8BF][\uDC00-\uDFFD]/gim.test(String.fromCodePoint(e))}function np(e){return/[\u0E01-\u0E3A\u0E40-\u0E4E\u0E81\u0E82\u0E84\u0E86-\u0E8A\u0E8C-\u0EA3\u0EA5\u0EA7-\u0EBD\u0EC0-\u0EC4\u0EC6\u0EC8-\u0ECE\u0EDC-\u0EDF\u0F00-\u0F47\u0F49-\u0F6C\u0F71-\u0F97\u0F99-\u0FBC\u0FBE-\u0FCC\u0FCE-\u0FD4\u0FD9\u0FDA\u1000-\u103F\u1050-\u108F\u109A-\u109F\u1780-\u17D3\u17D7\u17DC\u17DD\u1950-\u196D\u1970-\u1974\u1980-\u19AB\u19B0-\u19C9\u19DE\u19DF\u1A20-\u1A5E\u1A60-\u1A7C\u1AA0-\u1AAD\u1B00-\u1B4C\u1B4E-\u1B7F\uA980-\uA9CD\uA9D0-\uA9D9\uA9DE-\uA9EF\uA9FA-\uA9FE\uAA60-\uAAC2\uAADB-\uAADF]|\uD805[\uDF00-\uDF1A\uDF1D-\uDF2B\uDF3A\uDF3B\uDF3F-\uDF46]/gim.test(String.fromCodePoint(e))}function op(e,t){return/(?:[\u1039\u17D2\u1A60\u1BAB\u200D\uAAF6]|\uD802\uDE3F|\uD804[\uDD33\uDFD0]|\uD806[\uDD3E\uDE47\uDE99]|\uD807[\uDD45\uDD97\uDF42])$/.test(e)||/^\p{gc=Mc}/u.test(t)}var sp={1569:[65152,0,0,0],1570:[65153,65154,0,0],1571:[65155,65156,0,0],1572:[65157,65158,0,0],1573:[65159,65160,0,0],1574:[65161,65162,65163,65164],1575:[65165,65166,0,0],1576:[65167,65168,65169,65170],1577:[65171,65172,0,0],1578:[65173,65174,65175,65176],1579:[65177,65178,65179,65180],1580:[65181,65182,65183,65184],1581:[65185,65186,65187,65188],1582:[65189,65190,65191,65192],1583:[65193,65194,0,0],1584:[65195,65196,0,0],1585:[65197,65198,0,0],1586:[65199,65200,0,0],1587:[65201,65202,65203,65204],1588:[65205,65206,65207,65208],1589:[65209,65210,65211,65212],1590:[65213,65214,65215,65216],1591:[65217,65218,65219,65220],1592:[65221,65222,65223,65224],1593:[65225,65226,65227,65228],1594:[65229,65230,65231,65232],1601:[65233,65234,65235,65236],1602:[65237,65238,65239,65240],1603:[65241,65242,65243,65244],1604:[65245,65246,65247,65248],1605:[65249,65250,65251,65252],1606:[65253,65254,65255,65256],1607:[65257,65258,65259,65260],1608:[65261,65262,0,0],1609:[65263,65264,64488,64489],1610:[65265,65266,65267,65268],1611:[65136,0,0,65137],1612:[65138,0,0,0],1613:[65140,0,0,0],1614:[65142,0,0,65143],1615:[65144,0,0,65145],1616:[65146,0,0,65147],1617:[65148,0,0,65149],1618:[65150,0,0,65151],1649:[64336,64337,0,0],1655:[64477,0,0,0],1657:[64358,64359,64360,64361],1658:[64350,64351,64352,64353],1659:[64338,64339,64340,64341],1662:[64342,64343,64344,64345],1663:[64354,64355,64356,64357],1664:[64346,64347,64348,64349],1667:[64374,64375,64376,64377],1668:[64370,64371,64372,64373],1670:[64378,64379,64380,64381],1671:[64382,64383,64384,64385],1672:[64392,64393,0,0],1676:[64388,64389,0,0],1677:[64386,64387,0,0],1678:[64390,64391,0,0],1681:[64396,64397,0,0],1688:[64394,64395,0,0],1700:[64362,64363,64364,64365],1702:[64366,64367,64368,64369],1705:[64398,64399,64400,64401],1709:[64467,64468,64469,64470],1711:[64402,64403,64404,64405],1713:[64410,64411,64412,64413],1715:[64406,64407,64408,64409],1722:[64414,64415,0,0],1723:[64416,64417,64418,64419],1726:[64426,64427,64428,64429],1728:[64420,64421,0,0],1729:[64422,64423,64424,64425],1733:[64480,64481,0,0],1734:[64473,64474,0,0],1735:[64471,64472,0,0],1736:[64475,64476,0,0],1737:[64482,64483,0,0],1739:[64478,64479,0,0],1740:[64508,64509,64510,64511],1744:[64484,64485,64486,64487],1746:[64430,64431,0,0],1747:[64432,64433,0,0]},lp={"لآ":[65269,65270],"لأ":[65271,65272],"لإ":[65273,65274],"لا":[65275,65276]},up=/[\u0600-\u06ff\u0750-\u077f\u0870-\u089f\u08a0-\u08ff\ufb50-\ufdff\ufe70-\ufeff]/;function hp(e,t,i){let r=0;for(let a of e.split(";")){let[e,n]=a.split(",").map(e=>parseInt(e,36)),o=r+e;for(let r=o;r<o+n;r++)i.set(r,t);r=o+n}}var cp=/* @__PURE__ */new Map;for(let[bC,wC]of Object.entries({C:"18g,1;g2,3;4nb,1",D:"17k,1;5,1;1,1;1,5;4,d;1,7;1,2;z,2;8,g;i,12;1,2;9,1;1,1;1,2;14,3;2,1;28,9;3,f;2,4;1,1;2,3;2,6;7a,1;2,5;1,1;g,a;5,2;2,6;1,f",R:"17m,4;1,1;1,1;5,4;l,1;14,3;1,3;g,i;12,1;2,9;1,1;1,1;2,2;1,1;o,2;2x,3;f,2;4,1;1,2;3,2;6u,j;b,1;r,3;1,1;2,2;6,1",T:"174,b;1,1;1a,l;g,1;2t,7;2,6;2,2;1,4;bt,9;16,o;1,t;1clb,1"}))hp(wC,bC,cp);function dp(e){return cp.get(e)??"U"}function pp(e){return"D"===e||"L"===e||"C"===e}function fp(e){return"D"===e||"R"===e||"C"===e}function mp(e,t,i){return"D"===e?t&&i?3:t?1:i?2:0:"R"===e?+!!t:"L"===e?i?2:0:null}function _p(e){if(!up.test(e))return e;let t=function(e){return[...e].map(e=>{let t=e.codePointAt(0);return{codePoint:t,type:dp(t),form:null}})}(e);return function(e){let t=e.filter(e=>"T"!==e.type);for(let i=0;i<t.length;i++){let e=t[i],r=i>0&&pp(t[i-1].type),a=i+1<t.length&&fp(t[i+1].type);e.form=mp(e.type,r,a)}}(t),function(e){let t=!1;for(let i of e)"T"===i.type?i.form=t?3:0:t=2===i.form||3===i.form}(t),function(e){let t=[];for(let i=0;i<e.length;i++){let r=e[i];if(1604!==r.codePoint){t.push(r);continue}let a=i+1;for(;a<e.length&&"T"===e[a].type;)a++;let n=e[a],o=n&&lp[String.fromCodePoint(1604,n.codePoint)];if(!o){t.push(r);continue}let s=3===r.form||1===r.form;t.push({codePoint:o[+!!s],type:"R",form:0}),t.push(...e.slice(i+1,a)),i=a}return t}(t).map(e=>String.fromCodePoint(function(e){if(null===e.form)return e.codePoint;let t=sp[e.codePoint];return t&&(t[e.form]||t[0])||e.codePoint}(e))).join("")}function gp(e,t,i){let r=t.layout.get("text-transform").evaluate(i,{});return"uppercase"===r?e=e.toLocaleUpperCase():"lowercase"===r&&(e=e.toLocaleLowerCase()),(ip.applyArabicShaping??_p)(e)}function yp(e,t,i){for(let r of e.sections)r.text=gp(r.text,t,i);return e}function vp(e,t,i){let r=i?t.last.points:t.first.points,a=i?r[r.length-1]:r[0];return`${e}:${a.x}:${a.y}`}function xp(e){let t=e.first.points,i=t.length;for(let n=e.first.next;n;n=n.next)i+=n.points.length-1;let r=Array(i);for(let n=0;n<t.length;n++)r[n]=t[n];let a=t.length;for(let n=e.first.next;n;n=n.next){let e=n.points;for(let t=1;t<e.length;t++)r[a++]=e[t]}return r}function bp(e,t,i,r,a){let n=t[i];delete t[i],t[r]=n;let o=e[n];return o.last.next=a.first,o.last=a.last,n}function wp(e,t,i,r,a){let n=t[r];delete t[r],t[i]=n;let o=e[n];return a.last.next=o.first,o.first=a.first,n}var Tp,Sp,Dp=typeof Intl<"u"&&"Segmenter"in Intl;function Ep(e){if(!Dp||!function(e){return/[\r\u0300-\u036F\u0483-\u0489\u0591-\u05BD\u05BF\u05C1\u05C2\u05C4\u05C5\u05C7\u0600-\u0605\u0610-\u061A\u064B-\u065F\u0670\u06D6-\u06DD\u06DF-\u06E4\u06E7\u06E8\u06EA-\u06ED\u070F\u0711\u0730-\u074A\u07A6-\u07B0\u07EB-\u07F3\u07FD\u0816-\u0819\u081B-\u0823\u0825-\u0827\u0829-\u082D\u0859-\u085B\u0890\u0891\u0897-\u089F\u08CA-\u0903\u093A-\u093C\u093E-\u094F\u0951-\u0957\u0962\u0963\u0981-\u0983\u09BC\u09BE-\u09C4\u09C7\u09C8\u09CB-\u09CD\u09D7\u09E2\u09E3\u09FE\u0A01-\u0A03\u0A3C\u0A3E-\u0A42\u0A47\u0A48\u0A4B-\u0A4D\u0A51\u0A70\u0A71\u0A75\u0A81-\u0A83\u0ABC\u0ABE-\u0AC5\u0AC7-\u0AC9\u0ACB-\u0ACD\u0AE2\u0AE3\u0AFA-\u0AFF\u0B01-\u0B03\u0B3C\u0B3E-\u0B44\u0B47\u0B48\u0B4B-\u0B4D\u0B55-\u0B57\u0B62\u0B63\u0B82\u0BBE-\u0BC2\u0BC6-\u0BC8\u0BCA-\u0BCD\u0BD7\u0C00-\u0C04\u0C3C\u0C3E-\u0C44\u0C46-\u0C48\u0C4A-\u0C4D\u0C55\u0C56\u0C62\u0C63\u0C81-\u0C83\u0CBC\u0CBE-\u0CC4\u0CC6-\u0CC8\u0CCA-\u0CCD\u0CD5\u0CD6\u0CE2\u0CE3\u0CF3\u0D00-\u0D03\u0D3B\u0D3C\u0D3E-\u0D44\u0D46-\u0D48\u0D4A-\u0D4E\u0D57\u0D62\u0D63\u0D81-\u0D83\u0DCA\u0DCF-\u0DD4\u0DD6\u0DD8-\u0DDF\u0DF2\u0DF3\u0E31\u0E33-\u0E3A\u0E47-\u0E4E\u0EB1\u0EB3-\u0EBC\u0EC8-\u0ECE\u0F18\u0F19\u0F35\u0F37\u0F39\u0F3E\u0F3F\u0F71-\u0F84\u0F86\u0F87\u0F8D-\u0F97\u0F99-\u0FBC\u0FC6\u102D-\u1037\u1039-\u103E\u1056-\u1059\u105E-\u1060\u1071-\u1074\u1082\u1084-\u1086\u108D\u109D\u1100-\u11FF\u135D-\u135F\u1712-\u1715\u1732-\u1734\u1752\u1753\u1772\u1773\u17B4-\u17D3\u17DD\u180B-\u180D\u180F\u1885\u1886\u18A9\u1920-\u192B\u1930-\u193B\u1A17-\u1A1B\u1A55-\u1A5E\u1A60\u1A62\u1A65-\u1A7C\u1A7F\u1AB0-\u1ADD\u1AE0-\u1AEB\u1B00-\u1B04\u1B34-\u1B44\u1B6B-\u1B73\u1B80-\u1B82\u1BA1-\u1BAD\u1BE6-\u1BF3\u1C24-\u1C37\u1CD0-\u1CD2\u1CD4-\u1CE8\u1CED\u1CF4\u1CF7-\u1CF9\u1DC0-\u1DFF\u200C\u200D\u20D0-\u20F0\u2CEF-\u2CF1\u2D7F\u2DE0-\u2DFF\u302A-\u302F\u3099\u309A\uA66F-\uA672\uA674-\uA67D\uA69E\uA69F\uA6F0\uA6F1\uA802\uA806\uA80B\uA823-\uA827\uA82C\uA880\uA881\uA8B4-\uA8C5\uA8E0-\uA8F1\uA8FF\uA926-\uA92D\uA947-\uA953\uA960-\uA97C\uA980-\uA983\uA9B3-\uA9C0\uA9E5\uAA29-\uAA36\uAA43\uAA4C\uAA4D\uAA7C\uAAB0\uAAB2-\uAAB4\uAAB7\uAAB8\uAABE\uAABF\uAAC1\uAAEB-\uAAEF\uAAF5\uAAF6\uABE3-\uABEA\uABEC\uABED\uAC00-\uD7A3\uD7B0-\uD7C6\uD7CB-\uD7FB\uFB1E\uFE00-\uFE0F\uFE20-\uFE2F\uFF9E\uFF9F]|\uD800[\uDDFD\uDEE0\uDF76-\uDF7A]|\uD802[\uDE01-\uDE03\uDE05\uDE06\uDE0C-\uDE0F\uDE38-\uDE3A\uDE3F\uDEE5\uDEE6]|\uD803[\uDD24-\uDD27\uDD69-\uDD6D\uDEAB\uDEAC\uDEFA-\uDEFF\uDF46-\uDF50\uDF82-\uDF85]|\uD804[\uDC00-\uDC02\uDC38-\uDC46\uDC70\uDC73\uDC74\uDC7F-\uDC82\uDCB0-\uDCBA\uDCBD\uDCC2\uDCCD\uDD00-\uDD02\uDD27-\uDD34\uDD45\uDD46\uDD73\uDD80-\uDD82\uDDB3-\uDDC0\uDDC2\uDDC3\uDDC9-\uDDCC\uDDCE\uDDCF\uDE2C-\uDE37\uDE3E\uDE41\uDEDF-\uDEEA\uDF00-\uDF03\uDF3B\uDF3C\uDF3E-\uDF44\uDF47\uDF48\uDF4B-\uDF4D\uDF57\uDF62\uDF63\uDF66-\uDF6C\uDF70-\uDF74\uDFB8-\uDFC0\uDFC2\uDFC5\uDFC7-\uDFCA\uDFCC-\uDFD2\uDFE1\uDFE2]|\uD805[\uDC35-\uDC46\uDC5E\uDCB0-\uDCC3\uDDAF-\uDDB5\uDDB8-\uDDC0\uDDDC\uDDDD\uDE30-\uDE40\uDEAB-\uDEB7\uDF1D-\uDF1F\uDF22-\uDF2B]|\uD806[\uDC2C-\uDC3A\uDD30-\uDD35\uDD37\uDD38\uDD3B-\uDD43\uDDD1-\uDDD7\uDDDA-\uDDE0\uDDE4\uDE01-\uDE0A\uDE33-\uDE39\uDE3B-\uDE3E\uDE47\uDE51-\uDE5B\uDE84-\uDE99\uDF60-\uDF67]|\uD807[\uDC2F-\uDC36\uDC38-\uDC3F\uDC92-\uDCA7\uDCA9-\uDCB6\uDD31-\uDD36\uDD3A\uDD3C\uDD3D\uDD3F-\uDD47\uDD8A-\uDD8E\uDD90\uDD91\uDD93-\uDD97\uDEF3-\uDEF6\uDF00-\uDF03\uDF34-\uDF3A\uDF3E-\uDF42\uDF5A]|\uD80D[\uDC40\uDC47-\uDC55]|\uD818[\uDD1E-\uDD2F]|\uD81A[\uDEF0-\uDEF4\uDF30-\uDF36]|\uD81B[\uDD63\uDD67-\uDD6A\uDF4F\uDF51-\uDF87\uDF8F-\uDF92\uDFE4\uDFF0\uDFF1]|\uD82F[\uDC9D\uDC9E]|\uD833[\uDF00-\uDF2D\uDF30-\uDF46]|\uD834[\uDD65-\uDD69\uDD6D-\uDD72\uDD7B-\uDD82\uDD85-\uDD8B\uDDAA-\uDDAD\uDE42-\uDE44]|\uD836[\uDE00-\uDE36\uDE3B-\uDE6C\uDE75\uDE84\uDE9B-\uDE9F\uDEA1-\uDEAF]|\uD838[\uDC00-\uDC06\uDC08-\uDC18\uDC1B-\uDC21\uDC23\uDC24\uDC26-\uDC2A\uDC8F\uDD30-\uDD36\uDEAE\uDEEC-\uDEEF]|\uD839[\uDCEC-\uDCEF\uDDEE\uDDEF\uDEE3\uDEE6\uDEEE\uDEEF\uDEF5]|\uD83A[\uDCD0-\uDCD6\uDD44-\uDD4A]|\uD83C[\uDDE6-\uDDFF\uDFFB-\uDFFF]|\uDB40[\uDC20-\uDC7F\uDD00-\uDDEF]/.test(e)}(e))return[...e];Tp??=new Intl.Segmenter(void 0,{granularity:"grapheme"});let t=[];for(let{segment:i}of Tp.segment(e)){let e=t.length-1;e>=0&&op(t[e],i)?t[e]+=i:t.push(i)}return t}function Cp(e){let t=/* @__PURE__ */new Set;if(Dp){Sp??=new Intl.Segmenter(void 0,{granularity:"word"});for(let{index:i}of Sp.segment(e))t.add(i);return t}let i=0;for(let r of e.split(/\b|(?=\p{Ideo})/u))t.add(i),i+=r.length;return t}function Pp(e){let t=e.codePointAt(0);return e.length>(t>65535?2:1)}function Ap(e){return/\s/u.test(String.fromCodePoint(e))}function Ip(e){return/[\p{P}\p{S}]/u.test(String.fromCodePoint(e))}function Mp(e){for(let t of e)if(ap(t.codePointAt(0)))return!0;return!1}function Fp(e){for(let t of e)if(!zp(t.codePointAt(0)))return!1;return!0}function zp(e){return!function(e){return/[\u0600-\u0604\u0606-\u060B\u060D-\u061A\u061C-\u061E\u0620-\u063F\u0641-\u064A\u0656-\u066F\u0671-\u06DC\u06DE-\u070D\u070F-\u074A\u074D-\u077F\u07C0-\u07FA\u07FD-\u07FF\u0840-\u085B\u085E\u0860-\u086A\u0870-\u0891\u0897-\u08E1\u08E3-\u08FF\u1800\u1801\u1804\u1806-\u1819\u1820-\u1878\u1880-\u18AA\uA840-\uA877\uFB50-\uFD3D\uFD40-\uFDCF\uFDF0-\uFDFF\uFE70-\uFE74\uFE76-\uFEFC]|\uD802[\uDEC0-\uDEE6\uDEEB-\uDEF6\uDF80-\uDF91\uDF99-\uDF9C\uDFA9-\uDFAF]|\uD803[\uDD00-\uDD27\uDD30-\uDD39\uDE60-\uDE7E\uDEC2-\uDEC7\uDED0-\uDED8\uDEFA-\uDEFF\uDF30-\uDF59\uDF70-\uDF89\uDFB0-\uDFCB]|\uD805[\uDE60-\uDE6C]|\uD82F[\uDC00-\uDC6A\uDC70-\uDC7C\uDC80-\uDC88\uDC90-\uDC99\uDC9C-\uDC9F]|\uD83A[\uDD00-\uDD4B\uDD50-\uDD59\uDD5E\uDD5F]|\uD83B[\uDE00-\uDE03\uDE05-\uDE1F\uDE21\uDE22\uDE24\uDE27\uDE29-\uDE32\uDE34-\uDE37\uDE39\uDE3B\uDE42\uDE47\uDE49\uDE4B\uDE4D-\uDE4F\uDE51\uDE52\uDE54\uDE57\uDE59\uDE5B\uDE5D\uDE5F\uDE61\uDE62\uDE64\uDE67-\uDE6A\uDE6C-\uDE72\uDE74-\uDE77\uDE79-\uDE7C\uDE7E\uDE80-\uDE89\uDE8B-\uDE9B\uDEA1-\uDEA3\uDEA5-\uDEA9\uDEAB-\uDEBB\uDEF0\uDEF1]/gim.test(String.fromCodePoint(e))}(e)}function kp(e){return!(ap(e)||function(e){return/[\xA7\xA9\xAE\xB1\xBC-\xBE\xD7\xF7\u2016\u2020\u2021\u2030\u2031\u203B\u203C\u2042\u2047-\u2049\u2051\u2100-\u218F\u221E\u2234\u2235\u2300-\u2307\u230C-\u231F\u2324-\u2328\u232B\u237D-\u239A\u23BE-\u23CD\u23CF\u23D1-\u23DB\u23E2-\u2422\u2424-\u24FF\u25A0-\u2619\u2620-\u2767\u2776-\u2793\u2B12-\u2B2F\u2B50-\u2B59\u2BB8-\u2BEB\u3000-\u303F\u30A0-\u30FF\uE000-\uF8FF\uFE30-\uFE6F\uFF00-\uFFEF\uFFFC\uFFFD]|[\uDB80-\uDBFF][\uDC00-\uDFFF]/gim.test(String.fromCodePoint(e))}(e))}function Rp(e){return/\p{sc=Arab}/u.test(String.fromCodePoint(e))}function Lp(e){return function(e){return/[\u0591-\u05C7\u05D0-\u05EA\u05EF-\u05F4\u0600-\u0604\u0606-\u060B\u060D-\u061A\u061C-\u061E\u0620-\u063F\u0641-\u064A\u0656-\u066F\u0671-\u06DC\u06DE-\u070D\u070F-\u074A\u074D-\u07B1\u07C0-\u07FA\u07FD-\u082D\u0830-\u083E\u0840-\u085B\u085E\u0860-\u086A\u0870-\u0891\u0897-\u08E1\u08E3-\u08FF\uFB1D-\uFB36\uFB38-\uFB3C\uFB3E\uFB40\uFB41\uFB43\uFB44\uFB46-\uFD3D\uFD40-\uFDCF\uFDF0-\uFDFF\uFE70-\uFE74\uFE76-\uFEFC]|\uD802[\uDC00-\uDC05\uDC08\uDC0A-\uDC35\uDC37\uDC38\uDC3C\uDC3F-\uDC55\uDC57-\uDC9E\uDCA7-\uDCAF\uDCE0-\uDCF2\uDCF4\uDCF5\uDCFB-\uDD1B\uDD1F-\uDD39\uDD3F-\uDD59\uDD80-\uDDB7\uDDBC-\uDDCF\uDDD2-\uDE03\uDE05\uDE06\uDE0C-\uDE13\uDE15-\uDE17\uDE19-\uDE35\uDE38-\uDE3A\uDE3F-\uDE48\uDE50-\uDE58\uDE60-\uDE9F\uDEC0-\uDEE6\uDEEB-\uDEF6\uDF00-\uDF35\uDF39-\uDF55\uDF58-\uDF72\uDF78-\uDF91\uDF99-\uDF9C\uDFA9-\uDFAF]|\uD803[\uDC00-\uDC48\uDC80-\uDCB2\uDCC0-\uDCF2\uDCFA-\uDD27\uDD30-\uDD39\uDD40-\uDD65\uDD69-\uDD85\uDD8E\uDD8F\uDE60-\uDE7E\uDE80-\uDEA9\uDEAB-\uDEAD\uDEB0\uDEB1\uDEC2-\uDEC7\uDED0-\uDED8\uDEFA-\uDF27\uDF30-\uDF59\uDF70-\uDF89\uDFB0-\uDFCB\uDFE0-\uDFF6]|\uD83A[\uDC00-\uDCC4\uDCC7-\uDCD6\uDD00-\uDD4B\uDD50-\uDD59\uDD5E\uDD5F]|\uD83B[\uDE00-\uDE03\uDE05-\uDE1F\uDE21\uDE22\uDE24\uDE27\uDE29-\uDE32\uDE34-\uDE37\uDE39\uDE3B\uDE42\uDE47\uDE49\uDE4B\uDE4D-\uDE4F\uDE51\uDE52\uDE54\uDE57\uDE59\uDE5B\uDE5D\uDE5F\uDE61\uDE62\uDE64\uDE67-\uDE6A\uDE6C-\uDE72\uDE74-\uDE77\uDE79-\uDE7C\uDE7E\uDE80-\uDE89\uDE8B-\uDE9B\uDEA1-\uDEA3\uDEA5-\uDEA9\uDEAB-\uDEBB\uDEF0\uDEF1]/gim.test(String.fromCodePoint(e))}(e)}function Bp(e){for(let t of e)if(Lp(t.codePointAt(0)))return!0;return!1}var Op={"!":"︕","#":"#",$:"$","%":"%","&":"&","(":"︵",")":"︶","*":"*","+":"+",",":"︐","-":"︲",".":"・","/":"/",":":"︓",";":"︔","<":"︿","=":"=",">":"﹀","?":"︖","@":"@","[":"﹇","\\":"\","]":"﹈","^":"^",_:"︳","`":"`","{":"︷","|":"―","}":"︸","~":"~","¢":"¢","£":"£","¥":"¥","¦":"¦","¬":"¬","¯":" ̄","–":"︲","—":"︱","‘":"﹃","’":"﹄","“":"﹁","”":"﹂","…":"︙","⋯":"︙","‧":"・","₩":"₩","、":"︑","。":"︒","〈":"︿","〉":"﹀","《":"︽","》":"︾","「":"﹁","」":"﹂","『":"﹃","』":"﹄","【":"︻","】":"︼","〔":"︹","〕":"︺","〖":"︗","〗":"︘","!":"︕","(":"︵",")":"︶",",":"︐","-":"︲",".":"・",":":"︓",";":"︔","<":"︿",">":"﹀","?":"︖","[":"﹇","]":"﹈","_":"︳","{":"︷","|":"―","}":"︸","⦅":"︵","⦆":"︶","。":"︒","「":"﹁","」":"﹂"},jp={10:!0,13:!0,32:!0,38:!0,41:!0,43:!0,45:!0,47:!0,173:!0,183:!0,8203:!0,8208:!0,8211:!0,8231:!0},Vp={40:!0};function Np(e,t,i,r,a,n){if("fontStack"in t){let r=i[t.fontStack]?.default,n=r?.[e];if(n)return n.metrics.advance*t.scale+a;let o=0;for(let i of e){let e=r?.[i];e&&(o+=e.metrics.advance*t.scale+a)}return o}{let e=r[t.imageName];return e?e.displaySize[0]*t.scale*24/n+a:0}}function Up(e,t,i,r){let a=(e-t)**2;return r?e<t?a/2:2*a:a+Math.abs(i)*i}function $p(e){return/^\s+$/u.test(e)}function Gp(e,t,i){let r=0;return(10===e||13===e)&&(r-=1e4),i&&(r+=150),(40===e||65288===e)&&(r+=50),(41===t||65289===t)&&(r+=50),r}function Zp(e,t,i,r,a,n){let o=null,s=Up(t,i,a,n);for(let l of r){let e=Up(t-l.x,i,a,n)+l.badness;e<=s&&(o=l,s=e)}return{index:e,x:t,priorBreak:o,badness:s}}function qp(e){return e?qp(e.priorBreak).concat(e.index):[]}var Wp=class e{constructor(e="",t=[],i=[]){this.text=e,this.sections=t,this.sectionIndex=i,this.imageSectionID=null,this.cachedGraphemes=null}graphemes(){return this.cachedGraphemes??=Ep(this.text),this.cachedGraphemes}static fromFeature(t,i,r,a){let n=new e;for(let e of t.sections)e.image?n.addImageSection(e):n.addTextSection(e,i);return r&&n.verticalizePunctuation(a),n}length(){return this.graphemes().length}getSection(e){return this.sections[this.sectionIndex[e]]}getSectionIndex(e){return this.sectionIndex[e]}verticalizePunctuation(e={},t){let i=function(e){let t="",i={premature:!0,value:void 0},r=e[Symbol.iterator](),a=r.next(),n=e[Symbol.iterator]();n.next();let o=n.next();for(;!a.done;)!o.done&&kp(o.value.codePointAt(0))&&!Op[o.value]||!i.premature&&kp(i.value.codePointAt(0))&&!Op[i.value]||!Op[a.value]?t+=a.value:t+=Op[a.value],i={value:a.value,premature:!1},a=r.next(),o=n.next();return t}(this.text),r=0;this.cachedGraphemes=this.graphemes().map((a,n)=>{let o=i.slice(r,r+a.length);r+=a.length;let s=this.getSection(n);return!1!==t?.[n]&&"fontStack"in s&&e[s.fontStack]?.vertical?.[a]?a:o}),this.text=this.cachedGraphemes.join("")}hasZeroWidthSpaces(){return this.text.includes("")}trim(){let e=this.graphemes(),t=0;for(;t<e.length&&$p(e[t]);)t++;let i=e.length;for(;i>t&&$p(e[i-1]);)i--;this.text=e.slice(t,i).join(""),this.sectionIndex=this.sectionIndex.slice(t,i),this.cachedGraphemes=null}substring(t,i){let r=this.graphemes().slice(t,i).join(""),a=this.sectionIndex.slice(t,i);return new e(r,this.sections,a)}toCodeUnitIndex(e){return this.graphemes().slice(0,e).join("").length}toString(){return this.text}getMaxScale(){return this.sectionIndex.reduce((e,t)=>Math.max(e,this.sections[t].scale),0)}getMaxImageSize(e){let t=0,i=0;for(let r=0;r<this.length();r++){let a=this.getSection(r);if("imageName"in a){let r=e[a.imageName];if(!r)continue;let n=r.displaySize;t=Math.max(t,n[0]),i=Math.max(i,n[1])}}return{maxImageWidth:t,maxImageHeight:i}}_appendSection(e,t){let i=this.graphemes(),r=i.length>0?i[i.length-1]:"",a=Ep(r+e);this.text+=e,this.cachedGraphemes=i.slice(0,r?-1:void 0).concat(a);let n=a.length-+!!r;for(let o=0;o<n;o++)this.sectionIndex.push(t)}addTextSection(e,t){this.sections.push({scale:e.scale||1,verticalAlign:e.verticalAlign||"bottom",fontStack:e.fontStack||t}),this._appendSection(e.text,this.sections.length-1)}addImageSection(e){let t=e.image?e.image.name:"";if(0===t.length)return void Oe("Can't add FormattedSection with an empty image.");let i=this.getNextImageSectionCharCode();i?(this.sections.push({scale:1,verticalAlign:e.verticalAlign||"bottom",imageName:t}),this._appendSection(String.fromCharCode(i),this.sections.length-1)):Oe("Reached maximum number of images 6401")}getNextImageSectionCharCode(){return this.imageSectionID?this.imageSectionID>=63743?null:++this.imageSectionID:(this.imageSectionID=57344,this.imageSectionID)}determineLineBreaks(e,t,i,r,a){let n=this.determineTotalWidth(e,i,r,a);if(e>=0&&n>0&&n<=t&&!/[\n\r]/.test(this.text))return[this.length()];let o=[],s=n/Math.max(1,Math.ceil(n/t)),l=this.hasZeroWidthSpaces(),u=this.graphemes(),h=null,c=0,d=0;for(let p=0;p<u.length;p++){let t=u[p];if(p>0){let e=u[p-1].codePointAt(0),i=t.codePointAt(0),r=rp(e),a=np(e)&&np(i);(jp[e]||r||"imageName"in this.getSection(p-1)||void 0!==u[p+1]&&Vp[i]||a&&(h??=Cp(this.text)).has(d))&&o.push(Zp(p,c,s,o,Gp(e,i,r&&l),!1))}Ap(t.codePointAt(0))||(c+=Np(t,this.getSection(p),i,r,e,a)),d+=t.length}return qp(Zp(this.length(),c,s,o,0,!0))}determineTotalWidth(e,t,i,r){let a=0,n=0;for(let o of this.graphemes())a+=Np(o,this.getSection(n),t,i,e,r),n++;return a}},Hp=function(e){var t={R:"13k,1a,2,3,3,2+1j,ch+16,a+1,5+2,2+n,5,a,4,6+16,4+3,h+1b,4mo,179q,2+9,2+11,2i9+7y,2+68,4,3+4,5+13,4+3,2+4k,3+29,8+cf,1t+7z,w+17,3+3m,1t+3z,16o1+5r,8+30,8+mc,29+1r,29+4v,75+73",EN:"1c+9,3d+1,6,187+9,513,4+5,7+9,sf+j,175h+9,qw+q,161f+1d,4xt+a,25i+9",ES:"17,2,6dp+1,f+1,av,16vr,mx+1,4o,2",ET:"z+2,3h+3,b+1,ym,3e+1,2o,p4+1,8,6u,7c,g6,1wc,1n9+4,30+1b,2n,6d,qhx+1,h0m,a+1,49+2,63+1,4+1,6bb+3,12jj",AN:"16o+5,2j+9,2+1,35,ed,1ff2+9,87+u",CS:"18,2+1,b,2u,12k,55v,l,17v0,2,3,53,2+1,b",B:"a,3,f+2,2v,690",S:"9,2,k",WS:"c,k,4f4,1vk+a,u,1j,335",ON:"x+1,4+4,h+5,r+5,r+3,z,5+3,2+1,2+1,5,2+2,3+4,o,w,ci+1,8+d,3+d,6+8,2+g,39+1,9,6+1,2,33,b8,3+1,3c+1,7+1,5r,b,7h+3,sa+5,2,3i+6,jg+3,ur+9,2v,ij+1,9g+9,7+a,8m,4+1,49+x,14u,2+2,c+2,e+2,e+2,e+1,i+n,e+e,2+p,u+2,e+2,36+1,2+3,2+1,b,2+2,6+5,2,2,2,h+1,5+4,6+3,3+f,16+2,5+3l,3+81,1y+p,2+40,q+a,m+13,2r+ch,2+9e,75+hf,3+v,2+2w,6e+5,f+6,75+2a,1a+p,2+2g,d+5x,r+b,6+3,4+o,g,6+1,6+2,2k+1,4,2j,5h+z,1m+1,1e+f,t+2,1f+e,d+3,4o+3,2s+1,w,535+1r,h3l+1i,93+2,2s,b+1,3l+x,2v,4g+3,21+3,kz+1,g5v+1,5a,j+9,n+v,2,3,2+8,2+1,3+2,2,3,46+1,4+4,h+5,r+5,r+a,3h+2,4+6,b+4,78,1r+24,4+c,4,1hb,ey+6,103+j,16j+c,1ux+7,5+g,fsh,jdq+1t,4,57+2e,p1,1m,1m,1m,1m,4kt+1,7j+17,5+2r,d+e,3+e,2+e,2+10,m+4,w,1n+5,1q,4z+5,4b+rb,9+c,4+c,4+37,d+2g,8+b,l+b,5+1j,9+9,7+13,9+t,3+1,27+3c,2+29,2+3q,d+d,3+4,4+2,6+6,a+o,8+6,a+2,e+6,16+42,2+1i",BN:"0+8,6+d,2s+5,2+p,e,4m9,1kt+2,2b+5,5+5,17q9+v,7k,6p+8,6+1,119d+3,440+7,96s+1,1ekf+1,1ekf+1,1ekf+1,1ekf+1,1ekf+1,1ekf+1,1ekf+1,1ekf+1,1ekf+1,1ekf+1,1ekf+1,1ekf+75,6p+2rz,1ben+1,1ekf+1,1ekf+1",NSM:"lc+33,7o+6,7c+18,2,2+1,2+1,2,21+a,1d+k,h,2u+6,3+5,3+1,2+3,10,v+q,2k+a,1n+8,a,p+3,2+8,2+2,2+4,18+2,3c+e,2+v,1k,2,5+7,5,4+6,b+1,u,1n,5+3,9,l+1,r,3+1,1m,5+1,5+1,3+2,4,v+1,4,c+1,1m,5+4,2+1,5,l+1,n+5,2,1n,3,2+3,9,8+1,c+1,v,1q,d,1f,4,1m+2,6+2,2+3,8+1,c+1,u,1n,g+1,l+1,t+1,1m+1,5+3,9,l+1,u,21,8+2,2,2j,3+6,d+7,2r,3+8,c+5,23+1,s,2,2,1k+d,2+4,2+1,6+a,2+z,a,2v+3,2+5,2+1,3+1,q+1,5+2,h+3,e,3+1,7,g,jk+2,qb+2,u+2,u+1,v+1,1t+1,2+6,9,3+a,a,1a+2,3c+1,z,3b+2,5+1,a,7+2,64+1,3,1n,2+6,2,2,3+7,7+9,3,1d+g,1s+3,1d,2+4,2,6,15+8,d+1,x+3,3+1,2+2,1l,2+1,4,2+2,1n+7,3+1,49+2,2+c,2+6,5,7,4+1,5j+1l,2+4,k1+w,2db+2,3y,2p+v,ff+3,30+1,n9x+3,2+9,x+1,29+1,7l,4,5,q+1,6,48+1,r+h,e,13+7,q+a,1b+2,1d,3+3,3+1,14,1w+5,3+1,3+1,d,9,1c,1g,2+2,3+1,6+1,2,17+1,9,6n,3,5,fn5,ki+f,h+f,r2,6b,46+4,1af+2,2+1,6+3,15+2,5,4m+1,fy+3,as+1,4a+a,4x,1j+e,1l+2,1e+3,3+1,1y+2,11+4,2+7,1r,d+1,1h+8,b+3,3,2o+2,3,2+1,7,4h,4+7,m+1,1m+1,4,12+6,4+4,5g+7,3+2,2,o,2d+5,2,5+1,2+1,6n+3,7+1,2+1,s+1,2e+7,3,2+1,2z,2,3+5,2,2u+2,3+3,2+4,78+8,2+1,75+1,2,5,41+3,3+1,5,x+5,3+1,15+5,3+3,9,a+5,3+2,1b+c,2+1,bb+6,2+5,2d+l,3+6,2+1,2+1,3f+5,4,2+1,2+6,2,21+1,4,2,9o+1,f0c+4,1o+6,t5,1s+3,2a,f5l+1,43t+2,i+7,3+6,v+3,45+2,1j0+1i,5+1d,9,f,n+4,2+e,11t+6,2+g,3+6,2+1,2+4,7a+6,c6+3,15t+6,32+6,gzhy+6n",AL:"16w,3,2,e+1b,z+2,2+2s,g+1,8+1,b+m,2+t,s+2i,c+e,4h+f,1d+1e,1bwe+dp,3+3z,x+c,2+1,35+3y,2rm+z,5+7,b+5,dt+l,c+u,17nl+27,1t+27,4x+6n,3+d",LRO:"6ct",RLO:"6cu",LRE:"6cq",RLE:"6cr",PDF:"6cs",LRI:"6ee",RLI:"6ef",FSI:"6eg",PDI:"6eh"},i={},r={};i.L=1,r[1]="L",Object.keys(t).forEach(function(e,t){i[e]=1<<t+1,r[i[e]]=e}),Object.freeze(i);var a=i.LRI|i.RLI|i.FSI,n=i.L|i.R|i.AL,o=i.B|i.S|i.WS|i.ON|i.FSI|i.LRI|i.RLI|i.PDI,s=i.BN|i.RLE|i.LRE|i.RLO|i.LRO|i.PDF,l=i.S|i.WS|i.B|a|i.PDI|s,u=null;function h(e){return function(){if(!u){u=/* @__PURE__ */new Map;var e=0;for(var r in t)if(t.hasOwnProperty(r))for(var a=t[r],n="",o=void 0,s=!1,l=0,h=0;h<=a.length+1;h+=1){var c=a[h];if(","!==c&&h!==a.length)"+"===c?(s=!0,l=e=l+parseInt(n,36),n=""):n+=c;else{s?o=e+parseInt(n,36):(l=e=l+parseInt(n,36),o=e),s=!1,n="",l=o;for(var d=e;d<o+1;d+=1)u.set(d,i[r])}}}}(),u.get(e.codePointAt(0))||i.L}var c,d,p,f="14>1,1e>2,u>2,2wt>1,1>1,1ge>1,1wp>1,1j>1,f>1,hm>1,1>1,u>1,u6>1,1>1,+5,28>1,w>1,1>1,+3,b8>1,1>1,+3,1>3,-1>-1,3>1,1>1,+2,1s>1,1>1,x>1,th>1,1>1,+2,db>1,1>1,+3,3>1,1>1,+2,14qm>1,1>1,+1,4q>1,1e>2,u>2,2>1,+1",m="6f1>-6dx,6dy>-6dx,6ec>-6ed,6ee>-6ed,6ww>2jj,-2ji>2jj,14r4>-1e7l,1e7m>-1e7l,1e7m>-1e5c,1e5d>-1e5b,1e5c>-14qx,14qy>-14qx,14vn>-1ecg,1ech>-1ecg,1edu>-1ecg,1eci>-1ecg,1eda>-1ecg,1eci>-1ecg,1eci>-168q,168r>-168q,168s>-14ye,14yf>-14ye";function _(e,t){var i,r=0,a=/* @__PURE__ */new Map,n=t&&/* @__PURE__ */new Map;return e.split(",").forEach(function e(o){if(-1!==o.indexOf("+"))for(var s=+o;s--;)e(i);else{i=o;var l=o.split(">"),u=l[0],h=l[1];u=String.fromCodePoint(r+=parseInt(u,36)),h=String.fromCodePoint(r+=parseInt(h,36)),a.set(u,h),t&&n.set(h,u)}}),{map:a,reverseMap:n}}function g(){if(!c){var e=_(f,!0),t=e.map,i=e.reverseMap;c=t,d=i,p=_(m,!1).map}}function y(e){return g(),c.get(e)||null}function v(e){return g(),d.get(e)||null}function x(e){return g(),p.get(e)||null}var b,w=i.L,T=i.R,S=i.EN,D=i.ES,E=i.ET,C=i.AN,P=i.CS,A=i.B,I=i.S,M=i.ON,F=i.BN,z=i.NSM,k=i.AL,R=i.LRO,L=i.RLO,B=i.LRE,O=i.RLE,j=i.PDF,V=i.LRI,N=i.RLI,U=i.FSI,$=i.PDI;function G(e){return function(){if(!b){var e=_("14>1,j>2,t>2,u>2,1a>g,2v3>1,1>1,1ge>1,1wd>1,b>1,1j>1,f>1,ai>3,-2>3,+1,8>1k0,-1jq>1y7,-1y6>1hf,-1he>1h6,-1h5>1ha,-1h8>1qi,-1pu>1,6>3u,-3s>7,6>1,1>1,f>1,1>1,+2,3>1,1>1,+13,4>1,1>1,6>1eo,-1ee>1,3>1mg,-1me>1mk,-1mj>1mi,-1mg>1mi,-1md>1,1>1,+2,1>10k,-103>1,1>1,4>1,5>1,1>1,+10,3>1,1>8,-7>8,+1,-6>7,+1,a>1,1>1,u>1,u6>1,1>1,+5,26>1,1>1,2>1,2>2,8>1,7>1,4>1,1>1,+5,b8>1,1>1,+3,1>3,-2>1,2>1,1>1,+2,c>1,3>1,1>1,+2,h>1,3>1,a>1,1>1,2>1,3>1,1>1,d>1,f>1,3>1,1a>1,1>1,6>1,7>1,13>1,k>1,1>1,+19,4>1,1>1,+2,2>1,1>1,+18,m>1,a>1,1>1,lk>1,1>1,4>1,2>1,f>1,3>1,1>1,+3,db>1,1>1,+3,3>1,1>1,+2,14qm>1,1>1,+1,6>1,4j>1,j>2,t>2,u>2,2>1,+1",!0),t=e.map;e.reverseMap.forEach(function(e,i){t.set(i,e)}),b=t}}(),b.get(e)||null}function Z(e,t,i,r){var a=e.length;i=Math.max(0,null==i?0:+i),r=Math.min(a-1,null==r?a-1:+r);var n=[];return t.paragraphs.forEach(function(a){var o=Math.max(i,a.start),s=Math.min(r,a.end);if(o<s){for(var u=t.levels.slice(o,s+1),c=s;c>=o&&h(e[c])&l;c--)u[c]=a.level;for(var d=a.level,p=1/0,f=0;f<u.length;f++){var m=u[f];m>d&&(d=m),m<p&&(p=1|m)}for(var _=d;_>=p;_--)for(var g=0;g<u.length;g++)if(u[g]>=_){for(var y=g;g+1<u.length&&u[g+1]>=_;)g++;g>y&&n.push([y+o,g+o])}}}),n}function q(e,t,i,r){for(var a=Z(e,t,i,r),n=[],o=0;o<e.length;o++)n[o]=o;return a.forEach(function(e){for(var t=e[0],i=e[1],r=n.slice(t,i+1),a=r.length;a--;)n[i-a]=r[a]}),n}return e.closingToOpeningBracket=v,e.getBidiCharType=h,e.getBidiCharTypeName=function(e){return r[h(e)]},e.getCanonicalBracket=x,e.getEmbeddingLevels=function(e,t){for(var i=new Uint32Array(e.length),r=0;r<e.length;r++)i[r]=h(e[r]);var u=/* @__PURE__ */new Map;function c(e,t){var r=i[e];i[e]=t,u.set(r,u.get(r)-1),r&o&&u.set(o,u.get(o)-1),u.set(t,(u.get(t)||0)+1),t&o&&u.set(o,(u.get(o)||0)+1)}for(var d=new Uint8Array(e.length),p=/* @__PURE__ */new Map,f=[],m=null,_=0;_<e.length;_++)m||f.push(m={start:_,end:e.length-1,level:"rtl"===t?1:"ltr"===t?0:Vt(_,!1)}),i[_]&A&&(m.end=_,m=null);for(var g=O|B|L|R|a|$|j|A,b=function(e){return e+(1&e?1:2)},G=function(e){return e+(1&e?2:1)},Z=0;Z<f.length;Z++){var q=[{_level:(m=f[Z]).level,_override:0,_isolate:0}],W=void 0,H=0,X=0,Y=0;u.clear();for(var K=m.start;K<=m.end;K++){var J=i[K];if(W=q[q.length-1],u.set(J,(u.get(J)||0)+1),J&o&&u.set(o,(u.get(o)||0)+1),J&g)if(J&(O|B)){d[K]=W._level;var Q=(J===O?G:b)(W._level);Q<=125&&!H&&!X?q.push({_level:Q,_override:0,_isolate:0}):H||X++}else if(J&(L|R)){d[K]=W._level;var ee=(J===L?G:b)(W._level);ee<=125&&!H&&!X?q.push({_level:ee,_override:J&L?T:w,_isolate:0}):H||X++}else if(J&a){J&U&&(J=1===Vt(K+1,!0)?N:V),d[K]=W._level,W._override&&c(K,W._override);var te=(J===N?G:b)(W._level);te<=125&&0===H&&0===X?(Y++,q.push({_level:te,_override:0,_isolate:1,_isolInitIndex:K})):H++}else if(J&$){if(H>0)H--;else if(Y>0){for(X=0;!q[q.length-1]._isolate;)q.pop();var ie=q[q.length-1]._isolInitIndex;null!=ie&&(p.set(ie,K),p.set(K,ie)),q.pop(),Y--}W=q[q.length-1],d[K]=W._level,W._override&&c(K,W._override)}else J&j?(0===H&&(X>0?X--:!W._isolate&&q.length>1&&(q.pop(),W=q[q.length-1])),d[K]=W._level):J&A&&(d[K]=m.level);else d[K]=W._level,W._override&&J!==F&&c(K,W._override)}for(var re=[],ae=null,ne=m.start;ne<=m.end;ne++){var oe=i[ne];if(!(oe&s)){var se=d[ne],le=oe&a,ue=oe===$;ae&&se===ae._level?(ae._end=ne,ae._endsWithIsolInit=le):re.push(ae={_start:ne,_end:ne,_level:se,_startsWithPDI:ue,_endsWithIsolInit:le})}}for(var he=[],ce=0;ce<re.length;ce++){var de=re[ce];if(!de._startsWithPDI||de._startsWithPDI&&!p.has(de._start)){for(var pe=[ae=de],fe=void 0;ae&&ae._endsWithIsolInit&&null!=(fe=p.get(ae._end));)for(var me=ce+1;me<re.length;me++)if(re[me]._start===fe){pe.push(ae=re[me]);break}for(var _e=[],ge=0;ge<pe.length;ge++)for(var ye=pe[ge],ve=ye._start;ve<=ye._end;ve++)_e.push(ve);for(var xe=d[_e[0]],be=m.level,we=_e[0]-1;we>=0;we--)if(!(i[we]&s)){be=d[we];break}var Te=_e[_e.length-1],Se=d[Te],De=m.level;if(!(i[Te]&a))for(var Ee=Te+1;Ee<=m.end;Ee++)if(!(i[Ee]&s)){De=d[Ee];break}he.push({_seqIndices:_e,_sosType:Math.max(be,xe)%2?T:w,_eosType:Math.max(De,Se)%2?T:w})}}for(var Ce=0;Ce<he.length;Ce++){var Pe=he[Ce],Ae=Pe._seqIndices,Ie=Pe._sosType,Me=Pe._eosType,Fe=1&d[Ae[0]]?T:w;if(u.get(z))for(var ze=0;ze<Ae.length;ze++){var ke=Ae[ze];if(i[ke]&z){for(var Re=Ie,Le=ze-1;Le>=0;Le--)if(!(i[Ae[Le]]&s)){Re=i[Ae[Le]];break}c(ke,Re&(a|$)?M:Re)}}if(u.get(S))for(var Be=0;Be<Ae.length;Be++){var Oe=Ae[Be];if(i[Oe]&S)for(var je=Be-1;je>=-1;je--){var Ve=-1===je?Ie:i[Ae[je]];if(Ve&n){Ve===k&&c(Oe,C);break}}}if(u.get(k))for(var Ne=0;Ne<Ae.length;Ne++){var Ue=Ae[Ne];i[Ue]&k&&c(Ue,T)}if(u.get(D)||u.get(P))for(var $e=1;$e<Ae.length-1;$e++){var Ge=Ae[$e];if(i[Ge]&(D|P)){for(var Ze=0,qe=0,We=$e-1;We>=0&&(Ze=i[Ae[We]])&s;We--);for(var He=$e+1;He<Ae.length&&(qe=i[Ae[He]])&s;He++);Ze===qe&&(i[Ge]===D?Ze===S:Ze&(S|C))&&c(Ge,Ze)}}if(u.get(S))for(var Xe=0;Xe<Ae.length;Xe++)if(i[Ae[Xe]]&S){for(var Ye=Xe-1;Ye>=0&&i[Ae[Ye]]&(E|s);Ye--)c(Ae[Ye],S);for(Xe++;Xe<Ae.length&&i[Ae[Xe]]&(E|s|S);Xe++)i[Ae[Xe]]!==S&&c(Ae[Xe],S)}if(u.get(E)||u.get(D)||u.get(P))for(var Ke=0;Ke<Ae.length;Ke++){var Je=Ae[Ke];if(i[Je]&(E|D|P)){c(Je,M);for(var Qe=Ke-1;Qe>=0&&i[Ae[Qe]]&s;Qe--)c(Ae[Qe],M);for(var et=Ke+1;et<Ae.length&&i[Ae[et]]&s;et++)c(Ae[et],M)}}if(u.get(S))for(var tt=0,it=Ie;tt<Ae.length;tt++){var rt=Ae[tt],at=i[rt];at&S?it===w&&c(rt,w):at&n&&(it=at)}if(u.get(o)){for(var nt=T|S|C,ot=nt|w,st=[],lt=[],ut=0;ut<Ae.length;ut++)if(i[Ae[ut]]&o){var ht=e[Ae[ut]],ct=void 0;if(null!==y(ht)){if(!(lt.length<63))break;lt.push({char:ht,seqIndex:ut})}else if(null!==(ct=v(ht)))for(var dt=lt.length-1;dt>=0;dt--){var pt=lt[dt].char;if(pt===ct||pt===v(x(ht))||y(x(pt))===ht){st.push([lt[dt].seqIndex,ut]),lt.length=dt;break}}}st.sort(function(e,t){return e[0]-t[0]});for(var ft=0;ft<st.length;ft++){for(var mt=st[ft],_t=mt[0],gt=mt[1],yt=!1,vt=0,xt=_t+1;xt<gt;xt++){var bt=Ae[xt];if(i[bt]&ot){yt=!0;var wt=i[bt]&nt?T:w;if(wt===Fe){vt=wt;break}}}if(yt&&!vt){vt=Ie;for(var Tt=_t-1;Tt>=0;Tt--){var St=Ae[Tt];if(i[St]&ot){var Dt=i[St]&nt?T:w;vt=Dt===Fe?Fe:Dt;break}}}if(vt){if(i[Ae[_t]]=i[Ae[gt]]=vt,vt!==Fe)for(var Et=_t+1;Et<Ae.length;Et++)if(!(i[Ae[Et]]&s)){h(e[Ae[Et]])&z&&(i[Ae[Et]]=vt);break}if(vt!==Fe)for(var Ct=gt+1;Ct<Ae.length;Ct++)if(!(i[Ae[Ct]]&s)){h(e[Ae[Ct]])&z&&(i[Ae[Ct]]=vt);break}}}for(var Pt=0;Pt<Ae.length;Pt++)if(i[Ae[Pt]]&o){for(var At=Pt,It=Pt,Mt=Ie,Ft=Pt-1;Ft>=0;Ft--){if(!(i[Ae[Ft]]&s)){Mt=i[Ae[Ft]]&nt?T:w;break}At=Ft}for(var zt=Me,kt=Pt+1;kt<Ae.length;kt++){if(!(i[Ae[kt]]&(o|s))){zt=i[Ae[kt]]&nt?T:w;break}It=kt}for(var Rt=At;Rt<=It;Rt++)i[Ae[Rt]]=Mt===zt?Mt:Fe;Pt=It}}}for(var Lt=m.start;Lt<=m.end;Lt++){var Bt=d[Lt],Ot=i[Lt];if(1&Bt?Ot&(w|S|C)&&d[Lt]++:Ot&T?d[Lt]++:Ot&(C|S)&&(d[Lt]+=2),Ot&s&&(d[Lt]=0===Lt?m.level:d[Lt-1]),Lt===m.end||h(e[Lt])&(I|A))for(var jt=Lt;jt>=0&&h(e[jt])&l;jt--)d[jt]=m.level}}return{levels:d,paragraphs:f};function Vt(t,r){for(var n=t;n<e.length;n++){var o=i[n];if(o&(T|k))return 1;if(o&(A|w)||r&&o===$)return 0;if(o&a){var s=Nt(n);n=-1===s?e.length:s}}return 0}function Nt(t){for(var r=1,n=t+1;n<e.length;n++){var o=i[n];if(o&A)break;if(o&$){if(0===--r)return n}else o&a&&r++}return-1}},e.getMirroredCharacter=G,e.getMirroredCharactersMap=function(e,t,i,r){var a=e.length;i=Math.max(0,null==i?0:+i),r=Math.min(a-1,null==r?a-1:+r);for(var n=/* @__PURE__ */new Map,o=i;o<=r;o++)if(1&t[o]){var s=G(e[o]);null!==s&&n.set(o,s)}return n},e.getReorderSegments=Z,e.getReorderedIndices=q,e.getReorderedString=function(e,t,i,r){var a=q(e,t,i,r),n=[].concat(e);return a.forEach(function(i,r){n[r]=(1&t.levels[i]?G(e[i]):null)||e[i]}),n.join("")},e.openingToClosingBracket=y,Object.defineProperty(e,"__esModule",{value:!0}),e}({}),Xp=/[\u061c\u200e\u200f\u202a-\u202e\u2066-\u2069]/,Yp=/* @__PURE__ */new Set(["WS","FSI","LRI","RLI","PDI"]),Kp=/* @__PURE__ */new Set(["S","B"]);function Jp(e){return e.level%2==0?e.text:Hp.getMirroredCharacter(e.text)??e.text}function Qp(e,t){let{levels:i,paragraphs:r}=Hp.getEmbeddingLevels(e);return function(e,t){let i=t.filter(t=>t>0&&t<e.length),r=[.../* @__PURE__ */new Set([0,...i,e.length])].sort((e,t)=>e-t),a=[];for(let n=0;n+1<r.length;n++)a.push([r[n],r[n+1]]);return a}(e,t.concat(r.map(e=>e.start))).map(([t,a])=>function(e,t,i,r,a){let n=function(e,t,i,r){let a=[],n=i;for(let o of Ep(e.slice(i,r)))a.push({index:n,text:o,level:t[n]}),n+=o.length;return a}(e,t,r,a);!function(e,t){let i=!0;for(let r=e.length-1;r>=0;r--){let a=Hp.getBidiCharTypeName(e[r].text[0]);Kp.has(a)?(e[r].level=t,i=!0):i&&Yp.has(a)?e[r].level=t:i=!1}}(n,i);let o="",s=[];for(let l of function(e,t){let i=t,r=1/0;for(let{level:n}of e)n>i&&(i=n),(1|n)<r&&(r=1|n);let a=e.slice();for(let n=i;n>=r;n--)for(let e=0;e<a.length;e++){if(a[e].level<n)continue;let t=e;for(;t+1<a.length&&a[t+1].level>=n;)t++;for(let i=e,r=t;i<r;i++,r--)[a[i],a[r]]=[a[r],a[i]];e=t}return a}(n,i)){if(Xp.test(l.text))continue;let e=Jp(l);o+=e,s.push(...Array(e.length).fill(l.index))}return{text:o,sourceIndices:s}}(e,i,function(e,t){return e.find(e=>t>=e.start&&t<=e.end)?.level??0}(r,t),t,a))}var ef=4294967296,tf=typeof TextDecoder>"u"?null:new TextDecoder("utf-8"),rf=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)*ef;return this.pos+=8,e}readSFixed64(){let e=this.dataView.getUint32(this.pos,!0)+this.dataView.getInt32(this.pos+4,!0)*ef;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&&tf?tf.decode(this.buf.subarray(t,e)):function(e,t,i){let r="",a=t;for(;a<i;){let t,n,o,s=e[a],l=null,u=s>239?4:s>223?3:s>191?2:1;if(a+u>i)break;1===u?s<128&&(l=s):2===u?(t=e[a+1],128==(192&t)&&(l=(31&s)<<6|63&t,l<=127&&(l=null))):3===u?(t=e[a+1],n=e[a+2],128==(192&t)&&128==(192&n)&&(l=(15&s)<<12|(63&t)<<6|63&n,(l<=2047||l>=55296&&l<=57343)&&(l=null))):4===u&&(t=e[a+1],n=e[a+2],o=e[a+3],128==(192&t)&&128==(192&n)&&128==(192&o)&&(l=(15&s)<<18|(63&t)<<12|(63&n)<<6|63&o,(l<=65535||l>=1114112)&&(l=null))),null===l?(l=65533,u=1):l>65535&&(l-=65536,r+=String.fromCharCode(l>>>10&1023|55296),l=56320|1023&l),r+=String.fromCharCode(l),a+=u}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 af(e,t,i){1===e&&i.readMessage(nf,t)}function nf(e,t,i){if(3===e){let{id:e,bitmap:r,width:a,height:n,left:o,top:s,advance:l}=i.readMessage(of,{});t.push({id:e,bitmap:new xh({width:a+6,height:n+6},r),metrics:{width:a,height:n,left:o,top:s,advance:l}})}}function of(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 sf(e){return"function"==typeof e?.renderWithWebGL}function lf(e){let{userImage:t}=e;return!(!t?.render||!t.render()||(sf(t.data)||e.data.replace(new Uint8Array(t.data.buffer)),0))}function uf(e){let t=0,i=0;for(let o of e)t+=o.w*o.h,i=Math.max(i,o.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 o of e)for(let e=r.length-1;e>=0;e--){let t=r[e];if(!(o.w>t.w||o.h>t.h)){if(o.x=t.x,o.y=t.y,n=Math.max(n,o.y+o.h),a=Math.max(a,o.x+o.w),o.w===t.w&&o.h===t.h){let t=r.pop();t&&e<r.length&&(r[e]=t)}else o.h===t.h?(t.x+=o.w,t.w-=o.w):o.w===t.w?(t.y+=o.h,t.h-=o.h):(r.push({x:t.x+o.w,y:t.y,w:t.w-o.w,h:o.h}),t.y+=o.h,t.h-=o.h);break}}return{w:a,h:n,fill:t/(a*n)||0}}var hf=class{constructor(e,{pixelRatio:t,version:i,isWebGLImage:r=!1,stretchX:a,stretchY:n,content:o,textFitWidth:s,textFitHeight:l}){this.paddedRect=e,this.pixelRatio=t,this.stretchX=a,this.stretchY=n,this.content=o,this.version=i,this.needsFirstWebGLRender=r,this.textFitWidth=s,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]}};Po("ImagePosition",hf),Po("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:o}=uf(a),s=new bh({width:n||1,height:o||1});for(let l in e){let t=e[l];if(t.isWebGLImage)continue;let r=i[l].paddedRect;bh.copy(t.data,s,{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,o=e.data.width,u=e.data.height;bh.copy(e.data,s,{x:0,y:0},{x:a,y:n},e.data),bh.copy(e.data,s,{x:0,y:u-1},{x:a,y:n-1},{width:o,height:1}),bh.copy(e.data,s,{x:0,y:0},{x:a,y:n+u},{width:o,height:1}),bh.copy(e.data,s,{x:o-1,y:0},{x:a-1,y:n},{width:1,height:u}),bh.copy(e.data,s,{x:0,y:0},{x:a+o,y:n},{width:1,height:u})}this.image=s,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 hf(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(!sf(n))return void i.update(t.data,void 0,{x:r,y:a});let{width:o,height:s}=t.data;i.context.setCustomLayerDefaults(),n.renderWithWebGL({gl:i.context.gl,texture:i.texture,x:r,y:a,width:o,height:s}),i.context.setDirty()}});var cf=/* @__PURE__ */function(e){return e[e.none=0]="none",e[e.horizontal=1]="horizontal",e[e.vertical=2]="vertical",e[e.horizontalOnly=3]="horizontalOnly",e}(cf||{}),df=/^\p{gc=M}$/u;function pf(e,t,i){let r=new Wp(e.join(""),t,[]),a=0;for(let n of r.graphemes())r.sectionIndex.push(i[a]??0),a+=[...n].length;return r}function ff(e){let t=[],i=0;for(let r of e)t.push(i),i+=r.length;return t}function mf(e,t,i){let r=[...e],a=ff(r),n=function(e){let t=[],i=0;for(;i<e.length;){if(!df.test(e[i])){t.push(i),i++;continue}let r=i;for(;r<e.length&&df.test(e[r]);)r++;let a=e[r];if(void 0!==a&&Lp(a.codePointAt(0))){t.push(r);for(let e=r-1;e>=i;e--)t.push(e);i=r+1}else{for(let e=i;e<r;e++)t.push(e);i=r}}return t}(r);return pf(n.map(e=>r[e]),t,n.map(e=>i[a[e]]??0))}function _f(e,t,i,r,a,n,o,s,l,u,h,c,d,p,f){let m=Wp.fromFeature(e,a,2===c,t),_=m.determineLineBreaks(u,n,t,r,p),g=Bp(m.text)?function(e,t){let i=t.map(t=>e.toCodeUnitIndex(t)),r=ip.isParsed()?ip:null;if(1===e.sections.length)return r?r.processBidirectionalText(e.toString(),i).map(t=>mf(t,e.sections,[...t].map(()=>0))):function(e,t){return Qp(e,t).map(e=>e.text)}(e.toString(),i).map(t=>pf([...t],e.sections,[...t].map(()=>0)));let a=function(e){let t=[],i=0;for(let r of e.graphemes())t.push(...Array(r.length).fill(e.sectionIndex[i])),i++;return t}(e);return r?r.processStyledBidirectionalText(e.text,a,i).map(([t,i])=>mf(t,e.sections,i)):function(e,t,i){return Qp(e,i).map(e=>[e.text,e.sourceIndices.map(e=>t[e]??0)])}(e.text,a,i).map(([t,i])=>{let r=[...t];return pf(r,e.sections,ff(r).map(e=>i[e]??0))})}(m,_):function(e,t){let i=[],r=0;for(let a of t)i.push(e.substring(r,a)),r=a;return r<e.length()&&i.push(e.substring(r,e.length())),i}(m,_),y=[],v={positionedLines:y,text:m.toString(),top:h[1],bottom:h[1],left:h[0],right:h[0],writingMode:c,iconsInText:!1,verticalizable:!1};return function(e,t,i,r,a,n,o,s,l,u,h,c){let d=0,p=0,f=0,m=0,_="right"===s?1:"left"===s?0:.5,g=24/c,y=0;for(let b of a){b.trim();let a=b.getMaxScale(),o={positionedGlyphs:[],lineOffset:0};e.positionedLines[y]=o;let s=o.positionedGlyphs,c=0;if(!b.length()){p+=n,++y;continue}let v=yf(r,b,g),x=2!==l||h?null:Cf(b,t),w=b.graphemes();for(let n=0;n<w.length;n++){let o=b.getSection(n),f=w[n],m=f.codePointAt(0),_=x?x[n]:xf(l,h,m),y="fontStack"in o&&Pp(f)&&!t[o.fontStack]?.default?.[f]?[...f]:[f];for(let l of y){let h,f={glyph:l.codePointAt(0),grapheme:l,imageName:null,x:d,y:p+-17,vertical:_,scale:1,fontStack:"",sectionIndex:b.getSectionIndex(n),metrics:null,rect:null};if("fontStack"in o){if(h=Pf(o,l,_,v,t,i),!h)continue;f.fontStack=o.fontStack}else{if(e.iconsInText=!0,o.scale*=g,h=Af(o,_,a,v,r),!h)continue;c=Math.max(c,h.imageOffset),f.imageName=o.imageName}let{rect:m,metrics:y,baselineOffset:x}=h;f.y+=x,f.scale=o.scale,f.metrics=y,f.rect=m,s.push(f),_?(e.verticalizable=!0,d+=("imageName"in o?y.advance:24)*o.scale+u):d+=y.advance*o.scale+u}}if(0!==s.length){let e=d-u;f=Math.max(e,f),If(s,0,s.length-1,_)}d=0;let T=24*(a-1);o.lineOffset=Math.max(c,T);let S=n*a+c;p+=S,m=Math.max(S,m),++y}let{horizontalAlign:v,verticalAlign:x}=gf(o);(function(e,t,i,r,a,n,o,s,l){let u=(t-i)*a,h=0;h=n===o?-r*l*o+.5*o:-s*r- -17;for(let c of e)for(let e of c.positionedGlyphs)e.x+=u,e.y+=h})(e.positionedLines,_,v,x,f,m,n,p,a.length),e.top+=-x*p,e.bottom=e.top+p,e.left+=-v*f,e.right=e.left+f}(v,t,i,r,g,o,s,l,c,u,d,f),!function(e){for(let t of e)if(0!==t.positionedGlyphs.length)return!1;return!0}(y)&&v}function gf(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 yf(e,t,i){let r=24*t.getMaxScale(),{maxImageWidth:a,maxImageHeight:n}=t.getMaxImageSize(e),o=Math.max(r,n*i);return{verticalLineContentWidth:Math.max(r,a*i),horizontalLineContentHeight:o}}function vf(e){switch(e){case"top":return 0;case"center":return.5;default:return 1}}function xf(e,t,i){return!(1===e||!t&&!ap(i)||t&&(Ap(i)||Rp(i)))}function bf(e){return/\p{Nd}/u.test(String.fromCodePoint(e))}function wf(e){return/\p{Lu}/u.test(String.fromCodePoint(e))}function Tf(e){let t=e.some(bf)&&e.every(e=>bf(e)||Ip(e)),i=e.length<=3&&e.every(e=>wf(e)||bf(e));return t||i}function Sf(e){return(bf(e)||wf(e))&&!Rp(e)}function Df(e,t){return t?xf(2,!0,e):!kp(e)||Sf(e)||Ip(e)}function Ef(e,t,i){for(;t>=0&&t<e.length&&Ap(e[t]);)t+=i;let r=[];for(;t>=0&&t<e.length&&!ap(e[t])&&!Ap(e[t]);)r.push(e[t]),t+=i;return!Tf(r)&&!r.every(Ip)&&r.some(kp)}function Cf(e,t){let i=e.graphemes().slice(),r=i.map(e=>e.codePointAt(0)),a=i.map((i,r)=>{let a=e.getSection(r);return"fontStack"in a&&!!t[a.fontStack]?.vertical?.[i]}),n=r.map(ap),o=t=>!n[t]&&!Ap(r[t])&&!("imageName"in e.getSection(t));for(let s=0;s<r.length;s++){if(!o(s))continue;let e=s;for(;e+1<r.length&&o(e+1);)e++;let t=r.slice(s,e+1),i=Tf(t),l=t.every(Ip),u=l&&(Ef(r,s-1,-1)||Ef(r,e+1,1)),h=!i&&t.some(kp);for(let o=s;o<=e;o++)n[o]=i&&Sf(r[o])||a[o]&&!u&&(l||!h&&!kp(r[o]));s=e}if(a.some((e,t)=>e&&!n[t])){let i=e.text;if(e.verticalizePunctuation(t,n),e.text!==i)return Cf(e,t)}return function(e,t,i){let r=!1;for(let a=0;a<e.length;a++){if(t[a])continue;let n=Op[e[a]];if(n&&(0===a||t[a-1])&&(a===e.length-1||t[a+1])){if(t[a]=!0,i[a])continue;e[a]=n,r=!0}}return r}(i,n,a)&&(e.text=i.join(""),e.cachedGraphemes=i),n}function Pf(e,t,i,r,a,n){let o,s=i&&a[e.fontStack]?.vertical?.[t]?"vertical":"default",l=n[e.fontStack]?.[s]?.[t],u=a[e.fontStack]?.[s]?.[t],h=function(e,t){return e?.rect?e:t?{rect:null,metrics:t.metrics}:null}(l,u);if(null===h)return null;if(i)o=r.verticalLineContentWidth-24*e.scale;else{let t=vf(e.verticalAlign);o=(r.horizontalLineContentHeight-24*e.scale)*t}return{rect:h.rect,metrics:h.metrics,baselineOffset:o}}function Af(e,t,i,r,a){let n=a[e.imageName];if(!n)return null;let o,s=n.paddedRect,l=n.displaySize,u={width:l[0],height:l[1],left:1,top:-3,advance:t?l[1]:l[0]};if(t)o=r.verticalLineContentWidth-l[1]*e.scale;else{let t=vf(e.verticalAlign);o=(r.horizontalLineContentHeight-l[1]*e.scale)*t}return{rect:s,metrics:u,baselineOffset:o,imageOffset:(t?l[0]:l[1])*e.scale-24*i}}function If(e,t,i,r){if(0===r)return;let a=e[i],n=a.metrics.advance*a.scale,o=(e[i].x+n)*r;for(let s=t;s<=i;s++)e[s].x-=o}function Mf(e,t,i){let{horizontalAlign:r,verticalAlign:a}=gf(i),n=t[0],o=t[1],s=n-e.displaySize[0]*r,l=s+e.displaySize[0],u=o-e.displaySize[1]*a;return{image:e,top:u,bottom:u+e.displaySize[1],left:s,right:l}}function Ff(e){let t=e.left,i=e.top,r=e.right-t,a=e.bottom-i,n=e.image.content[2]-e.image.content[0],o=e.image.content[3]-e.image.content[1],s=e.image.textFitWidth??"stretchOrShrink",l=e.image.textFitHeight??"stretchOrShrink",u=n/o;if("proportional"===l){if("stretchOnly"===s&&r/a<u||"proportional"===s){let e=Math.ceil(a*u);t*=e/r,r=e}}else if("proportional"===s&&"stretchOnly"===l&&0!==u&&r/a>u){let e=Math.ceil(r/u);i*=e/a,a=e}return{x1:t,y1:i,x2:t+r,y2:i+a}}function zf(e,t,i,r,a,n){let o,s=e.image;if(s.content){let e=s.content,t=s.pixelRatio||1;o=[e[0]/t,e[1]/t,s.displaySize[0]-e[2]/t,s.displaySize[1]-e[3]/t]}let l,u,h,c,d=t.left*n,p=t.right*n;"width"===i||"both"===i?(c=a[0]+d-r[3],u=a[0]+p+r[1]):(c=a[0]+(d+p-s.displaySize[0])/2,u=c+s.displaySize[0]);let f=t.top*n,m=t.bottom*n;return"height"===i||"both"===i?(l=a[1]+f-r[0],h=a[1]+m+r[2]):(l=a[1]+(f+m-s.displaySize[1])/2,h=l+s.displaySize[1]),{image:s,top:l,right:u,bottom:h,left:c,collisionPadding:o}}function kf(e,t){let{expression:i}=t;if("constant"===i.kind)return{kind:"constant",layoutSize:i.evaluate(new gs(e+1))};if("source"===i.kind)return{kind:"source"};if("composite"===i.kind){let{minZoom:t,maxZoom:r}=function(e,t){let i=0;for(;i<e.length&&e[i]<=t;)i++;i=Math.max(0,i-1);let r=i;for(;r<e.length&&e[r]<t+1;)r++;return r=Math.min(e.length-1,r),{minZoom:e[i],maxZoom:e[r]}}(i.zoomStops,e);return{kind:"composite",minZoom:t,maxZoom:r,interpolationType:i.interpolationType}}{let t=function(e){return e.zoomStops.map(t=>e.evaluate(new gs(t===-1/0?e.zoomStops[1]-1:t)))}(i),r=i.evaluate(new gs(e+1));return{kind:"camera",zoomStops:i.zoomStops,sizes:t,layoutSize:r,interpolationType:i.interpolationType}}}function Rf(e,{uSize:t,uSizeT:i},{lowerSize:r,upperSize:a}){return"source"===e.kind?r/128:"composite"===e.kind?gr.number(r/128,a/128,i):t}function Lf(e,t){let i=0,r=0;return"constant"===e.kind?r=e.layoutSize:"camera"===e.kind?r=function({zoomStops:e,sizes:t,layoutSize:i,interpolationType:r},a){let n=e.length-1;for(;n>0&&e[n]>a;)n--;let o=Math.min(n+1,e.length-1),s=r?Se(mr.interpolationFactor(r,a,e[n],e[o]),0,1):0;return Math.min(gr.number(t[n],t[o],s),i)}(e,t):"composite"===e.kind&&(i=function({interpolationType:e,minZoom:t,maxZoom:i},r){return e?Se(mr.interpolationFactor(e,r,t,i),0,1):0}(e,t)),{uSizeT:i,uSize:r}}var Bf=class e extends d{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)}};function Of(e,t,i,r,a){if(void 0===t.segment||0===i)return!0;let n=t,o=t.segment+1,s=0;for(;s>-i/2;){if(o--,o<0)return!1;s-=e[o].dist(n),n=e[o]}s+=e[o].dist(e[o+1]),o++;let l=[],u=0;for(;s<i/2;){let t=e[o-1],i=e[o],n=e[o+1];if(!n)return!1;let h=t.angleTo(i)-i.angleTo(n);for(h=Math.abs((h+3*Math.PI)%(2*Math.PI)-Math.PI),l.push({distance:s,angleDelta:h}),u+=h;s-l[0].distance>r;)u-=l.shift().angleDelta;if(u>a)return!1;o++,s+=i.dist(n)}return!0}function jf(e){let t=0;for(let i=0;i<e.length-1;i++)t+=e[i].dist(e[i+1]);return t}function Vf(e,t,i){return e?.6*t*i:0}function Nf(e,t){return Math.max(e?e.right-e.left:0,t?t.right-t.left:0)}function Uf(e,t,i,r,a,n){let o=Vf(i,a,n),s=Nf(i,r)*n,l=0,u=jf(e)/2;for(let h=0;h<e.length-1;h++){let i=e[h],r=e[h+1],a=i.dist(r);if(l+a>u){let n=(u-l)/a,c=new Bf(gr.number(i.x,r.x,n),gr.number(i.y,r.y,n),r.angleTo(i),h);return c._round(),!o||Of(e,c,s,o,t)?c:void 0}l+=a}}function $f(e,t,i,r,a,n,o,s,l){let u=Vf(r,n,o),h=Nf(r,a),c=h*o,d=0===e[0].x||e[0].x===l||0===e[0].y||e[0].y===l;return t-c<t/4&&(t=c+t/4),Gf(e,d?t/2*s%t:(h/2+2*n)*o*s%t,t,u,i,c,d,!1,l)}function Gf(e,t,i,r,a,n,o,s,l){let u=n/2,h=jf(e),c=0,d=t-i,p=[];for(let f=0;f<e.length-1;f++){let t=e[f],o=e[f+1],s=t.dist(o),m=o.angleTo(t);for(;d+i<c+s;){d+=i;let _=(d-c)/s,g=gr.number(t.x,o.x,_),y=gr.number(t.y,o.y,_);if(g>=0&&g<l&&y>=0&&y<l&&d-u>=0&&d+u<=h){let t=new Bf(g,y,m,f);t._round(),(!r||Of(e,t,n,r,a))&&p.push(t)}}c+=s}return!s&&!p.length&&!o&&(p=Gf(e,c/2,i,r,a,n,o,!0,l)),p}function Zf(e,t,i,r,a){let n=[];for(let o of e){let e;for(let s=0;s<o.length-1;s++){let l=o[s],u=o[s+1];l.x<t&&u.x<t||(l.x<t?l=new d(t,l.y+(u.y-l.y)*((t-l.x)/(u.x-l.x)))._round():u.x<t&&(u=new d(t,l.y+(u.y-l.y)*((t-l.x)/(u.x-l.x)))._round()),!(l.y<i&&u.y<i)&&(l.y<i?l=new d(l.x+(u.x-l.x)*((i-l.y)/(u.y-l.y)),i)._round():u.y<i&&(u=new d(l.x+(u.x-l.x)*((i-l.y)/(u.y-l.y)),i)._round()),!(l.x>=r&&u.x>=r)&&(l.x>=r?l=new d(r,l.y+(u.y-l.y)*((r-l.x)/(u.x-l.x)))._round():u.x>=r&&(u=new d(r,l.y+(u.y-l.y)*((r-l.x)/(u.x-l.x)))._round()),!(l.y>=a&&u.y>=a)&&(l.y>=a?l=new d(l.x+(u.x-l.x)*((a-l.y)/(u.y-l.y)),a)._round():u.y>=a&&(u=new d(l.x+(u.x-l.x)*((a-l.y)/(u.y-l.y)),a)._round()),(!e||!l.equals(e[e.length-1]))&&(e=[l],n.push(e)),e.push(u)))))}}return n}function qf(e,t,i,r){let a=[],n=e.image,o=n.pixelRatio,s=n.paddedRect.w-2,l=n.paddedRect.h-2,u={x1:e.left,y1:e.top,x2:e.right,y2:e.bottom},h=n.stretchX||[[0,s]],c=n.stretchY||[[0,l]],p=(e,t)=>e+t[1]-t[0],f=h.reduce(p,0),m=c.reduce(p,0),_=s-f,g=l-m,y=0,v=f,x=0,b=m,w=0,T=_,S=0,D=g;if(n.content&&r){let t=n.content,i=t[2]-t[0],r=t[3]-t[1];(n.textFitWidth||n.textFitHeight)&&(u=Ff(e)),y=Wf(h,0,t[0]),x=Wf(c,0,t[1]),v=Wf(h,t[0],t[2]),b=Wf(c,t[1],t[3]),w=t[0]-y,S=t[1]-x,T=i-v,D=r-b}let E=u.x1,C=u.y1,P=u.x2-E,A=u.y2-C,I=(e,r,a,s)=>{let l=Xf(e.stretch-y,v,P,E),u=Yf(e.fixed-w,T,e.stretch,f),h=Xf(r.stretch-x,b,A,C),c=Yf(r.fixed-S,D,r.stretch,m),p=Xf(a.stretch-y,v,P,E),_=Yf(a.fixed-w,T,a.stretch,f),g=Xf(s.stretch-x,b,A,C),I=Yf(s.fixed-S,D,s.stretch,m),M=new d(l,h),F=new d(p,h),z=new d(p,g),k=new d(l,g),R=new d(u/o,c/o),L=new d(_/o,I/o),B=t*Math.PI/180;if(B){let e=Math.sin(B),t=Math.cos(B),i=[t,-e,e,t];M._matMult(i),F._matMult(i),k._matMult(i),z._matMult(i)}let O=e.stretch+e.fixed,j=a.stretch+a.fixed,V=r.stretch+r.fixed,N=s.stretch+s.fixed;return{tl:M,tr:F,bl:k,br:z,tex:{x:n.paddedRect.x+1+O,y:n.paddedRect.y+1+V,w:j-O,h:N-V},writingMode:void 0,glyphOffset:[0,0],sectionIndex:0,pixelOffsetTL:R,pixelOffsetBR:L,minFontScaleX:T/o/P,minFontScaleY:D/o/A,isSDF:i}};if(r&&(n.stretchX||n.stretchY)){let e=Hf(h,_,f),t=Hf(c,g,m);for(let i=0;i<e.length-1;i++){let r=e[i],n=e[i+1];for(let e=0;e<t.length-1;e++){let i=t[e],o=t[e+1];a.push(I(r,i,n,o))}}}else a.push(I({fixed:0,stretch:-1},{fixed:0,stretch:-1},{fixed:0,stretch:s+1},{fixed:0,stretch:l+1}));return a}function Wf(e,t,i){let r=0;for(let a of e)r+=Math.max(t,Math.min(i,a[1]))-Math.max(t,Math.min(i,a[0]));return r}function Hf(e,t,i){let r=[{fixed:-1,stretch:0}];for(let[a,n]of e){let e=r[r.length-1];r.push({fixed:a-e.stretch,stretch:e.stretch}),r.push({fixed:a-e.stretch,stretch:e.stretch+(n-a)})}return r.push({fixed:t+1,stretch:i}),r}function Xf(e,t,i,r){return e/t*i+r}function Yf(e,t,i,r){return e-t*i/r}function Kf(e,t,i,r,a,n,o,s){let l=r.layout.get("text-rotate").evaluate(n,{})*Math.PI/180,u=[];for(let h of t.positionedLines)for(let e of h.positionedGlyphs){if(!e.rect)continue;let r=e.rect||{},n=4,c=!0,p=1,f=0,m=(a||s)&&e.vertical,_=e.metrics.advance*e.scale/2;if(s&&t.verticalizable){let t=24*(e.scale-1),i=(24-e.metrics.width*e.scale)/2;f=h.lineOffset/2-(e.imageName?-i:t)}if(e.imageName){let t=o[e.imageName];c=t.sdf,p=t.pixelRatio,n=1/p}let g=a?[e.x+_,e.y]:[0,0],y=a?[0,0]:[e.x+_+i[0],e.y+i[1]-f],v=[0,0];m&&(v=y,y=[0,0]);let x=e.metrics.isDoubleResolution?2:1,b=(e.metrics.left-n)*e.scale-_+y[0],w=(-e.metrics.top-n)*e.scale+y[1],T=b+r.w/x*e.scale/p,S=w+r.h/x*e.scale/p,D=new d(b,w),E=new d(T,w),C=new d(b,S),P=new d(T,S);if(m){let t=new d(-_,_- -17),i=-Math.PI/2,r=12-_,a=new d(22-r,-(e.imageName?r:0)),n=new d(...v);D._rotateAround(i,t)._add(a)._add(n),E._rotateAround(i,t)._add(a)._add(n),C._rotateAround(i,t)._add(a)._add(n),P._rotateAround(i,t)._add(a)._add(n)}if(l){let e=Math.sin(l),t=Math.cos(l),i=[t,-e,e,t];D._matMult(i),E._matMult(i),C._matMult(i),P._matMult(i)}let A=new d(0,0),I=new d(0,0);u.push({tl:D,tr:E,bl:C,br:P,tex:r,writingMode:t.writingMode,glyphOffset:g,sectionIndex:e.sectionIndex,isSDF:c,pixelOffsetTL:A,pixelOffsetBR:I,minFontScaleX:0,minFontScaleY:0})}return u}Po("Anchor",Bf);var Jf=class{constructor(e,t,i,r,a,n,o,s,l,u){if(this.boxStartIndex=e.length,l){let e=n.top,t=n.bottom,i=n.collisionPadding;i&&(e-=i[1],t+=i[3]);let r=t-e;r>0&&(r=Math.max(10,r),this.circleDiameter=r)}else{let l=n.image?.content&&(n.image.textFitWidth||n.image.textFitHeight)?Ff(n):{x1:n.left,y1:n.top,x2:n.right,y2:n.bottom};l.y1=l.y1*o-s[0],l.y2=l.y2*o+s[2],l.x1=l.x1*o-s[3],l.x2=l.x2*o+s[1];let h=n.collisionPadding;if(h&&(l.x1-=h[0]*o,l.y1-=h[1]*o,l.x2+=h[2]*o,l.y2+=h[3]*o),u){let e=new d(l.x1,l.y1),t=new d(l.x2,l.y1),i=new d(l.x1,l.y2),r=new d(l.x2,l.y2),a=u*Math.PI/180;e._rotate(a),t._rotate(a),i._rotate(a),r._rotate(a),l.x1=Math.min(e.x,t.x,i.x,r.x),l.x2=Math.max(e.x,t.x,i.x,r.x),l.y1=Math.min(e.y,t.y,i.y,r.y),l.y2=Math.max(e.y,t.y,i.y,r.y)}e.emplaceBack(t.x,t.y,l.x1,l.y1,l.x2,l.y2,i,r,a)}this.boxEndIndex=e.length}},Qf=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 em(e,t=1){let i=ku.fromPoints(e[0]),r=Math.min(i.width(),i.height()),a=r/2,n=new Qf([],tm),{minX:o,minY:s,maxX:l,maxY:u}=i;if(0===r)return new d(o,s);for(let d=o;d<l;d+=r)for(let t=s;t<u;t+=r)n.push(new im(d+a,t+a,a,e));let h=function(e){let t=0,i=0,r=0,a=e[0];for(let n=0,o=a.length,s=o-1;n<o;s=n++){let e=a[n],o=a[s],l=e.x*o.y-o.x*e.y;i+=(e.x+o.x)*l,r+=(e.y+o.y)*l,t+=3*l}return new im(i/t,r/t,0,e)}(e),c=h;for(;n.length;){let i=n.pop();(i.d>c.d||!c.d)&&(c=i),!(i.max-c.d<=t)&&(a=i.h/2,n.push(new im(i.p.x-a,i.p.y-a,a,e)),n.push(new im(i.p.x+a,i.p.y-a,a,e)),n.push(new im(i.p.x-a,i.p.y+a,a,e)),n.push(new im(i.p.x+a,i.p.y+a,a,e)))}return h.d>0&&c.d-h.d<=t?h.p:c.p}function tm(e,t){return t.max-e.max}var im=class{constructor(e,t,i,r){this.p=new d(e,t),this.h=i,this.d=function(e,t){let i=!1,r=1/0;for(let a of t)for(let t=0,n=a.length,o=n-1;t<n;o=t++){let n=a[t],s=a[o];n.y>e.y!=s.y>e.y&&e.x<(s.x-n.x)*(e.y-n.y)/(s.y-n.y)+n.x&&(i=!i),r=Math.min(r,Yu(e,n,s))}return(i?1:-1)*Math.sqrt(r)}(this.p,r),this.max=this.d+this.h*Math.SQRT2}},rm=/* @__PURE__ */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}({}),am=1/0;function nm(e,t){return t[1]===am?function(e,t){let i=0,r=0;t<0&&(t=0);let a=t/Math.SQRT2;switch(e){case"top-right":case"top-left":r=a-7;break;case"bottom-right":case"bottom-left":r=7-a;break;case"bottom":r=7-t;break;case"top":r=t-7}switch(e){case"top-right":case"bottom-right":i=-a;break;case"top-left":case"bottom-left":i=a;break;case"left":i=t;break;case"right":i=-t}return[i,r]}(e,t[0]):function(e,t,i){let r=0,a=0;switch(t=Math.abs(t),i=Math.abs(i),e){case"top-right":case"top-left":case"top":a=i-7;break;case"bottom-right":case"bottom-left":case"bottom":a=7-i}switch(e){case"top-right":case"bottom-right":case"right":r=-t;break;case"top-left":case"bottom-left":case"left":r=t}return[r,a]}(e,t[0],t[1])}function om(e,t,i){let r=e.layout,a=r.get("text-variable-anchor-offset")?.evaluate(t,{},i);if(a){let e=a.values,t=[];for(let i=0;i<e.length;i+=2){let r=t[i]=e[i],a=e[i+1].map(e=>24*e);r.startsWith("top")?a[1]-=7:r.startsWith("bottom")&&(a[1]+=7),t[i+1]=a}return new ir(t)}let n=r.get("text-variable-anchor");if(n){let a;a=void 0===e._unevaluatedLayout.getValue("text-radial-offset")?r.get("text-offset").evaluate(t,{},i).map(e=>24*e):[24*r.get("text-radial-offset").evaluate(t,{},i),am];let o=[];for(let e of n)o.push(e,nm(e,a));return new ir(o)}return null}function sm(e){switch(e){case"right":case"top-right":case"bottom-right":return"right";case"left":case"top-left":case"bottom-left":return"left"}return"center"}function lm(e,t,i,r,a,n,o,s,l,u,h,c,d){let p=n.textMaxSize.evaluate(t,{});void 0===p&&(p=o);let f,m=e.layers[0].layout,_=m.get("icon-offset").evaluate(t,{},h),g=hm(i.horizontal),y=o/24,v=e.tilePixelRatio*y,x=e.tilePixelRatio*p/24,b=e.tilePixelRatio*s,w=e.tilePixelRatio*m.get("symbol-spacing"),T=m.get("text-padding")*e.tilePixelRatio,S=function(e,t,i,r=1){let a=e.get("icon-padding").evaluate(t,{},i)?.values;return[a[0]*r,a[1]*r,a[2]*r,a[3]*r]}(m,t,h,e.tilePixelRatio),D=m.get("text-max-angle")/180*Math.PI,E="viewport"!==m.get("text-rotation-alignment")&&"point"!==m.get("symbol-placement"),C="map"===m.get("icon-rotation-alignment").constantOr("viewport")&&"point"!==m.get("symbol-placement"),P=m.get("symbol-placement"),A=w/2,I=m.get("icon-text-fit");r&&"none"!==I&&(e.allowVerticalPlacement&&i.vertical&&(f=zf(r,i.vertical,I,m.get("icon-text-fit-padding"),_,y)),g&&(r=zf(r,g,I,m.get("icon-text-fit-padding"),_,y)));let M=h?c.line.getGranularityForZoomLevel(h.z):1,F=(s,c)=>{Ou(c)||function(e,t,i,r,a,n,o,s,l,u,h,c,d,p,f,m,_,g,y,v,x,b,w,T,S,D){let E=e.addToLineVertexArray(t,i),C=s.layout.get("symbol-height-offset").evaluate(x,{},T);C>e.maxHeightOffset&&(e.maxHeightOffset=C);let P,A,I,M,F=0,z=0,k=0,R=0,L=-1,B=-1,O={},j=(0,iu.default)("");if(e.allowVerticalPlacement&&r.vertical){let e=s.layout.get("text-rotate").evaluate(x,{},T)+90,i=r.vertical;I=new Jf(l,t,u,h,c,i,d,p,f,e),o&&(M=new Jf(l,t,u,h,c,o,_,g,f,e))}if(a){let i=s.layout.get("icon-rotate").evaluate(x,{}),r="none"!==s.layout.get("icon-text-fit"),n=qf(a,i,w,r),d=o?qf(o,i,w,r):void 0;A=new Jf(l,t,u,h,c,a,_,g,!1,i),F=4*n.length;let p=e.iconSizeData,f=null;"source"===p.kind?(f=[128*s.layout.get("icon-size").evaluate(x,{})],f[0]>32640&&Oe(`${e.layerIds[0]}: Value for "icon-size" is >= 255. Reduce your "icon-size".`)):"composite"===p.kind&&(f=[128*b.compositeIconSizes[0].evaluate(x,{},T),128*b.compositeIconSizes[1].evaluate(x,{},T)],(f[0]>32640||f[1]>32640)&&Oe(`${e.layerIds[0]}: Value for "icon-size" is >= 255. Reduce your "icon-size".`)),e.addSymbols(e.icon,n,f,v,y,x,0,t,E.lineStartIndex,E.lineLength,-1,T,C),L=e.icon.placedSymbolArray.length-1,d&&(z=4*d.length,e.addSymbols(e.icon,d,f,v,y,x,2,t,E.lineStartIndex,E.lineLength,-1,T,C),B=e.icon.placedSymbolArray.length-1)}let V=Object.keys(r.horizontal);for(let te of V){let i=r.horizontal[te];P||=(j=(0,iu.default)(i.text),new Jf(l,t,u,h,c,i,d,p,f,s.layout.get("text-rotate").evaluate(x,{},T)));let a=1===i.positionedLines.length;if(k+=um(e,t,i,n,s,f,x,m,C,E,r.vertical?1:3,a?V:[te],O,L,b,T),a)break}r.vertical&&(R+=um(e,t,r.vertical,n,s,f,x,m,C,E,2,["vertical"],O,B,b,T));let N=P?P.boxStartIndex:e.collisionBoxArray.length,U=P?P.boxEndIndex:e.collisionBoxArray.length,$=I?I.boxStartIndex:e.collisionBoxArray.length,G=I?I.boxEndIndex:e.collisionBoxArray.length,Z=A?A.boxStartIndex:e.collisionBoxArray.length,q=A?A.boxEndIndex:e.collisionBoxArray.length,W=M?M.boxStartIndex:e.collisionBoxArray.length,H=M?M.boxEndIndex:e.collisionBoxArray.length,X=-1,Y=(e,t)=>e?.circleDiameter?Math.max(e.circleDiameter,t):t;X=Y(P,X),X=Y(I,X),X=Y(A,X),X=Y(M,X);let K=+(X>-1);K&&(X*=S/24),e.glyphOffsetArray.length>=e.maxGlyphs&&Oe("Too many glyphs being rendered in a tile. See https://github.com/mapbox/mapbox-gl-js/issues/2907"),void 0!==x.sortKey&&e.addToSortKeyRanges(e.symbolInstances.length,x.sortKey);let J=om(s,x,T),[Q,ee]=function(e,t){let i=e.length,r=t?.values;if(r?.length>0)for(let a=0;a<r.length;a+=2){let t=rm[r[a]],i=r[a+1];e.emplaceBack(t,i[0],i[1])}return[i,e.length]}(e.textAnchorOffsets,J);D&&(j=function(e,t){return null==t.id||t.properties?.cluster?e:(0,iu.default)(String(t.id),e)}(j,x)),e.symbolInstances.emplaceBack(t.x,t.y,O.right>=0?O.right:-1,O.center>=0?O.center:-1,O.left>=0?O.left:-1,O.vertical||-1,L,B,j,N,U,$,G,Z,q,W,H,u,k,R,F,z,K,0,d,X,Q,ee,C)}(e,c,s,i,r,a,f,e.layers[0],e.collisionBoxArray,t.index,t.sourceLayerIndex,e.index,v,[T,T,T,T],E,l,b,S,C,_,t,n,u,h,o,d)};if("line"===P)for(let z of Zf(t.geometry,0,0,re,re)){let t=Mc(z,M),a=$f(t,w,D,i.vertical||g,r,24,x,e.overscaling,re);for(let i of a)(!g||!cm(e,g.text,A,i))&&F(t,i)}else if("line-center"===P){for(let z of t.geometry)if(z.length>1){let e=Mc(z,M),t=Uf(e,D,i.vertical||g,r,24,x);t&&F(e,t)}}else if("Polygon"===t.type)for(let z of wr(t.geometry,0)){let e=em(z,16);F(Mc(z[0],M,!0),new Bf(e.x,e.y,0))}else if("LineString"===t.type)for(let z of t.geometry){let e=Mc(z,M);F(e,new Bf(e[0].x,e[0].y,0))}else if("Point"===t.type)for(let z of t.geometry)for(let e of z)F([e],new Bf(e.x,e.y,0))}function um(e,t,i,r,a,n,o,s,l,u,h,c,d,p,f,m){let _=Kf(0,i,s,a,n,o,r,e.allowVerticalPlacement),g=e.textSizeData,y=null;"source"===g.kind?(y=[128*a.layout.get("text-size").evaluate(o,{})],y[0]>32640&&Oe(`${e.layerIds[0]}: Value for "text-size" is >= 255. Reduce your "text-size".`)):"composite"===g.kind&&(y=[128*f.compositeTextSizes[0].evaluate(o,{},m),128*f.compositeTextSizes[1].evaluate(o,{},m)],(y[0]>32640||y[1]>32640)&&Oe(`${e.layerIds[0]}: Value for "text-size" is >= 255. Reduce your "text-size".`)),e.addSymbols(e.text,_,y,s,n,o,h,t,u.lineStartIndex,u.lineLength,p,m,l);for(let v of c)d[v]=e.text.placedSymbolArray.length-1;return 4*_.length}function hm(e){for(let t in e)return e[t];return null}function cm(e,t,i,r){let a=e.compareText;if(t in a){let e=a[t];for(let t=e.length-1;t>=0;t--)if(r.dist(e[t])<i)return!0}else a[t]=[];return a[t].push(r),!1}function dm(e,t,i){let r="never",a=e.get(t);return a?r=a:e.get(i)&&(r="always"),r}var pm=[{name:"a_fade_opacity",components:1,type:"Uint8",offset:0}];function fm(e,t,i,r,a,n,o,s,l,u,h,c,d,p){let f=s?Math.min(32640,Math.round(s[0])):0,m=s?Math.min(32640,Math.round(s[1])):0;e.emplaceBack(t,i,Math.round(32*r),Math.round(32*a),n,o,+!!l+(f<<1),m,16*u,16*h,256*c,256*d,p)}function mm(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 _m(e){for(let t of e.sections)if(Bp(t.text))return!0;return!1}var gm=class{constructor(e){this.layoutVertexArray=new Ol,this.indexArray=new Zl,this.programConfigurations=e,this.segments=new Yl,this.dynamicLayoutVertexArray=new jl,this.opacityVertexArray=new Vl,this.hasVisibleVertices=!1,this.placedSymbolArray=new vl}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,Yd.members),this.indexBuffer=e.createIndexBuffer(this.indexArray,t),this.dynamicLayoutVertexBuffer=e.createVertexBuffer(this.dynamicLayoutVertexArray,Kd.members,!0),this.opacityVertexBuffer=e.createVertexBuffer(this.opacityVertexArray,pm,!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())}};Po("SymbolBuffers",gm);var ym=class{constructor(e,t,i){this.layoutVertexArray=new e,this.layoutAttributes=t,this.indexArray=new i,this.segments=new Yl,this.collisionVertexArray=new $l}upload(e){this.layoutVertexBuffer=e.createVertexBuffer(this.layoutVertexArray,this.layoutAttributes),this.indexBuffer=e.createIndexBuffer(this.indexArray),this.collisionVertexBuffer=e.createVertexBuffer(this.collisionVertexArray,Jd.members,!0)}destroy(){this.layoutVertexBuffer&&(this.layoutVertexBuffer.destroy(),this.indexBuffer.destroy(),this.segments.destroy(),this.collisionVertexBuffer.destroy())}};Po("CollisionBuffers",ym);var vm,xm=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=!0,this.hasRTLText=!1,this.maxHeightOffset=0,this.sortKeyRanges=[],this.collisionCircleArray=[],this.maxGlyphs=65535;let t=this.layers[0]._unevaluatedLayout._values;this.textSizeData=kf(this.zoom,t["text-size"]),this.iconSizeData=kf(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"!==dm(i,"text-overlap","text-allow-overlap")||"never"!==dm(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=>cf[e])),this.stateDependentLayerIds=this.layers.filter(e=>e.isStateDependent()).map(e=>e.id),this.sourceID=e.sourceID}createArrays(){this.text=new gm(new Cu(this.layers,this.zoom,e=>e.startsWith("text"))),this.icon=new gm(new Cu(this.layers,this.zoom,e=>e.startsWith("icon"))),this.glyphOffsetArray=new wl,this.lineVertexArray=new Tl,this.symbolInstances=new bl,this.textAnchorOffsets=new Dl}calculateGlyphDependencies(e,t,i,r){let a=Wp.fromFeature(e,i,!1),n=a.graphemes();for(let o=0;o<n.length;o++){let e=a.getSection(o);if("imageName"in e)continue;t[e.fontStack]||={default:{},vertical:{}};let i=t[e.fontStack],s=n[o],l=r&&Df(s.codePointAt(0),this.allowVerticalPlacement);Pp(s)&&(i.default[s]=!0),l&&(i.vertical[s]=!0);for(let t of s){if(i.default[t]=!0,!r)continue;l&&Pp(s)&&(i.vertical[t]=!0);let e=Op[t];e&&(i.default[e]=!0)}}}populate(e,t,i){let r=this.layers[0],a=r.layout,n=a.get("text-font"),o=a.get("text-field"),s=a.get("icon-image"),l=("constant"!==o.value.kind||o.value.value instanceof Yi&&!o.value.value.isEmpty()||o.value.value.toString().length>0)&&("constant"!==n.value.kind||n.value.value.length>0),u="constant"!==s.value.kind||!!s.value.value||Object.keys(s.parameters).length>0,h=a.get("symbol-sort-key"),c="point"===a.get("symbol-placement");if(this.features=[],!l&&!u)return;let d=t.iconDependencies,p=t.glyphDependencies,f=t.availableImages,m=new gs(this.zoom),_=a.get("text-keep-upright");for(let{feature:g,id:y,index:v,sourceLayerIndex:x}of e){let e,t,o=r._featureFilter.needGeometry,s=zu(g,o);if(!r._featureFilter.filter(m,s,i)||(o||(s.geometry=Fu(g)),c&&1===g.type&&bm(s.geometry)))continue;if(l){let t=r.getValueAndResolveTokens("text-field",s,i,f),a=Yi.factory(t);this.hasRTLText||=_m(a),e=yp(a,r,s)}if(u){let e=r.getValueAndResolveTokens("icon-image",s,i,f);t=e instanceof rr?e:rr.fromString(e)}if(!e&&!t)continue;let b=this.sortFeaturesByKey?h.evaluate(s,{},i):void 0,w={id:y,text:e,icon:t,index:v,sourceLayerIndex:x,geometry:s.geometry,properties:g.properties,type:Gc.types[g.type],sortKey:b};if(this.features.push(w),t&&(d[t.name]=!0),e){let t=n.evaluate(s,{},i).join(","),r="viewport"!==a.get("text-rotation-alignment")&&"point"!==a.get("symbol-placement");this.allowVerticalPlacement=this.writingModes?.includes(2);let o=(r&&_||this.allowVerticalPlacement)&&Mp(e.toString());this.calculateGlyphDependencies(e,p,t,o);for(let i of e.sections)i.image&&(d[i.image.name]=!0)}}"line"===a.get("symbol-placement")&&(this.features=function(e){let t={},i={},r=[];for(let n of e){let e=n.text?n.text.toString():null,a={points:n.geometry[0],next:null},o={feature:n,first:a,last:a};if(!e){r.push(o);continue}let s=vp(e,o),l=vp(e,o,!0);if(s in i&&l in t&&i[s]!==t[l]){let a=wp(r,t,s,l,o),n=bp(r,i,s,l,r[a]);delete t[s],delete i[l],i[vp(e,r[n],!0)]=n,r[a].feature.geometry=null}else if(s in i)bp(r,i,s,l,o);else if(l in t)wp(r,t,s,l,o);else{let e=r.push(o)-1;t[s]=e,i[l]=e}}let a=[];for(let n of r){let e=n.feature;e.geometry&&(n.first.next&&(e.geometry[0]=xp(n)),a.push(e))}return a}(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}))}addFeatures({options:e,canonical:t,glyphMap:i,glyphPositions:r,iconMap:a,iconPositions:n,showCollisionBoxes:o}){!function(e){e.bucket.createArrays();let t=512*e.bucket.overscaling;e.bucket.tilePixelRatio=re/t,e.bucket.compareText={},e.bucket.iconsNeedLinear=!1;let i=e.bucket.layers[0],r=i.layout,a=i._unevaluatedLayout._values,n={layoutIconSize:a["icon-size"].possiblyEvaluate(new gs(e.bucket.zoom+1),e.canonical),layoutTextSize:a["text-size"].possiblyEvaluate(new gs(e.bucket.zoom+1),e.canonical),textMaxSize:a["text-size"].possiblyEvaluate(new gs(18))};if("composite"===e.bucket.textSizeData.kind){let{minZoom:t,maxZoom:i}=e.bucket.textSizeData;n.compositeTextSizes=[a["text-size"].possiblyEvaluate(new gs(t),e.canonical),a["text-size"].possiblyEvaluate(new gs(i),e.canonical)]}if("composite"===e.bucket.iconSizeData.kind){let{minZoom:t,maxZoom:i}=e.bucket.iconSizeData;n.compositeIconSizes=[a["icon-size"].possiblyEvaluate(new gs(t),e.canonical),a["icon-size"].possiblyEvaluate(new gs(i),e.canonical)]}let o=24*r.get("text-line-height"),s="viewport"!==r.get("text-rotation-alignment")&&"point"!==r.get("symbol-placement"),l=r.get("text-keep-upright"),u=r.get("text-size");for(let h of e.bucket.features){let t=r.get("text-font").evaluate(h,{},e.canonical).join(","),a=u.evaluate(h,{},e.canonical),c=n.layoutTextSize.evaluate(h,{},e.canonical),d=n.layoutIconSize.evaluate(h,{},e.canonical),p={horizontal:{},vertical:void 0},f=h.text,m=[0,0];if(f){let n=f.toString(),u=24*r.get("text-letter-spacing").evaluate(h,{},e.canonical),d=Fp(n)?u:0,_=r.get("text-anchor").evaluate(h,{},e.canonical),g=om(i,h,e.canonical);if(!g){let t=r.get("text-radial-offset").evaluate(h,{},e.canonical);m=t?nm(_,[24*t,am]):r.get("text-offset").evaluate(h,{},e.canonical).map(e=>24*e)}let y=s?"center":r.get("text-justify").evaluate(h,{},e.canonical),v="point"===r.get("symbol-placement")?24*r.get("text-max-width").evaluate(h,{},e.canonical):1/0,x=()=>{e.bucket.allowVerticalPlacement&&Mp(n)&&(p.vertical=_f(f,e.glyphMap,e.glyphPositions,e.imagePositions,t,v,o,_,"left",d,m,2,!0,c,a))};if(!s&&g){let i=/* @__PURE__ */new Set;if("auto"===y)for(let e=0;e<g.values.length;e+=2)i.add(sm(g.values[e]));else i.add(y);let r=!1;for(let n of i)if(!p.horizontal[n])if(r)p.horizontal[n]=p.horizontal[0];else{let i=_f(f,e.glyphMap,e.glyphPositions,e.imagePositions,t,v,o,"center",n,d,m,1,!1,c,a);i&&(p.horizontal[n]=i,r=1===i.positionedLines.length)}x()}else{"auto"===y&&(y=sm(_));let i=_f(f,e.glyphMap,e.glyphPositions,e.imagePositions,t,v,o,_,y,d,m,1,!1,c,a);i&&(p.horizontal[y]=i),x(),Mp(n)&&s&&l&&(p.vertical=_f(f,e.glyphMap,e.glyphPositions,e.imagePositions,t,v,o,_,y,d,m,2,!1,c,a))}}let _,g=!1;if(h.icon?.name){let t=e.imageMap[h.icon.name];t&&(_=Mf(e.imagePositions[h.icon.name],r.get("icon-offset").evaluate(h,{},e.canonical),r.get("icon-anchor").evaluate(h,{},e.canonical)),g=!!t.sdf,void 0===e.bucket.sdfIcons?e.bucket.sdfIcons=g:e.bucket.sdfIcons!==g&&Oe("Style sheet warning: Cannot mix SDF and non-SDF icons in one buffer"),t.pixelRatio===e.bucket.pixelRatio?0!==r.get("icon-rotate").constantOr(1)&&(e.bucket.iconsNeedLinear=!0):e.bucket.iconsNeedLinear=!0)}let y=hm(p.horizontal)||p.vertical;e.bucket.iconsInText||=!!y&&y.iconsInText,(y||_)&&lm(e.bucket,h,p,_,e.imageMap,n,c,d,m,g,e.canonical,e.subdivisionGranularity,e.hasPromoteId)}e.showCollisionBoxes&&e.bucket.generateCollisionDebugBuffers()}({bucket:this,glyphMap:i,glyphPositions:r,imageMap:a,imagePositions:n,showCollisionBoxes:o,canonical:t,subdivisionGranularity:e.subdivisionGranularity,hasPromoteId:null!=e.featureIndex.promoteId})}isEmpty(){return 0===this.symbolInstances.length}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,o,s,l,u,h,c,d){let p=e.indexArray,f=e.layoutVertexArray,m=e.segments.prepareSegment(4*t.length,f,p,this.canOverlap?n.sortKey:void 0),_=this.glyphOffsetArray.length,g=m.vertexLength,y=this.allowVerticalPlacement&&2===o?Math.PI/2:0,v=n.text&&n.text.sections;for(let x=0;x<t.length;x++){let{tl:r,tr:a,bl:o,br:l,tex:u,pixelOffsetTL:h,pixelOffsetBR:_,minFontScaleX:g,minFontScaleY:b,glyphOffset:w,isSDF:T,sectionIndex:S}=t[x],D=m.vertexLength,E=w[1];fm(f,s.x,s.y,r.x,E+r.y,u.x,u.y,i,T,h.x,h.y,g,b,d),fm(f,s.x,s.y,a.x,E+a.y,u.x+u.w,u.y,i,T,_.x,h.y,g,b,d),fm(f,s.x,s.y,o.x,E+o.y,u.x,u.y+u.h,i,T,h.x,_.y,g,b,d),fm(f,s.x,s.y,l.x,E+l.y,u.x+u.w,u.y+u.h,i,T,_.x,_.y,g,b,d),mm(e.dynamicLayoutVertexArray,s,y),p.emplaceBack(D,D+2,D+1),p.emplaceBack(D+1,D+2,D+3),m.vertexLength+=4,m.primitiveLength+=2,this.glyphOffsetArray.emplaceBack(w[0]),(x===t.length-1||S!==t[x+1].sectionIndex)&&e.programConfigurations.populatePaintArrays(f.length,n,n.index,{imagePositions:{},canonical:c,formattedSection:v?.[S]})}e.placedSymbolArray.emplaceBack(s.x,s.y,_,this.glyphOffsetArray.length-_,g,l,u,s.segment,i?i[0]:0,i?i[1]:0,r[0],r[1],o,0,!1,0,h,d)}_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,o){let s=a.segments.prepareSegment(4,a.layoutVertexArray,a.indexArray),l=s.vertexLength,u=a.layoutVertexArray,h=a.collisionVertexArray,c=o.anchorX,p=o.anchorY;this._addCollisionDebugVertex(u,h,n,c,p,new d(e,t)),this._addCollisionDebugVertex(u,h,n,c,p,new d(i,t)),this._addCollisionDebugVertex(u,h,n,c,p,new d(i,r)),this._addCollisionDebugVertex(u,h,n,c,p,new d(e,r)),s.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),s.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,o=e.x2,s=e.y2;this.addCollisionDebugVertices(t,n,o,s,r?this.textCollisionBox:this.iconCollisionBox,e.anchorPoint,i)}}generateCollisionDebugBuffers(){this.hasDebugData()&&this.destroyDebugData(),this.textCollisionBox=new ym(Nl,Qd.members,ql),this.iconCollisionBox=new ym(Nl,Qd.members,ql);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,o,s,l){let u={};for(let h=t;h<i;h++){let t=e.get(h);u.textBox={x1:t.x1,y1:t.y1,x2:t.x2,y2:t.y2,anchorPointX:t.anchorPointX,anchorPointY:t.anchorPointY},u.textFeatureIndex=t.featureIndex;break}for(let h=r;h<a;h++){let t=e.get(h);u.verticalTextBox={x1:t.x1,y1:t.y1,x2:t.x2,y2:t.y2,anchorPointX:t.anchorPointX,anchorPointY:t.anchorPointY},u.verticalTextFeatureIndex=t.featureIndex;break}for(let h=n;h<o;h++){let t=e.get(h);u.iconBox={x1:t.x1,y1:t.y1,x2:t.x2,y2:t.y2,anchorPointX:t.anchorPointX,anchorPointY:t.anchorPointY},u.iconFeatureIndex=t.featureIndex;break}for(let h=s;h<l;h++){let t=e.get(h);u.verticalIconBox={x1:t.x1,y1:t.y1,x2:t.x2,y2:t.y2,anchorPointX:t.anchorPointX,anchorPointY:t.anchorPointY},u.verticalIconFeatureIndex=t.featureIndex;break}return u}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 o=0;o<this.symbolInstances.length;++o){n.push(o);let e=this.symbolInstances.get(o);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)}}};function bm(e){return e.every(e=>e.every(Ou))}Po("SymbolBucket",xm,{omit:["layers","collisionBoxArray","features","compareText"]});var wm,Tm={get paint(){return wm||=new zs({"icon-opacity":new As(Nt.paint_symbol["icon-opacity"],"icon-opacity"),"icon-color":new As(Nt.paint_symbol["icon-color"],"icon-color"),"icon-halo-color":new As(Nt.paint_symbol["icon-halo-color"],"icon-halo-color"),"icon-halo-width":new As(Nt.paint_symbol["icon-halo-width"],"icon-halo-width"),"icon-halo-blur":new As(Nt.paint_symbol["icon-halo-blur"],"icon-halo-blur"),"icon-translate":new Ps(Nt.paint_symbol["icon-translate"],"icon-translate"),"icon-translate-anchor":new Ps(Nt.paint_symbol["icon-translate-anchor"],"icon-translate-anchor"),"text-opacity":new As(Nt.paint_symbol["text-opacity"],"text-opacity"),"text-color":new As(Nt.paint_symbol["text-color"],"text-color",{runtimeType:oi,getOverride:e=>e.textColor,hasOverride:e=>!!e.textColor}),"text-halo-color":new As(Nt.paint_symbol["text-halo-color"],"text-halo-color"),"text-halo-width":new As(Nt.paint_symbol["text-halo-width"],"text-halo-width"),"text-halo-blur":new As(Nt.paint_symbol["text-halo-blur"],"text-halo-blur"),"text-translate":new Ps(Nt.paint_symbol["text-translate"],"text-translate"),"text-translate-anchor":new Ps(Nt.paint_symbol["text-translate-anchor"],"text-translate-anchor")})},get layout(){return vm||=new zs({"symbol-placement":new Ps(Nt.layout_symbol["symbol-placement"],"symbol-placement"),"symbol-spacing":new Ps(Nt.layout_symbol["symbol-spacing"],"symbol-spacing"),"symbol-avoid-edges":new Ps(Nt.layout_symbol["symbol-avoid-edges"],"symbol-avoid-edges"),"symbol-sort-key":new As(Nt.layout_symbol["symbol-sort-key"],"symbol-sort-key"),"symbol-z-order":new Ps(Nt.layout_symbol["symbol-z-order"],"symbol-z-order"),"icon-allow-overlap":new Ps(Nt.layout_symbol["icon-allow-overlap"],"icon-allow-overlap"),"icon-overlap":new Ps(Nt.layout_symbol["icon-overlap"],"icon-overlap"),"icon-ignore-placement":new Ps(Nt.layout_symbol["icon-ignore-placement"],"icon-ignore-placement"),"icon-optional":new Ps(Nt.layout_symbol["icon-optional"],"icon-optional"),"icon-rotation-alignment":new As(Nt.layout_symbol["icon-rotation-alignment"],"icon-rotation-alignment"),"icon-size":new As(Nt.layout_symbol["icon-size"],"icon-size"),"icon-text-fit":new Ps(Nt.layout_symbol["icon-text-fit"],"icon-text-fit"),"icon-text-fit-padding":new Ps(Nt.layout_symbol["icon-text-fit-padding"],"icon-text-fit-padding"),"icon-image":new As(Nt.layout_symbol["icon-image"],"icon-image"),"icon-rotate":new As(Nt.layout_symbol["icon-rotate"],"icon-rotate"),"icon-padding":new As(Nt.layout_symbol["icon-padding"],"icon-padding"),"icon-keep-upright":new Ps(Nt.layout_symbol["icon-keep-upright"],"icon-keep-upright"),"icon-offset":new As(Nt.layout_symbol["icon-offset"],"icon-offset"),"icon-anchor":new As(Nt.layout_symbol["icon-anchor"],"icon-anchor"),"icon-pitch-alignment":new Ps(Nt.layout_symbol["icon-pitch-alignment"],"icon-pitch-alignment"),"text-pitch-alignment":new Ps(Nt.layout_symbol["text-pitch-alignment"],"text-pitch-alignment"),"text-rotation-alignment":new Ps(Nt.layout_symbol["text-rotation-alignment"],"text-rotation-alignment"),"text-field":new As(Nt.layout_symbol["text-field"],"text-field"),"text-font":new As(Nt.layout_symbol["text-font"],"text-font"),"text-size":new As(Nt.layout_symbol["text-size"],"text-size"),"text-max-width":new As(Nt.layout_symbol["text-max-width"],"text-max-width"),"text-line-height":new Ps(Nt.layout_symbol["text-line-height"],"text-line-height"),"text-letter-spacing":new As(Nt.layout_symbol["text-letter-spacing"],"text-letter-spacing"),"text-justify":new As(Nt.layout_symbol["text-justify"],"text-justify"),"text-radial-offset":new As(Nt.layout_symbol["text-radial-offset"],"text-radial-offset"),"text-variable-anchor":new Ps(Nt.layout_symbol["text-variable-anchor"],"text-variable-anchor"),"text-variable-anchor-offset":new As(Nt.layout_symbol["text-variable-anchor-offset"],"text-variable-anchor-offset"),"text-anchor":new As(Nt.layout_symbol["text-anchor"],"text-anchor"),"text-max-angle":new Ps(Nt.layout_symbol["text-max-angle"],"text-max-angle"),"text-writing-mode":new Ps(Nt.layout_symbol["text-writing-mode"],"text-writing-mode"),"text-rotate":new As(Nt.layout_symbol["text-rotate"],"text-rotate"),"text-padding":new Ps(Nt.layout_symbol["text-padding"],"text-padding"),"text-keep-upright":new Ps(Nt.layout_symbol["text-keep-upright"],"text-keep-upright"),"text-transform":new As(Nt.layout_symbol["text-transform"],"text-transform"),"text-offset":new As(Nt.layout_symbol["text-offset"],"text-offset"),"text-allow-overlap":new Ps(Nt.layout_symbol["text-allow-overlap"],"text-allow-overlap"),"text-overlap":new Ps(Nt.layout_symbol["text-overlap"],"text-overlap"),"text-ignore-placement":new Ps(Nt.layout_symbol["text-ignore-placement"],"text-ignore-placement"),"text-optional":new Ps(Nt.layout_symbol["text-optional"],"text-optional"),"symbol-height-offset":new As(Nt.layout_symbol["symbol-height-offset"],"symbol-height-offset"),"symbol-height-anchor":new Ps(Nt.layout_symbol["symbol-height-anchor"],"symbol-height-anchor")})}},Sm=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:ii,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}};Po("FormatSectionOverride",Sm,{omit:["defaultValue"]});var Dm,Em=e=>"symbol"===e.type,Cm=class e extends Bs{constructor(e,t){super(e,Tm,t)}recalculate(e,t){super.recalculate(e,t);let i=this.layout.get("icon-rotation-alignment");if(("constant"!==i.value.kind||"auto"===i.value.value)&&(this.layout._values["icon-rotation-alignment"]=new Ss(i.property,{kind:"constant",value:"point"===this.layout.get("symbol-placement")?"viewport":"map"},i.parameters)),"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").constantOr("viewport")),"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()||mn(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 xm(e)}queryRadius(){return 0}queryIntersectsFeature(){throw Error("Should take a different path in FeatureIndex")}_setPaintOverrides(){for(let t of Tm.paint.overridableProperties){if(!e.hasPaintOverride(this.layout,t))continue;let i=this.paint.get(t),r=new dn(new Sm(i),`layers[${this.id}].paint.${i.property.name}`,i.property.specification),a=null;a="constant"===i.value.kind||"source"===i.value.kind?new gn("source",r):new yn("composite",r,i.value.zoomStops),this.paint._values[t]=new Ss(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=Tm.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 Yi)n(i.value.value.sections);else if("source"===i.value.kind||"composite"===i.value.kind){let e=t=>{if(!a)if(t instanceof hr&&lr(t.value)===ci){let e=t.value;n(e.sections)}else t instanceof yr?n(t.sections):t.eachChild(e)},t=i.value;t._styleExpression&&e(t._styleExpression.expression)}return a}},Pm={get paint(){return Dm||=new zs({"background-color":new Ps(Nt.paint_background["background-color"],"background-color"),"background-pattern":new Ms(Nt.paint_background["background-pattern"],"background-pattern"),"background-opacity":new Ps(Nt.paint_background["background-opacity"],"background-opacity")})}},Am=class extends Bs{constructor(e,t){super(e,Pm,t)}},Im=e=>"custom"===e.type,Mm=class extends Bs{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 Fm(e,t){if("custom"===e.type)return new Mm(e,t);switch(e.type){case"background":return new Am(e,t);case"circle":return new fh(e,t);case"color-relief":return new Rh(e,t);case"fill":return new Vc(e,t);case"fill-extrusion":return new Fd(e,t);case"heatmap":return new Ch(e,t);case"hillshade":return new Ah(e,t);case"line":return new Hd(e,t);case"raster":return new Vs(e,t);case"symbol":return new Cm(e,t)}}function zm(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 km(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 Rm=class extends Ot{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 bh({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 Bt(/* @__PURE__ */Error(`Image "${e}" has invalid "stretchX" value`))),i=!1),this._validateStretch(t.stretchY,r?.height)||(this.fire(new Bt(/* @__PURE__ */Error(`Image "${e}" has invalid "stretchY" value`))),i=!1),this._validateContent(t.content,t)||(this.fire(new Bt(/* @__PURE__ */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 o in t){let i=this._getSpriteImageId(e,o);r.push(i),i in this.images?this.updateImage(i,t[o],!1):this.addImage(i,t[o])}let a=new Set(r),n=i.filter(e=>!a.has(e));for(let o of n)this.removeImage(o);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 hs({id:a})),Oe(`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||Oe(`Image with ID: "${t}" was not found`),lf(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}},Lm=class{constructor(e){this._imageManager=e,this._entries={},this._image=new bh({width:1,height:1}),this._dirty=!0}destroy(){this._texture&&=(this._texture.destroy(),null),this._entries={},this._image=new bh({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 hf(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}isPatternMissing(e){if(!e)return!1;if(!e.from||!e.to)return!0;let t=this.getPattern(e.from.toString()),i=this.getPattern(e.to.toString());return!t||!i}bind(e){let t=e.gl;this._texture?this._dirty&&=(this._texture.update(this._image),!1):(this._texture=new Fh(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}=uf(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,o=n.width,s=n.height;bh.copy(n,r,{x:0,y:0},{x:t,y:i},{width:o,height:s}),bh.copy(n,r,{x:0,y:s-1},{x:t,y:i-1},{width:o,height:1}),bh.copy(n,r,{x:0,y:0},{x:t,y:i+s},{width:o,height:1}),bh.copy(n,r,{x:o-1,y:0},{x:t-1,y:i},{width:1,height:s}),bh.copy(n,r,{x:0,y:0},{x:t+o,y:i},{width:1,height:s})}this._dirty=!0}},Bm=1114111,Om={start:0,end:Bm},jm=0;function Vm(e){let t=/^u\+([0-9a-f]*)(\?+)$/i.exec(e);if(t){let[,e,i]=t;return e.length+i.length>6?null:Nm(parseInt(`${e}${"0".repeat(i.length)}`,16),parseInt(`${e}${"f".repeat(i.length)}`,16))}let i=/^u\+([0-9a-f]{1,6})(?:-([0-9a-f]{1,6}))?$/i.exec(e);if(!i)return null;let r=parseInt(i[1],16);return Nm(r,void 0===i[2]?r:parseInt(i[2],16))}function Nm(e,t){return e>t||e>Bm?null:{start:e,end:Math.min(t,Bm)}}function Um(e,t){return e.ranges.some(({start:e,end:i})=>t>=e&&t<=i)}var $m=class{constructor(e){this.requestManager=e,this._faces={},this._registered=/* @__PURE__ */new Set}setFontFaces(e){this._unregisterAll(),this._faces={};for(let[t,i]of Object.entries(e??{})){let e=Array.isArray(i)?i:[i];this._faces[t]=e.map(e=>this._declareFontFace(t,e)).filter(e=>null!==e)}}hasFontFaces(){return Object.keys(this._faces).length>0}async getFontFamily(e,t,i){for(let r of e.split(","))for(let e of this._faces[r.trim()]??[]){if(!Um(e,t))continue;e.loads.normal??=this._loadFontFace(e,"normal");let r=e.data,a=await e.loads.normal;if(a)return"normal"===i?a:(e.loads[i]??=this._loadFontFace(e,i,r),e.loads[i])}return null}_declareFontFace(e,t){let i="string"==typeof t?{url:t}:t;if("string"!=typeof i?.url)return Oe(`Ignoring the font face declared for "${e}": it has no URL.`),null;let r="maplibre-gl-font-face-"+jm++,a=i["unicode-range"];if(!a?.length)return{url:i.url,ranges:[Om],family:r,loads:{}};let n=[];for(let o of a){let e=Vm(o);e?n.push(e):Oe(`Ignoring the unicode range "${o}" of the font face at ${i.url}: it is not a valid range.`)}return n.length?{url:i.url,ranges:n,family:r,loads:{}}:null}async _loadFontFace(e,t,i){let r,a="normal"===t?"font face":`font face with "${t}" enabled`;if(typeof FontFace>"u"||typeof document>"u"||!document.fonts)return Oe(`Ignoring the ${a} at ${e.url}: this environment has no CSS Font Loading API.`),null;try{i||=(e.data??=this._downloadFontFile(e.url),e.data);let a="normal"===t?e.family:`${e.family}-${t}`;return r=new FontFace(a,await i,{featureSettings:"normal"===t?"normal":`"${t}" 1`}),Object.values(this._faces).some(t=>t.includes(e))&&("normal"===t||r.featureSettings&&"normal"!==r.featureSettings)?(document.fonts.add(r),this._registered.add(r),await r.load(),this._registered.has(r)?a:null):null}catch(t){return r&&this._unregister(r),Oe(`Ignoring the ${a} at ${e.url}: ${ne(t).message}`),null}finally{e.data===i&&delete e.data}}async _downloadFontFile(e){let t=await this.requestManager.transformRequest(e,"Glyphs"),i=await Ft(t,new AbortController);if(!i?.data)throw Error(`the response was empty for the font file at ${e}`);return i.data}_unregister(e){document.fonts?.delete(e),this._registered.delete(e)}_unregisterAll(){for(let e of Object.values(this._faces))for(let t of e)delete t.data;for(let e of this._registered)document.fonts?.delete(e);this._registered.clear()}destroy(){this._unregisterAll(),this._faces={}}},Gm=1e20,Zm=/* @__PURE__ */new Float64Array(256);for(let bC=0;bC<256;bC++){let e=.5-(bC/255)**(1/2.2);Zm[bC]=e*Math.abs(e)}Zm[255]=-1e20;var qm=class{constructor({fontSize:e=24,buffer:t=3,radius:i=8,cutoff:r=.25,fontFamily:a="sans-serif",fontWeight:n="normal",fontStyle:o="normal",lang:s=null}={}){t=this.buffer=Math.round(t),this.radius=i,this.cutoff=r,this.lang=s;let l=this.size=Math.ceil(e)+4*t,u=this._createCanvas(l),h=this.ctx=u.getContext("2d",{willReadFrequently:!0});h.font=`${o} ${n} ${e}px ${a}`,h.textBaseline="alphabetic",h.textAlign="left",h.fillStyle="black",s&&(h.lang=s);let c=(this.maxGlyphDim=l-t)+2*t;this.gridOuter=new Float64Array(c*c),this.gridInner=new Float64Array(c*c),this.f=new Float64Array(c),this.z=new Float64Array(c+1),this.v=new Uint16Array(c)}_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),o=Math.ceil(i),s=Math.floor(-a),l=Math.max(0,Math.min(this.maxGlyphDim,Math.ceil(n)-s)),u=Math.max(0,Math.min(this.maxGlyphDim,o+Math.ceil(r))),h=l+2*this.buffer,c=u+2*this.buffer,d=h*c,p=new Uint8ClampedArray(d),f={data:p,width:h,height:c,glyphWidth:l,glyphHeight:u,glyphTop:o,glyphLeft:s,glyphAdvance:t};if(0===l||0===u)return f;let{ctx:m,buffer:_,gridInner:g,gridOuter:y}=this;m.clearRect(_,_,l,u),m.fillText(e,_-s,_+o);let v=m.getImageData(_,_,l,u);y.fill(Gm,0,d),g.fill(0,0,d);let x=3;for(let S=0;S<u;S++){let e=(S+_)*h+_;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)}}Wm(y,0,0,h,c,h,this.f,this.v,this.z,_);let b=Math.min(_,1);Wm(g,_-b,_-b,l+2*b,u+2*b,h,this.f,this.v,this.z);let w=255/this.radius,T=255*(1-this.cutoff);for(let S=0;S<d;S++){let e=Math.sqrt(y[S])-Math.sqrt(g[S]);p[S]=T-w*e}return f}};function Wm(e,t,i,r,a,n,o,s,l,u=0){for(let h=t+u;h<t+r-u;h++)Hm(e,i*n+h,n,a,o,s,l);for(let h=i;h<i+a;h++)Hm(e,h*n+t,1,r,o,s,l)}function Hm(e,t,i,r,a,n,o){n[0]=0,o[0]=-1e20,o[1]=Gm,a[0]=e[t];for(let s=1,l=0;s<r;s++){let r,u=a[s]=e[t+s*i],h=s*s;do{let e=n[l];r=(u-a[e]+h-e*e)/(s-e)/2}while(r<=o[l]&&--l>-1);l++,n[l]=s,o[l]=r,o[l+1]=Gm}for(let s=0,l=0;s<r;s++){for(;o[l+1]<s;)l++;let r=n[l],u=s-r;e[t+s*i]=a[r]+u*u}}var Xm,Ym,Km=Nt.layout_symbol["text-font"].default.join(","),Jm=(e,t)=>{let i=new qm(e);return i.buffer=t,i},Qm={vertical:"vert"},e_=class{constructor(e,t,i,r=Jm){this.rasterizedGlyphs=/* @__PURE__ */new WeakMap,this.requestManager=e,this.localIdeographFontFamily=t,this.entries={},this.lang=i,this.fontFaceManager=new $m(e),this.createRasterizer=r}setURL(e){this.url=e}setFontFaces(e){this.fontFaceManager.setFontFaces(e),this.entries={}}async getGlyphs(e){let t=[],i=this.fontFaceManager.hasFontFaces();for(let n in e)for(let r in e[n])if(!Qm[r]||i)for(let i of e[n][r])t.push(this._getAndCacheGlyphsPromise(n,i,r));let r=await Promise.all(t),a={};for(let{stack:n,id:o,variant:s,glyph:l}of r)a[n]||={},a[n][s]||={},a[n][s][o]=l&&{id:l.id,bitmap:l.bitmap.clone(),metrics:l.metrics};return a}async _getAndCacheGlyphsPromise(e,t,i){this.entries[e]??={glyphs:{default:{}},requests:{}};let r=this.entries[e],a=r.glyphs[i]||={},n=a[t];if(void 0!==n)return{stack:e,id:t,variant:i,glyph:n};if("default"!==i){let o=Qm[i];return n=o?await this._drawAlternateGlyph(r,e,t,o):null,a[t]=n,{stack:e,id:t,variant:i,glyph:n}}let o=t.codePointAt(0),s=this.fontFaceManager.hasFontFaces()?await this.fontFaceManager.getFontFamily(e,o,"normal"):null;return s?(n=await this._drawGlyph(r,e,t,s),a[t]=n,{stack:e,id:t,variant:i,glyph:n}):!this.url||Pp(t)||this._charUsesLocalIdeographFontFamily(o)||function(e){return/[\u0900-\u109F\u1700-\u17FF\u1900-\u194F\u19E0-\u1AAF\u1B00-\u1C4F\u1CC0-\u1CCF\uA800-\uA82F\uA880-\uA8FF\uA930-\uA95F\uA980-\uAAFF\uABC0-\uABFF]|\uD802[\uDE00-\uDE5F]|\uD804[\uDC00-\uDCCF\uDD00-\uDD4F\uDD80-\uDE4F\uDEB0-\uDFFF]|\uD805[\uDC00-\uDCDF\uDD80-\uDE5F\uDE80-\uDF4F]|\uD806[\uDC00-\uDC4F\uDD00-\uDD5F\uDDA0-\uDEAF\uDF00-\uDF7F]|\uD807[\uDC00-\uDCBF\uDD00-\uDDAF\uDEE0-\uDF5F\uDFC0-\uDFFF]|\uD818[\uDD00-\uDD3F]/gim.test(String.fromCodePoint(e))}(o)?(n=await this._drawGlyph(r,e,t),a[t]=n,{stack:e,id:t,variant:i,glyph:n}):{...await this._downloadAndCacheRangePromise(e,t),variant:i}}async _drawAlternateGlyph(e,t,i,r){let a=await this._getFontFaceTinySDF(e,t,i,r);if(!a||this.entries[t]!==e)return null;let n=a.draw(i);if(!n.glyphWidth||!n.glyphHeight)return null;let o=await this._getFontFaceTinySDF(e,t,i,"normal");if(!o||this.entries[t]!==e)return null;let s=this._createGlyph(i,n);return function(e,t){return e.bitmap.width===t.bitmap.width&&e.bitmap.height===t.bitmap.height&&e.metrics.width===t.metrics.width&&e.metrics.height===t.metrics.height&&e.metrics.left===t.metrics.left&&e.metrics.top===t.metrics.top&&e.metrics.advance===t.metrics.advance&&e.bitmap.data.every((e,i)=>e===t.bitmap.data[i])}(this._getRasterizedGlyph(o,i),s)?null:s}async _downloadAndCacheRangePromise(e,t){let i=t.codePointAt(0),r=this.entries[e],a=Math.floor(i/256);r.requests[a]||=this._loadGlyphRange(e,a);try{let n=(await r.requests[a])[i]||null;return r.glyphs.default[t]=n,{stack:e,id:t,glyph:n}}catch(s){let o=await this._drawGlyph(r,e,t);return r.glyphs.default[t]=o,this._warnOnMissingGlyphRange(o,a,i,ne(s)),{stack:e,id:t,glyph:o}}}async _loadGlyphRange(e,t){let i=256*t,r=i+255,a=await this.requestManager.transformRequest(this.url.replace("{fontstack}",e).replace("{range}",`${i}-${r}`),"Glyphs"),n=await Ft(a,new AbortController);if(!n?.data)throw Error(`Could not load glyph range. range: ${t}, ${i}-${r}`);let o={};for(let s of function(e){return new rf(e).readFields(af,[])}(n.data))o[s.id]=s;return o}_warnOnMissingGlyphRange(e,t,i,r){let a=256*t;Oe(`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,r){let a=await this._getTinySDF(e,t,i,r);return this._getRasterizedGlyph(a,i)}_getRasterizedGlyph(e,t){let i=this.rasterizedGlyphs.get(e);return i||(i={},this.rasterizedGlyphs.set(e,i)),i[t]??=this._createGlyph(t,e.draw(t)),i[t]}_createGlyph(e,t){let i=/^\p{gc=Cf}+$/u.test(e);return{id:e.codePointAt(0),bitmap:new xh({width:t.width||60,height:t.height||60},t.data),metrics:{width:i?0:t.glyphWidth/2||24,height:t.glyphHeight/2||24,left:t.glyphLeft/2+.5||0,top:t.glyphTop/2-27.5||-8,advance:i?0:t.glyphAdvance/2||24,isDoubleResolution:!0}}}async _getFontFaceTinySDF(e,t,i,r){if(this.entries[t]!==e)return null;let a=await this.fontFaceManager.getFontFamily(t,i.codePointAt(0),r);return a&&this.entries[t]===e?this._getTinySDF(e,t,i,a):null}_getTinySDF(e,t,i,r){let a=Pp(i);if(r){let t=a?"clusterTinySDFs":"fontFaceTinySDFs";return e[t]??={},e[t][r]||=this._createTinySDF(r,!1,a?3:1),e[t][r]}let n=t===Km&&""!==this.localIdeographFontFamily&&this._charUsesLocalIdeographFontFamily(i.codePointAt(0)),o=n?this.localIdeographFontFamily:t;if(a)return e.clusterTinySDFs??={},e.clusterTinySDFs[o]||=this._createTinySDF(o,!0,3),e.clusterTinySDFs[o];let s=n?"ideographTinySDF":"tinySDF";return e[s]||=this._createTinySDF(o),e[s]}async _createTinySDF(e,t=!0,i=1){let r=e?e.split(","):[];r.push("sans-serif");let a=r.map(e=>/[-\w]+/.test(e)?e:`'${CSS.escape(e)}'`).join(","),n=t?this._fontWeight(r[0]):void 0,o=t?this._fontStyle(r[0]):"normal";if(typeof document<"u"&&document.fonts?.load)try{await document.fonts.load(`${o} ${n||"normal"} 48px ${a}`)}catch(e){Oe(`Failed to load font "${a}": ${ne(e).message}`)}return this.createRasterizer({fontSize:48,buffer:Math.max(6,Math.ceil(48*(i-1)/4)),radius:16,cutoff:.25,fontFamily:a,fontWeight:n,fontStyle:o,lang:this.lang},6)}_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.fontFaceTinySDFs={},t.glyphs={default:{}},t.requests={}}this.entries={},this.fontFaceManager.destroy()}},t_=class extends Ot{constructor(e,t){super(),this._transitionable=new xs(Xm||=new zs({anchor:new Ps(Nt.light.anchor,"anchor"),position:new Ps(Nt.light.position,"position"),color:new Ps(Nt.light.color,"color"),intensity:new Ps(Nt.light.intensity,"intensity")}),"light",t),this.setLight(e),this._transitioning=this._transitionable.untransitioned(),this.recalculate(new gs(0))}getLight(){return this._transitionable.serialize()}getEvaluated(){return{anchor:this.properties.get("anchor"),position:this.properties.get("position"),color:this.properties.get("color"),intensity:this.properties.get("intensity")}}setLight(e,t={}){this._validate(cs.light,e,t)||this._transitionable.setValues(e)}updateTransitions(e){this._transitioning=this._transitionable.transitioned(e,this._transitioning)}hasTransition(){return this._transitioning.hasTransition()}applyGlobalStateChange(e,t,i){this._transitioning=this._transitionable.applyGlobalStateChange(e,t,this._transitioning,i)}recalculate(e){this.properties=this._transitioning.possiblyEvaluate(e)}_validate(e,t,i){return ms(this,e,{value:t},i)}},i_=class extends Ot{constructor(e,t){super(),this._transitionable=new xs(Ym||=new zs({"sky-color":new Ps(Nt.sky["sky-color"],"sky-color"),"horizon-color":new Ps(Nt.sky["horizon-color"],"horizon-color"),"fog-color":new Ps(Nt.sky["fog-color"],"fog-color"),"fog-ground-blend":new Ps(Nt.sky["fog-ground-blend"],"fog-ground-blend"),"horizon-fog-blend":new Ps(Nt.sky["horizon-fog-blend"],"horizon-fog-blend"),"sky-horizon-blend":new Ps(Nt.sky["sky-horizon-blend"],"sky-horizon-blend"),"atmosphere-blend":new Ps(Nt.sky["atmosphere-blend"],"atmosphere-blend")}),"sky",t),this.setSky(e),this._transitioning=this._transitionable.untransitioned(),this.recalculate(new gs(0))}setSky(e,t={}){return!this._validate(cs.sky,e,t)&&(e||={"sky-color":"transparent","horizon-color":"transparent","fog-color":"transparent","fog-ground-blend":1,"atmosphere-blend":0},this._transitionable.setValues(e),!0)}getSky(){return this._transitionable.serialize()}updateTransitions(e){this._transitioning=this._transitionable.transitioned(e,this._transitioning)}hasTransition(){return this._transitioning.hasTransition()}applyGlobalStateChange(e,t,i){this._transitioning=this._transitionable.applyGlobalStateChange(e,t,this._transitioning,i)}recalculate(e){this.properties=this._transitioning.possiblyEvaluate(e)}_validate(e,t,i={}){return ms(this,e,{value:t},i)}getEvaluated(){return{"sky-color":this.properties.get("sky-color"),"horizon-color":this.properties.get("horizon-color"),"fog-color":this.properties.get("fog-color"),"fog-ground-blend":this.properties.get("fog-ground-blend"),"horizon-fog-blend":this.properties.get("horizon-fog-blend"),"sky-horizon-blend":this.properties.get("sky-horizon-blend"),"atmosphere-blend":this.properties.get("atmosphere-blend")}}};function r_(e){return e<60?0:e<70?(e-60)/10:1}var a_=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,o=!0;r.push({left:a,right:n,isDash:o,zeroLength:0===e[0]});let s=e[0];for(let l=1;l<e.length;l++){o=!o;let t=e[l];a=s*i,s+=t,n=s*i,r.push({left:a,right:n,isDash:o,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,o=0,s=e[o];for(let l=0;l<this.width;l++){l/s.right>1&&(s=e[++o]);let t,u=Math.abs(l-s.left),h=Math.abs(l-s.right),c=Math.min(u,h),d=a/i*(r+1);if(s.isDash){let e=r-Math.abs(d);t=Math.sqrt(c*c+e*e)}else t=r-Math.sqrt(c*c+d*d);this.data[n+l]=Math.max(0,Math.min(255,t+128))}}}addRegularDash(e){for(let o=e.length-1;o>=0;--o){let t=e[o],i=e[o+1];t.zeroLength?e.splice(o,1):i?.isDash===t.isDash&&(i.left=t.left,e.splice(o,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 o=0;o<this.width;o++){o/n.right>1&&(n=e[++a]);let t=Math.abs(o-n.left),i=Math.abs(o-n.right),s=Math.min(t,i),l=n.isDash?s:-s;this.data[r+o]=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 Oe("LineAtlas out of space"),null;let a=0;for(let o of e)a+=o;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))}},n_=class extends Ot{constructor(e,t){super(),this.workerPool=e,this.actors=[],this.currentActor=0,this.id=t,this.removed=!1,this.workerErrorSubscriptions=[],this.actorsPromise=this.initActors(t)}async initActors(e){let t=await this.workerPool.acquire(e);if(this.removed)return[];let{actors:i,workerErrorSubscriptions:r}=Bo(t,e,this);if(this.actors=i,this.workerErrorSubscriptions=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();for(let t of this.workerErrorSubscriptions)t.unsubscribe();this.actors=[],this.workerErrorSubscriptions=[],this.setEventedParent(null),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 o_(e,t){let i=y();T(i,i,[1,1,0]),S(i,i,[.5*e.width,.5*e.height,1]);let r=e.getFastPathSimpleProjectionMatrix(t);return r?w(i,i,r):i}function s_(e,t,i,r,a,n,o){let s=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(),u=e.tilesIn(r,l,s);u.sort(l_);let h=[];for(let c of u)h.push({wrappedTileID:c.tileID.wrapped().key,queryResults:c.tile.queryRenderedFeatures(t,i,e.getState(),c.queryGeometry,c.cameraQueryGeometry,c.scale,a,n,l,o_(n,c.tileID),o?(e,t)=>o(c.tileID,e,t):void 0)});return function(e,t){for(let i in e)for(let r of e[i])u_(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}(h),e)}function l_(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 u_(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 h_(e,t,i,r){let a=e;if(e.url?a=(await Mt(await t.transformRequest(e.url,"Source"),i)).data:await ht.frameAsync(i,r),!a)return null;let n=Ce(Ee(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 c_=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 Kc?new Kc(e.lng,e.lat):Kc.convert(e),this}setSouthWest(e){return this._sw=e instanceof Kc?new Kc(e.lng,e.lat):Kc.convert(e),this}extend(t){let i,r,a=this._sw,n=this._ne;if(t instanceof Kc)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(Kc.convert(e))}}return t&&("lng"in t||"lon"in t)&&"lat"in t?this.extend(Kc.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 Kc(i.lng,i.lat),this._ne=new Kc(r.lng,r.lat)),this}getCenter(){return new Kc((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 Kc(this.getWest(),this.getNorth())}getSouthEast(){return new Kc(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}=Kc.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=De(this.getWest(),-180,180),n=De(this.getEast(),-180,180),o=De(t.getWest(),-180,180),s=De(t.getEast(),-180,180),l=a>n,u=o>s;return!(!l||!u)||(l?s>=a||o<=n:u?n>=o||a<=s:o<=n&&s>=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 Kc(t.lng-a,t.lat-r),new Kc(t.lng+a,t.lat+r))}adjustAntiMeridian(){let t=new Kc(this._sw.lng,this._sw.lat),i=new Kc(this._ne.lng,this._ne.lat);return t.lng>i.lng?new e(t,new Kc(i.lng+360,i.lat)):new e(t,i)}},d_=class{constructor(e,t,i,r){this.bounds=c_.convert(this.validateBounds(e)),this.minzoom=t||0,this.maxzoom=i||24,this._worldBox=vd(r,this.bounds.getWest(),this.bounds.getSouth(),this.bounds.getEast(),this.bounds.getNorth())}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(this._worldBox.minX*t),r=Math.floor(this._worldBox.minY*t),a=Math.ceil(this._worldBox.maxX*t),n=Math.ceil(this._worldBox.maxY*t);return e.x>=i&&e.x<a&&e.y>=r&&e.y<n}},p_=class extends Ot{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,Ee(this,Ce(t,["url","scheme","tileSize","promoteId","encoding"])),this._options=Ee({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 is("dataloading")),this._tileJSONRequest=new AbortController;try{let t=await h_(this._options,this.map._requestManager,this._tileJSONRequest,this.map._ownerWindow);this._tileJSONRequest=null,this._loaded=!0,t&&(Ee(this,t),t.bounds&&(this.tileBounds=new d_(t.bounds,this.minzoom,this.maxzoom,this.map.style.projection.worldCoordinateHelper)),this.fire(new is("data",{sourceDataType:"metadata"})),this.fire(new is("data",{sourceDataType:"content",sourceDataChanged:e})))}catch(e){this._tileJSONRequest=null,this._loaded=!0,lt(e)||this.fire(new Bt(ne(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.tiles=e,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 Ee({},this._options)}async loadTile(e){let t=e.tileID.canonical.url(this.tiles,this.map.getPixelRatio(),this.scheme,this.map.style.projection.worldCoordinateHelper.tileMatrixSet),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};if(this._setAcceptHeader(i.request),i.request.collectResourceTiming=this._collectResourceTiming,await this.dispatcher.waitForInitComplete(),e.aborted)return;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||lt(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,this.map.style.projection.worldCoordinateHelper.tileMatrixSet),r=await this.map._requestManager.transformRequest(i,"Tile");return this._setAcceptHeader(r),{maxZoomTileID:t,overzoomRequest:r}}_setAcceptHeader(e){"mlt"===this.encoding&&(e.headers??={},e.headers.Accept??="application/vnd.maplibre-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.style),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 this.dispatcher.broadcast("RMT",{uid:e.uid,type:this.type,source:this.id})}hasTransition(){return!1}},f_=class extends Ot{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=Ee({type:"raster"},t),Ee(this,Ce(t,["url","scheme","tileSize"]))}async load(e=!1){this._loaded=!1,this.fire(new is("dataloading")),this._tileJSONRequest=new AbortController;try{let t=await h_(this._options,this.map._requestManager,this._tileJSONRequest,this.map._ownerWindow);this._tileJSONRequest=null,this._loaded=!0,t&&(Ee(this,t),t.bounds&&(this.tileBounds=new d_(t.bounds,this.minzoom,this.maxzoom,this.map.style.projection.worldCoordinateHelper)),this.fire(new is("data",{sourceDataType:"metadata"})),this.fire(new is("data",{sourceDataType:"content",sourceDataChanged:e})))}catch(e){this._tileJSONRequest=null,this._loaded=!0,lt(e)||this.fire(new Bt(ne(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.tiles=e,this._options.tiles=e}),this}setUrl(e){return this.setSourceProperty(()=>{this.url=e,this._options.url=e}),this}serialize(){return Ee({},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,this.map.style.projection.worldCoordinateHelper.tileMatrixSet),i=this._premultiplyAlpha,r=i?void 0:{premultiplyAlpha:"none"};e.abortController=new AbortController;try{let a=await Ho.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){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??new bh({width:1,height:1},/* @__PURE__ */new Uint8Array(4));e.texture=this.map.painter.getTileTexture(n.width),e.texture?e.texture.update(n,{useMipmap:!0,premultiply:i}):(e.texture=new Fh(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}};function m_(e,t,i){let{x:r,y:a}=i.worldFromLngLat(t.lng,t.lat);return!(e<0||e>25||a<0||a>=1||r<0||r>=1)}var __=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=v_(0,e,e,t,i)}equals(e){return this.z===e.z&&this.x===e.x&&this.y===e.y}url(e,t,i,r=Qc){let 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,()=>x_(this.x,this.y,this.z,Qc)).replace(/{bbox}/g,()=>x_(this.x,this.y,this.z,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 d((e.x*t-this.x)*re,(e.y*t-this.y)*re)}toString(){return`${this.z}/${this.x}/${this.y}`}},g_=class{constructor(e,t){this.wrap=e,this.canonical=t,this.key=v_(e,t.z,t.z,t.x,t.y)}},y_=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 __(i,+r,+a),this.key=v_(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?v_(this.wrap*+t,e,this.canonical.z,this.canonical.x,this.canonical.y):v_(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 g_(this.wrap,this.canonical)}toString(){return`${this.overscaledZ}/${this.canonical.x}/${this.canonical.y}`}getTilePoint(e){return this.canonical.getTilePoint(new ld(e.x-this.wrap,e.y))}normalizeCoordinates(t,i,r=re){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),o=t-a*r,s=i-n*r,l=this.canonical.z,u=1<<l,h=this.canonical.y+n;if(h<0||h>=u)return null;let c=this.canonical.x+a,d=this.wrap;return c<0?(d-=Math.ceil(-c/u),c=(c%u+u)%u):c>=u&&(d+=Math.floor(c/u),c%=u),{tileID:new e(this.overscaledZ,d,l,c,h),x:o,y:s}}};function v_(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)}function x_(e,t,i,r){let a=2**i,n=r.extentAtZoom0/a,[o,s]=r.origin,l=s-r.extentAtZoom0,u=a-t-1;return`${o+e*n},${l+u*n},${o+(e+1)*n},${l+(u+1)*n}`}function b_(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}Po("CanonicalTileID",__),Po("OverscaledTileID",y_,{omit:["terrainRttPosMatrix32f"]});var w_=class extends f_{constructor(e,t,i,r){super(e,t,i,r),this.type="raster-dem",this.maxzoom=22,this._options=Ee({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,this.map.style.projection.worldCoordinateHelper.tileMatrixSet);e.neighboringTiles=this._getNeighboringTiles(e.tileID),e.abortController=new AbortController;try{let i=await Ho.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){if(this.map._refreshExpiredTiles&&(i.cacheControl||i.expires)&&e.setExpiryData({cacheControl:i.cacheControl,expires:i.expires}),!i.data)return void(e.state="loaded");let t=i.data,r=Ge(t)&&p()?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.needsColorReliefPrepare=!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"&&f()){let t=e.width+4,i=e.height+4;try{return new bh({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 o=n?.format;if(!o||!o.startsWith("BGR")&&!o.startsWith("RGB"))throw Error(`Unrecognized format ${o}`);let s=o.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),o=(Math.max(0,i)-i)*r*4+n,s=4*r,l=Math.max(0,t),u=Math.max(0,i);return{rect:{x:l,y:u,width:Math.min(e.width,t+r)-l,height:Math.min(e.height,i+a)-u},layout:[{offset:o,stride:s}]}}(e,t,i,r,a)),s)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,-2,-2,t,i))}catch{}}return ht.getImageData(e,2)}_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,o=t.x+1===i?e.wrap+1:e.wrap,s={};return s[new y_(e.overscaledZ,a,t.z,r,t.y).key]={backfilled:!1},s[new y_(e.overscaledZ,o,t.z,n,t.y).key]={backfilled:!1},t.y>0&&(s[new y_(e.overscaledZ,a,t.z,r,t.y-1).key]={backfilled:!1},s[new y_(e.overscaledZ,e.wrap,t.z,t.x,t.y-1).key]={backfilled:!1},s[new y_(e.overscaledZ,o,t.z,n,t.y-1).key]={backfilled:!1}),t.y+1<i&&(s[new y_(e.overscaledZ,a,t.z,r,t.y+1).key]={backfilled:!1},s[new y_(e.overscaledZ,e.wrap,t.z,t.x,t.y+1).key]={backfilled:!1},s[new y_(e.overscaledZ,o,t.z,n,t.y+1).key]={backfilled:!1}),s}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 T_(e,t){return t?e.properties[t]:e.id}function S_(e,t){let i={id:e.id};if(t.removeAllProperties&&(delete e.removeProperties,delete e.addOrUpdateProperties,delete t.removeProperties),t.removeProperties&&e.addOrUpdateProperties){let i=new Set(t.removeProperties);e.addOrUpdateProperties=e.addOrUpdateProperties.filter(e=>!i.has(e.key))}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)return{};let i={};return i.removeAll=e.removeAll,i.remove=new Set(e.remove||[]),i.add=new Map(e.add?.map(e=>[T_(e,t),e])),i.update=new Map(e.update?.map(e=>[e.id,e])),i}function E_(e){return e&&0!==e.length?"number"==typeof e[0]?[e]:e.flatMap(e=>E_(e)):[]}function C_(e){return e?"GeometryCollection"===e.type?e.geometries.flatMap(e=>C_(e)):E_(e.coordinates):[]}function P_(e){let t,i=new c_;switch(e.type){case"FeatureCollection":t=e.features.flatMap(e=>C_(e.geometry));break;case"Feature":t=C_(e.geometry);break;default:t=C_(e)}if(0===t.length)return i;for(let r of t){let[e,t]=r;i.extend([e,t])}return i}var A_=class{constructor(e){this._waiting=[],this._sending=!1,this._replacedWhileSending=!1,this._handlers=e}isIdle(){return!this._sending&&0===this._waiting.length}top(){return this._waiting.length?this._waiting[this._waiting.length-1]:void 0}some(e){return this._waiting.some(e)}enqueue(e){this._waiting.push(e)}replace(e){this._waiting=[e],this._replacedWhileSending=this._sending}clear(){this._waiting=[]}flush(){if(this.isIdle())return Promise.resolve();if(!this._flushing){let e,t=new Promise(t=>{e=t});this._flushing={promise:t,resolve:e}}let{promise:e}=this._flushing;return this._next(),e}_next(){if(this._sending)return;let e=this._waiting.shift();void 0===e?(this._flushing?.resolve(),this._flushing=void 0):(this._sending=!0,this._replacedWhileSending=!1,this._send(e).finally(()=>this._next()))}async _send(e){let t;try{t=await this._handlers.send(e)}catch(t){return this._sending=!1,void this._handlers.onError(e,t)}this._sending=!1;try{this._handlers.onResult(e,t,this._replacedWhileSending)}catch(t){this._handlers.onError(e,t)}}},I_=class{constructor(e){this.wraps=!1,this._crs=e,this._originX=e.tileMatrixSet.origin[0],this._originY=e.tileMatrixSet.origin[1],this._extent=e.tileMatrixSet.extentAtZoom0}get name(){return this._crs.name}get tileMatrixSet(){return this._crs.tileMatrixSet}worldFromLngLat(e,t,i){let[r,a]=this._crs.projection.forward([e,t]);return new ld((r-this._originX)/this._extent,(this._originY-a)/this._extent,void 0===i?0:i/this._extent)}lngLatFromWorld(e,t){let i=Se(e,0,1),r=Se(t,0,1),a=this._inverse(e,t)??this._inverse(i,r)??this._inverseTowardCenter(i,r)??this._finiteInverse(i,r);if(!a)throw Error(`The inverse of the projection "${this._crs.name}" has no answer inside its tile matrix set.`);return new Kc(a[0],Se(a[1],-90,90))}hasLngLat(e,t){return null!==this._inverse(e,t)}_inverse(e,t){let i=this._finiteInverse(e,t);if(!i)return null;let r=this._originX+e*this._extent,a=this._originY-t*this._extent,[n,o]=this._crs.projection.forward(i);return Math.hypot(n-r,o-a)<=.001*this._extent?i:null}_finiteInverse(e,t){let i;try{i=this._crs.projection.inverse([this._originX+e*this._extent,this._originY-t*this._extent])}catch{return null}return i&&Number.isFinite(i[0])&&Number.isFinite(i[1])?i:null}_inverseTowardCenter(e,t){let i=0,r=1;for(let a=0;a<30;a++){let a=(i+r)/2;this._inverse(.5+(e-.5)*a,.5+(t-.5)*a)?i=a:r=a}return this._inverse(.5+(e-.5)*i,.5+(t-.5)*i)}metersPerWorldUnit(e,t){return this._extent}worldZFromAltitude(e,t){return e/this._extent}get latitudeRange(){return this._latitudeRange??=[this._findLatitudeLimit(-90),this._findLatitudeLimit(90)],this._latitudeRange}_findLatitudeLimit(e){let t=this.lngLatFromWorld(.5,.5),i=10*this._meridianStretch(t.lng,t.lat);if(!(i>0))return e;let r=Math.sign(e-t.lat);for(let a=t.lat;Math.abs(e-a)>1;a+=r)if(!(this._meridianStretch(t.lng,a+r)<=i))return a;return e}_meridianStretch(e,t){let[i,r]=this._crs.projection.forward([e,t]),[a,n]=this._crs.projection.forward([e,t>=0?t-.01:t+.01]);return Math.hypot(a-i,n-r)}},M_=class{forward(e){return[e[0],e[1]]}inverse(e){return[e[0],e[1]]}},F_=new class{constructor(){this.name="identity",this.projection=new M_,this.tileMatrixSet={origin:[-90,90],extentAtZoom0:180}}},z_=/* @__PURE__ */new Map([[F_.name,F_]]);function k_(e){return"string"==typeof e?z_.get(e):void 0}function R_(e){if(!e.name.includes(":"))throw Error(`The projection name "${e.name}" needs a colon, like "EPSG:2193" or "custom:equal-earth": names without one are reserved for built-in projections.`);if(z_.has(e.name))throw Error(`A projection called "${e.name}" already exists.`);if(!(e.tileMatrixSet.extentAtZoom0>0))throw Error(`The projection "${e.name}" needs a tileMatrixSet.extentAtZoom0 greater than zero.`);z_.set(e.name,e)}function L_(e){if(!e.includes(":"))throw Error(`The projection name "${e}" has no colon, so it is reserved for built-in projections, which cannot be removed.`);z_.delete(e)}var B_=class extends Ot{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._workerUpdates=new A_({send:e=>this._sendWorkerUpdate(e),onResult:(e,t,i)=>this._onWorkerUpdateResult(e,t,i),onError:(e,t)=>this._onWorkerUpdateError(t)}),void 0!==t.data&&this._workerUpdates.enqueue({data:t.data}),this.actorPromise=i.getActor(),this.setEventedParent(r),this._data="string"==typeof t.data?{url:t.data}:{geojson:t.data},this._options=Ee({},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&&Oe(`The maxzoom value "${this.maxzoom}" is expected to be greater than the clusterMaxZoom value "${t.clusterMaxZoom}".`),this.workerOptions=Ee({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:re,maxZoom:this.maxzoom,lineMetrics:t.lineMetrics||!1,generateId:t.generateId||!1,promoteId:this._promoteIdKey,cluster:t.cluster||!1,clusterOptions:{maxZoom:this._getClusterMaxZoom(t.clusterMaxZoom),minPoints:Math.max(2,t.clusterMinPoints||2),extent:re,radius:this._pixelsToTileUnits(t.clusterRadius||50),log:!1,generateId:t.generateId||!1}},clusterProperties:t.clusterProperties,filter:t.filter},t.workerOptions)}get _promoteIdKey(){return"string"==typeof this.promoteId?this.promoteId:void 0}_pixelsToTileUnits(e){return e*(re/this.tileSize)}_tileUnitsToPixels(e){return e/(re/this.tileSize)}_getClusterMaxZoom(e){let t=e?Math.round(e):this.maxzoom-1;return Number.isInteger(e)||void 0===e||Oe(`Integer expected for option 'clusterMaxZoom': provided value "${e}" rounded to "${t}"`),t}async load(){this._workerUpdates.isIdle()?Oe(`No pending worker updates for GeoJSONSource ${this.id}.`):await this._workerUpdates.flush()}onAdd(e){this.map=e,this.load()}setData(e){return this._data="string"==typeof e?{url:e}:{geojson:e},this._workerUpdates.replace({data:e}),this._workerUpdates.flush()}updateData(e){let t=this._getWaitingWorkerChange();return t?t.diff=function(e,t,i){if(!e)return t||{};if(!t)return e||{};let r=D_(e,i),a=D_(t,i);!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 of t.add.keys())e.update.delete(i);for(let[i,r]of t.update){let a=e.update.get(i);a&&(t.update.set(i,S_(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);return 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)}(t.diff,e,this._promoteIdKey):this._workerUpdates.enqueue({diff:e}),this._workerUpdates.flush()}async getData(){for(;this._data.url;)await this.once("data");return this._data.geojson?this._data.geojson:{type:"FeatureCollection",features:Array.from(this._data.updateable.values())}}async getBounds(){return P_(await this.getData())}setClusterOptions(e){if(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._workerUpdates.some(e=>"data"in e)){let e=this._getWaitingWorkerChange();e?e.updateCluster=!0:this._workerUpdates.enqueue({updateCluster:!0})}return this._workerUpdates.flush()}_getWaitingWorkerChange(){let e=this._workerUpdates.top();return e&&!("data"in e)?e:void 0}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 _getLoadGeoJSONParameters(e){let t=Ee({type:this.type,source:this.id},this.workerOptions),i=this._getCRSParameters();return i&&(t.crs=i),"data"in e?"string"==typeof e.data?(t.request=await this.map._requestManager.transformRequest(ht.resolveURL(e.data),"Source"),t.request.collectResourceTiming=this._collectResourceTiming,t):(t.data=e.data,t):(e.diff&&(t.dataDiff=e.diff),e.updateCluster&&(t.updateCluster=!0),t)}_getCRSParameters(){let e=k_(this.map?.style?.projection?.name);if(e){if(e.definition||e===F_)return{name:e.name,definition:e.definition,tileMatrixSet:e.tileMatrixSet};Oe(`GeoJSON source "${this.id}" is drawn in the wrong place: the projection "${e.name}" has no \`definition\` to project its data with.`)}}async _sendWorkerUpdate(e){this.fire(new is("dataloading"));let t=await this._getLoadGeoJSONParameters(e);return(await this.actorPromise).sendAsync({type:"LD",data:t})}_onWorkerUpdateResult(e,t,i){if(this._removed||t.abandoned)return void this.fire(new is("dataabort"));t.data&&!i&&(this._data={geojson:t.data});let r="data"in e||i?void 0:e.diff,a=this._applyDiffToSource(r),n=!("data"in e)&&e.updateCluster||!1===this.map?.style?.projection?.worldCoordinateHelper.wraps?void 0:this._getShouldReloadTileOptions(a),o={};this._applyResourceTiming(o,t),this.fire(new is("data",{...o,sourceDataType:"metadata"})),this.fire(new is("data",{...o,sourceDataType:"content",shouldReloadTileOptions:n}))}_onWorkerUpdateError(e){this._removed?this.fire(new is("dataabort")):this.fire(new Bt(ne(e)))}_applyResourceTiming(e,t){if(!this._collectResourceTiming)return;let i=t.resourceTiming?.[this.id];if(!i)return;let r=i.slice(0);r?.length&&Ee(e,{resourceTiming:r})}_applyDiffToSource(e){if(!e)return;let t=this._promoteIdKey;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=T_(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=T_(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=T_(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 o={...t};if(e.set(a.id,o),i&&(r.push(a.newGeometry),o.geometry=a.newGeometry),n){if(o.properties=a.removeAllProperties?{}:{...o.properties||{}},a.removeProperties)for(let e of a.removeProperties)delete o.properties[e];if(a.addOrUpdateProperties)for(let{key:e,value:t}of a.addOrUpdateProperties)o.properties[e]=t}}return r}(this._data.updateable,e,t);return e.removeAll||this.workerOptions.geojsonVtOptions.cluster?void 0:i}_getShouldReloadTileOptions(e){if(e)return{affectedBounds:e.filter(Boolean).map(e=>P_(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,a){let n=2**i,{west:o,south:s,east:l,north:u}=function(e,t,i,r,a){let n=[e.lngLatFromWorld(t,i),e.lngLatFromWorld(r,i),e.lngLatFromWorld(r,a),e.lngLatFromWorld(t,a)];return{west:Math.min(n[0].lng,n[1].lng,n[2].lng,n[3].lng),south:Math.min(n[0].lat,n[1].lat,n[2].lat,n[3].lat),east:Math.max(n[0].lng,n[1].lng,n[2].lng,n[3].lng),north:Math.max(n[0].lat,n[1].lat,n[2].lat,n[3].lat)}}(a,(e-r)/n,(t-r)/n,(e+1+r)/n,(t+1+r)/n);return new c_([o,s],[l,u])}(e.tileID.canonical,i/r,this.map.style.projection.worldCoordinateHelper);for(let n of t)if(a.intersects(n))return!0;return!1}loaded(){return this._workerUpdates.isIdle()}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.style,"RT"===t)}catch(t){if(delete e.abortController,e.aborted||lt(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._workerUpdates.clear(),this.actorPromise.then(e=>e.sendAsync({type:"RS",data:{type:this.type,source:this.id}}))}serialize(){return Ee({},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}},O_=[0,0,1],j_=(e,t,i,r,a,n)=>({u_tl_parent:e,u_scale_parent:t,u_buffer_scale:1,u_image_warp: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:U_(r.paint.get("raster-saturation")),u_contrast_factor:N_(r.paint.get("raster-contrast")),u_spin_weights:V_(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 V_(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 N_(e){return e>0?1/(1-e):1+e}function U_(e){return e>0?1-1/(1.001-e):-e}var $_=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}},G_=Gs([{name:"a_pos",type:"Int16",components:2}]);function Z_(e,t){let i=q_(t,"16bit"),r=Pl.deserialize({arrayBuffer:i.vertices,length:i.vertices.byteLength/2/2}),a=Zl.deserialize({arrayBuffer:i.indices,length:i.indices.byteLength/2/3});return new $_(e.createVertexBuffer(r,G_.members),e.createIndexBuffer(a),Yl.simpleSegment(0,0,r.length,a.length))}function q_(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,o=a+1,s=e.generateBorders?-1:0,l=e.generateBorders||e.extendToNorthPole?-1:0,u=i+ +!!e.generateBorders,h=i+(e.generateBorders||e.extendToSouthPole?1:0),c=n*o,d=r*a*6,p=n*o>65536;if(p&&"16bit"===t)throw Error("Granularity is too large and meshes would not fit inside 16 bit vertex indices.");let f=p||"32bit"===t,m=new Int16Array(2*c),_=0;for(let v=l;v<=h;v++)for(let t=s;t<=u;t++){let r=t/i*re;-1===t&&(r=-64),t===i+1&&(r=8256);let a=v/i*re;-1===v&&(a=e.extendToNorthPole?Cc:-64),v===i+1&&(a=e.extendToSouthPole?Pc:8256),m[_++]=r,m[_++]=a}let g=f?new Uint32Array(d):new Uint16Array(d),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 W_=class extends Ot{constructor(e,t,i,r){super(),this.imageWarp=O_,this.flippedWindingOrder=!1,this._warp="auto",this._imageDirty=!1,this._subdividedQuad=!1,this._subdividedMesh=null,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){if(void 0===this.options.url)this._loaded=!0,this._finishLoading();else{this._loaded=!1,this.fire(new is("dataloading")),this.url=this.options.url,this._abortController=new AbortController;try{let t=await Ho.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()):this.fire(new Bt(/* @__PURE__ */Error(`Could not load image ${this.url}: the response is empty`)))}catch(e){if(lt(e))return;this._abortController=null,this._loaded=!0,this.fire(new Bt(ne(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)}_setImage(e){this.image=e,this._imageDirty=!0}getMesh(e,t){return!this._subdividedQuad||t?null:(this._subdividedMesh??=Z_(e,{granularity:16}),this._subdividedMesh)}_disposeTexture(){this.texture?.destroy(),this.texture=null}_finishLoading(){if(this.map)try{this.setCoordinates(this.coordinates),this.fire(new is("data",{sourceDataType:"metadata"}))}catch(i){this.fire(new Bt(ne(i)))}}onAdd(e){this.map=e,this.load()}onRemove(){this._abortController&&=(this._abortController.abort(),null),this._disposeTexture(),this._subdividedMesh?.destroy(),this._subdividedMesh=null,this.image=null,this.tiles={}}setWarp(e){return this._warp===e||(this._warp=e,this.tileCoords&&this.setCoordinates(this.coordinates)),this}getWarp(){return this._warp}setCoordinates(e){this.coordinates=e;let t=this.map.style.projection.worldCoordinateHelper,i=e.map(e=>{let i=Kc.convert(e);return t.worldFromLngLat(i.lng,i.lat)});return this.tileID=function(e){let t=ku.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 __(a,Math.floor((t.minX+t.maxX)/2*n),Math.floor((t.minY+t.maxY)/2*n))}(i),this.terrainTileRanges=this._getOverlappingTileRanges(i),this.minzoom=this.maxzoom=this.tileID.z,this.tileCoords=i.map(e=>this.tileID.getTilePoint(e)._round()),this.imageWarp=function(e,t){if("flat"===t||H_(e))return O_;let[i,r,a,n]=e,o=i.x-r.x+a.x-n.x,s=i.y-r.y+a.y-n.y,l=[r.x-a.x,r.y-a.y,n.x-a.x,n.y-a.y],[u,h,c,d]=l,p=function(e){return e[0]*e[3]-e[2]*e[1]}(l),f=(o*d-c*s)/p,m=(u*s-o*h)/p,_=[1,1+f,1+f+m,1+m],g=Math.max(..._)/Math.min(..._),y="perspective"===t?0:function(e){let t=(1-4/e)/(1-4/512);return Math.max(0,t)}(g);return!(g>=1&&g<=512)||y>=1?O_:[f,m,y]}(this.tileCoords,this._warp),this._subdividedQuad=this.imageWarp[2]>0&&!H_(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 is("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 Fh(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 is("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(){let e={type:"image",coordinates:this.coordinates};return void 0!==this.options.url&&(e.url=this.options.url),e}hasTransition(){return!1}_getOverlappingTileRanges(e){let{minX:t,minY:i,maxX:r,maxY:a}=ku.fromPoints(e),n={};for(let o=0;o<=25;o++){let e=2**o,s=Math.floor(t*e),l=Math.floor(i*e),u=Math.floor(r*e),h=Math.floor(a*e),c=(s%e+e)%e,d=u%e,p=Math.floor(s/e),f=Math.floor(u/e);n[o]={minWrap:p,maxWrap:f,minTileXWrapped:c,maxTileXWrapped:d,minTileY:l,maxTileY:h}}return n}};function H_(e){let[t,i,r,a]=e;return t.x+r.x===i.x+a.x&&t.y+r.y===i.y+a.y}var X_,Y_,K_=class extends W_{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");zt(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 Bt(ne(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 Bt(new ti(`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 Fh(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 is("data",{sourceDataType:"idle",sourceId:this.id}))}serialize(){return{type:"video",urls:this.urls,coordinates:this.coordinates}}hasTransition(){return this.video&&!this.video.paused}},J_=class extends W_{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 Bt(new ti(`sources.${e}`,null,'"coordinates" property must be an array of 4 longitude/latitude array pairs'))):this.fire(new Bt(new ti(`sources.${e}`,null,'missing required property "coordinates"'))),t.animate&&"boolean"!=typeof t.animate&&this.fire(new Bt(new ti(`sources.${e}`,null,'optional "animate" property must be a boolean value'))),t.canvas?"string"!=typeof t.canvas&&!(t.canvas instanceof HTMLCanvasElement)&&this.fire(new Bt(new ti(`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 Bt(new ti(`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 Bt(/* @__PURE__ */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 Fh(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 is("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}},Q_={},eg=e=>{switch(e){case"geojson":return B_;case"image":return W_;case"raster":return f_;case"raster-dem":return w_;case"vector":return p_;case"video":return K_;case"canvas":return J_}return Q_[e]},tg=async(e,t)=>{if(eg(e))throw Error(`A source type called "${e}" already exists.`);((e,t)=>{Q_[e]=t})(e,t)},ig="_geojsonTileLayer",rg=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]}},ag=class e{static{this.worldCoordinateHelpers=/* @__PURE__ */new WeakMap}constructor(t,i,r,a,n,o){this.type="Feature",this._vectorTileFeature=t,this._x=r,this._y=a,this._z=i,o!==ud&&e.worldCoordinateHelpers.set(this,o);for(let e in t.properties)"string"==typeof t.properties[e]&&t.properties[e].startsWith("__$json__:")&&(t.properties[e]=JSON.parse(t.properties[e].slice(10)));this.properties=t.properties,this.id=n}projectPoint(e,t,i,r,a){if(a){let n=a.lngLatFromWorld((e.x+t)/r,(e.y+i)/r);return[n.lng,n.lat]}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,a){return e.map(e=>this.projectPoint(e,t,i,r,a))}get geometry(){if(this._geometry)return this._geometry;let t=this._vectorTileFeature,i=e.worldCoordinateHelpers.get(this),r=t.extent*2**this._z,a=t.extent*this._x,n=t.extent*this._y,o=t.loadGeometry();switch(t.type){case 1:{let e=[];for(let i of o)e.push(i[0]);let t=this.projectLine(e,a,n,r,i);this._geometry=1===e.length?{type:"Point",coordinates:t[0]}:{type:"MultiPoint",coordinates:t};break}case 2:{let e=o.map(e=>this.projectLine(e,a,n,r,i));this._geometry=1===e.length?{type:"LineString",coordinates:e[0]}:{type:"MultiLineString",coordinates:e};break}case 3:{let e=Zc(o),t=[];for(let o of e)t.push(o.map(e=>this.projectLine(e,a,n,r,i)));this._geometry=1===t.length?{type:"Polygon",coordinates:t[0]}:{type:"MultiPolygon",coordinates:t};break}default:throw Error(`unknown feature type: ${t.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}},ng=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}},og=class extends ng{},sg=class extends og{getValueFromBuffer(e){return this.dataBuffer[e]}},lg=class extends og{getValueFromBuffer(e){return this.dataBuffer[e]}},ug=class extends ng{constructor(e,t,i,r){super(e,t,r),this.delta=i}},hg=class extends ug{constructor(e,t,i,r,a){super(e,a?Int32Array.of(t):Uint32Array.of(t),i,r)}getValueFromBuffer(e){return this.dataBuffer[0]+e*this.delta}},cg=class extends ng{constructor(e,t,i,r){super(e,r?Int32Array.of(t):Uint32Array.of(t),i)}getValueFromBuffer(e){return this.dataBuffer[0]}},dg=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);null!==e&&(r=this.containsMaxSafeIntegerValues(this.idVector)?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 sg||e instanceof cg||e instanceof hg||e instanceof lg}},pg=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"}(X_||={}),function(e){e.NONE="NONE",e.FAST_PFOR="FAST_PFOR",e.VARINT="VARINT"}(Y_||={});var fg=/* @__PURE__ */new Uint32Array(33);fg[0]=0;for(let bC=1;bC<=32;bC++)fg[bC]=32===bC?4294967295:4294967295>>>32-bC;var mg=fg,_g=65536;function gg(e,t){return e-e%t}function yg(e){return gg(e+31,32)}function vg(e){if(!Number.isFinite(e)||e<=0)return _g;let t=gg(Math.floor(e),256);return 0===t?256:t}function xg(e){let t=e>>>0;return((255&t)<<24|(65280&t)<<8|t>>>8&65280|t>>>24&255)>>>0}var bg,wg,Tg,Sg,Dg=vg(_g),Eg=3*Dg/256+Dg|0;function Cg(){let e=new Uint8Array(Eg);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 Pg(e,t,i,r,a){switch(a){case 1:!function(e,t,i,r){let a=r,n=t;for(let o=0;o<8;o++){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 o=0;o<8;o++){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 o=0;o<8;o++){let t=e[n++]>>>0,r=e[n++]>>>0,o=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&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);break;case 4:!function(e,t,i,r){let a=r,n=t;for(let o=0;o<8;o++){let t=e[n++]>>>0,r=e[n++]>>>0,o=e[n++]>>>0,s=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++]=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++]=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}}(e,t,i,r);break;case 5:!function(e,t,i,r){let a=r,n=t;for(let o=0;o<8;o++){let t=e[n++]>>>0,r=e[n++]>>>0,o=e[n++]>>>0,s=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&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&s)<<1),i[a++]=s>>>4&31,i[a++]=s>>>9&31,i[a++]=s>>>14&31,i[a++]=s>>>19&31,i[a++]=s>>>24&31,i[a++]=31&(s>>>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 o=0;o<8;o++){let t=e[n++]>>>0,r=e[n++]>>>0,o=e[n++]>>>0,s=e[n++]>>>0,l=e[n++]>>>0,u=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&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++]=s>>>0&63,i[a++]=s>>>6&63,i[a++]=s>>>12&63,i[a++]=s>>>18&63,i[a++]=s>>>24&63,i[a++]=63&(s>>>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&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);break;case 7:!function(e,t,i,r){let a=r,n=t;for(let o=0;o<8;o++){let t=e[n++]>>>0,r=e[n++]>>>0,o=e[n++]>>>0,s=e[n++]>>>0,l=e[n++]>>>0,u=e[n++]>>>0,h=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&o)<<1),i[a++]=o>>>6&127,i[a++]=o>>>13&127,i[a++]=o>>>20&127,i[a++]=127&(o>>>27|(3&s)<<5),i[a++]=s>>>2&127,i[a++]=s>>>9&127,i[a++]=s>>>16&127,i[a++]=s>>>23&127,i[a++]=127&(s>>>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&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&h)<<3),i[a++]=h>>>4&127,i[a++]=h>>>11&127,i[a++]=h>>>18&127,i[a++]=h>>>25&127}}(e,t,i,r);break;case 8:!function(e,t,i,r){let a=r,n=t;for(let o=0;o<8;o++){let t=e[n++]>>>0,r=e[n++]>>>0,o=e[n++]>>>0,s=e[n++]>>>0,l=e[n++]>>>0,u=e[n++]>>>0,h=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++]=o>>>0&255,i[a++]=o>>>8&255,i[a++]=o>>>16&255,i[a++]=o>>>24&255,i[a++]=s>>>0&255,i[a++]=s>>>8&255,i[a++]=s>>>16&255,i[a++]=s>>>24&255,i[a++]=l>>>0&255,i[a++]=l>>>8&255,i[a++]=l>>>16&255,i[a++]=l>>>24&255,i[a++]=u>>>0&255,i[a++]=u>>>8&255,i[a++]=u>>>16&255,i[a++]=u>>>24&255,i[a++]=h>>>0&255,i[a++]=h>>>8&255,i[a++]=h>>>16&255,i[a++]=h>>>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 o=0;o<128;o++){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=mg[a]>>>0,o=t,s=0,l=e[o]>>>0,u=r;for(let h=0;h<8;h++){for(let t=0;t<32;t++)if(s+a<=32){let r=l>>>s&n;i[u+t]=0|r,s+=a,32===s&&(s=0,o++,31!==t&&(l=e[o]>>>0))}else{let r=32-s,h=l>>>s;o++,l=e[o]>>>0;let c=a-r,d=(h|(l&-1>>>32-c>>>0)<<r)&n;i[u+t]=0|d,s=c}u+=32,s=0,h<7&&(l=e[o]>>>0)}}(e,t,i,r,a)}return t+(a<<3)|0}function Ag(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 Ig(e,t,i,r,a,n,o,s,l){let{maxBits:u,exceptionBitWidth:h,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 o=e[i++];if(o<r||o>32)throw Error(`FastPFOR decode: invalid maxBits=${o} at block=${n} (bitWidth=${r}, expected ${r}..32)`);let s=o-r|0;if(s<1||s>32)throw Error(`FastPFOR decode: invalid exceptionBitWidth=${s} at block=${n} (bitWidth=${r}, maxBits=${o})`);if(i+a>t)throw Error(`FastPFOR decode: exception positions underflow at block=${n} (need=${a}, have=${t-i})`);return{maxBits:o,exceptionBitWidth:s,bytePosIn:i}}(a,n,o,i,r,l);if(o=c,1===h){let n=1<<i;for(let i=0;i<r;i=i+1|0)e[a[o++]+t|0]|=n;return o}let d=s.dataToBePacked[h];if(!d)throw Error(`FastPFOR decode: missing exception stream for exceptionBitWidth=${h} (bitWidth=${i}, maxBits=${u}) at block ${l}`);let p=s.dataPointers,f=0|p[h],m=0|s.exceptionSizes[h];if(f+r>m)throw Error(`FastPFOR decode: exception stream overflow for exceptionBitWidth=${h} (ptr=${f}, need ${r}, size=${m}) at block ${l}`);for(let _=0;_<r;_=_+1|0){let r=a[o++],n=0|d[f++];e[r+t|0]|=n<<i}return p[h]=f,o}function Mg(e,t,i,r,a,n){let o=0|i,s=0|e[o];if(s<=0||o+s>e.length-1)throw Error(`FastPFOR decode: invalid whereMeta=${s} at pageStart=${o} (expected > 0 and pageStart+whereMeta < encoded.length=${e.length})`);let l=o+1|0,u=o+s|0,h=e[u]>>>0,c=h+3>>>2,d=u+1,p=d+c;if(p>=e.length)throw Error(`FastPFOR decode: invalid byteSize=${h} (metaInts=${c}, pageStart=${o}, packedEnd=${u}, byteContainerStart=${d}) causes bitmapPos=${p} 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 s=0;s<n;s=s+1|0){let i=0|e[t+s|0],r=s<<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 o=3&i;if(o>0){let i=0|e[t+n|0],r=n<<2;for(let e=0;e<o;e=e+1|0)a[r+e|0]=i>>>(e<<3)&255}return a}(e,d,h,n),m=h,_=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 o=e[t++]>>>0,s=yg(o),l=o*n+31>>>5;if(t+l>e.length)throw Error(`FastPFOR decode: truncated exception stream (bitWidth=${n}, size=${o}, streamWordIndex=${t}, needWords=${l}, availableWords=${e.length-t}, encodedWords=${e.length})`);let u=a[n];(!u||u.length<s)&&(u=a[n]=new Uint32Array(s));let h=0;for(;h<o;h=h+32|0)Fg(e,t,u,h,n),t=t+n|0;t=t-((h-o|0)*n>>>5)|0,i.exceptionSizes[n]=o}return t}(e,p,n);return n.dataPointers.fill(0),function(e,t,i,r,a,n,o,s,l,u){let h=0|i,c=0;for(let d=0;d<o;d=d+1|0){let t=Ag(s,l,c,d);c=t.bytePosIn;let i=t.bitWidth,r=t.exceptionCount,o=n+256*d|0;switch(i){case 0:a.fill(0,o,o+256);break;case 32:for(let t=0;t<256;t=t+1|0)a[o+t|0]=0|e[h+t|0];h=h+256|0;break;default:h=Pg(e,h,a,o,i)}r>0&&(c=Ig(a,o,i,r,s,l,c,u,d))}if(h!==r)throw Error(`FastPFOR decode: packed region mismatch (pageStart=${t}, packedStart=${i}, consumedPackedEnd=${h}, expectedPackedEnd=${r}, packedWords=${r-i}, encoded.length=${e.length})`)}(e,o,l,u,t,0|r,a/256|0,f,m,n),_}function Fg(e,t,i,r,a){switch(a){case 2:return void function(e,t,i,r){let a=r,n=e[t]>>>0,o=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++]=o>>>0&3,i[a++]=o>>>2&3,i[a++]=o>>>4&3,i[a++]=o>>>6&3,i[a++]=o>>>8&3,i[a++]=o>>>10&3,i[a++]=o>>>12&3,i[a++]=o>>>14&3,i[a++]=o>>>16&3,i[a++]=o>>>18&3,i[a++]=o>>>20&3,i[a++]=o>>>22&3,i[a++]=o>>>24&3,i[a++]=o>>>26&3,i[a++]=o>>>28&3,i[a]=o>>>30&3}(e,t,i,r);case 3:return void function(e,t,i,r){let a=r,n=e[t]>>>0,o=e[t+1]>>>0,s=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&o)<<2),i[a++]=o>>>1&7,i[a++]=o>>>4&7,i[a++]=o>>>7&7,i[a++]=o>>>10&7,i[a++]=o>>>13&7,i[a++]=o>>>16&7,i[a++]=o>>>19&7,i[a++]=o>>>22&7,i[a++]=o>>>25&7,i[a++]=o>>>28&7,i[a++]=7&(o>>>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);case 4:return void function(e,t,i,r){let a=r,n=e[t]>>>0,o=e[t+1]>>>0,s=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++]=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++]=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++]=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,o=e[t+1]>>>0,s=e[t+2]>>>0,l=e[t+3]>>>0,u=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&o)<<2),i[a++]=o>>>3&31,i[a++]=o>>>8&31,i[a++]=o>>>13&31,i[a++]=o>>>18&31,i[a++]=o>>>23&31,i[a++]=31&(o>>>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&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&u)<<3),i[a++]=u>>>2&31,i[a++]=u>>>7&31,i[a++]=u>>>12&31,i[a++]=u>>>17&31,i[a++]=u>>>22&31,i[a]=u>>>27&31}(e,t,i,r);case 6:return void function(e,t,i,r){let a=r,n=e[t]>>>0,o=e[t+1]>>>0,s=e[t+2]>>>0,l=e[t+3]>>>0,u=e[t+4]>>>0,h=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&o)<<2),i[a++]=o>>>4&63,i[a++]=o>>>10&63,i[a++]=o>>>16&63,i[a++]=o>>>22&63,i[a++]=63&(o>>>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++]=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&u)<<2),i[a++]=u>>>4&63,i[a++]=u>>>10&63,i[a++]=u>>>16&63,i[a++]=u>>>22&63,i[a++]=63&(u>>>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);case 7:return void function(e,t,i,r){let a=r,n=e[t]>>>0,o=e[t+1]>>>0,s=e[t+2]>>>0,l=e[t+3]>>>0,u=e[t+4]>>>0,h=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&o)<<4),i[a++]=o>>>3&127,i[a++]=o>>>10&127,i[a++]=o>>>17&127,i[a++]=o>>>24&127,i[a++]=127&(o>>>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&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&u)<<2),i[a++]=u>>>5&127,i[a++]=u>>>12&127,i[a++]=u>>>19&127,i[a++]=127&(u>>>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&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,o=e[t+1]>>>0,s=e[t+2]>>>0,l=e[t+3]>>>0,u=e[t+4]>>>0,h=e[t+5]>>>0,c=e[t+6]>>>0,d=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++]=o>>>0&255,i[a++]=o>>>8&255,i[a++]=o>>>16&255,i[a++]=o>>>24&255,i[a++]=s>>>0&255,i[a++]=s>>>8&255,i[a++]=s>>>16&255,i[a++]=s>>>24&255,i[a++]=l>>>0&255,i[a++]=l>>>8&255,i[a++]=l>>>16&255,i[a++]=l>>>24&255,i[a++]=u>>>0&255,i[a++]=u>>>8&255,i[a++]=u>>>16&255,i[a++]=u>>>24&255,i[a++]=h>>>0&255,i[a++]=h>>>8&255,i[a++]=h>>>16&255,i[a++]=h>>>24&255,i[a++]=c>>>0&255,i[a++]=c>>>8&255,i[a++]=c>>>16&255,i[a++]=c>>>24&255,i[a++]=d>>>0&255,i[a++]=d>>>8&255,i[a++]=d>>>16&255,i[a]=d>>>24&255}(e,t,i,r);case 9:return void function(e,t,i,r){let a=r,n=e[t]>>>0,o=e[t+1]>>>0,s=e[t+2]>>>0,l=e[t+3]>>>0,u=e[t+4]>>>0,h=e[t+5]>>>0,c=e[t+6]>>>0,d=e[t+7]>>>0,p=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&o)<<5),i[a++]=o>>>4&511,i[a++]=o>>>13&511,i[a++]=o>>>22&511,i[a++]=511&(o>>>31|(255&s)<<1),i[a++]=s>>>8&511,i[a++]=s>>>17&511,i[a++]=511&(s>>>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&u)<<2),i[a++]=u>>>7&511,i[a++]=u>>>16&511,i[a++]=511&(u>>>25|(3&h)<<7),i[a++]=h>>>2&511,i[a++]=h>>>11&511,i[a++]=h>>>20&511,i[a++]=511&(h>>>29|(63&c)<<3),i[a++]=c>>>6&511,i[a++]=c>>>15&511,i[a++]=511&(c>>>24|(1&d)<<8),i[a++]=d>>>1&511,i[a++]=d>>>10&511,i[a++]=d>>>19&511,i[a++]=511&(d>>>28|(31&p)<<4),i[a++]=p>>>5&511,i[a++]=p>>>14&511,i[a]=p>>>23&511}(e,t,i,r);case 10:return void function(e,t,i,r){let a=r,n=e[t]>>>0,o=e[t+1]>>>0,s=e[t+2]>>>0,l=e[t+3]>>>0,u=e[t+4]>>>0,h=e[t+5]>>>0,c=e[t+6]>>>0,d=e[t+7]>>>0,p=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&o)<<2),i[a++]=o>>>8&1023,i[a++]=o>>>18&1023,i[a++]=1023&(o>>>28|(63&s)<<4),i[a++]=s>>>6&1023,i[a++]=s>>>16&1023,i[a++]=1023&(s>>>26|(15&l)<<6),i[a++]=l>>>4&1023,i[a++]=l>>>14&1023,i[a++]=1023&(l>>>24|(3&u)<<8),i[a++]=u>>>2&1023,i[a++]=u>>>12&1023,i[a++]=u>>>22&1023,i[a++]=h>>>0&1023,i[a++]=h>>>10&1023,i[a++]=h>>>20&1023,i[a++]=1023&(h>>>30|(255&c)<<2),i[a++]=c>>>8&1023,i[a++]=c>>>18&1023,i[a++]=1023&(c>>>28|(63&d)<<4),i[a++]=d>>>6&1023,i[a++]=d>>>16&1023,i[a++]=1023&(d>>>26|(15&p)<<6),i[a++]=p>>>4&1023,i[a++]=p>>>14&1023,i[a++]=1023&(p>>>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,o=e[t+1]>>>0,s=e[t+2]>>>0,l=e[t+3]>>>0,u=e[t+4]>>>0,h=e[t+5]>>>0,c=e[t+6]>>>0,d=e[t+7]>>>0,p=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&o)<<10),i[a++]=o>>>1&2047,i[a++]=o>>>12&2047,i[a++]=2047&(o>>>23|(3&s)<<9),i[a++]=s>>>2&2047,i[a++]=s>>>13&2047,i[a++]=2047&(s>>>24|(7&l)<<8),i[a++]=l>>>3&2047,i[a++]=l>>>14&2047,i[a++]=2047&(l>>>25|(15&u)<<7),i[a++]=u>>>4&2047,i[a++]=u>>>15&2047,i[a++]=2047&(u>>>26|(31&h)<<6),i[a++]=h>>>5&2047,i[a++]=h>>>16&2047,i[a++]=2047&(h>>>27|(63&c)<<5),i[a++]=c>>>6&2047,i[a++]=c>>>17&2047,i[a++]=2047&(c>>>28|(127&d)<<4),i[a++]=d>>>7&2047,i[a++]=d>>>18&2047,i[a++]=2047&(d>>>29|(255&p)<<3),i[a++]=p>>>8&2047,i[a++]=p>>>19&2047,i[a++]=2047&(p>>>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,o=e[t+1]>>>0,s=e[t+2]>>>0,l=e[t+3]>>>0,u=e[t+4]>>>0,h=e[t+5]>>>0,c=e[t+6]>>>0,d=e[t+7]>>>0,p=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&o)<<8),i[a++]=o>>>4&4095,i[a++]=o>>>16&4095,i[a++]=4095&(o>>>28|(255&s)<<4),i[a++]=s>>>8&4095,i[a++]=s>>>20&4095,i[a++]=l>>>0&4095,i[a++]=l>>>12&4095,i[a++]=4095&(l>>>24|(15&u)<<8),i[a++]=u>>>4&4095,i[a++]=u>>>16&4095,i[a++]=4095&(u>>>28|(255&h)<<4),i[a++]=h>>>8&4095,i[a++]=h>>>20&4095,i[a++]=c>>>0&4095,i[a++]=c>>>12&4095,i[a++]=4095&(c>>>24|(15&d)<<8),i[a++]=d>>>4&4095,i[a++]=d>>>16&4095,i[a++]=4095&(d>>>28|(255&p)<<4),i[a++]=p>>>8&4095,i[a++]=p>>>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,o=e[t+1]>>>0,s=e[t+2]>>>0,l=e[t+3]>>>0,u=e[t+4]>>>0,h=e[t+5]>>>0,c=e[t+6]>>>0,d=e[t+7]>>>0,p=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++]=o>>>0&65535,i[a++]=o>>>16&65535,i[a++]=s>>>0&65535,i[a++]=s>>>16&65535,i[a++]=l>>>0&65535,i[a++]=l>>>16&65535,i[a++]=u>>>0&65535,i[a++]=u>>>16&65535,i[a++]=h>>>0&65535,i[a++]=h>>>16&65535,i[a++]=c>>>0&65535,i[a++]=c>>>16&65535,i[a++]=d>>>0&65535,i[a++]=d>>>16&65535,i[a++]=p>>>0&65535,i[a++]=p>>>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=mg[a]>>>0,o=t,s=0,l=e[o]>>>0;for(let u=0;u<32;u++)if(s+a<=32){let t=l>>>s&n;i[r+u]=0|t,s+=a,32===s&&(s=0,o++,31!==u&&(l=e[o]>>>0))}else{let t=32-s,h=l>>>s;o++,l=e[o]>>>0;let c=(h|(l&mg[a-t]>>>0)<<t)&n;i[r+u]=0|c,s=a-t}}function zg(e,t,i){let r=new Uint32Array(i),a=0,n=t.get();for(let o=0;o<r.length;o++){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 kg(e,t,i){let r=new BigUint64Array(i);for(let a=0;a<r.length;a++)r[a]=Rg(e,t);return r}function Rg(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 Lg(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 Bg(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 o=i>>>2,s=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,o);!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,o=n?a+1:a;if(r.length<o)throw RangeError(`decodeBigEndianInt32sInto: out.length=${r.length} < ${o}`);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|xg(t[e])}}if(n){let n=t+4*a,o=i-4*a,s=0;for(let t=0;t<o;t++)s|=e[n+t]<<24-8*t;r[a]=0|s}}(e,n,i,s);let l=function(e,t,i){let r=0,a=0,n=new Uint32Array(t),o=i??Cg();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 o=r+gg(a,256),s=r,l=i;for(;s!==o;){let i=Math.min(Dg,o-s);l=Mg(e,t,l,s,i,n),s=s+i|0}return l}(e,n,r,a,t,o),a=a+t|0}return function(e,t,i,r,a,n){if(0===n)return t;let o=0,s=t,l=t+i,u=a,h=a,c=a+n,d=0,p=0;for(;s<l&&h<c;){let t=e[s]>>>o&255;if(o+=8,s+=o>>>5,o&=31,d|=(127&t)<<p,128&t)r[h++]=0|d,d=0,p=0;else if(p+=7,p>28)throw Error(`FastPFOR VByte: unterminated value (expected MSB=1 terminator within 5 bytes; shift=${p}, partial=${d}, decoded=${h-u}/${n}, inPos=${s}, inEnd=${l})`)}if(h!==c)throw Error(`FastPFOR VByte: truncated stream (decoded=${h-u}, expected=${n}, consumedWords=${s-t}/${i}, vbyteStart=${t}, vbyteEnd=${l})`)}(e,r,e.length-r|0,n,a,t-a|0),n}(s.subarray(0,o),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:Cg()}}(i>>>2))}function Og(e){return e>>>1^-(1&e)}function jg(e){return e>>1n^-(1n&e)}function Vg(e){return e%2==1?(e+1)/-2:e/2}function Ng(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],o=e[n+t];r.fill(o,a,a+i),a+=i}return r}function Ug(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]),o=e[n+t];r.fill(o,a,a+i),a+=i}return r}function $g(e,t,i){let r=new Float64Array(i),a=0;for(let n=0;n<t;n++){let i=e[n],o=e[n+t];r.fill(o,a,a+i),a+=i}return r}function Gg(e){let t=new Int32Array(e.length);t[0]=Og(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],o=e[r+3];t[r]=Og(i)+t[r-1],t[r+1]=Og(a)+t[r],t[r+2]=Og(n)+t[r+1],t[r+3]=Og(o)+t[r+2]}for(;r!==e.length;++r)t[r]=Og(e[r])+t[r-1];return t}function Zg(e){let t=new BigInt64Array(e.length);t[0]=jg(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],o=e[r+3];t[r]=jg(i)+t[r-1],t[r+1]=jg(a)+t[r],t[r+2]=jg(n)+t[r+1],t[r+3]=jg(o)+t[r+2]}for(;r!==t.length;++r)t[r]=jg(e[r])+t[r-1];return t}function qg(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 Wg(e,t,i,r){if(e.length<2)return new Int32Array(e);let a=new Int32Array(e.length),n=Og(e[0]),o=Og(e[1]);a[0]=Hg(Math.round(n*t),i,r),a[1]=Hg(Math.round(o*t),i,r);let s=e.length/16,l=2;if(s>=4)for(;l<s-4;l+=4){let s=e[l],u=e[l+1],h=Og(s)+n,c=Og(u)+o;a[l]=Hg(Math.round(h*t),i,r),a[l+1]=Hg(Math.round(c*t),i,r);let d=e[l+2],p=e[l+3];n=Og(d)+h,o=Og(p)+c,a[l+2]=Hg(Math.round(n*t),i,r),a[l+3]=Hg(Math.round(o*t),i,r)}for(;l!==e.length;l+=2)n+=Og(e[l]),o+=Og(e[l+1]),a[l]=Hg(Math.round(n*t),i,r),a[l+1]=Hg(Math.round(o*t),i,r);return a}function Hg(e,t,i){return Math.min(i,Math.max(t,e))}function Xg(e){let t=new Uint32Array(e.length);t[0]=Og(e[0])>>>0;for(let i=1;i<e.length;i++)t[i]=t[i-1]+Og(e[i])>>>0;return t}function Yg(e){let t=new BigUint64Array(e.length);t[0]=BigInt.asUintN(64,jg(e[0]));for(let i=1;i<e.length;i++)t[i]=BigInt.asUintN(64,t[i-1]+jg(e[i]));return t}!function(e){e.PRESENT="PRESENT",e.DATA="DATA",e.OFFSET="OFFSET",e.LENGTH="LENGTH"}(bg||={}),function(e){e.NONE="NONE",e.SINGLE="SINGLE",e.SHARED="SHARED",e.VERTEX="VERTEX",e.MORTON="MORTON",e.FSST="FSST"}(wg||={}),function(e){e.VERTEX="VERTEX",e.INDEX="INDEX",e.STRING="STRING",e.KEY="KEY"}(Tg||={}),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"}(Sg||={});var Kg,Jg=[bg.PRESENT,bg.DATA,bg.OFFSET,bg.LENGTH],Qg=[X_.NONE,X_.DELTA,X_.COMPONENTWISE_DELTA,X_.RLE,X_.MORTON],ey=[Y_.NONE,Y_.FAST_PFOR,Y_.VARINT],ty=[wg.NONE,wg.SINGLE,wg.SHARED,wg.VERTEX,wg.MORTON,wg.FSST],iy=[Tg.VERTEX,Tg.INDEX,Tg.STRING,Tg.KEY],ry=[Sg.VAR_BINARY,Sg.GEOMETRIES,Sg.PARTS,Sg.RINGS,Sg.TRIANGLES,Sg.SYMBOL,Sg.DICTIONARY];function ay(e,t){let i=function(e,t){let i=e[t.get()],r=Jg[i>>4],a={};switch(r){case bg.DATA:a={dictionaryType:ty[15&i]};break;case bg.OFFSET:a={offsetType:iy[15&i]};break;case bg.LENGTH:a={lengthType:ry[15&i]}}t.increment();let n=e[t.get()],o=Qg[n>>5],s=Qg[n>>2&7],l=ey[3&n];t.increment();let u=zg(e,t,2),h=u[0];return{physicalStreamType:r,logicalStreamType:a,logicalLevelTechnique1:o,logicalLevelTechnique2:s,physicalLevelTechnique:l,numValues:h,byteLength:u[1],decompressedCount:h}}(e,t);return i.logicalLevelTechnique1===X_.MORTON?function(e,t,i){let r=zg(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):X_.RLE!==i.logicalLevelTechnique1&&X_.RLE!==i.logicalLevelTechnique2||Y_.NONE===i.physicalLevelTechnique?i:function(e,t,i){let r=zg(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"}(Kg||={});var ny=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 oy(e,t,i){if(!t)return e;let r=t.size(),a=new(0,e.constructor)(r),n=0;for(let o=0;o<r;o++)a[o]=t.get(o)?e[n++]:i;return a}function sy(e,t,i){for(let r=0;r<e;r++){let e=ay(t,i);i.add(e.byteLength)}}function ly(e,t,i,r,a){let n=function(e,t,i,r){let a=new Uint8Array(t),n=0,o=r.get()+i;for(;n<t&&!(r.get()>=o);){let i=e[r.increment()];if(i<=127){let o=i+3,s=e[r.increment()],l=Math.min(n+o,t);a.fill(s,n,l),n=l}else{let o=256-i;for(let i=0;i<o&&n<t;i++)a[n++]=e[r.increment()]}}return r.set(o),a}(e,Math.ceil(t/8),i,r);return a?function(e,t,i){if(!i)return e;let r=i.size(),a=new ny(e,t),n=new ny(new Uint8Array(Math.ceil(r/8)),r),o=0;for(let s=0;s<r;s++){let e=!!i.get(s)&&a.get(o++);n.set(s,e)}return n.getBuffer()}(n,t,a):n}function uy(e,t,i,r){let a=t.get(),n=a+i*Float32Array.BYTES_PER_ELEMENT,o=new Uint8Array(e.subarray(a,n)).buffer,s=new Float32Array(o);return t.set(n),r?oy(s,r,0):s}function hy(e,t,i,r){let a=t.get(),n=a+i*Float64Array.BYTES_PER_ELEMENT,o=new Uint8Array(e.subarray(a,n)).buffer,s=new Float64Array(o);return t.set(n),r?oy(s,r,0):s}var cy=new TextDecoder;function dy(e,t,i){return i-t>=12?cy.decode(e.subarray(t,i)):function(e,t,i){let r="",a=t;for(;a<i;){let t,n,o,s=e[a],l=null,u=s>239?4:s>223?3:s>191?2:1;if(a+u>i)break;1===u?s<128&&(l=s):2===u?(t=e[a+1],128==(192&t)&&(l=(31&s)<<6|63&t,l<=127&&(l=null))):3===u?(t=e[a+1],n=e[a+2],128==(192&t)&&128==(192&n)&&(l=(15&s)<<12|(63&t)<<6|63&n,(l<=2047||l>=55296&&l<=57343)&&(l=null))):4===u&&(t=e[a+1],n=e[a+2],o=e[a+3],128==(192&t)&&128==(192&n)&&128==(192&o)&&(l=(15&s)<<18|(63&t)<<12|(63&n)<<6|63&o,(l<=65535||l>=1114112)&&(l=null))),null===l?(l=65533,u=1):l>65535&&(l-=65536,r+=String.fromCharCode(l>>>10&1023|55296),l=56320|1023&l),r+=String.fromCharCode(l),a+=u}return r}(e,t,i)}function py(e,t,i,r,a){return function(e,t,i,r){let a;switch(t.logicalLevelTechnique1){case X_.DELTA:if(t.logicalLevelTechnique2===X_.RLE){let i=t;if(!r)return function(e,t,i){let r=new Int32Array(i),a=0,n=0;for(let o=0;o<t;o++){let i=e[o],s=Og(e[o+t]);for(let e=0;e<i;e++)n+=s,r[a++]=n}return r}(e,i.runs,i.numRleValues);a=Gg(e=Ng(e,i.runs,i.numRleValues))}else a=Gg(e);break;case X_.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],o=e[n+t];o=Og(o),r.fill(o,a,a+i),a+=i}return r}(e,t.runs,t.numRleValues);break;case X_.MORTON:qg(e),a=new Int32Array(e);break;case X_.COMPONENTWISE_DELTA:if(i&&!r)return Wg(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]=Og(e[0]),t[1]=Og(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],o=e[r+3];t[r]=Og(i)+t[r-2],t[r+1]=Og(a)+t[r-1],t[r+2]=Og(n)+t[r],t[r+3]=Og(o)+t[r+1]}for(;r!==e.length;r+=2)t[r]=Og(e[r])+t[r-2],t[r+1]=Og(e[r+1])+t[r-1];return t}(e);break;case X_.NONE:a=function(e){let t=new Int32Array(e.length);for(let i=0;i<e.length;i++)t[i]=Og(e[i]);return t}(e);break;default:throw Error(`The specified Logical level technique is not supported: ${t.logicalLevelTechnique1}`)}return r?oy(a,r,0):a}(_y(e,t,i),i,r,a)}function fy(e,t,i,r,a){return function(e,t,i,r){let a;switch(t.logicalLevelTechnique1){case X_.DELTA:if(t.logicalLevelTechnique2===X_.RLE){let i=t;a=Xg(Ng(e,i.runs,i.numRleValues))}else a=Xg(e);break;case X_.RLE:a=Ng(e,t.runs,t.numRleValues);break;case X_.MORTON:qg(e),a=e;break;case X_.COMPONENTWISE_DELTA:a=i&&!r?function(e,t,i,r){let a=Wg(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]=Og(e[0])>>>0,t[1]=Og(e[1])>>>0;for(let i=2;i<e.length;i+=2)t[i]=t[i-2]+Og(e[i])>>>0,t[i+1]=t[i-1]+Og(e[i+1])>>>0;return t}(e);break;case X_.NONE:a=e;break;default:throw Error(`The specified Logical level technique is not supported: ${t.logicalLevelTechnique1}`)}return r?oy(a,r,0):a}(_y(e,t,i),i,r,a)}function my(e,t,i){return function(e,t){if(t.logicalLevelTechnique1===X_.DELTA&&t.logicalLevelTechnique2===X_.NONE)return function(e){let t=new Int32Array(e.length+1);t[0]=0,t[1]=Og(e[0]);let i=t[1];for(let r=2;r!==t.length;++r)i+=Og(e[r-1]),t[r]=t[r-1]+i;return new Uint32Array(t)}(e);if(t.logicalLevelTechnique1===X_.RLE&&t.logicalLevelTechnique2===X_.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 o=0;o<t;o++){let i=e[o],s=e[o+t];for(let e=a;e<a+i;e++)r[e]=s+n,n=r[e];a+=i}return r}(e,i.runs,i.numRleValues)}if(t.logicalLevelTechnique1===X_.NONE&&t.logicalLevelTechnique2===X_.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===X_.DELTA&&t.logicalLevelTechnique2===X_.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 o=0;o<t;o++){let i=e[o],s=e[o+t];s=Og(s);for(let e=a;e<a+i;e++)r[e]=s+n,n=r[e];a+=i}return r}(e,i.runs,i.numRleValues);return qg(r),new Uint32Array(r)}throw Error("Only delta encoding is supported for transforming length to offset streams yet.")}(_y(e,t,i),i)}function _y(e,t,i){let r=i.physicalLevelTechnique;switch(r){case Y_.FAST_PFOR:return Bg(e,i.numValues,i.byteLength,t);case Y_.VARINT:return zg(e,t,i.numValues);case Y_.NONE:return function(e,t,i){let r=t.get(),a=i*Uint32Array.BYTES_PER_ELEMENT,n=new DataView(e.buffer,e.byteOffset,e.byteLength),o=new Uint32Array(i);for(let s=0;s<i;s++)o[s]=n.getUint32(r+s*Uint32Array.BYTES_PER_ELEMENT,!0);return t.add(a),o}(e,t,i.numValues);default:throw Error(`Specified physicalLevelTechnique ${r} is not supported (yet).`)}}function gy(e,t,i){let r=i.physicalLevelTechnique;switch(r){case Y_.VARINT:return kg(e,t,i.numValues);case Y_.NONE:return function(e,t,i){let r=t.get(),a=i*BigUint64Array.BYTES_PER_ELEMENT,n=new DataView(e.buffer,e.byteOffset,e.byteLength),o=new BigUint64Array(i);for(let s=0;s<i;s++)o[s]=n.getBigUint64(r+s*BigUint64Array.BYTES_PER_ELEMENT,!0);return t.add(a),o}(e,t,i.numValues);default:throw Error(`Specified physicalLevelTechnique ${r} is not supported (yet).`)}}function yy(e,t,i){let r=_y(e,t,i);return 1===r.length?i.logicalLevelTechnique1===X_.DELTA?Og(r[0]):r[0]:function(e){return e[1]}(r)}function vy(e,t,i){return function(e){if(2===e.length){let t=Og(e[1]);return[t,t]}return[Og(e[2]),Og(e[3])]}(_y(e,t,i))}function xy(e,t,i){return function(e){if(2===e.length){let t=jg(e[1]);return[t,t]}return[jg(e[2]),jg(e[3])]}(kg(e,t,i.numValues))}function by(e,t,i,r){return Sy(gy(e,t,i),i,r)}function wy(e,t,i,r){return Dy(gy(e,t,i),i,r)}function Ty(e,t,i){let r=gy(e,t,i);return 1===r.length?i.logicalLevelTechnique1===X_.DELTA?jg(r[0]):r[0]:function(e){return e[1]}(r)}function Sy(e,t,i){let r;switch(t.logicalLevelTechnique1){case X_.DELTA:if(t.logicalLevelTechnique2===X_.RLE){let a=t;if(!i)return function(e,t,i){let r=new BigInt64Array(i),a=0,n=0n;for(let o=0;o<t;o++){let i=Number(e[o]),s=jg(e[o+t]);for(let e=0;e<i;e++)n+=s,r[a++]=n}return r}(e,a.runs,a.numRleValues);r=Zg(e=Ug(e,a.runs,a.numRleValues))}else r=Zg(e);break;case X_.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]),o=e[n+t];o=jg(o),r.fill(o,a,a+i),a+=i}return r}(e,t.runs,t.numRleValues);break;case X_.NONE:r=function(e){let t=new BigInt64Array(e.length);for(let i=0;i<e.length;i++)t[i]=jg(e[i]);return t}(e);break;default:throw Error(`The specified Logical level technique is not supported: ${t.logicalLevelTechnique1}`)}return i?oy(r,i,0n):r}function Dy(e,t,i){let r;switch(t.logicalLevelTechnique1){case X_.DELTA:if(t.logicalLevelTechnique2===X_.RLE){let i=t;r=Yg(Ug(e,i.runs,i.numRleValues))}else r=Yg(e);break;case X_.RLE:r=Ug(e,t.runs,t.numRleValues);break;case X_.NONE:r=e;break;default:throw Error(`The specified Logical level technique is not supported: ${t.logicalLevelTechnique1}`)}return i?oy(r,i,0n):r}function Ey(e,t,i,r,a="int32"){let n=e.logicalLevelTechnique1;if(n===X_.RLE)return 1===e.runs?Kg.CONST:Kg.FLAT;if(n!==X_.DELTA||e.logicalLevelTechnique2!==X_.RLE)return 1===e.numValues?Kg.CONST:Kg.FLAT;let o=t instanceof ny?t.size():t,s=e;if(s.numRleValues!==o)return Kg.FLAT;if(1===s.runs)return Kg.SEQUENCE;if(2!==s.runs)return 1===e.numValues?Kg.CONST:Kg.FLAT;let l=r.get();if(e.physicalLevelTechnique===Y_.VARINT)return function(e,t,i){let r=new pg(t.get());if("int64"===i){let t=kg(e,r,4);return 2n===t[2]&&2n===t[3]}let a=zg(e,r,4);return 2===a[2]&&2===a[3]}(i,r,a)?Kg.SEQUENCE:1===e.numValues?Kg.CONST:Kg.FLAT;let u=r.get(),h=new Int32Array(i.buffer,i.byteOffset+u,4);return r.set(l),2===h[2]&&2===h[3]?Kg.SEQUENCE:1===e.numValues?Kg.CONST:Kg.FLAT}var Cy,Py,Ay,Iy=class extends og{getValueFromBuffer(e){return this.dataBuffer[e]}},My=class extends ug{constructor(e,t,i,r,a){super(e,a?BigInt64Array.of(t):BigUint64Array.of(t),i,r)}getValueFromBuffer(e){return this.dataBuffer[0]+BigInt(e)*this.delta}};function Fy(e,t,i){return{x:zy(e,t)-i,y:zy(e>>1,t)-i}}function zy(e,t){let i=0;for(let r=0;r<t;r++)i|=(e&1<<2*r)>>r;return i}function ky(e,t,i,r,a,n,o){return e===Ay.MORTON?function(e,t,i,r,a,n){let o=Array(a?r+1:r);for(let s=0;s<r;s++){let r=Fy(e[t[i+s]],n.numBits,n.coordinateShift);o[s]=new d(r.x,r.y)}return a&&(o[o.length-1]=o[0]),o}(t,i,r,a,n,o):function(e,t,i,r,a){let n=Array(a?r+1:r);for(let o=0;o<2*r;o+=2){let r=2*t[i+o/2],a=e[r],s=e[r+1];n[o/2]=new d(a,s)}return a&&(n[n.length-1]=n[0]),n}(t,i,r,a,n)}function Ry(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 d(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"}(Cy||={}),function(e){e[e.POINT=0]="POINT",e[e.LINESTRING=1]="LINESTRING",e[e.POLYGON=2]="POLYGON"}(Py||={}),function(e){e[e.MORTON=0]="MORTON",e[e.VEC_2=1]="VEC_2",e[e.VEC_3=2]="VEC_3"}(Ay||={});var Ly=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=Fy(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,o=0,s=0,l=e.mortonSettings,u=e.topologyVector,h=u.geometryOffsets,c=u.partOffsets,p=u.ringOffsets,f=e.vertexOffsets,m=!f||0===f.length,_=e.containsPolygonGeometry(),g=e.vertexBuffer;for(let y=0;y<e.numGeometries;y++){let u=e.geometryType(y);switch(u){case Cy.POINT:{let u,_;if(m)u=g[o++],_=g[o++];else if(e.vertexBufferType===Ay.MORTON){let e=Fy(g[f[s++]],l.numBits,l.coordinateShift);u=e.x,_=e.y}else{let e=2*f[s++];u=g[e],_=g[e+1]}t[n++]=[[new d(u,_)]],h&&a++,c&&i++,p&&r++}break;case Cy.MULTIPOINT:{let u,c=h[a]-h[a-1];if(a++,m){u=Array(c);for(let e=0;e<c;e++){let t=g[o++],i=g[o++];u[e]=new d(t,i)}}else u=ky(e.vertexBufferType,g,f,s,c,!1,l),s+=c;t[n++]=u.map(e=>[e]),i+=c,r+=c}break;case Cy.LINESTRING:{let u,d;_?(u=p[r]-p[r-1],r++):u=c[i]-c[i-1],i++,m?(d=Ry(g,o,u,!1),o+=2*u):(d=ky(e.vertexBufferType,g,f,s,u,!1,l),s+=u),t[n++]=[d],h&&a++}break;case Cy.POLYGON:{let u=c[i]-c[i-1];i++;let d,_=Array(u-1),y=p[r]-p[r-1];if(r++,m){d=Ry(g,o,y,!0),o+=2*y;for(let e=0;e<_.length;e++)y=p[r]-p[r-1],r++,_[e]=Ry(g,o,y,!0),o+=2*y}else{d=ky(e.vertexBufferType,g,f,s,y,!0,l),s+=y;for(let t=0;t<_.length;t++)y=p[r]-p[r-1],r++,_[t]=ky(e.vertexBufferType,g,f,s,y,!0,l),s+=y}t[n++]=[d].concat(_),h&&a++}break;case Cy.MULTILINESTRING:{let u=h[a]-h[a-1];a++;let d=Array(u);for(let t=0;t<u;t++){let a;if(_?(a=p[r]-p[r-1],r++):a=c[i]-c[i-1],i++,m)d[t]=Ry(g,o,a,!1),o+=2*a;else{let i=ky(e.vertexBufferType,g,f,s,a,!1,l);d[t]=i,s+=a}}t[n++]=d}break;case Cy.MULTIPOLYGON:{let u=h[a]-h[a-1];a++;let d=Array(u);for(let t=0;t<u;t++){let a=c[i]-c[i-1];i++;let n,u=Array(a-1),h=p[r]-p[r-1];r++,m?(n=Ry(g,o,h,!0),o+=2*h):(n=ky(e.vertexBufferType,g,f,s,h,!0,l),s+=h);for(let t=0;t<u.length;t++){let i=p[r]-p[r-1];r++,m?(u[t]=Ry(g,o,i,!0),o+=2*i):(u[t]=ky(e.vertexBufferType,g,f,s,i,!0,l),s+=i)}d[t]=[n].concat(u)}t[n++]=d.flat()}break;default:throw Error(`The specified geometry type (${u}) is currently not supported.`)}}return t}(this)}get mortonSettings(){return this._mortonSettings}},By=class extends Ly{constructor(e,t,i,r,a,n,o){super(i,r,a,n,o),this._numGeometries=e,this._geometryType=t}geometryType(e){return this._geometryType}get numGeometries(){return this._numGeometries}containsPolygonGeometry(){return this._geometryType===Cy.POLYGON||this._geometryType===Cy.MULTIPOLYGON}containsSingleGeometryType(){return!0}};function Oy(e,t,i,r){return new jy(Ay.VEC_2,e,t,i,r)}var jy=class extends Ly{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)===Cy.POLYGON||this.geometryType(e)===Cy.MULTIPOLYGON)return!0;return!1}containsSingleGeometryType(){return!1}},Vy=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=new Uint32Array(this.numGeometries);for(let t=0;t<this.numGeometries;t++)e[t]=this.geometryType(t);return Oy(e,this._topologyVector,void 0,this._vertexBuffer).getGeometries()}[Symbol.iterator](){return null}};function Ny(e,t,i,r,a,n){return new Uy(e,t,i,r,a,n)}var Uy=class extends Vy{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 $y(e,t,i,r,a){return new Gy(e,t,i,r,a)}var Gy=class extends Vy{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 Zy(e,t,i,r,a){let n,o,s,l,u=ay(e,i);if(Ey(u,r,e,i)===Kg.CONST){let h,c,d,p,f=yy(e,i,u);for(let r=0;r<t-1;r++){let t=ay(e,i);switch(t.physicalStreamType){case bg.LENGTH:switch(t.logicalStreamType.lengthType){case Sg.GEOMETRIES:h=my(e,i,t);break;case Sg.PARTS:c=my(e,i,t);break;case Sg.RINGS:d=my(e,i,t);break;case Sg.TRIANGLES:p=my(e,i,t)}break;case bg.OFFSET:switch(t.logicalStreamType.offsetType){case Tg.VERTEX:n=fy(e,i,t);break;case Tg.INDEX:l=fy(e,i,t)}break;case bg.DATA:if(wg.VERTEX===t.logicalStreamType.dictionaryType)o=py(e,i,t,a);else{let r=t;s={numBits:r.numBits,coordinateShift:r.coordinateShift},o=fy(e,i,t,a)}}}return l?void 0!==h||void 0!==c?Ny(r,f,p,l,o,{geometryOffsets:h,partOffsets:c,ringOffsets:d}):Ny(r,f,p,l,o):void 0===s?function(e,t,i,r,a){return new By(e,t,Ay.VEC_2,i,r,a)}(r,f,{geometryOffsets:h,partOffsets:c,ringOffsets:d},n,o):function(e,t,i,r,a,n){return new By(e,t,Ay.MORTON,i,r,a,n)}(r,f,{geometryOffsets:h,partOffsets:c,ringOffsets:d},n,o,s)}let h,c,d,p,f,m,_,g=fy(e,i,u);for(let y=0;y<t-1;y++){let t=ay(e,i);switch(t.physicalStreamType){case bg.LENGTH:switch(t.logicalStreamType.lengthType){case Sg.GEOMETRIES:h=fy(e,i,t);break;case Sg.PARTS:c=fy(e,i,t);break;case Sg.RINGS:d=fy(e,i,t);break;case Sg.TRIANGLES:p=my(e,i,t)}break;case bg.OFFSET:switch(t.logicalStreamType.offsetType){case Tg.VERTEX:n=fy(e,i,t);break;case Tg.INDEX:l=fy(e,i,t)}break;case bg.DATA:if(wg.VERTEX===t.logicalStreamType.dictionaryType)o=py(e,i,t,a);else{let r=t;s={numBits:r.numBits,coordinateShift:r.coordinateShift},o=fy(e,i,t,a)}}}return h?(f=qy(g,h,2),c&&d?(m=Wy(g,f,c,!1),_=function(e,t,i,r){let a=new Uint32Array(i[i.length-1]+1),n=0;a[0]=n;let o=1,s=1,l=0;for(let u=0;u<e.length;u++){let h=e[u],c=t[u+1]-t[u];if(0!==h&&3!==h)for(let e=0;e<c;e++){let e=i[o]-i[o-1];o++;for(let t=0;t<e;t++)n=a[s++]=n+r[l++]}else for(let e=0;e<c;e++)a[s++]=++n,o++}return a}(g,f,m,d)):c&&(m=function(e,t,i){let r=new Uint32Array(t[t.length-1]+1),a=0;r[0]=a;let n=1,o=0;for(let s=0;s<e.length;s++){let l=e[s],u=t[s+1]-t[s];if(4===l||1===l)for(let e=0;e<u;e++)a=r[n++]=a+i[o++];else for(let e=0;e<u;e++)r[n++]=++a}return r}(g,f,c))):c&&d?(m=qy(g,c,1),_=Wy(g,m,d,!0)):c&&(m=qy(g,c,0)),l&&!m?$y(g,p,l,o):l?$y(g,p,l,o,{geometryOffsets:f,partOffsets:m,ringOffsets:_}):void 0===s?Oy(g,{geometryOffsets:f,partOffsets:m,ringOffsets:_},n,o):function(e,t,i,r,a){return new jy(Ay.MORTON,e,t,i,r,a)}(g,{geometryOffsets:f,partOffsets:m,ringOffsets:_},n,o,s)}function qy(e,t,i){let r=new Uint32Array(e.length+1),a=0;r[0]=a;let n=0;for(let o=0;o<e.length;o++)a=r[o+1]=a+(e[o]>i?t[n++]:1);return r}function Wy(e,t,i,r){let a=new Uint32Array(t[t.length-1]+1),n=0;a[0]=n;let o=1,s=0;for(let l=0;l<e.length;l++){let u=e[l],h=t[l+1]-t[l];if(5===u||2===u||r&&(4===u||1===u))for(let e=0;e<h;e++)n=a[o++]=n+i[s++];else for(let e=0;e<h;e++)a[o++]=++n}return a}var Hy=class extends ng{constructor(e,t,i){super(e,t.getBuffer(),i),this.dataVector=t}getValueFromBuffer(e){return this.dataVector.get(e)}},Xy=class extends og{getValueFromBuffer(e){return this.dataBuffer[e]}},Yy=class extends ng{constructor(e,t,i,r){super(e,r?BigInt64Array.of(t):BigUint64Array.of(t),i)}getValueFromBuffer(e){return this.dataBuffer[0]}},Ky=class extends ng{constructor(e,t,i,r){super(e,i,r),this.offsetBuffer=t}},Jy=class extends Ky{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 dy(this.dataBuffer,t,i)}},Qy=class extends Ky{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 dy(this.dataBuffer,i,r)}},ev=class extends Ky{constructor(e,t,i,r,a,n,o,s){super(e,i,r,o??t.length),this.indexBuffer=t,this.symbolOffsetBuffer=a,this.symbolTableBuffer=n,this.sharedDictionaryCache=s}getValueFromBuffer(e){this.decodedDictionary??(this.decodedDictionary=this.sharedDictionaryCache?.decodedDictionary,this.decodedDictionary??(this.decodedDictionary=this.decodeDictionary(),this.sharedDictionaryCache&&(this.sharedDictionaryCache.decodedDictionary=this.decodedDictionary)));let t=this.indexBuffer[e],i=this.offsetBuffer[t],r=this.offsetBuffer[t+1];return dy(this.decodedDictionary,i,r)}decodeDictionary(){return this.symbolLengthBuffer??=this.offsetToLengthBuffer(this.symbolOffsetBuffer),function(e,t,i){let r=new Uint32Array(t.length);for(let o=1;o<t.length;o++)r[o]=r[o-1]+t[o-1];let a=new Uint8Array(function(e,t){let i=0;for(let r=0;r<t.length;r++){let a=t[r];255===a?(i++,r++):i+=e[a]}return i}(t,i)),n=0;for(let o=0;o<i.length;o++){let s=i[o];if(255===s)o++,a[n++]=i[o];else{let i=t[s],o=r[s];for(;i-- >0;)a[n++]=e[o++]}}return a}(this.symbolTableBuffer,this.symbolLengthBuffer,this.dataBuffer)}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 tv(e,t,i,r,a){let n,o,s,l,u,h,c,d=a;for(let p=0;p<r;p++){let e=ay(t,i);switch(e.physicalStreamType){case bg.PRESENT:{let r=new ny(ly(t,e.numValues,e.byteLength,i),e.numValues);d=a??r;break}case bg.OFFSET:o=fy(t,i,e,void 0,d);break;case bg.LENGTH:{let r=my(t,i,e);Sg.DICTIONARY===e.logicalStreamType.lengthType?n=r:Sg.SYMBOL===e.logicalStreamType.lengthType?l=r:h=r;break}case bg.DATA:{let r=t.subarray(i.get(),i.get()+e.byteLength);i.add(e.byteLength);let a=e.logicalStreamType.dictionaryType;wg.FSST===a?u=r:wg.SINGLE===a||wg.SHARED===a?s=r:wg.NONE===a&&(c=r);break}}}return function(e,t,i,r,a,n,o){if(t){if(!(i&&r&&a&&n))throw Error(`Incomplete FSST dictionary string column "${e}"`);return new ev(e,i,r,a,n,t,o)}}(e,u,o,n,s,l,d)??function(e,t,i,r,a){if(t){if(!i||!r)throw Error(`Incomplete dictionary string column "${e}"`);return a?new Qy(e,i,r,t,a):new Qy(e,i,r,t)}}(e,s,o,n,d)??function(e,t,i,r,a){if(t&&i){if(r)return a?new Qy(e,r,t,i,a):new Qy(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 Qy(e,r,t,i,a)}return a?new Jy(e,t,i,a):new Jy(e,t,i)}}(e,h,c,o,d)}var iv,rv,av=class extends ng{constructor(e,t,i){super(e,/* @__PURE__ */new Uint8Array,i??t.length),this.values=t}getValueFromBuffer(e){return this.values[e]}};function nv(e,t,i,r,a){let n,{lengthStream:o,flattenedValues:s,presentStream:l,dictionary:u}=e,h=t*i,c=i;if(l){n=new ny(new Uint8Array(Math.ceil(i/8)),i),c=0;for(let e=0;e<i;e++)l.get(h+e)&&(n.set(e,!0),c++)}let d=r+c;if(d>o.length)throw Error("Merged map counts underflow while decoding child streams");let p=Array(i),f=r,m=a;for(let y=0;y<i;y++){if(l&&!l.get(h+y)){p[y]=null;continue}let e=m+o[f++];if(e>s.length)throw Error("Map value stream underflow while decoding feature payload");let t=ov(s,m,e,u);p[y]=t.value,m=t.nextIndex}let _=0;for(let y=r;y<d;y++)_+=o[y];let g=a+_;if(m!==g)throw Error("Unused flattened map values remain after decode");return{value:p,nullabilityBuffer:n,countsEnd:d,valuesEnd:g}}function ov(e,t,i,r){return i-t===1||e[t]===rv.START_LIST?lv(e,t,i,r):sv(e,t,i,r)}function sv(e,t,i,r){let a=Object.create(null),n=t;for(;n<i;){let t=hv(e[n++],r);if("string"!=typeof t)throw Error(`Map key dictionary index does not resolve to a string: ${t}`);let o=lv(e,n,i,r);a[t]=o.value,n=o.nextIndex}return{value:a,nextIndex:n}}function lv(e,t,i,r){if(t>=i)throw Error("Unexpected end of map value stream");let a=e[t];if(a===rv.FALSE)return{value:!1,nextIndex:t+1};if(a===rv.TRUE)return{value:!0,nextIndex:t+1};if(a===rv.START_MAP){let a=uv(e,t,i);return{value:sv(e,t+2,a,r).value,nextIndex:a}}if(a===rv.START_LIST){let a=uv(e,t,i),n=[],o=t+2;for(;o<a;){let t=lv(e,o,a,r);n.push(t.value),o=t.nextIndex}return{value:n,nextIndex:a}}return{value:hv(a,r),nextIndex:t+1}}function uv(e,t,i){if(t+1>=i)throw Error("Missing length for nested map/list payload");let r=e[t+1];if(r<2)throw Error(`Invalid nested payload length: ${r}`);let a=t+r;if(a>i)throw Error("Nested payload exceeds containing payload bounds");return a}function hv(e,t){let i=e-rv.COUNT;if(i<0||i>=t.length)throw Error(`Scalar dictionary index out of range: ${e}`);return t[i]}function cv(e,t){for(let i of t)e.push(i)}function dv(e,t,i,r,a,n){return"scalarType"===i.type?n&&!n.has(i.name)?(sy(r,e,t),null):function(e,t,i,r,a,n){let o;if(0===e)return null;if(n.nullable){let e=ay(t,i),r=e.numValues,a=i.get(),n=ly(t,r,e.byteLength,i);i.set(a+e.byteLength),o=new ny(n,e.numValues)}let s=o??r;switch(a.physicalType){case 4:case 3:return function(e,t,i,r,a){let n=ay(e,t),o=Ey(n,a,e,t),s=3===r.physicalType;if(o===Kg.FLAT){let r=pv(a)?a:void 0,o=s?py(e,t,n,void 0,r):fy(e,t,n,void 0,r);return new sg(i.name,o,a)}if(o===Kg.SEQUENCE){let r=vy(e,t,n);return new hg(i.name,r[0],r[1],n.numRleValues,s)}let l=s?function(e,t,i){let r=_y(e,t,i);return 1===r.length?Og(r[0]):function(e){return Og(e[1])}(r)}(e,t,n):yy(e,t,n);return new cg(i.name,l,a,s)}(t,i,n,a,s);case 9:{let r=n.nullable?e-1:e;return tv(n.name,t,i,r,o)??null}case 0:return function(e,t,i,r,a){let n=ay(e,t),o=n.numValues,s=t.get(),l=pv(a)?a:void 0,u=ly(e,o,n.byteLength,t,l);t.set(s+n.byteLength);let h=new ny(u,o);return new Hy(i.name,h,a)}(t,i,n,0,s);case 6:case 5:return function(e,t,i,r,a){let n=ay(e,t),o=Ey(n,r,e,t,"int64"),s=5===a.physicalType;if(o===Kg.FLAT){let a=pv(r)?r:void 0,o=s?by(e,t,n,a):wy(e,t,n,a);return new Iy(i.name,o,r)}if(o===Kg.SEQUENCE){let r=xy(e,t,n);return new My(i.name,r[0],r[1],n.numRleValues,s)}let l=s?function(e,t,i){let r=gy(e,t,i);return 1===r.length?jg(r[0]):function(e){return jg(e[1])}(r)}(e,t,n):Ty(e,t,n);return new Yy(i.name,l,r,s)}(t,i,n,s,a);case 7:return function(e,t,i,r){let a=ay(e,t),n=pv(r)?r:void 0,o=uy(e,t,a.numValues,n);return new Xy(i.name,o,r)}(t,i,n,s);case 8:return function(e,t,i,r){let a=ay(e,t),n=pv(r)?r:void 0,o=hy(e,t,a.numValues,n);return new lg(i.name,o,r)}(t,i,n,s);default:throw Error(`The specified data type for the field is currently not supported: ${a}`)}}(r,e,t,a,i.scalarType,i):2===i.complexType?.physicalType?function(e,t,i,r){let a=function(e){let t="complexType"===e.type?e.complexType.children:void 0;return t&&0!==t.length?t.map(t=>e.name+(t.name??"")):[e.name]}(i);if(0===r)return a.map(e=>new av(e,[]));let n=function(e,t,i){let r=e[t.get()];t.add(1);let a=fy(e,t,ay(e,t)),n=i-1,o=[];r&iv.STRING&&(n-=function(e,t,i){let r=e[t.get()];t.add(1);let a=tv("",e,t,r);if(a)for(let n=0;n<a.size;n++)i.push(a.getValue(n));return r}(e,t,o)),n-=function(e,t,i,r){let a=0;return i&iv.INT32?(cv(r,py(e,t,ay(e,t))),a++):i&iv.INT64&&(cv(r,by(e,t,ay(e,t))),a++),i&iv.UINT32?(cv(r,fy(e,t,ay(e,t))),a++):i&iv.UINT64&&(cv(r,wy(e,t,ay(e,t))),a++),a}(e,t,r,o),n-=function(e,t,i,r){let a=0;return i&iv.FLOAT&&(cv(r,uy(e,t,ay(e,t).numValues)),a++),i&iv.DOUBLE&&(cv(r,hy(e,t,ay(e,t).numValues)),a++),a}(e,t,r,o);let s,l=0;if(r&iv.PRESENCE){let i=function(e,t){let i=ay(e,t);if(i.physicalStreamType!==bg.PRESENT)throw Error(`Expected PRESENT stream for map column but found: ${i.physicalStreamType}`);let r=i.numValues,a=t.get(),n=new ny(ly(e,r,i.byteLength,t),r);return t.set(a+i.byteLength),{value:n,count:r}}(e,t);s=i.value,l=i.count,n--}let u=/* @__PURE__ */new Uint32Array;if(n>0&&(u=fy(e,t,ay(e,t)),n--),0!==n)throw Error(`Unexpected number of remaining streams while decoding map column: ${n}`);return{lengthStream:a,dictionary:o,presentStream:s,presentCount:l,flattenedValues:u}}(e,t,r),o=(n.presentStream?n.presentCount:n.lengthStream.length)/a.length,s=[],l=0,u=0;for(let h=0;h<a.length;h++){let e=nv(n,h,o,l,u);s.push(new av(a[h],e.value,e.nullabilityBuffer)),l=e.countsEnd,u=e.valuesEnd}return s}(e,t,i,r):0===r?null:function(e,t,i,r){let a,n,o,s,l=!1;for(;!l;){let i=ay(e,t);switch(i.physicalStreamType){case bg.LENGTH:Sg.DICTIONARY===i.logicalStreamType.lengthType?a=my(e,t,i):o=my(e,t,i);break;case bg.DATA:wg.SINGLE===i.logicalStreamType.dictionaryType||wg.SHARED===i.logicalStreamType.dictionaryType?(n=e.subarray(t.get(),t.get()+i.byteLength),l=!0):s=e.subarray(t.get(),t.get()+i.byteLength),t.add(i.byteLength)}}if("complexType"!==i.type)throw Error(`Shared dictionary column ${i.name} must be a complex (struct) column.`);if(!a||!n)throw Error(`Incomplete shared dictionary for column "${i.name}"`);let u=i.complexType.children,h=[],c=s?{}:void 0,d=0;for(let p of u){let l=zg(e,t,1)[0];if(0===l)continue;let u,f=p.name?`${i.name}${p.name}`:i.name;if(r&&!r.has(f)){sy(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=ay(e,t);u=new ny(ly(e,i.numValues,i.byteLength,t),i.numValues)}let m=fy(e,t,ay(e,t),void 0,u);if(s){if(!o)throw Error(`Incomplete shared FSST dictionary for column "${f}"`);h[d++]=new ev(f,m,a,n,o,s,u,c)}else h[d++]=new Qy(f,m,a,n,u)}return h}(e,t,i,n)}function pv(e){return e instanceof ny}!function(e){e[e.STRING=1]="STRING",e[e.INT32=2]="INT32",e[e.UINT32=4]="UINT32",e[e.INT64=8]="INT64",e[e.UINT64=16]="UINT64",e[e.FLOAT=32]="FLOAT",e[e.DOUBLE=64]="DOUBLE",e[e.PRESENCE=128]="PRESENCE"}(iv||={}),function(e){e[e.FALSE=0]="FALSE",e[e.TRUE=1]="TRUE",e[e.START_MAP=2]="START_MAP",e[e.START_LIST=3]="START_LIST",e[e.COUNT=4]="COUNT"}(rv||={});function fv(e){switch(e){case 0:case 1:case 2:case 3:return{nullable:!!(1&e),columnScope:0,type:"scalarType",scalarType:{longID:!!(2&e),type:"logicalType",logicalType:0}};case 4:return{nullable:!1,columnScope:0,type:"complexType",complexType:{type:"physicalType",physicalType:0,children:[]}};case 30:return{nullable:!1,columnScope:0,type:"complexType",complexType:{type:"physicalType",physicalType:1,children:[]}};case 31:return{nullable:!0,columnScope:0,type:"complexType",complexType:{type:"physicalType",physicalType:2,children:[]}};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}return{nullable:!!(1&e),columnScope:0,type:"scalarType",scalarType:{longID:!1,type:"physicalType",physicalType:t}}}(e)}}function mv(e){return 30===e||31===e}function _v(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:case 2:return!0;default:return!1}}return console.warn("Unexpected column type in hasStreamCount",e),!1}function gv(e){return"scalarType"===e.type&&"logicalType"===e.scalarType?.type&&0===e.scalarType.logicalType}function yv(e){return"complexType"===e.type&&"physicalType"===e.complexType?.type&&0===e.complexType.physicalType}var vv=new TextDecoder,xv="0-3(ID), 4(GEOMETRY), 10-29(scalars), 30(STRUCT), 31(MAP)";function bv(e,t){let i=zg(e,t,1)[0];if(0===i)return"";let r=t.get(),a=r+i,n=e.subarray(r,a);return t.add(i),vv.decode(n)}function wv(e,t){let i=zg(e,t,1)[0]>>>0,r=i>=10?fv(i):null;if(!r)throw Error(`Unsupported field type code ${i}. Supported: 10-29(scalars), 30(STRUCT), 31(MAP)`);let a={...r,name:bv(e,t)};if("complexType"===a.type&&mv(i)){let i=a.complexType,r=zg(e,t,1)[0]>>>0;i.children=Array(r);for(let a=0;a<r;a++)i.children[a]=wv(e,t)}return function(e){let t=e.name,i=e.nullable;return"scalarType"===e.type?{type:"scalarField",scalarField:e.scalarType,name:t,nullable:i}:{type:"complexField",complexField:e.complexType,name:t,nullable:i}}(a)}function Tv(e,t){let i,r=zg(e,t,1)[0]>>>0,a=fv(r);if(!a)throw Error(`Unsupported column type code ${r}. Supported: ${xv}`);if(function(e){return e>=10}(r))i=bv(e,t);else if(r<4)i="id";else{if(4!==r)throw Error(`Unsupported column type code ${r}. Supported: ${xv}`);i="geometry"}let n={...a,name:i};if("complexType"===n.type&&mv(r)){let i=zg(e,t,1)[0]>>>0,r=n.complexType;r.children=Array(i);for(let a=0;a<i;a++)r.children[a]=wv(e,t)}return n}function Sv(e,t){let i={featureTables:[]},r={};if(r.name=bv(e,t),0===r.name.length)throw Error("Missing layer name");let a=zg(e,t,1)[0]>>>0,n=zg(e,t,1)[0]>>>0;r.columns=Array(n);for(let o=0;o<n;o++)r.columns[o]=Tv(e,t);return i.featureTables.push(r),[i,a]}function Dv(e,t,i,r,a,n,o=!1){let s=t.scalarType?.longID?6:4,l="number"==typeof n?void 0:n,u=Ey(a,n,e,i,6===s?"int64":"int32");if(4===s)switch(u){case Kg.FLAT:return new sg(r,fy(e,i,a,void 0,l),n);case Kg.SEQUENCE:{let t=vy(e,i,a);return new hg(r,t[0],t[1],a.numRleValues,!1)}case Kg.CONST:return new cg(r,yy(e,i,a),n,!1)}switch(u){case Kg.FLAT:return o?new lg(r,function(e,t,i,r){let a=function(e,t,i){if(i.physicalLevelTechnique===Y_.VARINT)return function(e,t){switch(t.logicalLevelTechnique1){case X_.DELTA:if(t.logicalLevelTechnique2===X_.RLE){let i=t;e=$g(e,i.runs,i.numRleValues)}return function(e){e[0]=Vg(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]=Vg(t)+e[i-1],e[i+1]=Vg(r)+e[i],e[i+2]=Vg(a)+e[i+1],e[i+3]=Vg(n)+e[i+2]}for(;i!==e.length;++i)e[i]=Vg(e[i])+e[i-1]}(e),e;case X_.RLE:return function(e,t){return $g(e,t.runs,t.numRleValues)}(e,t);case X_.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]=Lg(e,t);return r}(e,t,i.numValues),i);let r=Dy(gy(e,t,i),i);return Float64Array.from(r,Number)}(e,t,i);return r?oy(a,r,0):a}(e,i,a,l),n):new Iy(r,wy(e,i,a,l),n);case Kg.SEQUENCE:{let t=xy(e,i,a);return new My(r,t[0],t[1],a.numRleValues,!1)}case Kg.CONST:return new Yy(r,Ty(e,i,a),n,!1)}throw Error("Vector type not supported for id column.")}vg(_g);var Ev=class{constructor(e,t){switch(this._featureData=e,this.properties=this._featureData.properties||{},this._featureData.geometry?.type){case Cy.POINT:case Cy.MULTIPOINT:this.type=1;break;case Cy.LINESTRING:case Cy.MULTILINESTRING:this.type=2;break;case Cy.POLYGON:case Cy.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 d(e.x,e.y));e.push(i)}return e}},Cv=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 Ev(this.features[e],this.extent)}},Pv=class{constructor(e){this.layers={};let t=function(e,t,i=!0){let r=new pg(0),a=[];for(;r.get()<e.length;){let n=zg(e,r,1)[0]>>>0,o=r.get()+n;if(o>e.length)throw Error(`Block overruns tile: ${o} > ${e.length}`);let s=zg(e,r,1)[0]>>>0;if(1!==s&&2!==s){r.set(o);continue}let[l,u]=Sv(e,r),h=l.featureTables[0],c=null,d=null,p=[],f=0;for(let a of h.columns){let n=a.name;if(gv(a)){let t=null;if(a.nullable){let i=ay(e,r),a=r.get(),n=ly(e,i.numValues,i.byteLength,r);r.set(a+i.byteLength),t=new ny(n,i.numValues)}let o=ay(e,r);f=t?t.size():o.decompressedCount,c=Dv(e,a,r,n,o,t??f,i)}else if(yv(a)){let i=zg(e,r,1)[0];if(0===f){let t=r.get();f=ay(e,r).decompressedCount,r.set(t)}t&&(t.scale=t.extent/u),d=Zy(e,i,r,f,t)}else{let t=_v(a)?zg(e,r,1)[0]:1;if(0===t)continue;let i=dv(e,r,a,t,f,void 0);if(i)if(Array.isArray(i))for(let e of i)p.push(e);else p.push(i)}}let m=new dg(h.name,d,c,p,u);a.push(m),r.set(o)}return a}(new Uint8Array(e));this.layers=t.reduce((e,t)=>({...e,[t.name]:new Cv(t)}),{})}};function Av(e,t,i,r,a){return ze(e,(e,n)=>{let o=t instanceof Ds?t.get(n):null;return function(e){return"object"==typeof e&&!!e&&"evaluate"in e}(o)?o.evaluate(i,r,void 0,a):o})}function Iv(e,t){return t-e}Po("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 jt(re,16,0),this.grid3D=new jt(re,16,0),this.featureIndexArray=new Cl,this.promoteId=t}insert(e,t,i,r,a,n){let o=this.featureIndexArray.length;this.featureIndexArray.emplaceBack(i,r,a);let s=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&&s.insert(o,e[0],e[1],e[2],e[3])}}loadVTLayers(){return this.vtLayers||("mlt"===this.encoding?this.vtLayers=new Pv(this.rawTileData).layers:this.vtLayers=new Xc(new rf(this.rawTileData)).layers,this.sourceLayerCoder=new rg(this.vtLayers?Object.keys(this.vtLayers).sort():[ig])),this.vtLayers}query(e,t,i,r){this.loadVTLayers();let a=e.params,n=re/e.tileSize/e.scale,o=Fn(a.filter,"queryRenderedFeatures filter",a.globalState),s=e.queryGeometry,l=e.queryPadding*n,u=ku.fromPoints(s),h=this.grid.query(u.minX-l,u.minY-l,u.maxX+l,u.maxY+l),c=ku.fromPoints(e.cameraQueryGeometry).expandBy(l),d=this.grid3D.query(c.minX,c.minY,c.maxX,c.maxY,(t,i,r,a)=>Qu(e.cameraQueryGeometry,t-l,i-l,r+l,a+l));for(let m of d)h.push(m);h.sort(Iv);let p,f={};for(let m of h){if(m===p)continue;p=m;let l=this.featureIndexArray.get(m),u=null;this.loadMatchingFeature(f,l.bucketIndex,l.sourceLayerIndex,l.featureIndex,o,a.layers,a.availableImages,t,i,e.transform.worldCoordinateHelper,r,(t,i,r)=>(u||=Fu(t),i.queryIntersectsFeature({queryGeometry:s,feature:t,featureState:r,geometry:u,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,o,s,l,u,h,c){let d=this.bucketLayerIDs[t];if(n&&!d.some(e=>n.has(e)))return;let p=this.sourceLayerCoder.decode(i),f=this.vtLayers[p].feature(r);if(a.needGeometry){let e=zu(f,!0);if(!a.filter(new gs(this.tileID.overscaledZ),e,this.tileID.canonical))return}else if(!a.filter(new gs(this.tileID.overscaledZ),f))return;let m=this.getId(f,p);for(let _ of d){if(n&&!n.has(_))continue;let t=s[_];if(!t)continue;let i={};m&&h&&(i=h.getState(t.sourceLayer||"_geojsonTileLayer",m));let a=Ee({},l[_]);a.paint=Av(a.paint,t.paint,f,i,o),a.layout=Av(a.layout,t.layout,f,i,o);let d=!c||c(f,t,i);if(!d)continue;let p=new ag(f,this.z,this.x,this.y,m,u);p.layer=a;let g=e[_];void 0===g&&(g=e[_]=[]),g.push({featureIndex:r,feature:p,intersectionZ:d})}}lookupSymbolFeatures(e,t,i,r,a,n,o,s){let l={};this.loadVTLayers();let u=Fn(a.filterSpec,"queryRenderedFeatures symbol filter",a.globalState);for(let h of e)this.loadMatchingFeature(l,i,r,h,u,n,o,s,t,a.worldCoordinateHelper);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 Mv="RTLPluginLoaded",Fv=class extends Ot{constructor(){super(),this.status="unavailable",this.url=null,this.dispatcher=Yo(),this.dispatcher.on("workerscreate",()=>this._resyncWorkers())}async _resyncWorkers(){try{"deferred"===this.status?await this._syncState("deferred"):"loaded"===this.status&&await this._requestImport()}catch(i){Oe(`Failed to load the RTL text plugin into the new workers: ${i}`)}}_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=ht.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 Lt(Mv))}lazyLoad(){"unavailable"===this.status?this.status="requested":"deferred"===this.status&&this._requestImport()}},zv=null;function kv(){return zv||=new Fv,zv}var Rv=class{constructor(e,t){this.timeAdded=0,this.fadeEndTime=0,this.fadeOpacity=1,this.tileID=e,this.uid=Ae(),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||0!==this.fadingDirection||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=dt(),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}}releaseRTTStack(e,t){let i=this.rttObjects[t];i&&(e.releaseRTT(i),this.rttObjects[t]=void 0)}loadVectorData(e,t,i){if(!0===e?.etagUnmodified)this.state="loaded";else 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),this.hasSymbolBuckets=!1;for(let e in this.buckets){let t=this.buckets[e];if(t instanceof xm){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 xm&&t.hasRTLText){this.hasRTLText=!0,kv().lazyLoad();break}}this.queryPadding=0;for(let e in this.buckets){let i=this.buckets[e];this.queryPadding=Math.max(this.queryPadding,t.getLayer(e).queryRadius(i))}e.imageAtlas&&(this.imageAtlas=e.imageAtlas),e.glyphAtlasImage&&(this.glyphAtlasImage=e.glyphAtlasImage),this.dashPositions=e.dashPositions}else this.collisionBoxArray=new gl}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 Fh(e,this.imageAtlas.image,t.RGBA),this.imageAtlas.uploaded=!0),this.glyphAtlasImage&&=(this.glyphAtlasTexture=new Fh(e,this.glyphAtlasImage,t.ALPHA),null)}prepare(e){this.imageAtlas&&this.imageAtlas.patchUpdatedImages(e,this.imageAtlasTexture)}queryRenderedFeatures(e,t,i,r,a,n,o,s,l,u,h){return this.latestFeatureIndex?.rawTileData?this.latestFeatureIndex.query({queryGeometry:r,cameraQueryGeometry:a,scale:n,tileSize:this.tileSize,pixelPosMatrix:u,transform:s,params:o,queryPadding:this.queryPadding*l,getElevation:h},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 o=Fn(t.filter,`querySourceFeatures[${a}].filter`,t.globalState),{z:s,x:l,y:u}=this.tileID.canonical,h={z:s,x:l,y:u};for(let c=0;c<n.length;c++){let r=n.feature(c);if(o.needGeometry){let e=zu(r,!0);if(!o.filter(new gs(this.tileID.overscaledZ),e,this.tileID.canonical))continue}else if(!o.filter(new gs(this.tileID.overscaledZ),r))continue;let d=new ag(r,s,l,u,i.getId(r,a),t.worldCoordinateHelper);d.tile=h,e.push(d)}}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.hasLayer(a))continue;let i=this.buckets[a],n=i.layers[0].sourceLayer||"_geojsonTileLayer",o=r[n],s=e[n];if(!o||!s||0===s.length)continue;i.update(s,o,this.imageAtlas?.patternPositions||{},this.dashPositions||{});let l=t.getLayer(a);l&&(this.queryPadding=Math.max(this.queryPadding,l.queryRadius(i)))}}holdingForSymbolFade(){return void 0!==this.symbolFadeHoldUntil}symbolFadeFinished(){return!this.symbolFadeHoldUntil||this.symbolFadeHoldUntil<dt()}clearSymbolFadeHold(){this.symbolFadeHoldUntil=void 0}setSymbolHoldDuration(e){this.symbolFadeHoldUntil=dt()+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}},Lv=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)}};function Bv(e){let t=[];for(let i in e)t.push({id:i,state:e[i]});return t}var Ov=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]||={},Ee(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=Ee({},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]=Bv(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]||={},Ee(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{if(!this.state[a][e])continue;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]=Bv(i[a]);e.setFeatureState(r,t,this.revision)}},jv=class e{constructor(e,t){this.min=e,this.max=t,this.center=L([],k([],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}},Vv=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 o=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]],s=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=H([],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,s));a&&function(e,t,i,r){let a=r?4:0,n=r?0:4,o=0,s=[],l=[];for(let c=0;c<4;c++){let t=q([],e[c+n],e[c+a]),i=F(t);L(t,t,1/i),s.push(i),l.push(t)}for(let c=0;c<4;c++){let t=fe(e[c+a],l[c],i);o=null!==t&&t>=0?Math.max(o,t):Math.max(o,s[c])}let u=function(e,t){let i=[0,0,0,0];return j(i,N([],q([],e[t[0]],e[t[1]]),q([],e[t[2]],e[t[1]]))),i[3]=-V(i,e[t[0]]),i}(e,t),h=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/W(e)),r=q([],t,L([],i,V(t,i))),a=W(r);if(a>0){let e=Math.sqrt(1-i[3]*i[3]);return de(t,k([],L([],i,-i[3]),L([],r,e/a)))}return null}(i,u);if(null!==h){let e=h/V(l[0],u);o=Math.min(o,e)}for(let c=0;c<4;c++){let t=Math.min(o,s[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,o[0],a,n);let u=o.map(e=>{let t=j([],N([],q([],l[e[0]],l[e[1]]),q([],l[e[2]],l[e[1]]))),i=-V(t,l[e[1]]);return t.concat(i)}),h=[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++)h[t]=Math.min(h[t],e[t]),c[t]=Math.max(c[t],e[t]);return new e(l,u,new jv(h,c))}};function Nv(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 Uv(e,t,i){let r=0,a=(i-t)/10;for(let n=0;n<10;n++){let o=t+(n+.5)/10*(i-t);r+=a*Math.cos(o)**+e}return r}function $v(e,t){return function(i,r,a,n,o){let s=2*((e-1)/Me(Math.cos(qe(hd-o))/Math.cos(qe(hd)))-1),l=Math.acos(a/n),u=2*Uv(s-1,0,qe(o/2)),h=Math.min(qe(hd),l+qe(o/2)),c=Uv(s-1,Math.min(h,l-qe(o/2)),h),d=Math.atan(r/a),p=i;return p+=Me(n/Math.hypot(r,a)/Math.max(.5,Math.cos(qe(o/2)))),p+=s*Me(Math.cos(d))/2,p-=Me(Math.max(1,c/u/t))/2,p}}var Gv=$v(9.314,3);function Zv(e,t){let i=(t.roundZoom?Math.round:Math.floor)(e.zoom+Me(e.tileSize/t.tileSize));return Math.max(0,i)}function qv(e,t,i){let r=e.planes[1],a=e.points.map(e=>{let a=r[0]*e[0]+r[1]*e[1]+r[2]*e[2]+r[3];if(Math.abs(a)>1e-6)return e;let n=[e[0]-i[0],e[1]-i[1],e[2]-i[2]],o=r[0]*n[0]+r[1]*n[1]+r[2]*n[2];if(o>=-1e-9)return e;let s=t/-o;return[e[0]+n[0]*s,e[1]+n[1]*s,e[2]+n[2]*s,e[3]]}),n=e.planes.map((e,i)=>1===i?[e[0],e[1],e[2],e[3]+t]:e),o=[1/0,1/0,1/0],s=[-1/0,-1/0,-1/0];for(let l of a)for(let e=0;e<3;e++)o[e]=Math.min(o[e],l[e]),s[e]=Math.max(s[e],l[e]);return new Vv(a,n,new jv(o,s))}function Wv(e,t){let i=e.getCameraFrustum(),r=e.getClippingPlane();r&&t.maxContentElevation>0&&({frustum:i,plane:r}=function(e,t,i,r){let a=Math.hypot(t[0],t[1],t[2]);if(0===a)return{frustum:e,plane:t};let n=1+r/Yc,o=Se(-t[3]/a,-1,1),s=Math.cos(Math.acos(o)+Math.acos(1/n));return{frustum:qv(e,Math.sqrt(n*n-1),i),plane:[t[0],t[1],t[2],-s*a]}}(i,r,e.cameraPosition,t.maxContentElevation));let a=e.getCoveringTilesDetailsProvider(),n=a.getCenter(e),o=function(e,t=e.center){let i=e.worldCoordinateHelper,r=i.worldZFromAltitude(1,t),a=r*e.worldSize,n=e.cameraToCenterDistance/a;return _d(i.worldFromLngLat(t.lng,t.lat,e.elevation),e.pitch,e.bearing,n*r)}(e,n),s=e.worldCoordinateHelper.worldFromLngLat(n.lng,n.lat,e.elevation),l=function(e,t){let i=Se((15-(hd-e.pitch-e.fov/2))/15,0,1),r=Math.max(500,t??0);return e.elevation+i*r}(e,t.maxContentElevation),u=a.allowVariableZoom(e,t),h=Zv(e,t),c=t.minzoom||0,d=void 0===t.maxzoom?e.maxZoom:t.maxzoom,p=Math.min(Math.max(0,h),d),f=2**p,m=[f*o.x,f*o.y,0],_=[f*s.x,f*s.y,0],g=Math.hypot(s.x-o.x,s.y-o.y),y=Math.abs(s.z-o.z),v=Math.hypot(g,y),x=e=>({zoom:0,x:0,y:0,wrap:e,fullyVisible:!1}),b=[],w=[];if(e.renderWorldCopies&&e.worldCoordinateHelper.wraps&&a.allowWorldCopies())for(let T=1;T<=3;T++)b.push(x(-T)),b.push(x(T));for(b.push(x(0));b.length>0;){let n=b.pop(),f=n.x,g=n.y,x=n.fullyVisible,T={x:f,y:g,z:n.zoom},S=a.getTileBoundingVolume(T,n.wrap,l,t);if(!x){let e=Nv(i,S,r);if(0===e)continue;x=2===e}let D=a.distanceToTile2d(o.x,o.y,T,S),E=h;u&&(E=(t.calculateTileZoom||Gv)(e.zoom+Me(e.tileSize/t.tileSize),D,y,v,e.fov)),E=(t.roundZoom?Math.round:Math.floor)(E),E=Math.max(0,E);let C=Math.min(E,d);if(n.wrap=a.getWrap(s,T,n.wrap),n.zoom>=C){if(n.zoom<c)continue;let e=p-n.zoom,i=m[0]-.5-(f<<e),r=m[1]-.5-(g<<e),a=t.reparseOverscaled?Math.max(n.zoom,E):n.zoom;w.push({tileID:new y_(n.zoom===d?a:n.zoom,n.wrap,n.zoom,f,g),distanceSq:ie([_[0]-.5-f,_[1]-.5-g]),tileDistanceToCamera:Math.sqrt(i*i+r*r)})}else for(let e=0;e<4;e++){let t=(f<<1)+e%2,i=(g<<1)+(e>>1),r=n.zoom+1;b.push({zoom:r,x:t,y:i,wrap:n.wrap,fullyVisible:x})}}return w.sort((e,t)=>e.distanceSq-t.distanceSq).map(e=>e.tileID)}function Hv(e){return"raster"===e||"image"===e||"video"===e}function Xv(e,t,i,r,a,n,o){if(!t.hasData())return!1;let{tileID:s,fadingRole:l,fadingDirection:u,fadingParentID:h}=t;if(0===l&&1===u&&h)return i[h.key]=h,!0;let c=Math.max(s.overscaledZ-a,n);for(let d=s.overscaledZ-1;d>=c;d--){let a=s.scaledTo(d),n=e.getLoadedTile(a);if(n)return t.setCrossFadeLogic({fadingRole:0,fadingDirection:1,fadingParentID:n.tileID,fadeEndTime:r+o}),n.setCrossFadeLogic({fadingRole:1,fadingDirection:0,fadeEndTime:r+o}),i[a.key]=a,!0}return!1}function Yv(e,t,i,r,a,n){if(!t.hasData())return!1;let o=t.tileID.children(a),s=Kv(e,t,o,i,r,a,n);if(s)return!0;for(let l of o)Kv(e,t,l.children(a),i,r,a,n)&&(s=!0);return s}function Kv(e,t,i,r,a,n,o){if(i[0].overscaledZ>n)return!1;let s=!1;for(let l of i){let i=e.getLoadedTile(l);if(!i)continue;let{fadingRole:n,fadingDirection:u,fadingParentID:h}=i;(0!==n||0!==u||!h)&&(i.setCrossFadeLogic({fadingRole:0,fadingDirection:0,fadingParentID:t.tileID,fadeEndTime:a+o}),t.setCrossFadeLogic({fadingRole:1,fadingDirection:1,fadeEndTime:a+o})),r[l.key]=l,s=!0}return s}function Jv(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 Qv(e,t){e.needsHillshadePrepare=!0,e.needsTerrainPrepare=!0,e.needsColorReliefPrepare=!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 ex=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(b_).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 d(r.canonical.x,r.canonical.y)._rotate(-e),o=new d(a.canonical.x,a.canonical.y)._rotate(-e);return r.overscaledZ-a.overscaledZ||o.y-n.y||o.x-n.x}).map(e=>e.tileID.key):i.map(e=>e.tileID).sort(b_).map(e=>e.key)}},tx=class e extends Ot{static{this.maxUnderzooming=10}static{this.maxOverzooming=3}constructor(e,t,i){super(),this._maxContentElevationSeen=0,this.id=e,this.dispatcher=i,this.on("data",e=>{this._dataHandler(e)}),this.on("dataloading",()=>{this._sourceErrored=!1}),this.on("error",e=>{e.tile||(this._sourceErrored=this._source.loaded())}),this._source=((e,t,i,r)=>{let a=new(eg(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 ex,this._outOfViewCache=new Lv(0,e=>this._unloadTile(e)),this._timers={},this._maxTileCacheSize=null,this._maxTileCacheZoomLevels=null,this._rasterFadeDuration=0,this._maxFadingAncestorLevels=5,this._state=new Ov,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 ex}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 Bt(ne(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 is("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.style);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=dt(),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||Qv(e,i),!i.neighboringTiles?.[e.tileID.key]?.backfilled&&Qv(i,e)}}(e,this._inViewTiles),e.featureStateRevision=-1,this._state.initializeTileState(e,this.style),e.aborted||this._source.fire(new is("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 o=n.overscaledZ+e.maxOverzooming,s=i.filter(e=>e.tileID.overscaledZ<=o);if(!s.length){a.add(n);continue}let l=Math.min(...s.map(e=>e.tileID.overscaledZ)),u=s.filter(e=>e.tileID.overscaledZ===l).map(e=>e.tileID);for(let e of u)t[e.key]=e;this._areDescendentsComplete(u,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?Tt.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())}_updateMaxContentElevation(){let e=this._maxContentElevationSeen,t=this.map?.style?._layers;if(!t)return e;let i=this._inViewTiles.getAllTiles();for(let r in t){let a=t[r];if("symbol"!==a.type||a.source!==this.id||a.isHidden(this.transform.zoom))continue;let n=a;if(!n.layout)continue;let o=n.layout.get("symbol-height-offset");if(e=Math.max(e,o.constantOr(0)),!o.isConstant())for(let t of i){let i=t.getBucket(a);i&&i.maxHeightOffset>e&&(e=i.maxHeightOffset)}}return this._maxContentElevationSeen=e,e}update(e,t){if(!this._sourceLoaded||this._paused)return;let i;this.transform=e,this.terrain=t,this.updateCacheSize(e),this.transform.worldCoordinateHelper.wraps&&this.handleWrapJump(this.transform.center.lng),this.used||this.usedForTerrain?this._source.tileID?i=e.getVisibleUnwrappedCoordinates(this._source.tileID).map(e=>new y_(e.canonical.z,e.wrap,e.canonical.z,e.canonical.x,e.canonical.y)):(i=Wv(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,maxContentElevation:this._updateMaxContentElevation()}),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 is("data",{sourceDataType:"idle",sourceId:this.id}));let a=Zv(e,this._source),n=this._updateRetainedTiles(i,a),o=Hv(this._source.type);o&&this._rasterFadeDuration>0&&!t&&function(e,t,i,r,a,n,o){let s=dt(),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,o=[];for(let l of e){let{x:e,y:s,z:u}=l.canonical,h=2**(t-u),c=e*h,d=s*h;o.push({id:l,x:c,y:d}),c<i&&(i=c),c>r&&(r=c),d<a&&(a=d),d>n&&(n=d)}let s=/* @__PURE__ */new Set;for(let l of o)(l.x===i||l.x===r||l.y===a||l.y===n)&&s.add(l.id);return s}(t);for(let u of t){let t=e.getTileById(u.key);(0===t.fadingDirection||0===t.fadeOpacity)&&t.resetFadeLogic(),!Xv(e,t,i,s,r,a,o)&&(Yv(e,t,i,s,n,o)||Jv(t,l,s,o)||t.resetFadeLogic())}}(this._inViewTiles,i,n,this._maxFadingAncestorLevels,this._source.minzoom,this._source.maxzoom,this._rasterFadeDuration),o?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),o={},s=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>=s;--r){let n=e.scaledTo(r);if(o[n.key])break;if(o[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.style));let i=t;return t||(t=new Rv(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 is("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){"source"===e.dataType&&("metadata"===e.sourceDataType?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))}resetMaxContentElevation(){this._maxContentElevationSeen=0}clearTiles(){this._shouldReloadOnResume=!1,this._paused=!1,this.resetMaxContentElevation();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(),o=i?a.getCameraQueryGeometry(e):e,s=e=>a.screenPointToMercatorCoordinate(e,this.terrain),l=this.transformBbox(e,s,!n),u=this.transformBbox(o,s,!n),h=this.getIds(),c=ku.fromPoints(u);for(let d of h){let e=this._inViewTiles.getTileById(d);if(e.holdingForSymbolFade())continue;let i=n?[e.tileID]:[e.tileID.unwrapTo(-1),e.tileID.unwrapTo(0)],o=2**(a.zoom-e.tileID.overscaledZ),s=t*e.queryPadding*re/e.tileSize/o;for(let t of i){let i=c.map(e=>t.getTilePoint(new ld(e.x,e.y)));if(i.expandBy(s),i.intersects(Ru)){let i=l.map(e=>t.getTilePoint(e)),a=u.map(e=>t.getTilePoint(e));r.push({tile:e,tileID:n?t:t.unwrapTo(0),queryGeometry:i,cameraQueryGeometry:a,scale:o})}}}return r}transformBbox(e,t,i){let r=e.map(t);if(i){let i=ku.fromPoints(e);i.shrinkBy(.001*Math.min(i.width(),i.height()));let a=i.map(t);ku.fromPoints(r).covers(a)||(r=r.map(e=>e.x>.5?new ld(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()||Hv(this._source.type)&&function(e,t){if(t<=0)return!1;let i=dt();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||=ig,this._state.updateState(e,t,i)}removeFeatureState(e,t,i){e||=ig,this._state.removeFeatureState(e,t,i)}getFeatureState(e,t){return e||=ig,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}},ix=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=Se(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],o=i-n,s=o>0?(r-n)/o:0;return this.points[a].mult(1-s).add(this.points[t].mult(s))}};function rx(e,t,i,r,a){return a?e?e(t,i)+r:0===r?void 0:r:r}function ax(e,t){let i=!0;return"always"===e||("never"===e||"never"===t)&&(i=!1),i}var nx=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,o){if(i<0||e>this.width||r<0||t>this.height)return[];let s=[];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++)s.push({key:this.boxKeys[e],x1:this.bboxes[4*e],y1:this.bboxes[4*e+1],x2:this.bboxes[4*e+2],y2:this.bboxes[4*e+3]});for(let e=0;e<this.circleKeys.length;e++){let t=this.circles[3*e],i=this.circles[3*e+1],r=this.circles[3*e+2];s.push({key:this.circleKeys[e],x1:t-r,y1:i-r,x2:t+r,y2:i+r})}}else{let l={hitTest:a,overlapMode:n,seenUids:{box:{},circle:{}}};this._forEachCell(e,t,i,r,this._queryCell,s,l,o)}return s}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,o=e+i,s=t-i,l=t+i;if(o<0||n>this.width||l<0||s>this.height)return!1;let u=[],h={hitTest:!0,overlapMode:r,circle:{x:e,y:t,radius:i},seenUids:{box:{},circle:{}}};return this._forEachCell(n,s,o,l,this._queryCellCircle,u,h,a),u.length>0}_queryCell(e,t,i,r,a,n,o,s){let{seenUids:l,hitTest:u,overlapMode:h}=o,c=this.boxCells[a],d=1e-6;if(null!==c){let a=this.bboxes;for(let o of c)if(!l.box[o]){l.box[o]=!0;let c=4*o,p=this.boxKeys[o];if(e<=a[c+2]+d&&t<=a[c+3]+d&&i>=a[c+0]-d&&r>=a[c+1]-d&&(!s||s(p))&&(!u||!ax(h,p.overlapMode))&&(n.push({key:p,x1:a[c],y1:a[c+1],x2:a[c+2],y2:a[c+3]}),u))return!0}}let p=this.circleCells[a];if(null!==p){let a=this.circles;for(let o of p)if(!l.circle[o]){l.circle[o]=!0;let c=3*o,d=this.circleKeys[o];if(this._circleAndRectCollide(a[c],a[c+1],a[c+2],e,t,i,r)&&(!s||s(d))&&(!u||!ax(h,d.overlapMode))){let e=a[c],t=a[c+1],i=a[c+2];if(n.push({key:d,x1:e-i,y1:t-i,x2:e+i,y2:t+i}),u)return!0}}}return!1}_queryCellCircle(e,t,i,r,a,n,o,s){let{circle:l,seenUids:u,overlapMode:h}=o,c=this.boxCells[a];if(null!==c){let e=this.bboxes;for(let t of c)if(!u.box[t]){u.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])&&(!s||s(r))&&!ax(h,r.overlapMode))return n.push(!0),!0}}let d=this.circleCells[a];if(null!==d){let e=this.circles;for(let t of d)if(!u.circle[t]){u.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)&&(!s||s(r))&&!ax(h,r.overlapMode))return n.push(!0),!0}}}_forEachCell(e,t,i,r,a,n,o,s){let l=this._convertToXCellCoord(e),u=this._convertToYCellCoord(t),h=this._convertToXCellCoord(i),c=this._convertToYCellCoord(r);for(let d=l;d<=h;d++)for(let l=u;l<=c;l++){let u=this.xCellCount*l+d;if(a.call(this,e,t,i,r,u,n,o,s))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 o=r-e,s=a-t,l=i+n;return l*l>o*o+s*s}_circleAndRectCollide(e,t,i,r,a,n,o){let s=(n-r)/2,l=Math.abs(e-(r+s));if(l>s+i)return!1;let u=(o-a)/2,h=Math.abs(t-(a+u));if(h>u+i)return!1;if(l<=s||h<=u)return!0;let c=l-s,d=h-u;return c*c+d*d<=i*i}};function ox(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,o=t[8]*r,s=t[1]*i,l=t[5]*i,u=t[9]*r,h=t[2]*i,c=t[6]*i,d=t[10]*r;e[0]=a,e[1]=n,e[2]=o,e[4]=s,e[5]=l,e[6]=u,e[8]=h,e[9]=c,e[10]=d;let p=t[12],f=t[13],m=t[14];return e[12]=-a*p-s*f-h*m,e[13]=-n*p-l*f-c*m,e[14]=-o*p-u*f-d*m,e[3]=0,e[7]=0,e[11]=0,e[15]=1,e}var sx=y();function lx(e,t,i){let r=y();if(!e){let{vecSouth:e,vecEast:i}=hx(t),a=_();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],o=i*n-a*r;o&&(o=1/o,e[0]=n*o,e[1]=-r*o,e[2]=-a*o,e[3]=i*o)}(a,a),r[0]=a[0],r[1]=a[1],r[4]=a[2],r[5]=a[3]}return S(r,r,[1/i,1/i,1]),r}function ux(e,t,i,r){if(e){let e=y();if(!t){let{vecSouth:t,vecEast:r}=hx(i);e[0]=r[0],e[1]=r[1],e[4]=t[0],e[5]=t[1]}return S(e,e,[r,r,1]),e}return i.pixelsToClipSpaceMatrix}function hx(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),o=K();o[0]=-a*r*i-n*t,o[1]=-n*r*i+a*t;let s=ee(o);s<1e-9?te(o):Q(o,o,1/s);let l=K();l[0]=a*r*t-n*i,l[1]=n*r*t+a*i;let u=ee(l);return u<1e-9?te(l):Q(l,l,1/u),{vecEast:l,vecSouth:o}}function cx(e,t,i){return rx(e.getElevation,t,i,e.heightOffset??0,e.heightAnchorGround??!0)}function dx(e,t,i,r){let a;null==r?(a=[e,t,0,1],Ax(a,a,i)):(a=[e,t,r,1],H(a,a,i));let n=a[3];return{point:new d(a[0]/n,a[1]/n),signedDistanceFromCamera:n,isOccluded:!1}}function px(e,t){return.5+e/t*.5}function fx(e,t){return e.x>=-t[0]&&e.x<=t[0]&&e.y>=-t[1]&&e.y<=t[1]}function mx(e,t,i,r,a,n,o,s,l,u,h,c){let p=r?e.textSizeData:e.iconSizeData,f=Lf(p,i.zoom),m=[256/t.width*2+1,256/t.height*2+1],_=r?e.text.dynamicLayoutVertexArray:e.icon.dynamicLayoutVertexArray;_.clear();let g=e.lineVertexArray,y=r?e.text.placedSymbolArray:e.icon.placedSymbolArray,v=i.width/i.height,x=!1;for(let b=0;b<y.length;b++){let t=y.get(b);if(t.hidden||2===t.writingMode&&!x){Px(t.numGlyphs,_);continue}x=!1;let r={getElevation:c,pitchedLabelPlaneMatrix:a,lineVertexArray:g,pitchWithMap:o,projectionCache:{projections:{},offsets:{},cachedAnchorPoint:void 0,anyProjectionOccluded:!1},transform:i,tileAnchorPoint:new d(t.anchorX,t.anchorY),unwrappedTileID:u,width:i.width,height:i.height,translation:h},w=Tx(t.anchorX,t.anchorY,r);if(!fx(w.point,m)){Px(t.numGlyphs,_);continue}let T=w.signedDistanceFromCamera,S=px(i.cameraToCenterDistance,T),D=Rf(p,f,t),E=o?D*i.getPitchedTextCorrection(t.anchorX,t.anchorY,u)/S:D*S,C=yx({projectionContext:r,pitchedLabelPlaneMatrixInverse:n,symbol:t,fontSize:E,flip:!1,keepUpright:s,glyphOffsetArray:e.glyphOffsetArray,dynamicLayoutVertexArray:_,aspectRatio:v,rotateToLine:l});x=C.useVertical,(C.notEnoughRoom||x||C.needsFlipping&&yx({projectionContext:r,pitchedLabelPlaneMatrixInverse:n,symbol:t,fontSize:E,flip:!0,keepUpright:s,glyphOffsetArray:e.glyphOffsetArray,dynamicLayoutVertexArray:_,aspectRatio:v,rotateToLine:l}).notEnoughRoom)&&Px(t.numGlyphs,_)}r?e.text.dynamicLayoutVertexBuffer.updateData(_):e.icon.dynamicLayoutVertexBuffer.updateData(_)}function _x(e,t,i,r,a,n,o,s){let l=n.glyphStartIndex+n.numGlyphs,u=n.lineStartIndex,h=n.lineStartIndex+n.lineLength,c=t.getoffsetX(n.glyphStartIndex),d=t.getoffsetX(l-1),p=Ex(e*c,i,r,a,n.segment,u,h,s,o);if(!p)return null;let f=Ex(e*d,i,r,a,n.segment,u,h,s,o);return!f||s.projectionCache.anyProjectionOccluded?null:{first:p,last:f}}function gx(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 yx(e){let t,{projectionContext:i,pitchedLabelPlaneMatrixInverse:r,symbol:a,fontSize:n,flip:o,keepUpright:s,glyphOffsetArray:l,dynamicLayoutVertexArray:u,aspectRatio:h,rotateToLine:c}=e,p=n/24,f=a.lineOffsetX*p,m=a.lineOffsetY*p;if(a.numGlyphs>1){let e=a.glyphStartIndex+a.numGlyphs,n=a.lineStartIndex,u=a.lineStartIndex+a.lineLength,d=_x(p,l,f,m,o,a,c,i);if(!d)return{notEnoughRoom:!0};let _=wx(d.first.point.x,d.first.point.y,i,r),g=wx(d.last.point.x,d.last.point.y,i,r);if(s&&!o){let e=gx(a.writingMode,_,g,h);if(e)return e}t=[d.first];for(let r=a.glyphStartIndex+1;r<e-1;r++){let e=Ex(p*l.getoffsetX(r),f,m,o,a.segment,n,u,i,c);if(!e)return{notEnoughRoom:!0};t.push(e)}t.push(d.last)}else{if(s&&!o){let e=bx(i.tileAnchorPoint.x,i.tileAnchorPoint.y,i).point,t=a.lineStartIndex+a.segment+1,n=new d(i.lineVertexArray.getx(t),i.lineVertexArray.gety(t)),o=bx(n.x,n.y,i),s=o.signedDistanceFromCamera>0?o.point:vx(i.tileAnchorPoint,n,e,1,i),l=wx(e.x,e.y,i,r),u=wx(s.x,s.y,i,r),c=gx(a.writingMode,l,u,h);if(c)return c}let e=Ex(p*l.getoffsetX(a.glyphStartIndex),f,m,o,a.segment,a.lineStartIndex,a.lineStartIndex+a.lineLength,i,c);if(!e||i.projectionCache.anyProjectionOccluded)return{notEnoughRoom:!0};t=[e]}for(let d of t)mm(u,d.point,d.angle);return{}}function vx(e,t,i,r,a){let n=e.add(e.sub(t)._unit()),o=bx(n.x,n.y,a).point,s=i.sub(o);return i.add(s._mult(r/s.mag()))}function xx(e,t,i){let r=t.projectionCache;if(r.projections[e])return r.projections[e];let a=new d(t.lineVertexArray.getx(e),t.lineVertexArray.gety(e)),n=bx(a.x,a.y,t);if(n.signedDistanceFromCamera>0)return r.projections[e]=n.point,r.anyProjectionOccluded||=n.isOccluded,n.point;let o=e-i.direction,s=0===i.distanceFromAnchor?t.tileAnchorPoint:new d(t.lineVertexArray.getx(o),t.lineVertexArray.gety(o)),l=i.absOffsetX-i.distanceFromAnchor+1;return vx(s,a,i.previousVertex,l,t)}function bx(e,t,i){let r,a=e+i.translation[0],n=t+i.translation[1];return i.pitchWithMap?(r=dx(a,n,i.pitchedLabelPlaneMatrix,cx(i,a,n)),r.isOccluded=!1):(r=i.transform.projectTileCoordinates(a,n,i.unwrappedTileID,cx(i,a,n)),r.point.x=(.5*r.point.x+.5)*i.width,r.point.y=(.5*-r.point.y+.5)*i.height),r}function wx(e,t,i,r){if(i.pitchWithMap){let a=[e,t,0,1];H(a,a,r);let n=a[0]/a[3],o=a[1]/a[3];return i.transform.projectTileCoordinates(n,o,i.unwrappedTileID,cx(i,n,o)).point}return{x:e/i.width*2-1,y:1-t/i.height*2}}function Tx(e,t,i){return i.transform.projectTileCoordinates(e,t,i.unwrappedTileID,cx(i,e,t))}function Sx(e,t,i){return e._unit()._perp()._mult(t*i)}function Dx(e,t,i,r,a,n,o,s,l){if(s.projectionCache.offsets[e])return s.projectionCache.offsets[e];let u=i.add(t);if(e+l.direction<r||e+l.direction>=a)return s.projectionCache.offsets[e]=u,u;let h=xx(e+l.direction,s,l),c=Sx(h.sub(i),o,l.direction),d=i.add(c),p=h.add(c);return s.projectionCache.offsets[e]=Ve(n,u,d,p)||u,s.projectionCache.offsets[e]}function Ex(e,t,i,r,a,n,o,s,l){let u=r?e-t:e+t,h=u>0?1:-1,c=0;r&&(h*=-1,c=Math.PI),h<0&&(c+=Math.PI);let d,p=h>0?n+a:n+a+1;s.projectionCache.cachedAnchorPoint?d=s.projectionCache.cachedAnchorPoint:(d=bx(s.tileAnchorPoint.x,s.tileAnchorPoint.y,s).point,s.projectionCache.cachedAnchorPoint=d);let f,m,_,g=d,y=d,v=0,x=0,b=Math.abs(u),w=[];for(;v+x<=b;){if(p+=h,p<n||p>=o)return null;v+=x,y=g,m=f;let e={absOffsetX:b,direction:h,distanceFromAnchor:v,previousVertex:y};if(g=xx(p,s,e),0===i)w.push(y),_=g.sub(y);else{let t,r=g.sub(y);t=0===r.mag()?Sx(xx(p+h,s,e).sub(g),i,h):Sx(r,i,h),m||=y.add(t),f=Dx(p,t,g,n,o,m,i,s,e),w.push(m),_=f.sub(m)}x=_.mag()}let T=(b-v)/x,S=_._mult(T)._add(m||y),D=c+Math.atan2(g.y-y.y,g.x-y.x);return w.push(S),{point:S,angle:l?D:0,path:w}}var Cx=new Float32Array([-1/0,-1/0,0,-1/0,-1/0,0,-1/0,-1/0,0,-1/0,-1/0,0]);function Px(e,t){for(let i=0;i<e;i++){let e=t.length;t.resize(e+4),t.float32.set(Cx,3*e)}}function Ax(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 Ix=class{constructor(e,t=new nx(e.width+200,e.height+200,25),i=new nx(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,o,s,l,u,h,c,d=0,p=!0){let f,m=e.anchorPointX+s[0],_=e.anchorPointY+s[1],g=this.projectAndGetPerspectiveRatio(m,_,a,rx(u,m,_,d,p),c),y=i*g.perspectiveRatio;if(n||o)f=this._projectCollisionBox(e,y,r,a,n,o,s,g,u,h,c,d,p);else{let t=g.x+(h?h.x*y:0),i=g.y+(h?h.y*y:0);f={allPointsOccluded:!1,box:[t+e.x1*y,i+e.y1*y,t+e.x2*y,i+e.y2*y]}}let[v,x,b,w]=f.box,T=n?f.allPointsOccluded:g.isOccluded,S=T;return S||=g.perspectiveRatio<this.perspectiveRatioCutoff,S||=!this.isInsideGrid(v,x,b,w),S||"always"!==t&&this.grid.hitTest(v,x,b,w,t,l)?{box:[v,x,b,w],placeable:!1,offscreen:!1,occluded:T}:{box:[v,x,b,w],placeable:!0,offscreen:this.isOffscreen(v,x,b,w),occluded:T}}placeCollisionCircles(e,t,i,r,a,n,o,s,l,u,h,c,p,f){let m=[],_=new d(t.anchorX,t.anchorY),g=this.getPerspectiveRatio(_.x,_.y,n,f?.(_.x,_.y)),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:o,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:p},w=_x(y,r,v,x,!1,t,!1,b),T=!1,S=!1,D=!0;if(w){let t=.5*h*g+c,i=new d(-100,-100),r=new d(this.screenRightBoundary,this.screenBottomBoundary),a=new ix,n=w.first,o=w.last,p=[];for(let e=n.path.length-1;e>=1;e--)p.push(n.path[e]);for(let e=1;e<o.path.length;e++)p.push(o.path[e]);let f=2.5*t;if(l){let e=this.projectPathToScreenSpace(p,b);p=e.some(e=>e.signedDistanceFromCamera<=0)?[]:e.map(e=>e.point)}let _=[];if(p.length>0){let e=p[0].clone(),t=p[0].clone();for(let i=1;i<p.length;i++)e.x=Math.min(e.x,p[i].x),e.y=Math.min(e.y,p[i].y),t.x=Math.max(t.x,p[i].x),t.y=Math.max(t.y,p[i].y);_=e.x>=i.x&&t.x<=r.x&&e.y>=i.y&&t.y<=r.y?[p]:t.x<i.x||e.x>r.x||t.y<i.y||e.y>r.y?[]:Zf([p],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),o=a.lerp(n),l=o.x+100,h=o.y+100;m.push(l,h,t,0);let c=l-t,d=h-t,p=l+t,f=h+t;if(D&&=this.isOffscreen(c,d,p,f),S||=this.isInsideGrid(c,d,p,f),"always"!==e&&this.grid.hitTestCircle(l,h,t,e,u)&&(T=!0,!s))return{circles:[],offscreen:!1,collisionDetected:T}}}}return{circles:!s&&T||!S||g<this.perspectiveRatioCutoff?[]:m,offscreen:D,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=sx;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=dx(e.x,e.y,i,cx(t,e.x,e.y)),a=t.transform.projectTileCoordinates(r.point.x,r.point.y,t.unwrappedTileID,cx(t,r.point.x,r.point.y));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 ku;for(let h of e){let e=new d(h.x+100,h.y+100);i.extend(e),t.push(e)}let{minX:r,minY:a,maxX:n,maxY:o}=i,s=this.grid.query(r,a,n,o).concat(this.ignoredGrid.query(r,a,n,o)),l={},u={};for(let h of s){let e=h.key;void 0===l[e.bucketInstanceId]&&(l[e.bucketInstanceId]={}),!l[e.bucketInstanceId][e.featureIndex]&&$u(t,[new d(h.x1,h.y1),new d(h.x2,h.y1),new d(h.x2,h.y2),new d(h.x1,h.y2)])&&(l[e.bucketInstanceId][e.featureIndex]=!0,void 0===u[e.bucketInstanceId]&&(u[e.bucketInstanceId]=[]),u[e.bucketInstanceId].push(e.featureIndex))}return u}insertCollisionBox(e,t,i,r,a,n){let o={bucketInstanceId:r,featureIndex:a,collisionGroupID:n,overlapMode:t};(i?this.ignoredGrid:this.grid).insert(o,e[0],e[1],e[2],e[3])}insertCollisionCircles(e,t,i,r,a,n){let o=i?this.ignoredGrid:this.grid,s={bucketInstanceId:r,featureIndex:a,collisionGroupID:n,overlapMode:t};for(let l=0;l<e.length;l+=4)o.insertCircle(s,e[l],e[l+1],e[l+2])}projectAndGetPerspectiveRatio(e,t,i,r,a){if(a){let i;null==r?(i=[e,t,0,1],Ax(i,i,a)):(i=[e,t,r,1],H(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=x([]);return T(e,e,[-100,-100,0]),e}_projectCollisionBox(e,t,i,r,a,n,o,s,l,u,h,c=0,p=!0){let f=1,m=0,_=0,g=1,y=e.anchorPointX+o[0],v=e.anchorPointY+o[1];if(n&&!a){let e=this.projectAndGetPerspectiveRatio(y+1,v,r,rx(l,y+1,v,c,p),h),t=e.x-s.x,i=e.y-s.y,a=Math.atan(i/t)+(t<0?Math.PI:0),n=Math.sin(a),o=Math.cos(a);f=o,m=n,_=-n,g=o}else if(!n&&a){let e=hx(this.transform);f=e.vecEast[0],m=e.vecEast[1],_=e.vecSouth[0],g=e.vecSouth[1]}let x=s.x,b=s.y,w=t;a&&(x=y,b=v,w=2**-(this.transform.zoom-i.overscaledZ),w*=this.transform.getPitchedTextCorrection(y,v,r),!u)&&(w*=Se(.5+s.signedDistanceFromCamera/this.transform.cameraToCenterDistance*.5,0,4)),u&&(x+=f*u.x*w+_*u.y*w,b+=m*u.x*w+g*u.y*w);let T=e.x1*w,S=e.x2*w,D=(T+S)/2,E=e.y1*w,C=e.y2*w,P=(E+C)/2,A=[{offsetX:T,offsetY:E},{offsetX:D,offsetY:E},{offsetX:S,offsetY:E},{offsetX:S,offsetY:P},{offsetX:S,offsetY:C},{offsetX:D,offsetY:C},{offsetX:T,offsetY:C},{offsetX:T,offsetY:P}],I=[];for(let{offsetX:F,offsetY:z}of A)I.push(new d(x+f*F+_*z,b+m*F+g*z));let M=!1;if(a){let e=I.map(e=>this.projectAndGetPerspectiveRatio(e.x,e.y,r,rx(l,e.x,e.y,c,p),h));M=e.some(e=>!e.isOccluded),I=e.map(e=>new d(e.x,e.y))}else M=!0;return{box:be(I),allPointsOccluded:!M}}},Mx=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}},Fx=class{constructor(e,t,i,r,a){this.text=new Mx(e?e.text:null,t,i,a),this.icon=new Mx(e?e.icon:null,t,r,a)}isHidden(){return this.text.isHidden()&&this.icon.isHidden()}},zx=class{constructor(e,t,i){this.text=e,this.icon=t,this.skipFade=i}},kx=class{constructor(e,t,i,r,a){this.bucketInstanceId=e,this.featureIndex=t,this.sourceLayerIndex=i,this.bucketIndex=r,this.tileID=a}},Rx=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 Lx(e,t,i,r,a){let{horizontalAlign:n,verticalAlign:o}=gf(e),s=-(o-.5)*i;return new d(-(n-.5)*t+r[0]*a,s+r[1]*a)}var Bx=tp.members.find(e=>"crossTileID"===e.name).offset/4,Ox=class{constructor(e,t,i,r,a){this.transform=e.clone(),this.terrain=t,this.collisionIndex=new Ix(this.transform),this.placements={},this.opacities={},this.variableOffsets={},this.stale=!1,this.commitTime=0,this.fadeDuration=i,this.retainedQueryData={},this.collisionGroups=new Rx(r),this.collisionCircleArrays={},this.collisionBoxArrays=/* @__PURE__ */new Map,this.lastOpacityInputs=/* @__PURE__ */new WeakMap,this.prevPlacement=a,a&&(a.prevPlacement=void 0),this.placedOrientations={}}_getTerrainElevationFunc(e){let t=this.terrain;if(t)return(i,r)=>t.getElevation(e,i,r)}getBucketParts(e,t,i,r){let a=i.getBucket(t),n=i.latestFeatureIndex;if(!a||!n||t.id!==a.layerIds[0])return;let o=i.collisionBoxArray,s=a.layers[0].layout,l=a.layers[0].paint,u=2**(this.transform.zoom-i.tileID.overscaledZ),h=i.tileSize/re,c=i.tileID.toUnwrapped(),d="map"===s.get("text-rotation-alignment"),p=ae(i,1,this.transform.zoom),f=ce(this.collisionIndex.transform,i,l.get("text-translate"),l.get("text-translate-anchor")),m=ce(this.collisionIndex.transform,i,l.get("icon-translate"),l.get("icon-translate-anchor")),_=lx(d,this.transform,p);this.retainedQueryData[a.bucketInstanceId]=new kx(a.bucketInstanceId,n,a.sourceLayerIndex,a.index,i.tileID);let g={bucket:a,layout:s,translationText:f,translationIcon:m,unwrappedTileID:c,pitchedLabelPlaneMatrix:_,scale:u,textPixelRatio:h,holdingForFade:i.holdingForSymbolFade(),collisionBoxArray:o,partiallyEvaluatedTextSize:Lf(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,o,s,l,u,h,c,d,p,f,m,_,g,y,v,x,b){let w=rm[e.textAnchor],T=[e.textOffset0,e.textOffset1],S=Lx(w,i,r,T,a),D=this.collisionIndex.placeCollisionBox(t,c,s,l,u,o,n,m,h.predicate,y,S,v,x,b);if((!g||this.collisionIndex.placeCollisionBox(g,c,s,l,u,o,n,_,h.predicate,y,S,v,x,b).placeable)&&D.placeable){let e;if(this.prevPlacement?.variableOffsets[d.crossTileID]&&this.prevPlacement?.placements[d.crossTileID]?.text&&(e=this.prevPlacement.variableOffsets[d.crossTileID].anchor),0===d.crossTileID)throw Error("symbolInstance.crossTileID can't be 0");return this.variableOffsets[d.crossTileID]={textOffset:T,width:i,height:r,anchor:w,textBoxScale:a,prevAnchor:e},this.markUsedJustification(p,w,d,f),p.allowVerticalPlacement&&(this.markUsedOrientation(p,f,d),this.placedOrientations[d.crossTileID]=f),{shift:S,placedGlyphBoxes:D}}}placeLayerBucketPart(e,t,i){let{bucket:r,layout:a,translationText:n,translationIcon:o,unwrappedTileID:s,pitchedLabelPlaneMatrix:l,textPixelRatio:u,holdingForFade:h,collisionBoxArray:c,partiallyEvaluatedTextSize:d,collisionGroup:p}=e.parameters,f=a.get("text-optional"),m=a.get("icon-optional"),_=dm(a,"text-overlap","text-allow-overlap"),g="always"===_,y=dm(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="ground"===a.get("symbol-height-anchor"),D=g&&(v||!r.hasIconData()||m),E=v&&(g||!r.hasTextData()||f);!r.collisionArrays&&c&&r.deserializeCollisionBoxes(c);let C=this.retainedQueryData[r.bucketInstanceId].tileID,P=this._getTerrainElevationFunc(C),A=this.transform.getFastPathSimpleProjectionMatrix(C),I=(e,c,v)=>{if(t[e.crossTileID])return;if(h)return void(this.placements[e.crossTileID]=new zx(!1,!1,!1));let T=e.heightOffset,I=!1,M=!1,F=!0,z=null,k={box:null,placeable:!1,offscreen:null,occluded:!1},R={box:null,placeable:!1,offscreen:null},L=null,B=null,O=null,j=0,V=0,N=0;c.textFeatureIndex?j=c.textFeatureIndex:e.useRuntimeCollisionCircles&&(j=e.featureIndex),c.verticalTextFeatureIndex&&(V=c.verticalTextFeatureIndex);let U=c.textBox;if(U){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?(k=i(),R=k):k=t(),k?.placeable)break}else k=t()},l=e.textAnchorOffsetStartIndex,h=e.textAnchorOffsetEndIndex;if(h===l){let i=(t,i)=>{let a=this.collisionIndex.placeCollisionBox(t,_,u,C,s,b,x,n,p.predicate,P,void 0,A,T,S);return a?.placeable&&(this.markUsedOrientation(r,i,e),this.placedOrientations[e.crossTileID]=i),a};a(()=>i(U,1),()=>{let t=c.verticalTextBox;return r.allowVerticalPlacement&&e.numVerticalGlyphVertices>0&&t?i(t,2):{box:null,offscreen:null}}),t(k?.placeable)}else{let d=rm[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,D=null,E="never"===_?1:2,M="never";d&&E++;for(let i=0;i<E;i++){for(let i=l;i<h;i++){let a=r.textAnchorOffsets.get(i);if(d&&a.textAnchor!==d)continue;let l=this.attemptAnchorPlacement(a,t,f,m,g,x,b,u,C,s,p,M,e,r,c,n,o,v,P,A,T,S);if(l&&(D=l.placedGlyphBoxes,D?.placeable))return I=!0,z=l.shift,D}d?d=null:M=_}return i&&!D&&(D={box:this.collisionIndex.placeCollisionBox(U,"always",u,C,s,b,x,n,p.predicate,P,void 0,A,T,S).box,offscreen:!1,placeable:!1,occluded:!1}),D};a(()=>f(U,c.iconBox,1),()=>{let t=c.verticalTextBox,i=k?.placeable;return r.allowVerticalPlacement&&!i&&e.numVerticalGlyphVertices>0&&t?f(t,c.verticalIconBox,2):{box:null,occluded:!0,offscreen:null}}),k&&(I=k.placeable,F=k.offscreen);let m=t(k?.placeable);if(!I&&this.prevPlacement){let t=this.prevPlacement.variableOffsets[e.crossTileID];t&&(this.variableOffsets[e.crossTileID]=t,this.markUsedJustification(r,t.anchor,e,m))}}}if(L=k,I=L?.placeable,F=L?.offscreen,e.useRuntimeCollisionCircles&&e.centerJustifiedTextSymbolIndex>=0){let t=r.text.placedSymbolArray.get(e.centerJustifiedTextSymbolIndex),o=Rf(r.textSizeData,d,t),u=a.get("text-padding"),h=e.collisionCircleDiameter;B=this.collisionIndex.placeCollisionCircles(_,t,r.lineVertexArray,r.glyphOffsetArray,o,s,l,i,b,p.predicate,h,u,n,P),B.circles.length&&B.collisionDetected&&!i&&Oe("Collisions detected, but collision boxes are not shown"),I=g||B.circles.length>0&&!B.collisionDetected,F&&=B.offscreen}if(c.iconFeatureIndex&&(N=c.iconFeatureIndex),c.iconBox){let e=e=>this.collisionIndex.placeCollisionBox(e,y,u,C,s,b,x,o,p.predicate,P,w&&z?z:void 0,A,T,S);R&&R.placeable&&c.verticalIconBox?(O=e(c.verticalIconBox),M=O.placeable):(O=e(c.iconBox),M=O.placeable),F&&=O.offscreen}let $=f||0===e.numHorizontalGlyphVertices&&0===e.numVerticalGlyphVertices,G=m||0===e.numIconVertices;$||G?G?$||(M&&=I):I=M&&I:M=I=M&&I;let Z=I&&L.placeable,q=M&&O.placeable;if(Z&&(R&&R.placeable&&V?this.collisionIndex.insertCollisionBox(L.box,_,a.get("text-ignore-placement"),r.bucketInstanceId,V,p.ID):this.collisionIndex.insertCollisionBox(L.box,_,a.get("text-ignore-placement"),r.bucketInstanceId,j,p.ID)),q&&this.collisionIndex.insertCollisionBox(O.box,y,a.get("icon-ignore-placement"),r.bucketInstanceId,N,p.ID),B&&I&&this.collisionIndex.insertCollisionCircles(B.circles,_,a.get("text-ignore-placement"),r.bucketInstanceId,j,p.ID),i&&this.storeCollisionData(r.bucketInstanceId,v,c,L,O,B),0===e.crossTileID)throw Error("symbolInstance.crossTileID can't be 0");if(0===r.bucketInstanceId)throw Error("bucket.bucketInstanceId can't be 0");let W=(I||D)&&!L?.occluded,H=(M||E)&&!O?.occluded;this.placements[e.crossTileID]=new zx(W,H,F||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];I(r.symbolInstances.get(i),r.collisionArrays[i],i)}}else for(let M=e.symbolInstanceStart;M<e.symbolInstanceEnd;M++)I(r.symbolInstances.get(M),r.collisionArrays[M],M);r.justReloaded=!1}storeCollisionData(e,t,i,r,a,n){if(i.textBox||i.iconBox){let n,o;this.collisionBoxArrays.has(e)?n=this.collisionBoxArrays.get(e):(n=/* @__PURE__ */new Map,this.collisionBoxArrays.set(e,n)),n.has(t)?o=n.get(t):(o={text:null,icon:null},n.set(t,o)),i.textBox&&(o.text=r.box),i.iconBox&&(o.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[sm(t)];let o=[i.leftJustifiedTextSymbolIndex,i.centerJustifiedTextSymbolIndex,i.rightJustifiedTextSymbolIndex,i.verticalPlacedTextSymbolIndex];for(let s of o)s>=0&&(e.text.placedSymbolArray.get(s).crossTileID=a>=0&&s!==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 o of n)e.text.placedSymbolArray.get(o).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:{},o=t?t.placedOrientations:{};for(let s in this.placements){let e=this.placements[s],t=a[s];t?(this.opacities[s]=new Fx(t,r,e.text,e.icon),i||=e.text!==t.text.placed,i||=e.icon!==t.icon.placed):(this.opacities[s]=new Fx(null,r,e.text,e.icon,e.skipFade),i||=e.text||e.icon)}for(let s in a){let e=a[s];if(!this.opacities[s]){let t=new Fx(e,r,!1,!1);t.isHidden()||(this.opacities[s]=t,i||=e.text.placed,i||=e.icon.placed)}}for(let s in n)!this.variableOffsets[s]&&this.opacities[s]&&!this.opacities[s].isHidden()&&(this.variableOffsets[s]=n[s]);for(let s in o)!this.placedOrientations[s]&&this.opacities[s]&&!this.opacities[s].isHidden()&&(this.placedOrientations[s]=o[s]);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);if(!t||!r.latestFeatureIndex||e.id!==t.layerIds[0])continue;let{duplicates:a,changed:n}=this._markDuplicates(t,i),o=!!t.hasDebugData()||t.bucketInstanceId in this.collisionCircleArrays;(n||o)&&this.updateBucketOpacities(t,r.tileID,a,r.collisionBoxArray),t.sortFeatures(-this.transform.bearingInRadians),this.retainedQueryData[t.bucketInstanceId]&&(this.retainedQueryData[t.bucketInstanceId].featureSortOrder=t.featureSortOrder)}}_markDuplicates(e,t){let i=e.symbolInstances.length,r=this.lastOpacityInputs.get(e),a=!1;r||(r={crossTileIDs:Array(i).fill(0),duplicates:Array(i).fill(!1)},this.lastOpacityInputs.set(e,r),a=!0);let{crossTileIDs:n,duplicates:o}=r,s=e.symbolInstances.uint32,l=e.symbolInstances.bytesPerElement/4;for(let u=0;u<i;u++){let e=s[u*l+Bx],i=!!t[e];t[e]=!0,(n[u]!==e||o[u]!==i)&&(n[u]=e,o[u]=i,a=!0)}return{duplicates:o,changed:a}}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,o=new Fx(null,0,!1,!1,!0),s=n.get("text-allow-overlap"),l=n.get("icon-allow-overlap"),u=a._unevaluatedLayout.hasValue("text-variable-anchor")||a._unevaluatedLayout.hasValue("text-variable-anchor-offset"),h="map"===n.get("text-rotation-alignment"),c="map"===n.get("text-pitch-alignment"),p="none"!==n.get("icon-text-fit"),f=new Fx(null,0,s&&(l||!e.hasIconData()||n.get("icon-optional")),l&&(s||!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||=0!==i},_=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,s=i[g],l=this.opacities[n];s?l=o:l||(l=f,this.opacities[n]=l);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=Gx(l.text),n=b?0:i;m(e.text,r,n);let o=w?0:i;m(e.text,a,o);let s=l.text.isHidden(),u=[t.rightJustifiedTextSymbolIndex,t.centerJustifiedTextSymbolIndex,t.leftJustifiedTextSymbolIndex];for(let t of u)t>=0&&(e.text.placedSymbolArray.get(t).hidden=s||b?1:0);t.verticalPlacedTextSymbolIndex>=0&&(e.text.placedSymbolArray.get(t.verticalPlacedTextSymbolIndex).hidden=s||w?1:0);let h=this.variableOffsets[t.crossTileID];h&&this.markUsedJustification(e,h.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=Gx(l.icon),r=!(p&&t.verticalPlacedIconSymbolIndex&&b);if(t.placedIconSymbolIndex>=0){let a=r?i:0;m(e.icon,t.numIconVertices,a),e.icon.placedSymbolArray.get(t.placedIconSymbolIndex).hidden=l.icon.isHidden()}if(t.verticalPlacedIconSymbolIndex>=0){let a=r?0: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 d(0,0);if(t.textBox||t.verticalTextBox){let r=!0;if(u){let e=this.variableOffsets[n];e?(i=Lx(e.anchor,e.width,e.height,e.textOffset,e.textBoxScale),h&&i._rotate(c?-this.transform.bearingInRadians:this.transform.bearingInRadians)):r=!1}if(t.textBox||t.verticalTextBox){let a;t.textBox&&(a=b),t.verticalTextBox&&(a=w),jx(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),jx(e.iconCollisionBox.collisionVertexArray,l.icon.placed,r,T.icon,p?i.x:0,p?i.y:0)}}}}if(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 jx(e,t,i,r,a,n){(!r||0===r.length)&&(r=[0,0,0,0]);let o=r[0]-100,s=r[1]-100,l=r[2]-100,u=r[3]-100;e.emplaceBack(+!!t,+!!i,a||0,n||0,o,s),e.emplaceBack(+!!t,+!!i,a||0,n||0,l,s),e.emplaceBack(+!!t,+!!i,a||0,n||0,l,u),e.emplaceBack(+!!t,+!!i,a||0,n||0,o,u)}var Vx=2**25,Nx=2**24,Ux=2**17,$x=65536;function Gx(e){if(0===e.opacity&&!e.placed)return 0;if(1===e.opacity&&e.placed)return Zx;let t=+!!e.placed,i=Math.floor(127*e.opacity);return i*Vx+t*Nx+i*Ux+t*$x+512*i+256*t+2*i+t}var Zx=4294967295,qx=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}},Wx=class{constructor(e,t,i,r,a,n,o,s){this.placement=new Ox(e,t,n,o,s),this._currentPlacementIndex=i.length-1,this._forceFullPlacement=r,this._showCollisionBoxes=a,this._done=!1}isDone(){return this._done}continuePlacement(e,t,i){let r=dt(),a=()=>!this._forceFullPlacement&&dt()-r>2;for(;this._currentPlacementIndex>=0;){let r=t[e[this._currentPlacementIndex]],n=this.placement.collisionIndex.transform.zoom;if(Em(r)&&r.layout&&(!r.minzoom||r.minzoom<=n)&&(!r.maxzoom||r.maxzoom>n)){if(this._inProgressLayer||=new qx(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}},Hx=[Int8Array,Uint8Array,Uint8ClampedArray,Int16Array,Uint16Array,Int32Array,Uint32Array,Float32Array,Float64Array],Xx=/* @__PURE__ */new Uint32Array(96),Yx=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=Hx[15&r];if(!n)throw Error("Unrecognized array type.");let[o]=new Uint16Array(t,2,1),[s]=new Uint32Array(t,4,1);return new e(s,o,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=Hx.indexOf(this.ArrayType),o=2*e*this.ArrayType.BYTES_PER_ELEMENT,s=e*this.IndexArrayType.BYTES_PER_ELEMENT,l=(8-s%8)%8;if(n<0)throw Error(`Unexpected typed array class: ${i}.`);if(a)this.data=a,this.ids=new this.IndexArrayType(a,8,e),this.coords=new i(a,8+s+l,2*e),this._pos=2*e,this._finished=!0;else{let a=this.data=new r(8+o+s+l);this.ids=new this.IndexArrayType(a,8,e),this.coords=new i(a,8+s+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 Kx(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:o}=this;Xx[0]=0,Xx[1]=a.length-1,Xx[2]=0;let s=3,l=[];for(;s>0;){let u=Xx[--s],h=Xx[--s],c=Xx[--s];if(h-c<=o){for(let o=c;o<=h;o++){let s=n[2*o],u=n[2*o+1];s>=e&&s<=i&&u>=t&&u<=r&&l.push(a[o])}continue}let d=c+h>>1,p=n[2*d],f=n[2*d+1];p>=e&&p<=i&&f>=t&&f<=r&&l.push(a[d]),(0===u?e<=p:t<=f)&&(Xx[s++]=c,Xx[s++]=d-1,Xx[s++]=1-u),(0===u?i>=p:r>=f)&&(Xx[s++]=d+1,Xx[s++]=h,Xx[s++]=1-u)}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:o}=this;Xx[0]=0,Xx[1]=a.length-1,Xx[2]=0;let s=3,l=0,u=i*i;for(;s>0;){let h=Xx[--s],c=Xx[--s],d=Xx[--s];if(c-d<=o){for(let i=d;i<=c;i++)tb(n[2*i],n[2*i+1],e,t)<=u&&(r[l++]=a[i]);continue}let p=d+c>>1,f=n[2*p],m=n[2*p+1];tb(f,m,e,t)<=u&&(r[l++]=a[p]),(0===h?e-i<=f:t-i<=m)&&(Xx[s++]=d,Xx[s++]=p-1,Xx[s++]=1-h),(0===h?e+i>=f:t+i>=m)&&(Xx[s++]=p+1,Xx[s++]=c,Xx[s++]=1-h)}return l}};function Kx(e,t,i,r,a,n){if(a-r<=i)return;let o=r+a>>1;Jx(e,t,o,r,a,n),Kx(e,t,i,r,o-1,1-n),Kx(e,t,i,o+1,a,1-n)}function Jx(e,t,i,r,a,n){for(;a>r;){if(a-r>600){let o=a-r+1,s=i-r+1,l=Math.log(o),u=.5*Math.exp(2*l/3),h=.5*Math.sqrt(l*u*(o-u)/o)*(s-o/2<0?-1:1);Jx(e,t,i,Math.max(r,Math.floor(i-s*u/o+h)),Math.min(a,Math.floor(i+(o-s)*u/o+h)),n)}let o=t[2*i+n],s=r,l=a;for(Qx(e,t,r,i),t[2*a+n]>o&&Qx(e,t,r,a);s<l;){for(Qx(e,t,s,l),s++,l--;t[2*s+n]<o;)s++;for(;t[2*l+n]>o;)l--}t[2*r+n]===o?Qx(e,t,r,l):(l++,Qx(e,t,l,a)),l<=i&&(r=l+1),i<=l&&(a=l-1)}}function Qx(e,t,i,r){eb(e,i,r),eb(t,2*i,2*r),eb(t,2*i+1,2*r+1)}function eb(e,t,i){let r=e[t];e[t]=e[i],e[i]=r}function tb(e,t,i,r){let a=e-i,n=t-r;return a*a+n*n}var ib=.03125,rb=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*ib),y:Math.floor(e.anchorY*ib)})),crossTileIDs:n.map(e=>e.crossTileID)};if(e.positions.length>128){let t=new Yx(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:o,z:s}=t.canonical,l=ib/2**(s-a),u=(n*re+e.anchorX)*l,h=(o*re+e.anchorY)*l,c=i*re*ib,d=r*re*ib;return{x:Math.floor(u-c),y:Math.floor(h-d)}}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 o=this._symbolsByKey[n.key];if(!o)continue;let s=this.getScaledCoordinates(n,t);o.index?this.findMatchesForIndexedEntry(o,n,s,r,i):o.positions&&this.findMatchesForNonIndexedEntry(o,n,s,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),o=1/0;for(let s of n)s<o&&!a[e.crossTileIDs[s]]&&(o=s);if(o!==1/0){let i=e.crossTileIDs[o];a[i]=!0,t.crossTileID=i}}findMatchesForNonIndexedEntry(e,t,i,r,a){for(let n=0;n<e.positions.length;n++){let o=e.positions[n],s=e.crossTileIDs[n];if(Math.abs(o.x-i.x)<=r&&Math.abs(o.y-i.y)<=r&&!a[s]){a[s]=!0,t.crossTileID=s;break}}}getCrossTileIDsLists(){return Object.values(this._symbolsByKey).map(({crossTileIDs:e})=>e)}},ab=class{constructor(){this.maxCrossTileID=0}generate(){return++this.maxCrossTileID}},nb=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 rb(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}},ob=class{constructor(){this.layerIndexes={},this.crossTileIDs=new ab,this.maxBucketInstanceId=0,this.bucketsInCurrentPlacement={}}addLayer(e,t,i){let r=this.layerIndexes[e.id];void 0===r&&(r=this.layerIndexes[e.id]=new nb);let a=!1,n={};r.handleWrapJump(i);for(let o of t){let t=o.getBucket(e);e.id===t?.layerIds[0]&&(t.bucketInstanceId||=(this.maxBucketInstanceId+=1,this.maxBucketInstanceId),r.addBucket(o.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]}},sb="void main() {fragColor=vec4(1.0);}",lb={prelude:ub("#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;layout(std140) uniform ProjectionUBO {highp mat4 u_projection_matrix;highp mat4 u_projection_fallback_matrix;highp vec4 u_projection_tile_mercator_coords;highp vec4 u_projection_clipping_plane;highp float u_projection_transition;highp int u_projection_clip_antimeridian;};layout(std140) uniform FrameUBO {highp vec2 u_units_to_pixels;highp vec2 u_world_size;highp float u_camera_to_center_distance;highp float u_symbol_fade_change;highp float u_aspect_ratio;highp float u_device_pixel_ratio;highp vec2 u_viewport_size;highp vec2 u_pixel_extrude_scale;highp float u_pitch;};","#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 highp sampler2D u_depth;layout(std140) uniform TerrainUBO {highp mat4 u_terrain_matrix;highp vec4 u_terrain_unpack;highp float u_terrain_dim;highp float u_terrain_exaggeration;};\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.5;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;\n#define PROJECTION_UBO\nlayout(std140) uniform ProjectionUBO {highp mat4 u_projection_matrix;highp mat4 u_projection_fallback_matrix;highp vec4 u_projection_tile_mercator_coords;highp vec4 u_projection_clipping_plane;highp float u_projection_transition;highp int u_projection_clip_antimeridian;};layout(std140) uniform FrameUBO {highp vec2 u_units_to_pixels;highp vec2 u_world_size;highp float u_camera_to_center_distance;highp float u_symbol_fade_change;highp float u_aspect_ratio;highp float u_device_pixel_ratio;highp vec2 u_viewport_size;highp vec2 u_pixel_extrude_scale;highp float u_pitch;};"),projectionMercator:ub("\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:ub("in highp float v_projection_tile_x;void clipAntimeridian() {if (u_projection_clip_antimeridian !=0 && (v_projection_tile_x < 0.0 || v_projection_tile_x >=8192.0)) {discard;}}","#define GLOBE_RADIUS 6371008.8\n#ifndef PROJECTION_UBO\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;\n#endif\nout 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:ub("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,a_pos);}"),backgroundPattern:ub("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,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:ub("in vec3 v_data;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 vec2 u_translate;layout(location=0) in ivec2 a_pos;out vec3 v_data;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:ub(sb,"layout(location=0) in vec2 a_pos;void main() {gl_Position=projectTile(a_pos,a_pos);}"),heatmap:ub("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:ub("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;layout(location=0) in vec2 a_pos;out vec2 v_pos;void main() {gl_Position=u_matrix*vec4(a_pos*u_world_size,0,1);v_pos.x=a_pos.x;v_pos.y=1.0-a_pos.y;}"),collisionBox:ub("in float v_placed;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;out float v_placed;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:ub("in float v_radius;in vec2 v_extrude;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;out float v_radius;out vec2 v_extrude;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:ub("#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=2.0/u_dimension;float scale=(u_dimension.x-4.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:ub("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:ub(sb,"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:ub("#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:ub("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_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_size;\n#ifdef GLOBE\nv_depth=gl_Position.z/gl_Position.w;\n#endif\n}"),fillOutlinePattern:ub("uniform vec2 u_texsize;uniform sampler2D u_image;uniform float u_fade;uniform bool u_sdf_pattern;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 highp vec4 color\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 highp vec4 color\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);if (u_sdf_pattern) {highp float sdf_edge=(256.0-64.0)/256.0;highp float sdf_gamma_a=max(fwidth(color1.a)*0.5,1.0/255.0/16.0);highp float sdf_gamma_b=max(fwidth(color2.a)*0.5,1.0/255.0/16.0);float sdf_alpha_a=smoothstep(sdf_edge-sdf_gamma_a,sdf_edge+sdf_gamma_a,color1.a);float sdf_alpha_b=smoothstep(sdf_edge-sdf_gamma_b,sdf_edge+sdf_gamma_b,color2.a);fragColor=mix(color*sdf_alpha_a,color*sdf_alpha_b,u_fade)*alpha*opacity;} else {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_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 highp vec4 color\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 highp vec4 color\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_size;\n#ifdef GLOBE\nv_depth=gl_Position.z/gl_Position.w;\n#endif\n}"),fillPattern:ub("#ifdef GL_ES\nprecision highp float;\n#endif\nuniform vec2 u_texsize;uniform float u_fade;uniform bool u_sdf_pattern;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 highp vec4 color\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 highp vec4 color\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);if (u_sdf_pattern) {highp float sdf_edge=(256.0-64.0)/256.0;highp float sdf_gamma_a=max(fwidth(color1.a)*0.5,1.0/255.0/16.0);highp float sdf_gamma_b=max(fwidth(color2.a)*0.5,1.0/255.0/16.0);float sdf_alpha_a=smoothstep(sdf_edge-sdf_gamma_a,sdf_edge+sdf_gamma_a,color1.a);float sdf_alpha_b=smoothstep(sdf_edge-sdf_gamma_b,sdf_edge+sdf_gamma_b,color2.a);fragColor=mix(color*sdf_alpha_a,color*sdf_alpha_b,u_fade)*opacity;} else {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 highp vec4 color\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 highp vec4 color\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:ub("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);float gradient_base=max(0.0,base);float gradient_height=max(0.0,height);\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.z==0.0) {directional*=((1.0-u_vertical_gradient)+(u_vertical_gradient*clamp((t+gradient_base)*pow(gradient_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:ub("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;float gradient_base=max(0.0,base);float gradient_height=max(0.0,height);\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.z==0.0) {directional*=((1.0-u_vertical_gradient)+(u_vertical_gradient*clamp((t+gradient_base)*pow(gradient_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:ub("#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;uniform float u_log2_world_width;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-4.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+(3.0+u_log2_world_width-u_zoom));fragColor=clamp(vec4(deriv.x/8.0+128.0/255.0,deriv.y/8.0+128.0/255.0,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:ub("uniform sampler2D u_image;in highp 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() {highp vec2 size=vec2(textureSize(u_image,0));highp vec2 texturePos=(v_pos*(size-2.0)+1.0)/size;vec4 pixel=texture(u_image,texturePos);float scaleFactor=cos(radians((u_latrange[0]-u_latrange[1])*(1.0-v_pos.y)+u_latrange[1]));vec2 deriv=(pixel.rg-128.0/255.0)*8.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:ub("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;layout(location=2) in vec2 a_offset_normal;uniform vec2 u_translation;uniform mediump float u_ratio;out vec2 v_normal;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);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 vec2 offset2=offset*a_offset_normal*scale*normal.y;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:ub("uniform sampler2D u_image;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 vec2 a_offset_normal;layout(location=3) in float a_uv_x;layout(location=4) in float a_split_index;uniform vec2 u_translation;uniform mediump float u_ratio;uniform float u_image_height;out vec2 v_normal;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);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 vec2 offset2=offset*a_offset_normal*scale*normal.y;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:ub("#ifdef GL_ES\nprecision highp float;\n#endif\nuniform vec2 u_texsize;uniform float u_fade;uniform mediump vec3 u_scale;uniform sampler2D u_image;in vec2 v_normal;in vec2 v_width2;in float v_linesofar;in float v_gamma_scale;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;layout(location=2) in vec2 a_offset_normal;uniform vec2 u_translation;uniform mediump float u_ratio;out vec2 v_normal;out vec2 v_width2;out float v_linesofar;out float v_gamma_scale;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_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 vec2 offset2=offset*a_offset_normal*scale*normal.y;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:ub("uniform lowp float u_lineatlas_width;uniform sampler2D u_image;uniform float u_mix;in vec2 v_normal;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;layout(location=2) in vec2 a_offset_normal;uniform vec2 u_translation;uniform mediump float u_ratio;uniform float u_tileratio;uniform float u_crossfade_from;uniform float u_crossfade_to;uniform float u_lineatlas_height;out vec2 v_normal;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_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 vec2 offset2=offset*a_offset_normal*scale*normal.y;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:ub("uniform sampler2D u_image;uniform sampler2D u_image_dash;uniform float u_mix;uniform lowp float u_lineatlas_width;in vec2 v_normal;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 vec2 a_offset_normal;layout(location=3) in float a_uv_x;layout(location=4) in float a_split_index;uniform vec2 u_translation;uniform mediump float u_ratio;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;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_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 vec2 offset2=offset*a_offset_normal*scale*normal.y;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:ub("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:ub("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_image_warp;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 topLeft=u_coords_top.xy;vec2 topRight=u_coords_top.zw;vec2 bottomLeft=u_coords_bottom.xy;vec2 bottomRight=u_coords_bottom.zw;vec2 bilinearPos=mix(mix(topLeft,topRight,fractionalPos.x),mix(bottomLeft,bottomRight,fractionalPos.x),fractionalPos.y);float denominator=dot(u_image_warp.xy,fractionalPos)+1.0;vec2 acrossTop=topRight-topLeft+u_image_warp.x*topRight;vec2 downLeft=bottomLeft-topLeft+u_image_warp.y*bottomLeft;vec2 projectivePos=(acrossTop*fractionalPos.x+downLeft*fractionalPos.y+topLeft)/denominator;vec2 position=mix(projectivePos,bilinearPos,u_image_warp.z);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=mix(1.0/denominator,1.0,u_image_warp.z);v_pos0=vec3(texturePos*perspectiveRatio,perspectiveRatio);vec2 parentPos=(texturePos*u_scale_parent)+u_tl_parent;v_pos1=vec3(parentPos*perspectiveRatio,perspectiveRatio);}"),symbolIcon:ub("uniform sampler2D u_texture;in vec2 v_tex;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;layout(location=5) in float a_height_offset;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 bool u_rotate_symbol;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;uniform bool u_height_anchor_ground;out vec2 v_tex;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=a_height_offset+(u_height_anchor_ground ? get_elevation(a_pos) : 0.0);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_symbol_fade_change :-u_symbol_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:ub("#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 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;layout(location=5) in float a_height_offset;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 bool u_rotate_symbol;uniform vec2 u_texsize;uniform vec2 u_translation;uniform float u_pitched_scale;uniform bool u_is_offset;uniform bool u_height_anchor_ground;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=a_height_offset+(u_height_anchor_ground ? get_elevation(a_pos) : 0.0);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_symbol_fade_change :-u_symbol_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:ub("#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;in vec4 v_data0;in vec3 v_data1;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;layout(location=4) in float a_height_offset;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_rotate_symbol;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;uniform bool u_height_anchor_ground;out vec4 v_data0;out vec3 v_data1;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=a_height_offset+(u_height_anchor_ground ? get_elevation(a_pos) : 0.0);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_symbol_fade_change :-u_symbol_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:ub("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:ub("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;}"),terrainHeight:ub("in highp float v_elevation;void main() {fragColor=vec4(v_elevation,0.0,0.0,1.0);}","layout(location=0) in vec3 a_pos3d;uniform vec4 u_tile_bounds;out highp float v_elevation;void main() {v_elevation=get_elevation(a_pos3d.xy);vec2 position=u_tile_bounds.xy+a_pos3d.xy/8192.0*u_tile_bounds.zw;gl_Position=vec4(position.x*2.0-1.0,1.0-position.y*2.0,0.0,1.0);}"),atmosphere:ub("#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:ub("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;uniform vec3 u_globe_position;uniform float u_globe_radius;uniform float u_atmosphere_blend;in vec3 v_view_direction;const float ATMOSPHERE_HEIGHT_TO_GLOBE_RADIUS=100000.0/6371000.0;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;float opacity=1.0;if (u_sky_blend > 0.0) {vec3 ray=normalize(v_view_direction);float globe_distance=length(u_globe_position);float angle_to_globe_center=acos(clamp(dot(ray,u_globe_position)/globe_distance,-1.0,1.0));float horizon_angle=asin(min(u_globe_radius/globe_distance,1.0));blend=mix(blend,((angle_to_globe_center-horizon_angle)*u_camera_to_center_distance+1.0)*u_device_pixel_ratio,u_sky_blend);float closest_approach=max(dot(ray,u_globe_position),0.0);float lowest_altitude=sqrt(max(globe_distance*globe_distance-closest_approach*closest_approach,0.0))-u_globe_radius;float atmosphere_height=u_globe_radius*ATMOSPHERE_HEIGHT_TO_GLOBE_RADIUS;float inside_atmosphere=1.0-smoothstep(atmosphere_height,10.0*atmosphere_height,globe_distance-u_globe_radius);float through_atmosphere=1.0-smoothstep(0.0,atmosphere_height,lowest_altitude);opacity=inside_atmosphere*through_atmosphere*(1.0-u_atmosphere_blend);}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(1.0,opacity,u_sky_blend);}","layout(location=0) in vec2 a_pos;uniform mat4 u_inv_proj_matrix;out vec3 v_view_direction;void main() {v_view_direction=(u_inv_proj_matrix*vec4(a_pos,0.0,1.0)).xyz;gl_Position=vec4(a_pos,1.0,1.0);}")};function ub(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),o=n?n.concat(a):a,s=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",o=a.match(/color/)?"color":n;return l[a]?"define"===t?`\n#ifndef HAS_UNIFORM_u_${a}\nuniform lowp float u_${a}_t;\nlayout(location = ${s++}) in ${i} ${n} a_${a};\nout ${i} ${r} ${a};\n#else\nuniform ${i} ${r} u_${a};\n#endif\n`:"vec4"===o?`\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_${o}(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 = ${s++}) in ${i} ${n} a_${a};\n#else\nuniform ${i} ${r} u_${a};\n#endif\n`:"vec4"===o?`\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_${o}(a_${a}, u_${a}_t);\n#else\n ${i} ${r} ${a} = u_${a};\n#endif\n`}),{fragmentSource:e,vertexSource:t,staticAttributes:r,staticUniforms:o}}var hb="#define PROJECTION_MERCATOR",cb="mercator",db=class{constructor(e=ud){this._cachedMesh=null,this._worldCoordinateHelper=e}get name(){return this._worldCoordinateHelper.name}get worldCoordinateHelper(){return this._worldCoordinateHelper}get useSubdivision(){return!1}get shaderVariantName(){return cb}get shaderDefine(){return hb}get shaderPreludeCode(){return lb.projectionMercator}get vertexShaderPreludeCode(){return lb.projectionMercator.vertexSource}get subdivisionGranularity(){return Ec.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 Pl;n.emplaceBack(0,0),n.emplaceBack(re,0),n.emplaceBack(0,re),n.emplaceBack(re,re);let o=e.createVertexBuffer(n,G_.members),s=Yl.simpleSegment(0,0,4,2),l=new Zl;l.emplaceBack(1,0,2),l.emplaceBack(1,2,3);let u=e.createIndexBuffer(l);return this._cachedMesh=new $_(o,u,s),this._cachedMesh}recalculate(){}hasTransition(){return!1}},pb=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=gr.number(e.top,t.top,i)),null!=t.bottom&&null!=e.bottom&&(this.bottom=gr.number(e.bottom,t.bottom,i)),null!=t.left&&null!=e.left&&(this.left=gr.number(e.left,t.left,i)),null!=t.right&&null!=e.right&&(this.right=gr.number(e.right,t.right,i)),this}getCenter(e,t){return new d(Se((this.left+e-this.right)/2,0,e),Se((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 fb(e){return e.edgeInsets.getCenter(e.width,e.height)}function mb(e){return fb(e)._sub(new d(e.width,e.height)._div(2))}function _b(e){return e.tileSize*e.scale}function gb(e){return e.bearingInRadians/Math.PI*180}function yb(e){return e.pitchInRadians/Math.PI*180}function vb(e){return e.rollInRadians/Math.PI*180}function xb(e){return We(e.fovInRadians)}function bb(e,t){if(!e.renderWorldCopies||!e.worldCoordinateHelper.wraps||e.lngRange)return;let i=t.lng-e.center.lng;t.lng+=i>180?-360:i<-180?360:0}var wb=class{constructor(e,t){this.applyConstrain=(e,t)=>null===this._constrainOverride?this._callbacks.defaultConstrain(e,t):this._constrainOverride(e,t),this._callbacks=e,this._cameraState=function(e){return{tileSize:512,width:0,height:0,center:new Kc(0,0),elevation:0,zoom:0,bearingInRadians:0,pitchInRadians:0,rollInRadians:0,fovInRadians:.6435011087932844,edgeInsets:new pb,minZoom:e?.minZoom||0,maxZoom:e?.maxZoom||22,minPitch:null==e?.minPitch?0:e?.minPitch,maxPitch:null==e?.maxPitch?60:e?.maxPitch,lngRange:null,latRange:[-85.051129,Ke],renderWorldCopies:void 0===e?.renderWorldCopies||!!e?.renderWorldCopies,minElevationForCurrentTile:0,nearFarZOverride:null,tileZoom:0,scale:1,pixelsPerMeter:void 0,cameraToCenterDistance:void 0,rotationMatrix:void 0,pixelsToGLUnits:void 0,pixelsToClipSpaceMatrix:void 0,clipSpaceToPixelsMatrix:void 0}}(t),this._worldCoordinateHelper=t?.worldCoordinateHelper??ud,this._constrainOverride=t?.constrainOverride??null,this._unmodified=!0}apply(e,t){this._constrainOverride=e.constrainOverride,this._cameraState.latRange=e.latRange,this._cameraState.lngRange=e.lngRange,this._cameraState.width=e.width,this._cameraState.height=e.height,this._cameraState.center=e.center,this._cameraState.elevation=e.elevation,this._cameraState.minElevationForCurrentTile=e.minElevationForCurrentTile,this._cameraState.zoom=e.zoom,this._cameraState.tileZoom=function(e){return Math.max(0,Math.floor(e))}(this._cameraState.zoom),this._cameraState.scale=Ie(this._cameraState.zoom),this._cameraState.bearingInRadians=e.bearingInRadians,this._cameraState.fovInRadians=e.fovInRadians,this._cameraState.pitchInRadians=e.pitchInRadians,this._cameraState.rollInRadians=e.rollInRadians,this._unmodified=e.unmodified,this._cameraState.edgeInsets=new pb(e.padding.top,e.padding.bottom,e.padding.left,e.padding.right),this._cameraState.minZoom=e.minZoom,this._cameraState.maxZoom=e.maxZoom,this._cameraState.minPitch=e.minPitch,this._cameraState.maxPitch=e.maxPitch,this._cameraState.renderWorldCopies=e.renderWorldCopies,this._cameraState.cameraToCenterDistance=e.cameraToCenterDistance,this._cameraState.nearFarZOverride=e.nearFarZOverride,t&&this.constrainInternal(),this._calcMatrices()}get pixelsToClipSpaceMatrix(){return this._cameraState.pixelsToClipSpaceMatrix}get clipSpaceToPixelsMatrix(){return this._cameraState.clipSpaceToPixelsMatrix}get minElevationForCurrentTile(){return this._cameraState.minElevationForCurrentTile}setMinElevationForCurrentTile(e){e!==this._cameraState.minElevationForCurrentTile&&(this._cameraState.minElevationForCurrentTile=e,this._calcMatrices())}get tileSize(){return this._cameraState.tileSize}get tileZoom(){return this._cameraState.tileZoom}get scale(){return this._cameraState.scale}get width(){return this._cameraState.width}get height(){return this._cameraState.height}get bearingInRadians(){return this._cameraState.bearingInRadians}get lngRange(){return this._cameraState.lngRange}get latRange(){return this._cameraState.latRange}get worldCoordinateHelper(){return this._worldCoordinateHelper}get pixelsToGLUnits(){return this._cameraState.pixelsToGLUnits}get minZoom(){return this._cameraState.minZoom}setMinZoom(e){if(this._cameraState.minZoom===e)return;this._cameraState.minZoom=e;let t=this._unmodified;this.setZoom(this.applyConstrain(this._cameraState.center,this.zoom).zoom),this._unmodified=t}get maxZoom(){return this._cameraState.maxZoom}setMaxZoom(e){if(this._cameraState.maxZoom===e)return;this._cameraState.maxZoom=e;let t=this._unmodified;this.setZoom(this.applyConstrain(this._cameraState.center,this.zoom).zoom),this._unmodified=t}get minPitch(){return this._cameraState.minPitch}setMinPitch(e){if(this._cameraState.minPitch===e)return;this._cameraState.minPitch=e;let t=this._unmodified;this.setPitch(Math.max(this.pitch,e)),this._unmodified=t}get maxPitch(){return this._cameraState.maxPitch}setMaxPitch(e){if(this._cameraState.maxPitch===e)return;this._cameraState.maxPitch=e;let t=this._unmodified;this.setPitch(Math.min(this.pitch,e)),this._unmodified=t}get renderWorldCopies(){return this._cameraState.renderWorldCopies}setRenderWorldCopies(e){void 0===e?e=!0:null===e&&(e=!1),e&&!this._worldCoordinateHelper.wraps&&Oe("renderWorldCopies has no effect in a projection whose world does not wrap."),this._cameraState.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 _b(this._cameraState)}get size(){return new d(this._cameraState.width,this._cameraState.height)}get bearing(){return gb(this._cameraState)}setBearing(e){let t=De(e,-180,180)*Math.PI/180;this._cameraState.bearingInRadians!==t&&(this._unmodified=!1,this._cameraState.bearingInRadians=t,this._calcMatrices(),this._cameraState.rotationMatrix=_(),function(e,t,i){var r=t[0],a=t[1],n=t[2],o=t[3],s=Math.sin(i),l=Math.cos(i);e[0]=r*l+n*s,e[1]=a*l+o*s,e[2]=r*-s+n*l,e[3]=a*-s+o*l}(this._cameraState.rotationMatrix,this._cameraState.rotationMatrix,-this._cameraState.bearingInRadians))}get rotationMatrix(){return this._cameraState.rotationMatrix}get pitchInRadians(){return this._cameraState.pitchInRadians}get pitch(){return yb(this._cameraState)}setPitch(e){let t=Se(e,this.minPitch,this.maxPitch)/180*Math.PI;this._cameraState.pitchInRadians!==t&&(this._unmodified=!1,this._cameraState.pitchInRadians=t,this._calcMatrices())}get rollInRadians(){return this._cameraState.rollInRadians}get roll(){return vb(this._cameraState)}setRoll(e){let t=e/180*Math.PI;this._cameraState.rollInRadians!==t&&(this._unmodified=!1,this._cameraState.rollInRadians=t,this._calcMatrices())}get fovInRadians(){return this._cameraState.fovInRadians}get fov(){return xb(this._cameraState)}setFov(e){e=Se(e,.1,150),this.fov!==e&&(this._unmodified=!1,this._cameraState.fovInRadians=qe(e),this._calcMatrices())}get zoom(){return this._cameraState.zoom}setZoom(e){let t=this.applyConstrain(this._cameraState.center,e).zoom;this._cameraState.zoom!==t&&(this._unmodified=!1,this._cameraState.zoom=t,this._cameraState.tileZoom=Math.max(0,Math.floor(t)),this._cameraState.scale=Ie(t),this.constrainInternal(),this._calcMatrices())}get center(){return this._cameraState.center}setCenter(e){(e.lat!==this._cameraState.center.lat||e.lng!==this._cameraState.center.lng)&&(this._unmodified=!1,this._cameraState.center=e,this.constrainInternal(),this._calcMatrices())}setCenterAndZoom(e,t){let i=this._cameraState;this._unmodified=!1,i.center=e,i.zoom=t,i.tileZoom=Math.max(0,Math.floor(t)),i.scale=Ie(t),this._calcMatrices()}get elevation(){return this._cameraState.elevation}setElevation(e){e!==this._cameraState.elevation&&(this._cameraState.elevation=e,this.constrainInternal(),this._calcMatrices())}get padding(){return this._cameraState.edgeInsets.toJSON()}setPadding(e){this._cameraState.edgeInsets.equals(e)||(this._unmodified=!1,this._cameraState.edgeInsets.interpolate(this._cameraState.edgeInsets,e,1),this.constrainInternal(),this._calcMatrices())}get centerPoint(){return fb(this._cameraState)}get pixelsPerMeter(){return this._cameraState.pixelsPerMeter}get unmodified(){return this._unmodified}get cameraState(){return this._cameraState}get cameraToCenterDistance(){return this._cameraState.cameraToCenterDistance}get nearFarZOverride(){return this._cameraState.nearFarZOverride}get autoCalculateNearFarZ(){return null===this._cameraState.nearFarZOverride}overrideNearFarZ(e,t){this._cameraState.nearFarZOverride={nearZ:e,farZ:t},this._calcMatrices()}clearNearFarZOverride(){this._cameraState.nearFarZOverride=null,this._calcMatrices()}isPaddingEqual(e){return this._cameraState.edgeInsets.equals(e)}interpolatePadding(e,t,i){this._unmodified=!1,this._cameraState.edgeInsets.interpolate(e,t,i),this.constrainInternal(),this._calcMatrices()}resize(e,t,i=!0){this._cameraState.width=e,this._cameraState.height=t,i&&this.constrainInternal(),this._calcMatrices()}getMaxBounds(){return this._cameraState.lngRange||-85.051129!==this._cameraState.latRange[0]||85.051129!==this._cameraState.latRange[1]?new c_([this._cameraState.lngRange?.[0]??-1/0,this._cameraState.latRange[0],this._cameraState.lngRange?.[1]??1/0,this._cameraState.latRange[1]]):null}setMaxBounds(e){if(!e)return this._cameraState.lngRange=null,void(this._cameraState.latRange=[-85.051129,Ke]);let t=e.getWest(),i=e.getEast(),r=e.getSouth(),a=e.getNorth(),n=t===-1/0&&i===1/0;if(!(Number.isFinite(t)&&Number.isFinite(i)||n))throw Error("Longitude maxBounds values must either be finite or span from -Infinity to Infinity");this._cameraState.lngRange=n?null:[t,i],this._cameraState.latRange=[Se(r,-85.051129,Ke),Se(a,-85.051129,Ke)],this.constrainInternal()}getCameraQueryGeometry(e,t){if(1===t.length)return[t[0],e];{let{minX:i,minY:r,maxX:a,maxY:n}=ku.fromPoints(t).extend(e);return[new d(i,r),new d(a,r),new d(a,n),new d(i,n),new d(i,r)]}}getConstrainedCamera(e,t){if(!this._cameraState.width||!this._cameraState.height)return{center:e,zoom:t};let i=this.applyConstrain(e,t);return{center:i.center,zoom:this.applyConstrain(i.center,i.zoom).zoom}}constrainInternal(){if(!this.center||!this._cameraState.width||!this._cameraState.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._cameraState.pixelsPerMeter=this.worldCoordinateHelper.worldZFromAltitude(1,this.center)*this.worldSize,!this._cameraState.width||!this._cameraState.height)return;this._cameraState.pixelsToGLUnits=[2/this._cameraState.width,-2/this._cameraState.height];let e=x(/* @__PURE__ */new Float64Array(16));S(e,e,[this._cameraState.width/2,-this._cameraState.height/2,1]),T(e,e,[1,-1,0]),this._cameraState.clipSpaceToPixelsMatrix=e,e=x(/* @__PURE__ */new Float64Array(16)),S(e,e,[1,-1,1]),T(e,e,[-1,-1,0]),S(e,e,[2/this._cameraState.width,2/this._cameraState.height,1]),this._cameraState.pixelsToClipSpaceMatrix=e;let t=this.fovInRadians/2;this._cameraState.cameraToCenterDistance=.5/Math.tan(t)*this._cameraState.height,this._callbacks.calcMatrices()}calculateCenterFromCameraLngLatAlt(e,t,i,r){let a=void 0===i?this.bearing:i,n=r=void 0===r?this.pitch:r,{distanceToCenter:o,clampedElevation:s}=this._distanceToCenterFromAltElevationPitch(t,this.elevation,n),{x:l,y:u}=gd(n,a),h=this.worldCoordinateHelper,c=Kc.convert(e),d=h.worldFromLngLat(c.lng,c.lat,t),{centerMercator:p,dMercator:f}=this._centerAlongView(d,l,u,o,h.metersPerWorldUnit(d.x,d.y));return{center:h.lngLatFromWorld(p.x,p.y),elevation:s,zoom:Me(this.height/2/Math.tan(this.fovInRadians/2)/f/this.tileSize)}}recalculateZoomAndCenter(e){if(this.elevation-e===0)return;let t=this.pitch,i=this.bearing,{x:r,y:a,z:n}=gd(t,i),o=this.worldCoordinateHelper,s=o.worldFromLngLat(this.center.lng,this.center.lat,this.elevation),l=1/o.worldZFromAltitude(1,this.center),u=this.cameraToCenterDistance/this.worldSize,h=new ld(s.x-r*u,s.y-a*u,s.z+n*u),{distanceToCenter:c,clampedElevation:d}=this._distanceToCenterFromAltElevationPitch(h.z*l,e,t),{centerMercator:p,dMercator:f}=this._centerAlongView(h,r,a,c,l),m=o.lngLatFromWorld(p.x,p.y),_=Me(this.cameraToCenterDistance/f/this.tileSize);this._cameraState.elevation=d,this._cameraState.center=m;let g=this._cameraState.zoom;this.setZoom(_),this._cameraState.zoom===g&&(this._unmodified=!1,this.constrainInternal(),this._calcMatrices())}_centerAlongView(e,t,i,r,a){let n=r/a,o=new ld(e.x+t*n,e.y+i*n),s=1/0;for(let l=1;l<10;l++){let l=this.worldCoordinateHelper.metersPerWorldUnit(o.x,o.y),u=Math.abs(l-a);if(u<=1e-12*a||u>=s)break;s=u,n=r/(a=l),o=new ld(e.x+t*n,e.y+i*n)}return{centerMercator:o,dMercator:n}}_distanceToCenterFromAltElevationPitch(e,t,i){let r,a=-Math.cos(qe(i)),n=e-t,o=t;return a*n>=0||Math.abs(a)<Math.cos(qe(89.25))?(r=1e4,o=e+r*a):r=-n/a,{distanceToCenter:r,clampedElevation:o}}getCameraPoint(){let e=this.pitchInRadians,t=Math.tan(e)*(this.cameraToCenterDistance||1);return this.centerPoint.add(new d(t*Math.sin(this.rollInRadians),t*Math.cos(this.rollInRadians)))}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/re,1/t/re]}},Tb=class{getCenter(e){return e.center}distanceToTile2d(e,t,i,r){let a=r,n=a.distanceX([e,t]),o=a.distanceY([e,t]);return Math.hypot(n,o)}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 y_(e.z,t,e.z,e.x,e.y),o=r.terrain.getMinMaxElevation(i);a=o.minElevation??a,n=o.maxElevation??n}let o=1<<e.z;return new jv([t+e.x/o,e.y/o,a],[t+(e.x+1)/o,(e.y+1)/o,n])}allowVariableZoom(e,t){let i=Se(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(){}},Sb=re*(1-1e-12),Db={covered:!1,demLoaded:!1,elevation:0},Eb=class{constructor(e,t,i=()=>ud){this.tileManager=e,this.exaggeration=t,this.getWorldCoordinateHelper=i,this._samplerCache=/* @__PURE__ */new Map}reset(){this._samplerCache.clear(),this._index=void 0,this._ownDemIndex=void 0}getIndex(e=!1){return e?(void 0===this._ownDemIndex&&(this._ownDemIndex=this._build(!0)),this._ownDemIndex):(void 0===this._index&&(this._index=this._build(!1)),this._index)}sample(e,t=!1){let i=this.getIndex(t);if(!i)return;let r=this.getWorldCoordinateHelper(),{x:a,y:n}=r.worldFromLngLat(e.lng,e.lat),o=Cb(i,this.exaggeration,a,n,r.wraps);return o.demLoaded?o.elevation:void 0}getSampler(e){let t=e.key,i=this._samplerCache.get(t);if(i)return i;let r=this._createElevationSampler(e);return r&&this._samplerCache.set(t,r),r}_createElevationSampler(e){let t=this.tileManager.getSourceTile(e,!0),i=t?.dem;if(!t||!i)return null;let r=e.canonical.z-t.tileID.canonical.z,a=1<<r,n=i.dim/(re*a),o=(e.canonical.x-(e.canonical.x>>r<<r))/a*i.dim-.5,s=(e.canonical.y-(e.canonical.y>>r<<r))/a*i.dim-.5;return(e,t,r)=>{let a=8192===r?1:re/r;return i.sampleBilinear(e*a*n+o,t*a*n+s)}}_build(e){let{tileManager:t}=this,i=[],r=/* @__PURE__ */new Map,a=0,n=0;for(let o of t.getRenderableTiles()){if(!o)continue;let{canonical:s,wrap:l}=o.tileID;i.includes(s.z)||i.push(s.z);let u=e&&!t.getSourceTile(o.tileID)?.dem?null:this.getSampler(o.tileID);r.set(`${l}/${s.z}/${s.x}/${s.y}`,u);let h=t.getSourceTile(o.tileID,!0)?.dem;a=Math.min(a,(h?.min??0)*this.exaggeration),n=Math.max(n,(h?.max??0)*this.exaggeration)}return 0===r.size?null:(i.sort((e,t)=>t-e),{zooms:i,samplerPerTile:r,minElevation:a-10,maxElevation:n+10})}};function Cb(e,t,i,r,a){if(r<0||r>=1||!a&&(i<0||i>=1))return Db;let n=a?Math.floor(i):0,o=i-n;for(let s of e.zooms){let i=1<<s,a=o*i,l=r*i,u=Math.floor(a),h=Math.floor(l),c=`${n}/${s}/${u}/${h}`;if(!e.samplerPerTile.has(c))continue;let d=e.samplerPerTile.get(c);return d?{covered:!0,demLoaded:!0,elevation:d(Math.min((a-u)*re,Sb),Math.min((l-h)*re,Sb),re)*t}:{covered:!0,demLoaded:!1,elevation:0}}return Db}function Pb(e,t){return e.covered&&t<=e.elevation+1e-6}function Ab(e,t,i,r,a){for(let n=0;n<40&&r-i>a;n++){let a=(i+r)/2;t(e,a)?r=a:i=a}return{lo:i,hi:r}}var Ib=class e{get pixelsToClipSpaceMatrix(){return this._helper.pixelsToClipSpaceMatrix}get clipSpaceToPixelsMatrix(){return this._helper.clipSpaceToPixelsMatrix}get pixelsToGLUnits(){return this._helper.pixelsToGLUnits}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._nearZ}get farZ(){return this._farZ}get nearFarZOverride(){return this._helper.nearFarZOverride}get autoCalculateNearFarZ(){return this._helper.autoCalculateNearFarZ}setTransitionState(e){}constructor(e,t){this._posMatrixCache=/* @__PURE__ */new Map,this._alignedPosMatrixCache=/* @__PURE__ */new Map,this._fogMatrixCacheF32=/* @__PURE__ */new Map,this._maxBoundsWorldBox=null,this.defaultConstrain=(e,t)=>{if(t=Se(+t,this._cameraState.minZoom,this._cameraState.maxZoom),!this.worldCoordinateHelper.wraps)return this._constrainToWorldSquare(e,t);let i={center:new Kc(e.lng,e.lat),zoom:t},r=this._cameraState.lngRange;!this._cameraState.renderWorldCopies&&null===r&&(r=[-179.9999999999,180-1e-10]);let a=this._cameraState.tileSize*Ie(i.zoom),n=0,o=a,s=0,l=a,u=0,h=0,{top:c=0,bottom:p=0,left:f=0,right:m=0}=this._cameraState.edgeInsets,_=this._cameraState.width-f-m,g=this._cameraState.height-c-p;if(this._cameraState.latRange){let e=this._cameraState.latRange;n=rd(e[1])*a,o=rd(e[0])*a,o-n<g&&(u=g/(o-n))}r&&(s=De(id(r[0])*a,0,a),l=De(id(r[1])*a,0,a),l<s&&(l+=a),l-s<_&&(h=_/(l-s)));let y,v,{x:x,y:b}=dd(a,e,this.worldCoordinateHelper),w=Math.max(h||0,u||0);if(w)return i.center=pd(a,new d(h?(l+s)/2:x,u?(o+n)/2:b),this.worldCoordinateHelper).wrap(),i.zoom+=Me(w),i;if(this._cameraState.latRange){let e=g/2;b-e<n&&(v=n+e),b+e>o&&(v=o-e)}if(r){let e=(s+l)/2,t=x;this._cameraState.renderWorldCopies&&(t=De(x,e-a/2,e+a/2));let i=_/2;t-i<s&&(y=s+i),t+i>l&&(y=l-i)}return(void 0!==y||void 0!==v)&&(i.center=pd(a,new d(y??x,v??b),this.worldCoordinateHelper).wrap()),i},this.applyConstrain=(e,t)=>this._helper.applyConstrain(e,t),this._helper=t??new wb({calcMatrices:()=>this._calcMatrices(),defaultConstrain:(e,t)=>this.defaultConstrain(e,t)},e),this._coveringTilesDetailsProvider=new Tb}get _cameraState(){return this._helper.cameraState}_getHorizon(){return fd({pitch:yb(this._cameraState),cameraToCenterDistance:this._cameraState.cameraToCenterDistance})}clone(){let t=new e({worldCoordinateHelper:this.worldCoordinateHelper});return t.apply(this,!1),t}get worldCoordinateHelper(){return this._helper.worldCoordinateHelper}apply(e,t){this._helper.apply(e,t)}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 g_(0,e)];if(this._cameraState.renderWorldCopies&&this.worldCoordinateHelper.wraps){let i=this.screenPointToMercatorCoordinate(new d(0,0)),r=this.screenPointToMercatorCoordinate(new d(this._cameraState.width,0)),a=this.screenPointToMercatorCoordinate(new d(this._cameraState.width,this._cameraState.height)),n=this.screenPointToMercatorCoordinate(new d(0,this._cameraState.height)),o=Math.floor(Math.min(i.x,r.x,a.x,n.x)),s=Math.floor(Math.max(i.x,r.x,a.x,n.x));for(let l=o-1;l<=s+1;l++)0!==l&&t.push(new g_(l,e))}return t}getCameraFrustum(){return Vv.fromInvProjectionMatrix(this._invViewProjMatrix,_b(this._cameraState))}getClippingPlane(){return null}getCoveringTilesDetailsProvider(){return this._coveringTilesDetailsProvider}recalculateZoomAndCenter(e){for(let t=0;t<3;t++){let t=this.getGroundElevationAtCenter(e);if(null===t||(this._helper.recalculateZoomAndCenter(t),!e||Math.abs(e.getElevationForLngLat(this._cameraState.center,this._cameraState.tileZoom)-this._cameraState.elevation)<=1e-4))return}}getGroundElevationAtCenter(e){let t=e&&this._terrainPointPastMaxZoom(e)||this.screenPointToLocation(fb(this._cameraState),e),i=e?e.getElevationForLngLat(t,this._cameraState.tileZoom):0;return yb(this._cameraState)<90&&i>=this.getCameraAltitude()?null:i}setLocationAtPoint(e,t,i){let r=this.getCameraForLocationAtPoint(e,t,i);r&&this._helper.setCenterAndZoom(r.center,r.zoom)}getCameraForLocationAtPoint(e,t,i=this._cameraState.elevation){let r=i-this._cameraState.elevation,a=this.screenPointToMercatorCoordinateAtZ(t,r),n=this.screenPointToMercatorCoordinateAtZ(fb(this._cameraState),0),o=this.worldCoordinateHelper,s=o.worldFromLngLat(e.lng,e.lat),l=o.lngLatFromWorld(s.x-(a.x-n.x),s.y-(a.y-n.y)),u=l.lng!==this._cameraState.center.lng||l.lat!==this._cameraState.center.lat?this._helper.getConstrainedCamera(l,this._cameraState.zoom):null;if(this._cameraState.renderWorldCopies&&o.wraps){let e=u??{center:this._cameraState.center,zoom:this._cameraState.zoom},t=e.center.wrap();t.lng!==e.center.lng&&(u=this._helper.getConstrainedCamera(t,e.zoom))}return u}locationToScreenPoint(e,t){let i=this.worldCoordinateHelper.worldFromLngLat(e.lng,e.lat);return t?this.coordinatePoint(i,t.getElevationForLngLat(e,this._cameraState.tileZoom),this._pixelMatrix3D):this.coordinatePoint(i)}screenPointToLocation(e,t){return this._worldToLngLat(this.screenPointToMercatorCoordinate(e,t))}screenPointToLocationAtElevation(e,t){return this._worldToLngLat(this.screenPointToMercatorCoordinateAtZ(e,t-this._cameraState.elevation))}_worldToLngLat(e){return e?this.worldCoordinateHelper.lngLatFromWorld(e.x,e.y):void 0}screenPointToMercatorCoordinate(e,t){if(t){let i=this.screenTerrainPointToMercatorCoordinate(e,t);if(null!=i)return i}return this.screenPointToMercatorCoordinateAtZ(e)}_terrainPointPastMaxZoom(e){let t=e.getCoverageIndex();if(!t)return null;let{near:i,far:r}=this.getRaySegmentFromPixel(fb(this._cameraState),-1),a=this._cameraState.cameraToCenterDistance*Ie(this._cameraState.zoom-this._cameraState.maxZoom),n=function(e,t,i,r){var a=t[0],n=t[1],o=t[2];return e[0]=a+r*(i[0]-a),e[1]=n+r*(i[1]-n),e[2]=o+r*(i[2]-o),e}([],i,r,Math.max(0,(a-this.nearZ)/(this.farZ-this.nearZ)));return Pb(Cb(t,e.exaggeration,n[0]/_b(this._cameraState),n[1]/_b(this._cameraState),this.worldCoordinateHelper.wraps),n[2])?null:this._worldToLngLat(this._raycastTerrain(n,r,e))??null}screenTerrainPointToMercatorCoordinate(e,t){let{near:i,far:r}=this.getRaySegmentFromPixel(e,-1);return this._raycastTerrain(i,r,t)}_raycastTerrain(e,t,i){let r=i.getCoverageIndex();if(!r)return null;let a=_b(this._cameraState),n=t[0]-e[0],o=t[1]-e[1],s=t[2]-e[2],l={index:r,exaggeration:i.exaggeration,near:e,dx:n,dy:o,dz:s,worldSize:a,wraps:this.worldCoordinateHelper.wraps},u=0,h=1;if(0===s){if(e[2]>r.maxElevation||e[2]<r.minElevation)return null}else{let t=(r.maxElevation-e[2])/s,i=(r.minElevation-e[2])/s;if(u=Math.max(u,Math.min(t,i)),h=Math.min(h,Math.max(t,i)),u>h)return null}let c=Math.hypot(n,o),d=Se(Math.ceil(c*(h-u)/4),1,512),p=0,f=!zb(l,0);for(let m=0;m<=d;m++){let t=u+(h-u)*m/d;if(f){if(zb(l,t)){let{lo:i,hi:r}=Ab(l,zb,p,t,.001/c),u=Fb(l,i),h=Fb(l,r),d=e[2]+i*s-u.elevation,f=e[2]+r*s-h.elevation,m=u.covered&&d>f?Se(i+d*(r-i)/(d-f),i,r):r;return new ld((e[0]+m*n)/a,(e[1]+m*o)/a,Fb(l,m).elevation)}}else f=!zb(l,t);p=t}return null}getRaySegmentFromPixel(e,t=0){let i=[e.x,e.y,t,1],r=[e.x,e.y,1,1];H(i,i,this._pixelMatrixInverse),H(r,r,this._pixelMatrixInverse);let a=i[3],n=r[3],o=this._cameraState.elevation;return{near:[i[0]/a,i[1]/a,i[2]/a+o],far:[r[0]/n,r[1]/n,r[2]/n+o]}}screenPointToMercatorCoordinateAtZ(e,t){let i=t||0,{near:r,far:a}=this.getRaySegmentFromPixel(e),n=r[2]===a[2]?0:(i+this._cameraState.elevation-r[2])/(a[2]-r[2]);return new ld(gr.number(r[0],a[0],n)/_b(this._cameraState),gr.number(r[1],a[1],n)/_b(this._cameraState),i)}coordinatePoint(e,t=0,i=this._pixelMatrix){let r=this._coordinateClipPoint(e,t,i),a=r[3];return a>0?new d(r[0]/a,r[1]/a):this._offScreenPointBehindCamera(r[0],r[1],a)}_coordinateClipPoint(e,t,i){let r=[e.x*_b(this._cameraState),e.y*_b(this._cameraState),t,1];return H(r,r,i)}_offScreenPointBehindCamera(e,t,i){let r=this._cameraState.width/2,a=this._cameraState.height/2,n=e-r*i,o=t-a*i;0===n&&0===o&&(o=1);let s=r+this._cameraState.width,l=a+this._cameraState.height,u=Math.min(0===n?1/0:s/Math.abs(n),0===o?1/0:l/Math.abs(o));return new d(r+n*u,a+o*u)}getBounds(){let e=Math.max(0,this._cameraState.height/2-this._getHorizon());return(new c_).extend(this.screenPointToLocation(new d(0,e))).extend(this.screenPointToLocation(new d(this._cameraState.width,e))).extend(this.screenPointToLocation(new d(this._cameraState.width,this._cameraState.height))).extend(this.screenPointToLocation(new d(0,this._cameraState.height)))}isPointOnMapSurface(e,t){if(t)return null!=this.screenTerrainPointToMercatorCoordinate(e,t);let i=e.y>fb(this._cameraState).y-this._getHorizon();if(!i||this.worldCoordinateHelper.wraps)return i;let r=this.screenPointToMercatorCoordinate(e);return this.worldCoordinateHelper.hasLngLat(r.x,r.y)}calculatePosMatrix(e,t=!1,i=!1){let r=e.key??v_(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=md(e,_b(this._cameraState));w(n,t?this._alignedProjMatrix:this._viewProjMatrix,n);let o={f64:n,f32:new Float32Array(n)};return a.set(r,o),i?o.f32:o.f64}calculateFogMatrix(e){let t=e.key,i=this._fogMatrixCacheF32;if(i.has(t))return i.get(t);let r=md(e,_b(this._cameraState));return w(r,this._fogMatrix,r),i.set(t,new Float32Array(r)),i.get(t)}_constrainToWorldSquare(e,t){let i=this.worldCoordinateHelper,r=this._cameraState.lngRange,a=this._cameraState.tileSize*Ie(t);if(!r){let{x:r,y:n}=dd(a,e,i),o=Se(r,0,a),s=Se(n,0,a);return o!==r||s!==n?{center:pd(a,new d(o,s),i),zoom:t}:{center:new Kc(e.lng,e.lat),zoom:t}}let n=this._projectMaxBounds(r,this._cameraState.latRange),o=Math.max(n.minX,0)*a,s=Math.min(n.maxX,1)*a,l=Math.max(n.minY,0)*a,u=Math.min(n.maxY,1)*a,{width:h,height:c}=this._cameraState,p=s-o<h?h/(s-o):0,f=u-l<c?c/(u-l):0,{x:m,y:_}=dd(a,e,i),g=Math.max(p,f);if(g)return{center:pd(a,new d(p?(s+o)/2:m,f?(u+l)/2:_),i),zoom:t+Me(g)};let y=Se(m,o+h/2,s-h/2),v=Se(_,l+c/2,u-c/2);return y!==m||v!==_?{center:pd(a,new d(y,v),i),zoom:t}:{center:new Kc(e.lng,e.lat),zoom:t}}_projectMaxBounds(e,t){let i=this._maxBoundsWorldBox;if(i?.lngRange===e&&i.latRange===t)return i.box;let r=vd(this.worldCoordinateHelper,e[0],t[0],e[1],t[1]);return this._maxBoundsWorldBox={lngRange:e,latRange:t,box:r},r}calculateCenterFromCameraLngLatAlt(e,t,i,r){return this._helper.calculateCenterFromCameraLngLatAlt(e,t,i,r)}calculateCameraOptionsFromTo(e,t,i,r){let a=this.worldCoordinateHelper,n=Kc.convert(e),o=Kc.convert(i),s=a.worldFromLngLat(n.lng,n.lat,t),l=a.worldFromLngLat(o.lng,o.lat,r),u=l.x-s.x,h=l.y-s.y,c=l.z-s.z,d=Math.hypot(u,h,c);if(0===d)throw Error("Can't calculate camera options with same From and To");let p=Math.hypot(u,h),f=Me(this._cameraState.cameraToCenterDistance/d/this._cameraState.tileSize),m=We(Math.atan2(u,-h)),_=We(Math.acos(p/d));return _=c<0?90-_:90+_,{center:a.lngLatFromWorld(l.x,l.y),elevation:r,zoom:f,pitch:_,bearing:m}}_calculateNearFarZ(e,t,i){let r=Math.min(this._cameraState.elevation,this._cameraState.minElevationForCurrentTile,this.getCameraAltitude()-100),a=e-r*this._cameraState.pixelsPerMeter/Math.cos(t),n=r<0?a:e,o=Math.PI/2+this._cameraState.pitchInRadians,s=qe(xb(this._cameraState))*(Math.abs(Math.cos(qe(vb(this._cameraState))))*this._cameraState.height+Math.abs(Math.sin(qe(vb(this._cameraState))))*this._cameraState.width)/this._cameraState.height*(.5+i.y/this._cameraState.height),l=Math.sin(s)*n/Math.sin(Se(Math.PI-o-s,.01,Math.PI-.01)),u=this._getHorizon(),h=Math.atan(u/this._cameraState.cameraToCenterDistance),c=qe(.75),d=h>c?2*h*(.5+i.y/(2*u)):c,p=Math.sin(d)*n/Math.sin(Se(Math.PI-o-d,.01,Math.PI-.01)),f=Math.min(l,p),m=1.01*(Math.cos(Math.PI/2-t)*f+n);return{nearZ:this._cameraState.height/50,farZ:m}}_calcMatrices(e=this._cameraState.nearFarZOverride){let t,i=mb(this._cameraState),r=this.worldCoordinateHelper,a=dd(_b(this._cameraState),this._cameraState.center,r),n=a.x,o=a.y,s=qe(Math.min(yb(this._cameraState),hd)),l=Math.max(this._cameraState.cameraToCenterDistance/2,this._cameraState.cameraToCenterDistance+this._cameraState.elevation*this._cameraState.pixelsPerMeter/Math.cos(s)),{nearZ:u,farZ:h}=e??this._calculateNearFarZ(l,s,i);this._nearZ=u,this._farZ=h,t=/* @__PURE__ */new Float64Array(16),P(t,this._cameraState.fovInRadians,this._cameraState.width/this._cameraState.height,this._nearZ,this._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,t),t[8]=2*-i.x/this._cameraState.width,t[9]=2*i.y/this._cameraState.height,this._projectionMatrix=v(t),S(t,t,[1,-1,1]),T(t,t,[0,0,-this._cameraState.cameraToCenterDistance]),C(t,t,-this._cameraState.rollInRadians),D(t,t,this._cameraState.pitchInRadians),C(t,t,-this._cameraState.bearingInRadians),T(t,t,[-n,-o,0]),this._mercatorMatrix=S([],t,[_b(this._cameraState),_b(this._cameraState),_b(this._cameraState)]),S(t,t,[1,1,this._cameraState.pixelsPerMeter]),this._pixelMatrix=w(/* @__PURE__ */new Float64Array(16),this._cameraState.clipSpaceToPixelsMatrix,t),T(t,t,[0,0,-this._cameraState.elevation]),this._viewProjMatrix=t,this._invViewProjMatrix=b([],t);let c=[0,0,-1,1];H(c,c,this._invViewProjMatrix),this._cameraPosition=[c[0]/c[3],c[1]/c[3],c[2]/c[3]],this._fogMatrix=/* @__PURE__ */new Float64Array(16),P(this._fogMatrix,this._cameraState.fovInRadians,this._cameraState.width/this._cameraState.height,l,this._farZ),this._fogMatrix[8]=2*-i.x/this._cameraState.width,this._fogMatrix[9]=2*i.y/this._cameraState.height,S(this._fogMatrix,this._fogMatrix,[1,-1,1]),T(this._fogMatrix,this._fogMatrix,[0,0,-this._cameraState.cameraToCenterDistance]),C(this._fogMatrix,this._fogMatrix,-this._cameraState.rollInRadians),D(this._fogMatrix,this._fogMatrix,this._cameraState.pitchInRadians),C(this._fogMatrix,this._fogMatrix,-this._cameraState.bearingInRadians),T(this._fogMatrix,this._fogMatrix,[-n,-o,0]),S(this._fogMatrix,this._fogMatrix,[1,1,this._cameraState.pixelsPerMeter]),T(this._fogMatrix,this._fogMatrix,[0,0,-this._cameraState.elevation]),this._pixelMatrix3D=w(/* @__PURE__ */new Float64Array(16),this._cameraState.clipSpaceToPixelsMatrix,t);let d=this._cameraState.width%2/2,p=this._cameraState.height%2/2,f=Math.cos(this._cameraState.bearingInRadians),m=Math.sin(-this._cameraState.bearingInRadians),_=n-Math.round(n)+f*d+m*p,g=o-Math.round(o)+f*p+m*d,y=new Float64Array(t);if(T(y,y,[_>.5?_-1:_,g>.5?g-1:g,0]),this._alignedProjMatrix=y,t=b(/* @__PURE__ */new Float64Array(16),this._pixelMatrix),!t)throw Error("failed to invert matrix");this._pixelMatrixInverse=t,this._clearMatrixCaches()}_clearMatrixCaches(){this._posMatrixCache.clear(),this._alignedPosMatrixCache.clear(),this._fogMatrixCacheF32.clear()}maxPitchScaleFactor(){if(!this._pixelMatrixInverse)return 1;let e=this.screenPointToMercatorCoordinate(new d(0,0)),t=[e.x*_b(this._cameraState),e.y*_b(this._cameraState),0,1];return H(t,t,this._pixelMatrix)[3]/this._cameraState.cameraToCenterDistance}getCameraPoint(){return this._helper.getCameraPoint()}getCameraAltitude(){return Math.cos(this._cameraState.pitchInRadians)*this._cameraState.cameraToCenterDistance/this._cameraState.pixelsPerMeter+this._cameraState.elevation}getCameraLngLat(){let e=this.worldCoordinateHelper,t=this._cameraState.center,i=e.worldZFromAltitude(1,t),r=i*_b(this._cameraState),a=this._cameraState.cameraToCenterDistance/r,n=_d(e.worldFromLngLat(t.lng,t.lat,this._cameraState.elevation),yb(this._cameraState),gb(this._cameraState),a*i);return e.lngLatFromWorld(n.x,n.y)}getProjectionData(e){let t,{overscaledTileID:i,aligned:r,applyTerrainMatrix:a}=e,n=this._helper.getMercatorTileCoordinates(i),o=i?this.calculatePosMatrix(i,r,!0):null;return t=i?.terrainRttPosMatrix32f&&a?i.terrainRttPosMatrix32f:o||he(),{mainMatrix:t,tileMercatorCoords:n,clippingPlane:[0,0,0,0],projectionTransition:0,fallbackMatrix:t,clipAntimeridian:!1}}isLocationOccluded(e,t,i){if(!t?.getCoverageIndex())return!1;let r=this.worldCoordinateHelper.worldFromLngLat(e.lng,e.lat);i??=t.getElevationForLngLat(e,this._cameraState.tileZoom);let a=this._coordinateClipPoint(r,i,this._pixelMatrix3D),n=a[3];if(n<=0||a[2]>n)return!0;let o=new d(a[0]/n,a[1]/n),s=this.screenTerrainPointToMercatorCoordinate(o,t);if(null==s)return!1;let l=this.getRaySegmentFromPixel(o,-1),u=kb(l,r.x*_b(this._cameraState),r.y*_b(this._cameraState),i);return kb(l,s.x*_b(this._cameraState),s.y*_b(this._cameraState),s.z)<.99*u}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);null==r?(a=[e,t,0,1],Ax(a,a,n)):(a=[e,t,r,1],H(a,a,n));let o=a[3];return{point:new d(a[0]/o,a[1]/o),signedDistanceFromCamera:o,isOccluded:!1}}populateCache(e){for(let t of e)this.calculatePosMatrix(t)}getProjectionDataForCustomLayer(e=!0){let t=new y_(0,0,0,0,0),i=this.getProjectionData({overscaledTileID:t,applyGlobeMatrix:e}),r=md(t,_b(this._cameraState));w(r,this._viewProjMatrix,r);let a=[re,re,_b(this._cameraState)/this._cameraState.pixelsPerMeter],n=le();return S(n,r,a),{...i,tileMercatorCoords:[0,0,1,1],fallbackMatrix:n,mainMatrix:n}}getFastPathSimpleProjectionMatrix(e){return this.calculatePosMatrix(e)}};function Mb(e){return new Ib(e)}function Fb(e,t){return Cb(e.index,e.exaggeration,(e.near[0]+t*e.dx)/e.worldSize,(e.near[1]+t*e.dy)/e.worldSize,e.wraps)}function zb(e,t){return Pb(Fb(e,t),e.near[2]+t*e.dz)}function kb({near:e,far:t},i,r,a){let n=t[0]-e[0],o=t[1]-e[1],s=t[2]-e[2];return((i-e[0])*n+(r-e[1])*o+(a-e[2])*s)/(n*n+o*o+s*s)}function Rb(){Oe("Map cannot fit within canvas with the given bounds, padding, and/or offset.")}function Lb(e){if(e.useSlerp)if(e.k<1){let t=Ye(e.startEulerAngles.roll,e.startEulerAngles.pitch,e.startEulerAngles.bearing),i=Ye(e.endEulerAngles.roll,e.endEulerAngles.pitch,e.endEulerAngles.bearing),r=/* @__PURE__ */new Float64Array(4);!function(e,t,i,r){var a,n,o,s,l=t[0],u=t[1],h=t[2],c=t[3],d=i[0],p=i[1],f=i[2],m=i[3],_=l*d+u*p+h*f+c*m;_<0&&(_=-_,d=-d,p=-p,f=-f,m=-m),1-_>1e-6?(a=Math.acos(_),n=Math.sin(a),o=Math.sin((1-r)*a)/n,s=Math.sin(r*a)/n):(o=1-r,s=r),e[0]=o*l+s*d,e[1]=o*u+s*p,e[2]=o*h+s*f,e[3]=o*c+s*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],o=i+i,s=r+r,l=a+a,u=i*o,h=r*o,c=r*s,d=a*o,p=a*s,f=a*l,m=n*o,_=n*s,g=n*l;e[0]=1-c-f,e[3]=h-g,e[6]=d+_,e[1]=h+g,e[4]=1-u-f,e[7]=p-m,e[2]=d-_,e[5]=p+m,e[8]=1-u-c}(t,e);let i,r,a=We(-Math.asin(Se(t[2],-1,1)));return Math.hypot(t[5],t[8])<.001?(i=0,r=-We(Math.atan2(t[3],t[4]))):(i=We(0===t[5]&&0===t[8]?0:Math.atan2(t[5],t[8])),r=We(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(gr.number(e.startEulerAngles.roll,e.endEulerAngles.roll,e.k)),e.tr.setPitch(gr.number(e.startEulerAngles.pitch,e.endEulerAngles.pitch,e.k)),e.tr.setBearing(gr.number(e.startEulerAngles.bearing,e.endEulerAngles.bearing,e.k))}function Bb(e,t,i,r,a,n){let o=n.worldCoordinateHelper,s=dd(n.worldSize,r.getNorthWest(),o),l=dd(n.worldSize,r.getNorthEast(),o),u=dd(n.worldSize,r.getSouthEast(),o),h=dd(n.worldSize,r.getSouthWest(),o),[c,p]=o.wraps?[Se(r.getSouth(),-85.051129,Ke),Se(r.getNorth(),-85.051129,Ke)]:[r.getSouth(),r.getNorth()],{points:f,bulge:m}=yd(o,r.getWest(),c,r.getEast(),p),_=qe(-a),g=1/0,y=1/0,v=-1/0,x=-1/0;for(let d of f){let{x:e,y:t}=d.mult(n.worldSize).rotate(_);e<g&&(g=e),t<y&&(y=t),e>v&&(v=e),t>x&&(x=t)}let b=m*n.worldSize,w=new d(v+b,x+b),T=new d(g-b,y-b),S=w.sub(T),D=n.width-(i.left+i.right+t.left+t.right),E=n.height-(i.top+i.bottom+t.top+t.bottom),C=D/S.x,P=E/S.y;if(P<0||C<0||!Number.isFinite(S.x)||!Number.isFinite(S.y))return void Rb();let A=Math.min(Me(n.scale*Math.min(C,P)),e.maxZoom),I=d.convert(e.offset),M=new d((t.left-t.right)/2,(t.top-t.bottom)/2).rotate(qe(a)),F=I.add(M).mult(n.scale/Ie(A)),z=0===m&&s.add(u).equals(l.add(h))?s.add(u).div(2):w.add(T).div(2).rotate(-_);return{center:pd(n.worldSize,z.sub(F),o),zoom:A,bearing:a}}var Ob,jb=class{get useGlobeControls(){return!1}handlePanInertia(e,t){let i=e.mag(),r=Math.abs(fd(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,n){return Bb(e,t,i,r,a,n)}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(Kc.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},o=void 0!==t.zoom,s=!e.isPaddingEqual(t.padding),l=!1,u=o?+t.zoom:e.zoom,h=e.centerPoint.add(t.offsetAsPoint),c=e.screenPointToLocation(h),{center:d,zoom:p}=e.applyConstrain(Kc.convert(t.center||c),u??i);bb(e,d);let f=e.worldCoordinateHelper,m=dd(e.worldSize,c,f),_=dd(e.worldSize,d,f).sub(m),g=Ie(p-i);l=p!==i;let y=this._transformAtAnimationEnd(e,p,n,t.padding);return t.around?y.setLocationAtPoint(t.around,t.aroundPoint):y.setLocationAtPoint(d,y.centerPoint.add(t.offsetAsPoint)),{easeFunc:o=>{if(l&&e.setZoom(gr.number(i,p,o)),He(a,n)||Lb({startEulerAngles:a,endEulerAngles:n,tr:e,k:o,useSlerp:a.roll!=n.roll}),s&&(e.interpolatePadding(r,t.padding,o),h=e.centerPoint.add(t.offsetAsPoint)),t.around)e.setLocationAtPoint(t.around,t.aroundPoint);else{let t=Ie(e.zoom-i),r=(p>i?Math.min(2,g):Math.max(.5,g))**(1-o),a=m.add(_.mult(o*r)).mult(t),n=pd(e.worldSize,a,f);e.setLocationAtPoint(e.renderWorldCopies&&f.wraps?n.wrap():n,h)}},isZooming:l,elevationCenter:y.center}}handleFlyTo(e,t){let i=void 0!==t.zoom,r=e.zoom,a=e.applyConstrain(Kc.convert(t.center||t.locationAtOffset),i?+t.zoom:r),n=a.center,o=a.zoom;bb(e,n);let s=e.worldCoordinateHelper,l=e.worldSize,u=dd(l,t.locationAtOffset,s),h=dd(l,n,s).sub(u),c=h.mag(),d=Ie(o-r),p=void 0===t.minZoom?e.minZoom:+t.minZoom,f=Math.max(p,e.minZoom),m=Math.min(f,r,o),_=Ie(e.applyConstrain(n,m).zoom-r),g=this._transformAtAnimationEnd(e,o,{roll:t.roll,pitch:t.pitch,bearing:t.bearing},t.padding);return g.setLocationAtPoint(n,g.centerPoint.add(t.offsetAsPoint)),{easeFunc:(t,i,a,c)=>{e.setZoom(1===t?o:r+Me(i));let d=1===t?n:pd(l,u.add(h.mult(a)),s);e.setLocationAtPoint(e.renderWorldCopies&&s.wraps?d.wrap():d,c)},scaleOfZoom:d,targetCenter:g.center,scaleOfMinZoom:_,pixelPathLength:c}}_transformAtAnimationEnd(e,t,i,r){let a=e.clone();return a.setZoom(t),a.setRoll(i.roll),a.setPitch(i.pitch),a.setBearing(i.bearing),a.setPadding(r),a}},Vb=new Ec({fill:new Dc(128,2),line:new Dc(512,0),tile:new Dc(128,32),stencil:new Dc(128,1),circle:3}),Nb=class{constructor(){this._tileMeshCache={}}get name(){return"vertical-perspective"}get worldCoordinateHelper(){return ud}get transitionState(){return 1}get useSubdivision(){return!0}get shaderVariantName(){return"globe"}get shaderDefine(){return"#define GLOBE"}get shaderPreludeCode(){return lb.projectionGlobe}get vertexShaderPreludeCode(){return lb.projectionMercator.vertexSource}get subdivisionGranularity(){return Vb}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?Vb.stencil:Vb.tile).getGranularityForZoomLevel(t.z),o=0===t.y&&r,s=t.y===(1<<t.z)-1&&r;return this._getMesh(e,{granularity:n,generateBorders:i,extendToNorthPole:o,extendToSouthPole:s})}_getMesh(e,t){let i=this._getMeshKey(t);if(i in this._tileMeshCache)return this._tileMeshCache[i];let r=Z_(e,t);return this._tileMeshCache[i]=r,r}recalculate(e){}hasTransition(){return!1}},Ub=class extends Ot{constructor(e,t){super(),this._transitionable=new xs(Ob||=new zs({type:new Ps(Nt.projection.type,"type")}),"projection",t),this.setProjection(e),this._transitioning=this._transitionable.untransitioned(),this.recalculate(new gs(0)),this._mercatorProjection=new db,this._verticalPerspectiveProjection=new Nb}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 ar){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 worldCoordinateHelper(){return this.currentProjection.worldCoordinateHelper}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 $b(e){let t=qb(e.worldSize,e.center.lat);return 2*Math.PI*t}function Gb(e,t,i,r,a){let n=1/(1<<a),o=t/re*n+r*n,s=ye((e/re*n+i*n)*Math.PI*2+Math.PI,2*Math.PI),l=2*Math.atan(Math.exp(Math.PI-o*Math.PI*2))-.5*Math.PI,u=Math.cos(l),h=/* @__PURE__ */new Float64Array(3);return h[0]=Math.sin(s)*u,h[1]=Math.sin(l),h[2]=Math.cos(s)*u,h}function Zb(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 qb(e,t){return e/(2*Math.PI)/Kb(t)}function Wb(e){let t=H(oe(),[0,0,0,1],e.modelViewProjectionMatrix);return H(t,t,e.inverseProjectionMatrix),[t[0]/t[3],t[1]/t[3],t[2]/t[3]]}function Hb(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 Kc(De((r>0?n:-n)/Math.PI*180,-180,180),t)}return new Kc(0,t)}var Xb=.98*Math.PI;function Yb(e,t){let i=e.cameraPosition,r=F(i);if(r<=1)return e.screenPointToLocation(t);let a=se();j(a,i);let n=e.getRayDirectionFromPixel(t),o=-V(n,a),s=se();B(s,n,a,o);let l=F(s);if(l<1e-9)return e.screenPointToLocation(t);let u=Math.atan2(l,o),h=.9*Math.asin(1/r);if(u<h)return e.screenPointToLocation(t);let c=r*Math.sin(h),d=Math.asin(Se(c,-1,1))-h,p=r*Math.cos(h)/Math.sqrt(Math.max(1-c*c,1e-12))-1,f=Xb-d,m=u-h,_=d+p*m*f/(f+p*m),g=se();L(g,s,1/l);let y=se();return L(y,a,Math.cos(Se(_,0,Xb))),B(y,y,g,Math.sin(Se(_,0,Xb))),j(y,y),Hb(y)}function Kb(e){return Math.cos(Math.min(Math.abs(e),Ke)*Math.PI/180)}function Jb(e,t){let i=Kb(e);return Me(Kb(t)/i)}function Qb(e){let t=.5*e,i=Math.sin(t),r=Math.cos(t);return Math.log(i+r)-Math.log(r-i)}function ew(e,t,i,r){let a=Se(e.lat+i*r,-90,90),n=Se(e.lat,-85.051129,Ke),o=Se(e.lat+i,-85.051129,Ke);if(Math.abs(o-n)>1){let i=(Math.sign(o)===Math.sign(n)?Math.abs(n):-Math.abs(n))*Math.PI/180,s=Math.abs(o)*Math.PI/180,l=Qb(i+r*(s-i)),u=Qb(i),h=(l-u)/(Qb(s)-u);return new Kc(e.lng+t*h,a)}return new Kc(e.lng+t*r,a)}function tw(e,t,i=1){let r=V(e,t),a=i*i,n=se(),o=se();L(o,t,r),q(n,e,o);let s=a-V(n,n);if(s<0)return null;let l=V(e,e)-a,u=-r+(r<0?1:-1)*Math.sqrt(s),h=l/u,c=u,d=Math.max(h,c);return d<0?null:{tMin:Math.min(h,c),tMax:d}}function iw(e,t){let i=.01569612305760477*t,r=Se((e-i)/(9*i),0,1);return r*r*(3-2*r)}var rw=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 o=this._cachePrevious.get(a);if(o)return this._cache.set(a,o),o;let s=this._boundingVolumeFactory(e,t,i,r);return this._cache.set(a,s),this._hadAnyChanges=!0,s}},aw=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=Y([],r[0],r[1],r[2]),n=U([],[i[0],0,0],a),o=U([],[0,i[1],0],a),s=U([],[0,0,i[2]],a),l=[...t],u=[...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)+o[i]*(1==(e>>1&1)?1:-1)+s[i]*(1==(e>>2&1)?1:-1);l[i]=Math.min(l[i],r),u[i]=Math.max(u[i],r)}let h=[];for(let e=0;e<8;e++){let i=[...t];k(i,i,L([],n,1&~e?-1:1)),k(i,i,L([],o,1==(e>>1&1)?1:-1)),k(i,i,L([],s,1==(e>>2&1)?1:-1)),h.push(i)}return new e(h,[[...n,-V(n,h[0])],[...o,-V(o,h[0])],[...s,-V(s,h[0])],[-n[0],-n[1],-n[2],-V(n,h[7])],[-o[0],-o[1],-o[2],-V(o,h[7])],[-s[0],-s[1],-s[2],-V(s,h[7])]],l,u)}intersectsFrustum(e){let t=!0,i=this.points.length,r=this.planes.length,a=e.planes.length,n=e.points.length;for(let o=0;o<a;o++){let r=e.planes[o],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 o=0;o<r;o++){let t=this.planes[o],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 nw(e,t,i){let r=e-t;return r<0?-r:Math.max(0,r-i)}function ow(e,t,i,r,a){let n,o=e-i;return n=o<0?Math.min(-o,1+o-a):o>a?Math.min(Math.max(o-a,0),1-o):0,Math.max(n,nw(t,r,a))}var sw=class{constructor(){this._boundingVolumeCache=new rw(this._computeTileBoundingVolume)}getCenter(e){return new Kc(e.center.lng,Se(e.center.lat,-85.051129,Ke))}prepareNextFrame(){this._boundingVolumeCache.swapBuffers()}distanceToTile2d(e,t,i,r){let a=1<<i.z,n=1/a,o=i.x/a,s=i.y/a,l=2;return l=Math.min(l,ow(e,t,o,s,n)),l=Math.min(l,ow(e,t,o+.5,-s-n,n)),l=Math.min(l,ow(e,t,o+.5,2-s-n,n)),l}getWrap(e,t,i){let r=1<<t.z,a=1/r,n=t.x/r,o=nw(e.x,n,a),s=nw(e.x,n-1,a),l=nw(e.x,n+1,a),u=Math.min(o,s,l);return u===l?1:u===s?-1:0}allowVariableZoom(e,t){return Zv(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 y_(e.z,t,e.z,e.x,e.y),o=r.terrain.getMinMaxElevation(i);a=o.minElevation??a,n=Math.max(o.maxElevation??n,n)}if(a/=Yc,n/=Yc,a+=1,n+=1,e.z<=0)return aw.fromAabb([-n,-n,-n],[n,n,n]);if(1===e.z)return aw.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=[Gb(0,0,e.x,e.y,e.z),Gb(re,0,e.x,e.y,e.z),Gb(re,re,e.x,e.y,e.z),Gb(0,re,e.x,e.y,e.z)],i=[];for(let e of t)i.push(L([],e,n));if(n!==a)for(let e of t)i.push(L([],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],o=[-1,-1,-1];for(let e of i)for(let t=0;t<3;t++)r[t]=Math.min(r[t],e[t]),o[t]=Math.max(o[t],e[t]);let s=Gb(re/2,re/2,e.x,e.y,e.z),l=N([],[0,1,0],s);j(l,l);let u=N([],s,l);j(u,u);let h=N([],t[2],t[1]);j(h,h);let c=N([],t[0],t[3]);j(c,c),i.push(L([],s,n)),e.y>=(1<<e.z)/2&&i.push(L([],Gb(4096,0,e.x,e.y,e.z),n)),e.y<(1<<e.z)/2&&i.push(L([],Gb(4096,8192,e.x,e.y,e.z),n));let d=lw(s,i),p=lw(u,i),f=[-s[0],-s[1],-s[2],d.max],m=[s[0],s[1],s[2],-d.min],_=[-u[0],-u[1],-u[2],p.max],g=[u[0],u[1],u[2],-p.min],y=[...h,0],v=[...c,0],x=[];return 0===e.y?x.push(pe(v,y,f),pe(v,y,m)):x.push(pe(_,y,f),pe(_,y,m),pe(_,v,f),pe(_,v,m)),e.y===(1<<e.z)-1?x.push(pe(v,y,f),pe(v,y,m)):x.push(pe(g,y,f),pe(g,y,m),pe(g,v,f),pe(g,v,m)),new aw(x,[f,m,_,g,y,v],r,o)}}};function lw(e,t){let i=1/0,r=-1/0;for(let a of t){let t=V(e,a);i=Math.min(i,t),r=Math.max(r,t)}return{min:i,max:r}}var uw=class e{get pixelsToClipSpaceMatrix(){return this._helper.pixelsToClipSpaceMatrix}get clipSpaceToPixelsMatrix(){return this._helper.clipSpaceToPixelsMatrix}get pixelsToGLUnits(){return this._helper.pixelsToGLUnits}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 constrainOverride(){return this._helper.constrainOverride}get nearZ(){return this._nearZ}get farZ(){return this._farZ}get nearFarZOverride(){return this._helper.nearFarZOverride}get autoCalculateNearFarZ(){return this._helper.autoCalculateNearFarZ}setTransitionState(e){}constructor(e,t){this._cachedClippingPlane=oe(),this._projectionMatrix=ue(),this._globeViewProjMatrix32f=he(),this._globeViewProjMatrixF64=ue(),this._globeViewProjMatrixF64Inverted=ue(),this._globeProjMatrixInverted=ue(),this._cameraPosition=se(),this.defaultConstrain=(e,t)=>{let i=Se(+t,this._cameraState.minZoom+Jb(0,e.lat),this._cameraState.maxZoom),r=this._getMaxLatitude(i);return{center:new Kc(e.lng,Se(e.lat,-r,r)),zoom:i}},this.applyConstrain=(e,t)=>this._helper.applyConstrain(e,t),this._helper=t??new wb({calcMatrices:()=>this._calcMatrices(),defaultConstrain:(e,t)=>this.defaultConstrain(e,t)},e),this._coveringTilesDetailsProvider=new sw}get _cameraState(){return this._helper.cameraState}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=se();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._cameraState.pitchInRadians,i=this._cameraState.cameraToCenterDistance/e,r=Math.sin(t)*i,a=Math.cos(t)*i+1,n=1/Math.sqrt(r*r+a*a)*1,o=-r,s=a,l=Math.sqrt(o*o+s*s);o/=l,s/=l;let u=[0,o,s];Z(u,u,[0,0,0],-this._cameraState.bearingInRadians),$(u,u,[0,0,0],-1*this._cameraState.center.lat*Math.PI/180),G(u,u,[0,0,0],this._cameraState.center.lng*Math.PI/180);let h=1/F(u);return L(u,u,h),[...u,-n*h]}isLocationOccluded(e,t,i){let r=t?.getCoverageIndex();i??=r?t.getElevationForLngLat(e,this._cameraState.tileZoom):0;let a=pw(e,i);if(!this.isSurfacePointVisible(a))return!0;if(!r)return!1;let n=this._projectSurfacePointToScreen(a),o=this.cameraPosition,s=this.getRayDirectionFromPixel(n),l=fw(o,s,a);if(l<=0)return!0;let u=this.screenTerrainPointToMercatorCoordinate(n,t);return null!=u&&fw(o,s,pw(u.toLngLat(),u.z))<.99*l}transformLightDirection(e){let t=this._cameraState.center.lng*Math.PI/180,i=this._cameraState.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]],o=[0,0,0];N(o,n,a),j(n,n),j(o,o);let s=[0,0,0];return j(s,[n[0]*e[0]+o[0]*e[1]+a[0]*e[2],n[1]*e[0]+o[1]*e[1]+a[1]*e[2],n[2]*e[0]+o[2]*e[1]+a[2]*e[2]]),s}getPixelScale(){return 1/Kb(this._cameraState.center.lat)}getCircleRadiusCorrection(){return Kb(this._cameraState.center.lat)}getPitchedTextCorrection(e,t,i){let r=cd(e,t,i.canonical),a=function(e,t){return[ye(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,n=i.canonical,o=Gb(e,t,n.x,n.y,n.z),s=1+(r??0)/Yc,l=o[0]*s,u=o[1]*s,h=o[2]*s,c=[l,u,h,1];if(H(c,c,this._globeViewProjMatrixF64),s<=1){let e=this._cachedClippingPlane;a=e[0]*o[0]+e[1]*o[1]+e[2]*o[2]+e[3]<0}else a=this._isLineOfSightBlocked(l,u,h);return{point:new d(c[0]/c[3],c[1]/c[3]),signedDistanceFromCamera:c[3],isOccluded:a}}_isLineOfSightBlocked(e,t,i){let r=this._cameraPosition,a=e-r[0],n=t-r[1],o=i-r[2],s=a*a+n*n+o*o;if(0===s)return!1;let l=Se(-(r[0]*a+r[1]*n+r[2]*o)/s,0,1),u=r[0]+l*a,h=r[1]+l*n,c=r[2]+l*o;return u*u+h*h+c*c<1}_calcMatrices(e=this._cameraState.nearFarZOverride){let t=qb(_b(this._cameraState),this._cameraState.center.lat),i=le(),{nearZ:r,farZ:a}=e??{nearZ:.5,farZ:this._cameraState.cameraToCenterDistance+2*t};this._nearZ=r,this._farZ=a,P(i,this._cameraState.fovInRadians,this._cameraState.width/this._cameraState.height,this._nearZ,this._farZ);let n=mb(this._cameraState);i[8]=2*-n.x/this._cameraState.width,i[9]=2*n.y/this._cameraState.height,this._projectionMatrix=v(i),this._globeProjMatrixInverted=le(),b(this._globeProjMatrixInverted,i),T(i,i,[0,0,-this._cameraState.cameraToCenterDistance]),C(i,i,this._cameraState.rollInRadians),D(i,i,-this._cameraState.pitchInRadians),C(i,i,this._cameraState.bearingInRadians),T(i,i,[0,0,-t]);let o=se();o[0]=t,o[1]=t,o[2]=t,D(i,i,this._cameraState.center.lat*Math.PI/180),E(i,i,-this._cameraState.center.lng*Math.PI/180),S(i,i,o),this._globeViewProjMatrixF64=i,this._globeViewProjMatrix32f=new Float32Array(i),this._globeViewProjMatrixF64Inverted=le(),b(this._globeViewProjMatrixF64Inverted,i);let s=se();this._cameraPosition=se(),this._cameraPosition[2]=this._cameraState.cameraToCenterDistance/t,Z(this._cameraPosition,this._cameraPosition,s,-this._cameraState.rollInRadians),$(this._cameraPosition,this._cameraPosition,s,this._cameraState.pitchInRadians),Z(this._cameraPosition,this._cameraPosition,s,-this._cameraState.bearingInRadians),k(this._cameraPosition,this._cameraPosition,[0,0,1]),$(this._cameraPosition,this._cameraPosition,s,-this._cameraState.center.lat*Math.PI/180),G(this._cameraPosition,this._cameraPosition,s,this._cameraState.center.lng*Math.PI/180),this._cachedClippingPlane=this._computeClippingPlane(t);let l=v(this._globeViewProjMatrixF64Inverted);S(l,l,[1,1,-1]),this._cachedFrustum=Vv.fromInvProjectionMatrix(l,1,0,this._cachedClippingPlane,!0)}calculateFogMatrix(e){Oe("calculateFogMatrix is not supported on globe projection.");let t=le();return x(t),t}getVisibleUnwrappedCoordinates(e){return[new g_(0,e)]}getCameraFrustum(){return this._cachedFrustum}getClippingPlane(){return this._cachedClippingPlane}getCoveringTilesDetailsProvider(){return this._coveringTilesDetailsProvider}recalculateZoomAndCenter(e){e?Oe("terrain is not fully supported on vertical perspective projection."):this._helper.recalculateZoomAndCenter(0)}maxPitchScaleFactor(){return 1}getCameraPoint(){return this._helper.getCameraPoint()}getCameraAltitude(){return(F(this._cameraPosition)-1)*Yc}getCameraLngLat(){let e=se();return j(e,this._cameraPosition),Hb(e)}get worldCoordinateHelper(){return this._helper.worldCoordinateHelper}populateCache(e){}getBounds(){let e=.5*this._cameraState.width,t=.5*this._cameraState.height,i=[new d(0,0),new d(e,0),new d(this._cameraState.width,0),new d(this._cameraState.width,t),new d(this._cameraState.width,this._cameraState.height),new d(e,this._cameraState.height),new d(0,this._cameraState.height),new d(0,t)],r=[];for(let h of i)r.push(this.unprojectScreenPoint(h));let a=0,n=0,o=0,s=0,l=this._cameraState.center;for(let h of r){let e=_e(l.lng,h.lng),t=_e(l.lat,h.lat);e<n&&(n=e),e>a&&(a=e),t<s&&(s=t),t>o&&(o=t)}let u=[l.lng+n,l.lat+s,l.lng+a,l.lat+o];return this.isSurfacePointOnScreen([0,1,0])&&(u[3]=90,u[0]=-180,u[2]=180),this.isSurfacePointOnScreen([0,-1,0])&&(u[1]=-90,u[0]=-180,u[2]=180),new c_(u)}_getMaxLatitude(e){let t=qe(4.948870999999997),i=qb(this._cameraState.tileSize*Ie(e),Ke)*t,r=Math.min(this._cameraState.width,this._cameraState.height)/2,a=Math.min(i,r)*ve(i,r,4*r,1,0);return Ke+We(t*a/i)}calculateCenterFromCameraLngLatAlt(e,t,i,r){return this._helper.calculateCenterFromCameraLngLatAlt(e,t,i,r)}calculateCameraOptionsFromTo(e,t,i,r){let a=Kc.convert(i),n=Zb(Kc.convert(e));L(n,n,1+t/Yc);let o=Zb(a),s=L(se(),o,1+r/Yc),l=R(se(),n,o),u=F(l);if(u<1e-12||O(n,s)<1e-12)throw Error("Can't calculate camera options with same From and To");let h=se();G(l,l,h,-qe(a.lng)),$(l,l,h,qe(a.lat));let c=We(Math.acos(Se(l[2]/u,-1,1))),d=Math.hypot(l[0],l[1])<1e-9*u?gb(this._cameraState):We(Math.atan2(-l[0],-l[1]));return{center:a,elevation:r,zoom:Me(this._cameraState.cameraToCenterDistance/u/qb(this._cameraState.tileSize,a.lat)),pitch:c,bearing:d}}setLocationAtPoint(e,t,i){let r=this.getCameraForLocationAtPoint(e,t);r&&this._helper.setCenterAndZoom(r.center,r.zoom)}getCameraForLocationAtPoint(e,t){let i=Zb(this.unprojectScreenPoint(t)),r=Zb(e),a=se();!function(e){e[0]=0,e[1]=0,e[2]=0}(a);let n=se();G(n,i,a,-this._cameraState.center.lng*Math.PI/180),$(n,n,a,this._cameraState.center.lat*Math.PI/180);let o=r[0]*r[0]+r[2]*r[2],s=n[0]*n[0];if(o<s)return null;let l=Math.sqrt(o-s),u=-l,h=me(r[0],r[2],n[0],l),c=me(r[0],r[2],n[0],u),d=se();G(d,r,a,-h);let p=me(d[1],d[2],n[1],n[2]),f=se();G(f,r,a,-c);let m,_,g=me(f[1],f[2],n[1],n[2]),y=.5*Math.PI,v=p>=-y&&p<=y,x=g>=-y&&g<=y;if(v&&x){let e=this._cameraState.center.lng*Math.PI/180,t=this._cameraState.center.lat*Math.PI/180;ge(h,e)+ge(p,t)<ge(c,e)+ge(g,t)?(m=h,_=p):(m=c,_=g)}else if(v)m=h,_=p;else{if(!x)return null;m=c,_=g}let b=m/Math.PI*180,w=Se(_/Math.PI*180,-90,90),T=b!==this._cameraState.center.lng||w!==this._cameraState.center.lat,{center:S,zoom:D}=T?this._helper.getConstrainedCamera(new Kc(b,w),this._cameraState.zoom):{center:this._cameraState.center,zoom:this._cameraState.zoom},E=this.applyConstrain(S,D+Jb(this._cameraState.center.lat,S.lat)).zoom;return E===D?T?{center:S,zoom:D}:null:this._helper.getConstrainedCamera(S,E)}locationToScreenPoint(e,t){let i=Zb(e);return t&&L(i,i,1+t.getElevationForLngLat(e,this._cameraState.tileZoom)/Yc),this._projectSurfacePointToScreen(i)}_projectSurfacePointToScreen(e){let t=oe();return H(t,[...e,1],this._globeViewProjMatrixF64),t[0]/=t[3],t[1]/=t[3],new d((.5*t[0]+.5)*this._cameraState.width,(.5*-t[1]+.5)*this._cameraState.height)}screenPointToMercatorCoordinate(e,t){if(t){let i=this.screenTerrainPointToMercatorCoordinate(e,t);if(i)return i}return ld.fromLngLat(this.unprojectScreenPoint(e))}screenTerrainPointToMercatorCoordinate(e,t){let i=t.getCoverageIndex();if(!i)return null;let r=this.cameraPosition,a=this.getRayDirectionFromPixel(e),n=tw(r,a,1+i.maxElevation/Yc);if(!n)return null;let o=tw(r,a,1+i.minElevation/Yc),s=Math.max(n.tMin,0),l=o?o.tMin:n.tMax;if(l<=s)return null;let u={index:i,exaggeration:t.exaggeration,origin:r,direction:a},h=0;for(let c=0;c<=256;c++){let e=s+(l-s)*c/256;if(dw(u,e)){let{hi:t}=Ab(u,dw,h,e,1e-12),{sample:i,mercator:r}=cw(u,t);return new ld(r.x,r.y,i.elevation)}h=e}return null}screenPointToLocation(e,t){return this.screenPointToMercatorCoordinate(e,t)?.toLngLat()}screenPointToLocationAtElevation(e,t){return this.screenPointToLocation(e)}isPointOnMapSurface(e,t){return!!tw(this._cameraPosition,this.getRayDirectionFromPixel(e))}getRayDirectionFromPixel(e){let t=oe();t[0]=e.x/this._cameraState.width*2-1,t[1]=-1*(e.y/this._cameraState.height*2-1),t[2]=1,t[3]=1,H(t,t,this._globeViewProjMatrixF64Inverted),t[0]/=t[3],t[1]/=t[3],t[2]/=t[3];let i=se();i[0]=t[0]-this._cameraPosition[0],i[1]=t[1]-this._cameraPosition[1],i[2]=t[2]-this._cameraPosition[2];let r=se();return j(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=oe();return H(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}unprojectScreenPoint(e){let t=this._cameraPosition,i=this.getRayDirectionFromPixel(e),r=tw(t,i);if(r){let e=se();k(e,t,[i[0]*r.tMin,i[1]*r.tMin,i[2]*r.tMin]);let a=se();return j(a,e),Hb(a)}let a=this._cachedClippingPlane,n=a[0]*i[0]+a[1]*i[1]+a[2]*i[2],o=-de(a,t)/n,s=se();if(o>0)k(s,t,[i[0]*o,i[1]*o,i[2]*o]);else{let e=se();k(e,t,[2*i[0],2*i[1],2*i[2]]);let r=de(this._cachedClippingPlane,e);q(s,e,[this._cachedClippingPlane[0]*r,this._cachedClippingPlane[1]*r,this._cachedClippingPlane[2]*r])}let l=function(e){let t=se();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 Hb(function(e,t,i){let r=se();q(r,i,e);let a=se();return B(a,e,r,t/W(r)),a}(l.center,l.radius,s))}getProjectionDataForCustomLayer(e=!0){let t=this.getProjectionData({overscaledTileID:new y_(0,0,0,0,0),applyGlobeMatrix:e});return t.tileMercatorCoords=[0,0,1,1],t}getFastPathSimpleProjectionMatrix(e){}};function hw(e){return new uw(e)}function cw(e,t){let i=se();B(i,e.origin,e.direction,t);let r=F(i),a=se();L(a,i,1/r);let n=Hb(a),o=ld.fromLngLat(n),s=new ld(o.x,Se(o.y,0,.999999999)),l=Cb(e.index,e.exaggeration,s.x,s.y,!1),u=Math.abs(n.lat)>85.051129?0:l.elevation;return{sample:{...l,elevation:u},radius:r,mercator:s}}function dw(e,t){let{sample:i,radius:r}=cw(e,t);return Pb(i,(r-1)*Yc)}function pw(e,t){let i=Zb(e);return L(i,i,1+t/Yc)}function fw(e,t,i){return V(R(se(),i,e),t)}var mw=class e{get pixelsToClipSpaceMatrix(){return this._helper.pixelsToClipSpaceMatrix}get clipSpaceToPixelsMatrix(){return this._helper.clipSpaceToPixelsMatrix}get pixelsToGLUnits(){return this._helper.pixelsToGLUnits}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.currentTransform.nearZ}get farZ(){return this.currentTransform.farZ}get nearFarZOverride(){return this._helper.nearFarZOverride}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 wb({calcMatrices:()=>this._calcMatrices(),defaultConstrain:(e,t)=>this.defaultConstrain(e,t)},e),this._globeness=1,this._mercatorTransform=new Ib(void 0,this._helper),this._verticalPerspectiveTransform=new uw(void 0,this._helper)}get _cameraState(){return this._helper.cameraState}clone(){let t=new e;return t._globeness=this._globeness,t.apply(this,!1),t}apply(e,t){this._helper.apply(e,t)}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,t,i){return this.currentTransform.isLocationOccluded(e,t,i)}transformLightDirection(e){return this.currentTransform.transformLightDirection(e)}getPixelScale(){return xe(this._mercatorTransform.getPixelScale(),this._verticalPerspectiveTransform.getPixelScale(),this._globeness)}getCircleRadiusCorrection(){return this.currentTransform.getCircleRadiusCorrection()}getPitchedTextCorrection(e,t,i){return xe(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(){if(!this._cameraState.width||!this._cameraState.height)return;let e=this._verticalPerspectiveTransform;e._calcMatrices();let t=this.isGlobeRendering?{nearZ:e.nearZ,farZ:e.farZ}:this._cameraState.nearFarZOverride;this._mercatorTransform._calcMatrices(t)}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.currentTransform.getCameraAltitude()}getCameraLngLat(){return this.currentTransform.getCameraLngLat()}get worldCoordinateHelper(){return this._helper.worldCoordinateHelper}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)}calculateCameraOptionsFromTo(e,t,i,r){return this.currentTransform.calculateCameraOptionsFromTo(e,t,i,r)}setLocationAtPoint(e,t,i){this.currentTransform.setLocationAtPoint(e,t,i)}locationToScreenPoint(e,t){return this.currentTransform.locationToScreenPoint(e,t)}screenPointToMercatorCoordinate(e,t){return this.currentTransform.screenPointToMercatorCoordinate(e,t)}screenTerrainPointToMercatorCoordinate(e,t){return this.currentTransform.screenTerrainPointToMercatorCoordinate(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)}};function _w(e){return new mw(e)}var gw=class e{get useGlobeControls(){return!0}handlePanInertia(e,t){let i=function(e,t){let i=e.rotate(t.bearingInRadians),r=t.zoom+Jb(t.center.lat,0),a=xe(1/Kb(t.center.lat),1/Kb(Math.min(Math.abs(t.center.lat),60)),ve(r,7,3,0,1)),n=function(e,t){return 360/$b({worldSize:e,center:{lat:t}})}(t.worldSize,t.center.lat);return new Kc(t.center.lng-i.x*n*a,Se(t.center.lat+i.y*n,-90,90))}(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 d(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 o=_e(t.center.lng,r.lng),s=o/(Math.abs(o/180)+1),l=_e(t.center.lat,r.lat),u=t.getRayDirectionFromPixel(i),h=t.cameraPosition,c=-1*V(h,u),d=se();k(d,h,[u[0]*c,u[1]*c,u[2]*c]);let p=F(d),f=p-1,m=Math.exp(.5*-Math.max(f-.3,0)),_=ve(p,.95,.999,0,1),g=ve(qb(t.worldSize,t.center.lat)/Math.min(t.width,t.height),.9,.5,1,.25),y=Math.min(m,xe(1,g,_)),v=(1-Ie(-n))*y,x=t.center.lat,b=t.zoom,w=new Kc(t.center.lng+s*v,Se(t.center.lat+l*v,-90,90));t.setLocationAtPoint(r,i);let T=t.center,S=ve(Math.abs(o),45,85,0,1),D=Math.max(S,_)**.25,E=_e(T.lng,w.lng),C=_e(T.lat,w.lat);t.setCenter(new Kc(T.lng+E*D,Se(T.lat+C*D,-90,90)).wrap()),t.setZoom(b+Jb(x,t.center.lat))}handleMapControlsPan(e,t,i){e.panDelta&&function(e,t,i,r,a=!0){let n=Yb(e,i),o=t;if(r)o=Yb(e,i.sub(r));else if(!e.isPointOnMapSurface(i))return;let s=Zb(n),l=Zb(o),u=function(e,t){return Y(oe(),-e.lng,-e.lat,t)}(e.center,e.bearing),h=N(se(),l,s),c=Math.sqrt(V(h,h)),d=Math.acos(Se(V(l,s),-1,1))/2,p=Math.sin(d),f=c?function(e,t,i,r,a){return e[0]=t,e[1]=i,e[2]=r,e[3]=a,e}(oe(),h[1]/c*p,-h[0]/c*p,h[2]/c*p,Math.cos(d)):function(e){return e[0]=0,e[1]=0,e[2]=0,e[3]=1,e}(oe()),{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(Se(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],o=t[3],s=i[0],l=i[1],u=i[2],h=i[3];return e[0]=r*h+o*s+a*u-n*l,e[1]=a*h+o*l+n*s-r*u,e[2]=n*h+o*u+r*l-a*s,e[3]=o*h-r*s-a*l-n*u,e}(oe(),u,f)),y=e.center.lat,v=e.zoom,x=a?function(e,t,i){return Math.abs(_e(e.bearing,i))<=90?t:t>0?90:-90}(e,_,g):_,b=a?function(e,t,i,r){let a=e.center.lng,n=e.center.lat,o=n>=0?90:-90,s=e.locationToScreenPoint(new Kc(0,o)),l=t.x-s.x,u=t.y-s.y,h=l*l+u*u,c=Se(1-(Ke-Math.abs(n))/12,0,1),d=c*c*(3-2*c),p=ye(r-a+180,360)-180,f=0;return d>0&&i&&(f=(o>0?1:-1)*((l*i.y-u*i.x)/Math.max(h,400))*180/Math.PI),a+(1-d)*p+d*f}(e,i,r,m):m;e.setCenter(new Kc(De(b,-180,180),x)),a||e.setBearing(g),e.setZoom(v+Jb(y,e.center.lat))}(t,i,t.isPointOnMapSurface(e.around)?e.around:t.centerPoint,e.panDelta)}cameraForBoxAndBearing(t,i,r,a,n,o){let s=Bb(t,i,r,a,n,o);if(!s)return;let l=i.left/o.width*2-1,u=(o.width-i.right)/o.width*2-1,h=i.top/o.height*-2+1,c=(o.height-i.bottom)/o.height*-2+1,d=_e(a.getWest(),a.getEast())<0,p=d?a.getEast():a.getWest(),f=d?a.getWest():a.getEast(),m=Math.max(a.getNorth(),a.getSouth()),_=Math.min(a.getNorth(),a.getSouth()),g=p+.5*_e(p,f),y=m+.5*_e(m,_),v=o.clone();v.setCenter(s.center),v.setPadding(r),v.setBearing(s.bearing),v.setPitch(0),v.setRoll(0),v.setZoom(s.zoom);let x=v.modelViewProjectionMatrix,b=[Zb(a.getNorthWest()),Zb(a.getNorthEast()),Zb(a.getSouthWest()),Zb(a.getSouthEast()),Zb(new Kc(f,y)),Zb(new Kc(p,y)),Zb(new Kc(g,m)),Zb(new Kc(g,_))],w=Zb(s.center),T=1/0;for(let S of b)l<0&&(T=e.getLesserNonNegativeNonNull(T,e.solveVectorScale(S,w,x,"x",l))),u>0&&(T=e.getLesserNonNegativeNonNull(T,e.solveVectorScale(S,w,x,"x",u))),h>0&&(T=e.getLesserNonNegativeNonNull(T,e.solveVectorScale(S,w,x,"y",h))),c<0&&(T=e.getLesserNonNegativeNonNull(T,e.solveVectorScale(S,w,x,"y",c)));if(Number.isFinite(T)&&0!==T)return s.zoom=Math.min(v.zoom+Me(T),t.maxZoom),s;Rb()}handleJumpToCenterZoom(e,t){let i=e.center.lat,r=t.center?Kc.convert(t.center):e.center;e.setCenter(e.applyConstrain(r,e.zoom).center.wrap());let a=void 0===t.zoom?e.zoom+Jb(i,e.center.lat):+t.zoom;e.zoom!==a&&(e.setZoom(a),e.setCenter(e.applyConstrain(r,e.zoom).center.wrap()))}handleEaseTo(e,t){let i=e.zoom,r=e.center,a=e.padding,n={roll:e.roll,pitch:e.pitch,bearing:e.bearing},o={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,l=!e.isPaddingEqual(t.padding),u=!1,h=t.center?Kc.convert(t.center):r,c=e.applyConstrain(h,s?+t.zoom:i).center;bb(e,c);let p=e.clone();p.setCenter(c),p.setZoom(s?+t.zoom:i+Jb(r.lat,h.lat)),p.setBearing(t.bearing);let f=new d(Se(e.centerPoint.x+t.offsetAsPoint.x,0,e.width),Se(e.centerPoint.y+t.offsetAsPoint.y,0,e.height));p.setLocationAtPoint(c,f);let m=(t.offset&&t.offsetAsPoint.mag())>0?p.center:c,_=s?+t.zoom:i+Jb(r.lat,m.lat),g=i+Jb(r.lat,0),y=_+Jb(m.lat,0),v=_e(r.lng,m.lng),x=_e(r.lat,m.lat),b=Ie(y-g);return u=_!==i,{easeFunc:i=>{if(He(n,o)||Lb({startEulerAngles:n,endEulerAngles:o,tr:e,k:i,useSlerp:n.roll!=o.roll}),l&&e.interpolatePadding(a,t.padding,i),t.around)Oe("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=ew(r,v,x,t);e.setCenter(a.wrap())}if(u){let t=gr.number(g,y,i)+Jb(0,e.center.lat);e.setZoom(t)}1===i&&!t.around&&e.setCenter(m.wrap())},isZooming:u,elevationCenter:m}}handleFlyTo(e,t){let i=void 0!==t.zoom,r=e.center,a=e.zoom,n=e.padding,o=!e.isPaddingEqual(t.padding),s=e.applyConstrain(Kc.convert(t.center||t.locationAtOffset),i?+t.zoom:a).center,l=i?+t.zoom:e.zoom+Jb(e.center.lat,s.lat),u=e.clone();u.setCenter(s),u.setZoom(l),u.setBearing(t.bearing);let h=new d(Se(e.centerPoint.x+t.offsetAsPoint.x,0,e.width),Se(e.centerPoint.y+t.offsetAsPoint.y,0,e.height));u.setLocationAtPoint(s,h);let c=u.center;bb(e,c);let p=function(e,t,i){let r=Se(V(Zb(t),Zb(i)),-1,1),a=Math.acos(r),n=$b(e);return a/(2*Math.PI)*n}(e,r,c),f=a+Jb(r.lat,0),m=l+Jb(c.lat,0),_=Ie(m-f),g="number"==typeof t.minZoom?+t.minZoom:e.minZoom,y=Math.max(g,e.minZoom)+Jb(c.lat,0),v=Math.min(y,f,m)+Jb(0,c.lat),x=Ie(e.applyConstrain(c,v).zoom+Jb(c.lat,0)-f),b=_e(r.lng,c.lng),w=_e(r.lat,c.lat);return{easeFunc:(i,a,s,u)=>{let h=ew(r,b,w,s);o&&e.interpolatePadding(n,t.padding,i);let d=1===i?c:h;e.setCenter(d.wrap());let p=f+Me(a);e.setZoom(1===i?l:p+Jb(0,d.lat)),1===i&&e.setCenter(c.wrap())},scaleOfZoom:_,targetCenter:c,scaleOfMinZoom:x,pixelPathLength:p}}static solveVectorScale(e,t,i,r,a){let n=a,o="x"===r?[i[0],i[4],i[8],i[12]]:[i[1],i[5],i[9],i[13]],s=[i[3],i[7],i[11],i[15]],l=e[0]*o[0]+e[1]*o[1]+e[2]*o[2],u=e[0]*s[0]+e[1]*s[1]+e[2]*s[2],h=t[0]*o[0]+t[1]*o[1]+t[2]*o[2],c=t[0]*s[0]+t[1]*s[1]+t[2]*s[2];return h+n*u===l+n*c||s[3]*(l-h)+o[3]*(c-u)+l*c===h*u?null:(h+o[3]-n*c-n*s[3])/(h-l-n*c+n*u)}static getLesserNonNegativeNonNull(e,t){return null!==t&&t>=0&&t<e?t:e}},yw=class{constructor(e){this._globe=e,this._mercatorCameraHelper=new jb,this._verticalPerspectiveCameraHelper=new gw}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,n){return this.currentHelper.cameraForBoxAndBearing(e,t,i,r,a,n)}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)}};function vw(e,t,i){let r={constrainOverride:t};if(Array.isArray(e)){let t=function(e){return e.flat(1/0).find(e=>"string"==typeof e&&void 0!==k_(e))}(e);t&&Oe(`Projection expressions cannot use the registered projection "${t}", which only works as a plain name. Falling back to the globe projection.`);let a=new Ub({type:e},i);return{projection:a,transform:_w(r),cameraHelper:new yw(a)}}let a=k_(e);if(a){let e=new I_(a);return{projection:new db(e),transform:Mb({...r,worldCoordinateHelper:e}),cameraHelper:new jb}}switch(e){case"mercator":return{projection:new db,transform:Mb(r),cameraHelper:new jb};case"globe":{let e=new Ub({type:["interpolate",["linear"],["zoom"],11,"vertical-perspective",12,"mercator"]},{});return{projection:e,transform:_w(r),cameraHelper:new yw(e)}}case"vertical-perspective":return{projection:new Nb,transform:hw(r),cameraHelper:new gw};default:return Oe(`Unknown projection name: ${e}. Falling back to mercator projection.`),{projection:new db,transform:Mb(r),cameraHelper:new jb}}}var xw=function(){let e={},t=Nt.$version;for(let i in Nt.$root){let r=Nt.$root[i];if(r.required){let a=null;a="version"===i?t:"array"===r.type?[]:{},null!=a&&(e[i]=a)}}return e}(),bw=class extends Ot{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 n_(Go(),e._getMapId()).setEventedParent(this),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 Rm,this.imageManager.setEventedParent(this),this.imageManager.setMissingImageResolver(e._missingStyleImageResolver),this.patternAtlas=new Lm(this.imageManager);let i=e._container?.lang||typeof document<"u"&&document.documentElement?.lang||void 0;this.glyphManager=new e_(e._requestManager,t.localIdeographFontFamily,i),this.lineAtlas=new a_(256,512),this.crossTileSymbolIndex=new ob,this._setInitialValues(),this._initialGlobalState=t.globalState??{},this._resetUpdates(),this.dispatcher.broadcast("SR",At()),kv().on(Mv,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 _s,this._imagesListDirty=!1,this._initialGlobalState={},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._symbolPlacementTriggered=!1,this._placedProjectionTransition=void 0,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;return this._setGlobalStateValues({[e]:i}),this}getGlobalState(){return this._globalState}setGlobalState(e){this._checkLoaded();let t={},i=/* @__PURE__ */new Set([...Object.keys(e??{}),...Object.keys(this._initialGlobalState)]);for(let r of i)t[r]=this._initialGlobalState[r]??e[r]?.default??null;this._setGlobalStateValues(t)}_setGlobalStateValues(e){let t=[];for(let r in e)Re(e[r],this._globalState[r])||t.push(r);if(0===t.length)return;let i={...this._globalState};for(let r of t)this._globalState[r]=e[r];this._applyGlobalStateChanges(t,i)}_applyGlobalStateChanges(e,t){let i=/* @__PURE__ */new Set,r={};for(let n of e)r[n]=this._globalState[n];for(let n in this._layers){let r=this._layers[n];r.retainPriorGlobalState(e,t);let a=r.getLayoutAffectingGlobalStateRefs(),o=r.getPaintAffectingGlobalStateRefs(),s=r.getVisibilityAffectingGlobalStateRefs();for(let t of e){if(a.has(t)&&i.add(r.source),o.has(t))for(let{name:e,value:i}of o.get(t))this._updatePaintProperty(r,e,i,{validate:!1});s?.has(t)&&(r.recalculateVisibility(),this._updateLayer(r))}}let a={now:dt(),transition:this.getTransition()};this.light?.applyGlobalStateChange(e,t,a),this.sky?.applyGlobalStateChange(e,t,a),this.dispatcher.broadcast("UGS",r);for(let n in this.tileManagers)i.has(n)&&(this._reloadSource(n),this._changed=!0)}async loadURL(e,t={},i){this.fire(new ts("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");ut(r.signal);let n=await Mt(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 Bt(ne(e)))}}loadJSON(e,t={},i){this.fire(new ts("dataloading")),this._frameRequest=new AbortController,ht.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 ts("dataloading")),this._load(xw,{validate:!1})}_load(e,t,i){let r=t.transformStyle?t.transformStyle(i,e):e;if(t.validate&&ps(this,r))return;r={...r},this._loaded=!0,this.stylesheet=r,this.setGlobalState(this.stylesheet.state??null);let a=vw(this.stylesheet.projection?.type||"mercator",this.map._camera?.transform.constrainOverride,this._globalState);this.projection=a.projection;for(let n in r.sources)this.addSource(n,r.sources[n],{validate:!1});r.sprite?this._loadSprite(r.sprite):this.imageManager.setLoaded(!0),this.glyphManager.setURL(r.glyphs),this.glyphManager.setFontFaces(r["font-faces"]),this._createLayers(),this.light=new t_(this.stylesheet.light??{},this._globalState),this._applyProjection(a),this.sky=new i_(this.stylesheet.sky,this._globalState),this.sky.setEventedParent(this),this.map.setTerrain(this.stylesheet.terrain??null,{validate:!1}),this.fire(new ts("data")),this.fire(new es)}_createLayers(){let e=Gt(this.stylesheet.layers);this.dispatcher.broadcast("SL",e),this._order=e.map(e=>e.id),this._layers={},this._serializedLayers=null;for(let t of e){let e=Fm(t,this._globalState);if(e.setEventedParent(this,{layer:{id:t.id}}),this._layers[t.id]=e,js(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=zm(e),n=i>1?"@2x":"",o={},s={};for(let{id:l,url:u}of a){let e=await t.transformRequest(km(u,n,".json"),"SpriteJSON");o[l]=Mt(e,r);let i=await t.transformRequest(km(u,n,".png"),"SpriteImage");s[l]=Ho.getImage(i,r)}return await Promise.all([...Object.values(o),...Object.values(s)]),async function(e,t){let i={};for(let r in e){i[r]={};let a=(await t[r]).data;if(!a)throw Error(`Could not load sprite image for ${r}: the response is empty`);let n=ht.getImageCanvasContext(a),o=(await e[r]).data;for(let e in o){let{width:t,height:a,x:s,y:l,sdf:u,pixelRatio:h,stretchX:c,stretchY:d,content:p,textFitWidth:f,textFitHeight:m}=o[e],_={width:t,height:a,x:s,y:l,context:n};i[r][e]={data:null,pixelRatio:h,sdf:u,stretchX:c,stretchY:d,content:p,textFitWidth:f,textFitHeight:m,spriteData:_}}}return i}(o,s)}(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 Bt(r))}finally{this._spriteRequest=null,this.imageManager.setLoaded(!0),t&&(this._changed=!0),this.dispatcher.broadcast("SI",this.imageManager.listImages()),this.fire(new ts("data")),i?.(r)}}_unloadSprite(){this._markImagesChanged(this.imageManager.removeAllSpriteImages()),this._imagesListDirty=!0,this._changed=!0,this.fire(new ts("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 Bt(/* @__PURE__ */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?Le(i):i);let r=[];for(let a of e)if(i[a]){let e=t?Le(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._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 is("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 ts("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})}resize(){for(let e of this._order)this._layers[e].resize()}_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??!0)&&ps(this,e))return!1;(e=Le(e)).layers=Gt(e.layers);let r=function(e,t){if(!e)return[{command:"setStyle",args:[t]}];let i=[];try{if(!Zt(e.version,t.version))return[{command:"setStyle",args:[t]}];Zt(e.center,t.center)||i.push({command:"setCenter",args:[t.center]}),Zt(e.state,t.state)||i.push({command:"setGlobalState",args:[t.state]}),Zt(e.centerAltitude,t.centerAltitude)||i.push({command:"setCenterAltitude",args:[t.centerAltitude]}),Zt(e.zoom,t.zoom)||i.push({command:"setZoom",args:[t.zoom]}),Zt(e.bearing,t.bearing)||i.push({command:"setBearing",args:[t.bearing]}),Zt(e.pitch,t.pitch)||i.push({command:"setPitch",args:[t.pitch]}),Zt(e.roll,t.roll)||i.push({command:"setRoll",args:[t.roll]}),Zt(e.sprite,t.sprite)||i.push({command:"setSprite",args:[t.sprite]}),Zt(e.glyphs,t.glyphs)||i.push({command:"setGlyphs",args:[t.glyphs]}),Zt(e["font-faces"],t["font-faces"])||i.push({command:"setFontFaces",args:[t["font-faces"]]}),Zt(e.transition,t.transition)||i.push({command:"setTransition",args:[t.transition]}),Zt(e.light,t.light)||i.push({command:"setLight",args:[t.light]});let r=!Zt(e.terrain,t.terrain);r&&!t.terrain&&i.push({command:"setTerrain",args:[void 0]}),Zt(e.sky,t.sky)||i.push({command:"setSky",args:[t.sky]}),Zt(e.projection,t.projection)||i.push({command:"setProjection",args:[t.projection]});let a={},n=[];!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)||Ht(a,i,r));for(a in t)Object.prototype.hasOwnProperty.call(t,a)&&(Object.prototype.hasOwnProperty.call(e,a)?Zt(e[a],t[a])||("geojson"===e[a].type&&"geojson"===t[a].type&&Yt(e,t,a)?qt(i,{command:"setGeoJSONSourceData",args:[a,t[a].data]}):Xt(a,t,i,r)):Wt(a,t,i))}(e.sources,t.sources,n,a);let o=[];e.layers&&e.layers.forEach(e=>{"source"in e&&a[e.source]?i.push({command:"removeLayer",args:[e.id]}):o.push(e)}),i=i.concat(n),function(e,t,i){e||=[],t||=[];let r,a,n,o,s,l=e.map(Qt),u=t.map(Qt),h=e.reduce(ei,{}),c=t.reduce(ei,{}),d=l.slice(),p=Object.create(null);for(let f=0,m=0;f<l.length;f++)r=l[f],Object.prototype.hasOwnProperty.call(c,r)?m++:(qt(i,{command:"removeLayer",args:[r]}),d.splice(d.indexOf(r,m),1));for(let f=0,m=0;f<u.length;f++)r=u[u.length-1-f],d[d.length-1-f]!==r&&(Object.prototype.hasOwnProperty.call(h,r)?(qt(i,{command:"removeLayer",args:[r]}),d.splice(d.lastIndexOf(r,d.length-m),1)):m++,o=d[d.length-f],qt(i,{command:"addLayer",args:[c[r],o]}),d.splice(d.length-f,0,r),p[r]=!0);for(let f=0;f<u.length;f++)if(r=u[f],a=h[r],n=c[r],!p[r]&&!Zt(a,n))if(Zt(a.source,n.source)&&Zt(a["source-layer"],n["source-layer"])&&Zt(a.type,n.type)){for(s in Jt(a.layout,n.layout,i,r,"setLayoutProperty"),Jt(a.paint,n.paint,i,r,"setPaintProperty"),Zt(a.filter,n.filter)||qt(i,{command:"setFilter",args:[r,n.filter]}),(!Zt(a.minzoom,n.minzoom)||!Zt(a.maxzoom,n.maxzoom))&&qt(i,{command:"setLayerZoomRange",args:[r,n.minzoom,n.maxzoom]}),a)Object.prototype.hasOwnProperty.call(a,s)&&"layout"!==s&&"paint"!==s&&"filter"!==s&&"metadata"!==s&&"minzoom"!==s&&"maxzoom"!==s&&(0===s.indexOf("paint.")?Jt(a[s],n[s],i,r,"setPaintProperty"):Zt(a[s],n[s])||qt(i,{command:"setLayerProperty",args:[r,s,n[s]]}));for(s in n)Object.prototype.hasOwnProperty.call(n,s)&&!Object.prototype.hasOwnProperty.call(a,s)&&"layout"!==s&&"paint"!==s&&"filter"!==s&&"metadata"!==s&&"minzoom"!==s&&"maxzoom"!==s&&(0===s.indexOf("paint.")?Jt(a[s],n[s],i,r,"setPaintProperty"):Zt(a[s],n[s])||qt(i,{command:"setLayerProperty",args:[r,s,n[s]]}))}else qt(i,{command:"removeLayer",args:[r]}),o=d[d.lastIndexOf(r)+1],qt(i,{command:"addLayer",args:[n,o]})}(o,t.layers,i),r&&t.terrain&&i.push({command:"setTerrain",args:[t.terrain]})}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;this._initialGlobalState=t.globalState??{};for(let n of a.operations)n();return this.stylesheet=e,this._serializedLayers=null,this.fire(new es({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":{let[e,i]=r.args;t.push(()=>this.addLayer(e,i));break}case"removeLayer":{let[e]=r.args;t.push(()=>this.removeLayer(e));break}case"setPaintProperty":{let[e,i,a]=r.args;t.push(()=>this.setPaintProperty(e,i,a));break}case"setLayoutProperty":{let[e,i,a]=r.args;t.push(()=>this.setLayoutProperty(e,i,a));break}case"setFilter":{let[e,i]=r.args;t.push(()=>this.setFilter(e,i));break}case"addSource":{let[e,i]=r.args;t.push(()=>this.addSource(e,i));break}case"removeSource":{let[e]=r.args;t.push(()=>this.removeSource(e));break}case"setLayerZoomRange":{let[e,i,a]=r.args;t.push(()=>this.setLayerZoomRange(e,i,a));break}case"setLight":{let[e]=r.args;t.push(()=>this.setLight(e));break}case"setGeoJSONSourceData":{let[e,i]=r.args;t.push(()=>this.setGeoJSONSourceData(e,i));break}case"setGlyphs":{let[e]=r.args;t.push(()=>this.setGlyphs(e));break}case"setFontFaces":{let[e]=r.args;t.push(()=>this.setFontFaces(e));break}case"setSprite":{let[e]=r.args;t.push(()=>this.setSprite(e));break}case"setTerrain":{let[e]=r.args;t.push(()=>this.map.setTerrain(e));break}case"setSky":{let[e]=r.args;t.push(()=>this.setSky(e));break}case"setProjection":{let[e]=r.args;t.push(()=>this.setProjection(e));break}case"setGlobalState":{let[e]=r.args;t.push(()=>this.setGlobalState(e));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 Bt(/* @__PURE__ */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 Bt(/* @__PURE__ */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 ts("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(ds.has(t.type)&&this._validate(cs.source,`sources.${e}`,t,null,i))return;this.map?._collectResourceTiming&&(t.collectResourceTiming=!0);let r=this.tileManagers[e]=new tx(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 Bt(/* @__PURE__ */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 is("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 Bt(/* @__PURE__ */Error(`Layer "${a}" already exists on this map.`)));if("custom"===e.type){if(fs(this,function(e){let t=[],i=e.id;return void 0===i&&t.push(new ti(`layers.${i}`,null,'missing required property "id"')),void 0===e.render&&t.push(new ti(`layers.${i}`,null,'missing required method "render"')),e.renderingMode&&"2d"!==e.renderingMode&&"3d"!==e.renderingMode&&t.push(new ti(`layers.${i}`,null,'property "renderingMode" must be either "2d" or "3d"')),t}(e)))return;r=Fm(e,this._globalState)}else{if("source"in e&&"object"==typeof e.source&&(this.addSource(a,e.source),e=Ee(e=Le(e),{source:a})),this._validate(cs.layer,`layers.${a}`,e,{arrayIndex:-1},i))return;r=Fm(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 Bt(/* @__PURE__ */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 Bt(/* @__PURE__ */Error(`The layer '${e}' does not exist in the map's style and cannot be moved.`)));if(e===t)return;if(t&&!this._order.includes(t))return void this.fire(new Bt(/* @__PURE__ */Error(`Cannot move layer "${e}" before non-existing layer "${t}".`)));let i=this._order.indexOf(e);this._order.splice(i,1);let r=t?this._order.indexOf(t):this._order.length;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 Bt(/* @__PURE__ */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],"symbol"===t.type&&t.source&&this.tileManagers[t.source]?.resetMaxContentElevation(),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 Bt(/* @__PURE__ */Error(`Cannot set the zoom range of non-existing layer "${e}".`)))}setFilter(e,t,i={}){this._checkLoaded();let r=this.getLayer(e);r?Re(r.filter,t)||(null==t?(r.setFilter(void 0),this._updateLayer(r)):this._validate(cs.filter,`layers.${r.id}.filter`,t,null,i)||(r.setFilter(Le(t)),this._updateLayer(r))):this.fire(new Bt(/* @__PURE__ */Error(`Cannot filter non-existing layer "${e}".`)))}getFilter(e){return Le(this.getLayer(e).filter)}setLayoutProperty(e,t,i,r={}){this._checkLoaded();let a=this.getLayer(e);a?Re(a.getLayoutProperty(t),i)||(a.setLayoutProperty(t,i,r),this._updateLayer(a)):this.fire(new Bt(/* @__PURE__ */Error(`Cannot style non-existing layer "${e}".`)))}getLayoutProperty(e,t){let i=this.getLayer(e);if(i)return i.getLayoutProperty(t);this.fire(new Bt(/* @__PURE__ */Error(`Cannot get style of non-existing layer "${e}".`)))}setPaintProperty(e,t,i,r={}){this._checkLoaded();let a=this.getLayer(e);a?Re(a.getPaintProperty(t),i)||this._updatePaintProperty(a,t,i,r):this.fire(new Bt(/* @__PURE__ */Error(`Cannot style non-existing layer "${e}".`)))}_updatePaintProperty(e,t,i,r={}){e.setPaintProperty(t,i,r)&&this._updateLayer(e),js(e)&&"raster-fade-duration"===t&&this.tileManagers[e.source].setRasterFadeDuration(i),this._changed=!0,this._updatedPaintProps[e.id]=!0,"symbol"===e.type&&this.triggerSymbolPlacement(),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 Bt(/* @__PURE__ */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 Bt(/* @__PURE__ */Error("GeoJSON sources cannot have a sourceLayer parameter.")));if("vector"===n&&!r)return void this.fire(new Bt(/* @__PURE__ */Error("The sourceLayer parameter must be provided for vector source types.")));if(void 0===e.id)return void this.fire(new Bt(/* @__PURE__ */Error("The feature id parameter must be provided.")));let o=["__proto__","constructor","prototype"];t&&Object.keys(t).some(e=>o.includes(e))?this.fire(new Bt(/* @__PURE__ */Error(`The feature state should not include one of the following keys: ${o}`))):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 Bt(/* @__PURE__ */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 Bt(/* @__PURE__ */Error("A feature id is required to remove its specific state property."))):r.removeFeatureState(n,e.id,t):this.fire(new Bt(/* @__PURE__ */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)this.fire(new Bt(/* @__PURE__ */Error(`The source '${t}' does not exist in the map's style.`)));else{if("vector"!==r.getSource().type||i)return void 0===e.id&&this.fire(new Bt(/* @__PURE__ */Error("The feature id parameter must be provided."))),r.getFeatureState(i,e.id);this.fire(new Bt(/* @__PURE__ */Error("The sourceLayer parameter must be provided for vector source types.")))}}getTransition(){return Ee({duration:300,delay:0},this.stylesheet?.transition)}serialize(){if(!this._loaded)return;let e=ze(this.tileManagers,e=>e.serialize()),t=this._serializeByIds(this._order,!0),i=this.map.getTerrain()||void 0,r=this.stylesheet;return ke({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,"font-faces":r["font-faces"],transition:r.transition,projection:r.projection,state:r.state,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 o=this._order[n];if(t(o))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[o];if(e)for(let t of e)a.push(t.feature)}}return a}queryRenderedFeatures(e,t,i){t?.filter&&this._validate(cs.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 Bt(/* @__PURE__ */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 Bt(/* @__PURE__ */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(),o=t.layers instanceof Set?t.layers:Array.isArray(t.layers)?new Set(t.layers):null,s={...t,layers:o,globalState:this._globalState};for(let l in this.tileManagers)(!t.layers||r[l])&&a.push(s_(this.tileManagers[l],this._layers,n,e,s,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,o){let s={},l=n.queryRenderedSymbols(r),u=[];for(let h of Object.keys(l).map(Number))u.push(o[h]);u.sort(l_);for(let h of u){let i=h.featureIndex.lookupSymbolFeatures(l[h.bucketInstanceId],t,h.bucketIndex,h.sourceLayerIndex,{filterSpec:a.filter,globalState:a.globalState,worldCoordinateHelper:n.transform.worldCoordinateHelper},a.layers,a.availableImages,e);for(let e in i){s[e]||=[];let t=i[e];t.sort((e,t)=>{let i=h.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)s[e].push(i)}}return function(e,t,i){for(let r in e)for(let a of e[r])u_(a,i[t[r].source]);return e}(s,e,i)}(this._layers,n,this.tileManagers,e,s,this.placement.collisionIndex,this.placement.retainedQueryData)),this._flattenAndSortRenderedFeatures(a)}querySourceFeatures(e,t){t?.filter&&this._validate(cs.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,globalState:this._globalState,worldCoordinateHelper:this.projection.worldCoordinateHelper}):[]}getLight(){return this.light.getLight()}setLight(e,t={}){this._checkLoaded();let i=this.light.getLight(),r=!1;for(let n in e)if(!Re(e[n],i[n])){r=!0;break}if(!r)return;let a={now:dt(),transition:Ee({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(!Re(e[n],i[n])){r=!0;break}if(!r)return;let a={now:dt(),transition:Ee({duration:300,delay:0},this.stylesheet.transition)};this.sky.setSky(e,t)&&(this.stylesheet.sky=e,this.sky.updateTransitions(a))}_setProjectionInternal(e){this._applyProjection(vw(e,this.map._camera?.transform.constrainOverride,this._globalState))}_applyProjection(e){this.projection=e.projection,this.map.migrateProjection(e.transform,e.cameraHelper);for(let t in this.tileManagers)this.tileManagers[t].reload()}_validate(e,t,i,r,a={}){return!1!==a.validate&&ms(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),kv().off(Mv,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)}triggerSymbolPlacement(){this._symbolPlacementTriggered=!0}_placementInputsChanged(e,t,i){let r=this.pauseablePlacement;return!r||this._symbolPlacementTriggered||this._placedProjectionTransition!==this.projection?.transitionState||r._showCollisionBoxes!==t||r.placement.collisionGroups.crossSourceCollisions!==i||r.placement.transform.renderWorldCopies!==e.renderWorldCopies||!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]}(r.placement.transform.modelViewProjectionMatrix,e.modelViewProjectionMatrix)}_updatePlacement(e,t,i,r,a=!1){let n=!1,o=!1,s={};for(let h of this._order){let t=this._layers[h];if("symbol"!==t.type)continue;if(!s[t.source]){let e=this.tileManagers[t.source];s[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,s[t.source],e.worldCoordinateHelper.wraps?e.center.lng:0);n||=i}this.crossTileSymbolIndex.pruneUnusedLayers(this._order),a||=this._layerOrderChanged||0===i;let l=n||this._placementInputsChanged(e,t,r),u=this.pauseablePlacement?.isDone()&&!this.placement.stillRecent(dt(),e.zoom);if((a||!this.pauseablePlacement||u&&(l||this.placement.stale))&&(this._symbolPlacementTriggered=!1,this._placedProjectionTransition=this.projection?.transitionState,this.pauseablePlacement=new Wx(e,this.map.terrain,this._order,a,t,i,r,this.placement),this._layerOrderChanged=!1),this.pauseablePlacement.isDone()?l&&this.placement.setStale():(this.pauseablePlacement.continuePlacement(this._order,this._layers,s),this.pauseablePlacement.isDone()&&(this.placement=this.pauseablePlacement.commit(dt()),o=!0),n&&this.pauseablePlacement.placement.setStale()),o||n)for(let h of this._order){let e=this._layers[h];"symbol"===e.type&&this.placement.updateLayerOpacities(e,s[e.source])}return!this.pauseablePlacement.isDone()||this.placement.hasTransitions(dt())}_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(cs.glyphs,"glyphs",e,null,t))&&(this._changed=!0,this._glyphsDidChange=!0,this.stylesheet.glyphs=e,this.glyphManager.entries={},this.glyphManager.setURL(e))}getFontFaces(){return this.stylesheet["font-faces"]||null}setFontFaces(e){this._checkLoaded(),this._changed=!0,this._glyphsDidChange=!0,this.stylesheet["font-faces"]=e,this.glyphManager.setFontFaces(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=[...zm(this.stylesheet.sprite),...a];this._validate(cs.sprite,"sprite",n,null,i)||(this.stylesheet.sprite=n,this._loadSprite(a,!0,r))}removeSprite(e){this._checkLoaded();let t=zm(this.stylesheet.sprite);if(!t.find(t=>t.id===e))return void this.fire(new Bt(/* @__PURE__ */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 ts("data"))}getSprite(){return zm(this.stylesheet.sprite)}setSprite(e,t={},i){this._checkLoaded(),(!e||!this._validate(cs.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={}}},ww=Gs([{name:"a_pos",type:"Int16",components:2},{name:"a_texture_pos",type:"Int16",components:2}]),Tw=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)}},Sw={Int8:"BYTE",Uint8:"UNSIGNED_BYTE",Int16:"SHORT",Uint16:"UNSIGNED_SHORT",Int32:"INT",Uint32:"UNSIGNED_INT",Float32:"FLOAT"},Dw=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[Sw[r.type]],this.itemSize,t):e.vertexAttribPointer(a.location,r.components,e[Sw[r.type]],!1,this.itemSize,t)}}}destroy(){let e=this.context.gl;this.buffer&&(e.deleteBuffer(this.buffer),delete this.buffer)}},Ew=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)}},Cw=class extends Ew{getDefault(){return Wi.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)}},Pw=class extends Ew{getDefault(){return 1}set(e){(e!==this.current||this.dirty)&&(this.gl.clearDepth(e),this.current=e,this.dirty=!1)}},Aw=class extends Ew{getDefault(){return 0}set(e){(e!==this.current||this.dirty)&&(this.gl.clearStencil(e),this.current=e,this.dirty=!1)}},Iw=class extends Ew{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)}},Mw=class extends Ew{getDefault(){return!0}set(e){(e!==this.current||this.dirty)&&(this.gl.depthMask(e),this.current=e,this.dirty=!1)}},Fw=class extends Ew{getDefault(){return 255}set(e){(e!==this.current||this.dirty)&&(this.gl.stencilMask(e),this.current=e,this.dirty=!1)}},zw=class extends Ew{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)}},kw=class extends Ew{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)}},Rw=class extends Ew{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}},Lw=class extends Ew{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)}},Bw=class extends Ew{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}},Ow=class extends Ew{getDefault(){return this.gl.LESS}set(e){(e!==this.current||this.dirty)&&(this.gl.depthFunc(e),this.current=e,this.dirty=!1)}},jw=class extends Ew{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}},Vw=class extends Ew{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)}},Nw=class extends Ew{getDefault(){return Wi.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)}},Uw=class extends Ew{getDefault(){return this.gl.FUNC_ADD}set(e){(e!==this.current||this.dirty)&&(this.gl.blendEquation(e),this.current=e,this.dirty=!1)}},$w=class extends Ew{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}},Gw=class extends Ew{getDefault(){return this.gl.BACK}set(e){(e!==this.current||this.dirty)&&(this.gl.cullFace(e),this.current=e,this.dirty=!1)}},Zw=class extends Ew{getDefault(){return this.gl.CCW}set(e){(e!==this.current||this.dirty)&&(this.gl.frontFace(e),this.current=e,this.dirty=!1)}},qw=class extends Ew{getDefault(){return null}set(e){(e!==this.current||this.dirty)&&(this.gl.useProgram(e),this.current=e,this.dirty=!1)}},Ww=class extends Ew{getDefault(){return this.gl.TEXTURE0}set(e){(e!==this.current||this.dirty)&&(this.gl.activeTexture(e),this.current=e,this.dirty=!1)}},Hw=class extends Ew{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)}},Xw=class extends Ew{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}},Yw=class extends Ew{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}},Kw=class extends Ew{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}},Jw=class extends Ew{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}},Qw=class extends Ew{getDefault(){return null}set(e){let t=this.gl;t.bindBuffer(t.ELEMENT_ARRAY_BUFFER,e),this.current=e,this.dirty=!1}},eT=class extends Ew{getDefault(){return null}set(e){(e!==this.current||this.dirty)&&(this.gl.bindVertexArray(e),this.current=e,this.dirty=!1)}},tT=class extends Ew{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}},iT=class extends Ew{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}},rT=class extends Ew{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}},aT=class extends Ew{constructor(e,t){super(e),this.context=e,this.parent=t}getDefault(){return null}},nT=class extends aT{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}},oT=class extends aT{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}},sT=class extends aT{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}},lT=class{constructor(e,t,i,r,a){this.context=e,this.width=t,this.height=i;let n=e.gl,o=this.framebuffer=n.createFramebuffer();if(this.colorAttachment=new nT(e,o),r)this.depthAttachment=a?new sT(e,o):new oT(e,o);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)}},uT={ProjectionUBO:0,TerrainUBO:1,FrameUBO:2},hT={float:[1,1],int:[1,1],vec2:[2,2],vec4:[4,4],mat4:[16,4]};function cT(e){let t={},i=0;for(let{name:r,type:a}of e){let[e,n]=hT[a];i=Math.ceil(i/n)*n,t[r]=i,i+=e}return{offsets:t,contentWords:i,sizeWords:4*Math.ceil(i/4)}}var dT=class{constructor(e,t,i){this.context=e,this.binding=t,this.contentWords=i.contentWords;let r=e.gl;this.buffer=r.createBuffer(),r.bindBuffer(r.UNIFORM_BUFFER,this.buffer),r.bufferData(r.UNIFORM_BUFFER,4*i.sizeWords,r.DYNAMIC_DRAW),this.uploaded=new Float32Array(i.sizeWords),this.pending=new Float32Array(i.sizeWords),this.uploadedWords=new Uint32Array(this.uploaded.buffer),this.pendingWords=new Uint32Array(this.pending.buffer),this.hasData=!1}upload(){let e=this.context.gl,t=!this.hasData;if(!t){let e=this.pendingWords,i=this.uploadedWords;for(let r=0;r<this.contentWords;r++)if(e[r]!==i[r]){t=!0;break}}t?(e.bindBufferBase(e.UNIFORM_BUFFER,this.binding,this.buffer),this.context.boundUniformBuffers[this.binding]=this.buffer,e.bufferData(e.UNIFORM_BUFFER,this.pending,e.DYNAMIC_DRAW),this.uploaded.set(this.pending),this.hasData=!0):this.bind()}bind(){let e=this.context.boundUniformBuffers;if(e[this.binding]===this.buffer)return;let t=this.context.gl;t.bindBufferBase(t.UNIFORM_BUFFER,this.binding,this.buffer),e[this.binding]=this.buffer}destroy(){let e=this.context.gl;this.buffer&&(e.deleteBuffer(this.buffer),delete this.buffer)}},pT=cT([{name:"u_projection_matrix",type:"mat4"},{name:"u_projection_fallback_matrix",type:"mat4"},{name:"u_projection_tile_mercator_coords",type:"vec4"},{name:"u_projection_clipping_plane",type:"vec4"},{name:"u_projection_transition",type:"float"},{name:"u_projection_clip_antimeridian",type:"int"}]),fT=pT.offsets;function mT(e){return new dT(e,uT.ProjectionUBO,pT)}function _T(e,t){let i=e.pending;i.set(t.mainMatrix,fT.u_projection_matrix),i.set(t.fallbackMatrix,fT.u_projection_fallback_matrix),i.set(t.tileMercatorCoords,fT.u_projection_tile_mercator_coords),i.set(t.clippingPlane,fT.u_projection_clipping_plane),i[fT.u_projection_transition]=t.projectionTransition,e.pendingWords[fT.u_projection_clip_antimeridian]=+!!t.clipAntimeridian,e.upload()}var gT=cT([{name:"u_units_to_pixels",type:"vec2"},{name:"u_world_size",type:"vec2"},{name:"u_camera_to_center_distance",type:"float"},{name:"u_symbol_fade_change",type:"float"},{name:"u_aspect_ratio",type:"float"},{name:"u_device_pixel_ratio",type:"float"},{name:"u_viewport_size",type:"vec2"},{name:"u_pixel_extrude_scale",type:"vec2"},{name:"u_pitch",type:"float"}]),yT=gT.offsets;function vT(e,t,i){let r=e.pending;r[yT.u_world_size]=t,r[yT.u_world_size+1]=i,e.upload()}var xT=cT([{name:"u_terrain_matrix",type:"mat4"},{name:"u_terrain_unpack",type:"vec4"},{name:"u_terrain_dim",type:"float"},{name:"u_terrain_exaggeration",type:"float"}]),bT=xT.offsets,wT=class{constructor(e,t,i){this.blendFunction=e,this.blendColor=t,this.mask=i}};wT.Replace=[1,0],wT.disabled=new wT(wT.Replace,Wi.transparent,[!1,!1,!1,!1]),wT.unblended=new wT(wT.Replace,Wi.transparent,[!0,!0,!0,!0]),wT.alphaBlended=new wT([1,771],Wi.transparent,[!0,!0,!0,!0]);var TT=class{constructor(e){this.gl=e,this.clearColor=new Cw(this),this.clearDepth=new Pw(this),this.clearStencil=new Aw(this),this.colorMask=new Iw(this),this.depthMask=new Mw(this),this.stencilMask=new Fw(this),this.stencilFunc=new zw(this),this.stencilOp=new kw(this),this.stencilTest=new Rw(this),this.depthRange=new Lw(this),this.depthTest=new Bw(this),this.depthFunc=new Ow(this),this.blend=new jw(this),this.blendFunc=new Vw(this),this.blendColor=new Nw(this),this.blendEquation=new Uw(this),this.cullFace=new $w(this),this.cullFaceSide=new Gw(this),this.frontFace=new Zw(this),this.program=new qw(this),this.activeTexture=new Ww(this),this.viewport=new Hw(this),this.bindFramebuffer=new Xw(this),this.bindRenderbuffer=new Yw(this),this.bindTexture=new Kw(this),this.bindVertexBuffer=new Jw(this),this.bindElementBuffer=new Qw(this),this.bindVertexArray=new eT(this),this.pixelStoreUnpack=new tT(this),this.pixelStoreUnpackPremultiplyAlpha=new iT(this),this.pixelStoreUnpackFlipY=new rT(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"),this.boundUniformBuffers=[],this.projectionUniformBuffer=mT(this),this.keyedProjectionUniformBuffers=/* @__PURE__ */new Map,this.freeProjectionUniformBuffers=[],this.terrainUniformBuffer=function(e){return new dT(e,uT.TerrainUBO,xT)}(this),this.frameUniformBuffer=function(e){return new dT(e,uT.FrameUBO,gT)}(this)}destroy(){(function(e){e.projectionUniformBuffer.destroy();for(let t of e.keyedProjectionUniformBuffers.values())t.destroy();for(let t of e.freeProjectionUniformBuffers)t.destroy()})(this),this.terrainUniformBuffer.destroy(),this.frameUniformBuffer.destroy()}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,this.boundUniformBuffers=[]}setCustomLayerDefaults(){this.unbindVAO(),this.cullFace.setDefault(),this.activeTexture.setDefault(),this.pixelStoreUnpack.setDefault(),this.pixelStoreUnpackPremultiplyAlpha.setDefault(),this.pixelStoreUnpackFlipY.setDefault()}createIndexBuffer(e,t){return new Tw(this,e,t)}createVertexBuffer(e,t,i){return new Dw(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 lT(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){Re(e.blendFunction,wT.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)}},ST=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,o,s,l){this.context=e;let u=this.boundPaintVertexBuffers.length!==r.length;for(let h=0;!u&&h<r.length;h++)this.boundPaintVertexBuffers[h]!==r[h]&&(u=!0);!this.vao||this.boundProgram!==t||this.boundLayoutVertexBuffer!==i||u||this.boundIndexBuffer!==a||this.boundVertexOffset!==n||this.boundDynamicVertexBuffer!==o||this.boundDynamicVertexBuffer2!==s||this.boundDynamicVertexBuffer3!==l?this.freshBind(t,i,r,a,n,o,s,l):e.bindVertexArray.set(this.vao)}freshBind(e,t,i,r,a,n,o,s){let l=e.numAttributes,u=this.context,h=u.gl;this.vao&&this.destroy(),this.vao=u.createVertexArray(),u.bindVertexArray.set(this.vao),this.boundProgram=e,this.boundLayoutVertexBuffer=t,this.boundPaintVertexBuffers=i,this.boundIndexBuffer=r,this.boundVertexOffset=a,this.boundDynamicVertexBuffer=n,this.boundDynamicVertexBuffer2=o,this.boundDynamicVertexBuffer3=s,t.enableAttributes(h,e);for(let c of i)c.enableAttributes(h,e);n&&n.enableAttributes(h,e),o&&o.enableAttributes(h,e),s&&s.enableAttributes(h,e),t.bind(),t.setVertexAttribPointers(h,e,a);for(let c of i)c.bind(),c.setVertexAttribPointers(h,e,a);n&&(n.bind(),n.setVertexAttribPointers(h,e,a)),r&&r.bind(),o&&(o.bind(),o.setVertexAttribPointers(h,e,a)),s&&(s.bind(),s.setVertexAttribPointers(h,e,a)),u.currentNumAttributes=l}destroy(){this.vao&&=(this.context.deleteVertexArray(this.vao),null)}},DT=(e,t,i,r,a)=>({u_texture:0,u_ele_delta:e,u_fog_matrix:t,u_fog_color:i?i["fog-color"]:Wi.white,u_fog_ground_blend:i?i["fog-ground-blend"]:1,u_fog_ground_blend_opacity:a?0:i?r_(r):0,u_horizon_color:i?i["horizon-color"]:Wi.white,u_horizon_fog_blend:i?i["horizon-fog-blend"]:1,u_is_globe_mode:+!!a}),ET=e=>({u_ele_delta:e}),CT=e=>({u_tile_bounds:e});function PT(e){let t=[];for(let i of e){if(null===i)continue;let e=i.split(" ");t.push(e.pop())}return t}var AT=class{constructor(e,t,i,r,a,n,o,s,l=[]){let u=e.gl;this.program=u.createProgram();let h=PT(t.staticAttributes),c=i?i.getBinderAttributes():[],d=h.concat(c),p=lb.prelude.staticUniforms?PT(lb.prelude.staticUniforms):[],f=t.staticUniforms?PT(t.staticUniforms):[],m=i?i.getBinderUniforms():[],_=p.concat(f).concat(m),g=[];for(let D of _)g.includes(D)||g.push(D);let y=i?i.defines():[];y.unshift("#version 300 es"),a&&y.push("#define OVERDRAW_INSPECTOR;"),n&&y.push("#define TERRAIN3D;"),s&&y.push(s),l&&y.push(...l);let v=y.concat(lb.prelude.fragmentSource,o.fragmentSource,t.fragmentSource).join("\n"),x=y.concat(lb.prelude.vertexSource,o.vertexSource,t.vertexSource).join("\n"),b=u.createShader(u.FRAGMENT_SHADER);if(u.isContextLost())return void(this.failedToCreate=!0);u.shaderSource(b,v),u.compileShader(b),u.attachShader(this.program,b);let w=u.createShader(u.VERTEX_SHADER);if(u.isContextLost())return void(this.failedToCreate=!0);u.shaderSource(w,x),u.compileShader(w),u.attachShader(this.program,w),this.attributes={};let T={};if(this.numAttributes=d.length,u.linkProgram(this.program),!u.getProgramParameter(this.program,u.LINK_STATUS)){if(u.isContextLost()||0===u.getProgramParameter(this.program,u.ATTACHED_SHADERS))return void(this.failedToCreate=!0);throw u.getShaderParameter(b,u.COMPILE_STATUS)?u.getShaderParameter(w,u.COMPILE_STATUS)?Error(`Program failed to link: ${u.getProgramInfoLog(this.program)}`):Error(`Could not compile vertex shader: ${u.getShaderInfoLog(w)}`):Error(`Could not compile fragment shader: ${u.getShaderInfoLog(b)}`)}!function(e,t){for(let[i,r]of Object.entries(uT)){let a=e.getUniformBlockIndex(t,i);a!==e.INVALID_INDEX&&e.uniformBlockBinding(t,a,r)}}(u,this.program);let S=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}(u,this.program);for(let D of d){if(!D)continue;let e=u.getAttribLocation(this.program,D);e>=0&&(this.attributes[D]={location:e,isInteger:S.has(D)})}u.deleteShader(w),u.deleteShader(b);for(let D of g)if(D&&!T[D]){let e=u.getUniformLocation(this.program,D);e&&(T[D]=e)}this.fixedUniforms=r(e,T),this.terrainUniforms=((e,t)=>({u_depth:new lu(e,t.u_depth),u_terrain:new lu(e,t.u_terrain)}))(e,T),this.binderUniforms=i?i.getUniforms(e,T):[]}draw(e,t,i,r,a,n,o,s,l,u,h,c,d,p,f,m,_,g,y){let v=e.gl;if(this.failedToCreate)return;if(e.program.set(this.program),e.terrainUniformBuffer.bind(),e.frameUniformBuffer.bind(),e.setDepthMode(i),e.setStencilMode(r),e.setColorMode(a),e.setCullFace(n),s){e.activeTexture.set(v.TEXTURE2),v.bindTexture(v.TEXTURE_2D,s.depthTexture),e.activeTexture.set(v.TEXTURE3),v.bindTexture(v.TEXTURE_2D,s.texture);for(let e in this.terrainUniforms)this.terrainUniforms[e].set(s[e]);!function(e,t){let i=e.pending;i.set(t.u_terrain_matrix,bT.u_terrain_matrix),i.set(t.u_terrain_unpack,bT.u_terrain_unpack),i[bT.u_terrain_dim]=t.u_terrain_dim,i[bT.u_terrain_exaggeration]=t.u_terrain_exaggeration,e.upload()}(e.terrainUniformBuffer,s)}if(function(e,t){if(!t)return void e.projectionUniformBuffer.bind();let i=t.uniformBufferKey;if(void 0===i)return void _T(e.projectionUniformBuffer,t);let r=e.keyedProjectionUniformBuffers.get(i);if(r)return void r.bind();let a=e.freeProjectionUniformBuffers.pop()??mT(e);e.keyedProjectionUniformBuffers.set(i,a),_T(a,t)}(e,l),o)for(let b in this.fixedUniforms)this.fixedUniforms[b].set(o[b]);m&&m.setUniforms(e,this.binderUniforms,p,{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 d.get())b.vaos||={},b.vaos[u]||=new ST,b.vaos[u].bind(e,this,h,m?m.getPaintVertexBuffers():[],c,b.vertexOffset,_,g,y),v.drawElements(t,b.primitiveLength*x,v.UNSIGNED_SHORT,b.primitiveOffset*x*2)}};function IT(e,t,i){let r=1/ae(i,1,t.tileZoom),a=2**i.tileID.overscaledZ,n=i.tileSize*2**t.tileZoom/a,o=n*(i.tileID.canonical.x+i.tileID.wrap*a),s=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:[o>>16,s>>16],u_pixel_coord_lower:[65535&o,65535&s]}}var MT=(e,t,i,r,a)=>{let n=Ne(t.position),o=g();"viewport"===t.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}(o,e.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,o);let s=e.transformLightDirection(n),l=t.color;return{u_lightpos:n,u_lightpos_globe:s,u_lightintensity:t.intensity,u_lightcolor:[l.r,l.g,l.b],u_vertical_gradient:+i,u_opacity:r,u_fill_translate:a}},FT=(e,t,i,r,a,n,o,s)=>Ee(MT(e,t,i,r,a),IT(o,e,s),{u_height_factor:-(2**n.overscaledZ)/s.tileSize/8}),zT=(e,t,i,r,a)=>Ee(IT(t,e,i),{u_fill_translate:r,u_sdf_pattern:+!!a}),kT=e=>({u_fill_translate:e}),RT=e=>({u_fill_translate:e}),LT=(e,t,i,r,a)=>zT(e,t,i,r,a),BT=(e,t,i,r,a)=>{let n,o,s=0;if("map"===i.paint.get("circle-pitch-alignment")){let i=ae(t,1,e.zoom);n=!0,o=[i,i],s=i/(re*2**t.tileID.overscaledZ)*2*Math.PI*a}else n=!1,o=e.pixelsToGLUnits;return{u_scale_with_map:+("map"===i.paint.get("circle-pitch-scale")),u_pitch_with_map:+n,u_extrude_scale:o,u_globe_extrude_scale:s,u_translate:r}},OT=(e,t=1)=>({u_color:e,u_overlay:0,u_overlay_scale:t}),jT=(e,t,i,r)=>{let a=ae(e,1,t)/(re*2**e.tileID.overscaledZ)*2*Math.PI*r;return{u_extrude_scale:ae(e,1,t),u_intensity:i,u_globe_extrude_scale:a}},VT=(e,t,i,r)=>{let a=y();return A(a,0,e.width,e.height,0,0,1),{u_matrix:a,u_image:i,u_color_ramp:r,u_opacity:t.paint.get("heatmap-opacity")}},NT=(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 o=0;o<n.directionRadians.length;o++)"viewport"===i.paint.get("hillshade-illumination-anchor")&&(n.directionRadians[o]+=e.bearingInRadians);return{u_image:0,u_latrange:GT(e,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}},UT=(e,t,i)=>{let r=i.stride,a=y();return A(a,0,re,-8192,0,0,1),T(a,a,[0,-8192,0]),{u_matrix:a,u_image:1,u_dimension:[r,r],u_zoom:t.overscaledZ,u_unpack:i.getUnpackVector(),u_log2_world_width:$T(e)}};function $T(e){let t=e.worldCoordinateHelper;return t.wraps?25.2562:Math.log2(t.metersPerWorldUnit(.5,.5))}function GT(e,t){let i=e.worldCoordinateHelper;if(!i.wraps)return[0,0];let r=2**t.canonical.z,a=t.canonical.y;return[i.lngLatFromWorld(0,a/r).lat,i.lngLatFromWorld(0,(a+1)/r).lat]}var ZT=(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")}),qT=(e,t,i,r)=>({u_translation:JT(e,t,i),u_ratio:r/ae(t,1,e.zoom)}),WT=(e,t,i,r,a)=>Ee(qT(e,t,i,r),{u_image:0,u_image_height:a}),HT=(e,t,i,r,a)=>{let n=KT(t,e);return{u_translation:JT(e,t,i),u_texsize:t.imageAtlasTexture.size,u_ratio:r/ae(t,1,e.zoom),u_image:0,u_scale:[n,a.fromScale,a.toScale],u_fade:a.t}},XT=(e,t,i,r,a,n)=>{let o=KT(i,e);return Ee(qT(e,i,r,a),{u_tileratio:o,u_crossfade_from:n.fromScale,u_crossfade_to:n.toScale,u_image:0,u_mix:n.t,u_lineatlas_width:t.width,u_lineatlas_height:t.height})},YT=(e,t,i,r,a,n,o)=>{let s=KT(i,e);return Ee(qT(e,i,r,a),{u_image:0,u_image_height:o,u_tileratio:s,u_crossfade_from:n.fromScale,u_crossfade_to:n.toScale,u_image_dash:1,u_mix:n.t,u_lineatlas_width:t.width,u_lineatlas_height:t.height})};function KT(e,t){return 1/ae(e,1,t.tileZoom)}function JT(e,t,i){return ce(e,t,i.paint.get("line-translate"),i.paint.get("line-translate-anchor"))}var QT=(e,t,i,r,a,n,o,s,l,u,h,c,d,p)=>({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_rotate_symbol:+i,u_label_plane_matrix:o,u_coord_matrix:s,u_is_text:+u,u_pitch_with_map:+r,u_is_along_line:a,u_is_variable_anchor:n,u_texsize:h,u_texture:0,u_translation:l,u_pitched_scale:c,u_is_offset:d,u_height_anchor_ground:+p}),eS=(e,t,i,r,a,n,o,s,l,u,h,c,d,p,f,m)=>Ee(QT(e,t,i,r,a,n,s,l,u,h,c,p,f,m),{u_gamma_scale:r?Math.cos(o.pitch*Math.PI/180)*o.cameraToCenterDistance:1,u_is_halo:+!!d,u_is_plain:1}),tS=(e,t,i,r,a,n,o,s,l,u,h,c,d,p,f)=>Ee(eS(e,t,i,r,a,n,o,s,l,u,!0,h,!0,d,p,f),{u_texsize_icon:c,u_texture_icon:1}),iS=(e,t)=>({u_opacity:e,u_color:t}),rS=(e,t,i,r,a,n)=>Ee(function(e,t,i,r,a){let n=i.getPattern(e.from.toString()),o=i.getPattern(e.to.toString()),{width:s,height:l}=i.getPixelSize(),u=2**a.tileID.overscaledZ,h=a.tileSize*2**r.tileZoom/u,c=h*(a.tileID.canonical.x+a.tileID.wrap*u),d=h*a.tileID.canonical.y;return{u_image:0,u_pattern_tl_a:n.tl,u_pattern_br_a:n.br,u_pattern_tl_b:o.tl,u_pattern_br_b:o.br,u_texsize:[s,l],u_mix:t.t,u_pattern_size_a:n.displaySize,u_pattern_size_b:o.displaySize,u_scale_a:t.fromScale,u_scale_b:t.toScale,u_tile_units_to_pixels:1/ae(a,1,r.tileZoom),u_pixel_coord_upper:[c>>16,d>>16],u_pixel_coord_lower:[65535&c,65535&d]}}(r,n,t,i,a),{u_opacity:e}),aS=(e,t)=>({}),nS={fillExtrusion:(e,t)=>({u_lightpos:new cu(e,t.u_lightpos),u_lightpos_globe:new cu(e,t.u_lightpos_globe),u_lightintensity:new uu(e,t.u_lightintensity),u_lightcolor:new cu(e,t.u_lightcolor),u_vertical_gradient:new uu(e,t.u_vertical_gradient),u_opacity:new uu(e,t.u_opacity),u_fill_translate:new hu(e,t.u_fill_translate)}),fillExtrusionPattern:(e,t)=>({u_lightpos:new cu(e,t.u_lightpos),u_lightpos_globe:new cu(e,t.u_lightpos_globe),u_lightintensity:new uu(e,t.u_lightintensity),u_lightcolor:new cu(e,t.u_lightcolor),u_vertical_gradient:new uu(e,t.u_vertical_gradient),u_height_factor:new uu(e,t.u_height_factor),u_opacity:new uu(e,t.u_opacity),u_fill_translate:new hu(e,t.u_fill_translate),u_image:new lu(e,t.u_image),u_texsize:new hu(e,t.u_texsize),u_pixel_coord_upper:new hu(e,t.u_pixel_coord_upper),u_pixel_coord_lower:new hu(e,t.u_pixel_coord_lower),u_scale:new cu(e,t.u_scale),u_fade:new uu(e,t.u_fade)}),fill:(e,t)=>({u_fill_translate:new hu(e,t.u_fill_translate)}),fillPattern:(e,t)=>({u_image:new lu(e,t.u_image),u_texsize:new hu(e,t.u_texsize),u_pixel_coord_upper:new hu(e,t.u_pixel_coord_upper),u_pixel_coord_lower:new hu(e,t.u_pixel_coord_lower),u_scale:new cu(e,t.u_scale),u_fade:new uu(e,t.u_fade),u_sdf_pattern:new lu(e,t.u_sdf_pattern),u_fill_translate:new hu(e,t.u_fill_translate)}),fillOutline:(e,t)=>({u_fill_translate:new hu(e,t.u_fill_translate)}),fillOutlinePattern:(e,t)=>({u_image:new lu(e,t.u_image),u_texsize:new hu(e,t.u_texsize),u_pixel_coord_upper:new hu(e,t.u_pixel_coord_upper),u_pixel_coord_lower:new hu(e,t.u_pixel_coord_lower),u_scale:new cu(e,t.u_scale),u_fade:new uu(e,t.u_fade),u_sdf_pattern:new lu(e,t.u_sdf_pattern),u_fill_translate:new hu(e,t.u_fill_translate)}),circle:(e,t)=>({u_scale_with_map:new lu(e,t.u_scale_with_map),u_pitch_with_map:new lu(e,t.u_pitch_with_map),u_extrude_scale:new hu(e,t.u_extrude_scale),u_globe_extrude_scale:new uu(e,t.u_globe_extrude_scale),u_translate:new hu(e,t.u_translate)}),collisionBox:aS,collisionCircle:aS,debug:(e,t)=>({u_color:new pu(e,t.u_color),u_overlay:new lu(e,t.u_overlay),u_overlay_scale:new uu(e,t.u_overlay_scale)}),depth:aS,clippingMask:aS,heatmap:(e,t)=>({u_extrude_scale:new uu(e,t.u_extrude_scale),u_intensity:new uu(e,t.u_intensity),u_globe_extrude_scale:new uu(e,t.u_globe_extrude_scale)}),heatmapTexture:(e,t)=>({u_matrix:new gu(e,t.u_matrix),u_image:new lu(e,t.u_image),u_color_ramp:new lu(e,t.u_color_ramp),u_opacity:new uu(e,t.u_opacity)}),hillshade:(e,t)=>({u_image:new lu(e,t.u_image),u_latrange:new hu(e,t.u_latrange),u_exaggeration:new uu(e,t.u_exaggeration),u_altitudes:new mu(e,t.u_altitudes),u_azimuths:new mu(e,t.u_azimuths),u_accent:new pu(e,t.u_accent),u_method:new lu(e,t.u_method),u_shadows:new fu(e,t.u_shadows),u_highlights:new fu(e,t.u_highlights)}),hillshadePrepare:(e,t)=>({u_matrix:new gu(e,t.u_matrix),u_image:new lu(e,t.u_image),u_dimension:new hu(e,t.u_dimension),u_zoom:new uu(e,t.u_zoom),u_unpack:new du(e,t.u_unpack),u_log2_world_width:new uu(e,t.u_log2_world_width)}),colorRelief:(e,t)=>({u_image:new lu(e,t.u_image),u_unpack:new du(e,t.u_unpack),u_dimension:new hu(e,t.u_dimension),u_elevation_stops:new lu(e,t.u_elevation_stops),u_color_stops:new lu(e,t.u_color_stops),u_color_ramp_size:new lu(e,t.u_color_ramp_size),u_opacity:new uu(e,t.u_opacity)}),line:(e,t)=>({u_translation:new hu(e,t.u_translation),u_ratio:new uu(e,t.u_ratio)}),lineGradient:(e,t)=>({u_translation:new hu(e,t.u_translation),u_ratio:new uu(e,t.u_ratio),u_image:new lu(e,t.u_image),u_image_height:new uu(e,t.u_image_height)}),linePattern:(e,t)=>({u_translation:new hu(e,t.u_translation),u_texsize:new hu(e,t.u_texsize),u_ratio:new uu(e,t.u_ratio),u_image:new lu(e,t.u_image),u_scale:new cu(e,t.u_scale),u_fade:new uu(e,t.u_fade)}),lineSDF:(e,t)=>({u_translation:new hu(e,t.u_translation),u_ratio:new uu(e,t.u_ratio),u_image:new lu(e,t.u_image),u_mix:new uu(e,t.u_mix),u_tileratio:new uu(e,t.u_tileratio),u_crossfade_from:new uu(e,t.u_crossfade_from),u_crossfade_to:new uu(e,t.u_crossfade_to),u_lineatlas_width:new uu(e,t.u_lineatlas_width),u_lineatlas_height:new uu(e,t.u_lineatlas_height)}),lineGradientSDF:(e,t)=>({u_translation:new hu(e,t.u_translation),u_ratio:new uu(e,t.u_ratio),u_image:new lu(e,t.u_image),u_image_height:new uu(e,t.u_image_height),u_tileratio:new uu(e,t.u_tileratio),u_crossfade_from:new uu(e,t.u_crossfade_from),u_crossfade_to:new uu(e,t.u_crossfade_to),u_image_dash:new lu(e,t.u_image_dash),u_mix:new uu(e,t.u_mix),u_lineatlas_width:new uu(e,t.u_lineatlas_width),u_lineatlas_height:new uu(e,t.u_lineatlas_height)}),layerOpacity:(e,t)=>({u_image:new lu(e,t.u_image),u_opacity:new uu(e,t.u_opacity)}),raster:(e,t)=>({u_tl_parent:new hu(e,t.u_tl_parent),u_scale_parent:new uu(e,t.u_scale_parent),u_buffer_scale:new uu(e,t.u_buffer_scale),u_image_warp:new cu(e,t.u_image_warp),u_fade_t:new uu(e,t.u_fade_t),u_opacity:new uu(e,t.u_opacity),u_image0:new lu(e,t.u_image0),u_image1:new lu(e,t.u_image1),u_brightness_low:new uu(e,t.u_brightness_low),u_brightness_high:new uu(e,t.u_brightness_high),u_saturation_factor:new uu(e,t.u_saturation_factor),u_contrast_factor:new uu(e,t.u_contrast_factor),u_spin_weights:new cu(e,t.u_spin_weights),u_coords_top:new du(e,t.u_coords_top),u_coords_bottom:new du(e,t.u_coords_bottom)}),symbolIcon:(e,t)=>({u_is_size_zoom_constant:new lu(e,t.u_is_size_zoom_constant),u_is_size_feature_constant:new lu(e,t.u_is_size_feature_constant),u_size_t:new uu(e,t.u_size_t),u_size:new uu(e,t.u_size),u_rotate_symbol:new lu(e,t.u_rotate_symbol),u_label_plane_matrix:new gu(e,t.u_label_plane_matrix),u_coord_matrix:new gu(e,t.u_coord_matrix),u_is_text:new lu(e,t.u_is_text),u_pitch_with_map:new lu(e,t.u_pitch_with_map),u_is_along_line:new lu(e,t.u_is_along_line),u_is_variable_anchor:new lu(e,t.u_is_variable_anchor),u_texsize:new hu(e,t.u_texsize),u_texture:new lu(e,t.u_texture),u_translation:new hu(e,t.u_translation),u_pitched_scale:new uu(e,t.u_pitched_scale),u_is_offset:new lu(e,t.u_is_offset),u_height_anchor_ground:new lu(e,t.u_height_anchor_ground)}),symbolSDF:(e,t)=>({u_is_size_zoom_constant:new lu(e,t.u_is_size_zoom_constant),u_is_size_feature_constant:new lu(e,t.u_is_size_feature_constant),u_size_t:new uu(e,t.u_size_t),u_size:new uu(e,t.u_size),u_rotate_symbol:new lu(e,t.u_rotate_symbol),u_label_plane_matrix:new gu(e,t.u_label_plane_matrix),u_coord_matrix:new gu(e,t.u_coord_matrix),u_is_text:new lu(e,t.u_is_text),u_pitch_with_map:new lu(e,t.u_pitch_with_map),u_is_along_line:new lu(e,t.u_is_along_line),u_is_variable_anchor:new lu(e,t.u_is_variable_anchor),u_texsize:new hu(e,t.u_texsize),u_texture:new lu(e,t.u_texture),u_gamma_scale:new uu(e,t.u_gamma_scale),u_is_halo:new lu(e,t.u_is_halo),u_is_plain:new lu(e,t.u_is_plain),u_translation:new hu(e,t.u_translation),u_pitched_scale:new uu(e,t.u_pitched_scale),u_is_offset:new lu(e,t.u_is_offset),u_height_anchor_ground:new lu(e,t.u_height_anchor_ground)}),symbolTextAndIcon:(e,t)=>({u_is_size_zoom_constant:new lu(e,t.u_is_size_zoom_constant),u_is_size_feature_constant:new lu(e,t.u_is_size_feature_constant),u_size_t:new uu(e,t.u_size_t),u_size:new uu(e,t.u_size),u_rotate_symbol:new lu(e,t.u_rotate_symbol),u_label_plane_matrix:new gu(e,t.u_label_plane_matrix),u_coord_matrix:new gu(e,t.u_coord_matrix),u_is_text:new lu(e,t.u_is_text),u_pitch_with_map:new lu(e,t.u_pitch_with_map),u_is_along_line:new lu(e,t.u_is_along_line),u_is_variable_anchor:new lu(e,t.u_is_variable_anchor),u_texsize:new hu(e,t.u_texsize),u_texsize_icon:new hu(e,t.u_texsize_icon),u_texture:new lu(e,t.u_texture),u_texture_icon:new lu(e,t.u_texture_icon),u_gamma_scale:new uu(e,t.u_gamma_scale),u_is_halo:new lu(e,t.u_is_halo),u_translation:new hu(e,t.u_translation),u_pitched_scale:new uu(e,t.u_pitched_scale),u_is_offset:new lu(e,t.u_is_offset),u_height_anchor_ground:new lu(e,t.u_height_anchor_ground)}),background:(e,t)=>({u_opacity:new uu(e,t.u_opacity),u_color:new pu(e,t.u_color)}),backgroundPattern:(e,t)=>({u_opacity:new uu(e,t.u_opacity),u_image:new lu(e,t.u_image),u_pattern_tl_a:new hu(e,t.u_pattern_tl_a),u_pattern_br_a:new hu(e,t.u_pattern_br_a),u_pattern_tl_b:new hu(e,t.u_pattern_tl_b),u_pattern_br_b:new hu(e,t.u_pattern_br_b),u_texsize:new hu(e,t.u_texsize),u_mix:new uu(e,t.u_mix),u_pattern_size_a:new hu(e,t.u_pattern_size_a),u_pattern_size_b:new hu(e,t.u_pattern_size_b),u_scale_a:new uu(e,t.u_scale_a),u_scale_b:new uu(e,t.u_scale_b),u_pixel_coord_upper:new hu(e,t.u_pixel_coord_upper),u_pixel_coord_lower:new hu(e,t.u_pixel_coord_lower),u_tile_units_to_pixels:new uu(e,t.u_tile_units_to_pixels)}),terrain:(e,t)=>({u_texture:new lu(e,t.u_texture),u_ele_delta:new uu(e,t.u_ele_delta),u_fog_matrix:new gu(e,t.u_fog_matrix),u_fog_color:new pu(e,t.u_fog_color),u_fog_ground_blend:new uu(e,t.u_fog_ground_blend),u_fog_ground_blend_opacity:new uu(e,t.u_fog_ground_blend_opacity),u_horizon_color:new pu(e,t.u_horizon_color),u_horizon_fog_blend:new uu(e,t.u_horizon_fog_blend),u_is_globe_mode:new uu(e,t.u_is_globe_mode)}),terrainDepth:(e,t)=>({u_ele_delta:new uu(e,t.u_ele_delta)}),terrainHeight:(e,t)=>({u_tile_bounds:new du(e,t.u_tile_bounds)}),atmosphere:(e,t)=>({u_sun_pos:new cu(e,t.u_sun_pos),u_atmosphere_blend:new uu(e,t.u_atmosphere_blend),u_globe_position:new cu(e,t.u_globe_position),u_globe_radius:new uu(e,t.u_globe_radius),u_inv_proj_matrix:new gu(e,t.u_inv_proj_matrix)}),sky:(e,t)=>({u_sky_color:new pu(e,t.u_sky_color),u_horizon_color:new pu(e,t.u_horizon_color),u_horizon:new hu(e,t.u_horizon),u_horizon_normal:new hu(e,t.u_horizon_normal),u_sky_horizon_blend:new uu(e,t.u_sky_horizon_blend),u_sky_blend:new uu(e,t.u_sky_blend),u_inv_proj_matrix:new gu(e,t.u_inv_proj_matrix),u_globe_position:new cu(e,t.u_globe_position),u_globe_radius:new uu(e,t.u_globe_radius),u_atmosphere_blend:new uu(e,t.u_atmosphere_blend)})},oS=class{constructor(e){this.programs={},this.context=e}getProgram(e){let t=e.programConfiguration?e.programConfiguration.cacheKey:"",i=`/${e.projectionShaderVariant.name}`,r=e.showOverdrawInspector?"/overdraw":"",a=e.useTerrain?"/terrain":"",n=e.defines?`/${e.defines.join("/")}`:"",o=e.name+t+i+r+a+n;return this.programs[o]||=new AT(this.context,lb[e.name],e.programConfiguration,nS[e.name],e.showOverdrawInspector,e.useTerrain,e.projectionShaderVariant.prelude,e.projectionShaderVariant.define,e.defines),this.programs[o]}destroy(){for(let e of Object.values(this.programs))e.program&&this.context.gl.deleteProgram(e.program);this.programs={}}},sS=7680,lS=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}};lS.disabled=new lS({func:519,mask:0},0,0,sS,sS,sS);var uS=2305,hS=class{constructor(e,t,i){this.enable=e,this.mode=t,this.frontFace=i}};hS.disabled=new hS(!1,1029,uS),hS.backCCW=new hS(!0,1029,uS),hS.frontCCW=new hS(!0,1028,uS);var cS,dS=class{constructor(e,t,i){this.func=e,this.mask=t,this.range=i}};function pS(e,t,i,r,a){let n=a.context,o=n.gl,s=a.useProgram("collisionBox"),l=[],u=0,h=0;for(let _ of i){let i=e.getTile(_).getBucket(t);if(!i)continue;let c=r?i.textCollisionBox:i.iconCollisionBox,d=i.collisionCircleArray;d.length>0&&(l.push({circleArray:d,circleOffset:h,coord:_}),u+=d.length/4,h=u),c&&s.draw(n,o.LINES,dS.disabled,lS.disabled,a.colorModeForRenderPass(),hS.disabled,null,a.getTerrainDataForTile(_),a.getProjectionDataForTile(_),t.id,c.layoutVertexBuffer,c.indexBuffer,c.segments,null,a.transform.zoom,null,null,c.collisionVertexBuffer)}if(!r||!l.length)return;let c=a.useProgram("collisionCircle"),d=new Ul;d.resize(4*u),d._trim();let p=0;for(let _ of l)for(let e=0;e<_.circleArray.length/4;e++){let t=4*e,i=_.circleArray[t+0],r=_.circleArray[t+1],a=_.circleArray[t+2],n=_.circleArray[t+3];d.emplace(p++,i,r,a,n,0),d.emplace(p++,i,r,a,n,1),d.emplace(p++,i,r,a,n,2),d.emplace(p++,i,r,a,n,3)}(!cS||cS.length<2*u)&&(cS=function(e){let t=2*e,i=new Gl;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 f=n.createIndexBuffer(cS,!0),m=n.createVertexBuffer(d,ep.members,!0);for(let _ of l)c.draw(n,o.TRIANGLES,dS.disabled,lS.disabled,a.colorModeForRenderPass(),hS.disabled,null,a.getTerrainDataForTile(_.coord),null,t.id,m,f,Yl.simpleSegment(0,2*_.circleOffset,_.circleArray.length,_.circleArray.length/2),null,a.transform.zoom,null,null,null);m.destroy(),f.destroy()}dS.ReadOnly=!1,dS.ReadWrite=!0,dS.disabled=new dS(519,dS.ReadOnly,[0,1]);var fS=x(/* @__PURE__ */new Float32Array(16));function mS(e,t,i,r,a,n){let{horizontalAlign:o,verticalAlign:s}=gf(e),l=-(s-.5)*i;return new d((-(o-.5)*t/a+r[0])*n,(l/a+r[1])*n)}function _S(e,t,i,r,a,n){let o=t.tileAnchorPoint.add(new d(t.translation[0],t.translation[1]));if(t.pitchWithMap){let e=r.mult(n);i||(e=e.rotate(-a));let s=o.add(e);return dx(s.x,s.y,t.pitchedLabelPlaneMatrix,cx(t,s.x,s.y)).point}if(i){let i=bx(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 gS(e,t,i,r,a,n,o,s,l,u,h,c,p){let f=e.text.placedSymbolArray,m=e.text.dynamicLayoutVertexArray,_=e.icon.dynamicLayoutVertexArray,g={};m.clear();for(let y=0;y<f.length;y++){let _=f.get(y),v=e.allowVerticalPlacement&&!_.placedOrientation,x=_.hidden||!_.crossTileID||v?null:r[_.crossTileID];if(x){let r=new d(_.anchorX,_.anchorY),f={getElevation:c,heightOffset:_.heightOffset,heightAnchorGround:p,width:a.width,height:a.height,pitchedLabelPlaneMatrix:n,lineVertexArray:null,pitchWithMap:i,transform:a,projectionCache:null,tileAnchorPoint:r,translation:u,unwrappedTileID:h},y=i?Tx(r.x,r.y,f):bx(r.x,r.y,f),v=px(a.cameraToCenterDistance,y.signedDistanceFromCamera),b=Rf(e.textSizeData,s,_)*v/24;i&&(b*=e.tilePixelRatio/o);let{width:w,height:T,anchor:S,textOffset:D,textBoxScale:E}=x,C=mS(S,w,T,D,E,b),P=a.getPitchedTextCorrection(r.x+u[0],r.y+u[1],h),A=_S(y.point,f,t,C,-a.bearingInRadians,P),I=e.allowVerticalPlacement&&2===_.placedOrientation?Math.PI/2:0;for(let e=0;e<_.numGlyphs;e++)mm(m,A,I);l&&_.associatedIconIndex>=0&&(g[_.associatedIconIndex]={shiftedAnchor:A,angle:I})}else Px(_.numGlyphs,m)}if(l){_.clear();let t=e.icon.placedSymbolArray;for(let e=0;e<t.length;e++){let i=t.get(e);if(i.hidden)Px(i.numGlyphs,_);else{let t=g[e];if(t)for(let e=0;e<i.numGlyphs;e++)mm(_,t.shiftedAnchor,t.angle);else Px(i.numGlyphs,_)}}e.icon.dynamicLayoutVertexBuffer.updateData(_)}e.text.dynamicLayoutVertexBuffer.updateData(m)}function yS(e,t,i){return i.iconsInText&&t?"symbolTextAndIcon":e?"symbolSDF":"symbolIcon"}function vS(e,t,i,r,a,n,o,s,l,u,h,c,d){let p=d.context,f=p.gl,m=d.transform,_="map"===s,g="map"===l,v="viewport"!==s&&"point"!==i.layout.get("symbol-placement"),x=_&&!g&&!v,b=!i.layout.get("symbol-sort-key").isConstant(),w=!1,T=d.getDepthModeForSublayer(0,dS.ReadOnly),S=i._unevaluatedLayout.hasValue("text-variable-anchor")||i._unevaluatedLayout.hasValue("text-variable-anchor-offset"),D=[],E=m.getCircleRadiusCorrection();for(let A of r){let r=t.getTile(A),s=r.getBucket(i);if(!s)continue;let l=a?s.text:s.icon;if(!l?.segments.get().length||!l.hasVisibleVertices)continue;let h,c,p,T,C=l.programConfigurations.get(i.id),P=a||s.sdfIcons,I=a?s.textSizeData:s.iconSizeData,M=g||0!==m.pitch,F=d.useProgram(yS(P,a,s),C),z=Lf(I,m.zoom),k=d.getTerrainDataForTile(A),R=[0,0],L=null;if(a){if(c=r.glyphAtlasTexture,p=f.LINEAR,h=r.glyphAtlasTexture.size,s.iconsInText){R=r.imageAtlasTexture.size,L=r.imageAtlasTexture;let e="composite"===I.kind||"camera"===I.kind;T=M||d.data.rotating||d.data.zooming||e?f.LINEAR:f.NEAREST}}else{let e=1!==i.layout.get("icon-size").constantOr(0)||s.iconsNeedLinear;c=r.imageAtlasTexture,p=P||d.data.rotating||d.data.zooming||e||M?f.LINEAR:f.NEAREST,h=r.imageAtlasTexture.size}let B=ae(r,1,d.transform.zoom),O=lx(_,d.transform,B),j=ux(g,_,d.transform,B),V=ce(m,r,n,o),N=d.getProjectionDataForTile(A),U=S&&s.hasTextData(),$="none"!==i.layout.get("icon-text-fit")&&U&&s.hasIconData(),G=i._unevaluatedLayout.hasValue("icon-offset"),Z="ground"===i.layout.get("symbol-height-anchor");if(v){let t=y();ox(t,O);let r=d.terrain?(e,t)=>d.terrain.getElevation(A,e,t):void 0;mx(s,e,m,a,O,t,g,u,"map"===i.layout.get("text-rotation-alignment"),A.toUnwrapped(),V,r)}let q,W=a&&S||$,H=g?O:d.transform.clipSpaceToPixelsMatrix,X=v||W?fS:H,Y=P&&0!==i.paint.get(a?"text-halo-width":"icon-halo-width").constantOr(1);q=P?s.iconsInText?tS(I.kind,z,x,g,v,W,m,X,j,V,h,R,E,G,Z):eS(I.kind,z,x,g,v,W,m,X,j,V,a,h,Y,E,G,Z):QT(I.kind,z,x,g,v,W,X,j,V,a,h,E,G,Z);let K={program:F,buffers:l,uniformValues:q,projectionData:N,atlasTexture:c,atlasTextureIcon:L,atlasInterpolation:p,atlasInterpolationIcon:T,isSDF:P,hasHalo:Y};if(b&&s.canOverlap){w=!0;let e=l.segments.get();for(let t of e)D.push({segments:new Yl([t]),sortKey:t.sortKey,state:K,terrainData:k})}else D.push({segments:l.segments,sortKey:0,state:K,terrainData:k})}w&&D.sort((e,t)=>e.sortKey-t.sortKey);let C=i.paint.get(a?"text-halo-width":"icon-halo-width").constantOr(null)??1/0,P=24*i.layout.get("text-letter-spacing").constantOr(0)<0||C>1;for(let y of D){let e=y.state;p.activeTexture.set(f.TEXTURE0),e.atlasTexture.bind(e.atlasInterpolation,f.CLAMP_TO_EDGE),e.atlasTextureIcon&&(p.activeTexture.set(f.TEXTURE1),e.atlasTextureIcon&&e.atlasTextureIcon.bind(e.atlasInterpolationIcon,f.CLAMP_TO_EDGE));let t=e.isSDF&&e.hasHalo;if(t){let t=e.uniformValues;t.u_is_halo=1,P&&(t.u_is_plain=0,xS(e.buffers,y.segments,i,d,e.program,T,h,c,t,e.projectionData,y.terrainData),t.u_is_halo=0,t.u_is_plain=1)}xS(e.buffers,y.segments,i,d,e.program,T,h,c,e.uniformValues,e.projectionData,y.terrainData),t&&!P&&(e.uniformValues.u_is_halo=0)}}function xS(e,t,i,r,a,n,o,s,l,u,h){let c=r.context,d=c.gl;a.draw(c,d.TRIANGLES,n,o,s,hS.backCCW,l,h,u,i.id,e.layoutVertexBuffer,e.indexBuffer,t,i.paint,r.transform.zoom,e.programConfigurations.get(i.id),e.dynamicLayoutVertexBuffer,e.opacityVertexBuffer)}function bS(e,t,i,r){let a=r.context,n=a.gl,o=lS.disabled,s=new wT([n.ONE,n.ONE],Wi.transparent,[!0,!0,!0,!0]),l=e.getBucket(t);if(!l)return;let u=i.key,h=t.heatmapFbos.get(u);h||(h=TS(a,e.tileSize,e.tileSize),t.heatmapFbos.set(u,h)),a.bindFramebuffer.set(h.framebuffer),a.viewport.set([0,0,e.tileSize,e.tileSize]),a.clear({color:Wi.transparent});let c=l.programConfigurations.get(t.id),d=r.useProgram("heatmap",c,!r.data.isRenderingGlobe),p=r.getProjectionDataForTile(e.tileID),f=r.getTerrainDataForTile(i);d.draw(a,n.TRIANGLES,dS.disabled,o,s,hS.disabled,jT(e,r.transform.zoom,t.paint.get("heatmap-intensity"),1),f,p,t.id,l.layoutVertexBuffer,l.indexBuffer,l.segments,t.paint,r.transform.zoom,c)}function wS(e,t,i,r){let a=r.context,n=a.gl,o=r.transform;a.setColorMode(r.colorModeForRenderPass());let s=SS(a,t),l=i.key,u=t.heatmapFbos.get(l);if(!u)return;a.activeTexture.set(n.TEXTURE0),n.bindTexture(n.TEXTURE_2D,u.colorAttachment.get()),a.activeTexture.set(n.TEXTURE1),s.bind(n.LINEAR,n.CLAMP_TO_EDGE);let h=r.getProjectionDataForTile(i,{applyTerrainMatrix:r.data.isRenderingGlobe});r.useProgram("heatmapTexture").draw(a,n.TRIANGLES,dS.disabled,lS.disabled,r.colorModeForRenderPass(),hS.disabled,VT(e,t,0,1),null,h,t.id,e.rasterBoundsBuffer,e.quadTriangleIndexBuffer,e.rasterBoundsSegments,t.paint,o.zoom),u.destroy(),t.heatmapFbos.delete(l)}function TS(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 SS(e,t){return t.colorRampTexture||=new Fh(e,t.colorRamp,e.gl.RGBA),t.colorRampTexture}function DS(e,t,i,r){let a=r.context,n=a.bindFramebuffer.get(),o=a.viewport.get(),[,,s,l]=o;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,s,l),a.viewport.set([0,0,s,l]),a.clear({color:Wi.transparent,depth:1,stencil:0}),r.invalidateTileClippingMasks(),r.renderTileClippingMasks(t,i),{compositeTarget:n,compositeViewport:o}}function ES(e,t,i,r,a){let n=a.context,o=n.gl;n.bindFramebuffer.set(i.compositeTarget),n.viewport.set(i.compositeViewport),n.activeTexture.set(o.TEXTURE0),o.bindTexture(o.TEXTURE_2D,e.layerOpacityFbo.colorAttachment.get()),a.useProgram("layerOpacity").draw(n,o.TRIANGLES,dS.disabled,lS.disabled,a.colorModeForRenderPass(),hS.disabled,(e=>({u_image:0,u_opacity:e}))(t),null,null,r.id,e.viewportBuffer,e.quadTriangleIndexBuffer,e.viewportSegments,r.paint,a.transform.zoom),a.invalidateTileClippingMasks()}function CS(e,t,i,r,a,n,o,s){let l=256;if(r.stepInterpolant){let i=e.getSource().maxzoom,r=n.canonical.z===i?Math.ceil(1<<s.transform.maxZoom-n.canonical.z):1;l=Se(function(e){return e<=1?1:2**Math.ceil(Math.log(e)/Math.LN2)}(a.maxLineLength/re*1024*r),256,t.maxTextureSize)}return o.gradient=Th({expression:r.gradientExpression(),evaluationKey:"lineProgress",resolution:l,image:o.gradient||void 0,clips:a.lineClipsArray}),o.texture?o.texture.update(o.gradient):o.texture=new Fh(t,o.gradient,i.RGBA),o.version=r.gradientVersion,o.texture}function PS(e,t,i,r,a){e.activeTexture.set(t.TEXTURE0),i.imageAtlasTexture.bind(t.LINEAR,t.CLAMP_TO_EDGE),r.updatePaintBuffers(a)}function AS(e,t,i,r,a,n){(a||e.lineAtlas.dirty)&&(t.activeTexture.set(i.TEXTURE0),e.lineAtlas.bind(t)),r.updatePaintBuffers(n)}function IS(e,t,i,r,a,n,o){let s=a.gradients[r.id],l=s.texture;r.gradientVersion!==s.version&&(l=CS(e,t,i,r,a,n,s,o)),t.activeTexture.set(i.TEXTURE0),l.bind(r.stepInterpolant?i.NEAREST:i.LINEAR,i.CLAMP_TO_EDGE)}function MS(e,t,i,r,a,n,o,s,l,u){let h=n.gradients[a.id],c=h.texture;a.gradientVersion!==h.version&&(c=CS(t,i,r,a,n,o,h,u)),i.activeTexture.set(r.TEXTURE0),c.bind(a.stepInterpolant?r.NEAREST:r.LINEAR,r.CLAMP_TO_EDGE),i.activeTexture.set(r.TEXTURE1),e.lineAtlas.bind(i),s.updatePaintBuffers(l)}function FS(e,t,i,r,a){let n,o=a.getDepthModeForSublayer(0,dS.ReadOnly),s=a.colorModeForRenderPass(),l=i.paint.get("line-dasharray"),u=l.constantOr(1),h=i.paint.get("line-pattern"),c=h.constantOr(1),d=i.paint.get("line-gradient"),p=i.getCrossfadeParameters();n=c?"linePattern":u&&d?"lineGradientSDF":u?"lineSDF":d?"lineGradient":"line";let f=a.context,m=f.gl,_=a.transform,g=!0;for(let y of r){let r=t.getTile(y);if(c&&!r.patternsLoaded())continue;let v=r.getBucket(i);if(!v)continue;let x=v.programConfigurations.get(i.id),b=f.program.get(),w=a.useProgram(n,x),T=g||w.program!==b,S=a.getTerrainDataForTile(y),D=h.constantOr(null),E=l?.constantOr(null);if(D&&r.imageAtlas){let e=r.imageAtlas,t=e.patternPositions[D.to.toString()],i=e.patternPositions[D.from.toString()];t&&i&&x.setConstantPatternPositions(t,i)}else if(E){let t="round"===i.layout.get("line-cap").constantOr(null),r=e.lineAtlas.getDash(E.to,t),a=e.lineAtlas.getDash(E.from,t);x.setConstantDashPositions(r,a)}let C,P=a.getProjectionDataForTile(y),A=_.getPixelScale();c?(C=HT(_,r,i,A,p),PS(f,m,r,x,p)):u&&d?(C=YT(_,e.lineAtlas,r,i,A,p,v.lineClipsArray.length),MS(e,t,f,m,i,v,y,x,p,a)):u?(C=XT(_,e.lineAtlas,r,i,A,p),AS(e,f,m,x,T,p)):d?(C=WT(_,r,i,A,v.lineClipsArray.length),IS(t,f,m,i,v,y,a)):C=qT(_,r,i,A);let I=a.stencilModeForClipping(y);w.draw(f,m.TRIANGLES,o,I,s,hS.disabled,C,S,P,i.id,v.layoutVertexBuffer,v.indexBuffer,v.segments,i.paint,a.transform.zoom,x,v.layoutVertexBuffer2),g=!1}}function zS(e,t,i,r,a){if(!i||!r?.imageAtlas)return;let n=r.imageAtlas.patternPositions,o=n[i.to.toString()],s=n[i.from.toString()];if(!o&&s&&(o=s),!s&&o&&(s=o),!o||!s){let e=a.getPaintProperty(t);o=n[e],s=n[e]}o&&s&&e.setConstantPatternPositions(o,s)}function kS(e,t,i,r){let a=r.colorModeForRenderPass();LS(e,t,i,r.getDepthModeForSublayer(1,dS.ReadOnly),a,!1,r),RS(e,t,i,r)}function RS(e,t,i,r){if(!t.paint.get("fill-antialias"))return;let a=r.colorModeForRenderPass();LS(e,t,i,r.getDepthModeForSublayer(t.getPaintProperty("fill-outline-color")?2:0,dS.ReadOnly),a,!0,r)}function LS(e,t,i,r,a,n,o){let s,l,u,h,c,d=o.context,p=d.gl,f="fill-pattern",m=t.paint.get(f),_=m?.constantOr(1),g=t.getCrossfadeParameters(),y=o.transform,v=t.paint.get("fill-translate"),x=t.paint.get("fill-translate-anchor");n?(l=_&&!t.getPaintProperty("fill-outline-color")?"fillOutlinePattern":"fillOutline",s=p.LINES):(l=_?"fillPattern":"fill",s=p.TRIANGLES);let b=m.constantOr(null);for(let w of i){let i=e.getTile(w);if(_&&!i.patternsLoaded())continue;let m=i.getBucket(t);if(!m)continue;let T=m.sdfPatterns[t.id]??!1,S=m.programConfigurations.get(t.id),D=o.useProgram(l,S),E=o.getTerrainDataForTile(w);_&&(d.activeTexture.set(p.TEXTURE0),i.imageAtlasTexture.bind(p.LINEAR,p.CLAMP_TO_EDGE),S.updatePaintBuffers(g)),zS(S,f,b,i,t);let C=o.getProjectionDataForTile(w),P=ce(y,i,v,x);n?(h=m.indexBuffer2,c=m.segments2,u="fillOutlinePattern"===l&&_?LT(y,g,i,P,T):RT(P)):(h=m.indexBuffer,c=m.segments,u=_?zT(y,g,i,P,T):kT(P));let A=o.stencilModeForClipping(w);D.draw(d,s,r,A,a,hS.backCCW,u,E,C,t.id,m.layoutVertexBuffer,h,c,t.paint,o.transform.zoom,S)}}function BS(e,t,i,r,a,n,o){let s=o.context,l=s.gl,u="fill-extrusion-pattern",h=t.paint.get(u),c=h.constantOr(1),d=t.getCrossfadeParameters(),p=t.paint.get("fill-extrusion-opacity"),f=h.constantOr(null),m=o.transform;for(let _ of i){let i=e.getTile(_),h=i.getBucket(t);if(!h)continue;let g=o.getTerrainDataForTile(_),y=h.programConfigurations.get(t.id),v=o.useProgram(c?"fillExtrusionPattern":"fillExtrusion",y);c&&(s.activeTexture.set(l.TEXTURE0),i.imageAtlasTexture.bind(l.LINEAR,l.CLAMP_TO_EDGE),y.updatePaintBuffers(d));let x=o.getProjectionDataForTile(_);zS(y,u,f,i,t);let b=ce(m,i,t.paint.get("fill-extrusion-translate"),t.paint.get("fill-extrusion-translate-anchor")),w=t.paint.get("fill-extrusion-vertical-gradient"),T=c?FT(m,o.data.light,w,p,b,_,d,i):MT(m,o.data.light,w,p,b);v.draw(s,s.gl.TRIANGLES,r,a,n,hS.backCCW,T,g,x,t.id,h.layoutVertexBuffer,h.indexBuffer,h.segments,t.paint,o.transform.zoom,y,o.terrain&&h.centroidVertexBuffer)}}function OS(e,t,i,r,a,n,o,s){let l=s.context,u=l.gl,h=[`#define NUM_ILLUMINATION_SOURCES ${t.paint.get("hillshade-highlight-color").values.length}`],c=s.useProgram("hillshade",null,!1,h),d=!s.data.moving;for(let p of i){let i=e.getTile(p),h=i.fbo;if(!h)continue;let f=s.getMeshFromTileID(p.canonical,o,!0,"raster"),m=s.getTerrainDataForTile(p);l.activeTexture.set(u.TEXTURE0),u.bindTexture(u.TEXTURE_2D,h.colorAttachment.get());let _=s.getProjectionDataForTile(p,{aligned:d});c.draw(l,u.TRIANGLES,a,r[p.overscaledZ],n,hS.backCCW,NT(s.transform,i,t),m,_,t.id,f.vertexBuffer,f.indexBuffer,f.segments)}}var jS=0;function VS(e,t,i,r,a,n,o,s,l){let u=l.context,h=u.gl,c=l.useProgram("colorRelief"),d=!l.data.moving,p="nearest"===i.paint.get("resampling")?h.NEAREST:h.LINEAR,f=!0,m=0;for(let _ of r){let r=t.getTile(_),g=r.dem;if(!g?.data)continue;if(f){jS||=h.getParameter(h.MAX_TEXTURE_SIZE);let e=jS,{elevationTexture:t,colorTexture:r}=i.getColorRampTextures(u,e,g.getUnpackVector());u.activeTexture.set(h.TEXTURE1),t.bind(h.NEAREST,h.CLAMP_TO_EDGE),u.activeTexture.set(h.TEXTURE4),r.bind(h.LINEAR,h.CLAMP_TO_EDGE),f=!1,m=t.size[0]}let y=g.stride;u.activeTexture.set(h.TEXTURE0),(!r.demTexture||r.needsColorReliefPrepare)&&(u.pixelStoreUnpackPremultiplyAlpha.set(!1),r.demTexture||=e.getTileTexture(y)??new Fh(u,{width:y,height:y,data:null},h.RGBA),r.demTexture.update(g.getPixels(),{premultiply:!1}),r.needsColorReliefPrepare=!1),r.demTexture.bind(p,h.CLAMP_TO_EDGE);let v=l.getMeshFromTileID(_.canonical,s,!0,"raster"),x=l.getTerrainDataForTile(_),b=l.getProjectionDataForTile(_,{aligned:d});c.draw(u,h.TRIANGLES,n,a[_.overscaledZ],o,hS.backCCW,ZT(i,r.dem,m),x,b,i.id,v.vertexBuffer,v.indexBuffer,v.segments)}}var NS=[new d(0,0),new d(re,0),new d(re,re),new d(0,re)];function US(e,t,i,r,a,n,o,s,l=!1,u,h=null){let c=i[i.length-1].overscaledZ,d=u.context,p=d.gl,f=u.useProgram("raster"),m=u.colorModeForRenderPass(),_=!u.data.moving,g=t.paint.get("raster-opacity"),y="nearest"===t.paint.get("resampling")||"nearest"===t.paint.get("raster-resampling")?p.NEAREST:p.LINEAR,v=t.paint.get("raster-fade-duration"),x=!!u.terrain;for(let b of i){let i=u.getDepthModeForSublayer(b.overscaledZ-c,1===g?dS.ReadWrite:dS.ReadOnly,p.LESS),w=e.getTile(b);d.activeTexture.set(p.TEXTURE0),w.texture.bind(y,p.CLAMP_TO_EDGE,p.LINEAR_MIPMAP_NEAREST),d.activeTexture.set(p.TEXTURE1);let{parentTile:T,parentScaleBy:S,parentTopLeft:D,fadeValues:E}=$S(w,e,v,x);w.fadeOpacity=E.tileOpacity,T?(T.fadeOpacity=E.parentTileOpacity,T.texture.bind(y,p.CLAMP_TO_EDGE,p.LINEAR_MIPMAP_NEAREST)):w.texture.bind(y,p.CLAMP_TO_EDGE,p.LINEAR_MIPMAP_NEAREST),w.texture.useMipmap&&d.extTextureFilterAnisotropic&&u.transform.pitch>u.data.anisotropicFilterPitch&&p.texParameterf(p.TEXTURE_2D,d.extTextureFilterAnisotropic.TEXTURE_MAX_ANISOTROPY_EXT,d.extTextureFilterAnisotropicMax);let C=u.getTerrainDataForTile(b),P=u.getProjectionDataForTile(b,{aligned:_}),A=j_(D,S,E.fadeMix,t,o,s),I=h??u.getMeshFromTileID(b.canonical,a,n,"raster"),M=r?r[b.overscaledZ]:lS.disabled;f.draw(d,p.TRIANGLES,i,M,m,l?hS.frontCCW:hS.backCCW,A,C,P,t.id,I.vertexBuffer,I.indexBuffer,I.segments)}}function $S(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:GS(e,r,i)}}return e.selfFading?{parentTile:null,parentScaleBy:1,parentTopLeft:[0,0],fadeValues:ZS(e,i)}:a}function GS(e,t,i){let r=dt(),a=(r-e.timeAdded)/i,n=(r-t.timeAdded)/i,o=1===e.fadingDirection,s=Se(a,0,1),l=Se(1-n,0,1),u=o?s:l;return{tileOpacity:u,parentTileOpacity:o?l:s,fadeMix:{opacity:1,mix:1-u}}}function ZS(e,t){let i=Se((dt()-e.timeAdded)/t,0,1);return{tileOpacity:i,fadeMix:{opacity:i,mix:0}}}var qS=new Wi(1,0,0,1),WS=new Wi(0,1,0,1),HS=new Wi(0,0,1,1),XS=new Wi(1,0,1,1),YS=new Wi(0,1,1,1);function KS(e,t,i,r){QS(e,0,t+i/2,e.transform.width,i,r)}function JS(e,t,i,r){QS(e,t-i/2,0,i,e.transform.height,r)}function QS(e,t,i,r,a,n){let o=e.context,s=o.gl,l=e.data.pixelRatio;s.enable(s.SCISSOR_TEST),s.scissor(t*l,i*l,r*l,a*l),o.clear({color:n}),s.disable(s.SCISSOR_TEST)}function eD(e,t,i,r){let a=r.context,n=a.gl,o=r.useProgram("debug"),s=dS.disabled,l=lS.disabled,u=r.colorModeForRenderPass(),h="$debug",c=r.getTerrainDataForTile(i);a.activeTexture.set(n.TEXTURE0);let d=t.getTileByID(i.key).latestRawTileData?.byteLength||0,p=Math.floor(d/1024),f=t.getTile(i).tileSize,m=512/Math.min(f,512)*(i.overscaledZ/r.transform.zoom)*.5,_=i.canonical.toString();i.overscaledZ!==i.canonical.z&&(_+=` => ${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,`${_} ${p}kB`);let g=r.getProjectionDataForTile(i);o.draw(a,n.TRIANGLES,s,l,wT.alphaBlended,hS.disabled,OT(Wi.transparent,m),null,g,h,e.debugBuffer,e.quadTriangleIndexBuffer,e.debugSegments),o.draw(a,n.LINE_STRIP,s,l,u,hS.disabled,OT(Wi.red),c,g,h,e.debugBuffer,e.tileBorderIndexBuffer,e.debugSegments)}var tD={symbol:function(e,t,i,r,a){if("translucent"!==a.currentPass)return;let n=lS.disabled,o=a.colorModeForRenderPass();(i._unevaluatedLayout.hasValue("text-variable-anchor")||i._unevaluatedLayout.hasValue("text-variable-anchor-offset"))&&function(e,t,i,r,a,n,o,s){let l=s.transform,u=s.terrain,h=s.data.variableOffsets,c="map"===r,d="map"===a;for(let p of e){let e=i.getTile(p),r=e.getBucket(t);if(!r?.text?.segments.get().length)continue;let a=Lf(r.textSizeData,l.zoom),s=lx(c,l,ae(e,1,l.zoom)),f="none"!==t.layout.get("icon-text-fit")&&r.hasIconData();if(a){let i=2**(l.zoom-e.tileID.overscaledZ),m=u?(e,t)=>u.getElevation(p,e,t):void 0;gS(r,c,d,h,l,s,i,a,f,ce(l,e,n,o),p.toUnwrapped(),m,"ground"===t.layout.get("symbol-height-anchor"))}}}(r,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)&&vS(e,t,i,r,!1,i.paint.get("icon-translate"),i.paint.get("icon-translate-anchor"),i.layout.get("icon-rotation-alignment").constantOr("viewport"),i.layout.get("icon-pitch-alignment"),i.layout.get("icon-keep-upright"),n,o,a),0!==i.paint.get("text-opacity").constantOr(1)&&vS(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"),n,o,a),t.map.showCollisionBoxes&&(pS(t,i,r,!0,a),pS(t,i,r,!1,a))},circle:function(e,t,i,r){if("translucent"!==r.currentPass)return;let a=t.paint.get("circle-opacity"),n=t.paint.get("circle-stroke-width"),o=t.paint.get("circle-stroke-opacity"),s=!t.layout.get("circle-sort-key").isConstant();if(0===a.constantOr(1)&&(0===n.constantOr(1)||0===o.constantOr(1)))return;let l=r.context,u=l.gl,h=r.transform,c=r.getDepthModeForSublayer(0,dS.ReadOnly),d=lS.disabled,p=r.colorModeForRenderPass(),f=[],m=h.getCircleRadiusCorrection();for(let _ of i){let i=e.getTile(_),a=i.getBucket(t);if(!a)continue;let n=ce(h,i,t.paint.get("circle-translate"),t.paint.get("circle-translate-anchor")),o=a.programConfigurations.get(t.id),l=r.useProgram("circle",o),u=a.layoutVertexBuffer,c=a.indexBuffer,d=r.getTerrainDataForTile(_),p={programConfiguration:o,program:l,layoutVertexBuffer:u,indexBuffer:c,uniformValues:BT(h,i,t,n,m),terrainData:d,projectionData:r.getProjectionDataForTile(_)};if(s){let e=a.segments.get();for(let t of e)f.push({segments:new Yl([t]),sortKey:t.sortKey,state:p})}else f.push({segments:a.segments,sortKey:0,state:p})}s&&f.sort((e,t)=>e.sortKey-t.sortKey);for(let _ of f){let{programConfiguration:e,program:i,layoutVertexBuffer:a,indexBuffer:n,uniformValues:o,terrainData:s,projectionData:h}=_.state,f=_.segments;i.draw(l,u.TRIANGLES,c,d,p,hS.backCCW,o,s,h,t.id,a,n,f,t.paint,r.transform.zoom,e)}},heatmap:function(e,t,i,r,a){if(0===i.paint.get("heatmap-opacity"))return;let n=a.context;if(a.terrain){for(let n of r){let r=t.getTile(n);t.hasRenderableParent(n)||("offscreen"===a.currentPass?bS(r,i,n,a):"translucent"===a.currentPass&&wS(e,i,n,a))}n.viewport.set([0,0,e.width,e.height])}else"offscreen"===a.currentPass?function(e,t,i,r,a){let n=a.context,o=n.gl,s=a.transform,l=lS.disabled,u=new wT([o.ONE,o.ONE],Wi.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(Eh);a?(r.bindTexture(r.TEXTURE_2D,a.colorAttachment.get()),e.bindFramebuffer.set(a.framebuffer)):(a=TS(e,t.width/4,t.height/4),i.heatmapFbos.set(Eh,a))})(n,e,i),n.clear({color:Wi.transparent});for(let h of r){if(t.hasRenderableParent(h))continue;let e=t.getTile(h),r=e.getBucket(i);if(!r)continue;let c=r.programConfigurations.get(i.id),d=a.useProgram("heatmap",c),p=a.getProjectionDataForTile(h,{applyTerrainMatrix:!1}),f=s.getCircleRadiusCorrection();d.draw(n,o.TRIANGLES,dS.disabled,l,u,hS.backCCW,jT(e,s.zoom,i.paint.get("heatmap-intensity"),f),null,p,i.id,r.layoutVertexBuffer,r.indexBuffer,r.segments,i.paint,s.zoom,c)}n.viewport.set([0,0,e.width,e.height])}(e,t,i,r,a):"translucent"===a.currentPass&&function(e,t,i){let r=i.context,a=r.gl;r.setColorMode(i.colorModeForRenderPass());let n=t.heatmapFbos.get(Eh);n&&(r.activeTexture.set(a.TEXTURE0),a.bindTexture(a.TEXTURE_2D,n.colorAttachment.get()),r.activeTexture.set(a.TEXTURE1),SS(r,t).bind(a.LINEAR,a.CLAMP_TO_EDGE),i.useProgram("heatmapTexture").draw(r,a.TRIANGLES,dS.disabled,lS.disabled,i.colorModeForRenderPass(),hS.disabled,VT(e,t,0,1),null,null,t.id,e.viewportBuffer,e.quadTriangleIndexBuffer,e.viewportSegments,t.paint,i.transform.zoom))}(e,i,a)},line:function(e,t,i,r,a){if("translucent"!==a.currentPass)return;let n=i.paint.get("line-opacity"),o=i.paint.get("line-width"),s=i.paint.get("line-layer-opacity");if(0!==n.constantOr(1)&&0!==o.constantOr(1)&&0!==s)if(s<1){let n=DS(e,i,r,a);FS(e,t,i,r,a),ES(e,s,n,i,a)}else FS(e,t,i,r,a)},fill:function(e,t,i,r,a){let n=i.paint.get("fill-color"),o=i.paint.get("fill-opacity"),s=i.paint.get("fill-layer-opacity");if(0===o.constantOr(1)||0===s)return;if(s<1){if("translucent"!==a.currentPass)return;let n=DS(e,i,r,a);return kS(t,i,r,a),void ES(e,s,n,i,a)}let l=i.paint.get("fill-pattern"),u=a.opaquePassEnabledForLayer()&&!l.constantOr(1)&&1===n.constantOr(Wi.transparent).a&&1===o.constantOr(0);if(u&&"opaque"===a.currentPass){let e=a.colorModeForRenderPass();LS(t,i,r,a.getDepthModeForSublayer(1,dS.ReadWrite),e,!1,a)}else u&&"translucent"===a.currentPass?RS(t,i,r,a):"translucent"===a.currentPass&&kS(t,i,r,a)},fillExtrusion:function(e,t,i,r){let a=t.paint.get("fill-extrusion-opacity");if(0!==a&&"translucent"===r.currentPass){let n=new dS(r.context.gl.LEQUAL,dS.ReadWrite,r.depthRangeFor3D);if(1!==a||t.paint.get("fill-extrusion-pattern").constantOr(1))BS(e,t,i,n,lS.disabled,wT.disabled,r),BS(e,t,i,n,r.stencilModeFor3D(),r.colorModeForRenderPass(),r);else{let a=r.colorModeForRenderPass();BS(e,t,i,n,lS.disabled,a,r)}}},hillshade:function(e,t,i,r,a){if("offscreen"!==a.currentPass&&"translucent"!==a.currentPass)return;let n=a.context,{useSubdivision:o}=a.data,s=a.getDepthModeForSublayer(0,dS.ReadOnly),l=a.colorModeForRenderPass();if("offscreen"===a.currentPass)(function(e,t,i,r,a,n,o,s){let l=s.context,u=l.gl,h="nearest"===r.paint.get("resampling")?u.NEAREST:u.LINEAR;for(let c of i){let i=t.getTile(c),d=i.dem;if(!d?.data||!i.needsHillshadePrepare)continue;let p=d.dim+2,f=d.stride,m=d.getPixels();if(l.activeTexture.set(u.TEXTURE1),l.pixelStoreUnpackPremultiplyAlpha.set(!1),i.demTexture||=e.getTileTexture(f),i.demTexture){let e=i.demTexture;e.update(m,{premultiply:!1}),e.bind(u.NEAREST,u.CLAMP_TO_EDGE)}else i.demTexture=new Fh(l,m,u.RGBA,{premultiply:!1}),i.demTexture.bind(u.NEAREST,u.CLAMP_TO_EDGE);l.activeTexture.set(u.TEXTURE0);let _=i.fbo;if(!_){let e=new Fh(l,{width:p,height:p,data:null},u.RGBA);e.bind(h,u.CLAMP_TO_EDGE),_=i.fbo=l.createFramebuffer(p,p,!0,!1),_.colorAttachment.set(e.texture)}l.bindFramebuffer.set(_.framebuffer),l.viewport.set([0,0,p,p]),s.useProgram("hillshadePrepare").draw(l,u.TRIANGLES,a,n,o,hS.disabled,UT(s.transform,i.tileID,d),null,null,r.id,e.rasterBoundsBuffer,e.quadTriangleIndexBuffer,e.rasterBoundsSegments),i.needsHillshadePrepare=!1}})(e,t,r,i,s,lS.disabled,l,a),n.viewport.set([0,0,e.width,e.height]);else if("translucent"===a.currentPass)if(o){let[e,n,o]=a.stencilConfigForOverlapTwoPass(r);OS(t,i,o,e,s,l,!1,a),OS(t,i,o,n,s,l,!0,a)}else{let[e,n]=a.getStencilConfigForOverlapAndUpdateStencilID(r);OS(t,i,n,e,s,l,!1,a)}},colorRelief:function(e,t,i,r,a){if("translucent"!==a.currentPass||!r.length)return;let{useSubdivision:n}=a.data,o=a.getDepthModeForSublayer(0,dS.ReadOnly),s=a.colorModeForRenderPass();if(n){let[n,l,u]=a.stencilConfigForOverlapTwoPass(r);VS(e,t,i,u,n,o,s,!1,a),VS(e,t,i,u,l,o,s,!0,a)}else{let[n,l]=a.getStencilConfigForOverlapAndUpdateStencilID(r);VS(e,t,i,l,n,o,s,!1,a)}},raster:function(e,t,i,r){if("translucent"!==r.currentPass||0===t.paint.get("raster-opacity")||!i.length)return;let a=e.getSource(),{useSubdivision:n}=r.data;if(a instanceof W_)US(e,t,i,null,!1,!1,a.tileCoords,a.imageWarp,a.flippedWindingOrder,r,a.getMesh(r.context,n));else if(n){let[a,n,o]=r.stencilConfigForOverlapTwoPass(i);US(e,t,o,a,!1,!0,NS,O_,!1,r),US(e,t,o,n,!0,!0,NS,O_,!1,r)}else{let[a,n]=r.getStencilConfigForOverlapAndUpdateStencilID(i);US(e,t,n,a,!1,!0,NS,O_,!1,r)}},background:function(e,t,i,r,a){let n=i.paint.get("background-color"),o=i.paint.get("background-opacity");if(0===o)return;let s=a.context,l=s.gl,u=a.transform,h=u.tileSize,c=i.paint.get("background-pattern");if(e.patternAtlas.isPatternMissing(c))return;let d=!c&&1===n.a&&1===o&&a.opaquePassEnabledForLayer()?"opaque":"translucent";if(a.currentPass!==d)return;let p=lS.disabled,f=a.getDepthModeForSublayer(0,"opaque"===d?dS.ReadWrite:dS.ReadOnly),m=a.colorModeForRenderPass(),_=a.useProgram(c?"backgroundPattern":"background"),g=r||Wv(u,{tileSize:h,terrain:a.terrain});c&&(s.activeTexture.set(l.TEXTURE0),e.patternAtlas.bind(s));let y=i.getCrossfadeParameters();for(let v of g){let t=a.getProjectionDataForTile(v),r=c?rS(o,e.patternAtlas,u,c,{tileID:v,tileSize:h},y):iS(o,n),d=a.getTerrainDataForTile(v),g=a.getMeshFromTileID(v.canonical,!1,!0,"raster");_.draw(s,l.TRIANGLES,f,p,m,hS.backCCW,r,d,t,i.id,g.vertexBuffer,g.indexBuffer,g.segments)}},sky:function(e,t){let i=t.context,r=i.gl,{sky:a,pixelRatio:n}=t.data,o=((e,t,i)=>{let r=Math.cos(t.rollInRadians),a=Math.sin(t.rollInRadians),n=fd(t),o=t.getProjectionData({overscaledTileID:null,applyGlobeMatrix:!0,applyTerrainMatrix:!0}).projectionTransition,s=Wb(t),l=qb(t.worldSize,t.center.lat);return{u_sky_color:e["sky-color"],u_horizon_color:e["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["sky-horizon-blend"]*t.height/2*i,u_sky_blend:o,u_inv_proj_matrix:t.inverseProjectionMatrix,u_globe_position:s,u_globe_radius:l,u_atmosphere_blend:e["atmosphere-blend"]*iw(F(s)-l,l)}})(a,t.transform,n),s=new dS(r.LEQUAL,dS.ReadWrite,[0,1]),l=lS.disabled,u=t.colorModeForRenderPass();t.useProgram("sky").draw(i,r.TRIANGLES,s,l,u,hS.disabled,o,null,void 0,"sky",e.vertexBuffer,e.indexBuffer,e.segments)},atmosphere:function(e,t){let i=t.context,r=i.gl,{sky:a,light:n}=t.data,o=t.useProgram("atmosphere"),s=new dS(r.LEQUAL,dS.ReadOnly,[0,1]),l=t.transform,u=function(e,t){let i=Ne(e.position);!function(e,t){e[0]=-t[0],e[1]=-t[1],e[2]=-t[2]}(i,i);let r=x(/* @__PURE__ */new Float64Array(16));return"map"===e.anchor&&(C(r,r,t.rollInRadians),D(r,r,-t.pitchInRadians),C(r,r,t.bearingInRadians),D(r,r,t.center.lat*Math.PI/180),E(r,r,-t.center.lng*Math.PI/180)),function(e,t,i){var r=t[0],a=t[1],n=t[2],o=i[3]*r+i[7]*a+i[11]*n+i[15];o||=1,e[0]=(i[0]*r+i[4]*a+i[8]*n+i[12])/o,e[1]=(i[1]*r+i[5]*a+i[9]*n+i[13])/o,e[2]=(i[2]*r+i[6]*a+i[10]*n+i[14])/o}(i,i,r),i}(n,l),h=l.getProjectionData({overscaledTileID:null,applyGlobeMatrix:!0,applyTerrainMatrix:!0}),c=qb(l.worldSize,l.center.lat),d=Wb(l),p=iw(F(d)-c,c),f=a["atmosphere-blend"]*h.projectionTransition*p;if(0===f)return;let m=((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}))(u,f,d,c,l.inverseProjectionMatrix);o.draw(i,r.TRIANGLES,s,lS.disabled,wT.alphaBlended,hS.disabled,m,null,null,"atmosphere",e.vertexBuffer,e.indexBuffer,e.segments)},custom:function(e,t,i,r,a){if(a.isRenderingToTexture)return void function(e,t,i,r){let a=r.context,n=a.bindFramebuffer.get(),o=a.viewport.get();a.setCustomLayerDefaults(),a.setColorMode(r.colorModeForRenderPass()),a.setDepthMode(dS.disabled),a.setStencilMode(lS.disabled),t.implementation.renderToTerrainTile(a.gl,{tileID:{canonical:i.canonical,wrap:i.wrap},width:o[2],height:o[3]}),a.setDirty(),e.setBaseState(),a.bindFramebuffer.set(n),a.viewport.set(o)}(e,i,r[0],a);let{isRenderingGlobe:n,projectionShaderVariant:o}=a.data,{terrain:s}=a,l=a.context,u=i.implementation,h=a.transform,c=h.getProjectionDataForCustomLayer(n),d={farZ:h.farZ,nearZ:h.nearZ,fov:h.fov*Math.PI/180,modelViewProjectionMatrix:h.modelViewProjectionMatrix,projectionMatrix:h.projectionMatrix,shaderData:{variantName:o.name,vertexShaderPrelude:`const float PI = 3.141592653589793;\nuniform mat4 u_projection_matrix;\n${o.prelude.vertexSource}`,define:o.define},defaultProjectionData:c,getProjectionData:e=>h.getProjectionData({overscaledTileID:new y_(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}),renderTerrainHeightMap:s&&"offscreen"===a.currentPass?e=>function(e,t,i){let r=e.context,a=r.gl,[n,o,s,l]=i.bounds;r.setDirty();let u=t.getHeightMapFramebuffer(i.texture);r.viewport.set([0,0,i.width,i.height]),r.clear({color:Wi.transparent});let h=e.useProgram("terrainHeight",null,!0);for(let c of t.tileManager.getRenderableTiles()){let i=t.getTerrainData(c.tileID);if(!i.tile?.dem)continue;let{canonical:u,wrap:d}=c.tileID,p=1/(1<<u.z),f=CT([(u.x*p+d-n)/(s-n),(u.y*p-o)/(l-o),p/(s-n),p/(l-o)]),m=t.getTerrainMesh(c.tileID,e.data.isRenderingGlobe);h.draw(r,a.TRIANGLES,dS.disabled,lS.disabled,wT.unblended,hS.disabled,f,i,null,"terrain",m.vertexBuffer,m.indexBuffer,m.segments)}u.colorAttachment.set(null)}(a,s,e):void 0},p=u.renderingMode?u.renderingMode:"2d";if("offscreen"===a.currentPass){let t=u.prerender;t&&(l.setCustomLayerDefaults(),l.setColorMode(a.colorModeForRenderPass()),t.call(u,l.gl,d),l.setDirty(),e.setBaseState())}else if("translucent"===a.currentPass){l.setCustomLayerDefaults(),l.setColorMode(a.colorModeForRenderPass()),l.setStencilMode(lS.disabled);let t="3d"===p?a.getDepthModeFor3D():a.getDepthModeForSublayer(0,dS.ReadOnly);l.setDepthMode(t),u.render(l.gl,d),l.setDirty(),e.setBaseState(),l.bindFramebuffer.set(null)}},debug:function(e,t,i,r){for(let a of i)eD(e,t,a,r)},debugPadding:function(e){let t=e.transform.padding;KS(e,e.transform.height-(t.top||0),3,qS),KS(e,t.bottom||0,3,WS),JS(e,t.left||0,3,HS),JS(e,e.transform.width-(t.right||0),3,XS);let i=e.transform.centerPoint;!function(e,t,i,r){QS(e,t-1,i-10,2,20,r),QS(e,t-10,i-1,20,2,r)}(e,i.x,e.transform.height-i.y,YS)},terrainDepth:function(e,t,i){let r=i.context,a=r.gl,n=i.transform,o=wT.unblended,s=new dS(a.LEQUAL,dS.ReadWrite,[0,1]),l=t.tileManager.getRenderableTiles(),u=i.useProgram("terrainDepth");r.bindFramebuffer.set(t.getFramebuffer().framebuffer),r.viewport.set([0,0,e.width/devicePixelRatio,e.height/devicePixelRatio]),r.clear({color:Wi.white,depth:1});for(let h of l){let e=t.getTerrainMesh(h.tileID,i.data.isRenderingGlobe),l=t.getTerrainData(h.tileID),c=n.getProjectionData({overscaledTileID:h.tileID,applyTerrainMatrix:!1,applyGlobeMatrix:!0}),d=ET(t.getSkirtLength(n.zoom));u.draw(r,a.TRIANGLES,s,lS.disabled,o,hS.backCCW,d,l,c,"terrain",e.vertexBuffer,e.indexBuffer,e.segments)}r.bindFramebuffer.set(null),r.viewport.set([0,0,e.width,e.height])}},iD=tx.maxOverzooming+tx.maxUnderzooming+1,rD=1/65536,aD={name:cb,define:hb,prelude:lb.projectionMercator},nD=class{constructor(e){this.currentLayer=0,this.opaquePassCutoff=1/0,this.depthRangeFor3D=[0,1],this.isRenderingToTexture=!1,this.nextStencilID=1,this.tileClippingMaskIDs={},this.transform=e.transform,this.terrain=e.terrain,this.data=e.data,this.context=e.context,this.programCache=e.programCache,this.currentPass=e.currentPass,this.projection=e.projection}getProjectionDataForTile(e,t={}){let i=this.transform.getProjectionData({overscaledTileID:e,aligned:t.aligned,applyGlobeMatrix:!this.isRenderingToTexture,applyTerrainMatrix:t.applyTerrainMatrix??!0});return this.isRenderingToTexture||(i.uniformBufferKey=t.aligned?`${e.key}/aligned`:e.key),i}getTerrainDataForTile(e){return this.isRenderingToTexture?null:this.terrain?.getTerrainData(e)??null}getMeshFromTileID(e,t,i,r){return this.projection.getMeshFromTileID(this.context,e,t,i,r)}useProgram(e,t,i=!1,r=[]){return this.programCache.getProgram({name:e,programConfiguration:t,projectionShaderVariant:i?aD:this.data.projectionShaderVariant,showOverdrawInspector:this.data.showOverdrawInspector,useTerrain:null!==this.terrain,defines:r})}colorModeForRenderPass(){let e=this.context.gl;if(this.data.showOverdrawInspector){let t=1/8;return new wT([e.CONSTANT_COLOR,e.ONE],new Wi(t,t,t,0),[!0,!0,!0,!0])}return"opaque"===this.currentPass?wT.unblended:wT.alphaBlended}getDepthModeForSublayer(e,t,i){if(!this.opaquePassEnabledForLayer())return dS.disabled;let r=1-((1+this.currentLayer)*iD+e)*rD;return new dS(i||this.context.gl.LEQUAL,t,[r,r])}getDepthModeFor3D(){return new dS(this.context.gl.LEQUAL,dS.ReadWrite,this.depthRangeFor3D)}setDepthRangeFor3D(e){this.depthRangeFor3D=[0,1-(e+2)*iD*rD]}opaquePassEnabledForLayer(){return this.currentLayer<this.opaquePassCutoff}clearStencil(){this.nextStencilID=1,this.currentStencilSource=void 0,this.context.clear({stencil:0})}invalidateTileClippingMasks(){this.currentStencilSource=void 0}renderTileClippingMasks(e,t){if(this.currentStencilSource===e.source||!e.isTileClipped()||!t?.length)return;this.currentStencilSource=e.source,this.nextStencilID+t.length>256&&this.clearStencil();let i=this.context;i.setColorMode(wT.disabled),i.setDepthMode(dS.disabled);let r={};for(let a of t)r[a.key]=this.nextStencilID++;this.data.useSubdivision&&this.renderTileMasks(r,t,!0),this.renderTileMasks(r,t,!1),this.tileClippingMaskIDs=r}renderTileMasks(e,t,i){let r=this.context,a=r.gl,n=this.useProgram("clippingMask");for(let o of t){let t=e[o.key],s=this.getTerrainDataForTile(o),l=this.getMeshFromTileID(o.canonical,i,!0,"stencil"),u=this.getProjectionDataForTile(o);n.draw(r,a.TRIANGLES,dS.disabled,new lS({func:a.ALWAYS,mask:0},t,255,a.KEEP,a.KEEP,a.REPLACE),wT.disabled,this.isRenderingToTexture?hS.disabled:hS.backCCW,null,s,u,"$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 lS({func:t.NOTEQUAL,mask:255},e,255,t.KEEP,t.KEEP,t.REPLACE)}stencilModeForClipping(e){let t=this.context.gl;return new lS({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 lS({func:t.GEQUAL,mask:255},i+this.nextStencilID,255,t.KEEP,t.KEEP,t.REPLACE);return this.nextStencilID+=a,[e,i]}return[{[r]:lS.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 lS({func:t.GREATER,mask:255},a+1+i,255,t.KEEP,t.KEEP,t.REPLACE),n[i+r]=new lS({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 lS({func:t.GREATER,mask:255},2,255,t.KEEP,t.KEEP,t.REPLACE)},{[r]:new lS({func:t.GREATER,mask:255},1,255,t.KEEP,t.KEEP,t.REPLACE)},i]}},oD=class e{constructor(e){this.drawFunctions=tD,this.context=new TT(e),this.programCache=new oS(this.context),this.layerOpacityFbo=null,this._tileTextures={},this._rttObjectRecyclePool=[],this._rttSharedFbo=null,this.terrainFacilitator={depthDirty:!0,matrix:x(/* @__PURE__ */new Float64Array(16)),renderTime:0},this.setup()}resize(e,t,i){this.width=Math.round(e*i),this.height=Math.round(t*i),this.context.viewport.set([0,0,this.width,this.height])}setup(){let e=this.context,t=new Pl;t.emplaceBack(0,0),t.emplaceBack(re,0),t.emplaceBack(0,re),t.emplaceBack(re,re),this.tileExtentBuffer=e.createVertexBuffer(t,G_.members),this.tileExtentSegments=Yl.simpleSegment(0,0,4,2);let i=new Pl;i.emplaceBack(0,0),i.emplaceBack(re,0),i.emplaceBack(0,re),i.emplaceBack(re,re),this.debugBuffer=e.createVertexBuffer(i,G_.members),this.debugSegments=Yl.simpleSegment(0,0,4,5);let r=new Il;r.emplaceBack(0,0,0,0),r.emplaceBack(re,0,re,0),r.emplaceBack(0,re,0,re),r.emplaceBack(re,re,re,re),this.rasterBoundsBuffer=e.createVertexBuffer(r,ww.members),this.rasterBoundsSegments=Yl.simpleSegment(0,0,4,2);let a=new Pl;a.emplaceBack(0,0),a.emplaceBack(1,0),a.emplaceBack(0,1),a.emplaceBack(1,1),this.viewportBuffer=e.createVertexBuffer(a,G_.members),this.viewportSegments=Yl.simpleSegment(0,0,4,2);let n=new Wl;n.emplaceBack(0),n.emplaceBack(1),n.emplaceBack(3),n.emplaceBack(2),n.emplaceBack(0),this.tileBorderIndexBuffer=e.createIndexBuffer(n);let o=new Zl;o.emplaceBack(1,0,2),o.emplaceBack(1,2,3),this.quadTriangleIndexBuffer=e.createIndexBuffer(o),this.tileExtentMesh=new $_(this.tileExtentBuffer,this.quadTriangleIndexBuffer,this.tileExtentSegments);let s=new Pl;s.emplaceBack(-1,-1),s.emplaceBack(1,-1),s.emplaceBack(1,1),s.emplaceBack(-1,1);let l=new Zl;l.emplaceBack(0,1,2),l.emplaceBack(0,2,3),this.skyMesh=new $_(e.createVertexBuffer(s,G_.members),e.createIndexBuffer(l),Yl.simpleSegment(0,0,s.length,l.length))}_renderTilesDepthBuffer(e){let t=this.context,i=t.gl,r=e.transform,a=e.useProgram("depth"),n=e.getDepthModeFor3D(),o=Wv(r,{tileSize:r.tileSize});for(let s of o){let r=e.getTerrainDataForTile(s),o=e.getMeshFromTileID(s.canonical,!0,!0,"raster"),l=e.getProjectionDataForTile(s);a.draw(t,i.TRIANGLES,n,lS.disabled,wT.disabled,hS.backCCW,null,r,l,"$clipping",o.vertexBuffer,o.indexBuffer,o.segments)}}render(e,t,i){if(this.context.gl.isContextLost())return;let r=new nD({transform:t,terrain:e.map.terrain??null,data:i,context:this.context,programCache:this.programCache,currentPass:"offscreen",projection:e.projection});this.lineAtlas=e.lineAtlas,this.patternAtlas=e.patternAtlas,function(e,t,i){let r=e.pending,a=e.context.gl;r[yT.u_units_to_pixels]=1/t.pixelsToGLUnits[0],r[yT.u_units_to_pixels+1]=1/t.pixelsToGLUnits[1],r[yT.u_world_size]=a.drawingBufferWidth,r[yT.u_world_size+1]=a.drawingBufferHeight,r[yT.u_camera_to_center_distance]=t.cameraToCenterDistance,r[yT.u_symbol_fade_change]=i.fadeDuration?i.symbolFadeChange:1,r[yT.u_aspect_ratio]=t.width/t.height,r[yT.u_device_pixel_ratio]=i.pixelRatio,r[yT.u_viewport_size]=t.width,r[yT.u_viewport_size+1]=t.height,r[yT.u_pixel_extrude_scale]=1/t.width,r[yT.u_pixel_extrude_scale+1]=1/t.height,r[yT.u_pitch]=t.pitch/360*2*Math.PI,e.upload()}(this.context.frameUniformBuffer,t,i),e.imageManager.beginFrame(),function(e){e.freeProjectionUniformBuffers.push(...e.keyedProjectionUniformBuffers.values()),e.keyedProjectionUniformBuffers.clear()}(this.context);let a=e._order,n=e.tileManagers,o={},s={},l={};for(let h in n){let e=n[h];e.used&&e.prepare(this.context),o[h]=e.getVisibleCoordinates(!1),s[h]=o[h].slice().reverse(),l[h]=e.getVisibleCoordinates(!0).reverse()}r.opaquePassCutoff=1/0;for(let h=0;h<a.length;h++){let t=a[h];if(e._layers[t].is3D()){r.opaquePassCutoff=h;break}}this.maybeDrawDepth(r),this.renderToTexture&&(this.renderToTexture.prepareForRender(e,t.zoom,i.moving),r.opaquePassCutoff=0),r.currentPass="offscreen";for(let h of a){let i=e._layers[h];if(!i.hasOffscreenPass()||i.isHidden(t.zoom))continue;let a=s[i.source];("custom"===i.type||a.length)&&this.renderLayer(this,n[i.source],i,a,r)}if(this.context.viewport.set([0,0,this.width,this.height]),this.context.bindFramebuffer.set(null),this.context.clear({color:i.showOverdrawInspector?Wi.black:Wi.transparent,depth:1}),r.clearStencil(),i.sky&&this.drawFunctions.sky(this.skyMesh,r),r.setDepthRangeFor3D(e._order.length),!this.renderToTexture)for(r.currentPass="opaque",r.currentLayer=a.length-1;r.currentLayer>=0;r.currentLayer--){let i=e._layers[a[r.currentLayer]];if(i.isHidden(t.zoom))continue;let s=n[i.source],l=o[i.source];r.renderTileClippingMasks(i,l),this.renderLayer(this,s,i,l,r)}r.currentPass="translucent";let u=!1;for(r.currentLayer=0;r.currentLayer<a.length;r.currentLayer++){let h=e._layers[a[r.currentLayer]];if(h.isHidden(t.zoom))continue;let c=n[h.source];if(this.renderToTexture?.renderLayer(h,e,r))continue;!r.opaquePassEnabledForLayer()&&!u&&(u=!0,i.isRenderingGlobe&&!r.terrain&&this._renderTilesDepthBuffer(r));let d=("symbol"===h.type?l:s)[h.source];r.renderTileClippingMasks(h,o[h.source]),this.renderLayer(this,c,h,d,r)}if(i.isRenderingGlobe&&this.drawFunctions.atmosphere(this.skyMesh,r),i.showTileBoundaries){let i=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),o=e=>{(!i||i.getSource().maxzoom<e.getSource().maxzoom)&&(i=e)};for(let s of a)o(s);if(!i)for(let s of n)o(s);return i}(e,t.zoom);i&&this.drawFunctions.debug(this,i,i.getVisibleCoordinates(),r)}i.showPadding&&this.drawFunctions.debugPadding(r),this.renderToTexture&&!i.moving&&this.clearRTTPool(),this.context.setDefault()}markTerrainDepthDirty(){this.terrainFacilitator.depthDirty=!0}maybeDrawDepth(e){if(!e.data.projectionShaderVariant||!e.terrain)return;let t=this.terrainFacilitator.matrix,i=e.transform.modelViewProjectionMatrix,r=this.terrainFacilitator.depthDirty;r||=!function(e,t){var i=e[0],r=e[1],a=e[2],n=e[3],o=e[4],s=e[5],l=e[6],u=e[7],h=e[8],c=e[9],d=e[10],p=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],D=t[7],E=t[8],C=t[9],P=t[10],A=t[11],I=t[12],M=t[13],F=t[14],z=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(o-w)<=1e-6*Math.max(1,Math.abs(o),Math.abs(w))&&Math.abs(s-T)<=1e-6*Math.max(1,Math.abs(s),Math.abs(T))&&Math.abs(l-S)<=1e-6*Math.max(1,Math.abs(l),Math.abs(S))&&Math.abs(u-D)<=1e-6*Math.max(1,Math.abs(u),Math.abs(D))&&Math.abs(h-E)<=1e-6*Math.max(1,Math.abs(h),Math.abs(E))&&Math.abs(c-C)<=1e-6*Math.max(1,Math.abs(c),Math.abs(C))&&Math.abs(d-P)<=1e-6*Math.max(1,Math.abs(d),Math.abs(P))&&Math.abs(p-A)<=1e-6*Math.max(1,Math.abs(p),Math.abs(A))&&Math.abs(f-I)<=1e-6*Math.max(1,Math.abs(f),Math.abs(I))&&Math.abs(m-M)<=1e-6*Math.max(1,Math.abs(m),Math.abs(M))&&Math.abs(_-F)<=1e-6*Math.max(1,Math.abs(_),Math.abs(F))&&Math.abs(g-z)<=1e-6*Math.max(1,Math.abs(g),Math.abs(z))}(t,i),r||=e.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=dt(),this.terrainFacilitator.depthDirty=!1,this.drawFunctions.terrainDepth(this,e.terrain,e))}renderLayer(e,t,i,r,a){if(i.isHidden(a.transform.zoom)||"background"!==i.type&&"custom"!==i.type&&!(r||[]).length)return;let n=this.drawFunctions;Em(i)?n.symbol(e,t,i,r,a):(e=>"circle"===e.type)(i)?n.circle(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(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):js(i)?n.raster(t,i,r,a):(e=>"background"===e.type)(i)?n.background(e,t,i,r,a):Im(i)&&n.custom(e,t,i,r,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&&(i.texture.update({width:e,height:e,data:null},{premultiply:!1,useMipmap:!0}),i.texture.bind(t.LINEAR,t.CLAMP_TO_EDGE,t.LINEAR_MIPMAP_LINEAR),this.context.extTextureFilterAnisotropic&&t.texParameterf(t.TEXTURE_2D,this.context.extTextureFilterAnisotropic.TEXTURE_MAX_ANISOTROPY_EXT,this.context.extTextureFilterAnisotropicMax),i.size=e),i;let r=new Fh(this.context,{width:e,height:e,data:null},t.RGBA,{premultiply:!1,useMipmap:!0});return r.bind(t.LINEAR,t.CLAMP_TO_EDGE,t.LINEAR_MIPMAP_LINEAR),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)}clearRTTPool(){for(let e of this._rttObjectRecyclePool)e.texture.destroy();this._rttObjectRecyclePool.length=0}destroyRTTResources(){if(this.clearRTTPool(),!this._rttSharedFbo)return;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}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 Fh(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={}}this.destroyRTTResources(),this.layerOpacityFbo?.destroy(),this.layerOpacityFbo=null,this.tileExtentBuffer&&this.tileExtentBuffer.destroy(),this.debugBuffer&&this.debugBuffer.destroy(),this.rasterBoundsBuffer&&this.rasterBoundsBuffer.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.skyMesh?.destroy(),this.skyMesh=null,this.debugOverlayTexture&&this.debugOverlayTexture.destroy(),this.context.destroy(),this.programCache.destroy(),this.context&&this.context.setDefault()}overLimit(){let{drawingBufferWidth:e,drawingBufferHeight:t}=this.context.gl;return this.width!==e||this.height!==t}},sD=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 lD(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 uD=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=lD(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=function(e,t){if(e.wraps)return 360;let i=t.lat>0?-1e-4:xd,r=e.worldFromLngLat(t.lng,t.lat),a=e.worldFromLngLat(t.lng+xd,t.lat),n=e.worldFromLngLat(t.lng,t.lat+i),o=Math.max(Math.hypot(a.x-r.x,a.y-r.y),Math.hypot(n.x-r.x,n.y-r.y));return xd/o}(this._map._camera.transform.worldCoordinateHelper,t),a=10**Math.ceil((i*Math.LN2+Math.log(512/r/.5))/Math.LN10),n=Math.round(t.lng*a)/a,o=Math.round(t.lat*a)/a,s=this._map.getBearing(),l=this._map.getPitch(),u="";if(u+=e?`/${n}/${o}/${i}`:`${i}/${o}/${n}`,(s||l)&&(u+="/"+Math.round(10*s)/10),l&&(u+=`/${Math.round(l)}`),this._hashName){let e=this._getHashParams();return e.set(this._hashName,u),`#${decodeURIComponent(e.toString()).replace(/=&/g,"&").replace(/=$/g,"")}`}return`#${u}`}_isValidHash(e){if(e.length<3||e.some(e=>isNaN(+e)))return!1;try{new Kc(+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()}},hD={linearity:.3,easing:we(0,0,.3,1)},cD=Ee({deceleration:2500,maxSpeed:1400},hD),dD=Ee({deceleration:20,maxSpeed:1400},hD),pD=Ee({deceleration:1e3,maxSpeed:360},hD),fD=Ee({deceleration:1e3,maxSpeed:90},hD),mD=Ee({deceleration:1e3,maxSpeed:360},hD),_D=class{constructor(e){this._map=e,this.clear()}clear(){this._inertiaBuffer=[]}record(e){this._drainInertiaBuffer(),this._inertiaBuffer.push({time:dt(),settings:e})}_drainInertiaBuffer(){let e=this._inertiaBuffer,t=dt();for(;e.length>0&&t-e[0].time>160;)e.shift()}_getVelocityEntries(){let e=this._inertiaBuffer,t=dt()-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 d(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=dt()-t[0].time,a={};if(i.pan.mag()){let t=yD(i.pan.mag(),r,Ee({},cD,e||{})),n=i.pan.mult(t.amount/i.pan.mag()),o=this._map._camera.cameraHelper.handlePanInertia(n,this._map._camera.transform);a.center=o.easingCenter,a.offset=o.easingOffset,gD(a,t)}if(i.zoom){let e=yD(i.zoom,r,dD);a.zoom=Fe(this._map.getZoom()+e.amount,this._map.getZoomSnap(),e.amount),gD(a,e)}if(i.bearing){let e=yD(i.bearing,r,pD);a.bearing=this._map.getBearing()+Se(e.amount,-179,179),gD(a,e)}if(i.pitch){let e=yD(i.pitch,r,fD);a.pitch=this._map.getPitch()+e.amount,gD(a,e)}if(i.roll){let e=yD(i.roll,r,mD);a.roll=this._map.getRoll()+Se(e.amount,-179,179),gD(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(),Ee(a,{noMoveStart:!0})}};function gD(e,t){(!e.duration||e.duration<t.duration)&&(e.duration=t.duration,e.easing=t.easing)}function yD(e,t,i){let{maxSpeed:r,linearity:a,deceleration:n}=i,o=Se(e*a/(t/1e3),-r,r),s=Math.abs(o)/(n*a);return{easing:i.easing,duration:1e3*s,amount:s/2*o}}var vD=class{constructor(e,t){this._map=e,this._clickTolerance=t.clickTolerance}reset(){delete this._mousedownPos}wheel(e){return this._firePreventable(new ns(this._map,e))}mousedown(e,t){return this._mousedownPos=t,this._firePreventable(new rs(e.type,this._map,e))}mouseup(e){this._map.fire(new rs(e.type,this._map,e))}click(e,t){this._mousedownPos&&this._mousedownPos.dist(t)>=this._clickTolerance||this._map.fire(new rs(e.type,this._map,e))}dblclick(e){return this._firePreventable(new rs(e.type,this._map,e))}mouseover(e){this._map.fire(new rs(e.type,this._map,e))}mouseout(e){this._map.fire(new rs(e.type,this._map,e))}touchstart(e){return this._firePreventable(new as(e.type,this._map,e))}touchmove(e){this._map.fire(new as(e.type,this._map,e))}touchend(e){this._map.fire(new as(e.type,this._map,e))}touchcancel(e){this._map.fire(new as(e.type,this._map,e))}_firePreventable(e){if(this._map.fire(e),e.defaultPrevented)return{}}isEnabled(){return!0}isActive(){return!1}enable(){}disable(){}},xD=class{constructor(e,t){this._map=e,this._clickTolerance=t.clickTolerance}reset(){this._delayContextMenu=!1,this._ignoreContextMenu=!0,delete this._contextMenuEvent,this._clearLongPress(),this._touchActive=!1}mousemove(e){this._map.fire(new rs(e.type,this._map,e))}mousedown(){this._delayContextMenu=!0,this._ignoreContextMenu=!1}mouseup(){this._delayContextMenu=!1,this._contextMenuEvent&&(this._map.fire(new rs("contextmenu",this._map,this._contextMenuEvent)),delete this._contextMenuEvent)}touchstart(e,t,i){if(this._clearLongPress(),this._touchActive=i.length>0,1!==i.length)return;this._longPressStart=t[0];let r=i[0];this._longPressTimer=setTimeout(()=>{this._longPressTimer=void 0;let e=new MouseEvent("contextmenu",{clientX:r.clientX,clientY:r.clientY,button:2,bubbles:!0,cancelable:!0});this._map.fire(new rs("contextmenu",this._map,e))},500)}touchmove(e,t,i){this._longPressTimer&&(1!==i.length||!this._longPressStart||t[0].dist(this._longPressStart)>this._clickTolerance)&&this._clearLongPress()}touchend(){this._touchActive=!1,this._clearLongPress()}touchcancel(){this._touchActive=!1,this._clearLongPress()}_clearLongPress(){this._longPressTimer&&=void clearTimeout(this._longPressTimer),this._longPressStart=void 0}contextmenu(e){this._touchActive?e.preventDefault():(this._delayContextMenu?this._contextMenuEvent=e:this._ignoreContextMenu||this._map.fire(new rs(e.type,this._map,e)),this._map.listens("contextmenu")&&e.preventDefault())}isEnabled(){return!0}isActive(){return!1}enable(){}disable(){}},bD=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&&(wt.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=wt.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),o=Math.min(r.y,i.y),s=Math.max(r.y,i.y);this._box.style.transform=`translate(${a}px,${o}px)`,this._box.style.width=n-a+"px",this._box.style.height=s-o+"px"}mouseupWindow(e,t){if(!this._active||0!==e.button)return;let i=this._startPos,r=t;if(this.reset(),wt.suppressClick(),i.x!==r.x||i.y!==r.y)return this._map.fire(new os("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),wt.enableDrag(),delete this._startPos,delete this._lastPos}_fireEvent(e,t){return this._map.fire(new os(e,{originalEvent:t}))}};function wD(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 TD=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 d(0,0);for(let i of e)t._add(i);return t.div(e.length)}(t),this.touches=wD(i,t)))}touchmove(e,t,i){if(this.aborted||!this.centroid)return;let r=wD(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}}},SD=class{constructor(e){this.singleTap=new TD(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}}},DD=class{constructor(e,t){this._tr=t,this._zoomIn=new SD({numTouches:1,numTaps:2}),this._zoomOut=new SD({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:Fe(n.zoom+1,t.getZoomSnap()),around:n.transform.isPointOnMapSurface(r)?n.unproject(r):void 0},{originalEvent:e})}):a?(this._active=!0,e.preventDefault(),setTimeout(()=>this.reset(),0),{cameraAnimation:t=>t.easeTo({duration:300,zoom:Fe(n.zoom-1,t.getZoomSnap()),around:n.transform.isPointOnMapSurface(a)?n.unproject(a):void 0},{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}},ED=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,delete this._startPoint,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._startPoint=Array.isArray(t)?t[0]:t,this._lastPoint=this._startPoint,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,this._startPoint))}dragEnd(e){this.isEnabled()&&this._lastPoint&&this._moveStateManager.isValidEndEvent(e)&&(this._moved&&wt.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}},CD={0:1,2:2},PD=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=CD[t];return void 0===e.buttons||(e.buttons&i)!==i}(e,this._eventButton)}isValidEndEvent(e){return e.button===this._eventButton}},AD=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)}},ID=class{constructor(e=new PD({checkCorrectEvent:()=>!0}),t=new AD){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))}};function MD(e,t,i){return"center"!==t&&(e.bearingDelta||e.pitchDelta||e.rollDelta)?{...e,around:i}:e}var FD=e=>{e.mousedown=e.dragStart,e.mousemoveWindow=e.dragMove,e.mouseup=e.dragEnd,e.contextmenu=e=>{e.preventDefault()}};function zD({enable:e,clickTolerance:t,minPixelCenterThreshold:i=100,rotateSpeed:r=.8},a,n,o){return new ED({clickTolerance:t,move:(e,t,s)=>{if("pointer"===n?.())return MD({bearingDelta:(t.x-e.x)*r},"pointer",s);let l=a(),u="circular"===(o?.()??"circular");if(u&&Math.abs(l.y-e.y)>i)return{bearingDelta:Xe(new d(e.x,t.y),t,l)};let h=(t.x-e.x)*r;return u&&t.y<l.y&&(h=-h),{bearingDelta:h}},moveStateManager:new PD({checkCorrectEvent:e=>0===e.button&&e.ctrlKey||2===e.button&&!e.ctrlKey}),enable:e,assignEvents:FD})}var kD=class{constructor(e,t){this._clickTolerance=e.clickTolerance||1,this._map=t,this.reset()}reset(){this._active=!1,this._touches={},this._sum=new d(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){if(!this._shouldBePrevented(i.length))return e.preventDefault(),this._calculateTransform(e,t,i);this._map.cooperativeGestures.notifyGestureBlocked("touch_pan",e)}}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=wD(i,t),a=new d(0,0),n=new d(0,0),o=0;for(let l in r){let e=r[l],t=this._touches[l];t&&(a._add(e),n._add(e.sub(t)),o++,r[l]=e)}if(this._touches=r,this._shouldBePrevented(o)||!n.mag())return;let s=n.div(o);return this._sum._add(s),this._sum.mag()<this._clickTolerance?void 0:{around:a.div(o),panDelta:s}}enable(){this._enabled=!0}disable(){this._enabled=!1,this.reset()}isEnabled(){return this._enabled}isActive(){return this._active}},RD=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=LD(i,t,r),o=LD(i,t,a);if(!n||!o)return;let s=this._aroundCenter?null:n.add(o).div(2);return this._move([n,o],s,e)}touchend(e,t,i){if(!this._firstTwoTouches)return;let[r,a]=this._firstTwoTouches,n=LD(i,t,r),o=LD(i,t,a);n&&o||(this._active&&wt.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 LD(e,t,i){for(let r=0;r<e.length;r++)if(e[r].identifier===i)return t[r]}function BD(e,t){return Math.log(e/t)/Math.LN2}var OD=class extends RD{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(BD(this._distance,this._startDistance))<this._zoomThreshold))return this._active=!0,{zoomDelta:BD(this._distance,i)*this._zoomRate,pinchAround:t}}};function jD(e,t){return 180*e.angleWith(t)/Math.PI}var VD=class extends RD{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:jD(this._vector,r),pinchAround:t}}_isBelowThreshold(e){this._minDiameter=Math.min(this._minDiameter,e.mag());let t=25/(Math.PI*this._minDiameter)*360,i=jD(e,this._startVector);return Math.abs(i)<t}};function ND(e){return Math.abs(e.y)>Math.abs(e.x)}var UD=class extends RD{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,ND(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 ND(e)&&ND(t)&&n}},$D={panStep:100,bearingStep:15,pitchStep:10},GD=class{constructor(e,t){this._tr=t;let i=$D;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:o=>{let s=this._tr;o.easeTo({duration:300,easeId:"keyboardHandler",easing:ZD,zoom:t?Fe(s.zoom+t*(e.shiftKey?2:1),o.getZoomSnap()):s.zoom,bearing:s.bearing+i*this._bearingStep,pitch:s.pitch+r*this._pitchStep,offset:[-a*this._panStep,-n*this._panStep],center:s.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 ZD(e){return e*(2-e)}var qD=4.000244140625,WD=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=dt(),r=i-(this._lastWheelEventTime||0);this._lastWheelEventTime=i,0!==t&&t%qD==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=wt.mousePos(this._map.getCanvas(),e),i=this._tr;this._aroundPoint=this._aroundCenter?i.transform.locationToScreenPoint(Kc.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)>qD?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?Ie(this._targetZoom):e.scale,a=e.applyConstrain(e.getCameraLngLat(),Me(r*i)).zoom,n=this._map.getZoomSnap();if("wheel"===this._type&&n>0){let t=Fe(e.zoom,n);this._targetZoom=Fe(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=dt()-this._lastWheelEventTime,o=Math.min((e+5)/200,1),s=a(o);t=gr.number(r,i,s),o<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=Te;if(this._prevEase){let e=this._prevEase,i=(dt()-e.start)/e.duration,r=e.easing(i+.01)-e.easing(i),a=.27/Math.sqrt(r*r+1e-4)*.01;t=we(a,Math.sqrt(.0729-a*a),.25,1)}return this._prevEase={start:dt(),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)}},HD=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()}},XD=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:Fe(this._tr.zoom+(e.shiftKey?-1:1),i.getZoomSnap()),around:this._tr.transform.isPointOnMapSurface(t)?this._tr.unproject(t):void 0},{originalEvent:e})}}}enable(){this._enabled=!0}disable(){this._enabled=!1,this.reset()}isEnabled(){return this._enabled}isActive(){return this._active}},YD=class{constructor(){this._tap=new SD({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}},KD=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()}},JD=class{constructor(e,t,i,r){this._pitchWithRotate=e.pitchWithRotate,this._rollEnabled=e.rollEnabled,this._mouseRotate=t,this._mousePitch=i,this._mouseRoll=r;let{aroundCenter:a=!0}=e;this._defaultMovement=a?"circular":"linear",this.around="center",this.movement=this._defaultMovement}enable(e){let t="object"==typeof e?e:{};this.around=t.around??"center",this.movement="pointer"===t.around?"linear":t.movement??this._defaultMovement,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()}},QD=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()}},eE=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=wt.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 Jo("cooperativegestureprevented",{gestureType:e,originalEvent:t})),this._container.classList.add("maplibregl-show"),setTimeout(()=>{this._container.classList.remove("maplibregl-show")},100))}},tE=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(d.convert(e),this._camera.terrain)}},iE=e=>e.zoom||e.drag||e.roll||e.pitch||e.rotate,rE=class extends Lt{};function aE(e){return e.panDelta?.mag()||e.zoomDelta||e.bearingDelta||e.pitchDelta||e.rollDelta}var nE=class{get _ownerDocument(){return this._el?.ownerDocument||document}get _ownerWindow(){return this._el?.ownerDocument?.defaultView||window}constructor(e,t,i){this._terrainGesture={inFlight:!1,anchorElevation:null,anchorCenterElevation:null},this._rotationPivot=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:u,allowed:h}of this._handlers){if(!u.isEnabled())continue;let o;if(this._blockedByActive(n,h,l))u.reset();else if(u[t||e.type]){if(tt(e,t||e.type)){let i=wt.mousePos(this._map.getCanvas(),e);o=u[t||e.type](e,i)}else if(et(e,t||e.type)){let i=e.touches,r=this._getMapTouches(i),a=wt.touchPos(this._map.getCanvas(),r);o=u[t||e.type](e,a,r)}else it(t||e.type)||(o=u[t||e.type](e));this.mergeHandlerResult(r,a,o,l,i),o?.needsRenderFrame&&this._triggerRenderFrame()}(o||u.isActive())&&(n[l]=u)}let o={};for(let l in this._previousActiveHandlers)n[l]||(o[l]=i);this._previousActiveHandlers=n,(Object.keys(o).length||aE(r))&&(this._changes.push([r,a,o]),this._triggerRenderFrame()),(Object.keys(n).length||aE(r))&&this._camera.stop(!0),this._updatingCamera=!1;let{cameraAnimation:s}=r;s&&(this._inertia.clear(),this._fireEvents({},{},!0),this._changes=[],s(this._map))},this._map=e,this._camera=t,this._transformProvider=new tE(this._camera),this._el=this._map.getCanvasContainer(),this._handlers=[],this._handlersById={},this._changes=[],this._inertia=new _D(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,o]of this._listeners)a.addEventListener(n,a===this._ownerDocument?this.handleWindowEvent:this.handleEvent,o)}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 vD(t,e));let r=t.boxZoom=new bD(t,e,this._transformProvider);this._add("boxZoom",r),e.interactive&&e.boxZoom&&r.enable();let a=t.cooperativeGestures=new eE(t,e.cooperativeGestures);this._add("cooperativeGestures",a),e.cooperativeGestures&&a.enable();let n=new DD(t,this._transformProvider),o=new XD(t,this._transformProvider);t.doubleClickZoom=new HD(o,n),this._add("tapZoom",n),this._add("clickZoom",o),e.interactive&&e.doubleClickZoom&&t.doubleClickZoom.enable();let s=new YD;this._add("tapDragZoom",s);let l=t.touchPitch=new UD(t);this._add("touchPitch",l),e.interactive&&e.touchPitch&&t.touchPitch.enable(e.touchPitch);let u=()=>this._camera.transform.centerPoint,h=()=>t.dragRotate.around,c=zD(e,u,h,()=>t.dragRotate.movement),d=function({enable:e,clickTolerance:t,pitchSpeed:i=-.5},r){return new ED({clickTolerance:t,move:(e,t,a)=>MD({pitchDelta:(t.y-e.y)*i},r?.()??"center",a),moveStateManager:new PD({checkCorrectEvent:e=>0===e.button&&e.ctrlKey||2===e.button}),enable:e,assignEvents:FD})}(e,h),p=function({enable:e,clickTolerance:t,rollDegreesPerPixelMoved:i=.3},r,a){return new ED({clickTolerance:t,move:(e,t,n)=>{let o=r(),s=(t.x-e.x)*i;return t.y<o.y&&(s=-s),MD({rollDelta:s},a?.()??"center",n)},moveStateManager:new PD({checkCorrectEvent:e=>2===e.button&&e.ctrlKey}),enable:e,assignEvents:FD})}(e,u,h);t.dragRotate=new JD(e,c,d,p),this._add("mouseRotate",c,["mousePitch"]),this._add("mousePitch",d,["mouseRotate","mouseRoll"]),this._add("mouseRoll",p,["mousePitch"]),e.interactive&&e.dragRotate&&t.dragRotate.enable(e.dragRotate);let f=function({enable:e,clickTolerance:t}){return new ED({clickTolerance:t,move:(e,t)=>({around:t,panDelta:t.sub(e)}),activateOnStart:!0,moveStateManager:new PD({checkCorrectEvent:e=>0===e.button&&!e.ctrlKey}),enable:e,assignEvents:FD})}(e),m=new kD(e,t);t.dragPan=new KD(i,f,m),this._add("mousePan",f),this._add("touchPan",m,["touchZoom","touchRotate"]),e.interactive&&e.dragPan&&t.dragPan.enable(e.dragPan);let _=new VD,g=new OD;t.touchZoomRotate=new QD(i,g,_,s),this._add("touchRotate",_,["touchPan","touchZoom"]),this._add("touchZoom",g,["touchPan","touchRotate"]),e.interactive&&e.touchZoomRotate&&t.touchZoomRotate.enable(e.touchZoomRotate),this._add("blockableMapEvent",new xD(t,e),["touchPan"]);let y=t.scrollZoom=new WD(t,()=>this._triggerRenderFrame(),this._transformProvider);this._add("scrollZoom",y,["mousePan"]),e.interactive&&e.scrollZoom&&t.scrollZoom.enable(e.scrollZoom);let v=t.keyboard=new GD(t,this._transformProvider);this._add("keyboard",v),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!!iE(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;Ee(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 d(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),Ee(t,a),Ee(i,n);this._updateMapTransform(e,t,i),this._changes=[]}_updateMapTransform(e,t,i){let r=this._map.terrain;if(!aE(e))return void this._fireEvents(t,i,!0);let a=this._camera.getTransformForUpdate();if(this._camera.stop(!0),this._turnsAroundPivot(e,t))return this._orbitRotationPivot(a,e,r),void this._commitFrame(a,e,t,i);let{panDelta:n,zoomDelta:o,bearingDelta:s,pitchDelta:l,rollDelta:u}=e;o>0&&this._terrainGesture.inFlight&&this._camera.moveCenterOntoTerrain(a,o);let{around:h,aroundOnSurface:c}=this._resolveAround(e,r,a),d=r?this._terrainGestureElevation(r,h,c,a,t):void 0,p={panDelta:n,zoomDelta:o,rollDelta:u,pitchDelta:l,bearingDelta:s,around:h,aroundElevation:d};this._camera.cameraHelper.useGlobeControls&&!a.isPointOnMapSurface(h)&&(h=a.centerPoint);let f=this._computePreZoomAroundLoc(a,h,n,d);this._handleMapControls({terrain:r,tr:a,deltasForHelper:p,preZoomAroundLoc:f,combinedEventsInProgress:t,panDelta:n}),this._commitFrame(a,e,t,i)}_commitFrame(e,t,i,r){this._camera.applyUpdatedTransform(e),this._map._update(),t.noInertia||this._inertia.record(t),this._fireEvents(i,r,!0)}_turnsAroundPivot(e,t){return!!e.around&&!t.drag&&!t.zoom}_orbitRotationPivot(e,t,i){i&&!this._terrainGesture.inFlight&&(this._terrainGesture.inFlight=!0,this._camera.holdElevation(e,"gesture"));let{panDelta:r,zoomDelta:a,bearingDelta:n,pitchDelta:o,rollDelta:s,around:l}=t;this._rotationPivot??=this._camera.captureRotationPivot(e,l),this._camera.orbitRotationPivot(e,this._rotationPivot,{panDelta:r,zoomDelta:a,bearingDelta:n,pitchDelta:o,rollDelta:s,around:l})||(this._rotationPivot=null)}_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._terrainGesture.anchorCenterElevation!==r.elevation&&(a.drag||a.zoom)){let i=r.screenTerrainPointToMercatorCoordinate(t,e);this._terrainGesture.anchorElevation=i?i.z:void 0,this._terrainGesture.anchorCenterElevation=r.elevation}let n=this._terrainGesture.anchorElevation;return null==n||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 o=this._camera.cameraHelper;o.handleMapControlsRollPitchBearingZoom(i,t),e||o.useGlobeControls||t.isPointOnMapSurface(i.around)?e?this._terrainGesture.inFlight?!o.useGlobeControls&&void 0===i.aroundElevation&&a.drag&&n?t.setCenter(t.screenPointToLocation(t.centerPoint.sub(n))):o.handleMapControlsPan(i,t,r):(this._terrainGesture.inFlight=!0,this._camera.holdElevation(t,"gesture"),o.handleMapControlsPan(i,t,r)):o.handleMapControlsPan(i,t,r):n&&t.setCenter(t.screenPointToLocation(t.centerPoint.sub(n)))}_fireEvents(e,t,i){let r=iE(this._eventsInProgress),a=iE(e),n={};for(let h in e){let{originalEvent:t}=e[h];this._eventsInProgress[h]||(n[`${h}start`]=t),this._eventsInProgress[h]=e[h]}!r&&a&&this._fireEvent("movestart",a.originalEvent);for(let h in n)this._fireEvent(h,n[h]);a&&this._fireEvent("move",a.originalEvent);for(let h in e){let{originalEvent:t}=e[h];this._fireEvent(h,t)}let o,s={};for(let h in this._eventsInProgress){let{handlerName:e,originalEvent:i}=this._eventsInProgress[h];this._handlersById[e].isActive()||(delete this._eventsInProgress[h],o=t[e]||i,s[`${h}end`]=o)}for(let h in s)this._fireEvent(h,s[h]);let l=iE(this._eventsInProgress),u=(r||a)&&!l;if(u&&this._terrainGesture.inFlight){let e=this._camera.releaseElevation();this._terrainGesture={inFlight:!1,anchorElevation:null,anchorCenterElevation:null},this._camera.applyTransformChange(t=>{this._map.getCenterClampedToGround()&&(this._map.terrain?this._camera.putCenterBackOnTerrain(t,this._map.terrain,e):t.setElevation(0))})}if(i&&u){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&&ht.prefersReducedMotion?(this._fireEvent("moveend",o),t(this._map.getBearing())&&this._map.resetNorth()):(t(e.bearing||this._map.getBearing())&&(e.bearing=0),e.freezeElevation=!0,this._map.easeTo(e,{originalEvent:o})),this._updatingCamera=!1}u&&(this._rotationPivot=null)}_fireEvent(e,t){this._camera.fire(new Qo(e,t?{originalEvent:t}:{}))}_requestFrame(){return this._map.triggerRepaint(),this._map._renderTaskQueue.add(e=>{delete this._frameId,this.handleEvent(new rE("renderFrame",{timeStamp:e})),this._applyChanges()})}_triggerRenderFrame(){void 0===this._frameId&&(this._frameId=this._requestFrame())}},oE=class{constructor(e,t,i){this.holder=e,this.lift=null,this._terrainChanged=!1,this._dem=t?"awaiting":"loaded",this.keepsTerrainBelowMaxZoomForCenter=i}get tookDem(){return"taken"===this._dem}noteTerrainChange(){this._terrainChanged=!0}take(e,t){let i=!1;if(this._terrainChanged&&(this._terrainChanged=!1,"loaded"!==t.getElevationAndDEMStateForLngLat(e.center,e.tileZoom).demState&&(e.setElevation(0),this._dem="awaiting",i=!0)),"awaiting"!==this._dem)return i;let r=t.getDrawnElevationForLngLat(e.center,!0);if(void 0!==r)return e.setElevation(r),this._dem="taken",!0;let a=t.getDrawnElevationForLngLat(e.center);return void 0===a||a===e.elevation?i:(e.setElevation(a),!0)}},sE=class extends Ot{constructor(e){super(),this._elevationHold=null,this._renderFrameCallback=()=>{let e=Math.min((dt()-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=Mb(),this.cameraHelper=new jb,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})}setTerrain(e){this.terrain=e,e&&this._elevationHold?.noteTerrainChange(),this.applyTerrainChange()}migrateProjection(e,t){if(e.apply(this.transform,!0),this.transform=e,this.cameraHelper=t,this._requestedCameraState){let t=e.clone();t.apply(this._requestedCameraState,!0),this._requestedCameraState=t}}getCenter(){return new Kc(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=d.convert(e).mult(-1),this.panTo(this.transform.center,Ee({offset:e},t),i)}panTo(e,t,i){return this.easeTo(Ee({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(Ee({zoom:e},t),i)}zoomIn(e,t){return this.zoomTo(Fe(this.getZoom()+1,this._zoomSnap),e,t),this}zoomOut(e,t){return this.zoomTo(Fe(this.getZoom()-1,this._zoomSnap),e,t),this}getVerticalFieldOfView(){return this.transform.fov}setVerticalFieldOfView(e,t){return e!=this.transform.fov&&(this.applyTransformChange(t=>t.setFov(e)),this.fire(new Qo("movestart",t)).fire(new Qo("move",t)).fire(new Qo("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(Ee({bearing:e},t),i)}resetNorth(e,t){return this.rotateTo(0,Ee({duration:1e3},e),t),this}resetNorthPitch(e,t){return this.easeTo(Ee({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=c_.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=Ee({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=Ee(a,r.padding);r.padding=n;let o=this.transform,s=new c_(e,t),l={top:0,bottom:0,right:0,left:0},u=r.absolutePadding?l:n,h=r.absolutePadding?n:Ee(l,o.padding),c=this.cameraHelper.cameraForBoxAndBearing(r,u,h,s,i,o);if(c)return this._zoomSnap&&(c.zoom=Fe(c.zoom,this._zoomSnap,-1)),r.absolutePadding?{...c,padding:n}:c}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(d.convert(e)),this.transform.screenPointToLocation(d.convert(t)),i,r),r,a)}_fitInternal(e,t,i){return e?((t=Ee(e,t)).absolutePadding?(t.padding=e.padding,delete t.absolutePadding):delete t.padding,t.linear?this.easeTo(t,i):this.flyTo(t,i)):this}jumpTo(e,t){this.stop(),void 0!==e.zoom&&this._zoomSnap&&(e.zoom=Fe(e.zoom,this._zoomSnap));let i=this.getTransformForUpdate(),r=!1,a=!1,n=!1,o=i.zoom;if(this.terrain&&this.getCenterClampedToGround()){let{elevation:t,demState:r}=this.terrain.getElevationAndDEMStateForLngLat(e.center?Kc.convert(e.center):i.center,i.tileZoom);"loading"!==r&&i.setElevation(t)}this.cameraHelper.handleJumpToCenterZoom(i,e);let s=i.zoom!==o;return void 0!==e.elevation&&i.elevation!==+e.elevation&&i.setElevation(+e.elevation),void 0!==e.bearing&&i.bearing!==+e.bearing&&(r=!0,i.setBearing(+e.bearing)),void 0!==e.pitch&&i.pitch!==+e.pitch&&(a=!0,i.setPitch(+e.pitch)),void 0!==e.roll&&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 Qo("movestart",t)).fire(new Qo("move",t)),s&&this.fire(new Qo("zoomstart",t)).fire(new Qo("zoom",t)).fire(new Qo("zoomend",t)),r&&this.fire(new Qo("rotatestart",t)).fire(new Qo("rotate",t)).fire(new Qo("rotateend",t)),a&&this.fire(new Qo("pitchstart",t)).fire(new Qo("pitch",t)).fire(new Qo("pitchend",t)),n&&this.fire(new Qo("rollstart",t)).fire(new Qo("roll",t)).fire(new Qo("rollend",t)),this.fire(new Qo("moveend",t))}calculateAnchoredCameraOptions(e){let t=this.transform.clone(),i=Kc.convert(e.anchorLocation),r=d.convert(e.anchorScreenPoint),a={panDelta:r.sub(this.transform.locationToScreenPoint(i,this.terrain)),zoomDelta:void 0===e.zoom?0:e.zoom-t.zoom,bearingDelta:0,pitchDelta:0,rollDelta:0,around:r,aroundElevation:this.terrain?.getElevationForLngLat(i,t.tileZoom)};return this.cameraHelper.handleMapControlsRollPitchBearingZoom(a,t),this.cameraHelper.handleMapControlsPan(a,t,i),{center:t.center,zoom:t.zoom}}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),void 0!==(e=Ee({offset:[0,0],duration:500,easing:Te},e)).zoom&&this._zoomSnap&&(e.zoom=Fe(e.zoom,this._zoomSnap)),(!1===e.animate||!e.essential&&ht.prefersReducedMotion)&&(e.duration=0);let i,r,a=this.getTransformForUpdate(),n=this.getBearing(),o=a.pitch,s=a.roll,l=void 0===e.bearing?n:this._normalizeBearing(e.bearing,n),u=void 0===e.pitch?o:+e.pitch,h=void 0===e.roll?s:this._normalizeBearing(e.roll,s),c=void 0===e.padding?a.padding:e.padding,p=d.convert(e.offset);e.around&&(i=Kc.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:u,roll:h,padding:c,around:i,aroundPoint:r,offsetAsPoint:p,offset:e.offset,zoom:e.zoom,center:e.center});return this._rotating||=n!==l,this._pitching||=u!==o,this._rolling||=h!==s,this._padding=!a.isPaddingEqual(c),this._zooming||=m.isZooming,this._easeId=e.easeId,this._prepareEase(t,e.noMoveStart,f,{tr:a,center:m.elevationCenter,freeze:e.freezeElevation}),this._ease(i=>{m.easeFunc(i),this.terrain&&!e.freezeElevation&&this._updateElevation(i,a),this.applyUpdatedTransform(a),this._fireMoveEvents(t)},i=>{this._afterEase(t,i,e.freezeElevation)},e),this}_prepareEase(e,t,i={},r){this._moving=!0,this.terrain&&r&&(this._prepareElevation(r.center,r.tr),r.freeze&&this.holdElevation(r.tr,"animation")),!t&&!i.moving&&this.fire(new Qo("movestart",e)),this._zooming&&!i.zooming&&this.fire(new Qo("zoomstart",e)),this._rotating&&!i.rotating&&this.fire(new Qo("rotatestart",e)),this._pitching&&!i.pitching&&this.fire(new Qo("pitchstart",e)),this._rolling&&!i.rolling&&this.fire(new Qo("rollstart",e))}_prepareElevation(e,t){this._elevationCenter=e,this._elevationStart=t.elevation;let{elevation:i,demState:r}=this.terrain.getElevationAndDEMStateForLngLat(e,t.tileZoom);this._elevationTarget="loading"===r?t.elevation:i,this.elevationFreeze=!0}_updateElevation(e,t){(void 0===this._elevationStart||void 0===this._elevationCenter)&&this._prepareElevation(t.center,t),t.setMinElevationForCurrentTile(this.terrain.getMinTileElevationForLngLatZoom(this._elevationCenter,t.tileZoom));let{elevation:i,demState:r}=this.terrain.getElevationAndDEMStateForLngLat(this._elevationCenter,t.tileZoom),a="loading"===r?this._elevationTarget:i;if(e<1&&a!==this._elevationTarget){let t=this._elevationTarget-this._elevationStart,i=(a-(t*e+this._elevationStart))/(1-e);this._elevationStart+=e*(t-i),this._elevationTarget=a}this.getCenterClampedToGround()&&t.setElevation(gr.number(this._elevationStart,this._elevationTarget,e))}holdElevation(e,t){this.elevationFreeze=!0;let i=!!this.terrain&&this.getCenterClampedToGround()&&"loaded"!==this.terrain.getElevationAndDEMStateForLngLat(e.center,e.tileZoom).demState,r=this.terrain?this._terrainHeightAboveMaxZoomForCenter(e):void 0;this._elevationHold=new oE(t,i,void 0!==r&&r<=.01)}releaseElevation(){let e=this._elevationHold?.tookDem??!1;return this.elevationFreeze=!1,this._elevationHold=null,e}putCenterBackOnTerrain(e,t,i){if(i&&void 0===t.getDrawnElevationForLngLat(e.center,!0)){e.setElevation(t.getElevationForLngLat(e.center,e.tileZoom));let i=this._raiseCameraByPitchAndZoom(e);i!==e&&e.apply(i,!1)}else e.recalculateZoomAndCenter(t)}_takeLandedElevation(e){return!!(this._elevationHold&&this.terrain&&this.getCenterClampedToGround())&&this._elevationHold.take(e,this.terrain)}applyTerrainChange(){if(this.elevationFreeze){let e=this._requestedCameraState;return void("gesture"===this._elevationHold?.holder&&e&&this._takeLandedElevation(e)&&this.applyUpdatedTransform(e))}let e=this.transform;if(e.setMinElevationForCurrentTile(this.terrain?this.terrain.getMinTileElevationForLngLatZoom(e.center,e.tileZoom):0),!this.getCenterClampedToGround())return;if(!this.terrain)return void e.setElevation(0);let{elevation:t,demState:i}=this.terrain.getElevationAndDEMStateForLngLat(e.center,e.tileZoom);"loading"!==i&&e.setElevation(t)}getTransformForUpdate(){return this.transformCameraUpdate||this.terrain?(this._requestedCameraState||=this.transform.clone(),this._requestedCameraState):this.transform}_keepCameraAboveTerrain(e){let t=this._elevationHold;if(!this.terrain||!t||e.pitch>=90||!this.getCenterClampedToGround()||e.getClippingPlane())return this._raiseCameraByPitchAndZoom(e);let i="gesture"===t.holder,r=t.lift&&t.lift.heldElevation+t.lift.height===e.elevation?t.lift:{heldElevation:e.elevation,height:0},a=this._terrainHeightAboveMaxZoomForCenter(e);void 0!==a&&a<=.01&&(t.keepsTerrainBelowMaxZoomForCenter=!0);let n=t.keepsTerrainBelowMaxZoomForCenter&&void 0!==a?a:-1/0,o=i?this._terrainHeightAboveCamera(e):-1/0,s=Math.max(0,Math.max(o,n)+r.height);return s!==r.height&&e.setElevation(r.heldElevation+s),t.lift=s>0?{heldElevation:r.heldElevation,height:s}:null,i?e:this._raiseCameraByPitchAndZoom(e)}_raiseCameraByPitchAndZoom(e){if(!this.terrain&&e.elevation>=0&&e.pitch<=90||e.getClippingPlane())return e;let t=e.getCameraLngLat(),i=this.terrain?this._terrainHeightAboveCamera(e):-e.getCameraAltitude();if(i<=0)return e;let r=e.clone();for(let a=0;a<3&&i>0;a++){let{zoom:e,pitch:a}=r.calculateCameraOptionsFromTo(t,r.getCameraAltitude()+i,r.center,r.elevation);r.setZoom(e),r.setPitch(a),i=this.terrain?this._terrainHeightAboveCamera(r):-r.getCameraAltitude()}return r}_terrainHeightAboveCamera(e){let t=this.terrain.getElevationForLngLat(e.getCameraLngLat(),e.tileZoom)-e.getCameraAltitude(),i=e.getClippingPlane()?null:this.terrain.getCoverageIndex();if(!i)return t;let[r,a,n,o]=e.getCameraFrustum().points;for(let s=0;s<=2;s++){let l=s/2;for(let s=0;s<=2;s++){let u=s/2,h=(1-u)*(1-l),c=u*(1-l),d=u*l,p=(1-u)*l,f=h*r[0]+c*a[0]+d*n[0]+p*o[0],m=h*r[1]+c*a[1]+d*n[1]+p*o[1],_=h*r[2]+c*a[2]+d*n[2]+p*o[2],g=Cb(i,this.terrain.exaggeration,f,m,e.worldCoordinateHelper.wraps);g.covered&&(t=Math.max(t,g.elevation-_))}}return t}_terrainHeightAboveMaxZoomForCenter(e){let t=this.terrain.getCoverageIndex();if(!t)return;let i=e.worldCoordinateHelper,r=e.getCameraLngLat(),a=i.worldFromLngLat(r.lng,r.lat),n=i.worldFromLngLat(e.center.lng,e.center.lat),o=Ie(e.zoom-e.maxZoom),s=Cb(t,this.terrain.exaggeration,xe(a.x,n.x,o),xe(a.y,n.y,o),i.wraps);return s.covered?s.elevation-xe(e.getCameraAltitude(),e.elevation,o):void 0}moveCenterOntoTerrain(e,t){if(!this.terrain||!this.getCenterClampedToGround()||e.getClippingPlane())return;let{center:i,elevation:r,zoom:a}=e;e.recalculateZoomAndCenter(this.terrain),(!(e.zoom>a-t&&e.zoom<e.maxZoom)||Math.abs(this.terrain.getElevationForLngLat(e.center,e.tileZoom)-e.elevation)>=1)&&(e.setZoom(a),e.setCenter(i),e.setElevation(r))}captureRotationPivot(e,t){if(!hE(e,t))return{point:e.centerPoint,location:e.center,distance:cE(e,e.center)};let i=this.terrain?e.screenTerrainPointToMercatorCoordinate(t,this.terrain):null,r=i?i.toLngLat():e.screenPointToLocation(t);return i&&this.cameraHelper.useGlobeControls?{point:e.locationToScreenPoint(r),location:r,distance:cE(e,r)}:{point:t,location:r,elevation:i?.z,distance:cE(e,r,i?.z)}}orbitRotationPivot(e,t,i){if(t.point.equals(e.centerPoint))return this.cameraHelper.handleMapControlsRollPitchBearingZoom(i,e),!0;let r=this._turnAroundPivot(e,t,i)??this._turnAroundPivot(e,t,{...i,pitchDelta:0,rollDelta:0});return r?(e.apply(r,!1),!0):(this.cameraHelper.handleMapControlsRollPitchBearingZoom(i,e),!1)}_turnAroundPivot(e,t,i){let r=e.clone();return this.cameraHelper.handleMapControlsRollPitchBearingZoom(i,r),r.pitch>=90||!hE(r,t.point)?null:function(e,t){let i=1,r=lE(e,t),a=t.distance/r;for(let n=0;n<5&&!uE(r,t);n++){if(!Number.isFinite(a)||a<=0)return!1;let n=e.zoom;e.setZoom(n+Me(i/a));let o=i*Ie(n-e.zoom);if(o===i)return!0;let s=lE(e,t);a=o+(t.distance-s)*(o-i)/(s-r),i=o,r=s}return uE(r,t)}(r,t)&&function(e,t){return void 0!==t.elevation||O(dE(e.screenPointToLocation(t.point),0),dE(t.location,0))<1e-4*t.distance}(r,t)?r:null}applyUpdatedTransform(e){this._takeLandedElevation(e);let t=this._keepCameraAboveTerrain(e);if(!this.transformCameraUpdate)return void(t!==this.transform&&this.transform.apply(t,!1));let i=t.clone(),{center:r,zoom:a,roll:n,pitch:o,bearing:s,elevation:l}=this.transformCameraUpdate(i);r&&i.setCenter(r),void 0!==l&&i.setElevation(l),void 0!==a&&i.setZoom(a),void 0!==n&&i.setRoll(n),void 0!==o&&i.setPitch(o),void 0!==s&&i.setBearing(s),this.transform.apply(void 0===l?i:this._raiseCameraByPitchAndZoom(i),!1)}applyTransformChange(e){let t=void 0!==this._requestedCameraState,i=this.getTransformForUpdate();e(i),this.applyUpdatedTransform(i),t||delete this._requestedCameraState}_fireMoveEvents(e){this.fire(new Qo("move",e)),this._zooming&&this.fire(new Qo("zoom",e)),this._rotating&&this.fire(new Qo("rotate",e)),this._pitching&&this.fire(new Qo("pitch",e)),this._rolling&&this.fire(new Qo("roll",e))}_afterEase(e,t,i=!1){this._takeLandedElevation(this.transform);let r=this.releaseElevation();if(this.terrain&&i&&this.getCenterClampedToGround()&&this.putCenterBackOnTerrain(this.transform,this.terrain,r),this._easeId&&t&&this._easeId===t)return;delete this._easeId;let a=this._zooming,n=this._rotating,o=this._pitching,s=this._rolling;this._moving=!1,this._zooming=!1,this._rotating=!1,this._pitching=!1,this._rolling=!1,this._padding=!1,a&&this.fire(new Qo("zoomend",e)),n&&this.fire(new Qo("rotateend",e)),o&&this.fire(new Qo("pitchend",e)),s&&this.fire(new Qo("rollend",e)),this.fire(new Qo("moveend",e))}flyTo(e,t){if(!e.essential&&ht.prefersReducedMotion)return this.easeTo(e,t);this.stop(),void 0!==(e=Ee({offset:[0,0],speed:1.2,curve:1.42,easing:Te},e)).zoom&&this._zoomSnap&&(e.zoom=Fe(e.zoom,this._zoomSnap));let i=this.getTransformForUpdate(),r=i.bearing,a=i.pitch,n=i.roll,o=i.padding,s=void 0===e.bearing?r:this._normalizeBearing(e.bearing,r),l=void 0===e.pitch?a:+e.pitch,u=void 0===e.roll?n:this._normalizeBearing(e.roll,n),h=void 0===e.padding?i.padding:e.padding,c=d.convert(e.offset),p=i.centerPoint.add(c),f=i.screenPointToLocation(p),m=this.cameraHelper.handleFlyTo(i,{bearing:s,pitch:l,roll:u,padding:h,locationAtOffset:f,offsetAsPoint:c,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 D=w(!1),E=function(e){return S(D)/S(D+_*e)},C=function(e){return g*((S(D)*function(e){return T(e)/S(e)}(D+_*e)-T(D))/b)/v},P=(w(!0)-D)/_;if(Math.abs(v)<2e-6||!isFinite(P)){if(Math.abs(g-y)<1e-6)return this.easeTo(e,t);let i=y<g?-1:1;P=Math.abs(Math.log(y/g))/_,C=()=>0,E=e=>Math.exp(i*_*e)}if(void 0!==e.duration)e.duration=+e.duration;else{let t=void 0===e.screenSpeed?+e.speed:+e.screenSpeed/_;e.duration=1e3*P/t}return e.maxDuration&&e.duration>e.maxDuration&&(e.duration=0),this._zooming=!0,this._rotating=r!==s,this._pitching=l!==a,this._rolling=u!==n,this._padding=!i.isPaddingEqual(h),this._prepareEase(t,!1,{},{tr:i,center:m.targetCenter,freeze:e.freezeElevation}),this._ease(d=>{let f=d*P,_=1/E(f),g=C(f);this._rotating&&i.setBearing(gr.number(r,s,d)),this._pitching&&i.setPitch(gr.number(a,l,d)),this._rolling&&i.setRoll(gr.number(n,u,d)),this._padding&&(i.interpolatePadding(o,h,d),p=i.centerPoint.add(c)),m.easeFunc(d,_,g,p),this.terrain&&!e.freezeElevation&&this._updateElevation(d,i),this.applyUpdatedTransform(i),this._fireMoveEvents(t)},()=>{this._afterEase(t,void 0,e.freezeElevation)},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=dt(),this._easeOptions=i,this._onEaseFrame=e,this._onEaseEnd=t,this._easeFrameId=this._requestRenderFrame(this._renderFrameCallback))}_normalizeBearing(e,t){e=De(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}};function lE(e,t){return e.setLocationAtPoint(t.location,t.point,t.elevation),cE(e,t.location,t.elevation)}function uE(e,t){return Math.abs(e/t.distance-1)<1e-7}function hE(e,t){return e.isPointOnMapSurface(new d(t.x,t.y-16))}function cE(e,t,i=e.elevation){return O(dE(e.getCameraLngLat(),e.getCameraAltitude()),dE(t,i))}function dE(e,t){let i=Zb(e);return L(i,i,Yc+t)}var pE={compact:!0,customAttribution:'<a href="https://maplibre.org/" target="_blank">MapLibre</a>'},fE=class{constructor(e=pE){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=wt.create("details","maplibregl-ctrl maplibregl-ctrl-attrib"),this._compactButton=wt.create("summary","maplibregl-ctrl-attrib-button",this._container),this._compactButton.addEventListener("click",this._toggleAttribution),this._setElementTitle(this._compactButton,"ToggleAttribution"),this._innerContainer=wt.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(" | ");if(i!==this._attribHTML){if(this._attribHTML=i,e.length){let t=document.createDocumentFragment(),i=!0;for(let r of e){let e=wt.sanitize(r);e.hasChildNodes()&&(i||t.append(" | "),t.append(e),i=!1)}this._innerContainer.replaceChildren(t),this._container.classList.remove("maplibregl-attrib-empty")}else this._container.classList.add("maplibregl-attrib-empty");this._updateCompact(),this._editLink=null}}},mE=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=wt.create("div","maplibregl-ctrl");let t=wt.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}},_E=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=[];let i,r=!1;for(let a of t)if(!a.cancelled){try{a.callback(e)}catch(e){r||(r=!0,i=e)}if(this._cleared)break}if(this._cleared=!1,this._currentlyRunning=!1,r)throw i}clear(){this._currentlyRunning&&(this._cleared=!0),this._queue=[]}},gE=Gs([{name:"a_pos3d",type:"Int16",components:3}]),yE=class extends Ot{constructor(e){super(),this._lastTilesetChange=dt(),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={},r=!1;for(let a of Wv(e,{tileSize:this.tileSize,minzoom:this.minzoom,maxzoom:this.maxzoom,reparseOverscaled:!1,terrain:t}))i[a.key]=!0,this._renderableTilesKeys.push(a.key),this._tiles[a.key]||(a.terrainRttPosMatrix32f=/* @__PURE__ */new Float32Array(16),A(a.terrainRttPosMatrix32f,0,8192,8192,0,0,1),this._tiles[a.key]=new Rv(a,this.tileSize),this._lastTilesetChange=dt(),r=!0);for(let a in this._tiles)i[a]||(this._tiles[a].releaseRTT(this.tileManager.map.painter),delete this._tiles[a],r=!0);return 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=le();if(r.canonical.equals(e.canonical))A(n,0,re,re,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),o=re>>t;A(n,0,o,o,0,0,1),T(n,n,[-i*o,-a*o,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),o=re>>t;A(n,0,re,re,0,0,1),T(n,n,[i*o,a*o,0]),S(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(),o=le();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;A(o,0,re,re,0,0,1),T(o,o,[t*re,i*re,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),s=e.canonical.y-(a.canonical.y>>t),l=re>>t;A(o,0,l,l,0,0,1),T(o,o,[-i*l+n*re,-r*l+s*re,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,s=(e.canonical.y>>t)-a.canonical.y,l=re<<t;A(o,0,l,l,0,0,1),T(o,o,[i*re+n*l,r*re+s*l,0])}n.terrainRttPosMatrix32f=new Float32Array(o),i[r]=n}return i}getSourceTile(e,t){let i=this.tileManager._source,r=this._getSourceZoom(e,i);if(void 0===r)return;this._sourceTileCache[e.key]?.zoom!==r&&(this._sourceTileCache[e.key]={zoom:r,key:e.scaledTo(r).key});let a=this.findTileInCaches(this._sourceTileCache[e.key].key);if(!a?.dem&&t)for(;r>=i.minzoom&&!a?.dem;)a=this.findTileInCaches(e.scaledTo(r--).key);return a}isStillWaitingForDEM(e){let t=this.tileManager._source,i=this._getSourceZoom(e,t);if(void 0===i)return!1;let r=e.scaledTo(i);return!(t.hasTile&&!t.hasTile(r))&&"errored"!==this.findTileInCaches(r.key)?.state}_getSourceZoom(e,t){let i=Math.min(e.overscaledZ-this.deltaZoom,t.maxzoom);return i<t.minzoom&&(i=t.minzoom),i<=e.overscaledZ?i:void 0}findTileInCaches(e){let t=this.tileManager.getTileByID(e);return t||(t=this.tileManager._outOfViewCache.getByKey(e),t)}anyTilesAfterTime(e=dt()){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)}},vE=class{constructor(e,t,i,r="auto",a=()=>ud){this._meshCache={},this.painter=e,this._getWorldCoordinateHelper=a,this.tileManager=new yE(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.coverage=new Eb(this.tileManager,this.exaggeration,()=>this._worldCoordinateHelper)}destroy(){this._fbo&&=(this._fbo.destroy(),null),this._heightMapFbo&&=(this._heightMapFbo.destroy(),null),this._fboDepthTexture&&=(this._fboDepthTexture.destroy(),null),this._emptyDemTexture&&=(this._emptyDemTexture.destroy(),null),this._emptyDepthTexture&&=(this._emptyDepthTexture.destroy(),null);for(let e in this._meshCache)this._meshCache[e].destroy();this._meshCache={},this.tileManager.destruct()}getDEMElevation(e,t,i,r=re){let a=e.normalizeCoordinates(t,i,r);if(!a)return 0;let n=this.coverage.getSampler(a.tileID);return n?n(a.x,a.y,r):0}getElevationForLngLatZoom(e,t){let i=this._worldCoordinateHelper;if(!m_(t,i.wraps?e.wrap():e,i))return 0;let{tileID:r,worldX:a,worldY:n}=this._getOverscaledTileIDFromLngLatZoom(e,t);return this.getElevation(r,a%re,n%re,re)}getElevationForLngLat(e,t){let i=this.getDrawnElevationForLngLat(e);return void 0===i?this.getElevationForLngLatZoom(e,this._getFallbackZoom(t)):i}getDrawnElevationForLngLat(e,t=!1){return this.coverage.sample(e,t)}getElevationAndDEMStateForLngLat(e,t){let i=this.getElevationForLngLat(e,t);if(0!==i||void 0!==this.getDrawnElevationForLngLat(e))return{elevation:i,demState:"loaded"};let r=this._getFallbackZoom(t),a=this._worldCoordinateHelper;if(!m_(r,a.wraps?e.wrap():e,a))return{elevation:i,demState:"none"};let{tileID:n}=this._getOverscaledTileIDFromLngLatZoom(e,r);return this.tileManager.getSourceTile(n,!0)?.dem?{elevation:i,demState:"loaded"}:{elevation:i,demState:this.tileManager.isStillWaitingForDEM(n)?"loading":"none"}}_getFallbackZoom(e){return Math.min(e,this.tileManager.maxzoom)}getElevation(e,t,i,r=re){return this.getDEMElevation(e,t,i,r)*this.exaggeration}resetElevationCache(){this.coverage.reset()}getCoverageIndex(){return this.coverage.getIndex()}_getDEMTileMatrix(e,t){let i=`${t.tileID.key}/${e.key}`,r=this._demMatrixCache.get(i);if(r)return r;let a=e.canonical.z-t.tileID.canonical.z,n=e.canonical.x-(e.canonical.x>>a<<a),o=e.canonical.y-(e.canonical.y>>a<<a),s=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/(re<<a),1/(re<<a),0]);return T(s,s,[n*re,o*re,0]),this._demMatrixCache.set(i,s),s}getTerrainData(e){if(!this._emptyDemTexture){let e=this.painter.context,t=new bh({width:1,height:1},/* @__PURE__ */new Uint8Array(4));this._emptyDepthTexture=new Fh(e,t,e.gl.RGBA,{premultiply:!1}),this._emptyDemUnpack=[0,0,0,0],this._emptyDemTexture=new Fh(e,new bh({width:1,height:1}),e.gl.RGBA,{premultiply:!1}),this._emptyDemTexture.bind(e.gl.NEAREST,e.gl.CLAMP_TO_EDGE),this._emptyDemMatrix=x([])}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 Fh(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(){let e=this.painter,t=e.width/devicePixelRatio,i=e.height/devicePixelRatio;return this._fbo&&(this._fbo.width!==t||this._fbo.height!==i)&&(this._fbo.destroy(),this._fboDepthTexture.destroy(),delete this._fbo,delete this._fboDepthTexture),this._fboDepthTexture||(this._fboDepthTexture=new Fh(e.context,{width:t,height:i,data:null},e.context.gl.RGBA,{premultiply:!1}),this._fboDepthTexture.bind(e.context.gl.NEAREST,e.context.gl.CLAMP_TO_EDGE)),this._fbo||(this._fbo=e.context.createFramebuffer(t,i,!0,!1),this._fbo.depthAttachment.set(e.context.createRenderbuffer(e.context.gl.DEPTH_COMPONENT16,t,i))),this._fbo.colorAttachment.set(this._fboDepthTexture.texture),this._fbo}getHeightMapFramebuffer(e){return this._heightMapFbo||=this.painter.context.createFramebuffer(1,1,!1,!1),this._heightMapFbo.colorAttachment.set(e),this._heightMapFbo}getTerrainMesh(e,t){let 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,o=new Al,s=new Zl,l=this.meshSize,u=re/l,h=l*l;for(let d=0;d<=l;d++)for(let e=0;e<=l;e++)o.emplaceBack(e*u,d*u,0);for(let d=0;d<h;d+=l+1)for(let e=0;e<l;e++)s.emplaceBack(e+d,l+e+d+1,l+e+d+2),s.emplaceBack(e+d,l+e+d+2,e+d+1);"none"!==this._terrainSkirtLength&&this._buildSkirts(o,s,l,u,i,r);let c=new $_(n.createVertexBuffer(o,gE.members),n.createIndexBuffer(s),Yl.simpleSegment(0,0,o.length,s.length));return this._meshCache[a]=c,c}getSkirtLength(e){return this._worldCoordinateHelper.metersPerWorldUnit(.5,.5)/2**Math.max(e,0)/5}getMinTileElevationForLngLatZoom(e,t){let i=this._worldCoordinateHelper;if(!m_(t,i.wraps?e.wrap():e,i))return 0;let{tileID:r}=this._getOverscaledTileIDFromLngLatZoom(e,t);return this.getMinMaxElevation(r).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}get _worldCoordinateHelper(){return this._getWorldCoordinateHelper()}_getOverscaledTileIDFromLngLatZoom(e,t){let i=this._worldCoordinateHelper,r=i.wraps?e.wrap():e,a=i.worldFromLngLat(r.lng,r.lat),n=(1<<t)*re,o=a.x*n,s=a.y*n;return{tileID:new y_(t,0,t,Math.floor(o/re),Math.floor(s/re)),worldX:o,worldY:s}}_buildSkirts(e,t,i,r,a,n){let o=e.length,s=o+(i+1),l=(i+1)*i,u=a?Cc:0,h=+!a,c=n?Pc:re,d=+!n;for(let m=0;m<=i;m++)e.emplaceBack(m*r,u,h);for(let m=0;m<=i;m++)e.emplaceBack(m*r,c,d);for(let m=0;m<i;m++)t.emplaceBack(l+m,s+m,s+m+1),t.emplaceBack(l+m,s+m+1,l+m+1),t.emplaceBack(0+m,o+m+1,o+m),t.emplaceBack(0+m,0+m+1,o+m+1);let p=e.length,f=p+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*re,t*r,i);for(let m=0;m<2*i;m+=2)t.emplaceBack(p+m,p+m+1,p+m+3),t.emplaceBack(p+m,p+m+3,p+m+2),t.emplaceBack(f+m,f+m+3,f+m+1),t.emplaceBack(f+m,f+m+2,f+m+3)}},xE=["none","zoom","sourceTiles","visibleLayers","revision"],bE=class{constructor(e,t,i,r){this._tileKeys=e.map(e=>e.key).sort().join(),this._revision=t,this._zoom=i,this._visibleLayerIds=r}difference(e){return this._revision===e?._revision?this._visibleLayerIds===e._visibleLayerIds?this._tileKeys===e._tileKeys?this._zoom===e._zoom?"none":"zoom":"sourceTiles":"visibleLayers":"revision"}},wE={background:!0,fill:!0,line:!0,raster:!0,hillshade:!0,"color-relief":!0};function TE(e){return Im(e)?`custom-layer:${e.id}`:e.source}function SE(e){return Im(e)?void 0!==e.implementation.renderToTerrainTile:!0===wE[e.type]}var DE,EE=class{constructor(e,t){this.needsFollowUpFrame=!1,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,i){let r=t!==this._lastPrepareZoom;this._lastPrepareZoom=t,this._stacks=[],this._prevRenderedToTexture=!1,this._rttTiles=[],this._renderableTiles=this.terrain.tileManager.getRenderableTiles(),this._renderableLayerIds=e._order.filter(i=>!e._layers[i].isHidden(t));let a=function(e,t){let i=[],r=!1;for(let a of t){let t=SE(e._layers[a]);t&&!r&&i.push([]),t&&i[i.length-1].push(a),r=t}return i}(e,this._renderableLayerIds),n=this._renderableLayerIds.join(),o=/* @__PURE__ */new Set;for(let u of this._renderableLayerIds){let t=e._layers[u],i=t.source;i&&wE[t.type]&&o.add(i)}this._coordsAscending={},this._rttFingerprints={};for(let u of o){let i=e.tileManagers[u];if(!i)continue;this._coordsAscending[u]={};let r=this._coordsAscending[u],a=i.getSource(),o=a instanceof W_?a.terrainTileRanges:null;for(let e of i.getVisibleCoordinates()){let t=this.terrain.tileManager.getTerrainCoords(e,o);for(let e in t)r[e]||=[],r[e].push(t[e])}this._rttFingerprints[u]={};let s=this._rttFingerprints[u],l=i.getState().revision;for(let e in r)s[e]=new bE(r[e],l,t,n)}for(let u of this._renderableLayerIds){let i=e._layers[u];if(!Im(i)||!SE(i))continue;let r=i.implementation.terrainTileRevision??0,a={};for(let e of this._renderableTiles)a[e.tileID.key]=new bE([e.tileID],r,t,n);this._rttFingerprints[TE(i)]=a}this.needsFollowUpFrame=!1;let s=r||i,l=!1;for(let u of this._renderableTiles){let t=this._textureDifference(u);"none"!==t&&("zoom"===t&&s||"visibleLayers"===t&&r?this.needsFollowUpFrame=!0:"zoom"===t||"sourceTiles"===t?(l?this.needsFollowUpFrame=!0:this._releaseChangedTextures(u,e,a),l=!0):this._releaseChangedTextures(u,e,a))}}_releaseChangedTextures(e,t,i){let r=i.map(i=>this._hasStackChanged(e,t,i));if(r.includes(!1))for(let[a,n]of r.entries())n&&e.releaseRTTStack(this.painter,a);else e.releaseRTT(this.painter)}_hasStackChanged(e,t,i){let r=!1;for(let a of i){let i=TE(t._layers[a]),n=this._rttFingerprints[i]?.[e.tileID.key],o=e.rttFingerprint[i];if(n||o){if("none"!==n?.difference(o))return!0;r=!0}}return!r}_textureDifference(e){let t="none";for(let i in this._rttFingerprints){let r=this._rttFingerprints[i][e.tileID.key];if(!r)continue;let a=r.difference(e.rttFingerprint[i]);xE.indexOf(a)>xE.indexOf(t)&&(t=a)}return t}renderLayer(e,t,i){if(e.isHidden(i.transform.zoom))return!1;let r=SE(e),a=this.painter,n=this._renderableLayerIds[this._renderableLayerIds.length-1]===e.id;if(r&&(this._prevRenderedToTexture||this._stacks.push([]),this._prevRenderedToTexture=!0,this._stacks[this._stacks.length-1].push(e.id),!n))return!0;if(this._prevRenderedToTexture||r&&n){this._prevRenderedToTexture=r;let e=this._stacks.length-1,n=this._stacks[e]||[];i.isRenderingToTexture=!0,vT(a.context.frameUniformBuffer,this.rttSize,this.rttSize);for(let r of this._renderableTiles){if(this._rttTiles.push(r),r.getRTT(e))continue;let o=r.acquireRTT(a,e,this.rttSize);a.bindRTT(o),a.context.clear({color:Wi.transparent,stencil:0}),i.invalidateTileClippingMasks();for(let e of n){let n=t._layers[e],o=n.source?this._coordsAscending[n.source][r.tileID.key]:[r.tileID];a.context.viewport.set([0,0,this.rttSize,this.rttSize]),i.renderTileClippingMasks(n,o),a.renderLayer(a,t.tileManagers[n.source],n,o,i);let s=TE(n);s&&(r.rttFingerprint[s]=this._rttFingerprints[s][r.tileID.key])}o.texture.generateMipmap()}return i.isRenderingToTexture=!1,vT(a.context.frameUniformBuffer,a.context.gl.drawingBufferWidth,a.context.gl.drawingBufferHeight),function(e,t,i,r){let{isRenderingGlobe:a}=r.data,n=r.context,o=n.gl,s=r.transform,l=r.colorModeForRenderPass(),u=r.getDepthModeFor3D(),h=r.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,a),d=e.renderToTexture.getTexture(c),p=t.getTerrainData(c.tileID);n.activeTexture.set(o.TEXTURE0),d.bind(o.LINEAR,o.CLAMP_TO_EDGE,o.LINEAR_MIPMAP_LINEAR);let f=t.getSkirtLength(s.zoom),m=s.calculateFogMatrix(c.tileID.toUnwrapped()),_=DT(f,m,r.data.sky,s.pitch,a),g=r.getProjectionDataForTile(c.tileID,{applyTerrainMatrix:!1});h.draw(n,o.TRIANGLES,u,lS.disabled,l,hS.backCCW,_,p,g,"terrain",i.vertexBuffer,i.indexBuffer,i.segments)}}(this.painter,this.terrain,this._rttTiles,i),this._rttTiles=[],r}return!1}},CE={"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"},PE=c,AE={hash:!1,interactive:!0,bearingSnap:7,zoomSnap:0,attributionControl:pE,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:Tt.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,globalState:void 0,transformStyle:void 0,maxCanvasSize:[4096,4096],cancelPendingTileRequestsWhileZooming:!0,centerClampedToGround:!0,terrainSkirtLength:"auto",zoomLevelsToOverscale:4,anisotropicFilterPitch:20},IE=class extends Ot{get _ownerWindow(){return this._container?.ownerDocument?.defaultView||window}constructor(e){super(),this._idleTriggered=!1,this._crossFadingFactor=1,this._renderTaskQueue=new _E,this._controls=[],this._mapId=Ae(),this._styleUrl=null,this._missingStyleImageResolver=null,this._lostContextSnapshot={style:null,images:{}},this._contextLost=e=>{e.preventDefault(),this._frameRequest&&=(this._frameRequest.abort(),null),this.painter.destroy(),this._lostContextSnapshot=this._takeStyleSnapshot(),this.style&&=(this._warnAboutUnrestorableLayers(),this.style.off("error",this._onStyleError),this.style.destroy(),null),this.fire(new us("webglcontextlost",{originalEvent:e}))},this._contextRestored=e=>{this._restoreStyleSnapshot(this._lostContextSnapshot),this._lostContextSnapshot={style:null,images:{}};try{this._setupPainter()}catch(e){return void this.fire(new Bt(e))}this.resize(),this._update(),this._resizeInternal(),this.fire(new us("webglcontextrestored",{originalEvent:e}))},this._handleWorkersRestarted=()=>{if(!this.style)return;if(!this.style._loaded)return this.style.off("style.load",this._handleWorkersRestarted),void this.style.once("style.load",this._handleWorkersRestarted);let e=this._takeStyleSnapshot();this._warnAboutUnrestorableLayers(),this.fire(new us("webglcontextlost",{originalEvent:new globalThis.Event("webglcontextlost")})),this._restoreStyleSnapshot(e),this._update(),this.fire(new us("webglcontextrestored",{originalEvent:new globalThis.Event("webglcontextrestored")}))},this._onMapScroll=e=>{if(e.target===this._container)return this._container.scrollTop=0,this._container.scrollLeft=0,!1},this._onStyleError=e=>{e.tile&&this.triggerRepaint()},this._onWindowOnline=()=>{this._update()},Go().on("restart",this._handleWorkersRestarted),Yo().watchWorkers();let t={...AE,...e,canvasContextAttributes:{...AE.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");this._camera=new sE({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={...CE,...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&&(ht.prefersReducedMotion=t.reduceMotion),this._requestManager=new Ko(t.transformRequest),this._container=this._resolveContainer(t.container),t.maxBounds&&this.setMaxBounds(t.maxBounds),this._setupContainer();try{this._setupPainter()}catch(e){throw this._cleanupContainer(),e}this._imageQueueHandle=Ho.addThrottleControl(()=>this.isMoving()),this.on("move",()=>this._update(!1)),this.on("moveend",()=>this._update(!1)),this.on("zoom",()=>this._update(!0)),this.on("terrain",()=>{this.painter.markTerrainDepthDirty(),this._update(!0)}),this.once("idle",()=>this._idleTriggered=!0),this._handlers=new nE(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 uD(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,Ee({},t.fitBoundsOptions,{duration:0}))));let r="string"==typeof t.style?void 0:t.style?.projection?.type,a="globe"!==r&&!k_(r);this.resize(null,a),this._localIdeographFontFamily=t.localIdeographFontFamily,this._validateStyle=t.validateStyle,this._initialGlobalState=t.globalState,this._transformStyle=t.transformStyle,t.style&&this.setStyle(t.style,{localIdeographFontFamily:t.localIdeographFontFamily}),t.attributionControl&&this.addControl(new fE("boolean"==typeof t.attributionControl?void 0:t.attributionControl)),t.maplibreLogo&&this.addControl(new mE,t.logoPosition),this.on("style.load",()=>{if(a||this._resizeTransform(),this._camera.transform.unmodified){let e=Ce(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 ts("styledata",e):new is("sourcedata",e))}),this.on("dataloading",e=>{this.fire("style"===e.dataType?new ts("styledataloading",e):new is("sourcedataloading",e))}),this.on("dataabort",e=>{this.fire(new is("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 Bt(/* @__PURE__ */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 Bt(/* @__PURE__ */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 Wv(this._camera.transform,e)}setTransformCameraUpdate(e){this._camera.transformCameraUpdate=e}getCenter(){return new Kc(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}calculateAnchoredCameraOptions(e){return this._camera.calculateAnchoredCameraOptions(e)}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(Kc.convert(e),this._camera.transform.tileZoom):null}getCenterClampedToGround(){return this._camera.getCenterClampedToGround()}calculateCameraOptionsFromTo(e,t,i,r){return null==r&&this.terrain&&(r=this.terrain.getElevationForLngLat(i,this._camera.transform.tileZoom)),this._camera.transform.calculateCameraOptionsFromTo(e,t,i,r??0)}resize(e,t=!0){if(null!==this._lostContextSnapshot.style)return this;this._resizeInternal(t);let i=!this._camera._moving;return i&&(this.stop(),this.fire(new Qo("movestart",e)).fire(new Qo("move",e))),this.fire(new Jo("resize",e)),i&&this.fire(new Qo("moveend",e)),this}_resizeInternal(e=!0){let[t,i]=this._containerDimensions();this._clampedPixelRatio=this._getClampedPixelRatio(t,i),this._resizeCanvas(t,i,this._clampedPixelRatio),this.painter.resize(t,i,this._clampedPixelRatio);let r=this.painter.context.gl;!r.isContextLost()&&this.painter.overLimit()&&(this._maxCanvasSize=[r.drawingBufferWidth,r.drawingBufferHeight],this._clampedPixelRatio=this._getClampedPixelRatio(t,i),this._resizeCanvas(t,i,this._clampedPixelRatio),this.painter.resize(t,i,this._clampedPixelRatio)),this.style?.resize(),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,o=t*a,s=n>i?i/n:1,l=o>r?r/o:1,u=Math.min(s,l);return u<1&&Oe("The canvas is larger than maxCanvasSize and is rendered at a lower pixel ratio to fit. Increase maxCanvasSize, within MAX_TEXTURE_SIZE, to render at full resolution."),u*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.applyTransformChange(t=>t.setMaxBounds(c_.convert(e))),this._update()}setMinZoom(e){if(e??=-2,e>=-2&&e<=this._camera.transform.maxZoom){let t=this._camera.transform.zoom;return this._camera.applyTransformChange(t=>t.setMinZoom(e)),this._update(),t!==this._camera.transform.zoom&&this.fire(new Qo("zoomstart")).fire(new Qo("zoom")).fire(new Qo("zoomend")).fire(new Qo("movestart")).fire(new Qo("move")).fire(new Qo("moveend")),this}throw Error("minZoom must be between -2 and the current maxZoom, inclusive")}getMinZoom(e=!1){let t=this._camera.transform;return e?t.applyConstrain(t.center,t.minZoom).zoom:t.minZoom}setMaxZoom(e){if(e??=22,e>=this._camera.transform.minZoom){let t=this._camera.transform.zoom;return this._camera.applyTransformChange(t=>t.setMaxZoom(e)),this._update(),t!==this._camera.transform.zoom&&this.fire(new Qo("zoomstart")).fire(new Qo("zoom")).fire(new Qo("zoomend")).fire(new Qo("movestart")).fire(new Qo("move")).fire(new Qo("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;return this._camera.applyTransformChange(t=>t.setMinPitch(e)),this._update(),t!==this._camera.transform.pitch&&this.fire(new Qo("pitchstart")).fire(new Qo("pitch")).fire(new Qo("pitchend")).fire(new Qo("movestart")).fire(new Qo("move")).fire(new Qo("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;return this._camera.applyTransformChange(t=>t.setMaxPitch(e)),this._update(),t!==this._camera.transform.pitch&&this.fire(new Qo("pitchstart")).fire(new Qo("pitch")).fire(new Qo("pitchend")).fire(new Qo("movestart")).fire(new Qo("move")).fire(new Qo("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.applyTransformChange(t=>t.setRenderWorldCopies(e)),this._update()}setTransformConstrain(e){return this._camera.applyTransformChange(t=>t.setConstrainOverride(e)),this._update()}project(e){return this._camera.transform.locationToScreenPoint(Kc.convert(e),this.style&&this.terrain)}unproject(e){return this._camera.transform.screenPointToLocation(d.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}_createDelegates(e,t,i){if("mouseenter"===e||"mouseover"===e){let r=!1;return{mousemove:a=>{let n=t.filter(e=>this.getLayer(e)),o=0===n.length?[]:this.queryRenderedFeatures(a.point,{layers:n});o.length?r||(r=!0,i.call(this,new rs(e,this,a.originalEvent,{features:o}))):r=!1},mouseout:()=>{r=!1}}}if("mouseleave"===e||"mouseout"===e){let r=!1;return{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 rs(e,this,a.originalEvent)))},mouseout:t=>{r&&(r=!1,i.call(this,new rs(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{[e]:r}}}_addDelegatedListener(e,t){this._delegatedListeners||={},this._delegatedListeners[e]||=[],this._delegatedListeners[e].push(t);for(let i in t.delegates)this.on(i,t.delegates[i])}_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={layers:r,listener:i,delegates:this._createDelegates(e,r,i)};return this._addDelegatedListener(e,a),{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={layers:r,listener:i,delegates:this._createDelegates(e,r,t=>{this._removeDelegatedListener(e,r,i),i.call(this,t)})};return this._addDelegatedListener(e,a),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 d||Array.isArray(e),a=r?e:[[0,0],[this._camera.transform.width,this._camera.transform.height]];if(t||=(r?{}:e)||{},a instanceof d||"number"==typeof a[0])i=[d.convert(a)];else{let e=d.convert(a[0]),t=d.convert(a[1]);i=[e,new d(t.x,e.y),t,new d(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 t=Ee({},{localIdeographFontFamily:this._localIdeographFontFamily,validate:this._validateStyle,globalState:this._initialGlobalState,transformStyle:this._transformStyle},t),this._styleUrl="string"==typeof e?e:null,!1!==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.off("error",this._onStyleError),this.style.setEventedParent(null),this.style._remove(!e)),e?(this.style=new bw(this,t||{}),this.style.setEventedParent(this,{style:this.style}),this.style.on("error",this._onStyleError),"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 bw(this,{}),this.style.setEventedParent(this,{style:this.style}),this.style.on("error",this._onStyleError),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 Mt(e,r);this._diffStyleRequest=null,this._updateDiff(a.data,t)}catch(e){this._diffStyleRequest=null,lt(e)||this.fire(new Bt(ne(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){Oe(`Unable to perform style diff: ${ne(a).message}. Rebuilding the style from scratch.`),this._updateStyle(e,t)}}getStyle(){if(this.style)return this.style.serialize()}getStyleUrl(){return this._styleUrl}_takeStyleSnapshot(){return this.style?{style:this.style.serialize(),images:this.style.imageManager.cloneImages()}:{style:null,images:{}}}isStyleLoaded(){if(this.style)return this.style.loaded();Oe("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 Bt(/* @__PURE__ */Error(`There is no tile manager with ID '${e}'`)))}setTerrain(e,t={}){if(this.style._checkLoaded(),e&&ms(this,cs.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&&Oe("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&&Oe("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 vE(this.painter,t,e,this._terrainSkirtLength,()=>this._camera.transform.worldCoordinateHelper),this.painter.renderToTexture=new EE(this.painter,this.terrain),this._camera.setTerrain(this.terrain),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.painter.destroyRTTResources(),this._camera.setTerrain(null);return this.style.triggerSymbolPlacement(),this.fire(new ss({terrain:e})),this}_handleTerrainDataEvent(e,t){if("style"===e.dataType)return void this.terrain.tileManager.releaseAllRTT();let i=e.sourceId===t;i&&(this.terrain.resetElevationCache(),this.style.triggerSymbolPlacement()),i&&e.tile&&(this.painter.markTerrainDepthDirty(),this._camera.applyTerrainChange()),e.tile&&("image"===e.source?.type?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=$v(Math.max(1,e),Math.max(1,t))}else for(let r in this.style.tileManagers)this.style.tileManagers[r].getSource().calculateTileZoom=$v(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 __(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}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:o,textFitWidth:s,textFitHeight:l}=t;if(e instanceof HTMLImageElement||Ge(e)){let{width:t,height:u,data:h}=ht.getImageData(e);return{data:new bh({width:t,height:u},h),pixelRatio:i,stretchX:a,stretchY:n,content:o,textFitWidth:s,textFitHeight:l,sdf:r,version:0}}if(void 0===e.width||void 0===e.height)return this.fire(new Bt(/* @__PURE__ */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:u,data:h}=e,c=e,d=sf(c.data);return{data:d?new bh({width:t,height:u}):new bh({width:t,height:u},new Uint8Array(h)),pixelRatio:i,stretchX:a,stretchY:n,content:o,textFitWidth:s,textFitHeight:l,sdf:r,version:0,isWebGLImage:d,userImage:c}}}updateImage(e,t){let i=this.style.getImage(e);if(!i)return this.fire(new Bt(/* @__PURE__ */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||Ge(t)?ht.getImageData(t):t;if(void 0===r||void 0===a)return this.fire(new Bt(/* @__PURE__ */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 Bt(/* @__PURE__ */Error("The width and height of the updated image must be that same as the previous version of the image")));if(i.isWebGLImage=sf(n),i.isWebGLImage)i.userImage=t;else{let e=!(t instanceof HTMLImageElement||Ge(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 Bt(/* @__PURE__ */Error("Missing required image id"))),!1)}removeImage(e){this.style.removeImage(e)}async loadImage(e){let t=await Ho.getImage(await this._requestManager.transformRequest(e,"Image"),new AbortController);if(!t.data)throw Error(`Could not load image ${e}: the response is empty`);return t}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()}setFontFaces(e){return this._lazyInitEmptyStyle(),this.style.setFontFaces(e),this._update(!0)}getFontFaces(){return this.style.getFontFaces()}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=Math.floor(this._container.clientWidth)||400,t=Math.floor(this._container.clientHeight)||300),[e,t]}_shouldHandleInitialResize(){if(!this._container?.clientWidth||!this._container.clientHeight)return!1;let[e,t]=this._containerDimensions();return e!==this._camera.transform.width||t!==this._camera.transform.height}_setupResizeObserver(){let e=!1,t=lD(e=>{this._trackResize&&!this._removed&&(this.resize(e),this.redraw())},50),i=this._ownerWindow.ResizeObserver??ResizeObserver;this._resizeObserver=new i(i=>{!e&&(e=!0,!this._shouldHandleInitialResize())||t(i)}),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._containerDimensions(),t=this._getClampedPixelRatio(e[0],e[1]),i=this._container;i.classList.add("maplibregl-map");let r=this._canvasContainer=wt.create("div","maplibregl-canvas-container",i);this._interactive&&r.classList.add("maplibregl-interactive"),this._canvas=wt.create("canvas","maplibregl-canvas",r),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"),this._resizeCanvas(e[0],e[1],t);let a=this._controlContainer=wt.create("div","maplibregl-control-container",i),n=this._controlPositions={};for(let o of["top-left","top-right","bottom-left","bottom-right"])n[o]=wt.create("div",`maplibregl-ctrl-${o} `,a);this._container.addEventListener("scroll",this._onMapScroll,!1)}_cleanupContainer(){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")}_resizeCanvas(e,t,i){let r=Math.round(i*e),a=Math.round(i*t);this._canvas.width=r,this._canvas.height=a,this._canvas.style.width=r/i+"px",this._canvas.style.height=a/i+"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);if(!i)throw new sD(e,t);this.painter=new oD(i)}migrateProjection(e,t){this._camera.migrateProjection(e,t),this.fire(new ls({newProjection:this.style.projection.name}))}_warnAboutUnrestorableLayers(){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.`)}_restoreStyleSnapshot({style:e,images:t}){if(e&&(this.setStyle(e,{diff:!1}),this.style)){this.style.imageManager.images=t;for(let[e,i]of Object.entries(t))i.isWebGLImage&&this.style.imageManager.updateImage(e,i,!1)}}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}_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=dt();this.style.zoomHistory.update(e,i);let a=new gs(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;if(this._camera.transform.setTransitionState(this.style.projection?.transitionState),this.style&&(this._sourcesDirty||a)&&(this._sourcesDirty=!1,this.style._updateSources(this._camera.transform)),this.terrain){if(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()){let{elevation:e,demState:t}=this.terrain.getElevationAndDEMStateForLngLat(this._camera.transform.center,this._camera.transform.tileZoom);"loading"!==t&&this._camera.transform.setElevation(e)}}else 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);let n=this.style.projection,o=n?.transitionState??0;this.painter.render(this.style,this._camera.transform,{showTileBoundaries:this.showTileBoundaries,showOverdrawInspector:this._showOverdrawInspector,rotating:this.isRotating(),zooming:this.isZooming(),moving:this.isMoving(),fadeDuration:t,symbolFadeChange:this.style.placement.symbolFadeChange(dt()),variableOffsets:this.style.placement.variableOffsets,showPadding:this.showPadding,anisotropicFilterPitch:this.getAnisotropicFilterPitch(),projectionTransition:o,isRenderingGlobe:o>0,projectionShaderVariant:n?{name:n.shaderVariantName,define:n.shaderDefine,prelude:n.shaderPreludeCode}:void 0,useSubdivision:n?.useSubdivision??!1,pixelRatio:this._clampedPixelRatio,light:this.style.light?.getEvaluated(),sky:this.style.sky?.getEvaluated()}),this.fire(new Jo("render")),this.loaded()&&!this._loaded&&(this._loaded=!0,this.fire(new Jo("load"))),this.style&&(this.style.hasTransitions()||r)&&(this._styleDirty=!0),this.style&&!this._placementDirty&&this.style._releaseSymbolFadeTiles();let s=this._sourcesDirty||this._styleDirty||this._placementDirty||this.painter.renderToTexture?.needsFollowUpFrame;return s||this._repaint?this.triggerRepaint():!this.isMoving()&&this.loaded()&&this.fire(new Jo("idle")),this._loaded&&!this._fullyLoaded&&!s&&(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(),Go().off("restart",this._handleWorkersRestarted),this.setStyle(null),typeof window<"u"&&this._ownerWindow.removeEventListener("online",this._onWindowOnline,!1),Ho.removeThrottleControl(this._imageQueueHandle),this._resizeObserver?.disconnect();let e=this.painter.context.gl.getExtension("WEBGL_lose_context");e?.loseContext&&e.loseContext(),this._cleanupContainer(),this._removed=!0,this.fire(new Jo("remove"))}triggerRepaint(){this.style&&!this._frameRequest&&(this._frameRequest=new AbortController,ht.frame(this._frameRequest,e=>{this._frameRequest=null;try{this._render(e)}catch(e){if(!lt(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 PE}getCameraTargetElevation(){return this._camera.transform.elevation}getProjection(){return this.style.getProjection()}setProjection(e){return this._lazyInitEmptyStyle(),this.style.setProjection(e),this._update(!0)}},ME={showCompass:!0,showZoom:!0,visualizePitch:!1,visualizeRoll:!0},FE=class{constructor(e){this._updateZoomButtons=()=>{let e=this._map.getZoom(),t=e===this._map.getMaxZoom(),i=e===this._map.getMinZoom(!0);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(qe(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=Ee({},ME,e),this._container=wt.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})),wt.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})),wt.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=wt.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("move",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 zE(this._map,this._compass,this.options.visualizePitch)),this._container}onRemove(){this._container.remove(),this.options.showZoom&&this._map.off("move",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=wt.create("button",e,this._container);return i.type="button",i.addEventListener("click",t),i}},zE=class{constructor(e,t,i=!1){this.mousedown=e=>{this.startMove(e,wt.mousePos(this.element,e)),window.addEventListener("mousemove",this.mousemove),window.addEventListener("mouseup",this.mouseup)},this.mousemove=e=>{this.move(e,wt.mousePos(this.element,e))},this.mouseup=e=>{this._rotatePitchHandler.dragEnd(e),this.offTemp()},this.touchstart=e=>{1===e.targetTouches.length?(this._startPos=this._lastPos=wt.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=wt.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 ID;this._rotatePitchHandler=new ED({clickTolerance:3,move:(e,r)=>{let a=t.getBoundingClientRect(),n=new d((a.bottom-a.top)/2,(a.right-a.left)/2);return{bearingDelta:Xe(new d(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),wt.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(){wt.enableDrag(),window.removeEventListener("mousemove",this.mousemove),window.removeEventListener("mouseup",this.mouseup),window.removeEventListener("touchmove",this.touchmove),window.removeEventListener("touchend",this.touchend)}};function kE(e,t,i,r=!1){if(r||!i.getCoveringTilesDetailsProvider().allowWorldCopies())return e?.wrap();let a=new Kc(e.lng,e.lat);if(e=new Kc(e.lng,e.lat),t){let r=new Kc(e.lng-360,e.lat),a=new Kc(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 RE={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 LE(e,t,i){let r=e.classList;for(let a in RE)r.remove(`maplibregl-${i}-anchor-${a}`);r.add(`maplibregl-${i}-anchor-${t}`)}var BE,OE={ArrowLeft:[-1,0],ArrowRight:[1,0],ArrowUp:[0,-1],ArrowDown:[0,1]},jE="#3FB1CE";function VE(e,t,i=[]){let r=wt.createNS("http://www.w3.org/2000/svg",e);for(let a in t)r.setAttributeNS(null,a,t[a]);for(let a of i)r.appendChild(a);return r}var NE=class extends Lt{},UE=class extends Lt{},$E=class extends Ot{constructor(e){if(super(),this._onClick=e=>{this.fire(new UE("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=OE[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 d(r.x+t[0]*i,r.y+t[1]*i))),this._keyboardDragActive||(this._keyboardDragActive=!0,this.fire(new NE("dragstart"))),this.fire(new NE("drag"))},this._onKeyUp=e=>{OE[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._updateCoveredUnthrottled=()=>{let e=this._map?.terrain;if(!e||!this._isInViewport())return;let t=this._isCovered(e);t&&this._popup?.isOpen()&&this._popup.remove(),this._element.style.opacity=t?this._opacityWhenCovered:this._opacity,this._element.classList.toggle("maplibregl-marker-covered",t)},this._updateCovered=lD(this._updateCoveredUnthrottled,100),this._update=e=>{if(!this._map)return;this._lngLat=kE(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 t="";"viewport"===this._rotationAlignment||"auto"===this._rotationAlignment?t=`rotateZ(${this._rotation}deg)`:"map"===this._rotationAlignment&&(t=`rotateZ(${this._rotation-this._map.getBearing()}deg)`);let i="";"viewport"===this._pitchAlignment||"auto"===this._pitchAlignment?i="rotateX(0deg)":"map"===this._pitchAlignment&&(i=`rotateX(${this._map.getPitch()}deg)`),!this._subpixelPositioning&&"move"!==e?.type&&(this._pos=this._pos.round()),this._element.style.transform=`${RE[this._anchor]} translate(${this._pos.x}px, ${this._pos.y}px) ${i} ${t}`,this._updateOpacity()},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 NE("dragstart"))),this.fire(new NE("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 NE("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||jE,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=d.convert(e?.offset||[0,0]);else{this._defaultMarker=!0,this._element=wt.create("div");let t=(BE||(BE=VE("svg",{display:"block",height:"41px",width:"27px",viewBox:"0 0 27 41"},[VE("g",{"fill-rule":"nonzero"},[VE("g",{transform:"translate(3.0, 29.0)",fill:"#000000"},[["10.5","5.25002273"],["10.5","5.25002273"],["9.5","4.77275007"],["8.5","4.29549936"],["7.5","3.81822308"],["6.5","3.34094679"],["5.5","2.86367051"],["4.5","2.38636864"]].map(([e,t])=>VE("ellipse",{opacity:"0.04",cx:"10.5",cy:"5.80029008",rx:e,ry:t}))),VE("g",{fill:jE},[VE("path",{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"})]),VE("g",{opacity:"0.25",fill:"#000000"},[VE("path",{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"})]),VE("g",{transform:"translate(6.0, 7.0)",fill:"#FFFFFF"}),VE("g",{transform:"translate(8.0, 8.0)"},[VE("circle",{fill:"#000000",opacity:"0.25",cx:"5.5",cy:"5.5",r:"5.4999962"}),VE("circle",{fill:"#FFFFFF",cx:"5.5",cy:"5.5",r:"5.4999962"})])])]),BE)).cloneNode(!0);t.setAttributeNS(null,"height",41*this._scale+"px"),t.setAttributeNS(null,"width",27*this._scale+"px"),function(e){return e.firstElementChild.children[1]}(t).setAttributeNS(null,"fill",this._color),this._element.appendChild(t),this._offset=d.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()}),LE(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),e.on("idle",this._update),this._element.addEventListener("click",this._onClick),this.setDraggable(this._draggable),this._update(),this._map.on("click",this._onMapClick),this}remove(){return 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("idle",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=Kc.convert(e),this._pos=null,this._update(),this._popup&&this._popup.setLngLat(this._lngLat),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 NE("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(){if(!this._isInViewport())return;let e=this._map?.terrain,t=this._map._camera.transform.isLocationOccluded(this._lngLat);if(!e||t){let e=t?this._opacityWhenCovered:this._opacity;this._element.style.opacity!==e&&(this._element.style.opacity=e,this._element.classList.toggle("maplibregl-marker-covered",t))}else this._updateCovered()}_isInViewport(){let{width:e,height:t}=this._map._camera.transform;return!!this._pos&&this._pos.x>=0&&this._pos.y>=0&&this._pos.x<=e&&this._pos.y<=t}_isCovered(e){let t=this._map._camera.transform,i=e.getElevationForLngLat(this._lngLat,t.tileZoom),r=Math.max(0,-this._offset.y)/t.pixelsPerMeter,a=Math.sin(this._map.getPitch()*Math.PI/180)*r;return t.isLocationOccluded(this._lngLat,e,i+a)}getOffset(){return this._offset}setOffset(e){return this._offset=d.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(),this}},GE={positionOptions:{enableHighAccuracy:!1,maximumAge:0,timeout:6e3},fitBoundsOptions:{maxZoom:15},trackUserLocation:!1,showAccuracyCircle:!0,showUserLocation:!0,zoomToUserAccuracy:!0},ZE=0,qE=!1,WE=class extends Lt{},HE=class extends Lt{},XE=class extends Lt{},YE=class extends Ot{constructor(e){super(),this._onSuccess=e=>{if(this._map)if(this._isOutOfMapMaxBounds(e))this._setErrorState(),this.fire(new HE("outofmaxbounds",e)),this._updateMarker(),this._finish();else{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 HE("geolocate",e)),this._finish()}},this._updateCamera=e=>{let t=new Kc(e.coords.longitude,e.coords.latitude),i=this._map.getBearing(),r={geolocateSource:!0};if(!this.options.zoomToUserAccuracy){let e=Ee({},this.options.fitBoundsOptions,{center:t,bearing:i,zoom:this._map.getZoom()});return void(e.linear?this._map.easeTo(e,r):this._map.flyTo(e,r))}let a=e.coords.accuracy,n=Ee({bearing:i},this.options.fitBoundsOptions),o=c_.fromLngLat(t,a);this._map.fitBounds(o,n,r)},this._updateMarker=e=>{if(e){let t=new Kc(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&&qE)return;this._setErrorState()}"OFF"!==this._watchState&&this.options.showUserLocation&&this._dotElement.classList.add("maplibregl-user-location-dot-stale"),this.fire(new XE("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 WE("trackuserlocationend")),this.fire(new WE("userlocationlostfocus")))},this._setupUI=()=>{this._map&&(this._container.addEventListener("contextmenu",e=>{e.preventDefault()}),this._geolocateButton=wt.create("button","maplibregl-ctrl-geolocate",this._container),wt.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){Oe("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=wt.create("div","maplibregl-user-location-dot"),this._userLocationDotMarker=new $E({element:this._dotElement}),this._circleElement=wt.create("div","maplibregl-user-location-accuracy-circle"),this._accuracyCircleMarker=new $E({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=Ee({},GE,e)}onAdd(e){return this._map=e,this._container=wt.create("div","maplibregl-ctrl maplibregl-ctrl-group"),this._setupUI(),async function(e=!1){if(void 0!==DE&&!e)return DE;if(void 0===window.navigator.permissions)return DE=!!window.navigator.geolocation;try{DE="denied"!==(await window.navigator.permissions.query({name:"geolocation"})).state}catch{DE=!!window.navigator.geolocation}return DE}().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,ZE=0,qE=!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 Oe("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 WE("trackuserlocationstart"));break;case"WAITING_ACTIVE":case"ACTIVE_LOCK":case"ACTIVE_ERROR":case"BACKGROUND_ERROR":ZE--,qE=!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 WE("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 WE("trackuserlocationstart")),this.fire(new WE("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"),++ZE>1?(e={maximumAge:6e5,timeout:0},qE=!0):(e=this.options.positionOptions,qE=!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)}},KE={maxWidth:100,unit:"metric"},JE=class{constructor(e){this._onMove=()=>{QE(this._map,this._container,this.options)},this.setUnit=e=>{this.options.unit=e,this._map&&QE(this._map,this._container,this.options)},this.options={...KE,...e}}getDefaultPosition(){return"bottom-left"}onAdd(e){return this._map=e,this._container=wt.create("div","maplibregl-ctrl maplibregl-ctrl-scale",e.getContainer()),this._map.on("move",this._onMove),this._map.on("projectiontransition",this._onMove),this._onMove(),this._container}onRemove(){this._container.remove(),this._map.off("move",this._onMove),this._map.off("projectiontransition",this._onMove),this._map=void 0}};function QE(e,t,i){let r=i?.maxWidth||100,{width:a,height:n}=e._camera.transform,o=n/2,s=a/2,l=e.unproject([s-r/2,o]),u=e.unproject([s+r/2,o]);if(!l||!u)return;let h=Math.round(e.project(u).x-e.project(l).x),c=Math.min(r,h,a),d=l.distanceTo(u);if("imperial"===i?.unit){let i=3.2808*d;i>5280?eC(t,c,i/5280,e._getUIString("ScaleControl.Miles")):eC(t,c,i,e._getUIString("ScaleControl.Feet"))}else"nautical"===i?.unit?eC(t,c,d/1852,e._getUIString("ScaleControl.NauticalMiles")):d>=1e3?eC(t,c,d/1e3,e._getUIString("ScaleControl.Kilometers")):eC(t,c,d,e._getUIString("ScaleControl.Meters"))}function eC(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";let o=`${a} ${r}`;e.textContent!==o&&(e.textContent=o)}var tC=class extends Lt{},iC=class extends Ot{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:Oe("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=wt.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=wt.create("button","maplibregl-ctrl-fullscreen",this._controlContainer);wt.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 tC("fullscreenstart")),this._prevCooperativeGesturesEnabled=this._map.cooperativeGestures.isEnabled(),this._map.cooperativeGestures.disable()):(this.fire(new tC("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()}},rC=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=wt.create("div","maplibregl-ctrl maplibregl-ctrl-group"),this._terrainButton=wt.create("button","maplibregl-ctrl-terrain",this._container),wt.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}},aC=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=wt.create("div","maplibregl-ctrl maplibregl-ctrl-group"),this._globeButton=wt.create("button","maplibregl-ctrl-globe",this._container),wt.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}},nC={closeButton:!0,closeOnClick:!0,focusAfterOpen:!0,className:"",maxWidth:"240px",subpixelPositioning:!1,locationOccludedOpacity:void 0,padding:void 0},oC=["a[href]","[tabindex]:not([tabindex='-1'])","[contenteditable]:not([contenteditable='false'])","button:not([disabled])","input:not([disabled])","select:not([disabled])","textarea:not([disabled])"].join(", "),sC=class extends Lt{},lC=class extends Ot{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("idle",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 sC("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=wt.create("div","maplibregl-popup",this._map.getContainer()),this._tip=wt.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=kE(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=uC(this.options.offset);if(!a){let e,t=this._container.offsetWidth,i=this._container.offsetHeight,o=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+o.top?["top"]:r.y>this._map._camera.transform.height-i-o.bottom?["bottom"]:[],r.x<t/2+o.left?e.push("left"):r.x>this._map._camera.transform.width-t/2-o.right&&e.push("right"),a=0===e.length?"bottom":e.join("-")}let o=r.add(n[a]);this.options.subpixelPositioning||(o=o.round()),this._container.style.transform=`${RE[a]} translate(${o.x}px,${o.y}px)`,LE(this._container,a,"popup"),this._updateOpacity()},this._onClose=()=>{this.remove()},this.options=Ee(Object.create(nC),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._map.on("idle",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 sC("open")),this}isOpen(){return!!this._map}getLngLat(){return this._lngLat}setLngLat(e){return this._lngLat=Kc.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=wt.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=wt.create("button","maplibregl-popup-close-button",this._content),this._closeButton.type="button",this._closeButton.textContent="×",this._closeButton.addEventListener("click",this._onClose))}_focusFirstElement(){if(!this.options.focusAfterOpen||!this._container)return;let e=this._container.querySelector(oC);e&&e.focus()}};function uC(e){if(!e)return uC(new d(0,0));if("number"==typeof e){let t=Math.round(Math.abs(e)/Math.SQRT2);return{center:new d(0,0),top:new d(0,e),"top-left":new d(t,t),"top-right":new d(-t,t),bottom:new d(0,-e),"bottom-left":new d(t,-t),"bottom-right":new d(-t,-t),left:new d(e,0),right:new d(-e,0)}}if(e instanceof d||Array.isArray(e)){let t=d.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:d.convert(e.center||[0,0]),top:d.convert(e.top||[0,0]),"top-left":d.convert(e["top-left"]||[0,0]),"top-right":d.convert(e["top-right"]||[0,0]),bottom:d.convert(e.bottom||[0,0]),"bottom-left":d.convert(e["bottom-left"]||[0,0]),"bottom-right":d.convert(e["bottom-right"]||[0,0]),left:d.convert(e.left||[0,0]),right:d.convert(e.right||[0,0])}}var hC=c;function cC(e,t){return kv().setRTLTextPlugin(e,t)}function dC(){return kv().getRTLTextPluginStatus()}function pC(){return hC}function fC(){return Uo.workerCount}function mC(e){Uo.workerCount=e}function _C(){return Tt.MAX_PARALLEL_IMAGE_REQUESTS}function gC(e){Tt.MAX_PARALLEL_IMAGE_REQUESTS=e}function yC(){return Tt.WORKER_URL}function vC(e){Tt.WORKER_URL=e}async function xC(e){await Yo().importScript(e)}export{Pt as AJAXError,fE as AttributionControl,bD as BoxZoomHandler,J_ as CanvasSource,eE as CooperativeGesturesHandler,HD as DoubleClickZoomHandler,KD as DragPanHandler,JD as DragRotateHandler,re as EXTENT,pb as EdgeInsets,Bt as ErrorEvent,Lt as Event,Ot as Evented,iC as FullscreenControl,tC as FullscreenEvent,sD as GPUInitializationError,B_ as GeoJSONSource,YE as GeolocateControl,XE as GeolocateErrorEvent,WE as GeolocateEvent,HE as GeolocatePositionEvent,aC as GlobeControl,uD as Hash,W_ as ImageSource,GD as KeyboardHandler,Kc as LngLat,c_ as LngLatBounds,mE as LogoControl,IE as Map,IE as MapLibreMap,os as MapBoxZoomEvent,us as MapContextEvent,Jo as MapLibreEvent,rs as MapMouseEvent,Qo as MapMovementEvent,ls as MapProjectionEvent,is as MapSourceDataEvent,ts as MapStyleDataEvent,hs as MapStyleImageMissingEvent,es as MapStyleLoadEvent,ss as MapTerrainEvent,as as MapTouchEvent,ns as MapWheelEvent,$E as Marker,UE as MarkerClickEvent,NE as MarkerDragEvent,ld as MercatorCoordinate,FE as NavigationControl,d as Point,lC as Popup,sC as PopupEvent,w_ as RasterDEMTileSource,f_ as RasterTileSource,JE as ScaleControl,WD as ScrollZoomHandler,bw as Style,rC as TerrainControl,UD as TwoFingersTouchPitchHandler,VD as TwoFingersTouchRotateHandler,OD as TwoFingersTouchZoomHandler,QD as TwoFingersTouchZoomRotateHandler,p_ as VectorTileSource,K_ as VideoSource,R_ as addProjection,Dt as addProtocol,tg as addSourceType,qo as clearPrewarmedResources,Tt as config,q_ as createTileMesh,Yo as getGlobalDispatcher,_C as getMaxParallelImageRequests,dC as getRTLTextPluginStatus,pC as getVersion,fC as getWorkerCount,yC as getWorkerUrl,xC as importScriptInWorkers,mt as isTimeFrozen,dt as now,Zo as prewarm,L_ as removeProjection,Et as removeProtocol,ft as restoreNow,gC as setMaxParallelImageRequests,pt as setNow,cC as setRTLTextPlugin,mC as setWorkerCount,vC as setWorkerUrl};
|