@mapslibvn/web 0.4.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/LICENSE +21 -0
- package/README.md +40 -0
- package/THIRD_PARTY_NOTICES.md +393 -0
- package/dist/index.d.ts +91 -0
- package/dist/index.js +367 -0
- package/dist/maplibre-gl-shared.mjs +6 -0
- package/dist/maplibre-gl-worker.mjs +6 -0
- package/dist/mapslibvn.css +1 -0
- package/dist/mapslibvn.umd.js +839 -0
- package/dist/mapslibvn.umd.js.map +1 -0
- package/package.json +43 -0
|
@@ -0,0 +1,839 @@
|
|
|
1
|
+
(function(he,pe){typeof exports=="object"&&typeof module<"u"?pe(exports):typeof define=="function"&&define.amd?define(["exports"],pe):(he=typeof globalThis<"u"?globalThis:he||self,pe(he.MapsLibVN={}))})(this,(function(he){"use strict";var Zk=Object.defineProperty;var a1=he=>{throw TypeError(he)};var qk=(he,pe,it)=>pe in he?Zk(he,pe,{enumerable:!0,configurable:!0,writable:!0,value:it}):he[pe]=it;var As=(he,pe,it)=>qk(he,typeof pe!="symbol"?pe+"":pe,it),Gd=(he,pe,it)=>pe.has(he)||a1("Cannot "+it);var q=(he,pe,it)=>(Gd(he,pe,"read from private field"),it?it.call(he):pe.get(he)),kt=(he,pe,it)=>pe.has(he)?a1("Cannot add the same private member more than once"):pe instanceof WeakSet?pe.add(he):pe.set(he,it),Lt=(he,pe,it,Or)=>(Gd(he,pe,"write to private field"),Or?Or.call(he,it):pe.set(he,it),it),nt=(he,pe,it)=>(Gd(he,pe,"access private method"),it);var dr=(he,pe,it,Or)=>({set _(jl){Lt(he,pe,jl,it)},get _(){return q(he,pe,Or)}});var bt,lr,_a,t,Pe,ur,ya,Hi,Fr,Xe,Xt,Rr,kr,hr,li,cr,ln,Ts,Ss,Es,Ps,De,V1,j1,U1,mr,G1,Qd,xa;var pe=typeof document<"u"?document.currentScript:null;/**
|
|
2
|
+
* MapLibre GL JS
|
|
3
|
+
* @license 3-Clause BSD. Full text of license: https://github.com/maplibre/maplibre-gl-js/blob/v6.8.0/LICENSE.txt
|
|
4
|
+
*/var it=Object.create,Or=Object.defineProperty,jl=Object.getOwnPropertyDescriptor,Z1=Object.getOwnPropertyNames,q1=Object.getPrototypeOf,W1=Object.prototype.hasOwnProperty,Ul=(e,t)=>()=>(t||(e((t={exports:{}}).exports,t),e=null),t.exports),H1=(e,t,i,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(var a=Z1(t),n=0,s=a.length,o;n<s;n++)o=a[n],!W1.call(e,o)&&o!==i&&Or(e,o,{get:(l=>t[l]).bind(null,o),enumerable:!(r=jl(t,o))||r.enumerable});return e},X1=(e,t,i)=>(i=e==null?{}:it(q1(e)),H1(Or(i,"default",{value:e,enumerable:!0}),e));function C(e,t){this.x=e,this.y=t}C.prototype={clone(){return new C(this.x,this.y)},add(e){return this.clone()._add(e)},sub(e){return this.clone()._sub(e)},multByPoint(e){return this.clone()._multByPoint(e)},divByPoint(e){return this.clone()._divByPoint(e)},mult(e){return this.clone()._mult(e)},div(e){return this.clone()._div(e)},rotate(e){return this.clone()._rotate(e)},rotateAround(e,t){return this.clone()._rotateAround(e,t)},matMult(e){return this.clone()._matMult(e)},unit(){return this.clone()._unit()},perp(){return this.clone()._perp()},round(){return this.clone()._round()},mag(){return Math.sqrt(this.x*this.x+this.y*this.y)},equals(e){return this.x===e.x&&this.y===e.y},dist(e){return Math.sqrt(this.distSqr(e))},distSqr(e){let t=e.x-this.x,i=e.y-this.y;return t*t+i*i},angle(){return Math.atan2(this.y,this.x)},angleTo(e){return Math.atan2(this.y-e.y,this.x-e.x)},angleWith(e){return this.angleWithSep(e.x,e.y)},angleWithSep(e,t){return Math.atan2(this.x*t-this.y*e,this.x*e+this.y*t)},_matMult(e){let t=e[0]*this.x+e[1]*this.y,i=e[2]*this.x+e[3]*this.y;return this.x=t,this.y=i,this},_add(e){return this.x+=e.x,this.y+=e.y,this},_sub(e){return this.x-=e.x,this.y-=e.y,this},_mult(e){return this.x*=e,this.y*=e,this},_div(e){return this.x/=e,this.y/=e,this},_multByPoint(e){return this.x*=e.x,this.y*=e.y,this},_divByPoint(e){return this.x/=e.x,this.y/=e.y,this},_unit(){return this._div(this.mag()),this},_perp(){let e=this.y;return this.y=this.x,this.x=-e,this},_rotate(e){let t=Math.cos(e),i=Math.sin(e),r=t*this.x-i*this.y,a=i*this.x+t*this.y;return this.x=r,this.y=a,this},_rotateAround(e,t){let i=Math.cos(e),r=Math.sin(e),a=t.x+i*(this.x-t.x)-r*(this.y-t.y),n=t.y+r*(this.x-t.x)+i*(this.y-t.y);return this.x=a,this.y=n,this},_round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this},constructor:C},C.convert=function(e){if(e instanceof C)return e;if(Array.isArray(e))return new C(+e[0],+e[1]);if(e.x!==void 0&&e.y!==void 0)return new C(+e.x,+e.y);throw Error("Expected [x, y] or {x, y} point format")};function Y1(e,t,i,r){let a=3*e,n=3*(i-e)-a,s=1-a-n,o=3*t,l=3*(r-t)-o,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 ep;function tp(){return ep??(ep=typeof OffscreenCanvas<"u"&&new OffscreenCanvas(1,1).getContext("2d")&&typeof createImageBitmap=="function"),ep}let Rs;function K1(){if(Rs==null&&(Rs=!1,tp())){let e=new OffscreenCanvas(5,5).getContext("2d",{willReadFrequently:!0});if(e){for(let i=0;i<25;i++){let r=i*4;e.fillStyle=`rgb(${r},${r+1},${r+2})`,e.fillRect(i%5,Math.floor(i/5),1,1)}let t=e.getImageData(0,0,5,5).data;for(let i=0;i<100;i++)if(i%4!=3&&t[i]!==i){Rs=!0;break}}}return Rs||!1}var dt=typeof Float32Array<"u"?Float32Array:Array;function ip(){var e=new dt(9);return dt!=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 J1(e){var t=e[0],i=e[1],r=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)+i*(-u*a+s*o)+r*(l*a-n*o)}function Q1(e,t){var i=Math.sin(t),r=Math.cos(t);return e[0]=r,e[1]=i,e[2]=0,e[3]=-i,e[4]=r,e[5]=0,e[6]=0,e[7]=0,e[8]=1,e}function ex(e,t){var i=t[0],r=t[1],a=t[2],n=t[3],s=i+i,o=r+r,l=a+a,u=i*s,h=r*s,c=r*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 gr(){var e=new dt(16);return dt!=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 Gl(e){var t=new dt(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 tx(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 Si(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 ks(e,t){var i=t[0],r=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=i*o-r*s,x=i*l-a*s,v=i*u-n*s,w=r*l-a*o,b=r*u-n*o,T=a*u-n*l,P=h*m-c*f,S=h*g-d*f,M=h*_-p*f,F=c*g-d*m,R=c*_-p*m,I=d*_-p*g,D=y*I-x*R+v*F+w*M-b*S+T*P;return D?(D=1/D,e[0]=(o*I-l*R+u*F)*D,e[1]=(a*R-r*I-n*F)*D,e[2]=(m*T-g*b+_*w)*D,e[3]=(d*b-c*T-p*w)*D,e[4]=(l*M-s*I-u*S)*D,e[5]=(i*I-a*M+n*S)*D,e[6]=(g*v-f*T-_*x)*D,e[7]=(h*T-d*v+p*x)*D,e[8]=(s*R-o*M+u*P)*D,e[9]=(r*M-i*R-n*P)*D,e[10]=(f*b-m*v+_*y)*D,e[11]=(c*v-h*b-p*y)*D,e[12]=(o*S-s*F-l*P)*D,e[13]=(i*F-r*S+a*P)*D,e[14]=(m*x-f*w-g*y)*D,e[15]=(h*w-c*x+d*y)*D,e):null}function ba(e,t,i){var r=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],x=i[0],v=i[1],w=i[2],b=i[3];return e[0]=x*r+v*o+w*c+b*m,e[1]=x*a+v*l+w*d+b*g,e[2]=x*n+v*u+w*p+b*_,e[3]=x*s+v*h+w*f+b*y,x=i[4],v=i[5],w=i[6],b=i[7],e[4]=x*r+v*o+w*c+b*m,e[5]=x*a+v*l+w*d+b*g,e[6]=x*n+v*u+w*p+b*_,e[7]=x*s+v*h+w*f+b*y,x=i[8],v=i[9],w=i[10],b=i[11],e[8]=x*r+v*o+w*c+b*m,e[9]=x*a+v*l+w*d+b*g,e[10]=x*n+v*u+w*p+b*_,e[11]=x*s+v*h+w*f+b*y,x=i[12],v=i[13],w=i[14],b=i[15],e[12]=x*r+v*o+w*c+b*m,e[13]=x*a+v*l+w*d+b*g,e[14]=x*n+v*u+w*p+b*_,e[15]=x*s+v*h+w*f+b*y,e}function rt(e,t,i){var r=i[0],a=i[1],n=i[2],s,o,l,u,h,c,d,p,f,m,g,_;return t===e?(e[12]=t[0]*r+t[4]*a+t[8]*n+t[12],e[13]=t[1]*r+t[5]*a+t[9]*n+t[13],e[14]=t[2]*r+t[6]*a+t[10]*n+t[14],e[15]=t[3]*r+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*r+h*a+f*n+t[12],e[13]=o*r+c*a+m*n+t[13],e[14]=l*r+d*a+g*n+t[14],e[15]=u*r+p*a+_*n+t[15]),e}function Tt(e,t,i){var r=i[0],a=i[1],n=i[2];return e[0]=t[0]*r,e[1]=t[1]*r,e[2]=t[2]*r,e[3]=t[3]*r,e[4]=t[4]*a,e[5]=t[5]*a,e[6]=t[6]*a,e[7]=t[7]*a,e[8]=t[8]*n,e[9]=t[9]*n,e[10]=t[10]*n,e[11]=t[11]*n,e[12]=t[12],e[13]=t[13],e[14]=t[14],e[15]=t[15],e}function wa(e,t,i){var r=Math.sin(i),a=Math.cos(i),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*r,e[5]=s*a+h*r,e[6]=o*a+c*r,e[7]=l*a+d*r,e[8]=u*a-n*r,e[9]=h*a-s*r,e[10]=c*a-o*r,e[11]=d*a-l*r,e}function rp(e,t,i){var r=Math.sin(i),a=Math.cos(i),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*r,e[1]=s*a-h*r,e[2]=o*a-c*r,e[3]=l*a-d*r,e[8]=n*r+u*a,e[9]=s*r+h*a,e[10]=o*r+c*a,e[11]=l*r+d*a,e}function _r(e,t,i){var r=Math.sin(i),a=Math.cos(i),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*r,e[1]=s*a+h*r,e[2]=o*a+c*r,e[3]=l*a+d*r,e[4]=u*a-n*r,e[5]=h*a-s*r,e[6]=c*a-o*r,e[7]=d*a-l*r,e}function ix(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 rx(e,t,i,r,a){var n=1/Math.tan(t/2);if(e[0]=n/i,e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[5]=n,e[6]=0,e[7]=0,e[8]=0,e[9]=0,e[11]=-1,e[12]=0,e[13]=0,e[15]=0,a!=null&&a!==1/0){var s=1/(r-a);e[10]=(a+r)*s,e[14]=2*a*r*s}else e[10]=-1,e[14]=-2*r;return e}var Zl=rx;function ax(e,t,i,r,a,n,s){var o=1/(t-i),l=1/(r-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+i)*o,e[13]=(a+r)*l,e[14]=(s+n)*u,e[15]=1,e}var Ri=ax;function nx(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 sx(e,t){var i=e[0],r=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],x=t[1],v=t[2],w=t[3],b=t[4],T=t[5],P=t[6],S=t[7],M=t[8],F=t[9],R=t[10],I=t[11],D=t[12],E=t[13],A=t[14],B=t[15];return Math.abs(i-y)<=1e-6*Math.max(1,Math.abs(i),Math.abs(y))&&Math.abs(r-x)<=1e-6*Math.max(1,Math.abs(r),Math.abs(x))&&Math.abs(a-v)<=1e-6*Math.max(1,Math.abs(a),Math.abs(v))&&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-T)<=1e-6*Math.max(1,Math.abs(o),Math.abs(T))&&Math.abs(l-P)<=1e-6*Math.max(1,Math.abs(l),Math.abs(P))&&Math.abs(u-S)<=1e-6*Math.max(1,Math.abs(u),Math.abs(S))&&Math.abs(h-M)<=1e-6*Math.max(1,Math.abs(h),Math.abs(M))&&Math.abs(c-F)<=1e-6*Math.max(1,Math.abs(c),Math.abs(F))&&Math.abs(d-R)<=1e-6*Math.max(1,Math.abs(d),Math.abs(R))&&Math.abs(p-I)<=1e-6*Math.max(1,Math.abs(p),Math.abs(I))&&Math.abs(f-D)<=1e-6*Math.max(1,Math.abs(f),Math.abs(D))&&Math.abs(m-E)<=1e-6*Math.max(1,Math.abs(m),Math.abs(E))&&Math.abs(g-A)<=1e-6*Math.max(1,Math.abs(g),Math.abs(A))&&Math.abs(_-B)<=1e-6*Math.max(1,Math.abs(_),Math.abs(B))}function ap(){var e=new dt(3);return dt!=Float32Array&&(e[0]=0,e[1]=0,e[2]=0),e}function ql(e){var t=new dt(3);return t[0]=e[0],t[1]=e[1],t[2]=e[2],t}function Ki(e){var t=e[0],i=e[1],r=e[2];return Math.sqrt(t*t+i*i+r*r)}function np(e,t,i){var r=new dt(3);return r[0]=e,r[1]=t,r[2]=i,r}function ui(e,t,i){return e[0]=t[0]+i[0],e[1]=t[1]+i[1],e[2]=t[2]+i[2],e}function sp(e,t,i){return e[0]=t[0]-i[0],e[1]=t[1]-i[1],e[2]=t[2]-i[2],e}function ke(e,t,i){return e[0]=t[0]*i,e[1]=t[1]*i,e[2]=t[2]*i,e}function Ls(e,t,i,r){return e[0]=t[0]+i[0]*r,e[1]=t[1]+i[1]*r,e[2]=t[2]+i[2]*r,e}function ox(e,t){var i=t[0]-e[0],r=t[1]-e[1],a=t[2]-e[2];return Math.sqrt(i*i+r*r+a*a)}function lx(e,t){return e[0]=-t[0],e[1]=-t[1],e[2]=-t[2],e}function Bt(e,t){var i=t[0],r=t[1],a=t[2],n=i*i+r*r+a*a;return n>0&&(n=1/Math.sqrt(n)),e[0]=t[0]*n,e[1]=t[1]*n,e[2]=t[2]*n,e}function st(e,t){return e[0]*t[0]+e[1]*t[1]+e[2]*t[2]}function qt(e,t,i){var r=t[0],a=t[1],n=t[2],s=i[0],o=i[1],l=i[2];return e[0]=a*l-n*o,e[1]=n*s-r*l,e[2]=r*o-a*s,e}function ux(e,t,i){var r=t[0],a=t[1],n=t[2],s=i[3]*r+i[7]*a+i[11]*n+i[15];return s||(s=1),e[0]=(i[0]*r+i[4]*a+i[8]*n+i[12])/s,e[1]=(i[1]*r+i[5]*a+i[9]*n+i[13])/s,e[2]=(i[2]*r+i[6]*a+i[10]*n+i[14])/s,e}function hx(e,t,i){var r=t[0],a=t[1],n=t[2];return e[0]=r*i[0]+a*i[3]+n*i[6],e[1]=r*i[1]+a*i[4]+n*i[7],e[2]=r*i[2]+a*i[5]+n*i[8],e}function Wl(e,t,i){var r=i[0],a=i[1],n=i[2],s=i[3],o=t[0],l=t[1],u=t[2],h=a*u-n*l,c=n*o-r*u,d=r*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-r*d,e[2]=u+s*d+r*c-a*h,e}function cn(e,t,i,r){var a=[],n=[];return a[0]=t[0]-i[0],a[1]=t[1]-i[1],a[2]=t[2]-i[2],n[0]=a[0],n[1]=a[1]*Math.cos(r)-a[2]*Math.sin(r),n[2]=a[1]*Math.sin(r)+a[2]*Math.cos(r),e[0]=n[0]+i[0],e[1]=n[1]+i[1],e[2]=n[2]+i[2],e}function Ta(e,t,i,r){var a=[],n=[];return a[0]=t[0]-i[0],a[1]=t[1]-i[1],a[2]=t[2]-i[2],n[0]=a[2]*Math.sin(r)+a[0]*Math.cos(r),n[1]=a[1],n[2]=a[2]*Math.cos(r)-a[0]*Math.sin(r),e[0]=n[0]+i[0],e[1]=n[1]+i[1],e[2]=n[2]+i[2],e}function Hl(e,t,i,r){var a=[],n=[];return a[0]=t[0]-i[0],a[1]=t[1]-i[1],a[2]=t[2]-i[2],n[0]=a[0]*Math.cos(r)-a[1]*Math.sin(r),n[1]=a[0]*Math.sin(r)+a[1]*Math.cos(r),n[2]=a[2],e[0]=n[0]+i[0],e[1]=n[1]+i[1],e[2]=n[2]+i[2],e}function cx(e){return e[0]=0,e[1]=0,e[2]=0,e}var Ji=sp,Bs=Ki;(function(){var e=ap();return function(t,i,r,a,n,s){var o,l;for(i||(i=3),r||(r=0),l=a?Math.min(a*i+r,t.length):t.length,o=r;o<l;o+=i)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 dx(){var e=new dt(4);return dt!=Float32Array&&(e[0]=0,e[1]=0,e[2]=0,e[3]=0),e}function px(e,t,i,r){var a=new dt(4);return a[0]=e,a[1]=t,a[2]=i,a[3]=r,a}function fx(e,t,i){return e[0]=t[0]*i[0],e[1]=t[1]*i[1],e[2]=t[2]*i[2],e[3]=t[3]*i[3],e}function mx(e,t,i){return e[0]=t[0]*i,e[1]=t[1]*i,e[2]=t[2]*i,e[3]=t[3]*i,e}function gx(e,t){var i=t[0],r=t[1],a=t[2],n=t[3],s=i*i+r*r+a*a+n*n;return s>0&&(s=1/Math.sqrt(s)),e[0]=i*s,e[1]=r*s,e[2]=a*s,e[3]=n*s,e}function pt(e,t,i){var r=t[0],a=t[1],n=t[2],s=t[3];return e[0]=i[0]*r+i[4]*a+i[8]*n+i[12]*s,e[1]=i[1]*r+i[5]*a+i[9]*n+i[13]*s,e[2]=i[2]*r+i[6]*a+i[10]*n+i[14]*s,e[3]=i[3]*r+i[7]*a+i[11]*n+i[15]*s,e}var _x=fx;(function(){var e=dx();return function(t,i,r,a,n,s){var o,l;for(i||(i=4),r||(r=0),l=a?Math.min(a*i+r,t.length):t.length,o=r;o<l;o+=i)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 op(){var e=new dt(4);return dt!=Float32Array&&(e[0]=0,e[1]=0,e[2]=0),e[3]=1,e}function yx(e,t,i){i*=.5;var r=Math.sin(i);return e[0]=r*t[0],e[1]=r*t[1],e[2]=r*t[2],e[3]=Math.cos(i),e}function vx(e,t,i){var r=t[0],a=t[1],n=t[2],s=t[3],o=i[0],l=i[1],u=i[2],h=i[3];return e[0]=r*h+s*o+a*u-n*l,e[1]=a*h+s*l+n*o-r*u,e[2]=n*h+s*u+r*l-a*o,e[3]=s*h-r*o-a*l-n*u,e}function $s(e,t,i,r){var a=t[0],n=t[1],s=t[2],o=t[3],l=i[0],u=i[1],h=i[2],c=i[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-r)*d)/f,g=Math.sin(r*d)/f):(m=1-r,g=r),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 xx(e,t){var i=t[0]+t[4]+t[8],r;if(i>0)r=Math.sqrt(i+1),e[3]=.5*r,r=.5/r,e[0]=(t[5]-t[7])*r,e[1]=(t[6]-t[2])*r,e[2]=(t[1]-t[3])*r;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;r=Math.sqrt(t[a*3+a]-t[n*3+n]-t[s*3+s]+1),e[a]=.5*r,r=.5/r,e[3]=(t[n*3+s]-t[s*3+n])*r,e[n]=(t[n*3+a]+t[a*3+n])*r,e[s]=(t[s*3+a]+t[a*3+s])*r}return e}function Xl(e,t,i,r){var a=arguments.length>4&&arguments[4]!==void 0?arguments[4]:"zyx",n=Math.PI/360;t*=n,r*=n,i*=n;var s=Math.sin(t),o=Math.cos(t),l=Math.sin(i),u=Math.cos(i),h=Math.sin(r),c=Math.cos(r);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 lp=px,up=gx;(function(){var e=ap(),t=np(1,0,0),i=np(0,1,0);return function(r,a,n){var s=st(a,n);return s<-.999999?(qt(e,t,a),Bs(e)<1e-6&&qt(e,i,a),Bt(e,e),yx(r,e,Math.PI),r):s>.999999?(r[0]=0,r[1]=0,r[2]=0,r[3]=1,r):(qt(e,a,n),r[0]=e[0],r[1]=e[1],r[2]=e[2],r[3]=1+s,up(r,r))}})(),(function(){var e=op(),t=op();return function(i,r,a,n,s,o){return $s(e,r,s,o),$s(t,a,n,o),$s(i,e,t,2*o*(1-o)),i}})(),(function(){var e=ip();return function(t,i,r,a){return e[0]=r[0],e[3]=r[1],e[6]=r[2],e[1]=a[0],e[4]=a[1],e[7]=a[2],e[2]=-i[0],e[5]=-i[1],e[8]=-i[2],up(t,xx(t,e))}})();function Yl(){var e=new dt(2);return dt!=Float32Array&&(e[0]=0,e[1]=0),e}function hp(e,t){var i=new dt(2);return i[0]=e,i[1]=t,i}function cp(e,t,i){return e[0]=t[0]*i,e[1]=t[1]*i,e}function dp(e){var t=e[0],i=e[1];return Math.sqrt(t*t+i*i)}function bx(e){var t=e[0],i=e[1];return t*t+i*i}function wx(e,t){return e[0]*t[0]+e[1]*t[1]}function pp(e){return e[0]=0,e[1]=0,e}var Tx=bx;(function(){var e=Yl();return function(t,i,r,a,n,s){var o,l;for(i||(i=2),r||(r=0),l=a?Math.min(a*i+r,t.length):t.length,o=r;o<l;o+=i)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 k=8192;function Kt(e,t,i){return t*(k/(e.tileSize*2**(i-e.tileID.overscaledZ)))}function St(e){return e instanceof Error?e:Error(typeof e=="string"?e:String(e))}function yr(){return new Float64Array(4)}function xe(){return new Float64Array(3)}function Nr(){return new Float64Array(16)}function Os(){let e=new Float64Array(16);return Si(e),e}function fp(){let e=new Float32Array(16);return Si(e),e}function vr(e,t,i,r,a=!1){if(!i[0]&&!i[1])return[0,0];let n=a?r==="map"?-e.bearingInRadians:0:r==="viewport"?e.bearingInRadians:0;if(n){let s=Math.sin(n),o=Math.cos(n);i=[i[0]*o-i[1]*s,i[0]*s+i[1]*o]}return[a?i[0]:Kt(t,i[0],e.zoom),a?i[1]:Kt(t,i[1],e.zoom)]}function Kl(e,t){return e[0]*t[0]+e[1]*t[1]+e[2]*t[2]+e[3]}function hi(e,t,i){let r=J1([e[0],e[1],e[2],t[0],t[1],t[2],i[0],i[1],i[2]]);if(r===0)return null;let a=qt([],[t[0],t[1],t[2]],[i[0],i[1],i[2]]),n=qt([],[i[0],i[1],i[2]],[e[0],e[1],e[2]]),s=qt([],[e[0],e[1],e[2]],[t[0],t[1],t[2]]),o=ke([],a,-e[3]);return ui(o,o,ke([],n,-t[3])),ui(o,o,ke([],s,-i[3])),ke(o,o,1/r),o}function Sx(e,t,i){let r=e[0]*i[0]+e[1]*i[1]+e[2]*i[2],a=t[0]*i[0]+t[1]*i[1]+t[2]*i[2];return a===0?null:(-r-i[3])/a}function Ns(e,t,i,r){let a=Math.sqrt(e*e+t*t),n=Math.sqrt(i*i+r*r);e/=a,t/=a,i/=n,r/=n;let s=e*i+t*r,o=Math.acos(s);return-t*i+e*r>0?o:-o}function Jt(e,t){let i=Vr(e,360),r=Vr(t,360),a=r-i,n=r>i?a-360:a+360;return Math.abs(a)<Math.abs(n)?a:n}function Vs(e,t){let i=Vr(e,Math.PI*2),r=Vr(t,Math.PI*2);return Math.min(Math.abs(i-r),Math.abs(i-r+Math.PI*2),Math.abs(i-r-Math.PI*2))}function Vr(e,t){return(e%t+t)%t}function js(e,t,i,r,a){return Sa(r,a,ee((e-t)/(i-t),0,1))}function Sa(e,t,i){return e*(1-i)+t*i}function Ex(e){let t=1/0,i=1/0,r=-1/0,a=-1/0;for(let n of e)t=Math.min(t,n.x),i=Math.min(i,n.y),r=Math.max(r,n.x),a=Math.max(a,n.y);return[t,i,r,a]}function Px(e){if(!e.length)return new Set;let t=Math.max(...e.map(l=>l.canonical.z)),i=1/0,r=-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<i&&(i=p),p>r&&(r=p),f<a&&(a=f),f>n&&(n=f)}let o=new Set;for(let l of s)(l.x===i||l.x===r||l.y===a||l.y===n)&&o.add(l.id);return o}function Cx(e){if(e<=0)return 0;if(e>=1)return 1;let t=e*e,i=t*e;return 4*(e<.5?i:3*(e-t)+i-.75)}function Jl(e,t,i,r){return Y1(e,t,i,r)}const Ql=Jl(.25,.1,.25,1);function ee(e,t,i){return Math.min(i,Math.max(t,e))}function ci(e,t,i){let r=i-t,a=((e-t)%r+r)%r+t;return a===t?i:a}function Z(e,...t){for(let i of t)for(let r in i)e[r]=i[r];return e}function dn(e,t){let i={};for(let r of t)r in e&&(i[r]=e[r]);return i}let Ax=1;function mp(){return Ax++}function Dx(e){return Math.log(e)/Math.LN2%1==0}function Ix(e){return e<=1?1:2**Math.ceil(Math.log(e)/Math.LN2)}function $t(e){return 2**e}function Et(e){return Math.log(e)/Math.LN2}function Qt(e,t,i){if(t<=0)return e;let r=1/t;return i===void 0||Math.abs(i)<1e-10?Math.round(e*r)/r:(i>0?Math.ceil(e*r-1e-9):Math.floor(e*r+1e-10))/r}function eu(e,t,i){let r={};for(let a in e)r[a]=t.call(this,e[a],a,e);return r}function gp(e,t,i){let r={};for(let a in e)t.call(this,e[a],a,e)&&(r[a]=e[a]);return r}function ki(e,t){if(Array.isArray(e)){if(!Array.isArray(t)||e.length!==t.length)return!1;for(let i=0;i<e.length;i++)if(!ki(e[i],t[i]))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 i in e)if(!ki(e[i],t[i]))return!1;return!0}return e===t}function Wt(e){return Array.isArray(e)?e.map(Wt):typeof e=="object"&&e?eu(e,Wt):e}const _p={};function le(e){_p[e]||(typeof console<"u"&&console.warn(e),_p[e]=!0)}function xr(e,t,i){return(i.y-e.y)*(t.x-e.x)>(t.y-e.y)*(i.x-e.x)}function Mx(e,t,i,r){let a=t.y-e.y,n=t.x-e.x,s=r.y-i.y,o=r.x-i.x,l=s*n-o*a;if(l===0)return null;let u=e.y-i.y,h=e.x-i.x,c=(o*u-s*h)/l;return new C(e.x+c*n,e.y+c*a)}function zx([e,t,i]){return t+=90,t*=Math.PI/180,i*=Math.PI/180,[e*Math.cos(t)*Math.sin(i),e*Math.sin(t)*Math.sin(i),e*Math.cos(i)]}function Ea(e){return typeof WorkerGlobalScope<"u"&&e!==void 0&&e instanceof WorkerGlobalScope}function Fx(e){let t=/(?:^|(?:\s*\,\s*))([^\x00-\x20\(\)<>@\,;\:\\"\/\[\]\?\=\{\}\x7F]+)(?:\=(?:([^\x00-\x20\(\)<>@\,;\:\\"\/\[\]\?\=\{\}\x7F]+)|(?:\"((?:[^"\\]|\\.)*)\")))?/g,i={};if(e.replace(t,(r,a,n,s)=>{let o=n||s;return i[a]=!o||o.toLowerCase(),""}),i["max-age"]){let r=parseInt(i["max-age"],10);isNaN(r)?delete i["max-age"]:i["max-age"]=r}return i}let tu=null;function Rx(e){if(tu==null){let t=e.navigator?e.navigator.userAgent:null;tu=!!e.safari||!!(t&&(/\b(iPad|iPhone|iPod)\b/.test(t)||t.match("Safari")&&!t.match("Chrome")))}return tu}function jr(e){return typeof ImageBitmap<"u"&&e instanceof ImageBitmap}const kx=async(e,t)=>{let i=new Blob([new Uint8Array(e)],{type:"image/png"});try{return createImageBitmap(i,t)}catch(r){throw Error(`Could not load image because of ${St(r).message}. Please make sure to use a supported image type such as PNG or JPEG. Note that SVGs are not supported.`)}},Lx=e=>new Promise((t,i)=>{let r=new Image;r.onload=()=>{t(r),URL.revokeObjectURL(r.src),r.onload=null,window.requestAnimationFrame(()=>r.src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAAC0lEQVQYV2NgAAIAAAUAAarVyFEAAAAASUVORK5CYII=")},r.onerror=()=>i(Error("Could not load image. Please make sure to use a supported image type such as PNG or JPEG. Note that SVGs are not supported."));let a=new Blob([new Uint8Array(e)],{type:"image/png"});r.src=URL.createObjectURL(a)});function Bx(e,t,i,r,a){let n=Math.max(-t,0)*4,s=(Math.max(0,i)-i)*r*4+n,o=r*4,l=Math.max(0,t),u=Math.max(0,i),h=Math.min(e.width,t+r),c=Math.min(e.height,i+a);return{rect:{x:l,y:u,width:h-l,height:c-u},layout:[{offset:s,stride:o}]}}async function $x(e,t,i,r,a){if(typeof VideoFrame>"u")throw Error("VideoFrame not supported");let n=new VideoFrame(e,{timestamp:0});try{let s=n==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(r*a*4);if(await n.copyTo(l,Bx(e,t,i,r,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 iu(e,t,i,r){return e.addEventListener(t,i,r),{unsubscribe:()=>{e.removeEventListener(t,i,r)}}}function Be(e){return e*Math.PI/180}function Li(e){return e/Math.PI*180}function yp(e,t){return e.roll==t.roll&&e.pitch==t.pitch&&e.bearing==t.bearing}function Ox(e){let t=new Float64Array(9);ex(t,e);let i=Li(-Math.asin(ee(t[2],-1,1))),r,a;return Math.hypot(t[5],t[8])<.001?(r=0,a=-Li(Math.atan2(t[3],t[4]))):(r=Li(t[5]===0&&t[8]===0?0:Math.atan2(t[5],t[8])),a=Li(t[1]===0&&t[0]===0?0:Math.atan2(t[1],t[0]))),{roll:r,pitch:i+90,bearing:a}}function vp(e,t,i){let r=hp(t.x-i.x,t.y-i.y),a=hp(e.x-i.x,e.y-i.y),n=r[0]*a[1]-r[1]*a[0];return Li(Math.atan2(n,wx(r,a)))}function xp(e,t,i){let r=new Float64Array(4);return Xl(r,e,t-90,i),r}const Bi=85.051129,bp={touchstart:!0,touchmove:!0,touchmoveWindow:!0,touchend:!0,touchcancel:!0},wp={dblclick:!0,click:!0,mouseover:!0,mouseout:!0,mousedown:!0,mousemove:!0,mousemoveWindow:!0,mouseup:!0,mouseupWindow:!0,contextmenu:!0,wheel:!0};function Nx(e,t){return bp[t]&&"touches"in e}function Vx(e,t){var a,n;if(!wp[t])return!1;let i=e,r=((n=(a=i==null?void 0:i.target)==null?void 0:a.ownerDocument)==null?void 0:n.defaultView)||window;return i instanceof r.MouseEvent||i instanceof r.WheelEvent}function jx(e){return bp[e]||wp[e]}const Tp="AbortError";var pn=class extends Error{constructor(e=Tp){super(e instanceof Error?e.message:e),this.name=Tp,e instanceof Error&&e.stack&&(this.stack=e.stack)}};function br(e){return e instanceof Error&&e.name==="AbortError"}function ru(e){if(e.aborted)throw new pn(e.reason)}const ei={MAX_PARALLEL_IMAGE_REQUESTS:16,MAX_PARALLEL_IMAGE_REQUESTS_PER_FRAME:8,MAX_TILE_CACHE_ZOOM_LEVELS:5,REGISTERED_PROTOCOLS:{},WORKER_URL:""};function Sp(e){return ei.REGISTERED_PROTOCOLS[e.substring(0,e.indexOf("://"))]}function Ux(e,t){ei.REGISTERED_PROTOCOLS[e]=t}function Gx(e){delete ei.REGISTERED_PROTOCOLS[e]}const au="global-dispatcher";var fn=class extends Error{constructor(e,t,i,r){super(`AJAXError: ${t} (${e}): ${i}`),this.status=e,this.statusText=t,this.url=i,this.body=r}};function nu(){var e;if(Ea(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 Zx=e=>{var t;return e.startsWith("file:")||((t=nu())==null?void 0:t.startsWith("file:"))&&!/^\w+:/.test(e)};async function qx(e,t){let i=new Request(e.url,{method:e.method||"GET",body:e.body,credentials:e.credentials,headers:e.headers,cache:e.cache,referrer:nu(),referrerPolicy:e.referrerPolicy,signal:t.signal});e.type==="json"&&!i.headers.has("Accept")&&i.headers.set("Accept","application/json");let r;try{r=await fetch(i)}catch(s){throw br(s)?s:new fn(0,St(s).message,e.url,new Blob)}if(!r.ok){let s=await r.blob();throw new fn(r.status,r.statusText,e.url,s)}let a;a=e.type==="arrayBuffer"||e.type==="image"?r.arrayBuffer():e.type==="json"?r.json():r.text();let n=await a;return ru(t.signal),{data:n,cacheControl:r.headers.get("Cache-Control"),expires:r.headers.get("Expires"),etag:r.headers.get("ETag")}}function Wx(e,t){return new Promise((i,r)=>{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=()=>{r(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){r(o);return}i({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")});r(new fn(a.status,a.statusText,e.url,s))}},t.signal.addEventListener("abort",()=>{a.abort(),r(new pn(t.signal.reason))}),a.send(e.body)})}const Us=async function(e,t){var i,r;if(e.url.includes("://")&&!/^https?:|^file:/.test(e.url)){let a=Sp(e.url);if(a){let n=await a(e,t);return!n.data&&e.type==="arrayBuffer"?Z(n,{data:new ArrayBuffer(0)}):n}if(Ea(self)&&((i=self.worker)!=null&&i.actor))return self.worker.actor.sendAsync({type:"GR",data:e,targetMapId:au},t)}if(!Zx(e.url)){if(fetch&&Request&&AbortController&&Object.hasOwn(Request.prototype,"signal"))return qx(e,t);if(Ea(self)&&((r=self.worker)!=null&&r.actor))return self.worker.actor.sendAsync({type:"GR",data:e,mustQueue:!0,targetMapId:au},t)}return Wx(e,t)},Gs=(e,t)=>Us(Z(e,{type:"json"}),t),Ep=(e,t)=>Us(Z(e,{type:"arrayBuffer"}),t);function Pp(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),i=window.location;return t.protocol===i.protocol&&t.host===i.host}const Hx=e=>{let t=window.document.createElement("video");return t.muted=!0,new Promise(i=>{t.onloadstart=()=>{i(t)};for(let r of e){let a=window.document.createElement("source");Pp(r)||(t.crossOrigin="Anonymous"),a.src=r,t.appendChild(a)}})};function Cp(e,t,i){var r;(r=i[e])!=null&&r.includes(t)||(i[e]||(i[e]=[]),i[e].push(t))}function su(e,t,i){if(i!=null&&i[e]){let r=i[e].indexOf(t);r!==-1&&i[e].splice(r,1)}}var ti=class{constructor(e,t={}){Z(this,t),this.type=e}},K=class extends ti{constructor(e,t={}){super("error",Z({error:e},t))}},ot=class{on(e,t){return this._listeners||(this._listeners={}),Cp(e,t,this._listeners),{unsubscribe:()=>{this.off(e,t)}}}off(e,t){return su(e,t,this._listeners),su(e,t,this._oneTimeListeners),this}once(e,t){return t?(this._oneTimeListeners||(this._oneTimeListeners={}),Cp(e,t,this._oneTimeListeners),this):new Promise(i=>this.once(e,i))}fire(e,t){var a,n,s,o;let i=typeof e=="string"?new ti(e,t||{}):e,r=i.type;if(this.listens(r)){i.target=this;let l=((n=(a=this._listeners)==null?void 0:a[r])==null?void 0:n.slice())??[];for(let c of l)c.call(this,i);let u=((o=(s=this._oneTimeListeners)==null?void 0:s[r])==null?void 0:o.slice())??[];for(let c of u)su(r,c,this._oneTimeListeners),c.call(this,i);let h=this._eventedParent;h&&(Z(i,typeof this._eventedParentData=="function"?this._eventedParentData():this._eventedParentData),h.fire(i))}else i instanceof K&&console.error(i.error);return this}listens(e){var t,i,r,a,n;return!!((i=(t=this._listeners)==null?void 0:t[e])!=null&&i.length||(a=(r=this._oneTimeListeners)==null?void 0:r[e])!=null&&a.length||(n=this._eventedParent)!=null&&n.listens(e))}setEventedParent(e,t){return this._eventedParent=e,this._eventedParentData=t,this}},Ap={$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,minimum:0,units:"meters",transition:!0,expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"fill-extrusion-base":{type:"number",default:0,minimum:0,units:"meters",transition:!0,requires:["fill-extrusion-height"],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"fill-extrusion-vertical-gradient":{type:"boolean",default:!0,transition:!1,expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"}},paint_line:{"line-opacity":{type:"number",default:1,minimum:0,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"line-layer-opacity":{type:"number",default:1,minimum:0,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom","global-state"]},"property-type":"data-constant"},"line-color":{type:"color",default:"#000000",transition:!0,requires:[{"!":"line-pattern"}],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"line-translate":{type:"array",value:"number",length:2,default:[0,0],transition:!0,units:"pixels",expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"line-translate-anchor":{type:"enum",values:{map:{},viewport:{}},default:"map",requires:["line-translate"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"line-width":{type:"number",default:1,minimum:0,transition:!0,units:"pixels",expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"line-gap-width":{type:"number",default:0,minimum:0,transition:!0,units:"pixels",expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"line-offset":{type:"number",default:0,transition:!0,units:"pixels",expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"line-blur":{type:"number",default:0,minimum:0,transition:!0,units:"pixels",expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"line-dasharray":{type:"array",value:"number",minimum:0,transition:!0,units:"line widths",requires:[{"!":"line-pattern"}],expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"cross-faded-data-driven"},"line-pattern":{type:"resolvedImage",transition:!0,expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"cross-faded-data-driven"},"line-gradient":{type:"color",transition:!1,requires:[{"!":"line-dasharray"},{"!":"line-pattern"},{source:"geojson",has:{lineMetrics:!0}}],expression:{interpolated:!0,parameters:["line-progress"]},"property-type":"color-ramp"}},paint_circle:{"circle-radius":{type:"number",default:5,minimum:0,transition:!0,units:"pixels",expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"circle-color":{type:"color",default:"#000000",transition:!0,expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"circle-blur":{type:"number",default:0,transition:!0,expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"circle-opacity":{type:"number",default:1,minimum:0,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"circle-translate":{type:"array",value:"number",length:2,default:[0,0],transition:!0,units:"pixels",expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"circle-translate-anchor":{type:"enum",values:{map:{},viewport:{}},default:"map",requires:["circle-translate"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"circle-pitch-scale":{type:"enum",values:{map:{},viewport:{}},default:"map",expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"circle-pitch-alignment":{type:"enum",values:{map:{},viewport:{}},default:"viewport",expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"circle-stroke-width":{type:"number",default:0,minimum:0,transition:!0,units:"pixels",expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"circle-stroke-color":{type:"color",default:"#000000",transition:!0,expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"circle-stroke-opacity":{type:"number",default:1,minimum:0,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"}},paint_heatmap:{"heatmap-radius":{type:"number",default:30,minimum:1,transition:!0,units:"pixels",expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"heatmap-weight":{type:"number",default:1,minimum:0,transition:!1,expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"heatmap-intensity":{type:"number",default:1,minimum:0,transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"heatmap-color":{type:"color",default:["interpolate",["linear"],["heatmap-density"],0,"rgba(0, 0, 255, 0)",.1,"royalblue",.3,"cyan",.5,"lime",.7,"yellow",1,"red"],transition:!1,expression:{interpolated:!0,parameters:["heatmap-density"]},"property-type":"color-ramp"},"heatmap-opacity":{type:"number",default:1,minimum:0,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"}},paint_symbol:{"icon-opacity":{type:"number",default:1,minimum:0,maximum:1,transition:!0,requires:["icon-image"],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"icon-color":{type:"color",default:"#000000",transition:!0,requires:["icon-image"],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"icon-halo-color":{type:"color",default:"rgba(0, 0, 0, 0)",transition:!0,requires:["icon-image"],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"icon-halo-width":{type:"number",default:0,minimum:0,transition:!0,units:"pixels",requires:["icon-image"],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"icon-halo-blur":{type:"number",default:0,minimum:0,transition:!0,units:"pixels",requires:["icon-image"],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"icon-translate":{type:"array",value:"number",length:2,default:[0,0],transition:!0,units:"pixels",requires:["icon-image"],expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"icon-translate-anchor":{type:"enum",values:{map:{},viewport:{}},default:"map",requires:["icon-image","icon-translate"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"text-opacity":{type:"number",default:1,minimum:0,maximum:1,transition:!0,requires:["text-field"],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"text-color":{type:"color",default:"#000000",transition:!0,overridable:!0,requires:["text-field"],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"text-halo-color":{type:"color",default:"rgba(0, 0, 0, 0)",transition:!0,requires:["text-field"],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"text-halo-width":{type:"number",default:0,minimum:0,transition:!0,units:"pixels",requires:["text-field"],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"text-halo-blur":{type:"number",default:0,minimum:0,transition:!0,units:"pixels",requires:["text-field"],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"text-translate":{type:"array",value:"number",length:2,default:[0,0],transition:!0,units:"pixels",requires:["text-field"],expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"text-translate-anchor":{type:"enum",values:{map:{},viewport:{}},default:"map",requires:["text-field","text-translate"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"}},paint_raster:{"raster-opacity":{type:"number",default:1,minimum:0,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"raster-hue-rotate":{type:"number",default:0,period:360,transition:!0,units:"degrees",expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"raster-brightness-min":{type:"number",default:0,minimum:0,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"raster-brightness-max":{type:"number",default:1,minimum:0,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"raster-saturation":{type:"number",default:0,minimum:-1,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"raster-contrast":{type:"number",default:0,minimum:-1,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},resampling:{type:"enum",values:{linear:{},nearest:{}},default:"linear",expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"raster-resampling":{type:"enum",values:{linear:{},nearest:{}},default:"linear",expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"raster-fade-duration":{type:"number",default:300,minimum:0,transition:!1,units:"milliseconds",expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"}},paint_hillshade:{"hillshade-illumination-direction":{type:"numberArray",default:335,minimum:0,maximum:359,transition:!1,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"hillshade-illumination-altitude":{type:"numberArray",default:45,minimum:0,maximum:90,transition:!1,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"hillshade-illumination-anchor":{type:"enum",values:{map:{},viewport:{}},default:"viewport",expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"hillshade-exaggeration":{type:"number",default:.5,minimum:0,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"hillshade-shadow-color":{type:"colorArray",default:"#000000",transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"hillshade-highlight-color":{type:"colorArray",default:"#FFFFFF",transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"hillshade-accent-color":{type:"color",default:"#000000",transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"hillshade-method":{type:"enum",values:{standard:{},basic:{},combined:{},igor:{},multidirectional:{}},default:"standard",expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},resampling:{type:"enum",values:{linear:{},nearest:{}},default:"linear",expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"}},"paint_color-relief":{"color-relief-opacity":{type:"number",default:1,minimum:0,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"color-relief-color":{type:"color",transition:!1,expression:{interpolated:!0,parameters:["elevation"]},"property-type":"color-ramp"},resampling:{type:"enum",values:{linear:{},nearest:{}},default:"linear",expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"}},paint_background:{"background-color":{type:"color",default:"#000000",transition:!0,requires:[{"!":"background-pattern"}],expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"background-pattern":{type:"resolvedImage",transition:!0,expression:{interpolated:!1,parameters:["zoom"]},"property-type":"cross-faded"},"background-opacity":{type:"number",default:1,minimum:0,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"}},transition:{duration:{type:"number",default:300,minimum:0,units:"milliseconds"},delay:{type:"number",default:0,minimum:0,units:"milliseconds"}},"property-type":{"data-driven":{type:"property-type"},"cross-faded":{type:"property-type"},"cross-faded-data-driven":{type:"property-type"},"color-ramp":{type:"property-type"},"data-constant":{type:"property-type"},constant:{type:"property-type"}},promoteId:{"*":{type:"string"}},interpolation:{type:"array",value:"interpolation_name",minimum:1},interpolation_name:{type:"enum",values:{linear:{syntax:{overloads:[{parameters:[],"output-type":"interpolation"}],parameters:[]}},exponential:{syntax:{overloads:[{parameters:["base"],"output-type":"interpolation"}],parameters:[{name:"base",type:"number literal"}]}},"cubic-bezier":{syntax:{overloads:[{parameters:["x1","y1","x2","y2"],"output-type":"interpolation"}],parameters:[{name:"x1",type:"number literal"},{name:"y1",type:"number literal"},{name:"x2",type:"number literal"},{name:"y2",type:"number literal"}]}}}}};const z=Ap,Xx=["type","source","source-layer","minzoom","maxzoom","filter","layout"];var $=class{constructor(t,i,r,a,n="error"){this.message=(t?`${t}: `:"")+r,a&&(this.identifier=a),this.severity=n,i!=null&&i.__line__&&(this.line=i.__line__)}};const mn={kind:"null"},V={kind:"number"},ie={kind:"string"},ce={kind:"boolean"},Ei={kind:"color"},Zs={kind:"projectionDefinition"},Ur={kind:"object"},re={kind:"value"},Yx={kind:"error"},qs={kind:"collator"},gn={kind:"formatted"},Ws={kind:"padding"},_n={kind:"colorArray"},Hs={kind:"numberArray"},yn={kind:"resolvedImage"},Xs={kind:"variableAnchorOffsetCollection"};function zt(e,t){return{kind:"array",itemType:e,N:t}}function Ze(e){if(e.kind==="array"){let t=Ze(e.itemType);return typeof e.N=="number"?`array<${t}, ${e.N}>`:e.itemType.kind==="value"?"array":`array<${t}>`}return e.kind}const Kx=[mn,V,ie,ce,Ei,Zs,gn,Ur,zt(re),Ws,Hs,_n,yn,Xs];function vn(e,t){if(t.kind==="error")return null;if(e.kind==="array"){if(t.kind==="array"&&(t.N===0&&t.itemType.kind==="value"||!vn(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 i of Kx)if(!vn(i,t))return null}}return`Expected ${Ze(e)} but found ${Ze(t)} instead.`}function ou(e,t){return t.some(i=>i.kind===e.kind)}function Gr(e,t){return t.some(i=>i==="null"?e===null:i==="array"?Array.isArray(e):i==="object"?e&&!Array.isArray(e)&&typeof e=="object":i===typeof e)}function wr(e,t){return e.kind==="array"&&t.kind==="array"?e.itemType.kind===t.itemType.kind&&typeof e.N=="number":e.kind===t.kind}const Dp=.96422,Ip=.82521,Mp=4/29,lu=6/29,zp=3*lu*lu,Jx=Math.PI/180,Qx=180/Math.PI;function Fp(e){return e%=360,e<0&&(e+=360),e}function Rp([e,t,i,r]){e=uu(e),t=uu(t),i=uu(i);let a,n,s=hu((.2225045*e+.7168786*t+.0606169*i)/1);e===t&&t===i?a=n=s:(a=hu((.4360747*e+.3850649*t+.1430804*i)/Dp),n=hu((.0139322*e+.0971045*t+.7141733*i)/Ip));let o=116*s-16;return[o<0?0:o,500*(a-s),200*(s-n),r]}function uu(e){return e<=.04045?e/12.92:((e+.055)/1.055)**2.4}function hu(e){return e>.008856451679035631?e**(1/3):e/zp+Mp}function kp([e,t,i,r]){let a=(e+16)/116,n=isNaN(t)?a:a+t/500,s=isNaN(i)?a:a-i/200;return a=1*du(a),n=Dp*du(n),s=Ip*du(s),[cu(3.1338561*n-1.6168667*a-.4906146*s),cu(-.9787684*n+1.9161415*a+.033454*s),cu(.0719453*n-.2289914*a+1.4052427*s),r]}function cu(e){return e=e<=.00304?12.92*e:1.055*e**(1/2.4)-.055,e<0?0:e>1?1:e}function du(e){return e>lu?e*e*e:zp*(e-Mp)}function eb(e){let[t,i,r,a]=Rp(e),n=Math.sqrt(i*i+r*r);return[Math.round(n*1e4)?Fp(Math.atan2(r,i)*Qx):NaN,n,t,a]}function tb([e,t,i,r]){return e=isNaN(e)?0:e*Jx,kp([i,Math.cos(e)*t,Math.sin(e)*t,r])}function ib([e,t,i,r]){e=Fp(e),t/=100,i/=100;function a(n){let s=(n+e/30)%12,o=t*Math.min(i,1-i);return i-o*Math.max(-1,Math.min(s-3,9-s,1))}return[a(0),a(8),a(4),r]}const rb=Object.hasOwn||function(e,t){return Object.prototype.hasOwnProperty.call(e,t)};function xn(e,t){return rb(e,t)?e[t]:void 0}function ab(e){if(e=e.toLowerCase().trim(),e==="transparent")return[0,0,0,0];let t=xn(nb,e);if(t){let[r,a,n]=t;return[r/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 r=e.length<6?1:2,a=1;return[Ys(e.slice(a,a+=r)),Ys(e.slice(a,a+=r)),Ys(e.slice(a,a+=r)),Ys(e.slice(a,a+r)||"ff")]}if(e.startsWith("rgb")){let r=e.match(/^rgba?\(\s*([\de.+-]+)(%)?(?:\s+|\s*(,)\s*)([\de.+-]+)(%)?(?:\s+|\s*(,)\s*)([\de.+-]+)(%)?(?:\s*([,\/])\s*([\de.+-]+)(%)?)?\s*\)$/);if(r){let[a,n,s,o,l,u,h,c,d,p,f,m]=r,g=[o||" ",h||" ",p].join("");if(g===" "||g===" /"||g===",,"||g===",,,"){let _=[s,u,d].join(""),y=_==="%%%"?100:_===""?255:0;if(y){let x=[Pa(+n/y,0,1),Pa(+l/y,0,1),Pa(+c/y,0,1),f?Lp(+f,m):1];if(Bp(x))return x}}return}}let i=e.match(/^hsla?\(\s*([\de.+-]+)(?:deg)?(?:\s+|\s*(,)\s*)([\de.+-]+)%(?:\s+|\s*(,)\s*)([\de.+-]+)%(?:\s*([,\/])\s*([\de.+-]+)(%)?)?\s*\)$/);if(i){let[r,a,n,s,o,l,u,h,c]=i,d=[n||" ",o||" ",u].join("");if(d===" "||d===" /"||d===",,"||d===",,,"){let p=[+a,Pa(+s,0,100),Pa(+l,0,100),h?Lp(+h,c):1];if(Bp(p))return ib(p)}}}function Ys(e){return parseInt(e.padEnd(2,e),16)/255}function Lp(e,t){return Pa(t?e/100:e,0,1)}function Pa(e,t,i){return Math.min(Math.max(t,e),i)}function Bp(e){return!e.some(Number.isNaN)}const nb={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 Tr(e,t,i){return e+i*(t-e)}function Ca(e,t,i){return e.map((r,a)=>Tr(r,t[a],i))}function sb(e){return e==="rgb"||e==="hcl"||e==="lab"}var te=(bt=class{constructor(t,i,r,a=1,n=!0){this.r=t,this.g=i,this.b=r,this.a=a,n||(this.r*=a,this.g*=a,this.b*=a,a||this.overwriteGetter("rgb",[t,i,r,a]))}static parse(t){if(t instanceof bt)return t;if(typeof t!="string")return;let i=ab(t);if(i)return new bt(...i,!1)}get rgb(){let{r:t,g:i,b:r,a}=this,n=a||1/0;return this.overwriteGetter("rgb",[t/n,i/n,r/n,a])}get hcl(){return this.overwriteGetter("hcl",eb(this.rgb))}get lab(){return this.overwriteGetter("lab",Rp(this.rgb))}overwriteGetter(t,i){return Object.defineProperty(this,t,{value:i}),i}toString(){let[t,i,r,a]=this.rgb;return`rgba(${[t,i,r].map(n=>Math.round(n*255)).join(",")},${a})`}static interpolate(t,i,r,a="rgb"){switch(a){case"rgb":{let[n,s,o,l]=Ca(t.rgb,i.rgb,r);return new bt(n,s,o,l,!1)}case"hcl":{let[n,s,o,l]=t.hcl,[u,h,c,d]=i.hcl,p,f;if(!isNaN(n)&&!isNaN(u)){let x=u-n;u>n&&x>180?x-=360:u<n&&n-u>180&&(x+=360),p=n+r*x}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]=tb([p,f??Tr(s,h,r),Tr(o,c,r),Tr(l,d,r)]);return new bt(m,g,_,y,!1)}case"lab":{let[n,s,o,l]=kp(Ca(t.lab,i.lab,r));return new bt(n,s,o,l,!1)}}}},bt.black=new bt(0,0,0,1),bt.white=new bt(1,1,1,1),bt.transparent=new bt(0,0,0,0),bt.red=new bt(1,0,0,1),bt);const ob=["bottom","center","top"];var pu=class{constructor(t,i,r,a,n,s){this.text=t,this.image=i,this.scale=r,this.fontStack=a,this.textColor=n,this.verticalAlign=s}},Qi=class $l{constructor(t){this.sections=t}static fromString(t){return new $l([new pu(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 $l?t:$l.fromString(t)}toString(){return this.sections.length===0?"":this.sections.map(t=>t.text).join("")}},$i=class Ds{constructor(t){this.values=t.slice()}static parse(t){if(t instanceof Ds)return t;if(typeof t=="number")return new Ds([t,t,t,t]);if(Array.isArray(t)&&!(t.length<1||t.length>4)){for(let i of t)if(typeof i!="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 Ds(t)}}toString(){return JSON.stringify(this.values)}static interpolate(t,i,r){return new Ds(Ca(t.values,i.values,r))}},Oi=class Is{constructor(t){this.values=t.slice()}static parse(t){if(t instanceof Is)return t;if(typeof t=="number")return new Is([t]);if(Array.isArray(t)){for(let i of t)if(typeof i!="number")return;return new Is(t)}}toString(){return JSON.stringify(this.values)}static interpolate(t,i,r){return new Is(Ca(t.values,i.values,r))}},di=class Ms{constructor(t){this.values=t.slice()}static parse(t){if(t instanceof Ms)return t;if(typeof t=="string"){let r=te.parse(t);return r?new Ms([r]):void 0}if(!Array.isArray(t))return;let i=[];for(let r of t){if(typeof r!="string")return;let a=te.parse(r);if(!a)return;i.push(a)}return new Ms(i)}toString(){return JSON.stringify(this.values)}static interpolate(t,i,r,a="rgb"){let n=[];if(t.values.length!=i.values.length)throw Error(`colorArray: Arrays have mismatched length (${t.values.length} vs. ${i.values.length}), cannot interpolate.`);for(let s=0;s<t.values.length;s++)n.push(te.interpolate(t.values[s],i.values[s],r,a));return new Ms(n)}},$e=class extends Error{constructor(t,i){super(t),this.name="RuntimeError",this.path=i}toJSON(){return this.message}};const lb=new Set(["center","left","right","top","bottom","top-left","top-right","bottom-left","bottom-right"]);var Ni=class Ol{constructor(t){this.values=t.slice()}static parse(t){if(t instanceof Ol)return t;if(!(!Array.isArray(t)||t.length<1||t.length%2!=0)){for(let i=0;i<t.length;i+=2){let r=t[i],a=t[i+1];if(typeof r!="string"||!lb.has(r)||!Array.isArray(a)||a.length!==2||typeof a[0]!="number"||typeof a[1]!="number")return}return new Ol(t)}}toString(){return JSON.stringify(this.values)}static interpolate(t,i,r,a){let n=t.values,s=i.values;if(n.length!==s.length)throw new $e(`Cannot interpolate values of different length. from: ${t.toString()}, to: ${i.toString()}`,a);let o=[];for(let l=0;l<n.length;l+=2){if(n[l]!==s[l])throw new $e(`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([Tr(u,c,r),Tr(h,d,r)])}return new Ol(o)}},Vi=class n1{constructor(t){this.name=t.name,this.available=t.available}toString(){return this.name}static fromString(t){return t?new n1({name:t,available:!1}):null}},Sr=class un{constructor(t,i,r){this.from=t,this.to=i,this.transition=r}toString(){return this.from===this.to&&this.transition===1?this.from:JSON.stringify([this.from,this.to,this.transition])}static interpolate(t,i,r){return new un(t,i,r)}static parse(t){if(t instanceof un)return t;if(Array.isArray(t)&&t.length===3&&typeof t[0]=="string"&&typeof t[1]=="string"&&typeof t[2]=="number")return new un(t[0],t[1],t[2]);if(typeof t=="object"&&typeof t.from=="string"&&typeof t.to=="string"&&typeof t.transition=="number")return new un(t.from,t.to,t.transition);if(typeof t=="string")return new un(t,t,1)}},fu=class{constructor(t,i,r){this.sensitivity=t?i?"variant":"case":i?"accent":"base",this.locale=r,this.collator=new Intl.Collator(this.locale?this.locale:[],{sensitivity:this.sensitivity,usage:"search"})}compare(t,i){return this.collator.compare(t,i)}resolvedLocale(){return new Intl.Collator(this.locale?this.locale:[]).resolvedOptions().locale}};function $p(e,t,i,r){return typeof e=="number"&&e>=0&&e<=255&&typeof t=="number"&&t>=0&&t<=255&&typeof i=="number"&&i>=0&&i<=255?r===void 0||typeof r=="number"&&r>=0&&r<=1?null:`Invalid rgba value [${[e,t,i,r].join(", ")}]: 'a' must be between 0 and 1.`:`Invalid rgba value [${(typeof r=="number"?[e,t,i,r]:[e,t,i]).join(", ")}]: 'r', 'g', and 'b' must be between 0 and 255.`}function Aa(e){if(e===null||typeof e=="string"||typeof e=="boolean"||typeof e=="number"||e instanceof Sr||e instanceof te||e instanceof fu||e instanceof Qi||e instanceof $i||e instanceof Oi||e instanceof di||e instanceof Ni||e instanceof Vi)return!0;if(Array.isArray(e)){for(let t of e)if(!Aa(t))return!1;return!0}if(typeof e=="object"){for(let t in e)if(!Aa(e[t]))return!1;return!0}return!1}function Je(e){if(e===null)return mn;if(typeof e=="string")return ie;if(typeof e=="boolean")return ce;if(typeof e=="number")return V;if(e instanceof te)return Ei;if(e instanceof Sr)return Zs;if(e instanceof fu)return qs;if(e instanceof Qi)return gn;if(e instanceof $i)return Ws;if(e instanceof Oi)return Hs;if(e instanceof di)return _n;if(e instanceof Ni)return Xs;if(e instanceof Vi)return yn;if(Array.isArray(e)){let t=e.length,i;for(let r of e){let a=Je(r);if(!i)i=a;else{if(i===a)continue;i=re;break}}return zt(i||re,t)}return Ur}function bn(e){let t=typeof e;return e===null?"":t==="string"||t==="number"||t==="boolean"?String(e):e instanceof te||e instanceof Sr||e instanceof Qi||e instanceof $i||e instanceof Oi||e instanceof di||e instanceof Ni||e instanceof Vi?e.toString():JSON.stringify(e)}var Da=class s1{constructor(t,i){this.type=t,this.value=i}static parse(t,i){if(t.length!==2)return i.error(`'literal' expression requires exactly one argument, but found ${t.length-1} instead.`);if(!Aa(t[1]))return i.error(`invalid value of type "${typeof t[1]}"`);let r=t[1],a=Je(r),n=i.expectedType;return a.kind==="array"&&a.N===0&&n&&n.kind==="array"&&(typeof n.N!="number"||n.N===0)&&(a=n),new s1(a,r)}evaluate(){return this.value}eachChild(){}outputDefined(){return!0}};const ub=["Unknown","Point","LineString","Polygon"];var Op=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"?ub[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 i=this._parseColorCache.get(t);return i||(i=te.parse(t),this._parseColorCache.set(t,i)),i}};function Ks(e,t,i){let r=e.length-1,a=0,n=r,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===r||t<l)return s;a=s+1}else if(o>t)n=s-1;else throw new $e("Input is not a number.",i);return 0}var mu=class o1{constructor(t,i,r,a){this.type=t,this.input=i,this.key=a,this.labels=[],this.outputs=[];for(let[n,s]of r)this.labels.push(n),this.outputs.push(s)}static parse(t,i){if(t.length-1<4)return i.error(`Expected at least 4 arguments, but found only ${t.length-1}.`);if((t.length-1)%2!=0)return i.error("Expected an even number of arguments.");let r=i.parse(t[1],1,V);if(!r)return null;let a=[],n=null;i.expectedType&&i.expectedType.kind!=="value"&&(n=i.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 i.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 i.error('Input/output pairs for "step" expressions must be arranged with input values in strictly ascending order.',u);let c=i.parse(l,h,n);if(!c)return null;n||(n=c.type),a.push([o,c])}return new o1(n,r,a,i.key)}evaluate(t){let i=this.labels,r=this.outputs;if(i.length===1)return r[0].evaluate(t);let a=this.input.evaluate(t);if(a<=i[0])return r[0].evaluate(t);let n=i.length;return a>=i[n-1]?r[n-1].evaluate(t):r[Ks(i,a,this.key)].evaluate(t)}eachChild(t){t(this.input);for(let i of this.outputs)t(i)}outputDefined(){return this.outputs.every(t=>t.outputDefined())}};function hb(e,t,i,r){let a=3*e,n=3*(i-e)-a,s=1-a-n,o=3*t,l=3*(r-t)-o,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 pi=class Zd{constructor(t,i,r,a,n,s){this.type=t,this.operator=i,this.interpolation=r,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,i,r,a){let n=0;if(t.name==="exponential")n=gu(i,t.base,r,a);else if(t.name==="linear")n=gu(i,1,r,a);else if(t.name==="cubic-bezier"){let s=t.controlPoints;n=hb(s[0],s[1],s[2],s[3])(gu(i,1,r,a))}return n}static parse(t,i){let[r,a,n,...s]=t;if(!Array.isArray(a)||a.length===0)return i.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 i.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 i.error("Cubic bezier interpolation requires four numeric arguments with values between 0 and 1.",1);a={name:"cubic-bezier",controlPoints:u}}else return i.error(`Unknown interpolation type ${String(a[0])}`,1,0);if(t.length-1<4)return i.error(`Expected at least 4 arguments, but found only ${t.length-1}.`);if((t.length-1)%2!=0)return i.error("Expected an even number of arguments.");if(n=i.parse(n,2,V),!n)return null;let o=[],l=null;(r==="interpolate-hcl"||r==="interpolate-lab")&&i.expectedType!=_n?l=Ei:i.expectedType&&i.expectedType.kind!=="value"&&(l=i.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 i.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 i.error('Input/output pairs for "interpolate" expressions must be arranged with input values in strictly ascending order.',d);let f=i.parse(c,p,l);if(!f)return null;l||(l=f.type),o.push([h,f])}return!wr(l,V)&&!wr(l,Zs)&&!wr(l,Ei)&&!wr(l,Ws)&&!wr(l,Hs)&&!wr(l,_n)&&!wr(l,Xs)&&!wr(l,zt(V))?i.error(`Type ${Ze(l)} is not interpolatable.`):new Zd(l,r,a,n,o,i.key)}evaluate(t){let i=this.labels,r=this.outputs;if(i.length===1)return r[0].evaluate(t);let a=this.input.evaluate(t);if(a<=i[0])return r[0].evaluate(t);let n=i.length;if(a>=i[n-1])return r[n-1].evaluate(t);let s=Ks(i,a,this.key),o=i[s],l=i[s+1],u=Zd.interpolationFactor(this.interpolation,a,o,l),h=r[s].evaluate(t),c=r[s+1].evaluate(t);switch(this.operator){case"interpolate":switch(this.type.kind){case"number":return Tr(h,c,u);case"color":return te.interpolate(h,c,u);case"padding":return $i.interpolate(h,c,u);case"colorArray":return di.interpolate(h,c,u);case"numberArray":return Oi.interpolate(h,c,u);case"variableAnchorOffsetCollection":return Ni.interpolate(h,c,u,this.key);case"array":return Ca(h,c,u);case"projectionDefinition":return Sr.interpolate(h,c,u)}case"interpolate-hcl":switch(this.type.kind){case"color":return te.interpolate(h,c,u,"hcl");case"colorArray":return di.interpolate(h,c,u,"hcl")}case"interpolate-lab":switch(this.type.kind){case"color":return te.interpolate(h,c,u,"lab");case"colorArray":return di.interpolate(h,c,u,"lab")}}}eachChild(t){t(this.input);for(let i of this.outputs)t(i)}outputDefined(){return this.outputs.every(t=>t.outputDefined())}};function gu(e,t,i,r){let a=r-i,n=e-i;return a===0?0:t===1?n/a:(t**+n-1)/(t**+a-1)}const Oe={color:te.interpolate,number:Tr,padding:$i.interpolate,numberArray:Oi.interpolate,colorArray:di.interpolate,variableAnchorOffsetCollection:Ni.interpolate,array:Ca};var Np=class l1{constructor(t){this.type=gn,this.sections=t}static parse(t,i){if(t.length<2)return i.error("Expected at least one argument.");let r=t[1];if(!Array.isArray(r)&&typeof r=="object")return i.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=i.parse(o["font-scale"],1,V),!l))return null;let u=null;if(o["text-font"]&&(u=i.parse(o["text-font"],1,zt(ie)),!u))return null;let h=null;if(o["text-color"]&&(h=i.parse(o["text-color"],1,Ei),!h))return null;let c=null;if(o["vertical-align"]){if(typeof o["vertical-align"]=="string"&&!ob.includes(o["vertical-align"]))return i.error(`'vertical-align' must be one of: 'bottom', 'center', 'top' but found '${o["vertical-align"]}' instead.`);if(c=i.parse(o["vertical-align"],1,ie),!c)return null}let d=a[a.length-1];d.scale=l,d.font=u,d.textColor=h,d.verticalAlign=c}else{let l=i.parse(t[s],1,re);if(!l)return null;let u=l.type.kind;if(u!=="string"&&u!=="value"&&u!=="null"&&u!=="resolvedImage")return i.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 l1(a)}evaluate(t){return new Qi(this.sections.map(i=>{let r=i.content.evaluate(t);return Je(r)===yn?new pu("",r,null,null,null,i.verticalAlign?i.verticalAlign.evaluate(t):null):new pu(bn(r),null,i.scale?i.scale.evaluate(t):null,i.font?i.font.evaluate(t).join(","):null,i.textColor?i.textColor.evaluate(t):null,i.verticalAlign?i.verticalAlign.evaluate(t):null)}))}eachChild(t){for(let i of this.sections)t(i.content),i.scale&&t(i.scale),i.font&&t(i.font),i.textColor&&t(i.textColor),i.verticalAlign&&t(i.verticalAlign)}outputDefined(){return!1}};function Vp(e,t,i=0,r=e.length-1,a=cb){for(;r>i;){if(r-i>600){let l=r-i+1,u=t-i+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);Vp(e,t,Math.max(i,Math.floor(t-u*c/l+d)),Math.min(r,Math.floor(t+(l-u)*c/l+d)),a)}let n=e[t],s=i,o=r;for(wn(e,i,t),a(e[r],n)>0&&wn(e,i,r);s<o;){for(wn(e,s,o),s++,o--;a(e[s],n)<0;)s++;for(;a(e[o],n)>0;)o--}a(e[i],n)===0?wn(e,i,o):(o++,wn(e,o,r)),o<=t&&(i=o+1),t<=o&&(r=o-1)}}function wn(e,t,i){let r=e[t];e[t]=e[i],e[i]=r}function cb(e,t){return e<t?-1:+(e>t)}function Js(e,t){if(e.length<=1)return[e];let i=[],r,a;for(let n of e){let s=pb(n);s!==0&&(n.area=Math.abs(s),a===void 0&&(a=s<0),a===s<0?(r&&i.push(r),r=[n]):r.push(n))}if(r&&i.push(r),t>1)for(let n=0;n<i.length;n++)i[n].length<=t||(Vp(i[n],t,1,i[n].length-1,db),i[n]=i[n].slice(0,t));return i}function db(e,t){return t.area-e.area}function pb(e){let t=0;for(let i=0,r=e.length,a=r-1,n,s;i<r;a=i++)n=e[i],s=e[a],t+=(s.x-n.x)*(n.y+s.y);return t}const Qs={string:ie,number:V,boolean:ce,object:Ur};var er=class u1{constructor(t,i,r){this.type=t,this.args=i,this.key=r}static parse(t,i){if(t.length<2)return i.error("Expected at least one argument.");let r=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 i.error('The item type argument of "array" must be one of string, number, boolean',1);o=Qs[u],r++}else o=re;let l;if(t.length>3){if(t[2]!==null&&(typeof t[2]!="number"||t[2]<0||t[2]!==Math.floor(t[2])))return i.error('The length argument to "array" must be a positive integer literal',2);l=t[2],r++}a=zt(o,l)}else{if(!Qs[n])throw Error(`Types doesn't contain name = ${n}`);a=Qs[n]}let s=[];for(;r<t.length;r++){let o=i.parse(t[r],r,re);if(!o)return null;s.push(o)}return new u1(a,s,i.key)}evaluate(t){for(let i=0;i<this.args.length;i++){let r=this.args[i].evaluate(t);if(!vn(this.type,Je(r)))return r;if(i===this.args.length-1)throw new $e(`Expected value to be of type ${Ze(this.type)}, but found ${Ze(Je(r))} instead.`,this.key)}throw Error()}eachChild(t){this.args.forEach(t)}outputDefined(){return this.args.every(t=>t.outputDefined())}};const jp={"to-boolean":ce,"to-color":Ei,"to-number":V,"to-string":ie};var Ia=class h1{constructor(t,i,r){this.type=t,this.args=i,this.key=r}static parse(t,i){if(t.length<2)return i.error("Expected at least one argument.");let r=t[0];if(!jp[r])throw Error(`Can't parse ${r} as it is not part of the known types`);if((r==="to-boolean"||r==="to-string")&&t.length!==2)return i.error("Expected one argument.");let a=jp[r],n=[];for(let s=1;s<t.length;s++){let o=i.parse(t[s],s,re);if(!o)return null;n.push(o)}return new h1(a,n,i.key)}evaluate(t){switch(this.type.kind){case"boolean":return!!this.args[0].evaluate(t);case"color":{let i,r;for(let a of this.args){if(i=a.evaluate(t),r=null,i instanceof te)return i;if(typeof i=="string"){let n=t.parseColor(i);if(n)return n}else if(Array.isArray(i)&&(r=i.length<3||i.length>4?`Invalid rgba value ${JSON.stringify(i)}: expected an array containing either three or four numeric values.`:$p(i[0],i[1],i[2],i[3]),!r))return new te(i[0]/255,i[1]/255,i[2]/255,i[3])}throw new $e(r||`Could not parse color from value '${typeof i=="string"?i:JSON.stringify(i)}'`,this.key)}case"padding":{let i;for(let r of this.args){i=r.evaluate(t);let a=$i.parse(i);if(a)return a}throw new $e(`Could not parse padding from value '${typeof i=="string"?i:JSON.stringify(i)}'`,this.key)}case"numberArray":{let i;for(let r of this.args){i=r.evaluate(t);let a=Oi.parse(i);if(a)return a}throw new $e(`Could not parse numberArray from value '${typeof i=="string"?i:JSON.stringify(i)}'`,this.key)}case"colorArray":{let i;for(let r of this.args){i=r.evaluate(t);let a=di.parse(i);if(a)return a}throw new $e(`Could not parse colorArray from value '${typeof i=="string"?i:JSON.stringify(i)}'`,this.key)}case"variableAnchorOffsetCollection":{let i;for(let r of this.args){i=r.evaluate(t);let a=Ni.parse(i);if(a)return a}throw new $e(`Could not parse variableAnchorOffsetCollection from value '${typeof i=="string"?i:JSON.stringify(i)}'`,this.key)}case"number":{let i=null;for(let r of this.args){if(i=r.evaluate(t),i===null)return 0;let a=Number(i);if(!isNaN(a))return a}throw new $e(`Could not convert ${JSON.stringify(i)} to number.`,this.key)}case"formatted":return Qi.fromString(bn(this.args[0].evaluate(t)));case"resolvedImage":return Vi.fromString(bn(this.args[0].evaluate(t)));case"projectionDefinition":{let i=this.args[0].evaluate(t);if(Sr.parse(i))return i;throw new $e(`Could not parse projectionDefinition from value '${typeof i=="string"?i:JSON.stringify(i)}'`,this.key)}default:return bn(this.args[0].evaluate(t))}}eachChild(t){this.args.forEach(t)}outputDefined(){return this.args.every(t=>t.outputDefined())}},Up=class c1{constructor(t,i){this.type=i.type,this.bindings=[].concat(t),this.result=i}evaluate(t){return this.result.evaluate(t)}eachChild(t){for(let i of this.bindings)t(i[1]);t(this.result)}static parse(t,i){if(t.length<4)return i.error(`Expected at least 3 arguments, but found ${t.length-1} instead.`);let r=[];for(let n=1;n<t.length-1;n+=2){let s=t[n];if(typeof s!="string")return i.error(`Expected string, but found ${typeof s} instead.`,n);if(/[^a-zA-Z0-9_]/.test(s))return i.error("Variable names must contain only alphanumeric characters or '_'.",n);let o=i.parse(t[n+1],n+1);if(!o)return null;r.push([s,o])}let a=i.parse(t[t.length-1],t.length-1,i.expectedType,r);return a?new c1(r,a):null}outputDefined(){return this.result.outputDefined()}},Gp=class d1{constructor(t,i){this.type=i.type,this.name=t,this.boundExpression=i}static parse(t,i){if(t.length!==2||typeof t[1]!="string")return i.error("'var' expression requires exactly one string literal argument.");let r=t[1];return i.scope.has(r)?new d1(r,i.scope.get(r)):i.error(`Unknown variable "${r}". Make sure "${r}" has been bound in an enclosing "let" expression before using it.`,1)}evaluate(t){return this.boundExpression.evaluate(t)}eachChild(){}outputDefined(){return!1}},fb=class p1{constructor(t,i,r,a){this.type=t,this.index=i,this.input=r,this.key=a}static parse(t,i){if(t.length!==3)return i.error(`Expected 2 arguments, but found ${t.length-1} instead.`);let r=i.parse(t[1],1,V),a=i.parse(t[2],2,zt(i.expectedType||re));if(!r||!a)return null;let n=a.type;return new p1(n.itemType,r,a,i.key)}evaluate(t){let i=this.index.evaluate(t),r=this.input.evaluate(t);if(i<0)throw new $e(`Array index out of bounds: ${i} < 0.`,this.key);if(i>=r.length)throw new $e(`Array index out of bounds: ${i} > ${r.length-1}.`,this.key);if(i!==Math.floor(i))throw new $e(`Array index must be an integer, but found ${i} instead.`,this.key);return r[i]}eachChild(t){t(this.index),t(this.input)}outputDefined(){return!1}},mb=class f1{constructor(t,i,r){this.needle=t,this.haystack=i,this.key=r,this.type=ce}static parse(t,i){if(t.length!==3)return i.error(`Expected 2 arguments, but found ${t.length-1} instead.`);let r=i.parse(t[1],1,re),a=i.parse(t[2],2,re);return!r||!a?null:ou(r.type,[ce,ie,V,mn,re])?new f1(r,a,i.key):i.error(`Expected first argument to be of type boolean, string, number or null, but found ${Ze(r.type)} instead`)}evaluate(t){let i=this.needle.evaluate(t),r=this.haystack.evaluate(t);if(!r)return!1;if(!Gr(i,["boolean","string","number","null"]))throw new $e(`Expected first argument to be of type boolean, string, number or null, but found ${Ze(Je(i))} instead.`,this.key);if(!Gr(r,["string","array"]))throw new $e(`Expected second argument to be of type array or string, but found ${Ze(Je(r))} instead.`,this.key);return r.indexOf(i)>=0}eachChild(t){t(this.needle),t(this.haystack)}outputDefined(){return!0}},gb=class qd{constructor(t,i,r,a){this.needle=t,this.haystack=i,this.key=r,this.fromIndex=a,this.type=V}static parse(t,i){if(t.length<=2||t.length>=5)return i.error(`Expected 2 or 3 arguments, but found ${t.length-1} instead.`);let r=i.parse(t[1],1,re),a=i.parse(t[2],2,re);if(!r||!a)return null;if(!ou(r.type,[ce,ie,V,mn,re]))return i.error(`Expected first argument to be of type boolean, string, number or null, but found ${Ze(r.type)} instead`);if(t.length===4){let n=i.parse(t[3],3,V);return n?new qd(r,a,i.key,n):null}return new qd(r,a,i.key)}evaluate(t){let i=this.needle.evaluate(t),r=this.haystack.evaluate(t);if(!Gr(i,["boolean","string","number","null"]))throw new $e(`Expected first argument to be of type boolean, string, number or null, but found ${Ze(Je(i))} instead.`,this.key);let a;if(this.fromIndex&&(a=this.fromIndex.evaluate(t)),Gr(r,["string"])){let n=r.indexOf(i,a);return n===-1?-1:[...r.slice(0,n)].length}if(Gr(r,["array"]))return r.indexOf(i,a);throw new $e(`Expected second argument to be of type array or string, but found ${Ze(Je(r))} instead.`,this.key)}eachChild(t){t(this.needle),t(this.haystack),this.fromIndex&&t(this.fromIndex)}outputDefined(){return!1}},_b=class m1{constructor(t,i,r,a,n,s){this.inputType=t,this.type=i,this.input=r,this.cases=a,this.outputs=n,this.otherwise=s}static parse(t,i){if(t.length<5)return i.error(`Expected at least 4 arguments, but found only ${t.length-1}.`);if(t.length%2!=1)return i.error("Expected an even number of arguments.");let r,a;i.expectedType&&i.expectedType.kind!=="value"&&(a=i.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=i.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(!r)r=Je(f);else if(d.checkSubtype(r,Je(f)))return null;if(n[String(f)]!==void 0)return d.error("Branch labels must be unique.");n[String(f)]=s.length}let p=i.parse(c,u,a);if(!p)return null;a||(a=p.type),s.push(p)}let o=i.parse(t[1],1,re);if(!o)return null;let l=i.parse(t[t.length-1],t.length-1,a);return!l||o.type.kind!=="value"&&i.concat(1).checkSubtype(r,o.type)?null:new m1(r,a,o,n,s,l)}evaluate(t){let i=this.input.evaluate(t);return(Je(i)===this.inputType&&this.outputs[this.cases[i]]||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()}},yb=class g1{constructor(t,i,r){this.type=t,this.branches=i,this.otherwise=r}static parse(t,i){if(t.length<4)return i.error(`Expected at least 3 arguments, but found only ${t.length-1}.`);if(t.length%2!=0)return i.error("Expected an odd number of arguments.");let r;i.expectedType&&i.expectedType.kind!=="value"&&(r=i.expectedType);let a=[];for(let s=1;s<t.length-1;s+=2){let o=i.parse(t[s],s,ce);if(!o)return null;let l=i.parse(t[s+1],s+1,r);if(!l)return null;a.push([o,l]),r||(r=l.type)}let n=i.parse(t[t.length-1],t.length-1,r);if(!n)return null;if(!r)throw Error("Can't infer output type");return new g1(r,a,n)}evaluate(t){for(let[i,r]of this.branches)if(i.evaluate(t))return r.evaluate(t);return this.otherwise.evaluate(t)}eachChild(t){for(let[i,r]of this.branches)t(i),t(r);t(this.otherwise)}outputDefined(){return this.branches.every(([t,i])=>i.outputDefined())&&this.otherwise.outputDefined()}},vb=class Wd{constructor(t,i,r,a,n){this.type=t,this.input=i,this.beginIndex=r,this.key=a,this.endIndex=n}static parse(t,i){if(t.length<=2||t.length>=5)return i.error(`Expected 2 or 3 arguments, but found ${t.length-1} instead.`);let r=i.parse(t[1],1,re),a=i.parse(t[2],2,V);if(!r||!a)return null;if(!ou(r.type,[zt(re),ie,re]))return i.error(`Expected first argument to be of type array or string, but found ${Ze(r.type)} instead`);if(t.length===4){let n=i.parse(t[3],3,V);return n?new Wd(r.type,r,a,i.key,n):null}return new Wd(r.type,r,a,i.key)}evaluate(t){let i=this.input.evaluate(t),r=this.beginIndex.evaluate(t),a;if(this.endIndex&&(a=this.endIndex.evaluate(t)),Gr(i,["string"]))return[...i].slice(r,a).join("");if(Gr(i,["array"]))return i.slice(r,a);throw new $e(`Expected first argument to be of type array or string, but found ${Ze(Je(i))} instead.`,this.key)}eachChild(t){t(this.input),t(this.beginIndex),this.endIndex&&t(this.endIndex)}outputDefined(){return!1}},Zp=class Hd{constructor(t,i){this.type=t,this.args=i}static parse(t,i){if(t.length<2)return i.error("Expected at least one argument.");let r=null,a=i.expectedType;a&&a.kind!=="value"&&(r=a);let n=[];for(let s of t.slice(1)){let o=i.parse(s,1+n.length,r,void 0,{typeAnnotation:"omit"});if(!o)return null;r||(r=o.type),n.push(o)}if(!r)throw Error("No output type");return a&&n.some(s=>vn(a,s.type))?new Hd(re,n):new Hd(r,n)}evaluate(t){let i=null,r=0,a;for(let n of this.args)if(r++,i=n.evaluate(t),i&&i instanceof Vi&&!i.available&&(a||(a=i.name),i=null,r===this.args.length&&(i=a)),i!==null)break;return i}eachChild(t){this.args.forEach(t)}outputDefined(){return this.args.every(t=>t.outputDefined())}};function qp(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 xb(e,t,i){return t===i}function bb(e,t,i){return t!==i}function wb(e,t,i){return t<i}function Tb(e,t,i){return t>i}function Sb(e,t,i){return t<=i}function Eb(e,t,i){return t>=i}function Wp(e,t,i,r){return r.compare(t,i)===0}function Pb(e,t,i,r){return!Wp(e,t,i,r)}function Cb(e,t,i,r){return r.compare(t,i)<0}function Ab(e,t,i,r){return r.compare(t,i)>0}function Db(e,t,i,r){return r.compare(t,i)<=0}function Ib(e,t,i,r){return r.compare(t,i)>=0}function Ma(e,t,i){let r=e!=="=="&&e!=="!=";return class _1{constructor(n,s,o,l){this.lhs=n,this.rhs=s,this.key=o,this.collator=l,this.type=ce,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,re);if(!l)return null;if(!qp(o,l.type))return s.concat(1).error(`"${o}" comparisons are not supported for type '${Ze(l.type)}'.`);let u=s.parse(n[2],2,re);if(!u)return null;if(!qp(o,u.type))return s.concat(2).error(`"${o}" comparisons are not supported for type '${Ze(u.type)}'.`);if(l.type.kind!==u.type.kind&&l.type.kind!=="value"&&u.type.kind!=="value")return s.error(`Cannot compare types '${Ze(l.type)}' and '${Ze(u.type)}'.`);r&&(l.type.kind==="value"&&u.type.kind!=="value"?l=new er(u.type,[l],s.key):l.type.kind!=="value"&&u.type.kind==="value"&&(u=new er(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,qs),!h)return null}return new _1(l,u,s.key,h)}evaluate(n){let s=this.lhs.evaluate(n),o=this.rhs.evaluate(n);if(r&&this.hasUntypedArgument){let l=Je(s),u=Je(o);if(l.kind!==u.kind||l.kind!=="string"&&l.kind!=="number")throw new $e(`Expected arguments for "${e}" to be (string, string) or (number, number), but found (${l.kind}, ${u.kind}) instead.`,this.key)}if(this.collator&&!r&&this.hasUntypedArgument){let l=Je(s),u=Je(o);if(l.kind!=="string"||u.kind!=="string")return t(n,s,o)}return this.collator?i(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 Mb=Ma("==",xb,Wp),zb=Ma("!=",bb,Pb),Fb=Ma("<",wb,Cb),Rb=Ma(">",Tb,Ab),kb=Ma("<=",Sb,Db),Lb=Ma(">=",Eb,Ib);var Hp=class y1{constructor(t,i,r){this.type=qs,this.locale=r,this.caseSensitive=t,this.diacriticSensitive=i}static parse(t,i){if(t.length!==2)return i.error("Expected one argument.");let r=t[1];if(typeof r!="object"||Array.isArray(r))return i.error("Collator options argument must be an object.");let a=i.parse(r["case-sensitive"]!==void 0&&r["case-sensitive"],1,ce);if(!a)return null;let n=i.parse(r["diacritic-sensitive"]!==void 0&&r["diacritic-sensitive"],1,ce);if(!n)return null;let s=null;return r.locale&&(s=i.parse(r.locale,1,ie),!s)?null:new y1(a,n,s)}evaluate(t){return new fu(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}},Bb=class v1{constructor(t,i,r,a,n,s){this.type=ie,this.number=t,this.locale=i,this.currency=r,this.unit=a,this.minFractionDigits=n,this.maxFractionDigits=s}static parse(t,i){if(t.length!==3)return i.error("Expected two arguments.");let r=i.parse(t[1],1,V);if(!r)return null;let a=t[2];if(typeof a!="object"||Array.isArray(a))return i.error("NumberFormat options argument must be an object.");let n=null;if(a.locale&&(n=i.parse(a.locale,1,ie),!n))return null;let s=null;if(a.currency&&(s=i.parse(a.currency,1,ie),!s))return null;let o=null;if(a.unit&&(o=i.parse(a.unit,1,ie),!o))return null;if(s&&o)return i.error("NumberFormat options `currency` and `unit` are mutually exclusive");let l=null;if(a["min-fraction-digits"]&&(l=i.parse(a["min-fraction-digits"],1,V),!l))return null;let u=null;return a["max-fraction-digits"]&&(u=i.parse(a["max-fraction-digits"],1,V),!u)?null:new v1(r,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}},$b=class x1{constructor(t){this.type=yn,this.input=t}static parse(t,i){if(t.length!==2)return i.error("Expected two arguments.");let r=i.parse(t[1],1,ie);return r?new x1(r):i.error("No image name provided.")}evaluate(t){let i=this.input.evaluate(t),r=Vi.fromString(i);return r&&t.availableImages&&(r.available=t.availableImages.indexOf(i)>-1),r}eachChild(t){t(this.input)}outputDefined(){return!1}},Ob=class b1{constructor(t,i){this.input=t,this.key=i,this.type=V}static parse(t,i){if(t.length!==2)return i.error(`Expected 1 argument, but found ${t.length-1} instead.`);let r=i.parse(t[1],1);return r?r.type.kind!=="array"&&r.type.kind!=="string"&&r.type.kind!=="value"?i.error(`Expected argument of type string or array, but found ${Ze(r.type)} instead.`):new b1(r,i.key):null}evaluate(t){let i=this.input.evaluate(t);if(typeof i=="string")return[...i].length;if(Array.isArray(i))return i.length;throw new $e(`Expected value to be of type string or array, but found ${Ze(Je(i))} instead.`,this.key)}eachChild(t){t(this.input)}outputDefined(){return!1}};const ji=8192;function Nb(e,t){let i=Vb(e[0]),r=Ub(e[1]),a=2**t.z;return[Math.round(i*a*ji),Math.round(r*a*ji)]}function _u(e,t){let i=2**t.z,r=(e[0]/ji+t.x)/i,a=(e[1]/ji+t.y)/i;return[jb(r),Gb(a)]}function Vb(e){return(180+e)/360}function jb(e){return e*360-180}function Ub(e){return(180-180/Math.PI*Math.log(Math.tan(Math.PI/4+e*Math.PI/360)))/360}function Gb(e){return 360/Math.PI*Math.atan(Math.exp((180-e*360)*Math.PI/180))-90}function Tn(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 Sn(e,t){return!(e[0]<=t[0]||e[2]>=t[2]||e[1]<=t[1]||e[3]>=t[3])}function Zb(e,t,i){return t[1]>e[1]!=i[1]>e[1]&&e[0]<(i[0]-t[0])*(e[1]-t[1])/(i[1]-t[1])+t[0]}function qb(e,t,i){let r=e[0]-t[0],a=e[1]-t[1],n=e[0]-i[0],s=e[1]-i[1];return r*s-n*a===0&&r*n<=0&&a*s<=0}function eo(e,t,i,r){let a=[t[0]-e[0],t[1]-e[1]];return Yb([r[0]-i[0],r[1]-i[1]],a)!==0&&!!(Yp(e,t,i,r)&&Yp(i,r,e,t))}function Wb(e,t,i){for(let r of i)for(let a=0;a<r.length-1;++a)if(eo(e,t,r[a],r[a+1]))return!0;return!1}function za(e,t,i=!1){let r=!1;for(let a of t)for(let n=0;n<a.length-1;n++){if(qb(e,a[n],a[n+1]))return i;Zb(e,a[n],a[n+1])&&(r=!r)}return r}function Hb(e,t){for(let i of t)if(za(e,i))return!0;return!1}function Xp(e,t){for(let i of e)if(!za(i,t))return!1;for(let i=0;i<e.length-1;++i)if(Wb(e[i],e[i+1],t))return!1;return!0}function Xb(e,t){for(let i of t)if(Xp(e,i))return!0;return!1}function Yb(e,t){return e[0]*t[1]-e[1]*t[0]}function Yp(e,t,i,r){let a=e[0]-i[0],n=e[1]-i[1],s=t[0]-i[0],o=t[1]-i[1],l=r[0]-i[0],u=r[1]-i[1],h=a*u-l*n,c=s*u-l*o;return h>0&&c<0||h<0&&c>0}function yu(e,t,i){let r=[];for(let a=0;a<e.length;a++){let n=[];for(let s=0;s<e[a].length;s++){let o=Nb(e[a][s],i);Tn(t,o),n.push(o)}r.push(n)}return r}function Kp(e,t,i){let r=[];for(let a=0;a<e.length;a++){let n=yu(e[a],t,i);r.push(n)}return r}function Jp(e,t,i,r){if(e[0]<i[0]||e[0]>i[2]){let a=r*.5,n=e[0]-i[0]>a?-r:i[0]-e[0]>a?r:0;n===0&&(n=e[0]-i[2]>a?-r:i[2]-e[0]>a?r:0),e[0]+=n}Tn(t,e)}function Kb(e){e[0]=e[1]=1/0,e[2]=e[3]=-1/0}function Qp(e,t,i,r){let a=2**r.z*ji,n=[r.x*ji,r.y*ji],s=[];for(let o of e)for(let l of o){let u=[l.x+n[0],l.y+n[1]];Jp(u,t,i,a),s.push(u)}return s}function ef(e,t,i,r){let a=2**r.z*ji,n=[r.x*ji,r.y*ji],s=[];for(let o of e){let l=[];for(let u of o){let h=[u.x+n[0],u.y+n[1]];Tn(t,h),l.push(h)}s.push(l)}if(t[2]-t[0]<=a/2){Kb(t);for(let o of s)for(let l of o)Jp(l,t,i,a)}return s}function Jb(e,t){let i=[1/0,1/0,-1/0,-1/0],r=[1/0,1/0,-1/0,-1/0],a=e.canonicalID();if(t.type==="Polygon"){let n=yu(t.coordinates,r,a),s=Qp(e.geometry(),i,r,a);if(!Sn(i,r))return!1;for(let o of s)if(!za(o,n))return!1}if(t.type==="MultiPolygon"){let n=Kp(t.coordinates,r,a),s=Qp(e.geometry(),i,r,a);if(!Sn(i,r))return!1;for(let o of s)if(!Hb(o,n))return!1}return!0}function Qb(e,t){let i=[1/0,1/0,-1/0,-1/0],r=[1/0,1/0,-1/0,-1/0],a=e.canonicalID();if(t.type==="Polygon"){let n=yu(t.coordinates,r,a),s=ef(e.geometry(),i,r,a);if(!Sn(i,r))return!1;for(let o of s)if(!Xp(o,n))return!1}if(t.type==="MultiPolygon"){let n=Kp(t.coordinates,r,a),s=ef(e.geometry(),i,r,a);if(!Sn(i,r))return!1;for(let o of s)if(!Xb(o,n))return!1}return!0}var vu=class Nl{constructor(t,i){this.type=ce,this.geojson=t,this.geometries=i}static parse(t,i){if(t.length!==2)return i.error(`'within' expression requires exactly one argument, but found ${t.length-1} instead.`);if(Aa(t[1])){let r=t[1];if(r.type==="FeatureCollection"){let a=[];for(let n of r.features){let{type:s,coordinates:o}=n.geometry;s==="Polygon"&&a.push(o),s==="MultiPolygon"&&a.push(...o)}if(a.length)return new Nl(r,{type:"MultiPolygon",coordinates:a})}else if(r.type==="Feature"){let a=r.geometry.type;if(a==="Polygon"||a==="MultiPolygon")return new Nl(r,r.geometry)}else if(r.type==="Polygon"||r.type==="MultiPolygon")return new Nl(r,r)}return i.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 Jb(t,this.geometries);if(t.geometryType()==="LineString")return Qb(t,this.geometries)}return!1}eachChild(){}outputDefined(){return!0}},tf=class{constructor(t=[],i=(r,a)=>r<a?-1:+(r>a)){if(this.data=t,this.length=this.data.length,this.compare=i,this.length>0)for(let r=(this.length>>1)-1;r>=0;r--)this._down(r)}push(t){this.data.push(t),this._up(this.length++)}pop(){if(this.length===0)return;let t=this.data[0],i=this.data.pop();return--this.length>0&&(this.data[0]=i,this._down(0)),t}peek(){return this.data[0]}_up(t){let{data:i,compare:r}=this,a=i[t];for(;t>0;){let n=t-1>>1,s=i[n];if(r(a,s)>=0)break;i[t]=s,t=n}i[t]=a}_down(t){let{data:i,compare:r}=this,a=this.length>>1,n=i[t];for(;t<a;){let s=(t<<1)+1,o=s+1;if(o<this.length&&r(i[o],i[s])<0&&(s=o),r(i[s],n)>=0)break;i[t]=i[s],t=s}i[t]=n}};const rf=Math.PI/180;var xu=class{constructor(t){let i=rf*6378.137*1e3,r=Math.cos(t*rf),a=1/(1-.0066943799901413165*(1-r*r)),n=Math.sqrt(a);this.kx=i*n*r,this.ky=i*n*a*.9933056200098587}distance(t,i){let r=this.wrap(t[0]-i[0])*this.kx,a=(t[1]-i[1])*this.ky;return Math.sqrt(r*r+a*a)}pointOnLine(t,i){let r=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(i[0]-u)*this.kx*c+(i[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(i[0]-u)*this.kx,d=(i[1]-h)*this.ky;let f=c*c+d*d;f<r&&(r=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 af(e,t){return t[0]-e[0]}function to(e){return e[1]-e[0]+1}function tr(e,t){return e[1]>=e[0]&&e[1]<t}function bu(e,t){if(e[0]>e[1])return[null,null];let i=to(e);if(t){if(i===2)return[e,null];let a=Math.floor(i/2);return[[e[0],e[0]+a],[e[0]+a,e[1]]]}if(i===1)return[e,null];let r=Math.floor(i/2)-1;return[[e[0],e[0]+r],[e[0]+r+1,e[1]]]}function wu(e,t){if(!tr(t,e.length))return[1/0,1/0,-1/0,-1/0];let i=[1/0,1/0,-1/0,-1/0];for(let r=t[0];r<=t[1];++r)Tn(i,e[r]);return i}function Tu(e){let t=[1/0,1/0,-1/0,-1/0];for(let i of e)for(let r of i)Tn(t,r);return t}function nf(e){return e[0]!==-1/0&&e[1]!==-1/0&&e[2]!==1/0&&e[3]!==1/0}function Su(e,t,i){if(!nf(e)||!nf(t))return NaN;let r=0,a=0;return e[2]<t[0]&&(r=t[0]-e[2]),e[0]>t[2]&&(r=e[0]-t[2]),e[1]>t[3]&&(a=e[1]-t[3]),e[3]<t[1]&&(a=t[1]-e[3]),i.distance([0,0],[r,a])}function Zr(e,t,i){let r=i.pointOnLine(t,e);return i.distance(e,r.point)}function Eu(e,t,i,r,a){let n=Math.min(Zr(e,[i,r],a),Zr(t,[i,r],a)),s=Math.min(Zr(i,[e,t],a),Zr(r,[e,t],a));return Math.min(n,s)}function ew(e,t,i,r,a){if(!(tr(t,e.length)&&tr(r,i.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=r[0];u<r[1];++u){let h=i[u],c=i[u+1];if(eo(o,l,h,c))return 0;n=Math.min(n,Eu(o,l,h,c,a))}}return n}function tw(e,t,i,r,a){if(!(tr(t,e.length)&&tr(r,i.length)))return NaN;let n=1/0;for(let s=t[0];s<=t[1];++s)for(let o=r[0];o<=r[1];++o)if(n=Math.min(n,a.distance(e[s],i[o])),n===0)return n;return n}function iw(e,t,i){if(za(e,t,!0))return 0;let r=1/0;for(let a of t){let n=a[0],s=a[a.length-1];if(n!==s&&(r=Math.min(r,Zr(e,[s,n],i)),r===0))return r;let o=i.pointOnLine(a,e);if(r=Math.min(r,i.distance(e,o.point)),r===0)return r}return r}function rw(e,t,i,r){if(!tr(t,e.length))return NaN;for(let n=t[0];n<=t[1];++n)if(za(e[n],i,!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 i)for(let u=0,h=l.length,c=h-1;u<h;c=u++){let d=l[c],p=l[u];if(eo(s,o,d,p))return 0;a=Math.min(a,Eu(s,o,d,p,r))}}return a}function sf(e,t){for(let i of e)for(let r of i)if(za(r,t,!0))return!0;return!1}function aw(e,t,i,r=1/0){let a=Tu(e),n=Tu(t);if(r!==1/0&&Su(a,n,i)>=r)return r;if(Sn(a,n)){if(sf(e,t))return 0}else if(sf(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(eo(c,d,_,y))return 0;s=Math.min(s,Eu(c,d,_,y,i))}}return s}function of(e,t,i,r,a,n){if(!n)return;let s=Su(wu(r,n),a,i);s<t&&e.push([s,n,[0,0]])}function io(e,t,i,r,a,n,s){if(!n||!s)return;let o=Su(wu(r,n),wu(a,s),i);o<t&&e.push([o,n,s])}function ro(e,t,i,r,a=1/0){let n=Math.min(r.distance(e[0],i[0][0]),a);if(n===0)return n;let s=new tf([[0,[0,e.length-1],[0,0]]],af),o=Tu(i);for(;s.length>0;){let l=s.pop();if(l[0]>=n)continue;let u=l[1],h=t?50:100;if(to(u)<=h){if(!tr(u,e.length))return NaN;if(t){let c=rw(e,u,i,r);if(isNaN(c)||c===0)return c;n=Math.min(n,c)}else for(let c=u[0];c<=u[1];++c){let d=iw(e[c],i,r);if(n=Math.min(n,d),n===0)return 0}}else{let c=bu(u,t);of(s,n,r,e,o,c[0]),of(s,n,r,e,o,c[1])}}return n}function ao(e,t,i,r,a,n=1/0){let s=Math.min(n,a.distance(e[0],i[0]));if(s===0)return s;let o=new tf([[0,[0,e.length-1],[0,i.length-1]]],af);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=r?50:100;if(to(u)<=c&&to(h)<=d){if(!tr(u,e.length)&&tr(h,i.length))return NaN;let p;if(t&&r)p=ew(e,u,i,h,a),s=Math.min(s,p);else if(t&&!r){let f=e.slice(u[0],u[1]+1);for(let m=h[0];m<=h[1];++m)if(p=Zr(i[m],f,a),s=Math.min(s,p),s===0)return s}else if(!t&&r){let f=i.slice(h[0],h[1]+1);for(let m=u[0];m<=u[1];++m)if(p=Zr(e[m],f,a),s=Math.min(s,p),s===0)return s}else p=tw(e,u,i,h,a),s=Math.min(s,p)}else{let p=bu(u,t),f=bu(h,r);io(o,s,a,e,i,p[0],f[0]),io(o,s,a,e,i,p[0],f[1]),io(o,s,a,e,i,p[1],f[0]),io(o,s,a,e,i,p[1],f[1])}}return s}function nw(e,t){let i=e.geometry(),r=i.flat().map(s=>_u([s.x,s.y],e.canonical));if(i.length===0)return NaN;let a=new xu(r[0][1]),n=1/0;for(let s of t){switch(s.type){case"Point":n=Math.min(n,ao(r,!1,[s.coordinates],!1,a,n));break;case"LineString":n=Math.min(n,ao(r,!1,s.coordinates,!0,a,n));break;case"Polygon":n=Math.min(n,ro(r,!1,s.coordinates,a,n))}if(n===0)return n}return n}function sw(e,t){let i=e.geometry(),r=i.flat().map(s=>_u([s.x,s.y],e.canonical));if(i.length===0)return NaN;let a=new xu(r[0][1]),n=1/0;for(let s of t){switch(s.type){case"Point":n=Math.min(n,ao(r,!0,[s.coordinates],!1,a,n));break;case"LineString":n=Math.min(n,ao(r,!0,s.coordinates,!0,a,n));break;case"Polygon":n=Math.min(n,ro(r,!0,s.coordinates,a,n))}if(n===0)return n}return n}function ow(e,t){let i=e.geometry();if(i.length===0||i[0].length===0)return NaN;let r=Js(i,0).map(s=>s.map(o=>o.map(l=>_u([l.x,l.y],e.canonical)))),a=new xu(r[0][0][0][1]),n=1/0;for(let s of t)for(let o of r){switch(s.type){case"Point":n=Math.min(n,ro([s.coordinates],!1,o,a,n));break;case"LineString":n=Math.min(n,ro(s.coordinates,!0,o,a,n));break;case"Polygon":n=Math.min(n,aw(o,s.coordinates,a,n))}if(n===0)return n}return n}function Pu(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 Cu=class Vl{constructor(t,i){this.type=V,this.geojson=t,this.geometries=i}static parse(t,i){if(t.length!==2)return i.error(`'distance' expression requires exactly one argument, but found ${t.length-1} instead.`);if(Aa(t[1])){let r=t[1];if(r.type==="FeatureCollection")return new Vl(r,r.features.map(a=>Pu(a.geometry)).flat());if(r.type==="Feature")return new Vl(r,Pu(r.geometry));if("type"in r&&"coordinates"in r)return new Vl(r,Pu(r))}return i.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 nw(t,this.geometries);if(t.geometryType()==="LineString")return sw(t,this.geometries);if(t.geometryType()==="Polygon")return ow(t,this.geometries)}return NaN}eachChild(){}outputDefined(){return!0}},lw=class w1{constructor(t){let i=null;for(let r of t)if(!i)i=r.type;else{if(i===r.type)continue;i=re;break}this.type=zt(i??re,t.length),this.arr=t}static parse(t,i){if(t.length!==2)return i.error(`'semiliteral' expression requires exactly one argument, but found ${t.length-1} instead.`);if(!Aa(t[1]))return i.error(`invalid value of type "${typeof t[1]}"`);let r=t[1],a=Je(r);if(a.kind==="array"){let n=r.map(s=>i.parse(s,null,re));return new w1(n)}return new Da(a,r)}evaluate(t){return this.arr.map(i=>i.evaluate(t))}eachChild(t){this.arr.forEach(t)}outputDefined(){return this.arr.every(t=>t.outputDefined())}},Au=class T1{constructor(t){this.key=t,this.type=re}static parse(t,i){if(t.length!==2)return i.error(`Expected 1 argument, but found ${t.length-1} instead.`);let r=t[1];return r==null?i.error("Global state property must be defined."):typeof r=="string"?new T1(r):i.error(`Global state property must be string, but found ${typeof t[1]} instead.`)}evaluate(t){var r;let i=(r=t.globals)==null?void 0:r.globalState;return!i||Object.keys(i).length===0?null:xn(i,this.key)??null}eachChild(){}outputDefined(){return!1}};const Fa={"==":Mb,"!=":zb,">":Rb,"<":Fb,">=":Lb,"<=":kb,array:er,at:fb,boolean:er,case:yb,coalesce:Zp,collator:Hp,format:Np,image:$b,in:mb,"index-of":gb,interpolate:pi,"interpolate-hcl":pi,"interpolate-lab":pi,length:Ob,let:Up,literal:Da,match:_b,number:er,"number-format":Bb,object:er,semiliteral:lw,slice:vb,step:mu,string:er,"to-boolean":Ia,"to-color":Ia,"to-number":Ia,"to-string":Ia,var:Gp,within:vu,distance:Cu,"global-state":Au};var Ui=class extends Error{constructor(t,i){super(i),this.message=i,this.key=t}},uw=class S1{constructor(t,i=[]){this.parent=t,this.bindings={};for(let[r,a]of i)this.bindings[r]=a}concat(t){return new S1(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}},lf=class E1{constructor(t,i,r=[],a,n=new uw,s=[]){this.registry=t,this.path=r,this.key=r.map(o=>`[${o}]`).join(""),this.scope=n,this.errors=s,this.expectedType=a,this._isConstant=i}parse(t,i,r,a,n={}){return i?this.concat(i,r,a)._parse(t,n):this._parse(t,n)}_parse(t,i){(t===null||typeof t=="string"||typeof t=="boolean"||typeof t=="number")&&(t=["literal",t]);let r=this.key;function a(n,s,o){return o==="assert"?new er(s,[n],r):o==="coerce"?new Ia(s,[n],r):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,i.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,i.typeAnnotation||"coerce");else if(this.checkSubtype(l,u))return null}if(!(o instanceof Da)&&o.type.kind!=="resolvedImage"&&this._isConstant(o)){let l=new Op;try{o=new Da(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,i,r){let a=typeof t=="number"?this.path.concat(t):this.path,n=r?this.scope.concat(r):this.scope;return new E1(this.registry,this._isConstant,a,i||null,n,this.errors)}error(t,...i){let r=`${this.key}${i.map(a=>`[${a}]`).join("")}`;this.errors.push(new Ui(r,t))}checkSubtype(t,i){let r=vn(t,i);return r&&this.error(r),r}},qr=class zs{constructor(t,i,r,a,n){this.name=t,this.type=i,this._evaluate=r,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,i){let r=t[0],a=zs.definitions[r];if(!a)return i.error(`Unknown expression "${r}". If you wanted a literal array, use ["literal", [...]].`,0);let n=Array.isArray(a)?a[0]:a.type,s=Array.isArray(a)?[[a[1],a[2]]]:a.overloads,o=s.filter(([u])=>!Array.isArray(u)||u.length===t.length-1),l=null;for(let[u,h]of o){l=new lf(i.registry,no,i.path,null,i.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 zs(r,n,h,c,i.key)}}if(o.length===1)i.errors.push(...l.errors);else{let u=(o.length?o:s).map(([c])=>cw(c)).join(" | "),h=[];for(let c=1;c<t.length;c++){let d=i.parse(t[c],1+h.length);if(!d)return null;h.push(Ze(d.type))}i.error(`Expected arguments of type ${u}, but found (${h.join(", ")}) instead.`)}return null}static register(t,i){zs.definitions=i;for(let r in i)t[r]=zs}};function uf(e,[t,i,r,a],n){t=t.evaluate(e),i=i.evaluate(e),r=r.evaluate(e);let s=a?a.evaluate(e):1,o=$p(t,i,r,s);if(o)throw new $e(o,n);return new te(t/255,i/255,r/255,s,!1)}function hf(e,t){return e in t&&t[e]!==void 0}function Du(e,t){let i=t[e];return i===void 0?null:i}function hw(e,t,i,r){for(;i<=r;){let a=i+r>>1;if(t[a]===e)return!0;t[a]>e?r=a-1:i=a+1}return!1}function Wr(e){return{type:e}}qr.register(Fa,{error:[Yx,[ie],(e,[t],i)=>{throw new $e(t.evaluate(e),i)}],typeof:[ie,[re],(e,[t])=>Ze(Je(t.evaluate(e)))],"to-rgba":[zt(V,4),[Ei],(e,[t])=>{let[i,r,a,n]=t.evaluate(e).rgb;return[i*255,r*255,a*255,n]}],rgb:[Ei,[V,V,V],uf],rgba:[Ei,[V,V,V,V],uf],has:{type:ce,overloads:[[[ie],(e,[t])=>hf(t.evaluate(e),e.properties())],[[ie,Ur],(e,[t,i])=>hf(t.evaluate(e),i.evaluate(e))]]},get:{type:re,overloads:[[[ie],(e,[t])=>Du(t.evaluate(e),e.properties())],[[ie,Ur],(e,[t,i])=>Du(t.evaluate(e),i.evaluate(e))]]},"feature-state":[re,[ie],(e,[t])=>Du(t.evaluate(e),e.featureState||{})],properties:[Ur,[],e=>e.properties()],"geometry-type":[ie,[],e=>e.geometryType()],id:[re,[],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:[re,[],e=>e.globals.accumulated===void 0?null:e.globals.accumulated],"+":[V,Wr(V),(e,t)=>{let i=0;for(let r of t)i+=r.evaluate(e);return i}],"*":[V,Wr(V),(e,t)=>{let i=1;for(let r of t)i*=r.evaluate(e);return i}],"-":{type:V,overloads:[[[V,V],(e,[t,i])=>t.evaluate(e)-i.evaluate(e)],[[V],(e,[t])=>-t.evaluate(e)]]},"/":[V,[V,V],(e,[t,i])=>t.evaluate(e)/i.evaluate(e)],"%":[V,[V,V],(e,[t,i])=>t.evaluate(e)%i.evaluate(e)],ln2:[V,[],()=>Math.LN2],pi:[V,[],()=>Math.PI],e:[V,[],()=>Math.E],"^":[V,[V,V],(e,[t,i])=>t.evaluate(e)**+i.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,Wr(V),(e,t)=>Math.min(...t.map(i=>i.evaluate(e)))],max:[V,Wr(V),(e,t)=>Math.max(...t.map(i=>i.evaluate(e)))],abs:[V,[V],(e,[t])=>Math.abs(t.evaluate(e))],round:[V,[V],(e,[t])=>{let i=t.evaluate(e);return i<0?-Math.round(-i):Math.round(i)}],floor:[V,[V],(e,[t])=>Math.floor(t.evaluate(e))],ceil:[V,[V],(e,[t])=>Math.ceil(t.evaluate(e))],"filter-==":[ce,[ie,re],(e,[t,i])=>e.properties()[t.value]===i.value],"filter-id-==":[ce,[re],(e,[t])=>e.id()===t.value],"filter-type-==":[ce,[ie],(e,[t])=>e.geometryType()===t.value],"filter-<":[ce,[ie,re],(e,[t,i])=>{let r=e.properties()[t.value],a=i.value;return typeof r==typeof a&&r<a}],"filter-id-<":[ce,[re],(e,[t])=>{let i=e.id(),r=t.value;return typeof i==typeof r&&i<r}],"filter->":[ce,[ie,re],(e,[t,i])=>{let r=e.properties()[t.value],a=i.value;return typeof r==typeof a&&r>a}],"filter-id->":[ce,[re],(e,[t])=>{let i=e.id(),r=t.value;return typeof i==typeof r&&i>r}],"filter-<=":[ce,[ie,re],(e,[t,i])=>{let r=e.properties()[t.value],a=i.value;return typeof r==typeof a&&r<=a}],"filter-id-<=":[ce,[re],(e,[t])=>{let i=e.id(),r=t.value;return typeof i==typeof r&&i<=r}],"filter->=":[ce,[ie,re],(e,[t,i])=>{let r=e.properties()[t.value],a=i.value;return typeof r==typeof a&&r>=a}],"filter-id->=":[ce,[re],(e,[t])=>{let i=e.id(),r=t.value;return typeof i==typeof r&&i>=r}],"filter-has":[ce,[re],(e,[t])=>{let i=t.value,r=e.properties();return i in r&&r[i]!==void 0}],"filter-has-id":[ce,[],e=>e.id()!==null&&e.id()!==void 0],"filter-type-in":[ce,[zt(ie)],(e,[t])=>t.value.indexOf(e.geometryType())>=0],"filter-id-in":[ce,[zt(re)],(e,[t])=>t.value.indexOf(e.id())>=0],"filter-in-small":[ce,[ie,zt(re)],(e,[t,i])=>i.value.indexOf(e.properties()[t.value])>=0],"filter-in-large":[ce,[ie,zt(re)],(e,[t,i])=>hw(e.properties()[t.value],i.value,0,i.value.length-1)],all:{type:ce,overloads:[[[ce,ce],(e,[t,i])=>t.evaluate(e)&&i.evaluate(e)],[Wr(ce),(e,t)=>{for(let i of t)if(!i.evaluate(e))return!1;return!0}]]},any:{type:ce,overloads:[[[ce,ce],(e,[t,i])=>t.evaluate(e)||i.evaluate(e)],[Wr(ce),(e,t)=>{for(let i of t)if(i.evaluate(e))return!0;return!1}]]},"!":[ce,[ce],(e,[t])=>!t.evaluate(e)],"is-supported-script":[ce,[ie],(e,[t])=>{let i=e.globals&&e.globals.isSupportedScript;return!i||i(t.evaluate(e))}],upcase:[ie,[ie],(e,[t])=>t.evaluate(e).toUpperCase()],downcase:[ie,[ie],(e,[t])=>t.evaluate(e).toLowerCase()],concat:[ie,Wr(re),(e,t)=>t.map(i=>bn(i.evaluate(e))).join("")],split:[zt(ie),[ie,ie],(e,[t,i])=>t.evaluate(e).split(i.evaluate(e))],join:[ie,[zt(ie),ie],(e,[t,i])=>t.evaluate(e).join(i.evaluate(e))],"resolved-locale":[ie,[qs],(e,[t])=>t.evaluate(e).resolvedLocale()]});function cw(e){return Array.isArray(e)?`(${e.map(Ze).join(", ")})`:`(${Ze(e.type)}...)`}function no(e){if(e instanceof Gp)return no(e.boundExpression);if(e instanceof qr&&e.name==="error"||e instanceof Hp||e instanceof vu||e instanceof Cu||e instanceof Au)return!1;let t=e instanceof Ia||e instanceof er,i=!0;return e.eachChild(r=>{i&&(i=t?no(r):r instanceof Da)}),i?so(e)&&oo(e,["zoom","heatmap-density","elevation","line-progress","accumulated","is-supported-script"]):!1}function so(e){if(e instanceof qr&&(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 vu||e instanceof Cu)return!1;let t=!0;return e.eachChild(i=>{t&&!so(i)&&(t=!1)}),t}function En(e){if(e instanceof qr&&e.name==="feature-state")return!1;let t=!0;return e.eachChild(i=>{t&&!En(i)&&(t=!1)}),t}function oo(e,t){if(e instanceof qr&&t.indexOf(e.name)>=0)return!1;let i=!0;return e.eachChild(r=>{i&&!oo(r,t)&&(i=!1)}),i}function Ra(e){return e["property-type"]==="data-driven"||e["property-type"]==="cross-faded-data-driven"}function cf(e){return!!e.expression&&e.expression.parameters.indexOf("zoom")>-1}function Iu(e){return!!e.expression&&e.expression.interpolated}function Pn(e,...t){for(let i of t)for(let r in i)e[r]=i[r];return e}function oe(e){return e instanceof Number?"number":e instanceof String?"string":e instanceof Boolean?"boolean":Array.isArray(e)?"array":e===null?"null":typeof e}function lo(e){return typeof e=="object"&&!!e&&!Array.isArray(e)&&Je(e)===Ur}function dw(e){return e}function pw(e){switch(e.type){case"color":return te.parse;case"padding":return $i.parse;case"numberArray":return Oi.parse;case"colorArray":return di.parse;default:return null}}function fw(e){switch(e){case"exponential":return pf;case"interval":return gw;case"categorical":return mw;case"identity":return _w;default:throw Error(`Unknown function type "${e}"`)}}function df(e,t){let i=e.stops&&typeof e.stops[0][0]=="object",r=i||e.property!==void 0,a=i||!r,n=e.type||(Iu(t)?"exponential":"interval"),s=pw(t);if(s&&(e=Pn({},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&&!sb(e.colorSpace))throw Error(`Unknown color space: "${e.colorSpace}"`);let o=fw(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(i){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,df(h[f],t)]);let p={name:"linear"};return{kind:"composite",interpolationType:p,interpolationFactor:pi.interpolationFactor.bind(void 0,p),zoomStops:d.map(f=>f[0]),evaluate({zoom:f},m){return pf({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:pi.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?Cn(e.default,t.default):o(e,t,d,l,u)}}}function Cn(e,t,i){if(e!==void 0)return e;if(t!==void 0)return t;if(i!==void 0)return i}function mw(e,t,i,r,a){return Cn(typeof i===a?r[i]:void 0,e.default,t.default)}function gw(e,t,i){if(oe(i)!=="number")return Cn(e.default,t.default);let r=e.stops.length;if(r===1||i<=e.stops[0][0])return e.stops[0][1];if(i>=e.stops[r-1][0])return e.stops[r-1][1];let a=Ks(e.stops.map(n=>n[0]),i,"");return e.stops[a][1]}function pf(e,t,i){let r=e.base===void 0?1:e.base;if(oe(i)!=="number")return Cn(e.default,t.default);let a=e.stops.length;if(a===1||i<=e.stops[0][0])return e.stops[0][1];if(i>=e.stops[a-1][0])return e.stops[a-1][1];let n=Ks(e.stops.map(h=>h[0]),i,""),s=yw(i,r,e.stops[n][0],e.stops[n+1][0]),o=e.stops[n][1],l=e.stops[n+1][1],u=Oe[t.type]||dw;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 _w(e,t,i){switch(t.type){case"color":i=te.parse(i);break;case"formatted":i=Qi.fromString(i.toString());break;case"resolvedImage":i=Vi.fromString(i.toString());break;case"padding":i=$i.parse(i);break;case"colorArray":i=di.parse(i);break;case"numberArray":i=Oi.parse(i);break;default:oe(i)!==t.type&&(t.type!=="enum"||!t.values[i])&&(i=void 0)}return Cn(i,e.default,t.default)}function yw(e,t,i,r){let a=r-i,n=e-i;return a===0?0:t===1?n/a:(t**+n-1)/(t**+a-1)}function Mu(e){return{result:"success",value:e}}function ka(e){return{result:"error",value:e}}var zu=class{constructor(t,i,r,a){this.expression=t,this._warningHistory={},this._evaluator=new Op,this._defaultValue=r?yf(r):null,this._enumValues=r&&r.type==="enum"?r.values:null,this._globalState=a,this._rootKey=i}evaluateWithoutErrorHandling(t,i,r,a,n,s){return this._globalState&&(t=La(t,this._globalState)),this._evaluator.globals=t,this._evaluator.feature=i,this._evaluator.featureState=r,this._evaluator.canonical=a,this._evaluator.availableImages=n||null,this._evaluator.formattedSection=s,this.expression.evaluate(this._evaluator)}evaluate(t,i,r,a,n,s){this._globalState&&(t=La(t,this._globalState)),this._evaluator.globals=t,this._evaluator.feature=i||null,this._evaluator.featureState=r||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 $e(`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 $e?o.path:"",u=`${l}|${o.message}`;return this._warningHistory[u]||(this._warningHistory[u]=!0,typeof console<"u"&&console.warn(ff(this._rootKey,l,o.message,this._defaultValue))),this._defaultValue}}};function ff(e,t,i,r){return`${e}${t}: ${i}${r==null?"":` Falling back to ${String(r)}.`}`}function mf(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 uo(e){return Array.isArray(e)&&e.length>0&&typeof e[0]=="string"&&e[0]in Fa}function ho(e,t,i,r){mf(t);let a=new lf(Fa,no,[],i?bw(i):void 0),n=a.parse(e,void 0,void 0,void 0,i&&i.type==="string"?{typeAnnotation:"coerce"}:void 0);return n?Mu(new zu(n,t,i,r)):ka(a.errors)}var An=class{constructor(t,i,r){this.kind=t,this._styleExpression=i,this.isStateDependent=t!=="constant"&&!En(i.expression),this.globalStateRefs=Dn(i.expression),this._globalState=r}evaluateWithoutErrorHandling(t,i,r,a,n,s){return this._globalState&&(t=La(t,this._globalState)),this._styleExpression.evaluateWithoutErrorHandling(t,i,r,a,n,s)}evaluate(t,i,r,a,n,s){return this._globalState&&(t=La(t,this._globalState)),this._styleExpression.evaluate(t,i,r,a,n,s)}},co=class{constructor(t,i,r,a,n){this.kind=t,this.zoomStops=r,this._styleExpression=i,this.isStateDependent=t!=="camera"&&!En(i.expression),this.globalStateRefs=Dn(i.expression),this.interpolationType=a,this._globalState=n}evaluateWithoutErrorHandling(t,i,r,a,n,s){return this._globalState&&(t=La(t,this._globalState)),this._styleExpression.evaluateWithoutErrorHandling(t,i,r,a,n,s)}evaluate(t,i,r,a,n,s){return this._globalState&&(t=La(t,this._globalState)),this._styleExpression.evaluate(t,i,r,a,n,s)}interpolationFactor(t,i,r){return this.interpolationType?pi.interpolationFactor(this.interpolationType,t,i,r):0}};function vw(e){return e._styleExpression!==void 0}function gf(e,t,i,r){let a=ho(e,t,i,r);if(a.result==="error")return a;let n=a.value.expression,s=so(n);if(!s&&!Ra(i))return ka([new Ui("","data expressions not supported")]);let o=oo(n,["zoom"]);if(!o&&!cf(i))return ka([new Ui("","zoom expressions not supported")]);let l=po(n);if(!l&&!o)return ka([new Ui("",'"zoom" expression may only be used as input to a top-level "step" or "interpolate" expression.')]);if(l instanceof Ui)return ka([l]);if(l instanceof pi&&!Iu(i))return ka([new Ui("",'"interpolate" expressions cannot be used with this property')]);if(!l)return Mu(s?new An("constant",a.value,r):new An("source",a.value,r));let u=l instanceof pi?l.interpolation:void 0;return Mu(s?new co("camera",a.value,l.labels,u,r):new co("composite",a.value,l.labels,u,r))}var _f=class P1{constructor(t,i,r){this.isStateDependent=!1,this.globalStateRefs=new Set,this._globalState=null,mf(i),this._parameters=t,this._specification=r,this._rootKey=i,this._defaultValue=yf(r),this._warningHistory={};let a=df(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,i){try{return this._innerEvaluate(t,i)}catch(r){let a=r instanceof Error?r.message:String(r),n=`|${a}`;return this._warningHistory[n]||(this._warningHistory[n]=!0,typeof console<"u"&&console.warn(ff(this._rootKey,"",a,this._defaultValue))),this._defaultValue}}static deserialize(t){return new P1(t._parameters,t._rootKey,t._specification)}static serialize(t){return{_parameters:t._parameters,_specification:t._specification,_rootKey:t._rootKey}}};function xw(e,t,i,r){if(lo(e))return new _f(e,t,i);if(uo(e)){let a=gf(e,t,i,r);if(a.result==="error")throw Error(a.value.map(n=>`${n.key}: ${n.message}`).join(", "));return a.value}{let a=e;return i.type==="color"&&typeof e=="string"?a=te.parse(e):i.type==="padding"&&(typeof e=="number"||Array.isArray(e))?a=$i.parse(e):i.type==="numberArray"&&(typeof e=="number"||Array.isArray(e))?a=Oi.parse(e):i.type==="colorArray"&&(typeof e=="string"||Array.isArray(e))?a=di.parse(e):i.type==="variableAnchorOffsetCollection"&&Array.isArray(e)?a=Ni.parse(e):i.type==="projectionDefinition"&&typeof e=="string"&&(a=Sr.parse(e)),{globalStateRefs:new Set,_globalState:null,kind:"constant",evaluate:()=>a}}}function po(e){let t=null;if(e instanceof Up)t=po(e.result);else if(e instanceof Zp){for(let i of e.args)if(t=po(i),t)break}else(e instanceof mu||e instanceof pi)&&e.input instanceof qr&&e.input.name==="zoom"&&(t=e);return t instanceof Ui||e.eachChild(i=>{let r=po(i);r instanceof Ui?t=r:!t&&r?t=new Ui("",'"zoom" expression may only be used as input to a top-level "step" or "interpolate" expression.'):t&&r&&t!==r&&(t=new Ui("",'Only one zoom-based "step" or "interpolate" subexpression may be used in an expression.'))}),t}function Dn(e,t=new Set){return e instanceof Au&&t.add(e.key),e.eachChild(i=>{Dn(i,t)}),t}function bw(e){let t={color:Ei,string:ie,number:V,enum:ie,boolean:ce,formatted:gn,padding:Ws,numberArray:Hs,colorArray:_n,projectionDefinition:Zs,resolvedImage:yn,variableAnchorOffsetCollection:Xs};return e.type==="array"?zt(t[e.value]||re,e.length):t[e.type]}function yf(e){if(e.type==="color"&&lo(e.default))return new te(0,0,0,0);switch(e.type){case"color":return te.parse(e.default)||null;case"padding":return $i.parse(e.default)||null;case"numberArray":return Oi.parse(e.default)||null;case"colorArray":return di.parse(e.default)||null;case"variableAnchorOffsetCollection":return Ni.parse(e.default)||null;case"projectionDefinition":return Sr.parse(e.default)||null;default:return e.default===void 0?null:e.default}}function La(e,t){let{zoom:i,heatmapDensity:r,elevation:a,lineProgress:n,isSupportedScript:s,accumulated:o}=e??{};return{zoom:i,heatmapDensity:r,elevation:a,lineProgress:n,isSupportedScript:s,accumulated:o,globalState:t}}function ww(e){let t=!1;for(let i of e){let r=vf(i);if(r==="expression")return"expression";r==="legacy"&&(t=!0)}return t?"legacy":"neutral"}function vf(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 ww(e.slice(1));default:return"expression"}}function Fu(e){return vf(e)!=="legacy"}function xf(e){return e==="$type"?["geometry-type"]:e==="$id"?["id"]:["get",e]}function Tw(e){switch(e[0]){case"==":case"!=":case"<":case"<=":case">":case">=":return e.length!==3||typeof e[1]!="string"?null:[e[0],xf(e[1]),e[2]];case"in":case"!in":{if(e.length<2||typeof e[1]!="string")return null;let t=["in",xf(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 bf(e){if((e[0]==="<"||e[0]==="<="||e[0]===">"||e[0]===">=")&&e[1]==="$type")return`"$type" cannot be use with operator "${e[0]}"`;let t=Tw(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 Ru(e,t,i){let r=i[e];return Array.isArray(r)?Fu(r)?ku(r,t.concat(e)):{path:t.concat(e),legacyFilter:r}:null}function ku(e,t=[]){if(!Array.isArray(e)||e.length<1)return null;switch(e[0]){case"all":case"any":case"none":for(let i=1;i<e.length;i++){let r=Ru(i,t,e);if(r)return r}break;case"!":{let i=Ru(1,t,e);if(i)return i;break}case"case":for(let i=1;i<e.length-1;i+=2){let r=Ru(i,t,e);if(r)return r}}return null}function Sw(e,t){let i=ku(e);if(!i||typeof console>"u")return;let r=i.path.map(a=>`[${a}]`).join("");console.warn(`${t}${r}: ${bf(i.legacyFilter)}`)}const Ew={type:"boolean",default:!1,transition:!1,"property-type":"data-driven",expression:{interpolated:!1,parameters:["zoom","feature"]}};function In(e,t,i){if(e==null)return{filter:()=>!0,needGeometry:!1,getGlobalStateRefs:()=>new Set};Fu(e)?Sw(e,t):e=fo(e);let r=ho(e,t,Ew,i);if(r.result==="error")throw Error(r.value.map(a=>`${a.key}: ${a.message}`).join(", "));return{filter:(a,n,s)=>r.value.evaluate(a,n,{},s),needGeometry:wf(e),getGlobalStateRefs:()=>Dn(r.value.expression)}}function Pw(e,t){return e<t?-1:+(e>t)}function wf(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(wf(e[t]))return!0;return!1}function fo(e){if(!e)return!0;let t=e[0];return e.length<=1?t!=="any":t==="=="?Lu(e[1],e[2],"=="):t==="!="?mo(Lu(e[1],e[2],"==")):t==="<"||t===">"||t==="<="||t===">="?Lu(e[1],e[2],t):t==="any"?Cw(e.slice(1)):t==="all"?["all"].concat(e.slice(1).map(fo)):t==="none"?["all"].concat(e.slice(1).map(fo).map(mo)):t==="in"?Tf(e[1],e.slice(2)):t==="!in"?mo(Tf(e[1],e.slice(2))):t==="has"?Sf(e[1]):t!=="!has"||mo(Sf(e[1]))}function Lu(e,t,i){switch(e){case"$type":return[`filter-type-${i}`,t];case"$id":return[`filter-id-${i}`,t];default:return[`filter-${i}`,e,t]}}function Cw(e){return["any"].concat(e.map(fo))}function Tf(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(i=>typeof i!=typeof t[0])?["filter-in-large",e,["literal",t.sort(Pw)]]:["filter-in-small",e,["literal",t]]}}function Sf(e){switch(e){case"$type":return!0;case"$id":return["filter-has-id"];default:return["filter-has",e]}}function mo(e){return["!",e]}function Ef(e){let t=e.key,i=e.value;return i?[new $(t,i,"constants have been deprecated as of v8")]:[]}function Qe(e){return e instanceof Number||e instanceof String||e instanceof Boolean?e.valueOf():e}function Hr(e){if(Array.isArray(e))return e.map(Hr);if(e instanceof Object&&!(e instanceof Number||e instanceof String||e instanceof Boolean)){let t={};for(let i in e)t[i]=Hr(e[i]);return t}return Qe(e)}function ii(e){let t=e.key,i=e.value,r=e.valueSpec||{},a=e.objectElementValidators||{},n=e.style,s=e.styleSpec,o=e.validateSpec,l=[],u=oe(i);if(u!=="object")return[new $(t,i,`object expected, ${u} found`)];for(let h in i){let c=h.split(".")[0],d=xn(r,c)||r["*"],p;if(xn(a,c))p=a[c];else if(xn(r,c)){if(i[h]===void 0)continue;p=o}else if(a["*"])p=a["*"];else if(r["*"])p=o;else{l.push(new $(t,i[h],`unknown property "${h}"`));continue}l=l.concat(p({key:(t&&`${t}.`)+h,value:i[h],valueSpec:d,style:n,styleSpec:s,object:i,objectKey:h,validateSpec:o},i))}for(let h in r)a[h]||r[h].required&&r[h].default===void 0&&i[h]===void 0&&l.push(new $(t,i,`missing required property "${h}"`));return l}function Bu(e){let t=e.value,i=e.valueSpec,r=e.validateSpec,a=e.style,n=e.styleSpec,s=e.key,o=e.arrayElementValidator||r;if(oe(t)!=="array")return[new $(s,t,`array expected, ${oe(t)} found`)];if(i.length&&t.length!==i.length)return[new $(s,t,`array length ${i.length} expected, length ${t.length} found`)];let l={type:i.value,values:i.values};n.$version<7&&(l.function=i.function),oe(i.value)==="object"&&(l=i.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 go(e){let t=e.key,i=e.value,r=e.valueSpec,a=oe(i);return a==="number"&&i!==i&&(a="NaN"),a==="number"?"minimum"in r&&i<r.minimum?[new $(t,i,`${i} is less than the minimum value ${r.minimum}`)]:"maximum"in r&&i>r.maximum?[new $(t,i,`${i} is greater than the maximum value ${r.maximum}`)]:[]:[new $(t,i,`number expected, ${a} found`)]}function Pf(e){let t=e.valueSpec,i=Qe(e.value.type),r,a={},n,s,o=i!=="categorical"&&e.value.property===void 0,l=!o,u=oe(e.value.stops)==="array"&&oe(e.value.stops[0])==="array"&&oe(e.value.stops[0][0])==="object",h=ii({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 i==="identity"&&o&&h.push(new $(e.key,e.value,'missing required property "property"')),i!=="identity"&&!e.value.stops&&h.push(new $(e.key,e.value,'missing required property "stops"')),i==="exponential"&&e.valueSpec.expression&&!Iu(e.valueSpec)&&h.push(new $(e.key,e.value,"exponential functions not supported")),e.styleSpec.$version>=8&&(l&&!Ra(e.valueSpec)?h.push(new $(e.key,e.value,"property functions not supported")):o&&!cf(e.valueSpec)&&h.push(new $(e.key,e.value,"zoom functions not supported"))),(i==="categorical"||u)&&e.value.property===void 0&&h.push(new $(e.key,e.value,'"property" property is required')),h;function c(m){if(i==="identity")return[new $(m.key,m.value,'identity function may not have a "stops" property')];let g=[],_=m.value;return g=g.concat(Bu({key:m.key,value:_,valueSpec:m.valueSpec,validateSpec:m.validateSpec,style:m.style,styleSpec:m.styleSpec,arrayElementValidator:d})),oe(_)==="array"&&_.length===0&&g.push(new $(m.key,_,"array must have at least one stop")),g}function d(m){let g=[],_=m.value,y=m.key;if(oe(_)!=="array")return[new $(y,_,`array expected, ${oe(_)} found`)];if(_.length!==2)return[new $(y,_,`array length 2 expected, length ${_.length} found`)];if(u){if(oe(_[0])!=="object")return[new $(y,_,`object expected, ${oe(_[0])} found`)];if(_[0].zoom===void 0)return[new $(y,_,"object stop key must have zoom")];if(_[0].value===void 0)return[new $(y,_,"object stop key must have value")];if(s&&s>Qe(_[0].zoom))return[new $(y,_[0].zoom,"stop zoom values must appear in ascending order")];Qe(_[0].zoom)!==s&&(s=Qe(_[0].zoom),n=void 0,a={}),g=g.concat(ii({key:`${y}[0]`,value:_[0],valueSpec:{zoom:{}},validateSpec:m.validateSpec,style:m.style,styleSpec:m.styleSpec,objectElementValidators:{zoom:go,value:p}}))}else g=g.concat(p({key:`${y}[0]`,value:_[0],validateSpec:m.validateSpec,style:m.style,styleSpec:m.styleSpec},_));return uo(Hr(_[1]))?g.concat([new $(`${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 _=oe(m.value),y=Qe(m.value),x=m.value===null?g:m.value;if(!r)r=_;else if(_!==r)return[new $(m.key,x,`${_} stop domain type must match previous stop domain type ${r}`)];if(_!=="number"&&_!=="string"&&_!=="boolean")return[new $(m.key,x,"stop domain value must be a number, string, or boolean")];if(_!=="number"&&i!=="categorical"){let v=`number expected, ${_} found`;return Ra(t)&&i===void 0&&(v+='\nIf you intended to use a categorical function, specify `"type": "categorical"`.'),[new $(m.key,x,v)]}return i==="categorical"&&_==="number"&&(!isFinite(y)||Math.floor(y)!==y)?[new $(m.key,x,`integer expected, found ${y}`)]:i!=="categorical"&&_==="number"&&n!==void 0&&y<n?[new $(m.key,x,"stop domain values must appear in ascending order")]:(n=y,i==="categorical"&&y in a?[new $(m.key,x,"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 Ba(e){let t=(e.expressionContext==="property"?gf:ho)(Hr(e.value),e.key,e.valueSpec);if(t.result==="error")return t.value.map(r=>new $(`${e.key}${r.key}`,e.value,r.message));let i=t.value.expression||t.value._styleExpression.expression;if(e.expressionContext==="property"&&e.propertyKey==="text-font"&&!i.outputDefined())return[new $(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"&&!En(i))return[new $(e.key,e.value,'"feature-state" data expressions are not supported with layout properties.')];if(e.expressionContext==="filter"&&!En(i))return[new $(e.key,e.value,'"feature-state" data expressions are not supported with filters.')];if(e.expressionContext&&e.expressionContext.indexOf("cluster")===0){if(!oo(i,["zoom","feature-state"]))return[new $(e.key,e.value,'"zoom" and "feature-state" expressions are not supported with cluster properties.')];if(e.expressionContext==="cluster-initial"&&!so(i))return[new $(e.key,e.value,"Feature data expressions are not supported with initial expression part of cluster properties.")]}return[]}function Aw(e){let t=e.value,i=e.key,r=oe(t);return r==="boolean"?[]:[new $(i,t,`boolean expected, ${r} found`)]}function $u(e){let t=e.key,i=e.value,r=oe(i);return r==="string"?te.parse(String(i))?[]:[new $(t,i,`color expected, "${i}" found`)]:[new $(t,i,`color expected, ${r} found`)]}function Mn(e){let t=e.key,i=e.value,r=e.valueSpec,a=[];return Array.isArray(r.values)?r.values.indexOf(Qe(i))===-1&&a.push(new $(t,i,`expected one of [${r.values.join(", ")}], ${JSON.stringify(i)} found`)):Object.keys(r.values).indexOf(Qe(i))===-1&&a.push(new $(t,i,`expected one of [${Object.keys(r.values).join(", ")}], ${JSON.stringify(i)} found`)),a}function Dw(e,t){let i=e;for(let r of t)i=i[r];return i}function Iw(e,t){let i=ku(t);return i?[new $(`${e.key}${i.path.map(r=>`[${r}]`).join("")}`,Dw(e.value,i.path),bf(i.legacyFilter),null,"warning")]:[]}function Ou(e){let t=Hr(e.value);return Fu(t)?[...Iw(e,t),...Ba(Pn({},e,{expressionContext:"filter",valueSpec:{value:"boolean"}}))]:Cf(e)}function Cf(e){let t=e.value,i=e.key;if(oe(t)!=="array")return[new $(i,t,`array expected, ${oe(t)} found`)];let r=e.styleSpec,a,n=[];if(t.length<1)return[new $(i,t,"filter array must have at least 1 element")];switch(n=n.concat(Mn({key:`${i}[0]`,value:t[0],valueSpec:r.filter_operator,style:e.style,styleSpec:e.styleSpec})),Qe(t[0])){case"<":case"<=":case">":case">=":t.length>=2&&Qe(t[1])==="$type"&&n.push(new $(i,t,`"$type" cannot be use with operator "${t[0]}"`));case"==":case"!=":t.length!==3&&n.push(new $(i,t,`filter array for operator "${t[0]}" must have 3 elements`));case"in":case"!in":t.length>=2&&(a=oe(t[1]),a!=="string"&&n.push(new $(`${i}[1]`,t[1],`string expected, ${a} found`)));for(let s=2;s<t.length;s++)a=oe(t[s]),Qe(t[1])==="$type"?n=n.concat(Mn({key:`${i}[${s}]`,value:t[s],valueSpec:r.geometry_type,style:e.style,styleSpec:e.styleSpec})):a!=="string"&&a!=="number"&&a!=="boolean"&&n.push(new $(`${i}[${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(Cf({key:`${i}[${s}]`,value:t[s],style:e.style,styleSpec:e.styleSpec}));break;case"has":case"!has":a=oe(t[1]),t.length===2?a!=="string"&&n.push(new $(`${i}[1]`,t[1],`string expected, ${a} found`)):n.push(new $(i,t,`filter array for "${t[0]}" operator must have 2 elements`))}return n}function Af(e,t){let i=e.key,r=e.validateSpec,a=e.style,n=e.styleSpec,s=e.value,o=e.objectKey,l=n[`${t}_${e.layerType}`];if(!l)return[];let u=o.match(/^(.*)-transition$/);if(t==="paint"&&u&&l[u[1]]&&l[u[1]].transition)return r({key:i,value:s,valueSpec:n.transition,style:a,styleSpec:n});let h=e.valueSpec||l[o];if(!h)return[new $(i,s,`unknown property "${o}"`)];let c;if(oe(s)==="string"&&Ra(h)&&!h.tokens&&(c=/^{([^}]+)}$/.exec(s)))return[new $(i,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"&&lo(Hr(s))&&Qe(s.type)==="identity"&&d.push(new $(i,s,'"text-font" does not support identity functions')),d.concat(r({key:e.key,value:s,valueSpec:h,style:a,styleSpec:n,expressionContext:"property",propertyType:t,propertyKey:o}))}function Df(e){return Af(e,"paint")}function If(e){return Af(e,"layout")}function Mf(e){var l,u;let t=[],i=e.value,r=e.key,a=e.style,n=e.styleSpec;if(oe(i)!=="object")return[new $(r,i,`object expected, ${oe(i)} found`)];!i.type&&!i.ref&&t.push(new $(r,i,'either "type" or "ref" is required'));let s=Qe(i.type),o=Qe(i.ref);if(i.id){let h=Qe(i.id);for(let c=0;c<e.arrayIndex;c++){let d=a.layers[c];Qe(d.id)===h&&t.push(new $(r,i.id,`duplicate layer id "${i.id}", previously used at line ${d.id.__line__}`))}}if("ref"in i){["type","source","source-layer","filter","layout"].forEach(c=>{c in i&&t.push(new $(r,i[c],`"${c}" is prohibited for ref layers`))});let h;a.layers.forEach(c=>{Qe(c.id)===o&&(h=c)}),h?h.ref?t.push(new $(r,i.ref,"ref cannot reference another ref layer")):s=Qe(h.type):t.push(new $(r,i.ref,`ref layer "${o}" not found`))}else if(s!=="background")if(!i.source)t.push(new $(r,i,'missing required property "source"'));else{let h=a.sources&&a.sources[i.source],c=h&&Qe(h.type);h?c==="vector"&&s==="raster"?t.push(new $(r,i.source,`layer "${i.id}" requires a raster source`)):c!=="raster-dem"&&s==="hillshade"||c!=="raster-dem"&&s==="color-relief"?t.push(new $(r,i.source,`layer "${i.id}" requires a raster-dem source`)):c==="raster"&&s!=="raster"?t.push(new $(r,i.source,`layer "${i.id}" requires a vector source`)):c==="vector"&&!i["source-layer"]?t.push(new $(r,i,`layer "${i.id}" must specify a "source-layer"`)):c==="raster-dem"&&s!=="hillshade"&&s!=="color-relief"?t.push(new $(r,i.source,"raster-dem source can only be used with layer type 'hillshade' or 'color-relief'.")):s==="line"&&i.paint&&i.paint["line-gradient"]&&(c!=="geojson"||!h.lineMetrics)&&t.push(new $(r,i,`layer "${i.id}" specifies a line-gradient, which requires a GeoJSON source with \`lineMetrics\` enabled.`)):t.push(new $(r,i.source,`source "${i.source}" not found`))}return s==="raster"&&((l=i.paint)!=null&&l.resampling)&&((u=i.paint)!=null&&u["raster-resampling"])&&t.push(new $(r,i.paint,`layer "${i.id}" redundantly specifies "resampling" and "raster-resampling" paint properties, but only one is allowed. It is advised to use "resampling".`)),t=t.concat(ii({key:r,value:i,valueSpec:n.layer,style:e.style,styleSpec:e.styleSpec,validateSpec:e.validateSpec,objectElementValidators:{"*"(){return[]},type(){return e.validateSpec({key:`${r}.type`,value:i.type,valueSpec:n.layer.type,style:e.style,styleSpec:e.styleSpec,validateSpec:e.validateSpec,object:i,objectKey:"type"})},filter:Ou,layout(h){return ii({layer:i,key:h.key,value:h.value,style:h.style,styleSpec:h.styleSpec,validateSpec:h.validateSpec,objectElementValidators:{"*"(c){return If(Pn({layerType:s},c))}}})},paint(h){return ii({layer:i,key:h.key,value:h.value,style:h.style,styleSpec:h.styleSpec,validateSpec:h.validateSpec,objectElementValidators:{"*"(c){return Df(Pn({layerType:s},c))}}})}}})),t}function Er(e){let t=e.value,i=e.key,r=oe(t);return r==="string"?[]:[new $(i,t,`string expected, ${r} found`)]}function Mw(e){let t=e.sourceName??"",i=e.value,r=e.styleSpec,a=r.source_raster_dem,n=e.style,s=[],o=oe(i);if(i===void 0)return s;if(o!=="object")return s.push(new $("source_raster_dem",i,`object expected, ${o} found`)),s;let l=Qe(i.encoding)==="custom",u=["redFactor","greenFactor","blueFactor","baseShift"],h=e.value.encoding?`"${e.value.encoding}"`:"Default";for(let c in i)!l&&u.includes(c)?s.push(new $(c,i[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:i[c],valueSpec:a[c],validateSpec:e.validateSpec,style:n,styleSpec:r})):s.push(new $(c,i[c],`unknown property "${c}"`));return s}const zf={promoteId:zw};function Ff(e){let t=e.value,i=e.key,r=e.styleSpec,a=e.style,n=e.validateSpec;if(!t.type)return[new $(i,t,'"type" is required')];let s=Qe(t.type),o;switch(s){case"vector":case"raster":return o=ii({key:i,value:t,valueSpec:r[`source_${s.replace("-","_")}`],style:e.style,styleSpec:r,objectElementValidators:zf,validateSpec:n}),o;case"raster-dem":return o=Mw({sourceName:i,value:t,style:e.style,styleSpec:r,validateSpec:n}),o;case"geojson":if(o=ii({key:i,value:t,valueSpec:r.source_geojson,style:a,styleSpec:r,validateSpec:n,objectElementValidators:zf}),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(...Ba({key:`${i}.${l}.map`,value:h,expressionContext:"cluster-map"})),o.push(...Ba({key:`${i}.${l}.reduce`,value:c,expressionContext:"cluster-reduce"}))}return o;case"video":return ii({key:i,value:t,valueSpec:r.source_video,style:a,validateSpec:n,styleSpec:r});case"image":return ii({key:i,value:t,valueSpec:r.source_image,style:a,validateSpec:n,styleSpec:r});case"canvas":return[new $(i,null,"Please use runtime APIs to add canvas sources, rather than including them in stylesheets.","source.canvas")];default:return Mn({key:`${i}.type`,value:t.type,valueSpec:{values:["vector","raster","raster-dem","geojson","video","image"]}})}}function zw({key:e,value:t}){if(oe(t)==="string")return Er({key:e,value:t});{let i=[];for(let r in t)i.push(...Er({key:`${e}.${r}`,value:t[r]}));return i}}function Rf(e){let t=e.value,i=e.styleSpec,r=i.light,a=e.style,n=[],s=oe(t);if(t===void 0)return n;if(s!=="object")return n=n.concat([new $("light",t,`object expected, ${s} found`)]),n;for(let o in t){let l=o.match(/^(.*)-transition$/);n=l&&r[l[1]]&&r[l[1]].transition?n.concat(e.validateSpec({key:o,value:t[o],valueSpec:i.transition,validateSpec:e.validateSpec,style:a,styleSpec:i})):r[o]?n.concat(e.validateSpec({key:o,value:t[o],valueSpec:r[o],validateSpec:e.validateSpec,style:a,styleSpec:i})):n.concat([new $(o,t[o],`unknown property "${o}"`)])}return n}function kf(e){let t=e.value,i=e.styleSpec,r=i.sky,a=e.style,n=oe(t);if(t===void 0)return[];if(n!=="object")return[new $("sky",t,`object expected, ${n} found`)];let s=[];for(let o in t)s=r[o]?s.concat(e.validateSpec({key:o,value:t[o],valueSpec:r[o],style:a,styleSpec:i})):s.concat([new $(o,t[o],`unknown property "${o}"`)]);return s}function Lf(e){let t=e.value,i=e.styleSpec,r=i.terrain,a=e.style,n=[],s=oe(t);if(t===void 0)return n;if(s!=="object")return n=n.concat([new $("terrain",t,`object expected, ${s} found`)]),n;for(let o in t)n=r[o]?n.concat(e.validateSpec({key:o,value:t[o],valueSpec:r[o],validateSpec:e.validateSpec,style:a,styleSpec:i})):n.concat([new $(o,t[o],`unknown property "${o}"`)]);return n}function Fw(e){return Er(e).length===0?[]:Ba(e)}function Rw(e){return Er(e).length===0?[]:Ba(e)}function kw(e){let t=e.key,i=e.value;if(oe(i)==="array"){if(i.length<1||i.length>4)return[new $(t,i,`padding requires 1 to 4 values; ${i.length} values found`)];let r={type:"number"},a=[];for(let n=0;n<i.length;n++)a=a.concat(e.validateSpec({key:`${t}[${n}]`,value:i[n],validateSpec:e.validateSpec,valueSpec:r}));return a}return go({key:t,value:i,valueSpec:{}})}function Lw(e){let t=e.key,i=e.value;if(oe(i)==="array"){let r={type:"number"};if(i.length<1)return[new $(t,i,"array length at least 1 expected, length 0 found")];let a=[];for(let n=0;n<i.length;n++)a=a.concat(e.validateSpec({key:`${t}[${n}]`,value:i[n],validateSpec:e.validateSpec,valueSpec:r}));return a}return go({key:t,value:i,valueSpec:{}})}function Bw(e){let t=e.key,i=e.value;if(oe(i)==="array"){if(i.length<1)return[new $(t,i,"array length at least 1 expected, length 0 found")];let r=[];for(let a=0;a<i.length;a++)r=r.concat($u({key:`${t}[${a}]`,value:i[a]}));return r}return $u({key:t,value:i})}function $w(e){let t=e.key,i=e.value,r=oe(i),a=e.styleSpec;if(r!=="array"||i.length<1||i.length%2!=0)return[new $(t,i,"variableAnchorOffsetCollection requires a non-empty array of even length")];let n=[];for(let s=0;s<i.length;s+=2)n=n.concat(Mn({key:`${t}[${s}]`,value:i[s],valueSpec:a.layout_symbol["text-anchor"]})),n=n.concat(Bu({key:`${t}[${s+1}]`,value:i[s+1],valueSpec:{length:2,value:"number"},validateSpec:e.validateSpec,style:e.style,styleSpec:a}));return n}function Bf(e){let t=[],i=e.value,r=e.key;if(Array.isArray(i)){let a=[],n=[];for(let s in i)i[s].id&&a.includes(i[s].id)&&t.push(new $(r,i,`all the sprites' ids must be unique, but ${i[s].id} is duplicated`)),a.push(i[s].id),i[s].url&&n.includes(i[s].url)&&t.push(new $(r,i,`all the sprites' URLs must be unique, but ${i[s].url} is duplicated`)),n.push(i[s].url),t=t.concat(ii({key:`${r}[${s}]`,value:i[s],valueSpec:{id:{type:"string",required:!0},url:{type:"string",required:!0}},validateSpec:e.validateSpec}));return t}return Er({key:r,value:i})}function Ow(e){let t=e.value,i=e.styleSpec,r=i.projection,a=e.style,n=oe(t);if(t===void 0)return[];if(n!=="object")return[new $("projection",t,`object expected, ${n} found`)];let s=[];for(let o in t)s=r[o]?s.concat(e.validateSpec({key:o,value:t[o],valueSpec:r[o],style:a,styleSpec:i})):s.concat([new $(o,t[o],`unknown property "${o}"`)]);return s}function Nw(e){let t=e.key,i=e.value;i=i instanceof String?i.valueOf():i;let r=oe(i);return r==="array"&&!jw(i)&&!Vw(i)?[new $(t,i,`projection expected, invalid array ${JSON.stringify(i)} found`)]:["array","string"].includes(r)?[]:[new $(t,i,`projection expected, invalid type "${r}" found`)]}function Vw(e){return!!["interpolate","step","literal"].includes(e[0])}function jw(e){return Array.isArray(e)&&e.length===3&&typeof e[0]=="string"&&typeof e[1]=="string"&&typeof e[2]=="number"}function Nu(e){return!!e&&e.constructor===Object}function $f(e){return Nu(e.value)?[]:[new $(e.key,e.value,`object expected, ${oe(e.value)} found`)]}const Of=1114111,Uw=/^u\+(?:([0-9a-f]{1,6})(?:-([0-9a-f]{1,6}))?|([0-9a-f]{0,5}\?{1,6}))$/i;function Gw(e,t){if(oe(t)!=="string")return[];let i=`${t}`,r=()=>[new $(e,t,'invalid unicode range, expected a value such as "U+26", "U+0-10FFFF" or "U+4??"')],a=i.match(Uw);if(!a)return r();let[,n,s,o]=a;if(o!==void 0)return o.length>6?r():[];let l=parseInt(n,16),u=s===void 0?l:parseInt(s,16);return l>Of||u>Of?[new $(e,t,"unicode range is out of bounds, the maximum code point is U+10FFFF")]:l>u?[new $(e,t,`unicode range start must not be greater than its end, but ${i} is`)]:[]}function Nf(e){let t=e.key??"font-faces",i=e.value,r=e.validateSpec,a=e.styleSpec??Ap,n=e.style;if(!Nu(i))return[new $(t,i,`object expected, ${oe(i)} found`)];let s=[];for(let o in i){let l=i[o],u=oe(l);if(u==="string")s.push(...Er({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(...ii({key:p,value:d,valueSpec:h,styleSpec:a,style:n,validateSpec:r}));let f=Nu(d)?d["unicode-range"]:void 0;if(oe(f)==="array")for(let[m,g]of f.entries())s.push(...Gw(`${p}.unicode-range[${m}]`,g))}}else s.push(new $(`${t}.${o}`,l,`string or array expected, ${u} found`))}return s}const Vf={"*"(){return[]},array:Bu,boolean:Aw,number:go,color:$u,constants:Ef,enum:Mn,filter:Ou,function:Pf,layer:Mf,object:ii,source:Ff,light:Rf,sky:kf,terrain:Lf,projection:Ow,projectionDefinition:Nw,string:Er,formatted:Fw,resolvedImage:Rw,padding:kw,numberArray:Lw,colorArray:Bw,variableAnchorOffsetCollection:$w,sprite:Bf,state:$f,fontFaces:Nf};function _o(e){let t=e.value,i=e.valueSpec,r=e.styleSpec;return e.validateSpec=_o,i.expression&&lo(Qe(t))?Pf(e):i.expression&&uo(Hr(t))?Ba(e):i.type&&Vf[i.type]?Vf[i.type](e):ii(Pn({},e,{valueSpec:i.type?r[i.type]:i}))}function jf(e){let t=e.value,i=e.key,r=Er(e);return r.length||(t.indexOf("{fontstack}")===-1&&r.push(new $(i,t,'"glyphs" url must include a "{fontstack}" token')),t.indexOf("{range}")===-1&&r.push(new $(i,t,'"glyphs" url must include a "{range}" token'))),r}function ri(e,t=z){let i=[];return i=i.concat(_o({key:"",value:e,valueSpec:t.$root,styleSpec:t,style:e,validateSpec:_o,objectElementValidators:{glyphs:jf,"*"(){return[]}}})),e.constants&&(i=i.concat(Ef({key:"constants",value:e.constants}))),Uf(i)}ri.source=mi(fi(Ff)),ri.sprite=mi(fi(Bf)),ri.glyphs=mi(fi(jf)),ri.fontFaces=mi(fi(Nf)),ri.light=mi(fi(Rf)),ri.sky=mi(fi(kf)),ri.terrain=mi(fi(Lf)),ri.state=mi(fi($f)),ri.layer=mi(fi(Mf)),ri.filter=mi(fi(Ou)),ri.paintProperty=mi(fi(Df)),ri.layoutProperty=mi(fi(If));function fi(e){return function(t){return e(Object.assign({},t,{validateSpec:_o}))}}function Uf(e){return[].concat(e).sort((t,i)=>t.line-i.line)}function mi(e){return function(...t){return Uf(e.apply(this,t))}}const Zw={type:"enum","property-type":"data-constant",expression:{interpolated:!1,parameters:["global-state"]},values:{visible:{},none:{}},transition:!1,default:"visible"};var qw=class{constructor(t,i,r){this._rootKey=i,this._globalState=r,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 i=ho(t,this._rootKey,Zw,this._globalState);if(i.result==="error")throw this._literalValue="visible",this._compiledValue=void 0,Error(i.value.map(r=>`${r.key}: ${r.message}`).join(", "));this._literalValue=void 0,this._compiledValue=i.value,this._globalStateRefs=Dn(i.value.expression)}getGlobalStateRefs(){return this._globalStateRefs}};function Ww(e,t,i){return new qw(e,t,i)}const Ht=ri,Gf=new Set(Object.keys(z).filter(e=>e.startsWith("source_")).map(e=>e.slice(7).replaceAll("_","-")));function Hw(e){return Object.entries(e.sources??{}).filter(([,t])=>!Gf.has(t.type)).map(([t])=>`sources.${t}`)}function Zf(e,t){let i=Hw(t);return Vu(e,Ht(t).filter(({message:r})=>!i.some(a=>r.startsWith(`${a}:`)||r.startsWith(`${a}.`))))}function Vu(e,t){let i=!1;for(let r of t){if(r.severity==="warning"){le(r.message);continue}e.fire(new K(Error(r.message))),i=!0}return i}function zn(e,t,i,r){return(r==null?void 0:r.validate)!==!1&&Vu(e,t({styleSpec:z,...i}))}var ju=class C1{constructor(t,i,r){let a=this.cells=[];if(t instanceof ArrayBuffer){this.arrayBuffer=t;let s=new Int32Array(this.arrayBuffer);t=s[0],i=s[1],r=s[2],this.d=i+2*r;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=i+2*r;for(let s=0;s<this.d*this.d;s++)a.push([]);this.keys=[],this.bboxes=[]}this.n=i,this.extent=t,this.padding=r,this.scale=i/t,this.uid=0;let n=r/i*t;this.min=-n,this.max=t+n}insert(t,i,r,a,n){this._forEachCell(i,r,a,n,this._insertCell,this.uid++,void 0,void 0),this.keys.push(t),this.bboxes.push(i),this.bboxes.push(r),this.bboxes.push(a),this.bboxes.push(n)}_insertReadonly(){throw Error("Cannot insert into a GridIndex created from an ArrayBuffer.")}_insertCell(t,i,r,a,n,s){this.cells[n].push(s)}query(t,i,r,a,n){let s=this.min,o=this.max;if(t<=s&&i<=s&&o<=r&&o<=a&&!n)return[...this.keys];{let l=[];return this._forEachCell(t,i,r,a,this._queryCell,l,{},n),l}}_queryCell(t,i,r,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]&&i<=c[p+3]&&r>=c[p+0]&&a>=c[p+1])?(o[d]=!0,s.push(h[d])):o[d]=!1}}}_forEachCell(t,i,r,a,n,s,o,l){let u=this._convertToCellCoord(t),h=this._convertToCellCoord(i),c=this._convertToCellCoord(r),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,i,r,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,i=3+this.cells.length+1+1,r=0;for(let s of this.cells)r+=s.length;let a=new Int32Array(i+r+this.keys.length+this.bboxes.length);a[0]=this.extent,a[1]=this.n,a[2]=this.padding;let n=i;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,i){let r=t.toArrayBuffer();return i&&i.push(r),{buffer:r}}static deserialize(t){return new C1(t.buffer)}};const ir={};function U(e,t,i={}){if(ir[e])throw Error(`${e} is already registered.`);Object.defineProperty(t,"_classRegistryKey",{value:e,writeable:!1}),ir[e]={klass:t,omit:i.omit||[],shallow:i.shallow||[]}}U("Object",Object),U("Set",Set),U("TransferableGridIndex",ju),U("Color",te),U("Error",Error),U("AJAXError",fn),U("ResolvedImage",Vi),U("StylePropertyFunction",_f),U("StyleExpression",zu,{omit:["_evaluator"]}),U("ZoomDependentExpression",co),U("ZoomConstantExpression",An),U("CompoundExpression",qr,{omit:["_evaluate"]});for(let e in Fa)Fa[e]._classRegistryKey||U(`Expression_${e}`,Fa[e]);function qf(e){var t;return e&&typeof ArrayBuffer<"u"&&(e instanceof ArrayBuffer||((t=e.constructor)==null?void 0:t.name)==="ArrayBuffer")}function Uu(e){let t=e.constructor;return e.$name||t._classRegistryKey}function Xw(e){if(typeof e!="object"||!e)return!1;let t=Uu(e);return t&&t!=="Object"}function Wf(e){return!Xw(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||qf(e)||jr(e)||ArrayBuffer.isView(e)||e instanceof ImageData)}function Fn(e,t){if(Wf(e))return(qf(e)||jr(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(Fn(s,t));return n}if(typeof e!="object")throw Error(`can't serialize object of type ${typeof e}`);let i=Uu(e);if(!i)throw Error(`can't serialize object of unregistered class ${e.constructor.name}`);if(!ir[i])throw Error(`${i} is not registered.`);let{klass:r}=ir[i],a=r.serialize?r.serialize(e,t):{};if(r.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)||ir[i].omit.includes(n))continue;let s=e[n];s!==void 0&&(a[n]=ir[i].shallow.includes(n)?s:Fn(s,t))}e instanceof Error&&(a.message=e.message)}if(a.$name)throw Error("$name property is reserved for worker serialization logic.");return i!=="Object"&&(a.$name=i),a}function Rn(e){if(Wf(e))return e;if(Array.isArray(e))return e.map(Rn);if(typeof e!="object")throw Error(`can't deserialize object of type ${typeof e}`);let t=Uu(e)||"Object";if(!ir[t])throw Error(`can't deserialize unregistered class ${t}`);let{klass:i}=ir[t];if(!i)throw Error(`can't deserialize unregistered class ${t}`);if(i.deserialize)return i.deserialize(e);let r=Object.create(i.prototype);for(let a of Object.keys(e)){if(a==="$name")continue;let n=e[a];r[a]=ir[t].shallow.includes(a)?n:Rn(n)}return r}var Gu=class{constructor(){this.first=!0}update(t,i){let r=Math.floor(t);return this.first?(this.first=!1,this.lastIntegerZoom=r,this.lastIntegerZoomTime=0,this.lastZoom=t,this.lastFloorZoom=r,!0):(this.lastFloorZoom>r?(this.lastIntegerZoom=r+1,this.lastIntegerZoomTime=i):this.lastFloorZoom<r&&(this.lastIntegerZoom=r,this.lastIntegerZoomTime=i),t!==this.lastZoom&&(this.lastZoom=t,this.lastFloorZoom=r,!0))}};function Yw(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 Kw(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 yo(e){return/[\u02EA\u02EB\u1100-\u11FF\u1400-\u167F\u18B0-\u18F5\u2E80-\u2E99\u2E9B-\u2EF3\u2F00-\u2FD5\u2FF0-\u3007\u3012\u3013\u3020-\u302F\u3031-\u303F\u3041-\u3096\u309D-\u30FB\u30FD-\u30FF\u3105-\u312F\u3131-\u318E\u3190-\uA48C\uA490-\uA4C6\uA960-\uA97C\uAC00-\uD7A3\uD7B0-\uD7C6\uD7CB-\uD7FB\uF900-\uFA6D\uFA70-\uFAD9\uFE10-\uFE1F\uFE30-\uFE48\uFE50-\uFE57\uFE5F-\uFE62\uFE67-\uFE6F\uFF00-\uFF07\uFF0A-\uFF0C\uFF0E-\uFF19\uFF1F-\uFF3A\uFF3C\uFF3E\uFF40-\uFF5A\uFFE0-\uFFE2\uFFE4-\uFFE7]|\uD802[\uDD80-\uDD9F]|\uD805[\uDD80-\uDDFF]|\uD806[\uDE00-\uDEBF]|\uD811[\uDC00-\uDE7F]|\uD81B[\uDFE0-\uDFE4\uDFF0-\uDFF6]|[\uD81C-\uD822\uD83D\uD840-\uD868\uD86A-\uD86D\uD86F-\uD872\uD874-\uD879\uD880-\uD883\uD885-\uD88C][\uDC00-\uDFFF]|\uD823[\uDC00-\uDCD5\uDCFF-\uDD1E\uDD80-\uDDF2]|\uD82B[\uDFF0-\uDFF3\uDFF5-\uDFFB\uDFFD\uDFFE]|\uD82C[\uDC00-\uDD22\uDD30-\uDEFB]|\uD833[\uDEC0-\uDFCF]|\uD834[\uDC00-\uDDFF\uDEE0-\uDF7F]|\uD836[\uDC00-\uDEAF]|\uD83C[\uDC00-\uDE00\uDF00-\uDFFF]|\uD83E[\uDD00-\uDEFF]|\uD869[\uDC00-\uDEDF\uDF00-\uDFFF]|\uD86E[\uDC00-\uDC1D\uDC20-\uDFFF]|\uD873[\uDC00-\uDEAD\uDEB0-\uDFFF]|\uD87A[\uDC00-\uDFE0\uDFF0-\uDFFF]|\uD87B[\uDC00-\uDE5D]|\uD87E[\uDC00-\uDE1D]|\uD884[\uDC00-\uDF4A\uDF50-\uDFFF]|\uD88D[\uDC00-\uDC79]/gim.test(String.fromCodePoint(e))}function Jw(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 Qw(e){return/[\u0900-\u0DFF\u0F00-\u109F\u1780-\u17FF]/gim.test(String.fromCodePoint(e))}function e2(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 Hf(e){return/[\u0E01-\u0E3A\u0E40-\u0E5B\u0E81\u0E82\u0E84\u0E86-\u0E8A\u0E8C-\u0EA3\u0EA5\u0EA7-\u0EBD\u0EC0-\u0EC4\u0EC6\u0EC8-\u0ECE\u0ED0-\u0ED9\u0EDC-\u0EDF\u0F00-\u0F47\u0F49-\u0F6C\u0F71-\u0F97\u0F99-\u0FBC\u0FBE-\u0FCC\u0FCE-\u0FD4\u0FD9\u0FDA\u1000-\u109F\u1780-\u17DD\u17E0-\u17E9\u17F0-\u17F9\u19E0-\u19FF\u1B00-\u1B4C\u1B4E-\u1B7F\uA980-\uA9CD\uA9D0-\uA9D9\uA9DE-\uA9FE\uAA60-\uAA7F]|\uD805[\uDED0-\uDEE3]/gim.test(String.fromCodePoint(e))}function t2(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)}function Zu(e){return/\s/u.test(String.fromCodePoint(e))}function qu(e){for(let t of e)if(yo(t.codePointAt(0)))return!0;return!1}function i2(e){for(let t of e)if(!a2(t.codePointAt(0)))return!1;return!0}function Xf(e){let t=e.map(i=>{try{return RegExp(`\\p{sc=${i}}`,"u").source}catch{return null}}).filter(i=>i);return new RegExp(t.join("|"),"u")}const r2=Xf(["Arab","Dupl","Mong","Ougr","Syrc"]);function a2(e){return!r2.test(String.fromCodePoint(e))}function Yf(e){return!(yo(e)||Jw(e))}function Kf(e){return new RegExp("\\p{sc=Arab}","u").test(String.fromCodePoint(e))}const n2=Xf("Adlm.Arab.Armi.Avst.Chrs.Cprt.Egyp.Elym.Gara.Hatr.Hebr.Hung.Khar.Lydi.Mand.Mani.Mend.Merc.Mero.Narb.Nbat.Nkoo.Orkh.Palm.Phli.Phlp.Phnx.Prti.Rohg.Samr.Sarb.Sogo.Syrc.Thaa.Todr.Yezi".split("."));function Wu(e){return n2.test(String.fromCodePoint(e))}function s2(e,t){return!t&&Wu(e)?!1:!Qw(e)}function o2(e){for(let t of e)if(Wu(t.codePointAt(0)))return!0;return!1}function l2(e,t){for(let i of e)if(!s2(i.codePointAt(0),t))return!1;return!0}const Xr=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(Xr.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 i=e.pluginURL,r=new Promise(n=>{this.loadScriptResolve=n}),a=new Promise(n=>setTimeout(()=>n(),this.TIMEOUT));if(await t(i),await Promise.race([r,a]),this.isParsed()){let n={pluginStatus:"loaded",pluginURL:i};return this.setState(n),n}throw this.setState({pluginStatus:"error",pluginURL:""}),Error(`RTL Text Plugin failed to import scripts from ${i}`)}};var be=class{constructor(t,i){this.isSupportedScript=u2,this.zoom=t,i?(this.now=i.now||0,this.fadeDuration=i.fadeDuration||0,this.zoomHistory=i.zoomHistory||new Gu,this.transition=i.transition||{}):(this.now=0,this.fadeDuration=0,this.zoomHistory=new Gu,this.transition={})}crossFadingFactor(){return this.fadeDuration===0?1:Math.min((this.now-this.zoomHistory.lastIntegerZoomTime)/this.fadeDuration,1)}getCrossfadeParameters(){let t=this.zoom,i=t-Math.floor(t),r=this.crossFadingFactor();return t>this.zoomHistory.lastIntegerZoom?{fromScale:2,toScale:1,t:i+(1-i)*r}:{fromScale:.5,toScale:1,t:1-(1-r)*i}}};function u2(e){return l2(e,Xr.getRTLTextPluginStatus()==="loaded")}const Hu="-transition";var vo=class{constructor(t,i,r,a){this.property=t,this.value=i,this.expression=xw(i===void 0?t.specification.default:i,r,t.specification,a)}isDataDriven(){return this.expression.kind==="source"||this.expression.kind==="composite"}getGlobalStateRefs(){return this.expression.globalStateRefs||new Set}possiblyEvaluate(t,i,r){return this.property.possiblyEvaluate(this,t,i,r)}},Xu=class{constructor(t,i,r){this.property=t,this.value=new vo(t,void 0,i,r)}transitioned(t,i){return new Jf(this.property,this.value,i,Z({},t.transition,this.transition),t.now)}untransitioned(){return new Jf(this.property,this.value,null,{},0)}},xo=class{constructor(t,i,r){this._properties=t,this._values=Object.create(t.defaultTransitionablePropertyValues),this._globalState=r,this._rootKey=i}_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,i){Object.hasOwn(this._values,t)||(this._values[t]=new Xu(this._values[t].property,this._propertyRootKey(t),this._globalState)),this._values[t].value=new vo(this._values[t].property,i===null?void 0:Wt(i),this._propertyRootKey(t),this._globalState)}getTransition(t){return Wt(this._values[t].transition)}setTransition(t,i){Object.hasOwn(this._values,t)||(this._values[t]=new Xu(this._values[t].property,this._propertyRootKey(t),this._globalState)),this._values[t].transition=Wt(i)||void 0}serialize(){let t={};for(let i of Object.keys(this._values)){let r=this.getValue(i);r!==void 0&&(t[i]=r);let a=this.getTransition(i);a!==void 0&&(t[`${i}${Hu}`]=a)}return t}transitioned(t,i){let r=new Qf(this._properties);for(let a of Object.keys(this._values))r._values[a]=this._values[a].transitioned(t,i._values[a]);return r}untransitioned(){let t=new Qf(this._properties);for(let i of Object.keys(this._values))t._values[i]=this._values[i].untransitioned();return t}},Jf=class{constructor(t,i,r,a,n){this.property=t,this.value=i,this.begin=n+a.delay||0,this.end=this.begin+a.duration||0,t.specification.transition&&(a.delay||a.duration)&&(this.prior=r)}possiblyEvaluate(t,i,r){let a=t.now||0,n=this.value.possiblyEvaluate(t,i,r),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,i,r);{let o=(a-this.begin)/(this.end-this.begin);return this.property.interpolate(s.possiblyEvaluate(t,i,r),n,Cx(o))}}},Qf=class{constructor(t){this._properties=t,this._values=Object.create(t.defaultTransitioningPropertyValues)}possiblyEvaluate(t,i,r){let a=new bo(this._properties);for(let n of Object.keys(this._values))a._values[n]=this._values[n].possiblyEvaluate(t,i,r);return a}hasTransition(){for(let t of Object.keys(this._values))if(this._values[t].prior)return!0;return!1}},h2=class{constructor(t,i,r){this._properties=t,this._values=Object.create(t.defaultPropertyValues),this._globalState=r,this._rootKey=i}_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,i){this._values[t]=new vo(this._values[t].property,i===null?void 0:Wt(i),this._propertyRootKey(t),this._globalState)}serialize(){let t={};for(let i of Object.keys(this._values)){let r=this.getValue(i);r!==void 0&&(t[i]=r)}return t}possiblyEvaluate(t,i,r){let a=new bo(this._properties);for(let n of Object.keys(this._values))a._values[n]=this._values[n].possiblyEvaluate(t,i,r);return a}},gi=class{constructor(t,i,r){this.property=t,this.value=i,this.parameters=r}isConstant(){return this.value.kind==="constant"}constantOr(t){return this.value.kind==="constant"?this.value.value:t}evaluate(t,i,r,a){return this.property.evaluate(this.value,this.parameters,t,i,r,a)}},bo=class{constructor(t){this._properties=t,this._values=Object.create(t.defaultPossiblyEvaluatedValues)}get(t){return this._values[t]}};function em(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 tm(e,t){let i=em(e),r=em(t);return i!==void 0&&r!==void 0&&i!==r}var j=class{constructor(t,i){this.specification=t,this.name=i}possiblyEvaluate(t,i){if(t.isDataDriven())throw Error("Value should not be data driven");return t.expression.evaluate(i)}interpolate(t,i,r){if(tm(t,i))return le(`Property "${this.name}" is trying to interpolate arrays of different lengths. Rendering may 'jump'.`),i;let a=this.specification.type,n=Oe[a];return n?n(t,i,r):t}},J=class{constructor(t,i,r){this.specification=t,this.name=i,this.overrides=r}possiblyEvaluate(t,i,r,a){return t.expression.kind==="constant"||t.expression.kind==="camera"?new gi(this,{kind:"constant",value:t.expression.evaluate(i,null,{},r,a)},i):new gi(this,t.expression,i)}interpolate(t,i,r){if(t.value.kind!=="constant"||i.value.kind!=="constant")return t;if(t.value.value===void 0||i.value.value===void 0)return new gi(this,{kind:"constant",value:void 0},t.parameters);if(tm(t.value.value,i.value.value))return le(`Property "${this.name}" is trying to interpolate arrays of different lengths. Rendering may 'jump'.`),i;let a=this.specification.type,n=Oe[a];if(n){let s=n(t.value.value,i.value.value,r);return new gi(this,{kind:"constant",value:s},t.parameters)}return t}evaluate(t,i,r,a,n,s){return t.kind==="constant"?t.value:t.evaluate(i,r,a,n,s)}},kn=class extends J{possiblyEvaluate(t,i,r,a){if(t.value===void 0)return new gi(this,{kind:"constant",value:void 0},i);if(t.expression.kind==="constant"){let n=t.expression.evaluate(i,null,{},r,a),s=t.property.specification.type==="resolvedImage"&&typeof n!="string"?n.name:n,o=this._calculate(s,s,s,i);return new gi(this,{kind:"constant",value:o},i)}if(t.expression.kind==="camera"){let n=this._calculate(t.expression.evaluate({zoom:i.zoom-1}),t.expression.evaluate({zoom:i.zoom}),t.expression.evaluate({zoom:i.zoom+1}),i);return new gi(this,{kind:"constant",value:n},i)}return new gi(this,t.expression,i)}evaluate(t,i,r,a,n,s){if(t.kind==="source"){let o=t.evaluate(i,r,a,n,s);return this._calculate(o,o,o,i)}return t.kind==="composite"?this._calculate(t.evaluate({zoom:Math.floor(i.zoom)-1},r,a),t.evaluate({zoom:Math.floor(i.zoom)},r,a),t.evaluate({zoom:Math.floor(i.zoom)+1},r,a),i):t.value}_calculate(t,i,r,a){return a.zoom>a.zoomHistory.lastIntegerZoom?{from:t,to:i}:{from:r,to:i}}interpolate(t){return t}},im=class{constructor(t,i){this.specification=t,this.name=i}possiblyEvaluate(t,i,r,a){if(t.value!==void 0){if(t.expression.kind==="constant"){let n=t.expression.evaluate(i,null,{},r,a);return this._calculate(n,n,n,i)}return this._calculate(t.expression.evaluate(new be(Math.floor(i.zoom-1),i)),t.expression.evaluate(new be(Math.floor(i.zoom),i)),t.expression.evaluate(new be(Math.floor(i.zoom+1),i)),i)}}_calculate(t,i,r,a){return a.zoom>a.zoomHistory.lastIntegerZoom?{from:t,to:i}:{from:r,to:i}}interpolate(t){return t}},wo=class{constructor(t,i){this.specification=t,this.name=i}possiblyEvaluate(t,i,r,a){return!!t.expression.evaluate(i,null,{},r,a)}interpolate(){return!1}},yt=class{constructor(t){this.properties=t,this.defaultPropertyValues={},this.defaultTransitionablePropertyValues={},this.defaultTransitioningPropertyValues={},this.defaultPossiblyEvaluatedValues={},this.overridableProperties=[];for(let i in t){let r=t[i];r.specification.overridable&&this.overridableProperties.push(i);let a=this.defaultPropertyValues[i]=new vo(r,void 0,r.name,void 0),n=this.defaultTransitionablePropertyValues[i]=new Xu(r,r.name,void 0);this.defaultTransitioningPropertyValues[i]=n.untransitioned(),this.defaultPossiblyEvaluatedValues[i]=a.possiblyEvaluate({})}}};U("DataDrivenProperty",J),U("DataConstantProperty",j),U("CrossFadedDataDrivenProperty",kn),U("CrossFadedProperty",im),U("ColorRampProperty",wo);const rm=" is a PAINT property not a LAYOUT property. Use get/setPaintProperty instead?",Yu=" is a LAYOUT property not a PAINT property. Use get/setLayoutProperty instead?";var Pi=class extends ot{constructor(t,i,r){if(super(),this.id=t.id,this.type=t.type,this._globalState=r,this._featureFilter={filter:()=>!0,needGeometry:!1,getGlobalStateRefs:()=>new Set},this._visibilityExpression=Ww(this.visibility,`layers[${this.id}].layout.visibility`,r),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=In(t.filter,`layers[${this.id}].filter`,r)),i.layout&&(this._unevaluatedLayout=new h2(i.layout,`layers[${this.id}].layout`,r)),i.paint)){this._transitionablePaint=new xo(i.paint,`layers[${this.id}].paint`,r);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 bo(i.paint)}}setFilter(t){this.filter=t,this._featureFilter=In(t,`layers[${this.id}].filter`,this._globalState)}getCrossfadeParameters(){return this._crossfadeParameters}getLayoutProperty(t){var i;if(t==="visibility")return this.visibility;if((i=this._transitionablePaint)!=null&&i.hasProperty(t))throw Error(t+rm);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 i of this._visibilityExpression.getGlobalStateRefs())t.add(i);if(this._unevaluatedLayout)for(let i in this._unevaluatedLayout._values){let r=this._unevaluatedLayout._values[i];for(let a of r.getGlobalStateRefs())t.add(a)}for(let i of this._featureFilter.getGlobalStateRefs())t.add(i);return t}getPaintAffectingGlobalStateRefs(){let t=new globalThis.Map;if(this._transitionablePaint)for(let i in this._transitionablePaint._values){let r=this._transitionablePaint._values[i].value;for(let a of r.getGlobalStateRefs()){let n=t.get(a)??[];n.push({name:i,value:r.value}),t.set(a,n)}}return t}getVisibilityAffectingGlobalStateRefs(){return this._visibilityExpression.getGlobalStateRefs()}setLayoutProperty(t,i,r={}){var a;if(t==="visibility"){this.visibility=i,this._visibilityExpression.setValue(i),this.recalculateVisibility();return}if((a=this._transitionablePaint)!=null&&a.hasProperty(t)){this.fire(new K(Error(t+rm)));return}i!=null&&this._validate(Ht.layoutProperty,`layers.${this.id}.layout.${t}`,t,i,r)||this._unevaluatedLayout.setValue(t,i)}getPaintProperty(t){var i,r;if(t.endsWith("-transition")){let a=t.slice(0,-11);if(a==="visibility"||(i=this._unevaluatedLayout)!=null&&i.hasProperty(a))throw Error(t+Yu);return this._transitionablePaint.getTransition(a)}if(t==="visibility"||(r=this._unevaluatedLayout)!=null&&r.hasProperty(t))throw Error(t+Yu);return this._transitionablePaint.getValue(t)}setPaintProperty(t,i,r={}){var a;if(t==="visibility"||(a=this._unevaluatedLayout)!=null&&a.hasProperty(t))return this.fire(new K(Error(t+Yu))),!1;if(i!=null&&this._validate(Ht.paintProperty,`layers.${this.id}.paint.${t}`,t,i,r))return!1;if(t.endsWith("-transition"))return this._transitionablePaint.setTransition(t.slice(0,-11),i||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,i),this._handleSpecialPaintPropertyUpdate(t);let u=this._transitionablePaint._values[t].value;return u.isDataDriven()||o||s||this._handleOverridablePaintPropertyUpdate(t,l,u)}}_handleSpecialPaintPropertyUpdate(t){}_handleOverridablePaintPropertyUpdate(t,i,r){return!1}isHidden(t=this.minzoom,i=!1){return this.minzoom&&t<(i?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)}hasTransition(){return this._transitioningPaint.hasTransition()}recalculateVisibility(){this._evaluatedVisibility=this._visibilityExpression.evaluate()}recalculate(t,i){t.getCrossfadeParameters&&(this._crossfadeParameters=t.getCrossfadeParameters()),this._unevaluatedLayout&&(this.layout=this._unevaluatedLayout.possiblyEvaluate(t,void 0,i)),this.paint=this._transitioningPaint.possiblyEvaluate(t,void 0,i)}serialize(){var i,r;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:(i=this._unevaluatedLayout)==null?void 0:i.serialize(),paint:(r=this._transitionablePaint)==null?void 0:r.serialize()};return this.visibility&&(t.layout||(t.layout={}),t.layout.visibility=this.visibility),gp(t,(a,n)=>a!==void 0&&!(n==="layout"&&!Object.keys(a).length)&&!(n==="paint"&&!Object.keys(a).length))}_validate(t,i,r,a,n={}){return zn(this,t,{key:i,layerType:this.type,objectKey:r,value:a},n)}is3D(){return!1}isTileClipped(){return!1}hasOffscreenPass(){return!1}resize(){}isStateDependent(){for(let t in this.paint._values){let i=this.paint.get(t);if(i instanceof gi&&Ra(i.property.specification)&&(i.value.kind==="source"||i.value.kind==="composite")&&i.value.isStateDependent)return!0}return!1}};let c2;const d2=()=>c2||(c2=new yt({"raster-opacity":new j(z.paint_raster["raster-opacity"],"raster-opacity"),"raster-hue-rotate":new j(z.paint_raster["raster-hue-rotate"],"raster-hue-rotate"),"raster-brightness-min":new j(z.paint_raster["raster-brightness-min"],"raster-brightness-min"),"raster-brightness-max":new j(z.paint_raster["raster-brightness-max"],"raster-brightness-max"),"raster-saturation":new j(z.paint_raster["raster-saturation"],"raster-saturation"),"raster-contrast":new j(z.paint_raster["raster-contrast"],"raster-contrast"),resampling:new j(z.paint_raster.resampling,"resampling"),"raster-resampling":new j(z.paint_raster["raster-resampling"],"raster-resampling"),"raster-fade-duration":new j(z.paint_raster["raster-fade-duration"],"raster-fade-duration")}));var p2={get paint(){return d2()}};const Ku=e=>e.type==="raster";var f2=class extends Pi{constructor(t,i){super(t,p2,i)}};const m2={Int8:Int8Array,Uint8:Uint8Array,Int16:Int16Array,Uint16:Uint16Array,Int32:Int32Array,Uint32:Uint32Array,Float32:Float32Array};var Ln=class{constructor(t,i){this._structArray=t,this._pos1=i*this.size,this._pos2=this._pos1/2,this._pos4=this._pos1/4,this._pos8=this._pos1/8}},qe=class{constructor(){this.isTransferred=!1,this.capacity=-1,this.resize(0)}static serialize(t,i){return t._trim(),i&&(t.isTransferred=!0,i.push(t.arrayBuffer)),{length:t.length,arrayBuffer:t.arrayBuffer}}static deserialize(t){let i=Object.create(this.prototype);return i.arrayBuffer=t.arrayBuffer,i.length=t.length,i.capacity=t.arrayBuffer.byteLength/i.bytesPerElement,i._refreshViews(),i}_trim(){this.length!==this.capacity&&(this.capacity=this.length,this.arrayBuffer=this.arrayBuffer.slice(0,this.length*this.bytesPerElement),this._refreshViews())}clear(){this.length=0}resize(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 i=this.uint8;this._refreshViews(),i&&this.uint8.set(i)}}_refreshViews(){throw Error("_refreshViews() must be implemented by each concrete StructArray layout")}freeBufferAfterUpload(){this.arrayBuffer=new ArrayBuffer(0),this._refreshViews()}};function We(e,t=1){let i=0,r=0;return{members:e.map(a=>{let n=g2(a.type),s=i=am(i,Math.max(t,n)),o=a.components||1;return r=Math.max(r,n),i+=n*o,{name:a.name,type:a.type,components:o,offset:s}}),size:am(i,Math.max(r,t)),alignment:t}}function g2(e){return m2[e].BYTES_PER_ELEMENT}function am(e,t){return Math.ceil(e/t)*t}var Bn=class extends qe{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(t,i){let r=this.length;return this.resize(r+1),this.emplace(r,t,i)}emplace(t,i,r){let a=t*2;return this.int16[a+0]=i,this.int16[a+1]=r,t}};Bn.prototype.bytesPerElement=4,U("StructArrayLayout2i4",Bn);var To=class extends qe{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(t,i,r){let a=this.length;return this.resize(a+1),this.emplace(a,t,i,r)}emplace(t,i,r,a){let n=t*3;return this.int16[n+0]=i,this.int16[n+1]=r,this.int16[n+2]=a,t}};To.prototype.bytesPerElement=6,U("StructArrayLayout3i6",To);var Ju=class extends qe{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(t,i,r,a){let n=this.length;return this.resize(n+1),this.emplace(n,t,i,r,a)}emplace(t,i,r,a,n){let s=t*4;return this.int16[s+0]=i,this.int16[s+1]=r,this.int16[s+2]=a,this.int16[s+3]=n,t}};Ju.prototype.bytesPerElement=8,U("StructArrayLayout4i8",Ju);var Qu=class extends qe{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(t,i,r,a,n,s){let o=this.length;return this.resize(o+1),this.emplace(o,t,i,r,a,n,s)}emplace(t,i,r,a,n,s,o){let l=t*6;return this.int16[l+0]=i,this.int16[l+1]=r,this.int16[l+2]=a,this.int16[l+3]=n,this.int16[l+4]=s,this.int16[l+5]=o,t}};Qu.prototype.bytesPerElement=12,U("StructArrayLayout2i4i12",Qu);var eh=class extends qe{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(t,i,r,a,n,s){let o=this.length;return this.resize(o+1),this.emplace(o,t,i,r,a,n,s)}emplace(t,i,r,a,n,s,o){let l=t*4,u=t*8;return this.int16[l+0]=i,this.int16[l+1]=r,this.uint8[u+4]=a,this.uint8[u+5]=n,this.uint8[u+6]=s,this.uint8[u+7]=o,t}};eh.prototype.bytesPerElement=8,U("StructArrayLayout2i4ub8",eh);var $n=class extends qe{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(t,i){let r=this.length;return this.resize(r+1),this.emplace(r,t,i)}emplace(t,i,r){let a=t*2;return this.float32[a+0]=i,this.float32[a+1]=r,t}};$n.prototype.bytesPerElement=8,U("StructArrayLayout2f8",$n);var th=class extends qe{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(t,i,r,a,n,s,o,l,u,h){let c=this.length;return this.resize(c+1),this.emplace(c,t,i,r,a,n,s,o,l,u,h)}emplace(t,i,r,a,n,s,o,l,u,h,c){let d=t*10;return this.uint16[d+0]=i,this.uint16[d+1]=r,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}};th.prototype.bytesPerElement=20,U("StructArrayLayout10ui20",th);var ih=class extends qe{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(t,i,r,a,n,s,o,l){let u=this.length;return this.resize(u+1),this.emplace(u,t,i,r,a,n,s,o,l)}emplace(t,i,r,a,n,s,o,l,u){let h=t*8;return this.uint16[h+0]=i,this.uint16[h+1]=r,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}};ih.prototype.bytesPerElement=16,U("StructArrayLayout8ui16",ih);var rh=class extends qe{_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,i,r,a,n,s,o,l,u,h,c,d,p){let f=this.length;return this.resize(f+1),this.emplace(f,t,i,r,a,n,s,o,l,u,h,c,d,p)}emplace(t,i,r,a,n,s,o,l,u,h,c,d,p,f){let m=t*14,g=t*7;return this.int16[m+0]=i,this.int16[m+1]=r,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}};rh.prototype.bytesPerElement=28,U("StructArrayLayout4i4ui4i1f28",rh);var ah=class extends qe{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(t,i,r){let a=this.length;return this.resize(a+1),this.emplace(a,t,i,r)}emplace(t,i,r,a){let n=t*3;return this.float32[n+0]=i,this.float32[n+1]=r,this.float32[n+2]=a,t}};ah.prototype.bytesPerElement=12,U("StructArrayLayout3f12",ah);var nh=class extends qe{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint32=new Uint32Array(this.arrayBuffer)}emplaceBack(t){let i=this.length;return this.resize(i+1),this.emplace(i,t)}emplace(t,i){let r=t*1;return this.uint32[r+0]=i,t}};nh.prototype.bytesPerElement=4,U("StructArrayLayout1ul4",nh);var sh=class extends qe{_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,i,r,a,n,s,o,l,u){let h=this.length;return this.resize(h+1),this.emplace(h,t,i,r,a,n,s,o,l,u)}emplace(t,i,r,a,n,s,o,l,u,h){let c=t*10,d=t*5;return this.int16[c+0]=i,this.int16[c+1]=r,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}};sh.prototype.bytesPerElement=20,U("StructArrayLayout6i1ul2ui20",sh);var oh=class extends qe{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(t,i,r,a,n,s){let o=this.length;return this.resize(o+1),this.emplace(o,t,i,r,a,n,s)}emplace(t,i,r,a,n,s,o){let l=t*6;return this.int16[l+0]=i,this.int16[l+1]=r,this.int16[l+2]=a,this.int16[l+3]=n,this.int16[l+4]=s,this.int16[l+5]=o,t}};oh.prototype.bytesPerElement=12,U("StructArrayLayout2i2i2i12",oh);var lh=class extends qe{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(t,i,r,a,n){let s=this.length;return this.resize(s+1),this.emplace(s,t,i,r,a,n)}emplace(t,i,r,a,n,s){let o=t*4,l=t*8;return this.float32[o+0]=i,this.float32[o+1]=r,this.float32[o+2]=a,this.int16[l+6]=n,this.int16[l+7]=s,t}};lh.prototype.bytesPerElement=16,U("StructArrayLayout2f1f2i16",lh);var uh=class extends qe{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(t,i,r,a,n,s){let o=this.length;return this.resize(o+1),this.emplace(o,t,i,r,a,n,s)}emplace(t,i,r,a,n,s,o){let l=t*16,u=t*4,h=t*8;return this.uint8[l+0]=i,this.uint8[l+1]=r,this.float32[u+1]=a,this.float32[u+2]=n,this.int16[h+6]=s,this.int16[h+7]=o,t}};uh.prototype.bytesPerElement=16,U("StructArrayLayout2ub2f2i16",uh);var So=class extends qe{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(t,i,r){let a=this.length;return this.resize(a+1),this.emplace(a,t,i,r)}emplace(t,i,r,a){let n=t*3;return this.uint16[n+0]=i,this.uint16[n+1]=r,this.uint16[n+2]=a,t}};So.prototype.bytesPerElement=6,U("StructArrayLayout3ui6",So);var hh=class extends qe{_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,i,r,a,n,s,o,l,u,h,c,d,p,f,m,g,_,y){let x=this.length;return this.resize(x+1),this.emplace(x,t,i,r,a,n,s,o,l,u,h,c,d,p,f,m,g,_,y)}emplace(t,i,r,a,n,s,o,l,u,h,c,d,p,f,m,g,_,y,x){let v=t*26,w=t*13,b=t*52;return this.int16[v+0]=i,this.int16[v+1]=r,this.uint16[v+2]=a,this.uint16[v+3]=n,this.uint32[w+2]=s,this.uint32[w+3]=o,this.uint32[w+4]=l,this.uint16[v+10]=u,this.uint16[v+11]=h,this.uint16[v+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[v+22]=y,this.float32[w+12]=x,t}};hh.prototype.bytesPerElement=52,U("StructArrayLayout2i2ui3ul3ui2f3ub1ul1i1f52",hh);var ch=class extends qe{_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,i,r,a,n,s,o,l,u,h,c,d,p,f,m,g,_,y,x,v,w,b,T,P,S,M,F,R,I){let D=this.length;return this.resize(D+1),this.emplace(D,t,i,r,a,n,s,o,l,u,h,c,d,p,f,m,g,_,y,x,v,w,b,T,P,S,M,F,R,I)}emplace(t,i,r,a,n,s,o,l,u,h,c,d,p,f,m,g,_,y,x,v,w,b,T,P,S,M,F,R,I,D){let E=t*34,A=t*17;return this.int16[E+0]=i,this.int16[E+1]=r,this.int16[E+2]=a,this.int16[E+3]=n,this.int16[E+4]=s,this.int16[E+5]=o,this.int16[E+6]=l,this.int16[E+7]=u,this.uint16[E+8]=h,this.uint16[E+9]=c,this.uint16[E+10]=d,this.uint16[E+11]=p,this.uint16[E+12]=f,this.uint16[E+13]=m,this.uint16[E+14]=g,this.uint16[E+15]=_,this.uint16[E+16]=y,this.uint16[E+17]=x,this.uint16[E+18]=v,this.uint16[E+19]=w,this.uint16[E+20]=b,this.uint16[E+21]=T,this.uint16[E+22]=P,this.uint32[A+12]=S,this.float32[A+13]=M,this.float32[A+14]=F,this.uint16[E+30]=R,this.uint16[E+31]=I,this.float32[A+16]=D,t}};ch.prototype.bytesPerElement=68,U("StructArrayLayout8i15ui1ul2f2ui1f68",ch);var Eo=class extends qe{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(t){let i=this.length;return this.resize(i+1),this.emplace(i,t)}emplace(t,i){let r=t*1;return this.float32[r+0]=i,t}};Eo.prototype.bytesPerElement=4,U("StructArrayLayout1f4",Eo);var dh=class extends qe{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(t,i,r){let a=this.length;return this.resize(a+1),this.emplace(a,t,i,r)}emplace(t,i,r,a){let n=t*6,s=t*3;return this.uint16[n+0]=i,this.float32[s+1]=r,this.float32[s+2]=a,t}};dh.prototype.bytesPerElement=12,U("StructArrayLayout1ui2f12",dh);var ph=class extends qe{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint32=new Uint32Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(t,i,r){let a=this.length;return this.resize(a+1),this.emplace(a,t,i,r)}emplace(t,i,r,a){let n=t*2,s=t*4;return this.uint32[n+0]=i,this.uint16[s+2]=r,this.uint16[s+3]=a,t}};ph.prototype.bytesPerElement=8,U("StructArrayLayout1ul2ui8",ph);var fh=class extends qe{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(t,i){let r=this.length;return this.resize(r+1),this.emplace(r,t,i)}emplace(t,i,r){let a=t*2;return this.uint16[a+0]=i,this.uint16[a+1]=r,t}};fh.prototype.bytesPerElement=4,U("StructArrayLayout2ui4",fh);var mh=class extends qe{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(t){let i=this.length;return this.resize(i+1),this.emplace(i,t)}emplace(t,i){let r=t*1;return this.uint16[r+0]=i,t}};mh.prototype.bytesPerElement=2,U("StructArrayLayout1ui2",mh);var gh=class extends qe{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(t,i,r,a){let n=this.length;return this.resize(n+1),this.emplace(n,t,i,r,a)}emplace(t,i,r,a,n){let s=t*4;return this.float32[s+0]=i,this.float32[s+1]=r,this.float32[s+2]=a,this.float32[s+3]=n,t}};gh.prototype.bytesPerElement=16,U("StructArrayLayout4f16",gh);var nm=class extends Ln{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 C(this.anchorPointX,this.anchorPointY)}};nm.prototype.size=20;var sm=class extends sh{get(t){return new nm(this,t)}};U("CollisionBoxArray",sm);var om=class extends Ln{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]}};om.prototype.size=52;var lm=class extends hh{get(t){return new om(this,t)}};U("PlacedSymbolArray",lm);var um=class extends Ln{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]}};um.prototype.size=68;var hm=class extends ch{get(t){return new um(this,t)}};U("SymbolInstanceArray",hm);var cm=class extends Eo{getoffsetX(t){return this.float32[t*1+0]}};U("GlyphOffsetArray",cm);var dm=class extends To{getx(t){return this.int16[t*3+0]}gety(t){return this.int16[t*3+1]}gettileUnitDistanceFromAnchor(t){return this.int16[t*3+2]}};U("SymbolLineVertexArray",dm);var pm=class extends Ln{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]}};pm.prototype.size=12;var fm=class extends dh{get(t){return new pm(this,t)}};U("TextAnchorOffsetArray",fm);var mm=class extends Ln{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]}};mm.prototype.size=8;var gm=class extends ph{get(t){return new mm(this,t)}};U("FeatureIndexArray",gm);var Pr=class extends Bn{},_2=class extends To{},y2=class extends Ju{},v2=class extends Bn{},x2=class extends Bn{},b2=class extends Qu{},w2=class extends eh{},T2=class extends $n{},$a=class extends th{},_m=class extends ih{},S2=class extends rh{},E2=class extends ah{},P2=class extends nh{},ym=class extends oh{},C2=class extends lh{},A2=class extends uh{},D2=class extends So{},Gi=class extends So{},_h=class extends fh{},I2=class extends mh{};const M2=We([{name:"a_pos",components:2,type:"Int16"}],4),z2=M2.members;var Ne=class hn{constructor(t=[]){this._forceNewSegmentOnNextPrepare=!1,this.segments=t}prepareSegment(t,i,r,a){let n=this.segments[this.segments.length-1];return t>hn.MAX_VERTEX_ARRAY_LENGTH&&le(`Max vertices per segment is ${hn.MAX_VERTEX_ARRAY_LENGTH}: bucket requested ${t}. Consider using the \`fillLargeMeshArrays\` function if you require meshes with more than ${hn.MAX_VERTEX_ARRAY_LENGTH} vertices.`),this._forceNewSegmentOnNextPrepare||!n||n.vertexLength+t>hn.MAX_VERTEX_ARRAY_LENGTH||n.sortKey!==a?this.createNewSegment(i,r,a):n}createNewSegment(t,i,r){let a={vertexOffset:t.length,primitiveOffset:i.length,vertexLength:0,primitiveLength:0,vaos:{}};return r!==void 0&&(a.sortKey=r),this._forceNewSegmentOnNextPrepare=!1,this.segments.push(a),a}getOrCreateLatestSegment(t,i,r){return this.prepareSegment(0,t,i,r)}forceNewSegmentOnNextPrepare(){this._forceNewSegmentOnNextPrepare=!0}get(){return this.segments}destroy(){for(let t of this.segments)for(let i in t.vaos)t.vaos[i].destroy()}static simpleSegment(t,i,r,a){return new hn([{vertexOffset:t,primitiveOffset:i,vertexLength:r,primitiveLength:a,vaos:{},sortKey:0}])}};Ne.MAX_VERTEX_ARRAY_LENGTH=2**16-1,U("SegmentVector",Ne);function vm(e,t){return e=ee(Math.floor(e),0,255),t=ee(Math.floor(t),0,255),256*e+t}const F2=We([{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"}]),R2=We([{name:"a_dasharray_from",components:4,type:"Uint16"},{name:"a_dasharray_to",components:4,type:"Uint16"}]);var k2=Ul(((e,t)=>{function i(r,a){for(var n=r.length&3,s=r.length-n,o=a,l,u=3432918353,h=461845907,c,d=0;d<s;)c=r.charCodeAt(d)&255|(r.charCodeAt(++d)&255)<<8|(r.charCodeAt(++d)&255)<<16|(r.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^=(r.charCodeAt(d+2)&255)<<16;case 2:c^=(r.charCodeAt(d+1)&255)<<8;case 1:c^=r.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^=r.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=i)})),L2=Ul(((e,t)=>{function i(r,a){for(var n=r.length,s=a^n,o=0,l;n>=4;)l=r.charCodeAt(o)&255|(r.charCodeAt(++o)&255)<<8|(r.charCodeAt(++o)&255)<<16|(r.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^=(r.charCodeAt(o+2)&255)<<16;case 2:s^=(r.charCodeAt(o+1)&255)<<8;case 1:s^=r.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=i})),yh=X1(Ul(((e,t)=>{var i=k2(),r=L2();t.exports=i,t.exports.murmur3=i,t.exports.murmur2=r}))()),xm=class A1{constructor(){this.ids=[],this.positions=[],this.indexed=!1}add(t,i,r,a){this.ids.push(bm(t)),this.positions.push(i,r,a)}getPositions(t){if(!this.indexed)throw Error("Trying to get index, but feature positions are not indexed");let i=bm(t),r=0,a=this.ids.length-1;for(;r<a;){let s=r+a>>1;this.ids[s]>=i?a=s:r=s+1}let n=[];for(;this.ids[r]===i;){let s=this.positions[3*r],o=this.positions[3*r+1],l=this.positions[3*r+2];n.push({index:s,start:o,end:l}),r++}return n}static serialize(t,i){let r=new Float64Array(t.ids),a=new Uint32Array(t.positions);return vh(r,a,0,r.length-1),i&&i.push(r.buffer,a.buffer),{ids:r,positions:a}}static deserialize(t){let i=new A1;return i.ids=t.ids,i.positions=t.positions,i.indexed=!0,i}};function bm(e){let t=+e;return!isNaN(t)&&t<=2**53-1?t:(0,yh.default)(String(e))}function vh(e,t,i,r){for(;i<r;){let a=e[i+r>>1],n=i-1,s=r+1;for(;;){do n++;while(e[n]<a);do s--;while(e[s]>a);if(n>=s)break;Po(e,n,s),Po(t,3*n,3*s),Po(t,3*n+1,3*s+1),Po(t,3*n+2,3*s+2)}s-i<r-s?(vh(e,t,i,s),i=s+1):(vh(e,t,s+1,r),r=s)}}function Po(e,t,i){let r=e[t];e[t]=e[i],e[i]=r}U("FeaturePositionMap",xm);var rr=class{constructor(t,i){this.gl=t.gl,this.location=i}},X=class extends rr{constructor(t,i){super(t,i),this.current=0}set(t){this.current!==t&&(this.current=t,this.gl.uniform1i(this.location,t))}},G=class extends rr{constructor(t,i){super(t,i),this.current=0}set(t){this.current!==t&&(this.current=t,this.gl.uniform1f(this.location,t))}},se=class extends rr{constructor(t,i){super(t,i),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]))}},Ot=class extends rr{constructor(t,i){super(t,i),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]))}},On=class extends rr{constructor(t,i){super(t,i),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]))}},Cr=class extends rr{constructor(t,i){super(t,i),this.current=te.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))}},wm=class extends rr{constructor(t,i){super(t,i),this.current=[]}set(t){if(t!=this.current){this.current=t;let i=new Float32Array(t.length*4);for(let r=0;r<t.length;r++)i[4*r]=t[r].r,i[4*r+1]=t[r].g,i[4*r+2]=t[r].b,i[4*r+3]=t[r].a;this.gl.uniform4fv(this.location,i)}}},Tm=class extends rr{constructor(t,i){super(t,i),this.current=[]}set(t){if(t!=this.current){this.current=t;let i=new Float32Array(t);this.gl.uniform1fv(this.location,i)}}};const B2=new Float32Array(16);var Ci=class extends rr{constructor(t,i){super(t,i),this.current=B2}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 i=1;i<16;i++)if(t[i]!==this.current[i]){this.current=t,this.gl.uniformMatrix4fv(this.location,!1,t);break}}};function xh(e){return[vm(255*e.r,255*e.g),vm(255*e.b,255*e.a)]}var Nn=class{constructor(t,i,r){this.value=t,this.uniformNames=i.map(a=>`u_${a}`),this.type=r}setUniform(t,i,r){t.set(r.constantOr(this.value))}getBinding(t,i,r){return this.type==="color"?new Cr(t,i):new G(t,i)}},Yr=class{constructor(t,i){this.uniformNames=i.map(r=>`u_${r}`),this.patternFrom=null,this.patternTo=null,this.pixelRatioFrom=1,this.pixelRatioTo=1}setConstantPatternPositions(t,i){this.pixelRatioFrom=i.pixelRatio,this.pixelRatioTo=t.pixelRatio,this.patternFrom=i.tlbr,this.patternTo=t.tlbr}setConstantDashPositions(t,i){this.dashTo=[0,t.y,t.height,t.width],this.dashFrom=[0,i.y,i.height,i.width]}setUniform(t,i,r,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,i,r){return r.startsWith("u_pattern")||r.startsWith("u_dasharray_")?new On(t,i):new G(t,i)}},ar=class{constructor(t,i,r,a){this.expression=t,this.type=r,this.maxValue=0,this.paintVertexAttributes=i.map(n=>({name:`a_${n}`,type:"Float32",components:r==="color"?2:1,offset:0})),this.paintVertexArray=new a}populatePaintArray(t,i,r){let a=this.paintVertexArray.length,n=this.expression.evaluate(new be(0,r),i,{},r.canonical,[],r.formattedSection);this.paintVertexArray.resize(t),this._setPaintValue(a,t,n)}updatePaintArray(t,i,r,a,n){let s=this.expression.evaluate(new be(0,n),r,a);this._setPaintValue(t,i,s)}_setPaintValue(t,i,r){if(this.type==="color"){let a=xh(r);for(let n=t;n<i;n++)this.paintVertexArray.emplace(n,a[0],a[1])}else{for(let a=t;a<i;a++)this.paintVertexArray.emplace(a,r);this.maxValue=Math.max(this.maxValue,Math.abs(r))}}upload(t){var i,r;(i=this.paintVertexArray)!=null&&i.arrayBuffer.byteLength&&((r=this.paintVertexBuffer)!=null&&r.buffer?this.paintVertexBuffer.updateData(this.paintVertexArray):this.paintVertexBuffer=t.createVertexBuffer(this.paintVertexArray,this.paintVertexAttributes,this.expression.isStateDependent))}destroy(){this.paintVertexBuffer&&this.paintVertexBuffer.destroy()}},Ai=class{constructor(t,i,r,a,n,s){this.expression=t,this.uniformNames=i.map(o=>`u_${o}_t`),this.type=r,this.useIntegerZoom=a,this.zoom=n,this.maxValue=0,this.paintVertexAttributes=i.map(o=>({name:`a_${o}`,type:"Float32",components:r==="color"?4:2,offset:0})),this.paintVertexArray=new s}populatePaintArray(t,i,r){let a=this.expression.evaluate(new be(this.zoom,r),i,{},r.canonical,[],r.formattedSection),n=this.expression.evaluate(new be(this.zoom+1,r),i,{},r.canonical,[],r.formattedSection),s=this.paintVertexArray.length;this.paintVertexArray.resize(t),this._setPaintValue(s,t,a,n)}updatePaintArray(t,i,r,a,n){let s=this.expression.evaluate(new be(this.zoom,n),r,a),o=this.expression.evaluate(new be(this.zoom+1,n),r,a);this._setPaintValue(t,i,s,o)}_setPaintValue(t,i,r,a){if(this.type==="color"){let n=xh(r),s=xh(a);for(let o=t;o<i;o++)this.paintVertexArray.emplace(o,n[0],n[1],s[0],s[1])}else{for(let n=t;n<i;n++)this.paintVertexArray.emplace(n,r,a);this.maxValue=Math.max(this.maxValue,Math.abs(r),Math.abs(a))}}upload(t){var i,r;(i=this.paintVertexArray)!=null&&i.arrayBuffer.byteLength&&((r=this.paintVertexBuffer)!=null&&r.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,i){let r=this.useIntegerZoom?Math.floor(i.zoom):i.zoom,a=ee(this.expression.interpolationFactor(r,this.zoom,this.zoom+1),0,1);t.set(a)}getBinding(t,i,r){return new G(t,i)}},Ar=class{constructor(t,i,r,a,n,s){this.expression=t,this.type=i,this.useIntegerZoom=r,this.zoom=a,this.layerId=s,this.zoomInPaintVertexArray=new n,this.zoomOutPaintVertexArray=new n}populatePaintArray(t,i,r){let a=this.zoomInPaintVertexArray.length;this.zoomInPaintVertexArray.resize(t),this.zoomOutPaintVertexArray.resize(t),this._setPaintValues(a,t,this.getPositionIds(i),r)}updatePaintArray(t,i,r,a,n){this._setPaintValues(t,i,this.getPositionIds(r),n)}_setPaintValues(t,i,r,a){let n=this.getPositions(a);if(!n||!r)return;let s=n[r.min],o=n[r.mid],l=n[r.max];if(s&&o&&l)for(let u=t;u<i;u++)this.emplace(this.zoomInPaintVertexArray,u,s,o),this.emplace(this.zoomOutPaintVertexArray,u,l,o)}upload(t){var i,r;if((i=this.zoomInPaintVertexArray)!=null&&i.arrayBuffer.byteLength&&((r=this.zoomOutPaintVertexArray)!=null&&r.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()}},Sm=class extends Ar{getPositions(t){return t.imagePositions}getPositionIds(t){var i;return(i=t.patterns)==null?void 0:i[this.layerId]}getVertexAttributes(){return F2.members}emplace(t,i,r,a){t.emplace(i,r.tlbr[0],r.tlbr[1],r.tlbr[2],r.tlbr[3],a.tlbr[0],a.tlbr[1],a.tlbr[2],a.tlbr[3],r.pixelRatio,a.pixelRatio)}},Em=class extends Ar{getPositions(t){return t.dashPositions}getPositionIds(t){var i;return(i=t.dashes)==null?void 0:i[this.layerId]}getVertexAttributes(){return R2.members}emplace(t,i,r,a){t.emplace(i,0,r.y,r.height,r.width,0,a.y,a.height,a.width)}},Pm=class{constructor(t,i,r){this.binders={},this._buffers=[];let a=[];for(let n in t.paint._values){if(!r(n))continue;let s=t.paint.get(n);if(!(s instanceof gi)||!Ra(s.property.specification))continue;let o=$2(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 Yr(l.value,o):new Nn(l.value,o,u),a.push(`/u_${n}`);else if(l.kind==="source"||d){let p=Cm(n,u,"source");this.binders[n]=d?n==="line-dasharray"?new Em(l,u,h,i,p,t.id):new Sm(l,u,h,i,p,t.id):new ar(l,o,u,p),a.push(`/a_${n}`)}else{let p=Cm(n,u,"composite");this.binders[n]=new Ai(l,o,u,h,i,p),a.push(`/z_${n}`)}}this.cacheKey=a.sort().join("")}getMaxValue(t){let i=this.binders[t];return i instanceof ar||i instanceof Ai?i.maxValue:0}populatePaintArrays(t,i,r){for(let a in this.binders){let n=this.binders[a];(n instanceof ar||n instanceof Ai||n instanceof Ar)&&n.populatePaintArray(t,i,r)}}setConstantPatternPositions(t,i){for(let r in this.binders){let a=this.binders[r];a instanceof Yr&&a.setConstantPatternPositions(t,i)}}setConstantDashPositions(t,i){for(let r in this.binders){let a=this.binders[r];a instanceof Yr&&a.setConstantDashPositions(t,i)}}updatePaintArrays(t,i,r,a,n){let s=!1;for(let o of t){let l=i.getPositions(o.id);for(let u of l){let h=r.feature(u.index);for(let c in this.binders){let d=this.binders[c];(d instanceof ar||d instanceof Ai||d instanceof Ar)&&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 i in this.binders){let r=this.binders[i];(r instanceof Nn||r instanceof Yr)&&t.push(...r.uniformNames.map(a=>`#define HAS_UNIFORM_${a}`))}return t}getBinderAttributes(){let t=[];for(let i in this.binders){let r=this.binders[i];if(r instanceof ar||r instanceof Ai)for(let a of r.paintVertexAttributes)t.push(a.name);else if(r instanceof Ar){let a=r.getVertexAttributes();for(let n of a)t.push(n.name)}}return t}getBinderUniforms(){let t=[];for(let i in this.binders){let r=this.binders[i];if(r instanceof Nn||r instanceof Yr||r instanceof Ai)for(let a of r.uniformNames)t.push(a)}return t}getPaintVertexBuffers(){return this._buffers}getUniforms(t,i){let r=[];for(let a in this.binders){let n=this.binders[a];if(n instanceof Nn||n instanceof Yr||n instanceof Ai){for(let s of n.uniformNames)if(i[s]){let o=n.getBinding(t,i[s],s);r.push({name:s,property:a,binding:o})}}}return r}setUniforms(t,i,r,a){for(let{name:n,property:s,binding:o}of i)this.binders[s].setUniform(o,a,r.get(s),n)}updatePaintBuffers(t){this._buffers=[];for(let i in this.binders){let r=this.binders[i];if(t&&r instanceof Ar){let a=t.fromScale===2?r.zoomInPaintVertexBuffer:r.zoomOutPaintVertexBuffer;a&&this._buffers.push(a)}else(r instanceof ar||r instanceof Ai)&&r.paintVertexBuffer&&this._buffers.push(r.paintVertexBuffer)}}upload(t){for(let i in this.binders){let r=this.binders[i];(r instanceof ar||r instanceof Ai||r instanceof Ar)&&r.upload(t)}this.updatePaintBuffers()}destroy(){for(let t in this.binders){let i=this.binders[t];(i instanceof ar||i instanceof Ai||i instanceof Ar)&&i.destroy()}}},Kr=class{constructor(t,i,r=()=>!0){this.programConfigurations={};for(let a of t)this.programConfigurations[a.id]=new Pm(a,i,r);this.needsUpload=!1,this._featureMap=new xm,this._bufferOffset=0}populatePaintArrays(t,i,r,a){for(let n in this.programConfigurations)this.programConfigurations[n].populatePaintArrays(t,i,a);i.id!==void 0&&this._featureMap.add(i.id,r,this._bufferOffset,t),this._bufferOffset=t,this.needsUpload=!0}updatePaintArrays(t,i,r,a){for(let n of r)this.needsUpload=this.programConfigurations[n.id].updatePaintArrays(t,this._featureMap,i,n,a)||this.needsUpload}get(t){return this.programConfigurations[t]}upload(t){if(this.needsUpload){for(let i in this.programConfigurations)this.programConfigurations[i].upload(t);this.needsUpload=!1}}destroy(){for(let t in this.programConfigurations)this.programConfigurations[t].destroy()}};function $2(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 O2(e){return{"line-pattern":{source:$a,composite:$a},"fill-pattern":{source:$a,composite:$a},"fill-extrusion-pattern":{source:$a,composite:$a},"line-dasharray":{source:_m,composite:_m}}[e]}function Cm(e,t,i){var a;let r={color:{source:$n,composite:gh},number:{source:Eo,composite:$n}};return((a=O2(e))==null?void 0:a[i])||r[t][i]}U("ConstantBinder",Nn),U("CrossFadedConstantBinder",Yr),U("SourceExpressionBinder",ar),U("CrossFadedPatternBinder",Sm),U("CrossFadedDasharrayBinder",Em),U("CompositeExpressionBinder",Ai),U("ProgramConfiguration",Pm,{omit:["_buffers"]}),U("ProgramConfigurationSet",Kr);const bh=2**14-1,Am=-bh-1;function Jr(e){let t=k/e.extent,i=e.loadGeometry();for(let r of i)for(let a of r){let n=Math.round(a.x*t),s=Math.round(a.y*t);a.x=ee(n,Am,bh),a.y=ee(s,Am,bh),(n<a.x||n>a.x+1||s<a.y||s>a.y+1)&&le("Geometry exceeds allowed extent, reduce your vector tile buffer size")}return i}function Qr(e,t){return{type:e.type,id:e.id,properties:e.properties,geometry:t?Jr(e):[]}}const Dm=-32768;function N2(e,t,i,r,a){e.emplaceBack(Dm+t*8+r,Dm+i*8+a)}var wh=class{constructor(t){this.zoom=t.zoom,this.overscaling=t.overscaling,this.layers=t.layers,this.layerIds=this.layers.map(i=>i.id),this.index=t.index,this.hasDependencies=!1,this.layoutVertexArray=new v2,this.indexArray=new Gi,this.segments=new Ne,this.programConfigurations=new Kr(t.layers,t.zoom),this.stateDependentLayerIds=this.layers.filter(i=>i.isStateDependent()).map(i=>i.id)}populate(t,i,r){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?i.subdivisionGranularity.circle:1,h=new be(this.zoom),c=this.layers[0]._featureFilter.needGeometry;for(let{feature:d,id:p,index:f,sourceLayerIndex:m}of t){let g=Qr(d,c);if(!this.layers[0]._featureFilter.filter(h,g,r))continue;let _=o?s.evaluate(g,{},r):void 0,y={id:p,properties:d.properties,type:d.type,sourceLayerIndex:m,index:f,geometry:c?g.geometry:Jr(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,r,u),i.featureIndex.insert(g,p,f,m,this.index)}}update(t,i,r){this.stateDependentLayers.length&&this.programConfigurations.updatePaintArrays(t,i,this.stateDependentLayers,{imagePositions:r})}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,z2),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,i,r,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 i)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++)N2(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,r,{imagePositions:{},canonical:a})}};U("CircleBucket",wh,{omit:["layers"]});function Im(e,t){for(let i of e)if(Oa(t,i))return!0;for(let i of t)if(Oa(e,i))return!0;return Th(e,t)}function Co(e,t,i){return Oa(e,t)?!0:Sh(t,e,i)}function Mm(e,t){if(e.length===1)return Fm(t,e[0]);for(let i of t)for(let r of i)if(Oa(e,r))return!0;for(let i of e)if(Fm(t,i))return!0;for(let i of t)if(Th(e,i))return!0;return!1}function V2(e,t,i){for(let r of t){if(e.length>=3){for(let a of r)if(Oa(e,a))return!0}if(j2(e,r,i))return!0}return!1}function j2(e,t,i){if(e.length>1){if(Th(e,t))return!0;for(let r of t)if(Sh(r,e,i))return!0}for(let r of e)if(Sh(r,t,i))return!0;return!1}function Th(e,t){if(e.length===0||t.length===0)return!1;for(let i=0;i<e.length-1;i++){let r=e[i],a=e[i+1];for(let n=0;n<t.length-1;n++){let s=t[n],o=t[n+1];if(U2(r,a,s,o))return!0}}return!1}function U2(e,t,i,r){return xr(e,i,r)!==xr(t,i,r)&&xr(e,t,i)!==xr(e,t,r)}function Sh(e,t,i){let r=i*i;if(t.length===1)return e.distSqr(t[0])<r;for(let a=1;a<t.length;a++){let n=t[a-1],s=t[a];if(zm(e,n,s)<r)return!0}return!1}function zm(e,t,i){let r=t.distSqr(i);if(r===0)return e.distSqr(t);let a=((e.x-t.x)*(i.x-t.x)+(e.y-t.y)*(i.y-t.y))/r;return a<0?e.distSqr(t):a>1?e.distSqr(i):e.distSqr(i.sub(t)._mult(a)._add(t))}function Fm(e,t){let i=!1,r,a,n;for(let s of e){r=s;for(let o=0,l=r.length-1;o<r.length;l=o++)a=r[o],n=r[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&&(i=!i)}return i}function Oa(e,t){let i=!1;for(let r=0,a=e.length-1;r<e.length;a=r++){let n=e[r],s=e[a];n.y>t.y!=s.y>t.y&&t.x<(s.x-n.x)*(t.y-n.y)/(s.y-n.y)+n.x&&(i=!i)}return i}function G2(e,t,i,r,a){for(let s of e)if(t<=s.x&&i<=s.y&&r>=s.x&&a>=s.y)return!0;let n=[new C(t,i),new C(t,a),new C(r,a),new C(r,i)];if(e.length>2){for(let s of n)if(Oa(e,s))return!0}for(let s=0;s<e.length-1;s++){let o=e[s],l=e[s+1];if(Z2(o,l,n))return!0}return!1}function Z2(e,t,i){let r=i[0],a=i[2];if(e.x<r.x&&t.x<r.x||e.x>a.x&&t.x>a.x||e.y<r.y&&t.y<r.y||e.y>a.y&&t.y>a.y)return!1;let n=xr(e,t,i[0]);return n!==xr(e,t,i[1])||n!==xr(e,t,i[2])||n!==xr(e,t,i[3])}function Na(e,t,i){let r=t.paint.get(e).value;return r.kind==="constant"?r.value:i.programConfigurations.get(t.id).getMaxValue(e)}function Ao(e){return Math.sqrt(e[0]*e[0]+e[1]*e[1])}function Do(e,t,i,r,a){if(!t[0]&&!t[1])return e;let n=C.convert(t)._mult(a);i==="viewport"&&n._rotate(-r);let s=[];for(let o of e)s.push(o.sub(n));return s}function q2(e){let t=[];for(let i=0;i<e.length;i++){let r=e[i],a=t.at(-1);(i===0||a&&!r.equals(a))&&t.push(r)}return t}function W2(e,t){let i=[];for(let r of e){let a=q2(r),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 C(0,0):o.sub(l)._unit()._perp(),c=s===a.length-1?new C(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))}i.push(n)}return i}function H2({queryGeometry:e,size:t},i){return Co(e,i,t)}function X2({queryGeometry:e,size:t,transform:i,unwrappedTileID:r,getElevation:a},n){return Co(e,n,t*(i.projectTileCoordinates(n.x,n.y,r,a==null?void 0:a(n.x,n.y)).signedDistanceFromCamera/i.cameraToCenterDistance))}function Y2({queryGeometry:e,size:t,transform:i,unwrappedTileID:r,getElevation:a},n){let s=i.projectTileCoordinates(n.x,n.y,r,a==null?void 0:a(n.x,n.y)).signedDistanceFromCamera,o=t*(i.cameraToCenterDistance/s);return Co(e,Eh(n,i,r,a),o)}function K2({queryGeometry:e,size:t,transform:i,unwrappedTileID:r,getElevation:a},n){return Co(e,Eh(n,i,r,a),t)}function Rm({queryGeometry:e,size:t,transform:i,unwrappedTileID:r,getElevation:a,pitchAlignment:n="map",pitchScale:s="map"},o){let l=n==="map"?s==="map"?H2:X2:s==="map"?Y2:K2,u={queryGeometry:e,size:t,transform:i,unwrappedTileID:r,getElevation:a};for(let h of o)for(let c of h)if(l(u,c))return!0;return!1}function Eh(e,t,i,r){let a=t.projectTileCoordinates(e.x,e.y,i,r==null?void 0:r(e.x,e.y)).point;return new C((a.x*.5+.5)*t.width,(-a.y*.5+.5)*t.height)}function J2(e,t,i,r){return e.map(a=>Eh(a,t,i,r))}let Q2;const eT=()=>Q2||(Q2=new yt({"circle-sort-key":new J(z.layout_circle["circle-sort-key"],"circle-sort-key")}));let tT;const iT=()=>tT||(tT=new yt({"circle-radius":new J(z.paint_circle["circle-radius"],"circle-radius"),"circle-color":new J(z.paint_circle["circle-color"],"circle-color"),"circle-blur":new J(z.paint_circle["circle-blur"],"circle-blur"),"circle-opacity":new J(z.paint_circle["circle-opacity"],"circle-opacity"),"circle-translate":new j(z.paint_circle["circle-translate"],"circle-translate"),"circle-translate-anchor":new j(z.paint_circle["circle-translate-anchor"],"circle-translate-anchor"),"circle-pitch-scale":new j(z.paint_circle["circle-pitch-scale"],"circle-pitch-scale"),"circle-pitch-alignment":new j(z.paint_circle["circle-pitch-alignment"],"circle-pitch-alignment"),"circle-stroke-width":new J(z.paint_circle["circle-stroke-width"],"circle-stroke-width"),"circle-stroke-color":new J(z.paint_circle["circle-stroke-color"],"circle-stroke-color"),"circle-stroke-opacity":new J(z.paint_circle["circle-stroke-opacity"],"circle-stroke-opacity")}));var rT={get paint(){return iT()},get layout(){return eT()}};const aT=e=>e.type==="circle";var nT=class extends Pi{constructor(t,i){super(t,rT,i)}createBucket(t){return new wh(t)}queryRadius(t){let i=t;return Na("circle-radius",this,i)+Na("circle-stroke-width",this,i)+Ao(this.paint.get("circle-translate"))}queryIntersectsFeature({queryGeometry:t,feature:i,featureState:r,geometry:a,transform:n,pixelsToTileUnits:s,unwrappedTileID:o,getElevation:l}){let u=Do(t,this.paint.get("circle-translate"),this.paint.get("circle-translate-anchor"),-n.bearingInRadians,s),h=this.paint.get("circle-radius").evaluate(i,r)+this.paint.get("circle-stroke-width").evaluate(i,r),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=J2(u,n,o,l),f=h),Rm({queryGeometry:p,size:f,transform:n,unwrappedTileID:o,getElevation:l,pitchAlignment:d,pitchScale:c},a)}},km=class extends wh{};U("HeatmapBucket",km,{omit:["layers"]});let sT;const oT=()=>sT||(sT=new yt({"heatmap-radius":new J(z.paint_heatmap["heatmap-radius"],"heatmap-radius"),"heatmap-weight":new J(z.paint_heatmap["heatmap-weight"],"heatmap-weight"),"heatmap-intensity":new j(z.paint_heatmap["heatmap-intensity"],"heatmap-intensity"),"heatmap-color":new wo(z.paint_heatmap["heatmap-color"],"heatmap-color"),"heatmap-opacity":new j(z.paint_heatmap["heatmap-opacity"],"heatmap-opacity")}));var lT={get paint(){return oT()}};function Ph(e,{width:t,height:i},r,a){if(!a)a=new Uint8Array(t*i*r);else if(a instanceof Uint8ClampedArray)a=new Uint8Array(a.buffer);else if(a.length!==t*i*r)throw RangeError(`mismatched image size. expected: ${a.length} but got: ${t*i*r}`);return e.width=t,e.height=i,e.data=a,e}function Lm(e,{width:t,height:i},r){if(t===e.width&&i===e.height)return;let a=Ph({},{width:t,height:i},r);Ch(e,a,{x:0,y:0},{x:0,y:0},{width:Math.min(e.width,t),height:Math.min(e.height,i)},r),e.width=t,e.height=i,e.data=a.data}function Ch(e,t,i,r,a,n){if(a.width===0||a.height===0)return t;if(a.width>e.width||a.height>e.height||i.x>e.width-a.width||i.y>e.height-a.height)throw RangeError("out of range source coordinates for image copy");if(a.width>t.width||a.height>t.height||r.x>t.width-a.width||r.y>t.height-a.height)throw RangeError("out of range destination coordinates for image copy");let s=e.data,o=t.data;if(s===o)throw Error("srcData equals dstData, so image is already copied");for(let l=0;l<a.height;l++){let u=((i.y+l)*e.width+i.x)*n,h=((r.y+l)*t.width+r.x)*n;for(let c=0;c<a.width*n;c++)o[h+c]=s[u+c]}return t}var Ah=class D1{constructor(t,i){Ph(this,t,1,i)}resize(t){Lm(this,t,1)}clone(){return new D1({width:this.width,height:this.height},new Uint8Array(this.data))}static copy(t,i,r,a,n){Ch(t,i,r,a,n,1)}},Fe=class I1{constructor(t,i){Ph(this,t,4,i)}resize(t){Lm(this,t,4)}replace(t,i){i?this.data.set(t):this.data=t instanceof Uint8ClampedArray?new Uint8Array(t.buffer):t}clone(){return new I1({width:this.width,height:this.height},new Uint8Array(this.data))}static copy(t,i,r,a,n){Ch(t,i,r,a,n,4)}setPixel(t,i,r){let a=(t*this.width+i)*4;this.data[a+0]=Math.round(r.r*255/r.a),this.data[a+1]=Math.round(r.g*255/r.a),this.data[a+2]=Math.round(r.b*255/r.a),this.data[a+3]=Math.round(r.a*255)}};function Dh(e){let t=new Uint8Array(e.length);for(let i=0;i<e.length;i+=4){let r=e[i+3];t[i+0]=Math.round(e[i+0]*r/255),t[i+1]=Math.round(e[i+1]*r/255),t[i+2]=Math.round(e[i+2]*r/255),t[i+3]=r}return t}U("AlphaImage",Ah),U("RGBAImage",Fe);function Bm(e){let t={},i=e.resolution||256,r=e.clips?e.clips.length:1,a=e.image||new Fe({width:i,height:r});if(!Dx(i))throw Error(`width is not a power of 2 - ${i}`);let n=(s,o,l)=>{t[e.evaluationKey]=l;let u=e.expression.evaluate(t);a.setPixel(s/4/i,o/4,u)};if(e.clips)for(let s=0,o=0;s<r;++s,o+=i*4)for(let l=0,u=0;l<i;l++,u+=4){let h=l/(i-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<i;s++,o+=4){let l=s/(i-1);n(0,o,l)}return a}const Io="big-fb",uT=e=>e.type==="heatmap";var hT=class extends Pi{createBucket(t){return new km(t)}constructor(t,i){super(t,lT,i),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=Bm({expression:t,evaluationKey:"heatmapDensity",image:this.colorRamp}),this.colorRampTexture=null}resize(){this.heatmapFbos.has("big-fb")&&this.heatmapFbos.delete(Io)}queryRadius(t){return Na("heatmap-radius",this,t)}queryIntersectsFeature({queryGeometry:t,feature:i,featureState:r,geometry:a,transform:n,pixelsToTileUnits:s,unwrappedTileID:o,getElevation:l}){return Rm({queryGeometry:t,size:this.paint.get("heatmap-radius").evaluate(i,r)*s,transform:n,unwrappedTileID:o,getElevation:l},a)}hasOffscreenPass(){return this.paint.get("heatmap-opacity")!==0&&!this.isHidden()}};let cT;const dT=()=>cT||(cT=new yt({"hillshade-illumination-direction":new j(z.paint_hillshade["hillshade-illumination-direction"],"hillshade-illumination-direction"),"hillshade-illumination-altitude":new j(z.paint_hillshade["hillshade-illumination-altitude"],"hillshade-illumination-altitude"),"hillshade-illumination-anchor":new j(z.paint_hillshade["hillshade-illumination-anchor"],"hillshade-illumination-anchor"),"hillshade-exaggeration":new j(z.paint_hillshade["hillshade-exaggeration"],"hillshade-exaggeration"),"hillshade-shadow-color":new j(z.paint_hillshade["hillshade-shadow-color"],"hillshade-shadow-color"),"hillshade-highlight-color":new j(z.paint_hillshade["hillshade-highlight-color"],"hillshade-highlight-color"),"hillshade-accent-color":new j(z.paint_hillshade["hillshade-accent-color"],"hillshade-accent-color"),"hillshade-method":new j(z.paint_hillshade["hillshade-method"],"hillshade-method"),resampling:new j(z.paint_hillshade.resampling,"resampling")}));var pT={get paint(){return dT()}};const fT=e=>e.type==="hillshade";var mT=class extends Pi{constructor(t,i){super(t,pT,i),this.recalculate({zoom:0,zoomHistory:{}},void 0)}getIlluminationProperties(){let t=this.paint.get("hillshade-illumination-direction").values,i=this.paint.get("hillshade-illumination-altitude").values,r=this.paint.get("hillshade-highlight-color").values,a=this.paint.get("hillshade-shadow-color").values,n=Math.max(t.length,i.length,r.length,a.length);t=t.concat(Array(n-t.length).fill(t.at(-1))),i=i.concat(Array(n-i.length).fill(i.at(-1))),r=r.concat(Array(n-r.length).fill(r.at(-1))),a=a.concat(Array(n-a.length).fill(a.at(-1)));let s=i.map(Be);return{directionRadians:t.map(Be),altitudeRadians:s,shadowColor:a,highlightColor:r}}hasOffscreenPass(){return this.paint.get("hillshade-exaggeration")!==0&&!this.isHidden()}};let gT;const _T=()=>gT||(gT=new yt({"color-relief-opacity":new j(z["paint_color-relief"]["color-relief-opacity"],"color-relief-opacity"),"color-relief-color":new wo(z["paint_color-relief"]["color-relief-color"],"color-relief-color"),resampling:new j(z["paint_color-relief"].resampling,"resampling")}));var yT={get paint(){return _T()}};function Mo(e){return"data"in e}var lt=class{constructor(t,i,r,a){this.context=t,this.format=r,this.texture=t.gl.createTexture(),this._ownedHandle=this.texture,this.update(i,a)}update(t,i,r){var h;let{width:a,height:n}=t,s=(((h=this.size)==null?void 0:h[0])!==a||this.size[1]!==n)&&!r,{context:o}=this,{gl:l}=o;this.useMipmap=!!(i!=null&&i.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&&(i==null?void 0:i.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),Mo(t)){o.pixelStoreUnpackPremultiplyAlpha.set(!1);let{data:d}=t;u&&d&&(d=Dh(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 Mo(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}=r||{x:0,y:0};Mo(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&&!(Mo(t)&&t.data===null)&&l.generateMipmap(l.TEXTURE_2D),o.pixelStoreUnpackFlipY.setDefault(),o.pixelStoreUnpack.setDefault(),o.pixelStoreUnpackPremultiplyAlpha.setDefault()}_uploadDomImage(t,i){i.texImage2D(i.TEXTURE_2D,0,this.format,this.format,i.UNSIGNED_BYTE,t)}_uploadRawData(t,i,r,a,n){let{data:s}=t;i&&s&&(s=Dh(s)),n.texImage2D(n.TEXTURE_2D,0,this.format,r,a,0,this.format,n.UNSIGNED_BYTE,s)}_updateDomImage(t,i,r,a){a.texSubImage2D(a.TEXTURE_2D,0,i,r,a.RGBA,a.UNSIGNED_BYTE,t)}_updateRawData(t,i,r,a,n,s,o){let{data:l}=t;i&&l&&(l=Dh(l)),o.texSubImage2D(o.TEXTURE_2D,0,r,a,n,s,o.RGBA,o.UNSIGNED_BYTE,l)}bind(t,i,r){let{context:a}=this,{gl:n}=a;this.texture!==this._ownedHandle&&(this.texture=this._ownedHandle),n.bindTexture(n.TEXTURE_2D,this.texture),(r===n.LINEAR_MIPMAP_NEAREST||r===n.LINEAR_MIPMAP_LINEAR)&&!this.useMipmap&&(r=n.LINEAR);let s=r||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),i!==this.wrap&&(n.texParameteri(n.TEXTURE_2D,n.TEXTURE_WRAP_S,i),n.texParameteri(n.TEXTURE_2D,n.TEXTURE_WRAP_T,i),this.wrap=i)}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}},vT=(lr=class{constructor(t,i,r,a=1,n=1,s=1,o=0){if(this.uid=t,i.height!==i.width)throw RangeError("DEM tiles must be square");if(r&&!["mapbox","terrarium","custom"].includes(r)){le(`"${r}" is not a valid encoding type. Valid types include "mapbox", "terrarium" and "custom".`);return}this.stride=i.height;let l=this.dim=i.height-4;switch(this.data=new Uint32Array(i.data.buffer),lr.byteViewCache.set(this,new Uint8Array(this.data.buffer)),r){case"terrarium":this.redFactor=256,this.greenFactor=1,this.blueFactor=1/256,this.baseShift=32768;break;case"custom":this.redFactor=a,this.greenFactor=n,this.blueFactor=s,this.baseShift=o;break;default:this.redFactor=6553.6,this.greenFactor=25.6,this.blueFactor=.1,this.baseShift=1e4}for(let 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,i){let r=this._getByteView(),a=this._idx(t,i)*4;return this._unpackAtIndex(r,a)}sampleBilinear(t,i){let r=Math.floor(t),a=Math.floor(i);if(r<-1||r>=this.dim||a<-1||a>=this.dim)throw RangeError(`Out of range source coordinates for DEM data. x: ${t}, y: ${i}, dim: ${this.dim}`);let n=this._getByteView(),s=((a+2)*this.stride+r+2)*4,o=this.stride*4,l=t-r,u=i-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,i){if(t<-2||t>=this.dim+2||i<-2||i>=this.dim+2)throw RangeError(`Out of range source coordinates for DEM data. x: ${t}, y: ${i}, dim: ${this.dim}`);return(i+2)*this.stride+(t+2)}unpack(t,i,r){return t*this.redFactor+i*this.greenFactor+r*this.blueFactor-this.baseShift}pack(t){return $m(t,this.getUnpackVector())}getPixels(){return new Fe({width:this.stride,height:this.stride},this._getByteView())}backfillBorder(t,i,r){if(this.dim!==t.dim)throw Error("dem dimension mismatch");let a=i*this.dim,n=i*this.dim+this.dim,s=r*this.dim,o=r*this.dim+this.dim;switch(i){case-1:a=n-2;break;case 1:n=a+2}switch(r){case-1:s=o-2;break;case 1:o=s+2}let l=-i*this.dim,u=-r*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=lr.byteViewCache.get(this);return(t==null?void 0:t.buffer)!==this.data.buffer&&(t=new Uint8Array(this.data.buffer),lr.byteViewCache.set(this,t)),t}_unpackAtIndex(t,i){return this.unpack(t[i],t[i+1],t[i+2])}},lr.byteViewCache=new WeakMap,lr);function $m(e,t){let i=t[0],r=t[1],a=t[2],n=t[3],s=Math.min(i,r,a),o=Math.round((e+n)/s);return{r:Math.floor(o*s/i)%256,g:Math.floor(o*s/r)%256,b:Math.floor(o*s/a)%256}}U("DEMData",vT);const xT=e=>e.type==="color-relief";var bT=class extends Pi{constructor(t,i){super(t,yT,i)}_createColorRamp(t){let i={elevationStops:[],colorStops:[]},r=this._transitionablePaint._values["color-relief-color"].value.expression;if(r instanceof An&&r._styleExpression.expression instanceof pi){this.colorRampExpression=r;let s=r._styleExpression.expression;i.elevationStops=s.labels,i.colorStops=[];for(let o of i.elevationStops)i.colorStops.push(s.evaluate({globals:{elevation:o}}))}if(i.elevationStops.length<1&&(i.elevationStops=[0],i.colorStops=[te.transparent]),i.elevationStops.length<2&&(i.elevationStops.push(i.elevationStops[0]+1),i.colorStops.push(i.colorStops[0])),i.elevationStops.length<=t)return i;let a={elevationStops:[],colorStops:[]},n=(i.elevationStops.length-1)/(t-1);for(let s=0;s<i.elevationStops.length-.5;s+=n)a.elevationStops.push(i.elevationStops[Math.round(s)]),a.colorStops.push(i.colorStops[Math.round(s)]);return le(`Too many colors in specification of ${this.id} color-relief layer, may not render properly. Max possible colors: ${t}, provided: ${i.elevationStops.length}`),a}_colorRampChanged(){return this.colorRampExpression!=this._transitionablePaint._values["color-relief-color"].value.expression}getColorRampTextures(t,i,r){if(this.colorRampTextures&&!this._colorRampChanged())return this.colorRampTextures;let a=this._createColorRamp(i),n=new Fe({width:a.colorStops.length,height:1}),s=new Fe({width:a.colorStops.length,height:1});for(let o=0;o<a.elevationStops.length;o++){let l=$m(a.elevationStops[o],r);s.setPixel(0,o,new te(l.r/255,l.g/255,l.b/255,1)),n.setPixel(0,o,a.colorStops[o])}return this.colorRampTextures={elevationTexture:new lt(t,s,t.gl.RGBA),colorTexture:new lt(t,n,t.gl.RGBA)},this.colorRampTextures}hasOffscreenPass(){return!this.isHidden()&&!!this.colorRampTextures}};const wT=We([{name:"a_pos",components:2,type:"Int16"}],4),TT=wT.members;function zo(e,t,i){let r=i.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,r[o.to]=!0,r[o.from]=!0)}return a}function Ih(e,t,i,r,a){let{zoom:n}=r,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},i,{},a.availableImages),h=l.evaluate({zoom:n},i,{},a.availableImages),c=l.evaluate({zoom:n+1},i,{},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,i.patterns[o.id]={min:u,mid:h,max:c}}}return i}const Vn=new Set;let Mh=!1;function ST(e,t,i=2){let r=t&&t.length,a=r?t[0]*i:e.length;Vn.size&&Vn.clear();let n=Om(e,0,a,i,!0),s=[];if(!n||n.next===n.prev)return s;let o=0,l=0,u=0;if(r&&(n=DT(e,t,n,i)),e.length>80*i){o=e[0],l=e[1];let h=o,c=l;for(let d=i;d<a;d+=i){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 zh(n,s,o,l,u),s}function Om(e,t,i,r,a){let n=null;if(a===jT(e,t,i,r)>0)for(let s=t;s<i;s+=r)n=Zm(s/r|0,e[s],e[s+1],n);else for(let s=i-r;s>=t;s-=r)n=Zm(s/r|0,e[s],e[s+1],n);return n&&Zn(n,n.next)&&(Wn(n),n=n.next),n}function ea(e,t=e){let i=t===e,r=e,a;do a=!1,r!==r.next&&(Vn.size===0||!Vn.has(r))&&(Zn(r,r.next)||ut(r.prev,r,r.next)===0)?((i||r===t)&&(t=r.prev),Mh=!0,Wn(r),r=r.prev,a=!0):(i||r!==t)&&(r=r.next,a=!i);while(a||r!==t);return t}function zh(e,t,i,r,a){a&<(e,i,r,a);let n=e,s=!1;for(;e.prev!==e.next;){let o=e.prev,l=e.next;if(ut(o,e,l)<0&&(a?PT(e,i,r,a):ET(e))){t.push(o.i,e.i,l.i),Wn(e),e=l,n=l;continue}if(e=l,e===n){if(Mh=!1,e=ea(e),Mh){n=e;continue}if(!s){e=CT(e,t),n=e,s=!0;continue}AT(e,t,i,r,a);break}}}function ET(e){let t=e.prev,i=e,r=e.next,a=t.x,n=i.x,s=r.x,o=t.y,l=i.y,u=r.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=r.next;for(;f!==t;){if(f.x>=h&&f.x<=d&&f.y>=c&&f.y<=p&&(a!==f.x||o!==f.y)&&ko(a,o,n,l,s,u,f.x,f.y)&&ut(f.prev,f,f.next)>=0)return!1;f=f.next}return!0}function PT(e,t,i,r){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),_=Lh(p,f,t,i,r),y=Lh(m,g,t,i,r),x=e.prevZ;for(;x&&x.z>=_;){if(x.x>=p&&x.x<=m&&x.y>=f&&x.y<=g&&x!==s&&(o!==x.x||h!==x.y)&&ko(o,h,l,c,u,d,x.x,x.y)&&ut(x.prev,x,x.next)>=0)return!1;x=x.prevZ}let v=e.nextZ;for(;v&&v.z<=y;){if(v.x>=p&&v.x<=m&&v.y>=f&&v.y<=g&&v!==s&&(o!==v.x||h!==v.y)&&ko(o,h,l,c,u,d,v.x,v.y)&&ut(v.prev,v,v.next)>=0)return!1;v=v.nextZ}return!0}function CT(e,t){let i=e,r=!1;do{let a=i.prev,n=i.next.next;Um(a,i,i.next,n,!1)&&qn(a,n)&&qn(n,a)&&(t.push(a.i,i.i,n.i),Wn(i),Wn(i.next),i=e=n,r=!0),i=i.next}while(i!==e);return r?ea(i):i}function AT(e,t,i,r,a){let n=e;do{let s=n.next.next;for(;s!==n.prev;){if(n.i!==s.i&&OT(n,s)){let o=Gm(n,s);n=ea(n,n.next),o=ea(o,o.next),zh(n,t,i,r,a),zh(o,t,i,r,a);return}s=s.next}n=n.next}while(n!==e)}let Fh=!1;function DT(e,t,i,r){let a=[];for(let n=0,s=t.length;n<s;n++){let o=Om(e,t[n]*r,n<s-1?t[n+1]*r:e.length,r,!1);o===o.next&&Vn.add(o),a.push($T(o))}a.sort(IT),zT(e.length/r,t.length),Nm(i,i),Fh=!0;for(let n=0;n<a.length;n++)i=MT(a[n],i);return Fh=!1,ea(i)}function IT(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 MT(e,t){let i=RT(e,t);if(!i)return t;let r=Gm(i,e),a=r.next;return Nm(i,a.next),ea(r,r.next),ea(i,i.next)}let et=new Float64Array,Fo=0;const Rh=[],kh=[];function zT(e,t){let i=Math.ceil((e+2*t)/16)+t+2;et.length<i*4&&(et=new Float64Array(i*4)),Fo=0}function Nm(e,t){let i=e;do{let r=Fo++;Rh[r]=i;let a=1/0,n=1/0,s=-1/0,o=-1/0,l=0;do{let h=i.next;i.z=r,i.x<a&&(a=i.x),i.x>s&&(s=i.x),i.y<n&&(n=i.y),i.y>o&&(o=i.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),i=h}while(++l<16&&i!==t);kh[r]=i;let u=r*4;et[u]=a,et[u+1]=n,et[u+2]=s,et[u+3]=o}while(i!==t)}function FT(e,t){let i=e.z*4;t.x<et[i]&&(et[i]=t.x),t.y<et[i+1]&&(et[i+1]=t.y),t.x>et[i+2]&&(et[i+2]=t.x),t.y>et[i+3]&&(et[i+3]=t.y)}function Vm(e){let t=kh[e];for(;t.prev.next!==t;)t=t.next;return kh[e]=t,t}function jm(e){let t=Rh[e];for(;t.prev.next!==t;)t=t.next;return Rh[e]=t,t}function RT(e,t){let i=t,r=e.x,a=e.y,n=-1/0,s;if(Zn(e,i))return i;for(let d=0,p=0;d<Fo;d++,p+=4){if(a<et[p+1]||a>et[p+3]||et[p]>r||et[p+2]<=n)continue;let f=Vm(d);i=jm(d);do{if(i.prev.next===i){if(Zn(e,i.next))return i.next;if(a<=i.y&&a>=i.next.y&&i.next.y!==i.y){let m=i.x+(a-i.y)*(i.next.x-i.x)/(i.next.y-i.y);if(m<=r&&m>n&&(n=m,s=i.x<i.next.x?i:i.next,m===r))return s}}i=i.next}while(i!==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<Fo;d++,p+=4){if(et[p+2]<o||et[p]>r||et[p+3]<u||et[p+1]>h)continue;let f=Vm(d);i=jm(d);do{if(i.prev.next===i&&r>=i.x&&i.x>=o&&r!==i.x&&ko(a<l?r:n,a,o,l,a<l?n:r,a,i.x,i.y)){let m=Math.abs(a-i.y)/(r-i.x);(qn(i,e)||i.y===a&&i.next.y===a&&i.next.x>r)&&(m<c||m===c&&(i.x>s.x||i.x===s.x&&kT(s,i)))&&(s=i,c=m)}i=i.next}while(i!==f)}return s}function kT(e,t){return ut(e.prev,e,t.prev)<0&&ut(t.next,e,e.next)<0}const _i=[];let jn=[],ta=new Uint32Array,Un=new Uint32Array;const Gn=new Uint32Array(256);function LT(e,t,i,r){let a=e,n=0;do a.z=Lh(a.x,a.y,t,i,r),_i[n++]=a,a=a.next;while(a!==e);BT(n);let s=null;for(let o=0;o<n;o++){let l=_i[o];l.prevZ=s,s&&(s.nextZ=l),s=l}s.nextZ=null}function BT(e){if(e<=32){for(let t=1;t<e;t++){let i=_i[t],r=i.z,a=t-1;for(;a>=0&&_i[a].z>r;)_i[a+1]=_i[a],a--;_i[a+1]=i}return}ta.length<e&&(ta=new Uint32Array(e),Un=new Uint32Array(e),jn=Array(e));for(let t=0;t<e;t++)ta[t]=_i[t].z;Ro(e,_i,ta,jn,Un,0),Ro(e,jn,Un,_i,ta,8),Ro(e,_i,ta,jn,Un,16),Ro(e,jn,Un,_i,ta,24)}function Ro(e,t,i,r,a,n){Gn.fill(0);for(let o=0;o<e;o++)Gn[i[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=i[o],u=Gn[l>>>n&255]++;r[u]=t[o],a[u]=l}}function Lh(e,t,i,r,a){return e=(e-i)*a|0,t=(t-r)*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 $T(e){let t=e,i=e;do(t.x<i.x||t.x===i.x&&t.y<i.y)&&(i=t),t=t.next;while(t!==e);return i}function ko(e,t,i,r,a,n,s,o){return(a-s)*(t-o)>=(e-s)*(n-o)&&(e-s)*(r-o)>=(i-s)*(t-o)&&(i-s)*(n-o)>=(a-s)*(r-o)}function OT(e,t){let i=Zn(e,t)&&ut(e.prev,e,e.next)>0&&ut(t.prev,t,t.next)>0;return e.next.i!==t.i&&(i||qn(e,t)&&qn(t,e)&&(ut(e.prev,e,t.prev)!==0||ut(e,t.prev,t)!==0))&&!NT(e,t)&&(i||VT(e,t))}function ut(e,t,i){return(t.y-e.y)*(i.x-t.x)-(t.x-e.x)*(i.y-t.y)}function Zn(e,t){return e.x===t.x&&e.y===t.y}function Um(e,t,i,r,a=!0){let n=ut(e,t,i),s=ut(e,t,r),o=ut(i,r,e),l=ut(i,r,t);return(n>0&&s<0||n<0&&s>0)&&(o>0&&l<0||o<0&&l>0)?!0:a?!!(n===0&&Lo(e,i,t)||s===0&&Lo(e,r,t)||o===0&&Lo(i,e,r)||l===0&&Lo(i,t,r)):!1}function Lo(e,t,i){return t.x<=Math.max(e.x,i.x)&&t.x>=Math.min(e.x,i.x)&&t.y<=Math.max(e.y,i.y)&&t.y>=Math.min(e.y,i.y)}function NT(e,t){let i=Math.min(e.x,t.x),r=Math.max(e.x,t.x),a=Math.min(e.y,t.y),n=Math.max(e.y,t.y),s=e;do{let o=s.next;if(s.x>r&&o.x>r||s.x<i&&o.x<i||s.y>n&&o.y>n||s.y<a&&o.y<a){s=o;continue}if(s.i!==e.i&&o.i!==e.i&&s.i!==t.i&&o.i!==t.i&&Um(s,o,e,t))return!0;s=o}while(s!==e);return!1}function qn(e,t){return ut(e.prev,e,e.next)<0?ut(e,t,e.next)>=0&&ut(e,e.prev,t)>=0:ut(e,t,e.prev)<0||ut(e,e.next,t)<0}function VT(e,t){let i=e,r=!1,a=(e.x+t.x)/2,n=(e.y+t.y)/2;do{let s=i.next;i.y>n!=s.y>n&&a<(s.x-i.x)*(n-i.y)/(s.y-i.y)+i.x&&(r=!r),i=s}while(i!==e);return r}function Gm(e,t){let i=Bh(e.i,e.x,e.y),r=Bh(t.i,t.x,t.y),a=e.next,n=t.prev;return e.next=t,t.prev=e,i.next=a,a.prev=i,r.next=i,i.prev=r,n.next=r,r.prev=n,r}function Zm(e,t,i,r){let a=Bh(e,t,i);return r?(a.next=r.next,a.prev=r,r.next.prev=a,r.next=a):(a.prev=a,a.next=a),a}function Wn(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),Fh&&FT(e.prev,e.next)}function Bh(e,t,i){return{i:e,x:t,y:i,prev:null,next:null,z:0,prevZ:null,nextZ:null}}function jT(e,t,i,r){let a=0;for(let n=t,s=i-r;n<i;n+=r)a+=(e[s]-e[n])*(e[n+1]+e[s+1]),s=n;return a}var nr=class{constructor(t,i){if(i>t)throw Error("Min granularity must not be greater than base granularity.");this._baseZoomGranularity=t,this._minGranularity=i}getGranularityForZoomLevel(t){let i=1<<t;return Math.max(Math.floor(this._baseZoomGranularity/i),this._minGranularity,1)}},$h=(_a=class{constructor(t){this.fill=t.fill,this.line=t.line,this.tile=t.tile,this.stencil=t.stencil,this.circle=t.circle}},_a.noSubdivision=new _a({fill:new nr(0,0),line:new nr(0,0),tile:new nr(0,0),stencil:new nr(0,0),circle:1}),_a);U("SubdivisionGranularityExpression",nr),U("SubdivisionGranularitySetting",$h);const Hn=-32768,Xn=32767;var UT=class{constructor(t,i){this._vertexBuffer=[],this._vertexDictionary=new Map,this._used=!1,this._granularity=t,this._granularityCellSize=k/t,this._canonical=i}_getKey(t,i){return t+=32768,i+=32768,t<<16|i<<0}_vertexToIndex(t,i){if(t<-32768||i<-32768||t>32767||i>32767)throw Error("Vertex coordinates are out of signed 16 bit integer range.");let r=Math.round(t)|0,a=Math.round(i)|0,n=this._getKey(r,a);if(this._vertexDictionary.has(n))return this._vertexDictionary.get(n);let s=this._vertexBuffer.length/2;return this._vertexDictionary.set(n,s),this._vertexBuffer.push(r,a),s}_subdivideTrianglesScanline(t){if(this._granularity<2)return ZT(this._vertexBuffer,t);let i=[],r=t.length;for(let a=0;a<r;a+=3){let n=[t[a+0],t[a+1],t[a+2]],s=[this._vertexBuffer[t[a+0]*2+0],this._vertexBuffer[t[a+0]*2+1],this._vertexBuffer[t[a+1]*2+0],this._vertexBuffer[t[a+1]*2+1],this._vertexBuffer[t[a+2]*2+0],this._vertexBuffer[t[a+2]*2+1]],o=1/0,l=1/0,u=-1/0,h=-1/0;for(let m=0;m<3;m++){let g=s[m*2],_=s[m*2+1];o=Math.min(o,g),u=Math.max(u,g),l=Math.min(l,_),h=Math.max(h,_)}if(o===u||l===h)continue;let c=Math.floor(o/this._granularityCellSize),d=Math.ceil(u/this._granularityCellSize),p=Math.floor(l/this._granularityCellSize),f=Math.ceil(h/this._granularityCellSize);if(c===d&&p===f){i.push(...n);continue}for(let m=p;m<f;m++){let g=this._scanlineGenerateVertexRingForCellRow(m,s,n);qT(this._vertexBuffer,g,i)}}return i}_scanlineGenerateVertexRingForCellRow(t,i,r){let a=t*this._granularityCellSize,n=a+this._granularityCellSize,s=[];for(let o=0;o<3;o++){let l=i[o*2],u=i[o*2+1],h=i[(o+1)*2%6],c=i[((o+1)*2+1)%6],d=i[(o+2)*2%6],p=i[((o+2)*2+1)%6],f=h-l,m=c-u,g=f===0,_=m===0,y=(a-u)/m,x=(n-u)/m,v=Math.min(y,x),w=Math.max(y,x);if(!_&&(v>=1||w<=0)||_&&(u<a||u>n)){c>=a&&c<=n&&s.push(r[(o+1)%3]);continue}if(!_&&v>0){let P=l+f*v,S=u+m*v;s.push(this._vertexToIndex(P,S))}let b=l+f*Math.max(v,0),T=l+f*Math.min(w,1);if(g||this._generateIntraEdgeVertices(s,l,u,h,c,b,T),!_&&w<1){let P=l+f*w,S=u+m*w;s.push(this._vertexToIndex(P,S))}(_||c>=a&&c<=n)&&s.push(r[(o+1)%3]),!_&&(c<=a||c>=n)&&this._generateInterEdgeVertices(s,l,u,h,c,d,p,T,a,n)}return s}_generateIntraEdgeVertices(t,i,r,a,n,s,o){let l=a-i,u=n-r,h=u===0,c=h?Math.min(i,a):Math.min(s,o),d=h?Math.max(i,a):Math.max(s,o),p=Math.floor(c/this._granularityCellSize)+1,f=Math.ceil(d/this._granularityCellSize)-1;if(h?i<a:s<o)for(let m=p;m<=f;m++){let g=m*this._granularityCellSize,_=r+u*(g-i)/l;t.push(this._vertexToIndex(g,_))}else for(let m=f;m>=p;m--){let g=m*this._granularityCellSize,_=r+u*(g-i)/l;t.push(this._vertexToIndex(g,_))}}_generateInterEdgeVertices(t,i,r,a,n,s,o,l,u,h){let c=n-r,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,x=Math.floor(Math.min(y,l)/this._granularityCellSize)+1,v=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 P=i-s,S=r-o,M=(u-o)/S,F=(h-o)/S,R=s+P*Math.min(M,F);x=Math.floor(Math.min(R,l)/this._granularityCellSize)+1,v=Math.ceil(Math.max(R,l)/this._granularityCellSize)-1,w=l<R}let T=c>0?h:u;if(w)for(let P=x;P<=v;P++){let S=P*this._granularityCellSize;t.push(this._vertexToIndex(S,T))}else for(let P=v;P>=x;P--){let S=P*this._granularityCellSize;t.push(this._vertexToIndex(S,T))}}_generateOutline(t){let i=[];for(let r of t){let a=ia(r,this._granularity,!0),n=this._pointArrayToIndices(a),s=[];for(let o=1;o<n.length;o++)s.push(n[o-1]),s.push(n[o]);i.push(s)}return i}_handlePoles(t){let i=!1,r=!1;this._canonical&&(this._canonical.y===0&&(i=!0),this._canonical.y===(1<<this._canonical.z)-1&&(r=!0)),(i||r)&&this._fillPoles(t,i,r)}_ensureNoPoleVertices(){let t=this._vertexBuffer;for(let i=0;i<t.length;i+=2){let r=t[i+1];r===-32768&&(t[i+1]=-32767),r===32767&&(t[i+1]=32766)}}_generatePoleQuad(t,i,r,a,n,s){a>n==(s===-32768)?(t.push(r),t.push(i),t.push(this._vertexToIndex(a,s)),t.push(this._vertexToIndex(n,s)),t.push(r),t.push(this._vertexToIndex(a,s))):(t.push(i),t.push(r),t.push(this._vertexToIndex(a,s)),t.push(r),t.push(this._vertexToIndex(n,s)),t.push(this._vertexToIndex(a,s)))}_fillPoles(t,i,r){let a=this._vertexBuffer,n=k,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];i&&(d===0&&f===0&&this._generatePoleQuad(t,l,u,c,p,Hn),f===0&&g===0&&this._generatePoleQuad(t,u,h,p,m,Hn),g===0&&d===0&&this._generatePoleQuad(t,h,l,m,c,Hn)),r&&(d===n&&f===n&&this._generatePoleQuad(t,l,u,c,p,Xn),f===n&&g===n&&this._generatePoleQuad(t,u,h,p,m,Xn),g===n&&d===n&&this._generatePoleQuad(t,h,l,m,c,Xn))}}_initializeVertices(t){for(let i=0;i<t.length;i+=2)this._vertexToIndex(t[i],t[i+1])}subdividePolygonInternal(t,i){var o;if(this._used)throw Error("Subdivision: multiple use not allowed.");this._used=!0;let{flattened:r,holeIndices:a}=GT(t);this._initializeVertices(r);let n;try{let l=ST(r,a),u=this._convertIndices(r,l);n=this._subdivideTrianglesScanline(u)}catch(l){console.error(l)}let s=[];return i&&(s=this._generateOutline(t)),this._ensureNoPoleVertices(),this._handlePoles(n),this._granularity>=2&&((o=this._canonical)==null?void 0:o.z)===0&&(n=this._removeTrianglesOutsideTileX(n),s=s.map(l=>this._removeLinesOutsideTileX(l))),{verticesFlattened:this._vertexBuffer,indicesTriangles:n,indicesLineList:s}}_vertexOutsideTileX(t){let i=this._vertexBuffer[t*2];return i<0||i>8192}_removeTrianglesOutsideTileX(t){let i=[];for(let r=0;r<t.length;r+=3)this._vertexOutsideTileX(t[r])||this._vertexOutsideTileX(t[r+1])||this._vertexOutsideTileX(t[r+2])||i.push(t[r],t[r+1],t[r+2]);return i}_removeLinesOutsideTileX(t){let i=[];for(let r=0;r<t.length;r+=2)this._vertexOutsideTileX(t[r])||this._vertexOutsideTileX(t[r+1])||i.push(t[r],t[r+1]);return i}_convertIndices(t,i){let r=[];for(let a of i){let n=t[a*2],s=t[a*2+1];r.push(this._vertexToIndex(n,s))}return r}_pointArrayToIndices(t){let i=[];for(let r of t)i.push(this._vertexToIndex(r.x,r.y));return i}};function qm(e,t,i,r=!0){return new UT(i,t).subdividePolygonInternal(e,r)}function ia(e,t,i=!1){if(!e||e.length<1||e.length<2)return[];let r=e[0],a=e[e.length-1],n=i&&(r.x!==a.x||r.y!==a.y);if(t<2)return n?[...e,e[0]]:[...e];let s=Math.floor(k/t),o=[];o.push(new C(e[0].x,e[0].y));let l=e.length,u=n?l:l-1;for(let h=0;h<u;h++){let c=e[h],d=h<l-1?e[h+1]:e[0],p=c.x,f=c.y,m=d.x,g=d.y,_=p!==m,y=f!==g;if(!_&&!y)continue;let x=m-p,v=g-f,w=Math.abs(x),b=Math.abs(v),T=p,P=f;for(;;){let M=x>0?(Math.floor(T/s)+1)*s:(Math.ceil(T/s)-1)*s,F=v>0?(Math.floor(P/s)+1)*s:(Math.ceil(P/s)-1)*s,R=Math.abs(T-M),I=Math.abs(P-F),D=Math.abs(T-m),E=Math.abs(P-g),A=_?R/w:1/0,B=y?I/b:1/0;if((D<=R||!_)&&(E<=I||!y))break;if(A<B&&_||!y){T=M,P+=v*A;let N=new C(T,Math.round(P));(o[o.length-1].x!==N.x||o[o.length-1].y!==N.y)&&o.push(N)}else{T+=x*B,P=F;let N=new C(Math.round(T),P);(o[o.length-1].x!==N.x||o[o.length-1].y!==N.y)&&o.push(N)}}let S=new C(m,g);(o[o.length-1].x!==S.x||o[o.length-1].y!==S.y)&&o.push(S)}return o}function GT(e){let t=[],i=[];for(let r of e)if(r.length!==0){r!==e[0]&&t.push(i.length/2);for(let a of r)i.push(a.x),i.push(a.y)}return{flattened:i,holeIndices:t}}function ZT(e,t){let i=[];for(let r=0;r<t.length;r+=3){let a=t[r],n=t[r+1],s=t[r+2],o=e[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?(i.push(a),i.push(s),i.push(n)):(i.push(a),i.push(n),i.push(s))}return i}function qT(e,t,i){if(t.length===0)throw Error("Subdivision vertex ring is empty.");let r=0,a=e[t[0]*2];for(let l=1;l<t.length;l++){let u=e[t[l]*2];u<a&&(a=u,r=l)}let n=t.length,s=r,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 x=_-m,v=-(g-f),w=m<_?1:-1;((h-f)*x+(c-m)*v)*w>((d-f)*x+(p-m)*v)*w&&(y=!0)}if(y){let x=t[l],v=t[s],w=t[o];x!==v&&x!==w&&v!==w&&i.push(w,v,x),s--,s<0&&(s=n-1)}else{let x=t[u],v=t[s],w=t[o];x!==v&&x!==w&&v!==w&&i.push(w,v,x),o++,o>=n&&(o=0)}if(l===u)break}}function Wm(e,t,i,r,a,n,s,o,l){let u=a.length/2,h=s&&o&&l;if(u<Ne.MAX_VERTEX_ARRAY_LENGTH){let c=t.prepareSegment(u,i,r),d=c.vertexLength;for(let m=0;m<n.length;m+=3)r.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,i,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 WT(t,i,r,a,n,e),h&&HT(s,i,o,a,l,e),t.forceNewSegmentOnNextPrepare(),s==null||s.forceNewSegmentOnNextPrepare()}function Yn(e,t,i,r,a,n,s){if(n){let o=r.count;return i(t[a*2],t[a*2+1]),e[a]=r.count,r.count++,s.vertexLength++,o}return e[a]}function WT(e,t,i,r,a,n){let s=[];for(let c=0;c<r.length/2;c++)s.push(-1);let o={count:0},l=0,u=e.getOrCreateLatestSegment(t,i),h=u.vertexLength;for(let c=2;c<a.length;c+=3){let d=a[c-2],p=a[c-1],f=a[c],m=s[d]<l,g=s[p]<l,_=s[f]<l,y=+!!m+ +!!g+ +!!_;u.vertexLength+y>Ne.MAX_VERTEX_ARRAY_LENGTH&&(u=e.createNewSegment(t,i),l=o.count,m=!0,g=!0,_=!0,h=0);let x=Yn(s,r,n,o,d,m,u),v=Yn(s,r,n,o,p,g,u),w=Yn(s,r,n,o,f,_,u);i.emplaceBack(h+x-l,h+v-l,h+w-l),u.primitiveLength++}}function HT(e,t,i,r,a,n){let s=[];for(let c=0;c<r.length/2;c++)s.push(-1);let o={count:0},l=0,u=e.getOrCreateLatestSegment(t,i),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+_>Ne.MAX_VERTEX_ARRAY_LENGTH&&(u=e.createNewSegment(t,i),l=o.count,m=!0,g=!0,h=0);let y=Yn(s,r,n,o,p,m,u),x=Yn(s,r,n,o,f,g,u);i.emplaceBack(h+y-l,h+x-l),u.primitiveLength++}}var Hm=class{constructor(t){this.zoom=t.zoom,this.overscaling=t.overscaling,this.layers=t.layers,this.layerIds=this.layers.map(i=>i.id),this.index=t.index,this.hasDependencies=!1,this.sdfPatterns={},this.patternFeatures=[],this.layoutVertexArray=new x2,this.indexArray=new Gi,this.indexArray2=new _h,this.programConfigurations=new Kr(t.layers,t.zoom),this.segments=new Ne,this.segments2=new Ne,this.stateDependentLayerIds=this.layers.filter(i=>i.isStateDependent()).map(i=>i.id)}populate(t,i,r){this.hasDependencies=zo("fill",this.layers,i);let a=this.layers[0].layout.get("fill-sort-key"),n=!a.isConstant(),s=[],o=new be(this.zoom),l=this.layers[0]._featureFilter.needGeometry;for(let{feature:u,id:h,index:c,sourceLayerIndex:d}of t){let p=Qr(u,l);if(!this.layers[0]._featureFilter.filter(o,p,r))continue;let f=n?a.evaluate(p,{},r,i.availableImages):void 0,m={id:h,properties:u.properties,type:u.type,sourceLayerIndex:d,index:c,geometry:l?p.geometry:Jr(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=Ih("fill",this.layers,u,{zoom:this.zoom},i);this.patternFeatures.push(f)}else this.addFeature(u,h,c,r,{},i.subdivisionGranularity);let p=t[c].feature;i.featureIndex.insert(p,h,c,d,this.index)}}update(t,i,r){this.stateDependentLayers.length&&this.programConfigurations.updatePaintArrays(t,i,this.stateDependentLayers,{imagePositions:r})}addFeatures({options:t,canonical:i,patternPositions:r,patternMap:a}){this.detectSdfPatterns(a);for(let n of this.patternFeatures)this.addFeature(n,n.geometry,n.index,i,r,t.subdivisionGranularity)}detectSdfPatterns(t){for(let i of this.patternFeatures)for(let r in i.patterns){let a=i.patterns[r];this.recordSdfPattern(r,t[a.min]),this.recordSdfPattern(r,t[a.mid]),this.recordSdfPattern(r,t[a.max])}for(let i of this.layers){let r=i.paint.get("fill-pattern").constantOr(null);r&&(this.recordSdfPattern(i.id,t[r.from.toString()]),this.recordSdfPattern(i.id,t[r.to.toString()]))}}recordSdfPattern(t,i){if(!i)return;let r=i.sdf===!0,a=this.sdfPatterns[t];a===void 0?this.sdfPatterns[t]=r:a!==r&&le(`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,TT),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,i,r,a,n,s){for(let o of Js(i,500)){let l=qm(o,a,s.fill.getGranularityForZoomLevel(a.z)),u=this.layoutVertexArray;Wm((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,r,{imagePositions:n,canonical:a})}};U("FillBucket",Hm,{omit:["layers","patternFeatures"]});let XT;const YT=()=>XT||(XT=new yt({"fill-sort-key":new J(z.layout_fill["fill-sort-key"],"fill-sort-key")}));let KT;const JT=()=>KT||(KT=new yt({"fill-antialias":new j(z.paint_fill["fill-antialias"],"fill-antialias"),"fill-opacity":new J(z.paint_fill["fill-opacity"],"fill-opacity"),"fill-layer-opacity":new j(z.paint_fill["fill-layer-opacity"],"fill-layer-opacity"),"fill-color":new J(z.paint_fill["fill-color"],"fill-color"),"fill-outline-color":new J(z.paint_fill["fill-outline-color"],"fill-outline-color"),"fill-translate":new j(z.paint_fill["fill-translate"],"fill-translate"),"fill-translate-anchor":new j(z.paint_fill["fill-translate-anchor"],"fill-translate-anchor"),"fill-pattern":new kn(z.paint_fill["fill-pattern"],"fill-pattern")}));var QT={get paint(){return JT()},get layout(){return YT()}};const eS=e=>e.type==="fill";var tS=class extends Pi{constructor(t,i){super(t,QT,i)}recalculate(t,i){super.recalculate(t,i);let r=this.paint._values["fill-outline-color"];r.value.kind==="constant"&&r.value.value===void 0&&(this.paint._values["fill-outline-color"]=this.paint._values["fill-color"])}createBucket(t){return new Hm(t)}queryRadius(){return Ao(this.paint.get("fill-translate"))}queryIntersectsFeature({queryGeometry:t,geometry:i,transform:r,pixelsToTileUnits:a}){return Mm(Do(t,this.paint.get("fill-translate"),this.paint.get("fill-translate-anchor"),-r.bearingInRadians,a),i)}isTileClipped(){return!0}};const iS=We([{name:"a_pos",components:2,type:"Int16"},{name:"a_normal_ed",components:4,type:"Int16"}],4),rS=We([{name:"a_centroid",components:2,type:"Int16"}],4),aS=iS.members;var Di=class Xd{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 i=new Xd;return i.extend(t(new C(this.minX,this.minY))),i.extend(t(new C(this.maxX,this.minY))),i.extend(t(new C(this.minX,this.maxY))),i.extend(t(new C(this.maxX,this.maxY))),i}static fromPoints(t){let i=new Xd;for(let r of t)i.extend(r);return i}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 nS=Di.fromPoints([new C(0,0),new C(k,k)]);function Oh(e,t){return e.x===t.x&&(e.x<0||e.x>8192)||e.y===t.y&&(e.y<0||e.y>8192)}function Xm(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 Kn=class{constructor(t,i,r,a,n){for(this.properties=Object.create(null),this.extent=r,this.type=0,this.id=void 0,this._pbf=t,this._geometry=-1,this._keys=a,this._values=n;t.pos<i;){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 i=t.readVarint()+t.pos,r=[],a,n=1,s=0,o=0,l=0;for(;t.pos<i;){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&&r.push(a),a=[new C(o,l)];else if(n===2)o+=t.readSVarint(),l+=t.readSVarint(),a&&a.push(new C(o,l));else if(n===7)a&&a.push(a[0].clone());else throw Error(`unknown command ${n}`)}return a&&r.push(a),r}bbox(){if(this._geometry<0)throw Error("feature has no geometry");let t=this._pbf;t.pos=this._geometry;let i=t.readVarint()+t.pos,r=1,a=0,n=0,s=0,o=1/0,l=-1/0,u=1/0,h=-1/0;for(;t.pos<i;){if(a<=0){let c=t.readVarint();if(r=c&7,a=c>>3,a===0)continue}if(a--,r===1||r===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(r!==7)throw Error(`unknown command ${r}`)}return[o,u,l,h]}toGeoJSON(t,i,r){let a=this.extent*2**r,n=this.extent*t,s=this.extent*i,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=Ym(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}};Kn.types=["Unknown","Point","LineString","Polygon"];function Ym(e){let t=e.length;if(t<=1)return[e];let i=[],r,a;for(let n=0;n<t;n++){let s=sS(e[n]);s!==0&&(a===void 0&&(a=s<0),a===s<0?(r&&i.push(r),r=[e[n]]):r&&r.push(e[n]))}return r&&i.push(r),i}function sS(e){let t=0;for(let i=0,r=e.length,a=r-1,n,s;i<r;a=i++)n=e[i],s=e[a],t+=(s.x-n.x)*(n.y+s.y);return t}var oS=class{constructor(t,i){for(this.version=1,this.name="",this.extent=4096,this.length=0,this._pbf=t,this._keys=[],this._values=[],this._features=[],i===void 0&&(i=t.length);t.pos<i;){let r=t.readVarint();r===10?this.name=t.readString():r===18?(this._features.push(t.pos),t.skip(r)):r===26?this._keys.push(t.readString()):r===34?this._values.push(lS(t)):r===40?this.extent=t.readVarint():r===120?this.version=t.readVarint():t.skip(r)}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 i=this._pbf.readVarint()+this._pbf.pos;return new Kn(this._pbf,i,this.extent,this._keys,this._values)}};function lS(e){let t=null,i=e.readVarint()+e.pos;for(;e.pos<i;){let r=e.readVarint();t=r===10?e.readString():r===21?e.readFloat():r===25?e.readDouble():r===32?e.readVarint(!0):r===40?e.readVarint():r===48?e.readSVarint():r===56?e.readBoolean():(e.skip(r),null)}if(t==null)throw Error("unknown feature value");return t}var uS=class{constructor(t,i=t.length){let r=Object.create(null);for(;t.pos<i;){let a=t.readVarint();if(a===26){let n=new oS(t,t.readVarint()+t.pos);n.length&&(r[n.name]=n)}else t.skip(a)}this.layers=r}};const Nt=63710088e-1;var W=class Fs{constructor(t,i){if(isNaN(t)||isNaN(i))throw Error(`Invalid LngLat object: (${t}, ${i})`);if(this.lng=+t,this.lat=+i,this.lat>90||this.lat<-90)throw Error("Invalid LngLat latitude value: must be between -90 and 90")}wrap(){return new Fs(ci(this.lng,-180,180),this.lat)}toArray(){return[this.lng,this.lat]}toString(){return`LngLat(${this.lng}, ${this.lat})`}distanceTo(t){let i=Math.PI/180,r=this.lat*i,a=t.lat*i,n=Math.sin(r)*Math.sin(a)+Math.cos(r)*Math.cos(a)*Math.cos((t.lng-this.lng)*i);return Nt*Math.acos(Math.min(n,1))}static convert(t){if(t instanceof Fs)return t;if(Array.isArray(t)&&(t.length===2||t.length===3))return new Fs(Number(t[0]),Number(t[1]));if(!Array.isArray(t)&&typeof t=="object"&&t)return new Fs(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 Km=2*Math.PI*Nt;function Jm(e){return Km*Math.cos(e*Math.PI/180)}function Va(e){return(180+e)/360}function ja(e){return(180-180/Math.PI*Math.log(Math.tan(Math.PI/4+e*Math.PI/360)))/360}function ra(e,t){return e/Jm(t)}function Nh(e){return e*360-180}function Jn(e){let t=180-e*360;return 360/Math.PI*Math.atan(Math.exp(t*Math.PI/180))-90}function Qm(e,t){return e*Jm(Jn(t))}function hS(e){return 1/Math.cos(e*Math.PI/180)}var ye=class M1{constructor(t,i,r=0){this.x=+t,this.y=+i,this.z=+r}static fromLngLat(t,i=0){let r=W.convert(t);return new M1(Va(r.lng),ja(r.lat),ra(i,r.lat))}toLngLat(){return new W(Nh(this.x),Jn(this.y))}toAltitude(){return Qm(this.z,this.y)}meterInMercatorCoordinateUnits(){return 1/Km*hS(Jn(this.y))}};const aa=89.25;function eg(e,t,i){let r=1/(1<<i.z);return new ye(e/k*r+i.x*r,t/k*r+i.y*r)}function cS(e,t,i){return eg(e,t,i).toLngLat()}function Zi(e,t){let i=ee(t.lat,-85.051129,Bi);return new C(Va(t.lng)*e,ja(i)*e)}function Qn(e,t){return new ye(t.x/e,t.y/e).toLngLat()}function es(e){return e.cameraToCenterDistance*Math.min(Math.tan(Be(90-e.pitch))*.85,Math.tan(Be(aa-e.pitch)))}function Vh(e,t){let i=e.canonical,r=t/$t(i.z),a=i.x+2**i.z*e.wrap,n=new Float64Array(16);return Si(n),rt(n,n,[a*r,i.y*r,0]),Tt(n,n,[r/k,r/k,1]),n}function tg(e,t,i,r,a){let n=ye.fromLngLat(e,t),s=a*ra(1,e.lat),{x:o,y:l,z:u}=jh(i,r),h=s*-o,c=s*-l,d=s*u;return new ye(n.x+h,n.y+c,n.z+d)}function dS(e){let t=ra(1,e.center.lat)*e.worldSize;return tg(e.center,e.elevation,e.pitch,e.bearing,e.cameraToCenterDistance/t)}function jh(e,t){let i=Be(e),r=Be(t),a=Math.cos(-i),n=Math.sin(i);return{x:n*Math.sin(r),y:-n*Math.cos(r),z:a}}function ig(e,t,i){if(t<=0||!e||e.length===0)return e;let r=pS(t,i);return e.map(a=>fS(a,r))}function pS(e,t){let i=cS(k/2,k/2,t),r=ye.fromLngLat(i).meterInMercatorCoordinateUnits(),a=(1<<t.z)*k;return e*r*a}function fS(e,t){if(!e||e.length<3)return e;let i=e[0].x===e[e.length-1].x&&e[0].y===e[e.length-1].y,r=i?e.length-1:e.length;if(r<3)return e;let a=[];for(let s=0;s<r;s++){let o=e[(s-1+r)%r],l=e[s],u=e[(s+1)%r];if(Oh(o,l)||Oh(l,u)){a.push(l.clone());continue}gS(a,o,l,u,t)}let n=mS(a);return n.length<3?e:(i&&n.push(n[0].clone()),n)}function mS(e){let t=[];for(let i of e){let r=i.round(),a=t[t.length-1];((a==null?void 0:a.x)!==r.x||(a==null?void 0:a.y)!==r.y)&&t.push(r)}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 gS(e,t,i,r,a){let n=t.sub(i),s=r.sub(i),o=n.mag(),l=s.mag();if(o<1e-6||l<1e-6){e.push(i.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(i.clone());return}let h=.2,c=Math.min(a,o*h,l*h),d=i.add(n.mult(c)),p=i.add(s.mult(c)),f=Math.sqrt((1+u)/2),m=i.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 Uh=8192;function ts(e,t,i,r,a,n,s,o){e.emplaceBack(t,i,Math.floor(r*Uh)*2+s,a*Uh*2,n*Uh*2,Math.round(o))}var rg=class{constructor(t){this.zoom=t.zoom,this.overscaling=t.overscaling,this.layers=t.layers,this.layerIds=this.layers.map(i=>i.id),this.index=t.index,this.hasDependencies=!1,this.layoutVertexArray=new b2,this.centroidVertexArray=new Pr,this.indexArray=new Gi,this.programConfigurations=new Kr(t.layers,t.zoom),this.segments=new Ne,this.stateDependentLayerIds=this.layers.filter(i=>i.isStateDependent()).map(i=>i.id)}populate(t,i,r){this.features=[],this.hasDependencies=zo("fill-extrusion",this.layers,i);let a=new be(this.zoom),n=this.layers[0],s=n.layout.get("fill-extrusion-rounded-corner-distance"),o=n._featureFilter.needGeometry;for(let{feature:l,id:u,index:h,sourceLayerIndex:c}of t){let d=Qr(l,o);if(!n._featureFilter.filter(a,d,r))continue;let p=o?d.geometry:Jr(l),f={id:u,sourceLayerIndex:c,index:h,geometry:s>0?ig(p,s,r):p,properties:l.properties,type:l.type,patterns:{}};this.hasDependencies?this.features.push(Ih("fill-extrusion",this.layers,f,{zoom:this.zoom},i)):this.addFeature(f,f.geometry,h,r,{},i.subdivisionGranularity),i.featureIndex.insert(l,f.geometry,h,c,this.index,!0)}}addFeatures({options:t,canonical:i,patternPositions:r}){for(let a of this.features){let{geometry:n}=a;this.addFeature(a,n,a.index,i,r,t.subdivisionGranularity)}}update(t,i,r){this.stateDependentLayers.length&&this.programConfigurations.updatePaintArrays(t,i,this.stateDependentLayers,{imagePositions:r})}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,aS),this.centroidVertexBuffer=t.createVertexBuffer(this.centroidVertexArray,rS.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,i,r,a,n,s){let o=this.layers[0],l=o.layout?o.layout.get("fill-extrusion-rounded-corner-distance"):0,u=l>0?ig(i,l,a):i;for(let h of Js(u,500)){let c={x:0,y:0,sampleCount:0},d=this.layoutVertexArray.length;this.processPolygon(c,a,t,h,s);let p=this.layoutVertexArray.length-d,f=Math.floor(c.x/c.sampleCount),m=Math.floor(c.y/c.sampleCount);for(let g=0;g<p;g++)this.centroidVertexArray.emplaceBack(f,m)}this.programConfigurations.populatePaintArrays(this.layoutVertexArray.length,t,r,{imagePositions:n,canonical:a})}processPolygon(t,i,r,a,n){if(a.length<1||Xm(a[0]))return;for(let c of a)c.length!==0&&_S(t,c);let s={segment:this.segments.prepareSegment(4,this.layoutVertexArray,this.indexArray)},o=n.fill.getGranularityForZoomLevel(i.z),l=Kn.types[r.type]==="Polygon";for(let c of a){if(c.length===0||Xm(c))continue;let d=ia(c,o,l);this._generateSideFaces(d,s)}if(!l)return;let u=qm(a,i,o,!1),h=this.layoutVertexArray;Wm((c,d)=>{ts(h,c,d,0,0,1,1,0)},this.segments,this.layoutVertexArray,this.indexArray,u.verticesFlattened,u.indicesTriangles)}_generateSideFaces(t,i){let r=0;for(let a=1;a<t.length;a++){let n=t[a],s=t[a-1];if(Oh(n,s))continue;i.segment.vertexLength+4>Ne.MAX_VERTEX_ARRAY_LENGTH&&(i.segment=this.segments.prepareSegment(4,this.layoutVertexArray,this.indexArray));let o=n.sub(s)._perp()._unit(),l=s.dist(n);r+l>32768&&(r=0),ts(this.layoutVertexArray,n.x,n.y,o.x,o.y,0,0,r),ts(this.layoutVertexArray,n.x,n.y,o.x,o.y,0,1,r),r+=l,ts(this.layoutVertexArray,s.x,s.y,o.x,o.y,0,0,r),ts(this.layoutVertexArray,s.x,s.y,o.x,o.y,0,1,r);let u=i.segment.vertexLength;this.indexArray.emplaceBack(u,u+2,u+1),this.indexArray.emplaceBack(u+1,u+2,u+3),i.segment.vertexLength+=4,i.segment.primitiveLength+=2}}};function _S(e,t){for(let i=0;i<t.length;i++){let r=t[i];(i!==t.length-1||t[0].x!==r.x||t[0].y!==r.y)&&(e.x+=r.x,e.y+=r.y,e.sampleCount++)}}U("FillExtrusionBucket",rg,{omit:["layers","features"]});let yS;const vS=()=>yS||(yS=new yt({"fill-extrusion-rounded-corner-distance":new j(z["layout_fill-extrusion"]["fill-extrusion-rounded-corner-distance"],"fill-extrusion-rounded-corner-distance")}));let xS;const bS=()=>xS||(xS=new yt({"fill-extrusion-opacity":new j(z["paint_fill-extrusion"]["fill-extrusion-opacity"],"fill-extrusion-opacity"),"fill-extrusion-color":new J(z["paint_fill-extrusion"]["fill-extrusion-color"],"fill-extrusion-color"),"fill-extrusion-translate":new j(z["paint_fill-extrusion"]["fill-extrusion-translate"],"fill-extrusion-translate"),"fill-extrusion-translate-anchor":new j(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 J(z["paint_fill-extrusion"]["fill-extrusion-height"],"fill-extrusion-height"),"fill-extrusion-base":new J(z["paint_fill-extrusion"]["fill-extrusion-base"],"fill-extrusion-base"),"fill-extrusion-vertical-gradient":new j(z["paint_fill-extrusion"]["fill-extrusion-vertical-gradient"],"fill-extrusion-vertical-gradient")}));var wS={get paint(){return bS()},get layout(){return vS()}};const TS=e=>e.type==="fill-extrusion";var SS=class extends Pi{constructor(t,i){super(t,wS,i)}createBucket(t){return new rg(t)}queryRadius(){return Ao(this.paint.get("fill-extrusion-translate"))}is3D(){return!0}queryIntersectsFeature({queryGeometry:t,feature:i,featureState:r,geometry:a,transform:n,pixelsToTileUnits:s,pixelPosMatrix:o}){let l=Do(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(i,r),h=this.paint.get("fill-extrusion-base").evaluate(i,r),c=CS(l,o,0),d=PS(a,h,u,o),p=d[0],f=d[1];return ES(p,f,c)}};function is(e,t){return e.x*t.x+e.y*t.y}function ag(e,t){if(e.length===1){let i=0,r=t[i++],a;for(;!a||r.equals(a);)if(a=t[i++],!a)return 1/0;for(;i<t.length;i++){let n=t[i],s=e[0],o=a.sub(r),l=n.sub(r),u=s.sub(r),h=is(o,o),c=is(o,l),d=is(l,l),p=is(u,o),f=is(u,l),m=h*d-c*c,g=(d*p-c*f)/m,_=(h*f-c*p)/m,y=1-g-_,x=r.z*y+a.z*g+n.z*_;if(isFinite(x))return x}return 1/0}{let i=1/0;for(let r of t)i=Math.min(i,r.z);return i}}function ES(e,t,i){let r=1/0;Mm(i,t)&&(r=ag(i,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];Im(i,c)&&(r=Math.min(r,ag(i,c)))}}return r!==1/0&&r}function PS(e,t,i,r){let a=[],n=[],s=r[8]*t,o=r[9]*t,l=r[10]*t,u=r[11]*t,h=r[8]*i,c=r[9]*i,d=r[10]*i,p=r[11]*i;for(let f of e){let m=[],g=[];for(let _ of f){let y=_.x,x=_.y,v=r[0]*y+r[4]*x+r[12],w=r[1]*y+r[5]*x+r[13],b=r[2]*y+r[6]*x+r[14],T=r[3]*y+r[7]*x+r[15],P=v+s,S=w+o,M=b+l,F=T+u,R=v+h,I=w+c,D=b+d,E=T+p,A=new C(P/F,S/F);A.z=M/F,m.push(A);let B=new C(R/E,I/E);B.z=D/E,g.push(B)}a.push(m),n.push(g)}return[a,n]}function CS(e,t,i){let r=[];for(let a of e){let n=[a.x,a.y,i,1];pt(n,n,t),r.push(new C(n[0]/n[3],n[1]/n[3]))}return r}const AS="geojsonvt_clip_start",DS="geojsonvt_clip_end",IS=We([{name:"a_pos_normal",components:2,type:"Int16"},{name:"a_data",components:4,type:"Uint8"}],4),MS=IS.members,zS=We([{name:"a_uv_x",components:1,type:"Float32"},{name:"a_split_index",components:1,type:"Float32"}]),FS=zS.members,RS=Math.cos(75/2*(Math.PI/180)),ng=1/2,sg=2**14/ng;var og=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 T2,this.indexArray=new Gi,this.programConfigurations=new Kr(e.layers,e.zoom),this.segments=new Ne,this.maxLineLength=0,this.stateDependentLayerIds=this.layers.filter(t=>t.isStateDependent()).map(t=>t.id)}populate(e,t,i){this.hasDependencies=zo("line",this.layers,t)||this.hasLineDasharray(this.layers);let r=this.layers[0].layout.get("line-sort-key"),a=!r.isConstant(),n=[],s=new be(this.zoom),o=this.layers[0]._featureFilter.needGeometry;for(let{feature:l,id:u,index:h,sourceLayerIndex:c}of e){let d=Qr(l,o);if(!this.layers[0]._featureFilter.filter(s,d,i))continue;let p=a?r.evaluate(d,{},i):void 0,f={id:u,properties:l.properties,type:l.type,sourceLayerIndex:c,index:h,geometry:o?d.geometry:Jr(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?(zo("line",this.layers,t)?Ih("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,i,{},{},t.subdivisionGranularity);let d=e[h].feature;t.featureIndex.insert(d,u,h,c,this.index)}}update(e,t,i,r){this.stateDependentLayers.length&&this.programConfigurations.updatePaintArrays(e,t,this.stateDependentLayers,{imagePositions:i,dashPositions:r})}addFeatures({options:e,canonical:t,patternPositions:i,dashPositions:r}){for(let a of this.patternFeatures)this.addFeature(a,a.geometry,a.index,t,i,r,e.subdivisionGranularity)}isEmpty(){return 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,FS)),this.layoutVertexBuffer=e.createVertexBuffer(this.layoutVertexArray,MS),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[AS],end:+e.properties[DS]}}addFeature(e,t,i,r,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,r,s);this.programConfigurations.populatePaintArrays(this.layoutVertexArray.length,e,i,{imagePositions:a,dashPositions:n,canonical:r})}addLine(e,t,i,r,a,n,s,o){this.distance=0,this.scaledDistance=0,this.totalDistance=0;let l=s?o.line.getGranularityForZoomLevel(s.z):1;if(e=ia(e,l),this.lineClips){this.lineClipsArray.push(this.lineClips);for(let x=0;x<e.length-1;x++)this.totalDistance+=e[x].dist(e[x+1]);this.updateScaledDistance(),this.maxLineLength=Math.max(this.maxLineLength,this.totalDistance)}let u=Kn.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;i==="bevel"&&(a=1.05);let d=this.overscaling<=16?15*k/(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 x=c;x<h;x++){if(g=x===h-1?u?e[c+1]:void 0:e[x+1],g&&e[x].equals(g))continue;y&&(_=y),f&&(m=f),f=e[x],y=g?g.sub(f)._unit()._perp():_,_||(_=y);let v=_.add(y);(v.x!==0||v.y!==0)&&v._unit();let w=_.x*y.x+_.y*y.y,b=v.x*y.x+v.y*y.y,T=b===0?1/0:1/b,P=2*Math.sqrt(2-2*b),S=b<RS&&m&&g,M=_.x*y.y-_.y*y.x>0;if(S&&x>c){let I=f.dist(m);if(I>2*d){let D=f.sub(f.sub(m)._mult(d/I)._round());this.updateDistance(m,D),this.addCurrentVertex(D,_,0,0,p),m=D}}let F=m&&g,R=F?i:u?"butt":r;if(F&&R==="round"&&(T<n?R="miter":T<=2&&(R="fakeround")),R==="miter"&&T>a&&(R="bevel"),R==="bevel"&&(T>2&&(R="flipbevel"),T<a&&(R="miter")),m&&this.updateDistance(m,f),R==="miter")v._mult(T),this.addCurrentVertex(f,v,0,0,p);else if(R==="flipbevel"){if(T>100)v=y.mult(-1);else{let I=T*_.add(y).mag()/_.sub(y).mag();v._perp()._mult(I*(M?-1:1))}this.addCurrentVertex(f,v,0,0,p),this.addCurrentVertex(f,v.mult(-1),0,0,p)}else if(R==="bevel"||R==="fakeround"){let I=-Math.sqrt(T*T-1),D=M?I:0,E=M?0:I;if(m&&this.addCurrentVertex(f,_,D,E,p),R==="fakeround"){let A=Math.round(P*180/Math.PI/20);for(let B=1;B<A;B++){let N=B/A;if(N!==.5){let H=N-.5,ue=1.0904+w*(-3.2452+w*(3.55645-w*1.43519)),Ae=.848013+w*(-1.06021+w*.215638);N+=N*H*(N-1)*(ue*H*H+Ae)}let O=y.sub(_)._mult(N)._add(_)._unit()._mult(M?-1:1);this.addHalfVertex(f,O.x,O.y,!1,M,0,p)}}g&&this.addCurrentVertex(f,y,-D,-E,p)}else if(R==="butt")this.addCurrentVertex(f,v,0,0,p);else if(R==="square"){let I=m?1:-1;this.addCurrentVertex(f,v,I,I,p)}else R==="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(S&&x<h-1){let I=f.dist(g);if(I>2*d){let D=f.add(g.sub(f)._mult(d/I)._round());this.updateDistance(f,D),this.addCurrentVertex(D,y,0,0,p),f=D}}}}addCurrentVertex(e,t,i,r,a,n=!1){let s=t.x+t.y*i,o=t.y-t.x*i,l=-t.x+t.y*r,u=-t.y-t.x*r;this.addHalfVertex(e,s,o,n,!1,i,a),this.addHalfVertex(e,l,u,n,!0,-r,a),this.distance>sg/2&&this.totalDistance===0&&(this.distance=0,this.updateScaledDistance(),this.addCurrentVertex(e,t,i,r,a,n))}addHalfVertex({x:e,y:t},i,r,a,n,s,o){let l=(this.lineClips?this.scaledDistance*(sg-1):this.scaledDistance)*ng;if(this.layoutVertexArray.emplaceBack((e<<1)+ +!!a,(t<<1)+ +!!n,Math.round(63*i)+128,Math.round(63*r)+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 i=t.paint.get("line-dasharray");if(i&&!i.isConstant())return!0}return!1}addLineDashDependencies(e,t,i,r){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:i-1},t,{}),round:s},l={dasharray:n.value.evaluate({zoom:i},t,{}),round:s},u={dasharray:n.value.evaluate({zoom:i+1},t,{}),round:s},h=`${o.dasharray.join(",")},${o.round}`,c=`${l.dasharray.join(",")},${l.round}`,d=`${u.dasharray.join(",")},${u.round}`;r.dashDependencies[h]=o,r.dashDependencies[c]=l,r.dashDependencies[d]=u,t.dashes[a.id]={min:h,mid:c,max:d}}}};U("LineBucket",og,{omit:["layers","patternFeatures"]});let kS;const LS=()=>kS||(kS=new yt({"line-cap":new J(z.layout_line["line-cap"],"line-cap"),"line-join":new J(z.layout_line["line-join"],"line-join"),"line-miter-limit":new J(z.layout_line["line-miter-limit"],"line-miter-limit"),"line-round-limit":new J(z.layout_line["line-round-limit"],"line-round-limit"),"line-sort-key":new J(z.layout_line["line-sort-key"],"line-sort-key")}));let BS;const $S=()=>BS||(BS=new yt({"line-opacity":new J(z.paint_line["line-opacity"],"line-opacity"),"line-layer-opacity":new j(z.paint_line["line-layer-opacity"],"line-layer-opacity"),"line-color":new J(z.paint_line["line-color"],"line-color"),"line-translate":new j(z.paint_line["line-translate"],"line-translate"),"line-translate-anchor":new j(z.paint_line["line-translate-anchor"],"line-translate-anchor"),"line-width":new J(z.paint_line["line-width"],"line-width"),"line-gap-width":new J(z.paint_line["line-gap-width"],"line-gap-width"),"line-offset":new J(z.paint_line["line-offset"],"line-offset"),"line-blur":new J(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 wo(z.paint_line["line-gradient"],"line-gradient")}));var lg={get paint(){return $S()},get layout(){return LS()}},OS=class extends J{possiblyEvaluate(e,t){return t=new be(Math.floor(t.zoom),{now:t.now,fadeDuration:t.fadeDuration,zoomHistory:t.zoomHistory,transition:t.transition}),super.possiblyEvaluate(e,t)}evaluate(e,t,i,r){return t=Z({},t,{zoom:Math.floor(t.zoom)}),super.evaluate(e,t,i,r)}};let Bo;const NS=e=>e.type==="line";var VS=class extends Pi{constructor(e,t){super(e,lg,t),this.gradientVersion=0,Bo||(Bo=new OS(lg.paint.properties["line-width"].specification,"line-floorwidth"),Bo.useIntegerZoom=!0)}_handleSpecialPaintPropertyUpdate(e){if(e==="line-gradient"){let t=this.gradientExpression();this.stepInterpolant=vw(t)?t._styleExpression.expression instanceof mu:!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"]=Bo.possiblyEvaluate(this._transitioningPaint._values["line-width"].value,e)}createBucket(e){return new og(e)}queryRadius(e){let t=e,i=ug(Na("line-width",this,t),Na("line-gap-width",this,t)),r=Na("line-offset",this,t);return i/2+Math.abs(r)+Ao(this.paint.get("line-translate"))}queryIntersectsFeature({queryGeometry:e,feature:t,featureState:i,geometry:r,transform:a,pixelsToTileUnits:n}){let s=Do(e,this.paint.get("line-translate"),this.paint.get("line-translate-anchor"),-a.bearingInRadians,n),o=n/2*ug(this.paint.get("line-width").evaluate(t,i),this.paint.get("line-gap-width").evaluate(t,i)),l=this.paint.get("line-offset").evaluate(t,i);return l&&(r=W2(r,l*n)),V2(s,r,o)}isTileClipped(){return!0}};function ug(e,t){return t>0?t+2*e:e}const jS=We([{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),US=We([{name:"a_projected_pos",components:3,type:"Float32"}],4);We([{name:"a_fade_opacity",components:1,type:"Uint32"}],4);const GS=We([{name:"a_placed",components:2,type:"Uint8"},{name:"a_shift",components:2,type:"Float32"},{name:"a_box_real",components:2,type:"Int16"}]);We([{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 hg=We([{name:"a_pos",components:2,type:"Int16"},{name:"a_anchor_pos",components:2,type:"Int16"},{name:"a_extrude",components:2,type:"Int16"}],4),ZS=We([{name:"a_pos",components:2,type:"Float32"},{name:"a_radius",components:1,type:"Float32"},{name:"a_flags",components:2,type:"Int16"}],4);We([{name:"triangle",components:3,type:"Uint16"}]),We([{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"}]),We([{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"}]),We([{type:"Float32",name:"offsetX"}]),We([{type:"Int16",name:"x"},{type:"Int16",name:"y"},{type:"Int16",name:"tileUnitDistanceFromAnchor"}]),We([{type:"Uint16",name:"textAnchor"},{type:"Float32",components:2,name:"textOffset"}]);function qS(e,t,i){let r=t.layout.get("text-transform").evaluate(i,{});return r==="uppercase"?e=e.toLocaleUpperCase():r==="lowercase"&&(e=e.toLocaleLowerCase()),Xr.applyArabicShaping&&(e=Xr.applyArabicShaping(e)),e}function WS(e,t,i){for(let r of e.sections)r.text=qS(r.text,t,i);return e}function HS(e){let t={},i={},r=[],a=0;function n(u){r.push(e[u]),a++}function s(u,h,c){let d=i[u];return delete i[u],i[h]=d,r[d].geometry[0].pop(),r[d].geometry[0]=r[d].geometry[0].concat(c[0]),d}function o(u,h,c){let d=t[h];return delete t[h],t[u]=d,r[d].geometry[0].shift(),r[d].geometry[0]=c[0].concat(r[d].geometry[0]),d}function l(u,h,c){let d=c?h[0][h[0].length-1]:h[0][0];return`${u}:${d.x}:${d.y}`}for(let u=0;u<e.length;u++){let h=e[u],c=h.geometry,d=h.text?h.text.toString():null;if(!d){n(u);continue}let p=l(d,c),f=l(d,c,!0);if(p in i&&f in t&&i[p]!==t[f]){let m=o(p,f,c),g=s(p,f,r[m].geometry);delete t[p],delete i[f],i[l(d,r[g].geometry,!0)]=g,r[m].geometry=null}else p in i?s(p,f,c):f in t?o(p,f,c):(n(u),t[p]=a-1,i[f]=a-1)}return r.filter(u=>u.geometry)}const cg=typeof Intl<"u"&&"Segmenter"in Intl;let dg,pg;function fg(e){if(!cg||!e2(e))return[...e];dg??(dg=new Intl.Segmenter(void 0,{granularity:"grapheme"}));let t=[];for(let{segment:i}of dg.segment(e)){let r=t.length-1;r>=0&&t2(t[r],i)?t[r]+=i:t.push(i)}return t}function XS(e){let t=new Set;if(cg){pg??(pg=new Intl.Segmenter(void 0,{granularity:"word"}));for(let{index:r}of pg.segment(e))t.add(r);return t}let i=0;for(let r of e.split(new RegExp("\\b|(?=\\p{Ideo})","u")))t.add(i),i+=r.length;return t}function $o(e){let t=e.codePointAt(0);return e.length>(t>65535?2:1)}const Ua={"!":"︕","#":"#",$:"$","%":"%","&":"&","(":"︵",")":"︶","*":"*","+":"+",",":"︐","-":"︲",".":"・","/":"/",":":"︓",";":"︔","<":"︿","=":"=",">":"﹀","?":"︖","@":"@","[":"﹇","\\":"\","]":"﹈","^":"^",_:"︳","`":"`","{":"︷","|":"―","}":"︸","~":"~","¢":"¢","£":"£","¥":"¥","¦":"¦","¬":"¬","¯":" ̄","–":"︲","—":"︱","‘":"﹃","’":"﹄","“":"﹁","”":"﹂","…":"︙","⋯":"︙","‧":"・","₩":"₩","、":"︑","。":"︒","〈":"︿","〉":"﹀","《":"︽","》":"︾","「":"﹁","」":"﹂","『":"﹃","』":"﹄","【":"︻","】":"︼","〔":"︹","〕":"︺","〖":"︗","〗":"︘","!":"︕","(":"︵",")":"︶",",":"︐","-":"︲",".":"・",":":"︓",";":"︔","<":"︿",">":"﹀","?":"︖","[":"﹇","]":"﹈","_":"︳","{":"︷","|":"―","}":"︸","⦅":"︵","⦆":"︶","。":"︒","「":"﹁","」":"﹂"};function YS(e){let t="",i={premature:!0,value:void 0},r=e[Symbol.iterator](),a=r.next(),n=e[Symbol.iterator]();n.next();let s=n.next();for(;!a.done;)(s.done||!Yf(s.value.codePointAt(0))||Ua[s.value])&&(i.premature||!Yf(i.value.codePointAt(0))||Ua[i.value])&&Ua[a.value]?t+=Ua[a.value]:t+=a.value,i={value:a.value,premature:!1},a=r.next(),s=n.next();return t}const KS={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},JS={40:!0};function mg(e,t,i,r,a,n){if("fontStack"in t){let s=i[t.fontStack],o=s==null?void 0:s[e];if(o)return o.metrics.advance*t.scale+a;let l=0;for(let u of e){let h=s==null?void 0:s[u];h&&(l+=h.metrics.advance*t.scale+a)}return l}{let s=r[t.imageName];return s?s.displaySize[0]*t.scale*24/n+a:0}}function gg(e,t,i,r){let a=(e-t)**2;return r?e<t?a/2:a*2:a+Math.abs(i)*i}function _g(e){return/^\s+$/u.test(e)}function QS(e,t,i){let r=0;return(e===10||e===13)&&(r-=1e4),i&&(r+=150),(e===40||e===65288)&&(r+=50),(t===41||t===65289)&&(r+=50),r}function yg(e,t,i,r,a,n){let s=null,o=gg(t,i,a,n);for(let l of r){let u=gg(t-l.x,i,a,n)+l.badness;u<=o&&(s=l,o=u)}return{index:e,x:t,priorBreak:s,badness:o}}function vg(e){return e?vg(e.priorBreak).concat(e.index):[]}var Gh=class Yd{constructor(t="",i=[],r=[]){this.text=t,this.sections=i,this.sectionIndex=r,this.imageSectionID=null,this._graphemes=null}graphemes(){return this._graphemes??(this._graphemes=fg(this.text)),this._graphemes}static fromFeature(t,i){let r=new Yd;for(let a of t.sections)a.image?r.addImageSection(a):r.addTextSection(a,i);return r}length(){return this.graphemes().length}getSection(t){return this.sections[this.sectionIndex[t]]}getSectionIndex(t){return this.sectionIndex[t]}verticalizePunctuation(){this.text=YS(this.text),this._graphemes=null}hasZeroWidthSpaces(){return this.text.includes("")}trim(){let t=this.graphemes(),i=0;for(;i<t.length&&_g(t[i]);)i++;let r=t.length;for(;r>i&&_g(t[r-1]);)r--;this.text=t.slice(i,r).join(""),this.sectionIndex=this.sectionIndex.slice(i,r),this._graphemes=null}substring(t,i){let r=this.graphemes().slice(t,i).join(""),a=this.sectionIndex.slice(t,i);return new Yd(r,this.sections,a)}toCodeUnitIndex(t){return this.graphemes().slice(0,t).join("").length}toString(){return this.text}getMaxScale(){return this.sectionIndex.reduce((t,i)=>Math.max(t,this.sections[i].scale),0)}getMaxImageSize(t){let i=0,r=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;i=Math.max(i,o[0]),r=Math.max(r,o[1])}}return{maxImageWidth:i,maxImageHeight:r}}_appendSection(t,i){let r=this.graphemes(),a=r.length>0?r[r.length-1]:"",n=fg(a+t);this.text+=t,this._graphemes=r.slice(0,a?-1:void 0).concat(n);let s=n.length-+!!a;for(let o=0;o<s;o++)this.sectionIndex.push(i)}addTextSection(t,i){this.sections.push({scale:t.scale||1,verticalAlign:t.verticalAlign||"bottom",fontStack:t.fontStack||i}),this._appendSection(t.text,this.sections.length-1)}addImageSection(t){let i=t.image?t.image.name:"";if(i.length===0){le("Can't add FormattedSection with an empty image.");return}let r=this.getNextImageSectionCharCode();if(!r){le("Reached maximum number of images 6401");return}this.sections.push({scale:1,verticalAlign:t.verticalAlign||"bottom",imageName:i}),this._appendSection(String.fromCharCode(r),this.sections.length-1)}getNextImageSectionCharCode(){return this.imageSectionID?this.imageSectionID>=63743?null:++this.imageSectionID:(this.imageSectionID=57344,this.imageSectionID)}determineLineBreaks(t,i,r,a,n){let s=[],o=this.determineAverageLineWidth(t,i,r,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),_=Kw(m),y=Hf(m)&&Hf(g);(KS[m]||_||"imageName"in this.getSection(p-1)||u[p+1]!==void 0&&JS[g]||y&&(h??(h=XS(this.text))).has(d))&&s.push(yg(p,c,o,s,QS(m,g,_&&l),!1))}Zu(f.codePointAt(0))||(c+=mg(f,this.getSection(p),r,a,t,n)),d+=f.length}return vg(yg(this.length(),c,o,s,0,!0))}determineAverageLineWidth(t,i,r,a,n){let s=0,o=0;for(let u of this.graphemes()){let h=this.getSection(o);s+=mg(u,h,r,a,t,n),o++}let l=Math.max(1,Math.ceil(s/i));return s/l}};const xg=4294967296,bg=typeof TextDecoder>"u"?null:new TextDecoder("utf-8");var wg=class{constructor(e){this.buf=ArrayBuffer.isView(e)?e:new Uint8Array(e),this.dataView=new DataView(this.buf.buffer,this.buf.byteOffset,this.buf.byteLength),this.pos=0,this.type=0,this._valueStart=-1,this.length=this.buf.length}readFields(e,t,i=this.length){let r;for(;r=this.nextField(i);)e(r,t,this);return t}readMessage(e,t){return this.readFields(e,t,this.readVarint()+this.pos)}readFixed32(){let e=this.dataView.getUint32(this.pos,!0);return this.pos+=4,e}readSFixed32(){let e=this.dataView.getInt32(this.pos,!0);return this.pos+=4,e}readFixed64(){let e=this.dataView.getUint32(this.pos,!0)+this.dataView.getUint32(this.pos+4,!0)*xg;return this.pos+=8,e}readSFixed64(){let e=this.dataView.getUint32(this.pos,!0)+this.dataView.getInt32(this.pos+4,!0)*xg;return this.pos+=8,e}readFloat(){let e=this.dataView.getFloat32(this.pos,!0);return this.pos+=4,e}readDouble(){let e=this.dataView.getFloat64(this.pos,!0);return this.pos+=8,e}readVarint(e){let t=this.buf,i=t[this.pos++];if(i<128)return i;let r=i&127,a;return a=t[this.pos++],r|=(a&127)<<7,a<128||(a=t[this.pos++],r|=(a&127)<<14,a<128)||(a=t[this.pos++],r|=(a&127)<<21,a<128)?r:(a=t[this.pos],r|=(a&15)<<28,eE(r,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&&bg?bg.decode(this.buf.subarray(t,e)):iE(this.buf,t,e)}readBytes(){let e=this.readVarint()+this.pos,t=this.buf.subarray(this.pos,e);return this.pos=e,t}readPackedVarint(e=[],t){let i=this.readPackedEnd();for(;this.pos<i;)e.push(this.readVarint(t));return e}readPackedSVarint(e=[]){let t=this.readPackedEnd();for(;this.pos<t;)e.push(this.readSVarint());return e}readPackedBoolean(e=[]){let t=this.readPackedEnd();for(;this.pos<t;)e.push(this.readBoolean());return e}readPackedFloat(e=[]){let t=this.readPackedEnd();for(;this.pos<t;)e.push(this.readFloat());return e}readPackedDouble(e=[]){let t=this.readPackedEnd();for(;this.pos<t;)e.push(this.readDouble());return e}readPackedFixed32(e=[]){let t=this.readPackedEnd();for(;this.pos<t;)e.push(this.readFixed32());return e}readPackedSFixed32(e=[]){let t=this.readPackedEnd();for(;this.pos<t;)e.push(this.readSFixed32());return e}readPackedFixed64(e=[]){let t=this.readPackedEnd();for(;this.pos<t;)e.push(this.readFixed64());return e}readPackedSFixed64(e=[]){let t=this.readPackedEnd();for(;this.pos<t;)e.push(this.readSFixed64());return e}readPackedEnd(){return 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 eE(e,t,i){let r=i.buf,a,n;if(n=r[i.pos++],a=(n&112)>>4,n<128||(n=r[i.pos++],a|=(n&127)<<3,n<128)||(n=r[i.pos++],a|=(n&127)<<10,n<128)||(n=r[i.pos++],a|=(n&127)<<17,n<128)||(n=r[i.pos++],a|=(n&127)<<24,n<128)||(n=r[i.pos++],a|=(n&1)<<31,n<128))return tE(e,a,t);throw Error("Expected varint not more than 10 bytes")}function tE(e,t,i){return i?t*4294967296+(e>>>0):(t>>>0)*4294967296+(e>>>0)}function iE(e,t,i){let r="",a=t;for(;a<i;){let n=e[a],s=null,o=n>239?4:n>223?3:n>191?2:1;if(a+o>i)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,r+=String.fromCharCode(s>>>10&1023|55296),s=56320|s&1023),r+=String.fromCharCode(s),a+=o}return r}function rE(e,t,i){e===1&&i.readMessage(aE,t)}function aE(e,t,i){if(e===3){let{id:r,bitmap:a,width:n,height:s,left:o,top:l,advance:u}=i.readMessage(nE,{});t.push({id:r,bitmap:new Ah({width:n+6,height:s+6},a),metrics:{width:n,height:s,left:o,top:l,advance:u}})}}function nE(e,t,i){e===1?t.id=i.readVarint():e===2?t.bitmap=i.readBytes():e===3?t.width=i.readVarint():e===4?t.height=i.readVarint():e===5?t.left=i.readSVarint():e===6?t.top=i.readSVarint():e===7&&(t.advance=i.readVarint())}function sE(e){return new wg(e).readFields(rE,[])}function Oo(e){return typeof(e==null?void 0:e.renderWithWebGL)=="function"}function oE(e){let{userImage:t}=e;return!(t!=null&&t.render)||!t.render()?!1:(Oo(t.data)||e.data.replace(new Uint8Array(t.data.buffer)),!0)}function Tg(e){let t=0,i=0;for(let s of e)t+=s.w*s.h,i=Math.max(i,s.w);e.sort((s,o)=>o.h-s.h);let r=[{x:0,y:0,w:Math.max(Math.ceil(Math.sqrt(t/.95)),i),h:1/0}],a=0,n=0;for(let s of e)for(let o=r.length-1;o>=0;o--){let l=r[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=r.pop();u&&o<r.length&&(r[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):(r.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 Zh=class{constructor(e,{pixelRatio:t,version:i,isWebGLImage:r=!1,stretchX:a,stretchY:n,content:s,textFitWidth:o,textFitHeight:l}){this.paddedRect=e,this.pixelRatio=t,this.stretchX=a,this.stretchY=n,this.content=s,this.version=i,this.needsFirstWebGLRender=r,this.textFitWidth=o,this.textFitHeight=l}get tl(){return[this.paddedRect.x+1,this.paddedRect.y+1]}get br(){return[this.paddedRect.x+this.paddedRect.w-1,this.paddedRect.y+this.paddedRect.h-1]}get tlbr(){return this.tl.concat(this.br)}get displaySize(){return[(this.paddedRect.w-2)/this.pixelRatio,(this.paddedRect.h-2)/this.pixelRatio]}},lE=class{constructor(e,t){let i={},r={};this.haveRenderCallbacks=[],this.patchedUpdateVersion=-1;let a=[];this.addImages(e,i,a),this.addImages(t,r,a);let{w:n,h:s}=Tg(a),o=new Fe({width:n||1,height:s||1});for(let l in e){let u=e[l];if(u.isWebGLImage)continue;let h=i[l].paddedRect;Fe.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=r[l].paddedRect,c=h.x+1,d=h.y+1,p=u.data.width,f=u.data.height;Fe.copy(u.data,o,{x:0,y:0},{x:c,y:d},u.data),Fe.copy(u.data,o,{x:0,y:f-1},{x:c,y:d-1},{width:p,height:1}),Fe.copy(u.data,o,{x:0,y:0},{x:c,y:d+f},{width:p,height:1}),Fe.copy(u.data,o,{x:p-1,y:0},{x:c-1,y:d},{width:1,height:f}),Fe.copy(u.data,o,{x:0,y:0},{x:c+p,y:d},{width:1,height:f})}this.image=o,this.iconPositions=i,this.patternPositions=r}addImages(e,t,i){for(let r in e){let a=e[r],n={x:0,y:0,w:a.data.width+2,h:a.data.height+2};i.push(n),t[r]=new Zh(n,a),a.hasRenderCallback&&this.haveRenderCallbacks.push(r)}}patchUpdatedImages(e,t){if(e.dispatchRenderCallbacks(this.haveRenderCallbacks),this.patchedUpdateVersion!==e.updateVersion){this.patchedUpdateVersion=e.updateVersion;for(let i in this.iconPositions)this.patchUpdatedImage(this.iconPositions[i],e.getImage(i),t);for(let i in this.patternPositions)this.patchUpdatedImage(this.patternPositions[i],e.getImage(i),t)}}patchUpdatedImage(e,t,i){var l;if(!e||!t||!e.needsFirstWebGLRender&&e.version===t.version)return;e.needsFirstWebGLRender=!1,e.version=t.version;let[r,a]=e.tl,n=(l=t.userImage)==null?void 0:l.data;if(!Oo(n)){i.update(t.data,void 0,{x:r,y:a});return}let{width:s,height:o}=t.data;i.context.setCustomLayerDefaults(),n.renderWithWebGL({gl:i.context.gl,texture:i.texture,x:r,y:a,width:s,height:o}),i.context.setDirty()}};U("ImagePosition",Zh),U("ImageAtlas",lE);var Sg=(function(e){return e[e.none=0]="none",e[e.horizontal=1]="horizontal",e[e.vertical=2]="vertical",e[e.horizontalOnly=3]="horizontalOnly",e})(Sg||{});function uE(e){for(let t of e)if(t.positionedGlyphs.length!==0)return!1;return!0}function hE(e,t){let i=[],r=0;for(let a of t)i.push(e.substring(r,a)),r=a;return r<e.length()&&i.push(e.substring(r,e.length())),i}const Eg=new RegExp("^\\p{gc=M}$","u");function cE(e){let t=[],i=0;for(;i<e.length;){if(!Eg.test(e[i])){t.push(i),i++;continue}let r=i;for(;r<e.length&&Eg.test(e[r]);)r++;let a=e[r];if(a!==void 0&&Wu(a.codePointAt(0))){t.push(r);for(let n=r-1;n>=i;n--)t.push(n);i=r+1}else{for(let n=i;n<r;n++)t.push(n);i=r}}return t}function dE(e){let t=[],i=0;for(let r of e.graphemes())t.push(...Array(r.length).fill(e.sectionIndex[i])),i++;return t}function Pg(e,t,i){let r=[...e],a=[],n=0;for(let h of r)a.push(n),n+=h.length;let s=cE(r),o=new Gh(s.map(h=>r[h]).join(""),t,[]),l=s.map(h=>i[a[h]]??0),u=0;for(let h of o.graphemes())o.sectionIndex.push(l[u]??0),u+=[...h].length;return o}function No(e,t,i,r,a,n,s,o,l,u,h,c,d,p,f){let m=Gh.fromFeature(e,a);c===2&&m.verticalizePunctuation();let g,_=m.determineLineBreaks(u,n,t,r,p),{processBidirectionalText:y,processStyledBidirectionalText:x}=Xr;if(y&&m.sections.length===1){g=[],_=_.map(T=>m.toCodeUnitIndex(T));let b=y(m.toString(),_);for(let T of b)g.push(Pg(T,m.sections,[...T].map(()=>0)))}else if(x){g=[],_=_.map(P=>m.toCodeUnitIndex(P));let b=dE(m),T=x(m.text,b,_);for(let P of T)g.push(Pg(P[0],m.sections,P[1]))}else g=hE(m,_);let v=[],w={positionedLines:v,text:m.toString(),top:h[1],bottom:h[1],left:h[0],right:h[0],writingMode:c,iconsInText:!1,verticalizable:!1};return bE(w,t,i,r,g,s,o,l,c,u,d,f),!uE(v)&&w}function Vo(e){let t=.5,i=.5;switch(e){case"right":case"top-right":case"bottom-right":t=1;break;case"left":case"top-left":case"bottom-left":t=0}switch(e){case"bottom":case"bottom-right":case"bottom-left":i=1;break;case"top":case"top-right":case"top-left":i=0}return{horizontalAlign:t,verticalAlign:i}}function pE(e,t,i){let r=t.getMaxScale()*24,{maxImageWidth:a,maxImageHeight:n}=t.getMaxImageSize(e),s=Math.max(r,n*i);return{verticalLineContentWidth:Math.max(r,a*i),horizontalLineContentHeight:s}}function Cg(e){switch(e){case"top":return 0;case"center":return .5;default:return 1}}function fE(e,t,i,r){var n;if(e!=null&&e.rect)return e;let a=(n=t[i.fontStack])==null?void 0:n[r];return a?{rect:null,metrics:a.metrics}:null}function mE(e,t,i){return!(e===1||!t&&!yo(i)||t&&(Zu(i)||Kf(i)))}function jo(e){return new RegExp("\\p{Nd}","u").test(String.fromCodePoint(e))}function Ag(e){return new RegExp("\\p{Lu}","u").test(String.fromCodePoint(e))}function gE(e){return/[\p{P}\p{S}]/u.test(String.fromCodePoint(e))}function _E(e){let t=e.some(jo)&&e.every(r=>jo(r)||gE(r)),i=e.length<=3&&e.every(r=>Ag(r)||jo(r));return t||i}function yE(e){return(jo(e)||Ag(e))&&!Kf(e)}function vE(e,t){let i=!1;for(let r=0;r<e.length;r++){if(t[r])continue;let a=Ua[e[r]];a&&(r===0||t[r-1])&&(r===e.length-1||t[r+1])&&(e[r]=a,t[r]=!0,i=!0)}return i}function xE(e){let t=e.graphemes().slice(),i=t.map(n=>n.codePointAt(0)),r=i.map(yo),a=n=>!r[n]&&!Zu(i[n])&&!("imageName"in e.getSection(n));for(let n=0;n<i.length;n++){if(!a(n))continue;let s=n;for(;s+1<i.length&&a(s+1);)s++;if(_E(i.slice(n,s+1)))for(let o=n;o<=s;o++)r[o]=yE(i[o]);n=s}return vE(t,r)&&(e.text=t.join(""),e._graphemes=null),r}function bE(e,t,i,r,a,n,s,o,l,u,h,c){var w;let d=0,p=0,f=0,m=0,g=o==="right"?1:o==="left"?0:.5,_=24/c,y=0;for(let b of a){b.trim();let T=b.getMaxScale(),P={positionedGlyphs:[],lineOffset:0};e.positionedLines[y]=P;let S=P.positionedGlyphs,M=0;if(!b.length()){p+=n,++y;continue}let F=pE(r,b,_),R=l===2&&!h?xE(b):null,I=b.graphemes();for(let A=0;A<I.length;A++){let B=b.getSection(A),N=I[A],O=N.codePointAt(0),H=R?R[A]:mE(l,h,O),ue="fontStack"in B&&$o(N)&&!((w=t[B.fontStack])!=null&&w[N])?[...N]:[N];for(let Ae of ue){let ne={glyph:Ae.codePointAt(0),grapheme:Ae,imageName:null,x:d,y:p+-17,vertical:H,scale:1,fontStack:"",sectionIndex:b.getSectionIndex(A),metrics:null,rect:null},Ce;if("fontStack"in B){if(Ce=wE(B,Ae,H,F,t,i),!Ce)continue;ne.fontStack=B.fontStack}else{if(e.iconsInText=!0,B.scale*=_,Ce=TE(B,H,T,F,r),!Ce)continue;M=Math.max(M,Ce.imageOffset),ne.imageName=B.imageName}let{rect:_e,metrics:Ie,baselineOffset:Me}=Ce;if(ne.y+=Me,ne.scale=B.scale,ne.metrics=Ie,ne.rect=_e,S.push(ne),!H)d+=Ie.advance*B.scale+u;else{e.verticalizable=!0;let ct="imageName"in B?Ie.advance:24;d+=ct*B.scale+u}}}if(S.length!==0){let A=d-u;f=Math.max(A,f),SE(S,0,S.length-1,g)}d=0;let D=(T-1)*24;P.lineOffset=Math.max(M,D);let E=n*T+M;p+=E,m=Math.max(E,m),++y}let{horizontalAlign:x,verticalAlign:v}=Vo(s);EE(e.positionedLines,g,x,v,f,m,n,p,a.length),e.top+=-v*p,e.bottom=e.top+p,e.left+=-x*f,e.right=e.left+f}function wE(e,t,i,r,a,n){var u;let s=(u=n[e.fontStack])==null?void 0:u[t],o=fE(s,a,e,t);if(o===null)return null;let l;if(i)l=r.verticalLineContentWidth-e.scale*24;else{let h=Cg(e.verticalAlign);l=(r.horizontalLineContentHeight-e.scale*24)*h}return{rect:o.rect,metrics:o.metrics,baselineOffset:l}}function TE(e,t,i,r,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=r.verticalLineContentWidth-o[1]*e.scale;else{let c=Cg(e.verticalAlign);u=(r.horizontalLineContentHeight-o[1]*e.scale)*c}let h=(t?o[0]:o[1])*e.scale-24*i;return{rect:s,metrics:l,baselineOffset:u,imageOffset:h}}function SE(e,t,i,r){if(r===0)return;let a=e[i],n=a.metrics.advance*a.scale,s=(e[i].x+n)*r;for(let o=t;o<=i;o++)e[o].x-=s}function EE(e,t,i,r,a,n,s,o,l){let u=(t-i)*a,h=0;h=n===s?-r*l*s+.5*s:-o*r- -17;for(let c of e)for(let d of c.positionedGlyphs)d.x+=u,d.y+=h}function PE(e,t,i){let{horizontalAlign:r,verticalAlign:a}=Vo(i),n=t[0],s=t[1],o=n-e.displaySize[0]*r,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 Dg(e){let t=e.left,i=e.top,r=e.right-t,a=e.bottom-i,n=e.image.content[2]-e.image.content[0],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"&&r/a<u||o==="proportional"){let h=Math.ceil(a*u);t*=h/r,r=h}}else if(o==="proportional"&&l==="stretchOnly"&&u!==0&&r/a>u){let h=Math.ceil(r/u);i*=h/a,a=h}return{x1:t,y1:i,x2:t+r,y2:i+a}}function Ig(e,t,i,r,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;i==="width"||i==="both"?(p=a[0]+l-r[3],c=a[0]+u+r[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 i==="height"||i==="both"?(h=a[1]+f-r[0],d=a[1]+m+r[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 Mg=32640;function zg(e,t){let{expression:i}=t;if(i.kind==="constant")return{kind:"constant",layoutSize:i.evaluate(new be(e+1))};if(i.kind==="source")return{kind:"source"};if(i.kind==="composite"){let{minZoom:r,maxZoom:a}=CE(i.zoomStops,e);return{kind:"composite",minZoom:r,maxZoom:a,interpolationType:i.interpolationType}}{let r=AE(i),a=i.evaluate(new be(e+1));return{kind:"camera",zoomStops:i.zoomStops,sizes:r,layoutSize:a,interpolationType:i.interpolationType}}}function CE(e,t){let i=0;for(;i<e.length&&e[i]<=t;)i++;i=Math.max(0,i-1);let r=i;for(;r<e.length&&e[r]<t+1;)r++;return r=Math.min(e.length-1,r),{minZoom:e[i],maxZoom:e[r]}}function AE(e){return e.zoomStops.map(t=>e.evaluate(new be(t===-1/0?e.zoomStops[1]-1:t)))}function qh(e,{uSize:t,uSizeT:i},{lowerSize:r,upperSize:a}){return e.kind==="source"?r/128:e.kind==="composite"?Oe.number(r/128,a/128,i):t}function Uo(e,t){let i=0,r=0;return e.kind==="constant"?r=e.layoutSize:e.kind==="camera"?r=DE(e,t):e.kind==="composite"&&(i=IE(e,t)),{uSizeT:i,uSize:r}}function DE({zoomStops:e,sizes:t,layoutSize:i,interpolationType:r},a){let n=e.length-1;for(;n>0&&e[n]>a;)n--;let s=Math.min(n+1,e.length-1),o=r?ee(pi.interpolationFactor(r,a,e[n],e[s]),0,1):0;return Math.min(Oe.number(t[n],t[s],o),i)}function IE({interpolationType:e,minZoom:t,maxZoom:i},r){return e?ee(pi.interpolationFactor(e,r,t,i),0,1):0}var Ga=class z1 extends C{constructor(t,i,r,a){super(t,i),this.angle=r,a!==void 0&&(this.segment=a)}clone(){return new z1(this.x,this.y,this.angle,this.segment)}};U("Anchor",Ga);function Fg(e,t,i,r,a){if(t.segment===void 0||i===0)return!0;let n=t,s=t.segment+1,o=0;for(;o>-i/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<i/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>r;)u-=l.shift().angleDelta;if(u>a)return!1;s++,o+=c.dist(d)}return!0}function Rg(e){let t=0;for(let i=0;i<e.length-1;i++)t+=e[i].dist(e[i+1]);return t}function kg(e,t,i){return e?3/5*t*i:0}function Lg(e,t){return Math.max(e?e.right-e.left:0,t?t.right-t.left:0)}function ME(e,t,i,r,a,n){let s=kg(i,a,n),o=Lg(i,r)*n,l=0,u=Rg(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 Ga(Oe.number(c.x,d.x,f),Oe.number(c.y,d.y,f),d.angleTo(c),h);return m._round(),!s||Fg(e,m,o,s,t)?m:void 0}l+=p}}function zE(e,t,i,r,a,n,s,o,l){let u=kg(r,n,s),h=Lg(r,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 Bg(e,d?t/2*o%t:(h/2+p)*s*o%t,t,u,i,c,d,!1,l)}function Bg(e,t,i,r,a,n,s,o,l){let u=n/2,h=Rg(e),c=0,d=t-i,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+i<c+_;){d+=i;let x=(d-c)/_,v=Oe.number(m.x,g.x,x),w=Oe.number(m.y,g.y,x);if(v>=0&&v<l&&w>=0&&w<l&&d-u>=0&&d+u<=h){let b=new Ga(v,w,y,f);b._round(),(!r||Fg(e,b,n,r,a))&&p.push(b)}}c+=_}return!o&&!p.length&&!s&&(p=Bg(e,c/2,i,r,a,n,s,!0,l)),p}function $g(e,t,i,r,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 C(t,u.y+(h.y-u.y)*((t-u.x)/(h.x-u.x)))._round():h.x<t&&(h=new C(t,u.y+(h.y-u.y)*((t-u.x)/(h.x-u.x)))._round()),!(u.y<i&&h.y<i)&&(u.y<i?u=new C(u.x+(h.x-u.x)*((i-u.y)/(h.y-u.y)),i)._round():h.y<i&&(h=new C(u.x+(h.x-u.x)*((i-u.y)/(h.y-u.y)),i)._round()),!(u.x>=r&&h.x>=r)&&(u.x>=r?u=new C(r,u.y+(h.y-u.y)*((r-u.x)/(h.x-u.x)))._round():h.x>=r&&(h=new C(r,u.y+(h.y-u.y)*((r-u.x)/(h.x-u.x)))._round()),!(u.y>=a&&h.y>=a)&&(u.y>=a?u=new C(u.x+(h.x-u.x)*((a-u.y)/(h.y-u.y)),a)._round():h.y>=a&&(h=new C(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 Og(e,t,i,r){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=(D,E)=>D+E[1]-E[0],p=h.reduce(d,0),f=c.reduce(d,0),m=o-p,g=l-f,_=0,y=p,x=0,v=f,w=0,b=m,T=0,P=g;if(n.content&&r){let D=n.content,E=D[2]-D[0],A=D[3]-D[1];(n.textFitWidth||n.textFitHeight)&&(u=Dg(e)),_=Go(h,0,D[0]),x=Go(c,0,D[1]),y=Go(h,D[0],D[2]),v=Go(c,D[1],D[3]),w=D[0]-_,T=D[1]-x,b=E-y,P=A-v}let S=u.x1,M=u.y1,F=u.x2-S,R=u.y2-M,I=(D,E,A,B)=>{let N=Zo(D.stretch-_,y,F,S),O=qo(D.fixed-w,b,D.stretch,p),H=Zo(E.stretch-x,v,R,M),ue=qo(E.fixed-T,P,E.stretch,f),Ae=Zo(A.stretch-_,y,F,S),ne=qo(A.fixed-w,b,A.stretch,p),Ce=Zo(B.stretch-x,v,R,M),_e=qo(B.fixed-T,P,B.stretch,f),Ie=new C(N,H),Me=new C(Ae,H),ct=new C(Ae,Ce),Mt=new C(N,Ce),Fi=new C(O/s,ue/s),Ut=new C(ne/s,_e/s),Ue=t*Math.PI/180;if(Ue){let Xi=Math.sin(Ue),Ye=Math.cos(Ue),Ge=[Ye,-Xi,Xi,Ye];Ie._matMult(Ge),Me._matMult(Ge),Mt._matMult(Ge),ct._matMult(Ge)}let wt=D.stretch+D.fixed,Lr=A.stretch+A.fixed,Br=E.stretch+E.fixed,va=B.stretch+B.fixed;return{tl:Ie,tr:Me,bl:Mt,br:ct,tex:{x:n.paddedRect.x+1+wt,y:n.paddedRect.y+1+Br,w:Lr-wt,h:va-Br},writingMode:void 0,glyphOffset:[0,0],sectionIndex:0,pixelOffsetTL:Fi,pixelOffsetBR:Ut,minFontScaleX:b/s/F,minFontScaleY:P/s/R,isSDF:i}};if(!r||!n.stretchX&&!n.stretchY)a.push(I({fixed:0,stretch:-1},{fixed:0,stretch:-1},{fixed:0,stretch:o+1},{fixed:0,stretch:l+1}));else{let D=Ng(h,m,p),E=Ng(c,g,f);for(let A=0;A<D.length-1;A++){let B=D[A],N=D[A+1];for(let O=0;O<E.length-1;O++){let H=E[O],ue=E[O+1];a.push(I(B,H,N,ue))}}}return a}function Go(e,t,i){let r=0;for(let a of e)r+=Math.max(t,Math.min(i,a[1]))-Math.max(t,Math.min(i,a[0]));return r}function Ng(e,t,i){let r=[{fixed:-1,stretch:0}];for(let[a,n]of e){let s=r[r.length-1];r.push({fixed:a-s.stretch,stretch:s.stretch}),r.push({fixed:a-s.stretch,stretch:s.stretch+(n-a)})}return r.push({fixed:t+1,stretch:i}),r}function Zo(e,t,i,r){return e/t*i+r}function qo(e,t,i,r){return e-t*i/r}function FE(e,t,i,r,a,n,s,o){let l=r.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 B=(c.scale-1)*24,N=(24-c.metrics.width*c.scale)/2;g=h.lineOffset/2-(c.imageName?-N:B)}if(c.imageName){let B=s[c.imageName];f=B.sdf,m=B.pixelRatio,p=1/m}let x=a?[c.x+y,c.y]:[0,0],v=a?[0,0]:[c.x+y+i[0],c.y+i[1]-g],w=[0,0];_&&(w=v,v=[0,0]);let b=c.metrics.isDoubleResolution?2:1,T=(c.metrics.left-p)*c.scale-y+v[0],P=(-c.metrics.top-p)*c.scale+v[1],S=T+d.w/b*c.scale/m,M=P+d.h/b*c.scale/m,F=new C(T,P),R=new C(S,P),I=new C(T,M),D=new C(S,M);if(_){let B=new C(-y,y- -17),N=-Math.PI/2,O=12-y,H=c.imageName?O:0,ue=new C(22-O,-H),Ae=new C(...w);F._rotateAround(N,B)._add(ue)._add(Ae),R._rotateAround(N,B)._add(ue)._add(Ae),I._rotateAround(N,B)._add(ue)._add(Ae),D._rotateAround(N,B)._add(ue)._add(Ae)}if(l){let B=Math.sin(l),N=Math.cos(l),O=[N,-B,B,N];F._matMult(O),R._matMult(O),I._matMult(O),D._matMult(O)}let E=new C(0,0),A=new C(0,0);u.push({tl:F,tr:R,bl:I,br:D,tex:d,writingMode:t.writingMode,glyphOffset:x,sectionIndex:c.sectionIndex,isSDF:f,pixelOffsetTL:E,pixelOffsetBR:A,minFontScaleX:0,minFontScaleY:0})}return u}var Wo=class{constructor(e,t,i,r,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)?Dg(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 C(c.x1,c.y1),f=new C(c.x2,c.y1),m=new C(c.x1,c.y2),g=new C(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,i,r,a)}this.boxEndIndex=e.length}},RE=class{constructor(e=[],t=(i,r)=>i<r?-1:+(i>r)){if(this.data=e,this.length=this.data.length,this.compare=t,this.length>0)for(let i=(this.length>>1)-1;i>=0;i--)this._down(i)}push(e){this.data.push(e),this._up(this.length++)}pop(){if(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:i}=this,r=t[e];for(;e>0;){let a=e-1>>1,n=t[a];if(i(r,n)>=0)break;t[e]=n,e=a}t[e]=r}_down(e){let{data:t,compare:i}=this,r=this.length>>1,a=t[e];for(;e<r;){let n=(e<<1)+1,s=n+1;if(s<this.length&&i(t[s],t[n])<0&&(n=s),i(t[n],a)>=0)break;t[e]=t[n],e=n}t[e]=a}};function kE(e,t=1){let i=Di.fromPoints(e[0]),r=Math.min(i.width(),i.height()),a=r/2,n=new RE([],LE),{minX:s,minY:o,maxX:l,maxY:u}=i;if(r===0)return new C(s,o);for(let d=s;d<l;d+=r)for(let p=o;p<u;p+=r)n.push(new Za(d+a,p+a,a,e));let h=$E(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 Za(d.p.x-a,d.p.y-a,a,e)),n.push(new Za(d.p.x+a,d.p.y-a,a,e)),n.push(new Za(d.p.x-a,d.p.y+a,a,e)),n.push(new Za(d.p.x+a,d.p.y+a,a,e)))}return h.d>0&&c.d-h.d<=t?h.p:c.p}function LE(e,t){return t.max-e.max}var Za=class{constructor(e,t,i,r){this.p=new C(e,t),this.h=i,this.d=BE(this.p,r),this.max=this.d+this.h*Math.SQRT2}};function BE(e,t){let i=!1,r=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&&(i=!i),r=Math.min(r,zm(e,l,u))}return(i?1:-1)*Math.sqrt(r)}function $E(e){let t=0,i=0,r=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;i+=(l.x+u.x)*h,r+=(l.y+u.y)*h,t+=h*3}return new Za(i/t,r/t,0,e)}let Wh=(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 Hh=1/0;function Vg(e,t){function i(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 r(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]===Hh?i(e,t[0]):r(e,t[0],t[1])}function jg(e,t,i){var s;let r=e.layout,a=(s=r.get("text-variable-anchor-offset"))==null?void 0:s.evaluate(t,{},i);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 Ni(l)}let n=r.get("text-variable-anchor");if(n){let o;o=e._unevaluatedLayout.getValue("text-radial-offset")===void 0?r.get("text-offset").evaluate(t,{},i).map(u=>u*24):[r.get("text-radial-offset").evaluate(t,{},i)*24,Hh];let l=[];for(let u of n)l.push(u,Vg(u,o));return new Ni(l)}return null}function OE(e){var h,c;e.bucket.createArrays();let t=512*e.bucket.overscaling;e.bucket.tilePixelRatio=k/t,e.bucket.compareText={},e.bucket.iconsNeedLinear=!1;let i=e.bucket.layers[0],r=i.layout,a=i._unevaluatedLayout._values,n={layoutIconSize:a["icon-size"].possiblyEvaluate(new be(e.bucket.zoom+1),e.canonical),layoutTextSize:a["text-size"].possiblyEvaluate(new be(e.bucket.zoom+1),e.canonical),textMaxSize:a["text-size"].possiblyEvaluate(new be(18))};if(e.bucket.textSizeData.kind==="composite"){let{minZoom:d,maxZoom:p}=e.bucket.textSizeData;n.compositeTextSizes=[a["text-size"].possiblyEvaluate(new be(d),e.canonical),a["text-size"].possiblyEvaluate(new be(p),e.canonical)]}if(e.bucket.iconSizeData.kind==="composite"){let{minZoom:d,maxZoom:p}=e.bucket.iconSizeData;n.compositeIconSizes=[a["icon-size"].possiblyEvaluate(new be(d),e.canonical),a["icon-size"].possiblyEvaluate(new be(p),e.canonical)]}let s=r.get("text-line-height")*24,o=r.get("text-rotation-alignment")!=="viewport"&&r.get("symbol-placement")!=="point",l=r.get("text-keep-upright"),u=r.get("text-size");for(let d of e.bucket.features){let p=r.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,x=[0,0];if(y){let T=y.toString(),P=r.get("text-letter-spacing").evaluate(d,{},e.canonical)*24,S=i2(T)?P:0,M=r.get("text-anchor").evaluate(d,{},e.canonical),F=jg(i,d,e.canonical);if(!F){let E=r.get("text-radial-offset").evaluate(d,{},e.canonical);x=E?Vg(M,[E*24,Hh]):r.get("text-offset").evaluate(d,{},e.canonical).map(A=>A*24)}let R=o?"center":r.get("text-justify").evaluate(d,{},e.canonical),I=r.get("symbol-placement")==="point"?r.get("text-max-width").evaluate(d,{},e.canonical)*24:1/0,D=()=>{e.bucket.allowVerticalPlacement&&qu(T)&&(_.vertical=No(y,e.glyphMap,e.glyphPositions,e.imagePositions,p,I,s,M,"left",S,x,2,!0,m,f))};if(!o&&F){let E=new Set;if(R==="auto")for(let B=0;B<F.values.length;B+=2)E.add(Xh(F.values[B]));else E.add(R);let A=!1;for(let B of E)if(!_.horizontal[B])if(A)_.horizontal[B]=_.horizontal[0];else{let N=No(y,e.glyphMap,e.glyphPositions,e.imagePositions,p,I,s,"center",B,S,x,1,!1,m,f);N&&(_.horizontal[B]=N,A=N.positionedLines.length===1)}D()}else{R==="auto"&&(R=Xh(M));let E=No(y,e.glyphMap,e.glyphPositions,e.imagePositions,p,I,s,M,R,S,x,1,!1,m,f);E&&(_.horizontal[R]=E),D(),qu(T)&&o&&l&&(_.vertical=No(y,e.glyphMap,e.glyphPositions,e.imagePositions,p,I,s,M,R,S,x,2,!1,m,f))}}let v,w=!1;if((h=d.icon)!=null&&h.name){let T=e.imageMap[d.icon.name];T&&(v=PE(e.imagePositions[d.icon.name],r.get("icon-offset").evaluate(d,{},e.canonical),r.get("icon-anchor").evaluate(d,{},e.canonical)),w=!!T.sdf,e.bucket.sdfIcons===void 0?e.bucket.sdfIcons=w:e.bucket.sdfIcons!==w&&le("Style sheet warning: Cannot mix SDF and non-SDF icons in one buffer"),T.pixelRatio===e.bucket.pixelRatio?r.get("icon-rotate").constantOr(1)!==0&&(e.bucket.iconsNeedLinear=!0):e.bucket.iconsNeedLinear=!0)}let b=Gg(_.horizontal)||_.vertical;(c=e.bucket).iconsInText||(c.iconsInText=b?b.iconsInText:!1),(b||v)&&NE(e.bucket,d,_,v,e.imageMap,n,m,g,x,w,e.canonical,e.subdivisionGranularity)}e.showCollisionBoxes&&e.bucket.generateCollisionDebugBuffers()}function Xh(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 NE(e,t,i,r,a,n,s,o,l,u,h,c){let d=n.textMaxSize.evaluate(t,{});d===void 0&&(d=s);let p=e.layers[0].layout,f=p.get("icon-offset").evaluate(t,{},h),m=Gg(i.horizontal),g=s/24,_=e.tilePixelRatio*g,y=e.tilePixelRatio*d/24,x=e.tilePixelRatio*o,v=e.tilePixelRatio*p.get("symbol-spacing"),w=p.get("text-padding")*e.tilePixelRatio,b=JE(p,t,h,e.tilePixelRatio),T=p.get("text-max-angle")/180*Math.PI,P=p.get("text-rotation-alignment")!=="viewport"&&p.get("symbol-placement")!=="point",S=p.get("icon-rotation-alignment").constantOr("viewport")==="map"&&p.get("symbol-placement")!=="point",M=p.get("symbol-placement"),F=v/2,R=p.get("icon-text-fit"),I;r&&R!=="none"&&(e.allowVerticalPlacement&&i.vertical&&(I=Ig(r,i.vertical,R,p.get("icon-text-fit-padding"),f,g)),m&&(r=Ig(r,m,R,p.get("icon-text-fit-padding"),f,g)));let D=h?c.line.getGranularityForZoomLevel(h.z):1,E=(A,B)=>{B.x<0||B.x>=8192||B.y<0||B.y>=8192||jE(e,B,A,i,r,a,I,e.layers[0],e.collisionBoxArray,t.index,t.sourceLayerIndex,e.index,_,[w,w,w,w],P,l,x,b,S,f,t,n,u,h,s)};if(M==="line")for(let A of $g(t.geometry,0,0,k,k)){let B=ia(A,D),N=zE(B,v,T,i.vertical||m,r,24,y,e.overscaling,k);for(let O of N){let H=m;(!H||!UE(e,H.text,F,O))&&E(B,O)}}else if(M==="line-center"){for(let A of t.geometry)if(A.length>1){let B=ia(A,D),N=ME(B,T,i.vertical||m,r,24,y);N&&E(B,N)}}else if(t.type==="Polygon")for(let A of Js(t.geometry,0)){let B=kE(A,16);E(ia(A[0],D,!0),new Ga(B.x,B.y,0))}else if(t.type==="LineString")for(let A of t.geometry){let B=ia(A,D);E(B,new Ga(B[0].x,B[0].y,0))}else if(t.type==="Point")for(let A of t.geometry)for(let B of A)E([B],new Ga(B.x,B.y,0))}function VE(e,t){let i=e.length,r=t==null?void 0:t.values;if((r==null?void 0:r.length)>0)for(let a=0;a<r.length;a+=2){let n=Wh[r[a]],s=r[a+1];e.emplaceBack(n,s[0],s[1])}return[i,e.length]}function Ug(e,t,i,r,a,n,s,o,l,u,h,c,d,p,f,m){let g=FE(t,i,o,a,n,s,r,e.allowVerticalPlacement),_=e.textSizeData,y=null;_.kind==="source"?(y=[128*a.layout.get("text-size").evaluate(s,{})],y[0]>32640&&le(`${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)&&le(`${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 x of c)d[x]=e.text.placedSymbolArray.length-1;return g.length*4}function Gg(e){for(let t in e)return e[t];return null}function jE(e,t,i,r,a,n,s,o,l,u,h,c,d,p,f,m,g,_,y,x,v,w,b,T,P){let S=e.addToLineVertexArray(t,i),M=o.layout.get("symbol-height-offset").evaluate(v,{},T);M>e.maxHeightOffset&&(e.maxHeightOffset=M);let F,R,I,D,E=0,A=0,B=0,N=0,O=-1,H=-1,ue={},Ae=(0,yh.default)("");if(e.allowVerticalPlacement&&r.vertical){let Ye=o.layout.get("text-rotate").evaluate(v,{},T)+90,Ge=r.vertical;I=new Wo(l,t,u,h,c,Ge,d,p,f,Ye),s&&(D=new Wo(l,t,u,h,c,s,g,_,f,Ye))}if(a){let Ye=o.layout.get("icon-rotate").evaluate(v,{}),Ge=o.layout.get("icon-text-fit")!=="none",Ft=Og(a,Ye,b,Ge),Yt=s?Og(s,Ye,b,Ge):void 0;R=new Wo(l,t,u,h,c,a,g,_,!1,Ye),E=Ft.length*4;let Yi=e.iconSizeData,Gt=null;Yi.kind==="source"?(Gt=[128*o.layout.get("icon-size").evaluate(v,{})],Gt[0]>32640&&le(`${e.layerIds[0]}: Value for "icon-size" is >= 255. Reduce your "icon-size".`)):Yi.kind==="composite"&&(Gt=[128*w.compositeIconSizes[0].evaluate(v,{},T),128*w.compositeIconSizes[1].evaluate(v,{},T)],(Gt[0]>32640||Gt[1]>32640)&&le(`${e.layerIds[0]}: Value for "icon-size" is >= 255. Reduce your "icon-size".`)),e.addSymbols(e.icon,Ft,Gt,x,y,v,0,t,S.lineStartIndex,S.lineLength,-1,T,M),O=e.icon.placedSymbolArray.length-1,Yt&&(A=Yt.length*4,e.addSymbols(e.icon,Yt,Gt,x,y,v,2,t,S.lineStartIndex,S.lineLength,-1,T,M),H=e.icon.placedSymbolArray.length-1)}let ne=Object.keys(r.horizontal);for(let Ye of ne){let Ge=r.horizontal[Ye];F||(F=(Ae=(0,yh.default)(Ge.text),new Wo(l,t,u,h,c,Ge,d,p,f,o.layout.get("text-rotate").evaluate(v,{},T))));let Ft=Ge.positionedLines.length===1;if(B+=Ug(e,t,Ge,n,o,f,v,m,M,S,r.vertical?1:3,Ft?ne:[Ye],ue,O,w,T),Ft)break}r.vertical&&(N+=Ug(e,t,r.vertical,n,o,f,v,m,M,S,2,["vertical"],ue,H,w,T));let Ce=F?F.boxStartIndex:e.collisionBoxArray.length,_e=F?F.boxEndIndex:e.collisionBoxArray.length,Ie=I?I.boxStartIndex:e.collisionBoxArray.length,Me=I?I.boxEndIndex:e.collisionBoxArray.length,ct=R?R.boxStartIndex:e.collisionBoxArray.length,Mt=R?R.boxEndIndex:e.collisionBoxArray.length,Fi=D?D.boxStartIndex:e.collisionBoxArray.length,Ut=D?D.boxEndIndex:e.collisionBoxArray.length,Ue=-1,wt=(Ye,Ge)=>Ye!=null&&Ye.circleDiameter?Math.max(Ye.circleDiameter,Ge):Ge;Ue=wt(F,Ue),Ue=wt(I,Ue),Ue=wt(R,Ue),Ue=wt(D,Ue);let Lr=+(Ue>-1);Lr&&(Ue*=P/24),e.glyphOffsetArray.length>=e.maxGlyphs&&le("Too many glyphs being rendered in a tile. See https://github.com/mapbox/mapbox-gl-js/issues/2907"),v.sortKey!==void 0&&e.addToSortKeyRanges(e.symbolInstances.length,v.sortKey);let Br=jg(o,v,T),[va,Xi]=VE(e.textAnchorOffsets,Br);e.symbolInstances.emplaceBack(t.x,t.y,ue.right>=0?ue.right:-1,ue.center>=0?ue.center:-1,ue.left>=0?ue.left:-1,ue.vertical||-1,O,H,Ae,Ce,_e,Ie,Me,ct,Mt,Fi,Ut,u,B,N,E,A,Lr,0,d,Ue,va,Xi,M)}function UE(e,t,i,r){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(r.dist(n[s])<i)return!0}return a[t].push(r),!1}function Ho(e,t,i){let r="never",a=e.get(t);return a?r=a:e.get(i)&&(r="always"),r}const GE=[{name:"a_fade_opacity",components:1,type:"Uint8",offset:0}];function Xo(e,t,i,r,a,n,s,o,l,u,h,c,d,p){let f=o?Math.min(Mg,Math.round(o[0])):0,m=o?Math.min(Mg,Math.round(o[1])):0;e.emplaceBack(t,i,Math.round(r*32),Math.round(a*32),n,s,(f<<1)+ +!!l,m,u*16,h*16,c*256,d*256,p)}function Yo(e,t,i){e.emplaceBack(t.x,t.y,i),e.emplaceBack(t.x,t.y,i),e.emplaceBack(t.x,t.y,i),e.emplaceBack(t.x,t.y,i)}function ZE(e){for(let t of e.sections)if(o2(t.text))return!0;return!1}var Yh=class{constructor(e){this.layoutVertexArray=new S2,this.indexArray=new Gi,this.programConfigurations=e,this.segments=new Ne,this.dynamicLayoutVertexArray=new E2,this.opacityVertexArray=new P2,this.hasVisibleVertices=!1,this.placedSymbolArray=new lm}isEmpty(){return this.layoutVertexArray.length===0&&this.indexArray.length===0&&this.dynamicLayoutVertexArray.length===0&&this.opacityVertexArray.length===0}upload(e,t,i,r){this.isEmpty()||(i&&(this.layoutVertexBuffer=e.createVertexBuffer(this.layoutVertexArray,jS.members),this.indexBuffer=e.createIndexBuffer(this.indexArray,t),this.dynamicLayoutVertexBuffer=e.createVertexBuffer(this.dynamicLayoutVertexArray,US.members,!0),this.opacityVertexBuffer=e.createVertexBuffer(this.opacityVertexArray,GE,!0),this.opacityVertexBuffer.itemSize=1),(i||r)&&this.programConfigurations.upload(e))}destroy(){this.layoutVertexBuffer&&(this.layoutVertexBuffer.destroy(),this.indexBuffer.destroy(),this.programConfigurations.destroy(),this.segments.destroy(),this.dynamicLayoutVertexBuffer.destroy(),this.opacityVertexBuffer.destroy())}};U("SymbolBuffers",Yh);var Kh=class{constructor(e,t,i){this.layoutVertexArray=new e,this.layoutAttributes=t,this.indexArray=new i,this.segments=new Ne,this.collisionVertexArray=new A2}upload(e){this.layoutVertexBuffer=e.createVertexBuffer(this.layoutVertexArray,this.layoutAttributes),this.indexBuffer=e.createIndexBuffer(this.indexArray),this.collisionVertexBuffer=e.createVertexBuffer(this.collisionVertexArray,GS.members,!0)}destroy(){this.layoutVertexBuffer&&(this.layoutVertexBuffer.destroy(),this.indexBuffer.destroy(),this.segments.destroy(),this.collisionVertexBuffer.destroy())}};U("CollisionBuffers",Kh);var Ko=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=zg(this.zoom,t["text-size"]),this.iconSizeData=zg(this.zoom,t["icon-size"]);let i=this.layers[0].layout,r=i.get("symbol-sort-key"),a=i.get("symbol-z-order");this.canOverlap=Ho(i,"text-overlap","text-allow-overlap")!=="never"||Ho(i,"icon-overlap","icon-allow-overlap")!=="never"||i.get("text-ignore-placement")||i.get("icon-ignore-placement"),this.sortFeaturesByKey=a!=="viewport-y"&&!r.isConstant();let n=a==="viewport-y"||a==="auto"&&!this.sortFeaturesByKey;this.sortFeaturesByY=n&&this.canOverlap,i.get("symbol-placement")==="point"&&(this.writingModes=i.get("text-writing-mode").map(s=>Sg[s])),this.stateDependentLayerIds=this.layers.filter(s=>s.isStateDependent()).map(s=>s.id),this.sourceID=e.sourceID}createArrays(){this.text=new Yh(new Kr(this.layers,this.zoom,e=>e.startsWith("text"))),this.icon=new Yh(new Kr(this.layers,this.zoom,e=>e.startsWith("icon"))),this.glyphOffsetArray=new cm,this.lineVertexArray=new dm,this.symbolInstances=new hm,this.textAnchorOffsets=new fm}calculateGlyphDependencies(e,t,i,r,a){var l;let n=(r||this.allowVerticalPlacement)&&a,s=Gh.fromFeature(e,i),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]={}),d=o[u];$o(d)&&(c[d]=!0);for(let p of d){if(c[p]=!0,!n)continue;let f=Ua[p];f&&(c[f]=!0)}}}populate(e,t,i){var m;let r=this.layers[0],a=r.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 Qi&&!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 be(this.zoom);for(let{feature:g,id:_,index:y,sourceLayerIndex:x}of e){let v=r._featureFilter.needGeometry,w=Qr(g,v);if(!r._featureFilter.filter(f,w,i))continue;v||(w.geometry=Jr(g));let b;if(l){let M=r.getValueAndResolveTokens("text-field",w,i,p),F=Qi.factory(M);this.hasRTLText||(this.hasRTLText=ZE(F)),(!this.hasRTLText||Xr.getRTLTextPluginStatus()==="unavailable"||this.hasRTLText&&Xr.isParsed())&&(b=WS(F,r,w))}let T;if(u){let M=r.getValueAndResolveTokens("icon-image",w,i,p);T=M instanceof Vi?M:Vi.fromString(M)}if(!b&&!T)continue;let P=this.sortFeaturesByKey?h.evaluate(w,{},i):void 0,S={id:_,text:b,icon:T,index:y,sourceLayerIndex:x,geometry:w.geometry,properties:g.properties,type:Kn.types[g.type],sortKey:P};if(this.features.push(S),T&&(c[T.name]=!0),b){let M=n.evaluate(w,{},i).join(","),F=a.get("text-rotation-alignment")!=="viewport"&&a.get("symbol-placement")!=="point";this.allowVerticalPlacement=(m=this.writingModes)==null?void 0:m.includes(2);let R=qu(b.toString());this.calculateGlyphDependencies(b,d,M,F,R);for(let I of b.sections)I.image&&(c[I.image.name]=!0)}}a.get("symbol-placement")==="line"&&(this.features=HS(this.features)),this.sortFeaturesByKey&&this.features.sort((g,_)=>g.sortKey-_.sortKey)}update(e,t,i){this.stateDependentLayers.length&&(this.text.programConfigurations.updatePaintArrays(e,t,this.layers,{imagePositions:i}),this.icon.programConfigurations.updatePaintArrays(e,t,this.layers,{imagePositions:i}))}addFeatures({options:e,canonical:t,glyphMap:i,glyphPositions:r,iconMap:a,iconPositions:n,showCollisionBoxes:s}){OE({bucket:this,glyphMap:i,glyphPositions:r,imageMap:a,imagePositions:n,showCollisionBoxes:s,canonical:t,subdivisionGranularity:e.subdivisionGranularity})}isEmpty(){return this.symbolInstances.length===0&&!this.hasRTLText}uploadPending(){return!this.uploaded||this.text.programConfigurations.needsUpload||this.icon.programConfigurations.needsUpload}upload(e){!this.uploaded&&this.hasDebugData()&&(this.textCollisionBox.upload(e),this.iconCollisionBox.upload(e)),this.text.upload(e,this.sortFeaturesByY,!this.uploaded,this.text.programConfigurations.needsUpload),this.icon.upload(e,this.sortFeaturesByY,!this.uploaded,this.icon.programConfigurations.needsUpload),this.uploaded=!0}destroyDebugData(){this.textCollisionBox.destroy(),this.iconCollisionBox.destroy()}destroy(){this.text.destroy(),this.icon.destroy(),this.hasDebugData()&&this.destroyDebugData()}addToLineVertexArray(e,t){let i=this.lineVertexArray.length;if(e.segment!==void 0){let r=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:r},s<t.length-1&&(r+=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:i,lineLength:this.lineVertexArray.length-i}}addSymbols(e,t,i,r,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,x=n.text&&n.text.sections;for(let v=0;v<t.length;v++){let{tl:w,tr:b,bl:T,br:P,tex:S,pixelOffsetTL:M,pixelOffsetBR:F,minFontScaleX:R,minFontScaleY:I,glyphOffset:D,isSDF:E,sectionIndex:A}=t[v],B=m.vertexLength,N=D[1];Xo(f,o.x,o.y,w.x,N+w.y,S.x,S.y,i,E,M.x,M.y,R,I,d),Xo(f,o.x,o.y,b.x,N+b.y,S.x+S.w,S.y,i,E,F.x,M.y,R,I,d),Xo(f,o.x,o.y,T.x,N+T.y,S.x,S.y+S.h,i,E,M.x,F.y,R,I,d),Xo(f,o.x,o.y,P.x,N+P.y,S.x+S.w,S.y+S.h,i,E,F.x,F.y,R,I,d),Yo(e.dynamicLayoutVertexArray,o,y),p.emplaceBack(B,B+2,B+1),p.emplaceBack(B+1,B+2,B+3),m.vertexLength+=4,m.primitiveLength+=2,this.glyphOffsetArray.emplaceBack(D[0]),(v===t.length-1||A!==t[v+1].sectionIndex)&&e.programConfigurations.populatePaintArrays(f.length,n,n.index,{imagePositions:{},canonical:c,formattedSection:x==null?void 0:x[A]})}e.placedSymbolArray.emplaceBack(o.x,o.y,g,this.glyphOffsetArray.length-g,_,l,u,o.segment,i?i[0]:0,i?i[1]:0,r[0],r[1],s,0,!1,0,h,d)}_addCollisionDebugVertex(e,t,i,r,a,n){return t.emplaceBack(0,0),e.emplaceBack(i.x,i.y,r,a,Math.round(n.x),Math.round(n.y))}addCollisionDebugVertices(e,t,i,r,a,n,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 C(e,t)),this._addCollisionDebugVertex(u,h,n,c,d,new C(i,t)),this._addCollisionDebugVertex(u,h,n,c,d,new C(i,r)),this._addCollisionDebugVertex(u,h,n,c,d,new C(e,r)),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,i,r){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,r?this.textCollisionBox:this.iconCollisionBox,n.anchorPoint,i)}}generateCollisionDebugBuffers(){this.hasDebugData()&&this.destroyDebugData(),this.textCollisionBox=new Kh(ym,hg.members,_h),this.iconCollisionBox=new Kh(ym,hg.members,_h);for(let e=0;e<this.symbolInstances.length;e++){let t=this.symbolInstances.get(e);this.addDebugCollisionBoxes(t.textBoxStartIndex,t.textBoxEndIndex,t,!0),this.addDebugCollisionBoxes(t.verticalTextBoxStartIndex,t.verticalTextBoxEndIndex,t,!0),this.addDebugCollisionBoxes(t.iconBoxStartIndex,t.iconBoxEndIndex,t,!1),this.addDebugCollisionBoxes(t.verticalIconBoxStartIndex,t.verticalIconBoxEndIndex,t,!1)}}_deserializeCollisionBoxesForSymbol(e,t,i,r,a,n,s,o,l){let u={};for(let h=t;h<i;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=r;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 i=this.symbolInstances.get(t);this.collisionArrays.push(this._deserializeCollisionBoxesForSymbol(e,i.textBoxStartIndex,i.textBoxEndIndex,i.verticalTextBoxStartIndex,i.verticalTextBoxEndIndex,i.iconBoxStartIndex,i.iconBoxEndIndex,i.verticalIconBoxStartIndex,i.verticalIconBoxEndIndex))}}hasTextData(){return this.text.segments.get().length>0}hasIconData(){return this.icon.segments.get().length>0}hasDebugData(){return this.textCollisionBox&&this.iconCollisionBox}hasTextCollisionBoxData(){return this.hasDebugData()&&this.textCollisionBox.segments.get().length>0}hasIconCollisionBoxData(){return this.hasDebugData()&&this.iconCollisionBox.segments.get().length>0}addIndicesForPlacedSymbol(e,t){let i=e.placedSymbolArray.get(t),r=i.vertexStartIndex+i.numGlyphs*4;for(let a=i.vertexStartIndex;a<r;a+=4)e.indexArray.emplaceBack(a,a+2,a+1),e.indexArray.emplaceBack(a+1,a+2,a+3)}getSortedSymbolIndexes(e){if(this.sortedAngle===e&&this.symbolInstanceIndexes!==void 0)return this.symbolInstanceIndexes;let t=Math.sin(e),i=Math.cos(e),r=[],a=[],n=[];for(let s=0;s<this.symbolInstances.length;++s){n.push(s);let o=this.symbolInstances.get(s);r.push(Math.round(t*o.anchorX+i*o.anchorY)|0),a.push(o.featureIndex)}return n.sort((s,o)=>r[s]-r[o]||a[o]-a[s]),n}addToSortKeyRanges(e,t){let i=this.sortKeyRanges[this.sortKeyRanges.length-1];(i==null?void 0:i.sortKey)===t?i.symbolInstanceEnd=e+1:this.sortKeyRanges.push({sortKey:t,symbolInstanceStart:e,symbolInstanceEnd:e+1})}sortFeatures(e){if(this.sortFeaturesByY&&this.sortedAngle!==e&&!(this.text.segments.get().length>1||this.icon.segments.get().length>1)){this.symbolInstanceIndexes=this.getSortedSymbolIndexes(e),this.sortedAngle=e,this.text.indexArray.clear(),this.icon.indexArray.clear(),this.featureSortOrder=[];for(let t of this.symbolInstanceIndexes){let i=this.symbolInstances.get(t);this.featureSortOrder.push(i.featureIndex);let r=[i.rightJustifiedTextSymbolIndex,i.centerJustifiedTextSymbolIndex,i.leftJustifiedTextSymbolIndex];for(let a=0;a<r.length;a++){let n=r[a];n>=0&&r.indexOf(n)===a&&this.addIndicesForPlacedSymbol(this.text,n)}i.verticalPlacedTextSymbolIndex>=0&&this.addIndicesForPlacedSymbol(this.text,i.verticalPlacedTextSymbolIndex),i.placedIconSymbolIndex>=0&&this.addIndicesForPlacedSymbol(this.icon,i.placedIconSymbolIndex),i.verticalPlacedIconSymbolIndex>=0&&this.addIndicesForPlacedSymbol(this.icon,i.verticalPlacedIconSymbolIndex)}this.text.indexBuffer&&this.text.indexBuffer.updateData(this.text.indexArray),this.icon.indexBuffer&&this.icon.indexBuffer.updateData(this.icon.indexArray)}}};U("SymbolBucket",Ko,{omit:["layers","collisionBoxArray","features","compareText"]});function qE(e,t){return t.replace(/{([^{}]+)}/g,(i,r)=>e&&r in e?String(e[r]):"")}let WE;const HE=()=>WE||(WE=new yt({"symbol-placement":new j(z.layout_symbol["symbol-placement"],"symbol-placement"),"symbol-spacing":new j(z.layout_symbol["symbol-spacing"],"symbol-spacing"),"symbol-avoid-edges":new j(z.layout_symbol["symbol-avoid-edges"],"symbol-avoid-edges"),"symbol-sort-key":new J(z.layout_symbol["symbol-sort-key"],"symbol-sort-key"),"symbol-z-order":new j(z.layout_symbol["symbol-z-order"],"symbol-z-order"),"icon-allow-overlap":new j(z.layout_symbol["icon-allow-overlap"],"icon-allow-overlap"),"icon-overlap":new j(z.layout_symbol["icon-overlap"],"icon-overlap"),"icon-ignore-placement":new j(z.layout_symbol["icon-ignore-placement"],"icon-ignore-placement"),"icon-optional":new j(z.layout_symbol["icon-optional"],"icon-optional"),"icon-rotation-alignment":new J(z.layout_symbol["icon-rotation-alignment"],"icon-rotation-alignment"),"icon-size":new J(z.layout_symbol["icon-size"],"icon-size"),"icon-text-fit":new j(z.layout_symbol["icon-text-fit"],"icon-text-fit"),"icon-text-fit-padding":new j(z.layout_symbol["icon-text-fit-padding"],"icon-text-fit-padding"),"icon-image":new J(z.layout_symbol["icon-image"],"icon-image"),"icon-rotate":new J(z.layout_symbol["icon-rotate"],"icon-rotate"),"icon-padding":new J(z.layout_symbol["icon-padding"],"icon-padding"),"icon-keep-upright":new j(z.layout_symbol["icon-keep-upright"],"icon-keep-upright"),"icon-offset":new J(z.layout_symbol["icon-offset"],"icon-offset"),"icon-anchor":new J(z.layout_symbol["icon-anchor"],"icon-anchor"),"icon-pitch-alignment":new j(z.layout_symbol["icon-pitch-alignment"],"icon-pitch-alignment"),"text-pitch-alignment":new j(z.layout_symbol["text-pitch-alignment"],"text-pitch-alignment"),"text-rotation-alignment":new j(z.layout_symbol["text-rotation-alignment"],"text-rotation-alignment"),"text-field":new J(z.layout_symbol["text-field"],"text-field"),"text-font":new J(z.layout_symbol["text-font"],"text-font"),"text-size":new J(z.layout_symbol["text-size"],"text-size"),"text-max-width":new J(z.layout_symbol["text-max-width"],"text-max-width"),"text-line-height":new j(z.layout_symbol["text-line-height"],"text-line-height"),"text-letter-spacing":new J(z.layout_symbol["text-letter-spacing"],"text-letter-spacing"),"text-justify":new J(z.layout_symbol["text-justify"],"text-justify"),"text-radial-offset":new J(z.layout_symbol["text-radial-offset"],"text-radial-offset"),"text-variable-anchor":new j(z.layout_symbol["text-variable-anchor"],"text-variable-anchor"),"text-variable-anchor-offset":new J(z.layout_symbol["text-variable-anchor-offset"],"text-variable-anchor-offset"),"text-anchor":new J(z.layout_symbol["text-anchor"],"text-anchor"),"text-max-angle":new j(z.layout_symbol["text-max-angle"],"text-max-angle"),"text-writing-mode":new j(z.layout_symbol["text-writing-mode"],"text-writing-mode"),"text-rotate":new J(z.layout_symbol["text-rotate"],"text-rotate"),"text-padding":new j(z.layout_symbol["text-padding"],"text-padding"),"text-keep-upright":new j(z.layout_symbol["text-keep-upright"],"text-keep-upright"),"text-transform":new J(z.layout_symbol["text-transform"],"text-transform"),"text-offset":new J(z.layout_symbol["text-offset"],"text-offset"),"text-allow-overlap":new j(z.layout_symbol["text-allow-overlap"],"text-allow-overlap"),"text-overlap":new j(z.layout_symbol["text-overlap"],"text-overlap"),"text-ignore-placement":new j(z.layout_symbol["text-ignore-placement"],"text-ignore-placement"),"text-optional":new j(z.layout_symbol["text-optional"],"text-optional"),"symbol-height-offset":new J(z.layout_symbol["symbol-height-offset"],"symbol-height-offset"),"symbol-height-anchor":new j(z.layout_symbol["symbol-height-anchor"],"symbol-height-anchor")}));let XE;const YE=()=>XE||(XE=new yt({"icon-opacity":new J(z.paint_symbol["icon-opacity"],"icon-opacity"),"icon-color":new J(z.paint_symbol["icon-color"],"icon-color"),"icon-halo-color":new J(z.paint_symbol["icon-halo-color"],"icon-halo-color"),"icon-halo-width":new J(z.paint_symbol["icon-halo-width"],"icon-halo-width"),"icon-halo-blur":new J(z.paint_symbol["icon-halo-blur"],"icon-halo-blur"),"icon-translate":new j(z.paint_symbol["icon-translate"],"icon-translate"),"icon-translate-anchor":new j(z.paint_symbol["icon-translate-anchor"],"icon-translate-anchor"),"text-opacity":new J(z.paint_symbol["text-opacity"],"text-opacity"),"text-color":new J(z.paint_symbol["text-color"],"text-color",{runtimeType:Ei,getOverride:e=>e.textColor,hasOverride:e=>!!e.textColor}),"text-halo-color":new J(z.paint_symbol["text-halo-color"],"text-halo-color"),"text-halo-width":new J(z.paint_symbol["text-halo-width"],"text-halo-width"),"text-halo-blur":new J(z.paint_symbol["text-halo-blur"],"text-halo-blur"),"text-translate":new j(z.paint_symbol["text-translate"],"text-translate"),"text-translate-anchor":new j(z.paint_symbol["text-translate-anchor"],"text-translate-anchor")}));var Jh={get paint(){return YE()},get layout(){return HE()}},Zg=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:mn,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}};U("FormatSectionOverride",Zg,{omit:["defaultValue"]});const qg=e=>e.type==="symbol";var KE=class Kd extends Pi{constructor(t,i){super(t,Jh,i)}recalculate(t,i){super.recalculate(t,i);let r=this.layout.get("icon-rotation-alignment");if((r.value.kind!=="constant"||r.value.value==="auto")&&(this.layout._values["icon-rotation-alignment"]=new gi(r.property,{kind:"constant",value:this.layout.get("symbol-placement")==="point"?"viewport":"map"},r.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,i,r,a){let n=this.layout.get(t).evaluate(i,{},r,a),s=this._unevaluatedLayout._values[t];return!s.isDataDriven()&&!uo(s.value)&&n?qE(i.properties,n):n}createBucket(t){return new Ko(t)}queryRadius(){return 0}queryIntersectsFeature(){throw Error("Should take a different path in FeatureIndex")}_setPaintOverrides(){for(let t of Jh.paint.overridableProperties){if(!Kd.hasPaintOverride(this.layout,t))continue;let i=this.paint.get(t),r=new zu(new Zg(i),`layers[${this.id}].paint.${i.property.name}`,i.property.specification),a=null;a=i.value.kind==="constant"||i.value.kind==="source"?new An("source",r):new co("composite",r,i.value.zoomStops),this.paint._values[t]=new gi(i.property,a,i.parameters)}}_handleOverridablePaintPropertyUpdate(t,i,r){return!this.layout||i.isDataDriven()||r.isDataDriven()?!1:Kd.hasPaintOverride(this.layout,t)}static hasPaintOverride(t,i){let r=t.get("text-field"),a=Jh.paint.properties[i],n=!1,s=o=>{var l;for(let u of o)if((l=a.overrides)!=null&&l.hasOverride(u)){n=!0;return}};if(r.value.kind==="constant"&&r.value.value instanceof Qi)s(r.value.value.sections);else if(r.value.kind==="source"||r.value.kind==="composite"){let o=u=>{if(!n)if(u instanceof Da&&Je(u.value)===gn){let h=u.value;s(h.sections)}else u instanceof Np?s(u.sections):u.eachChild(o)},l=r.value;l._styleExpression&&o(l._styleExpression.expression)}return n}};function JE(e,t,i,r=1){var n;let a=(n=e.get("icon-padding").evaluate(t,{},i))==null?void 0:n.values;return[a[0]*r,a[1]*r,a[2]*r,a[3]*r]}let QE;const eP=()=>QE||(QE=new yt({"background-color":new j(z.paint_background["background-color"],"background-color"),"background-pattern":new im(z.paint_background["background-pattern"],"background-pattern"),"background-opacity":new j(z.paint_background["background-opacity"],"background-opacity")}));var tP={get paint(){return eP()}};const iP=e=>e.type==="background";var rP=class extends Pi{constructor(e,t){super(e,tP,t)}};function aP(e){let t=[],i=e.id;return i===void 0&&t.push(new $(`layers.${i}`,null,'missing required property "id"')),e.render===void 0&&t.push(new $(`layers.${i}`,null,'missing required method "render"')),e.renderingMode&&e.renderingMode!=="2d"&&e.renderingMode!=="3d"&&t.push(new $(`layers.${i}`,null,'property "renderingMode" must be either "2d" or "3d"')),t}const nP=e=>e.type==="custom";var sP=class extends Pi{constructor(e,t){super(e,{},t),this.onAdd=i=>{this.implementation.onAdd&&this.implementation.onAdd(i,i.painter.context.gl)},this.onRemove=i=>{this.implementation.onRemove&&this.implementation.onRemove(i,i.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 Qh(e,t){if(e.type==="custom")return new sP(e,t);switch(e.type){case"background":return new rP(e,t);case"circle":return new nT(e,t);case"color-relief":return new bT(e,t);case"fill":return new tS(e,t);case"fill-extrusion":return new SS(e,t);case"heatmap":return new hT(e,t);case"hillshade":return new mT(e,t);case"line":return new VS(e,t);case"raster":return new f2(e,t);case"symbol":return new KE(e,t)}}var oP=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 lP={once:!0};var uP=class{constructor(e,t){this.target=e,this.mapId=t,this.resolveRejects={},this.tasks={},this.taskQueue=[],this.abortControllers={},this.messageHandlers={},this.invoker=new oP(()=>this.process()),this.subscription=iu(this.target,"message",i=>this.receive(i),!1),this.globalScope=Ea(self)?e:window}registerMessageHandler(e,t){this.messageHandlers[e]=t}unregisterMessageHandler(e){delete this.messageHandlers[e]}sendAsync(e,t){return new Promise((i,r)=>{let a=Math.round(Math.random()*1e18).toString(36).substring(0,10),n=t?iu(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),r(new pn(t.signal.reason))},lP):null;this.resolveRejects[a]={resolve:l=>{n==null||n.unsubscribe(),i(l)},reject:l=>{n==null||n.unsubscribe(),r(l)}};let s=[],o={...e,id:a,sourceMapId:this.mapId,origin:location.origin,data:Fn(e.data,s)};this.target.postMessage(o,{transfer:s})})}receive(e){let t=e.data,i=t.id,r=["file://","resource://android","null"],a=[t.origin,location.origin],n=t.origin===location.origin,s=a.some(o=>r.includes(o));if((n||s)&&!(t.targetMapId&&this.mapId!==t.targetMapId)){if(t.type==="<cancel>"){delete this.tasks[i];let o=this.abortControllers[i];delete this.abortControllers[i],o&&o.abort();return}if(Ea(self)||t.mustQueue){this.tasks[i]=t,this.taskQueue.push(i),this.invoker.trigger();return}this.processTask(i,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(St(Rn(t.error))):a.resolve(Rn(t.data));return}if(!this.messageHandlers[t.type]){this.completeTask(e,null,null);return}let i=Rn(t.data),r=new AbortController;this.abortControllers[e]=r;try{let a=await this.messageHandlers[t.type](t.sourceMapId,i,r);this.completeTask(e,null,a)}catch(a){this.completeTask(e,St(a))}}completeTask(e,t,i){let r=[];delete this.abortControllers[e];let a={id:e,type:"<response>",sourceMapId:this.mapId,origin:location.origin,error:t?Fn(t):null,data:Fn(i,r)};this.target.postMessage(a,{transfer:r})}remove(){this.invoker.remove(),this.subscription.unsubscribe()}};function hP(e,t,i){return!(e<0||e>25||i<0||i>=2**e||t<0||t>=2**e)}function Wg(e,t){let{x:i,y:r}=ye.fromLngLat(t);return!(e<0||e>25||r<0||r>=1||i<0||i>=1)}var Jo=class{constructor(e,t,i){if(!hP(e,t,i))throw Error(`x=${t}, y=${i}, z=${e} outside of bounds. 0<=x<${2**e}, 0<=y<${2**e} 0<=z<=25 `);this.z=e,this.x=t,this.y=i,this.key=qa(0,e,e,t,i)}equals(e){return this.z===e.z&&this.x===e.x&&this.y===e.y}url(e,t,i){let r=cP(this.x,this.y,this.z),a=dP(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(i==="tms"?2**this.z-this.y-1:this.y)).replace(/{ratio}/g,t>1?"@2x":"").replace(/{quadkey}/g,a).replace(/{bbox-epsg-3857}/g,r)}isChildOf(e){let t=this.z-e.z;return t>0&&e.x===this.x>>t&&e.y===this.y>>t}getTilePoint(e){let t=2**this.z;return new C((e.x*t-this.x)*k,(e.y*t-this.y)*k)}toString(){return`${this.z}/${this.x}/${this.y}`}},Qo=class{constructor(e,t){this.wrap=e,this.canonical=t,this.key=qa(e,t.z,t.z,t.x,t.y)}},Pt=class Ti{constructor(t,i,r,a,n){if(this.terrainRttPosMatrix32f=null,t<r)throw Error(`overscaledZ should be >= z; overscaledZ = ${t}; z = ${r}`);this.overscaledZ=t,this.wrap=i,this.canonical=new Jo(r,+a,+n),this.key=qa(i,t,r,a,n)}clone(){return new Ti(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 i=this.canonical.z-t;return t>this.canonical.z?new Ti(t,this.wrap,this.canonical.z,this.canonical.x,this.canonical.y):new Ti(t,this.wrap,t,this.canonical.x>>i,this.canonical.y>>i)}isOverscaled(){return this.overscaledZ>this.canonical.z}calculateScaledKey(t,i){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?qa(this.wrap*+i,t,this.canonical.z,this.canonical.x,this.canonical.y):qa(this.wrap*+i,t,t,this.canonical.x>>r,this.canonical.y>>r)}isChildOf(t){if(t.wrap!==this.wrap||this.overscaledZ-t.overscaledZ<=0)return!1;if(t.overscaledZ===0)return this.overscaledZ>0;let i=this.canonical.z-t.canonical.z;return i<0?!1:t.canonical.x===this.canonical.x>>i&&t.canonical.y===this.canonical.y>>i}children(t){if(this.overscaledZ>=t)return[new Ti(this.overscaledZ+1,this.wrap,this.canonical.z,this.canonical.x,this.canonical.y)];let i=this.canonical.z+1,r=this.canonical.x*2,a=this.canonical.y*2;return[new Ti(i,this.wrap,i,r,a),new Ti(i,this.wrap,i,r+1,a),new Ti(i,this.wrap,i,r,a+1),new Ti(i,this.wrap,i,r+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 Ti(this.overscaledZ,0,this.canonical.z,this.canonical.x,this.canonical.y)}unwrapTo(t){return new Ti(this.overscaledZ,t,this.canonical.z,this.canonical.x,this.canonical.y)}overscaleFactor(){return 2**(this.overscaledZ-this.canonical.z)}toUnwrapped(){return new Qo(this.wrap,this.canonical)}toString(){return`${this.overscaledZ}/${this.canonical.x}/${this.canonical.y}`}getTilePoint(t){return this.canonical.getTilePoint(new ye(t.x-this.wrap,t.y))}normalizeCoordinates(t,i,r=k){if(t>=0&&t<r&&i>=0&&i<r)return{tileID:this,x:t,y:i};let a=Math.floor(t/r),n=Math.floor(i/r),s=t-a*r,o=i-n*r,l=this.canonical.z,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 Ti(this.overscaledZ,d,l,c,h),x:s,y:o}}};function qa(e,t,i,r,a){e*=2,e<0&&(e=e*-1-1);let n=1<<i;return(n*n*e+n*a+r).toString(36)+i.toString(36)+t.toString(36)}const ec=Math.PI*6378137;function cP(e,t,i){t=2**i-t-1;let r=Hg(e*256,t*256,i),a=Hg((e+1)*256,(t+1)*256,i);return`${r[0]},${r[1]},${a[0]},${a[1]}`}function Hg(e,t,i){let r=2*ec/256/2**i;return[e*r-ec,t*r-ec]}function dP(e,t,i){let r="";for(let a=e;a>0;a--){let n=1<<a-1;r+=(t&n?1:0)+(i&n?2:0)}return r}function Xg(e,t){let i=Math.abs(e.wrap*2)-+(e.wrap<0),r=Math.abs(t.wrap*2)-+(t.wrap<0);return e.overscaledZ-t.overscaledZ||r-i||t.canonical.y-e.canonical.y||t.canonical.x-e.canonical.x}U("CanonicalTileID",Jo),U("OverscaledTileID",Pt,{omit:["terrainRttPosMatrix32f"]});const el="_geojsonTileLayer";var pP=class{constructor(e){this._stringToNumber={},this._numberToString=[];for(let t=0;t<e.length;t++){let i=e[t];this._stringToNumber[i]=t,this._numberToString[t]=i}}encode(e){return this._stringToNumber[e]}decode(e){if(e>=this._numberToString.length)throw Error(`Out of bounds. Index requested n=${e} can't be >= this._numberToString.length ${this._numberToString.length}`);return this._numberToString[e]}},Yg=class{constructor(e,t,i,r,a){this.type="Feature",this._vectorTileFeature=e,this._x=i,this._y=r,this._z=t;for(let n in e.properties)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,i,r){return[(e.x+t)*360/r-180,360/Math.PI*Math.atan(Math.exp((1-(e.y+i)*2/r)*Math.PI))-90]}projectLine(e,t,i,r){return e.map(a=>this.projectPoint(a,t,i,r))}get geometry(){if(this._geometry)return this._geometry;let e=this._vectorTileFeature,t=e.extent*2**this._z,i=e.extent*this._x,r=e.extent*this._y,a=e.loadGeometry();switch(e.type){case 1:{let n=[];for(let o of a)n.push(o[0]);let s=this.projectLine(n,i,r,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,i,r,t));this._geometry=n.length===1?{type:"LineString",coordinates:n[0]}:{type:"MultiLineString",coordinates:n};break}case 3:{let n=Ym(a),s=[];for(let o of n)s.push(o.map(l=>this.projectLine(l,i,r,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,i){this._name=e,this.dataBuffer=t,typeof i=="number"?this._size=i:(this.nullabilityBuffer=i,this._size=i.size())}getValue(e){return this.nullabilityBuffer&&!this.nullabilityBuffer.get(e)?null:this.getValueFromBuffer(e)}has(e){var t;return((t=this.nullabilityBuffer)==null?void 0:t.get(e))||!this.nullabilityBuffer}get name(){return this._name}get size(){return this._size}},tl=class extends na{},tc=class extends tl{getValueFromBuffer(e){return this.dataBuffer[e]}},ic=class extends tl{getValueFromBuffer(e){return this.dataBuffer[e]}},Kg=class extends na{constructor(e,t,i,r){super(e,t,r),this.delta=i}},rc=class extends Kg{constructor(e,t,i,r,a){super(e,a?Int32Array.of(t):Uint32Array.of(t),i,r)}getValueFromBuffer(e){return this.dataBuffer[0]+e*this.delta}},ac=class extends na{constructor(e,t,i,r){super(e,r?Int32Array.of(t):Uint32Array.of(t),i)}getValueFromBuffer(e){return this.dataBuffer[0]}},fP=class{constructor(e,t,i,r,a=4096){if(this._name=e,this._geometryVector=t,this._idVector=i,this._propertyVectors=r,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 i=0;i<this.numFeatures;i++){let r;if(this.idVector){let s=this.idVector.getValue(i);s!==null&&(r=this.containsMaxSafeIntegerValues(this.idVector)?Number(s):s)}let a={coordinates:t[i],type:this.geometryVector.geometryType(i)},n={};for(let s of this.propertyVectors){if(!s)continue;let o=s.name,l=s.getValue(i);l!==null&&(n[o]=l)}e.push({id:r,geometry:a,properties:n})}return e}containsMaxSafeIntegerValues(e){return e instanceof tc||e instanceof ac||e instanceof rc||e instanceof ic}};const rs={FEATURE:0},me={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},Dr={GEOMETRY:0,STRUCT:1,MAP:2},Jg={ID:0};var Qg=class{constructor(e){this.value=e}get(){return this.value}set(e){this.value=e}increment(){return this.value++}add(e){this.value+=e}},ae;(function(e){e.NONE="NONE",e.DELTA="DELTA",e.COMPONENTWISE_DELTA="COMPONENTWISE_DELTA",e.RLE="RLE",e.MORTON="MORTON"})(ae||(ae={}));var yi;(function(e){e.NONE="NONE",e.FAST_PFOR="FAST_PFOR",e.VARINT="VARINT"})(yi||(yi={}));const nc=new Uint32Array(33);nc[0]=0;for(let e=1;e<=32;e++)nc[e]=e===32?4294967295:4294967295>>>32-e;const sc=nc,e_=65536;function oc(e,t){return e-e%t}function mP(e){return oc(e+31,32)}function gP(e){if(!Number.isFinite(e)||e<=0)return e_;let t=oc(Math.floor(e),256);return t===0?256:t}function _P(e){let t=e>>>0;return((t&255)<<24|(t&65280)<<8|t>>>8&65280|t>>>24&255)>>>0}function yP(e,t,i,r){let a=r,n=e[t]>>>0,s=e[t+1]>>>0;i[a++]=n>>>0&3,i[a++]=n>>>2&3,i[a++]=n>>>4&3,i[a++]=n>>>6&3,i[a++]=n>>>8&3,i[a++]=n>>>10&3,i[a++]=n>>>12&3,i[a++]=n>>>14&3,i[a++]=n>>>16&3,i[a++]=n>>>18&3,i[a++]=n>>>20&3,i[a++]=n>>>22&3,i[a++]=n>>>24&3,i[a++]=n>>>26&3,i[a++]=n>>>28&3,i[a++]=n>>>30&3,i[a++]=s>>>0&3,i[a++]=s>>>2&3,i[a++]=s>>>4&3,i[a++]=s>>>6&3,i[a++]=s>>>8&3,i[a++]=s>>>10&3,i[a++]=s>>>12&3,i[a++]=s>>>14&3,i[a++]=s>>>16&3,i[a++]=s>>>18&3,i[a++]=s>>>20&3,i[a++]=s>>>22&3,i[a++]=s>>>24&3,i[a++]=s>>>26&3,i[a++]=s>>>28&3,i[a]=s>>>30&3}function vP(e,t,i,r){let a=r,n=e[t]>>>0,s=e[t+1]>>>0,o=e[t+2]>>>0;i[a++]=n>>>0&7,i[a++]=n>>>3&7,i[a++]=n>>>6&7,i[a++]=n>>>9&7,i[a++]=n>>>12&7,i[a++]=n>>>15&7,i[a++]=n>>>18&7,i[a++]=n>>>21&7,i[a++]=n>>>24&7,i[a++]=n>>>27&7,i[a++]=(n>>>30|(s&1)<<2)&7,i[a++]=s>>>1&7,i[a++]=s>>>4&7,i[a++]=s>>>7&7,i[a++]=s>>>10&7,i[a++]=s>>>13&7,i[a++]=s>>>16&7,i[a++]=s>>>19&7,i[a++]=s>>>22&7,i[a++]=s>>>25&7,i[a++]=s>>>28&7,i[a++]=(s>>>31|(o&3)<<1)&7,i[a++]=o>>>2&7,i[a++]=o>>>5&7,i[a++]=o>>>8&7,i[a++]=o>>>11&7,i[a++]=o>>>14&7,i[a++]=o>>>17&7,i[a++]=o>>>20&7,i[a++]=o>>>23&7,i[a++]=o>>>26&7,i[a]=o>>>29&7}function xP(e,t,i,r){let a=r,n=e[t]>>>0,s=e[t+1]>>>0,o=e[t+2]>>>0,l=e[t+3]>>>0;i[a++]=n>>>0&15,i[a++]=n>>>4&15,i[a++]=n>>>8&15,i[a++]=n>>>12&15,i[a++]=n>>>16&15,i[a++]=n>>>20&15,i[a++]=n>>>24&15,i[a++]=n>>>28&15,i[a++]=s>>>0&15,i[a++]=s>>>4&15,i[a++]=s>>>8&15,i[a++]=s>>>12&15,i[a++]=s>>>16&15,i[a++]=s>>>20&15,i[a++]=s>>>24&15,i[a++]=s>>>28&15,i[a++]=o>>>0&15,i[a++]=o>>>4&15,i[a++]=o>>>8&15,i[a++]=o>>>12&15,i[a++]=o>>>16&15,i[a++]=o>>>20&15,i[a++]=o>>>24&15,i[a++]=o>>>28&15,i[a++]=l>>>0&15,i[a++]=l>>>4&15,i[a++]=l>>>8&15,i[a++]=l>>>12&15,i[a++]=l>>>16&15,i[a++]=l>>>20&15,i[a++]=l>>>24&15,i[a]=l>>>28&15}function bP(e,t,i,r){let a=r,n=e[t]>>>0,s=e[t+1]>>>0,o=e[t+2]>>>0,l=e[t+3]>>>0,u=e[t+4]>>>0;i[a++]=n>>>0&31,i[a++]=n>>>5&31,i[a++]=n>>>10&31,i[a++]=n>>>15&31,i[a++]=n>>>20&31,i[a++]=n>>>25&31,i[a++]=(n>>>30|(s&7)<<2)&31,i[a++]=s>>>3&31,i[a++]=s>>>8&31,i[a++]=s>>>13&31,i[a++]=s>>>18&31,i[a++]=s>>>23&31,i[a++]=(s>>>28|(o&1)<<4)&31,i[a++]=o>>>1&31,i[a++]=o>>>6&31,i[a++]=o>>>11&31,i[a++]=o>>>16&31,i[a++]=o>>>21&31,i[a++]=o>>>26&31,i[a++]=(o>>>31|(l&15)<<1)&31,i[a++]=l>>>4&31,i[a++]=l>>>9&31,i[a++]=l>>>14&31,i[a++]=l>>>19&31,i[a++]=l>>>24&31,i[a++]=(l>>>29|(u&3)<<3)&31,i[a++]=u>>>2&31,i[a++]=u>>>7&31,i[a++]=u>>>12&31,i[a++]=u>>>17&31,i[a++]=u>>>22&31,i[a]=u>>>27&31}function wP(e,t,i,r){let a=r,n=e[t]>>>0,s=e[t+1]>>>0,o=e[t+2]>>>0,l=e[t+3]>>>0,u=e[t+4]>>>0,h=e[t+5]>>>0;i[a++]=n>>>0&63,i[a++]=n>>>6&63,i[a++]=n>>>12&63,i[a++]=n>>>18&63,i[a++]=n>>>24&63,i[a++]=(n>>>30|(s&15)<<2)&63,i[a++]=s>>>4&63,i[a++]=s>>>10&63,i[a++]=s>>>16&63,i[a++]=s>>>22&63,i[a++]=(s>>>28|(o&3)<<4)&63,i[a++]=o>>>2&63,i[a++]=o>>>8&63,i[a++]=o>>>14&63,i[a++]=o>>>20&63,i[a++]=o>>>26&63,i[a++]=l>>>0&63,i[a++]=l>>>6&63,i[a++]=l>>>12&63,i[a++]=l>>>18&63,i[a++]=l>>>24&63,i[a++]=(l>>>30|(u&15)<<2)&63,i[a++]=u>>>4&63,i[a++]=u>>>10&63,i[a++]=u>>>16&63,i[a++]=u>>>22&63,i[a++]=(u>>>28|(h&3)<<4)&63,i[a++]=h>>>2&63,i[a++]=h>>>8&63,i[a++]=h>>>14&63,i[a++]=h>>>20&63,i[a]=h>>>26&63}function TP(e,t,i,r){let a=r,n=e[t]>>>0,s=e[t+1]>>>0,o=e[t+2]>>>0,l=e[t+3]>>>0,u=e[t+4]>>>0,h=e[t+5]>>>0,c=e[t+6]>>>0;i[a++]=n>>>0&127,i[a++]=n>>>7&127,i[a++]=n>>>14&127,i[a++]=n>>>21&127,i[a++]=(n>>>28|(s&7)<<4)&127,i[a++]=s>>>3&127,i[a++]=s>>>10&127,i[a++]=s>>>17&127,i[a++]=s>>>24&127,i[a++]=(s>>>31|(o&63)<<1)&127,i[a++]=o>>>6&127,i[a++]=o>>>13&127,i[a++]=o>>>20&127,i[a++]=(o>>>27|(l&3)<<5)&127,i[a++]=l>>>2&127,i[a++]=l>>>9&127,i[a++]=l>>>16&127,i[a++]=l>>>23&127,i[a++]=(l>>>30|(u&31)<<2)&127,i[a++]=u>>>5&127,i[a++]=u>>>12&127,i[a++]=u>>>19&127,i[a++]=(u>>>26|(h&1)<<6)&127,i[a++]=h>>>1&127,i[a++]=h>>>8&127,i[a++]=h>>>15&127,i[a++]=h>>>22&127,i[a++]=(h>>>29|(c&15)<<3)&127,i[a++]=c>>>4&127,i[a++]=c>>>11&127,i[a++]=c>>>18&127,i[a]=c>>>25&127}function SP(e,t,i,r){let a=r,n=e[t]>>>0,s=e[t+1]>>>0,o=e[t+2]>>>0,l=e[t+3]>>>0,u=e[t+4]>>>0,h=e[t+5]>>>0,c=e[t+6]>>>0,d=e[t+7]>>>0;i[a++]=n>>>0&255,i[a++]=n>>>8&255,i[a++]=n>>>16&255,i[a++]=n>>>24&255,i[a++]=s>>>0&255,i[a++]=s>>>8&255,i[a++]=s>>>16&255,i[a++]=s>>>24&255,i[a++]=o>>>0&255,i[a++]=o>>>8&255,i[a++]=o>>>16&255,i[a++]=o>>>24&255,i[a++]=l>>>0&255,i[a++]=l>>>8&255,i[a++]=l>>>16&255,i[a++]=l>>>24&255,i[a++]=u>>>0&255,i[a++]=u>>>8&255,i[a++]=u>>>16&255,i[a++]=u>>>24&255,i[a++]=h>>>0&255,i[a++]=h>>>8&255,i[a++]=h>>>16&255,i[a++]=h>>>24&255,i[a++]=c>>>0&255,i[a++]=c>>>8&255,i[a++]=c>>>16&255,i[a++]=c>>>24&255,i[a++]=d>>>0&255,i[a++]=d>>>8&255,i[a++]=d>>>16&255,i[a]=d>>>24&255}function EP(e,t,i,r){let a=r,n=e[t]>>>0,s=e[t+1]>>>0,o=e[t+2]>>>0,l=e[t+3]>>>0,u=e[t+4]>>>0,h=e[t+5]>>>0,c=e[t+6]>>>0,d=e[t+7]>>>0,p=e[t+8]>>>0;i[a++]=n>>>0&511,i[a++]=n>>>9&511,i[a++]=n>>>18&511,i[a++]=(n>>>27|(s&15)<<5)&511,i[a++]=s>>>4&511,i[a++]=s>>>13&511,i[a++]=s>>>22&511,i[a++]=(s>>>31|(o&255)<<1)&511,i[a++]=o>>>8&511,i[a++]=o>>>17&511,i[a++]=(o>>>26|(l&7)<<6)&511,i[a++]=l>>>3&511,i[a++]=l>>>12&511,i[a++]=l>>>21&511,i[a++]=(l>>>30|(u&127)<<2)&511,i[a++]=u>>>7&511,i[a++]=u>>>16&511,i[a++]=(u>>>25|(h&3)<<7)&511,i[a++]=h>>>2&511,i[a++]=h>>>11&511,i[a++]=h>>>20&511,i[a++]=(h>>>29|(c&63)<<3)&511,i[a++]=c>>>6&511,i[a++]=c>>>15&511,i[a++]=(c>>>24|(d&1)<<8)&511,i[a++]=d>>>1&511,i[a++]=d>>>10&511,i[a++]=d>>>19&511,i[a++]=(d>>>28|(p&31)<<4)&511,i[a++]=p>>>5&511,i[a++]=p>>>14&511,i[a]=p>>>23&511}function PP(e,t,i,r){let a=r,n=e[t]>>>0,s=e[t+1]>>>0,o=e[t+2]>>>0,l=e[t+3]>>>0,u=e[t+4]>>>0,h=e[t+5]>>>0,c=e[t+6]>>>0,d=e[t+7]>>>0,p=e[t+8]>>>0,f=e[t+9]>>>0;i[a++]=n>>>0&1023,i[a++]=n>>>10&1023,i[a++]=n>>>20&1023,i[a++]=(n>>>30|(s&255)<<2)&1023,i[a++]=s>>>8&1023,i[a++]=s>>>18&1023,i[a++]=(s>>>28|(o&63)<<4)&1023,i[a++]=o>>>6&1023,i[a++]=o>>>16&1023,i[a++]=(o>>>26|(l&15)<<6)&1023,i[a++]=l>>>4&1023,i[a++]=l>>>14&1023,i[a++]=(l>>>24|(u&3)<<8)&1023,i[a++]=u>>>2&1023,i[a++]=u>>>12&1023,i[a++]=u>>>22&1023,i[a++]=h>>>0&1023,i[a++]=h>>>10&1023,i[a++]=h>>>20&1023,i[a++]=(h>>>30|(c&255)<<2)&1023,i[a++]=c>>>8&1023,i[a++]=c>>>18&1023,i[a++]=(c>>>28|(d&63)<<4)&1023,i[a++]=d>>>6&1023,i[a++]=d>>>16&1023,i[a++]=(d>>>26|(p&15)<<6)&1023,i[a++]=p>>>4&1023,i[a++]=p>>>14&1023,i[a++]=(p>>>24|(f&3)<<8)&1023,i[a++]=f>>>2&1023,i[a++]=f>>>12&1023,i[a]=f>>>22&1023}function CP(e,t,i,r){let a=r,n=e[t]>>>0,s=e[t+1]>>>0,o=e[t+2]>>>0,l=e[t+3]>>>0,u=e[t+4]>>>0,h=e[t+5]>>>0,c=e[t+6]>>>0,d=e[t+7]>>>0,p=e[t+8]>>>0,f=e[t+9]>>>0,m=e[t+10]>>>0;i[a++]=n>>>0&2047,i[a++]=n>>>11&2047,i[a++]=(n>>>22|(s&1)<<10)&2047,i[a++]=s>>>1&2047,i[a++]=s>>>12&2047,i[a++]=(s>>>23|(o&3)<<9)&2047,i[a++]=o>>>2&2047,i[a++]=o>>>13&2047,i[a++]=(o>>>24|(l&7)<<8)&2047,i[a++]=l>>>3&2047,i[a++]=l>>>14&2047,i[a++]=(l>>>25|(u&15)<<7)&2047,i[a++]=u>>>4&2047,i[a++]=u>>>15&2047,i[a++]=(u>>>26|(h&31)<<6)&2047,i[a++]=h>>>5&2047,i[a++]=h>>>16&2047,i[a++]=(h>>>27|(c&63)<<5)&2047,i[a++]=c>>>6&2047,i[a++]=c>>>17&2047,i[a++]=(c>>>28|(d&127)<<4)&2047,i[a++]=d>>>7&2047,i[a++]=d>>>18&2047,i[a++]=(d>>>29|(p&255)<<3)&2047,i[a++]=p>>>8&2047,i[a++]=p>>>19&2047,i[a++]=(p>>>30|(f&511)<<2)&2047,i[a++]=f>>>9&2047,i[a++]=f>>>20&2047,i[a++]=(f>>>31|(m&1023)<<1)&2047,i[a++]=m>>>10&2047,i[a]=m>>>21&2047}function AP(e,t,i,r){let a=r,n=e[t]>>>0,s=e[t+1]>>>0,o=e[t+2]>>>0,l=e[t+3]>>>0,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;i[a++]=n>>>0&4095,i[a++]=n>>>12&4095,i[a++]=(n>>>24|(s&15)<<8)&4095,i[a++]=s>>>4&4095,i[a++]=s>>>16&4095,i[a++]=(s>>>28|(o&255)<<4)&4095,i[a++]=o>>>8&4095,i[a++]=o>>>20&4095,i[a++]=l>>>0&4095,i[a++]=l>>>12&4095,i[a++]=(l>>>24|(u&15)<<8)&4095,i[a++]=u>>>4&4095,i[a++]=u>>>16&4095,i[a++]=(u>>>28|(h&255)<<4)&4095,i[a++]=h>>>8&4095,i[a++]=h>>>20&4095,i[a++]=c>>>0&4095,i[a++]=c>>>12&4095,i[a++]=(c>>>24|(d&15)<<8)&4095,i[a++]=d>>>4&4095,i[a++]=d>>>16&4095,i[a++]=(d>>>28|(p&255)<<4)&4095,i[a++]=p>>>8&4095,i[a++]=p>>>20&4095,i[a++]=f>>>0&4095,i[a++]=f>>>12&4095,i[a++]=(f>>>24|(m&15)<<8)&4095,i[a++]=m>>>4&4095,i[a++]=m>>>16&4095,i[a++]=(m>>>28|(g&255)<<4)&4095,i[a++]=g>>>8&4095,i[a]=g>>>20&4095}function DP(e,t,i,r){let a=r,n=e[t]>>>0,s=e[t+1]>>>0,o=e[t+2]>>>0,l=e[t+3]>>>0,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,x=e[t+14]>>>0,v=e[t+15]>>>0;i[a++]=n>>>0&65535,i[a++]=n>>>16&65535,i[a++]=s>>>0&65535,i[a++]=s>>>16&65535,i[a++]=o>>>0&65535,i[a++]=o>>>16&65535,i[a++]=l>>>0&65535,i[a++]=l>>>16&65535,i[a++]=u>>>0&65535,i[a++]=u>>>16&65535,i[a++]=h>>>0&65535,i[a++]=h>>>16&65535,i[a++]=c>>>0&65535,i[a++]=c>>>16&65535,i[a++]=d>>>0&65535,i[a++]=d>>>16&65535,i[a++]=p>>>0&65535,i[a++]=p>>>16&65535,i[a++]=f>>>0&65535,i[a++]=f>>>16&65535,i[a++]=m>>>0&65535,i[a++]=m>>>16&65535,i[a++]=g>>>0&65535,i[a++]=g>>>16&65535,i[a++]=_>>>0&65535,i[a++]=_>>>16&65535,i[a++]=y>>>0&65535,i[a++]=y>>>16&65535,i[a++]=x>>>0&65535,i[a++]=x>>>16&65535,i[a++]=v>>>0&65535,i[a]=v>>>16&65535}function IP(e,t,i,r){let a=r,n=t;for(let s=0;s<8;s++){let o=e[n++]>>>0;i[a++]=o>>>0&1,i[a++]=o>>>1&1,i[a++]=o>>>2&1,i[a++]=o>>>3&1,i[a++]=o>>>4&1,i[a++]=o>>>5&1,i[a++]=o>>>6&1,i[a++]=o>>>7&1,i[a++]=o>>>8&1,i[a++]=o>>>9&1,i[a++]=o>>>10&1,i[a++]=o>>>11&1,i[a++]=o>>>12&1,i[a++]=o>>>13&1,i[a++]=o>>>14&1,i[a++]=o>>>15&1,i[a++]=o>>>16&1,i[a++]=o>>>17&1,i[a++]=o>>>18&1,i[a++]=o>>>19&1,i[a++]=o>>>20&1,i[a++]=o>>>21&1,i[a++]=o>>>22&1,i[a++]=o>>>23&1,i[a++]=o>>>24&1,i[a++]=o>>>25&1,i[a++]=o>>>26&1,i[a++]=o>>>27&1,i[a++]=o>>>28&1,i[a++]=o>>>29&1,i[a++]=o>>>30&1,i[a++]=o>>>31&1}}function MP(e,t,i,r){let a=r,n=t;for(let s=0;s<8;s++){let o=e[n++]>>>0,l=e[n++]>>>0;i[a++]=o>>>0&3,i[a++]=o>>>2&3,i[a++]=o>>>4&3,i[a++]=o>>>6&3,i[a++]=o>>>8&3,i[a++]=o>>>10&3,i[a++]=o>>>12&3,i[a++]=o>>>14&3,i[a++]=o>>>16&3,i[a++]=o>>>18&3,i[a++]=o>>>20&3,i[a++]=o>>>22&3,i[a++]=o>>>24&3,i[a++]=o>>>26&3,i[a++]=o>>>28&3,i[a++]=o>>>30&3,i[a++]=l>>>0&3,i[a++]=l>>>2&3,i[a++]=l>>>4&3,i[a++]=l>>>6&3,i[a++]=l>>>8&3,i[a++]=l>>>10&3,i[a++]=l>>>12&3,i[a++]=l>>>14&3,i[a++]=l>>>16&3,i[a++]=l>>>18&3,i[a++]=l>>>20&3,i[a++]=l>>>22&3,i[a++]=l>>>24&3,i[a++]=l>>>26&3,i[a++]=l>>>28&3,i[a++]=l>>>30&3}}function zP(e,t,i,r){let a=r,n=t;for(let s=0;s<8;s++){let o=e[n++]>>>0,l=e[n++]>>>0,u=e[n++]>>>0;i[a++]=o>>>0&7,i[a++]=o>>>3&7,i[a++]=o>>>6&7,i[a++]=o>>>9&7,i[a++]=o>>>12&7,i[a++]=o>>>15&7,i[a++]=o>>>18&7,i[a++]=o>>>21&7,i[a++]=o>>>24&7,i[a++]=o>>>27&7,i[a++]=(o>>>30|(l&1)<<2)&7,i[a++]=l>>>1&7,i[a++]=l>>>4&7,i[a++]=l>>>7&7,i[a++]=l>>>10&7,i[a++]=l>>>13&7,i[a++]=l>>>16&7,i[a++]=l>>>19&7,i[a++]=l>>>22&7,i[a++]=l>>>25&7,i[a++]=l>>>28&7,i[a++]=(l>>>31|(u&3)<<1)&7,i[a++]=u>>>2&7,i[a++]=u>>>5&7,i[a++]=u>>>8&7,i[a++]=u>>>11&7,i[a++]=u>>>14&7,i[a++]=u>>>17&7,i[a++]=u>>>20&7,i[a++]=u>>>23&7,i[a++]=u>>>26&7,i[a++]=u>>>29&7}}function FP(e,t,i,r){let a=r,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;i[a++]=o>>>0&15,i[a++]=o>>>4&15,i[a++]=o>>>8&15,i[a++]=o>>>12&15,i[a++]=o>>>16&15,i[a++]=o>>>20&15,i[a++]=o>>>24&15,i[a++]=o>>>28&15,i[a++]=l>>>0&15,i[a++]=l>>>4&15,i[a++]=l>>>8&15,i[a++]=l>>>12&15,i[a++]=l>>>16&15,i[a++]=l>>>20&15,i[a++]=l>>>24&15,i[a++]=l>>>28&15,i[a++]=u>>>0&15,i[a++]=u>>>4&15,i[a++]=u>>>8&15,i[a++]=u>>>12&15,i[a++]=u>>>16&15,i[a++]=u>>>20&15,i[a++]=u>>>24&15,i[a++]=u>>>28&15,i[a++]=h>>>0&15,i[a++]=h>>>4&15,i[a++]=h>>>8&15,i[a++]=h>>>12&15,i[a++]=h>>>16&15,i[a++]=h>>>20&15,i[a++]=h>>>24&15,i[a++]=h>>>28&15}}function RP(e,t,i,r){let a=r,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;i[a++]=o>>>0&31,i[a++]=o>>>5&31,i[a++]=o>>>10&31,i[a++]=o>>>15&31,i[a++]=o>>>20&31,i[a++]=o>>>25&31,i[a++]=(o>>>30|(l&7)<<2)&31,i[a++]=l>>>3&31,i[a++]=l>>>8&31,i[a++]=l>>>13&31,i[a++]=l>>>18&31,i[a++]=l>>>23&31,i[a++]=(l>>>28|(u&1)<<4)&31,i[a++]=u>>>1&31,i[a++]=u>>>6&31,i[a++]=u>>>11&31,i[a++]=u>>>16&31,i[a++]=u>>>21&31,i[a++]=u>>>26&31,i[a++]=(u>>>31|(h&15)<<1)&31,i[a++]=h>>>4&31,i[a++]=h>>>9&31,i[a++]=h>>>14&31,i[a++]=h>>>19&31,i[a++]=h>>>24&31,i[a++]=(h>>>29|(c&3)<<3)&31,i[a++]=c>>>2&31,i[a++]=c>>>7&31,i[a++]=c>>>12&31,i[a++]=c>>>17&31,i[a++]=c>>>22&31,i[a++]=c>>>27&31}}function kP(e,t,i,r){let a=r,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;i[a++]=o>>>0&63,i[a++]=o>>>6&63,i[a++]=o>>>12&63,i[a++]=o>>>18&63,i[a++]=o>>>24&63,i[a++]=(o>>>30|(l&15)<<2)&63,i[a++]=l>>>4&63,i[a++]=l>>>10&63,i[a++]=l>>>16&63,i[a++]=l>>>22&63,i[a++]=(l>>>28|(u&3)<<4)&63,i[a++]=u>>>2&63,i[a++]=u>>>8&63,i[a++]=u>>>14&63,i[a++]=u>>>20&63,i[a++]=u>>>26&63,i[a++]=h>>>0&63,i[a++]=h>>>6&63,i[a++]=h>>>12&63,i[a++]=h>>>18&63,i[a++]=h>>>24&63,i[a++]=(h>>>30|(c&15)<<2)&63,i[a++]=c>>>4&63,i[a++]=c>>>10&63,i[a++]=c>>>16&63,i[a++]=c>>>22&63,i[a++]=(c>>>28|(d&3)<<4)&63,i[a++]=d>>>2&63,i[a++]=d>>>8&63,i[a++]=d>>>14&63,i[a++]=d>>>20&63,i[a++]=d>>>26&63}}function LP(e,t,i,r){let a=r,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;i[a++]=o>>>0&127,i[a++]=o>>>7&127,i[a++]=o>>>14&127,i[a++]=o>>>21&127,i[a++]=(o>>>28|(l&7)<<4)&127,i[a++]=l>>>3&127,i[a++]=l>>>10&127,i[a++]=l>>>17&127,i[a++]=l>>>24&127,i[a++]=(l>>>31|(u&63)<<1)&127,i[a++]=u>>>6&127,i[a++]=u>>>13&127,i[a++]=u>>>20&127,i[a++]=(u>>>27|(h&3)<<5)&127,i[a++]=h>>>2&127,i[a++]=h>>>9&127,i[a++]=h>>>16&127,i[a++]=h>>>23&127,i[a++]=(h>>>30|(c&31)<<2)&127,i[a++]=c>>>5&127,i[a++]=c>>>12&127,i[a++]=c>>>19&127,i[a++]=(c>>>26|(d&1)<<6)&127,i[a++]=d>>>1&127,i[a++]=d>>>8&127,i[a++]=d>>>15&127,i[a++]=d>>>22&127,i[a++]=(d>>>29|(p&15)<<3)&127,i[a++]=p>>>4&127,i[a++]=p>>>11&127,i[a++]=p>>>18&127,i[a++]=p>>>25&127}}function BP(e,t,i,r){let a=r,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;i[a++]=o>>>0&255,i[a++]=o>>>8&255,i[a++]=o>>>16&255,i[a++]=o>>>24&255,i[a++]=l>>>0&255,i[a++]=l>>>8&255,i[a++]=l>>>16&255,i[a++]=l>>>24&255,i[a++]=u>>>0&255,i[a++]=u>>>8&255,i[a++]=u>>>16&255,i[a++]=u>>>24&255,i[a++]=h>>>0&255,i[a++]=h>>>8&255,i[a++]=h>>>16&255,i[a++]=h>>>24&255,i[a++]=c>>>0&255,i[a++]=c>>>8&255,i[a++]=c>>>16&255,i[a++]=c>>>24&255,i[a++]=d>>>0&255,i[a++]=d>>>8&255,i[a++]=d>>>16&255,i[a++]=d>>>24&255,i[a++]=p>>>0&255,i[a++]=p>>>8&255,i[a++]=p>>>16&255,i[a++]=p>>>24&255,i[a++]=f>>>0&255,i[a++]=f>>>8&255,i[a++]=f>>>16&255,i[a++]=f>>>24&255}}function $P(e,t,i,r){let a=r,n=t;for(let s=0;s<128;s++){let o=e[n++]>>>0;i[a++]=o&65535,i[a++]=o>>>16&65535}}function OP(e,t,i,r,a){let n=sc[a]>>>0,s=t,o=0,l=e[s]>>>0,u=r;for(let h=0;h<8;h++){for(let c=0;c<32;c++)if(o+a<=32){let d=l>>>o&n;i[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;i[u+c]=g|0,o=f}u+=32,o=0,h<7&&(l=e[s]>>>0)}}const lc=gP(e_),NP=3*lc/256+lc|0;function t_(){let e=new Uint8Array(NP);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 VP(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:t_()}}function jP(e,t){if(t<=e.encodedWords.length)return e.encodedWords;let i=new Uint32Array(Math.max(16,t*2));return e.encodedWords=i,i}function UP(e,t,i,r){r.byteContainer.length<i&&(r.byteContainer=new Uint8Array(i*2),r.byteContainerI32=void 0);let a=r.byteContainer,n=i>>>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=r.byteContainerI32;(!o||o.buffer!==a.buffer||o.byteOffset!==a.byteOffset||o.length<n)&&(o=r.byteContainerI32=new Int32Array(a.buffer,a.byteOffset,a.byteLength>>>2)),o.set(e.subarray(t,t+n))}let s=i&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 GP(e,t,i){let r=e[t++]|0,a=i.dataToBePacked;for(let n=2;n<=32;n=n+1|0){if(!(r>>>n-1&1))continue;if(t>=e.length)throw Error(`FastPFOR decode: truncated exception stream header (bitWidth=${n}, streamWordIndex=${t}, needWords=1, availableWords=${e.length-t}, encodedWords=${e.length})`);let s=e[t++]>>>0,o=mP(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)eC(e,t,u,h,n),t=t+n|0;let c=h-s|0;t=t-(c*n>>>5)|0,i.exceptionSizes[n]=s}return t}function ZP(e,t,i,r,a){switch(a){case 1:IP(e,t,i,r);break;case 2:MP(e,t,i,r);break;case 3:zP(e,t,i,r);break;case 4:FP(e,t,i,r);break;case 5:RP(e,t,i,r);break;case 6:kP(e,t,i,r);break;case 7:LP(e,t,i,r);break;case 8:BP(e,t,i,r);break;case 16:$P(e,t,i,r);break;default:OP(e,t,i,r,a)}return t+(a<<3)|0}function qP(e,t,i,r){if(i+2>t)throw Error(`FastPFOR decode: byteContainer underflow at block=${r} (need 2 bytes for [bitWidth, exceptionCount], bytePos=${i}, byteSize=${t})`);let a=e[i++],n=e[i++];if(a>32)throw Error(`FastPFOR decode: invalid bitWidth=${a} at block=${r} (expected 0..32). This likely indicates corrupted or truncated input.`);return{bitWidth:a,exceptionCount:n,bytePosIn:i}}function WP(e,t,i,r,a,n){if(i+1>t)throw Error(`FastPFOR decode: exception header underflow at block=${n} (need 1 byte for maxBits, bytePos=${i}, byteSize=${t})`);let s=e[i++];if(s<r||s>32)throw Error(`FastPFOR decode: invalid maxBits=${s} at block=${n} (bitWidth=${r}, expected ${r}..32)`);let o=s-r|0;if(o<1||o>32)throw Error(`FastPFOR decode: invalid exceptionBitWidth=${o} at block=${n} (bitWidth=${r}, maxBits=${s})`);if(i+a>t)throw Error(`FastPFOR decode: exception positions underflow at block=${n} (need=${a}, have=${t-i})`);return{maxBits:s,exceptionBitWidth:o,bytePosIn:i}}function HP(e,t,i,r,a,n,s,o,l){let{maxBits:u,exceptionBitWidth:h,bytePosIn:c}=WP(a,n,s,i,r,l);if(s=c,h===1){let g=1<<i;for(let _=0;_<r;_=_+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=${i}, maxBits=${u}) at block ${l}`);let p=o.dataPointers,f=p[h]|0,m=o.exceptionSizes[h]|0;if(f+r>m)throw Error(`FastPFOR decode: exception stream overflow for exceptionBitWidth=${h} (ptr=${f}, need ${r}, size=${m}) at block ${l}`);for(let g=0;g<r;g=g+1|0){let _=a[s++],y=d[f++]|0;e[_+t|0]|=y<<i}return p[h]=f,s}function XP(e,t,i,r,a,n,s,o,l,u){let h=i|0,c=0;for(let d=0;d<s;d=d+1|0){let p=qP(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=ZP(e,h,a,g,f)}m>0&&(c=HP(a,g,f,m,o,l,c,u,d))}if(h!==r)throw Error(`FastPFOR decode: packed region mismatch (pageStart=${t}, packedStart=${i}, consumedPackedEnd=${h}, expectedPackedEnd=${r}, packedWords=${r-i}, encoded.length=${e.length})`)}function YP(e,t,i,r,a,n){let s=i|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=UP(e,d,h,n),m=h,g=GP(e,p,n);return n.dataPointers.fill(0),XP(e,s,l,u,t,r|0,a/256|0,f,m,n),g}function KP(e,t,i,r,a,n){let s=r+oc(a,256),o=r,l=i;for(;o!==s;){let u=Math.min(lc,s-o);l=YP(e,t,l,o,u,n),o=o+u|0}return l}function JP(e,t,i,r,a,n){if(n===0)return t;let s=0,o=t,l=t+i,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)r[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}/${i}, vbyteStart=${t}, vbyteEnd=${l})`);return o}function QP(e,t,i){let r=0,a=0,n=new Uint32Array(t),s=i??t_();if(e.length>0){let u=e[r]|0;if(r=r+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})`);r=KP(e,n,r,a,u,s),a=a+u|0}let o=e.length-r|0,l=t-a|0;return JP(e,r,o,n,a,l),n}function eC(e,t,i,r,a){switch(a){case 2:yP(e,t,i,r);return;case 3:vP(e,t,i,r);return;case 4:xP(e,t,i,r);return;case 5:bP(e,t,i,r);return;case 6:wP(e,t,i,r);return;case 7:TP(e,t,i,r);return;case 8:SP(e,t,i,r);return;case 9:EP(e,t,i,r);return;case 10:PP(e,t,i,r);return;case 11:CP(e,t,i,r);return;case 12:AP(e,t,i,r);return;case 16:DP(e,t,i,r);return;case 32:for(let u=0;u<32;u=u+1|0)i[r+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;i[r+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;i[r+u]=p|0,o=a-h}}function tC(e,t,i,r){if(t<0||i<0||t+i>e.length)throw RangeError(`decodeBigEndianInt32sInto: out of bounds (offset=${t}, byteLength=${i}, bytes.length=${e.length})`);let a=Math.floor(i/4),n=i%4!=0,s=n?a+1:a;if(r.length<s)throw RangeError(`decodeBigEndianInt32sInto: out.length=${r.length} < ${s}`);if(a>0){let o=e.byteOffset+t;if(o&3)for(let l=0;l<a;l++){let u=t+l*4;r[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++)r[u]=_P(l[u])|0}}if(n){let o=t+a*4,l=i-a*4,u=0;for(let h=0;h<l;h++)u|=e[o+h]<<24-h*8;r[a]=u|0}return s}function Ct(e,t,i){let r=new Uint32Array(i),a=0,n=t.get();for(let s=0;s<r.length;s++){let o=e[n++],l=o&127;if(o<128){r[a++]=l;continue}if(o=e[n++],l|=(o&127)<<7,o<128){r[a++]=l;continue}if(o=e[n++],l|=(o&127)<<14,o<128){r[a++]=l;continue}if(o=e[n++],l|=(o&127)<<21,o<128){r[a++]=l;continue}o=e[n++],l|=(o&15)<<28,r[a++]=l}return t.set(n),r}function uc(e,t,i){let r=new BigUint64Array(i);for(let a=0;a<r.length;a++)r[a]=iC(e,t);return r}function iC(e,t){let i=0n,r=0,a=t.get();for(;a<e.length;){let n=e[a++];if(i|=BigInt(n&127)<<BigInt(r),!(n&128))break;if(r+=7,r>=64)throw Error("Varint too long")}return t.set(a),i}function rC(e,t,i){let r=new Float64Array(i);for(let a=0;a<i;a++)r[a]=aC(e,t);return r}function aC(e,t){let i,r;return r=e[t.get()],t.increment(),i=r&127,r<128||(r=e[t.get()],t.increment(),i|=(r&127)<<7,r<128)||(r=e[t.get()],t.increment(),i|=(r&127)<<14,r<128)||(r=e[t.get()],t.increment(),i|=(r&127)<<21,r<128)?i:(r=e[t.get()],i|=(r&15)<<28,nC(i,e,t))}function nC(e,t,i){let r,a;if(a=t[i.get()],i.increment(),r=(a&112)>>4,a<128||(a=t[i.get()],i.increment(),r|=(a&127)<<3,a<128)||(a=t[i.get()],i.increment(),r|=(a&127)<<10,a<128)||(a=t[i.get()],i.increment(),r|=(a&127)<<17,a<128)||(a=t[i.get()],i.increment(),r|=(a&127)<<24,a<128)||(a=t[i.get()],i.increment(),r|=(a&1)<<31,a<128))return r*4294967296+(e>>>0);throw Error("Expected varint not more than 10 bytes")}function sC(e,t,i,r){return oC(e,t,i,r,VP(i>>>2))}function oC(e,t,i,r,a){let n=r.get();if(i&3)throw Error(`FastPFOR: invalid encodedByteLength=${i} at offset=${n} (encodedBytes.length=${e.length}; expected a multiple of 4 bytes for an int32 big-endian word stream)`);let s=i>>>2,o=jP(a,s);tC(e,n,i,o);let l=QP(o.subarray(0,s),t,a.decoderWorkspace);return r.add(i),l}function we(e){return e>>>1^-(e&1)}function At(e){return e>>1n^-(e&1n)}function sa(e){return e%2==1?(e+1)/-2:e/2}function lC(e){let t=new Int32Array(e.length);for(let i=0;i<e.length;i++)t[i]=we(e[i]);return t}function uC(e){let t=new BigInt64Array(e.length);for(let i=0;i<e.length;i++)t[i]=At(e[i]);return t}function hc(e,t,i){if(i===void 0){i=0;for(let n=0;n<t;n++)i+=e[n]}let r=new Uint32Array(i),a=0;for(let n=0;n<t;n++){let s=e[n],o=e[n+t];r.fill(o,a,a+s),a+=s}return r}function cc(e,t,i){if(i===void 0){i=0;for(let n=0;n<t;n++)i+=Number(e[n])}let r=new BigUint64Array(i),a=0;for(let n=0;n<t;n++){let s=Number(e[n]),o=e[n+t];r.fill(o,a,a+s),a+=s}return r}function i_(e,t,i){let r=new Float64Array(i),a=0;for(let n=0;n<t;n++){let s=e[n],o=e[n+t];r.fill(o,a,a+s),a+=s}return r}function r_(e){let t=new Int32Array(e.length);t[0]=we(e[0]);let i=e.length/4*4,r=1;if(i>=4)for(;r<i-4;r+=4){let a=e[r],n=e[r+1],s=e[r+2],o=e[r+3];t[r]=we(a)+t[r-1],t[r+1]=we(n)+t[r],t[r+2]=we(s)+t[r+1],t[r+3]=we(o)+t[r+2]}for(;r!==e.length;++r)t[r]=we(e[r])+t[r-1];return t}function a_(e){let t=new BigInt64Array(e.length);t[0]=At(e[0]);let i=e.length/4*4,r=1;if(i>=4)for(;r<i-4;r+=4){let a=e[r],n=e[r+1],s=e[r+2],o=e[r+3];t[r]=At(a)+t[r-1],t[r+1]=At(n)+t[r],t[r+2]=At(s)+t[r+1],t[r+3]=At(o)+t[r+2]}for(;r!==t.length;++r)t[r]=At(e[r])+t[r-1];return t}function hC(e){e[0]=sa(e[0]);let t=e.length/4*4,i=1;if(t>=4)for(;i<t-4;i+=4){let r=e[i],a=e[i+1],n=e[i+2],s=e[i+3];e[i]=sa(r)+e[i-1],e[i+1]=sa(a)+e[i],e[i+2]=sa(n)+e[i+1],e[i+3]=sa(s)+e[i+2]}for(;i!==e.length;++i)e[i]=sa(e[i])+e[i-1]}function cC(e,t,i){if(i===void 0){i=0;for(let n=0;n<t;n++)i+=e[n]}let r=new Int32Array(i),a=0;for(let n=0;n<t;n++){let s=e[n],o=e[n+t];o=we(o),r.fill(o,a,a+s),a+=s}return r}function dC(e,t,i){if(i===void 0){i=0;for(let n=0;n<t;n++)i+=Number(e[n])}let r=new BigInt64Array(i),a=0;for(let n=0;n<t;n++){let s=Number(e[n]),o=e[n+t];o=At(o),r.fill(o,a,a+s),a+=s}return r}function pC(e,t,i){let r=new Float64Array(i),a=0;for(let n=0;n<t;n++){let s=e[n],o=e[n+t];o=sa(o),r.fill(o,a,a+s),a+=s}return r}function dc(e){let t=e.length/4*4,i=1;if(t>=4)for(let r=e[0];i<t-4;i+=4)r=e[i]+=r,r=e[i+1]+=r,r=e[i+2]+=r,r=e[i+3]+=r;for(;i!==e.length;)e[i]+=e[i-1],++i}function fC(e){let t=0;for(let i=0;i<e.length;i++)e[i]+=t,t=e[i]}function mC(e){if(e.length<2)return new Int32Array(e);let t=new Int32Array(e.length);t[0]=we(e[0]),t[1]=we(e[1]);let i=e.length/4*4,r=2;if(i>=4)for(;r<i-4;r+=4){let a=e[r],n=e[r+1],s=e[r+2],o=e[r+3];t[r]=we(a)+t[r-2],t[r+1]=we(n)+t[r-1],t[r+2]=we(s)+t[r],t[r+3]=we(o)+t[r+1]}for(;r!==e.length;r+=2)t[r]=we(e[r])+t[r-2],t[r+1]=we(e[r+1])+t[r-1];return t}function gC(e){let t=new Int32Array(e.length+1);t[0]=0,t[1]=we(e[0]);let i=t[1];for(let r=2;r!==t.length;++r){let a=e[r-1],n=we(a);i+=n,t[r]=t[r-1]+i}return new Uint32Array(t)}function _C(e,t,i){let r=new Int32Array(i+1);r[0]=0;let a=1,n=r[0];for(let s=0;s<t;s++){let o=e[s],l=e[s+t];l=we(l);for(let u=a;u<a+o;u++)r[u]=l+n,n=r[u];a+=o}return r}function yC(e,t,i){let r=new Uint32Array(i+1);r[0]=0;let a=1,n=r[0];for(let s=0;s<t;s++){let o=e[s],l=e[s+t];for(let u=a;u<a+o;u++)r[u]=l+n,n=r[u];a+=o}return r}function vC(e,t,i){let r=new Int32Array(i),a=0,n=0;for(let s=0;s<t;s++){let o=e[s],l=e[s+t],u=we(l);for(let h=0;h<o;h++)n+=u,r[a++]=n}return r}function xC(e,t,i){let r=new BigInt64Array(i),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,r[a++]=n}return r}function n_(e){let t=new Uint32Array(e.length);t[0]=we(e[0])>>>0;for(let i=1;i<e.length;i++)t[i]=t[i-1]+we(e[i])>>>0;return t}function s_(e){let t=new BigUint64Array(e.length);t[0]=BigInt.asUintN(64,At(e[0]));for(let i=1;i<e.length;i++)t[i]=BigInt.asUintN(64,t[i-1]+At(e[i]));return t}function bC(e){if(e.length<2)return new Uint32Array(e);let t=new Uint32Array(e.length);t[0]=we(e[0])>>>0,t[1]=we(e[1])>>>0;for(let i=2;i<e.length;i+=2)t[i]=t[i-2]+we(e[i])>>>0,t[i+1]=t[i-1]+we(e[i+1])>>>0;return t}function wC(e){return e[1]}function TC(e){return we(e[1])}function SC(e){if(e.length===2){let t=we(e[1]);return[t,t]}return[we(e[2]),we(e[3])]}function EC(e){return e[1]}function PC(e){return At(e[1])}function CC(e){if(e.length===2){let t=At(e[1]);return[t,t]}return[At(e[2]),At(e[3])]}var at;(function(e){e.PRESENT="PRESENT",e.DATA="DATA",e.OFFSET="OFFSET",e.LENGTH="LENGTH"})(at||(at={}));var Vt;(function(e){e.NONE="NONE",e.SINGLE="SINGLE",e.SHARED="SHARED",e.VERTEX="VERTEX",e.MORTON="MORTON",e.FSST="FSST"})(Vt||(Vt={}));var sr;(function(e){e.VERTEX="VERTEX",e.INDEX="INDEX",e.STRING="STRING",e.KEY="KEY"})(sr||(sr={}));var ft;(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"})(ft||(ft={}));const AC=[at.PRESENT,at.DATA,at.OFFSET,at.LENGTH],o_=[ae.NONE,ae.DELTA,ae.COMPONENTWISE_DELTA,ae.RLE,ae.MORTON],DC=[yi.NONE,yi.FAST_PFOR,yi.VARINT],IC=[Vt.NONE,Vt.SINGLE,Vt.SHARED,Vt.VERTEX,Vt.MORTON,Vt.FSST],MC=[sr.VERTEX,sr.INDEX,sr.STRING,sr.KEY],zC=[ft.VAR_BINARY,ft.GEOMETRIES,ft.PARTS,ft.RINGS,ft.TRIANGLES,ft.SYMBOL,ft.DICTIONARY];function Ve(e,t){let i=kC(e,t);return i.logicalLevelTechnique1===ae.MORTON?FC(i,e,t):(ae.RLE===i.logicalLevelTechnique1||ae.RLE===i.logicalLevelTechnique2)&&yi.NONE!==i.physicalLevelTechnique?RC(i,e,t):i}function FC(e,t,i){let r=Ct(t,i,2);return{physicalStreamType:e.physicalStreamType,logicalStreamType:e.logicalStreamType,logicalLevelTechnique1:e.logicalLevelTechnique1,logicalLevelTechnique2:e.logicalLevelTechnique2,physicalLevelTechnique:e.physicalLevelTechnique,numValues:e.numValues,byteLength:e.byteLength,decompressedCount:e.decompressedCount,numBits:r[0],coordinateShift:r[1]}}function RC(e,t,i){let r=Ct(t,i,2);return{physicalStreamType:e.physicalStreamType,logicalStreamType:e.logicalStreamType,logicalLevelTechnique1:e.logicalLevelTechnique1,logicalLevelTechnique2:e.logicalLevelTechnique2,physicalLevelTechnique:e.physicalLevelTechnique,numValues:e.numValues,byteLength:e.byteLength,decompressedCount:r[1],runs:r[0],numRleValues:r[1]}}function kC(e,t){let i=e[t.get()],r=AC[i>>4],a={};switch(r){case at.DATA:a={dictionaryType:IC[i&15]};break;case at.OFFSET:a={offsetType:MC[i&15]};break;case at.LENGTH:a={lengthType:zC[i&15]}}t.increment();let n=e[t.get()],s=o_[n>>5],o=o_[n>>2&7],l=DC[n&3];t.increment();let u=Ct(e,t,2),h=u[0],c=u[1];return{physicalStreamType:r,logicalStreamType:a,logicalLevelTechnique1:s,logicalLevelTechnique2:o,physicalLevelTechnique:l,numValues:h,byteLength:c,decompressedCount:h}}var Le;(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"})(Le||(Le={}));var Ii=class{constructor(e,t){this.values=e,this._size=t}get(e){let t=Math.floor(e/8),i=e%8;return(this.values[t]>>i&1)==1}set(e,t){let i=Math.floor(e/8),r=e%8;this.values[i]=this.values[i]|+!!t<<r}getInt(e){let t=Math.floor(e/8),i=e%8;return this.values[t]>>i&1}size(){return this._size}getBuffer(){return this.values}};function oa(e,t,i){if(!t)return e;let r=t.size(),a=e.constructor,n=new a(r),s=0;for(let o=0;o<r;o++)n[o]=t.get(o)?e[s++]:i;return n}function LC(e,t,i){if(!i)return e;let r=i.size(),a=new Ii(e,t),n=new Ii(new Uint8Array(Math.ceil(r/8)),r),s=0;for(let o=0;o<r;o++){let l=i.get(o)?a.get(s++):!1;n.set(o,l)}return n.getBuffer()}function Wa(e,t,i,r,a){let n=BC(e,Math.ceil(t/8),i,r);return a?LC(n,t,a):n}function BC(e,t,i,r){let a=new Uint8Array(t),n=0,s=r.get()+i;for(;n<t&&!(r.get()>=s);){let o=e[r.increment()];if(o<=127){let l=o+3,u=e[r.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[r.increment()]}}return r.set(s),a}function l_(e,t,i,r){let a=t.get(),n=a+i*Float32Array.BYTES_PER_ELEMENT,s=new Uint8Array(e.subarray(a,n)).buffer,o=new Float32Array(s);return t.set(n),r?oa(o,r,0):o}function u_(e,t,i,r){let a=t.get(),n=a+i*Float64Array.BYTES_PER_ELEMENT,s=new Uint8Array(e.subarray(a,n)).buffer,o=new Float64Array(s);return t.set(n),r?oa(o,r,0):o}function $C(e,t,i){let r=t.get(),a=i*Uint32Array.BYTES_PER_ELEMENT,n=new DataView(e.buffer,e.byteOffset,e.byteLength),s=new Uint32Array(i);for(let o=0;o<i;o++)s[o]=n.getUint32(r+o*Uint32Array.BYTES_PER_ELEMENT,!0);return t.add(a),s}function OC(e,t,i){let r=t.get(),a=i*BigUint64Array.BYTES_PER_ELEMENT,n=new DataView(e.buffer,e.byteOffset,e.byteLength),s=new BigUint64Array(i);for(let o=0;o<i;o++)s[o]=n.getBigUint64(r+o*BigUint64Array.BYTES_PER_ELEMENT,!0);return t.add(a),s}const NC=new TextDecoder;function pc(e,t,i){return i-t>=12?NC.decode(e.subarray(t,i)):VC(e,t,i)}function VC(e,t,i){let r="",a=t;for(;a<i;){let n=e[a],s=null,o=n>239?4:n>223?3:n>191?2:1;if(a+o>i)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,r+=String.fromCharCode(s>>>10&1023|55296),s=56320|s&1023),r+=String.fromCharCode(s),a+=o}return r}function il(e,t,i,r,a){return qC(Ha(e,t,i),i,r,a)}function Dt(e,t,i,r,a){return WC(Ha(e,t,i),i,r,a)}function Ir(e,t,i){return YC(Ha(e,t,i),i)}function Ha(e,t,i){let r=i.physicalLevelTechnique;switch(r){case yi.FAST_PFOR:return sC(e,i.numValues,i.byteLength,t);case yi.VARINT:return Ct(e,t,i.numValues);case yi.NONE:return $C(e,t,i.numValues);default:throw Error(`Specified physicalLevelTechnique ${r} is not supported (yet).`)}}function as(e,t,i){let r=i.physicalLevelTechnique;switch(r){case yi.VARINT:return uc(e,t,i.numValues);case yi.NONE:return OC(e,t,i.numValues);default:throw Error(`Specified physicalLevelTechnique ${r} is not supported (yet).`)}}function jC(e,t,i){let r=Ha(e,t,i);return r.length===1?we(r[0]):TC(r)}function fc(e,t,i){let r=Ha(e,t,i);return r.length===1?i.logicalLevelTechnique1===ae.DELTA?we(r[0]):r[0]:wC(r)}function h_(e,t,i){return SC(Ha(e,t,i))}function c_(e,t,i){return CC(uc(e,t,i.numValues))}function d_(e,t,i,r){return HC(as(e,t,i),i,r)}function mc(e,t,i,r){return f_(as(e,t,i),i,r)}function UC(e,t,i,r){let a=GC(e,t,i,!1);return r?oa(a,r,0):a}function GC(e,t,i,r){if(i.physicalLevelTechnique===yi.VARINT)return XC(rC(e,t,i.numValues),i,r);let a=as(e,t,i),n=f_(a,i);return Float64Array.from(n,Number)}function ZC(e,t,i){let r=as(e,t,i);return r.length===1?At(r[0]):PC(r)}function p_(e,t,i){let r=as(e,t,i);return r.length===1?i.logicalLevelTechnique1===ae.DELTA?At(r[0]):r[0]:EC(r)}function qC(e,t,i,r){let a;switch(t.logicalLevelTechnique1){case ae.DELTA:if(t.logicalLevelTechnique2===ae.RLE){let n=t;if(!r)return vC(e,n.runs,n.numRleValues);e=hc(e,n.runs,n.numRleValues),a=r_(e)}else a=r_(e);break;case ae.RLE:a=cC(e,t.runs,t.numRleValues);break;case ae.MORTON:dc(e),a=new Int32Array(e);break;case ae.COMPONENTWISE_DELTA:a=mC(e);break;case ae.NONE:a=lC(e);break;default:throw Error(`The specified Logical level technique is not supported: ${t.logicalLevelTechnique1}`)}return r?oa(a,r,0):a}function WC(e,t,i,r){let a;switch(t.logicalLevelTechnique1){case ae.DELTA:if(t.logicalLevelTechnique2===ae.RLE){let n=t;a=n_(hc(e,n.runs,n.numRleValues))}else a=n_(e);break;case ae.RLE:a=hc(e,t.runs,t.numRleValues);break;case ae.MORTON:dc(e),a=e;break;case ae.COMPONENTWISE_DELTA:a=bC(e);break;case ae.NONE:a=e;break;default:throw Error(`The specified Logical level technique is not supported: ${t.logicalLevelTechnique1}`)}return r?oa(a,r,0):a}function HC(e,t,i){let r;switch(t.logicalLevelTechnique1){case ae.DELTA:if(t.logicalLevelTechnique2===ae.RLE){let a=t;if(!i)return xC(e,a.runs,a.numRleValues);e=cc(e,a.runs,a.numRleValues),r=a_(e)}else r=a_(e);break;case ae.RLE:r=dC(e,t.runs,t.numRleValues);break;case ae.NONE:r=uC(e);break;default:throw Error(`The specified Logical level technique is not supported: ${t.logicalLevelTechnique1}`)}return i?oa(r,i,0n):r}function f_(e,t,i){let r;switch(t.logicalLevelTechnique1){case ae.DELTA:if(t.logicalLevelTechnique2===ae.RLE){let a=t;r=s_(cc(e,a.runs,a.numRleValues))}else r=s_(e);break;case ae.RLE:r=cc(e,t.runs,t.numRleValues);break;case ae.NONE:r=e;break;default:throw Error(`The specified Logical level technique is not supported: ${t.logicalLevelTechnique1}`)}return i?oa(r,i,0n):r}function XC(e,t,i){switch(t.logicalLevelTechnique1){case ae.DELTA:if(t.logicalLevelTechnique2===ae.RLE){let r=t;e=i_(e,r.runs,r.numRleValues)}return hC(e),e;case ae.RLE:return JC(e,t,i);case ae.NONE:return e;default:throw Error(`The specified Logical level technique is not supported: ${t.logicalLevelTechnique1}`)}}function YC(e,t){if(t.logicalLevelTechnique1===ae.DELTA&&t.logicalLevelTechnique2===ae.NONE)return gC(e);if(t.logicalLevelTechnique1===ae.RLE&&t.logicalLevelTechnique2===ae.NONE){let i=t;return yC(e,i.runs,i.numRleValues)}if(t.logicalLevelTechnique1===ae.NONE&&t.logicalLevelTechnique2===ae.NONE){fC(e);let i=new Uint32Array(t.numValues+1);return i[0]=0,i.set(e,1),i}if(t.logicalLevelTechnique1===ae.DELTA&&t.logicalLevelTechnique2===ae.RLE){let i=t,r=_C(e,i.runs,i.numRleValues);return dc(r),new Uint32Array(r)}throw Error("Only delta encoding is supported for transforming length to offset streams yet.")}function rl(e,t,i,r,a="int32"){let n=e.logicalLevelTechnique1;if(n===ae.RLE)return e.runs===1?Le.CONST:Le.FLAT;if(n!==ae.DELTA||e.logicalLevelTechnique2!==ae.RLE)return e.numValues===1?Le.CONST:Le.FLAT;let s=t instanceof Ii?t.size():t,o=e;if(o.numRleValues!==s)return Le.FLAT;if(o.runs===1)return Le.SEQUENCE;if(o.runs!==2)return e.numValues===1?Le.CONST:Le.FLAT;let l=r.get();if(e.physicalLevelTechnique===yi.VARINT)return KC(i,r,a)?Le.SEQUENCE:e.numValues===1?Le.CONST:Le.FLAT;let u=r.get(),h=new Int32Array(i.buffer,i.byteOffset+u,4);return r.set(l),h[2]===2&&h[3]===2?Le.SEQUENCE:e.numValues===1?Le.CONST:Le.FLAT}function KC(e,t,i){let r=new Qg(t.get());if(i==="int64"){let n=uc(e,r,4);return n[2]===2n&&n[3]===2n}let a=Ct(e,r,4);return a[2]===2&&a[3]===2}function JC(e,t,i){return i?pC(e,t.runs,t.numRleValues):i_(e,t.runs,t.numRleValues)}var m_=class extends tl{getValueFromBuffer(e){return this.dataBuffer[e]}},g_=class extends Kg{constructor(e,t,i,r,a){super(e,a?BigInt64Array.of(t):BigUint64Array.of(t),i,r)}getValueFromBuffer(e){return this.dataBuffer[0]+BigInt(e)*this.delta}};function gc(e,t,i){return{x:__(e,t)-i,y:__(e>>1,t)-i}}function __(e,t){let i=0;for(let r=0;r<t;r++)i|=(e&1<<2*r)>>r;return i}var It;(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"})(It||(It={}));var QC;(function(e){e[e.POINT=0]="POINT",e[e.LINESTRING=1]="LINESTRING",e[e.POLYGON=2]="POLYGON"})(QC||(QC={}));var la;(function(e){e[e.MORTON=0]="MORTON",e[e.VEC_2=1]="VEC_2",e[e.VEC_3=2]="VEC_3"})(la||(la={}));function eA(e){let t=Array(e.numGeometries),i=1,r=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 It.POINT:{let x,v;if(f)x=g[s++],v=g[s++];else if(e.vertexBufferType===la.MORTON){let w=g[p[o++]],b=gc(w,l.numBits,l.coordinateShift);x=b.x,v=b.y}else{let w=p[o++]*2;x=g[w],v=g[w+1]}t[n++]=[[new C(x,v)]],h&&a++,c&&i++,d&&r++}break;case It.MULTIPOINT:{let x=h[a]-h[a-1];a++;let v;if(f){v=Array(x);for(let w=0;w<x;w++){let b=g[s++],T=g[s++];v[w]=new C(b,T)}}else v=ua(e.vertexBufferType,g,p,o,x,!1,l),o+=x;t[n++]=v.map(w=>[w]),i+=x,r+=x}break;case It.LINESTRING:{let x;m?(x=d[r]-d[r-1],r++):x=c[i]-c[i-1],i++;let v;f?(v=Xa(g,s,x,!1),s+=x*2):(v=ua(e.vertexBufferType,g,p,o,x,!1,l),o+=x),t[n++]=[v],h&&a++}break;case It.POLYGON:{let x=c[i]-c[i-1];i++;let v=Array(x-1),w,b=d[r]-d[r-1];if(r++,f){w=Xa(g,s,b,!0),s+=b*2;for(let T=0;T<v.length;T++)b=d[r]-d[r-1],r++,v[T]=Xa(g,s,b,!0),s+=b*2}else{w=ua(e.vertexBufferType,g,p,o,b,!0,l),o+=b;for(let T=0;T<v.length;T++)b=d[r]-d[r-1],r++,v[T]=ua(e.vertexBufferType,g,p,o,b,!0,l),o+=b}t[n++]=[w].concat(v),h&&a++}break;case It.MULTILINESTRING:{let x=h[a]-h[a-1];a++;let v=Array(x);for(let w=0;w<x;w++){let b;if(m?(b=d[r]-d[r-1],r++):b=c[i]-c[i-1],i++,f)v[w]=Xa(g,s,b,!1),s+=b*2;else{let T=ua(e.vertexBufferType,g,p,o,b,!1,l);v[w]=T,o+=b}}t[n++]=v}break;case It.MULTIPOLYGON:{let x=h[a]-h[a-1];a++;let v=Array(x);for(let w=0;w<x;w++){let b=c[i]-c[i-1];i++;let T,P=Array(b-1),S=d[r]-d[r-1];r++,f?(T=Xa(g,s,S,!0),s+=S*2):(T=ua(e.vertexBufferType,g,p,o,S,!0,l),o+=S);for(let M=0;M<P.length;M++){let F=d[r]-d[r-1];r++,f?(P[M]=Xa(g,s,F,!0),s+=F*2):(P[M]=ua(e.vertexBufferType,g,p,o,F,!0,l),o+=F)}v[w]=[T].concat(P)}t[n++]=v.flat()}break;default:throw Error(`The specified geometry type (${y}) is currently not supported.`)}}return t}function ua(e,t,i,r,a,n,s){return e===la.MORTON?iA(t,i,r,a,n,s):tA(t,i,r,a,n)}function Xa(e,t,i,r){let a=Array(r?i+1:i);for(let n=0;n<i*2;n+=2){let s=e[t+n],o=e[t+n+1];a[n/2]=new C(s,o)}return r&&(a[a.length-1]=a[0]),a}function tA(e,t,i,r,a){let n=Array(a?r+1:r);for(let s=0;s<r*2;s+=2){let o=t[i+s/2]*2,l=e[o],u=e[o+1];n[s/2]=new C(l,u)}return a&&(n[n.length-1]=n[0]),n}function iA(e,t,i,r,a,n){let s=Array(a?r+1:r);for(let o=0;o<r;o++){let l=e[t[i+o]],u=gc(l,n.numBits,n.coordinateShift);s[o]=new C(u.x,u.y)}return a&&(s[s.length-1]=s[0]),s}var y_=class{constructor(e,t,i,r,a){this._vertexBufferType=e,this._topologyVector=t,this._vertexOffsets=i,this._vertexBuffer=r,this._mortonSettings=a}get vertexBufferType(){return this._vertexBufferType}get topologyVector(){return this._topologyVector}get vertexOffsets(){return this._vertexOffsets}get vertexBuffer(){return this._vertexBuffer}getSimpleEncodedVertex(e){let t=this.vertexOffsets?this.vertexOffsets[e]*2:e*2;return[this.vertexBuffer[t],this.vertexBuffer[t+1]]}getVertex(e){if(this.vertexOffsets&&this.mortonSettings){let i=this.vertexOffsets[e],r=this.vertexBuffer[i],a=gc(r,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 eA(this)}get mortonSettings(){return this._mortonSettings}};function rA(e,t,i,r,a){return new v_(e,t,la.VEC_2,i,r,a)}function aA(e,t,i,r,a,n){return new v_(e,t,la.MORTON,i,r,a,n)}var v_=class extends y_{constructor(e,t,i,r,a,n,s){super(i,r,a,n,s),this._numGeometries=e,this._geometryType=t}geometryType(e){return this._geometryType}get numGeometries(){return this._numGeometries}containsPolygonGeometry(){return this._geometryType===It.POLYGON||this._geometryType===It.MULTIPOLYGON}containsSingleGeometryType(){return!0}};function x_(e,t,i,r){return new b_(la.VEC_2,e,t,i,r)}function nA(e,t,i,r,a){return new b_(la.MORTON,e,t,i,r,a)}var b_=class extends y_{constructor(e,t,i,r,a,n){super(e,i,r,a,n),this._geometryTypes=t}geometryType(e){return this._geometryTypes[e]}get numGeometries(){return this._geometryTypes.length}containsPolygonGeometry(){for(let e=0;e<this.numGeometries;e++)if(this.geometryType(e)===It.POLYGON||this.geometryType(e)===It.MULTIPOLYGON)return!0;return!1}containsSingleGeometryType(){return!1}},w_=class{constructor(e,t,i,r){this._triangleOffsets=e,this._indexBuffer=t,this._vertexBuffer=i,this._topologyVector=r}get triangleOffsets(){return this._triangleOffsets}get indexBuffer(){return this._indexBuffer}get vertexBuffer(){return this._vertexBuffer}get topologyVector(){return this._topologyVector}getGeometries(){if(!this._topologyVector)throw Error("Cannot convert GpuVector to coordinates without topology information");let e=new Uint32Array(this.numGeometries);for(let t=0;t<this.numGeometries;t++)e[t]=this.geometryType(t);return x_(e,this._topologyVector,void 0,this._vertexBuffer).getGeometries()}[Symbol.iterator](){return null}};function T_(e,t,i,r,a,n){return new sA(e,t,i,r,a,n)}var sA=class extends w_{constructor(e,t,i,r,a,n){super(i,r,a,n),this._numGeometries=e,this._geometryType=t}geometryType(e){return this._geometryType}get numGeometries(){return this._numGeometries}containsSingleGeometryType(){return!0}};function S_(e,t,i,r,a){return new oA(e,t,i,r,a)}var oA=class extends w_{constructor(e,t,i,r,a){super(t,i,r,a),this._geometryTypes=e}geometryType(e){return this._geometryTypes[e]}get numGeometries(){return this._geometryTypes.length}containsSingleGeometryType(){return!1}};function lA(e,t,i,r,a){let n=Ve(e,i),s=rl(n,r,e,i),o,l,u,h;if(s===Le.CONST){let x=fc(e,i,n),v,w,b,T;for(let P=0;P<t-1;P++){let S=Ve(e,i);switch(S.physicalStreamType){case at.LENGTH:switch(S.logicalStreamType.lengthType){case ft.GEOMETRIES:v=Ir(e,i,S);break;case ft.PARTS:w=Ir(e,i,S);break;case ft.RINGS:b=Ir(e,i,S);break;case ft.TRIANGLES:T=Ir(e,i,S)}break;case at.OFFSET:switch(S.logicalStreamType.offsetType){case sr.VERTEX:o=Dt(e,i,S);break;case sr.INDEX:h=Dt(e,i,S)}break;case at.DATA:if(Vt.VERTEX===S.logicalStreamType.dictionaryType)l=il(e,i,S,a);else{let M=S;u={numBits:M.numBits,coordinateShift:M.coordinateShift},l=Dt(e,i,S,a)}}}return h?v!==void 0||w!==void 0?T_(r,x,T,h,l,{geometryOffsets:v,partOffsets:w,ringOffsets:b}):T_(r,x,T,h,l):u===void 0?rA(r,x,{geometryOffsets:v,partOffsets:w,ringOffsets:b},o,l):aA(r,x,{geometryOffsets:v,partOffsets:w,ringOffsets:b},o,l,u)}let c=Dt(e,i,n),d,p,f,m;for(let x=0;x<t-1;x++){let v=Ve(e,i);switch(v.physicalStreamType){case at.LENGTH:switch(v.logicalStreamType.lengthType){case ft.GEOMETRIES:d=Dt(e,i,v);break;case ft.PARTS:p=Dt(e,i,v);break;case ft.RINGS:f=Dt(e,i,v);break;case ft.TRIANGLES:m=Ir(e,i,v)}break;case at.OFFSET:switch(v.logicalStreamType.offsetType){case sr.VERTEX:o=Dt(e,i,v);break;case sr.INDEX:h=Dt(e,i,v)}break;case at.DATA:if(Vt.VERTEX===v.logicalStreamType.dictionaryType)l=il(e,i,v,a);else{let w=v;u={numBits:w.numBits,coordinateShift:w.coordinateShift},l=Dt(e,i,v,a)}}}let g,_,y;return d?(g=_c(c,d,2),p&&f?(_=E_(c,g,p,!1),y=hA(c,g,_,f)):p&&(_=uA(c,g,p))):p&&f?(_=_c(c,p,1),y=E_(c,_,f,!0)):p&&(_=_c(c,p,0)),h&&!_?S_(c,m,h,l):h?S_(c,m,h,l,{geometryOffsets:g,partOffsets:_,ringOffsets:y}):u===void 0?x_(c,{geometryOffsets:g,partOffsets:_,ringOffsets:y},o,l):nA(c,{geometryOffsets:g,partOffsets:_,ringOffsets:y},o,l,u)}function _c(e,t,i){let r=new Uint32Array(e.length+1),a=0;r[0]=a;let n=0;for(let s=0;s<e.length;s++)a=r[s+1]=a+(e[s]>i?t[n++]:1);return r}function E_(e,t,i,r){let a=new Uint32Array(t[t.length-1]+1),n=0;a[0]=n;let s=1,o=0;for(let l=0;l<e.length;l++){let u=e[l],h=t[l+1]-t[l];if(u===5||u===2||r&&(u===4||u===1))for(let c=0;c<h;c++)n=a[s++]=n+i[o++];else for(let c=0;c<h;c++)a[s++]=++n}return a}function uA(e,t,i){let r=new Uint32Array(t[t.length-1]+1),a=0;r[0]=a;let n=1,s=0;for(let o=0;o<e.length;o++){let l=e[o],u=t[o+1]-t[o];if(l===4||l===1)for(let h=0;h<u;h++)a=r[n++]=a+i[s++];else for(let h=0;h<u;h++)r[n++]=++a}return r}function hA(e,t,i,r){let a=new Uint32Array(i[i.length-1]+1),n=0;a[0]=n;let s=1,o=1,l=0;for(let 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=i[s]-i[s-1];s++;for(let f=0;f<p;f++)n=a[o++]=n+r[l++]}else for(let d=0;d<c;d++)a[o++]=++n,s++}return a}var cA=class extends na{constructor(e,t,i){super(e,t.getBuffer(),i),this.dataVector=t}getValueFromBuffer(e){return this.dataVector.get(e)}},dA=class extends tl{getValueFromBuffer(e){return this.dataBuffer[e]}},P_=class extends na{constructor(e,t,i,r){super(e,r?BigInt64Array.of(t):BigUint64Array.of(t),i)}getValueFromBuffer(e){return this.dataBuffer[0]}},yc=class extends na{constructor(e,t,i,r){super(e,i,r),this.offsetBuffer=t}},C_=class extends yc{constructor(e,t,i,r){super(e,t,i,r??t.length-1)}getValueFromBuffer(e){let t=this.offsetBuffer[e],i=this.offsetBuffer[e+1];return pc(this.dataBuffer,t,i)}},Ya=class extends yc{constructor(e,t,i,r,a){super(e,i,r,a??t.length),this.indexBuffer=t,this.indexBuffer=t}getValueFromBuffer(e){let t=this.indexBuffer[e],i=this.offsetBuffer[t],r=this.offsetBuffer[t+1];return pc(this.dataBuffer,i,r)}};function pA(e,t){let i=0;for(let r=0;r<t.length;r++){let a=t[r];a===255?(i++,r++):i+=e[a]}return i}function fA(e,t,i){let r=new Uint32Array(t.length);for(let s=1;s<t.length;s++)r[s]=r[s-1]+t[s-1];let a=new Uint8Array(pA(t,i)),n=0;for(let s=0;s<i.length;s++){let o=i[s];if(o===255)s++,a[n++]=i[s];else{let l=t[o],u=r[o];for(;l-- >0;)a[n++]=e[u++]}}return a}var A_=class extends yc{constructor(e,t,i,r,a,n,s,o){super(e,i,r,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],i=this.offsetBuffer[t],r=this.offsetBuffer[t+1];return pc(this.decodedDictionary,i,r)}decodeDictionary(){return this.symbolLengthBuffer??(this.symbolLengthBuffer=this.offsetToLengthBuffer(this.symbolOffsetBuffer)),fA(this.symbolTableBuffer,this.symbolLengthBuffer,this.dataBuffer)}offsetToLengthBuffer(e){let t=new Uint32Array(e.length-1),i=e[0];for(let r=1;r<e.length;r++){let a=e[r];t[r-1]=a-i,i=a}return t}};function D_(e,t,i,r,a){let n,s,o,l,u,h=a,c,d;for(let p=0;p<r;p++){let f=Ve(t,i);switch(f.physicalStreamType){case at.PRESENT:{let m=new Ii(Wa(t,f.numValues,f.byteLength,i),f.numValues);h=a??m;break}case at.OFFSET:s=Dt(t,i,f,void 0,h);break;case at.LENGTH:{let m=Ir(t,i,f);ft.DICTIONARY===f.logicalStreamType.lengthType?n=m:ft.SYMBOL===f.logicalStreamType.lengthType?l=m:c=m;break}case at.DATA:{let m=t.subarray(i.get(),i.get()+f.byteLength);i.add(f.byteLength);let g=f.logicalStreamType.dictionaryType;Vt.FSST===g?u=m:Vt.SINGLE===g||Vt.SHARED===g?o=m:Vt.NONE===g&&(d=m);break}}}return mA(e,u,s,n,o,l,h)??gA(e,o,s,n,h)??_A(e,c,d,s,h)}function mA(e,t,i,r,a,n,s){if(t){if(!i||!r||!a||!n)throw Error(`Incomplete FSST dictionary string column "${e}"`);return new A_(e,i,r,a,n,t,s)}}function gA(e,t,i,r,a){if(t){if(!i||!r)throw Error(`Incomplete dictionary string column "${e}"`);return a?new Ya(e,i,r,t,a):new Ya(e,i,r,t)}}function _A(e,t,i,r,a){if(t&&i){if(r)return a?new Ya(e,r,t,i,a):new Ya(e,r,t,i);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 Ya(e,n,t,i,a)}return a?new C_(e,t,i,a):new C_(e,t,i)}}function yA(e,t,i,r){let a,n,s,o,l=!1;for(;!l;){let p=Ve(e,t);switch(p.physicalStreamType){case at.LENGTH:ft.DICTIONARY===p.logicalStreamType.lengthType?a=Ir(e,t,p):s=Ir(e,t,p);break;case at.DATA:Vt.SINGLE===p.logicalStreamType.dictionaryType||Vt.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(i.type!=="complexType")throw Error(`Shared dictionary column ${i.name} must be a complex (struct) column.`);if(!a||!n)throw Error(`Incomplete shared dictionary for column "${i.name}"`);let u=i.complexType.children,h=[],c=o?{}:void 0,d=0;for(let p of u){let f=Ct(e,t,1)[0];if(f===0)continue;let m=p.name?`${i.name}${p.name}`:i.name;if(p.type!=="scalarField"||p.scalarField.physicalType!==me.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=Ve(e,t);g=new Ii(Wa(e,y.numValues,y.byteLength,t),y.numValues)}let _=Dt(e,t,Ve(e,t),void 0,g);if(o){if(!s)throw Error(`Incomplete shared FSST dictionary for column "${m}"`);h[d++]=new A_(m,_,a,n,s,o,g,c)}else h[d++]=new Ya(m,_,a,n,g)}return h}var I_=class extends na{constructor(e,t,i){super(e,new Uint8Array,i??t.length),this.values=t}getValueFromBuffer(e){return this.values[e]}},or;(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"})(or||(or={}));var ha;(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"})(ha||(ha={}));function vA(e,t,i,r){let a=xA(i);if(r===0)return a.map(h=>new I_(h,[]));let n=bA(e,t,r),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=PA(n,h,s,l,u);o.push(new I_(a[h],c.value,c.nullabilityBuffer)),l=c.countsEnd,u=c.valuesEnd}return o}function xA(e){let t=e.type==="complexType"?e.complexType.children:void 0;return!t||t.length===0?[e.name]:t.map(i=>e.name+(i.name??""))}function bA(e,t,i){let r=e[t.get()];t.add(1);let a=Dt(e,t,Ve(e,t)),n=i-1,s=[];r&or.STRING&&(n-=wA(e,t,s)),n-=TA(e,t,r,s),n-=SA(e,t,r,s);let o,l=0;if(r&or.PRESENCE){let h=EA(e,t);o=h.value,l=h.count,n--}let u=new Uint32Array;if(n>0&&(u=Dt(e,t,Ve(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 wA(e,t,i){let r=e[t.get()];t.add(1);let a=D_("",e,t,r);if(a)for(let n=0;n<a.size;n++)i.push(a.getValue(n));return r}function TA(e,t,i,r){let a=0;return i&or.INT32?(Ka(r,il(e,t,Ve(e,t))),a++):i&or.INT64&&(Ka(r,d_(e,t,Ve(e,t))),a++),i&or.UINT32?(Ka(r,Dt(e,t,Ve(e,t))),a++):i&or.UINT64&&(Ka(r,mc(e,t,Ve(e,t))),a++),a}function SA(e,t,i,r){let a=0;return i&or.FLOAT&&(Ka(r,l_(e,t,Ve(e,t).numValues)),a++),i&or.DOUBLE&&(Ka(r,u_(e,t,Ve(e,t).numValues)),a++),a}function EA(e,t){let i=Ve(e,t);if(i.physicalStreamType!==at.PRESENT)throw Error(`Expected PRESENT stream for map column but found: ${i.physicalStreamType}`);let r=i.numValues,a=t.get(),n=new Ii(Wa(e,r,i.byteLength,t),r);return t.set(a+i.byteLength),{value:n,count:r}}function PA(e,t,i,r,a){let{lengthStream:n,flattenedValues:s,presentStream:o,dictionary:l}=e,u=t*i,h=i,c;if(o){c=new Ii(new Uint8Array(Math.ceil(i/8)),i),h=0;for(let y=0;y<i;y++)o.get(u+y)&&(c.set(y,!0),h++)}let d=r+h;if(d>n.length)throw Error("Merged map counts underflow while decoding child streams");let p=Array(i),f=r,m=a;for(let y=0;y<i;y++){if(o&&!o.get(u+y)){p[y]=null;continue}let x=m+n[f++];if(x>s.length)throw Error("Map value stream underflow while decoding feature payload");let v=CA(s,m,x,l);p[y]=v.value,m=v.nextIndex}let g=0;for(let y=r;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 CA(e,t,i,r){return i-t===1||e[t]===ha.START_LIST?vc(e,t,i,r):M_(e,t,i,r)}function M_(e,t,i,r){let a=Object.create(null),n=t;for(;n<i;){let s=F_(e[n++],r);if(typeof s!="string")throw Error(`Map key dictionary index does not resolve to a string: ${s}`);let o=vc(e,n,i,r);a[s]=o.value,n=o.nextIndex}return{value:a,nextIndex:n}}function vc(e,t,i,r){if(t>=i)throw Error("Unexpected end of map value stream");let a=e[t];if(a===ha.FALSE)return{value:!1,nextIndex:t+1};if(a===ha.TRUE)return{value:!0,nextIndex:t+1};if(a===ha.START_MAP){let n=z_(e,t,i);return{value:M_(e,t+2,n,r).value,nextIndex:n}}if(a===ha.START_LIST){let n=z_(e,t,i),s=[],o=t+2;for(;o<n;){let l=vc(e,o,n,r);s.push(l.value),o=l.nextIndex}return{value:s,nextIndex:n}}return{value:F_(a,r),nextIndex:t+1}}function z_(e,t,i){if(t+1>=i)throw Error("Missing length for nested map/list payload");let r=e[t+1];if(r<2)throw Error(`Invalid nested payload length: ${r}`);let a=t+r;if(a>i)throw Error("Nested payload exceeds containing payload bounds");return a}function F_(e,t){let i=e-ha.COUNT;if(i<0||i>=t.length)throw Error(`Scalar dictionary index out of range: ${e}`);return t[i]}function Ka(e,t){for(let i of t)e.push(i)}function AA(e,t,i,r,a,n){var s;return i.type==="scalarType"?DA(r,e,t,a,i.scalarType,i):((s=i.complexType)==null?void 0:s.physicalType)===Dr.MAP?vA(e,t,i,r):r===0?null:yA(e,t,i)}function DA(e,t,i,r,a,n){let s;if(e===0)return null;if(n.nullable){let l=Ve(t,i),u=l.numValues,h=i.get(),c=Wa(t,u,l.byteLength,i);i.set(h+l.byteLength),s=new Ii(c,l.numValues)}let o=s??r;switch(a.physicalType){case me.UINT_32:case me.INT_32:return RA(t,i,n,a,o);case me.STRING:{let l=n.nullable?e-1:e;return D_(n.name,t,i,l,s)??null}case me.BOOLEAN:return IA(t,i,n,r,o);case me.UINT_64:case me.INT_64:return FA(t,i,n,o,a);case me.FLOAT:return MA(t,i,n,o);case me.DOUBLE:return zA(t,i,n,o);default:throw Error(`The specified data type for the field is currently not supported: ${a}`)}}function IA(e,t,i,r,a){let n=Ve(e,t),s=n.numValues,o=t.get(),l=ns(a)?a:void 0,u=Wa(e,s,n.byteLength,t,l);t.set(o+n.byteLength);let h=new Ii(u,s);return new cA(i.name,h,a)}function MA(e,t,i,r){let a=Ve(e,t),n=ns(r)?r:void 0,s=l_(e,t,a.numValues,n);return new dA(i.name,s,r)}function zA(e,t,i,r){let a=Ve(e,t),n=ns(r)?r:void 0,s=u_(e,t,a.numValues,n);return new ic(i.name,s,r)}function FA(e,t,i,r,a){let n=Ve(e,t),s=rl(n,r,e,t,"int64"),o=a.physicalType===me.INT_64;if(s===Le.FLAT){let u=ns(r)?r:void 0,h=o?d_(e,t,n,u):mc(e,t,n,u);return new m_(i.name,h,r)}if(s===Le.SEQUENCE){let u=c_(e,t,n);return new g_(i.name,u[0],u[1],n.numRleValues,o)}let l=o?ZC(e,t,n):p_(e,t,n);return new P_(i.name,l,r,o)}function RA(e,t,i,r,a){let n=Ve(e,t),s=rl(n,a,e,t),o=r.physicalType===me.INT_32;if(s===Le.FLAT){let u=ns(a)?a:void 0,h=o?il(e,t,n,void 0,u):Dt(e,t,n,void 0,u);return new tc(i.name,h,a)}if(s===Le.SEQUENCE){let u=h_(e,t,n);return new rc(i.name,u[0],u[1],n.numRleValues,o)}let l=o?jC(e,t,n):fc(e,t,n);return new ac(i.name,l,a,o)}function ns(e){return e instanceof Ii}const mt={ID:0,ID_NULLABLE:1,ID_LONG:2,GEOMETRY:4,SCALAR_BASE:10,STRUCT:30,MAP:31};function R_(e){switch(e){case mt.ID:case mt.ID|mt.ID_NULLABLE:case mt.ID|mt.ID_LONG:case mt.ID|mt.ID_LONG|mt.ID_NULLABLE:return{nullable:(e&mt.ID_NULLABLE)!==0,columnScope:rs.FEATURE,type:"scalarType",scalarType:{longID:(e&mt.ID_LONG)!==0,type:"logicalType",logicalType:Jg.ID}};case mt.GEOMETRY:return{nullable:!1,columnScope:rs.FEATURE,type:"complexType",complexType:{type:"physicalType",physicalType:Dr.GEOMETRY,children:[]}};case mt.STRUCT:return{nullable:!1,columnScope:rs.FEATURE,type:"complexType",complexType:{type:"physicalType",physicalType:Dr.STRUCT,children:[]}};case mt.MAP:return{nullable:!0,columnScope:rs.FEATURE,type:"complexType",complexType:{type:"physicalType",physicalType:Dr.MAP,children:[]}};default:return OA(e)}}function kA(e){return e>=mt.SCALAR_BASE}function k_(e){return e===mt.STRUCT||e===mt.MAP}function LA(e){if(e.type==="scalarType"){let t=e.scalarType;if(t.type==="physicalType")switch(t.physicalType){case me.BOOLEAN:case me.INT_8:case me.UINT_8:case me.INT_32:case me.UINT_32:case me.INT_64:case me.UINT_64:case me.FLOAT:case me.DOUBLE:return!1;case me.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 Dr.GEOMETRY:case Dr.STRUCT:case Dr.MAP:return!0;default:return!1}}return console.warn("Unexpected column type in hasStreamCount",e),!1}function BA(e){var t;return e.type==="scalarType"&&((t=e.scalarType)==null?void 0:t.type)==="logicalType"&&e.scalarType.logicalType===Jg.ID}function $A(e){var t;return e.type==="complexType"&&((t=e.complexType)==null?void 0:t.type)==="physicalType"&&e.complexType.physicalType===Dr.GEOMETRY}function OA(e){let t;switch(e){case 10:case 11:t=me.BOOLEAN;break;case 12:case 13:t=me.INT_8;break;case 14:case 15:t=me.UINT_8;break;case 16:case 17:t=me.INT_32;break;case 18:case 19:t=me.UINT_32;break;case 20:case 21:t=me.INT_64;break;case 22:case 23:t=me.UINT_64;break;case 24:case 25:t=me.FLOAT;break;case 26:case 27:t=me.DOUBLE;break;case 28:case 29:t=me.STRING;break;default:return null}return{nullable:!!(e&1),columnScope:rs.FEATURE,type:"scalarType",scalarType:{longID:!1,type:"physicalType",physicalType:t}}}const NA=new TextDecoder,L_="0-3(ID), 4(GEOMETRY), 10-29(scalars), 30(STRUCT), 31(MAP)";function xc(e,t){let i=Ct(e,t,1)[0];if(i===0)return"";let r=t.get(),a=r+i,n=e.subarray(r,a);return t.add(i),NA.decode(n)}function VA(e){let t=e.name,i=e.nullable;return e.type==="scalarType"?{type:"scalarField",scalarField:e.scalarType,name:t,nullable:i}:{type:"complexField",complexField:e.complexType,name:t,nullable:i}}function B_(e,t){let i=Ct(e,t,1)[0]>>>0,r=i>=mt.SCALAR_BASE?R_(i):null;if(!r)throw Error(`Unsupported field type code ${i}. Supported: 10-29(scalars), 30(STRUCT), 31(MAP)`);let a={...r,name:xc(e,t)};if(a.type==="complexType"&&k_(i)){let n=a.complexType,s=Ct(e,t,1)[0]>>>0;n.children=Array(s);for(let o=0;o<s;o++)n.children[o]=B_(e,t)}return VA(a)}function jA(e,t){let i=Ct(e,t,1)[0]>>>0,r=R_(i);if(!r)throw Error(`Unsupported column type code ${i}. Supported: ${L_}`);let a;if(kA(i))a=xc(e,t);else if(i<mt.GEOMETRY)a="id";else if(i===mt.GEOMETRY)a="geometry";else throw Error(`Unsupported column type code ${i}. Supported: ${L_}`);let n={...r,name:a};if(n.type==="complexType"&&k_(i)){let s=Ct(e,t,1)[0]>>>0,o=n.complexType;o.children=Array(s);for(let l=0;l<s;l++)o.children[l]=B_(e,t)}return n}function UA(e,t){let i={};i.featureTables=[];let r={};if(r.name=xc(e,t),r.name.length===0)throw Error("Missing layer name");let a=Ct(e,t,1)[0]>>>0,n=Ct(e,t,1)[0]>>>0;r.columns=Array(n);for(let s=0;s<n;s++)r.columns[s]=jA(e,t);return i.featureTables.push(r),[i,a]}function GA(e,t,i=!0){let r=new Qg(0),a=[];for(;r.get()<e.length;){let n=Ct(e,r,1)[0]>>>0,s=r.get()+n;if(s>e.length)throw Error(`Block overruns tile: ${s} > ${e.length}`);let o=Ct(e,r,1)[0]>>>0;if(o!==1&&o!==2){r.set(s);continue}let[l,u]=UA(e,r),h=l.featureTables[0],c=null,d=null,p=[],f=0;for(let g of h.columns){let _=g.name;if(BA(g)){let y=null;if(g.nullable){let v=Ve(e,r),w=r.get(),b=Wa(e,v.numValues,v.byteLength,r);r.set(w+v.byteLength),y=new Ii(b,v.numValues)}let x=Ve(e,r);f=y?y.size():x.decompressedCount,c=ZA(e,g,r,_,x,y??f,i)}else if($A(g)){let y=Ct(e,r,1)[0];if(f===0){let x=r.get();f=Ve(e,r).decompressedCount,r.set(x)}d=lA(e,y,r,f,t)}else{let y=LA(g)?Ct(e,r,1)[0]:1;if(y===0)continue;let x=AA(e,r,g,y,f);if(x)if(Array.isArray(x))for(let v of x)p.push(v);else p.push(x)}}let m=new fP(h.name,d,c,p,u);a.push(m),r.set(s)}return a}function ZA(e,t,i,r,a,n,s=!1){var h;let o=(h=t.scalarType)!=null&&h.longID?me.UINT_64:me.UINT_32,l=typeof n=="number"?void 0:n,u=rl(a,n,e,i,o===me.UINT_64?"int64":"int32");if(o===me.UINT_32)switch(u){case Le.FLAT:return new tc(r,Dt(e,i,a,void 0,l),n);case Le.SEQUENCE:{let c=h_(e,i,a);return new rc(r,c[0],c[1],a.numRleValues,!1)}case Le.CONST:return new ac(r,fc(e,i,a),n,!1)}switch(u){case Le.FLAT:return s?new ic(r,UC(e,i,a,l),n):new m_(r,mc(e,i,a,l),n);case Le.SEQUENCE:{let c=c_(e,i,a);return new g_(r,c[0],c[1],a.numRleValues,!1)}case Le.CONST:return new P_(r,p_(e,i,a),n,!1)}throw Error("Vector type not supported for id column.")}var qA=class{constructor(e,t){var i;switch(this._featureData=e,this.properties=this._featureData.properties||{},(i=this._featureData.geometry)==null?void 0:i.type){case It.POINT:case It.MULTIPOINT:this.type=1;break;case It.LINESTRING:case It.MULTILINESTRING:this.type=2;break;case It.POLYGON:case It.MULTIPOLYGON:this.type=3;break;default:this.type=0}this.extent=t,this.id=Number(this._featureData.id)}loadGeometry(){let e=[];for(let t of this._featureData.geometry.coordinates){let i=[];for(let r of t)i.push(new C(r.x,r.y));e.push(i)}return e}},WA=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 qA(this.features[e],this.extent)}},HA=class{constructor(e){this.layers={};let t=GA(new Uint8Array(e));this.layers=t.reduce((i,r)=>({...i,[r.name]:new WA(r)}),{})}},XA=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 ju(k,16,0),this.grid3D=new ju(k,16,0),this.featureIndexArray=new gm,this.promoteId=t}insert(e,t,i,r,a,n){let s=this.featureIndexArray.length;this.featureIndexArray.emplaceBack(i,r,a);let o=n?this.grid3D:this.grid;for(let l of t){let 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 HA(this.rawTileData).layers;break;default:this.vtLayers=new uS(new wg(this.rawTileData)).layers}this.sourceLayerCoder=new pP(this.vtLayers?Object.keys(this.vtLayers).sort():[el])}return this.vtLayers}query(e,t,i,r){this.loadVTLayers();let a=e.params,n=k/e.tileSize/e.scale,s=In(a.filter,"queryRenderedFeatures filter",a.globalState),o=e.queryGeometry,l=e.queryPadding*n,u=Di.fromPoints(o),h=this.grid.query(u.minX-l,u.minY-l,u.maxX+l,u.maxY+l),c=Di.fromPoints(e.cameraQueryGeometry).expandBy(l),d=this.grid3D.query(c.minX,c.minY,c.maxX,c.maxY,(m,g,_,y)=>G2(e.cameraQueryGeometry,m-l,g-l,_+l,y+l));for(let m of d)h.push(m);h.sort(KA);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,i,r,(y,x,v)=>(_||(_=Jr(y)),x.queryIntersectsFeature({queryGeometry:o,feature:y,featureState:v,geometry:_,zoom:this.z,transform:e.transform,pixelsToTileUnits:n,pixelPosMatrix:e.pixelPosMatrix,unwrappedTileID:this.tileID.toUnwrapped(),getElevation:e.getElevation})))}return p}loadMatchingFeature(e,t,i,r,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(i),p=this.vtLayers[d].feature(r);if(a.needGeometry){let m=Qr(p,!0);if(!a.filter(new be(this.tileID.overscaledZ),m,this.tileID.canonical))return}else if(!a.filter(new be(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=Z({},l[m]);y.paint=$_(y.paint,g.paint,p,_,s),y.layout=$_(y.layout,g.layout,p,_,s);let x=!h||h(p,g,_);if(!x)continue;let v=new Yg(p,this.z,this.x,this.y,f);v.layer=y;let w=e[m];w===void 0&&(w=e[m]=[]),w.push({featureIndex:r,feature:v,intersectionZ:x})}}lookupSymbolFeatures(e,t,i,r,a,n,s,o){let l={};this.loadVTLayers();let u=In(a.filterSpec,"queryRenderedFeatures symbol filter",a.globalState);for(let h of e)this.loadMatchingFeature(l,i,r,h,u,n,s,o,t);return l}hasLayer(e){for(let t of this.bucketLayerIDs)for(let i of t)if(e===i)return!0;return!1}getId(e,t){var r;let i=e.id;if(this.promoteId){let a=typeof this.promoteId=="string"?this.promoteId:this.promoteId[t];i=e.properties[a],typeof i=="boolean"&&(i=Number(i)),i===void 0&&((r=e.properties)!=null&&r.cluster)&&this.promoteId&&(i=Number(e.properties.cluster_id))}return i}};U("FeatureIndex",XA,{omit:["rawTileData","sourceLayerCoder"]});function YA(e){return typeof e=="object"&&!!e&&"evaluate"in e}function $_(e,t,i,r,a){return eu(e,(n,s)=>{let o=t instanceof bo?t.get(s):null;return YA(o)?o.evaluate(i,r,void 0,a):o})}function KA(e,t){return t-e}var JA=class{constructor(e,t){this.max=e,this.onRemove=t,this.reset()}reset(){for(let e in this.data)for(let t of this.data[e])t.timeout&&clearTimeout(t.timeout),this.onRemove(t.value);return this.data={},this.order=[],this}add(e,t,i){let r=e.wrapped().key;this.data[r]===void 0&&(this.data[r]=[]);let a={value:t,timeout:void 0};if(i!==void 0&&(a.timeout=setTimeout(()=>{this.remove(e,a)},i)),this.data[r].push(a),this.order.push(r),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 i=e.wrapped().key,r=t===void 0?0:this.data[i].indexOf(t),a=this.data[i][r];return this.data[i].splice(r,1),a.timeout&&clearTimeout(a.timeout),this.data[i].length===0&&delete this.data[i],this.onRemove(a.value),this.order.splice(this.order.indexOf(i),1),this}setMaxSize(e){for(this.max=e;this.order.length>this.max;){let t=this._getAndRemoveByKey(this.order[0]);t&&this.onRemove(t)}return this}filter(e){let t=[];for(let i in this.data)for(let r of this.data[i])e(r.value)||t.push(r);for(let i of t)this.remove(i.value.tileID,i)}};/**
|
|
6
|
+
* MapLibre GL JS
|
|
7
|
+
* @license 3-Clause BSD. Full text of license: https://github.com/maplibre/maplibre-gl-js/blob/v6.8.0/LICENSE.txt
|
|
8
|
+
*/var O_="6.8.0";function N_(){var e=new dt(4);return dt!=Float32Array&&(e[1]=0,e[2]=0),e[0]=1,e[3]=1,e}function QA(e,t){var i=t[0],r=t[1],a=t[2],n=t[3],s=i*n-a*r;return s?(s=1/s,e[0]=n*s,e[1]=-r*s,e[2]=-a*s,e[3]=i*s,e):null}function eD(e){return e[0]*e[3]-e[2]*e[1]}function tD(e,t,i){var r=t[0],a=t[1],n=t[2],s=t[3],o=Math.sin(i),l=Math.cos(i);return e[0]=r*l+n*o,e[1]=a*l+s*o,e[2]=r*-o+n*l,e[3]=a*-o+s*l,e}let bc,V_,wc;const jt={frame(e,t,i,r){let a=r||window,n=a.requestAnimationFrame(o=>{s(),t(o)}),{unsubscribe:s}=iu(e.signal,"abort",()=>{s(),a.cancelAnimationFrame(n),i(new pn(e.signal.reason))},!1)},frameAsync(e,t){return new Promise((i,r)=>{this.frame(e,i,r,t)})},getImageData(e,t=0){return this.getImageCanvasContext(e).getImageData(-t,-t,e.width+2*t,e.height+2*t)},getImageCanvasContext(e){let t=window.document.createElement("canvas"),i=t.getContext("2d",{willReadFrequently:!0});if(!i)throw Error("failed to create canvas 2d context");return t.width=e.width,t.height=e.height,i.drawImage(e,0,0,e.width,e.height),i},resolveURL(e){return bc||(bc=document.createElement("a")),bc.href=e,bc.href},get hardwareConcurrency(){return typeof navigator<"u"&&navigator.hardwareConcurrency||4},get prefersReducedMotion(){return wc===void 0?matchMedia?(V_??(V_=matchMedia("(prefers-reduced-motion: reduce)")),V_.matches):!1:wc},set prefersReducedMotion(e){wc=e}},al=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 Te(){return al.getCurrentTime()}function iD(e){al.setNow(e)}function rD(){al.restoreNow()}function aD(){return al.isFrozen()}var Q=(Pe=class{static create(t,i,r){let a=window.document.createElement(t);return i!==void 0&&(a.className=i),r&&r.appendChild(a),a}static createNS(t,i){return window.document.createElementNS(t,i)}static disableDrag(){Pe.docStyle&&Pe.selectProp&&(Pe.userSelect=Pe.docStyle[Pe.selectProp],Pe.docStyle[Pe.selectProp]="none")}static enableDrag(){Pe.docStyle&&Pe.selectProp&&(Pe.docStyle[Pe.selectProp]=Pe.userSelect)}static suppressClickInternal(t){t.preventDefault(),t.stopPropagation(),window.removeEventListener("click",Pe.suppressClickInternal,!0)}static suppressClick(){window.addEventListener("click",Pe.suppressClickInternal,!0),window.setTimeout(()=>{window.removeEventListener("click",Pe.suppressClickInternal,!0)},0)}static getScale(t){let i=t.getBoundingClientRect();return{x:i.width/t.offsetWidth||1,y:i.height/t.offsetHeight||1,boundingClientRect:i}}static getPoint(t,i,r){let a=i.boundingClientRect;return new C((r.clientX-a.left)/i.x-t.clientLeft,(r.clientY-a.top)/i.y-t.clientTop)}static mousePos(t,i){let r=Pe.getScale(t);return Pe.getPoint(t,r,i)}static touchPos(t,i){let r=[],a=Pe.getScale(t);for(let n of i)r.push(Pe.getPoint(t,a,n));return r}static sanitize(t){let i=new DOMParser().parseFromString(t,"text/html").body||document.createElement("body"),r=i.querySelectorAll("script");for(let a of r)a.remove();return Pe.clean(i),i.innerHTML}static isPossiblyDangerous(t,i){let r=i.replace(/\s+/g,"").toLowerCase();if(["src","href","xlink:href"].includes(t)&&(r.includes("javascript:")||r.includes("data:"))||t.startsWith("on"))return!0}static clean(t){let i=t.children;for(let r of i)Pe.removeAttributes(r),Pe.clean(r)}static removeAttributes(t){for(let{name:i,value:r}of Array.from(t.attributes))Pe.isPossiblyDangerous(i,r)&&t.removeAttribute(i)}},Pe.docStyle=typeof window<"u"&&((t=window.document)==null?void 0:t.documentElement.style),Pe.selectProp=!Pe.docStyle||"userSelect"in Pe.docStyle?"userSelect":"webkitUserSelect",Pe);let qi;(function(e){let t,i,r,a;e.resetRequestQueue=()=>{t=[],i=0,r=0,a={}},e.addThrottleControl=c=>{let d=r++;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 ru(f.signal),qi.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,*/*",Z(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"?kx(c,d):Lx(c),l=async c=>{c.state="running";let{requestParameters:d,supportImageRefresh:p,imageBitmapOptions:f,onError:m,onSuccess:g,abortController:_}=c,y=p===!1&&!f&&!Ea(self)&&!Sp(d.url)&&(!d.headers||Object.keys(d.headers).reduce((v,w)=>v&&w==="accept",!0));i++;let x=y?h(d,_):Us(d,_);try{let v=await x;delete c.abortController,c.state="completed",v.data instanceof HTMLImageElement||jr(v.data)?g(v):!v.data||v.data.byteLength===0?g({data:null,cacheControl:v.cacheControl,expires:v.expires}):g({data:await o(v.data,f),cacheControl:v.cacheControl,expires:v.expires})}catch(v){delete c.abortController,m(St(v))}finally{i--,u()}},u=()=>{let c=n()?ei.MAX_PARALLEL_IMAGE_REQUESTS_PER_FRAME:ei.MAX_PARALLEL_IMAGE_REQUESTS;for(let d=i;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"||!Pp(g))&&(m.crossOrigin="anonymous"),d.signal.addEventListener("abort",()=>{m.src="",f(new pn(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})})(qi||(qi={})),qi.resetRequestQueue();var nD=class{constructor(e){this._transformRequestFn=e??null}transformRequest(e,t){return this._transformRequestFn&&this._transformRequestFn(e,t)||{url:e}}setTransformRequest(e){this._transformRequestFn=e}},gt=class extends ti{},Y=class extends gt{},Tc=class extends gt{constructor(e={}){super("style.load",e)}},vi=class extends gt{constructor(e,t={}){super(e,t),this.dataType="style"}},Re=class extends gt{constructor(t,i={}){super(t,i),this.dataType="source"}},ai=class extends gt{preventDefault(){this._defaultPrevented=!0}get defaultPrevented(){return this._defaultPrevented}constructor(e,t,i,r={}){i=i instanceof MouseEvent?i:new MouseEvent(e,i);let a=Q.mousePos(t.getCanvas(),i),n=t.unproject(a);super(e,Z({point:a,lngLat:n,originalEvent:i},r)),this._defaultPrevented=!1,this.target=t}},ss=class extends gt{preventDefault(){this._defaultPrevented=!0}get defaultPrevented(){return this._defaultPrevented}constructor(e,t,i){let r=e==="touchend"?i.changedTouches:i.touches,a=Q.touchPos(t.getCanvasContainer(),r),n=a.map(l=>t.unproject(l)),s=a.reduce((l,u,h,c)=>l.add(u.div(c.length)),new C(0,0)),o=t.unproject(s);super(e,{points:a,point:s,lngLats:n,lngLat:o,originalEvent:i}),this._defaultPrevented=!1}},j_=class extends gt{preventDefault(){this._defaultPrevented=!0}get defaultPrevented(){return this._defaultPrevented}constructor(e,t){super("wheel",{originalEvent:t}),this._defaultPrevented=!1}},Sc=class extends gt{},U_=class extends gt{constructor(e={}){super("terrain",e)}},G_=class extends gt{constructor(e={}){super("projectiontransition",e)}},nl=class extends gt{},Z_=class extends gt{constructor(e={}){super("styleimagemissing",e)}};function sD(e,t){let i={};for(let r in e)r!=="ref"&&(i[r]=e[r]);return Xx.forEach(r=>{r in t&&(i[r]=t[r])}),i}function q_(e){e=e.slice();let t=Object.create(null);for(let i=0;i<e.length;i++)t[e[i].id]=e[i];for(let i=0;i<e.length;i++)"ref"in e[i]&&(e[i]=sD(e[i],t[e[i].ref]));return e}function Se(e,t){if(Array.isArray(e)){if(!Array.isArray(t)||e.length!==t.length)return!1;for(let i=0;i<e.length;i++)if(!Se(e[i],t[i]))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 i in e)if(!Se(e[i],t[i]))return!1;return!0}return e===t}function xi(e,t){e.push(t)}function W_(e,t,i){xi(i,{command:"addSource",args:[e,t[e]]})}function H_(e,t,i){xi(t,{command:"removeSource",args:[e]}),i[e]=!0}function oD(e,t,i,r){H_(e,i,r),W_(e,t,i)}function lD(e,t,i){let r;for(r in e[i])if(Object.prototype.hasOwnProperty.call(e[i],r)&&r!=="data"&&!Se(e[i][r],t[i][r]))return!1;for(r in t[i])if(Object.prototype.hasOwnProperty.call(t[i],r)&&r!=="data"&&!Se(e[i][r],t[i][r]))return!1;return!0}function uD(e,t,i,r){e||(e={}),t||(t={});let a;for(a in e)Object.prototype.hasOwnProperty.call(e,a)&&(Object.prototype.hasOwnProperty.call(t,a)||H_(a,i,r));for(a in t)Object.prototype.hasOwnProperty.call(t,a)&&(Object.prototype.hasOwnProperty.call(e,a)?Se(e[a],t[a])||(e[a].type==="geojson"&&t[a].type==="geojson"&&lD(e,t,a)?xi(i,{command:"setGeoJSONSourceData",args:[a,t[a].data]}):oD(a,t,i,r)):W_(a,t,i))}function sl(e,t,i,r,a,n){e||(e={}),t||(t={});for(let s in e)Object.prototype.hasOwnProperty.call(e,s)&&(Se(e[s],t[s])||i.push({command:n,args:[r,s,t[s],a]}));for(let s in t)Object.prototype.hasOwnProperty.call(t,s)&&!Object.prototype.hasOwnProperty.call(e,s)&&(Se(e[s],t[s])||i.push({command:n,args:[r,s,t[s],a]}))}function X_(e){return e.id}function Y_(e,t){return e[t.id]=t,e}function hD(e,t,i){e||(e=[]),t||(t=[]);let r=e.map(X_),a=t.map(X_),n=e.reduce(Y_,{}),s=t.reduce(Y_,{}),o=r.slice(),l=Object.create(null),u,h,c,d,p;for(let f=0,m=0;f<r.length;f++)u=r[f],Object.prototype.hasOwnProperty.call(s,u)?m++:(xi(i,{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)?(xi(i,{command:"removeLayer",args:[u]}),o.splice(o.lastIndexOf(u,o.length-m),1)):m++,d=o[o.length-f],xi(i,{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]||Se(h,c))){if(!Se(h.source,c.source)||!Se(h["source-layer"],c["source-layer"])||!Se(h.type,c.type)){xi(i,{command:"removeLayer",args:[u]}),d=o[o.lastIndexOf(u)+1],xi(i,{command:"addLayer",args:[c,d]});continue}for(p in sl(h.layout,c.layout,i,u,null,"setLayoutProperty"),sl(h.paint,c.paint,i,u,null,"setPaintProperty"),Se(h.filter,c.filter)||xi(i,{command:"setFilter",args:[u,c.filter]}),(!Se(h.minzoom,c.minzoom)||!Se(h.maxzoom,c.maxzoom))&&xi(i,{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?sl(h[p],c[p],i,u,p.slice(6),"setPaintProperty"):Se(h[p],c[p])||xi(i,{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?sl(h[p],c[p],i,u,p.slice(6),"setPaintProperty"):Se(h[p],c[p])||xi(i,{command:"setLayerProperty",args:[u,p,c[p]]}))}}function cD(e,t){if(!e)return[{command:"setStyle",args:[t]}];let i=[];try{if(!Se(e.version,t.version))return[{command:"setStyle",args:[t]}];Se(e.center,t.center)||i.push({command:"setCenter",args:[t.center]}),Se(e.state,t.state)||i.push({command:"setGlobalState",args:[t.state]}),Se(e.centerAltitude,t.centerAltitude)||i.push({command:"setCenterAltitude",args:[t.centerAltitude]}),Se(e.zoom,t.zoom)||i.push({command:"setZoom",args:[t.zoom]}),Se(e.bearing,t.bearing)||i.push({command:"setBearing",args:[t.bearing]}),Se(e.pitch,t.pitch)||i.push({command:"setPitch",args:[t.pitch]}),Se(e.roll,t.roll)||i.push({command:"setRoll",args:[t.roll]}),Se(e.sprite,t.sprite)||i.push({command:"setSprite",args:[t.sprite]}),Se(e.glyphs,t.glyphs)||i.push({command:"setGlyphs",args:[t.glyphs]}),Se(e["font-faces"],t["font-faces"])||i.push({command:"setFontFaces",args:[t["font-faces"]]}),Se(e.transition,t.transition)||i.push({command:"setTransition",args:[t.transition]}),Se(e.light,t.light)||i.push({command:"setLight",args:[t.light]}),Se(e.terrain,t.terrain)||i.push({command:"setTerrain",args:[t.terrain]}),Se(e.sky,t.sky)||i.push({command:"setSky",args:[t.sky]}),Se(e.projection,t.projection)||i.push({command:"setProjection",args:[t.projection]});let r={},a=[];uD(e.sources,t.sources,a,r);let n=[];e.layers&&e.layers.forEach(s=>{"source"in s&&r[s.source]?i.push({command:"removeLayer",args:[s.id]}):n.push(s)}),i=i.concat(a),hD(n,t.layers,i)}catch(r){console.warn("Unable to compute style diff:",r),i=[{command:"setStyle",args:[t]}]}return i}function dD(){let e={},t=z.$version;for(let i in z.$root){let r=z.$root[i];if(r.required){let a=null;a=i==="version"?t:r.type==="array"?[]:{},a!=null&&(e[i]=a)}}return e}function ol(e){let t=[];if(typeof e=="string")t.push({id:"default",url:e});else if(e&&e.length>0){let i=[];for(let{id:r,url:a}of e){let n=`${r}${a}`;i.includes(n)||(i.push(n),t.push({id:r,url:a}))}}return t}function K_(e,t,i){try{let r=new URL(e);return r.pathname+=`${t}${i}`,r.toString()}catch{throw Error(`Invalid sprite URL "${e}", must be absolute. Modify style specification directly or use TransformStyleFunction to correct the issue dynamically`)}}async function pD(e,t,i,r){let a=ol(e),n=i>1?"@2x":"",s={},o={};for(let{id:l,url:u}of a){let h=await t.transformRequest(K_(u,n,".json"),"SpriteJSON");s[l]=Gs(h,r);let c=await t.transformRequest(K_(u,n,".png"),"SpriteImage");o[l]=qi.getImage(c,r)}return await Promise.all([...Object.values(s),...Object.values(o)]),fD(s,o)}async function fD(e,t){let i={};for(let r in e){i[r]={};let a=(await t[r]).data;if(!a)throw Error(`Could not load sprite image for ${r}: the response is empty`);let n=jt.getImageCanvasContext(a),s=(await e[r]).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],x={width:l,height:u,x:h,y:c,context:n};i[r][o]={data:null,pixelRatio:p,sdf:d,stretchX:f,stretchY:m,content:g,textFitWidth:_,textFitHeight:y,spriteData:x}}}return i}var mD=class extends ot{constructor(){super(),this.images={},this.updateVersion=0,this.loaded=!1,this.requestors=[],this.missingImageResolver=null,this._spriteImagesIds={},this._imagesIds=null,this._renderCallbacksDispatchedThisFrame={}}destroy(){for(let e of Object.keys(this.images))this.removeImage(e);this._spriteImagesIds={}}isLoaded(){return this.loaded}setLoaded(e){if(this.loaded!==e&&(this.loaded=e,e)){for(let{ids:t,promiseResolve:i}of this.requestors)i(this._getImagesForIds(t));this.requestors=[]}}getImage(e){let t=this.images[e];if(t&&!t.data&&t.spriteData){let i=t.spriteData;t.data=new Fe({width:i.width,height:i.height},i.context.getImageData(i.x,i.y,i.width,i.height).data),t.spriteData=null}return t}addImage(e,t){if(this.images[e])throw Error(`Image id ${e} already exist, use updateImage instead`);this._validate(e,t)&&(this.images[e]=t,this._imagesIds=null,t.isWebGLImage&&this.updateImage(e,t,!1))}_validate(e,t){let i=!0,r=t.data||t.spriteData;return this._validateStretch(t.stretchX,r==null?void 0:r.width)||(this.fire(new K(Error(`Image "${e}" has invalid "stretchX" value`))),i=!1),this._validateStretch(t.stretchY,r==null?void 0:r.height)||(this.fire(new K(Error(`Image "${e}" has invalid "stretchY" value`))),i=!1),this._validateContent(t.content,t)||(this.fire(new K(Error(`Image "${e}" has invalid "content" value`))),i=!1),i}_validateStretch(e,t){if(!e)return!0;let i=0;for(let r of e){if(r[0]<i||r[1]<r[0]||t<r[1])return!1;i=r[1]}return!0}_validateContent(e,t){if(!e)return!0;if(e.length!==4)return!1;let i=t.spriteData,r=(i==null?void 0:i.width)||t.data.width,a=(i==null?void 0:i.height)||t.data.height;return e[0]<0||r<e[0]||e[1]<0||a<e[1]||e[2]<0||r<e[2]||e[3]<0||a<e[3]||e[2]<e[0]?!1:e[3]>=e[1]}updateImage(e,t,i=!0){let r=this.images[e];if(i){let a=r.data||r.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=(r.version??0)+1,this.images[e]=t,this.updateVersion++}removeImage(e){var i;let t=this.images[e];t&&(delete this.images[e],this._imagesIds=null,(i=t.userImage)!=null&&i.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 i=this._spriteImagesIds[e]??[],r=[];for(let s in t){let o=this._getSpriteImageId(e,s);r.push(o),o in this.images?this.updateImage(o,t[s],!1):this.addImage(o,t[s])}let a=new Set(r),n=i.filter(s=>!a.has(s));for(let s of n)this.removeImage(s);return this._spriteImagesIds[e]=r,{loaded:r,removed:n}}removeSpriteImages(e){let t=this._spriteImagesIds[e]??[];for(let i of t)this.removeImage(i);return delete this._spriteImagesIds[e],t}removeAllSpriteImages(){let e=Object.values(this._spriteImagesIds).flat();for(let t of e)this.removeImage(t);return this._spriteImagesIds={},e}setMissingImageResolver(e){this.missingImageResolver=e}getImages(e){return new Promise((t,i)=>{let r=!0;if(!this.isLoaded())for(let a of e)this.images[a]||(r=!1);this.isLoaded()||r?t(this._getImagesForIds(e)):this.requestors.push({ids:e,promiseResolve:t})})}async _getImagesForIds(e){var a;let t=new Set(e.filter(n=>!this.getImage(n))),i=this.missingImageResolver;i&&await Promise.allSettled(Array.from(t,n=>i(n)));let r={};for(let n of e){let s=this.getImage(n);s&&(t.delete(n),r[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 Z_({id:n})),le(`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 r}beginFrame(){this._renderCallbacksDispatchedThisFrame={}}dispatchRenderCallbacks(e){for(let t of e){if(this._renderCallbacksDispatchedThisFrame[t])continue;this._renderCallbacksDispatchedThisFrame[t]=!0;let i=this.getImage(t);i||le(`Image with ID: "${t}" was not found`),oE(i)&&this.updateImage(t,i)}}cloneImages(){let e={};for(let t in this.images){let i=this.images[t];e[t]={...i,data:i.data?i.data.clone():null}}return e}},gD=class{constructor(e){this._imageManager=e,this._entries={},this._image=new Fe({width:1,height:1}),this._dirty=!0}destroy(){this._texture&&(this._texture=(this._texture.destroy(),null)),this._entries={},this._image=new Fe({width:1,height:1}),this._dirty=!0}getPixelSize(){let{width:e,height:t}=this._image;return{width:e,height:t}}getPattern(e){let t=this._imageManager.getImage(e);if(!t)return null;let i=this._entries[e];if((i==null?void 0:i.image)!==t){let r={w:t.data.width+2,h:t.data.height+2,x:0,y:0};this._entries[e]={bin:r,position:new Zh(r,t),image:t}}else if(i.position.version!==t.version)i.position.version=t.version;else return i.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 lt(e,this._image,t.RGBA),this._dirty=!1),this._texture.bind(t.LINEAR,t.CLAMP_TO_EDGE)}_update(){for(let a in this._entries)this._imageManager.getImage(a)||delete this._entries[a];let e=[];for(let a in this._entries)e.push(this._entries[a].bin);let{w:t,h:i}=Tg(e),r=this._image;r.resize({width:t||1,height:i||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;Fe.copy(l,r,{x:0,y:0},{x:s,y:o},{width:u,height:h}),Fe.copy(l,r,{x:0,y:h-1},{x:s,y:o-1},{width:u,height:1}),Fe.copy(l,r,{x:0,y:0},{x:s,y:o+h},{width:u,height:1}),Fe.copy(l,r,{x:u-1,y:0},{x:s-1,y:o},{width:1,height:h}),Fe.copy(l,r,{x:0,y:0},{x:s+u,y:o},{width:1,height:h})}this._dirty=!0}};const Ec=1114111,_D={start:0,end:Ec};let yD=0;function vD(e){let t=/^u\+([0-9a-f]*)(\?+)$/i.exec(e);if(t){let[,a,n]=t;return a.length+n.length>6?null:J_(parseInt(`${a}${"0".repeat(n.length)}`,16),parseInt(`${a}${"f".repeat(n.length)}`,16))}let i=/^u\+([0-9a-f]{1,6})(?:-([0-9a-f]{1,6}))?$/i.exec(e);if(!i)return null;let r=parseInt(i[1],16);return J_(r,i[2]===void 0?r:parseInt(i[2],16))}function J_(e,t){return e>t||e>Ec?null:{start:e,end:Math.min(t,Ec)}}function xD(e,t){return e.ranges.some(({start:i,end:r})=>t>=i&&t<=r)}var bD=class{constructor(e){this.requestManager=e,this._faces={},this._registered=new Set}setFontFaces(e){this._unregisterAll(),this._faces={};for(let[t,i]of Object.entries(e??{})){let r=Array.isArray(i)?i:[i];this._faces[t]=r.map(a=>this._declareFontFace(t,a)).filter(a=>a!==null)}}hasFontFaces(){return Object.keys(this._faces).length>0}async getFontFamily(e,t){for(let i of e.split(","))for(let r of this._faces[i.trim()]??[])if(xD(r,t)&&(r.loaded??(r.loaded=this._loadFontFace(r)),await r.loaded))return r.family;return null}_declareFontFace(e,t){let i=typeof t=="string"?{url:t}:t;if(typeof(i==null?void 0:i.url)!="string")return le(`Ignoring the font face declared for "${e}": it has no URL.`),null;let r=`maplibre-gl-font-face-${yD++}`,a=i["unicode-range"];if(!(a!=null&&a.length))return{url:i.url,ranges:[_D],family:r};let n=[];for(let s of a){let o=vD(s);if(!o){le(`Ignoring the unicode range "${s}" of the font face at ${i.url}: it is not a valid range.`);continue}n.push(o)}return n.length?{url:i.url,ranges:n,family:r}:null}async _loadFontFace(e){if(typeof FontFace>"u"||typeof document>"u"||!document.fonts)return le(`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(i=>i.includes(e))?(document.fonts.add(t),this._registered.add(t),await t.load(),!0):!1}catch(i){return t&&this._unregister(t),le(`Ignoring the font face at ${e.url}: ${St(i).message}`),!1}}async _downloadFontFile(e){let t=await this.requestManager.transformRequest(e,"Glyphs"),i=await Ep(t,new AbortController);if(!(i!=null&&i.data))throw Error(`the response was empty for the font file at ${e}`);return i.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 Pc=1e20,Cc=new Float64Array(256);for(let e=0;e<256;e++){let t=.5-(e/255)**.45454545454545453;Cc[e]=t*Math.abs(t)}Cc[255]=-1e20;var wD=class{constructor({fontSize:e=24,buffer:t=3,radius:i=8,cutoff:r=.25,fontFamily:a="sans-serif",fontWeight:n="normal",fontStyle:s="normal",lang:o=null}={}){this.buffer=t,this.radius=i,this.cutoff=r,this.lang=o;let l=this.size=e+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:i,actualBoundingBoxDescent:r,actualBoundingBoxLeft:a,actualBoundingBoxRight:n}=this.ctx.measureText(e),s=Math.ceil(i),o=Math.floor(-a),l=Math.max(0,Math.min(this.size-this.buffer,Math.ceil(n)-o)),u=Math.max(0,Math.min(this.size-this.buffer,s+Math.ceil(r))),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 x=m.getImageData(g,g,l,u);y.fill(Pc,0,d),_.fill(0,0,d);let v=3;for(let P=0;P<u;P++){let S=(P+g)*h+g;for(let M=0;M<l;M++,v+=4,S++){let F=x.data[v];if(F===0)continue;let R=Cc[F];y[S]=Math.max(0,R),_[S]=Math.max(0,-R)}}Q_(y,0,0,h,c,h,this.f,this.v,this.z);let w=Math.min(g,1);Q_(_,g-w,g-w,l+2*w,u+2*w,h,this.f,this.v,this.z);let b=255/this.radius,T=255*(1-this.cutoff);for(let P=0;P<d;P++){let S=Math.sqrt(y[P])-Math.sqrt(_[P]);p[P]=Math.round(T-b*S)}return f}};function Q_(e,t,i,r,a,n,s,o,l){for(let u=t;u<t+r;u++)ey(e,i*n+u,n,a,s,o,l);for(let u=i;u<i+a;u++)ey(e,u*n+t,1,r,s,o,l)}function ey(e,t,i,r,a,n,s){n[0]=0,s[0]=-1e20,s[1]=Pc,a[0]=e[t];for(let o=1,l=0,u=0;o<r;o++){a[o]=e[t+o*i];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]=Pc}for(let o=0,l=0;o<r;o++){for(;s[l+1]<o;)l++;let u=n[l],h=o-u;e[t+o*i]=a[u]+h*h}}const TD=z.layout_symbol["text-font"].default.join(","),SD=(e,t)=>{let i=new wD(e);return i.buffer=t,i};var ED=class{constructor(e,t,i,r=SD){this.requestManager=e,this.localIdeographFontFamily=t,this.entries={},this.lang=i,this.fontFaceManager=new bD(e),this.createRasterizer=r}setURL(e){this.url=e}setFontFaces(e){this.fontFaceManager.setFontFaces(e),this.entries={}}async getGlyphs(e){let t=[];for(let a in e)for(let n of e[a])t.push(this._getAndCacheGlyphsPromise(a,n));let i=await Promise.all(t),r={};for(let{stack:a,id:n,glyph:s}of i)r[a]||(r[a]={}),r[a][n]=s&&{id:s.id,bitmap:s.bitmap.clone(),metrics:s.metrics};return r}async _getAndCacheGlyphsPromise(e,t){var s;(s=this.entries)[e]??(s[e]={glyphs:{},requests:{},ranges:{}});let i=this.entries[e],r=i.glyphs[t];if(r!==void 0)return{stack:e,id:t,glyph:r};let a=t.codePointAt(0),n=this.fontFaceManager.hasFontFaces()?await this.fontFaceManager.getFontFamily(e,a):null;return n?(r=i.glyphs[t]=await this._drawGlyph(i,e,t,n),{stack:e,id:t,glyph:r}):$o(t)?(r=i.glyphs[t]=null,{stack:e,id:t,glyph:r}):!this.url||this._charUsesLocalIdeographFontFamily(a)?(r=i.glyphs[t]=await this._drawGlyph(i,e,t),{stack:e,id:t,glyph:r}):await this._downloadAndCacheRangePromise(e,t)}async _downloadAndCacheRangePromise(e,t){var n;let i=t.codePointAt(0),r=this.entries[e],a=Math.floor(i/256);if(r.ranges[a])return{stack:e,id:t,glyph:null};(n=r.requests)[a]||(n[a]=this._loadGlyphRange(e,a));try{let s=await r.requests[a];for(let o in s)r.glyphs[String.fromCodePoint(+o)]=s[+o];return r.ranges[a]=!0,{stack:e,id:t,glyph:s[i]||null}}catch(s){let o=r.glyphs[t]=await this._drawGlyph(r,e,t);return this._warnOnMissingGlyphRange(o,a,i,St(s)),{stack:e,id:t,glyph:o}}}async _loadGlyphRange(e,t){let i=t*256,r=i+255,a=await this.requestManager.transformRequest(this.url.replace("{fontstack}",e).replace("{range}",`${i}-${r}`),"Glyphs"),n=await Ep(a,new AbortController);if(!(n!=null&&n.data))throw Error(`Could not load glyph range. range: ${t}, ${i}-${r}`);let s={};for(let o of sE(n.data))s[o.id]=o;return s}_warnOnMissingGlyphRange(e,t,i,r){let a=t*256,n=a+255,s=i.toString(16).padStart(4,"0").toUpperCase();le(`Unable to load glyph range ${t}, ${a}-${n}. Rendering codepoint U+${s} locally instead. ${r}`)}_charUsesLocalIdeographFontFamily(e){return!!this.localIdeographFontFamily&&Yw(e)}async _drawGlyph(e,t,i,r){let a=(await this._getTinySDF(e,t,i,r)).draw(i),n=new RegExp("^\\p{gc=Cf}+$","u").test(i);return{id:i.codePointAt(0),bitmap:new Ah({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,i,r){var s;if(r){let o=$o(i),l=o?"clusterTinySDFs":"fontFaceTinySDFs";return e[l]??(e[l]={}),(s=e[l])[r]||(s[r]=this._createTinySDF(r,!1,o?3:1)),e[l][r]}let a=t===TD&&this.localIdeographFontFamily!==""&&this._charUsesLocalIdeographFontFamily(i.codePointAt(0)),n=a?"ideographTinySDF":"tinySDF";return e[n]||(e[n]=this._createTinySDF(a?this.localIdeographFontFamily:t)),e[n]}async _createTinySDF(e,t=!0,i=1){var o;let r=e?e.split(","):[];r.push("sans-serif");let a=r.map(l=>/[-\w]+/.test(l)?l:`'${CSS.escape(l)}'`).join(","),n=t?this._fontWeight(r[0]):void 0,s=t?this._fontStyle(r[0]):"normal";if(typeof document<"u"&&((o=document.fonts)!=null&&o.load))try{await document.fonts.load(`${s} ${n||"normal"} 48px ${a}`)}catch(l){le(`Failed to load font "${a}": ${St(l).message}`)}return this.createRasterizer({fontSize:48,buffer:Math.max(6,Math.ceil(48*(i-1)/4)),radius:16,cutoff:.25,fontFamily:a,fontWeight:n,fontStyle: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},i;for(let[r,a]of Object.entries(t))RegExp(`\\b${r}\\b`,"i").test(e)&&(i=`${a}`);return i}destroy(){for(let e in this.entries){let t=this.entries[e];t.tinySDF=null,t.ideographTinySDF=null,t.fontFaceTinySDFs={},t.glyphs={},t.requests={},t.ranges={}}this.entries={},this.fontFaceManager.destroy()}};let PD;const CD=()=>PD||(PD=new yt({anchor:new j(z.light.anchor,"anchor"),position:new j(z.light.position,"position"),color:new j(z.light.color,"color"),intensity:new j(z.light.intensity,"intensity")}));var AD=class extends ot{constructor(e,t){super(),this._transitionable=new xo(CD(),"light",t),this.setLight(e),this._transitioning=this._transitionable.untransitioned()}getLight(){return this._transitionable.serialize()}getCartesianPosition(){return zx(this.properties.get("position"))}setLight(e,t={}){if(!this._validate(Ht.light,e,t))for(let i in e){let r=e[i];i.endsWith("-transition")?this._transitionable.setTransition(i.slice(0,-Hu.length),r):this._transitionable.setValue(i,r)}}updateTransitions(e){this._transitioning=this._transitionable.transitioned(e,this._transitioning)}hasTransition(){return this._transitioning.hasTransition()}recalculate(e){this.properties=this._transitioning.possiblyEvaluate(e)}_validate(e,t,i){return zn(this,e,{value:t},i)}};let DD;const ID=()=>DD||(DD=new yt({"sky-color":new j(z.sky["sky-color"],"sky-color"),"horizon-color":new j(z.sky["horizon-color"],"horizon-color"),"fog-color":new j(z.sky["fog-color"],"fog-color"),"fog-ground-blend":new j(z.sky["fog-ground-blend"],"fog-ground-blend"),"horizon-fog-blend":new j(z.sky["horizon-fog-blend"],"horizon-fog-blend"),"sky-horizon-blend":new j(z.sky["sky-horizon-blend"],"sky-horizon-blend"),"atmosphere-blend":new j(z.sky["atmosphere-blend"],"atmosphere-blend")}));var MD=class extends ot{constructor(e,t){super(),this._transitionable=new xo(ID(),"sky",t),this.setSky(e),this._transitioning=this._transitionable.untransitioned(),this.recalculate(new be(0))}setSky(e,t={}){if(!this._validate(Ht.sky,e,t)){e||(e={"sky-color":"transparent","horizon-color":"transparent","fog-color":"transparent","fog-ground-blend":1,"atmosphere-blend":0});for(let i in e){let r=e[i];i.endsWith("-transition")?this._transitionable.setTransition(i.slice(0,-Hu.length),r):this._transitionable.setValue(i,r)}}}getSky(){return this._transitionable.serialize()}updateTransitions(e){this._transitioning=this._transitionable.transitioned(e,this._transitioning)}hasTransition(){return this._transitioning.hasTransition()}recalculate(e){this.properties=this._transitioning.possiblyEvaluate(e)}_validate(e,t,i={}){return zn(this,e,{value:t},i)}calculateFogBlendOpacity(e){return e<60?0:e<70?(e-60)/10:1}},zD=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 r;let i=e.join(",")+String(t);return(r=this.dashEntry)[i]||(r[i]=this.addDash(e,t)),this.dashEntry[i]}getDashRanges(e,t,i){let r=e.length%2==1,a=[],n=r?-e[e.length-1]*i:0,s=e[0]*i,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*i,l+=h,s=l*i,a.push({left:n,right:s,isDash:o,zeroLength:h===0})}return a}addRoundDash(e,t,i){let r=t/2;for(let a=-i;a<=i;a++){let n=this.nextRow+i+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/i*(r+1);if(l.isDash){let m=r-Math.abs(f);p=Math.sqrt(d*d+m*m)}else p=r-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],i=e[e.length-1];t.isDash===i.isDash&&(t.left=i.left-this.width,i.right=t.right+this.width);let r=this.width*this.nextRow,a=0,n=e[a];for(let s=0;s<this.width;s++){s/n.right>1&&(n=e[++a]);let o=Math.abs(s-n.left),l=Math.abs(s-n.right),u=Math.min(o,l),h=n.isDash?u:-u;this.data[r+s]=Math.max(0,Math.min(255,h+128))}}addDash(e,t){let i=t?7:0,r=2*i+1;if(this.nextRow+r>this.height)return le("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,i):this.addRegularDash(o)}let n={y:this.nextRow+i,height:2*i,width:a};return this.nextRow+=r,this.dirty=!0,n}bind(e){let t=e.gl;this.texture?(t.bindTexture(t.TEXTURE_2D,this.texture),this.dirty&&(this.dirty=!1,t.texSubImage2D(t.TEXTURE_2D,0,0,0,this.width,this.height,t.ALPHA,t.UNSIGNED_BYTE,this.data))):(this.texture=t.createTexture(),t.bindTexture(t.TEXTURE_2D,this.texture),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_WRAP_S,t.REPEAT),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_WRAP_T,t.REPEAT),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_MIN_FILTER,t.LINEAR),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_MAG_FILTER,t.LINEAR),t.texImage2D(t.TEXTURE_2D,0,t.ALPHA,this.width,this.height,0,t.ALPHA,t.UNSIGNED_BYTE,this.data))}};function FD(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 RD(){let e=typeof document>"u"&&typeof location>"u"?require("url").pathToFileURL(__filename).href:typeof document>"u"?location.href:pe&&pe.tagName.toUpperCase()==="SCRIPT"&&pe.src||new URL("mapslibvn.umd.js",document.baseURI).href;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 Ac(e,t){if(t)try{return new Worker(e,{type:"module"})}catch(i){console.warn("Module worker not supported, falling back to classic worker",i)}return new Worker(e)}async function kD(e){let t=await fetch(e);if(!t.ok)throw Error(`Failed to fetch worker script (${t.status}): ${e}`);let i=await t.text(),r=new Blob([i],{type:"text/javascript"});return URL.createObjectURL(r)}function LD(e){let t=new Blob([`import ${JSON.stringify(new URL(e,typeof document>"u"&&typeof location>"u"?require("url").pathToFileURL(__filename).href:typeof document>"u"?location.href:pe&&pe.tagName.toUpperCase()==="SCRIPT"&&pe.src||new URL("mapslibvn.umd.js",document.baseURI).href).href)}`],{type:"text/javascript"});return URL.createObjectURL(t)}async function BD(){let e=ei.WORKER_URL||RD(),t=!(e!=null&&e.endsWith(".cjs"));if(!FD(e))return Ac(e,t);if(t){let r=LD(e);try{return Ac(r,t)}finally{URL.revokeObjectURL(r)}}let i=await kD(e);try{return Ac(i,t)}finally{URL.revokeObjectURL(i)}}const Dc="maplibre_preloaded_worker_pool";var ll=class F1{constructor(){this.active={},this.workersPromise=null}async acquire(t){if(this.active[t]=!0,!this.workersPromise){let i=[];for(;i.length<F1.workerCount;)i.push(BD());this.workersPromise=Promise.all(i)}return(await this.workersPromise).slice()}release(t){if(delete this.active[t],this.numActive()===0&&this.workersPromise){let i=this.workersPromise;this.workersPromise=null,i.then(r=>{for(let a of r)a.terminate()})}}isPreloaded(){return!!this.active[Dc]}numActive(){return Object.keys(this.active).length}};const $D=Math.floor(jt.hardwareConcurrency/2);ll.workerCount=Rx(globalThis)?Math.max(Math.min($D,3),1):1;let ul;function Ic(){return ul||(ul=new ll),ul}function OD(){Ic().acquire(Dc)}function ND(){let e=ul;e&&(e.isPreloaded()&&e.numActive()===1?(e.release(Dc),ul=null):console.warn("Could not clear WebWorkers since there are active Map instances that still reference it. The pre-warmed WebWorker pool can only be cleared when all map instances have been removed with map.remove()"))}var ty=class{constructor(e,t){this.workerPool=e,this.actors=[],this.currentActor=0,this.id=t,this.removed=!1,this.actorsPromise=this.initActors(t)}async initActors(e){let t=await this.workerPool.acquire(e);if(this.removed)return[];if(this.actors=t.map((i,r)=>{let a=new uP(i,e);return a.name=`Worker ${r}`,a}),!this.actors.length)throw Error("No actors found");return this.actors}async broadcast(e,t){let i=await this.actorsPromise;return Promise.all(i.map(r=>r.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();this.actors=[],e&&this.workerPool.release(this.id)}async registerMessageHandler(e,t){let i=await this.actorsPromise;for(let r of i)r.registerMessageHandler(e,t)}async unregisterMessageHandler(e){let t=await this.actorsPromise;for(let i of t)i.unregisterMessageHandler(e)}};let hl;function Mc(){return hl||(hl=new ty(Ic(),au),hl.registerMessageHandler("GR",(e,t,i)=>Us(t,i))),hl}function VD(e,t){let i=gr();return rt(i,i,[1,1,0]),Tt(i,i,[e.width*.5,e.height*.5,1]),e.calculatePosMatrix?ba(i,i,e.calculatePosMatrix(t.toUnwrapped())):i}function jD(e,t,i){if(e)for(let r of e){let a=t[r];if((a==null?void 0:a.source)===i&&a.type==="fill-extrusion")return!0}else for(let r in t){let a=t[r];if(a.source===i&&a.type==="fill-extrusion")return!0}return!1}function UD(e,t,i,r,a,n,s){let o=jD((a==null?void 0:a.layers)??null,t,e.id),l=n.maxPitchScaleFactor(),u=e.tilesIn(r,l,o);u.sort(iy);let h=[];for(let c of u)h.push({wrappedTileID:c.tileID.wrapped().key,queryResults:c.tile.queryRenderedFeatures(t,i,e.getState(),c.queryGeometry,c.cameraQueryGeometry,c.scale,a,n,l,VD(n,c.tileID),s?(d,p)=>s(c.tileID,d,p):void 0)});return WD(qD(h),e)}function GD(e,t,i,r,a,n,s){let o={},l=n.queryRenderedSymbols(r),u=[];for(let h of Object.keys(l).map(Number))u.push(s[h]);u.sort(iy);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 HD(o,e,i)}function ZD(e,t){let i=e.getRenderableIds().map(n=>e.getTileByID(n)),r=[],a={};for(let n of i){let s=n.tileID.canonical.key;a[s]||(a[s]=!0,n.querySourceFeatures(r,t))}return r}function iy(e,t){let i=e.tileID,r=t.tileID;return i.overscaledZ-r.overscaledZ||i.canonical.y-r.canonical.y||i.wrap-r.wrap||i.canonical.x-r.canonical.x}function qD(e){let t={},i={};for(let{queryResults:r,wrappedTileID:a}of e){i[a]||(i[a]={});let n=i[a];for(let s in r){let o=r[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 WD(e,t){for(let i in e)for(let r of e[i])ry(r,t);return e}function HD(e,t,i){for(let r in e)for(let a of e[r]){let n=i[t[r].source];ry(a,n)}return e}function ry(e,t){let i=e.feature,r=t.getFeatureState(i.layer["source-layer"],i.id);i.source=i.layer.source,i.layer["source-layer"]&&(i.sourceLayer=i.layer["source-layer"]),i.state=r}async function ay(e,t,i,r){let a=e;if(e.url?a=(await Gs(await t.transformRequest(e.url,"Source"),i)).data:await jt.frameAsync(i,r),!a)return null;let n=dn(Z(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 Mi=class pr{constructor(t,i){t&&(i?this.setSouthWest(t).setNorthEast(i):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 W?new W(t.lng,t.lat):W.convert(t),this}setSouthWest(t){return this._sw=t instanceof W?new W(t.lng,t.lat):W.convert(t),this}extend(t){let i=this._sw,r=this._ne,a,n;if(t instanceof W)a=t,n=t;else if(t instanceof pr){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(pr.convert(s))}{let s=t;return this.extend(W.convert(s))}}return t&&("lng"in t||"lon"in t)&&"lat"in t?this.extend(W.convert(t)):this}return!i&&!r?(this._sw=new W(a.lng,a.lat),this._ne=new W(n.lng,n.lat)):(i.lng=Math.min(a.lng,i.lng),i.lat=Math.min(a.lat,i.lat),r.lng=Math.max(n.lng,r.lng),r.lat=Math.max(n.lat,r.lat)),this}getCenter(){return new W((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 W(this.getWest(),this.getNorth())}getSouthEast(){return new W(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:i,lat:r}=W.convert(t),a=this._sw.lat<=r&&r<=this._ne.lat,n=this._sw.lng<=i&&i<=this._ne.lng;return this._sw.lng>this._ne.lng&&(n=this._sw.lng>=i&&i>=this._ne.lng),a&&n}intersects(t){if(t=pr.convert(t),!(t.getNorth()>=this.getSouth()&&t.getSouth()<=this.getNorth()))return!1;let i=Math.abs(this.getEast()-this.getWest()),r=Math.abs(t.getEast()-t.getWest());if(i>=360||r>=360)return!0;let a=ci(this.getWest(),-180,180),n=ci(this.getEast(),-180,180),s=ci(t.getWest(),-180,180),o=ci(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 pr||!t?t:new pr(t)}static fromLngLat(t,i=0){let r=360*i/40075017,a=r/Math.cos(Math.PI/180*t.lat);return new pr(new W(t.lng-a,t.lat-r),new W(t.lng+a,t.lat+r))}adjustAntiMeridian(){let t=new W(this._sw.lng,this._sw.lat),i=new W(this._ne.lng,this._ne.lat);return t.lng>i.lng?new pr(t,new W(i.lng+360,i.lat)):new pr(t,i)}},ny=class{constructor(e,t,i){this.bounds=Mi.convert(this.validateBounds(e)),this.minzoom=t||0,this.maxzoom=i||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,i={minX:Math.floor(Va(this.bounds.getWest())*t),minY:Math.floor(ja(this.bounds.getNorth())*t),maxX:Math.ceil(Va(this.bounds.getEast())*t),maxY:Math.ceil(ja(this.bounds.getSouth())*t)};return e.x>=i.minX&&e.x<i.maxX&&e.y>=i.minY&&e.y<i.maxY}},sy=class extends ot{constructor(e,t,i,r){if(super(),this.id=e,this.dispatcher=i,this.type="vector",this.minzoom=0,this.maxzoom=22,this.scheme="xyz",this.tileSize=512,this.reparseOverscaled=!0,this.isTileClipped=!0,this._loaded=!1,Z(this,dn(t,["url","scheme","tileSize","promoteId","encoding"])),this._options=Z({type:"vector"},t),this._collectResourceTiming=t.collectResourceTiming,this.tileSize!==512)throw Error("vector tile sources must have a tileSize of 512");this.setEventedParent(r)}async load(e=!1){this._loaded=!1,this.fire(new Re("dataloading")),this._tileJSONRequest=new AbortController;try{let t=await ay(this._options,this.map._requestManager,this._tileJSONRequest,this.map._ownerWindow);this._tileJSONRequest=null,this._loaded=!0,t&&(Z(this,t),t.bounds&&(this.tileBounds=new ny(t.bounds,this.minzoom,this.maxzoom)),this.fire(new Re("data",{sourceDataType:"metadata"})),this.fire(new Re("data",{sourceDataType:"content",sourceDataChanged:e})))}catch(t){this._tileJSONRequest=null,this._loaded=!0,br(t)||this.fire(new K(St(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 Z({},this._options)}async loadTile(e){let t=e.tileID.canonical.url(this.tiles,this.map.getPixelRatio(),this.scheme),i={request:await this.map._requestManager.transformRequest(t,"Tile"),uid:e.uid,tileID:e.tileID,zoom:e.tileID.overscaledZ,tileSize:this.tileSize*e.tileID.overscaleFactor(),type:this.type,source:this.id,pixelRatio:this.map.getPixelRatio(),showCollisionBoxes:this.map.showCollisionBoxes,promoteId:this.promoteId,subdivisionGranularity:this.map.style.projection.subdivisionGranularity,encoding:this.encoding,overzoomParameters:await this._getOverzoomParameters(e),etag:e.etag};i.request.collectResourceTiming=this._collectResourceTiming,await this.dispatcher.waitForInitComplete();let r="RT";if(!e.actor||e.state==="expired")e.actor=this.dispatcher.getReadyActor(),r="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:r,data:i},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||br(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,i=t.url(this.tiles,this.map.getPixelRatio(),this.scheme);return{maxZoomTileID:t,overzoomRequest:await this.map._requestManager.transformRequest(i,"Tile")}}_afterTileLoadWorkerResponse(e,t){if(t!=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 i=e.reloadPromise;e.reloadPromise=null,this.loadTile(e).then(i.resolve).catch(i.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}},zc=class extends ot{constructor(e,t,i,r){super(),this.id=e,this.dispatcher=i,this.setEventedParent(r),this.type="raster",this.minzoom=0,this.maxzoom=22,this.roundZoom=!0,this.scheme="xyz",this.tileSize=512,this._loaded=!1,this._premultiplyAlpha=!0,this._options=Z({type:"raster"},t),Z(this,dn(t,["url","scheme","tileSize"]))}async load(e=!1){this._loaded=!1,this.fire(new Re("dataloading")),this._tileJSONRequest=new AbortController;try{let t=await ay(this._options,this.map._requestManager,this._tileJSONRequest,this.map._ownerWindow);this._tileJSONRequest=null,this._loaded=!0,t&&(Z(this,t),t.bounds&&(this.tileBounds=new ny(t.bounds,this.minzoom,this.maxzoom)),this.fire(new Re("data",{sourceDataType:"metadata"})),this.fire(new Re("data",{sourceDataType:"content",sourceDataChanged:e})))}catch(t){this._tileJSONRequest=null,this._loaded=!0,br(t)||this.fire(new K(St(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 Z({},this._options)}setPremultiplyAlpha(e){return this._premultiplyAlpha===e||this.setSourceProperty(()=>{this._premultiplyAlpha=e}),this}hasTile(e){return!this.tileBounds||this.tileBounds.contains(e.canonical)}async loadTile(e){let t=e.tileID.canonical.url(this.tiles,this.map.getPixelRatio(),this.scheme),i=this._premultiplyAlpha,r=i?void 0:{premultiplyAlpha:"none"};e.abortController=new AbortController;try{let a=await qi.transformAndGetImage(this.map._requestManager,t,"Tile",e.abortController,this.map._refreshExpiredTiles,r);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 Fe({width:1,height:1},new Uint8Array(4));e.texture=this.map.painter.getTileTexture(o.width),e.texture?e.texture.update(o,{useMipmap:!0,premultiply:i}):(e.texture=new lt(n,o,s.RGBA,{useMipmap:!0,premultiply:i}),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}},oy=class extends zc{constructor(e,t,i,r){super(e,t,i,r),this.type="raster-dem",this.maxzoom=22,this._options=Z({type:"raster-dem"},t),this.encoding=t.encoding||"mapbox",this.redFactor=t.redFactor,this.greenFactor=t.greenFactor,this.blueFactor=t.blueFactor,this.baseShift=t.baseShift}async loadTile(e){let t=e.tileID.canonical.url(this.tiles,this.map.getPixelRatio(),this.scheme);e.neighboringTiles=this._getNeighboringTiles(e.tileID),e.abortController=new AbortController;try{let i=await qi.transformAndGetImage(this.map._requestManager,t,"Tile",e.abortController,this.map._refreshExpiredTiles,{colorSpaceConversion:"none"});if(delete e.abortController,e.aborted){e.state="unloaded";return}if(i){if(this.map._refreshExpiredTiles&&(i.cacheControl||i.expires)&&e.setExpiryData({cacheControl:i.cacheControl,expires:i.expires}),!i.data){e.state="loaded";return}let r=i.data,a=jr(r)&&tp()?r:await this.readImageNow(r),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(i){if(delete e.abortController,e.aborted)e.state="unloaded";else if(i)throw e.state="errored",i}}async readImageNow(e){if(typeof VideoFrame<"u"&&K1()){let t=e.width+4,i=e.height+4;try{return new Fe({width:t,height:i},await $x(e,-2,-2,t,i))}catch{}}return jt.getImageData(e,2)}_getNeighboringTiles(e){let t=e.canonical,i=2**t.z,r=(t.x-1+i)%i,a=t.x===0?e.wrap-1:e.wrap,n=(t.x+1+i)%i,s=t.x+1===i?e.wrap+1:e.wrap,o={};return o[new Pt(e.overscaledZ,a,t.z,r,t.y).key]={backfilled:!1},o[new Pt(e.overscaledZ,s,t.z,n,t.y).key]={backfilled:!1},t.y>0&&(o[new Pt(e.overscaledZ,a,t.z,r,t.y-1).key]={backfilled:!1},o[new Pt(e.overscaledZ,e.wrap,t.z,t.x,t.y-1).key]={backfilled:!1},o[new Pt(e.overscaledZ,s,t.z,n,t.y-1).key]={backfilled:!1}),t.y+1<i&&(o[new Pt(e.overscaledZ,a,t.z,r,t.y+1).key]={backfilled:!1},o[new Pt(e.overscaledZ,e.wrap,t.z,t.x,t.y+1).key]={backfilled:!1},o[new Pt(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 Fc(e,t){return t?e.properties[t]:e.id}function XD(e,t){let i=new Map;if(e==null||e.type==null)return i;if(e.type==="Feature"){let r=Fc(e,t);return r==null?void 0:(i.set(r,e),i)}if(e.type==="FeatureCollection"){let r=new Set;for(let a of e.features){let n=Fc(a,t);if(n==null||r.has(n))return;r.add(n),i.set(n,a)}return i}}function YD(e,t,i){var a,n;let r=[];if(t.removeAll)e.clear();else if(t.remove)for(let s of t.remove){let o=e.get(s);o&&(r.push(o.geometry),e.delete(s))}if(t.add)for(let s of t.add){let o=Fc(s,i);if(o==null)continue;let l=e.get(o);l&&r.push(l.geometry),r.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;r.push(o.geometry);let h={...o};if(e.set(s.id,h),l&&(r.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 r}function KD(e,t,i){if(!e)return t||{};if(!t)return e||{};let r=ly(e),a=ly(t);JD(r,a);let n={};if((r.removeAll||a.removeAll)&&(n.removeAll=!0),n.remove=new Set([...r.remove,...a.remove]),n.add=new Map([...r.add,...a.add]),n.update=new Map([...r.update,...a.update]),n.remove.size&&n.add.size)for(let o of n.add.keys())n.remove.delete(o);return eI(n)}function JD(e,t){t.removeAll&&(e.add.clear(),e.update.clear(),e.remove.clear(),t.remove.clear());for(let i of t.remove)e.add.delete(i),e.update.delete(i);for(let[i,r]of t.update){let a=e.update.get(i);a&&(t.update.set(i,QD(a,r)),e.update.delete(i))}}function QD(e,t){let i={id:e.id};if(t.removeAllProperties&&(delete e.removeProperties,delete e.addOrUpdateProperties,delete t.removeProperties),t.removeProperties)for(let r of t.removeProperties){let a=e.addOrUpdateProperties.findIndex(n=>n.key===r);a>-1&&e.addOrUpdateProperties.splice(a,1)}return(e.removeAllProperties||t.removeAllProperties)&&(i.removeAllProperties=!0),(e.removeProperties||t.removeProperties)&&(i.removeProperties=[...e.removeProperties||[],...t.removeProperties||[]]),(e.addOrUpdateProperties||t.addOrUpdateProperties)&&(i.addOrUpdateProperties=[...e.addOrUpdateProperties||[],...t.addOrUpdateProperties||[]]),(e.newGeometry||t.newGeometry)&&(i.newGeometry=t.newGeometry||e.newGeometry),i}function ly(e){var i,r;if(!e)return{};let t={};return t.removeAll=e.removeAll,t.remove=new Set(e.remove||[]),t.add=new Map((i=e.add)==null?void 0:i.map(a=>[a.id,a])),t.update=new Map((r=e.update)==null?void 0:r.map(a=>[a.id,a])),t}function eI(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 uy(e){return!e||e.length===0?[]:typeof e[0]=="number"?[e]:e.flatMap(t=>uy(t))}function cl(e){return e.type==="GeometryCollection"?e.geometries.flatMap(t=>cl(t)):uy(e.coordinates)}function hy(e){let t=new Mi,i;switch(e.type){case"FeatureCollection":i=e.features.flatMap(r=>cl(r.geometry));break;case"Feature":i=cl(e.geometry);break;default:i=cl(e)}if(i.length===0)return t;for(let r of i){let[a,n]=r;t.extend([a,n])}return t}function tI({x:e,y:t,z:i},r=0){let a=Nh((e-r)/2**i),n=Jn((t+1+r)/2**i),s=Nh((e+1+r)/2**i),o=Jn((t-r)/2**i);return new Mi([a,n],[s,o])}var cy=class extends ot{constructor(e,t,i,r){super(),this.id=e,this.type="geojson",this.minzoom=0,this.maxzoom=18,this.tileSize=512,this.isTileClipped=!0,this.reparseOverscaled=!0,this._removed=!1,this._isUpdatingWorker=!1,this._pendingWorkerUpdate={data:t.data},this.actorPromise=i.getActor(),this.setEventedParent(r),this._data=typeof t.data=="string"?{url:t.data}:{geojson:t.data},this._options=Z({},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&&le(`The maxzoom value "${this.maxzoom}" is expected to be greater than the clusterMaxZoom value "${t.clusterMaxZoom}".`),this.workerOptions=Z({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:k,maxZoom:this.maxzoom,lineMetrics:t.lineMetrics||!1,generateId:t.generateId||!1,promoteId:typeof t.promoteId=="string"?t.promoteId:void 0,cluster:t.cluster||!1,clusterOptions:{maxZoom:this._getClusterMaxZoom(t.clusterMaxZoom),minPoints:Math.max(2,t.clusterMinPoints||2),extent:k,radius:this._pixelsToTileUnits(t.clusterRadius||50),log:!1,generateId:t.generateId||!1}},clusterProperties:t.clusterProperties,filter:t.filter},t.workerOptions)}_hasPendingWorkerUpdate(){return this._pendingWorkerUpdate.data!==void 0||this._pendingWorkerUpdate.diff!==void 0||this._pendingWorkerUpdate.updateCluster}_pixelsToTileUnits(e){return e*(k/this.tileSize)}_tileUnitsToPixels(e){return e/(k/this.tileSize)}_getClusterMaxZoom(e){let t=e?Math.round(e):this.maxzoom-1;return Number.isInteger(e)||e===void 0||le(`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=KD(this._pendingWorkerUpdate.diff,e),this._updateWorkerData()}async getData(){return this._data.url&&await this.once("data"),this._data.geojson?this._data.geojson:{type:"FeatureCollection",features:Array.from(this._data.updateable.values())}}async getBounds(){return hy(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,i){return(await this.actorPromise).sendAsync({type:"GCL",data:{type:this.type,source:this.id,clusterId:e,limit:t,offset:i}})}async _updateWorkerData(){if(this._isUpdatingWorker)return this._updatePromise;if(!this._hasPendingWorkerUpdate()){le(`No pending worker updates for GeoJSONSource ${this.id}.`);return}let{data:e,diff:t,updateCluster:i}=this._pendingWorkerUpdate,r=this._getLoadGeoJSONParameters(e,t,i);e===void 0?t?this._pendingWorkerUpdate.diff=void 0:i&&(this._pendingWorkerUpdate.updateCluster=void 0):this._pendingWorkerUpdate.data=void 0,this._updatePromise=this._dispatchWorkerUpdate(r),await this._updatePromise}async _getLoadGeoJSONParameters(e,t,i){let r=Z({type:this.type,source:this.id},this.workerOptions);if(typeof e=="string")return r.request=await this.map._requestManager.transformRequest(jt.resolveURL(e),"Source"),r.request.collectResourceTiming=this._collectResourceTiming,r;if(e!==void 0)return r.data=e,r;if(t)return r.dataDiff=t,r;if(i)return r.updateCluster=!0,r}async _dispatchWorkerUpdate(e){this._isUpdatingWorker=!0,this.fire(new Re("dataloading"));try{let t=await e,i=await(await this.actorPromise).sendAsync({type:"LD",data:t});if(this._isUpdatingWorker=!1,this._removed||i.abandoned){this.fire(new Re("dataabort"));return}i.data&&(this._data={geojson:i.data});let r=this._applyDiffToSource(t.dataDiff),a=this._getShouldReloadTileOptions(r),n={};this._applyResourceTiming(n,i),this.fire(new Re("data",{...n,sourceDataType:"metadata"})),this.fire(new Re("data",{...n,sourceDataType:"content",shouldReloadTileOptions:a}))}catch(t){if(this._isUpdatingWorker=!1,this._removed){this.fire(new Re("dataabort"));return}this.fire(new K(St(t)))}finally{this._hasPendingWorkerUpdate()&&await this._updateWorkerData()}}_applyResourceTiming(e,t){var a;if(!this._collectResourceTiming)return;let i=(a=t.resourceTiming)==null?void 0:a[this.id];if(!i)return;let r=i.slice(0);r!=null&&r.length&&Z(e,{resourceTiming:r})}_applyDiffToSource(e){if(!e)return;let t=typeof this.promoteId=="string"?this.promoteId:void 0;if(!this._data.url&&!this._data.updateable){let r=XD(this._data.geojson,t);if(!r)throw Error(`GeoJSONSource "${this.id}": GeoJSON data is not compatible with updateData`);this._data={updateable:r}}if(!this._data.updateable)return;let i=YD(this._data.updateable,e,t);if(!(e.removeAll||this._options.cluster))return i}_getShouldReloadTileOptions(e){if(e)return{affectedBounds:e.filter(Boolean).map(t=>hy(t))}}shouldReloadTile(e,{affectedBounds:t}){if(e.state==="loading")return!0;if(e.state==="unloaded")return!1;let{buffer:i,extent:r}=this.workerOptions.geojsonVtOptions,a=tI(e.tileID.canonical,i/r);for(let n of t)if(a.intersects(n))return!0;return!1}loaded(){return!this._isUpdatingWorker&&!this._hasPendingWorkerUpdate()}async loadTile(e){let t=e.actor?"RT":"LT";e.actor=await this.actorPromise;let i={type:this.type,uid:e.uid,tileID:e.tileID,zoom:e.tileID.overscaledZ,maxZoom:this.maxzoom,tileSize:this.tileSize,source:this.id,pixelRatio:this.map.getPixelRatio(),showCollisionBoxes:this.map.showCollisionBoxes,promoteId:this.promoteId,subdivisionGranularity:this.map.style.projection.subdivisionGranularity};e.abortController=new AbortController;try{let r=await(await this.actorPromise).sendAsync({type:t,data:i},e.abortController);delete e.abortController,e.unloadVectorData(),e.aborted||e.loadVectorData(r,this.map.painter,t==="RT")}catch(r){if(delete e.abortController,e.aborted||br(r))return;throw r}}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 Z({},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 Ja=[0,0,1],iI=(e,t)=>({u_tl_parent:new se(e,t.u_tl_parent),u_scale_parent:new G(e,t.u_scale_parent),u_buffer_scale:new G(e,t.u_buffer_scale),u_image_warp:new Ot(e,t.u_image_warp),u_fade_t:new G(e,t.u_fade_t),u_opacity:new G(e,t.u_opacity),u_image0:new X(e,t.u_image0),u_image1:new X(e,t.u_image1),u_brightness_low:new G(e,t.u_brightness_low),u_brightness_high:new G(e,t.u_brightness_high),u_saturation_factor:new G(e,t.u_saturation_factor),u_contrast_factor:new G(e,t.u_contrast_factor),u_spin_weights:new Ot(e,t.u_spin_weights),u_coords_top:new On(e,t.u_coords_top),u_coords_bottom:new On(e,t.u_coords_bottom)}),rI=(e,t,i,r,a,n)=>({u_tl_parent:e,u_scale_parent:t,u_buffer_scale:1,u_image_warp:n,u_fade_t:i.mix,u_opacity:i.opacity*r.paint.get("raster-opacity"),u_image0:0,u_image1:1,u_brightness_low:r.paint.get("raster-brightness-min"),u_brightness_high:r.paint.get("raster-brightness-max"),u_saturation_factor:sI(r.paint.get("raster-saturation")),u_contrast_factor:nI(r.paint.get("raster-contrast")),u_spin_weights:aI(r.paint.get("raster-hue-rotate")),u_coords_top:[a[0].x,a[0].y,a[1].x,a[1].y],u_coords_bottom:[a[3].x,a[3].y,a[2].x,a[2].y]});function aI(e){e*=Math.PI/180;let t=Math.sin(e),i=Math.cos(e);return[(2*i+1)/3,(-Math.sqrt(3)*t-i+1)/3,(Math.sqrt(3)*t-i+1)/3]}function nI(e){return e>0?1/(1-e):1+e}function sI(e){return e>0?1-1/(1.001-e):-e}var os=class{constructor(e,t,i){this.vertexBuffer=e,this.indexBuffer=t,this.segments=i}destroy(){this.vertexBuffer.destroy(),this.indexBuffer.destroy(),this.segments.destroy(),this.vertexBuffer=null,this.indexBuffer=null,this.segments=null}};const ca=We([{name:"a_pos",type:"Int16",components:2}]),dl=k/128;function dy(e,t){let i=py(t,"16bit"),r=Pr.deserialize({arrayBuffer:i.vertices,length:i.vertices.byteLength/2/2}),a=Gi.deserialize({arrayBuffer:i.indices,length:i.indices.byteLength/2/3});return new os(e.createVertexBuffer(r,ca.members),e.createIndexBuffer(a),Ne.simpleSegment(0,0,r.length,a.length))}function py(e,t){let i=e.granularity===void 0?1:Math.max(e.granularity,1),r=i+(e.generateBorders?2:0),a=i+(e.extendToNorthPole||e.generateBorders?1:0)+(e.extendToSouthPole||e.generateBorders?1:0),n=r+1,s=a+1,o=e.generateBorders?-1:0,l=e.generateBorders||e.extendToNorthPole?-1:0,u=i+ +!!e.generateBorders,h=i+(e.generateBorders||e.extendToSouthPole?1:0),c=n*s,d=r*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 x=l;x<=h;x++)for(let v=o;v<=u;v++){let w=v/i*k;v===-1&&(w=-dl),v===i+1&&(w=k+dl);let b=x/i*k;x===-1&&(b=e.extendToNorthPole?Hn:-dl),x===i+1&&(b=e.extendToSouthPole?Xn:k+dl),m[g++]=w,m[g++]=b}let _=f?new Uint32Array(d):new Uint16Array(d),y=0;for(let x=0;x<a;x++)for(let v=0;v<r;v++){let w=v+x*n,b=v+1+x*n,T=v+(x+1)*n,P=v+1+(x+1)*n;_[y++]=w,_[y++]=T,_[y++]=b,_[y++]=b,_[y++]=T,_[y++]=P}return{vertices:m.buffer.slice(0),indices:_.buffer.slice(0),uses32bitIndices:f}}var Qa=class extends ot{constructor(e,t,i,r){super(),this.imageWarp=Ja,this.flippedWindingOrder=!1,this._warp="auto",this._imageDirty=!1,this._subdividedQuad=!1,this._subdividedMesh=null,this.id=e,this.dispatcher=i,this.coordinates=t.coordinates,this.type="image",this.minzoom=0,this.maxzoom=22,this.tileSize=512,this.tiles={},this._loaded=!1,this.setEventedParent(r),this.options=t}async load(e){if(this.options.url===void 0){this._loaded=!0,this._finishLoading();return}this._loaded=!1,this.fire(new Re("dataloading")),this.url=this.options.url,this._abortController=new AbortController;try{let t=await qi.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 K(Error(`Could not load image ${this.url}: the response is empty`)))}catch(t){if(br(t))return;this._abortController=null,this._loaded=!0,this.fire(new K(St(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=dy(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 Re("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(ye.fromLngLat);return this.tileID=oI(t),this.terrainTileRanges=this._getOverlappingTileRanges(t),this.minzoom=this.maxzoom=this.tileID.z,this.tileCoords=t.map(i=>this.tileID.getTilePoint(i)._round()),this.imageWarp=uI(this.tileCoords,this._warp),this._subdividedQuad=this.imageWarp[2]>0&&!fy(this.tileCoords),this.flippedWindingOrder=lI(this.tileCoords),this.fire(new Re("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 lt(e,this.image,t.RGBA),this.texture.bind(t.LINEAR,t.CLAMP_TO_EDGE)),this._imageDirty=!1;let i=!1;for(let r in this.tiles){let a=this.tiles[r];a.state!=="loaded"&&(a.state="loaded",a.texture=this.texture,i=!0)}i&&this.fire(new Re("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:i,maxX:r,maxY:a}=Di.fromPoints(e),n={};for(let s=0;s<=25;s++){let o=2**s,l=Math.floor(t*o),u=Math.floor(i*o),h=Math.floor(r*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 oI(e){let t=Di.fromPoints(e),i=t.width(),r=t.height(),a=Math.max(0,Math.floor(-Math.log(Math.max(i,r))/Math.LN2)),n=2**a;return new Jo(a,Math.floor((t.minX+t.maxX)/2*n),Math.floor((t.minY+t.maxY)/2*n))}function lI(e){let t=e[1].x-e[0].x,i=e[1].y-e[0].y,r=e[2].x-e[0].x;return t*(e[2].y-e[0].y)-i*r<0}function uI(e,t){if(t==="flat"||fy(e))return Ja;let[i,r,a,n]=e,s=i.x-r.x+a.x-n.x,o=i.y-r.y+a.y-n.y,l=[r.x-a.x,r.y-a.y,n.x-a.x,n.y-a.y],[u,h,c,d]=l,p=eD(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:hI(_);return!(_>=1&&_<=512)||y>=1?Ja:[f,m,y]}function hI(e){let t=(1-4/e)/.9921875;return Math.max(0,t)}function fy(e){let[t,i,r,a]=e;return t.x+r.x===i.x+a.x&&t.y+r.y===i.y+a.y}var my=class extends Qa{constructor(e,t,i,r){super(e,t,i,r),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 Hx(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 K(St(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 K(new $(`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 lt(e,this.video,t.RGBA),this.texture.bind(t.LINEAR,t.CLAMP_TO_EDGE));let i=!1;for(let r in this.tiles){let a=this.tiles[r];a.state!=="loaded"&&(a.state="loaded",a.texture=this.texture,i=!0)}i&&this.fire(new Re("data",{sourceDataType:"idle",sourceId:this.id}))}serialize(){return{type:"video",urls:this.urls,coordinates:this.coordinates}}hasTransition(){return this.video&&!this.video.paused}},gy=class extends Qa{constructor(e,t,i,r){super(e,t,i,r),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 K(new $(`sources.${e}`,null,'"coordinates" property must be an array of 4 longitude/latitude array pairs'))):this.fire(new K(new $(`sources.${e}`,null,'missing required property "coordinates"'))),t.animate&&typeof t.animate!="boolean"&&this.fire(new K(new $(`sources.${e}`,null,'optional "animate" property must be a boolean value'))),t.canvas?typeof t.canvas!="string"&&!(t.canvas instanceof HTMLCanvasElement)&&this.fire(new K(new $(`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 K(new $(`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 K(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,i=t.gl;this.texture?(e||this._playing)&&this.texture.update(this.canvas,{premultiply:!0}):(this.texture=new lt(t,this.canvas,i.RGBA,{premultiply:!0}),this.texture.bind(i.LINEAR,i.CLAMP_TO_EDGE));let r=!1;for(let a in this.tiles){let n=this.tiles[a];n.state!=="loaded"&&(n.state="loaded",n.texture=this.texture,r=!0)}r&&this.fire(new Re("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 _y={},cI=(e,t,i,r)=>{let a=new(yy(t.type))(e,t,i,r);if(a.id!==e)throw Error(`Expected Source id to be ${e} instead of ${a.id}`);return a},yy=e=>{switch(e){case"geojson":return cy;case"image":return Qa;case"raster":return zc;case"raster-dem":return oy;case"vector":return sy;case"video":return my;case"canvas":return gy}return _y[e]},dI=(e,t)=>{_y[e]=t},pI=async(e,t)=>{if(yy(e))throw Error(`A source type called "${e}" already exists.`);dI(e,t)};function fI(e,t){let i={};if(!t)return i;for(let r of e){let a=r.layerIds.map(n=>t.getLayer(n)).filter(Boolean);if(a.length!==0){r.layers=a,r.stateDependentLayerIds&&(r.stateDependentLayers=r.stateDependentLayerIds.map(n=>a.filter(s=>s.id===n)[0]));for(let n of a)i[n.id]=r}}return i}const Rc="RTLPluginLoaded";var mI=class extends ot{constructor(...e){super(...e),this.status="unavailable",this.url=null,this.dispatcher=Mc()}_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=jt.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 ti(Rc))}lazyLoad(){this.status==="unavailable"?this.status="requested":this.status==="deferred"&&this._requestImport()}};let vy=null;function ls(){return vy||(vy=new mI),vy}var xy=class{constructor(e,t){this.timeAdded=0,this.fadeEndTime=0,this.fadeOpacity=1,this.tileID=e,this.uid=mp(),this.uses=0,this.tileSize=t,this.buckets={},this.expirationTime=null,this.queryPadding=0,this.hasSymbolBuckets=!1,this.hasRTLText=!1,this.dependencies={},this.rttObjects=[],this.rttFingerprint={},this.expiredRequestCount=0,this.state="loading",this.featureStateRevision=-1}isRenderable(e){return this.hasData()&&(!this.fadeEndTime||this.fadeOpacity>0)&&(e||!this.holdingForSymbolFade())}setCrossFadeLogic({fadingRole:e,fadingDirection:t,fadingParentID:i,fadeEndTime:r}){this.resetFadeLogic(),this.fadingRole=e,this.fadingDirection=t,this.fadingParentID=i,this.fadeEndTime=r}setSelfFadeLogic(e){this.resetFadeLogic(),this.selfFading=!0,this.fadeEndTime=e}resetFadeLogic(){this.fadingRole=null,this.fadingDirection=null,this.fadingParentID=null,this.selfFading=!1,this.timeAdded=Te(),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,i){return this.rttObjects[t]=e.acquireRTT(i)}releaseRTT(e){if(this.rttObjects.length!==0){for(let t of this.rttObjects)t&&e.releaseRTT(t);this.rttObjects.length=0}}loadVectorData(e,t,i){if((e==null?void 0:e.etagUnmodified)===!0){this.state="loaded";return}if(this.hasData()&&this.unloadVectorData(),this.state="loaded",!e){this.collisionBoxArray=new sm;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=fI(e.buckets,t==null?void 0:t.style),this.hasSymbolBuckets=!1;for(let r in this.buckets){let a=this.buckets[r];if(a instanceof Ko)if(this.hasSymbolBuckets=!0,i)a.justReloaded=!0;else break}if(this.hasRTLText=!1,this.hasSymbolBuckets)for(let r in this.buckets){let a=this.buckets[r];if(a instanceof Ko&&a.hasRTLText){this.hasRTLText=!0,ls().lazyLoad();break}}this.queryPadding=0;for(let r in this.buckets){let a=this.buckets[r];this.queryPadding=Math.max(this.queryPadding,t.style.getLayer(r).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 i in this.buckets){let r=this.buckets[i];r.uploadPending()&&r.upload(e)}let t=e.gl;this.imageAtlas&&!this.imageAtlas.uploaded&&(this.imageAtlasTexture=new lt(e,this.imageAtlas.image,t.RGBA),this.imageAtlas.uploaded=!0),this.glyphAtlasImage&&(this.glyphAtlasImage=(this.glyphAtlasTexture=new lt(e,this.glyphAtlasImage,t.ALPHA),null))}prepare(e){this.imageAtlas&&this.imageAtlas.patchUpdatedImages(e,this.imageAtlasTexture)}queryRenderedFeatures(e,t,i,r,a,n,s,o,l,u,h){var c;return(c=this.latestFeatureIndex)!=null&&c.rawTileData?this.latestFeatureIndex.query({queryGeometry:r,cameraQueryGeometry:a,scale:n,tileSize:this.tileSize,pixelPosMatrix:u,transform:o,params:s,queryPadding:this.queryPadding*l,getElevation:h},e,t,i):{}}querySourceFeatures(e,t){let i=this.latestFeatureIndex;if(!(i!=null&&i.rawTileData))return;let r=i.loadVTLayers(),a=t!=null&&t.sourceLayer?t.sourceLayer:"",n=r._geojsonTileLayer||r[a];if(!n)return;let s=In(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=Qr(d,!0);if(!s.filter(new be(this.tileID.overscaledZ),m,this.tileID.canonical))continue}else if(!s.filter(new be(this.tileID.overscaledZ),d))continue;let p=i.getId(d,a),f=new Yg(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 i=Fx(e.cacheControl);i["max-age"]&&(this.expirationTime=Date.now()+i["max-age"]*1e3)}else e.expires&&(this.expirationTime=new Date(e.expires).getTime());if(this.expirationTime){let i=Date.now(),r=!1;if(this.expirationTime>i)r=!1;else if(!t)r=!0;else if(this.expirationTime<t)r=!0;else{let a=this.expirationTime-t;a?this.expirationTime=i+Math.max(a,3e4):r=!0}r?(this.expiredRequestCount++,this.state="expired"):this.expiredRequestCount=0}}getExpiryTimeout(){if(this.expirationTime)return this.expiredRequestCount?1e3*(1<<Math.min(this.expiredRequestCount-1,31)):Math.min(this.expirationTime-new Date().getTime(),2**31-1)}setFeatureState(e,t,i){var a,n,s;if(!((a=this.latestFeatureIndex)!=null&&a.rawTileData)||Object.keys(e).length===0||this.featureStateRevision===i)return;this.featureStateRevision=i;let r=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=r[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<Te()}clearSymbolFadeHold(){this.symbolFadeHoldUntil=void 0}setSymbolHoldDuration(e){this.symbolFadeHoldUntil=Te()+e}setDependencies(e,t){let i={};for(let r of t)i[r]=!0;this.dependencies[e]=i}hasDependency(e,t){for(let i of e){let r=this.dependencies[i];if(r){for(let a of t)if(r[a])return!0}}return!1}};function by(e){let t=[];for(let i in e)t.push({id:i,state:e[i]});return t}var gI=class{constructor(){this.state={},this.stateChanges={},this.deletedStates={},this.revision=0}updateState(e,t,i){var a,n,s,o,l;let r=String(t);if((a=this.stateChanges)[e]||(a[e]={}),(n=this.stateChanges[e])[r]||(n[r]={}),Z(this.stateChanges[e][r],i),this.deletedStates[e]===null){this.deletedStates[e]={};for(let u in this.state[e])if(u===r){this.deletedStates[e][r]={};for(let h in this.state[e][u])i[h]===void 0&&(this.deletedStates[e][r][h]=null)}else this.deletedStates[e][u]=null}else if(((s=this.deletedStates[e])==null?void 0:s[r])===null){this.deletedStates[e][r]={};for(let u in this.state[e][r])i[u]===void 0&&(this.deletedStates[e][r][u]=null)}else for(let u in i)((l=(o=this.deletedStates[e])==null?void 0:o[r])==null?void 0:l[u])===null&&delete this.deletedStates[e][r][u]}removeFeatureState(e,t,i){var a,n,s;if(this.deletedStates[e]===null)return;let r=String(t);if((a=this.deletedStates)[e]||(a[e]={}),i&&t!==void 0)this.deletedStates[e][r]!==null&&((n=this.deletedStates[e])[r]||(n[r]={}),this.deletedStates[e][r][i]=null);else if(t!==void 0)if((s=this.stateChanges[e])!=null&&s[r])for(i in this.deletedStates[e][r]={},this.stateChanges[e][r])this.deletedStates[e][r][i]=null;else this.deletedStates[e][r]=null;else this.deletedStates[e]=null}getState(e,t){let i=String(t),r=this.state[e]||{},a=this.stateChanges[e]||{},n=Z({},r[i],a[i]);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 i={};for(let r in this.state)i[r]=by(this.state[r]);e.setFeatureState(i,t,this.revision)}coalesceChanges(e,t){var a,n,s;let i={};for(let o in this.stateChanges){(a=this.state)[o]||(a[o]={}),i[o]||(i[o]={});for(let l in this.stateChanges[o])(n=this.state[o])[l]||(n[l]={}),Z(this.state[o][l],this.stateChanges[o][l]),i[o][l]=this.state[o][l]}for(let o in this.deletedStates)if((s=this.state)[o]||(s[o]={}),i[o]||(i[o]={}),this.deletedStates[o]===null)for(let l in this.state[o])this.state[o][l]={},i[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];i[o][l]=this.state[o][l]}if(this.stateChanges={},this.deletedStates={},Object.keys(i).length===0)return;this.revision++;let r={};for(let o in i)r[o]=by(i[o]);e.setFeatureState(r,t,this.revision)}},kc=class R1{constructor(t,i){this.min=t,this.max=i,this.center=ke([],ui([],this.min,this.max),.5)}quadrant(t){let i=[t%2==0,t<2],r=ql(this.min),a=ql(this.max);for(let n=0;n<i.length;n++)r[n]=i[n]?this.min[n]:this.center[n],a[n]=i[n]?this.center[n]:this.max[n];return a[2]=this.max[2],new R1(r,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 i=!0;for(let r of t.planes){let a=this.intersectsPlane(r);if(a===0)return 0;a===1&&(i=!1)}return i?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 i=t[3],r=t[3];for(let a=0;a<3;a++)t[a]>0?(i+=t[a]*this.min[a],r+=t[a]*this.max[a]):(r+=t[a]*this.min[a],i+=t[a]*this.max[a]);return i>=0?2:r<0?0:1}},Lc=class k1{constructor(t,i,r){this.points=t,this.planes=i,this.aabb=r}static fromInvProjectionMatrix(t,i=1,r=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**r,u=s.map(p=>_I(p,t,i,l));a&&yI(u,o[0],a,n);let h=o.map(p=>{let f=Ji([],u[p[0]],u[p[1]]),m=Ji([],u[p[2]],u[p[1]]),g=Bt([],qt([],f,m)),_=-st(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 k1(u,h,new kc(c,d))}};function _I(e,t,i,r){let a=pt([],e,t),n=1/a[3]/i*r;return _x(a,a,[n,n,1/a[3],n])}function yI(e,t,i,r){let a=r?4:0,n=r?0:4,s=0,o=[],l=[];for(let c=0;c<4;c++){let d=Ji([],e[c+n],e[c+a]),p=Ki(d);ke(d,d,1/p),o.push(p),l.push(d)}for(let c=0;c<4;c++){let d=Sx(e[c+a],l[c],i);s=d!==null&&d>=0?Math.max(s,d):Math.max(s,o[c])}let u=vI(e,t),h=xI(i,u);if(h!==null){let c=h/st(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 vI(e,t){let i=Ji([],e[t[0]],e[t[1]]),r=Ji([],e[t[2]],e[t[1]]),a=[0,0,0,0];return Bt(a,qt([],i,r)),a[3]=-st(a,e[t[0]]),a}function xI(e,t){let i=Bs(e),r=mx([],e,1/i),a=Ji([],t,ke([],r,st(t,r))),n=Bs(a);if(n>0){let s=Math.sqrt(1-r[3]*r[3]),o=ke([],r,-r[3]),l=ui([],o,ke([],a,s/n));return Kl(t,l)}return null}function bI(e,t,i){let r=t.intersectsFrustum(e);if(!i||r===0)return r;let a=t.intersectsPlane(i);return a===0?0:r===2&&a===2?2:1}function wy(e,t,i){let r=0,a=(i-t)/10;for(let n=0;n<10;n++){let s=t+(n+.5)/10*(i-t);r+=a*Math.cos(s)**+e}return r}function Bc(e,t){return function(i,r,a,n,s){let o=2*((e-1)/Et(Math.cos(Be(aa-s))/Math.cos(Be(aa)))-1),l=Math.acos(a/n),u=2*wy(o-1,0,Be(s/2)),h=Math.min(Be(aa),l+Be(s/2)),c=Math.min(h,l-Be(s/2)),d=wy(o-1,c,h),p=Math.atan(r/a),f=Math.hypot(r,a),m=i;return m+=Et(n/f/Math.max(.5,Math.cos(Be(s/2)))),m+=o*Et(Math.cos(p))/2,m-=Et(Math.max(1,d/u/t))/2,m}}const wI=Bc(9.314,3);function $c(e,t){let i=(t.roundZoom?Math.round:Math.floor)(e.zoom+Et(e.tileSize/t.tileSize));return Math.max(0,i)}function TI(e,t){let i=aa-e.pitch-e.fov/2,r=ee((15-i)/15,0,1),a=Math.max(500,t??0);return e.elevation+r*a}function SI(e,t,i){let r=e.planes[1],a=e.points.map(l=>{let u=r[0]*l[0]+r[1]*l[1]+r[2]*l[2]+r[3];if(Math.abs(u)>1e-6)return l;let h=[l[0]-i[0],l[1]-i[1],l[2]-i[2]],c=r[0]*h[0]+r[1]*h[1]+r[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 Lc(a,n,new kc(s,o))}function en(e,t){let i=e.getCameraFrustum(),r=e.getClippingPlane();if(r&&t.maxContentElevation>0){let b=Math.hypot(r[0],r[1],r[2]);if(b>0){let T=1+t.maxContentElevation/Nt,P=ee(-r[3]/b,-1,1),S=Math.cos(Math.acos(P)+Math.acos(1/T));r=[r[0],r[1],r[2],-S*b],i=SI(i,Math.sqrt(T*T-1),e.cameraPosition)}}let a=dS(e),n=ye.fromLngLat(e.center,e.elevation),s=TI(e,t.maxContentElevation),o=e.getCoveringTilesDetailsProvider(),l=o.allowVariableZoom(e,t),u=$c(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,_),x=b=>({zoom:0,x:0,y:0,wrap:b,fullyVisible:!1}),v=[],w=[];if(e.renderWorldCopies&&o.allowWorldCopies())for(let b=1;b<=3;b++)v.push(x(-b)),v.push(x(b));for(v.push(x(0));v.length>0;){let b=v.pop(),T=b.x,P=b.y,S=b.fullyVisible,M={x:T,y:P,z:b.zoom},F=o.getTileBoundingVolume(M,b.wrap,s,t);if(!S){let E=bI(i,F,r);if(E===0)continue;S=E===2}let R=o.distanceToTile2d(a.x,a.y,M,F),I=u;l&&(I=(t.calculateTileZoom||wI)(e.zoom+Et(e.tileSize/t.tileSize),R,_,y,e.fov)),I=(t.roundZoom?Math.round:Math.floor)(I),I=Math.max(0,I);let D=Math.min(I,c);if(b.wrap=o.getWrap(n,M,b.wrap),b.zoom>=D){if(b.zoom<h)continue;let E=d-b.zoom,A=f[0]-.5-(T<<E),B=f[1]-.5-(P<<E),N=t.reparseOverscaled?Math.max(b.zoom,I):b.zoom;w.push({tileID:new Pt(b.zoom===c?N:b.zoom,b.wrap,b.zoom,T,P),distanceSq:Tx([m[0]-.5-T,m[1]-.5-P]),tileDistanceToCamera:Math.sqrt(A*A+B*B)});continue}for(let E=0;E<4;E++){let A=(T<<1)+E%2,B=(P<<1)+(E>>1),N=b.zoom+1;v.push({zoom:N,x:A,y:B,wrap:b.wrap,fullyVisible:S})}}return w.sort((b,T)=>b.distanceSq-T.distanceSq).map(b=>b.tileID)}function Ty(e){return e==="raster"||e==="image"||e==="video"}function EI(e,t,i,r,a,n,s){let o=Te(),l=Px(t);for(let u of t){let h=e.getTileById(u.key);(h.fadingDirection===0||h.fadeOpacity===0)&&h.resetFadeLogic(),!PI(e,h,i,o,r,a,s)&&(CI(e,h,i,o,n,s)||AI(h,l,o,s)||h.resetFadeLogic())}}function PI(e,t,i,r,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 i[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:r+s}),f.setCrossFadeLogic({fadingRole:1,fadingDirection:0,fadeEndTime:r+s}),i[p.key]=p,!0}return!1}function CI(e,t,i,r,a,n){if(!t.hasData())return!1;let s=t.tileID.children(a),o=Sy(e,t,s,i,r,a,n);if(o)return!0;for(let l of s)Sy(e,t,l.children(a),i,r,a,n)&&(o=!0);return o}function Sy(e,t,i,r,a,n,s){if(i[0].overscaledZ>=n)return!1;let o=!1;for(let l of i){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})),r[l.key]=l,o=!0}return o}function AI(e,t,i,r){let a=e.tileID;if(e.selfFading)return!0;if(e.hasData())return!1;if(t.has(a)){let n=i+r;return e.setSelfFadeLogic(n),!0}return!1}function DI(e,t){if(t<=0)return!1;let i=Te();for(let r of e.getAllTiles())if(r.fadeEndTime>=i)return!0;return!1}function II(e,t){var r,a,n;let i=t.getRenderableIds();for(let s of i){if(!((r=e.neighboringTiles)!=null&&r[s]))continue;let o=t.getTileById(s);e.neighboringTiles[s].backfilled||Ey(e,o),!((n=(a=o.neighboringTiles)==null?void 0:a[e.tileID.key])!=null&&n.backfilled)&&Ey(o,e)}}function Ey(e,t){var s;e.needsHillshadePrepare=!0,e.needsTerrainPrepare=!0,e.needsColorReliefPrepare=!0;let i=t.tileID.canonical.x-e.tileID.canonical.x,r=t.tileID.canonical.y-e.tileID.canonical.y,a=2**e.tileID.canonical.z,n=t.tileID.key;(i!==0||r!==0)&&(Math.abs(r)>1||(Math.abs(i)>1&&(Math.abs(i+a)===1?i+=a:Math.abs(i-a)===1&&(i-=a)),t.dem&&e.dem&&(e.dem.backfillBorder(t.dem,i,r),(s=e.neighboringTiles)!=null&&s[n]&&(e.neighboringTiles[n].backfilled=!0))))}var Py=class{constructor(){this._tiles={}}handleWrapJump(e){let t={};for(let i in this._tiles){let r=this._tiles[i];r.tileID=r.tileID.unwrapTo(r.tileID.wrap+e),t[r.tileID.key]=r}this._tiles=t}setFeatureState(e,t,i){for(let r in this._tiles)this._tiles[r].setFeatureState(e,t,i)}getAllTiles(){return Object.values(this._tiles)}getAllIds(e=!1){return e?Object.values(this._tiles).map(t=>t.tileID).sort(Xg).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 i;return(i=this.getTileById(e))==null?void 0:i.isRenderable(t)}getRenderableIds(e=0,t){let i=[];for(let r of this.getAllIds())this.isIdRenderable(r,t)&&i.push(this.getTileById(r));return t?i.sort((r,a)=>{let n=r.tileID,s=a.tileID,o=new C(n.canonical.x,n.canonical.y)._rotate(-e),l=new C(s.canonical.x,s.canonical.y)._rotate(-e);return n.overscaledZ-s.overscaledZ||l.y-o.y||l.x-o.x}).map(r=>r.tileID.key):i.map(r=>r.tileID).sort(Xg).map(r=>r.key)}},Oc=(ur=class extends ot{constructor(t,i,r){super(),this._maxContentElevationSeen=0,this.id=t,this.dispatcher=r,this.on("data",a=>{this._dataHandler(a)}),this.on("dataloading",()=>{this._sourceErrored=!1}),this.on("error",()=>{this._sourceErrored=this._source.loaded()}),this._source=cI(t,i,r,this),this._inViewTiles=new Py,this._outOfViewCache=new JA(0,a=>this._unloadTile(a)),this._timers={},this._maxTileCacheSize=null,this._maxTileCacheZoomLevels=null,this._rasterFadeDuration=0,this._maxFadingAncestorLevels=5,this._state=new gI,this._didEmitContent=!1,this._updated=!1}onAdd(t){var i;this.map=t,this._maxTileCacheSize=t?t._maxTileCacheSize:null,this._maxTileCacheZoomLevels=t?t._maxTileCacheZoomLevels:null,(i=this._source)!=null&&i.onAdd&&this._source.onAdd(t)}onRemove(t){var i;for(let r of this._inViewTiles.getAllTiles())r.unloadVectorData();this.clearTiles(),(i=this._source)!=null&&i.onRemove&&this._source.onRemove(t),this._inViewTiles=new Py}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,i,r,a){try{let n=await this._source.loadTile(t);this._tileLoaded(t,i,r,a,n)}catch(n){t.state="errored",n.status===404?this.update(this.transform,this.terrain):this._source.fire(new K(St(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 Re("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 i of this._inViewTiles.getAllTiles())i.upload(t),i.prepare(this.map.style.imageManager)}getIds(){return this._inViewTiles.getAllIds(!0)}getRenderableIds(t){var i;return this._inViewTiles.getRenderableIds((i=this.transform)==null?void 0:i.bearingInRadians,t)}hasRenderableParent(t){let i=t.overscaledZ-1;if(i>=this._source.minzoom){let r=this.getLoadedTile(t.scaledTo(i));if(r)return this._inViewTiles.isIdRenderable(r.tileID.key)}return!1}reload(t,i=void 0){if(this._paused){this._shouldReloadOnResume=!0;return}this._outOfViewCache.reset();for(let r of this._inViewTiles.getAllIds()){let a=this._inViewTiles.getTileById(r);(!i||this._source.shouldReloadTile(a,i))&&(t?this._reloadTile(r,a.state==="errored"?"loading":"expired"):a.state!=="errored"&&this._reloadTile(r,"reloading"))}}async _reloadTile(t,i){let r=this._inViewTiles.getTileById(t);if(!r)return;let a=r.hasData();r.state!=="loading"&&(r.state=i),await this._loadTile(r,t,i,a)}_tileLoaded(t,i,r,a,n){a||(t.timeAdded=Te(),t.selfFading&&(t.fadeEndTime=t.timeAdded+this._rasterFadeDuration)),r==="expired"&&(t.refreshedUponExpiration=!0),this._setTileReloadTimer(i,t),!(n!=null&&n.unmodified)&&(this.getSource().type==="raster-dem"&&t.dem&&II(t,this._inViewTiles),t.featureStateRevision=-1,this._state.initializeTileState(t,this.map?this.map.painter:null),t.aborted||this._source.fire(new Re("data",{tile:t,coord:t.tileID})))}getTile(t){return this.getTileByID(t.key)}getTileByID(t){return this._inViewTiles.getTileById(t)}_retainLoadedChildren(t,i){let r=this._getLoadedDescendents(i),a=new Set;for(let n of i){let s=r[n.key];if(!(s!=null&&s.length)){a.add(n);continue}let o=n.overscaledZ+ur.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 r;let i={};for(let a of this._inViewTiles.getAllTiles().filter(n=>n.hasData()))for(let n of t)a.tileID.isChildOf(n)&&(i[r=n.key]||(i[r]=[]),i[n.key].push(a));return i}_areDescendentsComplete(t,i,r){return t.length===1&&t[0].isOverscaled()?t[0].overscaledZ===i:4**(i-r)===t.length}getLoadedTile(t){return this._inViewTiles.getLoadedTile(t)}updateCacheSize(t){let i=(Math.ceil(t.width/this._source.tileSize)+1)*(Math.ceil(t.height/this._source.tileSize)+1),r=this._maxTileCacheZoomLevels===null?ei.MAX_TILE_CACHE_ZOOM_LEVELS:this._maxTileCacheZoomLevels,a=Math.floor(i*r),n=typeof this._maxTileCacheSize=="number"?Math.min(this._maxTileCacheSize,a):a;this._outOfViewCache.setMaxSize(n)}handleWrapJump(t){let i=(t-(this._prevLng===void 0?t:this._prevLng))/360,r=Math.round(i);this._prevLng=t,r&&(this._inViewTiles.handleWrapJump(r),this._resetTileReloadTimers())}_updateMaxContentElevation(){var a,n;let t=this._maxContentElevationSeen,i=(n=(a=this.map)==null?void 0:a.style)==null?void 0:n._layers;if(!i)return t;let r=this._inViewTiles.getAllTiles();for(let s in i){let o=i[s];if(o.type!=="symbol"||o.source!==this.id||o.isHidden(this.transform.zoom))continue;let l=o;if(l.layout){t=Math.max(t,l.layout.get("symbol-height-offset").constantOr(0));for(let u of r){let h=u.getBucket(o);h&&h.maxHeightOffset>t&&(t=h.maxHeightOffset)}}}return this._maxContentElevationSeen=t,t}update(t,i){if(!this._sourceLoaded||this._paused)return;this.transform=t,this.terrain=i,this.updateCacheSize(t),this.handleWrapJump(this.transform.center.lng);let r;!this.used&&!this.usedForTerrain?r=[]:this._source.tileID?r=t.getVisibleUnwrappedCoordinates(this._source.tileID).map(l=>new Pt(l.canonical.z,l.wrap,l.canonical.z,l.canonical.x,l.canonical.y)):(r=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:i,calculateTileZoom:this._source.calculateTileZoom,maxContentElevation:this._updateMaxContentElevation()}),this._source.hasTile&&(r=r.filter(l=>this._source.hasTile(l)))),this.usedForTerrain&&(r=this._addTerrainIdealTiles(r));let a=r.length===0&&!this._updated&&this._didEmitContent;this._updated=!0,a&&this.fire(new Re("data",{sourceDataType:"idle",sourceId:this.id}));let n=$c(t,this._source),s=this._updateRetainedTiles(r,n),o=Ty(this._source.type);o&&this._rasterFadeDuration>0&&!i&&EI(this._inViewTiles,r,s,this._maxFadingAncestorLevels,this._source.minzoom,this._source.maxzoom,this._rasterFadeDuration),o?this._cleanUpRasterTiles(s):this._cleanUpVectorTiles(s)}_cleanUpRasterTiles(t){for(let i of this._inViewTiles.getAllIds())t[i]||this._removeTile(i)}_cleanUpVectorTiles(t){for(let i of this._inViewTiles.getAllIds()){let r=this._inViewTiles.getTileById(i);if(t[i]){r.clearSymbolFadeHold();continue}if(!r.hasSymbolBuckets){this._removeTile(i);continue}r.holdingForSymbolFade()?r.symbolFadeFinished()&&this._removeTile(i):r.setSymbolHoldDuration(this.map._fadeDuration)}}_addTerrainIdealTiles(t){let i=[];for(let r of t)if(r.canonical.z>this._source.minzoom){let a=r.scaledTo(r.canonical.z-1);i.push(a);let n=r.scaledTo(Math.max(this._source.minzoom,Math.min(r.canonical.z,5)));i.push(n)}return t.concat(i)}releaseSymbolFadeTiles(){for(let t of this._inViewTiles.getAllIds())this._inViewTiles.getTileById(t).holdingForSymbolFade()&&this._removeTile(t)}_updateRetainedTiles(t,i){var l;let r=new Set;for(let u of t)this._addTile(u).hasData()||r.add(u);let a=t.reduce((u,h)=>(u[h.key]=h,u),{}),n=this._retainLoadedChildren(a,r),s={},o=Math.max(i-ur.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 i=this._inViewTiles.getTileById(t.key);if(i)return i;i=this._outOfViewCache.getAndRemove(t),i&&(i.resetFadeLogic(),this._setTileReloadTimer(t.key,i),i.tileID=t,this._state.initializeTileState(i,this.map?this.map.painter:null));let r=i;return i||(i=new xy(t,this._source.tileSize*t.overscaleFactor()),this._loadTile(i,t.key,i.state,!1)),i.uses++,this._inViewTiles.setTile(t.key,i),r||this._source.fire(new Re("dataloading",{tile:i,coord:i.tileID})),i}_setTileReloadTimer(t,i){this._clearTileReloadTimer(t);let r=i.getExpiryTimeout();if(r){let a=()=>{this._reloadTile(t,"expired"),delete this._timers[t]};this._timers[t]=setTimeout(a,r)}}_clearTileReloadTimer(t){let i=this._timers[t];i&&(clearTimeout(i),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 i=this._inViewTiles.getTileById(t);this._setTileReloadTimer(t,i)}}refreshTiles(t){for(let i of this._inViewTiles.getAllIds()){let r=this._inViewTiles.getTileById(i);(this._inViewTiles.isIdRenderable(i)||r.state=="errored")&&t.some(a=>a.equals(r.tileID.canonical))&&this._reloadTile(i,"expired")}}_removeTile(t){let i=this._inViewTiles.getTileById(t);i&&(i.uses--,this._inViewTiles.deleteTileById(t),this._clearTileReloadTimer(t),!(i.uses>0)&&(i.hasData()&&i.state!=="reloading"?this._outOfViewCache.add(i.tileID,i,i.getExpiryTimeout()):(i.aborted=!0,this._abortTile(i),this._unloadTile(i))))}_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,i,r){let a=[],n=this.transform;if(!n)return a;let s=n.getCoveringTilesDetailsProvider().allowWorldCopies(),o=r?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=Di.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),_=i*f.queryPadding*k/f.tileSize/g;for(let y of m){let x=d.map(v=>y.getTilePoint(new ye(v.x,v.y)));if(x.expandBy(_),x.intersects(nS)){let v=u.map(b=>y.getTilePoint(b)),w=h.map(b=>y.getTilePoint(b));a.push({tile:f,tileID:s?y:y.unwrapTo(0),queryGeometry:v,cameraQueryGeometry:w,scale:g})}}}return a}transformBbox(t,i,r){let a=t.map(i);if(r){let n=Di.fromPoints(t);n.shrinkBy(Math.min(n.width(),n.height())*.001);let s=n.map(i);Di.fromPoints(a).covers(s)||(a=a.map(o=>o.x>.5?new ye(o.x-1,o.y,o.z):o))}return a}getVisibleCoordinates(t){let i=this.getRenderableIds(t).map(r=>this._inViewTiles.getTileById(r).tileID);return this.transform&&this.transform.populateCache(i),i}hasTransition(){return this._source.hasTransition()?!0:Ty(this._source.type)&&DI(this._inViewTiles,this._rasterFadeDuration)}setRasterFadeDuration(t){this._rasterFadeDuration=t}setFeatureState(t,i,r){t||(t=el),this._state.updateState(t,i,r)}removeFeatureState(t,i,r){t||(t=el),this._state.removeFeatureState(t,i,r)}getFeatureState(t,i){return t||(t=el),this._state.getState(t,i)}setDependencies(t,i,r){let a=this._inViewTiles.getTileById(t);a&&a.setDependencies(i,r)}reloadTilesForDependencies(t,i){for(let r of this._inViewTiles.getAllIds())this._inViewTiles.getTileById(r).hasDependency(t,i)&&this._reloadTile(r,"reloading");this._outOfViewCache.filter(r=>!r.hasDependency(t,i))}areTilesLoaded(){for(let t of this._inViewTiles.getAllTiles())if(t.state!=="loaded"&&t.state!=="errored")return!1;return!0}},ur.maxUnderzooming=10,ur.maxOverzooming=3,ur),MI=class{constructor(e,t){this.reset(e,t)}reset(e,t){this.points=e||[],this._distances=[0];for(let i=1;i<this.points.length;i++)this._distances[i]=this._distances[i-1]+this.points[i].dist(this.points[i-1]);this.length=this._distances[this._distances.length-1],this.padding=Math.min(t||0,this.length*.5),this.paddedLength=this.length-this.padding*2}lerp(e){if(this.points.length===1)return this.points[0];e=ee(e,0,1);let t=1,i=this._distances[t],r=e*this.paddedLength+this.padding;for(;i<r&&t<this._distances.length;)i=this._distances[++t];let a=t-1,n=this._distances[a],s=i-n,o=s>0?(r-n)/s:0;return this.points[a].mult(1-o).add(this.points[t].mult(o))}};function pl(e,t,i,r,a){return a?e?e(t,i)+r:r===0?void 0:r:r}function fl(e,t){let i=!0;return e==="always"||(e==="never"||t==="never")&&(i=!1),i}var Cy=class{constructor(e,t,i){let r=this.boxCells=[],a=this.circleCells=[];this.xCellCount=Math.ceil(e/i),this.yCellCount=Math.ceil(t/i);for(let n=0;n<this.xCellCount*this.yCellCount;n++)r.push([]),a.push([]);this.circleKeys=[],this.boxKeys=[],this.bboxes=[],this.circles=[],this.width=e,this.height=t,this.xScale=this.xCellCount/e,this.yScale=this.yCellCount/t,this.boxUid=0,this.circleUid=0}keysLength(){return this.boxKeys.length+this.circleKeys.length}insert(e,t,i,r,a){this._forEachCell(t,i,r,a,this._insertBoxCell,this.boxUid++),this.boxKeys.push(e),this.bboxes.push(t),this.bboxes.push(i),this.bboxes.push(r),this.bboxes.push(a)}insertCircle(e,t,i,r){this._forEachCell(t-r,i-r,t+r,i+r,this._insertCircleCell,this.circleUid++),this.circleKeys.push(e),this.circles.push(t),this.circles.push(i),this.circles.push(r)}_insertBoxCell(e,t,i,r,a,n){this.boxCells[a].push(n)}_insertCircleCell(e,t,i,r,a,n){this.circleCells[a].push(n)}_query(e,t,i,r,a,n,s){if(i<0||e>this.width||r<0||t>this.height)return[];let o=[];if(e<=0&&t<=0&&this.width<=i&&this.height<=r){if(a)return[{key:null,x1:e,y1:t,x2:i,y2:r}];for(let 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,i,r,this._queryCell,o,l,s)}return o}query(e,t,i,r){return this._query(e,t,i,r,!1,null)}hitTest(e,t,i,r,a,n){return this._query(e,t,i,r,!0,a,n).length>0}hitTestCircle(e,t,i,r,a){let n=e-i,s=e+i,o=t-i,l=t+i;if(s<0||n>this.width||l<0||o>this.height)return!1;let u=[],h={hitTest:!0,overlapMode:r,circle:{x:e,y:t,radius:i},seenUids:{box:{},circle:{}}};return this._forEachCell(n,o,s,l,this._queryCellCircle,u,h,a),u.length>0}_queryCell(e,t,i,r,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&&i>=f[g+0]-d&&r>=f[g+1]-d&&(!o||o(_))&&(!u||!fl(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,i,r)&&(!o||o(_))&&(!u||!fl(h,_.overlapMode))){let y=f[g],x=f[g+1],v=f[g+2];if(n.push({key:_,x1:y-v,y1:x-v,x2:y+v,y2:x+v}),u)return!0}}}return!1}_queryCellCircle(e,t,i,r,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))&&!fl(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))&&!fl(h,g.overlapMode))return n.push(!0),!0}}}_forEachCell(e,t,i,r,a,n,s,o){let l=this._convertToXCellCoord(e),u=this._convertToYCellCoord(t),h=this._convertToXCellCoord(i),c=this._convertToYCellCoord(r);for(let d=l;d<=h;d++)for(let p=u;p<=c;p++){let f=this.xCellCount*p+d;if(a.call(this,e,t,i,r,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,i,r,a,n){let s=r-e,o=a-t,l=i+n;return l*l>s*s+o*o}_circleAndRectCollide(e,t,i,r,a,n,s){let o=(n-r)/2,l=Math.abs(e-(r+o));if(l>o+i)return!1;let u=(s-a)/2,h=Math.abs(t-(a+u));if(h>u+i)return!1;if(l<=o||h<=u)return!0;let c=l-o,d=h-u;return c*c+d*d<=i*i}};function zI(e,t){let i=1/(t[0]*t[0]+t[1]*t[1]+t[2]*t[2]),r=1/(t[8]*t[8]+t[9]*t[9]+t[10]*t[10]),a=t[0]*i,n=t[4]*i,s=t[8]*r,o=t[1]*i,l=t[5]*i,u=t[9]*r,h=t[2]*i,c=t[6]*i,d=t[10]*r;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 FI(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 RI(e,t){let i=1/(t[0]*t[5]-t[1]*t[4]);return e[0]=t[5]*i,e[1]=-t[1]*i,e[2]=0,e[3]=0,e[4]=-t[4]*i,e[5]=t[0]*i,e[6]=0,e[7]=0,e[8]=0,e[9]=0,e[10]=1/t[10],e[11]=0,e[12]=0,e[13]=0,e[14]=0,e[15]=1/t[15],e}const kI=gr();function Nc(e,t,i){let r=gr();if(!e){let{vecSouth:a,vecEast:n}=Vc(t),s=N_();s[0]=n[0],s[1]=n[1],s[2]=a[0],s[3]=a[1],QA(s,s),r[0]=s[0],r[1]=s[1],r[4]=s[2],r[5]=s[3]}return Tt(r,r,[1/i,1/i,1]),r}function LI(e,t,i,r){if(e){let a=gr();if(!t){let{vecSouth:n,vecEast:s}=Vc(i);a[0]=s[0],a[1]=s[1],a[4]=n[0],a[5]=n[1]}return Tt(a,a,[r,r,1]),a}return i.pixelsToClipSpaceMatrix}function Vc(e){let t=Math.cos(e.rollInRadians),i=Math.sin(e.rollInRadians),r=Math.cos(e.pitchInRadians),a=Math.cos(e.bearingInRadians),n=Math.sin(e.bearingInRadians),s=Yl();s[0]=-a*r*i-n*t,s[1]=-n*r*i+a*t;let o=dp(s);o<1e-9?pp(s):cp(s,s,1/o);let l=Yl();l[0]=a*r*t-n*i,l[1]=n*r*t+a*i;let u=dp(l);return u<1e-9?pp(l):cp(l,l,1/u),{vecEast:l,vecSouth:s}}function da(e,t,i){return pl(e.getElevation,t,i,e.heightOffset??0,e.heightAnchorGround??!0)}function jc(e,t,i,r){let a;r==null?(a=[e,t,0,1],Zc(a,a,i)):(a=[e,t,r,1],pt(a,a,i));let n=a[3];return{point:new C(a[0]/n,a[1]/n),signedDistanceFromCamera:n,isOccluded:!1}}function Ay(e,t){return .5+e/t*.5}function BI(e,t){return e.x>=-t[0]&&e.x<=t[0]&&e.y>=-t[1]&&e.y<=t[1]}function $I(e,t,i,r,a,n,s,o,l,u,h,c,d){let p=i?e.textSizeData:e.iconSizeData,f=Uo(p,t.transform.zoom),m=[256/t.width*2+1,256/t.height*2+1],g=i?e.text.dynamicLayoutVertexArray:e.icon.dynamicLayoutVertexArray;g.clear();let _=e.lineVertexArray,y=i?e.text.placedSymbolArray:e.icon.placedSymbolArray,x=t.transform.width/t.transform.height,v=!1;for(let w=0;w<y.length;w++){let b=y.get(w);if(b.hidden||b.writingMode===2&&!v){tn(b.numGlyphs,g);continue}v=!1;let T=new C(b.anchorX,b.anchorY),P={getElevation:d,pitchedLabelPlaneMatrix:r,lineVertexArray:_,pitchWithMap:n,projectionCache:{projections:{},offsets:{},cachedAnchorPoint:void 0,anyProjectionOccluded:!1},transform:t.transform,tileAnchorPoint:T,unwrappedTileID:l,width:u,height:h,translation:c},S=Fy(b.anchorX,b.anchorY,P);if(!BI(S.point,m)){tn(b.numGlyphs,g);continue}let M=S.signedDistanceFromCamera,F=Ay(t.transform.cameraToCenterDistance,M),R=qh(p,f,b),I=n?R*t.transform.getPitchedTextCorrection(b.anchorX,b.anchorY,l)/F:R*F,D=My({projectionContext:P,pitchedLabelPlaneMatrixInverse:a,symbol:b,fontSize:I,flip:!1,keepUpright:s,glyphOffsetArray:e.glyphOffsetArray,dynamicLayoutVertexArray:g,aspectRatio:x,rotateToLine:o});v=D.useVertical,(D.notEnoughRoom||v||D.needsFlipping&&My({projectionContext:P,pitchedLabelPlaneMatrixInverse:a,symbol:b,fontSize:I,flip:!0,keepUpright:s,glyphOffsetArray:e.glyphOffsetArray,dynamicLayoutVertexArray:g,aspectRatio:x,rotateToLine:o}).notEnoughRoom)&&tn(b.numGlyphs,g)}i?e.text.dynamicLayoutVertexBuffer.updateData(g):e.icon.dynamicLayoutVertexBuffer.updateData(g)}function Dy(e,t,i,r,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=gl(e*c,i,r,a,n.segment,u,h,o,s);if(!p)return null;let f=gl(e*d,i,r,a,n.segment,u,h,o,s);return!f||o.projectionCache.anyProjectionOccluded?null:{first:p,last:f}}function Iy(e,t,i,r){return e===1&&Math.abs(i.y-t.y)>Math.abs(i.x-t.x)*r?{useVertical:!0}:(e===2?t.y<i.y:t.x>i.x)?{needsFlipping:!0}:null}function My(e){let{projectionContext:t,pitchedLabelPlaneMatrixInverse:i,symbol:r,fontSize:a,flip:n,keepUpright:s,glyphOffsetArray:o,dynamicLayoutVertexArray:l,aspectRatio:u,rotateToLine:h}=e,c=a/24,d=r.lineOffsetX*c,p=r.lineOffsetY*c,f;if(r.numGlyphs>1){let m=r.glyphStartIndex+r.numGlyphs,g=r.lineStartIndex,_=r.lineStartIndex+r.lineLength,y=Dy(c,o,d,p,n,r,h,t);if(!y)return{notEnoughRoom:!0};let x=ml(y.first.point.x,y.first.point.y,t,i),v=ml(y.last.point.x,y.last.point.y,t,i);if(s&&!n){let w=Iy(r.writingMode,x,v,u);if(w)return w}f=[y.first];for(let w=r.glyphStartIndex+1;w<m-1;w++){let b=gl(c*o.getoffsetX(w),d,p,n,r.segment,g,_,t,h);if(!b)return{notEnoughRoom:!0};f.push(b)}f.push(y.last)}else{if(s&&!n){let g=pa(t.tileAnchorPoint.x,t.tileAnchorPoint.y,t).point,_=r.lineStartIndex+r.segment+1,y=new C(t.lineVertexArray.getx(_),t.lineVertexArray.gety(_)),x=pa(y.x,y.y,t),v=x.signedDistanceFromCamera>0?x.point:zy(t.tileAnchorPoint,y,g,1,t),w=ml(g.x,g.y,t,i),b=ml(v.x,v.y,t,i),T=Iy(r.writingMode,w,b,u);if(T)return T}let m=gl(c*o.getoffsetX(r.glyphStartIndex),d,p,n,r.segment,r.lineStartIndex,r.lineStartIndex+r.lineLength,t,h);if(!m||t.projectionCache.anyProjectionOccluded)return{notEnoughRoom:!0};f=[m]}for(let m of f)Yo(l,m.point,m.angle);return{}}function zy(e,t,i,r,a){let n=e.add(e.sub(t)._unit()),s=pa(n.x,n.y,a).point,o=i.sub(s);return i.add(o._mult(r/o.mag()))}function Uc(e,t,i){let r=t.projectionCache;if(r.projections[e])return r.projections[e];let a=new C(t.lineVertexArray.getx(e),t.lineVertexArray.gety(e)),n=pa(a.x,a.y,t);if(n.signedDistanceFromCamera>0)return r.projections[e]=n.point,r.anyProjectionOccluded||(r.anyProjectionOccluded=n.isOccluded),n.point;let s=e-i.direction,o=i.distanceFromAnchor===0?t.tileAnchorPoint:new C(t.lineVertexArray.getx(s),t.lineVertexArray.gety(s)),l=i.absOffsetX-i.distanceFromAnchor+1;return zy(o,a,i.previousVertex,l,t)}function pa(e,t,i){let r=e+i.translation[0],a=t+i.translation[1],n;return i.pitchWithMap?(n=jc(r,a,i.pitchedLabelPlaneMatrix,da(i,r,a)),n.isOccluded=!1):(n=i.transform.projectTileCoordinates(r,a,i.unwrappedTileID,da(i,r,a)),n.point.x=(n.point.x*.5+.5)*i.width,n.point.y=(-n.point.y*.5+.5)*i.height),n}function ml(e,t,i,r){if(i.pitchWithMap){let a=[e,t,0,1];pt(a,a,r);let n=a[0]/a[3],s=a[1]/a[3];return i.transform.projectTileCoordinates(n,s,i.unwrappedTileID,da(i,n,s)).point}return{x:e/i.width*2-1,y:1-t/i.height*2}}function Fy(e,t,i){return i.transform.projectTileCoordinates(e,t,i.unwrappedTileID,da(i,e,t))}function Gc(e,t,i){return e._unit()._perp()._mult(t*i)}function OI(e,t,i,r,a,n,s,o,l){if(o.projectionCache.offsets[e])return o.projectionCache.offsets[e];let u=i.add(t);if(e+l.direction<r||e+l.direction>=a)return o.projectionCache.offsets[e]=u,u;let h=Uc(e+l.direction,o,l),c=Gc(h.sub(i),s,l.direction),d=i.add(c),p=h.add(c);return o.projectionCache.offsets[e]=Mx(n,u,d,p)||u,o.projectionCache.offsets[e]}function gl(e,t,i,r,a,n,s,o,l){let u=r?e-t:e+t,h=u>0?1:-1,c=0;r&&(h*=-1,c=Math.PI),h<0&&(c+=Math.PI);let d=h>0?n+a:n+a+1,p;o.projectionCache.cachedAnchorPoint?p=o.projectionCache.cachedAnchorPoint:(p=pa(o.tileAnchorPoint.x,o.tileAnchorPoint.y,o).point,o.projectionCache.cachedAnchorPoint=p);let f=p,m=p,g,_,y=0,x=0,v=Math.abs(u),w=[],b;for(;y+x<=v;){if(d+=h,d<n||d>=s)return null;y+=x,m=f,_=g;let M={absOffsetX:v,direction:h,distanceFromAnchor:y,previousVertex:m};if(f=Uc(d,o,M),i===0)w.push(m),b=f.sub(m);else{let F,R=f.sub(m);F=R.mag()===0?Gc(Uc(d+h,o,M).sub(f),i,h):Gc(R,i,h),_||(_=m.add(F)),g=OI(d,F,f,n,s,_,i,o,M),w.push(_),b=g.sub(_)}x=b.mag()}let T=(v-y)/x,P=b._mult(T)._add(_||m),S=c+Math.atan2(f.y-m.y,f.x-m.x);return w.push(P),{point:P,angle:l?S:0,path:w}}const NI=new Float32Array([-1/0,-1/0,0,-1/0,-1/0,0,-1/0,-1/0,0,-1/0,-1/0,0]);function tn(e,t){for(let i=0;i<e;i++){let r=t.length;t.resize(r+4),t.float32.set(NI,r*3)}}function Zc(e,t,i){let r=t[0],a=t[1];return e[0]=i[0]*r+i[4]*a+i[12],e[1]=i[1]*r+i[5]*a+i[13],e[3]=i[3]*r+i[7]*a+i[15],e}function VI(e,t){let i=kI;return RI(i,t.pitchedLabelPlaneMatrix),e.map(r=>{let a=jc(r.x,r.y,i,da(t,r.x,r.y)),n=t.transform.projectTileCoordinates(a.point.x,a.point.y,t.unwrappedTileID,da(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 jI(e){let t=0,i=0,r=0,a=0;for(let n=0;n<e.length;n++)e[n].isOccluded?(r=n+1,a=0):(a++,a>i&&(i=a,t=r));return e.slice(t,t+i)}var UI=class{constructor(e,t=new Cy(e.width+200,e.height+200,25),i=new Cy(e.width+200,e.height+200,25)){this.transform=e,this.grid=t,this.ignoredGrid=i,this.pitchFactor=Math.cos(e.pitch*Math.PI/180)*e.cameraToCenterDistance,this.screenRightBoundary=e.width+100,this.screenBottomBoundary=e.height+100,this.gridRightBoundary=e.width+200,this.gridBottomBoundary=e.height+200,this.perspectiveRatioCutoff=.6}placeCollisionBox(e,t,i,r,a,n,s,o,l,u,h,c,d=0,p=!0){let f=e.anchorPointX+o[0],m=e.anchorPointY+o[1],g=this.projectAndGetPerspectiveRatio(f,m,a,pl(u,f,m,d,p),c),_=i*g.perspectiveRatio,y;if(!n&&!s){let S=g.x+(h?h.x*_:0),M=g.y+(h?h.y*_:0);y={allPointsOccluded:!1,box:[S+e.x1*_,M+e.y1*_,S+e.x2*_,M+e.y2*_]}}else y=this._projectCollisionBox(e,_,r,a,n,s,o,g,u,h,c,d,p);let[x,v,w,b]=y.box,T=n?y.allPointsOccluded:g.isOccluded,P=T;return P||(P=g.perspectiveRatio<this.perspectiveRatioCutoff),P||(P=!this.isInsideGrid(x,v,w,b)),P||t!=="always"&&this.grid.hitTest(x,v,w,b,t,l)?{box:[x,v,w,b],placeable:!1,offscreen:!1,occluded:T}:{box:[x,v,w,b],placeable:!0,offscreen:this.isOffscreen(x,v,w,b),occluded:T}}placeCollisionCircles(e,t,i,r,a,n,s,o,l,u,h,c,d,p){let f=[],m=new C(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},x=t.lineOffsetX*_,v=t.lineOffsetY*_,w={getElevation:p,pitchedLabelPlaneMatrix:s,lineVertexArray:i,pitchWithMap:l,projectionCache:y,transform:this.transform,tileAnchorPoint:m,unwrappedTileID:n,width:this.transform.width,height:this.transform.height,translation:d},b=Dy(_,r,x,v,!1,t,!1,w),T=!1,P=!1,S=!0;if(b){let M=h*.5*g+c,F=new C(-100,-100),R=new C(this.screenRightBoundary,this.screenBottomBoundary),I=new MI,D=b.first,E=b.last,A=[];for(let O=D.path.length-1;O>=1;O--)A.push(D.path[O]);for(let O=1;O<E.path.length;O++)A.push(E.path[O]);let B=M*2.5;if(l){let O=this.projectPathToScreenSpace(A,w);A=O.some(H=>H.signedDistanceFromCamera<=0)?[]:O.map(H=>H.point)}let N=[];if(A.length>0){let O=A[0].clone(),H=A[0].clone();for(let ue=1;ue<A.length;ue++)O.x=Math.min(O.x,A[ue].x),O.y=Math.min(O.y,A[ue].y),H.x=Math.max(H.x,A[ue].x),H.y=Math.max(H.y,A[ue].y);N=O.x>=F.x&&H.x<=R.x&&O.y>=F.y&&H.y<=R.y?[A]:H.x<F.x||O.x>R.x||H.y<F.y||O.y>R.y?[]:$g([A],F.x,F.y,R.x,R.y)}for(let O of N){I.reset(O,M*.25);let H=0;H=I.length<=.5*M?1:Math.ceil(I.paddedLength/B)+1;for(let ue=0;ue<H;ue++){let Ae=ue/Math.max(H-1,1),ne=I.lerp(Ae),Ce=ne.x+100,_e=ne.y+100;f.push(Ce,_e,M,0);let Ie=Ce-M,Me=_e-M,ct=Ce+M,Mt=_e+M;if(S&&(S=this.isOffscreen(Ie,Me,ct,Mt)),P||(P=this.isInsideGrid(Ie,Me,ct,Mt)),e!=="always"&&this.grid.hitTestCircle(Ce,_e,M,e,u)&&(T=!0,!o))return{circles:[],offscreen:!1,collisionDetected:T}}}}return{circles:!o&&T||!P||g<this.perspectiveRatioCutoff?[]:f,offscreen:S,collisionDetected:T}}projectPathToScreenSpace(e,t){return jI(VI(e,t))}queryRenderedSymbols(e){if(e.length===0||this.grid.keysLength()===0&&this.ignoredGrid.keysLength()===0)return{};let t=[],i=new Di;for(let h of e){let c=new C(h.x+100,h.y+100);i.extend(c),t.push(c)}let{minX:r,minY:a,maxX:n,maxY:s}=i,o=this.grid.query(r,a,n,s).concat(this.ignoredGrid.query(r,a,n,s)),l={},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 C(h.x1,h.y1),new C(h.x2,h.y1),new C(h.x2,h.y2),new C(h.x1,h.y2)];Im(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,i,r,a,n){let s=i?this.ignoredGrid:this.grid,o={bucketInstanceId:r,featureIndex:a,collisionGroupID:n,overlapMode:t};s.insert(o,e[0],e[1],e[2],e[3])}insertCollisionCircles(e,t,i,r,a,n){let s=i?this.ignoredGrid:this.grid,o={bucketInstanceId:r,featureIndex:a,collisionGroupID:n,overlapMode:t};for(let l=0;l<e.length;l+=4)s.insertCircle(o,e[l],e[l+1],e[l+2])}projectAndGetPerspectiveRatio(e,t,i,r,a){if(a){let n;r==null?(n=[e,t,0,1],Zc(n,n,a)):(n=[e,t,r,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,i,r);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,i,r){let a=this.transform.projectTileCoordinates(e,t,i,r);return .5+.5*(this.transform.cameraToCenterDistance/a.signedDistanceFromCamera)}isOffscreen(e,t,i,r){return i<100||e>=this.screenRightBoundary||r<100||t>this.screenBottomBoundary}isInsideGrid(e,t,i,r){return i>=0&&e<this.gridRightBoundary&&r>=0&&t<this.gridBottomBoundary}getViewportMatrix(){let e=Si([]);return rt(e,e,[-100,-100,0]),e}_projectCollisionBox(e,t,i,r,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 E=this.projectAndGetPerspectiveRatio(_+1,y,r,pl(l,_+1,y,c,d),h),A=E.x-o.x,B=E.y-o.y,N=Math.atan(B/A)+(A<0?Math.PI:0),O=Math.sin(N),H=Math.cos(N);p=H,f=O,m=-O,g=H}else if(!n&&a){let E=Vc(this.transform);p=E.vecEast[0],f=E.vecEast[1],m=E.vecSouth[0],g=E.vecSouth[1]}let x=o.x,v=o.y,w=t;if(a&&(x=_,v=y,w=2**-(this.transform.zoom-i.overscaledZ),w*=this.transform.getPitchedTextCorrection(_,y,r),!u)){let E=o.signedDistanceFromCamera/this.transform.cameraToCenterDistance,A=ee(.5+.5*E,0,4);w*=A}u&&(x+=p*u.x*w+m*u.y*w,v+=f*u.x*w+g*u.y*w);let b=e.x1*w,T=e.x2*w,P=(b+T)/2,S=e.y1*w,M=e.y2*w,F=(S+M)/2,R=[{offsetX:b,offsetY:S},{offsetX:P,offsetY:S},{offsetX:T,offsetY:S},{offsetX:T,offsetY:F},{offsetX:T,offsetY:M},{offsetX:P,offsetY:M},{offsetX:b,offsetY:M},{offsetX:b,offsetY:F}],I=[];for(let{offsetX:E,offsetY:A}of R)I.push(new C(x+p*E+m*A,v+f*E+g*A));let D=!1;if(a){let E=I.map(A=>this.projectAndGetPerspectiveRatio(A.x,A.y,r,pl(l,A.x,A.y,c,d),h));D=E.some(A=>!A.isOccluded),I=E.map(A=>new C(A.x,A.y))}else D=!0;return{box:Ex(I),allPointsOccluded:!D}}},Ry=class{constructor(e,t,i,r){this.opacity=e?Math.max(0,Math.min(1,e.opacity+(e.placed?t:-t))):r&&i?1:0,this.placed=i}isHidden(){return this.opacity===0&&!this.placed}},us=class{constructor(e,t,i,r,a){this.text=new Ry(e?e.text:null,t,i,a),this.icon=new Ry(e?e.icon:null,t,r,a)}isHidden(){return this.text.isHidden()&&this.icon.isHidden()}},ky=class{constructor(e,t,i){this.text=e,this.icon=t,this.skipFade=i}},GI=class{constructor(e,t,i,r,a){this.bucketInstanceId=e,this.featureIndex=t,this.sourceLayerIndex=i,this.bucketIndex=r,this.tileID=a}},ZI=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:i=>i.collisionGroupID===t}}return this.collisionGroups[e]}};function Ly(e,t,i,r,a){let{horizontalAlign:n,verticalAlign:s}=Vo(e),o=-(n-.5)*t,l=-(s-.5)*i;return new C(o+r[0]*a,l+r[1]*a)}var qI=class{constructor(e,t,i,r,a){this.transform=e.clone(),this.terrain=t,this.collisionIndex=new UI(this.transform),this.placements={},this.opacities={},this.variableOffsets={},this.stale=!1,this.commitTime=0,this.fadeDuration=i,this.retainedQueryData={},this.collisionGroups=new ZI(r),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(i,r)=>t.getElevation(e,i,r)}getBucketParts(e,t,i,r){let a=i.getBucket(t),n=i.latestFeatureIndex;if(!a||!n||t.id!==a.layerIds[0])return;let s=i.collisionBoxArray,o=a.layers[0].layout,l=a.layers[0].paint,u=2**(this.transform.zoom-i.tileID.overscaledZ),h=i.tileSize/k,c=i.tileID.toUnwrapped(),d=o.get("text-rotation-alignment")==="map",p=Kt(i,1,this.transform.zoom),f=vr(this.collisionIndex.transform,i,l.get("text-translate"),l.get("text-translate-anchor")),m=vr(this.collisionIndex.transform,i,l.get("icon-translate"),l.get("icon-translate-anchor")),g=Nc(d,this.transform,p);this.retainedQueryData[a.bucketInstanceId]=new GI(a.bucketInstanceId,n,a.sourceLayerIndex,a.index,i.tileID);let _={bucket:a,layout:o,translationText:f,translationIcon:m,unwrappedTileID:c,pitchedLabelPlaneMatrix:g,scale:u,textPixelRatio:h,holdingForFade:i.holdingForSymbolFade(),collisionBoxArray:s,partiallyEvaluatedTextSize:Uo(a.textSizeData,this.transform.zoom),collisionGroup:this.collisionGroups.get(a.sourceID)};if(r)for(let y of a.sortKeyRanges){let{sortKey:x,symbolInstanceStart:v,symbolInstanceEnd:w}=y;e.push({sortKey:x,symbolInstanceStart:v,symbolInstanceEnd:w,parameters:_})}else e.push({symbolInstanceStart:0,symbolInstanceEnd:a.symbolInstances.length,parameters:_})}attemptAnchorPlacement(e,t,i,r,a,n,s,o,l,u,h,c,d,p,f,m,g,_,y,x,v,w){var M,F,R;let b=Wh[e.textAnchor],T=[e.textOffset0,e.textOffset1],P=Ly(b,i,r,T,a),S=this.collisionIndex.placeCollisionBox(t,c,o,l,u,s,n,m,h.predicate,y,P,x,v,w);if((!_||this.collisionIndex.placeCollisionBox(_,c,o,l,u,s,n,g,h.predicate,y,P,x,v,w).placeable)&&S.placeable){let I;if((M=this.prevPlacement)!=null&&M.variableOffsets[d.crossTileID]&&((R=(F=this.prevPlacement)==null?void 0:F.placements[d.crossTileID])!=null&&R.text)&&(I=this.prevPlacement.variableOffsets[d.crossTileID].anchor),d.crossTileID===0)throw Error("symbolInstance.crossTileID can't be 0");return this.variableOffsets[d.crossTileID]={textOffset:T,width:i,height:r,anchor:b,textBoxScale:a,prevAnchor:I},this.markUsedJustification(p,b,d,f),p.allowVerticalPlacement&&(this.markUsedOrientation(p,f,d),this.placedOrientations[d.crossTileID]=f),{shift:P,placedGlyphBoxes:S}}}placeLayerBucketPart(e,t,i){let{bucket:r,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=Ho(a,"text-overlap","text-allow-overlap"),_=g==="always",y=Ho(a,"icon-overlap","icon-allow-overlap"),x=y==="always",v=a.get("text-rotation-alignment")==="map",w=a.get("text-pitch-alignment")==="map",b=a.get("icon-text-fit")!=="none",T=a.get("symbol-z-order")==="viewport-y",P=a.get("symbol-height-anchor")==="ground",S=_&&(x||!r.hasIconData()||m),M=x&&(_||!r.hasTextData()||f);!r.collisionArrays&&c&&r.deserializeCollisionBoxes(c);let F=this.retainedQueryData[r.bucketInstanceId].tileID,R=this._getTerrainElevationFunc(F),I=this.transform.getFastPathSimpleProjectionMatrix(F),D=(E,A,B)=>{var Ye,Ge;if(t[E.crossTileID])return;if(h){this.placements[E.crossTileID]=new ky(!1,!1,!1);return}let N=E.heightOffset,O=!1,H=!1,ue=!0,Ae=null,ne={box:null,placeable:!1,offscreen:null,occluded:!1},Ce={placeable:!1},_e=null,Ie=null,Me=null,ct=0,Mt=0,Fi=0;A.textFeatureIndex?ct=A.textFeatureIndex:E.useRuntimeCollisionCircles&&(ct=E.featureIndex),A.verticalTextFeatureIndex&&(Mt=A.verticalTextFeatureIndex);let Ut=A.textBox;if(Ut){let Ft=Rt=>{let tt=1;if(r.allowVerticalPlacement&&!Rt&&this.prevPlacement){let Zt=this.prevPlacement.placedOrientations[E.crossTileID];Zt&&(this.placedOrientations[E.crossTileID]=Zt,tt=Zt,this.markUsedOrientation(r,tt,E))}return tt},Yt=(Rt,tt)=>{if(r.allowVerticalPlacement&&E.numVerticalGlyphVertices>0&&A.verticalTextBox){for(let Zt of r.writingModes)if(Zt===2?(ne=tt(),Ce=ne):ne=Rt(),ne==null?void 0:ne.placeable)break}else ne=Rt()},Yi=E.textAnchorOffsetStartIndex,Gt=E.textAnchorOffsetEndIndex;if(Gt===Yi){let Rt=(tt,Zt)=>{let _t=this.collisionIndex.placeCollisionBox(tt,g,u,F,o,w,v,n,p.predicate,R,void 0,I,N,P);return _t!=null&&_t.placeable&&(this.markUsedOrientation(r,Zt,E),this.placedOrientations[E.crossTileID]=Zt),_t};Yt(()=>Rt(Ut,1),()=>{let tt=A.verticalTextBox;return r.allowVerticalPlacement&&E.numVerticalGlyphVertices>0&&tt?Rt(tt,2):{box:null,offscreen:null}}),Ft(ne==null?void 0:ne.placeable)}else{let Rt=Wh[(Ge=(Ye=this.prevPlacement)==null?void 0:Ye.variableOffsets[E.crossTileID])==null?void 0:Ge.anchor],tt=(_t,Cs,Nk)=>{let Vk=_t.x2-_t.x1,jk=_t.y2-_t.y1,Uk=E.textBoxScale,Gk=b&&y==="never"?Cs:null,$r=null,e1=g==="never"?1:2,t1="never";Rt&&e1++;for(let i1=0;i1<e1;i1++){for(let jd=Yi;jd<Gt;jd++){let r1=r.textAnchorOffsets.get(jd);if(Rt&&r1.textAnchor!==Rt)continue;let Ud=this.attemptAnchorPlacement(r1,_t,Vk,jk,Uk,v,w,u,F,o,p,t1,E,r,Nk,n,s,Gk,R,I,N,P);if(Ud&&($r=Ud.placedGlyphBoxes,$r==null?void 0:$r.placeable))return O=!0,Ae=Ud.shift,$r}Rt?Rt=null:t1=g}return i&&!$r&&($r={box:this.collisionIndex.placeCollisionBox(Ut,"always",u,F,o,w,v,n,p.predicate,R,void 0,I,N,P).box,offscreen:!1,placeable:!1,occluded:!1}),$r};Yt(()=>tt(Ut,A.iconBox,1),()=>{let _t=A.verticalTextBox,Cs=ne==null?void 0:ne.placeable;return r.allowVerticalPlacement&&!Cs&&E.numVerticalGlyphVertices>0&&_t?tt(_t,A.verticalIconBox,2):{box:null,occluded:!0,offscreen:null}}),ne&&(O=ne.placeable,ue=ne.offscreen);let Zt=Ft(ne==null?void 0:ne.placeable);if(!O&&this.prevPlacement){let _t=this.prevPlacement.variableOffsets[E.crossTileID];_t&&(this.variableOffsets[E.crossTileID]=_t,this.markUsedJustification(r,_t.anchor,E,Zt))}}}if(_e=ne,O=_e==null?void 0:_e.placeable,ue=_e==null?void 0:_e.offscreen,E.useRuntimeCollisionCircles&&E.centerJustifiedTextSymbolIndex>=0){let Ft=r.text.placedSymbolArray.get(E.centerJustifiedTextSymbolIndex),Yt=qh(r.textSizeData,d,Ft),Yi=a.get("text-padding"),Gt=E.collisionCircleDiameter;Ie=this.collisionIndex.placeCollisionCircles(g,Ft,r.lineVertexArray,r.glyphOffsetArray,Yt,o,l,i,w,p.predicate,Gt,Yi,n,R),Ie.circles.length&&Ie.collisionDetected&&!i&&le("Collisions detected, but collision boxes are not shown"),O=_||Ie.circles.length>0&&!Ie.collisionDetected,ue&&(ue=Ie.offscreen)}if(A.iconFeatureIndex&&(Fi=A.iconFeatureIndex),A.iconBox){let Ft=Yt=>this.collisionIndex.placeCollisionBox(Yt,y,u,F,o,w,v,s,p.predicate,R,b&&Ae?Ae:void 0,I,N,P);Ce&&Ce.placeable&&A.verticalIconBox?(Me=Ft(A.verticalIconBox),H=Me.placeable):(Me=Ft(A.iconBox),H=Me.placeable),ue&&(ue=Me.offscreen)}let Ue=f||E.numHorizontalGlyphVertices===0&&E.numVerticalGlyphVertices===0,wt=m||E.numIconVertices===0;!Ue&&!wt?H=O=H&&O:wt?Ue||H&&(H=O):O=H&&O;let Lr=O&&_e.placeable,Br=H&&Me.placeable;if(Lr&&(Ce&&Ce.placeable&&Mt?this.collisionIndex.insertCollisionBox(_e.box,g,a.get("text-ignore-placement"),r.bucketInstanceId,Mt,p.ID):this.collisionIndex.insertCollisionBox(_e.box,g,a.get("text-ignore-placement"),r.bucketInstanceId,ct,p.ID)),Br&&this.collisionIndex.insertCollisionBox(Me.box,y,a.get("icon-ignore-placement"),r.bucketInstanceId,Fi,p.ID),Ie&&O&&this.collisionIndex.insertCollisionCircles(Ie.circles,g,a.get("text-ignore-placement"),r.bucketInstanceId,ct,p.ID),i&&this.storeCollisionData(r.bucketInstanceId,B,A,_e,Me,Ie),E.crossTileID===0)throw Error("symbolInstance.crossTileID can't be 0");if(r.bucketInstanceId===0)throw Error("bucket.bucketInstanceId can't be 0");let va=(O||S)&&!(_e!=null&&_e.occluded),Xi=(H||M)&&!(Me!=null&&Me.occluded);this.placements[E.crossTileID]=new ky(va,Xi,ue||r.justReloaded),t[E.crossTileID]=!0};if(T){if(e.symbolInstanceStart!==0)throw Error("bucket.bucketInstanceId should be 0");let E=r.getSortedSymbolIndexes(-this.transform.bearingInRadians);for(let A=E.length-1;A>=0;--A){let B=E[A];D(r.symbolInstances.get(B),r.collisionArrays[B],B)}}else for(let E=e.symbolInstanceStart;E<e.symbolInstanceEnd;E++)D(r.symbolInstances.get(E),r.collisionArrays[E],E);r.justReloaded=!1}storeCollisionData(e,t,i,r,a,n){if(i.textBox||i.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)),i.textBox&&(o.text=r.box),i.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,i,r){let a={left:i.leftJustifiedTextSymbolIndex,center:i.centerJustifiedTextSymbolIndex,right:i.rightJustifiedTextSymbolIndex},n;n=r===2?i.verticalPlacedTextSymbolIndex:a[Xh(t)];let s=[i.leftJustifiedTextSymbolIndex,i.centerJustifiedTextSymbolIndex,i.rightJustifiedTextSymbolIndex,i.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=i.crossTileID)}markUsedOrientation(e,t,i){let r=t===1||t===3?t:0,a=t===2?t:0,n=[i.leftJustifiedTextSymbolIndex,i.centerJustifiedTextSymbolIndex,i.rightJustifiedTextSymbolIndex];for(let s of n)e.text.placedSymbolArray.get(s).placedOrientation=r;i.verticalPlacedTextSymbolIndex&&(e.text.placedSymbolArray.get(i.verticalPlacedTextSymbolIndex).placedOrientation=a)}commit(e){this.commitTime=e,this.zoomAtLastRecencyCheck=this.transform.zoom;let t=this.prevPlacement,i=!1;this.prevZoomAdjustment=t?t.zoomAdjustment(this.transform.zoom):0;let r=t?t.symbolFadeChange(e):1,a=t?t.opacities:{},n=t?t.variableOffsets:{},s=t?t.placedOrientations:{};for(let o in this.placements){let l=this.placements[o],u=a[o];u?(this.opacities[o]=new us(u,r,l.text,l.icon),i||(i=l.text!==u.text.placed),i||(i=l.icon!==u.icon.placed)):(this.opacities[o]=new us(null,r,l.text,l.icon,l.skipFade),i||(i=l.text||l.icon))}for(let o in a){let l=a[o];if(!this.opacities[o]){let u=new us(l,r,!1,!1);u.isHidden()||(this.opacities[o]=u,i||(i=l.text.placed),i||(i=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");i?this.lastPlacementChangeTime=e:typeof this.lastPlacementChangeTime!="number"&&(this.lastPlacementChangeTime=t?t.lastPlacementChangeTime:e)}updateLayerOpacities(e,t){let i={};for(let r of t){let a=r.getBucket(e);a&&r.latestFeatureIndex&&e.id===a.layerIds[0]&&this.updateBucketOpacities(a,r.tileID,i,r.collisionBoxArray)}}updateBucketOpacities(e,t,i,r){e.hasTextData()&&(e.text.opacityVertexArray.clear(),e.text.hasVisibleVertices=!1),e.hasIconData()&&(e.icon.opacityVertexArray.clear(),e.icon.hasVisibleVertices=!1),e.hasIconCollisionBoxData()&&e.iconCollisionBox.collisionVertexArray.clear(),e.hasTextCollisionBoxData()&&e.textCollisionBox.collisionVertexArray.clear();let a=e.layers[0],n=a.layout,s=new us(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 us(null,0,o&&(l||!e.hasIconData()||n.get("icon-optional")),l&&(o||!e.hasTextData()||n.get("text-optional")),!0);!e.collisionArrays&&r&&(e.hasIconCollisionBoxData()||e.hasTextCollisionBoxData())&&e.deserializeCollisionBoxes(r);let f=(g,_,y)=>{for(let x=0;x<_/4;x++)g.opacityVertexArray.emplaceBack(y);g.hasVisibleVertices||(g.hasVisibleVertices=y!==hs)},m=this.collisionBoxArrays.get(e.bucketInstanceId);for(let g=0;g<e.symbolInstances.length;g++){let _=e.symbolInstances.get(g),{numHorizontalGlyphVertices:y,numVerticalGlyphVertices:x,crossTileID:v}=_,w=i[v],b=this.opacities[v];w?b=s:b||(b=p,this.opacities[v]=b),i[v]=!0;let T=y>0||x>0,P=_.numIconVertices>0,S=this.placedOrientations[_.crossTileID],M=S===2,F=S===1||S===3;if(T){let I=$y(b.text),D=M?hs:I;f(e.text,y,D);let E=F?hs:I;f(e.text,x,E);let A=b.text.isHidden(),B=[_.rightJustifiedTextSymbolIndex,_.centerJustifiedTextSymbolIndex,_.leftJustifiedTextSymbolIndex];for(let H of B)H>=0&&(e.text.placedSymbolArray.get(H).hidden=A||M?1:0);_.verticalPlacedTextSymbolIndex>=0&&(e.text.placedSymbolArray.get(_.verticalPlacedTextSymbolIndex).hidden=A||F?1:0);let N=this.variableOffsets[_.crossTileID];N&&this.markUsedJustification(e,N.anchor,_,S);let O=this.placedOrientations[_.crossTileID];O&&(this.markUsedJustification(e,"left",_,O),this.markUsedOrientation(e,O,_))}if(P){let I=$y(b.icon),D=!(d&&_.verticalPlacedIconSymbolIndex&&M);if(_.placedIconSymbolIndex>=0){let E=D?I:hs;f(e.icon,_.numIconVertices,E),e.icon.placedSymbolArray.get(_.placedIconSymbolIndex).hidden=b.icon.isHidden()}if(_.verticalPlacedIconSymbolIndex>=0){let E=D?hs:I;f(e.icon,_.numVerticalIconVertices,E),e.icon.placedSymbolArray.get(_.verticalPlacedIconSymbolIndex).hidden=b.icon.isHidden()}}let R=m!=null&&m.has(g)?m.get(g):{text:null,icon:null};if(e.hasIconCollisionBoxData()||e.hasTextCollisionBoxData()){let I=e.collisionArrays[g];if(I){let D=new C(0,0);if(I.textBox||I.verticalTextBox){let E=!0;if(u){let A=this.variableOffsets[v];A?(D=Ly(A.anchor,A.width,A.height,A.textOffset,A.textBoxScale),h&&D._rotate(c?-this.transform.bearingInRadians:this.transform.bearingInRadians)):E=!1}if(I.textBox||I.verticalTextBox){let A;I.textBox&&(A=M),I.verticalTextBox&&(A=F),By(e.textCollisionBox.collisionVertexArray,b.text.placed,!E||A,R.text,D.x,D.y)}}if(I.iconBox||I.verticalIconBox){let E=!(F||!I.verticalIconBox),A;I.iconBox&&(A=E),I.verticalIconBox&&(A=!E),By(e.iconCollisionBox.collisionVertexArray,b.icon.placed,A,R.icon,d?D.x:0,d?D.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 i=this.zoomAtLastRecencyCheck===t?1-this.zoomAdjustment(t):1;return this.zoomAtLastRecencyCheck=t,this.commitTime+this.fadeDuration*i>e}setStale(){this.stale=!0}};function By(e,t,i,r,a,n){(!r||r.length===0)&&(r=[0,0,0,0]);let s=r[0]-100,o=r[1]-100,l=r[2]-100,u=r[3]-100;e.emplaceBack(+!!t,+!!i,a||0,n||0,s,o),e.emplaceBack(+!!t,+!!i,a||0,n||0,l,o),e.emplaceBack(+!!t,+!!i,a||0,n||0,l,u),e.emplaceBack(+!!t,+!!i,a||0,n||0,s,u)}const WI=2**25,HI=2**24,XI=2**17,YI=2**16;function $y(e){if(e.opacity===0&&!e.placed)return 0;if(e.opacity===1&&e.placed)return 4294967295;let t=+!!e.placed,i=Math.floor(e.opacity*127);return i*WI+t*HI+i*XI+t*YI+i*512+t*256+i*2+t}const hs=0;var KI=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,i,r,a){let n=this._bucketParts;for(;this._currentTileIndex<e.length;){let s=e[this._currentTileIndex];if(t.getBucketParts(n,r,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,i),this._currentPartIndex++,a())return!0}return!1}},JI=class{constructor(e,t,i,r,a,n,s,o){this.placement=new qI(e,t,n,s,o),this._currentPlacementIndex=i.length-1,this._forceFullPlacement=r,this._showCollisionBoxes=a,this._done=!1}isDone(){return this._done}continuePlacement(e,t,i){let r=Te(),a=()=>!this._forceFullPlacement&&Te()-r>2;for(;this._currentPlacementIndex>=0;){let n=t[e[this._currentPlacementIndex]],s=this.placement.collisionIndex.transform.zoom;if(qg(n)&&n.layout&&(!n.minzoom||n.minzoom<=s)&&(!n.maxzoom||n.maxzoom>s)){if(this._inProgressLayer||(this._inProgressLayer=new KI(n)),this._inProgressLayer.continuePlacement(i[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 Oy=[Int8Array,Uint8Array,Uint8ClampedArray,Int16Array,Uint16Array,Int32Array,Uint32Array,Float32Array,Float64Array],He=new Uint32Array(96);var QI=class L1{static from(t){if(!t||t.byteLength===void 0||t.buffer)throw Error("Data must be an instance of ArrayBuffer or SharedArrayBuffer.");let[i,r]=new Uint8Array(t,0,2);if(i!==219)throw Error("Data does not appear to be in a KDBush format.");let a=r>>4;if(a!==1)throw Error(`Got v${a} data when expected v1.`);let n=Oy[r&15];if(!n)throw Error("Unrecognized array type.");let[s]=new Uint16Array(t,2,1),[o]=new Uint32Array(t,4,1);return new L1(o,s,n,void 0,t)}constructor(t,i=64,r=Float64Array,a=ArrayBuffer,n){if(isNaN(t)||t<0)throw Error(`Unexpected numItems value: ${t}.`);this.numItems=+t,this.nodeSize=Math.min(Math.max(+i,2),65535),this.ArrayType=r,this.IndexArrayType=t<65536?Uint16Array:Uint32Array;let s=Oy.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: ${r}.`);if(n)this.data=n,this.ids=new this.IndexArrayType(n,8,t),this.coords=new r(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 r(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]=i,new Uint32Array(h,4,1)[0]=t}}add(t,i){let r=this._pos>>1;return this.ids[r]=r,this.coords[this._pos++]=t,this.coords[this._pos++]=i,r}finish(){let t=this._pos>>1;if(t!==this.numItems)throw Error(`Added ${t} items when expected ${this.numItems}.`);return qc(this.ids,this.coords,this.nodeSize,0,this.numItems-1,0),this._finished=!0,this}range(t,i,r,a){if(!this._finished)throw Error("Data not yet indexed - call index.finish().");let{ids:n,coords:s,nodeSize:o}=this;He[0]=0,He[1]=n.length-1,He[2]=0;let l=3,u=[];for(;l>0;){let h=He[--l],c=He[--l],d=He[--l];if(c-d<=o){for(let g=d;g<=c;g++){let _=s[2*g],y=s[2*g+1];_>=t&&_<=r&&y>=i&&y<=a&&u.push(n[g])}continue}let p=d+c>>1,f=s[2*p],m=s[2*p+1];f>=t&&f<=r&&m>=i&&m<=a&&u.push(n[p]),(h===0?t<=f:i<=m)&&(He[l++]=d,He[l++]=p-1,He[l++]=1-h),(h===0?r>=f:a>=m)&&(He[l++]=p+1,He[l++]=c,He[l++]=1-h)}return u}within(t,i,r){let a=[];return this.withinInto(t,i,r,a),a}withinInto(t,i,r,a){if(!this._finished)throw Error("Data not yet indexed - call index.finish().");let{ids:n,coords:s,nodeSize:o}=this;He[0]=0,He[1]=n.length-1,He[2]=0;let l=3,u=0,h=r*r;for(;l>0;){let c=He[--l],d=He[--l],p=He[--l];if(d-p<=o){for(let _=p;_<=d;_++)Vy(s[2*_],s[2*_+1],t,i)<=h&&(a[u++]=n[_]);continue}let f=p+d>>1,m=s[2*f],g=s[2*f+1];Vy(m,g,t,i)<=h&&(a[u++]=n[f]),(c===0?t-r<=m:i-r<=g)&&(He[l++]=p,He[l++]=f-1,He[l++]=1-c),(c===0?t+r>=m:i+r>=g)&&(He[l++]=f+1,He[l++]=d,He[l++]=1-c)}return u}};function qc(e,t,i,r,a,n){if(a-r<=i)return;let s=r+a>>1;Ny(e,t,s,r,a,n),qc(e,t,i,r,s-1,1-n),qc(e,t,i,s+1,a,1-n)}function Ny(e,t,i,r,a,n){for(;a>r;){if(a-r>600){let u=a-r+1,h=i-r+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);Ny(e,t,i,Math.max(r,Math.floor(i-h*d/u+p)),Math.min(a,Math.floor(i+(u-h)*d/u+p)),n)}let s=t[2*i+n],o=r,l=a;for(cs(e,t,r,i),t[2*a+n]>s&&cs(e,t,r,a);o<l;){for(cs(e,t,o,l),o++,l--;t[2*o+n]<s;)o++;for(;t[2*l+n]>s;)l--}t[2*r+n]===s?cs(e,t,r,l):(l++,cs(e,t,l,a)),l<=i&&(r=l+1),i<=l&&(a=l-1)}}function cs(e,t,i,r){Wc(e,i,r),Wc(t,2*i,2*r),Wc(t,2*i+1,2*r+1)}function Wc(e,t,i){let r=e[t];e[t]=e[i],e[i]=r}function Vy(e,t,i,r){let a=e-i,n=t-r;return a*a+n*n}const ds=512/k/2;var eM=class{constructor(e,t,i){this.tileID=e,this.bucketInstanceId=i,this._symbolsByKey={};let r=new Map;for(let a=0;a<t.length;a++){let n=t.get(a),s=n.key,o=r.get(s);o?o.push(n):r.set(s,[n])}for(let[a,n]of r){let s={positions:n.map(o=>({x:Math.floor(o.anchorX*ds),y:Math.floor(o.anchorY*ds)})),crossTileIDs:n.map(o=>o.crossTileID)};if(s.positions.length>128){let o=new QI(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:i,y:r,z:a}=this.tileID.canonical,{x:n,y:s,z:o}=t.canonical,l=o-a,u=ds/2**l,h=(n*k+e.anchorX)*u,c=(s*k+e.anchorY)*u,d=i*k*ds,p=r*k*ds;return{x:Math.floor(h-d),y:Math.floor(c-p)}}findMatches(e,t,i){let r=this.tileID.canonical.z<t.canonical.z?1:2**(this.tileID.canonical.z-t.canonical.z);for(let a=0;a<e.length;a++){let n=e.get(a);if(n.crossTileID)continue;let s=this._symbolsByKey[n.key];if(!s)continue;let o=this.getScaledCoordinates(n,t);s.index?this.findMatchesForIndexedEntry(s,n,o,r,i):s.positions&&this.findMatchesForNonIndexedEntry(s,n,o,r,i)}}findMatchesForIndexedEntry(e,t,i,r,a){let n=e.index.range(i.x-r,i.y-r,i.x+r,i.y+r),s=1/0;for(let o of n)o<s&&!a[e.crossTileIDs[o]]&&(s=o);if(s!==1/0){let o=e.crossTileIDs[s];a[o]=!0,t.crossTileID=o}}findMatchesForNonIndexedEntry(e,t,i,r,a){for(let n=0;n<e.positions.length;n++){let s=e.positions[n],o=e.crossTileIDs[n];if(Math.abs(s.x-i.x)<=r&&Math.abs(s.y-i.y)<=r&&!a[o]){a[o]=!0,t.crossTileID=o;break}}}getCrossTileIDsLists(){return Object.values(this._symbolsByKey).map(({crossTileIDs:e})=>e)}},tM=class{constructor(){this.maxCrossTileID=0}generate(){return++this.maxCrossTileID}},iM=class{constructor(){this.indexes={},this.usedCrossTileIDs={},this.lng=0}handleWrapJump(e){let t=Math.round((e-this.lng)/360);if(t!==0)for(let i in this.indexes){let r=this.indexes[i],a={};for(let n in r){let s=r[n];s.tileID=s.tileID.unwrapTo(s.tileID.wrap+t),a[s.tileID.key]=s}this.indexes[i]=a}this.lng=e}addBucket(e,t,i){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 r=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,r)}else{let u=l[e.scaledTo(Number(o)).key];u&&u.findMatches(t.symbolInstances,e,r)}}for(let o=0;o<t.symbolInstances.length;o++){let l=t.symbolInstances.get(o);l.crossTileID||(l.crossTileID=i.generate(),r[l.crossTileID]=!0)}return this.indexes[e.overscaledZ]===void 0&&(this.indexes[e.overscaledZ]={}),this.indexes[e.overscaledZ][e.key]=new eM(e,t.symbolInstances,t.bucketInstanceId),!0}removeBucketCrossTileIDs(e,t){for(let i of t.getCrossTileIDsLists())for(let r of i)delete this.usedCrossTileIDs[e][r]}removeStaleBuckets(e){let t=!1;for(let i in this.indexes){let r=this.indexes[i];for(let a in r)e[r[a].bucketInstanceId]||(this.removeBucketCrossTileIDs(i,r[a]),delete r[a],t=!0)}return t}},jy=class{constructor(){this.layerIndexes={},this.crossTileIDs=new tM,this.maxBucketInstanceId=0,this.bucketsInCurrentPlacement={}}addLayer(e,t,i){let r=this.layerIndexes[e.id];r===void 0&&(r=this.layerIndexes[e.id]=new iM);let a=!1,n={};r.handleWrapJump(i);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)),r.addBucket(s.tileID,o,this.crossTileIDs)&&(a=!0),n[o.bucketInstanceId]=!0)}return r.removeStaleBuckets(n)&&(a=!0),a}pruneUnusedLayers(e){let t={};for(let i of e)t[i]=!0;for(let i in this.layerIndexes)t[i]||delete this.layerIndexes[i]}},rM=`#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;};`,aM=`#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+2.0;vec2 f=fract(coord);ivec2 c=ivec2(floor(coord));ivec2 hi=textureSize(u_terrain,0)-1;float tl=ele(clamp(c,ivec2(0),hi));float tr=ele(clamp(c+ivec2(1,0),ivec2(0),hi));float bl=ele(clamp(c+ivec2(0,1),ivec2(0),hi));float br=ele(clamp(c+ivec2(1,1),ivec2(0),hi));float elevation=mix(mix(tl,tr,f.x),mix(bl,br,f.x),f.y);return elevation*u_terrain_exaggeration;
|
|
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;};`,nM=`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
|
+
}`,sM="layout(location=0) in vec2 a_pos;void main() {gl_Position=projectTile(a_pos);}",oM=`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
|
+
}`,lM="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);}",uM=`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
|
+
}`,hM=`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);}`,Uy="void main() {fragColor=vec4(1.0);}";const Wi={prelude:fe(rM,aM),projectionMercator:fe(`
|
|
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:fe("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:fe(nM,sM),backgroundPattern:fe(oM,lM),circle:fe(uM,hM),clippingMask:fe(Uy,"layout(location=0) in vec2 a_pos;void main() {gl_Position=projectTile(a_pos);}"),heatmap:fe(`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:fe(`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:fe("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:fe("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:fe(`#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:fe("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:fe(Uy,`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:fe(`#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:fe(`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:fe(`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:fe(`#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:fe(`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);
|
|
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+base)*pow(height/150.0,0.5),mix(0.7,0.98,1.0-u_lightintensity),1.0)));}v_color.r+=clamp(color.r*directional*u_lightcolor.r,mix(0.0,0.3,1.0-u_lightcolor.r),1.0);v_color.g+=clamp(color.g*directional*u_lightcolor.g,mix(0.0,0.3,1.0-u_lightcolor.g),1.0);v_color.b+=clamp(color.b*directional*u_lightcolor.b,mix(0.0,0.3,1.0-u_lightcolor.b),1.0);v_color*=u_opacity;}`),fillExtrusionPattern:fe(`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;
|
|
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+base)*pow(height/150.0,0.5),mix(0.7,0.98,1.0-u_lightintensity),1.0)));}v_lighting.rgb+=clamp(directional*u_lightcolor,mix(vec3(0.0),vec3(0.3),1.0-u_lightcolor),vec3(1.0));v_lighting*=u_opacity;}`),hillshadePrepare:fe(`#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+0.5,deriv.y/8.0+0.5,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:fe(`uniform sampler2D u_image;in vec2 v_pos;uniform vec2 u_latrange;uniform float u_exaggeration;uniform vec4 u_accent;uniform int u_method;uniform float u_altitudes[NUM_ILLUMINATION_SOURCES];uniform float u_azimuths[NUM_ILLUMINATION_SOURCES];uniform vec4 u_shadows[NUM_ILLUMINATION_SOURCES];uniform vec4 u_highlights[NUM_ILLUMINATION_SOURCES];
|
|
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() {vec2 size=vec2(textureSize(u_image,0));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*8.0)-4.0)/scaleFactor;if (u_method==BASIC) {basic_hillshade(deriv);} else if (u_method==COMBINED) {combined_hillshade(deriv);} else if (u_method==IGOR) {igor_hillshade(deriv);} else if (u_method==MULTIDIRECTIONAL) {multidirectional_hillshade(deriv);} else if (u_method==STANDARD) {standard_hillshade(deriv);} else {standard_hillshade(deriv);}
|
|
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:fe(`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:fe(`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:fe(`#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:fe(`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:fe(`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:fe(`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:fe(`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:fe(`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:fe(`#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:fe(`#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:fe("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:fe("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:fe(`#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:fe("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;in vec3 v_view_direction;void main() {float x=gl_FragCoord.x;float y=gl_FragCoord.y;float blend=(y-u_horizon.y)*u_horizon_normal.y+(x-u_horizon.x)*u_horizon_normal.x;if (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*u_device_pixel_ratio,u_sky_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(fragColor,vec4(vec3(0.0),0.0),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 fe(e,t){let i=/#pragma maplibre: ([\w]+) ([\w]+) ([\w]+) ([\w]+)/g,r=t.match(/in ([\w]+) ([\w]+)/g),a=e.match(/uniform ([\w]+) ([\w]+)([\s]*)([\w]*)/g),n=t.match(/uniform ([\w]+) ([\w]+)([\s]*)([\w]*)/g),s=n?n.concat(a):a,o=r?r.length:0,l={};return e=e.replace(i,(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(i,(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:r,staticUniforms:s}}const Gy="#define PROJECTION_MERCATOR",Zy="mercator";var Hc=class{constructor(){this._cachedMesh=null}get name(){return"mercator"}get useSubdivision(){return!1}get shaderVariantName(){return Zy}get shaderDefine(){return Gy}get shaderPreludeCode(){return Wi.projectionMercator}get vertexShaderPreludeCode(){return Wi.projectionMercator.vertexSource}get subdivisionGranularity(){return $h.noSubdivision}get useGlobeControls(){return!1}get transitionState(){return 0}destroy(){}getMeshFromTileID(e,t,i,r,a){if(this._cachedMesh)return this._cachedMesh;let n=new Pr;n.emplaceBack(0,0),n.emplaceBack(k,0),n.emplaceBack(0,k),n.emplaceBack(k,k);let s=e.createVertexBuffer(n,ca.members),o=Ne.simpleSegment(0,0,4,2),l=new Gi;l.emplaceBack(1,0,2),l.emplaceBack(1,2,3);let u=e.createIndexBuffer(l);return this._cachedMesh=new os(s,u,o),this._cachedMesh}recalculate(){}hasTransition(){return!1}},Xc=class B1{constructor(t=0,i=0,r=0,a=0){if(isNaN(t)||t<0||isNaN(i)||i<0||isNaN(r)||r<0||isNaN(a)||a<0)throw Error("Invalid value for edge-insets, top, bottom, left and right must all be numbers");this.top=t,this.bottom=i,this.left=r,this.right=a}interpolate(t,i,r){return i.top!=null&&t.top!=null&&(this.top=Oe.number(t.top,i.top,r)),i.bottom!=null&&t.bottom!=null&&(this.bottom=Oe.number(t.bottom,i.bottom,r)),i.left!=null&&t.left!=null&&(this.left=Oe.number(t.left,i.left,r)),i.right!=null&&t.right!=null&&(this.right=Oe.number(t.right,i.right,r)),this}getCenter(t,i){let r=ee((this.left+t-this.right)/2,0,t),a=ee((this.top+i-this.bottom)/2,0,i);return new C(r,a)}equals(t){return this.top===t.top&&this.bottom===t.bottom&&this.left===t.left&&this.right===t.right}clone(){return new B1(this.top,this.bottom,this.left,this.right)}toJSON(){return{top:this.top,bottom:this.bottom,left:this.left,right:this.right}}};function _l(e,t){if(!e.renderWorldCopies||e.lngRange)return;let i=t.lng-e.center.lng;t.lng+=i>180?-360:i<-180?360:0}function qy(e){return Math.max(0,Math.floor(e))}var Yc=class{constructor(e,t){this.applyConstrain=(i,r)=>this._constrainOverride===null?this._callbacks.defaultConstrain(i,r):this._constrainOverride(i,r),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 W(0,0),this._elevation=0,this._zoom=0,this._tileZoom=qy(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 Xc,this._minElevationForCurrentTile=0,this._autoCalculateNearFarZ=!0}apply(e,t,i){this._constrainOverride=e.constrainOverride,this._latRange=e.latRange,this._lngRange=e.lngRange,this._width=e.width,this._height=e.height,this._center=e.center,this._elevation=e.elevation,this._minElevationForCurrentTile=e.minElevationForCurrentTile,this._zoom=e.zoom,this._tileZoom=qy(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 Xc(e.padding.top,e.padding.bottom,e.padding.left,e.padding.right),this._minZoom=e.minZoom,this._maxZoom=e.maxZoom,this._minPitch=e.minPitch,this._maxPitch=e.maxPitch,this._renderWorldCopies=e.renderWorldCopies,this._cameraToCenterDistance=e.cameraToCenterDistance,this._nearZ=e.nearZ,this._farZ=e.farZ,this._autoCalculateNearFarZ=!i&&e.autoCalculateNearFarZ,t&&this.constrainInternal(),this._calcMatrices()}get pixelsToClipSpaceMatrix(){return this._pixelsToClipSpaceMatrix}get clipSpaceToPixelsMatrix(){return this._clipSpaceToPixelsMatrix}get minElevationForCurrentTile(){return this._minElevationForCurrentTile}setMinElevationForCurrentTile(e){this._minElevationForCurrentTile=e}get tileSize(){return this._tileSize}get tileZoom(){return this._tileZoom}get scale(){return this._scale}get width(){return this._width}get height(){return this._height}get bearingInRadians(){return this._bearingInRadians}get lngRange(){return this._lngRange}get latRange(){return this._latRange}get pixelsToGLUnits(){return this._pixelsToGLUnits}get minZoom(){return this._minZoom}setMinZoom(e){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 C(this._width,this._height)}get bearing(){return this._bearingInRadians/Math.PI*180}setBearing(e){let t=ci(e,-180,180)*Math.PI/180;this._bearingInRadians!==t&&(this._unmodified=!1,this._bearingInRadians=t,this._calcMatrices(),this._rotationMatrix=N_(),tD(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=ee(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 Li(this._fovInRadians)}setFov(e){e=ee(e,.1,150),this.fov!==e&&(this._unmodified=!1,this._fovInRadians=Be(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,i){this._unmodified=!1,this._edgeInsets.interpolate(e,t,i),this.constrainInternal(),this._calcMatrices()}resize(e,t,i=!0){this._width=e,this._height=t,i&&this.constrainInternal(),this._calcMatrices()}getMaxBounds(){var e,t;return((e=this._latRange)==null?void 0:e.length)!==2||((t=this._lngRange)==null?void 0:t.length)!==2?null:new Mi([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=[-Bi,Bi])}getCameraQueryGeometry(e,t){if(t.length===1)return[t[0],e];{let{minX:i,minY:r,maxX:a,maxY:n}=Di.fromPoints(t).extend(e);return[new C(i,r),new C(a,r),new C(a,n),new C(i,n),new C(i,r)]}}constrainInternal(){if(!this.center||!this._width||!this._height||this._constraining)return;this._constraining=!0;let e=this._unmodified,{center:t,zoom:i}=this.applyConstrain(this.center,this.zoom);this.setCenter(t),this.setZoom(i),this._unmodified=e,this._constraining=!1}_calcMatrices(){if(this._width&&this._height){this._pixelsToGLUnits=[2/this._width,-2/this._height];let e=Si(new Float64Array(16));Tt(e,e,[this._width/2,-this._height/2,1]),rt(e,e,[1,-1,0]),this._clipSpaceToPixelsMatrix=e,e=Si(new Float64Array(16)),Tt(e,e,[1,-1,1]),rt(e,e,[-1,-1,0]),Tt(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._pixelPerMeter=ra(1,this.center.lat)*this.worldSize,this._callbacks.calcMatrices()}calculateCenterFromCameraLngLatAlt(e,t,i,r){let a=i===void 0?this.bearing:i,n=r=r===void 0?this.pitch:r,{distanceToCenter:s,clampedElevation:o}=this._distanceToCenterFromAltElevationPitch(t,this.elevation,n),{x:l,y:u}=jh(n,a),h=ye.fromLngLat(e,t),c=Qm(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 ye(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:Et(this.height/2/Math.tan(this.fovInRadians/2)/p/this.tileSize)}}recalculateZoomAndCenter(e){if(this.elevation-e===0)return;let t=1/this.worldSize,i=ra(1,this.center.lat)*this.worldSize,r=ye.fromLngLat(this.center,this.elevation),a=r.x/t,n=r.y/t,s=r.z/t,o=this.pitch,l=this.bearing,{x:u,y:h,z:c}=jh(o,l),d=this.cameraToCenterDistance,p=a+d*-u,f=n+d*-h,m=s+d*c,{distanceToCenter:g,clampedElevation:_}=this._distanceToCenterFromAltElevationPitch(m/i,e,o),y=g*i,x=p+u*y,v=f+h*y,w=new ye(x*t,v*t,0).toLngLat(),b=ra(1,w.lat),T=Et(this.height/2/Math.tan(this.fovInRadians/2)/g/b/this.tileSize);this._elevation=_,this._center=w,this.setZoom(T)}_distanceToCenterFromAltElevationPitch(e,t,i){let r=-Math.cos(Be(i)),a=e-t,n,s=t;return r*a>=0||Math.abs(r)<.1?(n=1e4,s=e+n*r):n=-a/r,{distanceToCenter:n,clampedElevation:s}}getCameraPoint(){let e=this.pitchInRadians,t=Math.tan(e)*(this.cameraToCenterDistance||1);return this.centerPoint.add(new C(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/k,1/t/k]}},cM=class{distanceToTile2d(e,t,i,r){let a=r,n=a.distanceX([e,t]),s=a.distanceY([e,t]);return Math.hypot(n,s)}getWrap(e,t,i){return i}getTileBoundingVolume(e,t,i,r){let a=Math.min(0,i),n=Math.max(0,i);if(r!=null&&r.terrain){let o=new Pt(e.z,t,e.z,e.x,e.y),l=r.terrain.getMinMaxElevation(o);a=l.minElevation??a,n=l.maxElevation??n}let s=1<<e.z;return new kc([t+e.x/s,e.y/s,a],[t+(e.x+1)/s,(e.y+1)/s,n])}allowVariableZoom(e,t){let i=e.fov*(Math.abs(Math.cos(e.rollInRadians))*e.height+Math.abs(Math.sin(e.rollInRadians))*e.width)/e.height,r=ee(78.5-i/2,0,60);return!!t.terrain||e.pitch>r}allowWorldCopies(){return!0}prepareNextFrame(){}};const dM=We([{name:"a_pos3d",type:"Int16",components:3}]);var pM=class extends ot{constructor(e){super(),this._lastTilesetChange=Te(),this.tileManager=e,this._tiles={},this._renderableTilesKeys=[],this._sourceTileCache={},this.minzoom=0,this.maxzoom=22,this.deltaZoom=1,this.tileSize=e._source.tileSize*2**this.deltaZoom,e.usedForTerrain=!0,e.tileSize=this.tileSize}destruct(){this.tileManager.usedForTerrain=!1,this.tileManager.tileSize=null,this.releaseAllRTT()}getSource(){return this.tileManager._source}update(e,t){this.tileManager.update(e,t),this._renderableTilesKeys=[];let i={},r=!1;for(let a of en(e,{tileSize:this.tileSize,minzoom:this.minzoom,maxzoom:this.maxzoom,reparseOverscaled:!1,terrain:t,calculateTileZoom:this.tileManager._source.calculateTileZoom}))i[a.key]=!0,this._renderableTilesKeys.push(a.key),this._tiles[a.key]||(a.terrainRttPosMatrix32f=new Float32Array(16),Ri(a.terrainRttPosMatrix32f,0,k,k,0,0,1),this._tiles[a.key]=new xy(a,this.tileSize),this._lastTilesetChange=Te(),r=!0);for(let a in this._tiles)i[a]||(this._tiles[a].releaseRTT(this.tileManager.map.painter),delete this._tiles[a],r=!0);return r}releaseRTT(e){for(let t in this._tiles){let i=this._tiles[t];(i.tileID.equals(e)||i.tileID.isChildOf(e)||e.isChildOf(i.tileID))&&i.releaseRTT(this.tileManager.map.painter)}}releaseAllRTT(){for(let e in this._tiles)this._tiles[e].releaseRTT(this.tileManager.map.painter)}getRenderableTiles(){return this._renderableTilesKeys.map(e=>this.getTileByID(e))}getTileByID(e){return this._tiles[e]}getTerrainCoords(e,t){return t?this._getTerrainCoordsForTileRanges(e,t):this._getTerrainCoordsForRegularTile(e)}_getTerrainCoordsForRegularTile(e){let t={};for(let i of this._renderableTilesKeys){let r=this._tiles[i].tileID,a=e.clone(),n=Nr();if(r.canonical.equals(e.canonical))Ri(n,0,k,k,0,0,1);else if(r.canonical.isChildOf(e.canonical)){let s=r.canonical.z-e.canonical.z,o=r.canonical.x-(r.canonical.x>>s<<s),l=r.canonical.y-(r.canonical.y>>s<<s),u=k>>s;Ri(n,0,u,u,0,0,1),rt(n,n,[-o*u,-l*u,0])}else if(e.canonical.isChildOf(r.canonical)){let s=e.canonical.z-r.canonical.z,o=e.canonical.x-(e.canonical.x>>s<<s),l=e.canonical.y-(e.canonical.y>>s<<s),u=k>>s;Ri(n,0,k,k,0,0,1),rt(n,n,[o*u,l*u,0]),Tt(n,n,[1/2**s,1/2**s,0])}else continue;a.terrainRttPosMatrix32f=new Float32Array(n),t[i]=a}return t}_getTerrainCoordsForTileRanges(e,t){let i={};for(let r of this._renderableTilesKeys){let a=this._tiles[r].tileID;if(!this._isWithinTileRanges(a,t))continue;let n=e.clone(),s=Nr();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;Ri(s,0,k,k,0,0,1),rt(s,s,[o*k,l*k,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=k>>o;Ri(s,0,d,d,0,0,1),rt(s,s,[-l*d+h*k,-u*d+c*k,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=k<<o;Ri(s,0,d,d,0,0,1),rt(s,s,[l*k+h*d,u*k+c*d,0])}n.terrainRttPosMatrix32f=new Float32Array(s),i[r]=n}return i}getSourceTile(e,t){var n,s;let i=this.tileManager._source,r=e.overscaledZ-this.deltaZoom;if(r>i.maxzoom&&(r=i.maxzoom),r<i.minzoom)return;(n=this._sourceTileCache)[s=e.key]||(n[s]=e.scaledTo(r).key);let a=this.findTileInCaches(this._sourceTileCache[e.key]);if(!(a!=null&&a.dem)&&t)for(;r>=i.minzoom&&!(a!=null&&a.dem);)a=this.findTileInCaches(e.scaledTo(r--).key);return a}findTileInCaches(e){let t=this.tileManager.getTileByID(e);return t||(t=this.tileManager._outOfViewCache.getByKey(e),t)}anyTilesAfterTime(e=Te()){return this._lastTilesetChange>=e}_isWithinTileRanges(e,t){let i=t[e.canonical.z];return!!i&&(e.wrap>i.minWrap||e.wrap<i.maxWrap||e.canonical.x>=i.minTileXWrapped&&e.canonical.x<=i.maxTileXWrapped&&e.canonical.y>=i.minTileY&&e.canonical.y<=i.maxTileY)}};const Wy=k*(1-1e-12);var fM=class{constructor(e,t,i,r="auto"){this._meshCache={},this.painter=e,this.tileManager=new pM(t),this.options=i,this.exaggeration=typeof i.exaggeration=="number"?i.exaggeration:1,this._terrainSkirtLength=r,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,i,r=k){let a=e.normalizeCoordinates(t,i,r);if(!a)return 0;let n=this.getElevationSampler(a.tileID);return n?n(a.x,a.y,r):0}getElevationForLngLatZoom(e,t){if(!Wg(t,e.wrap()))return 0;let{tileID:i,mercatorX:r,mercatorY:a}=this._getOverscaledTileIDFromLngLatZoom(e,t);return this.getElevation(i,r%k,a%k,k)}getElevationForLngLat(e,t){let i=this.getCoverageIndex();if(i){let n=ye.fromLngLat(e),s=Kc(i,this.exaggeration,n.x,n.y);if(s.demLoaded)return s.elevation}let r=en(t,{maxzoom:this.tileManager.maxzoom,minzoom:this.tileManager.minzoom,tileSize:512,terrain:this}),a=0;for(let n of r)n.canonical.z>a&&(a=Math.min(n.canonical.z,this.tileManager.maxzoom));return this.getElevationForLngLatZoom(e,a)}getElevation(e,t,i,r=k){return this.getDEMElevation(e,t,i,r)*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,i=0,r=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);i=Math.min(i,l??0),r=Math.max(r,u??0)}return t.size===0?null:(e.sort((a,n)=>n-a),{zooms:e,samplerPerTile:t,minElevation:i-10,maxElevation:r+10})}getElevationSampler(e){let t=e.key,i=this._elevationSamplerCache.get(t);if(i)return i;let r=this.tileManager.getSourceTile(e,!0),a=r==null?void 0:r.dem;if(!r||!a)return null;let n=this._getDEMTileMatrix(e,r),s=n[0]*a.dim,o=n[5]*a.dim,l=n[12]*a.dim,u=n[13]*a.dim,h=(c,d,p)=>{let f=p===8192?1:k/p;return a.sampleBilinear(c*f*s+l,d*f*o+u)};return this._elevationSamplerCache.set(t,h),h}_getDEMTileMatrix(e,t){let i=`${t.tileID.key}/${e.key}`,r=this._demMatrixCache.get(i);if(r)return r;let a=this.tileManager.getSource().maxzoom,n=e.canonical.z-t.tileID.canonical.z;e.overscaledZ>e.canonical.z&&(e.canonical.z>=a?n=e.canonical.z-a:le("cannot calculate elevation if elevation maxzoom > source.maxzoom"));let s=e.canonical.x-(e.canonical.x>>n<<n),o=e.canonical.y-(e.canonical.y>>n<<n),l=ix(new Float64Array(16),[1/(k<<n),1/(k<<n),0]);return rt(l,l,[s*k,o*k,0]),this._demMatrixCache.set(i,l),l}getTerrainData(e){var r,a;if(!this._emptyDemTexture){let n=this.painter.context,s=new Fe({width:1,height:1},new Uint8Array(4));this._emptyDepthTexture=new lt(n,s,n.gl.RGBA,{premultiply:!1}),this._emptyDemUnpack=[0,0,0,0],this._emptyDemTexture=new lt(n,new Fe({width:1,height:1}),n.gl.RGBA,{premultiply:!1}),this._emptyDemTexture.bind(n.gl.NEAREST,n.gl.CLAMP_TO_EDGE),this._emptyDemMatrix=Si([])}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 lt(n,t.dem.getPixels(),n.gl.RGBA,{premultiply:!1}),t.demTexture.bind(n.gl.NEAREST,n.gl.CLAMP_TO_EDGE),t.needsTerrainPrepare=!1}let i=t?this._getDEMTileMatrix(e,t):this._emptyDemMatrix;return{u_depth:2,u_terrain:3,u_terrain_dim:((r=t==null?void 0:t.dem)==null?void 0:r.dim)||1,u_terrain_matrix:i,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,i=e.height/devicePixelRatio;return this._fbo&&(this._fbo.width!==t||this._fbo.height!==i)&&(this._fbo.destroy(),this._fboDepthTexture.destroy(),delete this._fbo,delete this._fboDepthTexture),this._fboDepthTexture||(this._fboDepthTexture=new lt(e.context,{width:t,height:i,data:null},e.context.gl.RGBA,{premultiply:!1}),this._fboDepthTexture.bind(e.context.gl.NEAREST,e.context.gl.CLAMP_TO_EDGE)),this._fbo||(this._fbo=e.context.createFramebuffer(t,i,!0,!1),this._fbo.depthAttachment.set(e.context.createRenderbuffer(e.context.gl.DEPTH_COMPONENT16,t,i))),this._fbo.colorAttachment.set(this._fboDepthTexture.texture),this._fbo}depthAtPoint(e){let t=new Uint8Array(4),i=this.painter.context,r=i.gl;return i.bindFramebuffer.set(this.getFramebuffer().framebuffer),r.readPixels(e.x,this.painter.height/devicePixelRatio-e.y-1,1,1,r.RGBA,r.UNSIGNED_BYTE,t),i.bindFramebuffer.set(null),(t[0]/16777216+t[1]/65536+t[2]/256+t[3])/256}getTerrainMesh(e){var d;let t=((d=this.painter.style.projection)==null?void 0:d.transitionState)>0,i=t&&e.canonical.y===0,r=t&&e.canonical.y===(1<<e.canonical.z)-1,a=`m_${i?"n":""}_${r?"s":""}`;if(this._meshCache[a])return this._meshCache[a];let n=this.painter.context,s=new _2,o=new Gi,l=this.meshSize,u=k/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,i,r);let c=new os(n.createVertexBuffer(s,dM.members),n.createIndexBuffer(o),Ne.simpleSegment(0,0,s.length,o.length));return this._meshCache[a]=c,c}getSkirtLength(e){return 2*Math.PI*Nt/2**Math.max(e,0)/5}getMinTileElevationForLngLatZoom(e,t){if(!Wg(t,e.wrap()))return 0;let{tileID:i}=this._getOverscaledTileIDFromLngLatZoom(e,t);return this.getMinMaxElevation(i).minElevation??0}getMinMaxElevation(e){let t=this.tileManager.getSourceTile(e,!0),i={minElevation:null,maxElevation:null};return t!=null&&t.dem&&(i.minElevation=t.dem.min*this.exaggeration,i.maxElevation=t.dem.max*this.exaggeration),i}_getOverscaledTileIDFromLngLatZoom(e,t){let i=ye.fromLngLat(e.wrap()),r=(1<<t)*k,a=i.x*r,n=i.y*r,s=Math.floor(a/k),o=Math.floor(n/k);return{tileID:new Pt(t,0,t,s,o),mercatorX:a,mercatorY:n}}_buildSkirts(e,t,i,r,a,n){let s=e.length,o=s+(i+1),l=(i+1)*i,u=a?Hn:0,h=+!a,c=n?Xn:k,d=+!n;for(let m=0;m<=i;m++)e.emplaceBack(m*r,u,h);for(let m=0;m<=i;m++)e.emplaceBack(m*r,c,d);for(let m=0;m<i;m++)t.emplaceBack(l+m,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+(i+1)*2;for(let m of[0,1])for(let g=0;g<=i;g++)for(let _ of[0,1])e.emplaceBack(m*k,g*r,_);for(let m=0;m<i*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 Hy={covered:!1,demLoaded:!1,elevation:0};function Kc(e,t,i,r){if(r<0||r>=1)return Hy;let a=Math.floor(i),n=i-a;for(let s of e.zooms){let o=1<<s,l=n*o,u=r*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)*k,Wy),Math.min((u-c)*k,Wy),k)*t}:{covered:!0,demLoaded:!1,elevation:0}}return Hy}function Xy(e,t){return e.covered&&t<=e.elevation+1e-6}function Yy(e,t,i,r,a){for(let n=0;n<40&&r-i>a;n++){let s=(i+r)/2;t(e,s)?r=s:i=s}return{lo:i,hi:r}}var yl=class $1{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,i,r){this._helper.interpolatePadding(t,i,r)}isPaddingEqual(t){return this._helper.isPaddingEqual(t)}resize(t,i,r=!0){this._helper.resize(t,i,r)}getMaxBounds(){return this._helper.getMaxBounds()}setMaxBounds(t){this._helper.setMaxBounds(t)}setConstrainOverride(t){this._helper.setConstrainOverride(t)}overrideNearFarZ(t,i){this._helper.overrideNearFarZ(t,i)}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){this._posMatrixCache=new Map,this._alignedPosMatrixCache=new Map,this._fogMatrixCacheF32=new Map,this.defaultConstrain=(i,r)=>{r=ee(+r,this.minZoom,this.maxZoom);let a={center:new W(i.lng,i.lat),zoom:r},n=this._helper._lngRange;!this._helper._renderWorldCopies&&n===null&&(n=[-179.9999999999,180-1e-10]);let s=this.tileSize*$t(a.zoom),o=0,l=s,u=0,h=s,c=0,d=0,{x:p,y:f}=this.size;if(this._helper._latRange){let v=this._helper._latRange;o=ja(v[1])*s,l=ja(v[0])*s,l-o<f&&(c=f/(l-o))}n&&(u=ci(Va(n[0])*s,0,s),h=ci(Va(n[1])*s,0,s),h<u&&(h+=s),h-u<p&&(d=p/(h-u)));let{x:m,y:g}=Zi(s,i),_,y,x=Math.max(d||0,c||0);if(x){let v=new C(d?(h+u)/2:m,c?(l+o)/2:g);return a.center=Qn(s,v).wrap(),a.zoom+=Et(x),a}if(this._helper._latRange){let v=f/2;g-v<o&&(y=o+v),g+v>l&&(y=l-v)}if(n){let v=(u+h)/2,w=m;this._helper._renderWorldCopies&&(w=ci(m,v-s/2,v+s/2));let b=p/2;w-b<u&&(_=u+b),w+b>h&&(_=h-b)}if(_!==void 0||y!==void 0){let v=new C(_??m,y??g);a.center=Qn(s,v).wrap()}return a},this.applyConstrain=(i,r)=>this._helper.applyConstrain(i,r),this._helper=new Yc({calcMatrices:()=>this._calcMatrices(),defaultConstrain:(i,r)=>this.defaultConstrain(i,r)},t),this._coveringTilesDetailsProvider=new cM}clone(){let t=new $1;return t.apply(this,!1),t}apply(t,i,r){this._helper.apply(t,i,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 i=[new Qo(0,t)];if(this._helper._renderWorldCopies){let r=this.screenPointToMercatorCoordinate(new C(0,0)),a=this.screenPointToMercatorCoordinate(new C(this._helper._width,0)),n=this.screenPointToMercatorCoordinate(new C(this._helper._width,this._helper._height)),s=this.screenPointToMercatorCoordinate(new C(0,this._helper._height)),o=Math.floor(Math.min(r.x,a.x,n.x,s.x)),l=Math.floor(Math.max(r.x,a.x,n.x,s.x));for(let u=o-1;u<=l+1;u++)u!==0&&i.push(new Qo(u,t))}return i}getCameraFrustum(){return Lc.fromInvProjectionMatrix(this._invViewProjMatrix,this.worldSize)}getClippingPlane(){return null}getCoveringTilesDetailsProvider(){return this._coveringTilesDetailsProvider}recalculateZoomAndCenter(t){let i=this.screenPointToLocation(this.centerPoint,t),r=t?t.getElevationForLngLat(i,this):0;this._helper.recalculateZoomAndCenter(r)}setLocationAtPoint(t,i,r=this.elevation){let a=r-this.elevation,n=this.screenPointToMercatorCoordinateAtZ(i,a),s=this.screenPointToMercatorCoordinateAtZ(this.centerPoint,0),o=ye.fromLngLat(t),l=new ye(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,i){return i?this.coordinatePoint(ye.fromLngLat(t),i.getElevationForLngLat(t,this),this._pixelMatrix3D):this.coordinatePoint(ye.fromLngLat(t))}screenPointToLocation(t,i){var r;return(r=this.screenPointToMercatorCoordinate(t,i))==null?void 0:r.toLngLat()}screenPointToLocationAtElevation(t,i){var r;return(r=this.screenPointToMercatorCoordinateAtZ(t,i-this.elevation))==null?void 0:r.toLngLat()}screenPointToMercatorCoordinate(t,i){if(i){let r=this.screenTerrainPointToMercatorCoordinate(t,i);if(r!=null)return r}return this.screenPointToMercatorCoordinateAtZ(t)}screenTerrainPointToMercatorCoordinate(t,i){let r=i.getCoverageIndex();if(!r)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:r,exaggeration:i.exaggeration,near:a,dx:o,dy:l,dz:u,worldSize:s},c=0,d=1;if(u===0){if(a[2]>r.maxElevation||a[2]<r.minElevation)return null}else{let _=(r.maxElevation-a[2])/u,y=(r.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=ee(Math.ceil(p*(d-c)/4),1,512),m=0,g=!xl(h,0);for(let _=0;_<=f;_++){let y=c+(d-c)*_/f;if(!g)g=!xl(h,y);else if(xl(h,y)){let{lo:x,hi:v}=Yy(h,xl,m,y,.001/p),w=vl(h,x),b=vl(h,v),T=a[2]+x*u-w.elevation,P=a[2]+v*u-b.elevation,S=w.covered&&T>P?ee(x+T*(v-x)/(T-P),x,v):v;return new ye((a[0]+S*o)/s,(a[1]+S*l)/s,vl(h,S).elevation)}m=y}return null}getRaySegmentFromPixel(t){let i=[t.x,t.y,0,1],r=[t.x,t.y,1,1];pt(i,i,this._pixelMatrixInverse),pt(r,r,this._pixelMatrixInverse);let a=i[3],n=r[3],s=this.elevation;return{near:[i[0]/a,i[1]/a,i[2]/a+s],far:[r[0]/n,r[1]/n,r[2]/n+s]}}screenPointToMercatorCoordinateAtZ(t,i){let r=i||0,{near:a,far:n}=this.getRaySegmentFromPixel(t),s=a[2]===n[2]?0:(r+this.elevation-a[2])/(n[2]-a[2]);return new ye(Oe.number(a[0],n[0],s)/this.worldSize,Oe.number(a[1],n[1],s)/this.worldSize,r)}coordinatePoint(t,i=0,r=this._pixelMatrix){let a=[t.x*this.worldSize,t.y*this.worldSize,i,1];return pt(a,a,r),new C(a[0]/a[3],a[1]/a[3])}getBounds(){let t=Math.max(0,this._helper._height/2-es(this));return new Mi().extend(this.screenPointToLocation(new C(0,t))).extend(this.screenPointToLocation(new C(this._helper._width,t))).extend(this.screenPointToLocation(new C(this._helper._width,this._helper._height))).extend(this.screenPointToLocation(new C(0,this._helper._height)))}isPointOnMapSurface(t,i){return i?this.screenTerrainPointToMercatorCoordinate(t,i)!=null:t.y>this.height/2-es(this)}calculatePosMatrix(t,i=!1,r=!1){let a=t.key??qa(t.wrap,t.canonical.z,t.canonical.z,t.canonical.x,t.canonical.y),n=i?this._alignedPosMatrixCache:this._posMatrixCache;if(n.has(a)){let l=n.get(a);return r?l.f32:l.f64}let s=Vh(t,this.worldSize);ba(s,i?this._alignedProjMatrix:this._viewProjMatrix,s);let o={f64:s,f32:new Float32Array(s)};return n.set(a,o),r?o.f32:o.f64}calculateFogMatrix(t){let i=t.key,r=this._fogMatrixCacheF32;if(r.has(i))return r.get(i);let a=Vh(t,this.worldSize);return ba(a,this._fogMatrix,a),r.set(i,new Float32Array(a)),r.get(i)}calculateCenterFromCameraLngLatAlt(t,i,r,a){return this._helper.calculateCenterFromCameraLngLatAlt(t,i,r,a)}calculateCameraOptionsFromTo(t,i,r,a){let n=ye.fromLngLat(t,i),s=ye.fromLngLat(r,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=Et(this.cameraToCenterDistance/h/this.tileSize),p=Li(Math.atan2(o,-l)),f=Li(Math.acos(c/h));return f=u<0?90-f:90+f,{center:s.toLngLat(),elevation:a,zoom:d,pitch:f,bearing:p}}_calculateNearFarZIfNeeded(t,i,r){if(!this._helper.autoCalculateNearFarZ)return;let a=Math.min(this.elevation,this.minElevationForCurrentTile,this.getCameraAltitude()-100),n=t-a*this._helper._pixelPerMeter/Math.cos(i),s=a<0?n:t,o=Math.PI/2+this.pitchInRadians,l=Be(this.fov)*(Math.abs(Math.cos(Be(this.roll)))*this.height+Math.abs(Math.sin(Be(this.roll)))*this.width)/this.height*(.5+r.y/this.height),u=Math.sin(l)*s/Math.sin(ee(Math.PI-o-l,.01,Math.PI-.01)),h=es(this),c=Math.atan(h/this._helper.cameraToCenterDistance),d=Be(90-aa),p=c>d?2*c*(.5+r.y/(h*2)):d,f=Math.sin(p)*s/Math.sin(ee(Math.PI-o-p,.01,Math.PI-.01)),m=Math.min(u,f);this._helper._farZ=(Math.cos(Math.PI/2-i)*m+s)*1.01,this._helper._nearZ=this._helper._height/50}_calcMatrices(){if(!this._helper._height)return;let t=this.centerOffset,i=Zi(this.worldSize,this.center),r=i.x,a=i.y,n=Be(Math.min(this.pitch,aa)),s=Math.max(this._helper.cameraToCenterDistance/2,this._helper.cameraToCenterDistance+this._helper._elevation*this._helper._pixelPerMeter/Math.cos(n));this._calculateNearFarZIfNeeded(s,n,t);let o;o=new Float64Array(16),Zl(o,this.fovInRadians,this._helper._width/this._helper._height,this._helper._nearZ,this._helper._farZ),this._invProjMatrix=new Float64Array(16),FI(this._invProjMatrix,o),o[8]=-t.x*2/this._helper._width,o[9]=t.y*2/this._helper._height,this._projectionMatrix=Gl(o),Tt(o,o,[1,-1,1]),rt(o,o,[0,0,-this._helper.cameraToCenterDistance]),_r(o,o,-this.rollInRadians),wa(o,o,this.pitchInRadians),_r(o,o,-this.bearingInRadians),rt(o,o,[-r,-a,0]),this._mercatorMatrix=Tt([],o,[this.worldSize,this.worldSize,this.worldSize]),Tt(o,o,[1,1,this._helper._pixelPerMeter]),this._pixelMatrix=ba(new Float64Array(16),this.clipSpaceToPixelsMatrix,o),rt(o,o,[0,0,-this.elevation]),this._viewProjMatrix=o,this._invViewProjMatrix=ks([],o);let l=[0,0,-1,1];pt(l,l,this._invViewProjMatrix),this._cameraPosition=[l[0]/l[3],l[1]/l[3],l[2]/l[3]],this._fogMatrix=new Float64Array(16),Zl(this._fogMatrix,this.fovInRadians,this.width/this.height,s,this._helper._farZ),this._fogMatrix[8]=-t.x*2/this.width,this._fogMatrix[9]=t.y*2/this.height,Tt(this._fogMatrix,this._fogMatrix,[1,-1,1]),rt(this._fogMatrix,this._fogMatrix,[0,0,-this.cameraToCenterDistance]),_r(this._fogMatrix,this._fogMatrix,-this.rollInRadians),wa(this._fogMatrix,this._fogMatrix,this.pitchInRadians),_r(this._fogMatrix,this._fogMatrix,-this.bearingInRadians),rt(this._fogMatrix,this._fogMatrix,[-r,-a,0]),Tt(this._fogMatrix,this._fogMatrix,[1,1,this._helper._pixelPerMeter]),rt(this._fogMatrix,this._fogMatrix,[0,0,-this.elevation]),this._pixelMatrix3D=ba(new Float64Array(16),this.clipSpaceToPixelsMatrix,o);let u=this._helper._width%2/2,h=this._helper._height%2/2,c=Math.cos(this.bearingInRadians),d=Math.sin(-this.bearingInRadians),p=r-Math.round(r)+c*u+d*h,f=a-Math.round(a)+c*h+d*u,m=new Float64Array(o);if(rt(m,m,[p>.5?p-1:p,f>.5?f-1:f,0]),this._alignedProjMatrix=m,o=ks(new Float64Array(16),this._pixelMatrix),!o)throw Error("failed to invert matrix");this._pixelMatrixInverse=o,this._clearMatrixCaches()}_clearMatrixCaches(){this._posMatrixCache.clear(),this._alignedPosMatrixCache.clear(),this._fogMatrixCacheF32.clear()}maxPitchScaleFactor(){if(!this._pixelMatrixInverse)return 1;let t=this.screenPointToMercatorCoordinate(new C(0,0)),i=[t.x*this.worldSize,t.y*this.worldSize,0,1];return pt(i,i,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=ra(1,this.center.lat)*this.worldSize,i=this._helper.cameraToCenterDistance/t;return tg(this.center,this.elevation,this.pitch,this.bearing,i).toLngLat()}lngLatToCameraDepth(t,i){let r=ye.fromLngLat(t),a=[r.x*this.worldSize,r.y*this.worldSize,i,1];return pt(a,a,this._viewProjMatrix),a[2]/a[3]}getProjectionData(t){let{overscaledTileID:i,aligned:r,applyTerrainMatrix:a}=t,n=this._helper.getMercatorTileCoordinates(i),s=i?this.calculatePosMatrix(i,r,!0):null,o;return o=i!=null&&i.terrainRttPosMatrix32f&&a?i.terrainRttPosMatrix32f:s||fp(),{mainMatrix:o,tileMercatorCoords:n,clippingPlane:[0,0,0,0],projectionTransition:0,fallbackMatrix:o,clipAntimeridian:!1}}isLocationOccluded(t){return!1}getPixelScale(){return 1}getCircleRadiusCorrection(){return 1}getPitchedTextCorrection(t,i,r){return 1}transformLightDirection(t){return ql(t)}getRayDirectionFromPixel(t){throw Error("Not implemented.")}projectTileCoordinates(t,i,r,a){let n=this.calculatePosMatrix(r),s;a==null?(s=[t,i,0,1],Zc(s,s,n)):(s=[t,i,a,1],pt(s,s,n));let o=s[3];return{point:new C(s[0]/o,s[1]/o),signedDistanceFromCamera:o,isOccluded:!1}}populateCache(t){for(let i of t)this.calculatePosMatrix(i)}getProjectionDataForCustomLayer(t=!0){let i=new Pt(0,0,0,0,0),r=this.getProjectionData({overscaledTileID:i,applyGlobeMatrix:t}),a=Vh(i,this.worldSize);ba(a,this._viewProjMatrix,a);let n=[k,k,this.worldSize/this._helper.pixelsPerMeter],s=Nr();return Tt(s,a,n),{...r,tileMercatorCoords:[0,0,1,1],fallbackMatrix:s,mainMatrix:s}}getFastPathSimpleProjectionMatrix(t){return this.calculatePosMatrix(t)}};function vl(e,t){return Kc(e.index,e.exaggeration,(e.near[0]+t*e.dx)/e.worldSize,(e.near[1]+t*e.dy)/e.worldSize)}function xl(e,t){return Xy(vl(e,t),e.near[2]+t*e.dz)}function Ky(){le("Map cannot fit within canvas with the given bounds, padding, and/or offset.")}function Jy(e){if(e.useSlerp)if(e.k<1){let t=xp(e.startEulerAngles.roll,e.startEulerAngles.pitch,e.startEulerAngles.bearing),i=xp(e.endEulerAngles.roll,e.endEulerAngles.pitch,e.endEulerAngles.bearing),r=new Float64Array(4);$s(r,t,i,e.k);let a=Ox(r);e.tr.setRoll(a.roll),e.tr.setPitch(a.pitch),e.tr.setBearing(a.bearing)}else e.tr.setRoll(e.endEulerAngles.roll),e.tr.setPitch(e.endEulerAngles.pitch),e.tr.setBearing(e.endEulerAngles.bearing);else e.tr.setRoll(Oe.number(e.startEulerAngles.roll,e.endEulerAngles.roll,e.k)),e.tr.setPitch(Oe.number(e.startEulerAngles.pitch,e.endEulerAngles.pitch,e.k)),e.tr.setBearing(Oe.number(e.startEulerAngles.bearing,e.endEulerAngles.bearing,e.k))}function Qy(e,t,i,r,a){let n=a.padding,s=Zi(a.worldSize,i.getNorthWest()),o=Zi(a.worldSize,i.getNorthEast()),l=Zi(a.worldSize,i.getSouthEast()),u=Zi(a.worldSize,i.getSouthWest()),h=Be(-r),c=s.rotate(h),d=o.rotate(h),p=l.rotate(h),f=u.rotate(h),m=new C(Math.max(c.x,d.x,f.x,p.x),Math.max(c.y,d.y,f.y,p.y)),g=new C(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),x=a.height-(n.top+n.bottom+t.top+t.bottom),v=y/_.x,w=x/_.y;if(w<0||v<0){Ky();return}let b=Math.min(Et(a.scale*Math.min(v,w)),e.maxZoom),T=C.convert(e.offset),P=(t.left-t.right)/2,S=(t.top-t.bottom)/2,M=new C(P,S).rotate(Be(r)),F=T.add(M).mult(a.scale/$t(b));return{center:Qn(a.worldSize,s.add(l).div(2).sub(F)),zoom:b,bearing:r}}var bl=class{get useGlobeControls(){return!1}handlePanInertia(e,t){let i=e.mag(),r=Math.abs(es(t));return{easingOffset:e.mult(Math.min(r*.75/i,1)),easingCenter:t.center}}handleMapControlsRollPitchBearingZoom(e,t){e.bearingDelta&&t.setBearing(t.bearing+e.bearingDelta),e.pitchDelta&&t.setPitch(t.pitch+e.pitchDelta),e.rollDelta&&t.setRoll(t.roll+e.rollDelta),e.zoomDelta&&t.setZoom(t.zoom+e.zoomDelta)}handleMapControlsPan(e,t,i){e.around.distSqr(t.centerPoint)<.01||t.setLocationAtPoint(i,e.around,e.aroundElevation)}cameraForBoxAndBearing(e,t,i,r,a){return Qy(e,t,i,r,a)}handleJumpToCenterZoom(e,t){let i=t.zoom===void 0?e.zoom:+t.zoom;e.zoom!==i&&e.setZoom(+t.zoom),t.center!==void 0&&e.setCenter(W.convert(t.center))}handleEaseTo(e,t){let i=e.zoom,r=e.padding,a={roll:e.roll,pitch:e.pitch,bearing:e.bearing},n={roll: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(W.convert(t.center||c),u??i);_l(e,d);let f=Zi(e.worldSize,c),m=Zi(e.worldSize,d).sub(f),g=$t(p-i);return l=p!==i,{easeFunc:_=>{if(l&&e.setZoom(Oe.number(i,p,_)),yp(a,n)||Jy({startEulerAngles:a,endEulerAngles:n,tr:e,k:_,useSlerp:a.roll!=n.roll}),o&&(e.interpolatePadding(r,t.padding,_),h=e.centerPoint.add(t.offsetAsPoint)),t.around)e.setLocationAtPoint(t.around,t.aroundPoint);else{let y=$t(e.zoom-i),x=(p>i?Math.min(2,g):Math.max(.5,g))**(1-_),v=Qn(e.worldSize,f.add(m.mult(_*x)).mult(y));e.setLocationAtPoint(e.renderWorldCopies?v.wrap():v,h)}},isZooming:l,elevationCenter:d}}handleFlyTo(e,t){let i=t.zoom!==void 0,r=e.zoom,a=e.applyConstrain(W.convert(t.center||t.locationAtOffset),i?+t.zoom:r),n=a.center,s=a.zoom;_l(e,n);let o=e.worldSize,l=Zi(o,t.locationAtOffset),u=Zi(o,n).sub(l),h=u.mag(),c=$t(s-r),d=t.minZoom===void 0?e.minZoom:+t.minZoom,p=Math.max(d,e.minZoom),f=Math.min(p,r,s),m=e.applyConstrain(n,f).zoom;return{easeFunc:(g,_,y,x)=>{e.setZoom(g===1?s:r+Et(_));let v=g===1?n:Qn(o,l.add(u.mult(y)));e.setLocationAtPoint(e.renderWorldCopies?v.wrap():v,x)},scaleOfZoom:c,targetCenter:n,scaleOfMinZoom:$t(m-r),pixelPathLength:h}}};let mM;const gM=()=>mM||(mM=new yt({type:new j(z.projection.type,"type")})),Jc=new $h({fill:new nr(128,2),line:new nr(512,0),tile:new nr(128,32),stencil:new nr(128,1),circle:3});var e0=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 Wi.projectionGlobe}get vertexShaderPreludeCode(){return Wi.projectionMercator.vertexSource}get subdivisionGranularity(){return Jc}get useGlobeControls(){return!0}destroy(){}_getMeshKey(e){return`${e.granularity.toString(36)}_${e.generateBorders?"b":""}${e.extendToNorthPole?"n":""}${e.extendToSouthPole?"s":""}`}getMeshFromTileID(e,t,i,r,a){let n=(a==="stencil"?Jc.stencil:Jc.tile).getGranularityForZoomLevel(t.z),s=t.y===0&&r,o=t.y===(1<<t.z)-1&&r;return this._getMesh(e,{granularity:n,generateBorders:i,extendToNorthPole:s,extendToSouthPole:o})}_getMesh(e,t){let i=this._getMeshKey(t);if(i in this._tileMeshCache)return this._tileMeshCache[i];let r=dy(e,t);return this._tileMeshCache[i]=r,r}recalculate(e){}hasTransition(){return!1}},t0=class extends ot{constructor(e,t){super(),this._transitionable=new xo(gM(),"projection",t),this.setProjection(e),this._transitioning=this._transitionable.untransitioned(),this.recalculate(new be(0)),this._mercatorProjection=new Hc,this._verticalPerspectiveProjection=new e0}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 Sr){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,i,r,a){return this.currentProjection.getMeshFromTileID(e,t,i,r,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 i0(e){let t=rn(e.worldSize,e.center.lat);return 2*Math.PI*t}function _M(e,t,i){let r=ht(t),a=ht(i),n=st(r,a),s=Math.acos(n),o=i0(e);return s/(2*Math.PI)*o}function yM(e,t){return[Vr(e*Math.PI*2+Math.PI,Math.PI*2),2*Math.atan(Math.exp(Math.PI-t*Math.PI*2))-Math.PI*.5]}function vM(e,t){let i=Math.cos(t),r=new Float64Array(3);return r[0]=Math.sin(e)*i,r[1]=Math.sin(t),r[2]=Math.cos(e)*i,r}function Mr(e,t,i,r,a){let n=1/(1<<a),s=e/k*n+i*n,o=t/k*n+r*n,l=Vr(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 ht(e){return vM(e.lng*Math.PI/180,e.lat*Math.PI/180)}function rn(e,t){return e/(2*Math.PI)/Math.cos(t*Math.PI/180)}function r0(e){let t=pt(yr(),[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 ps(e){let t=Math.asin(e[1])/Math.PI*180,i=Math.sqrt(e[0]*e[0]+e[2]*e[2]);if(i>1e-6){let r=e[0]/i,a=e[2]/i,n=Math.acos(a),s=(r>0?n:-n)/Math.PI*180;return new W(ci(s,-180,180),t)}return new W(0,t)}function xM(e,t){return Xl(yr(),-e.lng,-e.lat,t)}function bM(e){let t=e[0],i=e[1],r=e[2],a=e[3];return{lng:-Math.atan2(2*(a*t+i*r),1-2*(t*t+i*i))*180/Math.PI,lat:-Math.asin(ee(2*(a*i-r*t),-1,1))*180/Math.PI,bearing:Math.atan2(2*(a*r+t*i),1-2*(i*i+r*r))*180/Math.PI}}const Qc=Math.PI*.98;function a0(e,t){let i=e.cameraPosition,r=Ki(i);if(r<=1)return e.screenPointToLocation(t);let a=xe();Bt(a,i);let n=e.getRayDirectionFromPixel(t),s=-st(n,a),o=xe();Ls(o,n,a,s);let l=Ki(o);if(l<1e-9)return e.screenPointToLocation(t);let u=Math.atan2(l,s),h=Math.asin(1/r)*.9;if(u<h)return e.screenPointToLocation(t);let c=r*Math.sin(h),d=Math.asin(ee(c,-1,1))-h,p=r*Math.cos(h)/Math.sqrt(Math.max(1-c*c,1e-12))-1,f=Qc-d,m=u-h,g=d+p*m*f/(f+p*m),_=xe();ke(_,o,1/l);let y=xe();return ke(y,a,Math.cos(ee(g,0,Qc))),Ls(y,y,_,Math.sin(ee(g,0,Qc))),Bt(y,y),ps(y)}function wM(e,t,i,r,a=!0){let n=a0(e,i),s=t;if(r)s=a0(e,i.sub(r));else if(!e.isPointOnMapSurface(i))return;let o=ht(n),l=ht(s),u=xM(e.center,e.bearing),h=qt(xe(),l,o),c=Math.sqrt(st(h,h)),d=Math.acos(ee(st(l,o),-1,1))/2,p=Math.sin(d),f=c?lp(h[1]/c*p,-h[0]/c*p,h[2]/c*p,Math.cos(d)):lp(0,0,0,1),{lng:m,lat:g,bearing:_}=bM(vx(yr(),u,f)),y=e.center.lat,x=e.zoom,v=ee(g,-90,90),w=a?TM(e,i,r,m):m;e.setCenter(new W(ci(w,-180,180),v)),a||e.setBearing(_),e.setZoom(x+vt(y,e.center.lat))}function TM(e,t,i,r){let a=e.center.lng,n=e.center.lat,s=n>=0?90:-90,o=e.locationToScreenPoint(new W(0,s)),l=t.x-o.x,u=t.y-o.y,h=l*l+u*u,c=ee(1-(Bi-Math.abs(n))/12,0,1),d=c*c*(3-2*c),p=Vr(r-a+180,360)-180,f=0;if(d>0&&i){let m=(l*i.y-u*i.x)/Math.max(h,400);f=(s>0?1:-1)*m*180/Math.PI}return a+(1-d)*p+d*f}function SM(e){let t=xe();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 EM(e,t,i){let r=xe();Ji(r,i,e);let a=xe();return Ls(a,e,r,t/Bs(r)),a}function wl(e){return Math.cos(e*Math.PI/180)}function vt(e,t){let i=wl(e),r=wl(t);return Et(r/i)}function PM(e,t){return 360/i0({worldSize:e,center:{lat:t}})}function CM(e,t){let i=e.rotate(t.bearingInRadians),r=t.zoom+vt(t.center.lat,0),a=Sa(1/wl(t.center.lat),1/wl(Math.min(Math.abs(t.center.lat),60)),js(r,7,3,0,1)),n=PM(t.worldSize,t.center.lat);return new W(t.center.lng-i.x*n*a,ee(t.center.lat+i.y*n,-Bi,Bi))}function ed(e){let t=.5*e,i=Math.sin(t),r=Math.cos(t);return Math.log(i+r)-Math.log(r-i)}function n0(e,t,i,r){let a=e.lat+i*r;if(Math.abs(i)>1){let n=e.lat+i,s=(Math.sign(n)===Math.sign(e.lat)?Math.abs(e.lat):-Math.abs(e.lat))*Math.PI/180,o=Math.abs(e.lat+i)*Math.PI/180,l=ed(s+r*(o-s)),u=ed(s),h=ed(o),c=(l-u)/(h-u),d=e.lng+t*c;return new W(d,a)}{let n=e.lng+t*r;return new W(n,a)}}function Tl(e,t,i=1){let r=st(e,t),a=i*i,n=xe(),s=xe();ke(s,t,r),Ji(n,e,s);let o=a-st(n,n);if(o<0)return null;let l=st(e,e)-a,u=-r+(r<0?1:-1)*Math.sqrt(o),h=l/u,c=u;return{tMin:Math.min(h,c),tMax:Math.max(h,c)}}var AM=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,i,r){let a=`${e.z}_${e.x}_${e.y}_${r!=null&&r.terrain?"t":""}_${Math.round(i)}`,n=this._cache.get(a);if(n)return n;let s=this._cachePrevious.get(a);if(s)return this._cache.set(a,s),s;let o=this._boundingVolumeFactory(e,t,i,r);return this._cache.set(a,o),this._hadAnyChanges=!0,o}},td=class Jd{constructor(t,i,r,a){this.min=r,this.max=a,this.points=t,this.planes=i}static fromAabb(t,i){let r=[];for(let a=0;a<8;a++)r.push([(a>>0&1)==1?i[0]:t[0],(a>>1&1)==1?i[1]:t[1],(a>>2&1)==1?i[2]:t[2]]);return new Jd(r,[[-1,0,0,i[0]],[1,0,0,-t[0]],[0,-1,0,i[1]],[0,1,0,-t[1]],[0,0,-1,i[2]],[0,0,1,-t[2]]],t,i)}static fromCenterSizeAngles(t,i,r){let a=Xl([],r[0],r[1],r[2]),n=Wl([],[i[0],0,0],a),s=Wl([],[0,i[1],0],a),o=Wl([],[0,0,i[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];ui(d,d,ke([],n,(c>>0&1)==1?1:-1)),ui(d,d,ke([],s,(c>>1&1)==1?1:-1)),ui(d,d,ke([],o,(c>>2&1)==1?1:-1)),h.push(d)}return new Jd(h,[[...n,-st(n,h[0])],[...s,-st(s,h[0])],[...o,-st(o,h[0])],[-n[0],-n[1],-n[2],-st(n,h[7])],[-s[0],-s[1],-s[2],-st(s,h[7])],[-o[0],-o[1],-o[2],-st(o,h[7])]],l,u)}intersectsFrustum(t){let i=!0,r=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<r;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<r&&(i=!1)}if(i)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 i=this.points.length,r=0;for(let a=0;a<i;a++){let n=this.points[a];t[0]*n[0]+t[1]*n[1]+t[2]*n[2]+t[3]>=0&&r++}return r===i?2:r===0?0:1}};function Sl(e,t,i){let r=e-t;return r<0?-r:Math.max(0,r-i)}function id(e,t,i,r,a){let n=e-i,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,Sl(t,r,a))}var DM=class{constructor(){this._boundingVolumeCache=new AM(this._computeTileBoundingVolume)}prepareNextFrame(){this._boundingVolumeCache.swapBuffers()}distanceToTile2d(e,t,i,r){let a=1<<i.z,n=1/a,s=i.x/a,o=i.y/a,l=.5,u=2;return u=Math.min(u,id(e,t,s,o,n)),u=Math.min(u,id(e,t,s+l,-o-n,n)),u=Math.min(u,id(e,t,s+l,2-o-n,n)),u}getWrap(e,t,i){let r=1<<t.z,a=1/r,n=t.x/r,s=Sl(e.x,n,a),o=Sl(e.x,n-1,a),l=Sl(e.x,n+1,a),u=Math.min(s,o,l);return u===l?1:u===o?-1:0}allowVariableZoom(e,t){return $c(e,t)>4}allowWorldCopies(){return!1}getTileBoundingVolume(e,t,i,r){return this._boundingVolumeCache.getTileBoundingVolume(e,t,i,r)}_computeTileBoundingVolume(e,t,i,r){let a=Math.min(0,i),n=Math.max(0,i);if(r!=null&&r.terrain){let s=new Pt(e.z,t,e.z,e.x,e.y),o=r.terrain.getMinMaxElevation(s);a=o.minElevation??a,n=Math.max(o.maxElevation??n,n)}if(a/=Nt,n/=Nt,a+=1,n+=1,e.z<=0)return td.fromAabb([-n,-n,-n],[n,n,n]);if(e.z===1)return td.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=[Mr(0,0,e.x,e.y,e.z),Mr(k,0,e.x,e.y,e.z),Mr(k,k,e.x,e.y,e.z),Mr(0,k,e.x,e.y,e.z)],o=[];for(let P of s)o.push(ke([],P,n));if(n!==a)for(let P of s)o.push(ke([],P,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 P of o)for(let S=0;S<3;S++)l[S]=Math.min(l[S],P[S]),u[S]=Math.max(u[S],P[S]);let h=Mr(k/2,k/2,e.x,e.y,e.z),c=qt([],[0,1,0],h);Bt(c,c);let d=qt([],h,c);Bt(d,d);let p=qt([],s[2],s[1]);Bt(p,p);let f=qt([],s[0],s[3]);Bt(f,f),o.push(ke([],h,n)),e.y>=(1<<e.z)/2&&o.push(ke([],Mr(k/2,0,e.x,e.y,e.z),n)),e.y<(1<<e.z)/2&&o.push(ke([],Mr(k/2,k,e.x,e.y,e.z),n));let m=s0(h,o),g=s0(d,o),_=[-h[0],-h[1],-h[2],m.max],y=[h[0],h[1],h[2],-m.min],x=[-d[0],-d[1],-d[2],g.max],v=[d[0],d[1],d[2],-g.min],w=[...p,0],b=[...f,0],T=[];return e.y===0?T.push(hi(b,w,_),hi(b,w,y)):T.push(hi(x,w,_),hi(x,w,y),hi(x,b,_),hi(x,b,y)),e.y===(1<<e.z)-1?T.push(hi(b,w,_),hi(b,w,y)):T.push(hi(v,w,_),hi(v,w,y),hi(v,b,_),hi(v,b,y)),new td(T,[_,y,x,v,w,b],l,u)}}};function s0(e,t){let i=1/0,r=-1/0;for(let a of t){let n=st(e,a);i=Math.min(i,n),r=Math.max(r,n)}return{min:i,max:r}}const o0=1e-12;var l0=class O1{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,i,r){this._helper.interpolatePadding(t,i,r)}isPaddingEqual(t){return this._helper.isPaddingEqual(t)}resize(t,i){this._helper.resize(t,i)}getMaxBounds(){return this._helper.getMaxBounds()}setMaxBounds(t){this._helper.setMaxBounds(t)}setConstrainOverride(t){this._helper.setConstrainOverride(t)}overrideNearFarZ(t,i){this._helper.overrideNearFarZ(t,i)}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){this._cachedClippingPlane=yr(),this._projectionMatrix=Os(),this._globeViewProjMatrix32f=fp(),this._globeViewProjMatrixF64=Os(),this._globeViewProjMatrixF64Inverted=Os(),this._globeProjMatrixInverted=Os(),this._cameraPosition=xe(),this.defaultConstrain=(i,r)=>{let a=ee(i.lat,-Bi,Bi),n=ee(+r,this.minZoom+vt(0,a),this.maxZoom);return{center:new W(i.lng,a),zoom:n}},this.applyConstrain=(i,r)=>this._helper.applyConstrain(i,r),this._helper=new Yc({calcMatrices:()=>this._calcMatrices(),defaultConstrain:(i,r)=>this.defaultConstrain(i,r)},t),this._coveringTilesDetailsProvider=new DM}clone(){let t=new O1;return t.apply(this,!1),t}apply(t,i){this._helper.apply(t,i)}get projectionMatrix(){return this._projectionMatrix}get modelViewProjectionMatrix(){return this._globeViewProjMatrixF64}get inverseProjectionMatrix(){return this._globeProjMatrixInverted}get cameraPosition(){let t=xe();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:i,applyGlobeMatrix:r}=t,a=this._helper.getMercatorTileCoordinates(i);return{mainMatrix:this._globeViewProjMatrix32f,tileMercatorCoords:a,clippingPlane:this._cachedClippingPlane,projectionTransition:+!!r,fallbackMatrix:this._globeViewProjMatrix32f,clipAntimeridian:(i==null?void 0:i.canonical.z)===0}}_computeClippingPlane(t){let i=this.pitchInRadians,r=this.cameraToCenterDistance/t,a=Math.sin(i)*r,n=Math.cos(i)*r+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];Hl(h,h,[0,0,0],-this.bearingInRadians),cn(h,h,[0,0,0],-1*this.center.lat*Math.PI/180),Ta(h,h,[0,0,0],this.center.lng*Math.PI/180);let c=1/Ki(h);return ke(h,h,c),[...h,-s*c]}isLocationOccluded(t){return!this.isSurfacePointVisible(ht(t))}transformLightDirection(t){let i=this._helper._center.lng*Math.PI/180,r=this._helper._center.lat*Math.PI/180,a=Math.cos(r),n=[Math.sin(i)*a,Math.sin(r),Math.cos(i)*a],s=[n[2],0,-n[0]],o=[0,0,0];qt(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,i,r){let a=eg(t,i,r.canonical),n=yM(a.x,a.y);return this.getCircleRadiusCorrection()/Math.cos(n[1])}projectTileCoordinates(t,i,r,a){let n=r.canonical,s=Mr(t,i,n.x,n.y,n.z),o=1+(a??0)/Nt,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 C(c[0]/c[3],c[1]/c[3]),signedDistanceFromCamera:c[3],isOccluded:d}}_isLineOfSightBlocked(t,i,r){let a=this._cameraPosition,n=t-a[0],s=i-a[1],o=r-a[2],l=n*n+s*s+o*o;if(l===0)return!1;let u=ee(-(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(){if(!this._helper._width||!this._helper._height)return;let t=rn(this.worldSize,this.center.lat),i=Nr();this._helper.autoCalculateNearFarZ&&(this._helper._nearZ=.5,this._helper._farZ=this.cameraToCenterDistance+t*2),Zl(i,this.fovInRadians,this.width/this.height,this._helper._nearZ,this._helper._farZ);let r=this.centerOffset;i[8]=-r.x*2/this._helper._width,i[9]=r.y*2/this._helper._height,this._projectionMatrix=Gl(i),this._globeProjMatrixInverted=Nr(),ks(this._globeProjMatrixInverted,i),rt(i,i,[0,0,-this.cameraToCenterDistance]),_r(i,i,this.rollInRadians),wa(i,i,-this.pitchInRadians),_r(i,i,this.bearingInRadians),rt(i,i,[0,0,-t]);let a=xe();a[0]=t,a[1]=t,a[2]=t,wa(i,i,this.center.lat*Math.PI/180),rp(i,i,-this.center.lng*Math.PI/180),Tt(i,i,a),this._globeViewProjMatrixF64=i,this._globeViewProjMatrix32f=new Float32Array(i),this._globeViewProjMatrixF64Inverted=Nr(),ks(this._globeViewProjMatrixF64Inverted,i);let n=xe();this._cameraPosition=xe(),this._cameraPosition[2]=this.cameraToCenterDistance/t,Hl(this._cameraPosition,this._cameraPosition,n,-this.rollInRadians),cn(this._cameraPosition,this._cameraPosition,n,this.pitchInRadians),Hl(this._cameraPosition,this._cameraPosition,n,-this.bearingInRadians),ui(this._cameraPosition,this._cameraPosition,[0,0,1]),cn(this._cameraPosition,this._cameraPosition,n,-this.center.lat*Math.PI/180),Ta(this._cameraPosition,this._cameraPosition,n,this.center.lng*Math.PI/180),this._cachedClippingPlane=this._computeClippingPlane(t);let s=Gl(this._globeViewProjMatrixF64Inverted);Tt(s,s,[1,1,-1]),this._cachedFrustum=Lc.fromInvProjectionMatrix(s,1,0,this._cachedClippingPlane,!0)}calculateFogMatrix(t){le("calculateFogMatrix is not supported on globe projection.");let i=Nr();return Si(i),i}getVisibleUnwrappedCoordinates(t){return[new Qo(0,t)]}getCameraFrustum(){return this._cachedFrustum}getClippingPlane(){return this._cachedClippingPlane}getCoveringTilesDetailsProvider(){return this._coveringTilesDetailsProvider}recalculateZoomAndCenter(t){if(t){le("terrain is not fully supported on vertical perspective projection.");return}this._helper.recalculateZoomAndCenter(0)}maxPitchScaleFactor(){return 1}getCameraPoint(){return this._helper.getCameraPoint()}getCameraAltitude(){return(Ki(this._cameraPosition)-1)*Nt}getCameraLngLat(){let t=xe();return Bt(t,this._cameraPosition),ps(t)}lngLatToCameraDepth(t,i){let r=ht(t);ke(r,r,1+i/Nt);let a=yr();return pt(a,[r[0],r[1],r[2],1],this._globeViewProjMatrixF64),a[2]/a[3]}populateCache(t){}getBounds(){let t=this.width*.5,i=this.height*.5,r=[new C(0,0),new C(t,0),new C(this.width,0),new C(this.width,i),new C(this.width,this.height),new C(t,this.height),new C(0,this.height),new C(0,i)],a=[];for(let c of r)a.push(this.unprojectScreenPoint(c));let n=0,s=0,o=0,l=0,u=this.center;for(let c of a){let d=Jt(u.lng,c.lng),p=Jt(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 Mi(h)}calculateCenterFromCameraLngLatAlt(t,i,r,a){return this._helper.calculateCenterFromCameraLngLatAlt(t,i,r,a)}calculateCameraOptionsFromTo(t,i,r,a){let n=W.convert(r),s=ht(W.convert(t));ke(s,s,1+i/Nt);let o=ht(n),l=ke(xe(),o,1+a/Nt),u=sp(xe(),s,o),h=Ki(u);if(h<o0||ox(s,l)<o0)throw Error("Can't calculate camera options with same From and To");let c=xe();Ta(u,u,c,-Be(n.lng)),cn(u,u,c,Be(n.lat));let d=Li(Math.acos(ee(u[2]/h,-1,1))),p=Math.hypot(u[0],u[1])<h*1e-9?this.bearing:Li(Math.atan2(-u[0],-u[1]));return{center:n,elevation:a,zoom:Et(this.cameraToCenterDistance/h/rn(this.tileSize,n.lat)),pitch:d,bearing:p}}setLocationAtPoint(t,i,r){let a=ht(this.unprojectScreenPoint(i)),n=ht(t),s=xe();cx(s);let o=xe();Ta(o,a,s,-this.center.lng*Math.PI/180),cn(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=xe();Ta(f,n,s,-d);let m=Ns(f[1],f[2],o[1],o[2]),g=xe();Ta(g,n,s,-p);let _=Ns(g[1],g[2],o[1],o[2]),y=Math.PI*.5,x=m>=-y&&m<=y,v=_>=-y&&_<=y,w,b;if(x&&v){let M=this.center.lng*Math.PI/180,F=this.center.lat*Math.PI/180,R=Vs(d,M),I=Vs(m,F),D=Vs(p,M),E=Vs(_,F);R+I<D+E?(w=d,b=m):(w=p,b=_)}else if(x)w=d,b=m;else if(v)w=p,b=_;else return;let T=w/Math.PI*180,P=b/Math.PI*180,S=this.center.lat;this.setCenter(new W(T,ee(P,-90,90))),this.setZoom(this.zoom+vt(S,this.center.lat))}locationToScreenPoint(t,i){let r=ht(t);if(i){let a=i.getElevationForLngLatZoom(t,this._helper._tileZoom);ke(r,r,1+a/Nt)}return this._projectSurfacePointToScreen(r)}_projectSurfacePointToScreen(t){let i=yr();return pt(i,[...t,1],this._globeViewProjMatrixF64),i[0]/=i[3],i[1]/=i[3],new C((i[0]*.5+.5)*this.width,(-i[1]*.5+.5)*this.height)}screenPointToMercatorCoordinate(t,i){if(i){let r=this.screenTerrainPointToMercatorCoordinate(t,i);if(r)return r}return ye.fromLngLat(this.unprojectScreenPoint(t))}screenTerrainPointToMercatorCoordinate(t,i){let r=i.getCoverageIndex();if(!r)return null;let a=this.cameraPosition,n=this.getRayDirectionFromPixel(t),s=Tl(a,n,1+r.maxElevation/Nt);if(!s)return null;let o=Tl(a,n,1+r.minElevation/Nt),l=Math.max(s.tMin,0),u=o?o.tMin:s.tMax;if(u<=l)return null;let h={index:r,exaggeration:i.exaggeration,origin:a,direction:n},c=0;for(let d=0;d<=256;d++){let p=l+(u-l)*d/256;if(h0(h,p)){let{hi:f}=Yy(h,h0,c,p,1e-12),{sample:m,mercator:g}=u0(h,f);return new ye(g.x,g.y,m.elevation)}c=p}return null}screenPointToLocation(t,i){var r;return(r=this.screenPointToMercatorCoordinate(t,i))==null?void 0:r.toLngLat()}screenPointToLocationAtElevation(t,i){return this.screenPointToLocation(t)}isPointOnMapSurface(t,i){let r=this._cameraPosition;return!!Tl(r,this.getRayDirectionFromPixel(t))}getRayDirectionFromPixel(t){let i=yr();i[0]=t.x/this.width*2-1,i[1]=(t.y/this.height*2-1)*-1,i[2]=1,i[3]=1,pt(i,i,this._globeViewProjMatrixF64Inverted),i[0]/=i[3],i[1]/=i[3],i[2]/=i[3];let r=xe();r[0]=i[0]-this._cameraPosition[0],r[1]=i[1]-this._cameraPosition[1],r[2]=i[2]-this._cameraPosition[2];let a=xe();return Bt(a,r),a}isSurfacePointVisible(t){let i=this._cachedClippingPlane;return i[0]*t[0]+i[1]*t[1]+i[2]*t[2]+i[3]>=0}isSurfacePointOnScreen(t){if(!this.isSurfacePointVisible(t))return!1;let i=yr();return pt(i,[...t,1],this._globeViewProjMatrixF64),i[0]/=i[3],i[1]/=i[3],i[2]/=i[3],i[0]>-1&&i[0]<1&&i[1]>-1&&i[1]<1&&i[2]>-1&&i[2]<1}unprojectScreenPoint(t){let i=this._cameraPosition,r=this.getRayDirectionFromPixel(t),a=Tl(i,r);if(a){let h=xe();ui(h,i,[r[0]*a.tMin,r[1]*a.tMin,r[2]*a.tMin]);let c=xe();return Bt(c,h),ps(c)}let n=this._cachedClippingPlane,s=n[0]*r[0]+n[1]*r[1]+n[2]*r[2],o=-Kl(n,i)/s,l=xe();if(o>0)ui(l,i,[r[0]*o,r[1]*o,r[2]*o]);else{let h=xe();ui(h,i,[r[0]*2,r[1]*2,r[2]*2]);let c=Kl(this._cachedClippingPlane,h);Ji(l,h,[this._cachedClippingPlane[0]*c,this._cachedClippingPlane[1]*c,this._cachedClippingPlane[2]*c])}let u=SM(n);return ps(EM(u.center,u.radius,l))}getProjectionDataForCustomLayer(t=!0){let i=this.getProjectionData({overscaledTileID:new Pt(0,0,0,0,0),applyGlobeMatrix:t});return i.tileMercatorCoords=[0,0,1,1],i}getFastPathSimpleProjectionMatrix(t){}};function u0(e,t){let i=xe();Ls(i,e.origin,e.direction,t);let r=Ki(i),a=xe();ke(a,i,1/r);let n=ps(a),s=ye.fromLngLat(n),o=new ye(s.x,ee(s.y,0,.999999999)),l=Kc(e.index,e.exaggeration,o.x,o.y),u=Math.abs(n.lat)>85.051129?0:l.elevation;return{sample:{...l,elevation:u},radius:r,mercator:o}}function h0(e,t){let{sample:i,radius:r}=u0(e,t);return Xy(i,(r-1)*Nt)}var c0=class N1{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,i,r){this._helper.interpolatePadding(t,i,r)}isPaddingEqual(t){return this._helper.isPaddingEqual(t)}resize(t,i,r=!0){this._helper.resize(t,i,r)}getMaxBounds(){return this._helper.getMaxBounds()}setMaxBounds(t){this._helper.setMaxBounds(t)}setConstrainOverride(t){this._helper.setConstrainOverride(t)}overrideNearFarZ(t,i){this._helper.overrideNearFarZ(t,i)}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=(i,r)=>this.currentTransform.defaultConstrain(i,r),this.applyConstrain=(i,r)=>this._helper.applyConstrain(i,r),this._helper=new Yc({calcMatrices:()=>this._calcMatrices(),defaultConstrain:(i,r)=>this.defaultConstrain(i,r)},t),this._globeness=1,this._mercatorTransform=new yl,this._verticalPerspectiveTransform=new l0}clone(){let t=new N1;return t._globeness=this._globeness,t.apply(this,!1),t}apply(t,i){this._helper.apply(t,i),this._mercatorTransform.apply(this,!1),this._verticalPerspectiveTransform.apply(this,!1)}get projectionMatrix(){return this.currentTransform.projectionMatrix}get modelViewProjectionMatrix(){return this.currentTransform.modelViewProjectionMatrix}get inverseProjectionMatrix(){return this.currentTransform.inverseProjectionMatrix}get cameraPosition(){return this.currentTransform.cameraPosition}getProjectionData(t){let i=this._mercatorTransform.getProjectionData(t),r=this._verticalPerspectiveTransform.getProjectionData(t);return{mainMatrix:this.isGlobeRendering?r.mainMatrix:i.mainMatrix,clippingPlane:r.clippingPlane,tileMercatorCoords:r.tileMercatorCoords,projectionTransition:t.applyGlobeMatrix?this._globeness:0,fallbackMatrix:i.fallbackMatrix,clipAntimeridian:r.clipAntimeridian}}isLocationOccluded(t){return this.currentTransform.isLocationOccluded(t)}transformLightDirection(t){return this.currentTransform.transformLightDirection(t)}getPixelScale(){return Sa(this._mercatorTransform.getPixelScale(),this._verticalPerspectiveTransform.getPixelScale(),this._globeness)}getCircleRadiusCorrection(){return Sa(this._mercatorTransform.getCircleRadiusCorrection(),this._verticalPerspectiveTransform.getCircleRadiusCorrection(),this._globeness)}getPitchedTextCorrection(t,i,r){let a=this._mercatorTransform.getPitchedTextCorrection(t,i,r),n=this._verticalPerspectiveTransform.getPitchedTextCorrection(t,i,r);return Sa(a,n,this._globeness)}projectTileCoordinates(t,i,r,a){return this.currentTransform.projectTileCoordinates(t,i,r,a)}_calcMatrices(){this._helper._width&&this._helper._height&&(this._verticalPerspectiveTransform.apply(this,!1),this._helper._nearZ=this._verticalPerspectiveTransform.nearZ,this._helper._farZ=this._verticalPerspectiveTransform.farZ,this._mercatorTransform.apply(this,!0,this.isGlobeRendering),this._helper._nearZ=this._mercatorTransform.nearZ,this._helper._farZ=this._mercatorTransform.farZ)}calculateFogMatrix(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()}lngLatToCameraDepth(t,i){return this.currentTransform.lngLatToCameraDepth(t,i)}populateCache(t){this._mercatorTransform.populateCache(t),this._verticalPerspectiveTransform.populateCache(t)}getBounds(){return this.currentTransform.getBounds()}calculateCenterFromCameraLngLatAlt(t,i,r,a){return this._helper.calculateCenterFromCameraLngLatAlt(t,i,r,a)}calculateCameraOptionsFromTo(t,i,r,a){return this.currentTransform.calculateCameraOptionsFromTo(t,i,r,a)}setLocationAtPoint(t,i,r){if(!this.isGlobeRendering){this._mercatorTransform.setLocationAtPoint(t,i,r),this.apply(this._mercatorTransform,!1);return}this._verticalPerspectiveTransform.setLocationAtPoint(t,i,r),this.apply(this._verticalPerspectiveTransform,!1)}locationToScreenPoint(t,i){return this.currentTransform.locationToScreenPoint(t,i)}screenPointToMercatorCoordinate(t,i){return this.currentTransform.screenPointToMercatorCoordinate(t,i)}screenTerrainPointToMercatorCoordinate(t,i){return this.currentTransform.screenTerrainPointToMercatorCoordinate(t,i)}screenPointToLocation(t,i){return this.currentTransform.screenPointToLocation(t,i)}screenPointToLocationAtElevation(t,i){return this.currentTransform.screenPointToLocationAtElevation(t,i)}isPointOnMapSurface(t,i){return this.currentTransform.isPointOnMapSurface(t,i)}getRayDirectionFromPixel(t){return this._verticalPerspectiveTransform.getRayDirectionFromPixel(t)}getProjectionDataForCustomLayer(t=!0){let i=this._mercatorTransform.getProjectionDataForCustomLayer(t);if(!this.isGlobeRendering)return i;let r=this._verticalPerspectiveTransform.getProjectionDataForCustomLayer(t);return r.fallbackMatrix=i.mainMatrix,r.projectionTransition=this._globeness,r}getFastPathSimpleProjectionMatrix(t){return this.currentTransform.getFastPathSimpleProjectionMatrix(t)}},d0=class fr{get useGlobeControls(){return!0}handlePanInertia(t,i){let r=CM(t,i);return Math.abs(r.lng-i.center.lng)>180&&(r.lng=i.center.lng+179.5*Math.sign(r.lng-i.center.lng)),{easingCenter:r,easingOffset:new C(0,0)}}handleMapControlsRollPitchBearingZoom(t,i){let r=t.around,a=i.screenPointToLocation(r);t.bearingDelta&&i.setBearing(i.bearing+t.bearingDelta),t.pitchDelta&&i.setPitch(i.pitch+t.pitchDelta),t.rollDelta&&i.setRoll(i.roll+t.rollDelta);let n=i.zoom;t.zoomDelta&&i.setZoom(i.zoom+t.zoomDelta);let s=i.zoom-n;if(s===0)return;let o=Jt(i.center.lng,a.lng),l=o/(Math.abs(o/180)+1),u=Jt(i.center.lat,a.lat),h=i.getRayDirectionFromPixel(r),c=i.cameraPosition,d=st(c,h)*-1,p=xe();ui(p,c,[h[0]*d,h[1]*d,h[2]*d]);let f=Ki(p),m=f-1,g=Math.exp(-Math.max(m-.3,0)*.5),_=js(f,.95,.999,0,1),y=rn(i.worldSize,i.center.lat)/Math.min(i.width,i.height),x=js(y,.9,.5,1,.25),v=Math.min(g,Sa(1,x,_)),w=(1-$t(-s))*v,b=i.center.lat,T=i.zoom,P=new W(i.center.lng+l*w,ee(i.center.lat+u*w,-Bi,Bi));i.setLocationAtPoint(a,r);let S=i.center,M=js(Math.abs(o),45,85,0,1),F=Math.max(M,_)**.25,R=Jt(S.lng,P.lng),I=Jt(S.lat,P.lat);i.setCenter(new W(S.lng+R*F,S.lat+I*F).wrap()),i.setZoom(T+vt(b,i.center.lat))}handleMapControlsPan(t,i,r){t.panDelta&&wM(i,r,i.isPointOnMapSurface(t.around)?t.around:i.centerPoint,t.panDelta)}cameraForBoxAndBearing(t,i,r,a,n){let s=Qy(t,i,r,a,n),o=i.left/n.width*2-1,l=(n.width-i.right)/n.width*2-1,u=i.top/n.height*-2+1,h=(n.height-i.bottom)/n.height*-2+1,c=Jt(r.getWest(),r.getEast())<0,d=c?r.getEast():r.getWest(),p=c?r.getWest():r.getEast(),f=Math.max(r.getNorth(),r.getSouth()),m=Math.min(r.getNorth(),r.getSouth()),g=d+Jt(d,p)*.5,_=f+Jt(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 x=y.modelViewProjectionMatrix,v=[ht(r.getNorthWest()),ht(r.getNorthEast()),ht(r.getSouthWest()),ht(r.getSouthEast()),ht(new W(p,_)),ht(new W(d,_)),ht(new W(g,f)),ht(new W(g,m))],w=ht(s.center),b=1/0;for(let T of v)o<0&&(b=fr.getLesserNonNegativeNonNull(b,fr.solveVectorScale(T,w,x,"x",o))),l>0&&(b=fr.getLesserNonNegativeNonNull(b,fr.solveVectorScale(T,w,x,"x",l))),u>0&&(b=fr.getLesserNonNegativeNonNull(b,fr.solveVectorScale(T,w,x,"y",u))),h<0&&(b=fr.getLesserNonNegativeNonNull(b,fr.solveVectorScale(T,w,x,"y",h)));if(!Number.isFinite(b)||b===0){Ky();return}return s.zoom=Math.min(y.zoom+Et(b),t.maxZoom),s}handleJumpToCenterZoom(t,i){let r=t.center.lat,a=t.applyConstrain(i.center?W.convert(i.center):t.center,t.zoom).center;t.setCenter(a.wrap());let n=i.zoom===void 0?t.zoom+vt(r,a.lat):+i.zoom;t.zoom!==n&&t.setZoom(n)}handleEaseTo(t,i){let r=t.zoom,a=t.center,n=t.padding,s={roll:t.roll,pitch:t.pitch,bearing:t.bearing},o={roll:i.roll===void 0?t.roll:i.roll,pitch:i.pitch===void 0?t.pitch:i.pitch,bearing:i.bearing===void 0?t.bearing:i.bearing},l=i.zoom!==void 0,u=!t.isPaddingEqual(i.padding),h=!1,c=i.center?W.convert(i.center):a,d=t.applyConstrain(c,r).center;_l(t,d);let p=t.clone();p.setCenter(d),p.setZoom(l?+i.zoom:r+vt(a.lat,c.lat)),p.setBearing(i.bearing);let f=new C(ee(t.centerPoint.x+i.offsetAsPoint.x,0,t.width),ee(t.centerPoint.y+i.offsetAsPoint.y,0,t.height));p.setLocationAtPoint(d,f);let m=(i.offset&&i.offsetAsPoint.mag())>0?p.center:d,g=l?+i.zoom:r+vt(a.lat,m.lat),_=r+vt(a.lat,0),y=g+vt(m.lat,0),x=Jt(a.lng,m.lng),v=Jt(a.lat,m.lat),w=$t(y-_);return h=g!==r,{easeFunc:b=>{if(yp(s,o)||Jy({startEulerAngles:s,endEulerAngles:o,tr:t,k:b,useSlerp:s.roll!=o.roll}),u&&t.interpolatePadding(n,i.padding,b),i.around)le("Easing around a point is not supported under globe projection."),t.setLocationAtPoint(i.around,i.aroundPoint);else{let T=b*(y>_?Math.min(2,w):Math.max(.5,w))**(1-b),P=n0(a,x,v,T);t.setCenter(P.wrap())}if(h){let T=Oe.number(_,y,b)+vt(0,t.center.lat);t.setZoom(T)}},isZooming:h,elevationCenter:m}}handleFlyTo(t,i){let r=i.zoom!==void 0,a=t.center,n=t.zoom,s=t.padding,o=!t.isPaddingEqual(i.padding),l=t.applyConstrain(W.convert(i.center||i.locationAtOffset),n).center,u=r?+i.zoom:t.zoom+vt(t.center.lat,l.lat),h=t.clone();h.setCenter(l),h.setZoom(u),h.setBearing(i.bearing);let c=new C(ee(t.centerPoint.x+i.offsetAsPoint.x,0,t.width),ee(t.centerPoint.y+i.offsetAsPoint.y,0,t.height));h.setLocationAtPoint(l,c);let d=h.center;_l(t,d);let p=_M(t,a,d),f=n+vt(a.lat,0),m=u+vt(d.lat,0),g=$t(m-f),_=typeof i.minZoom=="number"?+i.minZoom:t.minZoom,y=Math.max(_,t.minZoom)+vt(d.lat,0),x=Math.min(y,f,m)+vt(0,d.lat),v=t.applyConstrain(d,x).zoom+vt(d.lat,0),w=$t(v-f),b=Jt(a.lng,d.lng),T=Jt(a.lat,d.lat);return{easeFunc:(P,S,M,F)=>{let R=n0(a,b,T,M);o&&t.interpolatePadding(s,i.padding,P);let I=P===1?d:R;t.setCenter(I.wrap());let D=f+Et(S);t.setZoom(P===1?u:D+vt(0,I.lat))},scaleOfZoom:g,targetCenter:d,scaleOfMinZoom:w,pixelPathLength:p}}static solveVectorScale(t,i,r,a,n){let s=n,o=a==="x"?[r[0],r[4],r[8],r[12]]:[r[1],r[5],r[9],r[13]],l=[r[3],r[7],r[11],r[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=i[0]*o[0]+i[1]*o[1]+i[2]*o[2],d=i[0]*l[0]+i[1]*l[1]+i[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,i){return i!==null&&i>=0&&i<t?i:t}},p0=class{constructor(e){this._globe=e,this._mercatorCameraHelper=new bl,this._verticalPerspectiveCameraHelper=new d0}get useGlobeControls(){return this._globe.useGlobeRendering}get currentHelper(){return this.useGlobeControls?this._verticalPerspectiveCameraHelper:this._mercatorCameraHelper}handlePanInertia(e,t){return this.currentHelper.handlePanInertia(e,t)}handleMapControlsRollPitchBearingZoom(e,t){this.currentHelper.handleMapControlsRollPitchBearingZoom(e,t)}handleMapControlsPan(e,t,i){this.currentHelper.handleMapControlsPan(e,t,i)}cameraForBoxAndBearing(e,t,i,r,a){return this.currentHelper.cameraForBoxAndBearing(e,t,i,r,a)}handleJumpToCenterZoom(e,t){this.currentHelper.handleJumpToCenterZoom(e,t)}handleEaseTo(e,t){return this.currentHelper.handleEaseTo(e,t)}handleFlyTo(e,t){return this.currentHelper.handleFlyTo(e,t)}};function IM(e,t,i){let r={constrainOverride:t};if(Array.isArray(e)){let a=new t0({type:e},i);return{projection:a,transform:new c0(r),cameraHelper:new p0(a)}}switch(e){case"mercator":return{projection:new Hc,transform:new yl(r),cameraHelper:new bl};case"globe":{let a=new t0({type:["interpolate",["linear"],["zoom"],11,"vertical-perspective",12,"mercator"]},{});return{projection:a,transform:new c0(r),cameraHelper:new p0(a)}}case"vertical-perspective":return{projection:new e0,transform:new l0(r),cameraHelper:new d0};default:return le(`Unknown projection name: ${e}. Falling back to mercator projection.`),{projection:new Hc,transform:new yl(r),cameraHelper:new bl}}}const MM=dD();var rd=class extends ot{constructor(e,t={}){var r,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 ty(Ic(),e._getMapId()),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 mD,this.imageManager.setEventedParent(this),this.imageManager.setMissingImageResolver(e._missingStyleImageResolver),this.patternAtlas=new gD(this.imageManager);let i=((r=e._container)==null?void 0:r.lang)||typeof document<"u"&&((a=document.documentElement)==null?void 0:a.lang)||void 0;this.glyphManager=new ED(e._requestManager,t.localIdeographFontFamily,i),this.lineAtlas=new zD(256,512),this.crossTileSymbolIndex=new jy,this._setInitialValues(),this._resetUpdates(),this.dispatcher.broadcast("SR",nu()),ls().on(Rc,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 Gu,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 r,a;this._checkLoaded();let i=t===null?((a=(r=this.stylesheet.state)==null?void 0:r[e])==null?void 0:a.default)??null:t;if(ki(i,this._globalState[e]))return this;this._globalState[e]=i,this._applyGlobalStateChanges([e])}getGlobalState(){return this._globalState}setGlobalState(e){this._checkLoaded();let t=[];for(let i in e)ki(this._globalState[i],e[i].default)||(t.push(i),this._globalState[i]=e[i].default);this._applyGlobalStateChanges(t)}_applyGlobalStateChanges(e){if(e.length===0)return;let t=new Set,i={};for(let r of e){i[r]=this._globalState[r];for(let a in this._layers){let n=this._layers[a],s=n.getLayoutAffectingGlobalStateRefs(),o=n.getPaintAffectingGlobalStateRefs(),l=n.getVisibilityAffectingGlobalStateRefs();if(s.has(r)&&t.add(n.source),o.has(r))for(let{name:u,value:h}of o.get(r))this._updatePaintProperty(n,u,h);l!=null&&l.has(r)&&(n.recalculateVisibility(),this._updateLayer(n))}}this.dispatcher.broadcast("UGS",i);for(let r in this.tileManagers)t.has(r)&&(this._reloadSource(r),this._changed=!0)}async loadURL(e,t={},i){this.fire(new vi("dataloading")),t.validate=typeof t.validate!="boolean"||t.validate,this._loadStyleRequest=new AbortController;let r=this._loadStyleRequest;try{let a=await this.map._requestManager.transformRequest(e,"Style");ru(r.signal);let n=await Gs(a,r);this._loadStyleRequest===r&&(this._loadStyleRequest=null),this._load(n.data,t,i)}catch(a){this._loadStyleRequest===r&&(this._loadStyleRequest=null),a&&!r.signal.aborted&&this.fire(new K(St(a)))}}loadJSON(e,t={},i){this.fire(new vi("dataloading")),this._frameRequest=new AbortController,jt.frameAsync(this._frameRequest,this.map._ownerWindow).then(()=>{this._frameRequest=null,t.validate=t.validate!==!1,this._load(e,t,i)}).catch(()=>{})}loadEmpty(){this.fire(new vi("dataloading")),this._load(MM,{validate:!1})}_load(e,t,i){var a;let r=t.transformStyle?t.transformStyle(i,e):e;if(!(t.validate&&Zf(this,r))){r={...r},this._loaded=!0,this.stylesheet=r;for(let n in r.sources)this.addSource(n,r.sources[n],{validate:!1});r.sprite?this._loadSprite(r.sprite):this.imageManager.setLoaded(!0),this.glyphManager.setURL(r.glyphs),this.glyphManager.setFontFaces(r["font-faces"]),this._createLayers(),this.light=new AD(this.stylesheet.light??{},this._globalState),this._setProjectionInternal(((a=this.stylesheet.projection)==null?void 0:a.type)||"mercator"),this.sky=new MD(this.stylesheet.sky,this._globalState),this.map.setTerrain(this.stylesheet.terrain??null,{validate:!1}),this.fire(new vi("data")),this.fire(new Tc)}}_createLayers(){var t;let e=q_(this.stylesheet.layers);this.setGlobalState(this.stylesheet.state??null),this.dispatcher.broadcast("SL",e),this._order=e.map(i=>i.id),this._layers={},this._serializedLayers=null;for(let i of e){let r=Qh(i,this._globalState);if(r.setEventedParent(this,{layer:{id:i.id}}),this._layers[i.id]=r,Ku(r)&&this.tileManagers[r.source]){let a=((t=i.paint)==null?void 0:t["raster-fade-duration"])??r.paint.get("raster-fade-duration");this.tileManagers[r.source].setRasterFadeDuration(a)}}}async _loadSprite(e,t=!1,i=void 0){this.imageManager.setLoaded(!1);let r=new AbortController;this._spriteRequest=r;let a;try{let n=await pD(e,this.map._requestManager,this.map.getPixelRatio(),r);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,r.signal.aborted||this.fire(new K(a))}finally{this._spriteRequest=null,this.imageManager.setLoaded(!0),t&&(this._changed=!0),this.dispatcher.broadcast("SI",this.imageManager.listImages()),this.fire(new vi("data")),i==null||i(a)}}_unloadSprite(){this._markImagesChanged(this.imageManager.removeAllSpriteImages()),this._imagesListDirty=!0,this._changed=!0,this.fire(new vi("data"))}_validateLayer(e){let t=this.tileManagers[e.source];if(!t)return;let i=e.sourceLayer;if(!i)return;let r=t.getSource();(r.type==="geojson"||r.vectorLayerIds&&!r.vectorLayerIds.includes(i))&&this.fire(new K(Error(`Source layer "${i}" does not exist on source "${r.id}" as specified by style layer "${e.id}".`)))}loaded(){if(!this._loaded||Object.keys(this._updatedSources).length)return!1;for(let e in this.tileManagers)if(!this.tileManagers[e].loaded())return!1;return this.imageManager.isLoaded()}_serializeByIds(e,t=!1){let i=this._serializedAllLayers();if(!e||e.length===0)return Object.values(t?Wt(i):i);let r=[];for(let a of e)if(i[a]){let n=t?Wt(i[a]):i[a];r.push(n)}return r}_serializedAllLayers(){let e=this._serializedLayers;if(e)return e;e=this._serializedLayers={};let t=Object.keys(this._layers);for(let i of t){let r=this._layers[i];r.type!=="custom"&&(e[i]=r.serialize())}return e}hasTransitions(){var e,t,i;if((e=this.light)!=null&&e.hasTransition()||(t=this.sky)!=null&&t.hasTransition()||(i=this.projection)!=null&&i.hasTransition())return!0;for(let r in this.tileManagers)if(this.tileManagers[r].hasTransition())return!0;for(let r in this._layers)if(this._layers[r].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.light.updateTransitions(e),this.sky.updateTransitions(e),this._resetUpdates()}let i={};for(let a in this.tileManagers){let n=this.tileManagers[a];i[a]=n.used,n.used=!1}let r=this.imageManager.listImages();for(let a of this._order){let n=this._layers[a];n.recalculate(e,r),!n.isHidden(e.zoom)&&n.source&&(this.tileManagers[n.source].used=!0)}for(let a in i){let n=this.tileManagers[a];!!i[a]!=!!n.used&&n.fire(new Re("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 vi("data"))}_updateTilesForChangedImages(){let e=Object.keys(this._changedImages);if(e.length){for(let t in this.tileManagers)this.tileManagers[t].reloadTilesForDependencies(["icons","patterns"],e);this._changedImages={}}}_updateTilesForChangedGlyphs(){if(this._glyphsDidChange){for(let e in this.tileManagers)this.tileManagers[e].reloadTilesForDependencies(["glyphs"],[""]);this._glyphsDidChange=!1}}_updateWorkerLayers(e,t){this.dispatcher.broadcast("UL",{layers:this._serializeByIds(e,!1),removedIds:t})}_resetUpdates(){this._changed=!1,this._updatedLayers={},this._removedLayers={},this._updatedSources={},this._updatedPaintProps={},this._changedImages={},this._glyphsDidChange=!1}setState(e,t={}){this._checkLoaded();let i=this.serialize();if(e=t.transformStyle?t.transformStyle(i,e):e,(t.validate??!0)&&Zf(this,e))return!1;e=Wt(e),e.layers=q_(e.layers);let r=cD(i,e),a=this._getOperationsToPerform(r);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 Tc({style:this})),!0}_getOperationsToPerform(e){let t=[],i=[];for(let r of e)switch(r.command){case"setCenter":case"setZoom":case"setBearing":case"setPitch":case"setRoll":continue;case"addLayer":t.push(()=>this.addLayer.apply(this,r.args));break;case"removeLayer":t.push(()=>this.removeLayer.apply(this,r.args));break;case"setPaintProperty":t.push(()=>this.setPaintProperty.apply(this,r.args));break;case"setLayoutProperty":t.push(()=>this.setLayoutProperty.apply(this,r.args));break;case"setFilter":t.push(()=>this.setFilter.apply(this,r.args));break;case"addSource":t.push(()=>this.addSource.apply(this,r.args));break;case"removeSource":t.push(()=>this.removeSource.apply(this,r.args));break;case"setLayerZoomRange":t.push(()=>this.setLayerZoomRange.apply(this,r.args));break;case"setLight":t.push(()=>this.setLight.apply(this,r.args));break;case"setGeoJSONSourceData":t.push(()=>this.setGeoJSONSourceData.apply(this,r.args));break;case"setGlyphs":t.push(()=>this.setGlyphs.apply(this,r.args));break;case"setFontFaces":t.push(()=>this.setFontFaces.apply(this,r.args));break;case"setSprite":t.push(()=>this.setSprite.apply(this,r.args));break;case"setTerrain":t.push(()=>this.map.setTerrain.apply(this,r.args));break;case"setSky":t.push(()=>this.setSky.apply(this,r.args));break;case"setProjection":this.setProjection.apply(this,r.args);break;case"setGlobalState":t.push(()=>this.setGlobalState.apply(this,r.args));break;case"setTransition":t.push(()=>{});break;default:i.push(r.command)}return{operations:t,unimplemented:i}}addImage(e,t){if(this.getImage(e)){this.fire(new K(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 K(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 vi("data"))}listImages(){return this._checkLoaded(),this.imageManager.listImages()}addSource(e,t,i={}){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(Gf.has(t.type)&&this._validate(Ht.source,`sources.${e}`,t,null,i))return;(a=this.map)!=null&&a._collectResourceTiming&&(t.collectResourceTiming=!0);let r=this.tileManagers[e]=new Oc(e,t,this.dispatcher);r.style=this,r.setEventedParent(this,()=>({isSourceLoaded:r.loaded(),source:r.serialize(),sourceId:e})),r.onAdd(this.map),this._changed=!0}removeSource(e){if(this._checkLoaded(),this.tileManagers[e]===void 0)throw Error(`There is no source with this ID=${e}`);for(let i in this._layers)if(this._layers[i].source===e)return this.fire(new K(Error(`Source "${e}" cannot be removed while layer "${i}" is using it.`)));let t=this.tileManagers[e];delete this.tileManagers[e],delete this._updatedSources[e],t.fire(new Re("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 i=this.tileManagers[e].getSource();if(i.type!=="geojson")throw Error(`geojsonSource.type is ${i.type}, which is !== 'geojson`);i.setData(t),this._changed=!0}getSource(e){var t;return(t=this.tileManagers[e])==null?void 0:t.getSource()}addLayer(e,t,i={}){this._checkLoaded();let r=e.id;if(this.getLayer(r)){this.fire(new K(Error(`Layer "${r}" already exists on this map.`)));return}let a;if(e.type==="custom"){if(Vu(this,aP(e)))return;a=Qh(e,this._globalState)}else{if("source"in e&&typeof e.source=="object"&&(this.addSource(r,e.source),e=Wt(e),e=Z(e,{source:r})),this._validate(Ht.layer,`layers.${r}`,e,{arrayIndex:-1},i))return;a=Qh(e,this._globalState),this._validateLayer(a),a.setEventedParent(this,{layer:{id:r}})}let n=t?this._order.indexOf(t):this._order.length;if(t&&n===-1){this.fire(new K(Error(`Cannot add layer "${r}" before non-existing layer "${t}".`)));return}if(this._order.splice(n,0,r),this._layerOrderChanged=!0,this._layers[r]=a,this._removedLayers[r]&&a.source&&a.type!=="custom"){let s=this._removedLayers[r];delete this._removedLayers[r],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 K(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 K(Error(`Cannot move layer "${e}" before non-existing layer "${t}".`)));return}let i=this._order.indexOf(e);this._order.splice(i,1);let r=t?this._order.indexOf(t):this._order.length;this._order.splice(r,0,e),this._layerOrderChanged=!0}removeLayer(e){var r;this._checkLoaded();let t=this._layers[e];if(!t){this.fire(new K(Error(`Cannot remove non-existing layer "${e}".`)));return}t.setEventedParent(null);let i=this._order.indexOf(e);this._order.splice(i,1),this._layerOrderChanged=!0,this._changed=!0,this._removedLayers[e]=t,delete this._layers[e],this._serializedLayers&&delete this._serializedLayers[e],delete this._updatedLayers[e],delete this._updatedPaintProps[e],t.type==="symbol"&&t.source&&((r=this.tileManagers[t.source])==null||r.resetMaxContentElevation()),t.onRemove&&t.onRemove(this.map)}getLayer(e){return this._layers[e]}getLayersOrder(){return[...this._order]}hasLayer(e){return e in this._layers}setLayerZoomRange(e,t,i){this._checkLoaded();let r=this.getLayer(e);if(!r){this.fire(new K(Error(`Cannot set the zoom range of non-existing layer "${e}".`)));return}(r.minzoom!==t||r.maxzoom!==i)&&(t!=null&&(r.minzoom=t),i!=null&&(r.maxzoom=i),this._updateLayer(r))}setFilter(e,t,i={}){this._checkLoaded();let r=this.getLayer(e);if(!r){this.fire(new K(Error(`Cannot filter non-existing layer "${e}".`)));return}if(!ki(r.filter,t)){if(t==null){r.setFilter(void 0),this._updateLayer(r);return}this._validate(Ht.filter,`layers.${r.id}.filter`,t,null,i)||(r.setFilter(Wt(t)),this._updateLayer(r))}}getFilter(e){return Wt(this.getLayer(e).filter)}setLayoutProperty(e,t,i,r={}){this._checkLoaded();let a=this.getLayer(e);if(!a){this.fire(new K(Error(`Cannot style non-existing layer "${e}".`)));return}ki(a.getLayoutProperty(t),i)||(a.setLayoutProperty(t,i,r),this._updateLayer(a))}getLayoutProperty(e,t){let i=this.getLayer(e);if(!i){this.fire(new K(Error(`Cannot get style of non-existing layer "${e}".`)));return}return i.getLayoutProperty(t)}setPaintProperty(e,t,i,r={}){this._checkLoaded();let a=this.getLayer(e);if(!a){this.fire(new K(Error(`Cannot style non-existing layer "${e}".`)));return}ki(a.getPaintProperty(t),i)||this._updatePaintProperty(a,t,i,r)}_updatePaintProperty(e,t,i,r={}){e.setPaintProperty(t,i,r)&&this._updateLayer(e),Ku(e)&&t==="raster-fade-duration"&&this.tileManagers[e.source].setRasterFadeDuration(i),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 i=e.source,r=e.sourceLayer,a=this.tileManagers[i];if(a===void 0){this.fire(new K(Error(`The source '${i}' does not exist in the map's style.`)));return}let n=a.getSource().type;if(n==="geojson"&&r){this.fire(new K(Error("GeoJSON sources cannot have a sourceLayer parameter.")));return}if(n==="vector"&&!r){this.fire(new K(Error("The sourceLayer parameter must be provided for vector source types.")));return}if(e.id===void 0){this.fire(new K(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 K(Error(`The feature state should not include one of the following keys: ${s}`)));return}a.setFeatureState(r,e.id,t)}removeFeatureState(e,t){this._checkLoaded();let i=e.source,r=this.tileManagers[i];if(r===void 0){this.fire(new K(Error(`The source '${i}' does not exist in the map's style.`)));return}let a=r.getSource().type,n=a==="vector"?e.sourceLayer:void 0;if(a==="vector"&&!n){this.fire(new K(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 K(Error("A feature id is required to remove its specific state property.")));return}r.removeFeatureState(n,e.id,t)}getFeatureState(e){this._checkLoaded();let t=e.source,i=e.sourceLayer,r=this.tileManagers[t];if(r===void 0){this.fire(new K(Error(`The source '${t}' does not exist in the map's style.`)));return}if(r.getSource().type==="vector"&&!i){this.fire(new K(Error("The sourceLayer parameter must be provided for vector source types.")));return}return e.id===void 0&&this.fire(new K(Error("The feature id parameter must be provided."))),r.getFeatureState(i,e.id)}getTransition(){var e;return Z({duration:300,delay:0},(e=this.stylesheet)==null?void 0:e.transition)}serialize(){if(!this._loaded)return;let e=eu(this.tileManagers,a=>a.serialize()),t=this._serializeByIds(this._order,!0),i=this.map.getTerrain()||void 0,r=this.stylesheet;return gp({version:r.version,name:r.name,metadata:r.metadata,light:r.light,sky:r.sky,center:r.center,zoom:r.zoom,bearing:r.bearing,pitch:r.pitch,sprite:r.sprite,glyphs:r.glyphs,"font-faces":r["font-faces"],transition:r.transition,projection:r.projection,state:r.state,sources:e,layers:t,terrain:i},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",i={},r=[];for(let n=this._order.length-1;n>=0;n--){let s=this._order[n];if(t(s)){i[s]=n;for(let o of e){let l=o[s];if(l)for(let u of l)r.push(u)}}}r.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=r.length-1;o>=0;o--){let l=r[o].feature;if(i[l.layer.id]<n)break;a.push(l),r.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,i){t!=null&&t.filter&&this._validate(Ht.filter,"queryRenderedFeatures.filter",t.filter,null,t);let r={};if(t!=null&&t.layers){if(!(Array.isArray(t.layers)||t.layers instanceof Set))return this.fire(new K(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 K(Error(`The layer '${l}' does not exist in the map's style and cannot be queried for features.`))),[];r[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||r[l])&&a.push(UD(this.tileManagers[l],this._layers,n,e,o,i,this.map.terrain?(u,h,c)=>this.map.terrain.getElevation(u,h,c):void 0));return this.placement&&a.push(GD(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(Ht.filter,"querySourceFeatures.filter",t.filter,null,t);let i=this.tileManagers[e];return i?ZD(i,t?{...t,globalState:this._globalState}:{globalState:this._globalState}):[]}getLight(){return this.light.getLight()}setLight(e,t={}){this._checkLoaded();let i=this.light.getLight(),r=!1;for(let n in e)if(!ki(e[n],i[n])){r=!0;break}if(!r)return;let a={now:Te(),transition:Z({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 i=this.getSky(),r=!1;if(!e&&!i)return;if(e&&!i)r=!0;else if(!e&&i)r=!0;else for(let n in e)if(!ki(e[n],i[n])){r=!0;break}if(!r)return;let a={now:Te(),transition:Z({duration:300,delay:0},this.stylesheet.transition)};this.stylesheet.sky=e,this.sky.setSky(e,t),this.sky.updateTransitions(a)}_setProjectionInternal(e){var i;let t=IM(e,(i=this.map._camera)==null?void 0:i.transform.constrainOverride,this._globalState);this.projection=t.projection,this.map.migrateProjection(t.transform,t.cameraHelper);for(let r in this.tileManagers)this.tileManagers[r].reload()}_validate(e,t,i,r,a={}){return a.validate!==!1&&zn(this,e,{key:t,style:this.serialize(),value:i,...r},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)),ls().off(Rc,this._rtlPluginLoaded);for(let t in this._layers)this._layers[t].setEventedParent(null);for(let t in this.tileManagers){let i=this.tileManagers[t];i.setEventedParent(null),i.onRemove(this.map)}this.imageManager.setEventedParent(null),this.setEventedParent(null),e&&this.dispatcher.broadcast("RM",void 0),this.dispatcher.remove(e)}_clearSource(e){this.tileManagers[e].clearTiles()}_reloadSource(e){this.tileManagers[e].resume(),this.tileManagers[e].reload()}_updateSources(e){for(let t in this.tileManagers)this.tileManagers[t].update(e,this.map.terrain)}_generateCollisionBoxes(){for(let e in this.tileManagers)this._reloadSource(e)}triggerSymbolPlacement(){this._symbolPlacementTriggered=!0}_placementInputsChanged(e,t,i){var a;let r=this.pauseablePlacement;return!r||this._symbolPlacementTriggered||this._placedProjectionTransition!==((a=this.projection)==null?void 0:a.transitionState)||r._showCollisionBoxes!==t||r.placement.collisionGroups.crossSourceCollisions!==i||r.placement.transform.renderWorldCopies!==e.renderWorldCopies||!nx(r.placement.transform.modelViewProjectionMatrix,e.modelViewProjectionMatrix)}_updatePlacement(e,t,i,r,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||i===0);let l=n||this._placementInputsChanged(e,t,r),u=((h=this.pauseablePlacement)==null?void 0:h.isDone())&&!this.placement.stillRecent(Te(),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 JI(e,this.map.terrain,this._order,a,t,i,r,this.placement),this._layerOrderChanged=!1),this.pauseablePlacement.isDone()?l&&this.placement.setStale():(this.pauseablePlacement.continuePlacement(this._order,this._layers,o),this.pauseablePlacement.isDone()&&(this.placement=this.pauseablePlacement.commit(Te()),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(Te())}_releaseSymbolFadeTiles(){for(let e in this.tileManagers)this.tileManagers[e].releaseSymbolFadeTiles()}async getImages(e,t){let i=await this.imageManager.getImages(t.icons);this._updateTilesForChangedImages();let r=this.tileManagers[t.source];return r&&r.setDependencies(t.tileID.key,t.type,t.icons),i}async getGlyphs(e,t){let i=await this.glyphManager.getGlyphs(t.stacks),r=this.tileManagers[t.source];return r&&r.setDependencies(t.tileID.key,t.type,[""]),i}getGlyphsUrl(){return this.stylesheet.glyphs||null}setGlyphs(e,t={}){this._checkLoaded(),!(e&&this._validate(Ht.glyphs,"glyphs",e,null,t))&&(this._changed=!0,this._glyphsDidChange=!0,this.stylesheet.glyphs=e,this.glyphManager.entries={},this.glyphManager.setURL(e))}getFontFaces(){return this.stylesheet["font-faces"]||null}setFontFaces(e){this._checkLoaded(),this._changed=!0,this._glyphsDidChange=!0,this.stylesheet["font-faces"]=e,this.glyphManager.setFontFaces(e)}async getDashes(e,t){let i={};for(let[r,a]of Object.entries(t.dashes))i[r]=this.lineAtlas.getDash(a.dasharray,a.round);return i}addSprite(e,t,i={},r){this._checkLoaded();let a=[{id:e,url:t}],n=[...ol(this.stylesheet.sprite),...a];this._validate(Ht.sprite,"sprite",n,null,i)||(this.stylesheet.sprite=n,this._loadSprite(a,!0,r))}removeSprite(e){this._checkLoaded();let t=ol(this.stylesheet.sprite);if(!t.find(r=>r.id===e)){this.fire(new K(Error(`Sprite "${e}" doesn't exists on this map.`)));return}let i=this.imageManager.removeSpriteImages(e);this._markImagesChanged(i),t.splice(t.findIndex(r=>r.id===e),1),this.stylesheet.sprite=t.length>0?t:void 0,this._imagesListDirty=!0,this._changed=!0,this.fire(new vi("data"))}getSprite(){return ol(this.stylesheet.sprite)}setSprite(e,t={},i){this._checkLoaded(),!(e&&this._validate(Ht.sprite,"sprite",e,null,t))&&(this.stylesheet.sprite=e,e?this._loadSprite(e,!0,i):(this._unloadSprite(),i&&i(null)))}destroy(){this._frameRequest&&(this._frameRequest=(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 zM=We([{name:"a_pos",type:"Int16",components:2},{name:"a_texture_pos",type:"Int16",components:2}]);var FM=class{constructor(){this.boundProgram=null,this.boundLayoutVertexBuffer=null,this.boundPaintVertexBuffers=[],this.boundIndexBuffer=null,this.boundVertexOffset=null,this.boundDynamicVertexBuffer=null,this.vao=null}bind(e,t,i,r,a,n,s,o,l){this.context=e;let u=this.boundPaintVertexBuffers.length!==r.length;for(let h=0;!u&&h<r.length;h++)this.boundPaintVertexBuffers[h]!==r[h]&&(u=!0);!this.vao||this.boundProgram!==t||this.boundLayoutVertexBuffer!==i||u||this.boundIndexBuffer!==a||this.boundVertexOffset!==n||this.boundDynamicVertexBuffer!==s||this.boundDynamicVertexBuffer2!==o||this.boundDynamicVertexBuffer3!==l?this.freshBind(t,i,r,a,n,s,o,l):(e.bindVertexArray.set(this.vao),s&&s.bind(),a!=null&&a.dynamicDraw&&a.bind(),o&&o.bind(),l&&l.bind())}freshBind(e,t,i,r,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=i,this.boundIndexBuffer=r,this.boundVertexOffset=a,this.boundDynamicVertexBuffer=n,this.boundDynamicVertexBuffer2=s,this.boundDynamicVertexBuffer3=o,t.enableAttributes(h,e);for(let c of i)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 i)c.bind(),c.setVertexAttribPointers(h,e,a);n&&(n.bind(),n.setVertexAttribPointers(h,e,a)),r&&r.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 RM=(e,t)=>({u_depth:new X(e,t.u_depth),u_terrain:new X(e,t.u_terrain)}),kM=(e,t)=>({u_texture:new X(e,t.u_texture),u_ele_delta:new G(e,t.u_ele_delta),u_fog_matrix:new Ci(e,t.u_fog_matrix),u_fog_color:new Cr(e,t.u_fog_color),u_fog_ground_blend:new G(e,t.u_fog_ground_blend),u_fog_ground_blend_opacity:new G(e,t.u_fog_ground_blend_opacity),u_horizon_color:new Cr(e,t.u_horizon_color),u_horizon_fog_blend:new G(e,t.u_horizon_fog_blend),u_is_globe_mode:new G(e,t.u_is_globe_mode)}),LM=(e,t)=>({u_ele_delta:new G(e,t.u_ele_delta)}),BM=(e,t,i,r,a)=>({u_texture:0,u_ele_delta:e,u_fog_matrix:t,u_fog_color:i?i.properties.get("fog-color"):te.white,u_fog_ground_blend:i?i.properties.get("fog-ground-blend"):1,u_fog_ground_blend_opacity:a?0:i?i.calculateFogBlendOpacity(r):0,u_horizon_color:i?i.properties.get("horizon-color"):te.white,u_horizon_fog_blend:i?i.properties.get("horizon-fog-blend"):1,u_is_globe_mode:+!!a}),$M=e=>({u_ele_delta:e}),El={ProjectionUBO:0,TerrainUBO:1,FrameUBO:2};function OM(e,t){for(let[i,r]of Object.entries(El)){let a=e.getUniformBlockIndex(t,i);a!==e.INVALID_INDEX&&e.uniformBlockBinding(t,a,r)}}const NM={float:[1,1],int:[1,1],vec2:[2,2],vec4:[4,4],mat4:[16,4]};function ad(e){let t={},i=0;for(let{name:r,type:a}of e){let[n,s]=NM[a];i=Math.ceil(i/s)*s,t[r]=i,i+=n}return{offsets:t,contentWords:i,sizeWords:Math.ceil(i/4)*4}}var nd=class{constructor(e,t,i){this.context=e,this.binding=t,this.contentWords=i.contentWords;let r=e.gl;this.buffer=r.createBuffer(),r.bindBuffer(r.UNIFORM_BUFFER,this.buffer),r.bufferData(r.UNIFORM_BUFFER,i.sizeWords*4,r.DYNAMIC_DRAW),r.bindBufferBase(r.UNIFORM_BUFFER,t,this.buffer),this.uploaded=new Float32Array(i.sizeWords),this.pending=new Float32Array(i.sizeWords),this.uploadedWords=new Uint32Array(this.uploaded.buffer),this.pendingWords=new Uint32Array(this.pending.buffer),this.hasData=!1,this.bindingDirty=!1}upload(){let e=this.context.gl,t=!this.hasData;if(!t){let i=this.pendingWords,r=this.uploadedWords;for(let a=0;a<this.contentWords;a++)if(i[a]!==r[a]){t=!0;break}}this.bindingDirty&&(this.bindingDirty=(e.bindBufferBase(e.UNIFORM_BUFFER,this.binding,this.buffer),!1)),t&&(e.bindBuffer(e.UNIFORM_BUFFER,this.buffer),e.bufferSubData(e.UNIFORM_BUFFER,0,this.pending),this.uploaded.set(this.pending),this.hasData=!0)}destroy(){let e=this.context.gl;this.buffer&&(e.deleteBuffer(this.buffer),delete this.buffer)}};const f0=ad([{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"}]),an=f0.offsets;function VM(e){return new nd(e,El.ProjectionUBO,f0)}function jM(e,t){let i=e.pending;i.set(t.mainMatrix,an.u_projection_matrix),i.set(t.fallbackMatrix,an.u_projection_fallback_matrix),i.set(t.tileMercatorCoords,an.u_projection_tile_mercator_coords),i.set(t.clippingPlane,an.u_projection_clipping_plane),i[an.u_projection_transition]=t.projectionTransition,e.pendingWords[an.u_projection_clip_antimeridian]=+!!t.clipAntimeridian,e.upload()}const m0=ad([{name:"u_terrain_matrix",type:"mat4"},{name:"u_terrain_unpack",type:"vec4"},{name:"u_terrain_dim",type:"float"},{name:"u_terrain_exaggeration",type:"float"}]),Pl=m0.offsets;function UM(e){return new nd(e,El.TerrainUBO,m0)}function GM(e,t){let i=e.pending;i.set(t.u_terrain_matrix,Pl.u_terrain_matrix),i.set(t.u_terrain_unpack,Pl.u_terrain_unpack),i[Pl.u_terrain_dim]=t.u_terrain_dim,i[Pl.u_terrain_exaggeration]=t.u_terrain_exaggeration,e.upload()}function sd(e){let t=[];for(let i of e){if(i===null)continue;let r=i.split(" ");t.push(r.pop())}return t}function ZM(e,t){let i=new Set([e.INT,e.INT_VEC2,e.INT_VEC3,e.INT_VEC4,e.UNSIGNED_INT,e.UNSIGNED_INT_VEC2,e.UNSIGNED_INT_VEC3,e.UNSIGNED_INT_VEC4]),r=new Set,a=e.getProgramParameter(t,e.ACTIVE_ATTRIBUTES);for(let n=0;n<a;n++){let s=e.getActiveAttrib(t,n);s&&i.has(s.type)&&r.add(s.name)}return r}var qM=class{constructor(e,t,i,r,a,n,s,o,l=[]){let u=e.gl;this.program=u.createProgram();let h=sd(t.staticAttributes),c=i?i.getBinderAttributes():[],d=h.concat(c),p=Wi.prelude.staticUniforms?sd(Wi.prelude.staticUniforms):[],f=t.staticUniforms?sd(t.staticUniforms):[],m=i?i.getBinderUniforms():[],g=p.concat(f).concat(m),_=[];for(let S of g)_.includes(S)||_.push(S);let y=i?i.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 x=y.concat(Wi.prelude.fragmentSource,s.fragmentSource,t.fragmentSource).join(`
|
|
820
|
+
`),v=y.concat(Wi.prelude.vertexSource,s.vertexSource,t.vertexSource).join(`
|
|
821
|
+
`),w=u.createShader(u.FRAGMENT_SHADER);if(u.isContextLost()){this.failedToCreate=!0;return}u.shaderSource(w,x),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,v),u.compileShader(b),u.attachShader(this.program,b),this.attributes={};let T={};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)}`)}OM(u,this.program);let P=ZM(u,this.program);for(let S of d){if(!S)continue;let M=u.getAttribLocation(this.program,S);M>=0&&(this.attributes[S]={location:M,isInteger:P.has(S)})}u.deleteShader(b),u.deleteShader(w);for(let S of _)if(S&&!T[S]){let M=u.getUniformLocation(this.program,S);M&&(T[S]=M)}this.fixedUniforms=r(e,T),this.terrainUniforms=RM(e,T),this.binderUniforms=i?i.getUniforms(e,T):[]}draw(e,t,i,r,a,n,s,o,l,u,h,c,d,p,f,m,g,_,y){var w;let x=e.gl;if(this.failedToCreate)return;if(e.program.set(this.program),e.setDepthMode(i),e.setStencilMode(r),e.setColorMode(a),e.setCullFace(n),o){e.activeTexture.set(x.TEXTURE2),x.bindTexture(x.TEXTURE_2D,o.depthTexture),e.activeTexture.set(x.TEXTURE3),x.bindTexture(x.TEXTURE_2D,o.texture);for(let b in this.terrainUniforms)this.terrainUniforms[b].set(o[b]);GM(e.terrainUniformBuffer,o)}if(l&&jM(e.projectionUniformBuffer,l),s)for(let b in this.fixedUniforms)this.fixedUniforms[b].set(s[b]);m&&m.setUniforms(e,this.binderUniforms,p,{zoom:f});let v=0;switch(t){case x.LINES:v=2;break;case x.TRIANGLES:v=3;break;case x.LINE_STRIP:v=1}for(let b of d.get())b.vaos||(b.vaos={}),(w=b.vaos)[u]||(w[u]=new FM),b.vaos[u].bind(e,this,h,m?m.getPaintVertexBuffers():[],c,b.vertexOffset,g,_,y),x.drawElements(t,b.primitiveLength*v,x.UNSIGNED_SHORT,b.primitiveOffset*v*2)}};function g0(e,t,i){let r=1/Kt(i,1,t.transform.tileZoom),a=2**i.tileID.overscaledZ,n=i.tileSize*2**t.transform.tileZoom/a,s=n*(i.tileID.canonical.x+i.tileID.wrap*a),o=n*i.tileID.canonical.y;return{u_image:0,u_texsize:i.imageAtlasTexture.size,u_scale:[r,e.fromScale,e.toScale],u_fade:e.t,u_pixel_coord_upper:[s>>16,o>>16],u_pixel_coord_lower:[s&65535,o&65535]}}function WM(e,t,i,r){let a=i.patternAtlas.getPattern(e.from.toString()),n=i.patternAtlas.getPattern(e.to.toString()),{width:s,height:o}=i.patternAtlas.getPixelSize(),l=2**r.tileID.overscaledZ,u=r.tileSize*2**i.transform.tileZoom/l,h=u*(r.tileID.canonical.x+r.tileID.wrap*l),c=u*r.tileID.canonical.y;return{u_image:0,u_pattern_tl_a:a.tl,u_pattern_br_a:a.br,u_pattern_tl_b:n.tl,u_pattern_br_b:n.br,u_texsize:[s,o],u_mix:t.t,u_pattern_size_a:a.displaySize,u_pattern_size_b:n.displaySize,u_scale_a:t.fromScale,u_scale_b:t.toScale,u_tile_units_to_pixels:1/Kt(r,1,i.transform.tileZoom),u_pixel_coord_upper:[h>>16,c>>16],u_pixel_coord_lower:[h&65535,c&65535]}}const HM=(e,t)=>({u_lightpos:new Ot(e,t.u_lightpos),u_lightpos_globe:new Ot(e,t.u_lightpos_globe),u_lightintensity:new G(e,t.u_lightintensity),u_lightcolor:new Ot(e,t.u_lightcolor),u_vertical_gradient:new G(e,t.u_vertical_gradient),u_opacity:new G(e,t.u_opacity),u_fill_translate:new se(e,t.u_fill_translate)}),XM=(e,t)=>({u_lightpos:new Ot(e,t.u_lightpos),u_lightpos_globe:new Ot(e,t.u_lightpos_globe),u_lightintensity:new G(e,t.u_lightintensity),u_lightcolor:new Ot(e,t.u_lightcolor),u_vertical_gradient:new G(e,t.u_vertical_gradient),u_height_factor:new G(e,t.u_height_factor),u_opacity:new G(e,t.u_opacity),u_fill_translate:new se(e,t.u_fill_translate),u_image:new X(e,t.u_image),u_texsize:new se(e,t.u_texsize),u_pixel_coord_upper:new se(e,t.u_pixel_coord_upper),u_pixel_coord_lower:new se(e,t.u_pixel_coord_lower),u_scale:new Ot(e,t.u_scale),u_fade:new G(e,t.u_fade)}),_0=(e,t,i,r)=>{let a=e.style.light,n=a.getCartesianPosition(),s=ip();a.properties.get("anchor")==="viewport"&&Q1(s,e.transform.bearingInRadians),hx(n,n,s);let o=e.transform.transformLightDirection(n),l=a.properties.get("color");return{u_lightpos:n,u_lightpos_globe:o,u_lightintensity:a.properties.get("intensity"),u_lightcolor:[l.r,l.g,l.b],u_vertical_gradient:+t,u_opacity:i,u_fill_translate:r}},YM=(e,t,i,r,a,n,s)=>Z(_0(e,t,i,r),g0(n,e,s),{u_height_factor:-(2**a.overscaledZ)/s.tileSize/8}),KM=(e,t)=>({u_fill_translate:new se(e,t.u_fill_translate)}),JM=(e,t)=>({u_image:new X(e,t.u_image),u_texsize:new se(e,t.u_texsize),u_pixel_coord_upper:new se(e,t.u_pixel_coord_upper),u_pixel_coord_lower:new se(e,t.u_pixel_coord_lower),u_scale:new Ot(e,t.u_scale),u_fade:new G(e,t.u_fade),u_sdf_pattern:new X(e,t.u_sdf_pattern),u_fill_translate:new se(e,t.u_fill_translate)}),QM=(e,t)=>({u_fill_translate:new se(e,t.u_fill_translate)}),e3=(e,t)=>({u_image:new X(e,t.u_image),u_texsize:new se(e,t.u_texsize),u_pixel_coord_upper:new se(e,t.u_pixel_coord_upper),u_pixel_coord_lower:new se(e,t.u_pixel_coord_lower),u_scale:new Ot(e,t.u_scale),u_fade:new G(e,t.u_fade),u_sdf_pattern:new X(e,t.u_sdf_pattern),u_fill_translate:new se(e,t.u_fill_translate)}),y0=(e,t,i,r,a)=>Z(g0(t,e,i),{u_fill_translate:r,u_sdf_pattern:+!!a}),t3=e=>({u_fill_translate:e}),i3=e=>({u_fill_translate:e}),r3=(e,t,i,r,a)=>y0(e,t,i,r,a),a3=(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 se(e,t.u_extrude_scale),u_globe_extrude_scale:new G(e,t.u_globe_extrude_scale),u_translate:new se(e,t.u_translate)}),n3=(e,t,i,r,a)=>{let n=e.transform,s,o,l=0;if(i.paint.get("circle-pitch-alignment")==="map"){let u=Kt(t,1,n.zoom);s=!0,o=[u,u],l=u/(k*2**t.tileID.overscaledZ)*2*Math.PI*a}else s=!1,o=n.pixelsToGLUnits;return{u_scale_with_map:+(i.paint.get("circle-pitch-scale")==="map"),u_pitch_with_map:+s,u_extrude_scale:o,u_globe_extrude_scale:l,u_translate:r}},s3=(e,t)=>({u_color:new Cr(e,t.u_color),u_overlay:new X(e,t.u_overlay),u_overlay_scale:new G(e,t.u_overlay_scale)}),v0=(e,t=1)=>({u_color:e,u_overlay:0,u_overlay_scale:t}),o3=(e,t)=>({u_extrude_scale:new G(e,t.u_extrude_scale),u_intensity:new G(e,t.u_intensity),u_globe_extrude_scale:new G(e,t.u_globe_extrude_scale)}),l3=(e,t)=>({u_matrix:new Ci(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 G(e,t.u_opacity)}),x0=(e,t,i,r)=>{let a=Kt(e,1,t)/(k*2**e.tileID.overscaledZ)*2*Math.PI*r;return{u_extrude_scale:Kt(e,1,t),u_intensity:i,u_globe_extrude_scale:a}},b0=(e,t,i,r)=>{let a=gr();return Ri(a,0,e.width,e.height,0,0,1),{u_matrix:a,u_image:i,u_color_ramp:r,u_opacity:t.paint.get("heatmap-opacity")}},u3=(e,t)=>({u_image:new X(e,t.u_image),u_latrange:new se(e,t.u_latrange),u_exaggeration:new G(e,t.u_exaggeration),u_altitudes:new Tm(e,t.u_altitudes),u_azimuths:new Tm(e,t.u_azimuths),u_accent:new Cr(e,t.u_accent),u_method:new X(e,t.u_method),u_shadows:new wm(e,t.u_shadows),u_highlights:new wm(e,t.u_highlights)}),h3=(e,t)=>({u_matrix:new Ci(e,t.u_matrix),u_image:new X(e,t.u_image),u_dimension:new se(e,t.u_dimension),u_zoom:new G(e,t.u_zoom),u_unpack:new On(e,t.u_unpack)}),c3=(e,t,i)=>{let r=i.paint.get("hillshade-accent-color"),a;switch(i.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=i.getIlluminationProperties();for(let s=0;s<n.directionRadians.length;s++)i.paint.get("hillshade-illumination-anchor")==="viewport"&&(n.directionRadians[s]+=e.transform.bearingInRadians);return{u_image:0,u_latrange:p3(e,t.tileID),u_exaggeration:i.paint.get("hillshade-exaggeration"),u_altitudes:n.altitudeRadians,u_azimuths:n.directionRadians,u_accent:r,u_method:a,u_highlights:n.highlightColor,u_shadows:n.shadowColor}},d3=(e,t)=>{let i=t.stride,r=gr();return Ri(r,0,k,-k,0,0,1),rt(r,r,[0,-k,0]),{u_matrix:r,u_image:1,u_dimension:[i,i],u_zoom:e.overscaledZ,u_unpack:t.getUnpackVector()}};function p3(e,t){let i=2**t.canonical.z,r=t.canonical.y;return[new ye(0,r/i).toLngLat().lat,new ye(0,(r+1)/i).toLngLat().lat]}const f3=(e,t)=>({u_image:new X(e,t.u_image),u_unpack:new On(e,t.u_unpack),u_dimension:new se(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 G(e,t.u_opacity)}),m3=(e,t,i=0)=>({u_image:0,u_unpack:t.getUnpackVector(),u_dimension:[t.stride,t.stride],u_elevation_stops:1,u_color_stops:4,u_color_ramp_size:i,u_opacity:e.paint.get("color-relief-opacity")}),g3=(e,t)=>({u_translation:new se(e,t.u_translation),u_ratio:new G(e,t.u_ratio)}),_3=(e,t)=>({u_translation:new se(e,t.u_translation),u_ratio:new G(e,t.u_ratio),u_image:new X(e,t.u_image),u_image_height:new G(e,t.u_image_height)}),y3=(e,t)=>({u_translation:new se(e,t.u_translation),u_texsize:new se(e,t.u_texsize),u_ratio:new G(e,t.u_ratio),u_image:new X(e,t.u_image),u_scale:new Ot(e,t.u_scale),u_fade:new G(e,t.u_fade)}),v3=(e,t)=>({u_translation:new se(e,t.u_translation),u_ratio:new G(e,t.u_ratio),u_image:new X(e,t.u_image),u_mix:new G(e,t.u_mix),u_tileratio:new G(e,t.u_tileratio),u_crossfade_from:new G(e,t.u_crossfade_from),u_crossfade_to:new G(e,t.u_crossfade_to),u_lineatlas_width:new G(e,t.u_lineatlas_width),u_lineatlas_height:new G(e,t.u_lineatlas_height)}),x3=(e,t)=>({u_translation:new se(e,t.u_translation),u_ratio:new G(e,t.u_ratio),u_image:new X(e,t.u_image),u_image_height:new G(e,t.u_image_height),u_tileratio:new G(e,t.u_tileratio),u_crossfade_from:new G(e,t.u_crossfade_from),u_crossfade_to:new G(e,t.u_crossfade_to),u_image_dash:new X(e,t.u_image_dash),u_mix:new G(e,t.u_mix),u_lineatlas_width:new G(e,t.u_lineatlas_width),u_lineatlas_height:new G(e,t.u_lineatlas_height)}),Cl=(e,t,i,r)=>{let a=e.transform;return{u_translation:w0(e,t,i),u_ratio:r/Kt(t,1,a.zoom)}},b3=(e,t,i,r,a)=>Z(Cl(e,t,i,r),{u_image:0,u_image_height:a}),w3=(e,t,i,r,a)=>{let n=e.transform,s=od(t,n);return{u_translation:w0(e,t,i),u_texsize:t.imageAtlasTexture.size,u_ratio:r/Kt(t,1,n.zoom),u_image:0,u_scale:[s,a.fromScale,a.toScale],u_fade:a.t}},T3=(e,t,i,r,a)=>{let n=e.transform,s=od(t,n);return Z(Cl(e,t,i,r),{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})},S3=(e,t,i,r,a,n)=>{let s=e.transform,o=od(t,s);return Z(Cl(e,t,i,r),{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 od(e,t){return 1/Kt(e,1,t.tileZoom)}function w0(e,t,i){return vr(e.transform,t,i.paint.get("line-translate"),i.paint.get("line-translate-anchor"))}const E3=(e,t)=>({u_image:new X(e,t.u_image),u_opacity:new G(e,t.u_opacity)}),P3=(e,t)=>({u_image:t,u_opacity:e}),C3=(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 G(e,t.u_size_t),u_size:new G(e,t.u_size),u_rotate_symbol:new X(e,t.u_rotate_symbol),u_label_plane_matrix:new Ci(e,t.u_label_plane_matrix),u_coord_matrix:new Ci(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 se(e,t.u_texsize),u_texture:new X(e,t.u_texture),u_translation:new se(e,t.u_translation),u_pitched_scale:new G(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)}),A3=(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 G(e,t.u_size_t),u_size:new G(e,t.u_size),u_rotate_symbol:new X(e,t.u_rotate_symbol),u_label_plane_matrix:new Ci(e,t.u_label_plane_matrix),u_coord_matrix:new Ci(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 se(e,t.u_texsize),u_texture:new X(e,t.u_texture),u_gamma_scale:new G(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 se(e,t.u_translation),u_pitched_scale:new G(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)}),D3=(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 G(e,t.u_size_t),u_size:new G(e,t.u_size),u_rotate_symbol:new X(e,t.u_rotate_symbol),u_label_plane_matrix:new Ci(e,t.u_label_plane_matrix),u_coord_matrix:new Ci(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 se(e,t.u_texsize),u_texsize_icon:new se(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 G(e,t.u_gamma_scale),u_is_halo:new X(e,t.u_is_halo),u_translation:new se(e,t.u_translation),u_pitched_scale:new G(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)}),T0=(e,t,i,r,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:+i,u_label_plane_matrix:o,u_coord_matrix:l,u_is_text:+h,u_pitch_with_map:+r,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}),S0=(e,t,i,r,a,n,s,o,l,u,h,c,d,p,f,m)=>{let g=s.transform;return Z(T0(e,t,i,r,a,n,s,o,l,u,h,c,p,f,m),{u_gamma_scale:r?Math.cos(g.pitch*Math.PI/180)*g.cameraToCenterDistance:1,u_is_halo:+!!d,u_is_plain:1})},I3=(e,t,i,r,a,n,s,o,l,u,h,c,d,p,f)=>Z(S0(e,t,i,r,a,n,s,o,l,u,!0,h,!0,d,p,f),{u_texsize_icon:c,u_texture_icon:1}),M3=(e,t)=>({u_opacity:new G(e,t.u_opacity),u_color:new Cr(e,t.u_color)}),z3=(e,t)=>({u_opacity:new G(e,t.u_opacity),u_image:new X(e,t.u_image),u_pattern_tl_a:new se(e,t.u_pattern_tl_a),u_pattern_br_a:new se(e,t.u_pattern_br_a),u_pattern_tl_b:new se(e,t.u_pattern_tl_b),u_pattern_br_b:new se(e,t.u_pattern_br_b),u_texsize:new se(e,t.u_texsize),u_mix:new G(e,t.u_mix),u_pattern_size_a:new se(e,t.u_pattern_size_a),u_pattern_size_b:new se(e,t.u_pattern_size_b),u_scale_a:new G(e,t.u_scale_a),u_scale_b:new G(e,t.u_scale_b),u_pixel_coord_upper:new se(e,t.u_pixel_coord_upper),u_pixel_coord_lower:new se(e,t.u_pixel_coord_lower),u_tile_units_to_pixels:new G(e,t.u_tile_units_to_pixels)}),F3=(e,t)=>({u_opacity:e,u_color:t}),R3=(e,t,i,r,a)=>Z(WM(i,a,t,r),{u_opacity:e}),k3=(e,t)=>({u_sun_pos:new Ot(e,t.u_sun_pos),u_atmosphere_blend:new G(e,t.u_atmosphere_blend),u_globe_position:new Ot(e,t.u_globe_position),u_globe_radius:new G(e,t.u_globe_radius),u_inv_proj_matrix:new Ci(e,t.u_inv_proj_matrix)}),L3=(e,t,i,r,a)=>({u_sun_pos:e,u_atmosphere_blend:t,u_globe_position:i,u_globe_radius:r,u_inv_proj_matrix:a}),B3=(e,t)=>({u_sky_color:new Cr(e,t.u_sky_color),u_horizon_color:new Cr(e,t.u_horizon_color),u_horizon:new se(e,t.u_horizon),u_horizon_normal:new se(e,t.u_horizon_normal),u_sky_horizon_blend:new G(e,t.u_sky_horizon_blend),u_sky_blend:new G(e,t.u_sky_blend),u_inv_proj_matrix:new Ci(e,t.u_inv_proj_matrix),u_globe_position:new Ot(e,t.u_globe_position),u_globe_radius:new G(e,t.u_globe_radius)}),$3=(e,t,i)=>{let r=Math.cos(t.rollInRadians),a=Math.sin(t.rollInRadians),n=es(t),s=t.getProjectionData({overscaledTileID:null,applyGlobeMatrix:!0,applyTerrainMatrix:!0}).projectionTransition;return{u_sky_color:e.properties.get("sky-color"),u_horizon_color:e.properties.get("horizon-color"),u_horizon:[(t.width/2-n*a)*i,(t.height/2+n*r)*i],u_horizon_normal:[-a,r],u_sky_horizon_blend:e.properties.get("sky-horizon-blend")*t.height/2*i,u_sky_blend:s,u_inv_proj_matrix:t.inverseProjectionMatrix,u_globe_position:r0(t),u_globe_radius:rn(t.worldSize,t.center.lat)}},Al=(e,t)=>({}),O3={fillExtrusion:HM,fillExtrusionPattern:XM,fill:KM,fillPattern:JM,fillOutline:QM,fillOutlinePattern:e3,circle:a3,collisionBox:Al,collisionCircle:Al,debug:s3,depth:Al,clippingMask:Al,heatmap:o3,heatmapTexture:l3,hillshade:u3,hillshadePrepare:h3,colorRelief:f3,line:g3,lineGradient:_3,linePattern:y3,lineSDF:v3,lineGradientSDF:x3,layerOpacity:E3,raster:iI,symbolIcon:C3,symbolSDF:A3,symbolTextAndIcon:D3,background:M3,backgroundPattern:z3,terrain:kM,terrainDepth:LM,atmosphere:k3,sky:B3};var N3=class{constructor(e,t,i){this.context=e;let r=e.gl;this.buffer=r.createBuffer(),this.dynamicDraw=!!i,this.context.unbindVAO(),e.bindElementBuffer.set(this.buffer),r.bufferData(r.ELEMENT_ARRAY_BUFFER,t.arrayBuffer,this.dynamicDraw?r.DYNAMIC_DRAW:r.STATIC_DRAW),this.dynamicDraw||t.freeBufferAfterUpload()}bind(){this.context.bindElementBuffer.set(this.buffer)}updateData(e){let t=this.context.gl;if(!this.dynamicDraw)throw Error("Attempted to update data while not in dynamic mode.");this.context.unbindVAO(),this.bind(),t.bufferSubData(t.ELEMENT_ARRAY_BUFFER,0,e.arrayBuffer)}destroy(){let e=this.context.gl;this.buffer&&(e.deleteBuffer(this.buffer),delete this.buffer)}};const E0={Int8:"BYTE",Uint8:"UNSIGNED_BYTE",Int16:"SHORT",Uint16:"UNSIGNED_SHORT",Int32:"INT",Uint32:"UNSIGNED_INT",Float32:"FLOAT"};var V3=class{constructor(e,t,i,r){this.length=t.length,this.attributes=i,this.itemSize=t.bytesPerElement,this.dynamicDraw=r,this.context=e;let a=e.gl;this.buffer=a.createBuffer(),e.bindVertexBuffer.set(this.buffer),a.bufferData(a.ARRAY_BUFFER,t.arrayBuffer,this.dynamicDraw?a.DYNAMIC_DRAW:a.STATIC_DRAW),this.dynamicDraw||t.freeBufferAfterUpload()}bind(){this.context.bindVertexBuffer.set(this.buffer)}updateData(e){if(e.length!==this.length)throw Error(`Length of new data is ${e.length}, which doesn't match current length of ${this.length}`);let t=this.context.gl;this.bind(),t.bufferSubData(t.ARRAY_BUFFER,0,e.arrayBuffer)}enableAttributes(e,t){for(let i of this.attributes){let r=t.attributes[i.name];r!==void 0&&e.enableVertexAttribArray(r.location)}}setVertexAttribPointers(e,t,i){for(let r of this.attributes){let a=t.attributes[r.name];if(a!==void 0){let n=r.offset+this.itemSize*(i||0);a.isInteger?e.vertexAttribIPointer(a.location,r.components,e[E0[r.type]],this.itemSize,n):e.vertexAttribPointer(a.location,r.components,e[E0[r.type]],!1,this.itemSize,n)}}}destroy(){let e=this.context.gl;this.buffer&&(e.deleteBuffer(this.buffer),delete this.buffer)}},Ee=class{constructor(t){this.gl=t.gl,this.default=this.getDefault(),this.current=this.default,this.dirty=!1}get(){return this.current}set(t){}getDefault(){return this.default}setDefault(){this.set(this.default)}},j3=class extends Ee{getDefault(){return te.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)}},U3=class extends Ee{getDefault(){return 1}set(e){(e!==this.current||this.dirty)&&(this.gl.clearDepth(e),this.current=e,this.dirty=!1)}},G3=class extends Ee{getDefault(){return 0}set(e){(e!==this.current||this.dirty)&&(this.gl.clearStencil(e),this.current=e,this.dirty=!1)}},Z3=class extends Ee{getDefault(){return[!0,!0,!0,!0]}set(t){let i=this.current;(t[0]!==i[0]||t[1]!==i[1]||t[2]!==i[2]||t[3]!==i[3]||this.dirty)&&(this.gl.colorMask(t[0],t[1],t[2],t[3]),this.current=t,this.dirty=!1)}},q3=class extends Ee{getDefault(){return!0}set(e){(e!==this.current||this.dirty)&&(this.gl.depthMask(e),this.current=e,this.dirty=!1)}},W3=class extends Ee{getDefault(){return 255}set(e){(e!==this.current||this.dirty)&&(this.gl.stencilMask(e),this.current=e,this.dirty=!1)}},H3=class extends Ee{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)}},X3=class extends Ee{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)}},Y3=class extends Ee{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}},K3=class extends Ee{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)}},J3=class extends Ee{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}},Q3=class extends Ee{getDefault(){return this.gl.LESS}set(e){(e!==this.current||this.dirty)&&(this.gl.depthFunc(e),this.current=e,this.dirty=!1)}},ez=class extends Ee{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}},tz=class extends Ee{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 Ee{getDefault(){return te.transparent}set(t){let i=this.current;(t.r!==i.r||t.g!==i.g||t.b!==i.b||t.a!==i.a||this.dirty)&&(this.gl.blendColor(t.r,t.g,t.b,t.a),this.current=t,this.dirty=!1)}},rz=class extends Ee{getDefault(){return this.gl.FUNC_ADD}set(e){(e!==this.current||this.dirty)&&(this.gl.blendEquation(e),this.current=e,this.dirty=!1)}},az=class extends Ee{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}},nz=class extends Ee{getDefault(){return this.gl.BACK}set(e){(e!==this.current||this.dirty)&&(this.gl.cullFace(e),this.current=e,this.dirty=!1)}},sz=class extends Ee{getDefault(){return this.gl.CCW}set(e){(e!==this.current||this.dirty)&&(this.gl.frontFace(e),this.current=e,this.dirty=!1)}},oz=class extends Ee{getDefault(){return null}set(e){(e!==this.current||this.dirty)&&(this.gl.useProgram(e),this.current=e,this.dirty=!1)}},lz=class extends Ee{getDefault(){return this.gl.TEXTURE0}set(e){(e!==this.current||this.dirty)&&(this.gl.activeTexture(e),this.current=e,this.dirty=!1)}},uz=class extends Ee{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)}},hz=class extends Ee{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}},cz=class extends Ee{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}},dz=class extends Ee{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}},pz=class extends Ee{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}},fz=class extends Ee{getDefault(){return null}set(e){let t=this.gl;t.bindBuffer(t.ELEMENT_ARRAY_BUFFER,e),this.current=e,this.dirty=!1}},mz=class extends Ee{getDefault(){return null}set(e){(e!==this.current||this.dirty)&&(this.gl.bindVertexArray(e),this.current=e,this.dirty=!1)}},gz=class extends Ee{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}},_z=class extends Ee{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}},yz=class extends Ee{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}},ld=class extends Ee{constructor(e,t){super(e),this.context=e,this.parent=t}getDefault(){return null}},vz=class extends ld{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}},xz=class extends ld{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}},bz=class extends ld{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}},wz=class{constructor(e,t,i,r,a){this.context=e,this.width=t,this.height=i;let n=e.gl,s=this.framebuffer=n.createFramebuffer();if(this.colorAttachment=new vz(e,s),r)this.depthAttachment=a?new bz(e,s):new xz(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 i=this.depthAttachment.get();i&&e.deleteRenderbuffer(i)}e.deleteFramebuffer(this.framebuffer)}};const P0=ad([{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"}]),ni=P0.offsets;function Tz(e){return new nd(e,El.FrameUBO,P0)}function Sz(e,t){let i=e.pending,{transform:r}=t,a=t.context.gl;i[ni.u_units_to_pixels]=1/r.pixelsToGLUnits[0],i[ni.u_units_to_pixels+1]=1/r.pixelsToGLUnits[1],i[ni.u_world_size]=a.drawingBufferWidth,i[ni.u_world_size+1]=a.drawingBufferHeight,i[ni.u_camera_to_center_distance]=r.cameraToCenterDistance,i[ni.u_symbol_fade_change]=t.options.fadeDuration?t.symbolFadeChange:1,i[ni.u_aspect_ratio]=r.width/r.height,i[ni.u_device_pixel_ratio]=t.pixelRatio,i[ni.u_viewport_size]=r.width,i[ni.u_viewport_size+1]=r.height,i[ni.u_pixel_extrude_scale]=1/r.width,i[ni.u_pixel_extrude_scale+1]=1/r.height,i[ni.u_pitch]=r.pitch/360*2*Math.PI,e.upload()}var Ke=class{constructor(t,i,r){this.blendFunction=t,this.blendColor=i,this.mask=r}};Ke.Replace=[1,0],Ke.disabled=new Ke(Ke.Replace,te.transparent,[!1,!1,!1,!1]),Ke.unblended=new Ke(Ke.Replace,te.transparent,[!0,!0,!0,!0]),Ke.alphaBlended=new Ke([1,771],te.transparent,[!0,!0,!0,!0]);var Ez=class{constructor(e){this.gl=e,this.clearColor=new j3(this),this.clearDepth=new U3(this),this.clearStencil=new G3(this),this.colorMask=new Z3(this),this.depthMask=new q3(this),this.stencilMask=new W3(this),this.stencilFunc=new H3(this),this.stencilOp=new X3(this),this.stencilTest=new Y3(this),this.depthRange=new K3(this),this.depthTest=new J3(this),this.depthFunc=new Q3(this),this.blend=new ez(this),this.blendFunc=new tz(this),this.blendColor=new iz(this),this.blendEquation=new rz(this),this.cullFace=new az(this),this.cullFaceSide=new nz(this),this.frontFace=new sz(this),this.program=new oz(this),this.activeTexture=new lz(this),this.viewport=new uz(this),this.bindFramebuffer=new hz(this),this.bindRenderbuffer=new cz(this),this.bindTexture=new dz(this),this.bindVertexBuffer=new pz(this),this.bindElementBuffer=new fz(this),this.bindVertexArray=new mz(this),this.pixelStoreUnpack=new gz(this),this.pixelStoreUnpackPremultiplyAlpha=new _z(this),this.pixelStoreUnpackFlipY=new yz(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.projectionUniformBuffer=VM(this),this.terrainUniformBuffer=UM(this),this.frameUniformBuffer=Tz(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.projectionUniformBuffer.bindingDirty=!0,this.terrainUniformBuffer.bindingDirty=!0,this.frameUniformBuffer.bindingDirty=!0}setCustomLayerDefaults(){this.unbindVAO(),this.cullFace.setDefault(),this.activeTexture.setDefault(),this.pixelStoreUnpack.setDefault(),this.pixelStoreUnpackPremultiplyAlpha.setDefault(),this.pixelStoreUnpackFlipY.setDefault()}createIndexBuffer(e,t){return new N3(this,e,t)}createVertexBuffer(e,t,i){return new V3(this,e,t,i)}createRenderbuffer(e,t,i){let r=this.gl,a=r.createRenderbuffer();return this.bindRenderbuffer.set(a),r.renderbufferStorage(r.RENDERBUFFER,e,t,i),this.bindRenderbuffer.set(null),a}createFramebuffer(e,t,i,r){return new wz(this,e,t,i,r)}clear({color:e,depth:t,stencil:i}){let r=this.gl,a=0;e&&(a|=r.COLOR_BUFFER_BIT,this.clearColor.set(e),this.colorMask.set([!0,!0,!0,!0])),t!==void 0&&(a|=r.DEPTH_BUFFER_BIT,this.depthRange.set([0,1]),this.clearDepth.set(t),this.depthMask.set(!0)),i!==void 0&&(a|=r.STENCIL_BUFFER_BIT,this.clearStencil.set(i),this.stencilMask.set(255)),r.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){ki(e.blendFunction,Ke.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)}},de=class{constructor(t,i,r){this.func=t,this.mask=i,this.range=r}};de.ReadOnly=!1,de.ReadWrite=!0,de.disabled=new de(519,de.ReadOnly,[0,1]);const ud=7680;var ve=class{constructor(t,i,r,a,n,s){this.test=t,this.ref=i,this.mask=r,this.fail=a,this.depthFail=n,this.pass=s}};ve.disabled=new ve({func:519,mask:0},0,0,ud,ud,ud);const C0=1029,hd=2305;var ge=class{constructor(e,t,i){this.enable=e,this.mode=t,this.frontFace=i}};ge.disabled=new ge(!1,C0,hd),ge.backCCW=new ge(!0,C0,hd),ge.frontCCW=new ge(!0,1028,hd);let Dl;function A0(e,t,i,r,a){var _,y;let n=e.context,s=e.transform,o=n.gl,l=e.useProgram("collisionBox"),u=[],h=0,c=0;for(let x of r){let v=t.getTile(x).getBucket(i);if(!v)continue;let w=a?v.textCollisionBox:v.iconCollisionBox,b=v.collisionCircleArray;b.length>0&&(u.push({circleArray:b,circleOffset:c,coord:x}),h+=b.length/4,c=h),w&&l.draw(n,o.LINES,de.disabled,ve.disabled,e.colorModeForRenderPass(),ge.disabled,null,(_=e.style.map.terrain)==null?void 0:_.getTerrainData(x),s.getProjectionData({overscaledTileID:x,applyGlobeMatrix:!0,applyTerrainMatrix:!0}),i.id,w.layoutVertexBuffer,w.indexBuffer,w.segments,null,e.transform.zoom,null,null,w.collisionVertexBuffer)}if(!a||!u.length)return;let d=e.useProgram("collisionCircle"),p=new C2;p.resize(h*4),p._trim();let f=0;for(let x of u)for(let v=0;v<x.circleArray.length/4;v++){let w=v*4,b=x.circleArray[w+0],T=x.circleArray[w+1],P=x.circleArray[w+2],S=x.circleArray[w+3];p.emplace(f++,b,T,P,S,0),p.emplace(f++,b,T,P,S,1),p.emplace(f++,b,T,P,S,2),p.emplace(f++,b,T,P,S,3)}(!Dl||Dl.length<h*2)&&(Dl=Pz(h));let m=n.createIndexBuffer(Dl,!0),g=n.createVertexBuffer(p,ZS.members,!0);for(let x of u)d.draw(n,o.TRIANGLES,de.disabled,ve.disabled,e.colorModeForRenderPass(),ge.disabled,null,(y=e.style.map.terrain)==null?void 0:y.getTerrainData(x.coord),null,i.id,g,m,Ne.simpleSegment(0,x.circleOffset*2,x.circleArray.length,x.circleArray.length/2),null,e.transform.zoom,null,null,null);g.destroy(),m.destroy()}function Pz(e){let t=e*2,i=new D2;i.resize(t),i._trim();for(let r=0;r<t;r++){let a=r*6;i.uint16[a+0]=r*4+0,i.uint16[a+1]=r*4+1,i.uint16[a+2]=r*4+2,i.uint16[a+3]=r*4+2,i.uint16[a+4]=r*4+3,i.uint16[a+5]=r*4+0}return i}const Cz=Si(new Float32Array(16));function Az(e,t,i,r,a,n){if(n.currentPass!=="translucent")return;let{isRenderingToTexture:s}=n,o=ve.disabled,l=e.colorModeForRenderPass();(i._unevaluatedLayout.hasValue("text-variable-anchor")||i._unevaluatedLayout.hasValue("text-variable-anchor-offset"))&&Iz(r,e,i,t,i.layout.get("text-rotation-alignment"),i.layout.get("text-pitch-alignment"),i.paint.get("text-translate"),i.paint.get("text-translate-anchor"),a),i.paint.get("icon-opacity").constantOr(1)!==0&&D0(e,t,i,r,!1,i.paint.get("icon-translate"),i.paint.get("icon-translate-anchor"),i.layout.get("icon-rotation-alignment").constantOr("viewport"),i.layout.get("icon-pitch-alignment"),i.layout.get("icon-keep-upright"),o,l,s),i.paint.get("text-opacity").constantOr(1)!==0&&D0(e,t,i,r,!0,i.paint.get("text-translate"),i.paint.get("text-translate-anchor"),i.layout.get("text-rotation-alignment"),i.layout.get("text-pitch-alignment"),i.layout.get("text-keep-upright"),o,l,s),t.map.showCollisionBoxes&&(A0(e,t,i,r,!0),A0(e,t,i,r,!1))}function Dz(e,t,i,r,a,n){let{horizontalAlign:s,verticalAlign:o}=Vo(e),l=-(s-.5)*t,u=-(o-.5)*i;return new C((l/a+r[0])*n,(u/a+r[1])*n)}function Iz(e,t,i,r,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=r.getTile(f),g=m.getBucket(i);if(!((p=g==null?void 0:g.text)!=null&&p.segments.get().length))continue;let _=g.textSizeData,y=Uo(_,u.zoom),x=Kt(m,1,t.transform.zoom),v=Nc(c,t.transform,x),w=i.layout.get("icon-text-fit")!=="none"&&g.hasIconData();if(y){let b=2**(u.zoom-m.tileID.overscaledZ),T=h?(P,S)=>h.getElevation(f,P,S):void 0;zz(g,c,d,l,u,v,b,y,w,vr(u,m,s,o),f.toUnwrapped(),T,i.layout.get("symbol-height-anchor")==="ground")}}}function Mz(e,t,i,r,a,n){let s=t.tileAnchorPoint.add(new C(t.translation[0],t.translation[1]));if(t.pitchWithMap){let o=r.mult(n);i||(o=o.rotate(-a));let l=s.add(o);return jc(l.x,l.y,t.pitchedLabelPlaneMatrix,da(t,l.x,l.y)).point}if(i){let o=pa(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(r.rotate(l))}return e.add(r)}function zz(e,t,i,r,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(_),x=e.allowVerticalPlacement&&!y.placedOrientation,v=!y.hidden&&y.crossTileID&&!x?r[y.crossTileID]:null;if(!v)tn(y.numGlyphs,f);else{let w=new C(y.anchorX,y.anchorY),b={getElevation:c,heightOffset:y.heightOffset,heightAnchorGround:d,width:a.width,height:a.height,pitchedLabelPlaneMatrix:n,pitchWithMap:i,transform:a,tileAnchorPoint:w,translation:u,unwrappedTileID:h},T=i?Fy(w.x,w.y,b):pa(w.x,w.y,b),P=Ay(a.cameraToCenterDistance,T.signedDistanceFromCamera),S=qh(e.textSizeData,o,y)*P/24;i&&(S*=e.tilePixelRatio/s);let{width:M,height:F,anchor:R,textOffset:I,textBoxScale:D}=v,E=Dz(R,M,F,I,D,S),A=a.getPitchedTextCorrection(w.x+u[0],w.y+u[1],h),B=Mz(T.point,b,t,E,-a.bearingInRadians,A),N=e.allowVerticalPlacement&&y.placedOrientation===2?Math.PI/2:0;for(let O=0;O<y.numGlyphs;O++)Yo(f,B,N);l&&y.associatedIconIndex>=0&&(g[y.associatedIconIndex]={shiftedAnchor:B,angle:N})}}if(l){m.clear();let _=e.icon.placedSymbolArray;for(let y=0;y<_.length;y++){let x=_.get(y);if(x.hidden)tn(x.numGlyphs,m);else{let v=g[y];if(!v)tn(x.numGlyphs,m);else for(let w=0;w<x.numGlyphs;w++)Yo(m,v.shiftedAnchor,v.angle)}}e.icon.dynamicLayoutVertexBuffer.updateData(m)}e.text.dynamicLayoutVertexBuffer.updateData(f)}function Fz(e,t,i){return i.iconsInText&&t?"symbolTextAndIcon":e?"symbolSDF":"symbolIcon"}function D0(e,t,i,r,a,n,s,o,l,u,h,c,d){var R;let p=e.context,f=p.gl,m=e.transform,g=o==="map",_=l==="map",y=o!=="viewport"&&i.layout.get("symbol-placement")!=="point",x=g&&!_&&!y,v=!i.layout.get("symbol-sort-key").isConstant(),w=!1,b=e.getDepthModeForSublayer(0,de.ReadOnly),T=i._unevaluatedLayout.hasValue("text-variable-anchor")||i._unevaluatedLayout.hasValue("text-variable-anchor-offset"),P=[],S=m.getCircleRadiusCorrection();for(let I of r){let D=t.getTile(I),E=D.getBucket(i);if(!E)continue;let A=a?E.text:E.icon;if(!(A!=null&&A.segments.get().length)||!A.hasVisibleVertices)continue;let B=A.programConfigurations.get(i.id),N=a||E.sdfIcons,O=a?E.textSizeData:E.iconSizeData,H=_||m.pitch!==0,ue=e.useProgram(Fz(N,a,E),B),Ae=Uo(O,m.zoom),ne=(R=e.style.map.terrain)==null?void 0:R.getTerrainData(I),Ce,_e=[0,0],Ie,Me,ct=null,Mt;if(a){if(Ie=D.glyphAtlasTexture,Me=f.LINEAR,Ce=D.glyphAtlasTexture.size,E.iconsInText){_e=D.imageAtlasTexture.size,ct=D.imageAtlasTexture;let tt=O.kind==="composite"||O.kind==="camera";Mt=H||e.options.rotating||e.options.zooming||tt?f.LINEAR:f.NEAREST}}else{let tt=i.layout.get("icon-size").constantOr(0)!==1||E.iconsNeedLinear;Ie=D.imageAtlasTexture,Me=N||e.options.rotating||e.options.zooming||tt||H?f.LINEAR:f.NEAREST,Ce=D.imageAtlasTexture.size}let Fi=Kt(D,1,e.transform.zoom),Ut=Nc(g,e.transform,Fi),Ue=LI(_,g,e.transform,Fi),wt=vr(m,D,n,s),Lr=m.getProjectionData({overscaledTileID:I,applyGlobeMatrix:!d,applyTerrainMatrix:!0}),Br=T&&E.hasTextData(),va=i.layout.get("icon-text-fit")!=="none"&&Br&&E.hasIconData(),Xi=i._unevaluatedLayout.hasValue("icon-offset"),Ye=i.layout.get("symbol-height-anchor")==="ground";if(y){let tt=gr();zI(tt,Ut);let Zt=e.style.map.terrain?(_t,Cs)=>e.style.map.terrain.getElevation(I,_t,Cs):void 0;$I(E,e,a,Ut,tt,_,u,i.layout.get("text-rotation-alignment")==="map",I.toUnwrapped(),m.width,m.height,wt,Zt)}let Ge=a&&T||va,Ft=_?Ut:e.transform.clipSpaceToPixelsMatrix,Yt=y||Ge?Cz:Ft,Yi=N&&i.paint.get(a?"text-halo-width":"icon-halo-width").constantOr(1)!==0,Gt;Gt=N?E.iconsInText?I3(O.kind,Ae,x,_,y,Ge,e,Yt,Ue,wt,Ce,_e,S,Xi,Ye):S0(O.kind,Ae,x,_,y,Ge,e,Yt,Ue,wt,a,Ce,Yi,S,Xi,Ye):T0(O.kind,Ae,x,_,y,Ge,e,Yt,Ue,wt,a,Ce,S,Xi,Ye);let Rt={program:ue,buffers:A,uniformValues:Gt,projectionData:Lr,atlasTexture:Ie,atlasTextureIcon:ct,atlasInterpolation:Me,atlasInterpolationIcon:Mt,isSDF:N,hasHalo:Yi};if(v&&E.canOverlap){w=!0;let tt=A.segments.get();for(let Zt of tt)P.push({segments:new Ne([Zt]),sortKey:Zt.sortKey,state:Rt,terrainData:ne})}else P.push({segments:A.segments,sortKey:0,state:Rt,terrainData:ne})}w&&P.sort((I,D)=>I.sortKey-D.sortKey);let M=i.paint.get(a?"text-halo-width":"icon-halo-width").constantOr(null)??1/0,F=i.layout.get("text-letter-spacing").constantOr(0)*24<0||M>1;for(let I of P){let D=I.state;p.activeTexture.set(f.TEXTURE0),D.atlasTexture.bind(D.atlasInterpolation,f.CLAMP_TO_EDGE),D.atlasTextureIcon&&(p.activeTexture.set(f.TEXTURE1),D.atlasTextureIcon&&D.atlasTextureIcon.bind(D.atlasInterpolationIcon,f.CLAMP_TO_EDGE));let E=D.isSDF&&D.hasHalo;if(E){let A=D.uniformValues;A.u_is_halo=1,F&&(A.u_is_plain=0,I0(D.buffers,I.segments,i,e,D.program,b,h,c,A,D.projectionData,I.terrainData),A.u_is_halo=0,A.u_is_plain=1)}I0(D.buffers,I.segments,i,e,D.program,b,h,c,D.uniformValues,D.projectionData,I.terrainData),E&&!F&&(D.uniformValues.u_is_halo=0)}}function I0(e,t,i,r,a,n,s,o,l,u,h){let c=r.context,d=c.gl;a.draw(c,d.TRIANGLES,n,s,o,ge.backCCW,l,h,u,i.id,e.layoutVertexBuffer,e.indexBuffer,t,i.paint,r.transform.zoom,e.programConfigurations.get(i.id),e.dynamicLayoutVertexBuffer,e.opacityVertexBuffer)}function Rz(e,t,i,r,a){var y;if(a.currentPass!=="translucent")return;let{isRenderingToTexture:n}=a,s=i.paint.get("circle-opacity"),o=i.paint.get("circle-stroke-width"),l=i.paint.get("circle-stroke-opacity"),u=!i.layout.get("circle-sort-key").isConstant();if(s.constantOr(1)===0&&(o.constantOr(1)===0||l.constantOr(1)===0))return;let h=e.context,c=h.gl,d=e.transform,p=e.getDepthModeForSublayer(0,de.ReadOnly),f=ve.disabled,m=e.colorModeForRenderPass(),g=[],_=d.getCircleRadiusCorrection();for(let x of r){let v=t.getTile(x),w=v.getBucket(i);if(!w)continue;let b=i.paint.get("circle-translate"),T=i.paint.get("circle-translate-anchor"),P=vr(d,v,b,T),S=w.programConfigurations.get(i.id),M=e.useProgram("circle",S),F=w.layoutVertexBuffer,R=w.indexBuffer,I=(y=e.style.map.terrain)==null?void 0:y.getTerrainData(x),D={programConfiguration:S,program:M,layoutVertexBuffer:F,indexBuffer:R,uniformValues:n3(e,v,i,P,_),terrainData:I,projectionData:d.getProjectionData({overscaledTileID:x,applyGlobeMatrix:!n,applyTerrainMatrix:!0})};if(u){let E=w.segments.get();for(let A of E)g.push({segments:new Ne([A]),sortKey:A.sortKey,state:D})}else g.push({segments:w.segments,sortKey:0,state:D})}u&&g.sort((x,v)=>x.sortKey-v.sortKey);for(let x of g){let{programConfiguration:v,program:w,layoutVertexBuffer:b,indexBuffer:T,uniformValues:P,terrainData:S,projectionData:M}=x.state,F=x.segments;w.draw(h,c.TRIANGLES,p,f,m,ge.backCCW,P,S,M,i.id,b,T,F,i.paint,e.transform.zoom,v)}}function kz(e,t,i,r,a){if(i.paint.get("heatmap-opacity")===0)return;let n=e.context,{isRenderingToTexture:s,isRenderingGlobe:o}=a;if(e.style.map.terrain){for(let l of r){let u=t.getTile(l);t.hasRenderableParent(l)||(a.currentPass==="offscreen"?$z(e,u,i,l,o):a.currentPass==="translucent"&&Oz(e,i,l,s,o))}n.viewport.set([0,0,e.width,e.height])}else a.currentPass==="offscreen"?Lz(e,t,i,r):a.currentPass==="translucent"&&Bz(e,i)}function Lz(e,t,i,r){let a=e.context,n=a.gl,s=e.transform,o=ve.disabled,l=new Ke([n.ONE,n.ONE],te.transparent,[!0,!0,!0,!0]);Nz(a,e,i),a.clear({color:te.transparent});for(let u of r){if(t.hasRenderableParent(u))continue;let h=t.getTile(u),c=h.getBucket(i);if(!c)continue;let d=c.programConfigurations.get(i.id),p=e.useProgram("heatmap",d),f=s.getProjectionData({overscaledTileID:u,applyGlobeMatrix:!0,applyTerrainMatrix:!1}),m=s.getCircleRadiusCorrection();p.draw(a,n.TRIANGLES,de.disabled,o,l,ge.backCCW,x0(h,s.zoom,i.paint.get("heatmap-intensity"),m),null,f,i.id,c.layoutVertexBuffer,c.indexBuffer,c.segments,i.paint,s.zoom,d)}a.viewport.set([0,0,e.width,e.height])}function Bz(e,t){let i=e.context,r=i.gl;i.setColorMode(e.colorModeForRenderPass());let a=t.heatmapFbos.get(Io);a&&(i.activeTexture.set(r.TEXTURE0),r.bindTexture(r.TEXTURE_2D,a.colorAttachment.get()),i.activeTexture.set(r.TEXTURE1),z0(i,t).bind(r.LINEAR,r.CLAMP_TO_EDGE),e.useProgram("heatmapTexture").draw(i,r.TRIANGLES,de.disabled,ve.disabled,e.colorModeForRenderPass(),ge.disabled,b0(e,t,0,1),null,null,t.id,e.viewportBuffer,e.quadTriangleIndexBuffer,e.viewportSegments,t.paint,e.transform.zoom))}function $z(e,t,i,r,a){let n=e.context,s=n.gl,o=ve.disabled,l=new Ke([s.ONE,s.ONE],te.transparent,[!0,!0,!0,!0]),u=t.getBucket(i);if(!u)return;let h=r.key,c=i.heatmapFbos.get(h);c||(c=M0(n,t.tileSize,t.tileSize),i.heatmapFbos.set(h,c)),n.bindFramebuffer.set(c.framebuffer),n.viewport.set([0,0,t.tileSize,t.tileSize]),n.clear({color:te.transparent});let d=u.programConfigurations.get(i.id),p=e.useProgram("heatmap",d,!a),f=e.transform.getProjectionData({overscaledTileID:t.tileID,applyGlobeMatrix:!0,applyTerrainMatrix:!0}),m=e.style.map.terrain.getTerrainData(r);p.draw(n,s.TRIANGLES,de.disabled,o,l,ge.disabled,x0(t,e.transform.zoom,i.paint.get("heatmap-intensity"),1),m,f,i.id,u.layoutVertexBuffer,u.indexBuffer,u.segments,i.paint,e.transform.zoom,d)}function Oz(e,t,i,r,a){let n=e.context,s=n.gl,o=e.transform;n.setColorMode(e.colorModeForRenderPass());let l=z0(n,t),u=i.key,h=t.heatmapFbos.get(u);if(!h)return;n.activeTexture.set(s.TEXTURE0),s.bindTexture(s.TEXTURE_2D,h.colorAttachment.get()),n.activeTexture.set(s.TEXTURE1),l.bind(s.LINEAR,s.CLAMP_TO_EDGE);let c=o.getProjectionData({overscaledTileID:i,applyTerrainMatrix:a,applyGlobeMatrix:!r});e.useProgram("heatmapTexture").draw(n,s.TRIANGLES,de.disabled,ve.disabled,e.colorModeForRenderPass(),ge.disabled,b0(e,t,0,1),null,c,t.id,e.rasterBoundsBuffer,e.quadTriangleIndexBuffer,e.rasterBoundsSegments,t.paint,o.zoom),h.destroy(),t.heatmapFbos.delete(u)}function Nz(e,t,i){let r=e.gl;e.activeTexture.set(r.TEXTURE1),e.viewport.set([0,0,t.width/4,t.height/4]);let a=i.heatmapFbos.get(Io);a?(r.bindTexture(r.TEXTURE_2D,a.colorAttachment.get()),e.bindFramebuffer.set(a.framebuffer)):(a=M0(e,t.width/4,t.height/4),i.heatmapFbos.set(Io,a))}function M0(e,t,i){let r=e.gl,a=r.createTexture();r.bindTexture(r.TEXTURE_2D,a),r.texParameteri(r.TEXTURE_2D,r.TEXTURE_WRAP_S,r.CLAMP_TO_EDGE),r.texParameteri(r.TEXTURE_2D,r.TEXTURE_WRAP_T,r.CLAMP_TO_EDGE),r.texParameteri(r.TEXTURE_2D,r.TEXTURE_MIN_FILTER,r.LINEAR),r.texParameteri(r.TEXTURE_2D,r.TEXTURE_MAG_FILTER,r.LINEAR),r.texStorage2D(r.TEXTURE_2D,1,r.RGBA16F,t,i);let n=e.createFramebuffer(t,i,!1,!1);return n.colorAttachment.set(a),n}function z0(e,t){return t.colorRampTexture||(t.colorRampTexture=new lt(e,t.colorRamp,e.gl.RGBA)),t.colorRampTexture}function F0(e,t,i,r){let a=e.context,n=a.bindFramebuffer.get(),s=a.viewport.get(),[,,o,l]=s;return Vz(e,o,l),a.viewport.set([0,0,o,l]),a.clear({color:te.transparent,depth:1,stencil:0}),e.currentStencilSource=void 0,e.renderTileClippingMasks(t,i,r),{compositeTarget:n,compositeViewport:s}}function Vz(e,t,i){let r=e.context.gl;if(!e.layerOpacityFbo){let n=e.context.createFramebuffer(t,i,!0,!0),s=r.createTexture();r.bindTexture(r.TEXTURE_2D,s),r.texParameteri(r.TEXTURE_2D,r.TEXTURE_WRAP_S,r.CLAMP_TO_EDGE),r.texParameteri(r.TEXTURE_2D,r.TEXTURE_WRAP_T,r.CLAMP_TO_EDGE),r.texParameteri(r.TEXTURE_2D,r.TEXTURE_MIN_FILTER,r.LINEAR),r.texParameteri(r.TEXTURE_2D,r.TEXTURE_MAG_FILTER,r.LINEAR),r.texImage2D(r.TEXTURE_2D,0,r.RGBA,t,i,0,r.RGBA,r.UNSIGNED_BYTE,null),n.colorAttachment.set(s),n.depthAttachment.set(e.context.createRenderbuffer(r.DEPTH_STENCIL,t,i)),e.layerOpacityFbo=n,e.context.bindFramebuffer.set(e.layerOpacityFbo.framebuffer);return}if(e.layerOpacityFbo.width===t&&e.layerOpacityFbo.height===i){e.context.bindFramebuffer.set(e.layerOpacityFbo.framebuffer);return}let a=e.layerOpacityFbo;r.bindTexture(r.TEXTURE_2D,a.colorAttachment.get()),r.texImage2D(r.TEXTURE_2D,0,r.RGBA,t,i,0,r.RGBA,r.UNSIGNED_BYTE,null),e.context.bindRenderbuffer.set(a.depthAttachment.get()),r.renderbufferStorage(r.RENDERBUFFER,r.DEPTH_STENCIL,t,i),e.context.bindRenderbuffer.set(null),a.width=t,a.height=i,e.context.bindFramebuffer.set(a.framebuffer)}function R0(e,t,i,r){let a=e.context,n=a.gl;a.bindFramebuffer.set(i.compositeTarget),a.viewport.set(i.compositeViewport),a.activeTexture.set(n.TEXTURE0),n.bindTexture(n.TEXTURE_2D,e.layerOpacityFbo.colorAttachment.get()),e.useProgram("layerOpacity").draw(a,n.TRIANGLES,de.disabled,ve.disabled,e.colorModeForRenderPass(),ge.disabled,P3(t,0),null,null,r.id,e.viewportBuffer,e.quadTriangleIndexBuffer,e.viewportSegments,r.paint,e.transform.zoom),e.currentStencilSource=void 0}function k0(e,t,i,r,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/k*1024*h;l=ee(Ix(c),256,i.maxTextureSize)}return o.gradient=Bm({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 lt(i,o.gradient,r.RGBA),o.version=a.gradientVersion,o.texture}function jz(e,t,i,r,a){e.activeTexture.set(t.TEXTURE0),i.imageAtlasTexture.bind(t.LINEAR,t.CLAMP_TO_EDGE),r.updatePaintBuffers(a)}function Uz(e,t,i,r,a,n){(a||e.lineAtlas.dirty)&&(t.activeTexture.set(i.TEXTURE0),e.lineAtlas.bind(t)),r.updatePaintBuffers(n)}function Gz(e,t,i,r,a,n,s){let o=n.gradients[a.id],l=o.texture;a.gradientVersion!==o.version&&(l=k0(e,t,i,r,a,n,s,o)),i.activeTexture.set(r.TEXTURE0),l.bind(a.stepInterpolant?r.NEAREST:r.LINEAR,r.CLAMP_TO_EDGE)}function Zz(e,t,i,r,a,n,s,o,l){let u=n.gradients[a.id],h=u.texture;a.gradientVersion!==u.version&&(h=k0(e,t,i,r,a,n,s,u)),i.activeTexture.set(r.TEXTURE0),h.bind(a.stepInterpolant?r.NEAREST:r.LINEAR,r.CLAMP_TO_EDGE),i.activeTexture.set(r.TEXTURE1),e.lineAtlas.bind(i),o.updatePaintBuffers(l)}function qz(e,t,i,r,a){if(a.currentPass!=="translucent")return;let n=i.paint.get("line-opacity"),s=i.paint.get("line-width"),o=i.paint.get("line-layer-opacity");if(n.constantOr(1)===0||s.constantOr(1)===0||o===0)return;let l=!!e.style.map.terrain;if(o<1){let u=F0(e,i,r,l);L0(e,t,i,r,a,l),R0(e,o,u,i);return}L0(e,t,i,r,a,l)}function L0(e,t,i,r,a,n){let{isRenderingToTexture:s}=a,o=e.getDepthModeForSublayer(0,de.ReadOnly),l=e.colorModeForRenderPass(),u=i.paint.get("line-dasharray"),h=u.constantOr(1),c=i.paint.get("line-pattern"),d=c.constantOr(1),p=i.paint.get("line-gradient"),f=i.getCrossfadeParameters(),m;m=d?"linePattern":h&&p?"lineGradientSDF":h?"lineSDF":p?"lineGradient":"line";let g=e.context,_=g.gl,y=e.transform,x=!0;for(let v of r){let w=t.getTile(v);if(d&&!w.patternsLoaded())continue;let b=w.getBucket(i);if(!b)continue;let T=b.programConfigurations.get(i.id),P=e.context.program.get(),S=e.useProgram(m,T),M=x||S.program!==P,F=n?e.getTerrainDataForTile(v,s):null,R=c.constantOr(null),I=u==null?void 0:u.constantOr(null);if(R&&w.imageAtlas){let N=w.imageAtlas,O=N.patternPositions[R.to.toString()],H=N.patternPositions[R.from.toString()];O&&H&&T.setConstantPatternPositions(O,H)}else if(I){let N=i.layout.get("line-cap").constantOr(null)==="round",O=e.lineAtlas.getDash(I.to,N),H=e.lineAtlas.getDash(I.from,N);T.setConstantDashPositions(O,H)}let D=y.getProjectionData({overscaledTileID:v,applyGlobeMatrix:!s,applyTerrainMatrix:!0}),E=y.getPixelScale(),A;d?(A=w3(e,w,i,E,f),jz(g,_,w,T,f)):h&&p?(A=S3(e,w,i,E,f,b.lineClipsArray.length),Zz(e,t,g,_,i,b,v,T,f)):h?(A=T3(e,w,i,E,f),Uz(e,g,_,T,M,f)):p?(A=b3(e,w,i,E,b.lineClipsArray.length),Gz(e,t,g,_,i,b,v)):A=Cl(e,w,i,E);let B=e.stencilModeForClipping(v);S.draw(g,_.TRIANGLES,o,B,l,ge.disabled,A,F,D,i.id,b.layoutVertexBuffer,b.indexBuffer,b.segments,i.paint,e.transform.zoom,T,b.layoutVertexBuffer2),x=!1}}function B0(e,t,i,r,a){if(!i||!(r!=null&&r.imageAtlas))return;let n=r.imageAtlas.patternPositions,s=n[i.to.toString()],o=n[i.from.toString()];if(!s&&o&&(s=o),!o&&s&&(o=s),!s||!o){let l=a.getPaintProperty(t);s=n[l],o=n[l]}s&&o&&e.setConstantPatternPositions(s,o)}function Wz(e,t,i,r,a){let n=i.paint.get("fill-color"),s=i.paint.get("fill-opacity"),o=i.paint.get("fill-layer-opacity");if(s.constantOr(1)===0||o===0)return;if(o<1){if(a.currentPass!=="translucent")return;let h=F0(e,i,r,!!e.style.map.terrain);$0(e,t,i,r,a),R0(e,o,h,i);return}let l=i.paint.get("fill-pattern"),u=e.opaquePassEnabledForLayer()&&!l.constantOr(1)&&n.constantOr(te.transparent).a===1&&s.constantOr(0)===1;if(u&&a.currentPass==="opaque"){let{isRenderingToTexture:h}=a,c=e.colorModeForRenderPass();cd(e,t,i,r,e.getDepthModeForSublayer(1,de.ReadWrite),c,!1,h);return}if(u&&a.currentPass==="translucent"){O0(e,t,i,r,a);return}a.currentPass==="translucent"&&$0(e,t,i,r,a)}function $0(e,t,i,r,a){let{isRenderingToTexture:n}=a,s=e.colorModeForRenderPass();cd(e,t,i,r,e.getDepthModeForSublayer(1,de.ReadOnly),s,!1,n),O0(e,t,i,r,a)}function O0(e,t,i,r,a){if(!i.paint.get("fill-antialias"))return;let{isRenderingToTexture:n}=a,s=e.colorModeForRenderPass();cd(e,t,i,r,e.getDepthModeForSublayer(i.getPaintProperty("fill-outline-color")?2:0,de.ReadOnly),s,!0,n)}function cd(e,t,i,r,a,n,s,o){let l=e.context.gl,u="fill-pattern",h=i.paint.get(u),c=h==null?void 0:h.constantOr(1),d=i.getCrossfadeParameters(),p,f,m,g,_,y=e.transform,x=i.paint.get("fill-translate"),v=i.paint.get("fill-translate-anchor");s?(f=c&&!i.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 r){let T=t.getTile(b);if(c&&!T.patternsLoaded())continue;let P=T.getBucket(i);if(!P)continue;let S=P.sdfPatterns[i.id]??!1,M=P.programConfigurations.get(i.id),F=e.useProgram(f,M),R=e.getTerrainDataForTile(b,o);c&&(e.context.activeTexture.set(l.TEXTURE0),T.imageAtlasTexture.bind(l.LINEAR,l.CLAMP_TO_EDGE),M.updatePaintBuffers(d)),B0(M,u,w,T,i);let I=y.getProjectionData({overscaledTileID:b,applyGlobeMatrix:!o,applyTerrainMatrix:!0}),D=vr(y,T,x,v);s?(g=P.indexBuffer2,_=P.segments2,m=f==="fillOutlinePattern"&&c?r3(e,d,T,D,S):i3(D)):(g=P.indexBuffer,_=P.segments,m=c?y0(e,d,T,D,S):t3(D));let E=e.stencilModeForClipping(b);F.draw(e.context,p,a,E,n,ge.backCCW,m,R,I,i.id,P.layoutVertexBuffer,g,_,i.paint,e.transform.zoom,M)}}function Hz(e,t,i,r,a){let n=i.paint.get("fill-extrusion-opacity");if(n===0)return;let{isRenderingToTexture:s}=a;if(a.currentPass==="translucent"){let o=new de(e.context.gl.LEQUAL,de.ReadWrite,a.depthRangeFor3D);if(n===1&&!i.paint.get("fill-extrusion-pattern").constantOr(1)){let l=e.colorModeForRenderPass();dd(e,t,i,r,o,ve.disabled,l,s)}else dd(e,t,i,r,o,ve.disabled,Ke.disabled,s),dd(e,t,i,r,o,e.stencilModeFor3D(),e.colorModeForRenderPass(),s)}}function dd(e,t,i,r,a,n,s,o){var _;let l=e.context,u=l.gl,h="fill-extrusion-pattern",c=i.paint.get(h),d=c.constantOr(1),p=i.getCrossfadeParameters(),f=i.paint.get("fill-extrusion-opacity"),m=c.constantOr(null),g=e.transform;for(let y of r){let x=t.getTile(y),v=x.getBucket(i);if(!v)continue;let w=(_=e.style.map.terrain)==null?void 0:_.getTerrainData(y),b=v.programConfigurations.get(i.id),T=e.useProgram(d?"fillExtrusionPattern":"fillExtrusion",b);d&&(e.context.activeTexture.set(u.TEXTURE0),x.imageAtlasTexture.bind(u.LINEAR,u.CLAMP_TO_EDGE),b.updatePaintBuffers(p));let P=g.getProjectionData({overscaledTileID:y,applyGlobeMatrix:!o,applyTerrainMatrix:!0});B0(b,h,m,x,i);let S=vr(g,x,i.paint.get("fill-extrusion-translate"),i.paint.get("fill-extrusion-translate-anchor")),M=i.paint.get("fill-extrusion-vertical-gradient"),F=d?YM(e,M,f,S,y,p,x):_0(e,M,f,S);T.draw(l,l.gl.TRIANGLES,a,n,s,ge.backCCW,F,w,P,i.id,v.layoutVertexBuffer,v.indexBuffer,v.segments,i.paint,e.transform.zoom,b,e.style.map.terrain&&v.centroidVertexBuffer)}}function Xz(e,t,i,r,a){if(a.currentPass!=="offscreen"&&a.currentPass!=="translucent")return;let{isRenderingToTexture:n}=a,s=e.context,o=e.style.projection.useSubdivision,l=e.getDepthModeForSublayer(0,de.ReadOnly),u=e.colorModeForRenderPass();if(a.currentPass==="offscreen")Yz(e,t,r,i,l,ve.disabled,u),s.viewport.set([0,0,e.width,e.height]);else if(a.currentPass==="translucent")if(o){let[h,c,d]=e.stencilConfigForOverlapTwoPass(r);pd(e,t,i,d,h,l,u,!1,n),pd(e,t,i,d,c,l,u,!0,n)}else{let[h,c]=e.getStencilConfigForOverlapAndUpdateStencilID(r);pd(e,t,i,c,h,l,u,!1,n)}}function pd(e,t,i,r,a,n,s,o,l){let u=e.style.projection,h=e.context,c=e.transform,d=h.gl,p=[`#define NUM_ILLUMINATION_SOURCES ${i.paint.get("hillshade-highlight-color").values.length}`],f=e.useProgram("hillshade",null,!1,p),m=!e.options.moving;for(let g of r){let _=t.getTile(g),y=_.fbo;if(!y)continue;let x=u.getMeshFromTileID(h,g.canonical,o,!0,"raster"),v=e.getTerrainDataForTile(g,l);h.activeTexture.set(d.TEXTURE0),d.bindTexture(d.TEXTURE_2D,y.colorAttachment.get());let w=c.getProjectionData({overscaledTileID:g,aligned:m,applyGlobeMatrix:!l,applyTerrainMatrix:!0});f.draw(h,d.TRIANGLES,n,a[g.overscaledZ],s,ge.backCCW,c3(e,_,i),v,w,i.id,x.vertexBuffer,x.indexBuffer,x.segments)}}function Yz(e,t,i,r,a,n,s){let o=e.context,l=o.gl,u=r.paint.get("resampling")==="nearest"?l.NEAREST:l.LINEAR;for(let h of i){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 lt(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 lt(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,ge.disabled,d3(c.tileID,d),null,null,r.id,e.rasterBoundsBuffer,e.quadTriangleIndexBuffer,e.rasterBoundsSegments),c.needsHillshadePrepare=!1}}function Kz(e,t,i,r,a){if(a.currentPass!=="translucent"||!r.length)return;let{isRenderingToTexture:n}=a,s=e.style.projection.useSubdivision,o=e.getDepthModeForSublayer(0,de.ReadOnly),l=e.colorModeForRenderPass();if(s){let[u,h,c]=e.stencilConfigForOverlapTwoPass(r);fd(e,t,i,c,u,o,l,!1,n),fd(e,t,i,c,h,o,l,!0,n)}else{let[u,h]=e.getStencilConfigForOverlapAndUpdateStencilID(r);fd(e,t,i,h,u,o,l,!1,n)}}let N0=0;function fd(e,t,i,r,a,n,s,o,l){let u=e.style.projection,h=e.context,c=e.transform,d=h.gl,p=e.useProgram("colorRelief"),f=!e.options.moving,m=i.paint.get("resampling")==="nearest"?d.NEAREST:d.LINEAR,g=!0,_=0;for(let y of r){let x=t.getTile(y),v=x.dem;if(!(v!=null&&v.data))continue;if(g){N0||(N0=d.getParameter(d.MAX_TEXTURE_SIZE));let S=N0,{elevationTexture:M,colorTexture:F}=i.getColorRampTextures(h,S,v.getUnpackVector());h.activeTexture.set(d.TEXTURE1),M.bind(d.NEAREST,d.CLAMP_TO_EDGE),h.activeTexture.set(d.TEXTURE4),F.bind(d.LINEAR,d.CLAMP_TO_EDGE),g=!1,_=M.size[0]}let w=v.stride;h.activeTexture.set(d.TEXTURE0),(!x.demTexture||x.needsColorReliefPrepare)&&(h.pixelStoreUnpackPremultiplyAlpha.set(!1),x.demTexture||(x.demTexture=e.getTileTexture(w)??new lt(h,{width:w,height:w,data:null},d.RGBA)),x.demTexture.update(v.getPixels(),{premultiply:!1}),x.needsColorReliefPrepare=!1),x.demTexture.bind(m,d.CLAMP_TO_EDGE);let b=u.getMeshFromTileID(h,y.canonical,o,!0,"raster"),T=e.getTerrainDataForTile(y,l),P=c.getProjectionData({overscaledTileID:y,aligned:f,applyGlobeMatrix:!l,applyTerrainMatrix:!0});p.draw(h,d.TRIANGLES,n,a[y.overscaledZ],s,ge.backCCW,m3(i,x.dem,_),T,P,i.id,b.vertexBuffer,b.indexBuffer,b.segments)}}const md=[new C(0,0),new C(k,0),new C(k,k),new C(0,k)];function Jz(e,t,i,r,a){if(a.currentPass!=="translucent"||i.paint.get("raster-opacity")===0||!r.length)return;let{isRenderingToTexture:n}=a,s=t.getSource(),o=e.style.projection.useSubdivision;if(s instanceof Qa)Il(e,t,i,r,null,!1,!1,s.tileCoords,s.imageWarp,s.flippedWindingOrder,n,s.getMesh(e.context,o));else if(o){let[l,u,h]=e.stencilConfigForOverlapTwoPass(r);Il(e,t,i,h,l,!1,!0,md,Ja,!1,n),Il(e,t,i,h,u,!0,!0,md,Ja,!1,n)}else{let[l,u]=e.getStencilConfigForOverlapAndUpdateStencilID(r);Il(e,t,i,u,l,!1,!0,md,Ja,!1,n)}}function Il(e,t,i,r,a,n,s,o,l,u=!1,h=!1,c=null){let d=r[r.length-1].overscaledZ,p=e.context,f=p.gl,m=e.useProgram("raster"),g=e.transform,_=e.style.projection,y=e.colorModeForRenderPass(),x=!e.options.moving,v=i.paint.get("raster-opacity"),w=i.paint.get("resampling")==="nearest"||i.paint.get("raster-resampling")==="nearest"?f.NEAREST:f.LINEAR,b=i.paint.get("raster-fade-duration"),T=!!e.style.map.terrain;for(let P of r){let S=e.getDepthModeForSublayer(P.overscaledZ-d,v===1?de.ReadWrite:de.ReadOnly,f.LESS),M=t.getTile(P);p.activeTexture.set(f.TEXTURE0),M.texture.bind(w,f.CLAMP_TO_EDGE,f.LINEAR_MIPMAP_NEAREST),p.activeTexture.set(f.TEXTURE1);let{parentTile:F,parentScaleBy:R,parentTopLeft:I,fadeValues:D}=Qz(M,t,b,T);M.fadeOpacity=D.tileOpacity,F?(F.fadeOpacity=D.parentTileOpacity,F.texture.bind(w,f.CLAMP_TO_EDGE,f.LINEAR_MIPMAP_NEAREST)):M.texture.bind(w,f.CLAMP_TO_EDGE,f.LINEAR_MIPMAP_NEAREST),M.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=e.getTerrainDataForTile(P,h),A=g.getProjectionData({overscaledTileID:P,aligned:x,applyGlobeMatrix:!h,applyTerrainMatrix:!0}),B=rI(I,R,D.fadeMix,i,o,l),N=c??_.getMeshFromTileID(p,P.canonical,n,s,"raster"),O=a?a[P.overscaledZ]:ve.disabled;m.draw(p,f.TRIANGLES,S,O,y,u?ge.frontCCW:ge.backCCW,B,E,A,i.id,N.vertexBuffer,N.indexBuffer,N.segments)}}function Qz(e,t,i,r){let a={parentTile:null,parentScaleBy:1,parentTopLeft:[0,0],fadeValues:{tileOpacity:1,parentTileOpacity:1,fadeMix:{opacity:1,mix:0}}};if(i===0||r)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:eF(e,n,i)}}return e.selfFading?{parentTile:null,parentScaleBy:1,parentTopLeft:[0,0],fadeValues:tF(e,i)}:a}function eF(e,t,i){let r=Te(),a=(r-e.timeAdded)/i,n=(r-t.timeAdded)/i,s=e.fadingDirection===1,o=ee(a,0,1),l=ee(1-n,0,1),u=s?o:l;return{tileOpacity:u,parentTileOpacity:s?l:o,fadeMix:{opacity:1,mix:1-u}}}function tF(e,t){let i=(Te()-e.timeAdded)/t,r=ee(i,0,1);return{tileOpacity:r,fadeMix:{opacity:r,mix:0}}}function iF(e,t,i,r,a){let n=i.paint.get("background-color"),s=i.paint.get("background-opacity");if(s===0)return;let{isRenderingToTexture:o}=a,l=e.context,u=l.gl,h=e.style.projection,c=e.transform,d=c.tileSize,p=i.paint.get("background-pattern");if(e.isPatternMissing(p))return;let f=!p&&n.a===1&&s===1&&e.opaquePassEnabledForLayer()?"opaque":"translucent";if(a.currentPass!==f)return;let m=ve.disabled,g=e.getDepthModeForSublayer(0,f==="opaque"?de.ReadWrite:de.ReadOnly),_=e.colorModeForRenderPass(),y=e.useProgram(p?"backgroundPattern":"background"),x=r||en(c,{tileSize:d,terrain:e.style.map.terrain});p&&(l.activeTexture.set(u.TEXTURE0),e.patternAtlas.bind(e.context));let v=i.getCrossfadeParameters();for(let w of x){let b=c.getProjectionData({overscaledTileID:w,applyGlobeMatrix:!o,applyTerrainMatrix:!0}),T=p?R3(s,e,p,{tileID:w,tileSize:d},v):F3(s,n),P=e.getTerrainDataForTile(w,o),S=h.getMeshFromTileID(l,w.canonical,!1,!0,"raster");y.draw(l,u.TRIANGLES,g,m,_,ge.backCCW,T,P,b,i.id,S.vertexBuffer,S.indexBuffer,S.segments)}}const rF=new te(1,0,0,1),aF=new te(0,1,0,1),nF=new te(0,0,1,1),sF=new te(1,0,1,1),oF=new te(0,1,1,1);function lF(e){let t=e.transform.padding;V0(e,e.transform.height-(t.top||0),3,rF),V0(e,t.bottom||0,3,aF),j0(e,t.left||0,3,nF),j0(e,e.transform.width-(t.right||0),3,sF);let i=e.transform.centerPoint;uF(e,i.x,e.transform.height-i.y,oF)}function uF(e,t,i,r){Ml(e,t-1,i-10,2,20,r),Ml(e,t-10,i-1,20,2,r)}function V0(e,t,i,r){Ml(e,0,t+i/2,e.transform.width,i,r)}function j0(e,t,i,r){Ml(e,t-i/2,0,i,e.transform.height,r)}function Ml(e,t,i,r,a,n){let s=e.context,o=s.gl;o.enable(o.SCISSOR_TEST),o.scissor(t*e.pixelRatio,i*e.pixelRatio,r*e.pixelRatio,a*e.pixelRatio),s.clear({color:n}),o.disable(o.SCISSOR_TEST)}function hF(e,t,i){for(let r of i)cF(e,t,r)}function cF(e,t,i){var _,y;let r=e.context,a=r.gl,n=e.useProgram("debug"),s=de.disabled,o=ve.disabled,l=e.colorModeForRenderPass(),u="$debug",h=(_=e.style.map.terrain)==null?void 0:_.getTerrainData(i);r.activeTexture.set(a.TEXTURE0);let c=((y=t.getTileByID(i.key).latestRawTileData)==null?void 0:y.byteLength)||0,d=Math.floor(c/1024),p=t.getTile(i).tileSize,f=512/Math.min(p,512)*(i.overscaledZ/e.transform.zoom)*.5,m=i.canonical.toString();i.overscaledZ!==i.canonical.z&&(m+=` => ${i.overscaledZ}`),dF(e,`${m} ${d}kB`);let g=e.transform.getProjectionData({overscaledTileID:i,applyGlobeMatrix:!0,applyTerrainMatrix:!0});n.draw(r,a.TRIANGLES,s,o,Ke.alphaBlended,ge.disabled,v0(te.transparent,f),null,g,u,e.debugBuffer,e.quadTriangleIndexBuffer,e.debugSegments),n.draw(r,a.LINE_STRIP,s,o,l,ge.disabled,v0(te.red),h,g,u,e.debugBuffer,e.tileBorderIndexBuffer,e.debugSegments)}function dF(e,t){e.initDebugOverlayCanvas();let i=e.debugOverlayCanvas,r=e.context.gl,a=e.debugOverlayCanvas.getContext("2d");a.clearRect(0,0,i.width,i.height),a.shadowColor="white",a.shadowBlur=2,a.lineWidth=1.5,a.strokeStyle="white",a.textBaseline="top",a.font="bold 36px Open Sans, sans-serif",a.fillText(t,5,5),a.strokeText(t,5,5),e.debugOverlayTexture.update(i),e.debugOverlayTexture.bind(r.LINEAR,r.CLAMP_TO_EDGE)}function pF(e,t){let i=null,r=Object.values(e._layers).flatMap(o=>o.source&&!o.isHidden(t)?[e.tileManagers[o.source]]:[]),a=r.filter(o=>o.getSource().type==="vector"),n=r.filter(o=>o.getSource().type!=="vector"),s=o=>{(!i||i.getSource().maxzoom<o.getSource().maxzoom)&&(i=o)};for(let o of a)s(o);if(!i)for(let o of n)s(o);return i}function fF(e,t,i,r){let{isRenderingGlobe:a}=r,n=e.context,s=i.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 Pt(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(r.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(r.currentPass==="translucent"){e.setCustomLayerDefaults(),n.setColorMode(e.colorModeForRenderPass()),n.setStencilMode(ve.disabled);let d=c==="3d"?e.getDepthModeFor3D():e.getDepthModeForSublayer(0,de.ReadOnly);n.setDepthMode(d),s.render(n.gl,h),n.setDirty(),e.setBaseState(),n.bindFramebuffer.set(null)}}function mF(e,t){let i=e.context,r=i.gl,a=e.transform,n=Ke.unblended,s=new de(r.LEQUAL,de.ReadWrite,[0,1]),o=t.tileManager.getRenderableTiles(),l=e.useProgram("terrainDepth");i.bindFramebuffer.set(t.getFramebuffer().framebuffer),i.viewport.set([0,0,e.width/devicePixelRatio,e.height/devicePixelRatio]),i.clear({color:te.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=$M(t.getSkirtLength(a.zoom));l.draw(i,r.TRIANGLES,s,ve.disabled,n,ge.backCCW,p,c,d,"terrain",h.vertexBuffer,h.indexBuffer,h.segments)}i.bindFramebuffer.set(null),i.viewport.set([0,0,e.width,e.height])}function gF(e,t,i,r){let{isRenderingGlobe:a}=r,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 i){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()),_=BM(m,g,e.style.sky,o.pitch,a),y=o.getProjectionData({overscaledTileID:c.tileID,applyTerrainMatrix:!1,applyGlobeMatrix:!0});h.draw(n,s.TRIANGLES,u,ve.disabled,l,ge.backCCW,_,f,y,"terrain",d.vertexBuffer,d.indexBuffer,d.segments)}}function U0(e,t){if(!t.mesh){let i=new Pr;i.emplaceBack(-1,-1),i.emplaceBack(1,-1),i.emplaceBack(1,1),i.emplaceBack(-1,1);let r=new Gi;r.emplaceBack(0,1,2),r.emplaceBack(0,2,3),t.mesh=new os(e.createVertexBuffer(i,ca.members),e.createIndexBuffer(r),Ne.simpleSegment(0,0,i.length,r.length))}return t.mesh}function _F(e,t){let i=e.context,r=i.gl,a=$3(t,e.transform,e.pixelRatio),n=new de(r.LEQUAL,de.ReadWrite,[0,1]),s=ve.disabled,o=e.colorModeForRenderPass(),l=e.useProgram("sky"),u=U0(i,t);l.draw(i,r.TRIANGLES,n,s,o,ge.disabled,a,null,void 0,"sky",u.vertexBuffer,u.indexBuffer,u.segments)}function yF(e,t){let i=e.getCartesianPosition();lx(i,i);let r=Si(new Float64Array(16));return e.properties.get("anchor")==="map"&&(_r(r,r,t.rollInRadians),wa(r,r,-t.pitchInRadians),_r(r,r,t.bearingInRadians),wa(r,r,t.center.lat*Math.PI/180),rp(r,r,-t.center.lng*Math.PI/180)),ux(i,i,r),i}function vF(e,t,i){let r=e.context,a=r.gl,n=e.useProgram("atmosphere"),s=new de(a.LEQUAL,de.ReadOnly,[0,1]),o=e.transform,l=yF(i,e.transform),u=o.getProjectionData({overscaledTileID:null,applyGlobeMatrix:!0,applyTerrainMatrix:!0}),h=t.properties.get("atmosphere-blend")*u.projectionTransition;if(h===0)return;let c=rn(o.worldSize,o.center.lat),d=r0(o),p=L3(l,h,d,c,o.inverseProjectionMatrix),f=U0(r,t);n.draw(r,a.TRIANGLES,s,ve.disabled,Ke.alphaBlended,ge.disabled,p,null,null,"atmosphere",f.vertexBuffer,f.indexBuffer,f.segments)}const xF={symbol:Az,circle:Rz,heatmap:kz,line:qz,fill:Wz,fillExtrusion:Hz,hillshade:Xz,colorRelief:Kz,raster:Jz,background:iF,sky:_F,atmosphere:vF,custom:fF,debug:hF,debugPadding:lF,terrainDepth:mF};function bF(e,t,i){let r=(t==null?void 0:t.transitionState)??0;return{currentPass:"offscreen",currentLayer:0,opaquePassCutoff:1/0,depthRangeFor3D:[0,1],isRenderingToTexture:!1,transform:e,terrain:i,projectionTransition:r,isRenderingGlobe:r>0}}var wF=(ya=class{constructor(t,i){this.drawFunctions=xF,this.context=new Ez(t),this.transform=i,this.layerOpacityFbo=null,this._tileTextures={},this._rttObjectRecyclePool=[],this._rttSharedFbo=null,this.terrainFacilitator={depthDirty:!0,matrix:Si(new Float64Array(16)),renderTime:0},this.setup(),this.numSublayers=Oc.maxOverzooming+Oc.maxUnderzooming+1,this.depthEpsilon=1/2**16,this.crossTileSymbolIndex=new jy}resize(t,i,r){if(this.width=Math.floor(t*r),this.height=Math.floor(i*r),this.pixelRatio=r,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,i=new Pr;i.emplaceBack(0,0),i.emplaceBack(k,0),i.emplaceBack(0,k),i.emplaceBack(k,k),this.tileExtentBuffer=t.createVertexBuffer(i,ca.members),this.tileExtentSegments=Ne.simpleSegment(0,0,4,2);let r=new Pr;r.emplaceBack(0,0),r.emplaceBack(k,0),r.emplaceBack(0,k),r.emplaceBack(k,k),this.debugBuffer=t.createVertexBuffer(r,ca.members),this.debugSegments=Ne.simpleSegment(0,0,4,5);let a=new y2;a.emplaceBack(0,0,0,0),a.emplaceBack(k,0,k,0),a.emplaceBack(0,k,0,k),a.emplaceBack(k,k,k,k),this.rasterBoundsBuffer=t.createVertexBuffer(a,zM.members),this.rasterBoundsSegments=Ne.simpleSegment(0,0,4,2);let n=new Pr;n.emplaceBack(0,0),n.emplaceBack(k,0),n.emplaceBack(0,k),n.emplaceBack(k,k),this.rasterBoundsBufferPosOnly=t.createVertexBuffer(n,ca.members),this.rasterBoundsSegmentsPosOnly=Ne.simpleSegment(0,0,4,5);let s=new Pr;s.emplaceBack(0,0),s.emplaceBack(1,0),s.emplaceBack(0,1),s.emplaceBack(1,1),this.viewportBuffer=t.createVertexBuffer(s,ca.members),this.viewportSegments=Ne.simpleSegment(0,0,4,2);let o=new I2;o.emplaceBack(0),o.emplaceBack(1),o.emplaceBack(3),o.emplaceBack(2),o.emplaceBack(0),this.tileBorderIndexBuffer=t.createIndexBuffer(o);let l=new Gi;l.emplaceBack(1,0,2),l.emplaceBack(1,2,3),this.quadTriangleIndexBuffer=t.createIndexBuffer(l);let u=this.context.gl;this.stencilClearMode=new ve({func:u.ALWAYS,mask:0},0,255,u.ZERO,u.ZERO,u.ZERO),this.tileExtentMesh=new os(this.tileExtentBuffer,this.quadTriangleIndexBuffer,this.tileExtentSegments)}clearStencil(){let t=this.context,i=t.gl;this.nextStencilID=1,this.currentStencilSource=void 0;let r=gr();Ri(r,0,this.width,this.height,0,0,1),Tt(r,r,[i.drawingBufferWidth,i.drawingBufferHeight,0]);let a={mainMatrix:r,tileMercatorCoords:[0,0,1,1],clippingPlane:[0,0,0,0],projectionTransition:0,fallbackMatrix:r,clipAntimeridian:!1};this.useProgram("clippingMask",null,!0).draw(t,i.TRIANGLES,de.disabled,this.stencilClearMode,Ke.disabled,ge.disabled,null,null,a,"$clipping",this.viewportBuffer,this.quadTriangleIndexBuffer,this.viewportSegments)}renderTileClippingMasks(t,i,r){if(this.currentStencilSource===t.source||!t.isTileClipped()||!(i!=null&&i.length))return;this.currentStencilSource=t.source,this.nextStencilID+i.length>256&&this.clearStencil();let a=this.context;a.setColorMode(Ke.disabled),a.setDepthMode(de.disabled);let n={};for(let s of i)n[s.key]=this.nextStencilID++;this.style.projection.useSubdivision&&this._renderTileMasks(n,i,r,!0),this._renderTileMasks(n,i,r,!1),this._tileClippingMaskIDs=n}_renderTileMasks(t,i,r,a){let n=this.context,s=n.gl,o=this.style.projection,l=this.transform,u=this.useProgram("clippingMask");for(let h of i){let c=t[h.key],d=this.getTerrainDataForTile(h,r),p=o.getMeshFromTileID(this.context,h.canonical,a,!0,"stencil"),f=l.getProjectionData({overscaledTileID:h,applyGlobeMatrix:!r,applyTerrainMatrix:!0});u.draw(n,s.TRIANGLES,de.disabled,new ve({func:s.ALWAYS,mask:0},c,255,s.KEEP,s.KEEP,s.REPLACE),Ke.disabled,r?ge.disabled:ge.backCCW,null,d,f,"$clipping",p.vertexBuffer,p.indexBuffer,p.segments)}}getTerrainDataForTile(t,i){var r,a;return i&&((r=this.style.projection)==null?void 0:r.name)==="mercator"?null:((a=this.style.map.terrain)==null?void 0:a.getTerrainData(t))||null}_renderTilesDepthBuffer(){var l;let t=this.context,i=t.gl,r=this.style.projection,a=this.transform,n=this.useProgram("depth"),s=this.getDepthModeFor3D(),o=en(a,{tileSize:a.tileSize});for(let u of o){let h=(l=this.style.map.terrain)==null?void 0:l.getTerrainData(u),c=r.getMeshFromTileID(this.context,u.canonical,!0,!0,"raster"),d=a.getProjectionData({overscaledTileID:u,applyGlobeMatrix:!0,applyTerrainMatrix:!0});n.draw(t,i.TRIANGLES,s,ve.disabled,Ke.disabled,ge.backCCW,null,h,d,"$clipping",c.vertexBuffer,c.indexBuffer,c.segments)}}stencilModeFor3D(){this.currentStencilSource=void 0,this.nextStencilID+1>256&&this.clearStencil();let t=this.nextStencilID++,i=this.context.gl;return new ve({func:i.NOTEQUAL,mask:255},t,255,i.KEEP,i.KEEP,i.REPLACE)}stencilModeForClipping(t){let i=this.context.gl;return new ve({func:i.EQUAL,mask:255},this._tileClippingMaskIDs[t.key],0,i.KEEP,i.KEEP,i.REPLACE)}getStencilConfigForOverlapAndUpdateStencilID(t){let i=this.context.gl,r=t.sort((s,o)=>o.overscaledZ-s.overscaledZ),a=r[r.length-1].overscaledZ,n=r[0].overscaledZ-a+1;if(n>1){this.currentStencilSource=void 0,this.nextStencilID+n>256&&this.clearStencil();let s={};for(let o=0;o<n;o++)s[o+a]=new ve({func:i.GEQUAL,mask:255},o+this.nextStencilID,255,i.KEEP,i.KEEP,i.REPLACE);return this.nextStencilID+=n,[s,r]}return[{[a]:ve.disabled},r]}stencilConfigForOverlapTwoPass(t){let i=this.context.gl,r=t.sort((s,o)=>o.overscaledZ-s.overscaledZ),a=r[r.length-1].overscaledZ,n=r[0].overscaledZ-a+1;if(this.clearStencil(),n>1){let s={},o={};for(let l=0;l<n;l++)s[l+a]=new ve({func:i.GREATER,mask:255},n+1+l,255,i.KEEP,i.KEEP,i.REPLACE),o[l+a]=new ve({func:i.GREATER,mask:255},1+l,255,i.KEEP,i.KEEP,i.REPLACE);return this.nextStencilID=n*2+1,[s,o,r]}return this.nextStencilID=3,[{[a]:new ve({func:i.GREATER,mask:255},2,255,i.KEEP,i.KEEP,i.REPLACE)},{[a]:new ve({func:i.GREATER,mask:255},1,255,i.KEEP,i.KEEP,i.REPLACE)},r]}colorModeForRenderPass(){let t=this.context.gl;if(this._showOverdrawInspector){let i=.125;return new Ke([t.CONSTANT_COLOR,t.ONE],new te(i,i,i,0),[!0,!0,!0,!0])}return this.renderOptions.currentPass==="opaque"?Ke.unblended:Ke.alphaBlended}getDepthModeForSublayer(t,i,r){if(!this.opaquePassEnabledForLayer())return de.disabled;let a=1-((1+this.renderOptions.currentLayer)*this.numSublayers+t)*this.depthEpsilon;return new de(r||this.context.gl.LEQUAL,i,[a,a])}getDepthModeFor3D(){return new de(this.context.gl.LEQUAL,de.ReadWrite,this.renderOptions.depthRangeFor3D)}opaquePassEnabledForLayer(){return this.renderOptions.currentLayer<this.renderOptions.opaquePassCutoff}render(t,i){var h;this.style=t,this.options=i;let r=this.renderOptions=bF(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(Te()),Sz(this.context.frameUniformBuffer,this),this.imageManager.beginFrame();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()}r.opaquePassCutoff=1/0;for(let c=0;c<a.length;c++){let d=a[c];if(this.style._layers[d].is3D()){r.opaquePassCutoff=c;break}}this.maybeDrawDepth(),this.renderToTexture&&(this.renderToTexture.prepareForRender(this.style,this.transform.zoom),r.opaquePassCutoff=0),r.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,r)}if(this.context.viewport.set([0,0,this.width,this.height]),this.context.bindFramebuffer.set(null),this.context.clear({color:i.showOverdrawInspector?te.black:te.transparent,depth:1}),this.clearStencil(),this.style.sky&&this.drawFunctions.sky(this,this.style.sky),this._showOverdrawInspector=i.showOverdrawInspector,r.depthRangeFor3D=[0,1-(t._order.length+2)*this.numSublayers*this.depthEpsilon],!this.renderToTexture)for(r.currentPass="opaque",r.currentLayer=a.length-1;r.currentLayer>=0;r.currentLayer--){let c=this.style._layers[a[r.currentLayer]],d=n[c.source],p=s[c.source];this.renderTileClippingMasks(c,p,!1),this.renderLayer(this,d,c,p,r)}r.currentPass="translucent";let u=!1;for(r.currentLayer=0;r.currentLayer<a.length;r.currentLayer++){let c=this.style._layers[a[r.currentLayer]],d=n[c.source];if((h=this.renderToTexture)!=null&&h.renderLayer(c,r))continue;!this.opaquePassEnabledForLayer()&&!u&&(u=!0,r.isRenderingGlobe&&!this.style.map.terrain&&this._renderTilesDepthBuffer());let p=(c.type==="symbol"?l:o)[c.source];this.renderTileClippingMasks(c,s[c.source],!!this.renderToTexture),this.renderLayer(this,d,c,p,r)}if(r.isRenderingGlobe&&this.drawFunctions.atmosphere(this,this.style.sky,this.style.light),this.options.showTileBoundaries){let c=pF(this.style,this.transform.zoom);c&&this.drawFunctions.debug(this,c,c.getVisibleCoordinates())}this.options.showPadding&&this.drawFunctions.debugPadding(this),this.context.setDefault()}maybeDrawDepth(){var a,n;if(!((n=(a=this.style)==null?void 0:a.map)!=null&&n.terrain))return;let t=this.terrainFacilitator.matrix,i=this.transform.modelViewProjectionMatrix,r=this.terrainFacilitator.depthDirty;r||(r=!sx(t,i)),r||(r=this.style.map.terrain.tileManager.anyTilesAfterTime(this.terrainFacilitator.renderTime)),r&&(tx(t,i),this.terrainFacilitator.renderTime=Te(),this.terrainFacilitator.depthDirty=!1,this.drawFunctions.terrainDepth(this,this.style.map.terrain))}renderLayer(t,i,r,a,n){if(r.isHidden(this.transform.zoom)||r.type!=="background"&&r.type!=="custom"&&!(a||[]).length)return;this.id=r.id;let s=this.drawFunctions;qg(r)?s.symbol(t,i,r,a,this.style.placement.variableOffsets,n):aT(r)?s.circle(t,i,r,a,n):uT(r)?s.heatmap(t,i,r,a,n):NS(r)?s.line(t,i,r,a,n):eS(r)?s.fill(t,i,r,a,n):TS(r)?s.fillExtrusion(t,i,r,a,n):fT(r)?s.hillshade(t,i,r,a,n):xT(r)?s.colorRelief(t,i,r,a,n):Ku(r)?s.raster(t,i,r,a,n):iP(r)?s.background(t,i,r,a,n):nP(r)&&s.custom(t,i,r,n)}saveTileTexture(t){let i=this._tileTextures[t.size[0]];i?i.length<ya.MAX_TEXTURE_POOL_SIZE_PER_BUCKET?i.push(t):t.destroy():this._tileTextures[t.size[0]]=[t]}getTileTexture(t){let i=this._tileTextures[t];return i&&i.length>0?i.pop():null}acquireRTT(t){let i=this.context.gl,r=this._rttObjectRecyclePool.pop();if(r)return r.size!==t&&(r.texture.update({width:t,height:t,data:null},{premultiply:!1,useMipmap:!0}),r.texture.bind(i.LINEAR,i.CLAMP_TO_EDGE,i.LINEAR_MIPMAP_LINEAR),this.context.extTextureFilterAnisotropic&&i.texParameterf(i.TEXTURE_2D,this.context.extTextureFilterAnisotropic.TEXTURE_MAX_ANISOTROPY_EXT,this.context.extTextureFilterAnisotropicMax),r.size=t),r;let a=new lt(this.context,{width:t,height:t,data:null},i.RGBA,{premultiply:!1,useMipmap:!0});return a.bind(i.LINEAR,i.CLAMP_TO_EDGE,i.LINEAR_MIPMAP_LINEAR),this.context.extTextureFilterAnisotropic&&i.texParameterf(i.TEXTURE_2D,this.context.extTextureFilterAnisotropic.TEXTURE_MAX_ANISOTROPY_EXT,this.context.extTextureFilterAnisotropicMax),{texture:a,size:t}}bindRTT(t){let i=this.context.gl,r=t.size;if(!this._rttSharedFbo){let a=this.context.createFramebuffer(r,r,!0,!0),n=this.context.createRenderbuffer(i.DEPTH_STENCIL,r,r);a.depthAttachment.set(n),this._rttSharedFbo={fbo:a,depthRenderbuffer:n,size:r}}this._rttSharedFbo.size!==r&&(this.context.bindRenderbuffer.set(this._rttSharedFbo.depthRenderbuffer),i.renderbufferStorage(i.RENDERBUFFER,i.DEPTH_STENCIL,r,r),this.context.bindRenderbuffer.set(null),this._rttSharedFbo.fbo.width=r,this._rttSharedFbo.fbo.height=r,this._rttSharedFbo.size=r),this._rttSharedFbo.fbo.colorAttachment.set(t.texture.texture),this.context.bindFramebuffer.set(this._rttSharedFbo.fbo.framebuffer)}releaseRTT(t){this._rttObjectRecyclePool.push(t)}isPatternMissing(t){if(!t)return!1;if(!t.from||!t.to)return!0;let i=this.patternAtlas.getPattern(t.from.toString()),r=this.patternAtlas.getPattern(t.to.toString());return!i||!r}useProgram(t,i,r=!1,a=[]){var m;this.cache||(this.cache={});let n=!!this.style.map.terrain,s=this.style.projection,o=r?Wi.projectionMercator:s.shaderPreludeCode,l=r?Gy:s.shaderDefine,u=`/${r?Zy:s.shaderVariantName}`,h=i?i.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 qM(this.context,Wi[t],i,O3[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 lt(this.context,this.debugOverlayCanvas,t.RGBA)}}destroy(){var t,i,r;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={}}for(let a of this._rttObjectRecyclePool)a.texture.destroy();if(this._rttObjectRecyclePool=[],this._rttSharedFbo){this._rttSharedFbo.fbo.colorAttachment.set(null),this._rttSharedFbo.fbo.depthAttachment.set(null);let a=this.context.gl;a.deleteRenderbuffer(this._rttSharedFbo.depthRenderbuffer),a.deleteFramebuffer(this._rttSharedFbo.fbo.framebuffer),this._rttSharedFbo=null}if((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&&((i=this.tileExtentMesh.vertexBuffer)==null||i.destroy()),this.tileExtentMesh&&((r=this.tileExtentMesh.indexBuffer)==null||r.destroy()),this.debugOverlayTexture&&this.debugOverlayTexture.destroy(),this.context.projectionUniformBuffer.destroy(),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:i}=this.context.gl;return this.width!==t||this.height!==i}},ya.MAX_TEXTURE_POOL_SIZE_PER_BUCKET=50,ya),G0=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 Z0(e,t){let i=!1,r=null,a,n=()=>{r=null,i&&(i=(e(...a),r=setTimeout(n,t),!1))};return(...s)=>(i=!0,a=s,r||n(),r)}var q0=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 i=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:i,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 i=decodeURIComponent(t.toString()).replace(/=&/g,"&").replace(/=$/g,""),r=i?`#${i}`:"",a=window.location.href.replace(/(#.+)?$/,r);a=a.replace("&&","&"),window.history.replaceState(window.history.state,null,a)},this._updateHash=Z0(this._updateHashUnthrottled,300),this._hashName=e&&encodeURIComponent(e)}addTo(e){return this._map=e,addEventListener("hashchange",this._onHashChange,!1),this._map.on("moveend",this._updateHash),this}remove(){return removeEventListener("hashchange",this._onHashChange,!1),this._map.off("moveend",this._updateHash),clearTimeout(this._updateHash()),this._removeHash(),delete this._map,this}getHashString(e){let t=this._map.getCenter(),i=Math.round(this._map.getZoom()*100)/100,r=10**Math.ceil((i*Math.LN2+Math.log(512/360/.5))/Math.LN10),a=Math.round(t.lng*r)/r,n=Math.round(t.lat*r)/r,s=this._map.getBearing(),o=this._map.getPitch(),l="";if(l+=e?`/${a}/${n}/${i}`:`${i}/${n}/${a}`,(s||o)&&(l+=`/${Math.round(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 W(+e[2],+e[1])}catch{return!1}let t=+e[0],i=+(e[3]||0),r=+(e[4]||0);return t>=this._map.getMinZoom()&&t<=this._map.getMaxZoom()&&i>=-180&&i<=180&&r>=this._map.getMinPitch()&&r<=this._map.getMaxPitch()}};const fs={linearity:.3,easing:Jl(0,0,.3,1)},TF=Z({deceleration:2500,maxSpeed:1400},fs),SF=Z({deceleration:20,maxSpeed:1400},fs),EF=Z({deceleration:1e3,maxSpeed:360},fs),PF=Z({deceleration:1e3,maxSpeed:90},fs),CF=Z({deceleration:1e3,maxSpeed:360},fs);var AF=class{constructor(e){this._map=e,this.clear()}clear(){this._inertiaBuffer=[]}record(e){this._drainInertiaBuffer(),this._inertiaBuffer.push({time:Te(),settings:e})}_drainInertiaBuffer(){let e=this._inertiaBuffer,t=Te();for(;e.length>0&&t-e[0].time>160;)e.shift()}_getVelocityEntries(){let e=this._inertiaBuffer,t=Te()-60,i=Math.max(0,e.length-2);for(;i>0&&e[i-1].time>=t;)i--;return e.slice(i)}_onMoveEnd(e){this._drainInertiaBuffer();let t=this._getVelocityEntries();if(t.length<2){this.clear();return}let i={zoom:0,bearing:0,pitch:0,roll:0,pan:new C(0,0),pinchAround:void 0,around:void 0};for(let{settings:n}of t)n.around&&(i.around=n.around),n.pinchAround&&(i.pinchAround=n.pinchAround);for(let{settings:n}of t.slice(1))i.zoom+=n.zoomDelta||0,i.bearing+=n.bearingDelta||0,i.pitch+=n.pitchDelta||0,i.roll+=n.rollDelta||0,n.panDelta&&i.pan._add(n.panDelta);if(!i.pan.mag()&&!i.zoom&&!i.bearing&&!i.pitch&&!i.roll){this.clear();return}let r=Te()-t[0].time,a={};if(i.pan.mag()){let n=gs(i.pan.mag(),r,Z({},TF,e||{})),s=i.pan.mult(n.amount/i.pan.mag()),o=this._map._camera.cameraHelper.handlePanInertia(s,this._map._camera.transform);a.center=o.easingCenter,a.offset=o.easingOffset,ms(a,n)}if(i.zoom){let n=gs(i.zoom,r,SF);a.zoom=Qt(this._map.getZoom()+n.amount,this._map.getZoomSnap(),n.amount),ms(a,n)}if(i.bearing){let n=gs(i.bearing,r,EF);a.bearing=this._map.getBearing()+ee(n.amount,-179,179),ms(a,n)}if(i.pitch){let n=gs(i.pitch,r,PF);a.pitch=this._map.getPitch()+n.amount,ms(a,n)}if(i.roll){let n=gs(i.roll,r,CF);a.roll=this._map.getRoll()+ee(n.amount,-179,179),ms(a,n)}if(a.zoom||a.bearing){let n=i.pinchAround===void 0?i.around:i.pinchAround;a.around=n?this._map.unproject(n):this._map.getCenter()}return this.clear(),Z(a,{noMoveStart:!0})}};function ms(e,t){(!e.duration||e.duration<t.duration)&&(e.duration=t.duration,e.easing=t.easing)}function gs(e,t,i){let{maxSpeed:r,linearity:a,deceleration:n}=i,s=ee(e*a/(t/1e3),-r,r),o=Math.abs(s)/(n*a);return{easing:i.easing,duration:o*1e3,amount:o/2*s}}var DF=class{constructor(e,t){this._map=e,this._clickTolerance=t.clickTolerance}reset(){delete this._mousedownPos}wheel(e){return this._firePreventable(new j_(this._map,e))}mousedown(e,t){return this._mousedownPos=t,this._firePreventable(new ai(e.type,this._map,e))}mouseup(e){this._map.fire(new ai(e.type,this._map,e))}click(e,t){this._mousedownPos&&this._mousedownPos.dist(t)>=this._clickTolerance||this._map.fire(new ai(e.type,this._map,e))}dblclick(e){return this._firePreventable(new ai(e.type,this._map,e))}mouseover(e){this._map.fire(new ai(e.type,this._map,e))}mouseout(e){this._map.fire(new ai(e.type,this._map,e))}touchstart(e){return this._firePreventable(new ss(e.type,this._map,e))}touchmove(e){this._map.fire(new ss(e.type,this._map,e))}touchend(e){this._map.fire(new ss(e.type,this._map,e))}touchcancel(e){this._map.fire(new ss(e.type,this._map,e))}_firePreventable(e){if(this._map.fire(e),e.defaultPrevented)return{}}isEnabled(){return!0}isActive(){return!1}enable(){}disable(){}},IF=class{constructor(e){this._map=e}reset(){this._delayContextMenu=!1,this._ignoreContextMenu=!0,delete this._contextMenuEvent}mousemove(e){this._map.fire(new ai(e.type,this._map,e))}mousedown(){this._delayContextMenu=!0,this._ignoreContextMenu=!1}mouseup(){this._delayContextMenu=!1,this._contextMenuEvent&&(this._map.fire(new ai("contextmenu",this._map,this._contextMenuEvent)),delete this._contextMenuEvent)}contextmenu(e){this._delayContextMenu?this._contextMenuEvent=e:this._ignoreContextMenu||this._map.fire(new ai(e.type,this._map,e)),this._map.listens("contextmenu")&&e.preventDefault()}isEnabled(){return!0}isActive(){return!1}enable(){}disable(){}},W0=class{constructor(e,t,i){this._map=e,this._tr=i,this._el=e.getCanvasContainer(),this._container=e.getContainer(),this._clickTolerance=t.clickTolerance||1,t.boxZoom&&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&&(Q.disableDrag(),this._startPos=this._lastPos=t,this._active=!0)}mousemoveWindow(e,t){if(!this._active)return;let i=t;if(this._lastPos.equals(i)||!this._box&&i.dist(this._startPos)<this._clickTolerance)return;let r=this._startPos;this._lastPos=i,this._box||(this._box=Q.create("div","maplibregl-boxzoom",this._container),this._container.classList.add("maplibregl-crosshair"),this._fireEvent("boxzoomstart",e));let a=Math.min(r.x,i.x),n=Math.max(r.x,i.x),s=Math.min(r.y,i.y),o=Math.max(r.y,i.y);this._box.style.transform=`translate(${a}px,${s}px)`,this._box.style.width=`${n-a}px`,this._box.style.height=`${o-s}px`}mouseupWindow(e,t){if(!this._active||e.button!==0)return;let i=this._startPos,r=t;if(this.reset(),Q.suppressClick(),i.x===r.x&&i.y===r.y)this._fireEvent("boxzoomcancel",e);else{if(this._map.fire(new Sc("boxzoomend",{originalEvent:e})),this._boxZoomEnd){this._boxZoomEnd(this._map,i,r,e);return}return{cameraAnimation:a=>a.fitScreenCoordinates(i,r,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)),Q.enableDrag(),delete this._startPos,delete this._lastPos}_fireEvent(e,t){return this._map.fire(new Sc(e,{originalEvent:t}))}};function gd(e,t){if(e.length!==t.length)throw Error(`The number of touches and points are not equal - touches ${e.length}, points ${t.length}`);let i={};for(let r=0;r<e.length;r++)i[e[r].identifier]=t[r];return i}function MF(e){let t=new C(0,0);for(let i of e)t._add(i);return t.div(e.length)}var zF=class{constructor(e){this.reset(),this.numTouches=e.numTouches}reset(){delete this.centroid,delete this.startTime,delete this.touches,this.aborted=!1}touchstart(e,t,i){(this.centroid||i.length>this.numTouches)&&(this.aborted=!0),!this.aborted&&(this.startTime===void 0&&(this.startTime=e.timeStamp),i.length===this.numTouches&&(this.centroid=MF(t),this.touches=gd(i,t)))}touchmove(e,t,i){if(this.aborted||!this.centroid)return;let r=gd(i,t);for(let a in this.touches){let n=this.touches[a],s=r[a];(!s||s.dist(n)>30)&&(this.aborted=!0)}}touchend(e,t,i){if((!this.centroid||e.timeStamp-this.startTime>500)&&(this.aborted=!0),i.length===0){let r=!this.aborted&&this.centroid;if(this.reset(),r)return r}}},_d=class{constructor(e){this.singleTap=new zF(e),this.numTaps=e.numTaps,this.reset()}reset(){this.lastTime=1/0,delete this.lastTap,this.count=0,this.singleTap.reset()}touchstart(e,t,i){this.singleTap.touchstart(e,t,i)}touchmove(e,t,i){this.singleTap.touchmove(e,t,i)}touchend(e,t,i){let r=this.singleTap.touchend(e,t,i);if(r){let a=e.timeStamp-this.lastTime<500,n=!this.lastTap||this.lastTap.dist(r)<30;if((!a||!n)&&this.reset(),this.count++,this.lastTime=e.timeStamp,this.lastTap=r,this.count===this.numTaps)return this.reset(),r}}},FF=class{constructor(e,t){this._tr=t,this._zoomIn=new _d({numTouches:1,numTaps:2}),this._zoomOut=new _d({numTouches:2,numTaps:1}),this.reset()}reset(){this._active=!1,this._zoomIn.reset(),this._zoomOut.reset()}touchstart(e,t,i){this._zoomIn.touchstart(e,t,i),this._zoomOut.touchstart(e,t,i)}touchmove(e,t,i){this._zoomIn.touchmove(e,t,i),this._zoomOut.touchmove(e,t,i)}touchend(e,t,i){let r=this._zoomIn.touchend(e,t,i),a=this._zoomOut.touchend(e,t,i),n=this._tr;if(r)return this._active=!0,e.preventDefault(),setTimeout(()=>this.reset(),0),{cameraAnimation:s=>s.easeTo({duration:300,zoom:Qt(n.zoom+1,s.getZoomSnap()),around:n.unproject(r)},{originalEvent:e})};if(a)return this._active=!0,e.preventDefault(),setTimeout(()=>this.reset(),0),{cameraAnimation:s=>s.easeTo({duration:300,zoom:Qt(n.zoom-1,s.getZoomSnap()),around:n.unproject(a)},{originalEvent:e})}}touchcancel(){this.reset()}enable(){this._enabled=!0}disable(){this._enabled=!1,this.reset()}isEnabled(){return this._enabled}isActive(){return this._active}},_s=class{constructor(e){this._enabled=!!e.enable,this._moveStateManager=e.moveStateManager,this._clickTolerance=e.clickTolerance||1,this._moveFunction=e.move,this._activateOnStart=!!e.activateOnStart,e.assignEvents(this),this.reset()}reset(e){this._active=!1,this._moved=!1,delete this._lastPoint,this._moveStateManager.endMove(e)}_move(...e){let t=this._moveFunction(...e);if(t.bearingDelta||t.pitchDelta||t.rollDelta||t.around||t.panDelta)return this._active=!0,t}dragStart(e,t){this.isEnabled()&&!this._lastPoint&&this._moveStateManager.isValidStartEvent(e)&&(this._moveStateManager.startMove(e),this._lastPoint=Array.isArray(t)?t[0]:t,this._activateOnStart&&this._lastPoint&&(this._active=!0))}dragMove(e,t){if(!this.isEnabled())return;let i=this._lastPoint;if(!i)return;if(e.preventDefault(),!this._moveStateManager.isValidMoveEvent(e)){this.reset(e);return}let r=Array.isArray(t)?t[0]:t;if(!(!this._moved&&r.dist(i)<this._clickTolerance))return this._moved=!0,this._lastPoint=r,this._move(i,r)}dragEnd(e){this.isEnabled()&&this._lastPoint&&this._moveStateManager.isValidEndEvent(e)&&(this._moved&&Q.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 RF={0:1,2:2};function kF(e,t){let i=RF[t];return e.buttons===void 0||(e.buttons&i)!==i}var ys=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!kF(e,this._eventButton)}isValidEndEvent(e){return e.button===this._eventButton}},LF=class{constructor(){this._firstTouch=void 0}_isOneFingerTouch(e){return e.targetTouches.length===1}_isSameTouchEvent(e){return e.targetTouches[0].identifier===this._firstTouch}startMove(e){this._firstTouch=e.targetTouches[0].identifier}endMove(e){delete this._firstTouch}isValidStartEvent(e){return this._isOneFingerTouch(e)}isValidMoveEvent(e){return this._isOneFingerTouch(e)&&this._isSameTouchEvent(e)}isValidEndEvent(e){return this._isOneFingerTouch(e)&&this._isSameTouchEvent(e)}},BF=class{constructor(e=new ys({checkCorrectEvent:()=>!0}),t=new LF){this.mouseMoveStateManager=e,this.oneFingerTouchMoveStateManager=t}_executeRelevantHandler(e,t,i){if(e instanceof MouseEvent)return t(e);if(typeof TouchEvent<"u"&&e instanceof TouchEvent)return i(e)}startMove(e){this._executeRelevantHandler(e,t=>{this.mouseMoveStateManager.startMove(t)},t=>{this.oneFingerTouchMoveStateManager.startMove(t)})}endMove(e){this._executeRelevantHandler(e,t=>{this.mouseMoveStateManager.endMove(t)},t=>{this.oneFingerTouchMoveStateManager.endMove(t)})}isValidStartEvent(e){return!!this._executeRelevantHandler(e,t=>this.mouseMoveStateManager.isValidStartEvent(t),t=>this.oneFingerTouchMoveStateManager.isValidStartEvent(t))}isValidMoveEvent(e){return!!this._executeRelevantHandler(e,t=>this.mouseMoveStateManager.isValidMoveEvent(t),t=>this.oneFingerTouchMoveStateManager.isValidMoveEvent(t))}isValidEndEvent(e){return!!this._executeRelevantHandler(e,t=>this.mouseMoveStateManager.isValidEndEvent(t),t=>this.oneFingerTouchMoveStateManager.isValidEndEvent(t))}};const zl=e=>{e.mousedown=e.dragStart,e.mousemoveWindow=e.dragMove,e.mouseup=e.dragEnd,e.contextmenu=t=>{t.preventDefault()}};function $F({enable:e,clickTolerance:t}){return new _s({clickTolerance:t,move:(i,r)=>({around:r,panDelta:r.sub(i)}),activateOnStart:!0,moveStateManager:new ys({checkCorrectEvent:i=>i.button===0&&!i.ctrlKey}),enable:e,assignEvents:zl})}function OF({enable:e,clickTolerance:t,aroundCenter:i=!0,minPixelCenterThreshold:r=100,rotateSpeed:a=.8},n){return new _s({clickTolerance:t,move:(s,o)=>{let l=n();if(i&&Math.abs(l.y-s.y)>r)return{bearingDelta:vp(new C(s.x,o.y),o,l)};let u=(o.x-s.x)*a;return i&&o.y<l.y&&(u=-u),{bearingDelta:u}},moveStateManager:new ys({checkCorrectEvent:s=>s.button===0&&s.ctrlKey||s.button===2&&!s.ctrlKey}),enable:e,assignEvents:zl})}function NF({enable:e,clickTolerance:t,pitchSpeed:i=-.5}){return new _s({clickTolerance:t,move:(r,a)=>({pitchDelta:(a.y-r.y)*i}),moveStateManager:new ys({checkCorrectEvent:r=>r.button===0&&r.ctrlKey||r.button===2}),enable:e,assignEvents:zl})}function VF({enable:e,clickTolerance:t,rollDegreesPerPixelMoved:i=.3},r){return new _s({clickTolerance:t,move:(a,n)=>{let s=r(),o=(n.x-a.x)*i;return n.y<s.y&&(o=-o),{rollDelta:o}},moveStateManager:new ys({checkCorrectEvent:a=>a.button===2&&a.ctrlKey}),enable:e,assignEvents:zl})}var jF=class{constructor(e,t){this._clickTolerance=e.clickTolerance||1,this._map=t,this.reset()}reset(){this._active=!1,this._touches={},this._sum=new C(0,0)}_shouldBePrevented(e){return e<(this._map.cooperativeGestures.isEnabled()?2:1)}touchstart(e,t,i){return this._calculateTransform(e,t,i)}touchmove(e,t,i){if(this._active){if(this._shouldBePrevented(i.length)){this._map.cooperativeGestures.notifyGestureBlocked("touch_pan",e);return}return e.preventDefault(),this._calculateTransform(e,t,i)}}touchend(e,t,i){this._calculateTransform(e,t,i),this._active&&this._shouldBePrevented(i.length)&&this.reset()}touchcancel(){this.reset()}_calculateTransform(e,t,i){i.length>0&&(this._active=!0);let r=gd(i,t),a=new C(0,0),n=new C(0,0),s=0;for(let l in r){let u=r[l],h=this._touches[l];h&&(a._add(u),n._add(u.sub(h)),s++,r[l]=u)}if(this._touches=r,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}},yd=class{constructor(){this.reset()}reset(){this._active=!1,delete this._firstTwoTouches}touchstart(e,t,i){this._firstTwoTouches||i.length<2||(this._firstTwoTouches=[i[0].identifier,i[1].identifier],this._start([t[0],t[1]]))}touchmove(e,t,i){if(!this._firstTwoTouches)return;e.preventDefault();let[r,a]=this._firstTwoTouches,n=Fl(i,t,r),s=Fl(i,t,a);if(!n||!s)return;let o=this._aroundCenter?null:n.add(s).div(2);return this._move([n,s],o,e)}touchend(e,t,i){if(!this._firstTwoTouches)return;let[r,a]=this._firstTwoTouches,n=Fl(i,t,r),s=Fl(i,t,a);n&&s||(this._active&&Q.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 Fl(e,t,i){for(let r=0;r<e.length;r++)if(e[r].identifier===i)return t[r]}const H0=.1;function X0(e,t){return Math.log(e/t)/Math.LN2}var Y0=class extends yd{constructor(){super(),this._zoomRate=1,this._zoomThreshold=H0}setZoomRate(e){this._zoomRate=e??1}setZoomThreshold(e){this._zoomThreshold=e??H0}reset(){super.reset(),delete this._distance,delete this._startDistance}_start(e){this._startDistance=this._distance=e[0].dist(e[1])}_move(e,t){let i=this._distance;if(this._distance=e[0].dist(e[1]),!(!this._active&&Math.abs(X0(this._distance,this._startDistance))<this._zoomThreshold))return this._active=!0,{zoomDelta:X0(this._distance,i)*this._zoomRate,pinchAround:t}}};function K0(e,t){return e.angleWith(t)*180/Math.PI}var J0=class extends yd{reset(){super.reset(),delete this._minDiameter,delete this._startVector,delete this._vector}_start(e){this._startVector=this._vector=e[0].sub(e[1]),this._minDiameter=e[0].dist(e[1])}_move(e,t,i){let r=this._vector;if(this._vector=e[0].sub(e[1]),this._active||!this._isBelowThreshold(this._vector))return this._active=!0,{bearingDelta:K0(this._vector,r),pinchAround:t}}_isBelowThreshold(e){this._minDiameter=Math.min(this._minDiameter,e.mag());let t=25/(Math.PI*this._minDiameter)*360,i=K0(e,this._startVector);return Math.abs(i)<t}};function vd(e){return Math.abs(e.y)>Math.abs(e.x)}var Q0=class extends yd{constructor(e){super(),this._currentTouchCount=0,this._map=e}reset(){super.reset(),this._valid=void 0,delete this._firstMove,delete this._lastPoints}touchstart(e,t,i){super.touchstart(e,t,i),this._currentTouchCount=i.length}_start(e){this._lastPoints=e,vd(e[0].sub(e[1]))&&(this._valid=!1)}_move(e,t,i){if(this._map.cooperativeGestures.isEnabled()&&this._currentTouchCount<3)return;let r=e[0].sub(this._lastPoints[0]),a=e[1].sub(this._lastPoints[1]);if(this._valid=this.gestureBeginsVertically(r,a,i.timeStamp),this._valid)return this._lastPoints=e,this._active=!0,{pitchDelta:(r.y+a.y)/2*-.5}}gestureBeginsVertically(e,t,i){if(this._valid!==void 0)return this._valid;let r=e.mag()>=2,a=t.mag()>=2;if(!r&&!a)return;if(!r||!a)return this._firstMove===void 0&&(this._firstMove=i),i-this._firstMove<100&&void 0;let n=e.y>0==t.y>0;return vd(e)&&vd(t)&&n}};const UF={panStep:100,bearingStep:15,pitchStep:10};var ev=class{constructor(e,t){this._tr=t;let i=UF;this._panStep=i.panStep,this._bearingStep=i.bearingStep,this._pitchStep=i.pitchStep,this._rotationDisabled=!1}reset(){this._active=!1}keydown(e){if(e.altKey||e.ctrlKey||e.metaKey)return;let t=0,i=0,r=0,a=0,n=0;switch(e.keyCode){case 61:case 107:case 171:case 187:t=1;break;case 189:case 109:case 173:t=-1;break;case 37:e.shiftKey?i=-1:(e.preventDefault(),a=-1);break;case 39:e.shiftKey?i=1:(e.preventDefault(),a=1);break;case 38:e.shiftKey?r=1:(e.preventDefault(),n=-1);break;case 40:e.shiftKey?r=-1:(e.preventDefault(),n=1);break;default:return}return this._rotationDisabled&&(i=0,r=0),{cameraAnimation:s=>{let o=this._tr;s.easeTo({duration:300,easeId:"keyboardHandler",easing:GF,zoom:t?Qt(o.zoom+t*(e.shiftKey?2:1),s.getZoomSnap()):o.zoom,bearing:o.bearing+i*this._bearingStep,pitch:o.pitch+r*this._pitchStep,offset:[-a*this._panStep,-n*this._panStep],center:o.center},{originalEvent:e})}}}enable(){this._enabled=!0}disable(){this._enabled=!1,this.reset()}isEnabled(){return this._enabled}isActive(){return this._active}disableRotation(){this._rotationDisabled=!0}enableRotation(){this._rotationDisabled=!1}};function GF(e){return e*(2-e)}const tv=4.000244140625;var iv=class{constructor(e,t,i){this._onTimeout=r=>{this._type="wheel",this._delta-=this._lastValue,this._active||this._start(r)},this._map=e,this._tr=i,this._triggerRenderFrame=t,this._delta=0,this._defaultZoomRate=.01,this._wheelZoomRate=.0022222222222222222}setZoomRate(e){this._defaultZoomRate=e}setWheelZoomRate(e){this._wheelZoomRate=e}isEnabled(){return!!this._enabled}isActive(){return!!this._active||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,i=Te(),r=i-(this._lastWheelEventTime||0);this._lastWheelEventTime=i,t!==0&&t%tv==0?this._type="wheel":t!==0&&Math.abs(t)<4?this._type="trackpad":r>400?(this._type=null,this._lastValue=t,this._timeout=setTimeout(this._onTimeout,40,e)):this._type||(this._type=Math.abs(r*t)<200?"trackpad":"wheel",this._timeout&&(clearTimeout(this._timeout),this._timeout=null,t+=this._lastValue)),e.shiftKey&&t&&(t/=4),this._type&&(this._lastWheelEvent=e,this._delta-=t,this._active||this._start(e)),e.preventDefault()}_start(e){if(!this._delta)return;this._needsRerender=!1,this._active=!0,this.isZooming()||(this._zooming=!0),this._finishTimeout&&(clearTimeout(this._finishTimeout),delete this._finishTimeout);let t=Q.mousePos(this._map.getCanvas(),e),i=this._tr;this._aroundPoint=this._aroundCenter?i.transform.locationToScreenPoint(W.convert(i.center)):t,this._needsRerender||(this._needsRerender=!0,this._triggerRenderFrame())}renderFrame(){if(!this._needsRerender||(this._needsRerender=!1,!this.isActive()))return;let e=this._tr.transform;if(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)>tv?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(),Et(l*o)).zoom,h=this._map.getZoomSnap();if(this._type==="wheel"&&h>0){let c=Qt(e.zoom,h);this._targetZoom=Qt(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,i=this._startZoom,r=this._easing,a=!1,n;if(this._type==="wheel"&&i&&r){let s=Te()-this._lastWheelEventTime,o=Math.min((s+5)/200,1),l=r(o);n=Oe.number(i,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=Ql;if(this._prevEase){let i=this._prevEase,r=(Te()-i.start)/i.duration,a=i.easing(r+.01)-i.easing(r),n=.27/Math.sqrt(a*a+1e-4)*.01,s=Math.sqrt(.0729-n*n);t=Jl(n,s,.25,1)}return this._prevEase={start:Te(),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)}},rv=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()}},ZF=class{constructor(e,t){this._tr=t,this.reset()}reset(){this._active=!1}dblclick(e,t){return e.preventDefault(),{cameraAnimation:i=>{i.easeTo({duration:300,zoom:Qt(this._tr.zoom+(e.shiftKey?-1:1),i.getZoomSnap()),around:this._tr.unproject(t)},{originalEvent:e})}}}enable(){this._enabled=!0}disable(){this._enabled=!1,this.reset()}isEnabled(){return this._enabled}isActive(){return this._active}},qF=class{constructor(){this._tap=new _d({numTouches:1,numTaps:1}),this._zoomRate=1,this.reset()}setZoomRate(e){this._zoomRate=e??1}reset(){this._active=!1,delete this._swipePoint,delete this._swipeTouch,delete this._tapTime,delete this._tapPoint,this._tap.reset()}touchstart(e,t,i){if(!this._swipePoint)if(!this._tapTime)this._tap.touchstart(e,t,i);else{let r=t[0],a=e.timeStamp-this._tapTime<500,n=this._tapPoint.dist(r)<30;!a||!n?this.reset():i.length>0&&(this._swipePoint=r,this._swipeTouch=i[0].identifier)}}touchmove(e,t,i){if(!this._tapTime)this._tap.touchmove(e,t,i);else if(this._swipePoint){if(i[0].identifier!==this._swipeTouch)return;let r=t[0],a=r.y-this._swipePoint.y;return this._swipePoint=r,e.preventDefault(),this._active=!0,{zoomDelta:a/128*this._zoomRate}}}touchend(e,t,i){if(this._tapTime)this._swipePoint&&i.length===0&&this.reset();else{let r=this._tap.touchend(e,t,i);r&&(this._tapTime=e.timeStamp,this._tapPoint=r)}}touchcancel(){this.reset()}enable(){this._enabled=!0}disable(){this._enabled=!1,this.reset()}isEnabled(){return this._enabled}isActive(){return this._active}},av=class{constructor(e,t,i){this._el=e,this._mousePan=t,this._touchPan=i}enable(e){this._inertiaOptions=e||{},this._mousePan.enable(),this._touchPan.enable(),this._el.classList.add("maplibregl-touch-drag-pan")}disable(){this._mousePan.disable(),this._touchPan.disable(),this._el.classList.remove("maplibregl-touch-drag-pan")}isEnabled(){return this._mousePan.isEnabled()&&this._touchPan.isEnabled()}isActive(){return this._mousePan.isActive()||this._touchPan.isActive()}},nv=class{constructor(e,t,i,r){this._pitchWithRotate=e.pitchWithRotate,this._rollEnabled=e.rollEnabled,this._mouseRotate=t,this._mousePitch=i,this._mouseRoll=r}enable(){this._mouseRotate.enable(),this._pitchWithRotate&&this._mousePitch.enable(),this._rollEnabled&&this._mouseRoll.enable()}disable(){this._mouseRotate.disable(),this._mousePitch.disable(),this._mouseRoll.disable()}isEnabled(){return this._mouseRotate.isEnabled()&&(!this._pitchWithRotate||this._mousePitch.isEnabled())&&(!this._rollEnabled||this._mouseRoll.isEnabled())}isActive(){return this._mouseRotate.isActive()||this._mousePitch.isActive()||this._mouseRoll.isActive()}},sv=class{constructor(e,t,i,r){this._el=e,this._touchZoom=t,this._touchRotate=i,this._tapDragZoom=r,this._rotationDisabled=!1,this._enabled=!0}enable(e){this._touchZoom.enable(e),this._rotationDisabled||this._touchRotate.enable(e),this._tapDragZoom.enable(),this._el.classList.add("maplibregl-touch-zoom-rotate")}disable(){this._touchZoom.disable(),this._touchRotate.disable(),this._tapDragZoom.disable(),this._el.classList.remove("maplibregl-touch-zoom-rotate")}isEnabled(){return this._touchZoom.isEnabled()&&(this._rotationDisabled||this._touchRotate.isEnabled())&&this._tapDragZoom.isEnabled()}isActive(){return this._touchZoom.isActive()||this._touchRotate.isActive()||this._tapDragZoom.isActive()}setZoomRate(e){this._touchZoom.setZoomRate(e),this._tapDragZoom.setZoomRate(e)}setZoomThreshold(e){this._touchZoom.setZoomThreshold(e)}disableRotation(){this._rotationDisabled=!0,this._touchRotate.disable()}enableRotation(){this._rotationDisabled=!1,this._touchZoom.isEnabled()&&this._touchRotate.enable()}},ov=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=Q.create("div","maplibregl-cooperative-gesture-screen",e);let t=this._map._getUIString("CooperativeGesturesHandler.WindowsHelpText");this._bypassKey==="metaKey"&&(t=this._map._getUIString("CooperativeGesturesHandler.MacHelpText"));let i=this._map._getUIString("CooperativeGesturesHandler.MobileHelpText"),r=document.createElement("div");r.className="maplibregl-desktop-message",r.textContent=t,this._container.appendChild(r);let a=document.createElement("div");a.className="maplibregl-mobile-message",a.textContent=i,this._container.appendChild(a),this._container.setAttribute("aria-hidden","true")}_destroyUI(){this._container&&(this._container.remove(),this._map.getCanvasContainer().classList.remove("maplibregl-cooperative-gestures")),delete this._container}enable(){this._setupUI(),this._enabled=!0}disable(){this._enabled=!1,this._destroyUI()}isEnabled(){return this._enabled}isBypassed(e){return e[this._bypassKey]}notifyGestureBlocked(e,t){this._enabled&&(this._map.fire(new gt("cooperativegestureprevented",{gestureType:e,originalEvent:t})),this._container.classList.add("maplibregl-show"),setTimeout(()=>{this._container.classList.remove("maplibregl-show")},100))}},WF=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(C.convert(e),this._camera.terrain)}};const Rl=e=>e.zoom||e.drag||e.roll||e.pitch||e.rotate;var HF=class extends ti{};function xd(e){var t;return((t=e.panDelta)==null?void 0:t.mag())||e.zoomDelta||e.bearingDelta||e.pitchDelta||e.rollDelta}var XF=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,i){this._terrainGestureAnchorElevation=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(Vx(a,n||a.type)){let g=Q.mousePos(this._map.getCanvas(),a);m=p[n||a.type](a,g)}else if(Nx(a,n||a.type)){let g=a.touches,_=this._getMapTouches(g),y=Q.touchPos(this._map.getCanvas(),_);m=p[n||a.type](a,y,_)}else jx(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||xd(o))&&(this._changes.push([o,l,h]),this._triggerRenderFrame()),(Object.keys(u).length||xd(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 WF(this._camera),this._el=this._map.getCanvasContainer(),this._handlers=[],this._handlersById={},this._changes=[],this._inertia=new AF(e),this._bearingSnap=i.bearingSnap,this._previousActiveHandlers={},this._eventsInProgress={},this._addDefaultHandlers(i);let r=this._el;this._listeners=[[r,"touchstart",{passive:!0}],[r,"touchmove",{passive:!1}],[r,"touchend",void 0],[r,"touchcancel",void 0],[r,"mousedown",void 0],[r,"mousemove",void 0],[r,"mouseup",void 0],[this._ownerDocument,"mousemove",{capture:!0}],[this._ownerDocument,"mouseup",void 0],[r,"mouseover",void 0],[r,"mouseout",void 0],[r,"dblclick",void 0],[r,"click",void 0],[r,"keydown",{capture:!1}],[r,"keyup",void 0],[r,"wheel",{passive:!1}],[r,"contextmenu",void 0],[this._ownerWindow,"blur",void 0]];for(let[a,n,s]of this._listeners)a.addEventListener(n,a===this._ownerDocument?this.handleWindowEvent:this.handleEvent,s)}destroy(){for(let[e,t,i]of this._listeners)e.removeEventListener(t,e===this._ownerDocument?this.handleWindowEvent:this.handleEvent,i)}_addDefaultHandlers(e){let t=this._map,i=t.getCanvasContainer();this._add("mapEvent",new DF(t,e));let r=t.boxZoom=new W0(t,e,this._transformProvider);this._add("boxZoom",r),e.interactive&&e.boxZoom&&r.enable();let a=t.cooperativeGestures=new ov(t,e.cooperativeGestures);this._add("cooperativeGestures",a),e.cooperativeGestures&&a.enable();let n=new FF(t,this._transformProvider),s=new ZF(t,this._transformProvider);t.doubleClickZoom=new rv(s,n),this._add("tapZoom",n),this._add("clickZoom",s),e.interactive&&e.doubleClickZoom&&t.doubleClickZoom.enable();let o=new qF;this._add("tapDragZoom",o);let l=t.touchPitch=new Q0(t);this._add("touchPitch",l),e.interactive&&e.touchPitch&&t.touchPitch.enable(e.touchPitch);let u=()=>t.project(t.getCenter()),h=OF(e,u),c=NF(e),d=VF(e,u);t.dragRotate=new nv(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=$F(e),f=new jF(e,t);t.dragPan=new av(i,p,f),this._add("mousePan",p),this._add("touchPan",f,["touchZoom","touchRotate"]),e.interactive&&e.dragPan&&t.dragPan.enable(e.dragPan);let m=new J0,g=new Y0;t.touchZoomRotate=new sv(i,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 IF(t));let _=t.scrollZoom=new iv(t,()=>this._triggerRenderFrame(),this._transformProvider);this._add("scrollZoom",_,["mousePan"]),e.interactive&&e.scrollZoom&&t.scrollZoom.enable(e.scrollZoom);let y=t.keyboard=new ev(t,this._transformProvider);this._add("keyboard",y),e.interactive&&e.keyboard&&t.keyboard.enable()}_add(e,t,i){this._handlers.push({handlerName:e,handler:t,allowed:i}),this._handlersById[e]=t}stop(e){if(!this._updatingCamera){for(let{handler: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!!Rl(this._eventsInProgress)||this.isZooming()}_blockedByActive(e,t,i){for(let r in e)if(r!==i&&!(t!=null&&t.includes(r)))return!0;return!1}_getMapTouches(e){let t=[];for(let i of e){let r=i.target;this._el.contains(r)&&t.push(i)}return t}mergeHandlerResult(e,t,i,r,a){if(!i)return;Z(e,i);let n={handlerName:r,originalEvent:i.originalEvent||a};i.zoomDelta!==void 0&&(t.zoom=n),i.panDelta!==void 0&&(t.drag=n),i.rollDelta!==void 0&&(t.roll=n),i.pitchDelta!==void 0&&(t.pitch=n),i.bearingDelta!==void 0&&(t.rotate=n)}_applyChanges(){let e={},t={},i={};for(let[r,a,n]of this._changes)r.panDelta&&(e.panDelta=(e.panDelta||new C(0,0))._add(r.panDelta)),r.zoomDelta&&(e.zoomDelta=(e.zoomDelta||0)+r.zoomDelta),r.bearingDelta&&(e.bearingDelta=(e.bearingDelta||0)+r.bearingDelta),r.pitchDelta&&(e.pitchDelta=(e.pitchDelta||0)+r.pitchDelta),r.rollDelta&&(e.rollDelta=(e.rollDelta||0)+r.rollDelta),r.around!==void 0&&(e.around=r.around),r.pinchAround!==void 0&&(e.pinchAround=r.pinchAround),r.noInertia&&(e.noInertia=r.noInertia),Z(t,a),Z(i,n);this._updateMapTransform(e,t,i),this._changes=[]}_updateMapTransform(e,t,i){let r=this._map,a=this._camera.getTransformForUpdate(),n=r.terrain;if(!xd(e)&&!(n&&this._terrainMovement)){this._fireEvents(t,i,!0);return}this._camera.stop(!0);let{panDelta:s,zoomDelta:o,bearingDelta:l,pitchDelta:u,rollDelta:h}=e,{around:c,aroundOnSurface:d}=this._resolveAround(e,n,a),p=n?this._terrainGestureElevation(n,c,d,a,t):void 0,f={panDelta:s,zoomDelta:o,rollDelta:h,pitchDelta:u,bearingDelta:l,around:c,aroundElevation:p};this._camera.cameraHelper.useGlobeControls&&!a.isPointOnMapSurface(c)&&(c=a.centerPoint);let m=this._computePreZoomAroundLoc(a,c,s,p);this._handleMapControls({terrain:n,tr:a,deltasForHelper:f,preZoomAroundLoc:m,combinedEventsInProgress:t,panDelta:s}),this._camera.applyUpdatedTransform(a),this._map._update(),e.noInertia||this._inertia.record(e),this._fireEvents(t,i,!0)}_resolveAround(e,t,i){let r=e.pinchAround===void 0?e.around:e.pinchAround;return r||(r=this._camera.transform.centerPoint),t&&!i.isPointOnMapSurface(r)?{around:i.centerPoint,aroundOnSurface:!1}:{around:r,aroundOnSurface:!0}}_terrainGestureElevation(e,t,i,r,a){if(!i)return;if(!this._terrainMovement&&(a.drag||a.zoom)){let s=r.screenTerrainPointToMercatorCoordinate(t,e);this._terrainGestureAnchorElevation=s?s.z:null}if(this._terrainGestureAnchorElevation===null)return;let n=this._terrainGestureAnchorElevation;if(!(t.distSqr(r.centerPoint)<.01)&&!(n-r.elevation>=.9*(r.getCameraAltitude()-r.elevation)))return n}_computePreZoomAroundLoc(e,t,i,r){if(t.distSqr(e.centerPoint)<.01)return e.center;let a=i?t.sub(i):t;return r===void 0?e.screenPointToLocation(a):e.screenPointToLocationAtElevation(a,r)}_handleMapControls({terrain:e,tr:t,deltasForHelper:i,preZoomAroundLoc:r,combinedEventsInProgress:a,panDelta:n}){let s=this._camera.cameraHelper;if(s.handleMapControlsRollPitchBearingZoom(i,t),!e){s.handleMapControlsPan(i,t,r);return}if(s.useGlobeControls){!this._terrainMovement&&(a.drag||a.zoom)&&(this._terrainMovement=!0,this._camera.elevationFreeze=!0),s.handleMapControlsPan(i,t,r);return}if(!this._terrainMovement&&(a.drag||a.zoom)){this._terrainMovement=!0,this._camera.elevationFreeze=!0,s.handleMapControlsPan(i,t,r);return}if(i.aroundElevation===void 0&&a.drag&&this._terrainMovement&&n){t.setCenter(t.screenPointToLocation(t.centerPoint.sub(n)));return}s.handleMapControlsPan(i,t,r)}_fireEvents(e,t,i){let r=Rl(this._eventsInProgress),a=Rl(e),n={};for(let h in e){let{originalEvent:c}=e[h];this._eventsInProgress[h]||(n[`${h}start`]=c),this._eventsInProgress[h]=e[h]}!r&&a&&this._fireEvent("movestart",a.originalEvent);for(let h in n)this._fireEvent(h,n[h]);a&&this._fireEvent("move",a.originalEvent);for(let h in e){let{originalEvent: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=Rl(this._eventsInProgress),u=(r||a)&&!l;if(u&&this._terrainMovement){this._camera.elevationFreeze=!1,this._terrainMovement=!1,this._terrainGestureAnchorElevation=null;let h=this._camera.getTransformForUpdate();this._map.getCenterClampedToGround()&&h.recalculateZoomAndCenter(this._map.terrain),this._camera.applyUpdatedTransform(h)}if(i&&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||!jt.prefersReducedMotion)?(c(h.bearing||this._map.getBearing())&&(h.bearing=0),h.freezeElevation=!0,this._map.easeTo(h,{originalEvent:o})):(this._map.fire(new Y("moveend",{originalEvent:o})),c(this._map.getBearing())&&this._map.resetNorth()),this._updatingCamera=!1}}_fireEvent(e,t){this._map.fire(new Y(e,t?{originalEvent:t}:{}))}_requestFrame(){return this._map.triggerRepaint(),this._map._renderTaskQueue.add(e=>{delete this._frameId,this.handleEvent(new HF("renderFrame",{timeStamp:e})),this._applyChanges()})}_triggerRenderFrame(){this._frameId===void 0&&(this._frameId=this._requestFrame())}},YF=class extends ot{constructor(e){super(),this._renderFrameCallback=()=>{let t=Math.min((Te()-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 yl,this.cameraHelper=new bl,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})}migrateProjection(e,t){e.apply(this.transform,!0),this.transform=e,this.cameraHelper=t}getCenter(){return new W(this.transform.center.lng,this.transform.center.lat)}setCenter(e,t){return this.jumpTo({center:e},t)}getCenterElevation(){return this.transform.elevation}setCenterElevation(e,t){return this.jumpTo({elevation:e},t),this}getCenterClampedToGround(){return this._centerClampedToGround}setCenterClampedToGround(e){this._centerClampedToGround=e}panBy(e,t,i){return e=C.convert(e).mult(-1),this.panTo(this.transform.center,Z({offset:e},t),i)}panTo(e,t,i){return this.easeTo(Z({center:e},t),i)}getZoom(){return this.transform.zoom}setZoom(e,t){return this.jumpTo({zoom:e},t),this}zoomTo(e,t,i){return this.easeTo(Z({zoom:e},t),i)}zoomIn(e,t){return this.zoomTo(Qt(this.getZoom()+1,this._zoomSnap),e,t),this}zoomOut(e,t){return this.zoomTo(Qt(this.getZoom()-1,this._zoomSnap),e,t),this}getVerticalFieldOfView(){return this.transform.fov}setVerticalFieldOfView(e,t){return e!=this.transform.fov&&(this.transform.setFov(e),this.fire(new Y("movestart",t)).fire(new Y("move",t)).fire(new Y("moveend",t))),this}getBearing(){return this.transform.bearing}setZoomSnap(e){return this._zoomSnap=e,this}getZoomSnap(){return this._zoomSnap}setBearing(e,t){return this.jumpTo({bearing:e},t),this}getPadding(){return this.transform.padding}setPadding(e,t){return this.jumpTo({padding:e},t),this}rotateTo(e,t,i){return this.easeTo(Z({bearing:e},t),i)}resetNorth(e,t){return this.rotateTo(0,Z({duration:1e3},e),t),this}resetNorthPitch(e,t){return this.easeTo(Z({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=Mi.convert(e).adjustAntiMeridian();let i=(t==null?void 0:t.bearing)||0;return this._cameraForBoxAndBearing(e.getNorthWest(),e.getSouthEast(),i,t)}_cameraForBoxAndBearing(e,t,i,r){let a={top:0,bottom:0,right:0,left:0};if(r=Z({padding:a,offset:[0,0],maxZoom:this.transform.maxZoom},r),typeof r.padding=="number"){let u=r.padding;r.padding={top:u,bottom:u,right:u,left:u}}let n=Z(a,r.padding);r.padding=n;let s=this.transform,o=new Mi(e,t),l=this.cameraHelper.cameraForBoxAndBearing(r,n,o,i,s);return l&&this._zoomSnap&&(l.zoom=Qt(l.zoom,this._zoomSnap,-1)),l}fitBounds(e,t,i){return this._fitInternal(this.cameraForBounds(e,t),t,i)}fitScreenCoordinates(e,t,i,r,a){return this._fitInternal(this._cameraForBoxAndBearing(this.transform.screenPointToLocation(C.convert(e)),this.transform.screenPointToLocation(C.convert(t)),i,r),r,a)}_fitInternal(e,t,i){return e?(t=Z(e,t),delete t.padding,t.linear?this.easeTo(t,i):this.flyTo(t,i)):this}jumpTo(e,t){this.stop(),"zoom"in e&&this._zoomSnap&&(e.zoom=Qt(e.zoom,this._zoomSnap));let i=this.getTransformForUpdate(),r=!1,a=!1,n=!1,s=i.zoom;this.terrain&&i.setElevation(this.terrain.getElevationForLngLat(e.center?W.convert(e.center):i.center,i)),this.cameraHelper.handleJumpToCenterZoom(i,e);let o=i.zoom!==s;return"elevation"in e&&i.elevation!==+e.elevation&&i.setElevation(+e.elevation),"bearing"in e&&i.bearing!==+e.bearing&&(r=!0,i.setBearing(+e.bearing)),"pitch"in e&&i.pitch!==+e.pitch&&(a=!0,i.setPitch(+e.pitch)),"roll"in e&&i.roll!==+e.roll&&(n=!0,i.setRoll(+e.roll)),e.padding!=null&&!i.isPaddingEqual(e.padding)&&i.setPadding(e.padding),this.applyUpdatedTransform(i),this.fire(new Y("movestart",t)).fire(new Y("move",t)),o&&this.fire(new Y("zoomstart",t)).fire(new Y("zoom",t)).fire(new Y("zoomend",t)),r&&this.fire(new Y("rotatestart",t)).fire(new Y("rotate",t)).fire(new Y("rotateend",t)),a&&this.fire(new Y("pitchstart",t)).fire(new Y("pitch",t)).fire(new Y("pitchend",t)),n&&this.fire(new Y("rollstart",t)).fire(new Y("roll",t)).fire(new Y("rollend",t)),this.fire(new Y("moveend",t))}calculateCameraOptionsFromCameraLngLatAltRotation(e,t,i,r,a){let n=this.transform.calculateCenterFromCameraLngLatAlt(e,t,i,r);return{center:n.center,elevation:n.elevation,zoom:n.zoom,bearing:i,pitch:r,roll:a}}easeTo(e,t){this._stop(!1,e.easeId),e=Z({offset:[0,0],duration:500,easing:Ql},e),"zoom"in e&&this._zoomSnap&&(e.zoom=Qt(e.zoom,this._zoomSnap)),(e.animate===!1||!e.essential&&jt.prefersReducedMotion)&&(e.duration=0);let i=this.getTransformForUpdate(),r=this.getBearing(),a=i.pitch,n=i.roll,s="bearing"in e?this._normalizeBearing(e.bearing,r):r,o="pitch"in e?+e.pitch:a,l="roll"in e?this._normalizeBearing(e.roll,n):n,u="padding"in e?e.padding:i.padding,h=C.convert(e.offset),c,d;e.around&&(c=W.convert(e.around),d=i.locationToScreenPoint(c));let p={moving:this._moving,zooming:this._zooming,rotating:this._rotating,pitching:this._pitching,rolling:this._rolling},f=this.cameraHelper.handleEaseTo(i,{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=r!==s),this._pitching||(this._pitching=o!==a),this._rolling||(this._rolling=l!==n),this._padding=!i.isPaddingEqual(u),this._zooming||(this._zooming=f.isZooming),this._easeId=e.easeId,this._prepareEase(t,e.noMoveStart,p),this.terrain&&this._prepareElevation(f.elevationCenter),this._ease(m=>{f.easeFunc(m),this.terrain&&!e.freezeElevation&&this._updateElevation(m),this.applyUpdatedTransform(i),this._fireMoveEvents(t)},m=>{this.terrain&&e.freezeElevation&&this._finalizeElevation(),this._afterEase(t,m)},e),this}_prepareEase(e,t,i={}){this._moving=!0,!t&&!i.moving&&this.fire(new Y("movestart",e)),this._zooming&&!i.zooming&&this.fire(new Y("zoomstart",e)),this._rotating&&!i.rotating&&this.fire(new Y("rotatestart",e)),this._pitching&&!i.pitching&&this.fire(new Y("pitchstart",e)),this._rolling&&!i.rolling&&this.fire(new Y("rollstart",e))}_prepareElevation(e){this._elevationCenter=e,this._elevationStart=this.transform.elevation,this._elevationTarget=this.terrain.getElevationForLngLat(e,this.transform),this.elevationFreeze=!0}_updateElevation(e){(this._elevationStart===void 0||this._elevationCenter===void 0)&&this._prepareElevation(this.transform.center),this.transform.setMinElevationForCurrentTile(this.terrain.getMinTileElevationForLngLatZoom(this._elevationCenter,this.transform.tileZoom));let t=this.terrain.getElevationForLngLat(this._elevationCenter,this.transform);if(e<1&&t!==this._elevationTarget){let i=this._elevationTarget-this._elevationStart,r=(t-(i*e+this._elevationStart))/(1-e);this._elevationStart+=e*(i-r),this._elevationTarget=t}this.transform.setElevation(Oe.number(this._elevationStart,this._elevationTarget,e))}_finalizeElevation(){this.elevationFreeze=!1,this.getCenterClampedToGround()&&this.transform.recalculateZoomAndCenter(this.terrain)}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(),i=e.getCameraAltitude(),r=this.terrain?this.terrain.getElevationForLngLatZoom(t,e.zoom):0;if(i<r){let a=e.calculateCameraOptionsFromTo(t,r,e.center,e.elevation);return{pitch:a.pitch,zoom:a.zoom}}return{}}applyUpdatedTransform(e){let t=[];if(t.push(r=>this._elevateCameraIfInsideTerrain(r)),this.transformCameraUpdate&&t.push(r=>this.transformCameraUpdate(r)),!t.length)return;let i=e.clone();for(let r of t){let a=i.clone(),{center:n,zoom:s,roll:o,pitch:l,bearing:u,elevation:h}=r(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),i.apply(a,!1)}this.transform.apply(i,!1)}_fireMoveEvents(e){this.fire(new Y("move",e)),this._zooming&&this.fire(new Y("zoom",e)),this._rotating&&this.fire(new Y("rotate",e)),this._pitching&&this.fire(new Y("pitch",e)),this._rolling&&this.fire(new Y("roll",e))}_afterEase(e,t){if(this._easeId&&t&&this._easeId===t)return;delete this._easeId;let i=this._zooming,r=this._rotating,a=this._pitching,n=this._rolling;this._moving=!1,this._zooming=!1,this._rotating=!1,this._pitching=!1,this._rolling=!1,this._padding=!1,i&&this.fire(new Y("zoomend",e)),r&&this.fire(new Y("rotateend",e)),a&&this.fire(new Y("pitchend",e)),n&&this.fire(new Y("rollend",e)),this.fire(new Y("moveend",e))}flyTo(e,t){if(!e.essential&&jt.prefersReducedMotion){let I=dn(e,["center","zoom","bearing","pitch","roll","elevation","padding"]);return this.jumpTo(I,t)}this.stop(),e=Z({offset:[0,0],speed:1.2,curve:1.42,easing:Ql},e),"zoom"in e&&this._zoomSnap&&(e.zoom=Qt(e.zoom,this._zoomSnap));let i=this.getTransformForUpdate(),r=i.bearing,a=i.pitch,n=i.roll,s=i.padding,o="bearing"in e?this._normalizeBearing(e.bearing,r):r,l="pitch"in e?+e.pitch:a,u="roll"in e?this._normalizeBearing(e.roll,n):n,h="padding"in e?e.padding:i.padding,c=C.convert(e.offset),d=i.centerPoint.add(c),p=i.screenPointToLocation(d),f=this.cameraHelper.handleFlyTo(i,{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(i.width,i.height),_=g/f.scaleOfZoom,y=f.pixelPathLength,x=g/f.scaleOfMinZoom;m=Math.min(m,Math.sqrt(x/y*2));let v=m*m;function w(I){let D=(_*_-g*g+(I?-1:1)*v*v*y*y)/(2*(I?_:g)*v*y);return Math.log(Math.sqrt(D*D+1)-D)}function b(I){return(Math.exp(I)-Math.exp(-I))/2}function T(I){return(Math.exp(I)+Math.exp(-I))/2}function P(I){return b(I)/T(I)}let S=w(!1),M=function(I){return T(S)/T(S+m*I)},F=function(I){return g*((T(S)*P(S+m*I)-b(S))/v)/y},R=(w(!0)-S)/m;if(Math.abs(y)<2e-6||!isFinite(R)){if(Math.abs(g-_)<1e-6)return this.easeTo(e,t);let I=_<g?-1:1;R=Math.abs(Math.log(_/g))/m,F=()=>0,M=D=>Math.exp(I*m*D)}if("duration"in e)e.duration=+e.duration;else{let I="screenSpeed"in e?+e.screenSpeed/m:+e.speed;e.duration=1e3*R/I}return e.maxDuration&&e.duration>e.maxDuration&&(e.duration=0),this._zooming=!0,this._rotating=r!==o,this._pitching=l!==a,this._rolling=u!==n,this._padding=!i.isPaddingEqual(h),this._prepareEase(t,!1),this.terrain&&this._prepareElevation(f.targetCenter),this._ease(I=>{let D=I*R,E=1/M(D),A=F(D);this._rotating&&i.setBearing(Oe.number(r,o,I)),this._pitching&&i.setPitch(Oe.number(a,l,I)),this._rolling&&i.setRoll(Oe.number(n,u,I)),this._padding&&(i.interpolatePadding(s,h,I),d=i.centerPoint.add(c)),f.easeFunc(I,E,A,d),this.terrain&&!e.freezeElevation&&this._updateElevation(I),this.applyUpdatedTransform(i),this._fireMoveEvents(t)},()=>{this.terrain&&e.freezeElevation&&this._finalizeElevation(),this._afterEase(t)},e),this}isEasing(){return!!this._easeFrameId}stop(e){return this._stop(e)}_stop(e,t){if(this._easeFrameId&&(this._cancelRenderFrame(this._easeFrameId),delete this._easeFrameId,delete this._onEaseFrame),this._onEaseEnd){let i=this._onEaseEnd;delete this._onEaseEnd,i.call(this,t)}return e||this._stopHandlers(),this}_ease(e,t,i){i.animate===!1||i.duration===0?(e(1),t()):(this._easeStart=Te(),this._easeOptions=i,this._onEaseFrame=e,this._onEaseEnd=t,this._easeFrameId=this._requestRenderFrame(this._renderFrameCallback))}_normalizeBearing(e,t){e=ci(e,-180,180);let i=Math.abs(e-t);return Math.abs(e-360-t)<i&&(e-=360),Math.abs(e+360-t)<i&&(e+=360),e}isMoving(){return this._moving}isZooming(){return this._zooming}isRotating(){return this._rotating}};const lv={compact:!0,customAttribution:'<a href="https://maplibre.org/" target="_blank">MapLibre</a>'};var uv=class{constructor(e=lv){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=Q.create("details","maplibregl-ctrl maplibregl-ctrl-attrib"),this._compactButton=Q.create("summary","maplibregl-ctrl-attrib-button",this._container),this._compactButton.addEventListener("click",this._toggleAttribution),this._setElementTitle(this._compactButton,"ToggleAttribution"),this._innerContainer=Q.create("div","maplibregl-ctrl-attrib-inner",this._container),this._updateAttributions(),this._updateCompact(),this._map.on("styledata",this._updateData),this._map.on("sourcedata",this._updateData),this._map.on("terrain",this._updateData),this._map.on("resize",this._updateCompact),this._map.on("drag",this._updateCompactMinimize),this._container}onRemove(){this._container.remove(),this._map.off("styledata",this._updateData),this._map.off("sourcedata",this._updateData),this._map.off("terrain",this._updateData),this._map.off("resize",this._updateCompact),this._map.off("drag",this._updateCompactMinimize),this._map=void 0,this._compact=void 0,this._attribHTML=void 0}_setElementTitle(e,t){let i=this._map._getUIString(`AttributionControl.${t}`);e.title=i,e.setAttribute("aria-label",i)}_updateAttributions(){if(!this._map.style)return;let e=[];if(this.options.customAttribution&&(Array.isArray(this.options.customAttribution)?e=e.concat(this.options.customAttribution.map(r=>typeof r=="string"?r:"")):typeof this.options.customAttribution=="string"&&e.push(this.options.customAttribution)),this._map.style.stylesheet){let r=this._map.style.stylesheet;this.styleOwner=r.owner,this.styleId=r.id}let t=this._map.style.tileManagers;for(let r in t){let a=t[r];if(a.used||a.usedForTerrain){let n=a.getSource();n.attribution&&!e.includes(n.attribution)&&e.push(n.attribution)}}e=e.filter(r=>String(r).trim()),e.sort((r,a)=>r.length-a.length),e=e.filter((r,a)=>{for(let n=a+1;n<e.length;n++)if(e[n].includes(r))return!1;return!0});let i=e.join(" | ");i!==this._attribHTML&&(this._attribHTML=i,e.length?(this._innerContainer.innerHTML=Q.sanitize(i),this._container.classList.remove("maplibregl-attrib-empty")):this._container.classList.add("maplibregl-attrib-empty"),this._updateCompact(),this._editLink=null)}},hv=class{constructor(e={}){this._updateCompact=()=>{let t=this._container.children;if(t.length){let i=t[0];this._map.getCanvasContainer().offsetWidth<=640||this._compact?this._compact!==!1&&i.classList.add("maplibregl-compact"):i.classList.remove("maplibregl-compact")}},this.options=e}getDefaultPosition(){return"bottom-left"}onAdd(e){var i;this._map=e,this._compact=(i=this.options)==null?void 0:i.compact,this._container=Q.create("div","maplibregl-ctrl");let t=Q.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}},KF=class{constructor(){this._queue=[],this._id=0,this._cleared=!1,this._currentlyRunning=!1}add(e){let t=++this._id;return this._queue.push({callback:e,id:t,cancelled:!1}),t}remove(e){let t=this._currentlyRunning,i=t?this._queue.concat(t):this._queue;for(let r of i)if(r.id===e){r.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 i=!1,r;for(let a of t)if(!a.cancelled){try{a.callback(e)}catch(n){i||(i=!0,r=n)}if(this._cleared)break}if(this._cleared=!1,this._currentlyRunning=!1,i)throw r}clear(){this._currentlyRunning&&(this._cleared=!0),this._queue=[]}},JF=class{constructor(e,t,i){this._tileKeys=e.map(r=>r.key).sort().join(),this._revision=t,this._zoom=i}equals(e){return this.equalsIgnoringZoom(e)&&this._zoom===e._zoom}equalsIgnoringZoom(e){return e!==void 0&&this._tileKeys===e._tileKeys&&this._revision===e._revision}};const nn={background:!0,fill:!0,line:!0,raster:!0,hillshade:!0,"color-relief":!0};var QF=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 i=t!==this._lastPrepareZoom;this._lastPrepareZoom=t,this._stacks=[],this._prevType=null,this._rttTiles=[],this._renderableTiles=this.terrain.tileManager.getRenderableTiles(),this._renderableLayerIds=e._order.filter(a=>!e._layers[a].isHidden(t));let r=new Set;for(let a of this._renderableLayerIds){let n=e._layers[a],s=n.source;s&&nn[n.type]&&r.add(s)}this._coordsAscending={},this._rttFingerprints={};for(let a of r){let n=e.tileManagers[a];if(!n)continue;this._coordsAscending[a]={};let s=this._coordsAscending[a],o=n.getSource(),l=o instanceof Qa?o.terrainTileRanges:null;for(let c of n.getVisibleCoordinates()){let d=this.terrain.tileManager.getTerrainCoords(c,l);for(let p in d)s[p]||(s[p]=[]),s[p].push(d[p])}this._rttFingerprints[a]={};let u=this._rttFingerprints[a],h=n.getState().revision;for(let c in s)u[c]=new JF(s[c],h,t)}this.needsFollowUpFrame=!1;for(let a of this._renderableTiles)for(let n in this._rttFingerprints){let s=this._rttFingerprints[n][a.tileID.key],o=a.rttFingerprint[n];s&&!s.equals(o)&&(i&&s.equalsIgnoringZoom(o)?this.needsFollowUpFrame=!0:a.releaseRTT(this.painter))}}renderLayer(e,t){if(e.isHidden(this.painter.transform.zoom))return!1;let i={...t,isRenderingToTexture:!0},r=e.type,a=this.painter,n=this._renderableLayerIds[this._renderableLayerIds.length-1]===e.id;if(nn[r]&&((!this._prevType||!nn[this._prevType])&&this._stacks.push([]),this._prevType=r,this._stacks[this._stacks.length-1].push(e.id),!n))return!0;if(nn[this._prevType]||nn[r]&&n){this._prevType=r;let s=this._stacks.length-1,o=this._stacks[s]||[];for(let l of this._renderableTiles){if(this._rttTiles.push(l),l.getRTT(s))continue;let u=l.acquireRTT(a,s,this.rttSize);a.bindRTT(u),a.context.clear({color:te.transparent,stencil:0}),a.currentStencilSource=void 0;for(let h of o){let c=a.style._layers[h],d=c.source?this._coordsAscending[c.source][l.tileID.key]:[l.tileID];a.context.viewport.set([0,0,this.rttSize,this.rttSize]),a.renderTileClippingMasks(c,d,!0),a.renderLayer(a,a.style.tileManagers[c.source],c,d,i),c.source&&(l.rttFingerprint[c.source]=this._rttFingerprints[c.source][l.tileID.key])}u.texture.generateMipmap()}return gF(this.painter,this.terrain,this._rttTiles,i),this._rttTiles=[],nn[r]}return!1}};const eR={"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"},tR=O_,cv={hash:!1,interactive:!0,bearingSnap:7,zoomSnap:0,attributionControl:lv,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:ei.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 dv=class extends ot{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 KF,this._controls=[],this._mapId=mp(),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 nl("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 nl("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 K(l));return}this.resize(),this._update(),this._resizeInternal(),this.fire(new nl("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={...cv,...e,canvasContextAttributes:{...cv.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 YF({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={...eR,...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&&(jt.prefersReducedMotion=t.reduceMotion),this._requestManager=new nD(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=qi.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.terrainFacilitator.depthDirty=!0,this._update(!0)}),this.once("idle",()=>this._idleTriggered=!0),this._handlers=new XF(this,this._camera,t),typeof window<"u"&&(this._ownerWindow.addEventListener("online",this._onWindowOnline,!1),this._setupResizeObserver());let i=typeof t.hash=="string"&&t.hash||void 0;this._hash=t.hash?new q0(i).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,Z({},t.fitBoundsOptions,{duration:0}))));let r=typeof t.style=="string"||((s=(n=t.style)==null?void 0:n.projection)==null?void 0:s.type)!=="globe";this.resize(null,r),this._localIdeographFontFamily=t.localIdeographFontFamily,this._validateStyle=t.validateStyle,t.style&&this.setStyle(t.style,{localIdeographFontFamily:t.localIdeographFontFamily}),t.attributionControl&&this.addControl(new uv(typeof t.attributionControl=="boolean"?void 0:t.attributionControl)),t.maplibreLogo&&this.addControl(new hv,t.logoPosition),this.on("style.load",()=>{if(r||this._resizeTransform(),this._camera.transform.unmodified){let o=dn(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 vi("styledata",o):new Re("sourcedata",o))}),this.on("dataloading",o=>{this.fire(o.dataType==="style"?new vi("styledataloading",o):new Re("sourcedataloading",o))}),this.on("dataabort",o=>{this.fire(new Re("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 K(Error("Invalid argument to map.addControl(). Argument must be a control with onAdd and onRemove methods.")));let i=e.onAdd(this);this._controls.push(e);let r=this._controlPositions[t];return t.includes("bottom")?r.insertBefore(i,r.firstChild):r.appendChild(i),this}removeControl(e){if(!(e!=null&&e.onRemove))return this.fire(new K(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 W(this._camera.transform.center.lng,this._camera.transform.center.lat)}setCenter(e,t){return this._camera.setCenter(e,t),this}getCenterElevation(){return this._camera.transform.elevation}setCenterElevation(e,t){return this._camera.setCenterElevation(e,t),this}setCenterClampedToGround(e){this._camera.setCenterClampedToGround(e)}panBy(e,t,i){return this._camera.panBy(e,t,i),this}panTo(e,t,i){return this._camera.panTo(e,t,i),this}getZoom(){return this._camera.transform.zoom}setZoom(e,t){return this._camera.setZoom(e,t),this}zoomTo(e,t,i){return this._camera.zoomTo(e,t,i),this}zoomIn(e,t){return this._camera.zoomIn(e,t),this}zoomOut(e,t){return this._camera.zoomOut(e,t),this}getVerticalFieldOfView(){return this._camera.transform.fov}setVerticalFieldOfView(e,t){return this._camera.setVerticalFieldOfView(e,t),this}getBearing(){return this._camera.transform.bearing}setBearing(e,t){return this._camera.setBearing(e,t),this}getZoomSnap(){return this._camera.getZoomSnap()}setZoomSnap(e){return this._camera.setZoomSnap(e),this}getPadding(){return this._camera.transform.padding}setPadding(e,t){return this._camera.setPadding(e,t),this}rotateTo(e,t,i){return this._camera.rotateTo(e,t,i),this}resetNorth(e,t){return this._camera.resetNorth(e,t),this}resetNorthPitch(e,t){return this._camera.resetNorthPitch(e,t),this}snapToNorth(e,t){return this._camera.snapToNorth(e,t),this}getPitch(){return this._camera.transform.pitch}setPitch(e,t){return this._camera.setPitch(e,t),this}getRoll(){return this._camera.transform.roll}setRoll(e,t){return this._camera.setRoll(e,t),this}cameraForBounds(e,t){return this._camera.cameraForBounds(e,t)}fitBounds(e,t,i){return this._camera.fitBounds(e,t,i),this}fitScreenCoordinates(e,t,i,r,a){return this._camera.fitScreenCoordinates(e,t,i,r,a),this}jumpTo(e,t){return this._camera.jumpTo(e,t),this}calculateCameraOptionsFromCameraLngLatAltRotation(e,t,i,r,a){return this._camera.calculateCameraOptionsFromCameraLngLatAltRotation(e,t,i,r,a)}easeTo(e,t){return this._camera.easeTo(e,t),this}flyTo(e,t){return this._camera.flyTo(e,t),this}stop(){return this._camera.stop(),this}queryTerrainElevation(e){return this.terrain?this.terrain.getElevationForLngLat(W.convert(e),this._camera.transform):null}getCenterClampedToGround(){return this._camera.getCenterClampedToGround()}calculateCameraOptionsFromTo(e,t,i,r){return r==null&&this.terrain&&(r=this.terrain.getElevationForLngLat(i,this._camera.transform)),this._camera.transform.calculateCameraOptionsFromTo(e,t,i,r??0)}resize(e,t=!0){if(this._lostContextStyle.style!==null)return this;this._resizeInternal(t);let i=!this._camera._moving;return i&&(this.stop(),this.fire(new Y("movestart",e)).fire(new Y("move",e))),this.fire(new gt("resize",e)),i&&this.fire(new Y("moveend",e)),this}_resizeInternal(e=!0){let[t,i]=this._containerDimensions(),r=this._getClampedPixelRatio(t,i);if(this._resizeCanvas(t,i,r),this.painter.resize(t,i,r),this.painter.overLimit()){let a=this.painter.context.gl;this._maxCanvasSize=[a.drawingBufferWidth,a.drawingBufferHeight];let n=this._getClampedPixelRatio(t,i);this._resizeCanvas(t,i,n),this.painter.resize(t,i,n)}this._resizeTransform(e)}_resizeTransform(e=!0){var r;let[t,i]=this._containerDimensions();this._camera.transform.resize(t,i,e),(r=this._camera._requestedCameraState)==null||r.resize(t,i,e)}_getClampedPixelRatio(e,t){let{0:i,1:r}=this._maxCanvasSize,a=this.getPixelRatio(),n=e*a,s=t*a,o=n>i?i/n:1,l=s>r?r/s:1,u=Math.min(o,l);return u<1&&le("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.transform.setMaxBounds(Mi.convert(e)),this._update()}setMinZoom(e){if(e??(e=-2),e>=-2&&e<=this._camera.transform.maxZoom){let t=this._camera.transform.zoom,i=this._camera.getTransformForUpdate();return i.setMinZoom(e),this._camera.applyUpdatedTransform(i),this._update(),t!==this._camera.transform.zoom&&this.fire(new Y("zoomstart")).fire(new Y("zoom")).fire(new Y("zoomend")).fire(new Y("movestart")).fire(new Y("move")).fire(new Y("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,i=this._camera.getTransformForUpdate();return i.setMaxZoom(e),this._camera.applyUpdatedTransform(i),this._update(),t!==this._camera.transform.zoom&&this.fire(new Y("zoomstart")).fire(new Y("zoom")).fire(new Y("zoomend")).fire(new Y("movestart")).fire(new Y("move")).fire(new Y("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,i=this._camera.getTransformForUpdate();return i.setMinPitch(e),this._camera.applyUpdatedTransform(i),this._update(),t!==this._camera.transform.pitch&&this.fire(new Y("pitchstart")).fire(new Y("pitch")).fire(new Y("pitchend")).fire(new Y("movestart")).fire(new Y("move")).fire(new Y("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,i=this._camera.getTransformForUpdate();return i.setMaxPitch(e),this._camera.applyUpdatedTransform(i),this._update(),t!==this._camera.transform.pitch&&this.fire(new Y("pitchstart")).fire(new Y("pitch")).fire(new Y("pitchend")).fire(new Y("movestart")).fire(new Y("move")).fire(new Y("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.transform.setRenderWorldCopies(e),this._update()}setTransformConstrain(e){return this._camera.transform.setConstrainOverride(e),this._update()}project(e){return this._camera.transform.locationToScreenPoint(W.convert(e),this.style&&this.terrain)}unproject(e){return this._camera.transform.screenPointToLocation(C.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}_createDelegatedListener(e,t,i){if(e==="mouseenter"||e==="mouseover"){let r=!1;return{layers:t,listener:i,delegates:{mousemove:a=>{let n=t.filter(o=>this.getLayer(o)),s=n.length===0?[]:this.queryRenderedFeatures(a.point,{layers:n});s.length?r||(r=!0,i.call(this,new ai(e,this,a.originalEvent,{features:s}))):r=!1},mouseout:()=>{r=!1}}}}if(e==="mouseleave"||e==="mouseout"){let r=!1;return{layers:t,listener:i,delegates:{mousemove:a=>{let n=t.filter(s=>this.getLayer(s));(n.length===0?[]:this.queryRenderedFeatures(a.point,{layers:n})).length?r=!0:r&&(r=!1,i.call(this,new ai(e,this,a.originalEvent)))},mouseout:a=>{r&&(r=!1,i.call(this,new ai(e,this,a.originalEvent)))}}}}{let r=a=>{let n=t.filter(o=>this.getLayer(o)),s=n.length===0?[]:this.queryRenderedFeatures(a.point,{layers:n});s.length&&(a.features=s,i.call(this,a),delete a.features)};return{layers:t,listener:i,delegates:{[e]:r}}}}_saveDelegatedListener(e,t){var i;this._delegatedListeners||(this._delegatedListeners={}),(i=this._delegatedListeners)[e]||(i[e]=[]),this._delegatedListeners[e].push(t)}_removeDelegatedListener(e,t,i){var a;if(!((a=this._delegatedListeners)!=null&&a[e]))return;let r=this._delegatedListeners[e];for(let n=0;n<r.length;n++){let s=r[n];if(s.listener===i&&s.layers.length===t.length&&s.layers.every(o=>t.includes(o))){for(let o in s.delegates)this.off(o,s.delegates[o]);r.splice(n,1);return}}}on(e,t,i){if(i===void 0)return super.on(e,t);let r=typeof t=="string"?[t]:t,a=this._createDelegatedListener(e,r,i);this._saveDelegatedListener(e,a);for(let n in a.delegates)this.on(n,a.delegates[n]);return{unsubscribe:()=>{this._removeDelegatedListener(e,r,i)}}}once(e,t,i){if(i===void 0)return super.once(e,t);let r=typeof t=="string"?[t]:t,a=this._createDelegatedListener(e,r,i);for(let n in a.delegates){let s=a.delegates[n];a.delegates[n]=(...o)=>{this._removeDelegatedListener(e,r,i),s(...o)}}this._saveDelegatedListener(e,a);for(let n in a.delegates)this.once(n,a.delegates[n]);return this}off(e,t,i){if(i===void 0)return super.off(e,t);let r=typeof t=="string"?[t]:t;return this._removeDelegatedListener(e,r,i),this}queryRenderedFeatures(e,t){if(!this.style)return[];let i,r=e instanceof C||Array.isArray(e),a=r?e:[[0,0],[this._camera.transform.width,this._camera.transform.height]];if(t||(t=(r?{}:e)||{}),a instanceof C||typeof a[0]=="number")i=[C.convert(a)];else{let n=C.convert(a[0]),s=C.convert(a[1]);i=[n,new C(s.x,n.y),s,new C(n.x,s.y),n]}return this.style.queryRenderedFeatures(i,t,this._camera.transform)}querySourceFeatures(e,t){return this.style.querySourceFeatures(e,t)}setStyle(e,t){return t=Z({},{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 r,a,n;if((r=this._diffStyleRequest)==null||r.abort(),this._diffStyleRequest=null,t.transformStyle&&this.style&&!this.style._loaded){this.style.once("style.load",()=>this._updateStyle(e,t));return}let i=this.style&&t.transformStyle?this.style.serialize():void 0;if(this.style&&(this.style.setEventedParent(null),this.style._remove(!e)),e)this.style=new rd(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,i):this.style.loadJSON(e,t,i),this}_lazyInitEmptyStyle(){this.style||(this.style=new rd(this,{}),this.style.setEventedParent(this,{style:this.style}),this.style.loadEmpty())}async _diffStyle(e,t){var i;if((i=this._diffStyleRequest)==null||i.abort(),typeof e=="string"){let r=e;this._diffStyleRequest=new AbortController;let a=this._diffStyleRequest;try{let n=await this._requestManager.transformRequest(r,"Style");if(a.signal.aborted){this._diffStyleRequest=null;return}let s=await Gs(n,a);this._diffStyleRequest=null,this._updateDiff(s.data,t)}catch(n){this._diffStyleRequest=null,br(n)||this.fire(new K(St(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(i){le(`Unable to perform style diff: ${St(i).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){le("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 i;let t=(i=this.style)==null?void 0:i.tileManagers[e];if(t===void 0){this.fire(new K(Error(`There is no tile manager with ID '${e}'`)));return}return t.loaded()}setTerrain(e,t={}){if(this.style._checkLoaded(),e&&zn(this,Ht.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._camera.terrain=null,this._camera.transform.setMinElevationForCurrentTile(0),this.getCenterClampedToGround()&&this._camera.transform.setElevation(0);else{let i=this.style.tileManagers[e.source];if(!i)throw Error(`cannot load terrain, because there exists no source with ID: ${e.source}`);this.terrain===null&&i.reload();for(let r in this.style._layers){let a=this.style._layers[r];a.type==="hillshade"&&a.source===e.source&&le("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&&le("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 fM(this.painter,i,e,this._terrainSkirtLength),this.painter.renderToTexture=new QF(this.painter,this.terrain),this._camera.terrain=this.terrain,this._camera.transform.setMinElevationForCurrentTile(this.terrain.getMinTileElevationForLngLatZoom(this._camera.transform.center,this._camera.transform.tileZoom)),this._camera.transform.setElevation(this.terrain.getElevationForLngLat(this._camera.transform.center,this._camera.transform)),this._terrainDataCallback=r=>this._handleTerrainDataEvent(r,e.source),this.style.on("data",this._terrainDataCallback)}return this.style.triggerSymbolPlacement(),this.fire(new U_({terrain:e})),this}_handleTerrainDataEvent(e,t){var r;if(e.dataType==="style"){this.terrain.tileManager.releaseAllRTT();return}let i=e.sourceId===t;if(i&&(this.terrain.resetElevationCache(),this.style.triggerSymbolPlacement()),i&&e.tile&&!this._camera.elevationFreeze&&(this._camera.transform.setMinElevationForCurrentTile(this.terrain.getMinTileElevationForLngLatZoom(this._camera.transform.center,this._camera.transform.tileZoom)),this.getCenterClampedToGround()&&this._camera.transform.setElevation(this.terrain.getElevationForLngLat(this._camera.transform.center,this._camera.transform))),e.tile){if(((r=e.source)==null?void 0:r.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 i of Object.values(e))if(!i.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,i){if(i){let r=this.getSource(i);if(!r)throw Error(`There is no source with ID "${i}", cannot set LOD parameters`);r.calculateTileZoom=Bc(Math.max(1,e),Math.max(1,t))}else for(let r in this.style.tileManagers)this.style.tileManagers[r].getSource().calculateTileZoom=Bc(Math.max(1,e),Math.max(1,t));return this._update(!0),this}refreshTiles(e,t){let i=this.style.tileManagers[e];if(!i)throw Error(`There is no tile manager with ID "${e}", cannot refresh tile`);t===void 0?i.reload(!0):i.refreshTiles(t.map(r=>new Jo(r.z,r.x,r.y)))}addImage(e,t,i={}){var a;this._lazyInitEmptyStyle();let r=this._createStyleImage(t,i);return r?(this.style.addImage(e,r),(a=r.userImage)!=null&&a.onAdd&&r.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:i=1,sdf:r=!1,stretchX:a,stretchY:n,content:s,textFitWidth:o,textFitHeight:l}=t;if(e instanceof HTMLImageElement||jr(e)){let{width:u,height:h,data:c}=jt.getImageData(e);return{data:new Fe({width:u,height:h},c),pixelRatio:i,stretchX:a,stretchY:n,content:s,textFitWidth:o,textFitHeight:l,sdf:r,version:0}}if(e.width===void 0||e.height===void 0)return this.fire(new K(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=Oo(d.data);return{data:p?new Fe({width:u,height:h}):new Fe({width:u,height:h},new Uint8Array(c)),pixelRatio:i,stretchX:a,stretchY:n,content:s,textFitWidth:o,textFitHeight:l,sdf:r,version:0,isWebGLImage:p,userImage:d}}}updateImage(e,t){let i=this.style.getImage(e);if(!i)return this.fire(new K(Error("The map has no image with that id. If you are adding a new image use `map.addImage(...)` instead.")));let{width:r,height:a,data:n}=t instanceof HTMLImageElement||jr(t)?jt.getImageData(t):t;if(r===void 0||a===void 0)return this.fire(new K(Error("Invalid arguments to map.updateImage(). The second argument must be an `HTMLImageElement`, `ImageData`, `ImageBitmap`, or object with `width`, `height`, and `data` properties with the same format as `ImageData`")));if(r!==i.data.width||a!==i.data.height)return this.fire(new K(Error("The width and height of the updated image must be that same as the previous version of the image")));if(i.isWebGLImage=Oo(n),i.isWebGLImage)i.userImage=t;else{let s=!(t instanceof HTMLImageElement||jr(t));i.data.replace(n,s)}return this.style.updateImage(e,i),this}getImage(e){return this.style.getImage(e)}hasImage(e){return e?!!this.style.getImage(e):(this.fire(new K(Error("Missing required image id"))),!1)}removeImage(e){this.style.removeImage(e)}async loadImage(e){let t=await qi.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,i){return this.style.setLayerZoomRange(e,t,i),this._update(!0)}setFilter(e,t,i={}){var r;return(r=this.style)==null||r.setFilter(e,t,i),this._update(!0)}getFilter(e){return this.style.getFilter(e)}setPaintProperty(e,t,i,r={}){var a;return(a=this.style)==null||a.setPaintProperty(e,t,i,r),this._update(!0)}getPaintProperty(e,t){return this.style.getPaintProperty(e,t)}setLayoutProperty(e,t,i,r={}){return this.style.setLayoutProperty(e,t,i,r),this._update(!0)}getLayoutProperty(e,t){return this.style.getLayoutProperty(e,t)}setGlyphs(e,t={}){return this._lazyInitEmptyStyle(),this.style.setGlyphs(e,t),this._update(!0)}getGlyphs(){return this.style.getGlyphsUrl()}setFontFaces(e){return this._lazyInitEmptyStyle(),this.style.setFontFaces(e),this._update(!0)}getFontFaces(){return this.style.getFontFaces()}addSprite(e,t,i={}){return this._lazyInitEmptyStyle(),this.style.addSprite(e,t,i,r=>{r||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,i=>{i||this._update(!0)}),this}setLight(e,t={}){return this._lazyInitEmptyStyle(),this.style.setLight(e,t),this._update(!0)}getLight(){return this.style.getLight()}setSky(e,t={}){return this._lazyInitEmptyStyle(),this.style.setSky(e,t),this._update(!0)}getSky(){return this.style.getSky()}setFeatureState(e,t){return this.style.setFeatureState(e,t),this._update()}removeFeatureState(e,t){return this.style.removeFeatureState(e,t),this._update()}getFeatureState(e){return this.style.getFeatureState(e)}getContainer(){return this._container}getCanvasContainer(){return this._canvasContainer}getCanvas(){return this._canvas}_containerDimensions(){let e=0,t=0;return this._container&&(e=this._container.clientWidth||400,t=this._container.clientHeight||300),[e,t]}_setupResizeObserver(){let e=!1,t=Z0(r=>{this._trackResize&&!this._removed&&(this.resize(r),this.redraw())},50),i=this._ownerWindow.ResizeObserver??ResizeObserver;this._resizeObserver=new i(r=>{if(!e){e=!0;return}t(r)}),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._container;e.classList.add("maplibregl-map");let t=this._canvasContainer=Q.create("div","maplibregl-canvas-container",e);this._interactive&&t.classList.add("maplibregl-interactive"),this._canvas=Q.create("canvas","maplibregl-canvas",t),this._canvas.addEventListener("webglcontextlost",this._contextLost,!1),this._canvas.addEventListener("webglcontextrestored",this._contextRestored,!1),this._canvas.setAttribute("tabindex",this._interactive?"0":"-1"),this._canvas.setAttribute("aria-label",this._getUIString("Map.Title")),this._canvas.setAttribute("role","region");let i=this._containerDimensions(),r=this._getClampedPixelRatio(i[0],i[1]);this._resizeCanvas(i[0],i[1],r);let a=this._controlContainer=Q.create("div","maplibregl-control-container",e),n=this._controlPositions={};for(let s of["top-left","top-right","bottom-left","bottom-right"])n[s]=Q.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,i){this._canvas.width=Math.floor(i*e),this._canvas.height=Math.floor(i*t),this._canvas.style.width=`${e}px`,this._canvas.style.height=`${t}px`}_setupPainter(){let e={...this._canvasContextAttributes,alpha:!0,depth:!0,stencil:!0,premultipliedAlpha:!0},t=null;this._canvas.addEventListener("webglcontextcreationerror",r=>{t=r},{once:!0});let i=this._canvas.getContext("webgl2",e);if(!i)throw new G0(e,t);this.painter=new wF(i,this._camera.transform)}migrateProjection(e,t){this._camera.migrateProjection(e,t),this.painter.transform=e,this.fire(new G_({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,i=((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 r=!1;if(this.style&&this._styleDirty){this._styleDirty=!1;let c=this._camera.transform.zoom,d=Te();this.style.zoomHistory.update(c,d);let p=new be(c,{now:d,fadeDuration:t,zoomHistory:this.style.zoomHistory,transition:this.style.getTransition()}),f=p.crossFadingFactor();(f!==1||f!==this._crossFadingFactor)&&(r=!0,this._crossFadingFactor=f),this.style.update(p)}let a=((o=this.style.projection)==null?void 0:o.transitionState)>0!==i;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 gt("render")),this.loaded()&&!this._loaded&&(this._loaded=!0,this.fire(new gt("load"))),this.style&&(this.style.hasTransitions()||r)&&(this._styleDirty=!0),this.style&&!this._placementDirty&&this.style._releaseSymbolFadeTiles();let n=this._sourcesDirty||this._styleDirty||this._placementDirty||((h=this.painter.renderToTexture)==null?void 0:h.needsFollowUpFrame);return n||this._repaint?this.triggerRepaint():!this.isMoving()&&this.loaded()&&this.fire(new gt("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,i;this._hash&&this._hash.remove();for(let r of this._controls)r.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),qi.removeThrottleControl(this._imageQueueHandle),(i=this._resizeObserver)==null||i.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 gt("remove"))}triggerRepaint(){this.style&&!this._frameRequest&&(this._frameRequest=new AbortController,jt.frame(this._frameRequest,e=>{this._frameRequest=null;try{this._render(e)}catch(t){if(!br(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 tR}getCameraTargetElevation(){return this._camera.transform.elevation}getProjection(){return this.style.getProjection()}setProjection(e){return this._lazyInitEmptyStyle(),this.style.setProjection(e),this._update(!0)}};const iR={showCompass:!0,showZoom:!0,visualizePitch:!1,visualizeRoll:!0};var rR=class{constructor(e){this._updateZoomButtons=()=>{let t=this._map.getZoom(),i=t===this._map.getMaxZoom(),r=t===this._map.getMinZoom(!0);this._zoomInButton.disabled=i,this._zoomOutButton.disabled=r,this._zoomInButton.setAttribute("aria-disabled",i.toString()),this._zoomOutButton.setAttribute("aria-disabled",r.toString())},this._rotateCompassArrow=()=>{let t=this._map.getPitch(),i=this._map.getRoll(),r=this._map.getBearing(),a=1/Math.cos(Be(t))**.5;if(this.options.visualizePitch&&this.options.visualizeRoll){this._compassIcon.style.transform=`scale(${a}) rotateZ(${-i}deg) rotateX(${t}deg) rotateZ(${-r}deg)`;return}if(this.options.visualizePitch){this._compassIcon.style.transform=`scale(${a}) rotateX(${t}deg) rotateZ(${-r}deg)`;return}if(this.options.visualizeRoll){this._compassIcon.style.transform=`rotate(${-r-i}deg)`;return}this._compassIcon.style.transform=`rotate(${-r}deg)`},this._setButtonTitle=(t,i)=>{let r=this._map._getUIString(`NavigationControl.${i}`);t.title=r,t.setAttribute("aria-label",r)},this.options=Z({},iR,e),this._container=Q.create("div","maplibregl-ctrl maplibregl-ctrl-group"),this._container.addEventListener("contextmenu",t=>t.preventDefault()),this.options.showZoom&&(this._zoomInButton=this._createButton("maplibregl-ctrl-zoom-in",t=>this._map.zoomIn({},{originalEvent:t})),Q.create("span","maplibregl-ctrl-icon",this._zoomInButton).setAttribute("aria-hidden","true"),this._zoomOutButton=this._createButton("maplibregl-ctrl-zoom-out",t=>this._map.zoomOut({},{originalEvent:t})),Q.create("span","maplibregl-ctrl-icon",this._zoomOutButton).setAttribute("aria-hidden","true")),this.options.showCompass&&(this._compass=this._createButton("maplibregl-ctrl-compass",t=>{this.options.visualizePitch?this._map.resetNorthPitch({},{originalEvent:t}):this._map.resetNorth({},{originalEvent:t})}),this._compassIcon=Q.create("span","maplibregl-ctrl-icon",this._compass),this._compassIcon.setAttribute("aria-hidden","true"))}onAdd(e){return this._map=e,this.options.showZoom&&(this._setButtonTitle(this._zoomInButton,"ZoomIn"),this._setButtonTitle(this._zoomOutButton,"ZoomOut"),this._map.on("move",this._updateZoomButtons),this._updateZoomButtons()),this.options.showCompass&&(this._setButtonTitle(this._compass,"ResetBearing"),this.options.visualizePitch&&this._map.on("pitch",this._rotateCompassArrow),this.options.visualizeRoll&&this._map.on("roll",this._rotateCompassArrow),this._map.on("rotate",this._rotateCompassArrow),this._rotateCompassArrow(),this._handler=new aR(this._map,this._compass,this.options.visualizePitch)),this._container}onRemove(){this._container.remove(),this.options.showZoom&&this._map.off("move",this._updateZoomButtons),this.options.showCompass&&(this.options.visualizePitch&&this._map.off("pitch",this._rotateCompassArrow),this.options.visualizeRoll&&this._map.off("roll",this._rotateCompassArrow),this._map.off("rotate",this._rotateCompassArrow),this._handler.off(),delete this._handler),delete this._map}_createButton(e,t){let i=Q.create("button",e,this._container);return i.type="button",i.addEventListener("click",t),i}},aR=class{constructor(e,t,i=!1){this.mousedown=a=>{this.startMove(a,Q.mousePos(this.element,a)),window.addEventListener("mousemove",this.mousemove),window.addEventListener("mouseup",this.mouseup)},this.mousemove=a=>{this.move(a,Q.mousePos(this.element,a))},this.mouseup=a=>{this._rotatePitchHandler.dragEnd(a),this.offTemp()},this.touchstart=a=>{a.targetTouches.length===1?(this._startPos=this._lastPos=Q.touchPos(this.element,a.targetTouches)[0],this.startMove(a,this._startPos),window.addEventListener("touchmove",this.touchmove,{passive:!1}),window.addEventListener("touchend",this.touchend)):this.reset()},this.touchmove=a=>{a.targetTouches.length===1?(this._lastPos=Q.touchPos(this.element,a.targetTouches)[0],this.move(a,this._lastPos)):this.reset()},this.touchend=a=>{a.targetTouches.length===0&&this._startPos&&this._lastPos&&this._startPos.dist(this._lastPos)<this._clickTolerance&&this.element.click(),delete this._startPos,delete this._lastPos,this.offTemp()},this.reset=()=>{this._rotatePitchHandler.reset(),delete this._startPos,delete this._lastPos,this.offTemp()},this._clickTolerance=10,this.element=t;let r=new BF;this._rotatePitchHandler=new _s({clickTolerance:3,move:(a,n)=>{let s=t.getBoundingClientRect(),o=new C((s.bottom-s.top)/2,(s.right-s.left)/2);return{bearingDelta:vp(new C(a.x,n.y),n,o),pitchDelta:i?(n.y-a.y)*-.5:void 0}},moveStateManager:r,enable:!0,assignEvents:()=>{}}),this.map=e,t.addEventListener("mousedown",this.mousedown),t.addEventListener("touchstart",this.touchstart,{passive:!1}),t.addEventListener("touchcancel",this.reset)}startMove(e,t){this._rotatePitchHandler.dragStart(e,t),Q.disableDrag()}move(e,t){let i=this.map,{bearingDelta:r,pitchDelta:a}=this._rotatePitchHandler.dragMove(e,t)||{};r&&i.setBearing(i.getBearing()+r),a&&i.setPitch(i.getPitch()+a)}off(){let e=this.element;e.removeEventListener("mousedown",this.mousedown),e.removeEventListener("touchstart",this.touchstart),window.removeEventListener("touchmove",this.touchmove),window.removeEventListener("touchend",this.touchend),e.removeEventListener("touchcancel",this.reset),this.offTemp()}offTemp(){Q.enableDrag(),window.removeEventListener("mousemove",this.mousemove),window.removeEventListener("mouseup",this.mouseup),window.removeEventListener("touchmove",this.touchmove),window.removeEventListener("touchend",this.touchend)}};let fa;async function nR(e=!1){if(fa!==void 0&&!e)return fa;if(window.navigator.permissions===void 0)return fa=!!window.navigator.geolocation,fa;try{fa=(await window.navigator.permissions.query({name:"geolocation"})).state!=="denied"}catch{fa=!!window.navigator.geolocation}return fa}function pv(e,t,i,r=!1){if(r||!i.getCoveringTilesDetailsProvider().allowWorldCopies())return e==null?void 0:e.wrap();let a=new W(e.lng,e.lat);if(e=new W(e.lng,e.lat),t){let n=new W(e.lng-360,e.lat),s=new W(e.lng+360,e.lat),o=i.locationToScreenPoint(e).distSqr(t);i.locationToScreenPoint(n).distSqr(t)<o?e=n:i.locationToScreenPoint(s).distSqr(t)<o&&(e=s)}for(;Math.abs(e.lng-i.center.lng)>180;){let n=i.locationToScreenPoint(e);if(n.x>=0&&n.y>=0&&n.x<=i.width&&n.y<=i.height)break;e.lng>i.center.lng?e.lng-=360:e.lng+=360}return e.lng!==a.lng&&i.isPointOnMapSurface(i.locationToScreenPoint(e))?e:a}const bd={center:"translate(-50%,-50%)",top:"translate(-50%,0)","top-left":"translate(0,0)","top-right":"translate(-100%,0)",bottom:"translate(-50%,-100%)","bottom-left":"translate(0,-100%)","bottom-right":"translate(-100%,-100%)",left:"translate(0,-50%)",right:"translate(-100%,-50%)"};function fv(e,t,i){let r=e.classList;for(let a in bd)r.remove(`maplibregl-${i}-anchor-${a}`);r.add(`maplibregl-${i}-anchor-${t}`)}const mv={ArrowLeft:[-1,0],ArrowRight:[1,0],ArrowUp:[0,-1],ArrowDown:[0,1]},gv="#3FB1CE";function bi(e,t,i=[]){let r=Q.createNS("http://www.w3.org/2000/svg",e);for(let a in t)r.setAttributeNS(null,a,t[a]);for(let a of i)r.appendChild(a);return r}let wd;function sR(){return wd||(wd=bi("svg",{display:"block",height:"41px",width:"27px",viewBox:"0 0 27 41"},[bi("g",{"fill-rule":"nonzero"},[bi("g",{transform:"translate(3.0, 29.0)",fill:"#000000"},[["10.5","5.25002273"],["10.5","5.25002273"],["9.5","4.77275007"],["8.5","4.29549936"],["7.5","3.81822308"],["6.5","3.34094679"],["5.5","2.86367051"],["4.5","2.38636864"]].map(([e,t])=>bi("ellipse",{opacity:"0.04",cx:"10.5",cy:"5.80029008",rx:e,ry:t}))),bi("g",{fill:gv},[bi("path",{d:"M27,13.5 C27,19.074644 20.250001,27.000002 14.75,34.500002 C14.016665,35.500004 12.983335,35.500004 12.25,34.500002 C6.7499993,27.000002 0,19.222562 0,13.5 C0,6.0441559 6.0441559,0 13.5,0 C20.955844,0 27,6.0441559 27,13.5 Z"})]),bi("g",{opacity:"0.25",fill:"#000000"},[bi("path",{d:"M13.5,0 C6.0441559,0 0,6.0441559 0,13.5 C0,19.222562 6.7499993,27 12.25,34.5 C13,35.522727 14.016664,35.500004 14.75,34.5 C20.250001,27 27,19.074644 27,13.5 C27,6.0441559 20.955844,0 13.5,0 Z M13.5,1 C20.415404,1 26,6.584596 26,13.5 C26,15.898657 24.495584,19.181431 22.220703,22.738281 C19.945823,26.295132 16.705119,30.142167 13.943359,33.908203 C13.743445,34.180814 13.612715,34.322738 13.5,34.441406 C13.387285,34.322738 13.256555,34.180814 13.056641,33.908203 C10.284481,30.127985 7.4148684,26.314159 5.015625,22.773438 C2.6163816,19.232715 1,15.953538 1,13.5 C1,6.584596 6.584596,1 13.5,1 Z"})]),bi("g",{transform:"translate(6.0, 7.0)",fill:"#FFFFFF"}),bi("g",{transform:"translate(8.0, 8.0)"},[bi("circle",{fill:"#000000",opacity:"0.25",cx:"5.5",cy:"5.5",r:"5.4999962"}),bi("circle",{fill:"#FFFFFF",cx:"5.5",cy:"5.5",r:"5.4999962"})])])]),wd)}function oR(e){return e.firstElementChild.children[1]}var ma=class extends ti{},_v=class extends ti{},Td=class extends ot{constructor(e){if(super(),this._onClick=t=>{this.fire(new _v("click",{originalEvent:t}))},this._onKeyPress=t=>{(t.code==="Space"||t.code==="Enter")&&this.togglePopup()},this._onKeyDown=t=>{if(!this._defaultMarker||!this._draggable||!this._map||!this._lngLat||t.composedPath()[0]!==this._element||t.altKey||t.ctrlKey||t.metaKey)return;let i=mv[t.key];if(!i)return;t.preventDefault(),t.stopPropagation();let r=t.shiftKey?10:1,a=this._map.project(this._lngLat);this.setLngLat(this._map.unproject(new C(a.x+i[0]*r,a.y+i[1]*r))),this._keyboardDragActive||(this._keyboardDragActive=!0,this.fire(new ma("dragstart"))),this.fire(new ma("drag"))},this._onKeyUp=t=>{mv[t.key]&&this._endKeyboardDrag()},this._onBlur=()=>{this._endKeyboardDrag()},this._onMapClick=t=>{let i=t.originalEvent.target,r=this._element;this._popup&&(i===r||r.contains(i))&&this.togglePopup()},this._update=t=>{if(!this._map)return;let i=this._map.loaded()&&!this._map.isMoving();((t==null?void 0:t.type)==="terrain"||(t==null?void 0:t.type)==="render"&&!i)&&this._map.once("render",this._update),this._lngLat=pv(this._lngLat,this._flatPos,this._map._camera.transform),this._flatPos=this._pos=this._map.project(this._lngLat)._add(this._offset),this._map.terrain&&(this._flatPos=this._map._camera.transform.locationToScreenPoint(this._lngLat)._add(this._offset));let r="";this._rotationAlignment==="viewport"||this._rotationAlignment==="auto"?r=`rotateZ(${this._rotation}deg)`:this._rotationAlignment==="map"&&(r=`rotateZ(${this._rotation-this._map.getBearing()}deg)`);let a="";this._pitchAlignment==="viewport"||this._pitchAlignment==="auto"?a="rotateX(0deg)":this._pitchAlignment==="map"&&(a=`rotateX(${this._map.getPitch()}deg)`),!this._subpixelPositioning&&(!t||t.type==="moveend")&&(this._pos=this._pos.round()),this._element.style.transform=`${bd[this._anchor]} translate(${this._pos.x}px, ${this._pos.y}px) ${a} ${r}`,jt.frameAsync(new AbortController,this._map._ownerWindow).then(()=>{this._updateOpacity((t==null?void 0:t.type)==="moveend")}).catch(()=>{})},this._onMove=t=>{if(!this._isDragging){let i=this._clickTolerance||this._map._clickTolerance;this._isDragging=t.point.dist(this._pointerdownPos)>=i}this._isDragging&&(this._pos=t.point.sub(this._positionDelta),this._lngLat=this._map.unproject(this._pos),this.setLngLat(this._lngLat),this._element.style.pointerEvents="none",this._state==="pending"&&(this._state="active",this.fire(new ma("dragstart"))),this.fire(new ma("drag")))},this._onUp=()=>{this._element.style.pointerEvents="auto",this._positionDelta=null,this._pointerdownPos=null,this._isDragging=!1,this._map.off("mousemove",this._onMove),this._map.off("touchmove",this._onMove),this._state==="active"&&this.fire(new ma("dragend")),this._state="inactive"},this._addDragHandler=t=>{this._element.contains(t.originalEvent.target)&&(t.preventDefault(),this._positionDelta=t.point.sub(this._pos).add(this._offset),this._pointerdownPos=t.point,this._state="pending",this._map.on("mousemove",this._onMove),this._map.on("touchmove",this._onMove),this._map.once("mouseup",this._onUp),this._map.once("touchend",this._onUp))},this._anchor=(e==null?void 0:e.anchor)||"center",this._color=(e==null?void 0:e.color)||gv,this._scale=(e==null?void 0:e.scale)||1,this._draggable=(e==null?void 0:e.draggable)||!1,this._clickTolerance=(e==null?void 0:e.clickTolerance)||0,this._subpixelPositioning=(e==null?void 0:e.subpixelPositioning)||!1,this._isDragging=!1,this._roleManaged=!1,this._tabIndexManaged=!1,this._keyboardDragActive=!1,this._state="inactive",this._rotation=(e==null?void 0:e.rotation)||0,this._rotationAlignment=(e==null?void 0:e.rotationAlignment)||"auto",this._pitchAlignment=e!=null&&e.pitchAlignment&&e.pitchAlignment!=="auto"?e.pitchAlignment:this._rotationAlignment,this.setOpacity(e==null?void 0:e.opacity,e==null?void 0:e.opacityWhenCovered),e==null?void 0:e.element)this._element=e.element,this._offset=C.convert((e==null?void 0:e.offset)||[0,0]);else{this._defaultMarker=!0,this._element=Q.create("div");let t=sR().cloneNode(!0);t.setAttributeNS(null,"height",`${41*this._scale}px`),t.setAttributeNS(null,"width",`${27*this._scale}px`),oR(t).setAttributeNS(null,"fill",this._color),this._element.appendChild(t),this._offset=C.convert((e==null?void 0:e.offset)||[0,-14])}if(this._element.classList.add("maplibregl-marker"),this._element.addEventListener("dragstart",t=>{t.preventDefault()}),this._element.addEventListener("mousedown",t=>{t.preventDefault()}),fv(this._element,this._anchor,"marker"),e==null?void 0:e.className)for(let t of e.className.split(" "))this._element.classList.add(t);this._popup=null}addTo(e){return this.remove(),this._map=e,this._defaultMarker&&!this._element.hasAttribute("aria-label")&&this._element.setAttribute("aria-label",e._getUIString("Marker.Title")),this._updateAccessibilityRole(),e.getCanvasContainer().appendChild(this._element),e.on("move",this._update),e.on("moveend",this._update),e.on("terrain",this._update),e.on("projectiontransition",this._update),this._element.addEventListener("click",this._onClick),this.setDraggable(this._draggable),this._update(),this._map.on("click",this._onMapClick),this}remove(){return this._opacityTimeout&&(clearTimeout(this._opacityTimeout),delete this._opacityTimeout),this._map&&(this._map.off("click",this._onMapClick),this._map.off("move",this._update),this._map.off("moveend",this._update),this._map.off("terrain",this._update),this._map.off("projectiontransition",this._update),this._map.off("mousedown",this._addDragHandler),this._map.off("touchstart",this._addDragHandler),this._map.off("mouseup",this._onUp),this._map.off("touchend",this._onUp),this._map.off("mousemove",this._onMove),this._map.off("touchmove",this._onMove),delete this._map),this._element.removeEventListener("click",this._onClick),this._element.removeEventListener("keydown",this._onKeyDown),this._element.removeEventListener("keyup",this._onKeyUp),this._element.removeEventListener("blur",this._onBlur),this._element.removeEventListener("keypress",this._onKeyPress),this._keyboardDragActive=!1,this._element.remove(),this._popup&&this._popup.remove(),this}getLngLat(){return this._lngLat}setLngLat(e){return this._lngLat=W.convert(e),this._pos=null,this._update(),this._popup&&this._popup.setLngLat(this._lngLat),this}getElement(){return this._element}setPopup(e){if(this._popup&&(this._popup.remove(),this._popup=null,this._element.removeEventListener("keypress",this._onKeyPress)),e){if(!("offset"in e.options)){let t=13.5/Math.SQRT2;e.options.offset=this._defaultMarker?{top:[0,0],"top-left":[0,0],"top-right":[0,0],bottom:[0,-38.1],"bottom-left":[t,(24.6+t)*-1],"bottom-right":[-t,(24.6+t)*-1],left:[13.5,-24.6],right:[-13.5,-24.6]}:this._offset}this._popup=e,this._element.addEventListener("keypress",this._onKeyPress)}return this._updateTabIndex(),this._updateAccessibilityRole(),this}setSubpixelPositioning(e){return this._subpixelPositioning=e,this}_endKeyboardDrag(){this._keyboardDragActive&&(this._keyboardDragActive=!1,this.fire(new ma("dragend")))}getPopup(){return this._popup}togglePopup(){let e=this._popup;if(this._element.style.opacity===this._opacityWhenCovered)return this;if(e)e.isOpen()?e.remove():(e.setLngLat(this._lngLat),e.addTo(this._map));else return this;return this}_updateOpacity(e=!1){var d,p;let t=(d=this._map)==null?void 0:d.terrain,i=this._map._camera.transform.isLocationOccluded(this._lngLat);if(!t||i){let f=i?this._opacityWhenCovered:this._opacity;this._element.style.opacity!==f&&(this._element.style.opacity=f,this._element.classList.toggle("maplibregl-marker-covered",i));return}if(e)this._opacityTimeout=null;else{if(this._opacityTimeout)return;this._opacityTimeout=setTimeout(()=>{this._opacityTimeout=null},100)}let r=this._map,a=r.terrain.depthAtPoint(this._pos),n=r.terrain.getElevationForLngLat(this._lngLat,r._camera.transform),s=r._camera.transform.lngLatToCameraDepth(this._lngLat,n),o=.006;if(s-a<o){this._element.style.opacity=this._opacity,this._element.classList.remove("maplibregl-marker-covered");return}let l=-this._offset.y/r._camera.transform.pixelsPerMeter,u=Math.sin(r.getPitch()*Math.PI/180)*l,h=r.terrain.depthAtPoint(new C(this._pos.x,this._pos.y-this._offset.y)),c=r._camera.transform.lngLatToCameraDepth(this._lngLat,n+u)-h>o;(p=this._popup)!=null&&p.isOpen()&&c&&this._popup.remove(),this._element.style.opacity=c?this._opacityWhenCovered:this._opacity,this._element.classList.toggle("maplibregl-marker-covered",c)}getOffset(){return this._offset}setOffset(e){return this._offset=C.convert(e),this._update(),this}addClassName(e){this._element.classList.add(e)}removeClassName(e){this._element.classList.remove(e)}toggleClassName(e){return this._element.classList.toggle(e)}setDraggable(e){return this._draggable=!!e,this._element.classList.toggle("maplibregl-marker-draggable",this._draggable),this._map&&(e?(this._map.on("mousedown",this._addDragHandler),this._map.on("touchstart",this._addDragHandler)):(this._map.off("mousedown",this._addDragHandler),this._map.off("touchstart",this._addDragHandler))),this._defaultMarker&&(this._draggable?(this._element.addEventListener("keydown",this._onKeyDown),this._element.addEventListener("keyup",this._onKeyUp),this._element.addEventListener("blur",this._onBlur)):(this._element.removeEventListener("keydown",this._onKeyDown),this._element.removeEventListener("keyup",this._onKeyUp),this._element.removeEventListener("blur",this._onBlur),this._endKeyboardDrag())),this._updateTabIndex(),this._updateAccessibilityRole(),this}isDraggable(){return this._draggable}_updateTabIndex(){this._popup||this._defaultMarker&&this._draggable?this._element.hasAttribute("tabindex")||(this._element.setAttribute("tabindex","0"),this._tabIndexManaged=!0):this._tabIndexManaged&&(this._tabIndexManaged=(this._element.getAttribute("tabindex")==="0"&&this._element.removeAttribute("tabindex"),!1))}_updateAccessibilityRole(){if(!this._defaultMarker||this._element.hasAttribute("role")&&!this._roleManaged)return;let e=this._draggable||this._popup?"button":"img";this._element.setAttribute("role",e),this._roleManaged=!0}setRotation(e){return this._rotation=e||0,this._update(),this}getRotation(){return this._rotation}setRotationAlignment(e){return this._rotationAlignment=e||"auto",this._update(),this}getRotationAlignment(){return this._rotationAlignment}setPitchAlignment(e){return this._pitchAlignment=e&&e!=="auto"?e:this._rotationAlignment,this._update(),this}getPitchAlignment(){return this._pitchAlignment}setOpacity(e,t){return(this._opacity===void 0||e===void 0&&t===void 0)&&(this._opacity="1",this._opacityWhenCovered="0.2"),e!==void 0&&(this._opacity=String(e)),t!==void 0&&(this._opacityWhenCovered=String(t)),this._map&&this._updateOpacity(!0),this}};const lR={positionOptions:{enableHighAccuracy:!1,maximumAge:0,timeout:6e3},fitBoundsOptions:{maxZoom:15},trackUserLocation:!1,showAccuracyCircle:!0,showUserLocation:!0};let kl=0,vs=!1;var ga=class extends ti{},Sd=class extends ti{},yv=class extends ti{},uR=class extends ot{constructor(e){super(),this._onSuccess=t=>{if(this._map){if(this._isOutOfMapMaxBounds(t)){this._setErrorState(),this.fire(new Sd("outofmaxbounds",t)),this._updateMarker(),this._finish();return}if(this.options.trackUserLocation)switch(this._lastKnownPosition=t,this._watchState){case"WAITING_ACTIVE":case"ACTIVE_LOCK":case"ACTIVE_ERROR":this._watchState="ACTIVE_LOCK",this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-waiting"),this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-active-error"),this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-active");break;case"BACKGROUND":case"BACKGROUND_ERROR":this._watchState="BACKGROUND",this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-waiting"),this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-background-error"),this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-background");break;default:throw Error(`Unexpected watchState ${this._watchState}`)}this.options.showUserLocation&&this._watchState!=="OFF"&&this._updateMarker(t),(!this.options.trackUserLocation||this._watchState==="ACTIVE_LOCK")&&this._updateCamera(t),this.options.showUserLocation&&this._dotElement.classList.remove("maplibregl-user-location-dot-stale"),this.fire(new Sd("geolocate",t)),this._finish()}},this._updateCamera=t=>{let i=new W(t.coords.longitude,t.coords.latitude),r=t.coords.accuracy,a=this._map.getBearing(),n=Z({bearing:a},this.options.fitBoundsOptions),s=Mi.fromLngLat(i,r);this._map.fitBounds(s,n,{geolocateSource:!0})},this._updateMarker=t=>{if(t){let i=new W(t.coords.longitude,t.coords.latitude);this._accuracyCircleMarker.setLngLat(i).addTo(this._map),this._userLocationDotMarker.setLngLat(i).addTo(this._map),this._accuracy=t.coords.accuracy,this._updateCircleRadiusIfNeeded()}else this._userLocationDotMarker.remove(),this._accuracyCircleMarker.remove()},this._onUpdate=()=>{this._updateCircleRadiusIfNeeded()},this._onError=t=>{if(this._map){if(t.code===1){this._watchState="OFF",this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-waiting"),this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-active"),this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-active-error"),this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-background"),this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-background-error"),this._geolocateButton.disabled=!0;let i=this._map._getUIString("GeolocateControl.LocationNotAvailable");this._geolocateButton.title=i,this._geolocateButton.setAttribute("aria-label",i),this._geolocationWatchID!==void 0&&this._clearWatch()}else{if(t.code===3&&vs)return;this._setErrorState()}this._watchState!=="OFF"&&this.options.showUserLocation&&this._dotElement.classList.add("maplibregl-user-location-dot-stale"),this.fire(new yv("error",t)),this._finish()}},this._finish=()=>{this._timeoutId&&clearTimeout(this._timeoutId),this._timeoutId=void 0},this._onMoveStart=t=>{if(!this._map)return;let i=(t==null?void 0:t[0])instanceof ResizeObserverEntry;!t.geolocateSource&&this._watchState==="ACTIVE_LOCK"&&!i&&!this._map.isZooming()&&(this._watchState="BACKGROUND",this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-background"),this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-active"),this.fire(new ga("trackuserlocationend")),this.fire(new ga("userlocationlostfocus")))},this._setupUI=()=>{this._map&&(this._container.addEventListener("contextmenu",t=>{t.preventDefault()}),this._geolocateButton=Q.create("button","maplibregl-ctrl-geolocate",this._container),Q.create("span","maplibregl-ctrl-icon",this._geolocateButton).setAttribute("aria-hidden","true"),this._geolocateButton.type="button",this._geolocateButton.disabled=!0)},this._finishSetupUI=t=>{if(this._map){if(t===!1){le("Geolocation support is not available so the GeolocateControl will be disabled.");let i=this._map._getUIString("GeolocateControl.LocationNotAvailable");this._geolocateButton.disabled=!0,this._geolocateButton.title=i,this._geolocateButton.setAttribute("aria-label",i)}else{let i=this._map._getUIString("GeolocateControl.FindMyLocation");this._geolocateButton.disabled=!1,this._geolocateButton.title=i,this._geolocateButton.setAttribute("aria-label",i)}this.options.trackUserLocation&&(this._geolocateButton.setAttribute("aria-pressed","false"),this._watchState="OFF"),this.options.showUserLocation&&(this._dotElement=Q.create("div","maplibregl-user-location-dot"),this._userLocationDotMarker=new Td({element:this._dotElement}),this._circleElement=Q.create("div","maplibregl-user-location-accuracy-circle"),this._accuracyCircleMarker=new Td({element:this._circleElement,pitchAlignment:"map"}),this.options.trackUserLocation&&(this._watchState="OFF"),this._map.on("zoom",this._onUpdate),this._map.on("move",this._onUpdate),this._map.on("rotate",this._onUpdate),this._map.on("pitch",this._onUpdate)),this._geolocateButton.addEventListener("click",()=>this.trigger()),this._setup=!0,this.options.trackUserLocation&&this._map.on("movestart",this._onMoveStart)}},this.options=Z({},lR,e)}onAdd(e){return this._map=e,this._container=Q.create("div","maplibregl-ctrl maplibregl-ctrl-group"),this._setupUI(),nR().then(t=>this._finishSetupUI(t)),this._container}onRemove(){this._geolocationWatchID!==void 0&&(window.navigator.geolocation.clearWatch(this._geolocationWatchID),this._geolocationWatchID=void 0),this.options.showUserLocation&&this._userLocationDotMarker&&this._userLocationDotMarker.remove(),this.options.showAccuracyCircle&&this._accuracyCircleMarker&&this._accuracyCircleMarker.remove(),this._container.remove(),this._map.off("movestart",this._onMoveStart),this._map.off("zoom",this._onUpdate),this._map.off("move",this._onUpdate),this._map.off("rotate",this._onUpdate),this._map.off("pitch",this._onUpdate),this._map=void 0,kl=0,vs=!1}_isOutOfMapMaxBounds(e){let t=this._map.getMaxBounds(),i=e.coords;return t&&(i.longitude<t.getWest()||i.longitude>t.getEast()||i.latitude<t.getSouth()||i.latitude>t.getNorth())}_setErrorState(){switch(this._watchState){case"WAITING_ACTIVE":this._watchState="ACTIVE_ERROR",this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-active"),this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-active-error");break;case"ACTIVE_LOCK":this._watchState="ACTIVE_ERROR",this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-active"),this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-active-error"),this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-waiting");break;case"BACKGROUND":this._watchState="BACKGROUND_ERROR",this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-background"),this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-background-error"),this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-waiting");break;case"ACTIVE_ERROR":case"BACKGROUND_ERROR":break;case"OFF":case void 0:break;default:throw Error(`Unexpected watchState ${this._watchState}`)}}_updateCircleRadiusIfNeeded(){let e=this._userLocationDotMarker.getLngLat();if(!this.options.showUserLocation||!this.options.showAccuracyCircle||!this._accuracy||!e)return;let t=this._map.project(e),i=this._map.unproject([t.x+100,t.y]),r=e.distanceTo(i)/100,a=2*this._accuracy/r;this._circleElement.style.width=`${a.toFixed(2)}px`,this._circleElement.style.height=`${a.toFixed(2)}px`}trigger(){if(!this._setup)return le("Geolocate control triggered before added to a map"),!1;if(this.options.trackUserLocation){switch(this._watchState){case"OFF":this._watchState="WAITING_ACTIVE",this.fire(new ga("trackuserlocationstart"));break;case"WAITING_ACTIVE":case"ACTIVE_LOCK":case"ACTIVE_ERROR":case"BACKGROUND_ERROR":kl--,vs=!1,this._watchState="OFF",this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-waiting"),this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-active"),this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-active-error"),this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-background"),this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-background-error"),this.fire(new ga("trackuserlocationend"));break;case"BACKGROUND":this._watchState="ACTIVE_LOCK",this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-background"),this._lastKnownPosition&&this._updateCamera(this._lastKnownPosition),this.fire(new ga("trackuserlocationstart")),this.fire(new ga("userlocationfocus"));break;default:throw Error(`Unexpected watchState ${this._watchState}`)}switch(this._watchState){case"WAITING_ACTIVE":this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-waiting"),this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-active");break;case"ACTIVE_LOCK":this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-active");break;case"OFF":break;default:throw Error(`Unexpected watchState ${this._watchState}`)}if(this._watchState==="OFF"&&this._geolocationWatchID!==void 0)this._clearWatch();else if(this._geolocationWatchID===void 0){this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-waiting"),this._geolocateButton.setAttribute("aria-pressed","true"),kl++;let e;kl>1?(e={maximumAge:6e5,timeout:0},vs=!0):(e=this.options.positionOptions,vs=!1),this._geolocationWatchID=window.navigator.geolocation.watchPosition(this._onSuccess,this._onError,e)}}else window.navigator.geolocation.getCurrentPosition(this._onSuccess,this._onError,this.options.positionOptions),this._timeoutId=setTimeout(this._finish,1e4);return!0}_clearWatch(){window.navigator.geolocation.clearWatch(this._geolocationWatchID),this._geolocationWatchID=void 0,this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-waiting"),this._geolocateButton.setAttribute("aria-pressed","false"),this.options.showUserLocation&&this._updateMarker(null)}};const hR={maxWidth:100,unit:"metric"};var cR=class{constructor(e){this._onMove=()=>{vv(this._map,this._container,this.options)},this.setUnit=t=>{this.options.unit=t,vv(this._map,this._container,this.options)},this.options={...hR,...e}}getDefaultPosition(){return"bottom-left"}onAdd(e){return this._map=e,this._container=Q.create("div","maplibregl-ctrl maplibregl-ctrl-scale",e.getContainer()),this._map.on("move",this._onMove),this._onMove(),this._container}onRemove(){this._container.remove(),this._map.off("move",this._onMove),this._map=void 0}};function vv(e,t,i){let r=(i==null?void 0:i.maxWidth)||100,a=e._container.clientHeight/2,n=e._container.clientWidth/2,s=e.unproject([n-r/2,a]),o=e.unproject([n+r/2,a]),l=Math.round(e.project(o).x-e.project(s).x),u=Math.min(r,l,e._container.clientWidth),h=s.distanceTo(o);if((i==null?void 0:i.unit)==="imperial"){let c=3.2808*h;c>5280?xs(t,u,c/5280,e._getUIString("ScaleControl.Miles")):xs(t,u,c,e._getUIString("ScaleControl.Feet"))}else(i==null?void 0:i.unit)==="nautical"?xs(t,u,h/1852,e._getUIString("ScaleControl.NauticalMiles")):h>=1e3?xs(t,u,h/1e3,e._getUIString("ScaleControl.Kilometers")):xs(t,u,h,e._getUIString("ScaleControl.Meters"))}function xs(e,t,i,r){let a=pR(i),n=a/i;e.style.width=`${t*n}px`,e.innerHTML=`${a} ${r}`}function dR(e){let t=10**Math.ceil(-Math.log(e)/Math.LN10);return Math.round(e*t)/t}function pR(e){let t=10**(`${Math.floor(e)}`.length-1),i=e/t;return i=i>=10?10:i>=5?5:i>=3?3:i>=2?2:i>=1?1:dR(i),t*i}var Ed=class extends ti{},fR=class extends ot{constructor(e={}){super(),this._onFullscreenChange=()=>{var i;let t=window.document.fullscreenElement||window.document.webkitFullscreenElement;for(;(i=t==null?void 0:t.shadowRoot)!=null&&i.fullscreenElement;)t=t.shadowRoot.fullscreenElement;t===this._container!==this._fullscreen&&this._handleFullscreenChange()},this._onClickFullscreen=()=>{this._isFullscreen()?this._exitFullscreen():this._requestFullscreen()},this._fullscreen=!1,this._pseudo=e.pseudo??!1,e!=null&&e.container&&(e.container instanceof HTMLElement?this._container=e.container:le("Full screen control 'container' must be a DOM element.")),"onfullscreenchange"in document?this._fullscreenchange="fullscreenchange":"onmozfullscreenchange"in document?this._fullscreenchange="mozfullscreenchange":"onwebkitfullscreenchange"in document?this._fullscreenchange="webkitfullscreenchange":"onmsfullscreenchange"in document&&(this._fullscreenchange="MSFullscreenChange")}onAdd(e){return this._map=e,this._container||(this._container=this._map.getContainer()),this._controlContainer=Q.create("div","maplibregl-ctrl maplibregl-ctrl-group"),this._setupUI(),this._controlContainer}onRemove(){this._controlContainer.remove(),this._map=null,window.document.removeEventListener(this._fullscreenchange,this._onFullscreenChange)}_setupUI(){let e=this._fullscreenButton=Q.create("button","maplibregl-ctrl-fullscreen",this._controlContainer);Q.create("span","maplibregl-ctrl-icon",e).setAttribute("aria-hidden","true"),e.type="button",this._updateTitle(),this._fullscreenButton.addEventListener("click",this._onClickFullscreen),window.document.addEventListener(this._fullscreenchange,this._onFullscreenChange)}_updateTitle(){let e=this._getTitle();this._fullscreenButton.setAttribute("aria-label",e),this._fullscreenButton.title=e}_getTitle(){return this._map._getUIString(this._isFullscreen()?"FullscreenControl.Exit":"FullscreenControl.Enter")}_isFullscreen(){return this._fullscreen}_handleFullscreenChange(){this._fullscreen=!this._fullscreen,this._fullscreenButton.classList.toggle("maplibregl-ctrl-shrink"),this._fullscreenButton.classList.toggle("maplibregl-ctrl-fullscreen"),this._updateTitle(),this._fullscreen?(this.fire(new Ed("fullscreenstart")),this._prevCooperativeGesturesEnabled=this._map.cooperativeGestures.isEnabled(),this._map.cooperativeGestures.disable()):(this.fire(new Ed("fullscreenend")),this._prevCooperativeGesturesEnabled&&this._map.cooperativeGestures.enable())}_exitFullscreen(){this._pseudo?this._togglePseudoFullScreen():window.document.exitFullscreen?window.document.exitFullscreen():window.document.webkitCancelFullScreen?window.document.webkitCancelFullScreen():this._togglePseudoFullScreen()}_requestFullscreen(){this._pseudo?this._togglePseudoFullScreen():this._container.requestFullscreen?this._container.requestFullscreen():this._container.webkitRequestFullscreen?this._container.webkitRequestFullscreen():this._togglePseudoFullScreen()}_togglePseudoFullScreen(){this._container.classList.toggle("maplibregl-pseudo-fullscreen"),this._handleFullscreenChange(),this._map.resize()}},mR=class{constructor(e){this._toggleTerrain=()=>{this._map.getTerrain()?this._map.setTerrain(null):this._map.setTerrain(this.options),this._updateTerrainIcon()},this._updateTerrainIcon=()=>{this._terrainButton.classList.remove("maplibregl-ctrl-terrain"),this._terrainButton.classList.remove("maplibregl-ctrl-terrain-enabled"),this._map.terrain?(this._terrainButton.classList.add("maplibregl-ctrl-terrain-enabled"),this._terrainButton.title=this._map._getUIString("TerrainControl.Disable")):(this._terrainButton.classList.add("maplibregl-ctrl-terrain"),this._terrainButton.title=this._map._getUIString("TerrainControl.Enable"))},this.options=e}onAdd(e){return this._map=e,this._container=Q.create("div","maplibregl-ctrl maplibregl-ctrl-group"),this._terrainButton=Q.create("button","maplibregl-ctrl-terrain",this._container),Q.create("span","maplibregl-ctrl-icon",this._terrainButton).setAttribute("aria-hidden","true"),this._terrainButton.type="button",this._terrainButton.addEventListener("click",this._toggleTerrain),this._updateTerrainIcon(),this._map.on("terrain",this._updateTerrainIcon),this._container}onRemove(){this._container.remove(),this._map.off("terrain",this._updateTerrainIcon),this._map=void 0}},gR=class{constructor(){this._toggleProjection=()=>{var t;let e=(t=this._map.getProjection())==null?void 0:t.type;e==="mercator"||!e?this._map.setProjection({type:"globe"}):this._map.setProjection({type:"mercator"}),this._updateGlobeIcon()},this._updateGlobeIcon=()=>{var e;this._globeButton.classList.remove("maplibregl-ctrl-globe"),this._globeButton.classList.remove("maplibregl-ctrl-globe-enabled"),((e=this._map.getProjection())==null?void 0:e.type)==="globe"?(this._globeButton.classList.add("maplibregl-ctrl-globe-enabled"),this._globeButton.title=this._map._getUIString("GlobeControl.Disable")):(this._globeButton.classList.add("maplibregl-ctrl-globe"),this._globeButton.title=this._map._getUIString("GlobeControl.Enable"))}}onAdd(e){return this._map=e,this._container=Q.create("div","maplibregl-ctrl maplibregl-ctrl-group"),this._globeButton=Q.create("button","maplibregl-ctrl-globe",this._container),Q.create("span","maplibregl-ctrl-icon",this._globeButton).setAttribute("aria-hidden","true"),this._globeButton.type="button",this._globeButton.addEventListener("click",this._toggleProjection),this._updateGlobeIcon(),this._map.on("styledata",this._updateGlobeIcon),this._map.on("projectiontransition",this._updateGlobeIcon),this._container}onRemove(){this._container.remove(),this._map.off("styledata",this._updateGlobeIcon),this._map.off("projectiontransition",this._updateGlobeIcon),this._globeButton.removeEventListener("click",this._toggleProjection),this._map=void 0}};const _R={closeButton:!0,closeOnClick:!0,focusAfterOpen:!0,className:"",maxWidth:"240px",subpixelPositioning:!1,locationOccludedOpacity:void 0,padding:void 0},yR=["a[href]","[tabindex]:not([tabindex='-1'])","[contenteditable]:not([contenteditable='false'])","button:not([disabled])","input:not([disabled])","select:not([disabled])","textarea:not([disabled])"].join(", ");var Pd=class extends ti{},vR=class extends ot{constructor(e){super(),this._updateOpacity=()=>{this.options.locationOccludedOpacity!==void 0&&(this._map._camera.transform.isLocationOccluded(this.getLngLat())?this._container.style.opacity=`${this.options.locationOccludedOpacity}`:this._container.style.opacity="")},this.remove=()=>(this._content&&this._content.remove(),this._container&&(this._container.remove(),delete this._container),this._map&&(this._map.off("move",this._update),this._map.off("move",this._onClose),this._map.off("click",this._onClose),this._map.off("remove",this.remove),this._map.off("terrain",this._update),this._map.off("projectiontransition",this._update),this._map.off("mousemove",this._update),this._map.off("mouseup",this._update),this._map.off("drag",this._update),this._map._canvasContainer.classList.remove("maplibregl-track-pointer"),delete this._map,this.fire(new Pd("close"))),this),this._update=t=>{let i=this._lngLat||this._trackPointer;if(!this._map||!i||!this._content)return;if(!this._container){if(this._container=Q.create("div","maplibregl-popup",this._map.getContainer()),this._tip=Q.create("div","maplibregl-popup-tip",this._container),this._container.appendChild(this._content),this.options.className)for(let l of this.options.className.split(" "))this._container.classList.add(l);this._closeButton&&this._closeButton.setAttribute("aria-label",this._map._getUIString("Popup.Close")),this._trackPointer&&this._container.classList.add("maplibregl-popup-track-pointer")}this.options.maxWidth&&this._container.style.maxWidth!==this.options.maxWidth&&(this._container.style.maxWidth=this.options.maxWidth),this._lngLat=pv(this._lngLat,this._flatPos,this._map._camera.transform,this._trackPointer);let r;if(t&&"point"in t&&t.point&&(r=t.point),this._trackPointer&&!r)return;let a=this._flatPos=this._pos=this._trackPointer&&r?r:this._map.project(this._lngLat);this._map.terrain&&(this._flatPos=this._trackPointer&&r?r:this._map._camera.transform.locationToScreenPoint(this._lngLat));let n=this.options.anchor,s=xv(this.options.offset);if(!n){let l=this._container.offsetWidth,u=this._container.offsetHeight,h=xR(this.options.padding),c;c=a.y+s.bottom.y<u+h.top?["top"]:a.y>this._map._camera.transform.height-u-h.bottom?["bottom"]:[],a.x<l/2+h.left?c.push("left"):a.x>this._map._camera.transform.width-l/2-h.right&&c.push("right"),n=c.length===0?"bottom":c.join("-")}let o=a.add(s[n]);this.options.subpixelPositioning||(o=o.round()),this._container.style.transform=`${bd[n]} translate(${o.x}px,${o.y}px)`,fv(this._container,n,"popup"),this._updateOpacity()},this._onClose=()=>{this.remove()},this.options=Z(Object.create(_R),e)}addTo(e){return this._map&&this.remove(),this._map=e,this.options.closeOnClick&&this._map.on("click",this._onClose),this.options.closeOnMove&&this._map.on("move",this._onClose),this._map.on("remove",this.remove),this._map.on("terrain",this._update),this._map.on("projectiontransition",this._update),this._update(),this._focusFirstElement(),this._trackPointer?(this._map.on("mousemove",this._update),this._map.on("mouseup",this._update),this._container&&this._container.classList.add("maplibregl-popup-track-pointer"),this._map._canvasContainer.classList.add("maplibregl-track-pointer")):this._map.on("move",this._update),this.fire(new Pd("open")),this}isOpen(){return!!this._map}getLngLat(){return this._lngLat}setLngLat(e){return this._lngLat=W.convert(e),this._pos=null,this._flatPos=null,this._trackPointer=!1,this._update(),this._map&&(this._map.on("move",this._update),this._map.off("mousemove",this._update),this._container&&this._container.classList.remove("maplibregl-popup-track-pointer"),this._map._canvasContainer.classList.remove("maplibregl-track-pointer")),this}trackPointer(){return this._trackPointer=!0,this._pos=null,this._flatPos=null,this._update(),this._map&&(this._map.off("move",this._update),this._map.on("mousemove",this._update),this._map.on("drag",this._update),this._container&&this._container.classList.add("maplibregl-popup-track-pointer"),this._map._canvasContainer.classList.add("maplibregl-track-pointer")),this}getElement(){return this._container}setText(e){return this.setDOMContent(document.createTextNode(e))}setHTML(e){let t=document.createDocumentFragment(),i=document.createElement("body"),r;for(i.innerHTML=e;r=i.firstChild,r;)t.appendChild(r);return this.setDOMContent(t)}getMaxWidth(){var e;return(e=this._container)==null?void 0:e.style.maxWidth}setMaxWidth(e){return this.options.maxWidth=e,this._update(),this}setDOMContent(e){if(this._content)for(;this._content.hasChildNodes();)this._content.firstChild&&this._content.removeChild(this._content.firstChild);else this._content=Q.create("div","maplibregl-popup-content",this._container);return this._content.appendChild(e),this._createCloseButton(),this._update(),this._focusFirstElement(),this}addClassName(e){return this._container&&this._container.classList.add(e),this}removeClassName(e){return this._container&&this._container.classList.remove(e),this}setOffset(e){return this.options.offset=e,this._update(),this}toggleClassName(e){if(this._container)return this._container.classList.toggle(e)}setSubpixelPositioning(e){this.options.subpixelPositioning=e}setPadding(e){this.options.padding=e,this._update()}_createCloseButton(){this.options.closeButton&&(this._closeButton=Q.create("button","maplibregl-popup-close-button",this._content),this._closeButton.type="button",this._closeButton.innerHTML="×",this._closeButton.addEventListener("click",this._onClose))}_focusFirstElement(){if(!this.options.focusAfterOpen||!this._container)return;let e=this._container.querySelector(yR);e&&e.focus()}};function xv(e){if(!e)return xv(new C(0,0));if(typeof e=="number"){let t=Math.round(Math.abs(e)/Math.SQRT2);return{center:new C(0,0),top:new C(0,e),"top-left":new C(t,t),"top-right":new C(-t,t),bottom:new C(0,-e),"bottom-left":new C(t,-t),"bottom-right":new C(-t,-t),left:new C(e,0),right:new C(-e,0)}}if(e instanceof C||Array.isArray(e)){let t=C.convert(e);return{center:t,top:t,"top-left":t,"top-right":t,bottom:t,"bottom-left":t,"bottom-right":t,left:t,right:t}}return{center:C.convert(e.center||[0,0]),top:C.convert(e.top||[0,0]),"top-left":C.convert(e["top-left"]||[0,0]),"top-right":C.convert(e["top-right"]||[0,0]),bottom:C.convert(e.bottom||[0,0]),"bottom-left":C.convert(e["bottom-left"]||[0,0]),"bottom-right":C.convert(e["bottom-right"]||[0,0]),left:C.convert(e.left||[0,0]),right:C.convert(e.right||[0,0])}}function xR(e){return e?{top:e.top??0,right:e.right??0,bottom:e.bottom??0,left:e.left??0}:{top:0,right:0,bottom:0,left:0}}const bR=O_;function wR(e,t){return ls().setRTLTextPlugin(e,t)}function TR(){return ls().getRTLTextPluginStatus()}function SR(){return bR}function ER(){return ll.workerCount}function PR(e){ll.workerCount=e}function CR(){return ei.MAX_PARALLEL_IMAGE_REQUESTS}function AR(e){ei.MAX_PARALLEL_IMAGE_REQUESTS=e}function DR(){return ei.WORKER_URL}function IR(e){ei.WORKER_URL=e}async function MR(e){await Mc().broadcast("IS",e)}const bv=Object.freeze(Object.defineProperty({__proto__:null,AJAXError:fn,AttributionControl:uv,BoxZoomHandler:W0,CanvasSource:gy,CooperativeGesturesHandler:ov,DoubleClickZoomHandler:rv,DragPanHandler:av,DragRotateHandler:nv,EXTENT:k,EdgeInsets:Xc,ErrorEvent:K,Event:ti,Evented:ot,FullscreenControl:fR,FullscreenEvent:Ed,GPUInitializationError:G0,GeoJSONSource:cy,GeolocateControl:uR,GeolocateErrorEvent:yv,GeolocateEvent:ga,GeolocatePositionEvent:Sd,GlobeControl:gR,Hash:q0,ImageSource:Qa,KeyboardHandler:ev,LngLat:W,LngLatBounds:Mi,LogoControl:hv,Map:dv,MapBoxZoomEvent:Sc,MapContextEvent:nl,MapLibreEvent:gt,MapLibreMap:dv,MapMouseEvent:ai,MapMovementEvent:Y,MapProjectionEvent:G_,MapSourceDataEvent:Re,MapStyleDataEvent:vi,MapStyleImageMissingEvent:Z_,MapStyleLoadEvent:Tc,MapTerrainEvent:U_,MapTouchEvent:ss,MapWheelEvent:j_,Marker:Td,MarkerClickEvent:_v,MarkerDragEvent:ma,MercatorCoordinate:ye,NavigationControl:rR,Point:C,Popup:vR,PopupEvent:Pd,RasterDEMTileSource:oy,RasterTileSource:zc,ScaleControl:cR,ScrollZoomHandler:iv,Style:rd,TerrainControl:mR,TwoFingersTouchPitchHandler:Q0,TwoFingersTouchRotateHandler:J0,TwoFingersTouchZoomHandler:Y0,TwoFingersTouchZoomRotateHandler:sv,VectorTileSource:sy,VideoSource:my,addProtocol:Ux,addSourceType:pI,clearPrewarmedResources:ND,config:ei,createTileMesh:py,getGlobalDispatcher:Mc,getMaxParallelImageRequests:CR,getRTLTextPluginStatus:TR,getVersion:SR,getWorkerCount:ER,getWorkerUrl:DR,importScriptInWorkers:MR,isTimeFrozen:aD,now:Te,prewarm:OD,removeProtocol:Gx,restoreNow:rD,setMaxParallelImageRequests:AR,setNow:iD,setRTLTextPlugin:wR,setWorkerCount:PR,setWorkerUrl:IR},Symbol.toStringTag,{value:"Module"}));var wv=[{text:"© MapsLibVN",href:"https://github.com/dotienphong/maps-library-vietnam"},{text:"© OpenStreetMap contributors",href:"https://www.openstreetmap.org/copyright",license:"ODbL"},{text:"© OpenMapTiles",href:"https://openmaptiles.org/"},{text:"Places: Overture Maps Foundation",href:"https://overturemaps.org/",license:"CDLA-Permissive 2.0"},{text:"Foursquare OS Places",href:"https://opensource.foursquare.com/os-places/",license:"Apache-2.0"}],Tv=(e,t)=>e.license?`${t} (${e.license})`:t;function zR(e){return e.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""")}function Sv(e){const[t,i,r,a,n]=e;return`${t} · ${i} · ${r} · ${a}, ${n}`}function FR(){return Sv(wv.map(e=>Tv(e,e.text)))}function Ev(){return Sv(wv.map(e=>Tv(e,`<a href="${e.href}" target="_blank" rel="noopener">${zR(e.text)}</a>`)))}var Pv=class extends Error{constructor(t,i,r,a){super(r);As(this,"status");As(this,"code");As(this,"requestId");this.name="MapsLibVNError",this.status=t,this.code=i,this.requestId=a}},Cv=["osm","overture","fsq"],Ll={all:["osm","overture","fsq"],osm:["osm"],"osm-fsq":["osm","fsq"],"overture-fsq":["overture","fsq"],overture:["overture"],fsq:["fsq"]},Cd=Ll.all,RR=e=>Cv.includes(e);function Ad(e){if(e.length===0||!e.every(RR))return null;const t=new Set(e);return Cv.filter(i=>t.has(i))}function kR(e){const t=(e==null?void 0:e.trim())??"";return t?t==="all"?[...Ll.all]:Ad(t.split(",").map(i=>i.trim())):[...Cd]}function Av(e){return(Ad(e)??[]).join(",")}function LR(e){const t=Av(e);for(const[i,r]of Object.entries(Ll))if(r.join(",")===t)return i;return null}function Dd(e){const t=e.baseUrl.replace(/\/+$/,""),i=Ad(e.poiSources??Cd);if(!i)throw new Error(`poiSources không hợp lệ: ${JSON.stringify(e.poiSources)}`);const r=Av(i),a=e.fetch??globalThis.fetch.bind(globalThis),n=()=>({...e.headers??{},"X-Api-Key":e.apiKey});async function s(u){var h,c,d;if(!u.ok){let p={};try{p=await u.json()}catch{}throw new Pv(u.status,((h=p.error)==null?void 0:h.code)??"http_error",((c=p.error)==null?void 0:c.message)??`HTTP ${u.status}`,(d=p.error)==null?void 0:d.request_id)}return await u.json()}async function o(u,h={}){const c=new URL(t+u);for(const[p,f]of Object.entries(h))f!==void 0&&c.searchParams.set(p,String(f));const d=await a(c,{headers:n()});return s(d)}async function l(u,h){const c=await a(new URL(t+u),{method:"POST",headers:{...n(),"content-type":"application/json"},body:JSON.stringify(h)});return s(c)}return{baseUrl:t,attribution:()=>o("/v1/attribution"),styleUrl:u=>`${t}/v1/styles/${u}.json?key=${encodeURIComponent(e.apiKey)}&sources=${encodeURIComponent(r)}`,autocomplete:(u,h={})=>{var c,d;return o("/v1/autocomplete",{q:u,near:(c=h.near)==null?void 0:c.join(","),limit:h.limit,types:(d=h.types)==null?void 0:d.join(","),sources:r})},search:(u,h={})=>{var c,d;return o("/v1/search",{q:u,category:h.category,near:(c=h.near)==null?void 0:c.join(","),radius:h.radius,bbox:(d=h.bbox)==null?void 0:d.join(","),limit:h.limit,offset:h.offset,sources:r})},nearby:u=>o("/v1/nearby",{lat:u.lat,lng:u.lng,radius:u.radius,category:u.category,limit:u.limit,sources:r}),getPlace:u=>o(`/v1/places/${encodeURIComponent(u)}`),geocode:(u,h={})=>{var c;return o("/v1/geocode",{q:u,near:(c=h.near)==null?void 0:c.join(","),limit:h.limit})},reverse:(u,h)=>o("/v1/reverse",{lat:u,lng:h,sources:r}),suggestEdit:u=>l("/v1/edits",u)}}var BR={"tp.":"thanh pho","tt.":"thi tran","tx.":"thi xa","p.":"phuong","q.":"quan","h.":"huyen","x.":"xa","d.":"duong","ng.":"nguyen",kp:"khu pho",cty:"cong ty",cp:"co phan"},$R={highlands:["highlands coffee","highland coffee","highland"],cong:["cong caphe","cong ca phe","cong cafe","cong coffee"],"the coffee house":["tch","coffee house"],"phuc long":["phuc long coffee tea","phuc long tea coffee","phuc long coffee"],"trung nguyen":["trung nguyen legend","trung nguyen e-coffee","trung nguyen coffee"],starbucks:["starbucks coffee","starbucks reserve"],"circle k":["circlek"],winmart:["vinmart","vinmart plus","winmart plus"],coopmart:["co opmart","co op mart","coop mart","saigon co op"],"bach hoa xanh":["bhx"],"family mart":["familymart"],gs25:["gs 25"],"pho 24":["pho24"],kfc:["kentucky fried chicken"],vietcombank:["ngan hang vietcombank","ngan hang tmcp ngoai thuong viet nam","vcb"],techcombank:["ngan hang techcombank","tcb"],agribank:["ngan hang agribank","ngan hang nong nghiep va phat trien nong thon"],bidv:["ngan hang bidv","ngan hang dau tu va phat trien viet nam"],vietinbank:["ngan hang vietinbank","ngan hang cong thuong viet nam"],pharmacity:["nha thuoc pharmacity"],"long chau":["nha thuoc long chau","fpt long chau"],"an khang":["nha thuoc an khang"],"the gioi di dong":["tgdd"],"dien may xanh":["dmx"],"fpt shop":["fptshop"]},OR=BR,NR=$R,VR=e=>e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),jR=Object.entries(OR).map(([e,t])=>{const i=e.endsWith(".")?"":"(?=[\\s\\d,.]|$)";return{re:new RegExp(`(^|[\\s,.(])${VR(e)}${i}`,"g"),replacement:`$1${t} `}});Object.entries(NR).flatMap(([e,t])=>t.map(i=>({variant:i,canonical:e}))).sort((e,t)=>t.variant.length-e.variant.length);function UR(e){return e.normalize("NFD").replace(new RegExp("\\p{M}","gu"),"").replace(/đ/g,"d").replace(/Đ/g,"D")}function GR(e){let t=e;for(const{re:i,replacement:r}of jR)t=t.replace(i,r);return t=t.replace(/(^|\s)f\.?(?=\s*\d)/g,"$1phuong "),t.replace(/ {2,}/g," ").trim()}function ZR(e){let t=UR(e.normalize("NFC").toLowerCase());return t=GR(t),t=t.replace(/[^a-z0-9/\-\s]/g," "),t=t.replace(/\s*\/\s*/g,"/"),t=t.replace(/\s+-\s+/g," "),t.replace(/\s+/g," ").trim()}var qR={"Hà Nội":["ha noi","hanoi","hn"],Huế:["hue","thua thien hue","thua thien-hue"],"Lai Châu":["lai chau"],"Điện Biên":["dien bien"],"Sơn La":["son la"],"Lạng Sơn":["lang son"],"Quảng Ninh":["quang ninh","ha long"],"Thanh Hóa":["thanh hoa"],"Nghệ An":["nghe an","vinh"],"Hà Tĩnh":["ha tinh"],"Cao Bằng":["cao bang"],"Tuyên Quang":["tuyen quang","ha giang"],"Lào Cai":["lao cai","yen bai","sa pa","sapa"],"Thái Nguyên":["thai nguyen","bac kan","bac can"],"Phú Thọ":["phu tho","vinh phuc","hoa binh","viet tri"],"Bắc Ninh":["bac ninh","bac giang"],"Hưng Yên":["hung yen","thai binh"],"Hải Phòng":["hai phong","hai duong"],"Ninh Bình":["ninh binh","ha nam","nam dinh"],"Quảng Trị":["quang tri","quang binh","dong hoi"],"Đà Nẵng":["da nang","danang","quang nam","hoi an","tam ky"],"Quảng Ngãi":["quang ngai","kon tum"],"Gia Lai":["gia lai","binh dinh","quy nhon","pleiku"],"Khánh Hòa":["khanh hoa","ninh thuan","nha trang","cam ranh","phan rang"],"Lâm Đồng":["lam dong","dak nong","dac nong","binh thuan","da lat","dalat","phan thiet"],"Đắk Lắk":["dak lak","dac lac","daklak","phu yen","buon ma thuot","tuy hoa"],"Thành phố Hồ Chí Minh":["ho chi minh","hcm","tphcm","sai gon","saigon","binh duong","ba ria vung tau","ba ria-vung tau","ba ria","vung tau","thu dau mot","di an"],"Đồng Nai":["dong nai","binh phuoc","bien hoa","dong xoai"],"Tây Ninh":["tay ninh","long an","tan an"],"Cần Thơ":["can tho","soc trang","hau giang","vi thanh"],"Vĩnh Long":["vinh long","ben tre","tra vinh"],"Đồng Tháp":["dong thap","tien giang","my tho","cao lanh","sa dec"],"Cà Mau":["ca mau","bac lieu"],"An Giang":["an giang","kien giang","rach gia","phu quoc","long xuyen","chau doc"]},Dv=new Map;for(const[e,t]of Object.entries(qR)){Dv.set(ZR(e).replace(/^thanh pho /,""),e);for(const i of t)Dv.set(i,e)}var WR="poi",HR="sovereignty-label";function XR(e){return e.id===WR||e.source==="poi"}function Iv(e){return["coalesce",["get",`name:${e}`],["get","name"]]}function YR(e){var i;if(e.type!=="symbol"||e.id===HR)return!1;const t=(i=e.layout)==null?void 0:i["text-field"];return t!==void 0&&JSON.stringify(t).includes("name")}var KR={"quy nhon":{variants:["qui nhon"],source:"osm:node/369487010 alt_name"},"dak lak":{variants:["darlac","daklak"],source:"osm:relation/1884034 alt_name"},"buon ma thuot":{variants:["buon me thuot","ban me thuot","buon ma thot"],source:"osm:node/2502425156 alt_name"},"da nang":{variants:["tourane"],source:"osm:relation/1891418 old_name"},hue:{variants:["thua thien hue","thua thien"],source:"osm:relation/1891483 old_name"},"tan son nhat":{variants:["tan son nhut"],source:"osm:node/13097604035 old_name"},"hoi an":{variants:["faifo"],source:"osm:node/110506070 old_name"},"soc trang":{variants:["khanh hung"],source:"osm:node/369487102 old_name"},"can tho":{variants:["tay do","phong dinh"],source:"osm:node/948325197 old_name"},"ca mau":{variants:["an xuyen"],source:"osm:relation/1873490 old_name"},"ha noi":{variants:["thang long"],source:"osm:relation/1903516 old_name"}},JR=e=>typeof e=="object"&&e!==null&&"variants"in e&&"source"in e,QR=Object.fromEntries(Object.entries(KR).filter(e=>!e[0].startsWith("$")&&JR(e[1]))),ek=e=>e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&");Object.entries(QR).flatMap(([e,{variants:t}])=>t.map(i=>({variant:i,canonical:e}))).sort((e,t)=>t.variant.length-e.variant.length).map(({variant:e,canonical:t})=>({re:new RegExp(`(^|\\s)${ek(e)}(?=\\s|$)`,"g"),replacement:`$1${t}`}));var tk={wordStart:[["^ngh","ng"],["^gh","g"],["^ph","f"],["^gi(?=[aeiouy])","d"],["^r","d"],["^tr","c"],["^ch","c"],["^x","s"],["^k(?=[aou])","c"]],wordEnd:[["ng$","n"],["nh$","n"],["t$","c"]],anywhere:[["quy","qui"],["([bcdfghklmnpqrstvx])y$","$1i"]]},Id=tk,Md=e=>e.map(([t,i])=>({re:new RegExp(t),replacement:i}));Md(Id.wordStart),Md(Id.wordEnd),Md(Id.anywhere);const ik=`
|
|
824
|
+
:host { display: block; position: relative; color: #172033; font: 14px system-ui, sans-serif; }
|
|
825
|
+
input { width: 100%; box-sizing: border-box; padding: 10px 12px; border: 1px solid #9ca8ba;
|
|
826
|
+
border-radius: 8px; color: inherit; background: #fff; font: inherit; outline: none; }
|
|
827
|
+
input:focus { border-color: #2458a6; box-shadow: 0 0 0 3px rgba(36,88,166,.18); }
|
|
828
|
+
ul { position: absolute; left: 0; right: 0; margin: 4px 0 0; padding: 4px; list-style: none;
|
|
829
|
+
background: #fff; border: 1px solid #c7cfda; border-radius: 8px; z-index: 30;
|
|
830
|
+
max-height: 280px; overflow-y: auto; box-shadow: 0 8px 24px rgba(23,32,51,.16); }
|
|
831
|
+
li { padding: 8px 10px; border-radius: 5px; cursor: pointer; }
|
|
832
|
+
li:hover, li[aria-selected="true"] { background: #e9f1fc; }
|
|
833
|
+
.secondary { color: #667085; font-size: 12px; display: block; margin-top: 2px; }
|
|
834
|
+
.icon { display: inline-block; width: 1.2em; color: #667085; font-size: 12px; }
|
|
835
|
+
li[data-type="area"] .icon { color: #2458a6; }
|
|
836
|
+
.status { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
|
|
837
|
+
overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }
|
|
838
|
+
`;let rk=0;const Mv={poi:"●",street:"─",address:"⌂",area:"▣"};class zd extends HTMLElement{constructor(){super(...arguments);kt(this,De);kt(this,Hi,null);kt(this,Fr,null);kt(this,Xe,null);kt(this,Xt,null);kt(this,Rr,null);kt(this,kr,[]);kt(this,hr);kt(this,li,0);kt(this,cr,-1);kt(this,ln,`mapslibvn-autocomplete-${++rk}`);kt(this,Ts,()=>{var r;clearTimeout(q(this,hr)),dr(this,li)._++;const i=((r=q(this,Xe))==null?void 0:r.value)??"";if(i.trim().length<2){dr(this,li)._++,nt(this,De,mr).call(this,[]),nt(this,De,xa).call(this,"");return}nt(this,De,xa).call(this,"Đang tìm…"),Lt(this,hr,setTimeout(()=>void nt(this,De,U1).call(this,i),200))});kt(this,Ss,()=>{dr(this,li)._++,Lt(this,hr,setTimeout(()=>nt(this,De,mr).call(this,[]),150))});kt(this,Es,i=>{if(i.key==="Escape"){clearTimeout(q(this,hr)),dr(this,li)._++,nt(this,De,mr).call(this,[]);return}if(q(this,kr).length!==0)if(i.key==="ArrowDown"||i.key==="ArrowUp"){i.preventDefault();const r=i.key==="ArrowDown"?1:-1,a=q(this,cr)<0?r>0?-1:0:q(this,cr);nt(this,De,G1).call(this,(a+r+q(this,kr).length)%q(this,kr).length)}else i.key==="Enter"&&q(this,cr)>=0&&(i.preventDefault(),nt(this,De,Qd).call(this,q(this,cr)))});kt(this,Ps,i=>{i.preventDefault();const r=i.target.closest('[role="option"]');r&&nt(this,De,Qd).call(this,Number(r.dataset.index))})}get map(){return q(this,Hi)}set map(i){i!==q(this,Hi)&&(Lt(this,Hi,i),clearTimeout(q(this,hr)),dr(this,li)._++,nt(this,De,mr).call(this,[]))}connectedCallback(){if(q(this,Xe))return;const i=this.shadowRoot??this.attachShadow({mode:"open"});i.innerHTML=`<style>${ik}</style><input type="search" role="combobox" autocomplete="off" aria-autocomplete="list" aria-expanded="false" aria-controls="${q(this,ln)}" /><ul id="${q(this,ln)}" role="listbox" hidden></ul><div class="status" role="status" aria-live="polite"></div>`,Lt(this,Xe,i.querySelector("input")),Lt(this,Xt,i.querySelector("ul")),Lt(this,Rr,i.querySelector(".status")),!(!q(this,Xe)||!q(this,Xt)||!q(this,Rr))&&(q(this,Xe).placeholder=this.getAttribute("placeholder")??"Tìm địa điểm…",q(this,Xe).addEventListener("input",q(this,Ts)),q(this,Xe).addEventListener("keydown",q(this,Es)),q(this,Xe).addEventListener("blur",q(this,Ss)),q(this,Xt).addEventListener("pointerdown",q(this,Ps)))}disconnectedCallback(){var i,r,a,n;clearTimeout(q(this,hr)),dr(this,li)._++,(i=q(this,Xe))==null||i.removeEventListener("input",q(this,Ts)),(r=q(this,Xe))==null||r.removeEventListener("keydown",q(this,Es)),(a=q(this,Xe))==null||a.removeEventListener("blur",q(this,Ss)),(n=q(this,Xt))==null||n.removeEventListener("pointerdown",q(this,Ps)),Lt(this,Xe,null),Lt(this,Xt,null),Lt(this,Rr,null)}attributeChangedCallback(i){(i==="api-key"||i==="api-base"||i==="sources")&&(Lt(this,Fr,null),dr(this,li)._++),i==="placeholder"&&q(this,Xe)&&(q(this,Xe).placeholder=this.getAttribute("placeholder")??"Tìm địa điểm…")}}Hi=new WeakMap,Fr=new WeakMap,Xe=new WeakMap,Xt=new WeakMap,Rr=new WeakMap,kr=new WeakMap,hr=new WeakMap,li=new WeakMap,cr=new WeakMap,ln=new WeakMap,Ts=new WeakMap,Ss=new WeakMap,Es=new WeakMap,Ps=new WeakMap,De=new WeakSet,V1=function(){var s;if((s=q(this,Hi))!=null&&s.places)return q(this,Hi).places;if(q(this,Fr))return q(this,Fr);const i=this.getAttribute("api-key"),r=this.getAttribute("api-base");if(!i||!r)return null;const a=this.getAttribute("sources"),n=a===null?null:kR(a);return a!==null&&!n&&console.warn(`<mapslibvn-autocomplete sources="${a}"> không hợp lệ — dùng mặc định`),Lt(this,Fr,Dd({apiKey:i,baseUrl:r,...n?{poiSources:n}:{}})),q(this,Fr)},j1=function(){var n;if(q(this,Hi)){const s=q(this,Hi).gl.getCenter();return[s.lat,s.lng]}const i=(n=this.getAttribute("near"))==null?void 0:n.split(",").map(Number),r=i==null?void 0:i[0],a=i==null?void 0:i[1];return r!==void 0&&a!==void 0&&Number.isFinite(r)&&Number.isFinite(a)?[r,a]:void 0},U1=async function(i){const r=i.trim(),a=nt(this,De,V1).call(this);if(!a||r.length<2){nt(this,De,mr).call(this,[]),nt(this,De,xa).call(this,a?"":"Thiếu cấu hình API.");return}const n=++dr(this,li)._;try{const s=nt(this,De,j1).call(this),{items:o}=await a.autocomplete(r,s?{near:s}:{});if(n!==q(this,li))return;nt(this,De,mr).call(this,o),nt(this,De,xa).call(this,o.length>0?`Có ${o.length} kết quả.`:"Không tìm thấy kết quả.")}catch{if(n!==q(this,li))return;nt(this,De,mr).call(this,[]),nt(this,De,xa).call(this,"Không thể tải gợi ý. Vui lòng thử lại.")}},mr=function(i){!q(this,Xt)||!q(this,Xe)||(Lt(this,kr,i),Lt(this,cr,-1),q(this,Xe).removeAttribute("aria-activedescendant"),q(this,Xe).setAttribute("aria-expanded",String(i.length>0)),q(this,Xt).hidden=i.length===0,q(this,Xt).replaceChildren(...i.map((r,a)=>{const n=document.createElement("li");n.id=`${q(this,ln)}-option-${a}`,n.dataset.index=String(a),n.dataset.type=r.type,n.setAttribute("role","option"),n.setAttribute("aria-selected","false");const s=document.createElement("span");s.className="icon",s.setAttribute("aria-hidden","true"),s.textContent=Mv[r.type]??Mv.poi;const o=document.createElement("span");o.textContent=r.name;const l=document.createElement("span");return l.className="secondary",l.textContent=r.matched_alt?`${r.secondary}${r.secondary?" · ":""}tên cũ: ${r.matched_alt}`:r.secondary,n.append(s,o,l),n})))},G1=function(i){if(!q(this,Xe)||!q(this,Xt))return;Lt(this,cr,i);for(const[a,n]of Array.from(q(this,Xt).children).entries())n.setAttribute("aria-selected",String(a===i));const r=q(this,Xt).children.item(i);r&&(q(this,Xe).setAttribute("aria-activedescendant",r.id),r.scrollIntoView({block:"nearest"}))},Qd=function(i){const r=q(this,kr)[i];!r||!q(this,Xe)||(q(this,Xe).value=r.name,nt(this,De,mr).call(this,[]),nt(this,De,xa).call(this,`Đã chọn ${r.name}.`),this.dispatchEvent(new CustomEvent("select",{detail:r,bubbles:!0,composed:!0})))},xa=function(i){q(this,Rr)&&(q(this,Rr).textContent=i)},As(zd,"observedAttributes",["api-key","api-base","placeholder","near","sources"]);function zv(){customElements.get("mapslibvn-autocomplete")||customElements.define("mapslibvn-autocomplete",zd)}function Fv(e,t){var i;for(const r of((i=e.getStyle())==null?void 0:i.layers)??[])YR(r)&&e.setLayoutProperty(r.id,"text-field",Iv(t))}var si=Uint8Array,sn=Uint16Array,ak=Int32Array,Rv=new si([0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0,0,0,0]),kv=new si([0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13,0,0]),nk=new si([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),Lv=function(e,t){for(var i=new sn(31),r=0;r<31;++r)i[r]=t+=1<<e[r-1];for(var a=new ak(i[30]),r=1;r<30;++r)for(var n=i[r];n<i[r+1];++n)a[n]=n-i[r]<<5|r;return{b:i,r:a}},Bv=Lv(Rv,2),$v=Bv.b,sk=Bv.r;$v[28]=258,sk[258]=28;for(var ok=Lv(kv,0),lk=ok.b,Fd=new sn(32768),je=0;je<32768;++je){var zr=(je&43690)>>1|(je&21845)<<1;zr=(zr&52428)>>2|(zr&13107)<<2,zr=(zr&61680)>>4|(zr&3855)<<4,Fd[je]=((zr&65280)>>8|(zr&255)<<8)>>1}for(var bs=(function(e,t,i){for(var r=e.length,a=0,n=new sn(t);a<r;++a)e[a]&&++n[e[a]-1];var s=new sn(t);for(a=1;a<t;++a)s[a]=s[a-1]+n[a-1]<<1;var o;if(i){o=new sn(1<<t);var l=15-t;for(a=0;a<r;++a)if(e[a])for(var u=a<<4|e[a],h=t-e[a],c=s[e[a]-1]++<<h,d=c|(1<<h)-1;c<=d;++c)o[Fd[c]>>l]=u}else for(o=new sn(r),a=0;a<r;++a)e[a]&&(o[a]=Fd[s[e[a]-1]++]>>15-e[a]);return o}),ws=new si(288),je=0;je<144;++je)ws[je]=8;for(var je=144;je<256;++je)ws[je]=9;for(var je=256;je<280;++je)ws[je]=7;for(var je=280;je<288;++je)ws[je]=8;for(var Ov=new si(32),je=0;je<32;++je)Ov[je]=5;var uk=bs(ws,9,1),hk=bs(Ov,5,1),Rd=function(e){for(var t=e[0],i=1;i<e.length;++i)e[i]>t&&(t=e[i]);return t},zi=function(e,t,i){var r=t/8|0;return(e[r]|e[r+1]<<8)>>(t&7)&i},kd=function(e,t){var i=t/8|0;return(e[i]|e[i+1]<<8|e[i+2]<<16)>>(t&7)},ck=function(e){return(e+7)/8|0},dk=function(e,t,i){return(i==null||i>e.length)&&(i=e.length),new si(e.subarray(t,i))},pk=["unexpected EOF","invalid block type","invalid length/literal","invalid distance","stream finished","no stream handler",,"no callback","invalid UTF-8 data","extra field too long","date not in range 1980-2099","filename too long","stream finishing","invalid zip data"],oi=function(e,t,i){var r=new Error(t||pk[e]);if(r.code=e,Error.captureStackTrace&&Error.captureStackTrace(r,oi),!i)throw r;return r},Ld=function(e,t,i,r){var a=e.length,n=0;if(!a||t.f&&!t.l)return i||new si(0);var s=!i,o=s||t.i!=2,l=t.i;s&&(i=new si(a*3));var u=function(Ut){var Ue=i.length;if(Ut>Ue){var wt=new si(Math.max(Ue*2,Ut));wt.set(i),i=wt}},h=t.f||0,c=t.p||0,d=t.b||0,p=t.l,f=t.d,m=t.m,g=t.n,_=a*8;do{if(!p){h=zi(e,c,1);var y=zi(e,c+1,3);if(c+=3,y)if(y==1)p=uk,f=hk,m=9,g=5;else if(y==2){var b=zi(e,c,31)+257,T=zi(e,c+10,15)+4,P=b+zi(e,c+5,31)+1;c+=14;for(var S=new si(P),M=new si(19),F=0;F<T;++F)M[nk[F]]=zi(e,c+F*3,7);c+=T*3;for(var R=Rd(M),I=(1<<R)-1,D=bs(M,R,1),F=0;F<P;){var E=D[zi(e,c,I)];c+=E&15;var x=E>>4;if(x<16)S[F++]=x;else{var A=0,B=0;for(x==16?(B=3+zi(e,c,3),c+=2,A=S[F-1]):x==17?(B=3+zi(e,c,7),c+=3):x==18&&(B=11+zi(e,c,127),c+=7);B--;)S[F++]=A}}var N=S.subarray(0,b),O=S.subarray(b);m=Rd(N),g=Rd(O),p=bs(N,m,1),f=bs(O,g,1)}else oi(1);else{var x=ck(c)+4,v=e[x-4]|e[x-3]<<8,w=x+v;if(w>a){l&&oi(0);break}o&&u(d+v),i.set(e.subarray(x,w),d),t.b=d+=v,t.p=c=w*8,t.f=h;continue}if(c>_){l&&oi(0);break}}o&&u(d+131072);for(var H=(1<<m)-1,ue=(1<<g)-1,Ae=c;;Ae=c){var A=p[kd(e,c)&H],ne=A>>4;if(c+=A&15,c>_){l&&oi(0);break}if(A||oi(2),ne<256)i[d++]=ne;else if(ne==256){Ae=c,p=null;break}else{var Ce=ne-254;if(ne>264){var F=ne-257,_e=Rv[F];Ce=zi(e,c,(1<<_e)-1)+$v[F],c+=_e}var Ie=f[kd(e,c)&ue],Me=Ie>>4;Ie||oi(3),c+=Ie&15;var O=lk[Me];if(Me>3){var _e=kv[Me];O+=kd(e,c)&(1<<_e)-1,c+=_e}if(c>_){l&&oi(0);break}o&&u(d+131072);var ct=d+Ce;if(d<O){var Mt=n-O,Fi=Math.min(O,ct);for(Mt+d<0&&oi(3);d<Fi;++d)i[d]=r[Mt+d]}for(;d<ct;++d)i[d]=i[d-O]}}t.l=p,t.p=Ae,t.b=d,t.f=h,p&&(h=1,t.m=m,t.d=f,t.n=g)}while(!h);return d!=i.length&&s?dk(i,0,d):i.subarray(0,d)},fk=new si(0),mk=function(e){(e[0]!=31||e[1]!=139||e[2]!=8)&&oi(6,"invalid gzip data");var t=e[3],i=10;t&4&&(i+=(e[10]|e[11]<<8)+2);for(var r=(t>>3&1)+(t>>4&1);r>0;r-=!e[i++]);return i+(t&2)},gk=function(e){var t=e.length;return(e[t-4]|e[t-3]<<8|e[t-2]<<16|e[t-1]<<24)>>>0},_k=function(e,t){return((e[0]&15)!=8||e[0]>>4>7||(e[0]<<8|e[1])%31)&&oi(6,"invalid zlib data"),(e[1]>>5&1)==1&&oi(6,"invalid zlib data: "+(e[1]&32?"need":"unexpected")+" dictionary"),(e[1]>>3&4)+2};function yk(e,t){return Ld(e,{i:2},t,t)}function vk(e,t){var i=mk(e);return i+8>e.length&&oi(6,"invalid gzip data"),Ld(e.subarray(i,-8),{i:2},new si(gk(e)),t)}function xk(e,t){return Ld(e.subarray(_k(e),-4),{i:2},t,t)}function bk(e,t){return e[0]==31&&e[1]==139&&e[2]==8?vk(e,t):(e[0]&15)!=8||e[0]>>4>7||(e[0]<<8|e[1])%31?yk(e,t):xk(e,t)}var wk=typeof TextDecoder<"u"&&new TextDecoder,Tk=0;try{wk.decode(fk,{stream:!0}),Tk=1}catch{}var Sk=Object.defineProperty,Ek=Math.pow,ze=(e,t)=>Sk(e,"name",{value:t,configurable:!0}),xt=(e,t,i)=>new Promise((r,a)=>{var n=l=>{try{o(i.next(l))}catch(u){a(u)}},s=l=>{try{o(i.throw(l))}catch(u){a(u)}},o=l=>l.done?r(l.value):Promise.resolve(l.value).then(n,s);o((i=i.apply(e,t)).next())});ze((e,t)=>{let i=!1,r="",a=L.GridLayer.extend({createTile:ze((n,s)=>{let o=document.createElement("img"),l=new AbortController,u=l.signal;return o.cancel=()=>{l.abort()},i||(e.getHeader().then(h=>{h.tileType===1||h.tileType===6?console.error("Error: archive contains vector tiles, but leafletRasterLayer is for displaying raster tiles. See https://github.com/protomaps/PMTiles/tree/main/js for details."):h.tileType===2?r="image/png":h.tileType===3?r="image/jpeg":h.tileType===4?r="image/webp":h.tileType===5&&(r="image/avif")}),i=!0),e.getZxy(n.z,n.x,n.y,u).then(h=>{if(h){let c=new Blob([h.data],{type:r}),d=window.URL.createObjectURL(c);o.src=d}else o.style.display="none";o.cancel=void 0,s(void 0,o)}).catch(h=>{if(h.name!=="AbortError")throw h}),o},"createTile"),_removeTile:ze(function(n){let s=this._tiles[n];s&&(s.el.cancel&&s.el.cancel(),s.el.src&&window.URL.revokeObjectURL(s.el.src),s.el.width=0,s.el.height=0,s.el.deleted=!0,L.DomUtil.remove(s.el),delete this._tiles[n],this.fire("tileunload",{tile:s.el,coords:this._keyToTileCoords(n)}))},"_removeTile")});return new a(t)},"leafletRasterLayer");var Pk=ze(e=>(t,i)=>{if(i instanceof AbortController)return e(t,i);let r=new AbortController;return e(t,r).then(a=>i(void 0,a.data,a.cacheControl||"",a.expires||""),a=>i(a)).catch(a=>i(a)),{cancel:ze(()=>r.abort(),"cancel")}},"v3compat"),Nv=class{constructor(t){this.tilev4=ze((i,r)=>xt(this,null,function*(){if(i.type==="json"){let p=i.url.substr(10),f=this.tiles.get(p);if(f||(f=new Jv(p),this.tiles.set(p,f)),this.metadata){let g=yield f.getTileJson(i.url);return r.signal.throwIfAborted(),{data:g}}let m=yield f.getHeader();return r.signal.throwIfAborted(),(m.minLon>=m.maxLon||m.minLat>=m.maxLat)&&console.error(`Bounds of PMTiles archive ${m.minLon},${m.minLat},${m.maxLon},${m.maxLat} are not valid.`),{data:{tiles:[`${i.url}/{z}/{x}/{y}`],minzoom:m.minZoom,maxzoom:m.maxZoom,bounds:[m.minLon,m.minLat,m.maxLon,m.maxLat]}}}let a=new RegExp(/pmtiles:\/\/(.+)\/(\d+)\/(\d+)\/(\d+)/),n=i.url.match(a);if(!n)throw new Error("Invalid PMTiles protocol URL");let s=n[1],o=this.tiles.get(s);o||(o=new Jv(s),this.tiles.set(s,o));let l=n[2],u=n[3],h=n[4],c=yield o==null?void 0:o.getZxy(+l,+u,+h,r.signal);if(r.signal.throwIfAborted(),c)return{data:new Uint8Array(c.data),cacheControl:c.cacheControl,expires:c.expires};let d=yield o.getHeader();if(d.tileType===1||d.tileType===6){if(this.errorOnMissingTile)throw new Error("Tile not found.");return{data:new Uint8Array}}return{data:null}}),"tilev4"),this.tile=Pk(this.tilev4),this.tiles=new Map,this.metadata=(t==null?void 0:t.metadata)||!1,this.errorOnMissingTile=(t==null?void 0:t.errorOnMissingTile)||!1}add(t){this.tiles.set(t.source.getKey(),t)}get(t){return this.tiles.get(t)}};ze(Nv,"Protocol");var Ck=Nv;function Vv(e,t){return(t>>>0)*4294967296+(e>>>0)}ze(Vv,"toNum");function jv(e,t){let i=t.buf,r=i[t.pos++],a=(r&112)>>4;if(r<128||(r=i[t.pos++],a|=(r&127)<<3,r<128)||(r=i[t.pos++],a|=(r&127)<<10,r<128)||(r=i[t.pos++],a|=(r&127)<<17,r<128)||(r=i[t.pos++],a|=(r&127)<<24,r<128)||(r=i[t.pos++],a|=(r&1)<<31,r<128))return Vv(e,a);throw new Error("Expected varint not more than 10 bytes")}ze(jv,"readVarintRemainder");function on(e){let t=e.buf,i=t[e.pos++],r=i&127;return i<128||(i=t[e.pos++],r|=(i&127)<<7,i<128)||(i=t[e.pos++],r|=(i&127)<<14,i<128)||(i=t[e.pos++],r|=(i&127)<<21,i<128)?r:(i=t[e.pos],r|=(i&15)<<28,jv(r,e))}ze(on,"readVarint");function Bd(e,t,i,r,a){return a===0?r!==0?[e-1-i,e-1-t]:[i,t]:[t,i]}ze(Bd,"rotate");function Uv(e,t,i){if(e>26)throw new Error("Tile zoom level exceeds max safe number limit (26)");if(t>=1<<e||i>=1<<e)throw new Error("tile x/y outside zoom level bounds");let r=((1<<e)*(1<<e)-1)/3,a=e-1,[n,s]=[t,i];for(let o=1<<a;o>0;o>>=1){let l=n&o,u=s&o;r+=(3*l^u)*(1<<a),[n,s]=Bd(o,n,s,l,u),a--}return r}ze(Uv,"zxyToTileId");function Gv(e){let t=3*e+1;return t<4294967296?31-Math.clz32(t):63-Math.clz32(t/4294967296)}ze(Gv,"tileIdToZ");function Ak(e){let t=Gv(e)>>1;if(t>26)throw new Error("Tile zoom level exceeds max safe number limit (26)");let i=((1<<t)*(1<<t)-1)/3,r=e-i,a=0,n=0,s=1<<t;for(let o=1;o<s;o<<=1){let l=o&r/2,u=o&(r^l);[a,n]=Bd(o,a,n,l,u),r=r/2,a+=l,n+=u}return[t,a,n]}ze(Ak,"tileIdToZxy");var Dk=(e=>(e[e.Unknown=0]="Unknown",e[e.None=1]="None",e[e.Gzip=2]="Gzip",e[e.Brotli=3]="Brotli",e[e.Zstd=4]="Zstd",e))(Dk||{});function Bl(e,t){return xt(this,null,function*(){if(t===1||t===0)return e;if(t===2){if(typeof globalThis.DecompressionStream>"u")return bk(new Uint8Array(e));let i=new Response(e).body;if(!i)throw new Error("Failed to read response stream");let r=i.pipeThrough(new globalThis.DecompressionStream("gzip"));return new Response(r).arrayBuffer()}throw new Error("Compression method not supported")})}ze(Bl,"defaultDecompress");var Ik=(e=>(e[e.Unknown=0]="Unknown",e[e.Mvt=1]="Mvt",e[e.Png=2]="Png",e[e.Jpeg=3]="Jpeg",e[e.Webp=4]="Webp",e[e.Avif=5]="Avif",e[e.Mlt=6]="Mlt",e))(Ik||{});function Zv(e){return e===1?".mvt":e===2?".png":e===3?".jpg":e===4?".webp":e===5?".avif":e===6?".mlt":""}ze(Zv,"tileTypeExt");var Mk=127;function qv(e,t){let i=0,r=e.length-1;for(;i<=r;){let a=r+i>>1,n=t-e[a].tileId;if(n>0)i=a+1;else if(n<0)r=a-1;else return e[a]}return r>=0&&(e[r].runLength===0||t-e[r].tileId<e[r].runLength)?e[r]:null}ze(qv,"findTile");var zk=class{constructor(t){this.file=t}getKey(){return this.file.name}getBytes(t,i){return xt(this,null,function*(){return{data:yield this.file.slice(t,t+i).arrayBuffer()}})}};ze(zk,"FileSource");var Wv=class{constructor(t,i=new Headers,r=void 0){var a,n;this.url=t,this.customHeaders=i,this.credentials=r,this.mustReload=!1;let s="";"navigator"in globalThis&&(s=(n=(a=globalThis.navigator)==null?void 0:a.userAgent)!=null?n:"");let o=s.indexOf("Windows")>-1,l=/Chrome|Chromium|Edg|OPR|Brave/.test(s);this.chromeWindowsNoCache=!1,o&&l&&(this.chromeWindowsNoCache=!0)}getKey(){return this.url}setHeaders(t){this.customHeaders=t}getBytes(t,i,r,a){return xt(this,null,function*(){let n,s;r?s=r:(n=new AbortController,s=n.signal);let o=new Headers(this.customHeaders);o.set("range",`bytes=${t}-${t+i-1}`);let l;this.mustReload?l="reload":this.chromeWindowsNoCache&&(l="no-store");let u=yield fetch(this.url,{signal:s,cache:l,headers:o,credentials:this.credentials});if(t===0&&u.status===416){let d=u.headers.get("Content-Range");if(!d||!d.startsWith("bytes */"))throw new Error("Missing content-length on 416 response");let p=+d.substr(8);o.set("range",`bytes=0-${p-1}`),u=yield fetch(this.url,{signal:s,cache:"reload",headers:o,credentials:this.credentials})}let h=u.headers.get("Etag");if(h!=null&&h.startsWith("W/")&&(h=null),u.status===416||a&&h&&h!==a)throw this.mustReload=!0,new Od(`Server returned non-matching ETag ${a} after one retry. Check browser extensions and servers for issues that may affect correct ETag headers.`);if(u.status>=300)throw new Error(`Bad response code: ${u.status}`);let c=u.headers.get("Content-Length");if(u.status===200&&(!c||+c>i))throw n&&n.abort(),new Error("Server returned no content-length header or content-length exceeding request. Check that your storage backend supports HTTP Byte Serving.");return{data:yield u.arrayBuffer(),etag:h||void 0,cacheControl:u.headers.get("Cache-Control")||void 0,expires:u.headers.get("Expires")||void 0}})}};ze(Wv,"FetchSource");var Fk=Wv;function wi(e,t){let i=e.getUint32(t+4,!0),r=e.getUint32(t+0,!0);return i*Ek(2,32)+r}ze(wi,"getUint64");function Hv(e,t){let i=new DataView(e),r=i.getUint8(7);if(r>3)throw new Error(`Archive is spec version ${r} but this library supports up to spec version 3`);return{specVersion:r,rootDirectoryOffset:wi(i,8),rootDirectoryLength:wi(i,16),jsonMetadataOffset:wi(i,24),jsonMetadataLength:wi(i,32),leafDirectoryOffset:wi(i,40),leafDirectoryLength:wi(i,48),tileDataOffset:wi(i,56),tileDataLength:wi(i,64),numAddressedTiles:wi(i,72),numTileEntries:wi(i,80),numTileContents:wi(i,88),clustered:i.getUint8(96)===1,internalCompression:i.getUint8(97),tileCompression:i.getUint8(98),tileType:i.getUint8(99),minZoom:i.getUint8(100),maxZoom:i.getUint8(101),minLon:i.getInt32(102,!0)/1e7,minLat:i.getInt32(106,!0)/1e7,maxLon:i.getInt32(110,!0)/1e7,maxLat:i.getInt32(114,!0)/1e7,centerZoom:i.getUint8(118),centerLon:i.getInt32(119,!0)/1e7,centerLat:i.getInt32(123,!0)/1e7,etag:t}}ze(Hv,"bytesToHeader");function $d(e){let t={buf:new Uint8Array(e),pos:0},i=on(t),r=[],a=0;for(let n=0;n<i;n++){let s=on(t);r.push({tileId:a+s,offset:0,length:0,runLength:1}),a+=s}for(let n=0;n<i;n++)r[n].runLength=on(t);for(let n=0;n<i;n++)r[n].length=on(t);for(let n=0;n<i;n++){let s=on(t);s===0&&n>0?r[n].offset=r[n-1].offset+r[n-1].length:r[n].offset=s-1}return r}ze($d,"deserializeIndex");var Xv=class extends Error{};ze(Xv,"EtagMismatch");var Od=Xv;function Nd(e,t){return xt(this,null,function*(){let i=yield e.getBytes(0,16384);if(new DataView(i.data).getUint16(0,!0)!==19792)throw new Error("Wrong magic number for PMTiles archive");let r=i.data.slice(0,Mk),a=Hv(r,i.etag),n=i.data.slice(a.rootDirectoryOffset,a.rootDirectoryOffset+a.rootDirectoryLength),s=`${e.getKey()}|${a.etag||""}|${a.rootDirectoryOffset}|${a.rootDirectoryLength}`,o=$d(yield t(n,a.internalCompression));return[a,[s,o.length,o]]})}ze(Nd,"getHeaderAndRoot");function Vd(e,t,i,r,a,n){return xt(this,null,function*(){let s=yield e.getBytes(i,r,n,a.etag),o=yield t(s.data,a.internalCompression),l=$d(o);if(l.length===0)throw new Error("Empty directory is invalid");return l})}ze(Vd,"getDirectory");var Rk=class{constructor(t=100,i=!0,r=Bl){this.cache=new Map,this.maxCacheEntries=t,this.counter=1,this.decompress=r}getHeader(t){return xt(this,null,function*(){let i=t.getKey(),r=this.cache.get(i);if(r)return r.lastUsed=this.counter++,r.data;let a=yield Nd(t,this.decompress);return a[1]&&this.cache.set(a[1][0],{lastUsed:this.counter++,data:a[1][2]}),this.cache.set(i,{lastUsed:this.counter++,data:a[0]}),this.prune(),a[0]})}getDirectory(t,i,r,a,n){return xt(this,null,function*(){let s=`${t.getKey()}|${a.etag||""}|${i}|${r}`,o=this.cache.get(s);if(o)return o.lastUsed=this.counter++,o.data;let l=yield Vd(t,this.decompress,i,r,a,n);return this.cache.set(s,{lastUsed:this.counter++,data:l}),this.prune(),l})}prune(){if(this.cache.size>this.maxCacheEntries){let t=1/0,i;this.cache.forEach((r,a)=>{r.lastUsed<t&&(t=r.lastUsed,i=a)}),i&&this.cache.delete(i)}}invalidate(t){return xt(this,null,function*(){this.cache.delete(t.getKey())})}};ze(Rk,"ResolvedValueCache");var Yv=class{constructor(t=100,i=!0,r=Bl){this.cache=new Map,this.invalidations=new Map,this.pendingFetches=new Map,this.maxCacheEntries=t,this.counter=1,this.decompress=r}getHeader(t){return xt(this,null,function*(){let i=t.getKey(),r=this.cache.get(i);if(r)return r.lastUsed=this.counter++,yield r.data;let a=new Promise((n,s)=>{Nd(t,this.decompress).then(o=>{o[1]&&this.cache.set(o[1][0],{lastUsed:this.counter++,data:Promise.resolve(o[1][2])}),n(o[0]),this.prune()}).catch(o=>{s(o)})});return this.cache.set(i,{lastUsed:this.counter++,data:a}),a})}trackSignal(t,i,r){i.refs++,r.addEventListener("abort",()=>{--i.refs<=0&&this.pendingFetches.get(t)===i&&(i.controller.abort(),this.cache.delete(t),this.pendingFetches.delete(t))},{once:!0})}getDirectory(t,i,r,a,n){return xt(this,null,function*(){let s=`${t.getKey()}|${a.etag||""}|${i}|${r}`,o=this.cache.get(s);if(o){o.lastUsed=this.counter++;let c=this.pendingFetches.get(s);return c&&this.trackSignal(s,c,n??new AbortController().signal),yield o.data}let l=new AbortController,u={controller:l,refs:0};this.trackSignal(s,u,n??new AbortController().signal),this.pendingFetches.set(s,u);let h=new Promise((c,d)=>{Vd(t,this.decompress,i,r,a,l.signal).then(p=>{this.pendingFetches.delete(s),c(p),this.prune()}).catch(p=>{d(p)})});return this.cache.set(s,{lastUsed:this.counter++,data:h}),h})}prune(){if(this.cache.size>=this.maxCacheEntries){let t=1/0,i;this.cache.forEach((r,a)=>{r.lastUsed<t&&(t=r.lastUsed,i=a)}),i&&this.cache.delete(i)}}invalidate(t){return xt(this,null,function*(){let i=t.getKey();if(this.invalidations.get(i))return yield this.invalidations.get(i);this.cache.delete(t.getKey());let r=new Promise((a,n)=>{this.getHeader(t).then(s=>{a(),this.invalidations.delete(i)}).catch(s=>{n(s)})});this.invalidations.set(i,r)})}};ze(Yv,"SharedPromiseCache");var kk=Yv,Kv=class{constructor(t,i,r){typeof t=="string"?this.source=new Fk(t):this.source=t,r?this.decompress=r:this.decompress=Bl,i?this.cache=i:this.cache=new kk}getHeader(){return xt(this,null,function*(){return yield this.cache.getHeader(this.source)})}getZxyAttempt(t,i,r,a){return xt(this,null,function*(){let n=Uv(t,i,r),s=yield this.cache.getHeader(this.source);if(a==null||a.throwIfAborted(),t<s.minZoom||t>s.maxZoom)return;let o=s.rootDirectoryOffset,l=s.rootDirectoryLength;for(let u=0;u<=3;u++){let h=yield this.cache.getDirectory(this.source,o,l,s,a);a==null||a.throwIfAborted();let c=qv(h,n);if(c){if(c.runLength>0){let d=yield this.source.getBytes(s.tileDataOffset+c.offset,c.length,a,s.etag);return{data:yield this.decompress(d.data,s.tileCompression),cacheControl:d.cacheControl,expires:d.expires}}o=s.leafDirectoryOffset+c.offset,l=c.length}else return}throw new Error("Maximum directory depth exceeded")})}getZxy(t,i,r,a){return xt(this,null,function*(){try{return yield this.getZxyAttempt(t,i,r,a)}catch(n){if(n instanceof Od)return this.cache.invalidate(this.source),yield this.getZxyAttempt(t,i,r,a);throw n}})}getMetadataAttempt(){return xt(this,null,function*(){let t=yield this.cache.getHeader(this.source),i=yield this.source.getBytes(t.jsonMetadataOffset,t.jsonMetadataLength,void 0,t.etag),r=yield this.decompress(i.data,t.internalCompression),a=new TextDecoder("utf-8");return JSON.parse(a.decode(r))})}getMetadata(){return xt(this,null,function*(){try{return yield this.getMetadataAttempt()}catch(t){if(t instanceof Od)return this.cache.invalidate(this.source),yield this.getMetadataAttempt();throw t}})}getTileJson(t){return xt(this,null,function*(){let i=yield this.getHeader(),r=yield this.getMetadata(),a=Zv(i.tileType);return{tilejson:"3.0.0",scheme:"xyz",tiles:[`${t}/{z}/{x}/{y}${a}`],vector_layers:r.vector_layers,attribution:r.attribution,description:r.description,name:r.name,version:r.version,bounds:[i.minLon,i.minLat,i.maxLon,i.maxLat],center:[i.centerLon,i.centerLat,i.centerZoom],minzoom:i.minZoom,maxzoom:i.maxZoom}})}};ze(Kv,"PMTiles");var Jv=Kv;let Qv=!1;function Lk(e){Qv||(e.addProtocol("pmtiles",new Ck().tile),Qv=!0)}const Bk=e=>e==="light"||e==="dark";function $k(e,t){const i=(t==null?void 0:t.maplibre)??globalThis.maplibregl;if(!i)throw new Error("Cần maplibre-gl: import maplibre-gl hoặc dùng bản UMD @mapslibvn/web/umd");Lk(i);const r=e.poiSources??Cd;if(!LR(r)){const h=Object.values(Ll).map(c=>c.join(",")).join(" | ");throw new Error(`poiSources "${r.join(",")}" chưa có bộ tiles; hiện hỗ trợ: ${h}`)}const a=Dd({apiKey:e.apiKey,baseUrl:e.apiBase,poiSources:r}),n=e.style??"light",s=Bk(n)?a.styleUrl(n):n,o=new i.Map({container:e.container,style:s,center:e.center??[106.7,10.776],zoom:e.zoom??12,attributionControl:!1});o.addControl(new i.AttributionControl({compact:e.compactAttribution??!1,customAttribution:Ev()}));const l={poiClick:new Set,load:new Set},u=(h,c)=>{for(const d of l[h])d(c)};return o.on("load",()=>{if(e.lang&&e.lang!=="vi"&&Fv(o,e.lang),e.poiLayer===!1)for(const h of o.getStyle().layers??[])XR(h)&&o.getLayer(h.id)&&o.setLayoutProperty(h.id,"visibility","none");u("load",void 0)}),o.on("click",h=>{if(l.poiClick.size===0||!o.getLayer("poi"))return;const c=o.queryRenderedFeatures(h.point,{layers:["poi"]})[0];if(!c||c.geometry.type!=="Point")return;const d=c.properties;u("poiClick",{id:String(d.id),name:String(d.name??""),category:String(d.cat??""),group:String(d.grp??""),lngLat:c.geometry.coordinates})}),{gl:o,places:a,addMarker(h){const c=new i.Marker(h.color?{color:h.color}:void 0).setLngLat([h.lng,h.lat]);return h.popupHtml&&c.setPopup(new i.Popup({offset:24}).setHTML(h.popupHtml)),c.addTo(o)},fitBounds(h,c=40){o.fitBounds([[h[0],h[1]],[h[2],h[3]]],{padding:c})},flyTo(h,c){o.flyTo(c===void 0?{center:h}:{center:h,zoom:c})},on(h,c){l[h].add(c)},off(h,c){l[h].delete(c)},remove(){o.remove()}}}zv();function Ok(e){return $k(e,{maplibre:bv})}he.MapsLibVNAutocomplete=zd,he.MapsLibVNError=Pv,he.applyLanguage=Fv,he.attributionHtml=Ev,he.attributionText=FR,he.createClient=Dd,he.createMap=Ok,he.defineAutocomplete=zv,he.maplibregl=bv,he.nameExpression=Iv,Object.defineProperty(he,Symbol.toStringTag,{value:"Module"})}));
|
|
839
|
+
//# sourceMappingURL=mapslibvn.umd.js.map
|