t.y!=o.y>t.y&&t.x<(o.x-i.x)*(t.y-i.y)/(o.y-i.y)+i.x&&(r=!r),n=Math.min(n,il(t,i,o));}}return (r?1:-1)*Math.sqrt(n)}(this.p,n),this.max=this.d+this.h*Math.SQRT2;}const jp=Number.POSITIVE_INFINITY,Up=Math.sqrt(2);function $p(t,[e,r]){let n=0,i=0;if(r===jp){e<0&&(e=0);const r=e/Up;switch(t){case\"top-right\":case\"top-left\":i=r-7;break;case\"bottom-right\":case\"bottom-left\":i=7-r;break;case\"bottom\":i=7-e;break;case\"top\":i=e-7;}switch(t){case\"top-right\":case\"bottom-right\":n=-r;break;case\"top-left\":case\"bottom-left\":n=r;break;case\"left\":n=e;break;case\"right\":n=-e;}}else {switch(e=Math.abs(e),r=Math.abs(r),t){case\"top-right\":case\"top-left\":case\"top\":i=r-7;break;case\"bottom-right\":case\"bottom-left\":case\"bottom\":i=7-r;}switch(t){case\"top-right\":case\"bottom-right\":case\"right\":n=-e;break;case\"top-left\":case\"bottom-left\":case\"left\":n=e;}}return [n,i]}function Op(t,e,r,n,i,s,a,o,l,u){t.createArrays(),t.tilePixelRatio=So/(512*t.overscaling),t.compareText={},t.iconsNeedLinear=!1;const c=t.layers[0].layout,h=t.layers[0]._unevaluatedLayout._values,p={};if(\"composite\"===t.textSizeData.kind){const{minZoom:e,maxZoom:r}=t.textSizeData;p.compositeTextSizes=[h[\"text-size\"].possiblyEvaluate(new Us(e),o),h[\"text-size\"].possiblyEvaluate(new Us(r),o)];}if(\"composite\"===t.iconSizeData.kind){const{minZoom:e,maxZoom:r}=t.iconSizeData;p.compositeIconSizes=[h[\"icon-size\"].possiblyEvaluate(new Us(e),o),h[\"icon-size\"].possiblyEvaluate(new Us(r),o)];}p.layoutTextSize=h[\"text-size\"].possiblyEvaluate(new Us(l+1),o),p.layoutIconSize=h[\"icon-size\"].possiblyEvaluate(new Us(l+1),o),p.textMaxSize=h[\"text-size\"].possiblyEvaluate(new Us(18),o);const f=\"map\"===c.get(\"text-rotation-alignment\")&&\"point\"!==c.get(\"symbol-placement\"),d=c.get(\"text-size\");for(const s of t.features){const l=c.get(\"text-font\").evaluate(s,{},o).join(\",\"),h=d.evaluate(s,{},o),y=p.layoutTextSize.evaluate(s,{},o),m=(p.layoutIconSize.evaluate(s,{},o),{horizontal:{},vertical:void 0}),g=s.text;let x,v=[0,0];if(g){const n=g.toString(),a=c.get(\"text-letter-spacing\").evaluate(s,{},o)*yh,u=c.get(\"text-line-height\").evaluate(s,{},o)*yh,p=ws(n)?a:0,d=c.get(\"text-anchor\").evaluate(s,{},o),x=c.get(\"text-variable-anchor\");if(!x){const t=c.get(\"text-radial-offset\").evaluate(s,{},o);v=t?$p(d,[t*yh,jp]):c.get(\"text-offset\").evaluate(s,{},o).map((t=>t*yh));}let b=f?\"center\":c.get(\"text-justify\").evaluate(s,{},o);const w=\"point\"===c.get(\"symbol-placement\"),_=w?c.get(\"text-max-width\").evaluate(s,{},o)*yh:1/0,A=s=>{t.allowVerticalPlacement&&bs(n)&&(m.vertical=rp(g,e,r,i,l,_,u,d,s,p,v,Qh.vertical,!0,y,h));};if(!f&&x){const t=\"auto\"===b?x.map((t=>qp(t))):[b];let n=!1;for(let s=0;s=0||!bs(n)){const t=rp(g,e,r,i,l,_,u,d,b,p,v,Qh.horizontal,!1,y,h);t&&(m.horizontal[b]=t);}A(w?\"left\":b);}}let b=!1;if(s.icon&&s.icon.name){const e=n[s.icon.name];e&&(x=pp(i[s.icon.name],c.get(\"icon-offset\").evaluate(s,{},o),c.get(\"icon-anchor\").evaluate(s,{},o)),b=e.sdf,void 0===t.sdfIcons?t.sdfIcons=e.sdf:t.sdfIcons!==e.sdf&&$(\"Style sheet warning: Cannot mix SDF and non-SDF icons in one buffer\"),(e.pixelRatio!==t.pixelRatio||0!==c.get(\"icon-rotate\").constantOr(1))&&(t.iconsNeedLinear=!0));}const w=Zp(m.horizontal)||m.vertical;t.iconsInText||(t.iconsInText=!!w&&w.iconsInText),(w||x)&&Np(t,s,m,x,n,p,y,0,v,b,a,o,u);}s&&t.generateCollisionDebugBuffers(l,t.collisionBoxArray);}function qp(t){switch(t){case\"right\":case\"top-right\":case\"bottom-right\":return \"right\";case\"left\":case\"top-left\":case\"bottom-left\":return \"left\"}return \"center\"}function Np(t,e,r,n,i,s,a,o,l,u,c,h,p){let f=s.textMaxSize.evaluate(e,{},h);void 0===f&&(f=a);const d=t.layers[0].layout,y=d.get(\"icon-offset\").evaluate(e,{},h),m=Zp(r.horizontal)||r.vertical,g=\"globe\"===p.name,v=a/24,b=t.tilePixelRatio*f/24,w=(z=t.overscaling,t.zoom>18&&z>2&&(z>>=1),Math.max(So/(512*z),1)*d.get(\"symbol-spacing\")),_=d.get(\"text-padding\")*t.tilePixelRatio,A=d.get(\"icon-padding\")*t.tilePixelRatio,S=x(d.get(\"text-max-angle\")),k=\"map\"===d.get(\"text-rotation-alignment\")&&\"point\"!==d.get(\"symbol-placement\"),I=\"map\"===d.get(\"icon-rotation-alignment\")&&\"point\"!==d.get(\"symbol-placement\"),M=d.get(\"symbol-placement\"),T=w/2;var z;const B=d.get(\"icon-text-fit\");let E;n&&\"none\"!==B&&(t.allowVerticalPlacement&&r.vertical&&(E=fp(n,r.vertical,B,d.get(\"icon-text-fit-padding\"),y,v)),m&&(n=fp(n,m,B,d.get(\"icon-text-fit-padding\"),y,v)));const C=(a,o,f)=>{if(o.x<0||o.x>=So||o.y<0||o.y>=So)return;let d=null;if(g){const{x:t,y:e,z:r}=p.projectTilePoint(o.x,o.y,f);d={anchor:new dp(t,e,r,0,void 0),up:p.upVector(f,o.x,o.y)};}!function(t,e,r,n,i,s,a,o,l,u,c,h,p,f,d,y,m,g,x,v,b,w,_,A,S){const k=t.addToLineVertexArray(e,n);let I,M,T,z,B,E,C,P=0,D=0,V=0,L=0,F=-1,R=-1;const j={};let U=qa.exports(\"\");const O=r?r.anchor:e;let q=0,N=0;if(void 0===l._unevaluatedLayout.getValue(\"text-radial-offset\")?[q,N]=l.layout.get(\"text-offset\").evaluate(b,{},S).map((t=>t*yh)):(q=l.layout.get(\"text-radial-offset\").evaluate(b,{},S)*yh,N=jp),t.allowVerticalPlacement&&i.vertical){const t=i.vertical;if(d)E=Yp(t),o&&(C=Yp(o));else {const r=l.layout.get(\"text-rotate\").evaluate(b,{},S)+90;T=Kp(u,O,e,c,h,p,t,f,r,y),o&&(z=Kp(u,O,e,c,h,p,o,g,r));}}if(s){const n=l.layout.get(\"icon-rotate\").evaluate(b,{},S),i=\"none\"!==l.layout.get(\"icon-text-fit\"),a=Tp(s,n,_,i),f=o?Tp(o,n,_,i):void 0;M=Kp(u,O,e,c,h,p,s,g,n),P=4*a.length;const d=t.iconSizeData;let y=null;\"source\"===d.kind?(y=[mh*l.layout.get(\"icon-size\").evaluate(b,{},S)],y[0]>Gp&&$(`${t.layerIds[0]}: Value for \"icon-size\" is >= 255. Reduce your \"icon-size\".`)):\"composite\"===d.kind&&(y=[mh*w.compositeIconSizes[0].evaluate(b,{},S),mh*w.compositeIconSizes[1].evaluate(b,{},S)],(y[0]>Gp||y[1]>Gp)&&$(`${t.layerIds[0]}: Value for \"icon-size\" is >= 255. Reduce your \"icon-size\".`)),t.addSymbols(t.icon,a,y,v,x,b,!1,r,e,k.lineStartIndex,k.lineLength,-1,A,S),F=t.icon.placedSymbolArray.length-1,f&&(D=4*f.length,t.addSymbols(t.icon,f,y,v,x,b,Qh.vertical,r,e,k.lineStartIndex,k.lineLength,-1,A,S),R=t.icon.placedSymbolArray.length-1);}for(const n in i.horizontal){const s=i.horizontal[n];I||(U=qa.exports(s.text),d?B=Yp(s):I=Kp(u,O,e,c,h,p,s,f,l.layout.get(\"text-rotate\").evaluate(b,{},S),y));const o=1===s.positionedLines.length;if(V+=Xp(t,r,e,s,a,l,d,b,y,k,i.vertical?Qh.horizontal:Qh.horizontalOnly,o?Object.keys(i.horizontal):[n],j,F,w,A,S),o)break}i.vertical&&(L+=Xp(t,r,e,i.vertical,a,l,d,b,y,k,Qh.vertical,[\"vertical\"],j,R,w,A,S));let G=-1;const X=(t,e)=>t?Math.max(t,e):e;G=X(B,G),G=X(E,G),G=X(C,G);const Z=G>-1?1:0;t.glyphOffsetArray.length>=cd.MAX_GLYPHS&&$(\"Too many glyphs being rendered in a tile. See https://github.com/mapbox/mapbox-gl-js/issues/2907\"),void 0!==b.sortKey&&t.addToSortKeyRanges(t.symbolInstances.length,b.sortKey),t.symbolInstances.emplaceBack(O.x,O.y,O.z,e.x,e.y,j.right>=0?j.right:-1,j.center>=0?j.center:-1,j.left>=0?j.left:-1,j.vertical>=0?j.vertical:-1,F,R,U,void 0!==I?I:t.collisionBoxArray.length,void 0!==I?I+1:t.collisionBoxArray.length,void 0!==T?T:t.collisionBoxArray.length,void 0!==T?T+1:t.collisionBoxArray.length,void 0!==M?M:t.collisionBoxArray.length,void 0!==M?M+1:t.collisionBoxArray.length,z||t.collisionBoxArray.length,z?z+1:t.collisionBoxArray.length,c,V,L,P,D,Z,0,q,N,G);}(t,o,d,a,r,n,i,E,t.layers[0],t.collisionBoxArray,e.index,e.sourceLayerIndex,t.index,_,k,l,0,A,I,y,e,s,u,c,h);};if(\"line\"===M)for(const i of _p(e.geometry,0,0,So,So)){const e=bp(i,w,S,r.vertical||m,n,24,b,t.overscaling,So);for(const r of e){const e=m;e&&Hp(t,e.text,T,r)||C(i,r,h);}}else if(\"line-center\"===M){for(const t of e.geometry)if(t.length>1){const e=vp(t,S,r.vertical||m,n,24,b);e&&C(t,e,h);}}else if(\"Polygon\"===e.type)for(const t of tc(e.geometry,0)){const e=Lp(t,16);C(t[0],new dp(e.x,e.y,0,0,void 0),h);}else if(\"LineString\"===e.type)for(const t of e.geometry)C(t,new dp(t[0].x,t[0].y,0,0,void 0),h);else if(\"Point\"===e.type)for(const t of e.geometry)for(const e of t)C([e],new dp(e.x,e.y,0,0,void 0),h);}const Gp=32640;function Xp(t,e,r,n,i,s,a,o,l,u,c,h,p,f,y,m,g){const x=function(t,e,r,n,i,s,a,o){const l=[];if(0===e.positionedLines.length)return l;const u=n.layout.get(\"text-rotate\").evaluate(s,{})*Math.PI/180,c=function(t){const e=t[0],r=t[1],n=e*r;return n>0?[e,-r]:n<0?[-e,r]:0===e?[r,e]:[r,-e]}(r);let h=Math.abs(e.top-e.bottom);for(const t of e.positionedLines)h-=t.lineOffset;const p=e.positionedLines.length,f=h/p;let y=e.top-r[1];for(let t=0;tGp&&$(`${t.layerIds[0]}: Value for \"text-size\" is >= 255. Reduce your \"text-size\".`)):\"composite\"===v.kind&&(b=[mh*y.compositeTextSizes[0].evaluate(o,{},g),mh*y.compositeTextSizes[1].evaluate(o,{},g)],(b[0]>Gp||b[1]>Gp)&&$(`${t.layerIds[0]}: Value for \"text-size\" is >= 255. Reduce your \"text-size\".`)),t.addSymbols(t.text,x,b,l,a,o,c,e,r,u.lineStartIndex,u.lineLength,f,m,g);for(const e of h)p[e]=t.text.placedSymbolArray.length-1;return 4*x.length}function Zp(t){for(const e in t)return t[e];return null}function Kp(t,e,r,n,i,s,a,o,l,u){let c=a.top,h=a.bottom,p=a.left,f=a.right;const y=a.collisionPadding;if(y&&(p-=y[0],c-=y[1],f+=y[2],h+=y[3]),l){const t=new d(p,c),e=new d(f,c),r=new d(p,h),n=new d(f,h),i=x(l);let s=new d(0,0);u&&(s=new d(u[0],u[1])),t._rotateAround(i,s),e._rotateAround(i,s),r._rotateAround(i,s),n._rotateAround(i,s),p=Math.min(t.x,e.x,r.x,n.x),f=Math.max(t.x,e.x,r.x,n.x),c=Math.min(t.y,e.y,r.y,n.y),h=Math.max(t.y,e.y,r.y,n.y);}return t.emplaceBack(e.x,e.y,e.z,r.x,r.y,p,c,f,h,o,n,i,s),t.length-1}function Yp(t){t.collisionPadding&&(t.top-=t.collisionPadding[1],t.bottom+=t.collisionPadding[3]);const e=t.bottom-t.top;return e>0?Math.max(10,e):null}function Hp(t,e,r,n){const i=t.compareText;if(e in i){const t=i[e];for(let e=t.length-1;e>=0;e--)if(n.dist(t[e])1?null:function(t,e,r,n){const i=Math.sin(r);return t*(Math.sin((1-n)*r)/i)+e*(Math.sin(n*r)/i)}(t.a[e],t.b[e],t.angle,S(r,0,1))+t.center[e]}function pf(t){if(t.z<=1)return lf[t.z+2*t.y+t.x];const e=xf(gf(t));return au.fromPoints(e)}function ff(t,e,r){return Rl(t,t,1-r),jl(t,t,e,r)}function df(t,e){const r=Mf(e.zoom);if(0===r)return pf(t);const n=gf(t),i=xf(n),s=Bo(n.getWest())*e.worldSize,a=Bo(n.getEast())*e.worldSize,o=Eo(n.getNorth())*e.worldSize,l=Eo(n.getSouth())*e.worldSize,u=[s,o,0],c=[a,o,0],h=[s,l,0],p=[a,l,0],f=bl([],e.globeMatrix);return ql(u,u,f),ql(c,c,f),ql(h,h,f),ql(p,p,f),i[0]=ff(i[0],h,r),i[1]=ff(i[1],p,r),i[2]=ff(i[2],c,r),i[3]=ff(i[3],u,r),au.fromPoints(i)}function yf(t,e,r){for(const n of t)ql(n,n,e),Rl(n,n,r);}function mf(t,e,r){const n=e/t.worldSize,i=t.globeMatrix;if(r.z<=1){const t=pf(r).getCorners();return yf(t,i,n),au.fromPoints(t)}const s=gf(r),a=xf(s);yf(a,i,n);const o=Number.MAX_VALUE,l=[-o,-o,-o],u=[o,o,o];if(s.contains(t.center)){for(const t of a)Ll(u,u,t),Fl(l,l,t);l[2]=0;const e=t.point,r=[e.x*n,e.y*n,0];return Ll(u,u,r),Fl(l,l,r),new au(u,l)}const c=[i[12]*n,i[13]*n,i[14]*n],h=s.getCenter(),p=S(t.center.lat,-85.051129,Lo),f=S(h.lat,-85.051129,Lo),d=Bo(t.center.lng),y=Eo(p);let m=d-Bo(h.lng);const g=y-Eo(f);m>.5?m-=1:m<-.5&&(m+=1);let v=0;Math.abs(m)>Math.abs(g)?v=m>=0?1:3:(v=g>=0?0:2,jl(c,c,[i[4]*n,i[5]*n,i[6]*n],-Math.sin(x(g>=0?s.getSouth():s.getNorth()))*ef));const b=a[v],w=a[(v+1)%4],_=new cf(b,w,c),A=[hf(_,0)||b[0],hf(_,1)||b[1],hf(_,2)||b[2]],k=Mf(t.zoom);if(k>0){const n=function({x:t,y:e,z:r},n,i,s,a){const o=1/(1<.5?p=-1:f<-.5&&(p=1),l=((l+p)*n-(s*=n))*i+s,u=((u+p)*n-s)*i+s,c=(c*n-(a*=n))*i+a,h=(h*n-a)*i+a,[[l,h,0],[u,h,0],[u,c,0],[l,c,0]]}(r,e,t._pixelsPerMercatorPixel,d,y);for(let t=0;tMath.PI/2*1.01}const Bf=x(85),Ef=Math.cos(Bf),Cf=Math.sin(Bf);function Pf(t,e){const r=t.fovAboveCenter,n=t.elevation?t.elevation.getMinElevationBelowMSL()*e:0,i=(t._camera.position[2]*t.worldSize-n)/Math.cos(t._pitch),s=Math.sin(r)*i/Math.sin(Math.max(Math.PI/2-t._pitch-r,.01)),a=Math.sin(t._pitch)*s+i;return Math.min(1.01*a,i*(1/t._horizonShift))}function Df(t,e){if(!e.isReprojectedInTileSpace)return {scale:1<v&&(b(t,u,n,i,o,l),b(u,r,o,l,s,a));}b(h,p,n,s,i,s),b(p,f,i,s,i,a),b(f,d,i,a,n,a),b(d,h,n,a,n,s),y-=v,m-=v,g+=v,x+=v;const w=1/Math.max(g-y,x-m);return {scale:w,x:y*w,y:m*w,x2:g*w,y2:x*w,projection:e}}const Vf=vl(new Float32Array(16));class Lf{constructor(t){this.spec=t,this.name=t.name,this.wrap=!1,this.requiresDraping=!1,this.supportsWorldCopies=!1,this.supportsTerrain=!1,this.supportsFog=!1,this.supportsFreeCamera=!1,this.zAxisUnit=\"meters\",this.isReprojectedInTileSpace=!0,this.unsupportedLayers=[\"custom\"],this.center=[0,0],this.range=[3.5,7];}project(t,e){return {x:0,y:0,z:0}}unproject(t,e){return new Mo(0,0)}projectTilePoint(t,e,r){return {x:t,y:e,z:0}}locationPoint(t,e,r=!0){return t._coordinatePoint(t.locationCoordinate(e),r)}pixelsPerMeter(t,e){return Co(1,t)*e}pixelSpaceConversion(t,e,r){return 1}farthestPixelDistance(t){return Pf(t,t.pixelsPerMeter)}pointCoordinate(t,e,r,n){const i=t.horizonLineFromTop(!1),s=new d(e,Math.max(i,r));return t.rayIntersectionCoordinate(t.pointRayIntersection(s,n))}pointCoordinate3D(t,e,r){const n=new d(e,r);if(t.elevation)return t.elevation.pointCoordinate(n);{const e=this.pointCoordinate(t,n.x,n.y,0);return [e.x,e.y,e.z]}}isPointAboveHorizon(t,e){if(t.elevation)return !this.pointCoordinate3D(t,e.x,e.y);const r=t.horizonLineFromTop();return e.y0?e<-Gf+r&&(e=-Gf+r):e>Gf-r&&(e=Gf-r);const s=i/Math.pow(Xf(e),n);let a=s*Math.sin(n*t),o=i-s*Math.cos(n*t);return a=.5*(a/Math.PI+.5),o=.5*(o/Math.PI+.5),{x:a,y:this.southernCenter?o:1-o,z:0}}unproject(t,e){t=(2*t-.5)*Math.PI,this.southernCenter&&(e=1-e),e=(2*(1-e)-.5)*Math.PI;const{n:r,f:n}=this,i=n-e,s=Math.sign(i),a=Math.sign(r)*Math.sqrt(t*t+i*i);let o=Math.atan2(t,Math.abs(i))*s;i*r<0&&(o-=Math.PI*Math.sign(t)*s);const l=S(v(o/r)+this.center[0],-180,180),u=S(v(2*Math.atan(Math.pow(n/a,1/r))-Gf),-85.051129,Lo);return new Mo(l,this.southernCenter?-u:u)}}class Kf extends Lf{constructor(t){super(t),this.wrap=!0,this.supportsWorldCopies=!0,this.supportsTerrain=!0,this.supportsFog=!0,this.supportsFreeCamera=!0,this.isReprojectedInTileSpace=!1,this.unsupportedLayers=[],this.range=null;}project(t,e){return {x:Bo(t),y:Eo(e),z:0}}unproject(t,e){const r=Po(t),n=Do(e);return new Mo(r,n)}}const Yf=x(Lo);class Hf extends Lf{project(t,e){const r=(e=x(e))*e,n=r*r;return {x:.5*((t=x(t))*(.8707-.131979*r+n*(n*(.003971*r-.001529*n)-.013791))/Math.PI+.5),y:1-.5*(e*(1.007226+r*(.015085+n*(.028874*r-.044475-.005916*n)))/Math.PI+1),z:0}}unproject(t,e){t=(2*t-.5)*Math.PI;let r=e=(2*(1-e)-1)*Math.PI,n=25,i=0,s=r*r;do{s=r*r;const t=s*s;i=(r*(1.007226+s*(.015085+t*(.028874*s-.044475-.005916*t)))-e)/(1.007226+s*(.045255+t*(.259866*s-.311325-.005916*11*t))),r=S(r-i,-Yf,Yf);}while(Math.abs(i)>1e-6&&--n>0);s=r*r;const a=S(v(t/(.8707+s*(s*(s*s*s*(.003971-.001529*s)-.013791)-.131979))),-180,180),o=v(r);return new Mo(a,o)}}const Wf=x(Lo);class Jf extends Lf{project(t,e){e=x(e),t=x(t);const r=Math.cos(e),n=2/Math.PI,i=Math.acos(r*Math.cos(t/2)),s=Math.sin(i)/i,a=.5*(t*n+2*r*Math.sin(t/2)/s)||0,o=.5*(e+Math.sin(e)/s)||0;return {x:.5*(a/Math.PI+.5),y:1-.5*(o/Math.PI+1),z:0}}unproject(t,e){let r=t=(2*t-.5)*Math.PI,n=e=(2*(1-e)-1)*Math.PI,i=25;const s=1e-6;let a=0,o=0;do{const i=Math.cos(n),s=Math.sin(n),l=2*s*i,u=s*s,c=i*i,h=Math.cos(r/2),p=Math.sin(r/2),f=2*h*p,d=p*p,y=1-c*h*h,m=y?1/y:0,g=y?Math.acos(i*h)*Math.sqrt(1/y):0,x=.5*(2*g*i*p+2*r/Math.PI)-t,v=.5*(g*s+n)-e,b=.5*m*(c*d+g*i*h*u)+1/Math.PI,w=m*(f*l/4-g*s*p),_=.125*m*(l*p-g*s*c*f),A=.5*m*(u*h+g*d*i)+.5,k=w*_-A*b;a=(v*w-x*A)/k,o=(x*_-v*b)/k,r=S(r-a,-Math.PI,Math.PI),n=S(n-o,-Wf,Wf);}while((Math.abs(a)>s||Math.abs(o)>s)&&--i>0);return new Mo(v(r),v(n))}}class Qf extends Lf{constructor(t){super(t),this.center=t.center||[0,0],this.parallels=t.parallels||[0,0],this.cosPhi=Math.max(.01,Math.cos(x(this.parallels[0]))),this.scale=1/(2*Math.max(Math.PI*this.cosPhi,1/this.cosPhi)),this.wrap=!0,this.supportsWorldCopies=!0;}project(t,e){const{scale:r,cosPhi:n}=this;return {x:x(t)*n*r+.5,y:-Math.sin(x(e))/n*r+.5,z:0}}unproject(t,e){const{scale:r,cosPhi:n}=this,i=-(e-.5)/r,s=S(v((t-.5)/r)/n,-180,180),a=Math.asin(S(i*n,-1,1)),o=S(v(a),-85.051129,Lo);return new Mo(s,o)}}class td extends Kf{constructor(t){super(t),this.requiresDraping=!0,this.supportsWorldCopies=!1,this.supportsFog=!0,this.zAxisUnit=\"pixels\",this.unsupportedLayers=[\"debug\",\"custom\"],this.range=[3,5];}projectTilePoint(t,e,r){const n=wf(t,e,r);return ql(n,n,Sf(pf(r))),{x:n[0],y:n[1],z:n[2]}}locationPoint(t,e){const r=bf(e.lat,e.lng),n=Ul([],r),i=t.elevation?t.elevation.getAtPointOrZero(t.locationCoordinate(e),t._centerAltitude):t._centerAltitude;jl(r,r,n,Co(1,0)*So*i);const s=vl(new Float64Array(16));return wl(s,t.pixelMatrix,t.globeMatrix),ql(r,r,s),new d(r[0],r[1])}pixelsPerMeter(t,e){return Co(1,0)*e}pixelSpaceConversion(t,e,r){const n=Co(1,t)*e,i=Mr(Co(1,45)*e,n,r);return this.pixelsPerMeter(t,e)/i}createTileMatrix(t,e,r){const n=kf(pf(r.canonical));return wl(new Float64Array(16),t.globeMatrix,n)}createInversionMatrix(t,e){const{center:r}=t,n=Sf(pf(e));return kl(n,n,x(r.lng)),Sl(n,n,x(r.lat)),Al(n,n,[t._pixelsPerMercatorPixel,t._pixelsPerMercatorPixel,1]),Float32Array.from(n)}pointCoordinate(t,e,r,n){return uf(t,e,r,!0)||new Ro(0,0)}pointCoordinate3D(t,e,r){const n=this.pointCoordinate(t,e,r,0);return [n.x,n.y,n.z]}isPointAboveHorizon(t,e){return !uf(t,e.x,e.y,!1)}farthestPixelDistance(t){const e=function(t,e){const r=t.cameraToCenterDistance,n=t._centerAltitude*e,i=t._camera,s=t._camera.forward(),a=Pl([],Rl([],s,-r),[0,0,n]),o=t.worldSize/(2*Math.PI),l=[0,0,-o],u=t.width/t.height,c=Math.tan(t.fovAboveCenter),h=Rl([],i.up(),c),p=Rl([],i.right(),c*u),f=Ul([],Pl([],Pl([],s,h),p)),d=[];let y;if(new nu(a,f).closestPointOnSphere(l,o,d)){const e=Pl([],d,l),r=Xl([],e,a);y=Math.cos(t.fovAboveCenter)*El(r);}else {const t=Xl([],a,l),e=Xl([],l,a);Ul(e,e);const r=El(t)-o;y=Math.sqrt(r*(r+2*o));const n=Math.acos(y/(o+r))-Math.acos($l(s,e));y*=Math.cos(n);}return 1.01*y}(t,this.pixelsPerMeter(t.center.lat,t.worldSize)),r=Mf(t.zoom);if(r>0){const n=Pf(t,Co(1,t.center.lat)*t.worldSize),i=t.worldSize/(2*Math.PI),s=Math.max(t.width,t.height)/t.worldSize*Math.PI;return Mr(e,n+i*(1-Math.cos(s)),Math.pow(r,10))}return e}upVector(t,e,r){return wf(e,r,t,1)}upVectorScale(t){return {metersToTile:rf*_f(pf(t))}}}function ed(t){const e=t.parallels,r=!!e&&Math.abs(e[0]+e[1])<.01;switch(t.name){case\"mercator\":return new Kf(t);case\"equirectangular\":return new Nf(t);case\"naturalEarth\":return new Hf(t);case\"equalEarth\":return new qf(t);case\"winkelTripel\":return new Jf(t);case\"albers\":return r?new Qf(t):new Ff(t);case\"lambertConformalConic\":return r?new Qf(t):new Zf(t);case\"globe\":return new td(t)}throw new Error(`Invalid projection name: ${t.name}`)}const rd=Sc.types,nd=[{name:\"a_fade_opacity\",components:1,type:\"Uint8\",offset:0}];function id(t,e,r,n,i,s,a,o,l,u,c,h,p){const f=o?Math.min(Gp,Math.round(o[0])):0,d=o?Math.min(Gp,Math.round(o[1])):0;t.emplaceBack(e,r,Math.round(32*n),Math.round(32*i),s,a,(f<<1)+(l?1:0),d,16*u,16*c,256*h,256*p);}function sd(t,e,r,n,i,s,a){t.emplaceBack(e,r,n,i,s,a);}function ad(t,e,r,n,i){t.emplaceBack(e,r,n,i),t.emplaceBack(e,r,n,i),t.emplaceBack(e,r,n,i),t.emplaceBack(e,r,n,i);}function od(t){for(const e of t.sections)if(Ms(e.text))return !0;return !1}class ld{constructor(t){this.layoutVertexArray=new fa,this.indexArray=new wa,this.programConfigurations=t,this.segments=new Ao,this.dynamicLayoutVertexArray=new ua,this.opacityVertexArray=new ya,this.placedSymbolArray=new Pa,this.globeExtVertexArray=new da;}isEmpty(){return 0===this.layoutVertexArray.length&&0===this.indexArray.length&&0===this.dynamicLayoutVertexArray.length&&0===this.opacityVertexArray.length}upload(t,e,r,n){this.isEmpty()||(r&&(this.layoutVertexBuffer=t.createVertexBuffer(this.layoutVertexArray,lh.members),this.indexBuffer=t.createIndexBuffer(this.indexArray,e),this.dynamicLayoutVertexBuffer=t.createVertexBuffer(this.dynamicLayoutVertexArray,ch.members,!0),this.opacityVertexBuffer=t.createVertexBuffer(this.opacityVertexArray,nd,!0),this.globeExtVertexArray.length>0&&(this.globeExtVertexBuffer=t.createVertexBuffer(this.globeExtVertexArray,uh.members,!0)),this.opacityVertexBuffer.itemSize=1),(r||n)&&this.programConfigurations.upload(t));}destroy(){this.layoutVertexBuffer&&(this.layoutVertexBuffer.destroy(),this.indexBuffer.destroy(),this.programConfigurations.destroy(),this.segments.destroy(),this.dynamicLayoutVertexBuffer.destroy(),this.opacityVertexBuffer.destroy(),this.globeExtVertexBuffer&&this.globeExtVertexBuffer.destroy());}}Oi(ld,\"SymbolBuffers\");class ud{constructor(t,e,r){this.layoutVertexArray=new t,this.layoutAttributes=e,this.indexArray=new r,this.segments=new Ao,this.collisionVertexArray=new va,this.collisionVertexArrayExt=new ba;}upload(t){this.layoutVertexBuffer=t.createVertexBuffer(this.layoutVertexArray,this.layoutAttributes),this.indexBuffer=t.createIndexBuffer(this.indexArray),this.collisionVertexBuffer=t.createVertexBuffer(this.collisionVertexArray,hh.members,!0),this.collisionVertexBufferExt=t.createVertexBuffer(this.collisionVertexArrayExt,ph.members,!0);}destroy(){this.layoutVertexBuffer&&(this.layoutVertexBuffer.destroy(),this.indexBuffer.destroy(),this.segments.destroy(),this.collisionVertexBuffer.destroy(),this.collisionVertexBufferExt.destroy());}}Oi(ud,\"CollisionBuffers\");class cd{constructor(t){this.collisionBoxArray=t.collisionBoxArray,this.zoom=t.zoom,this.overscaling=t.overscaling,this.layers=t.layers,this.layerIds=this.layers.map((t=>t.id)),this.index=t.index,this.pixelRatio=t.pixelRatio,this.sourceLayerIndex=t.sourceLayerIndex,this.hasPattern=!1,this.hasRTLText=!1,this.fullyClipped=!1,this.sortKeyRanges=[],this.collisionCircleArray=[],this.placementInvProjMatrix=vl([]),this.placementViewportMatrix=vl([]);const e=this.layers[0]._unevaluatedLayout._values;this.textSizeData=gh(this.zoom,e[\"text-size\"]),this.iconSizeData=gh(this.zoom,e[\"icon-size\"]);const r=this.layers[0].layout,n=r.get(\"symbol-sort-key\"),i=r.get(\"symbol-z-order\");this.canOverlap=r.get(\"text-allow-overlap\")||r.get(\"icon-allow-overlap\")||r.get(\"text-ignore-placement\")||r.get(\"icon-ignore-placement\"),this.sortFeaturesByKey=\"viewport-y\"!==i&&void 0!==n.constantOr(1),this.sortFeaturesByY=(\"viewport-y\"===i||\"auto\"===i&&!this.sortFeaturesByKey)&&this.canOverlap,this.writingModes=r.get(\"text-writing-mode\").map((t=>Qh[t])),this.stateDependentLayerIds=this.layers.filter((t=>t.isStateDependent())).map((t=>t.id)),this.sourceID=t.sourceID,this.projection=t.projection;}createArrays(){this.text=new ld(new po(this.layers,this.zoom,(t=>/^text/.test(t)))),this.icon=new ld(new po(this.layers,this.zoom,(t=>/^icon/.test(t)))),this.glyphOffsetArray=new La,this.lineVertexArray=new Fa,this.symbolInstances=new Va;}calculateGlyphDependencies(t,e,r,n,i){for(let r=0;r0)&&(\"constant\"!==o.value.kind||o.value.value.length>0),h=\"constant\"!==u.value.kind||!!u.value.value||Object.keys(u.parameters).length>0,p=s.get(\"symbol-sort-key\");if(this.features=[],!c&&!h)return;const f=e.iconDependencies,d=e.glyphDependencies,y=e.availableImages,m=new Us(this.zoom);for(const{feature:e,id:l,index:u,sourceLayerIndex:g}of t){const t=i._featureFilter.needGeometry,x=Zo(e,t);if(!i._featureFilter.filter(m,x,r))continue;if(t||(x.geometry=Xo(e,r,n)),a&&1!==e.type&&r.z<=5){const t=x.geometry,e=.98078528056,n=(t,n)=>$l(wf(t.x,t.y,r,1),wf(n.x,n.y,r,1))=0;for(const r of v.sections)if(r.image)f[r.image.name]=!0;else {const n=bs(v.toString()),i=r.fontStack||t,s=d[i]=d[i]||{};this.calculateGlyphDependencies(r.text,s,e,this.allowVerticalPlacement,n);}}}\"line\"===s.get(\"symbol-placement\")&&(this.features=function(t){const e={},r={},n=[];let i=0;function s(e){n.push(t[e]),i++;}function a(t,e,i){const s=r[t];return delete r[t],r[e]=s,n[s].geometry[0].pop(),n[s].geometry[0]=n[s].geometry[0].concat(i[0]),s}function o(t,r,i){const s=e[r];return delete e[r],e[t]=s,n[s].geometry[0].shift(),n[s].geometry[0]=i[0].concat(n[s].geometry[0]),s}function l(t,e,r){const n=r?e[0][e[0].length-1]:e[0][0];return `${t}:${n.x}:${n.y}`}for(let u=0;ut.geometry))}(this.features)),this.sortFeaturesByKey&&this.features.sort(((t,e)=>t.sortKey-e.sortKey));}update(t,e,r,n){this.stateDependentLayers.length&&(this.text.programConfigurations.updatePaintArrays(t,e,this.layers,r,n),this.icon.programConfigurations.updatePaintArrays(t,e,this.layers,r,n));}isEmpty(){return 0===this.symbolInstances.length&&!this.hasRTLText}uploadPending(){return !this.uploaded||this.text.programConfigurations.needsUpload||this.icon.programConfigurations.needsUpload}upload(t){!this.uploaded&&this.hasDebugData()&&(this.textCollisionBox.upload(t),this.iconCollisionBox.upload(t)),this.text.upload(t,this.sortFeaturesByY,!this.uploaded,this.text.programConfigurations.needsUpload),this.icon.upload(t,this.sortFeaturesByY,!this.uploaded,this.icon.programConfigurations.needsUpload),this.uploaded=!0;}destroyDebugData(){this.textCollisionBox.destroy(),this.iconCollisionBox.destroy();}getProjection(){return this.projectionInstance||(this.projectionInstance=ed(this.projection)),this.projectionInstance}destroy(){this.text.destroy(),this.icon.destroy(),this.hasDebugData()&&this.destroyDebugData();}addToLineVertexArray(t,e){const r=this.lineVertexArray.length;if(void 0!==t.segment)for(const{x:t,y:r}of e)this.lineVertexArray.emplaceBack(t,r);return {lineStartIndex:r,lineLength:this.lineVertexArray.length-r}}addSymbols(t,e,r,n,i,s,a,o,l,u,c,h,p,f){const d=t.indexArray,y=t.layoutVertexArray,m=t.globeExtVertexArray,g=t.segments.prepareSegment(4*e.length,y,d,this.canOverlap?s.sortKey:void 0),x=this.glyphOffsetArray.length,v=g.vertexLength,b=this.allowVerticalPlacement&&a===Qh.vertical?Math.PI/2:0,w=s.text&&s.text.sections;for(let n=0;n=0?e.rightJustifiedTextSymbolIndex:e.centerJustifiedTextSymbolIndex>=0?e.centerJustifiedTextSymbolIndex:e.leftJustifiedTextSymbolIndex>=0?e.leftJustifiedTextSymbolIndex:e.verticalPlacedTextSymbolIndex>=0?e.verticalPlacedTextSymbolIndex:n),s=xh(this.textSizeData,t,i)/yh;return this.tilePixelRatio*s}getSymbolInstanceIconSize(t,e,r){const n=this.icon.placedSymbolArray.get(r),i=xh(this.iconSizeData,t,n);return this.tilePixelRatio*i}_commitDebugCollisionVertexUpdate(t,e,r){t.emplaceBack(e,-r,-r),t.emplaceBack(e,r,-r),t.emplaceBack(e,r,r),t.emplaceBack(e,-r,r);}_updateTextDebugCollisionBoxes(t,e,r,n,i,s){for(let a=n;a0}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(t,e){const r=t.placedSymbolArray.get(e),n=r.vertexStartIndex+4*r.numGlyphs;for(let e=r.vertexStartIndex;en[t]-n[e]||i[e]-i[t])),s}addToSortKeyRanges(t,e){const r=this.sortKeyRanges[this.sortKeyRanges.length-1];r&&r.sortKey===e?r.symbolInstanceEnd=t+1:this.sortKeyRanges.push({sortKey:e,symbolInstanceStart:t,symbolInstanceEnd:t+1});}sortFeatures(t){if(this.sortFeaturesByY&&this.sortedAngle!==t&&!(this.text.segments.get().length>1||this.icon.segments.get().length>1)){this.symbolInstanceIndexes=this.getSortedSymbolIndexes(t),this.sortedAngle=t,this.text.indexArray.clear(),this.icon.indexArray.clear(),this.featureSortOrder=[];for(const t of this.symbolInstanceIndexes){const e=this.symbolInstances.get(t);this.featureSortOrder.push(e.featureIndex);const{rightJustifiedTextSymbolIndex:r,centerJustifiedTextSymbolIndex:n,leftJustifiedTextSymbolIndex:i,verticalPlacedTextSymbolIndex:s,placedIconSymbolIndex:a,verticalPlacedIconSymbolIndex:o}=e;r>=0&&this.addIndicesForPlacedSymbol(this.text,r),n>=0&&n!==r&&this.addIndicesForPlacedSymbol(this.text,n),i>=0&&i!==n&&i!==r&&this.addIndicesForPlacedSymbol(this.text,i),s>=0&&this.addIndicesForPlacedSymbol(this.text,s),a>=0&&this.addIndicesForPlacedSymbol(this.icon,a),o>=0&&this.addIndicesForPlacedSymbol(this.icon,o);}this.text.indexBuffer&&this.text.indexBuffer.updateData(this.text.indexArray),this.icon.indexBuffer&&this.icon.indexBuffer.updateData(this.icon.indexArray);}}}Oi(cd,\"SymbolBucket\",{omit:[\"layers\",\"collisionBoxArray\",\"features\",\"compareText\"]}),cd.MAX_GLYPHS=65535,cd.addDynamicAttributes=ad;const hd=new Js({\"symbol-placement\":new Ys(Ht.layout_symbol[\"symbol-placement\"]),\"symbol-spacing\":new Ys(Ht.layout_symbol[\"symbol-spacing\"]),\"symbol-avoid-edges\":new Ys(Ht.layout_symbol[\"symbol-avoid-edges\"]),\"symbol-sort-key\":new Hs(Ht.layout_symbol[\"symbol-sort-key\"]),\"symbol-z-order\":new Ys(Ht.layout_symbol[\"symbol-z-order\"]),\"icon-allow-overlap\":new Ys(Ht.layout_symbol[\"icon-allow-overlap\"]),\"icon-ignore-placement\":new Ys(Ht.layout_symbol[\"icon-ignore-placement\"]),\"icon-optional\":new Ys(Ht.layout_symbol[\"icon-optional\"]),\"icon-rotation-alignment\":new Ys(Ht.layout_symbol[\"icon-rotation-alignment\"]),\"icon-size\":new Hs(Ht.layout_symbol[\"icon-size\"]),\"icon-text-fit\":new Ys(Ht.layout_symbol[\"icon-text-fit\"]),\"icon-text-fit-padding\":new Ys(Ht.layout_symbol[\"icon-text-fit-padding\"]),\"icon-image\":new Hs(Ht.layout_symbol[\"icon-image\"]),\"icon-rotate\":new Hs(Ht.layout_symbol[\"icon-rotate\"]),\"icon-padding\":new Ys(Ht.layout_symbol[\"icon-padding\"]),\"icon-keep-upright\":new Ys(Ht.layout_symbol[\"icon-keep-upright\"]),\"icon-offset\":new Hs(Ht.layout_symbol[\"icon-offset\"]),\"icon-anchor\":new Hs(Ht.layout_symbol[\"icon-anchor\"]),\"icon-pitch-alignment\":new Ys(Ht.layout_symbol[\"icon-pitch-alignment\"]),\"text-pitch-alignment\":new Ys(Ht.layout_symbol[\"text-pitch-alignment\"]),\"text-rotation-alignment\":new Ys(Ht.layout_symbol[\"text-rotation-alignment\"]),\"text-field\":new Hs(Ht.layout_symbol[\"text-field\"]),\"text-font\":new Hs(Ht.layout_symbol[\"text-font\"]),\"text-size\":new Hs(Ht.layout_symbol[\"text-size\"]),\"text-max-width\":new Hs(Ht.layout_symbol[\"text-max-width\"]),\"text-line-height\":new Hs(Ht.layout_symbol[\"text-line-height\"]),\"text-letter-spacing\":new Hs(Ht.layout_symbol[\"text-letter-spacing\"]),\"text-justify\":new Hs(Ht.layout_symbol[\"text-justify\"]),\"text-radial-offset\":new Hs(Ht.layout_symbol[\"text-radial-offset\"]),\"text-variable-anchor\":new Ys(Ht.layout_symbol[\"text-variable-anchor\"]),\"text-anchor\":new Hs(Ht.layout_symbol[\"text-anchor\"]),\"text-max-angle\":new Ys(Ht.layout_symbol[\"text-max-angle\"]),\"text-writing-mode\":new Ys(Ht.layout_symbol[\"text-writing-mode\"]),\"text-rotate\":new Hs(Ht.layout_symbol[\"text-rotate\"]),\"text-padding\":new Ys(Ht.layout_symbol[\"text-padding\"]),\"text-keep-upright\":new Ys(Ht.layout_symbol[\"text-keep-upright\"]),\"text-transform\":new Hs(Ht.layout_symbol[\"text-transform\"]),\"text-offset\":new Hs(Ht.layout_symbol[\"text-offset\"]),\"text-allow-overlap\":new Ys(Ht.layout_symbol[\"text-allow-overlap\"]),\"text-ignore-placement\":new Ys(Ht.layout_symbol[\"text-ignore-placement\"]),\"text-optional\":new Ys(Ht.layout_symbol[\"text-optional\"])});var pd={paint:new Js({\"icon-opacity\":new Hs(Ht.paint_symbol[\"icon-opacity\"]),\"icon-color\":new Hs(Ht.paint_symbol[\"icon-color\"]),\"icon-halo-color\":new Hs(Ht.paint_symbol[\"icon-halo-color\"]),\"icon-halo-width\":new Hs(Ht.paint_symbol[\"icon-halo-width\"]),\"icon-halo-blur\":new Hs(Ht.paint_symbol[\"icon-halo-blur\"]),\"icon-translate\":new Ys(Ht.paint_symbol[\"icon-translate\"]),\"icon-translate-anchor\":new Ys(Ht.paint_symbol[\"icon-translate-anchor\"]),\"text-opacity\":new Hs(Ht.paint_symbol[\"text-opacity\"]),\"text-color\":new Hs(Ht.paint_symbol[\"text-color\"],{runtimeType:le,getOverride:t=>t.textColor,hasOverride:t=>!!t.textColor}),\"text-halo-color\":new Hs(Ht.paint_symbol[\"text-halo-color\"]),\"text-halo-width\":new Hs(Ht.paint_symbol[\"text-halo-width\"]),\"text-halo-blur\":new Hs(Ht.paint_symbol[\"text-halo-blur\"]),\"text-translate\":new Ys(Ht.paint_symbol[\"text-translate\"]),\"text-translate-anchor\":new Ys(Ht.paint_symbol[\"text-translate-anchor\"])}),layout:hd};class fd{constructor(t){this.type=t.property.overrides?t.property.overrides.runtimeType:ie,this.defaultValue=t;}evaluate(t){if(t.formattedSection){const e=this.defaultValue.property.overrides;if(e&&e.hasOverride(t.formattedSection))return e.getOverride(t.formattedSection)}return t.feature&&t.featureState?this.defaultValue.evaluate(t.feature,t.featureState):this.defaultValue.property.specification.default}eachChild(t){this.defaultValue.isConstant()||t(this.defaultValue.value._styleExpression.expression);}outputDefined(){return !1}serialize(){return null}}Oi(fd,\"FormatSectionOverride\",{omit:[\"defaultValue\"]});class dd extends bo{constructor(t){super(t,pd);}recalculate(t,e){super.recalculate(t,e),\"auto\"===this.layout.get(\"icon-rotation-alignment\")&&(this.layout._values[\"icon-rotation-alignment\"]=\"point\"!==this.layout.get(\"symbol-placement\")?\"map\":\"viewport\"),\"auto\"===this.layout.get(\"text-rotation-alignment\")&&(this.layout._values[\"text-rotation-alignment\"]=\"point\"!==this.layout.get(\"symbol-placement\")?\"map\":\"viewport\"),\"auto\"===this.layout.get(\"text-pitch-alignment\")&&(this.layout._values[\"text-pitch-alignment\"]=this.layout.get(\"text-rotation-alignment\")),\"auto\"===this.layout.get(\"icon-pitch-alignment\")&&(this.layout._values[\"icon-pitch-alignment\"]=this.layout.get(\"icon-rotation-alignment\"));const r=this.layout.get(\"text-writing-mode\");if(r){const t=[];for(const e of r)t.indexOf(e)<0&&t.push(e);this.layout._values[\"text-writing-mode\"]=t;}else this.layout._values[\"text-writing-mode\"]=\"point\"===this.layout.get(\"symbol-placement\")?[\"horizontal\"]:[\"horizontal\",\"vertical\"];this._setPaintOverrides();}getValueAndResolveTokens(t,e,r,n){const i=this.layout.get(t).evaluate(e,{},r,n),s=this._unevaluatedLayout._values[t];return s.isDataDriven()||Nn(s.value)||!i?i:function(t,e){return e.replace(/{([^{}]+)}/g,((e,r)=>r in t?String(t[r]):\"\"))}(e.properties,i)}createBucket(t){return new cd(t)}queryRadius(){return 0}queryIntersectsFeature(){return !1}_setPaintOverrides(){for(const t of pd.paint.overridableProperties){if(!dd.hasPaintOverride(this.layout,t))continue;const e=this.paint.get(t),r=new fd(e),n=new qn(r,e.property.specification);let i=null;i=\"constant\"===e.value.kind||\"source\"===e.value.kind?new Xn(\"source\",n):new Zn(\"composite\",n,e.value.zoomStops,e.value._interpolationType),this.paint._values[t]=new Zs(e.property,i,e.parameters);}}_handleOverridablePaintPropertyUpdate(t,e,r){return !(!this.layout||e.isDataDriven()||r.isDataDriven())&&dd.hasPaintOverride(this.layout,t)}static hasPaintOverride(t,e){const r=t.get(\"text-field\"),n=pd.paint.properties[e];let i=!1;const s=t=>{for(const e of t)if(n.overrides&&n.overrides.hasOverride(e))return void(i=!0)};if(\"constant\"===r.value.kind&&r.value.value instanceof Be)s(r.value.value.sections);else if(\"source\"===r.value.kind){const t=e=>{i||(e instanceof Fe&&De(e.value)===pe?s(e.value.sections):e instanceof Oe?s(e.sections):e.eachChild(t));},e=r.value;e._styleExpression&&t(e._styleExpression.expression);}return i}getProgramConfiguration(t){return new ho(this,t)}}var yd={paint:new Js({\"background-color\":new Ys(Ht.paint_background[\"background-color\"]),\"background-pattern\":new Ys(Ht.paint_background[\"background-pattern\"]),\"background-opacity\":new Ys(Ht.paint_background[\"background-opacity\"])})},md={paint:new Js({\"raster-opacity\":new Ys(Ht.paint_raster[\"raster-opacity\"]),\"raster-hue-rotate\":new Ys(Ht.paint_raster[\"raster-hue-rotate\"]),\"raster-brightness-min\":new Ys(Ht.paint_raster[\"raster-brightness-min\"]),\"raster-brightness-max\":new Ys(Ht.paint_raster[\"raster-brightness-max\"]),\"raster-saturation\":new Ys(Ht.paint_raster[\"raster-saturation\"]),\"raster-contrast\":new Ys(Ht.paint_raster[\"raster-contrast\"]),\"raster-resampling\":new Ys(Ht.paint_raster[\"raster-resampling\"]),\"raster-fade-duration\":new Ys(Ht.paint_raster[\"raster-fade-duration\"])})};class gd extends bo{constructor(t){super(t,{}),this.implementation=t;}is3D(){return \"3d\"===this.implementation.renderingMode}hasOffscreenPass(){return void 0!==this.implementation.prerender}recalculate(){}updateTransitions(){}hasTransition(){return !1}serialize(){}onAdd(t){this.implementation.onAdd&&this.implementation.onAdd(t,t.painter.context.gl);}onRemove(t){this.implementation.onRemove&&this.implementation.onRemove(t,t.painter.context.gl);}}var xd={paint:new Js({\"sky-type\":new Ys(Ht.paint_sky[\"sky-type\"]),\"sky-atmosphere-sun\":new Ys(Ht.paint_sky[\"sky-atmosphere-sun\"]),\"sky-atmosphere-sun-intensity\":new Ys(Ht.paint_sky[\"sky-atmosphere-sun-intensity\"]),\"sky-gradient-center\":new Ys(Ht.paint_sky[\"sky-gradient-center\"]),\"sky-gradient-radius\":new Ys(Ht.paint_sky[\"sky-gradient-radius\"]),\"sky-gradient\":new Ws(Ht.paint_sky[\"sky-gradient\"]),\"sky-atmosphere-halo-color\":new Ys(Ht.paint_sky[\"sky-atmosphere-halo-color\"]),\"sky-atmosphere-color\":new Ys(Ht.paint_sky[\"sky-atmosphere-color\"]),\"sky-opacity\":new Ys(Ht.paint_sky[\"sky-opacity\"])})};function vd(t,e,r){const n=[0,0,1],i=Ql([]);return eu(i,i,r?-x(t)+Math.PI:x(t)),tu(i,i,-x(e)),Nl(n,n,i),Ul(n,n)}const bd={circle:class extends bo{constructor(t){super(t,dl);}createBucket(t){return new Ho(t)}queryRadius(t){const e=t;return ul(\"circle-radius\",this,e)+ul(\"circle-stroke-width\",this,e)+cl(this.paint.get(\"circle-translate\"))}queryIntersectsFeature(t,e,r,n,i,s,a,o){const l=pl(this.paint.get(\"circle-translate\"),this.paint.get(\"circle-translate-anchor\"),s.angle,t.pixelToTileUnitsFactor),u=this.paint.get(\"circle-radius\").evaluate(e,r)+this.paint.get(\"circle-stroke-width\").evaluate(e,r);return ou(t,n,s,a,o,\"map\"===this.paint.get(\"circle-pitch-alignment\"),\"map\"===this.paint.get(\"circle-pitch-scale\"),l,u)}getProgramIds(){return [\"circle\"]}getProgramConfiguration(t){return new ho(this,t)}},heatmap:class extends bo{createBucket(t){return new pu(t)}constructor(t){super(t,xu),this._updateColorRamp();}_handleSpecialPaintPropertyUpdate(t){\"heatmap-color\"===t&&this._updateColorRamp();}_updateColorRamp(){this.colorRamp=vu({expression:this._transitionablePaint._values[\"heatmap-color\"].value.expression,evaluationKey:\"heatmapDensity\",image:this.colorRamp}),this.colorRampTexture=null;}resize(){this.heatmapFbo&&(this.heatmapFbo.destroy(),this.heatmapFbo=null);}queryRadius(t){return ul(\"heatmap-radius\",this,t)}queryIntersectsFeature(t,e,r,n,i,s,a,o){const l=this.paint.get(\"heatmap-radius\").evaluate(e,r);return ou(t,n,s,a,o,!0,!0,new d(0,0),l)}hasOffscreenPass(){return 0!==this.paint.get(\"heatmap-opacity\")&&\"none\"!==this.visibility}getProgramIds(){return [\"heatmap\",\"heatmapTexture\"]}getProgramConfiguration(t){return new ho(this,t)}},hillshade:class extends bo{constructor(t){super(t,bu);}hasOffscreenPass(){return 0!==this.paint.get(\"hillshade-exaggeration\")&&\"none\"!==this.visibility}getProgramIds(){return [\"hillshade\",\"hillshadePrepare\"]}},fill:class extends bo{constructor(t){super(t,ac);}getProgramIds(){const t=this.paint.get(\"fill-pattern\"),e=t&&t.constantOr(1),r=[e?\"fillPattern\":\"fill\"];return this.paint.get(\"fill-antialias\")&&r.push(e&&!this.getPaintProperty(\"fill-outline-color\")?\"fillOutlinePattern\":\"fillOutline\"),r}getProgramConfiguration(t){return new ho(this,t)}recalculate(t,e){super.recalculate(t,e);const r=this.paint._values[\"fill-outline-color\"];\"constant\"===r.value.kind&&void 0===r.value.value&&(this.paint._values[\"fill-outline-color\"]=this.paint._values[\"fill-color\"]);}createBucket(t){return new ic(t)}queryRadius(){return cl(this.paint.get(\"fill-translate\"))}queryIntersectsFeature(t,e,r,n,i,s){return !t.queryGeometry.isAboveHorizon&&Qo(hl(t.tilespaceGeometry,this.paint.get(\"fill-translate\"),this.paint.get(\"fill-translate-anchor\"),s.angle,t.pixelToTileUnitsFactor),n)}isTileClipped(){return !0}},\"fill-extrusion\":class extends bo{constructor(t){super(t,$c);}createBucket(t){return new Ec(t)}queryRadius(){return cl(this.paint.get(\"fill-extrusion-translate\"))}is3D(){return !0}getProgramIds(){return [this.paint.get(\"fill-extrusion-pattern\").constantOr(1)?\"fillExtrusionPattern\":\"fillExtrusion\"]}getProgramConfiguration(t){return new ho(this,t)}queryIntersectsFeature(t,e,r,n,i,s,a,o,l){const u=pl(this.paint.get(\"fill-extrusion-translate\"),this.paint.get(\"fill-extrusion-translate-anchor\"),s.angle,t.pixelToTileUnitsFactor),c=this.paint.get(\"fill-extrusion-height\").evaluate(e,r),h=this.paint.get(\"fill-extrusion-base\").evaluate(e,r),p=[0,0],f=o&&s.elevation,y=s.elevation?s.elevation.exaggeration():1,m=t.tile.getBucket(this);if(f&&m instanceof Ec){const t=m.centroidVertexArray,e=l+1;et.polygon)).flat());const g=f?o:null,[x,v]=function(t,e,r,n,i,s,a,o,l,u,c){return \"globe\"===t.projection.name?function(t,e,r,n,i,s,a,o,l,u,c){const h=[],p=[],f=t.projection.upVectorScale(c,t.center.lat,t.worldSize).metersToTile,d=[0,0,0,1],y=[0,0,0,1],m=(t,e,r,n)=>{t[0]=e,t[1]=r,t[2]=n,t[3]=1;},g=Rc();r>0&&(r+=g),n+=g;for(const g of e){const e=[],x=[];for(const h of g){const p=h.x+i.x,g=h.y+i.y,v=t.projection.projectTilePoint(p,g,c),b=t.projection.upVector(c,h.x,h.y);let w=r,_=n;if(a){const t=Hc(p,g,r,n,a,o,l,u);w+=t.base,_+=t.top;}0!==r?m(d,v.x+b[0]*f*w,v.y+b[1]*f*w,v.z+b[2]*f*w):m(d,v.x,v.y,v.z),m(y,v.x+b[0]*f*_,v.y+b[1]*f*_,v.z+b[2]*f*_),ql(d,d,s),ql(y,y,s),e.push(new Zc(d[0],d[1],d[2])),x.push(new Zc(y[0],y[1],y[2]));}h.push(e),p.push(x);}return [h,p]}(t,e,r,n,i,s,a,o,l,u,c):a?function(t,e,r,n,i,s,a,o,l){const u=[],c=[],h=[0,0,0,1];for(const p of t){const t=[],f=[];for(const u of p){const c=u.x+n.x,p=u.y+n.y,d=Hc(c,p,e,r,s,a,o,l);h[0]=c,h[1]=p,h[2]=d.base,h[3]=1,Wl(h,h,i),h[3]=Math.max(h[3],1e-5);const y=new Zc(h[0]/h[3],h[1]/h[3],h[2]/h[3]);h[0]=c,h[1]=p,h[2]=d.top,h[3]=1,Wl(h,h,i),h[3]=Math.max(h[3],1e-5);const m=new Zc(h[0]/h[3],h[1]/h[3],h[2]/h[3]);t.push(y),f.push(m);}u.push(t),c.push(f);}return [u,c]}(e,r,n,i,s,a,o,l,u):function(t,e,r,n,i){const s=[],a=[],o=i[8]*e,l=i[9]*e,u=i[10]*e,c=i[11]*e,h=i[8]*r,p=i[9]*r,f=i[10]*r,d=i[11]*r;for(const e of t){const t=[],r=[];for(const s of e){const e=s.x+n.x,a=s.y+n.y,y=i[0]*e+i[4]*a+i[12],m=i[1]*e+i[5]*a+i[13],g=i[2]*e+i[6]*a+i[14],x=i[3]*e+i[7]*a+i[15],v=y+o,b=m+l,w=g+u,_=Math.max(x+c,1e-5),A=y+h,S=m+p,k=g+f,I=Math.max(x+d,1e-5);t.push(new Zc(v/_,b/_,w/_)),r.push(new Zc(A/I,S/I,k/I));}s.push(t),a.push(r);}return [s,a]}(e,r,n,i,s)}(s,n,h,c,u,a,g,p,y,s.center.lat,t.tileID.canonical),b=t.queryGeometry;return function(t,e,r){let n=1/0;Qo(r,e)&&(n=Yc(r,e[0]));for(let i=0;i=3)for(let e=0;e{this._triggered=!1,this._callback();});}trigger(){this._triggered||(this._triggered=!0,this._channel?this._channel.port1.postMessage(!0):setTimeout((()=>{this._triggered=!1,this._callback();}),0));}remove(){this._channel=void 0,this._callback=()=>{};}}class Ad{constructor(){this.tasks={},this.taskQueue=[],V([\"process\"],this),this.invoker=new _d(this.process),this.nextId=0;}add(t,e){const r=this.nextId++,n=function({type:t,isSymbolTile:e,zoom:r}){return r=r||0,\"message\"===t?0:\"maybePrepare\"!==t||e?\"parseTile\"!==t||e?\"parseTile\"===t&&e?300-r:\"maybePrepare\"===t&&e?400-r:500:200-r:100-r}(e);if(0===n){N();try{t();}finally{}return {cancel:()=>{}}}return this.tasks[r]={fn:t,metadata:e,priority:n,id:r},this.taskQueue.push(r),this.invoker.trigger(),{cancel:()=>{delete this.tasks[r];}}}process(){N();try{if(this.taskQueue=this.taskQueue.filter((t=>!!this.tasks[t])),!this.taskQueue.length)return;const t=this.pick();if(null===t)return;const e=this.tasks[t];if(delete this.tasks[t],this.taskQueue.length&&this.invoker.trigger(),!e)return;e.fn();}finally{}}pick(){let t=null,e=1/0;for(let r=0;r>=1)>1;){const t=r+i>>1,l=n+s>>1;1&e?(i=r,s=n,r=a,n=o):(r=i,n=s,i=a,s=o),a=t,o=l;}const l=4*t;zd[l+0]=r,zd[l+1]=n,zd[l+2]=i,zd[l+3]=s;}const Bd=new Uint16Array(2178),Ed=new Uint8Array(1089),Cd=new Uint16Array(1089);function Pd(t){return 0===t?-.03125:32===t?.03125:0}var Dd=na([{name:\"a_pos\",type:\"Int16\",components:2},{name:\"a_texture_pos\",type:\"Int16\",components:2}]);const Vd={type:2,extent:So,loadGeometry:()=>[[new d(0,0),new d(8193,0),new d(8193,8193),new d(0,8193),new d(0,0)]]};class Ld{constructor(t,e,r,n,i){this.tileID=t,this.uid=E(),this.uses=0,this.tileSize=e,this.tileZoom=r,this.buckets={},this.expirationTime=null,this.queryPadding=0,this.hasSymbolBuckets=!1,this.hasRTLText=!1,this.dependencies={},this.isRaster=i,this.expiredRequestCount=0,this.state=\"loading\",n&&n.transform&&(this.projection=n.transform.projection);}registerFadeDuration(t){const e=t+this.timeAdded;ee.getLayer(t))).filter(Boolean);if(0!==t.length){n.layers=t,n.stateDependentLayerIds&&(n.stateDependentLayers=n.stateDependentLayerIds.map((e=>t.filter((t=>t.id===e))[0])));for(const e of t)r[e.id]=n;}}return r}(t.buckets,e.style),this.hasSymbolBuckets=!1;for(const t in this.buckets){const e=this.buckets[t];if(e instanceof cd){if(this.hasSymbolBuckets=!0,!r)break;e.justReloaded=!0;}}if(this.hasRTLText=!1,this.hasSymbolBuckets)for(const t in this.buckets){const e=this.buckets[t];if(e instanceof cd&&e.hasRTLText){this.hasRTLText=!0,js.isLoading()||js.isLoaded()||\"deferred\"!==Fs()||Rs();break}}this.queryPadding=0;for(const t in this.buckets){const r=this.buckets[t];this.queryPadding=Math.max(this.queryPadding,e.style.getLayer(t).queryRadius(r));}t.imageAtlas&&(this.imageAtlas=t.imageAtlas),t.glyphAtlasImage&&(this.glyphAtlasImage=t.glyphAtlasImage),t.lineAtlas&&(this.lineAtlas=t.lineAtlas);}else this.collisionBoxArray=new Ea;}unloadVectorData(){if(this.hasData()){for(const t in this.buckets)this.buckets[t].destroy();this.buckets={},this.imageAtlas&&(this.imageAtlas=null),this.lineAtlas&&(this.lineAtlas=null),this.imageAtlasTexture&&this.imageAtlasTexture.destroy(),this.glyphAtlasTexture&&this.glyphAtlasTexture.destroy(),this.lineAtlasTexture&&this.lineAtlasTexture.destroy(),this._tileBoundsBuffer&&(this._tileBoundsBuffer.destroy(),this._tileBoundsIndexBuffer.destroy(),this._tileBoundsSegments.destroy(),this._tileBoundsBuffer=null),this._tileDebugBuffer&&(this._tileDebugBuffer.destroy(),this._tileDebugSegments.destroy(),this._tileDebugBuffer=null),this._tileDebugIndexBuffer&&(this._tileDebugIndexBuffer.destroy(),this._tileDebugIndexBuffer=null),this._globeTileDebugBorderBuffer&&(this._globeTileDebugBorderBuffer.destroy(),this._globeTileDebugBorderBuffer=null),this._tileDebugTextBuffer&&(this._tileDebugTextBuffer.destroy(),this._tileDebugTextSegments.destroy(),this._tileDebugTextIndexBuffer.destroy(),this._tileDebugTextBuffer=null),this._globeTileDebugTextBuffer&&(this._globeTileDebugTextBuffer.destroy(),this._globeTileDebugTextBuffer=null),this.latestFeatureIndex=null,this.state=\"unloaded\";}}getBucket(t){return this.buckets[t.id]}upload(t){for(const e in this.buckets){const r=this.buckets[e];r.uploadPending()&&r.upload(t);}const e=t.gl;this.imageAtlas&&!this.imageAtlas.uploaded&&(this.imageAtlasTexture=new wd(t,this.imageAtlas.image,e.RGBA),this.imageAtlas.uploaded=!0),this.glyphAtlasImage&&(this.glyphAtlasTexture=new wd(t,this.glyphAtlasImage,e.ALPHA),this.glyphAtlasImage=null),this.lineAtlas&&!this.lineAtlas.uploaded&&(this.lineAtlasTexture=new wd(t,this.lineAtlas.image,e.ALPHA),this.lineAtlas.uploaded=!0);}prepare(t){this.imageAtlas&&this.imageAtlas.patchUpdatedImages(t,this.imageAtlasTexture);}queryRenderedFeatures(t,e,r,n,i,s,a,o){return this.latestFeatureIndex&&this.latestFeatureIndex.rawTileData?this.latestFeatureIndex.query({tileResult:n,pixelPosMatrix:a,transform:s,params:i,tileTransform:this.tileTransform},t,e,r):{}}querySourceFeatures(t,e){const r=this.latestFeatureIndex;if(!r||!r.rawTileData)return;const n=r.loadVTLayers(),i=e?e.sourceLayer:\"\",s=n._geojsonTileLayer||n[i];if(!s)return;const a=ai(e&&e.filter),{z:o,x:l,y:u}=this.tileID.canonical,c={z:o,x:l,y:u};for(let e=0;et)r=!1;else if(e)if(this.expirationTime=0;t--){const e=4*t,r=zd[e+0],n=zd[e+1],i=zd[e+2],s=zd[e+3],a=r+i>>1,o=n+s>>1,l=a+o-n,u=o+r-a,c=n*Td+r,h=s*Td+i,p=o*Td+a,f=Math.hypot((Bd[2*c+0]+Bd[2*h+0])/2-Bd[2*p+0],(Bd[2*c+1]+Bd[2*h+1])/2-Bd[2*p+1])>=16;if(Ed[p]=Ed[p]||(f?1:0),t<1022){const t=(n+u>>1)*Td+(r+l>>1),e=(s+u>>1)*Td+(i+l>>1);Ed[p]=Ed[p]||Ed[t]||Ed[e];}}const i=new oa,s=new wa;let a=0;function o(t,e){const r=e*Td+t;return 0===Cd[r]&&(i.emplaceBack(Bd[2*r+0],Bd[2*r+1],t*So/Md,e*So/Md),Cd[r]=++a),Cd[r]-1}function l(t,e,r,n,i,a){const u=t+r>>1,c=e+n>>1;if(Math.abs(t-i)+Math.abs(e-a)>1&&Ed[c*Td+u])l(i,a,t,e,u,c),l(r,n,i,a,u,c);else {const l=o(t,e),u=o(r,n),c=o(i,a);s.emplaceBack(l,u,c);}}return l(0,0,Md,Md,Md,0),l(Md,Md,0,0,0,Md),{vertices:i,indices:s}}(this.tileID.canonical,e);n=t.vertices,i=t.indices;}else {n=new oa,i=new wa;for(const{x:t,y:e}of r)n.emplaceBack(t,e,0,0);const t=Au.exports(n.int16,void 0,4);for(let e=0;e0&&(a=bl(new Float64Array(16),e.globeMatrix)),this._makeGlobeTileDebugBorderBuffer(t,n,e,i,a,s),this._makeGlobeTileDebugTextBuffer(t,n,e,i,a,s);}_globePoint(t,e,r,n,i,s,a){let o=wf(t,e,r);if(s){const i=1<.5?h=-1:c<-.5&&(h=1);let p=(t/So+r.x)/i+h,f=(e/So+r.y)/i;p=(p-l)*n._pixelsPerMercatorPixel+l,f=(f-u)*n._pixelsPerMercatorPixel+u;const d=[p*n.worldSize,f*n.worldSize,0];ql(d,d,s),o=ff(o,d,a);}return ql(o,o,i)}_makeGlobeTileDebugBorderBuffer(t,e,r,n,i,s){const a=new sa,o=new Ta,l=new aa,u=(t,u,c,h,p)=>{const f=(c-t)/(p-1),d=(h-u)/(p-1),y=a.length;for(let c=0;cu*t+e;for(let t=0;te[a])return null}else {const o=1/n[a];let l=(t[a]-r[a])*o,u=(e[a]-r[a])*o;if(l>u){const t=l;l=u,u=t;}if(l>i&&(i=l),us)return null}return i}function Ud(t,e,r,n,i,s,a,o,l,u,c){const h=n-t,p=i-e,f=s-r,d=a-t,y=o-e,m=l-r,g=c[1]*m-c[2]*y,x=c[2]*d-c[0]*m,v=c[0]*y-c[1]*d,b=h*g+p*x+f*v;if(Math.abs(b)<1e-15)return null;const w=1/b,_=u[0]-t,A=u[1]-e,S=u[2]-r,k=(_*g+A*x+S*v)*w;if(k<0||k>1)return null;const I=A*f-S*p,M=S*h-_*f,T=_*p-A*h,z=(c[0]*I+c[1]*M+c[2]*T)*w;return z<0||k+z>1?null:(d*I+y*M+m*T)*w}function $d(t,e,r){return (t-e)/(r-e)}function Od(t,e,r,n,i,s,a,o,l){const u=1<{const s=n?1:0,a=(t+1)*r-s,o=e*r,l=(e+1)*r-s;i[0]=t*r,i[1]=o,i[2]=a,i[3]=l;};let a=new Rd(n);const o=[];for(let e=0;e=1;n/=2){const t=r[r.length-1];a=new Rd(n);for(let e=0;e0;){const{idx:o,t:f,nodex:d,nodey:y,depth:m}=p.pop();if(this.leaves[o]){Od(d,y,m,t,e,r,n,c,h);const o=1<=t[2])return f}continue}let g=0;for(let p=0;p=l[u[r]]&&(u.splice(r,0,p),e=!0);e||(u[g]=p),g++;}}for(let t=0;t=this.dim+1||e<-1||e>=this.dim+1)throw new RangeError(\"out of range source coordinates for DEM data\");return (e+1)*this.stride+(t+1)}_unpackMapbox(t,e,r){return (256*t*256+256*e+r)/10-1e4}_unpackTerrarium(t,e,r){return 256*t+e+r/256-32768}static pack(t,e){const r=[0,0,0,0],n=Zd.getUnpackVector(e);let i=Math.floor((t+n[3])/n[2]);return r[2]=i%256,i=Math.floor(i/256),r[1]=i%256,i=Math.floor(i/256),r[0]=i,r}getPixels(){return new gu({width:this.stride,height:this.stride},this.pixels)}backfillBorder(t,e,r){if(this.dim!==t.dim)throw new Error(\"dem dimension mismatch\");let n=e*this.dim,i=e*this.dim+this.dim,s=r*this.dim,a=r*this.dim+this.dim;switch(e){case-1:n=i-1;break;case 1:i=n+1;}switch(r){case-1:s=a-1;break;case 1:a=s+1;}const o=-e*this.dim,l=-r*this.dim;for(let e=s;e{this.remove(t,i);}),r)),this.data[n].push(i),this.order.push(n),this.order.length>this.max){const t=this._getAndRemoveByKey(this.order[0]);t&&this.onRemove(t);}return this}has(t){return t.wrapped().key in this.data}getAndRemove(t){return this.has(t)?this._getAndRemoveByKey(t.wrapped().key):null}_getAndRemoveByKey(t){const e=this.data[t].shift();return e.timeout&&clearTimeout(e.timeout),0===this.data[t].length&&delete this.data[t],this.order.splice(this.order.indexOf(t),1),e.value}getByKey(t){const e=this.data[t];return e?e[0].value:null}get(t){return this.has(t)?this.data[t.wrapped().key][0].value:null}remove(t,e){if(!this.has(t))return this;const r=t.wrapped().key,n=void 0===e?0:this.data[r].indexOf(e),i=this.data[r][n];return this.data[r].splice(n,1),i.timeout&&clearTimeout(i.timeout),0===this.data[r].length&&delete this.data[r],this.onRemove(i.value),this.order.splice(this.order.indexOf(r),1),this}setMaxSize(t){for(this.max=t;this.order.length>this.max;){const t=this._getAndRemoveByKey(this.order[0]);t&&this.onRemove(t);}return this}filter(t){const e=[];for(const r in this.data)for(const n of this.data[r])t(n.value)||e.push(n);for(const t of e)this.remove(t.value.tileID,t);}}class Yd{constructor(t,e,r){this.func=t,this.mask=e,this.range=r;}}Yd.ReadOnly=!1,Yd.ReadWrite=!0,Yd.disabled=new Yd(519,Yd.ReadOnly,[0,1]);const Hd=7680;class Wd{constructor(t,e,r,n,i,s){this.test=t,this.ref=e,this.mask=r,this.fail=n,this.depthFail=i,this.pass=s;}}Wd.disabled=new Wd({func:519,mask:0},0,0,Hd,Hd,Hd);class Jd{constructor(t,e,r){this.blendFunction=t,this.blendColor=e,this.mask=r;}}Jd.Replace=[1,0],Jd.disabled=new Jd(Jd.Replace,Me.transparent,[!1,!1,!1,!1]),Jd.unblended=new Jd(Jd.Replace,Me.transparent,[!0,!0,!0,!0]),Jd.alphaBlended=new Jd([1,771],Me.transparent,[!0,!0,!0,!0]);const Qd=1029,ty=2305;class ey{constructor(t,e,r){this.enable=t,this.mode=e,this.frontFace=r;}}ey.disabled=new ey(!1,Qd,ty),ey.backCCW=new ey(!0,Qd,ty),ey.backCW=new ey(!0,Qd,2304),ey.frontCW=new ey(!0,1028,2304),ey.frontCCW=new ey(!0,1028,ty);class ry extends Yt{constructor(t,e,r){super(),this.id=t,this._onlySymbols=r,e.on(\"data\",(t=>{\"source\"===t.dataType&&\"metadata\"===t.sourceDataType&&(this._sourceLoaded=!0),this._sourceLoaded&&!this._paused&&\"source\"===t.dataType&&\"content\"===t.sourceDataType&&(this.reload(),this.transform&&this.update(this.transform));})),e.on(\"error\",(()=>{this._sourceErrored=!0;})),this._source=e,this._tiles={},this._cache=new Kd(0,this._unloadTile.bind(this)),this._timers={},this._cacheTimers={},this._minTileCacheSize=e.minTileCacheSize,this._maxTileCacheSize=e.maxTileCacheSize,this._loadedParentTiles={},this._coveredTiles={},this._state=new Fd,this._isRaster=\"raster\"===this._source.type||\"raster-dem\"===this._source.type||\"custom\"===this._source.type&&\"raster\"===this._source._dataType;}onAdd(t){this.map=t,this._minTileCacheSize=void 0===this._minTileCacheSize&&t?t._minTileCacheSize:this._minTileCacheSize,this._maxTileCacheSize=void 0===this._maxTileCacheSize&&t?t._maxTileCacheSize:this._maxTileCacheSize;}loaded(){if(this._sourceErrored)return !0;if(!this._sourceLoaded)return !1;if(!this._source.loaded())return !1;for(const t in this._tiles){const e=this._tiles[t];if(\"loaded\"!==e.state&&\"errored\"!==e.state)return !1}return !0}getSource(){return this._source}pause(){this._paused=!0;}resume(){if(!this._paused)return;const t=this._shouldReloadOnResume;this._paused=!1,this._shouldReloadOnResume=!1,t&&this.reload(),this.transform&&this.update(this.transform);}_loadTile(t,e){return t.isSymbolTile=this._onlySymbols,this._source.loadTile(t,e)}_unloadTile(t){if(this._source.unloadTile)return this._source.unloadTile(t,(()=>{}))}_abortTile(t){if(this._source.abortTile)return this._source.abortTile(t,(()=>{}))}serialize(){return this._source.serialize()}prepare(t){this._source.prepare&&this._source.prepare(),this._state.coalesceChanges(this._tiles,this.map?this.map.painter:null);for(const e in this._tiles){const r=this._tiles[e];r.upload(t),r.prepare(this.map.style.imageManager);}}getIds(){return T(this._tiles).map((t=>t.tileID)).sort(ny).map((t=>t.key))}getRenderableIds(t){const e=[];for(const r in this._tiles)this._isIdRenderable(+r,t)&&e.push(this._tiles[r]);return t?e.sort(((t,e)=>{const r=t.tileID,n=e.tileID,i=new d(r.canonical.x,r.canonical.y)._rotate(this.transform.angle),s=new d(n.canonical.x,n.canonical.y)._rotate(this.transform.angle);return r.overscaledZ-n.overscaledZ||s.y-i.y||s.x-i.x})).map((t=>t.tileID.key)):e.map((t=>t.tileID)).sort(ny).map((t=>t.key))}hasRenderableParent(t){const e=this.findLoadedParent(t,0);return !!e&&this._isIdRenderable(e.tileID.key)}_isIdRenderable(t,e){return this._tiles[t]&&this._tiles[t].hasData()&&!this._coveredTiles[t]&&(e||!this._tiles[t].holdingForFade())}reload(){if(this._paused)this._shouldReloadOnResume=!0;else {this._cache.reset();for(const t in this._tiles)\"errored\"!==this._tiles[t].state&&this._reloadTile(+t,\"reloading\");}}_reloadTile(t,e){const r=this._tiles[t];r&&(\"loading\"!==r.state&&(r.state=e),this._loadTile(r,this._tileLoaded.bind(this,r,t,e)));}_tileLoaded(t,e,r,n){if(n)if(t.state=\"errored\",404!==n.status)this._source.fire(new Kt(n,{tile:t}));else if(\"raster-dem\"===this._source.type&&this.usedForTerrain&&this.map.painter.terrain){const t=this.map.painter.terrain;this.update(this.transform,t.getScaledDemTileSize(),!0),t.resetTileLookupCache(this.id);}else this.update(this.transform);else t.timeAdded=Nt.now(),\"expired\"===r&&(t.refreshedUponExpiration=!0),this._setTileReloadTimer(e,t),\"raster-dem\"===this._source.type&&t.dem&&this._backfillDEM(t),this._state.initializeTileState(t,this.map?this.map.painter:null),this._source.fire(new Zt(\"data\",{dataType:\"source\",tile:t,coord:t.tileID,sourceCacheId:this.id}));}_backfillDEM(t){const e=this.getRenderableIds();for(let n=0;n1||(Math.abs(r)>1&&(1===Math.abs(r+i)?r+=i:1===Math.abs(r-i)&&(r-=i)),e.dem&&t.dem&&(t.dem.backfillBorder(e.dem,r,n),t.neighboringTiles&&t.neighboringTiles[s]&&(t.neighboringTiles[s].backfilled=!0)));}}getTile(t){return this.getTileByID(t.key)}getTileByID(t){return this._tiles[t]}_retainLoadedChildren(t,e,r,n){for(const i in this._tiles){let s=this._tiles[i];if(n[i]||!s.hasData()||s.tileID.overscaledZ<=e||s.tileID.overscaledZ>r)continue;let a=s.tileID;for(;s&&s.tileID.overscaledZ>e+1;){const t=s.tileID.scaledTo(s.tileID.overscaledZ-1);s=this._tiles[t.key],s&&s.hasData()&&(a=t);}let o=a;for(;o.overscaledZ>e;)if(o=o.scaledTo(o.overscaledZ-1),t[o.key]){n[a.key]=a;break}}}findLoadedParent(t,e){if(t.key in this._loadedParentTiles){const r=this._loadedParentTiles[t.key];return r&&r.tileID.overscaledZ>=e?r:null}for(let r=t.overscaledZ-1;r>=e;r--){const e=t.scaledTo(r),n=this._getLoadedTile(e);if(n)return n}}_getLoadedTile(t){const e=this._tiles[t.key];return e&&e.hasData()?e:this._cache.getByKey(this._source.reparseOverscaled?t.wrapped().key:t.canonical.key)}updateCacheSize(t,e){e=e||this._source.tileSize;const r=Math.ceil(t.width/e)+1,n=Math.ceil(t.height/e)+1,i=Math.floor(r*n*5),s=\"number\"==typeof this._minTileCacheSize?Math.max(this._minTileCacheSize,i):i,a=\"number\"==typeof this._maxTileCacheSize?Math.min(this._maxTileCacheSize,s):s;this._cache.setMaxSize(a);}handleWrapJump(t){const e=Math.round((t-(void 0===this._prevLng?t:this._prevLng))/360);if(this._prevLng=t,e){const t={};for(const r in this._tiles){const n=this._tiles[r];n.tileID=n.tileID.unwrapTo(n.tileID.wrap+e),t[n.tileID.key]=n;}this._tiles=t;for(const t in this._timers)clearTimeout(this._timers[t]),delete this._timers[t];for(const t in this._tiles)this._setTileReloadTimer(+t,this._tiles[t]);}}update(t,e,r){if(this.transform=t,!this._sourceLoaded||this._paused||this.transform.freezeTileCoverage)return;if(this.usedForTerrain&&!r)return;let n;this.updateCacheSize(t,e),\"globe\"!==this.transform.projection.name&&this.handleWrapJump(this.transform.center.lng),this._coveredTiles={},this.used||this.usedForTerrain?this._source.tileID?n=t.getVisibleUnwrappedCoordinates(this._source.tileID).map((t=>new Gc(t.canonical.z,t.wrap,t.canonical.z,t.canonical.x,t.canonical.y))):(n=t.coveringTiles({tileSize:e||this._source.tileSize,minzoom:this._source.minzoom,maxzoom:this._source.maxzoom,roundZoom:this._source.roundZoom&&!r,reparseOverscaled:this._source.reparseOverscaled,isTerrainDEM:this.usedForTerrain}),this._source.hasTile&&(n=n.filter((t=>this._source.hasTile(t))))):n=[];const i=this._updateRetainedTiles(n);if(iy(this._source.type)&&0!==n.length){const t={},e={},r=Object.keys(i);for(const n of r){const r=i[n],s=this._tiles[n];if(!s||s.fadeEndTime&&s.fadeEndTime<=Nt.now())continue;const a=this.findLoadedParent(r,Math.max(r.overscaledZ-ry.maxOverzooming,this._source.minzoom));a&&(this._addTile(a.tileID),t[a.tileID.key]=a.tileID),e[n]=r;}const s=n[n.length-1].overscaledZ;for(const t in this._tiles){const r=this._tiles[t];if(i[t]||!r.hasData())continue;let n=r.tileID;for(;n.overscaledZ>s;){n=n.scaledTo(n.overscaledZ-1);const s=this._tiles[n.key];if(s&&s.hasData()&&e[n.key]){i[t]=r.tileID;break}}}for(const e in t)i[e]||(this._coveredTiles[e]=!0,i[e]=t[e]);}for(const t in i)this._tiles[t].clearFadeHold();const s=function(t,e){const r=[];for(const n in t)n in e||r.push(n);return r}(this._tiles,i);for(const t of s){const e=this._tiles[t];e.hasSymbolBuckets&&!e.holdingForFade()?e.setHoldDuration(this.map._fadeDuration):e.hasSymbolBuckets&&!e.symbolFadeFinished()||this._removeTile(+t);}this._updateLoadedParentTileCache(),this._onlySymbols&&this._source.afterUpdate&&this._source.afterUpdate();}releaseSymbolFadeTiles(){for(const t in this._tiles)this._tiles[t].holdingForFade()&&this._removeTile(+t);}_updateRetainedTiles(t){const e={};if(0===t.length)return e;const r={},n=t.reduce(((t,e)=>Math.min(t,e.overscaledZ)),1/0),i=t[0].overscaledZ,s=Math.max(i-ry.maxOverzooming,this._source.minzoom),a=Math.max(i+ry.maxUnderzooming,this._source.minzoom),o={};for(const r of t){const t=this._addTile(r);e[r.key]=r,t.hasData()||n=this._source.maxzoom){const t=n.children(this._source.maxzoom)[0],r=this.getTile(t);if(r&&r.hasData()){e[t.key]=t;continue}}else {const t=n.children(this._source.maxzoom);if(e[t[0].key]&&e[t[1].key]&&e[t[2].key]&&e[t[3].key])continue}let i=t.wasRequested();for(let a=n.overscaledZ-1;a>=s;--a){const s=n.scaledTo(a);if(r[s.key])break;if(r[s.key]=!0,t=this.getTile(s),!t&&i&&(t=this._addTile(s)),t&&(e[s.key]=s,i=t.wasRequested(),t.hasData()))break}}return e}_updateLoadedParentTileCache(){this._loadedParentTiles={};for(const t in this._tiles){const e=[];let r,n=this._tiles[t].tileID;for(;n.overscaledZ>0;){if(n.key in this._loadedParentTiles){r=this._loadedParentTiles[n.key];break}e.push(n.key);const t=n.scaledTo(n.overscaledZ-1);if(r=this._getLoadedTile(t),r)break;n=t;}for(const t of e)this._loadedParentTiles[t]=r;}}_addTile(t){let e=this._tiles[t.key];if(e)return e;e=this._cache.getAndRemove(t),e&&(this._setTileReloadTimer(t.key,e),e.tileID=t,this._state.initializeTileState(e,this.map?this.map.painter:null),this._cacheTimers[t.key]&&(clearTimeout(this._cacheTimers[t.key]),delete this._cacheTimers[t.key],this._setTileReloadTimer(t.key,e)));const r=Boolean(e);if(!r){const r=this.map?this.map.painter:null;e=new Ld(t,this._source.tileSize*t.overscaleFactor(),this.transform.tileZoom,r,this._isRaster),this._loadTile(e,this._tileLoaded.bind(this,e,t.key,e.state));}return e?(e.uses++,this._tiles[t.key]=e,r||this._source.fire(new Zt(\"dataloading\",{tile:e,coord:e.tileID,dataType:\"source\"})),e):null}_setTileReloadTimer(t,e){t in this._timers&&(clearTimeout(this._timers[t]),delete this._timers[t]);const r=e.getExpiryTimeout();r&&(this._timers[t]=setTimeout((()=>{this._reloadTile(t,\"expired\"),delete this._timers[t];}),r));}_removeTile(t){const e=this._tiles[t];e&&(e.uses--,delete this._tiles[t],this._timers[t]&&(clearTimeout(this._timers[t]),delete this._timers[t]),e.uses>0||(e.hasData()&&\"reloading\"!==e.state?this._cache.add(e.tileID,e,e.getExpiryTimeout()):(e.aborted=!0,this._abortTile(e),this._unloadTile(e))));}clearTiles(){this._shouldReloadOnResume=!1,this._paused=!1;for(const t in this._tiles)this._removeTile(+t);this._source._clear&&this._source._clear(),this._cache.reset(),this.map&&this.usedForTerrain&&this.map.painter.terrain&&this.map.painter.terrain.resetTileLookupCache(this.id);}tilesIn(t,e,r){const n=[],i=this.transform;if(!i)return n;const s=\"globe\"===i.projection.name,a=Bo(i.center.lng);for(const o in this._tiles){const l=this._tiles[o];if(r&&l.clearQueryDebugViz(),l.holdingForFade())continue;let u;if(s){const t=l.tileID.canonical;if(0===t.z){const e=[Math.abs(S(a,...sy(t,-1))-a),Math.abs(S(a,...sy(t,1))-a)];u=[0,2*e.indexOf(Math.min(...e))-1];}else {const e=[Math.abs(S(a,...sy(t,-1))-a),Math.abs(S(a,...sy(t,0))-a),Math.abs(S(a,...sy(t,1))-a)];u=[e.indexOf(Math.min(...e))-1];}}else u=[0];for(const r of u){const s=t.containsTile(l,i,e,r);s&&n.push(s);}}return n}getVisibleCoordinates(t){const e=this.getRenderableIds(t).map((t=>this._tiles[t].tileID));for(const t of e)t.projMatrix=this.transform.calculateProjMatrix(t.toUnwrapped());return e}hasTransition(){if(this._source.hasTransition())return !0;if(iy(this._source.type))for(const t in this._tiles){const e=this._tiles[t];if(void 0!==e.fadeEndTime&&e.fadeEndTime>=Nt.now())return !0}return !1}setFeatureState(t,e,r){this._state.updateState(t=t||\"_geojsonTileLayer\",e,r);}removeFeatureState(t,e,r){this._state.removeFeatureState(t=t||\"_geojsonTileLayer\",e,r);}getFeatureState(t,e){return this._state.getState(t=t||\"_geojsonTileLayer\",e)}setDependencies(t,e,r){const n=this._tiles[t];n&&n.setDependencies(e,r);}reloadTilesForDependencies(t,e){for(const r in this._tiles)this._tiles[r].hasDependency(t,e)&&this._reloadTile(+r,\"reloading\");this._cache.filter((r=>!r.hasDependency(t,e)));}_preloadTiles(t,e){const r=new Map,n=Array.isArray(t)?t:[t],i=this.map.painter.terrain,s=this.usedForTerrain&&i?i.getScaledDemTileSize():this._source.tileSize;for(const t of n){const e=t.coveringTiles({tileSize:s,minzoom:this._source.minzoom,maxzoom:this._source.maxzoom,roundZoom:this._source.roundZoom&&!this.usedForTerrain,reparseOverscaled:this._source.reparseOverscaled,isTerrainDEM:this.usedForTerrain});for(const t of e)r.set(t.key,t);this.usedForTerrain&&t.updateElevation(!1);}M(Array.from(r.values()),((t,e)=>{const r=new Ld(t,this._source.tileSize*t.overscaleFactor(),this.transform.tileZoom,this.map.painter,this._isRaster);this._loadTile(r,(t=>{\"raster-dem\"===this._source.type&&r.dem&&this._backfillDEM(r),e(t,r);}));}),e);}}function ny(t,e){const r=Math.abs(2*t.wrap)-+(t.wrap<0),n=Math.abs(2*e.wrap)-+(e.wrap<0);return t.overscaledZ-e.overscaledZ||n-r||e.canonical.y-t.canonical.y||e.canonical.x-t.canonical.x}function iy(t){return \"raster\"===t||\"image\"===t||\"video\"===t||\"custom\"===t}function sy(t,e){const r=1<=0&&n[3]>=0&&o.insert(a,n[0],n[1],n[2],n[3]);}}loadVTLayers(){if(!this.vtLayers){this.vtLayers=new Ac(new kh(this.rawTileData)).layers,this.sourceLayerCoder=new Sd(this.vtLayers?Object.keys(this.vtLayers).sort():[\"_geojsonTileLayer\"]),this.vtFeatures={};for(const t in this.vtLayers)this.vtFeatures[t]=[];}return this.vtLayers}query(t,e,r,n){this.loadVTLayers();const i=t.params||{},s=ai(i.filter),a=t.tileResult,o=t.transform,l=a.bufferedTilespaceBounds,u=this.grid.query(l.min.x,l.min.y,l.max.x,l.max.y,((t,e,r,n)=>ol(a.bufferedTilespaceGeometry,t,e,r,n)));u.sort(uy);let c=null;o.elevation&&u.length>0&&(c=ay.create(o.elevation,this.tileID));const h={};let p;for(let o=0;o(d||(d=Xo(e,this.tileID.canonical,t.tileTransform)),r.queryIntersectsFeature(a,e,n,d,this.z,t.transform,t.pixelPosMatrix,c,i))));}return h}loadMatchingFeature(t,e,r,n,i,s,a,o,l){const{featureIndex:u,bucketIndex:c,sourceLayerIndex:h,layoutVertexArrayOffset:p}=e,f=this.bucketLayerIDs[c];if(n&&!function(t,e){for(let r=0;r=0)return !0;return !1}(n,f))return;const d=this.sourceLayerCoder.decode(h),y=this.vtLayers[d].feature(u);if(r.needGeometry){const t=Zo(y,!0);if(!r.filter(new Us(this.tileID.overscaledZ),t,this.tileID.canonical))return}else if(!r.filter(new Us(this.tileID.overscaledZ),y))return;const m=this.getId(y,d);for(let e=0;e{const a=e instanceof Ks?e.get(s):null;return a&&a.evaluate?a.evaluate(r,n,i):a}))}function uy(t,e){return e-t}Oi(oy,\"FeatureIndex\",{omit:[\"rawTileData\",\"sourceLayerCoder\"]});class cy{constructor(t,e){this.width=t,this.height=e,this.nextRow=0,this.image=new mu({width:t,height:e}),this.positions={},this.uploaded=!1;}getDash(t,e){const r=this.getKey(t,e);return this.positions[r]}trim(){const t=this.width,e=this.height=P(this.nextRow);this.image.resize({width:t,height:e});}getKey(t,e){return t.join(\",\")+e}getDashRanges(t,e,r){const n=[];let i=t.length%2==1?-t[t.length-1]*r:0,s=t[0]*r,a=!0;n.push({left:i,right:s,isDash:a,zeroLength:0===t[0]});let o=t[0];for(let e=1;e1&&(a=t[++s]);const l=Math.abs(o-a.left),u=Math.abs(o-a.right),c=Math.min(l,u);let h;const p=e/r*(n+1);if(a.isDash){const t=n-Math.abs(p);h=Math.sqrt(c*c+t*t);}else h=n-Math.sqrt(c*c+p*p);this.image.data[i+o]=Math.max(0,Math.min(255,h+128));}}}addRegularDash(t,e){for(let e=t.length-1;e>=0;--e){const r=t[e],n=t[e+1];r.zeroLength?t.splice(e,1):n&&n.isDash===r.isDash&&(n.left=r.left,t.splice(e,1));}const r=t[0],n=t[t.length-1];r.isDash===n.isDash&&(r.left=n.left-this.width,n.right=r.right+this.width);const i=this.width*this.nextRow;let s=0,a=t[s];for(let r=0;r1&&(a=t[++s]);const n=Math.abs(r-a.left),o=Math.abs(r-a.right),l=Math.min(n,o);this.image.data[i+r]=Math.max(0,Math.min(255,(a.isDash?l:-l)+e+128));}}addDash(t,e){const r=this.getKey(t,e);if(this.positions[r])return this.positions[r];const n=\"round\"===e,i=n?7:0,s=2*i+1;if(this.nextRow+s>this.height)return $(\"LineAtlas out of space\"),null;0===t.length&&t.push(1);let a=0;for(let e=0;e=e.maxzoom||\"none\"!==e.visibility&&(fy(t,this.zoom,r),(o[e.id]=e.createBucket({index:a.bucketLayerIDs.length,layers:t,zoom:this.zoom,canonical:this.canonical,pixelRatio:this.pixelRatio,overscaling:this.overscaling,collisionBoxArray:this.collisionBoxArray,sourceLayerIndex:h,sourceID:this.source,enableTerrain:this.enableTerrain,projection:this.projection.spec,availableImages:r})).populate(p,u,this.tileID.canonical,this.tileTransform),a.bucketLayerIDs.push(t.map((t=>t.id))));}}let h,p,f,d;l.trim();const y={type:\"maybePrepare\",isSymbolTile:this.isSymbolTile,zoom:this.zoom},m=F(u.glyphDependencies,(t=>Object.keys(t).map(Number)));Object.keys(m).length?n.send(\"getGlyphs\",{uid:this.uid,stacks:m},((t,e)=>{h||(h=t,p=e,v.call(this));}),void 0,!1,y):p={};const g=Object.keys(u.iconDependencies);g.length?n.send(\"getImages\",{icons:g,source:this.source,tileID:this.tileID,type:\"icons\"},((t,e)=>{h||(h=t,f=e,v.call(this));}),void 0,!1,y):f={};const x=Object.keys(u.patternDependencies);function v(){if(h)return i(h);if(p&&f&&d){const t=new hy(p),e=new Jh(f,d);for(const n in o){const i=o[n];i instanceof cd?(fy(i.layers,this.zoom,r),Op(i,p,t.positions,f,e.iconPositions,this.showCollisionBoxes,r,this.tileID.canonical,this.tileZoom,this.projection)):i.hasPattern&&(i instanceof nh||i instanceof ic||i instanceof Ec)&&(fy(i.layers,this.zoom,r),i.addFeatures(u,this.tileID.canonical,e.patternPositions,r,this.tileTransform));}this.status=\"done\",i(null,{buckets:T(o).filter((t=>!t.isEmpty())),featureIndex:a,collisionBoxArray:this.collisionBoxArray,glyphAtlasImage:t.image,lineAtlas:l,imageAtlas:e,glyphMap:this.returnDependencies?p:null,iconMap:this.returnDependencies?f:null,glyphPositions:this.returnDependencies?t.positions:null});}}x.length?n.send(\"getImages\",{icons:x,source:this.source,tileID:this.tileID,type:\"patterns\"},((t,e)=>{h||(h=t,d=e,v.call(this));}),void 0,!1,y):d={},v.call(this);}}function fy(t,e,r){const n=new Us(e);for(const e of t)e.recalculate(n,r);}class dy{constructor(t){this.entries={},this.scheduler=t;}request(t,e,r,n){const i=this.entries[t]=this.entries[t]||{callbacks:[]};if(i.result){const[t,r]=i.result;return this.scheduler?this.scheduler.add((()=>{n(t,r);}),e):n(t,r),()=>{}}return i.callbacks.push(n),i.cancel||(i.cancel=r(((r,n)=>{i.result=[r,n];for(const t of i.callbacks)this.scheduler?this.scheduler.add((()=>{t(r,n);}),e):t(r,n);setTimeout((()=>delete this.entries[t]),3e3);}))),()=>{i.result||(i.callbacks=i.callbacks.filter((t=>t!==n)),i.callbacks.length||(i.cancel(),delete this.entries[t]));}}}function yy(t,e,r){const n=JSON.stringify(t.request);return t.data&&(this.deduped.entries[n]={result:[null,t.data]}),this.deduped.request(n,{type:\"parseTile\",isSymbolTile:t.isSymbolTile,zoom:t.tileZoom},(e=>{const n=ut(t.request,((t,n,i,s)=>{t?e(t):n&&e(null,{vectorTile:r?void 0:new Ac(new kh(n)),rawData:n,cacheControl:i,expires:s});}));return ()=>{n.cancel(),e();}}),e)}t.ARRAY_TYPE=ml,t.AUTH_ERR_MSG=yt,t.Aabb=au,t.Actor=class{constructor(t,r,n){this.target=t,this.parent=r,this.mapId=n,this.callbacks={},this.cancelCallbacks={},V([\"receive\"],this),this.target.addEventListener(\"message\",this.receive,!1),this.globalScope=N()?t:e,this.scheduler=new Ad;}send(t,e,r,n,i=!1,s){const a=Math.round(1e18*Math.random()).toString(36).substring(0,10);r&&(r.metadata=s,this.callbacks[a]=r);const o=Z(this.globalScope)?void 0:[];return this.target.postMessage({id:a,type:t,hasCallback:!!r,targetMapId:n,mustQueue:i,sourceMapId:this.mapId,data:Gi(e,o)},o),{cancel:()=>{r&&delete this.callbacks[a],this.target.postMessage({id:a,type:\"\",targetMapId:n,sourceMapId:this.mapId});}}}receive(t){const e=t.data,r=e.id;if(r&&(!e.targetMapId||this.mapId===e.targetMapId))if(\"\"===e.type){const t=this.cancelCallbacks[r];delete this.cancelCallbacks[r],t&&t.cancel();}else if(e.mustQueue||N()){const t=this.callbacks[r];this.cancelCallbacks[r]=this.scheduler.add((()=>this.processTask(r,e)),t&&t.metadata||{type:\"message\"});}else this.processTask(r,e);}processTask(t,e){if(\"\"===e.type){const r=this.callbacks[t];delete this.callbacks[t],r&&(e.error?r(Xi(e.error)):r(null,Xi(e.data)));}else {const r=Z(this.globalScope)?void 0:[],n=e.hasCallback?(e,n)=>{delete this.cancelCallbacks[t],this.target.postMessage({id:t,type:\"\",sourceMapId:this.mapId,error:e?Gi(e):null,data:Gi(n,r)},r);}:t=>{},i=Xi(e.data);if(this.parent[e.type])this.parent[e.type](e.sourceMapId,i,n);else if(this.parent.getWorkerSource){const t=e.type.split(\".\");this.parent.getWorkerSource(e.sourceMapId,t[0],i.source)[t[1]](i,n);}else n(new Error(`Could not find function ${e.type}`));}}remove(){this.scheduler.remove(),this.target.removeEventListener(\"message\",this.receive,!1);}},t.CanonicalTileID=qc,t.Color=Me,t.ColorMode=Jd,t.CullFaceMode=ey,t.DEMData=Zd,t.DataConstantProperty=Ys,t.DedupedRequest=dy,t.DepthMode=Yd,t.EXTENT=So,t.Elevation=class{isDataAvailableAtPoint(t){const e=this._source();if(this.isUsingMockSource()||!e||t.y<0||t.y>1)return !1;const r=e.getSource().maxzoom,n=1<1)return e;const i=n.getSource().maxzoom,s=1<{const s=this.getAtTileOffset(t,i.x,i.y),a=n.upVector(t.canonical,i.x,i.y);return Rl(a,a,s*n.upVectorScale(t.canonical,e,r).metersToTile),a}}getForTilePoints(t,e,r,n){if(this.isUsingMockSource())return !1;const i=ay.create(this,t,n);return !!i&&(e.forEach((t=>{t[2]=this.exaggeration()*i.getElevationAt(t[0],t[1],r);})),!0)}getMinMaxForTile(t){if(this.isUsingMockSource())return null;const e=this.findDEMTileFor(t);if(!e||!e.dem)return null;const r=e.dem.tree,n=e.tileID,i=1<this._skuTokenExpiresAt}transformRequest(t,e){return this._transformRequestFn&&this._transformRequestFn(t,e)||{url:t}}normalizeStyleURL(t,e){if(!mt(t))return t;const r=_t(t);return r.path=`/styles/v1${r.path}`,this._makeAPIURL(r,this._customAccessToken||e)}normalizeGlyphsURL(t,e){if(!mt(t))return t;const r=_t(t);return r.path=`/fonts/v1${r.path}`,this._makeAPIURL(r,this._customAccessToken||e)}normalizeSourceURL(t,e,r,n){if(!mt(t))return t;const i=_t(t);return i.path=`/v4/${i.authority}.json`,i.params.push(\"secure\"),r&&i.params.push(`language=${r}`),n&&i.params.push(`worldview=${n}`),this._makeAPIURL(i,this._customAccessToken||e)}normalizeSpriteURL(t,e,r,n){const i=_t(t);return mt(t)?(i.path=`/styles/v1${i.path}/sprite${e}${r}`,this._makeAPIURL(i,this._customAccessToken||n)):(i.path+=`${e}${r}`,At(i))}normalizeTileURL(t,e,r){if(this._isSkuTokenExpired()&&this._createSkuToken(),t&&!mt(t))return t;const n=_t(t);n.path=n.path.replace(/(\\.(png|jpg)\\d*)(?=$)/,`${e||r&&\"raster\"!==n.authority&&512===r?\"@2x\":\"\"}${s.supported?\".webp\":\"$1\"}`),\"raster\"===n.authority?n.path=`/${i.RASTER_URL_PREFIX}${n.path}`:(n.path=n.path.replace(/^.+\\/v4\\//,\"/\"),n.path=`/${i.TILE_URL_VERSION}${n.path}`);const a=this._customAccessToken||function(t){for(const e of t){const t=e.match(/^access_token=(.*)$/);if(t)return t[1]}return null}(n.params)||i.ACCESS_TOKEN;return i.REQUIRE_ACCESS_TOKEN&&a&&this._skuToken&&n.params.push(`sku=${this._skuToken}`),this._makeAPIURL(n,a)}canonicalizeTileURL(t,e){const r=_t(t);if(!r.path.match(/^(\\/v4\\/|\\/raster\\/v1\\/)/)||!r.path.match(/\\.[\\w]+$/))return t;let n=\"mapbox://\";r.path.match(/^\\/raster\\/v1\\//)?n+=`raster/${r.path.replace(`/${i.RASTER_URL_PREFIX}/`,\"\")}`:n+=`tiles/${r.path.replace(`/${i.TILE_URL_VERSION}/`,\"\")}`;let s=r.params;return e&&(s=s.filter((t=>!t.match(/^access_token=/)))),s.length&&(n+=`?${s.join(\"&\")}`),n}canonicalizeTileset(t,e){const r=!!e&&mt(e),n=[];for(const e of t.tiles||[])gt(e)?n.push(this.canonicalizeTileURL(e,r)):n.push(e);return n}_makeAPIURL(t,e){const r=\"See https://docs.mapbox.com/api/overview/#access-tokens-and-token-scopes\",n=_t(i.API_URL);if(t.protocol=n.protocol,t.authority=n.authority,\"http\"===t.protocol){const e=t.params.indexOf(\"secure\");e>=0&&t.params.splice(e,1);}if(\"/\"!==n.path&&(t.path=`${n.path}${t.path}`),!i.REQUIRE_ACCESS_TOKEN)return At(t);if(e=e||i.ACCESS_TOKEN,!this._silenceAuthErrors){if(!e)throw new Error(`An API access token is required to use Mapbox GL. ${r}`);if(\"s\"===e[0])throw new Error(`Use a public access token (pk.*) with Mapbox GL, not a secret access token (sk.*). ${r}`)}return t.params=t.params.filter((t=>-1===t.indexOf(\"access_token\"))),t.params.push(`access_token=${e||\"\"}`),At(t)}},t.ResourceType=st,t.SegmentVector=Ao,t.SourceCache=ry,t.StencilMode=Wd,t.StructArrayLayout1ui2=Ta,t.StructArrayLayout2f1f2i16=xa,t.StructArrayLayout2i4=sa,t.StructArrayLayout2ui4=Ma,t.StructArrayLayout3f12=ba,t.StructArrayLayout3ui6=wa,t.StructArrayLayout4i8=oa,t.StructArrayLayout5f20=ka,t.Texture=wd,t.Tile=Ld,t.Transitionable=qs,t.Uniform1f=Qa,t.Uniform1i=class extends Ja{constructor(t){super(t),this.current=0;}set(t,e,r){this.fetchUniformLocation(t,e)&&this.current!==r&&(this.current=r,this.gl.uniform1i(this.location,r));}},t.Uniform2f=class extends Ja{constructor(t){super(t),this.current=[0,0];}set(t,e,r){this.fetchUniformLocation(t,e)&&(r[0]===this.current[0]&&r[1]===this.current[1]||(this.current=r,this.gl.uniform2f(this.location,r[0],r[1])));}},t.Uniform3f=class extends Ja{constructor(t){super(t),this.current=[0,0,0];}set(t,e,r){this.fetchUniformLocation(t,e)&&(r[0]===this.current[0]&&r[1]===this.current[1]&&r[2]===this.current[2]||(this.current=r,this.gl.uniform3f(this.location,r[0],r[1],r[2])));}},t.Uniform4f=to,t.UniformColor=eo,t.UniformMatrix2f=class extends Ja{constructor(t){super(t),this.current=io;}set(t,e,r){if(this.fetchUniformLocation(t,e))for(let t=0;t<4;t++)if(r[t]!==this.current[t]){this.current=r,this.gl.uniformMatrix2fv(this.location,!1,r);break}}},t.UniformMatrix3f=class extends Ja{constructor(t){super(t),this.current=no;}set(t,e,r){if(this.fetchUniformLocation(t,e))for(let t=0;t<9;t++)if(r[t]!==this.current[t]){this.current=r,this.gl.uniformMatrix3fv(this.location,!1,r);break}}},t.UniformMatrix4f=class extends Ja{constructor(t){super(t),this.current=ro;}set(t,e,r){if(this.fetchUniformLocation(t,e)){if(r[12]!==this.current[12]||r[0]!==this.current[0])return this.current=r,void this.gl.uniformMatrix4fv(this.location,!1,r);for(let t=1;t<16;t++)if(r[t]!==this.current[t]){this.current=r,this.gl.uniformMatrix4fv(this.location,!1,r);break}}}},t.UnwrappedTileID=Nc,t.ValidationError=Wn,t.VectorTileFeature=Sc,t.VectorTileWorkerSource=class extends Yt{constructor(t,e,r,n,i){super(),this.actor=t,this.layerIndex=e,this.availableImages=r,this.loadVectorData=i||yy,this.loading={},this.loaded={},this.deduped=new dy(t.scheduler),this.isSpriteLoaded=n,this.scheduler=t.scheduler;}loadTile(t,e){const r=t.uid,n=t&&t.request,i=n&&n.collectResourceTiming,s=this.loading[r]=new py(t);s.abort=this.loadVectorData(t,((a,o)=>{const l=!this.loading[r];if(delete this.loading[r],l||a||!o)return s.status=\"done\",l||(this.loaded[r]=s),e(a);const u=o.rawData,c={};o.expires&&(c.expires=o.expires),o.cacheControl&&(c.cacheControl=o.cacheControl),s.vectorTile=o.vectorTile||new Ac(new kh(u));const h=()=>{s.parse(s.vectorTile,this.layerIndex,this.availableImages,this.actor,((t,r)=>{if(t||!r)return e(t);const s={};if(i){const t=jt(n);t.length>0&&(s.resourceTiming=JSON.parse(JSON.stringify(t)));}e(null,z({rawTileData:u.slice(0)},r,c,s));}));};this.isSpriteLoaded?h():this.once(\"isSpriteLoaded\",(()=>{this.scheduler?this.scheduler.add(h,{type:\"parseTile\",isSymbolTile:t.isSymbolTile,zoom:t.tileZoom}):h();})),this.loaded=this.loaded||{},this.loaded[r]=s;}));}reloadTile(t,e){const r=this.loaded,n=t.uid,i=this;if(r&&r[n]){const s=r[n];s.showCollisionBoxes=t.showCollisionBoxes,s.enableTerrain=!!t.enableTerrain,s.projection=t.projection,s.tileTransform=Df(t.tileID.canonical,t.projection);const a=(t,r)=>{const n=s.reloadCallback;n&&(delete s.reloadCallback,s.parse(s.vectorTile,i.layerIndex,this.availableImages,i.actor,n)),e(t,r);};\"parsing\"===s.status?s.reloadCallback=a:\"done\"===s.status&&(s.vectorTile?s.parse(s.vectorTile,this.layerIndex,this.availableImages,this.actor,a):a());}}abortTile(t,e){const r=t.uid,n=this.loading[r];n&&(n.abort&&n.abort(),delete this.loading[r]),e();}removeTile(t,e){const r=this.loaded,n=t.uid;r&&r[n]&&delete r[n],e();}},t.WritingMode=Qh,t.add=Pl,t.addDynamicAttributes=ad,t.adjoint=function(t,e){var r=e[0],n=e[1],i=e[2],s=e[3],a=e[4],o=e[5],l=e[6],u=e[7],c=e[8];return t[0]=a*c-o*u,t[1]=i*u-n*c,t[2]=n*o-i*a,t[3]=o*l-s*c,t[4]=r*c-i*l,t[5]=i*s-r*o,t[6]=s*u-a*l,t[7]=n*l-r*u,t[8]=r*a-n*s,t},t.asyncAll=M,t.bezier=_,t.bindAll=V,t.boundsAttributes=Dd,t.bufferConvexPolygon=function(t,e){const r=[];for(let n=0;ntt&&(t.getActor().send(\"enforceCacheSizeLimit\",Q),it=0);},t.calculateGlobeLabelMatrix=function(t,e){const{x:r,y:n}=t.point,i=If(r,n,t.worldSize/t._pixelsPerMercatorPixel,0,0);return wl(i,i,kf(pf(e)))},t.calculateGlobeMatrix=function(t){const{x:e,y:r}=t.point,{lng:n,lat:i}=t._center;return If(e,r,t.worldSize,n,i)},t.calculateGlobeMercatorMatrix=function(t){const e=t.pixelsPerMeter,r=e/Co(1,t.center.lat),n=vl(new Float64Array(16));return _l(n,n,[t.point.x,t.point.y,0]),Al(n,n,[r,r,e]),Float32Array.from(n)},t.circumferenceAtLatitude=zo,t.clamp=S,t.clearTileCache=function(t){if(!et())return;const r=e.caches.delete(H);t&&r.catch(t).then((()=>t()));},t.clipLine=_p,t.clone=function(t){var e=new ml(16);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},t.clone$1=j,t.collisionCircleLayout=dh,t.config=i,t.conjugate=function(t,e){return t[0]=-e[0],t[1]=-e[1],t[2]=-e[2],t[3]=e[3],t},t.create=function(){var t=new ml(16);return ml!=Float32Array&&(t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[6]=0,t[7]=0,t[8]=0,t[9]=0,t[11]=0,t[12]=0,t[13]=0,t[14]=0),t[0]=1,t[5]=1,t[10]=1,t[15]=1,t},t.create$1=gl,t.createExpression=Gn,t.createLayout=na,t.createStyleLayer=function(t){return \"custom\"===t.type?new gd(t):new bd[t.type](t)},t.cross=Ol,t.degToRad=x,t.distance=function(t,e){return Math.hypot(e[0]-t[0],e[1]-t[1],e[2]-t[2])},t.div=function(t,e,r){return t[0]=e[0]/r[0],t[1]=e[1]/r[1],t[2]=e[2]/r[2],t},t.dot=$l,t.earthRadius=Io,t.ease=A,t.easeCubicInOut=w,t.ecefToLatLng=function([t,e,r]){const n=Math.hypot(t,e,r),i=Math.atan2(t,r),s=.5*Math.PI-Math.acos(-e/n);return new Mo(v(i),v(s))},t.emitValidationErrors=Ri,t.endsWith=L,t.enforceCacheSizeLimit=function(t){rt(),W&&W.then((e=>{e.keys().then((r=>{for(let n=0;ns&&(n+=(t[i]-s)*(t[i]-s)),e[i]0){const t=180/n;xl(f,f,[t/u+1,0,0,0,t/c+1,0,-.5*t/h,.5*t/p,1]);}return f[2]=l,f[5]=t.x,f[8]=t.y,f},t.getImage=dt,t.getJSON=function(t,e){return lt(z(t,{type:\"json\"}),e)},t.getLatitudinalLod=function(t){const e=80.051129;t=S(t,-80.051129,e)/e*90;const r=Math.pow(Math.abs(Math.sin(x(t))),3);return Math.round(r*(sf.length-1))},t.getMapSessionAPI=Pt,t.getPerformanceMeasurement=jt,t.getProjection=ed,t.getRTLTextPluginStatus=Fs,t.getReferrer=ot,t.getTilePoint=function(t,{x:e,y:r},n=0){return new d(((e-n)*t.scale-t.x)*So,(r*t.scale-t.y)*So)},t.getTileVec3=function(t,e,r=0){return Cl(((e.x-r)*t.scale-t.x)*So,(e.y*t.scale-t.y)*So,Vo(e.z,e.y))},t.getVideo=function(t,r){const n=e.document.createElement(\"video\");n.muted=!0,n.onloadstart=function(){r(null,n);};for(let r=0;r{}}},t.globeCenterToScreenPoint=function(t){const e=[0,0,0],r=vl(new Float64Array(16));return wl(r,t.pixelMatrix,t.globeMatrix),ql(e,e,r),new d(e[0],e[1])},t.globeDenormalizeECEF=kf,t.globeECEFOrigin=function(t,e){const r=[0,0,0];return ql(r,r,Sf(pf(e.canonical))),ql(r,r,t),r},t.globeNormalizeECEF=Sf,t.globePixelsToTileUnits=function(t,e){return So/(512*Math.pow(2,t))*_f(pf(e))},t.globePoleMatrixForTile=function(t,e,r){const n=vl(new Float64Array(16)),i=(e/(1<0;return 0===n&&!i&&!a&&s},t.identity=vl,t.identity$1=Ql,t.invert=bl,t.isFullscreen=function(){return !!e.document.fullscreenElement||!!e.document.webkitFullscreenElement},t.isLngLatBehindGlobe=zf,t.isMapAuthenticated=function(t){return Dt.has(t)},t.isMapboxURL=mt,t.isSafariWithAntialiasingBug=function(t){const e=t.navigator?t.navigator.userAgent:null;return !!Z(t)&&e&&(e.match(\"Version/15.4\")||e.match(\"Version/15.5\")||e.match(/CPU (OS|iPhone OS) (15_4|15_5) like Mac OS X/))},t.latFromMercatorY=Do,t.latLngToECEF=bf,t.len=Kl,t.length=El,t.length$1=function(t){return Math.hypot(t[0],t[1],t[2],t[3])},t.lngFromMercatorX=Po,t.loadVectorTile=yy,t.makeRequest=lt,t.mapValue=function(t,e,r,n,i){return S((t-e)/(r-e)*(i-n)+n,n,i)},t.mercatorScale=Fo,t.mercatorXfromLng=Bo,t.mercatorYfromLat=Eo,t.mercatorZfromAltitude=Co,t.mul=Tl,t.mul$1=Zl,t.multiply=wl,t.multiply$1=xl,t.multiply$2=Vl,t.nextPowerOfTwo=P,t.normalize=Ul,t.normalize$1=ru,t.normalize$2=Hl,t.number=Mr,t.ortho=function(t,e,r,n,i,s,a){var o=1/(e-r),l=1/(n-i),u=1/(s-a);return t[0]=-2*o,t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=-2*l,t[6]=0,t[7]=0,t[8]=0,t[9]=0,t[10]=2*u,t[11]=0,t[12]=(e+r)*o,t[13]=(i+n)*l,t[14]=(a+s)*u,t[15]=1,t},t.pbf=kh,t.perspective=function(t,e,r,n,i){var s,a=1/Math.tan(e/2);return t[0]=a/r,t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=a,t[6]=0,t[7]=0,t[8]=0,t[9]=0,t[11]=-1,t[12]=0,t[13]=0,t[15]=0,null!=i&&i!==1/0?(t[10]=(i+n)*(s=1/(n-i)),t[14]=2*i*n*s):(t[10]=-1,t[14]=-2*n),t},t.pick=function(t,e){const r={};for(let n=0;n0&&r[0]<=t.width&&r[1]>0&&r[1]<=t.height&&!zf(t,new Mo(t.center.lat,90)),n[0]>0&&n[0]<=t.width&&n[1]>0&&n[1]<=t.height&&!zf(t,new Mo(t.center.lat,-90))]},t.polygonContainsPoint=al,t.polygonIntersectsBox=ol,t.polygonIntersectsPolygon=Wo,t.polygonizeBounds=function(t,e,r=0,n=!0){const i=new d(r,r),s=t.sub(i),a=e.add(i),o=[s,new d(a.x,s.y),a,new d(s.x,a.y)];return n&&o.push(s.clone()),o},t.posAttributes=tf,t.postMapLoadEvent=zt,t.postPerformanceEvent=Et,t.postTurnstileEvent=Mt,t.potpack=Hh,t.prevPowerOfTwo=function(t){return t<=1?1:Math.pow(2,Math.floor(Math.log(t)/Math.LN2))},t.radToDeg=v,t.refProperties=[\"type\",\"source\",\"source-layer\",\"minzoom\",\"maxzoom\",\"filter\",\"layout\"],t.registerForPluginStateChange=function(t){return t({pluginStatus:Cs,pluginURL:Ps}),Ls.on(\"pluginStateChange\",t),t},t.removeAuthState=function(t){Dt.delete(t);},t.renderColorRamp=vu,t.resample=Uo,t.rotateX=Sl,t.rotateX$1=tu,t.rotateY=kl,t.rotateY$1=eu,t.rotateZ=function(t,e,r){var n=Math.sin(r),i=Math.cos(r),s=e[0],a=e[1],o=e[2],l=e[3],u=e[4],c=e[5],h=e[6],p=e[7];return e!==t&&(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[0]=s*i+u*n,t[1]=a*i+c*n,t[2]=o*i+h*n,t[3]=l*i+p*n,t[4]=u*i-s*n,t[5]=c*i-a*n,t[6]=h*i-o*n,t[7]=p*i-l*n,t},t.rotateZ$1=function(t,e,r){r*=.5;var n=e[0],i=e[1],s=e[2],a=e[3],o=Math.sin(r),l=Math.cos(r);return t[0]=n*l+i*o,t[1]=i*l-n*o,t[2]=s*l+a*o,t[3]=a*l-s*o,t},t.scale=Al,t.scale$1=Yl,t.scale$2=Rl,t.scaleAndAdd=jl,t.set=function(t,e,r,n){return t[0]=e,t[1]=r,t[2]=n,t},t.setCacheLimits=function(t,e){Q=t,tt=e;},t.setColumn=function(t,e,r){t[4*e+0]=r[0],t[4*e+1]=r[1],t[4*e+2]=r[2],t[4*e+3]=r[3];},t.setRTLTextPlugin=function(t,e,r=!1){if(Cs===Ts||Cs===zs||Cs===Bs)throw new Error(\"setRTLTextPlugin cannot be called multiple times.\");Ps=Nt.resolveURL(t),Cs=Ts,Es=e,Vs(),r||Rs();},t.smoothstep=k,t.spec=Ht,t.squaredLength=function(t){var e=t[0],r=t[1],n=t[2];return e*e+r*r+n*n},t.storeAuthState=function(t,e){e?Dt.add(t):Dt.delete(t);},t.sub=Xl,t.subtract=Dl,t.symbolSize=bh,t.tileAABB=function(t,e,r,n,i,s,a,o,l){if(\"globe\"===l.name)return mf(t,e,new qc(r,n,i));const u=Df({z:r,x:n,y:i},l);return new au([(s+u.x/u.scale)*e,e*(u.y/u.scale),a],[(s+u.x2/u.scale)*e,e*(u.y2/u.scale),o])},t.tileCornersToBounds=gf,t.tileTransform=Df,t.transformMat3=function(t,e,r){var n=e[0],i=e[1],s=e[2];return t[0]=n*r[0]+i*r[3]+s*r[6],t[1]=n*r[1]+i*r[4]+s*r[7],t[2]=n*r[2]+i*r[5]+s*r[8],t},t.transformMat4=ql,t.transformMat4$1=Wl,t.transformQuat=Nl,t.transitionTileAABBinECEF=df,t.translate=_l,t.transpose=function(t,e){if(t===e){var r=e[1],n=e[2],i=e[5];t[1]=e[3],t[2]=e[6],t[3]=r,t[5]=e[7],t[6]=n,t[7]=i;}else t[0]=e[0],t[1]=e[3],t[2]=e[6],t[3]=e[1],t[4]=e[4],t[5]=e[7],t[6]=e[2],t[7]=e[5],t[8]=e[8];return t},t.triggerPluginCompletionEvent=Ds,t.uniqueId=E,t.updateGlobeVertexNormal=function(t,e,r,n,i){const s=5*e+2;t.float32[s+0]=r,t.float32[s+1]=n,t.float32[s+2]=i;},t.validateCustomStyleLayer=function(t){const e=[],r=t.id;return void 0===r&&e.push({message:`layers.${r}: missing required property \"id\"`}),void 0===t.render&&e.push({message:`layers.${r}: missing required method \"render\"`}),t.renderingMode&&\"2d\"!==t.renderingMode&&\"3d\"!==t.renderingMode&&e.push({message:`layers.${r}: property \"renderingMode\" must be either \"2d\" or \"3d\"`}),e},t.validateFilter=t=>Fi(xi(t)),t.validateFog=t=>Fi(Bi(t)),t.validateLayer=t=>Fi(Ai(t)),t.validateLight=t=>Fi(Ti(t)),t.validateSource=t=>Fi(Ii(t)),t.validateStyle=Di,t.validateTerrain=t=>Fi(zi(t)),t.values=T,t.vectorTile=hc,t.version=r,t.warnOnce=$,t.window=e,t.wrap=I;}));\n\ndefine([\"./shared\"],(function(e){\"use strict\";function t(e){if(\"number\"==typeof e||\"boolean\"==typeof e||\"string\"==typeof e||null==e)return JSON.stringify(e);if(Array.isArray(e)){let r=\"[\";for(const o of e)r+=`${t(o)},`;return `${r}]`}let r=\"{\";for(const o of Object.keys(e).sort())r+=`${o}:${t(e[o])},`;return `${r}}`}function r(r){let o=\"\";for(const n of e.refProperties)o+=`/${t(r[n])}`;return o}class o{constructor(e){this.keyCache={},e&&this.replace(e);}replace(e){this._layerConfigs={},this._layers={},this.update(e,[]);}update(t,o){for(const r of t)this._layerConfigs[r.id]=r,(this._layers[r.id]=e.createStyleLayer(r)).compileFilter(),this.keyCache[r.id]&&delete this.keyCache[r.id];for(const e of o)delete this.keyCache[e],delete this._layerConfigs[e],delete this._layers[e];this.familiesBySource={};const n=function(e,t){const o={};for(let n=0;nthis._layers[e.id])),r=t[0];if(\"none\"===r.visibility)continue;const o=r.source||\"\";let n=this.familiesBySource[o];n||(n=this.familiesBySource[o]={});const i=r.sourceLayer||\"_geojsonTileLayer\";let s=n[i];s||(s=n[i]=[]),s.push(t);}}}class n{loadTile(t,r){const{uid:o,encoding:n,rawImageData:i,padding:s,buildQuadTree:a}=t,l=e.window.ImageBitmap&&i instanceof e.window.ImageBitmap?this.getImageData(i,s):i;r(null,new e.DEMData(o,l,n,s<1,a));}getImageData(e,t){this.offscreenCanvas&&this.offscreenCanvasContext||(this.offscreenCanvas=new OffscreenCanvas(e.width,e.height),this.offscreenCanvasContext=this.offscreenCanvas.getContext(\"2d\",{willReadFrequently:!0})),this.offscreenCanvas.width=e.width,this.offscreenCanvas.height=e.height,this.offscreenCanvasContext.drawImage(e,0,0,e.width,e.height);const r=this.offscreenCanvasContext.getImageData(-t,-t,e.width+2*t,e.height+2*t);return this.offscreenCanvasContext.clearRect(0,0,this.offscreenCanvas.width,this.offscreenCanvas.height),r}}var i=function e(t,r){var o,n=t&&t.type;if(\"FeatureCollection\"===n)for(o=0;o=Math.abs(a)?r-l+a:a-l+r,r=l;}r+o>=0!=!!t&&e.reverse();}const l=e.VectorTileFeature.prototype.toGeoJSON;class u{constructor(t){this._feature=t,this.extent=e.EXTENT,this.type=t.type,this.properties=t.tags,\"id\"in t&&!isNaN(t.id)&&(this.id=parseInt(t.id,10));}loadGeometry(){if(1===this._feature.type){const t=[];for(const r of this._feature.geometry)t.push([new e.pointGeometry(r[0],r[1])]);return t}{const t=[];for(const r of this._feature.geometry){const o=[];for(const t of r)o.push(new e.pointGeometry(t[0],t[1]));t.push(o);}return t}}toGeoJSON(e,t,r){return l.call(this,e,t,r)}}class h{constructor(t){this.layers={_geojsonTileLayer:this},this.name=\"_geojsonTileLayer\",this.extent=e.EXTENT,this.length=t.length,this._features=t;}feature(e){return new u(this._features[e])}}var c={exports:{}},f=e.pointGeometry,p=e.vectorTile.VectorTileFeature,g=d;function d(e,t){this.options=t||{},this.features=e,this.length=e.length;}function m(e,t){this.id=\"number\"==typeof e.id?e.id:void 0,this.type=e.type,this.rawGeometry=1===e.type?[e.geometry]:e.geometry,this.properties=e.tags,this.extent=t||4096;}d.prototype.feature=function(e){return new m(this.features[e],this.options.extent)},m.prototype.loadGeometry=function(){var e=this.rawGeometry;this.geometry=[];for(var t=0;t>31}function k(e,t){for(var r=e.loadGeometry(),o=e.type,n=0,i=0,s=r.length,a=0;a>1;_(e,t,s,o,n,i%2),T(e,t,r,o,s-1,i+1),T(e,t,r,s+1,n,i+1);}function _(e,t,r,o,n,i){for(;n>o;){if(n-o>600){const s=n-o+1,a=r-o+1,l=Math.log(s),u=.5*Math.exp(2*l/3),h=.5*Math.sqrt(l*u*(s-u)/s)*(a-s/2<0?-1:1);_(e,t,r,Math.max(o,Math.floor(r-a*u/s+h)),Math.min(n,Math.floor(r+(s-a)*u/s+h)),i);}const s=t[2*r+i];let a=o,l=n;for(L(e,t,o,r),t[2*n+i]>s&&L(e,t,o,n);as;)l--;}t[2*o+i]===s?L(e,t,o,l):(l++,L(e,t,l,n)),l<=r&&(o=l+1),r<=l&&(n=l-1);}}function L(e,t,r,o){C(e,r,o),C(t,2*r,2*o),C(t,2*r+1,2*o+1);}function C(e,t,r){const o=e[t];e[t]=e[r],e[r]=o;}function O(e,t,r,o){const n=e-r,i=t-o;return n*n+i*i}c.exports=x,c.exports.fromVectorTileJs=x,c.exports.fromGeojsonVt=function(e,t){t=t||{};var r={};for(var o in e)r[o]=new v(e[o].features,t),r[o].name=o,r[o].version=t.version,r[o].extent=t.extent;return x({layers:r})},c.exports.GeoJSONWrapper=v;const z=e=>e[0],E=e=>e[1];class F{constructor(e,t=z,r=E,o=64,n=Float64Array){this.nodeSize=o,this.points=e;const i=e.length<65536?Uint16Array:Uint32Array,s=this.ids=new i(e.length),a=this.coords=new n(2*e.length);for(let o=0;o=r&&u<=n&&h>=o&&h<=i&&l.push(e[s]);continue}const g=Math.floor((p+f)/2);u=t[2*g],h=t[2*g+1],u>=r&&u<=n&&h>=o&&h<=i&&l.push(e[g]);const d=(c+1)%2;(0===c?r<=u:o<=h)&&(a.push(p),a.push(g-1),a.push(d)),(0===c?n>=u:i>=h)&&(a.push(g+1),a.push(f),a.push(d));}return l}(this.ids,this.coords,e,t,r,o,this.nodeSize)}within(e,t,r){return function(e,t,r,o,n,i){const s=[0,e.length-1,0],a=[],l=n*n;for(;s.length;){const u=s.pop(),h=s.pop(),c=s.pop();if(h-c<=i){for(let n=c;n<=h;n++)O(t[2*n],t[2*n+1],r,o)<=l&&a.push(e[n]);continue}const f=Math.floor((c+h)/2),p=t[2*f],g=t[2*f+1];O(p,g,r,o)<=l&&a.push(e[f]);const d=(u+1)%2;(0===u?r-n<=p:o-n<=g)&&(s.push(c),s.push(f-1),s.push(d)),(0===u?r+n>=p:o+n>=g)&&(s.push(f+1),s.push(h),s.push(d));}return a}(this.ids,this.coords,e,t,r,this.nodeSize)}}const N={minZoom:0,maxZoom:16,minPoints:2,radius:40,extent:512,nodeSize:64,log:!1,generateId:!1,reduce:null,map:e=>e},j=Math.fround||(Z=new Float32Array(1),e=>(Z[0]=+e,Z[0]));var Z;class G{constructor(e){this.options=$(Object.create(N),e),this.trees=new Array(this.options.maxZoom+1);}load(e){const{log:t,minZoom:r,maxZoom:o,nodeSize:n}=this.options;t&&console.time(\"total time\");const i=`prepare ${e.length} points`;t&&console.time(i),this.points=e;let s=[];for(let t=0;t=r;e--){const r=+Date.now();s=this._cluster(s,e),this.trees[e]=new F(s,B,R,n,Float32Array),t&&console.log(\"z%d: %d clusters in %dms\",e,s.length,+Date.now()-r);}return t&&console.timeEnd(\"total time\"),this}getClusters(e,t){let r=((e[0]+180)%360+360)%360-180;const o=Math.max(-90,Math.min(90,e[1]));let n=180===e[2]?180:((e[2]+180)%360+360)%360-180;const i=Math.max(-90,Math.min(90,e[3]));if(e[2]-e[0]>=360)r=-180,n=180;else if(r>n){const e=this.getClusters([r,o,180,i],t),s=this.getClusters([-180,o,n,i],t);return e.concat(s)}const s=this.trees[this._limitZoom(t)],a=s.range(V(r),A(i),V(n),A(o)),l=[];for(const e of a){const t=s.points[e];l.push(t.numPoints?Y(t):this.points[t.index]);}return l}getChildren(e){const t=this._getOriginId(e),r=this._getOriginZoom(e),o=\"No cluster with the specified id.\",n=this.trees[r];if(!n)throw new Error(o);const i=n.points[t];if(!i)throw new Error(o);const s=this.options.radius/(this.options.extent*Math.pow(2,r-1)),a=n.within(i.x,i.y,s),l=[];for(const t of a){const r=n.points[t];r.parentId===e&&l.push(r.numPoints?Y(r):this.points[r.index]);}if(0===l.length)throw new Error(o);return l}getLeaves(e,t,r){const o=[];return this._appendLeaves(o,e,t=t||10,r=r||0,0),o}getTile(e,t,r){const o=this.trees[this._limitZoom(e)],n=Math.pow(2,e),{extent:i,radius:s}=this.options,a=s/i,l=(r-a)/n,u=(r+1+a)/n,h={features:[]};return this._addTileFeatures(o.range((t-a)/n,l,(t+1+a)/n,u),o.points,t,r,n,h),0===t&&this._addTileFeatures(o.range(1-a/n,l,1,u),o.points,n,r,n,h),t===n-1&&this._addTileFeatures(o.range(0,l,a/n,u),o.points,-1,r,n,h),h.features.length?h:null}getClusterExpansionZoom(e){let t=this._getOriginZoom(e)-1;for(;t<=this.options.maxZoom;){const r=this.getChildren(e);if(t++,1!==r.length)break;e=r[0].properties.cluster_id;}return t}_appendLeaves(e,t,r,o,n){const i=this.getChildren(t);for(const t of i){const i=t.properties;if(i&&i.cluster?n+i.point_count<=o?n+=i.point_count:n=this._appendLeaves(e,i.cluster_id,r,o,n):nt&&(c+=r.numPoints||1);}if(c>h&&c>=s){let e=n.x*h,s=n.y*h,a=i&&h>1?this._map(n,!0):null;const f=(o<<5)+(t+1)+this.points.length;for(const r of u){const o=l.points[r];if(o.zoom<=t)continue;o.zoom=t;const u=o.numPoints||1;e+=o.x*u,s+=o.y*u,o.parentId=f,i&&(a||(a=this._map(n,!0)),i(a,this._map(o)));}n.parentId=f,r.push(J(e/c,s/c,f,c,a));}else if(r.push(n),c>1)for(const e of u){const o=l.points[e];o.zoom<=t||(o.zoom=t,r.push(o));}}return r}_getOriginId(e){return e-this.points.length>>5}_getOriginZoom(e){return (e-this.points.length)%32}_map(e,t){if(e.numPoints)return t?$({},e.properties):e.properties;const r=this.points[e.index].properties,o=this.options.map(r);return t&&o===r?$({},o):o}}function J(e,t,r,o,n){return {x:j(e),y:j(t),zoom:1/0,id:r,parentId:-1,numPoints:o,properties:n}}function W(e,t){const[r,o]=e.geometry.coordinates;return {x:j(V(r)),y:j(A(o)),zoom:1/0,index:t,parentId:-1}}function Y(e){return {type:\"Feature\",id:e.id,properties:X(e),geometry:{type:\"Point\",coordinates:[(t=e.x,360*(t-.5)),D(e.y)]}};var t;}function X(e){const t=e.numPoints,r=t>=1e4?`${Math.round(t/1e3)}k`:t>=1e3?Math.round(t/100)/10+\"k\":t;return $($({},e.properties),{cluster:!0,cluster_id:e.id,point_count:t,point_count_abbreviated:r})}function V(e){return e/360+.5}function A(e){const t=Math.sin(e*Math.PI/180),r=.5-.25*Math.log((1+t)/(1-t))/Math.PI;return r<0?0:r>1?1:r}function D(e){const t=(180-360*e)*Math.PI/180;return 360*Math.atan(Math.exp(t))/Math.PI-90}function $(e,t){for(const r in t)e[r]=t[r];return e}function B(e){return e.x}function R(e){return e.y}function q(e,t,r,o){for(var n,i=o,s=r-t>>1,a=r-t,l=e[t],u=e[t+1],h=e[r],c=e[r+1],f=t+3;fi)n=f,i=p;else if(p===i){var g=Math.abs(f-s);go&&(n-t>3&&q(e,t,n,o),e[n+2]=i,r-n>3&&q(e,n,r,o));}function U(e,t,r,o,n,i){var s=n-r,a=i-o;if(0!==s||0!==a){var l=((e-r)*s+(t-o)*a)/(s*s+a*a);l>1?(r=n,o=i):l>0&&(r+=s*l,o+=a*l);}return (s=e-r)*s+(a=t-o)*a}function Q(e,t,r,o){var n={id:void 0===e?null:e,type:t,geometry:r,tags:o,minX:1/0,minY:1/0,maxX:-1/0,maxY:-1/0};return function(e){var t=e.geometry,r=e.type;if(\"Point\"===r||\"MultiPoint\"===r||\"LineString\"===r)H(e,t);else if(\"Polygon\"===r||\"MultiLineString\"===r)for(var o=0;o0&&(s+=o?(n*u-l*i)/2:Math.sqrt(Math.pow(l-n,2)+Math.pow(u-i,2))),n=l,i=u;}var h=t.length-3;t[2]=1,q(t,0,h,r),t[h+2]=1,t.size=Math.abs(s),t.start=0,t.end=t.size;}function re(e,t,r,o){for(var n=0;n1?1:r}function ie(e,t,r,o,n,i,s,a){if(o/=t,i>=(r/=t)&&s=o)return null;for(var l=[],u=0;u=r&&g=o)){var d=[];if(\"Point\"===f||\"MultiPoint\"===f)se(c,d,r,o,n);else if(\"LineString\"===f)ae(c,d,r,o,n,!1,a.lineMetrics);else if(\"MultiLineString\"===f)ue(c,d,r,o,n,!1);else if(\"Polygon\"===f)ue(c,d,r,o,n,!0);else if(\"MultiPolygon\"===f)for(var m=0;m=r&&s<=o&&(t.push(e[i]),t.push(e[i+1]),t.push(e[i+2]));}}function ae(e,t,r,o,n,i,s){for(var a,l,u=le(e),h=0===n?ce:fe,c=e.start,f=0;fr&&(l=h(u,p,g,m,y,r),s&&(u.start=c+a*l)):v>o?x=r&&(l=h(u,p,g,m,y,r),w=!0),x>o&&v<=o&&(l=h(u,p,g,m,y,o),w=!0),!i&&w&&(s&&(u.end=c+a*l),t.push(u),u=le(e)),s&&(c+=a);}var S=e.length-3;p=e[S],g=e[S+1],d=e[S+2],(v=0===n?p:g)>=r&&v<=o&&he(u,p,g,d),S=u.length-3,i&&S>=3&&(u[S]!==u[0]||u[S+1]!==u[1])&&he(u,u[0],u[1],u[2]),u.length&&t.push(u);}function le(e){var t=[];return t.size=e.size,t.start=e.start,t.end=e.end,t}function ue(e,t,r,o,n,i){for(var s=0;ss.maxX&&(s.maxX=h),c>s.maxY&&(s.maxY=c);}return s}function ve(e,t,r,o){var n=t.geometry,i=t.type,s=[];if(\"Point\"===i||\"MultiPoint\"===i)for(var a=0;a0&&t.size<(n?s:o))r.numPoints+=t.length/3;else {for(var a=[],l=0;ls)&&(r.numSimplified++,a.push(t[l]),a.push(t[l+1])),r.numPoints++;n&&function(e,t){for(var r=0,o=0,n=e.length,i=n-2;o0===t)for(o=0,n=e.length;o24)throw new Error(\"maxZoom should be in the 0-24 range\");if(t.promoteId&&t.generateId)throw new Error(\"promoteId and generateId cannot be used together.\");var o=function(e,t){var r=[];if(\"FeatureCollection\"===e.type)for(var o=0;o1&&console.time(\"creation\"),f=this.tiles[c]=ye(e,t,r,o,l),this.tileCoords.push({z:t,x:r,y:o}),u)){u>1&&(console.log(\"tile z%d-%d-%d (features: %d, points: %d, simplified: %d)\",t,r,o,f.numFeatures,f.numPoints,f.numSimplified),console.timeEnd(\"creation\"));var p=\"z\"+t;this.stats[p]=(this.stats[p]||0)+1,this.total++;}if(f.source=e,n){if(t===l.maxZoom||t===n)continue;var g=1<1&&console.time(\"clipping\");var d,m,y,v,x,w,S=.5*l.buffer/l.extent,M=.5-S,P=.5+S,b=1+S;d=m=y=v=null,x=ie(e,h,r-S,r+P,0,f.minX,f.maxX,l),w=ie(e,h,r+M,r+b,0,f.minX,f.maxX,l),e=null,x&&(d=ie(x,h,o-S,o+P,1,f.minY,f.maxY,l),m=ie(x,h,o+M,o+b,1,f.minY,f.maxY,l),x=null),w&&(y=ie(w,h,o-S,o+P,1,f.minY,f.maxY,l),v=ie(w,h,o+M,o+b,1,f.minY,f.maxY,l),w=null),u>1&&console.timeEnd(\"clipping\"),a.push(d||[],t+1,2*r,2*o),a.push(m||[],t+1,2*r,2*o+1),a.push(y||[],t+1,2*r+1,2*o),a.push(v||[],t+1,2*r+1,2*o+1);}}},we.prototype.getTile=function(e,t,r){var o=this.options,n=o.extent,i=o.debug;if(e<0||e>24)return null;var s=1<1&&console.log(\"drilling down to z%d-%d-%d\",e,t,r);for(var l,u=e,h=t,c=r;!l&&u>0;)u--,h=Math.floor(h/2),c=Math.floor(c/2),l=this.tiles[Se(u,h,c)];return l&&l.source?(i>1&&console.log(\"found parent tile z%d-%d-%d\",u,h,c),i>1&&console.time(\"drilling down\"),this.splitTile(l.source,u,h,c,e,t,r),i>1&&console.timeEnd(\"drilling down\"),this.tiles[a]?de(this.tiles[a],n):null):null};class Pe extends e.VectorTileWorkerSource{constructor(e,t,r,o,n){super(e,t,r,o,Me),n&&(this.loadGeoJSON=n);}loadData(t,r){const o=t&&t.request,n=o&&o.collectResourceTiming;this.loadGeoJSON(t,((s,a)=>{if(s||!a)return r(s);if(\"object\"!=typeof a)return r(new Error(`Input data given to '${t.source}' is not a valid GeoJSON object.`));{i(a,!0);try{if(t.filter){const r=e.createExpression(t.filter,{type:\"boolean\",\"property-type\":\"data-driven\",overridable:!1,transition:!1});if(\"error\"===r.result)throw new Error(r.value.map((e=>`${e.key}: ${e.message}`)).join(\", \"));const o=a.features.filter((e=>r.value.evaluate({zoom:0},e)));a={type:\"FeatureCollection\",features:o};}this._geoJSONIndex=t.cluster?new G(function({superclusterOptions:t,clusterProperties:r}){if(!r||!t)return t;const o={},n={},i={accumulated:null,zoom:0},s={properties:null},a=Object.keys(r);for(const t of a){const[i,s]=r[t],a=e.createExpression(s),l=e.createExpression(\"string\"==typeof i?[i,[\"accumulated\"],[\"get\",t]]:i);o[t]=a.value,n[t]=l.value;}return t.map=e=>{s.properties=e;const t={};for(const e of a)t[e]=o[e].evaluate(i,s);return t},t.reduce=(e,t)=>{s.properties=t;for(const t of a)i.accumulated=e[t],e[t]=n[t].evaluate(i,s);},t}(t)).load(a.features):function(e,t){return new we(e,t)}(a,t.geojsonVtOptions);}catch(s){return r(s)}this.loaded={};const l={};if(n){const r=e.getPerformanceMeasurement(o);r&&(l.resourceTiming={},l.resourceTiming[t.source]=JSON.parse(JSON.stringify(r)));}r(null,l);}}));}reloadTile(e,t){const r=this.loaded;return r&&r[e.uid]?super.reloadTile(e,t):this.loadTile(e,t)}loadGeoJSON(t,r){if(t.request)e.getJSON(t.request,r);else {if(\"string\"!=typeof t.data)return r(new Error(`Input data given to '${t.source}' is not a valid GeoJSON object.`));try{return r(null,JSON.parse(t.data))}catch(e){return r(new Error(`Input data given to '${t.source}' is not a valid GeoJSON object.`))}}}getClusterExpansionZoom(e,t){try{t(null,this._geoJSONIndex.getClusterExpansionZoom(e.clusterId));}catch(e){t(e);}}getClusterChildren(e,t){try{t(null,this._geoJSONIndex.getChildren(e.clusterId));}catch(e){t(e);}}getClusterLeaves(e,t){try{t(null,this._geoJSONIndex.getLeaves(e.clusterId,e.limit,e.offset));}catch(e){t(e);}}}class be{constructor(t){this.self=t,this.actor=new e.Actor(t,this),this.layerIndexes={},this.availableImages={},this.isSpriteLoaded={},this.projections={},this.defaultProjection=e.getProjection({name:\"mercator\"}),this.workerSourceTypes={vector:e.VectorTileWorkerSource,geojson:Pe},this.workerSources={},this.demWorkerSources={},this.self.registerWorkerSource=(e,t)=>{if(this.workerSourceTypes[e])throw new Error(`Worker source with name \"${e}\" already registered.`);this.workerSourceTypes[e]=t;},this.self.registerRTLTextPlugin=t=>{if(e.plugin.isParsed())throw new Error(\"RTL text plugin already registered.\");e.plugin.applyArabicShaping=t.applyArabicShaping,e.plugin.processBidirectionalText=t.processBidirectionalText,e.plugin.processStyledBidirectionalText=t.processStyledBidirectionalText;};}clearCaches(e,t,r){delete this.layerIndexes[e],delete this.availableImages[e],delete this.workerSources[e],delete this.demWorkerSources[e],r();}checkIfReady(e,t,r){r();}setReferrer(e,t){this.referrer=t;}spriteLoaded(t,r){this.isSpriteLoaded[t]=r;for(const o in this.workerSources[t]){const n=this.workerSources[t][o];for(const t in n)n[t]instanceof e.VectorTileWorkerSource&&(n[t].isSpriteLoaded=r,n[t].fire(new e.Event(\"isSpriteLoaded\")));}}setImages(e,t,r){this.availableImages[e]=t;for(const r in this.workerSources[e]){const o=this.workerSources[e][r];for(const e in o)o[e].availableImages=t;}r();}enableTerrain(e,t,r){this.terrain=t,r();}setProjection(t,r){this.projections[t]=e.getProjection(r);}setLayers(e,t,r){this.getLayerIndex(e).replace(t),r();}updateLayers(e,t,r){this.getLayerIndex(e).update(t.layers,t.removedIds),r();}loadTile(t,r,o){const n=this.enableTerrain?e.extend({enableTerrain:this.terrain},r):r;n.projection=this.projections[t]||this.defaultProjection,this.getWorkerSource(t,r.type,r.source).loadTile(n,o);}loadDEMTile(t,r,o){const n=this.enableTerrain?e.extend({buildQuadTree:this.terrain},r):r;this.getDEMWorkerSource(t,r.source).loadTile(n,o);}reloadTile(t,r,o){const n=this.enableTerrain?e.extend({enableTerrain:this.terrain},r):r;n.projection=this.projections[t]||this.defaultProjection,this.getWorkerSource(t,r.type,r.source).reloadTile(n,o);}abortTile(e,t,r){this.getWorkerSource(e,t.type,t.source).abortTile(t,r);}removeTile(e,t,r){this.getWorkerSource(e,t.type,t.source).removeTile(t,r);}removeSource(e,t,r){if(!this.workerSources[e]||!this.workerSources[e][t.type]||!this.workerSources[e][t.type][t.source])return;const o=this.workerSources[e][t.type][t.source];delete this.workerSources[e][t.type][t.source],void 0!==o.removeSource?o.removeSource(t,r):r();}loadWorkerSource(e,t,r){try{this.self.importScripts(t.url),r();}catch(e){r(e.toString());}}syncRTLPluginState(t,r,o){try{e.plugin.setState(r);const t=e.plugin.getPluginURL();if(e.plugin.isLoaded()&&!e.plugin.isParsed()&&null!=t){this.self.importScripts(t);const r=e.plugin.isParsed();o(r?void 0:new Error(`RTL Text Plugin failed to import scripts from ${t}`),r);}}catch(e){o(e.toString());}}getAvailableImages(e){let t=this.availableImages[e];return t||(t=[]),t}getLayerIndex(e){let t=this.layerIndexes[e];return t||(t=this.layerIndexes[e]=new o),t}getWorkerSource(e,t,r){if(this.workerSources[e]||(this.workerSources[e]={}),this.workerSources[e][t]||(this.workerSources[e][t]={}),!this.workerSources[e][t][r]){const o={send:(t,r,o,n,i,s)=>{this.actor.send(t,r,o,e,i,s);},scheduler:this.actor.scheduler};this.workerSources[e][t][r]=new this.workerSourceTypes[t](o,this.getLayerIndex(e),this.getAvailableImages(e),this.isSpriteLoaded[e]);}return this.workerSources[e][t][r]}getDEMWorkerSource(e,t){return this.demWorkerSources[e]||(this.demWorkerSources[e]={}),this.demWorkerSources[e][t]||(this.demWorkerSources[e][t]=new n),this.demWorkerSources[e][t]}enforceCacheSizeLimit(t,r){e.enforceCacheSizeLimit(r);}getWorkerPerformanceMetrics(e,t,r){r(void 0,void 0);}}return \"undefined\"!=typeof WorkerGlobalScope&&\"undefined\"!=typeof self&&self instanceof WorkerGlobalScope&&(self.worker=new be(self)),be}));\n\ndefine([\"./shared\"],(function(e){\"use strict\";function t(e,i){if(Array.isArray(e)){if(!Array.isArray(i)||e.length!==i.length)return !1;for(let o=0;o{e.window.removeEventListener(\"click\",_,!0);}),0);}function p(e,t){const i=e.getBoundingClientRect();return g(e,i,t)}function m(e,t){const i=e.getBoundingClientRect(),o=[];for(let r=0;r=0?0:t.button}function g(t,i,o){const r=t.offsetWidth===i.width?1:t.offsetWidth/i.width;return new e.pointGeometry((o.clientX-i.left)*r,(o.clientY-i.top)*r)}function v(e,t){var i=t[0],o=t[1],r=t[2],n=t[3],s=i*n-r*o;return s?(e[0]=n*(s=1/s),e[1]=-o*s,e[2]=-r*s,e[3]=i*s,e):null}function x(e){const{userImage:t}=e;return !!(t&&t.render&&t.render())&&(e.data.replace(new Uint8Array(t.data.buffer)),!0)}class y extends e.Evented{constructor(){super(),this.images={},this.updatedImages={},this.callbackDispatchedThisFrame={},this.loaded=!1,this.requestors=[],this.patterns={},this.atlasImage=new e.RGBAImage({width:1,height:1}),this.dirty=!0;}isLoaded(){return this.loaded}setLoaded(e){if(this.loaded!==e&&(this.loaded=e,e)){for(const{ids:e,callback:t}of this.requestors)this._notify(e,t);this.requestors=[];}}hasImage(e){return !!this.getImage(e)}getImage(e){return this.images[e]}addImage(e,t){this._validate(e,t)&&(this.images[e]=t);}_validate(t,i){let o=!0;return this._validateStretch(i.stretchX,i.data&&i.data.width)||(this.fire(new e.ErrorEvent(new Error(`Image \"${t}\" has invalid \"stretchX\" value`))),o=!1),this._validateStretch(i.stretchY,i.data&&i.data.height)||(this.fire(new e.ErrorEvent(new Error(`Image \"${t}\" has invalid \"stretchY\" value`))),o=!1),this._validateContent(i.content,i)||(this.fire(new e.ErrorEvent(new Error(`Image \"${t}\" has invalid \"content\" value`))),o=!1),o}_validateStretch(e,t){if(!e)return !0;let i=0;for(const o of e){if(o[0]{this.ready=!0;}));}broadcast(t,i,o){e.asyncAll(this.actors,((e,o)=>{e.send(t,i,o);}),o=o||function(){});}getActor(){return this.currentActor=(this.currentActor+1)%this.actors.length,this.actors[this.currentActor]}remove(){this.actors.forEach((e=>{e.remove();})),this.actors=[],this.workerPool.release(this.id);}}function P(t,i,o){return i*(e.EXTENT/(t.tileSize*Math.pow(2,o-t.tileID.overscaledZ)))}z.Actor=e.Actor;class R{constructor(e,t,i,o){this.screenBounds=e,this.cameraPoint=t,this._screenRaycastCache={},this._cameraRaycastCache={},this.isAboveHorizon=i,this.screenGeometry=this.bufferedScreenGeometry(0),this.screenGeometryMercator=this._bufferedScreenMercator(0,o);}static createFromScreenPoints(t,i){let o,r;if(t instanceof e.pointGeometry||\"number\"==typeof t[0]){const n=e.pointGeometry.convert(t);o=[n],r=i.isPointAboveHorizon(n);}else {const n=e.pointGeometry.convert(t[0]),s=e.pointGeometry.convert(t[1]);o=[n,s],r=e.polygonizeBounds(n,s).every((e=>i.isPointAboveHorizon(e)));}return new R(o,i.getCameraPoint(),r,i)}isPointQuery(){return 1===this.screenBounds.length}bufferedScreenGeometry(t){return e.polygonizeBounds(this.screenBounds[0],1===this.screenBounds.length?this.screenBounds[0]:this.screenBounds[1],t)}bufferedCameraGeometry(t){const i=this.screenBounds[0],o=1===this.screenBounds.length?this.screenBounds[0].add(new e.pointGeometry(1,1)):this.screenBounds[1],r=e.polygonizeBounds(i,o,0,!1);return this.cameraPoint.y>o.y&&(this.cameraPoint.x>i.x&&this.cameraPoint.x=o.x?r[2]=this.cameraPoint:this.cameraPoint.x<=i.x&&(r[3]=this.cameraPoint)),e.bufferConvexPolygon(r,t)}bufferedCameraGeometryGlobe(t){const i=this.screenBounds[0],o=1===this.screenBounds.length?this.screenBounds[0].add(new e.pointGeometry(1,1)):this.screenBounds[1],r=e.polygonizeBounds(i,o,t),n=this.cameraPoint.clone();switch(3*((n.y>i.y)+(n.y>o.y))+((n.x>i.x)+(n.x>o.x))){case 0:r[0]=n,r[4]=n.clone();break;case 1:r.splice(1,0,n);break;case 2:r[1]=n;break;case 3:r.splice(4,0,n);break;case 5:r.splice(2,0,n);break;case 6:r[3]=n;break;case 7:r.splice(3,0,n);break;case 8:r[2]=n;}return r}containsTile(t,i,o,r=0){const n=t.queryPadding/i._pixelsPerMercatorPixel+1,s=o?this._bufferedCameraMercator(n,i):this._bufferedScreenMercator(n,i);let a=t.tileID.wrap+(s.unwrapped?r:0);const l=s.polygon.map((i=>e.getTilePoint(t.tileTransform,i,a)));if(!e.polygonIntersectsBox(l,0,0,e.EXTENT,e.EXTENT))return;a=t.tileID.wrap+(this.screenGeometryMercator.unwrapped?r:0);const c=this.screenGeometryMercator.polygon.map((i=>e.getTileVec3(t.tileTransform,i,a))),h=c.map((t=>new e.pointGeometry(t[0],t[1]))),u=i.getFreeCameraOptions().position||new e.MercatorCoordinate(0,0,0),_=e.getTileVec3(t.tileTransform,u,a),d=c.map((t=>{const i=e.sub(t,t,_);return e.normalize(i,i),new e.Ray(_,i)})),p=P(t,1,i.zoom)*i._pixelsPerMercatorPixel;return {queryGeometry:this,tilespaceGeometry:h,tilespaceRays:d,bufferedTilespaceGeometry:l,bufferedTilespaceBounds:(m=e.getBounds(l),m.min.x=e.clamp(m.min.x,0,e.EXTENT),m.min.y=e.clamp(m.min.y,0,e.EXTENT),m.max.x=e.clamp(m.max.x,0,e.EXTENT),m.max.y=e.clamp(m.max.y,0,e.EXTENT),m),tile:t,tileID:t.tileID,pixelToTileUnitsFactor:p};var m;}_bufferedScreenMercator(e,t){const i=k(e);if(this._screenRaycastCache[i])return this._screenRaycastCache[i];{let o;return o=\"globe\"===t.projection.name?this._projectAndResample(this.bufferedScreenGeometry(e),t):{polygon:this.bufferedScreenGeometry(e).map((e=>t.pointCoordinate3D(e))),unwrapped:!0},this._screenRaycastCache[i]=o,o}}_bufferedCameraMercator(e,t){const i=k(e);if(this._cameraRaycastCache[i])return this._cameraRaycastCache[i];{let o;return o=\"globe\"===t.projection.name?this._projectAndResample(this.bufferedCameraGeometryGlobe(e),t):{polygon:this.bufferedCameraGeometry(e).map((e=>t.pointCoordinate3D(e))),unwrapped:!0},this._cameraRaycastCache[i]=o,o}}_projectAndResample(t,i){const o=function(t,i){const o=e.multiply([],i.pixelMatrix,i.globeMatrix),r=[0,-e.GLOBE_RADIUS,0,1],n=[0,e.GLOBE_RADIUS,0,1],s=[0,0,0,1];e.transformMat4$1(r,r,o),e.transformMat4$1(n,n,o),e.transformMat4$1(s,s,o);const a=new e.pointGeometry(r[0]/r[3],r[1]/r[3]),l=new e.pointGeometry(n[0]/n[3],n[1]/n[3]),c=e.polygonContainsPoint(t,a)&&r[3]1?O(t.slice(0,_),i):[],m=_new e.pointGeometry(B(t.x),t.y))),m=m.map((t=>new e.pointGeometry(B(t.x),t.y)));const f=[...p];0===f.length&&f.push(m[m.length-1]);const g=e.number(f[f.length-1].y,(0===m.length?p[0]:m[0]).y,d);let v;return v=c?[new e.pointGeometry(0,g),new e.pointGeometry(0,0),new e.pointGeometry(1,0),new e.pointGeometry(1,g)]:[new e.pointGeometry(1,g),new e.pointGeometry(1,1),new e.pointGeometry(0,1),new e.pointGeometry(0,g)],f.push(...v),0===m.length?f.push(p[0]):f.push(...m),{polygon:f.map((t=>new e.MercatorCoordinate(t.x,t.y))),unwrapped:!1}}(t,i);if(o)return o;const r=function(t,i){let o=!1,r=-1/0,n=0;for(let e=0;er&&(r=t[e].x,n=e);for(let e=0;e.5&&(r.x{e.x-=1;})),{polygon:t,unwrapped:o}}(O(t,i).map((t=>new e.pointGeometry(B(t.x),t.y))),i);return {polygon:r.polygon.map((t=>new e.MercatorCoordinate(t.x,t.y))),unwrapped:r.unwrapped}}}function O(t,i){return e.resample(t,(e=>{const t=i.pointCoordinate3D(e);e.x=t.x,e.y=t.y;}),1/256)}function B(e){return e<0?1+e%1:e%1}function k(e){return 100*e|0}function F(t,i,o,r,n){const s=function(o,r){if(o)return n(o);if(r){t.url&&r.tiles&&t.tiles&&delete t.tiles;const o=e.pick(e.extend(r,t),[\"tiles\",\"minzoom\",\"maxzoom\",\"attribution\",\"mapbox_logo\",\"bounds\",\"scheme\",\"tileSize\",\"encoding\"]);r.vector_layers&&(o.vectorLayers=r.vector_layers,o.vectorLayerIds=o.vectorLayers.map((e=>e.id))),o.tiles=i.canonicalizeTileset(o,t.url),n(null,o);}};return t.url?e.getJSON(i.transformRequest(i.normalizeSourceURL(t.url,null,o,r),e.ResourceType.Source),s):e.exported.frame((()=>s(null,t)))}class U{constructor(t,i,o){this.bounds=e.LngLatBounds.convert(this.validateBounds(t)),this.minzoom=i||0,this.maxzoom=o||24;}validateBounds(e){return Array.isArray(e)&&4===e.length?[Math.max(-180,e[0]),Math.max(-90,e[1]),Math.min(180,e[2]),Math.min(90,e[3])]:[-180,-90,180,90]}contains(t){const i=Math.pow(2,t.z),o=Math.floor(e.mercatorXfromLng(this.bounds.getWest())*i),r=Math.floor(e.mercatorYfromLat(this.bounds.getNorth())*i),n=Math.ceil(e.mercatorXfromLng(this.bounds.getEast())*i),s=Math.ceil(e.mercatorYfromLat(this.bounds.getSouth())*i);return t.x>=o&&t.x=r&&t.y{this._tileJSONRequest=null,this._loaded=!0,t?this.fire(new e.ErrorEvent(t)):i&&(e.extend(this,i),i.bounds&&(this.tileBounds=new U(i.bounds,this.minzoom,this.maxzoom)),e.postTurnstileEvent(i.tiles),this.fire(new e.Event(\"data\",{dataType:\"source\",sourceDataType:\"metadata\"})),this.fire(new e.Event(\"data\",{dataType:\"source\",sourceDataType:\"content\"})));}));}loaded(){return this._loaded}onAdd(e){this.map=e,this.load();}onRemove(){this._tileJSONRequest&&(this._tileJSONRequest.cancel(),this._tileJSONRequest=null);}serialize(){return e.extend({},this._options)}hasTile(e){return !this.tileBounds||this.tileBounds.contains(e.canonical)}loadTile(t,i){const o=e.exported.devicePixelRatio>=2,r=this.map._requestManager.normalizeTileURL(t.tileID.canonical.url(this.tiles,this.scheme),o,this.tileSize);t.request=e.getImage(this.map._requestManager.transformRequest(r,e.ResourceType.Tile),((o,r,n,s)=>(delete t.request,t.aborted?(t.state=\"unloaded\",i(null)):o?(t.state=\"errored\",i(o)):r?(this.map._refreshExpiredTiles&&t.setExpiryData({cacheControl:n,expires:s}),t.setTexture(r,this.map.painter),t.state=\"loaded\",e.cacheEntryPossiblyAdded(this.dispatcher),void i(null)):i(null))));}static loadTileData(e,t,i){e.setTexture(t,i);}static unloadTileData(e,t){e.texture&&t.saveTileTexture(e.texture);}abortTile(e,t){e.request&&(e.request.cancel(),delete e.request),t();}unloadTile(e,t){e.texture&&this.map.painter.saveTileTexture(e.texture),t();}hasTransition(){return !1}}let Se;function De(t,i,o,r,n,s,a,l){const c=[t,o,n,i,r,s,1,1,1],h=[a,l,1],u=e.adjoint([],c),[_,d,p]=e.transformMat3(h,h,e.transpose(u,u));return e.multiply$1(c,[_,0,0,0,d,0,0,0,p],c)}class Ae extends e.Evented{constructor(e,t,i,o){super(),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(o),this.options=t,this._dirty=!1;}load(t,i){this._loaded=i||!1,this.fire(new e.Event(\"dataloading\",{dataType:\"source\"})),this.url=this.options.url,this._imageRequest=e.getImage(this.map._requestManager.transformRequest(this.url,e.ResourceType.Image),((i,o)=>{if(this._imageRequest=null,this._loaded=!0,i)this.fire(new e.ErrorEvent(i));else if(o){const{HTMLImageElement:i}=e.window;this.image=o instanceof i?e.exported.getImageData(o):o,this._dirty=!0,this.width=this.image.width,this.height=this.image.height,t&&(this.coordinates=t),this._finishLoading();}}));}loaded(){return this._loaded}updateImage(e){return this.image&&e.url?(this._imageRequest&&e.url!==this.options.url&&(this._imageRequest.cancel(),this._imageRequest=null),this.options.url=e.url,this.load(e.coordinates,this._loaded),this):this}_finishLoading(){this.map&&(this.setCoordinates(this.coordinates),this.fire(new e.Event(\"data\",{dataType:\"source\",sourceDataType:\"metadata\"})));}onAdd(e){this.map=e,this.load();}onRemove(){this._imageRequest&&(this._imageRequest.cancel(),this._imageRequest=null),this.texture&&this.texture.destroy();}setCoordinates(t){this.coordinates=t,this._boundsArray=void 0;const i=t.map(e.MercatorCoordinate.fromLngLat);return this.tileID=function(t){let i=1/0,o=1/0,r=-1/0,n=-1/0;for(const e of t)i=Math.min(i,e.x),o=Math.min(o,e.y),r=Math.max(r,e.x),n=Math.max(n,e.y);const s=Math.max(r-i,n-o),a=Math.max(0,Math.floor(-Math.log(s)/Math.LN2)),l=Math.pow(2,a);return new e.CanonicalTileID(a,Math.floor((i+r)/2*l),Math.floor((o+n)/2*l))}(i),this.minzoom=this.maxzoom=this.tileID.z,this.fire(new e.Event(\"data\",{dataType:\"source\",sourceDataType:\"content\"})),this}_clear(){this._boundsArray=void 0;}_prepareData(t){for(const e in this.tiles){const t=this.tiles[e];\"loaded\"!==t.state&&(t.state=\"loaded\",t.texture=this.texture);}if(this._boundsArray)return;const i=e.tileTransform(this.tileID,this.map.transform.projection),[o,r,n,s]=this.coordinates.map((t=>{const o=i.projection.project(t[0],t[1]);return e.getTilePoint(i,o)._round()}));this.perspectiveTransform=function(t,i,o,r,n,s,a,l,c,h){const u=De(0,0,t,0,0,i,t,i),_=De(o,r,n,s,a,l,c,h);return e.multiply$1(_,e.adjoint(u,u),_),[_[6]/_[8]*t/e.EXTENT,_[7]/_[8]*i/e.EXTENT]}(this.width,this.height,o.x,o.y,r.x,r.y,s.x,s.y,n.x,n.y);const a=this._boundsArray=new e.StructArrayLayout4i8;a.emplaceBack(o.x,o.y,0,0),a.emplaceBack(r.x,r.y,e.EXTENT,0),a.emplaceBack(s.x,s.y,0,e.EXTENT),a.emplaceBack(n.x,n.y,e.EXTENT,e.EXTENT),this.boundsBuffer&&this.boundsBuffer.destroy(),this.boundsBuffer=t.createVertexBuffer(a,e.boundsAttributes.members),this.boundsSegments=e.SegmentVector.simpleSegment(0,0,4,2);}prepare(){if(0===Object.keys(this.tiles).length||!this.image)return;const t=this.map.painter.context,i=t.gl;this._dirty&&(this.texture?this.texture.update(this.image):(this.texture=new e.Texture(t,this.image,i.RGBA),this.texture.bind(i.LINEAR,i.CLAMP_TO_EDGE)),this._dirty=!1),this._prepareData(t);}loadTile(e,t){this.tileID&&this.tileID.equals(e.tileID.canonical)?(this.tiles[String(e.tileID.wrap)]=e,e.buckets={},t(null)):(e.state=\"errored\",t(null));}serialize(){return {type:\"image\",url:this.options.url,coordinates:this.coordinates}}hasTransition(){return !1}}const Le={vector:class extends e.Evented{constructor(t,i,o,r){if(super(),this.id=t,this.dispatcher=o,this.type=\"vector\",this.minzoom=0,this.maxzoom=22,this.scheme=\"xyz\",this.tileSize=512,this.reparseOverscaled=!0,this.isTileClipped=!0,this._loaded=!1,e.extend(this,e.pick(i,[\"url\",\"scheme\",\"tileSize\",\"promoteId\"])),this._options=e.extend({type:\"vector\"},i),this._collectResourceTiming=i.collectResourceTiming,512!==this.tileSize)throw new Error(\"vector tile sources must have a tileSize of 512\");this.setEventedParent(r),this._tileWorkers={},this._deduped=new e.DedupedRequest;}load(t){this._loaded=!1,this.fire(new e.Event(\"dataloading\",{dataType:\"source\"}));const i=Array.isArray(this.map._language)?this.map._language.join():this.map._language,o=this.map._worldview;this._tileJSONRequest=F(this._options,this.map._requestManager,i,o,((r,n)=>{this._tileJSONRequest=null,this._loaded=!0,r?(i&&console.warn(`Ensure that your requested language string is a valid BCP-47 code or list of codes. Found: ${i}`),o&&2!==o.length&&console.warn(`Requested worldview strings must be a valid ISO alpha-2 code. Found: ${o}`),this.fire(new e.ErrorEvent(r))):n&&(e.extend(this,n),n.bounds&&(this.tileBounds=new U(n.bounds,this.minzoom,this.maxzoom)),e.postTurnstileEvent(n.tiles,this.map._requestManager._customAccessToken),this.fire(new e.Event(\"data\",{dataType:\"source\",sourceDataType:\"metadata\"})),this.fire(new e.Event(\"data\",{dataType:\"source\",sourceDataType:\"content\"}))),t&&t(r);}));}loaded(){return this._loaded}hasTile(e){return !this.tileBounds||this.tileBounds.contains(e.canonical)}onAdd(e){this.map=e,this.load();}reload(){this.cancelTileJSONRequest(),this.load((()=>{const e=this.map.style._getSourceCaches(this.id);for(const t of e)t.clearTiles();}));}setSourceProperty(e){e(),this.reload();}setTiles(e){return this._options.tiles=e,this.reload(),this}setUrl(e){return this.url=e,this._options.url=e,this.reload(),this}onRemove(){this.cancelTileJSONRequest();}serialize(){return e.extend({},this._options)}loadTile(t,i){const o=this.map._requestManager.normalizeTileURL(t.tileID.canonical.url(this.tiles,this.scheme)),r={request:this.map._requestManager.transformRequest(o,e.ResourceType.Tile),data:void 0,uid:t.uid,tileID:t.tileID,tileZoom:t.tileZoom,zoom:t.tileID.overscaledZ,tileSize:this.tileSize*t.tileID.overscaleFactor(),type:this.type,source:this.id,pixelRatio:e.exported.devicePixelRatio,showCollisionBoxes:this.map.showCollisionBoxes,promoteId:this.promoteId,isSymbolTile:t.isSymbolTile};if(r.request.collectResourceTiming=this._collectResourceTiming,t.actor&&\"expired\"!==t.state)\"loading\"===t.state?t.reloadCallback=i:t.request=t.actor.send(\"reloadTile\",r,n.bind(this));else if(t.actor=this._tileWorkers[o]=this._tileWorkers[o]||this.dispatcher.getActor(),this.dispatcher.ready)t.request=t.actor.send(\"loadTile\",r,n.bind(this),void 0,!0);else {const i=e.loadVectorTile.call({deduped:this._deduped},r,((e,i)=>{e||!i?n.call(this,e):(r.data={cacheControl:i.cacheControl,expires:i.expires,rawData:i.rawData.slice(0)},t.actor&&t.actor.send(\"loadTile\",r,n.bind(this),void 0,!0));}),!0);t.request={cancel:i};}function n(o,r){return delete t.request,t.aborted?i(null):o&&404!==o.status?i(o):(r&&r.resourceTiming&&(t.resourceTiming=r.resourceTiming),this.map._refreshExpiredTiles&&r&&t.setExpiryData(r),t.loadVectorData(r,this.map.painter),e.cacheEntryPossiblyAdded(this.dispatcher),i(null),void(t.reloadCallback&&(this.loadTile(t,t.reloadCallback),t.reloadCallback=null)))}}abortTile(e){e.request&&(e.request.cancel(),delete e.request),e.actor&&e.actor.send(\"abortTile\",{uid:e.uid,type:this.type,source:this.id});}unloadTile(e){e.unloadVectorData(),e.actor&&e.actor.send(\"removeTile\",{uid:e.uid,type:this.type,source:this.id});}hasTransition(){return !1}afterUpdate(){this._tileWorkers={};}cancelTileJSONRequest(){this._tileJSONRequest&&(this._tileJSONRequest.cancel(),this._tileJSONRequest=null);}},raster:Me,\"raster-dem\":class extends Me{constructor(t,i,o,r){super(t,i,o,r),this.type=\"raster-dem\",this.maxzoom=22,this._options=e.extend({type:\"raster-dem\"},i),this.encoding=i.encoding||\"mapbox\";}loadTile(t,i){const o=this.map._requestManager.normalizeTileURL(t.tileID.canonical.url(this.tiles,this.scheme),!1,this.tileSize);function r(e,o){e&&(t.state=\"errored\",i(e)),o&&(t.dem=o,t.dem.onDeserialize(),t.needsHillshadePrepare=!0,t.needsDEMTextureUpload=!0,t.state=\"loaded\",i(null));}t.request=e.getImage(this.map._requestManager.transformRequest(o,e.ResourceType.Tile),function(o,n,s,a){if(delete t.request,t.aborted)t.state=\"unloaded\",i(null);else if(o)t.state=\"errored\",i(o);else if(n){this.map._refreshExpiredTiles&&t.setExpiryData({cacheControl:s,expires:a});const i=e.window.ImageBitmap&&n instanceof e.window.ImageBitmap&&(null==Se&&(Se=e.window.OffscreenCanvas&&new e.window.OffscreenCanvas(1,1).getContext(\"2d\")&&\"function\"==typeof e.window.createImageBitmap),Se),o=1-(n.width-e.prevPowerOfTwo(n.width))/2;o<1||t.neighboringTiles||(t.neighboringTiles=this._getNeighboringTiles(t.tileID));const l=i?n:e.exported.getImageData(n,o),c={uid:t.uid,coord:t.tileID,source:this.id,rawImageData:l,encoding:this.encoding,padding:o};t.actor&&\"expired\"!==t.state||(t.actor=this.dispatcher.getActor(),t.actor.send(\"loadDEMTile\",c,r.bind(this),void 0,!0));}}.bind(this));}_getNeighboringTiles(t){const i=t.canonical,o=Math.pow(2,i.z),r=(i.x-1+o)%o,n=0===i.x?t.wrap-1:t.wrap,s=(i.x+1+o)%o,a=i.x+1===o?t.wrap+1:t.wrap,l={};return l[new e.OverscaledTileID(t.overscaledZ,n,i.z,r,i.y).key]={backfilled:!1},l[new e.OverscaledTileID(t.overscaledZ,a,i.z,s,i.y).key]={backfilled:!1},i.y>0&&(l[new e.OverscaledTileID(t.overscaledZ,n,i.z,r,i.y-1).key]={backfilled:!1},l[new e.OverscaledTileID(t.overscaledZ,t.wrap,i.z,i.x,i.y-1).key]={backfilled:!1},l[new e.OverscaledTileID(t.overscaledZ,a,i.z,s,i.y-1).key]={backfilled:!1}),i.y+1{if(this._loaded=!0,this._pendingLoad=null,t)this.fire(new e.ErrorEvent(t));else {const t={dataType:\"source\",sourceDataType:this._metadataFired?\"content\":\"metadata\"};this._collectResourceTiming&&i&&i.resourceTiming&&i.resourceTiming[this.id]&&(t.resourceTiming=i.resourceTiming[this.id]),this.fire(new e.Event(\"data\",t)),this._metadataFired=!0;}this._coalesce&&(this._updateWorkerData(),this._coalesce=!1);}));}loaded(){return this._loaded}loadTile(t,i){const o=t.actor?\"reloadTile\":\"loadTile\";t.actor=this.actor,t.request=this.actor.send(o,{type:this.type,uid:t.uid,tileID:t.tileID,tileZoom:t.tileZoom,zoom:t.tileID.overscaledZ,maxZoom:this.maxzoom,tileSize:this.tileSize,source:this.id,pixelRatio:e.exported.devicePixelRatio,showCollisionBoxes:this.map.showCollisionBoxes,promoteId:this.promoteId},((e,r)=>(delete t.request,t.unloadVectorData(),t.aborted?i(null):e?i(e):(t.loadVectorData(r,this.map.painter,\"reloadTile\"===o),i(null)))),void 0,\"loadTile\"===o);}abortTile(e){e.request&&(e.request.cancel(),delete e.request),e.aborted=!0;}unloadTile(e){e.unloadVectorData(),this.actor.send(\"removeTile\",{uid:e.uid,type:this.type,source:this.id});}onRemove(){this._pendingLoad&&this._pendingLoad.cancel();}serialize(){return e.extend({},this._options,{type:this.type,data:this._data})}hasTransition(){return !1}},video:class extends Ae{constructor(e,t,i,o){super(e,t,i,o),this.roundZoom=!0,this.type=\"video\",this.options=t;}load(){this._loaded=!1;const t=this.options;this.urls=[];for(const i of t.urls)this.urls.push(this.map._requestManager.transformRequest(i,e.ResourceType.Source).url);e.getVideo(this.urls,((t,i)=>{this._loaded=!0,t?this.fire(new e.ErrorEvent(t)):i&&(this.video=i,this.video.loop=!0,this.video.setAttribute(\"playsinline\",\"\"),this.video.addEventListener(\"playing\",(()=>{this.map.triggerRepaint();})),this.map&&this.video.play(),this._finishLoading());}));}pause(){this.video&&this.video.pause();}play(){this.video&&this.video.play();}seek(t){if(this.video){const i=this.video.seekable;ti.end(0)?this.fire(new e.ErrorEvent(new e.ValidationError(`sources.${this.id}`,null,`Playback for this video can be set only between the ${i.start(0)} and ${i.end(0)}-second mark.`))):this.video.currentTime=t;}}getVideo(){return this.video}onAdd(e){this.map||(this.map=e,this.load(),this.video&&(this.video.play(),this.setCoordinates(this.coordinates)));}prepare(){if(0===Object.keys(this.tiles).length||this.video.readyState<2)return;const t=this.map.painter.context,i=t.gl;this.texture?this.video.paused||(this.texture.bind(i.LINEAR,i.CLAMP_TO_EDGE),i.texSubImage2D(i.TEXTURE_2D,0,0,0,i.RGBA,i.UNSIGNED_BYTE,this.video)):(this.texture=new e.Texture(t,this.video,i.RGBA),this.texture.bind(i.LINEAR,i.CLAMP_TO_EDGE),this.width=this.video.videoWidth,this.height=this.video.videoHeight),this._prepareData(t);}serialize(){return {type:\"video\",urls:this.urls,coordinates:this.coordinates}}hasTransition(){return this.video&&!this.video.paused}},image:Ae,canvas:class extends Ae{constructor(t,i,o,r){super(t,i,o,r),i.coordinates?Array.isArray(i.coordinates)&&4===i.coordinates.length&&!i.coordinates.some((e=>!Array.isArray(e)||2!==e.length||e.some((e=>\"number\"!=typeof e))))||this.fire(new e.ErrorEvent(new e.ValidationError(`sources.${t}`,null,'\"coordinates\" property must be an array of 4 longitude/latitude array pairs'))):this.fire(new e.ErrorEvent(new e.ValidationError(`sources.${t}`,null,'missing required property \"coordinates\"'))),i.animate&&\"boolean\"!=typeof i.animate&&this.fire(new e.ErrorEvent(new e.ValidationError(`sources.${t}`,null,'optional \"animate\" property must be a boolean value'))),i.canvas?\"string\"==typeof i.canvas||i.canvas instanceof e.window.HTMLCanvasElement||this.fire(new e.ErrorEvent(new e.ValidationError(`sources.${t}`,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 e.ErrorEvent(new e.ValidationError(`sources.${t}`,null,'missing required property \"canvas\"'))),this.options=i,this.animate=void 0===i.animate||i.animate;}load(){this._loaded=!0,this.canvas||(this.canvas=this.options.canvas instanceof e.window.HTMLCanvasElement?this.options.canvas:e.window.document.getElementById(this.options.canvas)),this.width=this.canvas.width,this.height=this.canvas.height,this._hasInvalidDimensions()?this.fire(new e.ErrorEvent(new Error(\"Canvas dimensions cannot be less than or equal to zero.\"))):(this.play=function(){this._playing=!0,this.map.triggerRepaint();},this.pause=function(){this._playing&&(this.prepare(),this._playing=!1);},this._finishLoading());}getCanvas(){return this.canvas}onAdd(e){this.map=e,this.load(),this.canvas&&this.animate&&this.play();}onRemove(){this.pause();}prepare(){let t=!1;if(this.canvas.width!==this.width&&(this.width=this.canvas.width,t=!0),this.canvas.height!==this.height&&(this.height=this.canvas.height,t=!0),this._hasInvalidDimensions())return;if(0===Object.keys(this.tiles).length)return;const i=this.map.painter.context;this.texture?(t||this._playing)&&this.texture.update(this.canvas,{premultiply:!0}):this.texture=new e.Texture(i,this.canvas,i.gl.RGBA,{premultiply:!0}),this._prepareData(i);}serialize(){return {type:\"canvas\",coordinates:this.coordinates}}hasTransition(){return this._playing}_hasInvalidDimensions(){for(const e of [this.canvas.width,this.canvas.height])if(isNaN(e)||e<=0)return !0;return !1}},custom:class extends e.Evented{constructor(t,i,o,r){super(),this.id=t,this.type=\"custom\",this._dataType=\"raster\",this._dispatcher=o,this._implementation=i,this.setEventedParent(r),this.scheme=\"xyz\",this.minzoom=0,this.maxzoom=22,this.tileSize=512,this._loaded=!1,this.roundZoom=!0,this._implementation||this.fire(new e.ErrorEvent(new Error(`Missing implementation for ${this.id} custom source`))),this._implementation.loadTile||this.fire(new e.ErrorEvent(new Error(`Missing loadTile implementation for ${this.id} custom source`))),this._implementation.bounds&&(this.tileBounds=new U(this._implementation.bounds,this.minzoom,this.maxzoom)),i.update=this._update.bind(this),i.clearTiles=this._clearTiles.bind(this),i.coveringTiles=this._coveringTiles.bind(this),e.extend(this,e.pick(i,[\"dataType\",\"scheme\",\"minzoom\",\"maxzoom\",\"tileSize\",\"attribution\",\"minTileCacheSize\",\"maxTileCacheSize\"]));}serialize(){return e.pick(this,[\"type\",\"scheme\",\"minzoom\",\"maxzoom\",\"tileSize\",\"attribution\"])}load(){this._loaded=!0,this.fire(new e.Event(\"data\",{dataType:\"source\",sourceDataType:\"metadata\"})),this.fire(new e.Event(\"data\",{dataType:\"source\",sourceDataType:\"content\"}));}loaded(){return this._loaded}onAdd(t){this._map=t,this._loaded=!1,this.fire(new e.Event(\"dataloading\",{dataType:\"source\"})),this._implementation.onAdd&&this._implementation.onAdd(t),this.load();}onRemove(e){this._implementation.onRemove&&this._implementation.onRemove(e);}hasTile(e){if(this._implementation.hasTile){const{x:t,y:i,z:o}=e.canonical;return this._implementation.hasTile({x:t,y:i,z:o})}return !this.tileBounds||this.tileBounds.contains(e.canonical)}loadTile(t,i){const{x:o,y:r,z:n}=t.tileID.canonical,s=new e.window.AbortController;t.request=Promise.resolve(this._implementation.loadTile({x:o,y:r,z:n},{signal:s.signal})).then(function(o){return delete t.request,t.aborted?(t.state=\"unloaded\",i(null)):void 0===o?(t.state=\"errored\",i(null)):null===o?(this.loadTileData(t,{width:this.tileSize,height:this.tileSize,data:null}),t.state=\"loaded\",i(null)):function(t){return t instanceof e.window.ImageData||t instanceof e.window.HTMLCanvasElement||t instanceof e.window.ImageBitmap||t instanceof e.window.HTMLImageElement}(o)?(this.loadTileData(t,o),t.state=\"loaded\",void i(null)):(t.state=\"errored\",i(new Error(`Can't infer data type for ${this.id}, only raster data supported at the moment`)))}.bind(this)).catch((e=>{20!==e.code&&(t.state=\"errored\",i(e));})),t.request.cancel=()=>s.abort();}loadTileData(e,t){Me.loadTileData(e,t,this._map.painter);}unloadTileData(e){Me.unloadTileData(e,this._map.painter);}unloadTile(e,t){if(this.unloadTileData(e),this._implementation.unloadTile){const{x:t,y:i,z:o}=e.tileID.canonical;this._implementation.unloadTile({x:t,y:i,z:o});}t();}abortTile(e,t){e.request&&e.request.cancel&&(e.request.cancel(),delete e.request),t();}hasTransition(){return !1}_coveringTiles(){return this._map.transform.coveringTiles({tileSize:this.tileSize,minzoom:this.minzoom,maxzoom:this.maxzoom,roundZoom:this.roundZoom}).map((e=>({x:e.canonical.x,y:e.canonical.y,z:e.canonical.z})))}_clearTiles(){this._map.style._clearSource(this.id);}_update(){this.fire(new e.Event(\"data\",{dataType:\"source\",sourceDataType:\"content\"}));}}},ze=function(t,i,o,r){const n=new Le[i.type](t,i,o,r);if(n.id!==t)throw new Error(`Expected Source id to be ${t} instead of ${n.id}`);return e.bindAll([\"load\",\"abort\",\"unload\",\"serialize\",\"prepare\"],n),n};function Pe(t,i){const o=e.identity([]);return e.scale(o,o,[.5*t.width,.5*-t.height,1]),e.translate(o,o,[1,-1,0]),e.multiply(o,o,t.calculateProjMatrix(i.toUnwrapped())),Float32Array.from(o)}function Re(e,t,i,o,r,n,s,a=!1){const l=e.tilesIn(o,s,a);l.sort(Be);const c=[];for(const o of l)c.push({wrappedTileID:o.tile.tileID.wrapped().key,queryResults:o.tile.queryRenderedFeatures(t,i,e._state,o,r,n,Pe(e.transform,o.tile.tileID),a)});const h=function(e){const t={},i={};for(const o of e){const e=o.queryResults,r=o.wrappedTileID,n=i[r]=i[r]||{};for(const i in e){const o=e[i],r=n[i]=n[i]||{},s=t[i]=t[i]||[];for(const e of o)r[e.featureIndex]||(r[e.featureIndex]=!0,s.push(e));}}return t}(c);for(const t in h)h[t].forEach((t=>{const i=t.feature,o=i.layer;o&&\"background\"!==o.type&&\"sky\"!==o.type&&(i.source=o.source,o[\"source-layer\"]&&(i.sourceLayer=o[\"source-layer\"]),i.state=void 0!==i.id?e.getFeatureState(o[\"source-layer\"],i.id):{});}));return h}function Oe(e,t){const i=e.getRenderableIds().map((t=>e.getTileByID(t))),o=[],r={};for(let e=0;e{e.terminate();})),this.workers=null);}isPreloaded(){return !!this.active[Fe]}numActive(){return Object.keys(this.active).length}}let Ne;function Ge(){return Ne||(Ne=new Ue),Ne}function je(t,i){const o={};for(const e in t)\"ref\"!==e&&(o[e]=t[e]);return e.refProperties.forEach((e=>{e in i&&(o[e]=i[e]);})),o}function Ze(e){e=e.slice();const t=Object.create(null);for(let i=0;i0?(r-s)/a:0;return this.points[n].mult(1-l).add(this.points[i].mult(l))}}class Qe{constructor(e,t,i){const o=this.boxCells=[],r=this.circleCells=[];this.xCellCount=Math.ceil(e/i),this.yCellCount=Math.ceil(t/i);for(let e=0;ethis.width||o<0||t>this.height)return !r&&[];const s=[];if(e<=0&&t<=0&&this.width<=i&&this.height<=o){if(r)return !0;for(let e=0;e0:s}_queryCircle(e,t,i,o,r){const n=e-i,s=e+i,a=t-i,l=t+i;if(s<0||n>this.width||l<0||a>this.height)return !o&&[];const c=[];return this._forEachCell(n,a,s,l,this._queryCellCircle,c,{hitTest:o,circle:{x:e,y:t,radius:i},seenUids:{box:{},circle:{}}},r),o?c.length>0:c}query(e,t,i,o,r){return this._query(e,t,i,o,!1,r)}hitTest(e,t,i,o,r){return this._query(e,t,i,o,!0,r)}hitTestCircle(e,t,i,o){return this._queryCircle(e,t,i,!0,o)}_queryCell(e,t,i,o,r,n,s,a){const l=s.seenUids,c=this.boxCells[r];if(null!==c){const r=this.bboxes;for(const h of c)if(!l.box[h]){l.box[h]=!0;const c=4*h;if(e<=r[c+2]&&t<=r[c+3]&&i>=r[c+0]&&o>=r[c+1]&&(!a||a(this.boxKeys[h]))){if(s.hitTest)return n.push(!0),!0;n.push({key:this.boxKeys[h],x1:r[c],y1:r[c+1],x2:r[c+2],y2:r[c+3]});}}}const h=this.circleCells[r];if(null!==h){const r=this.circles;for(const c of h)if(!l.circle[c]){l.circle[c]=!0;const h=3*c;if(this._circleAndRectCollide(r[h],r[h+1],r[h+2],e,t,i,o)&&(!a||a(this.circleKeys[c]))){if(s.hitTest)return n.push(!0),!0;{const e=r[h],t=r[h+1],i=r[h+2];n.push({key:this.circleKeys[c],x1:e-i,y1:t-i,x2:e+i,y2:t+i});}}}}}_queryCellCircle(e,t,i,o,r,n,s,a){const l=s.circle,c=s.seenUids,h=this.boxCells[r];if(null!==h){const e=this.bboxes;for(const t of h)if(!c.box[t]){c.box[t]=!0;const i=4*t;if(this._circleAndRectCollide(l.x,l.y,l.radius,e[i+0],e[i+1],e[i+2],e[i+3])&&(!a||a(this.boxKeys[t])))return n.push(!0),!0}}const u=this.circleCells[r];if(null!==u){const e=this.circles;for(const t of u)if(!c.circle[t]){c.circle[t]=!0;const i=3*t;if(this._circlesCollide(e[i],e[i+1],e[i+2],l.x,l.y,l.radius)&&(!a||a(this.circleKeys[t])))return n.push(!0),!0}}}_forEachCell(e,t,i,o,r,n,s,a){const l=this._convertToXCellCoord(e),c=this._convertToYCellCoord(t),h=this._convertToXCellCoord(i),u=this._convertToYCellCoord(o);for(let _=l;_<=h;_++)for(let l=c;l<=u;l++)if(r.call(this,e,t,i,o,this.xCellCount*l+_,n,s,a))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,o,r,n){const s=o-e,a=r-t,l=i+n;return l*l>s*s+a*a}_circleAndRectCollide(e,t,i,o,r,n,s){const a=(n-o)/2,l=Math.abs(e-(o+a));if(l>a+i)return !1;const c=(s-r)/2,h=Math.abs(t-(r+c));if(h>c+i)return !1;if(l<=a||h<=c)return !0;const u=l-a,_=h-c;return u*u+_*_<=i*i}}const et=Math.tan(85*Math.PI/180);function tt(t,i,o,r,n,s,a){const l=e.create();if(o)if(\"globe\"===s.name){const t=e.calculateGlobeLabelMatrix(n,i);e.multiply(l,l,t);}else {const t=v([],a);l[0]=t[0],l[1]=t[1],l[4]=t[2],l[5]=t[3],r||e.rotateZ(l,l,n.angle);}else e.multiply(l,n.labelPlaneMatrix,t);return l}function it(e,t,i,o,r,n,s){const a=tt(e,t,i,o,r,n,s);return \"globe\"===n.name&&i||(a[2]=a[6]=a[10]=a[14]=0),a}function ot(t,i,o,r,n,s,a){if(o){if(\"globe\"===s.name){const l=tt(t,i,o,r,n,s,a);return e.invert(l,l),e.multiply(l,t,l),l}{const i=e.clone(t),o=e.identity([]);return o[0]=a[0],o[1]=a[1],o[4]=a[2],o[5]=a[3],e.multiply(i,i,o),r||e.rotateZ(i,i,-n.angle),i}}return n.glCoordMatrix}function rt(t,i,o,r){const n=[t,i,o,1];o?e.transformMat4$1(n,n,r):mt(n,n,r);const s=n[3];return n[0]/=s,n[1]/=s,n[2]/=s,n}function nt(e,t){return Math.min(.5+e/t*.5,1.5)}function st(e,t){const i=e[0]/e[3],o=e[1]/e[3];return i>=-t[0]&&i<=t[0]&&o>=-t[1]&&o<=t[1]}function at(t,i,o,r,n,s,a,l,c,h){const u=o.transform,_=r?t.textSizeData:t.iconSizeData,d=e.evaluateSizeForZoom(_,o.transform.zoom),p=\"globe\"===u.projection.name,m=[256/o.width*2+1,256/o.height*2+1],f=r?t.text.dynamicLayoutVertexArray:t.icon.dynamicLayoutVertexArray;f.clear();let g=null;p&&(g=r?t.text.globeExtVertexArray:t.icon.globeExtVertexArray);const v=t.lineVertexArray,x=r?t.text.placedSymbolArray:t.icon.placedSymbolArray,y=o.transform.width/o.transform.height;let b,w=!1;for(let r=0;rMath.abs(o)?{useVertical:!0}:t===e.WritingMode.vertical?r>0?{needsFlipping:!0}:null:0!==i&&function(e,t){return 0===e||Math.abs(t/e)>et}(o,r)?1===i?{needsFlipping:!0}:null:o<0?{needsFlipping:!0}:null}function ht(t,i,o,r,n,s,a,l,c,h,u,_,d,p,m,f,g,v,x){const y=i/24,b=t.lineOffsetX*y,w=t.lineOffsetY*y,{lineStartIndex:T,glyphStartIndex:E,numGlyphs:C,segment:I,writingMode:M,flipState:S}=t,D=T+t.lineLength,A=t=>{if(u){const[i,o,r]=t.up,n=h.length;e.updateGlobeVertexNormal(u,n+0,i,o,r),e.updateGlobeVertexNormal(u,n+1,i,o,r),e.updateGlobeVertexNormal(u,n+2,i,o,r),e.updateGlobeVertexNormal(u,n+3,i,o,r);}const[i,o,r]=t.point;e.addDynamicAttributes(h,i,o,r,t.angle);};if(C>1){const e=lt(y,l,b,w,o,_,d,t,c,s,p,f,!1,g,v,x);if(!e)return {notEnoughRoom:!0};if(r&&!o){let[i,o,r]=e.first.point,[n,s,l]=e.last.point;[i,o]=rt(i,o,r,a),[n,s]=rt(n,s,l,a);const c=ct(M,S,(n-i)*m,s-o);if(t.flipState=c&&c.needsFlipping?1:2,c)return c}A(e.first);for(let e=E+1;e0?s:_t(d,r,i,1,n,void 0,g,v.canonical),l=ct(M,S,(a[0]-i[0])*m,a[1]-i[1]);if(t.flipState=l&&l.needsFlipping?1:2,l)return l}const i=dt(y*l.getoffsetX(E),b,w,o,_,d,I,T,D,c,s,p,f,!1,!1,g,v,x);if(!i)return {notEnoughRoom:!0};A(i);}return {}}function ut(e,t,i,o,r){const{x:n,y:s,z:a}=o.projectTilePoint(e.x,e.y,t);if(!r)return rt(n,s,a,i);const[l,c,h]=r(e);return rt(n+l,s+c,a+h,i)}function _t(t,i,o,r,n,s,a,l){const c=ut(t.sub(i)._unit()._add(t),l,n,a,s);return e.sub(c,o,c),e.normalize(c,c),e.scaleAndAdd(c,o,c,r)}function dt(t,i,o,r,n,s,a,l,c,h,u,_,d,p,m,f,g,v){const x=r?t-i:t+i;let y=x>0?1:-1,b=0;r&&(y*=-1,b=Math.PI),y<0&&(b+=Math.PI);let w=l+a+(y>0?0:1)|0,T=n,E=n,C=0,I=0;const M=Math.abs(x),S=[],D=[];let A=s,L=A;const z=()=>_t(L,A,E,M-C+1,u,d,f,g.canonical);for(;C+I<=M;){if(w+=y,w=c)return null;if(E=T,L=A,S.push(E),p&&D.push(L),A=new e.pointGeometry(h.getx(w),h.gety(w)),T=_[w],!T){const e=ut(A,g.canonical,u,f,d);T=e[3]>0?_[w]=e:z();}C+=I,I=e.distance(E,T);}m&&d&&(_[w]&&(T=z(),I=e.distance(E,T)),_[w]=T);const P=(M-C)/I,R=A.sub(L)._mult(P)._add(L),O=e.sub([],T,E),B=e.scaleAndAdd([],E,O,P);let k=[0,0,1],F=O[0],U=O[1];if(v&&(k=f.upVector(g.canonical,R.x,R.y),0!==k[0]||0!==k[1]||1!==k[2])){const t=[k[2],0,-k[0]],i=e.cross([],k,t);e.normalize(t,t),e.normalize(i,i),F=e.dot(O,t),U=e.dot(O,i);}if(o){const t=e.cross([],k,O);e.normalize(t,t),e.scaleAndAdd(B,B,t,o*y);}const N=b+Math.atan2(U,F);return S.push(B),p&&D.push(R),{point:B,angle:N,path:S,tilePath:D,up:k}}function pt(e,t){const i=t.length,o=i+4*e;t.resize(o),t.float32.fill(-1/0,4*i,4*o);}function mt(e,t,i){const o=t[0],r=t[1];return e[0]=i[0]*o+i[4]*r+i[12],e[1]=i[1]*o+i[5]*r+i[13],e[3]=i[3]*o+i[7]*r+i[15],e}const ft=100;class gt{constructor(e,t,i=new Qe(e.width+200,e.height+200,25),o=new Qe(e.width+200,e.height+200,25)){this.transform=e,this.grid=i,this.ignoredGrid=o,this.pitchfactor=Math.cos(e._pitch)*e.cameraToCenterDistance,this.screenRightBoundary=e.width+ft,this.screenBottomBoundary=e.height+ft,this.gridRightBoundary=e.width+200,this.gridBottomBoundary=e.height+200,this.fogState=t;}placeCollisionBox(e,t,i,o,r,n,s,a){let l=i.projectedAnchorX,c=i.projectedAnchorY,h=i.projectedAnchorZ;const u=i.elevation,_=i.tileID,d=e.getProjection();if(u&&_){const[e,t,o]=d.upVector(_.canonical,i.tileAnchorX,i.tileAnchorY),r=d.upVectorScale(_.canonical,this.transform.center.lat,this.transform.worldSize).metersToTile;l+=e*u*r,c+=t*u*r,h+=o*u*r;}const p=this.projectAndGetPerspectiveRatio(s,l,c,h,i.tileID,\"globe\"===d.name||!!u||this.transform.pitch>0,d),m=n*p.perspectiveRatio,f=(i.x1*t+o.x-i.padding)*m+p.point.x,g=(i.y1*t+o.y-i.padding)*m+p.point.y,v=(i.x2*t+o.x+i.padding)*m+p.point.x,x=(i.y2*t+o.y+i.padding)*m+p.point.y,y=p.perspectiveRatio<=.55||p.occluded;return !this.isInsideGrid(f,g,v,x)||!r&&this.grid.hitTest(f,g,v,x,a)||y?{box:[],offscreen:!1,occluded:p.occluded}:{box:[f,g,v,x],offscreen:this.isOffscreen(f,g,v,x),occluded:!1}}placeCollisionCircles(t,i,o,r,n,s,a,l,c,h,u,_,d,p,m){const f=[],g=this.transform.elevation,v=t.getProjection(),x=g?g.getAtTileOffsetFunc(m,this.transform.center.lat,this.transform.worldSize,v):null,y=new e.pointGeometry(o.tileAnchorX,o.tileAnchorY);let{x:b,y:w,z:T}=v.projectTilePoint(y.x,y.y,m.canonical);if(x){const[e,t,i]=x(y);b+=e,w+=t,T+=i;}const E=\"globe\"===v.name,C=this.projectAndGetPerspectiveRatio(a,b,w,T,m,E||!!g||this.transform.pitch>0,v),{perspectiveRatio:I}=C,M=(u?s/I:s*I)/e.ONE_EM,S=rt(b,w,T,l),D=C.signedDistanceFromCamera>0?lt(M,n,o.lineOffsetX*M,o.lineOffsetY*M,!1,S,y,o,r,l,{},g&&!u?x:null,u&&!!g,v,m,u):null;let A=!1,L=!1,z=!0;if(D&&!C.occluded){const t=.5*d*I+p,o=new e.pointGeometry(-100,-100),r=new e.pointGeometry(this.screenRightBoundary,this.screenBottomBoundary),n=new Je,{first:s,last:a}=D,l=s.path.length;let u=[];for(let e=l-1;e>=1;e--)u.push(s.path[e]);for(let e=1;e(x&&!E&&(i=x(oe[3]<=0))&&(u=[]));let g=[];if(u.length>0){let t=1/0,i=-1/0,n=1/0,s=-1/0;for(const e of u)t=Math.min(t,e[0]),n=Math.min(n,e[1]),i=Math.max(i,e[0]),s=Math.max(s,e[1]);i>=o.x&&t<=r.x&&s>=o.y&&n<=r.y&&(g=[u.map((t=>new e.pointGeometry(t[0],t[1])))],(tr.x||nr.y)&&(g=e.clipLine(g,o.x,o.y,r.x,r.y)));}for(const e of g){n.reset(e,.25*t);let o=0;o=n.length<=.5*t?1:Math.ceil(n.paddedLength/m)+1;for(let e=0;e0){e.transformMat4$1(l,l,t);const s=\"globe\"===a.name;if(this.fogState&&n&&!s){const t=function(t,i,o,r,n,s){const a=s.calculateFogTileMatrix(n),l=[i,o,r];return e.transformMat4(l,l,a),M(t,l,s.pitch,s._fov)}(this.fogState,i,o,r,n.toUnwrapped(),this.transform);c=t>.9;}}else mt(l,l,t);const h=l[3];return {point:new e.pointGeometry((l[0]/h+1)/2*this.transform.width+ft,(-l[1]/h+1)/2*this.transform.height+ft),perspectiveRatio:Math.min(.5+this.transform.getCameraToCenterDistance(a)/h*.5,1.5),signedDistanceFromCamera:h,occluded:s&&l[2]>h||c}}isOffscreen(e,t,i,o){return i=this.screenRightBoundary||othis.screenBottomBoundary}isInsideGrid(e,t,i,o){return i>=0&&e=0&&te.collisionGroupID===t};}return this.collisionGroups[e]}}function Mt(t,i,o,r,n){const{horizontalAlign:s,verticalAlign:a}=e.getAnchorAlignment(t),l=-(s-.5)*i,c=-(a-.5)*o,h=e.evaluateVariableOffset(t,r);return new e.pointGeometry(l+h[0]*n,c+h[1]*n)}function St(t,i,o,r,n){const s=new e.pointGeometry(t,i);return o&&s._rotate(r?n:-n),s}class Dt{constructor(e,t,i,o,r){this.transform=e.clone(),this.projection=e.projection.name,this.collisionIndex=new gt(this.transform,r),this.placements={},this.opacities={},this.variableOffsets={},this.stale=!1,this.commitTime=0,this.fadeDuration=t,this.retainedQueryData={},this.collisionGroups=new It(i),this.collisionCircleArrays={},this.prevPlacement=o,o&&(o.prevPlacement=void 0),this.placedOrientations={};}getBucketParts(t,i,o,r){const n=o.getBucket(i),s=o.latestFeatureIndex;if(!n||!s||i.id!==n.layerIds[0])return;const a=n.layers[0].layout,l=o.collisionBoxArray,c=Math.pow(2,this.transform.zoom-o.tileID.overscaledZ),h=o.tileSize/e.EXTENT,u=o.tileID.toUnwrapped();this.transform.setProjection(n.projection);const _=(d=o.tileID,p=n.getProjection(),m=this.transform,p.name===this.projection?m.calculateProjMatrix(d.toUnwrapped()):vt(m,p,d));var d,p,m;const f=\"map\"===a.get(\"text-pitch-alignment\"),g=\"map\"===a.get(\"text-rotation-alignment\");i.compileFilter();const v=i.dynamicFilter(),x=i.dynamicFilterNeedsFeature(),y=this.transform.calculatePixelsToTileUnitsMatrix(o),b=it(_,o.tileID.canonical,f,g,this.transform,n.getProjection(),y);let w=null;if(f){const t=ot(_,o.tileID.canonical,f,g,this.transform,n.getProjection(),y);w=e.multiply([],this.transform.labelPlaneMatrix,t);}let T=null;v&&o.latestFeatureIndex&&(T={unwrappedTileID:u,dynamicFilter:v,dynamicFilterNeedsFeature:x,featureIndex:o.latestFeatureIndex}),this.retainedQueryData[n.bucketInstanceId]=new Ct(n.bucketInstanceId,s,n.sourceLayerIndex,n.index,o.tileID);const E={bucket:n,layout:a,posMatrix:_,textLabelPlaneMatrix:b,labelToScreenMatrix:w,clippingData:T,scale:c,textPixelRatio:h,holdingForFade:o.holdingForFade(),collisionBoxArray:l,partiallyEvaluatedTextSize:e.evaluateSizeForZoom(n.textSizeData,this.transform.zoom),partiallyEvaluatedIconSize:e.evaluateSizeForZoom(n.iconSizeData,this.transform.zoom),collisionGroup:this.collisionGroups.get(n.sourceID)};if(r)for(const e of n.sortKeyRanges){const{sortKey:i,symbolInstanceStart:o,symbolInstanceEnd:r}=e;t.push({sortKey:i,symbolInstanceStart:o,symbolInstanceEnd:r,parameters:E});}else t.push({symbolInstanceStart:0,symbolInstanceEnd:n.symbolInstances.length,parameters:E});}attemptAnchorPlacement(e,t,i,o,r,n,s,a,l,c,h,u,_,d,p,m,f,g){const{textOffset0:v,textOffset1:x,crossTileID:y}=u,b=[v,x],w=Mt(e,i,o,b,r),T=this.collisionIndex.placeCollisionBox(d,r,t,St(w.x,w.y,n,s,this.transform.angle),h,a,l,c.predicate);if(m){const e=d.getSymbolInstanceIconSize(g,this.transform.zoom,u.placedIconSymbolIndex);if(0===this.collisionIndex.placeCollisionBox(d,e,m,St(w.x,w.y,n,s,this.transform.angle),h,a,l,c.predicate).box.length)return}if(T.box.length>0){let t;return this.prevPlacement&&this.prevPlacement.variableOffsets[y]&&this.prevPlacement.placements[y]&&this.prevPlacement.placements[y].text&&(t=this.prevPlacement.variableOffsets[y].anchor),this.variableOffsets[y]={textOffset:b,width:i,height:o,anchor:e,textScale:r,prevAnchor:t},this.markUsedJustification(d,e,u,p),d.allowVerticalPlacement&&(this.markUsedOrientation(d,p,u),this.placedOrientations[y]=p),{shift:w,placedGlyphBoxes:T}}}placeLayerBucketPart(t,i,o,r){const{bucket:n,layout:s,posMatrix:a,textLabelPlaneMatrix:l,labelToScreenMatrix:c,clippingData:h,textPixelRatio:u,holdingForFade:_,collisionBoxArray:d,partiallyEvaluatedTextSize:p,partiallyEvaluatedIconSize:m,collisionGroup:f}=t.parameters,g=s.get(\"text-optional\"),v=s.get(\"icon-optional\"),x=s.get(\"text-allow-overlap\"),y=s.get(\"icon-allow-overlap\"),b=\"map\"===s.get(\"text-rotation-alignment\"),w=\"map\"===s.get(\"text-pitch-alignment\"),T=\"none\"!==s.get(\"icon-text-fit\"),E=\"viewport-y\"===s.get(\"symbol-z-order\");this.transform.setProjection(n.projection);let C=x&&(y||!n.hasIconData()||v),I=y&&(x||!n.hasTextData()||g);!n.collisionArrays&&d&&n.deserializeCollisionBoxes(d),o&&r&&n.updateCollisionDebugBuffers(this.transform.zoom,d);const M=(t,r,d)=>{const{crossTileID:E,numVerticalGlyphVertices:M}=t;if(h){const o={zoom:this.transform.zoom,pitch:this.transform.pitch};let r=null;if(h.dynamicFilterNeedsFeature){const e=this.retainedQueryData[n.bucketInstanceId];r=h.featureIndex.loadFeature({featureIndex:t.featureIndex,bucketIndex:e.bucketIndex,sourceLayerIndex:e.sourceLayerIndex,layoutVertexArrayOffset:0});}if(!(0,h.dynamicFilter)(o,r,this.retainedQueryData[n.bucketInstanceId].tileID.canonical,new e.pointGeometry(t.tileAnchorX,t.tileAnchorY),this.transform.calculateDistanceTileData(h.unwrappedTileID)))return this.placements[E]=new Tt(!1,!1,!1,!0),void(i[E]=!0)}if(i[E])return;if(_)return void(this.placements[E]=new Tt(!1,!1,!1));let S=!1,D=!1,A=!0,L=!1,z=!1,P=null,R={box:null,offscreen:null,occluded:null},O={box:null,offscreen:null,occluded:null},B=null,k=null,F=null,U=0,N=0,G=0;d.textFeatureIndex?U=d.textFeatureIndex:t.useRuntimeCollisionCircles&&(U=t.featureIndex),d.verticalTextFeatureIndex&&(N=d.verticalTextFeatureIndex);const j=e=>{e.tileID=this.retainedQueryData[n.bucketInstanceId].tileID;const t=this.transform.elevation;(t||e.elevation)&&(e.elevation=t?t.getAtTileOffset(e.tileID,e.tileAnchorX,e.tileAnchorY):0);},Z=d.textBox;if(Z){j(Z);const i=i=>{let o=e.WritingMode.horizontal;if(n.allowVerticalPlacement&&!i&&this.prevPlacement){const e=this.prevPlacement.placedOrientations[E];e&&(this.placedOrientations[E]=e,o=e,this.markUsedOrientation(n,o,t));}return o},o=(t,i)=>{if(n.allowVerticalPlacement&&M>0&&d.verticalTextBox){for(const o of n.writingModes)if(o===e.WritingMode.vertical?(R=i(),O=R):R=t(),R&&R.box&&R.box.length)break}else R=t();};if(s.get(\"text-variable-anchor\")){let l=s.get(\"text-variable-anchor\");if(this.prevPlacement&&this.prevPlacement.variableOffsets[E]){const e=this.prevPlacement.variableOffsets[E];l.indexOf(e.anchor)>0&&(l=l.filter((t=>t!==e.anchor)),l.unshift(e.anchor));}const c=(e,i,o)=>{const s=n.getSymbolInstanceTextSize(p,t,this.transform.zoom,r),c=(e.x2-e.x1)*s+2*e.padding,h=(e.y2-e.y1)*s+2*e.padding,_=T&&!y?i:null;_&&j(_);let d={box:[],offscreen:!1,occluded:!1};const g=x?2*l.length:l.length;for(let i=0;i=l.length,t,r,n,o,_,p,m);if(g&&(d=g.placedGlyphBoxes,d&&d.box&&d.box.length)){S=!0,P=g.shift;break}}return d};o((()=>c(Z,d.iconBox,e.WritingMode.horizontal)),(()=>{const t=d.verticalTextBox;return t&&j(t),n.allowVerticalPlacement&&!(R&&R.box&&R.box.length)&&M>0&&t?c(t,d.verticalIconBox,e.WritingMode.vertical):{box:null,offscreen:null,occluded:null}})),R&&(S=R.box,A=R.offscreen,L=R.occluded);const h=i(R&&R.box);if(!S&&this.prevPlacement){const e=this.prevPlacement.variableOffsets[E];e&&(this.variableOffsets[E]=e,this.markUsedJustification(n,e.anchor,t,h));}}else {const s=(i,o)=>{const s=n.getSymbolInstanceTextSize(p,t,this.transform.zoom,r),l=this.collisionIndex.placeCollisionBox(n,s,i,new e.pointGeometry(0,0),x,u,a,f.predicate);return l&&l.box&&l.box.length&&(this.markUsedOrientation(n,o,t),this.placedOrientations[E]=o),l};o((()=>s(Z,e.WritingMode.horizontal)),(()=>{const t=d.verticalTextBox;return n.allowVerticalPlacement&&M>0&&t?(j(t),s(t,e.WritingMode.vertical)):{box:null,offscreen:null,occluded:null}})),i(R&&R.box&&R.box.length);}}if(B=R,S=B&&B.box&&B.box.length>0,A=B&&B.offscreen,L=B&&B.occluded,t.useRuntimeCollisionCircles){const i=n.text.placedSymbolArray.get(t.centerJustifiedTextSymbolIndex>=0?t.centerJustifiedTextSymbolIndex:t.verticalPlacedTextSymbolIndex),r=e.evaluateSizeForFeature(n.textSizeData,p,i),h=s.get(\"text-padding\");k=this.collisionIndex.placeCollisionCircles(n,x,i,n.lineVertexArray,n.glyphOffsetArray,r,a,l,c,o,w,f.predicate,t.collisionCircleDiameter*r/e.ONE_EM,h,this.retainedQueryData[n.bucketInstanceId].tileID),S=x||k.circles.length>0&&!k.collisionDetected,A=A&&k.offscreen,L=k.occluded;}if(d.iconFeatureIndex&&(G=d.iconFeatureIndex),d.iconBox){const i=i=>{j(i);const o=T&&P?St(P.x,P.y,b,w,this.transform.angle):new e.pointGeometry(0,0),r=n.getSymbolInstanceIconSize(m,this.transform.zoom,t.placedIconSymbolIndex);return this.collisionIndex.placeCollisionBox(n,r,i,o,y,u,a,f.predicate)};O&&O.box&&O.box.length&&d.verticalIconBox?(F=i(d.verticalIconBox),D=F.box.length>0):(F=i(d.iconBox),D=F.box.length>0),A=A&&F.offscreen,z=F.occluded;}const V=g||0===t.numHorizontalGlyphVertices&&0===M,W=v||0===t.numIconVertices;if(V||W?W?V||(D=D&&S):S=D&&S:D=S=D&&S,S&&B&&B.box&&this.collisionIndex.insertCollisionBox(B.box,s.get(\"text-ignore-placement\"),n.bucketInstanceId,O&&O.box&&N?N:U,f.ID),D&&F&&this.collisionIndex.insertCollisionBox(F.box,s.get(\"icon-ignore-placement\"),n.bucketInstanceId,G,f.ID),k&&(S&&this.collisionIndex.insertCollisionCircles(k.circles,s.get(\"text-ignore-placement\"),n.bucketInstanceId,U,f.ID),o)){const e=n.bucketInstanceId;let t=this.collisionCircleArrays[e];void 0===t&&(t=this.collisionCircleArrays[e]=new Et);for(let e=0;e=0;--t){const i=e[t];M(n.symbolInstances.get(i),i,n.collisionArrays[i]);}}else for(let e=t.symbolInstanceStart;e=0&&(t.text.placedSymbolArray.get(n).crossTileID=u>=0&&n!==u?0:c),s>=0&&(t.text.placedSymbolArray.get(s).crossTileID=u>=0&&s!==u?0:c),a>=0&&(t.text.placedSymbolArray.get(a).crossTileID=u>=0&&a!==u?0:c),l>=0&&(t.text.placedSymbolArray.get(l).crossTileID=u>=0&&l!==u?0:c);}markUsedOrientation(t,i,o){const r=i===e.WritingMode.horizontal||i===e.WritingMode.horizontalOnly?i:0,n=i===e.WritingMode.vertical?i:0,{leftJustifiedTextSymbolIndex:s,centerJustifiedTextSymbolIndex:a,rightJustifiedTextSymbolIndex:l,verticalPlacedTextSymbolIndex:c}=o,h=t.text.placedSymbolArray;s>=0&&(h.get(s).placedOrientation=r),a>=0&&(h.get(a).placedOrientation=r),l>=0&&(h.get(l).placedOrientation=r),c>=0&&(h.get(c).placedOrientation=n);}commit(e){this.commitTime=e,this.zoomAtLastRecencyCheck=this.transform.zoom;const t=this.prevPlacement;let i=!1;this.prevZoomAdjustment=t?t.zoomAdjustment(this.transform.zoom):0;const o=t?t.symbolFadeChange(e):1,r=t?t.opacities:{},n=t?t.variableOffsets:{},s=t?t.placedOrientations:{};for(const e in this.placements){const t=this.placements[e],n=r[e];n?(this.opacities[e]=new wt(n,o,t.text,t.icon,null,t.clipped),i=i||t.text!==n.text.placed||t.icon!==n.icon.placed):(this.opacities[e]=new wt(null,o,t.text,t.icon,t.skipFade,t.clipped),i=i||t.text||t.icon);}for(const e in r){const t=r[e];if(!this.opacities[e]){const r=new wt(t,o,!1,!1);r.isHidden()||(this.opacities[e]=r,i=i||t.text.placed||t.icon.placed);}}for(const e in n)this.variableOffsets[e]||!this.opacities[e]||this.opacities[e].isHidden()||(this.variableOffsets[e]=n[e]);for(const e in s)this.placedOrientations[e]||!this.opacities[e]||this.opacities[e].isHidden()||(this.placedOrientations[e]=s[e]);i?this.lastPlacementChangeTime=e:\"number\"!=typeof this.lastPlacementChangeTime&&(this.lastPlacementChangeTime=t?t.lastPlacementChangeTime:e);}updateLayerOpacities(e,t){const i={};for(const o of t){const t=o.getBucket(e);t&&o.latestFeatureIndex&&e.id===t.layerIds[0]&&this.updateBucketOpacities(t,i,o.collisionBoxArray);}}updateBucketOpacities(t,i,o){t.hasTextData()&&t.text.opacityVertexArray.clear(),t.hasIconData()&&t.icon.opacityVertexArray.clear(),t.hasIconCollisionBoxData()&&t.iconCollisionBox.collisionVertexArray.clear(),t.hasTextCollisionBoxData()&&t.textCollisionBox.collisionVertexArray.clear();const r=t.layers[0].layout,n=!!t.layers[0].dynamicFilter(),s=new wt(null,0,!1,!1,!0),a=r.get(\"text-allow-overlap\"),l=r.get(\"icon-allow-overlap\"),c=r.get(\"text-variable-anchor\"),h=\"map\"===r.get(\"text-rotation-alignment\"),u=\"map\"===r.get(\"text-pitch-alignment\"),_=\"none\"!==r.get(\"icon-text-fit\"),d=new wt(null,0,a&&(l||!t.hasIconData()||r.get(\"icon-optional\")),l&&(a||!t.hasTextData()||r.get(\"text-optional\")),!0);!t.collisionArrays&&o&&(t.hasIconCollisionBoxData()||t.hasTextCollisionBoxData())&&t.deserializeCollisionBoxes(o);const p=(e,t,i)=>{for(let o=0;o0||l>0,y=g>0,b=this.placedOrientations[f],w=b===e.WritingMode.vertical,T=b===e.WritingMode.horizontal||b===e.WritingMode.horizontalOnly;if(!x&&!y||v.isHidden()||m++,x){const e=Ft(v.text);p(t.text,a,w?Ut:e),p(t.text,l,T?Ut:e);const i=v.text.isHidden(),{leftJustifiedTextSymbolIndex:o,centerJustifiedTextSymbolIndex:n,rightJustifiedTextSymbolIndex:s,verticalPlacedTextSymbolIndex:c}=r,h=t.text.placedSymbolArray,u=i||w?1:0;o>=0&&(h.get(o).hidden=u),n>=0&&(h.get(n).hidden=u),s>=0&&(h.get(s).hidden=u),c>=0&&(h.get(c).hidden=i||T?1:0);const _=this.variableOffsets[f];_&&this.markUsedJustification(t,_.anchor,r,b);const d=this.placedOrientations[f];d&&(this.markUsedJustification(t,\"left\",r,d),this.markUsedOrientation(t,d,r));}if(y){const e=Ft(v.icon),{placedIconSymbolIndex:i,verticalPlacedIconSymbolIndex:o}=r,n=t.icon.placedSymbolArray,s=v.icon.isHidden()?1:0;i>=0&&(p(t.icon,g,w?Ut:e),n.get(i).hidden=s),o>=0&&(p(t.icon,r.numVerticalIconVertices,T?Ut:e),n.get(o).hidden=s);}if(t.hasIconCollisionBoxData()||t.hasTextCollisionBoxData()){const i=t.collisionArrays[o];if(i){let o=new e.pointGeometry(0,0),r=!0;if(i.textBox||i.verticalTextBox){if(c){const e=this.variableOffsets[f];e?(o=Mt(e.anchor,e.width,e.height,e.textOffset,e.textScale),h&&o._rotate(u?this.transform.angle:-this.transform.angle)):r=!1;}n&&(r=!v.clipped),i.textBox&&At(t.textCollisionBox.collisionVertexArray,v.text.placed,!r||w,o.x,o.y),i.verticalTextBox&&At(t.textCollisionBox.collisionVertexArray,v.text.placed,!r||T,o.x,o.y);}const s=r&&Boolean(!T&&i.verticalIconBox);i.iconBox&&At(t.iconCollisionBox.collisionVertexArray,v.icon.placed,s,_?o.x:0,_?o.y:0),i.verticalIconBox&&At(t.iconCollisionBox.collisionVertexArray,v.icon.placed,!s,_?o.x:0,_?o.y:0);}}}if(t.fullyClipped=0===m,t.sortFeatures(this.transform.angle),this.retainedQueryData[t.bucketInstanceId]&&(this.retainedQueryData[t.bucketInstanceId].featureSortOrder=t.featureSortOrder),t.hasTextData()&&t.text.opacityVertexBuffer&&t.text.opacityVertexBuffer.updateData(t.text.opacityVertexArray),t.hasIconData()&&t.icon.opacityVertexBuffer&&t.icon.opacityVertexBuffer.updateData(t.icon.opacityVertexArray),t.hasIconCollisionBoxData()&&t.iconCollisionBox.collisionVertexBuffer&&t.iconCollisionBox.collisionVertexBuffer.updateData(t.iconCollisionBox.collisionVertexArray),t.hasTextCollisionBoxData()&&t.textCollisionBox.collisionVertexBuffer&&t.textCollisionBox.collisionVertexBuffer.updateData(t.textCollisionBox.collisionVertexArray),t.bucketInstanceId in this.collisionCircleArrays){const e=this.collisionCircleArrays[t.bucketInstanceId];t.placementInvProjMatrix=e.invProjMatrix,t.placementViewportMatrix=e.viewportMatrix,t.collisionCircleArray=e.circles,delete this.collisionCircleArrays[t.bucketInstanceId];}}symbolFadeChange(e){return 0===this.fadeDuration?1:(e-this.commitTime)/this.fadeDuration+this.prevZoomAdjustment}zoomAdjustment(e){return Math.max(0,(this.transform.zoom-e)/1.5)}hasTransitions(e){return this.stale||e-this.lastPlacementChangeTimee}setStale(){this.stale=!0;}}function At(e,t,i,o,r){e.emplaceBack(t?1:0,i?1:0,o||0,r||0),e.emplaceBack(t?1:0,i?1:0,o||0,r||0),e.emplaceBack(t?1:0,i?1:0,o||0,r||0),e.emplaceBack(t?1:0,i?1:0,o||0,r||0);}const Lt=Math.pow(2,25),zt=Math.pow(2,24),Pt=Math.pow(2,17),Rt=Math.pow(2,16),Ot=Math.pow(2,9),Bt=Math.pow(2,8),kt=Math.pow(2,1);function Ft(e){if(0===e.opacity&&!e.placed)return 0;if(1===e.opacity&&e.placed)return 4294967295;const t=e.placed?1:0,i=Math.floor(127*e.opacity);return i*Lt+t*zt+i*Pt+t*Rt+i*Ot+t*Bt+i*kt+t}const Ut=0;class Nt{constructor(e){this._sortAcrossTiles=\"viewport-y\"!==e.layout.get(\"symbol-z-order\")&&void 0!==e.layout.get(\"symbol-sort-key\").constantOr(1),this._currentTileIndex=0,this._currentPartIndex=0,this._seenCrossTileIDs={},this._bucketParts=[];}continuePlacement(e,t,i,o,r){const n=this._bucketParts;for(;this._currentTileIndexe.sortKey-t.sortKey)));this._currentPartIndex