lecodes-web-player 2.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +75 -0
- package/dist/VERSION.json +5 -0
- package/dist/assets/Roboto-Variable-DHm9jpd-.woff2 +0 -0
- package/dist/assets/camera-5XOM8eHl.js +1 -0
- package/dist/assets/creator-2d-D9WKYM6h.js +1 -0
- package/dist/assets/creator-2d-ukvEmNEp.wasm +0 -0
- package/dist/assets/creator-full-BBXzQlhq.js +1 -0
- package/dist/assets/creator-full-D2dSDdDj.wasm +0 -0
- package/dist/assets/creator-full.js-BYswGsqR.symbols +8124 -0
- package/dist/assets/creator-ui-DIc92ion.wasm +0 -0
- package/dist/assets/creator-ui-_1Z_AX2M.js +1 -0
- package/dist/assets/geolocation-BjTKN9_P.js +1 -0
- package/dist/assets/inspect-C7x78PNs.js +2 -0
- package/dist/assets/map-CyBxOSV0.js +1 -0
- package/dist/assets/map-XzoOFt0E.js +2 -0
- package/dist/assets/mapImpl-bxvQ2h1Z.js +823 -0
- package/dist/assets/maplibre-gl-worker-B7LXXUkR.js +8 -0
- package/dist/assets/materials-uri4FvPE.bin +0 -0
- package/dist/assets/materials-world-CQWt8TAm.bin +0 -0
- package/dist/assets/neutral_ibl128-D-lzdkLN.ktx +0 -0
- package/dist/assets/qr-scanner-CK_cYoJR.js +1 -0
- package/dist/assets/uberarchive-uXjRYa9p.bin +0 -0
- package/dist/index.html +36 -0
- package/dist/player.js +21 -0
- package/package.json +34 -0
|
@@ -0,0 +1,823 @@
|
|
|
1
|
+
import{M as Fp}from"./map-XzoOFt0E.js";import"../player.js";/**
|
|
2
|
+
* MapLibre GL JS
|
|
3
|
+
* @license 3-Clause BSD. Full text of license: https://github.com/maplibre/maplibre-gl-js/blob/v6.11.2/LICENSE.txt
|
|
4
|
+
*/var Ix=Object.create,Bg=Object.defineProperty,Mx=Object.getOwnPropertyDescriptor,zx=Object.getOwnPropertyNames,Fx=Object.getPrototypeOf,Rx=Object.prototype.hasOwnProperty,Vc=(e,t)=>()=>(t||(e((t={exports:{}}).exports,t),e=null),t.exports),kx=(e,t,r,i)=>{if(t&&typeof t=="object"||typeof t=="function")for(var a=zx(t),n=0,s=a.length,o;n<s;n++)o=a[n],!Rx.call(e,o)&&o!==r&&Bg(e,o,{get:(l=>t[l]).bind(null,o),enumerable:!(i=Mx(t,o))||i.enumerable});return e},Lx=(e,t,r)=>(r=e==null?{}:Ix(Fx(e)),kx(Bg(r,"default",{value:e,enumerable:!0}),e));function M(e,t){this.x=e,this.y=t}M.prototype={clone(){return new M(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,r=e.y-this.y;return t*t+r*r},angle(){return Math.atan2(this.y,this.x)},angleTo(e){return Math.atan2(this.y-e.y,this.x-e.x)},angleWith(e){return this.angleWithSep(e.x,e.y)},angleWithSep(e,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,r=e[2]*this.x+e[3]*this.y;return this.x=t,this.y=r,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),r=Math.sin(e),i=t*this.x-r*this.y,a=r*this.x+t*this.y;return this.x=i,this.y=a,this},_rotateAround(e,t){let r=Math.cos(e),i=Math.sin(e),a=t.x+r*(this.x-t.x)-i*(this.y-t.y),n=t.y+i*(this.x-t.x)+r*(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:M},M.convert=function(e){if(e instanceof M)return e;if(Array.isArray(e))return new M(+e[0],+e[1]);if(e.x!==void 0&&e.y!==void 0)return new M(+e.x,+e.y);throw Error("Expected [x, y] or {x, y} point format")};function Bx(e,t,r,i){let a=3*e,n=3*(r-e)-a,s=1-a-n,o=3*t,l=3*(i-t)-o,u=1-o-l;return function(h,c=1e-6){if(h<=0)return 0;if(h>=1)return 1;let d=h;for(let m=0;m<8;m++){let g=((s*d+n)*d+a)*d-h;if(Math.abs(g)<c)return((u*d+l)*d+o)*d;let _=(3*s*d+2*n)*d+a;if(Math.abs(_)<1e-6)break;d-=g/_}let p=0,f=1;d=h;for(let m=0;m<20;m++){let g=((s*d+n)*d+a)*d;if(Math.abs(g-h)<c)break;h>g?p=d:f=d,d=(p+f)*.5}return((u*d+l)*d+o)*d}}let Rp;function Nc(){return Rp??(Rp=typeof OffscreenCanvas<"u"&&!!new OffscreenCanvas(1,1).getContext("2d")&&typeof createImageBitmap=="function"),Rp}let js;function Og(){if(js==null&&(js=!1,Nc())){let e=new OffscreenCanvas(5,5).getContext("2d",{willReadFrequently:!0});if(e){for(let r=0;r<25;r++){let i=r*4;e.fillStyle=`rgb(${i},${i+1},${i+2})`,e.fillRect(r%5,Math.floor(r/5),1,1)}let t=e.getImageData(0,0,5,5).data;for(let r=0;r<100;r++)if(r%4!=3&&t[r]!==r){js=!0;break}}}return js||!1}var _t=typeof Float32Array<"u"?Float32Array:Array;function $g(){var e=new _t(9);return _t!=Float32Array&&(e[1]=0,e[2]=0,e[3]=0,e[5]=0,e[6]=0,e[7]=0),e[0]=1,e[4]=1,e[8]=1,e}function Ox(e){var t=e[0],r=e[1],i=e[2],a=e[3],n=e[4],s=e[5],o=e[6],l=e[7],u=e[8];return t*(u*n-s*l)+r*(-u*a+s*o)+i*(l*a-n*o)}function $x(e,t){var r=Math.sin(t),i=Math.cos(t);return e[0]=i,e[1]=r,e[2]=0,e[3]=-r,e[4]=i,e[5]=0,e[6]=0,e[7]=0,e[8]=1,e}function jx(e,t){var r=t[0],i=t[1],a=t[2],n=t[3],s=r+r,o=i+i,l=a+a,u=r*s,h=i*s,c=i*o,d=a*s,p=a*o,f=a*l,m=n*s,g=n*o,_=n*l;return e[0]=1-c-f,e[3]=h-_,e[6]=d+g,e[1]=h+_,e[4]=1-u-f,e[7]=p-m,e[2]=d-g,e[5]=p+m,e[8]=1-u-c,e}function Pi(){var e=new _t(16);return _t!=Float32Array&&(e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[6]=0,e[7]=0,e[8]=0,e[9]=0,e[11]=0,e[12]=0,e[13]=0,e[14]=0),e[0]=1,e[5]=1,e[10]=1,e[15]=1,e}function ch(e){var t=new _t(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 Vx(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],e}function Pr(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 Bo(e,t){var r=t[0],i=t[1],a=t[2],n=t[3],s=t[4],o=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],g=t[14],_=t[15],y=r*o-i*s,v=r*l-a*s,x=r*u-n*s,w=i*l-a*o,b=i*u-n*o,S=a*u-n*l,A=h*m-c*f,P=h*g-d*f,I=h*_-p*f,R=c*g-d*m,F=c*_-p*m,T=d*_-p*g,E=y*T-v*F+x*R+w*I-b*P+S*A;return E?(E=1/E,e[0]=(o*T-l*F+u*R)*E,e[1]=(a*F-i*T-n*R)*E,e[2]=(m*S-g*b+_*w)*E,e[3]=(d*b-c*S-p*w)*E,e[4]=(l*I-s*T-u*P)*E,e[5]=(r*T-a*I+n*P)*E,e[6]=(g*x-f*S-_*v)*E,e[7]=(h*S-d*x+p*v)*E,e[8]=(s*F-o*I+u*A)*E,e[9]=(i*I-r*F-n*A)*E,e[10]=(f*b-m*x+_*y)*E,e[11]=(c*x-h*b-p*y)*E,e[12]=(o*P-s*R-l*A)*E,e[13]=(r*R-i*P+a*A)*E,e[14]=(m*v-f*w-g*y)*E,e[15]=(h*w-c*v+d*y)*E,e):null}function ba(e,t,r){var i=t[0],a=t[1],n=t[2],s=t[3],o=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],g=t[13],_=t[14],y=t[15],v=r[0],x=r[1],w=r[2],b=r[3];return e[0]=v*i+x*o+w*c+b*m,e[1]=v*a+x*l+w*d+b*g,e[2]=v*n+x*u+w*p+b*_,e[3]=v*s+x*h+w*f+b*y,v=r[4],x=r[5],w=r[6],b=r[7],e[4]=v*i+x*o+w*c+b*m,e[5]=v*a+x*l+w*d+b*g,e[6]=v*n+x*u+w*p+b*_,e[7]=v*s+x*h+w*f+b*y,v=r[8],x=r[9],w=r[10],b=r[11],e[8]=v*i+x*o+w*c+b*m,e[9]=v*a+x*l+w*d+b*g,e[10]=v*n+x*u+w*p+b*_,e[11]=v*s+x*h+w*f+b*y,v=r[12],x=r[13],w=r[14],b=r[15],e[12]=v*i+x*o+w*c+b*m,e[13]=v*a+x*l+w*d+b*g,e[14]=v*n+x*u+w*p+b*_,e[15]=v*s+x*h+w*f+b*y,e}function ot(e,t,r){var i=r[0],a=r[1],n=r[2],s,o,l,u,h,c,d,p,f,m,g,_;return t===e?(e[12]=t[0]*i+t[4]*a+t[8]*n+t[12],e[13]=t[1]*i+t[5]*a+t[9]*n+t[13],e[14]=t[2]*i+t[6]*a+t[10]*n+t[14],e[15]=t[3]*i+t[7]*a+t[11]*n+t[15]):(s=t[0],o=t[1],l=t[2],u=t[3],h=t[4],c=t[5],d=t[6],p=t[7],f=t[8],m=t[9],g=t[10],_=t[11],e[0]=s,e[1]=o,e[2]=l,e[3]=u,e[4]=h,e[5]=c,e[6]=d,e[7]=p,e[8]=f,e[9]=m,e[10]=g,e[11]=_,e[12]=s*i+h*a+f*n+t[12],e[13]=o*i+c*a+m*n+t[13],e[14]=l*i+d*a+g*n+t[14],e[15]=u*i+p*a+_*n+t[15]),e}function Et(e,t,r){var i=r[0],a=r[1],n=r[2];return e[0]=t[0]*i,e[1]=t[1]*i,e[2]=t[2]*i,e[3]=t[3]*i,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 Oa(e,t,r){var i=Math.sin(r),a=Math.cos(r),n=t[4],s=t[5],o=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*i,e[5]=s*a+h*i,e[6]=o*a+c*i,e[7]=l*a+d*i,e[8]=u*a-n*i,e[9]=h*a-s*i,e[10]=c*a-o*i,e[11]=d*a-l*i,e}function jg(e,t,r){var i=Math.sin(r),a=Math.cos(r),n=t[0],s=t[1],o=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*i,e[1]=s*a-h*i,e[2]=o*a-c*i,e[3]=l*a-d*i,e[8]=n*i+u*a,e[9]=s*i+h*a,e[10]=o*i+c*a,e[11]=l*i+d*a,e}function yi(e,t,r){var i=Math.sin(r),a=Math.cos(r),n=t[0],s=t[1],o=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*i,e[1]=s*a+h*i,e[2]=o*a+c*i,e[3]=l*a+d*i,e[4]=u*a-n*i,e[5]=h*a-s*i,e[6]=c*a-o*i,e[7]=d*a-l*i,e}function Nx(e,t){return e[0]=t[0],e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[5]=t[1],e[6]=0,e[7]=0,e[8]=0,e[9]=0,e[10]=t[2],e[11]=0,e[12]=0,e[13]=0,e[14]=0,e[15]=1,e}function Ux(e,t,r,i,a){var n=1/Math.tan(t/2);if(e[0]=n/r,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,a!=null&&a!==1/0){var s=1/(i-a);e[10]=(a+i)*s,e[14]=2*a*i*s}else e[10]=-1,e[14]=-2*i;return e}var dh=Ux;function Gx(e,t,r,i,a,n,s){var o=1/(t-r),l=1/(i-a),u=1/(n-s);return e[0]=-2*o,e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[5]=-2*l,e[6]=0,e[7]=0,e[8]=0,e[9]=0,e[10]=2*u,e[11]=0,e[12]=(t+r)*o,e[13]=(a+i)*l,e[14]=(s+n)*u,e[15]=1,e}var Lr=Gx;function qx(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]}function Zx(e,t){var r=e[0],i=e[1],a=e[2],n=e[3],s=e[4],o=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],g=e[14],_=e[15],y=t[0],v=t[1],x=t[2],w=t[3],b=t[4],S=t[5],A=t[6],P=t[7],I=t[8],R=t[9],F=t[10],T=t[11],E=t[12],D=t[13],C=t[14],k=t[15];return Math.abs(r-y)<=1e-6*Math.max(1,Math.abs(r),Math.abs(y))&&Math.abs(i-v)<=1e-6*Math.max(1,Math.abs(i),Math.abs(v))&&Math.abs(a-x)<=1e-6*Math.max(1,Math.abs(a),Math.abs(x))&&Math.abs(n-w)<=1e-6*Math.max(1,Math.abs(n),Math.abs(w))&&Math.abs(s-b)<=1e-6*Math.max(1,Math.abs(s),Math.abs(b))&&Math.abs(o-S)<=1e-6*Math.max(1,Math.abs(o),Math.abs(S))&&Math.abs(l-A)<=1e-6*Math.max(1,Math.abs(l),Math.abs(A))&&Math.abs(u-P)<=1e-6*Math.max(1,Math.abs(u),Math.abs(P))&&Math.abs(h-I)<=1e-6*Math.max(1,Math.abs(h),Math.abs(I))&&Math.abs(c-R)<=1e-6*Math.max(1,Math.abs(c),Math.abs(R))&&Math.abs(d-F)<=1e-6*Math.max(1,Math.abs(d),Math.abs(F))&&Math.abs(p-T)<=1e-6*Math.max(1,Math.abs(p),Math.abs(T))&&Math.abs(f-E)<=1e-6*Math.max(1,Math.abs(f),Math.abs(E))&&Math.abs(m-D)<=1e-6*Math.max(1,Math.abs(m),Math.abs(D))&&Math.abs(g-C)<=1e-6*Math.max(1,Math.abs(g),Math.abs(C))&&Math.abs(_-k)<=1e-6*Math.max(1,Math.abs(_),Math.abs(k))}function Vg(){var e=new _t(3);return _t!=Float32Array&&(e[0]=0,e[1]=0,e[2]=0),e}function ph(e){var t=new _t(3);return t[0]=e[0],t[1]=e[1],t[2]=e[2],t}function Sr(e){var t=e[0],r=e[1],i=e[2];return Math.sqrt(t*t+r*r+i*i)}function kp(e,t,r){var i=new _t(3);return i[0]=e,i[1]=t,i[2]=r,i}function pr(e,t,r){return e[0]=t[0]+r[0],e[1]=t[1]+r[1],e[2]=t[2]+r[2],e}function Uc(e,t,r){return e[0]=t[0]-r[0],e[1]=t[1]-r[1],e[2]=t[2]-r[2],e}function Ve(e,t,r){return e[0]=t[0]*r,e[1]=t[1]*r,e[2]=t[2]*r,e}function Oo(e,t,r,i){return e[0]=t[0]+r[0]*i,e[1]=t[1]+r[1]*i,e[2]=t[2]+r[2]*i,e}function Wx(e,t){var r=t[0]-e[0],i=t[1]-e[1],a=t[2]-e[2];return Math.sqrt(r*r+i*i+a*a)}function Hx(e,t){return e[0]=-t[0],e[1]=-t[1],e[2]=-t[2],e}function Bt(e,t){var r=t[0],i=t[1],a=t[2],n=r*r+i*i+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 lt(e,t){return e[0]*t[0]+e[1]*t[1]+e[2]*t[2]}function Ht(e,t,r){var i=t[0],a=t[1],n=t[2],s=r[0],o=r[1],l=r[2];return e[0]=a*l-n*o,e[1]=n*s-i*l,e[2]=i*o-a*s,e}function Xx(e,t,r){var i=t[0],a=t[1],n=t[2],s=r[3]*i+r[7]*a+r[11]*n+r[15];return s||(s=1),e[0]=(r[0]*i+r[4]*a+r[8]*n+r[12])/s,e[1]=(r[1]*i+r[5]*a+r[9]*n+r[13])/s,e[2]=(r[2]*i+r[6]*a+r[10]*n+r[14])/s,e}function Yx(e,t,r){var i=t[0],a=t[1],n=t[2];return e[0]=i*r[0]+a*r[3]+n*r[6],e[1]=i*r[1]+a*r[4]+n*r[7],e[2]=i*r[2]+a*r[5]+n*r[8],e}function wu(e,t,r){var i=r[0],a=r[1],n=r[2],s=r[3],o=t[0],l=t[1],u=t[2],h=a*u-n*l,c=n*o-i*u,d=i*l-a*o;return h+=h,c+=c,d+=d,e[0]=o+s*h+a*d-n*c,e[1]=l+s*c+n*h-i*d,e[2]=u+s*d+i*c-a*h,e}function dn(e,t,r,i){var a=[],n=[];return a[0]=t[0]-r[0],a[1]=t[1]-r[1],a[2]=t[2]-r[2],n[0]=a[0],n[1]=a[1]*Math.cos(i)-a[2]*Math.sin(i),n[2]=a[1]*Math.sin(i)+a[2]*Math.cos(i),e[0]=n[0]+r[0],e[1]=n[1]+r[1],e[2]=n[2]+r[2],e}function ga(e,t,r,i){var a=[],n=[];return a[0]=t[0]-r[0],a[1]=t[1]-r[1],a[2]=t[2]-r[2],n[0]=a[2]*Math.sin(i)+a[0]*Math.cos(i),n[1]=a[1],n[2]=a[2]*Math.cos(i)-a[0]*Math.sin(i),e[0]=n[0]+r[0],e[1]=n[1]+r[1],e[2]=n[2]+r[2],e}function Tu(e,t,r,i){var a=[],n=[];return a[0]=t[0]-r[0],a[1]=t[1]-r[1],a[2]=t[2]-r[2],n[0]=a[0]*Math.cos(i)-a[1]*Math.sin(i),n[1]=a[0]*Math.sin(i)+a[1]*Math.cos(i),n[2]=a[2],e[0]=n[0]+r[0],e[1]=n[1]+r[1],e[2]=n[2]+r[2],e}function Kx(e){return e[0]=0,e[1]=0,e[2]=0,e}var li=Uc,$o=Sr;(function(){var e=Vg();return function(t,r,i,a,n,s){var o,l;for(r||(r=3),i||(i=0),l=a?Math.min(a*r+i,t.length):t.length,o=i;o<l;o+=r)e[0]=t[o],e[1]=t[o+1],e[2]=t[o+2],n(e,e,s),t[o]=e[0],t[o+1]=e[1],t[o+2]=e[2];return t}})();function Jx(){var e=new _t(4);return _t!=Float32Array&&(e[0]=0,e[1]=0,e[2]=0,e[3]=0),e}function Qx(e,t,r,i){var a=new _t(4);return a[0]=e,a[1]=t,a[2]=r,a[3]=i,a}function ev(e,t,r){return e[0]=t[0]*r[0],e[1]=t[1]*r[1],e[2]=t[2]*r[2],e[3]=t[3]*r[3],e}function tv(e,t,r){return e[0]=t[0]*r,e[1]=t[1]*r,e[2]=t[2]*r,e[3]=t[3]*r,e}function rv(e,t){var r=t[0],i=t[1],a=t[2],n=t[3],s=r*r+i*i+a*a+n*n;return s>0&&(s=1/Math.sqrt(s)),e[0]=r*s,e[1]=i*s,e[2]=a*s,e[3]=n*s,e}function Pt(e,t,r){var i=t[0],a=t[1],n=t[2],s=t[3];return e[0]=r[0]*i+r[4]*a+r[8]*n+r[12]*s,e[1]=r[1]*i+r[5]*a+r[9]*n+r[13]*s,e[2]=r[2]*i+r[6]*a+r[10]*n+r[14]*s,e[3]=r[3]*i+r[7]*a+r[11]*n+r[15]*s,e}var iv=ev;(function(){var e=Jx();return function(t,r,i,a,n,s){var o,l;for(r||(r=4),i||(i=0),l=a?Math.min(a*r+i,t.length):t.length,o=i;o<l;o+=r)e[0]=t[o],e[1]=t[o+1],e[2]=t[o+2],e[3]=t[o+3],n(e,e,s),t[o]=e[0],t[o+1]=e[1],t[o+2]=e[2],t[o+3]=e[3];return t}})();function Lp(){var e=new _t(4);return _t!=Float32Array&&(e[0]=0,e[1]=0,e[2]=0),e[3]=1,e}function av(e,t,r){r*=.5;var i=Math.sin(r);return e[0]=i*t[0],e[1]=i*t[1],e[2]=i*t[2],e[3]=Math.cos(r),e}function nv(e,t,r){var i=t[0],a=t[1],n=t[2],s=t[3],o=r[0],l=r[1],u=r[2],h=r[3];return e[0]=i*h+s*o+a*u-n*l,e[1]=a*h+s*l+n*o-i*u,e[2]=n*h+s*u+i*l-a*o,e[3]=s*h-i*o-a*l-n*u,e}function To(e,t,r,i){var a=t[0],n=t[1],s=t[2],o=t[3],l=r[0],u=r[1],h=r[2],c=r[3],d,p=a*l+n*u+s*h+o*c,f,m,g;return p<0&&(p=-p,l=-l,u=-u,h=-h,c=-c),1-p>1e-6?(d=Math.acos(p),f=Math.sin(d),m=Math.sin((1-i)*d)/f,g=Math.sin(i*d)/f):(m=1-i,g=i),e[0]=m*a+g*l,e[1]=m*n+g*u,e[2]=m*s+g*h,e[3]=m*o+g*c,e}function sv(e,t){var r=t[0]+t[4]+t[8],i;if(r>0)i=Math.sqrt(r+1),e[3]=.5*i,i=.5/i,e[0]=(t[5]-t[7])*i,e[1]=(t[6]-t[2])*i,e[2]=(t[1]-t[3])*i;else{var a=0;t[4]>t[0]&&(a=1),t[8]>t[a*3+a]&&(a=2);var n=(a+1)%3,s=(a+2)%3;i=Math.sqrt(t[a*3+a]-t[n*3+n]-t[s*3+s]+1),e[a]=.5*i,i=.5/i,e[3]=(t[n*3+s]-t[s*3+n])*i,e[n]=(t[n*3+a]+t[a*3+n])*i,e[s]=(t[s*3+a]+t[a*3+s])*i}return e}function Gc(e,t,r,i){var a=arguments.length>4&&arguments[4]!==void 0?arguments[4]:"zyx",n=Math.PI/360;t*=n,i*=n,r*=n;var s=Math.sin(t),o=Math.cos(t),l=Math.sin(r),u=Math.cos(r),h=Math.sin(i),c=Math.cos(i);switch(a){case"xyz":e[0]=s*u*c+o*l*h,e[1]=o*l*c-s*u*h,e[2]=o*u*h+s*l*c,e[3]=o*u*c-s*l*h;break;case"xzy":e[0]=s*u*c-o*l*h,e[1]=o*l*c-s*u*h,e[2]=o*u*h+s*l*c,e[3]=o*u*c+s*l*h;break;case"yxz":e[0]=s*u*c+o*l*h,e[1]=o*l*c-s*u*h,e[2]=o*u*h-s*l*c,e[3]=o*u*c+s*l*h;break;case"yzx":e[0]=s*u*c+o*l*h,e[1]=o*l*c+s*u*h,e[2]=o*u*h-s*l*c,e[3]=o*u*c-s*l*h;break;case"zxy":e[0]=s*u*c-o*l*h,e[1]=o*l*c+s*u*h,e[2]=o*u*h+s*l*c,e[3]=o*u*c-s*l*h;break;case"zyx":e[0]=s*u*c-o*l*h,e[1]=o*l*c+s*u*h,e[2]=o*u*h-s*l*c,e[3]=o*u*c+s*l*h;break;default:throw Error("Unknown angle order "+a)}return e}var Bp=Qx,Op=rv;(function(){var e=Vg(),t=kp(1,0,0),r=kp(0,1,0);return function(i,a,n){var s=lt(a,n);return s<-.999999?(Ht(e,t,a),$o(e)<1e-6&&Ht(e,r,a),Bt(e,e),av(i,e,Math.PI),i):s>.999999?(i[0]=0,i[1]=0,i[2]=0,i[3]=1,i):(Ht(e,a,n),i[0]=e[0],i[1]=e[1],i[2]=e[2],i[3]=1+s,Op(i,i))}})(),(function(){var e=Lp(),t=Lp();return function(r,i,a,n,s,o){return To(e,i,s,o),To(t,a,n,o),To(r,e,t,2*o*(1-o)),r}})(),(function(){var e=$g();return function(t,r,i,a){return e[0]=i[0],e[3]=i[1],e[6]=i[2],e[1]=a[0],e[4]=a[1],e[7]=a[2],e[2]=-r[0],e[5]=-r[1],e[8]=-r[2],Op(t,sv(t,e))}})();function fh(){var e=new _t(2);return _t!=Float32Array&&(e[0]=0,e[1]=0),e}function $p(e,t){var r=new _t(2);return r[0]=e,r[1]=t,r}function jp(e,t,r){return e[0]=t[0]*r,e[1]=t[1]*r,e}function Vp(e){var t=e[0],r=e[1];return Math.sqrt(t*t+r*r)}function ov(e){var t=e[0],r=e[1];return t*t+r*r}function lv(e,t){return e[0]*t[0]+e[1]*t[1]}function Np(e){return e[0]=0,e[1]=0,e}var uv=ov;(function(){var e=fh();return function(t,r,i,a,n,s){var o,l;for(r||(r=2),i||(i=0),l=a?Math.min(a*r+i,t.length):t.length,o=i;o<l;o+=r)e[0]=t[o],e[1]=t[o+1],n(e,e,s),t[o]=e[0],t[o+1]=e[1];return t}})();const L=8192;function nr(e,t,r){return t*(L/(e.tileSize*2**(r-e.tileID.overscaledZ)))}function zt(e){return e instanceof Error?e:Error(typeof e=="string"?e:String(e))}function Li(){return new Float64Array(4)}function Pe(){return new Float64Array(3)}function Bi(){return new Float64Array(16)}function Vs(){let e=new Float64Array(16);return Pr(e),e}function Ng(){let e=new Float32Array(16);return Pr(e),e}function Ti(e,t,r,i,a=!1){if(!r[0]&&!r[1])return[0,0];let n=a?i==="map"?-e.bearingInRadians:0:i==="viewport"?e.bearingInRadians:0;if(n){let s=Math.sin(n),o=Math.cos(n);r=[r[0]*o-r[1]*s,r[0]*s+r[1]*o]}return[a?r[0]:nr(t,r[0],e.zoom),a?r[1]:nr(t,r[1],e.zoom)]}function mh(e,t){return e[0]*t[0]+e[1]*t[1]+e[2]*t[2]+e[3]}function lr(e,t,r){let i=Ox([e[0],e[1],e[2],t[0],t[1],t[2],r[0],r[1],r[2]]);if(i===0)return null;let a=Ht([],[t[0],t[1],t[2]],[r[0],r[1],r[2]]),n=Ht([],[r[0],r[1],r[2]],[e[0],e[1],e[2]]),s=Ht([],[e[0],e[1],e[2]],[t[0],t[1],t[2]]),o=Ve([],a,-e[3]);return pr(o,o,Ve([],n,-t[3])),pr(o,o,Ve([],s,-r[3])),Ve(o,o,1/i),o}function hv(e,t,r){let i=e[0]*r[0]+e[1]*r[1]+e[2]*r[2],a=t[0]*r[0]+t[1]*r[1]+t[2]*r[2];return a===0?null:(-i-r[3])/a}function Ns(e,t,r,i){let a=Math.sqrt(e*e+t*t),n=Math.sqrt(r*r+i*i);e/=a,t/=a,r/=n,i/=n;let s=e*r+t*i,o=Math.acos(s);return-t*r+e*i>0?o:-o}function er(e,t){let r=Xi(e,360),i=Xi(t,360),a=i-r,n=i>r?a-360:a+360;return Math.abs(a)<Math.abs(n)?a:n}function Us(e,t){let r=Xi(e,Math.PI*2),i=Xi(t,Math.PI*2);return Math.min(Math.abs(r-i),Math.abs(r-i+Math.PI*2),Math.abs(r-i-Math.PI*2))}function Xi(e,t){return(e%t+t)%t}function So(e,t,r,i,a){return Ia(i,a,se((e-t)/(r-t),0,1))}function Ia(e,t,r){return e*(1-r)+t*r}function cv(e){let t=1/0,r=1/0,i=-1/0,a=-1/0;for(let n of e)t=Math.min(t,n.x),r=Math.min(r,n.y),i=Math.max(i,n.x),a=Math.max(a,n.y);return[t,r,i,a]}function dv(e){if(!e.length)return new Set;let t=Math.max(...e.map(l=>l.canonical.z)),r=1/0,i=-1/0,a=1/0,n=-1/0,s=[];for(let l of e){let{x:u,y:h,z:c}=l.canonical,d=2**(t-c),p=u*d,f=h*d;s.push({id:l,x:p,y:f}),p<r&&(r=p),p>i&&(i=p),f<a&&(a=f),f>n&&(n=f)}let o=new Set;for(let l of s)(l.x===r||l.x===i||l.y===a||l.y===n)&&o.add(l.id);return o}function pv(e){if(e<=0)return 0;if(e>=1)return 1;let t=e*e,r=t*e;return 4*(e<.5?r:3*(e-t)+r-.75)}function qc(e,t,r,i){return Bx(e,t,r,i)}const gh=qc(.25,.1,.25,1);function se(e,t,r){return Math.min(r,Math.max(t,e))}function fr(e,t,r){let i=r-t,a=((e-t)%i+i)%i+t;return a===t?r:a}function H(e,...t){for(let r of t)for(let i in r)e[i]=r[i];return e}function os(e,t){let r={};for(let i of t)i in e&&(r[i]=e[i]);return r}let fv=1;function Ug(){return fv++}function mv(e){return Math.log(e)/Math.LN2%1==0}function gv(e){return e<=1?1:2**Math.ceil(Math.log(e)/Math.LN2)}function $t(e){return 2**e}function It(e){return Math.log(e)/Math.LN2}function rr(e,t,r){if(t<=0)return e;let i=1/t;return r===void 0||Math.abs(r)<1e-10?Math.round(e*i)/i:(r>0?Math.ceil(e*i-1e-9):Math.floor(e*i+1e-10))/i}function Zc(e,t,r){let i={};for(let a in e)i[a]=t.call(this,e[a],a,e);return i}function Gg(e,t,r){let i={};for(let a in e)t.call(this,e[a],a,e)&&(i[a]=e[a]);return i}function Br(e,t){if(Array.isArray(e)){if(!Array.isArray(t)||e.length!==t.length)return!1;for(let r=0;r<e.length;r++)if(!Br(e[r],t[r]))return!1;return!0}if(typeof e=="object"&&e&&t!==null){if(typeof t!="object"||Object.keys(e).length!==Object.keys(t).length)return!1;for(let r in e)if(!Br(e[r],t[r]))return!1;return!0}return e===t}function Wt(e){return Array.isArray(e)?e.map(Wt):typeof e=="object"&&e?Zc(e,Wt):e}const Up={};function _e(e){Up[e]||(typeof console<"u"&&console.warn(e),Up[e]=!0)}function xi(e,t,r){return(r.y-e.y)*(t.x-e.x)>(t.y-e.y)*(r.x-e.x)}function _v(e,t,r,i){let a=t.y-e.y,n=t.x-e.x,s=i.y-r.y,o=i.x-r.x,l=s*n-o*a;if(l===0)return null;let u=e.y-r.y,h=e.x-r.x,c=(o*u-s*h)/l;return new M(e.x+c*n,e.y+c*a)}function yv([e,t,r]){return t+=90,t*=Math.PI/180,r*=Math.PI/180,[e*Math.cos(t)*Math.sin(r),e*Math.sin(t)*Math.sin(r),e*Math.cos(r)]}function $a(e){return typeof WorkerGlobalScope<"u"&&e!==void 0&&e instanceof WorkerGlobalScope}function xv(e){let t=/(?:^|(?:\s*\,\s*))([^\x00-\x20\(\)<>@\,;\:\\"\/\[\]\?\=\{\}\x7F]+)(?:\=(?:([^\x00-\x20\(\)<>@\,;\:\\"\/\[\]\?\=\{\}\x7F]+)|(?:\"((?:[^"\\]|\\.)*)\")))?/g,r={};if(e.replace(t,(i,a,n,s)=>{let o=n||s;return r[a]=!o||o.toLowerCase(),""}),r["max-age"]){let i=parseInt(r["max-age"],10);isNaN(i)?delete r["max-age"]:r["max-age"]=i}return r}let Su=null;function vv(e){if(Su==null){let t=e.navigator?e.navigator.userAgent:null;Su=!!e.safari||!!(t&&(/\b(iPad|iPhone|iPod)\b/.test(t)||t.match("Safari")&&!t.match("Chrome")))}return Su}function Ni(e){return typeof ImageBitmap<"u"&&e instanceof ImageBitmap}const bv=async(e,t)=>{let r=new Blob([new Uint8Array(e)],{type:"image/png"});try{return createImageBitmap(r,t)}catch(i){throw Error(`Could not load image because of ${zt(i).message}. Please make sure to use a supported image type such as PNG or JPEG. Note that SVGs are not supported.`)}},wv=e=>new Promise((t,r)=>{let i=new Image;i.onload=()=>{t(i),URL.revokeObjectURL(i.src),i.onload=null,window.requestAnimationFrame(()=>i.src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAAC0lEQVQYV2NgAAIAAAUAAarVyFEAAAAASUVORK5CYII=")},i.onerror=()=>r(Error("Could not load image. Please make sure to use a supported image type such as PNG or JPEG. Note that SVGs are not supported."));let a=new Blob([new Uint8Array(e)],{type:"image/png"});i.src=URL.createObjectURL(a)});function Tv(e,t,r,i,a){let n=Math.max(-t,0)*4,s=(Math.max(0,r)-r)*i*4+n,o=i*4,l=Math.max(0,t),u=Math.max(0,r),h=Math.min(e.width,t+i),c=Math.min(e.height,r+a);return{rect:{x:l,y:u,width:h-l,height:c-u},layout:[{offset:s,stride:o}]}}async function Sv(e,t,r,i,a){if(typeof VideoFrame>"u")throw Error("VideoFrame not supported");let n=new VideoFrame(e,{timestamp:0});try{let s=n==null?void 0:n.format;if(!s||!(s.startsWith("BGR")||s.startsWith("RGB")))throw Error(`Unrecognized format ${s}`);let o=s.startsWith("BGR"),l=new Uint8ClampedArray(i*a*4);if(await n.copyTo(l,Tv(e,t,r,i,a)),o)for(let u=0;u<l.length;u+=4){let h=l[u];l[u]=l[u+2],l[u+2]=h}return l}finally{n.close()}}function jo(e,t,r,i){return e.addEventListener(t,r,i),{unsubscribe:()=>{e.removeEventListener(t,r,i)}}}function Ge(e){return e*Math.PI/180}function $r(e){return e/Math.PI*180}function qg(e,t){return e.roll==t.roll&&e.pitch==t.pitch&&e.bearing==t.bearing}function Dv(e){let t=new Float64Array(9);jx(t,e);let r=$r(-Math.asin(se(t[2],-1,1))),i,a;return Math.hypot(t[5],t[8])<.001?(i=0,a=-$r(Math.atan2(t[3],t[4]))):(i=$r(t[5]===0&&t[8]===0?0:Math.atan2(t[5],t[8])),a=$r(t[1]===0&&t[0]===0?0:Math.atan2(t[1],t[0]))),{roll:i,pitch:r+90,bearing:a}}function Ev(e,t,r){let i=$p(t.x-r.x,t.y-r.y),a=$p(e.x-r.x,e.y-r.y),n=i[0]*a[1]-i[1]*a[0];return $r(Math.atan2(n,lv(i,a)))}function Gp(e,t,r){let i=new Float64Array(4);return Gc(i,e,t-90,r),i}const Gr=85.051129,Zg={touchstart:!0,touchmove:!0,touchmoveWindow:!0,touchend:!0,touchcancel:!0},Wg={dblclick:!0,click:!0,mouseover:!0,mouseout:!0,mousedown:!0,mousemove:!0,mousemoveWindow:!0,mouseup:!0,mouseupWindow:!0,contextmenu:!0,wheel:!0};function Pv(e,t){return Zg[t]&&"touches"in e}function Av(e,t){var a,n;if(!Wg[t])return!1;let r=e,i=((n=(a=r==null?void 0:r.target)==null?void 0:a.ownerDocument)==null?void 0:n.defaultView)||window;return r instanceof i.MouseEvent||r instanceof i.WheelEvent}function Cv(e){return Zg[e]||Wg[e]}const qp="AbortError";var ls=class extends Error{constructor(e=qp){super(e instanceof Error?e.message:e),this.name=qp,e instanceof Error&&e.stack&&(this.stack=e.stack)}};function Si(e){return e instanceof Error&&e.name==="AbortError"}function Wc(e){if(e.aborted)throw new ls(e.reason)}const Yi={MAX_PARALLEL_IMAGE_REQUESTS:16,MAX_PARALLEL_IMAGE_REQUESTS_PER_FRAME:8,MAX_TILE_CACHE_ZOOM_LEVELS:5,REGISTERED_PROTOCOLS:{},WORKER_URL:""};function Hg(e){return Yi.REGISTERED_PROTOCOLS[e.substring(0,e.indexOf("://"))]}const _h="global-dispatcher";var Vo=class extends Error{constructor(e,t,r,i){super(`AJAXError: ${t} (${e}): ${r}`),this.status=e,this.statusText=t,this.url=r,this.body=i}};function Hc(){var e;if($a(self))return(e=self.worker)==null?void 0:e.referrer;if(window.location.protocol==="blob:")try{return window.parent.location.href}catch{}return window.location.href}const Iv=e=>{var t;return e.startsWith("file:")||((t=Hc())==null?void 0:t.startsWith("file:"))&&!/^\w+:/.test(e)};async function Mv(e,t){let r=new Request(e.url,{method:e.method||"GET",body:e.body,credentials:e.credentials,headers:e.headers,cache:e.cache,referrer:Hc(),referrerPolicy:e.referrerPolicy,signal:t.signal});e.type==="json"&&!r.headers.has("Accept")&&r.headers.set("Accept","application/json");let i;try{i=await fetch(r)}catch(s){throw Si(s)?s:new Vo(0,zt(s).message,e.url,new Blob)}if(!i.ok){let s=await i.blob();throw new Vo(i.status,i.statusText,e.url,s)}let a;a=e.type==="arrayBuffer"||e.type==="image"?i.arrayBuffer():e.type==="json"?i.json():i.text();let n=await a;return Wc(t.signal),{data:n,cacheControl:i.headers.get("Cache-Control"),expires:i.headers.get("Expires"),etag:i.headers.get("ETag")}}function zv(e,t){return new Promise((r,i)=>{var n;let a=new XMLHttpRequest;a.open(e.method||"GET",e.url,!0),(e.type==="arrayBuffer"||e.type==="image")&&(a.responseType="arraybuffer");for(let s in e.headers)a.setRequestHeader(s,e.headers[s]);e.type==="json"&&(a.responseType="text",(n=e.headers)!=null&&n.Accept||a.setRequestHeader("Accept","application/json")),a.withCredentials=e.credentials==="include",a.onerror=()=>{i(Error(a.statusText))},a.onload=()=>{if(!t.signal.aborted)if((a.status>=200&&a.status<300||a.status===0)&&a.response!==null){let s=a.response;if(e.type==="json")try{s=JSON.parse(a.response)}catch(o){i(o);return}r({data:s,cacheControl:a.getResponseHeader("Cache-Control"),expires:a.getResponseHeader("Expires"),etag:a.getResponseHeader("ETag")})}else{let s=new Blob([a.response],{type:a.getResponseHeader("Content-Type")});i(new Vo(a.status,a.statusText,e.url,s))}},t.signal.addEventListener("abort",()=>{a.abort(),i(new ls(t.signal.reason))}),a.send(e.body)})}const yl=async function(e,t){var r,i;if(e.url.includes("://")&&!/^https?:|^file:/.test(e.url)){let a=Hg(e.url);if(a){let n=await a(e,t);return!n.data&&e.type==="arrayBuffer"?H(n,{data:new ArrayBuffer(0)}):n}if($a(self)&&((r=self.worker)!=null&&r.actor))return self.worker.actor.sendAsync({type:"GR",data:e,targetMapId:_h},t)}if(!Iv(e.url)){if(fetch&&Request&&AbortController&&Object.hasOwn(Request.prototype,"signal"))return Mv(e,t);if($a(self)&&((i=self.worker)!=null&&i.actor))return self.worker.actor.sendAsync({type:"GR",data:e,mustQueue:!0,targetMapId:_h},t)}return zv(e,t)},xl=(e,t)=>yl(H(e,{type:"json"}),t),Xg=(e,t)=>yl(H(e,{type:"arrayBuffer"}),t);function Yg(e){if(!e||e.startsWith("data:image/"))return!0;if(e.startsWith("blob:")&&(e=e.slice(5),e.startsWith("null")))return!1;if(e.indexOf("://")<=0)return!0;let t=new URL(e),r=window.location;return t.protocol===r.protocol&&t.host===r.host}const Fv=e=>{let t=window.document.createElement("video");return t.muted=!0,new Promise(r=>{t.onloadstart=()=>{r(t)};for(let i of e){let a=window.document.createElement("source");Yg(i)||(t.crossOrigin="Anonymous"),a.src=i,t.appendChild(a)}})};function Zp(e,t,r){var i;(i=r[e])!=null&&i.includes(t)||(r[e]||(r[e]=[]),r[e].push(t))}function Du(e,t,r){if(r!=null&&r[e]){let i=r[e].indexOf(t);i!==-1&&r[e].splice(i,1)}}var us=class{constructor(e,t={}){H(this,t),this.type=e}},Y=class extends us{constructor(e,t={}){super("error",H({error:e},t))}},kt=class{on(e,t){return this._listeners||(this._listeners={}),Zp(e,t,this._listeners),{unsubscribe:()=>{this.off(e,t)}}}off(e,t){return Du(e,t,this._listeners),Du(e,t,this._oneTimeListeners),this}once(e,t){return t?(this._oneTimeListeners||(this._oneTimeListeners={}),Zp(e,t,this._oneTimeListeners),this):new Promise(r=>this.once(e,r))}fire(e,t){var a,n,s,o;let r=typeof e=="string"?new us(e,t||{}):e,i=r.type;if(this.listens(i)){r.target=this;let l=((n=(a=this._listeners)==null?void 0:a[i])==null?void 0:n.slice())??[];for(let c of l)c.call(this,r);let u=((o=(s=this._oneTimeListeners)==null?void 0:s[i])==null?void 0:o.slice())??[];for(let c of u)Du(i,c,this._oneTimeListeners),c.call(this,r);let h=this._eventedParent;h&&(H(r,typeof this._eventedParentData=="function"?this._eventedParentData():this._eventedParentData),h.fire(r))}else r instanceof Y&&console.error(r.error);return this}listens(e){var t,r,i,a,n;return!!((r=(t=this._listeners)==null?void 0:t[e])!=null&&r.length||(a=(i=this._oneTimeListeners)==null?void 0:i[e])!=null&&a.length||(n=this._eventedParent)!=null&&n.listens(e))}setEventedParent(e,t){return this._eventedParent=e,this._eventedParentData=t,this}},Kg={$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"}]}}}}};const z=Kg,Rv=["type","source","source-layer","minzoom","maxzoom","filter","layout"];var O=class{constructor(e,t,r,i,a="error"){this.message=(e?`${e}: `:"")+r,i&&(this.identifier=i),this.severity=a,t!=null&&t.__line__&&(this.line=t.__line__)}};const hs={kind:"null"},V={kind:"number"},le={kind:"string"},fe={kind:"boolean"},Dr={kind:"color"},vl={kind:"projectionDefinition"},Ui={kind:"object"},ue={kind:"value"},kv={kind:"error"},bl={kind:"collator"},cs={kind:"formatted"},wl={kind:"padding"},Nn={kind:"colorArray"},Tl={kind:"numberArray"},ds={kind:"resolvedImage"},Sl={kind:"variableAnchorOffsetCollection"};function Rt(e,t){return{kind:"array",itemType:e,N:t}}function Ke(e){if(e.kind==="array"){let t=Ke(e.itemType);return typeof e.N=="number"?`array<${t}, ${e.N}>`:e.itemType.kind==="value"?"array":`array<${t}>`}return e.kind}const Lv=[hs,V,le,fe,Dr,vl,cs,Ui,Rt(ue),wl,Tl,Nn,ds,Sl];function Un(e,t){if(t.kind==="error")return null;if(e.kind==="array"){if(t.kind==="array"&&(t.N===0&&t.itemType.kind==="value"||!Un(e.itemType,t.itemType))&&(typeof e.N!="number"||e.N===t.N))return null}else{if(e.kind===t.kind)return null;if(e.kind==="value"){for(let r of Lv)if(!Un(r,t))return null}}return`Expected ${Ke(e)} but found ${Ke(t)} instead.`}function Xc(e,t){return t.some(r=>r.kind===e.kind)}function Gi(e,t){return t.some(r=>r==="null"?e===null:r==="array"?Array.isArray(e):r==="object"?e&&!Array.isArray(e)&&typeof e=="object":r===typeof e)}function fi(e,t){return e.kind==="array"&&t.kind==="array"?e.itemType.kind===t.itemType.kind&&typeof e.N=="number":e.kind===t.kind}const Jg=.96422,Qg=.82521,e_=4/29,yh=6/29,t_=3*yh*yh,Bv=Math.PI/180,Ov=180/Math.PI;function r_(e){return e%=360,e<0&&(e+=360),e}function i_([e,t,r,i]){e=Eu(e),t=Eu(t),r=Eu(r);let a,n,s=Pu((.2225045*e+.7168786*t+.0606169*r)/1);e===t&&t===r?a=n=s:(a=Pu((.4360747*e+.3850649*t+.1430804*r)/Jg),n=Pu((.0139322*e+.0971045*t+.7141733*r)/Qg));let o=116*s-16;return[o<0?0:o,500*(a-s),200*(s-n),i]}function Eu(e){return e<=.04045?e/12.92:((e+.055)/1.055)**2.4}function Pu(e){return e>.008856451679035631?e**(1/3):e/t_+e_}function a_([e,t,r,i]){let a=(e+16)/116,n=isNaN(t)?a:a+t/500,s=isNaN(r)?a:a-r/200;return a=1*Cu(a),n=Jg*Cu(n),s=Qg*Cu(s),[Au(3.1338561*n-1.6168667*a-.4906146*s),Au(-.9787684*n+1.9161415*a+.033454*s),Au(.0719453*n-.2289914*a+1.4052427*s),i]}function Au(e){return e=e<=.00304?12.92*e:1.055*e**(1/2.4)-.055,e<0?0:e>1?1:e}function Cu(e){return e>yh?e*e*e:t_*(e-e_)}function $v(e){let[t,r,i,a]=i_(e),n=Math.sqrt(r*r+i*i);return[Math.round(n*1e4)?r_(Math.atan2(i,r)*Ov):NaN,n,t,a]}function jv([e,t,r,i]){return e=isNaN(e)?0:e*Bv,a_([r,Math.cos(e)*t,Math.sin(e)*t,i])}function Vv([e,t,r,i]){e=r_(e),t/=100,r/=100;function a(n){let s=(n+e/30)%12,o=t*Math.min(r,1-r);return r-o*Math.max(-1,Math.min(s-3,9-s,1))}return[a(0),a(8),a(4),i]}const Nv=Object.hasOwn||function(e,t){return Object.prototype.hasOwnProperty.call(e,t)};function Fn(e,t){return Nv(e,t)?e[t]:void 0}function Uv(e){if(e=e.toLowerCase().trim(),e==="transparent")return[0,0,0,0];let t=Fn(Gv,e);if(t){let[i,a,n]=t;return[i/255,a/255,n/255,1]}if(e.startsWith("#")&&/^#(?:[0-9a-f]{3,4}|[0-9a-f]{6}|[0-9a-f]{8})$/.test(e)){let i=e.length<6?1:2,a=1;return[Gs(e.slice(a,a+=i)),Gs(e.slice(a,a+=i)),Gs(e.slice(a,a+=i)),Gs(e.slice(a,a+i)||"ff")]}if(e.startsWith("rgb")){let i=e.match(/^rgba?\(\s*([\de.+-]+)(%)?(?:\s+|\s*(,)\s*)([\de.+-]+)(%)?(?:\s+|\s*(,)\s*)([\de.+-]+)(%)?(?:\s*([,\/])\s*([\de.+-]+)(%)?)?\s*\)$/);if(i){let[a,n,s,o,l,u,h,c,d,p,f,m]=i,g=[o||" ",h||" ",p].join("");if(g===" "||g===" /"||g===",,"||g===",,,"){let _=[s,u,d].join(""),y=_==="%%%"?100:_===""?255:0;if(y){let v=[wa(+n/y,0,1),wa(+l/y,0,1),wa(+c/y,0,1),f?Wp(+f,m):1];if(Hp(v))return v}}return}}let r=e.match(/^hsla?\(\s*([\de.+-]+)(?:deg)?(?:\s+|\s*(,)\s*)([\de.+-]+)%(?:\s+|\s*(,)\s*)([\de.+-]+)%(?:\s*([,\/])\s*([\de.+-]+)(%)?)?\s*\)$/);if(r){let[i,a,n,s,o,l,u,h,c]=r,d=[n||" ",o||" ",u].join("");if(d===" "||d===" /"||d===",,"||d===",,,"){let p=[+a,wa(+s,0,100),wa(+l,0,100),h?Wp(+h,c):1];if(Hp(p))return Vv(p)}}}function Gs(e){return parseInt(e.padEnd(2,e),16)/255}function Wp(e,t){return wa(t?e/100:e,0,1)}function wa(e,t,r){return Math.min(Math.max(t,e),r)}function Hp(e){return!e.some(Number.isNaN)}const Gv={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 bi(e,t,r){return e+r*(t-e)}function ja(e,t,r){return e.map((i,a)=>bi(i,t[a],r))}function qv(e){return e==="rgb"||e==="hcl"||e==="lab"}var vt,oe=(vt=class{constructor(t,r,i,a=1,n=!0){this.r=t,this.g=r,this.b=i,this.a=a,n||(this.r*=a,this.g*=a,this.b*=a,a||this.overwriteGetter("rgb",[t,r,i,a]))}static parse(t){if(t instanceof vt)return t;if(typeof t!="string")return;let r=Uv(t);if(r)return new vt(...r,!1)}get rgb(){let{r:t,g:r,b:i,a}=this,n=a||1/0;return this.overwriteGetter("rgb",[t/n,r/n,i/n,a])}get hcl(){return this.overwriteGetter("hcl",$v(this.rgb))}get lab(){return this.overwriteGetter("lab",i_(this.rgb))}overwriteGetter(t,r){return Object.defineProperty(this,t,{value:r}),r}toString(){let[t,r,i,a]=this.rgb;return`rgba(${[t,r,i].map(n=>Math.round(n*255)).join(",")},${a})`}static interpolate(t,r,i,a="rgb"){switch(a){case"rgb":{let[n,s,o,l]=ja(t.rgb,r.rgb,i);return new vt(n,s,o,l,!1)}case"hcl":{let[n,s,o,l]=t.hcl,[u,h,c,d]=r.hcl,p,f;if(!isNaN(n)&&!isNaN(u)){let v=u-n;u>n&&v>180?v-=360:u<n&&n-u>180&&(v+=360),p=n+i*v}else isNaN(n)?isNaN(u)?p=NaN:(p=u,(o===1||o===0)&&(f=h)):(p=n,(c===1||c===0)&&(f=s));let[m,g,_,y]=jv([p,f??bi(s,h,i),bi(o,c,i),bi(l,d,i)]);return new vt(m,g,_,y,!1)}case"lab":{let[n,s,o,l]=a_(ja(t.lab,r.lab,i));return new vt(n,s,o,l,!1)}}}},vt.black=new vt(0,0,0,1),vt.white=new vt(1,1,1,1),vt.transparent=new vt(0,0,0,0),vt.red=new vt(1,0,0,1),vt);const Zv=["bottom","center","top"];var xh=class{constructor(t,r,i,a,n,s){this.text=t,this.image=r,this.scale=i,this.fontStack=a,this.textColor=n,this.verticalAlign=s}},ui=class Do{constructor(t){this.sections=t}static fromString(t){return new Do([new xh(t,null,null,null,null,null)])}isEmpty(){return this.sections.length===0||!this.sections.some(t=>t.text.length!==0||t.image&&t.image.name.length!==0)}static factory(t){return t instanceof Do?t:Do.fromString(t)}toString(){return this.sections.length===0?"":this.sections.map(t=>t.text).join("")}},Hr=class En{constructor(t){this.values=t.slice()}static parse(t){if(t instanceof En)return t;if(typeof t=="number")return new En([t,t,t,t]);if(Array.isArray(t)&&!(t.length<1||t.length>4)){for(let r of t)if(typeof r!="number")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 En(t)}}toString(){return JSON.stringify(this.values)}static interpolate(t,r,i){return new En(ja(t.values,r.values,i))}},Xr=class Pn{constructor(t){this.values=t.slice()}static parse(t){if(t instanceof Pn)return t;if(typeof t=="number")return new Pn([t]);if(Array.isArray(t)){for(let r of t)if(typeof r!="number")return;return new Pn(t)}}toString(){return JSON.stringify(this.values)}static interpolate(t,r,i){return new Pn(ja(t.values,r.values,i))}},gr=class An{constructor(t){this.values=t.slice()}static parse(t){if(t instanceof An)return t;if(typeof t=="string"){let i=oe.parse(t);return i?new An([i]):void 0}if(!Array.isArray(t))return;let r=[];for(let i of t){if(typeof i!="string")return;let a=oe.parse(i);if(!a)return;r.push(a)}return new An(r)}toString(){return JSON.stringify(this.values)}static interpolate(t,r,i,a="rgb"){let n=[];if(t.values.length!=r.values.length)throw Error(`colorArray: Arrays have mismatched length (${t.values.length} vs. ${r.values.length}), cannot interpolate.`);for(let s=0;s<t.values.length;s++)n.push(oe.interpolate(t.values[s],r.values[s],i,a));return new An(n)}},qe=class extends Error{constructor(e,t){super(e),this.name="RuntimeError",this.path=t}toJSON(){return this.message}};const Wv=new Set(["center","left","right","top","bottom","top-left","top-right","bottom-left","bottom-right"]);var qr=class Eo{constructor(t){this.values=t.slice()}static parse(t){if(t instanceof Eo)return t;if(!(!Array.isArray(t)||t.length<1||t.length%2!=0)){for(let r=0;r<t.length;r+=2){let i=t[r],a=t[r+1];if(typeof i!="string"||!Wv.has(i)||!Array.isArray(a)||a.length!==2||typeof a[0]!="number"||typeof a[1]!="number")return}return new Eo(t)}}toString(){return JSON.stringify(this.values)}static interpolate(t,r,i,a){let n=t.values,s=r.values;if(n.length!==s.length)throw new qe(`Cannot interpolate values of different length. from: ${t.toString()}, to: ${r.toString()}`,a);let o=[];for(let l=0;l<n.length;l+=2){if(n[l]!==s[l])throw new qe(`Cannot interpolate values containing mismatched anchors. from[${l}]: ${n[l]}, to[${l}]: ${s[l]}`,a);o.push(n[l]);let[u,h]=n[l+1],[c,d]=s[l+1];o.push([bi(u,c,i),bi(h,d,i)])}return new Eo(o)}},Zr=class n_{constructor(t){this.name=t.name,this.available=t.available}toString(){return this.name}static fromString(t){return t?new n_({name:t,available:!1}):null}},Ai=class Ta{constructor(t,r,i){this.from=t,this.to=r,this.transition=i}toString(){return this.from===this.to&&this.transition===1?this.from:JSON.stringify([this.from,this.to,this.transition])}static interpolate(t,r,i){return new Ta(t,r,i)}static parse(t){if(t instanceof Ta)return t;if(Array.isArray(t)&&t.length===3&&typeof t[0]=="string"&&typeof t[1]=="string"&&typeof t[2]=="number")return new Ta(t[0],t[1],t[2]);if(typeof t=="object"&&typeof t.from=="string"&&typeof t.to=="string"&&typeof t.transition=="number")return new Ta(t.from,t.to,t.transition);if(typeof t=="string")return new Ta(t,t,1)}},Yc=class{constructor(e,t,r){this.sensitivity=e?t?"variant":"case":t?"accent":"base",this.locale=r,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 s_(e,t,r,i){return typeof e=="number"&&e>=0&&e<=255&&typeof t=="number"&&t>=0&&t<=255&&typeof r=="number"&&r>=0&&r<=255?i===void 0||typeof i=="number"&&i>=0&&i<=1?null:`Invalid rgba value [${[e,t,r,i].join(", ")}]: 'a' must be between 0 and 1.`:`Invalid rgba value [${(typeof i=="number"?[e,t,r,i]:[e,t,r]).join(", ")}]: 'r', 'g', and 'b' must be between 0 and 255.`}function Va(e){if(e===null||typeof e=="string"||typeof e=="boolean"||typeof e=="number"||e instanceof Ai||e instanceof oe||e instanceof Yc||e instanceof ui||e instanceof Hr||e instanceof Xr||e instanceof gr||e instanceof qr||e instanceof Zr)return!0;if(Array.isArray(e)){for(let t of e)if(!Va(t))return!1;return!0}if(typeof e=="object"){for(let t in e)if(!Va(e[t]))return!1;return!0}return!1}function it(e){if(e===null)return hs;if(typeof e=="string")return le;if(typeof e=="boolean")return fe;if(typeof e=="number")return V;if(e instanceof oe)return Dr;if(e instanceof Ai)return vl;if(e instanceof Yc)return bl;if(e instanceof ui)return cs;if(e instanceof Hr)return wl;if(e instanceof Xr)return Tl;if(e instanceof gr)return Nn;if(e instanceof qr)return Sl;if(e instanceof Zr)return ds;if(Array.isArray(e)){let t=e.length,r;for(let i of e){let a=it(i);if(!r)r=a;else{if(r===a)continue;r=ue;break}}return Rt(r||ue,t)}return Ui}function Rn(e){let t=typeof e;return e===null?"":t==="string"||t==="number"||t==="boolean"?String(e):e instanceof oe||e instanceof Ai||e instanceof ui||e instanceof Hr||e instanceof Xr||e instanceof gr||e instanceof qr||e instanceof Zr?e.toString():JSON.stringify(e)}var Na=class o_{constructor(t,r){this.type=t,this.value=r}static parse(t,r){if(t.length!==2)return r.error(`'literal' expression requires exactly one argument, but found ${t.length-1} instead.`);if(!Va(t[1]))return r.error(`invalid value of type "${typeof t[1]}"`);let i=t[1],a=it(i),n=r.expectedType;return a.kind==="array"&&a.N===0&&n&&n.kind==="array"&&(typeof n.N!="number"||n.N===0)&&(a=n),new o_(a,i)}evaluate(){return this.value}eachChild(){}outputDefined(){return!0}};const Hv=["Unknown","Point","LineString","Polygon"];var l_=class{constructor(){this.globals=null,this.feature=null,this.featureState=null,this.formattedSection=null,this._parseColorCache=new Map,this.availableImages=null,this.canonical=null}id(){return this.feature&&"id"in this.feature?this.feature.id:null}geometryType(){return this.feature?typeof this.feature.type=="number"?Hv[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(t){let r=this._parseColorCache.get(t);return r||(r=oe.parse(t),this._parseColorCache.set(t,r)),r}};function Dl(e,t,r){let i=e.length-1,a=0,n=i,s=0,o,l;for(;a<=n;)if(s=Math.floor((a+n)/2),o=e[s],l=e[s+1],o<=t){if(s===i||t<l)return s;a=s+1}else if(o>t)n=s-1;else throw new qe("Input is not a number.",r);return 0}var Kc=class u_{constructor(t,r,i,a){this.type=t,this.input=r,this.key=a,this.labels=[],this.outputs=[];for(let[n,s]of i)this.labels.push(n),this.outputs.push(s)}static parse(t,r){if(t.length-1<4)return r.error(`Expected at least 4 arguments, but found only ${t.length-1}.`);if((t.length-1)%2!=0)return r.error("Expected an even number of arguments.");let i=r.parse(t[1],1,V);if(!i)return null;let a=[],n=null;r.expectedType&&r.expectedType.kind!=="value"&&(n=r.expectedType);for(let s=1;s<t.length;s+=2){let o=s===1?-1/0:t[s],l=t[s+1],u=s,h=s+1;if(typeof o!="number")return r.error('Input/output pairs for "step" expressions must be defined using literal numeric values (not computed expressions) for the input values.',u);if(a.length&&a[a.length-1][0]>=o)return r.error('Input/output pairs for "step" expressions must be arranged with input values in strictly ascending order.',u);let c=r.parse(l,h,n);if(!c)return null;n||(n=c.type),a.push([o,c])}return new u_(n,i,a,r.key)}evaluate(t){let r=this.labels,i=this.outputs;if(r.length===1)return i[0].evaluate(t);let a=this.input.evaluate(t);if(a<=r[0])return i[0].evaluate(t);let n=r.length;return a>=r[n-1]?i[n-1].evaluate(t):i[Dl(r,a,this.key)].evaluate(t)}eachChild(t){t(this.input);for(let r of this.outputs)t(r)}outputDefined(){return this.outputs.every(t=>t.outputDefined())}};function Xv(e,t,r,i){let a=3*e,n=3*(r-e)-a,s=1-a-n,o=3*t,l=3*(i-t)-o,u=1-o-l;return function(h,c=1e-6){if(h<=0)return 0;if(h>=1)return 1;let d=h;for(let m=0;m<8;m++){let g=((s*d+n)*d+a)*d-h;if(Math.abs(g)<c)return((u*d+l)*d+o)*d;let _=(3*s*d+2*n)*d+a;if(Math.abs(_)<1e-6)break;d-=g/_}let p=0,f=1;d=h;for(let m=0;m<20;m++){let g=((s*d+n)*d+a)*d;if(Math.abs(g-h)<c)break;h>g?p=d:f=d,d=(p+f)*.5}return((u*d+l)*d+o)*d}}var _r=class vh{constructor(t,r,i,a,n,s){this.type=t,this.operator=r,this.interpolation=i,this.input=a,this.key=s,this.labels=[],this.outputs=[];for(let[o,l]of n)this.labels.push(o),this.outputs.push(l)}static interpolationFactor(t,r,i,a){let n=0;if(t.name==="exponential")n=Iu(r,t.base,i,a);else if(t.name==="linear")n=Iu(r,1,i,a);else if(t.name==="cubic-bezier"){let s=t.controlPoints;n=Xv(s[0],s[1],s[2],s[3])(Iu(r,1,i,a))}return n}static parse(t,r){let[i,a,n,...s]=t;if(!Array.isArray(a)||a.length===0)return r.error("Expected an interpolation type expression.",1);if(a[0]==="linear")a={name:"linear"};else if(a[0]==="exponential"){let u=a[1];if(typeof u!="number")return r.error("Exponential interpolation requires a numeric base.",1,1);a={name:"exponential",base:u}}else if(a[0]==="cubic-bezier"){let u=a.slice(1);if(u.length!==4||u.some(h=>typeof h!="number"||h<0||h>1))return r.error("Cubic bezier interpolation requires four numeric arguments with values between 0 and 1.",1);a={name:"cubic-bezier",controlPoints:u}}else return r.error(`Unknown interpolation type ${String(a[0])}`,1,0);if(t.length-1<4)return r.error(`Expected at least 4 arguments, but found only ${t.length-1}.`);if((t.length-1)%2!=0)return r.error("Expected an even number of arguments.");if(n=r.parse(n,2,V),!n)return null;let o=[],l=null;(i==="interpolate-hcl"||i==="interpolate-lab")&&r.expectedType!=Nn?l=Dr:r.expectedType&&r.expectedType.kind!=="value"&&(l=r.expectedType);for(let u=0;u<s.length;u+=2){let h=s[u],c=s[u+1],d=u+3,p=u+4;if(typeof h!="number")return r.error('Input/output pairs for "interpolate" expressions must be defined using literal numeric values (not computed expressions) for the input values.',d);if(o.length&&o[o.length-1][0]>=h)return r.error('Input/output pairs for "interpolate" expressions must be arranged with input values in strictly ascending order.',d);let f=r.parse(c,p,l);if(!f)return null;l||(l=f.type),o.push([h,f])}return!fi(l,V)&&!fi(l,vl)&&!fi(l,Dr)&&!fi(l,wl)&&!fi(l,Tl)&&!fi(l,Nn)&&!fi(l,Sl)&&!fi(l,Rt(V))?r.error(`Type ${Ke(l)} is not interpolatable.`):new vh(l,i,a,n,o,r.key)}evaluate(t){let r=this.labels,i=this.outputs;if(r.length===1)return i[0].evaluate(t);let a=this.input.evaluate(t);if(a<=r[0])return i[0].evaluate(t);let n=r.length;if(a>=r[n-1])return i[n-1].evaluate(t);let s=Dl(r,a,this.key),o=r[s],l=r[s+1],u=vh.interpolationFactor(this.interpolation,a,o,l),h=i[s].evaluate(t),c=i[s+1].evaluate(t);switch(this.operator){case"interpolate":switch(this.type.kind){case"number":return bi(h,c,u);case"color":return oe.interpolate(h,c,u);case"padding":return Hr.interpolate(h,c,u);case"colorArray":return gr.interpolate(h,c,u);case"numberArray":return Xr.interpolate(h,c,u);case"variableAnchorOffsetCollection":return qr.interpolate(h,c,u,this.key);case"array":return ja(h,c,u);case"projectionDefinition":return Ai.interpolate(h,c,u)}case"interpolate-hcl":switch(this.type.kind){case"color":return oe.interpolate(h,c,u,"hcl");case"colorArray":return gr.interpolate(h,c,u,"hcl")}case"interpolate-lab":switch(this.type.kind){case"color":return oe.interpolate(h,c,u,"lab");case"colorArray":return gr.interpolate(h,c,u,"lab")}}}eachChild(t){t(this.input);for(let r of this.outputs)t(r)}outputDefined(){return this.outputs.every(t=>t.outputDefined())}};function Iu(e,t,r,i){let a=i-r,n=e-r;return a===0?0:t===1?n/a:(t**+n-1)/(t**+a-1)}const We={color:oe.interpolate,number:bi,padding:Hr.interpolate,numberArray:Xr.interpolate,colorArray:gr.interpolate,variableAnchorOffsetCollection:qr.interpolate,array:ja};var h_=class c_{constructor(t){this.type=cs,this.sections=t}static parse(t,r){if(t.length<2)return r.error("Expected at least one argument.");let i=t[1];if(!Array.isArray(i)&&typeof i=="object")return r.error("First argument must be an image or text section.");let a=[],n=!1;for(let s=1;s<=t.length-1;++s){let o=t[s];if(n&&typeof o=="object"&&!Array.isArray(o)){n=!1;let l=null;if(o["font-scale"]&&(l=r.parse(o["font-scale"],1,V),!l))return null;let u=null;if(o["text-font"]&&(u=r.parse(o["text-font"],1,Rt(le)),!u))return null;let h=null;if(o["text-color"]&&(h=r.parse(o["text-color"],1,Dr),!h))return null;let c=null;if(o["vertical-align"]){if(typeof o["vertical-align"]=="string"&&!Zv.includes(o["vertical-align"]))return r.error(`'vertical-align' must be one of: 'bottom', 'center', 'top' but found '${o["vertical-align"]}' instead.`);if(c=r.parse(o["vertical-align"],1,le),!c)return null}let d=a[a.length-1];d.scale=l,d.font=u,d.textColor=h,d.verticalAlign=c}else{let l=r.parse(t[s],1,ue);if(!l)return null;let u=l.type.kind;if(u!=="string"&&u!=="value"&&u!=="null"&&u!=="resolvedImage")return r.error("Formatted text type must be 'string', 'value', 'image' or 'null'.");n=!0,a.push({content:l,scale:null,font:null,textColor:null,verticalAlign:null})}}return new c_(a)}evaluate(t){return new ui(this.sections.map(r=>{let i=r.content.evaluate(t);return it(i)===ds?new xh("",i,null,null,null,r.verticalAlign?r.verticalAlign.evaluate(t):null):new xh(Rn(i),null,r.scale?r.scale.evaluate(t):null,r.font?r.font.evaluate(t).join(","):null,r.textColor?r.textColor.evaluate(t):null,r.verticalAlign?r.verticalAlign.evaluate(t):null)}))}eachChild(t){for(let r of this.sections)t(r.content),r.scale&&t(r.scale),r.font&&t(r.font),r.textColor&&t(r.textColor),r.verticalAlign&&t(r.verticalAlign)}outputDefined(){return!1}};function d_(e,t,r=0,i=e.length-1,a=Yv){for(;i>r;){if(i-r>600){let l=i-r+1,u=t-r+1,h=Math.log(l),c=.5*Math.exp(2*h/3),d=.5*Math.sqrt(h*c*(l-c)/l)*(u-l/2<0?-1:1);d_(e,t,Math.max(r,Math.floor(t-u*c/l+d)),Math.min(i,Math.floor(t+(l-u)*c/l+d)),a)}let n=e[t],s=r,o=i;for(pn(e,r,t),a(e[i],n)>0&&pn(e,r,i);s<o;){for(pn(e,s,o),s++,o--;a(e[s],n)<0;)s++;for(;a(e[o],n)>0;)o--}a(e[r],n)===0?pn(e,r,o):(o++,pn(e,o,i)),o<=t&&(r=o+1),t<=o&&(i=o-1)}}function pn(e,t,r){let i=e[t];e[t]=e[r],e[r]=i}function Yv(e,t){return e<t?-1:+(e>t)}function El(e,t){if(e.length<=1)return[e];let r=[],i,a;for(let n of e){let s=Jv(n);s!==0&&(n.area=Math.abs(s),a===void 0&&(a=s<0),a===s<0?(i&&r.push(i),i=[n]):i.push(n))}if(i&&r.push(i),t>1)for(let n=0;n<r.length;n++)r[n].length<=t||(d_(r[n],t,1,r[n].length-1,Kv),r[n]=r[n].slice(0,t));return r}function Kv(e,t){return t.area-e.area}function Jv(e){let t=0;for(let r=0,i=e.length,a=i-1,n,s;r<i;a=r++)n=e[r],s=e[a],t+=(s.x-n.x)*(n.y+s.y);return t}const qs={string:le,number:V,boolean:fe,object:Ui};var ti=class p_{constructor(t,r,i){this.type=t,this.args=r,this.key=i}static parse(t,r){if(t.length<2)return r.error("Expected at least one argument.");let i=1,a,n=t[0];if(n==="array"){let o;if(t.length>2){let u=t[1];if(typeof u!="string"||!(u in qs)||u==="object")return r.error('The item type argument of "array" must be one of string, number, boolean',1);o=qs[u],i++}else o=ue;let l;if(t.length>3){if(t[2]!==null&&(typeof t[2]!="number"||t[2]<0||t[2]!==Math.floor(t[2])))return r.error('The length argument to "array" must be a positive integer literal',2);l=t[2],i++}a=Rt(o,l)}else{if(!qs[n])throw Error(`Types doesn't contain name = ${n}`);a=qs[n]}let s=[];for(;i<t.length;i++){let o=r.parse(t[i],i,ue);if(!o)return null;s.push(o)}return new p_(a,s,r.key)}evaluate(t){for(let r=0;r<this.args.length;r++){let i=this.args[r].evaluate(t);if(!Un(this.type,it(i)))return i;if(r===this.args.length-1)throw new qe(`Expected value to be of type ${Ke(this.type)}, but found ${Ke(it(i))} instead.`,this.key)}throw Error()}eachChild(t){this.args.forEach(t)}outputDefined(){return this.args.every(t=>t.outputDefined())}};const Xp={"to-boolean":fe,"to-color":Dr,"to-number":V,"to-string":le};var Pa=class f_{constructor(t,r,i){this.type=t,this.args=r,this.key=i}static parse(t,r){if(t.length<2)return r.error("Expected at least one argument.");let i=t[0];if(!Xp[i])throw Error(`Can't parse ${i} as it is not part of the known types`);if((i==="to-boolean"||i==="to-string")&&t.length!==2)return r.error("Expected one argument.");let a=Xp[i],n=[];for(let s=1;s<t.length;s++){let o=r.parse(t[s],s,ue);if(!o)return null;n.push(o)}return new f_(a,n,r.key)}evaluate(t){switch(this.type.kind){case"boolean":return!!this.args[0].evaluate(t);case"color":{let r,i;for(let a of this.args){if(r=a.evaluate(t),i=null,r instanceof oe)return r;if(typeof r=="string"){let n=t.parseColor(r);if(n)return n}else if(Array.isArray(r)&&(i=r.length<3||r.length>4?`Invalid rgba value ${JSON.stringify(r)}: expected an array containing either three or four numeric values.`:s_(r[0],r[1],r[2],r[3]),!i))return new oe(r[0]/255,r[1]/255,r[2]/255,r[3])}throw new qe(i||`Could not parse color from value '${typeof r=="string"?r:JSON.stringify(r)}'`,this.key)}case"padding":{let r;for(let i of this.args){r=i.evaluate(t);let a=Hr.parse(r);if(a)return a}throw new qe(`Could not parse padding from value '${typeof r=="string"?r:JSON.stringify(r)}'`,this.key)}case"numberArray":{let r;for(let i of this.args){r=i.evaluate(t);let a=Xr.parse(r);if(a)return a}throw new qe(`Could not parse numberArray from value '${typeof r=="string"?r:JSON.stringify(r)}'`,this.key)}case"colorArray":{let r;for(let i of this.args){r=i.evaluate(t);let a=gr.parse(r);if(a)return a}throw new qe(`Could not parse colorArray from value '${typeof r=="string"?r:JSON.stringify(r)}'`,this.key)}case"variableAnchorOffsetCollection":{let r;for(let i of this.args){r=i.evaluate(t);let a=qr.parse(r);if(a)return a}throw new qe(`Could not parse variableAnchorOffsetCollection from value '${typeof r=="string"?r:JSON.stringify(r)}'`,this.key)}case"number":{let r=null;for(let i of this.args){if(r=i.evaluate(t),r===null)return 0;let a=Number(r);if(!isNaN(a))return a}throw new qe(`Could not convert ${JSON.stringify(r)} to number.`,this.key)}case"formatted":return ui.fromString(Rn(this.args[0].evaluate(t)));case"resolvedImage":return Zr.fromString(Rn(this.args[0].evaluate(t)));case"projectionDefinition":{let r=this.args[0].evaluate(t);if(Ai.parse(r))return r;throw new qe(`Could not parse projectionDefinition from value '${typeof r=="string"?r:JSON.stringify(r)}'`,this.key)}default:return Rn(this.args[0].evaluate(t))}}eachChild(t){this.args.forEach(t)}outputDefined(){return this.args.every(t=>t.outputDefined())}},m_=class g_{constructor(t,r){this.type=r.type,this.bindings=[].concat(t),this.result=r}evaluate(t){return this.result.evaluate(t)}eachChild(t){for(let r of this.bindings)t(r[1]);t(this.result)}static parse(t,r){if(t.length<4)return r.error(`Expected at least 3 arguments, but found ${t.length-1} instead.`);let i=[];for(let n=1;n<t.length-1;n+=2){let s=t[n];if(typeof s!="string")return r.error(`Expected string, but found ${typeof s} instead.`,n);if(/[^a-zA-Z0-9_]/.test(s))return r.error("Variable names must contain only alphanumeric characters or '_'.",n);let o=r.parse(t[n+1],n+1);if(!o)return null;i.push([s,o])}let a=r.parse(t[t.length-1],t.length-1,r.expectedType,i);return a?new g_(i,a):null}outputDefined(){return this.result.outputDefined()}},__=class y_{constructor(t,r){this.type=r.type,this.name=t,this.boundExpression=r}static parse(t,r){if(t.length!==2||typeof t[1]!="string")return r.error("'var' expression requires exactly one string literal argument.");let i=t[1];return r.scope.has(i)?new y_(i,r.scope.get(i)):r.error(`Unknown variable "${i}". Make sure "${i}" has been bound in an enclosing "let" expression before using it.`,1)}evaluate(t){return this.boundExpression.evaluate(t)}eachChild(){}outputDefined(){return!1}},Qv=class x_{constructor(t,r,i,a){this.type=t,this.index=r,this.input=i,this.key=a}static parse(t,r){if(t.length!==3)return r.error(`Expected 2 arguments, but found ${t.length-1} instead.`);let i=r.parse(t[1],1,V),a=r.parse(t[2],2,Rt(r.expectedType||ue));if(!i||!a)return null;let n=a.type;return new x_(n.itemType,i,a,r.key)}evaluate(t){let r=this.index.evaluate(t),i=this.input.evaluate(t);if(r<0)throw new qe(`Array index out of bounds: ${r} < 0.`,this.key);if(r>=i.length)throw new qe(`Array index out of bounds: ${r} > ${i.length-1}.`,this.key);if(r!==Math.floor(r))throw new qe(`Array index must be an integer, but found ${r} instead.`,this.key);return i[r]}eachChild(t){t(this.index),t(this.input)}outputDefined(){return!1}},eb=class v_{constructor(t,r,i){this.needle=t,this.haystack=r,this.key=i,this.type=fe}static parse(t,r){if(t.length!==3)return r.error(`Expected 2 arguments, but found ${t.length-1} instead.`);let i=r.parse(t[1],1,ue),a=r.parse(t[2],2,ue);return!i||!a?null:Xc(i.type,[fe,le,V,hs,ue])?new v_(i,a,r.key):r.error(`Expected first argument to be of type boolean, string, number or null, but found ${Ke(i.type)} instead`)}evaluate(t){let r=this.needle.evaluate(t),i=this.haystack.evaluate(t);if(!i)return!1;if(!Gi(r,["boolean","string","number","null"]))throw new qe(`Expected first argument to be of type boolean, string, number or null, but found ${Ke(it(r))} instead.`,this.key);if(!Gi(i,["string","array"]))throw new qe(`Expected second argument to be of type array or string, but found ${Ke(it(i))} instead.`,this.key);return i.indexOf(r)>=0}eachChild(t){t(this.needle),t(this.haystack)}outputDefined(){return!0}},tb=class bh{constructor(t,r,i,a){this.needle=t,this.haystack=r,this.key=i,this.fromIndex=a,this.type=V}static parse(t,r){if(t.length<=2||t.length>=5)return r.error(`Expected 2 or 3 arguments, but found ${t.length-1} instead.`);let i=r.parse(t[1],1,ue),a=r.parse(t[2],2,ue);if(!i||!a)return null;if(!Xc(i.type,[fe,le,V,hs,ue]))return r.error(`Expected first argument to be of type boolean, string, number or null, but found ${Ke(i.type)} instead`);if(t.length===4){let n=r.parse(t[3],3,V);return n?new bh(i,a,r.key,n):null}return new bh(i,a,r.key)}evaluate(t){let r=this.needle.evaluate(t),i=this.haystack.evaluate(t);if(!Gi(r,["boolean","string","number","null"]))throw new qe(`Expected first argument to be of type boolean, string, number or null, but found ${Ke(it(r))} instead.`,this.key);let a;if(this.fromIndex&&(a=this.fromIndex.evaluate(t)),Gi(i,["string"])){let n=i.indexOf(r,a);return n===-1?-1:[...i.slice(0,n)].length}if(Gi(i,["array"]))return i.indexOf(r,a);throw new qe(`Expected second argument to be of type array or string, but found ${Ke(it(i))} instead.`,this.key)}eachChild(t){t(this.needle),t(this.haystack),this.fromIndex&&t(this.fromIndex)}outputDefined(){return!1}},rb=class b_{constructor(t,r,i,a,n,s){this.inputType=t,this.type=r,this.input=i,this.cases=a,this.outputs=n,this.otherwise=s}static parse(t,r){if(t.length<5)return r.error(`Expected at least 4 arguments, but found only ${t.length-1}.`);if(t.length%2!=1)return r.error("Expected an even number of arguments.");let i,a;r.expectedType&&r.expectedType.kind!=="value"&&(a=r.expectedType);let n={},s=[];for(let u=2;u<t.length-1;u+=2){let h=t[u],c=t[u+1];Array.isArray(h)||(h=[h]);let d=r.concat(u);if(h.length===0)return d.error("Expected at least one branch label.");for(let f of h){if(typeof f!="number"&&typeof f!="string")return d.error("Branch labels must be numbers or strings.");if(typeof f=="number"&&Math.abs(f)>2**53-1)return d.error(`Branch labels must be integers no larger than ${2**53-1}.`);if(typeof f=="number"&&Math.floor(f)!==f)return d.error("Numeric branch labels must be integer values.");if(!i)i=it(f);else if(d.checkSubtype(i,it(f)))return null;if(n[String(f)]!==void 0)return d.error("Branch labels must be unique.");n[String(f)]=s.length}let p=r.parse(c,u,a);if(!p)return null;a||(a=p.type),s.push(p)}let o=r.parse(t[1],1,ue);if(!o)return null;let l=r.parse(t[t.length-1],t.length-1,a);return!l||o.type.kind!=="value"&&r.concat(1).checkSubtype(i,o.type)?null:new b_(i,a,o,n,s,l)}evaluate(t){let r=this.input.evaluate(t);return(it(r)===this.inputType&&this.outputs[this.cases[r]]||this.otherwise).evaluate(t)}eachChild(t){t(this.input),this.outputs.forEach(t),t(this.otherwise)}outputDefined(){return this.outputs.every(t=>t.outputDefined())&&this.otherwise.outputDefined()}},ib=class w_{constructor(t,r,i){this.type=t,this.branches=r,this.otherwise=i}static parse(t,r){if(t.length<4)return r.error(`Expected at least 3 arguments, but found only ${t.length-1}.`);if(t.length%2!=0)return r.error("Expected an odd number of arguments.");let i;r.expectedType&&r.expectedType.kind!=="value"&&(i=r.expectedType);let a=[];for(let s=1;s<t.length-1;s+=2){let o=r.parse(t[s],s,fe);if(!o)return null;let l=r.parse(t[s+1],s+1,i);if(!l)return null;a.push([o,l]),i||(i=l.type)}let n=r.parse(t[t.length-1],t.length-1,i);if(!n)return null;if(!i)throw Error("Can't infer output type");return new w_(i,a,n)}evaluate(t){for(let[r,i]of this.branches)if(r.evaluate(t))return i.evaluate(t);return this.otherwise.evaluate(t)}eachChild(t){for(let[r,i]of this.branches)t(r),t(i);t(this.otherwise)}outputDefined(){return this.branches.every(([t,r])=>r.outputDefined())&&this.otherwise.outputDefined()}},ab=class wh{constructor(t,r,i,a,n){this.type=t,this.input=r,this.beginIndex=i,this.key=a,this.endIndex=n}static parse(t,r){if(t.length<=2||t.length>=5)return r.error(`Expected 2 or 3 arguments, but found ${t.length-1} instead.`);let i=r.parse(t[1],1,ue),a=r.parse(t[2],2,V);if(!i||!a)return null;if(!Xc(i.type,[Rt(ue),le,ue]))return r.error(`Expected first argument to be of type array or string, but found ${Ke(i.type)} instead`);if(t.length===4){let n=r.parse(t[3],3,V);return n?new wh(i.type,i,a,r.key,n):null}return new wh(i.type,i,a,r.key)}evaluate(t){let r=this.input.evaluate(t),i=this.beginIndex.evaluate(t),a;if(this.endIndex&&(a=this.endIndex.evaluate(t)),Gi(r,["string"]))return[...r].slice(i,a).join("");if(Gi(r,["array"]))return r.slice(i,a);throw new qe(`Expected first argument to be of type array or string, but found ${Ke(it(r))} instead.`,this.key)}eachChild(t){t(this.input),t(this.beginIndex),this.endIndex&&t(this.endIndex)}outputDefined(){return!1}},T_=class Th{constructor(t,r){this.type=t,this.args=r}static parse(t,r){if(t.length<2)return r.error("Expected at least one argument.");let i=null,a=r.expectedType;a&&a.kind!=="value"&&(i=a);let n=[];for(let s of t.slice(1)){let o=r.parse(s,1+n.length,i,void 0,{typeAnnotation:"omit"});if(!o)return null;i||(i=o.type),n.push(o)}if(!i)throw Error("No output type");return a&&n.some(s=>Un(a,s.type))?new Th(ue,n):new Th(i,n)}evaluate(t){let r=null,i=0,a;for(let n of this.args)if(i++,r=n.evaluate(t),r&&r instanceof Zr&&!r.available&&(a||(a=r.name),r=null,i===this.args.length&&(r=a)),r!==null)break;return r}eachChild(t){this.args.forEach(t)}outputDefined(){return this.args.every(t=>t.outputDefined())}};function Yp(e,t){return e==="=="||e==="!="?t.kind==="boolean"||t.kind==="string"||t.kind==="number"||t.kind==="null"||t.kind==="value":t.kind==="string"||t.kind==="number"||t.kind==="value"}function nb(e,t,r){return t===r}function sb(e,t,r){return t!==r}function ob(e,t,r){return t<r}function lb(e,t,r){return t>r}function ub(e,t,r){return t<=r}function hb(e,t,r){return t>=r}function S_(e,t,r,i){return i.compare(t,r)===0}function cb(e,t,r,i){return!S_(e,t,r,i)}function db(e,t,r,i){return i.compare(t,r)<0}function pb(e,t,r,i){return i.compare(t,r)>0}function fb(e,t,r,i){return i.compare(t,r)<=0}function mb(e,t,r,i){return i.compare(t,r)>=0}function Ya(e,t,r){let i=e!=="=="&&e!=="!=";return class D_{constructor(n,s,o,l){this.lhs=n,this.rhs=s,this.key=o,this.collator=l,this.type=fe,this.hasUntypedArgument=n.type.kind==="value"||s.type.kind==="value"}static parse(n,s){if(n.length!==3&&n.length!==4)return s.error("Expected two or three arguments.");let o=n[0],l=s.parse(n[1],1,ue);if(!l)return null;if(!Yp(o,l.type))return s.concat(1).error(`"${o}" comparisons are not supported for type '${Ke(l.type)}'.`);let u=s.parse(n[2],2,ue);if(!u)return null;if(!Yp(o,u.type))return s.concat(2).error(`"${o}" comparisons are not supported for type '${Ke(u.type)}'.`);if(l.type.kind!==u.type.kind&&l.type.kind!=="value"&&u.type.kind!=="value")return s.error(`Cannot compare types '${Ke(l.type)}' and '${Ke(u.type)}'.`);i&&(l.type.kind==="value"&&u.type.kind!=="value"?l=new ti(u.type,[l],s.key):l.type.kind!=="value"&&u.type.kind==="value"&&(u=new ti(l.type,[u],s.key)));let h=null;if(n.length===4){if(l.type.kind!=="string"&&u.type.kind!=="string"&&l.type.kind!=="value"&&u.type.kind!=="value")return s.error("Cannot use collator to compare non-string types.");if(h=s.parse(n[3],3,bl),!h)return null}return new D_(l,u,s.key,h)}evaluate(n){let s=this.lhs.evaluate(n),o=this.rhs.evaluate(n);if(i&&this.hasUntypedArgument){let l=it(s),u=it(o);if(l.kind!==u.kind||l.kind!=="string"&&l.kind!=="number")throw new qe(`Expected arguments for "${e}" to be (string, string) or (number, number), but found (${l.kind}, ${u.kind}) instead.`,this.key)}if(this.collator&&!i&&this.hasUntypedArgument){let l=it(s),u=it(o);if(l.kind!=="string"||u.kind!=="string")return t(n,s,o)}return this.collator?r(n,s,o,this.collator.evaluate(n)):t(n,s,o)}eachChild(n){n(this.lhs),n(this.rhs),this.collator&&n(this.collator)}outputDefined(){return!0}}}const gb=Ya("==",nb,S_),_b=Ya("!=",sb,cb),yb=Ya("<",ob,db),xb=Ya(">",lb,pb),vb=Ya("<=",ub,fb),bb=Ya(">=",hb,mb);var E_=class P_{constructor(t,r,i){this.type=bl,this.locale=i,this.caseSensitive=t,this.diacriticSensitive=r}static parse(t,r){if(t.length!==2)return r.error("Expected one argument.");let i=t[1];if(typeof i!="object"||Array.isArray(i))return r.error("Collator options argument must be an object.");let a=r.parse(i["case-sensitive"]!==void 0&&i["case-sensitive"],1,fe);if(!a)return null;let n=r.parse(i["diacritic-sensitive"]!==void 0&&i["diacritic-sensitive"],1,fe);if(!n)return null;let s=null;return i.locale&&(s=r.parse(i.locale,1,le),!s)?null:new P_(a,n,s)}evaluate(t){return new Yc(this.caseSensitive.evaluate(t),this.diacriticSensitive.evaluate(t),this.locale?this.locale.evaluate(t):null)}eachChild(t){t(this.caseSensitive),t(this.diacriticSensitive),this.locale&&t(this.locale)}outputDefined(){return!1}},wb=class A_{constructor(t,r,i,a,n,s){this.type=le,this.number=t,this.locale=r,this.currency=i,this.unit=a,this.minFractionDigits=n,this.maxFractionDigits=s}static parse(t,r){if(t.length!==3)return r.error("Expected two arguments.");let i=r.parse(t[1],1,V);if(!i)return null;let a=t[2];if(typeof a!="object"||Array.isArray(a))return r.error("NumberFormat options argument must be an object.");let n=null;if(a.locale&&(n=r.parse(a.locale,1,le),!n))return null;let s=null;if(a.currency&&(s=r.parse(a.currency,1,le),!s))return null;let o=null;if(a.unit&&(o=r.parse(a.unit,1,le),!o))return null;if(s&&o)return r.error("NumberFormat options `currency` and `unit` are mutually exclusive");let l=null;if(a["min-fraction-digits"]&&(l=r.parse(a["min-fraction-digits"],1,V),!l))return null;let u=null;return a["max-fraction-digits"]&&(u=r.parse(a["max-fraction-digits"],1,V),!u)?null:new A_(i,n,s,o,l,u)}evaluate(t){return new Intl.NumberFormat(this.locale?this.locale.evaluate(t):[],{style:this.currency?"currency":this.unit?"unit":"decimal",currency:this.currency?this.currency.evaluate(t):void 0,unit:this.unit?this.unit.evaluate(t):void 0,minimumFractionDigits:this.minFractionDigits?this.minFractionDigits.evaluate(t):void 0,maximumFractionDigits:this.maxFractionDigits?this.maxFractionDigits.evaluate(t):void 0}).format(this.number.evaluate(t))}eachChild(t){t(this.number),this.locale&&t(this.locale),this.currency&&t(this.currency),this.unit&&t(this.unit),this.minFractionDigits&&t(this.minFractionDigits),this.maxFractionDigits&&t(this.maxFractionDigits)}outputDefined(){return!1}},Tb=class C_{constructor(t){this.type=ds,this.input=t}static parse(t,r){if(t.length!==2)return r.error("Expected two arguments.");let i=r.parse(t[1],1,le);return i?new C_(i):r.error("No image name provided.")}evaluate(t){let r=this.input.evaluate(t),i=Zr.fromString(r);return i&&t.availableImages&&(i.available=t.availableImages.indexOf(r)>-1),i}eachChild(t){t(this.input)}outputDefined(){return!1}},Sb=class I_{constructor(t,r){this.input=t,this.key=r,this.type=V}static parse(t,r){if(t.length!==2)return r.error(`Expected 1 argument, but found ${t.length-1} instead.`);let i=r.parse(t[1],1);return i?i.type.kind!=="array"&&i.type.kind!=="string"&&i.type.kind!=="value"?r.error(`Expected argument of type string or array, but found ${Ke(i.type)} instead.`):new I_(i,r.key):null}evaluate(t){let r=this.input.evaluate(t);if(typeof r=="string")return[...r].length;if(Array.isArray(r))return r.length;throw new qe(`Expected value to be of type string or array, but found ${Ke(it(r))} instead.`,this.key)}eachChild(t){t(this.input)}outputDefined(){return!1}};const Nr=8192;function Db(e,t){let r=Eb(e[0]),i=Ab(e[1]),a=2**t.z;return[Math.round(r*a*Nr),Math.round(i*a*Nr)]}function Jc(e,t){let r=2**t.z,i=(e[0]/Nr+t.x)/r,a=(e[1]/Nr+t.y)/r;return[Pb(i),Cb(a)]}function Eb(e){return(180+e)/360}function Pb(e){return e*360-180}function Ab(e){return(180-180/Math.PI*Math.log(Math.tan(Math.PI/4+e*Math.PI/360)))/360}function Cb(e){return 360/Math.PI*Math.atan(Math.exp((180-e*360)*Math.PI/180))-90}function ps(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 Gn(e,t){return!(e[0]<=t[0]||e[2]>=t[2]||e[1]<=t[1]||e[3]>=t[3])}function Ib(e,t,r){return t[1]>e[1]!=r[1]>e[1]&&e[0]<(r[0]-t[0])*(e[1]-t[1])/(r[1]-t[1])+t[0]}function Mb(e,t,r){let i=e[0]-t[0],a=e[1]-t[1],n=e[0]-r[0],s=e[1]-r[1];return i*s-n*a===0&&i*n<=0&&a*s<=0}function Pl(e,t,r,i){let a=[t[0]-e[0],t[1]-e[1]];return kb([i[0]-r[0],i[1]-r[1]],a)!==0&&!!(Kp(e,t,r,i)&&Kp(r,i,e,t))}function zb(e,t,r){for(let i of r)for(let a=0;a<i.length-1;++a)if(Pl(e,t,i[a],i[a+1]))return!0;return!1}function Ka(e,t,r=!1){let i=!1;for(let a of t)for(let n=0;n<a.length-1;n++){if(Mb(e,a[n],a[n+1]))return r;Ib(e,a[n],a[n+1])&&(i=!i)}return i}function Fb(e,t){for(let r of t)if(Ka(e,r))return!0;return!1}function M_(e,t){for(let r of e)if(!Ka(r,t))return!1;for(let r=0;r<e.length-1;++r)if(zb(e[r],e[r+1],t))return!1;return!0}function Rb(e,t){for(let r of t)if(M_(e,r))return!0;return!1}function kb(e,t){return e[0]*t[1]-e[1]*t[0]}function Kp(e,t,r,i){let a=e[0]-r[0],n=e[1]-r[1],s=t[0]-r[0],o=t[1]-r[1],l=i[0]-r[0],u=i[1]-r[1],h=a*u-l*n,c=s*u-l*o;return h>0&&c<0||h<0&&c>0}function Qc(e,t,r){let i=[];for(let a=0;a<e.length;a++){let n=[];for(let s=0;s<e[a].length;s++){let o=Db(e[a][s],r);ps(t,o),n.push(o)}i.push(n)}return i}function z_(e,t,r){let i=[];for(let a=0;a<e.length;a++){let n=Qc(e[a],t,r);i.push(n)}return i}function F_(e,t,r,i){if(e[0]<r[0]||e[0]>r[2]){let a=i*.5,n=e[0]-r[0]>a?-i:r[0]-e[0]>a?i:0;n===0&&(n=e[0]-r[2]>a?-i:r[2]-e[0]>a?i:0),e[0]+=n}ps(t,e)}function Lb(e){e[0]=e[1]=1/0,e[2]=e[3]=-1/0}function Jp(e,t,r,i){let a=2**i.z*Nr,n=[i.x*Nr,i.y*Nr],s=[];for(let o of e)for(let l of o){let u=[l.x+n[0],l.y+n[1]];F_(u,t,r,a),s.push(u)}return s}function Qp(e,t,r,i){let a=2**i.z*Nr,n=[i.x*Nr,i.y*Nr],s=[];for(let o of e){let l=[];for(let u of o){let h=[u.x+n[0],u.y+n[1]];ps(t,h),l.push(h)}s.push(l)}if(t[2]-t[0]<=a/2){Lb(t);for(let o of s)for(let l of o)F_(l,t,r,a)}return s}function Bb(e,t){let r=[1/0,1/0,-1/0,-1/0],i=[1/0,1/0,-1/0,-1/0],a=e.canonicalID();if(t.type==="Polygon"){let n=Qc(t.coordinates,i,a),s=Jp(e.geometry(),r,i,a);if(!Gn(r,i))return!1;for(let o of s)if(!Ka(o,n))return!1}if(t.type==="MultiPolygon"){let n=z_(t.coordinates,i,a),s=Jp(e.geometry(),r,i,a);if(!Gn(r,i))return!1;for(let o of s)if(!Fb(o,n))return!1}return!0}function Ob(e,t){let r=[1/0,1/0,-1/0,-1/0],i=[1/0,1/0,-1/0,-1/0],a=e.canonicalID();if(t.type==="Polygon"){let n=Qc(t.coordinates,i,a),s=Qp(e.geometry(),r,i,a);if(!Gn(r,i))return!1;for(let o of s)if(!M_(o,n))return!1}if(t.type==="MultiPolygon"){let n=z_(t.coordinates,i,a),s=Qp(e.geometry(),r,i,a);if(!Gn(r,i))return!1;for(let o of s)if(!Rb(o,n))return!1}return!0}var ed=class Po{constructor(t,r){this.type=fe,this.geojson=t,this.geometries=r}static parse(t,r){if(t.length!==2)return r.error(`'within' expression requires exactly one argument, but found ${t.length-1} instead.`);if(Va(t[1])){let i=t[1];if(i.type==="FeatureCollection"){let a=[];for(let n of i.features){let{type:s,coordinates:o}=n.geometry;s==="Polygon"&&a.push(o),s==="MultiPolygon"&&a.push(...o)}if(a.length)return new Po(i,{type:"MultiPolygon",coordinates:a})}else if(i.type==="Feature"){let a=i.geometry.type;if(a==="Polygon"||a==="MultiPolygon")return new Po(i,i.geometry)}else if(i.type==="Polygon"||i.type==="MultiPolygon")return new Po(i,i)}return r.error("'within' expression requires valid geojson object that contains polygon geometry type.")}evaluate(t){if(t.geometry()!=null&&t.canonicalID()!=null){if(t.geometryType()==="Point")return Bb(t,this.geometries);if(t.geometryType()==="LineString")return Ob(t,this.geometries)}return!1}eachChild(){}outputDefined(){return!0}},R_=class{constructor(t=[],r=(i,a)=>i<a?-1:+(i>a)){if(this.data=t,this.length=this.data.length,this.compare=r,this.length>0)for(let i=(this.length>>1)-1;i>=0;i--)this._down(i)}push(t){this.data.push(t),this._up(this.length++)}pop(){if(this.length===0)return;let t=this.data[0],r=this.data.pop();return--this.length>0&&(this.data[0]=r,this._down(0)),t}peek(){return this.data[0]}_up(t){let{data:r,compare:i}=this,a=r[t];for(;t>0;){let n=t-1>>1,s=r[n];if(i(a,s)>=0)break;r[t]=s,t=n}r[t]=a}_down(t){let{data:r,compare:i}=this,a=this.length>>1,n=r[t];for(;t<a;){let s=(t<<1)+1,o=s+1;if(o<this.length&&i(r[o],r[s])<0&&(s=o),i(r[s],n)>=0)break;r[t]=r[s],t=s}r[t]=n}};const ef=Math.PI/180;var td=class{constructor(t){let r=ef*6378.137*1e3,i=Math.cos(t*ef),a=1/(1-.0066943799901413165*(1-i*i)),n=Math.sqrt(a);this.kx=r*n*i,this.ky=r*n*a*.9933056200098587}distance(t,r){let i=this.wrap(t[0]-r[0])*this.kx,a=(t[1]-r[1])*this.ky;return Math.sqrt(i*i+a*a)}pointOnLine(t,r){let i=1/0,a,n,s,o;for(let l=0;l<t.length-1;l++){let u=t[l][0],h=t[l][1],c=this.wrap(t[l+1][0]-u)*this.kx,d=(t[l+1][1]-h)*this.ky,p=0;(c!==0||d!==0)&&(p=(this.wrap(r[0]-u)*this.kx*c+(r[1]-h)*this.ky*d)/(c*c+d*d),p>1?(u=t[l+1][0],h=t[l+1][1]):p>0&&(u+=c/this.kx*p,h+=d/this.ky*p)),c=this.wrap(r[0]-u)*this.kx,d=(r[1]-h)*this.ky;let f=c*c+d*d;f<i&&(i=f,a=u,n=h,s=l,o=p)}return{point:[a,n],index:s,t:Math.max(0,Math.min(1,o))}}wrap(t){for(;t<-180;)t+=360;for(;t>180;)t-=360;return t}};function k_(e,t){return t[0]-e[0]}function No(e){return e[1]-e[0]+1}function hi(e,t){return e[1]>=e[0]&&e[1]<t}function Sh(e,t){if(e[0]>e[1])return[null,null];let r=No(e);if(t){if(r===2)return[e,null];let a=Math.floor(r/2);return[[e[0],e[0]+a],[e[0]+a,e[1]]]}if(r===1)return[e,null];let i=Math.floor(r/2)-1;return[[e[0],e[0]+i],[e[0]+i+1,e[1]]]}function Dh(e,t){if(!hi(t,e.length))return[1/0,1/0,-1/0,-1/0];let r=[1/0,1/0,-1/0,-1/0];for(let i=t[0];i<=t[1];++i)ps(r,e[i]);return r}function Eh(e){let t=[1/0,1/0,-1/0,-1/0];for(let r of e)for(let i of r)ps(t,i);return t}function tf(e){return e[0]!==-1/0&&e[1]!==-1/0&&e[2]!==1/0&&e[3]!==1/0}function rd(e,t,r){if(!tf(e)||!tf(t))return NaN;let i=0,a=0;return e[2]<t[0]&&(i=t[0]-e[2]),e[0]>t[2]&&(i=e[0]-t[2]),e[1]>t[3]&&(a=e[1]-t[3]),e[3]<t[1]&&(a=t[1]-e[3]),r.distance([0,0],[i,a])}function Oi(e,t,r){let i=r.pointOnLine(t,e);return r.distance(e,i.point)}function id(e,t,r,i,a){let n=Math.min(Oi(e,[r,i],a),Oi(t,[r,i],a)),s=Math.min(Oi(r,[e,t],a),Oi(i,[e,t],a));return Math.min(n,s)}function $b(e,t,r,i,a){if(!(hi(t,e.length)&&hi(i,r.length)))return 1/0;let n=1/0;for(let s=t[0];s<t[1];++s){let o=e[s],l=e[s+1];for(let u=i[0];u<i[1];++u){let h=r[u],c=r[u+1];if(Pl(o,l,h,c))return 0;n=Math.min(n,id(o,l,h,c,a))}}return n}function jb(e,t,r,i,a){if(!(hi(t,e.length)&&hi(i,r.length)))return NaN;let n=1/0;for(let s=t[0];s<=t[1];++s)for(let o=i[0];o<=i[1];++o)if(n=Math.min(n,a.distance(e[s],r[o])),n===0)return n;return n}function Vb(e,t,r){if(Ka(e,t,!0))return 0;let i=1/0;for(let a of t){let n=a[0],s=a[a.length-1];if(n!==s&&(i=Math.min(i,Oi(e,[s,n],r)),i===0))return i;let o=r.pointOnLine(a,e);if(i=Math.min(i,r.distance(e,o.point)),i===0)return i}return i}function Nb(e,t,r,i){if(!hi(t,e.length))return NaN;for(let n=t[0];n<=t[1];++n)if(Ka(e[n],r,!0))return 0;let a=1/0;for(let n=t[0];n<t[1];++n){let s=e[n],o=e[n+1];for(let l of r)for(let u=0,h=l.length,c=h-1;u<h;c=u++){let d=l[c],p=l[u];if(Pl(s,o,d,p))return 0;a=Math.min(a,id(s,o,d,p,i))}}return a}function rf(e,t){for(let r of e)for(let i of r)if(Ka(i,t,!0))return!0;return!1}function Ub(e,t,r,i=1/0){let a=Eh(e),n=Eh(t);if(i!==1/0&&rd(a,n,r)>=i)return i;if(Gn(a,n)){if(rf(e,t))return 0}else if(rf(t,e))return 0;let s=1/0;for(let o of e)for(let l=0,u=o.length,h=u-1;l<u;h=l++){let c=o[h],d=o[l];for(let p of t)for(let f=0,m=p.length,g=m-1;f<m;g=f++){let _=p[g],y=p[f];if(Pl(c,d,_,y))return 0;s=Math.min(s,id(c,d,_,y,r))}}return s}function af(e,t,r,i,a,n){if(!n)return;let s=rd(Dh(i,n),a,r);s<t&&e.push([s,n,[0,0]])}function Zs(e,t,r,i,a,n,s){if(!n||!s)return;let o=rd(Dh(i,n),Dh(a,s),r);o<t&&e.push([o,n,s])}function Uo(e,t,r,i,a=1/0){let n=Math.min(i.distance(e[0],r[0][0]),a);if(n===0)return n;let s=new R_([[0,[0,e.length-1],[0,0]]],k_),o=Eh(r);for(;s.length>0;){let l=s.pop();if(l[0]>=n)continue;let u=l[1],h=t?50:100;if(No(u)<=h){if(!hi(u,e.length))return NaN;if(t){let c=Nb(e,u,r,i);if(isNaN(c)||c===0)return c;n=Math.min(n,c)}else for(let c=u[0];c<=u[1];++c){let d=Vb(e[c],r,i);if(n=Math.min(n,d),n===0)return 0}}else{let c=Sh(u,t);af(s,n,i,e,o,c[0]),af(s,n,i,e,o,c[1])}}return n}function Go(e,t,r,i,a,n=1/0){let s=Math.min(n,a.distance(e[0],r[0]));if(s===0)return s;let o=new R_([[0,[0,e.length-1],[0,r.length-1]]],k_);for(;o.length>0;){let l=o.pop();if(l[0]>=s)continue;let u=l[1],h=l[2],c=t?50:100,d=i?50:100;if(No(u)<=c&&No(h)<=d){if(!hi(u,e.length)&&hi(h,r.length))return NaN;let p;if(t&&i)p=$b(e,u,r,h,a),s=Math.min(s,p);else if(t&&!i){let f=e.slice(u[0],u[1]+1);for(let m=h[0];m<=h[1];++m)if(p=Oi(r[m],f,a),s=Math.min(s,p),s===0)return s}else if(!t&&i){let f=r.slice(h[0],h[1]+1);for(let m=u[0];m<=u[1];++m)if(p=Oi(e[m],f,a),s=Math.min(s,p),s===0)return s}else p=jb(e,u,r,h,a),s=Math.min(s,p)}else{let p=Sh(u,t),f=Sh(h,i);Zs(o,s,a,e,r,p[0],f[0]),Zs(o,s,a,e,r,p[0],f[1]),Zs(o,s,a,e,r,p[1],f[0]),Zs(o,s,a,e,r,p[1],f[1])}}return s}function Gb(e,t){let r=e.geometry(),i=r.flat().map(s=>Jc([s.x,s.y],e.canonical));if(r.length===0)return NaN;let a=new td(i[0][1]),n=1/0;for(let s of t){switch(s.type){case"Point":n=Math.min(n,Go(i,!1,[s.coordinates],!1,a,n));break;case"LineString":n=Math.min(n,Go(i,!1,s.coordinates,!0,a,n));break;case"Polygon":n=Math.min(n,Uo(i,!1,s.coordinates,a,n))}if(n===0)return n}return n}function qb(e,t){let r=e.geometry(),i=r.flat().map(s=>Jc([s.x,s.y],e.canonical));if(r.length===0)return NaN;let a=new td(i[0][1]),n=1/0;for(let s of t){switch(s.type){case"Point":n=Math.min(n,Go(i,!0,[s.coordinates],!1,a,n));break;case"LineString":n=Math.min(n,Go(i,!0,s.coordinates,!0,a,n));break;case"Polygon":n=Math.min(n,Uo(i,!0,s.coordinates,a,n))}if(n===0)return n}return n}function Zb(e,t){let r=e.geometry();if(r.length===0||r[0].length===0)return NaN;let i=El(r,0).map(s=>s.map(o=>o.map(l=>Jc([l.x,l.y],e.canonical)))),a=new td(i[0][0][0][1]),n=1/0;for(let s of t)for(let o of i){switch(s.type){case"Point":n=Math.min(n,Uo([s.coordinates],!1,o,a,n));break;case"LineString":n=Math.min(n,Uo(s.coordinates,!0,o,a,n));break;case"Polygon":n=Math.min(n,Ub(o,s.coordinates,a,n))}if(n===0)return n}return n}function Mu(e){return e.type==="MultiPolygon"?e.coordinates.map(t=>({type:"Polygon",coordinates:t})):e.type==="MultiLineString"?e.coordinates.map(t=>({type:"LineString",coordinates:t})):e.type==="MultiPoint"?e.coordinates.map(t=>({type:"Point",coordinates:t})):[e]}var ad=class Ao{constructor(t,r){this.type=V,this.geojson=t,this.geometries=r}static parse(t,r){if(t.length!==2)return r.error(`'distance' expression requires exactly one argument, but found ${t.length-1} instead.`);if(Va(t[1])){let i=t[1];if(i.type==="FeatureCollection")return new Ao(i,i.features.map(a=>Mu(a.geometry)).flat());if(i.type==="Feature")return new Ao(i,Mu(i.geometry));if("type"in i&&"coordinates"in i)return new Ao(i,Mu(i))}return r.error("'distance' expression requires valid geojson object that contains polygon geometry type.")}evaluate(t){if(t.geometry()!=null&&t.canonicalID()!=null){if(t.geometryType()==="Point")return Gb(t,this.geometries);if(t.geometryType()==="LineString")return qb(t,this.geometries);if(t.geometryType()==="Polygon")return Zb(t,this.geometries)}return NaN}eachChild(){}outputDefined(){return!0}},Wb=class L_{constructor(t){let r=null;for(let i of t)if(!r)r=i.type;else{if(r===i.type)continue;r=ue;break}this.type=Rt(r??ue,t.length),this.arr=t}static parse(t,r){if(t.length!==2)return r.error(`'semiliteral' expression requires exactly one argument, but found ${t.length-1} instead.`);if(!Va(t[1]))return r.error(`invalid value of type "${typeof t[1]}"`);let i=t[1],a=it(i);if(a.kind==="array"){let n=i,s=r.concat(1),o=[];for(let l=0;l<n.length;l++){let u=s.parse(n[l],l,ue);if(!u)return null;o.push(u)}return new L_(o)}return new Na(a,i)}evaluate(t){return this.arr.map(r=>r.evaluate(t))}eachChild(t){this.arr.forEach(t)}outputDefined(){return this.arr.every(t=>t.outputDefined())}},nd=class B_{constructor(t){this.key=t,this.type=ue}static parse(t,r){if(t.length!==2)return r.error(`Expected 1 argument, but found ${t.length-1} instead.`);let i=t[1];return i==null?r.error("Global state property must be defined."):typeof i=="string"?new B_(i):r.error(`Global state property must be string, but found ${typeof t[1]} instead.`)}evaluate(t){var i;let r=(i=t.globals)==null?void 0:i.globalState;return!r||Object.keys(r).length===0?null:Fn(r,this.key)??null}eachChild(){}outputDefined(){return!1}};const Ma={"==":gb,"!=":_b,">":xb,"<":yb,">=":bb,"<=":vb,array:ti,at:Qv,boolean:ti,case:ib,coalesce:T_,collator:E_,format:h_,image:Tb,in:eb,"index-of":tb,interpolate:_r,"interpolate-hcl":_r,"interpolate-lab":_r,length:Sb,let:m_,literal:Na,match:rb,number:ti,"number-format":wb,object:ti,semiliteral:Wb,slice:ab,step:Kc,string:ti,"to-boolean":Pa,"to-color":Pa,"to-number":Pa,"to-string":Pa,var:__,within:ed,distance:ad,"global-state":nd};var Or=class extends Error{constructor(t,r){super(r),this.message=r,this.key=t}},Hb=class O_{constructor(t,r=[]){this.parent=t,this.bindings={};for(let[i,a]of r)this.bindings[i]=a}concat(t){return new O_(this,t)}get(t){if(this.bindings[t])return this.bindings[t];if(this.parent)return this.parent.get(t);throw Error(`${t} not found in scope.`)}has(t){return this.bindings[t]?!0:this.parent?this.parent.has(t):!1}},$_=class j_{constructor(t,r,i=[],a,n=new Hb,s=[]){this.registry=t,this.path=i,this.key=i.map(o=>`[${o}]`).join(""),this.scope=n,this.errors=s,this.expectedType=a,this._isConstant=r}parse(t,r,i,a,n={}){return r==null?this._parse(t,n):this.concat(r,i,a)._parse(t,n)}_parse(t,r){(t===null||typeof t=="string"||typeof t=="boolean"||typeof t=="number")&&(t=["literal",t]);let i=this.key;function a(n,s,o){return o==="assert"?new ti(s,[n],i):o==="coerce"?new Pa(s,[n],i):n}if(Array.isArray(t)){if(t.length===0)return this.error('Expected an array with at least one element. If you wanted a literal array, use ["literal", []].');let n=t[0];if(typeof n!="string")return this.error(`Expression name must be a string, but found ${typeof n} instead. If you wanted a literal array, use ["literal", [...]].`,0),null;let s=this.registry[n];if(s){let o=s.parse(t,this);if(!o)return null;if(this.expectedType){let l=this.expectedType,u=o.type;if((l.kind==="string"||l.kind==="number"||l.kind==="boolean"||l.kind==="object"||l.kind==="array")&&u.kind==="value")o=a(o,l,r.typeAnnotation||"assert");else if(l.kind==="projectionDefinition"&&["string","array","value"].includes(u.kind)||["color","formatted","resolvedImage"].includes(l.kind)&&["value","string"].includes(u.kind)||["padding","numberArray"].includes(l.kind)&&["value","number","array"].includes(u.kind)||l.kind==="colorArray"&&["value","string","array"].includes(u.kind)||l.kind==="variableAnchorOffsetCollection"&&["value","array"].includes(u.kind))o=a(o,l,r.typeAnnotation||"coerce");else if(this.checkSubtype(l,u))return null}if(!(o instanceof Na)&&o.type.kind!=="resolvedImage"&&this._isConstant(o)){let l=new l_;try{o=new Na(o.type,o.evaluate(l))}catch(u){return this.error(u.message),null}}return o}return this.error(`Unknown expression "${n}". If you wanted a literal array, use ["literal", [...]].`,0)}return t===void 0?this.error("'undefined' value invalid. Use null instead."):typeof t=="object"?this.error('Bare objects invalid. Use ["literal", {...}] instead.'):this.error(`Expected an array, but found ${typeof t} instead.`)}concat(t,r,i){let a=typeof t=="number"?this.path.concat(t):this.path,n=i?this.scope.concat(i):this.scope;return new j_(this.registry,this._isConstant,a,r||null,n,this.errors)}error(t,...r){let i=`${this.key}${r.map(a=>`[${a}]`).join("")}`;this.errors.push(new Or(i,t))}checkSubtype(t,r){let i=Un(t,r);return i&&this.error(i),i}},ra=class Cn{constructor(t,r,i,a,n){this.name=t,this.type=r,this._evaluate=i,this.args=a,this.key=n}evaluate(t){return this._evaluate(t,this.args,this.key)}eachChild(t){this.args.forEach(t)}outputDefined(){return!1}static parse(t,r){let i=t[0],a=Cn.definitions[i];if(!a)return r.error(`Unknown expression "${i}". If you wanted a literal array, use ["literal", [...]].`,0);let n=Array.isArray(a)?a[0]:a.type,s=Array.isArray(a)?[[a[1],a[2]]]:a.overloads,o=s.filter(([u])=>!Array.isArray(u)||u.length===t.length-1),l=null;for(let[u,h]of o){l=new $_(r.registry,qo,r.path,null,r.scope);let c=[],d=!1;for(let p=1;p<t.length;p++){let f=t[p],m=Array.isArray(u)?u[p-1]:u.type,g=l.parse(f,1+c.length,m);if(!g){d=!0;break}c.push(g)}if(!d){if(Array.isArray(u)&&u.length!==c.length){l.error(`Expected ${u.length} arguments, but found ${c.length} instead.`);continue}for(let p=0;p<c.length;p++){let f=Array.isArray(u)?u[p]:u.type,m=c[p];l.concat(p+1).checkSubtype(f,m.type)}if(l.errors.length===0)return new Cn(i,n,h,c,r.key)}}if(o.length===1)r.errors.push(...l.errors);else{let u=(o.length?o:s).map(([c])=>Yb(c)).join(" | "),h=[];for(let c=1;c<t.length;c++){let d=r.parse(t[c],1+h.length);if(!d)return null;h.push(Ke(d.type))}r.error(`Expected arguments of type ${u}, but found (${h.join(", ")}) instead.`)}return null}static register(t,r){Cn.definitions=r;for(let i in r)t[i]=Cn}};function nf(e,[t,r,i,a],n){t=t.evaluate(e),r=r.evaluate(e),i=i.evaluate(e);let s=a?a.evaluate(e):1,o=s_(t,r,i,s);if(o)throw new qe(o,n);return new oe(t/255,r/255,i/255,s,!1)}function sf(e,t){return e in t&&t[e]!==void 0}function zu(e,t){let r=t[e];return r===void 0?null:r}function Xb(e,t,r,i){for(;r<=i;){let a=r+i>>1;if(t[a]===e)return!0;t[a]>e?i=a-1:r=a+1}return!1}function Mi(e){return{type:e}}ra.register(Ma,{error:[kv,[le],(e,[t],r)=>{throw new qe(t.evaluate(e),r)}],typeof:[le,[ue],(e,[t])=>Ke(it(t.evaluate(e)))],"to-rgba":[Rt(V,4),[Dr],(e,[t])=>{let[r,i,a,n]=t.evaluate(e).rgb;return[r*255,i*255,a*255,n]}],rgb:[Dr,[V,V,V],nf],rgba:[Dr,[V,V,V,V],nf],has:{type:fe,overloads:[[[le],(e,[t])=>sf(t.evaluate(e),e.properties())],[[le,Ui],(e,[t,r])=>sf(t.evaluate(e),r.evaluate(e))]]},get:{type:ue,overloads:[[[le],(e,[t])=>zu(t.evaluate(e),e.properties())],[[le,Ui],(e,[t,r])=>zu(t.evaluate(e),r.evaluate(e))]]},"feature-state":[ue,[le],(e,[t])=>zu(t.evaluate(e),e.featureState||{})],properties:[Ui,[],e=>e.properties()],"geometry-type":[le,[],e=>e.geometryType()],id:[ue,[],e=>e.id()],zoom:[V,[],e=>e.globals.zoom],"heatmap-density":[V,[],e=>e.globals.heatmapDensity||0],elevation:[V,[],e=>e.globals.elevation||0],"line-progress":[V,[],e=>e.globals.lineProgress||0],accumulated:[ue,[],e=>e.globals.accumulated===void 0?null:e.globals.accumulated],"+":[V,Mi(V),(e,t)=>{let r=0;for(let i of t)r+=i.evaluate(e);return r}],"*":[V,Mi(V),(e,t)=>{let r=1;for(let i of t)r*=i.evaluate(e);return r}],"-":{type:V,overloads:[[[V,V],(e,[t,r])=>t.evaluate(e)-r.evaluate(e)],[[V],(e,[t])=>-t.evaluate(e)]]},"/":[V,[V,V],(e,[t,r])=>t.evaluate(e)/r.evaluate(e)],"%":[V,[V,V],(e,[t,r])=>t.evaluate(e)%r.evaluate(e)],ln2:[V,[],()=>Math.LN2],pi:[V,[],()=>Math.PI],e:[V,[],()=>Math.E],"^":[V,[V,V],(e,[t,r])=>t.evaluate(e)**+r.evaluate(e)],sqrt:[V,[V],(e,[t])=>Math.sqrt(t.evaluate(e))],log10:[V,[V],(e,[t])=>Math.log(t.evaluate(e))/Math.LN10],ln:[V,[V],(e,[t])=>Math.log(t.evaluate(e))],log2:[V,[V],(e,[t])=>Math.log(t.evaluate(e))/Math.LN2],sin:[V,[V],(e,[t])=>Math.sin(t.evaluate(e))],cos:[V,[V],(e,[t])=>Math.cos(t.evaluate(e))],tan:[V,[V],(e,[t])=>Math.tan(t.evaluate(e))],asin:[V,[V],(e,[t])=>Math.asin(t.evaluate(e))],acos:[V,[V],(e,[t])=>Math.acos(t.evaluate(e))],atan:[V,[V],(e,[t])=>Math.atan(t.evaluate(e))],min:[V,Mi(V),(e,t)=>Math.min(...t.map(r=>r.evaluate(e)))],max:[V,Mi(V),(e,t)=>Math.max(...t.map(r=>r.evaluate(e)))],abs:[V,[V],(e,[t])=>Math.abs(t.evaluate(e))],round:[V,[V],(e,[t])=>{let r=t.evaluate(e);return r<0?-Math.round(-r):Math.round(r)}],floor:[V,[V],(e,[t])=>Math.floor(t.evaluate(e))],ceil:[V,[V],(e,[t])=>Math.ceil(t.evaluate(e))],"filter-==":[fe,[le,ue],(e,[t,r])=>e.properties()[t.value]===r.value],"filter-id-==":[fe,[ue],(e,[t])=>e.id()===t.value],"filter-type-==":[fe,[le],(e,[t])=>e.geometryType()===t.value],"filter-<":[fe,[le,ue],(e,[t,r])=>{let i=e.properties()[t.value],a=r.value;return typeof i==typeof a&&i<a}],"filter-id-<":[fe,[ue],(e,[t])=>{let r=e.id(),i=t.value;return typeof r==typeof i&&r<i}],"filter->":[fe,[le,ue],(e,[t,r])=>{let i=e.properties()[t.value],a=r.value;return typeof i==typeof a&&i>a}],"filter-id->":[fe,[ue],(e,[t])=>{let r=e.id(),i=t.value;return typeof r==typeof i&&r>i}],"filter-<=":[fe,[le,ue],(e,[t,r])=>{let i=e.properties()[t.value],a=r.value;return typeof i==typeof a&&i<=a}],"filter-id-<=":[fe,[ue],(e,[t])=>{let r=e.id(),i=t.value;return typeof r==typeof i&&r<=i}],"filter->=":[fe,[le,ue],(e,[t,r])=>{let i=e.properties()[t.value],a=r.value;return typeof i==typeof a&&i>=a}],"filter-id->=":[fe,[ue],(e,[t])=>{let r=e.id(),i=t.value;return typeof r==typeof i&&r>=i}],"filter-has":[fe,[ue],(e,[t])=>{let r=t.value,i=e.properties();return r in i&&i[r]!==void 0}],"filter-has-id":[fe,[],e=>e.id()!==null&&e.id()!==void 0],"filter-type-in":[fe,[Rt(le)],(e,[t])=>t.value.indexOf(e.geometryType())>=0],"filter-id-in":[fe,[Rt(ue)],(e,[t])=>t.value.indexOf(e.id())>=0],"filter-in-small":[fe,[le,Rt(ue)],(e,[t,r])=>r.value.indexOf(e.properties()[t.value])>=0],"filter-in-large":[fe,[le,Rt(ue)],(e,[t,r])=>Xb(e.properties()[t.value],r.value,0,r.value.length-1)],all:{type:fe,overloads:[[[fe,fe],(e,[t,r])=>t.evaluate(e)&&r.evaluate(e)],[Mi(fe),(e,t)=>{for(let r of t)if(!r.evaluate(e))return!1;return!0}]]},any:{type:fe,overloads:[[[fe,fe],(e,[t,r])=>t.evaluate(e)||r.evaluate(e)],[Mi(fe),(e,t)=>{for(let r of t)if(r.evaluate(e))return!0;return!1}]]},"!":[fe,[fe],(e,[t])=>!t.evaluate(e)],"is-supported-script":[fe,[le],(e,[t])=>{let r=e.globals&&e.globals.isSupportedScript;return!r||r(t.evaluate(e))}],upcase:[le,[le],(e,[t])=>t.evaluate(e).toUpperCase()],downcase:[le,[le],(e,[t])=>t.evaluate(e).toLowerCase()],concat:[le,Mi(ue),(e,t)=>t.map(r=>Rn(r.evaluate(e))).join("")],split:[Rt(le),[le,le],(e,[t,r])=>t.evaluate(e).split(r.evaluate(e))],join:[le,[Rt(le),le],(e,[t,r])=>t.evaluate(e).join(r.evaluate(e))],"resolved-locale":[le,[bl],(e,[t])=>t.evaluate(e).resolvedLocale()]});function Yb(e){return Array.isArray(e)?`(${e.map(Ke).join(", ")})`:`(${Ke(e.type)}...)`}function qo(e){if(e instanceof __)return qo(e.boundExpression);if(e instanceof ra&&e.name==="error"||e instanceof E_||e instanceof ed||e instanceof ad||e instanceof nd)return!1;let t=e instanceof Pa||e instanceof ti,r=!0;return e.eachChild(i=>{r&&(r=t?qo(i):i instanceof Na)}),r?Al(e)&&Cl(e,["zoom","heatmap-density","elevation","line-progress","accumulated","is-supported-script"]):!1}function Al(e){if(e instanceof ra&&(e.name==="get"&&e.args.length===1||e.name==="feature-state"||e.name==="has"&&e.args.length===1||e.name==="properties"||e.name==="geometry-type"||e.name==="id"||/^filter-/.test(e.name))||e instanceof ed||e instanceof ad)return!1;let t=!0;return e.eachChild(r=>{t&&!Al(r)&&(t=!1)}),t}function qn(e){if(e instanceof ra&&e.name==="feature-state")return!1;let t=!0;return e.eachChild(r=>{t&&!qn(r)&&(t=!1)}),t}function Cl(e,t){if(e instanceof ra&&t.indexOf(e.name)>=0)return!1;let r=!0;return e.eachChild(i=>{r&&!Cl(i,t)&&(r=!1)}),r}function Ua(e){return e["property-type"]==="data-driven"||e["property-type"]==="cross-faded-data-driven"}function V_(e){return!!e.expression&&e.expression.parameters.indexOf("zoom")>-1}function sd(e){return!!e.expression&&e.expression.interpolated}const od=/^(.*)-transition$/;function Zn(e,...t){for(let r of t)for(let i in r)e[i]=r[i];return e}function pe(e){return e instanceof Number?"number":e instanceof String?"string":e instanceof Boolean?"boolean":Array.isArray(e)?"array":e===null?"null":typeof e}function Il(e){return typeof e=="object"&&!!e&&!Array.isArray(e)&&it(e)===Ui}function Kb(e){return e}function Jb(e){switch(e.type){case"color":return oe.parse;case"padding":return Hr.parse;case"numberArray":return Xr.parse;case"colorArray":return gr.parse;default:return null}}function Qb(e){switch(e){case"exponential":return U_;case"interval":return t2;case"categorical":return e2;case"identity":return r2;default:throw Error(`Unknown function type "${e}"`)}}function N_(e,t){let r=e.stops&&typeof e.stops[0][0]=="object",i=r||e.property!==void 0,a=r||!i,n=e.type||(sd(t)?"exponential":"interval"),s=Jb(t);if(s&&(e=Zn({},e),e.stops&&(e.stops=e.stops.map(h=>[h[0],s(h[1])])),e.default?e.default=s(e.default):e.default=s(t.default)),e.colorSpace&&!qv(e.colorSpace))throw Error(`Unknown color space: "${e.colorSpace}"`);let o=Qb(n),l,u;if(n==="categorical"){l=Object.create(null);for(let h of e.stops)l[h[0]]=h[1];u=typeof e.stops[0][0]}if(r){let h={},c=[];for(let f=0;f<e.stops.length;f++){let m=e.stops[f],g=m[0].zoom;h[g]===void 0&&(h[g]={zoom:g,type:e.type,property:e.property,default:e.default,stops:[]},c.push(g)),h[g].stops.push([m[0].value,m[1]])}let d=[];for(let f of c)d.push([h[f].zoom,N_(h[f],t)]);let p={name:"linear"};return{kind:"composite",interpolationType:p,interpolationFactor:_r.interpolationFactor.bind(void 0,p),zoomStops:d.map(f=>f[0]),evaluate({zoom:f},m){return U_({stops:d,base:e.base},t,f).evaluate(f,m)}}}if(a){let h=n==="exponential"?{name:"exponential",base:e.base===void 0?1:e.base}:null;return{kind:"camera",interpolationType:h,interpolationFactor:_r.interpolationFactor.bind(void 0,h),zoomStops:e.stops.map(c=>c[0]),evaluate:({zoom:c})=>o(e,t,c,l,u)}}return{kind:"source",evaluate(h,c){let d=c&&c.properties?c.properties[e.property]:void 0;return d===void 0?fs(e.default,t.default):o(e,t,d,l,u)}}}function fs(e,t,r){if(e!==void 0)return e;if(t!==void 0)return t;if(r!==void 0)return r}function e2(e,t,r,i,a){return fs(typeof r===a?i[r]:void 0,e.default,t.default)}function t2(e,t,r){if(pe(r)!=="number")return fs(e.default,t.default);let i=e.stops.length;if(i===1||r<=e.stops[0][0])return e.stops[0][1];if(r>=e.stops[i-1][0])return e.stops[i-1][1];let a=Dl(e.stops.map(n=>n[0]),r,"");return e.stops[a][1]}function U_(e,t,r){let i=e.base===void 0?1:e.base;if(pe(r)!=="number")return fs(e.default,t.default);let a=e.stops.length;if(a===1||r<=e.stops[0][0])return e.stops[0][1];if(r>=e.stops[a-1][0])return e.stops[a-1][1];let n=Dl(e.stops.map(h=>h[0]),r,""),s=i2(r,i,e.stops[n][0],e.stops[n+1][0]),o=e.stops[n][1],l=e.stops[n+1][1],u=We[t.type]||Kb;return typeof o.evaluate=="function"?{evaluate(...h){let c=o.evaluate.apply(void 0,h),d=l.evaluate.apply(void 0,h);if(c!==void 0&&d!==void 0)return u(c,d,s,e.colorSpace)}}:u(o,l,s,e.colorSpace)}function r2(e,t,r){switch(t.type){case"color":r=oe.parse(r);break;case"formatted":r=ui.fromString(r.toString());break;case"resolvedImage":r=Zr.fromString(r.toString());break;case"padding":r=Hr.parse(r);break;case"colorArray":r=gr.parse(r);break;case"numberArray":r=Xr.parse(r);break;default:pe(r)!==t.type&&(t.type!=="enum"||!t.values[r])&&(r=void 0)}return fs(r,e.default,t.default)}function i2(e,t,r,i){let a=i-r,n=e-r;return a===0?0:t===1?n/a:(t**+n-1)/(t**+a-1)}function Ph(e){return{result:"success",value:e}}function Sa(e){return{result:"error",value:e}}var ld=class{constructor(t,r,i,a){this.expression=t,this._warningHistory={},this._evaluator=new l_,this._defaultValue=i?X_(i):null,this._enumValues=i&&i.type==="enum"?i.values:null,this._globalState=a,this._rootKey=r}evaluateWithoutErrorHandling(t,r,i,a,n,s){return this._globalState&&(t=Ga(t,this._globalState)),this._evaluator.globals=t,this._evaluator.feature=r,this._evaluator.featureState=i,this._evaluator.canonical=a,this._evaluator.availableImages=n||null,this._evaluator.formattedSection=s,this.expression.evaluate(this._evaluator)}evaluate(t,r,i,a,n,s){this._globalState&&(t=Ga(t,this._globalState)),this._evaluator.globals=t,this._evaluator.feature=r||null,this._evaluator.featureState=i||null,this._evaluator.canonical=a,this._evaluator.availableImages=n||null,this._evaluator.formattedSection=s||null;try{let o=this.expression.evaluate(this._evaluator);if(o==null||typeof o=="number"&&o!==o)return this._defaultValue;if(this._enumValues&&!(o in this._enumValues))throw new qe(`Expected value to be one of ${Object.keys(this._enumValues).map(l=>JSON.stringify(l)).join(", ")}, but found ${JSON.stringify(o)} instead.`,"");return o}catch(o){let l=o instanceof qe?o.path:"",u=`${l}|${o.message}`;return this._warningHistory[u]||(this._warningHistory[u]=!0,typeof console<"u"&&console.warn(G_(this._rootKey,l,o.message,this._defaultValue))),this._defaultValue}}};function G_(e,t,r,i){return`${e}${t}: ${r}${i==null?"":` Falling back to ${String(i)}.`}`}function q_(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 Ml(e){return Array.isArray(e)&&e.length>0&&typeof e[0]=="string"&&e[0]in Ma}function zl(e,t,r,i){q_(t);let a=new $_(Ma,qo,[],r?s2(r):void 0),n=a.parse(e,void 0,void 0,void 0,r&&r.type==="string"?{typeAnnotation:"coerce"}:void 0);return n?Ph(new ld(n,t,r,i)):Sa(a.errors)}var Wn=class{constructor(t,r,i){this.kind=t,this._styleExpression=r,this.isStateDependent=t!=="constant"&&!qn(r.expression),this.globalStateRefs=ms(r.expression),this._globalState=i}evaluateWithoutErrorHandling(t,r,i,a,n,s){return this._globalState&&(t=Ga(t,this._globalState)),this._styleExpression.evaluateWithoutErrorHandling(t,r,i,a,n,s)}evaluate(t,r,i,a,n,s){return this._globalState&&(t=Ga(t,this._globalState)),this._styleExpression.evaluate(t,r,i,a,n,s)}},Zo=class{constructor(t,r,i,a,n){this.kind=t,this.zoomStops=i,this._styleExpression=r,this.isStateDependent=t!=="camera"&&!qn(r.expression),this.globalStateRefs=ms(r.expression),this.interpolationType=a,this._globalState=n}evaluateWithoutErrorHandling(t,r,i,a,n,s){return this._globalState&&(t=Ga(t,this._globalState)),this._styleExpression.evaluateWithoutErrorHandling(t,r,i,a,n,s)}evaluate(t,r,i,a,n,s){return this._globalState&&(t=Ga(t,this._globalState)),this._styleExpression.evaluate(t,r,i,a,n,s)}interpolationFactor(t,r,i){return this.interpolationType?_r.interpolationFactor(this.interpolationType,t,r,i):0}};function a2(e){return e._styleExpression!==void 0}function Z_(e,t,r,i){let a=zl(e,t,r,i);if(a.result==="error")return a;let n=a.value.expression,s=Al(n);if(!s&&!Ua(r))return Sa([new Or("","data expressions not supported")]);let o=Cl(n,["zoom"]);if(!o&&!V_(r))return Sa([new Or("","zoom expressions not supported")]);let l=Co(n);if(!l&&!o)return Sa([new Or("",'"zoom" expression may only be used as input to a top-level "step" or "interpolate" expression.')]);if(l instanceof Or)return Sa([l]);if(l instanceof _r&&!sd(r))return Sa([new Or("",'"interpolate" expressions cannot be used with this property')]);if(!l)return Ph(s?new Wn("constant",a.value,i):new Wn("source",a.value,i));let u=l instanceof _r?l.interpolation:void 0;return Ph(s?new Zo("camera",a.value,l.labels,u,i):new Zo("composite",a.value,l.labels,u,i))}var W_=class H_{constructor(t,r,i){this.isStateDependent=!1,this.globalStateRefs=new Set,this._globalState=null,q_(r),this._parameters=t,this._specification=i,this._rootKey=r,this._defaultValue=X_(i),this._warningHistory={};let a=N_(this._parameters,this._specification);this.kind=a.kind,this.interpolationFactor=a.interpolationFactor,this.zoomStops=a.zoomStops,this.interpolationType=a.interpolationType,this._innerEvaluate=a.evaluate}evaluate(t,r){try{return this._innerEvaluate(t,r)}catch(i){let a=i instanceof Error?i.message:String(i),n=`|${a}`;return this._warningHistory[n]||(this._warningHistory[n]=!0,typeof console<"u"&&console.warn(G_(this._rootKey,"",a,this._defaultValue))),this._defaultValue}}static deserialize(t){return new H_(t._parameters,t._rootKey,t._specification)}static serialize(t){return{_parameters:t._parameters,_specification:t._specification,_rootKey:t._rootKey}}};function n2(e,t,r,i){if(Il(e))return new W_(e,t,r);if(Ml(e)){let a=Z_(e,t,r,i);if(a.result==="error")throw Error(a.value.map(n=>`${n.key}: ${n.message}`).join(", "));return a.value}{let a=e;return r.type==="color"&&typeof e=="string"?a=oe.parse(e):r.type==="padding"&&(typeof e=="number"||Array.isArray(e))?a=Hr.parse(e):r.type==="numberArray"&&(typeof e=="number"||Array.isArray(e))?a=Xr.parse(e):r.type==="colorArray"&&(typeof e=="string"||Array.isArray(e))?a=gr.parse(e):r.type==="variableAnchorOffsetCollection"&&Array.isArray(e)?a=qr.parse(e):r.type==="projectionDefinition"&&typeof e=="string"&&(a=Ai.parse(e)),{globalStateRefs:new Set,_globalState:null,kind:"constant",evaluate:()=>a}}}function Co(e){let t=null;if(e instanceof m_)t=Co(e.result);else if(e instanceof T_){for(let r of e.args)if(t=Co(r),t)break}else(e instanceof Kc||e instanceof _r)&&e.input instanceof ra&&e.input.name==="zoom"&&(t=e);return t instanceof Or||e.eachChild(r=>{let i=Co(r);i instanceof Or?t=i:!t&&i?t=new Or("",'"zoom" expression may only be used as input to a top-level "step" or "interpolate" expression.'):t&&i&&t!==i&&(t=new Or("",'Only one zoom-based "step" or "interpolate" subexpression may be used in an expression.'))}),t}function ms(e,t=new Set){return e instanceof nd&&t.add(e.key),e.eachChild(r=>{ms(r,t)}),t}function s2(e){let t={color:Dr,string:le,number:V,enum:le,boolean:fe,formatted:cs,padding:wl,numberArray:Tl,colorArray:Nn,projectionDefinition:vl,resolvedImage:ds,variableAnchorOffsetCollection:Sl};return e.type==="array"?Rt(t[e.value]||ue,e.length):t[e.type]}function X_(e){if(e.type==="color"&&Il(e.default))return new oe(0,0,0,0);switch(e.type){case"color":return oe.parse(e.default)||null;case"padding":return Hr.parse(e.default)||null;case"numberArray":return Xr.parse(e.default)||null;case"colorArray":return gr.parse(e.default)||null;case"variableAnchorOffsetCollection":return qr.parse(e.default)||null;case"projectionDefinition":return Ai.parse(e.default)||null;default:return e.default===void 0?null:e.default}}function Ga(e,t){let{zoom:r,heatmapDensity:i,elevation:a,lineProgress:n,isSupportedScript:s,accumulated:o}=e??{};return{zoom:r,heatmapDensity:i,elevation:a,lineProgress:n,isSupportedScript:s,accumulated:o,globalState:t}}function o2(e){let t=!1;for(let r of e){let i=Y_(r);if(i==="expression")return"expression";i==="legacy"&&(t=!0)}return t?"legacy":"neutral"}function Y_(e){if(typeof e=="boolean")return"neutral";if(!Array.isArray(e)||e.length===0)return"legacy";switch(e[0]){case"has":return e.length<2||e[1]==="$id"||e[1]==="$type"?"legacy":e.length===2?"neutral":"expression";case"in":return e.length>=3&&(typeof e[1]!="string"||Array.isArray(e[2]))?"expression":"legacy";case"!in":case"!has":return"legacy";case"==":case"!=":case">":case">=":case"<":case"<=":return e.length!==3||Array.isArray(e[1])||Array.isArray(e[2])?"expression":"legacy";case"none":return"legacy";case"any":case"all":return o2(e.slice(1));default:return"expression"}}function ud(e){return Y_(e)!=="legacy"}function of(e){return e==="$type"?["geometry-type"]:e==="$id"?["id"]:["get",e]}function l2(e){switch(e[0]){case"==":case"!=":case"<":case"<=":case">":case">=":return e.length!==3||typeof e[1]!="string"?null:[e[0],of(e[1]),e[2]];case"in":case"!in":{if(e.length<2||typeof e[1]!="string")return null;let t=["in",of(e[1]),["literal",e.slice(2)]];return e[0]==="!in"?["!",t]:t}case"has":case"!has":{if(e.length!==2||typeof e[1]!="string"||e[1]==="$type"||e[1]==="$id")return null;let t=["has",e[1]];return e[0]==="!has"?["!",t]:t}default:return null}}function K_(e){if((e[0]==="<"||e[0]==="<="||e[0]===">"||e[0]===">=")&&e[1]==="$type")return`"$type" cannot be use with operator "${e[0]}"`;let t=l2(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 Fu(e,t,r){let i=r[e];return Array.isArray(i)?ud(i)?hd(i,t.concat(e)):{path:t.concat(e),legacyFilter:i}:null}function hd(e,t=[]){if(!Array.isArray(e)||e.length<1)return null;switch(e[0]){case"all":case"any":case"none":for(let r=1;r<e.length;r++){let i=Fu(r,t,e);if(i)return i}break;case"!":{let r=Fu(1,t,e);if(r)return r;break}case"case":for(let r=1;r<e.length-1;r+=2){let i=Fu(r,t,e);if(i)return i}}return null}function u2(e,t){let r=hd(e);if(!r||typeof console>"u")return;let i=r.path.map(a=>`[${a}]`).join("");console.warn(`${t}${i}: ${K_(r.legacyFilter)}`)}const h2={type:"boolean",default:!1,transition:!1,"property-type":"data-driven",expression:{interpolated:!1,parameters:["zoom","feature"]}};function Hn(e,t,r){if(e==null)return{filter:()=>!0,needGeometry:!1,getGlobalStateRefs:()=>new Set};ud(e)?u2(e,t):e=Wo(e);let i=zl(e,t,h2,r);if(i.result==="error")throw Error(i.value.map(a=>`${a.key}: ${a.message}`).join(", "));return{filter:(a,n,s)=>i.value.evaluate(a,n,{},s),needGeometry:J_(e),getGlobalStateRefs:()=>ms(i.value.expression)}}function c2(e,t){return e<t?-1:+(e>t)}function J_(e){if(!Array.isArray(e))return!1;if(e[0]==="within"||e[0]==="distance")return!0;for(let t=1;t<e.length;t++)if(J_(e[t]))return!0;return!1}function Wo(e){if(!e)return!0;let t=e[0];return e.length<=1?t!=="any":t==="=="?Ru(e[1],e[2],"=="):t==="!="?Ws(Ru(e[1],e[2],"==")):t==="<"||t===">"||t==="<="||t===">="?Ru(e[1],e[2],t):t==="any"?d2(e.slice(1)):t==="all"?["all"].concat(e.slice(1).map(Wo)):t==="none"?["all"].concat(e.slice(1).map(Wo).map(Ws)):t==="in"?lf(e[1],e.slice(2)):t==="!in"?Ws(lf(e[1],e.slice(2))):t==="has"?uf(e[1]):t!=="!has"||Ws(uf(e[1]))}function Ru(e,t,r){switch(e){case"$type":return[`filter-type-${r}`,t];case"$id":return[`filter-id-${r}`,t];default:return[`filter-${r}`,e,t]}}function d2(e){return["any"].concat(e.map(Wo))}function lf(e,t){if(t.length===0)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(r=>typeof r!=typeof t[0])?["filter-in-large",e,["literal",t.sort(c2)]]:["filter-in-small",e,["literal",t]]}}function uf(e){switch(e){case"$type":return!0;case"$id":return["filter-has-id"];default:return["filter-has",e]}}function Ws(e){return["!",e]}function Q_(e){let t=e.key,r=e.value;return r?[new O(t,r,"constants have been deprecated as of v8")]:[]}function rt(e){return e instanceof Number||e instanceof String||e instanceof Boolean?e.valueOf():e}function Ki(e){if(Array.isArray(e))return e.map(Ki);if(e instanceof Object&&!(e instanceof Number||e instanceof String||e instanceof Boolean)){let t={};for(let r in e)t[r]=Ki(e[r]);return t}return rt(e)}function ar(e){let t=e.key,r=e.value,i=e.valueSpec||{},a=e.objectElementValidators||{},n=e.style,s=e.styleSpec,o=e.validateSpec,l=[],u=pe(r);if(u!=="object")return[new O(t,r,`object expected, ${u} found`)];for(let h in r){let c=h.split(".")[0],d=Fn(i,c)||i["*"],p;if(Fn(a,c))p=a[c];else if(Fn(i,c)){if(r[h]===void 0)continue;p=o}else if(a["*"])p=a["*"];else if(i["*"])p=o;else{l.push(new O(t,r[h],`unknown property "${h}"`));continue}l=l.concat(p({key:(t&&`${t}.`)+h,value:r[h],valueSpec:d,style:n,styleSpec:s,object:r,objectKey:h,validateSpec:o},r))}for(let h in i)a[h]||i[h].required&&i[h].default===void 0&&r[h]===void 0&&l.push(new O(t,r,`missing required property "${h}"`));return l}function cd(e){let t=e.value,r=e.valueSpec,i=e.validateSpec,a=e.style,n=e.styleSpec,s=e.key,o=e.arrayElementValidator||i;if(pe(t)!=="array")return[new O(s,t,`array expected, ${pe(t)} found`)];if(r.length&&t.length!==r.length)return[new O(s,t,`array length ${r.length} expected, length ${t.length} found`)];let l={type:r.value,values:r.values};n.$version<7&&(l.function=r.function),pe(r.value)==="object"&&(l=r.value);let u=[];for(let h=0;h<t.length;h++)u=u.concat(o({array:t,arrayIndex:h,value:t[h],valueSpec:l,validateSpec:e.validateSpec,style:a,styleSpec:n,key:`${s}[${h}]`}));return u}function Fl(e){let t=e.key,r=e.value,i=e.valueSpec,a=pe(r);return a==="number"&&r!==r&&(a="NaN"),a==="number"?"minimum"in i&&r<i.minimum?[new O(t,r,`${r} is less than the minimum value ${i.minimum}`)]:"maximum"in i&&r>i.maximum?[new O(t,r,`${r} is greater than the maximum value ${i.maximum}`)]:[]:[new O(t,r,`number expected, ${a} found`)]}function ey(e){let t=e.valueSpec,r=rt(e.value.type),i,a={},n,s,o=r!=="categorical"&&e.value.property===void 0,l=!o,u=pe(e.value.stops)==="array"&&pe(e.value.stops[0])==="array"&&pe(e.value.stops[0][0])==="object",h=ar({key:e.key,value:e.value,valueSpec:e.styleSpec.function,validateSpec:e.validateSpec,style:e.style,styleSpec:e.styleSpec,objectElementValidators:{stops:c,default:f}});return r==="identity"&&o&&h.push(new O(e.key,e.value,'missing required property "property"')),r!=="identity"&&!e.value.stops&&h.push(new O(e.key,e.value,'missing required property "stops"')),r==="exponential"&&e.valueSpec.expression&&!sd(e.valueSpec)&&h.push(new O(e.key,e.value,"exponential functions not supported")),e.styleSpec.$version>=8&&(l&&!Ua(e.valueSpec)?h.push(new O(e.key,e.value,"property functions not supported")):o&&!V_(e.valueSpec)&&h.push(new O(e.key,e.value,"zoom functions not supported"))),(r==="categorical"||u)&&e.value.property===void 0&&h.push(new O(e.key,e.value,'"property" property is required')),h;function c(m){if(r==="identity")return[new O(m.key,m.value,'identity function may not have a "stops" property')];let g=[],_=m.value;return g=g.concat(cd({key:m.key,value:_,valueSpec:m.valueSpec,validateSpec:m.validateSpec,style:m.style,styleSpec:m.styleSpec,arrayElementValidator:d})),pe(_)==="array"&&_.length===0&&g.push(new O(m.key,_,"array must have at least one stop")),g}function d(m){let g=[],_=m.value,y=m.key;if(pe(_)!=="array")return[new O(y,_,`array expected, ${pe(_)} found`)];if(_.length!==2)return[new O(y,_,`array length 2 expected, length ${_.length} found`)];if(u){if(pe(_[0])!=="object")return[new O(y,_,`object expected, ${pe(_[0])} found`)];if(_[0].zoom===void 0)return[new O(y,_,"object stop key must have zoom")];if(_[0].value===void 0)return[new O(y,_,"object stop key must have value")];if(s&&s>rt(_[0].zoom))return[new O(y,_[0].zoom,"stop zoom values must appear in ascending order")];rt(_[0].zoom)!==s&&(s=rt(_[0].zoom),n=void 0,a={}),g=g.concat(ar({key:`${y}[0]`,value:_[0],valueSpec:{zoom:{}},validateSpec:m.validateSpec,style:m.style,styleSpec:m.styleSpec,objectElementValidators:{zoom:Fl,value:p}}))}else g=g.concat(p({key:`${y}[0]`,value:_[0],validateSpec:m.validateSpec,style:m.style,styleSpec:m.styleSpec},_));return Ml(Ki(_[1]))?g.concat([new O(`${y}[1]`,_[1],"expressions are not allowed in function stops.")]):g.concat(m.validateSpec({key:`${y}[1]`,value:_[1],valueSpec:t,validateSpec:m.validateSpec,style:m.style,styleSpec:m.styleSpec}))}function p(m,g){let _=pe(m.value),y=rt(m.value),v=m.value===null?g:m.value;if(!i)i=_;else if(_!==i)return[new O(m.key,v,`${_} stop domain type must match previous stop domain type ${i}`)];if(_!=="number"&&_!=="string"&&_!=="boolean")return[new O(m.key,v,"stop domain value must be a number, string, or boolean")];if(_!=="number"&&r!=="categorical"){let x=`number expected, ${_} found`;return Ua(t)&&r===void 0&&(x+='\nIf you intended to use a categorical function, specify `"type": "categorical"`.'),[new O(m.key,v,x)]}return r==="categorical"&&_==="number"&&(!isFinite(y)||Math.floor(y)!==y)?[new O(m.key,v,`integer expected, found ${y}`)]:r!=="categorical"&&_==="number"&&n!==void 0&&y<n?[new O(m.key,v,"stop domain values must appear in ascending order")]:(n=y,r==="categorical"&&y in a?[new O(m.key,v,"stop domain values must be unique")]:(a[y]=!0,[]))}function f(m){return m.validateSpec({key:m.key,value:m.value,valueSpec:t,validateSpec:m.validateSpec,style:m.style,styleSpec:m.styleSpec})}}function qa(e){let t=(e.expressionContext==="property"?Z_:zl)(Ki(e.value),e.key,e.valueSpec);if(t.result==="error")return t.value.map(i=>new O(`${e.key}${i.key}`,e.value,i.message));let r=t.value.expression||t.value._styleExpression.expression;if(e.expressionContext==="property"&&e.propertyKey==="text-font"&&!r.outputDefined())return[new O(e.key,e.value,`Invalid data expression for "${e.propertyKey}". Output values must be contained as literals within the expression.`)];if(e.expressionContext==="property"&&e.propertyType==="layout"&&!qn(r))return[new O(e.key,e.value,'"feature-state" data expressions are not supported with layout properties.')];if(e.expressionContext==="filter"&&!qn(r))return[new O(e.key,e.value,'"feature-state" data expressions are not supported with filters.')];if(e.expressionContext&&e.expressionContext.indexOf("cluster")===0){if(!Cl(r,["zoom","feature-state"]))return[new O(e.key,e.value,'"zoom" and "feature-state" expressions are not supported with cluster properties.')];if(e.expressionContext==="cluster-initial"&&!Al(r))return[new O(e.key,e.value,"Feature data expressions are not supported with initial expression part of cluster properties.")]}return[]}function p2(e){let t=e.value,r=e.key,i=pe(t);return i==="boolean"?[]:[new O(r,t,`boolean expected, ${i} found`)]}function Ah(e){let t=e.key,r=e.value,i=pe(r);return i==="string"?oe.parse(String(r))?[]:[new O(t,r,`color expected, "${r}" found`)]:[new O(t,r,`color expected, ${i} found`)]}function Xn(e){let t=e.key,r=e.value,i=e.valueSpec,a=[];return Array.isArray(i.values)?i.values.indexOf(rt(r))===-1&&a.push(new O(t,r,`expected one of [${i.values.join(", ")}], ${JSON.stringify(r)} found`)):Object.keys(i.values).indexOf(rt(r))===-1&&a.push(new O(t,r,`expected one of [${Object.keys(i.values).join(", ")}], ${JSON.stringify(r)} found`)),a}function f2(e,t){let r=e;for(let i of t)r=r[i];return r}function m2(e,t){let r=hd(t);return r?[new O(`${e.key}${r.path.map(i=>`[${i}]`).join("")}`,f2(e.value,r.path),K_(r.legacyFilter),null,"warning")]:[]}function dd(e){let t=Ki(e.value);return ud(t)?[...m2(e,t),...qa(Zn({},e,{expressionContext:"filter",valueSpec:{value:"boolean"}}))]:ty(e)}function ty(e){let t=e.value,r=e.key;if(pe(t)!=="array")return[new O(r,t,`array expected, ${pe(t)} found`)];let i=e.styleSpec,a,n=[];if(t.length<1)return[new O(r,t,"filter array must have at least 1 element")];switch(n=n.concat(Xn({key:`${r}[0]`,value:t[0],valueSpec:i.filter_operator,style:e.style,styleSpec:e.styleSpec})),rt(t[0])){case"<":case"<=":case">":case">=":t.length>=2&&rt(t[1])==="$type"&&n.push(new O(r,t,`"$type" cannot be use with operator "${t[0]}"`));case"==":case"!=":t.length!==3&&n.push(new O(r,t,`filter array for operator "${t[0]}" must have 3 elements`));case"in":case"!in":t.length>=2&&(a=pe(t[1]),a!=="string"&&n.push(new O(`${r}[1]`,t[1],`string expected, ${a} found`)));for(let s=2;s<t.length;s++)a=pe(t[s]),rt(t[1])==="$type"?n=n.concat(Xn({key:`${r}[${s}]`,value:t[s],valueSpec:i.geometry_type,style:e.style,styleSpec:e.styleSpec})):a!=="string"&&a!=="number"&&a!=="boolean"&&n.push(new O(`${r}[${s}]`,t[s],`string, number, or boolean expected, ${a} found`));break;case"any":case"all":case"none":for(let s=1;s<t.length;s++)n=n.concat(ty({key:`${r}[${s}]`,value:t[s],style:e.style,styleSpec:e.styleSpec}));break;case"has":case"!has":a=pe(t[1]),t.length===2?a!=="string"&&n.push(new O(`${r}[1]`,t[1],`string expected, ${a} found`)):n.push(new O(r,t,`filter array for "${t[0]}" operator must have 2 elements`))}return n}function ry(e,t){let r=e.key,i=e.validateSpec,a=e.style,n=e.styleSpec,s=e.value,o=e.objectKey,l=n[`${t}_${e.layerType}`];if(!l)return[];let u=o.match(od);if(t==="paint"&&u&&l[u[1]]&&l[u[1]].transition)return i({key:r,value:s,valueSpec:n.transition,style:a,styleSpec:n});let h=e.valueSpec||l[o];if(!h)return[new O(r,s,`unknown property "${o}"`)];let c;if(pe(s)==="string"&&Ua(h)&&!h.tokens&&(c=/^{([^}]+)}$/.exec(s)))return[new O(r,s,`"${o}" does not support interpolation syntax
|
|
5
|
+
Use an identity property function instead: \`{ "type": "identity", "property": ${JSON.stringify(c[1])} }\`.`)];let d=[];return e.layerType==="symbol"&&o==="text-font"&&Il(Ki(s))&&rt(s.type)==="identity"&&d.push(new O(r,s,'"text-font" does not support identity functions')),d.concat(i({key:e.key,value:s,valueSpec:h,style:a,styleSpec:n,expressionContext:"property",propertyType:t,propertyKey:o}))}function iy(e){return ry(e,"paint")}function ay(e){return ry(e,"layout")}function ny(e){var l,u;let t=[],r=e.value,i=e.key,a=e.style,n=e.styleSpec;if(pe(r)!=="object")return[new O(i,r,`object expected, ${pe(r)} found`)];!r.type&&!r.ref&&t.push(new O(i,r,'either "type" or "ref" is required'));let s=rt(r.type),o=rt(r.ref);if(r.id){let h=rt(r.id);for(let c=0;c<e.arrayIndex;c++){let d=a.layers[c];rt(d.id)===h&&t.push(new O(i,r.id,`duplicate layer id "${r.id}", previously used at line ${d.id.__line__}`))}}if("ref"in r){["type","source","source-layer","filter","layout"].forEach(c=>{c in r&&t.push(new O(i,r[c],`"${c}" is prohibited for ref layers`))});let h;a.layers.forEach(c=>{rt(c.id)===o&&(h=c)}),h?h.ref?t.push(new O(i,r.ref,"ref cannot reference another ref layer")):s=rt(h.type):t.push(new O(i,r.ref,`ref layer "${o}" not found`))}else if(s!=="background")if(!r.source)t.push(new O(i,r,'missing required property "source"'));else{let h=a.sources&&a.sources[r.source],c=h&&rt(h.type);h?c==="vector"&&s==="raster"?t.push(new O(i,r.source,`layer "${r.id}" requires a raster source`)):c!=="raster-dem"&&s==="hillshade"||c!=="raster-dem"&&s==="color-relief"?t.push(new O(i,r.source,`layer "${r.id}" requires a raster-dem source`)):c==="raster"&&s!=="raster"?t.push(new O(i,r.source,`layer "${r.id}" requires a vector source`)):c==="vector"&&!r["source-layer"]?t.push(new O(i,r,`layer "${r.id}" must specify a "source-layer"`)):c==="raster-dem"&&s!=="hillshade"&&s!=="color-relief"?t.push(new O(i,r.source,"raster-dem source can only be used with layer type 'hillshade' or 'color-relief'.")):s==="line"&&r.paint&&r.paint["line-gradient"]&&(c!=="geojson"||!h.lineMetrics)&&t.push(new O(i,r,`layer "${r.id}" specifies a line-gradient, which requires a GeoJSON source with \`lineMetrics\` enabled.`)):t.push(new O(i,r.source,`source "${r.source}" not found`))}return s==="raster"&&((l=r.paint)!=null&&l.resampling)&&((u=r.paint)!=null&&u["raster-resampling"])&&t.push(new O(i,r.paint,`layer "${r.id}" redundantly specifies "resampling" and "raster-resampling" paint properties, but only one is allowed. It is advised to use "resampling".`)),t=t.concat(ar({key:i,value:r,valueSpec:n.layer,style:e.style,styleSpec:e.styleSpec,validateSpec:e.validateSpec,objectElementValidators:{"*"(){return[]},type(){return e.validateSpec({key:`${i}.type`,value:r.type,valueSpec:n.layer.type,style:e.style,styleSpec:e.styleSpec,validateSpec:e.validateSpec,object:r,objectKey:"type"})},filter:dd,layout(h){return ar({layer:r,key:h.key,value:h.value,style:h.style,styleSpec:h.styleSpec,validateSpec:h.validateSpec,objectElementValidators:{"*"(c){return ay(Zn({layerType:s},c))}}})},paint(h){return ar({layer:r,key:h.key,value:h.value,style:h.style,styleSpec:h.styleSpec,validateSpec:h.validateSpec,objectElementValidators:{"*"(c){return iy(Zn({layerType:s},c))}}})}}})),t}function Di(e){let t=e.value,r=e.key,i=pe(t);return i==="string"?[]:[new O(r,t,`string expected, ${i} found`)]}function g2(e){let t=e.sourceName??"",r=e.value,i=e.styleSpec,a=i.source_raster_dem,n=e.style,s=[],o=pe(r);if(r===void 0)return s;if(o!=="object")return s.push(new O("source_raster_dem",r,`object expected, ${o} found`)),s;let l=rt(r.encoding)==="custom",u=["redFactor","greenFactor","blueFactor","baseShift"],h=e.value.encoding?`"${e.value.encoding}"`:"Default";for(let c in r)!l&&u.includes(c)?s.push(new O(c,r[c],`In "${t}": "${c}" is only valid when "encoding" is set to "custom". ${h} encoding found`)):a[c]?s=s.concat(e.validateSpec({key:c,value:r[c],valueSpec:a[c],validateSpec:e.validateSpec,style:n,styleSpec:i})):s.push(new O(c,r[c],`unknown property "${c}"`));return s}const hf={promoteId:_2};function sy(e){let t=e.value,r=e.key,i=e.styleSpec,a=e.style,n=e.validateSpec;if(!t.type)return[new O(r,t,'"type" is required')];let s=rt(t.type),o;switch(s){case"vector":case"raster":return o=ar({key:r,value:t,valueSpec:i[`source_${s.replace("-","_")}`],style:e.style,styleSpec:i,objectElementValidators:hf,validateSpec:n}),o;case"raster-dem":return o=g2({sourceName:r,value:t,style:e.style,styleSpec:i,validateSpec:n}),o;case"geojson":if(o=ar({key:r,value:t,valueSpec:i.source_geojson,style:a,styleSpec:i,validateSpec:n,objectElementValidators:hf}),t.cluster)for(let l in t.clusterProperties){let[u,h]=t.clusterProperties[l],c=typeof u=="string"?[u,["accumulated"],["get",l]]:u;o.push(...qa({key:`${r}.${l}.map`,value:h,expressionContext:"cluster-map"})),o.push(...qa({key:`${r}.${l}.reduce`,value:c,expressionContext:"cluster-reduce"}))}return o;case"video":return ar({key:r,value:t,valueSpec:i.source_video,style:a,validateSpec:n,styleSpec:i});case"image":return ar({key:r,value:t,valueSpec:i.source_image,style:a,validateSpec:n,styleSpec:i});case"canvas":return[new O(r,null,"Please use runtime APIs to add canvas sources, rather than including them in stylesheets.","source.canvas")];default:return Xn({key:`${r}.type`,value:t.type,valueSpec:{values:["vector","raster","raster-dem","geojson","video","image"]}})}}function _2({key:e,value:t}){if(pe(t)==="string")return Di({key:e,value:t});{let r=[];for(let i in t)r.push(...Di({key:`${e}.${i}`,value:t[i]}));return r}}function oy(e){let t=e.value,r=e.styleSpec,i=r.light,a=e.style,n=[],s=pe(t);if(t===void 0)return n;if(s!=="object")return n=n.concat([new O("light",t,`object expected, ${s} found`)]),n;for(let o in t){let l=o.match(od);n=l&&i[l[1]]&&i[l[1]].transition?n.concat(e.validateSpec({key:o,value:t[o],valueSpec:r.transition,validateSpec:e.validateSpec,style:a,styleSpec:r})):i[o]?n.concat(e.validateSpec({key:o,value:t[o],valueSpec:i[o],validateSpec:e.validateSpec,style:a,styleSpec:r})):n.concat([new O(o,t[o],`unknown property "${o}"`)])}return n}function ly(e){let t=e.value,r=e.styleSpec,i=r.sky,a=e.style,n=pe(t);if(t===void 0)return[];if(n!=="object")return[new O("sky",t,`object expected, ${n} found`)];let s=[];for(let o in t){let l=o.match(od);s=l&&i[l[1]]&&i[l[1]].transition?s.concat(e.validateSpec({key:o,value:t[o],valueSpec:r.transition,style:a,styleSpec:r})):i[o]?s.concat(e.validateSpec({key:o,value:t[o],valueSpec:i[o],style:a,styleSpec:r})):s.concat([new O(o,t[o],`unknown property "${o}"`)])}return s}function uy(e){let t=e.value,r=e.styleSpec,i=r.terrain,a=e.style,n=[],s=pe(t);if(t===void 0)return n;if(s!=="object")return n=n.concat([new O("terrain",t,`object expected, ${s} found`)]),n;for(let o in t)n=i[o]?n.concat(e.validateSpec({key:o,value:t[o],valueSpec:i[o],validateSpec:e.validateSpec,style:a,styleSpec:r})):n.concat([new O(o,t[o],`unknown property "${o}"`)]);return n}function y2(e){return Di(e).length===0?[]:qa(e)}function x2(e){return Di(e).length===0?[]:qa(e)}function v2(e){let t=e.key,r=e.value;if(pe(r)==="array"){if(r.length<1||r.length>4)return[new O(t,r,`padding requires 1 to 4 values; ${r.length} values found`)];let i={type:"number"},a=[];for(let n=0;n<r.length;n++)a=a.concat(e.validateSpec({key:`${t}[${n}]`,value:r[n],validateSpec:e.validateSpec,valueSpec:i}));return a}return Fl({key:t,value:r,valueSpec:{}})}function b2(e){let t=e.key,r=e.value;if(pe(r)==="array"){let i={type:"number"};if(r.length<1)return[new O(t,r,"array length at least 1 expected, length 0 found")];let a=[];for(let n=0;n<r.length;n++)a=a.concat(e.validateSpec({key:`${t}[${n}]`,value:r[n],validateSpec:e.validateSpec,valueSpec:i}));return a}return Fl({key:t,value:r,valueSpec:{}})}function w2(e){let t=e.key,r=e.value;if(pe(r)==="array"){if(r.length<1)return[new O(t,r,"array length at least 1 expected, length 0 found")];let i=[];for(let a=0;a<r.length;a++)i=i.concat(Ah({key:`${t}[${a}]`,value:r[a]}));return i}return Ah({key:t,value:r})}function T2(e){let t=e.key,r=e.value,i=pe(r),a=e.styleSpec;if(i!=="array"||r.length<1||r.length%2!=0)return[new O(t,r,"variableAnchorOffsetCollection requires a non-empty array of even length")];let n=[];for(let s=0;s<r.length;s+=2)n=n.concat(Xn({key:`${t}[${s}]`,value:r[s],valueSpec:a.layout_symbol["text-anchor"]})),n=n.concat(cd({key:`${t}[${s+1}]`,value:r[s+1],valueSpec:{length:2,value:"number"},validateSpec:e.validateSpec,style:e.style,styleSpec:a}));return n}function hy(e){let t=[],r=e.value,i=e.key;if(Array.isArray(r)){let a=[],n=[];for(let s in r)r[s].id&&a.includes(r[s].id)&&t.push(new O(i,r,`all the sprites' ids must be unique, but ${r[s].id} is duplicated`)),a.push(r[s].id),r[s].url&&n.includes(r[s].url)&&t.push(new O(i,r,`all the sprites' URLs must be unique, but ${r[s].url} is duplicated`)),n.push(r[s].url),t=t.concat(ar({key:`${i}[${s}]`,value:r[s],valueSpec:{id:{type:"string",required:!0},url:{type:"string",required:!0}},validateSpec:e.validateSpec}));return t}return Di({key:i,value:r})}function S2(e){let t=e.value,r=e.styleSpec,i=r.projection,a=e.style,n=pe(t);if(t===void 0)return[];if(n!=="object")return[new O("projection",t,`object expected, ${n} found`)];let s=[];for(let o in t)s=i[o]?s.concat(e.validateSpec({key:o,value:t[o],valueSpec:i[o],style:a,styleSpec:r})):s.concat([new O(o,t[o],`unknown property "${o}"`)]);return s}function D2(e){let t=e.key,r=e.value;r=r instanceof String?r.valueOf():r;let i=pe(r);return i==="array"&&!P2(r)&&!E2(r)?[new O(t,r,`projection expected, invalid array ${JSON.stringify(r)} found`)]:["array","string"].includes(i)?[]:[new O(t,r,`projection expected, invalid type "${i}" found`)]}function E2(e){return!!["interpolate","step","literal"].includes(e[0])}function P2(e){return Array.isArray(e)&&e.length===3&&typeof e[0]=="string"&&typeof e[1]=="string"&&typeof e[2]=="number"}function Ch(e){return!!e&&e.constructor===Object}function cy(e){return Ch(e.value)?[]:[new O(e.key,e.value,`object expected, ${pe(e.value)} found`)]}const cf=1114111,A2=/^u\+(?:([0-9a-f]{1,6})(?:-([0-9a-f]{1,6}))?|([0-9a-f]{0,5}\?{1,6}))$/i;function C2(e,t){if(pe(t)!=="string")return[];let r=`${t}`,i=()=>[new O(e,t,'invalid unicode range, expected a value such as "U+26", "U+0-10FFFF" or "U+4??"')],a=r.match(A2);if(!a)return i();let[,n,s,o]=a;if(o!==void 0)return o.length>6?i():[];let l=parseInt(n,16),u=s===void 0?l:parseInt(s,16);return l>cf||u>cf?[new O(e,t,"unicode range is out of bounds, the maximum code point is U+10FFFF")]:l>u?[new O(e,t,`unicode range start must not be greater than its end, but ${r} is`)]:[]}function dy(e){let t=e.key??"font-faces",r=e.value,i=e.validateSpec,a=e.styleSpec??Kg,n=e.style;if(!Ch(r))return[new O(t,r,`object expected, ${pe(r)} found`)];let s=[];for(let o in r){let l=r[o],u=pe(l);if(u==="string")s.push(...Di({key:`${t}.${o}`,value:l}));else if(u==="array"){let h={url:{type:"string",required:!0},"unicode-range":{type:"array",value:"string"}};for(let[c,d]of l.entries()){let p=`${t}.${o}[${c}]`;s.push(...ar({key:p,value:d,valueSpec:h,styleSpec:a,style:n,validateSpec:i}));let f=Ch(d)?d["unicode-range"]:void 0;if(pe(f)==="array")for(let[m,g]of f.entries())s.push(...C2(`${p}.unicode-range[${m}]`,g))}}else s.push(new O(`${t}.${o}`,l,`string or array expected, ${u} found`))}return s}const df={"*"(){return[]},array:cd,boolean:p2,number:Fl,color:Ah,constants:Q_,enum:Xn,filter:dd,function:ey,layer:ny,object:ar,source:sy,light:oy,sky:ly,terrain:uy,projection:S2,projectionDefinition:D2,string:Di,formatted:y2,resolvedImage:x2,padding:v2,numberArray:b2,colorArray:w2,variableAnchorOffsetCollection:T2,sprite:hy,state:cy,fontFaces:dy};function Ho(e){let t=e.value,r=e.valueSpec,i=e.styleSpec;return e.validateSpec=Ho,r.expression&&Il(rt(t))?ey(e):r.expression&&Ml(Ki(t))?qa(e):r.type&&df[r.type]?df[r.type](e):ar(Zn({},e,{valueSpec:r.type?i[r.type]:r}))}function py(e){let t=e.value,r=e.key,i=Di(e);return i.length||(t.indexOf("{fontstack}")===-1&&i.push(new O(r,t,'"glyphs" url must include a "{fontstack}" token')),t.indexOf("{range}")===-1&&i.push(new O(r,t,'"glyphs" url must include a "{range}" token'))),i}function Qt(e,t=z){let r=[];return r=r.concat(Ho({key:"",value:e,valueSpec:t.$root,styleSpec:t,style:e,validateSpec:Ho,objectElementValidators:{glyphs:py,"*"(){return[]}}})),e.constants&&(r=r.concat(Q_({key:"constants",value:e.constants}))),fy(r)}Qt.source=hr(ur(sy)),Qt.sprite=hr(ur(hy)),Qt.glyphs=hr(ur(py)),Qt.fontFaces=hr(ur(dy)),Qt.light=hr(ur(oy)),Qt.sky=hr(ur(ly)),Qt.terrain=hr(ur(uy)),Qt.state=hr(ur(cy)),Qt.layer=hr(ur(ny)),Qt.filter=hr(ur(dd)),Qt.paintProperty=hr(ur(iy)),Qt.layoutProperty=hr(ur(ay));function ur(e){return function(t){return e(Object.assign({},t,{validateSpec:Ho}))}}function fy(e){return[].concat(e).sort((t,r)=>t.line-r.line)}function hr(e){return function(...t){return fy(e.apply(this,t))}}const I2={type:"enum","property-type":"data-constant",expression:{interpolated:!1,parameters:["global-state"]},values:{visible:{},none:{}},transition:!1,default:"visible"};var M2=class{constructor(t,r,i){this._rootKey=r,this._globalState=i,this.setValue(t)}evaluate(){return this._literalValue??this._compiledValue.evaluate({})}setValue(t){if(t==null||t==="visible"||t==="none"){this._literalValue=t==="none"?"none":"visible",this._compiledValue=void 0,this._globalStateRefs=new Set;return}let r=zl(t,this._rootKey,I2,this._globalState);if(r.result==="error")throw this._literalValue="visible",this._compiledValue=void 0,Error(r.value.map(i=>`${i.key}: ${i.message}`).join(", "));this._literalValue=void 0,this._compiledValue=r.value,this._globalStateRefs=ms(r.value.expression)}getGlobalStateRefs(){return this._globalStateRefs}};function z2(e,t,r){return new M2(e,t,r)}const Zt=Qt,my=new Set(Object.keys(z).filter(e=>e.startsWith("source_")).map(e=>e.slice(7).replaceAll("_","-")));function F2(e){return Object.entries(e.sources??{}).filter(([,t])=>!my.has(t.type)).map(([t])=>`sources.${t}`)}function pf(e,t){let r=F2(t);return pd(e,Zt(t).filter(({message:i})=>!r.some(a=>i.startsWith(`${a}:`)||i.startsWith(`${a}.`))))}function pd(e,t){let r=!1;for(let i of t){if(i.severity==="warning"){_e(i.message);continue}e.fire(new Y(Error(i.message))),r=!0}return r}function gs(e,t,r,i){return(i==null?void 0:i.validate)!==!1&&pd(e,t({styleSpec:z,...r}))}var Ih=class gy{constructor(t,r,i){let a=this.cells=[];if(t instanceof ArrayBuffer){this.arrayBuffer=t;let s=new Int32Array(this.arrayBuffer);t=s[0],r=s[1],i=s[2],this.d=r+2*i;for(let u=0;u<this.d*this.d;u++){let h=s[3+u],c=s[3+u+1];a.push(h===c?null:s.subarray(h,c))}let o=s[3+a.length],l=s[3+a.length+1];this.keys=s.subarray(o,l),this.bboxes=s.subarray(l),this.insert=this._insertReadonly}else{this.d=r+2*i;for(let s=0;s<this.d*this.d;s++)a.push([]);this.keys=[],this.bboxes=[]}this.n=r,this.extent=t,this.padding=i,this.scale=r/t,this.uid=0;let n=i/r*t;this.min=-n,this.max=t+n}insert(t,r,i,a,n){this._forEachCell(r,i,a,n,this._insertCell,this.uid++,void 0,void 0),this.keys.push(t),this.bboxes.push(r),this.bboxes.push(i),this.bboxes.push(a),this.bboxes.push(n)}_insertReadonly(){throw Error("Cannot insert into a GridIndex created from an ArrayBuffer.")}_insertCell(t,r,i,a,n,s){this.cells[n].push(s)}query(t,r,i,a,n){let s=this.min,o=this.max;if(t<=s&&r<=s&&o<=i&&o<=a&&!n)return[...this.keys];{let l=[];return this._forEachCell(t,r,i,a,this._queryCell,l,{},n),l}}_queryCell(t,r,i,a,n,s,o,l){let u=this.cells[n];if(u!==null){let h=this.keys,c=this.bboxes;for(let d of u)if(o[d]===void 0){let p=d*4;(l?l(c[p+0],c[p+1],c[p+2],c[p+3]):t<=c[p+2]&&r<=c[p+3]&&i>=c[p+0]&&a>=c[p+1])?(o[d]=!0,s.push(h[d])):o[d]=!1}}}_forEachCell(t,r,i,a,n,s,o,l){let u=this._convertToCellCoord(t),h=this._convertToCellCoord(r),c=this._convertToCellCoord(i),d=this._convertToCellCoord(a);for(let p=u;p<=c;p++)for(let f=h;f<=d;f++){let m=this.d*f+p;if((!l||l(this._convertFromCellCoord(p),this._convertFromCellCoord(f),this._convertFromCellCoord(p+1),this._convertFromCellCoord(f+1)))&&n.call(this,t,r,i,a,m,s,o,l))return}}_convertFromCellCoord(t){return(t-this.padding)/this.scale}_convertToCellCoord(t){return Math.max(0,Math.min(this.d-1,Math.floor(t*this.scale)+this.padding))}toArrayBuffer(){if(this.arrayBuffer)return this.arrayBuffer;let t=this.cells,r=3+this.cells.length+1+1,i=0;for(let s of this.cells)i+=s.length;let a=new Int32Array(r+i+this.keys.length+this.bboxes.length);a[0]=this.extent,a[1]=this.n,a[2]=this.padding;let n=r;for(let s=0;s<t.length;s++){let o=t[s];a[3+s]=n,a.set(o,n),n+=o.length}return a[3+t.length]=n,a.set(this.keys,n),n+=this.keys.length,a[3+t.length+1]=n,a.set(this.bboxes,n),n+=this.bboxes.length,a.buffer}static serialize(t,r){let i=t.toArrayBuffer();return r&&r.push(i),{buffer:i}}static deserialize(t){return new gy(t.buffer)}};const ri={};function G(e,t,r={}){if(ri[e])throw Error(`${e} is already registered.`);Object.defineProperty(t,"_classRegistryKey",{value:e,writeable:!1}),ri[e]={klass:t,omit:r.omit||[],shallow:r.shallow||[]}}G("Object",Object),G("Set",Set),G("TransferableGridIndex",Ih),G("Color",oe),G("Error",Error),G("AJAXError",Vo),G("ResolvedImage",Zr),G("StylePropertyFunction",W_),G("StyleExpression",ld,{omit:["_evaluator"]}),G("ZoomDependentExpression",Zo),G("ZoomConstantExpression",Wn),G("CompoundExpression",ra,{omit:["_evaluate"]});for(let e in Ma)Ma[e]._classRegistryKey||G(`Expression_${e}`,Ma[e]);function _y(e){var t;return e&&typeof ArrayBuffer<"u"&&(e instanceof ArrayBuffer||((t=e.constructor)==null?void 0:t.name)==="ArrayBuffer")}function fd(e){let t=e.constructor;return e.$name||t._classRegistryKey}function R2(e){if(typeof e!="object"||!e)return!1;let t=fd(e);return t&&t!=="Object"}function yy(e){return!R2(e)&&(e==null||typeof e=="boolean"||typeof e=="number"||typeof e=="string"||e instanceof Boolean||e instanceof Number||e instanceof String||e instanceof Date||e instanceof RegExp||e instanceof Blob||e instanceof Error||_y(e)||Ni(e)||ArrayBuffer.isView(e)||e instanceof ImageData)}function kn(e,t){if(yy(e))return(_y(e)||Ni(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 n=[];for(let s of e)n.push(kn(s,t));return n}if(typeof e!="object")throw Error(`can't serialize object of type ${typeof e}`);let r=fd(e);if(!r)throw Error(`can't serialize object of unregistered class ${e.constructor.name}`);if(!ri[r])throw Error(`${r} is not registered.`);let{klass:i}=ri[r],a=i.serialize?i.serialize(e,t):{};if(i.serialize){if(a===(t==null?void 0:t[t.length-1]))throw Error("statically serialized object won't survive transfer of $name property")}else{for(let n in e){if(!e.hasOwnProperty(n)||ri[r].omit.includes(n))continue;let s=e[n];s!==void 0&&(a[n]=ri[r].shallow.includes(n)?s:kn(s,t))}e instanceof Error&&(a.message=e.message)}if(a.$name)throw Error("$name property is reserved for worker serialization logic.");return r!=="Object"&&(a.$name=r),a}function Ln(e){if(yy(e))return e;if(Array.isArray(e))return e.map(Ln);if(typeof e!="object")throw Error(`can't deserialize object of type ${typeof e}`);let t=fd(e)||"Object";if(!ri[t])throw Error(`can't deserialize unregistered class ${t}`);let{klass:r}=ri[t];if(!r)throw Error(`can't deserialize unregistered class ${t}`);if(r.deserialize)return r.deserialize(e);let i=Object.create(r.prototype);for(let a of Object.keys(e)){if(a==="$name")continue;let n=e[a];i[a]=ri[t].shallow.includes(a)?n:Ln(n)}return i}var Mh=class{constructor(){this.first=!0}update(t,r){let i=Math.floor(t);return this.first?(this.first=!1,this.lastIntegerZoom=i,this.lastIntegerZoomTime=0,this.lastZoom=t,this.lastFloorZoom=i,!0):(this.lastFloorZoom>i?(this.lastIntegerZoom=i+1,this.lastIntegerZoomTime=r):this.lastFloorZoom<i&&(this.lastIntegerZoom=i,this.lastIntegerZoomTime=r),t!==this.lastZoom&&(this.lastZoom=t,this.lastFloorZoom=i,!0))}},ze=class{constructor(t,r){this.zoom=t,r?(this.now=r.now||0,this.fadeDuration=r.fadeDuration||0,this.zoomHistory=r.zoomHistory||new Mh,this.transition=r.transition||{}):(this.now=0,this.fadeDuration=0,this.zoomHistory=new Mh,this.transition={})}crossFadingFactor(){return this.fadeDuration===0?1:Math.min((this.now-this.zoomHistory.lastIntegerZoomTime)/this.fadeDuration,1)}getCrossfadeParameters(){let t=this.zoom,r=t-Math.floor(t),i=this.crossFadingFactor();return t>this.zoomHistory.lastIntegerZoom?{fromScale:2,toScale:1,t:r+(1-r)*i}:{fromScale:.5,toScale:1,t:1-(1-i)*r}}},Yn=class{constructor(t,r,i,a){this.property=t,this.value=r,this.expression=n2(r===void 0?t.specification.default:r,i,t.specification,a)}isDataDriven(){return this.expression.kind==="source"||this.expression.kind==="composite"}getGlobalStateRefs(){return this.expression.globalStateRefs||new Set}readsGlobalState(t){let r=this.getGlobalStateRefs();return t.some(i=>r.has(i))}possiblyEvaluate(t,r,i){return this.property.possiblyEvaluate(this,t,r,i)}},zh=class{constructor(t,r,i){this.property=t,this.value=new Yn(t,void 0,r,i)}transitioned(t,r){return r.value===this.value?r:new ff(this.property,this.value,r,H({},t.transition,this.transition),t.now)}untransitioned(){return new ff(this.property,this.value,null,{},0)}},Rl=class{constructor(t,r,i){this._properties=t,this._values=Object.create(t.defaultTransitionablePropertyValues),this._globalState=i,this._rootKey=r}_propertyRootKey(t){return`${this._rootKey}.${String(t)}`}hasProperty(t){return t in this._properties.defaultTransitionablePropertyValues}getValue(t){return Wt(this._values[t].value.value)}setValue(t,r){Object.hasOwn(this._values,t)||(this._values[t]=new zh(this._values[t].property,this._propertyRootKey(t),this._globalState)),this._values[t].value=new Yn(this._values[t].property,r===null?void 0:Wt(r),this._propertyRootKey(t),this._globalState)}setValues(t){for(let r in t){let i=t[r];r.endsWith("-transition")?this.setTransition(r.slice(0,-11),i):Br(this._values[r].value.value,i)||this.setValue(r,i)}}getTransition(t){return Wt(this._values[t].transition)}setTransition(t,r){Object.hasOwn(this._values,t)||(this._values[t]=new zh(this._values[t].property,this._propertyRootKey(t),this._globalState)),this._values[t].transition=Wt(r)||void 0}retainPriorGlobalState(t,r,i){for(let a of Object.keys(i._values))for(let n=i._values[a];n;n=n.prior){let{value:s}=n;s.property.specification.transition&&!s.isDataDriven()&&s.expression._globalState===this._globalState&&s.readsGlobalState(t)&&(n.value=new Yn(s.property,s.value,this._propertyRootKey(a),r))}}applyGlobalStateChange(t,r,i,a){this.retainPriorGlobalState(t,r,i);let n=!1;for(let s of Object.keys(this._values)){let{value:o}=this._values[s];o.readsGlobalState(t)&&(this.setValue(s,o.value),n=!0)}return n?this.transitioned(a,i):i}serialize(){let t={};for(let r of Object.keys(this._values)){let i=this.getValue(r);i!==void 0&&(t[r]=i);let a=this.getTransition(r);a!==void 0&&(t[`${r}-transition`]=a)}return t}transitioned(t,r){let i=new mf(this._properties);for(let a of Object.keys(this._values))i._values[a]=this._values[a].transitioned(t,r._values[a]);return i}untransitioned(){let t=new mf(this._properties);for(let r of Object.keys(this._values))t._values[r]=this._values[r].untransitioned();return t}},ff=class{constructor(t,r,i,a,n){this.property=t,this.value=r,this.begin=n+a.delay||0,this.end=this.begin+a.duration||0,t.specification.transition&&(a.delay||a.duration)&&(this.prior=i)}possiblyEvaluate(t,r,i){let a=t.now||0,n=this.value.possiblyEvaluate(t,r,i),s=this.prior;if(!s)return n;if(a>this.end||this.value.isDataDriven())return this.prior=null,n;if(a<this.begin)return s.possiblyEvaluate(t,r,i);{let o=(a-this.begin)/(this.end-this.begin);return this.property.interpolate(s.possiblyEvaluate(t,r,i),n,pv(o))}}},mf=class{constructor(t){this._properties=t,this._values=Object.create(t.defaultTransitioningPropertyValues)}possiblyEvaluate(t,r,i){let a=new kl(this._properties);for(let n of Object.keys(this._values))a._values[n]=this._values[n].possiblyEvaluate(t,r,i);return a}hasTransition(){for(let t of Object.keys(this._values))if(this._values[t].prior)return!0;return!1}},k2=class{constructor(t,r,i){this._properties=t,this._values=Object.create(t.defaultPropertyValues),this._globalState=i,this._rootKey=r}_propertyRootKey(t){return`${this._rootKey}.${String(t)}`}hasValue(t){return this._values[t].value!==void 0}hasProperty(t){return t in this._properties.defaultPropertyValues}getValue(t){return Wt(this._values[t].value)}setValue(t,r){this._values[t]=new Yn(this._values[t].property,r===null?void 0:Wt(r),this._propertyRootKey(t),this._globalState)}serialize(){let t={};for(let r of Object.keys(this._values)){let i=this.getValue(r);i!==void 0&&(t[r]=i)}return t}possiblyEvaluate(t,r,i){let a=new kl(this._properties);for(let n of Object.keys(this._values))a._values[n]=this._values[n].possiblyEvaluate(t,r,i);return a}},mr=class{constructor(t,r,i){this.property=t,this.value=r,this.parameters=i}isConstant(){return this.value.kind==="constant"}constantOr(t){return this.value.kind==="constant"?this.value.value:t}evaluate(t,r,i,a){return this.property.evaluate(this.value,this.parameters,t,r,i,a)}},kl=class{constructor(t){this._properties=t,this._values=Object.create(t.defaultPossiblyEvaluatedValues)}get(t){return this._values[t]}};function gf(e){if(Array.isArray(e))return e.length;let t=e==null?void 0:e.values;return Array.isArray(t)?t.length:void 0}function xy(e,t){let r=gf(e),i=gf(t);return r!==void 0&&i!==void 0&&r!==i}var N=class{constructor(t,r){this.specification=t,this.name=r}possiblyEvaluate(t,r){if(t.isDataDriven())throw Error("Value should not be data driven");return t.expression.evaluate(r)}interpolate(t,r,i){if(xy(t,r))return _e(`Property "${this.name}" is trying to interpolate arrays of different lengths. Rendering may 'jump'.`),r;let a=this.specification.type,n=We[a];return n?n(t,r,i):t}},K=class{constructor(t,r,i){this.specification=t,this.name=r,this.overrides=i}possiblyEvaluate(t,r,i,a){return t.expression.kind==="constant"||t.expression.kind==="camera"?new mr(this,{kind:"constant",value:t.expression.evaluate(r,null,{},i,a)},r):new mr(this,t.expression,r)}interpolate(t,r,i){if(t.value.kind!=="constant"||r.value.kind!=="constant")return t;if(t.value.value===void 0||r.value.value===void 0)return new mr(this,{kind:"constant",value:void 0},t.parameters);if(xy(t.value.value,r.value.value))return _e(`Property "${this.name}" is trying to interpolate arrays of different lengths. Rendering may 'jump'.`),r;let a=this.specification.type,n=We[a];if(n){let s=n(t.value.value,r.value.value,i);return new mr(this,{kind:"constant",value:s},t.parameters)}return t}evaluate(t,r,i,a,n,s){return t.kind==="constant"?t.value:t.evaluate(r,i,a,n,s)}},Kn=class extends K{possiblyEvaluate(t,r,i,a){if(t.value===void 0)return new mr(this,{kind:"constant",value:void 0},r);if(t.expression.kind==="constant"){let n=t.expression.evaluate(r,null,{},i,a),s=t.property.specification.type==="resolvedImage"&&typeof n!="string"?n.name:n,o=this._calculate(s,s,s,r);return new mr(this,{kind:"constant",value:o},r)}if(t.expression.kind==="camera"){let n=this._calculate(t.expression.evaluate({zoom:r.zoom-1}),t.expression.evaluate({zoom:r.zoom}),t.expression.evaluate({zoom:r.zoom+1}),r);return new mr(this,{kind:"constant",value:n},r)}return new mr(this,t.expression,r)}evaluate(t,r,i,a,n,s){if(t.kind==="source"){let o=t.evaluate(r,i,a,n,s);return this._calculate(o,o,o,r)}return t.kind==="composite"?this._calculate(t.evaluate({zoom:Math.floor(r.zoom)-1},i,a),t.evaluate({zoom:Math.floor(r.zoom)},i,a),t.evaluate({zoom:Math.floor(r.zoom)+1},i,a),r):t.value}_calculate(t,r,i,a){return a.zoom>a.zoomHistory.lastIntegerZoom?{from:t,to:r}:{from:i,to:r}}interpolate(t){return t}},vy=class{constructor(t,r){this.specification=t,this.name=r}possiblyEvaluate(t,r,i,a){if(t.value!==void 0){if(t.expression.kind==="constant"){let n=t.expression.evaluate(r,null,{},i,a);return this._calculate(n,n,n,r)}return this._calculate(t.expression.evaluate(new ze(Math.floor(r.zoom-1),r)),t.expression.evaluate(new ze(Math.floor(r.zoom),r)),t.expression.evaluate(new ze(Math.floor(r.zoom+1),r)),r)}}_calculate(t,r,i,a){return a.zoom>a.zoomHistory.lastIntegerZoom?{from:t,to:r}:{from:i,to:r}}interpolate(t){return t}},Ll=class{constructor(t,r){this.specification=t,this.name=r}possiblyEvaluate(t,r,i,a){return!!t.expression.evaluate(r,null,{},i,a)}interpolate(){return!1}},wt=class{constructor(t){this.properties=t,this.defaultPropertyValues={},this.defaultTransitionablePropertyValues={},this.defaultTransitioningPropertyValues={},this.defaultPossiblyEvaluatedValues={},this.overridableProperties=[];for(let r in t){let i=t[r];i.specification.overridable&&this.overridableProperties.push(r);let a=this.defaultPropertyValues[r]=new Yn(i,void 0,i.name,void 0),n=this.defaultTransitionablePropertyValues[r]=new zh(i,i.name,void 0);this.defaultTransitioningPropertyValues[r]=n.untransitioned(),this.defaultPossiblyEvaluatedValues[r]=a.possiblyEvaluate({})}}};G("DataDrivenProperty",K),G("DataConstantProperty",N),G("CrossFadedDataDrivenProperty",Kn),G("CrossFadedProperty",vy),G("ColorRampProperty",Ll);const _f=" is a PAINT property not a LAYOUT property. Use get/setPaintProperty instead?",ku=" is a LAYOUT property not a PAINT property. Use get/setLayoutProperty instead?";var Ir=class extends kt{constructor(t,r,i){if(super(),this.id=t.id,this.type=t.type,this._globalState=i,this._featureFilter={filter:()=>!0,needGeometry:!1,getGlobalStateRefs:()=>new Set},this._visibilityExpression=z2(this.visibility,`layers[${this.id}].layout.visibility`,i),t.type!=="custom"&&(this.metadata=t.metadata,this.minzoom=t.minzoom,this.maxzoom=t.maxzoom,t.type!=="background"&&(this.source=t.source,this.sourceLayer=t["source-layer"],this.filter=t.filter,this._featureFilter=Hn(t.filter,`layers[${this.id}].filter`,i)),r.layout&&(this._unevaluatedLayout=new k2(r.layout,`layers[${this.id}].layout`,i)),r.paint)){this._transitionablePaint=new Rl(r.paint,`layers[${this.id}].paint`,i);for(let a in t.paint)this.setPaintProperty(a,t.paint[a],{validate:!1});for(let a in t.layout)this.setLayoutProperty(a,t.layout[a],{validate:!1});this._transitioningPaint=this._transitionablePaint.untransitioned(),this.paint=new kl(r.paint)}}setFilter(t){this.filter=t,this._featureFilter=Hn(t,`layers[${this.id}].filter`,this._globalState)}getCrossfadeParameters(){return this._crossfadeParameters}getLayoutProperty(t){var r;if(t==="visibility")return this.visibility;if((r=this._transitionablePaint)!=null&&r.hasProperty(t))throw Error(t+_f);if(!this._unevaluatedLayout)throw Error(`Cannot get layout property "${t}" on layer type "${this.type}" which has no layout properties.`);return this._unevaluatedLayout.getValue(t)}getLayoutAffectingGlobalStateRefs(){let t=new Set;for(let r of this._visibilityExpression.getGlobalStateRefs())t.add(r);if(this._unevaluatedLayout)for(let r in this._unevaluatedLayout._values){let i=this._unevaluatedLayout._values[r];for(let a of i.getGlobalStateRefs())t.add(a)}for(let r of this._featureFilter.getGlobalStateRefs())t.add(r);return t}getPaintAffectingGlobalStateRefs(){let t=new globalThis.Map;if(this._transitionablePaint)for(let r in this._transitionablePaint._values){let i=this._transitionablePaint._values[r].value;for(let a of i.getGlobalStateRefs()){let n=t.get(a)??[];n.push({name:r,value:i.value}),t.set(a,n)}}return t}getVisibilityAffectingGlobalStateRefs(){return this._visibilityExpression.getGlobalStateRefs()}setLayoutProperty(t,r,i={}){var a;if(t==="visibility"){this.visibility=r,this._visibilityExpression.setValue(r),this.recalculateVisibility();return}if((a=this._transitionablePaint)!=null&&a.hasProperty(t)){this.fire(new Y(Error(t+_f)));return}r!=null&&this._validate(Zt.layoutProperty,`layers.${this.id}.layout.${t}`,t,r,i)||this._unevaluatedLayout.setValue(t,r)}getPaintProperty(t){var r,i;if(t.endsWith("-transition")){let a=t.slice(0,-11);if(a==="visibility"||(r=this._unevaluatedLayout)!=null&&r.hasProperty(a))throw Error(t+ku);return this._transitionablePaint.getTransition(a)}if(t==="visibility"||(i=this._unevaluatedLayout)!=null&&i.hasProperty(t))throw Error(t+ku);return this._transitionablePaint.getValue(t)}setPaintProperty(t,r,i={}){var a;if(t==="visibility"||(a=this._unevaluatedLayout)!=null&&a.hasProperty(t))return this.fire(new Y(Error(t+ku))),!1;if(r!=null&&this._validate(Zt.paintProperty,`layers.${this.id}.paint.${t}`,t,r,i))return!1;if(t.endsWith("-transition"))return this._transitionablePaint.setTransition(t.slice(0,-11),r||void 0),!1;{let n=this._transitionablePaint._values[t],s=n.property.specification["property-type"]==="cross-faded-data-driven",o=n.value.isDataDriven(),l=n.value;this._transitionablePaint.setValue(t,r),this._handleSpecialPaintPropertyUpdate(t);let u=this._transitionablePaint._values[t].value;return u.isDataDriven()||o||s||this._handleOverridablePaintPropertyUpdate(t,l,u)}}_handleSpecialPaintPropertyUpdate(t){}_handleOverridablePaintPropertyUpdate(t,r,i){return!1}isHidden(t=this.minzoom,r=!1){return this.minzoom&&t<(r?Math.floor(this.minzoom):this.minzoom)||this.maxzoom&&t>=this.maxzoom?!0:this._evaluatedVisibility==="none"}updateTransitions(t){this._transitioningPaint=this._transitionablePaint.transitioned(t,this._transitioningPaint)}retainPriorGlobalState(t,r){var i;(i=this._transitionablePaint)==null||i.retainPriorGlobalState(t,r,this._transitioningPaint)}hasTransition(){return this._transitioningPaint.hasTransition()}recalculateVisibility(){this._evaluatedVisibility=this._visibilityExpression.evaluate()}recalculate(t,r){t.getCrossfadeParameters&&(this._crossfadeParameters=t.getCrossfadeParameters()),this._unevaluatedLayout&&(this.layout=this._unevaluatedLayout.possiblyEvaluate(t,void 0,r)),this.paint=this._transitioningPaint.possiblyEvaluate(t,void 0,r)}serialize(){var r,i;let t={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:(r=this._unevaluatedLayout)==null?void 0:r.serialize(),paint:(i=this._transitionablePaint)==null?void 0:i.serialize()};return this.visibility&&(t.layout||(t.layout={}),t.layout.visibility=this.visibility),Gg(t,(a,n)=>a!==void 0&&!(n==="layout"&&!Object.keys(a).length)&&!(n==="paint"&&!Object.keys(a).length))}_validate(t,r,i,a,n={}){return gs(this,t,{key:r,layerType:this.type,objectKey:i,value:a},n)}is3D(){return!1}isTileClipped(){return!1}hasOffscreenPass(){return!1}resize(){}isStateDependent(){for(let t in this.paint._values){let r=this.paint.get(t);if(r instanceof mr&&Ua(r.property.specification)&&(r.value.kind==="source"||r.value.kind==="composite")&&r.value.isStateDependent)return!0}return!1}};let L2;const B2=()=>L2||(L2=new wt({"raster-opacity":new N(z.paint_raster["raster-opacity"],"raster-opacity"),"raster-hue-rotate":new N(z.paint_raster["raster-hue-rotate"],"raster-hue-rotate"),"raster-brightness-min":new N(z.paint_raster["raster-brightness-min"],"raster-brightness-min"),"raster-brightness-max":new N(z.paint_raster["raster-brightness-max"],"raster-brightness-max"),"raster-saturation":new N(z.paint_raster["raster-saturation"],"raster-saturation"),"raster-contrast":new N(z.paint_raster["raster-contrast"],"raster-contrast"),resampling:new N(z.paint_raster.resampling,"resampling"),"raster-resampling":new N(z.paint_raster["raster-resampling"],"raster-resampling"),"raster-fade-duration":new N(z.paint_raster["raster-fade-duration"],"raster-fade-duration")}));var O2={get paint(){return B2()}};const Fh=e=>e.type==="raster";var $2=class extends Ir{constructor(t,r){super(t,O2,r)}};const j2={Int8:Int8Array,Uint8:Uint8Array,Int16:Int16Array,Uint16:Uint16Array,Int32:Int32Array,Uint32:Uint32Array,Float32:Float32Array};var _s=class{constructor(t,r){this._structArray=t,this._pos1=r*this.size,this._pos2=this._pos1/2,this._pos4=this._pos1/4,this._pos8=this._pos1/8}},Je=class{constructor(){this.isTransferred=!1,this.capacity=-1,this.resize(0)}static serialize(t,r){return t._trim(),r&&(t.isTransferred=!0,r.push(t.arrayBuffer)),{length:t.length,arrayBuffer:t.arrayBuffer}}static deserialize(t){let r=Object.create(this.prototype);return r.arrayBuffer=t.arrayBuffer,r.length=t.length,r.capacity=t.arrayBuffer.byteLength/r.bytesPerElement,r._refreshViews(),r}_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(t){this.reserve(t),this.length=t}reserve(t){if(t>this.capacity){this.capacity=Math.max(t,Math.floor(this.capacity*5),128),this.arrayBuffer=new ArrayBuffer(this.capacity*this.bytesPerElement);let r=this.uint8;this._refreshViews(),r&&this.uint8.set(r)}}_refreshViews(){throw Error("_refreshViews() must be implemented by each concrete StructArray layout")}freeBufferAfterUpload(){this.arrayBuffer=new ArrayBuffer(0),this._refreshViews()}};function Ye(e,t=1){let r=0,i=0;return{members:e.map(a=>{let n=V2(a.type),s=r=yf(r,Math.max(t,n)),o=a.components||1;return i=Math.max(i,n),r+=n*o,{name:a.name,type:a.type,components:o,offset:s}}),size:yf(r,Math.max(i,t)),alignment:t}}function V2(e){return j2[e].BYTES_PER_ELEMENT}function yf(e,t){return Math.ceil(e/t)*t}var Jn=class extends Je{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(t,r){let i=this.length;return this.resize(i+1),this.emplace(i,t,r)}emplace(t,r,i){let a=t*2;return this.int16[a+0]=r,this.int16[a+1]=i,t}};Jn.prototype.bytesPerElement=4,G("StructArrayLayout2i4",Jn);var Xo=class extends Je{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(t,r,i){let a=this.length;return this.resize(a+1),this.emplace(a,t,r,i)}emplace(t,r,i,a){let n=t*3;return this.int16[n+0]=r,this.int16[n+1]=i,this.int16[n+2]=a,t}};Xo.prototype.bytesPerElement=6,G("StructArrayLayout3i6",Xo);var Rh=class extends Je{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(t,r,i,a){let n=this.length;return this.resize(n+1),this.emplace(n,t,r,i,a)}emplace(t,r,i,a,n){let s=t*4;return this.int16[s+0]=r,this.int16[s+1]=i,this.int16[s+2]=a,this.int16[s+3]=n,t}};Rh.prototype.bytesPerElement=8,G("StructArrayLayout4i8",Rh);var kh=class extends Je{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(t,r,i,a,n,s){let o=this.length;return this.resize(o+1),this.emplace(o,t,r,i,a,n,s)}emplace(t,r,i,a,n,s,o){let l=t*6;return this.int16[l+0]=r,this.int16[l+1]=i,this.int16[l+2]=a,this.int16[l+3]=n,this.int16[l+4]=s,this.int16[l+5]=o,t}};kh.prototype.bytesPerElement=12,G("StructArrayLayout2i4i12",kh);var Lh=class extends Je{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(t,r,i,a,n,s){let o=this.length;return this.resize(o+1),this.emplace(o,t,r,i,a,n,s)}emplace(t,r,i,a,n,s,o){let l=t*4,u=t*8;return this.int16[l+0]=r,this.int16[l+1]=i,this.uint8[u+4]=a,this.uint8[u+5]=n,this.uint8[u+6]=s,this.uint8[u+7]=o,t}};Lh.prototype.bytesPerElement=8,G("StructArrayLayout2i4ub8",Lh);var Qn=class extends Je{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(t,r){let i=this.length;return this.resize(i+1),this.emplace(i,t,r)}emplace(t,r,i){let a=t*2;return this.float32[a+0]=r,this.float32[a+1]=i,t}};Qn.prototype.bytesPerElement=8,G("StructArrayLayout2f8",Qn);var Bh=class extends Je{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(t,r,i,a,n,s,o,l,u,h){let c=this.length;return this.resize(c+1),this.emplace(c,t,r,i,a,n,s,o,l,u,h)}emplace(t,r,i,a,n,s,o,l,u,h,c){let d=t*10;return this.uint16[d+0]=r,this.uint16[d+1]=i,this.uint16[d+2]=a,this.uint16[d+3]=n,this.uint16[d+4]=s,this.uint16[d+5]=o,this.uint16[d+6]=l,this.uint16[d+7]=u,this.uint16[d+8]=h,this.uint16[d+9]=c,t}};Bh.prototype.bytesPerElement=20,G("StructArrayLayout10ui20",Bh);var Oh=class extends Je{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(t,r,i,a,n,s,o,l){let u=this.length;return this.resize(u+1),this.emplace(u,t,r,i,a,n,s,o,l)}emplace(t,r,i,a,n,s,o,l,u){let h=t*8;return this.uint16[h+0]=r,this.uint16[h+1]=i,this.uint16[h+2]=a,this.uint16[h+3]=n,this.uint16[h+4]=s,this.uint16[h+5]=o,this.uint16[h+6]=l,this.uint16[h+7]=u,t}};Oh.prototype.bytesPerElement=16,G("StructArrayLayout8ui16",Oh);var $h=class extends Je{_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(t,r,i,a,n,s,o,l,u,h,c,d,p){let f=this.length;return this.resize(f+1),this.emplace(f,t,r,i,a,n,s,o,l,u,h,c,d,p)}emplace(t,r,i,a,n,s,o,l,u,h,c,d,p,f){let m=t*14,g=t*7;return this.int16[m+0]=r,this.int16[m+1]=i,this.int16[m+2]=a,this.int16[m+3]=n,this.uint16[m+4]=s,this.uint16[m+5]=o,this.uint16[m+6]=l,this.uint16[m+7]=u,this.int16[m+8]=h,this.int16[m+9]=c,this.int16[m+10]=d,this.int16[m+11]=p,this.float32[g+6]=f,t}};$h.prototype.bytesPerElement=28,G("StructArrayLayout4i4ui4i1f28",$h);var jh=class extends Je{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(t,r,i){let a=this.length;return this.resize(a+1),this.emplace(a,t,r,i)}emplace(t,r,i,a){let n=t*3;return this.float32[n+0]=r,this.float32[n+1]=i,this.float32[n+2]=a,t}};jh.prototype.bytesPerElement=12,G("StructArrayLayout3f12",jh);var Vh=class extends Je{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint32=new Uint32Array(this.arrayBuffer)}emplaceBack(t){let r=this.length;return this.resize(r+1),this.emplace(r,t)}emplace(t,r){let i=t*1;return this.uint32[i+0]=r,t}};Vh.prototype.bytesPerElement=4,G("StructArrayLayout1ul4",Vh);var Nh=class extends Je{_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(t,r,i,a,n,s,o,l,u){let h=this.length;return this.resize(h+1),this.emplace(h,t,r,i,a,n,s,o,l,u)}emplace(t,r,i,a,n,s,o,l,u,h){let c=t*10,d=t*5;return this.int16[c+0]=r,this.int16[c+1]=i,this.int16[c+2]=a,this.int16[c+3]=n,this.int16[c+4]=s,this.int16[c+5]=o,this.uint32[d+3]=l,this.uint16[c+8]=u,this.uint16[c+9]=h,t}};Nh.prototype.bytesPerElement=20,G("StructArrayLayout6i1ul2ui20",Nh);var Uh=class extends Je{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(t,r,i,a,n,s){let o=this.length;return this.resize(o+1),this.emplace(o,t,r,i,a,n,s)}emplace(t,r,i,a,n,s,o){let l=t*6;return this.int16[l+0]=r,this.int16[l+1]=i,this.int16[l+2]=a,this.int16[l+3]=n,this.int16[l+4]=s,this.int16[l+5]=o,t}};Uh.prototype.bytesPerElement=12,G("StructArrayLayout2i2i2i12",Uh);var Gh=class extends Je{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(t,r,i,a,n){let s=this.length;return this.resize(s+1),this.emplace(s,t,r,i,a,n)}emplace(t,r,i,a,n,s){let o=t*4,l=t*8;return this.float32[o+0]=r,this.float32[o+1]=i,this.float32[o+2]=a,this.int16[l+6]=n,this.int16[l+7]=s,t}};Gh.prototype.bytesPerElement=16,G("StructArrayLayout2f1f2i16",Gh);var qh=class extends Je{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(t,r,i,a,n,s){let o=this.length;return this.resize(o+1),this.emplace(o,t,r,i,a,n,s)}emplace(t,r,i,a,n,s,o){let l=t*16,u=t*4,h=t*8;return this.uint8[l+0]=r,this.uint8[l+1]=i,this.float32[u+1]=a,this.float32[u+2]=n,this.int16[h+6]=s,this.int16[h+7]=o,t}};qh.prototype.bytesPerElement=16,G("StructArrayLayout2ub2f2i16",qh);var Yo=class extends Je{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(t,r,i){let a=this.length;return this.resize(a+1),this.emplace(a,t,r,i)}emplace(t,r,i,a){let n=t*3;return this.uint16[n+0]=r,this.uint16[n+1]=i,this.uint16[n+2]=a,t}};Yo.prototype.bytesPerElement=6,G("StructArrayLayout3ui6",Yo);var Zh=class extends Je{_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(t,r,i,a,n,s,o,l,u,h,c,d,p,f,m,g,_,y){let v=this.length;return this.resize(v+1),this.emplace(v,t,r,i,a,n,s,o,l,u,h,c,d,p,f,m,g,_,y)}emplace(t,r,i,a,n,s,o,l,u,h,c,d,p,f,m,g,_,y,v){let x=t*26,w=t*13,b=t*52;return this.int16[x+0]=r,this.int16[x+1]=i,this.uint16[x+2]=a,this.uint16[x+3]=n,this.uint32[w+2]=s,this.uint32[w+3]=o,this.uint32[w+4]=l,this.uint16[x+10]=u,this.uint16[x+11]=h,this.uint16[x+12]=c,this.float32[w+7]=d,this.float32[w+8]=p,this.uint8[b+36]=f,this.uint8[b+37]=m,this.uint8[b+38]=g,this.uint32[w+10]=_,this.int16[x+22]=y,this.float32[w+12]=v,t}};Zh.prototype.bytesPerElement=52,G("StructArrayLayout2i2ui3ul3ui2f3ub1ul1i1f52",Zh);var Wh=class extends Je{_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(t,r,i,a,n,s,o,l,u,h,c,d,p,f,m,g,_,y,v,x,w,b,S,A,P,I,R,F,T){let E=this.length;return this.resize(E+1),this.emplace(E,t,r,i,a,n,s,o,l,u,h,c,d,p,f,m,g,_,y,v,x,w,b,S,A,P,I,R,F,T)}emplace(t,r,i,a,n,s,o,l,u,h,c,d,p,f,m,g,_,y,v,x,w,b,S,A,P,I,R,F,T,E){let D=t*34,C=t*17;return this.int16[D+0]=r,this.int16[D+1]=i,this.int16[D+2]=a,this.int16[D+3]=n,this.int16[D+4]=s,this.int16[D+5]=o,this.int16[D+6]=l,this.int16[D+7]=u,this.uint16[D+8]=h,this.uint16[D+9]=c,this.uint16[D+10]=d,this.uint16[D+11]=p,this.uint16[D+12]=f,this.uint16[D+13]=m,this.uint16[D+14]=g,this.uint16[D+15]=_,this.uint16[D+16]=y,this.uint16[D+17]=v,this.uint16[D+18]=x,this.uint16[D+19]=w,this.uint16[D+20]=b,this.uint16[D+21]=S,this.uint16[D+22]=A,this.uint32[C+12]=P,this.float32[C+13]=I,this.float32[C+14]=R,this.uint16[D+30]=F,this.uint16[D+31]=T,this.float32[C+16]=E,t}};Wh.prototype.bytesPerElement=68,G("StructArrayLayout8i15ui1ul2f2ui1f68",Wh);var Ko=class extends Je{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(t){let r=this.length;return this.resize(r+1),this.emplace(r,t)}emplace(t,r){let i=t*1;return this.float32[i+0]=r,t}};Ko.prototype.bytesPerElement=4,G("StructArrayLayout1f4",Ko);var Hh=class extends Je{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(t,r,i){let a=this.length;return this.resize(a+1),this.emplace(a,t,r,i)}emplace(t,r,i,a){let n=t*6,s=t*3;return this.uint16[n+0]=r,this.float32[s+1]=i,this.float32[s+2]=a,t}};Hh.prototype.bytesPerElement=12,G("StructArrayLayout1ui2f12",Hh);var Xh=class extends Je{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint32=new Uint32Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(t,r,i){let a=this.length;return this.resize(a+1),this.emplace(a,t,r,i)}emplace(t,r,i,a){let n=t*2,s=t*4;return this.uint32[n+0]=r,this.uint16[s+2]=i,this.uint16[s+3]=a,t}};Xh.prototype.bytesPerElement=8,G("StructArrayLayout1ul2ui8",Xh);var Yh=class extends Je{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(t,r){let i=this.length;return this.resize(i+1),this.emplace(i,t,r)}emplace(t,r,i){let a=t*2;return this.uint16[a+0]=r,this.uint16[a+1]=i,t}};Yh.prototype.bytesPerElement=4,G("StructArrayLayout2ui4",Yh);var Kh=class extends Je{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(t){let r=this.length;return this.resize(r+1),this.emplace(r,t)}emplace(t,r){let i=t*1;return this.uint16[i+0]=r,t}};Kh.prototype.bytesPerElement=2,G("StructArrayLayout1ui2",Kh);var Jh=class extends Je{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(t,r,i,a){let n=this.length;return this.resize(n+1),this.emplace(n,t,r,i,a)}emplace(t,r,i,a,n){let s=t*4;return this.float32[s+0]=r,this.float32[s+1]=i,this.float32[s+2]=a,this.float32[s+3]=n,t}};Jh.prototype.bytesPerElement=16,G("StructArrayLayout4f16",Jh);var by=class extends _s{get anchorPointX(){return this._structArray.int16[this._pos2+0]}get anchorPointY(){return this._structArray.int16[this._pos2+1]}get x1(){return this._structArray.int16[this._pos2+2]}get y1(){return this._structArray.int16[this._pos2+3]}get x2(){return this._structArray.int16[this._pos2+4]}get y2(){return this._structArray.int16[this._pos2+5]}get featureIndex(){return this._structArray.uint32[this._pos4+3]}get sourceLayerIndex(){return this._structArray.uint16[this._pos2+8]}get bucketIndex(){return this._structArray.uint16[this._pos2+9]}get anchorPoint(){return new M(this.anchorPointX,this.anchorPointY)}};by.prototype.size=20;var wy=class extends Nh{get(t){return new by(this,t)}};G("CollisionBoxArray",wy);var Ty=class extends _s{get anchorX(){return this._structArray.int16[this._pos2+0]}get anchorY(){return this._structArray.int16[this._pos2+1]}get glyphStartIndex(){return this._structArray.uint16[this._pos2+2]}get numGlyphs(){return this._structArray.uint16[this._pos2+3]}get vertexStartIndex(){return this._structArray.uint32[this._pos4+2]}get lineStartIndex(){return this._structArray.uint32[this._pos4+3]}get lineLength(){return this._structArray.uint32[this._pos4+4]}get segment(){return this._structArray.uint16[this._pos2+10]}get lowerSize(){return this._structArray.uint16[this._pos2+11]}get upperSize(){return this._structArray.uint16[this._pos2+12]}get lineOffsetX(){return this._structArray.float32[this._pos4+7]}get lineOffsetY(){return this._structArray.float32[this._pos4+8]}get writingMode(){return this._structArray.uint8[this._pos1+36]}get placedOrientation(){return this._structArray.uint8[this._pos1+37]}set placedOrientation(t){this._structArray.uint8[this._pos1+37]=t}get hidden(){return this._structArray.uint8[this._pos1+38]}set hidden(t){this._structArray.uint8[this._pos1+38]=t}get crossTileID(){return this._structArray.uint32[this._pos4+10]}set crossTileID(t){this._structArray.uint32[this._pos4+10]=t}get associatedIconIndex(){return this._structArray.int16[this._pos2+22]}get heightOffset(){return this._structArray.float32[this._pos4+12]}};Ty.prototype.size=52;var Sy=class extends Zh{get(t){return new Ty(this,t)}};G("PlacedSymbolArray",Sy);var Dy=class extends _s{get anchorX(){return this._structArray.int16[this._pos2+0]}get anchorY(){return this._structArray.int16[this._pos2+1]}get rightJustifiedTextSymbolIndex(){return this._structArray.int16[this._pos2+2]}get centerJustifiedTextSymbolIndex(){return this._structArray.int16[this._pos2+3]}get leftJustifiedTextSymbolIndex(){return this._structArray.int16[this._pos2+4]}get verticalPlacedTextSymbolIndex(){return this._structArray.int16[this._pos2+5]}get placedIconSymbolIndex(){return this._structArray.int16[this._pos2+6]}get verticalPlacedIconSymbolIndex(){return this._structArray.int16[this._pos2+7]}get key(){return this._structArray.uint16[this._pos2+8]}get textBoxStartIndex(){return this._structArray.uint16[this._pos2+9]}get textBoxEndIndex(){return this._structArray.uint16[this._pos2+10]}get verticalTextBoxStartIndex(){return this._structArray.uint16[this._pos2+11]}get verticalTextBoxEndIndex(){return this._structArray.uint16[this._pos2+12]}get iconBoxStartIndex(){return this._structArray.uint16[this._pos2+13]}get iconBoxEndIndex(){return this._structArray.uint16[this._pos2+14]}get verticalIconBoxStartIndex(){return this._structArray.uint16[this._pos2+15]}get verticalIconBoxEndIndex(){return this._structArray.uint16[this._pos2+16]}get featureIndex(){return this._structArray.uint16[this._pos2+17]}get numHorizontalGlyphVertices(){return this._structArray.uint16[this._pos2+18]}get numVerticalGlyphVertices(){return this._structArray.uint16[this._pos2+19]}get numIconVertices(){return this._structArray.uint16[this._pos2+20]}get numVerticalIconVertices(){return this._structArray.uint16[this._pos2+21]}get useRuntimeCollisionCircles(){return this._structArray.uint16[this._pos2+22]}get crossTileID(){return this._structArray.uint32[this._pos4+12]}set crossTileID(t){this._structArray.uint32[this._pos4+12]=t}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]}};Dy.prototype.size=68;var Ey=class extends Wh{get(t){return new Dy(this,t)}};G("SymbolInstanceArray",Ey);var Py=class extends Ko{getoffsetX(t){return this.float32[t*1+0]}};G("GlyphOffsetArray",Py);var Ay=class extends Xo{getx(t){return this.int16[t*3+0]}gety(t){return this.int16[t*3+1]}gettileUnitDistanceFromAnchor(t){return this.int16[t*3+2]}};G("SymbolLineVertexArray",Ay);var Cy=class extends _s{get textAnchor(){return this._structArray.uint16[this._pos2+0]}get textOffset0(){return this._structArray.float32[this._pos4+1]}get textOffset1(){return this._structArray.float32[this._pos4+2]}};Cy.prototype.size=12;var Iy=class extends Hh{get(t){return new Cy(this,t)}};G("TextAnchorOffsetArray",Iy);var My=class extends _s{get featureIndex(){return this._structArray.uint32[this._pos4+0]}get sourceLayerIndex(){return this._structArray.uint16[this._pos2+2]}get bucketIndex(){return this._structArray.uint16[this._pos2+3]}};My.prototype.size=8;var zy=class extends Xh{get(t){return new My(this,t)}};G("FeatureIndexArray",zy);var vi=class extends Jn{},N2=class extends Xo{},U2=class extends Rh{},G2=class extends Jn{},q2=class extends Jn{},Z2=class extends kh{},W2=class extends Lh{},H2=class extends Qn{},_a=class extends Bh{},xf=class extends Oh{},X2=class extends $h{},Y2=class extends jh{},K2=class extends Vh{},vf=class extends Uh{},J2=class extends Gh{},Q2=class extends qh{},ew=class extends Yo{},Yr=class extends Yo{},Qh=class extends Yh{},tw=class extends Kh{};const rw=Ye([{name:"a_pos",components:2,type:"Int16"}],4),iw=rw.members;var Ze=class Da{constructor(t=[]){this._forceNewSegmentOnNextPrepare=!1,this.segments=t}prepareSegment(t,r,i,a){let n=this.segments[this.segments.length-1];return t>Da.MAX_VERTEX_ARRAY_LENGTH&&_e(`Max vertices per segment is ${Da.MAX_VERTEX_ARRAY_LENGTH}: bucket requested ${t}. Consider using the \`fillLargeMeshArrays\` function if you require meshes with more than ${Da.MAX_VERTEX_ARRAY_LENGTH} vertices.`),this._forceNewSegmentOnNextPrepare||!n||n.vertexLength+t>Da.MAX_VERTEX_ARRAY_LENGTH||n.sortKey!==a?this.createNewSegment(r,i,a):n}createNewSegment(t,r,i){let a={vertexOffset:t.length,primitiveOffset:r.length,vertexLength:0,primitiveLength:0,vaos:{}};return i!==void 0&&(a.sortKey=i),this._forceNewSegmentOnNextPrepare=!1,this.segments.push(a),a}getOrCreateLatestSegment(t,r,i){return this.prepareSegment(0,t,r,i)}forceNewSegmentOnNextPrepare(){this._forceNewSegmentOnNextPrepare=!0}get(){return this.segments}destroy(){for(let t of this.segments)for(let r in t.vaos)t.vaos[r].destroy()}static simpleSegment(t,r,i,a){return new Da([{vertexOffset:t,primitiveOffset:r,vertexLength:i,primitiveLength:a,vaos:{},sortKey:0}])}};Ze.MAX_VERTEX_ARRAY_LENGTH=2**16-1,G("SegmentVector",Ze);function bf(e,t){return e=se(Math.floor(e),0,255),t=se(Math.floor(t),0,255),256*e+t}const aw=Ye([{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"}]),nw=Ye([{name:"a_dasharray_from",components:4,type:"Uint16"},{name:"a_dasharray_to",components:4,type:"Uint16"}]);var sw=Vc(((e,t)=>{function r(i,a){for(var n=i.length&3,s=i.length-n,o=a,l,u=3432918353,h=461845907,c,d=0;d<s;)c=i.charCodeAt(d)&255|(i.charCodeAt(++d)&255)<<8|(i.charCodeAt(++d)&255)<<16|(i.charCodeAt(++d)&255)<<24,++d,c=(c&65535)*u+(((c>>>16)*u&65535)<<16)&4294967295,c=c<<15|c>>>17,c=(c&65535)*h+(((c>>>16)*h&65535)<<16)&4294967295,o^=c,o=o<<13|o>>>19,l=(o&65535)*5+(((o>>>16)*5&65535)<<16)&4294967295,o=(l&65535)+27492+(((l>>>16)+58964&65535)<<16);switch(c=0,n){case 3:c^=(i.charCodeAt(d+2)&255)<<16;case 2:c^=(i.charCodeAt(d+1)&255)<<8;case 1:c^=i.charCodeAt(d)&255,c=(c&65535)*u+(((c>>>16)*u&65535)<<16)&4294967295,c=c<<15|c>>>17,c=(c&65535)*h+(((c>>>16)*h&65535)<<16)&4294967295,o^=c}return o^=i.length,o^=o>>>16,o=(o&65535)*2246822507+(((o>>>16)*2246822507&65535)<<16)&4294967295,o^=o>>>13,o=(o&65535)*3266489909+(((o>>>16)*3266489909&65535)<<16)&4294967295,o^=o>>>16,o>>>0}t!==void 0&&(t.exports=r)})),ow=Vc(((e,t)=>{function r(i,a){for(var n=i.length,s=a^n,o=0,l;n>=4;)l=i.charCodeAt(o)&255|(i.charCodeAt(++o)&255)<<8|(i.charCodeAt(++o)&255)<<16|(i.charCodeAt(++o)&255)<<24,l=(l&65535)*1540483477+(((l>>>16)*1540483477&65535)<<16),l^=l>>>24,l=(l&65535)*1540483477+(((l>>>16)*1540483477&65535)<<16),s=(s&65535)*1540483477+(((s>>>16)*1540483477&65535)<<16)^l,n-=4,++o;switch(n){case 3:s^=(i.charCodeAt(o+2)&255)<<16;case 2:s^=(i.charCodeAt(o+1)&255)<<8;case 1:s^=i.charCodeAt(o)&255,s=(s&65535)*1540483477+(((s>>>16)*1540483477&65535)<<16)}return s^=s>>>13,s=(s&65535)*1540483477+(((s>>>16)*1540483477&65535)<<16),s^=s>>>15,s>>>0}t.exports=r})),Jo=Lx(Vc(((e,t)=>{var r=sw(),i=ow();t.exports=r,t.exports.murmur3=r,t.exports.murmur2=i}))()),Fy=class Ry{constructor(){this.ids=[],this.positions=[],this.indexed=!1}add(t,r,i,a){this.ids.push(wf(t)),this.positions.push(r,i,a)}getPositions(t){if(!this.indexed)throw Error("Trying to get index, but feature positions are not indexed");let r=wf(t),i=0,a=this.ids.length-1;for(;i<a;){let s=i+a>>1;this.ids[s]>=r?a=s:i=s+1}let n=[];for(;this.ids[i]===r;){let s=this.positions[3*i],o=this.positions[3*i+1],l=this.positions[3*i+2];n.push({index:s,start:o,end:l}),i++}return n}static serialize(t,r){let i=new Float64Array(t.ids),a=new Uint32Array(t.positions);return ec(i,a,0,i.length-1),r&&r.push(i.buffer,a.buffer),{ids:i,positions:a}}static deserialize(t){let r=new Ry;return r.ids=t.ids,r.positions=t.positions,r.indexed=!0,r}};function wf(e){let t=+e;return!isNaN(t)&&t<=2**53-1?t:(0,Jo.default)(String(e))}function ec(e,t,r,i){for(;r<i;){let a=e[r+i>>1],n=r-1,s=i+1;for(;;){do n++;while(e[n]<a);do s--;while(e[s]>a);if(n>=s)break;Hs(e,n,s),Hs(t,3*n,3*s),Hs(t,3*n+1,3*s+1),Hs(t,3*n+2,3*s+2)}s-r<i-s?(ec(e,t,r,s),r=s+1):(ec(e,t,s+1,i),i=s)}}function Hs(e,t,r){let i=e[t];e[t]=e[r],e[r]=i}G("FeaturePositionMap",Fy);var ci=class{constructor(t,r){this.gl=t.gl,this.location=r}},X=class extends ci{constructor(t,r){super(t,r),this.current=0}set(t){this.current!==t&&(this.current=t,this.gl.uniform1i(this.location,t))}},U=class extends ci{constructor(t,r){super(t,r),this.current=0}set(t){this.current!==t&&(this.current=t,this.gl.uniform1f(this.location,t))}},de=class extends ci{constructor(t,r){super(t,r),this.current=[0,0]}set(t){(t[0]!==this.current[0]||t[1]!==this.current[1])&&(this.current=t,this.gl.uniform2f(this.location,t[0],t[1]))}},jt=class extends ci{constructor(t,r){super(t,r),this.current=[0,0,0]}set(t){(t[0]!==this.current[0]||t[1]!==this.current[1]||t[2]!==this.current[2])&&(this.current=t,this.gl.uniform3f(this.location,t[0],t[1],t[2]))}},es=class extends ci{constructor(t,r){super(t,r),this.current=[0,0,0,0]}set(t){(t[0]!==this.current[0]||t[1]!==this.current[1]||t[2]!==this.current[2]||t[3]!==this.current[3])&&(this.current=t,this.gl.uniform4f(this.location,t[0],t[1],t[2],t[3]))}},Ei=class extends ci{constructor(t,r){super(t,r),this.current=oe.transparent}set(t){(t.r!==this.current.r||t.g!==this.current.g||t.b!==this.current.b||t.a!==this.current.a)&&(this.current=t,this.gl.uniform4f(this.location,t.r,t.g,t.b,t.a))}},Tf=class extends ci{constructor(t,r){super(t,r),this.current=[]}set(t){if(t!=this.current){this.current=t;let r=new Float32Array(t.length*4);for(let i=0;i<t.length;i++)r[4*i]=t[i].r,r[4*i+1]=t[i].g,r[4*i+2]=t[i].b,r[4*i+3]=t[i].a;this.gl.uniform4fv(this.location,r)}}},Sf=class extends ci{constructor(t,r){super(t,r),this.current=[]}set(t){if(t!=this.current){this.current=t;let r=new Float32Array(t);this.gl.uniform1fv(this.location,r)}}};const lw=new Float32Array(16);var Ar=class extends ci{constructor(t,r){super(t,r),this.current=lw}set(t){if(t[12]!==this.current[12]||t[0]!==this.current[0]){this.current=t,this.gl.uniformMatrix4fv(this.location,!1,t);return}for(let r=1;r<16;r++)if(t[r]!==this.current[r]){this.current=t,this.gl.uniformMatrix4fv(this.location,!1,t);break}}};function tc(e){return[bf(255*e.r,255*e.g),bf(255*e.b,255*e.a)]}var In=class{constructor(t,r,i){this.value=t,this.uniformNames=r.map(a=>`u_${a}`),this.type=i}setUniform(t,r,i){t.set(i.constantOr(this.value))}getBinding(t,r,i){return this.type==="color"?new Ei(t,r):new U(t,r)}},Ri=class{constructor(t,r){this.uniformNames=r.map(i=>`u_${i}`),this.patternFrom=null,this.patternTo=null,this.pixelRatioFrom=1,this.pixelRatioTo=1}setConstantPatternPositions(t,r){this.pixelRatioFrom=r.pixelRatio,this.pixelRatioTo=t.pixelRatio,this.patternFrom=r.tlbr,this.patternTo=t.tlbr}setConstantDashPositions(t,r){this.dashTo=[0,t.y,t.height,t.width],this.dashFrom=[0,r.y,r.height,r.width]}setUniform(t,r,i,a){let n=null;a==="u_pattern_to"?n=this.patternTo:a==="u_pattern_from"?n=this.patternFrom:a==="u_dasharray_to"?n=this.dashTo:a==="u_dasharray_from"?n=this.dashFrom:a==="u_pixel_ratio_to"?n=this.pixelRatioTo:a==="u_pixel_ratio_from"&&(n=this.pixelRatioFrom),n!==null&&t.set(n)}getBinding(t,r,i){return i.startsWith("u_pattern")||i.startsWith("u_dasharray_")?new es(t,r):new U(t,r)}},Jr=class{constructor(t,r,i,a){this.expression=t,this.type=i,this.maxValue=0,this.paintVertexAttributes=r.map(n=>({name:`a_${n}`,type:"Float32",components:i==="color"?2:1,offset:0})),this.paintVertexArray=new a}populatePaintArray(t,r,i){let a=this.paintVertexArray.length,n=this.expression.evaluate(new ze(0,i),r,{},i.canonical,[],i.formattedSection);this.paintVertexArray.resize(t),this._setPaintValue(a,t,n)}updatePaintArray(t,r,i,a,n){let s=this.expression.evaluate(new ze(0,n),i,a);this._setPaintValue(t,r,s)}_setPaintValue(t,r,i){if(this.type==="color"){let a=tc(i);for(let n=t;n<r;n++)this.paintVertexArray.emplace(n,a[0],a[1])}else{for(let a=t;a<r;a++)this.paintVertexArray.emplace(a,i);this.maxValue=Math.max(this.maxValue,Math.abs(i))}}upload(t){var r,i;(r=this.paintVertexArray)!=null&&r.arrayBuffer.byteLength&&((i=this.paintVertexBuffer)!=null&&i.buffer?this.paintVertexBuffer.updateData(this.paintVertexArray):this.paintVertexBuffer=t.createVertexBuffer(this.paintVertexArray,this.paintVertexAttributes,this.expression.isStateDependent))}destroy(){this.paintVertexBuffer&&this.paintVertexBuffer.destroy()}},wr=class{constructor(t,r,i,a,n,s){this.expression=t,this.uniformNames=r.map(o=>`u_${o}_t`),this.type=i,this.useIntegerZoom=a,this.zoom=n,this.maxValue=0,this.paintVertexAttributes=r.map(o=>({name:`a_${o}`,type:"Float32",components:i==="color"?4:2,offset:0})),this.paintVertexArray=new s}populatePaintArray(t,r,i){let a=this.expression.evaluate(new ze(this.zoom,i),r,{},i.canonical,[],i.formattedSection),n=this.expression.evaluate(new ze(this.zoom+1,i),r,{},i.canonical,[],i.formattedSection),s=this.paintVertexArray.length;this.paintVertexArray.resize(t),this._setPaintValue(s,t,a,n)}updatePaintArray(t,r,i,a,n){let s=this.expression.evaluate(new ze(this.zoom,n),i,a),o=this.expression.evaluate(new ze(this.zoom+1,n),i,a);this._setPaintValue(t,r,s,o)}_setPaintValue(t,r,i,a){if(this.type==="color"){let n=tc(i),s=tc(a);for(let o=t;o<r;o++)this.paintVertexArray.emplace(o,n[0],n[1],s[0],s[1])}else{for(let n=t;n<r;n++)this.paintVertexArray.emplace(n,i,a);this.maxValue=Math.max(this.maxValue,Math.abs(i),Math.abs(a))}}upload(t){var r,i;(r=this.paintVertexArray)!=null&&r.arrayBuffer.byteLength&&((i=this.paintVertexBuffer)!=null&&i.buffer?this.paintVertexBuffer.updateData(this.paintVertexArray):this.paintVertexBuffer=t.createVertexBuffer(this.paintVertexArray,this.paintVertexAttributes,this.expression.isStateDependent))}destroy(){this.paintVertexBuffer&&this.paintVertexBuffer.destroy()}setUniform(t,r){let i=this.useIntegerZoom?Math.floor(r.zoom):r.zoom,a=se(this.expression.interpolationFactor(i,this.zoom,this.zoom+1),0,1);t.set(a)}getBinding(t,r,i){return new U(t,r)}},gi=class{constructor(t,r,i,a,n,s){this.expression=t,this.type=r,this.useIntegerZoom=i,this.zoom=a,this.layerId=s,this.zoomInPaintVertexArray=new n,this.zoomOutPaintVertexArray=new n}populatePaintArray(t,r,i){let a=this.zoomInPaintVertexArray.length;this.zoomInPaintVertexArray.resize(t),this.zoomOutPaintVertexArray.resize(t),this._setPaintValues(a,t,this.getPositionIds(r),i)}updatePaintArray(t,r,i,a,n){this._setPaintValues(t,r,this.getPositionIds(i),n)}_setPaintValues(t,r,i,a){let n=this.getPositions(a);if(!n||!i)return;let s=n[i.min],o=n[i.mid],l=n[i.max];if(s&&o&&l)for(let u=t;u<r;u++)this.emplace(this.zoomInPaintVertexArray,u,s,o),this.emplace(this.zoomOutPaintVertexArray,u,l,o)}upload(t){var r,i;if((r=this.zoomInPaintVertexArray)!=null&&r.arrayBuffer.byteLength&&((i=this.zoomOutPaintVertexArray)!=null&&i.arrayBuffer.byteLength)){let a=this.getVertexAttributes();this.zoomInPaintVertexBuffer=t.createVertexBuffer(this.zoomInPaintVertexArray,a,this.expression.isStateDependent),this.zoomOutPaintVertexBuffer=t.createVertexBuffer(this.zoomOutPaintVertexArray,a,this.expression.isStateDependent)}}destroy(){this.zoomOutPaintVertexBuffer&&this.zoomOutPaintVertexBuffer.destroy(),this.zoomInPaintVertexBuffer&&this.zoomInPaintVertexBuffer.destroy()}},ky=class extends gi{getPositions(t){return t.imagePositions}getPositionIds(t){var r;return(r=t.patterns)==null?void 0:r[this.layerId]}getVertexAttributes(){return aw.members}emplace(t,r,i,a){t.emplace(r,i.tlbr[0],i.tlbr[1],i.tlbr[2],i.tlbr[3],a.tlbr[0],a.tlbr[1],a.tlbr[2],a.tlbr[3],i.pixelRatio,a.pixelRatio)}},Ly=class extends gi{getPositions(t){return t.dashPositions}getPositionIds(t){var r;return(r=t.dashes)==null?void 0:r[this.layerId]}getVertexAttributes(){return nw.members}emplace(t,r,i,a){t.emplace(r,0,i.y,i.height,i.width,0,a.y,a.height,a.width)}},By=class{constructor(t,r,i){this.binders={},this._buffers=[];let a=[];for(let n in t.paint._values){if(!i(n))continue;let s=t.paint.get(n);if(!(s instanceof mr)||!Ua(s.property.specification))continue;let o=uw(n,t.type),l=s.value,u=s.property.specification.type,h=s.property.useIntegerZoom,c=s.property.specification["property-type"],d=c==="cross-faded"||c==="cross-faded-data-driven";if(l.kind==="constant")this.binders[n]=d?new Ri(l.value,o):new In(l.value,o,u),a.push(`/u_${n}`);else if(l.kind==="source"||d){let p=Df(n,u,"source");this.binders[n]=d?n==="line-dasharray"?new Ly(l,u,h,r,p,t.id):new ky(l,u,h,r,p,t.id):new Jr(l,o,u,p),a.push(`/a_${n}`)}else{let p=Df(n,u,"composite");this.binders[n]=new wr(l,o,u,h,r,p),a.push(`/z_${n}`)}}this.cacheKey=a.sort().join("")}getMaxValue(t){let r=this.binders[t];return r instanceof Jr||r instanceof wr?r.maxValue:0}populatePaintArrays(t,r,i){for(let a in this.binders){let n=this.binders[a];(n instanceof Jr||n instanceof wr||n instanceof gi)&&n.populatePaintArray(t,r,i)}}setConstantPatternPositions(t,r){for(let i in this.binders){let a=this.binders[i];a instanceof Ri&&a.setConstantPatternPositions(t,r)}}setConstantDashPositions(t,r){for(let i in this.binders){let a=this.binders[i];a instanceof Ri&&a.setConstantDashPositions(t,r)}}updatePaintArrays(t,r,i,a,n){let s=!1;for(let o of t){let l=r.getPositions(o.id);for(let u of l){let h=i.feature(u.index);for(let c in this.binders){let d=this.binders[c];(d instanceof Jr||d instanceof wr||d instanceof gi)&&d.expression.isStateDependent===!0&&(d.expression=a.paint.get(c).value,d.updatePaintArray(u.start,u.end,h,o.state,n),s=!0)}}}return s}defines(){let t=[];for(let r in this.binders){let i=this.binders[r];(i instanceof In||i instanceof Ri)&&t.push(...i.uniformNames.map(a=>`#define HAS_UNIFORM_${a}`))}return t}getBinderAttributes(){let t=[];for(let r in this.binders){let i=this.binders[r];if(i instanceof Jr||i instanceof wr)for(let a of i.paintVertexAttributes)t.push(a.name);else if(i instanceof gi){let a=i.getVertexAttributes();for(let n of a)t.push(n.name)}}return t}getBinderUniforms(){let t=[];for(let r in this.binders){let i=this.binders[r];if(i instanceof In||i instanceof Ri||i instanceof wr)for(let a of i.uniformNames)t.push(a)}return t}getPaintVertexBuffers(){return this._buffers}getUniforms(t,r){let i=[];for(let a in this.binders){let n=this.binders[a];if(n instanceof In||n instanceof Ri||n instanceof wr){for(let s of n.uniformNames)if(r[s]){let o=n.getBinding(t,r[s],s);i.push({name:s,property:a,binding:o})}}}return i}setUniforms(t,r,i,a){for(let{name:n,property:s,binding:o}of r)this.binders[s].setUniform(o,a,i.get(s),n)}updatePaintBuffers(t){this._buffers=[];for(let r in this.binders){let i=this.binders[r];if(t&&i instanceof gi){let a=t.fromScale===2?i.zoomInPaintVertexBuffer:i.zoomOutPaintVertexBuffer;a&&this._buffers.push(a)}else(i instanceof Jr||i instanceof wr)&&i.paintVertexBuffer&&this._buffers.push(i.paintVertexBuffer)}}upload(t){for(let r in this.binders){let i=this.binders[r];(i instanceof Jr||i instanceof wr||i instanceof gi)&&i.upload(t)}this.updatePaintBuffers()}destroy(){for(let t in this.binders){let r=this.binders[t];(r instanceof Jr||r instanceof wr||r instanceof gi)&&r.destroy()}}},Ji=class{constructor(t,r,i=()=>!0){this.programConfigurations={};for(let a of t)this.programConfigurations[a.id]=new By(a,r,i);this.needsUpload=!1,this._featureMap=new Fy,this._bufferOffset=0}populatePaintArrays(t,r,i,a){for(let n in this.programConfigurations)this.programConfigurations[n].populatePaintArrays(t,r,a);r.id!==void 0&&this._featureMap.add(r.id,i,this._bufferOffset,t),this._bufferOffset=t,this.needsUpload=!0}updatePaintArrays(t,r,i,a){for(let n of i)this.needsUpload=this.programConfigurations[n.id].updatePaintArrays(t,this._featureMap,r,n,a)||this.needsUpload}get(t){return this.programConfigurations[t]}upload(t){if(this.needsUpload){for(let r in this.programConfigurations)this.programConfigurations[r].upload(t);this.needsUpload=!1}}destroy(){for(let t in this.programConfigurations)this.programConfigurations[t].destroy()}};function uw(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 hw(e){return{"line-pattern":{source:_a,composite:_a},"fill-pattern":{source:_a,composite:_a},"fill-extrusion-pattern":{source:_a,composite:_a},"line-dasharray":{source:xf,composite:xf}}[e]}function Df(e,t,r){var a;let i={color:{source:Qn,composite:Jh},number:{source:Ko,composite:Qn}};return((a=hw(e))==null?void 0:a[r])||i[t][r]}G("ConstantBinder",In),G("CrossFadedConstantBinder",Ri),G("SourceExpressionBinder",Jr),G("CrossFadedPatternBinder",ky),G("CrossFadedDasharrayBinder",Ly),G("CompositeExpressionBinder",wr),G("ProgramConfiguration",By,{omit:["_buffers"]}),G("ProgramConfigurationSet",Ji);const rc=2**14-1,Ef=-rc-1;function ia(e){let t=L/e.extent,r=e.loadGeometry();for(let i of r)for(let a of i){let n=Math.round(a.x*t),s=Math.round(a.y*t);a.x=se(n,Ef,rc),a.y=se(s,Ef,rc),(n<a.x||n>a.x+1||s<a.y||s>a.y+1)&&_e("Geometry exceeds allowed extent, reduce your vector tile buffer size")}return r}function aa(e,t){return{type:e.type,id:e.id,properties:e.properties,geometry:t?ia(e):[]}}const Pf=-32768;function cw(e,t,r,i,a){e.emplaceBack(Pf+t*8+i,Pf+r*8+a)}var md=class{constructor(t){this.zoom=t.zoom,this.overscaling=t.overscaling,this.layers=t.layers,this.layerIds=this.layers.map(r=>r.id),this.index=t.index,this.hasDependencies=!1,this.layoutVertexArray=new G2,this.indexArray=new Yr,this.segments=new Ze,this.programConfigurations=new Ji(t.layers,t.zoom),this.stateDependentLayerIds=this.layers.filter(r=>r.isStateDependent()).map(r=>r.id)}populate(t,r,i){let a=this.layers[0],n=[],s=null,o=!1,l=a.type==="heatmap";if(a.type==="circle"){let d=a;s=d.layout.get("circle-sort-key"),o=!s.isConstant(),l||(l=d.paint.get("circle-pitch-alignment")==="map")}let u=l?r.subdivisionGranularity.circle:1,h=new ze(this.zoom),c=this.layers[0]._featureFilter.needGeometry;for(let{feature:d,id:p,index:f,sourceLayerIndex:m}of t){let g=aa(d,c);if(!this.layers[0]._featureFilter.filter(h,g,i))continue;let _=o?s.evaluate(g,{},i):void 0,y={id:p,properties:d.properties,type:d.type,sourceLayerIndex:m,index:f,geometry:c?g.geometry:ia(d),patterns:{},sortKey:_};n.push(y)}o&&n.sort((d,p)=>d.sortKey-p.sortKey);for(let d of n){let{geometry:p,index:f,sourceLayerIndex:m}=d,g=t[f].feature;this.addFeature(d,p,f,i,u),r.featureIndex.insert(g,p,f,m,this.index)}}update(t,r,i){this.stateDependentLayers.length&&this.programConfigurations.updatePaintArrays(t,r,this.stateDependentLayers,{imagePositions:i})}addFeatures(t){}isEmpty(){return this.layoutVertexArray.length===0}uploadPending(){return!this.uploaded||this.programConfigurations.needsUpload}upload(t){this.uploaded||(this.layoutVertexBuffer=t.createVertexBuffer(this.layoutVertexArray,iw),this.indexBuffer=t.createIndexBuffer(this.indexArray)),this.programConfigurations.upload(t),this.uploaded=!0}destroy(){this.layoutVertexBuffer&&(this.layoutVertexBuffer.destroy(),this.indexBuffer.destroy(),this.programConfigurations.destroy(),this.segments.destroy())}addFeature(t,r,i,a,n=1){let s;switch(n){case 1:s=[0,7];break;case 3:s=[0,2,5,7];break;case 5:s=[0,1,3,4,6,7];break;case 7:s=[0,1,2,3,4,5,6,7];break;default:throw Error(`Invalid circle bucket granularity: ${n}; valid values are 1, 3, 5, 7.`)}let o=s.length;for(let l of r)for(let u of l){let h=u.x,c=u.y;if(h<0||h>=8192||c<0||c>=8192)continue;let d=this.segments.prepareSegment(o*o,this.layoutVertexArray,this.indexArray,t.sortKey),p=d.vertexLength;for(let f=0;f<o;f++)for(let m=0;m<o;m++)cw(this.layoutVertexArray,h,c,s[m],s[f]);for(let f=0;f<o-1;f++)for(let m=0;m<o-1;m++){let g=p+f*o+m,_=p+(f+1)*o+m;this.indexArray.emplaceBack(g,_+1,g+1),this.indexArray.emplaceBack(g,_,_+1)}d.vertexLength+=o*o,d.primitiveLength+=(o-1)*(o-1)*2}this.programConfigurations.populatePaintArrays(this.layoutVertexArray.length,t,i,{imagePositions:{},canonical:a})}};G("CircleBucket",md,{omit:["layers"]});function Oy(e,t){for(let r of e)if(Za(t,r))return!0;for(let r of t)if(Za(e,r))return!0;return gd(e,t)}function Bl(e,t,r){return Za(e,t)?!0:ic(t,e,r)}function $y(e,t){if(e.length===1)return Af(t,e[0]);for(let r of t)for(let i of r)if(Za(e,i))return!0;for(let r of e)if(Af(t,r))return!0;for(let r of t)if(gd(e,r))return!0;return!1}function dw(e,t,r){for(let i of t){if(e.length>=3){for(let a of i)if(Za(e,a))return!0}if(pw(e,i,r))return!0}return!1}function pw(e,t,r){if(e.length>1){if(gd(e,t))return!0;for(let i of t)if(ic(i,e,r))return!0}for(let i of e)if(ic(i,t,r))return!0;return!1}function gd(e,t){if(e.length===0||t.length===0)return!1;for(let r=0;r<e.length-1;r++){let i=e[r],a=e[r+1];for(let n=0;n<t.length-1;n++){let s=t[n],o=t[n+1];if(fw(i,a,s,o))return!0}}return!1}function fw(e,t,r,i){return xi(e,r,i)!==xi(t,r,i)&&xi(e,t,r)!==xi(e,t,i)}function ic(e,t,r){let i=r*r;if(t.length===1)return e.distSqr(t[0])<i;for(let a=1;a<t.length;a++){let n=t[a-1],s=t[a];if(jy(e,n,s)<i)return!0}return!1}function jy(e,t,r){let i=t.distSqr(r);if(i===0)return e.distSqr(t);let a=((e.x-t.x)*(r.x-t.x)+(e.y-t.y)*(r.y-t.y))/i;return a<0?e.distSqr(t):a>1?e.distSqr(r):e.distSqr(r.sub(t)._mult(a)._add(t))}function Af(e,t){let r=!1,i,a,n;for(let s of e){i=s;for(let o=0,l=i.length-1;o<i.length;l=o++)a=i[o],n=i[l],a.y>t.y!=n.y>t.y&&t.x<(n.x-a.x)*(t.y-a.y)/(n.y-a.y)+a.x&&(r=!r)}return r}function Za(e,t){let r=!1;for(let i=0,a=e.length-1;i<e.length;a=i++){let n=e[i],s=e[a];n.y>t.y!=s.y>t.y&&t.x<(s.x-n.x)*(t.y-n.y)/(s.y-n.y)+n.x&&(r=!r)}return r}function mw(e,t,r,i,a){for(let s of e)if(t<=s.x&&r<=s.y&&i>=s.x&&a>=s.y)return!0;let n=[new M(t,r),new M(t,a),new M(i,a),new M(i,r)];if(e.length>2){for(let s of n)if(Za(e,s))return!0}for(let s=0;s<e.length-1;s++){let o=e[s],l=e[s+1];if(gw(o,l,n))return!0}return!1}function gw(e,t,r){let i=r[0],a=r[2];if(e.x<i.x&&t.x<i.x||e.x>a.x&&t.x>a.x||e.y<i.y&&t.y<i.y||e.y>a.y&&t.y>a.y)return!1;let n=xi(e,t,r[0]);return n!==xi(e,t,r[1])||n!==xi(e,t,r[2])||n!==xi(e,t,r[3])}function za(e,t,r){let i=t.paint.get(e).value;return i.kind==="constant"?i.value:r.programConfigurations.get(t.id).getMaxValue(e)}function Ol(e){return Math.sqrt(e[0]*e[0]+e[1]*e[1])}function $l(e,t,r,i,a){if(!t[0]&&!t[1])return e;let n=M.convert(t)._mult(a);r==="viewport"&&n._rotate(-i);let s=[];for(let o of e)s.push(o.sub(n));return s}function _w(e){let t=[];for(let r=0;r<e.length;r++){let i=e[r],a=t.at(-1);(r===0||a&&!i.equals(a))&&t.push(i)}return t}function yw(e,t){let r=[];for(let i of e){let a=_w(i),n=[];for(let s=0;s<a.length;s++){let o=a[s],l=a[s-1],u=a[s+1],h=s===0?new M(0,0):o.sub(l)._unit()._perp(),c=s===a.length-1?new M(0,0):u.sub(o)._unit()._perp(),d=h._add(c)._unit(),p=d.x*c.x+d.y*c.y;p!==0&&d._mult(1/p),n.push(d._mult(t)._add(o))}r.push(n)}return r}function xw({queryGeometry:e,size:t},r){return Bl(e,r,t)}function vw({queryGeometry:e,size:t,transform:r,unwrappedTileID:i,getElevation:a},n){return Bl(e,n,t*(r.projectTileCoordinates(n.x,n.y,i,a==null?void 0:a(n.x,n.y)).signedDistanceFromCamera/r.cameraToCenterDistance))}function bw({queryGeometry:e,size:t,transform:r,unwrappedTileID:i,getElevation:a},n){let s=r.projectTileCoordinates(n.x,n.y,i,a==null?void 0:a(n.x,n.y)).signedDistanceFromCamera,o=t*(r.cameraToCenterDistance/s);return Bl(e,_d(n,r,i,a),o)}function ww({queryGeometry:e,size:t,transform:r,unwrappedTileID:i,getElevation:a},n){return Bl(e,_d(n,r,i,a),t)}function Vy({queryGeometry:e,size:t,transform:r,unwrappedTileID:i,getElevation:a,pitchAlignment:n="map",pitchScale:s="map"},o){let l=n==="map"?s==="map"?xw:vw:s==="map"?bw:ww,u={queryGeometry:e,size:t,transform:r,unwrappedTileID:i,getElevation:a};for(let h of o)for(let c of h)if(l(u,c))return!0;return!1}function _d(e,t,r,i){let a=t.projectTileCoordinates(e.x,e.y,r,i==null?void 0:i(e.x,e.y)).point;return new M((a.x*.5+.5)*t.width,(-a.y*.5+.5)*t.height)}function Tw(e,t,r,i){return e.map(a=>_d(a,t,r,i))}let Sw;const Dw=()=>Sw||(Sw=new wt({"circle-sort-key":new K(z.layout_circle["circle-sort-key"],"circle-sort-key")}));let Ew;const Pw=()=>Ew||(Ew=new wt({"circle-radius":new K(z.paint_circle["circle-radius"],"circle-radius"),"circle-color":new K(z.paint_circle["circle-color"],"circle-color"),"circle-blur":new K(z.paint_circle["circle-blur"],"circle-blur"),"circle-opacity":new K(z.paint_circle["circle-opacity"],"circle-opacity"),"circle-translate":new N(z.paint_circle["circle-translate"],"circle-translate"),"circle-translate-anchor":new N(z.paint_circle["circle-translate-anchor"],"circle-translate-anchor"),"circle-pitch-scale":new N(z.paint_circle["circle-pitch-scale"],"circle-pitch-scale"),"circle-pitch-alignment":new N(z.paint_circle["circle-pitch-alignment"],"circle-pitch-alignment"),"circle-stroke-width":new K(z.paint_circle["circle-stroke-width"],"circle-stroke-width"),"circle-stroke-color":new K(z.paint_circle["circle-stroke-color"],"circle-stroke-color"),"circle-stroke-opacity":new K(z.paint_circle["circle-stroke-opacity"],"circle-stroke-opacity")}));var Aw={get paint(){return Pw()},get layout(){return Dw()}};const Cw=e=>e.type==="circle";var Iw=class extends Ir{constructor(t,r){super(t,Aw,r)}createBucket(t){return new md(t)}queryRadius(t){let r=t;return za("circle-radius",this,r)+za("circle-stroke-width",this,r)+Ol(this.paint.get("circle-translate"))}queryIntersectsFeature({queryGeometry:t,feature:r,featureState:i,geometry:a,transform:n,pixelsToTileUnits:s,unwrappedTileID:o,getElevation:l}){let u=$l(t,this.paint.get("circle-translate"),this.paint.get("circle-translate-anchor"),-n.bearingInRadians,s),h=this.paint.get("circle-radius").evaluate(r,i)+this.paint.get("circle-stroke-width").evaluate(r,i),c=this.paint.get("circle-pitch-scale"),d=this.paint.get("circle-pitch-alignment"),p,f;return d==="map"?(p=u,f=h*s):(p=Tw(u,n,o,l),f=h),Vy({queryGeometry:p,size:f,transform:n,unwrappedTileID:o,getElevation:l,pitchAlignment:d,pitchScale:c},a)}},Ny=class extends md{};G("HeatmapBucket",Ny,{omit:["layers"]});let Mw;const zw=()=>Mw||(Mw=new wt({"heatmap-radius":new K(z.paint_heatmap["heatmap-radius"],"heatmap-radius"),"heatmap-weight":new K(z.paint_heatmap["heatmap-weight"],"heatmap-weight"),"heatmap-intensity":new N(z.paint_heatmap["heatmap-intensity"],"heatmap-intensity"),"heatmap-color":new Ll(z.paint_heatmap["heatmap-color"],"heatmap-color"),"heatmap-opacity":new N(z.paint_heatmap["heatmap-opacity"],"heatmap-opacity")}));var Fw={get paint(){return zw()}};function yd(e,{width:t,height:r},i,a){if(!a)a=new Uint8Array(t*r*i);else if(a instanceof Uint8ClampedArray)a=new Uint8Array(a.buffer);else if(a.length!==t*r*i)throw RangeError(`mismatched image size. expected: ${a.length} but got: ${t*r*i}`);return e.width=t,e.height=r,e.data=a,e}function Uy(e,{width:t,height:r},i){if(t===e.width&&r===e.height)return;let a=yd({},{width:t,height:r},i);xd(e,a,{x:0,y:0},{x:0,y:0},{width:Math.min(e.width,t),height:Math.min(e.height,r)},i),e.width=t,e.height=r,e.data=a.data}function xd(e,t,r,i,a,n){if(a.width===0||a.height===0)return t;if(a.width>e.width||a.height>e.height||r.x>e.width-a.width||r.y>e.height-a.height)throw RangeError("out of range source coordinates for image copy");if(a.width>t.width||a.height>t.height||i.x>t.width-a.width||i.y>t.height-a.height)throw RangeError("out of range destination coordinates for image copy");let s=e.data,o=t.data;if(s===o)throw Error("srcData equals dstData, so image is already copied");for(let l=0;l<a.height;l++){let u=((r.y+l)*e.width+r.x)*n,h=((i.y+l)*t.width+i.x)*n;for(let c=0;c<a.width*n;c++)o[h+c]=s[u+c]}return t}var vd=class Gy{constructor(t,r){yd(this,t,1,r)}resize(t){Uy(this,t,1)}clone(){return new Gy({width:this.width,height:this.height},new Uint8Array(this.data))}static copy(t,r,i,a,n){xd(t,r,i,a,n,1)}},$e=class qy{constructor(t,r){yd(this,t,4,r)}resize(t){Uy(this,t,4)}replace(t,r){r?this.data.set(t):this.data=t instanceof Uint8ClampedArray?new Uint8Array(t.buffer):t}clone(){return new qy({width:this.width,height:this.height},new Uint8Array(this.data))}static copy(t,r,i,a,n){xd(t,r,i,a,n,4)}setPixel(t,r,i){let a=(t*this.width+r)*4;this.data[a+0]=Math.round(i.r*255/i.a),this.data[a+1]=Math.round(i.g*255/i.a),this.data[a+2]=Math.round(i.b*255/i.a),this.data[a+3]=Math.round(i.a*255)}};function Lu(e){let t=new Uint8Array(e.length);for(let r=0;r<e.length;r+=4){let i=e[r+3];t[r+0]=Math.round(e[r+0]*i/255),t[r+1]=Math.round(e[r+1]*i/255),t[r+2]=Math.round(e[r+2]*i/255),t[r+3]=i}return t}G("AlphaImage",vd),G("RGBAImage",$e);function Zy(e){let t={},r=e.resolution||256,i=e.clips?e.clips.length:1,a=e.image||new $e({width:r,height:i});if(!mv(r))throw Error(`width is not a power of 2 - ${r}`);let n=(s,o,l)=>{t[e.evaluationKey]=l;let u=e.expression.evaluate(t);a.setPixel(s/4/r,o/4,u)};if(e.clips)for(let s=0,o=0;s<i;++s,o+=r*4)for(let l=0,u=0;l<r;l++,u+=4){let h=l/(r-1),{start:c,end:d}=e.clips[s],p=c*(1-h)+d*h;n(o,u,p)}else for(let s=0,o=0;s<r;s++,o+=4){let l=s/(r-1);n(0,o,l)}return a}const Qo="big-fb",Rw=e=>e.type==="heatmap";var kw=class extends Ir{createBucket(t){return new Ny(t)}constructor(t,r){super(t,Fw,r),this.heatmapFbos=new Map,this._updateColorRamp()}_handleSpecialPaintPropertyUpdate(t){t==="heatmap-color"&&this._updateColorRamp()}_updateColorRamp(){let t=this._transitionablePaint._values["heatmap-color"].value.expression;this.colorRamp=Zy({expression:t,evaluationKey:"heatmapDensity",image:this.colorRamp}),this.colorRampTexture=null}resize(){this.heatmapFbos.has("big-fb")&&this.heatmapFbos.delete(Qo)}queryRadius(t){return za("heatmap-radius",this,t)}queryIntersectsFeature({queryGeometry:t,feature:r,featureState:i,geometry:a,transform:n,pixelsToTileUnits:s,unwrappedTileID:o,getElevation:l}){return Vy({queryGeometry:t,size:this.paint.get("heatmap-radius").evaluate(r,i)*s,transform:n,unwrappedTileID:o,getElevation:l},a)}hasOffscreenPass(){return this.paint.get("heatmap-opacity")!==0&&!this.isHidden()}};let Lw;const Bw=()=>Lw||(Lw=new wt({"hillshade-illumination-direction":new N(z.paint_hillshade["hillshade-illumination-direction"],"hillshade-illumination-direction"),"hillshade-illumination-altitude":new N(z.paint_hillshade["hillshade-illumination-altitude"],"hillshade-illumination-altitude"),"hillshade-illumination-anchor":new N(z.paint_hillshade["hillshade-illumination-anchor"],"hillshade-illumination-anchor"),"hillshade-exaggeration":new N(z.paint_hillshade["hillshade-exaggeration"],"hillshade-exaggeration"),"hillshade-shadow-color":new N(z.paint_hillshade["hillshade-shadow-color"],"hillshade-shadow-color"),"hillshade-highlight-color":new N(z.paint_hillshade["hillshade-highlight-color"],"hillshade-highlight-color"),"hillshade-accent-color":new N(z.paint_hillshade["hillshade-accent-color"],"hillshade-accent-color"),"hillshade-method":new N(z.paint_hillshade["hillshade-method"],"hillshade-method"),resampling:new N(z.paint_hillshade.resampling,"resampling")}));var Ow={get paint(){return Bw()}};const $w=e=>e.type==="hillshade";var jw=class extends Ir{constructor(t,r){super(t,Ow,r),this.recalculate({zoom:0,zoomHistory:{}},void 0)}getIlluminationProperties(){let t=this.paint.get("hillshade-illumination-direction").values,r=this.paint.get("hillshade-illumination-altitude").values,i=this.paint.get("hillshade-highlight-color").values,a=this.paint.get("hillshade-shadow-color").values,n=Math.max(t.length,r.length,i.length,a.length);t=t.concat(Array(n-t.length).fill(t.at(-1))),r=r.concat(Array(n-r.length).fill(r.at(-1))),i=i.concat(Array(n-i.length).fill(i.at(-1))),a=a.concat(Array(n-a.length).fill(a.at(-1)));let s=r.map(Ge);return{directionRadians:t.map(Ge),altitudeRadians:s,shadowColor:a,highlightColor:i}}hasOffscreenPass(){return this.paint.get("hillshade-exaggeration")!==0&&!this.isHidden()}};let Vw;const Nw=()=>Vw||(Vw=new wt({"color-relief-opacity":new N(z["paint_color-relief"]["color-relief-opacity"],"color-relief-opacity"),"color-relief-color":new Ll(z["paint_color-relief"]["color-relief-color"],"color-relief-color"),resampling:new N(z["paint_color-relief"].resampling,"resampling")}));var Uw={get paint(){return Nw()}};function Xs(e){return"data"in e}var dt=class{constructor(t,r,i,a){this.context=t,this.format=i,this.texture=t.gl.createTexture(),this._ownedHandle=this.texture,this.update(r,a)}update(t,r,i){var h;let{width:a,height:n}=t,s=(((h=this.size)==null?void 0:h[0])!==a||this.size[1]!==n)&&!i,{context:o}=this,{gl:l}=o;this.useMipmap=!!(r!=null&&r.useMipmap),s&&this.size&&this.format===l.RGBA&&(l.deleteTexture(this.texture),this.texture=l.createTexture(),this._ownedHandle=this.texture,this.magFilter=void 0,this.minFilter=void 0,this.wrap=void 0),l.bindTexture(l.TEXTURE_2D,this.texture),o.pixelStoreUnpackFlipY.set(!1),o.pixelStoreUnpack.set(1);let u=this.format===l.RGBA&&(r==null?void 0:r.premultiply)!==!1;if(s)if(this.size=[a,n],this.format===l.RGBA&&a>0&&n>0){let c=this.useMipmap?Math.floor(Math.log2(Math.max(a,n)))+1:1;if(l.texStorage2D(l.TEXTURE_2D,c,l.RGBA8,a,n),Xs(t)){o.pixelStoreUnpackPremultiplyAlpha.set(!1);let{data:d}=t;u&&d&&(d=Lu(d)),d&&l.texSubImage2D(l.TEXTURE_2D,0,0,0,a,n,l.RGBA,l.UNSIGNED_BYTE,d)}else o.pixelStoreUnpackPremultiplyAlpha.set(u),l.texSubImage2D(l.TEXTURE_2D,0,0,0,l.RGBA,l.UNSIGNED_BYTE,t)}else Xs(t)?(o.pixelStoreUnpackPremultiplyAlpha.set(!1),this._uploadRawData(t,u,a,n,l)):(o.pixelStoreUnpackPremultiplyAlpha.set(u),this._uploadDomImage(t,l));else{let{x:c,y:d}=i||{x:0,y:0};Xs(t)?(o.pixelStoreUnpackPremultiplyAlpha.set(!1),this._updateRawData(t,u,c,d,a,n,l)):(o.pixelStoreUnpackPremultiplyAlpha.set(u),this._updateDomImage(t,c,d,l))}this.useMipmap&&!(Xs(t)&&t.data===null)&&l.generateMipmap(l.TEXTURE_2D),o.pixelStoreUnpackFlipY.setDefault(),o.pixelStoreUnpack.setDefault(),o.pixelStoreUnpackPremultiplyAlpha.setDefault()}_uploadDomImage(t,r){r.texImage2D(r.TEXTURE_2D,0,this.format,this.format,r.UNSIGNED_BYTE,t)}_uploadRawData(t,r,i,a,n){let{data:s}=t;r&&s&&(s=Lu(s)),n.texImage2D(n.TEXTURE_2D,0,this.format,i,a,0,this.format,n.UNSIGNED_BYTE,s)}_updateDomImage(t,r,i,a){a.texSubImage2D(a.TEXTURE_2D,0,r,i,a.RGBA,a.UNSIGNED_BYTE,t)}_updateRawData(t,r,i,a,n,s,o){let{data:l}=t;r&&l&&(l=Lu(l)),o.texSubImage2D(o.TEXTURE_2D,0,i,a,n,s,o.RGBA,o.UNSIGNED_BYTE,l)}bind(t,r,i){let{context:a}=this,{gl:n}=a;this.texture!==this._ownedHandle&&(this.texture=this._ownedHandle),n.bindTexture(n.TEXTURE_2D,this.texture),(i===n.LINEAR_MIPMAP_NEAREST||i===n.LINEAR_MIPMAP_LINEAR)&&!this.useMipmap&&(i=n.LINEAR);let s=i||t;t!==this.magFilter&&(n.texParameteri(n.TEXTURE_2D,n.TEXTURE_MAG_FILTER,t),this.magFilter=t),s!==this.minFilter&&(n.texParameteri(n.TEXTURE_2D,n.TEXTURE_MIN_FILTER,s),this.minFilter=s),r!==this.wrap&&(n.texParameteri(n.TEXTURE_2D,n.TEXTURE_WRAP_S,r),n.texParameteri(n.TEXTURE_2D,n.TEXTURE_WRAP_T,r),this.wrap=r)}generateMipmap(){if(!this.useMipmap)return;let{gl:t}=this.context;t.bindTexture(t.TEXTURE_2D,this.texture),t.generateMipmap(t.TEXTURE_2D)}destroy(){let{gl:t}=this.context;t.deleteTexture(this.texture),this.texture=null,this._ownedHandle=null}},si,Gw=(si=class{constructor(t,r,i,a=1,n=1,s=1,o=0){if(this.uid=t,r.height!==r.width)throw RangeError("DEM tiles must be square");if(i&&!["mapbox","terrarium","custom"].includes(i)){_e(`"${i}" is not a valid encoding type. Valid types include "mapbox", "terrarium" and "custom".`);return}this.stride=r.height;let l=this.dim=r.height-4;switch(this.data=new Uint32Array(r.data.buffer),si.byteViewCache.set(this,new Uint8Array(this.data.buffer)),i){case"terrarium":this.redFactor=256,this.greenFactor=1,this.blueFactor=1/256,this.baseShift=32768;break;case"custom":this.redFactor=a,this.greenFactor=n,this.blueFactor=s,this.baseShift=o;break;default:this.redFactor=6553.6,this.greenFactor=25.6,this.blueFactor=.1,this.baseShift=1e4}for(let h=-2;h<l+2;h++){let c=this._idx(0,Math.max(0,Math.min(l-1,h)));(h<0||h>=l)&&this.data.copyWithin(this._idx(0,h),c,c+l),this.data.fill(this.data[c],this._idx(-2,h),this._idx(0,h)),this.data.fill(this.data[c+l-1],this._idx(l,h),this._idx(l+1,h)+1)}let u=this._getByteView();this.min=2**53-1,this.max=-9007199254740991;for(let h=0;h<l;h++)for(let c=0;c<l;c++){let d=this._idx(h,c)*4,p=this._unpackAtIndex(u,d);p>this.max&&(this.max=p),p<this.min&&(this.min=p)}}get(t,r){let i=this._getByteView(),a=this._idx(t,r)*4;return this._unpackAtIndex(i,a)}sampleBilinear(t,r){let i=Math.floor(t),a=Math.floor(r);if(i<-1||i>=this.dim||a<-1||a>=this.dim)throw RangeError(`Out of range source coordinates for DEM data. x: ${t}, y: ${r}, dim: ${this.dim}`);let n=this._getByteView(),s=((a+2)*this.stride+i+2)*4,o=this.stride*4,l=t-i,u=r-a,h=this._unpackAtIndex(n,s),c=this._unpackAtIndex(n,s+4),d=this._unpackAtIndex(n,s+o),p=this._unpackAtIndex(n,s+o+4);return h*(1-l)*(1-u)+c*l*(1-u)+d*(1-l)*u+p*l*u}getUnpackVector(){return[this.redFactor,this.greenFactor,this.blueFactor,this.baseShift]}_idx(t,r){if(t<-2||t>=this.dim+2||r<-2||r>=this.dim+2)throw RangeError(`Out of range source coordinates for DEM data. x: ${t}, y: ${r}, dim: ${this.dim}`);return(r+2)*this.stride+(t+2)}unpack(t,r,i){return t*this.redFactor+r*this.greenFactor+i*this.blueFactor-this.baseShift}pack(t){return Wy(t,this.getUnpackVector())}getPixels(){return new $e({width:this.stride,height:this.stride},this._getByteView())}backfillBorder(t,r,i){if(this.dim!==t.dim)throw Error("dem dimension mismatch");let a=r*this.dim,n=r*this.dim+this.dim,s=i*this.dim,o=i*this.dim+this.dim;switch(r){case-1:a=n-2;break;case 1:n=a+2}switch(i){case-1:s=o-2;break;case 1:o=s+2}let l=-r*this.dim,u=-i*this.dim;for(let h=s;h<o;h++)for(let c=a;c<n;c++)this.data[this._idx(c,h)]=t.data[this._idx(c+l,h+u)]}_getByteView(){let t=si.byteViewCache.get(this);return(t==null?void 0:t.buffer)!==this.data.buffer&&(t=new Uint8Array(this.data.buffer),si.byteViewCache.set(this,t)),t}_unpackAtIndex(t,r){return this.unpack(t[r],t[r+1],t[r+2])}},si.byteViewCache=new WeakMap,si);function Wy(e,t){let r=t[0],i=t[1],a=t[2],n=t[3],s=Math.min(r,i,a),o=Math.round((e+n)/s);return{r:Math.floor(o*s/r)%256,g:Math.floor(o*s/i)%256,b:Math.floor(o*s/a)%256}}G("DEMData",Gw);const qw=e=>e.type==="color-relief";var Zw=class extends Ir{constructor(t,r){super(t,Uw,r)}_createColorRamp(t){let r={elevationStops:[],colorStops:[]},i=this._transitionablePaint._values["color-relief-color"].value.expression;if(i instanceof Wn&&i._styleExpression.expression instanceof _r){this.colorRampExpression=i;let s=i._styleExpression.expression;r.elevationStops=s.labels,r.colorStops=[];for(let o of r.elevationStops)r.colorStops.push(s.evaluate({globals:{elevation:o}}))}if(r.elevationStops.length<1&&(r.elevationStops=[0],r.colorStops=[oe.transparent]),r.elevationStops.length<2&&(r.elevationStops.push(r.elevationStops[0]+1),r.colorStops.push(r.colorStops[0])),r.elevationStops.length<=t)return r;let a={elevationStops:[],colorStops:[]},n=(r.elevationStops.length-1)/(t-1);for(let s=0;s<r.elevationStops.length-.5;s+=n)a.elevationStops.push(r.elevationStops[Math.round(s)]),a.colorStops.push(r.colorStops[Math.round(s)]);return _e(`Too many colors in specification of ${this.id} color-relief layer, may not render properly. Max possible colors: ${t}, provided: ${r.elevationStops.length}`),a}_colorRampChanged(){return this.colorRampExpression!=this._transitionablePaint._values["color-relief-color"].value.expression}getColorRampTextures(t,r,i){if(this.colorRampTextures&&!this._colorRampChanged())return this.colorRampTextures;let a=this._createColorRamp(r),n=new $e({width:a.colorStops.length,height:1}),s=new $e({width:a.colorStops.length,height:1});for(let o=0;o<a.elevationStops.length;o++){let l=Wy(a.elevationStops[o],i);s.setPixel(0,o,new oe(l.r/255,l.g/255,l.b/255,1)),n.setPixel(0,o,a.colorStops[o])}return this.colorRampTextures={elevationTexture:new dt(t,s,t.gl.RGBA),colorTexture:new dt(t,n,t.gl.RGBA)},this.colorRampTextures}hasOffscreenPass(){return!this.isHidden()&&!!this.colorRampTextures}};const Ww=Ye([{name:"a_pos",components:2,type:"Int16"}],4),Hw=Ww.members;function el(e,t,r){let i=r.patternDependencies,a=!1;for(let n of t){let s=n.paint.get(`${e}-pattern`);s.isConstant()||(a=!0);let o=s.constantOr(null);o&&(a=!0,i[o.to]=!0,i[o.from]=!0)}return a}function bd(e,t,r,i,a){let{zoom:n}=i,s=a.patternDependencies;for(let o of t){let l=o.paint.get(`${e}-pattern`).value;if(l.kind!=="constant"){let u=l.evaluate({zoom:n-1},r,{},a.availableImages),h=l.evaluate({zoom:n},r,{},a.availableImages),c=l.evaluate({zoom:n+1},r,{},a.availableImages);u=u!=null&&u.name?u.name:u,h=h!=null&&h.name?h.name:h,c=c!=null&&c.name?c.name:c,s[u]=!0,s[h]=!0,s[c]=!0,r.patterns[o.id]={min:u,mid:h,max:c}}}return r}const ts=new Set;let ac=!1;function Xw(e,t,r=2){let i=t&&t.length,a=i?t[0]*r:e.length;ts.size&&ts.clear();let n=Hy(e,0,a,r,!0),s=[];if(!n||n.next===n.prev)return s;let o=0,l=0,u=0;if(i&&(n=eT(e,t,n,r)),e.length>80*r){o=e[0],l=e[1];let h=o,c=l;for(let d=r;d<a;d+=r){let p=e[d],f=e[d+1];p<o&&(o=p),f<l&&(l=f),p>h&&(h=p),f>c&&(c=f)}u=Math.max(h-o,c-l),u=u===0?0:32767/u}return nc(n,s,o,l,u),s}function Hy(e,t,r,i,a){let n=null;if(a===pT(e,t,r,i)>0)for(let s=t;s<r;s+=i)n=Mf(s/i|0,e[s],e[s+1],n);else for(let s=r-i;s>=t;s-=i)n=Mf(s/i|0,e[s],e[s+1],n);return n&&rs(n,n.next)&&(as(n),n=n.next),n}function Qi(e,t=e){let r=t===e,i=e,a;do a=!1,i!==i.next&&(ts.size===0||!ts.has(i))&&(rs(i,i.next)||ct(i.prev,i,i.next)===0)?((r||i===t)&&(t=i.prev),ac=!0,as(i),i=i.prev,a=!0):(r||i!==t)&&(i=i.next,a=!r);while(a||i!==t);return t}function nc(e,t,r,i,a){a&&oT(e,r,i,a);let n=e,s=!1;for(;e.prev!==e.next;){let o=e.prev,l=e.next;if(ct(o,e,l)<0&&(a?Kw(e,r,i,a):Yw(e))){t.push(o.i,e.i,l.i),as(e),e=l,n=l;continue}if(e=l,e===n){if(ac=!1,e=Qi(e),ac){n=e;continue}if(!s){e=Jw(e,t),n=e,s=!0;continue}Qw(e,t,r,i,a);break}}}function Yw(e){let t=e.prev,r=e,i=e.next,a=t.x,n=r.x,s=i.x,o=t.y,l=r.y,u=i.y,h=Math.min(a,n,s),c=Math.min(o,l,u),d=Math.max(a,n,s),p=Math.max(o,l,u),f=i.next;for(;f!==t;){if(f.x>=h&&f.x<=d&&f.y>=c&&f.y<=p&&(a!==f.x||o!==f.y)&&rl(a,o,n,l,s,u,f.x,f.y)&&ct(f.prev,f,f.next)>=0)return!1;f=f.next}return!0}function Kw(e,t,r,i){let a=e.prev,n=e,s=e.next,o=a.x,l=n.x,u=s.x,h=a.y,c=n.y,d=s.y,p=Math.min(o,l,u),f=Math.min(h,c,d),m=Math.max(o,l,u),g=Math.max(h,c,d),_=uc(p,f,t,r,i),y=uc(m,g,t,r,i),v=e.prevZ;for(;v&&v.z>=_;){if(v.x>=p&&v.x<=m&&v.y>=f&&v.y<=g&&v!==s&&(o!==v.x||h!==v.y)&&rl(o,h,l,c,u,d,v.x,v.y)&&ct(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<=g&&x!==s&&(o!==x.x||h!==x.y)&&rl(o,h,l,c,u,d,x.x,x.y)&&ct(x.prev,x,x.next)>=0)return!1;x=x.nextZ}return!0}function Jw(e,t){let r=e,i=!1;do{let a=r.prev,n=r.next.next;Yy(a,r,r.next,n,!1)&&is(a,n)&&is(n,a)&&(t.push(a.i,r.i,n.i),as(r),as(r.next),r=e=n,i=!0),r=r.next}while(r!==e);return i?Qi(r):r}function Qw(e,t,r,i,a){let n=e;do{let s=n.next.next;for(;s!==n.prev;){if(n.i!==s.i&&hT(n,s)){let o=Ky(n,s);n=Qi(n,n.next),o=Qi(o,o.next),nc(n,t,r,i,a),nc(o,t,r,i,a);return}s=s.next}n=n.next}while(n!==e)}let sc=!1;function eT(e,t,r,i){let a=[];for(let n=0,s=t.length;n<s;n++){let o=Hy(e,t[n]*i,n<s-1?t[n+1]*i:e.length,i,!1);o===o.next&&ts.add(o),a.push(uT(o))}a.sort(tT),iT(e.length/i,t.length),Xy(r,r),sc=!0;for(let n=0;n<a.length;n++)r=rT(a[n],r);return sc=!1,Qi(r)}function tT(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 rT(e,t){let r=nT(e,t);if(!r)return t;let i=Ky(r,e),a=i.next;return Xy(r,a.next),Qi(i,i.next),Qi(r,r.next)}let tt=new Float64Array,tl=0;const oc=[],lc=[];function iT(e,t){let r=Math.ceil((e+2*t)/16)+t+2;tt.length<r*4&&(tt=new Float64Array(r*4)),tl=0}function Xy(e,t){let r=e;do{let i=tl++;oc[i]=r;let a=1/0,n=1/0,s=-1/0,o=-1/0,l=0;do{let h=r.next;r.z=i,r.x<a&&(a=r.x),r.x>s&&(s=r.x),r.y<n&&(n=r.y),r.y>o&&(o=r.y),h.x<a&&(a=h.x),h.x>s&&(s=h.x),h.y<n&&(n=h.y),h.y>o&&(o=h.y),r=h}while(++l<16&&r!==t);lc[i]=r;let u=i*4;tt[u]=a,tt[u+1]=n,tt[u+2]=s,tt[u+3]=o}while(r!==t)}function aT(e,t){let r=e.z*4;t.x<tt[r]&&(tt[r]=t.x),t.y<tt[r+1]&&(tt[r+1]=t.y),t.x>tt[r+2]&&(tt[r+2]=t.x),t.y>tt[r+3]&&(tt[r+3]=t.y)}function Cf(e){let t=lc[e];for(;t.prev.next!==t;)t=t.next;return lc[e]=t,t}function If(e){let t=oc[e];for(;t.prev.next!==t;)t=t.next;return oc[e]=t,t}function nT(e,t){let r=t,i=e.x,a=e.y,n=-1/0,s;if(rs(e,r))return r;for(let d=0,p=0;d<tl;d++,p+=4){if(a<tt[p+1]||a>tt[p+3]||tt[p]>i||tt[p+2]<=n)continue;let f=Cf(d);r=If(d);do{if(r.prev.next===r){if(rs(e,r.next))return r.next;if(a<=r.y&&a>=r.next.y&&r.next.y!==r.y){let m=r.x+(a-r.y)*(r.next.x-r.x)/(r.next.y-r.y);if(m<=i&&m>n&&(n=m,s=r.x<r.next.x?r:r.next,m===i))return s}}r=r.next}while(r!==f)}if(!s)return null;let o=s.x,l=s.y,u=Math.min(a,l),h=Math.max(a,l),c=1/0;for(let d=0,p=0;d<tl;d++,p+=4){if(tt[p+2]<o||tt[p]>i||tt[p+3]<u||tt[p+1]>h)continue;let f=Cf(d);r=If(d);do{if(r.prev.next===r&&i>=r.x&&r.x>=o&&i!==r.x&&rl(a<l?i:n,a,o,l,a<l?n:i,a,r.x,r.y)){let m=Math.abs(a-r.y)/(i-r.x);(is(r,e)||r.y===a&&r.next.y===a&&r.next.x>i)&&(m<c||m===c&&(r.x>s.x||r.x===s.x&&sT(s,r)))&&(s=r,c=m)}r=r.next}while(r!==f)}return s}function sT(e,t){return ct(e.prev,e,t.prev)<0&&ct(t.next,e,e.next)<0}const dr=[];let fn=[],zi=new Uint32Array,mn=new Uint32Array;const gn=new Uint32Array(256);function oT(e,t,r,i){let a=e,n=0;do a.z=uc(a.x,a.y,t,r,i),dr[n++]=a,a=a.next;while(a!==e);lT(n);let s=null;for(let o=0;o<n;o++){let l=dr[o];l.prevZ=s,s&&(s.nextZ=l),s=l}s.nextZ=null}function lT(e){if(e<=32){for(let t=1;t<e;t++){let r=dr[t],i=r.z,a=t-1;for(;a>=0&&dr[a].z>i;)dr[a+1]=dr[a],a--;dr[a+1]=r}return}zi.length<e&&(zi=new Uint32Array(e),mn=new Uint32Array(e),fn=Array(e));for(let t=0;t<e;t++)zi[t]=dr[t].z;Ys(e,dr,zi,fn,mn,0),Ys(e,fn,mn,dr,zi,8),Ys(e,dr,zi,fn,mn,16),Ys(e,fn,mn,dr,zi,24)}function Ys(e,t,r,i,a,n){gn.fill(0);for(let o=0;o<e;o++)gn[r[o]>>>n&255]++;let s=0;for(let o=0;o<256;o++){let l=gn[o];gn[o]=s,s+=l}for(let o=0;o<e;o++){let l=r[o],u=gn[l>>>n&255]++;i[u]=t[o],a[u]=l}}function uc(e,t,r,i,a){return e=(e-r)*a|0,t=(t-i)*a|0,e=(e|e<<8)&16711935,e=(e|e<<4)&252645135,e=(e|e<<2)&858993459,e=(e|e<<1)&1431655765,t=(t|t<<8)&16711935,t=(t|t<<4)&252645135,t=(t|t<<2)&858993459,t=(t|t<<1)&1431655765,e|t<<1}function uT(e){let t=e,r=e;do(t.x<r.x||t.x===r.x&&t.y<r.y)&&(r=t),t=t.next;while(t!==e);return r}function rl(e,t,r,i,a,n,s,o){return(a-s)*(t-o)>=(e-s)*(n-o)&&(e-s)*(i-o)>=(r-s)*(t-o)&&(r-s)*(n-o)>=(a-s)*(i-o)}function hT(e,t){let r=rs(e,t)&&ct(e.prev,e,e.next)>0&&ct(t.prev,t,t.next)>0;return e.next.i!==t.i&&(r||is(e,t)&&is(t,e)&&(ct(e.prev,e,t.prev)!==0||ct(e,t.prev,t)!==0))&&!cT(e,t)&&(r||dT(e,t))}function ct(e,t,r){return(t.y-e.y)*(r.x-t.x)-(t.x-e.x)*(r.y-t.y)}function rs(e,t){return e.x===t.x&&e.y===t.y}function Yy(e,t,r,i,a=!0){let n=ct(e,t,r),s=ct(e,t,i),o=ct(r,i,e),l=ct(r,i,t);return(n>0&&s<0||n<0&&s>0)&&(o>0&&l<0||o<0&&l>0)?!0:a?!!(n===0&&Ks(e,r,t)||s===0&&Ks(e,i,t)||o===0&&Ks(r,e,i)||l===0&&Ks(r,t,i)):!1}function Ks(e,t,r){return t.x<=Math.max(e.x,r.x)&&t.x>=Math.min(e.x,r.x)&&t.y<=Math.max(e.y,r.y)&&t.y>=Math.min(e.y,r.y)}function cT(e,t){let r=Math.min(e.x,t.x),i=Math.max(e.x,t.x),a=Math.min(e.y,t.y),n=Math.max(e.y,t.y),s=e;do{let o=s.next;if(s.x>i&&o.x>i||s.x<r&&o.x<r||s.y>n&&o.y>n||s.y<a&&o.y<a){s=o;continue}if(s.i!==e.i&&o.i!==e.i&&s.i!==t.i&&o.i!==t.i&&Yy(s,o,e,t))return!0;s=o}while(s!==e);return!1}function is(e,t){return ct(e.prev,e,e.next)<0?ct(e,t,e.next)>=0&&ct(e,e.prev,t)>=0:ct(e,t,e.prev)<0||ct(e,e.next,t)<0}function dT(e,t){let r=e,i=!1,a=(e.x+t.x)/2,n=(e.y+t.y)/2;do{let s=r.next;r.y>n!=s.y>n&&a<(s.x-r.x)*(n-r.y)/(s.y-r.y)+r.x&&(i=!i),r=s}while(r!==e);return i}function Ky(e,t){let r=hc(e.i,e.x,e.y),i=hc(t.i,t.x,t.y),a=e.next,n=t.prev;return e.next=t,t.prev=e,r.next=a,a.prev=r,i.next=r,r.prev=i,n.next=i,i.prev=n,i}function Mf(e,t,r,i){let a=hc(e,t,r);return i?(a.next=i.next,a.prev=i,i.next.prev=a,i.next=a):(a.prev=a,a.next=a),a}function as(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),sc&&aT(e.prev,e.next)}function hc(e,t,r){return{i:e,x:t,y:r,prev:null,next:null,z:0,prevZ:null,nextZ:null}}function pT(e,t,r,i){let a=0;for(let n=t,s=r-i;n<r;n+=i)a+=(e[s]-e[n])*(e[n+1]+e[s+1]),s=n;return a}var ii=class{constructor(t,r){if(r>t)throw Error("Min granularity must not be greater than base granularity.");this._baseZoomGranularity=t,this._minGranularity=r}getGranularityForZoomLevel(t){let r=1<<t;return Math.max(Math.floor(this._baseZoomGranularity/r),this._minGranularity,1)}},Wi,wd=(Wi=class{constructor(t){this.fill=t.fill,this.line=t.line,this.tile=t.tile,this.stencil=t.stencil,this.circle=t.circle}},Wi.noSubdivision=new Wi({fill:new ii(0,0),line:new ii(0,0),tile:new ii(0,0),stencil:new ii(0,0),circle:1}),Wi);G("SubdivisionGranularityExpression",ii),G("SubdivisionGranularitySetting",wd);const Bn=-32768,On=32767;var fT=class{constructor(t,r){this._vertexBuffer=[],this._vertexDictionary=new Map,this._used=!1,this._granularity=t,this._granularityCellSize=L/t,this._canonical=r}_getKey(t,r){return t+=32768,r+=32768,t<<16|r<<0}_vertexToIndex(t,r){if(t<-32768||r<-32768||t>32767||r>32767)throw Error("Vertex coordinates are out of signed 16 bit integer range.");let i=Math.round(t)|0,a=Math.round(r)|0,n=this._getKey(i,a),s=this._vertexDictionary.get(n);if(s!==void 0)return s;let o=this._vertexBuffer.length/2;return this._vertexDictionary.set(n,o),this._vertexBuffer.push(i,a),o}_subdivideTrianglesScanline(t,r){if(this._granularity<2)return _T(this._vertexBuffer,gT(t,r));let i=[],a=t.length;for(let n=0;n<a;n+=3){let s=[r[t[n+0]],r[t[n+1]],r[t[n+2]]],o=[this._vertexBuffer[s[0]*2+0],this._vertexBuffer[s[0]*2+1],this._vertexBuffer[s[1]*2+0],this._vertexBuffer[s[1]*2+1],this._vertexBuffer[s[2]*2+0],this._vertexBuffer[s[2]*2+1]],l=1/0,u=1/0,h=-1/0,c=-1/0;for(let g=0;g<3;g++){let _=o[g*2],y=o[g*2+1];l=Math.min(l,_),h=Math.max(h,_),u=Math.min(u,y),c=Math.max(c,y)}if(l===h||u===c)continue;let d=Math.floor(l/this._granularityCellSize),p=Math.ceil(h/this._granularityCellSize),f=Math.floor(u/this._granularityCellSize),m=Math.ceil(c/this._granularityCellSize);if(d===p&&f===m){i.push(...s);continue}for(let g=f;g<m;g++){let _=this._scanlineGenerateVertexRingForCellRow(g,o,s);yT(this._vertexBuffer,_,i)}}return i}_scanlineGenerateVertexRingForCellRow(t,r,i){let a=t*this._granularityCellSize,n=a+this._granularityCellSize,s=[];for(let o=0;o<3;o++){let l=r[o*2],u=r[o*2+1],h=r[(o+1)*2%6],c=r[((o+1)*2+1)%6],d=r[(o+2)*2%6],p=r[((o+2)*2+1)%6],f=h-l,m=c-u,g=f===0,_=m===0,y=(a-u)/m,v=(n-u)/m,x=Math.min(y,v),w=Math.max(y,v);if(!_&&(x>=1||w<=0)||_&&(u<a||u>n)){c>=a&&c<=n&&s.push(i[(o+1)%3]);continue}if(!_&&x>0){let A=l+f*x,P=u+m*x;s.push(this._vertexToIndex(A,P))}let b=l+f*Math.max(x,0),S=l+f*Math.min(w,1);if(g||this._generateIntraEdgeVertices(s,l,u,h,c,b,S),!_&&w<1){let A=l+f*w,P=u+m*w;s.push(this._vertexToIndex(A,P))}(_||c>=a&&c<=n)&&s.push(i[(o+1)%3]),!_&&(c<=a||c>=n)&&this._generateInterEdgeVertices(s,l,u,h,c,d,p,S,a,n)}return s}_generateIntraEdgeVertices(t,r,i,a,n,s,o){let l=a-r,u=n-i,h=u===0,c=h?Math.min(r,a):Math.min(s,o),d=h?Math.max(r,a):Math.max(s,o),p=Math.floor(c/this._granularityCellSize)+1,f=Math.ceil(d/this._granularityCellSize)-1;if(h?r<a:s<o)for(let m=p;m<=f;m++){let g=m*this._granularityCellSize,_=i+u*(g-r)/l;t.push(this._vertexToIndex(g,_))}else for(let m=f;m>=p;m--){let g=m*this._granularityCellSize,_=i+u*(g-r)/l;t.push(this._vertexToIndex(g,_))}}_generateInterEdgeVertices(t,r,i,a,n,s,o,l,u,h){let c=n-i,d=s-a,p=o-n,f=(u-n)/p,m=(h-n)/p,g=Math.min(f,m),_=Math.max(f,m),y=a+d*g,v=Math.floor(Math.min(y,l)/this._granularityCellSize)+1,x=Math.ceil(Math.max(y,l)/this._granularityCellSize)-1,w=l<y,b=p===0;if(b&&(o===u||o===h))return;if(b||g>=1||_<=0){let A=r-s,P=i-o,I=(u-o)/P,R=(h-o)/P,F=s+A*Math.min(I,R);v=Math.floor(Math.min(F,l)/this._granularityCellSize)+1,x=Math.ceil(Math.max(F,l)/this._granularityCellSize)-1,w=l<F}let S=c>0?h:u;if(w)for(let A=v;A<=x;A++){let P=A*this._granularityCellSize;t.push(this._vertexToIndex(P,S))}else for(let A=x;A>=v;A--){let P=A*this._granularityCellSize;t.push(this._vertexToIndex(P,S))}}_generateOutline(t,r){let i=[],a=0;for(let n of t){let s=this._granularity<2?this._ringPathIndices(n,a,r):this._pointArrayToIndices($i(n,this._granularity,!0));a+=n.length;let o=[];for(let l=1;l<s.length;l++)o.push(s[l-1]),o.push(s[l]);i.push(o)}return i}_ringPathIndices(t,r,i){let a=i.slice(r,r+t.length);return a.length>=2&&Qy(t)&&a.push(a[0]),a}_handlePoles(t){let r=!1,i=!1;this._canonical&&(this._canonical.y===0&&(r=!0),this._canonical.y===(1<<this._canonical.z)-1&&(i=!0)),(r||i)&&this._fillPoles(t,r,i)}_ensureNoPoleVertices(){let t=this._vertexBuffer;for(let r=0;r<t.length;r+=2){let i=t[r+1];i===-32768&&(t[r+1]=-32767),i===32767&&(t[r+1]=32766)}}_generatePoleQuad(t,r,i,a,n,s){a>n==(s===-32768)?(t.push(i),t.push(r),t.push(this._vertexToIndex(a,s)),t.push(this._vertexToIndex(n,s)),t.push(i),t.push(this._vertexToIndex(a,s))):(t.push(r),t.push(i),t.push(this._vertexToIndex(a,s)),t.push(i),t.push(this._vertexToIndex(n,s)),t.push(this._vertexToIndex(a,s)))}_fillPoles(t,r,i){let a=this._vertexBuffer,n=L,s=t.length;for(let o=2;o<s;o+=3){let l=t[o-2],u=t[o-1],h=t[o],c=a[l*2],d=a[l*2+1],p=a[u*2],f=a[u*2+1],m=a[h*2],g=a[h*2+1];r&&(d===0&&f===0&&this._generatePoleQuad(t,l,u,c,p,Bn),f===0&&g===0&&this._generatePoleQuad(t,u,h,p,m,Bn),g===0&&d===0&&this._generatePoleQuad(t,h,l,m,c,Bn)),i&&(d===n&&f===n&&this._generatePoleQuad(t,l,u,c,p,On),f===n&&g===n&&this._generatePoleQuad(t,u,h,p,m,On),g===n&&d===n&&this._generatePoleQuad(t,h,l,m,c,On))}}_initializeVertices(t){let r=[];for(let i=0;i<t.length;i+=2)r.push(this._vertexToIndex(t[i],t[i+1]));return r}subdividePolygonInternal(t,r){var l;if(this._used)throw Error("Subdivision: multiple use not allowed.");this._used=!0;let{flattened:i,holeIndices:a}=mT(t),n=this._initializeVertices(i),s;try{let u=Xw(i,a);s=this._subdivideTrianglesScanline(u,n)}catch(u){console.error(u)}let o=[];return r&&(o=this._generateOutline(t,n)),this._ensureNoPoleVertices(),this._handlePoles(s),this._granularity>=2&&((l=this._canonical)==null?void 0:l.z)===0&&(s=this._removeTrianglesOutsideTileX(s),o=o.map(u=>this._removeLinesOutsideTileX(u))),{verticesFlattened:this._vertexBuffer,indicesTriangles:s,indicesLineList:o}}_vertexOutsideTileX(t){let r=this._vertexBuffer[t*2];return r<0||r>8192}_removeTrianglesOutsideTileX(t){let r=[];for(let i=0;i<t.length;i+=3)this._vertexOutsideTileX(t[i])||this._vertexOutsideTileX(t[i+1])||this._vertexOutsideTileX(t[i+2])||r.push(t[i],t[i+1],t[i+2]);return r}_removeLinesOutsideTileX(t){let r=[];for(let i=0;i<t.length;i+=2)this._vertexOutsideTileX(t[i])||this._vertexOutsideTileX(t[i+1])||r.push(t[i],t[i+1]);return r}_pointArrayToIndices(t){let r=[];for(let i of t)r.push(this._vertexToIndex(i.x,i.y));return r}};function Jy(e,t,r,i=!0){return new fT(r,t).subdividePolygonInternal(e,i)}function $i(e,t,r=!1){if(!e||e.length<1||e.length<2)return[];let i=r&&Qy(e);if(t<2)return i?[...e,e[0]]:[...e];let a=Math.floor(L/t),n=[];n.push(new M(e[0].x,e[0].y));let s=e.length,o=i?s:s-1;for(let l=0;l<o;l++){let u=e[l],h=l<s-1?e[l+1]:e[0],c=u.x,d=u.y,p=h.x,f=h.y,m=c!==p,g=d!==f;if(!m&&!g)continue;let _=p-c,y=f-d,v=Math.abs(_),x=Math.abs(y),w=c,b=d;for(;;){let A=_>0?(Math.floor(w/a)+1)*a:(Math.ceil(w/a)-1)*a,P=y>0?(Math.floor(b/a)+1)*a:(Math.ceil(b/a)-1)*a,I=Math.abs(w-A),R=Math.abs(b-P),F=Math.abs(w-p),T=Math.abs(b-f),E=m?I/v:1/0,D=g?R/x:1/0;if((F<=I||!m)&&(T<=R||!g))break;if(E<D&&m||!g){w=A,b+=y*E;let C=new M(w,Math.round(b));(n[n.length-1].x!==C.x||n[n.length-1].y!==C.y)&&n.push(C)}else{w+=_*D,b=P;let C=new M(Math.round(w),b);(n[n.length-1].x!==C.x||n[n.length-1].y!==C.y)&&n.push(C)}}let S=new M(p,f);(n[n.length-1].x!==S.x||n[n.length-1].y!==S.y)&&n.push(S)}return n}function Qy(e){return!e[0].equals(e[e.length-1])}function mT(e){let t=[],r=[];for(let i of e)if(i.length!==0){i!==e[0]&&t.push(r.length/2);for(let a of i)r.push(a.x),r.push(a.y)}return{flattened:r,holeIndices:t}}function gT(e,t){let r=Array(e.length);for(let i=0;i<e.length;i++)r[i]=t[e[i]];return r}function _T(e,t){let r=[];for(let i=0;i<t.length;i+=3){let a=t[i],n=t[i+1],s=t[i+2],o=e[a*2],l=e[a*2+1],u=e[n*2],h=e[n*2+1],c=e[s*2],d=e[s*2+1],p=u-o,f=h-l,m=c-o;p*(d-l)-f*m>0?(r.push(a),r.push(s),r.push(n)):(r.push(a),r.push(n),r.push(s))}return r}function yT(e,t,r){if(t.length===0)throw Error("Subdivision vertex ring is empty.");let i=0,a=e[t[0]*2];for(let l=1;l<t.length;l++){let u=e[t[l]*2];u<a&&(a=u,i=l)}let n=t.length,s=i,o=(s+1)%n;for(;;){let l=s-1>=0?s-1:n-1,u=(o+1)%n,h=e[t[l]*2],c=e[t[l]*2+1],d=e[t[u]*2],p=e[t[u]*2+1],f=e[t[s]*2],m=e[t[s]*2+1],g=e[t[o]*2],_=e[t[o]*2+1],y=!1;if(h<d)y=!0;else if(h>d)y=!1;else{let v=_-m,x=-(g-f),w=m<_?1:-1;((h-f)*v+(c-m)*x)*w>((d-f)*v+(p-m)*x)*w&&(y=!0)}if(y){let v=t[l],x=t[s],w=t[o];v!==x&&v!==w&&x!==w&&r.push(w,x,v),s--,s<0&&(s=n-1)}else{let v=t[u],x=t[s],w=t[o];v!==x&&v!==w&&x!==w&&r.push(w,x,v),o++,o>=n&&(o=0)}if(l===u)break}}function e0(e,t,r,i,a,n,s,o,l){let u=a.length/2,h=s&&o&&l;if(u<Ze.MAX_VERTEX_ARRAY_LENGTH){let c=t.prepareSegment(u,r,i),d=c.vertexLength;for(let m=0;m<n.length;m+=3)i.emplaceBack(d+n[m],d+n[m+1],d+n[m+2]);c.vertexLength+=u,c.primitiveLength+=n.length/3;let p,f;h&&(f=s.prepareSegment(u,r,o),p=f.vertexLength,f.vertexLength+=u);for(let m=0;m<a.length;m+=2)e(a[m],a[m+1]);if(h)for(let m of l){for(let g=1;g<m.length;g+=2)o.emplaceBack(p+m[g-1],p+m[g]);f.primitiveLength+=m.length/2}}else xT(t,r,i,a,n,e),h&&vT(s,r,o,a,l,e),t.forceNewSegmentOnNextPrepare(),s==null||s.forceNewSegmentOnNextPrepare()}function $n(e,t,r,i,a,n,s){if(n){let o=i.count;return r(t[a*2],t[a*2+1]),e[a]=i.count,i.count++,s.vertexLength++,o}return e[a]}function xT(e,t,r,i,a,n){let s=[];for(let c=0;c<i.length/2;c++)s.push(-1);let o={count:0},l=0,u=e.getOrCreateLatestSegment(t,r),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=s[d]<l,g=s[p]<l,_=s[f]<l,y=+!!m+ +!!g+ +!!_;u.vertexLength+y>Ze.MAX_VERTEX_ARRAY_LENGTH&&(u=e.createNewSegment(t,r),l=o.count,m=!0,g=!0,_=!0,h=0);let v=$n(s,i,n,o,d,m,u),x=$n(s,i,n,o,p,g,u),w=$n(s,i,n,o,f,_,u);r.emplaceBack(h+v-l,h+x-l,h+w-l),u.primitiveLength++}}function vT(e,t,r,i,a,n){let s=[];for(let c=0;c<i.length/2;c++)s.push(-1);let o={count:0},l=0,u=e.getOrCreateLatestSegment(t,r),h=u.vertexLength;for(let c of a)for(let d=1;d<c.length;d+=2){let p=c[d-1],f=c[d],m=s[p]<l,g=s[f]<l,_=+!!m+ +!!g;u.vertexLength+_>Ze.MAX_VERTEX_ARRAY_LENGTH&&(u=e.createNewSegment(t,r),l=o.count,m=!0,g=!0,h=0);let y=$n(s,i,n,o,p,m,u),v=$n(s,i,n,o,f,g,u);r.emplaceBack(h+y-l,h+v-l),u.primitiveLength++}}var t0=class{constructor(t){this.zoom=t.zoom,this.overscaling=t.overscaling,this.layers=t.layers,this.layerIds=this.layers.map(r=>r.id),this.index=t.index,this.hasDependencies=!1,this.sdfPatterns={},this.patternFeatures=[],this.layoutVertexArray=new q2,this.indexArray=new Yr,this.indexArray2=new Qh,this.programConfigurations=new Ji(t.layers,t.zoom),this.segments=new Ze,this.segments2=new Ze,this.stateDependentLayerIds=this.layers.filter(r=>r.isStateDependent()).map(r=>r.id)}populate(t,r,i){this.hasDependencies=el("fill",this.layers,r);let a=this.layers[0].layout.get("fill-sort-key"),n=!a.isConstant(),s=[],o=new ze(this.zoom),l=this.layers[0]._featureFilter.needGeometry;for(let{feature:u,id:h,index:c,sourceLayerIndex:d}of t){let p=aa(u,l);if(!this.layers[0]._featureFilter.filter(o,p,i))continue;let f=n?a.evaluate(p,{},i,r.availableImages):void 0,m={id:h,properties:u.properties,type:u.type,sourceLayerIndex:d,index:c,geometry:l?p.geometry:ia(u),patterns:{},sortKey:f};s.push(m)}n&&s.sort((u,h)=>u.sortKey-h.sortKey);for(let u of s){let{geometry:h,index:c,sourceLayerIndex:d}=u;if(this.hasDependencies){let f=bd("fill",this.layers,u,{zoom:this.zoom},r);this.patternFeatures.push(f)}else this.addFeature(u,h,c,i,{},r.subdivisionGranularity);let p=t[c].feature;r.featureIndex.insert(p,h,c,d,this.index)}}update(t,r,i){this.stateDependentLayers.length&&this.programConfigurations.updatePaintArrays(t,r,this.stateDependentLayers,{imagePositions:i})}addFeatures({options:t,canonical:r,patternPositions:i,patternMap:a}){this.detectSdfPatterns(a);for(let n of this.patternFeatures)this.addFeature(n,n.geometry,n.index,r,i,t.subdivisionGranularity)}detectSdfPatterns(t){for(let r of this.patternFeatures)for(let i in r.patterns){let a=r.patterns[i];this.recordSdfPattern(i,t[a.min]),this.recordSdfPattern(i,t[a.mid]),this.recordSdfPattern(i,t[a.max])}for(let r of this.layers){let i=r.paint.get("fill-pattern").constantOr(null);i&&(this.recordSdfPattern(r.id,t[i.from.toString()]),this.recordSdfPattern(r.id,t[i.to.toString()]))}}recordSdfPattern(t,r){if(!r)return;let i=r.sdf===!0,a=this.sdfPatterns[t];a===void 0?this.sdfPatterns[t]=i:a!==i&&_e(`Style sheet warning: Cannot mix SDF and non-SDF fill patterns in layer "${t}"`)}isEmpty(){return this.layoutVertexArray.length===0}uploadPending(){return!this.uploaded||this.programConfigurations.needsUpload}upload(t){this.uploaded||(this.layoutVertexBuffer=t.createVertexBuffer(this.layoutVertexArray,Hw),this.indexBuffer=t.createIndexBuffer(this.indexArray),this.indexBuffer2=t.createIndexBuffer(this.indexArray2)),this.programConfigurations.upload(t),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(t,r,i,a,n,s){for(let o of El(r,500)){let l=Jy(o,a,s.fill.getGranularityForZoomLevel(a.z)),u=this.layoutVertexArray;e0((h,c)=>{u.emplaceBack(h,c)},this.segments,this.layoutVertexArray,this.indexArray,l.verticesFlattened,l.indicesTriangles,this.segments2,this.indexArray2,l.indicesLineList)}this.programConfigurations.populatePaintArrays(this.layoutVertexArray.length,t,i,{imagePositions:n,canonical:a})}};G("FillBucket",t0,{omit:["layers","patternFeatures"]});let bT;const wT=()=>bT||(bT=new wt({"fill-sort-key":new K(z.layout_fill["fill-sort-key"],"fill-sort-key")}));let TT;const ST=()=>TT||(TT=new wt({"fill-antialias":new N(z.paint_fill["fill-antialias"],"fill-antialias"),"fill-opacity":new K(z.paint_fill["fill-opacity"],"fill-opacity"),"fill-layer-opacity":new N(z.paint_fill["fill-layer-opacity"],"fill-layer-opacity"),"fill-color":new K(z.paint_fill["fill-color"],"fill-color"),"fill-outline-color":new K(z.paint_fill["fill-outline-color"],"fill-outline-color"),"fill-translate":new N(z.paint_fill["fill-translate"],"fill-translate"),"fill-translate-anchor":new N(z.paint_fill["fill-translate-anchor"],"fill-translate-anchor"),"fill-pattern":new Kn(z.paint_fill["fill-pattern"],"fill-pattern")}));var DT={get paint(){return ST()},get layout(){return wT()}};const ET=e=>e.type==="fill";var PT=class extends Ir{constructor(t,r){super(t,DT,r)}recalculate(t,r){super.recalculate(t,r);let i=this.paint._values["fill-outline-color"];i.value.kind==="constant"&&i.value.value===void 0&&(this.paint._values["fill-outline-color"]=this.paint._values["fill-color"])}createBucket(t){return new t0(t)}queryRadius(){return Ol(this.paint.get("fill-translate"))}queryIntersectsFeature({queryGeometry:t,geometry:r,transform:i,pixelsToTileUnits:a}){return $y($l(t,this.paint.get("fill-translate"),this.paint.get("fill-translate-anchor"),-i.bearingInRadians,a),r)}isTileClipped(){return!0}};const AT=Ye([{name:"a_pos",components:2,type:"Int16"},{name:"a_normal_ed",components:4,type:"Int16"}],4),CT=Ye([{name:"a_centroid",components:2,type:"Int16"}],4),IT=AT.members;var Er=class cc{constructor(){this.minX=1/0,this.maxX=-1/0,this.minY=1/0,this.maxY=-1/0}extend(t){return this.minX=Math.min(this.minX,t.x),this.minY=Math.min(this.minY,t.y),this.maxX=Math.max(this.maxX,t.x),this.maxY=Math.max(this.maxY,t.y),this}expandBy(t){return this.minX-=t,this.minY-=t,this.maxX+=t,this.maxY+=t,(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(t){return this.expandBy(-t)}map(t){let r=new cc;return r.extend(t(new M(this.minX,this.minY))),r.extend(t(new M(this.maxX,this.minY))),r.extend(t(new M(this.minX,this.maxY))),r.extend(t(new M(this.maxX,this.maxY))),r}static fromPoints(t){let r=new cc;for(let i of t)r.extend(i);return r}contains(t){return t.x>=this.minX&&t.x<=this.maxX&&t.y>=this.minY&&t.y<=this.maxY}empty(){return this.minX>this.maxX}width(){return this.maxX-this.minX}height(){return this.maxY-this.minY}covers(t){return!this.empty()&&!t.empty()&&t.minX>=this.minX&&t.maxX<=this.maxX&&t.minY>=this.minY&&t.maxY<=this.maxY}intersects(t){return!this.empty()&&!t.empty()&&t.minX<=this.maxX&&t.maxX>=this.minX&&t.minY<=this.maxY&&t.maxY>=this.minY}};const MT=Er.fromPoints([new M(0,0),new M(L,L)]);function dc(e,t){return e.x===t.x&&(e.x<0||e.x>8192)||e.y===t.y&&(e.y<0||e.y>8192)}function zf(e){return e.every(t=>t.x<0)||e.every(t=>t.x>8192)||e.every(t=>t.y<0)||e.every(t=>t.y>8192)}var ys=class{constructor(t,r,i,a,n){for(this.properties=Object.create(null),this.extent=i,this.type=0,this.id=void 0,this._pbf=t,this._geometry=-1,this._keys=a,this._values=n;t.pos<r;){let s=t.readVarint();if(s===8)this.id=t.readVarint();else if(s===18){let o=t.readVarint()+t.pos;for(;t.pos<o;){let l=a[t.readVarint()],u=n[t.readVarint()];this.properties[l]=u}}else s===24?this.type=t.readVarint():(s===34&&(this._geometry=t.pos),t.skip(s))}}loadGeometry(){if(this._geometry<0)throw Error("feature has no geometry");let t=this._pbf;t.pos=this._geometry;let r=t.readVarint()+t.pos,i=[],a,n=1,s=0,o=0,l=0;for(;t.pos<r;){if(s<=0){let u=t.readVarint();if(n=u&7,s=u>>3,s===0)continue}if(s--,n===1)o+=t.readSVarint(),l+=t.readSVarint(),a&&i.push(a),a=[new M(o,l)];else if(n===2)o+=t.readSVarint(),l+=t.readSVarint(),a&&a.push(new M(o,l));else if(n===7)a&&a.push(a[0].clone());else throw Error(`unknown command ${n}`)}return a&&i.push(a),i}bbox(){if(this._geometry<0)throw Error("feature has no geometry");let t=this._pbf;t.pos=this._geometry;let r=t.readVarint()+t.pos,i=1,a=0,n=0,s=0,o=1/0,l=-1/0,u=1/0,h=-1/0;for(;t.pos<r;){if(a<=0){let c=t.readVarint();if(i=c&7,a=c>>3,a===0)continue}if(a--,i===1||i===2)n+=t.readSVarint(),s+=t.readSVarint(),n<o&&(o=n),n>l&&(l=n),s<u&&(u=s),s>h&&(h=s);else if(i!==7)throw Error(`unknown command ${i}`)}return[o,u,l,h]}toGeoJSON(t,r,i){let a=this.extent*2**i,n=this.extent*t,s=this.extent*r,o=this.loadGeometry();function l(d){return[(d.x+n)*360/a-180,360/Math.PI*Math.atan(Math.exp((1-(d.y+s)*2/a)*Math.PI))-90]}function u(d){return d.map(l)}let h;if(this.type===1){let d=[];for(let f of o)d.push(f[0]);let p=u(d);h=d.length===1?{type:"Point",coordinates:p[0]}:{type:"MultiPoint",coordinates:p}}else if(this.type===2){let d=o.map(u);h=d.length===1?{type:"LineString",coordinates:d[0]}:{type:"MultiLineString",coordinates:d}}else if(this.type===3){let d=r0(o),p=[];for(let f of d)p.push(f.map(u));h=p.length===1?{type:"Polygon",coordinates:p[0]}:{type:"MultiPolygon",coordinates:p}}else throw Error("unknown feature type");let c={type:"Feature",geometry:h,properties:this.properties};return this.id!=null&&(c.id=this.id),c}};ys.types=["Unknown","Point","LineString","Polygon"];function r0(e){let t=e.length;if(t<=1)return[e];let r=[],i,a;for(let n=0;n<t;n++){let s=zT(e[n]);s!==0&&(a===void 0&&(a=s<0),a===s<0?(i&&r.push(i),i=[e[n]]):i&&i.push(e[n]))}return i&&r.push(i),r}function zT(e){let t=0;for(let r=0,i=e.length,a=i-1,n,s;r<i;a=r++)n=e[r],s=e[a],t+=(s.x-n.x)*(n.y+s.y);return t}var FT=class{constructor(t,r){for(this.version=1,this.name="",this.extent=4096,this.length=0,this._pbf=t,this._keys=[],this._values=[],this._features=[],r===void 0&&(r=t.length);t.pos<r;){let i=t.readVarint();i===10?this.name=t.readString():i===18?(this._features.push(t.pos),t.skip(i)):i===26?this._keys.push(t.readString()):i===34?this._values.push(RT(t)):i===40?this.extent=t.readVarint():i===120?this.version=t.readVarint():t.skip(i)}this.length=this._features.length}feature(t){if(t<0||t>=this._features.length)throw Error("feature index out of bounds");this._pbf.pos=this._features[t];let r=this._pbf.readVarint()+this._pbf.pos;return new ys(this._pbf,r,this.extent,this._keys,this._values)}};function RT(e){let t=null,r=e.readVarint()+e.pos;for(;e.pos<r;){let i=e.readVarint();t=i===10?e.readString():i===21?e.readFloat():i===25?e.readDouble():i===32?e.readVarint(!0):i===40?e.readVarint():i===48?e.readSVarint():i===56?e.readBoolean():(e.skip(i),null)}if(t==null)throw Error("unknown feature value");return t}var kT=class{constructor(t,r=t.length){let i=Object.create(null);for(;t.pos<r;){let a=t.readVarint();if(a===26){let n=new FT(t,t.readVarint()+t.pos);n.length&&(i[n.name]=n)}else t.skip(a)}this.layers=i}};const Lt=63710088e-1;var ee=class Mn{constructor(t,r){if(isNaN(t)||isNaN(r))throw Error(`Invalid LngLat object: (${t}, ${r})`);if(this.lng=+t,this.lat=+r,this.lat>90||this.lat<-90)throw Error("Invalid LngLat latitude value: must be between -90 and 90")}wrap(){return new Mn(fr(this.lng,-180,180),this.lat)}toArray(){return[this.lng,this.lat]}toString(){return`LngLat(${this.lng}, ${this.lat})`}distanceTo(t){let r=Math.PI/180,i=this.lat*r,a=t.lat*r,n=Math.sin(i)*Math.sin(a)+Math.cos(i)*Math.cos(a)*Math.cos((t.lng-this.lng)*r);return Lt*Math.acos(Math.min(n,1))}static convert(t){if(t instanceof Mn)return t;if(Array.isArray(t)&&(t.length===2||t.length===3))return new Mn(Number(t[0]),Number(t[1]));if(!Array.isArray(t)&&typeof t=="object"&&t)return new Mn(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>]")}};const i0=2*Math.PI*Lt;function a0(e){return i0*Math.cos(e*Math.PI/180)}function Wa(e){return(180+e)/360}function Ha(e){return(180-180/Math.PI*Math.log(Math.tan(Math.PI/4+e*Math.PI/360)))/360}function qi(e,t){return e/a0(t)}function pc(e){return e*360-180}function ns(e){let t=180-e*360;return 360/Math.PI*Math.atan(Math.exp(t*Math.PI/180))-90}function n0(e,t){return e*a0(ns(t))}function LT(e){return 1/Math.cos(e*Math.PI/180)}var Ie=class s0{constructor(t,r,i=0){this.x=+t,this.y=+r,this.z=+i}static fromLngLat(t,r=0){let i=ee.convert(t);return new s0(Wa(i.lng),Ha(i.lat),qi(r,i.lat))}toLngLat(){return new ee(pc(this.x),ns(this.y))}toAltitude(){return n0(this.z,this.y)}meterInMercatorCoordinateUnits(){return 1/i0*LT(ns(this.y))}};const Zi=89.25;function o0(e,t,r){let i=1/(1<<r.z);return new Ie(e/L*i+r.x*i,t/L*i+r.y*i)}function BT(e,t,r){return o0(e,t,r).toLngLat()}function jr(e,t){let r=se(t.lat,-85.051129,Gr);return new M(Wa(t.lng)*e,Ha(r)*e)}function ss(e,t){return new Ie(t.x/e,t.y/e).toLngLat()}function jn(e){return e.cameraToCenterDistance*Math.min(Math.tan(Ge(90-e.pitch))*.85,Math.tan(Ge(Zi-e.pitch)))}function Bu(e,t){let r=e.canonical,i=t/$t(r.z),a=r.x+2**r.z*e.wrap,n=new Float64Array(16);return Pr(n),ot(n,n,[a*i,r.y*i,0]),Et(n,n,[i/L,i/L,1]),n}function l0(e,t,r,i,a){let n=Ie.fromLngLat(e,t),s=a*qi(1,e.lat),{x:o,y:l,z:u}=fc(r,i),h=s*-o,c=s*-l,d=s*u;return new Ie(n.x+h,n.y+c,n.z+d)}function OT(e){let t=qi(1,e.center.lat)*e.worldSize;return l0(e.center,e.elevation,e.pitch,e.bearing,e.cameraToCenterDistance/t)}function fc(e,t){let r=Ge(e),i=Ge(t),a=Math.cos(-r),n=Math.sin(r);return{x:n*Math.sin(i),y:-n*Math.cos(i),z:a}}function $T(e,t){return t<=0||!e||e.length===0?e:e.map(r=>VT(r,t))}function jT(e,t){let r=BT(L/2,L/2,t),i=Ie.fromLngLat(r).meterInMercatorCoordinateUnits(),a=(1<<t.z)*L;return e*i*a}function VT(e,t){if(!e||e.length<3)return e;let r=e[0].x===e[e.length-1].x&&e[0].y===e[e.length-1].y,i=r?e.length-1:e.length;if(i<3)return e;let a=[],n=dc(e[i-1],e[0]);for(let o=0;o<i;o++){let l=e[(o-1+i)%i],u=e[o],h=e[(o+1)%i],c=dc(u,h);n||c?a.push(u.clone()):UT(a,l,u,h,t),n=c}let s=NT(a);return s.length<3?e:(r&&s.push(s[0].clone()),s)}function NT(e){let t=[];for(let r of e){let i=r.round(),a=t[t.length-1];((a==null?void 0:a.x)!==i.x||(a==null?void 0:a.y)!==i.y)&&t.push(i)}for(;t.length>1&&t[0].x===t[t.length-1].x&&t[0].y===t[t.length-1].y;)t.pop();return t}function UT(e,t,r,i,a){let n=t.sub(r),s=i.sub(r),o=n.mag(),l=s.mag();if(o<1e-6||l<1e-6){e.push(r.clone());return}n._div(o),s._div(l);let u=n.x*s.x+n.y*s.y;if(Math.abs(u)>Math.cos(5*Math.PI/180)){e.push(r.clone());return}let h=.2,c=Math.min(a,o*h,l*h),d=r.add(n.mult(c)),p=r.add(s.mult(c)),f=Math.sqrt((1+u)/2),m=r.add(n.add(s)._unit()._mult(c/f)),g=d.sub(m).angleWith(p.sub(m)),_=Math.max(2,Math.ceil(Math.abs(g)/(Math.PI/6)-1e-6));for(let y=0;y<=_;y++)e.push(d.rotateAround(y/_*g,m))}const Ou=8192;function _n(e,t,r,i,a,n,s,o){e.emplaceBack(t,r,Math.floor(i*Ou)*2+s,a*Ou*2,n*Ou*2,Math.round(o))}var u0=class{constructor(t){this.zoom=t.zoom,this.overscaling=t.overscaling,this.layers=t.layers,this.layerIds=this.layers.map(r=>r.id),this.index=t.index,this.hasDependencies=!1,this.layoutVertexArray=new Z2,this.centroidVertexArray=new vi,this.indexArray=new Yr,this.programConfigurations=new Ji(t.layers,t.zoom),this.segments=new Ze,this.stateDependentLayerIds=this.layers.filter(r=>r.isStateDependent()).map(r=>r.id)}populate(t,r,i){this.features=[],this.hasDependencies=el("fill-extrusion",this.layers,r);let a=new ze(this.zoom),n=this.layers[0],s=n.layout.get("fill-extrusion-rounded-corner-distance"),o=s>0?jT(s,i):0,l=n._featureFilter.needGeometry;for(let{feature:u,id:h,index:c,sourceLayerIndex:d}of t){let p=aa(u,l);if(!n._featureFilter.filter(a,p,i))continue;let f={id:h,sourceLayerIndex:d,index:c,geometry:$T(l?p.geometry:ia(u),o),properties:u.properties,type:u.type,patterns:{}};this.hasDependencies?this.features.push(bd("fill-extrusion",this.layers,f,{zoom:this.zoom},r)):this.addFeature(f,f.geometry,c,i,{},r.subdivisionGranularity),r.featureIndex.insert(u,f.geometry,c,d,this.index,!0)}}addFeatures({options:t,canonical:r,patternPositions:i}){for(let a of this.features){let{geometry:n}=a;this.addFeature(a,n,a.index,r,i,t.subdivisionGranularity)}}update(t,r,i){this.stateDependentLayers.length&&this.programConfigurations.updatePaintArrays(t,r,this.stateDependentLayers,{imagePositions:i})}isEmpty(){return this.layoutVertexArray.length===0&&this.centroidVertexArray.length===0}uploadPending(){return!this.uploaded||this.programConfigurations.needsUpload}upload(t){this.uploaded||(this.layoutVertexBuffer=t.createVertexBuffer(this.layoutVertexArray,IT),this.centroidVertexBuffer=t.createVertexBuffer(this.centroidVertexArray,CT.members,!0),this.indexBuffer=t.createIndexBuffer(this.indexArray)),this.programConfigurations.upload(t),this.uploaded=!0}destroy(){this.layoutVertexBuffer&&(this.layoutVertexBuffer.destroy(),this.indexBuffer.destroy(),this.programConfigurations.destroy(),this.segments.destroy(),this.centroidVertexBuffer.destroy())}addFeature(t,r,i,a,n,s){for(let o of El(r,500)){let l={x:0,y:0,sampleCount:0},u=this.layoutVertexArray.length;this.processPolygon(l,a,t,o,s);let h=this.layoutVertexArray.length-u,c=Math.floor(l.x/l.sampleCount),d=Math.floor(l.y/l.sampleCount);for(let p=0;p<h;p++)this.centroidVertexArray.emplaceBack(c,d)}this.programConfigurations.populatePaintArrays(this.layoutVertexArray.length,t,i,{imagePositions:n,canonical:a})}processPolygon(t,r,i,a,n){if(a.length<1||zf(a[0]))return;for(let c of a)c.length!==0&>(t,c);let s={segment:this.segments.prepareSegment(4,this.layoutVertexArray,this.indexArray)},o=n.fill.getGranularityForZoomLevel(r.z),l=ys.types[i.type]==="Polygon";for(let c of a){if(c.length===0||zf(c))continue;let d=$i(c,o,l);this._generateSideFaces(d,s)}if(!l)return;let u=Jy(a,r,o,!1),h=this.layoutVertexArray;e0((c,d)=>{_n(h,c,d,0,0,1,1,0)},this.segments,this.layoutVertexArray,this.indexArray,u.verticesFlattened,u.indicesTriangles)}_generateSideFaces(t,r){let i=0;for(let a=1;a<t.length;a++){let n=t[a],s=t[a-1];if(dc(n,s))continue;r.segment.vertexLength+4>Ze.MAX_VERTEX_ARRAY_LENGTH&&(r.segment=this.segments.prepareSegment(4,this.layoutVertexArray,this.indexArray));let o=n.sub(s)._perp()._unit(),l=s.dist(n);i+l>32768&&(i=0),_n(this.layoutVertexArray,n.x,n.y,o.x,o.y,0,0,i),_n(this.layoutVertexArray,n.x,n.y,o.x,o.y,0,1,i),i+=l,_n(this.layoutVertexArray,s.x,s.y,o.x,o.y,0,0,i),_n(this.layoutVertexArray,s.x,s.y,o.x,o.y,0,1,i);let u=r.segment.vertexLength;this.indexArray.emplaceBack(u,u+2,u+1),this.indexArray.emplaceBack(u+1,u+2,u+3),r.segment.vertexLength+=4,r.segment.primitiveLength+=2}}};function GT(e,t){for(let r=0;r<t.length;r++){let i=t[r];(r!==t.length-1||t[0].x!==i.x||t[0].y!==i.y)&&(e.x+=i.x,e.y+=i.y,e.sampleCount++)}}G("FillExtrusionBucket",u0,{omit:["layers","features"]});let qT;const ZT=()=>qT||(qT=new wt({"fill-extrusion-rounded-corner-distance":new N(z["layout_fill-extrusion"]["fill-extrusion-rounded-corner-distance"],"fill-extrusion-rounded-corner-distance")}));let WT;const HT=()=>WT||(WT=new wt({"fill-extrusion-opacity":new N(z["paint_fill-extrusion"]["fill-extrusion-opacity"],"fill-extrusion-opacity"),"fill-extrusion-color":new K(z["paint_fill-extrusion"]["fill-extrusion-color"],"fill-extrusion-color"),"fill-extrusion-translate":new N(z["paint_fill-extrusion"]["fill-extrusion-translate"],"fill-extrusion-translate"),"fill-extrusion-translate-anchor":new N(z["paint_fill-extrusion"]["fill-extrusion-translate-anchor"],"fill-extrusion-translate-anchor"),"fill-extrusion-pattern":new Kn(z["paint_fill-extrusion"]["fill-extrusion-pattern"],"fill-extrusion-pattern"),"fill-extrusion-height":new K(z["paint_fill-extrusion"]["fill-extrusion-height"],"fill-extrusion-height"),"fill-extrusion-base":new K(z["paint_fill-extrusion"]["fill-extrusion-base"],"fill-extrusion-base"),"fill-extrusion-vertical-gradient":new N(z["paint_fill-extrusion"]["fill-extrusion-vertical-gradient"],"fill-extrusion-vertical-gradient")}));var XT={get paint(){return HT()},get layout(){return ZT()}};const YT=e=>e.type==="fill-extrusion";var KT=class extends Ir{constructor(t,r){super(t,XT,r)}createBucket(t){return new u0(t)}queryRadius(){return Ol(this.paint.get("fill-extrusion-translate"))}is3D(){return!0}queryIntersectsFeature({queryGeometry:t,feature:r,featureState:i,geometry:a,transform:n,pixelsToTileUnits:s,pixelPosMatrix:o}){let l=$l(t,this.paint.get("fill-extrusion-translate"),this.paint.get("fill-extrusion-translate-anchor"),-n.bearingInRadians,s),u=this.paint.get("fill-extrusion-height").evaluate(r,i),h=this.paint.get("fill-extrusion-base").evaluate(r,i),c=eS(l,o,0),d=QT(a,h,u,o),p=d[0],f=d[1];return JT(p,f,c)}};function yn(e,t){return e.x*t.x+e.y*t.y}function Ff(e,t){if(e.length===1){let r=0,i=t[r++],a;for(;!a||i.equals(a);)if(a=t[r++],!a)return 1/0;for(;r<t.length;r++){let n=t[r],s=e[0],o=a.sub(i),l=n.sub(i),u=s.sub(i),h=yn(o,o),c=yn(o,l),d=yn(l,l),p=yn(u,o),f=yn(u,l),m=h*d-c*c,g=(d*p-c*f)/m,_=(h*f-c*p)/m,y=1-g-_,v=i.z*y+a.z*g+n.z*_;if(isFinite(v))return v}return 1/0}{let r=1/0;for(let i of t)r=Math.min(r,i.z);return r}}function JT(e,t,r){let i=1/0;$y(r,t)&&(i=Ff(r,t[0]));for(let a=0;a<t.length;a++){let n=t[a],s=e[a];for(let o=0;o<n.length-1;o++){let l=n[o],u=n[o+1],h=s[o],c=[l,u,s[o+1],h,l];Oy(r,c)&&(i=Math.min(i,Ff(r,c)))}}return i!==1/0&&i}function QT(e,t,r,i){let a=[],n=[],s=i[8]*t,o=i[9]*t,l=i[10]*t,u=i[11]*t,h=i[8]*r,c=i[9]*r,d=i[10]*r,p=i[11]*r;for(let f of e){let m=[],g=[];for(let _ of f){let y=_.x,v=_.y,x=i[0]*y+i[4]*v+i[12],w=i[1]*y+i[5]*v+i[13],b=i[2]*y+i[6]*v+i[14],S=i[3]*y+i[7]*v+i[15],A=x+s,P=w+o,I=b+l,R=S+u,F=x+h,T=w+c,E=b+d,D=S+p,C=new M(A/R,P/R);C.z=I/R,m.push(C);let k=new M(F/D,T/D);k.z=E/D,g.push(k)}a.push(m),n.push(g)}return[a,n]}function eS(e,t,r){let i=[];for(let a of e){let n=[a.x,a.y,r,1];Pt(n,n,t),i.push(new M(n[0]/n[3],n[1]/n[3]))}return i}const tS="geojsonvt_clip_start",rS="geojsonvt_clip_end",iS=Ye([{name:"a_pos_normal",components:2,type:"Int16"},{name:"a_data",components:4,type:"Uint8"}],4),aS=iS.members,nS=Ye([{name:"a_uv_x",components:1,type:"Float32"},{name:"a_split_index",components:1,type:"Float32"}]),sS=nS.members,oS=Math.cos(75/2*(Math.PI/180)),h0=1/2,Rf=2**14/h0;var c0=class{constructor(e){this.zoom=e.zoom,this.overscaling=e.overscaling,this.layers=e.layers,this.layerIds=this.layers.map(t=>t.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 W2,this.layoutVertexArray2=new H2,this.indexArray=new Yr,this.programConfigurations=new Ji(e.layers,e.zoom),this.segments=new Ze,this.maxLineLength=0,this.stateDependentLayerIds=this.layers.filter(t=>t.isStateDependent()).map(t=>t.id)}populate(e,t,r){this.hasDependencies=el("line",this.layers,t)||this.hasLineDasharray(this.layers);let i=this.layers[0].layout.get("line-sort-key"),a=!i.isConstant(),n=[],s=new ze(this.zoom),o=this.layers[0]._featureFilter.needGeometry;for(let{feature:l,id:u,index:h,sourceLayerIndex:c}of e){let d=aa(l,o);if(!this.layers[0]._featureFilter.filter(s,d,r))continue;let p=a?i.evaluate(d,{},r):void 0,f={id:u,properties:l.properties,type:l.type,sourceLayerIndex:c,index:h,geometry:o?d.geometry:ia(l),patterns:{},dashes:{},sortKey:p};n.push(f)}a&&n.sort((l,u)=>l.sortKey-u.sortKey);for(let l of n){let{geometry:u,index:h,sourceLayerIndex:c}=l;this.hasDependencies?(el("line",this.layers,t)?bd("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,u,h,r,{},{},t.subdivisionGranularity);let d=e[h].feature;t.featureIndex.insert(d,u,h,c,this.index)}}update(e,t,r,i){this.stateDependentLayers.length&&this.programConfigurations.updatePaintArrays(e,t,this.stateDependentLayers,{imagePositions:r,dashPositions:i})}addFeatures({options:e,canonical:t,patternPositions:r,dashPositions:i}){for(let a of this.patternFeatures)this.addFeature(a,a.geometry,a.index,t,r,i,e.subdivisionGranularity)}isEmpty(){return this.layoutVertexArray.length===0}uploadPending(){return!this.uploaded||this.programConfigurations.needsUpload}upload(e){this.uploaded||(this.layoutVertexArray2.length!==0&&(this.layoutVertexBuffer2=e.createVertexBuffer(this.layoutVertexArray2,sS)),this.layoutVertexBuffer=e.createVertexBuffer(this.layoutVertexArray,aS),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[tS],end:+e.properties[rS]}}addFeature(e,t,r,i,a,n,s){let o=this.layers[0].layout,l=o.get("line-join").evaluate(e,{}),u=o.get("line-cap").evaluate(e,{}),h=o.get("line-miter-limit").evaluate(e,{}),c=o.get("line-round-limit").evaluate(e,{});this.lineClips=this.lineFeatureClips(e);for(let d of t)this.addLine(d,e,l,u,h,c,i,s);this.programConfigurations.populatePaintArrays(this.layoutVertexArray.length,e,r,{imagePositions:a,dashPositions:n,canonical:i})}addLine(e,t,r,i,a,n,s,o){this.distance=0,this.scaledDistance=0,this.totalDistance=0;let l=s?o.line.getGranularityForZoomLevel(s.z):1;if(e=$i(e,l),this.lineClips){this.lineClipsArray.push(this.lineClips);for(let v=0;v<e.length-1;v++)this.totalDistance+=e[v].dist(e[v+1]);this.updateScaledDistance(),this.maxLineLength=Math.max(this.maxLineLength,this.totalDistance)}let u=ys.types[t.type]==="Polygon",h=e.length;for(;h>=2&&e[h-1].equals(e[h-2]);)h--;let c=0;for(;c<h-1&&e[c].equals(e[c+1]);)c++;if(h-c<(u?3:2))return;r==="bevel"&&(a=1.05);let d=this.overscaling<=16?15*L/(512*this.overscaling):0,p=this.segments.prepareSegment(h*10,this.layoutVertexArray,this.indexArray),f,m,g,_,y;this.e1=this.e2=-1,u&&(f=e[h-2],y=e[c].sub(f)._unit()._perp());for(let v=c;v<h;v++){if(g=v===h-1?u?e[c+1]:void 0:e[v+1],g&&e[v].equals(g))continue;y&&(_=y),f&&(m=f),f=e[v],y=g?g.sub(f)._unit()._perp():_,_||(_=y);let x=_.add(y);(x.x!==0||x.y!==0)&&x._unit();let w=_.x*y.x+_.y*y.y,b=x.x*y.x+x.y*y.y,S=b===0?1/0:1/b,A=2*Math.sqrt(2-2*b),P=b<oS&&m&&g,I=_.x*y.y-_.y*y.x>0;if(P&&v>c){let T=f.dist(m);if(T>2*d){let E=f.sub(f.sub(m)._mult(d/T)._round());this.updateDistance(m,E),this.addCurrentVertex(E,_,0,0,p),m=E}}let R=m&&g,F=R?r:u?"butt":i;if(R&&F==="round"&&(S<n?F="miter":S<=2&&(F="fakeround")),F==="miter"&&S>a&&(F="bevel"),F==="bevel"&&(S>2&&(F="flipbevel"),S<a&&(F="miter")),m&&this.updateDistance(m,f),F==="miter")x._mult(S),this.addCurrentVertex(f,x,0,0,p);else if(F==="flipbevel"){if(S>100)x=y.mult(-1);else{let T=S*_.add(y).mag()/_.sub(y).mag();x._perp()._mult(T*(I?-1:1))}this.addCurrentVertex(f,x,0,0,p),this.addCurrentVertex(f,x.mult(-1),0,0,p)}else if(F==="bevel"||F==="fakeround"){let T=-Math.sqrt(S*S-1),E=I?T:0,D=I?0:T;if(m&&this.addCurrentVertex(f,_,E,D,p),F==="fakeround"){let C=Math.round(A*180/Math.PI/20);for(let k=1;k<C;k++){let B=k/C;if(B!==.5){let W=B-.5,ie=1.0904+w*(-3.2452+w*(3.55645-w*1.43519)),ye=.848013+w*(-1.06021+w*.215638);B+=B*W*(B-1)*(ie*W*W+ye)}let $=y.sub(_)._mult(B)._add(_)._unit()._mult(I?-1:1);this.addHalfVertex(f,$.x,$.y,!1,I,0,p)}}g&&this.addCurrentVertex(f,y,-E,-D,p)}else if(F==="butt")this.addCurrentVertex(f,x,0,0,p);else if(F==="square"){let T=m?1:-1;this.addCurrentVertex(f,x,T,T,p)}else F==="round"&&(m&&(this.addCurrentVertex(f,_,0,0,p),this.addCurrentVertex(f,_,1,1,p,!0)),g&&(this.addCurrentVertex(f,y,-1,-1,p,!0),this.addCurrentVertex(f,y,0,0,p)));if(P&&v<h-1){let T=f.dist(g);if(T>2*d){let E=f.add(g.sub(f)._mult(d/T)._round());this.updateDistance(f,E),this.addCurrentVertex(E,y,0,0,p),f=E}}}}addCurrentVertex(e,t,r,i,a,n=!1){let s=t.x+t.y*r,o=t.y-t.x*r,l=-t.x+t.y*i,u=-t.y-t.x*i;this.addHalfVertex(e,s,o,n,!1,r,a),this.addHalfVertex(e,l,u,n,!0,-i,a),this.distance>Rf/2&&this.totalDistance===0&&(this.distance=0,this.updateScaledDistance(),this.addCurrentVertex(e,t,r,i,a,n))}addHalfVertex({x:e,y:t},r,i,a,n,s,o){let l=(this.lineClips?this.scaledDistance*(Rf-1):this.scaledDistance)*h0;if(this.layoutVertexArray.emplaceBack((e<<1)+ +!!a,(t<<1)+ +!!n,Math.round(63*r)+128,Math.round(63*i)+128,(s===0?0:s<0?-1:1)+1|(l&63)<<2,l>>6),this.lineClips){let h=(this.scaledDistance-this.lineClips.start)/(this.lineClips.end-this.lineClips.start);this.layoutVertexArray2.emplaceBack(h,this.lineClipsArray.length)}let u=o.vertexLength++;this.e1>=0&&this.e2>=0&&(this.indexArray.emplaceBack(this.e1,u,this.e2),o.primitiveLength++),n?this.e2=u:this.e1=u}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 r=t.paint.get("line-dasharray");if(r&&!r.isConstant())return!0}return!1}addLineDashDependencies(e,t,r,i){for(let a of e){let n=a.paint.get("line-dasharray");if(!n||n.value.kind==="constant")continue;let s=a.layout.get("line-cap").evaluate(t,{})==="round",o={dasharray:n.value.evaluate({zoom:r-1},t,{}),round:s},l={dasharray:n.value.evaluate({zoom:r},t,{}),round:s},u={dasharray:n.value.evaluate({zoom:r+1},t,{}),round:s},h=`${o.dasharray.join(",")},${o.round}`,c=`${l.dasharray.join(",")},${l.round}`,d=`${u.dasharray.join(",")},${u.round}`;i.dashDependencies[h]=o,i.dashDependencies[c]=l,i.dashDependencies[d]=u,t.dashes[a.id]={min:h,mid:c,max:d}}}};G("LineBucket",c0,{omit:["layers","patternFeatures"]});let lS;const uS=()=>lS||(lS=new wt({"line-cap":new K(z.layout_line["line-cap"],"line-cap"),"line-join":new K(z.layout_line["line-join"],"line-join"),"line-miter-limit":new K(z.layout_line["line-miter-limit"],"line-miter-limit"),"line-round-limit":new K(z.layout_line["line-round-limit"],"line-round-limit"),"line-sort-key":new K(z.layout_line["line-sort-key"],"line-sort-key")}));let hS;const cS=()=>hS||(hS=new wt({"line-opacity":new K(z.paint_line["line-opacity"],"line-opacity"),"line-layer-opacity":new N(z.paint_line["line-layer-opacity"],"line-layer-opacity"),"line-color":new K(z.paint_line["line-color"],"line-color"),"line-translate":new N(z.paint_line["line-translate"],"line-translate"),"line-translate-anchor":new N(z.paint_line["line-translate-anchor"],"line-translate-anchor"),"line-width":new K(z.paint_line["line-width"],"line-width"),"line-gap-width":new K(z.paint_line["line-gap-width"],"line-gap-width"),"line-offset":new K(z.paint_line["line-offset"],"line-offset"),"line-blur":new K(z.paint_line["line-blur"],"line-blur"),"line-dasharray":new Kn(z.paint_line["line-dasharray"],"line-dasharray"),"line-pattern":new Kn(z.paint_line["line-pattern"],"line-pattern"),"line-gradient":new Ll(z.paint_line["line-gradient"],"line-gradient")}));var kf={get paint(){return cS()},get layout(){return uS()}},dS=class extends K{possiblyEvaluate(e,t){return t=new ze(Math.floor(t.zoom),{now:t.now,fadeDuration:t.fadeDuration,zoomHistory:t.zoomHistory,transition:t.transition}),super.possiblyEvaluate(e,t)}evaluate(e,t,r,i){return t=H({},t,{zoom:Math.floor(t.zoom)}),super.evaluate(e,t,r,i)}};let Js;const pS=e=>e.type==="line";var fS=class extends Ir{constructor(e,t){super(e,kf,t),this.gradientVersion=0,Js||(Js=new dS(kf.paint.properties["line-width"].specification,"line-floorwidth"),Js.useIntegerZoom=!0)}_handleSpecialPaintPropertyUpdate(e){if(e==="line-gradient"){let t=this.gradientExpression();this.stepInterpolant=a2(t)?t._styleExpression.expression instanceof Kc:!1,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"]=Js.possiblyEvaluate(this._transitioningPaint._values["line-width"].value,e)}createBucket(e){return new c0(e)}queryRadius(e){let t=e,r=Lf(za("line-width",this,t),za("line-gap-width",this,t)),i=za("line-offset",this,t);return r/2+Math.abs(i)+Ol(this.paint.get("line-translate"))}queryIntersectsFeature({queryGeometry:e,feature:t,featureState:r,geometry:i,transform:a,pixelsToTileUnits:n}){let s=$l(e,this.paint.get("line-translate"),this.paint.get("line-translate-anchor"),-a.bearingInRadians,n),o=n/2*Lf(this.paint.get("line-width").evaluate(t,r),this.paint.get("line-gap-width").evaluate(t,r)),l=this.paint.get("line-offset").evaluate(t,r);return l&&(i=yw(i,l*n)),dw(s,i,o)}isTileClipped(){return!0}};function Lf(e,t){return t>0?t+2*e:e}const mS=Ye([{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),gS=Ye([{name:"a_projected_pos",components:3,type:"Float32"}],4);Ye([{name:"a_fade_opacity",components:1,type:"Uint32"}],4);const _S=Ye([{name:"a_placed",components:2,type:"Uint8"},{name:"a_shift",components:2,type:"Float32"},{name:"a_box_real",components:2,type:"Int16"}]);Ye([{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"}]);const Bf=Ye([{name:"a_pos",components:2,type:"Int16"},{name:"a_anchor_pos",components:2,type:"Int16"},{name:"a_extrude",components:2,type:"Int16"}],4),yS=Ye([{name:"a_pos",components:2,type:"Float32"},{name:"a_radius",components:1,type:"Float32"},{name:"a_flags",components:2,type:"Int16"}],4);Ye([{name:"triangle",components:3,type:"Uint16"}]),Ye([{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"}]),Ye([{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"}]),Ye([{type:"Float32",name:"offsetX"}]),Ye([{type:"Int16",name:"x"},{type:"Int16",name:"y"},{type:"Int16",name:"tileUnitDistanceFromAnchor"}]),Ye([{type:"Uint16",name:"textAnchor"},{type:"Float32",components:2,name:"textOffset"}]);const il=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(il.isParsed())throw Error("RTL text plugin already registered.");this.applyArabicShaping=e.applyArabicShaping,this.processBidirectionalText=e.processBidirectionalText,this.processStyledBidirectionalText=e.processStyledBidirectionalText,this.loadScriptResolve()}isParsed(){return this.applyArabicShaping!=null&&this.processBidirectionalText!=null&&this.processStyledBidirectionalText!=null}getRTLTextPluginStatus(){return this.pluginStatus}async syncState(e,t){if(this.isParsed())return this.getState();if(e.pluginStatus!=="loading")return this.setState(e),e;let r=e.pluginURL,i=new Promise(n=>{this.loadScriptResolve=n}),a=new Promise(n=>setTimeout(()=>n(),this.TIMEOUT));if(await t(r),await Promise.race([i,a]),this.isParsed()){let n={pluginStatus:"loaded",pluginURL:r};return this.setState(n),n}throw this.setState({pluginStatus:"error",pluginURL:""}),Error(`RTL Text Plugin failed to import scripts from ${r}`)}};function xS(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))}function vS(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))}function bS(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))}function wS(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 jl(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 TS(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))}function SS(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)}function Of(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 DS(e,t){return/(?:[\u1039\u17D2\u1A60\u1BAB\u200D\uAAF6]|\uD802\uDE3F|\uD804[\uDD33\uDFD0]|\uD806[\uDD3E\uDE47\uDE99]|\uD807[\uDD45\uDD97\uDF42])$/.test(e)||new RegExp("^\\p{gc=Mc}","u").test(t)}const ES={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"},PS={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]},AS={لآ:[65269,65270],لأ:[65271,65272],لإ:[65273,65274],لا:[65275,65276]},$f=1604,CS=/[\u0600-\u06ff\u0750-\u077f\u0870-\u089f\u08a0-\u08ff\ufb50-\ufdff\ufe70-\ufeff]/;function IS(e,t,r){let i=0;for(let a of e.split(";")){let[n,s]=a.split(",").map(l=>parseInt(l,36)),o=i+n;for(let l=o;l<o+s;l++)r.set(l,t);i=o+s}}const d0=new Map;for(let[e,t]of Object.entries(ES))IS(t,e,d0);function MS(e){return d0.get(e)??"U"}function zS(e){return e==="D"||e==="L"||e==="C"}function FS(e){return e==="D"||e==="R"||e==="C"}function RS(e,t,r){return e==="D"?t&&r?3:t?1:r?2:0:e==="R"?+!!t:e==="L"?r?2:0:null}function kS(e){return[...e].map(t=>{let r=t.codePointAt(0);return{codePoint:r,type:MS(r),form:null}})}function LS(e){let t=e.filter(r=>r.type!=="T");for(let r=0;r<t.length;r++){let i=t[r],a=r>0&&zS(t[r-1].type),n=r+1<t.length&&FS(t[r+1].type);i.form=RS(i.type,a,n)}}function BS(e){let t=!1;for(let r of e)r.type==="T"?r.form=t?3:0:t=r.form===2||r.form===3}function OS(e){let t=[];for(let r=0;r<e.length;r++){let i=e[r];if(i.codePoint!==$f){t.push(i);continue}let a=r+1;for(;a<e.length&&e[a].type==="T";)a++;let n=e[a],s=n&&AS[String.fromCodePoint($f,n.codePoint)];if(!s){t.push(i);continue}let o=i.form===3||i.form===1;t.push({codePoint:s[+!!o],type:"R",form:0}),t.push(...e.slice(r+1,a)),r=a}return t}function $S(e){if(e.form===null)return e.codePoint;let t=PS[e.codePoint];return t&&(t[e.form]||t[0])||e.codePoint}function jS(e){if(!CS.test(e))return e;let t=kS(e);return LS(t),BS(t),OS(t).map(r=>String.fromCodePoint($S(r))).join("")}function VS(e,t,r){let i=t.layout.get("text-transform").evaluate(r,{});return i==="uppercase"?e=e.toLocaleUpperCase():i==="lowercase"&&(e=e.toLocaleLowerCase()),(il.applyArabicShaping??jS)(e)}function NS(e,t,r){for(let i of e.sections)i.text=VS(i.text,t,r);return e}function $u(e,t,r){let i=r?t.last.points:t.first.points,a=r?i[i.length-1]:i[0];return`${e}:${a.x}:${a.y}`}function US(e){let t=e.first.points,r=t.length;for(let n=e.first.next;n;n=n.next)r+=n.points.length-1;let i=Array(r);for(let n=0;n<t.length;n++)i[n]=t[n];let a=t.length;for(let n=e.first.next;n;n=n.next){let s=n.points;for(let o=1;o<s.length;o++)i[a++]=s[o]}return i}function jf(e,t,r,i,a){let n=t[r];delete t[r],t[i]=n;let s=e[n];return s.last.next=a.first,s.last=a.last,n}function Vf(e,t,r,i,a){let n=t[i];delete t[i],t[r]=n;let s=e[n];return a.last.next=s.first,s.first=a.first,n}function GS(e){let t={},r={},i=[];for(let n of e){let s=n.text?n.text.toString():null,o={points:n.geometry[0],next:null},l={feature:n,first:o,last:o};if(!s){i.push(l);continue}let u=$u(s,l),h=$u(s,l,!0);if(u in r&&h in t&&r[u]!==t[h]){let c=Vf(i,t,u,h,l),d=jf(i,r,u,h,i[c]);delete t[u],delete r[h],r[$u(s,i[d],!0)]=d,i[c].feature.geometry=null}else if(u in r)jf(i,r,u,h,l);else if(h in t)Vf(i,t,u,h,l);else{let c=i.push(l)-1;t[u]=c,r[h]=c}}let a=[];for(let n of i){let s=n.feature;s.geometry&&(n.first.next&&(s.geometry[0]=US(n)),a.push(s))}return a}const p0=typeof Intl<"u"&&"Segmenter"in Intl;let Nf,Uf;function mc(e){if(!p0||!SS(e))return[...e];Nf??(Nf=new Intl.Segmenter(void 0,{granularity:"grapheme"}));let t=[];for(let{segment:r}of Nf.segment(e)){let i=t.length-1;i>=0&&DS(t[i],r)?t[i]+=r:t.push(r)}return t}function qS(e){let t=new Set;if(p0){Uf??(Uf=new Intl.Segmenter(void 0,{granularity:"word"}));for(let{index:i}of Uf.segment(e))t.add(i);return t}let r=0;for(let i of e.split(new RegExp("\\b|(?=\\p{Ideo})","u")))t.add(r),r+=i.length;return t}function al(e){let t=e.codePointAt(0);return e.length>(t>65535?2:1)}function Td(e){return/\s/u.test(String.fromCodePoint(e))}function gc(e){for(let t of e)if(jl(t.codePointAt(0)))return!0;return!1}function ZS(e){for(let t of e)if(!WS(t.codePointAt(0)))return!1;return!0}function WS(e){return!xS(e)}function Gf(e){return!(jl(e)||TS(e))}function f0(e){return new RegExp("\\p{sc=Arab}","u").test(String.fromCodePoint(e))}function m0(e){return vS(e)}function g0(e){for(let t of e)if(m0(t.codePointAt(0)))return!0;return!1}const Aa={"!":"︕","#":"#",$:"$","%":"%","&":"&","(":"︵",")":"︶","*":"*","+":"+",",":"︐","-":"︲",".":"・","/":"/",":":"︓",";":"︔","<":"︿","=":"=",">":"﹀","?":"︖","@":"@","[":"﹇","\\":"\","]":"﹈","^":"^",_:"︳","`":"`","{":"︷","|":"―","}":"︸","~":"~","¢":"¢","£":"£","¥":"¥","¦":"¦","¬":"¬","¯":" ̄","–":"︲","—":"︱","‘":"﹃","’":"﹄","“":"﹁","”":"﹂","…":"︙","⋯":"︙","‧":"・","₩":"₩","、":"︑","。":"︒","〈":"︿","〉":"﹀","《":"︽","》":"︾","「":"﹁","」":"﹂","『":"﹃","』":"﹄","【":"︻","】":"︼","〔":"︹","〕":"︺","〖":"︗","〗":"︘","!":"︕","(":"︵",")":"︶",",":"︐","-":"︲",".":"・",":":"︓",";":"︔","<":"︿",">":"﹀","?":"︖","[":"﹇","]":"﹈","_":"︳","{":"︷","|":"―","}":"︸","⦅":"︵","⦆":"︶","。":"︒","「":"﹁","」":"﹂"};function HS(e){let t="",r={premature:!0,value:void 0},i=e[Symbol.iterator](),a=i.next(),n=e[Symbol.iterator]();n.next();let s=n.next();for(;!a.done;)(s.done||!Gf(s.value.codePointAt(0))||Aa[s.value])&&(r.premature||!Gf(r.value.codePointAt(0))||Aa[r.value])&&Aa[a.value]?t+=Aa[a.value]:t+=a.value,r={value:a.value,premature:!1},a=i.next(),s=n.next();return t}const XS={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},YS={40:!0};function qf(e,t,r,i,a,n){var s;if("fontStack"in t){let o=(s=r[t.fontStack])==null?void 0:s.default,l=o==null?void 0:o[e];if(l)return l.metrics.advance*t.scale+a;let u=0;for(let h of e){let c=o==null?void 0:o[h];c&&(u+=c.metrics.advance*t.scale+a)}return u}{let o=i[t.imageName];return o?o.displaySize[0]*t.scale*24/n+a:0}}function Zf(e,t,r,i){let a=(e-t)**2;return i?e<t?a/2:a*2:a+Math.abs(r)*r}function Wf(e){return/^\s+$/u.test(e)}function KS(e,t,r){let i=0;return(e===10||e===13)&&(i-=1e4),r&&(i+=150),(e===40||e===65288)&&(i+=50),(t===41||t===65289)&&(i+=50),i}function Hf(e,t,r,i,a,n){let s=null,o=Zf(t,r,a,n);for(let l of i){let u=Zf(t-l.x,r,a,n)+l.badness;u<=o&&(s=l,o=u)}return{index:e,x:t,priorBreak:s,badness:o}}function _0(e){return e?_0(e.priorBreak).concat(e.index):[]}var Sd=class _c{constructor(t="",r=[],i=[]){this.text=t,this.sections=r,this.sectionIndex=i,this.imageSectionID=null,this._graphemes=null}graphemes(){return this._graphemes??(this._graphemes=mc(this.text)),this._graphemes}static fromFeature(t,r){let i=new _c;for(let a of t.sections)a.image?i.addImageSection(a):i.addTextSection(a,r);return i}length(){return this.graphemes().length}getSection(t){return this.sections[this.sectionIndex[t]]}getSectionIndex(t){return this.sectionIndex[t]}verticalizePunctuation(){this.text=HS(this.text),this._graphemes=null}hasZeroWidthSpaces(){return this.text.includes("")}trim(){let t=this.graphemes(),r=0;for(;r<t.length&&Wf(t[r]);)r++;let i=t.length;for(;i>r&&Wf(t[i-1]);)i--;this.text=t.slice(r,i).join(""),this.sectionIndex=this.sectionIndex.slice(r,i),this._graphemes=null}substring(t,r){let i=this.graphemes().slice(t,r).join(""),a=this.sectionIndex.slice(t,r);return new _c(i,this.sections,a)}toCodeUnitIndex(t){return this.graphemes().slice(0,t).join("").length}toString(){return this.text}getMaxScale(){return this.sectionIndex.reduce((t,r)=>Math.max(t,this.sections[r].scale),0)}getMaxImageSize(t){let r=0,i=0;for(let a=0;a<this.length();a++){let n=this.getSection(a);if("imageName"in n){let s=t[n.imageName];if(!s)continue;let o=s.displaySize;r=Math.max(r,o[0]),i=Math.max(i,o[1])}}return{maxImageWidth:r,maxImageHeight:i}}_appendSection(t,r){let i=this.graphemes(),a=i.length>0?i[i.length-1]:"",n=mc(a+t);this.text+=t,this._graphemes=i.slice(0,a?-1:void 0).concat(n);let s=n.length-+!!a;for(let o=0;o<s;o++)this.sectionIndex.push(r)}addTextSection(t,r){this.sections.push({scale:t.scale||1,verticalAlign:t.verticalAlign||"bottom",fontStack:t.fontStack||r}),this._appendSection(t.text,this.sections.length-1)}addImageSection(t){let r=t.image?t.image.name:"";if(r.length===0){_e("Can't add FormattedSection with an empty image.");return}let i=this.getNextImageSectionCharCode();if(!i){_e("Reached maximum number of images 6401");return}this.sections.push({scale:1,verticalAlign:t.verticalAlign||"bottom",imageName:r}),this._appendSection(String.fromCharCode(i),this.sections.length-1)}getNextImageSectionCharCode(){return this.imageSectionID?this.imageSectionID>=63743?null:++this.imageSectionID:(this.imageSectionID=57344,this.imageSectionID)}determineLineBreaks(t,r,i,a,n){let s=[],o=this.determineAverageLineWidth(t,r,i,a,n),l=this.hasZeroWidthSpaces(),u=this.graphemes(),h=null,c=0,d=0;for(let p=0;p<u.length;p++){let f=u[p];if(p>0){let m=u[p-1].codePointAt(0),g=f.codePointAt(0),_=wS(m),y=Of(m)&&Of(g);(XS[m]||_||"imageName"in this.getSection(p-1)||u[p+1]!==void 0&&YS[g]||y&&(h??(h=qS(this.text))).has(d))&&s.push(Hf(p,c,o,s,KS(m,g,_&&l),!1))}Td(f.codePointAt(0))||(c+=qf(f,this.getSection(p),i,a,t,n)),d+=f.length}return _0(Hf(this.length(),c,o,s,0,!0))}determineAverageLineWidth(t,r,i,a,n){let s=0,o=0;for(let u of this.graphemes()){let h=this.getSection(o);s+=qf(u,h,i,a,t,n),o++}let l=Math.max(1,Math.ceil(s/r));return s/l}};function JS(){return(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"},r={},i={};r.L=1,i[1]="L",Object.keys(t).forEach(function(Z,ge){r[Z]=1<<ge+1,i[r[Z]]=Z}),Object.freeze(r);var a=r.LRI|r.RLI|r.FSI,n=r.L|r.R|r.AL,s=r.B|r.S|r.WS|r.ON|r.FSI|r.LRI|r.RLI|r.PDI,o=r.BN|r.RLE|r.LRE|r.RLO|r.LRO|r.PDF,l=r.S|r.WS|r.B|a|r.PDI|o,u=null;function h(){if(!u){u=new Map;var Z=0;for(var ge in t)if(t.hasOwnProperty(ge))for(var re=t[ge],j="",xe=void 0,Q=!1,ae=0,q=0;q<=re.length+1;q+=1){var we=re[q];if(we!==","&&q!==re.length)we==="+"?(Q=!0,ae=Z=ae+parseInt(j,36),j=""):j+=we;else{Q?xe=Z+parseInt(j,36):(ae=Z=ae+parseInt(j,36),xe=Z),Q=!1,j="",ae=xe;for(var Te=Z;Te<xe+1;Te+=1)u.set(Te,r[ge])}}}}function c(Z){return h(),u.get(Z.codePointAt(0))||r.L}function d(Z){return i[c(Z)]}var p={pairs:"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",canonical:"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 f(Z,ge){var re=0,j=new Map,xe=ge&&new Map,Q;return Z.split(",").forEach(function ae(q){if(q.indexOf("+")!==-1)for(var we=+q;we--;)ae(Q);else{Q=q;var Te=q.split(">"),ne=Te[0],Qe=Te[1];ne=String.fromCodePoint(re+=parseInt(ne,36)),Qe=String.fromCodePoint(re+=parseInt(Qe,36)),j.set(ne,Qe),ge&&xe.set(Qe,ne)}}),{map:j,reverseMap:xe}}var m,g,_;function y(){if(!m){var Z=f(p.pairs,!0),ge=Z.map,re=Z.reverseMap;m=ge,g=re,_=f(p.canonical,!1).map}}function v(Z){return y(),m.get(Z)||null}function x(Z){return y(),g.get(Z)||null}function w(Z){return y(),_.get(Z)||null}var b=r.L,S=r.R,A=r.EN,P=r.ES,I=r.ET,R=r.AN,F=r.CS,T=r.B,E=r.S,D=r.ON,C=r.BN,k=r.NSM,B=r.AL,$=r.LRO,W=r.RLO,ie=r.LRE,ye=r.RLE,ce=r.PDF,ke=r.LRI,ve=r.RLI,Ue=r.FSI,Ee=r.PDI;function pt(Z,ge){for(var re=125,j=new Uint32Array(Z.length),xe=0;xe<Z.length;xe++)j[xe]=c(Z[xe]);var Q=new Map;function ae(Gt,br){var qt=j[Gt];j[Gt]=br,Q.set(qt,Q.get(qt)-1),qt&s&&Q.set(s,Q.get(s)-1),Q.set(br,(Q.get(br)||0)+1),br&s&&Q.set(s,(Q.get(s)||0)+1)}for(var q=new Uint8Array(Z.length),we=new Map,Te=[],ne=null,Qe=0;Qe<Z.length;Qe++)ne||Te.push(ne={start:Qe,end:Z.length-1,level:ge==="rtl"?1:ge==="ltr"?0:Mp(Qe,!1)}),j[Qe]&T&&(ne.end=Qe,ne=null);for(var Ci=ye|ie|W|$|a|Ee|ce|T,Kr=function(Gt){return Gt+(Gt&1?1:2)},Mr=function(Gt){return Gt+(Gt&1?2:1)},zr=0;zr<Te.length;zr++){ne=Te[zr];var Oe=[{_level:ne.level,_override:0,_isolate:0}],Le=void 0,or=0,vr=0,la=0;Q.clear();for(var st=ne.start;st<=ne.end;st++){var ht=j[st];if(Le=Oe[Oe.length-1],Q.set(ht,(Q.get(ht)||0)+1),ht&s&&Q.set(s,(Q.get(s)||0)+1),ht&Ci)if(ht&(ye|ie)){q[st]=Le._level;var ua=(ht===ye?Mr:Kr)(Le._level);ua<=re&&!or&&!vr?Oe.push({_level:ua,_override:0,_isolate:0}):or||vr++}else if(ht&(W|$)){q[st]=Le._level;var sp=(ht===W?Mr:Kr)(Le._level);sp<=re&&!or&&!vr?Oe.push({_level:sp,_override:ht&W?S:b,_isolate:0}):or||vr++}else if(ht&a){ht&Ue&&(ht=Mp(st+1,!0)===1?ve:ke),q[st]=Le._level,Le._override&&ae(st,Le._override);var op=(ht===ve?Mr:Kr)(Le._level);op<=re&&or===0&&vr===0?(la++,Oe.push({_level:op,_override:0,_isolate:1,_isolInitIndex:st})):or++}else if(ht&Ee){if(or>0)or--;else if(la>0){for(vr=0;!Oe[Oe.length-1]._isolate;)Oe.pop();var Kl=Oe[Oe.length-1]._isolInitIndex;Kl!=null&&(we.set(Kl,st),we.set(st,Kl)),Oe.pop(),la--}Le=Oe[Oe.length-1],q[st]=Le._level,Le._override&&ae(st,Le._override)}else ht&ce?(or===0&&(vr>0?vr--:!Le._isolate&&Oe.length>1&&(Oe.pop(),Le=Oe[Oe.length-1])),q[st]=Le._level):ht&T&&(q[st]=ne.level);else q[st]=Le._level,Le._override&&ht!==C&&ae(st,Le._override)}for(var ha=[],Fr=null,Ii=ne.start;Ii<=ne.end;Ii++){var Jl=j[Ii];if(!(Jl&o)){var lp=q[Ii],up=Jl&a,Sx=Jl===Ee;Fr&&lp===Fr._level?(Fr._end=Ii,Fr._endsWithIsolInit=up):ha.push(Fr={_start:Ii,_end:Ii,_level:lp,_startsWithPDI:Sx,_endsWithIsolInit:up})}}for(var Ql=[],Ss=0;Ss<ha.length;Ss++){var Ds=ha[Ss];if(!Ds._startsWithPDI||Ds._startsWithPDI&&!we.has(Ds._start)){for(var eu=[Fr=Ds],hp=void 0;Fr&&Fr._endsWithIsolInit&&(hp=we.get(Fr._end))!=null;)for(var Es=Ss+1;Es<ha.length;Es++)if(ha[Es]._start===hp){eu.push(Fr=ha[Es]);break}for(var ca=[],tu=0;tu<eu.length;tu++)for(var cp=eu[tu],ru=cp._start;ru<=cp._end;ru++)ca.push(ru);for(var Dx=q[ca[0]],dp=ne.level,Ps=ca[0]-1;Ps>=0;Ps--)if(!(j[Ps]&o)){dp=q[Ps];break}var iu=ca[ca.length-1],Ex=q[iu],pp=ne.level;if(!(j[iu]&a)){for(var As=iu+1;As<=ne.end;As++)if(!(j[As]&o)){pp=q[As];break}}Ql.push({_seqIndices:ca,_sosType:Math.max(dp,Dx)%2?S:b,_eosType:Math.max(pp,Ex)%2?S:b})}}for(var au=0;au<Ql.length;au++){var nu=Ql[au],te=nu._seqIndices,tn=nu._sosType,Px=nu._eosType,da=q[te[0]]&1?S:b;if(Q.get(k))for(var Cs=0;Cs<te.length;Cs++){var fp=te[Cs];if(j[fp]&k){for(var su=tn,Is=Cs-1;Is>=0;Is--)if(!(j[te[Is]]&o)){su=j[te[Is]];break}ae(fp,su&(a|Ee)?D:su)}}if(Q.get(A))for(var Ms=0;Ms<te.length;Ms++){var mp=te[Ms];if(j[mp]&A)for(var zs=Ms-1;zs>=-1;zs--){var gp=zs===-1?tn:j[te[zs]];if(gp&n){gp===B&&ae(mp,R);break}}}if(Q.get(B))for(var ou=0;ou<te.length;ou++){var _p=te[ou];j[_p]&B&&ae(_p,S)}if(Q.get(P)||Q.get(F))for(var rn=1;rn<te.length-1;rn++){var lu=te[rn];if(j[lu]&(P|F)){for(var pa=0,uu=0,hu=rn-1;hu>=0&&(pa=j[te[hu]],pa&o);hu--);for(var cu=rn+1;cu<te.length&&(uu=j[te[cu]],uu&o);cu++);pa===uu&&(j[lu]===P?pa===A:pa&(A|R))&&ae(lu,pa)}}if(Q.get(A)){for(var Rr=0;Rr<te.length;Rr++)if(j[te[Rr]]&A){for(var Fs=Rr-1;Fs>=0&&j[te[Fs]]&(I|o);Fs--)ae(te[Fs],A);for(Rr++;Rr<te.length&&j[te[Rr]]&(I|o|A);Rr++)j[te[Rr]]!==A&&ae(te[Rr],A)}}if(Q.get(I)||Q.get(P)||Q.get(F))for(var an=0;an<te.length;an++){var yp=te[an];if(j[yp]&(I|P|F)){ae(yp,D);for(var Rs=an-1;Rs>=0&&j[te[Rs]]&o;Rs--)ae(te[Rs],D);for(var ks=an+1;ks<te.length&&j[te[ks]]&o;ks++)ae(te[ks],D)}}if(Q.get(A))for(var du=0,xp=tn;du<te.length;du++){var vp=te[du],pu=j[vp];pu&A?xp===b&&ae(vp,b):pu&n&&(xp=pu)}if(Q.get(s)){for(var nn=S|A|R,bp=nn|b,Ls=[],fa=[],ma=0;ma<te.length;ma++)if(j[te[ma]]&s){var sn=Z[te[ma]],wp=void 0;if(v(sn)!==null)if(fa.length<63)fa.push({char:sn,seqIndex:ma});else break;else if((wp=x(sn))!==null)for(var on=fa.length-1;on>=0;on--){var fu=fa[on].char;if(fu===wp||fu===x(w(sn))||v(w(fu))===sn){Ls.push([fa[on].seqIndex,ma]),fa.length=on;break}}}Ls.sort(function(Gt,br){return Gt[0]-br[0]});for(var mu=0;mu<Ls.length;mu++){for(var Tp=Ls[mu],Bs=Tp[0],gu=Tp[1],Sp=!1,kr=0,_u=Bs+1;_u<gu;_u++){var Dp=te[_u];if(j[Dp]&bp){Sp=!0;var Ep=j[Dp]&nn?S:b;if(Ep===da){kr=Ep;break}}}if(Sp&&!kr){kr=tn;for(var yu=Bs-1;yu>=0;yu--){var Pp=te[yu];if(j[Pp]&bp){var Ap=j[Pp]&nn?S:b;kr=Ap===da?da:Ap;break}}}if(kr){if(j[te[Bs]]=j[te[gu]]=kr,kr!==da){for(var ln=Bs+1;ln<te.length;ln++)if(!(j[te[ln]]&o)){c(Z[te[ln]])&k&&(j[te[ln]]=kr);break}}if(kr!==da){for(var un=gu+1;un<te.length;un++)if(!(j[te[un]]&o)){c(Z[te[un]])&k&&(j[te[un]]=kr);break}}}}for(var di=0;di<te.length;di++)if(j[te[di]]&s){for(var Cp=di,xu=di,vu=tn,hn=di-1;hn>=0;hn--)if(j[te[hn]]&o)Cp=hn;else{vu=j[te[hn]]&nn?S:b;break}for(var Ip=Px,cn=di+1;cn<te.length;cn++)if(j[te[cn]]&(s|o))xu=cn;else{Ip=j[te[cn]]&nn?S:b;break}for(var bu=Cp;bu<=xu;bu++)j[te[bu]]=vu===Ip?vu:da;di=xu}}}for(var Kt=ne.start;Kt<=ne.end;Kt++){var Ax=q[Kt],Os=j[Kt];if(Ax&1?Os&(b|A|R)&&q[Kt]++:Os&S?q[Kt]++:Os&(R|A)&&(q[Kt]+=2),Os&o&&(q[Kt]=Kt===0?ne.level:q[Kt-1]),Kt===ne.end||c(Z[Kt])&(E|T))for(var $s=Kt;$s>=0&&c(Z[$s])&l;$s--)q[$s]=ne.level}}return{levels:q,paragraphs:Te};function Mp(Gt,br){for(var qt=Gt;qt<Z.length;qt++){var pi=j[qt];if(pi&(S|B))return 1;if(pi&(T|b)||br&&pi===Ee)return 0;if(pi&a){var zp=Cx(qt);qt=zp===-1?Z.length:zp}}return 0}function Cx(Gt){for(var br=1,qt=Gt+1;qt<Z.length;qt++){var pi=j[qt];if(pi&T)break;if(pi&Ee){if(--br===0)return qt}else pi&a&&br++}return-1}}var yt="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",Nt;function Ut(){if(!Nt){var Z=f(yt,!0),ge=Z.map;Z.reverseMap.forEach(function(re,j){ge.set(j,re)}),Nt=ge}}function Tt(Z){return Ut(),Nt.get(Z)||null}function nt(Z,ge,re,j){var xe=Z.length;re=Math.max(0,re==null?0:+re),j=Math.min(xe-1,j==null?xe-1:+j);for(var Q=new Map,ae=re;ae<=j;ae++)if(ge[ae]&1){var q=Tt(Z[ae]);q!==null&&Q.set(ae,q)}return Q}function Yt(Z,ge,re,j){var xe=Z.length;re=Math.max(0,re==null?0:+re),j=Math.min(xe-1,j==null?xe-1:+j);var Q=[];return ge.paragraphs.forEach(function(ae){var q=Math.max(re,ae.start),we=Math.min(j,ae.end);if(q<we){for(var Te=ge.levels.slice(q,we+1),ne=we;ne>=q&&c(Z[ne])&l;ne--)Te[ne]=ae.level;for(var Qe=ae.level,Ci=1/0,Kr=0;Kr<Te.length;Kr++){var Mr=Te[Kr];Mr>Qe&&(Qe=Mr),Mr<Ci&&(Ci=Mr|1)}for(var zr=Qe;zr>=Ci;zr--)for(var Oe=0;Oe<Te.length;Oe++)if(Te[Oe]>=zr){for(var Le=Oe;Oe+1<Te.length&&Te[Oe+1]>=zr;)Oe++;Oe>Le&&Q.push([Le+q,Oe+q])}}}),Q}function xr(Z,ge,re,j){var xe=sr(Z,ge,re,j),Q=[].concat(Z);return xe.forEach(function(ae,q){Q[q]=(ge.levels[ae]&1?Tt(Z[ae]):null)||Z[ae]}),Q.join("")}function sr(Z,ge,re,j){for(var xe=Yt(Z,ge,re,j),Q=[],ae=0;ae<Z.length;ae++)Q[ae]=ae;return xe.forEach(function(q){for(var we=q[0],Te=q[1],ne=Q.slice(we,Te+1),Qe=ne.length;Qe--;)Q[Te-Qe]=ne[Qe]}),Q}return e.closingToOpeningBracket=x,e.getBidiCharType=c,e.getBidiCharTypeName=d,e.getCanonicalBracket=w,e.getEmbeddingLevels=pt,e.getMirroredCharacter=Tt,e.getMirroredCharactersMap=nt,e.getReorderSegments=Yt,e.getReorderedIndices=sr,e.getReorderedString=xr,e.openingToClosingBracket=v,Object.defineProperty(e,"__esModule",{value:!0}),e})({})}const Dd=JS(),QS=/[\u061c\u200e\u200f\u202a-\u202e\u2066-\u2069]/,eD=new Set(["WS","FSI","LRI","RLI","PDI"]),tD=new Set(["S","B"]);function rD(e,t,r,i){let a=[],n=r;for(let s of mc(e.slice(r,i)))a.push({index:n,text:s,level:t[n]}),n+=s.length;return a}function iD(e,t){let r=!0;for(let i=e.length-1;i>=0;i--){let a=Dd.getBidiCharTypeName(e[i].text[0]);tD.has(a)?(e[i].level=t,r=!0):r&&eD.has(a)?e[i].level=t:r=!1}}function aD(e,t){let r=t,i=1/0;for(let{level:n}of e)n>r&&(r=n),(n|1)<i&&(i=n|1);let a=e.slice();for(let n=r;n>=i;n--)for(let s=0;s<a.length;s++){if(a[s].level<n)continue;let o=s;for(;o+1<a.length&&a[o+1].level>=n;)o++;for(let l=s,u=o;l<u;l++,u--)[a[l],a[u]]=[a[u],a[l]];s=o}return a}function nD(e){return e.level%2==0?e.text:Dd.getMirroredCharacter(e.text)??e.text}function sD(e,t){var r;return((r=e.find(i=>t>=i.start&&t<=i.end))==null?void 0:r.level)??0}function oD(e,t,r,i,a){let n=rD(e,t,i,a);iD(n,r);let s="",o=[];for(let l of aD(n,r)){if(QS.test(l.text))continue;let u=nD(l);s+=u,o.push(...Array(u.length).fill(l.index))}return{text:s,sourceIndices:o}}function lD(e,t){let r=t.filter(n=>n>0&&n<e.length),i=[...new Set([0,...r,e.length])].sort((n,s)=>n-s),a=[];for(let n=0;n+1<i.length;n++)a.push([i[n],i[n+1]]);return a}function y0(e,t){let{levels:r,paragraphs:i}=Dd.getEmbeddingLevels(e);return lD(e,t.concat(i.map(a=>a.start))).map(([a,n])=>oD(e,r,sD(i,a),a,n))}function uD(e,t){return y0(e,t).map(r=>r.text)}function hD(e,t,r){return y0(e,r).map(i=>[i.text,i.sourceIndices.map(a=>t[a]??0)])}const Xf=4294967296,Yf=typeof TextDecoder>"u"?null:new TextDecoder("utf-8");var x0=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,r=this.length){let i;for(;i=this.nextField(r);)e(i,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)*Xf;return this.pos+=8,e}readSFixed64(){let e=this.dataView.getUint32(this.pos,!0)+this.dataView.getInt32(this.pos+4,!0)*Xf;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,r=t[this.pos++];if(r<128)return r;let i=r&127,a;return a=t[this.pos++],i|=(a&127)<<7,a<128||(a=t[this.pos++],i|=(a&127)<<14,a<128)||(a=t[this.pos++],i|=(a&127)<<21,a<128)?i:(a=t[this.pos],i|=(a&15)<<28,cD(i,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&&Yf?Yf.decode(this.buf.subarray(t,e)):pD(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 r=this.readPackedEnd();for(;this.pos<r;)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 this.type===2?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=t&7,this._valueStart=this.pos,t>>>3}skip(e){let t=e&7;if(t===0)for(;this.buf[this.pos++]>127;);else if(t===2)this.pos=this.readVarint()+this.pos;else if(t===5)this.pos+=4;else if(t===1)this.pos+=8;else throw Error(`Unimplemented type: ${t}`)}};function cD(e,t,r){let i=r.buf,a,n;if(n=i[r.pos++],a=(n&112)>>4,n<128||(n=i[r.pos++],a|=(n&127)<<3,n<128)||(n=i[r.pos++],a|=(n&127)<<10,n<128)||(n=i[r.pos++],a|=(n&127)<<17,n<128)||(n=i[r.pos++],a|=(n&127)<<24,n<128)||(n=i[r.pos++],a|=(n&1)<<31,n<128))return dD(e,a,t);throw Error("Expected varint not more than 10 bytes")}function dD(e,t,r){return r?t*4294967296+(e>>>0):(t>>>0)*4294967296+(e>>>0)}function pD(e,t,r){let i="",a=t;for(;a<r;){let n=e[a],s=null,o=n>239?4:n>223?3:n>191?2:1;if(a+o>r)break;let l,u,h;o===1?n<128&&(s=n):o===2?(l=e[a+1],(l&192)==128&&(s=(n&31)<<6|l&63,s<=127&&(s=null))):o===3?(l=e[a+1],u=e[a+2],(l&192)==128&&(u&192)==128&&(s=(n&15)<<12|(l&63)<<6|u&63,(s<=2047||s>=55296&&s<=57343)&&(s=null))):o===4&&(l=e[a+1],u=e[a+2],h=e[a+3],(l&192)==128&&(u&192)==128&&(h&192)==128&&(s=(n&15)<<18|(l&63)<<12|(u&63)<<6|h&63,(s<=65535||s>=1114112)&&(s=null))),s===null?(s=65533,o=1):s>65535&&(s-=65536,i+=String.fromCharCode(s>>>10&1023|55296),s=56320|s&1023),i+=String.fromCharCode(s),a+=o}return i}function fD(e,t,r){e===1&&r.readMessage(mD,t)}function mD(e,t,r){if(e===3){let{id:i,bitmap:a,width:n,height:s,left:o,top:l,advance:u}=r.readMessage(gD,{});t.push({id:i,bitmap:new vd({width:n+6,height:s+6},a),metrics:{width:n,height:s,left:o,top:l,advance:u}})}}function gD(e,t,r){e===1?t.id=r.readVarint():e===2?t.bitmap=r.readBytes():e===3?t.width=r.readVarint():e===4?t.height=r.readVarint():e===5?t.left=r.readSVarint():e===6?t.top=r.readSVarint():e===7&&(t.advance=r.readVarint())}function _D(e){return new x0(e).readFields(fD,[])}function nl(e){return typeof(e==null?void 0:e.renderWithWebGL)=="function"}function yD(e){let{userImage:t}=e;return!(t!=null&&t.render)||!t.render()?!1:(nl(t.data)||e.data.replace(new Uint8Array(t.data.buffer)),!0)}function v0(e){let t=0,r=0;for(let s of e)t+=s.w*s.h,r=Math.max(r,s.w);e.sort((s,o)=>o.h-s.h);let i=[{x:0,y:0,w:Math.max(Math.ceil(Math.sqrt(t/.95)),r),h:1/0}],a=0,n=0;for(let s of e)for(let o=i.length-1;o>=0;o--){let l=i[o];if(!(s.w>l.w||s.h>l.h)){if(s.x=l.x,s.y=l.y,n=Math.max(n,s.y+s.h),a=Math.max(a,s.x+s.w),s.w===l.w&&s.h===l.h){let u=i.pop();u&&o<i.length&&(i[o]=u)}else s.h===l.h?(l.x+=s.w,l.w-=s.w):s.w===l.w?(l.y+=s.h,l.h-=s.h):(i.push({x:l.x+s.w,y:l.y,w:l.w-s.w,h:s.h}),l.y+=s.h,l.h-=s.h);break}}return{w:a,h:n,fill:t/(a*n)||0}}var Ed=class{constructor(e,{pixelRatio:t,version:r,isWebGLImage:i=!1,stretchX:a,stretchY:n,content:s,textFitWidth:o,textFitHeight:l}){this.paddedRect=e,this.pixelRatio=t,this.stretchX=a,this.stretchY=n,this.content=s,this.version=r,this.needsFirstWebGLRender=i,this.textFitWidth=o,this.textFitHeight=l}get tl(){return[this.paddedRect.x+1,this.paddedRect.y+1]}get br(){return[this.paddedRect.x+this.paddedRect.w-1,this.paddedRect.y+this.paddedRect.h-1]}get tlbr(){return this.tl.concat(this.br)}get displaySize(){return[(this.paddedRect.w-2)/this.pixelRatio,(this.paddedRect.h-2)/this.pixelRatio]}},xD=class{constructor(e,t){let r={},i={};this.haveRenderCallbacks=[],this.patchedUpdateVersion=-1;let a=[];this.addImages(e,r,a),this.addImages(t,i,a);let{w:n,h:s}=v0(a),o=new $e({width:n||1,height:s||1});for(let l in e){let u=e[l];if(u.isWebGLImage)continue;let h=r[l].paddedRect;$e.copy(u.data,o,{x:0,y:0},{x:h.x+1,y:h.y+1},u.data)}for(let l in t){let u=t[l],h=i[l].paddedRect,c=h.x+1,d=h.y+1,p=u.data.width,f=u.data.height;$e.copy(u.data,o,{x:0,y:0},{x:c,y:d},u.data),$e.copy(u.data,o,{x:0,y:f-1},{x:c,y:d-1},{width:p,height:1}),$e.copy(u.data,o,{x:0,y:0},{x:c,y:d+f},{width:p,height:1}),$e.copy(u.data,o,{x:p-1,y:0},{x:c-1,y:d},{width:1,height:f}),$e.copy(u.data,o,{x:0,y:0},{x:c+p,y:d},{width:1,height:f})}this.image=o,this.iconPositions=r,this.patternPositions=i}addImages(e,t,r){for(let i in e){let a=e[i],n={x:0,y:0,w:a.data.width+2,h:a.data.height+2};r.push(n),t[i]=new Ed(n,a),a.hasRenderCallback&&this.haveRenderCallbacks.push(i)}}patchUpdatedImages(e,t){if(e.dispatchRenderCallbacks(this.haveRenderCallbacks),this.patchedUpdateVersion!==e.updateVersion){this.patchedUpdateVersion=e.updateVersion;for(let r in this.iconPositions)this.patchUpdatedImage(this.iconPositions[r],e.getImage(r),t);for(let r in this.patternPositions)this.patchUpdatedImage(this.patternPositions[r],e.getImage(r),t)}}patchUpdatedImage(e,t,r){var l;if(!e||!t||!e.needsFirstWebGLRender&&e.version===t.version)return;e.needsFirstWebGLRender=!1,e.version=t.version;let[i,a]=e.tl,n=(l=t.userImage)==null?void 0:l.data;if(!nl(n)){r.update(t.data,void 0,{x:i,y:a});return}let{width:s,height:o}=t.data;r.context.setCustomLayerDefaults(),n.renderWithWebGL({gl:r.context.gl,texture:r.texture,x:i,y:a,width:s,height:o}),r.context.setDirty()}};G("ImagePosition",Ed),G("ImageAtlas",xD);var b0=(function(e){return e[e.none=0]="none",e[e.horizontal=1]="horizontal",e[e.vertical=2]="vertical",e[e.horizontalOnly=3]="horizontalOnly",e})(b0||{});function vD(e){for(let t of e)if(t.positionedGlyphs.length!==0)return!1;return!0}function bD(e,t){let r=[],i=0;for(let a of t)r.push(e.substring(i,a)),i=a;return i<e.length()&&r.push(e.substring(i,e.length())),r}const Kf=new RegExp("^\\p{gc=M}$","u");function wD(e){let t=[],r=0;for(;r<e.length;){if(!Kf.test(e[r])){t.push(r),r++;continue}let i=r;for(;i<e.length&&Kf.test(e[i]);)i++;let a=e[i];if(a!==void 0&&m0(a.codePointAt(0))){t.push(i);for(let n=i-1;n>=r;n--)t.push(n);r=i+1}else{for(let n=r;n<i;n++)t.push(n);r=i}}return t}function TD(e){let t=[],r=0;for(let i of e.graphemes())t.push(...Array(i.length).fill(e.sectionIndex[r])),r++;return t}function SD(e,t){let r=t.map(n=>e.toCodeUnitIndex(n)),i=il.isParsed()?il:null;if(e.sections.length===1)return i?i.processBidirectionalText(e.toString(),r).map(n=>Jf(n,e.sections,[...n].map(()=>0))):uD(e.toString(),r).map(n=>yc([...n],e.sections,[...n].map(()=>0)));let a=TD(e);return i?i.processStyledBidirectionalText(e.text,a,r).map(([n,s])=>Jf(n,e.sections,s)):hD(e.text,a,r).map(([n,s])=>{let o=[...n];return yc(o,e.sections,w0(o).map(l=>s[l]??0))})}function yc(e,t,r){let i=new Sd(e.join(""),t,[]),a=0;for(let n of i.graphemes())i.sectionIndex.push(r[a]??0),a+=[...n].length;return i}function w0(e){let t=[],r=0;for(let i of e)t.push(r),r+=i.length;return t}function Jf(e,t,r){let i=[...e],a=w0(i),n=wD(i);return yc(n.map(s=>i[s]),t,n.map(s=>r[a[s]]??0))}function Qs(e,t,r,i,a,n,s,o,l,u,h,c,d,p,f){let m=Sd.fromFeature(e,a);c===2&&m.verticalizePunctuation();let g=m.determineLineBreaks(u,n,t,i,p),_=g0(m.text)?SD(m,g):bD(m,g),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 FD(v,t,r,i,_,s,o,l,c,u,d,f),!vD(y)&&v}function Vl(e){let t=.5,r=.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":r=1;break;case"top":case"top-right":case"top-left":r=0}return{horizontalAlign:t,verticalAlign:r}}function DD(e,t,r){let i=t.getMaxScale()*24,{maxImageWidth:a,maxImageHeight:n}=t.getMaxImageSize(e),s=Math.max(i,n*r);return{verticalLineContentWidth:Math.max(i,a*r),horizontalLineContentHeight:s}}function T0(e){switch(e){case"top":return 0;case"center":return .5;default:return 1}}function ED(e,t,r,i){var n,s;if(e!=null&&e.rect)return e;let a=(s=(n=t[r.fontStack])==null?void 0:n.default)==null?void 0:s[i];return a?{rect:null,metrics:a.metrics}:null}function PD(e,t,r){return!(e===1||!t&&!jl(r)||t&&(Td(r)||f0(r)))}function Io(e){return new RegExp("\\p{Nd}","u").test(String.fromCodePoint(e))}function S0(e){return new RegExp("\\p{Lu}","u").test(String.fromCodePoint(e))}function AD(e){return/[\p{P}\p{S}]/u.test(String.fromCodePoint(e))}function CD(e){let t=e.some(Io)&&e.every(i=>Io(i)||AD(i)),r=e.length<=3&&e.every(i=>S0(i)||Io(i));return t||r}function ID(e){return(Io(e)||S0(e))&&!f0(e)}function MD(e,t){let r=!1;for(let i=0;i<e.length;i++){if(t[i])continue;let a=Aa[e[i]];a&&(i===0||t[i-1])&&(i===e.length-1||t[i+1])&&(e[i]=a,t[i]=!0,r=!0)}return r}function zD(e){let t=e.graphemes().slice(),r=t.map(n=>n.codePointAt(0)),i=r.map(jl),a=n=>!i[n]&&!Td(r[n])&&!("imageName"in e.getSection(n));for(let n=0;n<r.length;n++){if(!a(n))continue;let s=n;for(;s+1<r.length&&a(s+1);)s++;if(CD(r.slice(n,s+1)))for(let o=n;o<=s;o++)i[o]=ID(r[o]);n=s}return MD(t,i)&&(e.text=t.join(""),e._graphemes=null),i}function FD(e,t,r,i,a,n,s,o,l,u,h,c){var w,b;let d=0,p=0,f=0,m=0,g=o==="right"?1:o==="left"?0:.5,_=24/c,y=0;for(let S of a){S.trim();let A=S.getMaxScale(),P={positionedGlyphs:[],lineOffset:0};e.positionedLines[y]=P;let I=P.positionedGlyphs,R=0;if(!S.length()){p+=n,++y;continue}let F=DD(i,S,_),T=l===2&&!h?zD(S):null,E=S.graphemes();for(let k=0;k<E.length;k++){let B=S.getSection(k),$=E[k],W=$.codePointAt(0),ie=T?T[k]:PD(l,h,W),ye="fontStack"in B&&al($)&&!((b=(w=t[B.fontStack])==null?void 0:w.default)!=null&&b[$])?[...$]:[$];for(let ce of ye){let ke={glyph:ce.codePointAt(0),grapheme:ce,imageName:null,x:d,y:p+-17,vertical:ie,scale:1,fontStack:"",sectionIndex:S.getSectionIndex(k),metrics:null,rect:null},ve;if("fontStack"in B){if(ve=RD(B,ce,ie,F,t,r),!ve)continue;ke.fontStack=B.fontStack}else{if(e.iconsInText=!0,B.scale*=_,ve=kD(B,ie,A,F,i),!ve)continue;R=Math.max(R,ve.imageOffset),ke.imageName=B.imageName}let{rect:Ue,metrics:Ee,baselineOffset:pt}=ve;if(ke.y+=pt,ke.scale=B.scale,ke.metrics=Ee,ke.rect=Ue,I.push(ke),!ie)d+=Ee.advance*B.scale+u;else{e.verticalizable=!0;let yt="imageName"in B?Ee.advance:24;d+=yt*B.scale+u}}}if(I.length!==0){let k=d-u;f=Math.max(k,f),LD(I,0,I.length-1,g)}d=0;let D=(A-1)*24;P.lineOffset=Math.max(R,D);let C=n*A+R;p+=C,m=Math.max(C,m),++y}let{horizontalAlign:v,verticalAlign:x}=Vl(s);BD(e.positionedLines,g,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}function RD(e,t,r,i,a,n){var u,h;let s=(h=(u=n[e.fontStack])==null?void 0:u.default)==null?void 0:h[t],o=ED(s,a,e,t);if(o===null)return null;let l;if(r)l=i.verticalLineContentWidth-e.scale*24;else{let c=T0(e.verticalAlign);l=(i.horizontalLineContentHeight-e.scale*24)*c}return{rect:o.rect,metrics:o.metrics,baselineOffset:l}}function kD(e,t,r,i,a){let n=a[e.imageName];if(!n)return null;let s=n.paddedRect,o=n.displaySize,l={width:o[0],height:o[1],left:1,top:-3,advance:t?o[1]:o[0]},u;if(t)u=i.verticalLineContentWidth-o[1]*e.scale;else{let c=T0(e.verticalAlign);u=(i.horizontalLineContentHeight-o[1]*e.scale)*c}let h=(t?o[0]:o[1])*e.scale-24*r;return{rect:s,metrics:l,baselineOffset:u,imageOffset:h}}function LD(e,t,r,i){if(i===0)return;let a=e[r],n=a.metrics.advance*a.scale,s=(e[r].x+n)*i;for(let o=t;o<=r;o++)e[o].x-=s}function BD(e,t,r,i,a,n,s,o,l){let u=(t-r)*a,h=0;h=n===s?-i*l*s+.5*s:-o*i- -17;for(let c of e)for(let d of c.positionedGlyphs)d.x+=u,d.y+=h}function OD(e,t,r){let{horizontalAlign:i,verticalAlign:a}=Vl(r),n=t[0],s=t[1],o=n-e.displaySize[0]*i,l=o+e.displaySize[0],u=s-e.displaySize[1]*a;return{image:e,top:u,bottom:u+e.displaySize[1],left:o,right:l}}function D0(e){let t=e.left,r=e.top,i=e.right-t,a=e.bottom-r,n=e.image.content[2]-e.image.content[0],s=e.image.content[3]-e.image.content[1],o=e.image.textFitWidth??"stretchOrShrink",l=e.image.textFitHeight??"stretchOrShrink",u=n/s;if(l==="proportional"){if(o==="stretchOnly"&&i/a<u||o==="proportional"){let h=Math.ceil(a*u);t*=h/i,i=h}}else if(o==="proportional"&&l==="stretchOnly"&&u!==0&&i/a>u){let h=Math.ceil(i/u);r*=h/a,a=h}return{x1:t,y1:r,x2:t+i,y2:r+a}}function Qf(e,t,r,i,a,n){let s=e.image,o;if(s.content){let g=s.content,_=s.pixelRatio||1;o=[g[0]/_,g[1]/_,s.displaySize[0]-g[2]/_,s.displaySize[1]-g[3]/_]}let l=t.left*n,u=t.right*n,h,c,d,p;r==="width"||r==="both"?(p=a[0]+l-i[3],c=a[0]+u+i[1]):(p=a[0]+(l+u-s.displaySize[0])/2,c=p+s.displaySize[0]);let f=t.top*n,m=t.bottom*n;return r==="height"||r==="both"?(h=a[1]+f-i[0],d=a[1]+m+i[2]):(h=a[1]+(f+m-s.displaySize[1])/2,d=h+s.displaySize[1]),{image:s,top:h,right:c,bottom:d,left:p,collisionPadding:o}}const em=32640;function tm(e,t){let{expression:r}=t;if(r.kind==="constant")return{kind:"constant",layoutSize:r.evaluate(new ze(e+1))};if(r.kind==="source")return{kind:"source"};if(r.kind==="composite"){let{minZoom:i,maxZoom:a}=$D(r.zoomStops,e);return{kind:"composite",minZoom:i,maxZoom:a,interpolationType:r.interpolationType}}{let i=jD(r),a=r.evaluate(new ze(e+1));return{kind:"camera",zoomStops:r.zoomStops,sizes:i,layoutSize:a,interpolationType:r.interpolationType}}}function $D(e,t){let r=0;for(;r<e.length&&e[r]<=t;)r++;r=Math.max(0,r-1);let i=r;for(;i<e.length&&e[i]<t+1;)i++;return i=Math.min(e.length-1,i),{minZoom:e[r],maxZoom:e[i]}}function jD(e){return e.zoomStops.map(t=>e.evaluate(new ze(t===-1/0?e.zoomStops[1]-1:t)))}function Pd(e,{uSize:t,uSizeT:r},{lowerSize:i,upperSize:a}){return e.kind==="source"?i/128:e.kind==="composite"?We.number(i/128,a/128,r):t}function Nl(e,t){let r=0,i=0;return e.kind==="constant"?i=e.layoutSize:e.kind==="camera"?i=VD(e,t):e.kind==="composite"&&(r=ND(e,t)),{uSizeT:r,uSize:i}}function VD({zoomStops:e,sizes:t,layoutSize:r,interpolationType:i},a){let n=e.length-1;for(;n>0&&e[n]>a;)n--;let s=Math.min(n+1,e.length-1),o=i?se(_r.interpolationFactor(i,a,e[n],e[s]),0,1):0;return Math.min(We.number(t[n],t[s],o),r)}function ND({interpolationType:e,minZoom:t,maxZoom:r},i){return e?se(_r.interpolationFactor(e,i,t,r),0,1):0}var Fa=class E0 extends M{constructor(t,r,i,a){super(t,r),this.angle=i,a!==void 0&&(this.segment=a)}clone(){return new E0(this.x,this.y,this.angle,this.segment)}};G("Anchor",Fa);function P0(e,t,r,i,a){if(t.segment===void 0||r===0)return!0;let n=t,s=t.segment+1,o=0;for(;o>-r/2;){if(s--,s<0)return!1;o-=e[s].dist(n),n=e[s]}o+=e[s].dist(e[s+1]),s++;let l=[],u=0;for(;o<r/2;){let h=e[s-1],c=e[s],d=e[s+1];if(!d)return!1;let p=h.angleTo(c)-c.angleTo(d);for(p=Math.abs((p+3*Math.PI)%(Math.PI*2)-Math.PI),l.push({distance:o,angleDelta:p}),u+=p;o-l[0].distance>i;)u-=l.shift().angleDelta;if(u>a)return!1;s++,o+=c.dist(d)}return!0}function A0(e){let t=0;for(let r=0;r<e.length-1;r++)t+=e[r].dist(e[r+1]);return t}function C0(e,t,r){return e?3/5*t*r:0}function I0(e,t){return Math.max(e?e.right-e.left:0,t?t.right-t.left:0)}function UD(e,t,r,i,a,n){let s=C0(r,a,n),o=I0(r,i)*n,l=0,u=A0(e)/2;for(let h=0;h<e.length-1;h++){let c=e[h],d=e[h+1],p=c.dist(d);if(l+p>u){let f=(u-l)/p,m=new Fa(We.number(c.x,d.x,f),We.number(c.y,d.y,f),d.angleTo(c),h);return m._round(),!s||P0(e,m,o,s,t)?m:void 0}l+=p}}function GD(e,t,r,i,a,n,s,o,l){let u=C0(i,n,s),h=I0(i,a),c=h*s,d=e[0].x===0||e[0].x===l||e[0].y===0||e[0].y===l;t-c<t/4&&(t=c+t/4);let p=n*2;return M0(e,d?t/2*o%t:(h/2+p)*s*o%t,t,u,r,c,d,!1,l)}function M0(e,t,r,i,a,n,s,o,l){let u=n/2,h=A0(e),c=0,d=t-r,p=[];for(let f=0;f<e.length-1;f++){let m=e[f],g=e[f+1],_=m.dist(g),y=g.angleTo(m);for(;d+r<c+_;){d+=r;let v=(d-c)/_,x=We.number(m.x,g.x,v),w=We.number(m.y,g.y,v);if(x>=0&&x<l&&w>=0&&w<l&&d-u>=0&&d+u<=h){let b=new Fa(x,w,y,f);b._round(),(!i||P0(e,b,n,i,a))&&p.push(b)}}c+=_}return!o&&!p.length&&!s&&(p=M0(e,c/2,r,i,a,n,s,!0,l)),p}function z0(e,t,r,i,a){let n=[];for(let s of e){let o;for(let l=0;l<s.length-1;l++){let u=s[l],h=s[l+1];u.x<t&&h.x<t||(u.x<t?u=new M(t,u.y+(h.y-u.y)*((t-u.x)/(h.x-u.x)))._round():h.x<t&&(h=new M(t,u.y+(h.y-u.y)*((t-u.x)/(h.x-u.x)))._round()),!(u.y<r&&h.y<r)&&(u.y<r?u=new M(u.x+(h.x-u.x)*((r-u.y)/(h.y-u.y)),r)._round():h.y<r&&(h=new M(u.x+(h.x-u.x)*((r-u.y)/(h.y-u.y)),r)._round()),!(u.x>=i&&h.x>=i)&&(u.x>=i?u=new M(i,u.y+(h.y-u.y)*((i-u.x)/(h.x-u.x)))._round():h.x>=i&&(h=new M(i,u.y+(h.y-u.y)*((i-u.x)/(h.x-u.x)))._round()),!(u.y>=a&&h.y>=a)&&(u.y>=a?u=new M(u.x+(h.x-u.x)*((a-u.y)/(h.y-u.y)),a)._round():h.y>=a&&(h=new M(u.x+(h.x-u.x)*((a-u.y)/(h.y-u.y)),a)._round()),(!o||!u.equals(o[o.length-1]))&&(o=[u],n.push(o)),o.push(h)))))}}return n}function rm(e,t,r,i){let a=[],n=e.image,s=n.pixelRatio,o=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,o]],c=n.stretchY||[[0,l]],d=(E,D)=>E+D[1]-D[0],p=h.reduce(d,0),f=c.reduce(d,0),m=o-p,g=l-f,_=0,y=p,v=0,x=f,w=0,b=m,S=0,A=g;if(n.content&&i){let E=n.content,D=E[2]-E[0],C=E[3]-E[1];(n.textFitWidth||n.textFitHeight)&&(u=D0(e)),_=eo(h,0,E[0]),v=eo(c,0,E[1]),y=eo(h,E[0],E[2]),x=eo(c,E[1],E[3]),w=E[0]-_,S=E[1]-v,b=D-y,A=C-x}let P=u.x1,I=u.y1,R=u.x2-P,F=u.y2-I,T=(E,D,C,k)=>{let B=to(E.stretch-_,y,R,P),$=ro(E.fixed-w,b,E.stretch,p),W=to(D.stretch-v,x,F,I),ie=ro(D.fixed-S,A,D.stretch,f),ye=to(C.stretch-_,y,R,P),ce=ro(C.fixed-w,b,C.stretch,p),ke=to(k.stretch-v,x,F,I),ve=ro(k.fixed-S,A,k.stretch,f),Ue=new M(B,W),Ee=new M(ye,W),pt=new M(ye,ke),yt=new M(B,ke),Nt=new M($/s,ie/s),Ut=new M(ce/s,ve/s),Tt=t*Math.PI/180;if(Tt){let Z=Math.sin(Tt),ge=Math.cos(Tt),re=[ge,-Z,Z,ge];Ue._matMult(re),Ee._matMult(re),yt._matMult(re),pt._matMult(re)}let nt=E.stretch+E.fixed,Yt=C.stretch+C.fixed,xr=D.stretch+D.fixed,sr=k.stretch+k.fixed;return{tl:Ue,tr:Ee,bl:yt,br:pt,tex:{x:n.paddedRect.x+1+nt,y:n.paddedRect.y+1+xr,w:Yt-nt,h:sr-xr},writingMode:void 0,glyphOffset:[0,0],sectionIndex:0,pixelOffsetTL:Nt,pixelOffsetBR:Ut,minFontScaleX:b/s/R,minFontScaleY:A/s/F,isSDF:r}};if(!i||!n.stretchX&&!n.stretchY)a.push(T({fixed:0,stretch:-1},{fixed:0,stretch:-1},{fixed:0,stretch:o+1},{fixed:0,stretch:l+1}));else{let E=im(h,m,p),D=im(c,g,f);for(let C=0;C<E.length-1;C++){let k=E[C],B=E[C+1];for(let $=0;$<D.length-1;$++){let W=D[$],ie=D[$+1];a.push(T(k,W,B,ie))}}}return a}function eo(e,t,r){let i=0;for(let a of e)i+=Math.max(t,Math.min(r,a[1]))-Math.max(t,Math.min(r,a[0]));return i}function im(e,t,r){let i=[{fixed:-1,stretch:0}];for(let[a,n]of e){let s=i[i.length-1];i.push({fixed:a-s.stretch,stretch:s.stretch}),i.push({fixed:a-s.stretch,stretch:s.stretch+(n-a)})}return i.push({fixed:t+1,stretch:r}),i}function to(e,t,r,i){return e/t*r+i}function ro(e,t,r,i){return e-t*r/i}function qD(e,t,r,i,a,n,s,o){let l=i.layout.get("text-rotate").evaluate(n,{})*Math.PI/180,u=[];for(let h of t.positionedLines)for(let c of h.positionedGlyphs){if(!c.rect)continue;let d=c.rect||{},p=4,f=!0,m=1,g=0,_=(a||o)&&c.vertical,y=c.metrics.advance*c.scale/2;if(o&&t.verticalizable){let k=(c.scale-1)*24,B=(24-c.metrics.width*c.scale)/2;g=h.lineOffset/2-(c.imageName?-B:k)}if(c.imageName){let k=s[c.imageName];f=k.sdf,m=k.pixelRatio,p=1/m}let v=a?[c.x+y,c.y]:[0,0],x=a?[0,0]:[c.x+y+r[0],c.y+r[1]-g],w=[0,0];_&&(w=x,x=[0,0]);let b=c.metrics.isDoubleResolution?2:1,S=(c.metrics.left-p)*c.scale-y+x[0],A=(-c.metrics.top-p)*c.scale+x[1],P=S+d.w/b*c.scale/m,I=A+d.h/b*c.scale/m,R=new M(S,A),F=new M(P,A),T=new M(S,I),E=new M(P,I);if(_){let k=new M(-y,y- -17),B=-Math.PI/2,$=12-y,W=c.imageName?$:0,ie=new M(22-$,-W),ye=new M(...w);R._rotateAround(B,k)._add(ie)._add(ye),F._rotateAround(B,k)._add(ie)._add(ye),T._rotateAround(B,k)._add(ie)._add(ye),E._rotateAround(B,k)._add(ie)._add(ye)}if(l){let k=Math.sin(l),B=Math.cos(l),$=[B,-k,k,B];R._matMult($),F._matMult($),T._matMult($),E._matMult($)}let D=new M(0,0),C=new M(0,0);u.push({tl:R,tr:F,bl:T,br:E,tex:d,writingMode:t.writingMode,glyphOffset:v,sectionIndex:c.sectionIndex,isSDF:f,pixelOffsetTL:D,pixelOffsetBR:C,minFontScaleX:0,minFontScaleY:0})}return u}var io=class{constructor(e,t,r,i,a,n,s,o,l,u){var h;if(this.boxStartIndex=e.length,l){let c=n.top,d=n.bottom,p=n.collisionPadding;p&&(c-=p[1],d+=p[3]);let f=d-c;f>0&&(f=Math.max(10,f),this.circleDiameter=f)}else{let c=(h=n.image)!=null&&h.content&&(n.image.textFitWidth||n.image.textFitHeight)?D0(n):{x1:n.left,y1:n.top,x2:n.right,y2:n.bottom};c.y1=c.y1*s-o[0],c.y2=c.y2*s+o[2],c.x1=c.x1*s-o[3],c.x2=c.x2*s+o[1];let d=n.collisionPadding;if(d&&(c.x1-=d[0]*s,c.y1-=d[1]*s,c.x2+=d[2]*s,c.y2+=d[3]*s),u){let p=new M(c.x1,c.y1),f=new M(c.x2,c.y1),m=new M(c.x1,c.y2),g=new M(c.x2,c.y2),_=u*Math.PI/180;p._rotate(_),f._rotate(_),m._rotate(_),g._rotate(_),c.x1=Math.min(p.x,f.x,m.x,g.x),c.x2=Math.max(p.x,f.x,m.x,g.x),c.y1=Math.min(p.y,f.y,m.y,g.y),c.y2=Math.max(p.y,f.y,m.y,g.y)}e.emplaceBack(t.x,t.y,c.x1,c.y1,c.x2,c.y2,r,i,a)}this.boxEndIndex=e.length}},ZD=class{constructor(e=[],t=(r,i)=>r<i?-1:+(r>i)){if(this.data=e,this.length=this.data.length,this.compare=t,this.length>0)for(let r=(this.length>>1)-1;r>=0;r--)this._down(r)}push(e){this.data.push(e),this._up(this.length++)}pop(){if(this.length===0)return;let e=this.data[0],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:r}=this,i=t[e];for(;e>0;){let a=e-1>>1,n=t[a];if(r(i,n)>=0)break;t[e]=n,e=a}t[e]=i}_down(e){let{data:t,compare:r}=this,i=this.length>>1,a=t[e];for(;e<i;){let n=(e<<1)+1,s=n+1;if(s<this.length&&r(t[s],t[n])<0&&(n=s),r(t[n],a)>=0)break;t[e]=t[n],e=n}t[e]=a}};function WD(e,t=1){let r=Er.fromPoints(e[0]),i=Math.min(r.width(),r.height()),a=i/2,n=new ZD([],HD),{minX:s,minY:o,maxX:l,maxY:u}=r;if(i===0)return new M(s,o);for(let d=s;d<l;d+=i)for(let p=o;p<u;p+=i)n.push(new Ea(d+a,p+a,a,e));let h=YD(e),c=h;for(;n.length;){let d=n.pop();(d.d>c.d||!c.d)&&(c=d),!(d.max-c.d<=t)&&(a=d.h/2,n.push(new Ea(d.p.x-a,d.p.y-a,a,e)),n.push(new Ea(d.p.x+a,d.p.y-a,a,e)),n.push(new Ea(d.p.x-a,d.p.y+a,a,e)),n.push(new Ea(d.p.x+a,d.p.y+a,a,e)))}return h.d>0&&c.d-h.d<=t?h.p:c.p}function HD(e,t){return t.max-e.max}var Ea=class{constructor(e,t,r,i){this.p=new M(e,t),this.h=r,this.d=XD(this.p,i),this.max=this.d+this.h*Math.SQRT2}};function XD(e,t){let r=!1,i=1/0;for(let a of t)for(let n=0,s=a.length,o=s-1;n<s;o=n++){let l=a[n],u=a[o];l.y>e.y!=u.y>e.y&&e.x<(u.x-l.x)*(e.y-l.y)/(u.y-l.y)+l.x&&(r=!r),i=Math.min(i,jy(e,l,u))}return(r?1:-1)*Math.sqrt(i)}function YD(e){let t=0,r=0,i=0,a=e[0];for(let n=0,s=a.length,o=s-1;n<s;o=n++){let l=a[n],u=a[o],h=l.x*u.y-u.x*l.y;r+=(l.x+u.x)*h,i+=(l.y+u.y)*h,t+=h*3}return new Ea(r/t,i/t,0,e)}let xc=(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})({});const Ad=1/0;function F0(e,t){function r(a,n){let s=0,o=0;n<0&&(n=0);let l=n/Math.SQRT2;switch(a){case"top-right":case"top-left":o=l-7;break;case"bottom-right":case"bottom-left":o=-l+7;break;case"bottom":o=-n+7;break;case"top":o=n-7}switch(a){case"top-right":case"bottom-right":s=-l;break;case"top-left":case"bottom-left":s=l;break;case"left":s=n;break;case"right":s=-n}return[s,o]}function i(a,n,s){let o=0,l=0;switch(n=Math.abs(n),s=Math.abs(s),a){case"top-right":case"top-left":case"top":l=s-7;break;case"bottom-right":case"bottom-left":case"bottom":l=-s+7}switch(a){case"top-right":case"bottom-right":case"right":o=-n;break;case"top-left":case"bottom-left":case"left":o=n}return[o,l]}return t[1]===Ad?r(e,t[0]):i(e,t[0],t[1])}function R0(e,t,r){var s;let i=e.layout,a=(s=i.get("text-variable-anchor-offset"))==null?void 0:s.evaluate(t,{},r);if(a){let o=a.values,l=[];for(let u=0;u<o.length;u+=2){let h=l[u]=o[u],c=o[u+1].map(d=>d*24);h.startsWith("top")?c[1]-=7:h.startsWith("bottom")&&(c[1]+=7),l[u+1]=c}return new qr(l)}let n=i.get("text-variable-anchor");if(n){let o;o=e._unevaluatedLayout.getValue("text-radial-offset")===void 0?i.get("text-offset").evaluate(t,{},r).map(u=>u*24):[i.get("text-radial-offset").evaluate(t,{},r)*24,Ad];let l=[];for(let u of n)l.push(u,F0(u,o));return new qr(l)}return null}function KD(e){var h,c;e.bucket.createArrays();let t=512*e.bucket.overscaling;e.bucket.tilePixelRatio=L/t,e.bucket.compareText={},e.bucket.iconsNeedLinear=!1;let r=e.bucket.layers[0],i=r.layout,a=r._unevaluatedLayout._values,n={layoutIconSize:a["icon-size"].possiblyEvaluate(new ze(e.bucket.zoom+1),e.canonical),layoutTextSize:a["text-size"].possiblyEvaluate(new ze(e.bucket.zoom+1),e.canonical),textMaxSize:a["text-size"].possiblyEvaluate(new ze(18))};if(e.bucket.textSizeData.kind==="composite"){let{minZoom:d,maxZoom:p}=e.bucket.textSizeData;n.compositeTextSizes=[a["text-size"].possiblyEvaluate(new ze(d),e.canonical),a["text-size"].possiblyEvaluate(new ze(p),e.canonical)]}if(e.bucket.iconSizeData.kind==="composite"){let{minZoom:d,maxZoom:p}=e.bucket.iconSizeData;n.compositeIconSizes=[a["icon-size"].possiblyEvaluate(new ze(d),e.canonical),a["icon-size"].possiblyEvaluate(new ze(p),e.canonical)]}let s=i.get("text-line-height")*24,o=i.get("text-rotation-alignment")!=="viewport"&&i.get("symbol-placement")!=="point",l=i.get("text-keep-upright"),u=i.get("text-size");for(let d of e.bucket.features){let p=i.get("text-font").evaluate(d,{},e.canonical).join(","),f=u.evaluate(d,{},e.canonical),m=n.layoutTextSize.evaluate(d,{},e.canonical),g=n.layoutIconSize.evaluate(d,{},e.canonical),_={horizontal:{},vertical:void 0},y=d.text,v=[0,0];if(y){let S=y.toString(),A=i.get("text-letter-spacing").evaluate(d,{},e.canonical)*24,P=ZS(S)?A:0,I=i.get("text-anchor").evaluate(d,{},e.canonical),R=R0(r,d,e.canonical);if(!R){let D=i.get("text-radial-offset").evaluate(d,{},e.canonical);v=D?F0(I,[D*24,Ad]):i.get("text-offset").evaluate(d,{},e.canonical).map(C=>C*24)}let F=o?"center":i.get("text-justify").evaluate(d,{},e.canonical),T=i.get("symbol-placement")==="point"?i.get("text-max-width").evaluate(d,{},e.canonical)*24:1/0,E=()=>{e.bucket.allowVerticalPlacement&&gc(S)&&(_.vertical=Qs(y,e.glyphMap,e.glyphPositions,e.imagePositions,p,T,s,I,"left",P,v,2,!0,m,f))};if(!o&&R){let D=new Set;if(F==="auto")for(let k=0;k<R.values.length;k+=2)D.add(vc(R.values[k]));else D.add(F);let C=!1;for(let k of D)if(!_.horizontal[k])if(C)_.horizontal[k]=_.horizontal[0];else{let B=Qs(y,e.glyphMap,e.glyphPositions,e.imagePositions,p,T,s,"center",k,P,v,1,!1,m,f);B&&(_.horizontal[k]=B,C=B.positionedLines.length===1)}E()}else{F==="auto"&&(F=vc(I));let D=Qs(y,e.glyphMap,e.glyphPositions,e.imagePositions,p,T,s,I,F,P,v,1,!1,m,f);D&&(_.horizontal[F]=D),E(),gc(S)&&o&&l&&(_.vertical=Qs(y,e.glyphMap,e.glyphPositions,e.imagePositions,p,T,s,I,F,P,v,2,!1,m,f))}}let x,w=!1;if((h=d.icon)!=null&&h.name){let S=e.imageMap[d.icon.name];S&&(x=OD(e.imagePositions[d.icon.name],i.get("icon-offset").evaluate(d,{},e.canonical),i.get("icon-anchor").evaluate(d,{},e.canonical)),w=!!S.sdf,e.bucket.sdfIcons===void 0?e.bucket.sdfIcons=w:e.bucket.sdfIcons!==w&&_e("Style sheet warning: Cannot mix SDF and non-SDF icons in one buffer"),S.pixelRatio===e.bucket.pixelRatio?i.get("icon-rotate").constantOr(1)!==0&&(e.bucket.iconsNeedLinear=!0):e.bucket.iconsNeedLinear=!0)}let b=k0(_.horizontal)||_.vertical;(c=e.bucket).iconsInText||(c.iconsInText=b?b.iconsInText:!1),(b||x)&&JD(e.bucket,d,_,x,e.imageMap,n,m,g,v,w,e.canonical,e.subdivisionGranularity,e.hasPromoteId)}e.showCollisionBoxes&&e.bucket.generateCollisionDebugBuffers()}function vc(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 JD(e,t,r,i,a,n,s,o,l,u,h,c,d){let p=n.textMaxSize.evaluate(t,{});p===void 0&&(p=s);let f=e.layers[0].layout,m=f.get("icon-offset").evaluate(t,{},h),g=k0(r.horizontal),_=s/24,y=e.tilePixelRatio*_,v=e.tilePixelRatio*p/24,x=e.tilePixelRatio*o,w=e.tilePixelRatio*f.get("symbol-spacing"),b=f.get("text-padding")*e.tilePixelRatio,S=cE(f,t,h,e.tilePixelRatio),A=f.get("text-max-angle")/180*Math.PI,P=f.get("text-rotation-alignment")!=="viewport"&&f.get("symbol-placement")!=="point",I=f.get("icon-rotation-alignment").constantOr("viewport")==="map"&&f.get("symbol-placement")!=="point",R=f.get("symbol-placement"),F=w/2,T=f.get("icon-text-fit"),E;i&&T!=="none"&&(e.allowVerticalPlacement&&r.vertical&&(E=Qf(i,r.vertical,T,f.get("icon-text-fit-padding"),m,_)),g&&(i=Qf(i,g,T,f.get("icon-text-fit-padding"),m,_)));let D=h?c.line.getGranularityForZoomLevel(h.z):1,C=(k,B)=>{B.x<0||B.x>=8192||B.y<0||B.y>=8192||eE(e,B,k,r,i,a,E,e.layers[0],e.collisionBoxArray,t.index,t.sourceLayerIndex,e.index,y,[b,b,b,b],P,l,x,S,I,m,t,n,u,h,s,d)};if(R==="line")for(let k of z0(t.geometry,0,0,L,L)){let B=$i(k,D),$=GD(B,w,A,r.vertical||g,i,24,v,e.overscaling,L);for(let W of $){let ie=g;(!ie||!tE(e,ie.text,F,W))&&C(B,W)}}else if(R==="line-center"){for(let k of t.geometry)if(k.length>1){let B=$i(k,D),$=UD(B,A,r.vertical||g,i,24,v);$&&C(B,$)}}else if(t.type==="Polygon")for(let k of El(t.geometry,0)){let B=WD(k,16);C($i(k[0],D,!0),new Fa(B.x,B.y,0))}else if(t.type==="LineString")for(let k of t.geometry){let B=$i(k,D);C(B,new Fa(B[0].x,B[0].y,0))}else if(t.type==="Point")for(let k of t.geometry)for(let B of k)C([B],new Fa(B.x,B.y,0))}function QD(e,t){let r=e.length,i=t==null?void 0:t.values;if((i==null?void 0:i.length)>0)for(let a=0;a<i.length;a+=2){let n=xc[i[a]],s=i[a+1];e.emplaceBack(n,s[0],s[1])}return[r,e.length]}function am(e,t,r,i,a,n,s,o,l,u,h,c,d,p,f,m){let g=qD(t,r,o,a,n,s,i,e.allowVerticalPlacement),_=e.textSizeData,y=null;_.kind==="source"?(y=[128*a.layout.get("text-size").evaluate(s,{})],y[0]>32640&&_e(`${e.layerIds[0]}: Value for "text-size" is >= 255. Reduce your "text-size".`)):_.kind==="composite"&&(y=[128*f.compositeTextSizes[0].evaluate(s,{},m),128*f.compositeTextSizes[1].evaluate(s,{},m)],(y[0]>32640||y[1]>32640)&&_e(`${e.layerIds[0]}: Value for "text-size" is >= 255. Reduce your "text-size".`)),e.addSymbols(e.text,g,y,o,n,s,h,t,u.lineStartIndex,u.lineLength,p,m,l);for(let v of c)d[v]=e.text.placedSymbolArray.length-1;return g.length*4}function k0(e){for(let t in e)return e[t];return null}function eE(e,t,r,i,a,n,s,o,l,u,h,c,d,p,f,m,g,_,y,v,x,w,b,S,A,P){let I=e.addToLineVertexArray(t,r),R=o.layout.get("symbol-height-offset").evaluate(x,{},S);R>e.maxHeightOffset&&(e.maxHeightOffset=R);let F,T,E,D,C=0,k=0,B=0,$=0,W=-1,ie=-1,ye={},ce=(0,Jo.default)("");if(e.allowVerticalPlacement&&i.vertical){let re=o.layout.get("text-rotate").evaluate(x,{},S)+90,j=i.vertical;E=new io(l,t,u,h,c,j,d,p,f,re),s&&(D=new io(l,t,u,h,c,s,g,_,f,re))}if(a){let re=o.layout.get("icon-rotate").evaluate(x,{}),j=o.layout.get("icon-text-fit")!=="none",xe=rm(a,re,b,j),Q=s?rm(s,re,b,j):void 0;T=new io(l,t,u,h,c,a,g,_,!1,re),C=xe.length*4;let ae=e.iconSizeData,q=null;ae.kind==="source"?(q=[128*o.layout.get("icon-size").evaluate(x,{})],q[0]>32640&&_e(`${e.layerIds[0]}: Value for "icon-size" is >= 255. Reduce your "icon-size".`)):ae.kind==="composite"&&(q=[128*w.compositeIconSizes[0].evaluate(x,{},S),128*w.compositeIconSizes[1].evaluate(x,{},S)],(q[0]>32640||q[1]>32640)&&_e(`${e.layerIds[0]}: Value for "icon-size" is >= 255. Reduce your "icon-size".`)),e.addSymbols(e.icon,xe,q,v,y,x,0,t,I.lineStartIndex,I.lineLength,-1,S,R),W=e.icon.placedSymbolArray.length-1,Q&&(k=Q.length*4,e.addSymbols(e.icon,Q,q,v,y,x,2,t,I.lineStartIndex,I.lineLength,-1,S,R),ie=e.icon.placedSymbolArray.length-1)}let ke=Object.keys(i.horizontal);for(let re of ke){let j=i.horizontal[re];F||(F=(ce=(0,Jo.default)(j.text),new io(l,t,u,h,c,j,d,p,f,o.layout.get("text-rotate").evaluate(x,{},S))));let xe=j.positionedLines.length===1;if(B+=am(e,t,j,n,o,f,x,m,R,I,i.vertical?1:3,xe?ke:[re],ye,W,w,S),xe)break}i.vertical&&($+=am(e,t,i.vertical,n,o,f,x,m,R,I,2,["vertical"],ye,ie,w,S));let ve=F?F.boxStartIndex:e.collisionBoxArray.length,Ue=F?F.boxEndIndex:e.collisionBoxArray.length,Ee=E?E.boxStartIndex:e.collisionBoxArray.length,pt=E?E.boxEndIndex:e.collisionBoxArray.length,yt=T?T.boxStartIndex:e.collisionBoxArray.length,Nt=T?T.boxEndIndex:e.collisionBoxArray.length,Ut=D?D.boxStartIndex:e.collisionBoxArray.length,Tt=D?D.boxEndIndex:e.collisionBoxArray.length,nt=-1,Yt=(re,j)=>re!=null&&re.circleDiameter?Math.max(re.circleDiameter,j):j;nt=Yt(F,nt),nt=Yt(E,nt),nt=Yt(T,nt),nt=Yt(D,nt);let xr=+(nt>-1);xr&&(nt*=A/24),e.glyphOffsetArray.length>=e.maxGlyphs&&_e("Too many glyphs being rendered in a tile. See https://github.com/mapbox/mapbox-gl-js/issues/2907"),x.sortKey!==void 0&&e.addToSortKeyRanges(e.symbolInstances.length,x.sortKey);let sr=R0(o,x,S),[Z,ge]=QD(e.textAnchorOffsets,sr);P&&(ce=rE(ce,x)),e.symbolInstances.emplaceBack(t.x,t.y,ye.right>=0?ye.right:-1,ye.center>=0?ye.center:-1,ye.left>=0?ye.left:-1,ye.vertical||-1,W,ie,ce,ve,Ue,Ee,pt,yt,Nt,Ut,Tt,u,B,$,C,k,xr,0,d,nt,Z,ge,R)}function tE(e,t,r,i){let a=e.compareText;if(!(t in a))a[t]=[];else{let n=a[t];for(let s=n.length-1;s>=0;s--)if(i.dist(n[s])<r)return!0}return a[t].push(i),!1}function rE(e,t){var r;return t.id==null||(r=t.properties)!=null&&r.cluster?e:(0,Jo.default)(String(t.id),e)}function sl(e,t,r){let i="never",a=e.get(t);return a?i=a:e.get(r)&&(i="always"),i}const iE=[{name:"a_fade_opacity",components:1,type:"Uint8",offset:0}];function ao(e,t,r,i,a,n,s,o,l,u,h,c,d,p){let f=o?Math.min(em,Math.round(o[0])):0,m=o?Math.min(em,Math.round(o[1])):0;e.emplaceBack(t,r,Math.round(i*32),Math.round(a*32),n,s,(f<<1)+ +!!l,m,u*16,h*16,c*256,d*256,p)}function ol(e,t,r){e.emplaceBack(t.x,t.y,r),e.emplaceBack(t.x,t.y,r),e.emplaceBack(t.x,t.y,r),e.emplaceBack(t.x,t.y,r)}function aE(e){for(let t of e.sections)if(g0(t.text))return!0;return!1}var bc=class{constructor(e){this.layoutVertexArray=new X2,this.indexArray=new Yr,this.programConfigurations=e,this.segments=new Ze,this.dynamicLayoutVertexArray=new Y2,this.opacityVertexArray=new K2,this.hasVisibleVertices=!1,this.placedSymbolArray=new Sy}isEmpty(){return this.layoutVertexArray.length===0&&this.indexArray.length===0&&this.dynamicLayoutVertexArray.length===0&&this.opacityVertexArray.length===0}upload(e,t,r,i){this.isEmpty()||(r&&(this.layoutVertexBuffer=e.createVertexBuffer(this.layoutVertexArray,mS.members),this.indexBuffer=e.createIndexBuffer(this.indexArray,t),this.dynamicLayoutVertexBuffer=e.createVertexBuffer(this.dynamicLayoutVertexArray,gS.members,!0),this.opacityVertexBuffer=e.createVertexBuffer(this.opacityVertexArray,iE,!0),this.opacityVertexBuffer.itemSize=1),(r||i)&&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())}};G("SymbolBuffers",bc);var wc=class{constructor(e,t,r){this.layoutVertexArray=new e,this.layoutAttributes=t,this.indexArray=new r,this.segments=new Ze,this.collisionVertexArray=new Q2}upload(e){this.layoutVertexBuffer=e.createVertexBuffer(this.layoutVertexArray,this.layoutAttributes),this.indexBuffer=e.createIndexBuffer(this.indexArray),this.collisionVertexBuffer=e.createVertexBuffer(this.collisionVertexArray,_S.members,!0)}destroy(){this.layoutVertexBuffer&&(this.layoutVertexBuffer.destroy(),this.indexBuffer.destroy(),this.segments.destroy(),this.collisionVertexBuffer.destroy())}};G("CollisionBuffers",wc);var ll=class{constructor(e){this.collisionBoxArray=e.collisionBoxArray,this.zoom=e.zoom,this.overscaling=e.overscaling,this.layers=e.layers,this.layerIds=this.layers.map(s=>s.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=tm(this.zoom,t["text-size"]),this.iconSizeData=tm(this.zoom,t["icon-size"]);let r=this.layers[0].layout,i=r.get("symbol-sort-key"),a=r.get("symbol-z-order");this.canOverlap=sl(r,"text-overlap","text-allow-overlap")!=="never"||sl(r,"icon-overlap","icon-allow-overlap")!=="never"||r.get("text-ignore-placement")||r.get("icon-ignore-placement"),this.sortFeaturesByKey=a!=="viewport-y"&&!i.isConstant();let n=a==="viewport-y"||a==="auto"&&!this.sortFeaturesByKey;this.sortFeaturesByY=n&&this.canOverlap,r.get("symbol-placement")==="point"&&(this.writingModes=r.get("text-writing-mode").map(s=>b0[s])),this.stateDependentLayerIds=this.layers.filter(s=>s.isStateDependent()).map(s=>s.id),this.sourceID=e.sourceID}createArrays(){this.text=new bc(new Ji(this.layers,this.zoom,e=>e.startsWith("text"))),this.icon=new bc(new Ji(this.layers,this.zoom,e=>e.startsWith("icon"))),this.glyphOffsetArray=new Py,this.lineVertexArray=new Ay,this.symbolInstances=new Ey,this.textAnchorOffsets=new Iy}calculateGlyphDependencies(e,t,r,i,a){var l;let n=(i||this.allowVerticalPlacement)&&a,s=Sd.fromFeature(e,r),o=s.graphemes();for(let u=0;u<o.length;u++){let h=s.getSection(u);if("imageName"in h)continue;let c=(t[l=h.fontStack]||(t[l]={default:{}})).default,d=o[u];al(d)&&(c[d]=!0);for(let p of d){if(c[p]=!0,!n)continue;let f=Aa[p];f&&(c[f]=!0)}}}populate(e,t,r){var m;let i=this.layers[0],a=i.layout,n=a.get("text-font"),s=a.get("text-field"),o=a.get("icon-image"),l=(s.value.kind!=="constant"||s.value.value instanceof ui&&!s.value.value.isEmpty()||s.value.value.toString().length>0)&&(n.value.kind!=="constant"||n.value.value.length>0),u=o.value.kind!=="constant"||!!o.value.value||Object.keys(o.parameters).length>0,h=a.get("symbol-sort-key");if(this.features=[],!l&&!u)return;let c=t.iconDependencies,d=t.glyphDependencies,p=t.availableImages,f=new ze(this.zoom);for(let{feature:g,id:_,index:y,sourceLayerIndex:v}of e){let x=i._featureFilter.needGeometry,w=aa(g,x);if(!i._featureFilter.filter(f,w,r))continue;x||(w.geometry=ia(g));let b;if(l){let I=i.getValueAndResolveTokens("text-field",w,r,p),R=ui.factory(I);this.hasRTLText||(this.hasRTLText=aE(R)),b=NS(R,i,w)}let S;if(u){let I=i.getValueAndResolveTokens("icon-image",w,r,p);S=I instanceof Zr?I:Zr.fromString(I)}if(!b&&!S)continue;let A=this.sortFeaturesByKey?h.evaluate(w,{},r):void 0,P={id:_,text:b,icon:S,index:y,sourceLayerIndex:v,geometry:w.geometry,properties:g.properties,type:ys.types[g.type],sortKey:A};if(this.features.push(P),S&&(c[S.name]=!0),b){let I=n.evaluate(w,{},r).join(","),R=a.get("text-rotation-alignment")!=="viewport"&&a.get("symbol-placement")!=="point";this.allowVerticalPlacement=(m=this.writingModes)==null?void 0:m.includes(2);let F=gc(b.toString());this.calculateGlyphDependencies(b,d,I,R,F);for(let T of b.sections)T.image&&(c[T.image.name]=!0)}}a.get("symbol-placement")==="line"&&(this.features=GS(this.features)),this.sortFeaturesByKey&&this.features.sort((g,_)=>g.sortKey-_.sortKey)}update(e,t,r){this.stateDependentLayers.length&&(this.text.programConfigurations.updatePaintArrays(e,t,this.layers,{imagePositions:r}),this.icon.programConfigurations.updatePaintArrays(e,t,this.layers,{imagePositions:r}))}addFeatures({options:e,canonical:t,glyphMap:r,glyphPositions:i,iconMap:a,iconPositions:n,showCollisionBoxes:s}){KD({bucket:this,glyphMap:r,glyphPositions:i,imageMap:a,imagePositions:n,showCollisionBoxes:s,canonical:t,subdivisionGranularity:e.subdivisionGranularity,hasPromoteId:e.featureIndex.promoteId!=null})}isEmpty(){return this.symbolInstances.length===0}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 r=this.lineVertexArray.length;if(e.segment!==void 0){let i=e.dist(t[e.segment+1]),a=e.dist(t[e.segment]),n={};for(let s=e.segment+1;s<t.length;s++)n[s]={x:t[s].x,y:t[s].y,tileUnitDistanceFromAnchor:i},s<t.length-1&&(i+=t[s+1].dist(t[s]));for(let s=e.segment||0;s>=0;s--)n[s]={x:t[s].x,y:t[s].y,tileUnitDistanceFromAnchor:a},s>0&&(a+=t[s-1].dist(t[s]));for(let s=0;s<t.length;s++){let o=n[s];this.lineVertexArray.emplaceBack(o.x,o.y,o.tileUnitDistanceFromAnchor)}}return{lineStartIndex:r,lineLength:this.lineVertexArray.length-r}}addSymbols(e,t,r,i,a,n,s,o,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),g=this.glyphOffsetArray.length,_=m.vertexLength,y=this.allowVerticalPlacement&&s===2?Math.PI/2:0,v=n.text&&n.text.sections;for(let x=0;x<t.length;x++){let{tl:w,tr:b,bl:S,br:A,tex:P,pixelOffsetTL:I,pixelOffsetBR:R,minFontScaleX:F,minFontScaleY:T,glyphOffset:E,isSDF:D,sectionIndex:C}=t[x],k=m.vertexLength,B=E[1];ao(f,o.x,o.y,w.x,B+w.y,P.x,P.y,r,D,I.x,I.y,F,T,d),ao(f,o.x,o.y,b.x,B+b.y,P.x+P.w,P.y,r,D,R.x,I.y,F,T,d),ao(f,o.x,o.y,S.x,B+S.y,P.x,P.y+P.h,r,D,I.x,R.y,F,T,d),ao(f,o.x,o.y,A.x,B+A.y,P.x+P.w,P.y+P.h,r,D,R.x,R.y,F,T,d),ol(e.dynamicLayoutVertexArray,o,y),p.emplaceBack(k,k+2,k+1),p.emplaceBack(k+1,k+2,k+3),m.vertexLength+=4,m.primitiveLength+=2,this.glyphOffsetArray.emplaceBack(E[0]),(x===t.length-1||C!==t[x+1].sectionIndex)&&e.programConfigurations.populatePaintArrays(f.length,n,n.index,{imagePositions:{},canonical:c,formattedSection:v==null?void 0:v[C]})}e.placedSymbolArray.emplaceBack(o.x,o.y,g,this.glyphOffsetArray.length-g,_,l,u,o.segment,r?r[0]:0,r?r[1]:0,i[0],i[1],s,0,!1,0,h,d)}_addCollisionDebugVertex(e,t,r,i,a,n){return t.emplaceBack(0,0),e.emplaceBack(r.x,r.y,i,a,Math.round(n.x),Math.round(n.y))}addCollisionDebugVertices(e,t,r,i,a,n,s){let o=a.segments.prepareSegment(4,a.layoutVertexArray,a.indexArray),l=o.vertexLength,u=a.layoutVertexArray,h=a.collisionVertexArray,c=s.anchorX,d=s.anchorY;this._addCollisionDebugVertex(u,h,n,c,d,new M(e,t)),this._addCollisionDebugVertex(u,h,n,c,d,new M(r,t)),this._addCollisionDebugVertex(u,h,n,c,d,new M(r,i)),this._addCollisionDebugVertex(u,h,n,c,d,new M(e,i)),o.vertexLength+=4;let p=a.indexArray;p.emplaceBack(l,l+1),p.emplaceBack(l+1,l+2),p.emplaceBack(l+2,l+3),p.emplaceBack(l+3,l),o.primitiveLength+=4}addDebugCollisionBoxes(e,t,r,i){for(let a=e;a<t;a++){let n=this.collisionBoxArray.get(a),s=n.x1,o=n.y1,l=n.x2,u=n.y2;this.addCollisionDebugVertices(s,o,l,u,i?this.textCollisionBox:this.iconCollisionBox,n.anchorPoint,r)}}generateCollisionDebugBuffers(){this.hasDebugData()&&this.destroyDebugData(),this.textCollisionBox=new wc(vf,Bf.members,Qh),this.iconCollisionBox=new wc(vf,Bf.members,Qh);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,r,i,a,n,s,o,l){let u={};for(let h=t;h<r;h++){let c=e.get(h);u.textBox={x1:c.x1,y1:c.y1,x2:c.x2,y2:c.y2,anchorPointX:c.anchorPointX,anchorPointY:c.anchorPointY},u.textFeatureIndex=c.featureIndex;break}for(let h=i;h<a;h++){let c=e.get(h);u.verticalTextBox={x1:c.x1,y1:c.y1,x2:c.x2,y2:c.y2,anchorPointX:c.anchorPointX,anchorPointY:c.anchorPointY},u.verticalTextFeatureIndex=c.featureIndex;break}for(let h=n;h<s;h++){let c=e.get(h);u.iconBox={x1:c.x1,y1:c.y1,x2:c.x2,y2:c.y2,anchorPointX:c.anchorPointX,anchorPointY:c.anchorPointY},u.iconFeatureIndex=c.featureIndex;break}for(let h=o;h<l;h++){let c=e.get(h);u.verticalIconBox={x1:c.x1,y1:c.y1,x2:c.x2,y2:c.y2,anchorPointX:c.anchorPointX,anchorPointY:c.anchorPointY},u.verticalIconFeatureIndex=c.featureIndex;break}return u}deserializeCollisionBoxes(e){this.collisionArrays=[];for(let t=0;t<this.symbolInstances.length;t++){let r=this.symbolInstances.get(t);this.collisionArrays.push(this._deserializeCollisionBoxesForSymbol(e,r.textBoxStartIndex,r.textBoxEndIndex,r.verticalTextBoxStartIndex,r.verticalTextBoxEndIndex,r.iconBoxStartIndex,r.iconBoxEndIndex,r.verticalIconBoxStartIndex,r.verticalIconBoxEndIndex))}}hasTextData(){return this.text.segments.get().length>0}hasIconData(){return this.icon.segments.get().length>0}hasDebugData(){return this.textCollisionBox&&this.iconCollisionBox}hasTextCollisionBoxData(){return this.hasDebugData()&&this.textCollisionBox.segments.get().length>0}hasIconCollisionBoxData(){return this.hasDebugData()&&this.iconCollisionBox.segments.get().length>0}addIndicesForPlacedSymbol(e,t){let r=e.placedSymbolArray.get(t),i=r.vertexStartIndex+r.numGlyphs*4;for(let a=r.vertexStartIndex;a<i;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&&this.symbolInstanceIndexes!==void 0)return this.symbolInstanceIndexes;let t=Math.sin(e),r=Math.cos(e),i=[],a=[],n=[];for(let s=0;s<this.symbolInstances.length;++s){n.push(s);let o=this.symbolInstances.get(s);i.push(Math.round(t*o.anchorX+r*o.anchorY)|0),a.push(o.featureIndex)}return n.sort((s,o)=>i[s]-i[o]||a[o]-a[s]),n}addToSortKeyRanges(e,t){let r=this.sortKeyRanges[this.sortKeyRanges.length-1];(r==null?void 0:r.sortKey)===t?r.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 t of this.symbolInstanceIndexes){let r=this.symbolInstances.get(t);this.featureSortOrder.push(r.featureIndex);let i=[r.rightJustifiedTextSymbolIndex,r.centerJustifiedTextSymbolIndex,r.leftJustifiedTextSymbolIndex];for(let a=0;a<i.length;a++){let n=i[a];n>=0&&i.indexOf(n)===a&&this.addIndicesForPlacedSymbol(this.text,n)}r.verticalPlacedTextSymbolIndex>=0&&this.addIndicesForPlacedSymbol(this.text,r.verticalPlacedTextSymbolIndex),r.placedIconSymbolIndex>=0&&this.addIndicesForPlacedSymbol(this.icon,r.placedIconSymbolIndex),r.verticalPlacedIconSymbolIndex>=0&&this.addIndicesForPlacedSymbol(this.icon,r.verticalPlacedIconSymbolIndex)}this.text.indexBuffer&&this.text.indexBuffer.updateData(this.text.indexArray),this.icon.indexBuffer&&this.icon.indexBuffer.updateData(this.icon.indexArray)}}};G("SymbolBucket",ll,{omit:["layers","collisionBoxArray","features","compareText"]});function nE(e,t){return t.replace(/{([^{}]+)}/g,(r,i)=>e&&i in e?String(e[i]):"")}let sE;const oE=()=>sE||(sE=new wt({"symbol-placement":new N(z.layout_symbol["symbol-placement"],"symbol-placement"),"symbol-spacing":new N(z.layout_symbol["symbol-spacing"],"symbol-spacing"),"symbol-avoid-edges":new N(z.layout_symbol["symbol-avoid-edges"],"symbol-avoid-edges"),"symbol-sort-key":new K(z.layout_symbol["symbol-sort-key"],"symbol-sort-key"),"symbol-z-order":new N(z.layout_symbol["symbol-z-order"],"symbol-z-order"),"icon-allow-overlap":new N(z.layout_symbol["icon-allow-overlap"],"icon-allow-overlap"),"icon-overlap":new N(z.layout_symbol["icon-overlap"],"icon-overlap"),"icon-ignore-placement":new N(z.layout_symbol["icon-ignore-placement"],"icon-ignore-placement"),"icon-optional":new N(z.layout_symbol["icon-optional"],"icon-optional"),"icon-rotation-alignment":new K(z.layout_symbol["icon-rotation-alignment"],"icon-rotation-alignment"),"icon-size":new K(z.layout_symbol["icon-size"],"icon-size"),"icon-text-fit":new N(z.layout_symbol["icon-text-fit"],"icon-text-fit"),"icon-text-fit-padding":new N(z.layout_symbol["icon-text-fit-padding"],"icon-text-fit-padding"),"icon-image":new K(z.layout_symbol["icon-image"],"icon-image"),"icon-rotate":new K(z.layout_symbol["icon-rotate"],"icon-rotate"),"icon-padding":new K(z.layout_symbol["icon-padding"],"icon-padding"),"icon-keep-upright":new N(z.layout_symbol["icon-keep-upright"],"icon-keep-upright"),"icon-offset":new K(z.layout_symbol["icon-offset"],"icon-offset"),"icon-anchor":new K(z.layout_symbol["icon-anchor"],"icon-anchor"),"icon-pitch-alignment":new N(z.layout_symbol["icon-pitch-alignment"],"icon-pitch-alignment"),"text-pitch-alignment":new N(z.layout_symbol["text-pitch-alignment"],"text-pitch-alignment"),"text-rotation-alignment":new N(z.layout_symbol["text-rotation-alignment"],"text-rotation-alignment"),"text-field":new K(z.layout_symbol["text-field"],"text-field"),"text-font":new K(z.layout_symbol["text-font"],"text-font"),"text-size":new K(z.layout_symbol["text-size"],"text-size"),"text-max-width":new K(z.layout_symbol["text-max-width"],"text-max-width"),"text-line-height":new N(z.layout_symbol["text-line-height"],"text-line-height"),"text-letter-spacing":new K(z.layout_symbol["text-letter-spacing"],"text-letter-spacing"),"text-justify":new K(z.layout_symbol["text-justify"],"text-justify"),"text-radial-offset":new K(z.layout_symbol["text-radial-offset"],"text-radial-offset"),"text-variable-anchor":new N(z.layout_symbol["text-variable-anchor"],"text-variable-anchor"),"text-variable-anchor-offset":new K(z.layout_symbol["text-variable-anchor-offset"],"text-variable-anchor-offset"),"text-anchor":new K(z.layout_symbol["text-anchor"],"text-anchor"),"text-max-angle":new N(z.layout_symbol["text-max-angle"],"text-max-angle"),"text-writing-mode":new N(z.layout_symbol["text-writing-mode"],"text-writing-mode"),"text-rotate":new K(z.layout_symbol["text-rotate"],"text-rotate"),"text-padding":new N(z.layout_symbol["text-padding"],"text-padding"),"text-keep-upright":new N(z.layout_symbol["text-keep-upright"],"text-keep-upright"),"text-transform":new K(z.layout_symbol["text-transform"],"text-transform"),"text-offset":new K(z.layout_symbol["text-offset"],"text-offset"),"text-allow-overlap":new N(z.layout_symbol["text-allow-overlap"],"text-allow-overlap"),"text-overlap":new N(z.layout_symbol["text-overlap"],"text-overlap"),"text-ignore-placement":new N(z.layout_symbol["text-ignore-placement"],"text-ignore-placement"),"text-optional":new N(z.layout_symbol["text-optional"],"text-optional"),"symbol-height-offset":new K(z.layout_symbol["symbol-height-offset"],"symbol-height-offset"),"symbol-height-anchor":new N(z.layout_symbol["symbol-height-anchor"],"symbol-height-anchor")}));let lE;const uE=()=>lE||(lE=new wt({"icon-opacity":new K(z.paint_symbol["icon-opacity"],"icon-opacity"),"icon-color":new K(z.paint_symbol["icon-color"],"icon-color"),"icon-halo-color":new K(z.paint_symbol["icon-halo-color"],"icon-halo-color"),"icon-halo-width":new K(z.paint_symbol["icon-halo-width"],"icon-halo-width"),"icon-halo-blur":new K(z.paint_symbol["icon-halo-blur"],"icon-halo-blur"),"icon-translate":new N(z.paint_symbol["icon-translate"],"icon-translate"),"icon-translate-anchor":new N(z.paint_symbol["icon-translate-anchor"],"icon-translate-anchor"),"text-opacity":new K(z.paint_symbol["text-opacity"],"text-opacity"),"text-color":new K(z.paint_symbol["text-color"],"text-color",{runtimeType:Dr,getOverride:e=>e.textColor,hasOverride:e=>!!e.textColor}),"text-halo-color":new K(z.paint_symbol["text-halo-color"],"text-halo-color"),"text-halo-width":new K(z.paint_symbol["text-halo-width"],"text-halo-width"),"text-halo-blur":new K(z.paint_symbol["text-halo-blur"],"text-halo-blur"),"text-translate":new N(z.paint_symbol["text-translate"],"text-translate"),"text-translate-anchor":new N(z.paint_symbol["text-translate-anchor"],"text-translate-anchor")}));var ju={get paint(){return uE()},get layout(){return oE()}},L0=class{constructor(e){if(e.property.overrides===void 0)throw Error("overrides must be provided to instantiate FormatSectionOverride class");this.type=e.property.overrides?e.property.overrides.runtimeType:hs,this.defaultValue=e}evaluate(e){if(e.formattedSection){let t=this.defaultValue.property.overrides;if(t!=null&&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){if(!this.defaultValue.isConstant()){let t=this.defaultValue.value;e(t._styleExpression.expression)}}outputDefined(){return!1}serialize(){return null}};G("FormatSectionOverride",L0,{omit:["defaultValue"]});const B0=e=>e.type==="symbol";var hE=class Tc extends Ir{constructor(t,r){super(t,ju,r)}recalculate(t,r){super.recalculate(t,r);let i=this.layout.get("icon-rotation-alignment");if((i.value.kind!=="constant"||i.value.value==="auto")&&(this.layout._values["icon-rotation-alignment"]=new mr(i.property,{kind:"constant",value:this.layout.get("symbol-placement")==="point"?"viewport":"map"},i.parameters)),this.layout.get("text-rotation-alignment")==="auto"&&(this.layout.get("symbol-placement")==="point"?this.layout._values["text-rotation-alignment"]="viewport":this.layout._values["text-rotation-alignment"]="map"),this.layout.get("text-pitch-alignment")==="auto"&&(this.layout._values["text-pitch-alignment"]=this.layout.get("text-rotation-alignment")==="map"?"map":"viewport"),this.layout.get("icon-pitch-alignment")==="auto"&&(this.layout._values["icon-pitch-alignment"]=this.layout.get("icon-rotation-alignment").constantOr("viewport")),this.layout.get("symbol-placement")==="point"){let a=this.layout.get("text-writing-mode");if(a){let n=[];for(let s of a)n.includes(s)||n.push(s);this.layout._values["text-writing-mode"]=n}else this.layout._values["text-writing-mode"]=["horizontal"]}this._setPaintOverrides()}getValueAndResolveTokens(t,r,i,a){let n=this.layout.get(t).evaluate(r,{},i,a),s=this._unevaluatedLayout._values[t];return!s.isDataDriven()&&!Ml(s.value)&&n?nE(r.properties,n):n}createBucket(t){return new ll(t)}queryRadius(){return 0}queryIntersectsFeature(){throw Error("Should take a different path in FeatureIndex")}_setPaintOverrides(){for(let t of ju.paint.overridableProperties){if(!Tc.hasPaintOverride(this.layout,t))continue;let r=this.paint.get(t),i=new ld(new L0(r),`layers[${this.id}].paint.${r.property.name}`,r.property.specification),a=null;a=r.value.kind==="constant"||r.value.kind==="source"?new Wn("source",i):new Zo("composite",i,r.value.zoomStops),this.paint._values[t]=new mr(r.property,a,r.parameters)}}_handleOverridablePaintPropertyUpdate(t,r,i){return!this.layout||r.isDataDriven()||i.isDataDriven()?!1:Tc.hasPaintOverride(this.layout,t)}static hasPaintOverride(t,r){let i=t.get("text-field"),a=ju.paint.properties[r],n=!1,s=o=>{var l;for(let u of o)if((l=a.overrides)!=null&&l.hasOverride(u)){n=!0;return}};if(i.value.kind==="constant"&&i.value.value instanceof ui)s(i.value.value.sections);else if(i.value.kind==="source"||i.value.kind==="composite"){let o=u=>{if(!n)if(u instanceof Na&&it(u.value)===cs){let h=u.value;s(h.sections)}else u instanceof h_?s(u.sections):u.eachChild(o)},l=i.value;l._styleExpression&&o(l._styleExpression.expression)}return n}};function cE(e,t,r,i=1){var n;let a=(n=e.get("icon-padding").evaluate(t,{},r))==null?void 0:n.values;return[a[0]*i,a[1]*i,a[2]*i,a[3]*i]}let dE;const pE=()=>dE||(dE=new wt({"background-color":new N(z.paint_background["background-color"],"background-color"),"background-pattern":new vy(z.paint_background["background-pattern"],"background-pattern"),"background-opacity":new N(z.paint_background["background-opacity"],"background-opacity")}));var fE={get paint(){return pE()}};const mE=e=>e.type==="background";var gE=class extends Ir{constructor(e,t){super(e,fE,t)}};function _E(e){let t=[],r=e.id;return r===void 0&&t.push(new O(`layers.${r}`,null,'missing required property "id"')),e.render===void 0&&t.push(new O(`layers.${r}`,null,'missing required method "render"')),e.renderingMode&&e.renderingMode!=="2d"&&e.renderingMode!=="3d"&&t.push(new O(`layers.${r}`,null,'property "renderingMode" must be either "2d" or "3d"')),t}const yE=e=>e.type==="custom";var xE=class extends Ir{constructor(e,t){super(e,{},t),this.onAdd=r=>{this.implementation.onAdd&&this.implementation.onAdd(r,r.painter.context.gl)},this.onRemove=r=>{this.implementation.onRemove&&this.implementation.onRemove(r,r.painter.context.gl)},this.implementation=e}is3D(){return this.implementation.renderingMode==="3d"}hasOffscreenPass(){return this.implementation.prerender!==void 0}recalculate(){}updateTransitions(){}hasTransition(){return!1}serialize(){throw Error("Custom layers cannot be serialized")}};function Vu(e,t){if(e.type==="custom")return new xE(e,t);switch(e.type){case"background":return new gE(e,t);case"circle":return new Iw(e,t);case"color-relief":return new Zw(e,t);case"fill":return new PT(e,t);case"fill-extrusion":return new KT(e,t);case"heatmap":return new kw(e,t);case"hillshade":return new jw(e,t);case"line":return new fS(e,t);case"raster":return new $2(e,t);case"symbol":return new hE(e,t)}}var vE=class{constructor(e){this._methodToThrottle=e,this._triggered=!1,this._channel=new MessageChannel,this._channel.port2.onmessage=()=>{this._triggered=!1,this._methodToThrottle()}}trigger(){var e;this._triggered||(this._triggered=!0,(e=this._channel)==null||e.port1.postMessage(!0))}remove(){delete this._channel,this._methodToThrottle=()=>{}}};const bE={once:!0};var wE=class{constructor(e,t){this.target=e,this.mapId=t,this.resolveRejects={},this.tasks={},this.taskQueue=[],this.abortControllers={},this.messageHandlers={},this.invoker=new vE(()=>this.process()),this.subscription=jo(this.target,"message",r=>this.receive(r),!1),this.globalScope=$a(self)?e:window}registerMessageHandler(e,t){this.messageHandlers[e]=t}unregisterMessageHandler(e){delete this.messageHandlers[e]}sendAsync(e,t){return new Promise((r,i)=>{let a=Math.round(Math.random()*1e18).toString(36).substring(0,10),n=t?jo(t.signal,"abort",()=>{n==null||n.unsubscribe(),delete this.resolveRejects[a];let l={id:a,type:"<cancel>",origin:location.origin,targetMapId:e.targetMapId,sourceMapId:this.mapId};this.target.postMessage(l),i(new ls(t.signal.reason))},bE):null;this.resolveRejects[a]={resolve:l=>{n==null||n.unsubscribe(),r(l)},reject:l=>{n==null||n.unsubscribe(),i(l)}};let s=[],o={...e,id:a,sourceMapId:this.mapId,origin:location.origin,data:kn(e.data,s)};this.target.postMessage(o,{transfer:s})})}receive(e){let t=e.data,r=t.id,i=["file://","resource://android","null"],a=[t.origin,location.origin],n=t.origin===location.origin,s=a.some(o=>i.includes(o));if((n||s)&&!(t.targetMapId&&this.mapId!==t.targetMapId)){if(t.type==="<cancel>"){delete this.tasks[r];let o=this.abortControllers[r];delete this.abortControllers[r],o&&o.abort();return}if($a(self)||t.mustQueue){this.tasks[r]=t,this.taskQueue.push(r),this.invoker.trigger();return}this.processTask(r,t)}}process(){if(this.taskQueue.length===0)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(t.type==="<response>"){let a=this.resolveRejects[e];if(delete this.resolveRejects[e],!a)return;t.error?a.reject(zt(Ln(t.error))):a.resolve(Ln(t.data));return}if(!this.messageHandlers[t.type]){this.completeTask(e,null,null);return}let r=Ln(t.data),i=new AbortController;this.abortControllers[e]=i;try{let a=await this.messageHandlers[t.type](t.sourceMapId,r,i);this.completeTask(e,null,a)}catch(a){this.completeTask(e,zt(a))}}completeTask(e,t,r){let i=[];delete this.abortControllers[e];let a={id:e,type:"<response>",sourceMapId:this.mapId,origin:location.origin,error:t?kn(t):null,data:kn(r,i)};this.target.postMessage(a,{transfer:i})}remove(){this.invoker.remove(),this.subscription.unsubscribe()}};function TE(e,t,r){return!(e<0||e>25||r<0||r>=2**e||t<0||t>=2**e)}function nm(e,t){let{x:r,y:i}=Ie.fromLngLat(t);return!(e<0||e>25||i<0||i>=1||r<0||r>=1)}var Ul=class{constructor(e,t,r){if(!TE(e,t,r))throw Error(`x=${t}, y=${r}, z=${e} outside of bounds. 0<=x<${2**e}, 0<=y<${2**e} 0<=z<=25 `);this.z=e,this.x=t,this.y=r,this.key=Ra(0,e,e,t,r)}equals(e){return this.z===e.z&&this.x===e.x&&this.y===e.y}url(e,t,r){let i=SE(this.x,this.y,this.z),a=DE(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(r==="tms"?2**this.z-this.y-1:this.y)).replace(/{ratio}/g,t>1?"@2x":"").replace(/{quadkey}/g,a).replace(/{bbox-epsg-3857}/g,i)}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 M((e.x*t-this.x)*L,(e.y*t-this.y)*L)}toString(){return`${this.z}/${this.x}/${this.y}`}},ul=class{constructor(e,t){this.wrap=e,this.canonical=t,this.key=Ra(e,t.z,t.z,t.x,t.y)}},Dt=class cr{constructor(t,r,i,a,n){if(this.terrainRttPosMatrix32f=null,t<i)throw Error(`overscaledZ should be >= z; overscaledZ = ${t}; z = ${i}`);this.overscaledZ=t,this.wrap=r,this.canonical=new Ul(i,+a,+n),this.key=Ra(r,t,i,a,n)}clone(){return new cr(this.overscaledZ,this.wrap,this.canonical.z,this.canonical.x,this.canonical.y)}equals(t){return this.overscaledZ===t.overscaledZ&&this.wrap===t.wrap&&this.canonical.equals(t.canonical)}scaledTo(t){if(t>this.overscaledZ)throw Error(`targetZ > this.overscaledZ; targetZ = ${t}; overscaledZ = ${this.overscaledZ}`);let r=this.canonical.z-t;return t>this.canonical.z?new cr(t,this.wrap,this.canonical.z,this.canonical.x,this.canonical.y):new cr(t,this.wrap,t,this.canonical.x>>r,this.canonical.y>>r)}isOverscaled(){return this.overscaledZ>this.canonical.z}calculateScaledKey(t,r){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?Ra(this.wrap*+r,t,this.canonical.z,this.canonical.x,this.canonical.y):Ra(this.wrap*+r,t,t,this.canonical.x>>i,this.canonical.y>>i)}isChildOf(t){if(t.wrap!==this.wrap||this.overscaledZ-t.overscaledZ<=0)return!1;if(t.overscaledZ===0)return this.overscaledZ>0;let r=this.canonical.z-t.canonical.z;return r<0?!1:t.canonical.x===this.canonical.x>>r&&t.canonical.y===this.canonical.y>>r}children(t){if(this.overscaledZ>=t)return[new cr(this.overscaledZ+1,this.wrap,this.canonical.z,this.canonical.x,this.canonical.y)];let r=this.canonical.z+1,i=this.canonical.x*2,a=this.canonical.y*2;return[new cr(r,this.wrap,r,i,a),new cr(r,this.wrap,r,i+1,a),new cr(r,this.wrap,r,i,a+1),new cr(r,this.wrap,r,i+1,a+1)]}isLessThan(t){return this.wrap<t.wrap?!0:this.wrap>t.wrap?!1:this.overscaledZ<t.overscaledZ?!0:this.overscaledZ>t.overscaledZ?!1:this.canonical.x<t.canonical.x?!0:this.canonical.x>t.canonical.x?!1:this.canonical.y<t.canonical.y}wrapped(){return new cr(this.overscaledZ,0,this.canonical.z,this.canonical.x,this.canonical.y)}unwrapTo(t){return new cr(this.overscaledZ,t,this.canonical.z,this.canonical.x,this.canonical.y)}overscaleFactor(){return 2**(this.overscaledZ-this.canonical.z)}toUnwrapped(){return new ul(this.wrap,this.canonical)}toString(){return`${this.overscaledZ}/${this.canonical.x}/${this.canonical.y}`}getTilePoint(t){return this.canonical.getTilePoint(new Ie(t.x-this.wrap,t.y))}normalizeCoordinates(t,r,i=L){if(t>=0&&t<i&&r>=0&&r<i)return{tileID:this,x:t,y:r};let a=Math.floor(t/i),n=Math.floor(r/i),s=t-a*i,o=r-n*i,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 cr(this.overscaledZ,d,l,c,h),x:s,y:o}}};function Ra(e,t,r,i,a){e*=2,e<0&&(e=e*-1-1);let n=1<<r;return(n*n*e+n*a+i).toString(36)+r.toString(36)+t.toString(36)}const Nu=Math.PI*6378137;function SE(e,t,r){t=2**r-t-1;let i=sm(e*256,t*256,r),a=sm((e+1)*256,(t+1)*256,r);return`${i[0]},${i[1]},${a[0]},${a[1]}`}function sm(e,t,r){let i=2*Nu/256/2**r;return[e*i-Nu,t*i-Nu]}function DE(e,t,r){let i="";for(let a=e;a>0;a--){let n=1<<a-1;i+=(t&n?1:0)+(r&n?2:0)}return i}function om(e,t){let r=Math.abs(e.wrap*2)-+(e.wrap<0),i=Math.abs(t.wrap*2)-+(t.wrap<0);return e.overscaledZ-t.overscaledZ||i-r||t.canonical.y-e.canonical.y||t.canonical.x-e.canonical.x}G("CanonicalTileID",Ul),G("OverscaledTileID",Dt,{omit:["terrainRttPosMatrix32f"]});const Mo="_geojsonTileLayer";var EE=class{constructor(e){this._stringToNumber={},this._numberToString=[];for(let t=0;t<e.length;t++){let r=e[t];this._stringToNumber[r]=t,this._numberToString[t]=r}}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]}},O0=class{constructor(e,t,r,i,a){this.type="Feature",this._vectorTileFeature=e,this._x=r,this._y=i,this._z=t;for(let n in e.properties)typeof e.properties[n]=="string"&&e.properties[n].startsWith("__$json__:")&&(e.properties[n]=JSON.parse(e.properties[n].slice(10)));this.properties=e.properties,this.id=a}projectPoint(e,t,r,i){return[(e.x+t)*360/i-180,360/Math.PI*Math.atan(Math.exp((1-(e.y+r)*2/i)*Math.PI))-90]}projectLine(e,t,r,i){return e.map(a=>this.projectPoint(a,t,r,i))}get geometry(){if(this._geometry)return this._geometry;let e=this._vectorTileFeature,t=e.extent*2**this._z,r=e.extent*this._x,i=e.extent*this._y,a=e.loadGeometry();switch(e.type){case 1:{let n=[];for(let o of a)n.push(o[0]);let s=this.projectLine(n,r,i,t);this._geometry=n.length===1?{type:"Point",coordinates:s[0]}:{type:"MultiPoint",coordinates:s};break}case 2:{let n=a.map(s=>this.projectLine(s,r,i,t));this._geometry=n.length===1?{type:"LineString",coordinates:n[0]}:{type:"MultiLineString",coordinates:n};break}case 3:{let n=r0(a),s=[];for(let o of n)s.push(o.map(l=>this.projectLine(l,r,i,t)));this._geometry=s.length===1?{type:"Polygon",coordinates:s[0]}:{type:"MultiPolygon",coordinates:s};break}default:throw Error(`unknown feature type: ${e.type}`)}return this._geometry}set geometry(e){this._geometry=e}toJSON(){let e={geometry:this.geometry};for(let t in this)t!=="_geometry"&&t!=="_vectorTileFeature"&&t!=="_x"&&t!=="_y"&&t!=="_z"&&(e[t]=this[t]);return e}},na=class{constructor(e,t,r){this._name=e,this.dataBuffer=t,typeof r=="number"?this._size=r:(this.nullabilityBuffer=r,this._size=r.size())}getValue(e){return this.nullabilityBuffer&&!this.nullabilityBuffer.get(e)?null:this.getValueFromBuffer(e)}has(e){var t;return((t=this.nullabilityBuffer)==null?void 0:t.get(e))||!this.nullabilityBuffer}get name(){return this._name}get size(){return this._size}},Gl=class extends na{},Cd=class extends Gl{getValueFromBuffer(e){return this.dataBuffer[e]}},Id=class extends Gl{getValueFromBuffer(e){return this.dataBuffer[e]}},$0=class extends na{constructor(e,t,r,i){super(e,t,i),this.delta=r}},Md=class extends $0{constructor(e,t,r,i,a){super(e,a?Int32Array.of(t):Uint32Array.of(t),r,i)}getValueFromBuffer(e){return this.dataBuffer[0]+e*this.delta}},zd=class extends na{constructor(e,t,r,i){super(e,i?Int32Array.of(t):Uint32Array.of(t),r)}getValueFromBuffer(e){return this.dataBuffer[0]}},PE=class{constructor(e,t,r,i,a=4096){if(this._name=e,this._geometryVector=t,this._idVector=r,this._propertyVectors=i,this._extent=a,e.length===0)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||(this.propertyVectorsMap=new Map(this.propertyVectors.map(t=>[t.name,t]))),this.propertyVectorsMap.get(e)}get numFeatures(){return this.geometryVector.numGeometries}get extent(){return this._extent}getFeatures(){let e=[],t=this.geometryVector.getGeometries();for(let r=0;r<this.numFeatures;r++){let i;if(this.idVector){let s=this.idVector.getValue(r);s!==null&&(i=this.containsMaxSafeIntegerValues(this.idVector)?Number(s):s)}let a={coordinates:t[r],type:this.geometryVector.geometryType(r)},n={};for(let s of this.propertyVectors){if(!s)continue;let o=s.name,l=s.getValue(r);l!==null&&(n[o]=l)}e.push({id:i,geometry:a,properties:n})}return e}containsMaxSafeIntegerValues(e){return e instanceof Cd||e instanceof zd||e instanceof Md||e instanceof Id}};const zn={FEATURE:0},Se={BOOLEAN:0,INT_8:1,UINT_8:2,INT_32:3,UINT_32:4,INT_64:5,UINT_64:6,FLOAT:7,DOUBLE:8,STRING:9},wi={GEOMETRY:0,STRUCT:1,MAP:2},j0={ID:0};var V0=class{constructor(e){this.value=e}get(){return this.value}set(e){this.value=e}increment(){return this.value++}add(e){this.value+=e}},he;(function(e){e.NONE="NONE",e.DELTA="DELTA",e.COMPONENTWISE_DELTA="COMPONENTWISE_DELTA",e.RLE="RLE",e.MORTON="MORTON"})(he||(he={}));var yr;(function(e){e.NONE="NONE",e.FAST_PFOR="FAST_PFOR",e.VARINT="VARINT"})(yr||(yr={}));const Fd=new Uint32Array(33);Fd[0]=0;for(let e=1;e<=32;e++)Fd[e]=e===32?4294967295:4294967295>>>32-e;const Sc=Fd,N0=65536;function Rd(e,t){return e-e%t}function AE(e){return Rd(e+31,32)}function CE(e){if(!Number.isFinite(e)||e<=0)return N0;let t=Rd(Math.floor(e),256);return t===0?256:t}function IE(e){let t=e>>>0;return((t&255)<<24|(t&65280)<<8|t>>>8&65280|t>>>24&255)>>>0}function ME(e,t,r,i){let a=i,n=e[t]>>>0,s=e[t+1]>>>0;r[a++]=n>>>0&3,r[a++]=n>>>2&3,r[a++]=n>>>4&3,r[a++]=n>>>6&3,r[a++]=n>>>8&3,r[a++]=n>>>10&3,r[a++]=n>>>12&3,r[a++]=n>>>14&3,r[a++]=n>>>16&3,r[a++]=n>>>18&3,r[a++]=n>>>20&3,r[a++]=n>>>22&3,r[a++]=n>>>24&3,r[a++]=n>>>26&3,r[a++]=n>>>28&3,r[a++]=n>>>30&3,r[a++]=s>>>0&3,r[a++]=s>>>2&3,r[a++]=s>>>4&3,r[a++]=s>>>6&3,r[a++]=s>>>8&3,r[a++]=s>>>10&3,r[a++]=s>>>12&3,r[a++]=s>>>14&3,r[a++]=s>>>16&3,r[a++]=s>>>18&3,r[a++]=s>>>20&3,r[a++]=s>>>22&3,r[a++]=s>>>24&3,r[a++]=s>>>26&3,r[a++]=s>>>28&3,r[a]=s>>>30&3}function zE(e,t,r,i){let a=i,n=e[t]>>>0,s=e[t+1]>>>0,o=e[t+2]>>>0;r[a++]=n>>>0&7,r[a++]=n>>>3&7,r[a++]=n>>>6&7,r[a++]=n>>>9&7,r[a++]=n>>>12&7,r[a++]=n>>>15&7,r[a++]=n>>>18&7,r[a++]=n>>>21&7,r[a++]=n>>>24&7,r[a++]=n>>>27&7,r[a++]=(n>>>30|(s&1)<<2)&7,r[a++]=s>>>1&7,r[a++]=s>>>4&7,r[a++]=s>>>7&7,r[a++]=s>>>10&7,r[a++]=s>>>13&7,r[a++]=s>>>16&7,r[a++]=s>>>19&7,r[a++]=s>>>22&7,r[a++]=s>>>25&7,r[a++]=s>>>28&7,r[a++]=(s>>>31|(o&3)<<1)&7,r[a++]=o>>>2&7,r[a++]=o>>>5&7,r[a++]=o>>>8&7,r[a++]=o>>>11&7,r[a++]=o>>>14&7,r[a++]=o>>>17&7,r[a++]=o>>>20&7,r[a++]=o>>>23&7,r[a++]=o>>>26&7,r[a]=o>>>29&7}function FE(e,t,r,i){let a=i,n=e[t]>>>0,s=e[t+1]>>>0,o=e[t+2]>>>0,l=e[t+3]>>>0;r[a++]=n>>>0&15,r[a++]=n>>>4&15,r[a++]=n>>>8&15,r[a++]=n>>>12&15,r[a++]=n>>>16&15,r[a++]=n>>>20&15,r[a++]=n>>>24&15,r[a++]=n>>>28&15,r[a++]=s>>>0&15,r[a++]=s>>>4&15,r[a++]=s>>>8&15,r[a++]=s>>>12&15,r[a++]=s>>>16&15,r[a++]=s>>>20&15,r[a++]=s>>>24&15,r[a++]=s>>>28&15,r[a++]=o>>>0&15,r[a++]=o>>>4&15,r[a++]=o>>>8&15,r[a++]=o>>>12&15,r[a++]=o>>>16&15,r[a++]=o>>>20&15,r[a++]=o>>>24&15,r[a++]=o>>>28&15,r[a++]=l>>>0&15,r[a++]=l>>>4&15,r[a++]=l>>>8&15,r[a++]=l>>>12&15,r[a++]=l>>>16&15,r[a++]=l>>>20&15,r[a++]=l>>>24&15,r[a]=l>>>28&15}function RE(e,t,r,i){let a=i,n=e[t]>>>0,s=e[t+1]>>>0,o=e[t+2]>>>0,l=e[t+3]>>>0,u=e[t+4]>>>0;r[a++]=n>>>0&31,r[a++]=n>>>5&31,r[a++]=n>>>10&31,r[a++]=n>>>15&31,r[a++]=n>>>20&31,r[a++]=n>>>25&31,r[a++]=(n>>>30|(s&7)<<2)&31,r[a++]=s>>>3&31,r[a++]=s>>>8&31,r[a++]=s>>>13&31,r[a++]=s>>>18&31,r[a++]=s>>>23&31,r[a++]=(s>>>28|(o&1)<<4)&31,r[a++]=o>>>1&31,r[a++]=o>>>6&31,r[a++]=o>>>11&31,r[a++]=o>>>16&31,r[a++]=o>>>21&31,r[a++]=o>>>26&31,r[a++]=(o>>>31|(l&15)<<1)&31,r[a++]=l>>>4&31,r[a++]=l>>>9&31,r[a++]=l>>>14&31,r[a++]=l>>>19&31,r[a++]=l>>>24&31,r[a++]=(l>>>29|(u&3)<<3)&31,r[a++]=u>>>2&31,r[a++]=u>>>7&31,r[a++]=u>>>12&31,r[a++]=u>>>17&31,r[a++]=u>>>22&31,r[a]=u>>>27&31}function kE(e,t,r,i){let a=i,n=e[t]>>>0,s=e[t+1]>>>0,o=e[t+2]>>>0,l=e[t+3]>>>0,u=e[t+4]>>>0,h=e[t+5]>>>0;r[a++]=n>>>0&63,r[a++]=n>>>6&63,r[a++]=n>>>12&63,r[a++]=n>>>18&63,r[a++]=n>>>24&63,r[a++]=(n>>>30|(s&15)<<2)&63,r[a++]=s>>>4&63,r[a++]=s>>>10&63,r[a++]=s>>>16&63,r[a++]=s>>>22&63,r[a++]=(s>>>28|(o&3)<<4)&63,r[a++]=o>>>2&63,r[a++]=o>>>8&63,r[a++]=o>>>14&63,r[a++]=o>>>20&63,r[a++]=o>>>26&63,r[a++]=l>>>0&63,r[a++]=l>>>6&63,r[a++]=l>>>12&63,r[a++]=l>>>18&63,r[a++]=l>>>24&63,r[a++]=(l>>>30|(u&15)<<2)&63,r[a++]=u>>>4&63,r[a++]=u>>>10&63,r[a++]=u>>>16&63,r[a++]=u>>>22&63,r[a++]=(u>>>28|(h&3)<<4)&63,r[a++]=h>>>2&63,r[a++]=h>>>8&63,r[a++]=h>>>14&63,r[a++]=h>>>20&63,r[a]=h>>>26&63}function LE(e,t,r,i){let a=i,n=e[t]>>>0,s=e[t+1]>>>0,o=e[t+2]>>>0,l=e[t+3]>>>0,u=e[t+4]>>>0,h=e[t+5]>>>0,c=e[t+6]>>>0;r[a++]=n>>>0&127,r[a++]=n>>>7&127,r[a++]=n>>>14&127,r[a++]=n>>>21&127,r[a++]=(n>>>28|(s&7)<<4)&127,r[a++]=s>>>3&127,r[a++]=s>>>10&127,r[a++]=s>>>17&127,r[a++]=s>>>24&127,r[a++]=(s>>>31|(o&63)<<1)&127,r[a++]=o>>>6&127,r[a++]=o>>>13&127,r[a++]=o>>>20&127,r[a++]=(o>>>27|(l&3)<<5)&127,r[a++]=l>>>2&127,r[a++]=l>>>9&127,r[a++]=l>>>16&127,r[a++]=l>>>23&127,r[a++]=(l>>>30|(u&31)<<2)&127,r[a++]=u>>>5&127,r[a++]=u>>>12&127,r[a++]=u>>>19&127,r[a++]=(u>>>26|(h&1)<<6)&127,r[a++]=h>>>1&127,r[a++]=h>>>8&127,r[a++]=h>>>15&127,r[a++]=h>>>22&127,r[a++]=(h>>>29|(c&15)<<3)&127,r[a++]=c>>>4&127,r[a++]=c>>>11&127,r[a++]=c>>>18&127,r[a]=c>>>25&127}function BE(e,t,r,i){let a=i,n=e[t]>>>0,s=e[t+1]>>>0,o=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;r[a++]=n>>>0&255,r[a++]=n>>>8&255,r[a++]=n>>>16&255,r[a++]=n>>>24&255,r[a++]=s>>>0&255,r[a++]=s>>>8&255,r[a++]=s>>>16&255,r[a++]=s>>>24&255,r[a++]=o>>>0&255,r[a++]=o>>>8&255,r[a++]=o>>>16&255,r[a++]=o>>>24&255,r[a++]=l>>>0&255,r[a++]=l>>>8&255,r[a++]=l>>>16&255,r[a++]=l>>>24&255,r[a++]=u>>>0&255,r[a++]=u>>>8&255,r[a++]=u>>>16&255,r[a++]=u>>>24&255,r[a++]=h>>>0&255,r[a++]=h>>>8&255,r[a++]=h>>>16&255,r[a++]=h>>>24&255,r[a++]=c>>>0&255,r[a++]=c>>>8&255,r[a++]=c>>>16&255,r[a++]=c>>>24&255,r[a++]=d>>>0&255,r[a++]=d>>>8&255,r[a++]=d>>>16&255,r[a]=d>>>24&255}function OE(e,t,r,i){let a=i,n=e[t]>>>0,s=e[t+1]>>>0,o=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;r[a++]=n>>>0&511,r[a++]=n>>>9&511,r[a++]=n>>>18&511,r[a++]=(n>>>27|(s&15)<<5)&511,r[a++]=s>>>4&511,r[a++]=s>>>13&511,r[a++]=s>>>22&511,r[a++]=(s>>>31|(o&255)<<1)&511,r[a++]=o>>>8&511,r[a++]=o>>>17&511,r[a++]=(o>>>26|(l&7)<<6)&511,r[a++]=l>>>3&511,r[a++]=l>>>12&511,r[a++]=l>>>21&511,r[a++]=(l>>>30|(u&127)<<2)&511,r[a++]=u>>>7&511,r[a++]=u>>>16&511,r[a++]=(u>>>25|(h&3)<<7)&511,r[a++]=h>>>2&511,r[a++]=h>>>11&511,r[a++]=h>>>20&511,r[a++]=(h>>>29|(c&63)<<3)&511,r[a++]=c>>>6&511,r[a++]=c>>>15&511,r[a++]=(c>>>24|(d&1)<<8)&511,r[a++]=d>>>1&511,r[a++]=d>>>10&511,r[a++]=d>>>19&511,r[a++]=(d>>>28|(p&31)<<4)&511,r[a++]=p>>>5&511,r[a++]=p>>>14&511,r[a]=p>>>23&511}function $E(e,t,r,i){let a=i,n=e[t]>>>0,s=e[t+1]>>>0,o=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;r[a++]=n>>>0&1023,r[a++]=n>>>10&1023,r[a++]=n>>>20&1023,r[a++]=(n>>>30|(s&255)<<2)&1023,r[a++]=s>>>8&1023,r[a++]=s>>>18&1023,r[a++]=(s>>>28|(o&63)<<4)&1023,r[a++]=o>>>6&1023,r[a++]=o>>>16&1023,r[a++]=(o>>>26|(l&15)<<6)&1023,r[a++]=l>>>4&1023,r[a++]=l>>>14&1023,r[a++]=(l>>>24|(u&3)<<8)&1023,r[a++]=u>>>2&1023,r[a++]=u>>>12&1023,r[a++]=u>>>22&1023,r[a++]=h>>>0&1023,r[a++]=h>>>10&1023,r[a++]=h>>>20&1023,r[a++]=(h>>>30|(c&255)<<2)&1023,r[a++]=c>>>8&1023,r[a++]=c>>>18&1023,r[a++]=(c>>>28|(d&63)<<4)&1023,r[a++]=d>>>6&1023,r[a++]=d>>>16&1023,r[a++]=(d>>>26|(p&15)<<6)&1023,r[a++]=p>>>4&1023,r[a++]=p>>>14&1023,r[a++]=(p>>>24|(f&3)<<8)&1023,r[a++]=f>>>2&1023,r[a++]=f>>>12&1023,r[a]=f>>>22&1023}function jE(e,t,r,i){let a=i,n=e[t]>>>0,s=e[t+1]>>>0,o=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;r[a++]=n>>>0&2047,r[a++]=n>>>11&2047,r[a++]=(n>>>22|(s&1)<<10)&2047,r[a++]=s>>>1&2047,r[a++]=s>>>12&2047,r[a++]=(s>>>23|(o&3)<<9)&2047,r[a++]=o>>>2&2047,r[a++]=o>>>13&2047,r[a++]=(o>>>24|(l&7)<<8)&2047,r[a++]=l>>>3&2047,r[a++]=l>>>14&2047,r[a++]=(l>>>25|(u&15)<<7)&2047,r[a++]=u>>>4&2047,r[a++]=u>>>15&2047,r[a++]=(u>>>26|(h&31)<<6)&2047,r[a++]=h>>>5&2047,r[a++]=h>>>16&2047,r[a++]=(h>>>27|(c&63)<<5)&2047,r[a++]=c>>>6&2047,r[a++]=c>>>17&2047,r[a++]=(c>>>28|(d&127)<<4)&2047,r[a++]=d>>>7&2047,r[a++]=d>>>18&2047,r[a++]=(d>>>29|(p&255)<<3)&2047,r[a++]=p>>>8&2047,r[a++]=p>>>19&2047,r[a++]=(p>>>30|(f&511)<<2)&2047,r[a++]=f>>>9&2047,r[a++]=f>>>20&2047,r[a++]=(f>>>31|(m&1023)<<1)&2047,r[a++]=m>>>10&2047,r[a]=m>>>21&2047}function VE(e,t,r,i){let a=i,n=e[t]>>>0,s=e[t+1]>>>0,o=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,g=e[t+11]>>>0;r[a++]=n>>>0&4095,r[a++]=n>>>12&4095,r[a++]=(n>>>24|(s&15)<<8)&4095,r[a++]=s>>>4&4095,r[a++]=s>>>16&4095,r[a++]=(s>>>28|(o&255)<<4)&4095,r[a++]=o>>>8&4095,r[a++]=o>>>20&4095,r[a++]=l>>>0&4095,r[a++]=l>>>12&4095,r[a++]=(l>>>24|(u&15)<<8)&4095,r[a++]=u>>>4&4095,r[a++]=u>>>16&4095,r[a++]=(u>>>28|(h&255)<<4)&4095,r[a++]=h>>>8&4095,r[a++]=h>>>20&4095,r[a++]=c>>>0&4095,r[a++]=c>>>12&4095,r[a++]=(c>>>24|(d&15)<<8)&4095,r[a++]=d>>>4&4095,r[a++]=d>>>16&4095,r[a++]=(d>>>28|(p&255)<<4)&4095,r[a++]=p>>>8&4095,r[a++]=p>>>20&4095,r[a++]=f>>>0&4095,r[a++]=f>>>12&4095,r[a++]=(f>>>24|(m&15)<<8)&4095,r[a++]=m>>>4&4095,r[a++]=m>>>16&4095,r[a++]=(m>>>28|(g&255)<<4)&4095,r[a++]=g>>>8&4095,r[a]=g>>>20&4095}function NE(e,t,r,i){let a=i,n=e[t]>>>0,s=e[t+1]>>>0,o=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,g=e[t+11]>>>0,_=e[t+12]>>>0,y=e[t+13]>>>0,v=e[t+14]>>>0,x=e[t+15]>>>0;r[a++]=n>>>0&65535,r[a++]=n>>>16&65535,r[a++]=s>>>0&65535,r[a++]=s>>>16&65535,r[a++]=o>>>0&65535,r[a++]=o>>>16&65535,r[a++]=l>>>0&65535,r[a++]=l>>>16&65535,r[a++]=u>>>0&65535,r[a++]=u>>>16&65535,r[a++]=h>>>0&65535,r[a++]=h>>>16&65535,r[a++]=c>>>0&65535,r[a++]=c>>>16&65535,r[a++]=d>>>0&65535,r[a++]=d>>>16&65535,r[a++]=p>>>0&65535,r[a++]=p>>>16&65535,r[a++]=f>>>0&65535,r[a++]=f>>>16&65535,r[a++]=m>>>0&65535,r[a++]=m>>>16&65535,r[a++]=g>>>0&65535,r[a++]=g>>>16&65535,r[a++]=_>>>0&65535,r[a++]=_>>>16&65535,r[a++]=y>>>0&65535,r[a++]=y>>>16&65535,r[a++]=v>>>0&65535,r[a++]=v>>>16&65535,r[a++]=x>>>0&65535,r[a]=x>>>16&65535}function UE(e,t,r,i){let a=i,n=t;for(let s=0;s<8;s++){let o=e[n++]>>>0;r[a++]=o>>>0&1,r[a++]=o>>>1&1,r[a++]=o>>>2&1,r[a++]=o>>>3&1,r[a++]=o>>>4&1,r[a++]=o>>>5&1,r[a++]=o>>>6&1,r[a++]=o>>>7&1,r[a++]=o>>>8&1,r[a++]=o>>>9&1,r[a++]=o>>>10&1,r[a++]=o>>>11&1,r[a++]=o>>>12&1,r[a++]=o>>>13&1,r[a++]=o>>>14&1,r[a++]=o>>>15&1,r[a++]=o>>>16&1,r[a++]=o>>>17&1,r[a++]=o>>>18&1,r[a++]=o>>>19&1,r[a++]=o>>>20&1,r[a++]=o>>>21&1,r[a++]=o>>>22&1,r[a++]=o>>>23&1,r[a++]=o>>>24&1,r[a++]=o>>>25&1,r[a++]=o>>>26&1,r[a++]=o>>>27&1,r[a++]=o>>>28&1,r[a++]=o>>>29&1,r[a++]=o>>>30&1,r[a++]=o>>>31&1}}function GE(e,t,r,i){let a=i,n=t;for(let s=0;s<8;s++){let o=e[n++]>>>0,l=e[n++]>>>0;r[a++]=o>>>0&3,r[a++]=o>>>2&3,r[a++]=o>>>4&3,r[a++]=o>>>6&3,r[a++]=o>>>8&3,r[a++]=o>>>10&3,r[a++]=o>>>12&3,r[a++]=o>>>14&3,r[a++]=o>>>16&3,r[a++]=o>>>18&3,r[a++]=o>>>20&3,r[a++]=o>>>22&3,r[a++]=o>>>24&3,r[a++]=o>>>26&3,r[a++]=o>>>28&3,r[a++]=o>>>30&3,r[a++]=l>>>0&3,r[a++]=l>>>2&3,r[a++]=l>>>4&3,r[a++]=l>>>6&3,r[a++]=l>>>8&3,r[a++]=l>>>10&3,r[a++]=l>>>12&3,r[a++]=l>>>14&3,r[a++]=l>>>16&3,r[a++]=l>>>18&3,r[a++]=l>>>20&3,r[a++]=l>>>22&3,r[a++]=l>>>24&3,r[a++]=l>>>26&3,r[a++]=l>>>28&3,r[a++]=l>>>30&3}}function qE(e,t,r,i){let a=i,n=t;for(let s=0;s<8;s++){let o=e[n++]>>>0,l=e[n++]>>>0,u=e[n++]>>>0;r[a++]=o>>>0&7,r[a++]=o>>>3&7,r[a++]=o>>>6&7,r[a++]=o>>>9&7,r[a++]=o>>>12&7,r[a++]=o>>>15&7,r[a++]=o>>>18&7,r[a++]=o>>>21&7,r[a++]=o>>>24&7,r[a++]=o>>>27&7,r[a++]=(o>>>30|(l&1)<<2)&7,r[a++]=l>>>1&7,r[a++]=l>>>4&7,r[a++]=l>>>7&7,r[a++]=l>>>10&7,r[a++]=l>>>13&7,r[a++]=l>>>16&7,r[a++]=l>>>19&7,r[a++]=l>>>22&7,r[a++]=l>>>25&7,r[a++]=l>>>28&7,r[a++]=(l>>>31|(u&3)<<1)&7,r[a++]=u>>>2&7,r[a++]=u>>>5&7,r[a++]=u>>>8&7,r[a++]=u>>>11&7,r[a++]=u>>>14&7,r[a++]=u>>>17&7,r[a++]=u>>>20&7,r[a++]=u>>>23&7,r[a++]=u>>>26&7,r[a++]=u>>>29&7}}function ZE(e,t,r,i){let a=i,n=t;for(let s=0;s<8;s++){let o=e[n++]>>>0,l=e[n++]>>>0,u=e[n++]>>>0,h=e[n++]>>>0;r[a++]=o>>>0&15,r[a++]=o>>>4&15,r[a++]=o>>>8&15,r[a++]=o>>>12&15,r[a++]=o>>>16&15,r[a++]=o>>>20&15,r[a++]=o>>>24&15,r[a++]=o>>>28&15,r[a++]=l>>>0&15,r[a++]=l>>>4&15,r[a++]=l>>>8&15,r[a++]=l>>>12&15,r[a++]=l>>>16&15,r[a++]=l>>>20&15,r[a++]=l>>>24&15,r[a++]=l>>>28&15,r[a++]=u>>>0&15,r[a++]=u>>>4&15,r[a++]=u>>>8&15,r[a++]=u>>>12&15,r[a++]=u>>>16&15,r[a++]=u>>>20&15,r[a++]=u>>>24&15,r[a++]=u>>>28&15,r[a++]=h>>>0&15,r[a++]=h>>>4&15,r[a++]=h>>>8&15,r[a++]=h>>>12&15,r[a++]=h>>>16&15,r[a++]=h>>>20&15,r[a++]=h>>>24&15,r[a++]=h>>>28&15}}function WE(e,t,r,i){let a=i,n=t;for(let s=0;s<8;s++){let o=e[n++]>>>0,l=e[n++]>>>0,u=e[n++]>>>0,h=e[n++]>>>0,c=e[n++]>>>0;r[a++]=o>>>0&31,r[a++]=o>>>5&31,r[a++]=o>>>10&31,r[a++]=o>>>15&31,r[a++]=o>>>20&31,r[a++]=o>>>25&31,r[a++]=(o>>>30|(l&7)<<2)&31,r[a++]=l>>>3&31,r[a++]=l>>>8&31,r[a++]=l>>>13&31,r[a++]=l>>>18&31,r[a++]=l>>>23&31,r[a++]=(l>>>28|(u&1)<<4)&31,r[a++]=u>>>1&31,r[a++]=u>>>6&31,r[a++]=u>>>11&31,r[a++]=u>>>16&31,r[a++]=u>>>21&31,r[a++]=u>>>26&31,r[a++]=(u>>>31|(h&15)<<1)&31,r[a++]=h>>>4&31,r[a++]=h>>>9&31,r[a++]=h>>>14&31,r[a++]=h>>>19&31,r[a++]=h>>>24&31,r[a++]=(h>>>29|(c&3)<<3)&31,r[a++]=c>>>2&31,r[a++]=c>>>7&31,r[a++]=c>>>12&31,r[a++]=c>>>17&31,r[a++]=c>>>22&31,r[a++]=c>>>27&31}}function HE(e,t,r,i){let a=i,n=t;for(let s=0;s<8;s++){let o=e[n++]>>>0,l=e[n++]>>>0,u=e[n++]>>>0,h=e[n++]>>>0,c=e[n++]>>>0,d=e[n++]>>>0;r[a++]=o>>>0&63,r[a++]=o>>>6&63,r[a++]=o>>>12&63,r[a++]=o>>>18&63,r[a++]=o>>>24&63,r[a++]=(o>>>30|(l&15)<<2)&63,r[a++]=l>>>4&63,r[a++]=l>>>10&63,r[a++]=l>>>16&63,r[a++]=l>>>22&63,r[a++]=(l>>>28|(u&3)<<4)&63,r[a++]=u>>>2&63,r[a++]=u>>>8&63,r[a++]=u>>>14&63,r[a++]=u>>>20&63,r[a++]=u>>>26&63,r[a++]=h>>>0&63,r[a++]=h>>>6&63,r[a++]=h>>>12&63,r[a++]=h>>>18&63,r[a++]=h>>>24&63,r[a++]=(h>>>30|(c&15)<<2)&63,r[a++]=c>>>4&63,r[a++]=c>>>10&63,r[a++]=c>>>16&63,r[a++]=c>>>22&63,r[a++]=(c>>>28|(d&3)<<4)&63,r[a++]=d>>>2&63,r[a++]=d>>>8&63,r[a++]=d>>>14&63,r[a++]=d>>>20&63,r[a++]=d>>>26&63}}function XE(e,t,r,i){let a=i,n=t;for(let s=0;s<8;s++){let o=e[n++]>>>0,l=e[n++]>>>0,u=e[n++]>>>0,h=e[n++]>>>0,c=e[n++]>>>0,d=e[n++]>>>0,p=e[n++]>>>0;r[a++]=o>>>0&127,r[a++]=o>>>7&127,r[a++]=o>>>14&127,r[a++]=o>>>21&127,r[a++]=(o>>>28|(l&7)<<4)&127,r[a++]=l>>>3&127,r[a++]=l>>>10&127,r[a++]=l>>>17&127,r[a++]=l>>>24&127,r[a++]=(l>>>31|(u&63)<<1)&127,r[a++]=u>>>6&127,r[a++]=u>>>13&127,r[a++]=u>>>20&127,r[a++]=(u>>>27|(h&3)<<5)&127,r[a++]=h>>>2&127,r[a++]=h>>>9&127,r[a++]=h>>>16&127,r[a++]=h>>>23&127,r[a++]=(h>>>30|(c&31)<<2)&127,r[a++]=c>>>5&127,r[a++]=c>>>12&127,r[a++]=c>>>19&127,r[a++]=(c>>>26|(d&1)<<6)&127,r[a++]=d>>>1&127,r[a++]=d>>>8&127,r[a++]=d>>>15&127,r[a++]=d>>>22&127,r[a++]=(d>>>29|(p&15)<<3)&127,r[a++]=p>>>4&127,r[a++]=p>>>11&127,r[a++]=p>>>18&127,r[a++]=p>>>25&127}}function YE(e,t,r,i){let a=i,n=t;for(let s=0;s<8;s++){let o=e[n++]>>>0,l=e[n++]>>>0,u=e[n++]>>>0,h=e[n++]>>>0,c=e[n++]>>>0,d=e[n++]>>>0,p=e[n++]>>>0,f=e[n++]>>>0;r[a++]=o>>>0&255,r[a++]=o>>>8&255,r[a++]=o>>>16&255,r[a++]=o>>>24&255,r[a++]=l>>>0&255,r[a++]=l>>>8&255,r[a++]=l>>>16&255,r[a++]=l>>>24&255,r[a++]=u>>>0&255,r[a++]=u>>>8&255,r[a++]=u>>>16&255,r[a++]=u>>>24&255,r[a++]=h>>>0&255,r[a++]=h>>>8&255,r[a++]=h>>>16&255,r[a++]=h>>>24&255,r[a++]=c>>>0&255,r[a++]=c>>>8&255,r[a++]=c>>>16&255,r[a++]=c>>>24&255,r[a++]=d>>>0&255,r[a++]=d>>>8&255,r[a++]=d>>>16&255,r[a++]=d>>>24&255,r[a++]=p>>>0&255,r[a++]=p>>>8&255,r[a++]=p>>>16&255,r[a++]=p>>>24&255,r[a++]=f>>>0&255,r[a++]=f>>>8&255,r[a++]=f>>>16&255,r[a++]=f>>>24&255}}function KE(e,t,r,i){let a=i,n=t;for(let s=0;s<128;s++){let o=e[n++]>>>0;r[a++]=o&65535,r[a++]=o>>>16&65535}}function JE(e,t,r,i,a){let n=Sc[a]>>>0,s=t,o=0,l=e[s]>>>0,u=i;for(let h=0;h<8;h++){for(let c=0;c<32;c++)if(o+a<=32){let d=l>>>o&n;r[u+c]=d|0,o+=a,o===32&&(o=0,s++,c!==31&&(l=e[s]>>>0))}else{let d=32-o,p=l>>>o;s++,l=e[s]>>>0;let f=a-d,m=-1>>>32-f>>>0,g=(p|(l&m)<<d)&n;r[u+c]=g|0,o=f}u+=32,o=0,h<7&&(l=e[s]>>>0)}}const Dc=CE(N0),QE=3*Dc/256+Dc|0;function U0(){let e=new Uint8Array(QE);return{dataToBePacked:Array(33),dataPointers:new Int32Array(33),byteContainer:e,byteContainerI32:new Int32Array(e.buffer,e.byteOffset,e.byteLength>>>2),exceptionSizes:new Int32Array(33)}}function eP(e=16){if(e<0)throw RangeError(`initialEncodedWordCapacity must be >= 0, got ${e}`);let t=Math.max(16,e|0);return{encodedWords:new Uint32Array(t),decoderWorkspace:U0()}}function tP(e,t){if(t<=e.encodedWords.length)return e.encodedWords;let r=new Uint32Array(Math.max(16,t*2));return e.encodedWords=r,r}function rP(e,t,r,i){i.byteContainer.length<r&&(i.byteContainer=new Uint8Array(r*2),i.byteContainerI32=void 0);let a=i.byteContainer,n=r>>>2;if(a.byteOffset&3)for(let o=0;o<n;o=o+1|0){let l=e[t+o|0]|0,u=o<<2;a[u]=l&255,a[u+1|0]=l>>>8&255,a[u+2|0]=l>>>16&255,a[u+3|0]=l>>>24&255}else{let o=i.byteContainerI32;(!o||o.buffer!==a.buffer||o.byteOffset!==a.byteOffset||o.length<n)&&(o=i.byteContainerI32=new Int32Array(a.buffer,a.byteOffset,a.byteLength>>>2)),o.set(e.subarray(t,t+n))}let s=r&3;if(s>0){let o=e[t+n|0]|0,l=n<<2;for(let u=0;u<s;u=u+1|0)a[l+u|0]=o>>>(u<<3)&255}return a}function iP(e,t,r){let i=e[t++]|0,a=r.dataToBePacked;for(let n=2;n<=32;n=n+1|0){if(!(i>>>n-1&1))continue;if(t>=e.length)throw Error(`FastPFOR decode: truncated exception stream header (bitWidth=${n}, streamWordIndex=${t}, needWords=1, availableWords=${e.length-t}, encodedWords=${e.length})`);let s=e[t++]>>>0,o=AE(s),l=s*n+31>>>5;if(t+l>e.length)throw Error(`FastPFOR decode: truncated exception stream (bitWidth=${n}, size=${s}, streamWordIndex=${t}, needWords=${l}, availableWords=${e.length-t}, encodedWords=${e.length})`);let u=a[n];(!u||u.length<o)&&(u=a[n]=new Uint32Array(o));let h=0;for(;h<s;h=h+32|0)pP(e,t,u,h,n),t=t+n|0;let c=h-s|0;t=t-(c*n>>>5)|0,r.exceptionSizes[n]=s}return t}function aP(e,t,r,i,a){switch(a){case 1:UE(e,t,r,i);break;case 2:GE(e,t,r,i);break;case 3:qE(e,t,r,i);break;case 4:ZE(e,t,r,i);break;case 5:WE(e,t,r,i);break;case 6:HE(e,t,r,i);break;case 7:XE(e,t,r,i);break;case 8:YE(e,t,r,i);break;case 16:KE(e,t,r,i);break;default:JE(e,t,r,i,a)}return t+(a<<3)|0}function nP(e,t,r,i){if(r+2>t)throw Error(`FastPFOR decode: byteContainer underflow at block=${i} (need 2 bytes for [bitWidth, exceptionCount], bytePos=${r}, byteSize=${t})`);let a=e[r++],n=e[r++];if(a>32)throw Error(`FastPFOR decode: invalid bitWidth=${a} at block=${i} (expected 0..32). This likely indicates corrupted or truncated input.`);return{bitWidth:a,exceptionCount:n,bytePosIn:r}}function sP(e,t,r,i,a,n){if(r+1>t)throw Error(`FastPFOR decode: exception header underflow at block=${n} (need 1 byte for maxBits, bytePos=${r}, byteSize=${t})`);let s=e[r++];if(s<i||s>32)throw Error(`FastPFOR decode: invalid maxBits=${s} at block=${n} (bitWidth=${i}, expected ${i}..32)`);let o=s-i|0;if(o<1||o>32)throw Error(`FastPFOR decode: invalid exceptionBitWidth=${o} at block=${n} (bitWidth=${i}, maxBits=${s})`);if(r+a>t)throw Error(`FastPFOR decode: exception positions underflow at block=${n} (need=${a}, have=${t-r})`);return{maxBits:s,exceptionBitWidth:o,bytePosIn:r}}function oP(e,t,r,i,a,n,s,o,l){let{maxBits:u,exceptionBitWidth:h,bytePosIn:c}=sP(a,n,s,r,i,l);if(s=c,h===1){let g=1<<r;for(let _=0;_<i;_=_+1|0){let y=a[s++];e[y+t|0]|=g}return s}let d=o.dataToBePacked[h];if(!d)throw Error(`FastPFOR decode: missing exception stream for exceptionBitWidth=${h} (bitWidth=${r}, maxBits=${u}) at block ${l}`);let p=o.dataPointers,f=p[h]|0,m=o.exceptionSizes[h]|0;if(f+i>m)throw Error(`FastPFOR decode: exception stream overflow for exceptionBitWidth=${h} (ptr=${f}, need ${i}, size=${m}) at block ${l}`);for(let g=0;g<i;g=g+1|0){let _=a[s++],y=d[f++]|0;e[_+t|0]|=y<<r}return p[h]=f,s}function lP(e,t,r,i,a,n,s,o,l,u){let h=r|0,c=0;for(let d=0;d<s;d=d+1|0){let p=nP(o,l,c,d);c=p.bytePosIn;let f=p.bitWidth,m=p.exceptionCount,g=n+d*256|0;switch(f){case 0:a.fill(0,g,g+256);break;case 32:for(let _=0;_<256;_=_+1|0)a[g+_|0]=e[h+_|0]|0;h=h+256|0;break;default:h=aP(e,h,a,g,f)}m>0&&(c=oP(a,g,f,m,o,l,c,u,d))}if(h!==i)throw Error(`FastPFOR decode: packed region mismatch (pageStart=${t}, packedStart=${r}, consumedPackedEnd=${h}, expectedPackedEnd=${i}, packedWords=${i-r}, encoded.length=${e.length})`)}function uP(e,t,r,i,a,n){let s=r|0,o=e[s]|0;if(o<=0||s+o>e.length-1)throw Error(`FastPFOR decode: invalid whereMeta=${o} at pageStart=${s} (expected > 0 and pageStart+whereMeta < encoded.length=${e.length})`);let l=s+1|0,u=s+o|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=${s}, packedEnd=${u}, byteContainerStart=${d}) causes bitmapPos=${p} out of bounds (encoded.length=${e.length})`);let f=rP(e,d,h,n),m=h,g=iP(e,p,n);return n.dataPointers.fill(0),lP(e,s,l,u,t,i|0,a/256|0,f,m,n),g}function hP(e,t,r,i,a,n){let s=i+Rd(a,256),o=i,l=r;for(;o!==s;){let u=Math.min(Dc,s-o);l=uP(e,t,l,o,u,n),o=o+u|0}return l}function cP(e,t,r,i,a,n){if(n===0)return t;let s=0,o=t,l=t+r,u=a,h=a,c=a+n,d=0,p=0;for(;o<l&&h<c;){let f=e[o]>>>s&255;if(s+=8,o+=s>>>5,s&=31,d|=(f&127)<<p,f&128)i[h++]=d|0,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=${o}, inEnd=${l})`)}if(h!==c)throw Error(`FastPFOR VByte: truncated stream (decoded=${h-u}, expected=${n}, consumedWords=${o-t}/${r}, vbyteStart=${t}, vbyteEnd=${l})`);return o}function dP(e,t,r){let i=0,a=0,n=new Uint32Array(t),s=r??U0();if(e.length>0){let u=e[i]|0;if(i=i+1|0,u&255)throw Error(`FastPFOR decode: invalid alignedLength=${u} (expected multiple of 256)`);if(a+u>n.length)throw Error(`FastPFOR decode: output buffer too small (outPos=${a}, alignedLength=${u}, out.length=${n.length})`);i=hP(e,n,i,a,u,s),a=a+u|0}let o=e.length-i|0,l=t-a|0;return cP(e,i,o,n,a,l),n}function pP(e,t,r,i,a){switch(a){case 2:ME(e,t,r,i);return;case 3:zE(e,t,r,i);return;case 4:FE(e,t,r,i);return;case 5:RE(e,t,r,i);return;case 6:kE(e,t,r,i);return;case 7:LE(e,t,r,i);return;case 8:BE(e,t,r,i);return;case 9:OE(e,t,r,i);return;case 10:$E(e,t,r,i);return;case 11:jE(e,t,r,i);return;case 12:VE(e,t,r,i);return;case 16:NE(e,t,r,i);return;case 32:for(let u=0;u<32;u=u+1|0)r[i+u|0]=e[t+u|0]|0;return}let n=Sc[a]>>>0,s=t,o=0,l=e[s]>>>0;for(let u=0;u<32;u++)if(o+a<=32){let h=l>>>o&n;r[i+u]=h|0,o+=a,o===32&&(o=0,s++,u!==31&&(l=e[s]>>>0))}else{let h=32-o,c=l>>>o;s++,l=e[s]>>>0;let d=Sc[a-h]>>>0,p=(c|(l&d)<<h)&n;r[i+u]=p|0,o=a-h}}function fP(e,t,r,i){if(t<0||r<0||t+r>e.length)throw RangeError(`decodeBigEndianInt32sInto: out of bounds (offset=${t}, byteLength=${r}, bytes.length=${e.length})`);let a=Math.floor(r/4),n=r%4!=0,s=n?a+1:a;if(i.length<s)throw RangeError(`decodeBigEndianInt32sInto: out.length=${i.length} < ${s}`);if(a>0){let o=e.byteOffset+t;if(o&3)for(let l=0;l<a;l++){let u=t+l*4;i[l]=e[u]<<24|e[u+1]<<16|e[u+2]<<8|e[u+3]|0}else{let l=new Uint32Array(e.buffer,o,a);for(let u=0;u<a;u++)i[u]=IE(l[u])|0}}if(n){let o=t+a*4,l=r-a*4,u=0;for(let h=0;h<l;h++)u|=e[o+h]<<24-h*8;i[a]=u|0}return s}function Mt(e,t,r){let i=new Uint32Array(r),a=0,n=t.get();for(let s=0;s<i.length;s++){let o=e[n++],l=o&127;if(o<128){i[a++]=l;continue}if(o=e[n++],l|=(o&127)<<7,o<128){i[a++]=l;continue}if(o=e[n++],l|=(o&127)<<14,o<128){i[a++]=l;continue}if(o=e[n++],l|=(o&127)<<21,o<128){i[a++]=l;continue}o=e[n++],l|=(o&15)<<28,i[a++]=l}return t.set(n),i}function kd(e,t,r){let i=new BigUint64Array(r);for(let a=0;a<i.length;a++)i[a]=mP(e,t);return i}function mP(e,t){let r=0n,i=0,a=t.get();for(;a<e.length;){let n=e[a++];if(r|=BigInt(n&127)<<BigInt(i),!(n&128))break;if(i+=7,i>=64)throw Error("Varint too long")}return t.set(a),r}function gP(e,t,r){let i=new Float64Array(r);for(let a=0;a<r;a++)i[a]=_P(e,t);return i}function _P(e,t){let r,i;return i=e[t.get()],t.increment(),r=i&127,i<128||(i=e[t.get()],t.increment(),r|=(i&127)<<7,i<128)||(i=e[t.get()],t.increment(),r|=(i&127)<<14,i<128)||(i=e[t.get()],t.increment(),r|=(i&127)<<21,i<128)?r:(i=e[t.get()],r|=(i&15)<<28,yP(r,e,t))}function yP(e,t,r){let i,a;if(a=t[r.get()],r.increment(),i=(a&112)>>4,a<128||(a=t[r.get()],r.increment(),i|=(a&127)<<3,a<128)||(a=t[r.get()],r.increment(),i|=(a&127)<<10,a<128)||(a=t[r.get()],r.increment(),i|=(a&127)<<17,a<128)||(a=t[r.get()],r.increment(),i|=(a&127)<<24,a<128)||(a=t[r.get()],r.increment(),i|=(a&1)<<31,a<128))return i*4294967296+(e>>>0);throw Error("Expected varint not more than 10 bytes")}function xP(e,t,r,i){return vP(e,t,r,i,eP(r>>>2))}function vP(e,t,r,i,a){let n=i.get();if(r&3)throw Error(`FastPFOR: invalid encodedByteLength=${r} at offset=${n} (encodedBytes.length=${e.length}; expected a multiple of 4 bytes for an int32 big-endian word stream)`);let s=r>>>2,o=tP(a,s);fP(e,n,r,o);let l=dP(o.subarray(0,s),t,a.decoderWorkspace);return i.add(r),l}function Me(e){return e>>>1^-(e&1)}function At(e){return e>>1n^-(e&1n)}function ki(e){return e%2==1?(e+1)/-2:e/2}function bP(e){let t=new Int32Array(e.length);for(let r=0;r<e.length;r++)t[r]=Me(e[r]);return t}function wP(e){let t=new BigInt64Array(e.length);for(let r=0;r<e.length;r++)t[r]=At(e[r]);return t}function Ec(e,t,r){if(r===void 0){r=0;for(let n=0;n<t;n++)r+=e[n]}let i=new Uint32Array(r),a=0;for(let n=0;n<t;n++){let s=e[n],o=e[n+t];i.fill(o,a,a+s),a+=s}return i}function Pc(e,t,r){if(r===void 0){r=0;for(let n=0;n<t;n++)r+=Number(e[n])}let i=new BigUint64Array(r),a=0;for(let n=0;n<t;n++){let s=Number(e[n]),o=e[n+t];i.fill(o,a,a+s),a+=s}return i}function G0(e,t,r){let i=new Float64Array(r),a=0;for(let n=0;n<t;n++){let s=e[n],o=e[n+t];i.fill(o,a,a+s),a+=s}return i}function lm(e){let t=new Int32Array(e.length);t[0]=Me(e[0]);let r=e.length/4*4,i=1;if(r>=4)for(;i<r-4;i+=4){let a=e[i],n=e[i+1],s=e[i+2],o=e[i+3];t[i]=Me(a)+t[i-1],t[i+1]=Me(n)+t[i],t[i+2]=Me(s)+t[i+1],t[i+3]=Me(o)+t[i+2]}for(;i!==e.length;++i)t[i]=Me(e[i])+t[i-1];return t}function um(e){let t=new BigInt64Array(e.length);t[0]=At(e[0]);let r=e.length/4*4,i=1;if(r>=4)for(;i<r-4;i+=4){let a=e[i],n=e[i+1],s=e[i+2],o=e[i+3];t[i]=At(a)+t[i-1],t[i+1]=At(n)+t[i],t[i+2]=At(s)+t[i+1],t[i+3]=At(o)+t[i+2]}for(;i!==t.length;++i)t[i]=At(e[i])+t[i-1];return t}function TP(e){e[0]=ki(e[0]);let t=e.length/4*4,r=1;if(t>=4)for(;r<t-4;r+=4){let i=e[r],a=e[r+1],n=e[r+2],s=e[r+3];e[r]=ki(i)+e[r-1],e[r+1]=ki(a)+e[r],e[r+2]=ki(n)+e[r+1],e[r+3]=ki(s)+e[r+2]}for(;r!==e.length;++r)e[r]=ki(e[r])+e[r-1]}function SP(e,t,r){if(r===void 0){r=0;for(let n=0;n<t;n++)r+=e[n]}let i=new Int32Array(r),a=0;for(let n=0;n<t;n++){let s=e[n],o=e[n+t];o=Me(o),i.fill(o,a,a+s),a+=s}return i}function DP(e,t,r){if(r===void 0){r=0;for(let n=0;n<t;n++)r+=Number(e[n])}let i=new BigInt64Array(r),a=0;for(let n=0;n<t;n++){let s=Number(e[n]),o=e[n+t];o=At(o),i.fill(o,a,a+s),a+=s}return i}function EP(e,t,r){let i=new Float64Array(r),a=0;for(let n=0;n<t;n++){let s=e[n],o=e[n+t];o=ki(o),i.fill(o,a,a+s),a+=s}return i}function Ld(e){let t=e.length/4*4,r=1;if(t>=4)for(let i=e[0];r<t-4;r+=4)i=e[r]+=i,i=e[r+1]+=i,i=e[r+2]+=i,i=e[r+3]+=i;for(;r!==e.length;)e[r]+=e[r-1],++r}function PP(e){let t=0;for(let r=0;r<e.length;r++)e[r]+=t,t=e[r]}function AP(e){if(e.length<2)return new Int32Array(e);let t=new Int32Array(e.length);t[0]=Me(e[0]),t[1]=Me(e[1]);let r=e.length/4*4,i=2;if(r>=4)for(;i<r-4;i+=4){let a=e[i],n=e[i+1],s=e[i+2],o=e[i+3];t[i]=Me(a)+t[i-2],t[i+1]=Me(n)+t[i-1],t[i+2]=Me(s)+t[i],t[i+3]=Me(o)+t[i+1]}for(;i!==e.length;i+=2)t[i]=Me(e[i])+t[i-2],t[i+1]=Me(e[i+1])+t[i-1];return t}function CP(e){let t=new Int32Array(e.length+1);t[0]=0,t[1]=Me(e[0]);let r=t[1];for(let i=2;i!==t.length;++i){let a=e[i-1],n=Me(a);r+=n,t[i]=t[i-1]+r}return new Uint32Array(t)}function IP(e,t,r){let i=new Int32Array(r+1);i[0]=0;let a=1,n=i[0];for(let s=0;s<t;s++){let o=e[s],l=e[s+t];l=Me(l);for(let u=a;u<a+o;u++)i[u]=l+n,n=i[u];a+=o}return i}function MP(e,t,r){let i=new Uint32Array(r+1);i[0]=0;let a=1,n=i[0];for(let s=0;s<t;s++){let o=e[s],l=e[s+t];for(let u=a;u<a+o;u++)i[u]=l+n,n=i[u];a+=o}return i}function zP(e,t,r){let i=new Int32Array(r),a=0,n=0;for(let s=0;s<t;s++){let o=e[s],l=e[s+t],u=Me(l);for(let h=0;h<o;h++)n+=u,i[a++]=n}return i}function FP(e,t,r){let i=new BigInt64Array(r),a=0,n=0n;for(let s=0;s<t;s++){let o=Number(e[s]),l=e[s+t],u=At(l);for(let h=0;h<o;h++)n+=u,i[a++]=n}return i}function hm(e){let t=new Uint32Array(e.length);t[0]=Me(e[0])>>>0;for(let r=1;r<e.length;r++)t[r]=t[r-1]+Me(e[r])>>>0;return t}function cm(e){let t=new BigUint64Array(e.length);t[0]=BigInt.asUintN(64,At(e[0]));for(let r=1;r<e.length;r++)t[r]=BigInt.asUintN(64,t[r-1]+At(e[r]));return t}function RP(e){if(e.length<2)return new Uint32Array(e);let t=new Uint32Array(e.length);t[0]=Me(e[0])>>>0,t[1]=Me(e[1])>>>0;for(let r=2;r<e.length;r+=2)t[r]=t[r-2]+Me(e[r])>>>0,t[r+1]=t[r-1]+Me(e[r+1])>>>0;return t}function kP(e){return e[1]}function LP(e){return Me(e[1])}function BP(e){if(e.length===2){let t=Me(e[1]);return[t,t]}return[Me(e[2]),Me(e[3])]}function OP(e){return e[1]}function $P(e){return At(e[1])}function jP(e){if(e.length===2){let t=At(e[1]);return[t,t]}return[At(e[2]),At(e[3])]}var ut;(function(e){e.PRESENT="PRESENT",e.DATA="DATA",e.OFFSET="OFFSET",e.LENGTH="LENGTH"})(ut||(ut={}));var Ot;(function(e){e.NONE="NONE",e.SINGLE="SINGLE",e.SHARED="SHARED",e.VERTEX="VERTEX",e.MORTON="MORTON",e.FSST="FSST"})(Ot||(Ot={}));var ai;(function(e){e.VERTEX="VERTEX",e.INDEX="INDEX",e.STRING="STRING",e.KEY="KEY"})(ai||(ai={}));var gt;(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"})(gt||(gt={}));const VP=[ut.PRESENT,ut.DATA,ut.OFFSET,ut.LENGTH],dm=[he.NONE,he.DELTA,he.COMPONENTWISE_DELTA,he.RLE,he.MORTON],NP=[yr.NONE,yr.FAST_PFOR,yr.VARINT],UP=[Ot.NONE,Ot.SINGLE,Ot.SHARED,Ot.VERTEX,Ot.MORTON,Ot.FSST],GP=[ai.VERTEX,ai.INDEX,ai.STRING,ai.KEY],qP=[gt.VAR_BINARY,gt.GEOMETRIES,gt.PARTS,gt.RINGS,gt.TRIANGLES,gt.SYMBOL,gt.DICTIONARY];function He(e,t){let r=HP(e,t);return r.logicalLevelTechnique1===he.MORTON?ZP(r,e,t):(he.RLE===r.logicalLevelTechnique1||he.RLE===r.logicalLevelTechnique2)&&yr.NONE!==r.physicalLevelTechnique?WP(r,e,t):r}function ZP(e,t,r){let i=Mt(t,r,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:i[0],coordinateShift:i[1]}}function WP(e,t,r){let i=Mt(t,r,2);return{physicalStreamType:e.physicalStreamType,logicalStreamType:e.logicalStreamType,logicalLevelTechnique1:e.logicalLevelTechnique1,logicalLevelTechnique2:e.logicalLevelTechnique2,physicalLevelTechnique:e.physicalLevelTechnique,numValues:e.numValues,byteLength:e.byteLength,decompressedCount:i[1],runs:i[0],numRleValues:i[1]}}function HP(e,t){let r=e[t.get()],i=VP[r>>4],a={};switch(i){case ut.DATA:a={dictionaryType:UP[r&15]};break;case ut.OFFSET:a={offsetType:GP[r&15]};break;case ut.LENGTH:a={lengthType:qP[r&15]}}t.increment();let n=e[t.get()],s=dm[n>>5],o=dm[n>>2&7],l=NP[n&3];t.increment();let u=Mt(e,t,2),h=u[0],c=u[1];return{physicalStreamType:i,logicalStreamType:a,logicalLevelTechnique1:s,logicalLevelTechnique2:o,physicalLevelTechnique:l,numValues:h,byteLength:c,decompressedCount:h}}var je;(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"})(je||(je={}));var Cr=class{constructor(e,t){this.values=e,this._size=t}get(e){let t=Math.floor(e/8),r=e%8;return(this.values[t]>>r&1)==1}set(e,t){let r=Math.floor(e/8),i=e%8;this.values[r]=this.values[r]|+!!t<<i}getInt(e){let t=Math.floor(e/8),r=e%8;return this.values[t]>>r&1}size(){return this._size}getBuffer(){return this.values}};function sa(e,t,r){if(!t)return e;let i=t.size(),a=e.constructor,n=new a(i),s=0;for(let o=0;o<i;o++)n[o]=t.get(o)?e[s++]:r;return n}function XP(e,t,r){if(!r)return e;let i=r.size(),a=new Cr(e,t),n=new Cr(new Uint8Array(Math.ceil(i/8)),i),s=0;for(let o=0;o<i;o++){let l=r.get(o)?a.get(s++):!1;n.set(o,l)}return n.getBuffer()}function Ja(e,t,r,i,a){let n=YP(e,Math.ceil(t/8),r,i);return a?XP(n,t,a):n}function YP(e,t,r,i){let a=new Uint8Array(t),n=0,s=i.get()+r;for(;n<t&&!(i.get()>=s);){let o=e[i.increment()];if(o<=127){let l=o+3,u=e[i.increment()],h=Math.min(n+l,t);a.fill(u,n,h),n=h}else{let l=256-o;for(let u=0;u<l&&n<t;u++)a[n++]=e[i.increment()]}}return i.set(s),a}function q0(e,t,r,i){let a=t.get(),n=a+r*Float32Array.BYTES_PER_ELEMENT,s=new Uint8Array(e.subarray(a,n)).buffer,o=new Float32Array(s);return t.set(n),i?sa(o,i,0):o}function Z0(e,t,r,i){let a=t.get(),n=a+r*Float64Array.BYTES_PER_ELEMENT,s=new Uint8Array(e.subarray(a,n)).buffer,o=new Float64Array(s);return t.set(n),i?sa(o,i,0):o}function KP(e,t,r){let i=t.get(),a=r*Uint32Array.BYTES_PER_ELEMENT,n=new DataView(e.buffer,e.byteOffset,e.byteLength),s=new Uint32Array(r);for(let o=0;o<r;o++)s[o]=n.getUint32(i+o*Uint32Array.BYTES_PER_ELEMENT,!0);return t.add(a),s}function JP(e,t,r){let i=t.get(),a=r*BigUint64Array.BYTES_PER_ELEMENT,n=new DataView(e.buffer,e.byteOffset,e.byteLength),s=new BigUint64Array(r);for(let o=0;o<r;o++)s[o]=n.getBigUint64(i+o*BigUint64Array.BYTES_PER_ELEMENT,!0);return t.add(a),s}const QP=new TextDecoder;function Bd(e,t,r){return r-t>=12?QP.decode(e.subarray(t,r)):eA(e,t,r)}function eA(e,t,r){let i="",a=t;for(;a<r;){let n=e[a],s=null,o=n>239?4:n>223?3:n>191?2:1;if(a+o>r)break;let l,u,h;o===1?n<128&&(s=n):o===2?(l=e[a+1],(l&192)==128&&(s=(n&31)<<6|l&63,s<=127&&(s=null))):o===3?(l=e[a+1],u=e[a+2],(l&192)==128&&(u&192)==128&&(s=(n&15)<<12|(l&63)<<6|u&63,(s<=2047||s>=55296&&s<=57343)&&(s=null))):o===4&&(l=e[a+1],u=e[a+2],h=e[a+3],(l&192)==128&&(u&192)==128&&(h&192)==128&&(s=(n&15)<<18|(l&63)<<12|(u&63)<<6|h&63,(s<=65535||s>=1114112)&&(s=null))),s===null?(s=65533,o=1):s>65535&&(s-=65536,i+=String.fromCharCode(s>>>10&1023|55296),s=56320|s&1023),i+=String.fromCharCode(s),a+=o}return i}function hl(e,t,r,i,a){return nA(Qa(e,t,r),r,i,a)}function St(e,t,r,i,a){return sA(Qa(e,t,r),r,i,a)}function _i(e,t,r){return uA(Qa(e,t,r),r)}function Qa(e,t,r){let i=r.physicalLevelTechnique;switch(i){case yr.FAST_PFOR:return xP(e,r.numValues,r.byteLength,t);case yr.VARINT:return Mt(e,t,r.numValues);case yr.NONE:return KP(e,t,r.numValues);default:throw Error(`Specified physicalLevelTechnique ${i} is not supported (yet).`)}}function xs(e,t,r){let i=r.physicalLevelTechnique;switch(i){case yr.VARINT:return kd(e,t,r.numValues);case yr.NONE:return JP(e,t,r.numValues);default:throw Error(`Specified physicalLevelTechnique ${i} is not supported (yet).`)}}function tA(e,t,r){let i=Qa(e,t,r);return i.length===1?Me(i[0]):LP(i)}function Od(e,t,r){let i=Qa(e,t,r);return i.length===1?r.logicalLevelTechnique1===he.DELTA?Me(i[0]):i[0]:kP(i)}function W0(e,t,r){return BP(Qa(e,t,r))}function H0(e,t,r){return jP(kd(e,t,r.numValues))}function X0(e,t,r,i){return oA(xs(e,t,r),r,i)}function $d(e,t,r,i){return K0(xs(e,t,r),r,i)}function rA(e,t,r,i){let a=iA(e,t,r,!1);return i?sa(a,i,0):a}function iA(e,t,r,i){if(r.physicalLevelTechnique===yr.VARINT)return lA(gP(e,t,r.numValues),r,i);let a=xs(e,t,r),n=K0(a,r);return Float64Array.from(n,Number)}function aA(e,t,r){let i=xs(e,t,r);return i.length===1?At(i[0]):$P(i)}function Y0(e,t,r){let i=xs(e,t,r);return i.length===1?r.logicalLevelTechnique1===he.DELTA?At(i[0]):i[0]:OP(i)}function nA(e,t,r,i){let a;switch(t.logicalLevelTechnique1){case he.DELTA:if(t.logicalLevelTechnique2===he.RLE){let n=t;if(!i)return zP(e,n.runs,n.numRleValues);e=Ec(e,n.runs,n.numRleValues),a=lm(e)}else a=lm(e);break;case he.RLE:a=SP(e,t.runs,t.numRleValues);break;case he.MORTON:Ld(e),a=new Int32Array(e);break;case he.COMPONENTWISE_DELTA:a=AP(e);break;case he.NONE:a=bP(e);break;default:throw Error(`The specified Logical level technique is not supported: ${t.logicalLevelTechnique1}`)}return i?sa(a,i,0):a}function sA(e,t,r,i){let a;switch(t.logicalLevelTechnique1){case he.DELTA:if(t.logicalLevelTechnique2===he.RLE){let n=t;a=hm(Ec(e,n.runs,n.numRleValues))}else a=hm(e);break;case he.RLE:a=Ec(e,t.runs,t.numRleValues);break;case he.MORTON:Ld(e),a=e;break;case he.COMPONENTWISE_DELTA:a=RP(e);break;case he.NONE:a=e;break;default:throw Error(`The specified Logical level technique is not supported: ${t.logicalLevelTechnique1}`)}return i?sa(a,i,0):a}function oA(e,t,r){let i;switch(t.logicalLevelTechnique1){case he.DELTA:if(t.logicalLevelTechnique2===he.RLE){let a=t;if(!r)return FP(e,a.runs,a.numRleValues);e=Pc(e,a.runs,a.numRleValues),i=um(e)}else i=um(e);break;case he.RLE:i=DP(e,t.runs,t.numRleValues);break;case he.NONE:i=wP(e);break;default:throw Error(`The specified Logical level technique is not supported: ${t.logicalLevelTechnique1}`)}return r?sa(i,r,0n):i}function K0(e,t,r){let i;switch(t.logicalLevelTechnique1){case he.DELTA:if(t.logicalLevelTechnique2===he.RLE){let a=t;i=cm(Pc(e,a.runs,a.numRleValues))}else i=cm(e);break;case he.RLE:i=Pc(e,t.runs,t.numRleValues);break;case he.NONE:i=e;break;default:throw Error(`The specified Logical level technique is not supported: ${t.logicalLevelTechnique1}`)}return r?sa(i,r,0n):i}function lA(e,t,r){switch(t.logicalLevelTechnique1){case he.DELTA:if(t.logicalLevelTechnique2===he.RLE){let i=t;e=G0(e,i.runs,i.numRleValues)}return TP(e),e;case he.RLE:return cA(e,t,r);case he.NONE:return e;default:throw Error(`The specified Logical level technique is not supported: ${t.logicalLevelTechnique1}`)}}function uA(e,t){if(t.logicalLevelTechnique1===he.DELTA&&t.logicalLevelTechnique2===he.NONE)return CP(e);if(t.logicalLevelTechnique1===he.RLE&&t.logicalLevelTechnique2===he.NONE){let r=t;return MP(e,r.runs,r.numRleValues)}if(t.logicalLevelTechnique1===he.NONE&&t.logicalLevelTechnique2===he.NONE){PP(e);let r=new Uint32Array(t.numValues+1);return r[0]=0,r.set(e,1),r}if(t.logicalLevelTechnique1===he.DELTA&&t.logicalLevelTechnique2===he.RLE){let r=t,i=IP(e,r.runs,r.numRleValues);return Ld(i),new Uint32Array(i)}throw Error("Only delta encoding is supported for transforming length to offset streams yet.")}function ql(e,t,r,i,a="int32"){let n=e.logicalLevelTechnique1;if(n===he.RLE)return e.runs===1?je.CONST:je.FLAT;if(n!==he.DELTA||e.logicalLevelTechnique2!==he.RLE)return e.numValues===1?je.CONST:je.FLAT;let s=t instanceof Cr?t.size():t,o=e;if(o.numRleValues!==s)return je.FLAT;if(o.runs===1)return je.SEQUENCE;if(o.runs!==2)return e.numValues===1?je.CONST:je.FLAT;let l=i.get();if(e.physicalLevelTechnique===yr.VARINT)return hA(r,i,a)?je.SEQUENCE:e.numValues===1?je.CONST:je.FLAT;let u=i.get(),h=new Int32Array(r.buffer,r.byteOffset+u,4);return i.set(l),h[2]===2&&h[3]===2?je.SEQUENCE:e.numValues===1?je.CONST:je.FLAT}function hA(e,t,r){let i=new V0(t.get());if(r==="int64"){let n=kd(e,i,4);return n[2]===2n&&n[3]===2n}let a=Mt(e,i,4);return a[2]===2&&a[3]===2}function cA(e,t,r){return r?EP(e,t.runs,t.numRleValues):G0(e,t.runs,t.numRleValues)}var J0=class extends Gl{getValueFromBuffer(e){return this.dataBuffer[e]}},Q0=class extends $0{constructor(e,t,r,i,a){super(e,a?BigInt64Array.of(t):BigUint64Array.of(t),r,i)}getValueFromBuffer(e){return this.dataBuffer[0]+BigInt(e)*this.delta}};function jd(e,t,r){return{x:pm(e,t)-r,y:pm(e>>1,t)-r}}function pm(e,t){let r=0;for(let i=0;i<t;i++)r|=(e&1<<2*i)>>i;return r}var Ct;(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"})(Ct||(Ct={}));var dA;(function(e){e[e.POINT=0]="POINT",e[e.LINESTRING=1]="LINESTRING",e[e.POLYGON=2]="POLYGON"})(dA||(dA={}));var oa;(function(e){e[e.MORTON=0]="MORTON",e[e.VEC_2=1]="VEC_2",e[e.VEC_3=2]="VEC_3"})(oa||(oa={}));function pA(e){let t=Array(e.numGeometries),r=1,i=1,a=1,n=0,s=0,o=0,l=e.mortonSettings,u=e.topologyVector,h=u.geometryOffsets,c=u.partOffsets,d=u.ringOffsets,p=e.vertexOffsets,f=!p||p.length===0,m=e.containsPolygonGeometry(),g=e.vertexBuffer;for(let _=0;_<e.numGeometries;_++){let y=e.geometryType(_);switch(y){case Ct.POINT:{let v,x;if(f)v=g[s++],x=g[s++];else if(e.vertexBufferType===oa.MORTON){let w=g[p[o++]],b=jd(w,l.numBits,l.coordinateShift);v=b.x,x=b.y}else{let w=p[o++]*2;v=g[w],x=g[w+1]}t[n++]=[[new M(v,x)]],h&&a++,c&&r++,d&&i++}break;case Ct.MULTIPOINT:{let v=h[a]-h[a-1];a++;let x;if(f){x=Array(v);for(let w=0;w<v;w++){let b=g[s++],S=g[s++];x[w]=new M(b,S)}}else x=Fi(e.vertexBufferType,g,p,o,v,!1,l),o+=v;t[n++]=x.map(w=>[w]),r+=v,i+=v}break;case Ct.LINESTRING:{let v;m?(v=d[i]-d[i-1],i++):v=c[r]-c[r-1],r++;let x;f?(x=ya(g,s,v,!1),s+=v*2):(x=Fi(e.vertexBufferType,g,p,o,v,!1,l),o+=v),t[n++]=[x],h&&a++}break;case Ct.POLYGON:{let v=c[r]-c[r-1];r++;let x=Array(v-1),w,b=d[i]-d[i-1];if(i++,f){w=ya(g,s,b,!0),s+=b*2;for(let S=0;S<x.length;S++)b=d[i]-d[i-1],i++,x[S]=ya(g,s,b,!0),s+=b*2}else{w=Fi(e.vertexBufferType,g,p,o,b,!0,l),o+=b;for(let S=0;S<x.length;S++)b=d[i]-d[i-1],i++,x[S]=Fi(e.vertexBufferType,g,p,o,b,!0,l),o+=b}t[n++]=[w].concat(x),h&&a++}break;case Ct.MULTILINESTRING:{let v=h[a]-h[a-1];a++;let x=Array(v);for(let w=0;w<v;w++){let b;if(m?(b=d[i]-d[i-1],i++):b=c[r]-c[r-1],r++,f)x[w]=ya(g,s,b,!1),s+=b*2;else{let S=Fi(e.vertexBufferType,g,p,o,b,!1,l);x[w]=S,o+=b}}t[n++]=x}break;case Ct.MULTIPOLYGON:{let v=h[a]-h[a-1];a++;let x=Array(v);for(let w=0;w<v;w++){let b=c[r]-c[r-1];r++;let S,A=Array(b-1),P=d[i]-d[i-1];i++,f?(S=ya(g,s,P,!0),s+=P*2):(S=Fi(e.vertexBufferType,g,p,o,P,!0,l),o+=P);for(let I=0;I<A.length;I++){let R=d[i]-d[i-1];i++,f?(A[I]=ya(g,s,R,!0),s+=R*2):(A[I]=Fi(e.vertexBufferType,g,p,o,R,!0,l),o+=R)}x[w]=[S].concat(A)}t[n++]=x.flat()}break;default:throw Error(`The specified geometry type (${y}) is currently not supported.`)}}return t}function Fi(e,t,r,i,a,n,s){return e===oa.MORTON?mA(t,r,i,a,n,s):fA(t,r,i,a,n)}function ya(e,t,r,i){let a=Array(i?r+1:r);for(let n=0;n<r*2;n+=2){let s=e[t+n],o=e[t+n+1];a[n/2]=new M(s,o)}return i&&(a[a.length-1]=a[0]),a}function fA(e,t,r,i,a){let n=Array(a?i+1:i);for(let s=0;s<i*2;s+=2){let o=t[r+s/2]*2,l=e[o],u=e[o+1];n[s/2]=new M(l,u)}return a&&(n[n.length-1]=n[0]),n}function mA(e,t,r,i,a,n){let s=Array(a?i+1:i);for(let o=0;o<i;o++){let l=e[t[r+o]],u=jd(l,n.numBits,n.coordinateShift);s[o]=new M(u.x,u.y)}return a&&(s[s.length-1]=s[0]),s}var e1=class{constructor(e,t,r,i,a){this._vertexBufferType=e,this._topologyVector=t,this._vertexOffsets=r,this._vertexBuffer=i,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?this.vertexOffsets[e]*2:e*2;return[this.vertexBuffer[t],this.vertexBuffer[t+1]]}getVertex(e){if(this.vertexOffsets&&this.mortonSettings){let r=this.vertexOffsets[e],i=this.vertexBuffer[r],a=jd(i,this.mortonSettings.numBits,this.mortonSettings.coordinateShift);return[a.x,a.y]}let t=this.vertexOffsets?this.vertexOffsets[e]*2:e*2;return[this.vertexBuffer[t],this.vertexBuffer[t+1]]}getGeometries(){return pA(this)}get mortonSettings(){return this._mortonSettings}};function gA(e,t,r,i,a){return new t1(e,t,oa.VEC_2,r,i,a)}function _A(e,t,r,i,a,n){return new t1(e,t,oa.MORTON,r,i,a,n)}var t1=class extends e1{constructor(e,t,r,i,a,n,s){super(r,i,a,n,s),this._numGeometries=e,this._geometryType=t}geometryType(e){return this._geometryType}get numGeometries(){return this._numGeometries}containsPolygonGeometry(){return this._geometryType===Ct.POLYGON||this._geometryType===Ct.MULTIPOLYGON}containsSingleGeometryType(){return!0}};function r1(e,t,r,i){return new i1(oa.VEC_2,e,t,r,i)}function yA(e,t,r,i,a){return new i1(oa.MORTON,e,t,r,i,a)}var i1=class extends e1{constructor(e,t,r,i,a,n){super(e,r,i,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)===Ct.POLYGON||this.geometryType(e)===Ct.MULTIPOLYGON)return!0;return!1}containsSingleGeometryType(){return!1}},a1=class{constructor(e,t,r,i){this._triangleOffsets=e,this._indexBuffer=t,this._vertexBuffer=r,this._topologyVector=i}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 r1(e,this._topologyVector,void 0,this._vertexBuffer).getGeometries()}[Symbol.iterator](){return null}};function fm(e,t,r,i,a,n){return new xA(e,t,r,i,a,n)}var xA=class extends a1{constructor(e,t,r,i,a,n){super(r,i,a,n),this._numGeometries=e,this._geometryType=t}geometryType(e){return this._geometryType}get numGeometries(){return this._numGeometries}containsSingleGeometryType(){return!0}};function mm(e,t,r,i,a){return new vA(e,t,r,i,a)}var vA=class extends a1{constructor(e,t,r,i,a){super(t,r,i,a),this._geometryTypes=e}geometryType(e){return this._geometryTypes[e]}get numGeometries(){return this._geometryTypes.length}containsSingleGeometryType(){return!1}};function bA(e,t,r,i,a){let n=He(e,r),s=ql(n,i,e,r),o,l,u,h;if(s===je.CONST){let v=Od(e,r,n),x,w,b,S;for(let A=0;A<t-1;A++){let P=He(e,r);switch(P.physicalStreamType){case ut.LENGTH:switch(P.logicalStreamType.lengthType){case gt.GEOMETRIES:x=_i(e,r,P);break;case gt.PARTS:w=_i(e,r,P);break;case gt.RINGS:b=_i(e,r,P);break;case gt.TRIANGLES:S=_i(e,r,P)}break;case ut.OFFSET:switch(P.logicalStreamType.offsetType){case ai.VERTEX:o=St(e,r,P);break;case ai.INDEX:h=St(e,r,P)}break;case ut.DATA:if(Ot.VERTEX===P.logicalStreamType.dictionaryType)l=hl(e,r,P,a);else{let I=P;u={numBits:I.numBits,coordinateShift:I.coordinateShift},l=St(e,r,P,a)}}}return h?x!==void 0||w!==void 0?fm(i,v,S,h,l,{geometryOffsets:x,partOffsets:w,ringOffsets:b}):fm(i,v,S,h,l):u===void 0?gA(i,v,{geometryOffsets:x,partOffsets:w,ringOffsets:b},o,l):_A(i,v,{geometryOffsets:x,partOffsets:w,ringOffsets:b},o,l,u)}let c=St(e,r,n),d,p,f,m;for(let v=0;v<t-1;v++){let x=He(e,r);switch(x.physicalStreamType){case ut.LENGTH:switch(x.logicalStreamType.lengthType){case gt.GEOMETRIES:d=St(e,r,x);break;case gt.PARTS:p=St(e,r,x);break;case gt.RINGS:f=St(e,r,x);break;case gt.TRIANGLES:m=_i(e,r,x)}break;case ut.OFFSET:switch(x.logicalStreamType.offsetType){case ai.VERTEX:o=St(e,r,x);break;case ai.INDEX:h=St(e,r,x)}break;case ut.DATA:if(Ot.VERTEX===x.logicalStreamType.dictionaryType)l=hl(e,r,x,a);else{let w=x;u={numBits:w.numBits,coordinateShift:w.coordinateShift},l=St(e,r,x,a)}}}let g,_,y;return d?(g=Uu(c,d,2),p&&f?(_=gm(c,g,p,!1),y=TA(c,g,_,f)):p&&(_=wA(c,g,p))):p&&f?(_=Uu(c,p,1),y=gm(c,_,f,!0)):p&&(_=Uu(c,p,0)),h&&!_?mm(c,m,h,l):h?mm(c,m,h,l,{geometryOffsets:g,partOffsets:_,ringOffsets:y}):u===void 0?r1(c,{geometryOffsets:g,partOffsets:_,ringOffsets:y},o,l):yA(c,{geometryOffsets:g,partOffsets:_,ringOffsets:y},o,l,u)}function Uu(e,t,r){let i=new Uint32Array(e.length+1),a=0;i[0]=a;let n=0;for(let s=0;s<e.length;s++)a=i[s+1]=a+(e[s]>r?t[n++]:1);return i}function gm(e,t,r,i){let a=new Uint32Array(t[t.length-1]+1),n=0;a[0]=n;let s=1,o=0;for(let l=0;l<e.length;l++){let u=e[l],h=t[l+1]-t[l];if(u===5||u===2||i&&(u===4||u===1))for(let c=0;c<h;c++)n=a[s++]=n+r[o++];else for(let c=0;c<h;c++)a[s++]=++n}return a}function wA(e,t,r){let i=new Uint32Array(t[t.length-1]+1),a=0;i[0]=a;let n=1,s=0;for(let o=0;o<e.length;o++){let l=e[o],u=t[o+1]-t[o];if(l===4||l===1)for(let h=0;h<u;h++)a=i[n++]=a+r[s++];else for(let h=0;h<u;h++)i[n++]=++a}return i}function TA(e,t,r,i){let a=new Uint32Array(r[r.length-1]+1),n=0;a[0]=n;let s=1,o=1,l=0;for(let u=0;u<e.length;u++){let h=e[u],c=t[u+1]-t[u];if(h!==0&&h!==3)for(let d=0;d<c;d++){let p=r[s]-r[s-1];s++;for(let f=0;f<p;f++)n=a[o++]=n+i[l++]}else for(let d=0;d<c;d++)a[o++]=++n,s++}return a}var SA=class extends na{constructor(e,t,r){super(e,t.getBuffer(),r),this.dataVector=t}getValueFromBuffer(e){return this.dataVector.get(e)}},DA=class extends Gl{getValueFromBuffer(e){return this.dataBuffer[e]}},n1=class extends na{constructor(e,t,r,i){super(e,i?BigInt64Array.of(t):BigUint64Array.of(t),r)}getValueFromBuffer(e){return this.dataBuffer[0]}},Vd=class extends na{constructor(e,t,r,i){super(e,r,i),this.offsetBuffer=t}},_m=class extends Vd{constructor(e,t,r,i){super(e,t,r,i??t.length-1)}getValueFromBuffer(e){let t=this.offsetBuffer[e],r=this.offsetBuffer[e+1];return Bd(this.dataBuffer,t,r)}},ka=class extends Vd{constructor(e,t,r,i,a){super(e,r,i,a??t.length),this.indexBuffer=t,this.indexBuffer=t}getValueFromBuffer(e){let t=this.indexBuffer[e],r=this.offsetBuffer[t],i=this.offsetBuffer[t+1];return Bd(this.dataBuffer,r,i)}};function EA(e,t){let r=0;for(let i=0;i<t.length;i++){let a=t[i];a===255?(r++,i++):r+=e[a]}return r}function PA(e,t,r){let i=new Uint32Array(t.length);for(let s=1;s<t.length;s++)i[s]=i[s-1]+t[s-1];let a=new Uint8Array(EA(t,r)),n=0;for(let s=0;s<r.length;s++){let o=r[s];if(o===255)s++,a[n++]=r[s];else{let l=t[o],u=i[o];for(;l-- >0;)a[n++]=e[u++]}}return a}var s1=class extends Vd{constructor(e,t,r,i,a,n,s,o){super(e,r,i,s??t.length),this.indexBuffer=t,this.symbolOffsetBuffer=a,this.symbolTableBuffer=n,this.sharedDictionaryCache=o}getValueFromBuffer(e){var a;this.decodedDictionary??(this.decodedDictionary=(a=this.sharedDictionaryCache)==null?void 0:a.decodedDictionary,this.decodedDictionary??(this.decodedDictionary=this.decodeDictionary(),this.sharedDictionaryCache&&(this.sharedDictionaryCache.decodedDictionary=this.decodedDictionary)));let t=this.indexBuffer[e],r=this.offsetBuffer[t],i=this.offsetBuffer[t+1];return Bd(this.decodedDictionary,r,i)}decodeDictionary(){return this.symbolLengthBuffer??(this.symbolLengthBuffer=this.offsetToLengthBuffer(this.symbolOffsetBuffer)),PA(this.symbolTableBuffer,this.symbolLengthBuffer,this.dataBuffer)}offsetToLengthBuffer(e){let t=new Uint32Array(e.length-1),r=e[0];for(let i=1;i<e.length;i++){let a=e[i];t[i-1]=a-r,r=a}return t}};function o1(e,t,r,i,a){let n,s,o,l,u,h=a,c,d;for(let p=0;p<i;p++){let f=He(t,r);switch(f.physicalStreamType){case ut.PRESENT:{let m=new Cr(Ja(t,f.numValues,f.byteLength,r),f.numValues);h=a??m;break}case ut.OFFSET:s=St(t,r,f,void 0,h);break;case ut.LENGTH:{let m=_i(t,r,f);gt.DICTIONARY===f.logicalStreamType.lengthType?n=m:gt.SYMBOL===f.logicalStreamType.lengthType?l=m:c=m;break}case ut.DATA:{let m=t.subarray(r.get(),r.get()+f.byteLength);r.add(f.byteLength);let g=f.logicalStreamType.dictionaryType;Ot.FSST===g?u=m:Ot.SINGLE===g||Ot.SHARED===g?o=m:Ot.NONE===g&&(d=m);break}}}return AA(e,u,s,n,o,l,h)??CA(e,o,s,n,h)??IA(e,c,d,s,h)}function AA(e,t,r,i,a,n,s){if(t){if(!r||!i||!a||!n)throw Error(`Incomplete FSST dictionary string column "${e}"`);return new s1(e,r,i,a,n,t,s)}}function CA(e,t,r,i,a){if(t){if(!r||!i)throw Error(`Incomplete dictionary string column "${e}"`);return a?new ka(e,r,i,t,a):new ka(e,r,i,t)}}function IA(e,t,r,i,a){if(t&&r){if(i)return a?new ka(e,i,t,r,a):new ka(e,i,t,r);if(a&&a.size()!==t.length-1){let n=new Uint32Array(a.size()),s=0;for(let o=0;o<a.size();o++)a.get(o)?n[o]=s++:n[o]=0;return new ka(e,n,t,r,a)}return a?new _m(e,t,r,a):new _m(e,t,r)}}function MA(e,t,r,i){let a,n,s,o,l=!1;for(;!l;){let p=He(e,t);switch(p.physicalStreamType){case ut.LENGTH:gt.DICTIONARY===p.logicalStreamType.lengthType?a=_i(e,t,p):s=_i(e,t,p);break;case ut.DATA:Ot.SINGLE===p.logicalStreamType.dictionaryType||Ot.SHARED===p.logicalStreamType.dictionaryType?(n=e.subarray(t.get(),t.get()+p.byteLength),l=!0):o=e.subarray(t.get(),t.get()+p.byteLength),t.add(p.byteLength)}}if(r.type!=="complexType")throw Error(`Shared dictionary column ${r.name} must be a complex (struct) column.`);if(!a||!n)throw Error(`Incomplete shared dictionary for column "${r.name}"`);let u=r.complexType.children,h=[],c=o?{}:void 0,d=0;for(let p of u){let f=Mt(e,t,1)[0];if(f===0)continue;let m=p.name?`${r.name}${p.name}`:r.name;if(p.type!=="scalarField"||p.scalarField.physicalType!==Se.STRING)throw Error("Currently only scalar string fields are implemented for a struct.");if(f>1&&!p.nullable||f===1&&p.nullable)throw Error(`The number of streams for the child field ${p.name} does not match its nullability. nullibilty: ${p.nullable}, numStreams: ${f}`);let g;if(p.nullable){let y=He(e,t);g=new Cr(Ja(e,y.numValues,y.byteLength,t),y.numValues)}let _=St(e,t,He(e,t),void 0,g);if(o){if(!s)throw Error(`Incomplete shared FSST dictionary for column "${m}"`);h[d++]=new s1(m,_,a,n,s,o,g,c)}else h[d++]=new ka(m,_,a,n,g)}return h}var ym=class extends na{constructor(e,t,r){super(e,new Uint8Array,r??t.length),this.values=t}getValueFromBuffer(e){return this.values[e]}},ni;(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"})(ni||(ni={}));var ji;(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"})(ji||(ji={}));function zA(e,t,r,i){let a=FA(r);if(i===0)return a.map(h=>new ym(h,[]));let n=RA(e,t,i),s=(n.presentStream?n.presentCount:n.lengthStream.length)/a.length,o=[],l=0,u=0;for(let h=0;h<a.length;h++){let c=$A(n,h,s,l,u);o.push(new ym(a[h],c.value,c.nullabilityBuffer)),l=c.countsEnd,u=c.valuesEnd}return o}function FA(e){let t=e.type==="complexType"?e.complexType.children:void 0;return!t||t.length===0?[e.name]:t.map(r=>e.name+(r.name??""))}function RA(e,t,r){let i=e[t.get()];t.add(1);let a=St(e,t,He(e,t)),n=r-1,s=[];i&ni.STRING&&(n-=kA(e,t,s)),n-=LA(e,t,i,s),n-=BA(e,t,i,s);let o,l=0;if(i&ni.PRESENCE){let h=OA(e,t);o=h.value,l=h.count,n--}let u=new Uint32Array;if(n>0&&(u=St(e,t,He(e,t)),n--),n!==0)throw Error(`Unexpected number of remaining streams while decoding map column: ${n}`);return{lengthStream:a,dictionary:s,presentStream:o,presentCount:l,flattenedValues:u}}function kA(e,t,r){let i=e[t.get()];t.add(1);let a=o1("",e,t,i);if(a)for(let n=0;n<a.size;n++)r.push(a.getValue(n));return i}function LA(e,t,r,i){let a=0;return r&ni.INT32?(Ca(i,hl(e,t,He(e,t))),a++):r&ni.INT64&&(Ca(i,X0(e,t,He(e,t))),a++),r&ni.UINT32?(Ca(i,St(e,t,He(e,t))),a++):r&ni.UINT64&&(Ca(i,$d(e,t,He(e,t))),a++),a}function BA(e,t,r,i){let a=0;return r&ni.FLOAT&&(Ca(i,q0(e,t,He(e,t).numValues)),a++),r&ni.DOUBLE&&(Ca(i,Z0(e,t,He(e,t).numValues)),a++),a}function OA(e,t){let r=He(e,t);if(r.physicalStreamType!==ut.PRESENT)throw Error(`Expected PRESENT stream for map column but found: ${r.physicalStreamType}`);let i=r.numValues,a=t.get(),n=new Cr(Ja(e,i,r.byteLength,t),i);return t.set(a+r.byteLength),{value:n,count:i}}function $A(e,t,r,i,a){let{lengthStream:n,flattenedValues:s,presentStream:o,dictionary:l}=e,u=t*r,h=r,c;if(o){c=new Cr(new Uint8Array(Math.ceil(r/8)),r),h=0;for(let y=0;y<r;y++)o.get(u+y)&&(c.set(y,!0),h++)}let d=i+h;if(d>n.length)throw Error("Merged map counts underflow while decoding child streams");let p=Array(r),f=i,m=a;for(let y=0;y<r;y++){if(o&&!o.get(u+y)){p[y]=null;continue}let v=m+n[f++];if(v>s.length)throw Error("Map value stream underflow while decoding feature payload");let x=jA(s,m,v,l);p[y]=x.value,m=x.nextIndex}let g=0;for(let y=i;y<d;y++)g+=n[y];let _=a+g;if(m!==_)throw Error("Unused flattened map values remain after decode");return{value:p,nullabilityBuffer:c,countsEnd:d,valuesEnd:_}}function jA(e,t,r,i){return r-t===1||e[t]===ji.START_LIST?Nd(e,t,r,i):l1(e,t,r,i)}function l1(e,t,r,i){let a=Object.create(null),n=t;for(;n<r;){let s=u1(e[n++],i);if(typeof s!="string")throw Error(`Map key dictionary index does not resolve to a string: ${s}`);let o=Nd(e,n,r,i);a[s]=o.value,n=o.nextIndex}return{value:a,nextIndex:n}}function Nd(e,t,r,i){if(t>=r)throw Error("Unexpected end of map value stream");let a=e[t];if(a===ji.FALSE)return{value:!1,nextIndex:t+1};if(a===ji.TRUE)return{value:!0,nextIndex:t+1};if(a===ji.START_MAP){let n=xm(e,t,r);return{value:l1(e,t+2,n,i).value,nextIndex:n}}if(a===ji.START_LIST){let n=xm(e,t,r),s=[],o=t+2;for(;o<n;){let l=Nd(e,o,n,i);s.push(l.value),o=l.nextIndex}return{value:s,nextIndex:n}}return{value:u1(a,i),nextIndex:t+1}}function xm(e,t,r){if(t+1>=r)throw Error("Missing length for nested map/list payload");let i=e[t+1];if(i<2)throw Error(`Invalid nested payload length: ${i}`);let a=t+i;if(a>r)throw Error("Nested payload exceeds containing payload bounds");return a}function u1(e,t){let r=e-ji.COUNT;if(r<0||r>=t.length)throw Error(`Scalar dictionary index out of range: ${e}`);return t[r]}function Ca(e,t){for(let r of t)e.push(r)}function VA(e,t,r,i,a,n){var s;return r.type==="scalarType"?NA(i,e,t,a,r.scalarType,r):((s=r.complexType)==null?void 0:s.physicalType)===wi.MAP?zA(e,t,r,i):i===0?null:MA(e,t,r)}function NA(e,t,r,i,a,n){let s;if(e===0)return null;if(n.nullable){let l=He(t,r),u=l.numValues,h=r.get(),c=Ja(t,u,l.byteLength,r);r.set(h+l.byteLength),s=new Cr(c,l.numValues)}let o=s??i;switch(a.physicalType){case Se.UINT_32:case Se.INT_32:return WA(t,r,n,a,o);case Se.STRING:{let l=n.nullable?e-1:e;return o1(n.name,t,r,l,s)??null}case Se.BOOLEAN:return UA(t,r,n,i,o);case Se.UINT_64:case Se.INT_64:return ZA(t,r,n,o,a);case Se.FLOAT:return GA(t,r,n,o);case Se.DOUBLE:return qA(t,r,n,o);default:throw Error(`The specified data type for the field is currently not supported: ${a}`)}}function UA(e,t,r,i,a){let n=He(e,t),s=n.numValues,o=t.get(),l=vs(a)?a:void 0,u=Ja(e,s,n.byteLength,t,l);t.set(o+n.byteLength);let h=new Cr(u,s);return new SA(r.name,h,a)}function GA(e,t,r,i){let a=He(e,t),n=vs(i)?i:void 0,s=q0(e,t,a.numValues,n);return new DA(r.name,s,i)}function qA(e,t,r,i){let a=He(e,t),n=vs(i)?i:void 0,s=Z0(e,t,a.numValues,n);return new Id(r.name,s,i)}function ZA(e,t,r,i,a){let n=He(e,t),s=ql(n,i,e,t,"int64"),o=a.physicalType===Se.INT_64;if(s===je.FLAT){let u=vs(i)?i:void 0,h=o?X0(e,t,n,u):$d(e,t,n,u);return new J0(r.name,h,i)}if(s===je.SEQUENCE){let u=H0(e,t,n);return new Q0(r.name,u[0],u[1],n.numRleValues,o)}let l=o?aA(e,t,n):Y0(e,t,n);return new n1(r.name,l,i,o)}function WA(e,t,r,i,a){let n=He(e,t),s=ql(n,a,e,t),o=i.physicalType===Se.INT_32;if(s===je.FLAT){let u=vs(a)?a:void 0,h=o?hl(e,t,n,void 0,u):St(e,t,n,void 0,u);return new Cd(r.name,h,a)}if(s===je.SEQUENCE){let u=W0(e,t,n);return new Md(r.name,u[0],u[1],n.numRleValues,o)}let l=o?tA(e,t,n):Od(e,t,n);return new zd(r.name,l,a,o)}function vs(e){return e instanceof Cr}const ft={ID:0,ID_NULLABLE:1,ID_LONG:2,GEOMETRY:4,SCALAR_BASE:10,STRUCT:30,MAP:31};function h1(e){switch(e){case ft.ID:case ft.ID|ft.ID_NULLABLE:case ft.ID|ft.ID_LONG:case ft.ID|ft.ID_LONG|ft.ID_NULLABLE:return{nullable:(e&ft.ID_NULLABLE)!==0,columnScope:zn.FEATURE,type:"scalarType",scalarType:{longID:(e&ft.ID_LONG)!==0,type:"logicalType",logicalType:j0.ID}};case ft.GEOMETRY:return{nullable:!1,columnScope:zn.FEATURE,type:"complexType",complexType:{type:"physicalType",physicalType:wi.GEOMETRY,children:[]}};case ft.STRUCT:return{nullable:!1,columnScope:zn.FEATURE,type:"complexType",complexType:{type:"physicalType",physicalType:wi.STRUCT,children:[]}};case ft.MAP:return{nullable:!0,columnScope:zn.FEATURE,type:"complexType",complexType:{type:"physicalType",physicalType:wi.MAP,children:[]}};default:return JA(e)}}function HA(e){return e>=ft.SCALAR_BASE}function c1(e){return e===ft.STRUCT||e===ft.MAP}function XA(e){if(e.type==="scalarType"){let t=e.scalarType;if(t.type==="physicalType")switch(t.physicalType){case Se.BOOLEAN:case Se.INT_8:case Se.UINT_8:case Se.INT_32:case Se.UINT_32:case Se.INT_64:case Se.UINT_64:case Se.FLOAT:case Se.DOUBLE:return!1;case Se.STRING:return!0;default:return!1}if(t.type==="logicalType")return!1}else if(e.type==="complexType"){let t=e.complexType;if(t.type==="physicalType")switch(t.physicalType){case wi.GEOMETRY:case wi.STRUCT:case wi.MAP:return!0;default:return!1}}return console.warn("Unexpected column type in hasStreamCount",e),!1}function YA(e){var t;return e.type==="scalarType"&&((t=e.scalarType)==null?void 0:t.type)==="logicalType"&&e.scalarType.logicalType===j0.ID}function KA(e){var t;return e.type==="complexType"&&((t=e.complexType)==null?void 0:t.type)==="physicalType"&&e.complexType.physicalType===wi.GEOMETRY}function JA(e){let t;switch(e){case 10:case 11:t=Se.BOOLEAN;break;case 12:case 13:t=Se.INT_8;break;case 14:case 15:t=Se.UINT_8;break;case 16:case 17:t=Se.INT_32;break;case 18:case 19:t=Se.UINT_32;break;case 20:case 21:t=Se.INT_64;break;case 22:case 23:t=Se.UINT_64;break;case 24:case 25:t=Se.FLOAT;break;case 26:case 27:t=Se.DOUBLE;break;case 28:case 29:t=Se.STRING;break;default:return null}return{nullable:!!(e&1),columnScope:zn.FEATURE,type:"scalarType",scalarType:{longID:!1,type:"physicalType",physicalType:t}}}const QA=new TextDecoder,vm="0-3(ID), 4(GEOMETRY), 10-29(scalars), 30(STRUCT), 31(MAP)";function Ud(e,t){let r=Mt(e,t,1)[0];if(r===0)return"";let i=t.get(),a=i+r,n=e.subarray(i,a);return t.add(r),QA.decode(n)}function eC(e){let t=e.name,r=e.nullable;return e.type==="scalarType"?{type:"scalarField",scalarField:e.scalarType,name:t,nullable:r}:{type:"complexField",complexField:e.complexType,name:t,nullable:r}}function d1(e,t){let r=Mt(e,t,1)[0]>>>0,i=r>=ft.SCALAR_BASE?h1(r):null;if(!i)throw Error(`Unsupported field type code ${r}. Supported: 10-29(scalars), 30(STRUCT), 31(MAP)`);let a={...i,name:Ud(e,t)};if(a.type==="complexType"&&c1(r)){let n=a.complexType,s=Mt(e,t,1)[0]>>>0;n.children=Array(s);for(let o=0;o<s;o++)n.children[o]=d1(e,t)}return eC(a)}function tC(e,t){let r=Mt(e,t,1)[0]>>>0,i=h1(r);if(!i)throw Error(`Unsupported column type code ${r}. Supported: ${vm}`);let a;if(HA(r))a=Ud(e,t);else if(r<ft.GEOMETRY)a="id";else if(r===ft.GEOMETRY)a="geometry";else throw Error(`Unsupported column type code ${r}. Supported: ${vm}`);let n={...i,name:a};if(n.type==="complexType"&&c1(r)){let s=Mt(e,t,1)[0]>>>0,o=n.complexType;o.children=Array(s);for(let l=0;l<s;l++)o.children[l]=d1(e,t)}return n}function rC(e,t){let r={};r.featureTables=[];let i={};if(i.name=Ud(e,t),i.name.length===0)throw Error("Missing layer name");let a=Mt(e,t,1)[0]>>>0,n=Mt(e,t,1)[0]>>>0;i.columns=Array(n);for(let s=0;s<n;s++)i.columns[s]=tC(e,t);return r.featureTables.push(i),[r,a]}function iC(e,t,r=!0){let i=new V0(0),a=[];for(;i.get()<e.length;){let n=Mt(e,i,1)[0]>>>0,s=i.get()+n;if(s>e.length)throw Error(`Block overruns tile: ${s} > ${e.length}`);let o=Mt(e,i,1)[0]>>>0;if(o!==1&&o!==2){i.set(s);continue}let[l,u]=rC(e,i),h=l.featureTables[0],c=null,d=null,p=[],f=0;for(let g of h.columns){let _=g.name;if(YA(g)){let y=null;if(g.nullable){let x=He(e,i),w=i.get(),b=Ja(e,x.numValues,x.byteLength,i);i.set(w+x.byteLength),y=new Cr(b,x.numValues)}let v=He(e,i);f=y?y.size():v.decompressedCount,c=aC(e,g,i,_,v,y??f,r)}else if(KA(g)){let y=Mt(e,i,1)[0];if(f===0){let v=i.get();f=He(e,i).decompressedCount,i.set(v)}d=bA(e,y,i,f,t)}else{let y=XA(g)?Mt(e,i,1)[0]:1;if(y===0)continue;let v=VA(e,i,g,y,f);if(v)if(Array.isArray(v))for(let x of v)p.push(x);else p.push(v)}}let m=new PE(h.name,d,c,p,u);a.push(m),i.set(s)}return a}function aC(e,t,r,i,a,n,s=!1){var h;let o=(h=t.scalarType)!=null&&h.longID?Se.UINT_64:Se.UINT_32,l=typeof n=="number"?void 0:n,u=ql(a,n,e,r,o===Se.UINT_64?"int64":"int32");if(o===Se.UINT_32)switch(u){case je.FLAT:return new Cd(i,St(e,r,a,void 0,l),n);case je.SEQUENCE:{let c=W0(e,r,a);return new Md(i,c[0],c[1],a.numRleValues,!1)}case je.CONST:return new zd(i,Od(e,r,a),n,!1)}switch(u){case je.FLAT:return s?new Id(i,rA(e,r,a,l),n):new J0(i,$d(e,r,a,l),n);case je.SEQUENCE:{let c=H0(e,r,a);return new Q0(i,c[0],c[1],a.numRleValues,!1)}case je.CONST:return new n1(i,Y0(e,r,a),n,!1)}throw Error("Vector type not supported for id column.")}var nC=class{constructor(e,t){var r;switch(this._featureData=e,this.properties=this._featureData.properties||{},(r=this._featureData.geometry)==null?void 0:r.type){case Ct.POINT:case Ct.MULTIPOINT:this.type=1;break;case Ct.LINESTRING:case Ct.MULTILINESTRING:this.type=2;break;case Ct.POLYGON:case Ct.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 r=[];for(let i of t)r.push(new M(i.x,i.y));e.push(r)}return e}},sC=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 nC(this.features[e],this.extent)}},oC=class{constructor(e){this.layers={};let t=iC(new Uint8Array(e));this.layers=t.reduce((r,i)=>({...r,[i.name]:new sC(i)}),{})}},lC=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 Ih(L,16,0),this.grid3D=new Ih(L,16,0),this.featureIndexArray=new zy,this.promoteId=t}insert(e,t,r,i,a,n){let s=this.featureIndexArray.length;this.featureIndexArray.emplaceBack(r,i,a);let o=n?this.grid3D:this.grid;for(let l of t){let u=[1/0,1/0,-1/0,-1/0];for(let h of l)u[0]=Math.min(u[0],h.x),u[1]=Math.min(u[1],h.y),u[2]=Math.max(u[2],h.x),u[3]=Math.max(u[3],h.y);u[0]<8192&&u[1]<8192&&u[2]>=0&&u[3]>=0&&o.insert(s,u[0],u[1],u[2],u[3])}}loadVTLayers(){if(!this.vtLayers){switch(this.encoding){case"mlt":this.vtLayers=new oC(this.rawTileData).layers;break;default:this.vtLayers=new kT(new x0(this.rawTileData)).layers}this.sourceLayerCoder=new EE(this.vtLayers?Object.keys(this.vtLayers).sort():[Mo])}return this.vtLayers}query(e,t,r,i){this.loadVTLayers();let a=e.params,n=L/e.tileSize/e.scale,s=Hn(a.filter,"queryRenderedFeatures filter",a.globalState),o=e.queryGeometry,l=e.queryPadding*n,u=Er.fromPoints(o),h=this.grid.query(u.minX-l,u.minY-l,u.maxX+l,u.maxY+l),c=Er.fromPoints(e.cameraQueryGeometry).expandBy(l),d=this.grid3D.query(c.minX,c.minY,c.maxX,c.maxY,(m,g,_,y)=>mw(e.cameraQueryGeometry,m-l,g-l,_+l,y+l));for(let m of d)h.push(m);h.sort(hC);let p={},f;for(let m of h){if(m===f)continue;f=m;let g=this.featureIndexArray.get(m),_=null;this.loadMatchingFeature(p,g.bucketIndex,g.sourceLayerIndex,g.featureIndex,s,a.layers,a.availableImages,t,r,i,(y,v,x)=>(_||(_=ia(y)),v.queryIntersectsFeature({queryGeometry:o,feature:y,featureState:x,geometry:_,zoom:this.z,transform:e.transform,pixelsToTileUnits:n,pixelPosMatrix:e.pixelPosMatrix,unwrappedTileID:this.tileID.toUnwrapped(),getElevation:e.getElevation})))}return p}loadMatchingFeature(e,t,r,i,a,n,s,o,l,u,h){let c=this.bucketLayerIDs[t];if(n&&!c.some(m=>n.has(m)))return;let d=this.sourceLayerCoder.decode(r),p=this.vtLayers[d].feature(i);if(a.needGeometry){let m=aa(p,!0);if(!a.filter(new ze(this.tileID.overscaledZ),m,this.tileID.canonical))return}else if(!a.filter(new ze(this.tileID.overscaledZ),p))return;let f=this.getId(p,d);for(let m of c){if(n&&!n.has(m))continue;let g=o[m];if(!g)continue;let _={};f&&u&&(_=u.getState(g.sourceLayer||"_geojsonTileLayer",f));let y=H({},l[m]);y.paint=bm(y.paint,g.paint,p,_,s),y.layout=bm(y.layout,g.layout,p,_,s);let v=!h||h(p,g,_);if(!v)continue;let x=new O0(p,this.z,this.x,this.y,f);x.layer=y;let w=e[m];w===void 0&&(w=e[m]=[]),w.push({featureIndex:i,feature:x,intersectionZ:v})}}lookupSymbolFeatures(e,t,r,i,a,n,s,o){let l={};this.loadVTLayers();let u=Hn(a.filterSpec,"queryRenderedFeatures symbol filter",a.globalState);for(let h of e)this.loadMatchingFeature(l,r,i,h,u,n,s,o,t);return l}hasLayer(e){for(let t of this.bucketLayerIDs)for(let r of t)if(e===r)return!0;return!1}getId(e,t){var i;let r=e.id;if(this.promoteId){let a=typeof this.promoteId=="string"?this.promoteId:this.promoteId[t];r=e.properties[a],typeof r=="boolean"&&(r=Number(r)),r===void 0&&((i=e.properties)!=null&&i.cluster)&&this.promoteId&&(r=Number(e.properties.cluster_id))}return r}};G("FeatureIndex",lC,{omit:["rawTileData","sourceLayerCoder"]});function uC(e){return typeof e=="object"&&!!e&&"evaluate"in e}function bm(e,t,r,i,a){return Zc(e,(n,s)=>{let o=t instanceof kl?t.get(s):null;return uC(o)?o.evaluate(r,i,void 0,a):o})}function hC(e,t){return t-e}var cC=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,r){let i=e.wrapped().key;this.data[i]===void 0&&(this.data[i]=[]);let a={value:t,timeout:void 0};if(r!==void 0&&(a.timeout=setTimeout(()=>{this.remove(e,a)},r)),this.data[i].push(a),this.order.push(i),this.order.length>this.max){let n=this._getAndRemoveByKey(this.order[0]);n&&this.onRemove(n)}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),this.data[e].length===0&&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 r=e.wrapped().key,i=t===void 0?0:this.data[r].indexOf(t),a=this.data[r][i];return this.data[r].splice(i,1),a.timeout&&clearTimeout(a.timeout),this.data[r].length===0&&delete this.data[r],this.onRemove(a.value),this.order.splice(this.order.indexOf(r),1),this}setMaxSize(e){for(this.max=e;this.order.length>this.max;){let t=this._getAndRemoveByKey(this.order[0]);t&&this.onRemove(t)}return this}filter(e){let t=[];for(let r in this.data)for(let i of this.data[r])e(i.value)||t.push(i);for(let r of t)this.remove(r.value.tileID,r)}};/**
|
|
6
|
+
* MapLibre GL JS
|
|
7
|
+
* @license 3-Clause BSD. Full text of license: https://github.com/maplibre/maplibre-gl-js/blob/v6.11.2/LICENSE.txt
|
|
8
|
+
*/var dC="6.11.2";function p1(){var e=new _t(4);return _t!=Float32Array&&(e[1]=0,e[2]=0),e[0]=1,e[3]=1,e}function pC(e,t){var r=t[0],i=t[1],a=t[2],n=t[3],s=r*n-a*i;return s?(s=1/s,e[0]=n*s,e[1]=-i*s,e[2]=-a*s,e[3]=r*s,e):null}function fC(e){return e[0]*e[3]-e[2]*e[1]}function mC(e,t,r){var i=t[0],a=t[1],n=t[2],s=t[3],o=Math.sin(r),l=Math.cos(r);return e[0]=i*l+n*o,e[1]=a*l+s*o,e[2]=i*-o+n*l,e[3]=a*-o+s*l,e}let Gu,wm,qu;const Xt={frame(e,t,r,i){let a=i||window,n=a.requestAnimationFrame(o=>{s(),t(o)}),{unsubscribe:s}=jo(e.signal,"abort",()=>{s(),a.cancelAnimationFrame(n),r(new ls(e.signal.reason))},!1)},frameAsync(e,t){return new Promise((r,i)=>{this.frame(e,r,i,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(Nc()&&!Og())t=new OffscreenCanvas(e.width,e.height).getContext("2d",{willReadFrequently:!0});else{let r=window.document.createElement("canvas");r.width=e.width,r.height=e.height,t=r.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){return Gu||(Gu=document.createElement("a")),Gu.href=e,Gu.href},get hardwareConcurrency(){return typeof navigator<"u"&&navigator.hardwareConcurrency||4},get prefersReducedMotion(){return qu===void 0?matchMedia?(wm??(wm=matchMedia("(prefers-reduced-motion: reduce)")),wm.matches):!1:qu},set prefersReducedMotion(e){qu=e}},gC=new class{constructor(){this._frozenAt=null}getCurrentTime(){return this._frozenAt===null?performance.now():this._frozenAt}setNow(e){this._frozenAt=e}restoreNow(){this._frozenAt=null}isFrozen(){return this._frozenAt!==null}};function Fe(){return gC.getCurrentTime()}const _C=new Set("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(".")),yC=new Set(["alt","class","datetime","dir","height","href","hreflang","lang","referrerpolicy","rel","role","src","target","title","translate","type","width"]),xC=new Set(["href","src"]),vC=new Set(["http:","https:","mailto:"]);let Tm;function Zu(){return Tm??(Tm={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}),Tm}var t,Be,at=(Be=class{static create(t,r,i){let a=window.document.createElement(t);return r!==void 0&&(a.className=r),i&&i.appendChild(a),a}static createNS(t,r){return window.document.createElementNS(t,r)}static disableDrag(){Be.docStyle&&Be.selectProp&&(Be.userSelect=Be.docStyle[Be.selectProp],Be.docStyle[Be.selectProp]="none")}static enableDrag(){Be.docStyle&&Be.selectProp&&(Be.docStyle[Be.selectProp]=Be.userSelect)}static suppressClickInternal(t){t.preventDefault(),t.stopPropagation(),window.removeEventListener("click",Be.suppressClickInternal,!0)}static suppressClick(){window.addEventListener("click",Be.suppressClickInternal,!0),window.setTimeout(()=>{window.removeEventListener("click",Be.suppressClickInternal,!0)},0)}static getScale(t){let r=t.getBoundingClientRect();return{x:r.width/t.offsetWidth||1,y:r.height/t.offsetHeight||1,boundingClientRect:r}}static getPoint(t,r,i){let a=r.boundingClientRect;return new M((i.clientX-a.left)/r.x-t.clientLeft,(i.clientY-a.top)/r.y-t.clientTop)}static mousePos(t,r){let i=Be.getScale(t);return Be.getPoint(t,i,r)}static touchPos(t,r){let i=[],a=Be.getScale(t);for(let n of r)i.push(Be.getPoint(t,a,n));return i}static sanitize(t){let r=new DOMParser().parseFromString(t,"text/html").body,{querySelectorAll:i,remove:a}=Zu();for(let s of Array.from(i.call(r,"*")))Be.isAllowedElement(s)?Be.removeDisallowedAttributes(s):a.call(s);let n=document.createDocumentFragment();return n.append(...r.childNodes),n}static isAllowedElement(t){let{namespaceURI:r,localName:i}=Zu();return r.call(t)==="http://www.w3.org/1999/xhtml"&&_C.has(i.call(t))}static removeDisallowedAttributes(t){let{getAttributeNames:r,getAttribute:i,removeAttribute:a}=Zu();for(let n of r.call(t))Be.isAllowedAttribute(n,i.call(t,n))||a.call(t,n)}static isAllowedAttribute(t,r){if(!yC.has(t)&&!t.startsWith("aria-"))return!1;if(!xC.has(t))return!0;try{return vC.has(new URL(r,"https://maplibre.invalid/").protocol)}catch{return!1}}},Be.docStyle=typeof window<"u"&&((t=window.document)==null?void 0:t.documentElement.style),Be.selectProp=!Be.docStyle||"userSelect"in Be.docStyle?"userSelect":"webkitUserSelect",Be);let Ur;(function(e){let t,r,i,a;e.resetRequestQueue=()=>{t=[],r=0,i=0,a={}},e.addThrottleControl=c=>{let d=i++;return a[d]=c,d},e.removeThrottleControl=c=>{delete a[c],u()};let n=()=>{for(let c of Object.keys(a))if(a[c]())return!0;return!1};async function s(c,d,p,f,m=!0,g){let _=await c.transformRequest(d,p);return Wc(f.signal),Ur.getImage(_,f,m,g)}e.transformAndGetImage=s,e.getImage=(c,d,p=!0,f)=>new Promise((m,g)=>{c.headers||(c.headers={}),c.headers.accept="image/webp,*/*",H(c,{type:"image"});let _={abortController:d,requestParameters:c,supportImageRefresh:p,imageBitmapOptions:f,state:"queued",onError:y=>{g(y)},onSuccess:y=>{m(y)}};t.push(_),u()});let o=(c,d)=>typeof createImageBitmap=="function"?bv(c,d):wv(c),l=async c=>{c.state="running";let{requestParameters:d,supportImageRefresh:p,imageBitmapOptions:f,onError:m,onSuccess:g,abortController:_}=c,y=p===!1&&!f&&!$a(self)&&!Hg(d.url)&&(!d.headers||Object.keys(d.headers).reduce((x,w)=>x&&w==="accept",!0));r++;let v=y?h(d,_):yl(d,_);try{let x=await v;delete c.abortController,c.state="completed",x.data instanceof HTMLImageElement||Ni(x.data)?g(x):!x.data||x.data.byteLength===0?g({data:null,cacheControl:x.cacheControl,expires:x.expires}):g({data:await o(x.data,f),cacheControl:x.cacheControl,expires:x.expires})}catch(x){delete c.abortController,m(zt(x))}finally{r--,u()}},u=()=>{let c=n()?Yi.MAX_PARALLEL_IMAGE_REQUESTS_PER_FRAME:Yi.MAX_PARALLEL_IMAGE_REQUESTS;for(let d=r;d<c&&t.length>0;d++){let p=t.shift();if(p.abortController.signal.aborted){d--;continue}l(p)}},h=(c,d)=>new Promise((p,f)=>{let m=new Image,g=c.url,_=c.credentials;_&&_==="include"?m.crossOrigin="use-credentials":(_&&_==="same-origin"||!Yg(g))&&(m.crossOrigin="anonymous"),d.signal.addEventListener("abort",()=>{m.src="",f(new ls(d.signal.reason))}),m.fetchPriority="high",m.onload=()=>{m.onerror=m.onload=null,p({data:m})},m.onerror=()=>{m.onerror=m.onload=null,!d.signal.aborted&&f(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."))},m.src=g})})(Ur||(Ur={})),Ur.resetRequestQueue();var bC=class{constructor(e){this._transformRequestFn=e??null}transformRequest(e,t){return this._transformRequestFn&&this._transformRequestFn(e,t)||{url:e}}setTransformRequest(e){this._transformRequestFn=e}},bt=class extends us{},J=class extends bt{},Sm=class extends bt{constructor(e={}){super("style.load",e)}},Tr=class extends bt{constructor(e,t={}){super(e,t),this.dataType="style"}},Ne=class extends bt{constructor(e,t={}){super(e,t),this.dataType="source"}},ir=class extends bt{preventDefault(){this._defaultPrevented=!0}get defaultPrevented(){return this._defaultPrevented}constructor(e,t,r,i={}){r=r instanceof MouseEvent?r:new MouseEvent(e,r);let a=at.mousePos(t.getCanvas(),r),n=t.unproject(a);super(e,H({point:a,lngLat:n,originalEvent:r},i)),this._defaultPrevented=!1,this.target=t}},no=class extends bt{preventDefault(){this._defaultPrevented=!0}get defaultPrevented(){return this._defaultPrevented}constructor(e,t,r){let i=e==="touchend"?r.changedTouches:r.touches,a=at.touchPos(t.getCanvasContainer(),i),n=a.map(l=>t.unproject(l)),s=a.reduce((l,u,h,c)=>l.add(u.div(c.length)),new M(0,0)),o=t.unproject(s);super(e,{points:a,point:s,lngLats:n,lngLat:o,originalEvent:r}),this._defaultPrevented=!1}},wC=class extends bt{preventDefault(){this._defaultPrevented=!0}get defaultPrevented(){return this._defaultPrevented}constructor(e,t){super("wheel",{originalEvent:t}),this._defaultPrevented=!1}},Dm=class extends bt{},TC=class extends bt{constructor(e={}){super("terrain",e)}},SC=class extends bt{constructor(e={}){super("projectiontransition",e)}},Wu=class extends bt{},DC=class extends bt{constructor(e={}){super("styleimagemissing",e)}};function EC(e,t){let r={};for(let i in e)i!=="ref"&&(r[i]=e[i]);return Rv.forEach(i=>{i in t&&(r[i]=t[i])}),r}function Em(e){e=e.slice();let t=Object.create(null);for(let r=0;r<e.length;r++)t[e[r].id]=e[r];for(let r=0;r<e.length;r++)"ref"in e[r]&&(e[r]=EC(e[r],t[e[r].ref]));return e}function Ce(e,t){if(Array.isArray(e)){if(!Array.isArray(t)||e.length!==t.length)return!1;for(let r=0;r<e.length;r++)if(!Ce(e[r],t[r]))return!1;return!0}if(typeof e=="object"&&e&&t!==null){if(typeof t!="object"||Object.keys(e).length!==Object.keys(t).length)return!1;for(let r in e)if(!Ce(e[r],t[r]))return!1;return!0}return e===t}function tr(e,t){e.push(t)}function f1(e,t,r){tr(r,{command:"addSource",args:[e,t[e]]})}function m1(e,t,r){tr(t,{command:"removeSource",args:[e]}),r[e]=!0}function PC(e,t,r,i){m1(e,r,i),f1(e,t,r)}function AC(e,t,r){let i;for(i in e[r])if(Object.prototype.hasOwnProperty.call(e[r],i)&&i!=="data"&&!Ce(e[r][i],t[r][i]))return!1;for(i in t[r])if(Object.prototype.hasOwnProperty.call(t[r],i)&&i!=="data"&&!Ce(e[r][i],t[r][i]))return!1;return!0}function CC(e,t,r,i){e||(e={}),t||(t={});let a;for(a in e)Object.prototype.hasOwnProperty.call(e,a)&&(Object.prototype.hasOwnProperty.call(t,a)||m1(a,r,i));for(a in t)Object.prototype.hasOwnProperty.call(t,a)&&(Object.prototype.hasOwnProperty.call(e,a)?Ce(e[a],t[a])||(e[a].type==="geojson"&&t[a].type==="geojson"&&AC(e,t,a)?tr(r,{command:"setGeoJSONSourceData",args:[a,t[a].data]}):PC(a,t,r,i)):f1(a,t,r))}function Pm(e,t,r,i,a){tr(t,{command:a,args:[r,i,e[i]]})}function so(e,t,r,i,a){e||(e={}),t||(t={});for(let n in e)Object.prototype.hasOwnProperty.call(e,n)&&(Ce(e[n],t[n])||Pm(t,r,i,n,a));for(let n in t)Object.prototype.hasOwnProperty.call(t,n)&&!Object.prototype.hasOwnProperty.call(e,n)&&(Ce(e[n],t[n])||Pm(t,r,i,n,a))}function Am(e){return e.id}function Cm(e,t){return e[t.id]=t,e}function IC(e,t,r){e||(e=[]),t||(t=[]);let i=e.map(Am),a=t.map(Am),n=e.reduce(Cm,{}),s=t.reduce(Cm,{}),o=i.slice(),l=Object.create(null),u,h,c,d,p;for(let f=0,m=0;f<i.length;f++)u=i[f],Object.prototype.hasOwnProperty.call(s,u)?m++:(tr(r,{command:"removeLayer",args:[u]}),o.splice(o.indexOf(u,m),1));for(let f=0,m=0;f<a.length;f++)u=a[a.length-1-f],o[o.length-1-f]!==u&&(Object.prototype.hasOwnProperty.call(n,u)?(tr(r,{command:"removeLayer",args:[u]}),o.splice(o.lastIndexOf(u,o.length-m),1)):m++,d=o[o.length-f],tr(r,{command:"addLayer",args:[s[u],d]}),o.splice(o.length-f,0,u),l[u]=!0);for(let f=0;f<a.length;f++)if(u=a[f],h=n[u],c=s[u],!(l[u]||Ce(h,c))){if(!Ce(h.source,c.source)||!Ce(h["source-layer"],c["source-layer"])||!Ce(h.type,c.type)){tr(r,{command:"removeLayer",args:[u]}),d=o[o.lastIndexOf(u)+1],tr(r,{command:"addLayer",args:[c,d]});continue}for(p in so(h.layout,c.layout,r,u,"setLayoutProperty"),so(h.paint,c.paint,r,u,"setPaintProperty"),Ce(h.filter,c.filter)||tr(r,{command:"setFilter",args:[u,c.filter]}),(!Ce(h.minzoom,c.minzoom)||!Ce(h.maxzoom,c.maxzoom))&&tr(r,{command:"setLayerZoomRange",args:[u,c.minzoom,c.maxzoom]}),h)Object.prototype.hasOwnProperty.call(h,p)&&p!=="layout"&&p!=="paint"&&p!=="filter"&&p!=="metadata"&&p!=="minzoom"&&p!=="maxzoom"&&(p.indexOf("paint.")===0?so(h[p],c[p],r,u,"setPaintProperty"):Ce(h[p],c[p])||tr(r,{command:"setLayerProperty",args:[u,p,c[p]]}));for(p in c)Object.prototype.hasOwnProperty.call(c,p)&&!Object.prototype.hasOwnProperty.call(h,p)&&p!=="layout"&&p!=="paint"&&p!=="filter"&&p!=="metadata"&&p!=="minzoom"&&p!=="maxzoom"&&(p.indexOf("paint.")===0?so(h[p],c[p],r,u,"setPaintProperty"):Ce(h[p],c[p])||tr(r,{command:"setLayerProperty",args:[u,p,c[p]]}))}}function MC(e,t){if(!e)return[{command:"setStyle",args:[t]}];let r=[];try{if(!Ce(e.version,t.version))return[{command:"setStyle",args:[t]}];Ce(e.center,t.center)||r.push({command:"setCenter",args:[t.center]}),Ce(e.state,t.state)||r.push({command:"setGlobalState",args:[t.state]}),Ce(e.centerAltitude,t.centerAltitude)||r.push({command:"setCenterAltitude",args:[t.centerAltitude]}),Ce(e.zoom,t.zoom)||r.push({command:"setZoom",args:[t.zoom]}),Ce(e.bearing,t.bearing)||r.push({command:"setBearing",args:[t.bearing]}),Ce(e.pitch,t.pitch)||r.push({command:"setPitch",args:[t.pitch]}),Ce(e.roll,t.roll)||r.push({command:"setRoll",args:[t.roll]}),Ce(e.sprite,t.sprite)||r.push({command:"setSprite",args:[t.sprite]}),Ce(e.glyphs,t.glyphs)||r.push({command:"setGlyphs",args:[t.glyphs]}),Ce(e["font-faces"],t["font-faces"])||r.push({command:"setFontFaces",args:[t["font-faces"]]}),Ce(e.transition,t.transition)||r.push({command:"setTransition",args:[t.transition]}),Ce(e.light,t.light)||r.push({command:"setLight",args:[t.light]});let i=!Ce(e.terrain,t.terrain);i&&!t.terrain&&r.push({command:"setTerrain",args:[void 0]}),Ce(e.sky,t.sky)||r.push({command:"setSky",args:[t.sky]}),Ce(e.projection,t.projection)||r.push({command:"setProjection",args:[t.projection]});let a={},n=[];CC(e.sources,t.sources,n,a);let s=[];e.layers&&e.layers.forEach(o=>{"source"in o&&a[o.source]?r.push({command:"removeLayer",args:[o.id]}):s.push(o)}),r=r.concat(n),IC(s,t.layers,r),i&&t.terrain&&r.push({command:"setTerrain",args:[t.terrain]})}catch(i){console.warn("Unable to compute style diff:",i),r=[{command:"setStyle",args:[t]}]}return r}function zC(){let e={},t=z.$version;for(let r in z.$root){let i=z.$root[r];if(i.required){let a=null;a=r==="version"?t:i.type==="array"?[]:{},a!=null&&(e[r]=a)}}return e}function zo(e){let t=[];if(typeof e=="string")t.push({id:"default",url:e});else if(e&&e.length>0){let r=[];for(let{id:i,url:a}of e){let n=`${i}${a}`;r.includes(n)||(r.push(n),t.push({id:i,url:a}))}}return t}function Im(e,t,r){try{let i=new URL(e);return i.pathname+=`${t}${r}`,i.toString()}catch{throw Error(`Invalid sprite URL "${e}", must be absolute. Modify style specification directly or use TransformStyleFunction to correct the issue dynamically`)}}async function FC(e,t,r,i){let a=zo(e),n=r>1?"@2x":"",s={},o={};for(let{id:l,url:u}of a){let h=await t.transformRequest(Im(u,n,".json"),"SpriteJSON");s[l]=xl(h,i);let c=await t.transformRequest(Im(u,n,".png"),"SpriteImage");o[l]=Ur.getImage(c,i)}return await Promise.all([...Object.values(s),...Object.values(o)]),RC(s,o)}async function RC(e,t){let r={};for(let i in e){r[i]={};let a=(await t[i]).data;if(!a)throw Error(`Could not load sprite image for ${i}: the response is empty`);let n=Xt.getImageCanvasContext(a),s=(await e[i]).data;for(let o in s){let{width:l,height:u,x:h,y:c,sdf:d,pixelRatio:p,stretchX:f,stretchY:m,content:g,textFitWidth:_,textFitHeight:y}=s[o],v={width:l,height:u,x:h,y:c,context:n};r[i][o]={data:null,pixelRatio:p,sdf:d,stretchX:f,stretchY:m,content:g,textFitWidth:_,textFitHeight:y,spriteData:v}}}return r}var kC=class extends kt{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:t,promiseResolve:r}of this.requestors)r(this._getImagesForIds(t));this.requestors=[]}}getImage(e){let t=this.images[e];if(t&&!t.data&&t.spriteData){let r=t.spriteData;t.data=new $e({width:r.width,height:r.height},r.context.getImageData(r.x,r.y,r.width,r.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 r=!0,i=t.data||t.spriteData;return this._validateStretch(t.stretchX,i==null?void 0:i.width)||(this.fire(new Y(Error(`Image "${e}" has invalid "stretchX" value`))),r=!1),this._validateStretch(t.stretchY,i==null?void 0:i.height)||(this.fire(new Y(Error(`Image "${e}" has invalid "stretchY" value`))),r=!1),this._validateContent(t.content,t)||(this.fire(new Y(Error(`Image "${e}" has invalid "content" value`))),r=!1),r}_validateStretch(e,t){if(!e)return!0;let r=0;for(let i of e){if(i[0]<r||i[1]<i[0]||t<i[1])return!1;r=i[1]}return!0}_validateContent(e,t){if(!e)return!0;if(e.length!==4)return!1;let r=t.spriteData,i=(r==null?void 0:r.width)||t.data.width,a=(r==null?void 0:r.height)||t.data.height;return e[0]<0||i<e[0]||e[1]<0||a<e[1]||e[2]<0||i<e[2]||e[3]<0||a<e[3]||e[2]<e[0]?!1:e[3]>=e[1]}updateImage(e,t,r=!0){let i=this.images[e];if(r){let a=i.data||i.spriteData;if(a.width!==t.data.width||a.height!==t.data.height)throw Error(`size mismatch between old image (${a.width}x${a.height}) and new image (${t.data.width}x${t.data.height}).`)}t.version=(i.version??0)+1,this.images[e]=t,this.updateVersion++}removeImage(e){var r;let t=this.images[e];t&&(delete this.images[e],this._imagesIds=null,(r=t.userImage)!=null&&r.onRemove&&t.userImage.onRemove())}listImages(){return this._imagesIds??(this._imagesIds=Object.keys(this.images)),this._imagesIds}_getSpriteImageId(e,t){return e==="default"?t:`${e}:${t}`}setSpriteImages(e,t){let r=this._spriteImagesIds[e]??[],i=[];for(let s in t){let o=this._getSpriteImageId(e,s);i.push(o),o in this.images?this.updateImage(o,t[s],!1):this.addImage(o,t[s])}let a=new Set(i),n=r.filter(s=>!a.has(s));for(let s of n)this.removeImage(s);return this._spriteImagesIds[e]=i,{loaded:i,removed:n}}removeSpriteImages(e){let t=this._spriteImagesIds[e]??[];for(let r of t)this.removeImage(r);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,r)=>{let i=!0;if(!this.isLoaded())for(let a of e)this.images[a]||(i=!1);this.isLoaded()||i?t(this._getImagesForIds(e)):this.requestors.push({ids:e,promiseResolve:t})})}async _getImagesForIds(e){var a;let t=new Set(e.filter(n=>!this.getImage(n))),r=this.missingImageResolver;r&&await Promise.allSettled(Array.from(t,n=>r(n)));let i={};for(let n of e){let s=this.getImage(n);s&&(t.delete(n),i[n]={data:s.data.clone(),pixelRatio:s.pixelRatio,sdf:s.sdf,version:s.version,stretchX:s.stretchX,stretchY:s.stretchY,content:s.content,textFitWidth:s.textFitWidth,textFitHeight:s.textFitHeight,hasRenderCallback:!!((a=s.userImage)!=null&&a.render),isWebGLImage:s.isWebGLImage})}for(let n of t)this.fire(new DC({id:n})),_e(`Image "${n}" 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 i}beginFrame(){this._renderCallbacksDispatchedThisFrame={}}dispatchRenderCallbacks(e){for(let t of e){if(this._renderCallbacksDispatchedThisFrame[t])continue;this._renderCallbacksDispatchedThisFrame[t]=!0;let r=this.getImage(t);r||_e(`Image with ID: "${t}" was not found`),yD(r)&&this.updateImage(t,r)}}cloneImages(){let e={};for(let t in this.images){let r=this.images[t];e[t]={...r,data:r.data?r.data.clone():null}}return e}},LC=class{constructor(e){this._imageManager=e,this._entries={},this._image=new $e({width:1,height:1}),this._dirty=!0}destroy(){this._texture&&(this._texture=(this._texture.destroy(),null)),this._entries={},this._image=new $e({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 r=this._entries[e];if((r==null?void 0:r.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 Ed(i,t),image:t}}else if(r.position.version!==t.version)r.position.version=t.version;else return r.position;return this._update(),this._entries[e].position}bind(e){let t=e.gl;this._texture?this._dirty&&(this._dirty=(this._texture.update(this._image),!1)):(this._texture=new dt(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:r}=v0(e),i=this._image;i.resize({width:t||1,height:r||1});for(let a in this._entries){let{bin:n}=this._entries[a],s=n.x+1,o=n.y+1,l=this._entries[a].image.data,u=l.width,h=l.height;$e.copy(l,i,{x:0,y:0},{x:s,y:o},{width:u,height:h}),$e.copy(l,i,{x:0,y:h-1},{x:s,y:o-1},{width:u,height:1}),$e.copy(l,i,{x:0,y:0},{x:s,y:o+h},{width:u,height:1}),$e.copy(l,i,{x:u-1,y:0},{x:s-1,y:o},{width:1,height:h}),$e.copy(l,i,{x:0,y:0},{x:s+u,y:o},{width:1,height:h})}this._dirty=!0}};const Ac=1114111,BC={start:0,end:Ac};let OC=0;function $C(e){let t=/^u\+([0-9a-f]*)(\?+)$/i.exec(e);if(t){let[,a,n]=t;return a.length+n.length>6?null:Mm(parseInt(`${a}${"0".repeat(n.length)}`,16),parseInt(`${a}${"f".repeat(n.length)}`,16))}let r=/^u\+([0-9a-f]{1,6})(?:-([0-9a-f]{1,6}))?$/i.exec(e);if(!r)return null;let i=parseInt(r[1],16);return Mm(i,r[2]===void 0?i:parseInt(r[2],16))}function Mm(e,t){return e>t||e>Ac?null:{start:e,end:Math.min(t,Ac)}}function jC(e,t){return e.ranges.some(({start:r,end:i})=>t>=r&&t<=i)}var VC=class{constructor(e){this.requestManager=e,this._faces={},this._registered=new Set}setFontFaces(e){this._unregisterAll(),this._faces={};for(let[t,r]of Object.entries(e??{})){let i=Array.isArray(r)?r:[r];this._faces[t]=i.map(a=>this._declareFontFace(t,a)).filter(a=>a!==null)}}hasFontFaces(){return Object.keys(this._faces).length>0}async getFontFamily(e,t){for(let r of e.split(","))for(let i of this._faces[r.trim()]??[])if(jC(i,t)&&(i.loaded??(i.loaded=this._loadFontFace(i)),await i.loaded))return i.family;return null}_declareFontFace(e,t){let r=typeof t=="string"?{url:t}:t;if(typeof(r==null?void 0:r.url)!="string")return _e(`Ignoring the font face declared for "${e}": it has no URL.`),null;let i=`maplibre-gl-font-face-${OC++}`,a=r["unicode-range"];if(!(a!=null&&a.length))return{url:r.url,ranges:[BC],family:i};let n=[];for(let s of a){let o=$C(s);if(!o){_e(`Ignoring the unicode range "${s}" of the font face at ${r.url}: it is not a valid range.`);continue}n.push(o)}return n.length?{url:r.url,ranges:n,family:i}:null}async _loadFontFace(e){if(typeof FontFace>"u"||typeof document>"u"||!document.fonts)return _e(`Ignoring the font face at ${e.url}: this environment has no CSS Font Loading API.`),!1;let t;try{return t=new FontFace(e.family,await this._downloadFontFile(e.url)),Object.values(this._faces).some(r=>r.includes(e))?(document.fonts.add(t),this._registered.add(t),await t.load(),!0):!1}catch(r){return t&&this._unregister(t),_e(`Ignoring the font face at ${e.url}: ${zt(r).message}`),!1}}async _downloadFontFile(e){let t=await this.requestManager.transformRequest(e,"Glyphs"),r=await Xg(t,new AbortController);if(!(r!=null&&r.data))throw Error(`the response was empty for the font file at ${e}`);return r.data}_unregister(e){var t;(t=document.fonts)==null||t.delete(e),this._registered.delete(e)}_unregisterAll(){var e;for(let t of this._registered)(e=document.fonts)==null||e.delete(t);this._registered.clear()}destroy(){this._unregisterAll(),this._faces={}}};const Cc=1e20,Gd=new Float64Array(256);for(let e=0;e<256;e++){let t=.5-(e/255)**.45454545454545453;Gd[e]=t*Math.abs(t)}Gd[255]=-1e20;var NC=class{constructor({fontSize:e=24,buffer:t=3,radius:r=8,cutoff:i=.25,fontFamily:a="sans-serif",fontWeight:n="normal",fontStyle:s="normal",lang:o=null}={}){this.buffer=t,this.radius=r,this.cutoff=i,this.lang=o;let l=this.size=e+t*4,u=this._createCanvas(l),h=this.ctx=u.getContext("2d",{willReadFrequently:!0});h.font=`${s} ${n} ${e}px ${a}`,h.textBaseline="alphabetic",h.textAlign="left",h.fillStyle="black",this.gridOuter=new Float64Array(l*l),this.gridInner=new Float64Array(l*l),this.f=new Float64Array(l),this.z=new Float64Array(l+1),this.v=new Uint16Array(l)}_createCanvas(e){if(typeof OffscreenCanvas<"u")return new OffscreenCanvas(e,e);let t=document.createElement("canvas");return t.width=t.height=e,t}draw(e){let{width:t,actualBoundingBoxAscent:r,actualBoundingBoxDescent:i,actualBoundingBoxLeft:a,actualBoundingBoxRight:n}=this.ctx.measureText(e),s=Math.ceil(r),o=Math.floor(-a),l=Math.max(0,Math.min(this.size-this.buffer,Math.ceil(n)-o)),u=Math.max(0,Math.min(this.size-this.buffer,s+Math.ceil(i))),h=l+2*this.buffer,c=u+2*this.buffer,d=Math.max(h*c,0),p=new Uint8ClampedArray(d),f={data:p,width:h,height:c,glyphWidth:l,glyphHeight:u,glyphTop:s,glyphLeft:o,glyphAdvance:t};if(l===0||u===0)return f;let{ctx:m,buffer:g,gridInner:_,gridOuter:y}=this;this.lang&&(m.lang=this.lang),m.clearRect(g,g,l,u),m.fillText(e,g-o,g+s);let v=m.getImageData(g,g,l,u);y.fill(Cc,0,d),_.fill(0,0,d);let x=3;for(let A=0;A<u;A++){let P=(A+g)*h+g;for(let I=0;I<l;I++,x+=4,P++){let R=v.data[x];if(R===0)continue;let F=Gd[R];y[P]=Math.max(0,F),_[P]=Math.max(0,-F)}}zm(y,0,0,h,c,h,this.f,this.v,this.z);let w=Math.min(g,1);zm(_,g-w,g-w,l+2*w,u+2*w,h,this.f,this.v,this.z);let b=255/this.radius,S=255*(1-this.cutoff);for(let A=0;A<d;A++){let P=Math.sqrt(y[A])-Math.sqrt(_[A]);p[A]=Math.round(S-b*P)}return f}};function zm(e,t,r,i,a,n,s,o,l){for(let u=t;u<t+i;u++)Fm(e,r*n+u,n,a,s,o,l);for(let u=r;u<r+a;u++)Fm(e,u*n+t,1,i,s,o,l)}function Fm(e,t,r,i,a,n,s){n[0]=0,s[0]=-1e20,s[1]=Cc,a[0]=e[t];for(let o=1,l=0,u=0;o<i;o++){a[o]=e[t+o*r];let h=o*o;do{let c=n[l];u=(a[o]-a[c]+h-c*c)/(o-c)/2}while(u<=s[l]&&--l>-1);l++,n[l]=o,s[l]=u,s[l+1]=Cc}for(let o=0,l=0;o<i;o++){for(;s[l+1]<o;)l++;let u=n[l],h=o-u;e[t+o*r]=a[u]+h*h}}const UC=z.layout_symbol["text-font"].default.join(","),GC=(e,t)=>{let r=new NC(e);return r.buffer=t,r};var qC=class{constructor(e,t,r,i=GC){this.requestManager=e,this.localIdeographFontFamily=t,this.entries={},this.lang=r,this.fontFaceManager=new VC(e),this.createRasterizer=i}setURL(e){this.url=e}setFontFaces(e){this.fontFaceManager.setFontFaces(e),this.entries={}}async getGlyphs(e){var a;let t=[];for(let n in e)for(let s in e[n])for(let o of e[n][s])t.push(this._getAndCacheGlyphsPromise(n,o,s));let r=await Promise.all(t),i={};for(let{stack:n,id:s,variant:o,glyph:l}of r)i[n]||(i[n]={}),(a=i[n])[o]||(a[o]={}),i[n][o][s]=l&&{id:l.id,bitmap:l.bitmap.clone(),metrics:l.metrics};return i}async _getAndCacheGlyphsPromise(e,t,r){var l,u;(l=this.entries)[e]??(l[e]={glyphs:{default:{}},requests:{},ranges:{}});let i=this.entries[e],a=(u=i.glyphs)[r]||(u[r]={}),n=a[t];if(n!==void 0)return{stack:e,id:t,variant:r,glyph:n};if(r!=="default")return a[t]=null,{stack:e,id:t,variant:r,glyph:null};let s=t.codePointAt(0),o=this.fontFaceManager.hasFontFaces()?await this.fontFaceManager.getFontFamily(e,s):null;return o?(n=a[t]=await this._drawGlyph(i,e,t,o),{stack:e,id:t,variant:r,glyph:n}):!this.url||al(t)||this._charUsesLocalIdeographFontFamily(s)?(n=a[t]=await this._drawGlyph(i,e,t),{stack:e,id:t,variant:r,glyph:n}):{...await this._downloadAndCacheRangePromise(e,t),variant:r}}async _downloadAndCacheRangePromise(e,t){var n;let r=t.codePointAt(0),i=this.entries[e],a=Math.floor(r/256);if(i.ranges[a])return{stack:e,id:t,glyph:null};(n=i.requests)[a]||(n[a]=this._loadGlyphRange(e,a));try{let s=await i.requests[a];for(let o in s)i.glyphs.default[String.fromCodePoint(+o)]=s[+o];return i.ranges[a]=!0,{stack:e,id:t,glyph:s[r]||null}}catch(s){let o=i.glyphs.default[t]=await this._drawGlyph(i,e,t);return this._warnOnMissingGlyphRange(o,a,r,zt(s)),{stack:e,id:t,glyph:o}}}async _loadGlyphRange(e,t){let r=t*256,i=r+255,a=await this.requestManager.transformRequest(this.url.replace("{fontstack}",e).replace("{range}",`${r}-${i}`),"Glyphs"),n=await Xg(a,new AbortController);if(!(n!=null&&n.data))throw Error(`Could not load glyph range. range: ${t}, ${r}-${i}`);let s={};for(let o of _D(n.data))s[o.id]=o;return s}_warnOnMissingGlyphRange(e,t,r,i){let a=t*256,n=a+255,s=r.toString(16).padStart(4,"0").toUpperCase();_e(`Unable to load glyph range ${t}, ${a}-${n}. Rendering codepoint U+${s} locally instead. ${i}`)}_charUsesLocalIdeographFontFamily(e){return!!this.localIdeographFontFamily&&bS(e)}async _drawGlyph(e,t,r,i){let a=(await this._getTinySDF(e,t,r,i)).draw(r),n=new RegExp("^\\p{gc=Cf}+$","u").test(r);return{id:r.codePointAt(0),bitmap:new vd({width:a.width||60,height:a.height||60},a.data),metrics:{width:n?0:a.glyphWidth/2||24,height:a.glyphHeight/2||24,left:a.glyphLeft/2+.5||0,top:a.glyphTop/2-27.5||-8,advance:n?0:a.glyphAdvance/2||24,isDoubleResolution:!0}}}_getTinySDF(e,t,r,i){var l,u;let a=al(r);if(i){let h=a?"clusterTinySDFs":"fontFaceTinySDFs";return e[h]??(e[h]={}),(l=e[h])[i]||(l[i]=this._createTinySDF(i,!1,a?3:1)),e[h][i]}let n=t===UC&&this.localIdeographFontFamily!==""&&this._charUsesLocalIdeographFontFamily(r.codePointAt(0)),s=n?this.localIdeographFontFamily:t;if(a)return e.clusterTinySDFs??(e.clusterTinySDFs={}),(u=e.clusterTinySDFs)[s]||(u[s]=this._createTinySDF(s,!0,3)),e.clusterTinySDFs[s];let o=n?"ideographTinySDF":"tinySDF";return e[o]||(e[o]=this._createTinySDF(s)),e[o]}async _createTinySDF(e,t=!0,r=1){var o;let i=e?e.split(","):[];i.push("sans-serif");let a=i.map(l=>/[-\w]+/.test(l)?l:`'${CSS.escape(l)}'`).join(","),n=t?this._fontWeight(i[0]):void 0,s=t?this._fontStyle(i[0]):"normal";if(typeof document<"u"&&((o=document.fonts)!=null&&o.load))try{await document.fonts.load(`${s} ${n||"normal"} 48px ${a}`)}catch(l){_e(`Failed to load font "${a}": ${zt(l).message}`)}return this.createRasterizer({fontSize:48,buffer:Math.max(6,Math.ceil(48*(r-1)/4)),radius:16,cutoff:.25,fontFamily:a,fontWeight:n,fontStyle:s,lang:this.lang},6)}_fontStyle(e){return/italic/i.test(e)?"italic":/oblique/i.test(e)?"oblique":"normal"}_fontWeight(e){let t={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},r;for(let[i,a]of Object.entries(t))RegExp(`\\b${i}\\b`,"i").test(e)&&(r=`${a}`);return r}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={},t.ranges={}}this.entries={},this.fontFaceManager.destroy()}};let ZC;const WC=()=>ZC||(ZC=new wt({anchor:new N(z.light.anchor,"anchor"),position:new N(z.light.position,"position"),color:new N(z.light.color,"color"),intensity:new N(z.light.intensity,"intensity")}));var HC=class extends kt{constructor(e,t){super(),this._transitionable=new Rl(WC(),"light",t),this.setLight(e),this._transitioning=this._transitionable.untransitioned()}getLight(){return this._transitionable.serialize()}getCartesianPosition(){return yv(this.properties.get("position"))}setLight(e,t={}){this._validate(Zt.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,r){this._transitioning=this._transitionable.applyGlobalStateChange(e,t,this._transitioning,r)}recalculate(e){this.properties=this._transitioning.possiblyEvaluate(e)}_validate(e,t,r){return gs(this,e,{value:t},r)}};let XC;const YC=()=>XC||(XC=new wt({"sky-color":new N(z.sky["sky-color"],"sky-color"),"horizon-color":new N(z.sky["horizon-color"],"horizon-color"),"fog-color":new N(z.sky["fog-color"],"fog-color"),"fog-ground-blend":new N(z.sky["fog-ground-blend"],"fog-ground-blend"),"horizon-fog-blend":new N(z.sky["horizon-fog-blend"],"horizon-fog-blend"),"sky-horizon-blend":new N(z.sky["sky-horizon-blend"],"sky-horizon-blend"),"atmosphere-blend":new N(z.sky["atmosphere-blend"],"atmosphere-blend")}));var KC=class extends kt{constructor(e,t){super(),this._transitionable=new Rl(YC(),"sky",t),this.setSky(e),this._transitioning=this._transitionable.untransitioned(),this.recalculate(new ze(0))}setSky(e,t={}){return!this._validate(Zt.sky,e,t)&&(e||(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,r){this._transitioning=this._transitionable.applyGlobalStateChange(e,t,this._transitioning,r)}recalculate(e){this.properties=this._transitioning.possiblyEvaluate(e)}_validate(e,t,r={}){return gs(this,e,{value:t},r)}calculateFogBlendOpacity(e){return e<60?0:e<70?(e-60)/10:1}},JC=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){var i;let r=e.join(",")+String(t);return(i=this.dashEntry)[r]||(i[r]=this.addDash(e,t)),this.dashEntry[r]}getDashRanges(e,t,r){let i=e.length%2==1,a=[],n=i?-e[e.length-1]*r:0,s=e[0]*r,o=!0;a.push({left:n,right:s,isDash:o,zeroLength:e[0]===0});let l=e[0];for(let u=1;u<e.length;u++){o=!o;let h=e[u];n=l*r,l+=h,s=l*r,a.push({left:n,right:s,isDash:o,zeroLength:h===0})}return a}addRoundDash(e,t,r){let i=t/2;for(let a=-r;a<=r;a++){let n=this.nextRow+r+a,s=this.width*n,o=0,l=e[o];for(let u=0;u<this.width;u++){u/l.right>1&&(l=e[++o]);let h=Math.abs(u-l.left),c=Math.abs(u-l.right),d=Math.min(h,c),p,f=a/r*(i+1);if(l.isDash){let m=i-Math.abs(f);p=Math.sqrt(d*d+m*m)}else p=i-Math.sqrt(d*d+f*f);this.data[s+u]=Math.max(0,Math.min(255,p+128))}}}addRegularDash(e){for(let s=e.length-1;s>=0;--s){let o=e[s],l=e[s+1];o.zeroLength?e.splice(s,1):(l==null?void 0:l.isDash)===o.isDash&&(l.left=o.left,e.splice(s,1))}let t=e[0],r=e[e.length-1];t.isDash===r.isDash&&(t.left=r.left-this.width,r.right=t.right+this.width);let i=this.width*this.nextRow,a=0,n=e[a];for(let s=0;s<this.width;s++){s/n.right>1&&(n=e[++a]);let o=Math.abs(s-n.left),l=Math.abs(s-n.right),u=Math.min(o,l),h=n.isDash?u:-u;this.data[i+s]=Math.max(0,Math.min(255,h+128))}}addDash(e,t){let r=t?7:0,i=2*r+1;if(this.nextRow+i>this.height)return _e("LineAtlas out of space"),null;let a=0;for(let s of e)a+=s;if(a!==0){let s=this.width/a,o=this.getDashRanges(e,this.width,s);t?this.addRoundDash(o,s,r):this.addRegularDash(o)}let n={y:this.nextRow+r,height:2*r,width:a};return this.nextRow+=i,this.dirty=!0,n}bind(e){let t=e.gl;this.texture?(t.bindTexture(t.TEXTURE_2D,this.texture),this.dirty&&(this.dirty=!1,t.texSubImage2D(t.TEXTURE_2D,0,0,0,this.width,this.height,t.ALPHA,t.UNSIGNED_BYTE,this.data))):(this.texture=t.createTexture(),t.bindTexture(t.TEXTURE_2D,this.texture),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_WRAP_S,t.REPEAT),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_WRAP_T,t.REPEAT),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_MIN_FILTER,t.LINEAR),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_MAG_FILTER,t.LINEAR),t.texImage2D(t.TEXTURE_2D,0,t.ALPHA,this.width,this.height,0,t.ALPHA,t.UNSIGNED_BYTE,this.data))}};function QC(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}}function eI(){let e=import.meta.url;if(!/^https?:/.test(e))return"";let t=e.endsWith("-dev.mjs")?"maplibre-gl-worker-dev.mjs":"maplibre-gl-worker.mjs";return new URL(`./${t}`,e).href}function Hu(e,t){if(t)try{return new Worker(e,{type:"module"})}catch(r){console.warn("Module worker not supported, falling back to classic worker",r)}return new Worker(e)}async function tI(e){let t=await fetch(e);if(!t.ok)throw Error(`Failed to fetch worker script (${t.status}): ${e}`);let r=await t.text(),i=new Blob([r],{type:"text/javascript"});return URL.createObjectURL(i)}function rI(e){let t=new Blob([`import ${JSON.stringify(new URL(e,import.meta.url).href)}`],{type:"text/javascript"});return URL.createObjectURL(t)}async function iI(){let e=Yi.WORKER_URL||eI(),t=!(e!=null&&e.endsWith(".cjs"));if(!QC(e))return Hu(e,t);if(t){let i=rI(e);try{return Hu(i,t)}finally{URL.revokeObjectURL(i)}}let r=await tI(e);try{return Hu(r,t)}finally{URL.revokeObjectURL(r)}}const aI="maplibre_preloaded_worker_pool";var g1=class _1{constructor(){this.active={},this.workersPromise=null}async acquire(t){if(this.active[t]=!0,!this.workersPromise){let r=[];for(;r.length<_1.workerCount;)r.push(iI());this.workersPromise=Promise.all(r)}return(await this.workersPromise).slice()}release(t){if(delete this.active[t],this.numActive()===0&&this.workersPromise){let r=this.workersPromise;this.workersPromise=null,r.then(i=>{for(let a of i)a.terminate()})}}isPreloaded(){return!!this.active[aI]}numActive(){return Object.keys(this.active).length}};const nI=Math.floor(Xt.hardwareConcurrency/2);g1.workerCount=vv(globalThis)?Math.max(Math.min(nI,3),1):1;let Rm;function y1(){return Rm||(Rm=new g1),Rm}var x1=class extends kt{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[];if(this.actors=t.map((r,i)=>{this.workerErrorSubscriptions.push(jo(r,"error",()=>{this.fire(new Y(Error("Worker failed to load. Check that the worker URL is correct.")))},!1));let a=new wE(r,e);return a.name=`Worker ${i}`,a}),!this.actors.length)throw Error("No actors found");return this.actors}async broadcast(e,t){let r=await this.actorsPromise;return Promise.all(r.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(){this.actors.length===0&&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 r=await this.actorsPromise;for(let i of r)i.registerMessageHandler(e,t)}async unregisterMessageHandler(e){let t=await this.actorsPromise;for(let r of t)r.unregisterMessageHandler(e)}};let oo;function sI(){return oo||(oo=new x1(y1(),_h),oo.registerMessageHandler("GR",(e,t,r)=>yl(t,r))),oo}function oI(e,t){let r=Pi();return ot(r,r,[1,1,0]),Et(r,r,[e.width*.5,e.height*.5,1]),e.calculatePosMatrix?ba(r,r,e.calculatePosMatrix(t.toUnwrapped())):r}function lI(e,t,r){if(e)for(let i of e){let a=t[i];if((a==null?void 0:a.source)===r&&a.type==="fill-extrusion")return!0}else for(let i in t){let a=t[i];if(a.source===r&&a.type==="fill-extrusion")return!0}return!1}function uI(e,t,r,i,a,n,s){let o=lI((a==null?void 0:a.layers)??null,t,e.id),l=n.maxPitchScaleFactor(),u=e.tilesIn(i,l,o);u.sort(v1);let h=[];for(let c of u)h.push({wrappedTileID:c.tileID.wrapped().key,queryResults:c.tile.queryRenderedFeatures(t,r,e.getState(),c.queryGeometry,c.cameraQueryGeometry,c.scale,a,n,l,oI(n,c.tileID),s?(d,p)=>s(c.tileID,d,p):void 0)});return pI(dI(h),e)}function hI(e,t,r,i,a,n,s){let o={},l=n.queryRenderedSymbols(i),u=[];for(let h of Object.keys(l).map(Number))u.push(s[h]);u.sort(v1);for(let h of u){let c=h.featureIndex.lookupSymbolFeatures(l[h.bucketInstanceId],t,h.bucketIndex,h.sourceLayerIndex,{filterSpec:a.filter,globalState:a.globalState},a.layers,a.availableImages,e);for(let d in c){o[d]||(o[d]=[]);let p=c[d];p.sort((f,m)=>{let g=h.featureSortOrder;if(g){let _=g.indexOf(f.featureIndex);return g.indexOf(m.featureIndex)-_}return m.featureIndex-f.featureIndex});for(let f of p)o[d].push(f)}}return fI(o,e,r)}function cI(e,t){let r=e.getRenderableIds().map(n=>e.getTileByID(n)),i=[],a={};for(let n of r){let s=n.tileID.canonical.key;a[s]||(a[s]=!0,n.querySourceFeatures(i,t))}return i}function v1(e,t){let r=e.tileID,i=t.tileID;return r.overscaledZ-i.overscaledZ||r.canonical.y-i.canonical.y||r.wrap-i.wrap||r.canonical.x-i.canonical.x}function dI(e){let t={},r={};for(let{queryResults:i,wrappedTileID:a}of e){r[a]||(r[a]={});let n=r[a];for(let s in i){let o=i[s];n[s]||(n[s]={});let l=n[s];t[s]||(t[s]=[]);for(let u of o)l[u.featureIndex]||(l[u.featureIndex]=!0,t[s].push(u))}}return t}function pI(e,t){for(let r in e)for(let i of e[r])b1(i,t);return e}function fI(e,t,r){for(let i in e)for(let a of e[i]){let n=r[t[i].source];b1(a,n)}return e}function b1(e,t){let r=e.feature,i=t.getFeatureState(r.layer["source-layer"],r.id);r.source=r.layer.source,r.layer["source-layer"]&&(r.sourceLayer=r.layer["source-layer"]),r.state=i}async function w1(e,t,r,i){let a=e;if(e.url?a=(await xl(await t.transformRequest(e.url,"Source"),r)).data:await Xt.frameAsync(r,i),!a)return null;let n=os(H(a,e),["tiles","minzoom","maxzoom","attribution","bounds","scheme","tileSize","encoding"]);return"vector_layers"in a&&a.vector_layers&&(n.vectorLayerIds=a.vector_layers.map(s=>s.id)),n}var Wr=class Qr{constructor(t,r){t&&(r?this.setSouthWest(t).setNorthEast(r):Array.isArray(t)&&(t.length===4?this.setSouthWest([t[0],t[1]]).setNorthEast([t[2],t[3]]):this.setSouthWest(t[0]).setNorthEast(t[1])))}setNorthEast(t){return this._ne=t instanceof ee?new ee(t.lng,t.lat):ee.convert(t),this}setSouthWest(t){return this._sw=t instanceof ee?new ee(t.lng,t.lat):ee.convert(t),this}extend(t){let r=this._sw,i=this._ne,a,n;if(t instanceof ee)a=t,n=t;else if(t instanceof Qr){if(a=t._sw,n=t._ne,!a||!n)return this}else{if(Array.isArray(t)){if(t.length===4||t.every(Array.isArray)){let s=t;return this.extend(Qr.convert(s))}{let s=t;return this.extend(ee.convert(s))}}return t&&("lng"in t||"lon"in t)&&"lat"in t?this.extend(ee.convert(t)):this}return!r&&!i?(this._sw=new ee(a.lng,a.lat),this._ne=new ee(n.lng,n.lat)):(r.lng=Math.min(a.lng,r.lng),r.lat=Math.min(a.lat,r.lat),i.lng=Math.max(n.lng,i.lng),i.lat=Math.max(n.lat,i.lat)),this}getCenter(){return new ee((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 ee(this.getWest(),this.getNorth())}getSouthEast(){return new ee(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(t){let{lng:r,lat:i}=ee.convert(t),a=this._sw.lat<=i&&i<=this._ne.lat,n=this._sw.lng<=r&&r<=this._ne.lng;return this._sw.lng>this._ne.lng&&(n=this._sw.lng>=r&&r>=this._ne.lng),a&&n}intersects(t){if(t=Qr.convert(t),!(t.getNorth()>=this.getSouth()&&t.getSouth()<=this.getNorth()))return!1;let r=Math.abs(this.getEast()-this.getWest()),i=Math.abs(t.getEast()-t.getWest());if(r>=360||i>=360)return!0;let a=fr(this.getWest(),-180,180),n=fr(this.getEast(),-180,180),s=fr(t.getWest(),-180,180),o=fr(t.getEast(),-180,180),l=a>n,u=s>o;return l&&u?!0:l?o>=a||s<=n:u?n>=s||a<=o:s<=n&&o>=a}static convert(t){return t instanceof Qr||!t?t:new Qr(t)}static fromLngLat(t,r=0){let i=360*r/40075017,a=i/Math.cos(Math.PI/180*t.lat);return new Qr(new ee(t.lng-a,t.lat-i),new ee(t.lng+a,t.lat+i))}adjustAntiMeridian(){let t=new ee(this._sw.lng,this._sw.lat),r=new ee(this._ne.lng,this._ne.lat);return t.lng>r.lng?new Qr(t,new ee(r.lng+360,r.lat)):new Qr(t,r)}},T1=class{constructor(e,t,r){this.bounds=Wr.convert(this.validateBounds(e)),this.minzoom=t||0,this.maxzoom=r||24}validateBounds(e){return!Array.isArray(e)||e.length!==4?[-180,-90,180,90]:[Math.max(-180,e[0]),Math.max(-90,e[1]),Math.min(180,e[2]),Math.min(90,e[3])]}contains(e){let t=2**e.z,r={minX:Math.floor(Wa(this.bounds.getWest())*t),minY:Math.floor(Ha(this.bounds.getNorth())*t),maxX:Math.ceil(Wa(this.bounds.getEast())*t),maxY:Math.ceil(Ha(this.bounds.getSouth())*t)};return e.x>=r.minX&&e.x<r.maxX&&e.y>=r.minY&&e.y<r.maxY}},mI=class extends kt{constructor(e,t,r,i){if(super(),this.id=e,this.dispatcher=r,this.type="vector",this.minzoom=0,this.maxzoom=22,this.scheme="xyz",this.tileSize=512,this.reparseOverscaled=!0,this.isTileClipped=!0,this._loaded=!1,H(this,os(t,["url","scheme","tileSize","promoteId","encoding"])),this._options=H({type:"vector"},t),this._collectResourceTiming=t.collectResourceTiming,this.tileSize!==512)throw Error("vector tile sources must have a tileSize of 512");this.setEventedParent(i)}async load(e=!1){this._loaded=!1,this.fire(new Ne("dataloading")),this._tileJSONRequest=new AbortController;try{let t=await w1(this._options,this.map._requestManager,this._tileJSONRequest,this.map._ownerWindow);this._tileJSONRequest=null,this._loaded=!0,t&&(H(this,t),t.bounds&&(this.tileBounds=new T1(t.bounds,this.minzoom,this.maxzoom)),this.fire(new Ne("data",{sourceDataType:"metadata"})),this.fire(new Ne("data",{sourceDataType:"content",sourceDataChanged:e})))}catch(t){this._tileJSONRequest=null,this._loaded=!0,Si(t)||this.fire(new Y(zt(t)))}}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=(this._tileJSONRequest.abort(),null))}serialize(){return H({},this._options)}async loadTile(e){let t=e.tileID.canonical.url(this.tiles,this.map.getPixelRatio(),this.scheme),r={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(r.request.collectResourceTiming=this._collectResourceTiming,await this.dispatcher.waitForInitComplete(),e.aborted)return;let i="RT";if(!e.actor||e.state==="expired")e.actor=this.dispatcher.getReadyActor(),i="LT";else if(e.state==="loading")return new Promise((a,n)=>{e.reloadPromise={resolve:a,reject:n}});e.abortController=new AbortController;try{let a=await e.actor.sendAsync({type:i,data:r},e.abortController);if(delete e.abortController,e.aborted)return;this._afterTileLoadWorkerResponse(e,a);let n={};return a!=null&&a.etagUnmodified&&(n.unmodified=!0),n}catch(a){if(delete e.abortController,e.aborted||Si(a))return;if(a&&a.status!==404)throw a;this._afterTileLoadWorkerResponse(e,null)}}async _getOverzoomParameters(e){if(e.tileID.canonical.z<=this.maxzoom||this.map._zoomLevelsToOverscale===void 0)return;let t=e.tileID.scaledTo(this.maxzoom).canonical,r=t.url(this.tiles,this.map.getPixelRatio(),this.scheme);return{maxZoomTileID:t,overzoomRequest:await this.map._requestManager.transformRequest(r,"Tile")}}_afterTileLoadWorkerResponse(e,t){if(t!=null&&t.resourceTiming&&(e.resourceTiming=t.resourceTiming),t&&this.map._refreshExpiredTiles&&e.setExpiryData(t),e.etag=t==null?void 0:t.etag,e.loadVectorData(t,this.map.painter),e.reloadPromise){let r=e.reloadPromise;e.reloadPromise=null,this.loadTile(e).then(r.resolve).catch(r.reject)}}async abortTile(e){e.abortController&&(e.abortController.abort(),delete e.abortController),e.actor&&await e.actor.sendAsync({type:"AT",data:{uid:e.uid,type:this.type,source:this.id}})}async unloadTile(e){e.unloadVectorData(),e.actor&&await e.actor.sendAsync({type:"RMT",data:{uid:e.uid,type:this.type,source:this.id}})}hasTransition(){return!1}},S1=class extends kt{constructor(e,t,r,i){super(),this.id=e,this.dispatcher=r,this.setEventedParent(i),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=H({type:"raster"},t),H(this,os(t,["url","scheme","tileSize"]))}async load(e=!1){this._loaded=!1,this.fire(new Ne("dataloading")),this._tileJSONRequest=new AbortController;try{let t=await w1(this._options,this.map._requestManager,this._tileJSONRequest,this.map._ownerWindow);this._tileJSONRequest=null,this._loaded=!0,t&&(H(this,t),t.bounds&&(this.tileBounds=new T1(t.bounds,this.minzoom,this.maxzoom)),this.fire(new Ne("data",{sourceDataType:"metadata"})),this.fire(new Ne("data",{sourceDataType:"content",sourceDataChanged:e})))}catch(t){this._tileJSONRequest=null,this._loaded=!0,Si(t)||this.fire(new Y(zt(t)))}}loaded(){return this._loaded}onAdd(e){this.map=e,this.load()}onRemove(){this._tileJSONRequest&&(this._tileJSONRequest=(this._tileJSONRequest.abort(),null))}setSourceProperty(e){this._tileJSONRequest&&(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 H({},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),r=this._premultiplyAlpha,i=r?void 0:{premultiplyAlpha:"none"};e.abortController=new AbortController;try{let a=await Ur.transformAndGetImage(this.map._requestManager,t,"Tile",e.abortController,this.map._refreshExpiredTiles,i);if(delete e.abortController,e.aborted){e.state="unloaded";return}if(a){this.map._refreshExpiredTiles&&(a.cacheControl||a.expires)&&e.setExpiryData({cacheControl:a.cacheControl,expires:a.expires});let n=this.map.painter.context,s=n.gl,o=a.data??new $e({width:1,height:1},new Uint8Array(4));e.texture=this.map.painter.getTileTexture(o.width),e.texture?e.texture.update(o,{useMipmap:!0,premultiply:r}):(e.texture=new dt(n,o,s.RGBA,{useMipmap:!0,premultiply:r}),e.texture.bind(s.LINEAR,s.CLAMP_TO_EDGE,s.LINEAR_MIPMAP_NEAREST)),e.state="loaded"}}catch(a){if(delete e.abortController,e.aborted)e.state="unloaded";else if(a)throw e.state="errored",a}}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}},gI=class extends S1{constructor(e,t,r,i){super(e,t,r,i),this.type="raster-dem",this.maxzoom=22,this._options=H({type:"raster-dem"},t),this.encoding=t.encoding||"mapbox",this.redFactor=t.redFactor,this.greenFactor=t.greenFactor,this.blueFactor=t.blueFactor,this.baseShift=t.baseShift}async loadTile(e){let t=e.tileID.canonical.url(this.tiles,this.map.getPixelRatio(),this.scheme);e.neighboringTiles=this._getNeighboringTiles(e.tileID),e.abortController=new AbortController;try{let r=await Ur.transformAndGetImage(this.map._requestManager,t,"Tile",e.abortController,this.map._refreshExpiredTiles,{colorSpaceConversion:"none"});if(delete e.abortController,e.aborted){e.state="unloaded";return}if(r){if(this.map._refreshExpiredTiles&&(r.cacheControl||r.expires)&&e.setExpiryData({cacheControl:r.cacheControl,expires:r.expires}),!r.data){e.state="loaded";return}let i=r.data,a=Ni(i)&&Nc()?i:await this.readImageNow(i),n={type:this.type,uid:e.uid,source:this.id,rawImageData:a,encoding:this.encoding,redFactor:this.redFactor,greenFactor:this.greenFactor,blueFactor:this.blueFactor,baseShift:this.baseShift};if(e.actor&&e.state!=="expired"&&e.state!=="reloading")return;await this.dispatcher.waitForInitComplete(),(!e.actor||e.state==="expired")&&(e.actor=this.dispatcher.getReadyActor()),e.dem=await e.actor.sendAsync({type:"LDT",data:n}),e.needsHillshadePrepare=!0,e.needsTerrainPrepare=!0,e.needsColorReliefPrepare=!0,e.state="loaded"}}catch(r){if(delete e.abortController,e.aborted)e.state="unloaded";else if(r)throw e.state="errored",r}}async readImageNow(e){if(typeof VideoFrame<"u"&&Og()){let t=e.width+4,r=e.height+4;try{return new $e({width:t,height:r},await Sv(e,-2,-2,t,r))}catch{}}return Xt.getImageData(e,2)}_getNeighboringTiles(e){let t=e.canonical,r=2**t.z,i=(t.x-1+r)%r,a=t.x===0?e.wrap-1:e.wrap,n=(t.x+1+r)%r,s=t.x+1===r?e.wrap+1:e.wrap,o={};return o[new Dt(e.overscaledZ,a,t.z,i,t.y).key]={backfilled:!1},o[new Dt(e.overscaledZ,s,t.z,n,t.y).key]={backfilled:!1},t.y>0&&(o[new Dt(e.overscaledZ,a,t.z,i,t.y-1).key]={backfilled:!1},o[new Dt(e.overscaledZ,e.wrap,t.z,t.x,t.y-1).key]={backfilled:!1},o[new Dt(e.overscaledZ,s,t.z,n,t.y-1).key]={backfilled:!1}),t.y+1<r&&(o[new Dt(e.overscaledZ,a,t.z,i,t.y+1).key]={backfilled:!1},o[new Dt(e.overscaledZ,e.wrap,t.z,t.x,t.y+1).key]={backfilled:!1},o[new Dt(e.overscaledZ,s,t.z,n,t.y+1).key]={backfilled:!1}),o}async unloadTile(e){e.demTexture&&this.map.painter.saveTileTexture(e.demTexture),e.fbo&&(e.fbo.destroy(),delete e.fbo),e.dem&&delete e.dem,delete e.neighboringTiles,e.state="unloaded",e.actor&&await e.actor.sendAsync({type:"RDT",data:{type:this.type,uid:e.uid,source:this.id}})}};function cl(e,t){return t?e.properties[t]:e.id}function _I(e,t){let r=new Map;if(e==null||e.type==null)return r;if(e.type==="Feature"){let i=cl(e,t);return i==null?void 0:(r.set(i,e),r)}if(e.type==="FeatureCollection"){let i=new Set;for(let a of e.features){let n=cl(a,t);if(n==null||i.has(n))return;i.add(n),r.set(n,a)}return r}}function yI(e,t,r){var a,n;let i=[];if(t.removeAll)e.clear();else if(t.remove)for(let s of t.remove){let o=e.get(s);o&&(i.push(o.geometry),e.delete(s))}if(t.add)for(let s of t.add){let o=cl(s,r);if(o==null)continue;let l=e.get(o);l&&i.push(l.geometry),i.push(s.geometry),e.set(o,s)}if(t.update)for(let s of t.update){let o=e.get(s.id);if(!o)continue;let l=!!s.newGeometry,u=s.removeAllProperties||((a=s.removeProperties)==null?void 0:a.length)>0||((n=s.addOrUpdateProperties)==null?void 0:n.length)>0;if(!l&&!u)continue;i.push(o.geometry);let h={...o};if(e.set(s.id,h),l&&(i.push(s.newGeometry),h.geometry=s.newGeometry),u){if(h.properties=s.removeAllProperties?{}:{...h.properties||{}},s.removeProperties)for(let c of s.removeProperties)delete h.properties[c];if(s.addOrUpdateProperties)for(let{key:c,value:d}of s.addOrUpdateProperties)h.properties[c]=d}}return i}function xI(e,t,r){if(!e)return t||{};if(!t)return e||{};let i=km(e,r),a=km(t,r);vI(i,a);let n={};if((i.removeAll||a.removeAll)&&(n.removeAll=!0),n.remove=new Set([...i.remove,...a.remove]),n.add=new Map([...i.add,...a.add]),n.update=new Map([...i.update,...a.update]),n.remove.size&&n.add.size)for(let s of n.add.keys())n.remove.delete(s);return wI(n)}function vI(e,t){t.removeAll&&(e.add.clear(),e.update.clear(),e.remove.clear(),t.remove.clear());for(let r of t.remove)e.add.delete(r),e.update.delete(r);for(let[r,i]of t.update){let a=e.update.get(r);a&&(t.update.set(r,bI(a,i)),e.update.delete(r))}}function bI(e,t){let r={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(a=>!i.has(a.key))}return(e.removeAllProperties||t.removeAllProperties)&&(r.removeAllProperties=!0),(e.removeProperties||t.removeProperties)&&(r.removeProperties=[...e.removeProperties||[],...t.removeProperties||[]]),(e.addOrUpdateProperties||t.addOrUpdateProperties)&&(r.addOrUpdateProperties=[...e.addOrUpdateProperties||[],...t.addOrUpdateProperties||[]]),(e.newGeometry||t.newGeometry)&&(r.newGeometry=t.newGeometry||e.newGeometry),r}function km(e,t){var i,a;if(!e)return{};let r={};return r.removeAll=e.removeAll,r.remove=new Set(e.remove||[]),r.add=new Map((i=e.add)==null?void 0:i.map(n=>[cl(n,t),n])),r.update=new Map((a=e.update)==null?void 0:a.map(n=>[n.id,n])),r}function wI(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}function D1(e){return!e||e.length===0?[]:typeof e[0]=="number"?[e]:e.flatMap(t=>D1(t))}function Fo(e){return e.type==="GeometryCollection"?e.geometries.flatMap(t=>Fo(t)):D1(e.coordinates)}function Lm(e){let t=new Wr,r;switch(e.type){case"FeatureCollection":r=e.features.flatMap(i=>Fo(i.geometry));break;case"Feature":r=Fo(e.geometry);break;default:r=Fo(e)}if(r.length===0)return t;for(let i of r){let[a,n]=i;t.extend([a,n])}return t}function TI({x:e,y:t,z:r},i=0){let a=pc((e-i)/2**r),n=ns((t+1+i)/2**r),s=pc((e+1+i)/2**r),o=ns((t-i)/2**r);return new Wr([a,n],[s,o])}var SI=class extends kt{constructor(e,t,r,i){super(),this.id=e,this.type="geojson",this.minzoom=0,this.maxzoom=18,this.tileSize=512,this.isTileClipped=!0,this.reparseOverscaled=!0,this._removed=!1,this._isUpdatingWorker=!1,this._pendingWorkerUpdate={data:t.data},this.actorPromise=r.getActor(),this.setEventedParent(i),this._data=typeof t.data=="string"?{url:t.data}:{geojson:t.data},this._options=H({},t),this._collectResourceTiming=t.collectResourceTiming,t.maxzoom!==void 0&&(this.maxzoom=t.maxzoom),t.type&&(this.type=t.type),t.attribution&&(this.attribution=t.attribution),this.promoteId=t.promoteId,t.clusterMaxZoom!==void 0&&this.maxzoom<=t.clusterMaxZoom&&_e(`The maxzoom value "${this.maxzoom}" is expected to be greater than the clusterMaxZoom value "${t.clusterMaxZoom}".`),this.workerOptions=H({source:this.id,geojsonVtOptions:{buffer:this._pixelsToTileUnits(t.buffer===void 0?128:t.buffer),tolerance:this._pixelsToTileUnits(t.tolerance===void 0?.375:t.tolerance),extent:L,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:L,radius:this._pixelsToTileUnits(t.clusterRadius||50),log:!1,generateId:t.generateId||!1}},clusterProperties:t.clusterProperties,filter:t.filter},t.workerOptions)}get _promoteIdKey(){return typeof this.promoteId=="string"?this.promoteId:void 0}_hasPendingWorkerUpdate(){return this._pendingWorkerUpdate.data!==void 0||this._pendingWorkerUpdate.diff!==void 0||this._pendingWorkerUpdate.updateCluster}_pixelsToTileUnits(e){return e*(L/this.tileSize)}_tileUnitsToPixels(e){return e/(L/this.tileSize)}_getClusterMaxZoom(e){let t=e?Math.round(e):this.maxzoom-1;return Number.isInteger(e)||e===void 0||_e(`Integer expected for option 'clusterMaxZoom': provided value "${e}" rounded to "${t}"`),t}async load(){await this._updateWorkerData()}onAdd(e){this.map=e,this.load()}setData(e){return this._data=typeof e=="string"?{url:e}:{geojson:e},this._pendingWorkerUpdate={data:e},this._updateWorkerData()}updateData(e){return this._pendingWorkerUpdate.diff=xI(this._pendingWorkerUpdate.diff,e,this._promoteIdKey),this._updateWorkerData()}async getData(){return this._data.url&&await this.once("data"),this._data.geojson?this._data.geojson:{type:"FeatureCollection",features:Array.from(this._data.updateable.values())}}async getBounds(){return Lm(await this.getData())}setClusterOptions(e){return this.workerOptions.geojsonVtOptions.cluster=e.cluster,e.clusterRadius!==void 0&&(this.workerOptions.geojsonVtOptions.clusterOptions.radius=this._pixelsToTileUnits(e.clusterRadius)),e.clusterMaxZoom!==void 0&&(this.workerOptions.geojsonVtOptions.clusterOptions.maxZoom=this._getClusterMaxZoom(e.clusterMaxZoom)),this._pendingWorkerUpdate.updateCluster=!0,this._updateWorkerData()}getClusterOptions(){let{cluster:e,clusterOptions:t}=this.workerOptions.geojsonVtOptions;return{cluster:e,clusterMaxZoom:t.maxZoom,clusterRadius:this._tileUnitsToPixels(t.radius)}}async getClusterExpansionZoom(e){return(await this.actorPromise).sendAsync({type:"GCEZ",data:{type:this.type,clusterId:e,source:this.id}})}async getClusterChildren(e){return(await this.actorPromise).sendAsync({type:"GCC",data:{type:this.type,clusterId:e,source:this.id}})}async getClusterLeaves(e,t,r){return(await this.actorPromise).sendAsync({type:"GCL",data:{type:this.type,source:this.id,clusterId:e,limit:t,offset:r}})}async _updateWorkerData(){if(this._isUpdatingWorker)return this._updatePromise;if(!this._hasPendingWorkerUpdate()){_e(`No pending worker updates for GeoJSONSource ${this.id}.`);return}let{data:e,diff:t,updateCluster:r}=this._pendingWorkerUpdate,i=this._getLoadGeoJSONParameters(e,t,r);e===void 0?t?this._pendingWorkerUpdate.diff=void 0:r&&(this._pendingWorkerUpdate.updateCluster=void 0):this._pendingWorkerUpdate.data=void 0,this._updatePromise=this._dispatchWorkerUpdate(i),await this._updatePromise}async _getLoadGeoJSONParameters(e,t,r){let i=H({type:this.type,source:this.id},this.workerOptions);if(typeof e=="string")return i.request=await this.map._requestManager.transformRequest(Xt.resolveURL(e),"Source"),i.request.collectResourceTiming=this._collectResourceTiming,i;if(e!==void 0)return i.data=e,i;if(t)return i.dataDiff=t,i;if(r)return i.updateCluster=!0,i}async _dispatchWorkerUpdate(e){this._isUpdatingWorker=!0,this.fire(new Ne("dataloading"));try{let t=await e,r=await(await this.actorPromise).sendAsync({type:"LD",data:t});if(this._isUpdatingWorker=!1,this._removed||r.abandoned){this.fire(new Ne("dataabort"));return}r.data&&(this._data={geojson:r.data});let i=this._applyDiffToSource(t.dataDiff),a=this._getShouldReloadTileOptions(i),n={};this._applyResourceTiming(n,r),this.fire(new Ne("data",{...n,sourceDataType:"metadata"})),this.fire(new Ne("data",{...n,sourceDataType:"content",shouldReloadTileOptions:a}))}catch(t){if(this._isUpdatingWorker=!1,this._removed){this.fire(new Ne("dataabort"));return}this.fire(new Y(zt(t)))}finally{this._hasPendingWorkerUpdate()&&await this._updateWorkerData()}}_applyResourceTiming(e,t){var a;if(!this._collectResourceTiming)return;let r=(a=t.resourceTiming)==null?void 0:a[this.id];if(!r)return;let i=r.slice(0);i!=null&&i.length&&H(e,{resourceTiming:i})}_applyDiffToSource(e){if(!e)return;let t=this._promoteIdKey;if(!this._data.url&&!this._data.updateable){let i=_I(this._data.geojson,t);if(!i)throw Error(`GeoJSONSource "${this.id}": GeoJSON data is not compatible with updateData`);this._data={updateable:i}}if(!this._data.updateable)return;let r=yI(this._data.updateable,e,t);if(!(e.removeAll||this._options.cluster))return r}_getShouldReloadTileOptions(e){if(e)return{affectedBounds:e.filter(Boolean).map(t=>Lm(t))}}shouldReloadTile(e,{affectedBounds:t}){if(e.state==="loading")return!0;if(e.state==="unloaded")return!1;let{buffer:r,extent:i}=this.workerOptions.geojsonVtOptions,a=TI(e.tileID.canonical,r/i);for(let n of t)if(a.intersects(n))return!0;return!1}loaded(){return!this._isUpdatingWorker&&!this._hasPendingWorkerUpdate()}async loadTile(e){let t=e.actor?"RT":"LT";e.actor=await this.actorPromise;let r={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 i=await(await this.actorPromise).sendAsync({type:t,data:r},e.abortController);delete e.abortController,e.unloadVectorData(),e.aborted||e.loadVectorData(i,this.map.painter,t==="RT")}catch(i){if(delete e.abortController,e.aborted||Si(i))return;throw i}}async abortTile(e){e.abortController&&(e.abortController.abort(),delete e.abortController),e.aborted=!0}async unloadTile(e){e.unloadVectorData(),await(await this.actorPromise).sendAsync({type:"RMT",data:{uid:e.uid,type:this.type,source:this.id}})}onRemove(){this._removed=!0,this.actorPromise.then(e=>e.sendAsync({type:"RS",data:{type:this.type,source:this.id}}))}serialize(){return H({},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}};const La=[0,0,1],DI=(e,t)=>({u_tl_parent:new de(e,t.u_tl_parent),u_scale_parent:new U(e,t.u_scale_parent),u_buffer_scale:new U(e,t.u_buffer_scale),u_image_warp:new jt(e,t.u_image_warp),u_fade_t:new U(e,t.u_fade_t),u_opacity:new U(e,t.u_opacity),u_image0:new X(e,t.u_image0),u_image1:new X(e,t.u_image1),u_brightness_low:new U(e,t.u_brightness_low),u_brightness_high:new U(e,t.u_brightness_high),u_saturation_factor:new U(e,t.u_saturation_factor),u_contrast_factor:new U(e,t.u_contrast_factor),u_spin_weights:new jt(e,t.u_spin_weights),u_coords_top:new es(e,t.u_coords_top),u_coords_bottom:new es(e,t.u_coords_bottom)}),EI=(e,t,r,i,a,n)=>({u_tl_parent:e,u_scale_parent:t,u_buffer_scale:1,u_image_warp:n,u_fade_t:r.mix,u_opacity:r.opacity*i.paint.get("raster-opacity"),u_image0:0,u_image1:1,u_brightness_low:i.paint.get("raster-brightness-min"),u_brightness_high:i.paint.get("raster-brightness-max"),u_saturation_factor:CI(i.paint.get("raster-saturation")),u_contrast_factor:AI(i.paint.get("raster-contrast")),u_spin_weights:PI(i.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 PI(e){e*=Math.PI/180;let t=Math.sin(e),r=Math.cos(e);return[(2*r+1)/3,(-Math.sqrt(3)*t-r+1)/3,(Math.sqrt(3)*t-r+1)/3]}function AI(e){return e>0?1/(1-e):1+e}function CI(e){return e>0?1-1/(1.001-e):-e}var bs=class{constructor(e,t,r){this.vertexBuffer=e,this.indexBuffer=t,this.segments=r}destroy(){this.vertexBuffer.destroy(),this.indexBuffer.destroy(),this.segments.destroy(),this.vertexBuffer=null,this.indexBuffer=null,this.segments=null}};const Vi=Ye([{name:"a_pos",type:"Int16",components:2}]),lo=L/128;function E1(e,t){let r=II(t,"16bit"),i=vi.deserialize({arrayBuffer:r.vertices,length:r.vertices.byteLength/2/2}),a=Yr.deserialize({arrayBuffer:r.indices,length:r.indices.byteLength/2/3});return new bs(e.createVertexBuffer(i,Vi.members),e.createIndexBuffer(a),Ze.simpleSegment(0,0,i.length,a.length))}function II(e,t){let r=e.granularity===void 0?1:Math.max(e.granularity,1),i=r+(e.generateBorders?2:0),a=r+(e.extendToNorthPole||e.generateBorders?1:0)+(e.extendToSouthPole||e.generateBorders?1:0),n=i+1,s=a+1,o=e.generateBorders?-1:0,l=e.generateBorders||e.extendToNorthPole?-1:0,u=r+ +!!e.generateBorders,h=r+(e.generateBorders||e.extendToSouthPole?1:0),c=n*s,d=i*a*6,p=n*s>65536;if(p&&t==="16bit")throw Error("Granularity is too large and meshes would not fit inside 16 bit vertex indices.");let f=p||t==="32bit",m=new Int16Array(c*2),g=0;for(let v=l;v<=h;v++)for(let x=o;x<=u;x++){let w=x/r*L;x===-1&&(w=-lo),x===r+1&&(w=L+lo);let b=v/r*L;v===-1&&(b=e.extendToNorthPole?Bn:-lo),v===r+1&&(b=e.extendToSouthPole?On:L+lo),m[g++]=w,m[g++]=b}let _=f?new Uint32Array(d):new Uint16Array(d),y=0;for(let v=0;v<a;v++)for(let x=0;x<i;x++){let w=x+v*n,b=x+1+v*n,S=x+(v+1)*n,A=x+1+(v+1)*n;_[y++]=w,_[y++]=S,_[y++]=b,_[y++]=b,_[y++]=S,_[y++]=A}return{vertices:m.buffer.slice(0),indices:_.buffer.slice(0),uses32bitIndices:f}}var ws=class extends kt{constructor(e,t,r,i){super(),this.imageWarp=La,this.flippedWindingOrder=!1,this._warp="auto",this._imageDirty=!1,this._subdividedQuad=!1,this._subdividedMesh=null,this.id=e,this.dispatcher=r,this.coordinates=t.coordinates,this.type="image",this.minzoom=0,this.maxzoom=22,this.tileSize=512,this.tiles={},this._loaded=!1,this.setEventedParent(i),this.options=t}async load(e){if(this.options.url===void 0){this._loaded=!0,this._finishLoading();return}this._loaded=!1,this.fire(new Ne("dataloading")),this.url=this.options.url,this._abortController=new AbortController;try{let t=await Ur.transformAndGetImage(this.map._requestManager,this.url,"Image",this._abortController);this._abortController=null,this._loaded=!0,t!=null&&t.data?(this._setImage(t.data),e&&(this.coordinates=e),this._finishLoading()):this.fire(new Y(Error(`Could not load image ${this.url}: the response is empty`)))}catch(t){if(Si(t))return;this._abortController=null,this._loaded=!0,this.fire(new Y(zt(t)))}}loaded(){return this._loaded}updateImage(e){return this._abortController&&(this._abortController=(this._abortController.abort(),null)),"image"in e?(this._loaded=!0,this._setImage(e.image),e.coordinates&&(this.coordinates=e.coordinates),this._finishLoading(),this):e.url?(this.options.url=e.url,this.load(e.coordinates),this):this}_setImage(e){this.image=e,this._imageDirty=!0}getMesh(e,t){return!this._subdividedQuad||t?null:(this._subdividedMesh??(this._subdividedMesh=E1(e,{granularity:16})),this._subdividedMesh)}_disposeTexture(){var e;(e=this.texture)==null||e.destroy(),this.texture=null}_finishLoading(){this.map&&(this.setCoordinates(this.coordinates),this.fire(new Ne("data",{sourceDataType:"metadata"})))}onAdd(e){this.map=e,this.load()}onRemove(){var e;this._abortController&&(this._abortController=(this._abortController.abort(),null)),this._disposeTexture(),(e=this._subdividedMesh)==null||e.destroy(),this._subdividedMesh=null,this.image=null,this.tiles={}}setWarp(e){return this._warp===e?this:(this._warp=e,this.tileCoords&&this.setCoordinates(this.coordinates),this)}getWarp(){return this._warp}setCoordinates(e){this.coordinates=e;let t=e.map(Ie.fromLngLat);return this.tileID=MI(t),this.terrainTileRanges=this._getOverlappingTileRanges(t),this.minzoom=this.maxzoom=this.tileID.z,this.tileCoords=t.map(r=>this.tileID.getTilePoint(r)._round()),this.imageWarp=FI(this.tileCoords,this._warp),this._subdividedQuad=this.imageWarp[2]>0&&!P1(this.tileCoords),this.flippedWindingOrder=zI(this.tileCoords),this.fire(new Ne("data",{sourceDataType:"content"})),this}prepare(){if(Object.keys(this.tiles).length===0||!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 dt(e,this.image,t.RGBA),this.texture.bind(t.LINEAR,t.CLAMP_TO_EDGE)),this._imageDirty=!1;let r=!1;for(let i in this.tiles){let a=this.tiles[i];a.state!=="loaded"&&(a.state="loaded",a.texture=this.texture,r=!0)}r&&this.fire(new Ne("data",{sourceDataType:"idle",sourceId:this.id}))}async loadTile(e){var t;(t=this.tileID)!=null&&t.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 this.options.url!==void 0&&(e.url=this.options.url),e}hasTransition(){return!1}_getOverlappingTileRanges(e){let{minX:t,minY:r,maxX:i,maxY:a}=Er.fromPoints(e),n={};for(let s=0;s<=25;s++){let o=2**s,l=Math.floor(t*o),u=Math.floor(r*o),h=Math.floor(i*o),c=Math.floor(a*o),d=(l%o+o)%o,p=h%o,f=Math.floor(l/o),m=Math.floor(h/o);n[s]={minWrap:f,maxWrap:m,minTileXWrapped:d,maxTileXWrapped:p,minTileY:u,maxTileY:c}}return n}};function MI(e){let t=Er.fromPoints(e),r=t.width(),i=t.height(),a=Math.max(0,Math.floor(-Math.log(Math.max(r,i))/Math.LN2)),n=2**a;return new Ul(a,Math.floor((t.minX+t.maxX)/2*n),Math.floor((t.minY+t.maxY)/2*n))}function zI(e){let t=e[1].x-e[0].x,r=e[1].y-e[0].y,i=e[2].x-e[0].x;return t*(e[2].y-e[0].y)-r*i<0}function FI(e,t){if(t==="flat"||P1(e))return La;let[r,i,a,n]=e,s=r.x-i.x+a.x-n.x,o=r.y-i.y+a.y-n.y,l=[i.x-a.x,i.y-a.y,n.x-a.x,n.y-a.y],[u,h,c,d]=l,p=fC(l),f=(s*d-c*o)/p,m=(u*o-s*h)/p,g=[1,1+f,1+f+m,1+m],_=Math.max(...g)/Math.min(...g),y=t==="perspective"?0:RI(_);return!(_>=1&&_<=512)||y>=1?La:[f,m,y]}function RI(e){let t=(1-4/e)/.9921875;return Math.max(0,t)}function P1(e){let[t,r,i,a]=e;return t.x+i.x===r.x+a.x&&t.y+i.y===r.y+a.y}var kI=class extends ws{constructor(e,t,r,i){super(e,t,r,i),this._onPlayingHandler=()=>{var a;(a=this.map)==null||a.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 t=await Fv(this.urls);if(this._loaded=!0,!t)return;this.video=t,this.video.loop=!0,this.video.addEventListener("playing",this._onPlayingHandler),this.map&&this.video.play(),this._finishLoading()}catch(t){this.fire(new Y(zt(t)))}}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 Y(new O(`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(Object.keys(this.tiles).length===0||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 dt(e,this.video,t.RGBA),this.texture.bind(t.LINEAR,t.CLAMP_TO_EDGE));let r=!1;for(let i in this.tiles){let a=this.tiles[i];a.state!=="loaded"&&(a.state="loaded",a.texture=this.texture,r=!0)}r&&this.fire(new Ne("data",{sourceDataType:"idle",sourceId:this.id}))}serialize(){return{type:"video",urls:this.urls,coordinates:this.coordinates}}hasTransition(){return this.video&&!this.video.paused}},LI=class extends ws{constructor(e,t,r,i){super(e,t,r,i),t.coordinates?(!Array.isArray(t.coordinates)||t.coordinates.length!==4||t.coordinates.some(a=>!Array.isArray(a)||a.length!==2||a.some(n=>typeof n!="number")))&&this.fire(new Y(new O(`sources.${e}`,null,'"coordinates" property must be an array of 4 longitude/latitude array pairs'))):this.fire(new Y(new O(`sources.${e}`,null,'missing required property "coordinates"'))),t.animate&&typeof t.animate!="boolean"&&this.fire(new Y(new O(`sources.${e}`,null,'optional "animate" property must be a boolean value'))),t.canvas?typeof t.canvas!="string"&&!(t.canvas instanceof HTMLCanvasElement)&&this.fire(new Y(new O(`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 Y(new O(`sources.${e}`,null,'missing required property "canvas"'))),this.options=t,this.animate=t.animate===void 0||t.animate}async load(){if(this._loaded=!0,this.canvas||(this.canvas=this.options.canvas instanceof HTMLCanvasElement?this.options.canvas:document.getElementById(this.options.canvas)),this.width=this.canvas.width,this.height=this.canvas.height,this._hasInvalidDimensions()){this.fire(new Y(Error("Canvas dimensions cannot be less than or equal to zero.")));return}this.play=function(){this._playing=!0,this.map.triggerRepaint()},this.pause=function(){this._playing&&(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()||Object.keys(this.tiles).length===0)return;let t=this.map.painter.context,r=t.gl;this.texture?(e||this._playing)&&this.texture.update(this.canvas,{premultiply:!0}):(this.texture=new dt(t,this.canvas,r.RGBA,{premultiply:!0}),this.texture.bind(r.LINEAR,r.CLAMP_TO_EDGE));let i=!1;for(let a in this.tiles){let n=this.tiles[a];n.state!=="loaded"&&(n.state="loaded",n.texture=this.texture,i=!0)}i&&this.fire(new Ne("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}};const BI={},OI=(e,t,r,i)=>{let a=new($I(t.type))(e,t,r,i);if(a.id!==e)throw Error(`Expected Source id to be ${e} instead of ${a.id}`);return a},$I=e=>{switch(e){case"geojson":return SI;case"image":return ws;case"raster":return S1;case"raster-dem":return gI;case"vector":return mI;case"video":return kI;case"canvas":return LI}return BI[e]};function jI(e,t){let r={};if(!t)return r;for(let i of e){let a=i.layerIds.map(n=>t.getLayer(n)).filter(Boolean);if(a.length!==0){i.layers=a,i.stateDependentLayerIds&&(i.stateDependentLayers=i.stateDependentLayerIds.map(n=>a.filter(s=>s.id===n)[0]));for(let n of a)r[n.id]=i}}return r}const Ic="RTLPluginLoaded";var VI=class extends kt{constructor(...e){super(...e),this.status="unavailable",this.url=null,this.dispatcher=sI()}_syncState(e){return this.status=e,this.dispatcher.broadcast("SRPS",{pluginStatus:e,pluginURL:this.url}).catch(t=>{throw this.status="error",t})}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=Xt.resolveURL(e),!this.url)throw Error(`requested url ${e} is invalid`);if(this.status==="unavailable")if(t)this.status="deferred",this._syncState(this.status);else return this._requestImport();else if(this.status==="requested")return this._requestImport()}async _requestImport(){await this._syncState("loading"),this.status="loaded",this.fire(new us(Ic))}lazyLoad(){this.status==="unavailable"?this.status="requested":this.status==="deferred"&&this._requestImport()}};let Bm=null;function Mc(){return Bm||(Bm=new VI),Bm}var A1=class{constructor(e,t){this.timeAdded=0,this.fadeEndTime=0,this.fadeOpacity=1,this.tileID=e,this.uid=Ug(),this.uses=0,this.tileSize=t,this.buckets={},this.expirationTime=null,this.queryPadding=0,this.hasSymbolBuckets=!1,this.hasRTLText=!1,this.dependencies={},this.rttObjects=[],this.rttFingerprint={},this.expiredRequestCount=0,this.state="loading",this.featureStateRevision=-1}isRenderable(e){return this.hasData()&&(!this.fadeEndTime||this.fadingDirection!==0||this.fadeOpacity>0)&&(e||!this.holdingForSymbolFade())}setCrossFadeLogic({fadingRole:e,fadingDirection:t,fadingParentID:r,fadeEndTime:i}){this.resetFadeLogic(),this.fadingRole=e,this.fadingDirection=t,this.fadingParentID=r,this.fadeEndTime=i}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=Fe(),this.fadeEndTime=0,this.fadeOpacity=1}wasRequested(){return this.state==="errored"||this.state==="loaded"||this.state==="reloading"}clearTextures(e){this.demTexture&&e.saveTileTexture(this.demTexture),this.demTexture=null}getRTT(e){return this.rttObjects[e]}acquireRTT(e,t,r){return this.rttObjects[t]=e.acquireRTT(r)}releaseRTT(e){if(this.rttObjects.length!==0){for(let t of this.rttObjects)t&&e.releaseRTT(t);this.rttObjects.length=0}}loadVectorData(e,t,r){if((e==null?void 0:e.etagUnmodified)===!0){this.state="loaded";return}if(this.hasData()&&this.unloadVectorData(),this.state="loaded",!e){this.collisionBoxArray=new wy;return}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=jI(e.buckets,t==null?void 0:t.style),this.hasSymbolBuckets=!1;for(let i in this.buckets){let a=this.buckets[i];if(a instanceof ll)if(this.hasSymbolBuckets=!0,r)a.justReloaded=!0;else break}if(this.hasRTLText=!1,this.hasSymbolBuckets)for(let i in this.buckets){let a=this.buckets[i];if(a instanceof ll&&a.hasRTLText){this.hasRTLText=!0,Mc().lazyLoad();break}}this.queryPadding=0;for(let i in this.buckets){let a=this.buckets[i];this.queryPadding=Math.max(this.queryPadding,t.style.getLayer(i).queryRadius(a))}e.imageAtlas&&(this.imageAtlas=e.imageAtlas),e.glyphAtlasImage&&(this.glyphAtlasImage=e.glyphAtlasImage),this.dashPositions=e.dashPositions}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 r in this.buckets){let i=this.buckets[r];i.uploadPending()&&i.upload(e)}let t=e.gl;this.imageAtlas&&!this.imageAtlas.uploaded&&(this.imageAtlasTexture=new dt(e,this.imageAtlas.image,t.RGBA),this.imageAtlas.uploaded=!0),this.glyphAtlasImage&&(this.glyphAtlasImage=(this.glyphAtlasTexture=new dt(e,this.glyphAtlasImage,t.ALPHA),null))}prepare(e){this.imageAtlas&&this.imageAtlas.patchUpdatedImages(e,this.imageAtlasTexture)}queryRenderedFeatures(e,t,r,i,a,n,s,o,l,u,h){var c;return(c=this.latestFeatureIndex)!=null&&c.rawTileData?this.latestFeatureIndex.query({queryGeometry:i,cameraQueryGeometry:a,scale:n,tileSize:this.tileSize,pixelPosMatrix:u,transform:o,params:s,queryPadding:this.queryPadding*l,getElevation:h},e,t,r):{}}querySourceFeatures(e,t){let r=this.latestFeatureIndex;if(!(r!=null&&r.rawTileData))return;let i=r.loadVTLayers(),a=t!=null&&t.sourceLayer?t.sourceLayer:"",n=i._geojsonTileLayer||i[a];if(!n)return;let s=Hn(t==null?void 0:t.filter,`querySourceFeatures[${a}].filter`,t==null?void 0:t.globalState),{z:o,x:l,y:u}=this.tileID.canonical,h={z:o,x:l,y:u};for(let c=0;c<n.length;c++){let d=n.feature(c);if(s.needGeometry){let m=aa(d,!0);if(!s.filter(new ze(this.tileID.overscaledZ),m,this.tileID.canonical))continue}else if(!s.filter(new ze(this.tileID.overscaledZ),d))continue;let p=r.getId(d,a),f=new O0(d,o,l,u,p);f.tile=h,e.push(f)}}hasData(){return this.state==="loaded"||this.state==="reloading"||this.state==="expired"}patternsLoaded(){return this.imageAtlas&&!!Object.keys(this.imageAtlas.patternPositions).length}setExpiryData(e){let t=this.expirationTime;if(e.cacheControl){let r=xv(e.cacheControl);r["max-age"]&&(this.expirationTime=Date.now()+r["max-age"]*1e3)}else e.expires&&(this.expirationTime=new Date(e.expires).getTime());if(this.expirationTime){let r=Date.now(),i=!1;if(this.expirationTime>r)i=!1;else if(!t)i=!0;else if(this.expirationTime<t)i=!0;else{let a=this.expirationTime-t;a?this.expirationTime=r+Math.max(a,3e4):i=!0}i?(this.expiredRequestCount++,this.state="expired"):this.expiredRequestCount=0}}getExpiryTimeout(){if(this.expirationTime)return this.expiredRequestCount?1e3*(1<<Math.min(this.expiredRequestCount-1,31)):Math.min(this.expirationTime-new Date().getTime(),2**31-1)}setFeatureState(e,t,r){var a,n,s;if(!((a=this.latestFeatureIndex)!=null&&a.rawTileData)||Object.keys(e).length===0||this.featureStateRevision===r)return;this.featureStateRevision=r;let i=this.latestFeatureIndex.loadVTLayers();for(let o in this.buckets){if(!t.style.hasLayer(o))continue;let l=this.buckets[o],u=l.layers[0].sourceLayer||"_geojsonTileLayer",h=i[u],c=e[u];if(!h||!c||c.length===0)continue;l.update(c,h,((n=this.imageAtlas)==null?void 0:n.patternPositions)||{},this.dashPositions||{});let d=(s=t==null?void 0:t.style)==null?void 0:s.getLayer(o);d&&(this.queryPadding=Math.max(this.queryPadding,d.queryRadius(l)))}}holdingForSymbolFade(){return this.symbolFadeHoldUntil!==void 0}symbolFadeFinished(){return!this.symbolFadeHoldUntil||this.symbolFadeHoldUntil<Fe()}clearSymbolFadeHold(){this.symbolFadeHoldUntil=void 0}setSymbolHoldDuration(e){this.symbolFadeHoldUntil=Fe()+e}setDependencies(e,t){let r={};for(let i of t)r[i]=!0;this.dependencies[e]=r}hasDependency(e,t){for(let r of e){let i=this.dependencies[r];if(i){for(let a of t)if(i[a])return!0}}return!1}};function Om(e){let t=[];for(let r in e)t.push({id:r,state:e[r]});return t}var NI=class{constructor(){this.state={},this.stateChanges={},this.deletedStates={},this.revision=0}updateState(e,t,r){var a,n,s,o,l;let i=String(t);if((a=this.stateChanges)[e]||(a[e]={}),(n=this.stateChanges[e])[i]||(n[i]={}),H(this.stateChanges[e][i],r),this.deletedStates[e]===null){this.deletedStates[e]={};for(let u in this.state[e])if(u===i){this.deletedStates[e][i]={};for(let h in this.state[e][u])r[h]===void 0&&(this.deletedStates[e][i][h]=null)}else this.deletedStates[e][u]=null}else if(((s=this.deletedStates[e])==null?void 0:s[i])===null){this.deletedStates[e][i]={};for(let u in this.state[e][i])r[u]===void 0&&(this.deletedStates[e][i][u]=null)}else for(let u in r)((l=(o=this.deletedStates[e])==null?void 0:o[i])==null?void 0:l[u])===null&&delete this.deletedStates[e][i][u]}removeFeatureState(e,t,r){var a,n,s;if(this.deletedStates[e]===null)return;let i=String(t);if((a=this.deletedStates)[e]||(a[e]={}),r&&t!==void 0)this.deletedStates[e][i]!==null&&((n=this.deletedStates[e])[i]||(n[i]={}),this.deletedStates[e][i][r]=null);else if(t!==void 0)if((s=this.stateChanges[e])!=null&&s[i])for(r in this.deletedStates[e][i]={},this.stateChanges[e][i])this.deletedStates[e][i][r]=null;else this.deletedStates[e][i]=null;else this.deletedStates[e]=null}getState(e,t){let r=String(t),i=this.state[e]||{},a=this.stateChanges[e]||{},n=H({},i[r],a[r]);if(this.deletedStates[e]===null)return{};if(this.deletedStates[e]){let s=this.deletedStates[e][t];if(s===null)return{};for(let o in s)delete n[o]}return n}initializeTileState(e,t){let r={};for(let i in this.state)r[i]=Om(this.state[i]);e.setFeatureState(r,t,this.revision)}coalesceChanges(e,t){var a,n,s;let r={};for(let o in this.stateChanges){(a=this.state)[o]||(a[o]={}),r[o]||(r[o]={});for(let l in this.stateChanges[o])(n=this.state[o])[l]||(n[l]={}),H(this.state[o][l],this.stateChanges[o][l]),r[o][l]=this.state[o][l]}for(let o in this.deletedStates)if((s=this.state)[o]||(s[o]={}),r[o]||(r[o]={}),this.deletedStates[o]===null)for(let l in this.state[o])this.state[o][l]={},r[o][l]={};else for(let l in this.deletedStates[o]){if(this.deletedStates[o][l]===null)this.state[o][l]={};else for(let u of Object.keys(this.deletedStates[o][l]))delete this.state[o][l][u];r[o][l]=this.state[o][l]}if(this.stateChanges={},this.deletedStates={},Object.keys(r).length===0)return;this.revision++;let i={};for(let o in r)i[o]=Om(r[o]);e.setFeatureState(i,t,this.revision)}},qd=class C1{constructor(t,r){this.min=t,this.max=r,this.center=Ve([],pr([],this.min,this.max),.5)}quadrant(t){let r=[t%2==0,t<2],i=ph(this.min),a=ph(this.max);for(let n=0;n<r.length;n++)i[n]=r[n]?this.min[n]:this.center[n],a[n]=r[n]?this.center[n]:this.max[n];return a[2]=this.max[2],new C1(i,a)}distanceX(t){return Math.max(Math.min(this.max[0],t[0]),this.min[0])-t[0]}distanceY(t){return Math.max(Math.min(this.max[1],t[1]),this.min[1])-t[1]}intersectsFrustum(t){let r=!0;for(let i of t.planes){let a=this.intersectsPlane(i);if(a===0)return 0;a===1&&(r=!1)}return r?2:t.aabb.min[0]>this.max[0]||t.aabb.min[1]>this.max[1]||t.aabb.min[2]>this.max[2]||t.aabb.max[0]<this.min[0]||t.aabb.max[1]<this.min[1]||t.aabb.max[2]<this.min[2]?0:1}intersectsPlane(t){let r=t[3],i=t[3];for(let a=0;a<3;a++)t[a]>0?(r+=t[a]*this.min[a],i+=t[a]*this.max[a]):(i+=t[a]*this.min[a],r+=t[a]*this.max[a]);return r>=0?2:i<0?0:1}},Zd=class I1{constructor(t,r,i){this.points=t,this.planes=r,this.aabb=i}static fromInvProjectionMatrix(t,r=1,i=0,a,n){let s=[[-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]],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]],l=2**i,u=s.map(p=>UI(p,t,r,l));a&&GI(u,o[0],a,n);let h=o.map(p=>{let f=li([],u[p[0]],u[p[1]]),m=li([],u[p[2]],u[p[1]]),g=Bt([],Ht([],f,m)),_=-lt(g,u[p[1]]);return g.concat(_)}),c=[1/0,1/0,1/0],d=[-1/0,-1/0,-1/0];for(let p of u)for(let f=0;f<3;f++)c[f]=Math.min(c[f],p[f]),d[f]=Math.max(d[f],p[f]);return new I1(u,h,new qd(c,d))}};function UI(e,t,r,i){let a=Pt([],e,t),n=1/a[3]/r*i;return iv(a,a,[n,n,1/a[3],n])}function GI(e,t,r,i){let a=i?4:0,n=i?0:4,s=0,o=[],l=[];for(let c=0;c<4;c++){let d=li([],e[c+n],e[c+a]),p=Sr(d);Ve(d,d,1/p),o.push(p),l.push(d)}for(let c=0;c<4;c++){let d=hv(e[c+a],l[c],r);s=d!==null&&d>=0?Math.max(s,d):Math.max(s,o[c])}let u=qI(e,t),h=ZI(r,u);if(h!==null){let c=h/lt(l[0],u);s=Math.min(s,c)}for(let c=0;c<4;c++){let d=Math.min(s,o[c]);e[c+n]=[e[c+a][0]+l[c][0]*d,e[c+a][1]+l[c][1]*d,e[c+a][2]+l[c][2]*d,1]}}function qI(e,t){let r=li([],e[t[0]],e[t[1]]),i=li([],e[t[2]],e[t[1]]),a=[0,0,0,0];return Bt(a,Ht([],r,i)),a[3]=-lt(a,e[t[0]]),a}function ZI(e,t){let r=$o(e),i=tv([],e,1/r),a=li([],t,Ve([],i,lt(t,i))),n=$o(a);if(n>0){let s=Math.sqrt(1-i[3]*i[3]),o=Ve([],i,-i[3]),l=pr([],o,Ve([],a,s/n));return mh(t,l)}return null}function WI(e,t,r){let i=t.intersectsFrustum(e);if(!r||i===0)return i;let a=t.intersectsPlane(r);return a===0?0:i===2&&a===2?2:1}function $m(e,t,r){let i=0,a=(r-t)/10;for(let n=0;n<10;n++){let s=t+(n+.5)/10*(r-t);i+=a*Math.cos(s)**+e}return i}function zc(e,t){return function(r,i,a,n,s){let o=2*((e-1)/It(Math.cos(Ge(Zi-s))/Math.cos(Ge(Zi)))-1),l=Math.acos(a/n),u=2*$m(o-1,0,Ge(s/2)),h=Math.min(Ge(Zi),l+Ge(s/2)),c=Math.min(h,l-Ge(s/2)),d=$m(o-1,c,h),p=Math.atan(i/a),f=Math.hypot(i,a),m=r;return m+=It(n/f/Math.max(.5,Math.cos(Ge(s/2)))),m+=o*It(Math.cos(p))/2,m-=It(Math.max(1,d/u/t))/2,m}}const HI=zc(9.314,3);function Wd(e,t){let r=(t.roundZoom?Math.round:Math.floor)(e.zoom+It(e.tileSize/t.tileSize));return Math.max(0,r)}function XI(e,t){let r=Zi-e.pitch-e.fov/2,i=se((15-r)/15,0,1),a=Math.max(500,t??0);return e.elevation+i*a}function YI(e,t,r){let i=e.planes[1],a=e.points.map(l=>{let u=i[0]*l[0]+i[1]*l[1]+i[2]*l[2]+i[3];if(Math.abs(u)>1e-6)return l;let h=[l[0]-r[0],l[1]-r[1],l[2]-r[2]],c=i[0]*h[0]+i[1]*h[1]+i[2]*h[2];if(c>=-1e-9)return l;let d=t/-c;return[l[0]+h[0]*d,l[1]+h[1]*d,l[2]+h[2]*d,l[3]]}),n=e.planes.map((l,u)=>u===1?[l[0],l[1],l[2],l[3]+t]:l),s=[1/0,1/0,1/0],o=[-1/0,-1/0,-1/0];for(let l of a)for(let u=0;u<3;u++)s[u]=Math.min(s[u],l[u]),o[u]=Math.max(o[u],l[u]);return new Zd(a,n,new qd(s,o))}function KI(e,t,r,i){let a=Math.hypot(t[0],t[1],t[2]);if(a===0)return{frustum:e,plane:t};let n=1+i/Lt,s=se(-t[3]/a,-1,1),o=Math.cos(Math.acos(s)+Math.acos(1/n));return{frustum:YI(e,Math.sqrt(n*n-1),r),plane:[t[0],t[1],t[2],-o*a]}}function en(e,t){let r=e.getCameraFrustum(),i=e.getClippingPlane();i&&t.maxContentElevation>0&&({frustum:r,plane:i}=KI(r,i,e.cameraPosition,t.maxContentElevation));let a=OT(e),n=Ie.fromLngLat(e.center,e.elevation),s=XI(e,t.maxContentElevation),o=e.getCoveringTilesDetailsProvider(),l=o.allowVariableZoom(e,t),u=Wd(e,t),h=t.minzoom||0,c=t.maxzoom===void 0?e.maxZoom:t.maxzoom,d=Math.min(Math.max(0,u),c),p=2**d,f=[p*a.x,p*a.y,0],m=[p*n.x,p*n.y,0],g=Math.hypot(n.x-a.x,n.y-a.y),_=Math.abs(n.z-a.z),y=Math.hypot(g,_),v=b=>({zoom:0,x:0,y:0,wrap:b,fullyVisible:!1}),x=[],w=[];if(e.renderWorldCopies&&o.allowWorldCopies())for(let b=1;b<=3;b++)x.push(v(-b)),x.push(v(b));for(x.push(v(0));x.length>0;){let b=x.pop(),S=b.x,A=b.y,P=b.fullyVisible,I={x:S,y:A,z:b.zoom},R=o.getTileBoundingVolume(I,b.wrap,s,t);if(!P){let D=WI(r,R,i);if(D===0)continue;P=D===2}let F=o.distanceToTile2d(a.x,a.y,I,R),T=u;l&&(T=(t.calculateTileZoom||HI)(e.zoom+It(e.tileSize/t.tileSize),F,_,y,e.fov)),T=(t.roundZoom?Math.round:Math.floor)(T),T=Math.max(0,T);let E=Math.min(T,c);if(b.wrap=o.getWrap(n,I,b.wrap),b.zoom>=E){if(b.zoom<h)continue;let D=d-b.zoom,C=f[0]-.5-(S<<D),k=f[1]-.5-(A<<D),B=t.reparseOverscaled?Math.max(b.zoom,T):b.zoom;w.push({tileID:new Dt(b.zoom===c?B:b.zoom,b.wrap,b.zoom,S,A),distanceSq:uv([m[0]-.5-S,m[1]-.5-A]),tileDistanceToCamera:Math.sqrt(C*C+k*k)});continue}for(let D=0;D<4;D++){let C=(S<<1)+D%2,k=(A<<1)+(D>>1),B=b.zoom+1;x.push({zoom:B,x:C,y:k,wrap:b.wrap,fullyVisible:P})}}return w.sort((b,S)=>b.distanceSq-S.distanceSq).map(b=>b.tileID)}function jm(e){return e==="raster"||e==="image"||e==="video"}function JI(e,t,r,i,a,n,s){let o=Fe(),l=dv(t);for(let u of t){let h=e.getTileById(u.key);(h.fadingDirection===0||h.fadeOpacity===0)&&h.resetFadeLogic(),!QI(e,h,r,o,i,a,s)&&(eM(e,h,r,o,n,s)||tM(h,l,o,s)||h.resetFadeLogic())}}function QI(e,t,r,i,a,n,s){if(!t.hasData())return!1;let{tileID:o,fadingRole:l,fadingDirection:u,fadingParentID:h}=t;if(l===0&&u===1&&h)return r[h.key]=h,!0;let c=Math.max(o.overscaledZ-a,n);for(let d=o.overscaledZ-1;d>=c;d--){let p=o.scaledTo(d),f=e.getLoadedTile(p);if(f)return t.setCrossFadeLogic({fadingRole:0,fadingDirection:1,fadingParentID:f.tileID,fadeEndTime:i+s}),f.setCrossFadeLogic({fadingRole:1,fadingDirection:0,fadeEndTime:i+s}),r[p.key]=p,!0}return!1}function eM(e,t,r,i,a,n){if(!t.hasData())return!1;let s=t.tileID.children(a),o=Vm(e,t,s,r,i,a,n);if(o)return!0;for(let l of s)Vm(e,t,l.children(a),r,i,a,n)&&(o=!0);return o}function Vm(e,t,r,i,a,n,s){if(r[0].overscaledZ>=n)return!1;let o=!1;for(let l of r){let u=e.getLoadedTile(l);if(!u)continue;let{fadingRole:h,fadingDirection:c,fadingParentID:d}=u;(h!==0||c!==0||!d)&&(u.setCrossFadeLogic({fadingRole:0,fadingDirection:0,fadingParentID:t.tileID,fadeEndTime:a+s}),t.setCrossFadeLogic({fadingRole:1,fadingDirection:1,fadeEndTime:a+s})),i[l.key]=l,o=!0}return o}function tM(e,t,r,i){let a=e.tileID;if(e.selfFading)return!0;if(e.hasData())return!1;if(t.has(a)){let n=r+i;return e.setSelfFadeLogic(n),!0}return!1}function rM(e,t){if(t<=0)return!1;let r=Fe();for(let i of e.getAllTiles())if(i.fadeEndTime>=r)return!0;return!1}function iM(e,t){var i,a,n;let r=t.getRenderableIds();for(let s of r){if(!((i=e.neighboringTiles)!=null&&i[s]))continue;let o=t.getTileById(s);e.neighboringTiles[s].backfilled||Nm(e,o),!((n=(a=o.neighboringTiles)==null?void 0:a[e.tileID.key])!=null&&n.backfilled)&&Nm(o,e)}}function Nm(e,t){var s;e.needsHillshadePrepare=!0,e.needsTerrainPrepare=!0,e.needsColorReliefPrepare=!0;let r=t.tileID.canonical.x-e.tileID.canonical.x,i=t.tileID.canonical.y-e.tileID.canonical.y,a=2**e.tileID.canonical.z,n=t.tileID.key;(r!==0||i!==0)&&(Math.abs(i)>1||(Math.abs(r)>1&&(Math.abs(r+a)===1?r+=a:Math.abs(r-a)===1&&(r-=a)),t.dem&&e.dem&&(e.dem.backfillBorder(t.dem,r,i),(s=e.neighboringTiles)!=null&&s[n]&&(e.neighboringTiles[n].backfilled=!0))))}var Um=class{constructor(){this._tiles={}}handleWrapJump(e){let t={};for(let r in this._tiles){let i=this._tiles[r];i.tileID=i.tileID.unwrapTo(i.tileID.wrap+e),t[i.tileID.key]=i}this._tiles=t}setFeatureState(e,t,r){for(let i in this._tiles)this._tiles[i].setFeatureState(e,t,r)}getAllTiles(){return Object.values(this._tiles)}getAllIds(e=!1){return e?Object.values(this._tiles).map(t=>t.tileID).sort(om).map(t=>t.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!=null&&t.hasData()?t:null}isIdRenderable(e,t=!1){var r;return(r=this.getTileById(e))==null?void 0:r.isRenderable(t)}getRenderableIds(e=0,t){let r=[];for(let i of this.getAllIds())this.isIdRenderable(i,t)&&r.push(this.getTileById(i));return t?r.sort((i,a)=>{let n=i.tileID,s=a.tileID,o=new M(n.canonical.x,n.canonical.y)._rotate(-e),l=new M(s.canonical.x,s.canonical.y)._rotate(-e);return n.overscaledZ-s.overscaledZ||l.y-o.y||l.x-o.x}).map(i=>i.tileID.key):r.map(i=>i.tileID).sort(om).map(i=>i.key)}},oi,Fc=(oi=class extends kt{constructor(t,r,i){super(),this._maxContentElevationSeen=0,this.id=t,this.dispatcher=i,this.on("data",a=>{this._dataHandler(a)}),this.on("dataloading",()=>{this._sourceErrored=!1}),this.on("error",()=>{this._sourceErrored=this._source.loaded()}),this._source=OI(t,r,i,this),this._inViewTiles=new Um,this._outOfViewCache=new cC(0,a=>this._unloadTile(a)),this._timers={},this._maxTileCacheSize=null,this._maxTileCacheZoomLevels=null,this._rasterFadeDuration=0,this._maxFadingAncestorLevels=5,this._state=new NI,this._didEmitContent=!1,this._updated=!1}onAdd(t){var r;this.map=t,this._maxTileCacheSize=t?t._maxTileCacheSize:null,this._maxTileCacheZoomLevels=t?t._maxTileCacheZoomLevels:null,(r=this._source)!=null&&r.onAdd&&this._source.onAdd(t)}onRemove(t){var r;for(let i of this._inViewTiles.getAllTiles())i.unloadVectorData();this.clearTiles(),(r=this._source)!=null&&r.onRemove&&this._source.onRemove(t),this._inViewTiles=new Um}loaded(){if(this._sourceErrored)return!0;if(!this._sourceLoaded||!this._source.loaded())return!1;if((this.used!==void 0||this.usedForTerrain!==void 0)&&!this.used&&!this.usedForTerrain)return!0;if(!this._updated)return!1;for(let t of this._inViewTiles.getAllTiles())if(t.state!=="loaded"&&t.state!=="errored")return!1;return!0}getSource(){return this._source}getState(){return this._state}pause(){this._paused=!0}resume(){if(!this._paused)return;let t=this._shouldReloadOnResume;this._paused=!1,this._shouldReloadOnResume=!1,t&&this.reload(),this.transform&&this.update(this.transform,this.terrain)}async _loadTile(t,r,i,a){try{let n=await this._source.loadTile(t);this._tileLoaded(t,r,i,a,n)}catch(n){t.state="errored",n.status===404?this.update(this.transform,this.terrain):this._source.fire(new Y(zt(n),{tile:t}))}}_unloadTile(t){this._source.unloadTile&&this._source.unloadTile(t)}_abortTile(t){this._source.abortTile&&this._source.abortTile(t),this._source.fire(new Ne("dataabort",{tile:t,coord:t.tileID}))}serialize(){return this._source.serialize()}prepare(t){this._source.prepare&&this._source.prepare(),this._state.coalesceChanges(this._inViewTiles,this.map?this.map.painter:null);for(let r of this._inViewTiles.getAllTiles())r.upload(t),r.prepare(this.map.style.imageManager)}getIds(){return this._inViewTiles.getAllIds(!0)}getRenderableIds(t){var r;return this._inViewTiles.getRenderableIds((r=this.transform)==null?void 0:r.bearingInRadians,t)}hasRenderableParent(t){let r=t.overscaledZ-1;if(r>=this._source.minzoom){let i=this.getLoadedTile(t.scaledTo(r));if(i)return this._inViewTiles.isIdRenderable(i.tileID.key)}return!1}reload(t,r=void 0){if(this._paused){this._shouldReloadOnResume=!0;return}this._outOfViewCache.reset();for(let i of this._inViewTiles.getAllIds()){let a=this._inViewTiles.getTileById(i);(!r||this._source.shouldReloadTile(a,r))&&(t?this._reloadTile(i,a.state==="errored"?"loading":"expired"):a.state!=="errored"&&this._reloadTile(i,"reloading"))}}async _reloadTile(t,r){let i=this._inViewTiles.getTileById(t);if(!i)return;let a=i.hasData();i.state!=="loading"&&(i.state=r),await this._loadTile(i,t,r,a)}_tileLoaded(t,r,i,a,n){a||(t.timeAdded=Fe(),t.selfFading&&(t.fadeEndTime=t.timeAdded+this._rasterFadeDuration)),i==="expired"&&(t.refreshedUponExpiration=!0),this._setTileReloadTimer(r,t),!(n!=null&&n.unmodified)&&(this.getSource().type==="raster-dem"&&t.dem&&iM(t,this._inViewTiles),t.featureStateRevision=-1,this._state.initializeTileState(t,this.map?this.map.painter:null),t.aborted||this._source.fire(new Ne("data",{tile:t,coord:t.tileID})))}getTile(t){return this.getTileByID(t.key)}getTileByID(t){return this._inViewTiles.getTileById(t)}_retainLoadedChildren(t,r){let i=this._getLoadedDescendents(r),a=new Set;for(let n of r){let s=i[n.key];if(!(s!=null&&s.length)){a.add(n);continue}let o=n.overscaledZ+oi.maxOverzooming,l=s.filter(c=>c.tileID.overscaledZ<=o);if(!l.length){a.add(n);continue}let u=Math.min(...l.map(c=>c.tileID.overscaledZ)),h=l.filter(c=>c.tileID.overscaledZ===u).map(c=>c.tileID);for(let c of h)t[c.key]=c;this._areDescendentsComplete(h,u,n.overscaledZ)||a.add(n)}return a}_getLoadedDescendents(t){var i;let r={};for(let a of this._inViewTiles.getAllTiles().filter(n=>n.hasData()))for(let n of t)a.tileID.isChildOf(n)&&(r[i=n.key]||(r[i]=[]),r[n.key].push(a));return r}_areDescendentsComplete(t,r,i){return t.length===1&&t[0].isOverscaled()?t[0].overscaledZ===r:4**(r-i)===t.length}getLoadedTile(t){return this._inViewTiles.getLoadedTile(t)}updateCacheSize(t){let r=(Math.ceil(t.width/this._source.tileSize)+1)*(Math.ceil(t.height/this._source.tileSize)+1),i=this._maxTileCacheZoomLevels===null?Yi.MAX_TILE_CACHE_ZOOM_LEVELS:this._maxTileCacheZoomLevels,a=Math.floor(r*i),n=typeof this._maxTileCacheSize=="number"?Math.min(this._maxTileCacheSize,a):a;this._outOfViewCache.setMaxSize(n)}handleWrapJump(t){let r=(t-(this._prevLng===void 0?t:this._prevLng))/360,i=Math.round(r);this._prevLng=t,i&&(this._inViewTiles.handleWrapJump(i),this._resetTileReloadTimers())}_updateMaxContentElevation(){var a,n;let t=this._maxContentElevationSeen,r=(n=(a=this.map)==null?void 0:a.style)==null?void 0:n._layers;if(!r)return t;let i=this._inViewTiles.getAllTiles();for(let s in r){let o=r[s];if(o.type!=="symbol"||o.source!==this.id||o.isHidden(this.transform.zoom))continue;let l=o;if(!l.layout)continue;let u=l.layout.get("symbol-height-offset");if(t=Math.max(t,u.constantOr(0)),!u.isConstant())for(let h of i){let c=h.getBucket(o);c&&c.maxHeightOffset>t&&(t=c.maxHeightOffset)}}return this._maxContentElevationSeen=t,t}update(t,r){if(!this._sourceLoaded||this._paused)return;this.transform=t,this.terrain=r,this.updateCacheSize(t),this.handleWrapJump(this.transform.center.lng);let i;!this.used&&!this.usedForTerrain?i=[]:this._source.tileID?i=t.getVisibleUnwrappedCoordinates(this._source.tileID).map(l=>new Dt(l.canonical.z,l.wrap,l.canonical.z,l.canonical.x,l.canonical.y)):(i=en(t,{tileSize:this.usedForTerrain?this.tileSize:this._source.tileSize,minzoom:this._source.minzoom,maxzoom:this._source.type==="vector"&&this.map._zoomLevelsToOverscale!==void 0?Math.max(this._source.maxzoom,t.maxZoom-this.map._zoomLevelsToOverscale):this._source.maxzoom,roundZoom:!this.usedForTerrain&&this._source.roundZoom,reparseOverscaled:this._source.reparseOverscaled,terrain:r,calculateTileZoom:this._source.calculateTileZoom,maxContentElevation:this._updateMaxContentElevation()}),this._source.hasTile&&(i=i.filter(l=>this._source.hasTile(l)))),this.usedForTerrain&&(i=this._addTerrainIdealTiles(i));let a=i.length===0&&!this._updated&&this._didEmitContent;this._updated=!0,a&&this.fire(new Ne("data",{sourceDataType:"idle",sourceId:this.id}));let n=Wd(t,this._source),s=this._updateRetainedTiles(i,n),o=jm(this._source.type);o&&this._rasterFadeDuration>0&&!r&&JI(this._inViewTiles,i,s,this._maxFadingAncestorLevels,this._source.minzoom,this._source.maxzoom,this._rasterFadeDuration),o?this._cleanUpRasterTiles(s):this._cleanUpVectorTiles(s)}_cleanUpRasterTiles(t){for(let r of this._inViewTiles.getAllIds())t[r]||this._removeTile(r)}_cleanUpVectorTiles(t){for(let r of this._inViewTiles.getAllIds()){let i=this._inViewTiles.getTileById(r);if(t[r]){i.clearSymbolFadeHold();continue}if(!i.hasSymbolBuckets){this._removeTile(r);continue}i.holdingForSymbolFade()?i.symbolFadeFinished()&&this._removeTile(r):i.setSymbolHoldDuration(this.map._fadeDuration)}}_addTerrainIdealTiles(t){let r=[];for(let i of t)if(i.canonical.z>this._source.minzoom){let a=i.scaledTo(i.canonical.z-1);r.push(a);let n=i.scaledTo(Math.max(this._source.minzoom,Math.min(i.canonical.z,5)));r.push(n)}return t.concat(r)}releaseSymbolFadeTiles(){for(let t of this._inViewTiles.getAllIds())this._inViewTiles.getTileById(t).holdingForSymbolFade()&&this._removeTile(t)}_updateRetainedTiles(t,r){var l;let i=new Set;for(let u of t)this._addTile(u).hasData()||i.add(u);let a=t.reduce((u,h)=>(u[h.key]=h,u),{}),n=this._retainLoadedChildren(a,i),s={},o=Math.max(r-oi.maxUnderzooming,this._source.minzoom);for(let u of n){let h=this._inViewTiles.getTileById(u.key),c=h==null?void 0:h.wasRequested();for(let d=u.overscaledZ-1;d>=o;--d){let p=u.scaledTo(d);if(s[p.key])break;if(s[p.key]=!0,h=this.getTile(p),!h&&c&&(h=this._addTile(p)),h){let f=h.hasData();if((f||!((l=this.map)!=null&&l.cancelPendingTileRequestsWhileZooming)||c)&&(a[p.key]=p),c=h.wasRequested(),f)break}}}return a}_addTile(t){let r=this._inViewTiles.getTileById(t.key);if(r)return r;r=this._outOfViewCache.getAndRemove(t),r&&(r.resetFadeLogic(),this._setTileReloadTimer(t.key,r),r.tileID=t,this._state.initializeTileState(r,this.map?this.map.painter:null));let i=r;return r||(r=new A1(t,this._source.tileSize*t.overscaleFactor()),this._loadTile(r,t.key,r.state,!1)),r.uses++,this._inViewTiles.setTile(t.key,r),i||this._source.fire(new Ne("dataloading",{tile:r,coord:r.tileID})),r}_setTileReloadTimer(t,r){this._clearTileReloadTimer(t);let i=r.getExpiryTimeout();if(i){let a=()=>{this._reloadTile(t,"expired"),delete this._timers[t]};this._timers[t]=setTimeout(a,i)}}_clearTileReloadTimer(t){let r=this._timers[t];r&&(clearTimeout(r),delete this._timers[t])}_resetTileReloadTimers(){for(let t in this._timers)clearTimeout(this._timers[t]),delete this._timers[t];for(let t of this._inViewTiles.getAllIds()){let r=this._inViewTiles.getTileById(t);this._setTileReloadTimer(t,r)}}refreshTiles(t){for(let r of this._inViewTiles.getAllIds()){let i=this._inViewTiles.getTileById(r);(this._inViewTiles.isIdRenderable(r)||i.state=="errored")&&t.some(a=>a.equals(i.tileID.canonical))&&this._reloadTile(r,"expired")}}_removeTile(t){let r=this._inViewTiles.getTileById(t);r&&(r.uses--,this._inViewTiles.deleteTileById(t),this._clearTileReloadTimer(t),!(r.uses>0)&&(r.hasData()&&r.state!=="reloading"?this._outOfViewCache.add(r.tileID,r,r.getExpiryTimeout()):(r.aborted=!0,this._abortTile(r),this._unloadTile(r))))}_dataHandler(t){if(t.dataType==="source"){if(t.sourceDataType==="metadata"){this._sourceLoaded=!0;return}t.sourceDataType==="content"&&this._sourceLoaded&&!this._paused&&(this.reload(t.sourceDataChanged,t.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 t of this._inViewTiles.getAllIds())this._removeTile(t);this._outOfViewCache.reset()}tilesIn(t,r,i){let a=[],n=this.transform;if(!n)return a;let s=n.getCoveringTilesDetailsProvider().allowWorldCopies(),o=i?n.getCameraQueryGeometry(t):t,l=p=>n.screenPointToMercatorCoordinate(p,this.terrain),u=this.transformBbox(t,l,!s),h=this.transformBbox(o,l,!s),c=this.getIds(),d=Er.fromPoints(h);for(let p of c){let f=this._inViewTiles.getTileById(p);if(f.holdingForSymbolFade())continue;let m=s?[f.tileID]:[f.tileID.unwrapTo(-1),f.tileID.unwrapTo(0)],g=2**(n.zoom-f.tileID.overscaledZ),_=r*f.queryPadding*L/f.tileSize/g;for(let y of m){let v=d.map(x=>y.getTilePoint(new Ie(x.x,x.y)));if(v.expandBy(_),v.intersects(MT)){let x=u.map(b=>y.getTilePoint(b)),w=h.map(b=>y.getTilePoint(b));a.push({tile:f,tileID:s?y:y.unwrapTo(0),queryGeometry:x,cameraQueryGeometry:w,scale:g})}}}return a}transformBbox(t,r,i){let a=t.map(r);if(i){let n=Er.fromPoints(t);n.shrinkBy(Math.min(n.width(),n.height())*.001);let s=n.map(r);Er.fromPoints(a).covers(s)||(a=a.map(o=>o.x>.5?new Ie(o.x-1,o.y,o.z):o))}return a}getVisibleCoordinates(t){let r=this.getRenderableIds(t).map(i=>this._inViewTiles.getTileById(i).tileID);return this.transform&&this.transform.populateCache(r),r}hasTransition(){return this._source.hasTransition()?!0:jm(this._source.type)&&rM(this._inViewTiles,this._rasterFadeDuration)}setRasterFadeDuration(t){this._rasterFadeDuration=t}setFeatureState(t,r,i){t||(t=Mo),this._state.updateState(t,r,i)}removeFeatureState(t,r,i){t||(t=Mo),this._state.removeFeatureState(t,r,i)}getFeatureState(t,r){return t||(t=Mo),this._state.getState(t,r)}setDependencies(t,r,i){let a=this._inViewTiles.getTileById(t);a&&a.setDependencies(r,i)}reloadTilesForDependencies(t,r){for(let i of this._inViewTiles.getAllIds())this._inViewTiles.getTileById(i).hasDependency(t,r)&&this._reloadTile(i,"reloading");this._outOfViewCache.filter(i=>!i.hasDependency(t,r))}areTilesLoaded(){for(let t of this._inViewTiles.getAllTiles())if(t.state!=="loaded"&&t.state!=="errored")return!1;return!0}},oi.maxUnderzooming=10,oi.maxOverzooming=3,oi),aM=class{constructor(e,t){this.reset(e,t)}reset(e,t){this.points=e||[],this._distances=[0];for(let r=1;r<this.points.length;r++)this._distances[r]=this._distances[r-1]+this.points[r].dist(this.points[r-1]);this.length=this._distances[this._distances.length-1],this.padding=Math.min(t||0,this.length*.5),this.paddedLength=this.length-this.padding*2}lerp(e){if(this.points.length===1)return this.points[0];e=se(e,0,1);let t=1,r=this._distances[t],i=e*this.paddedLength+this.padding;for(;r<i&&t<this._distances.length;)r=this._distances[++t];let a=t-1,n=this._distances[a],s=r-n,o=s>0?(i-n)/s:0;return this.points[a].mult(1-o).add(this.points[t].mult(o))}};function Ro(e,t,r,i,a){return a?e?e(t,r)+i:i===0?void 0:i:i}function uo(e,t){let r=!0;return e==="always"||(e==="never"||t==="never")&&(r=!1),r}var Gm=class{constructor(e,t,r){let i=this.boxCells=[],a=this.circleCells=[];this.xCellCount=Math.ceil(e/r),this.yCellCount=Math.ceil(t/r);for(let n=0;n<this.xCellCount*this.yCellCount;n++)i.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,r,i,a){this._forEachCell(t,r,i,a,this._insertBoxCell,this.boxUid++),this.boxKeys.push(e),this.bboxes.push(t),this.bboxes.push(r),this.bboxes.push(i),this.bboxes.push(a)}insertCircle(e,t,r,i){this._forEachCell(t-i,r-i,t+i,r+i,this._insertCircleCell,this.circleUid++),this.circleKeys.push(e),this.circles.push(t),this.circles.push(r),this.circles.push(i)}_insertBoxCell(e,t,r,i,a,n){this.boxCells[a].push(n)}_insertCircleCell(e,t,r,i,a,n){this.circleCells[a].push(n)}_query(e,t,r,i,a,n,s){if(r<0||e>this.width||i<0||t>this.height)return[];let o=[];if(e<=0&&t<=0&&this.width<=r&&this.height<=i){if(a)return[{key:null,x1:e,y1:t,x2:r,y2:i}];for(let l=0;l<this.boxKeys.length;l++)o.push({key:this.boxKeys[l],x1:this.bboxes[l*4],y1:this.bboxes[l*4+1],x2:this.bboxes[l*4+2],y2:this.bboxes[l*4+3]});for(let l=0;l<this.circleKeys.length;l++){let u=this.circles[l*3],h=this.circles[l*3+1],c=this.circles[l*3+2];o.push({key:this.circleKeys[l],x1:u-c,y1:h-c,x2:u+c,y2:h+c})}}else{let l={hitTest:a,overlapMode:n,seenUids:{box:{},circle:{}}};this._forEachCell(e,t,r,i,this._queryCell,o,l,s)}return o}query(e,t,r,i){return this._query(e,t,r,i,!1,null)}hitTest(e,t,r,i,a,n){return this._query(e,t,r,i,!0,a,n).length>0}hitTestCircle(e,t,r,i,a){let n=e-r,s=e+r,o=t-r,l=t+r;if(s<0||n>this.width||l<0||o>this.height)return!1;let u=[],h={hitTest:!0,overlapMode:i,circle:{x:e,y:t,radius:r},seenUids:{box:{},circle:{}}};return this._forEachCell(n,o,s,l,this._queryCellCircle,u,h,a),u.length>0}_queryCell(e,t,r,i,a,n,s,o){let{seenUids:l,hitTest:u,overlapMode:h}=s,c=this.boxCells[a],d=1e-6;if(c!==null){let f=this.bboxes;for(let m of c)if(!l.box[m]){l.box[m]=!0;let g=m*4,_=this.boxKeys[m];if(e<=f[g+2]+d&&t<=f[g+3]+d&&r>=f[g+0]-d&&i>=f[g+1]-d&&(!o||o(_))&&(!u||!uo(h,_.overlapMode))&&(n.push({key:_,x1:f[g],y1:f[g+1],x2:f[g+2],y2:f[g+3]}),u))return!0}}let p=this.circleCells[a];if(p!==null){let f=this.circles;for(let m of p)if(!l.circle[m]){l.circle[m]=!0;let g=m*3,_=this.circleKeys[m];if(this._circleAndRectCollide(f[g],f[g+1],f[g+2],e,t,r,i)&&(!o||o(_))&&(!u||!uo(h,_.overlapMode))){let y=f[g],v=f[g+1],x=f[g+2];if(n.push({key:_,x1:y-x,y1:v-x,x2:y+x,y2:v+x}),u)return!0}}}return!1}_queryCellCircle(e,t,r,i,a,n,s,o){let{circle:l,seenUids:u,overlapMode:h}=s,c=this.boxCells[a];if(c!==null){let p=this.bboxes;for(let f of c)if(!u.box[f]){u.box[f]=!0;let m=f*4,g=this.boxKeys[f];if(this._circleAndRectCollide(l.x,l.y,l.radius,p[m+0],p[m+1],p[m+2],p[m+3])&&(!o||o(g))&&!uo(h,g.overlapMode))return n.push(!0),!0}}let d=this.circleCells[a];if(d!==null){let p=this.circles;for(let f of d)if(!u.circle[f]){u.circle[f]=!0;let m=f*3,g=this.circleKeys[f];if(this._circlesCollide(p[m],p[m+1],p[m+2],l.x,l.y,l.radius)&&(!o||o(g))&&!uo(h,g.overlapMode))return n.push(!0),!0}}}_forEachCell(e,t,r,i,a,n,s,o){let l=this._convertToXCellCoord(e),u=this._convertToYCellCoord(t),h=this._convertToXCellCoord(r),c=this._convertToYCellCoord(i);for(let d=l;d<=h;d++)for(let p=u;p<=c;p++){let f=this.xCellCount*p+d;if(a.call(this,e,t,r,i,f,n,s,o))return}}_convertToXCellCoord(e){return Math.max(0,Math.min(this.xCellCount-1,Math.floor(e*this.xScale)))}_convertToYCellCoord(e){return Math.max(0,Math.min(this.yCellCount-1,Math.floor(e*this.yScale)))}_circlesCollide(e,t,r,i,a,n){let s=i-e,o=a-t,l=r+n;return l*l>s*s+o*o}_circleAndRectCollide(e,t,r,i,a,n,s){let o=(n-i)/2,l=Math.abs(e-(i+o));if(l>o+r)return!1;let u=(s-a)/2,h=Math.abs(t-(a+u));if(h>u+r)return!1;if(l<=o||h<=u)return!0;let c=l-o,d=h-u;return c*c+d*d<=r*r}};function nM(e,t){let r=1/(t[0]*t[0]+t[1]*t[1]+t[2]*t[2]),i=1/(t[8]*t[8]+t[9]*t[9]+t[10]*t[10]),a=t[0]*r,n=t[4]*r,s=t[8]*i,o=t[1]*r,l=t[5]*r,u=t[9]*i,h=t[2]*r,c=t[6]*r,d=t[10]*i;e[0]=a,e[1]=n,e[2]=s,e[4]=o,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-o*f-h*m,e[13]=-n*p-l*f-c*m,e[14]=-s*p-u*f-d*m,e[3]=0,e[7]=0,e[11]=0,e[15]=1,e}function sM(e,t){return 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],e}function oM(e,t){let r=1/(t[0]*t[5]-t[1]*t[4]);return e[0]=t[5]*r,e[1]=-t[1]*r,e[2]=0,e[3]=0,e[4]=-t[4]*r,e[5]=t[0]*r,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],e}const lM=Pi();function Hd(e,t,r){let i=Pi();if(!e){let{vecSouth:a,vecEast:n}=Xd(t),s=p1();s[0]=n[0],s[1]=n[1],s[2]=a[0],s[3]=a[1],pC(s,s),i[0]=s[0],i[1]=s[1],i[4]=s[2],i[5]=s[3]}return Et(i,i,[1/r,1/r,1]),i}function uM(e,t,r,i){if(e){let a=Pi();if(!t){let{vecSouth:n,vecEast:s}=Xd(r);a[0]=s[0],a[1]=s[1],a[4]=n[0],a[5]=n[1]}return Et(a,a,[i,i,1]),a}return r.pixelsToClipSpaceMatrix}function Xd(e){let t=Math.cos(e.rollInRadians),r=Math.sin(e.rollInRadians),i=Math.cos(e.pitchInRadians),a=Math.cos(e.bearingInRadians),n=Math.sin(e.bearingInRadians),s=fh();s[0]=-a*i*r-n*t,s[1]=-n*i*r+a*t;let o=Vp(s);o<1e-9?Np(s):jp(s,s,1/o);let l=fh();l[0]=a*i*t-n*r,l[1]=n*i*t+a*r;let u=Vp(l);return u<1e-9?Np(l):jp(l,l,1/u),{vecEast:l,vecSouth:s}}function ea(e,t,r){return Ro(e.getElevation,t,r,e.heightOffset??0,e.heightAnchorGround??!0)}function Yd(e,t,r,i){let a;i==null?(a=[e,t,0,1],Kd(a,a,r)):(a=[e,t,i,1],Pt(a,a,r));let n=a[3];return{point:new M(a[0]/n,a[1]/n),signedDistanceFromCamera:n,isOccluded:!1}}function M1(e,t){return .5+e/t*.5}function hM(e,t){return e.x>=-t[0]&&e.x<=t[0]&&e.y>=-t[1]&&e.y<=t[1]}function cM(e,t,r,i,a,n,s,o,l,u,h,c,d){let p=r?e.textSizeData:e.iconSizeData,f=Nl(p,t.transform.zoom),m=[256/t.width*2+1,256/t.height*2+1],g=r?e.text.dynamicLayoutVertexArray:e.icon.dynamicLayoutVertexArray;g.clear();let _=e.lineVertexArray,y=r?e.text.placedSymbolArray:e.icon.placedSymbolArray,v=t.transform.width/t.transform.height,x=!1;for(let w=0;w<y.length;w++){let b=y.get(w);if(b.hidden||b.writingMode===2&&!x){Ba(b.numGlyphs,g);continue}x=!1;let S=new M(b.anchorX,b.anchorY),A={getElevation:d,pitchedLabelPlaneMatrix:i,lineVertexArray:_,pitchWithMap:n,projectionCache:{projections:{},offsets:{},cachedAnchorPoint:void 0,anyProjectionOccluded:!1},transform:t.transform,tileAnchorPoint:S,unwrappedTileID:l,width:u,height:h,translation:c},P=R1(b.anchorX,b.anchorY,A);if(!hM(P.point,m)){Ba(b.numGlyphs,g);continue}let I=P.signedDistanceFromCamera,R=M1(t.transform.cameraToCenterDistance,I),F=Pd(p,f,b),T=n?F*t.transform.getPitchedTextCorrection(b.anchorX,b.anchorY,l)/R:F*R,E=Zm({projectionContext:A,pitchedLabelPlaneMatrixInverse:a,symbol:b,fontSize:T,flip:!1,keepUpright:s,glyphOffsetArray:e.glyphOffsetArray,dynamicLayoutVertexArray:g,aspectRatio:v,rotateToLine:o});x=E.useVertical,(E.notEnoughRoom||x||E.needsFlipping&&Zm({projectionContext:A,pitchedLabelPlaneMatrixInverse:a,symbol:b,fontSize:T,flip:!0,keepUpright:s,glyphOffsetArray:e.glyphOffsetArray,dynamicLayoutVertexArray:g,aspectRatio:v,rotateToLine:o}).notEnoughRoom)&&Ba(b.numGlyphs,g)}r?e.text.dynamicLayoutVertexBuffer.updateData(g):e.icon.dynamicLayoutVertexBuffer.updateData(g)}function z1(e,t,r,i,a,n,s,o){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=dl(e*c,r,i,a,n.segment,u,h,o,s);if(!p)return null;let f=dl(e*d,r,i,a,n.segment,u,h,o,s);return!f||o.projectionCache.anyProjectionOccluded?null:{first:p,last:f}}function qm(e,t,r,i){return e===1&&Math.abs(r.y-t.y)>Math.abs(r.x-t.x)*i?{useVertical:!0}:(e===2?t.y<r.y:t.x>r.x)?{needsFlipping:!0}:null}function Zm(e){let{projectionContext:t,pitchedLabelPlaneMatrixInverse:r,symbol:i,fontSize:a,flip:n,keepUpright:s,glyphOffsetArray:o,dynamicLayoutVertexArray:l,aspectRatio:u,rotateToLine:h}=e,c=a/24,d=i.lineOffsetX*c,p=i.lineOffsetY*c,f;if(i.numGlyphs>1){let m=i.glyphStartIndex+i.numGlyphs,g=i.lineStartIndex,_=i.lineStartIndex+i.lineLength,y=z1(c,o,d,p,n,i,h,t);if(!y)return{notEnoughRoom:!0};let v=ho(y.first.point.x,y.first.point.y,t,r),x=ho(y.last.point.x,y.last.point.y,t,r);if(s&&!n){let w=qm(i.writingMode,v,x,u);if(w)return w}f=[y.first];for(let w=i.glyphStartIndex+1;w<m-1;w++){let b=dl(c*o.getoffsetX(w),d,p,n,i.segment,g,_,t,h);if(!b)return{notEnoughRoom:!0};f.push(b)}f.push(y.last)}else{if(s&&!n){let g=ta(t.tileAnchorPoint.x,t.tileAnchorPoint.y,t).point,_=i.lineStartIndex+i.segment+1,y=new M(t.lineVertexArray.getx(_),t.lineVertexArray.gety(_)),v=ta(y.x,y.y,t),x=v.signedDistanceFromCamera>0?v.point:F1(t.tileAnchorPoint,y,g,1,t),w=ho(g.x,g.y,t,r),b=ho(x.x,x.y,t,r),S=qm(i.writingMode,w,b,u);if(S)return S}let m=dl(c*o.getoffsetX(i.glyphStartIndex),d,p,n,i.segment,i.lineStartIndex,i.lineStartIndex+i.lineLength,t,h);if(!m||t.projectionCache.anyProjectionOccluded)return{notEnoughRoom:!0};f=[m]}for(let m of f)ol(l,m.point,m.angle);return{}}function F1(e,t,r,i,a){let n=e.add(e.sub(t)._unit()),s=ta(n.x,n.y,a).point,o=r.sub(s);return r.add(o._mult(i/o.mag()))}function Rc(e,t,r){let i=t.projectionCache;if(i.projections[e])return i.projections[e];let a=new M(t.lineVertexArray.getx(e),t.lineVertexArray.gety(e)),n=ta(a.x,a.y,t);if(n.signedDistanceFromCamera>0)return i.projections[e]=n.point,i.anyProjectionOccluded||(i.anyProjectionOccluded=n.isOccluded),n.point;let s=e-r.direction,o=r.distanceFromAnchor===0?t.tileAnchorPoint:new M(t.lineVertexArray.getx(s),t.lineVertexArray.gety(s)),l=r.absOffsetX-r.distanceFromAnchor+1;return F1(o,a,r.previousVertex,l,t)}function ta(e,t,r){let i=e+r.translation[0],a=t+r.translation[1],n;return r.pitchWithMap?(n=Yd(i,a,r.pitchedLabelPlaneMatrix,ea(r,i,a)),n.isOccluded=!1):(n=r.transform.projectTileCoordinates(i,a,r.unwrappedTileID,ea(r,i,a)),n.point.x=(n.point.x*.5+.5)*r.width,n.point.y=(-n.point.y*.5+.5)*r.height),n}function ho(e,t,r,i){if(r.pitchWithMap){let a=[e,t,0,1];Pt(a,a,i);let n=a[0]/a[3],s=a[1]/a[3];return r.transform.projectTileCoordinates(n,s,r.unwrappedTileID,ea(r,n,s)).point}return{x:e/r.width*2-1,y:1-t/r.height*2}}function R1(e,t,r){return r.transform.projectTileCoordinates(e,t,r.unwrappedTileID,ea(r,e,t))}function kc(e,t,r){return e._unit()._perp()._mult(t*r)}function dM(e,t,r,i,a,n,s,o,l){if(o.projectionCache.offsets[e])return o.projectionCache.offsets[e];let u=r.add(t);if(e+l.direction<i||e+l.direction>=a)return o.projectionCache.offsets[e]=u,u;let h=Rc(e+l.direction,o,l),c=kc(h.sub(r),s,l.direction),d=r.add(c),p=h.add(c);return o.projectionCache.offsets[e]=_v(n,u,d,p)||u,o.projectionCache.offsets[e]}function dl(e,t,r,i,a,n,s,o,l){let u=i?e-t:e+t,h=u>0?1:-1,c=0;i&&(h*=-1,c=Math.PI),h<0&&(c+=Math.PI);let d=h>0?n+a:n+a+1,p;o.projectionCache.cachedAnchorPoint?p=o.projectionCache.cachedAnchorPoint:(p=ta(o.tileAnchorPoint.x,o.tileAnchorPoint.y,o).point,o.projectionCache.cachedAnchorPoint=p);let f=p,m=p,g,_,y=0,v=0,x=Math.abs(u),w=[],b;for(;y+v<=x;){if(d+=h,d<n||d>=s)return null;y+=v,m=f,_=g;let I={absOffsetX:x,direction:h,distanceFromAnchor:y,previousVertex:m};if(f=Rc(d,o,I),r===0)w.push(m),b=f.sub(m);else{let R,F=f.sub(m);R=F.mag()===0?kc(Rc(d+h,o,I).sub(f),r,h):kc(F,r,h),_||(_=m.add(R)),g=dM(d,R,f,n,s,_,r,o,I),w.push(_),b=g.sub(_)}v=b.mag()}let S=(x-y)/v,A=b._mult(S)._add(_||m),P=c+Math.atan2(f.y-m.y,f.x-m.x);return w.push(A),{point:A,angle:l?P:0,path:w}}const pM=new Float32Array([-1/0,-1/0,0,-1/0,-1/0,0,-1/0,-1/0,0,-1/0,-1/0,0]);function Ba(e,t){for(let r=0;r<e;r++){let i=t.length;t.resize(i+4),t.float32.set(pM,i*3)}}function Kd(e,t,r){let i=t[0],a=t[1];return e[0]=r[0]*i+r[4]*a+r[12],e[1]=r[1]*i+r[5]*a+r[13],e[3]=r[3]*i+r[7]*a+r[15],e}function fM(e,t){let r=lM;return oM(r,t.pitchedLabelPlaneMatrix),e.map(i=>{let a=Yd(i.x,i.y,r,ea(t,i.x,i.y)),n=t.transform.projectTileCoordinates(a.point.x,a.point.y,t.unwrappedTileID,ea(t,a.point.x,a.point.y));return n.point.x=(n.point.x*.5+.5)*t.width,n.point.y=(-n.point.y*.5+.5)*t.height,n})}function mM(e){let t=0,r=0,i=0,a=0;for(let n=0;n<e.length;n++)e[n].isOccluded?(i=n+1,a=0):(a++,a>r&&(r=a,t=i));return e.slice(t,t+r)}var gM=class{constructor(e,t=new Gm(e.width+200,e.height+200,25),r=new Gm(e.width+200,e.height+200,25)){this.transform=e,this.grid=t,this.ignoredGrid=r,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,r,i,a,n,s,o,l,u,h,c,d=0,p=!0){let f=e.anchorPointX+o[0],m=e.anchorPointY+o[1],g=this.projectAndGetPerspectiveRatio(f,m,a,Ro(u,f,m,d,p),c),_=r*g.perspectiveRatio,y;if(!n&&!s){let P=g.x+(h?h.x*_:0),I=g.y+(h?h.y*_:0);y={allPointsOccluded:!1,box:[P+e.x1*_,I+e.y1*_,P+e.x2*_,I+e.y2*_]}}else y=this._projectCollisionBox(e,_,i,a,n,s,o,g,u,h,c,d,p);let[v,x,w,b]=y.box,S=n?y.allPointsOccluded:g.isOccluded,A=S;return A||(A=g.perspectiveRatio<this.perspectiveRatioCutoff),A||(A=!this.isInsideGrid(v,x,w,b)),A||t!=="always"&&this.grid.hitTest(v,x,w,b,t,l)?{box:[v,x,w,b],placeable:!1,offscreen:!1,occluded:S}:{box:[v,x,w,b],placeable:!0,offscreen:this.isOffscreen(v,x,w,b),occluded:S}}placeCollisionCircles(e,t,r,i,a,n,s,o,l,u,h,c,d,p){let f=[],m=new M(t.anchorX,t.anchorY),g=this.getPerspectiveRatio(m.x,m.y,n,p==null?void 0:p(m.x,m.y)),_=(l?a*this.transform.getPitchedTextCorrection(t.anchorX,t.anchorY,n)/g:a*g)/24,y={projections:{},offsets:{},cachedAnchorPoint:void 0,anyProjectionOccluded:!1},v=t.lineOffsetX*_,x=t.lineOffsetY*_,w={getElevation:p,pitchedLabelPlaneMatrix:s,lineVertexArray:r,pitchWithMap:l,projectionCache:y,transform:this.transform,tileAnchorPoint:m,unwrappedTileID:n,width:this.transform.width,height:this.transform.height,translation:d},b=z1(_,i,v,x,!1,t,!1,w),S=!1,A=!1,P=!0;if(b){let I=h*.5*g+c,R=new M(-100,-100),F=new M(this.screenRightBoundary,this.screenBottomBoundary),T=new aM,E=b.first,D=b.last,C=[];for(let $=E.path.length-1;$>=1;$--)C.push(E.path[$]);for(let $=1;$<D.path.length;$++)C.push(D.path[$]);let k=I*2.5;if(l){let $=this.projectPathToScreenSpace(C,w);C=$.some(W=>W.signedDistanceFromCamera<=0)?[]:$.map(W=>W.point)}let B=[];if(C.length>0){let $=C[0].clone(),W=C[0].clone();for(let ie=1;ie<C.length;ie++)$.x=Math.min($.x,C[ie].x),$.y=Math.min($.y,C[ie].y),W.x=Math.max(W.x,C[ie].x),W.y=Math.max(W.y,C[ie].y);B=$.x>=R.x&&W.x<=F.x&&$.y>=R.y&&W.y<=F.y?[C]:W.x<R.x||$.x>F.x||W.y<R.y||$.y>F.y?[]:z0([C],R.x,R.y,F.x,F.y)}for(let $ of B){T.reset($,I*.25);let W=0;W=T.length<=.5*I?1:Math.ceil(T.paddedLength/k)+1;for(let ie=0;ie<W;ie++){let ye=ie/Math.max(W-1,1),ce=T.lerp(ye),ke=ce.x+100,ve=ce.y+100;f.push(ke,ve,I,0);let Ue=ke-I,Ee=ve-I,pt=ke+I,yt=ve+I;if(P&&(P=this.isOffscreen(Ue,Ee,pt,yt)),A||(A=this.isInsideGrid(Ue,Ee,pt,yt)),e!=="always"&&this.grid.hitTestCircle(ke,ve,I,e,u)&&(S=!0,!o))return{circles:[],offscreen:!1,collisionDetected:S}}}}return{circles:!o&&S||!A||g<this.perspectiveRatioCutoff?[]:f,offscreen:P,collisionDetected:S}}projectPathToScreenSpace(e,t){return mM(fM(e,t))}queryRenderedSymbols(e){if(e.length===0||this.grid.keysLength()===0&&this.ignoredGrid.keysLength()===0)return{};let t=[],r=new Er;for(let h of e){let c=new M(h.x+100,h.y+100);r.extend(c),t.push(c)}let{minX:i,minY:a,maxX:n,maxY:s}=r,o=this.grid.query(i,a,n,s).concat(this.ignoredGrid.query(i,a,n,s)),l={},u={};for(let h of o){let c=h.key;if(l[c.bucketInstanceId]===void 0&&(l[c.bucketInstanceId]={}),l[c.bucketInstanceId][c.featureIndex])continue;let d=[new M(h.x1,h.y1),new M(h.x2,h.y1),new M(h.x2,h.y2),new M(h.x1,h.y2)];Oy(t,d)&&(l[c.bucketInstanceId][c.featureIndex]=!0,u[c.bucketInstanceId]===void 0&&(u[c.bucketInstanceId]=[]),u[c.bucketInstanceId].push(c.featureIndex))}return u}insertCollisionBox(e,t,r,i,a,n){let s=r?this.ignoredGrid:this.grid,o={bucketInstanceId:i,featureIndex:a,collisionGroupID:n,overlapMode:t};s.insert(o,e[0],e[1],e[2],e[3])}insertCollisionCircles(e,t,r,i,a,n){let s=r?this.ignoredGrid:this.grid,o={bucketInstanceId:i,featureIndex:a,collisionGroupID:n,overlapMode:t};for(let l=0;l<e.length;l+=4)s.insertCircle(o,e[l],e[l+1],e[l+2])}projectAndGetPerspectiveRatio(e,t,r,i,a){if(a){let n;i==null?(n=[e,t,0,1],Kd(n,n,a)):(n=[e,t,i,1],Pt(n,n,a));let s=n[3];return{x:(n[0]/s+1)/2*this.transform.width+100,y:(-n[1]/s+1)/2*this.transform.height+100,perspectiveRatio:.5+.5*(this.transform.cameraToCenterDistance/s),isOccluded:!1,signedDistanceFromCamera:s}}{let n=this.transform.projectTileCoordinates(e,t,r,i);return{x:(n.point.x+1)/2*this.transform.width+100,y:(-n.point.y+1)/2*this.transform.height+100,perspectiveRatio:.5+.5*(this.transform.cameraToCenterDistance/n.signedDistanceFromCamera),isOccluded:n.isOccluded,signedDistanceFromCamera:n.signedDistanceFromCamera}}}getPerspectiveRatio(e,t,r,i){let a=this.transform.projectTileCoordinates(e,t,r,i);return .5+.5*(this.transform.cameraToCenterDistance/a.signedDistanceFromCamera)}isOffscreen(e,t,r,i){return r<100||e>=this.screenRightBoundary||i<100||t>this.screenBottomBoundary}isInsideGrid(e,t,r,i){return r>=0&&e<this.gridRightBoundary&&i>=0&&t<this.gridBottomBoundary}getViewportMatrix(){let e=Pr([]);return ot(e,e,[-100,-100,0]),e}_projectCollisionBox(e,t,r,i,a,n,s,o,l,u,h,c=0,d=!0){let p=1,f=0,m=0,g=1,_=e.anchorPointX+s[0],y=e.anchorPointY+s[1];if(n&&!a){let D=this.projectAndGetPerspectiveRatio(_+1,y,i,Ro(l,_+1,y,c,d),h),C=D.x-o.x,k=D.y-o.y,B=Math.atan(k/C)+(C<0?Math.PI:0),$=Math.sin(B),W=Math.cos(B);p=W,f=$,m=-$,g=W}else if(!n&&a){let D=Xd(this.transform);p=D.vecEast[0],f=D.vecEast[1],m=D.vecSouth[0],g=D.vecSouth[1]}let v=o.x,x=o.y,w=t;if(a&&(v=_,x=y,w=2**-(this.transform.zoom-r.overscaledZ),w*=this.transform.getPitchedTextCorrection(_,y,i),!u)){let D=o.signedDistanceFromCamera/this.transform.cameraToCenterDistance,C=se(.5+.5*D,0,4);w*=C}u&&(v+=p*u.x*w+m*u.y*w,x+=f*u.x*w+g*u.y*w);let b=e.x1*w,S=e.x2*w,A=(b+S)/2,P=e.y1*w,I=e.y2*w,R=(P+I)/2,F=[{offsetX:b,offsetY:P},{offsetX:A,offsetY:P},{offsetX:S,offsetY:P},{offsetX:S,offsetY:R},{offsetX:S,offsetY:I},{offsetX:A,offsetY:I},{offsetX:b,offsetY:I},{offsetX:b,offsetY:R}],T=[];for(let{offsetX:D,offsetY:C}of F)T.push(new M(v+p*D+m*C,x+f*D+g*C));let E=!1;if(a){let D=T.map(C=>this.projectAndGetPerspectiveRatio(C.x,C.y,i,Ro(l,C.x,C.y,c,d),h));E=D.some(C=>!C.isOccluded),T=D.map(C=>new M(C.x,C.y))}else E=!0;return{box:cv(T),allPointsOccluded:!E}}},Wm=class{constructor(e,t,r,i){this.opacity=e?Math.max(0,Math.min(1,e.opacity+(e.placed?t:-t))):i&&r?1:0,this.placed=r}isHidden(){return this.opacity===0&&!this.placed}},xn=class{constructor(e,t,r,i,a){this.text=new Wm(e?e.text:null,t,r,a),this.icon=new Wm(e?e.icon:null,t,i,a)}isHidden(){return this.text.isHidden()&&this.icon.isHidden()}},Hm=class{constructor(e,t,r){this.text=e,this.icon=t,this.skipFade=r}},_M=class{constructor(e,t,r,i,a){this.bucketInstanceId=e,this.featureIndex=t,this.sourceLayerIndex=r,this.bucketIndex=i,this.tileID=a}},yM=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:r=>r.collisionGroupID===t}}return this.collisionGroups[e]}};function Xm(e,t,r,i,a){let{horizontalAlign:n,verticalAlign:s}=Vl(e),o=-(n-.5)*t,l=-(s-.5)*r;return new M(o+i[0]*a,l+i[1]*a)}var xM=class{constructor(e,t,r,i,a){this.transform=e.clone(),this.terrain=t,this.collisionIndex=new gM(this.transform),this.placements={},this.opacities={},this.variableOffsets={},this.stale=!1,this.commitTime=0,this.fadeDuration=r,this.retainedQueryData={},this.collisionGroups=new yM(i),this.collisionCircleArrays={},this.collisionBoxArrays=new Map,this.prevPlacement=a,a&&(a.prevPlacement=void 0),this.placedOrientations={}}_getTerrainElevationFunc(e){let t=this.terrain;if(t)return(r,i)=>t.getElevation(e,r,i)}getBucketParts(e,t,r,i){let a=r.getBucket(t),n=r.latestFeatureIndex;if(!a||!n||t.id!==a.layerIds[0])return;let s=r.collisionBoxArray,o=a.layers[0].layout,l=a.layers[0].paint,u=2**(this.transform.zoom-r.tileID.overscaledZ),h=r.tileSize/L,c=r.tileID.toUnwrapped(),d=o.get("text-rotation-alignment")==="map",p=nr(r,1,this.transform.zoom),f=Ti(this.collisionIndex.transform,r,l.get("text-translate"),l.get("text-translate-anchor")),m=Ti(this.collisionIndex.transform,r,l.get("icon-translate"),l.get("icon-translate-anchor")),g=Hd(d,this.transform,p);this.retainedQueryData[a.bucketInstanceId]=new _M(a.bucketInstanceId,n,a.sourceLayerIndex,a.index,r.tileID);let _={bucket:a,layout:o,translationText:f,translationIcon:m,unwrappedTileID:c,pitchedLabelPlaneMatrix:g,scale:u,textPixelRatio:h,holdingForFade:r.holdingForSymbolFade(),collisionBoxArray:s,partiallyEvaluatedTextSize:Nl(a.textSizeData,this.transform.zoom),collisionGroup:this.collisionGroups.get(a.sourceID)};if(i)for(let y of a.sortKeyRanges){let{sortKey:v,symbolInstanceStart:x,symbolInstanceEnd:w}=y;e.push({sortKey:v,symbolInstanceStart:x,symbolInstanceEnd:w,parameters:_})}else e.push({symbolInstanceStart:0,symbolInstanceEnd:a.symbolInstances.length,parameters:_})}attemptAnchorPlacement(e,t,r,i,a,n,s,o,l,u,h,c,d,p,f,m,g,_,y,v,x,w){var I,R,F;let b=xc[e.textAnchor],S=[e.textOffset0,e.textOffset1],A=Xm(b,r,i,S,a),P=this.collisionIndex.placeCollisionBox(t,c,o,l,u,s,n,m,h.predicate,y,A,v,x,w);if((!_||this.collisionIndex.placeCollisionBox(_,c,o,l,u,s,n,g,h.predicate,y,A,v,x,w).placeable)&&P.placeable){let T;if((I=this.prevPlacement)!=null&&I.variableOffsets[d.crossTileID]&&((F=(R=this.prevPlacement)==null?void 0:R.placements[d.crossTileID])!=null&&F.text)&&(T=this.prevPlacement.variableOffsets[d.crossTileID].anchor),d.crossTileID===0)throw Error("symbolInstance.crossTileID can't be 0");return this.variableOffsets[d.crossTileID]={textOffset:S,width:r,height:i,anchor:b,textBoxScale:a,prevAnchor:T},this.markUsedJustification(p,b,d,f),p.allowVerticalPlacement&&(this.markUsedOrientation(p,f,d),this.placedOrientations[d.crossTileID]=f),{shift:A,placedGlyphBoxes:P}}}placeLayerBucketPart(e,t,r){let{bucket:i,layout:a,translationText:n,translationIcon:s,unwrappedTileID:o,pitchedLabelPlaneMatrix:l,textPixelRatio:u,holdingForFade:h,collisionBoxArray:c,partiallyEvaluatedTextSize:d,collisionGroup:p}=e.parameters,f=a.get("text-optional"),m=a.get("icon-optional"),g=sl(a,"text-overlap","text-allow-overlap"),_=g==="always",y=sl(a,"icon-overlap","icon-allow-overlap"),v=y==="always",x=a.get("text-rotation-alignment")==="map",w=a.get("text-pitch-alignment")==="map",b=a.get("icon-text-fit")!=="none",S=a.get("symbol-z-order")==="viewport-y",A=a.get("symbol-height-anchor")==="ground",P=_&&(v||!i.hasIconData()||m),I=v&&(_||!i.hasTextData()||f);!i.collisionArrays&&c&&i.deserializeCollisionBoxes(c);let R=this.retainedQueryData[i.bucketInstanceId].tileID,F=this._getTerrainElevationFunc(R),T=this.transform.getFastPathSimpleProjectionMatrix(R),E=(D,C,k)=>{var ge,re;if(t[D.crossTileID])return;if(h){this.placements[D.crossTileID]=new Hm(!1,!1,!1);return}let B=D.heightOffset,$=!1,W=!1,ie=!0,ye=null,ce={box:null,placeable:!1,offscreen:null,occluded:!1},ke={placeable:!1},ve=null,Ue=null,Ee=null,pt=0,yt=0,Nt=0;C.textFeatureIndex?pt=C.textFeatureIndex:D.useRuntimeCollisionCircles&&(pt=D.featureIndex),C.verticalTextFeatureIndex&&(yt=C.verticalTextFeatureIndex);let Ut=C.textBox;if(Ut){let j=q=>{let we=1;if(i.allowVerticalPlacement&&!q&&this.prevPlacement){let Te=this.prevPlacement.placedOrientations[D.crossTileID];Te&&(this.placedOrientations[D.crossTileID]=Te,we=Te,this.markUsedOrientation(i,we,D))}return we},xe=(q,we)=>{if(i.allowVerticalPlacement&&D.numVerticalGlyphVertices>0&&C.verticalTextBox){for(let Te of i.writingModes)if(Te===2?(ce=we(),ke=ce):ce=q(),ce==null?void 0:ce.placeable)break}else ce=q()},Q=D.textAnchorOffsetStartIndex,ae=D.textAnchorOffsetEndIndex;if(ae===Q){let q=(we,Te)=>{let ne=this.collisionIndex.placeCollisionBox(we,g,u,R,o,w,x,n,p.predicate,F,void 0,T,B,A);return ne!=null&&ne.placeable&&(this.markUsedOrientation(i,Te,D),this.placedOrientations[D.crossTileID]=Te),ne};xe(()=>q(Ut,1),()=>{let we=C.verticalTextBox;return i.allowVerticalPlacement&&D.numVerticalGlyphVertices>0&&we?q(we,2):{box:null,offscreen:null}}),j(ce==null?void 0:ce.placeable)}else{let q=xc[(re=(ge=this.prevPlacement)==null?void 0:ge.variableOffsets[D.crossTileID])==null?void 0:re.anchor],we=(ne,Qe,Ci)=>{let Kr=ne.x2-ne.x1,Mr=ne.y2-ne.y1,zr=D.textBoxScale,Oe=b&&y==="never"?Qe:null,Le=null,or=g==="never"?1:2,vr="never";q&&or++;for(let la=0;la<or;la++){for(let st=Q;st<ae;st++){let ht=i.textAnchorOffsets.get(st);if(q&&ht.textAnchor!==q)continue;let ua=this.attemptAnchorPlacement(ht,ne,Kr,Mr,zr,x,w,u,R,o,p,vr,D,i,Ci,n,s,Oe,F,T,B,A);if(ua&&(Le=ua.placedGlyphBoxes,Le==null?void 0:Le.placeable))return $=!0,ye=ua.shift,Le}q?q=null:vr=g}return r&&!Le&&(Le={box:this.collisionIndex.placeCollisionBox(Ut,"always",u,R,o,w,x,n,p.predicate,F,void 0,T,B,A).box,offscreen:!1,placeable:!1,occluded:!1}),Le};xe(()=>we(Ut,C.iconBox,1),()=>{let ne=C.verticalTextBox,Qe=ce==null?void 0:ce.placeable;return i.allowVerticalPlacement&&!Qe&&D.numVerticalGlyphVertices>0&&ne?we(ne,C.verticalIconBox,2):{box:null,occluded:!0,offscreen:null}}),ce&&($=ce.placeable,ie=ce.offscreen);let Te=j(ce==null?void 0:ce.placeable);if(!$&&this.prevPlacement){let ne=this.prevPlacement.variableOffsets[D.crossTileID];ne&&(this.variableOffsets[D.crossTileID]=ne,this.markUsedJustification(i,ne.anchor,D,Te))}}}if(ve=ce,$=ve==null?void 0:ve.placeable,ie=ve==null?void 0:ve.offscreen,D.useRuntimeCollisionCircles&&D.centerJustifiedTextSymbolIndex>=0){let j=i.text.placedSymbolArray.get(D.centerJustifiedTextSymbolIndex),xe=Pd(i.textSizeData,d,j),Q=a.get("text-padding"),ae=D.collisionCircleDiameter;Ue=this.collisionIndex.placeCollisionCircles(g,j,i.lineVertexArray,i.glyphOffsetArray,xe,o,l,r,w,p.predicate,ae,Q,n,F),Ue.circles.length&&Ue.collisionDetected&&!r&&_e("Collisions detected, but collision boxes are not shown"),$=_||Ue.circles.length>0&&!Ue.collisionDetected,ie&&(ie=Ue.offscreen)}if(C.iconFeatureIndex&&(Nt=C.iconFeatureIndex),C.iconBox){let j=xe=>this.collisionIndex.placeCollisionBox(xe,y,u,R,o,w,x,s,p.predicate,F,b&&ye?ye:void 0,T,B,A);ke&&ke.placeable&&C.verticalIconBox?(Ee=j(C.verticalIconBox),W=Ee.placeable):(Ee=j(C.iconBox),W=Ee.placeable),ie&&(ie=Ee.offscreen)}let Tt=f||D.numHorizontalGlyphVertices===0&&D.numVerticalGlyphVertices===0,nt=m||D.numIconVertices===0;!Tt&&!nt?W=$=W&&$:nt?Tt||W&&(W=$):$=W&&$;let Yt=$&&ve.placeable,xr=W&&Ee.placeable;if(Yt&&(ke&&ke.placeable&&yt?this.collisionIndex.insertCollisionBox(ve.box,g,a.get("text-ignore-placement"),i.bucketInstanceId,yt,p.ID):this.collisionIndex.insertCollisionBox(ve.box,g,a.get("text-ignore-placement"),i.bucketInstanceId,pt,p.ID)),xr&&this.collisionIndex.insertCollisionBox(Ee.box,y,a.get("icon-ignore-placement"),i.bucketInstanceId,Nt,p.ID),Ue&&$&&this.collisionIndex.insertCollisionCircles(Ue.circles,g,a.get("text-ignore-placement"),i.bucketInstanceId,pt,p.ID),r&&this.storeCollisionData(i.bucketInstanceId,k,C,ve,Ee,Ue),D.crossTileID===0)throw Error("symbolInstance.crossTileID can't be 0");if(i.bucketInstanceId===0)throw Error("bucket.bucketInstanceId can't be 0");let sr=($||P)&&!(ve!=null&&ve.occluded),Z=(W||I)&&!(Ee!=null&&Ee.occluded);this.placements[D.crossTileID]=new Hm(sr,Z,ie||i.justReloaded),t[D.crossTileID]=!0};if(S){if(e.symbolInstanceStart!==0)throw Error("bucket.bucketInstanceId should be 0");let D=i.getSortedSymbolIndexes(-this.transform.bearingInRadians);for(let C=D.length-1;C>=0;--C){let k=D[C];E(i.symbolInstances.get(k),i.collisionArrays[k],k)}}else for(let D=e.symbolInstanceStart;D<e.symbolInstanceEnd;D++)E(i.symbolInstances.get(D),i.collisionArrays[D],D);i.justReloaded=!1}storeCollisionData(e,t,r,i,a,n){if(r.textBox||r.iconBox){let s;this.collisionBoxArrays.has(e)?s=this.collisionBoxArrays.get(e):(s=new Map,this.collisionBoxArrays.set(e,s));let o;s.has(t)?o=s.get(t):(o={text:null,icon:null},s.set(t,o)),r.textBox&&(o.text=i.box),r.iconBox&&(o.icon=a.box)}if(n){let s=this.collisionCircleArrays[e];s===void 0&&(s=this.collisionCircleArrays[e]=[]);for(let o=0;o<n.circles.length;o+=4)s.push(n.circles[o+0]-100),s.push(n.circles[o+1]-100),s.push(n.circles[o+2]),s.push(+!!n.collisionDetected)}}markUsedJustification(e,t,r,i){let a={left:r.leftJustifiedTextSymbolIndex,center:r.centerJustifiedTextSymbolIndex,right:r.rightJustifiedTextSymbolIndex},n;n=i===2?r.verticalPlacedTextSymbolIndex:a[vc(t)];let s=[r.leftJustifiedTextSymbolIndex,r.centerJustifiedTextSymbolIndex,r.rightJustifiedTextSymbolIndex,r.verticalPlacedTextSymbolIndex];for(let o of s)o>=0&&(n>=0&&o!==n?e.text.placedSymbolArray.get(o).crossTileID=0:e.text.placedSymbolArray.get(o).crossTileID=r.crossTileID)}markUsedOrientation(e,t,r){let i=t===1||t===3?t:0,a=t===2?t:0,n=[r.leftJustifiedTextSymbolIndex,r.centerJustifiedTextSymbolIndex,r.rightJustifiedTextSymbolIndex];for(let s of n)e.text.placedSymbolArray.get(s).placedOrientation=i;r.verticalPlacedTextSymbolIndex&&(e.text.placedSymbolArray.get(r.verticalPlacedTextSymbolIndex).placedOrientation=a)}commit(e){this.commitTime=e,this.zoomAtLastRecencyCheck=this.transform.zoom;let t=this.prevPlacement,r=!1;this.prevZoomAdjustment=t?t.zoomAdjustment(this.transform.zoom):0;let i=t?t.symbolFadeChange(e):1,a=t?t.opacities:{},n=t?t.variableOffsets:{},s=t?t.placedOrientations:{};for(let o in this.placements){let l=this.placements[o],u=a[o];u?(this.opacities[o]=new xn(u,i,l.text,l.icon),r||(r=l.text!==u.text.placed),r||(r=l.icon!==u.icon.placed)):(this.opacities[o]=new xn(null,i,l.text,l.icon,l.skipFade),r||(r=l.text||l.icon))}for(let o in a){let l=a[o];if(!this.opacities[o]){let u=new xn(l,i,!1,!1);u.isHidden()||(this.opacities[o]=u,r||(r=l.text.placed),r||(r=l.icon.placed))}}for(let o in n)!this.variableOffsets[o]&&this.opacities[o]&&!this.opacities[o].isHidden()&&(this.variableOffsets[o]=n[o]);for(let o in s)!this.placedOrientations[o]&&this.opacities[o]&&!this.opacities[o].isHidden()&&(this.placedOrientations[o]=s[o]);if(t&&t.lastPlacementChangeTime===void 0)throw Error("Last placement time for previous placement is not defined");r?this.lastPlacementChangeTime=e:typeof this.lastPlacementChangeTime!="number"&&(this.lastPlacementChangeTime=t?t.lastPlacementChangeTime:e)}updateLayerOpacities(e,t){let r={};for(let i of t){let a=i.getBucket(e);a&&i.latestFeatureIndex&&e.id===a.layerIds[0]&&this.updateBucketOpacities(a,i.tileID,r,i.collisionBoxArray)}}updateBucketOpacities(e,t,r,i){e.hasTextData()&&(e.text.opacityVertexArray.clear(),e.text.hasVisibleVertices=!1),e.hasIconData()&&(e.icon.opacityVertexArray.clear(),e.icon.hasVisibleVertices=!1),e.hasIconCollisionBoxData()&&e.iconCollisionBox.collisionVertexArray.clear(),e.hasTextCollisionBoxData()&&e.textCollisionBox.collisionVertexArray.clear();let a=e.layers[0],n=a.layout,s=new xn(null,0,!1,!1,!0),o=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=n.get("text-rotation-alignment")==="map",c=n.get("text-pitch-alignment")==="map",d=n.get("icon-text-fit")!=="none",p=new xn(null,0,o&&(l||!e.hasIconData()||n.get("icon-optional")),l&&(o||!e.hasTextData()||n.get("text-optional")),!0);!e.collisionArrays&&i&&(e.hasIconCollisionBoxData()||e.hasTextCollisionBoxData())&&e.deserializeCollisionBoxes(i);let f=(g,_,y)=>{for(let v=0;v<_/4;v++)g.opacityVertexArray.emplaceBack(y);g.hasVisibleVertices||(g.hasVisibleVertices=y!==vn)},m=this.collisionBoxArrays.get(e.bucketInstanceId);for(let g=0;g<e.symbolInstances.length;g++){let _=e.symbolInstances.get(g),{numHorizontalGlyphVertices:y,numVerticalGlyphVertices:v,crossTileID:x}=_,w=r[x],b=this.opacities[x];w?b=s:b||(b=p,this.opacities[x]=b),r[x]=!0;let S=y>0||v>0,A=_.numIconVertices>0,P=this.placedOrientations[_.crossTileID],I=P===2,R=P===1||P===3;if(S){let T=Km(b.text),E=I?vn:T;f(e.text,y,E);let D=R?vn:T;f(e.text,v,D);let C=b.text.isHidden(),k=[_.rightJustifiedTextSymbolIndex,_.centerJustifiedTextSymbolIndex,_.leftJustifiedTextSymbolIndex];for(let W of k)W>=0&&(e.text.placedSymbolArray.get(W).hidden=C||I?1:0);_.verticalPlacedTextSymbolIndex>=0&&(e.text.placedSymbolArray.get(_.verticalPlacedTextSymbolIndex).hidden=C||R?1:0);let B=this.variableOffsets[_.crossTileID];B&&this.markUsedJustification(e,B.anchor,_,P);let $=this.placedOrientations[_.crossTileID];$&&(this.markUsedJustification(e,"left",_,$),this.markUsedOrientation(e,$,_))}if(A){let T=Km(b.icon),E=!(d&&_.verticalPlacedIconSymbolIndex&&I);if(_.placedIconSymbolIndex>=0){let D=E?T:vn;f(e.icon,_.numIconVertices,D),e.icon.placedSymbolArray.get(_.placedIconSymbolIndex).hidden=b.icon.isHidden()}if(_.verticalPlacedIconSymbolIndex>=0){let D=E?vn:T;f(e.icon,_.numVerticalIconVertices,D),e.icon.placedSymbolArray.get(_.verticalPlacedIconSymbolIndex).hidden=b.icon.isHidden()}}let F=m!=null&&m.has(g)?m.get(g):{text:null,icon:null};if(e.hasIconCollisionBoxData()||e.hasTextCollisionBoxData()){let T=e.collisionArrays[g];if(T){let E=new M(0,0);if(T.textBox||T.verticalTextBox){let D=!0;if(u){let C=this.variableOffsets[x];C?(E=Xm(C.anchor,C.width,C.height,C.textOffset,C.textBoxScale),h&&E._rotate(c?-this.transform.bearingInRadians:this.transform.bearingInRadians)):D=!1}if(T.textBox||T.verticalTextBox){let C;T.textBox&&(C=I),T.verticalTextBox&&(C=R),Ym(e.textCollisionBox.collisionVertexArray,b.text.placed,!D||C,F.text,E.x,E.y)}}if(T.iconBox||T.verticalIconBox){let D=!(R||!T.verticalIconBox),C;T.iconBox&&(C=D),T.verticalIconBox&&(C=!D),Ym(e.iconCollisionBox.collisionVertexArray,b.icon.placed,C,F.icon,d?E.x:0,d?E.y:0)}}}}if(e.sortFeatures(-this.transform.bearingInRadians),this.retainedQueryData[e.bucketInstanceId]&&(this.retainedQueryData[e.bucketInstanceId].featureSortOrder=e.featureSortOrder),e.hasTextData()&&e.text.opacityVertexBuffer&&e.text.opacityVertexBuffer.updateData(e.text.opacityVertexArray),e.hasIconData()&&e.icon.opacityVertexBuffer&&e.icon.opacityVertexBuffer.updateData(e.icon.opacityVertexArray),e.hasIconCollisionBoxData()&&e.iconCollisionBox.collisionVertexBuffer&&e.iconCollisionBox.collisionVertexBuffer.updateData(e.iconCollisionBox.collisionVertexArray),e.hasTextCollisionBoxData()&&e.textCollisionBox.collisionVertexBuffer&&e.textCollisionBox.collisionVertexBuffer.updateData(e.textCollisionBox.collisionVertexArray),e.text.opacityVertexArray.length!==e.text.layoutVertexArray.length/4)throw Error(`bucket.text.opacityVertexArray.length (= ${e.text.opacityVertexArray.length}) !== bucket.text.layoutVertexArray.length (= ${e.text.layoutVertexArray.length}) / 4`);if(e.icon.opacityVertexArray.length!==e.icon.layoutVertexArray.length/4)throw Error(`bucket.icon.opacityVertexArray.length (= ${e.icon.opacityVertexArray.length}) !== bucket.icon.layoutVertexArray.length (= ${e.icon.layoutVertexArray.length}) / 4`);e.bucketInstanceId in this.collisionCircleArrays&&(e.collisionCircleArray=this.collisionCircleArrays[e.bucketInstanceId],delete this.collisionCircleArrays[e.bucketInstanceId])}symbolFadeChange(e){return this.fadeDuration===0?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 r=this.zoomAtLastRecencyCheck===t?1-this.zoomAdjustment(t):1;return this.zoomAtLastRecencyCheck=t,this.commitTime+this.fadeDuration*r>e}setStale(){this.stale=!0}};function Ym(e,t,r,i,a,n){(!i||i.length===0)&&(i=[0,0,0,0]);let s=i[0]-100,o=i[1]-100,l=i[2]-100,u=i[3]-100;e.emplaceBack(+!!t,+!!r,a||0,n||0,s,o),e.emplaceBack(+!!t,+!!r,a||0,n||0,l,o),e.emplaceBack(+!!t,+!!r,a||0,n||0,l,u),e.emplaceBack(+!!t,+!!r,a||0,n||0,s,u)}const vM=2**25,bM=2**24,wM=2**17,TM=2**16;function Km(e){if(e.opacity===0&&!e.placed)return 0;if(e.opacity===1&&e.placed)return 4294967295;let t=+!!e.placed,r=Math.floor(e.opacity*127);return r*vM+t*bM+r*wM+t*TM+r*512+t*256+r*2+t}const vn=0;var SM=class{constructor(e){this._sortAcrossTiles=e.layout.get("symbol-z-order")!=="viewport-y"&&!e.layout.get("symbol-sort-key").isConstant(),this._currentTileIndex=0,this._currentPartIndex=0,this._seenCrossTileIDs={},this._bucketParts=[]}continuePlacement(e,t,r,i,a){let n=this._bucketParts;for(;this._currentTileIndex<e.length;){let s=e[this._currentTileIndex];if(t.getBucketParts(n,i,s,this._sortAcrossTiles),this._currentTileIndex++,a())return!0}for(this._sortAcrossTiles&&(this._sortAcrossTiles=!1,n.sort((s,o)=>s.sortKey-o.sortKey));this._currentPartIndex<n.length;){let s=n[this._currentPartIndex];if(t.placeLayerBucketPart(s,this._seenCrossTileIDs,r),this._currentPartIndex++,a())return!0}return!1}},DM=class{constructor(e,t,r,i,a,n,s,o){this.placement=new xM(e,t,n,s,o),this._currentPlacementIndex=r.length-1,this._forceFullPlacement=i,this._showCollisionBoxes=a,this._done=!1}isDone(){return this._done}continuePlacement(e,t,r){let i=Fe(),a=()=>!this._forceFullPlacement&&Fe()-i>2;for(;this._currentPlacementIndex>=0;){let n=t[e[this._currentPlacementIndex]],s=this.placement.collisionIndex.transform.zoom;if(B0(n)&&n.layout&&(!n.minzoom||n.minzoom<=s)&&(!n.maxzoom||n.maxzoom>s)){if(this._inProgressLayer||(this._inProgressLayer=new SM(n)),this._inProgressLayer.continuePlacement(r[n.source],this.placement,this._showCollisionBoxes,n,a))return;delete this._inProgressLayer}this._currentPlacementIndex--}this._done=!0}commit(e){return this.placement.commit(e),this.placement}};const Jm=[Int8Array,Uint8Array,Uint8ClampedArray,Int16Array,Uint16Array,Int32Array,Uint32Array,Float32Array,Float64Array],Xe=new Uint32Array(96);var EM=class k1{static from(t){if(!t||t.byteLength===void 0||t.buffer)throw Error("Data must be an instance of ArrayBuffer or SharedArrayBuffer.");let[r,i]=new Uint8Array(t,0,2);if(r!==219)throw Error("Data does not appear to be in a KDBush format.");let a=i>>4;if(a!==1)throw Error(`Got v${a} data when expected v1.`);let n=Jm[i&15];if(!n)throw Error("Unrecognized array type.");let[s]=new Uint16Array(t,2,1),[o]=new Uint32Array(t,4,1);return new k1(o,s,n,void 0,t)}constructor(t,r=64,i=Float64Array,a=ArrayBuffer,n){if(isNaN(t)||t<0)throw Error(`Unexpected numItems value: ${t}.`);this.numItems=+t,this.nodeSize=Math.min(Math.max(+r,2),65535),this.ArrayType=i,this.IndexArrayType=t<65536?Uint16Array:Uint32Array;let s=Jm.indexOf(this.ArrayType),o=t*2*this.ArrayType.BYTES_PER_ELEMENT,l=t*this.IndexArrayType.BYTES_PER_ELEMENT,u=(8-l%8)%8;if(s<0)throw Error(`Unexpected typed array class: ${i}.`);if(n)this.data=n,this.ids=new this.IndexArrayType(n,8,t),this.coords=new i(n,8+l+u,t*2),this._pos=t*2,this._finished=!0;else{let h=this.data=new a(8+o+l+u);this.ids=new this.IndexArrayType(h,8,t),this.coords=new i(h,8+l+u,t*2),this._pos=0,this._finished=!1,new Uint8Array(h,0,2).set([219,16+s]),new Uint16Array(h,2,1)[0]=r,new Uint32Array(h,4,1)[0]=t}}add(t,r){let i=this._pos>>1;return this.ids[i]=i,this.coords[this._pos++]=t,this.coords[this._pos++]=r,i}finish(){let t=this._pos>>1;if(t!==this.numItems)throw Error(`Added ${t} items when expected ${this.numItems}.`);return Lc(this.ids,this.coords,this.nodeSize,0,this.numItems-1,0),this._finished=!0,this}range(t,r,i,a){if(!this._finished)throw Error("Data not yet indexed - call index.finish().");let{ids:n,coords:s,nodeSize:o}=this;Xe[0]=0,Xe[1]=n.length-1,Xe[2]=0;let l=3,u=[];for(;l>0;){let h=Xe[--l],c=Xe[--l],d=Xe[--l];if(c-d<=o){for(let g=d;g<=c;g++){let _=s[2*g],y=s[2*g+1];_>=t&&_<=i&&y>=r&&y<=a&&u.push(n[g])}continue}let p=d+c>>1,f=s[2*p],m=s[2*p+1];f>=t&&f<=i&&m>=r&&m<=a&&u.push(n[p]),(h===0?t<=f:r<=m)&&(Xe[l++]=d,Xe[l++]=p-1,Xe[l++]=1-h),(h===0?i>=f:a>=m)&&(Xe[l++]=p+1,Xe[l++]=c,Xe[l++]=1-h)}return u}within(t,r,i){let a=[];return this.withinInto(t,r,i,a),a}withinInto(t,r,i,a){if(!this._finished)throw Error("Data not yet indexed - call index.finish().");let{ids:n,coords:s,nodeSize:o}=this;Xe[0]=0,Xe[1]=n.length-1,Xe[2]=0;let l=3,u=0,h=i*i;for(;l>0;){let c=Xe[--l],d=Xe[--l],p=Xe[--l];if(d-p<=o){for(let _=p;_<=d;_++)Qm(s[2*_],s[2*_+1],t,r)<=h&&(a[u++]=n[_]);continue}let f=p+d>>1,m=s[2*f],g=s[2*f+1];Qm(m,g,t,r)<=h&&(a[u++]=n[f]),(c===0?t-i<=m:r-i<=g)&&(Xe[l++]=p,Xe[l++]=f-1,Xe[l++]=1-c),(c===0?t+i>=m:r+i>=g)&&(Xe[l++]=f+1,Xe[l++]=d,Xe[l++]=1-c)}return u}};function Lc(e,t,r,i,a,n){if(a-i<=r)return;let s=i+a>>1;L1(e,t,s,i,a,n),Lc(e,t,r,i,s-1,1-n),Lc(e,t,r,s+1,a,1-n)}function L1(e,t,r,i,a,n){for(;a>i;){if(a-i>600){let u=a-i+1,h=r-i+1,c=Math.log(u),d=.5*Math.exp(2*c/3),p=.5*Math.sqrt(c*d*(u-d)/u)*(h-u/2<0?-1:1);L1(e,t,r,Math.max(i,Math.floor(r-h*d/u+p)),Math.min(a,Math.floor(r+(u-h)*d/u+p)),n)}let s=t[2*r+n],o=i,l=a;for(bn(e,t,i,r),t[2*a+n]>s&&bn(e,t,i,a);o<l;){for(bn(e,t,o,l),o++,l--;t[2*o+n]<s;)o++;for(;t[2*l+n]>s;)l--}t[2*i+n]===s?bn(e,t,i,l):(l++,bn(e,t,l,a)),l<=r&&(i=l+1),r<=l&&(a=l-1)}}function bn(e,t,r,i){Xu(e,r,i),Xu(t,2*r,2*i),Xu(t,2*r+1,2*i+1)}function Xu(e,t,r){let i=e[t];e[t]=e[r],e[r]=i}function Qm(e,t,r,i){let a=e-r,n=t-i;return a*a+n*n}const wn=512/L/2;var PM=class{constructor(e,t,r){this.tileID=e,this.bucketInstanceId=r,this._symbolsByKey={};let i=new Map;for(let a=0;a<t.length;a++){let n=t.get(a),s=n.key,o=i.get(s);o?o.push(n):i.set(s,[n])}for(let[a,n]of i){let s={positions:n.map(o=>({x:Math.floor(o.anchorX*wn),y:Math.floor(o.anchorY*wn)})),crossTileIDs:n.map(o=>o.crossTileID)};if(s.positions.length>128){let o=new EM(s.positions.length,16,Uint16Array);for(let{x:l,y:u}of s.positions)o.add(l,u);o.finish(),delete s.positions,s.index=o}this._symbolsByKey[a]=s}}getScaledCoordinates(e,t){let{x:r,y:i,z:a}=this.tileID.canonical,{x:n,y:s,z:o}=t.canonical,l=o-a,u=wn/2**l,h=(n*L+e.anchorX)*u,c=(s*L+e.anchorY)*u,d=r*L*wn,p=i*L*wn;return{x:Math.floor(h-d),y:Math.floor(c-p)}}findMatches(e,t,r){let i=this.tileID.canonical.z<t.canonical.z?1:2**(this.tileID.canonical.z-t.canonical.z);for(let a=0;a<e.length;a++){let n=e.get(a);if(n.crossTileID)continue;let s=this._symbolsByKey[n.key];if(!s)continue;let o=this.getScaledCoordinates(n,t);s.index?this.findMatchesForIndexedEntry(s,n,o,i,r):s.positions&&this.findMatchesForNonIndexedEntry(s,n,o,i,r)}}findMatchesForIndexedEntry(e,t,r,i,a){let n=e.index.range(r.x-i,r.y-i,r.x+i,r.y+i),s=1/0;for(let o of n)o<s&&!a[e.crossTileIDs[o]]&&(s=o);if(s!==1/0){let o=e.crossTileIDs[s];a[o]=!0,t.crossTileID=o}}findMatchesForNonIndexedEntry(e,t,r,i,a){for(let n=0;n<e.positions.length;n++){let s=e.positions[n],o=e.crossTileIDs[n];if(Math.abs(s.x-r.x)<=i&&Math.abs(s.y-r.y)<=i&&!a[o]){a[o]=!0,t.crossTileID=o;break}}}getCrossTileIDsLists(){return Object.values(this._symbolsByKey).map(({crossTileIDs:e})=>e)}},AM=class{constructor(){this.maxCrossTileID=0}generate(){return++this.maxCrossTileID}},CM=class{constructor(){this.indexes={},this.usedCrossTileIDs={},this.lng=0}handleWrapJump(e){let t=Math.round((e-this.lng)/360);if(t!==0)for(let r in this.indexes){let i=this.indexes[r],a={};for(let n in i){let s=i[n];s.tileID=s.tileID.unwrapTo(s.tileID.wrap+t),a[s.tileID.key]=s}this.indexes[r]=a}this.lng=e}addBucket(e,t,r){var a,n,s;if((a=this.indexes[e.overscaledZ])!=null&&a[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 o=0;o<t.symbolInstances.length;o++){let l=t.symbolInstances.get(o);l.crossTileID=0}(n=this.usedCrossTileIDs)[s=e.overscaledZ]||(n[s]={});let i=this.usedCrossTileIDs[e.overscaledZ];for(let o in this.indexes){let l=this.indexes[o];if(Number(o)>e.overscaledZ)for(let u in l){let h=l[u];h.tileID.isChildOf(e)&&h.findMatches(t.symbolInstances,e,i)}else{let u=l[e.scaledTo(Number(o)).key];u&&u.findMatches(t.symbolInstances,e,i)}}for(let o=0;o<t.symbolInstances.length;o++){let l=t.symbolInstances.get(o);l.crossTileID||(l.crossTileID=r.generate(),i[l.crossTileID]=!0)}return this.indexes[e.overscaledZ]===void 0&&(this.indexes[e.overscaledZ]={}),this.indexes[e.overscaledZ][e.key]=new PM(e,t.symbolInstances,t.bucketInstanceId),!0}removeBucketCrossTileIDs(e,t){for(let r of t.getCrossTileIDsLists())for(let i of r)delete this.usedCrossTileIDs[e][i]}removeStaleBuckets(e){let t=!1;for(let r in this.indexes){let i=this.indexes[r];for(let a in i)e[i[a].bucketInstanceId]||(this.removeBucketCrossTileIDs(r,i[a]),delete i[a],t=!0)}return t}},B1=class{constructor(){this.layerIndexes={},this.crossTileIDs=new AM,this.maxBucketInstanceId=0,this.bucketsInCurrentPlacement={}}addLayer(e,t,r){let i=this.layerIndexes[e.id];i===void 0&&(i=this.layerIndexes[e.id]=new CM);let a=!1,n={};i.handleWrapJump(r);for(let s of t){let o=s.getBucket(e);e.id===(o==null?void 0:o.layerIds[0])&&(o.bucketInstanceId||(o.bucketInstanceId=(this.maxBucketInstanceId+=1,this.maxBucketInstanceId)),i.addBucket(s.tileID,o,this.crossTileIDs)&&(a=!0),n[o.bucketInstanceId]=!0)}return i.removeStaleBuckets(n)&&(a=!0),a}pruneUnusedLayers(e){let t={};for(let r of e)t[r]=!0;for(let r in this.layerIndexes)t[r]||delete this.layerIndexes[r]}},IM=`#ifdef GL_ES
|
|
9
|
+
precision mediump float;
|
|
10
|
+
#else
|
|
11
|
+
#if !defined(lowp)
|
|
12
|
+
#define lowp
|
|
13
|
+
#endif
|
|
14
|
+
#if !defined(mediump)
|
|
15
|
+
#define mediump
|
|
16
|
+
#endif
|
|
17
|
+
#if !defined(highp)
|
|
18
|
+
#define highp
|
|
19
|
+
#endif
|
|
20
|
+
#endif
|
|
21
|
+
out 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;};`,MM=`#ifdef GL_ES
|
|
22
|
+
precision highp float;
|
|
23
|
+
#else
|
|
24
|
+
#if !defined(lowp)
|
|
25
|
+
#define lowp
|
|
26
|
+
#endif
|
|
27
|
+
#if !defined(mediump)
|
|
28
|
+
#define mediump
|
|
29
|
+
#endif
|
|
30
|
+
#if !defined(highp)
|
|
31
|
+
#define highp
|
|
32
|
+
#endif
|
|
33
|
+
#endif
|
|
34
|
+
vec2 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
|
|
35
|
+
);}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
|
|
36
|
+
);}
|
|
37
|
+
#ifdef TERRAIN3D
|
|
38
|
+
uniform 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;};
|
|
39
|
+
#endif
|
|
40
|
+
const 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) {
|
|
41
|
+
#ifdef TERRAIN3D
|
|
42
|
+
highp 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));
|
|
43
|
+
#else
|
|
44
|
+
return 1.0;
|
|
45
|
+
#endif
|
|
46
|
+
}float calculate_visibility(vec4 pos) {
|
|
47
|
+
#ifdef TERRAIN3D
|
|
48
|
+
vec3 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;
|
|
49
|
+
#else
|
|
50
|
+
return 1.0;
|
|
51
|
+
#endif
|
|
52
|
+
}float ele(ivec2 pos) {
|
|
53
|
+
#ifdef TERRAIN3D
|
|
54
|
+
vec4 rgb=(texelFetch(u_terrain,pos,0)*255.0)*u_terrain_unpack;return rgb.r+rgb.g+rgb.b-u_terrain_unpack.a;
|
|
55
|
+
#else
|
|
56
|
+
return 0.0;
|
|
57
|
+
#endif
|
|
58
|
+
}float get_elevation(vec2 pos) {
|
|
59
|
+
#ifdef TERRAIN3D
|
|
60
|
+
#ifdef GLOBE
|
|
61
|
+
if ((pos.y <-32767.5) || (pos.y > 32766.5)) {return 0.0;}
|
|
62
|
+
#endif
|
|
63
|
+
vec2 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;
|
|
64
|
+
#else
|
|
65
|
+
return 0.0;
|
|
66
|
+
#endif
|
|
67
|
+
}const float PI=3.141592653589793;
|
|
68
|
+
#define PROJECTION_UBO
|
|
69
|
+
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;};`,zM=`uniform vec4 u_color;uniform float u_opacity;void main() {fragColor=u_color*u_opacity;
|
|
70
|
+
#ifdef OVERDRAW_INSPECTOR
|
|
71
|
+
fragColor=vec4(1.0);
|
|
72
|
+
#endif
|
|
73
|
+
}`,FM="layout(location=0) in vec2 a_pos;void main() {gl_Position=projectTile(a_pos);}",RM=`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;
|
|
74
|
+
#ifdef OVERDRAW_INSPECTOR
|
|
75
|
+
fragColor=vec4(1.0);
|
|
76
|
+
#endif
|
|
77
|
+
}`,kM="uniform vec2 u_pattern_size_a;uniform vec2 u_pattern_size_b;uniform vec2 u_pixel_coord_upper;uniform vec2 u_pixel_coord_lower;uniform float u_scale_a;uniform float u_scale_b;uniform float u_tile_units_to_pixels;layout(location=0) in vec2 a_pos;out vec2 v_pos_a;out vec2 v_pos_b;void main() {gl_Position=projectTile(a_pos);v_pos_a=get_pattern_pos(u_pixel_coord_upper,u_pixel_coord_lower,u_scale_a*u_pattern_size_a,u_tile_units_to_pixels,a_pos);v_pos_b=get_pattern_pos(u_pixel_coord_upper,u_pixel_coord_lower,u_scale_b*u_pattern_size_b,u_tile_units_to_pixels,a_pos);}",LM=`in vec3 v_data;flat in float v_visibility;
|
|
78
|
+
#pragma maplibre: define highp vec4 color
|
|
79
|
+
#pragma maplibre: define mediump float radius
|
|
80
|
+
#pragma maplibre: define lowp float blur
|
|
81
|
+
#pragma maplibre: define lowp float opacity
|
|
82
|
+
#pragma maplibre: define highp vec4 stroke_color
|
|
83
|
+
#pragma maplibre: define mediump float stroke_width
|
|
84
|
+
#pragma maplibre: define lowp float stroke_opacity
|
|
85
|
+
void main() {
|
|
86
|
+
#pragma maplibre: initialize highp vec4 color
|
|
87
|
+
#pragma maplibre: initialize mediump float radius
|
|
88
|
+
#pragma maplibre: initialize lowp float blur
|
|
89
|
+
#pragma maplibre: initialize lowp float opacity
|
|
90
|
+
#pragma maplibre: initialize highp vec4 stroke_color
|
|
91
|
+
#pragma maplibre: initialize mediump float stroke_width
|
|
92
|
+
#pragma maplibre: initialize lowp float stroke_opacity
|
|
93
|
+
vec2 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;}
|
|
94
|
+
#ifdef OVERDRAW_INSPECTOR
|
|
95
|
+
fragColor=vec4(1.0);
|
|
96
|
+
#endif
|
|
97
|
+
}`,BM=`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;flat out float v_visibility;
|
|
98
|
+
#pragma maplibre: define highp vec4 color
|
|
99
|
+
#pragma maplibre: define mediump float radius
|
|
100
|
+
#pragma maplibre: define lowp float blur
|
|
101
|
+
#pragma maplibre: define lowp float opacity
|
|
102
|
+
#pragma maplibre: define highp vec4 stroke_color
|
|
103
|
+
#pragma maplibre: define mediump float stroke_width
|
|
104
|
+
#pragma maplibre: define lowp float stroke_opacity
|
|
105
|
+
void main(void) {
|
|
106
|
+
#pragma maplibre: initialize highp vec4 color
|
|
107
|
+
#pragma maplibre: initialize mediump float radius
|
|
108
|
+
#pragma maplibre: initialize lowp float blur
|
|
109
|
+
#pragma maplibre: initialize lowp float opacity
|
|
110
|
+
#pragma maplibre: initialize highp vec4 stroke_color
|
|
111
|
+
#pragma maplibre: initialize mediump float stroke_width
|
|
112
|
+
#pragma maplibre: initialize lowp float stroke_opacity
|
|
113
|
+
ivec2 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) {
|
|
114
|
+
#ifdef GLOBE
|
|
115
|
+
vec3 center_vector=projectToSphere(circle_center);
|
|
116
|
+
#endif
|
|
117
|
+
float 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 {
|
|
118
|
+
#ifdef GLOBE
|
|
119
|
+
vec4 projected_center=interpolateProjection(circle_center,center_vector,ele);
|
|
120
|
+
#else
|
|
121
|
+
vec4 projected_center=projectTileWithElevation(circle_center,ele);
|
|
122
|
+
#endif
|
|
123
|
+
corner_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);}
|
|
124
|
+
#ifdef GLOBE
|
|
125
|
+
vec2 angles=extrude*angle_scale;vec3 corner_vector=globeRotateVector(center_vector,angles);gl_Position=interpolateProjection(corner_position,corner_vector,ele);
|
|
126
|
+
#else
|
|
127
|
+
gl_Position=projectTileWithElevation(corner_position,ele);
|
|
128
|
+
#endif
|
|
129
|
+
} 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);}`,eg="void main() {fragColor=vec4(1.0);}";const Vr={prelude:be(IM,MM),projectionMercator:be(`
|
|
130
|
+
void 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:be("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
|
|
131
|
+
#ifndef PROJECTION_UBO
|
|
132
|
+
uniform 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;
|
|
133
|
+
#endif
|
|
134
|
+
out highp float v_projection_tile_x;vec3 globeRotateVector(vec3 vec,vec2 angles) {vec3 axisRight=vec3(vec.z,0.0,-vec.x);vec3 axisUp=cross(axisRight,vec);axisRight=normalize(axisRight);axisUp=normalize(axisUp);vec2 t=tan(angles);return normalize(vec+axisRight*t.x+axisUp*t.y);}mat3 globeGetRotationMatrix(vec3 spherePos) {vec3 axisRight=vec3(spherePos.z,0.0,-spherePos.x);vec3 axisDown=cross(axisRight,spherePos);axisRight=normalize(axisRight);axisDown=normalize(axisDown);return mat3(axisRight,axisDown,spherePos
|
|
135
|
+
);}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
|
|
136
|
+
);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:be(zM,FM),backgroundPattern:be(RM,kM),circle:be(LM,BM),clippingMask:be(eg,"layout(location=0) in vec2 a_pos;void main() {gl_Position=projectTile(a_pos);}"),heatmap:be(`uniform highp float u_intensity;in vec2 v_extrude;
|
|
137
|
+
#pragma maplibre: define highp float weight
|
|
138
|
+
#define GAUSS_COEF 0.3989422804014327
|
|
139
|
+
void main() {
|
|
140
|
+
#pragma maplibre: initialize highp float weight
|
|
141
|
+
float 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);
|
|
142
|
+
#ifdef OVERDRAW_INSPECTOR
|
|
143
|
+
fragColor=vec4(1.0);
|
|
144
|
+
#endif
|
|
145
|
+
}`,`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;
|
|
146
|
+
#pragma maplibre: define highp float weight
|
|
147
|
+
#pragma maplibre: define mediump float radius
|
|
148
|
+
const highp float ZERO=1.0/255.0/16.0;
|
|
149
|
+
#define GAUSS_COEF 0.3989422804014327
|
|
150
|
+
void main(void) {
|
|
151
|
+
#pragma maplibre: initialize highp float weight
|
|
152
|
+
#pragma maplibre: initialize mediump float radius
|
|
153
|
+
ivec2 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);
|
|
154
|
+
#ifdef GLOBE
|
|
155
|
+
vec2 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);
|
|
156
|
+
#else
|
|
157
|
+
gl_Position=projectTileFor3D(circle_center+extrude,get_elevation(circle_center));
|
|
158
|
+
#endif
|
|
159
|
+
}`),heatmapTexture:be(`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;
|
|
160
|
+
#ifdef OVERDRAW_INSPECTOR
|
|
161
|
+
fragColor=vec4(0.0);
|
|
162
|
+
#endif
|
|
163
|
+
}`,"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:be("flat in float v_placed;flat in float v_notUsed;void main() {float alpha=0.5;fragColor=vec4(1.0,0.0,0.0,1.0)*alpha;if (v_placed > 0.5) {fragColor=vec4(0.0,0.0,1.0,0.5)*alpha;}if (v_notUsed > 0.5) {fragColor*=.1;}}","layout(location=0) in vec2 a_anchor_pos;layout(location=1) in vec2 a_placed;layout(location=2) in vec2 a_box_real;flat out float v_placed;flat out float v_notUsed;void main() {gl_Position=projectTileWithElevation(a_anchor_pos,get_elevation(a_anchor_pos));gl_Position.xy=((a_box_real+0.5)*u_pixel_extrude_scale*2.0-1.0)*vec2(1.0,-1.0)*gl_Position.w;if (gl_Position.z/gl_Position.w < 1.1) {gl_Position.z=0.5;}v_placed=a_placed.x;v_notUsed=a_placed.y;}"),collisionCircle:be("flat in float v_radius;in vec2 v_extrude;flat in float v_collision;void main() {float alpha=0.5;float stroke_radius=0.9;float distance_to_center=length(v_extrude);float distance_to_edge=abs(distance_to_center-v_radius);float opacity_t=smoothstep(-stroke_radius,0.0,-distance_to_edge);vec4 color=mix(vec4(0.0,0.0,1.0,0.5),vec4(1.0,0.0,0.0,1.0),v_collision);fragColor=color*alpha*opacity_t;}","layout(location=0) in vec2 a_pos;layout(location=1) in float a_radius;layout(location=2) in vec2 a_flags;flat out float v_radius;out vec2 v_extrude;flat out float v_collision;void main() {float radius=a_radius;float collision=a_flags.x;float vertexIdx=a_flags.y;vec2 quadVertexOffset=vec2(mix(-1.0,1.0,float(vertexIdx >=2.0)),mix(-1.0,1.0,float(vertexIdx >=1.0 && vertexIdx <=2.0)));vec2 quadVertexExtent=quadVertexOffset*radius;float padding_factor=1.2;v_radius=radius;v_extrude=quadVertexExtent*padding_factor;v_collision=collision;gl_Position=vec4((a_pos/u_viewport_size*2.0-1.0)*vec2(1.0,-1.0),0.0,1.0)+vec4(quadVertexExtent*padding_factor/u_viewport_size*2.0,0.0,0.0);}"),colorRelief:be(`#ifdef GL_ES
|
|
164
|
+
precision highp float;
|
|
165
|
+
#endif
|
|
166
|
+
uniform 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
|
|
167
|
+
{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));
|
|
168
|
+
#ifdef OVERDRAW_INSPECTOR
|
|
169
|
+
fragColor=vec4(1.0);
|
|
170
|
+
#endif
|
|
171
|
+
}`,"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:be("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:be(eg,`layout(location=0) in vec2 a_pos;void main() {
|
|
172
|
+
#ifdef GLOBE
|
|
173
|
+
gl_Position=projectTileFor3D(a_pos,0.0);
|
|
174
|
+
#else
|
|
175
|
+
gl_Position=u_projection_matrix*vec4(a_pos,0.0,1.0);
|
|
176
|
+
#endif
|
|
177
|
+
}`),fill:be(`#pragma maplibre: define highp vec4 color
|
|
178
|
+
#pragma maplibre: define lowp float opacity
|
|
179
|
+
void main() {
|
|
180
|
+
#pragma maplibre: initialize highp vec4 color
|
|
181
|
+
#pragma maplibre: initialize lowp float opacity
|
|
182
|
+
fragColor=color*opacity;
|
|
183
|
+
#ifdef OVERDRAW_INSPECTOR
|
|
184
|
+
fragColor=vec4(1.0);
|
|
185
|
+
#endif
|
|
186
|
+
}`,`uniform vec2 u_fill_translate;layout(location=0) in vec2 a_pos;
|
|
187
|
+
#pragma maplibre: define highp vec4 color
|
|
188
|
+
#pragma maplibre: define lowp float opacity
|
|
189
|
+
void main() {
|
|
190
|
+
#pragma maplibre: initialize highp vec4 color
|
|
191
|
+
#pragma maplibre: initialize lowp float opacity
|
|
192
|
+
if (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:be(`in vec2 v_pos;
|
|
193
|
+
#ifdef GLOBE
|
|
194
|
+
in float v_depth;
|
|
195
|
+
#endif
|
|
196
|
+
#pragma maplibre: define highp vec4 outline_color
|
|
197
|
+
#pragma maplibre: define lowp float opacity
|
|
198
|
+
void main() {
|
|
199
|
+
#pragma maplibre: initialize highp vec4 outline_color
|
|
200
|
+
#pragma maplibre: initialize lowp float opacity
|
|
201
|
+
float dist=length(v_pos-gl_FragCoord.xy);float alpha=1.0-smoothstep(0.0,1.0,dist);fragColor=outline_color*(alpha*opacity);
|
|
202
|
+
#ifdef GLOBE
|
|
203
|
+
if (v_depth > 1.0) {discard;}
|
|
204
|
+
#endif
|
|
205
|
+
#ifdef OVERDRAW_INSPECTOR
|
|
206
|
+
fragColor=vec4(1.0);
|
|
207
|
+
#endif
|
|
208
|
+
}`,`uniform vec2 u_fill_translate;layout(location=0) in vec2 a_pos;out vec2 v_pos;
|
|
209
|
+
#ifdef GLOBE
|
|
210
|
+
out float v_depth;
|
|
211
|
+
#endif
|
|
212
|
+
#pragma maplibre: define highp vec4 outline_color
|
|
213
|
+
#pragma maplibre: define lowp float opacity
|
|
214
|
+
void main() {
|
|
215
|
+
#pragma maplibre: initialize highp vec4 outline_color
|
|
216
|
+
#pragma maplibre: initialize lowp float opacity
|
|
217
|
+
if (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;
|
|
218
|
+
#ifdef GLOBE
|
|
219
|
+
v_depth=gl_Position.z/gl_Position.w;
|
|
220
|
+
#endif
|
|
221
|
+
}`),fillOutlinePattern:be(`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;
|
|
222
|
+
#ifdef GLOBE
|
|
223
|
+
in float v_depth;
|
|
224
|
+
#endif
|
|
225
|
+
#pragma maplibre: define lowp float opacity
|
|
226
|
+
#pragma maplibre: define highp vec4 color
|
|
227
|
+
#pragma maplibre: define lowp vec4 pattern_from
|
|
228
|
+
#pragma maplibre: define lowp vec4 pattern_to
|
|
229
|
+
void main() {
|
|
230
|
+
#pragma maplibre: initialize lowp float opacity
|
|
231
|
+
#pragma maplibre: initialize highp vec4 color
|
|
232
|
+
#pragma maplibre: initialize mediump vec4 pattern_from
|
|
233
|
+
#pragma maplibre: initialize mediump vec4 pattern_to
|
|
234
|
+
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;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;}
|
|
235
|
+
#ifdef GLOBE
|
|
236
|
+
if (v_depth > 1.0) {discard;}
|
|
237
|
+
#endif
|
|
238
|
+
#ifdef OVERDRAW_INSPECTOR
|
|
239
|
+
fragColor=vec4(1.0);
|
|
240
|
+
#endif
|
|
241
|
+
}`,`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;
|
|
242
|
+
#ifdef GLOBE
|
|
243
|
+
out float v_depth;
|
|
244
|
+
#endif
|
|
245
|
+
#pragma maplibre: define lowp float opacity
|
|
246
|
+
#pragma maplibre: define highp vec4 color
|
|
247
|
+
#pragma maplibre: define lowp vec4 pattern_from
|
|
248
|
+
#pragma maplibre: define lowp vec4 pattern_to
|
|
249
|
+
#pragma maplibre: define lowp float pixel_ratio_from
|
|
250
|
+
#pragma maplibre: define lowp float pixel_ratio_to
|
|
251
|
+
void main() {
|
|
252
|
+
#pragma maplibre: initialize lowp float opacity
|
|
253
|
+
#pragma maplibre: initialize highp vec4 color
|
|
254
|
+
#pragma maplibre: initialize mediump vec4 pattern_from
|
|
255
|
+
#pragma maplibre: initialize mediump vec4 pattern_to
|
|
256
|
+
#pragma maplibre: initialize lowp float pixel_ratio_from
|
|
257
|
+
#pragma maplibre: initialize lowp float pixel_ratio_to
|
|
258
|
+
if (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;
|
|
259
|
+
#ifdef GLOBE
|
|
260
|
+
v_depth=gl_Position.z/gl_Position.w;
|
|
261
|
+
#endif
|
|
262
|
+
}`),fillPattern:be(`#ifdef GL_ES
|
|
263
|
+
precision highp float;
|
|
264
|
+
#endif
|
|
265
|
+
uniform 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;
|
|
266
|
+
#pragma maplibre: define lowp float opacity
|
|
267
|
+
#pragma maplibre: define highp vec4 color
|
|
268
|
+
#pragma maplibre: define lowp vec4 pattern_from
|
|
269
|
+
#pragma maplibre: define lowp vec4 pattern_to
|
|
270
|
+
void main() {
|
|
271
|
+
#pragma maplibre: initialize lowp float opacity
|
|
272
|
+
#pragma maplibre: initialize highp vec4 color
|
|
273
|
+
#pragma maplibre: initialize mediump vec4 pattern_from
|
|
274
|
+
#pragma maplibre: initialize mediump vec4 pattern_to
|
|
275
|
+
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;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;}
|
|
276
|
+
#ifdef OVERDRAW_INSPECTOR
|
|
277
|
+
fragColor=vec4(1.0);
|
|
278
|
+
#endif
|
|
279
|
+
}`,`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;
|
|
280
|
+
#pragma maplibre: define lowp float opacity
|
|
281
|
+
#pragma maplibre: define highp vec4 color
|
|
282
|
+
#pragma maplibre: define lowp vec4 pattern_from
|
|
283
|
+
#pragma maplibre: define lowp vec4 pattern_to
|
|
284
|
+
#pragma maplibre: define lowp float pixel_ratio_from
|
|
285
|
+
#pragma maplibre: define lowp float pixel_ratio_to
|
|
286
|
+
void main() {
|
|
287
|
+
#pragma maplibre: initialize lowp float opacity
|
|
288
|
+
#pragma maplibre: initialize highp vec4 color
|
|
289
|
+
#pragma maplibre: initialize mediump vec4 pattern_from
|
|
290
|
+
#pragma maplibre: initialize mediump vec4 pattern_to
|
|
291
|
+
#pragma maplibre: initialize lowp float pixel_ratio_from
|
|
292
|
+
#pragma maplibre: initialize lowp float pixel_ratio_to
|
|
293
|
+
if (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:be(`in vec4 v_color;void main() {fragColor=v_color;
|
|
294
|
+
#ifdef OVERDRAW_INSPECTOR
|
|
295
|
+
fragColor=vec4(1.0);
|
|
296
|
+
#endif
|
|
297
|
+
}`,`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;
|
|
298
|
+
#ifdef TERRAIN3D
|
|
299
|
+
layout(location=2) in vec2 a_centroid;
|
|
300
|
+
#endif
|
|
301
|
+
out vec4 v_color;
|
|
302
|
+
#pragma maplibre: define highp float base
|
|
303
|
+
#pragma maplibre: define highp float height
|
|
304
|
+
#pragma maplibre: define highp vec4 color
|
|
305
|
+
void main() {
|
|
306
|
+
#pragma maplibre: initialize highp float base
|
|
307
|
+
#pragma maplibre: initialize highp float height
|
|
308
|
+
#pragma maplibre: initialize highp vec4 color
|
|
309
|
+
vec3 normal=vec3(a_normal_ed.xyz);float gradient_base=max(0.0,base);float gradient_height=max(0.0,height);
|
|
310
|
+
#ifdef TERRAIN3D
|
|
311
|
+
float height_terrain3d_offset=get_elevation(a_centroid);float base_terrain3d_offset=height_terrain3d_offset-(base > 0.0 ? 0.0 : 10.0);
|
|
312
|
+
#else
|
|
313
|
+
float height_terrain3d_offset=0.0;float base_terrain3d_offset=0.0;
|
|
314
|
+
#endif
|
|
315
|
+
base=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;
|
|
316
|
+
#ifdef GLOBE
|
|
317
|
+
vec3 spherePos=projectToSphere(posInTile,a_pos);gl_Position=interpolateProjectionFor3D(posInTile,spherePos,elevation);
|
|
318
|
+
#else
|
|
319
|
+
gl_Position=u_projection_matrix*vec4(posInTile,elevation,1.0);
|
|
320
|
+
#endif
|
|
321
|
+
float 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);
|
|
322
|
+
#ifdef GLOBE
|
|
323
|
+
mat3 rotMatrix=globeGetRotationMatrix(spherePos);normalForLighting=rotMatrix*normalForLighting;directional=mix(directional,clamp(dot(normalForLighting,u_lightpos_globe),0.0,1.0),u_projection_transition);
|
|
324
|
+
#endif
|
|
325
|
+
directional=mix((1.0-u_lightintensity),max((1.0-colorvalue+u_lightintensity),1.0),directional);if (normal.y !=0.0) {directional*=((1.0-u_vertical_gradient)+(u_vertical_gradient*clamp((t+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:be(`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;
|
|
326
|
+
#pragma maplibre: define lowp float base
|
|
327
|
+
#pragma maplibre: define lowp float height
|
|
328
|
+
#pragma maplibre: define lowp vec4 pattern_from
|
|
329
|
+
#pragma maplibre: define lowp vec4 pattern_to
|
|
330
|
+
#pragma maplibre: define lowp float pixel_ratio_from
|
|
331
|
+
#pragma maplibre: define lowp float pixel_ratio_to
|
|
332
|
+
void main() {
|
|
333
|
+
#pragma maplibre: initialize lowp float base
|
|
334
|
+
#pragma maplibre: initialize lowp float height
|
|
335
|
+
#pragma maplibre: initialize mediump vec4 pattern_from
|
|
336
|
+
#pragma maplibre: initialize mediump vec4 pattern_to
|
|
337
|
+
#pragma maplibre: initialize lowp float pixel_ratio_from
|
|
338
|
+
#pragma maplibre: initialize lowp float pixel_ratio_to
|
|
339
|
+
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;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;
|
|
340
|
+
#ifdef OVERDRAW_INSPECTOR
|
|
341
|
+
fragColor=vec4(1.0);
|
|
342
|
+
#endif
|
|
343
|
+
}`,`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;
|
|
344
|
+
#ifdef TERRAIN3D
|
|
345
|
+
layout(location=2) in vec2 a_centroid;
|
|
346
|
+
#endif
|
|
347
|
+
#ifdef GLOBE
|
|
348
|
+
out vec3 v_sphere_pos;
|
|
349
|
+
#endif
|
|
350
|
+
out vec2 v_pos_a;out vec2 v_pos_b;out vec4 v_lighting;
|
|
351
|
+
#pragma maplibre: define lowp float base
|
|
352
|
+
#pragma maplibre: define lowp float height
|
|
353
|
+
#pragma maplibre: define lowp vec4 pattern_from
|
|
354
|
+
#pragma maplibre: define lowp vec4 pattern_to
|
|
355
|
+
#pragma maplibre: define lowp float pixel_ratio_from
|
|
356
|
+
#pragma maplibre: define lowp float pixel_ratio_to
|
|
357
|
+
void main() {
|
|
358
|
+
#pragma maplibre: initialize lowp float base
|
|
359
|
+
#pragma maplibre: initialize lowp float height
|
|
360
|
+
#pragma maplibre: initialize mediump vec4 pattern_from
|
|
361
|
+
#pragma maplibre: initialize mediump vec4 pattern_to
|
|
362
|
+
#pragma maplibre: initialize lowp float pixel_ratio_from
|
|
363
|
+
#pragma maplibre: initialize lowp float pixel_ratio_to
|
|
364
|
+
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;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);
|
|
365
|
+
#ifdef TERRAIN3D
|
|
366
|
+
float height_terrain3d_offset=get_elevation(a_centroid);float base_terrain3d_offset=height_terrain3d_offset-(base > 0.0 ? 0.0 : 10.0);
|
|
367
|
+
#else
|
|
368
|
+
float height_terrain3d_offset=0.0;float base_terrain3d_offset=0.0;
|
|
369
|
+
#endif
|
|
370
|
+
base=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;
|
|
371
|
+
#ifdef GLOBE
|
|
372
|
+
vec3 spherePos=projectToSphere(posInTile,a_pos);vec3 elevatedPos=spherePos*(1.0+elevation/GLOBE_RADIUS);v_sphere_pos=elevatedPos;gl_Position=interpolateProjectionFor3D(posInTile,spherePos,elevation);
|
|
373
|
+
#else
|
|
374
|
+
gl_Position=u_projection_matrix*vec4(posInTile,elevation,1.0);
|
|
375
|
+
#endif
|
|
376
|
+
vec2 pos=a_normal_ed.x==1 && a_normal_ed.y==0 && a_normal_ed.z==16384
|
|
377
|
+
? a_pos
|
|
378
|
+
: vec2(edgedistance,elevation*u_height_factor);v_pos_a=get_pattern_pos(u_pixel_coord_upper,u_pixel_coord_lower,fromScale*display_size_a,tileRatio,pos);v_pos_b=get_pattern_pos(u_pixel_coord_upper,u_pixel_coord_lower,toScale*display_size_b,tileRatio,pos);v_lighting=vec4(0.0,0.0,0.0,1.0);float directional=clamp(dot(normal/16383.0,u_lightpos),0.0,1.0);directional=mix((1.0-u_lightintensity),max((0.5+u_lightintensity),1.0),directional);if (normal.y !=0.0) {directional*=((1.0-u_vertical_gradient)+(u_vertical_gradient*clamp((t+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:be(`#ifdef GL_ES
|
|
379
|
+
precision highp float;
|
|
380
|
+
#endif
|
|
381
|
+
uniform sampler2D u_image;in vec2 v_pos;uniform vec2 u_dimension;uniform float u_zoom;uniform vec4 u_unpack;float getElevation(ivec2 texel) {vec4 data=texelFetch(u_image,texel,0)*255.0;data.a=-1.0;return dot(data,u_unpack);}void main() {ivec2 pos=ivec2(gl_FragCoord.xy)+ivec2(1);float tileSize=u_dimension.x-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+(28.2562-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);
|
|
382
|
+
#ifdef OVERDRAW_INSPECTOR
|
|
383
|
+
fragColor=vec4(1.0);
|
|
384
|
+
#endif
|
|
385
|
+
}`,"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:be(`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];
|
|
386
|
+
#define PI 3.141592653589793
|
|
387
|
+
#define STANDARD 0
|
|
388
|
+
#define COMBINED 1
|
|
389
|
+
#define IGOR 2
|
|
390
|
+
#define MULTIDIRECTIONAL 3
|
|
391
|
+
#define BASIC 4
|
|
392
|
+
float 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
|
|
393
|
+
{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
|
|
394
|
+
{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);}
|
|
395
|
+
#ifdef OVERDRAW_INSPECTOR
|
|
396
|
+
fragColor=vec4(1.0);
|
|
397
|
+
#endif
|
|
398
|
+
}`,"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:be(`flat in vec2 v_width2;in vec2 v_normal;in float v_gamma_scale;
|
|
399
|
+
#ifdef GLOBE
|
|
400
|
+
in float v_depth;
|
|
401
|
+
#endif
|
|
402
|
+
#pragma maplibre: define highp vec4 color
|
|
403
|
+
#pragma maplibre: define lowp float blur
|
|
404
|
+
#pragma maplibre: define lowp float opacity
|
|
405
|
+
void main() {
|
|
406
|
+
#pragma maplibre: initialize highp vec4 color
|
|
407
|
+
#pragma maplibre: initialize lowp float blur
|
|
408
|
+
#pragma maplibre: initialize lowp float opacity
|
|
409
|
+
clipAntimeridian();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);
|
|
410
|
+
#ifdef GLOBE
|
|
411
|
+
if (v_depth > 1.0) {discard;}
|
|
412
|
+
#endif
|
|
413
|
+
#ifdef OVERDRAW_INSPECTOR
|
|
414
|
+
fragColor=vec4(1.0);
|
|
415
|
+
#endif
|
|
416
|
+
}`,`
|
|
417
|
+
#define scale 0.015873016
|
|
418
|
+
layout(location=0) in ivec2 a_pos_normal;layout(location=1) in uvec4 a_data;uniform vec2 u_translation;uniform mediump float u_ratio;out vec2 v_normal;flat out vec2 v_width2;out float v_gamma_scale;out highp float v_linesofar;
|
|
419
|
+
#ifdef GLOBE
|
|
420
|
+
out float v_depth;
|
|
421
|
+
#endif
|
|
422
|
+
#pragma maplibre: define highp vec4 color
|
|
423
|
+
#pragma maplibre: define lowp float blur
|
|
424
|
+
#pragma maplibre: define lowp float opacity
|
|
425
|
+
#pragma maplibre: define mediump float gapwidth
|
|
426
|
+
#pragma maplibre: define lowp float offset
|
|
427
|
+
#pragma maplibre: define mediump float width
|
|
428
|
+
void main() {
|
|
429
|
+
#pragma maplibre: initialize highp vec4 color
|
|
430
|
+
#pragma maplibre: initialize lowp float blur
|
|
431
|
+
#pragma maplibre: initialize lowp float opacity
|
|
432
|
+
#pragma maplibre: initialize mediump float gapwidth
|
|
433
|
+
#pragma maplibre: initialize lowp float offset
|
|
434
|
+
#pragma maplibre: initialize mediump float width
|
|
435
|
+
if (opacity < 0.01) {gl_Position=vec4(-2.0,-2.0,-2.0,1.0);return;}float ANTIALIASING=1.0/u_device_pixel_ratio/2.0;vec2 a_extrude=vec2(ivec2(a_data.xy)-128);float a_direction=float(int(a_data.z & 3u)-1);v_linesofar=float((a_data.z >> 2u)+a_data.w*64u)*2.0;vec2 pos=vec2(a_pos_normal >> 1);mediump vec2 normal=vec2(a_pos_normal & 1);normal.y=normal.y*2.0-1.0;v_normal=normal;gapwidth=gapwidth/2.0;float halfwidth=width/2.0;offset=-1.0*offset;float inset=gapwidth+(gapwidth > 0.0 ? ANTIALIASING : 0.0);float outset=gapwidth+halfwidth*(gapwidth > 0.0 ? 2.0 : 1.0)+(halfwidth==0.0 ? 0.0 : ANTIALIASING);mediump vec2 dist=outset*a_extrude*scale;mediump float u=0.5*a_direction;mediump float t=1.0-abs(u);mediump vec2 offset2=offset*a_extrude*scale*normal.y*mat2(t,-u,u,t);float adjustedThickness=projectLineThickness(pos.y);vec4 projected_no_extrude=projectTile(pos+offset2/u_ratio*adjustedThickness+u_translation);vec4 projected_with_extrude=projectTile(pos+offset2/u_ratio*adjustedThickness+u_translation+dist/u_ratio*adjustedThickness);gl_Position=projected_with_extrude;
|
|
436
|
+
#ifdef GLOBE
|
|
437
|
+
v_depth=gl_Position.z/gl_Position.w;
|
|
438
|
+
#endif
|
|
439
|
+
#ifdef TERRAIN3D
|
|
440
|
+
v_gamma_scale=1.0;
|
|
441
|
+
#else
|
|
442
|
+
float 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;
|
|
443
|
+
#endif
|
|
444
|
+
v_width2=vec2(outset,inset);}`),lineGradient:be(`uniform sampler2D u_image;flat in vec2 v_width2;in vec2 v_normal;in float v_gamma_scale;in highp vec2 v_uv;
|
|
445
|
+
#ifdef GLOBE
|
|
446
|
+
in float v_depth;
|
|
447
|
+
#endif
|
|
448
|
+
#pragma maplibre: define lowp float blur
|
|
449
|
+
#pragma maplibre: define lowp float opacity
|
|
450
|
+
void main() {
|
|
451
|
+
#pragma maplibre: initialize lowp float blur
|
|
452
|
+
#pragma maplibre: initialize lowp float opacity
|
|
453
|
+
clipAntimeridian();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);
|
|
454
|
+
#ifdef GLOBE
|
|
455
|
+
if (v_depth > 1.0) {discard;}
|
|
456
|
+
#endif
|
|
457
|
+
#ifdef OVERDRAW_INSPECTOR
|
|
458
|
+
fragColor=vec4(1.0);
|
|
459
|
+
#endif
|
|
460
|
+
}`,`
|
|
461
|
+
#define scale 0.015873016
|
|
462
|
+
layout(location=0) in ivec2 a_pos_normal;layout(location=1) in uvec4 a_data;layout(location=2) in float a_uv_x;layout(location=3) in float a_split_index;uniform vec2 u_translation;uniform mediump float u_ratio;uniform float u_image_height;out vec2 v_normal;flat out vec2 v_width2;out float v_gamma_scale;out highp vec2 v_uv;
|
|
463
|
+
#ifdef GLOBE
|
|
464
|
+
out float v_depth;
|
|
465
|
+
#endif
|
|
466
|
+
#pragma maplibre: define lowp float blur
|
|
467
|
+
#pragma maplibre: define lowp float opacity
|
|
468
|
+
#pragma maplibre: define mediump float gapwidth
|
|
469
|
+
#pragma maplibre: define lowp float offset
|
|
470
|
+
#pragma maplibre: define mediump float width
|
|
471
|
+
void main() {
|
|
472
|
+
#pragma maplibre: initialize lowp float blur
|
|
473
|
+
#pragma maplibre: initialize lowp float opacity
|
|
474
|
+
#pragma maplibre: initialize mediump float gapwidth
|
|
475
|
+
#pragma maplibre: initialize lowp float offset
|
|
476
|
+
#pragma maplibre: initialize mediump float width
|
|
477
|
+
if (opacity < 0.01) {gl_Position=vec4(-2.0,-2.0,-2.0,1.0);return;}float ANTIALIASING=1.0/u_device_pixel_ratio/2.0;vec2 a_extrude=vec2(ivec2(a_data.xy)-128);float a_direction=float(int(a_data.z & 3u)-1);highp float texel_height=1.0/u_image_height;highp float half_texel_height=0.5*texel_height;v_uv=vec2(a_uv_x,a_split_index*texel_height-half_texel_height);vec2 pos=vec2(a_pos_normal >> 1);mediump vec2 normal=vec2(a_pos_normal & 1);normal.y=normal.y*2.0-1.0;v_normal=normal;gapwidth=gapwidth/2.0;float halfwidth=width/2.0;offset=-1.0*offset;float inset=gapwidth+(gapwidth > 0.0 ? ANTIALIASING : 0.0);float outset=gapwidth+halfwidth*(gapwidth > 0.0 ? 2.0 : 1.0)+(halfwidth==0.0 ? 0.0 : ANTIALIASING);mediump vec2 dist=outset*a_extrude*scale;mediump float u=0.5*a_direction;mediump float t=1.0-abs(u);mediump vec2 offset2=offset*a_extrude*scale*normal.y*mat2(t,-u,u,t);float adjustedThickness=projectLineThickness(pos.y);vec4 projected_no_extrude=projectTile(pos+offset2/u_ratio*adjustedThickness+u_translation);vec4 projected_with_extrude=projectTile(pos+offset2/u_ratio*adjustedThickness+u_translation+dist/u_ratio*adjustedThickness);gl_Position=projected_with_extrude;
|
|
478
|
+
#ifdef GLOBE
|
|
479
|
+
v_depth=gl_Position.z/gl_Position.w;
|
|
480
|
+
#endif
|
|
481
|
+
#ifdef TERRAIN3D
|
|
482
|
+
v_gamma_scale=1.0;
|
|
483
|
+
#else
|
|
484
|
+
float 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;
|
|
485
|
+
#endif
|
|
486
|
+
v_width2=vec2(outset,inset);}`),linePattern:be(`#ifdef GL_ES
|
|
487
|
+
precision highp float;
|
|
488
|
+
#endif
|
|
489
|
+
uniform vec2 u_texsize;uniform float u_fade;uniform mediump vec3 u_scale;uniform sampler2D u_image;in vec2 v_normal;flat in vec2 v_width2;in float v_linesofar;in float v_gamma_scale;flat in float v_width;
|
|
490
|
+
#ifdef GLOBE
|
|
491
|
+
in float v_depth;
|
|
492
|
+
#endif
|
|
493
|
+
#pragma maplibre: define lowp vec4 pattern_from
|
|
494
|
+
#pragma maplibre: define lowp vec4 pattern_to
|
|
495
|
+
#pragma maplibre: define lowp float pixel_ratio_from
|
|
496
|
+
#pragma maplibre: define lowp float pixel_ratio_to
|
|
497
|
+
#pragma maplibre: define lowp float blur
|
|
498
|
+
#pragma maplibre: define lowp float opacity
|
|
499
|
+
void main() {
|
|
500
|
+
#pragma maplibre: initialize mediump vec4 pattern_from
|
|
501
|
+
#pragma maplibre: initialize mediump vec4 pattern_to
|
|
502
|
+
#pragma maplibre: initialize lowp float pixel_ratio_from
|
|
503
|
+
#pragma maplibre: initialize lowp float pixel_ratio_to
|
|
504
|
+
#pragma maplibre: initialize lowp float blur
|
|
505
|
+
#pragma maplibre: initialize lowp float opacity
|
|
506
|
+
clipAntimeridian();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;
|
|
507
|
+
#ifdef GLOBE
|
|
508
|
+
if (v_depth > 1.0) {discard;}
|
|
509
|
+
#endif
|
|
510
|
+
#ifdef OVERDRAW_INSPECTOR
|
|
511
|
+
fragColor=vec4(1.0);
|
|
512
|
+
#endif
|
|
513
|
+
}`,`
|
|
514
|
+
#define scale 0.015873016
|
|
515
|
+
#define LINE_DISTANCE_SCALE 2.0
|
|
516
|
+
layout(location=0) in ivec2 a_pos_normal;layout(location=1) in uvec4 a_data;uniform vec2 u_translation;uniform mediump float u_ratio;out vec2 v_normal;flat out vec2 v_width2;out float v_linesofar;out float v_gamma_scale;flat out float v_width;
|
|
517
|
+
#ifdef GLOBE
|
|
518
|
+
out float v_depth;
|
|
519
|
+
#endif
|
|
520
|
+
#pragma maplibre: define lowp float blur
|
|
521
|
+
#pragma maplibre: define lowp float opacity
|
|
522
|
+
#pragma maplibre: define lowp float offset
|
|
523
|
+
#pragma maplibre: define mediump float gapwidth
|
|
524
|
+
#pragma maplibre: define mediump float width
|
|
525
|
+
#pragma maplibre: define lowp float floorwidth
|
|
526
|
+
#pragma maplibre: define lowp vec4 pattern_from
|
|
527
|
+
#pragma maplibre: define lowp vec4 pattern_to
|
|
528
|
+
#pragma maplibre: define lowp float pixel_ratio_from
|
|
529
|
+
#pragma maplibre: define lowp float pixel_ratio_to
|
|
530
|
+
void main() {
|
|
531
|
+
#pragma maplibre: initialize lowp float blur
|
|
532
|
+
#pragma maplibre: initialize lowp float opacity
|
|
533
|
+
#pragma maplibre: initialize lowp float offset
|
|
534
|
+
#pragma maplibre: initialize mediump float gapwidth
|
|
535
|
+
#pragma maplibre: initialize mediump float width
|
|
536
|
+
#pragma maplibre: initialize lowp float floorwidth
|
|
537
|
+
#pragma maplibre: initialize mediump vec4 pattern_from
|
|
538
|
+
#pragma maplibre: initialize mediump vec4 pattern_to
|
|
539
|
+
#pragma maplibre: initialize lowp float pixel_ratio_from
|
|
540
|
+
#pragma maplibre: initialize lowp float pixel_ratio_to
|
|
541
|
+
if (opacity < 0.01) {gl_Position=vec4(-2.0,-2.0,-2.0,1.0);return;}float ANTIALIASING=1.0/u_device_pixel_ratio/2.0;vec2 a_extrude=vec2(ivec2(a_data.xy)-128);float a_direction=float(int(a_data.z & 3u)-1);float a_linesofar=float((a_data.z >> 2u)+a_data.w*64u)*LINE_DISTANCE_SCALE;vec2 pos=vec2(a_pos_normal >> 1);mediump vec2 normal=vec2(a_pos_normal & 1);normal.y=normal.y*2.0-1.0;v_normal=normal;gapwidth=gapwidth/2.0;float halfwidth=width/2.0;offset=-1.0*offset;float inset=gapwidth+(gapwidth > 0.0 ? ANTIALIASING : 0.0);float outset=gapwidth+halfwidth*(gapwidth > 0.0 ? 2.0 : 1.0)+(halfwidth==0.0 ? 0.0 : ANTIALIASING);mediump vec2 dist=outset*a_extrude*scale;mediump float u=0.5*a_direction;mediump float t=1.0-abs(u);mediump vec2 offset2=offset*a_extrude*scale*normal.y*mat2(t,-u,u,t);float adjustedThickness=projectLineThickness(pos.y);vec4 projected_no_extrude=projectTile(pos+offset2/u_ratio*adjustedThickness+u_translation);vec4 projected_with_extrude=projectTile(pos+offset2/u_ratio*adjustedThickness+u_translation+dist/u_ratio*adjustedThickness);gl_Position=projected_with_extrude;
|
|
542
|
+
#ifdef GLOBE
|
|
543
|
+
v_depth=gl_Position.z/gl_Position.w;
|
|
544
|
+
#endif
|
|
545
|
+
#ifdef TERRAIN3D
|
|
546
|
+
v_gamma_scale=1.0;
|
|
547
|
+
#else
|
|
548
|
+
float 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;
|
|
549
|
+
#endif
|
|
550
|
+
v_linesofar=a_linesofar;v_width2=vec2(outset,inset);v_width=floorwidth;}`),lineSDF:be(`uniform lowp float u_lineatlas_width;uniform sampler2D u_image;uniform float u_mix;in vec2 v_normal;flat in vec2 v_width2;in vec2 v_tex_a;in vec2 v_tex_b;in float v_gamma_scale;
|
|
551
|
+
#ifdef GLOBE
|
|
552
|
+
in float v_depth;
|
|
553
|
+
#endif
|
|
554
|
+
#pragma maplibre: define highp vec4 color
|
|
555
|
+
#pragma maplibre: define lowp float blur
|
|
556
|
+
#pragma maplibre: define lowp float opacity
|
|
557
|
+
#pragma maplibre: define mediump float width
|
|
558
|
+
#pragma maplibre: define lowp float floorwidth
|
|
559
|
+
#pragma maplibre: define mediump vec4 dasharray_from
|
|
560
|
+
#pragma maplibre: define mediump vec4 dasharray_to
|
|
561
|
+
void main() {
|
|
562
|
+
#pragma maplibre: initialize highp vec4 color
|
|
563
|
+
#pragma maplibre: initialize lowp float blur
|
|
564
|
+
#pragma maplibre: initialize lowp float opacity
|
|
565
|
+
#pragma maplibre: initialize mediump float width
|
|
566
|
+
#pragma maplibre: initialize lowp float floorwidth
|
|
567
|
+
#pragma maplibre: initialize mediump vec4 dasharray_from
|
|
568
|
+
#pragma maplibre: initialize mediump vec4 dasharray_to
|
|
569
|
+
clipAntimeridian();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);
|
|
570
|
+
#ifdef GLOBE
|
|
571
|
+
if (v_depth > 1.0) {discard;}
|
|
572
|
+
#endif
|
|
573
|
+
#ifdef OVERDRAW_INSPECTOR
|
|
574
|
+
fragColor=vec4(1.0);
|
|
575
|
+
#endif
|
|
576
|
+
}`,`
|
|
577
|
+
#define scale 0.015873016
|
|
578
|
+
#define LINE_DISTANCE_SCALE 2.0
|
|
579
|
+
layout(location=0) in ivec2 a_pos_normal;layout(location=1) in uvec4 a_data;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;flat out vec2 v_width2;out vec2 v_tex_a;out vec2 v_tex_b;out float v_gamma_scale;
|
|
580
|
+
#ifdef GLOBE
|
|
581
|
+
out float v_depth;
|
|
582
|
+
#endif
|
|
583
|
+
#pragma maplibre: define highp vec4 color
|
|
584
|
+
#pragma maplibre: define lowp float blur
|
|
585
|
+
#pragma maplibre: define lowp float opacity
|
|
586
|
+
#pragma maplibre: define mediump float gapwidth
|
|
587
|
+
#pragma maplibre: define lowp float offset
|
|
588
|
+
#pragma maplibre: define mediump float width
|
|
589
|
+
#pragma maplibre: define lowp float floorwidth
|
|
590
|
+
#pragma maplibre: define mediump vec4 dasharray_from
|
|
591
|
+
#pragma maplibre: define mediump vec4 dasharray_to
|
|
592
|
+
void main() {
|
|
593
|
+
#pragma maplibre: initialize highp vec4 color
|
|
594
|
+
#pragma maplibre: initialize lowp float blur
|
|
595
|
+
#pragma maplibre: initialize lowp float opacity
|
|
596
|
+
#pragma maplibre: initialize mediump float gapwidth
|
|
597
|
+
#pragma maplibre: initialize lowp float offset
|
|
598
|
+
#pragma maplibre: initialize mediump float width
|
|
599
|
+
#pragma maplibre: initialize lowp float floorwidth
|
|
600
|
+
#pragma maplibre: initialize mediump vec4 dasharray_from
|
|
601
|
+
#pragma maplibre: initialize mediump vec4 dasharray_to
|
|
602
|
+
if (opacity < 0.01) {gl_Position=vec4(-2.0,-2.0,-2.0,1.0);return;}float ANTIALIASING=1.0/u_device_pixel_ratio/2.0;vec2 a_extrude=vec2(ivec2(a_data.xy)-128);float a_direction=float(int(a_data.z & 3u)-1);float a_linesofar=float((a_data.z >> 2u)+a_data.w*64u)*LINE_DISTANCE_SCALE;vec2 pos=vec2(a_pos_normal >> 1);mediump vec2 normal=vec2(a_pos_normal & 1);normal.y=normal.y*2.0-1.0;v_normal=normal;gapwidth=gapwidth/2.0;float halfwidth=width/2.0;offset=-1.0*offset;float inset=gapwidth+(gapwidth > 0.0 ? ANTIALIASING : 0.0);float outset=gapwidth+halfwidth*(gapwidth > 0.0 ? 2.0 : 1.0)+(halfwidth==0.0 ? 0.0 : ANTIALIASING);mediump vec2 dist=outset*a_extrude*scale;mediump float u=0.5*a_direction;mediump float t=1.0-abs(u);mediump vec2 offset2=offset*a_extrude*scale*normal.y*mat2(t,-u,u,t);float adjustedThickness=projectLineThickness(pos.y);vec4 projected_no_extrude=projectTile(pos+offset2/u_ratio*adjustedThickness+u_translation);vec4 projected_with_extrude=projectTile(pos+offset2/u_ratio*adjustedThickness+u_translation+dist/u_ratio*adjustedThickness);gl_Position=projected_with_extrude;
|
|
603
|
+
#ifdef GLOBE
|
|
604
|
+
v_depth=gl_Position.z/gl_Position.w;
|
|
605
|
+
#endif
|
|
606
|
+
#ifdef TERRAIN3D
|
|
607
|
+
v_gamma_scale=1.0;
|
|
608
|
+
#else
|
|
609
|
+
float 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;
|
|
610
|
+
#endif
|
|
611
|
+
float 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:be(`uniform sampler2D u_image;uniform sampler2D u_image_dash;uniform float u_mix;uniform lowp float u_lineatlas_width;in vec2 v_normal;flat in vec2 v_width2;in vec2 v_tex_a;in vec2 v_tex_b;in float v_gamma_scale;in highp vec2 v_uv;
|
|
612
|
+
#ifdef GLOBE
|
|
613
|
+
in float v_depth;
|
|
614
|
+
#endif
|
|
615
|
+
#pragma maplibre: define lowp float blur
|
|
616
|
+
#pragma maplibre: define lowp float opacity
|
|
617
|
+
#pragma maplibre: define mediump float width
|
|
618
|
+
#pragma maplibre: define lowp float floorwidth
|
|
619
|
+
#pragma maplibre: define mediump vec4 dasharray_from
|
|
620
|
+
#pragma maplibre: define mediump vec4 dasharray_to
|
|
621
|
+
void main() {
|
|
622
|
+
#pragma maplibre: initialize lowp float blur
|
|
623
|
+
#pragma maplibre: initialize lowp float opacity
|
|
624
|
+
#pragma maplibre: initialize mediump float width
|
|
625
|
+
#pragma maplibre: initialize lowp float floorwidth
|
|
626
|
+
#pragma maplibre: initialize mediump vec4 dasharray_from
|
|
627
|
+
#pragma maplibre: initialize mediump vec4 dasharray_to
|
|
628
|
+
clipAntimeridian();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);
|
|
629
|
+
#ifdef GLOBE
|
|
630
|
+
if (v_depth > 1.0) {discard;}
|
|
631
|
+
#endif
|
|
632
|
+
#ifdef OVERDRAW_INSPECTOR
|
|
633
|
+
fragColor=vec4(1.0);
|
|
634
|
+
#endif
|
|
635
|
+
}`,`
|
|
636
|
+
#define scale 0.015873016
|
|
637
|
+
#define LINE_DISTANCE_SCALE 2.0
|
|
638
|
+
layout(location=0) in ivec2 a_pos_normal;layout(location=1) in uvec4 a_data;layout(location=2) in float a_uv_x;layout(location=3) in float a_split_index;uniform vec2 u_translation;uniform mediump float u_ratio;uniform float u_image_height;uniform float u_tileratio;uniform float u_crossfade_from;uniform float u_crossfade_to;uniform float u_lineatlas_height;out vec2 v_normal;flat out vec2 v_width2;out float v_gamma_scale;out highp vec2 v_uv;out vec2 v_tex_a;out vec2 v_tex_b;
|
|
639
|
+
#ifdef GLOBE
|
|
640
|
+
out float v_depth;
|
|
641
|
+
#endif
|
|
642
|
+
#pragma maplibre: define lowp float blur
|
|
643
|
+
#pragma maplibre: define lowp float opacity
|
|
644
|
+
#pragma maplibre: define mediump float gapwidth
|
|
645
|
+
#pragma maplibre: define lowp float offset
|
|
646
|
+
#pragma maplibre: define mediump float width
|
|
647
|
+
#pragma maplibre: define lowp float floorwidth
|
|
648
|
+
#pragma maplibre: define mediump vec4 dasharray_from
|
|
649
|
+
#pragma maplibre: define mediump vec4 dasharray_to
|
|
650
|
+
void main() {
|
|
651
|
+
#pragma maplibre: initialize lowp float blur
|
|
652
|
+
#pragma maplibre: initialize lowp float opacity
|
|
653
|
+
#pragma maplibre: initialize mediump float gapwidth
|
|
654
|
+
#pragma maplibre: initialize lowp float offset
|
|
655
|
+
#pragma maplibre: initialize mediump float width
|
|
656
|
+
#pragma maplibre: initialize lowp float floorwidth
|
|
657
|
+
#pragma maplibre: initialize mediump vec4 dasharray_from
|
|
658
|
+
#pragma maplibre: initialize mediump vec4 dasharray_to
|
|
659
|
+
if (opacity < 0.01) {gl_Position=vec4(-2.0,-2.0,-2.0,1.0);return;}float ANTIALIASING=1.0/u_device_pixel_ratio/2.0;vec2 a_extrude=vec2(ivec2(a_data.xy)-128);float a_direction=float(int(a_data.z & 3u)-1);float a_linesofar=float((a_data.z >> 2u)+a_data.w*64u)*LINE_DISTANCE_SCALE;float texel_height=1.0/u_image_height;float half_texel_height=0.5*texel_height;v_uv=vec2(a_uv_x,a_split_index*texel_height-half_texel_height);vec2 pos=vec2(a_pos_normal >> 1);mediump vec2 normal=vec2(a_pos_normal & 1);normal.y=normal.y*2.0-1.0;v_normal=normal;gapwidth=gapwidth/2.0;float halfwidth=width/2.0;offset=-1.0*offset;float inset=gapwidth+(gapwidth > 0.0 ? ANTIALIASING : 0.0);float outset=gapwidth+halfwidth*(gapwidth > 0.0 ? 2.0 : 1.0)+(halfwidth==0.0 ? 0.0 : ANTIALIASING);mediump vec2 dist=outset*a_extrude*scale;mediump float u=0.5*a_direction;mediump float t=1.0-abs(u);mediump vec2 offset2=offset*a_extrude*scale*normal.y*mat2(t,-u,u,t);float adjustedThickness=projectLineThickness(pos.y);vec4 projected_no_extrude=projectTile(pos+offset2/u_ratio*adjustedThickness+u_translation);vec4 projected_with_extrude=projectTile(pos+offset2/u_ratio*adjustedThickness+u_translation+dist/u_ratio*adjustedThickness);gl_Position=projected_with_extrude;
|
|
660
|
+
#ifdef GLOBE
|
|
661
|
+
v_depth=gl_Position.z/gl_Position.w;
|
|
662
|
+
#endif
|
|
663
|
+
#ifdef TERRAIN3D
|
|
664
|
+
v_gamma_scale=1.0;
|
|
665
|
+
#else
|
|
666
|
+
float 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;
|
|
667
|
+
#endif
|
|
668
|
+
float 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:be(`uniform sampler2D u_image;uniform float u_opacity;in vec2 v_pos;void main() {fragColor=texture(u_image,v_pos)*u_opacity;
|
|
669
|
+
#ifdef OVERDRAW_INSPECTOR
|
|
670
|
+
fragColor=vec4(0.0);
|
|
671
|
+
#endif
|
|
672
|
+
}`,"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:be(`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);
|
|
673
|
+
#ifdef OVERDRAW_INSPECTOR
|
|
674
|
+
fragColor=vec4(1.0);
|
|
675
|
+
#endif
|
|
676
|
+
}`,`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;
|
|
677
|
+
#ifdef GLOBE
|
|
678
|
+
if (a_pos.y <-32767.5) {texturePos.y=0.0;}if (a_pos.y > 32766.5) {texturePos.y=1.0;}
|
|
679
|
+
#endif
|
|
680
|
+
float 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:be(`uniform sampler2D u_texture;in vec2 v_tex;flat in float v_total_opacity;void main() {fragColor=texture(u_texture,v_tex)*v_total_opacity;
|
|
681
|
+
#ifdef OVERDRAW_INSPECTOR
|
|
682
|
+
fragColor=vec4(1.0);
|
|
683
|
+
#endif
|
|
684
|
+
}`,`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;flat out float v_total_opacity;
|
|
685
|
+
#pragma maplibre: define lowp float opacity
|
|
686
|
+
void main() {
|
|
687
|
+
#pragma maplibre: initialize lowp float opacity
|
|
688
|
+
vec2 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 ?
|
|
689
|
+
camera_to_anchor_distance/u_camera_to_center_distance :
|
|
690
|
+
u_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;
|
|
691
|
+
#ifdef GLOBE
|
|
692
|
+
if(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);}
|
|
693
|
+
#endif
|
|
694
|
+
vec4 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:be(`#define SDF_PX 8.0
|
|
695
|
+
uniform 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;
|
|
696
|
+
#pragma maplibre: define highp vec4 fill_color
|
|
697
|
+
#pragma maplibre: define highp vec4 halo_color
|
|
698
|
+
#pragma maplibre: define lowp float halo_width
|
|
699
|
+
#pragma maplibre: define lowp float halo_blur
|
|
700
|
+
void main() {
|
|
701
|
+
#pragma maplibre: initialize highp vec4 fill_color
|
|
702
|
+
#pragma maplibre: initialize highp vec4 halo_color
|
|
703
|
+
#pragma maplibre: initialize lowp float halo_width
|
|
704
|
+
#pragma maplibre: initialize lowp float halo_blur
|
|
705
|
+
float 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;}
|
|
706
|
+
#ifdef OVERDRAW_INSPECTOR
|
|
707
|
+
fragColor=vec4(1.0);
|
|
708
|
+
#endif
|
|
709
|
+
}`,`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;
|
|
710
|
+
#pragma maplibre: define highp vec4 fill_color
|
|
711
|
+
#pragma maplibre: define highp vec4 halo_color
|
|
712
|
+
#pragma maplibre: define lowp float opacity
|
|
713
|
+
#pragma maplibre: define lowp float halo_width
|
|
714
|
+
#pragma maplibre: define lowp float halo_blur
|
|
715
|
+
void main() {
|
|
716
|
+
#pragma maplibre: initialize highp vec4 fill_color
|
|
717
|
+
#pragma maplibre: initialize highp vec4 halo_color
|
|
718
|
+
#pragma maplibre: initialize lowp float opacity
|
|
719
|
+
#pragma maplibre: initialize lowp float halo_width
|
|
720
|
+
#pragma maplibre: initialize lowp float halo_blur
|
|
721
|
+
vec2 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 ?
|
|
722
|
+
camera_to_anchor_distance/u_camera_to_center_distance :
|
|
723
|
+
u_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;
|
|
724
|
+
#ifdef GLOBE
|
|
725
|
+
if(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);}
|
|
726
|
+
#endif
|
|
727
|
+
vec4 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:be(`#define SDF_PX 8.0
|
|
728
|
+
#define SDF 1.0
|
|
729
|
+
#define ICON 0.0
|
|
730
|
+
uniform 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;flat in float v_is_sdf;
|
|
731
|
+
#pragma maplibre: define highp vec4 fill_color
|
|
732
|
+
#pragma maplibre: define highp vec4 halo_color
|
|
733
|
+
#pragma maplibre: define lowp float halo_width
|
|
734
|
+
#pragma maplibre: define lowp float halo_blur
|
|
735
|
+
void main() {
|
|
736
|
+
#pragma maplibre: initialize highp vec4 fill_color
|
|
737
|
+
#pragma maplibre: initialize highp vec4 halo_color
|
|
738
|
+
#pragma maplibre: initialize lowp float halo_width
|
|
739
|
+
#pragma maplibre: initialize lowp float halo_blur
|
|
740
|
+
float 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;
|
|
741
|
+
#ifdef OVERDRAW_INSPECTOR
|
|
742
|
+
fragColor=vec4(1.0);
|
|
743
|
+
#endif
|
|
744
|
+
return;}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;}
|
|
745
|
+
#ifdef OVERDRAW_INSPECTOR
|
|
746
|
+
fragColor=vec4(1.0);
|
|
747
|
+
#endif
|
|
748
|
+
}`,`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;flat out float v_is_sdf;
|
|
749
|
+
#pragma maplibre: define highp vec4 fill_color
|
|
750
|
+
#pragma maplibre: define highp vec4 halo_color
|
|
751
|
+
#pragma maplibre: define lowp float opacity
|
|
752
|
+
#pragma maplibre: define lowp float halo_width
|
|
753
|
+
#pragma maplibre: define lowp float halo_blur
|
|
754
|
+
void main() {
|
|
755
|
+
#pragma maplibre: initialize highp vec4 fill_color
|
|
756
|
+
#pragma maplibre: initialize highp vec4 halo_color
|
|
757
|
+
#pragma maplibre: initialize lowp float opacity
|
|
758
|
+
#pragma maplibre: initialize lowp float halo_width
|
|
759
|
+
#pragma maplibre: initialize lowp float halo_blur
|
|
760
|
+
vec2 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 ?
|
|
761
|
+
camera_to_anchor_distance/u_camera_to_center_distance :
|
|
762
|
+
u_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;
|
|
763
|
+
#ifdef GLOBE
|
|
764
|
+
if(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);}
|
|
765
|
+
#endif
|
|
766
|
+
vec4 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:be("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:be("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;}"),atmosphere:be(`#ifdef GL_ES
|
|
767
|
+
precision highp float;
|
|
768
|
+
#endif
|
|
769
|
+
in 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
|
|
770
|
+
);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:be("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 be(e,t){let r=/#pragma maplibre: ([\w]+) ([\w]+) ([\w]+) ([\w]+)/g,i=t.match(/in ([\w]+) ([\w]+)/g),a=e.match(/uniform ([\w]+) ([\w]+)([\s]*)([\w]*)/g),n=t.match(/uniform ([\w]+) ([\w]+)([\s]*)([\w]*)/g),s=n?n.concat(a):a,o=i?i.length:0,l={};return e=e.replace(r,(u,h,c,d,p)=>(l[p]=!0,h==="define"?`
|
|
771
|
+
#ifndef HAS_UNIFORM_u_${p}
|
|
772
|
+
in ${c} ${d} ${p};
|
|
773
|
+
#else
|
|
774
|
+
uniform ${c} ${d} u_${p};
|
|
775
|
+
#endif
|
|
776
|
+
`:`
|
|
777
|
+
#ifdef HAS_UNIFORM_u_${p}
|
|
778
|
+
${c} ${d} ${p} = u_${p};
|
|
779
|
+
#endif
|
|
780
|
+
`)),t=t.replace(r,(u,h,c,d,p)=>{let f=d==="float"?"vec2":"vec4",m=p.match(/color/)?"color":f;return l[p]?h==="define"?`
|
|
781
|
+
#ifndef HAS_UNIFORM_u_${p}
|
|
782
|
+
uniform lowp float u_${p}_t;
|
|
783
|
+
layout(location = ${o++}) in ${c} ${f} a_${p};
|
|
784
|
+
out ${c} ${d} ${p};
|
|
785
|
+
#else
|
|
786
|
+
uniform ${c} ${d} u_${p};
|
|
787
|
+
#endif
|
|
788
|
+
`:m==="vec4"?`
|
|
789
|
+
#ifndef HAS_UNIFORM_u_${p}
|
|
790
|
+
${p} = a_${p};
|
|
791
|
+
#else
|
|
792
|
+
${c} ${d} ${p} = u_${p};
|
|
793
|
+
#endif
|
|
794
|
+
`:`
|
|
795
|
+
#ifndef HAS_UNIFORM_u_${p}
|
|
796
|
+
${p} = unpack_mix_${m}(a_${p}, u_${p}_t);
|
|
797
|
+
#else
|
|
798
|
+
${c} ${d} ${p} = u_${p};
|
|
799
|
+
#endif
|
|
800
|
+
`:h==="define"?`
|
|
801
|
+
#ifndef HAS_UNIFORM_u_${p}
|
|
802
|
+
uniform lowp float u_${p}_t;
|
|
803
|
+
layout(location = ${o++}) in ${c} ${f} a_${p};
|
|
804
|
+
#else
|
|
805
|
+
uniform ${c} ${d} u_${p};
|
|
806
|
+
#endif
|
|
807
|
+
`:m==="vec4"?`
|
|
808
|
+
#ifndef HAS_UNIFORM_u_${p}
|
|
809
|
+
${c} ${d} ${p} = a_${p};
|
|
810
|
+
#else
|
|
811
|
+
${c} ${d} ${p} = u_${p};
|
|
812
|
+
#endif
|
|
813
|
+
`:`
|
|
814
|
+
#ifndef HAS_UNIFORM_u_${p}
|
|
815
|
+
${c} ${d} ${p} = unpack_mix_${m}(a_${p}, u_${p}_t);
|
|
816
|
+
#else
|
|
817
|
+
${c} ${d} ${p} = u_${p};
|
|
818
|
+
#endif
|
|
819
|
+
`}),{fragmentSource:e,vertexSource:t,staticAttributes:i,staticUniforms:s}}const O1="#define PROJECTION_MERCATOR",$1="mercator";var Bc=class{constructor(){this._cachedMesh=null}get name(){return"mercator"}get useSubdivision(){return!1}get shaderVariantName(){return $1}get shaderDefine(){return O1}get shaderPreludeCode(){return Vr.projectionMercator}get vertexShaderPreludeCode(){return Vr.projectionMercator.vertexSource}get subdivisionGranularity(){return wd.noSubdivision}get useGlobeControls(){return!1}get transitionState(){return 0}destroy(){}getMeshFromTileID(e,t,r,i,a){if(this._cachedMesh)return this._cachedMesh;let n=new vi;n.emplaceBack(0,0),n.emplaceBack(L,0),n.emplaceBack(0,L),n.emplaceBack(L,L);let s=e.createVertexBuffer(n,Vi.members),o=Ze.simpleSegment(0,0,4,2),l=new Yr;l.emplaceBack(1,0,2),l.emplaceBack(1,2,3);let u=e.createIndexBuffer(l);return this._cachedMesh=new bs(s,u,o),this._cachedMesh}recalculate(){}hasTransition(){return!1}},tg=class j1{constructor(t=0,r=0,i=0,a=0){if(isNaN(t)||t<0||isNaN(r)||r<0||isNaN(i)||i<0||isNaN(a)||a<0)throw Error("Invalid value for edge-insets, top, bottom, left and right must all be numbers");this.top=t,this.bottom=r,this.left=i,this.right=a}interpolate(t,r,i){return r.top!=null&&t.top!=null&&(this.top=We.number(t.top,r.top,i)),r.bottom!=null&&t.bottom!=null&&(this.bottom=We.number(t.bottom,r.bottom,i)),r.left!=null&&t.left!=null&&(this.left=We.number(t.left,r.left,i)),r.right!=null&&t.right!=null&&(this.right=We.number(t.right,r.right,i)),this}getCenter(t,r){let i=se((this.left+t-this.right)/2,0,t),a=se((this.top+r-this.bottom)/2,0,r);return new M(i,a)}equals(t){return this.top===t.top&&this.bottom===t.bottom&&this.left===t.left&&this.right===t.right}clone(){return new j1(this.top,this.bottom,this.left,this.right)}toJSON(){return{top:this.top,bottom:this.bottom,left:this.left,right:this.right}}};function pl(e,t){if(!e.renderWorldCopies||e.lngRange)return;let r=t.lng-e.center.lng;t.lng+=r>180?-360:r<-180?360:0}function rg(e){return Math.max(0,Math.floor(e))}var Jd=class{constructor(e,t){this.applyConstrain=(r,i)=>this._constrainOverride===null?this._callbacks.defaultConstrain(r,i):this._constrainOverride(r,i),this._callbacks=e,this._tileSize=512,this._renderWorldCopies=(t==null?void 0:t.renderWorldCopies)===void 0||!!(t!=null&&t.renderWorldCopies),this._minZoom=(t==null?void 0:t.minZoom)||0,this._maxZoom=(t==null?void 0:t.maxZoom)||22,this._minPitch=(t==null?void 0:t.minPitch)===void 0||(t==null?void 0:t.minPitch)===null?0:t==null?void 0:t.minPitch,this._maxPitch=(t==null?void 0:t.maxPitch)===void 0||(t==null?void 0:t.maxPitch)===null?60:t==null?void 0:t.maxPitch,this._constrainOverride=(t==null?void 0:t.constrainOverride)??null,this.setMaxBounds(),this._width=0,this._height=0,this._center=new ee(0,0),this._elevation=0,this._zoom=0,this._tileZoom=rg(this._zoom),this._scale=$t(this._zoom),this._bearingInRadians=0,this._fovInRadians=.6435011087932844,this._pitchInRadians=0,this._rollInRadians=0,this._unmodified=!0,this._edgeInsets=new tg,this._minElevationForCurrentTile=0,this._autoCalculateNearFarZ=!0}apply(e,t){this._constrainOverride=e.constrainOverride,this._latRange=e.latRange,this._lngRange=e.lngRange,this._width=e.width,this._height=e.height,this._center=e.center,this._elevation=e.elevation,this._minElevationForCurrentTile=e.minElevationForCurrentTile,this._zoom=e.zoom,this._tileZoom=rg(this._zoom),this._scale=$t(this._zoom),this._bearingInRadians=e.bearingInRadians,this._fovInRadians=e.fovInRadians,this._pitchInRadians=e.pitchInRadians,this._rollInRadians=e.rollInRadians,this._unmodified=e.unmodified,this._edgeInsets=new tg(e.padding.top,e.padding.bottom,e.padding.left,e.padding.right),this._minZoom=e.minZoom,this._maxZoom=e.maxZoom,this._minPitch=e.minPitch,this._maxPitch=e.maxPitch,this._renderWorldCopies=e.renderWorldCopies,this._cameraToCenterDistance=e.cameraToCenterDistance,this._nearZ=e.nearZ,this._farZ=e.farZ,this._autoCalculateNearFarZ=e.autoCalculateNearFarZ,t&&this.constrainInternal(),this._calcMatrices()}get pixelsToClipSpaceMatrix(){return this._pixelsToClipSpaceMatrix}get clipSpaceToPixelsMatrix(){return this._clipSpaceToPixelsMatrix}get minElevationForCurrentTile(){return this._minElevationForCurrentTile}setMinElevationForCurrentTile(e){this._minElevationForCurrentTile=e}get tileSize(){return this._tileSize}get tileZoom(){return this._tileZoom}get scale(){return this._scale}get width(){return this._width}get height(){return this._height}get bearingInRadians(){return this._bearingInRadians}get lngRange(){return this._lngRange}get latRange(){return this._latRange}get pixelsToGLUnits(){return this._pixelsToGLUnits}get minZoom(){return this._minZoom}setMinZoom(e){if(this._minZoom===e)return;this._minZoom=e;let t=this._unmodified;this.setZoom(this.applyConstrain(this._center,this.zoom).zoom),this._unmodified=t}get maxZoom(){return this._maxZoom}setMaxZoom(e){if(this._maxZoom===e)return;this._maxZoom=e;let t=this._unmodified;this.setZoom(this.applyConstrain(this._center,this.zoom).zoom),this._unmodified=t}get minPitch(){return this._minPitch}setMinPitch(e){if(this._minPitch===e)return;this._minPitch=e;let t=this._unmodified;this.setPitch(Math.max(this.pitch,e)),this._unmodified=t}get maxPitch(){return this._maxPitch}setMaxPitch(e){if(this._maxPitch===e)return;this._maxPitch=e;let t=this._unmodified;this.setPitch(Math.min(this.pitch,e)),this._unmodified=t}get renderWorldCopies(){return this._renderWorldCopies}setRenderWorldCopies(e){e===void 0?e=!0:e===null&&(e=!1),this._renderWorldCopies=e}get constrainOverride(){return this._constrainOverride}setConstrainOverride(e){e===void 0&&(e=null),this._constrainOverride!==e&&(this._constrainOverride=e,this.constrainInternal(),this._calcMatrices())}get worldSize(){return this._tileSize*this._scale}get centerOffset(){return this.centerPoint._sub(this.size._div(2))}get size(){return new M(this._width,this._height)}get bearing(){return this._bearingInRadians/Math.PI*180}setBearing(e){let t=fr(e,-180,180)*Math.PI/180;this._bearingInRadians!==t&&(this._unmodified=!1,this._bearingInRadians=t,this._calcMatrices(),this._rotationMatrix=p1(),mC(this._rotationMatrix,this._rotationMatrix,-this._bearingInRadians))}get rotationMatrix(){return this._rotationMatrix}get pitchInRadians(){return this._pitchInRadians}get pitch(){return this._pitchInRadians/Math.PI*180}setPitch(e){let t=se(e,this.minPitch,this.maxPitch)/180*Math.PI;this._pitchInRadians!==t&&(this._unmodified=!1,this._pitchInRadians=t,this._calcMatrices())}get rollInRadians(){return this._rollInRadians}get roll(){return this._rollInRadians/Math.PI*180}setRoll(e){let t=e/180*Math.PI;this._rollInRadians!==t&&(this._unmodified=!1,this._rollInRadians=t,this._calcMatrices())}get fovInRadians(){return this._fovInRadians}get fov(){return $r(this._fovInRadians)}setFov(e){e=se(e,.1,150),this.fov!==e&&(this._unmodified=!1,this._fovInRadians=Ge(e),this._calcMatrices())}get zoom(){return this._zoom}setZoom(e){let t=this.applyConstrain(this._center,e).zoom;this._zoom!==t&&(this._unmodified=!1,this._zoom=t,this._tileZoom=Math.max(0,Math.floor(t)),this._scale=$t(t),this.constrainInternal(),this._calcMatrices())}get center(){return this._center}setCenter(e){(e.lat!==this._center.lat||e.lng!==this._center.lng)&&(this._unmodified=!1,this._center=e,this.constrainInternal(),this._calcMatrices())}get elevation(){return this._elevation}setElevation(e){e!==this._elevation&&(this._elevation=e,this.constrainInternal(),this._calcMatrices())}get padding(){return this._edgeInsets.toJSON()}setPadding(e){this._edgeInsets.equals(e)||(this._unmodified=!1,this._edgeInsets.interpolate(this._edgeInsets,e,1),this._calcMatrices())}get centerPoint(){return this._edgeInsets.getCenter(this._width,this._height)}get pixelsPerMeter(){return this._pixelPerMeter}get unmodified(){return this._unmodified}get cameraToCenterDistance(){return this._cameraToCenterDistance}get nearZ(){return this._nearZ}get farZ(){return this._farZ}get autoCalculateNearFarZ(){return this._autoCalculateNearFarZ}overrideNearFarZ(e,t){this._autoCalculateNearFarZ=!1,this._nearZ=e,this._farZ=t,this._calcMatrices()}clearNearFarZOverride(){this._autoCalculateNearFarZ=!0,this._calcMatrices()}isPaddingEqual(e){return this._edgeInsets.equals(e)}interpolatePadding(e,t,r){this._unmodified=!1,this._edgeInsets.interpolate(e,t,r),this.constrainInternal(),this._calcMatrices()}resize(e,t,r=!0){this._width=e,this._height=t,r&&this.constrainInternal(),this._calcMatrices()}getMaxBounds(){var e,t;return((e=this._latRange)==null?void 0:e.length)!==2||((t=this._lngRange)==null?void 0:t.length)!==2?null:new Wr([this._lngRange[0],this._latRange[0]],[this._lngRange[1],this._latRange[1]])}setMaxBounds(e){e?(this._lngRange=[e.getWest(),e.getEast()],this._latRange=[e.getSouth(),e.getNorth()],this.constrainInternal()):(this._lngRange=null,this._latRange=[-Gr,Gr])}getCameraQueryGeometry(e,t){if(t.length===1)return[t[0],e];{let{minX:r,minY:i,maxX:a,maxY:n}=Er.fromPoints(t).extend(e);return[new M(r,i),new M(a,i),new M(a,n),new M(r,n),new M(r,i)]}}constrainInternal(){if(!this.center||!this._width||!this._height||this._constraining)return;this._constraining=!0;let e=this._unmodified,{center:t,zoom:r}=this.applyConstrain(this.center,this.zoom);this.setCenter(t),this.setZoom(r),this._unmodified=e,this._constraining=!1}_calcMatrices(){if(this._pixelPerMeter=qi(1,this.center.lat)*this.worldSize,!this._width||!this._height)return;this._pixelsToGLUnits=[2/this._width,-2/this._height];let e=Pr(new Float64Array(16));Et(e,e,[this._width/2,-this._height/2,1]),ot(e,e,[1,-1,0]),this._clipSpaceToPixelsMatrix=e,e=Pr(new Float64Array(16)),Et(e,e,[1,-1,1]),ot(e,e,[-1,-1,0]),Et(e,e,[2/this._width,2/this._height,1]),this._pixelsToClipSpaceMatrix=e;let t=this.fovInRadians/2;this._cameraToCenterDistance=.5/Math.tan(t)*this._height,this._callbacks.calcMatrices()}calculateCenterFromCameraLngLatAlt(e,t,r,i){let a=r===void 0?this.bearing:r,n=i=i===void 0?this.pitch:i,{distanceToCenter:s,clampedElevation:o}=this._distanceToCenterFromAltElevationPitch(t,this.elevation,n),{x:l,y:u}=fc(n,a),h=Ie.fromLngLat(e,t),c=n0(1,h.y),d,p,f=0;do{if(f+=1,f>10)break;p=s/c;let m=l*p,g=u*p;d=new Ie(h.x+m,h.y+g),c=1/d.meterInMercatorCoordinateUnits()}while(Math.abs(s-p*c)>1e-12);return{center:d.toLngLat(),elevation:o,zoom:It(this.height/2/Math.tan(this.fovInRadians/2)/p/this.tileSize)}}recalculateZoomAndCenter(e){if(this.elevation-e===0)return;let t=1/this.worldSize,r=qi(1,this.center.lat)*this.worldSize,i=Ie.fromLngLat(this.center,this.elevation),a=i.x/t,n=i.y/t,s=i.z/t,o=this.pitch,l=this.bearing,{x:u,y:h,z:c}=fc(o,l),d=this.cameraToCenterDistance,p=a+d*-u,f=n+d*-h,m=s+d*c,{distanceToCenter:g,clampedElevation:_}=this._distanceToCenterFromAltElevationPitch(m/r,e,o),y=g*r,v=p+u*y,x=f+h*y,w=new Ie(v*t,x*t,0).toLngLat(),b=qi(1,w.lat),S=It(this.height/2/Math.tan(this.fovInRadians/2)/g/b/this.tileSize);this._elevation=_,this._center=w,this.setZoom(S)}_distanceToCenterFromAltElevationPitch(e,t,r){let i=-Math.cos(Ge(r)),a=e-t,n,s=t;return i*a>=0||Math.abs(i)<Math.cos(Ge(89.25))?(n=1e4,s=e+n*i):n=-a/i,{distanceToCenter:n,clampedElevation:s}}getCameraPoint(){let e=this.pitchInRadians,t=Math.tan(e)*(this.cameraToCenterDistance||1);return this.centerPoint.add(new M(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/L,1/t/L]}},OM=class{distanceToTile2d(e,t,r,i){let a=i,n=a.distanceX([e,t]),s=a.distanceY([e,t]);return Math.hypot(n,s)}getWrap(e,t,r){return r}getTileBoundingVolume(e,t,r,i){let a=Math.min(0,r),n=Math.max(0,r);if(i!=null&&i.terrain){let o=new Dt(e.z,t,e.z,e.x,e.y),l=i.terrain.getMinMaxElevation(o);a=l.minElevation??a,n=l.maxElevation??n}let s=1<<e.z;return new qd([t+e.x/s,e.y/s,a],[t+(e.x+1)/s,(e.y+1)/s,n])}allowVariableZoom(e,t){let r=e.fov*(Math.abs(Math.cos(e.rollInRadians))*e.height+Math.abs(Math.sin(e.rollInRadians))*e.width)/e.height,i=se(78.5-r/2,0,60);return!!t.terrain||e.pitch>i}allowWorldCopies(){return!0}prepareNextFrame(){}};const $M=Ye([{name:"a_pos3d",type:"Int16",components:3}]);var jM=class extends kt{constructor(e){super(),this._lastTilesetChange=Fe(),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 r={},i=!1;for(let a of en(e,{tileSize:this.tileSize,minzoom:this.minzoom,maxzoom:this.maxzoom,reparseOverscaled:!1,terrain:t}))r[a.key]=!0,this._renderableTilesKeys.push(a.key),this._tiles[a.key]||(a.terrainRttPosMatrix32f=new Float32Array(16),Lr(a.terrainRttPosMatrix32f,0,L,L,0,0,1),this._tiles[a.key]=new A1(a,this.tileSize),this._lastTilesetChange=Fe(),i=!0);for(let a in this._tiles)r[a]||(this._tiles[a].releaseRTT(this.tileManager.map.painter),delete this._tiles[a],i=!0);return i}releaseRTT(e){for(let t in this._tiles){let r=this._tiles[t];(r.tileID.equals(e)||r.tileID.isChildOf(e)||e.isChildOf(r.tileID))&&r.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 r of this._renderableTilesKeys){let i=this._tiles[r].tileID,a=e.clone(),n=Bi();if(i.canonical.equals(e.canonical))Lr(n,0,L,L,0,0,1);else if(i.canonical.isChildOf(e.canonical)){let s=i.canonical.z-e.canonical.z,o=i.canonical.x-(i.canonical.x>>s<<s),l=i.canonical.y-(i.canonical.y>>s<<s),u=L>>s;Lr(n,0,u,u,0,0,1),ot(n,n,[-o*u,-l*u,0])}else if(e.canonical.isChildOf(i.canonical)){let s=e.canonical.z-i.canonical.z,o=e.canonical.x-(e.canonical.x>>s<<s),l=e.canonical.y-(e.canonical.y>>s<<s),u=L>>s;Lr(n,0,L,L,0,0,1),ot(n,n,[o*u,l*u,0]),Et(n,n,[1/2**s,1/2**s,0])}else continue;a.terrainRttPosMatrix32f=new Float32Array(n),t[r]=a}return t}_getTerrainCoordsForTileRanges(e,t){let r={};for(let i of this._renderableTilesKeys){let a=this._tiles[i].tileID;if(!this._isWithinTileRanges(a,t))continue;let n=e.clone(),s=Bi();if(a.canonical.z===e.canonical.z){let o=e.canonical.x-a.canonical.x+e.wrap*(1<<e.canonical.z),l=e.canonical.y-a.canonical.y;Lr(s,0,L,L,0,0,1),ot(s,s,[o*L,l*L,0])}else if(a.canonical.z>e.canonical.z){let o=a.canonical.z-e.canonical.z,l=a.canonical.x-(a.canonical.x>>o<<o)+e.wrap*(1<<a.canonical.z),u=a.canonical.y-(a.canonical.y>>o<<o),h=e.canonical.x-(a.canonical.x>>o),c=e.canonical.y-(a.canonical.y>>o),d=L>>o;Lr(s,0,d,d,0,0,1),ot(s,s,[-l*d+h*L,-u*d+c*L,0])}else{let o=e.canonical.z-a.canonical.z,l=e.canonical.x-(e.canonical.x>>o<<o)+e.wrap*(1<<e.canonical.z),u=e.canonical.y-(e.canonical.y>>o<<o),h=(e.canonical.x>>o)-a.canonical.x,c=(e.canonical.y>>o)-a.canonical.y,d=L<<o;Lr(s,0,d,d,0,0,1),ot(s,s,[l*L+h*d,u*L+c*d,0])}n.terrainRttPosMatrix32f=new Float32Array(s),r[i]=n}return r}getSourceTile(e,t){var n,s;let r=this.tileManager._source,i=e.overscaledZ-this.deltaZoom;if(i>r.maxzoom&&(i=r.maxzoom),i<r.minzoom)return;(n=this._sourceTileCache)[s=e.key]||(n[s]=e.scaledTo(i).key);let a=this.findTileInCaches(this._sourceTileCache[e.key]);if(!(a!=null&&a.dem)&&t)for(;i>=r.minzoom&&!(a!=null&&a.dem);)a=this.findTileInCaches(e.scaledTo(i--).key);return a}findTileInCaches(e){let t=this.tileManager.getTileByID(e);return t||(t=this.tileManager._outOfViewCache.getByKey(e),t)}anyTilesAfterTime(e=Fe()){return this._lastTilesetChange>=e}_isWithinTileRanges(e,t){let r=t[e.canonical.z];return!!r&&(e.wrap>r.minWrap||e.wrap<r.maxWrap||e.canonical.x>=r.minTileXWrapped&&e.canonical.x<=r.maxTileXWrapped&&e.canonical.y>=r.minTileY&&e.canonical.y<=r.maxTileY)}};const ig=L*(1-1e-12),ag=-.5;var VM=class{constructor(e,t,r,i="auto"){this._meshCache={},this.painter=e,this.tileManager=new jM(t),this.options=r,this.exaggeration=typeof r.exaggeration=="number"?r.exaggeration:1,this._terrainSkirtLength=i,this.qualityFactor=2,this.meshSize=128,this._demMatrixCache=new Map,this._elevationSamplerCache=new Map}destroy(){this._fbo&&(this._fbo=(this._fbo.destroy(),null)),this._fboDepthTexture&&(this._fboDepthTexture=(this._fboDepthTexture.destroy(),null)),this._emptyDemTexture&&(this._emptyDemTexture=(this._emptyDemTexture.destroy(),null)),this._emptyDepthTexture&&(this._emptyDepthTexture=(this._emptyDepthTexture.destroy(),null));for(let e in this._meshCache)this._meshCache[e].destroy();this._meshCache={},this.tileManager.destruct()}getDEMElevation(e,t,r,i=L){let a=e.normalizeCoordinates(t,r,i);if(!a)return 0;let n=this.getElevationSampler(a.tileID);return n?n(a.x,a.y,i):0}getElevationForLngLatZoom(e,t){if(!nm(t,e.wrap()))return 0;let{tileID:r,mercatorX:i,mercatorY:a}=this._getOverscaledTileIDFromLngLatZoom(e,t);return this.getElevation(r,i%L,a%L,L)}getElevationForLngLat(e,t){let r=this.getCoverageIndex();if(r){let n=Ie.fromLngLat(e),s=Qd(r,this.exaggeration,n.x,n.y);if(s.demLoaded)return s.elevation}let i=en(t,{maxzoom:this.tileManager.maxzoom,minzoom:this.tileManager.minzoom,tileSize:512,terrain:this}),a=0;for(let n of i)n.canonical.z>a&&(a=Math.min(n.canonical.z,this.tileManager.maxzoom));return this.getElevationForLngLatZoom(e,a)}getElevation(e,t,r,i=L){return this.getDEMElevation(e,t,r,i)*this.exaggeration}resetElevationCache(){this._elevationSamplerCache.clear(),this._coverageIndex=void 0}getCoverageIndex(){return this._coverageIndex===void 0&&(this._coverageIndex=this._buildCoverageIndex()),this._coverageIndex}_buildCoverageIndex(){let e=[],t=new Map,r=0,i=0;for(let a of this.tileManager.getRenderableTiles()){if(!a)continue;let{canonical:n,wrap:s}=a.tileID;e.includes(n.z)||e.push(n.z);let o=this.getElevationSampler(a.tileID);t.set(`${s}/${n.z}/${n.x}/${n.y}`,o);let{minElevation:l,maxElevation:u}=this.getMinMaxElevation(a.tileID);r=Math.min(r,l??0),i=Math.max(i,u??0)}return t.size===0?null:(e.sort((a,n)=>n-a),{zooms:e,samplerPerTile:t,minElevation:r-10,maxElevation:i+10})}getElevationSampler(e){let t=e.key,r=this._elevationSamplerCache.get(t);if(r)return r;let i=this.tileManager.getSourceTile(e,!0),a=i==null?void 0:i.dem;if(!i||!a)return null;let n=this._getDEMTileMatrix(e,i),s=n[0]*a.dim,o=n[5]*a.dim,l=n[12]*a.dim+ag,u=n[13]*a.dim+ag,h=(c,d,p)=>{let f=p===8192?1:L/p;return a.sampleBilinear(c*f*s+l,d*f*o+u)};return this._elevationSamplerCache.set(t,h),h}_getDEMTileMatrix(e,t){let r=`${t.tileID.key}/${e.key}`,i=this._demMatrixCache.get(r);if(i)return i;let a=e.canonical.z-t.tileID.canonical.z,n=e.canonical.x-(e.canonical.x>>a<<a),s=e.canonical.y-(e.canonical.y>>a<<a),o=Nx(new Float64Array(16),[1/(L<<a),1/(L<<a),0]);return ot(o,o,[n*L,s*L,0]),this._demMatrixCache.set(r,o),o}getTerrainData(e){var i,a;if(!this._emptyDemTexture){let n=this.painter.context,s=new $e({width:1,height:1},new Uint8Array(4));this._emptyDepthTexture=new dt(n,s,n.gl.RGBA,{premultiply:!1}),this._emptyDemUnpack=[0,0,0,0],this._emptyDemTexture=new dt(n,new $e({width:1,height:1}),n.gl.RGBA,{premultiply:!1}),this._emptyDemTexture.bind(n.gl.NEAREST,n.gl.CLAMP_TO_EDGE),this._emptyDemMatrix=Pr([])}let t=this.tileManager.getSourceTile(e,!0);if(t!=null&&t.dem&&(!t.demTexture||t.needsTerrainPrepare)){let n=this.painter.context;t.demTexture||(t.demTexture=this.painter.getTileTexture(t.dem.stride)),t.demTexture?t.demTexture.update(t.dem.getPixels(),{premultiply:!1}):t.demTexture=new dt(n,t.dem.getPixels(),n.gl.RGBA,{premultiply:!1}),t.demTexture.bind(n.gl.NEAREST,n.gl.CLAMP_TO_EDGE),t.needsTerrainPrepare=!1}let r=t?this._getDEMTileMatrix(e,t):this._emptyDemMatrix;return{u_depth:2,u_terrain:3,u_terrain_dim:((i=t==null?void 0:t.dem)==null?void 0:i.dim)||1,u_terrain_matrix:r,u_terrain_unpack:((a=t==null?void 0:t.dem)==null?void 0:a.getUnpackVector())||this._emptyDemUnpack,u_terrain_exaggeration:this.exaggeration,texture:((t==null?void 0:t.demTexture)||this._emptyDemTexture).texture,depthTexture:(this._fboDepthTexture||this._emptyDepthTexture).texture,tile:t}}getFramebuffer(){let e=this.painter,t=e.width/devicePixelRatio,r=e.height/devicePixelRatio;return this._fbo&&(this._fbo.width!==t||this._fbo.height!==r)&&(this._fbo.destroy(),this._fboDepthTexture.destroy(),delete this._fbo,delete this._fboDepthTexture),this._fboDepthTexture||(this._fboDepthTexture=new dt(e.context,{width:t,height:r,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,r,!0,!1),this._fbo.depthAttachment.set(e.context.createRenderbuffer(e.context.gl.DEPTH_COMPONENT16,t,r))),this._fbo.colorAttachment.set(this._fboDepthTexture.texture),this._fbo}getTerrainMesh(e){var d;let t=((d=this.painter.style.projection)==null?void 0:d.transitionState)>0,r=t&&e.canonical.y===0,i=t&&e.canonical.y===(1<<e.canonical.z)-1,a=`m_${r?"n":""}_${i?"s":""}`;if(this._meshCache[a])return this._meshCache[a];let n=this.painter.context,s=new N2,o=new Yr,l=this.meshSize,u=L/l,h=l*l;for(let p=0;p<=l;p++)for(let f=0;f<=l;f++)s.emplaceBack(f*u,p*u,0);for(let p=0;p<h;p+=l+1)for(let f=0;f<l;f++)o.emplaceBack(f+p,l+f+p+1,l+f+p+2),o.emplaceBack(f+p,l+f+p+2,f+p+1);this._terrainSkirtLength!=="none"&&this._buildSkirts(s,o,l,u,r,i);let c=new bs(n.createVertexBuffer(s,$M.members),n.createIndexBuffer(o),Ze.simpleSegment(0,0,s.length,o.length));return this._meshCache[a]=c,c}getSkirtLength(e){return 2*Math.PI*Lt/2**Math.max(e,0)/5}getMinTileElevationForLngLatZoom(e,t){if(!nm(t,e.wrap()))return 0;let{tileID:r}=this._getOverscaledTileIDFromLngLatZoom(e,t);return this.getMinMaxElevation(r).minElevation??0}getMinMaxElevation(e){let t=this.tileManager.getSourceTile(e,!0),r={minElevation:null,maxElevation:null};return t!=null&&t.dem&&(r.minElevation=t.dem.min*this.exaggeration,r.maxElevation=t.dem.max*this.exaggeration),r}_getOverscaledTileIDFromLngLatZoom(e,t){let r=Ie.fromLngLat(e.wrap()),i=(1<<t)*L,a=r.x*i,n=r.y*i,s=Math.floor(a/L),o=Math.floor(n/L);return{tileID:new Dt(t,0,t,s,o),mercatorX:a,mercatorY:n}}_buildSkirts(e,t,r,i,a,n){let s=e.length,o=s+(r+1),l=(r+1)*r,u=a?Bn:0,h=+!a,c=n?On:L,d=+!n;for(let m=0;m<=r;m++)e.emplaceBack(m*i,u,h);for(let m=0;m<=r;m++)e.emplaceBack(m*i,c,d);for(let m=0;m<r;m++)t.emplaceBack(l+m,o+m,o+m+1),t.emplaceBack(l+m,o+m+1,l+m+1),t.emplaceBack(0+m,s+m+1,s+m),t.emplaceBack(0+m,0+m+1,s+m+1);let p=e.length,f=p+(r+1)*2;for(let m of[0,1])for(let g=0;g<=r;g++)for(let _ of[0,1])e.emplaceBack(m*L,g*i,_);for(let m=0;m<r*2;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)}};const ng={covered:!1,demLoaded:!1,elevation:0};function Qd(e,t,r,i){if(i<0||i>=1)return ng;let a=Math.floor(r),n=r-a;for(let s of e.zooms){let o=1<<s,l=n*o,u=i*o,h=Math.floor(l),c=Math.floor(u),d=`${a}/${s}/${h}/${c}`;if(!e.samplerPerTile.has(d))continue;let p=e.samplerPerTile.get(d);return p?{covered:!0,demLoaded:!0,elevation:p(Math.min((l-h)*L,ig),Math.min((u-c)*L,ig),L)*t}:{covered:!0,demLoaded:!1,elevation:0}}return ng}function V1(e,t){return e.covered&&t<=e.elevation+1e-6}function N1(e,t,r,i,a){for(let n=0;n<40&&i-r>a;n++){let s=(r+i)/2;t(e,s)?i=s:r=s}return{lo:r,hi:i}}var fl=class U1{get pixelsToClipSpaceMatrix(){return this._helper.pixelsToClipSpaceMatrix}get clipSpaceToPixelsMatrix(){return this._helper.clipSpaceToPixelsMatrix}get pixelsToGLUnits(){return this._helper.pixelsToGLUnits}get centerOffset(){return this._helper.centerOffset}get size(){return this._helper.size}get rotationMatrix(){return this._helper.rotationMatrix}get centerPoint(){return this._helper.centerPoint}get pixelsPerMeter(){return this._helper.pixelsPerMeter}setMinZoom(t){this._helper.setMinZoom(t)}setMaxZoom(t){this._helper.setMaxZoom(t)}setMinPitch(t){this._helper.setMinPitch(t)}setMaxPitch(t){this._helper.setMaxPitch(t)}setRenderWorldCopies(t){this._helper.setRenderWorldCopies(t)}setBearing(t){this._helper.setBearing(t)}setPitch(t){this._helper.setPitch(t)}setRoll(t){this._helper.setRoll(t)}setFov(t){this._helper.setFov(t)}setZoom(t){this._helper.setZoom(t)}setCenter(t){this._helper.setCenter(t)}setElevation(t){this._helper.setElevation(t)}setMinElevationForCurrentTile(t){this._helper.setMinElevationForCurrentTile(t)}setPadding(t){this._helper.setPadding(t)}interpolatePadding(t,r,i){this._helper.interpolatePadding(t,r,i)}isPaddingEqual(t){return this._helper.isPaddingEqual(t)}resize(t,r,i=!0){this._helper.resize(t,r,i)}getMaxBounds(){return this._helper.getMaxBounds()}setMaxBounds(t){this._helper.setMaxBounds(t)}setConstrainOverride(t){this._helper.setConstrainOverride(t)}overrideNearFarZ(t,r){this._helper.overrideNearFarZ(t,r)}clearNearFarZOverride(){this._helper.clearNearFarZOverride()}getCameraQueryGeometry(t){return this._helper.getCameraQueryGeometry(this.getCameraPoint(),t)}get tileSize(){return this._helper.tileSize}get tileZoom(){return this._helper.tileZoom}get scale(){return this._helper.scale}get worldSize(){return this._helper.worldSize}get width(){return this._helper.width}get height(){return this._helper.height}get lngRange(){return this._helper.lngRange}get latRange(){return this._helper.latRange}get minZoom(){return this._helper.minZoom}get maxZoom(){return this._helper.maxZoom}get zoom(){return this._helper.zoom}get center(){return this._helper.center}get minPitch(){return this._helper.minPitch}get maxPitch(){return this._helper.maxPitch}get pitch(){return this._helper.pitch}get pitchInRadians(){return this._helper.pitchInRadians}get roll(){return this._helper.roll}get rollInRadians(){return this._helper.rollInRadians}get bearing(){return this._helper.bearing}get bearingInRadians(){return this._helper.bearingInRadians}get fov(){return this._helper.fov}get fovInRadians(){return this._helper.fovInRadians}get elevation(){return this._helper.elevation}get minElevationForCurrentTile(){return this._helper.minElevationForCurrentTile}get padding(){return this._helper.padding}get unmodified(){return this._helper.unmodified}get renderWorldCopies(){return this._helper.renderWorldCopies}get cameraToCenterDistance(){return this._helper.cameraToCenterDistance}get constrainOverride(){return this._helper.constrainOverride}get nearZ(){return this._helper.nearZ}get farZ(){return this._helper.farZ}get autoCalculateNearFarZ(){return this._helper.autoCalculateNearFarZ}setTransitionState(t){}constructor(t,r){this._posMatrixCache=new Map,this._alignedPosMatrixCache=new Map,this._fogMatrixCacheF32=new Map,this.defaultConstrain=(i,a)=>{a=se(+a,this.minZoom,this.maxZoom);let n={center:new ee(i.lng,i.lat),zoom:a},s=this._helper._lngRange;!this._helper._renderWorldCopies&&s===null&&(s=[-179.9999999999,180-1e-10]);let o=this.tileSize*$t(n.zoom),l=0,u=o,h=0,c=o,d=0,p=0,{x:f,y:m}=this.size;if(this._helper._latRange){let w=this._helper._latRange;l=Ha(w[1])*o,u=Ha(w[0])*o,u-l<m&&(d=m/(u-l))}s&&(h=fr(Wa(s[0])*o,0,o),c=fr(Wa(s[1])*o,0,o),c<h&&(c+=o),c-h<f&&(p=f/(c-h)));let{x:g,y:_}=jr(o,i),y,v,x=Math.max(p||0,d||0);if(x){let w=new M(p?(c+h)/2:g,d?(u+l)/2:_);return n.center=ss(o,w).wrap(),n.zoom+=It(x),n}if(this._helper._latRange){let w=m/2;_-w<l&&(v=l+w),_+w>u&&(v=u-w)}if(s){let w=(h+c)/2,b=g;this._helper._renderWorldCopies&&(b=fr(g,w-o/2,w+o/2));let S=f/2;b-S<h&&(y=h+S),b+S>c&&(y=c-S)}if(y!==void 0||v!==void 0){let w=new M(y??g,v??_);n.center=ss(o,w).wrap()}return n},this.applyConstrain=(i,a)=>this._helper.applyConstrain(i,a),this._helper=r??new Jd({calcMatrices:()=>this._calcMatrices(),defaultConstrain:(i,a)=>this.defaultConstrain(i,a)},t),this._coveringTilesDetailsProvider=new OM}clone(){let t=new U1;return t.apply(this,!1),t}apply(t,r){this._helper.apply(t,r)}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(t){let r=[new ul(0,t)];if(this._helper._renderWorldCopies){let i=this.screenPointToMercatorCoordinate(new M(0,0)),a=this.screenPointToMercatorCoordinate(new M(this._helper._width,0)),n=this.screenPointToMercatorCoordinate(new M(this._helper._width,this._helper._height)),s=this.screenPointToMercatorCoordinate(new M(0,this._helper._height)),o=Math.floor(Math.min(i.x,a.x,n.x,s.x)),l=Math.floor(Math.max(i.x,a.x,n.x,s.x));for(let u=o-1;u<=l+1;u++)u!==0&&r.push(new ul(u,t))}return r}getCameraFrustum(){return Zd.fromInvProjectionMatrix(this._invViewProjMatrix,this.worldSize)}getClippingPlane(){return null}getCoveringTilesDetailsProvider(){return this._coveringTilesDetailsProvider}recalculateZoomAndCenter(t){let r=this.screenPointToLocation(this.centerPoint,t),i=t?t.getElevationForLngLat(r,this):0;this._helper.recalculateZoomAndCenter(i)}setLocationAtPoint(t,r,i=this.elevation){let a=i-this.elevation,n=this.screenPointToMercatorCoordinateAtZ(r,a),s=this.screenPointToMercatorCoordinateAtZ(this.centerPoint,0),o=Ie.fromLngLat(t),l=new Ie(o.x-(n.x-s.x),o.y-(n.y-s.y));this.setCenter(l==null?void 0:l.toLngLat()),this._helper._renderWorldCopies&&this.setCenter(this.center.wrap())}locationToScreenPoint(t,r){return r?this.coordinatePoint(Ie.fromLngLat(t),r.getElevationForLngLat(t,this),this._pixelMatrix3D):this.coordinatePoint(Ie.fromLngLat(t))}screenPointToLocation(t,r){var i;return(i=this.screenPointToMercatorCoordinate(t,r))==null?void 0:i.toLngLat()}screenPointToLocationAtElevation(t,r){var i;return(i=this.screenPointToMercatorCoordinateAtZ(t,r-this.elevation))==null?void 0:i.toLngLat()}screenPointToMercatorCoordinate(t,r){if(r){let i=this.screenTerrainPointToMercatorCoordinate(t,r);if(i!=null)return i}return this.screenPointToMercatorCoordinateAtZ(t)}screenTerrainPointToMercatorCoordinate(t,r){let i=r.getCoverageIndex();if(!i)return null;let{near:a,far:n}=this.getRaySegmentFromPixel(t),s=this.worldSize,o=n[0]-a[0],l=n[1]-a[1],u=n[2]-a[2],h={index:i,exaggeration:r.exaggeration,near:a,dx:o,dy:l,dz:u,worldSize:s},c=0,d=1;if(u===0){if(a[2]>i.maxElevation||a[2]<i.minElevation)return null}else{let _=(i.maxElevation-a[2])/u,y=(i.minElevation-a[2])/u;if(c=Math.max(c,Math.min(_,y)),d=Math.min(d,Math.max(_,y)),c>d)return null}let p=Math.hypot(o,l),f=se(Math.ceil(p*(d-c)/4),1,512),m=0,g=!co(h,0);for(let _=0;_<=f;_++){let y=c+(d-c)*_/f;if(!g)g=!co(h,y);else if(co(h,y)){let{lo:v,hi:x}=N1(h,co,m,y,.001/p),w=ko(h,v),b=ko(h,x),S=a[2]+v*u-w.elevation,A=a[2]+x*u-b.elevation,P=w.covered&&S>A?se(v+S*(x-v)/(S-A),v,x):x;return new Ie((a[0]+P*o)/s,(a[1]+P*l)/s,ko(h,P).elevation)}m=y}return null}getRaySegmentFromPixel(t){let r=[t.x,t.y,0,1],i=[t.x,t.y,1,1];Pt(r,r,this._pixelMatrixInverse),Pt(i,i,this._pixelMatrixInverse);let a=r[3],n=i[3],s=this.elevation;return{near:[r[0]/a,r[1]/a,r[2]/a+s],far:[i[0]/n,i[1]/n,i[2]/n+s]}}screenPointToMercatorCoordinateAtZ(t,r){let i=r||0,{near:a,far:n}=this.getRaySegmentFromPixel(t),s=a[2]===n[2]?0:(i+this.elevation-a[2])/(n[2]-a[2]);return new Ie(We.number(a[0],n[0],s)/this.worldSize,We.number(a[1],n[1],s)/this.worldSize,i)}coordinatePoint(t,r=0,i=this._pixelMatrix){let a=this._coordinateClipPoint(t,r,i),n=a[3];return n>0?new M(a[0]/n,a[1]/n):this._offScreenPointBehindCamera(a[0],a[1],n)}_coordinateClipPoint(t,r,i){let a=[t.x*this.worldSize,t.y*this.worldSize,r,1];return Pt(a,a,i)}_offScreenPointBehindCamera(t,r,i){let a=this.width/2,n=this.height/2,s=t-a*i,o=r-n*i;s===0&&o===0&&(o=1);let l=a+this.width,u=n+this.height,h=Math.min(s===0?1/0:l/Math.abs(s),o===0?1/0:u/Math.abs(o));return new M(a+s*h,n+o*h)}getBounds(){let t=Math.max(0,this._helper._height/2-jn(this));return new Wr().extend(this.screenPointToLocation(new M(0,t))).extend(this.screenPointToLocation(new M(this._helper._width,t))).extend(this.screenPointToLocation(new M(this._helper._width,this._helper._height))).extend(this.screenPointToLocation(new M(0,this._helper._height)))}isPointOnMapSurface(t,r){return r?this.screenTerrainPointToMercatorCoordinate(t,r)!=null:t.y>this.centerPoint.y-jn(this)}calculatePosMatrix(t,r=!1,i=!1){let a=t.key??Ra(t.wrap,t.canonical.z,t.canonical.z,t.canonical.x,t.canonical.y),n=r?this._alignedPosMatrixCache:this._posMatrixCache;if(n.has(a)){let l=n.get(a);return i?l.f32:l.f64}let s=Bu(t,this.worldSize);ba(s,r?this._alignedProjMatrix:this._viewProjMatrix,s);let o={f64:s,f32:new Float32Array(s)};return n.set(a,o),i?o.f32:o.f64}calculateFogMatrix(t){let r=t.key,i=this._fogMatrixCacheF32;if(i.has(r))return i.get(r);let a=Bu(t,this.worldSize);return ba(a,this._fogMatrix,a),i.set(r,new Float32Array(a)),i.get(r)}calculateCenterFromCameraLngLatAlt(t,r,i,a){return this._helper.calculateCenterFromCameraLngLatAlt(t,r,i,a)}calculateCameraOptionsFromTo(t,r,i,a){let n=Ie.fromLngLat(t,r),s=Ie.fromLngLat(i,a),o=s.x-n.x,l=s.y-n.y,u=s.z-n.z,h=Math.hypot(o,l,u);if(h===0)throw Error("Can't calculate camera options with same From and To");let c=Math.hypot(o,l),d=It(this.cameraToCenterDistance/h/this.tileSize),p=$r(Math.atan2(o,-l)),f=$r(Math.acos(c/h));return f=u<0?90-f:90+f,{center:s.toLngLat(),elevation:a,zoom:d,pitch:f,bearing:p}}_calculateNearFarZ(t,r,i){let a=Math.min(this.elevation,this.minElevationForCurrentTile,this.getCameraAltitude()-100),n=t-a*this._helper._pixelPerMeter/Math.cos(r),s=a<0?n:t,o=Math.PI/2+this.pitchInRadians,l=Ge(this.fov)*(Math.abs(Math.cos(Ge(this.roll)))*this.height+Math.abs(Math.sin(Ge(this.roll)))*this.width)/this.height*(.5+i.y/this.height),u=Math.sin(l)*s/Math.sin(se(Math.PI-o-l,.01,Math.PI-.01)),h=jn(this),c=Math.atan(h/this._helper.cameraToCenterDistance),d=Ge(90-Zi),p=c>d?2*c*(.5+i.y/(h*2)):d,f=Math.sin(p)*s/Math.sin(se(Math.PI-o-p,.01,Math.PI-.01)),m=Math.min(u,f);this._helper._farZ=(Math.cos(Math.PI/2-r)*m+s)*1.01,this._helper._nearZ=this._helper._height/50}_calcMatrices(t=this._helper.autoCalculateNearFarZ){let r=this.centerOffset,i=jr(this.worldSize,this.center),a=i.x,n=i.y,s=Ge(Math.min(this.pitch,Zi)),o=Math.max(this._helper.cameraToCenterDistance/2,this._helper.cameraToCenterDistance+this._helper._elevation*this._helper._pixelPerMeter/Math.cos(s));t&&this._calculateNearFarZ(o,s,r);let l;l=new Float64Array(16),dh(l,this.fovInRadians,this._helper._width/this._helper._height,this._helper._nearZ,this._helper._farZ),this._invProjMatrix=new Float64Array(16),sM(this._invProjMatrix,l),l[8]=-r.x*2/this._helper._width,l[9]=r.y*2/this._helper._height,this._projectionMatrix=ch(l),Et(l,l,[1,-1,1]),ot(l,l,[0,0,-this._helper.cameraToCenterDistance]),yi(l,l,-this.rollInRadians),Oa(l,l,this.pitchInRadians),yi(l,l,-this.bearingInRadians),ot(l,l,[-a,-n,0]),this._mercatorMatrix=Et([],l,[this.worldSize,this.worldSize,this.worldSize]),Et(l,l,[1,1,this._helper._pixelPerMeter]),this._pixelMatrix=ba(new Float64Array(16),this.clipSpaceToPixelsMatrix,l),ot(l,l,[0,0,-this.elevation]),this._viewProjMatrix=l,this._invViewProjMatrix=Bo([],l);let u=[0,0,-1,1];Pt(u,u,this._invViewProjMatrix),this._cameraPosition=[u[0]/u[3],u[1]/u[3],u[2]/u[3]],this._fogMatrix=new Float64Array(16),dh(this._fogMatrix,this.fovInRadians,this.width/this.height,o,this._helper._farZ),this._fogMatrix[8]=-r.x*2/this.width,this._fogMatrix[9]=r.y*2/this.height,Et(this._fogMatrix,this._fogMatrix,[1,-1,1]),ot(this._fogMatrix,this._fogMatrix,[0,0,-this.cameraToCenterDistance]),yi(this._fogMatrix,this._fogMatrix,-this.rollInRadians),Oa(this._fogMatrix,this._fogMatrix,this.pitchInRadians),yi(this._fogMatrix,this._fogMatrix,-this.bearingInRadians),ot(this._fogMatrix,this._fogMatrix,[-a,-n,0]),Et(this._fogMatrix,this._fogMatrix,[1,1,this._helper._pixelPerMeter]),ot(this._fogMatrix,this._fogMatrix,[0,0,-this.elevation]),this._pixelMatrix3D=ba(new Float64Array(16),this.clipSpaceToPixelsMatrix,l);let h=this._helper._width%2/2,c=this._helper._height%2/2,d=Math.cos(this.bearingInRadians),p=Math.sin(-this.bearingInRadians),f=a-Math.round(a)+d*h+p*c,m=n-Math.round(n)+d*c+p*h,g=new Float64Array(l);if(ot(g,g,[f>.5?f-1:f,m>.5?m-1:m,0]),this._alignedProjMatrix=g,l=Bo(new Float64Array(16),this._pixelMatrix),!l)throw Error("failed to invert matrix");this._pixelMatrixInverse=l,this._clearMatrixCaches()}_clearMatrixCaches(){this._posMatrixCache.clear(),this._alignedPosMatrixCache.clear(),this._fogMatrixCacheF32.clear()}maxPitchScaleFactor(){if(!this._pixelMatrixInverse)return 1;let t=this.screenPointToMercatorCoordinate(new M(0,0)),r=[t.x*this.worldSize,t.y*this.worldSize,0,1];return Pt(r,r,this._pixelMatrix)[3]/this._helper.cameraToCenterDistance}getCameraPoint(){return this._helper.getCameraPoint()}getCameraAltitude(){return Math.cos(this.pitchInRadians)*this.cameraToCenterDistance/this.pixelsPerMeter+this.elevation}getCameraLngLat(){let t=qi(1,this.center.lat)*this.worldSize,r=this._helper.cameraToCenterDistance/t;return l0(this.center,this.elevation,this.pitch,this.bearing,r).toLngLat()}getProjectionData(t){let{overscaledTileID:r,aligned:i,applyTerrainMatrix:a}=t,n=this._helper.getMercatorTileCoordinates(r),s=r?this.calculatePosMatrix(r,i,!0):null,o;return o=r!=null&&r.terrainRttPosMatrix32f&&a?r.terrainRttPosMatrix32f:s||Ng(),{mainMatrix:o,tileMercatorCoords:n,clippingPlane:[0,0,0,0],projectionTransition:0,fallbackMatrix:o,clipAntimeridian:!1}}isLocationOccluded(t,r,i){if(!(r!=null&&r.getCoverageIndex()))return!1;let a=Ie.fromLngLat(t);i??(i=r.getElevationForLngLat(t,this));let n=this._coordinateClipPoint(a,i,this._pixelMatrix3D),s=n[3];if(s<=0||n[2]>s)return!0;let o=new M(n[0]/s,n[1]/s),l=this.screenTerrainPointToMercatorCoordinate(o,r);if(l==null)return!1;let u=this.getRaySegmentFromPixel(o),h=sg(u,a.x*this.worldSize,a.y*this.worldSize,i);return sg(u,l.x*this.worldSize,l.y*this.worldSize,l.z)<h*.99}getPixelScale(){return 1}getCircleRadiusCorrection(){return 1}getPitchedTextCorrection(t,r,i){return 1}transformLightDirection(t){return ph(t)}getRayDirectionFromPixel(t){throw Error("Not implemented.")}projectTileCoordinates(t,r,i,a){let n=this.calculatePosMatrix(i),s;a==null?(s=[t,r,0,1],Kd(s,s,n)):(s=[t,r,a,1],Pt(s,s,n));let o=s[3];return{point:new M(s[0]/o,s[1]/o),signedDistanceFromCamera:o,isOccluded:!1}}populateCache(t){for(let r of t)this.calculatePosMatrix(r)}getProjectionDataForCustomLayer(t=!0){let r=new Dt(0,0,0,0,0),i=this.getProjectionData({overscaledTileID:r,applyGlobeMatrix:t}),a=Bu(r,this.worldSize);ba(a,this._viewProjMatrix,a);let n=[L,L,this.worldSize/this._helper.pixelsPerMeter],s=Bi();return Et(s,a,n),{...i,tileMercatorCoords:[0,0,1,1],fallbackMatrix:s,mainMatrix:s}}getFastPathSimpleProjectionMatrix(t){return this.calculatePosMatrix(t)}};function ko(e,t){return Qd(e.index,e.exaggeration,(e.near[0]+t*e.dx)/e.worldSize,(e.near[1]+t*e.dy)/e.worldSize)}function co(e,t){return V1(ko(e,t),e.near[2]+t*e.dz)}function sg({near:e,far:t},r,i,a){let n=t[0]-e[0],s=t[1]-e[1],o=t[2]-e[2];return((r-e[0])*n+(i-e[1])*s+(a-e[2])*o)/(n*n+s*s+o*o)}function G1(){_e("Map cannot fit within canvas with the given bounds, padding, and/or offset.")}function q1(e){if(e.useSlerp)if(e.k<1){let t=Gp(e.startEulerAngles.roll,e.startEulerAngles.pitch,e.startEulerAngles.bearing),r=Gp(e.endEulerAngles.roll,e.endEulerAngles.pitch,e.endEulerAngles.bearing),i=new Float64Array(4);To(i,t,r,e.k);let a=Dv(i);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(We.number(e.startEulerAngles.roll,e.endEulerAngles.roll,e.k)),e.tr.setPitch(We.number(e.startEulerAngles.pitch,e.endEulerAngles.pitch,e.k)),e.tr.setBearing(We.number(e.startEulerAngles.bearing,e.endEulerAngles.bearing,e.k))}function Z1(e,t,r,i,a){let n=a.padding,s=jr(a.worldSize,r.getNorthWest()),o=jr(a.worldSize,r.getNorthEast()),l=jr(a.worldSize,r.getSouthEast()),u=jr(a.worldSize,r.getSouthWest()),h=Ge(-i),c=s.rotate(h),d=o.rotate(h),p=l.rotate(h),f=u.rotate(h),m=new M(Math.max(c.x,d.x,f.x,p.x),Math.max(c.y,d.y,f.y,p.y)),g=new M(Math.min(c.x,d.x,f.x,p.x),Math.min(c.y,d.y,f.y,p.y)),_=m.sub(g),y=a.width-(n.left+n.right+t.left+t.right),v=a.height-(n.top+n.bottom+t.top+t.bottom),x=y/_.x,w=v/_.y;if(w<0||x<0){G1();return}let b=Math.min(It(a.scale*Math.min(x,w)),e.maxZoom),S=M.convert(e.offset),A=(t.left-t.right)/2,P=(t.top-t.bottom)/2,I=new M(A,P).rotate(Ge(i)),R=S.add(I).mult(a.scale/$t(b));return{center:ss(a.worldSize,s.add(l).div(2).sub(R)),zoom:b,bearing:i}}var ml=class{get useGlobeControls(){return!1}handlePanInertia(e,t){let r=e.mag(),i=Math.abs(jn(t));return{easingOffset:e.mult(Math.min(i*.75/r,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,r){e.around.distSqr(t.centerPoint)<.01||t.setLocationAtPoint(r,e.around,e.aroundElevation)}cameraForBoxAndBearing(e,t,r,i,a){return Z1(e,t,r,i,a)}handleJumpToCenterZoom(e,t){let r=t.zoom===void 0?e.zoom:+t.zoom;e.zoom!==r&&e.setZoom(+t.zoom),t.center!==void 0&&e.setCenter(ee.convert(t.center))}handleEaseTo(e,t){let r=e.zoom,i=e.padding,a={roll:e.roll,pitch:e.pitch,bearing:e.bearing},n={roll:t.roll===void 0?e.roll:t.roll,pitch:t.pitch===void 0?e.pitch:t.pitch,bearing:t.bearing===void 0?e.bearing:t.bearing},s=t.zoom!==void 0,o=!e.isPaddingEqual(t.padding),l=!1,u=s?+t.zoom:e.zoom,h=e.centerPoint.add(t.offsetAsPoint),c=e.screenPointToLocation(h),{center:d,zoom:p}=e.applyConstrain(ee.convert(t.center||c),u??r);pl(e,d);let f=jr(e.worldSize,c),m=jr(e.worldSize,d).sub(f),g=$t(p-r);l=p!==r;let _=v=>{if(l&&e.setZoom(We.number(r,p,v)),qg(a,n)||q1({startEulerAngles:a,endEulerAngles:n,tr:e,k:v,useSlerp:a.roll!=n.roll}),o&&(e.interpolatePadding(i,t.padding,v),h=e.centerPoint.add(t.offsetAsPoint)),t.around)e.setLocationAtPoint(t.around,t.aroundPoint);else{let x=$t(e.zoom-r),w=(p>r?Math.min(2,g):Math.max(.5,g))**(1-v),b=ss(e.worldSize,f.add(m.mult(v*w)).mult(x));e.setLocationAtPoint(e.renderWorldCopies?b.wrap():b,h)}},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:_,isZooming:l,elevationCenter:y.center}}handleFlyTo(e,t){let r=t.zoom!==void 0,i=e.zoom,a=e.applyConstrain(ee.convert(t.center||t.locationAtOffset),r?+t.zoom:i),n=a.center,s=a.zoom;pl(e,n);let o=e.worldSize,l=jr(o,t.locationAtOffset),u=jr(o,n).sub(l),h=u.mag(),c=$t(s-i),d=t.minZoom===void 0?e.minZoom:+t.minZoom,p=Math.max(d,e.minZoom),f=Math.min(p,i,s),m=e.applyConstrain(n,f).zoom,g=$t(m-i),_=(v,x,w,b)=>{e.setZoom(v===1?s:i+It(x));let S=v===1?n:ss(o,l.add(u.mult(w)));e.setLocationAtPoint(e.renderWorldCopies?S.wrap():S,b)},y=this._transformAtAnimationEnd(e,s,{roll:t.roll,pitch:t.pitch,bearing:t.bearing},t.padding);return y.setLocationAtPoint(n,y.centerPoint.add(t.offsetAsPoint)),{easeFunc:_,scaleOfZoom:c,targetCenter:y.center,scaleOfMinZoom:g,pixelPathLength:h}}_transformAtAnimationEnd(e,t,r,i){let a=e.clone();return a.setZoom(t),a.setRoll(r.roll),a.setPitch(r.pitch),a.setBearing(r.bearing),a.setPadding(i),a}};let NM;const UM=()=>NM||(NM=new wt({type:new N(z.projection.type,"type")})),Yu=new wd({fill:new ii(128,2),line:new ii(512,0),tile:new ii(128,32),stencil:new ii(128,1),circle:3});var W1=class{constructor(){this._tileMeshCache={}}get name(){return"vertical-perspective"}get transitionState(){return 1}get useSubdivision(){return!0}get shaderVariantName(){return"globe"}get shaderDefine(){return"#define GLOBE"}get shaderPreludeCode(){return Vr.projectionGlobe}get vertexShaderPreludeCode(){return Vr.projectionMercator.vertexSource}get subdivisionGranularity(){return Yu}get useGlobeControls(){return!0}destroy(){}_getMeshKey(e){return`${e.granularity.toString(36)}_${e.generateBorders?"b":""}${e.extendToNorthPole?"n":""}${e.extendToSouthPole?"s":""}`}getMeshFromTileID(e,t,r,i,a){let n=(a==="stencil"?Yu.stencil:Yu.tile).getGranularityForZoomLevel(t.z),s=t.y===0&&i,o=t.y===(1<<t.z)-1&&i;return this._getMesh(e,{granularity:n,generateBorders:r,extendToNorthPole:s,extendToSouthPole:o})}_getMesh(e,t){let r=this._getMeshKey(t);if(r in this._tileMeshCache)return this._tileMeshCache[r];let i=E1(e,t);return this._tileMeshCache[r]=i,i}recalculate(e){}hasTransition(){return!1}},og=class extends kt{constructor(e,t){super(),this._transitionable=new Rl(UM(),"projection",t),this.setProjection(e),this._transitioning=this._transitionable.untransitioned(),this.recalculate(new ze(0)),this._mercatorProjection=new Bc,this._verticalPerspectiveProjection=new W1}get transitionState(){let e=this.properties.get("type");if(typeof e=="string"&&e==="mercator")return 0;if(typeof e=="string"&&e==="vertical-perspective")return 1;if(e instanceof Ai){if(e.from===e.to)return e.from==="mercator"?0:1;if(e.from==="vertical-perspective"&&e.to==="mercator")return 1-e.transition;if(e.from==="mercator"&&e.to==="vertical-perspective")return e.transition}return 1}get useGlobeRendering(){return this.transitionState>0}get currentProjection(){return this.useGlobeRendering?this._verticalPerspectiveProjection:this._mercatorProjection}get name(){return"globe"}get useSubdivision(){return this.currentProjection.useSubdivision}get shaderVariantName(){return this.currentProjection.shaderVariantName}get shaderDefine(){return this.currentProjection.shaderDefine}get shaderPreludeCode(){return this.currentProjection.shaderPreludeCode}get vertexShaderPreludeCode(){return this.currentProjection.vertexShaderPreludeCode}get subdivisionGranularity(){return this.currentProjection.subdivisionGranularity}get useGlobeControls(){return this.transitionState>0}destroy(){this._mercatorProjection.destroy(),this._verticalPerspectiveProjection.destroy()}getMeshFromTileID(e,t,r,i,a){return this.currentProjection.getMeshFromTileID(e,t,r,i,a)}setProjection(e){this._transitionable.setValue("type",(e==null?void 0: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 H1(e){let t=Xa(e.worldSize,e.center.lat);return 2*Math.PI*t}function GM(e,t,r){let i=mt(t),a=mt(r),n=lt(i,a),s=Math.acos(n),o=H1(e);return s/(2*Math.PI)*o}function qM(e,t){return[Xi(e*Math.PI*2+Math.PI,Math.PI*2),2*Math.atan(Math.exp(Math.PI-t*Math.PI*2))-Math.PI*.5]}function ZM(e,t){let r=Math.cos(t),i=new Float64Array(3);return i[0]=Math.sin(e)*r,i[1]=Math.sin(t),i[2]=Math.cos(e)*r,i}function mi(e,t,r,i,a){let n=1/(1<<a),s=e/L*n+r*n,o=t/L*n+i*n,l=Xi(s*Math.PI*2+Math.PI,Math.PI*2),u=2*Math.atan(Math.exp(Math.PI-o*Math.PI*2))-Math.PI*.5,h=Math.cos(u),c=new Float64Array(3);return c[0]=Math.sin(l)*h,c[1]=Math.sin(u),c[2]=Math.cos(l)*h,c}function mt(e){return ZM(e.lng*Math.PI/180,e.lat*Math.PI/180)}function Xa(e,t){return e/(2*Math.PI)/Math.cos(t*Math.PI/180)}function X1(e){let t=Pt(Li(),[0,0,0,1],e.modelViewProjectionMatrix);return Pt(t,t,e.inverseProjectionMatrix),[t[0]/t[3],t[1]/t[3],t[2]/t[3]]}function Vn(e){let t=Math.asin(e[1])/Math.PI*180,r=Math.sqrt(e[0]*e[0]+e[2]*e[2]);if(r>1e-6){let i=e[0]/r,a=e[2]/r,n=Math.acos(a),s=(i>0?n:-n)/Math.PI*180;return new ee(fr(s,-180,180),t)}return new ee(0,t)}function WM(e,t){return Gc(Li(),-e.lng,-e.lat,t)}function HM(e){let t=e[0],r=e[1],i=e[2],a=e[3];return{lng:-Math.atan2(2*(a*t+r*i),1-2*(t*t+r*r))*180/Math.PI,lat:-Math.asin(se(2*(a*r-i*t),-1,1))*180/Math.PI,bearing:Math.atan2(2*(a*i+t*r),1-2*(r*r+i*i))*180/Math.PI}}const Ku=Math.PI*.98;function lg(e,t){let r=e.cameraPosition,i=Sr(r);if(i<=1)return e.screenPointToLocation(t);let a=Pe();Bt(a,r);let n=e.getRayDirectionFromPixel(t),s=-lt(n,a),o=Pe();Oo(o,n,a,s);let l=Sr(o);if(l<1e-9)return e.screenPointToLocation(t);let u=Math.atan2(l,s),h=Math.asin(1/i)*.9;if(u<h)return e.screenPointToLocation(t);let c=i*Math.sin(h),d=Math.asin(se(c,-1,1))-h,p=i*Math.cos(h)/Math.sqrt(Math.max(1-c*c,1e-12))-1,f=Ku-d,m=u-h,g=d+p*m*f/(f+p*m),_=Pe();Ve(_,o,1/l);let y=Pe();return Ve(y,a,Math.cos(se(g,0,Ku))),Oo(y,y,_,Math.sin(se(g,0,Ku))),Bt(y,y),Vn(y)}function XM(e,t,r,i,a=!0){let n=lg(e,r),s=t;if(i)s=lg(e,r.sub(i));else if(!e.isPointOnMapSurface(r))return;let o=mt(n),l=mt(s),u=WM(e.center,e.bearing),h=Ht(Pe(),l,o),c=Math.sqrt(lt(h,h)),d=Math.acos(se(lt(l,o),-1,1))/2,p=Math.sin(d),f=c?Bp(h[1]/c*p,-h[0]/c*p,h[2]/c*p,Math.cos(d)):Bp(0,0,0,1),{lng:m,lat:g,bearing:_}=HM(nv(Li(),u,f)),y=e.center.lat,v=e.zoom,x=se(g,-90,90),w=a?YM(e,r,i,m):m;e.setCenter(new ee(fr(w,-180,180),x)),a||e.setBearing(_),e.setZoom(v+xt(y,e.center.lat))}function YM(e,t,r,i){let a=e.center.lng,n=e.center.lat,s=n>=0?90:-90,o=e.locationToScreenPoint(new ee(0,s)),l=t.x-o.x,u=t.y-o.y,h=l*l+u*u,c=se(1-(Gr-Math.abs(n))/12,0,1),d=c*c*(3-2*c),p=Xi(i-a+180,360)-180,f=0;if(d>0&&r){let m=(l*r.y-u*r.x)/Math.max(h,400);f=(s>0?1:-1)*m*180/Math.PI}return a+(1-d)*p+d*f}function KM(e){let t=Pe();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])}}function JM(e,t,r){let i=Pe();li(i,r,e);let a=Pe();return Oo(a,e,i,t/$o(i)),a}function gl(e){return Math.cos(e*Math.PI/180)}function xt(e,t){let r=gl(e),i=gl(t);return It(i/r)}function QM(e,t){return 360/H1({worldSize:e,center:{lat:t}})}function e3(e,t){let r=e.rotate(t.bearingInRadians),i=t.zoom+xt(t.center.lat,0),a=Ia(1/gl(t.center.lat),1/gl(Math.min(Math.abs(t.center.lat),60)),So(i,7,3,0,1)),n=QM(t.worldSize,t.center.lat);return new ee(t.center.lng-r.x*n*a,se(t.center.lat+r.y*n,-Gr,Gr))}function Ju(e){let t=.5*e,r=Math.sin(t),i=Math.cos(t);return Math.log(r+i)-Math.log(i-r)}function ug(e,t,r,i){let a=e.lat+r*i;if(Math.abs(r)>1){let n=e.lat+r,s=(Math.sign(n)===Math.sign(e.lat)?Math.abs(e.lat):-Math.abs(e.lat))*Math.PI/180,o=Math.abs(e.lat+r)*Math.PI/180,l=Ju(s+i*(o-s)),u=Ju(s),h=Ju(o),c=(l-u)/(h-u),d=e.lng+t*c;return new ee(d,a)}{let n=e.lng+t*i;return new ee(n,a)}}function po(e,t,r=1){let i=lt(e,t),a=r*r,n=Pe(),s=Pe();Ve(s,t,i),li(n,e,s);let o=a-lt(n,n);if(o<0)return null;let l=lt(e,e)-a,u=-i+(i<0?1:-1)*Math.sqrt(o),h=l/u,c=u,d=Math.max(h,c);return d<0?null:{tMin:Math.min(h,c),tMax:d}}function Y1(e,t){let r=t*.01569612305760477,i=se((e-r)/(9*r),0,1);return i*i*(3-2*i)}var t3=class{constructor(e){this._cachePrevious=new Map,this._cache=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,r,i){let a=`${e.z}_${e.x}_${e.y}_${i!=null&&i.terrain?"t":""}_${Math.round(r)}`,n=this._cache.get(a);if(n)return n;let s=this._cachePrevious.get(a);if(s)return this._cache.set(a,s),s;let o=this._boundingVolumeFactory(e,t,r,i);return this._cache.set(a,o),this._hadAnyChanges=!0,o}},Qu=class Oc{constructor(t,r,i,a){this.min=i,this.max=a,this.points=t,this.planes=r}static fromAabb(t,r){let i=[];for(let a=0;a<8;a++)i.push([(a>>0&1)==1?r[0]:t[0],(a>>1&1)==1?r[1]:t[1],(a>>2&1)==1?r[2]:t[2]]);return new Oc(i,[[-1,0,0,r[0]],[1,0,0,-t[0]],[0,-1,0,r[1]],[0,1,0,-t[1]],[0,0,-1,r[2]],[0,0,1,-t[2]]],t,r)}static fromCenterSizeAngles(t,r,i){let a=Gc([],i[0],i[1],i[2]),n=wu([],[r[0],0,0],a),s=wu([],[0,r[1],0],a),o=wu([],[0,0,r[2]],a),l=[...t],u=[...t];for(let c=0;c<8;c++)for(let d=0;d<3;d++){let p=t[d]+n[d]*((c>>0&1)==1?1:-1)+s[d]*((c>>1&1)==1?1:-1)+o[d]*((c>>2&1)==1?1:-1);l[d]=Math.min(l[d],p),u[d]=Math.max(u[d],p)}let h=[];for(let c=0;c<8;c++){let d=[...t];pr(d,d,Ve([],n,(c>>0&1)==1?1:-1)),pr(d,d,Ve([],s,(c>>1&1)==1?1:-1)),pr(d,d,Ve([],o,(c>>2&1)==1?1:-1)),h.push(d)}return new Oc(h,[[...n,-lt(n,h[0])],[...s,-lt(s,h[0])],[...o,-lt(o,h[0])],[-n[0],-n[1],-n[2],-lt(n,h[7])],[-s[0],-s[1],-s[2],-lt(s,h[7])],[-o[0],-o[1],-o[2],-lt(o,h[7])]],l,u)}intersectsFrustum(t){let r=!0,i=this.points.length,a=this.planes.length,n=t.planes.length,s=t.points.length;for(let o=0;o<n;o++){let l=t.planes[o],u=0;for(let h=0;h<i;h++){let c=this.points[h];l[0]*c[0]+l[1]*c[1]+l[2]*c[2]+l[3]>=0&&u++}if(u===0)return 0;u<i&&(r=!1)}if(r)return 2;for(let o=0;o<a;o++){let l=this.planes[o],u=0;for(let h=0;h<s;h++){let c=t.points[h];l[0]*c[0]+l[1]*c[1]+l[2]*c[2]+l[3]>=0&&u++}if(u===0)return 0}return 1}intersectsPlane(t){let r=this.points.length,i=0;for(let a=0;a<r;a++){let n=this.points[a];t[0]*n[0]+t[1]*n[1]+t[2]*n[2]+t[3]>=0&&i++}return i===r?2:i===0?0:1}};function Lo(e,t,r){let i=e-t;return i<0?-i:Math.max(0,i-r)}function eh(e,t,r,i,a){let n=e-r,s;return s=n<0?Math.min(-n,1+n-a):n>a?Math.min(Math.max(n-a,0),1-n):0,Math.max(s,Lo(t,i,a))}var r3=class{constructor(){this._boundingVolumeCache=new t3(this._computeTileBoundingVolume)}prepareNextFrame(){this._boundingVolumeCache.swapBuffers()}distanceToTile2d(e,t,r,i){let a=1<<r.z,n=1/a,s=r.x/a,o=r.y/a,l=.5,u=2;return u=Math.min(u,eh(e,t,s,o,n)),u=Math.min(u,eh(e,t,s+l,-o-n,n)),u=Math.min(u,eh(e,t,s+l,2-o-n,n)),u}getWrap(e,t,r){let i=1<<t.z,a=1/i,n=t.x/i,s=Lo(e.x,n,a),o=Lo(e.x,n-1,a),l=Lo(e.x,n+1,a),u=Math.min(s,o,l);return u===l?1:u===o?-1:0}allowVariableZoom(e,t){return Wd(e,t)>4}allowWorldCopies(){return!1}getTileBoundingVolume(e,t,r,i){return this._boundingVolumeCache.getTileBoundingVolume(e,t,r,i)}_computeTileBoundingVolume(e,t,r,i){let a=Math.min(0,r),n=Math.max(0,r);if(i!=null&&i.terrain){let s=new Dt(e.z,t,e.z,e.x,e.y),o=i.terrain.getMinMaxElevation(s);a=o.minElevation??a,n=Math.max(o.maxElevation??n,n)}if(a/=Lt,n/=Lt,a+=1,n+=1,e.z<=0)return Qu.fromAabb([-n,-n,-n],[n,n,n]);if(e.z===1)return Qu.fromAabb([e.x===0?-n:0,e.y===0?0:-n,-n],[e.x===0?0:n,e.y===0?n:0,n]);{let s=[mi(0,0,e.x,e.y,e.z),mi(L,0,e.x,e.y,e.z),mi(L,L,e.x,e.y,e.z),mi(0,L,e.x,e.y,e.z)],o=[];for(let A of s)o.push(Ve([],A,n));if(n!==a)for(let A of s)o.push(Ve([],A,a));e.y===0&&o.push([0,1,0]),e.y===(1<<e.z)-1&&o.push([0,-1,0]);let l=[1,1,1],u=[-1,-1,-1];for(let A of o)for(let P=0;P<3;P++)l[P]=Math.min(l[P],A[P]),u[P]=Math.max(u[P],A[P]);let h=mi(L/2,L/2,e.x,e.y,e.z),c=Ht([],[0,1,0],h);Bt(c,c);let d=Ht([],h,c);Bt(d,d);let p=Ht([],s[2],s[1]);Bt(p,p);let f=Ht([],s[0],s[3]);Bt(f,f),o.push(Ve([],h,n)),e.y>=(1<<e.z)/2&&o.push(Ve([],mi(L/2,0,e.x,e.y,e.z),n)),e.y<(1<<e.z)/2&&o.push(Ve([],mi(L/2,L,e.x,e.y,e.z),n));let m=hg(h,o),g=hg(d,o),_=[-h[0],-h[1],-h[2],m.max],y=[h[0],h[1],h[2],-m.min],v=[-d[0],-d[1],-d[2],g.max],x=[d[0],d[1],d[2],-g.min],w=[...p,0],b=[...f,0],S=[];return e.y===0?S.push(lr(b,w,_),lr(b,w,y)):S.push(lr(v,w,_),lr(v,w,y),lr(v,b,_),lr(v,b,y)),e.y===(1<<e.z)-1?S.push(lr(b,w,_),lr(b,w,y)):S.push(lr(x,w,_),lr(x,w,y),lr(x,b,_),lr(x,b,y)),new Qu(S,[_,y,v,x,w,b],l,u)}}};function hg(e,t){let r=1/0,i=-1/0;for(let a of t){let n=lt(e,a);r=Math.min(r,n),i=Math.max(i,n)}return{min:r,max:i}}const cg=1e-12;var K1=class J1{get pixelsToClipSpaceMatrix(){return this._helper.pixelsToClipSpaceMatrix}get clipSpaceToPixelsMatrix(){return this._helper.clipSpaceToPixelsMatrix}get pixelsToGLUnits(){return this._helper.pixelsToGLUnits}get centerOffset(){return this._helper.centerOffset}get size(){return this._helper.size}get rotationMatrix(){return this._helper.rotationMatrix}get centerPoint(){return this._helper.centerPoint}get pixelsPerMeter(){return this._helper.pixelsPerMeter}setMinZoom(t){this._helper.setMinZoom(t)}setMaxZoom(t){this._helper.setMaxZoom(t)}setMinPitch(t){this._helper.setMinPitch(t)}setMaxPitch(t){this._helper.setMaxPitch(t)}setRenderWorldCopies(t){this._helper.setRenderWorldCopies(t)}setBearing(t){this._helper.setBearing(t)}setPitch(t){this._helper.setPitch(t)}setRoll(t){this._helper.setRoll(t)}setFov(t){this._helper.setFov(t)}setZoom(t){this._helper.setZoom(t)}setCenter(t){this._helper.setCenter(t)}setElevation(t){this._helper.setElevation(t)}setMinElevationForCurrentTile(t){this._helper.setMinElevationForCurrentTile(t)}setPadding(t){this._helper.setPadding(t)}interpolatePadding(t,r,i){this._helper.interpolatePadding(t,r,i)}isPaddingEqual(t){return this._helper.isPaddingEqual(t)}resize(t,r){this._helper.resize(t,r)}getMaxBounds(){return this._helper.getMaxBounds()}setMaxBounds(t){this._helper.setMaxBounds(t)}setConstrainOverride(t){this._helper.setConstrainOverride(t)}overrideNearFarZ(t,r){this._helper.overrideNearFarZ(t,r)}clearNearFarZOverride(){this._helper.clearNearFarZOverride()}getCameraQueryGeometry(t){return this._helper.getCameraQueryGeometry(this.getCameraPoint(),t)}get tileSize(){return this._helper.tileSize}get tileZoom(){return this._helper.tileZoom}get scale(){return this._helper.scale}get worldSize(){return this._helper.worldSize}get width(){return this._helper.width}get height(){return this._helper.height}get lngRange(){return this._helper.lngRange}get latRange(){return this._helper.latRange}get minZoom(){return this._helper.minZoom}get maxZoom(){return this._helper.maxZoom}get zoom(){return this._helper.zoom}get center(){return this._helper.center}get minPitch(){return this._helper.minPitch}get maxPitch(){return this._helper.maxPitch}get pitch(){return this._helper.pitch}get pitchInRadians(){return this._helper.pitchInRadians}get roll(){return this._helper.roll}get rollInRadians(){return this._helper.rollInRadians}get bearing(){return this._helper.bearing}get bearingInRadians(){return this._helper.bearingInRadians}get fov(){return this._helper.fov}get fovInRadians(){return this._helper.fovInRadians}get elevation(){return this._helper.elevation}get minElevationForCurrentTile(){return this._helper.minElevationForCurrentTile}get padding(){return this._helper.padding}get unmodified(){return this._helper.unmodified}get renderWorldCopies(){return this._helper.renderWorldCopies}get constrainOverride(){return this._helper.constrainOverride}get nearZ(){return this._helper.nearZ}get farZ(){return this._helper.farZ}get autoCalculateNearFarZ(){return this._helper.autoCalculateNearFarZ}setTransitionState(t){}constructor(t,r){this._cachedClippingPlane=Li(),this._projectionMatrix=Vs(),this._globeViewProjMatrix32f=Ng(),this._globeViewProjMatrixF64=Vs(),this._globeViewProjMatrixF64Inverted=Vs(),this._globeProjMatrixInverted=Vs(),this._cameraPosition=Pe(),this.defaultConstrain=(i,a)=>{let n=se(i.lat,-Gr,Gr),s=se(+a,this.minZoom+xt(0,n),this.maxZoom);return{center:new ee(i.lng,n),zoom:s}},this.applyConstrain=(i,a)=>this._helper.applyConstrain(i,a),this._helper=r??new Jd({calcMatrices:()=>this._calcMatrices(),defaultConstrain:(i,a)=>this.defaultConstrain(i,a)},t),this._coveringTilesDetailsProvider=new r3}clone(){let t=new J1;return t.apply(this,!1),t}apply(t,r){this._helper.apply(t,r)}get projectionMatrix(){return this._projectionMatrix}get modelViewProjectionMatrix(){return this._globeViewProjMatrixF64}get inverseProjectionMatrix(){return this._globeProjMatrixInverted}get cameraPosition(){let t=Pe();return t[0]=this._cameraPosition[0],t[1]=this._cameraPosition[1],t[2]=this._cameraPosition[2],t}get cameraToCenterDistance(){return this._helper.cameraToCenterDistance}getProjectionData(t){let{overscaledTileID:r,applyGlobeMatrix:i}=t,a=this._helper.getMercatorTileCoordinates(r);return{mainMatrix:this._globeViewProjMatrix32f,tileMercatorCoords:a,clippingPlane:this._cachedClippingPlane,projectionTransition:+!!i,fallbackMatrix:this._globeViewProjMatrix32f,clipAntimeridian:(r==null?void 0:r.canonical.z)===0}}_computeClippingPlane(t){let r=this.pitchInRadians,i=this.cameraToCenterDistance/t,a=Math.sin(r)*i,n=Math.cos(r)*i+1,s=1/Math.sqrt(a*a+n*n)*1,o=-a,l=n,u=Math.sqrt(o*o+l*l);o/=u,l/=u;let h=[0,o,l];Tu(h,h,[0,0,0],-this.bearingInRadians),dn(h,h,[0,0,0],-1*this.center.lat*Math.PI/180),ga(h,h,[0,0,0],this.center.lng*Math.PI/180);let c=1/Sr(h);return Ve(h,h,c),[...h,-s*c]}isLocationOccluded(t,r,i){let a=r==null?void 0:r.getCoverageIndex();i??(i=a?r.getElevationForLngLat(t,this):0);let n=pg(t,i);if(!this.isSurfacePointVisible(n))return!0;if(!a)return!1;let s=this._projectSurfacePointToScreen(n),o=this.cameraPosition,l=this.getRayDirectionFromPixel(s),u=fg(o,l,n);if(u<=0)return!0;let h=this.screenTerrainPointToMercatorCoordinate(s,r);return h!=null&&fg(o,l,pg(h.toLngLat(),h.z))<u*.99}transformLightDirection(t){let r=this._helper._center.lng*Math.PI/180,i=this._helper._center.lat*Math.PI/180,a=Math.cos(i),n=[Math.sin(r)*a,Math.sin(i),Math.cos(r)*a],s=[n[2],0,-n[0]],o=[0,0,0];Ht(o,s,n),Bt(s,s),Bt(o,o);let l=[s[0]*t[0]+o[0]*t[1]+n[0]*t[2],s[1]*t[0]+o[1]*t[1]+n[1]*t[2],s[2]*t[0]+o[2]*t[1]+n[2]*t[2]],u=[0,0,0];return Bt(u,l),u}getPixelScale(){return 1/Math.cos(this._helper._center.lat*Math.PI/180)}getCircleRadiusCorrection(){return Math.cos(this._helper._center.lat*Math.PI/180)}getPitchedTextCorrection(t,r,i){let a=o0(t,r,i.canonical),n=qM(a.x,a.y);return this.getCircleRadiusCorrection()/Math.cos(n[1])}projectTileCoordinates(t,r,i,a){let n=i.canonical,s=mi(t,r,n.x,n.y,n.z),o=1+(a??0)/Lt,l=s[0]*o,u=s[1]*o,h=s[2]*o,c=[l,u,h,1];Pt(c,c,this._globeViewProjMatrixF64);let d;if(o<=1){let p=this._cachedClippingPlane;d=p[0]*s[0]+p[1]*s[1]+p[2]*s[2]+p[3]<0}else d=this._isLineOfSightBlocked(l,u,h);return{point:new M(c[0]/c[3],c[1]/c[3]),signedDistanceFromCamera:c[3],isOccluded:d}}_isLineOfSightBlocked(t,r,i){let a=this._cameraPosition,n=t-a[0],s=r-a[1],o=i-a[2],l=n*n+s*s+o*o;if(l===0)return!1;let u=se(-(a[0]*n+a[1]*s+a[2]*o)/l,0,1),h=a[0]+u*n,c=a[1]+u*s,d=a[2]+u*o;return h*h+c*c+d*d<1}_calcMatrices(t=this._helper.autoCalculateNearFarZ){let r=Xa(this.worldSize,this.center.lat),i=Bi();t&&(this._helper._nearZ=.5,this._helper._farZ=this.cameraToCenterDistance+r*2),dh(i,this.fovInRadians,this.width/this.height,this._helper._nearZ,this._helper._farZ);let a=this.centerOffset;i[8]=-a.x*2/this._helper._width,i[9]=a.y*2/this._helper._height,this._projectionMatrix=ch(i),this._globeProjMatrixInverted=Bi(),Bo(this._globeProjMatrixInverted,i),ot(i,i,[0,0,-this.cameraToCenterDistance]),yi(i,i,this.rollInRadians),Oa(i,i,-this.pitchInRadians),yi(i,i,this.bearingInRadians),ot(i,i,[0,0,-r]);let n=Pe();n[0]=r,n[1]=r,n[2]=r,Oa(i,i,this.center.lat*Math.PI/180),jg(i,i,-this.center.lng*Math.PI/180),Et(i,i,n),this._globeViewProjMatrixF64=i,this._globeViewProjMatrix32f=new Float32Array(i),this._globeViewProjMatrixF64Inverted=Bi(),Bo(this._globeViewProjMatrixF64Inverted,i);let s=Pe();this._cameraPosition=Pe(),this._cameraPosition[2]=this.cameraToCenterDistance/r,Tu(this._cameraPosition,this._cameraPosition,s,-this.rollInRadians),dn(this._cameraPosition,this._cameraPosition,s,this.pitchInRadians),Tu(this._cameraPosition,this._cameraPosition,s,-this.bearingInRadians),pr(this._cameraPosition,this._cameraPosition,[0,0,1]),dn(this._cameraPosition,this._cameraPosition,s,-this.center.lat*Math.PI/180),ga(this._cameraPosition,this._cameraPosition,s,this.center.lng*Math.PI/180),this._cachedClippingPlane=this._computeClippingPlane(r);let o=ch(this._globeViewProjMatrixF64Inverted);Et(o,o,[1,1,-1]),this._cachedFrustum=Zd.fromInvProjectionMatrix(o,1,0,this._cachedClippingPlane,!0)}calculateFogMatrix(t){_e("calculateFogMatrix is not supported on globe projection.");let r=Bi();return Pr(r),r}getVisibleUnwrappedCoordinates(t){return[new ul(0,t)]}getCameraFrustum(){return this._cachedFrustum}getClippingPlane(){return this._cachedClippingPlane}getCoveringTilesDetailsProvider(){return this._coveringTilesDetailsProvider}recalculateZoomAndCenter(t){if(t){_e("terrain is not fully supported on vertical perspective projection.");return}this._helper.recalculateZoomAndCenter(0)}maxPitchScaleFactor(){return 1}getCameraPoint(){return this._helper.getCameraPoint()}getCameraAltitude(){return(Sr(this._cameraPosition)-1)*Lt}getCameraLngLat(){let t=Pe();return Bt(t,this._cameraPosition),Vn(t)}populateCache(t){}getBounds(){let t=this.width*.5,r=this.height*.5,i=[new M(0,0),new M(t,0),new M(this.width,0),new M(this.width,r),new M(this.width,this.height),new M(t,this.height),new M(0,this.height),new M(0,r)],a=[];for(let c of i)a.push(this.unprojectScreenPoint(c));let n=0,s=0,o=0,l=0,u=this.center;for(let c of a){let d=er(u.lng,c.lng),p=er(u.lat,c.lat);d<s&&(s=d),d>n&&(n=d),p<l&&(l=p),p>o&&(o=p)}let h=[u.lng+s,u.lat+l,u.lng+n,u.lat+o];return this.isSurfacePointOnScreen([0,1,0])&&(h[3]=90,h[0]=-180,h[2]=180),this.isSurfacePointOnScreen([0,-1,0])&&(h[1]=-90,h[0]=-180,h[2]=180),new Wr(h)}calculateCenterFromCameraLngLatAlt(t,r,i,a){return this._helper.calculateCenterFromCameraLngLatAlt(t,r,i,a)}calculateCameraOptionsFromTo(t,r,i,a){let n=ee.convert(i),s=mt(ee.convert(t));Ve(s,s,1+r/Lt);let o=mt(n),l=Ve(Pe(),o,1+a/Lt),u=Uc(Pe(),s,o),h=Sr(u);if(h<cg||Wx(s,l)<cg)throw Error("Can't calculate camera options with same From and To");let c=Pe();ga(u,u,c,-Ge(n.lng)),dn(u,u,c,Ge(n.lat));let d=$r(Math.acos(se(u[2]/h,-1,1))),p=Math.hypot(u[0],u[1])<h*1e-9?this.bearing:$r(Math.atan2(-u[0],-u[1]));return{center:n,elevation:a,zoom:It(this.cameraToCenterDistance/h/Xa(this.tileSize,n.lat)),pitch:d,bearing:p}}setLocationAtPoint(t,r,i){let a=mt(this.unprojectScreenPoint(r)),n=mt(t),s=Pe();Kx(s);let o=Pe();ga(o,a,s,-this.center.lng*Math.PI/180),dn(o,o,s,this.center.lat*Math.PI/180);let l=n[0]*n[0]+n[2]*n[2],u=o[0]*o[0];if(l<u)return;let h=Math.sqrt(l-u),c=-h,d=Ns(n[0],n[2],o[0],h),p=Ns(n[0],n[2],o[0],c),f=Pe();ga(f,n,s,-d);let m=Ns(f[1],f[2],o[1],o[2]),g=Pe();ga(g,n,s,-p);let _=Ns(g[1],g[2],o[1],o[2]),y=Math.PI*.5,v=m>=-y&&m<=y,x=_>=-y&&_<=y,w,b;if(v&&x){let I=this.center.lng*Math.PI/180,R=this.center.lat*Math.PI/180,F=Us(d,I),T=Us(m,R),E=Us(p,I),D=Us(_,R);F+T<E+D?(w=d,b=m):(w=p,b=_)}else if(v)w=d,b=m;else if(x)w=p,b=_;else return;let S=w/Math.PI*180,A=b/Math.PI*180,P=this.center.lat;this.setCenter(new ee(S,se(A,-90,90))),this.setZoom(this.zoom+xt(P,this.center.lat))}locationToScreenPoint(t,r){let i=mt(t);if(r){let a=r.getElevationForLngLatZoom(t,this._helper._tileZoom);Ve(i,i,1+a/Lt)}return this._projectSurfacePointToScreen(i)}_projectSurfacePointToScreen(t){let r=Li();return Pt(r,[...t,1],this._globeViewProjMatrixF64),r[0]/=r[3],r[1]/=r[3],new M((r[0]*.5+.5)*this.width,(-r[1]*.5+.5)*this.height)}screenPointToMercatorCoordinate(t,r){if(r){let i=this.screenTerrainPointToMercatorCoordinate(t,r);if(i)return i}return Ie.fromLngLat(this.unprojectScreenPoint(t))}screenTerrainPointToMercatorCoordinate(t,r){let i=r.getCoverageIndex();if(!i)return null;let a=this.cameraPosition,n=this.getRayDirectionFromPixel(t),s=po(a,n,1+i.maxElevation/Lt);if(!s)return null;let o=po(a,n,1+i.minElevation/Lt),l=Math.max(s.tMin,0),u=o?o.tMin:s.tMax;if(u<=l)return null;let h={index:i,exaggeration:r.exaggeration,origin:a,direction:n},c=0;for(let d=0;d<=256;d++){let p=l+(u-l)*d/256;if(dg(h,p)){let{hi:f}=N1(h,dg,c,p,1e-12),{sample:m,mercator:g}=Q1(h,f);return new Ie(g.x,g.y,m.elevation)}c=p}return null}screenPointToLocation(t,r){var i;return(i=this.screenPointToMercatorCoordinate(t,r))==null?void 0:i.toLngLat()}screenPointToLocationAtElevation(t,r){return this.screenPointToLocation(t)}isPointOnMapSurface(t,r){let i=this._cameraPosition;return!!po(i,this.getRayDirectionFromPixel(t))}getRayDirectionFromPixel(t){let r=Li();r[0]=t.x/this.width*2-1,r[1]=(t.y/this.height*2-1)*-1,r[2]=1,r[3]=1,Pt(r,r,this._globeViewProjMatrixF64Inverted),r[0]/=r[3],r[1]/=r[3],r[2]/=r[3];let i=Pe();i[0]=r[0]-this._cameraPosition[0],i[1]=r[1]-this._cameraPosition[1],i[2]=r[2]-this._cameraPosition[2];let a=Pe();return Bt(a,i),a}isSurfacePointVisible(t){let r=this._cachedClippingPlane;return r[0]*t[0]+r[1]*t[1]+r[2]*t[2]+r[3]>=0}isSurfacePointOnScreen(t){if(!this.isSurfacePointVisible(t))return!1;let r=Li();return Pt(r,[...t,1],this._globeViewProjMatrixF64),r[0]/=r[3],r[1]/=r[3],r[2]/=r[3],r[0]>-1&&r[0]<1&&r[1]>-1&&r[1]<1&&r[2]>-1&&r[2]<1}unprojectScreenPoint(t){let r=this._cameraPosition,i=this.getRayDirectionFromPixel(t),a=po(r,i);if(a){let h=Pe();pr(h,r,[i[0]*a.tMin,i[1]*a.tMin,i[2]*a.tMin]);let c=Pe();return Bt(c,h),Vn(c)}let n=this._cachedClippingPlane,s=n[0]*i[0]+n[1]*i[1]+n[2]*i[2],o=-mh(n,r)/s,l=Pe();if(o>0)pr(l,r,[i[0]*o,i[1]*o,i[2]*o]);else{let h=Pe();pr(h,r,[i[0]*2,i[1]*2,i[2]*2]);let c=mh(this._cachedClippingPlane,h);li(l,h,[this._cachedClippingPlane[0]*c,this._cachedClippingPlane[1]*c,this._cachedClippingPlane[2]*c])}let u=KM(n);return Vn(JM(u.center,u.radius,l))}getProjectionDataForCustomLayer(t=!0){let r=this.getProjectionData({overscaledTileID:new Dt(0,0,0,0,0),applyGlobeMatrix:t});return r.tileMercatorCoords=[0,0,1,1],r}getFastPathSimpleProjectionMatrix(t){}};function Q1(e,t){let r=Pe();Oo(r,e.origin,e.direction,t);let i=Sr(r),a=Pe();Ve(a,r,1/i);let n=Vn(a),s=Ie.fromLngLat(n),o=new Ie(s.x,se(s.y,0,.999999999)),l=Qd(e.index,e.exaggeration,o.x,o.y),u=Math.abs(n.lat)>85.051129?0:l.elevation;return{sample:{...l,elevation:u},radius:i,mercator:o}}function dg(e,t){let{sample:r,radius:i}=Q1(e,t);return V1(r,(i-1)*Lt)}function pg(e,t){let r=mt(e);return Ve(r,r,1+t/Lt)}function fg(e,t,r){let i=Uc(Pe(),r,e);return lt(i,t)}var mg=class ex{get pixelsToClipSpaceMatrix(){return this._helper.pixelsToClipSpaceMatrix}get clipSpaceToPixelsMatrix(){return this._helper.clipSpaceToPixelsMatrix}get pixelsToGLUnits(){return this._helper.pixelsToGLUnits}get centerOffset(){return this._helper.centerOffset}get size(){return this._helper.size}get rotationMatrix(){return this._helper.rotationMatrix}get centerPoint(){return this._helper.centerPoint}get pixelsPerMeter(){return this._helper.pixelsPerMeter}setMinZoom(t){this._helper.setMinZoom(t)}setMaxZoom(t){this._helper.setMaxZoom(t)}setMinPitch(t){this._helper.setMinPitch(t)}setMaxPitch(t){this._helper.setMaxPitch(t)}setRenderWorldCopies(t){this._helper.setRenderWorldCopies(t)}setBearing(t){this._helper.setBearing(t)}setPitch(t){this._helper.setPitch(t)}setRoll(t){this._helper.setRoll(t)}setFov(t){this._helper.setFov(t)}setZoom(t){this._helper.setZoom(t)}setCenter(t){this._helper.setCenter(t)}setElevation(t){this._helper.setElevation(t)}setMinElevationForCurrentTile(t){this._helper.setMinElevationForCurrentTile(t)}setPadding(t){this._helper.setPadding(t)}interpolatePadding(t,r,i){this._helper.interpolatePadding(t,r,i)}isPaddingEqual(t){return this._helper.isPaddingEqual(t)}resize(t,r,i=!0){this._helper.resize(t,r,i)}getMaxBounds(){return this._helper.getMaxBounds()}setMaxBounds(t){this._helper.setMaxBounds(t)}setConstrainOverride(t){this._helper.setConstrainOverride(t)}overrideNearFarZ(t,r){this._helper.overrideNearFarZ(t,r)}clearNearFarZOverride(){this._helper.clearNearFarZOverride()}getCameraQueryGeometry(t){return this._helper.getCameraQueryGeometry(this.getCameraPoint(),t)}get tileSize(){return this._helper.tileSize}get tileZoom(){return this._helper.tileZoom}get scale(){return this._helper.scale}get worldSize(){return this._helper.worldSize}get width(){return this._helper.width}get height(){return this._helper.height}get lngRange(){return this._helper.lngRange}get latRange(){return this._helper.latRange}get minZoom(){return this._helper.minZoom}get maxZoom(){return this._helper.maxZoom}get zoom(){return this._helper.zoom}get center(){return this._helper.center}get minPitch(){return this._helper.minPitch}get maxPitch(){return this._helper.maxPitch}get pitch(){return this._helper.pitch}get pitchInRadians(){return this._helper.pitchInRadians}get roll(){return this._helper.roll}get rollInRadians(){return this._helper.rollInRadians}get bearing(){return this._helper.bearing}get bearingInRadians(){return this._helper.bearingInRadians}get fov(){return this._helper.fov}get fovInRadians(){return this._helper.fovInRadians}get elevation(){return this._helper.elevation}get minElevationForCurrentTile(){return this._helper.minElevationForCurrentTile}get padding(){return this._helper.padding}get unmodified(){return this._helper.unmodified}get renderWorldCopies(){return this._helper.renderWorldCopies}get cameraToCenterDistance(){return this._helper.cameraToCenterDistance}get constrainOverride(){return this._helper.constrainOverride}get nearZ(){return this._helper.nearZ}get farZ(){return this._helper.farZ}get autoCalculateNearFarZ(){return this._helper.autoCalculateNearFarZ}get isGlobeRendering(){return this._globeness>0}setTransitionState(t){this._globeness=t,this._calcMatrices(),this._verticalPerspectiveTransform.getCoveringTilesDetailsProvider().prepareNextFrame(),this._mercatorTransform.getCoveringTilesDetailsProvider().prepareNextFrame()}get currentTransform(){return this.isGlobeRendering?this._verticalPerspectiveTransform:this._mercatorTransform}constructor(t){this._globeness=1,this.defaultConstrain=(r,i)=>this.currentTransform.defaultConstrain(r,i),this.applyConstrain=(r,i)=>this._helper.applyConstrain(r,i),this._helper=new Jd({calcMatrices:()=>this._calcMatrices(),defaultConstrain:(r,i)=>this.defaultConstrain(r,i)},t),this._globeness=1,this._mercatorTransform=new fl(void 0,this._helper),this._verticalPerspectiveTransform=new K1(void 0,this._helper)}clone(){let t=new ex;return t._globeness=this._globeness,t.apply(this,!1),t}apply(t,r){this._helper.apply(t,r)}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(t){let r=this._mercatorTransform.getProjectionData(t),i=this._verticalPerspectiveTransform.getProjectionData(t);return{mainMatrix:this.isGlobeRendering?i.mainMatrix:r.mainMatrix,clippingPlane:i.clippingPlane,tileMercatorCoords:i.tileMercatorCoords,projectionTransition:t.applyGlobeMatrix?this._globeness:0,fallbackMatrix:r.fallbackMatrix,clipAntimeridian:i.clipAntimeridian}}isLocationOccluded(t,r,i){return this.currentTransform.isLocationOccluded(t,r,i)}transformLightDirection(t){return this.currentTransform.transformLightDirection(t)}getPixelScale(){return Ia(this._mercatorTransform.getPixelScale(),this._verticalPerspectiveTransform.getPixelScale(),this._globeness)}getCircleRadiusCorrection(){return Ia(this._mercatorTransform.getCircleRadiusCorrection(),this._verticalPerspectiveTransform.getCircleRadiusCorrection(),this._globeness)}getPitchedTextCorrection(t,r,i){let a=this._mercatorTransform.getPitchedTextCorrection(t,r,i),n=this._verticalPerspectiveTransform.getPitchedTextCorrection(t,r,i);return Ia(a,n,this._globeness)}projectTileCoordinates(t,r,i,a){return this.currentTransform.projectTileCoordinates(t,r,i,a)}_calcMatrices(){this._helper._width&&this._helper._height&&(this._verticalPerspectiveTransform._calcMatrices(),this._mercatorTransform._calcMatrices(this.autoCalculateNearFarZ&&!this.isGlobeRendering))}calculateFogMatrix(t){return this.currentTransform.calculateFogMatrix(t)}getVisibleUnwrappedCoordinates(t){return this.currentTransform.getVisibleUnwrappedCoordinates(t)}getCameraFrustum(){return this.currentTransform.getCameraFrustum()}getClippingPlane(){return this.currentTransform.getClippingPlane()}getCoveringTilesDetailsProvider(){return this.currentTransform.getCoveringTilesDetailsProvider()}recalculateZoomAndCenter(t){this.currentTransform.recalculateZoomAndCenter(t)}maxPitchScaleFactor(){return this._mercatorTransform.maxPitchScaleFactor()}getCameraPoint(){return this._helper.getCameraPoint()}getCameraAltitude(){return this.currentTransform.getCameraAltitude()}getCameraLngLat(){return this.currentTransform.getCameraLngLat()}populateCache(t){this._mercatorTransform.populateCache(t),this._verticalPerspectiveTransform.populateCache(t)}getBounds(){return this.currentTransform.getBounds()}calculateCenterFromCameraLngLatAlt(t,r,i,a){return this._helper.calculateCenterFromCameraLngLatAlt(t,r,i,a)}calculateCameraOptionsFromTo(t,r,i,a){return this.currentTransform.calculateCameraOptionsFromTo(t,r,i,a)}setLocationAtPoint(t,r,i){this.currentTransform.setLocationAtPoint(t,r,i)}locationToScreenPoint(t,r){return this.currentTransform.locationToScreenPoint(t,r)}screenPointToMercatorCoordinate(t,r){return this.currentTransform.screenPointToMercatorCoordinate(t,r)}screenTerrainPointToMercatorCoordinate(t,r){return this.currentTransform.screenTerrainPointToMercatorCoordinate(t,r)}screenPointToLocation(t,r){return this.currentTransform.screenPointToLocation(t,r)}screenPointToLocationAtElevation(t,r){return this.currentTransform.screenPointToLocationAtElevation(t,r)}isPointOnMapSurface(t,r){return this.currentTransform.isPointOnMapSurface(t,r)}getRayDirectionFromPixel(t){return this._verticalPerspectiveTransform.getRayDirectionFromPixel(t)}getProjectionDataForCustomLayer(t=!0){let r=this._mercatorTransform.getProjectionDataForCustomLayer(t);if(!this.isGlobeRendering)return r;let i=this._verticalPerspectiveTransform.getProjectionDataForCustomLayer(t);return i.fallbackMatrix=r.mainMatrix,i.projectionTransition=this._globeness,i}getFastPathSimpleProjectionMatrix(t){return this.currentTransform.getFastPathSimpleProjectionMatrix(t)}},tx=class ei{get useGlobeControls(){return!0}handlePanInertia(t,r){let i=e3(t,r);return Math.abs(i.lng-r.center.lng)>180&&(i.lng=r.center.lng+179.5*Math.sign(i.lng-r.center.lng)),{easingCenter:i,easingOffset:new M(0,0)}}handleMapControlsRollPitchBearingZoom(t,r){let i=t.around,a=r.screenPointToLocation(i);t.bearingDelta&&r.setBearing(r.bearing+t.bearingDelta),t.pitchDelta&&r.setPitch(r.pitch+t.pitchDelta),t.rollDelta&&r.setRoll(r.roll+t.rollDelta);let n=r.zoom;t.zoomDelta&&r.setZoom(r.zoom+t.zoomDelta);let s=r.zoom-n;if(s===0)return;let o=er(r.center.lng,a.lng),l=o/(Math.abs(o/180)+1),u=er(r.center.lat,a.lat),h=r.getRayDirectionFromPixel(i),c=r.cameraPosition,d=lt(c,h)*-1,p=Pe();pr(p,c,[h[0]*d,h[1]*d,h[2]*d]);let f=Sr(p),m=f-1,g=Math.exp(-Math.max(m-.3,0)*.5),_=So(f,.95,.999,0,1),y=Xa(r.worldSize,r.center.lat)/Math.min(r.width,r.height),v=So(y,.9,.5,1,.25),x=Math.min(g,Ia(1,v,_)),w=(1-$t(-s))*x,b=r.center.lat,S=r.zoom,A=new ee(r.center.lng+l*w,se(r.center.lat+u*w,-Gr,Gr));r.setLocationAtPoint(a,i);let P=r.center,I=So(Math.abs(o),45,85,0,1),R=Math.max(I,_)**.25,F=er(P.lng,A.lng),T=er(P.lat,A.lat);r.setCenter(new ee(P.lng+F*R,P.lat+T*R).wrap()),r.setZoom(S+xt(b,r.center.lat))}handleMapControlsPan(t,r,i){t.panDelta&&XM(r,i,r.isPointOnMapSurface(t.around)?t.around:r.centerPoint,t.panDelta)}cameraForBoxAndBearing(t,r,i,a,n){let s=Z1(t,r,i,a,n);if(!s)return;let o=r.left/n.width*2-1,l=(n.width-r.right)/n.width*2-1,u=r.top/n.height*-2+1,h=(n.height-r.bottom)/n.height*-2+1,c=er(i.getWest(),i.getEast())<0,d=c?i.getEast():i.getWest(),p=c?i.getWest():i.getEast(),f=Math.max(i.getNorth(),i.getSouth()),m=Math.min(i.getNorth(),i.getSouth()),g=d+er(d,p)*.5,_=f+er(f,m)*.5,y=n.clone();y.setCenter(s.center),y.setBearing(s.bearing),y.setPitch(0),y.setRoll(0),y.setZoom(s.zoom);let v=y.modelViewProjectionMatrix,x=[mt(i.getNorthWest()),mt(i.getNorthEast()),mt(i.getSouthWest()),mt(i.getSouthEast()),mt(new ee(p,_)),mt(new ee(d,_)),mt(new ee(g,f)),mt(new ee(g,m))],w=mt(s.center),b=1/0;for(let S of x)o<0&&(b=ei.getLesserNonNegativeNonNull(b,ei.solveVectorScale(S,w,v,"x",o))),l>0&&(b=ei.getLesserNonNegativeNonNull(b,ei.solveVectorScale(S,w,v,"x",l))),u>0&&(b=ei.getLesserNonNegativeNonNull(b,ei.solveVectorScale(S,w,v,"y",u))),h<0&&(b=ei.getLesserNonNegativeNonNull(b,ei.solveVectorScale(S,w,v,"y",h)));if(!Number.isFinite(b)||b===0){G1();return}return s.zoom=Math.min(y.zoom+It(b),t.maxZoom),s}handleJumpToCenterZoom(t,r){let i=t.center.lat,a=t.applyConstrain(r.center?ee.convert(r.center):t.center,t.zoom).center;t.setCenter(a.wrap());let n=r.zoom===void 0?t.zoom+xt(i,a.lat):+r.zoom;t.zoom!==n&&t.setZoom(n)}handleEaseTo(t,r){let i=t.zoom,a=t.center,n=t.padding,s={roll:t.roll,pitch:t.pitch,bearing:t.bearing},o={roll:r.roll===void 0?t.roll:r.roll,pitch:r.pitch===void 0?t.pitch:r.pitch,bearing:r.bearing===void 0?t.bearing:r.bearing},l=r.zoom!==void 0,u=!t.isPaddingEqual(r.padding),h=!1,c=r.center?ee.convert(r.center):a,d=t.applyConstrain(c,i).center;pl(t,d);let p=t.clone();p.setCenter(d),p.setZoom(l?+r.zoom:i+xt(a.lat,c.lat)),p.setBearing(r.bearing);let f=new M(se(t.centerPoint.x+r.offsetAsPoint.x,0,t.width),se(t.centerPoint.y+r.offsetAsPoint.y,0,t.height));p.setLocationAtPoint(d,f);let m=(r.offset&&r.offsetAsPoint.mag())>0?p.center:d,g=l?+r.zoom:i+xt(a.lat,m.lat),_=i+xt(a.lat,0),y=g+xt(m.lat,0),v=er(a.lng,m.lng),x=er(a.lat,m.lat),w=$t(y-_);return h=g!==i,{easeFunc:b=>{if(qg(s,o)||q1({startEulerAngles:s,endEulerAngles:o,tr:t,k:b,useSlerp:s.roll!=o.roll}),u&&t.interpolatePadding(n,r.padding,b),r.around)_e("Easing around a point is not supported under globe projection."),t.setLocationAtPoint(r.around,r.aroundPoint);else{let S=b*(y>_?Math.min(2,w):Math.max(.5,w))**(1-b),A=ug(a,v,x,S);t.setCenter(A.wrap())}if(h){let S=We.number(_,y,b)+xt(0,t.center.lat);t.setZoom(S)}},isZooming:h,elevationCenter:m}}handleFlyTo(t,r){let i=r.zoom!==void 0,a=t.center,n=t.zoom,s=t.padding,o=!t.isPaddingEqual(r.padding),l=t.applyConstrain(ee.convert(r.center||r.locationAtOffset),n).center,u=i?+r.zoom:t.zoom+xt(t.center.lat,l.lat),h=t.clone();h.setCenter(l),h.setZoom(u),h.setBearing(r.bearing);let c=new M(se(t.centerPoint.x+r.offsetAsPoint.x,0,t.width),se(t.centerPoint.y+r.offsetAsPoint.y,0,t.height));h.setLocationAtPoint(l,c);let d=h.center;pl(t,d);let p=GM(t,a,d),f=n+xt(a.lat,0),m=u+xt(d.lat,0),g=$t(m-f),_=typeof r.minZoom=="number"?+r.minZoom:t.minZoom,y=Math.max(_,t.minZoom)+xt(d.lat,0),v=Math.min(y,f,m)+xt(0,d.lat),x=t.applyConstrain(d,v).zoom+xt(d.lat,0),w=$t(x-f),b=er(a.lng,d.lng),S=er(a.lat,d.lat);return{easeFunc:(A,P,I,R)=>{let F=ug(a,b,S,I);o&&t.interpolatePadding(s,r.padding,A);let T=A===1?d:F;t.setCenter(T.wrap());let E=f+It(P);t.setZoom(A===1?u:E+xt(0,T.lat))},scaleOfZoom:g,targetCenter:d,scaleOfMinZoom:w,pixelPathLength:p}}static solveVectorScale(t,r,i,a,n){let s=n,o=a==="x"?[i[0],i[4],i[8],i[12]]:[i[1],i[5],i[9],i[13]],l=[i[3],i[7],i[11],i[15]],u=t[0]*o[0]+t[1]*o[1]+t[2]*o[2],h=t[0]*l[0]+t[1]*l[1]+t[2]*l[2],c=r[0]*o[0]+r[1]*o[1]+r[2]*o[2],d=r[0]*l[0]+r[1]*l[1]+r[2]*l[2],p=(c+o[3]-s*d-s*l[3])/(c-u-s*d+s*h);return c+s*h===u+s*d||l[3]*(u-c)+o[3]*(d-h)+u*d===c*h?null:p}static getLesserNonNegativeNonNull(t,r){return r!==null&&r>=0&&r<t?r:t}},gg=class{constructor(e){this._globe=e,this._mercatorCameraHelper=new ml,this._verticalPerspectiveCameraHelper=new tx}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,r){this.currentHelper.handleMapControlsPan(e,t,r)}cameraForBoxAndBearing(e,t,r,i,a){return this.currentHelper.cameraForBoxAndBearing(e,t,r,i,a)}handleJumpToCenterZoom(e,t){this.currentHelper.handleJumpToCenterZoom(e,t)}handleEaseTo(e,t){return this.currentHelper.handleEaseTo(e,t)}handleFlyTo(e,t){return this.currentHelper.handleFlyTo(e,t)}};function i3(e,t,r){let i={constrainOverride:t};if(Array.isArray(e)){let a=new og({type:e},r);return{projection:a,transform:new mg(i),cameraHelper:new gg(a)}}switch(e){case"mercator":return{projection:new Bc,transform:new fl(i),cameraHelper:new ml};case"globe":{let a=new og({type:["interpolate",["linear"],["zoom"],11,"vertical-perspective",12,"mercator"]},{});return{projection:a,transform:new mg(i),cameraHelper:new gg(a)}}case"vertical-perspective":return{projection:new W1,transform:new K1(i),cameraHelper:new tx};default:return _e(`Unknown projection name: ${e}. Falling back to mercator projection.`),{projection:new Bc,transform:new fl(i),cameraHelper:new ml}}}const a3=zC();var _g=class extends kt{constructor(e,t={}){var i,a;super(),this._rtlPluginLoaded=()=>{for(let n in this.tileManagers){let s=this.tileManagers[n].getSource().type;(s==="vector"||s==="geojson")&&this.tileManagers[n].reload()}},this.map=e,this.dispatcher=new x1(y1(),e._getMapId()).setEventedParent(this),this.dispatcher.registerMessageHandler("GG",(n,s)=>this.getGlyphs(n,s)),this.dispatcher.registerMessageHandler("GI",(n,s)=>this.getImages(n,s)),this.dispatcher.registerMessageHandler("GDA",(n,s)=>this.getDashes(n,s)),this.imageManager=new kC,this.imageManager.setEventedParent(this),this.imageManager.setMissingImageResolver(e._missingStyleImageResolver),this.patternAtlas=new LC(this.imageManager);let r=((i=e._container)==null?void 0:i.lang)||typeof document<"u"&&((a=document.documentElement)==null?void 0:a.lang)||void 0;this.glyphManager=new qC(e._requestManager,t.localIdeographFontFamily,r),this.lineAtlas=new JC(256,512),this.crossTileSymbolIndex=new B1,this._setInitialValues(),this._resetUpdates(),this.dispatcher.broadcast("SR",Hc()),Mc().on(Ic,this._rtlPluginLoaded),this.on("data",n=>{if(n.dataType!=="source"||n.sourceDataType!=="metadata")return;let s=this.tileManagers[n.sourceId];if(!s)return;let o=s.getSource();if(o!=null&&o.vectorLayerIds)for(let l in this._layers){let u=this._layers[l];u.source===o.id&&this._validateLayer(u)}})}_setInitialValues(){var e;this._layers={},this._order=[],this.tileManagers={},this.zoomHistory=new Mh,this._imagesListDirty=!1,this._globalState={},this._serializedLayers={},this.stylesheet=null,this.light=null,this.sky=null,this.projection&&(this.projection.destroy(),delete this.projection),this._loaded=!1,this._changed=!1,this._updatedLayers={},this._updatedSources={},this._changedImages={},this._glyphsDidChange=!1,this._updatedPaintProps={},this._layerOrderChanged=!1,this._symbolPlacementTriggered=!1,this._placedProjectionTransition=void 0,this.crossTileSymbolIndex=new(((e=this.crossTileSymbolIndex)==null?void 0:e.constructor)||Object),this.pauseablePlacement=void 0,this.placement=void 0,this.z=0}setGlobalStateProperty(e,t){var i,a;this._checkLoaded();let r=t===null?((a=(i=this.stylesheet.state)==null?void 0:i[e])==null?void 0:a.default)??null:t;return this._setGlobalStateValues({[e]:r}),this}getGlobalState(){return this._globalState}setGlobalState(e){this._checkLoaded();let t={};for(let r in e)t[r]=e[r].default;this._setGlobalStateValues(t)}_setGlobalStateValues(e){let t=[];for(let i in e)Br(e[i],this._globalState[i])||t.push(i);if(t.length===0)return;let r={...this._globalState};for(let i of t)this._globalState[i]=e[i];this._applyGlobalStateChanges(t,r)}_applyGlobalStateChanges(e,t){var n,s;let r=new Set,i={};for(let o of e)i[o]=this._globalState[o];for(let o in this._layers){let l=this._layers[o];l.retainPriorGlobalState(e,t);let u=l.getLayoutAffectingGlobalStateRefs(),h=l.getPaintAffectingGlobalStateRefs(),c=l.getVisibilityAffectingGlobalStateRefs();for(let d of e){if(u.has(d)&&r.add(l.source),h.has(d))for(let{name:p,value:f}of h.get(d))this._updatePaintProperty(l,p,f,{validate:!1});c!=null&&c.has(d)&&(l.recalculateVisibility(),this._updateLayer(l))}}let a={now:Fe(),transition:this.getTransition()};(n=this.light)==null||n.applyGlobalStateChange(e,t,a),(s=this.sky)==null||s.applyGlobalStateChange(e,t,a),this.dispatcher.broadcast("UGS",i);for(let o in this.tileManagers)r.has(o)&&(this._reloadSource(o),this._changed=!0)}async loadURL(e,t={},r){this.fire(new Tr("dataloading")),t.validate=typeof t.validate!="boolean"||t.validate,this._loadStyleRequest=new AbortController;let i=this._loadStyleRequest;try{let a=await this.map._requestManager.transformRequest(e,"Style");Wc(i.signal);let n=await xl(a,i);this._loadStyleRequest===i&&(this._loadStyleRequest=null),this._load(n.data,t,r)}catch(a){this._loadStyleRequest===i&&(this._loadStyleRequest=null),a&&!i.signal.aborted&&this.fire(new Y(zt(a)))}}loadJSON(e,t={},r){this.fire(new Tr("dataloading")),this._frameRequest=new AbortController,Xt.frameAsync(this._frameRequest,this.map._ownerWindow).then(()=>{this._frameRequest=null,t.validate=t.validate!==!1,this._load(e,t,r)}).catch(()=>{})}loadEmpty(){this.fire(new Tr("dataloading")),this._load(a3,{validate:!1})}_load(e,t,r){var a;let i=t.transformStyle?t.transformStyle(r,e):e;if(!(t.validate&&pf(this,i))){i={...i},this._loaded=!0,this.stylesheet=i;for(let n in i.sources)this.addSource(n,i.sources[n],{validate:!1});i.sprite?this._loadSprite(i.sprite):this.imageManager.setLoaded(!0),this.glyphManager.setURL(i.glyphs),this.glyphManager.setFontFaces(i["font-faces"]),this._createLayers(),this.light=new HC(this.stylesheet.light??{},this._globalState),this._setProjectionInternal(((a=this.stylesheet.projection)==null?void 0:a.type)||"mercator"),this.sky=new KC(this.stylesheet.sky,this._globalState),this.sky.setEventedParent(this),this.map.setTerrain(this.stylesheet.terrain??null,{validate:!1}),this.fire(new Tr("data")),this.fire(new Sm)}}_createLayers(){var t;let e=Em(this.stylesheet.layers);this.setGlobalState(this.stylesheet.state??null),this.dispatcher.broadcast("SL",e),this._order=e.map(r=>r.id),this._layers={},this._serializedLayers=null;for(let r of e){let i=Vu(r,this._globalState);if(i.setEventedParent(this,{layer:{id:r.id}}),this._layers[r.id]=i,Fh(i)&&this.tileManagers[i.source]){let a=((t=r.paint)==null?void 0:t["raster-fade-duration"])??i.paint.get("raster-fade-duration");this.tileManagers[i.source].setRasterFadeDuration(a)}}}async _loadSprite(e,t=!1,r=void 0){this.imageManager.setLoaded(!1);let i=new AbortController;this._spriteRequest=i;let a;try{let n=await FC(e,this.map._requestManager,this.map.getPixelRatio(),i);if(!n)return;for(let s in n){let{loaded:o,removed:l}=this.imageManager.setSpriteImages(s,n[s]);this._markImagesChanged(l),t&&this._markImagesChanged(o)}}catch(n){a=n,i.signal.aborted||this.fire(new Y(a))}finally{this._spriteRequest=null,this.imageManager.setLoaded(!0),t&&(this._changed=!0),this.dispatcher.broadcast("SI",this.imageManager.listImages()),this.fire(new Tr("data")),r==null||r(a)}}_unloadSprite(){this._markImagesChanged(this.imageManager.removeAllSpriteImages()),this._imagesListDirty=!0,this._changed=!0,this.fire(new Tr("data"))}_validateLayer(e){let t=this.tileManagers[e.source];if(!t)return;let r=e.sourceLayer;if(!r)return;let i=t.getSource();(i.type==="geojson"||i.vectorLayerIds&&!i.vectorLayerIds.includes(r))&&this.fire(new Y(Error(`Source layer "${r}" does not exist on source "${i.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 r=this._serializedAllLayers();if(!e||e.length===0)return Object.values(t?Wt(r):r);let i=[];for(let a of e)if(r[a]){let n=t?Wt(r[a]):r[a];i.push(n)}return i}_serializedAllLayers(){let e=this._serializedLayers;if(e)return e;e=this._serializedLayers={};let t=Object.keys(this._layers);for(let r of t){let i=this._layers[r];i.type!=="custom"&&(e[r]=i.serialize())}return e}hasTransitions(){var e,t,r;if((e=this.light)!=null&&e.hasTransition()||(t=this.sky)!=null&&t.hasTransition()||(r=this.projection)!=null&&r.hasTransition())return!0;for(let i in this.tileManagers)if(this.tileManagers[i].hasTransition())return!0;for(let i in this._layers)if(this._layers[i].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._imagesListDirty=(this.dispatcher.broadcast("SI",this.imageManager.listImages()),!1));let a=Object.keys(this._updatedLayers),n=Object.keys(this._removedLayers);(a.length||n.length)&&this._updateWorkerLayers(a,n);for(let s in this._updatedSources){let o=this._updatedSources[s];if(o==="reload")this._reloadSource(s);else if(o==="clear")this._clearSource(s);else throw Error(`Invalid action ${o}`)}this._updateTilesForChangedImages(),this._updateTilesForChangedGlyphs();for(let s in this._updatedPaintProps)this._layers[s].updateTransitions(e);this._resetUpdates()}let r={};for(let a in this.tileManagers){let n=this.tileManagers[a];r[a]=n.used,n.used=!1}let i=this.imageManager.listImages();for(let a of this._order){let n=this._layers[a];n.recalculate(e,i),!n.isHidden(e.zoom)&&n.source&&(this.tileManagers[n.source].used=!0)}for(let a in r){let n=this.tileManagers[a];!!r[a]!=!!n.used&&n.fire(new Ne("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 Tr("data"))}_updateTilesForChangedImages(){let e=Object.keys(this._changedImages);if(e.length){for(let t in this.tileManagers)this.tileManagers[t].reloadTilesForDependencies(["icons","patterns"],e);this._changedImages={}}}_updateTilesForChangedGlyphs(){if(this._glyphsDidChange){for(let e in this.tileManagers)this.tileManagers[e].reloadTilesForDependencies(["glyphs"],[""]);this._glyphsDidChange=!1}}_updateWorkerLayers(e,t){this.dispatcher.broadcast("UL",{layers:this._serializeByIds(e,!1),removedIds:t})}_resetUpdates(){this._changed=!1,this._updatedLayers={},this._removedLayers={},this._updatedSources={},this._updatedPaintProps={},this._changedImages={},this._glyphsDidChange=!1}setState(e,t={}){this._checkLoaded();let r=this.serialize();if(e=t.transformStyle?t.transformStyle(r,e):e,(t.validate??!0)&&pf(this,e))return!1;e=Wt(e),e.layers=Em(e.layers);let i=MC(r,e),a=this._getOperationsToPerform(i);if(a.unimplemented.length>0)throw Error(`Unimplemented: ${a.unimplemented.join(", ")}.`);if(a.operations.length===0)return!1;for(let n of a.operations)n();return this.stylesheet=e,this._serializedLayers=null,this.fire(new Sm({style:this})),!0}_getOperationsToPerform(e){let t=[],r=[];for(let i of e)switch(i.command){case"setCenter":case"setZoom":case"setBearing":case"setPitch":case"setRoll":continue;case"addLayer":{let[a,n]=i.args;t.push(()=>this.addLayer(a,n));break}case"removeLayer":{let[a]=i.args;t.push(()=>this.removeLayer(a));break}case"setPaintProperty":{let[a,n,s]=i.args;t.push(()=>this.setPaintProperty(a,n,s));break}case"setLayoutProperty":{let[a,n,s]=i.args;t.push(()=>this.setLayoutProperty(a,n,s));break}case"setFilter":{let[a,n]=i.args;t.push(()=>this.setFilter(a,n));break}case"addSource":{let[a,n]=i.args;t.push(()=>this.addSource(a,n));break}case"removeSource":{let[a]=i.args;t.push(()=>this.removeSource(a));break}case"setLayerZoomRange":{let[a,n,s]=i.args;t.push(()=>this.setLayerZoomRange(a,n,s));break}case"setLight":{let[a]=i.args;t.push(()=>this.setLight(a));break}case"setGeoJSONSourceData":{let[a,n]=i.args;t.push(()=>this.setGeoJSONSourceData(a,n));break}case"setGlyphs":{let[a]=i.args;t.push(()=>this.setGlyphs(a));break}case"setFontFaces":{let[a]=i.args;t.push(()=>this.setFontFaces(a));break}case"setSprite":{let[a]=i.args;t.push(()=>this.setSprite(a));break}case"setTerrain":{let[a]=i.args;t.push(()=>this.map.setTerrain(a));break}case"setSky":{let[a]=i.args;t.push(()=>this.setSky(a));break}case"setProjection":{let[a]=i.args;t.push(()=>this.setProjection(a));break}case"setGlobalState":{let[a]=i.args;t.push(()=>this.setGlobalState(a));break}case"setTransition":t.push(()=>{});break;default:r.push(i.command)}return{operations:t,unimplemented:r}}addImage(e,t){if(this.getImage(e)){this.fire(new Y(Error(`An image named "${e}" already exists.`)));return}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){if(!this.getImage(e)){this.fire(new Y(Error(`An image named "${e}" does not exist.`)));return}this.imageManager.removeImage(e),this._afterImageUpdated(e)}_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 Tr("data"))}listImages(){return this._checkLoaded(),this.imageManager.listImages()}addSource(e,t,r={}){var a;if(this._checkLoaded(),this.tileManagers[e]!==void 0)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(my.has(t.type)&&this._validate(Zt.source,`sources.${e}`,t,null,r))return;(a=this.map)!=null&&a._collectResourceTiming&&(t.collectResourceTiming=!0);let i=this.tileManagers[e]=new Fc(e,t,this.dispatcher);i.style=this,i.setEventedParent(this,()=>({isSourceLoaded:i.loaded(),source:i.serialize(),sourceId:e})),i.onAdd(this.map),this._changed=!0}removeSource(e){if(this._checkLoaded(),this.tileManagers[e]===void 0)throw Error(`There is no source with this ID=${e}`);for(let r in this._layers)if(this._layers[r].source===e)return this.fire(new Y(Error(`Source "${e}" cannot be removed while layer "${r}" is using it.`)));let t=this.tileManagers[e];delete this.tileManagers[e],delete this._updatedSources[e],t.fire(new Ne("data",{sourceDataType:"metadata",sourceId:e})),t.setEventedParent(null),t.onRemove(this.map),this._changed=!0}setGeoJSONSourceData(e,t){if(this._checkLoaded(),this.tileManagers[e]===void 0)throw Error(`There is no source with this ID=${e}`);let r=this.tileManagers[e].getSource();if(r.type!=="geojson")throw Error(`geojsonSource.type is ${r.type}, which is !== 'geojson`);r.setData(t),this._changed=!0}getSource(e){var t;return(t=this.tileManagers[e])==null?void 0:t.getSource()}addLayer(e,t,r={}){this._checkLoaded();let i=e.id;if(this.getLayer(i)){this.fire(new Y(Error(`Layer "${i}" already exists on this map.`)));return}let a;if(e.type==="custom"){if(pd(this,_E(e)))return;a=Vu(e,this._globalState)}else{if("source"in e&&typeof e.source=="object"&&(this.addSource(i,e.source),e=Wt(e),e=H(e,{source:i})),this._validate(Zt.layer,`layers.${i}`,e,{arrayIndex:-1},r))return;a=Vu(e,this._globalState),this._validateLayer(a),a.setEventedParent(this,{layer:{id:i}})}let n=t?this._order.indexOf(t):this._order.length;if(t&&n===-1){this.fire(new Y(Error(`Cannot add layer "${i}" before non-existing layer "${t}".`)));return}if(this._order.splice(n,0,i),this._layerOrderChanged=!0,this._layers[i]=a,this._removedLayers[i]&&a.source&&a.type!=="custom"){let s=this._removedLayers[i];delete this._removedLayers[i],s.type===a.type?(this._updatedSources[a.source]="reload",this.tileManagers[a.source].pause()):this._updatedSources[a.source]="clear"}this._updateLayer(a),a.onAdd&&a.onAdd(this.map)}moveLayer(e,t){if(this._checkLoaded(),this._changed=!0,!this._layers[e]){this.fire(new Y(Error(`The layer '${e}' does not exist in the map's style and cannot be moved.`)));return}if(e===t)return;if(t&&!this._order.includes(t)){this.fire(new Y(Error(`Cannot move layer "${e}" before non-existing layer "${t}".`)));return}let r=this._order.indexOf(e);this._order.splice(r,1);let i=t?this._order.indexOf(t):this._order.length;this._order.splice(i,0,e),this._layerOrderChanged=!0}removeLayer(e){var i;this._checkLoaded();let t=this._layers[e];if(!t){this.fire(new Y(Error(`Cannot remove non-existing layer "${e}".`)));return}t.setEventedParent(null);let r=this._order.indexOf(e);this._order.splice(r,1),this._layerOrderChanged=!0,this._changed=!0,this._removedLayers[e]=t,delete this._layers[e],this._serializedLayers&&delete this._serializedLayers[e],delete this._updatedLayers[e],delete this._updatedPaintProps[e],t.type==="symbol"&&t.source&&((i=this.tileManagers[t.source])==null||i.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,r){this._checkLoaded();let i=this.getLayer(e);if(!i){this.fire(new Y(Error(`Cannot set the zoom range of non-existing layer "${e}".`)));return}(i.minzoom!==t||i.maxzoom!==r)&&(t!=null&&(i.minzoom=t),r!=null&&(i.maxzoom=r),this._updateLayer(i))}setFilter(e,t,r={}){this._checkLoaded();let i=this.getLayer(e);if(!i){this.fire(new Y(Error(`Cannot filter non-existing layer "${e}".`)));return}if(!Br(i.filter,t)){if(t==null){i.setFilter(void 0),this._updateLayer(i);return}this._validate(Zt.filter,`layers.${i.id}.filter`,t,null,r)||(i.setFilter(Wt(t)),this._updateLayer(i))}}getFilter(e){return Wt(this.getLayer(e).filter)}setLayoutProperty(e,t,r,i={}){this._checkLoaded();let a=this.getLayer(e);if(!a){this.fire(new Y(Error(`Cannot style non-existing layer "${e}".`)));return}Br(a.getLayoutProperty(t),r)||(a.setLayoutProperty(t,r,i),this._updateLayer(a))}getLayoutProperty(e,t){let r=this.getLayer(e);if(!r){this.fire(new Y(Error(`Cannot get style of non-existing layer "${e}".`)));return}return r.getLayoutProperty(t)}setPaintProperty(e,t,r,i={}){this._checkLoaded();let a=this.getLayer(e);if(!a){this.fire(new Y(Error(`Cannot style non-existing layer "${e}".`)));return}Br(a.getPaintProperty(t),r)||this._updatePaintProperty(a,t,r,i)}_updatePaintProperty(e,t,r,i={}){e.setPaintProperty(t,r,i)&&this._updateLayer(e),Fh(e)&&t==="raster-fade-duration"&&this.tileManagers[e.source].setRasterFadeDuration(r),this._changed=!0,this._updatedPaintProps[e.id]=!0,e.type==="symbol"&&this.triggerSymbolPlacement(),this._serializedLayers=null}getPaintProperty(e,t){return this.getLayer(e).getPaintProperty(t)}setFeatureState(e,t){this._checkLoaded();let r=e.source,i=e.sourceLayer,a=this.tileManagers[r];if(a===void 0){this.fire(new Y(Error(`The source '${r}' does not exist in the map's style.`)));return}let n=a.getSource().type;if(n==="geojson"&&i){this.fire(new Y(Error("GeoJSON sources cannot have a sourceLayer parameter.")));return}if(n==="vector"&&!i){this.fire(new Y(Error("The sourceLayer parameter must be provided for vector source types.")));return}if(e.id===void 0){this.fire(new Y(Error("The feature id parameter must be provided.")));return}let s=["__proto__","constructor","prototype"];if(t&&Object.keys(t).some(o=>s.includes(o))){this.fire(new Y(Error(`The feature state should not include one of the following keys: ${s}`)));return}a.setFeatureState(i,e.id,t)}removeFeatureState(e,t){this._checkLoaded();let r=e.source,i=this.tileManagers[r];if(i===void 0){this.fire(new Y(Error(`The source '${r}' does not exist in the map's style.`)));return}let a=i.getSource().type,n=a==="vector"?e.sourceLayer:void 0;if(a==="vector"&&!n){this.fire(new Y(Error("The sourceLayer parameter must be provided for vector source types.")));return}if(t&&typeof e.id!="string"&&typeof e.id!="number"){this.fire(new Y(Error("A feature id is required to remove its specific state property.")));return}i.removeFeatureState(n,e.id,t)}getFeatureState(e){this._checkLoaded();let t=e.source,r=e.sourceLayer,i=this.tileManagers[t];if(i===void 0){this.fire(new Y(Error(`The source '${t}' does not exist in the map's style.`)));return}if(i.getSource().type==="vector"&&!r){this.fire(new Y(Error("The sourceLayer parameter must be provided for vector source types.")));return}return e.id===void 0&&this.fire(new Y(Error("The feature id parameter must be provided."))),i.getFeatureState(r,e.id)}getTransition(){var e;return H({duration:300,delay:0},(e=this.stylesheet)==null?void 0:e.transition)}serialize(){if(!this._loaded)return;let e=Zc(this.tileManagers,a=>a.serialize()),t=this._serializeByIds(this._order,!0),r=this.map.getTerrain()||void 0,i=this.stylesheet;return Gg({version:i.version,name:i.name,metadata:i.metadata,light:i.light,sky:i.sky,center:i.center,zoom:i.zoom,bearing:i.bearing,pitch:i.pitch,sprite:i.sprite,glyphs:i.glyphs,"font-faces":i["font-faces"],transition:i.transition,projection:i.projection,state:i.state,sources:e,layers:t,terrain:r},a=>a!==void 0)}_updateLayer(e){this._updatedLayers[e.id]=!0,e.source&&!this._updatedSources[e.source]&&this.tileManagers[e.source].getSource().type!=="raster"&&(this._updatedSources[e.source]="reload",this.tileManagers[e.source].pause()),this._serializedLayers=null,this._changed=!0}_flattenAndSortRenderedFeatures(e){let t=n=>this._layers[n].type==="fill-extrusion",r={},i=[];for(let n=this._order.length-1;n>=0;n--){let s=this._order[n];if(t(s)){r[s]=n;for(let o of e){let l=o[s];if(l)for(let u of l)i.push(u)}}}i.sort((n,s)=>s.intersectionZ-n.intersectionZ);let a=[];for(let n=this._order.length-1;n>=0;n--){let s=this._order[n];if(t(s))for(let o=i.length-1;o>=0;o--){let l=i[o].feature;if(r[l.layer.id]<n)break;a.push(l),i.pop()}else for(let o of e){let l=o[s];if(l)for(let u of l)a.push(u.feature)}}return a}queryRenderedFeatures(e,t,r){t!=null&&t.filter&&this._validate(Zt.filter,"queryRenderedFeatures.filter",t.filter,null,t);let i={};if(t!=null&&t.layers){if(!(Array.isArray(t.layers)||t.layers instanceof Set))return this.fire(new Y(Error("parameters.layers must be an Array or a Set of strings"))),[];for(let l of t.layers){let u=this._layers[l];if(!u)return this.fire(new Y(Error(`The layer '${l}' does not exist in the map's style and cannot be queried for features.`))),[];i[u.source]=!0}}let a=[];t.availableImages=this.imageManager.listImages();let n=this._serializedAllLayers(),s=t.layers instanceof Set?t.layers:Array.isArray(t.layers)?new Set(t.layers):null,o={...t,layers:s,globalState:this._globalState};for(let l in this.tileManagers)(!t.layers||i[l])&&a.push(uI(this.tileManagers[l],this._layers,n,e,o,r,this.map.terrain?(u,h,c)=>this.map.terrain.getElevation(u,h,c):void 0));return this.placement&&a.push(hI(this._layers,n,this.tileManagers,e,o,this.placement.collisionIndex,this.placement.retainedQueryData)),this._flattenAndSortRenderedFeatures(a)}querySourceFeatures(e,t){t!=null&&t.filter&&this._validate(Zt.filter,"querySourceFeatures.filter",t.filter,null,t);let r=this.tileManagers[e];return r?cI(r,t?{...t,globalState:this._globalState}:{globalState:this._globalState}):[]}getLight(){return this.light.getLight()}setLight(e,t={}){this._checkLoaded();let r=this.light.getLight(),i=!1;for(let n in e)if(!Br(e[n],r[n])){i=!0;break}if(!i)return;let a={now:Fe(),transition:H({duration:300,delay:0},this.stylesheet.transition)};this.light.setLight(e,t),this.light.updateTransitions(a)}getProjection(){var e;return(e=this.stylesheet)==null?void 0:e.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(){var e;return(e=this.stylesheet)==null?void 0:e.sky}setSky(e,t={}){this._checkLoaded();let r=this.getSky(),i=!1;if(!e&&!r)return;if(e&&!r)i=!0;else if(!e&&r)i=!0;else for(let n in e)if(!Br(e[n],r[n])){i=!0;break}if(!i)return;let a={now:Fe(),transition:H({duration:300,delay:0},this.stylesheet.transition)};this.sky.setSky(e,t)&&(this.stylesheet.sky=e,this.sky.updateTransitions(a))}_setProjectionInternal(e){var r;let t=i3(e,(r=this.map._camera)==null?void 0:r.transform.constrainOverride,this._globalState);this.projection=t.projection,this.map.migrateProjection(t.transform,t.cameraHelper);for(let i in this.tileManagers)this.tileManagers[i].reload()}_validate(e,t,r,i,a={}){return a.validate!==!1&&gs(this,e,{key:t,style:this.serialize(),value:r,...i},a)}_remove(e=!0){this._frameRequest&&(this._frameRequest=(this._frameRequest.abort(),null)),this._loadStyleRequest&&(this._loadStyleRequest=(this._loadStyleRequest.abort(),null)),this._spriteRequest&&(this._spriteRequest=(this._spriteRequest.abort(),null)),Mc().off(Ic,this._rtlPluginLoaded);for(let t in this._layers)this._layers[t].setEventedParent(null);for(let t in this.tileManagers){let r=this.tileManagers[t];r.setEventedParent(null),r.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,r){var a;let i=this.pauseablePlacement;return!i||this._symbolPlacementTriggered||this._placedProjectionTransition!==((a=this.projection)==null?void 0:a.transitionState)||i._showCollisionBoxes!==t||i.placement.collisionGroups.crossSourceCollisions!==r||i.placement.transform.renderWorldCopies!==e.renderWorldCopies||!qx(i.placement.transform.modelViewProjectionMatrix,e.modelViewProjectionMatrix)}_updatePlacement(e,t,r,i,a=!1){var h,c;let n=!1,s=!1,o={};for(let d of this._order){let p=this._layers[d];if(p.type!=="symbol")continue;if(!o[p.source]){let m=this.tileManagers[p.source];o[p.source]=m.getRenderableIds(!0).map(g=>m.getTileByID(g)).sort((g,_)=>_.tileID.overscaledZ-g.tileID.overscaledZ||(g.tileID.isLessThan(_.tileID)?-1:1))}let f=this.crossTileSymbolIndex.addLayer(p,o[p.source],e.center.lng);n||(n=f)}this.crossTileSymbolIndex.pruneUnusedLayers(this._order),a||(a=this._layerOrderChanged||r===0);let l=n||this._placementInputsChanged(e,t,i),u=((h=this.pauseablePlacement)==null?void 0:h.isDone())&&!this.placement.stillRecent(Fe(),e.zoom);if((a||!this.pauseablePlacement||u&&(l||this.placement.stale))&&(this._symbolPlacementTriggered=!1,this._placedProjectionTransition=(c=this.projection)==null?void 0:c.transitionState,this.pauseablePlacement=new DM(e,this.map.terrain,this._order,a,t,r,i,this.placement),this._layerOrderChanged=!1),this.pauseablePlacement.isDone()?l&&this.placement.setStale():(this.pauseablePlacement.continuePlacement(this._order,this._layers,o),this.pauseablePlacement.isDone()&&(this.placement=this.pauseablePlacement.commit(Fe()),s=!0),n&&this.pauseablePlacement.placement.setStale()),s||n)for(let d of this._order){let p=this._layers[d];p.type==="symbol"&&this.placement.updateLayerOpacities(p,o[p.source])}return!this.pauseablePlacement.isDone()||this.placement.hasTransitions(Fe())}_releaseSymbolFadeTiles(){for(let e in this.tileManagers)this.tileManagers[e].releaseSymbolFadeTiles()}async getImages(e,t){let r=await this.imageManager.getImages(t.icons);this._updateTilesForChangedImages();let i=this.tileManagers[t.source];return i&&i.setDependencies(t.tileID.key,t.type,t.icons),r}async getGlyphs(e,t){let r=await this.glyphManager.getGlyphs(t.stacks),i=this.tileManagers[t.source];return i&&i.setDependencies(t.tileID.key,t.type,[""]),r}getGlyphsUrl(){return this.stylesheet.glyphs||null}setGlyphs(e,t={}){this._checkLoaded(),!(e&&this._validate(Zt.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 r={};for(let[i,a]of Object.entries(t.dashes))r[i]=this.lineAtlas.getDash(a.dasharray,a.round);return r}addSprite(e,t,r={},i){this._checkLoaded();let a=[{id:e,url:t}],n=[...zo(this.stylesheet.sprite),...a];this._validate(Zt.sprite,"sprite",n,null,r)||(this.stylesheet.sprite=n,this._loadSprite(a,!0,i))}removeSprite(e){this._checkLoaded();let t=zo(this.stylesheet.sprite);if(!t.find(i=>i.id===e)){this.fire(new Y(Error(`Sprite "${e}" doesn't exists on this map.`)));return}let r=this.imageManager.removeSpriteImages(e);this._markImagesChanged(r),t.splice(t.findIndex(i=>i.id===e),1),this.stylesheet.sprite=t.length>0?t:void 0,this._imagesListDirty=!0,this._changed=!0,this.fire(new Tr("data"))}getSprite(){return zo(this.stylesheet.sprite)}setSprite(e,t={},r){this._checkLoaded(),!(e&&this._validate(Zt.sprite,"sprite",e,null,t))&&(this.stylesheet.sprite=e,e?this._loadSprite(e,!0,r):(this._unloadSprite(),r&&r(null)))}destroy(){this._frameRequest&&(this._frameRequest=(this._frameRequest.abort(),null)),this._loadStyleRequest&&(this._loadStyleRequest=(this._loadStyleRequest.abort(),null)),this._spriteRequest&&(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={}}};const n3=Ye([{name:"a_pos",type:"Int16",components:2},{name:"a_texture_pos",type:"Int16",components:2}]);var s3=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,r,i,a,n,s,o,l){this.context=e;let u=this.boundPaintVertexBuffers.length!==i.length;for(let h=0;!u&&h<i.length;h++)this.boundPaintVertexBuffers[h]!==i[h]&&(u=!0);!this.vao||this.boundProgram!==t||this.boundLayoutVertexBuffer!==r||u||this.boundIndexBuffer!==a||this.boundVertexOffset!==n||this.boundDynamicVertexBuffer!==s||this.boundDynamicVertexBuffer2!==o||this.boundDynamicVertexBuffer3!==l?this.freshBind(t,r,i,a,n,s,o,l):e.bindVertexArray.set(this.vao)}freshBind(e,t,r,i,a,n,s,o){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=r,this.boundIndexBuffer=i,this.boundVertexOffset=a,this.boundDynamicVertexBuffer=n,this.boundDynamicVertexBuffer2=s,this.boundDynamicVertexBuffer3=o,t.enableAttributes(h,e);for(let c of r)c.enableAttributes(h,e);n&&n.enableAttributes(h,e),s&&s.enableAttributes(h,e),o&&o.enableAttributes(h,e),t.bind(),t.setVertexAttribPointers(h,e,a);for(let c of r)c.bind(),c.setVertexAttribPointers(h,e,a);n&&(n.bind(),n.setVertexAttribPointers(h,e,a)),i&&i.bind(),s&&(s.bind(),s.setVertexAttribPointers(h,e,a)),o&&(o.bind(),o.setVertexAttribPointers(h,e,a)),u.currentNumAttributes=l}destroy(){this.vao&&(this.vao=(this.context.deleteVertexArray(this.vao),null))}};const o3=(e,t)=>({u_depth:new X(e,t.u_depth),u_terrain:new X(e,t.u_terrain)}),l3=(e,t)=>({u_texture:new X(e,t.u_texture),u_ele_delta:new U(e,t.u_ele_delta),u_fog_matrix:new Ar(e,t.u_fog_matrix),u_fog_color:new Ei(e,t.u_fog_color),u_fog_ground_blend:new U(e,t.u_fog_ground_blend),u_fog_ground_blend_opacity:new U(e,t.u_fog_ground_blend_opacity),u_horizon_color:new Ei(e,t.u_horizon_color),u_horizon_fog_blend:new U(e,t.u_horizon_fog_blend),u_is_globe_mode:new U(e,t.u_is_globe_mode)}),u3=(e,t)=>({u_ele_delta:new U(e,t.u_ele_delta)}),h3=(e,t,r,i,a)=>({u_texture:0,u_ele_delta:e,u_fog_matrix:t,u_fog_color:r?r.properties.get("fog-color"):oe.white,u_fog_ground_blend:r?r.properties.get("fog-ground-blend"):1,u_fog_ground_blend_opacity:a?0:r?r.calculateFogBlendOpacity(i):0,u_horizon_color:r?r.properties.get("horizon-color"):oe.white,u_horizon_fog_blend:r?r.properties.get("horizon-fog-blend"):1,u_is_globe_mode:+!!a}),c3=e=>({u_ele_delta:e}),Zl={ProjectionUBO:0,TerrainUBO:1,FrameUBO:2};function d3(e,t){for(let[r,i]of Object.entries(Zl)){let a=e.getUniformBlockIndex(t,r);a!==e.INVALID_INDEX&&e.uniformBlockBinding(t,a,i)}}const p3={float:[1,1],int:[1,1],vec2:[2,2],vec4:[4,4],mat4:[16,4]};function ep(e){let t={},r=0;for(let{name:i,type:a}of e){let[n,s]=p3[a];r=Math.ceil(r/s)*s,t[i]=r,r+=n}return{offsets:t,contentWords:r,sizeWords:Math.ceil(r/4)*4}}var tp=class{constructor(e,t,r){this.context=e,this.binding=t,this.contentWords=r.contentWords;let i=e.gl;this.buffer=i.createBuffer(),i.bindBuffer(i.UNIFORM_BUFFER,this.buffer),i.bufferData(i.UNIFORM_BUFFER,r.sizeWords*4,i.DYNAMIC_DRAW),this.uploaded=new Float32Array(r.sizeWords),this.pending=new Float32Array(r.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 r=this.pendingWords,i=this.uploadedWords;for(let a=0;a<this.contentWords;a++)if(r[a]!==i[a]){t=!0;break}}if(!t){this.bind();return}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}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)}};const rx=ep([{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"}]),xa=rx.offsets;function ix(e){return new tp(e,Zl.ProjectionUBO,rx)}function yg(e,t){let r=e.pending;r.set(t.mainMatrix,xa.u_projection_matrix),r.set(t.fallbackMatrix,xa.u_projection_fallback_matrix),r.set(t.tileMercatorCoords,xa.u_projection_tile_mercator_coords),r.set(t.clippingPlane,xa.u_projection_clipping_plane),r[xa.u_projection_transition]=t.projectionTransition,e.pendingWords[xa.u_projection_clip_antimeridian]=+!!t.clipAntimeridian,e.upload()}function f3(e,t){if(!t){e.projectionUniformBuffer.bind();return}let r=t.uniformBufferKey;if(r===void 0){yg(e.projectionUniformBuffer,t);return}let i=e.keyedProjectionUniformBuffers.get(r);if(i){i.bind();return}let a=e.freeProjectionUniformBuffers.pop()??ix(e);e.keyedProjectionUniformBuffers.set(r,a),yg(a,t)}function m3(e){e.freeProjectionUniformBuffers.push(...e.keyedProjectionUniformBuffers.values()),e.keyedProjectionUniformBuffers.clear()}function g3(e){e.projectionUniformBuffer.destroy();for(let t of e.keyedProjectionUniformBuffers.values())t.destroy();for(let t of e.freeProjectionUniformBuffers)t.destroy()}const ax=ep([{name:"u_terrain_matrix",type:"mat4"},{name:"u_terrain_unpack",type:"vec4"},{name:"u_terrain_dim",type:"float"},{name:"u_terrain_exaggeration",type:"float"}]),fo=ax.offsets;function _3(e){return new tp(e,Zl.TerrainUBO,ax)}function y3(e,t){let r=e.pending;r.set(t.u_terrain_matrix,fo.u_terrain_matrix),r.set(t.u_terrain_unpack,fo.u_terrain_unpack),r[fo.u_terrain_dim]=t.u_terrain_dim,r[fo.u_terrain_exaggeration]=t.u_terrain_exaggeration,e.upload()}function th(e){let t=[];for(let r of e){if(r===null)continue;let i=r.split(" ");t.push(i.pop())}return t}function x3(e,t){let r=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]),i=new Set,a=e.getProgramParameter(t,e.ACTIVE_ATTRIBUTES);for(let n=0;n<a;n++){let s=e.getActiveAttrib(t,n);s&&r.has(s.type)&&i.add(s.name)}return i}var v3=class{constructor(e,t,r,i,a,n,s,o,l=[]){let u=e.gl;this.program=u.createProgram();let h=th(t.staticAttributes),c=r?r.getBinderAttributes():[],d=h.concat(c),p=Vr.prelude.staticUniforms?th(Vr.prelude.staticUniforms):[],f=t.staticUniforms?th(t.staticUniforms):[],m=r?r.getBinderUniforms():[],g=p.concat(f).concat(m),_=[];for(let P of g)_.includes(P)||_.push(P);let y=r?r.defines():[];y.unshift("#version 300 es"),a&&y.push("#define OVERDRAW_INSPECTOR;"),n&&y.push("#define TERRAIN3D;"),o&&y.push(o),l&&y.push(...l);let v=y.concat(Vr.prelude.fragmentSource,s.fragmentSource,t.fragmentSource).join(`
|
|
820
|
+
`),x=y.concat(Vr.prelude.vertexSource,s.vertexSource,t.vertexSource).join(`
|
|
821
|
+
`),w=u.createShader(u.FRAGMENT_SHADER);if(u.isContextLost()){this.failedToCreate=!0;return}u.shaderSource(w,v),u.compileShader(w),u.attachShader(this.program,w);let b=u.createShader(u.VERTEX_SHADER);if(u.isContextLost()){this.failedToCreate=!0;return}u.shaderSource(b,x),u.compileShader(b),u.attachShader(this.program,b),this.attributes={};let S={};if(this.numAttributes=d.length,u.linkProgram(this.program),!u.getProgramParameter(this.program,u.LINK_STATUS)){if(u.isContextLost()){this.failedToCreate=!0;return}throw u.getShaderParameter(w,u.COMPILE_STATUS)?u.getShaderParameter(b,u.COMPILE_STATUS)?Error(`Program failed to link: ${u.getProgramInfoLog(this.program)}`):Error(`Could not compile vertex shader: ${u.getShaderInfoLog(b)}`):Error(`Could not compile fragment shader: ${u.getShaderInfoLog(w)}`)}d3(u,this.program);let A=x3(u,this.program);for(let P of d){if(!P)continue;let I=u.getAttribLocation(this.program,P);I>=0&&(this.attributes[P]={location:I,isInteger:A.has(P)})}u.deleteShader(b),u.deleteShader(w);for(let P of _)if(P&&!S[P]){let I=u.getUniformLocation(this.program,P);I&&(S[P]=I)}this.fixedUniforms=i(e,S),this.terrainUniforms=o3(e,S),this.binderUniforms=r?r.getUniforms(e,S):[]}draw(e,t,r,i,a,n,s,o,l,u,h,c,d,p,f,m,g,_,y){var w;let v=e.gl;if(this.failedToCreate)return;if(e.program.set(this.program),e.terrainUniformBuffer.bind(),e.frameUniformBuffer.bind(),e.setDepthMode(r),e.setStencilMode(i),e.setColorMode(a),e.setCullFace(n),o){e.activeTexture.set(v.TEXTURE2),v.bindTexture(v.TEXTURE_2D,o.depthTexture),e.activeTexture.set(v.TEXTURE3),v.bindTexture(v.TEXTURE_2D,o.texture);for(let b in this.terrainUniforms)this.terrainUniforms[b].set(o[b]);y3(e.terrainUniformBuffer,o)}if(f3(e,l),s)for(let b in this.fixedUniforms)this.fixedUniforms[b].set(s[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={}),(w=b.vaos)[u]||(w[u]=new s3),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 nx(e,t,r){let i=1/nr(r,1,t.transform.tileZoom),a=2**r.tileID.overscaledZ,n=r.tileSize*2**t.transform.tileZoom/a,s=n*(r.tileID.canonical.x+r.tileID.wrap*a),o=n*r.tileID.canonical.y;return{u_image:0,u_texsize:r.imageAtlasTexture.size,u_scale:[i,e.fromScale,e.toScale],u_fade:e.t,u_pixel_coord_upper:[s>>16,o>>16],u_pixel_coord_lower:[s&65535,o&65535]}}function b3(e,t,r,i){let a=r.patternAtlas.getPattern(e.from.toString()),n=r.patternAtlas.getPattern(e.to.toString()),{width:s,height:o}=r.patternAtlas.getPixelSize(),l=2**i.tileID.overscaledZ,u=i.tileSize*2**r.transform.tileZoom/l,h=u*(i.tileID.canonical.x+i.tileID.wrap*l),c=u*i.tileID.canonical.y;return{u_image:0,u_pattern_tl_a:a.tl,u_pattern_br_a:a.br,u_pattern_tl_b:n.tl,u_pattern_br_b:n.br,u_texsize:[s,o],u_mix:t.t,u_pattern_size_a:a.displaySize,u_pattern_size_b:n.displaySize,u_scale_a:t.fromScale,u_scale_b:t.toScale,u_tile_units_to_pixels:1/nr(i,1,r.transform.tileZoom),u_pixel_coord_upper:[h>>16,c>>16],u_pixel_coord_lower:[h&65535,c&65535]}}const w3=(e,t)=>({u_lightpos:new jt(e,t.u_lightpos),u_lightpos_globe:new jt(e,t.u_lightpos_globe),u_lightintensity:new U(e,t.u_lightintensity),u_lightcolor:new jt(e,t.u_lightcolor),u_vertical_gradient:new U(e,t.u_vertical_gradient),u_opacity:new U(e,t.u_opacity),u_fill_translate:new de(e,t.u_fill_translate)}),T3=(e,t)=>({u_lightpos:new jt(e,t.u_lightpos),u_lightpos_globe:new jt(e,t.u_lightpos_globe),u_lightintensity:new U(e,t.u_lightintensity),u_lightcolor:new jt(e,t.u_lightcolor),u_vertical_gradient:new U(e,t.u_vertical_gradient),u_height_factor:new U(e,t.u_height_factor),u_opacity:new U(e,t.u_opacity),u_fill_translate:new de(e,t.u_fill_translate),u_image:new X(e,t.u_image),u_texsize:new de(e,t.u_texsize),u_pixel_coord_upper:new de(e,t.u_pixel_coord_upper),u_pixel_coord_lower:new de(e,t.u_pixel_coord_lower),u_scale:new jt(e,t.u_scale),u_fade:new U(e,t.u_fade)}),sx=(e,t,r,i)=>{let a=e.style.light,n=a.getCartesianPosition(),s=$g();a.properties.get("anchor")==="viewport"&&$x(s,e.transform.bearingInRadians),Yx(n,n,s);let o=e.transform.transformLightDirection(n),l=a.properties.get("color");return{u_lightpos:n,u_lightpos_globe:o,u_lightintensity:a.properties.get("intensity"),u_lightcolor:[l.r,l.g,l.b],u_vertical_gradient:+t,u_opacity:r,u_fill_translate:i}},S3=(e,t,r,i,a,n,s)=>H(sx(e,t,r,i),nx(n,e,s),{u_height_factor:-(2**a.overscaledZ)/s.tileSize/8}),D3=(e,t)=>({u_fill_translate:new de(e,t.u_fill_translate)}),E3=(e,t)=>({u_image:new X(e,t.u_image),u_texsize:new de(e,t.u_texsize),u_pixel_coord_upper:new de(e,t.u_pixel_coord_upper),u_pixel_coord_lower:new de(e,t.u_pixel_coord_lower),u_scale:new jt(e,t.u_scale),u_fade:new U(e,t.u_fade),u_sdf_pattern:new X(e,t.u_sdf_pattern),u_fill_translate:new de(e,t.u_fill_translate)}),P3=(e,t)=>({u_fill_translate:new de(e,t.u_fill_translate)}),A3=(e,t)=>({u_image:new X(e,t.u_image),u_texsize:new de(e,t.u_texsize),u_pixel_coord_upper:new de(e,t.u_pixel_coord_upper),u_pixel_coord_lower:new de(e,t.u_pixel_coord_lower),u_scale:new jt(e,t.u_scale),u_fade:new U(e,t.u_fade),u_sdf_pattern:new X(e,t.u_sdf_pattern),u_fill_translate:new de(e,t.u_fill_translate)}),ox=(e,t,r,i,a)=>H(nx(t,e,r),{u_fill_translate:i,u_sdf_pattern:+!!a}),C3=e=>({u_fill_translate:e}),I3=e=>({u_fill_translate:e}),M3=(e,t,r,i,a)=>ox(e,t,r,i,a),z3=(e,t)=>({u_scale_with_map:new X(e,t.u_scale_with_map),u_pitch_with_map:new X(e,t.u_pitch_with_map),u_extrude_scale:new de(e,t.u_extrude_scale),u_globe_extrude_scale:new U(e,t.u_globe_extrude_scale),u_translate:new de(e,t.u_translate)}),F3=(e,t,r,i,a)=>{let n=e.transform,s,o,l=0;if(r.paint.get("circle-pitch-alignment")==="map"){let u=nr(t,1,n.zoom);s=!0,o=[u,u],l=u/(L*2**t.tileID.overscaledZ)*2*Math.PI*a}else s=!1,o=n.pixelsToGLUnits;return{u_scale_with_map:+(r.paint.get("circle-pitch-scale")==="map"),u_pitch_with_map:+s,u_extrude_scale:o,u_globe_extrude_scale:l,u_translate:i}},R3=(e,t)=>({u_color:new Ei(e,t.u_color),u_overlay:new X(e,t.u_overlay),u_overlay_scale:new U(e,t.u_overlay_scale)}),xg=(e,t=1)=>({u_color:e,u_overlay:0,u_overlay_scale:t}),k3=(e,t)=>({u_extrude_scale:new U(e,t.u_extrude_scale),u_intensity:new U(e,t.u_intensity),u_globe_extrude_scale:new U(e,t.u_globe_extrude_scale)}),L3=(e,t)=>({u_matrix:new Ar(e,t.u_matrix),u_image:new X(e,t.u_image),u_color_ramp:new X(e,t.u_color_ramp),u_opacity:new U(e,t.u_opacity)}),lx=(e,t,r,i)=>{let a=nr(e,1,t)/(L*2**e.tileID.overscaledZ)*2*Math.PI*i;return{u_extrude_scale:nr(e,1,t),u_intensity:r,u_globe_extrude_scale:a}},ux=(e,t,r,i)=>{let a=Pi();return Lr(a,0,e.width,e.height,0,0,1),{u_matrix:a,u_image:r,u_color_ramp:i,u_opacity:t.paint.get("heatmap-opacity")}},B3=(e,t)=>({u_image:new X(e,t.u_image),u_latrange:new de(e,t.u_latrange),u_exaggeration:new U(e,t.u_exaggeration),u_altitudes:new Sf(e,t.u_altitudes),u_azimuths:new Sf(e,t.u_azimuths),u_accent:new Ei(e,t.u_accent),u_method:new X(e,t.u_method),u_shadows:new Tf(e,t.u_shadows),u_highlights:new Tf(e,t.u_highlights)}),O3=(e,t)=>({u_matrix:new Ar(e,t.u_matrix),u_image:new X(e,t.u_image),u_dimension:new de(e,t.u_dimension),u_zoom:new U(e,t.u_zoom),u_unpack:new es(e,t.u_unpack)}),$3=(e,t,r)=>{let i=r.paint.get("hillshade-accent-color"),a;switch(r.paint.get("hillshade-method")){case"basic":a=4;break;case"combined":a=1;break;case"igor":a=2;break;case"multidirectional":a=3;break;default:a=0}let n=r.getIlluminationProperties();for(let s=0;s<n.directionRadians.length;s++)r.paint.get("hillshade-illumination-anchor")==="viewport"&&(n.directionRadians[s]+=e.transform.bearingInRadians);return{u_image:0,u_latrange:V3(e,t.tileID),u_exaggeration:r.paint.get("hillshade-exaggeration"),u_altitudes:n.altitudeRadians,u_azimuths:n.directionRadians,u_accent:i,u_method:a,u_highlights:n.highlightColor,u_shadows:n.shadowColor}},j3=(e,t)=>{let r=t.stride,i=Pi();return Lr(i,0,L,-L,0,0,1),ot(i,i,[0,-L,0]),{u_matrix:i,u_image:1,u_dimension:[r,r],u_zoom:e.overscaledZ,u_unpack:t.getUnpackVector()}};function V3(e,t){let r=2**t.canonical.z,i=t.canonical.y;return[new Ie(0,i/r).toLngLat().lat,new Ie(0,(i+1)/r).toLngLat().lat]}const N3=(e,t)=>({u_image:new X(e,t.u_image),u_unpack:new es(e,t.u_unpack),u_dimension:new de(e,t.u_dimension),u_elevation_stops:new X(e,t.u_elevation_stops),u_color_stops:new X(e,t.u_color_stops),u_color_ramp_size:new X(e,t.u_color_ramp_size),u_opacity:new U(e,t.u_opacity)}),U3=(e,t,r=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:r,u_opacity:e.paint.get("color-relief-opacity")}),G3=(e,t)=>({u_translation:new de(e,t.u_translation),u_ratio:new U(e,t.u_ratio)}),q3=(e,t)=>({u_translation:new de(e,t.u_translation),u_ratio:new U(e,t.u_ratio),u_image:new X(e,t.u_image),u_image_height:new U(e,t.u_image_height)}),Z3=(e,t)=>({u_translation:new de(e,t.u_translation),u_texsize:new de(e,t.u_texsize),u_ratio:new U(e,t.u_ratio),u_image:new X(e,t.u_image),u_scale:new jt(e,t.u_scale),u_fade:new U(e,t.u_fade)}),W3=(e,t)=>({u_translation:new de(e,t.u_translation),u_ratio:new U(e,t.u_ratio),u_image:new X(e,t.u_image),u_mix:new U(e,t.u_mix),u_tileratio:new U(e,t.u_tileratio),u_crossfade_from:new U(e,t.u_crossfade_from),u_crossfade_to:new U(e,t.u_crossfade_to),u_lineatlas_width:new U(e,t.u_lineatlas_width),u_lineatlas_height:new U(e,t.u_lineatlas_height)}),H3=(e,t)=>({u_translation:new de(e,t.u_translation),u_ratio:new U(e,t.u_ratio),u_image:new X(e,t.u_image),u_image_height:new U(e,t.u_image_height),u_tileratio:new U(e,t.u_tileratio),u_crossfade_from:new U(e,t.u_crossfade_from),u_crossfade_to:new U(e,t.u_crossfade_to),u_image_dash:new X(e,t.u_image_dash),u_mix:new U(e,t.u_mix),u_lineatlas_width:new U(e,t.u_lineatlas_width),u_lineatlas_height:new U(e,t.u_lineatlas_height)}),Wl=(e,t,r,i)=>{let a=e.transform;return{u_translation:hx(e,t,r),u_ratio:i/nr(t,1,a.zoom)}},X3=(e,t,r,i,a)=>H(Wl(e,t,r,i),{u_image:0,u_image_height:a}),Y3=(e,t,r,i,a)=>{let n=e.transform,s=rp(t,n);return{u_translation:hx(e,t,r),u_texsize:t.imageAtlasTexture.size,u_ratio:i/nr(t,1,n.zoom),u_image:0,u_scale:[s,a.fromScale,a.toScale],u_fade:a.t}},K3=(e,t,r,i,a)=>{let n=e.transform,s=rp(t,n);return H(Wl(e,t,r,i),{u_tileratio:s,u_crossfade_from:a.fromScale,u_crossfade_to:a.toScale,u_image:0,u_mix:a.t,u_lineatlas_width:e.lineAtlas.width,u_lineatlas_height:e.lineAtlas.height})},J3=(e,t,r,i,a,n)=>{let s=e.transform,o=rp(t,s);return H(Wl(e,t,r,i),{u_image:0,u_image_height:n,u_tileratio:o,u_crossfade_from:a.fromScale,u_crossfade_to:a.toScale,u_image_dash:1,u_mix:a.t,u_lineatlas_width:e.lineAtlas.width,u_lineatlas_height:e.lineAtlas.height})};function rp(e,t){return 1/nr(e,1,t.tileZoom)}function hx(e,t,r){return Ti(e.transform,t,r.paint.get("line-translate"),r.paint.get("line-translate-anchor"))}const Q3=(e,t)=>({u_image:new X(e,t.u_image),u_opacity:new U(e,t.u_opacity)}),ez=(e,t)=>({u_image:t,u_opacity:e}),tz=(e,t)=>({u_is_size_zoom_constant:new X(e,t.u_is_size_zoom_constant),u_is_size_feature_constant:new X(e,t.u_is_size_feature_constant),u_size_t:new U(e,t.u_size_t),u_size:new U(e,t.u_size),u_rotate_symbol:new X(e,t.u_rotate_symbol),u_label_plane_matrix:new Ar(e,t.u_label_plane_matrix),u_coord_matrix:new Ar(e,t.u_coord_matrix),u_is_text:new X(e,t.u_is_text),u_pitch_with_map:new X(e,t.u_pitch_with_map),u_is_along_line:new X(e,t.u_is_along_line),u_is_variable_anchor:new X(e,t.u_is_variable_anchor),u_texsize:new de(e,t.u_texsize),u_texture:new X(e,t.u_texture),u_translation:new de(e,t.u_translation),u_pitched_scale:new U(e,t.u_pitched_scale),u_is_offset:new X(e,t.u_is_offset),u_height_anchor_ground:new X(e,t.u_height_anchor_ground)}),rz=(e,t)=>({u_is_size_zoom_constant:new X(e,t.u_is_size_zoom_constant),u_is_size_feature_constant:new X(e,t.u_is_size_feature_constant),u_size_t:new U(e,t.u_size_t),u_size:new U(e,t.u_size),u_rotate_symbol:new X(e,t.u_rotate_symbol),u_label_plane_matrix:new Ar(e,t.u_label_plane_matrix),u_coord_matrix:new Ar(e,t.u_coord_matrix),u_is_text:new X(e,t.u_is_text),u_pitch_with_map:new X(e,t.u_pitch_with_map),u_is_along_line:new X(e,t.u_is_along_line),u_is_variable_anchor:new X(e,t.u_is_variable_anchor),u_texsize:new de(e,t.u_texsize),u_texture:new X(e,t.u_texture),u_gamma_scale:new U(e,t.u_gamma_scale),u_is_halo:new X(e,t.u_is_halo),u_is_plain:new X(e,t.u_is_plain),u_translation:new de(e,t.u_translation),u_pitched_scale:new U(e,t.u_pitched_scale),u_is_offset:new X(e,t.u_is_offset),u_height_anchor_ground:new X(e,t.u_height_anchor_ground)}),iz=(e,t)=>({u_is_size_zoom_constant:new X(e,t.u_is_size_zoom_constant),u_is_size_feature_constant:new X(e,t.u_is_size_feature_constant),u_size_t:new U(e,t.u_size_t),u_size:new U(e,t.u_size),u_rotate_symbol:new X(e,t.u_rotate_symbol),u_label_plane_matrix:new Ar(e,t.u_label_plane_matrix),u_coord_matrix:new Ar(e,t.u_coord_matrix),u_is_text:new X(e,t.u_is_text),u_pitch_with_map:new X(e,t.u_pitch_with_map),u_is_along_line:new X(e,t.u_is_along_line),u_is_variable_anchor:new X(e,t.u_is_variable_anchor),u_texsize:new de(e,t.u_texsize),u_texsize_icon:new de(e,t.u_texsize_icon),u_texture:new X(e,t.u_texture),u_texture_icon:new X(e,t.u_texture_icon),u_gamma_scale:new U(e,t.u_gamma_scale),u_is_halo:new X(e,t.u_is_halo),u_translation:new de(e,t.u_translation),u_pitched_scale:new U(e,t.u_pitched_scale),u_is_offset:new X(e,t.u_is_offset),u_height_anchor_ground:new X(e,t.u_height_anchor_ground)}),cx=(e,t,r,i,a,n,s,o,l,u,h,c,d,p,f)=>({u_is_size_zoom_constant:+(e==="constant"||e==="source"),u_is_size_feature_constant:+(e==="constant"||e==="camera"),u_size_t:t?t.uSizeT:0,u_size:t?t.uSize:0,u_rotate_symbol:+r,u_label_plane_matrix:o,u_coord_matrix:l,u_is_text:+h,u_pitch_with_map:+i,u_is_along_line:a,u_is_variable_anchor:n,u_texsize:c,u_texture:0,u_translation:u,u_pitched_scale:d,u_is_offset:p,u_height_anchor_ground:+f}),dx=(e,t,r,i,a,n,s,o,l,u,h,c,d,p,f,m)=>{let g=s.transform;return H(cx(e,t,r,i,a,n,s,o,l,u,h,c,p,f,m),{u_gamma_scale:i?Math.cos(g.pitch*Math.PI/180)*g.cameraToCenterDistance:1,u_is_halo:+!!d,u_is_plain:1})},az=(e,t,r,i,a,n,s,o,l,u,h,c,d,p,f)=>H(dx(e,t,r,i,a,n,s,o,l,u,!0,h,!0,d,p,f),{u_texsize_icon:c,u_texture_icon:1}),nz=(e,t)=>({u_opacity:new U(e,t.u_opacity),u_color:new Ei(e,t.u_color)}),sz=(e,t)=>({u_opacity:new U(e,t.u_opacity),u_image:new X(e,t.u_image),u_pattern_tl_a:new de(e,t.u_pattern_tl_a),u_pattern_br_a:new de(e,t.u_pattern_br_a),u_pattern_tl_b:new de(e,t.u_pattern_tl_b),u_pattern_br_b:new de(e,t.u_pattern_br_b),u_texsize:new de(e,t.u_texsize),u_mix:new U(e,t.u_mix),u_pattern_size_a:new de(e,t.u_pattern_size_a),u_pattern_size_b:new de(e,t.u_pattern_size_b),u_scale_a:new U(e,t.u_scale_a),u_scale_b:new U(e,t.u_scale_b),u_pixel_coord_upper:new de(e,t.u_pixel_coord_upper),u_pixel_coord_lower:new de(e,t.u_pixel_coord_lower),u_tile_units_to_pixels:new U(e,t.u_tile_units_to_pixels)}),oz=(e,t)=>({u_opacity:e,u_color:t}),lz=(e,t,r,i,a)=>H(b3(r,a,t,i),{u_opacity:e}),uz=(e,t)=>({u_sun_pos:new jt(e,t.u_sun_pos),u_atmosphere_blend:new U(e,t.u_atmosphere_blend),u_globe_position:new jt(e,t.u_globe_position),u_globe_radius:new U(e,t.u_globe_radius),u_inv_proj_matrix:new Ar(e,t.u_inv_proj_matrix)}),hz=(e,t,r,i,a)=>({u_sun_pos:e,u_atmosphere_blend:t,u_globe_position:r,u_globe_radius:i,u_inv_proj_matrix:a}),cz=(e,t)=>({u_sky_color:new Ei(e,t.u_sky_color),u_horizon_color:new Ei(e,t.u_horizon_color),u_horizon:new de(e,t.u_horizon),u_horizon_normal:new de(e,t.u_horizon_normal),u_sky_horizon_blend:new U(e,t.u_sky_horizon_blend),u_sky_blend:new U(e,t.u_sky_blend),u_inv_proj_matrix:new Ar(e,t.u_inv_proj_matrix),u_globe_position:new jt(e,t.u_globe_position),u_globe_radius:new U(e,t.u_globe_radius),u_atmosphere_blend:new U(e,t.u_atmosphere_blend)}),dz=(e,t,r)=>{let i=Math.cos(t.rollInRadians),a=Math.sin(t.rollInRadians),n=jn(t),s=t.getProjectionData({overscaledTileID:null,applyGlobeMatrix:!0,applyTerrainMatrix:!0}).projectionTransition,o=X1(t),l=Xa(t.worldSize,t.center.lat);return{u_sky_color:e.properties.get("sky-color"),u_horizon_color:e.properties.get("horizon-color"),u_horizon:[(t.width/2-n*a)*r,(t.height/2+n*i)*r],u_horizon_normal:[-a,i],u_sky_horizon_blend:e.properties.get("sky-horizon-blend")*t.height/2*r,u_sky_blend:s,u_inv_proj_matrix:t.inverseProjectionMatrix,u_globe_position:o,u_globe_radius:l,u_atmosphere_blend:e.properties.get("atmosphere-blend")*Y1(Sr(o)-l,l)}},mo=(e,t)=>({}),pz={fillExtrusion:w3,fillExtrusionPattern:T3,fill:D3,fillPattern:E3,fillOutline:P3,fillOutlinePattern:A3,circle:z3,collisionBox:mo,collisionCircle:mo,debug:R3,depth:mo,clippingMask:mo,heatmap:k3,heatmapTexture:L3,hillshade:B3,hillshadePrepare:O3,colorRelief:N3,line:G3,lineGradient:q3,linePattern:Z3,lineSDF:W3,lineGradientSDF:H3,layerOpacity:Q3,raster:DI,symbolIcon:tz,symbolSDF:rz,symbolTextAndIcon:iz,background:nz,backgroundPattern:sz,terrain:l3,terrainDepth:u3,atmosphere:uz,sky:cz};var fz=class{constructor(e,t,r){this.context=e;let i=e.gl;this.buffer=i.createBuffer(),this.dynamicDraw=!!r,this.context.unbindVAO(),e.bindElementBuffer.set(this.buffer),i.bufferData(i.ELEMENT_ARRAY_BUFFER,t.arrayBuffer,this.dynamicDraw?i.DYNAMIC_DRAW:i.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)}};const vg={Int8:"BYTE",Uint8:"UNSIGNED_BYTE",Int16:"SHORT",Uint16:"UNSIGNED_SHORT",Int32:"INT",Uint32:"UNSIGNED_INT",Float32:"FLOAT"};var mz=class{constructor(e,t,r,i){this.length=t.length,this.attributes=r,this.itemSize=t.bytesPerElement,this.dynamicDraw=i,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 r of this.attributes){let i=t.attributes[r.name];i!==void 0&&e.enableVertexAttribArray(i.location)}}setVertexAttribPointers(e,t,r){for(let i of this.attributes){let a=t.attributes[i.name];if(a!==void 0){let n=i.offset+this.itemSize*(r||0);a.isInteger?e.vertexAttribIPointer(a.location,i.components,e[vg[i.type]],this.itemSize,n):e.vertexAttribPointer(a.location,i.components,e[vg[i.type]],!1,this.itemSize,n)}}}destroy(){let e=this.context.gl;this.buffer&&(e.deleteBuffer(this.buffer),delete this.buffer)}},Re=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)}},gz=class extends Re{getDefault(){return oe.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)}},_z=class extends Re{getDefault(){return 1}set(e){(e!==this.current||this.dirty)&&(this.gl.clearDepth(e),this.current=e,this.dirty=!1)}},yz=class extends Re{getDefault(){return 0}set(e){(e!==this.current||this.dirty)&&(this.gl.clearStencil(e),this.current=e,this.dirty=!1)}},xz=class extends Re{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)}},vz=class extends Re{getDefault(){return!0}set(e){(e!==this.current||this.dirty)&&(this.gl.depthMask(e),this.current=e,this.dirty=!1)}},bz=class extends Re{getDefault(){return 255}set(e){(e!==this.current||this.dirty)&&(this.gl.stencilMask(e),this.current=e,this.dirty=!1)}},wz=class extends Re{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)}},Tz=class extends Re{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)}},Sz=class extends Re{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}},Dz=class extends Re{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)}},Ez=class extends Re{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}},Pz=class extends Re{getDefault(){return this.gl.LESS}set(e){(e!==this.current||this.dirty)&&(this.gl.depthFunc(e),this.current=e,this.dirty=!1)}},Az=class extends Re{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}},Cz=class extends Re{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)}},Iz=class extends Re{getDefault(){return oe.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)}},Mz=class extends Re{getDefault(){return this.gl.FUNC_ADD}set(e){(e!==this.current||this.dirty)&&(this.gl.blendEquation(e),this.current=e,this.dirty=!1)}},zz=class extends Re{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}},Fz=class extends Re{getDefault(){return this.gl.BACK}set(e){(e!==this.current||this.dirty)&&(this.gl.cullFace(e),this.current=e,this.dirty=!1)}},Rz=class extends Re{getDefault(){return this.gl.CCW}set(e){(e!==this.current||this.dirty)&&(this.gl.frontFace(e),this.current=e,this.dirty=!1)}},kz=class extends Re{getDefault(){return null}set(e){(e!==this.current||this.dirty)&&(this.gl.useProgram(e),this.current=e,this.dirty=!1)}},Lz=class extends Re{getDefault(){return this.gl.TEXTURE0}set(e){(e!==this.current||this.dirty)&&(this.gl.activeTexture(e),this.current=e,this.dirty=!1)}},Bz=class extends Re{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)}},Oz=class extends Re{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}},$z=class extends Re{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}},jz=class extends Re{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}},Vz=class extends Re{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}},Nz=class extends Re{getDefault(){return null}set(e){let t=this.gl;t.bindBuffer(t.ELEMENT_ARRAY_BUFFER,e),this.current=e,this.dirty=!1}},Uz=class extends Re{getDefault(){return null}set(e){(e!==this.current||this.dirty)&&(this.gl.bindVertexArray(e),this.current=e,this.dirty=!1)}},Gz=class extends Re{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}},qz=class extends Re{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}},Zz=class extends Re{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}},ip=class extends Re{constructor(e,t){super(e),this.context=e,this.parent=t}getDefault(){return null}},Wz=class extends ip{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}},Hz=class extends ip{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}},Xz=class extends ip{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}},Yz=class{constructor(e,t,r,i,a){this.context=e,this.width=t,this.height=r;let n=e.gl,s=this.framebuffer=n.createFramebuffer();if(this.colorAttachment=new Wz(e,s),i)this.depthAttachment=a?new Xz(e,s):new Hz(e,s);else if(a)throw Error("Stencil cannot be set without depth")}destroy(){let e=this.context.gl,t=this.colorAttachment.get();if(t&&e.deleteTexture(t),this.depthAttachment){let r=this.depthAttachment.get();r&&e.deleteRenderbuffer(r)}e.deleteFramebuffer(this.framebuffer)}};const px=ep([{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"}]),Jt=px.offsets;function Kz(e){return new tp(e,Zl.FrameUBO,px)}function Jz(e,t){let r=e.pending,{transform:i}=t,a=t.context.gl;r[Jt.u_units_to_pixels]=1/i.pixelsToGLUnits[0],r[Jt.u_units_to_pixels+1]=1/i.pixelsToGLUnits[1],r[Jt.u_world_size]=a.drawingBufferWidth,r[Jt.u_world_size+1]=a.drawingBufferHeight,r[Jt.u_camera_to_center_distance]=i.cameraToCenterDistance,r[Jt.u_symbol_fade_change]=t.options.fadeDuration?t.symbolFadeChange:1,r[Jt.u_aspect_ratio]=i.width/i.height,r[Jt.u_device_pixel_ratio]=t.pixelRatio,r[Jt.u_viewport_size]=i.width,r[Jt.u_viewport_size+1]=i.height,r[Jt.u_pixel_extrude_scale]=1/i.width,r[Jt.u_pixel_extrude_scale+1]=1/i.height,r[Jt.u_pitch]=i.pitch/360*2*Math.PI,e.upload()}var et=class{constructor(e,t,r){this.blendFunction=e,this.blendColor=t,this.mask=r}};et.Replace=[1,0],et.disabled=new et(et.Replace,oe.transparent,[!1,!1,!1,!1]),et.unblended=new et(et.Replace,oe.transparent,[!0,!0,!0,!0]),et.alphaBlended=new et([1,771],oe.transparent,[!0,!0,!0,!0]);var Qz=class{constructor(e){this.gl=e,this.clearColor=new gz(this),this.clearDepth=new _z(this),this.clearStencil=new yz(this),this.colorMask=new xz(this),this.depthMask=new vz(this),this.stencilMask=new bz(this),this.stencilFunc=new wz(this),this.stencilOp=new Tz(this),this.stencilTest=new Sz(this),this.depthRange=new Dz(this),this.depthTest=new Ez(this),this.depthFunc=new Pz(this),this.blend=new Az(this),this.blendFunc=new Cz(this),this.blendColor=new Iz(this),this.blendEquation=new Mz(this),this.cullFace=new zz(this),this.cullFaceSide=new Fz(this),this.frontFace=new Rz(this),this.program=new kz(this),this.activeTexture=new Lz(this),this.viewport=new Bz(this),this.bindFramebuffer=new Oz(this),this.bindRenderbuffer=new $z(this),this.bindTexture=new jz(this),this.bindVertexBuffer=new Vz(this),this.bindElementBuffer=new Nz(this),this.bindVertexArray=new Uz(this),this.pixelStoreUnpack=new Gz(this),this.pixelStoreUnpackPremultiplyAlpha=new qz(this),this.pixelStoreUnpackFlipY=new Zz(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=ix(this),this.keyedProjectionUniformBuffers=new Map,this.freeProjectionUniformBuffers=[],this.terrainUniformBuffer=_3(this),this.frameUniformBuffer=Kz(this)}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 fz(this,e,t)}createVertexBuffer(e,t,r){return new mz(this,e,t,r)}createRenderbuffer(e,t,r){let i=this.gl,a=i.createRenderbuffer();return this.bindRenderbuffer.set(a),i.renderbufferStorage(i.RENDERBUFFER,e,t,r),this.bindRenderbuffer.set(null),a}createFramebuffer(e,t,r,i){return new Yz(this,e,t,r,i)}clear({color:e,depth:t,stencil:r}){let i=this.gl,a=0;e&&(a|=i.COLOR_BUFFER_BIT,this.clearColor.set(e),this.colorMask.set([!0,!0,!0,!0])),t!==void 0&&(a|=i.DEPTH_BUFFER_BIT,this.depthRange.set([0,1]),this.clearDepth.set(t),this.depthMask.set(!0)),r!==void 0&&(a|=i.STENCIL_BUFFER_BIT,this.clearStencil.set(r),this.stencilMask.set(255)),i.clear(a)}setCullFace(e){e.enable===!1?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(!1):(this.depthTest.set(!0),this.depthFunc.set(e.func),this.depthMask.set(e.mask),this.depthRange.set(e.range))}setStencilMode(e){e.test.func===this.gl.ALWAYS&&!e.mask?this.stencilTest.set(!1):(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}))}setColorMode(e){Br(e.blendFunction,et.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)}},me=class{constructor(e,t,r){this.func=e,this.mask=t,this.range=r}};me.ReadOnly=!1,me.ReadWrite=!0,me.disabled=new me(519,me.ReadOnly,[0,1]);const rh=7680;var Ae=class{constructor(e,t,r,i,a,n){this.test=e,this.ref=t,this.mask=r,this.fail=i,this.depthFail=a,this.pass=n}};Ae.disabled=new Ae({func:519,mask:0},0,0,rh,rh,rh);const bg=1029,ih=2305;var De=class{constructor(e,t,r){this.enable=e,this.mode=t,this.frontFace=r}};De.disabled=new De(!1,bg,ih),De.backCCW=new De(!0,bg,ih),De.frontCCW=new De(!0,1028,ih);function eF(e,t,r){let i=(t==null?void 0:t.transitionState)??0;return{currentPass:"offscreen",currentLayer:0,opaquePassCutoff:1/0,depthRangeFor3D:[0,1],isRenderingToTexture:!1,transform:e,terrain:r,projectionTransition:i,isRenderingGlobe:i>0}}function Ft(e,t,r={}){let i=e.transform.getProjectionData({overscaledTileID:t,aligned:r.aligned,applyGlobeMatrix:!e.isRenderingToTexture,applyTerrainMatrix:r.applyTerrainMatrix??!0});return e.isRenderingToTexture||(i.uniformBufferKey=r.aligned?`${t.key}/aligned`:t.key),i}function Vt(e,t){var r;return e.isRenderingToTexture?null:((r=e.terrain)==null?void 0:r.getTerrainData(t))??null}let go;function wg(e,t,r,i,a,n){let s=e.context,o=s.gl,l=e.useProgram("collisionBox"),u=[],h=0,c=0;for(let _ of i){let y=t.getTile(_).getBucket(r);if(!y)continue;let v=a?y.textCollisionBox:y.iconCollisionBox,x=y.collisionCircleArray;x.length>0&&(u.push({circleArray:x,circleOffset:c,coord:_}),h+=x.length/4,c=h),v&&l.draw(s,o.LINES,me.disabled,Ae.disabled,e.colorModeForRenderPass(),De.disabled,null,Vt(n,_),Ft(n,_),r.id,v.layoutVertexBuffer,v.indexBuffer,v.segments,null,e.transform.zoom,null,null,v.collisionVertexBuffer)}if(!a||!u.length)return;let d=e.useProgram("collisionCircle"),p=new J2;p.resize(h*4),p._trim();let f=0;for(let _ of u)for(let y=0;y<_.circleArray.length/4;y++){let v=y*4,x=_.circleArray[v+0],w=_.circleArray[v+1],b=_.circleArray[v+2],S=_.circleArray[v+3];p.emplace(f++,x,w,b,S,0),p.emplace(f++,x,w,b,S,1),p.emplace(f++,x,w,b,S,2),p.emplace(f++,x,w,b,S,3)}(!go||go.length<h*2)&&(go=tF(h));let m=s.createIndexBuffer(go,!0),g=s.createVertexBuffer(p,yS.members,!0);for(let _ of u)d.draw(s,o.TRIANGLES,me.disabled,Ae.disabled,e.colorModeForRenderPass(),De.disabled,null,Vt(n,_.coord),null,r.id,g,m,Ze.simpleSegment(0,_.circleOffset*2,_.circleArray.length,_.circleArray.length/2),null,e.transform.zoom,null,null,null);g.destroy(),m.destroy()}function tF(e){let t=e*2,r=new ew;r.resize(t),r._trim();for(let i=0;i<t;i++){let a=i*6;r.uint16[a+0]=i*4+0,r.uint16[a+1]=i*4+1,r.uint16[a+2]=i*4+2,r.uint16[a+3]=i*4+2,r.uint16[a+4]=i*4+3,r.uint16[a+5]=i*4+0}return r}const rF=Pr(new Float32Array(16));function iF(e,t,r,i,a,n){if(n.currentPass!=="translucent")return;let s=Ae.disabled,o=e.colorModeForRenderPass();(r._unevaluatedLayout.hasValue("text-variable-anchor")||r._unevaluatedLayout.hasValue("text-variable-anchor-offset"))&&nF(i,e,r,t,r.layout.get("text-rotation-alignment"),r.layout.get("text-pitch-alignment"),r.paint.get("text-translate"),r.paint.get("text-translate-anchor"),a),r.paint.get("icon-opacity").constantOr(1)!==0&&Tg(e,t,r,i,!1,r.paint.get("icon-translate"),r.paint.get("icon-translate-anchor"),r.layout.get("icon-rotation-alignment").constantOr("viewport"),r.layout.get("icon-pitch-alignment"),r.layout.get("icon-keep-upright"),s,o,n),r.paint.get("text-opacity").constantOr(1)!==0&&Tg(e,t,r,i,!0,r.paint.get("text-translate"),r.paint.get("text-translate-anchor"),r.layout.get("text-rotation-alignment"),r.layout.get("text-pitch-alignment"),r.layout.get("text-keep-upright"),s,o,n),t.map.showCollisionBoxes&&(wg(e,t,r,i,!0,n),wg(e,t,r,i,!1,n))}function aF(e,t,r,i,a,n){let{horizontalAlign:s,verticalAlign:o}=Vl(e),l=-(s-.5)*t,u=-(o-.5)*r;return new M((l/a+i[0])*n,(u/a+i[1])*n)}function nF(e,t,r,i,a,n,s,o,l){var p;let u=t.transform,h=t.style.map.terrain,c=a==="map",d=n==="map";for(let f of e){let m=i.getTile(f),g=m.getBucket(r);if(!((p=g==null?void 0:g.text)!=null&&p.segments.get().length))continue;let _=g.textSizeData,y=Nl(_,u.zoom),v=nr(m,1,t.transform.zoom),x=Hd(c,t.transform,v),w=r.layout.get("icon-text-fit")!=="none"&&g.hasIconData();if(y){let b=2**(u.zoom-m.tileID.overscaledZ),S=h?(A,P)=>h.getElevation(f,A,P):void 0;oF(g,c,d,l,u,x,b,y,w,Ti(u,m,s,o),f.toUnwrapped(),S,r.layout.get("symbol-height-anchor")==="ground")}}}function sF(e,t,r,i,a,n){let s=t.tileAnchorPoint.add(new M(t.translation[0],t.translation[1]));if(t.pitchWithMap){let o=i.mult(n);r||(o=o.rotate(-a));let l=s.add(o);return Yd(l.x,l.y,t.pitchedLabelPlaneMatrix,ea(t,l.x,l.y)).point}if(r){let o=ta(t.tileAnchorPoint.x+1,t.tileAnchorPoint.y,t).point.sub(e),l=Math.atan(o.y/o.x)+(o.x<0?Math.PI:0);return e.add(i.rotate(l))}return e.add(i)}function oF(e,t,r,i,a,n,s,o,l,u,h,c,d){let p=e.text.placedSymbolArray,f=e.text.dynamicLayoutVertexArray,m=e.icon.dynamicLayoutVertexArray,g={};f.clear();for(let _=0;_<p.length;_++){let y=p.get(_),v=e.allowVerticalPlacement&&!y.placedOrientation,x=!y.hidden&&y.crossTileID&&!v?i[y.crossTileID]:null;if(!x)Ba(y.numGlyphs,f);else{let w=new M(y.anchorX,y.anchorY),b={getElevation:c,heightOffset:y.heightOffset,heightAnchorGround:d,width:a.width,height:a.height,pitchedLabelPlaneMatrix:n,pitchWithMap:r,transform:a,tileAnchorPoint:w,translation:u,unwrappedTileID:h},S=r?R1(w.x,w.y,b):ta(w.x,w.y,b),A=M1(a.cameraToCenterDistance,S.signedDistanceFromCamera),P=Pd(e.textSizeData,o,y)*A/24;r&&(P*=e.tilePixelRatio/s);let{width:I,height:R,anchor:F,textOffset:T,textBoxScale:E}=x,D=aF(F,I,R,T,E,P),C=a.getPitchedTextCorrection(w.x+u[0],w.y+u[1],h),k=sF(S.point,b,t,D,-a.bearingInRadians,C),B=e.allowVerticalPlacement&&y.placedOrientation===2?Math.PI/2:0;for(let $=0;$<y.numGlyphs;$++)ol(f,k,B);l&&y.associatedIconIndex>=0&&(g[y.associatedIconIndex]={shiftedAnchor:k,angle:B})}}if(l){m.clear();let _=e.icon.placedSymbolArray;for(let y=0;y<_.length;y++){let v=_.get(y);if(v.hidden)Ba(v.numGlyphs,m);else{let x=g[y];if(!x)Ba(v.numGlyphs,m);else for(let w=0;w<v.numGlyphs;w++)ol(m,x.shiftedAnchor,x.angle)}}e.icon.dynamicLayoutVertexBuffer.updateData(m)}e.text.dynamicLayoutVertexBuffer.updateData(f)}function lF(e,t,r){return r.iconsInText&&t?"symbolTextAndIcon":e?"symbolSDF":"symbolIcon"}function Tg(e,t,r,i,a,n,s,o,l,u,h,c,d){let p=e.context,f=p.gl,m=e.transform,g=o==="map",_=l==="map",y=o!=="viewport"&&r.layout.get("symbol-placement")!=="point",v=g&&!_&&!y,x=!r.layout.get("symbol-sort-key").isConstant(),w=!1,b=e.getDepthModeForSublayer(0,me.ReadOnly),S=r._unevaluatedLayout.hasValue("text-variable-anchor")||r._unevaluatedLayout.hasValue("text-variable-anchor-offset"),A=[],P=m.getCircleRadiusCorrection();for(let F of i){let T=t.getTile(F),E=T.getBucket(r);if(!E)continue;let D=a?E.text:E.icon;if(!(D!=null&&D.segments.get().length)||!D.hasVisibleVertices)continue;let C=D.programConfigurations.get(r.id),k=a||E.sdfIcons,B=a?E.textSizeData:E.iconSizeData,$=_||m.pitch!==0,W=e.useProgram(lF(k,a,E),C),ie=Nl(B,m.zoom),ye=Vt(d,F),ce,ke=[0,0],ve,Ue,Ee=null,pt;if(a){if(ve=T.glyphAtlasTexture,Ue=f.LINEAR,ce=T.glyphAtlasTexture.size,E.iconsInText){ke=T.imageAtlasTexture.size,Ee=T.imageAtlasTexture;let q=B.kind==="composite"||B.kind==="camera";pt=$||e.options.rotating||e.options.zooming||q?f.LINEAR:f.NEAREST}}else{let q=r.layout.get("icon-size").constantOr(0)!==1||E.iconsNeedLinear;ve=T.imageAtlasTexture,Ue=k||e.options.rotating||e.options.zooming||q||$?f.LINEAR:f.NEAREST,ce=T.imageAtlasTexture.size}let yt=nr(T,1,e.transform.zoom),Nt=Hd(g,e.transform,yt),Ut=uM(_,g,e.transform,yt),Tt=Ti(m,T,n,s),nt=Ft(d,F),Yt=S&&E.hasTextData(),xr=r.layout.get("icon-text-fit")!=="none"&&Yt&&E.hasIconData(),sr=r._unevaluatedLayout.hasValue("icon-offset"),Z=r.layout.get("symbol-height-anchor")==="ground";if(y){let q=Pi();nM(q,Nt);let we=e.style.map.terrain?(Te,ne)=>e.style.map.terrain.getElevation(F,Te,ne):void 0;cM(E,e,a,Nt,q,_,u,r.layout.get("text-rotation-alignment")==="map",F.toUnwrapped(),m.width,m.height,Tt,we)}let ge=a&&S||xr,re=_?Nt:e.transform.clipSpaceToPixelsMatrix,j=y||ge?rF:re,xe=k&&r.paint.get(a?"text-halo-width":"icon-halo-width").constantOr(1)!==0,Q;Q=k?E.iconsInText?az(B.kind,ie,v,_,y,ge,e,j,Ut,Tt,ce,ke,P,sr,Z):dx(B.kind,ie,v,_,y,ge,e,j,Ut,Tt,a,ce,xe,P,sr,Z):cx(B.kind,ie,v,_,y,ge,e,j,Ut,Tt,a,ce,P,sr,Z);let ae={program:W,buffers:D,uniformValues:Q,projectionData:nt,atlasTexture:ve,atlasTextureIcon:Ee,atlasInterpolation:Ue,atlasInterpolationIcon:pt,isSDF:k,hasHalo:xe};if(x&&E.canOverlap){w=!0;let q=D.segments.get();for(let we of q)A.push({segments:new Ze([we]),sortKey:we.sortKey,state:ae,terrainData:ye})}else A.push({segments:D.segments,sortKey:0,state:ae,terrainData:ye})}w&&A.sort((F,T)=>F.sortKey-T.sortKey);let I=r.paint.get(a?"text-halo-width":"icon-halo-width").constantOr(null)??1/0,R=r.layout.get("text-letter-spacing").constantOr(0)*24<0||I>1;for(let F of A){let T=F.state;p.activeTexture.set(f.TEXTURE0),T.atlasTexture.bind(T.atlasInterpolation,f.CLAMP_TO_EDGE),T.atlasTextureIcon&&(p.activeTexture.set(f.TEXTURE1),T.atlasTextureIcon&&T.atlasTextureIcon.bind(T.atlasInterpolationIcon,f.CLAMP_TO_EDGE));let E=T.isSDF&&T.hasHalo;if(E){let D=T.uniformValues;D.u_is_halo=1,R&&(D.u_is_plain=0,Sg(T.buffers,F.segments,r,e,T.program,b,h,c,D,T.projectionData,F.terrainData),D.u_is_halo=0,D.u_is_plain=1)}Sg(T.buffers,F.segments,r,e,T.program,b,h,c,T.uniformValues,T.projectionData,F.terrainData),E&&!R&&(T.uniformValues.u_is_halo=0)}}function Sg(e,t,r,i,a,n,s,o,l,u,h){let c=i.context,d=c.gl;a.draw(c,d.TRIANGLES,n,s,o,De.backCCW,l,h,u,r.id,e.layoutVertexBuffer,e.indexBuffer,t,r.paint,i.transform.zoom,e.programConfigurations.get(r.id),e.dynamicLayoutVertexBuffer,e.opacityVertexBuffer)}function uF(e,t,r,i,a){if(a.currentPass!=="translucent")return;let n=r.paint.get("circle-opacity"),s=r.paint.get("circle-stroke-width"),o=r.paint.get("circle-stroke-opacity"),l=!r.layout.get("circle-sort-key").isConstant();if(n.constantOr(1)===0&&(s.constantOr(1)===0||o.constantOr(1)===0))return;let u=e.context,h=u.gl,c=e.transform,d=e.getDepthModeForSublayer(0,me.ReadOnly),p=Ae.disabled,f=e.colorModeForRenderPass(),m=[],g=c.getCircleRadiusCorrection();for(let _ of i){let y=t.getTile(_),v=y.getBucket(r);if(!v)continue;let x=r.paint.get("circle-translate"),w=r.paint.get("circle-translate-anchor"),b=Ti(c,y,x,w),S=v.programConfigurations.get(r.id),A=e.useProgram("circle",S),P=v.layoutVertexBuffer,I=v.indexBuffer,R=Vt(a,_),F={programConfiguration:S,program:A,layoutVertexBuffer:P,indexBuffer:I,uniformValues:F3(e,y,r,b,g),terrainData:R,projectionData:Ft(a,_)};if(l){let T=v.segments.get();for(let E of T)m.push({segments:new Ze([E]),sortKey:E.sortKey,state:F})}else m.push({segments:v.segments,sortKey:0,state:F})}l&&m.sort((_,y)=>_.sortKey-y.sortKey);for(let _ of m){let{programConfiguration:y,program:v,layoutVertexBuffer:x,indexBuffer:w,uniformValues:b,terrainData:S,projectionData:A}=_.state,P=_.segments;v.draw(u,h.TRIANGLES,d,p,f,De.backCCW,b,S,A,r.id,x,w,P,r.paint,e.transform.zoom,y)}}function hF(e,t,r,i,a){if(r.paint.get("heatmap-opacity")===0)return;let n=e.context;if(e.style.map.terrain){for(let s of i){let o=t.getTile(s);t.hasRenderableParent(s)||(a.currentPass==="offscreen"?pF(e,o,r,s,a):a.currentPass==="translucent"&&fF(e,r,s,a))}n.viewport.set([0,0,e.width,e.height])}else a.currentPass==="offscreen"?cF(e,t,r,i,a):a.currentPass==="translucent"&&dF(e,r)}function cF(e,t,r,i,a){let n=e.context,s=n.gl,o=e.transform,l=Ae.disabled,u=new et([s.ONE,s.ONE],oe.transparent,[!0,!0,!0,!0]);mF(n,e,r),n.clear({color:oe.transparent});for(let h of i){if(t.hasRenderableParent(h))continue;let c=t.getTile(h),d=c.getBucket(r);if(!d)continue;let p=d.programConfigurations.get(r.id),f=e.useProgram("heatmap",p),m=Ft(a,h,{applyTerrainMatrix:!1}),g=o.getCircleRadiusCorrection();f.draw(n,s.TRIANGLES,me.disabled,l,u,De.backCCW,lx(c,o.zoom,r.paint.get("heatmap-intensity"),g),null,m,r.id,d.layoutVertexBuffer,d.indexBuffer,d.segments,r.paint,o.zoom,p)}n.viewport.set([0,0,e.width,e.height])}function dF(e,t){let r=e.context,i=r.gl;r.setColorMode(e.colorModeForRenderPass());let a=t.heatmapFbos.get(Qo);a&&(r.activeTexture.set(i.TEXTURE0),i.bindTexture(i.TEXTURE_2D,a.colorAttachment.get()),r.activeTexture.set(i.TEXTURE1),mx(r,t).bind(i.LINEAR,i.CLAMP_TO_EDGE),e.useProgram("heatmapTexture").draw(r,i.TRIANGLES,me.disabled,Ae.disabled,e.colorModeForRenderPass(),De.disabled,ux(e,t,0,1),null,null,t.id,e.viewportBuffer,e.quadTriangleIndexBuffer,e.viewportSegments,t.paint,e.transform.zoom))}function pF(e,t,r,i,a){let n=e.context,s=n.gl,o=Ae.disabled,l=new et([s.ONE,s.ONE],oe.transparent,[!0,!0,!0,!0]),u=t.getBucket(r);if(!u)return;let h=i.key,c=r.heatmapFbos.get(h);c||(c=fx(n,t.tileSize,t.tileSize),r.heatmapFbos.set(h,c)),n.bindFramebuffer.set(c.framebuffer),n.viewport.set([0,0,t.tileSize,t.tileSize]),n.clear({color:oe.transparent});let d=u.programConfigurations.get(r.id),p=e.useProgram("heatmap",d,!a.isRenderingGlobe),f=Ft(a,t.tileID),m=Vt(a,i);p.draw(n,s.TRIANGLES,me.disabled,o,l,De.disabled,lx(t,e.transform.zoom,r.paint.get("heatmap-intensity"),1),m,f,r.id,u.layoutVertexBuffer,u.indexBuffer,u.segments,r.paint,e.transform.zoom,d)}function fF(e,t,r,i){let a=e.context,n=a.gl,s=e.transform;a.setColorMode(e.colorModeForRenderPass());let o=mx(a,t),l=r.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),o.bind(n.LINEAR,n.CLAMP_TO_EDGE);let h=Ft(i,r,{applyTerrainMatrix:i.isRenderingGlobe});e.useProgram("heatmapTexture").draw(a,n.TRIANGLES,me.disabled,Ae.disabled,e.colorModeForRenderPass(),De.disabled,ux(e,t,0,1),null,h,t.id,e.rasterBoundsBuffer,e.quadTriangleIndexBuffer,e.rasterBoundsSegments,t.paint,s.zoom),u.destroy(),t.heatmapFbos.delete(l)}function mF(e,t,r){let i=e.gl;e.activeTexture.set(i.TEXTURE1),e.viewport.set([0,0,t.width/4,t.height/4]);let a=r.heatmapFbos.get(Qo);a?(i.bindTexture(i.TEXTURE_2D,a.colorAttachment.get()),e.bindFramebuffer.set(a.framebuffer)):(a=fx(e,t.width/4,t.height/4),r.heatmapFbos.set(Qo,a))}function fx(e,t,r){let i=e.gl,a=i.createTexture();i.bindTexture(i.TEXTURE_2D,a),i.texParameteri(i.TEXTURE_2D,i.TEXTURE_WRAP_S,i.CLAMP_TO_EDGE),i.texParameteri(i.TEXTURE_2D,i.TEXTURE_WRAP_T,i.CLAMP_TO_EDGE),i.texParameteri(i.TEXTURE_2D,i.TEXTURE_MIN_FILTER,i.LINEAR),i.texParameteri(i.TEXTURE_2D,i.TEXTURE_MAG_FILTER,i.LINEAR),i.texStorage2D(i.TEXTURE_2D,1,i.RGBA16F,t,r);let n=e.createFramebuffer(t,r,!1,!1);return n.colorAttachment.set(a),n}function mx(e,t){return t.colorRampTexture||(t.colorRampTexture=new dt(e,t.colorRamp,e.gl.RGBA)),t.colorRampTexture}function gx(e,t,r){let i=e.context,a=i.bindFramebuffer.get(),n=i.viewport.get(),[,,s,o]=n;return gF(e,s,o),i.viewport.set([0,0,s,o]),i.clear({color:oe.transparent,depth:1,stencil:0}),e.currentStencilSource=void 0,e.renderTileClippingMasks(t,r),{compositeTarget:a,compositeViewport:n}}function gF(e,t,r){let i=e.context.gl;if(!e.layerOpacityFbo){let n=e.context.createFramebuffer(t,r,!0,!0),s=i.createTexture();i.bindTexture(i.TEXTURE_2D,s),i.texParameteri(i.TEXTURE_2D,i.TEXTURE_WRAP_S,i.CLAMP_TO_EDGE),i.texParameteri(i.TEXTURE_2D,i.TEXTURE_WRAP_T,i.CLAMP_TO_EDGE),i.texParameteri(i.TEXTURE_2D,i.TEXTURE_MIN_FILTER,i.LINEAR),i.texParameteri(i.TEXTURE_2D,i.TEXTURE_MAG_FILTER,i.LINEAR),i.texImage2D(i.TEXTURE_2D,0,i.RGBA,t,r,0,i.RGBA,i.UNSIGNED_BYTE,null),n.colorAttachment.set(s),n.depthAttachment.set(e.context.createRenderbuffer(i.DEPTH_STENCIL,t,r)),e.layerOpacityFbo=n,e.context.bindFramebuffer.set(e.layerOpacityFbo.framebuffer);return}if(e.layerOpacityFbo.width===t&&e.layerOpacityFbo.height===r){e.context.bindFramebuffer.set(e.layerOpacityFbo.framebuffer);return}let a=e.layerOpacityFbo;i.bindTexture(i.TEXTURE_2D,a.colorAttachment.get()),i.texImage2D(i.TEXTURE_2D,0,i.RGBA,t,r,0,i.RGBA,i.UNSIGNED_BYTE,null),e.context.bindRenderbuffer.set(a.depthAttachment.get()),i.renderbufferStorage(i.RENDERBUFFER,i.DEPTH_STENCIL,t,r),e.context.bindRenderbuffer.set(null),a.width=t,a.height=r,e.context.bindFramebuffer.set(a.framebuffer)}function _x(e,t,r,i){let a=e.context,n=a.gl;a.bindFramebuffer.set(r.compositeTarget),a.viewport.set(r.compositeViewport),a.activeTexture.set(n.TEXTURE0),n.bindTexture(n.TEXTURE_2D,e.layerOpacityFbo.colorAttachment.get()),e.useProgram("layerOpacity").draw(a,n.TRIANGLES,me.disabled,Ae.disabled,e.colorModeForRenderPass(),De.disabled,ez(t,0),null,null,i.id,e.viewportBuffer,e.quadTriangleIndexBuffer,e.viewportSegments,i.paint,e.transform.zoom),e.currentStencilSource=void 0}function yx(e,t,r,i,a,n,s,o){let l=256;if(a.stepInterpolant){let u=t.getSource().maxzoom,h=s.canonical.z===u?Math.ceil(1<<e.transform.maxZoom-s.canonical.z):1,c=n.maxLineLength/L*1024*h;l=se(gv(c),256,r.maxTextureSize)}return o.gradient=Zy({expression:a.gradientExpression(),evaluationKey:"lineProgress",resolution:l,image:o.gradient||void 0,clips:n.lineClipsArray}),o.texture?o.texture.update(o.gradient):o.texture=new dt(r,o.gradient,i.RGBA),o.version=a.gradientVersion,o.texture}function _F(e,t,r,i,a){e.activeTexture.set(t.TEXTURE0),r.imageAtlasTexture.bind(t.LINEAR,t.CLAMP_TO_EDGE),i.updatePaintBuffers(a)}function yF(e,t,r,i,a,n){(a||e.lineAtlas.dirty)&&(t.activeTexture.set(r.TEXTURE0),e.lineAtlas.bind(t)),i.updatePaintBuffers(n)}function xF(e,t,r,i,a,n,s){let o=n.gradients[a.id],l=o.texture;a.gradientVersion!==o.version&&(l=yx(e,t,r,i,a,n,s,o)),r.activeTexture.set(i.TEXTURE0),l.bind(a.stepInterpolant?i.NEAREST:i.LINEAR,i.CLAMP_TO_EDGE)}function vF(e,t,r,i,a,n,s,o,l){let u=n.gradients[a.id],h=u.texture;a.gradientVersion!==u.version&&(h=yx(e,t,r,i,a,n,s,u)),r.activeTexture.set(i.TEXTURE0),h.bind(a.stepInterpolant?i.NEAREST:i.LINEAR,i.CLAMP_TO_EDGE),r.activeTexture.set(i.TEXTURE1),e.lineAtlas.bind(r),o.updatePaintBuffers(l)}function bF(e,t,r,i,a){if(a.currentPass!=="translucent")return;let n=r.paint.get("line-opacity"),s=r.paint.get("line-width"),o=r.paint.get("line-layer-opacity");if(n.constantOr(1)!==0&&s.constantOr(1)!==0&&o!==0){if(o<1){let l=gx(e,r,i);Dg(e,t,r,i,a),_x(e,o,l,r);return}Dg(e,t,r,i,a)}}function Dg(e,t,r,i,a){let n=e.getDepthModeForSublayer(0,me.ReadOnly),s=e.colorModeForRenderPass(),o=r.paint.get("line-dasharray"),l=o.constantOr(1),u=r.paint.get("line-pattern"),h=u.constantOr(1),c=r.paint.get("line-gradient"),d=r.getCrossfadeParameters(),p;p=h?"linePattern":l&&c?"lineGradientSDF":l?"lineSDF":c?"lineGradient":"line";let f=e.context,m=f.gl,g=e.transform,_=!0;for(let y of i){let v=t.getTile(y);if(h&&!v.patternsLoaded())continue;let x=v.getBucket(r);if(!x)continue;let w=x.programConfigurations.get(r.id),b=e.context.program.get(),S=e.useProgram(p,w),A=_||S.program!==b,P=Vt(a,y),I=u.constantOr(null),R=o==null?void 0:o.constantOr(null);if(I&&v.imageAtlas){let C=v.imageAtlas,k=C.patternPositions[I.to.toString()],B=C.patternPositions[I.from.toString()];k&&B&&w.setConstantPatternPositions(k,B)}else if(R){let C=r.layout.get("line-cap").constantOr(null)==="round",k=e.lineAtlas.getDash(R.to,C),B=e.lineAtlas.getDash(R.from,C);w.setConstantDashPositions(k,B)}let F=Ft(a,y),T=g.getPixelScale(),E;h?(E=Y3(e,v,r,T,d),_F(f,m,v,w,d)):l&&c?(E=J3(e,v,r,T,d,x.lineClipsArray.length),vF(e,t,f,m,r,x,y,w,d)):l?(E=K3(e,v,r,T,d),yF(e,f,m,w,A,d)):c?(E=X3(e,v,r,T,x.lineClipsArray.length),xF(e,t,f,m,r,x,y)):E=Wl(e,v,r,T);let D=e.stencilModeForClipping(y);S.draw(f,m.TRIANGLES,n,D,s,De.disabled,E,P,F,r.id,x.layoutVertexBuffer,x.indexBuffer,x.segments,r.paint,e.transform.zoom,w,x.layoutVertexBuffer2),_=!1}}function xx(e,t,r,i,a){if(!r||!(i!=null&&i.imageAtlas))return;let n=i.imageAtlas.patternPositions,s=n[r.to.toString()],o=n[r.from.toString()];if(!s&&o&&(s=o),!o&&s&&(o=s),!s||!o){let l=a.getPaintProperty(t);s=n[l],o=n[l]}s&&o&&e.setConstantPatternPositions(s,o)}function wF(e,t,r,i,a){let n=r.paint.get("fill-color"),s=r.paint.get("fill-opacity"),o=r.paint.get("fill-layer-opacity");if(s.constantOr(1)===0||o===0)return;if(o<1){if(a.currentPass!=="translucent")return;let h=gx(e,r,i);Eg(e,t,r,i,a),_x(e,o,h,r);return}let l=r.paint.get("fill-pattern"),u=e.opaquePassEnabledForLayer()&&!l.constantOr(1)&&n.constantOr(oe.transparent).a===1&&s.constantOr(0)===1;if(u&&a.currentPass==="opaque"){let h=e.colorModeForRenderPass();ap(e,t,r,i,e.getDepthModeForSublayer(1,me.ReadWrite),h,!1,a);return}if(u&&a.currentPass==="translucent"){vx(e,t,r,i,a);return}a.currentPass==="translucent"&&Eg(e,t,r,i,a)}function Eg(e,t,r,i,a){let n=e.colorModeForRenderPass();ap(e,t,r,i,e.getDepthModeForSublayer(1,me.ReadOnly),n,!1,a),vx(e,t,r,i,a)}function vx(e,t,r,i,a){if(!r.paint.get("fill-antialias"))return;let n=e.colorModeForRenderPass();ap(e,t,r,i,e.getDepthModeForSublayer(r.getPaintProperty("fill-outline-color")?2:0,me.ReadOnly),n,!0,a)}function ap(e,t,r,i,a,n,s,o){let l=e.context.gl,u="fill-pattern",h=r.paint.get(u),c=h==null?void 0:h.constantOr(1),d=r.getCrossfadeParameters(),p,f,m,g,_,y=e.transform,v=r.paint.get("fill-translate"),x=r.paint.get("fill-translate-anchor");s?(f=c&&!r.getPaintProperty("fill-outline-color")?"fillOutlinePattern":"fillOutline",p=l.LINES):(f=c?"fillPattern":"fill",p=l.TRIANGLES);let w=h.constantOr(null);for(let b of i){let S=t.getTile(b);if(c&&!S.patternsLoaded())continue;let A=S.getBucket(r);if(!A)continue;let P=A.sdfPatterns[r.id]??!1,I=A.programConfigurations.get(r.id),R=e.useProgram(f,I),F=Vt(o,b);c&&(e.context.activeTexture.set(l.TEXTURE0),S.imageAtlasTexture.bind(l.LINEAR,l.CLAMP_TO_EDGE),I.updatePaintBuffers(d)),xx(I,u,w,S,r);let T=Ft(o,b),E=Ti(y,S,v,x);s?(g=A.indexBuffer2,_=A.segments2,m=f==="fillOutlinePattern"&&c?M3(e,d,S,E,P):I3(E)):(g=A.indexBuffer,_=A.segments,m=c?ox(e,d,S,E,P):C3(E));let D=e.stencilModeForClipping(b);R.draw(e.context,p,a,D,n,De.backCCW,m,F,T,r.id,A.layoutVertexBuffer,g,_,r.paint,e.transform.zoom,I)}}function TF(e,t,r,i,a){let n=r.paint.get("fill-extrusion-opacity");if(n!==0&&a.currentPass==="translucent"){let s=new me(e.context.gl.LEQUAL,me.ReadWrite,a.depthRangeFor3D);if(n===1&&!r.paint.get("fill-extrusion-pattern").constantOr(1)){let o=e.colorModeForRenderPass();ah(e,t,r,i,s,Ae.disabled,o,a)}else ah(e,t,r,i,s,Ae.disabled,et.disabled,a),ah(e,t,r,i,s,e.stencilModeFor3D(),e.colorModeForRenderPass(),a)}}function ah(e,t,r,i,a,n,s,o){let l=e.context,u=l.gl,h="fill-extrusion-pattern",c=r.paint.get(h),d=c.constantOr(1),p=r.getCrossfadeParameters(),f=r.paint.get("fill-extrusion-opacity"),m=c.constantOr(null),g=e.transform;for(let _ of i){let y=t.getTile(_),v=y.getBucket(r);if(!v)continue;let x=Vt(o,_),w=v.programConfigurations.get(r.id),b=e.useProgram(d?"fillExtrusionPattern":"fillExtrusion",w);d&&(e.context.activeTexture.set(u.TEXTURE0),y.imageAtlasTexture.bind(u.LINEAR,u.CLAMP_TO_EDGE),w.updatePaintBuffers(p));let S=Ft(o,_);xx(w,h,m,y,r);let A=Ti(g,y,r.paint.get("fill-extrusion-translate"),r.paint.get("fill-extrusion-translate-anchor")),P=r.paint.get("fill-extrusion-vertical-gradient"),I=d?S3(e,P,f,A,_,p,y):sx(e,P,f,A);b.draw(l,l.gl.TRIANGLES,a,n,s,De.backCCW,I,x,S,r.id,v.layoutVertexBuffer,v.indexBuffer,v.segments,r.paint,e.transform.zoom,w,e.style.map.terrain&&v.centroidVertexBuffer)}}function SF(e,t,r,i,a){if(a.currentPass!=="offscreen"&&a.currentPass!=="translucent")return;let n=e.context,s=e.style.projection.useSubdivision,o=e.getDepthModeForSublayer(0,me.ReadOnly),l=e.colorModeForRenderPass();if(a.currentPass==="offscreen")DF(e,t,i,r,o,Ae.disabled,l),n.viewport.set([0,0,e.width,e.height]);else if(a.currentPass==="translucent")if(s){let[u,h,c]=e.stencilConfigForOverlapTwoPass(i);nh(e,t,r,c,u,o,l,!1,a),nh(e,t,r,c,h,o,l,!0,a)}else{let[u,h]=e.getStencilConfigForOverlapAndUpdateStencilID(i);nh(e,t,r,h,u,o,l,!1,a)}}function nh(e,t,r,i,a,n,s,o,l){let u=e.style.projection,h=e.context,c=h.gl,d=[`#define NUM_ILLUMINATION_SOURCES ${r.paint.get("hillshade-highlight-color").values.length}`],p=e.useProgram("hillshade",null,!1,d),f=!e.options.moving;for(let m of i){let g=t.getTile(m),_=g.fbo;if(!_)continue;let y=u.getMeshFromTileID(h,m.canonical,o,!0,"raster"),v=Vt(l,m);h.activeTexture.set(c.TEXTURE0),c.bindTexture(c.TEXTURE_2D,_.colorAttachment.get());let x=Ft(l,m,{aligned:f});p.draw(h,c.TRIANGLES,n,a[m.overscaledZ],s,De.backCCW,$3(e,g,r),v,x,r.id,y.vertexBuffer,y.indexBuffer,y.segments)}}function DF(e,t,r,i,a,n,s){let o=e.context,l=o.gl,u=i.paint.get("resampling")==="nearest"?l.NEAREST:l.LINEAR;for(let h of r){let c=t.getTile(h),d=c.dem;if(!(d!=null&&d.data)||!c.needsHillshadePrepare)continue;let p=d.dim+2,f=d.stride,m=d.getPixels();if(o.activeTexture.set(l.TEXTURE1),o.pixelStoreUnpackPremultiplyAlpha.set(!1),c.demTexture||(c.demTexture=e.getTileTexture(f)),c.demTexture){let _=c.demTexture;_.update(m,{premultiply:!1}),_.bind(l.NEAREST,l.CLAMP_TO_EDGE)}else c.demTexture=new dt(o,m,l.RGBA,{premultiply:!1}),c.demTexture.bind(l.NEAREST,l.CLAMP_TO_EDGE);o.activeTexture.set(l.TEXTURE0);let g=c.fbo;if(!g){let _=new dt(o,{width:p,height:p,data:null},l.RGBA);_.bind(u,l.CLAMP_TO_EDGE),g=c.fbo=o.createFramebuffer(p,p,!0,!1),g.colorAttachment.set(_.texture)}o.bindFramebuffer.set(g.framebuffer),o.viewport.set([0,0,p,p]),e.useProgram("hillshadePrepare").draw(o,l.TRIANGLES,a,n,s,De.disabled,j3(c.tileID,d),null,null,i.id,e.rasterBoundsBuffer,e.quadTriangleIndexBuffer,e.rasterBoundsSegments),c.needsHillshadePrepare=!1}}function EF(e,t,r,i,a){if(a.currentPass!=="translucent"||!i.length)return;let n=e.style.projection.useSubdivision,s=e.getDepthModeForSublayer(0,me.ReadOnly),o=e.colorModeForRenderPass();if(n){let[l,u,h]=e.stencilConfigForOverlapTwoPass(i);sh(e,t,r,h,l,s,o,!1,a),sh(e,t,r,h,u,s,o,!0,a)}else{let[l,u]=e.getStencilConfigForOverlapAndUpdateStencilID(i);sh(e,t,r,u,l,s,o,!1,a)}}let Pg=0;function sh(e,t,r,i,a,n,s,o,l){let u=e.style.projection,h=e.context,c=h.gl,d=e.useProgram("colorRelief"),p=!e.options.moving,f=r.paint.get("resampling")==="nearest"?c.NEAREST:c.LINEAR,m=!0,g=0;for(let _ of i){let y=t.getTile(_),v=y.dem;if(!(v!=null&&v.data))continue;if(m){Pg||(Pg=c.getParameter(c.MAX_TEXTURE_SIZE));let A=Pg,{elevationTexture:P,colorTexture:I}=r.getColorRampTextures(h,A,v.getUnpackVector());h.activeTexture.set(c.TEXTURE1),P.bind(c.NEAREST,c.CLAMP_TO_EDGE),h.activeTexture.set(c.TEXTURE4),I.bind(c.LINEAR,c.CLAMP_TO_EDGE),m=!1,g=P.size[0]}let x=v.stride;h.activeTexture.set(c.TEXTURE0),(!y.demTexture||y.needsColorReliefPrepare)&&(h.pixelStoreUnpackPremultiplyAlpha.set(!1),y.demTexture||(y.demTexture=e.getTileTexture(x)??new dt(h,{width:x,height:x,data:null},c.RGBA)),y.demTexture.update(v.getPixels(),{premultiply:!1}),y.needsColorReliefPrepare=!1),y.demTexture.bind(f,c.CLAMP_TO_EDGE);let w=u.getMeshFromTileID(h,_.canonical,o,!0,"raster"),b=Vt(l,_),S=Ft(l,_,{aligned:p});d.draw(h,c.TRIANGLES,n,a[_.overscaledZ],s,De.backCCW,U3(r,y.dem,g),b,S,r.id,w.vertexBuffer,w.indexBuffer,w.segments)}}const oh=[new M(0,0),new M(L,0),new M(L,L),new M(0,L)];function PF(e,t,r,i,a){if(a.currentPass!=="translucent"||r.paint.get("raster-opacity")===0||!i.length)return;let n=t.getSource(),s=e.style.projection.useSubdivision;if(n instanceof ws)_o(e,t,r,i,null,!1,!1,n.tileCoords,n.imageWarp,n.flippedWindingOrder,a,n.getMesh(e.context,s));else if(s){let[o,l,u]=e.stencilConfigForOverlapTwoPass(i);_o(e,t,r,u,o,!1,!0,oh,La,!1,a),_o(e,t,r,u,l,!0,!0,oh,La,!1,a)}else{let[o,l]=e.getStencilConfigForOverlapAndUpdateStencilID(i);_o(e,t,r,l,o,!1,!0,oh,La,!1,a)}}function _o(e,t,r,i,a,n,s,o,l,u=!1,h,c=null){let d=i[i.length-1].overscaledZ,p=e.context,f=p.gl,m=e.useProgram("raster"),g=e.style.projection,_=e.colorModeForRenderPass(),y=!e.options.moving,v=r.paint.get("raster-opacity"),x=r.paint.get("resampling")==="nearest"||r.paint.get("raster-resampling")==="nearest"?f.NEAREST:f.LINEAR,w=r.paint.get("raster-fade-duration"),b=!!e.style.map.terrain;for(let S of i){let A=e.getDepthModeForSublayer(S.overscaledZ-d,v===1?me.ReadWrite:me.ReadOnly,f.LESS),P=t.getTile(S);p.activeTexture.set(f.TEXTURE0),P.texture.bind(x,f.CLAMP_TO_EDGE,f.LINEAR_MIPMAP_NEAREST),p.activeTexture.set(f.TEXTURE1);let{parentTile:I,parentScaleBy:R,parentTopLeft:F,fadeValues:T}=AF(P,t,w,b);P.fadeOpacity=T.tileOpacity,I?(I.fadeOpacity=T.parentTileOpacity,I.texture.bind(x,f.CLAMP_TO_EDGE,f.LINEAR_MIPMAP_NEAREST)):P.texture.bind(x,f.CLAMP_TO_EDGE,f.LINEAR_MIPMAP_NEAREST),P.texture.useMipmap&&p.extTextureFilterAnisotropic&&e.transform.pitch>e.options.anisotropicFilterPitch&&f.texParameterf(f.TEXTURE_2D,p.extTextureFilterAnisotropic.TEXTURE_MAX_ANISOTROPY_EXT,p.extTextureFilterAnisotropicMax);let E=Vt(h,S),D=Ft(h,S,{aligned:y}),C=EI(F,R,T.fadeMix,r,o,l),k=c??g.getMeshFromTileID(p,S.canonical,n,s,"raster"),B=a?a[S.overscaledZ]:Ae.disabled;m.draw(p,f.TRIANGLES,A,B,_,u?De.frontCCW:De.backCCW,C,E,D,r.id,k.vertexBuffer,k.indexBuffer,k.segments)}}function AF(e,t,r,i){let a={parentTile:null,parentScaleBy:1,parentTopLeft:[0,0],fadeValues:{tileOpacity:1,parentTileOpacity:1,fadeMix:{opacity:1,mix:0}}};if(r===0||i)return a;if(e.fadingParentID){let n=t.getLoadedTile(e.fadingParentID);if(!n)return a;let s=2**(n.tileID.overscaledZ-e.tileID.overscaledZ);return{parentTile:n,parentScaleBy:s,parentTopLeft:[e.tileID.canonical.x*s%1,e.tileID.canonical.y*s%1],fadeValues:CF(e,n,r)}}return e.selfFading?{parentTile:null,parentScaleBy:1,parentTopLeft:[0,0],fadeValues:IF(e,r)}:a}function CF(e,t,r){let i=Fe(),a=(i-e.timeAdded)/r,n=(i-t.timeAdded)/r,s=e.fadingDirection===1,o=se(a,0,1),l=se(1-n,0,1),u=s?o:l;return{tileOpacity:u,parentTileOpacity:s?l:o,fadeMix:{opacity:1,mix:1-u}}}function IF(e,t){let r=(Fe()-e.timeAdded)/t,i=se(r,0,1);return{tileOpacity:i,fadeMix:{opacity:i,mix:0}}}function MF(e,t,r,i,a){let n=r.paint.get("background-color"),s=r.paint.get("background-opacity");if(s===0)return;let o=e.context,l=o.gl,u=e.style.projection,h=e.transform,c=h.tileSize,d=r.paint.get("background-pattern");if(e.isPatternMissing(d))return;let p=!d&&n.a===1&&s===1&&e.opaquePassEnabledForLayer()?"opaque":"translucent";if(a.currentPass!==p)return;let f=Ae.disabled,m=e.getDepthModeForSublayer(0,p==="opaque"?me.ReadWrite:me.ReadOnly),g=e.colorModeForRenderPass(),_=e.useProgram(d?"backgroundPattern":"background"),y=i||en(h,{tileSize:c,terrain:e.style.map.terrain});d&&(o.activeTexture.set(l.TEXTURE0),e.patternAtlas.bind(e.context));let v=r.getCrossfadeParameters();for(let x of y){let w=Ft(a,x),b=d?lz(s,e,d,{tileID:x,tileSize:c},v):oz(s,n),S=Vt(a,x),A=u.getMeshFromTileID(o,x.canonical,!1,!0,"raster");_.draw(o,l.TRIANGLES,m,f,g,De.backCCW,b,S,w,r.id,A.vertexBuffer,A.indexBuffer,A.segments)}}const zF=new oe(1,0,0,1),FF=new oe(0,1,0,1),RF=new oe(0,0,1,1),kF=new oe(1,0,1,1),LF=new oe(0,1,1,1);function BF(e){let t=e.transform.padding;Ag(e,e.transform.height-(t.top||0),3,zF),Ag(e,t.bottom||0,3,FF),Cg(e,t.left||0,3,RF),Cg(e,e.transform.width-(t.right||0),3,kF);let r=e.transform.centerPoint;OF(e,r.x,e.transform.height-r.y,LF)}function OF(e,t,r,i){_l(e,t-1,r-10,2,20,i),_l(e,t-10,r-1,20,2,i)}function Ag(e,t,r,i){_l(e,0,t+r/2,e.transform.width,r,i)}function Cg(e,t,r,i){_l(e,t-r/2,0,r,e.transform.height,i)}function _l(e,t,r,i,a,n){let s=e.context,o=s.gl;o.enable(o.SCISSOR_TEST),o.scissor(t*e.pixelRatio,r*e.pixelRatio,i*e.pixelRatio,a*e.pixelRatio),s.clear({color:n}),o.disable(o.SCISSOR_TEST)}function $F(e,t,r,i){for(let a of r)jF(e,t,a,i)}function jF(e,t,r,i){var y;let a=e.context,n=a.gl,s=e.useProgram("debug"),o=me.disabled,l=Ae.disabled,u=e.colorModeForRenderPass(),h="$debug",c=Vt(i,r);a.activeTexture.set(n.TEXTURE0);let d=((y=t.getTileByID(r.key).latestRawTileData)==null?void 0:y.byteLength)||0,p=Math.floor(d/1024),f=t.getTile(r).tileSize,m=512/Math.min(f,512)*(r.overscaledZ/e.transform.zoom)*.5,g=r.canonical.toString();r.overscaledZ!==r.canonical.z&&(g+=` => ${r.overscaledZ}`),VF(e,`${g} ${p}kB`);let _=Ft(i,r);s.draw(a,n.TRIANGLES,o,l,et.alphaBlended,De.disabled,xg(oe.transparent,m),null,_,h,e.debugBuffer,e.quadTriangleIndexBuffer,e.debugSegments),s.draw(a,n.LINE_STRIP,o,l,u,De.disabled,xg(oe.red),c,_,h,e.debugBuffer,e.tileBorderIndexBuffer,e.debugSegments)}function VF(e,t){e.initDebugOverlayCanvas();let r=e.debugOverlayCanvas,i=e.context.gl,a=e.debugOverlayCanvas.getContext("2d");a.clearRect(0,0,r.width,r.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(r),e.debugOverlayTexture.bind(i.LINEAR,i.CLAMP_TO_EDGE)}function NF(e,t){let r=null,i=Object.values(e._layers).flatMap(o=>o.source&&!o.isHidden(t)?[e.tileManagers[o.source]]:[]),a=i.filter(o=>o.getSource().type==="vector"),n=i.filter(o=>o.getSource().type!=="vector"),s=o=>{(!r||r.getSource().maxzoom<o.getSource().maxzoom)&&(r=o)};for(let o of a)s(o);if(!r)for(let o of n)s(o);return r}function UF(e,t,r,i){let{isRenderingGlobe:a}=i,n=e.context,s=r.implementation,o=e.style.projection,l=e.transform,u=l.getProjectionDataForCustomLayer(a),h={farZ:l.farZ,nearZ:l.nearZ,fov:l.fov*Math.PI/180,modelViewProjectionMatrix:l.modelViewProjectionMatrix,projectionMatrix:l.projectionMatrix,shaderData:{variantName:o.shaderVariantName,vertexShaderPrelude:`const float PI = 3.141592653589793;
|
|
822
|
+
uniform mat4 u_projection_matrix;
|
|
823
|
+
${o.shaderPreludeCode.vertexSource}`,define:o.shaderDefine},defaultProjectionData:u,getProjectionData:d=>l.getProjectionData({overscaledTileID:new Dt(d.tileID.canonical.z,d.tileID.wrap??0,d.tileID.canonical.z,d.tileID.canonical.x,d.tileID.canonical.y),aligned:d.aligned,applyGlobeMatrix:d.applyGlobeMatrix,applyTerrainMatrix:d.applyTerrainMatrix})},c=s.renderingMode?s.renderingMode:"2d";if(i.currentPass==="offscreen"){let d=s.prerender;d&&(e.setCustomLayerDefaults(),n.setColorMode(e.colorModeForRenderPass()),d.call(s,n.gl,h),n.setDirty(),e.setBaseState())}else if(i.currentPass==="translucent"){e.setCustomLayerDefaults(),n.setColorMode(e.colorModeForRenderPass()),n.setStencilMode(Ae.disabled);let d=c==="3d"?e.getDepthModeFor3D():e.getDepthModeForSublayer(0,me.ReadOnly);n.setDepthMode(d),s.render(n.gl,h),n.setDirty(),e.setBaseState(),n.bindFramebuffer.set(null)}}function GF(e,t){let r=e.context,i=r.gl,a=e.transform,n=et.unblended,s=new me(i.LEQUAL,me.ReadWrite,[0,1]),o=t.tileManager.getRenderableTiles(),l=e.useProgram("terrainDepth");r.bindFramebuffer.set(t.getFramebuffer().framebuffer),r.viewport.set([0,0,e.width/devicePixelRatio,e.height/devicePixelRatio]),r.clear({color:oe.white,depth:1});for(let u of o){let h=t.getTerrainMesh(u.tileID),c=t.getTerrainData(u.tileID),d=a.getProjectionData({overscaledTileID:u.tileID,applyTerrainMatrix:!1,applyGlobeMatrix:!0}),p=c3(t.getSkirtLength(a.zoom));l.draw(r,i.TRIANGLES,s,Ae.disabled,n,De.backCCW,p,c,d,"terrain",h.vertexBuffer,h.indexBuffer,h.segments)}r.bindFramebuffer.set(null),r.viewport.set([0,0,e.width,e.height])}function qF(e,t,r,i){let{isRenderingGlobe:a}=i,n=e.context,s=n.gl,o=e.transform,l=e.colorModeForRenderPass(),u=e.getDepthModeFor3D(),h=e.useProgram("terrain");n.bindFramebuffer.set(null),n.viewport.set([0,0,e.width,e.height]);for(let c of r){let d=t.getTerrainMesh(c.tileID),p=e.renderToTexture.getTexture(c),f=t.getTerrainData(c.tileID);n.activeTexture.set(s.TEXTURE0),p.bind(s.LINEAR,s.CLAMP_TO_EDGE,s.LINEAR_MIPMAP_LINEAR);let m=t.getSkirtLength(o.zoom),g=o.calculateFogMatrix(c.tileID.toUnwrapped()),_=h3(m,g,e.style.sky,o.pitch,a),y=Ft(i,c.tileID,{applyTerrainMatrix:!1});h.draw(n,s.TRIANGLES,u,Ae.disabled,l,De.backCCW,_,f,y,"terrain",d.vertexBuffer,d.indexBuffer,d.segments)}}function bx(e,t){if(!t.mesh){let r=new vi;r.emplaceBack(-1,-1),r.emplaceBack(1,-1),r.emplaceBack(1,1),r.emplaceBack(-1,1);let i=new Yr;i.emplaceBack(0,1,2),i.emplaceBack(0,2,3),t.mesh=new bs(e.createVertexBuffer(r,Vi.members),e.createIndexBuffer(i),Ze.simpleSegment(0,0,r.length,i.length))}return t.mesh}function ZF(e,t){let r=e.context,i=r.gl,a=dz(t,e.transform,e.pixelRatio),n=new me(i.LEQUAL,me.ReadWrite,[0,1]),s=Ae.disabled,o=e.colorModeForRenderPass(),l=e.useProgram("sky"),u=bx(r,t);l.draw(r,i.TRIANGLES,n,s,o,De.disabled,a,null,void 0,"sky",u.vertexBuffer,u.indexBuffer,u.segments)}function WF(e,t){let r=e.getCartesianPosition();Hx(r,r);let i=Pr(new Float64Array(16));return e.properties.get("anchor")==="map"&&(yi(i,i,t.rollInRadians),Oa(i,i,-t.pitchInRadians),yi(i,i,t.bearingInRadians),Oa(i,i,t.center.lat*Math.PI/180),jg(i,i,-t.center.lng*Math.PI/180)),Xx(r,r,i),r}function HF(e,t,r){let i=e.context,a=i.gl,n=e.useProgram("atmosphere"),s=new me(a.LEQUAL,me.ReadOnly,[0,1]),o=e.transform,l=WF(r,e.transform),u=o.getProjectionData({overscaledTileID:null,applyGlobeMatrix:!0,applyTerrainMatrix:!0}),h=Xa(o.worldSize,o.center.lat),c=X1(o),d=Y1(Sr(c)-h,h),p=t.properties.get("atmosphere-blend")*u.projectionTransition*d;if(p===0)return;let f=hz(l,p,c,h,o.inverseProjectionMatrix),m=bx(i,t);n.draw(i,a.TRIANGLES,s,Ae.disabled,et.alphaBlended,De.disabled,f,null,null,"atmosphere",m.vertexBuffer,m.indexBuffer,m.segments)}const XF={symbol:iF,circle:uF,heatmap:hF,line:bF,fill:wF,fillExtrusion:TF,hillshade:SF,colorRelief:EF,raster:PF,background:MF,sky:ZF,atmosphere:HF,custom:UF,debug:$F,debugPadding:BF,terrainDepth:GF};var Hi,YF=(Hi=class{constructor(t,r){this.drawFunctions=XF,this.context=new Qz(t),this.transform=r,this.layerOpacityFbo=null,this._tileTextures={},this._rttObjectRecyclePool=[],this._rttSharedFbo=null,this.terrainFacilitator={depthDirty:!0,matrix:Pr(new Float64Array(16)),renderTime:0},this.setup(),this.numSublayers=Fc.maxOverzooming+Fc.maxUnderzooming+1,this.depthEpsilon=1/2**16,this.crossTileSymbolIndex=new B1}resize(t,r,i){if(this.width=Math.round(t*i),this.height=Math.round(r*i),this.pixelRatio=i,this.context.viewport.set([0,0,this.width,this.height]),this.style)for(let a of this.style._order)this.style._layers[a].resize()}setup(){let t=this.context,r=new vi;r.emplaceBack(0,0),r.emplaceBack(L,0),r.emplaceBack(0,L),r.emplaceBack(L,L),this.tileExtentBuffer=t.createVertexBuffer(r,Vi.members),this.tileExtentSegments=Ze.simpleSegment(0,0,4,2);let i=new vi;i.emplaceBack(0,0),i.emplaceBack(L,0),i.emplaceBack(0,L),i.emplaceBack(L,L),this.debugBuffer=t.createVertexBuffer(i,Vi.members),this.debugSegments=Ze.simpleSegment(0,0,4,5);let a=new U2;a.emplaceBack(0,0,0,0),a.emplaceBack(L,0,L,0),a.emplaceBack(0,L,0,L),a.emplaceBack(L,L,L,L),this.rasterBoundsBuffer=t.createVertexBuffer(a,n3.members),this.rasterBoundsSegments=Ze.simpleSegment(0,0,4,2);let n=new vi;n.emplaceBack(0,0),n.emplaceBack(L,0),n.emplaceBack(0,L),n.emplaceBack(L,L),this.rasterBoundsBufferPosOnly=t.createVertexBuffer(n,Vi.members),this.rasterBoundsSegmentsPosOnly=Ze.simpleSegment(0,0,4,5);let s=new vi;s.emplaceBack(0,0),s.emplaceBack(1,0),s.emplaceBack(0,1),s.emplaceBack(1,1),this.viewportBuffer=t.createVertexBuffer(s,Vi.members),this.viewportSegments=Ze.simpleSegment(0,0,4,2);let o=new tw;o.emplaceBack(0),o.emplaceBack(1),o.emplaceBack(3),o.emplaceBack(2),o.emplaceBack(0),this.tileBorderIndexBuffer=t.createIndexBuffer(o);let l=new Yr;l.emplaceBack(1,0,2),l.emplaceBack(1,2,3),this.quadTriangleIndexBuffer=t.createIndexBuffer(l);let u=this.context.gl;this.stencilClearMode=new Ae({func:u.ALWAYS,mask:0},0,255,u.ZERO,u.ZERO,u.ZERO),this.tileExtentMesh=new bs(this.tileExtentBuffer,this.quadTriangleIndexBuffer,this.tileExtentSegments)}clearStencil(){let t=this.context,r=t.gl;this.nextStencilID=1,this.currentStencilSource=void 0;let i=Pi();Lr(i,0,this.width,this.height,0,0,1),Et(i,i,[r.drawingBufferWidth,r.drawingBufferHeight,0]);let a={mainMatrix:i,tileMercatorCoords:[0,0,1,1],clippingPlane:[0,0,0,0],projectionTransition:0,fallbackMatrix:i,clipAntimeridian:!1};this.useProgram("clippingMask",null,!0).draw(t,r.TRIANGLES,me.disabled,this.stencilClearMode,et.disabled,De.disabled,null,null,a,"$clipping",this.viewportBuffer,this.quadTriangleIndexBuffer,this.viewportSegments)}renderTileClippingMasks(t,r){if(this.currentStencilSource===t.source||!t.isTileClipped()||!(r!=null&&r.length))return;this.currentStencilSource=t.source,this.nextStencilID+r.length>256&&this.clearStencil();let i=this.context;i.setColorMode(et.disabled),i.setDepthMode(me.disabled);let a={};for(let n of r)a[n.key]=this.nextStencilID++;this.style.projection.useSubdivision&&this._renderTileMasks(a,r,!0),this._renderTileMasks(a,r,!1),this._tileClippingMaskIDs=a}_renderTileMasks(t,r,i){let a=this.context,n=a.gl,s=this.style.projection,o=this.renderContext,l=this.useProgram("clippingMask");for(let u of r){let h=t[u.key],c=Vt(o,u),d=s.getMeshFromTileID(this.context,u.canonical,i,!0,"stencil"),p=Ft(o,u);l.draw(a,n.TRIANGLES,me.disabled,new Ae({func:n.ALWAYS,mask:0},h,255,n.KEEP,n.KEEP,n.REPLACE),et.disabled,o.isRenderingToTexture?De.disabled:De.backCCW,null,c,p,"$clipping",d.vertexBuffer,d.indexBuffer,d.segments)}}_renderTilesDepthBuffer(){let t=this.context,r=t.gl,i=this.style.projection,a=this.transform,n=this.useProgram("depth"),s=this.getDepthModeFor3D(),o=en(a,{tileSize:a.tileSize});for(let l of o){let u=Vt(this.renderContext,l),h=i.getMeshFromTileID(this.context,l.canonical,!0,!0,"raster"),c=Ft(this.renderContext,l);n.draw(t,r.TRIANGLES,s,Ae.disabled,et.disabled,De.backCCW,null,u,c,"$clipping",h.vertexBuffer,h.indexBuffer,h.segments)}}stencilModeFor3D(){this.currentStencilSource=void 0,this.nextStencilID+1>256&&this.clearStencil();let t=this.nextStencilID++,r=this.context.gl;return new Ae({func:r.NOTEQUAL,mask:255},t,255,r.KEEP,r.KEEP,r.REPLACE)}stencilModeForClipping(t){let r=this.context.gl;return new Ae({func:r.EQUAL,mask:255},this._tileClippingMaskIDs[t.key],0,r.KEEP,r.KEEP,r.REPLACE)}getStencilConfigForOverlapAndUpdateStencilID(t){let r=this.context.gl,i=t.sort((s,o)=>o.overscaledZ-s.overscaledZ),a=i[i.length-1].overscaledZ,n=i[0].overscaledZ-a+1;if(n>1){this.currentStencilSource=void 0,this.nextStencilID+n>256&&this.clearStencil();let s={};for(let o=0;o<n;o++)s[o+a]=new Ae({func:r.GEQUAL,mask:255},o+this.nextStencilID,255,r.KEEP,r.KEEP,r.REPLACE);return this.nextStencilID+=n,[s,i]}return[{[a]:Ae.disabled},i]}stencilConfigForOverlapTwoPass(t){let r=this.context.gl,i=t.sort((s,o)=>o.overscaledZ-s.overscaledZ),a=i[i.length-1].overscaledZ,n=i[0].overscaledZ-a+1;if(this.clearStencil(),n>1){let s={},o={};for(let l=0;l<n;l++)s[l+a]=new Ae({func:r.GREATER,mask:255},n+1+l,255,r.KEEP,r.KEEP,r.REPLACE),o[l+a]=new Ae({func:r.GREATER,mask:255},1+l,255,r.KEEP,r.KEEP,r.REPLACE);return this.nextStencilID=n*2+1,[s,o,i]}return this.nextStencilID=3,[{[a]:new Ae({func:r.GREATER,mask:255},2,255,r.KEEP,r.KEEP,r.REPLACE)},{[a]:new Ae({func:r.GREATER,mask:255},1,255,r.KEEP,r.KEEP,r.REPLACE)},i]}colorModeForRenderPass(){let t=this.context.gl;if(this._showOverdrawInspector){let r=.125;return new et([t.CONSTANT_COLOR,t.ONE],new oe(r,r,r,0),[!0,!0,!0,!0])}return this.renderContext.currentPass==="opaque"?et.unblended:et.alphaBlended}getDepthModeForSublayer(t,r,i){if(!this.opaquePassEnabledForLayer())return me.disabled;let a=1-((1+this.renderContext.currentLayer)*this.numSublayers+t)*this.depthEpsilon;return new me(i||this.context.gl.LEQUAL,r,[a,a])}getDepthModeFor3D(){return new me(this.context.gl.LEQUAL,me.ReadWrite,this.renderContext.depthRangeFor3D)}opaquePassEnabledForLayer(){return this.renderContext.currentLayer<this.renderContext.opaquePassCutoff}render(t,r){var h;this.style=t,this.options=r;let i=this.renderContext=eF(this.transform,t.projection,t.map.terrain??null);this.lineAtlas=t.lineAtlas,this.imageManager=t.imageManager,this.patternAtlas=t.patternAtlas,this.glyphManager=t.glyphManager,this.symbolFadeChange=t.placement.symbolFadeChange(Fe()),Jz(this.context.frameUniformBuffer,this),this.imageManager.beginFrame(),m3(this.context);let a=this.style._order,n=this.style.tileManagers,s={},o={},l={};for(let c in n){let d=n[c];d.used&&d.prepare(this.context),s[c]=d.getVisibleCoordinates(!1),o[c]=s[c].slice().reverse(),l[c]=d.getVisibleCoordinates(!0).reverse()}i.opaquePassCutoff=1/0;for(let c=0;c<a.length;c++){let d=a[c];if(this.style._layers[d].is3D()){i.opaquePassCutoff=c;break}}this.maybeDrawDepth(),this.renderToTexture&&(this.renderToTexture.prepareForRender(this.style,this.transform.zoom),i.opaquePassCutoff=0),i.currentPass="offscreen";for(let c of a){let d=this.style._layers[c];if(!d.hasOffscreenPass()||d.isHidden(this.transform.zoom))continue;let p=o[d.source];(d.type==="custom"||p.length)&&this.renderLayer(this,n[d.source],d,p,i)}if(this.context.viewport.set([0,0,this.width,this.height]),this.context.bindFramebuffer.set(null),this.context.clear({color:r.showOverdrawInspector?oe.black:oe.transparent,depth:1}),this.clearStencil(),this.style.sky&&this.drawFunctions.sky(this,this.style.sky),this._showOverdrawInspector=r.showOverdrawInspector,i.depthRangeFor3D=[0,1-(t._order.length+2)*this.numSublayers*this.depthEpsilon],!this.renderToTexture)for(i.currentPass="opaque",i.currentLayer=a.length-1;i.currentLayer>=0;i.currentLayer--){let c=this.style._layers[a[i.currentLayer]];if(c.isHidden(this.transform.zoom))continue;let d=n[c.source],p=s[c.source];this.renderTileClippingMasks(c,p),this.renderLayer(this,d,c,p,i)}i.currentPass="translucent";let u=!1;for(i.currentLayer=0;i.currentLayer<a.length;i.currentLayer++){let c=this.style._layers[a[i.currentLayer]];if(c.isHidden(this.transform.zoom))continue;let d=n[c.source];if((h=this.renderToTexture)!=null&&h.renderLayer(c,i))continue;!this.opaquePassEnabledForLayer()&&!u&&(u=!0,i.isRenderingGlobe&&!this.style.map.terrain&&this._renderTilesDepthBuffer());let p=(c.type==="symbol"?l:o)[c.source];this.renderTileClippingMasks(c,s[c.source]),this.renderLayer(this,d,c,p,i)}if(i.isRenderingGlobe&&this.drawFunctions.atmosphere(this,this.style.sky,this.style.light),this.options.showTileBoundaries){let c=NF(this.style,this.transform.zoom);c&&this.drawFunctions.debug(this,c,c.getVisibleCoordinates(),i)}this.options.showPadding&&this.drawFunctions.debugPadding(this),this.renderToTexture&&!this.options.moving&&this.clearRTTPool(),this.context.setDefault()}markTerrainDepthDirty(){this.terrainFacilitator.depthDirty=!0}maybeDrawDepth(){var a,n;if(!((a=this.style)!=null&&a.projection)||!((n=this.style.map)!=null&&n.terrain))return;let t=this.terrainFacilitator.matrix,r=this.transform.modelViewProjectionMatrix,i=this.terrainFacilitator.depthDirty;i||(i=!Zx(t,r)),i||(i=this.style.map.terrain.tileManager.anyTilesAfterTime(this.terrainFacilitator.renderTime)),i&&(Vx(t,r),this.terrainFacilitator.renderTime=Fe(),this.terrainFacilitator.depthDirty=!1,this.drawFunctions.terrainDepth(this,this.style.map.terrain))}renderLayer(t,r,i,a,n){if(i.isHidden(this.transform.zoom)||i.type!=="background"&&i.type!=="custom"&&!(a||[]).length)return;this.id=i.id;let s=this.drawFunctions;B0(i)?s.symbol(t,r,i,a,this.style.placement.variableOffsets,n):Cw(i)?s.circle(t,r,i,a,n):Rw(i)?s.heatmap(t,r,i,a,n):pS(i)?s.line(t,r,i,a,n):ET(i)?s.fill(t,r,i,a,n):YT(i)?s.fillExtrusion(t,r,i,a,n):$w(i)?s.hillshade(t,r,i,a,n):qw(i)?s.colorRelief(t,r,i,a,n):Fh(i)?s.raster(t,r,i,a,n):mE(i)?s.background(t,r,i,a,n):yE(i)&&s.custom(t,r,i,n)}saveTileTexture(t){let r=this._tileTextures[t.size[0]];r?r.length<Hi.MAX_TEXTURE_POOL_SIZE_PER_BUCKET?r.push(t):t.destroy():this._tileTextures[t.size[0]]=[t]}getTileTexture(t){let r=this._tileTextures[t];return r&&r.length>0?r.pop():null}acquireRTT(t){let r=this.context.gl,i=this._rttObjectRecyclePool.pop();if(i)return i.size!==t&&(i.texture.update({width:t,height:t,data:null},{premultiply:!1,useMipmap:!0}),i.texture.bind(r.LINEAR,r.CLAMP_TO_EDGE,r.LINEAR_MIPMAP_LINEAR),this.context.extTextureFilterAnisotropic&&r.texParameterf(r.TEXTURE_2D,this.context.extTextureFilterAnisotropic.TEXTURE_MAX_ANISOTROPY_EXT,this.context.extTextureFilterAnisotropicMax),i.size=t),i;let a=new dt(this.context,{width:t,height:t,data:null},r.RGBA,{premultiply:!1,useMipmap:!0});return a.bind(r.LINEAR,r.CLAMP_TO_EDGE,r.LINEAR_MIPMAP_LINEAR),this.context.extTextureFilterAnisotropic&&r.texParameterf(r.TEXTURE_2D,this.context.extTextureFilterAnisotropic.TEXTURE_MAX_ANISOTROPY_EXT,this.context.extTextureFilterAnisotropicMax),{texture:a,size:t}}bindRTT(t){let r=this.context.gl,i=t.size;if(!this._rttSharedFbo){let a=this.context.createFramebuffer(i,i,!0,!0),n=this.context.createRenderbuffer(r.DEPTH_STENCIL,i,i);a.depthAttachment.set(n),this._rttSharedFbo={fbo:a,depthRenderbuffer:n,size:i}}this._rttSharedFbo.size!==i&&(this.context.bindRenderbuffer.set(this._rttSharedFbo.depthRenderbuffer),r.renderbufferStorage(r.RENDERBUFFER,r.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(t.texture.texture),this.context.bindFramebuffer.set(this._rttSharedFbo.fbo.framebuffer)}releaseRTT(t){this._rttObjectRecyclePool.push(t)}clearRTTPool(){for(let t of this._rttObjectRecyclePool)t.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 t=this.context.gl;t.deleteRenderbuffer(this._rttSharedFbo.depthRenderbuffer),t.deleteFramebuffer(this._rttSharedFbo.fbo.framebuffer),this._rttSharedFbo=null}isPatternMissing(t){if(!t)return!1;if(!t.from||!t.to)return!0;let r=this.patternAtlas.getPattern(t.from.toString()),i=this.patternAtlas.getPattern(t.to.toString());return!r||!i}useProgram(t,r,i=!1,a=[]){var m;this.cache||(this.cache={});let n=!!this.style.map.terrain,s=this.style.projection,o=i?Vr.projectionMercator:s.shaderPreludeCode,l=i?O1:s.shaderDefine,u=`/${i?$1:s.shaderVariantName}`,h=r?r.cacheKey:"",c=this._showOverdrawInspector?"/overdraw":"",d=n?"/terrain":"",p=a?`/${a.join("/")}`:"",f=t+h+u+c+d+p;return(m=this.cache)[f]||(m[f]=new v3(this.context,Vr[t],r,pz[t],this._showOverdrawInspector,n,o,l,a)),this.cache[f]}setCustomLayerDefaults(){this.context.setCustomLayerDefaults()}setBaseState(){let t=this.context.gl;this.context.cullFace.set(!1),this.context.viewport.set([0,0,this.width,this.height]),this.context.blendEquation.set(t.FUNC_ADD)}initDebugOverlayCanvas(){if(this.debugOverlayCanvas==null){this.debugOverlayCanvas=document.createElement("canvas"),this.debugOverlayCanvas.width=512,this.debugOverlayCanvas.height=512;let t=this.context.gl;this.debugOverlayTexture=new dt(this.context,this.debugOverlayCanvas,t.RGBA)}}destroy(){var t,r,i;if(this._tileTextures){for(let a in this._tileTextures){let n=this._tileTextures[a];if(n)for(let s of n)s.destroy()}this._tileTextures={}}if(this.destroyRTTResources(),(t=this.layerOpacityFbo)==null||t.destroy(),this.layerOpacityFbo=null,this.tileExtentBuffer&&this.tileExtentBuffer.destroy(),this.debugBuffer&&this.debugBuffer.destroy(),this.rasterBoundsBuffer&&this.rasterBoundsBuffer.destroy(),this.rasterBoundsBufferPosOnly&&this.rasterBoundsBufferPosOnly.destroy(),this.viewportBuffer&&this.viewportBuffer.destroy(),this.tileBorderIndexBuffer&&this.tileBorderIndexBuffer.destroy(),this.quadTriangleIndexBuffer&&this.quadTriangleIndexBuffer.destroy(),this.tileExtentMesh&&((r=this.tileExtentMesh.vertexBuffer)==null||r.destroy()),this.tileExtentMesh&&((i=this.tileExtentMesh.indexBuffer)==null||i.destroy()),this.debugOverlayTexture&&this.debugOverlayTexture.destroy(),g3(this.context),this.context.terrainUniformBuffer.destroy(),this.context.frameUniformBuffer.destroy(),this.cache){for(let a in this.cache){let n=this.cache[a];n!=null&&n.program&&this.context.gl.deleteProgram(n.program)}this.cache={}}this.context&&this.context.setDefault()}overLimit(){let{drawingBufferWidth:t,drawingBufferHeight:r}=this.context.gl;return this.width!==t||this.height!==r}},Hi.MAX_TEXTURE_POOL_SIZE_PER_BUCKET=50,Hi),KF=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==null?void 0:t.statusMessage)??null}};function wx(e,t){let r=!1,i=null,a,n=()=>{i=null,r&&(r=(e(...a),i=setTimeout(n,t),!1))};return(...s)=>(r=!0,a=s,i||n(),i)}var JF=class{constructor(e){this._getHashParams=()=>new URLSearchParams(window.location.hash.replace("#","")),this._getCurrentHash=()=>{let t=this._getHashParams();return this._hashName?(t.get(this._hashName)||"").split("/"):([...t.keys()][0]??"").split("/")},this._onHashChange=()=>{let t=this._getCurrentHash();if(!this._isValidHash(t))return!1;let r=this._map.dragRotate.isEnabled()&&this._map.touchZoomRotate.isEnabled()?+(t[3]||0):this._map.getBearing();return this._map.jumpTo({center:[+t[2],+t[1]],zoom:+t[0],bearing:r,pitch:+(t[4]||0)}),!0},this._updateHashUnthrottled=()=>{let t=window.location.href.replace(/(#.*)?$/,this.getHashString());window.history.replaceState(window.history.state,null,t)},this._removeHash=()=>{let t=this._getHashParams();if(this._hashName)t.delete(this._hashName);else{let n=Array.from(t.keys());n.length>0&&t.delete(n[0])}let r=decodeURIComponent(t.toString()).replace(/=&/g,"&").replace(/=$/g,""),i=r?`#${r}`:"",a=window.location.href.replace(/(#.+)?$/,i);a=a.replace("&&","&"),window.history.replaceState(window.history.state,null,a)},this._updateHash=wx(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(),r=Math.round(this._map.getZoom()*100)/100,i=10**Math.ceil((r*Math.LN2+Math.log(512/360/.5))/Math.LN10),a=Math.round(t.lng*i)/i,n=Math.round(t.lat*i)/i,s=this._map.getBearing(),o=this._map.getPitch(),l="";if(l+=e?`/${a}/${n}/${r}`:`${r}/${n}/${a}`,(s||o)&&(l+=`/${Math.round(s*10)/10}`),o&&(l+=`/${Math.round(o)}`),this._hashName){let u=this._getHashParams();return u.set(this._hashName,l),`#${decodeURIComponent(u.toString()).replace(/=&/g,"&").replace(/=$/g,"")}`}return`#${l}`}_isValidHash(e){if(e.length<3||e.some(a=>isNaN(+a)))return!1;try{new ee(+e[2],+e[1])}catch{return!1}let t=+e[0],r=+(e[3]||0),i=+(e[4]||0);return t>=this._map.getMinZoom()&&t<=this._map.getMaxZoom()&&r>=-180&&r<=180&&i>=this._map.getMinPitch()&&i<=this._map.getMaxPitch()}};const Ts={linearity:.3,easing:qc(0,0,.3,1)},QF=H({deceleration:2500,maxSpeed:1400},Ts),e5=H({deceleration:20,maxSpeed:1400},Ts),t5=H({deceleration:1e3,maxSpeed:360},Ts),r5=H({deceleration:1e3,maxSpeed:90},Ts),i5=H({deceleration:1e3,maxSpeed:360},Ts);var a5=class{constructor(e){this._map=e,this.clear()}clear(){this._inertiaBuffer=[]}record(e){this._drainInertiaBuffer(),this._inertiaBuffer.push({time:Fe(),settings:e})}_drainInertiaBuffer(){let e=this._inertiaBuffer,t=Fe();for(;e.length>0&&t-e[0].time>160;)e.shift()}_getVelocityEntries(){let e=this._inertiaBuffer,t=Fe()-60,r=Math.max(0,e.length-2);for(;r>0&&e[r-1].time>=t;)r--;return e.slice(r)}_onMoveEnd(e){this._drainInertiaBuffer();let t=this._getVelocityEntries();if(t.length<2){this.clear();return}let r={zoom:0,bearing:0,pitch:0,roll:0,pan:new M(0,0),pinchAround:void 0,around:void 0};for(let{settings:n}of t)n.around&&(r.around=n.around),n.pinchAround&&(r.pinchAround=n.pinchAround);for(let{settings:n}of t.slice(1))r.zoom+=n.zoomDelta||0,r.bearing+=n.bearingDelta||0,r.pitch+=n.pitchDelta||0,r.roll+=n.rollDelta||0,n.panDelta&&r.pan._add(n.panDelta);if(!r.pan.mag()&&!r.zoom&&!r.bearing&&!r.pitch&&!r.roll){this.clear();return}let i=Fe()-t[0].time,a={};if(r.pan.mag()){let n=Sn(r.pan.mag(),i,H({},QF,e||{})),s=r.pan.mult(n.amount/r.pan.mag()),o=this._map._camera.cameraHelper.handlePanInertia(s,this._map._camera.transform);a.center=o.easingCenter,a.offset=o.easingOffset,Tn(a,n)}if(r.zoom){let n=Sn(r.zoom,i,e5);a.zoom=rr(this._map.getZoom()+n.amount,this._map.getZoomSnap(),n.amount),Tn(a,n)}if(r.bearing){let n=Sn(r.bearing,i,t5);a.bearing=this._map.getBearing()+se(n.amount,-179,179),Tn(a,n)}if(r.pitch){let n=Sn(r.pitch,i,r5);a.pitch=this._map.getPitch()+n.amount,Tn(a,n)}if(r.roll){let n=Sn(r.roll,i,i5);a.roll=this._map.getRoll()+se(n.amount,-179,179),Tn(a,n)}if(a.zoom||a.bearing){let n=r.pinchAround===void 0?r.around:r.pinchAround;a.around=n?this._map.unproject(n):this._map.getCenter()}return this.clear(),H(a,{noMoveStart:!0})}};function Tn(e,t){(!e.duration||e.duration<t.duration)&&(e.duration=t.duration,e.easing=t.easing)}function Sn(e,t,r){let{maxSpeed:i,linearity:a,deceleration:n}=r,s=se(e*a/(t/1e3),-i,i),o=Math.abs(s)/(n*a);return{easing:r.easing,duration:o*1e3,amount:o/2*s}}var n5=class{constructor(e,t){this._map=e,this._clickTolerance=t.clickTolerance}reset(){delete this._mousedownPos}wheel(e){return this._firePreventable(new wC(this._map,e))}mousedown(e,t){return this._mousedownPos=t,this._firePreventable(new ir(e.type,this._map,e))}mouseup(e){this._map.fire(new ir(e.type,this._map,e))}click(e,t){this._mousedownPos&&this._mousedownPos.dist(t)>=this._clickTolerance||this._map.fire(new ir(e.type,this._map,e))}dblclick(e){return this._firePreventable(new ir(e.type,this._map,e))}mouseover(e){this._map.fire(new ir(e.type,this._map,e))}mouseout(e){this._map.fire(new ir(e.type,this._map,e))}touchstart(e){return this._firePreventable(new no(e.type,this._map,e))}touchmove(e){this._map.fire(new no(e.type,this._map,e))}touchend(e){this._map.fire(new no(e.type,this._map,e))}touchcancel(e){this._map.fire(new no(e.type,this._map,e))}_firePreventable(e){if(this._map.fire(e),e.defaultPrevented)return{}}isEnabled(){return!0}isActive(){return!1}enable(){}disable(){}},s5=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 ir(e.type,this._map,e))}mousedown(){this._delayContextMenu=!0,this._ignoreContextMenu=!1}mouseup(){this._delayContextMenu=!1,this._contextMenuEvent&&(this._map.fire(new ir("contextmenu",this._map,this._contextMenuEvent)),delete this._contextMenuEvent)}touchstart(e,t,r){if(this._clearLongPress(),this._touchActive=r.length>0,r.length!==1)return;this._longPressStart=t[0];let i=r[0];this._longPressTimer=setTimeout(()=>{this._longPressTimer=void 0;let a=new MouseEvent("contextmenu",{clientX:i.clientX,clientY:i.clientY,button:2,bubbles:!0,cancelable:!0});this._map.fire(new ir("contextmenu",this._map,a))},500)}touchmove(e,t,r){this._longPressTimer&&(r.length!==1||!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&&(this._longPressTimer=(clearTimeout(this._longPressTimer),void 0)),this._longPressStart=void 0}contextmenu(e){if(this._touchActive){e.preventDefault();return}this._delayContextMenu?this._contextMenuEvent=e:this._ignoreContextMenu||this._map.fire(new ir(e.type,this._map,e)),this._map.listens("contextmenu")&&e.preventDefault()}isEnabled(){return!0}isActive(){return!1}enable(){}disable(){}},o5=class{constructor(e,t,r){this._map=e,this._tr=r,this._el=e.getCanvasContainer(),this._container=e.getContainer(),this._clickTolerance=t.clickTolerance||1,t.boxZoom&&typeof t.boxZoom=="object"&&(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&&e.button===0&&(at.disableDrag(),this._startPos=this._lastPos=t,this._active=!0)}mousemoveWindow(e,t){if(!this._active)return;let r=t;if(this._lastPos.equals(r)||!this._box&&r.dist(this._startPos)<this._clickTolerance)return;let i=this._startPos;this._lastPos=r,this._box||(this._box=at.create("div","maplibregl-boxzoom",this._container),this._container.classList.add("maplibregl-crosshair"),this._fireEvent("boxzoomstart",e));let a=Math.min(i.x,r.x),n=Math.max(i.x,r.x),s=Math.min(i.y,r.y),o=Math.max(i.y,r.y);this._box.style.transform=`translate(${a}px,${s}px)`,this._box.style.width=`${n-a}px`,this._box.style.height=`${o-s}px`}mouseupWindow(e,t){if(!this._active||e.button!==0)return;let r=this._startPos,i=t;if(this.reset(),at.suppressClick(),r.x===i.x&&r.y===i.y)this._fireEvent("boxzoomcancel",e);else{if(this._map.fire(new Dm("boxzoomend",{originalEvent:e})),this._boxZoomEnd){this._boxZoomEnd(this._map,r,i,e);return}return{cameraAnimation:a=>a.fitScreenCoordinates(r,i,this._tr.bearing,{linear:!0})}}}keydown(e){this._active&&e.keyCode===27&&(this.reset(),this._fireEvent("boxzoomcancel",e))}reset(){this._active=!1,this._container.classList.remove("maplibregl-crosshair"),this._box&&(this._box=(this._box.remove(),null)),at.enableDrag(),delete this._startPos,delete this._lastPos}_fireEvent(e,t){return this._map.fire(new Dm(e,{originalEvent:t}))}};function $c(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 r={};for(let i=0;i<e.length;i++)r[e[i].identifier]=t[i];return r}function l5(e){let t=new M(0,0);for(let r of e)t._add(r);return t.div(e.length)}var u5=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,r){(this.centroid||r.length>this.numTouches)&&(this.aborted=!0),!this.aborted&&(this.startTime===void 0&&(this.startTime=e.timeStamp),r.length===this.numTouches&&(this.centroid=l5(t),this.touches=$c(r,t)))}touchmove(e,t,r){if(this.aborted||!this.centroid)return;let i=$c(r,t);for(let a in this.touches){let n=this.touches[a],s=i[a];(!s||s.dist(n)>30)&&(this.aborted=!0)}}touchend(e,t,r){if((!this.centroid||e.timeStamp-this.startTime>500)&&(this.aborted=!0),r.length===0){let i=!this.aborted&&this.centroid;if(this.reset(),i)return i}}},jc=class{constructor(e){this.singleTap=new u5(e),this.numTaps=e.numTaps,this.reset()}reset(){this.lastTime=1/0,delete this.lastTap,this.count=0,this.singleTap.reset()}touchstart(e,t,r){this.singleTap.touchstart(e,t,r)}touchmove(e,t,r){this.singleTap.touchmove(e,t,r)}touchend(e,t,r){let i=this.singleTap.touchend(e,t,r);if(i){let a=e.timeStamp-this.lastTime<500,n=!this.lastTap||this.lastTap.dist(i)<30;if((!a||!n)&&this.reset(),this.count++,this.lastTime=e.timeStamp,this.lastTap=i,this.count===this.numTaps)return this.reset(),i}}},h5=class{constructor(e,t){this._tr=t,this._zoomIn=new jc({numTouches:1,numTaps:2}),this._zoomOut=new jc({numTouches:2,numTaps:1}),this.reset()}reset(){this._active=!1,this._zoomIn.reset(),this._zoomOut.reset()}touchstart(e,t,r){this._zoomIn.touchstart(e,t,r),this._zoomOut.touchstart(e,t,r)}touchmove(e,t,r){this._zoomIn.touchmove(e,t,r),this._zoomOut.touchmove(e,t,r)}touchend(e,t,r){let i=this._zoomIn.touchend(e,t,r),a=this._zoomOut.touchend(e,t,r),n=this._tr;if(i)return this._active=!0,e.preventDefault(),setTimeout(()=>this.reset(),0),{cameraAnimation:s=>s.easeTo({duration:300,zoom:rr(n.zoom+1,s.getZoomSnap()),around:n.transform.isPointOnMapSurface(i)?n.unproject(i):void 0},{originalEvent:e})};if(a)return this._active=!0,e.preventDefault(),setTimeout(()=>this.reset(),0),{cameraAnimation:s=>s.easeTo({duration:300,zoom:rr(n.zoom-1,s.getZoomSnap()),around:n.transform.isPointOnMapSurface(a)?n.unproject(a):void 0},{originalEvent:e})}}touchcancel(){this.reset()}enable(){this._enabled=!0}disable(){this._enabled=!1,this.reset()}isEnabled(){return this._enabled}isActive(){return this._active}},Hl=class{constructor(e){this._enabled=!!e.enable,this._moveStateManager=e.moveStateManager,this._clickTolerance=e.clickTolerance||1,this._moveFunction=e.move,this._activateOnStart=!!e.activateOnStart,e.assignEvents(this),this.reset()}reset(e){this._active=!1,this._moved=!1,delete this._lastPoint,this._moveStateManager.endMove(e)}_move(...e){let t=this._moveFunction(...e);if(t.bearingDelta||t.pitchDelta||t.rollDelta||t.around||t.panDelta)return this._active=!0,t}dragStart(e,t){this.isEnabled()&&!this._lastPoint&&this._moveStateManager.isValidStartEvent(e)&&(this._moveStateManager.startMove(e),this._lastPoint=Array.isArray(t)?t[0]:t,this._activateOnStart&&this._lastPoint&&(this._active=!0))}dragMove(e,t){if(!this.isEnabled())return;let r=this._lastPoint;if(!r)return;if(e.preventDefault(),!this._moveStateManager.isValidMoveEvent(e)){this.reset(e);return}let i=Array.isArray(t)?t[0]:t;if(!(!this._moved&&i.dist(r)<this._clickTolerance))return this._moved=!0,this._lastPoint=i,this._move(r,i)}dragEnd(e){this.isEnabled()&&this._lastPoint&&this._moveStateManager.isValidEndEvent(e)&&(this._moved&&at.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}};const c5={0:1,2:2};function d5(e,t){let r=c5[t];return e.buttons===void 0||(e.buttons&r)!==r}var Xl=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!d5(e,this._eventButton)}isValidEndEvent(e){return e.button===this._eventButton}};const Yl=e=>{e.mousedown=e.dragStart,e.mousemoveWindow=e.dragMove,e.mouseup=e.dragEnd,e.contextmenu=t=>{t.preventDefault()}};function p5({enable:e,clickTolerance:t}){return new Hl({clickTolerance:t,move:(r,i)=>({around:i,panDelta:i.sub(r)}),activateOnStart:!0,moveStateManager:new Xl({checkCorrectEvent:r=>r.button===0&&!r.ctrlKey}),enable:e,assignEvents:Yl})}function f5({enable:e,clickTolerance:t,aroundCenter:r=!0,minPixelCenterThreshold:i=100,rotateSpeed:a=.8},n){return new Hl({clickTolerance:t,move:(s,o)=>{let l=n();if(r&&Math.abs(l.y-s.y)>i)return{bearingDelta:Ev(new M(s.x,o.y),o,l)};let u=(o.x-s.x)*a;return r&&o.y<l.y&&(u=-u),{bearingDelta:u}},moveStateManager:new Xl({checkCorrectEvent:s=>s.button===0&&s.ctrlKey||s.button===2&&!s.ctrlKey}),enable:e,assignEvents:Yl})}function m5({enable:e,clickTolerance:t,pitchSpeed:r=-.5}){return new Hl({clickTolerance:t,move:(i,a)=>({pitchDelta:(a.y-i.y)*r}),moveStateManager:new Xl({checkCorrectEvent:i=>i.button===0&&i.ctrlKey||i.button===2}),enable:e,assignEvents:Yl})}function g5({enable:e,clickTolerance:t,rollDegreesPerPixelMoved:r=.3},i){return new Hl({clickTolerance:t,move:(a,n)=>{let s=i(),o=(n.x-a.x)*r;return n.y<s.y&&(o=-o),{rollDelta:o}},moveStateManager:new Xl({checkCorrectEvent:a=>a.button===2&&a.ctrlKey}),enable:e,assignEvents:Yl})}var _5=class{constructor(e,t){this._clickTolerance=e.clickTolerance||1,this._map=t,this.reset()}reset(){this._active=!1,this._touches={},this._sum=new M(0,0)}_shouldBePrevented(e){return e<(this._map.cooperativeGestures.isEnabled()?2:1)}touchstart(e,t,r){return this._calculateTransform(e,t,r)}touchmove(e,t,r){if(this._active){if(this._shouldBePrevented(r.length)){this._map.cooperativeGestures.notifyGestureBlocked("touch_pan",e);return}return e.preventDefault(),this._calculateTransform(e,t,r)}}touchend(e,t,r){this._calculateTransform(e,t,r),this._active&&this._shouldBePrevented(r.length)&&this.reset()}touchcancel(){this.reset()}_calculateTransform(e,t,r){r.length>0&&(this._active=!0);let i=$c(r,t),a=new M(0,0),n=new M(0,0),s=0;for(let l in i){let u=i[l],h=this._touches[l];h&&(a._add(u),n._add(u.sub(h)),s++,i[l]=u)}if(this._touches=i,this._shouldBePrevented(s)||!n.mag())return;let o=n.div(s);if(this._sum._add(o),!(this._sum.mag()<this._clickTolerance))return{around:a.div(s),panDelta:o}}enable(){this._enabled=!0}disable(){this._enabled=!1,this.reset()}isEnabled(){return this._enabled}isActive(){return this._active}},np=class{constructor(){this.reset()}reset(){this._active=!1,delete this._firstTwoTouches}touchstart(e,t,r){this._firstTwoTouches||r.length<2||(this._firstTwoTouches=[r[0].identifier,r[1].identifier],this._start([t[0],t[1]]))}touchmove(e,t,r){if(!this._firstTwoTouches)return;e.preventDefault();let[i,a]=this._firstTwoTouches,n=yo(r,t,i),s=yo(r,t,a);if(!n||!s)return;let o=this._aroundCenter?null:n.add(s).div(2);return this._move([n,s],o,e)}touchend(e,t,r){if(!this._firstTwoTouches)return;let[i,a]=this._firstTwoTouches,n=yo(r,t,i),s=yo(r,t,a);n&&s||(this._active&&at.suppressClick(),this.reset())}touchcancel(){this.reset()}enable(e){this._enabled=!0,this._aroundCenter=!!e&&e.around==="center"}disable(){this._enabled=!1,this.reset()}isEnabled(){return!!this._enabled}isActive(){return!!this._active}};function yo(e,t,r){for(let i=0;i<e.length;i++)if(e[i].identifier===r)return t[i]}const Ig=.1;function Mg(e,t){return Math.log(e/t)/Math.LN2}var y5=class extends np{constructor(){super(),this._zoomRate=1,this._zoomThreshold=Ig}setZoomRate(e){this._zoomRate=e??1}setZoomThreshold(e){this._zoomThreshold=e??Ig}reset(){super.reset(),delete this._distance,delete this._startDistance}_start(e){this._startDistance=this._distance=e[0].dist(e[1])}_move(e,t){let r=this._distance;if(this._distance=e[0].dist(e[1]),!(!this._active&&Math.abs(Mg(this._distance,this._startDistance))<this._zoomThreshold))return this._active=!0,{zoomDelta:Mg(this._distance,r)*this._zoomRate,pinchAround:t}}};function zg(e,t){return e.angleWith(t)*180/Math.PI}var x5=class extends np{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,r){let i=this._vector;if(this._vector=e[0].sub(e[1]),this._active||!this._isBelowThreshold(this._vector))return this._active=!0,{bearingDelta:zg(this._vector,i),pinchAround:t}}_isBelowThreshold(e){this._minDiameter=Math.min(this._minDiameter,e.mag());let t=25/(Math.PI*this._minDiameter)*360,r=zg(e,this._startVector);return Math.abs(r)<t}};function lh(e){return Math.abs(e.y)>Math.abs(e.x)}var v5=class extends np{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,r){super.touchstart(e,t,r),this._currentTouchCount=r.length}_start(e){this._lastPoints=e,lh(e[0].sub(e[1]))&&(this._valid=!1)}_move(e,t,r){if(this._map.cooperativeGestures.isEnabled()&&this._currentTouchCount<3)return;let i=e[0].sub(this._lastPoints[0]),a=e[1].sub(this._lastPoints[1]);if(this._valid=this.gestureBeginsVertically(i,a,r.timeStamp),this._valid)return this._lastPoints=e,this._active=!0,{pitchDelta:(i.y+a.y)/2*-.5}}gestureBeginsVertically(e,t,r){if(this._valid!==void 0)return this._valid;let i=e.mag()>=2,a=t.mag()>=2;if(!i&&!a)return;if(!i||!a)return this._firstMove===void 0&&(this._firstMove=r),r-this._firstMove<100&&void 0;let n=e.y>0==t.y>0;return lh(e)&&lh(t)&&n}};const b5={panStep:100,bearingStep:15,pitchStep:10};var w5=class{constructor(e,t){this._tr=t;let r=b5;this._panStep=r.panStep,this._bearingStep=r.bearingStep,this._pitchStep=r.pitchStep,this._rotationDisabled=!1}reset(){this._active=!1}keydown(e){if(e.altKey||e.ctrlKey||e.metaKey)return;let t=0,r=0,i=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?r=-1:(e.preventDefault(),a=-1);break;case 39:e.shiftKey?r=1:(e.preventDefault(),a=1);break;case 38:e.shiftKey?i=1:(e.preventDefault(),n=-1);break;case 40:e.shiftKey?i=-1:(e.preventDefault(),n=1);break;default:return}return this._rotationDisabled&&(r=0,i=0),{cameraAnimation:s=>{let o=this._tr;s.easeTo({duration:300,easeId:"keyboardHandler",easing:T5,zoom:t?rr(o.zoom+t*(e.shiftKey?2:1),s.getZoomSnap()):o.zoom,bearing:o.bearing+r*this._bearingStep,pitch:o.pitch+i*this._pitchStep,offset:[-a*this._panStep,-n*this._panStep],center:o.center},{originalEvent:e})}}}enable(){this._enabled=!0}disable(){this._enabled=!1,this.reset()}isEnabled(){return this._enabled}isActive(){return this._active}disableRotation(){this._rotationDisabled=!0}enableRotation(){this._rotationDisabled=!1}};function T5(e){return e*(2-e)}const Fg=4.000244140625;var S5=class{constructor(e,t,r){this._onTimeout=i=>{this._type="wheel",this._delta-=this._lastValue,this._active||this._start(i)},this._map=e,this._tr=r,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||this._finishTimeout!==void 0}isZooming(){return!!this._zooming}enable(e){this.isEnabled()||(this._enabled=!0,this._aroundCenter=!!e&&e.around==="center")}disable(){this.isEnabled()&&(this._enabled=!1)}_shouldBePrevented(e){return this._map.cooperativeGestures.isEnabled()?!(e.ctrlKey||this._map.cooperativeGestures.isBypassed(e)):!1}wheel(e){if(!this.isEnabled())return;if(this._shouldBePrevented(e)){this._map.cooperativeGestures.notifyGestureBlocked("wheel_zoom",e);return}let t=e.deltaMode===WheelEvent.DOM_DELTA_LINE?e.deltaY*40:e.deltaY,r=Fe(),i=r-(this._lastWheelEventTime||0);this._lastWheelEventTime=r,t!==0&&t%Fg==0?this._type="wheel":t!==0&&Math.abs(t)<4?this._type="trackpad":i>400?(this._type=null,this._lastValue=t,this._timeout=setTimeout(this._onTimeout,40,e)):this._type||(this._type=Math.abs(i*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=at.mousePos(this._map.getCanvas(),e),r=this._tr;this._aroundPoint=this._aroundCenter?r.transform.locationToScreenPoint(ee.convert(r.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(typeof this._lastExpectedZoom=="number"){let s=e.zoom-this._lastExpectedZoom;typeof this._startZoom=="number"&&(this._startZoom+=s),typeof this._targetZoom=="number"&&(this._targetZoom+=s)}if(this._delta!==0){let s=this._type==="wheel"&&Math.abs(this._delta)>Fg?this._wheelZoomRate:this._defaultZoomRate,o=2/(1+Math.exp(-Math.abs(this._delta*s)));this._delta<0&&o!==0&&(o=1/o);let l=typeof this._targetZoom=="number"?$t(this._targetZoom):e.scale,u=e.applyConstrain(e.getCameraLngLat(),It(l*o)).zoom,h=this._map.getZoomSnap();if(this._type==="wheel"&&h>0){let c=rr(e.zoom,h);this._targetZoom=rr(u,h,u-c)}else this._targetZoom=u;this._type==="wheel"&&(this._startZoom=e.zoom,this._easing=this._smoothOutEasing(200)),this._delta=0}let t=typeof this._targetZoom=="number"?this._targetZoom:e.zoom,r=this._startZoom,i=this._easing,a=!1,n;if(this._type==="wheel"&&r&&i){let s=Fe()-this._lastWheelEventTime,o=Math.min((s+5)/200,1),l=i(o);n=We.number(r,t,l),o<1?this._needsRerender=!0:a=!0}else n=t,a=!0;return this._active=!0,a&&(this._active=!1,this._finishTimeout=setTimeout(()=>{this._zooming=!1,this._triggerRenderFrame(),delete this._targetZoom,delete this._lastExpectedZoom,delete this._finishTimeout},200)),this._lastExpectedZoom=n,{noInertia:!0,needsRenderFrame:!a,zoomDelta:n-e.zoom,around:this._aroundPoint,originalEvent:this._lastWheelEvent}}_smoothOutEasing(e){let t=gh;if(this._prevEase){let r=this._prevEase,i=(Fe()-r.start)/r.duration,a=r.easing(i+.01)-r.easing(i),n=.27/Math.sqrt(a*a+1e-4)*.01,s=Math.sqrt(.0729-n*n);t=qc(n,s,.25,1)}return this._prevEase={start:Fe(),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)}},D5=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()}},E5=class{constructor(e,t){this._tr=t,this.reset()}reset(){this._active=!1}dblclick(e,t){return e.preventDefault(),{cameraAnimation:r=>{r.easeTo({duration:300,zoom:rr(this._tr.zoom+(e.shiftKey?-1:1),r.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}},P5=class{constructor(){this._tap=new jc({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,r){if(!this._swipePoint)if(!this._tapTime)this._tap.touchstart(e,t,r);else{let i=t[0],a=e.timeStamp-this._tapTime<500,n=this._tapPoint.dist(i)<30;!a||!n?this.reset():r.length>0&&(this._swipePoint=i,this._swipeTouch=r[0].identifier)}}touchmove(e,t,r){if(!this._tapTime)this._tap.touchmove(e,t,r);else if(this._swipePoint){if(r[0].identifier!==this._swipeTouch)return;let i=t[0],a=i.y-this._swipePoint.y;return this._swipePoint=i,e.preventDefault(),this._active=!0,{zoomDelta:a/128*this._zoomRate}}}touchend(e,t,r){if(this._tapTime)this._swipePoint&&r.length===0&&this.reset();else{let i=this._tap.touchend(e,t,r);i&&(this._tapTime=e.timeStamp,this._tapPoint=i)}}touchcancel(){this.reset()}enable(){this._enabled=!0}disable(){this._enabled=!1,this.reset()}isEnabled(){return this._enabled}isActive(){return this._active}},A5=class{constructor(e,t,r){this._el=e,this._mousePan=t,this._touchPan=r}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()}},C5=class{constructor(e,t,r,i){this._pitchWithRotate=e.pitchWithRotate,this._rollEnabled=e.rollEnabled,this._mouseRotate=t,this._mousePitch=r,this._mouseRoll=i}enable(){this._mouseRotate.enable(),this._pitchWithRotate&&this._mousePitch.enable(),this._rollEnabled&&this._mouseRoll.enable()}disable(){this._mouseRotate.disable(),this._mousePitch.disable(),this._mouseRoll.disable()}isEnabled(){return this._mouseRotate.isEnabled()&&(!this._pitchWithRotate||this._mousePitch.isEnabled())&&(!this._rollEnabled||this._mouseRoll.isEnabled())}isActive(){return this._mouseRotate.isActive()||this._mousePitch.isActive()||this._mouseRoll.isActive()}},I5=class{constructor(e,t,r,i){this._el=e,this._touchZoom=t,this._touchRotate=r,this._tapDragZoom=i,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()}},M5=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=at.create("div","maplibregl-cooperative-gesture-screen",e);let t=this._map._getUIString("CooperativeGesturesHandler.WindowsHelpText");this._bypassKey==="metaKey"&&(t=this._map._getUIString("CooperativeGesturesHandler.MacHelpText"));let r=this._map._getUIString("CooperativeGesturesHandler.MobileHelpText"),i=document.createElement("div");i.className="maplibregl-desktop-message",i.textContent=t,this._container.appendChild(i);let a=document.createElement("div");a.className="maplibregl-mobile-message",a.textContent=r,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 bt("cooperativegestureprevented",{gestureType:e,originalEvent:t})),this._container.classList.add("maplibregl-show"),setTimeout(()=>{this._container.classList.remove("maplibregl-show")},100))}},z5=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(M.convert(e),this._camera.terrain)}};const xo=e=>e.zoom||e.drag||e.roll||e.pitch||e.rotate;var F5=class extends us{};function uh(e){var t;return((t=e.panDelta)==null?void 0:t.mag())||e.zoomDelta||e.bearingDelta||e.pitchDelta||e.rollDelta}var R5=class{get _ownerDocument(){var e;return((e=this._el)==null?void 0:e.ownerDocument)||document}get _ownerWindow(){var e,t;return((t=(e=this._el)==null?void 0:e.ownerDocument)==null?void 0:t.defaultView)||window}constructor(e,t,r){this._terrainGesture={inFlight:!1,anchorElevation:null},this.handleWindowEvent=a=>{this.handleEvent(a,`${a.type}Window`)},this.handleEvent=(a,n)=>{if(a.type==="blur"){this.stop(!0);return}this._updatingCamera=!0;let s=a.type==="renderFrame"?void 0:a,o={needsRenderFrame:!1},l={},u={};for(let{handlerName:d,handler:p,allowed:f}of this._handlers){if(!p.isEnabled())continue;let m;if(this._blockedByActive(u,f,d))p.reset();else if(p[n||a.type]){if(Av(a,n||a.type)){let g=at.mousePos(this._map.getCanvas(),a);m=p[n||a.type](a,g)}else if(Pv(a,n||a.type)){let g=a.touches,_=this._getMapTouches(g),y=at.touchPos(this._map.getCanvas(),_);m=p[n||a.type](a,y,_)}else Cv(n||a.type)||(m=p[n||a.type](a));this.mergeHandlerResult(o,l,m,d,s),m!=null&&m.needsRenderFrame&&this._triggerRenderFrame()}(m||p.isActive())&&(u[d]=p)}let h={};for(let d in this._previousActiveHandlers)u[d]||(h[d]=s);this._previousActiveHandlers=u,(Object.keys(h).length||uh(o))&&(this._changes.push([o,l,h]),this._triggerRenderFrame()),(Object.keys(u).length||uh(o))&&this._camera.stop(!0),this._updatingCamera=!1;let{cameraAnimation:c}=o;c&&(this._inertia.clear(),this._fireEvents({},{},!0),this._changes=[],c(this._map))},this._map=e,this._camera=t,this._transformProvider=new z5(this._camera),this._el=this._map.getCanvasContainer(),this._handlers=[],this._handlersById={},this._changes=[],this._inertia=new a5(e),this._bearingSnap=r.bearingSnap,this._previousActiveHandlers={},this._eventsInProgress={},this._addDefaultHandlers(r);let i=this._el;this._listeners=[[i,"touchstart",{passive:!0}],[i,"touchmove",{passive:!1}],[i,"touchend",void 0],[i,"touchcancel",void 0],[i,"mousedown",void 0],[i,"mousemove",void 0],[i,"mouseup",void 0],[this._ownerDocument,"mousemove",{capture:!0}],[this._ownerDocument,"mouseup",void 0],[i,"mouseover",void 0],[i,"mouseout",void 0],[i,"dblclick",void 0],[i,"click",void 0],[i,"keydown",{capture:!1}],[i,"keyup",void 0],[i,"wheel",{passive:!1}],[i,"contextmenu",void 0],[this._ownerWindow,"blur",void 0]];for(let[a,n,s]of this._listeners)a.addEventListener(n,a===this._ownerDocument?this.handleWindowEvent:this.handleEvent,s)}destroy(){for(let[e,t,r]of this._listeners)e.removeEventListener(t,e===this._ownerDocument?this.handleWindowEvent:this.handleEvent,r)}_addDefaultHandlers(e){let t=this._map,r=t.getCanvasContainer();this._add("mapEvent",new n5(t,e));let i=t.boxZoom=new o5(t,e,this._transformProvider);this._add("boxZoom",i),e.interactive&&e.boxZoom&&i.enable();let a=t.cooperativeGestures=new M5(t,e.cooperativeGestures);this._add("cooperativeGestures",a),e.cooperativeGestures&&a.enable();let n=new h5(t,this._transformProvider),s=new E5(t,this._transformProvider);t.doubleClickZoom=new D5(s,n),this._add("tapZoom",n),this._add("clickZoom",s),e.interactive&&e.doubleClickZoom&&t.doubleClickZoom.enable();let o=new P5;this._add("tapDragZoom",o);let l=t.touchPitch=new v5(t);this._add("touchPitch",l),e.interactive&&e.touchPitch&&t.touchPitch.enable(e.touchPitch);let u=()=>this._camera.transform.centerPoint,h=f5(e,u),c=m5(e),d=g5(e,u);t.dragRotate=new C5(e,h,c,d),this._add("mouseRotate",h,["mousePitch"]),this._add("mousePitch",c,["mouseRotate","mouseRoll"]),this._add("mouseRoll",d,["mousePitch"]),e.interactive&&e.dragRotate&&t.dragRotate.enable();let p=p5(e),f=new _5(e,t);t.dragPan=new A5(r,p,f),this._add("mousePan",p),this._add("touchPan",f,["touchZoom","touchRotate"]),e.interactive&&e.dragPan&&t.dragPan.enable(e.dragPan);let m=new x5,g=new y5;t.touchZoomRotate=new I5(r,g,m,o),this._add("touchRotate",m,["touchPan","touchZoom"]),this._add("touchZoom",g,["touchPan","touchRotate"]),e.interactive&&e.touchZoomRotate&&t.touchZoomRotate.enable(e.touchZoomRotate),this._add("blockableMapEvent",new s5(t,e),["touchPan"]);let _=t.scrollZoom=new S5(t,()=>this._triggerRenderFrame(),this._transformProvider);this._add("scrollZoom",_,["mousePan"]),e.interactive&&e.scrollZoom&&t.scrollZoom.enable(e.scrollZoom);let y=t.keyboard=new w5(t,this._transformProvider);this._add("keyboard",y),e.interactive&&e.keyboard&&t.keyboard.enable()}_add(e,t,r){this._handlers.push({handlerName:e,handler:t,allowed:r}),this._handlersById[e]=t}stop(e){if(!this._updatingCamera){for(let{handler:t}of this._handlers)t.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!!xo(this._eventsInProgress)||this.isZooming()}_blockedByActive(e,t,r){for(let i in e)if(i!==r&&!(t!=null&&t.includes(i)))return!0;return!1}_getMapTouches(e){let t=[];for(let r of e){let i=r.target;this._el.contains(i)&&t.push(r)}return t}mergeHandlerResult(e,t,r,i,a){if(!r)return;H(e,r);let n={handlerName:i,originalEvent:r.originalEvent||a};r.zoomDelta!==void 0&&(t.zoom=n),r.panDelta!==void 0&&(t.drag=n),r.rollDelta!==void 0&&(t.roll=n),r.pitchDelta!==void 0&&(t.pitch=n),r.bearingDelta!==void 0&&(t.rotate=n)}_applyChanges(){let e={},t={},r={};for(let[i,a,n]of this._changes)i.panDelta&&(e.panDelta=(e.panDelta||new M(0,0))._add(i.panDelta)),i.zoomDelta&&(e.zoomDelta=(e.zoomDelta||0)+i.zoomDelta),i.bearingDelta&&(e.bearingDelta=(e.bearingDelta||0)+i.bearingDelta),i.pitchDelta&&(e.pitchDelta=(e.pitchDelta||0)+i.pitchDelta),i.rollDelta&&(e.rollDelta=(e.rollDelta||0)+i.rollDelta),i.around!==void 0&&(e.around=i.around),i.pinchAround!==void 0&&(e.pinchAround=i.pinchAround),i.noInertia&&(e.noInertia=i.noInertia),H(t,a),H(r,n);this._updateMapTransform(e,t,r),this._changes=[]}_updateMapTransform(e,t,r){let i=this._map.terrain;if(!uh(e)){this._fireEvents(t,r,!0);return}let a=this._camera.getTransformForUpdate();this._camera.stop(!0);let{panDelta:n,zoomDelta:s,bearingDelta:o,pitchDelta:l,rollDelta:u}=e,{around:h,aroundOnSurface:c}=this._resolveAround(e,i,a),d=i?this._terrainGestureElevation(i,h,c,a,t):void 0,p={panDelta:n,zoomDelta:s,rollDelta:u,pitchDelta:l,bearingDelta:o,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:i,tr:a,deltasForHelper:p,preZoomAroundLoc:f,combinedEventsInProgress:t,panDelta:n}),this._camera.applyUpdatedTransform(a),this._map._update(),e.noInertia||this._inertia.record(e),this._fireEvents(t,r,!0)}_resolveAround(e,t,r){let i=e.pinchAround===void 0?e.around:e.pinchAround;return i||(i=this._camera.transform.centerPoint),t&&!r.isPointOnMapSurface(i)?{around:r.centerPoint,aroundOnSurface:!1}:{around:i,aroundOnSurface:!0}}_terrainGestureElevation(e,t,r,i,a){if(!r)return;if(this._terrainGesture.anchorElevation===null&&(a.drag||a.zoom)){let s=i.screenTerrainPointToMercatorCoordinate(t,e);this._terrainGesture.anchorElevation=s?s.z:void 0}let n=this._terrainGesture.anchorElevation;if(n!=null&&!(t.distSqr(i.centerPoint)<.01)&&!(n-i.elevation>=.9*(i.getCameraAltitude()-i.elevation)))return n}_computePreZoomAroundLoc(e,t,r,i){if(t.distSqr(e.centerPoint)<.01)return e.center;let a=r?t.sub(r):t;return i===void 0?e.screenPointToLocation(a):e.screenPointToLocationAtElevation(a,i)}_handleMapControls({terrain:e,tr:t,deltasForHelper:r,preZoomAroundLoc:i,combinedEventsInProgress:a,panDelta:n}){let s=this._camera.cameraHelper;if(s.handleMapControlsRollPitchBearingZoom(r,t),!e&&!s.useGlobeControls&&!t.isPointOnMapSurface(r.around)){n&&t.setCenter(t.screenPointToLocation(t.centerPoint.sub(n)));return}if(!e){s.handleMapControlsPan(r,t,i);return}if(!this._terrainGesture.inFlight){this._terrainGesture.inFlight=!0,this._camera.elevationFreeze=!0,s.handleMapControlsPan(r,t,i);return}if(!s.useGlobeControls&&r.aroundElevation===void 0&&a.drag&&n){t.setCenter(t.screenPointToLocation(t.centerPoint.sub(n)));return}s.handleMapControlsPan(r,t,i)}_fireEvents(e,t,r){let i=xo(this._eventsInProgress),a=xo(e),n={};for(let h in e){let{originalEvent:c}=e[h];this._eventsInProgress[h]||(n[`${h}start`]=c),this._eventsInProgress[h]=e[h]}!i&&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:c}=e[h];this._fireEvent(h,c)}let s={},o;for(let h in this._eventsInProgress){let{handlerName:c,originalEvent:d}=this._eventsInProgress[h];this._handlersById[c].isActive()||(delete this._eventsInProgress[h],o=t[c]||d,s[`${h}end`]=o)}for(let h in s)this._fireEvent(h,s[h]);let l=xo(this._eventsInProgress),u=(i||a)&&!l;if(u&&this._terrainGesture.inFlight){this._camera.elevationFreeze=!1,this._terrainGesture={inFlight:!1,anchorElevation:null};let h=this._camera.getTransformForUpdate();this._map.getCenterClampedToGround()&&h.recalculateZoomAndCenter(this._map.terrain),this._camera.applyUpdatedTransform(h)}if(r&&u){this._updatingCamera=!0;let h=this._inertia._onMoveEnd(this._map.dragPan._inertiaOptions),c=d=>d!==0&&-this._bearingSnap<d&&d<this._bearingSnap;h&&(h.essential||!Xt.prefersReducedMotion)?(c(h.bearing||this._map.getBearing())&&(h.bearing=0),h.freezeElevation=!0,this._map.easeTo(h,{originalEvent:o})):(this._fireEvent("moveend",o),c(this._map.getBearing())&&this._map.resetNorth()),this._updatingCamera=!1}}_fireEvent(e,t){this._camera.fire(new J(e,t?{originalEvent:t}:{}))}_requestFrame(){return this._map.triggerRepaint(),this._map._renderTaskQueue.add(e=>{delete this._frameId,this.handleEvent(new F5("renderFrame",{timeStamp:e})),this._applyChanges()})}_triggerRenderFrame(){this._frameId===void 0&&(this._frameId=this._requestFrame())}},k5=class extends kt{constructor(e){super(),this._renderFrameCallback=()=>{let t=Math.min((Fe()-this._easeStart)/this._easeOptions.duration,1);this._onEaseFrame(this._easeOptions.easing(t)),t<1&&this._easeFrameId?this._easeFrameId=this._requestRenderFrame(this._renderFrameCallback):this.stop()},this.transform=new fl,this.cameraHelper=new ml,e.minZoom!==void 0&&this.transform.setMinZoom(e.minZoom),e.maxZoom!==void 0&&this.transform.setMaxZoom(e.maxZoom),e.minPitch!==void 0&&this.transform.setMinPitch(e.minPitch),e.maxPitch!==void 0&&this.transform.setMaxPitch(e.maxPitch),e.renderWorldCopies!==void 0&&this.transform.setRenderWorldCopies(e.renderWorldCopies),e.transformConstrain!==null&&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,this.applyTerrainChange()}migrateProjection(e,t){if(e.apply(this.transform,!0),this.transform=e,this.cameraHelper=t,this._requestedCameraState){let r=e.clone();r.apply(this._requestedCameraState,!0),this._requestedCameraState=r}}getCenter(){return new ee(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,r){return e=M.convert(e).mult(-1),this.panTo(this.transform.center,H({offset:e},t),r)}panTo(e,t,r){return this.easeTo(H({center:e},t),r)}getZoom(){return this.transform.zoom}setZoom(e,t){return this.jumpTo({zoom:e},t),this}zoomTo(e,t,r){return this.easeTo(H({zoom:e},t),r)}zoomIn(e,t){return this.zoomTo(rr(this.getZoom()+1,this._zoomSnap),e,t),this}zoomOut(e,t){return this.zoomTo(rr(this.getZoom()-1,this._zoomSnap),e,t),this}getVerticalFieldOfView(){return this.transform.fov}setVerticalFieldOfView(e,t){return e!=this.transform.fov&&(this.applyTransformChange(r=>r.setFov(e)),this.fire(new J("movestart",t)).fire(new J("move",t)).fire(new J("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,r){return this.easeTo(H({bearing:e},t),r)}resetNorth(e,t){return this.rotateTo(0,H({duration:1e3},e),t),this}resetNorthPitch(e,t){return this.easeTo(H({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=Wr.convert(e).adjustAntiMeridian();let r=(t==null?void 0:t.bearing)||0;return this._cameraForBoxAndBearing(e.getNorthWest(),e.getSouthEast(),r,t)}_cameraForBoxAndBearing(e,t,r,i){let a={top:0,bottom:0,right:0,left:0};if(i=H({padding:a,offset:[0,0],maxZoom:this.transform.maxZoom},i),typeof i.padding=="number"){let u=i.padding;i.padding={top:u,bottom:u,right:u,left:u}}let n=H(a,i.padding);i.padding=n;let s=this.transform,o=new Wr(e,t),l=this.cameraHelper.cameraForBoxAndBearing(i,n,o,r,s);return l&&this._zoomSnap&&(l.zoom=rr(l.zoom,this._zoomSnap,-1)),l}fitBounds(e,t,r){return this._fitInternal(this.cameraForBounds(e,t),t,r)}fitScreenCoordinates(e,t,r,i,a){return this._fitInternal(this._cameraForBoxAndBearing(this.transform.screenPointToLocation(M.convert(e)),this.transform.screenPointToLocation(M.convert(t)),r,i),i,a)}_fitInternal(e,t,r){return e?(t=H(e,t),delete t.padding,t.linear?this.easeTo(t,r):this.flyTo(t,r)):this}jumpTo(e,t){this.stop(),e.zoom!==void 0&&this._zoomSnap&&(e.zoom=rr(e.zoom,this._zoomSnap));let r=this.getTransformForUpdate(),i=!1,a=!1,n=!1,s=r.zoom;this.terrain&&r.setElevation(this.terrain.getElevationForLngLat(e.center?ee.convert(e.center):r.center,r)),this.cameraHelper.handleJumpToCenterZoom(r,e);let o=r.zoom!==s;return e.elevation!==void 0&&r.elevation!==+e.elevation&&r.setElevation(+e.elevation),e.bearing!==void 0&&r.bearing!==+e.bearing&&(i=!0,r.setBearing(+e.bearing)),e.pitch!==void 0&&r.pitch!==+e.pitch&&(a=!0,r.setPitch(+e.pitch)),e.roll!==void 0&&r.roll!==+e.roll&&(n=!0,r.setRoll(+e.roll)),e.padding!=null&&!r.isPaddingEqual(e.padding)&&r.setPadding(e.padding),this.applyUpdatedTransform(r),this.fire(new J("movestart",t)).fire(new J("move",t)),o&&this.fire(new J("zoomstart",t)).fire(new J("zoom",t)).fire(new J("zoomend",t)),i&&this.fire(new J("rotatestart",t)).fire(new J("rotate",t)).fire(new J("rotateend",t)),a&&this.fire(new J("pitchstart",t)).fire(new J("pitch",t)).fire(new J("pitchend",t)),n&&this.fire(new J("rollstart",t)).fire(new J("roll",t)).fire(new J("rollend",t)),this.fire(new J("moveend",t))}calculateAnchoredCameraOptions(e){var n;let t=this.transform.clone(),r=ee.convert(e.anchorLocation),i=M.convert(e.anchorScreenPoint),a={panDelta:i.sub(this.transform.locationToScreenPoint(r,this.terrain)),zoomDelta:e.zoom===void 0?0:e.zoom-t.zoom,bearingDelta:0,pitchDelta:0,rollDelta:0,around:i,aroundElevation:(n=this.terrain)==null?void 0:n.getElevationForLngLat(r,t)};return this.cameraHelper.handleMapControlsRollPitchBearingZoom(a,t),this.cameraHelper.handleMapControlsPan(a,t,r),{center:t.center,zoom:t.zoom}}calculateCameraOptionsFromCameraLngLatAltRotation(e,t,r,i,a){let n=this.transform.calculateCenterFromCameraLngLatAlt(e,t,r,i);return{center:n.center,elevation:n.elevation,zoom:n.zoom,bearing:r,pitch:i,roll:a}}easeTo(e,t){this._stop(!1,e.easeId),e=H({offset:[0,0],duration:500,easing:gh},e),e.zoom!==void 0&&this._zoomSnap&&(e.zoom=rr(e.zoom,this._zoomSnap)),(e.animate===!1||!e.essential&&Xt.prefersReducedMotion)&&(e.duration=0);let r=this.getTransformForUpdate(),i=this.getBearing(),a=r.pitch,n=r.roll,s=e.bearing===void 0?i:this._normalizeBearing(e.bearing,i),o=e.pitch===void 0?a:+e.pitch,l=e.roll===void 0?n:this._normalizeBearing(e.roll,n),u=e.padding===void 0?r.padding:e.padding,h=M.convert(e.offset),c,d;e.around&&(c=ee.convert(e.around),d=r.locationToScreenPoint(c));let p={moving:this._moving,zooming:this._zooming,rotating:this._rotating,pitching:this._pitching,rolling:this._rolling},f=this.cameraHelper.handleEaseTo(r,{bearing:s,pitch:o,roll:l,padding:u,around:c,aroundPoint:d,offsetAsPoint:h,offset:e.offset,zoom:e.zoom,center:e.center});return this._rotating||(this._rotating=i!==s),this._pitching||(this._pitching=o!==a),this._rolling||(this._rolling=l!==n),this._padding=!r.isPaddingEqual(u),this._zooming||(this._zooming=f.isZooming),this._easeId=e.easeId,this._prepareEase(t,e.noMoveStart,p),this.terrain&&this._prepareElevation(f.elevationCenter,r),this._ease(m=>{f.easeFunc(m),this.terrain&&!e.freezeElevation&&this._updateElevation(m,r),this.applyUpdatedTransform(r),this._fireMoveEvents(t)},m=>{this.terrain&&e.freezeElevation?this._finalizeElevation():this.elevationFreeze=!1,this._afterEase(t,m)},e),this}_prepareEase(e,t,r={}){this._moving=!0,!t&&!r.moving&&this.fire(new J("movestart",e)),this._zooming&&!r.zooming&&this.fire(new J("zoomstart",e)),this._rotating&&!r.rotating&&this.fire(new J("rotatestart",e)),this._pitching&&!r.pitching&&this.fire(new J("pitchstart",e)),this._rolling&&!r.rolling&&this.fire(new J("rollstart",e))}_prepareElevation(e,t){this._elevationCenter=e,this._elevationStart=t.elevation,this._elevationTarget=this.terrain.getElevationForLngLat(e,t),this.elevationFreeze=!0}_updateElevation(e,t){(this._elevationStart===void 0||this._elevationCenter===void 0)&&this._prepareElevation(t.center,t),t.setMinElevationForCurrentTile(this.terrain.getMinTileElevationForLngLatZoom(this._elevationCenter,t.tileZoom));let r=this.terrain.getElevationForLngLat(this._elevationCenter,t);if(e<1&&r!==this._elevationTarget){let i=this._elevationTarget-this._elevationStart,a=(r-(i*e+this._elevationStart))/(1-e);this._elevationStart+=e*(i-a),this._elevationTarget=r}t.setElevation(We.number(this._elevationStart,this._elevationTarget,e))}_finalizeElevation(){this.elevationFreeze=!1,this.getCenterClampedToGround()&&this.transform.recalculateZoomAndCenter(this.terrain)}applyTerrainChange(){if(this.elevationFreeze)return;let e=this.transform;e.setMinElevationForCurrentTile(this.terrain?this.terrain.getMinTileElevationForLngLatZoom(e.center,e.tileZoom):0),this.getCenterClampedToGround()&&e.setElevation(this.terrain?this.terrain.getElevationForLngLat(e.center,e):0)}getTransformForUpdate(){return!this.transformCameraUpdate&&!this.terrain?this.transform:(this._requestedCameraState||(this._requestedCameraState=this.transform.clone()),this._requestedCameraState)}_elevateCameraIfInsideTerrain(e){if(!this.terrain&&e.elevation>=0&&e.pitch<=90)return{};let t=e.getCameraLngLat(),r=e.getCameraAltitude(),i=this.terrain?this.terrain.getElevationForLngLatZoom(t,e.zoom):0;if(r<i){let a=e.calculateCameraOptionsFromTo(t,i,e.center,e.elevation);return{pitch:a.pitch,zoom:a.zoom}}return{}}applyUpdatedTransform(e){let t=[];if(t.push(i=>this._elevateCameraIfInsideTerrain(i)),this.transformCameraUpdate&&t.push(i=>this.transformCameraUpdate(i)),!t.length)return;let r=e.clone();for(let i of t){let a=r.clone(),{center:n,zoom:s,roll:o,pitch:l,bearing:u,elevation:h}=i(a);n&&a.setCenter(n),h!==void 0&&a.setElevation(h),s!==void 0&&a.setZoom(s),o!==void 0&&a.setRoll(o),l!==void 0&&a.setPitch(l),u!==void 0&&a.setBearing(u),r.apply(a,!1)}this.transform.apply(r,!1)}applyTransformChange(e){let t=this._requestedCameraState!==void 0,r=this.getTransformForUpdate();e(r),this.applyUpdatedTransform(r),t||delete this._requestedCameraState}_fireMoveEvents(e){this.fire(new J("move",e)),this._zooming&&this.fire(new J("zoom",e)),this._rotating&&this.fire(new J("rotate",e)),this._pitching&&this.fire(new J("pitch",e)),this._rolling&&this.fire(new J("roll",e))}_afterEase(e,t){if(this._easeId&&t&&this._easeId===t)return;delete this._easeId;let r=this._zooming,i=this._rotating,a=this._pitching,n=this._rolling;this._moving=!1,this._zooming=!1,this._rotating=!1,this._pitching=!1,this._rolling=!1,this._padding=!1,r&&this.fire(new J("zoomend",e)),i&&this.fire(new J("rotateend",e)),a&&this.fire(new J("pitchend",e)),n&&this.fire(new J("rollend",e)),this.fire(new J("moveend",e))}flyTo(e,t){if(!e.essential&&Xt.prefersReducedMotion){let T=os(e,["center","zoom","bearing","pitch","roll","elevation","padding"]);return this.jumpTo(T,t)}this.stop(),e=H({offset:[0,0],speed:1.2,curve:1.42,easing:gh},e),e.zoom!==void 0&&this._zoomSnap&&(e.zoom=rr(e.zoom,this._zoomSnap));let r=this.getTransformForUpdate(),i=r.bearing,a=r.pitch,n=r.roll,s=r.padding,o=e.bearing===void 0?i:this._normalizeBearing(e.bearing,i),l=e.pitch===void 0?a:+e.pitch,u=e.roll===void 0?n:this._normalizeBearing(e.roll,n),h=e.padding===void 0?r.padding:e.padding,c=M.convert(e.offset),d=r.centerPoint.add(c),p=r.screenPointToLocation(d),f=this.cameraHelper.handleFlyTo(r,{bearing:o,pitch:l,roll:u,padding:h,locationAtOffset:p,offsetAsPoint:c,center:e.center,minZoom:e.minZoom,zoom:e.zoom}),m=e.curve,g=Math.max(r.width,r.height),_=g/f.scaleOfZoom,y=f.pixelPathLength,v=g/f.scaleOfMinZoom;m=Math.min(m,Math.sqrt(v/y*2));let x=m*m;function w(T){let E=(_*_-g*g+(T?-1:1)*x*x*y*y)/(2*(T?_:g)*x*y);return Math.log(Math.sqrt(E*E+1)-E)}function b(T){return(Math.exp(T)-Math.exp(-T))/2}function S(T){return(Math.exp(T)+Math.exp(-T))/2}function A(T){return b(T)/S(T)}let P=w(!1),I=function(T){return S(P)/S(P+m*T)},R=function(T){return g*((S(P)*A(P+m*T)-b(P))/x)/y},F=(w(!0)-P)/m;if(Math.abs(y)<2e-6||!isFinite(F)){if(Math.abs(g-_)<1e-6)return this.easeTo(e,t);let T=_<g?-1:1;F=Math.abs(Math.log(_/g))/m,R=()=>0,I=E=>Math.exp(T*m*E)}if(e.duration!==void 0)e.duration=+e.duration;else{let T=e.screenSpeed===void 0?+e.speed:+e.screenSpeed/m;e.duration=1e3*F/T}return e.maxDuration&&e.duration>e.maxDuration&&(e.duration=0),this._zooming=!0,this._rotating=i!==o,this._pitching=l!==a,this._rolling=u!==n,this._padding=!r.isPaddingEqual(h),this._prepareEase(t,!1),this.terrain&&this._prepareElevation(f.targetCenter,r),this._ease(T=>{let E=T*F,D=1/I(E),C=R(E);this._rotating&&r.setBearing(We.number(i,o,T)),this._pitching&&r.setPitch(We.number(a,l,T)),this._rolling&&r.setRoll(We.number(n,u,T)),this._padding&&(r.interpolatePadding(s,h,T),d=r.centerPoint.add(c)),f.easeFunc(T,D,C,d),this.terrain&&!e.freezeElevation&&this._updateElevation(T,r),this.applyUpdatedTransform(r),this._fireMoveEvents(t)},()=>{this.terrain&&e.freezeElevation?this._finalizeElevation():this.elevationFreeze=!1,this._afterEase(t)},e),this}isEasing(){return!!this._easeFrameId}stop(e){return this._stop(e)}_stop(e,t){if(this._easeFrameId&&(this._cancelRenderFrame(this._easeFrameId),delete this._easeFrameId,delete this._onEaseFrame),this._onEaseEnd){let r=this._onEaseEnd;delete this._onEaseEnd,r.call(this,t)}return e||this._stopHandlers(),this}_ease(e,t,r){r.animate===!1||r.duration===0?(e(1),t()):(this._easeStart=Fe(),this._easeOptions=r,this._onEaseFrame=e,this._onEaseEnd=t,this._easeFrameId=this._requestRenderFrame(this._renderFrameCallback))}_normalizeBearing(e,t){e=fr(e,-180,180);let r=Math.abs(e-t);return Math.abs(e-360-t)<r&&(e-=360),Math.abs(e+360-t)<r&&(e+=360),e}isMoving(){return this._moving}isZooming(){return this._zooming}isRotating(){return this._rotating}};const Tx={compact:!0,customAttribution:'<a href="https://maplibre.org/" target="_blank">MapLibre</a>'};var L5=class{constructor(e=Tx){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=t=>{t&&(t.type==="terrain"||t.dataType==="style"||t.dataType==="source"&&(t.sourceDataType==="metadata"||t.sourceDataType==="visibility"))&&this._updateAttributions()},this._updateCompact=()=>{this._map.getCanvasContainer().offsetWidth<=640||this._compact?this._compact===!1?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=at.create("details","maplibregl-ctrl maplibregl-ctrl-attrib"),this._compactButton=at.create("summary","maplibregl-ctrl-attrib-button",this._container),this._compactButton.addEventListener("click",this._toggleAttribution),this._setElementTitle(this._compactButton,"ToggleAttribution"),this._innerContainer=at.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 r=this._map._getUIString(`AttributionControl.${t}`);e.title=r,e.setAttribute("aria-label",r)}_updateAttributions(){if(!this._map.style)return;let e=[];if(this.options.customAttribution&&(Array.isArray(this.options.customAttribution)?e=e.concat(this.options.customAttribution.map(i=>typeof i=="string"?i:"")):typeof this.options.customAttribution=="string"&&e.push(this.options.customAttribution)),this._map.style.stylesheet){let i=this._map.style.stylesheet;this.styleOwner=i.owner,this.styleId=i.id}let t=this._map.style.tileManagers;for(let i in t){let a=t[i];if(a.used||a.usedForTerrain){let n=a.getSource();n.attribution&&!e.includes(n.attribution)&&e.push(n.attribution)}}e=e.filter(i=>String(i).trim()),e.sort((i,a)=>i.length-a.length),e=e.filter((i,a)=>{for(let n=a+1;n<e.length;n++)if(e[n].includes(i))return!1;return!0});let r=e.join(" | ");r!==this._attribHTML&&(this._attribHTML=r,e.length?(this._innerContainer.replaceChildren(at.sanitize(r)),this._container.classList.remove("maplibregl-attrib-empty")):this._container.classList.add("maplibregl-attrib-empty"),this._updateCompact(),this._editLink=null)}},B5=class{constructor(e={}){this._updateCompact=()=>{let t=this._container.children;if(t.length){let r=t[0];this._map.getCanvasContainer().offsetWidth<=640||this._compact?this._compact!==!1&&r.classList.add("maplibregl-compact"):r.classList.remove("maplibregl-compact")}},this.options=e}getDefaultPosition(){return"bottom-left"}onAdd(e){var r;this._map=e,this._compact=(r=this.options)==null?void 0:r.compact,this._container=at.create("div","maplibregl-ctrl");let t=at.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}},O5=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,r=t?this._queue.concat(t):this._queue;for(let i of r)if(i.id===e){i.cancelled=!0;return}}run(e=0){if(this._currentlyRunning)throw Error("Attempting to run(), but is already running.");let t=this._currentlyRunning=this._queue;this._queue=[];let r=!1,i;for(let a of t)if(!a.cancelled){try{a.callback(e)}catch(n){r||(r=!0,i=n)}if(this._cleared)break}if(this._cleared=!1,this._currentlyRunning=!1,r)throw i}clear(){this._currentlyRunning&&(this._cleared=!0),this._queue=[]}};const Rg=["none","zoom","sourceTiles","visibleLayers","revision"];var $5=class{constructor(e,t,r,i){this._tileKeys=e.map(a=>a.key).sort().join(),this._revision=t,this._zoom=r,this._visibleLayerIds=i}difference(e){return this._revision===(e==null?void 0:e._revision)?this._visibleLayerIds===e._visibleLayerIds?this._tileKeys===e._tileKeys?this._zoom===e._zoom?"none":"zoom":"sourceTiles":"visibleLayers":"revision"}};const va={background:!0,fill:!0,line:!0,raster:!0,hillshade:!0,"color-relief":!0};var j5=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){let r=t!==this._lastPrepareZoom;this._lastPrepareZoom=t,this._stacks=[],this._prevType=null,this._rttTiles=[],this._renderableTiles=this.terrain.tileManager.getRenderableTiles(),this._renderableLayerIds=e._order.filter(o=>!e._layers[o].isHidden(t));let i=this._renderableLayerIds.join(),a=new Set;for(let o of this._renderableLayerIds){let l=e._layers[o],u=l.source;u&&va[l.type]&&a.add(u)}this._coordsAscending={},this._rttFingerprints={};for(let o of a){let l=e.tileManagers[o];if(!l)continue;this._coordsAscending[o]={};let u=this._coordsAscending[o],h=l.getSource(),c=h instanceof ws?h.terrainTileRanges:null;for(let f of l.getVisibleCoordinates()){let m=this.terrain.tileManager.getTerrainCoords(f,c);for(let g in m)u[g]||(u[g]=[]),u[g].push(m[g])}this._rttFingerprints[o]={};let d=this._rttFingerprints[o],p=l.getState().revision;for(let f in u)d[f]=new $5(u[f],p,t,i)}this.needsFollowUpFrame=!1;let n=r||this.painter.options.moving,s=!1;for(let o of this._renderableTiles){let l=this._textureDifference(o);l!=="none"&&(l==="zoom"&&n||l==="visibleLayers"&&r?this.needsFollowUpFrame=!0:l==="zoom"||l==="sourceTiles"?(s?this.needsFollowUpFrame=!0:o.releaseRTT(this.painter),s=!0):o.releaseRTT(this.painter))}}_textureDifference(e){let t="none";for(let r in this._rttFingerprints){let i=this._rttFingerprints[r][e.tileID.key];if(!i)continue;let a=i.difference(e.rttFingerprint[r]);Rg.indexOf(a)>Rg.indexOf(t)&&(t=a)}return t}renderLayer(e,t){if(e.isHidden(this.painter.transform.zoom))return!1;let r=e.type,i=this.painter,a=this._renderableLayerIds[this._renderableLayerIds.length-1]===e.id;if(va[r]&&((!this._prevType||!va[this._prevType])&&this._stacks.push([]),this._prevType=r,this._stacks[this._stacks.length-1].push(e.id),!a))return!0;if(va[this._prevType]||va[r]&&a){this._prevType=r;let n=this._stacks.length-1,s=this._stacks[n]||[];t.isRenderingToTexture=!0;for(let o of this._renderableTiles){if(this._rttTiles.push(o),o.getRTT(n))continue;let l=o.acquireRTT(i,n,this.rttSize);i.bindRTT(l),i.context.clear({color:oe.transparent,stencil:0}),i.currentStencilSource=void 0;for(let u of s){let h=i.style._layers[u],c=h.source?this._coordsAscending[h.source][o.tileID.key]:[o.tileID];i.context.viewport.set([0,0,this.rttSize,this.rttSize]),i.renderTileClippingMasks(h,c),i.renderLayer(i,i.style.tileManagers[h.source],h,c,t),h.source&&(o.rttFingerprint[h.source]=this._rttFingerprints[h.source][o.tileID.key])}l.texture.generateMipmap()}return t.isRenderingToTexture=!1,qF(this.painter,this.terrain,this._rttTiles,t),this._rttTiles=[],va[r]}return!1}};const V5={"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"},N5=dC,kg={hash:!1,interactive:!0,bearingSnap:7,zoomSnap:0,attributionControl:Tx,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:Yi.MAX_TILE_CACHE_ZOOM_LEVELS,transformRequest:null,transformCameraUpdate:null,transformConstrain:null,fadeDuration:300,crossSourceCollisions:!0,clickTolerance:3,localIdeographFontFamily:"sans-serif",pitchWithRotate:!0,rollEnabled:!1,rotateSpeed:.8,pitchSpeed:-.5,reduceMotion:void 0,validateStyle:!0,maxCanvasSize:[4096,4096],cancelPendingTileRequestsWhileZooming:!0,centerClampedToGround:!0,terrainSkirtLength:"auto",zoomLevelsToOverscale:4,anisotropicFilterPitch:20};var U5=class extends kt{get _ownerWindow(){var e,t;return((t=(e=this._container)==null?void 0:e.ownerDocument)==null?void 0:t.defaultView)||window}constructor(e){var a,n,s;super(),this._idleTriggered=!1,this._crossFadingFactor=1,this._renderTaskQueue=new O5,this._controls=[],this._mapId=Ug(),this._styleUrl=null,this._missingStyleImageResolver=null,this._lostContextStyle={style:null,images:null},this._contextLost=o=>{if(o.preventDefault(),this._frameRequest&&(this._frameRequest=(this._frameRequest.abort(),null)),this.painter.destroy(),this._lostContextStyle=this._getStyleAndImages(),!this.style){this.fire(new Wu("webglcontextlost",{originalEvent:o}));return}for(let l of Object.values(this.style._layers))if(l.type==="custom"&&console.warn(`Custom layer with id '${l.id}' cannot be restored after WebGL context loss. You will need to re-add it manually after context restoration.`),l._listeners)for(let[u]of Object.entries(l._listeners))console.warn(`Custom layer with id '${l.id}' had event listeners for event '${u}' which cannot be restored after WebGL context loss. You will need to re-add them manually after context restoration.`);this.style.destroy(),this.style=null,this.fire(new Wu("webglcontextlost",{originalEvent:o}))},this._contextRestored=o=>{if(this._lostContextStyle.style&&this.setStyle(this._lostContextStyle.style,{diff:!1}),this._lostContextStyle.images&&this.style){this.style.imageManager.images=this._lostContextStyle.images;for(let l in this._lostContextStyle.images){let u=this._lostContextStyle.images[l];u.isWebGLImage&&this.style.imageManager.updateImage(l,u,!1)}}this._lostContextStyle={style:null,images:null};try{this._setupPainter()}catch(l){this.fire(new Y(l));return}this.resize(),this._update(),this._resizeInternal(),this.fire(new Wu("webglcontextrestored",{originalEvent:o}))},this._onMapScroll=o=>{if(o.target===this._container)return this._container.scrollTop=0,this._container.scrollLeft=0,!1},this._onWindowOnline=()=>{this._update()};let t={...kg,...e,canvasContextAttributes:{...kg.canvasContextAttributes,...e.canvasContextAttributes}};if(t.minZoom!=null&&t.maxZoom!=null&&t.minZoom>t.maxZoom)throw Error("maxZoom must be greater than or equal to minZoom");if(t.minPitch!=null&&t.maxPitch!=null&&t.minPitch>t.maxPitch)throw Error("maxPitch must be greater than or equal to minPitch");if(t.minPitch!=null&&t.minPitch<0)throw Error("minPitch must be greater than or equal to 0");if(t.maxPitch!=null&&t.maxPitch>180)throw Error("maxPitch must be less than or equal to 180");this._camera=new k5({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:o=>this._requestRenderFrame(o),cancelRenderFrame:o=>this._cancelRenderFrame(o),transformCameraUpdate:t.transformCameraUpdate,stopHandlers:()=>{var o;return(o=this._handlers)==null?void 0:o.stop(!1)}}),this._camera.setEventedParent(this),this._interactive=t.interactive,this._maxTileCacheSize=t.maxTileCacheSize,this._maxTileCacheZoomLevels=t.maxTileCacheZoomLevels,this._canvasContextAttributes={...t.canvasContextAttributes},this._trackResize=t.trackResize===!0,this._terrainSkirtLength=t.terrainSkirtLength,this._refreshExpiredTiles=t.refreshExpiredTiles===!0,this._fadeDuration=t.fadeDuration,this._crossSourceCollisions=t.crossSourceCollisions===!0,this._collectResourceTiming=t.collectResourceTiming===!0,this._locale={...V5,...t.locale},this._clickTolerance=t.clickTolerance,this._overridePixelRatio=t.pixelRatio,this._maxCanvasSize=t.maxCanvasSize,this._zoomLevelsToOverscale=t.zoomLevelsToOverscale,this.cancelPendingTileRequestsWhileZooming=t.cancelPendingTileRequestsWhileZooming===!0,this.setAnisotropicFilterPitch(t.anisotropicFilterPitch),t.reduceMotion!==void 0&&(Xt.prefersReducedMotion=t.reduceMotion),this._requestManager=new bC(t.transformRequest),this._container=this._resolveContainer(t.container),t.maxBounds&&this.setMaxBounds(t.maxBounds),this._setupContainer();try{this._setupPainter()}catch(o){throw this._cleanupContainer(),o}this._imageQueueHandle=Ur.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 R5(this,this._camera,t),typeof window<"u"&&(this._ownerWindow.addEventListener("online",this._onWindowOnline,!1),this._setupResizeObserver());let r=typeof t.hash=="string"&&t.hash||void 0;this._hash=t.hash?new JF(r).addTo(this):void 0,(a=this._hash)!=null&&a._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,H({},t.fitBoundsOptions,{duration:0}))));let i=typeof t.style=="string"||((s=(n=t.style)==null?void 0:n.projection)==null?void 0:s.type)!=="globe";this.resize(null,i),this._localIdeographFontFamily=t.localIdeographFontFamily,this._validateStyle=t.validateStyle,t.style&&this.setStyle(t.style,{localIdeographFontFamily:t.localIdeographFontFamily}),t.attributionControl&&this.addControl(new L5(typeof t.attributionControl=="boolean"?void 0:t.attributionControl)),t.maplibreLogo&&this.addControl(new B5,t.logoPosition),this.on("style.load",()=>{if(i||this._resizeTransform(),this._camera.transform.unmodified){let o=os(this.style.stylesheet,["center","zoom","bearing","pitch","roll"]);this.jumpTo(o)}}),this.on("data",o=>{this._update(o.dataType==="style"),this.fire(o.dataType==="style"?new Tr("styledata",o):new Ne("sourcedata",o))}),this.on("dataloading",o=>{this.fire(o.dataType==="style"?new Tr("styledataloading",o):new Ne("sourcedataloading",o))}),this.on("dataabort",o=>{this.fire(new Ne("sourcedataabort",o))})}_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(t===void 0&&(t=e.getDefaultPosition?e.getDefaultPosition():"top-right"),!(e!=null&&e.onAdd))return this.fire(new Y(Error("Invalid argument to map.addControl(). Argument must be a control with onAdd and onRemove methods.")));let r=e.onAdd(this);this._controls.push(e);let i=this._controlPositions[t];return t.includes("bottom")?i.insertBefore(r,i.firstChild):i.appendChild(r),this}removeControl(e){if(!(e!=null&&e.onRemove))return this.fire(new Y(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 en(this._camera.transform,e)}setTransformCameraUpdate(e){this._camera.transformCameraUpdate=e}getCenter(){return new ee(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,r){return this._camera.panBy(e,t,r),this}panTo(e,t,r){return this._camera.panTo(e,t,r),this}getZoom(){return this._camera.transform.zoom}setZoom(e,t){return this._camera.setZoom(e,t),this}zoomTo(e,t,r){return this._camera.zoomTo(e,t,r),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,r){return this._camera.rotateTo(e,t,r),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,r){return this._camera.fitBounds(e,t,r),this}fitScreenCoordinates(e,t,r,i,a){return this._camera.fitScreenCoordinates(e,t,r,i,a),this}jumpTo(e,t){return this._camera.jumpTo(e,t),this}calculateAnchoredCameraOptions(e){return this._camera.calculateAnchoredCameraOptions(e)}calculateCameraOptionsFromCameraLngLatAltRotation(e,t,r,i,a){return this._camera.calculateCameraOptionsFromCameraLngLatAltRotation(e,t,r,i,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(ee.convert(e),this._camera.transform):null}getCenterClampedToGround(){return this._camera.getCenterClampedToGround()}calculateCameraOptionsFromTo(e,t,r,i){return i==null&&this.terrain&&(i=this.terrain.getElevationForLngLat(r,this._camera.transform)),this._camera.transform.calculateCameraOptionsFromTo(e,t,r,i??0)}resize(e,t=!0){if(this._lostContextStyle.style!==null)return this;this._resizeInternal(t);let r=!this._camera._moving;return r&&(this.stop(),this.fire(new J("movestart",e)).fire(new J("move",e))),this.fire(new bt("resize",e)),r&&this.fire(new J("moveend",e)),this}_resizeInternal(e=!0){let[t,r]=this._containerDimensions(),i=this._getClampedPixelRatio(t,r);if(this._resizeCanvas(t,r,i),this.painter.resize(t,r,i),this.painter.overLimit()){let a=this.painter.context.gl;this._maxCanvasSize=[a.drawingBufferWidth,a.drawingBufferHeight];let n=this._getClampedPixelRatio(t,r);this._resizeCanvas(t,r,n),this.painter.resize(t,r,n)}this._resizeTransform(e)}_resizeTransform(e=!0){var i;let[t,r]=this._containerDimensions();this._camera.transform.resize(t,r,e),(i=this._camera._requestedCameraState)==null||i.resize(t,r,e)}_getClampedPixelRatio(e,t){let{0:r,1:i}=this._maxCanvasSize,a=this.getPixelRatio(),n=e*a,s=t*a,o=n>r?r/n:1,l=s>i?i/s:1,u=Math.min(o,l);return u<1&&_e("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(Wr.convert(e))),this._update()}setMinZoom(e){if(e??(e=-2),e>=-2&&e<=this._camera.transform.maxZoom){let t=this._camera.transform.zoom;return this._camera.applyTransformChange(r=>r.setMinZoom(e)),this._update(),t!==this._camera.transform.zoom&&this.fire(new J("zoomstart")).fire(new J("zoom")).fire(new J("zoomend")).fire(new J("movestart")).fire(new J("move")).fire(new J("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??(e=22),e>=this._camera.transform.minZoom){let t=this._camera.transform.zoom;return this._camera.applyTransformChange(r=>r.setMaxZoom(e)),this._update(),t!==this._camera.transform.zoom&&this.fire(new J("zoomstart")).fire(new J("zoom")).fire(new J("zoomend")).fire(new J("movestart")).fire(new J("move")).fire(new J("moveend")),this}throw Error("maxZoom must be greater than the current minZoom")}getMaxZoom(){return this._camera.transform.maxZoom}setMinPitch(e){if(e??(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(r=>r.setMinPitch(e)),this._update(),t!==this._camera.transform.pitch&&this.fire(new J("pitchstart")).fire(new J("pitch")).fire(new J("pitchend")).fire(new J("movestart")).fire(new J("move")).fire(new J("moveend")),this}throw Error("minPitch must be between 0 and the current maxPitch, inclusive")}getMinPitch(){return this._camera.transform.minPitch}setMaxPitch(e){if(e??(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(r=>r.setMaxPitch(e)),this._update(),t!==this._camera.transform.pitch&&this.fire(new J("pitchstart")).fire(new J("pitch")).fire(new J("pitchend")).fire(new J("movestart")).fire(new J("move")).fire(new J("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??(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(ee.convert(e),this.style&&this.terrain)}unproject(e){return this._camera.transform.screenPointToLocation(M.convert(e),this.terrain)}isMoving(){var e;return this._camera.isMoving()||((e=this._handlers)==null?void 0:e.isMoving())||!1}isZooming(){var e;return this._camera.isZooming()||((e=this._handlers)==null?void 0:e.isZooming())||!1}isRotating(){var e;return this._camera.isRotating()||((e=this._handlers)==null?void 0:e.isRotating())||!1}_createDelegates(e,t,r){if(e==="mouseenter"||e==="mouseover"){let i=!1;return{mousemove:a=>{let n=t.filter(o=>this.getLayer(o)),s=n.length===0?[]:this.queryRenderedFeatures(a.point,{layers:n});s.length?i||(i=!0,r.call(this,new ir(e,this,a.originalEvent,{features:s}))):i=!1},mouseout:()=>{i=!1}}}if(e==="mouseleave"||e==="mouseout"){let i=!1;return{mousemove:a=>{let n=t.filter(s=>this.getLayer(s));(n.length===0?[]:this.queryRenderedFeatures(a.point,{layers:n})).length?i=!0:i&&(i=!1,r.call(this,new ir(e,this,a.originalEvent)))},mouseout:a=>{i&&(i=!1,r.call(this,new ir(e,this,a.originalEvent)))}}}{let i=a=>{let n=t.filter(o=>this.getLayer(o)),s=n.length===0?[]:this.queryRenderedFeatures(a.point,{layers:n});s.length&&(a.features=s,r.call(this,a),delete a.features)};return{[e]:i}}}_addDelegatedListener(e,t){var r;this._delegatedListeners||(this._delegatedListeners={}),(r=this._delegatedListeners)[e]||(r[e]=[]),this._delegatedListeners[e].push(t);for(let i in t.delegates)this.on(i,t.delegates[i])}_removeDelegatedListener(e,t,r){var a;if(!((a=this._delegatedListeners)!=null&&a[e]))return;let i=this._delegatedListeners[e];for(let n=0;n<i.length;n++){let s=i[n];if(s.listener===r&&s.layers.length===t.length&&s.layers.every(o=>t.includes(o))){for(let o in s.delegates)this.off(o,s.delegates[o]);i.splice(n,1);return}}}on(e,t,r){if(r===void 0)return super.on(e,t);let i=typeof t=="string"?[t]:t,a={layers:i,listener:r,delegates:this._createDelegates(e,i,r)};return this._addDelegatedListener(e,a),{unsubscribe:()=>{this._removeDelegatedListener(e,i,r)}}}once(e,t,r){if(r===void 0)return super.once(e,t);let i=typeof t=="string"?[t]:t,a={layers:i,listener:r,delegates:this._createDelegates(e,i,n=>{this._removeDelegatedListener(e,i,r),r.call(this,n)})};return this._addDelegatedListener(e,a),this}off(e,t,r){if(r===void 0)return super.off(e,t);let i=typeof t=="string"?[t]:t;return this._removeDelegatedListener(e,i,r),this}queryRenderedFeatures(e,t){if(!this.style)return[];let r,i=e instanceof M||Array.isArray(e),a=i?e:[[0,0],[this._camera.transform.width,this._camera.transform.height]];if(t||(t=(i?{}:e)||{}),a instanceof M||typeof a[0]=="number")r=[M.convert(a)];else{let n=M.convert(a[0]),s=M.convert(a[1]);r=[n,new M(s.x,n.y),s,new M(n.x,s.y),n]}return this.style.queryRenderedFeatures(r,t,this._camera.transform)}querySourceFeatures(e,t){return this.style.querySourceFeatures(e,t)}setStyle(e,t){return t=H({},{localIdeographFontFamily:this._localIdeographFontFamily,validate:this._validateStyle},t),this._styleUrl=typeof e=="string"?e:null,t.diff!==!1&&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(t==null)throw Error(`Missing UI string '${e}'`);return t}_updateStyle(e,t){var i,a,n;if((i=this._diffStyleRequest)==null||i.abort(),this._diffStyleRequest=null,t.transformStyle&&this.style&&!this.style._loaded){this.style.once("style.load",()=>this._updateStyle(e,t));return}let r=this.style&&t.transformStyle?this.style.serialize():void 0;if(this.style&&(this.style.setEventedParent(null),this.style._remove(!e)),e)this.style=new _g(this,t||{});else return this._frameRequest&&(this._frameRequest=(this._frameRequest.abort(),null)),(n=(a=this.style)==null?void 0:a.projection)==null||n.destroy(),delete this.style,this;return this.style.setEventedParent(this,{style:this.style}),typeof e=="string"?this.style.loadURL(e,t,r):this.style.loadJSON(e,t,r),this}_lazyInitEmptyStyle(){this.style||(this.style=new _g(this,{}),this.style.setEventedParent(this,{style:this.style}),this.style.loadEmpty())}async _diffStyle(e,t){var r;if((r=this._diffStyleRequest)==null||r.abort(),typeof e=="string"){let i=e;this._diffStyleRequest=new AbortController;let a=this._diffStyleRequest;try{let n=await this._requestManager.transformRequest(i,"Style");if(a.signal.aborted){this._diffStyleRequest=null;return}let s=await xl(n,a);this._diffStyleRequest=null,this._updateDiff(s.data,t)}catch(n){this._diffStyleRequest=null,Si(n)||this.fire(new Y(zt(n)))}}else typeof e=="object"&&(this._diffStyleRequest=null,this._updateDiff(e,t))}_updateDiff(e,t){try{this.style.setState(e,t)&&this._update(!0)}catch(r){_e(`Unable to perform style diff: ${zt(r).message}. Rebuilding the style from scratch.`),this._updateStyle(e,t)}}getStyle(){if(this.style)return this.style.serialize()}getStyleUrl(){return this._styleUrl}_getStyleAndImages(){return this.style?{style:this.style.serialize(),images:this.style.imageManager.cloneImages()}:{style:null,images:{}}}isStyleLoaded(){if(!this.style){_e("There is no style added to the map.");return}return this.style.loaded()}addSource(e,t){return this._lazyInitEmptyStyle(),this.style.addSource(e,t),this._update(!0)}isSourceLoaded(e){var r;let t=(r=this.style)==null?void 0:r.tileManagers[e];if(t===void 0){this.fire(new Y(Error(`There is no tile manager with ID '${e}'`)));return}return t.loaded()}setTerrain(e,t={}){if(this.style._checkLoaded(),e&&gs(this,Zt.terrain,{value:e},t))return this;if(this._terrainDataCallback&&this.style.off("data",this._terrainDataCallback),!e)this.terrain&&this.terrain.destroy(),this.terrain=null,this.painter.renderToTexture=null,this.painter.destroyRTTResources(),this._camera.setTerrain(null);else{let r=this.style.tileManagers[e.source];if(!r)throw Error(`cannot load terrain, because there exists no source with ID: ${e.source}`);this.terrain===null&&r.reload();for(let i in this.style._layers){let a=this.style._layers[i];a.type==="hillshade"&&a.source===e.source&&_e("You are using the same source for a hillshade layer and for 3D terrain. Please consider using two separate sources to improve rendering quality."),a.type==="color-relief"&&a.source===e.source&&_e("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 VM(this.painter,r,e,this._terrainSkirtLength),this.painter.renderToTexture=new j5(this.painter,this.terrain),this._camera.setTerrain(this.terrain),this._terrainDataCallback=i=>this._handleTerrainDataEvent(i,e.source),this.style.on("data",this._terrainDataCallback)}return this.style.triggerSymbolPlacement(),this.fire(new TC({terrain:e})),this}_handleTerrainDataEvent(e,t){var i;if(e.dataType==="style"){this.terrain.tileManager.releaseAllRTT();return}let r=e.sourceId===t;if(r&&(this.terrain.resetElevationCache(),this.style.triggerSymbolPlacement()),r&&e.tile&&(this.painter.markTerrainDepthDirty(),this._camera.applyTerrainChange()),e.tile){if(((i=e.source)==null?void 0:i.type)==="image"){this.terrain.tileManager.releaseAllRTT();return}this.terrain.tileManager.releaseRTT(e.tile.tileID)}}getTerrain(){var e;return((e=this.terrain)==null?void 0:e.options)??null}areTilesLoaded(){var t;let e=(t=this.style)==null?void 0:t.tileManagers;for(let r of Object.values(e))if(!r.areTilesLoaded())return!1;return!0}removeSource(e){return this.style.removeSource(e),this._update(!0)}getSource(e){var t;return(t=this.style)==null?void 0:t.getSource(e)}setSourceTileLodParams(e,t,r){if(r){let i=this.getSource(r);if(!i)throw Error(`There is no source with ID "${r}", cannot set LOD parameters`);i.calculateTileZoom=zc(Math.max(1,e),Math.max(1,t))}else for(let i in this.style.tileManagers)this.style.tileManagers[i].getSource().calculateTileZoom=zc(Math.max(1,e),Math.max(1,t));return this._update(!0),this}refreshTiles(e,t){let r=this.style.tileManagers[e];if(!r)throw Error(`There is no tile manager with ID "${e}", cannot refresh tile`);t===void 0?r.reload(!0):r.refreshTiles(t.map(i=>new Ul(i.z,i.x,i.y)))}addImage(e,t,r={}){var a;this._lazyInitEmptyStyle();let i=this._createStyleImage(t,r);return i?(this.style.addImage(e,i),(a=i.userImage)!=null&&a.onAdd&&i.userImage.onAdd(this,e),this):this}setMissingStyleImageResolver(e){var t;return this._missingStyleImageResolver=e,(t=this.style)==null||t.setMissingImageResolver(e),this}_createStyleImage(e,t={}){let{pixelRatio:r=1,sdf:i=!1,stretchX:a,stretchY:n,content:s,textFitWidth:o,textFitHeight:l}=t;if(e instanceof HTMLImageElement||Ni(e)){let{width:u,height:h,data:c}=Xt.getImageData(e);return{data:new $e({width:u,height:h},c),pixelRatio:r,stretchX:a,stretchY:n,content:s,textFitWidth:o,textFitHeight:l,sdf:i,version:0}}if(e.width===void 0||e.height===void 0)return this.fire(new Y(Error("Invalid arguments to map.addImage(). The second argument must be an `HTMLImageElement`, `ImageData`, `ImageBitmap`, or object with `width`, `height`, and `data` properties with the same format as `ImageData`"))),null;{let{width:u,height:h,data:c}=e,d=e,p=nl(d.data);return{data:p?new $e({width:u,height:h}):new $e({width:u,height:h},new Uint8Array(c)),pixelRatio:r,stretchX:a,stretchY:n,content:s,textFitWidth:o,textFitHeight:l,sdf:i,version:0,isWebGLImage:p,userImage:d}}}updateImage(e,t){let r=this.style.getImage(e);if(!r)return this.fire(new Y(Error("The map has no image with that id. If you are adding a new image use `map.addImage(...)` instead.")));let{width:i,height:a,data:n}=t instanceof HTMLImageElement||Ni(t)?Xt.getImageData(t):t;if(i===void 0||a===void 0)return this.fire(new Y(Error("Invalid arguments to map.updateImage(). The second argument must be an `HTMLImageElement`, `ImageData`, `ImageBitmap`, or object with `width`, `height`, and `data` properties with the same format as `ImageData`")));if(i!==r.data.width||a!==r.data.height)return this.fire(new Y(Error("The width and height of the updated image must be that same as the previous version of the image")));if(r.isWebGLImage=nl(n),r.isWebGLImage)r.userImage=t;else{let s=!(t instanceof HTMLImageElement||Ni(t));r.data.replace(n,s)}return this.style.updateImage(e,r),this}getImage(e){return this.style.getImage(e)}hasImage(e){return e?!!this.style.getImage(e):(this.fire(new Y(Error("Missing required image id"))),!1)}removeImage(e){this.style.removeImage(e)}async loadImage(e){let t=await Ur.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(){var e;return((e=this.style)==null?void 0:e.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){var t;return(t=this.style)==null?void 0:t.getLayer(e)}getLayersOrder(){var e;return((e=this.style)==null?void 0:e.getLayersOrder())??[]}setLayerZoomRange(e,t,r){return this.style.setLayerZoomRange(e,t,r),this._update(!0)}setFilter(e,t,r={}){var i;return(i=this.style)==null||i.setFilter(e,t,r),this._update(!0)}getFilter(e){return this.style.getFilter(e)}setPaintProperty(e,t,r,i={}){var a;return(a=this.style)==null||a.setPaintProperty(e,t,r,i),this._update(!0)}getPaintProperty(e,t){return this.style.getPaintProperty(e,t)}setLayoutProperty(e,t,r,i={}){return this.style.setLayoutProperty(e,t,r,i),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,r={}){return this._lazyInitEmptyStyle(),this.style.addSprite(e,t,r,i=>{i||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,r=>{r||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(){var r;if(!((r=this._container)!=null&&r.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=wx(i=>{this._trackResize&&!this._removed&&(this.resize(i),this.redraw())},50),r=this._ownerWindow.ResizeObserver??ResizeObserver;this._resizeObserver=new r(i=>{!e&&(e=!0,!this._shouldHandleInitialResize())||t(i)}),this._resizeObserver.observe(this._container)}_resolveContainer(e){if(typeof e=="string"){let t=document.getElementById(e);if(!t)throw Error(`Container '${e}' not found.`);return t}if(e instanceof HTMLElement||e&&typeof e=="object"&&e.nodeType===1)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]),r=this._container;r.classList.add("maplibregl-map");let i=this._canvasContainer=at.create("div","maplibregl-canvas-container",r);this._interactive&&i.classList.add("maplibregl-interactive"),this._canvas=at.create("canvas","maplibregl-canvas",i),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=at.create("div","maplibregl-control-container",r),n=this._controlPositions={};for(let s of["top-left","top-right","bottom-left","bottom-right"])n[s]=at.create("div",`maplibregl-ctrl-${s} `,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,r){let i=Math.round(r*e),a=Math.round(r*t);this._canvas.width=i,this._canvas.height=a,this._canvas.style.width=`${i/r}px`,this._canvas.style.height=`${a/r}px`}_setupPainter(){let e={...this._canvasContextAttributes,alpha:!0,depth:!0,stencil:!0,premultipliedAlpha:!0},t=null;this._canvas.addEventListener("webglcontextcreationerror",i=>{t=i},{once:!0});let r=this._canvas.getContext("webgl2",e);if(!r)throw new KF(e,t);this.painter=new YF(r,this._camera.transform)}migrateProjection(e,t){this._camera.migrateProjection(e,t),this.painter.transform=e,this.fire(new SC({newProjection:this.style.projection.name}))}loaded(){return!this._styleDirty&&!this._sourcesDirty&&!!this.style&&this.style.loaded()}_update(e){var t;return(t=this.style)!=null&&t._loaded?(this._styleDirty||(this._styleDirty=e),this._sourcesDirty=!0,this.triggerRepaint(),this):this}_requestRenderFrame(e){return this._update(),this._renderTaskQueue.add(e)}_cancelRenderFrame(e){this._renderTaskQueue.remove(e)}_render(e){var s,o,l,u,h;let t=this._idleTriggered?this._fadeDuration:0,r=((s=this.style.projection)==null?void 0:s.transitionState)>0;if(this.painter.context.setDirty(),this.painter.setBaseState(),this._renderTaskQueue.run(e),this._removed)return;let i=!1;if(this.style&&this._styleDirty){this._styleDirty=!1;let c=this._camera.transform.zoom,d=Fe();this.style.zoomHistory.update(c,d);let p=new ze(c,{now:d,fadeDuration:t,zoomHistory:this.style.zoomHistory,transition:this.style.getTransition()}),f=p.crossFadingFactor();(f!==1||f!==this._crossFadingFactor)&&(i=!0,this._crossFadingFactor=f),this.style.update(p)}let a=((o=this.style.projection)==null?void 0:o.transitionState)>0!==r;this._camera.transform.setTransitionState((l=this.style.projection)==null?void 0:l.transitionState),this.style&&(this._sourcesDirty||a)&&(this._sourcesDirty=!1,this.style._updateSources(this._camera.transform)),this.terrain?(this.terrain.tileManager.update(this._camera.transform,this.terrain)&&this.terrain.resetElevationCache(),this._camera.transform.setMinElevationForCurrentTile(this.terrain.getMinTileElevationForLngLatZoom(this._camera.transform.center,this._camera.transform.tileZoom)),!this._camera.elevationFreeze&&this.getCenterClampedToGround()&&this._camera.transform.setElevation(this.terrain.getElevationForLngLat(this._camera.transform.center,this._camera.transform))):(this._camera.transform.setMinElevationForCurrentTile(0),this.getCenterClampedToGround()&&this._camera.transform.setElevation(0)),this._placementDirty=(u=this.style)==null?void 0:u._updatePlacement(this._camera.transform,this.showCollisionBoxes,t,this._crossSourceCollisions,a),this.painter.render(this.style,{showTileBoundaries:this.showTileBoundaries,showOverdrawInspector:this._showOverdrawInspector,rotating:this.isRotating(),zooming:this.isZooming(),moving:this.isMoving(),fadeDuration:t,showPadding:this.showPadding,anisotropicFilterPitch:this.getAnisotropicFilterPitch()}),this.fire(new bt("render")),this.loaded()&&!this._loaded&&(this._loaded=!0,this.fire(new bt("load"))),this.style&&(this.style.hasTransitions()||i)&&(this._styleDirty=!0),this.style&&!this._placementDirty&&this.style._releaseSymbolFadeTiles();let n=this._sourcesDirty||this._styleDirty||this._placementDirty||((h=this.painter.renderToTexture)==null?void 0:h.needsFollowUpFrame);return n||this._repaint?this.triggerRepaint():!this.isMoving()&&this.loaded()&&this.fire(new bt("idle")),this._loaded&&!this._fullyLoaded&&!n&&(this._fullyLoaded=!0),this}redraw(){return this.style&&(this._frameRequest&&(this._frameRequest=(this._frameRequest.abort(),null)),this._render(0)),this}remove(){var t,r;this._hash&&this._hash.remove();for(let i of this._controls)i.onRemove(this);this._controls=[],this._frameRequest&&(this._frameRequest=(this._frameRequest.abort(),null)),this._renderTaskQueue.clear(),(t=this._diffStyleRequest)==null||t.abort(),this.painter.destroy(),this._handlers.destroy(),this.setStyle(null),typeof window<"u"&&this._ownerWindow.removeEventListener("online",this._onWindowOnline,!1),Ur.removeThrottleControl(this._imageQueueHandle),(r=this._resizeObserver)==null||r.disconnect();let e=this.painter.context.gl.getExtension("WEBGL_lose_context");e!=null&&e.loseContext&&e.loseContext(),this._cleanupContainer(),this._removed=!0,this.fire(new bt("remove"))}triggerRepaint(){this.style&&!this._frameRequest&&(this._frameRequest=new AbortController,Xt.frame(this._frameRequest,e=>{this._frameRequest=null;try{this._render(e)}catch(t){if(!Si(t))throw t}},()=>{},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 N5}getCameraTargetElevation(){return this._camera.transform.elevation}getProjection(){return this.style.getProjection()}setProjection(e){return this._lazyInitEmptyStyle(),this.style.setProjection(e),this._update(!0)}};function G5(e){Yi.WORKER_URL=e}const q5="#DD4B40",Dn="lecodes-user",vo="lecodes-user-halo",Z5="lecodes-user-dot",W5="lecodes-user-heading",hh="lecodes-user-heading",bo={type:"FeatureCollection",features:[]},H5=(e,t)=>{if(e.head.querySelector("style[data-maplibre-css]"))return;const r=e.createElement("style");r.setAttribute("data-maplibre-css",""),r.textContent=t,e.head.appendChild(r)},wo=e=>{if(!e)return null;const[t,r]=e;return!Number.isFinite(t)||!Number.isFinite(r)||r<-90||r>90?null:[t,r]},Lg=(e,t,r)=>{if(typeof e=="number")return{top:e,left:e,bottom:e,right:e};const i=e??{},a=(n,s)=>{if(typeof n=="number")return n;if(typeof n=="string"&&n.endsWith("%")){const o=Number(n.slice(0,-1));return Number.isFinite(o)?s*o/100:0}return 0};return{top:a(i.top,r),left:a(i.left,t),bottom:a(i.bottom,r),right:a(i.right,t)}},X5=e=>typeof e=="string"||typeof e=="number"?e:null,Y5=e=>!e||e.type!=="FeatureCollection"||!Array.isArray(e.features)?e:{...e,features:e.features.map(t=>{const r=(t==null?void 0:t.properties)??{};return r.color==null?{...t,properties:{...r,color:q5}}:t})},K5=e=>{const t=e.createElement("canvas");t.width=48,t.height=48;const r=t.getContext("2d");return r?(r.scale(2,2),r.beginPath(),r.moveTo(12,1),r.lineTo(18,10),r.lineTo(12,7.5),r.lineTo(6,10),r.closePath(),r.fillStyle="rgb(26,128,255)",r.fill(),r.strokeStyle="#fff",r.lineWidth=1,r.stroke(),r.getImageData(0,0,48,48)):null},J5=(e,t)=>{const r=e/(156543.03392*Math.cos(t*Math.PI/180)),i=["interpolate",["exponential",2],["zoom"],0,r,22,r*4194304];return["step",i,0,10,["min",600,i]]},pk=(e,t,r,i,a)=>{G5(a.workerUrl),H5(i,a.css);const n=t.rotate!==!1,s=t.tilt===!0,o=wo(t.center),l=(()=>{if(t.styleJson!==void 0)try{return JSON.parse(t.styleJson)}catch{return null}return t.style??null})();l||r.error({message:"MapView: `style` must be a URL or a style JSON"});const u=new U5({container:e,style:l??{version:8,sources:{},layers:[]},center:o??[0,0],zoom:t.zoom??(o?12:0),bearing:t.bearing??0,pitch:t.pitch??0,minZoom:t.minZoom,maxZoom:t.maxZoom,attributionControl:!1,dragRotate:n,pitchWithRotate:s,touchPitch:s});n||u.touchZoomRotate.disableRotation();let h=!1,c=new Map,d={},p=null;const f=()=>[e.clientWidth,e.clientHeight],m=()=>{const T=u.getCenter();return{center:[T.lng,T.lat],zoom:u.getZoom(),bearing:u.getBearing(),pitch:u.getPitch()}},g=T=>{var E;return(((E=u.getStyle())==null?void 0:E.layers)??[]).filter(D=>D.source===T).map(D=>D.id)};u.on("load",()=>{c=new Map,p=null,h=!0,r.ready(),I()}),u.on("error",T=>{var E;h||r.error({message:((E=T==null?void 0:T.error)==null?void 0:E.message)??"MapView: failed to load the style"})}),u.on("moveend",()=>{h&&r.moveEnd(m())}),u.on("resize",()=>I());let _=null;u.on("dblclick",()=>{_&&(clearTimeout(_),_=null)}),u.on("click",T=>{_&&clearTimeout(_);const E=T.point,D=[T.lngLat.lng,T.lngLat.lat];_=setTimeout(()=>{_=null,y(E,D)},300)});const y=(T,E)=>{if(!h)return;const D={lngLat:E,point:[T.x,T.y]};for(const C of c.keys()){const k=g(C);if(k.length===0)continue;let B;try{B=u.queryRenderedFeatures([T.x,T.y],{layers:k})}catch{continue}const $=B[0];if(!$)continue;const W=$.properties??{};if(W.cluster===!0||W.cluster==="true"){const ye=u.getSource(C),ce=$.geometry.type==="Point"?$.geometry.coordinates:E;ye==null||ye.getClusterExpansionZoom(Number(W.cluster_id)).then(ke=>u.easeTo({center:ce,zoom:ke}),()=>{});return}const ie=W.id??$.id;r.tap({...D,feature:{source:C,id:X5(ie),properties:W}});return}r.tap(D)},v=()=>new Fp("notReady"),x=(T,E)=>{if(!h)throw v();const D=u.getSource(T);if(!D||D.type!=="geojson")throw new Error(`unknown GeoJSON source "${T}" — call ensureLayer / map.markers(name) first, or declare it in the style`);const C=c.get(T);D.setData((C==null?void 0:C.kind)==="markers"?Y5(E):E)},w=(T,E,D={})=>{if(!h)throw v();if(!c.has(T)){if(u.getSource(T)){c.set(T,{kind:"styleOwned"});return}c.set(T,{kind:E,layerIds:S(T,E,D)})}},b=T=>{var D;const E=c.get(T);if(E){if(c.delete(T),E.kind==="styleOwned"){(D=u.getSource(T))==null||D.setData(bo);return}for(const C of E.layerIds)u.getLayer(C)&&u.removeLayer(C);u.getSource(T)&&u.removeSource(T)}},S=(T,E,D)=>{const C=E==="markers"&&D.cluster===!0;u.addSource(T,{type:"geojson",data:bo,...C?{cluster:!0,clusterRadius:D.clusterRadius??50,...D.clusterMaxZoom===void 0?{}:{clusterMaxZoom:D.clusterMaxZoom}}:{}});const k=[];if(E==="line")k.push({id:`${T}-line`,type:"line",source:T,layout:{"line-cap":"round","line-join":"round"},paint:{"line-color":D.color??"rgb(255,64,51)","line-width":D.width??4,"line-opacity":D.opacity??1}});else{const $=C?[["!",["has","point_count"]]]:[];k.push({id:`${T}-dot`,type:"circle",source:T,...C?{filter:["!",["has","point_count"]]}:{},paint:{"circle-radius":8,"circle-color":["get","color"],"circle-stroke-color":"#fff","circle-stroke-width":2}}),k.push({id:`${T}-icon`,type:"symbol",source:T,filter:["all",...$,["has","icon"]],layout:{"icon-image":["get","icon"],"icon-allow-overlap":!0,"icon-ignore-placement":!0}}),k.push({id:`${T}-label`,type:"symbol",source:T,filter:["all",...$,["has","title"]],layout:{"text-field":["get","title"],"text-size":12,"text-anchor":"top","text-offset":[0,.9],"text-optional":!0},paint:{"text-color":"#000","text-halo-color":"#fff","text-halo-width":1.2}}),C&&(k.push({id:`${T}-clusters`,type:"circle",source:T,filter:["has","point_count"],paint:{"circle-radius":18,"circle-color":"rgb(59,122,214)","circle-stroke-color":"#fff","circle-stroke-width":2}}),k.push({id:`${T}-cluster-count`,type:"symbol",source:T,filter:["has","point_count"],layout:{"text-field":["to-string",["get","point_count"]],"text-size":13,"text-allow-overlap":!0,"text-ignore-placement":!0},paint:{"text-color":"#fff"}}))}const B=p&&u.getLayer(vo)?vo:void 0;for(const $ of k)u.addLayer($,B);return k.map($=>$.id)},A=(T,E={},D)=>{const C=wo(T);if(!C)throw new Error(`the latitude ${T[1]} is off the globe`);const k={center:C,...E.zoom===void 0?{}:{zoom:E.zoom},...E.bearing===void 0?{}:{bearing:E.bearing},...E.pitch===void 0?{}:{pitch:E.pitch}};D?u.flyTo({...k,duration:E.duration??600}):u.jumpTo(k)},P=(T,E={})=>{const D=T.map(wo).filter(ie=>ie!==null);if(D.length===0)throw new Fp("noPoints");const C=E.animate!==!1,[k,B]=f(),$=new Wr(D[0],D[0]);for(const ie of D)$.extend(ie);const W=E.maxZoom??(D.length===1?16:void 0);u.fitBounds($,{padding:Lg(E.padding,k,B),...W!==void 0?{maxZoom:W}:{},duration:C?600:0})},I=()=>{const[T,E]=f();T===0||E===0||u.setPadding(Lg(d,T,E))},R=()=>{if(p)return;u.addSource(Dn,{type:"geojson",data:bo});const T=K5(i);T&&!u.hasImage(hh)&&u.addImage(hh,T,{pixelRatio:2}),u.addLayer({id:vo,type:"circle",source:Dn,paint:{"circle-color":"rgba(26,128,255,0.18)","circle-radius":0,"circle-pitch-alignment":"map"}}),u.addLayer({id:W5,type:"symbol",source:Dn,filter:["has","heading"],layout:{"icon-image":hh,"icon-rotate":["get","heading"],"icon-rotation-alignment":"map","icon-allow-overlap":!0,"icon-ignore-placement":!0}}),u.addLayer({id:Z5,type:"circle",source:Dn,paint:{"circle-radius":7,"circle-color":"rgb(26,128,255)","circle-stroke-color":"#fff","circle-stroke-width":2.5}}),p={accuracy:null,lat:0}},F=(T,E,D)=>{if(!h)return;R();const C=u.getSource(Dn);if(!(!C||!p)){if(!T){C.setData(bo);return}C.setData({type:"Feature",properties:D==null?{}:{heading:D},geometry:{type:"Point",coordinates:T}}),p.accuracy=E,p.lat=T[1],u.setPaintProperty(vo,"circle-radius",E!=null&&E>0?J5(E,T[1]):0)}};return{el:e,ensureLayer:w,removeLayer:b,setData:x,flyTo:(T,E)=>A(T,E,!0),jumpTo:(T,E)=>A(T,E,!1),fitPoints:P,setPadding:T=>{d=T,I()},getCamera:m,setUserLocation:(T,E)=>F(wo(T),(E==null?void 0:E.accuracy)??null,(E==null?void 0:E.heading)??null),destroy:()=>{_&&clearTimeout(_),u.remove()}}};export{pk as createMap};
|