sagadeck 1.7.1 → 1.9.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +55 -4
- package/SKILL.md +10 -3
- package/bin/sagadeck.js +23 -0
- package/docs/ANDAMENTO.md +483 -1
- package/docs/PLANO-MELHORIAS.md +180 -0
- package/docs/REFERENCIA.md +184 -105
- package/package.json +34 -2
- package/src/ai/commands.js +2 -2
- package/src/ai/deck-ai.js +14 -5
- package/src/ai/ia-check.js +127 -0
- package/src/ai/ia-config.js +2 -2
- package/src/ai/llm.js +5 -1
- package/src/ai/map-analysis-run.js +119 -0
- package/src/ai/map-data.js +221 -0
- package/src/ai/quality.js +1 -1
- package/src/ai/video-generation.js +70 -25
- package/src/build.js +51 -15
- package/src/elements.js +39 -1
- package/src/export/browser.js +23 -1
- package/src/export/pptx.js +9 -3
- package/src/export/shots.js +10 -3
- package/src/fiscal/normalize.js +19 -0
- package/src/fs-retry.js +37 -2
- package/src/import/office.js +5 -4
- package/src/layouts.js +114 -99
- package/src/lessons.js +1 -1
- package/src/library.js +7 -7
- package/src/map-analysis.js +109 -0
- package/src/map-config.js +89 -0
- package/src/map-routing.js +82 -0
- package/src/map-services.js +60 -0
- package/src/map.js +274 -0
- package/src/mcp/server.js +17 -0
- package/src/motion.js +20 -6
- package/src/purpose.js +1 -1
- package/src/runtime/base.css +105 -329
- package/src/runtime/fit.js +3 -2
- package/src/runtime/fonts/amatic-sc.css +3 -0
- package/src/runtime/fonts/bebas-neue.css +2 -0
- package/src/runtime/fonts/cabin-sketch.css +2 -0
- package/src/runtime/fonts/fraunces.css +3 -0
- package/src/runtime/fonts/gelasio.css +3 -0
- package/src/runtime/fonts/ibm-plex-mono.css +4 -0
- package/src/runtime/fonts/index.json +10 -1
- package/src/runtime/fonts/itim.css +2 -0
- package/src/runtime/fonts/montserrat.css +2 -0
- package/src/runtime/fonts/space-grotesk.css +2 -0
- package/src/runtime/map-background.js +91 -0
- package/src/runtime/map.js +266 -0
- package/src/runtime/runtime.js +81 -100
- package/src/runtime/skins/caderno.css +33 -0
- package/src/runtime/skins/cartaz.css +27 -0
- package/src/runtime/skins/infografico.css +29 -0
- package/src/runtime/skins/lousa.css +22 -0
- package/src/runtime/skins/musgo.css +42 -0
- package/src/runtime/vendor/LEAFLET-LICENSE.txt +26 -0
- package/src/runtime/vendor/MAPLIBRE-LEAFLET-LICENSE.txt +15 -0
- package/src/runtime/vendor/MAPLIBRE-LICENSE.txt +116 -0
- package/src/runtime/vendor/geo-contornos.json +1 -0
- package/src/runtime/vendor/leaflet.css +661 -0
- package/src/runtime/vendor/leaflet.js +6 -0
- package/src/runtime/vendor/maplibre-gl.css +1 -0
- package/src/runtime/vendor/maplibre-gl.js +825 -0
- package/src/runtime/vendor/maplibre-leaflet.js +234 -0
- package/src/runtime/vendor/maplibre-worker.js +10 -0
- package/src/studio/ai-chat-route.js +20 -0
- package/src/studio/assets/imagens/tour-mapa-botao.jpg +0 -0
- package/src/studio/assets/imagens/tour-mapa-editor.jpg +0 -0
- package/src/studio/command-approval.js +2 -3
- package/src/studio/demo-decks.js +6 -2
- package/src/studio/export-jobs.js +86 -0
- package/src/studio/exporting.js +36 -18
- package/src/studio/feature-demos.js +144 -0
- package/src/studio/geo-routes.js +138 -0
- package/src/studio/ia-routes.js +9 -0
- package/src/studio/layout-samples.js +78 -16
- package/src/studio/library-routes.js +0 -9
- package/src/studio/project.js +2 -1
- package/src/studio/public/ai-settings.js +6 -3
- package/src/studio/public/app.js +46 -52
- package/src/studio/public/explorer.js +23 -8
- package/src/studio/public/export-status.js +154 -0
- package/src/studio/public/index.html +17 -10
- package/src/studio/public/library.css +12 -3
- package/src/studio/public/library.html +3 -0
- package/src/studio/public/library.js +39 -12
- package/src/studio/public/map-data.js +158 -0
- package/src/studio/public/map-editor.js +676 -0
- package/src/studio/public/map-fields.js +21 -0
- package/src/studio/public/map-settings.js +86 -0
- package/src/studio/public/slide-form.js +19 -16
- package/src/studio/public/style.css +58 -0
- package/src/studio/public/ui-icons.js +1 -1
- package/src/studio/public/viewers.js +2 -1
- package/src/studio/public/visual-editor.js +1 -1
- package/src/studio/server.js +34 -9
- package/src/studio/snapshot.js +8 -4
- package/src/studio/template-collections.js +1 -1
- package/src/studio/tour.js +158 -0
- package/src/themes.js +154 -0
- package/templates/cenario-e-ciencia.yaml +1 -21
- package/templates/ensaio-api.yaml +3 -3
- package/templates/cenario/Texto no cen/303/241rio.yaml" +0 -171
- package/templates/cenario/imagens/cidade.svg +0 -30
- package/templates/cenario/imagens/pessoa.svg +0 -15
|
@@ -0,0 +1,825 @@
|
|
|
1
|
+
var maplibregl=(()=>{var Au=Object.defineProperty;var rb=Object.getOwnPropertyDescriptor;var ab=Object.getOwnPropertyNames;var nb=Object.prototype.hasOwnProperty;var ob=(e,t)=>{for(var i in t)Au(e,i,{get:t[i],enumerable:!0})},sb=(e,t,i,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let a of ab(t))!nb.call(e,a)&&a!==i&&Au(e,a,{get:()=>t[a],enumerable:!(r=rb(t,a))||r.enumerable});return e};var lb=e=>sb(Au({},"__esModule",{value:!0}),e);var xk={};ob(xk,{AJAXError:()=>Yn,AttributionControl:()=>Ux,BoxZoomHandler:()=>Ix,CanvasSource:()=>iv,CooperativeGesturesHandler:()=>Vx,DoubleClickZoomHandler:()=>Lx,DragPanHandler:()=>Bx,DragRotateHandler:()=>Ox,EXTENT:()=>k,EdgeInsets:()=>ad,ErrorEvent:()=>Y,Event:()=>li,Evented:()=>ht,FullscreenControl:()=>ik,FullscreenEvent:()=>cd,GPUInitializationError:()=>Px,GeoJSONSource:()=>K1,GeolocateControl:()=>KR,GeolocateErrorEvent:()=>Xx,GeolocateEvent:()=>Vr,GeolocatePositionEvent:()=>hd,GlobeControl:()=>ak,Hash:()=>Ax,ImageSource:()=>an,KeyboardHandler:()=>Rx,LngLat:()=>X,LngLatBounds:()=>zi,LogoControl:()=>$x,Map:()=>$R,MapBoxZoomEvent:()=>Rh,MapContextEvent:()=>Fs,MapLibreEvent:()=>gt,MapLibreMap:()=>$R,MapMouseEvent:()=>Xt,MapMovementEvent:()=>Q,MapProjectionEvent:()=>K_,MapSourceDataEvent:()=>Ne,MapStyleDataEvent:()=>_i,MapStyleImageMissingEvent:()=>J_,MapStyleLoadEvent:()=>zh,MapTerrainEvent:()=>Y_,MapTouchEvent:()=>In,MapWheelEvent:()=>X_,Marker:()=>ud,MarkerClickEvent:()=>Hx,MarkerDragEvent:()=>jr,MercatorCoordinate:()=>De,NavigationControl:()=>ZR,Point:()=>C,Popup:()=>sk,PopupEvent:()=>dd,RasterDEMTileSource:()=>X1,RasterTileSource:()=>op,ScaleControl:()=>QR,ScrollZoomHandler:()=>kx,Style:()=>od,TerrainControl:()=>rk,TwoFingersTouchPitchHandler:()=>zx,TwoFingersTouchRotateHandler:()=>Fx,TwoFingersTouchZoomHandler:()=>Mx,TwoFingersTouchZoomRotateHandler:()=>jx,VectorTileSource:()=>H1,VideoSource:()=>tv,addProtocol:()=>_w,addSourceType:()=>aA,clearPrewarmedResources:()=>CP,config:()=>si,createTileMesh:()=>Q1,getGlobalDispatcher:()=>np,getMaxParallelImageRequests:()=>mk,getRTLTextPluginStatus:()=>ck,getVersion:()=>dk,getWorkerCount:()=>pk,getWorkerUrl:()=>_k,importScriptInWorkers:()=>vk,isTimeFrozen:()=>dw,now:()=>Ie,prewarm:()=>SP,removeProtocol:()=>yw,restoreNow:()=>cw,setMaxParallelImageRequests:()=>gk,setNow:()=>hw,setRTLTextPlugin:()=>hk,setWorkerCount:()=>fk,setWorkerUrl:()=>yk});var ub=Object.create,M_=Object.defineProperty,hb=Object.getOwnPropertyDescriptor,cb=Object.getOwnPropertyNames,db=Object.getPrototypeOf,F_=Object.prototype.hasOwnProperty,pd=(e,t)=>()=>(t||(e((t={exports:{}}).exports,t),e=null),t.exports),pb=(e,t,i,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(var a=cb(t),n=0,o=a.length,s;n<o;n++)s=a[n],!F_.call(e,s)&&s!==i&&M_(e,s,{get:(l=>t[l]).bind(null,s),enumerable:!(r=hb(t,s))||r.enumerable});return e},fb=(e,t,i)=>(i=e==null?{}:ub(db(e)),pb(t||!e||!e.__esModule||!F_.call(e,"default")?M_(i,"default",{value:e,enumerable:!0}):i,e)),fd="6.13.0";function C(e,t){this.x=e,this.y=t}C.prototype={clone(){return new C(this.x,this.y)},add(e){return this.clone()._add(e)},sub(e){return this.clone()._sub(e)},multByPoint(e){return this.clone()._multByPoint(e)},divByPoint(e){return this.clone()._divByPoint(e)},mult(e){return this.clone()._mult(e)},div(e){return this.clone()._div(e)},rotate(e){return this.clone()._rotate(e)},rotateAround(e,t){return this.clone()._rotateAround(e,t)},matMult(e){return this.clone()._matMult(e)},unit(){return this.clone()._unit()},perp(){return this.clone()._perp()},round(){return this.clone()._round()},mag(){return Math.sqrt(this.x*this.x+this.y*this.y)},equals(e){return this.x===e.x&&this.y===e.y},dist(e){return Math.sqrt(this.distSqr(e))},distSqr(e){let t=e.x-this.x,i=e.y-this.y;return t*t+i*i},angle(){return Math.atan2(this.y,this.x)},angleTo(e){return Math.atan2(this.y-e.y,this.x-e.x)},angleWith(e){return this.angleWithSep(e.x,e.y)},angleWithSep(e,t){return Math.atan2(this.x*t-this.y*e,this.x*e+this.y*t)},_matMult(e){let t=e[0]*this.x+e[1]*this.y,i=e[2]*this.x+e[3]*this.y;return this.x=t,this.y=i,this},_add(e){return this.x+=e.x,this.y+=e.y,this},_sub(e){return this.x-=e.x,this.y-=e.y,this},_mult(e){return this.x*=e,this.y*=e,this},_div(e){return this.x/=e,this.y/=e,this},_multByPoint(e){return this.x*=e.x,this.y*=e.y,this},_divByPoint(e){return this.x/=e.x,this.y/=e.y,this},_unit(){return this._div(this.mag()),this},_perp(){let e=this.y;return this.y=this.x,this.x=-e,this},_rotate(e){let t=Math.cos(e),i=Math.sin(e),r=t*this.x-i*this.y,a=i*this.x+t*this.y;return this.x=r,this.y=a,this},_rotateAround(e,t){let i=Math.cos(e),r=Math.sin(e),a=t.x+i*(this.x-t.x)-r*(this.y-t.y),n=t.y+r*(this.x-t.x)+i*(this.y-t.y);return this.x=a,this.y=n,this},_round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this},constructor:C},C.convert=function(e){if(e instanceof C)return e;if(Array.isArray(e))return new C(+e[0],+e[1]);if(e.x!==void 0&&e.y!==void 0)return new C(+e.x,+e.y);throw Error("Expected [x, y] or {x, y} point format")};function mb(e,t,i,r){let a=3*e,n=3*(i-e)-a,o=1-a-n,s=3*t,l=3*(r-t)-s,u=1-s-l;return function(h,c=1e-6){if(h<=0)return 0;if(h>=1)return 1;let d=h;for(let m=0;m<8;m++){let g=((o*d+n)*d+a)*d-h;if(Math.abs(g)<c)return((u*d+l)*d+s)*d;let _=(3*o*d+2*n)*d+a;if(Math.abs(_)<1e-6)break;d-=g/_}let p=0,f=1;d=h;for(let m=0;m<20;m++){let g=((o*d+n)*d+a)*d;if(Math.abs(g-h)<c)break;h>g?p=d:f=d,d=(p+f)*.5}return((u*d+l)*d+s)*d}}var Iu;function md(){return Iu??(Iu=typeof OffscreenCanvas<"u"&&!!new OffscreenCanvas(1,1).getContext("2d")&&typeof createImageBitmap=="function"),Iu}var Jo;function z_(){if(Jo==null&&(Jo=!1,md())){let e=new OffscreenCanvas(5,5).getContext("2d",{willReadFrequently:!0});if(e){for(let i=0;i<25;i++){let r=i*4;e.fillStyle=`rgb(${r},${r+1},${r+2})`,e.fillRect(i%5,Math.floor(i/5),1,1)}let t=e.getImageData(0,0,5,5).data;for(let i=0;i<100;i++)if(i%4!=3&&t[i]!==i){Jo=!0;break}}}return Jo||!1}var _t=typeof Float32Array<"u"?Float32Array:Array;function R_(){var e=new _t(4);return _t!=Float32Array&&(e[1]=0,e[2]=0),e[0]=1,e[3]=1,e}function gb(e,t){var i=t[0],r=t[1],a=t[2],n=t[3],o=i*n-a*r;return o?(o=1/o,e[0]=n*o,e[1]=-r*o,e[2]=-a*o,e[3]=i*o,e):null}function _b(e){return e[0]*e[3]-e[2]*e[1]}function yb(e,t,i){var r=t[0],a=t[1],n=t[2],o=t[3],s=Math.sin(i),l=Math.cos(i);return e[0]=r*l+n*s,e[1]=a*l+o*s,e[2]=r*-s+n*l,e[3]=a*-s+o*l,e}function k_(){var e=new _t(9);return _t!=Float32Array&&(e[1]=0,e[2]=0,e[3]=0,e[5]=0,e[6]=0,e[7]=0),e[0]=1,e[4]=1,e[8]=1,e}function vb(e){var t=e[0],i=e[1],r=e[2],a=e[3],n=e[4],o=e[5],s=e[6],l=e[7],u=e[8];return t*(u*n-o*l)+i*(-u*a+o*s)+r*(l*a-n*s)}function xb(e,t){var i=Math.sin(t),r=Math.cos(t);return e[0]=r,e[1]=i,e[2]=0,e[3]=-i,e[4]=r,e[5]=0,e[6]=0,e[7]=0,e[8]=1,e}function bb(e,t){var i=t[0],r=t[1],a=t[2],n=t[3],o=i+i,s=r+r,l=a+a,u=i*o,h=r*o,c=r*s,d=a*o,p=a*s,f=a*l,m=n*o,g=n*s,_=n*l;return e[0]=1-c-f,e[3]=h-_,e[6]=d+g,e[1]=h+_,e[4]=1-u-f,e[7]=p-m,e[2]=d-g,e[5]=p+m,e[8]=1-u-c,e}function na(){var e=new _t(16);return _t!=Float32Array&&(e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[6]=0,e[7]=0,e[8]=0,e[9]=0,e[11]=0,e[12]=0,e[13]=0,e[14]=0),e[0]=1,e[5]=1,e[10]=1,e[15]=1,e}function Sh(e){var t=new _t(16);return t[0]=e[0],t[1]=e[1],t[2]=e[2],t[3]=e[3],t[4]=e[4],t[5]=e[5],t[6]=e[6],t[7]=e[7],t[8]=e[8],t[9]=e[9],t[10]=e[10],t[11]=e[11],t[12]=e[12],t[13]=e[13],t[14]=e[14],t[15]=e[15],t}function wb(e,t){return e[0]=t[0],e[1]=t[1],e[2]=t[2],e[3]=t[3],e[4]=t[4],e[5]=t[5],e[6]=t[6],e[7]=t[7],e[8]=t[8],e[9]=t[9],e[10]=t[10],e[11]=t[11],e[12]=t[12],e[13]=t[13],e[14]=t[14],e[15]=t[15],e}function Mi(e){return e[0]=1,e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[5]=1,e[6]=0,e[7]=0,e[8]=0,e[9]=0,e[10]=1,e[11]=0,e[12]=0,e[13]=0,e[14]=0,e[15]=1,e}function Zs(e,t){var i=t[0],r=t[1],a=t[2],n=t[3],o=t[4],s=t[5],l=t[6],u=t[7],h=t[8],c=t[9],d=t[10],p=t[11],f=t[12],m=t[13],g=t[14],_=t[15],y=i*s-r*o,v=i*l-a*o,x=i*u-n*o,b=r*l-a*s,w=r*u-n*s,T=a*u-n*l,E=h*m-c*f,S=h*g-d*f,M=h*_-p*f,z=c*g-d*m,R=c*_-p*m,I=d*_-p*g,D=y*I-v*R+x*z+b*M-w*S+T*E;return D?(D=1/D,e[0]=(s*I-l*R+u*z)*D,e[1]=(a*R-r*I-n*z)*D,e[2]=(m*T-g*w+_*b)*D,e[3]=(d*w-c*T-p*b)*D,e[4]=(l*M-o*I-u*S)*D,e[5]=(i*I-a*M+n*S)*D,e[6]=(g*x-f*T-_*v)*D,e[7]=(h*T-d*x+p*v)*D,e[8]=(o*R-s*M+u*E)*D,e[9]=(r*M-i*R-n*E)*D,e[10]=(f*w-m*x+_*y)*D,e[11]=(c*x-h*w-p*y)*D,e[12]=(s*S-o*z-l*E)*D,e[13]=(i*z-r*S+a*E)*D,e[14]=(m*v-f*b-g*y)*D,e[15]=(h*b-c*v+d*y)*D,e):null}function wa(e,t,i){var r=t[0],a=t[1],n=t[2],o=t[3],s=t[4],l=t[5],u=t[6],h=t[7],c=t[8],d=t[9],p=t[10],f=t[11],m=t[12],g=t[13],_=t[14],y=t[15],v=i[0],x=i[1],b=i[2],w=i[3];return e[0]=v*r+x*s+b*c+w*m,e[1]=v*a+x*l+b*d+w*g,e[2]=v*n+x*u+b*p+w*_,e[3]=v*o+x*h+b*f+w*y,v=i[4],x=i[5],b=i[6],w=i[7],e[4]=v*r+x*s+b*c+w*m,e[5]=v*a+x*l+b*d+w*g,e[6]=v*n+x*u+b*p+w*_,e[7]=v*o+x*h+b*f+w*y,v=i[8],x=i[9],b=i[10],w=i[11],e[8]=v*r+x*s+b*c+w*m,e[9]=v*a+x*l+b*d+w*g,e[10]=v*n+x*u+b*p+w*_,e[11]=v*o+x*h+b*f+w*y,v=i[12],x=i[13],b=i[14],w=i[15],e[12]=v*r+x*s+b*c+w*m,e[13]=v*a+x*l+b*d+w*g,e[14]=v*n+x*u+b*p+w*_,e[15]=v*o+x*h+b*f+w*y,e}function lt(e,t,i){var r=i[0],a=i[1],n=i[2],o,s,l,u,h,c,d,p,f,m,g,_;return t===e?(e[12]=t[0]*r+t[4]*a+t[8]*n+t[12],e[13]=t[1]*r+t[5]*a+t[9]*n+t[13],e[14]=t[2]*r+t[6]*a+t[10]*n+t[14],e[15]=t[3]*r+t[7]*a+t[11]*n+t[15]):(o=t[0],s=t[1],l=t[2],u=t[3],h=t[4],c=t[5],d=t[6],p=t[7],f=t[8],m=t[9],g=t[10],_=t[11],e[0]=o,e[1]=s,e[2]=l,e[3]=u,e[4]=h,e[5]=c,e[6]=d,e[7]=p,e[8]=f,e[9]=m,e[10]=g,e[11]=_,e[12]=o*r+h*a+f*n+t[12],e[13]=s*r+c*a+m*n+t[13],e[14]=l*r+d*a+g*n+t[14],e[15]=u*r+p*a+_*n+t[15]),e}function kt(e,t,i){var r=i[0],a=i[1],n=i[2];return e[0]=t[0]*r,e[1]=t[1]*r,e[2]=t[2]*r,e[3]=t[3]*r,e[4]=t[4]*a,e[5]=t[5]*a,e[6]=t[6]*a,e[7]=t[7]*a,e[8]=t[8]*n,e[9]=t[9]*n,e[10]=t[10]*n,e[11]=t[11]*n,e[12]=t[12],e[13]=t[13],e[14]=t[14],e[15]=t[15],e}function Ua(e,t,i){var r=Math.sin(i),a=Math.cos(i),n=t[4],o=t[5],s=t[6],l=t[7],u=t[8],h=t[9],c=t[10],d=t[11];return t!==e&&(e[0]=t[0],e[1]=t[1],e[2]=t[2],e[3]=t[3],e[12]=t[12],e[13]=t[13],e[14]=t[14],e[15]=t[15]),e[4]=n*a+u*r,e[5]=o*a+h*r,e[6]=s*a+c*r,e[7]=l*a+d*r,e[8]=u*a-n*r,e[9]=h*a-o*r,e[10]=c*a-s*r,e[11]=d*a-l*r,e}function L_(e,t,i){var r=Math.sin(i),a=Math.cos(i),n=t[0],o=t[1],s=t[2],l=t[3],u=t[8],h=t[9],c=t[10],d=t[11];return t!==e&&(e[4]=t[4],e[5]=t[5],e[6]=t[6],e[7]=t[7],e[12]=t[12],e[13]=t[13],e[14]=t[14],e[15]=t[15]),e[0]=n*a-u*r,e[1]=o*a-h*r,e[2]=s*a-c*r,e[3]=l*a-d*r,e[8]=n*r+u*a,e[9]=o*r+h*a,e[10]=s*r+c*a,e[11]=l*r+d*a,e}function br(e,t,i){var r=Math.sin(i),a=Math.cos(i),n=t[0],o=t[1],s=t[2],l=t[3],u=t[4],h=t[5],c=t[6],d=t[7];return t!==e&&(e[8]=t[8],e[9]=t[9],e[10]=t[10],e[11]=t[11],e[12]=t[12],e[13]=t[13],e[14]=t[14],e[15]=t[15]),e[0]=n*a+u*r,e[1]=o*a+h*r,e[2]=s*a+c*r,e[3]=l*a+d*r,e[4]=u*a-n*r,e[5]=h*a-o*r,e[6]=c*a-s*r,e[7]=d*a-l*r,e}function Tb(e,t){return e[0]=t[0],e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[5]=t[1],e[6]=0,e[7]=0,e[8]=0,e[9]=0,e[10]=t[2],e[11]=0,e[12]=0,e[13]=0,e[14]=0,e[15]=1,e}function Eb(e,t,i,r,a){var n=1/Math.tan(t/2);if(e[0]=n/i,e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[5]=n,e[6]=0,e[7]=0,e[8]=0,e[9]=0,e[11]=-1,e[12]=0,e[13]=0,e[15]=0,a!=null&&a!==1/0){var o=1/(r-a);e[10]=(a+r)*o,e[14]=2*a*r*o}else e[10]=-1,e[14]=-2*r;return e}var Ch=Eb;function Db(e,t,i,r,a,n,o){var s=1/(t-i),l=1/(r-a),u=1/(n-o);return e[0]=-2*s,e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[5]=-2*l,e[6]=0,e[7]=0,e[8]=0,e[9]=0,e[10]=2*u,e[11]=0,e[12]=(t+i)*s,e[13]=(a+r)*l,e[14]=(o+n)*u,e[15]=1,e}var ir=Db;function Sb(e,t){return e[0]===t[0]&&e[1]===t[1]&&e[2]===t[2]&&e[3]===t[3]&&e[4]===t[4]&&e[5]===t[5]&&e[6]===t[6]&&e[7]===t[7]&&e[8]===t[8]&&e[9]===t[9]&&e[10]===t[10]&&e[11]===t[11]&&e[12]===t[12]&&e[13]===t[13]&&e[14]===t[14]&&e[15]===t[15]}function Cb(e,t){var i=e[0],r=e[1],a=e[2],n=e[3],o=e[4],s=e[5],l=e[6],u=e[7],h=e[8],c=e[9],d=e[10],p=e[11],f=e[12],m=e[13],g=e[14],_=e[15],y=t[0],v=t[1],x=t[2],b=t[3],w=t[4],T=t[5],E=t[6],S=t[7],M=t[8],z=t[9],R=t[10],I=t[11],D=t[12],P=t[13],A=t[14],B=t[15];return Math.abs(i-y)<=1e-6*Math.max(1,Math.abs(i),Math.abs(y))&&Math.abs(r-v)<=1e-6*Math.max(1,Math.abs(r),Math.abs(v))&&Math.abs(a-x)<=1e-6*Math.max(1,Math.abs(a),Math.abs(x))&&Math.abs(n-b)<=1e-6*Math.max(1,Math.abs(n),Math.abs(b))&&Math.abs(o-w)<=1e-6*Math.max(1,Math.abs(o),Math.abs(w))&&Math.abs(s-T)<=1e-6*Math.max(1,Math.abs(s),Math.abs(T))&&Math.abs(l-E)<=1e-6*Math.max(1,Math.abs(l),Math.abs(E))&&Math.abs(u-S)<=1e-6*Math.max(1,Math.abs(u),Math.abs(S))&&Math.abs(h-M)<=1e-6*Math.max(1,Math.abs(h),Math.abs(M))&&Math.abs(c-z)<=1e-6*Math.max(1,Math.abs(c),Math.abs(z))&&Math.abs(d-R)<=1e-6*Math.max(1,Math.abs(d),Math.abs(R))&&Math.abs(p-I)<=1e-6*Math.max(1,Math.abs(p),Math.abs(I))&&Math.abs(f-D)<=1e-6*Math.max(1,Math.abs(f),Math.abs(D))&&Math.abs(m-P)<=1e-6*Math.max(1,Math.abs(m),Math.abs(P))&&Math.abs(g-A)<=1e-6*Math.max(1,Math.abs(g),Math.abs(A))&&Math.abs(_-B)<=1e-6*Math.max(1,Math.abs(_),Math.abs(B))}function B_(){var e=new _t(3);return _t!=Float32Array&&(e[0]=0,e[1]=0,e[2]=0),e}function Ph(e){var t=new _t(3);return t[0]=e[0],t[1]=e[1],t[2]=e[2],t}function Pi(e){var t=e[0],i=e[1],r=e[2];return Math.sqrt(t*t+i*i+r*r)}function mf(e,t,i){var r=new _t(3);return r[0]=e,r[1]=t,r[2]=i,r}function yi(e,t,i){return e[0]=t[0]+i[0],e[1]=t[1]+i[1],e[2]=t[2]+i[2],e}function gd(e,t,i){return e[0]=t[0]-i[0],e[1]=t[1]-i[1],e[2]=t[2]-i[2],e}function Ue(e,t,i){return e[0]=t[0]*i,e[1]=t[1]*i,e[2]=t[2]*i,e}function qs(e,t,i,r){return e[0]=t[0]+i[0]*r,e[1]=t[1]+i[1]*r,e[2]=t[2]+i[2]*r,e}function Pb(e,t){var i=t[0]-e[0],r=t[1]-e[1],a=t[2]-e[2];return Math.sqrt(i*i+r*r+a*a)}function Ab(e,t){return e[0]=-t[0],e[1]=-t[1],e[2]=-t[2],e}function Vt(e,t){var i=t[0],r=t[1],a=t[2],n=i*i+r*r+a*a;return n>0&&(n=1/Math.sqrt(n)),e[0]=t[0]*n,e[1]=t[1]*n,e[2]=t[2]*n,e}function ut(e,t){return e[0]*t[0]+e[1]*t[1]+e[2]*t[2]}function Yt(e,t,i){var r=t[0],a=t[1],n=t[2],o=i[0],s=i[1],l=i[2];return e[0]=a*l-n*s,e[1]=n*o-r*l,e[2]=r*s-a*o,e}function Ib(e,t,i,r){var a=t[0],n=t[1],o=t[2];return e[0]=a+r*(i[0]-a),e[1]=n+r*(i[1]-n),e[2]=o+r*(i[2]-o),e}function Mb(e,t,i){var r=t[0],a=t[1],n=t[2],o=i[3]*r+i[7]*a+i[11]*n+i[15];return o||(o=1),e[0]=(i[0]*r+i[4]*a+i[8]*n+i[12])/o,e[1]=(i[1]*r+i[5]*a+i[9]*n+i[13])/o,e[2]=(i[2]*r+i[6]*a+i[10]*n+i[14])/o,e}function Fb(e,t,i){var r=t[0],a=t[1],n=t[2];return e[0]=r*i[0]+a*i[3]+n*i[6],e[1]=r*i[1]+a*i[4]+n*i[7],e[2]=r*i[2]+a*i[5]+n*i[8],e}function Mu(e,t,i){var r=i[0],a=i[1],n=i[2],o=i[3],s=t[0],l=t[1],u=t[2],h=a*u-n*l,c=n*s-r*u,d=r*l-a*s;return h+=h,c+=c,d+=d,e[0]=s+o*h+a*d-n*c,e[1]=l+o*c+n*h-r*d,e[2]=u+o*d+r*c-a*h,e}function _n(e,t,i,r){var a=[],n=[];return a[0]=t[0]-i[0],a[1]=t[1]-i[1],a[2]=t[2]-i[2],n[0]=a[0],n[1]=a[1]*Math.cos(r)-a[2]*Math.sin(r),n[2]=a[1]*Math.sin(r)+a[2]*Math.cos(r),e[0]=n[0]+i[0],e[1]=n[1]+i[1],e[2]=n[2]+i[2],e}function ya(e,t,i,r){var a=[],n=[];return a[0]=t[0]-i[0],a[1]=t[1]-i[1],a[2]=t[2]-i[2],n[0]=a[2]*Math.sin(r)+a[0]*Math.cos(r),n[1]=a[1],n[2]=a[2]*Math.cos(r)-a[0]*Math.sin(r),e[0]=n[0]+i[0],e[1]=n[1]+i[1],e[2]=n[2]+i[2],e}function Fu(e,t,i,r){var a=[],n=[];return a[0]=t[0]-i[0],a[1]=t[1]-i[1],a[2]=t[2]-i[2],n[0]=a[0]*Math.cos(r)-a[1]*Math.sin(r),n[1]=a[0]*Math.sin(r)+a[1]*Math.cos(r),n[2]=a[2],e[0]=n[0]+i[0],e[1]=n[1]+i[1],e[2]=n[2]+i[2],e}function zb(e){return e[0]=0,e[1]=0,e[2]=0,e}var lr=gd,Ws=Pi;(function(){var e=B_();return function(t,i,r,a,n,o){var s,l;for(i||(i=3),r||(r=0),l=a?Math.min(a*i+r,t.length):t.length,s=r;s<l;s+=i)e[0]=t[s],e[1]=t[s+1],e[2]=t[s+2],n(e,e,o),t[s]=e[0],t[s+1]=e[1],t[s+2]=e[2];return t}})();function Rb(){var e=new _t(4);return _t!=Float32Array&&(e[0]=0,e[1]=0,e[2]=0,e[3]=0),e}function kb(e,t,i,r){var a=new _t(4);return a[0]=e,a[1]=t,a[2]=i,a[3]=r,a}function Lb(e,t,i){return e[0]=t[0]*i[0],e[1]=t[1]*i[1],e[2]=t[2]*i[2],e[3]=t[3]*i[3],e}function Bb(e,t,i){return e[0]=t[0]*i,e[1]=t[1]*i,e[2]=t[2]*i,e[3]=t[3]*i,e}function Ob(e,t){var i=t[0],r=t[1],a=t[2],n=t[3],o=i*i+r*r+a*a+n*n;return o>0&&(o=1/Math.sqrt(o)),e[0]=i*o,e[1]=r*o,e[2]=a*o,e[3]=n*o,e}function Pt(e,t,i){var r=t[0],a=t[1],n=t[2],o=t[3];return e[0]=i[0]*r+i[4]*a+i[8]*n+i[12]*o,e[1]=i[1]*r+i[5]*a+i[9]*n+i[13]*o,e[2]=i[2]*r+i[6]*a+i[10]*n+i[14]*o,e[3]=i[3]*r+i[7]*a+i[11]*n+i[15]*o,e}var jb=Lb;(function(){var e=Rb();return function(t,i,r,a,n,o){var s,l;for(i||(i=4),r||(r=0),l=a?Math.min(a*i+r,t.length):t.length,s=r;s<l;s+=i)e[0]=t[s],e[1]=t[s+1],e[2]=t[s+2],e[3]=t[s+3],n(e,e,o),t[s]=e[0],t[s+1]=e[1],t[s+2]=e[2],t[s+3]=e[3];return t}})();function gf(){var e=new _t(4);return _t!=Float32Array&&(e[0]=0,e[1]=0,e[2]=0),e[3]=1,e}function Vb(e,t,i){i*=.5;var r=Math.sin(i);return e[0]=r*t[0],e[1]=r*t[1],e[2]=r*t[2],e[3]=Math.cos(i),e}function Nb(e,t,i){var r=t[0],a=t[1],n=t[2],o=t[3],s=i[0],l=i[1],u=i[2],h=i[3];return e[0]=r*h+o*s+a*u-n*l,e[1]=a*h+o*l+n*s-r*u,e[2]=n*h+o*u+r*l-a*s,e[3]=o*h-r*s-a*l-n*u,e}function Ms(e,t,i,r){var a=t[0],n=t[1],o=t[2],s=t[3],l=i[0],u=i[1],h=i[2],c=i[3],d,p=a*l+n*u+o*h+s*c,f,m,g;return p<0&&(p=-p,l=-l,u=-u,h=-h,c=-c),1-p>1e-6?(d=Math.acos(p),f=Math.sin(d),m=Math.sin((1-r)*d)/f,g=Math.sin(r*d)/f):(m=1-r,g=r),e[0]=m*a+g*l,e[1]=m*n+g*u,e[2]=m*o+g*h,e[3]=m*s+g*c,e}function Ub(e,t){var i=t[0]+t[4]+t[8],r;if(i>0)r=Math.sqrt(i+1),e[3]=.5*r,r=.5/r,e[0]=(t[5]-t[7])*r,e[1]=(t[6]-t[2])*r,e[2]=(t[1]-t[3])*r;else{var a=0;t[4]>t[0]&&(a=1),t[8]>t[a*3+a]&&(a=2);var n=(a+1)%3,o=(a+2)%3;r=Math.sqrt(t[a*3+a]-t[n*3+n]-t[o*3+o]+1),e[a]=.5*r,r=.5/r,e[3]=(t[n*3+o]-t[o*3+n])*r,e[n]=(t[n*3+a]+t[a*3+n])*r,e[o]=(t[o*3+a]+t[a*3+o])*r}return e}function _d(e,t,i,r){var a=arguments.length>4&&arguments[4]!==void 0?arguments[4]:"zyx",n=Math.PI/360;t*=n,r*=n,i*=n;var o=Math.sin(t),s=Math.cos(t),l=Math.sin(i),u=Math.cos(i),h=Math.sin(r),c=Math.cos(r);switch(a){case"xyz":e[0]=o*u*c+s*l*h,e[1]=s*l*c-o*u*h,e[2]=s*u*h+o*l*c,e[3]=s*u*c-o*l*h;break;case"xzy":e[0]=o*u*c-s*l*h,e[1]=s*l*c-o*u*h,e[2]=s*u*h+o*l*c,e[3]=s*u*c+o*l*h;break;case"yxz":e[0]=o*u*c+s*l*h,e[1]=s*l*c-o*u*h,e[2]=s*u*h-o*l*c,e[3]=s*u*c+o*l*h;break;case"yzx":e[0]=o*u*c+s*l*h,e[1]=s*l*c+o*u*h,e[2]=s*u*h-o*l*c,e[3]=s*u*c-o*l*h;break;case"zxy":e[0]=o*u*c-s*l*h,e[1]=s*l*c+o*u*h,e[2]=s*u*h+o*l*c,e[3]=s*u*c-o*l*h;break;case"zyx":e[0]=o*u*c-s*l*h,e[1]=s*l*c+o*u*h,e[2]=s*u*h-o*l*c,e[3]=s*u*c+o*l*h;break;default:throw Error("Unknown angle order "+a)}return e}var _f=kb,yf=Ob;(function(){var e=B_(),t=mf(1,0,0),i=mf(0,1,0);return function(r,a,n){var o=ut(a,n);return o<-.999999?(Yt(e,t,a),Ws(e)<1e-6&&Yt(e,i,a),Vt(e,e),Vb(r,e,Math.PI),r):o>.999999?(r[0]=0,r[1]=0,r[2]=0,r[3]=1,r):(Yt(e,a,n),r[0]=e[0],r[1]=e[1],r[2]=e[2],r[3]=1+o,yf(r,r))}})(),(function(){var e=gf(),t=gf();return function(i,r,a,n,o,s){return Ms(e,r,o,s),Ms(t,a,n,s),Ms(i,e,t,2*s*(1-s)),i}})(),(function(){var e=k_();return function(t,i,r,a){return e[0]=r[0],e[3]=r[1],e[6]=r[2],e[1]=a[0],e[4]=a[1],e[7]=a[2],e[2]=-i[0],e[5]=-i[1],e[8]=-i[2],yf(t,Ub(t,e))}})();function Ah(){var e=new _t(2);return _t!=Float32Array&&(e[0]=0,e[1]=0),e}function vf(e,t){var i=new _t(2);return i[0]=e,i[1]=t,i}function xf(e,t,i){return e[0]=t[0]*i,e[1]=t[1]*i,e}function bf(e){var t=e[0],i=e[1];return Math.sqrt(t*t+i*i)}function $b(e){var t=e[0],i=e[1];return t*t+i*i}function Gb(e,t){return e[0]*t[0]+e[1]*t[1]}function wf(e){return e[0]=0,e[1]=0,e}var Zb=$b;(function(){var e=Ah();return function(t,i,r,a,n,o){var s,l;for(i||(i=2),r||(r=0),l=a?Math.min(a*i+r,t.length):t.length,s=r;s<l;s+=i)e[0]=t[s],e[1]=t[s+1],n(e,e,o),t[s]=e[0],t[s+1]=e[1];return t}})();var k=8192;function oi(e,t,i){return t*(k/(e.tileSize*2**(i-e.tileID.overscaledZ)))}function bt(e){return e instanceof Error?e:Error(typeof e=="string"?e:String(e))}function Nr(){return new Float64Array(4)}function Pe(){return new Float64Array(3)}function Ur(){return new Float64Array(16)}function Qo(){let e=new Float64Array(16);return Mi(e),e}function O_(){let e=new Float32Array(16);return Mi(e),e}function Sr(e,t,i,r,a=!1){if(!i[0]&&!i[1])return[0,0];let n=a?r==="map"?-e.bearingInRadians:0:r==="viewport"?e.bearingInRadians:0;if(n){let o=Math.sin(n),s=Math.cos(n);i=[i[0]*s-i[1]*o,i[0]*o+i[1]*s]}return[a?i[0]:oi(t,i[0],e.zoom),a?i[1]:oi(t,i[1],e.zoom)]}function Ih(e,t){return e[0]*t[0]+e[1]*t[1]+e[2]*t[2]+e[3]}function di(e,t,i){let r=vb([e[0],e[1],e[2],t[0],t[1],t[2],i[0],i[1],i[2]]);if(r===0)return null;let a=Yt([],[t[0],t[1],t[2]],[i[0],i[1],i[2]]),n=Yt([],[i[0],i[1],i[2]],[e[0],e[1],e[2]]),o=Yt([],[e[0],e[1],e[2]],[t[0],t[1],t[2]]),s=Ue([],a,-e[3]);return yi(s,s,Ue([],n,-t[3])),yi(s,s,Ue([],o,-i[3])),Ue(s,s,1/r),s}function qb(e,t,i){let r=e[0]*i[0]+e[1]*i[1]+e[2]*i[2],a=t[0]*i[0]+t[1]*i[1]+t[2]*i[2];return a===0?null:(-r-i[3])/a}function es(e,t,i,r){let a=Math.sqrt(e*e+t*t),n=Math.sqrt(i*i+r*r);e/=a,t/=a,i/=n,r/=n;let o=e*i+t*r,s=Math.acos(o);return-t*i+e*r>0?s:-s}function qt(e,t){let i=Jr(e,360),r=Jr(t,360),a=r-i,n=r>i?a-360:a+360;return Math.abs(a)<Math.abs(n)?a:n}function ts(e,t){let i=Jr(e,Math.PI*2),r=Jr(t,Math.PI*2);return Math.min(Math.abs(i-r),Math.abs(i-r+Math.PI*2),Math.abs(i-r-Math.PI*2))}function Jr(e,t){return(e%t+t)%t}function On(e,t,i,r,a){return za(r,a,ie((e-t)/(i-t),0,1))}function za(e,t,i){return e*(1-i)+t*i}function Wb(e){let t=1/0,i=1/0,r=-1/0,a=-1/0;for(let n of e)t=Math.min(t,n.x),i=Math.min(i,n.y),r=Math.max(r,n.x),a=Math.max(a,n.y);return[t,i,r,a]}function Hb(e){if(!e.length)return new Set;let t=Math.max(...e.map(l=>l.canonical.z)),i=1/0,r=-1/0,a=1/0,n=-1/0,o=[];for(let l of e){let{x:u,y:h,z:c}=l.canonical,d=2**(t-c),p=u*d,f=h*d;o.push({id:l,x:p,y:f}),p<i&&(i=p),p>r&&(r=p),f<a&&(a=f),f>n&&(n=f)}let s=new Set;for(let l of o)(l.x===i||l.x===r||l.y===a||l.y===n)&&s.add(l.id);return s}function Xb(e){if(e<=0)return 0;if(e>=1)return 1;let t=e*e,i=t*e;return 4*(e<.5?i:3*(e-t)+i-.75)}function yd(e,t,i,r){return mb(e,t,i,r)}var Mh=yd(.25,.1,.25,1);function ie(e,t,i){return Math.min(i,Math.max(t,e))}function vi(e,t,i){let r=i-t,a=((e-t)%r+r)%r+t;return a===t?i:a}function q(e,...t){for(let i of t)for(let r in i)e[r]=i[r];return e}function yo(e,t){let i={};for(let r of t)r in e&&(i[r]=e[r]);return i}var Yb=1;function j_(){return Yb++}function Kb(e){return Math.log(e)/Math.LN2%1==0}function Jb(e){return e<=1?1:2**Math.ceil(Math.log(e)/Math.LN2)}function It(e){return 2**e}function Mt(e){return Math.log(e)/Math.LN2}function ri(e,t,i){if(t<=0)return e;let r=1/t;return i===void 0||Math.abs(i)<1e-10?Math.round(e*r)/r:(i>0?Math.ceil(e*r-1e-9):Math.floor(e*r+1e-10))/r}function vd(e,t,i){let r={};for(let a in e)r[a]=t.call(i||this,e[a],a,e);return r}function V_(e,t,i){let r={};for(let a in e)t.call(i||this,e[a],a,e)&&(r[a]=e[a]);return r}function Vi(e,t){if(Array.isArray(e)){if(!Array.isArray(t)||e.length!==t.length)return!1;for(let i=0;i<e.length;i++)if(!Vi(e[i],t[i]))return!1;return!0}if(typeof e=="object"&&e&&t!==null){if(typeof t!="object"||Object.keys(e).length!==Object.keys(t).length)return!1;for(let i in e)if(!Vi(e[i],t[i]))return!1;return!0}return e===t}function Ht(e){return Array.isArray(e)?e.map(Ht):typeof e=="object"&&e?vd(e,Ht):e}var Tf={};function _e(e){Tf[e]||(typeof console<"u"&&console.warn(e),Tf[e]=!0)}function wr(e,t,i){return(i.y-e.y)*(t.x-e.x)>(t.y-e.y)*(i.x-e.x)}function Qb(e,t,i,r){let a=t.y-e.y,n=t.x-e.x,o=r.y-i.y,s=r.x-i.x,l=o*n-s*a;if(l===0)return null;let u=e.y-i.y,h=e.x-i.x,c=(s*u-o*h)/l;return new C(e.x+c*n,e.y+c*a)}function N_([e,t,i]){return t+=90,t*=Math.PI/180,i*=Math.PI/180,[e*Math.cos(t)*Math.sin(i),e*Math.sin(t)*Math.sin(i),e*Math.cos(i)]}function $a(e){return typeof WorkerGlobalScope<"u"&&e!==void 0&&e instanceof WorkerGlobalScope}function ew(e){let t=/(?:^|(?:\s*\,\s*))([^\x00-\x20\(\)<>@\,;\:\\"\/\[\]\?\=\{\}\x7F]+)(?:\=(?:([^\x00-\x20\(\)<>@\,;\:\\"\/\[\]\?\=\{\}\x7F]+)|(?:\"((?:[^"\\]|\\.)*)\")))?/g,i={};if(e.replace(t,(r,a,n,o)=>{let s=n||o;return i[a]=!s||s.toLowerCase(),""}),i["max-age"]){let r=parseInt(i["max-age"],10);isNaN(r)?delete i["max-age"]:i["max-age"]=r}return i}var zu=null;function tw(e){if(zu==null){let t=e.navigator?e.navigator.userAgent:null;zu=!!e.safari||!!(t&&(/\b(iPad|iPhone|iPod)\b/.test(t)||t.match("Safari")&&!t.match("Chrome")))}return zu}function qr(e){return typeof ImageBitmap<"u"&&e instanceof ImageBitmap}var iw=async(e,t)=>{let i=new Blob([new Uint8Array(e)],{type:"image/png"});try{return createImageBitmap(i,t)}catch(r){throw Error(`Could not load image because of ${bt(r).message}. Please make sure to use a supported image type such as PNG or JPEG. Note that SVGs are not supported.`)}},rw=e=>new Promise((t,i)=>{let r=new Image;r.onload=()=>{t(r),URL.revokeObjectURL(r.src),r.onload=null,window.requestAnimationFrame(()=>r.src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAAC0lEQVQYV2NgAAIAAAUAAarVyFEAAAAASUVORK5CYII=")},r.onerror=()=>i(Error("Could not load image. Please make sure to use a supported image type such as PNG or JPEG. Note that SVGs are not supported."));let a=new Blob([new Uint8Array(e)],{type:"image/png"});r.src=URL.createObjectURL(a)});function aw(e,t,i,r,a){let n=Math.max(-t,0)*4,o=(Math.max(0,i)-i)*r*4+n,s=r*4,l=Math.max(0,t),u=Math.max(0,i),h=Math.min(e.width,t+r),c=Math.min(e.height,i+a);return{rect:{x:l,y:u,width:h-l,height:c-u},layout:[{offset:o,stride:s}]}}async function nw(e,t,i,r,a){if(typeof VideoFrame>"u")throw Error("VideoFrame not supported");let n=new VideoFrame(e,{timestamp:0});try{let o=n?.format;if(!o||!(o.startsWith("BGR")||o.startsWith("RGB")))throw Error(`Unrecognized format ${o}`);let s=o.startsWith("BGR"),l=new Uint8ClampedArray(r*a*4);if(await n.copyTo(l,aw(e,t,i,r,a)),s)for(let u=0;u<l.length;u+=4){let h=l[u];l[u]=l[u+2],l[u+2]=h}return l}finally{n.close()}}function Hs(e,t,i,r){return e.addEventListener(t,i,r),{unsubscribe:()=>{e.removeEventListener(t,i,r)}}}function je(e){return e*Math.PI/180}function Si(e){return e/Math.PI*180}function U_(e,t){return e.roll==t.roll&&e.pitch==t.pitch&&e.bearing==t.bearing}function ow(e){let t=new Float64Array(9);bb(t,e);let i=Si(-Math.asin(ie(t[2],-1,1))),r,a;return Math.hypot(t[5],t[8])<.001?(r=0,a=-Si(Math.atan2(t[3],t[4]))):(r=Si(t[5]===0&&t[8]===0?0:Math.atan2(t[5],t[8])),a=Si(t[1]===0&&t[0]===0?0:Math.atan2(t[1],t[0]))),{roll:r,pitch:i+90,bearing:a}}function $_(e,t,i){let r=vf(t.x-i.x,t.y-i.y),a=vf(e.x-i.x,e.y-i.y),n=r[0]*a[1]-r[1]*a[0];return Si(Math.atan2(n,Gb(r,a)))}function Ef(e,t,i){let r=new Float64Array(4);return _d(r,e,t-90,i),r}var ur=85.051129,G_={touchstart:!0,touchmove:!0,touchmoveWindow:!0,touchend:!0,touchcancel:!0},Z_={dblclick:!0,click:!0,mouseover:!0,mouseout:!0,mousedown:!0,mousemove:!0,mousemoveWindow:!0,mouseup:!0,mouseupWindow:!0,contextmenu:!0,wheel:!0};function sw(e,t){return G_[t]&&"touches"in e}function lw(e,t){if(!Z_[t])return!1;let i=e,r=i?.target?.ownerDocument?.defaultView||window;return i instanceof r.MouseEvent||i instanceof r.WheelEvent}function uw(e){return G_[e]||Z_[e]}var Df="AbortError",vo=class extends Error{constructor(e=Df){super(e instanceof Error?e.message:e),this.name=Df,e instanceof Error&&e.stack&&(this.stack=e.stack)}};function Cr(e){return e instanceof Error&&e.name==="AbortError"}function xd(e){if(e.aborted)throw new vo(e.reason)}var is,Ru,ku,Kt={frame(e,t,i,r){let a=r||window,n=a.requestAnimationFrame(s=>{o(),t(s)}),{unsubscribe:o}=Hs(e.signal,"abort",()=>{o(),a.cancelAnimationFrame(n),i(new vo(e.signal.reason))},!1)},frameAsync(e,t){return new Promise((i,r)=>{this.frame(e,i,r,t)})},getImageData(e,t=0){return this.getImageCanvasContext(e).getImageData(-t,-t,e.width+2*t,e.height+2*t)},getImageCanvasContext(e){let t;if(md()&&!z_())t=new OffscreenCanvas(e.width,e.height).getContext("2d",{willReadFrequently:!0});else{let i=window.document.createElement("canvas");i.width=e.width,i.height=e.height,t=i.getContext("2d",{willReadFrequently:!0})}if(!t)throw Error("failed to create canvas 2d context");return t.drawImage(e,0,0,e.width,e.height),t},resolveURL(e){return is||(is=document.createElement("a")),is.href=e,is.href},get hardwareConcurrency(){return typeof navigator<"u"&&navigator.hardwareConcurrency||4},get prefersReducedMotion(){return ku===void 0?matchMedia?(Ru??(Ru=matchMedia("(prefers-reduced-motion: reduce)")),Ru.matches):!1:ku},set prefersReducedMotion(e){ku=e}},El=new class{constructor(){this._frozenAt=null}getCurrentTime(){return this._frozenAt===null?performance.now():this._frozenAt}setNow(e){this._frozenAt=e}restoreNow(){this._frozenAt=null}isFrozen(){return this._frozenAt!==null}};function Ie(){return El.getCurrentTime()}function hw(e){El.setNow(e)}function cw(){El.restoreNow()}function dw(){return El.isFrozen()}var pw=new Set("a.abbr.b.bdi.bdo.br.cite.code.del.div.em.i.img.ins.kbd.li.mark.ol.p.q.s.samp.small.span.strong.sub.sup.time.u.ul.var.wbr".split(".")),fw=new Set(["alt","class","datetime","dir","height","href","hreflang","lang","referrerpolicy","rel","role","src","target","title","translate","type","width"]),mw=new Set(["href","src"]),gw=new Set(["http:","https:","mailto:"]),Lu;function Bu(){return Lu??(Lu={getAttribute:Element.prototype.getAttribute,getAttributeNames:Element.prototype.getAttributeNames,querySelectorAll:Element.prototype.querySelectorAll,remove:Element.prototype.remove,removeAttribute:Element.prototype.removeAttribute,localName:Object.getOwnPropertyDescriptor(Element.prototype,"localName").get,namespaceURI:Object.getOwnPropertyDescriptor(Element.prototype,"namespaceURI").get}),Lu}var ze,ne=(ze=class{static create(t,i,r){let a=window.document.createElement(t);return i!==void 0&&(a.className=i),r&&r.appendChild(a),a}static createNS(t,i){return window.document.createElementNS(t,i)}static disableDrag(){ze.docStyle&&ze.selectProp&&(ze.userSelect=ze.docStyle[ze.selectProp],ze.docStyle[ze.selectProp]="none")}static enableDrag(){ze.docStyle&&ze.selectProp&&(ze.docStyle[ze.selectProp]=ze.userSelect)}static suppressClickInternal(t){t.preventDefault(),t.stopPropagation(),window.removeEventListener("click",ze.suppressClickInternal,!0)}static suppressClick(){window.addEventListener("click",ze.suppressClickInternal,!0),window.setTimeout(()=>{window.removeEventListener("click",ze.suppressClickInternal,!0)},0)}static getScale(t){let i=t.getBoundingClientRect();return{x:i.width/t.offsetWidth||1,y:i.height/t.offsetHeight||1,boundingClientRect:i}}static getPoint(t,i,r){let a=i.boundingClientRect;return new C((r.clientX-a.left)/i.x-t.clientLeft,(r.clientY-a.top)/i.y-t.clientTop)}static mousePos(t,i){let r=ze.getScale(t);return ze.getPoint(t,r,i)}static touchPos(t,i){let r=[],a=ze.getScale(t);for(let n of i)r.push(ze.getPoint(t,a,n));return r}static sanitize(t){let i=new DOMParser().parseFromString(t,"text/html").body,{querySelectorAll:r,remove:a}=Bu();for(let o of Array.from(r.call(i,"*")))ze.isAllowedElement(o)?ze.removeDisallowedAttributes(o):a.call(o);let n=document.createDocumentFragment();return n.append(...i.childNodes),n}static isAllowedElement(t){let{namespaceURI:i,localName:r}=Bu();return i.call(t)==="http://www.w3.org/1999/xhtml"&&pw.has(r.call(t))}static removeDisallowedAttributes(t){let{getAttributeNames:i,getAttribute:r,removeAttribute:a}=Bu();for(let n of i.call(t))ze.isAllowedAttribute(n,r.call(t,n))||a.call(t,n)}static isAllowedAttribute(t,i){if(!fw.has(t)&&!t.startsWith("aria-"))return!1;if(!mw.has(t))return!0;try{return gw.has(new URL(i,"https://maplibre.invalid/").protocol)}catch{return!1}}},ze.docStyle=typeof window<"u"&&window.document?.documentElement.style,ze.selectProp=!ze.docStyle||"userSelect"in ze.docStyle?"userSelect":"webkitUserSelect",ze),si={MAX_PARALLEL_IMAGE_REQUESTS:16,MAX_PARALLEL_IMAGE_REQUESTS_PER_FRAME:8,MAX_TILE_CACHE_ZOOM_LEVELS:5,REGISTERED_PROTOCOLS:{},WORKER_URL:""};function q_(e){return si.REGISTERED_PROTOCOLS[e.substring(0,e.indexOf("://"))]}function _w(e,t){si.REGISTERED_PROTOCOLS[e]=t}function yw(e){delete si.REGISTERED_PROTOCOLS[e]}var Fh="global-dispatcher",Yn=class extends Error{constructor(e,t,i,r){super(`AJAXError: ${t} (${e}): ${i}`),this.status=e,this.statusText=t,this.url=i,this.body=r}};function bd(){if($a(self))return self.worker?.referrer;if(window.location.protocol==="blob:")try{return window.parent.location.href}catch{}return window.location.href}var vw=e=>e.startsWith("file:")||bd()?.startsWith("file:")&&!/^\w+:/.test(e);async function xw(e,t){let i=new Request(e.url,{method:e.method||"GET",body:e.body,credentials:e.credentials,headers:e.headers,cache:e.cache,referrer:bd(),referrerPolicy:e.referrerPolicy,signal:t.signal});e.type==="json"&&!i.headers.has("Accept")&&i.headers.set("Accept","application/json");let r;try{r=await fetch(i)}catch(o){throw Cr(o)?o:new Yn(0,bt(o).message,e.url,new Blob)}if(!r.ok){let o=await r.blob();throw new Yn(r.status,r.statusText,e.url,o)}let a;a=e.type==="arrayBuffer"||e.type==="image"?r.arrayBuffer():e.type==="json"?r.json():r.text();let n=await a;return xd(t.signal),{data:n,cacheControl:r.headers.get("Cache-Control"),expires:r.headers.get("Expires"),etag:r.headers.get("ETag")}}function bw(e,t){return new Promise((i,r)=>{let a=new XMLHttpRequest;a.open(e.method||"GET",e.url,!0),(e.type==="arrayBuffer"||e.type==="image")&&(a.responseType="arraybuffer");for(let n in e.headers)a.setRequestHeader(n,e.headers[n]);e.type==="json"&&(a.responseType="text",e.headers?.Accept||a.setRequestHeader("Accept","application/json")),a.withCredentials=e.credentials==="include",a.onerror=()=>{r(Error(a.statusText))},a.onload=()=>{if(!t.signal.aborted)if((a.status>=200&&a.status<300||a.status===0)&&a.response!==null){let n=a.response;if(e.type==="json")try{n=JSON.parse(a.response)}catch(o){r(o);return}i({data:n,cacheControl:a.getResponseHeader("Cache-Control"),expires:a.getResponseHeader("Expires"),etag:a.getResponseHeader("ETag")})}else{let n=new Blob([a.response],{type:a.getResponseHeader("Content-Type")});r(new Yn(a.status,a.statusText,e.url,n))}},t.signal.addEventListener("abort",()=>{a.abort(),r(new vo(t.signal.reason))}),a.send(e.body)})}var Dl=async function(e,t){if(e.url.includes("://")&&!/^https?:|^file:/.test(e.url)){let i=q_(e.url);if(i){let r=await i(e,t);return!r.data&&e.type==="arrayBuffer"?q(r,{data:new ArrayBuffer(0)}):r}if($a(self)&&self.worker?.actor)return self.worker.actor.sendAsync({type:"GR",data:e,targetMapId:Fh},t)}if(!vw(e.url)){if(fetch&&Request&&AbortController&&Object.hasOwn(Request.prototype,"signal"))return xw(e,t);if($a(self)&&self.worker?.actor)return self.worker.actor.sendAsync({type:"GR",data:e,mustQueue:!0,targetMapId:Fh},t)}return bw(e,t)},Sl=(e,t)=>Dl(q(e,{type:"json"}),t),W_=(e,t)=>Dl(q(e,{type:"arrayBuffer"}),t);function H_(e){if(!e||e.startsWith("data:image/"))return!0;if(e.startsWith("blob:")&&(e=e.slice(5),e.startsWith("null")))return!1;if(e.indexOf("://")<=0)return!0;let t=new URL(e),i=window.location;return t.protocol===i.protocol&&t.host===i.host}var ww=e=>{let t=window.document.createElement("video");return t.muted=!0,new Promise(i=>{t.onloadstart=()=>{i(t)};for(let r of e){let a=window.document.createElement("source");H_(r)||(t.crossOrigin="Anonymous"),a.src=r,t.appendChild(a)}})},Ci;(function(e){let t,i,r,a;e.resetRequestQueue=()=>{t=[],i=0,r=0,a={}},e.addThrottleControl=c=>{let d=r++;return a[d]=c,d},e.removeThrottleControl=c=>{delete a[c],u()};let n=()=>{for(let c of Object.keys(a))if(a[c]())return!0;return!1};async function o(c,d,p,f,m=!0,g){let _=await c.transformRequest(d,p);return xd(f.signal),Ci.getImage(_,f,m,g)}e.transformAndGetImage=o,e.getImage=(c,d,p=!0,f)=>new Promise((m,g)=>{c.headers||(c.headers={}),c.headers.accept="image/webp,*/*",q(c,{type:"image"});let _={abortController:d,requestParameters:c,supportImageRefresh:p,imageBitmapOptions:f,state:"queued",onError:y=>{g(y)},onSuccess:y=>{m(y)}};t.push(_),u()});let s=(c,d)=>typeof createImageBitmap=="function"?iw(c,d):rw(c),l=async c=>{c.state="running";let{requestParameters:d,supportImageRefresh:p,imageBitmapOptions:f,onError:m,onSuccess:g,abortController:_}=c,y=p===!1&&!f&&!$a(self)&&!q_(d.url)&&(!d.headers||Object.keys(d.headers).reduce((x,b)=>x&&b==="accept",!0));i++;let v=y?h(d,_):Dl(d,_);try{let x=await v;delete c.abortController,c.state="completed",x.data instanceof HTMLImageElement||qr(x.data)?g(x):!x.data||x.data.byteLength===0?g({data:null,cacheControl:x.cacheControl,expires:x.expires}):g({data:await s(x.data,f),cacheControl:x.cacheControl,expires:x.expires})}catch(x){delete c.abortController,m(bt(x))}finally{i--,u()}},u=()=>{let c=n()?si.MAX_PARALLEL_IMAGE_REQUESTS_PER_FRAME:si.MAX_PARALLEL_IMAGE_REQUESTS;for(let d=i;d<c&&t.length>0;d++){let p=t.shift();if(p.abortController.signal.aborted){d--;continue}l(p)}},h=(c,d)=>new Promise((p,f)=>{let m=new Image,g=c.url,_=c.credentials;_&&_==="include"?m.crossOrigin="use-credentials":(_&&_==="same-origin"||!H_(g))&&(m.crossOrigin="anonymous"),d.signal.addEventListener("abort",()=>{m.src="",f(new vo(d.signal.reason))}),m.fetchPriority="high",m.onload=()=>{m.onerror=m.onload=null,p({data:m})},m.onerror=()=>{m.onerror=m.onload=null,!d.signal.aborted&&f(Error("Could not load image. Please make sure to use a supported image type such as PNG or JPEG. Note that SVGs are not supported."))},m.src=g})})(Ci||(Ci={})),Ci.resetRequestQueue();var Tw=class{constructor(e){this._transformRequestFn=e??null}transformRequest(e,t){return this._transformRequestFn&&this._transformRequestFn(e,t)||{url:e}}setTransformRequest(e){this._transformRequestFn=e}};function Sf(e,t,i){i[e]?.includes(t)||(i[e]||(i[e]=[]),i[e].push(t))}function Ou(e,t,i){if(i?.[e]){let r=i[e].indexOf(t);r!==-1&&i[e].splice(r,1)}}var li=class{constructor(e,t={}){q(this,t),this.type=e}},Y=class extends li{constructor(e,t={}){super("error",q({error:e},t))}},ht=class{on(e,t){return this._listeners||(this._listeners={}),Sf(e,t,this._listeners),{unsubscribe:()=>{this.off(e,t)}}}off(e,t){return Ou(e,t,this._listeners),Ou(e,t,this._oneTimeListeners),this}once(e,t){return t?(this._oneTimeListeners||(this._oneTimeListeners={}),Sf(e,t,this._oneTimeListeners),this):new Promise(i=>this.once(e,i))}fire(e,t){let i=typeof e=="string"?new li(e,t||{}):e,r=i.type;if(this.listens(r)){i.target=this;let a=this._listeners?.[r]?.slice()??[];for(let s of a)s.call(this,i);let n=this._oneTimeListeners?.[r]?.slice()??[];for(let s of n)Ou(r,s,this._oneTimeListeners),s.call(this,i);let o=this._eventedParent;o&&(q(i,typeof this._eventedParentData=="function"?this._eventedParentData():this._eventedParentData),o.fire(i))}else i instanceof Y&&console.error(i.error);return this}listens(e){return!!(this._listeners?.[e]?.length||this._oneTimeListeners?.[e]?.length||this._eventedParent?.listens(e))}setEventedParent(e,t){return this._eventedParent=e,this._eventedParentData=t,this}},gt=class extends li{},Q=class extends gt{},zh=class extends gt{constructor(e={}){super("style.load",e)}},_i=class extends gt{constructor(e,t={}){super(e,t),this.dataType="style"}},Ne=class extends gt{constructor(e,t={}){super(e,t),this.dataType="source"}},Xt=class extends gt{preventDefault(){this._defaultPrevented=!0}get defaultPrevented(){return this._defaultPrevented}constructor(e,t,i,r={}){i=i instanceof MouseEvent?i:new MouseEvent(e,i);let a=ne.mousePos(t.getCanvas(),i),n=t.unproject(a);super(e,q({point:a,lngLat:n,originalEvent:i},r)),this._defaultPrevented=!1,this.target=t}},In=class extends gt{preventDefault(){this._defaultPrevented=!0}get defaultPrevented(){return this._defaultPrevented}constructor(e,t,i){let r=e==="touchend"?i.changedTouches:i.touches,a=ne.touchPos(t.getCanvasContainer(),r),n=a.map(l=>t.unproject(l)),o=a.reduce((l,u,h,c)=>l.add(u.div(c.length)),new C(0,0)),s=t.unproject(o);super(e,{points:a,point:o,lngLats:n,lngLat:s,originalEvent:i}),this._defaultPrevented=!1}},X_=class extends gt{preventDefault(){this._defaultPrevented=!0}get defaultPrevented(){return this._defaultPrevented}constructor(e,t){super("wheel",{originalEvent:t}),this._defaultPrevented=!1}},Rh=class extends gt{},Y_=class extends gt{constructor(e={}){super("terrain",e)}},K_=class extends gt{constructor(e={}){super("projectiontransition",e)}},Fs=class extends gt{},J_=class extends gt{constructor(e={}){super("styleimagemissing",e)}},Q_={$version:8,$root:{version:{required:!0,type:"enum",values:[8]},name:{type:"string"},metadata:{type:"*"},center:{type:"array",value:"number",length:2},centerAltitude:{type:"number"},zoom:{type:"number"},bearing:{type:"number",default:0,period:360,units:"degrees"},pitch:{type:"number",default:0,units:"degrees"},roll:{type:"number",default:0,units:"degrees"},state:{type:"state",default:{}},light:{type:"light"},sky:{type:"sky"},projection:{type:"projection"},terrain:{type:"terrain"},sources:{required:!0,type:"sources"},sprite:{type:"sprite"},glyphs:{type:"string"},"font-faces":{type:"fontFaces"},transition:{type:"transition"},layers:{required:!0,type:"array",value:"layer"}},sources:{"*":{type:"source"}},source:["source_vector","source_raster","source_raster_dem","source_geojson","source_video","source_image"],source_vector:{type:{required:!0,type:"enum",values:{vector:{}}},url:{type:"string"},tiles:{type:"array",value:"string"},bounds:{type:"array",value:"number",length:4,default:[-180,-85.051129,180,85.051129]},scheme:{type:"enum",values:{xyz:{},tms:{}},default:"xyz"},minzoom:{type:"number",default:0},maxzoom:{type:"number",default:22},attribution:{type:"string"},promoteId:{type:"promoteId"},volatile:{type:"boolean",default:!1},encoding:{type:"enum",values:{mvt:{},mlt:{}},default:"mvt"},"*":{type:"*"}},source_raster:{type:{required:!0,type:"enum",values:{raster:{}}},url:{type:"string"},tiles:{type:"array",value:"string"},bounds:{type:"array",value:"number",length:4,default:[-180,-85.051129,180,85.051129]},minzoom:{type:"number",default:0},maxzoom:{type:"number",default:22},tileSize:{type:"number",default:512,units:"pixels"},scheme:{type:"enum",values:{xyz:{},tms:{}},default:"xyz"},attribution:{type:"string"},volatile:{type:"boolean",default:!1},"*":{type:"*"}},source_raster_dem:{type:{required:!0,type:"enum",values:{"raster-dem":{}}},url:{type:"string"},tiles:{type:"array",value:"string"},bounds:{type:"array",value:"number",length:4,default:[-180,-85.051129,180,85.051129]},minzoom:{type:"number",default:0},maxzoom:{type:"number",default:22},tileSize:{type:"number",default:512,units:"pixels"},attribution:{type:"string"},encoding:{type:"enum",values:{terrarium:{},mapbox:{},custom:{}},default:"mapbox"},redFactor:{type:"number",default:1},blueFactor:{type:"number",default:1},greenFactor:{type:"number",default:1},baseShift:{type:"number",default:0},volatile:{type:"boolean",default:!1},"*":{type:"*"}},source_geojson:{type:{required:!0,type:"enum",values:{geojson:{}}},data:{required:!0,type:"*"},maxzoom:{type:"number",default:18},attribution:{type:"string"},buffer:{type:"number",default:128,maximum:512,minimum:0},filter:{type:"filter"},tolerance:{type:"number",default:.375},cluster:{type:"boolean",default:!1},clusterRadius:{type:"number",default:50,minimum:0},clusterMaxZoom:{type:"number"},clusterMinPoints:{type:"number"},clusterProperties:{type:"*"},lineMetrics:{type:"boolean",default:!1},generateId:{type:"boolean",default:!1},promoteId:{type:"promoteId"}},source_video:{type:{required:!0,type:"enum",values:{video:{}}},urls:{required:!0,type:"array",value:"string"},coordinates:{required:!0,type:"array",length:4,value:{type:"array",length:2,value:"number"}}},source_image:{type:{required:!0,type:"enum",values:{image:{}}},url:{type:"string"},coordinates:{required:!0,type:"array",length:4,value:{type:"array",length:2,value:"number"}}},layer:{id:{type:"string",required:!0},type:{type:"enum",values:{fill:{},line:{},symbol:{},circle:{},heatmap:{},"fill-extrusion":{},raster:{},hillshade:{},"color-relief":{},background:{}},required:!0},metadata:{type:"*"},source:{type:"string"},"source-layer":{type:"string"},minzoom:{type:"number",minimum:0,maximum:24},maxzoom:{type:"number",minimum:0,maximum:24},filter:{type:"filter"},layout:{type:"layout"},paint:{type:"paint"}},layout:["layout_fill","layout_line","layout_circle","layout_heatmap","layout_fill-extrusion","layout_symbol","layout_raster","layout_hillshade","layout_color-relief","layout_background"],layout_background:{visibility:{type:"enum",values:{visible:{},none:{}},default:"visible",expression:{interpolated:!1,parameters:["global-state"]},"property-type":"data-constant"}},layout_fill:{"fill-sort-key":{type:"number",expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"data-driven"},visibility:{type:"enum",values:{visible:{},none:{}},default:"visible",expression:{interpolated:!1,parameters:["global-state"]},"property-type":"data-constant"}},layout_circle:{"circle-sort-key":{type:"number",expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"data-driven"},visibility:{type:"enum",values:{visible:{},none:{}},default:"visible",expression:{interpolated:!1,parameters:["global-state"]},"property-type":"data-constant"}},layout_heatmap:{visibility:{type:"enum",values:{visible:{},none:{}},default:"visible",expression:{interpolated:!1,parameters:["global-state"]},"property-type":"data-constant"}},"layout_fill-extrusion":{visibility:{type:"enum",values:{visible:{},none:{}},default:"visible",expression:{interpolated:!1,parameters:["global-state"]},"property-type":"data-constant"},"fill-extrusion-rounded-corner-distance":{type:"number",default:0,minimum:0,units:"meters","property-type":"constant"}},layout_line:{"line-cap":{type:"enum",values:{butt:{},round:{},square:{}},default:"butt",expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"data-driven"},"line-join":{type:"enum",values:{bevel:{},round:{},miter:{}},default:"miter",expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"data-driven"},"line-miter-limit":{type:"number",default:2,requires:[{"line-join":"miter"}],expression:{interpolated:!0,parameters:["zoom","feature"]},"property-type":"data-driven"},"line-round-limit":{type:"number",default:1.05,requires:[{"line-join":"round"}],expression:{interpolated:!0,parameters:["zoom","feature"]},"property-type":"data-driven"},"line-sort-key":{type:"number",expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"data-driven"},visibility:{type:"enum",values:{visible:{},none:{}},default:"visible",expression:{interpolated:!1,parameters:["global-state"]},"property-type":"data-constant"}},layout_symbol:{"symbol-placement":{type:"enum",values:{point:{},line:{},"line-center":{}},default:"point",expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"symbol-spacing":{type:"number",default:250,minimum:1,units:"pixels",requires:[{"symbol-placement":"line"}],expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"symbol-avoid-edges":{type:"boolean",default:!1,expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"symbol-sort-key":{type:"number",expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"data-driven"},"symbol-z-order":{type:"enum",values:{auto:{},"viewport-y":{},source:{}},default:"auto",expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"icon-allow-overlap":{type:"boolean",default:!1,requires:["icon-image",{"!":"icon-overlap"}],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"icon-overlap":{type:"enum",values:{never:{},always:{},cooperative:{}},requires:["icon-image"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"icon-ignore-placement":{type:"boolean",default:!1,requires:["icon-image"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"icon-optional":{type:"boolean",default:!1,requires:["icon-image","text-field"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"icon-rotation-alignment":{type:"enum",values:{map:{},viewport:{},auto:{}},default:"auto",requires:["icon-image"],expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"data-driven"},"icon-size":{type:"number",default:1,minimum:0,units:"factor of the original icon size",requires:["icon-image"],expression:{interpolated:!0,parameters:["zoom","feature"]},"property-type":"data-driven"},"icon-text-fit":{type:"enum",values:{none:{},width:{},height:{},both:{}},default:"none",requires:["icon-image","text-field"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"icon-text-fit-padding":{type:"array",value:"number",length:4,default:[0,0,0,0],units:"pixels",requires:["icon-image","text-field",{"icon-text-fit":["both","width","height"]}],expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"icon-image":{type:"resolvedImage",tokens:!0,expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"data-driven"},"icon-rotate":{type:"number",default:0,period:360,units:"degrees",requires:["icon-image"],expression:{interpolated:!0,parameters:["zoom","feature"]},"property-type":"data-driven"},"icon-padding":{type:"padding",default:[2],units:"pixels",requires:["icon-image"],expression:{interpolated:!0,parameters:["zoom","feature"]},"property-type":"data-driven"},"icon-keep-upright":{type:"boolean",default:!1,requires:["icon-image",{"icon-rotation-alignment":"map"},{"symbol-placement":["line","line-center"]}],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"icon-offset":{type:"array",value:"number",length:2,default:[0,0],requires:["icon-image"],expression:{interpolated:!0,parameters:["zoom","feature"]},"property-type":"data-driven"},"icon-anchor":{type:"enum",values:{center:{},left:{},right:{},top:{},bottom:{},"top-left":{},"top-right":{},"bottom-left":{},"bottom-right":{}},default:"center",requires:["icon-image"],expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"data-driven"},"icon-pitch-alignment":{type:"enum",values:{map:{},viewport:{},auto:{}},default:"auto",requires:["icon-image"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"text-pitch-alignment":{type:"enum",values:{map:{},viewport:{},auto:{}},default:"auto",requires:["text-field"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"text-rotation-alignment":{type:"enum",values:{map:{},viewport:{},"viewport-glyph":{},auto:{}},default:"auto",requires:["text-field"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"text-field":{type:"formatted",default:"",tokens:!0,expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"data-driven"},"text-font":{type:"array",value:"string",default:["Open Sans Regular","Arial Unicode MS Regular"],requires:["text-field"],expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"data-driven"},"text-size":{type:"number",default:16,minimum:0,units:"pixels",requires:["text-field"],expression:{interpolated:!0,parameters:["zoom","feature"]},"property-type":"data-driven"},"text-max-width":{type:"number",default:10,minimum:0,units:"ems",requires:["text-field"],expression:{interpolated:!0,parameters:["zoom","feature"]},"property-type":"data-driven"},"text-line-height":{type:"number",default:1.2,units:"ems",requires:["text-field"],expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"text-letter-spacing":{type:"number",default:0,units:"ems",requires:["text-field"],expression:{interpolated:!0,parameters:["zoom","feature"]},"property-type":"data-driven"},"text-justify":{type:"enum",values:{auto:{},left:{},center:{},right:{}},default:"center",requires:["text-field"],expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"data-driven"},"text-radial-offset":{type:"number",units:"ems",default:0,requires:["text-field"],"property-type":"data-driven",expression:{interpolated:!0,parameters:["zoom","feature"]}},"text-variable-anchor":{type:"array",value:"enum",values:{center:{},left:{},right:{},top:{},bottom:{},"top-left":{},"top-right":{},"bottom-left":{},"bottom-right":{}},requires:["text-field",{"symbol-placement":["point"]}],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"text-variable-anchor-offset":{type:"variableAnchorOffsetCollection",requires:["text-field",{"symbol-placement":["point"]}],expression:{interpolated:!0,parameters:["zoom","feature"]},"property-type":"data-driven"},"text-anchor":{type:"enum",values:{center:{},left:{},right:{},top:{},bottom:{},"top-left":{},"top-right":{},"bottom-left":{},"bottom-right":{}},default:"center",requires:["text-field",{"!":"text-variable-anchor"}],expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"data-driven"},"text-max-angle":{type:"number",default:45,units:"degrees",requires:["text-field",{"symbol-placement":["line","line-center"]}],expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"text-writing-mode":{type:"array",value:"enum",values:{horizontal:{},vertical:{}},requires:["text-field",{"symbol-placement":["point"]}],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"text-rotate":{type:"number",default:0,period:360,units:"degrees",requires:["text-field"],expression:{interpolated:!0,parameters:["zoom","feature"]},"property-type":"data-driven"},"text-padding":{type:"number",default:2,minimum:0,units:"pixels",requires:["text-field"],expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"text-keep-upright":{type:"boolean",default:!0,requires:["text-field",{"text-rotation-alignment":"map"},{"symbol-placement":["line","line-center"]}],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"text-transform":{type:"enum",values:{none:{},uppercase:{},lowercase:{}},default:"none",requires:["text-field"],expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"data-driven"},"text-offset":{type:"array",value:"number",units:"ems",length:2,default:[0,0],requires:["text-field",{"!":"text-radial-offset"}],expression:{interpolated:!0,parameters:["zoom","feature"]},"property-type":"data-driven"},"text-allow-overlap":{type:"boolean",default:!1,requires:["text-field",{"!":"text-overlap"}],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"text-overlap":{type:"enum",values:{never:{},always:{},cooperative:{}},requires:["text-field"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"text-ignore-placement":{type:"boolean",default:!1,requires:["text-field"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"text-optional":{type:"boolean",default:!1,requires:["text-field","icon-image"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"symbol-height-offset":{type:"number",default:0,units:"meters",requires:[{"symbol-placement":["point"]}],expression:{interpolated:!0,parameters:["zoom","feature"]},"property-type":"data-driven"},"symbol-height-anchor":{type:"enum",values:{ground:{},absolute:{}},default:"ground",requires:["symbol-height-offset"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},visibility:{type:"enum",values:{visible:{},none:{}},default:"visible",expression:{interpolated:!1,parameters:["global-state"]},"property-type":"data-constant"}},layout_raster:{visibility:{type:"enum",values:{visible:{},none:{}},default:"visible",expression:{interpolated:!1,parameters:["global-state"]},"property-type":"data-constant"}},layout_hillshade:{visibility:{type:"enum",values:{visible:{},none:{}},default:"visible",expression:{interpolated:!1,parameters:["global-state"]},"property-type":"data-constant"}},"layout_color-relief":{visibility:{type:"enum",values:{visible:{},none:{}},default:"visible",expression:{interpolated:!1,parameters:["global-state"]},"property-type":"data-constant"}},filter:{type:"boolean",expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"data-driven"},filter_operator:{type:"enum",values:{"==":{},"!=":{},">":{},">=":{},"<":{},"<=":{},in:{},"!in":{},all:{},any:{},none:{},has:{},"!has":{}}},geometry_type:{type:"enum",values:{Point:{},LineString:{},Polygon:{}}},function:{expression:{type:"expression"},stops:{type:"array",value:"function_stop"},base:{type:"number",default:1,minimum:0},property:{type:"string",default:"$zoom"},type:{type:"enum",values:{identity:{},exponential:{},interval:{},categorical:{}},default:"exponential"},colorSpace:{type:"enum",values:{rgb:{},lab:{},hcl:{}},default:"rgb"},default:{type:"*",required:!1}},function_stop:{type:"array",minimum:0,maximum:24,value:["number","color"],length:2},expression:{type:"array",value:"expression_name",minimum:1},light:{anchor:{type:"enum",default:"viewport",values:{map:{},viewport:{}},"property-type":"data-constant",transition:!1,expression:{interpolated:!1,parameters:["zoom"]}},position:{type:"array",default:[1.15,210,30],length:3,value:"number","property-type":"data-constant",transition:!0,expression:{interpolated:!0,parameters:["zoom"]}},color:{type:"color","property-type":"data-constant",default:"#ffffff",expression:{interpolated:!0,parameters:["zoom"]},transition:!0},intensity:{type:"number","property-type":"data-constant",default:.5,minimum:0,maximum:1,expression:{interpolated:!0,parameters:["zoom"]},transition:!0}},sky:{"sky-color":{type:"color","property-type":"data-constant",default:"#88C6FC",expression:{interpolated:!0,parameters:["zoom"]},transition:!0},"horizon-color":{type:"color","property-type":"data-constant",default:"#ffffff",expression:{interpolated:!0,parameters:["zoom"]},transition:!0},"fog-color":{type:"color","property-type":"data-constant",default:"#ffffff",expression:{interpolated:!0,parameters:["zoom"]},transition:!0},"fog-ground-blend":{type:"number","property-type":"data-constant",default:.5,minimum:0,maximum:1,expression:{interpolated:!0,parameters:["zoom"]},transition:!0},"horizon-fog-blend":{type:"number","property-type":"data-constant",default:.8,minimum:0,maximum:1,expression:{interpolated:!0,parameters:["zoom"]},transition:!0},"sky-horizon-blend":{type:"number","property-type":"data-constant",default:.8,minimum:0,maximum:1,expression:{interpolated:!0,parameters:["zoom"]},transition:!0},"atmosphere-blend":{type:"number","property-type":"data-constant",default:.8,minimum:0,maximum:1,expression:{interpolated:!0,parameters:["zoom"]},transition:!0}},terrain:{source:{type:"string",required:!0},exaggeration:{type:"number",minimum:0,default:1}},projection:{type:{type:"projectionDefinition",default:"mercator","property-type":"data-constant",transition:!1,expression:{interpolated:!0,parameters:["zoom"]}}},paint:["paint_fill","paint_line","paint_circle","paint_heatmap","paint_fill-extrusion","paint_symbol","paint_raster","paint_hillshade","paint_color-relief","paint_background"],paint_fill:{"fill-antialias":{type:"boolean",default:!0,expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"fill-opacity":{type:"number",default:1,minimum:0,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"fill-layer-opacity":{type:"number",default:1,minimum:0,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom","global-state"]},"property-type":"data-constant"},"fill-color":{type:"color",default:"#000000",transition:!0,expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"fill-outline-color":{type:"color",transition:!0,requires:[{"!":"fill-pattern"},{"fill-antialias":!0}],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"fill-translate":{type:"array",value:"number",length:2,default:[0,0],transition:!0,units:"pixels",expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"fill-translate-anchor":{type:"enum",values:{map:{},viewport:{}},default:"map",requires:["fill-translate"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"fill-pattern":{type:"resolvedImage",transition:!0,expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"cross-faded-data-driven"}},"paint_fill-extrusion":{"fill-extrusion-opacity":{type:"number",default:1,minimum:0,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"fill-extrusion-color":{type:"color",default:"#000000",transition:!0,requires:[{"!":"fill-extrusion-pattern"}],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"fill-extrusion-translate":{type:"array",value:"number",length:2,default:[0,0],transition:!0,units:"pixels",expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"fill-extrusion-translate-anchor":{type:"enum",values:{map:{},viewport:{}},default:"map",requires:["fill-extrusion-translate"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"fill-extrusion-pattern":{type:"resolvedImage",transition:!0,expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"cross-faded-data-driven"},"fill-extrusion-height":{type:"number",default:0,units:"meters",transition:!0,expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"fill-extrusion-base":{type:"number",default:0,units:"meters",transition:!0,requires:["fill-extrusion-height"],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"fill-extrusion-vertical-gradient":{type:"boolean",default:!0,transition:!1,expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"}},paint_line:{"line-opacity":{type:"number",default:1,minimum:0,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"line-layer-opacity":{type:"number",default:1,minimum:0,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom","global-state"]},"property-type":"data-constant"},"line-color":{type:"color",default:"#000000",transition:!0,requires:[{"!":"line-pattern"}],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"line-translate":{type:"array",value:"number",length:2,default:[0,0],transition:!0,units:"pixels",expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"line-translate-anchor":{type:"enum",values:{map:{},viewport:{}},default:"map",requires:["line-translate"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"line-width":{type:"number",default:1,minimum:0,transition:!0,units:"pixels",expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"line-gap-width":{type:"number",default:0,minimum:0,transition:!0,units:"pixels",expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"line-offset":{type:"number",default:0,transition:!0,units:"pixels",expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"line-blur":{type:"number",default:0,minimum:0,transition:!0,units:"pixels",expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"line-dasharray":{type:"array",value:"number",minimum:0,transition:!0,units:"line widths",requires:[{"!":"line-pattern"}],expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"cross-faded-data-driven"},"line-pattern":{type:"resolvedImage",transition:!0,expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"cross-faded-data-driven"},"line-gradient":{type:"color",transition:!1,requires:[{"!":"line-dasharray"},{"!":"line-pattern"},{source:"geojson",has:{lineMetrics:!0}}],expression:{interpolated:!0,parameters:["line-progress"]},"property-type":"color-ramp"}},paint_circle:{"circle-radius":{type:"number",default:5,minimum:0,transition:!0,units:"pixels",expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"circle-color":{type:"color",default:"#000000",transition:!0,expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"circle-blur":{type:"number",default:0,transition:!0,expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"circle-opacity":{type:"number",default:1,minimum:0,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"circle-translate":{type:"array",value:"number",length:2,default:[0,0],transition:!0,units:"pixels",expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"circle-translate-anchor":{type:"enum",values:{map:{},viewport:{}},default:"map",requires:["circle-translate"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"circle-pitch-scale":{type:"enum",values:{map:{},viewport:{}},default:"map",expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"circle-pitch-alignment":{type:"enum",values:{map:{},viewport:{}},default:"viewport",expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"circle-stroke-width":{type:"number",default:0,minimum:0,transition:!0,units:"pixels",expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"circle-stroke-color":{type:"color",default:"#000000",transition:!0,expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"circle-stroke-opacity":{type:"number",default:1,minimum:0,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"}},paint_heatmap:{"heatmap-radius":{type:"number",default:30,minimum:1,transition:!0,units:"pixels",expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"heatmap-weight":{type:"number",default:1,minimum:0,transition:!1,expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"heatmap-intensity":{type:"number",default:1,minimum:0,transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"heatmap-color":{type:"color",default:["interpolate",["linear"],["heatmap-density"],0,"rgba(0, 0, 255, 0)",.1,"royalblue",.3,"cyan",.5,"lime",.7,"yellow",1,"red"],transition:!1,expression:{interpolated:!0,parameters:["heatmap-density"]},"property-type":"color-ramp"},"heatmap-opacity":{type:"number",default:1,minimum:0,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"}},paint_symbol:{"icon-opacity":{type:"number",default:1,minimum:0,maximum:1,transition:!0,requires:["icon-image"],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"icon-color":{type:"color",default:"#000000",transition:!0,requires:["icon-image"],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"icon-halo-color":{type:"color",default:"rgba(0, 0, 0, 0)",transition:!0,requires:["icon-image"],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"icon-halo-width":{type:"number",default:0,minimum:0,transition:!0,units:"pixels",requires:["icon-image"],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"icon-halo-blur":{type:"number",default:0,minimum:0,transition:!0,units:"pixels",requires:["icon-image"],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"icon-translate":{type:"array",value:"number",length:2,default:[0,0],transition:!0,units:"pixels",requires:["icon-image"],expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"icon-translate-anchor":{type:"enum",values:{map:{},viewport:{}},default:"map",requires:["icon-image","icon-translate"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"text-opacity":{type:"number",default:1,minimum:0,maximum:1,transition:!0,requires:["text-field"],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"text-color":{type:"color",default:"#000000",transition:!0,overridable:!0,requires:["text-field"],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"text-halo-color":{type:"color",default:"rgba(0, 0, 0, 0)",transition:!0,requires:["text-field"],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"text-halo-width":{type:"number",default:0,minimum:0,transition:!0,units:"pixels",requires:["text-field"],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"text-halo-blur":{type:"number",default:0,minimum:0,transition:!0,units:"pixels",requires:["text-field"],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"text-translate":{type:"array",value:"number",length:2,default:[0,0],transition:!0,units:"pixels",requires:["text-field"],expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"text-translate-anchor":{type:"enum",values:{map:{},viewport:{}},default:"map",requires:["text-field","text-translate"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"}},paint_raster:{"raster-opacity":{type:"number",default:1,minimum:0,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"raster-hue-rotate":{type:"number",default:0,period:360,transition:!0,units:"degrees",expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"raster-brightness-min":{type:"number",default:0,minimum:0,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"raster-brightness-max":{type:"number",default:1,minimum:0,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"raster-saturation":{type:"number",default:0,minimum:-1,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"raster-contrast":{type:"number",default:0,minimum:-1,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},resampling:{type:"enum",values:{linear:{},nearest:{}},default:"linear",expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"raster-resampling":{type:"enum",values:{linear:{},nearest:{}},default:"linear",expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"raster-fade-duration":{type:"number",default:300,minimum:0,transition:!1,units:"milliseconds",expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"}},paint_hillshade:{"hillshade-illumination-direction":{type:"numberArray",default:335,minimum:0,maximum:359,transition:!1,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"hillshade-illumination-altitude":{type:"numberArray",default:45,minimum:0,maximum:90,transition:!1,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"hillshade-illumination-anchor":{type:"enum",values:{map:{},viewport:{}},default:"viewport",expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"hillshade-exaggeration":{type:"number",default:.5,minimum:0,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"hillshade-shadow-color":{type:"colorArray",default:"#000000",transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"hillshade-highlight-color":{type:"colorArray",default:"#FFFFFF",transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"hillshade-accent-color":{type:"color",default:"#000000",transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"hillshade-method":{type:"enum",values:{standard:{},basic:{},combined:{},igor:{},multidirectional:{}},default:"standard",expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},resampling:{type:"enum",values:{linear:{},nearest:{}},default:"linear",expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"}},"paint_color-relief":{"color-relief-opacity":{type:"number",default:1,minimum:0,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"color-relief-color":{type:"color",transition:!1,expression:{interpolated:!0,parameters:["elevation"]},"property-type":"color-ramp"},resampling:{type:"enum",values:{linear:{},nearest:{}},default:"linear",expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"}},paint_background:{"background-color":{type:"color",default:"#000000",transition:!0,requires:[{"!":"background-pattern"}],expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"background-pattern":{type:"resolvedImage",transition:!0,expression:{interpolated:!1,parameters:["zoom"]},"property-type":"cross-faded"},"background-opacity":{type:"number",default:1,minimum:0,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"}},transition:{duration:{type:"number",default:300,minimum:0,units:"milliseconds"},delay:{type:"number",default:0,minimum:0,units:"milliseconds"}},"property-type":{"data-driven":{type:"property-type"},"cross-faded":{type:"property-type"},"cross-faded-data-driven":{type:"property-type"},"color-ramp":{type:"property-type"},"data-constant":{type:"property-type"},constant:{type:"property-type"}},promoteId:{"*":{type:"string"}},interpolation:{type:"array",value:"interpolation_name",minimum:1},interpolation_name:{type:"enum",values:{linear:{syntax:{overloads:[{parameters:[],"output-type":"interpolation"}],parameters:[]}},exponential:{syntax:{overloads:[{parameters:["base"],"output-type":"interpolation"}],parameters:[{name:"base",type:"number literal"}]}},"cubic-bezier":{syntax:{overloads:[{parameters:["x1","y1","x2","y2"],"output-type":"interpolation"}],parameters:[{name:"x1",type:"number literal"},{name:"y1",type:"number literal"},{name:"x2",type:"number literal"},{name:"y2",type:"number literal"}]}}}}},F=Q_,Ew=["type","source","source-layer","minzoom","maxzoom","filter","layout"];function Dw(e,t){let i={};for(let r in e)r!=="ref"&&(i[r]=e[r]);return Ew.forEach(r=>{r in t&&(i[r]=t[r])}),i}function Cf(e){e=e.slice();let t=Object.create(null);for(let i=0;i<e.length;i++)t[e[i].id]=e[i];for(let i=0;i<e.length;i++)"ref"in e[i]&&(e[i]=Dw(e[i],t[e[i].ref]));return e}function Me(e,t){if(Array.isArray(e)){if(!Array.isArray(t)||e.length!==t.length)return!1;for(let i=0;i<e.length;i++)if(!Me(e[i],t[i]))return!1;return!0}if(typeof e=="object"&&e&&t!==null){if(typeof t!="object"||Object.keys(e).length!==Object.keys(t).length)return!1;for(let i in e)if(!Me(e[i],t[i]))return!1;return!0}return e===t}function ii(e,t){e.push(t)}function ey(e,t,i){ii(i,{command:"addSource",args:[e,t[e]]})}function ty(e,t,i){ii(t,{command:"removeSource",args:[e]}),i[e]=!0}function Sw(e,t,i,r){ty(e,i,r),ey(e,t,i)}function Cw(e,t,i){let r;for(r in e[i])if(Object.prototype.hasOwnProperty.call(e[i],r)&&r!=="data"&&!Me(e[i][r],t[i][r]))return!1;for(r in t[i])if(Object.prototype.hasOwnProperty.call(t[i],r)&&r!=="data"&&!Me(e[i][r],t[i][r]))return!1;return!0}function Pw(e,t,i,r){e||(e={}),t||(t={});let a;for(a in e)Object.prototype.hasOwnProperty.call(e,a)&&(Object.prototype.hasOwnProperty.call(t,a)||ty(a,i,r));for(a in t)Object.prototype.hasOwnProperty.call(t,a)&&(Object.prototype.hasOwnProperty.call(e,a)?Me(e[a],t[a])||(e[a].type==="geojson"&&t[a].type==="geojson"&&Cw(e,t,a)?ii(i,{command:"setGeoJSONSourceData",args:[a,t[a].data]}):Sw(a,t,i,r)):ey(a,t,i))}function Pf(e,t,i,r,a){ii(t,{command:a,args:[i,r,e[r]]})}function rs(e,t,i,r,a){e||(e={}),t||(t={});for(let n in e)Object.prototype.hasOwnProperty.call(e,n)&&(Me(e[n],t[n])||Pf(t,i,r,n,a));for(let n in t)Object.prototype.hasOwnProperty.call(t,n)&&!Object.prototype.hasOwnProperty.call(e,n)&&(Me(e[n],t[n])||Pf(t,i,r,n,a))}function Af(e){return e.id}function If(e,t){return e[t.id]=t,e}function Aw(e,t,i){e||(e=[]),t||(t=[]);let r=e.map(Af),a=t.map(Af),n=e.reduce(If,{}),o=t.reduce(If,{}),s=r.slice(),l=Object.create(null),u,h,c,d,p;for(let f=0,m=0;f<r.length;f++)u=r[f],Object.prototype.hasOwnProperty.call(o,u)?m++:(ii(i,{command:"removeLayer",args:[u]}),s.splice(s.indexOf(u,m),1));for(let f=0,m=0;f<a.length;f++)u=a[a.length-1-f],s[s.length-1-f]!==u&&(Object.prototype.hasOwnProperty.call(n,u)?(ii(i,{command:"removeLayer",args:[u]}),s.splice(s.lastIndexOf(u,s.length-m),1)):m++,d=s[s.length-f],ii(i,{command:"addLayer",args:[o[u],d]}),s.splice(s.length-f,0,u),l[u]=!0);for(let f=0;f<a.length;f++)if(u=a[f],h=n[u],c=o[u],!(l[u]||Me(h,c))){if(!Me(h.source,c.source)||!Me(h["source-layer"],c["source-layer"])||!Me(h.type,c.type)){ii(i,{command:"removeLayer",args:[u]}),d=s[s.lastIndexOf(u)+1],ii(i,{command:"addLayer",args:[c,d]});continue}for(p in rs(h.layout,c.layout,i,u,"setLayoutProperty"),rs(h.paint,c.paint,i,u,"setPaintProperty"),Me(h.filter,c.filter)||ii(i,{command:"setFilter",args:[u,c.filter]}),(!Me(h.minzoom,c.minzoom)||!Me(h.maxzoom,c.maxzoom))&&ii(i,{command:"setLayerZoomRange",args:[u,c.minzoom,c.maxzoom]}),h)Object.prototype.hasOwnProperty.call(h,p)&&p!=="layout"&&p!=="paint"&&p!=="filter"&&p!=="metadata"&&p!=="minzoom"&&p!=="maxzoom"&&(p.indexOf("paint.")===0?rs(h[p],c[p],i,u,"setPaintProperty"):Me(h[p],c[p])||ii(i,{command:"setLayerProperty",args:[u,p,c[p]]}));for(p in c)Object.prototype.hasOwnProperty.call(c,p)&&!Object.prototype.hasOwnProperty.call(h,p)&&p!=="layout"&&p!=="paint"&&p!=="filter"&&p!=="metadata"&&p!=="minzoom"&&p!=="maxzoom"&&(p.indexOf("paint.")===0?rs(h[p],c[p],i,u,"setPaintProperty"):Me(h[p],c[p])||ii(i,{command:"setLayerProperty",args:[u,p,c[p]]}))}}function Iw(e,t){if(!e)return[{command:"setStyle",args:[t]}];let i=[];try{if(!Me(e.version,t.version))return[{command:"setStyle",args:[t]}];Me(e.center,t.center)||i.push({command:"setCenter",args:[t.center]}),Me(e.state,t.state)||i.push({command:"setGlobalState",args:[t.state]}),Me(e.centerAltitude,t.centerAltitude)||i.push({command:"setCenterAltitude",args:[t.centerAltitude]}),Me(e.zoom,t.zoom)||i.push({command:"setZoom",args:[t.zoom]}),Me(e.bearing,t.bearing)||i.push({command:"setBearing",args:[t.bearing]}),Me(e.pitch,t.pitch)||i.push({command:"setPitch",args:[t.pitch]}),Me(e.roll,t.roll)||i.push({command:"setRoll",args:[t.roll]}),Me(e.sprite,t.sprite)||i.push({command:"setSprite",args:[t.sprite]}),Me(e.glyphs,t.glyphs)||i.push({command:"setGlyphs",args:[t.glyphs]}),Me(e["font-faces"],t["font-faces"])||i.push({command:"setFontFaces",args:[t["font-faces"]]}),Me(e.transition,t.transition)||i.push({command:"setTransition",args:[t.transition]}),Me(e.light,t.light)||i.push({command:"setLight",args:[t.light]});let r=!Me(e.terrain,t.terrain);r&&!t.terrain&&i.push({command:"setTerrain",args:[void 0]}),Me(e.sky,t.sky)||i.push({command:"setSky",args:[t.sky]}),Me(e.projection,t.projection)||i.push({command:"setProjection",args:[t.projection]});let a={},n=[];Pw(e.sources,t.sources,n,a);let o=[];e.layers&&e.layers.forEach(s=>{"source"in s&&a[s.source]?i.push({command:"removeLayer",args:[s.id]}):o.push(s)}),i=i.concat(n),Aw(o,t.layers,i),r&&t.terrain&&i.push({command:"setTerrain",args:[t.terrain]})}catch(r){console.warn("Unable to compute style diff:",r),i=[{command:"setStyle",args:[t]}]}return i}var L=class{constructor(e,t,i,r,a="error"){this.message=(e?`${e}: `:"")+i,r&&(this.identifier=r),this.severity=a,t!=null&&t.__line__&&(this.line=t.__line__)}},xo={kind:"null"},N={kind:"number"},le={kind:"string"},me={kind:"boolean"},Ai={kind:"color"},Cl={kind:"projectionDefinition"},Wr={kind:"object"},he={kind:"value"},Mw={kind:"error"},Pl={kind:"collator"},bo={kind:"formatted"},Al={kind:"padding"},Kn={kind:"colorArray"},Il={kind:"numberArray"},wo={kind:"resolvedImage"},Ml={kind:"variableAnchorOffsetCollection"};function Rt(e,t){return{kind:"array",itemType:e,N:t}}function Ke(e){if(e.kind==="array"){let t=Ke(e.itemType);return typeof e.N=="number"?`array<${t}, ${e.N}>`:e.itemType.kind==="value"?"array":`array<${t}>`}return e.kind}var Fw=[xo,N,le,me,Ai,Cl,bo,Wr,Rt(he),Al,Il,Kn,wo,Ml];function Jn(e,t){if(t.kind==="error")return null;if(e.kind==="array"){if(t.kind==="array"&&(t.N===0&&t.itemType.kind==="value"||!Jn(e.itemType,t.itemType))&&(typeof e.N!="number"||e.N===t.N))return null}else{if(e.kind===t.kind)return null;if(e.kind==="value"){for(let i of Fw)if(!Jn(i,t))return null}}return`Expected ${Ke(e)} but found ${Ke(t)} instead.`}function wd(e,t){return t.some(i=>i.kind===e.kind)}function Hr(e,t){return t.some(i=>i==="null"?e===null:i==="array"?Array.isArray(e):i==="object"?e&&!Array.isArray(e)&&typeof e=="object":i===typeof e)}function mr(e,t){return e.kind==="array"&&t.kind==="array"?e.itemType.kind===t.itemType.kind&&typeof e.N=="number":e.kind===t.kind}var iy=.96422,ry=.82521,ay=4/29,kh=6/29,ny=3*kh*kh,zw=Math.PI/180,Rw=180/Math.PI;function oy(e){return e%=360,e<0&&(e+=360),e}function sy([e,t,i,r]){e=ju(e),t=ju(t),i=ju(i);let a,n,o=Vu((.2225045*e+.7168786*t+.0606169*i)/1);e===t&&t===i?a=n=o:(a=Vu((.4360747*e+.3850649*t+.1430804*i)/iy),n=Vu((.0139322*e+.0971045*t+.7141733*i)/ry));let s=116*o-16;return[s<0?0:s,500*(a-o),200*(o-n),r]}function ju(e){return e<=.04045?e/12.92:((e+.055)/1.055)**2.4}function Vu(e){return e>.008856451679035631?e**(1/3):e/ny+ay}function ly([e,t,i,r]){let a=(e+16)/116,n=isNaN(t)?a:a+t/500,o=isNaN(i)?a:a-i/200;return a=1*Uu(a),n=iy*Uu(n),o=ry*Uu(o),[Nu(3.1338561*n-1.6168667*a-.4906146*o),Nu(-.9787684*n+1.9161415*a+.033454*o),Nu(.0719453*n-.2289914*a+1.4052427*o),r]}function Nu(e){return e=e<=.00304?12.92*e:1.055*e**(1/2.4)-.055,e<0?0:e>1?1:e}function Uu(e){return e>kh?e*e*e:ny*(e-ay)}function kw(e){let[t,i,r,a]=sy(e),n=Math.sqrt(i*i+r*r);return[Math.round(n*1e4)?oy(Math.atan2(r,i)*Rw):NaN,n,t,a]}function Lw([e,t,i,r]){return e=isNaN(e)?0:e*zw,ly([i,Math.cos(e)*t,Math.sin(e)*t,r])}function Bw([e,t,i,r]){e=oy(e),t/=100,i/=100;function a(n){let o=(n+e/30)%12,s=t*Math.min(i,1-i);return i-s*Math.max(-1,Math.min(o-3,9-o,1))}return[a(0),a(8),a(4),r]}var Ow=Object.hasOwn||function(e,t){return Object.prototype.hasOwnProperty.call(e,t)};function jn(e,t){return Ow(e,t)?e[t]:void 0}function jw(e){if(e=e.toLowerCase().trim(),e==="transparent")return[0,0,0,0];let t=jn(Vw,e);if(t){let[r,a,n]=t;return[r/255,a/255,n/255,1]}if(e.startsWith("#")&&/^#(?:[0-9a-f]{3,4}|[0-9a-f]{6}|[0-9a-f]{8})$/.test(e)){let r=e.length<6?1:2,a=1;return[as(e.slice(a,a+=r)),as(e.slice(a,a+=r)),as(e.slice(a,a+=r)),as(e.slice(a,a+r)||"ff")]}if(e.startsWith("rgb")){let r=e.match(/^rgba?\(\s*([\de.+-]+)(%)?(?:\s+|\s*(,)\s*)([\de.+-]+)(%)?(?:\s+|\s*(,)\s*)([\de.+-]+)(%)?(?:\s*([,\/])\s*([\de.+-]+)(%)?)?\s*\)$/);if(r){let[a,n,o,s,l,u,h,c,d,p,f,m]=r,g=[s||" ",h||" ",p].join("");if(g===" "||g===" /"||g===",,"||g===",,,"){let _=[o,u,d].join(""),y=_==="%%%"?100:_===""?255:0;if(y){let v=[Ta(+n/y,0,1),Ta(+l/y,0,1),Ta(+c/y,0,1),f?Mf(+f,m):1];if(Ff(v))return v}}return}}let i=e.match(/^hsla?\(\s*([\de.+-]+)(?:deg)?(?:\s+|\s*(,)\s*)([\de.+-]+)%(?:\s+|\s*(,)\s*)([\de.+-]+)%(?:\s*([,\/])\s*([\de.+-]+)(%)?)?\s*\)$/);if(i){let[r,a,n,o,s,l,u,h,c]=i,d=[n||" ",s||" ",u].join("");if(d===" "||d===" /"||d===",,"||d===",,,"){let p=[+a,Ta(+o,0,100),Ta(+l,0,100),h?Mf(+h,c):1];if(Ff(p))return Bw(p)}}}function as(e){return parseInt(e.padEnd(2,e),16)/255}function Mf(e,t){return Ta(t?e/100:e,0,1)}function Ta(e,t,i){return Math.min(Math.max(t,e),i)}function Ff(e){return!e.some(Number.isNaN)}var Vw={aliceblue:[240,248,255],antiquewhite:[250,235,215],aqua:[0,255,255],aquamarine:[127,255,212],azure:[240,255,255],beige:[245,245,220],bisque:[255,228,196],black:[0,0,0],blanchedalmond:[255,235,205],blue:[0,0,255],blueviolet:[138,43,226],brown:[165,42,42],burlywood:[222,184,135],cadetblue:[95,158,160],chartreuse:[127,255,0],chocolate:[210,105,30],coral:[255,127,80],cornflowerblue:[100,149,237],cornsilk:[255,248,220],crimson:[220,20,60],cyan:[0,255,255],darkblue:[0,0,139],darkcyan:[0,139,139],darkgoldenrod:[184,134,11],darkgray:[169,169,169],darkgreen:[0,100,0],darkgrey:[169,169,169],darkkhaki:[189,183,107],darkmagenta:[139,0,139],darkolivegreen:[85,107,47],darkorange:[255,140,0],darkorchid:[153,50,204],darkred:[139,0,0],darksalmon:[233,150,122],darkseagreen:[143,188,143],darkslateblue:[72,61,139],darkslategray:[47,79,79],darkslategrey:[47,79,79],darkturquoise:[0,206,209],darkviolet:[148,0,211],deeppink:[255,20,147],deepskyblue:[0,191,255],dimgray:[105,105,105],dimgrey:[105,105,105],dodgerblue:[30,144,255],firebrick:[178,34,34],floralwhite:[255,250,240],forestgreen:[34,139,34],fuchsia:[255,0,255],gainsboro:[220,220,220],ghostwhite:[248,248,255],gold:[255,215,0],goldenrod:[218,165,32],gray:[128,128,128],green:[0,128,0],greenyellow:[173,255,47],grey:[128,128,128],honeydew:[240,255,240],hotpink:[255,105,180],indianred:[205,92,92],indigo:[75,0,130],ivory:[255,255,240],khaki:[240,230,140],lavender:[230,230,250],lavenderblush:[255,240,245],lawngreen:[124,252,0],lemonchiffon:[255,250,205],lightblue:[173,216,230],lightcoral:[240,128,128],lightcyan:[224,255,255],lightgoldenrodyellow:[250,250,210],lightgray:[211,211,211],lightgreen:[144,238,144],lightgrey:[211,211,211],lightpink:[255,182,193],lightsalmon:[255,160,122],lightseagreen:[32,178,170],lightskyblue:[135,206,250],lightslategray:[119,136,153],lightslategrey:[119,136,153],lightsteelblue:[176,196,222],lightyellow:[255,255,224],lime:[0,255,0],limegreen:[50,205,50],linen:[250,240,230],magenta:[255,0,255],maroon:[128,0,0],mediumaquamarine:[102,205,170],mediumblue:[0,0,205],mediumorchid:[186,85,211],mediumpurple:[147,112,219],mediumseagreen:[60,179,113],mediumslateblue:[123,104,238],mediumspringgreen:[0,250,154],mediumturquoise:[72,209,204],mediumvioletred:[199,21,133],midnightblue:[25,25,112],mintcream:[245,255,250],mistyrose:[255,228,225],moccasin:[255,228,181],navajowhite:[255,222,173],navy:[0,0,128],oldlace:[253,245,230],olive:[128,128,0],olivedrab:[107,142,35],orange:[255,165,0],orangered:[255,69,0],orchid:[218,112,214],palegoldenrod:[238,232,170],palegreen:[152,251,152],paleturquoise:[175,238,238],palevioletred:[219,112,147],papayawhip:[255,239,213],peachpuff:[255,218,185],peru:[205,133,63],pink:[255,192,203],plum:[221,160,221],powderblue:[176,224,230],purple:[128,0,128],rebeccapurple:[102,51,153],red:[255,0,0],rosybrown:[188,143,143],royalblue:[65,105,225],saddlebrown:[139,69,19],salmon:[250,128,114],sandybrown:[244,164,96],seagreen:[46,139,87],seashell:[255,245,238],sienna:[160,82,45],silver:[192,192,192],skyblue:[135,206,235],slateblue:[106,90,205],slategray:[112,128,144],slategrey:[112,128,144],snow:[255,250,250],springgreen:[0,255,127],steelblue:[70,130,180],tan:[210,180,140],teal:[0,128,128],thistle:[216,191,216],tomato:[255,99,71],turquoise:[64,224,208],violet:[238,130,238],wheat:[245,222,179],white:[255,255,255],whitesmoke:[245,245,245],yellow:[255,255,0],yellowgreen:[154,205,50]};function Er(e,t,i){return e+i*(t-e)}function Ga(e,t,i){return e.map((r,a)=>Er(r,t[a],i))}function Nw(e){return e==="rgb"||e==="hcl"||e==="lab"}var vt,oe=(vt=class{constructor(t,i,r,a=1,n=!0){this.r=t,this.g=i,this.b=r,this.a=a,n||(this.r*=a,this.g*=a,this.b*=a,a||this.overwriteGetter("rgb",[t,i,r,a]))}static parse(t){if(t instanceof vt)return t;if(typeof t!="string")return;let i=jw(t);if(i)return new vt(...i,!1)}get rgb(){let{r:t,g:i,b:r,a}=this,n=a||1/0;return this.overwriteGetter("rgb",[t/n,i/n,r/n,a])}get hcl(){return this.overwriteGetter("hcl",kw(this.rgb))}get lab(){return this.overwriteGetter("lab",sy(this.rgb))}overwriteGetter(t,i){return Object.defineProperty(this,t,{value:i}),i}toString(){let[t,i,r,a]=this.rgb;return`rgba(${[t,i,r].map(n=>Math.round(n*255)).join(",")},${a})`}static interpolate(t,i,r,a="rgb"){switch(a){case"rgb":{let[n,o,s,l]=Ga(t.rgb,i.rgb,r);return new vt(n,o,s,l,!1)}case"hcl":{let[n,o,s,l]=t.hcl,[u,h,c,d]=i.hcl,p,f;if(!isNaN(n)&&!isNaN(u)){let v=u-n;u>n&&v>180?v-=360:u<n&&n-u>180&&(v+=360),p=n+r*v}else isNaN(n)?isNaN(u)?p=NaN:(p=u,(s===1||s===0)&&(f=h)):(p=n,(c===1||c===0)&&(f=o));let[m,g,_,y]=Lw([p,f??Er(o,h,r),Er(s,c,r),Er(l,d,r)]);return new vt(m,g,_,y,!1)}case"lab":{let[n,o,s,l]=ly(Ga(t.lab,i.lab,r));return new vt(n,o,s,l,!1)}}}},vt.black=new vt(0,0,0,1),vt.white=new vt(1,1,1,1),vt.transparent=new vt(0,0,0,0),vt.red=new vt(1,0,0,1),vt),Uw=["bottom","center","top"],Lh=class{constructor(e,t,i,r,a,n){this.text=e,this.image=t,this.scale=i,this.fontStack=r,this.textColor=a,this.verticalAlign=n}},hr=class zs{constructor(t){this.sections=t}static fromString(t){return new zs([new Lh(t,null,null,null,null,null)])}isEmpty(){return this.sections.length===0||!this.sections.some(t=>t.text.length!==0||t.image&&t.image.name.length!==0)}static factory(t){return t instanceof zs?t:zs.fromString(t)}toString(){return this.sections.length===0?"":this.sections.map(t=>t.text).join("")}},Yi=class Mn{constructor(t){this.values=t.slice()}static parse(t){if(t instanceof Mn)return t;if(typeof t=="number")return new Mn([t,t,t,t]);if(Array.isArray(t)&&!(t.length<1||t.length>4)){for(let i of t)if(typeof i!="number")return;switch(t.length){case 1:t=[t[0],t[0],t[0],t[0]];break;case 2:t=[t[0],t[1],t[0],t[1]];break;case 3:t=[t[0],t[1],t[2],t[1]]}return new Mn(t)}}toString(){return JSON.stringify(this.values)}static interpolate(t,i,r){return new Mn(Ga(t.values,i.values,r))}},Ki=class Fn{constructor(t){this.values=t.slice()}static parse(t){if(t instanceof Fn)return t;if(typeof t=="number")return new Fn([t]);if(Array.isArray(t)){for(let i of t)if(typeof i!="number")return;return new Fn(t)}}toString(){return JSON.stringify(this.values)}static interpolate(t,i,r){return new Fn(Ga(t.values,i.values,r))}},bi=class zn{constructor(t){this.values=t.slice()}static parse(t){if(t instanceof zn)return t;if(typeof t=="string"){let r=oe.parse(t);return r?new zn([r]):void 0}if(!Array.isArray(t))return;let i=[];for(let r of t){if(typeof r!="string")return;let a=oe.parse(r);if(!a)return;i.push(a)}return new zn(i)}toString(){return JSON.stringify(this.values)}static interpolate(t,i,r,a="rgb"){let n=[];if(t.values.length!=i.values.length)throw Error(`colorArray: Arrays have mismatched length (${t.values.length} vs. ${i.values.length}), cannot interpolate.`);for(let o=0;o<t.values.length;o++)n.push(oe.interpolate(t.values[o],i.values[o],r,a));return new zn(n)}},We=class extends Error{constructor(e,t){super(e),this.name="RuntimeError",this.path=t}toJSON(){return this.message}},$w=new Set(["center","left","right","top","bottom","top-left","top-right","bottom-left","bottom-right"]),Wi=class Rs{constructor(t){this.values=t.slice()}static parse(t){if(t instanceof Rs)return t;if(!(!Array.isArray(t)||t.length<1||t.length%2!=0)){for(let i=0;i<t.length;i+=2){let r=t[i],a=t[i+1];if(typeof r!="string"||!$w.has(r)||!Array.isArray(a)||a.length!==2||typeof a[0]!="number"||typeof a[1]!="number")return}return new Rs(t)}}toString(){return JSON.stringify(this.values)}static interpolate(t,i,r,a){let n=t.values,o=i.values;if(n.length!==o.length)throw new We(`Cannot interpolate values of different length. from: ${t.toString()}, to: ${i.toString()}`,a);let s=[];for(let l=0;l<n.length;l+=2){if(n[l]!==o[l])throw new We(`Cannot interpolate values containing mismatched anchors. from[${l}]: ${n[l]}, to[${l}]: ${o[l]}`,a);s.push(n[l]);let[u,h]=n[l+1],[c,d]=o[l+1];s.push([Er(u,c,r),Er(h,d,r)])}return new Rs(s)}},Hi=class uy{constructor(t){this.name=t.name,this.available=t.available}toString(){return this.name}static fromString(t){return t?new uy({name:t,available:!1}):null}},Mr=class Ea{constructor(t,i,r){this.from=t,this.to=i,this.transition=r}toString(){return this.from===this.to&&this.transition===1?this.from:JSON.stringify([this.from,this.to,this.transition])}static interpolate(t,i,r){return new Ea(t,i,r)}static parse(t){if(t instanceof Ea)return t;if(Array.isArray(t)&&t.length===3&&typeof t[0]=="string"&&typeof t[1]=="string"&&typeof t[2]=="number")return new Ea(t[0],t[1],t[2]);if(typeof t=="object"&&typeof t.from=="string"&&typeof t.to=="string"&&typeof t.transition=="number")return new Ea(t.from,t.to,t.transition);if(typeof t=="string")return new Ea(t,t,1)}},Td=class{constructor(e,t,i){this.sensitivity=e?t?"variant":"case":t?"accent":"base",this.locale=i,this.collator=new Intl.Collator(this.locale?this.locale:[],{sensitivity:this.sensitivity,usage:"search"})}compare(e,t){return this.collator.compare(e,t)}resolvedLocale(){return new Intl.Collator(this.locale?this.locale:[]).resolvedOptions().locale}};function hy(e,t,i,r){return typeof e=="number"&&e>=0&&e<=255&&typeof t=="number"&&t>=0&&t<=255&&typeof i=="number"&&i>=0&&i<=255?r===void 0||typeof r=="number"&&r>=0&&r<=1?null:`Invalid rgba value [${[e,t,i,r].join(", ")}]: 'a' must be between 0 and 1.`:`Invalid rgba value [${(typeof r=="number"?[e,t,i,r]:[e,t,i]).join(", ")}]: 'r', 'g', and 'b' must be between 0 and 255.`}function Za(e){if(e===null||typeof e=="string"||typeof e=="boolean"||typeof e=="number"||e instanceof Mr||e instanceof oe||e instanceof Td||e instanceof hr||e instanceof Yi||e instanceof Ki||e instanceof bi||e instanceof Wi||e instanceof Hi)return!0;if(Array.isArray(e)){for(let t of e)if(!Za(t))return!1;return!0}if(typeof e=="object"){for(let t in e)if(!Za(e[t]))return!1;return!0}return!1}function at(e){if(e===null)return xo;if(typeof e=="string")return le;if(typeof e=="boolean")return me;if(typeof e=="number")return N;if(e instanceof oe)return Ai;if(e instanceof Mr)return Cl;if(e instanceof Td)return Pl;if(e instanceof hr)return bo;if(e instanceof Yi)return Al;if(e instanceof Ki)return Il;if(e instanceof bi)return Kn;if(e instanceof Wi)return Ml;if(e instanceof Hi)return wo;if(Array.isArray(e)){let t=e.length,i;for(let r of e){let a=at(r);if(!i)i=a;else{if(i===a)continue;i=he;break}}return Rt(i||he,t)}return Wr}function Vn(e){let t=typeof e;return e===null?"":t==="string"||t==="number"||t==="boolean"?String(e):e instanceof oe||e instanceof Mr||e instanceof hr||e instanceof Yi||e instanceof Ki||e instanceof bi||e instanceof Wi||e instanceof Hi?e.toString():JSON.stringify(e)}var qa=class cy{constructor(t,i){this.type=t,this.value=i}static parse(t,i){if(t.length!==2)return i.error(`'literal' expression requires exactly one argument, but found ${t.length-1} instead.`);if(!Za(t[1]))return i.error(`invalid value of type "${typeof t[1]}"`);let r=t[1],a=at(r),n=i.expectedType;return a.kind==="array"&&a.N===0&&n&&n.kind==="array"&&(typeof n.N!="number"||n.N===0)&&(a=n),new cy(a,r)}evaluate(){return this.value}eachChild(){}outputDefined(){return!0}},Gw=["Unknown","Point","LineString","Polygon"],dy=class{constructor(){this.globals=null,this.feature=null,this.featureState=null,this.formattedSection=null,this._parseColorCache=new Map,this.availableImages=null,this.canonical=null}id(){return this.feature&&"id"in this.feature?this.feature.id:null}geometryType(){return this.feature?typeof this.feature.type=="number"?Gw[this.feature.type]:this.feature.type:null}geometry(){return this.feature&&"geometry"in this.feature?this.feature.geometry:null}canonicalID(){return this.canonical}properties(){return this.feature&&this.feature.properties||{}}parseColor(e){let t=this._parseColorCache.get(e);return t||(t=oe.parse(e),this._parseColorCache.set(e,t)),t}};function Fl(e,t,i){let r=e.length-1,a=0,n=r,o=0,s,l;for(;a<=n;)if(o=Math.floor((a+n)/2),s=e[o],l=e[o+1],s<=t){if(o===r||t<l)return o;a=o+1}else if(s>t)n=o-1;else throw new We("Input is not a number.",i);return 0}var Ed=class py{constructor(t,i,r,a){this.type=t,this.input=i,this.key=a,this.labels=[],this.outputs=[];for(let[n,o]of r)this.labels.push(n),this.outputs.push(o)}static parse(t,i){if(t.length-1<4)return i.error(`Expected at least 4 arguments, but found only ${t.length-1}.`);if((t.length-1)%2!=0)return i.error("Expected an even number of arguments.");let r=i.parse(t[1],1,N);if(!r)return null;let a=[],n=null;i.expectedType&&i.expectedType.kind!=="value"&&(n=i.expectedType);for(let o=1;o<t.length;o+=2){let s=o===1?-1/0:t[o],l=t[o+1],u=o,h=o+1;if(typeof s!="number")return i.error('Input/output pairs for "step" expressions must be defined using literal numeric values (not computed expressions) for the input values.',u);if(a.length&&a[a.length-1][0]>=s)return i.error('Input/output pairs for "step" expressions must be arranged with input values in strictly ascending order.',u);let c=i.parse(l,h,n);if(!c)return null;n||(n=c.type),a.push([s,c])}return new py(n,r,a,i.key)}evaluate(t){let i=this.labels,r=this.outputs;if(i.length===1)return r[0].evaluate(t);let a=this.input.evaluate(t);if(a<=i[0])return r[0].evaluate(t);let n=i.length;return a>=i[n-1]?r[n-1].evaluate(t):r[Fl(i,a,this.key)].evaluate(t)}eachChild(t){t(this.input);for(let i of this.outputs)t(i)}outputDefined(){return this.outputs.every(t=>t.outputDefined())}};function Zw(e,t,i,r){let a=3*e,n=3*(i-e)-a,o=1-a-n,s=3*t,l=3*(r-t)-s,u=1-s-l;return function(h,c=1e-6){if(h<=0)return 0;if(h>=1)return 1;let d=h;for(let m=0;m<8;m++){let g=((o*d+n)*d+a)*d-h;if(Math.abs(g)<c)return((u*d+l)*d+s)*d;let _=(3*o*d+2*n)*d+a;if(Math.abs(_)<1e-6)break;d-=g/_}let p=0,f=1;d=h;for(let m=0;m<20;m++){let g=((o*d+n)*d+a)*d;if(Math.abs(g-h)<c)break;h>g?p=d:f=d,d=(p+f)*.5}return((u*d+l)*d+s)*d}}var wi=class Bh{constructor(t,i,r,a,n,o){this.type=t,this.operator=i,this.interpolation=r,this.input=a,this.key=o,this.labels=[],this.outputs=[];for(let[s,l]of n)this.labels.push(s),this.outputs.push(l)}static interpolationFactor(t,i,r,a){let n=0;if(t.name==="exponential")n=$u(i,t.base,r,a);else if(t.name==="linear")n=$u(i,1,r,a);else if(t.name==="cubic-bezier"){let o=t.controlPoints;n=Zw(o[0],o[1],o[2],o[3])($u(i,1,r,a))}return n}static parse(t,i){let[r,a,n,...o]=t;if(!Array.isArray(a)||a.length===0)return i.error("Expected an interpolation type expression.",1);if(a[0]==="linear")a={name:"linear"};else if(a[0]==="exponential"){let u=a[1];if(typeof u!="number")return i.error("Exponential interpolation requires a numeric base.",1,1);a={name:"exponential",base:u}}else if(a[0]==="cubic-bezier"){let u=a.slice(1);if(u.length!==4||u.some(h=>typeof h!="number"||h<0||h>1))return i.error("Cubic bezier interpolation requires four numeric arguments with values between 0 and 1.",1);a={name:"cubic-bezier",controlPoints:u}}else return i.error(`Unknown interpolation type ${String(a[0])}`,1,0);if(t.length-1<4)return i.error(`Expected at least 4 arguments, but found only ${t.length-1}.`);if((t.length-1)%2!=0)return i.error("Expected an even number of arguments.");if(n=i.parse(n,2,N),!n)return null;let s=[],l=null;(r==="interpolate-hcl"||r==="interpolate-lab")&&i.expectedType!=Kn?l=Ai:i.expectedType&&i.expectedType.kind!=="value"&&(l=i.expectedType);for(let u=0;u<o.length;u+=2){let h=o[u],c=o[u+1],d=u+3,p=u+4;if(typeof h!="number")return i.error('Input/output pairs for "interpolate" expressions must be defined using literal numeric values (not computed expressions) for the input values.',d);if(s.length&&s[s.length-1][0]>=h)return i.error('Input/output pairs for "interpolate" expressions must be arranged with input values in strictly ascending order.',d);let f=i.parse(c,p,l);if(!f)return null;l||(l=f.type),s.push([h,f])}return!mr(l,N)&&!mr(l,Cl)&&!mr(l,Ai)&&!mr(l,Al)&&!mr(l,Il)&&!mr(l,Kn)&&!mr(l,Ml)&&!mr(l,Rt(N))?i.error(`Type ${Ke(l)} is not interpolatable.`):new Bh(l,r,a,n,s,i.key)}evaluate(t){let i=this.labels,r=this.outputs;if(i.length===1)return r[0].evaluate(t);let a=this.input.evaluate(t);if(a<=i[0])return r[0].evaluate(t);let n=i.length;if(a>=i[n-1])return r[n-1].evaluate(t);let o=Fl(i,a,this.key),s=i[o],l=i[o+1],u=Bh.interpolationFactor(this.interpolation,a,s,l),h=r[o].evaluate(t),c=r[o+1].evaluate(t);switch(this.operator){case"interpolate":switch(this.type.kind){case"number":return Er(h,c,u);case"color":return oe.interpolate(h,c,u);case"padding":return Yi.interpolate(h,c,u);case"colorArray":return bi.interpolate(h,c,u);case"numberArray":return Ki.interpolate(h,c,u);case"variableAnchorOffsetCollection":return Wi.interpolate(h,c,u,this.key);case"array":return Ga(h,c,u);case"projectionDefinition":return Mr.interpolate(h,c,u)}case"interpolate-hcl":switch(this.type.kind){case"color":return oe.interpolate(h,c,u,"hcl");case"colorArray":return bi.interpolate(h,c,u,"hcl")}case"interpolate-lab":switch(this.type.kind){case"color":return oe.interpolate(h,c,u,"lab");case"colorArray":return bi.interpolate(h,c,u,"lab")}}}eachChild(t){t(this.input);for(let i of this.outputs)t(i)}outputDefined(){return this.outputs.every(t=>t.outputDefined())}};function $u(e,t,i,r){let a=r-i,n=e-i;return a===0?0:t===1?n/a:(t**+n-1)/(t**+a-1)}var He={color:oe.interpolate,number:Er,padding:Yi.interpolate,numberArray:Ki.interpolate,colorArray:bi.interpolate,variableAnchorOffsetCollection:Wi.interpolate,array:Ga},fy=class my{constructor(t){this.type=bo,this.sections=t}static parse(t,i){if(t.length<2)return i.error("Expected at least one argument.");let r=t[1];if(!Array.isArray(r)&&typeof r=="object")return i.error("First argument must be an image or text section.");let a=[],n=!1;for(let o=1;o<=t.length-1;++o){let s=t[o];if(n&&typeof s=="object"&&!Array.isArray(s)){n=!1;let l=null;if(s["font-scale"]&&(l=i.parse(s["font-scale"],1,N),!l))return null;let u=null;if(s["text-font"]&&(u=i.parse(s["text-font"],1,Rt(le)),!u))return null;let h=null;if(s["text-color"]&&(h=i.parse(s["text-color"],1,Ai),!h))return null;let c=null;if(s["vertical-align"]){if(typeof s["vertical-align"]=="string"&&!Uw.includes(s["vertical-align"]))return i.error(`'vertical-align' must be one of: 'bottom', 'center', 'top' but found '${s["vertical-align"]}' instead.`);if(c=i.parse(s["vertical-align"],1,le),!c)return null}let d=a[a.length-1];d.scale=l,d.font=u,d.textColor=h,d.verticalAlign=c}else{let l=i.parse(t[o],1,he);if(!l)return null;let u=l.type.kind;if(u!=="string"&&u!=="value"&&u!=="null"&&u!=="resolvedImage")return i.error("Formatted text type must be 'string', 'value', 'image' or 'null'.");n=!0,a.push({content:l,scale:null,font:null,textColor:null,verticalAlign:null})}}return new my(a)}evaluate(t){return new hr(this.sections.map(i=>{let r=i.content.evaluate(t);return at(r)===wo?new Lh("",r,null,null,null,i.verticalAlign?i.verticalAlign.evaluate(t):null):new Lh(Vn(r),null,i.scale?i.scale.evaluate(t):null,i.font?i.font.evaluate(t).join(","):null,i.textColor?i.textColor.evaluate(t):null,i.verticalAlign?i.verticalAlign.evaluate(t):null)}))}eachChild(t){for(let i of this.sections)t(i.content),i.scale&&t(i.scale),i.font&&t(i.font),i.textColor&&t(i.textColor),i.verticalAlign&&t(i.verticalAlign)}outputDefined(){return!1}};function gy(e,t,i=0,r=e.length-1,a=qw){for(;r>i;){if(r-i>600){let l=r-i+1,u=t-i+1,h=Math.log(l),c=.5*Math.exp(2*h/3),d=.5*Math.sqrt(h*c*(l-c)/l)*(u-l/2<0?-1:1);gy(e,t,Math.max(i,Math.floor(t-u*c/l+d)),Math.min(r,Math.floor(t+(l-u)*c/l+d)),a)}let n=e[t],o=i,s=r;for(yn(e,i,t),a(e[r],n)>0&&yn(e,i,r);o<s;){for(yn(e,o,s),o++,s--;a(e[o],n)<0;)o++;for(;a(e[s],n)>0;)s--}a(e[i],n)===0?yn(e,i,s):(s++,yn(e,s,r)),s<=t&&(i=s+1),t<=s&&(r=s-1)}}function yn(e,t,i){let r=e[t];e[t]=e[i],e[i]=r}function qw(e,t){return e<t?-1:+(e>t)}function zl(e,t){if(e.length<=1)return[e];let i=[],r,a;for(let n of e){let o=Hw(n);o!==0&&(n.area=Math.abs(o),a===void 0&&(a=o<0),a===o<0?(r&&i.push(r),r=[n]):r.push(n))}if(r&&i.push(r),t>1)for(let n=0;n<i.length;n++)i[n].length<=t||(gy(i[n],t,1,i[n].length-1,Ww),i[n]=i[n].slice(0,t));return i}function Ww(e,t){return t.area-e.area}function Hw(e){let t=0;for(let i=0,r=e.length,a=r-1,n,o;i<r;a=i++)n=e[i],o=e[a],t+=(o.x-n.x)*(n.y+o.y);return t}var ns={string:le,number:N,boolean:me,object:Wr},rr=class _y{constructor(t,i,r){this.type=t,this.args=i,this.key=r}static parse(t,i){if(t.length<2)return i.error("Expected at least one argument.");let r=1,a,n=t[0];if(n==="array"){let s;if(t.length>2){let u=t[1];if(typeof u!="string"||!(u in ns)||u==="object")return i.error('The item type argument of "array" must be one of string, number, boolean',1);s=ns[u],r++}else s=he;let l;if(t.length>3){if(t[2]!==null&&(typeof t[2]!="number"||t[2]<0||t[2]!==Math.floor(t[2])))return i.error('The length argument to "array" must be a positive integer literal',2);l=t[2],r++}a=Rt(s,l)}else{if(!ns[n])throw Error(`Types doesn't contain name = ${n}`);a=ns[n]}let o=[];for(;r<t.length;r++){let s=i.parse(t[r],r,he);if(!s)return null;o.push(s)}return new _y(a,o,i.key)}evaluate(t){for(let i=0;i<this.args.length;i++){let r=this.args[i].evaluate(t);if(!Jn(this.type,at(r)))return r;if(i===this.args.length-1)throw new We(`Expected value to be of type ${Ke(this.type)}, but found ${Ke(at(r))} instead.`,this.key)}throw Error()}eachChild(t){this.args.forEach(t)}outputDefined(){return this.args.every(t=>t.outputDefined())}},zf={"to-boolean":me,"to-color":Ai,"to-number":N,"to-string":le},Aa=class yy{constructor(t,i,r){this.type=t,this.args=i,this.key=r}static parse(t,i){if(t.length<2)return i.error("Expected at least one argument.");let r=t[0];if(!zf[r])throw Error(`Can't parse ${r} as it is not part of the known types`);if((r==="to-boolean"||r==="to-string")&&t.length!==2)return i.error("Expected one argument.");let a=zf[r],n=[];for(let o=1;o<t.length;o++){let s=i.parse(t[o],o,he);if(!s)return null;n.push(s)}return new yy(a,n,i.key)}evaluate(t){switch(this.type.kind){case"boolean":return!!this.args[0].evaluate(t);case"color":{let i,r;for(let a of this.args){if(i=a.evaluate(t),r=null,i instanceof oe)return i;if(typeof i=="string"){let n=t.parseColor(i);if(n)return n}else if(Array.isArray(i)&&(r=i.length<3||i.length>4?`Invalid rgba value ${JSON.stringify(i)}: expected an array containing either three or four numeric values.`:hy(i[0],i[1],i[2],i[3]),!r))return new oe(i[0]/255,i[1]/255,i[2]/255,i[3])}throw new We(r||`Could not parse color from value '${typeof i=="string"?i:JSON.stringify(i)}'`,this.key)}case"padding":{let i;for(let r of this.args){i=r.evaluate(t);let a=Yi.parse(i);if(a)return a}throw new We(`Could not parse padding from value '${typeof i=="string"?i:JSON.stringify(i)}'`,this.key)}case"numberArray":{let i;for(let r of this.args){i=r.evaluate(t);let a=Ki.parse(i);if(a)return a}throw new We(`Could not parse numberArray from value '${typeof i=="string"?i:JSON.stringify(i)}'`,this.key)}case"colorArray":{let i;for(let r of this.args){i=r.evaluate(t);let a=bi.parse(i);if(a)return a}throw new We(`Could not parse colorArray from value '${typeof i=="string"?i:JSON.stringify(i)}'`,this.key)}case"variableAnchorOffsetCollection":{let i;for(let r of this.args){i=r.evaluate(t);let a=Wi.parse(i);if(a)return a}throw new We(`Could not parse variableAnchorOffsetCollection from value '${typeof i=="string"?i:JSON.stringify(i)}'`,this.key)}case"number":{let i=null;for(let r of this.args){if(i=r.evaluate(t),i===null)return 0;let a=Number(i);if(!isNaN(a))return a}throw new We(`Could not convert ${JSON.stringify(i)} to number.`,this.key)}case"formatted":return hr.fromString(Vn(this.args[0].evaluate(t)));case"resolvedImage":return Hi.fromString(Vn(this.args[0].evaluate(t)));case"projectionDefinition":{let i=this.args[0].evaluate(t);if(Mr.parse(i))return i;throw new We(`Could not parse projectionDefinition from value '${typeof i=="string"?i:JSON.stringify(i)}'`,this.key)}default:return Vn(this.args[0].evaluate(t))}}eachChild(t){this.args.forEach(t)}outputDefined(){return this.args.every(t=>t.outputDefined())}},vy=class xy{constructor(t,i){this.type=i.type,this.bindings=[].concat(t),this.result=i}evaluate(t){return this.result.evaluate(t)}eachChild(t){for(let i of this.bindings)t(i[1]);t(this.result)}static parse(t,i){if(t.length<4)return i.error(`Expected at least 3 arguments, but found ${t.length-1} instead.`);let r=[];for(let n=1;n<t.length-1;n+=2){let o=t[n];if(typeof o!="string")return i.error(`Expected string, but found ${typeof o} instead.`,n);if(/[^a-zA-Z0-9_]/.test(o))return i.error("Variable names must contain only alphanumeric characters or '_'.",n);let s=i.parse(t[n+1],n+1);if(!s)return null;r.push([o,s])}let a=i.parse(t[t.length-1],t.length-1,i.expectedType,r);return a?new xy(r,a):null}outputDefined(){return this.result.outputDefined()}},by=class wy{constructor(t,i){this.type=i.type,this.name=t,this.boundExpression=i}static parse(t,i){if(t.length!==2||typeof t[1]!="string")return i.error("'var' expression requires exactly one string literal argument.");let r=t[1];return i.scope.has(r)?new wy(r,i.scope.get(r)):i.error(`Unknown variable "${r}". Make sure "${r}" has been bound in an enclosing "let" expression before using it.`,1)}evaluate(t){return this.boundExpression.evaluate(t)}eachChild(){}outputDefined(){return!1}},Xw=class Ty{constructor(t,i,r,a){this.type=t,this.index=i,this.input=r,this.key=a}static parse(t,i){if(t.length!==3)return i.error(`Expected 2 arguments, but found ${t.length-1} instead.`);let r=i.parse(t[1],1,N),a=i.parse(t[2],2,Rt(i.expectedType||he));if(!r||!a)return null;let n=a.type;return new Ty(n.itemType,r,a,i.key)}evaluate(t){let i=this.index.evaluate(t),r=this.input.evaluate(t);if(i<0)throw new We(`Array index out of bounds: ${i} < 0.`,this.key);if(i>=r.length)throw new We(`Array index out of bounds: ${i} > ${r.length-1}.`,this.key);if(i!==Math.floor(i))throw new We(`Array index must be an integer, but found ${i} instead.`,this.key);return r[i]}eachChild(t){t(this.index),t(this.input)}outputDefined(){return!1}},Yw=class Ey{constructor(t,i,r){this.needle=t,this.haystack=i,this.key=r,this.type=me}static parse(t,i){if(t.length!==3)return i.error(`Expected 2 arguments, but found ${t.length-1} instead.`);let r=i.parse(t[1],1,he),a=i.parse(t[2],2,he);return!r||!a?null:wd(r.type,[me,le,N,xo,he])?new Ey(r,a,i.key):i.error(`Expected first argument to be of type boolean, string, number or null, but found ${Ke(r.type)} instead`)}evaluate(t){let i=this.needle.evaluate(t),r=this.haystack.evaluate(t);if(!r)return!1;if(!Hr(i,["boolean","string","number","null"]))throw new We(`Expected first argument to be of type boolean, string, number or null, but found ${Ke(at(i))} instead.`,this.key);if(!Hr(r,["string","array"]))throw new We(`Expected second argument to be of type array or string, but found ${Ke(at(r))} instead.`,this.key);return r.indexOf(i)>=0}eachChild(t){t(this.needle),t(this.haystack)}outputDefined(){return!0}},Kw=class Oh{constructor(t,i,r,a){this.needle=t,this.haystack=i,this.key=r,this.fromIndex=a,this.type=N}static parse(t,i){if(t.length<=2||t.length>=5)return i.error(`Expected 2 or 3 arguments, but found ${t.length-1} instead.`);let r=i.parse(t[1],1,he),a=i.parse(t[2],2,he);if(!r||!a)return null;if(!wd(r.type,[me,le,N,xo,he]))return i.error(`Expected first argument to be of type boolean, string, number or null, but found ${Ke(r.type)} instead`);if(t.length===4){let n=i.parse(t[3],3,N);return n?new Oh(r,a,i.key,n):null}return new Oh(r,a,i.key)}evaluate(t){let i=this.needle.evaluate(t),r=this.haystack.evaluate(t);if(!Hr(i,["boolean","string","number","null"]))throw new We(`Expected first argument to be of type boolean, string, number or null, but found ${Ke(at(i))} instead.`,this.key);let a;if(this.fromIndex&&(a=this.fromIndex.evaluate(t)),Hr(r,["string"])){let n=r.indexOf(i,a);return n===-1?-1:[...r.slice(0,n)].length}if(Hr(r,["array"]))return r.indexOf(i,a);throw new We(`Expected second argument to be of type array or string, but found ${Ke(at(r))} instead.`,this.key)}eachChild(t){t(this.needle),t(this.haystack),this.fromIndex&&t(this.fromIndex)}outputDefined(){return!1}},Jw=class Dy{constructor(t,i,r,a,n,o){this.inputType=t,this.type=i,this.input=r,this.cases=a,this.outputs=n,this.otherwise=o}static parse(t,i){if(t.length<5)return i.error(`Expected at least 4 arguments, but found only ${t.length-1}.`);if(t.length%2!=1)return i.error("Expected an even number of arguments.");let r,a;i.expectedType&&i.expectedType.kind!=="value"&&(a=i.expectedType);let n={},o=[];for(let u=2;u<t.length-1;u+=2){let h=t[u],c=t[u+1];Array.isArray(h)||(h=[h]);let d=i.concat(u);if(h.length===0)return d.error("Expected at least one branch label.");for(let f of h){if(typeof f!="number"&&typeof f!="string")return d.error("Branch labels must be numbers or strings.");if(typeof f=="number"&&Math.abs(f)>2**53-1)return d.error(`Branch labels must be integers no larger than ${2**53-1}.`);if(typeof f=="number"&&Math.floor(f)!==f)return d.error("Numeric branch labels must be integer values.");if(!r)r=at(f);else if(d.checkSubtype(r,at(f)))return null;if(n[String(f)]!==void 0)return d.error("Branch labels must be unique.");n[String(f)]=o.length}let p=i.parse(c,u,a);if(!p)return null;a||(a=p.type),o.push(p)}let s=i.parse(t[1],1,he);if(!s)return null;let l=i.parse(t[t.length-1],t.length-1,a);return!l||s.type.kind!=="value"&&i.concat(1).checkSubtype(r,s.type)?null:new Dy(r,a,s,n,o,l)}evaluate(t){let i=this.input.evaluate(t);return(at(i)===this.inputType&&this.outputs[this.cases[i]]||this.otherwise).evaluate(t)}eachChild(t){t(this.input),this.outputs.forEach(t),t(this.otherwise)}outputDefined(){return this.outputs.every(t=>t.outputDefined())&&this.otherwise.outputDefined()}},Qw=class Sy{constructor(t,i,r){this.type=t,this.branches=i,this.otherwise=r}static parse(t,i){if(t.length<4)return i.error(`Expected at least 3 arguments, but found only ${t.length-1}.`);if(t.length%2!=0)return i.error("Expected an odd number of arguments.");let r;i.expectedType&&i.expectedType.kind!=="value"&&(r=i.expectedType);let a=[];for(let o=1;o<t.length-1;o+=2){let s=i.parse(t[o],o,me);if(!s)return null;let l=i.parse(t[o+1],o+1,r);if(!l)return null;a.push([s,l]),r||(r=l.type)}let n=i.parse(t[t.length-1],t.length-1,r);if(!n)return null;if(!r)throw Error("Can't infer output type");return new Sy(r,a,n)}evaluate(t){for(let[i,r]of this.branches)if(i.evaluate(t))return r.evaluate(t);return this.otherwise.evaluate(t)}eachChild(t){for(let[i,r]of this.branches)t(i),t(r);t(this.otherwise)}outputDefined(){return this.branches.every(([t,i])=>i.outputDefined())&&this.otherwise.outputDefined()}},e2=class jh{constructor(t,i,r,a,n){this.type=t,this.input=i,this.beginIndex=r,this.key=a,this.endIndex=n}static parse(t,i){if(t.length<=2||t.length>=5)return i.error(`Expected 2 or 3 arguments, but found ${t.length-1} instead.`);let r=i.parse(t[1],1,he),a=i.parse(t[2],2,N);if(!r||!a)return null;if(!wd(r.type,[Rt(he),le,he]))return i.error(`Expected first argument to be of type array or string, but found ${Ke(r.type)} instead`);if(t.length===4){let n=i.parse(t[3],3,N);return n?new jh(r.type,r,a,i.key,n):null}return new jh(r.type,r,a,i.key)}evaluate(t){let i=this.input.evaluate(t),r=this.beginIndex.evaluate(t),a;if(this.endIndex&&(a=this.endIndex.evaluate(t)),Hr(i,["string"]))return[...i].slice(r,a).join("");if(Hr(i,["array"]))return i.slice(r,a);throw new We(`Expected first argument to be of type array or string, but found ${Ke(at(i))} instead.`,this.key)}eachChild(t){t(this.input),t(this.beginIndex),this.endIndex&&t(this.endIndex)}outputDefined(){return!1}},Cy=class Vh{constructor(t,i){this.type=t,this.args=i}static parse(t,i){if(t.length<2)return i.error("Expected at least one argument.");let r=null,a=i.expectedType;a&&a.kind!=="value"&&(r=a);let n=[];for(let o of t.slice(1)){let s=i.parse(o,1+n.length,r,void 0,{typeAnnotation:"omit"});if(!s)return null;r||(r=s.type),n.push(s)}if(!r)throw Error("No output type");return a&&n.some(o=>Jn(a,o.type))?new Vh(he,n):new Vh(r,n)}evaluate(t){let i=null,r=0,a;for(let n of this.args)if(r++,i=n.evaluate(t),i&&i instanceof Hi&&!i.available&&(a||(a=i.name),i=null,r===this.args.length&&(i=a)),i!==null)break;return i}eachChild(t){this.args.forEach(t)}outputDefined(){return this.args.every(t=>t.outputDefined())}};function Rf(e,t){return e==="=="||e==="!="?t.kind==="boolean"||t.kind==="string"||t.kind==="number"||t.kind==="null"||t.kind==="value":t.kind==="string"||t.kind==="number"||t.kind==="value"}function t2(e,t,i){return t===i}function i2(e,t,i){return t!==i}function r2(e,t,i){return t<i}function a2(e,t,i){return t>i}function n2(e,t,i){return t<=i}function o2(e,t,i){return t>=i}function Py(e,t,i,r){return r.compare(t,i)===0}function s2(e,t,i,r){return!Py(e,t,i,r)}function l2(e,t,i,r){return r.compare(t,i)<0}function u2(e,t,i,r){return r.compare(t,i)>0}function h2(e,t,i,r){return r.compare(t,i)<=0}function c2(e,t,i,r){return r.compare(t,i)>=0}function tn(e,t,i){let r=e!=="=="&&e!=="!=";return class Ay{constructor(n,o,s,l){this.lhs=n,this.rhs=o,this.key=s,this.collator=l,this.type=me,this.hasUntypedArgument=n.type.kind==="value"||o.type.kind==="value"}static parse(n,o){if(n.length!==3&&n.length!==4)return o.error("Expected two or three arguments.");let s=n[0],l=o.parse(n[1],1,he);if(!l)return null;if(!Rf(s,l.type))return o.concat(1).error(`"${s}" comparisons are not supported for type '${Ke(l.type)}'.`);let u=o.parse(n[2],2,he);if(!u)return null;if(!Rf(s,u.type))return o.concat(2).error(`"${s}" comparisons are not supported for type '${Ke(u.type)}'.`);if(l.type.kind!==u.type.kind&&l.type.kind!=="value"&&u.type.kind!=="value")return o.error(`Cannot compare types '${Ke(l.type)}' and '${Ke(u.type)}'.`);r&&(l.type.kind==="value"&&u.type.kind!=="value"?l=new rr(u.type,[l],o.key):l.type.kind!=="value"&&u.type.kind==="value"&&(u=new rr(l.type,[u],o.key)));let h=null;if(n.length===4){if(l.type.kind!=="string"&&u.type.kind!=="string"&&l.type.kind!=="value"&&u.type.kind!=="value")return o.error("Cannot use collator to compare non-string types.");if(h=o.parse(n[3],3,Pl),!h)return null}return new Ay(l,u,o.key,h)}evaluate(n){let o=this.lhs.evaluate(n),s=this.rhs.evaluate(n);if(r&&this.hasUntypedArgument){let l=at(o),u=at(s);if(l.kind!==u.kind||l.kind!=="string"&&l.kind!=="number")throw new We(`Expected arguments for "${e}" to be (string, string) or (number, number), but found (${l.kind}, ${u.kind}) instead.`,this.key)}if(this.collator&&!r&&this.hasUntypedArgument){let l=at(o),u=at(s);if(l.kind!=="string"||u.kind!=="string")return t(n,o,s)}return this.collator?i(n,o,s,this.collator.evaluate(n)):t(n,o,s)}eachChild(n){n(this.lhs),n(this.rhs),this.collator&&n(this.collator)}outputDefined(){return!0}}}var d2=tn("==",t2,Py),p2=tn("!=",i2,s2),f2=tn("<",r2,l2),m2=tn(">",a2,u2),g2=tn("<=",n2,h2),_2=tn(">=",o2,c2),Iy=class My{constructor(t,i,r){this.type=Pl,this.locale=r,this.caseSensitive=t,this.diacriticSensitive=i}static parse(t,i){if(t.length!==2)return i.error("Expected one argument.");let r=t[1];if(typeof r!="object"||Array.isArray(r))return i.error("Collator options argument must be an object.");let a=i.parse(r["case-sensitive"]!==void 0&&r["case-sensitive"],1,me);if(!a)return null;let n=i.parse(r["diacritic-sensitive"]!==void 0&&r["diacritic-sensitive"],1,me);if(!n)return null;let o=null;return r.locale&&(o=i.parse(r.locale,1,le),!o)?null:new My(a,n,o)}evaluate(t){return new Td(this.caseSensitive.evaluate(t),this.diacriticSensitive.evaluate(t),this.locale?this.locale.evaluate(t):null)}eachChild(t){t(this.caseSensitive),t(this.diacriticSensitive),this.locale&&t(this.locale)}outputDefined(){return!1}},y2=class Fy{constructor(t,i,r,a,n,o){this.type=le,this.number=t,this.locale=i,this.currency=r,this.unit=a,this.minFractionDigits=n,this.maxFractionDigits=o}static parse(t,i){if(t.length!==3)return i.error("Expected two arguments.");let r=i.parse(t[1],1,N);if(!r)return null;let a=t[2];if(typeof a!="object"||Array.isArray(a))return i.error("NumberFormat options argument must be an object.");let n=null;if(a.locale&&(n=i.parse(a.locale,1,le),!n))return null;let o=null;if(a.currency&&(o=i.parse(a.currency,1,le),!o))return null;let s=null;if(a.unit&&(s=i.parse(a.unit,1,le),!s))return null;if(o&&s)return i.error("NumberFormat options `currency` and `unit` are mutually exclusive");let l=null;if(a["min-fraction-digits"]&&(l=i.parse(a["min-fraction-digits"],1,N),!l))return null;let u=null;return a["max-fraction-digits"]&&(u=i.parse(a["max-fraction-digits"],1,N),!u)?null:new Fy(r,n,o,s,l,u)}evaluate(t){return new Intl.NumberFormat(this.locale?this.locale.evaluate(t):[],{style:this.currency?"currency":this.unit?"unit":"decimal",currency:this.currency?this.currency.evaluate(t):void 0,unit:this.unit?this.unit.evaluate(t):void 0,minimumFractionDigits:this.minFractionDigits?this.minFractionDigits.evaluate(t):void 0,maximumFractionDigits:this.maxFractionDigits?this.maxFractionDigits.evaluate(t):void 0}).format(this.number.evaluate(t))}eachChild(t){t(this.number),this.locale&&t(this.locale),this.currency&&t(this.currency),this.unit&&t(this.unit),this.minFractionDigits&&t(this.minFractionDigits),this.maxFractionDigits&&t(this.maxFractionDigits)}outputDefined(){return!1}},v2=class zy{constructor(t){this.type=wo,this.input=t}static parse(t,i){if(t.length!==2)return i.error("Expected two arguments.");let r=i.parse(t[1],1,le);return r?new zy(r):i.error("No image name provided.")}evaluate(t){let i=this.input.evaluate(t),r=Hi.fromString(i);return r&&t.availableImages&&(r.available=t.availableImages.indexOf(i)>-1),r}eachChild(t){t(this.input)}outputDefined(){return!1}},x2=class Ry{constructor(t,i){this.input=t,this.key=i,this.type=N}static parse(t,i){if(t.length!==2)return i.error(`Expected 1 argument, but found ${t.length-1} instead.`);let r=i.parse(t[1],1);return r?r.type.kind!=="array"&&r.type.kind!=="string"&&r.type.kind!=="value"?i.error(`Expected argument of type string or array, but found ${Ke(r.type)} instead.`):new Ry(r,i.key):null}evaluate(t){let i=this.input.evaluate(t);if(typeof i=="string")return[...i].length;if(Array.isArray(i))return i.length;throw new We(`Expected value to be of type string or array, but found ${Ke(at(i))} instead.`,this.key)}eachChild(t){t(this.input)}outputDefined(){return!1}},qi=8192;function b2(e,t){let i=w2(e[0]),r=E2(e[1]),a=2**t.z;return[Math.round(i*a*qi),Math.round(r*a*qi)]}function Dd(e,t){let i=2**t.z,r=(e[0]/qi+t.x)/i,a=(e[1]/qi+t.y)/i;return[T2(r),D2(a)]}function w2(e){return(180+e)/360}function T2(e){return e*360-180}function E2(e){return(180-180/Math.PI*Math.log(Math.tan(Math.PI/4+e*Math.PI/360)))/360}function D2(e){return 360/Math.PI*Math.atan(Math.exp((180-e*360)*Math.PI/180))-90}function To(e,t){e[0]=Math.min(e[0],t[0]),e[1]=Math.min(e[1],t[1]),e[2]=Math.max(e[2],t[0]),e[3]=Math.max(e[3],t[1])}function Qn(e,t){return!(e[0]<=t[0]||e[2]>=t[2]||e[1]<=t[1]||e[3]>=t[3])}function S2(e,t,i){return t[1]>e[1]!=i[1]>e[1]&&e[0]<(i[0]-t[0])*(e[1]-t[1])/(i[1]-t[1])+t[0]}function C2(e,t,i){let r=e[0]-t[0],a=e[1]-t[1],n=e[0]-i[0],o=e[1]-i[1];return r*o-n*a===0&&r*n<=0&&a*o<=0}function Rl(e,t,i,r){let a=[t[0]-e[0],t[1]-e[1]];return M2([r[0]-i[0],r[1]-i[1]],a)!==0&&!!(kf(e,t,i,r)&&kf(i,r,e,t))}function P2(e,t,i){for(let r of i)for(let a=0;a<r.length-1;++a)if(Rl(e,t,r[a],r[a+1]))return!0;return!1}function rn(e,t,i=!1){let r=!1;for(let a of t)for(let n=0;n<a.length-1;n++){if(C2(e,a[n],a[n+1]))return i;S2(e,a[n],a[n+1])&&(r=!r)}return r}function A2(e,t){for(let i of t)if(rn(e,i))return!0;return!1}function ky(e,t){for(let i of e)if(!rn(i,t))return!1;for(let i=0;i<e.length-1;++i)if(P2(e[i],e[i+1],t))return!1;return!0}function I2(e,t){for(let i of t)if(ky(e,i))return!0;return!1}function M2(e,t){return e[0]*t[1]-e[1]*t[0]}function kf(e,t,i,r){let a=e[0]-i[0],n=e[1]-i[1],o=t[0]-i[0],s=t[1]-i[1],l=r[0]-i[0],u=r[1]-i[1],h=a*u-l*n,c=o*u-l*s;return h>0&&c<0||h<0&&c>0}function Sd(e,t,i){let r=[];for(let a=0;a<e.length;a++){let n=[];for(let o=0;o<e[a].length;o++){let s=b2(e[a][o],i);To(t,s),n.push(s)}r.push(n)}return r}function Ly(e,t,i){let r=[];for(let a=0;a<e.length;a++){let n=Sd(e[a],t,i);r.push(n)}return r}function By(e,t,i,r){if(e[0]<i[0]||e[0]>i[2]){let a=r*.5,n=e[0]-i[0]>a?-r:i[0]-e[0]>a?r:0;n===0&&(n=e[0]-i[2]>a?-r:i[2]-e[0]>a?r:0),e[0]+=n}To(t,e)}function F2(e){e[0]=e[1]=1/0,e[2]=e[3]=-1/0}function Lf(e,t,i,r){let a=2**r.z*qi,n=[r.x*qi,r.y*qi],o=[];for(let s of e)for(let l of s){let u=[l.x+n[0],l.y+n[1]];By(u,t,i,a),o.push(u)}return o}function Bf(e,t,i,r){let a=2**r.z*qi,n=[r.x*qi,r.y*qi],o=[];for(let s of e){let l=[];for(let u of s){let h=[u.x+n[0],u.y+n[1]];To(t,h),l.push(h)}o.push(l)}if(t[2]-t[0]<=a/2){F2(t);for(let s of o)for(let l of s)By(l,t,i,a)}return o}function z2(e,t){let i=[1/0,1/0,-1/0,-1/0],r=[1/0,1/0,-1/0,-1/0],a=e.canonicalID();if(t.type==="Polygon"){let n=Sd(t.coordinates,r,a),o=Lf(e.geometry(),i,r,a);if(!Qn(i,r))return!1;for(let s of o)if(!rn(s,n))return!1}if(t.type==="MultiPolygon"){let n=Ly(t.coordinates,r,a),o=Lf(e.geometry(),i,r,a);if(!Qn(i,r))return!1;for(let s of o)if(!A2(s,n))return!1}return!0}function R2(e,t){let i=[1/0,1/0,-1/0,-1/0],r=[1/0,1/0,-1/0,-1/0],a=e.canonicalID();if(t.type==="Polygon"){let n=Sd(t.coordinates,r,a),o=Bf(e.geometry(),i,r,a);if(!Qn(i,r))return!1;for(let s of o)if(!ky(s,n))return!1}if(t.type==="MultiPolygon"){let n=Ly(t.coordinates,r,a),o=Bf(e.geometry(),i,r,a);if(!Qn(i,r))return!1;for(let s of o)if(!I2(s,n))return!1}return!0}var Cd=class ks{constructor(t,i){this.type=me,this.geojson=t,this.geometries=i}static parse(t,i){if(t.length!==2)return i.error(`'within' expression requires exactly one argument, but found ${t.length-1} instead.`);if(Za(t[1])){let r=t[1];if(r.type==="FeatureCollection"){let a=[];for(let n of r.features){let{type:o,coordinates:s}=n.geometry;o==="Polygon"&&a.push(s),o==="MultiPolygon"&&a.push(...s)}if(a.length)return new ks(r,{type:"MultiPolygon",coordinates:a})}else if(r.type==="Feature"){let a=r.geometry.type;if(a==="Polygon"||a==="MultiPolygon")return new ks(r,r.geometry)}else if(r.type==="Polygon"||r.type==="MultiPolygon")return new ks(r,r)}return i.error("'within' expression requires valid geojson object that contains polygon geometry type.")}evaluate(t){if(t.geometry()!=null&&t.canonicalID()!=null){if(t.geometryType()==="Point")return z2(t,this.geometries);if(t.geometryType()==="LineString")return R2(t,this.geometries)}return!1}eachChild(){}outputDefined(){return!0}},Oy=class{constructor(e=[],t=(i,r)=>i<r?-1:+(i>r)){if(this.data=e,this.length=this.data.length,this.compare=t,this.length>0)for(let i=(this.length>>1)-1;i>=0;i--)this._down(i)}push(e){this.data.push(e),this._up(this.length++)}pop(){if(this.length===0)return;let e=this.data[0],t=this.data.pop();return--this.length>0&&(this.data[0]=t,this._down(0)),e}peek(){return this.data[0]}_up(e){let{data:t,compare:i}=this,r=t[e];for(;e>0;){let a=e-1>>1,n=t[a];if(i(r,n)>=0)break;t[e]=n,e=a}t[e]=r}_down(e){let{data:t,compare:i}=this,r=this.length>>1,a=t[e];for(;e<r;){let n=(e<<1)+1,o=n+1;if(o<this.length&&i(t[o],t[n])<0&&(n=o),i(t[n],a)>=0)break;t[e]=t[n],e=n}t[e]=a}},Of=Math.PI/180,Pd=class{constructor(e){let t=Of*6378.137*1e3,i=Math.cos(e*Of),r=1/(1-.0066943799901413165*(1-i*i)),a=Math.sqrt(r);this.kx=t*a*i,this.ky=t*a*r*.9933056200098587}distance(e,t){let i=this.wrap(e[0]-t[0])*this.kx,r=(e[1]-t[1])*this.ky;return Math.sqrt(i*i+r*r)}pointOnLine(e,t){let i=1/0,r,a,n,o;for(let s=0;s<e.length-1;s++){let l=e[s][0],u=e[s][1],h=this.wrap(e[s+1][0]-l)*this.kx,c=(e[s+1][1]-u)*this.ky,d=0;(h!==0||c!==0)&&(d=(this.wrap(t[0]-l)*this.kx*h+(t[1]-u)*this.ky*c)/(h*h+c*c),d>1?(l=e[s+1][0],u=e[s+1][1]):d>0&&(l+=h/this.kx*d,u+=c/this.ky*d)),h=this.wrap(t[0]-l)*this.kx,c=(t[1]-u)*this.ky;let p=h*h+c*c;p<i&&(i=p,r=l,a=u,n=s,o=d)}return{point:[r,a],index:n,t:Math.max(0,Math.min(1,o))}}wrap(e){for(;e<-180;)e+=360;for(;e>180;)e-=360;return e}};function jy(e,t){return t[0]-e[0]}function Xs(e){return e[1]-e[0]+1}function cr(e,t){return e[1]>=e[0]&&e[1]<t}function Nh(e,t){if(e[0]>e[1])return[null,null];let i=Xs(e);if(t){if(i===2)return[e,null];let a=Math.floor(i/2);return[[e[0],e[0]+a],[e[0]+a,e[1]]]}if(i===1)return[e,null];let r=Math.floor(i/2)-1;return[[e[0],e[0]+r],[e[0]+r+1,e[1]]]}function Uh(e,t){if(!cr(t,e.length))return[1/0,1/0,-1/0,-1/0];let i=[1/0,1/0,-1/0,-1/0];for(let r=t[0];r<=t[1];++r)To(i,e[r]);return i}function $h(e){let t=[1/0,1/0,-1/0,-1/0];for(let i of e)for(let r of i)To(t,r);return t}function jf(e){return e[0]!==-1/0&&e[1]!==-1/0&&e[2]!==1/0&&e[3]!==1/0}function Ad(e,t,i){if(!jf(e)||!jf(t))return NaN;let r=0,a=0;return e[2]<t[0]&&(r=t[0]-e[2]),e[0]>t[2]&&(r=e[0]-t[2]),e[1]>t[3]&&(a=e[1]-t[3]),e[3]<t[1]&&(a=t[1]-e[3]),i.distance([0,0],[r,a])}function $r(e,t,i){let r=i.pointOnLine(t,e);return i.distance(e,r.point)}function Id(e,t,i,r,a){let n=Math.min($r(e,[i,r],a),$r(t,[i,r],a)),o=Math.min($r(i,[e,t],a),$r(r,[e,t],a));return Math.min(n,o)}function k2(e,t,i,r,a){if(!(cr(t,e.length)&&cr(r,i.length)))return 1/0;let n=1/0;for(let o=t[0];o<t[1];++o){let s=e[o],l=e[o+1];for(let u=r[0];u<r[1];++u){let h=i[u],c=i[u+1];if(Rl(s,l,h,c))return 0;n=Math.min(n,Id(s,l,h,c,a))}}return n}function L2(e,t,i,r,a){if(!(cr(t,e.length)&&cr(r,i.length)))return NaN;let n=1/0;for(let o=t[0];o<=t[1];++o)for(let s=r[0];s<=r[1];++s)if(n=Math.min(n,a.distance(e[o],i[s])),n===0)return n;return n}function B2(e,t,i){if(rn(e,t,!0))return 0;let r=1/0;for(let a of t){let n=a[0],o=a[a.length-1];if(n!==o&&(r=Math.min(r,$r(e,[o,n],i)),r===0))return r;let s=i.pointOnLine(a,e);if(r=Math.min(r,i.distance(e,s.point)),r===0)return r}return r}function O2(e,t,i,r){if(!cr(t,e.length))return NaN;for(let n=t[0];n<=t[1];++n)if(rn(e[n],i,!0))return 0;let a=1/0;for(let n=t[0];n<t[1];++n){let o=e[n],s=e[n+1];for(let l of i)for(let u=0,h=l.length,c=h-1;u<h;c=u++){let d=l[c],p=l[u];if(Rl(o,s,d,p))return 0;a=Math.min(a,Id(o,s,d,p,r))}}return a}function Vf(e,t){for(let i of e)for(let r of i)if(rn(r,t,!0))return!0;return!1}function j2(e,t,i,r=1/0){let a=$h(e),n=$h(t);if(r!==1/0&&Ad(a,n,i)>=r)return r;if(Qn(a,n)){if(Vf(e,t))return 0}else if(Vf(t,e))return 0;let o=1/0;for(let s of e)for(let l=0,u=s.length,h=u-1;l<u;h=l++){let c=s[h],d=s[l];for(let p of t)for(let f=0,m=p.length,g=m-1;f<m;g=f++){let _=p[g],y=p[f];if(Rl(c,d,_,y))return 0;o=Math.min(o,Id(c,d,_,y,i))}}return o}function Nf(e,t,i,r,a,n){if(!n)return;let o=Ad(Uh(r,n),a,i);o<t&&e.push([o,n,[0,0]])}function os(e,t,i,r,a,n,o){if(!n||!o)return;let s=Ad(Uh(r,n),Uh(a,o),i);s<t&&e.push([s,n,o])}function Ys(e,t,i,r,a=1/0){let n=Math.min(r.distance(e[0],i[0][0]),a);if(n===0)return n;let o=new Oy([[0,[0,e.length-1],[0,0]]],jy),s=$h(i);for(;o.length>0;){let l=o.pop();if(l[0]>=n)continue;let u=l[1],h=t?50:100;if(Xs(u)<=h){if(!cr(u,e.length))return NaN;if(t){let c=O2(e,u,i,r);if(isNaN(c)||c===0)return c;n=Math.min(n,c)}else for(let c=u[0];c<=u[1];++c){let d=B2(e[c],i,r);if(n=Math.min(n,d),n===0)return 0}}else{let c=Nh(u,t);Nf(o,n,r,e,s,c[0]),Nf(o,n,r,e,s,c[1])}}return n}function Ks(e,t,i,r,a,n=1/0){let o=Math.min(n,a.distance(e[0],i[0]));if(o===0)return o;let s=new Oy([[0,[0,e.length-1],[0,i.length-1]]],jy);for(;s.length>0;){let l=s.pop();if(l[0]>=o)continue;let u=l[1],h=l[2],c=t?50:100,d=r?50:100;if(Xs(u)<=c&&Xs(h)<=d){if(!cr(u,e.length)&&cr(h,i.length))return NaN;let p;if(t&&r)p=k2(e,u,i,h,a),o=Math.min(o,p);else if(t&&!r){let f=e.slice(u[0],u[1]+1);for(let m=h[0];m<=h[1];++m)if(p=$r(i[m],f,a),o=Math.min(o,p),o===0)return o}else if(!t&&r){let f=i.slice(h[0],h[1]+1);for(let m=u[0];m<=u[1];++m)if(p=$r(e[m],f,a),o=Math.min(o,p),o===0)return o}else p=L2(e,u,i,h,a),o=Math.min(o,p)}else{let p=Nh(u,t),f=Nh(h,r);os(s,o,a,e,i,p[0],f[0]),os(s,o,a,e,i,p[0],f[1]),os(s,o,a,e,i,p[1],f[0]),os(s,o,a,e,i,p[1],f[1])}}return o}function V2(e,t){let i=e.geometry(),r=i.flat().map(o=>Dd([o.x,o.y],e.canonical));if(i.length===0)return NaN;let a=new Pd(r[0][1]),n=1/0;for(let o of t){switch(o.type){case"Point":n=Math.min(n,Ks(r,!1,[o.coordinates],!1,a,n));break;case"LineString":n=Math.min(n,Ks(r,!1,o.coordinates,!0,a,n));break;case"Polygon":n=Math.min(n,Ys(r,!1,o.coordinates,a,n))}if(n===0)return n}return n}function N2(e,t){let i=e.geometry(),r=i.flat().map(o=>Dd([o.x,o.y],e.canonical));if(i.length===0)return NaN;let a=new Pd(r[0][1]),n=1/0;for(let o of t){switch(o.type){case"Point":n=Math.min(n,Ks(r,!0,[o.coordinates],!1,a,n));break;case"LineString":n=Math.min(n,Ks(r,!0,o.coordinates,!0,a,n));break;case"Polygon":n=Math.min(n,Ys(r,!0,o.coordinates,a,n))}if(n===0)return n}return n}function U2(e,t){let i=e.geometry();if(i.length===0||i[0].length===0)return NaN;let r=zl(i,0).map(o=>o.map(s=>s.map(l=>Dd([l.x,l.y],e.canonical)))),a=new Pd(r[0][0][0][1]),n=1/0;for(let o of t)for(let s of r){switch(o.type){case"Point":n=Math.min(n,Ys([o.coordinates],!1,s,a,n));break;case"LineString":n=Math.min(n,Ys(o.coordinates,!0,s,a,n));break;case"Polygon":n=Math.min(n,j2(s,o.coordinates,a,n))}if(n===0)return n}return n}function Gu(e){return e.type==="MultiPolygon"?e.coordinates.map(t=>({type:"Polygon",coordinates:t})):e.type==="MultiLineString"?e.coordinates.map(t=>({type:"LineString",coordinates:t})):e.type==="MultiPoint"?e.coordinates.map(t=>({type:"Point",coordinates:t})):[e]}var Md=class Ls{constructor(t,i){this.type=N,this.geojson=t,this.geometries=i}static parse(t,i){if(t.length!==2)return i.error(`'distance' expression requires exactly one argument, but found ${t.length-1} instead.`);if(Za(t[1])){let r=t[1];if(r.type==="FeatureCollection")return new Ls(r,r.features.map(a=>Gu(a.geometry)).flat());if(r.type==="Feature")return new Ls(r,Gu(r.geometry));if("type"in r&&"coordinates"in r)return new Ls(r,Gu(r))}return i.error("'distance' expression requires valid geojson object that contains polygon geometry type.")}evaluate(t){if(t.geometry()!=null&&t.canonicalID()!=null){if(t.geometryType()==="Point")return V2(t,this.geometries);if(t.geometryType()==="LineString")return N2(t,this.geometries);if(t.geometryType()==="Polygon")return U2(t,this.geometries)}return NaN}eachChild(){}outputDefined(){return!0}},$2=class Vy{constructor(t){let i=null;for(let r of t)if(!i)i=r.type;else{if(i===r.type)continue;i=he;break}this.type=Rt(i??he,t.length),this.arr=t}static parse(t,i){if(t.length!==2)return i.error(`'semiliteral' expression requires exactly one argument, but found ${t.length-1} instead.`);if(!Za(t[1]))return i.error(`invalid value of type "${typeof t[1]}"`);let r=t[1],a=at(r);if(a.kind==="array"){let n=r,o=i.concat(1),s=[];for(let l=0;l<n.length;l++){let u=o.parse(n[l],l,he);if(!u)return null;s.push(u)}return new Vy(s)}return new qa(a,r)}evaluate(t){return this.arr.map(i=>i.evaluate(t))}eachChild(t){this.arr.forEach(t)}outputDefined(){return this.arr.every(t=>t.outputDefined())}},Fd=class Ny{constructor(t){this.key=t,this.type=he}static parse(t,i){if(t.length!==2)return i.error(`Expected 1 argument, but found ${t.length-1} instead.`);let r=t[1];return r==null?i.error("Global state property must be defined."):typeof r=="string"?new Ny(r):i.error(`Global state property must be string, but found ${typeof t[1]} instead.`)}evaluate(t){let i=t.globals?.globalState;return!i||Object.keys(i).length===0?null:jn(i,this.key)??null}eachChild(){}outputDefined(){return!1}},Ra={"==":d2,"!=":p2,">":m2,"<":f2,">=":_2,"<=":g2,array:rr,at:Xw,boolean:rr,case:Qw,coalesce:Cy,collator:Iy,format:fy,image:v2,in:Yw,"index-of":Kw,interpolate:wi,"interpolate-hcl":wi,"interpolate-lab":wi,length:x2,let:vy,literal:qa,match:Jw,number:rr,"number-format":y2,object:rr,semiliteral:$2,slice:e2,step:Ed,string:rr,"to-boolean":Aa,"to-color":Aa,"to-number":Aa,"to-string":Aa,var:by,within:Cd,distance:Md,"global-state":Fd},Ni=class extends Error{constructor(e,t){super(t),this.message=t,this.key=e}},G2=class Uy{constructor(t,i=[]){this.parent=t,this.bindings={};for(let[r,a]of i)this.bindings[r]=a}concat(t){return new Uy(this,t)}get(t){if(this.bindings[t])return this.bindings[t];if(this.parent)return this.parent.get(t);throw Error(`${t} not found in scope.`)}has(t){return this.bindings[t]?!0:this.parent?this.parent.has(t):!1}},$y=class Gy{constructor(t,i,r=[],a,n=new G2,o=[]){this.registry=t,this.path=r,this.key=r.map(s=>`[${s}]`).join(""),this.scope=n,this.errors=o,this.expectedType=a,this._isConstant=i}parse(t,i,r,a,n={}){return i==null?this._parse(t,n):this.concat(i,r,a)._parse(t,n)}_parse(t,i){(t===null||typeof t=="string"||typeof t=="boolean"||typeof t=="number")&&(t=["literal",t]);let r=this.key;function a(n,o,s){return s==="assert"?new rr(o,[n],r):s==="coerce"?new Aa(o,[n],r):n}if(Array.isArray(t)){if(t.length===0)return this.error('Expected an array with at least one element. If you wanted a literal array, use ["literal", []].');let n=t[0];if(typeof n!="string")return this.error(`Expression name must be a string, but found ${typeof n} instead. If you wanted a literal array, use ["literal", [...]].`,0),null;let o=this.registry[n];if(o){let s=o.parse(t,this);if(!s)return null;if(this.expectedType){let l=this.expectedType,u=s.type;if((l.kind==="string"||l.kind==="number"||l.kind==="boolean"||l.kind==="object"||l.kind==="array")&&u.kind==="value")s=a(s,l,i.typeAnnotation||"assert");else if(l.kind==="projectionDefinition"&&["string","array","value"].includes(u.kind)||["color","formatted","resolvedImage"].includes(l.kind)&&["value","string"].includes(u.kind)||["padding","numberArray"].includes(l.kind)&&["value","number","array"].includes(u.kind)||l.kind==="colorArray"&&["value","string","array"].includes(u.kind)||l.kind==="variableAnchorOffsetCollection"&&["value","array"].includes(u.kind))s=a(s,l,i.typeAnnotation||"coerce");else if(this.checkSubtype(l,u))return null}if(!(s instanceof qa)&&s.type.kind!=="resolvedImage"&&this._isConstant(s)){let l=new dy;try{s=new qa(s.type,s.evaluate(l))}catch(u){return this.error(u.message),null}}return s}return this.error(`Unknown expression "${n}". If you wanted a literal array, use ["literal", [...]].`,0)}return t===void 0?this.error("'undefined' value invalid. Use null instead."):typeof t=="object"?this.error('Bare objects invalid. Use ["literal", {...}] instead.'):this.error(`Expected an array, but found ${typeof t} instead.`)}concat(t,i,r){let a=typeof t=="number"?this.path.concat(t):this.path,n=r?this.scope.concat(r):this.scope;return new Gy(this.registry,this._isConstant,a,i||null,n,this.errors)}error(t,...i){let r=`${this.key}${i.map(a=>`[${a}]`).join("")}`;this.errors.push(new Ni(r,t))}checkSubtype(t,i){let r=Jn(t,i);return r&&this.error(r),r}},oa=class Rn{constructor(t,i,r,a,n){this.name=t,this.type=i,this._evaluate=r,this.args=a,this.key=n}evaluate(t){return this._evaluate(t,this.args,this.key)}eachChild(t){this.args.forEach(t)}outputDefined(){return!1}static parse(t,i){let r=t[0],a=Rn.definitions[r];if(!a)return i.error(`Unknown expression "${r}". If you wanted a literal array, use ["literal", [...]].`,0);let n=Array.isArray(a)?a[0]:a.type,o=Array.isArray(a)?[[a[1],a[2]]]:a.overloads,s=o.filter(([u])=>!Array.isArray(u)||u.length===t.length-1),l=null;for(let[u,h]of s){l=new $y(i.registry,Js,i.path,null,i.scope);let c=[],d=!1;for(let p=1;p<t.length;p++){let f=t[p],m=Array.isArray(u)?u[p-1]:u.type,g=l.parse(f,1+c.length,m);if(!g){d=!0;break}c.push(g)}if(!d){if(Array.isArray(u)&&u.length!==c.length){l.error(`Expected ${u.length} arguments, but found ${c.length} instead.`);continue}for(let p=0;p<c.length;p++){let f=Array.isArray(u)?u[p]:u.type,m=c[p];l.concat(p+1).checkSubtype(f,m.type)}if(l.errors.length===0)return new Rn(r,n,h,c,i.key)}}if(s.length===1)i.errors.push(...l.errors);else{let u=(s.length?s:o).map(([c])=>q2(c)).join(" | "),h=[];for(let c=1;c<t.length;c++){let d=i.parse(t[c],1+h.length);if(!d)return null;h.push(Ke(d.type))}i.error(`Expected arguments of type ${u}, but found (${h.join(", ")}) instead.`)}return null}static register(t,i){Rn.definitions=i;for(let r in i)t[r]=Rn}};function Uf(e,[t,i,r,a],n){t=t.evaluate(e),i=i.evaluate(e),r=r.evaluate(e);let o=a?a.evaluate(e):1,s=hy(t,i,r,o);if(s)throw new We(s,n);return new oe(t/255,i/255,r/255,o,!1)}function $f(e,t){return e in t&&t[e]!==void 0}function Zu(e,t){let i=t[e];return i===void 0?null:i}function Z2(e,t,i,r){for(;i<=r;){let a=i+r>>1;if(t[a]===e)return!0;t[a]>e?r=a-1:i=a+1}return!1}function Rr(e){return{type:e}}oa.register(Ra,{error:[Mw,[le],(e,[t],i)=>{throw new We(t.evaluate(e),i)}],typeof:[le,[he],(e,[t])=>Ke(at(t.evaluate(e)))],"to-rgba":[Rt(N,4),[Ai],(e,[t])=>{let[i,r,a,n]=t.evaluate(e).rgb;return[i*255,r*255,a*255,n]}],rgb:[Ai,[N,N,N],Uf],rgba:[Ai,[N,N,N,N],Uf],has:{type:me,overloads:[[[le],(e,[t])=>$f(t.evaluate(e),e.properties())],[[le,Wr],(e,[t,i])=>$f(t.evaluate(e),i.evaluate(e))]]},get:{type:he,overloads:[[[le],(e,[t])=>Zu(t.evaluate(e),e.properties())],[[le,Wr],(e,[t,i])=>Zu(t.evaluate(e),i.evaluate(e))]]},"feature-state":[he,[le],(e,[t])=>Zu(t.evaluate(e),e.featureState||{})],properties:[Wr,[],e=>e.properties()],"geometry-type":[le,[],e=>e.geometryType()],id:[he,[],e=>e.id()],zoom:[N,[],e=>e.globals.zoom],"heatmap-density":[N,[],e=>e.globals.heatmapDensity||0],elevation:[N,[],e=>e.globals.elevation||0],"line-progress":[N,[],e=>e.globals.lineProgress||0],accumulated:[he,[],e=>e.globals.accumulated===void 0?null:e.globals.accumulated],"+":[N,Rr(N),(e,t)=>{let i=0;for(let r of t)i+=r.evaluate(e);return i}],"*":[N,Rr(N),(e,t)=>{let i=1;for(let r of t)i*=r.evaluate(e);return i}],"-":{type:N,overloads:[[[N,N],(e,[t,i])=>t.evaluate(e)-i.evaluate(e)],[[N],(e,[t])=>-t.evaluate(e)]]},"/":[N,[N,N],(e,[t,i])=>t.evaluate(e)/i.evaluate(e)],"%":[N,[N,N],(e,[t,i])=>t.evaluate(e)%i.evaluate(e)],ln2:[N,[],()=>Math.LN2],pi:[N,[],()=>Math.PI],e:[N,[],()=>Math.E],"^":[N,[N,N],(e,[t,i])=>t.evaluate(e)**+i.evaluate(e)],sqrt:[N,[N],(e,[t])=>Math.sqrt(t.evaluate(e))],log10:[N,[N],(e,[t])=>Math.log(t.evaluate(e))/Math.LN10],ln:[N,[N],(e,[t])=>Math.log(t.evaluate(e))],log2:[N,[N],(e,[t])=>Math.log(t.evaluate(e))/Math.LN2],sin:[N,[N],(e,[t])=>Math.sin(t.evaluate(e))],cos:[N,[N],(e,[t])=>Math.cos(t.evaluate(e))],tan:[N,[N],(e,[t])=>Math.tan(t.evaluate(e))],asin:[N,[N],(e,[t])=>Math.asin(t.evaluate(e))],acos:[N,[N],(e,[t])=>Math.acos(t.evaluate(e))],atan:[N,[N],(e,[t])=>Math.atan(t.evaluate(e))],min:[N,Rr(N),(e,t)=>Math.min(...t.map(i=>i.evaluate(e)))],max:[N,Rr(N),(e,t)=>Math.max(...t.map(i=>i.evaluate(e)))],abs:[N,[N],(e,[t])=>Math.abs(t.evaluate(e))],round:[N,[N],(e,[t])=>{let i=t.evaluate(e);return i<0?-Math.round(-i):Math.round(i)}],floor:[N,[N],(e,[t])=>Math.floor(t.evaluate(e))],ceil:[N,[N],(e,[t])=>Math.ceil(t.evaluate(e))],"filter-==":[me,[le,he],(e,[t,i])=>e.properties()[t.value]===i.value],"filter-id-==":[me,[he],(e,[t])=>e.id()===t.value],"filter-type-==":[me,[le],(e,[t])=>e.geometryType()===t.value],"filter-<":[me,[le,he],(e,[t,i])=>{let r=e.properties()[t.value],a=i.value;return typeof r==typeof a&&r<a}],"filter-id-<":[me,[he],(e,[t])=>{let i=e.id(),r=t.value;return typeof i==typeof r&&i<r}],"filter->":[me,[le,he],(e,[t,i])=>{let r=e.properties()[t.value],a=i.value;return typeof r==typeof a&&r>a}],"filter-id->":[me,[he],(e,[t])=>{let i=e.id(),r=t.value;return typeof i==typeof r&&i>r}],"filter-<=":[me,[le,he],(e,[t,i])=>{let r=e.properties()[t.value],a=i.value;return typeof r==typeof a&&r<=a}],"filter-id-<=":[me,[he],(e,[t])=>{let i=e.id(),r=t.value;return typeof i==typeof r&&i<=r}],"filter->=":[me,[le,he],(e,[t,i])=>{let r=e.properties()[t.value],a=i.value;return typeof r==typeof a&&r>=a}],"filter-id->=":[me,[he],(e,[t])=>{let i=e.id(),r=t.value;return typeof i==typeof r&&i>=r}],"filter-has":[me,[he],(e,[t])=>{let i=t.value,r=e.properties();return i in r&&r[i]!==void 0}],"filter-has-id":[me,[],e=>e.id()!==null&&e.id()!==void 0],"filter-type-in":[me,[Rt(le)],(e,[t])=>t.value.indexOf(e.geometryType())>=0],"filter-id-in":[me,[Rt(he)],(e,[t])=>t.value.indexOf(e.id())>=0],"filter-in-small":[me,[le,Rt(he)],(e,[t,i])=>i.value.indexOf(e.properties()[t.value])>=0],"filter-in-large":[me,[le,Rt(he)],(e,[t,i])=>Z2(e.properties()[t.value],i.value,0,i.value.length-1)],all:{type:me,overloads:[[[me,me],(e,[t,i])=>t.evaluate(e)&&i.evaluate(e)],[Rr(me),(e,t)=>{for(let i of t)if(!i.evaluate(e))return!1;return!0}]]},any:{type:me,overloads:[[[me,me],(e,[t,i])=>t.evaluate(e)||i.evaluate(e)],[Rr(me),(e,t)=>{for(let i of t)if(i.evaluate(e))return!0;return!1}]]},"!":[me,[me],(e,[t])=>!t.evaluate(e)],"is-supported-script":[me,[le],(e,[t])=>{let i=e.globals&&e.globals.isSupportedScript;return!i||i(t.evaluate(e))}],upcase:[le,[le],(e,[t])=>t.evaluate(e).toUpperCase()],downcase:[le,[le],(e,[t])=>t.evaluate(e).toLowerCase()],concat:[le,Rr(he),(e,t)=>t.map(i=>Vn(i.evaluate(e))).join("")],split:[Rt(le),[le,le],(e,[t,i])=>t.evaluate(e).split(i.evaluate(e))],join:[le,[Rt(le),le],(e,[t,i])=>t.evaluate(e).join(i.evaluate(e))],"resolved-locale":[le,[Pl],(e,[t])=>t.evaluate(e).resolvedLocale()]});function q2(e){return Array.isArray(e)?`(${e.map(Ke).join(", ")})`:`(${Ke(e.type)}...)`}function Js(e){if(e instanceof by)return Js(e.boundExpression);if(e instanceof oa&&e.name==="error"||e instanceof Iy||e instanceof Cd||e instanceof Md||e instanceof Fd)return!1;let t=e instanceof Aa||e instanceof rr,i=!0;return e.eachChild(r=>{i&&(i=t?Js(r):r instanceof qa)}),i?kl(e)&&Ll(e,["zoom","heatmap-density","elevation","line-progress","accumulated","is-supported-script"]):!1}function kl(e){if(e instanceof oa&&(e.name==="get"&&e.args.length===1||e.name==="feature-state"||e.name==="has"&&e.args.length===1||e.name==="properties"||e.name==="geometry-type"||e.name==="id"||/^filter-/.test(e.name))||e instanceof Cd||e instanceof Md)return!1;let t=!0;return e.eachChild(i=>{t&&!kl(i)&&(t=!1)}),t}function eo(e){if(e instanceof oa&&e.name==="feature-state")return!1;let t=!0;return e.eachChild(i=>{t&&!eo(i)&&(t=!1)}),t}function Ll(e,t){if(e instanceof oa&&t.indexOf(e.name)>=0)return!1;let i=!0;return e.eachChild(r=>{i&&!Ll(r,t)&&(i=!1)}),i}function Wa(e){return e["property-type"]==="data-driven"||e["property-type"]==="cross-faded-data-driven"}function Zy(e){return!!e.expression&&e.expression.parameters.indexOf("zoom")>-1}function zd(e){return!!e.expression&&e.expression.interpolated}var Rd=/^(.*)-transition$/;function to(e,...t){for(let i of t)for(let r in i)e[r]=i[r];return e}function pe(e){return e instanceof Number?"number":e instanceof String?"string":e instanceof Boolean?"boolean":Array.isArray(e)?"array":e===null?"null":typeof e}function Bl(e){return typeof e=="object"&&!!e&&!Array.isArray(e)&&at(e)===Wr}function W2(e){return e}function H2(e){switch(e.type){case"color":return oe.parse;case"padding":return Yi.parse;case"numberArray":return Ki.parse;case"colorArray":return bi.parse;default:return null}}function X2(e){switch(e){case"exponential":return Wy;case"interval":return K2;case"categorical":return Y2;case"identity":return J2;default:throw Error(`Unknown function type "${e}"`)}}function qy(e,t){let i=e.stops&&typeof e.stops[0][0]=="object",r=i||e.property!==void 0,a=i||!r,n=e.type||(zd(t)?"exponential":"interval"),o=H2(t);if(o&&(e=to({},e),e.stops&&(e.stops=e.stops.map(h=>[h[0],o(h[1])])),e.default?e.default=o(e.default):e.default=o(t.default)),e.colorSpace&&!Nw(e.colorSpace))throw Error(`Unknown color space: "${e.colorSpace}"`);let s=X2(n),l,u;if(n==="categorical"){l=Object.create(null);for(let h of e.stops)l[h[0]]=h[1];u=typeof e.stops[0][0]}if(i){let h={},c=[];for(let f=0;f<e.stops.length;f++){let m=e.stops[f],g=m[0].zoom;h[g]===void 0&&(h[g]={zoom:g,type:e.type,property:e.property,default:e.default,stops:[]},c.push(g)),h[g].stops.push([m[0].value,m[1]])}let d=[];for(let f of c)d.push([h[f].zoom,qy(h[f],t)]);let p={name:"linear"};return{kind:"composite",interpolationType:p,interpolationFactor:wi.interpolationFactor.bind(void 0,p),zoomStops:d.map(f=>f[0]),evaluate({zoom:f},m){return Wy({stops:d,base:e.base},t,f).evaluate(f,m)}}}if(a){let h=n==="exponential"?{name:"exponential",base:e.base===void 0?1:e.base}:null;return{kind:"camera",interpolationType:h,interpolationFactor:wi.interpolationFactor.bind(void 0,h),zoomStops:e.stops.map(c=>c[0]),evaluate:({zoom:c})=>s(e,t,c,l,u)}}return{kind:"source",evaluate(h,c){let d=c&&c.properties?c.properties[e.property]:void 0;return d===void 0?Eo(e.default,t.default):s(e,t,d,l,u)}}}function Eo(e,t,i){if(e!==void 0)return e;if(t!==void 0)return t;if(i!==void 0)return i}function Y2(e,t,i,r,a){return Eo(typeof i===a?r[i]:void 0,e.default,t.default)}function K2(e,t,i){if(pe(i)!=="number")return Eo(e.default,t.default);let r=e.stops.length;if(r===1||i<=e.stops[0][0])return e.stops[0][1];if(i>=e.stops[r-1][0])return e.stops[r-1][1];let a=Fl(e.stops.map(n=>n[0]),i,"");return e.stops[a][1]}function Wy(e,t,i){let r=e.base===void 0?1:e.base;if(pe(i)!=="number")return Eo(e.default,t.default);let a=e.stops.length;if(a===1||i<=e.stops[0][0])return e.stops[0][1];if(i>=e.stops[a-1][0])return e.stops[a-1][1];let n=Fl(e.stops.map(h=>h[0]),i,""),o=Q2(i,r,e.stops[n][0],e.stops[n+1][0]),s=e.stops[n][1],l=e.stops[n+1][1],u=He[t.type]||W2;return typeof s.evaluate=="function"?{evaluate(...h){let c=s.evaluate.apply(void 0,h),d=l.evaluate.apply(void 0,h);if(c!==void 0&&d!==void 0)return u(c,d,o,e.colorSpace)}}:u(s,l,o,e.colorSpace)}function J2(e,t,i){switch(t.type){case"color":i=oe.parse(i);break;case"formatted":i=hr.fromString(i.toString());break;case"resolvedImage":i=Hi.fromString(i.toString());break;case"padding":i=Yi.parse(i);break;case"colorArray":i=bi.parse(i);break;case"numberArray":i=Ki.parse(i);break;default:pe(i)!==t.type&&(t.type!=="enum"||!t.values[i])&&(i=void 0)}return Eo(i,e.default,t.default)}function Q2(e,t,i,r){let a=r-i,n=e-i;return a===0?0:t===1?n/a:(t**+n-1)/(t**+a-1)}function Gh(e){return{result:"success",value:e}}function Da(e){return{result:"error",value:e}}var kd=class{constructor(e,t,i,r){this.expression=e,this._warningHistory={},this._evaluator=new dy,this._defaultValue=i?Qy(i):null,this._enumValues=i&&i.type==="enum"?i.values:null,this._globalState=r,this._rootKey=t}evaluateWithoutErrorHandling(e,t,i,r,a,n){return this._globalState&&(e=Ha(e,this._globalState)),this._evaluator.globals=e,this._evaluator.feature=t,this._evaluator.featureState=i,this._evaluator.canonical=r,this._evaluator.availableImages=a||null,this._evaluator.formattedSection=n,this.expression.evaluate(this._evaluator)}evaluate(e,t,i,r,a,n){this._globalState&&(e=Ha(e,this._globalState)),this._evaluator.globals=e,this._evaluator.feature=t||null,this._evaluator.featureState=i||null,this._evaluator.canonical=r,this._evaluator.availableImages=a||null,this._evaluator.formattedSection=n||null;try{let o=this.expression.evaluate(this._evaluator);if(o==null||typeof o=="number"&&o!==o)return this._defaultValue;if(this._enumValues&&!(o in this._enumValues))throw new We(`Expected value to be one of ${Object.keys(this._enumValues).map(s=>JSON.stringify(s)).join(", ")}, but found ${JSON.stringify(o)} instead.`,"");return o}catch(o){let s=o instanceof We?o.path:"",l=`${s}|${o.message}`;return this._warningHistory[l]||(this._warningHistory[l]=!0,typeof console<"u"&&console.warn(Hy(this._rootKey,s,o.message,this._defaultValue))),this._defaultValue}}};function Hy(e,t,i,r){return`${e}${t}: ${i}${r==null?"":` Falling back to ${String(r)}.`}`}function Xy(e){if(!e)throw Error('rootKey must identify the location of the expression in the style JSON, e.g. "layers[3].paint.line-width".')}function Ol(e){return Array.isArray(e)&&e.length>0&&typeof e[0]=="string"&&e[0]in Ra}function jl(e,t,i,r){Xy(t);let a=new $y(Ra,Js,[],i?iT(i):void 0),n=a.parse(e,void 0,void 0,void 0,i&&i.type==="string"?{typeAnnotation:"coerce"}:void 0);return n?Gh(new kd(n,t,i,r)):Da(a.errors)}var io=class{constructor(e,t,i){this.kind=e,this._styleExpression=t,this.isStateDependent=e!=="constant"&&!eo(t.expression),this.globalStateRefs=Do(t.expression),this._globalState=i}evaluateWithoutErrorHandling(e,t,i,r,a,n){return this._globalState&&(e=Ha(e,this._globalState)),this._styleExpression.evaluateWithoutErrorHandling(e,t,i,r,a,n)}evaluate(e,t,i,r,a,n){return this._globalState&&(e=Ha(e,this._globalState)),this._styleExpression.evaluate(e,t,i,r,a,n)}},Qs=class{constructor(e,t,i,r,a){this.kind=e,this.zoomStops=i,this._styleExpression=t,this.isStateDependent=e!=="camera"&&!eo(t.expression),this.globalStateRefs=Do(t.expression),this.interpolationType=r,this._globalState=a}evaluateWithoutErrorHandling(e,t,i,r,a,n){return this._globalState&&(e=Ha(e,this._globalState)),this._styleExpression.evaluateWithoutErrorHandling(e,t,i,r,a,n)}evaluate(e,t,i,r,a,n){return this._globalState&&(e=Ha(e,this._globalState)),this._styleExpression.evaluate(e,t,i,r,a,n)}interpolationFactor(e,t,i){return this.interpolationType?wi.interpolationFactor(this.interpolationType,e,t,i):0}};function eT(e){return e._styleExpression!==void 0}function Yy(e,t,i,r){let a=jl(e,t,i,r);if(a.result==="error")return a;let n=a.value.expression,o=kl(n);if(!o&&!Wa(i))return Da([new Ni("","data expressions not supported")]);let s=Ll(n,["zoom"]);if(!s&&!Zy(i))return Da([new Ni("","zoom expressions not supported")]);let l=Bs(n);if(!l&&!s)return Da([new Ni("",'"zoom" expression may only be used as input to a top-level "step" or "interpolate" expression.')]);if(l instanceof Ni)return Da([l]);if(l instanceof wi&&!zd(i))return Da([new Ni("",'"interpolate" expressions cannot be used with this property')]);if(!l)return Gh(o?new io("constant",a.value,r):new io("source",a.value,r));let u=l instanceof wi?l.interpolation:void 0;return Gh(o?new Qs("camera",a.value,l.labels,u,r):new Qs("composite",a.value,l.labels,u,r))}var Ky=class Jy{constructor(t,i,r){this.isStateDependent=!1,this.globalStateRefs=new Set,this._globalState=null,Xy(i),this._parameters=t,this._specification=r,this._rootKey=i,this._defaultValue=Qy(r),this._warningHistory={};let a=qy(this._parameters,this._specification);this.kind=a.kind,this.interpolationFactor=a.interpolationFactor,this.zoomStops=a.zoomStops,this.interpolationType=a.interpolationType,this._innerEvaluate=a.evaluate}evaluate(t,i){try{return this._innerEvaluate(t,i)}catch(r){let a=r instanceof Error?r.message:String(r),n=`|${a}`;return this._warningHistory[n]||(this._warningHistory[n]=!0,typeof console<"u"&&console.warn(Hy(this._rootKey,"",a,this._defaultValue))),this._defaultValue}}static deserialize(t){return new Jy(t._parameters,t._rootKey,t._specification)}static serialize(t){return{_parameters:t._parameters,_specification:t._specification,_rootKey:t._rootKey}}};function tT(e,t,i,r){if(Bl(e))return new Ky(e,t,i);if(Ol(e)){let a=Yy(e,t,i,r);if(a.result==="error")throw Error(a.value.map(n=>`${n.key}: ${n.message}`).join(", "));return a.value}{let a=e;return i.type==="color"&&typeof e=="string"?a=oe.parse(e):i.type==="padding"&&(typeof e=="number"||Array.isArray(e))?a=Yi.parse(e):i.type==="numberArray"&&(typeof e=="number"||Array.isArray(e))?a=Ki.parse(e):i.type==="colorArray"&&(typeof e=="string"||Array.isArray(e))?a=bi.parse(e):i.type==="variableAnchorOffsetCollection"&&Array.isArray(e)?a=Wi.parse(e):i.type==="projectionDefinition"&&typeof e=="string"&&(a=Mr.parse(e)),{globalStateRefs:new Set,_globalState:null,kind:"constant",evaluate:()=>a}}}function Bs(e){let t=null;if(e instanceof vy)t=Bs(e.result);else if(e instanceof Cy){for(let i of e.args)if(t=Bs(i),t)break}else(e instanceof Ed||e instanceof wi)&&e.input instanceof oa&&e.input.name==="zoom"&&(t=e);return t instanceof Ni||e.eachChild(i=>{let r=Bs(i);r instanceof Ni?t=r:!t&&r?t=new Ni("",'"zoom" expression may only be used as input to a top-level "step" or "interpolate" expression.'):t&&r&&t!==r&&(t=new Ni("",'Only one zoom-based "step" or "interpolate" subexpression may be used in an expression.'))}),t}function Do(e,t=new Set){return e instanceof Fd&&t.add(e.key),e.eachChild(i=>{Do(i,t)}),t}function iT(e){let t={color:Ai,string:le,number:N,enum:le,boolean:me,formatted:bo,padding:Al,numberArray:Il,colorArray:Kn,projectionDefinition:Cl,resolvedImage:wo,variableAnchorOffsetCollection:Ml};return e.type==="array"?Rt(t[e.value]||he,e.length):t[e.type]}function Qy(e){if(e.type==="color"&&Bl(e.default))return new oe(0,0,0,0);switch(e.type){case"color":return oe.parse(e.default)||null;case"padding":return Yi.parse(e.default)||null;case"numberArray":return Ki.parse(e.default)||null;case"colorArray":return bi.parse(e.default)||null;case"variableAnchorOffsetCollection":return Wi.parse(e.default)||null;case"projectionDefinition":return Mr.parse(e.default)||null;default:return e.default===void 0?null:e.default}}function Ha(e,t){let{zoom:i,heatmapDensity:r,elevation:a,lineProgress:n,isSupportedScript:o,accumulated:s}=e??{};return{zoom:i,heatmapDensity:r,elevation:a,lineProgress:n,isSupportedScript:o,accumulated:s,globalState:t}}function rT(e){let t=!1;for(let i of e){let r=e0(i);if(r==="expression")return"expression";r==="legacy"&&(t=!0)}return t?"legacy":"neutral"}function e0(e){if(typeof e=="boolean")return"neutral";if(!Array.isArray(e)||e.length===0)return"legacy";switch(e[0]){case"has":return e.length<2||e[1]==="$id"||e[1]==="$type"?"legacy":e.length===2?"neutral":"expression";case"in":return e.length>=3&&(typeof e[1]!="string"||Array.isArray(e[2]))?"expression":"legacy";case"!in":case"!has":return"legacy";case"==":case"!=":case">":case">=":case"<":case"<=":return e.length!==3||Array.isArray(e[1])||Array.isArray(e[2])?"expression":"legacy";case"none":return"legacy";case"any":case"all":return rT(e.slice(1));default:return"expression"}}function Ld(e){return e0(e)!=="legacy"}function Gf(e){return e==="$type"?["geometry-type"]:e==="$id"?["id"]:["get",e]}function aT(e){switch(e[0]){case"==":case"!=":case"<":case"<=":case">":case">=":return e.length!==3||typeof e[1]!="string"?null:[e[0],Gf(e[1]),e[2]];case"in":case"!in":{if(e.length<2||typeof e[1]!="string")return null;let t=["in",Gf(e[1]),["literal",e.slice(2)]];return e[0]==="!in"?["!",t]:t}case"has":case"!has":{if(e.length!==2||typeof e[1]!="string"||e[1]==="$type"||e[1]==="$id")return null;let t=["has",e[1]];return e[0]==="!has"?["!",t]:t}default:return null}}function t0(e){if((e[0]==="<"||e[0]==="<="||e[0]===">"||e[0]===">=")&&e[1]==="$type")return`"$type" cannot be use with operator "${e[0]}"`;let t=aT(e);return t?`Mixing deprecated filter syntax with expression syntax is not supported. Replace ${JSON.stringify(e)} with ${JSON.stringify(t)}.`:`Mixing deprecated filter syntax with expression syntax is not supported. Convert ${JSON.stringify(e)} to expression syntax.`}function qu(e,t,i){let r=i[e];return Array.isArray(r)?Ld(r)?Bd(r,t.concat(e)):{path:t.concat(e),legacyFilter:r}:null}function Bd(e,t=[]){if(!Array.isArray(e)||e.length<1)return null;switch(e[0]){case"all":case"any":case"none":for(let i=1;i<e.length;i++){let r=qu(i,t,e);if(r)return r}break;case"!":{let i=qu(1,t,e);if(i)return i;break}case"case":for(let i=1;i<e.length-1;i+=2){let r=qu(i,t,e);if(r)return r}}return null}function nT(e,t){let i=Bd(e);if(!i||typeof console>"u")return;let r=i.path.map(a=>`[${a}]`).join("");console.warn(`${t}${r}: ${t0(i.legacyFilter)}`)}var oT={type:"boolean",default:!1,transition:!1,"property-type":"data-driven",expression:{interpolated:!1,parameters:["zoom","feature"]}};function ro(e,t,i){if(e==null)return{filter:()=>!0,needGeometry:!1,getGlobalStateRefs:()=>new Set};Ld(e)?nT(e,t):e=el(e);let r=jl(e,t,oT,i);if(r.result==="error")throw Error(r.value.map(a=>`${a.key}: ${a.message}`).join(", "));return{filter:(a,n,o)=>r.value.evaluate(a,n,{},o),needGeometry:i0(e),getGlobalStateRefs:()=>Do(r.value.expression)}}function sT(e,t){return e<t?-1:+(e>t)}function i0(e){if(!Array.isArray(e))return!1;if(e[0]==="within"||e[0]==="distance")return!0;for(let t=1;t<e.length;t++)if(i0(e[t]))return!0;return!1}function el(e){if(!e)return!0;let t=e[0];return e.length<=1?t!=="any":t==="=="?Wu(e[1],e[2],"=="):t==="!="?ss(Wu(e[1],e[2],"==")):t==="<"||t===">"||t==="<="||t===">="?Wu(e[1],e[2],t):t==="any"?lT(e.slice(1)):t==="all"?["all"].concat(e.slice(1).map(el)):t==="none"?["all"].concat(e.slice(1).map(el).map(ss)):t==="in"?Zf(e[1],e.slice(2)):t==="!in"?ss(Zf(e[1],e.slice(2))):t==="has"?qf(e[1]):t!=="!has"||ss(qf(e[1]))}function Wu(e,t,i){switch(e){case"$type":return[`filter-type-${i}`,t];case"$id":return[`filter-id-${i}`,t];default:return[`filter-${i}`,e,t]}}function lT(e){return["any"].concat(e.map(el))}function Zf(e,t){if(t.length===0)return!1;switch(e){case"$type":return["filter-type-in",["literal",t]];case"$id":return["filter-id-in",["literal",t]];default:return t.length>200&&!t.some(i=>typeof i!=typeof t[0])?["filter-in-large",e,["literal",t.sort(sT)]]:["filter-in-small",e,["literal",t]]}}function qf(e){switch(e){case"$type":return!0;case"$id":return["filter-has-id"];default:return["filter-has",e]}}function ss(e){return["!",e]}function uT(){let e={},t=F.$version;for(let i in F.$root){let r=F.$root[i];if(r.required){let a=null;a=i==="version"?t:r.type==="array"?[]:{},a!=null&&(e[i]=a)}}return e}function r0(e){let t=e.key,i=e.value;return i?[new L(t,i,"constants have been deprecated as of v8")]:[]}function it(e){return e instanceof Number||e instanceof String||e instanceof Boolean?e.valueOf():e}function Qr(e){if(Array.isArray(e))return e.map(Qr);if(e instanceof Object&&!(e instanceof Number||e instanceof String||e instanceof Boolean)){let t={};for(let i in e)t[i]=Qr(e[i]);return t}return it(e)}function ai(e){let t=e.key,i=e.value,r=e.valueSpec||{},a=e.objectElementValidators||{},n=e.style,o=e.styleSpec,s=e.validateSpec,l=[],u=pe(i);if(u!=="object")return[new L(t,i,`object expected, ${u} found`)];for(let h in i){let c=h.split(".")[0],d=jn(r,c)||r["*"],p;if(jn(a,c))p=a[c];else if(jn(r,c)){if(i[h]===void 0)continue;p=s}else if(a["*"])p=a["*"];else if(r["*"])p=s;else{l.push(new L(t,i[h],`unknown property "${h}"`));continue}l=l.concat(p({key:(t&&`${t}.`)+h,value:i[h],valueSpec:d,style:n,styleSpec:o,object:i,objectKey:h,validateSpec:s},i))}for(let h in r)a[h]||r[h].required&&r[h].default===void 0&&i[h]===void 0&&l.push(new L(t,i,`missing required property "${h}"`));return l}function Od(e){let t=e.value,i=e.valueSpec,r=e.validateSpec,a=e.style,n=e.styleSpec,o=e.key,s=e.arrayElementValidator||r;if(pe(t)!=="array")return[new L(o,t,`array expected, ${pe(t)} found`)];if(i.length&&t.length!==i.length)return[new L(o,t,`array length ${i.length} expected, length ${t.length} found`)];let l={type:i.value,values:i.values};n.$version<7&&(l.function=i.function),pe(i.value)==="object"&&(l=i.value);let u=[];for(let h=0;h<t.length;h++)u=u.concat(s({array:t,arrayIndex:h,value:t[h],valueSpec:l,validateSpec:e.validateSpec,style:a,styleSpec:n,key:`${o}[${h}]`}));return u}function Vl(e){let t=e.key,i=e.value,r=e.valueSpec,a=pe(i);return a==="number"&&i!==i&&(a="NaN"),a==="number"?"minimum"in r&&i<r.minimum?[new L(t,i,`${i} is less than the minimum value ${r.minimum}`)]:"maximum"in r&&i>r.maximum?[new L(t,i,`${i} is greater than the maximum value ${r.maximum}`)]:[]:[new L(t,i,`number expected, ${a} found`)]}function a0(e){let t=e.valueSpec,i=it(e.value.type),r,a={},n,o,s=i!=="categorical"&&e.value.property===void 0,l=!s,u=pe(e.value.stops)==="array"&&pe(e.value.stops[0])==="array"&&pe(e.value.stops[0][0])==="object",h=ai({key:e.key,value:e.value,valueSpec:e.styleSpec.function,validateSpec:e.validateSpec,style:e.style,styleSpec:e.styleSpec,objectElementValidators:{stops:c,default:f}});return i==="identity"&&s&&h.push(new L(e.key,e.value,'missing required property "property"')),i!=="identity"&&!e.value.stops&&h.push(new L(e.key,e.value,'missing required property "stops"')),i==="exponential"&&e.valueSpec.expression&&!zd(e.valueSpec)&&h.push(new L(e.key,e.value,"exponential functions not supported")),e.styleSpec.$version>=8&&(l&&!Wa(e.valueSpec)?h.push(new L(e.key,e.value,"property functions not supported")):s&&!Zy(e.valueSpec)&&h.push(new L(e.key,e.value,"zoom functions not supported"))),(i==="categorical"||u)&&e.value.property===void 0&&h.push(new L(e.key,e.value,'"property" property is required')),h;function c(m){if(i==="identity")return[new L(m.key,m.value,'identity function may not have a "stops" property')];let g=[],_=m.value;return g=g.concat(Od({key:m.key,value:_,valueSpec:m.valueSpec,validateSpec:m.validateSpec,style:m.style,styleSpec:m.styleSpec,arrayElementValidator:d})),pe(_)==="array"&&_.length===0&&g.push(new L(m.key,_,"array must have at least one stop")),g}function d(m){let g=[],_=m.value,y=m.key;if(pe(_)!=="array")return[new L(y,_,`array expected, ${pe(_)} found`)];if(_.length!==2)return[new L(y,_,`array length 2 expected, length ${_.length} found`)];if(u){if(pe(_[0])!=="object")return[new L(y,_,`object expected, ${pe(_[0])} found`)];if(_[0].zoom===void 0)return[new L(y,_,"object stop key must have zoom")];if(_[0].value===void 0)return[new L(y,_,"object stop key must have value")];if(o&&o>it(_[0].zoom))return[new L(y,_[0].zoom,"stop zoom values must appear in ascending order")];it(_[0].zoom)!==o&&(o=it(_[0].zoom),n=void 0,a={}),g=g.concat(ai({key:`${y}[0]`,value:_[0],valueSpec:{zoom:{}},validateSpec:m.validateSpec,style:m.style,styleSpec:m.styleSpec,objectElementValidators:{zoom:Vl,value:p}}))}else g=g.concat(p({key:`${y}[0]`,value:_[0],valueSpec:{},validateSpec:m.validateSpec,style:m.style,styleSpec:m.styleSpec},_));return Ol(Qr(_[1]))?g.concat([new L(`${y}[1]`,_[1],"expressions are not allowed in function stops.")]):g.concat(m.validateSpec({key:`${y}[1]`,value:_[1],valueSpec:t,validateSpec:m.validateSpec,style:m.style,styleSpec:m.styleSpec}))}function p(m,g){let _=pe(m.value),y=it(m.value),v=m.value===null?g:m.value;if(!r)r=_;else if(_!==r)return[new L(m.key,v,`${_} stop domain type must match previous stop domain type ${r}`)];if(_!=="number"&&_!=="string"&&_!=="boolean")return[new L(m.key,v,"stop domain value must be a number, string, or boolean")];if(_!=="number"&&i!=="categorical"){let x=`number expected, ${_} found`;return Wa(t)&&i===void 0&&(x+='\nIf you intended to use a categorical function, specify `"type": "categorical"`.'),[new L(m.key,v,x)]}return i==="categorical"&&_==="number"&&(!isFinite(y)||Math.floor(y)!==y)?[new L(m.key,v,`integer expected, found ${y}`)]:i!=="categorical"&&_==="number"&&n!==void 0&&y<n?[new L(m.key,v,"stop domain values must appear in ascending order")]:(n=y,i==="categorical"&&y in a?[new L(m.key,v,"stop domain values must be unique")]:(a[y]=!0,[]))}function f(m){return m.validateSpec({key:m.key,value:m.value,valueSpec:t,validateSpec:m.validateSpec,style:m.style,styleSpec:m.styleSpec})}}function Xa(e){let t=(e.expressionContext==="property"?Yy:jl)(Qr(e.value),e.key,e.valueSpec);if(t.result==="error")return t.value.map(r=>new L(`${e.key}${r.key}`,e.value,r.message));let i=t.value.expression||t.value._styleExpression.expression;if(e.expressionContext==="property"&&e.propertyKey==="text-font"&&!i.outputDefined())return[new L(e.key,e.value,`Invalid data expression for "${e.propertyKey}". Output values must be contained as literals within the expression.`)];if(e.expressionContext==="property"&&e.propertyType==="layout"&&!eo(i))return[new L(e.key,e.value,'"feature-state" data expressions are not supported with layout properties.')];if(e.expressionContext==="filter"&&!eo(i))return[new L(e.key,e.value,'"feature-state" data expressions are not supported with filters.')];if(e.expressionContext&&e.expressionContext.indexOf("cluster")===0){if(!Ll(i,["zoom","feature-state"]))return[new L(e.key,e.value,'"zoom" and "feature-state" expressions are not supported with cluster properties.')];if(e.expressionContext==="cluster-initial"&&!kl(i))return[new L(e.key,e.value,"Feature data expressions are not supported with initial expression part of cluster properties.")]}return[]}function hT(e){let t=e.value,i=e.key,r=pe(t);return r==="boolean"?[]:[new L(i,t,`boolean expected, ${r} found`)]}function Zh(e){let t=e.key,i=e.value,r=pe(i);return r==="string"?oe.parse(String(i))?[]:[new L(t,i,`color expected, "${i}" found`)]:[new L(t,i,`color expected, ${r} found`)]}function ao(e){let t=e.key,i=e.value,r=e.valueSpec,a=[];return Array.isArray(r.values)?r.values.indexOf(it(i))===-1&&a.push(new L(t,i,`expected one of [${r.values.join(", ")}], ${JSON.stringify(i)} found`)):Object.keys(r.values).indexOf(it(i))===-1&&a.push(new L(t,i,`expected one of [${Object.keys(r.values).join(", ")}], ${JSON.stringify(i)} found`)),a}function cT(e,t){let i=e;for(let r of t)i=i[r];return i}function dT(e,t){let i=Bd(t);return i?[new L(`${e.key}${i.path.map(r=>`[${r}]`).join("")}`,cT(e.value,i.path),t0(i.legacyFilter),null,"warning")]:[]}function jd(e){let t=Qr(e.value);return Ld(t)?[...dT(e,t),...Xa(to({},e,{expressionContext:"filter",valueSpec:{value:"boolean"}}))]:n0(e)}function n0(e){let t=e.value,i=e.key;if(pe(t)!=="array")return[new L(i,t,`array expected, ${pe(t)} found`)];let r=e.styleSpec,a,n=[];if(t.length<1)return[new L(i,t,"filter array must have at least 1 element")];switch(n=n.concat(ao({key:`${i}[0]`,value:t[0],valueSpec:r.filter_operator,style:e.style,styleSpec:e.styleSpec})),it(t[0])){case"<":case"<=":case">":case">=":t.length>=2&&it(t[1])==="$type"&&n.push(new L(i,t,`"$type" cannot be use with operator "${t[0]}"`));case"==":case"!=":t.length!==3&&n.push(new L(i,t,`filter array for operator "${t[0]}" must have 3 elements`));case"in":case"!in":t.length>=2&&(a=pe(t[1]),a!=="string"&&n.push(new L(`${i}[1]`,t[1],`string expected, ${a} found`)));for(let o=2;o<t.length;o++)a=pe(t[o]),it(t[1])==="$type"?n=n.concat(ao({key:`${i}[${o}]`,value:t[o],valueSpec:r.geometry_type,style:e.style,styleSpec:e.styleSpec})):a!=="string"&&a!=="number"&&a!=="boolean"&&n.push(new L(`${i}[${o}]`,t[o],`string, number, or boolean expected, ${a} found`));break;case"any":case"all":case"none":for(let o=1;o<t.length;o++)n=n.concat(n0({key:`${i}[${o}]`,value:t[o],style:e.style,styleSpec:e.styleSpec}));break;case"has":case"!has":a=pe(t[1]),t.length===2?a!=="string"&&n.push(new L(`${i}[1]`,t[1],`string expected, ${a} found`)):n.push(new L(i,t,`filter array for "${t[0]}" operator must have 2 elements`))}return n}function o0(e,t){let i=e.key,r=e.validateSpec,a=e.style,n=e.styleSpec,o=e.value,s=e.objectKey,l=n[`${t}_${e.layerType}`];if(!l)return[];let u=s.match(Rd);if(t==="paint"&&u&&l[u[1]]&&l[u[1]].transition)return r({key:i,value:o,valueSpec:n.transition,style:a,styleSpec:n});let h=e.valueSpec||l[s];if(!h)return[new L(i,o,`unknown property "${s}"`)];let c;if(pe(o)==="string"&&Wa(h)&&!h.tokens&&(c=/^{([^}]+)}$/.exec(o)))return[new L(i,o,`"${s}" does not support interpolation syntax
|
|
2
|
+
Use an identity property function instead: \`{ "type": "identity", "property": ${JSON.stringify(c[1])} }\`.`)];let d=[];return e.layerType==="symbol"&&s==="text-font"&&Bl(Qr(o))&&it(o.type)==="identity"&&d.push(new L(i,o,'"text-font" does not support identity functions')),d.concat(r({key:e.key,value:o,valueSpec:h,style:a,styleSpec:n,expressionContext:"property",propertyType:t,propertyKey:s}))}function s0(e){return o0(e,"paint")}function l0(e){return o0(e,"layout")}function u0(e){let t=[],i=e.value,r=e.key,a=e.style,n=e.styleSpec;if(pe(i)!=="object")return[new L(r,i,`object expected, ${pe(i)} found`)];!i.type&&!i.ref&&t.push(new L(r,i,'either "type" or "ref" is required'));let o=it(i.type),s=it(i.ref);if(i.id){let l=it(i.id);for(let u=0;u<e.arrayIndex;u++){let h=a.layers[u];it(h.id)===l&&t.push(new L(r,i.id,`duplicate layer id "${i.id}", previously used at line ${h.id.__line__}`))}}if("ref"in i){["type","source","source-layer","filter","layout"].forEach(u=>{u in i&&t.push(new L(r,i[u],`"${u}" is prohibited for ref layers`))});let l;a.layers.forEach(u=>{it(u.id)===s&&(l=u)}),l?l.ref?t.push(new L(r,i.ref,"ref cannot reference another ref layer")):o=it(l.type):t.push(new L(r,i.ref,`ref layer "${s}" not found`))}else if(o!=="background")if(!i.source)t.push(new L(r,i,'missing required property "source"'));else{let l=a.sources&&a.sources[i.source],u=l&&it(l.type);l?u==="vector"&&o==="raster"?t.push(new L(r,i.source,`layer "${i.id}" requires a raster source`)):u!=="raster-dem"&&o==="hillshade"||u!=="raster-dem"&&o==="color-relief"?t.push(new L(r,i.source,`layer "${i.id}" requires a raster-dem source`)):u==="raster"&&o!=="raster"?t.push(new L(r,i.source,`layer "${i.id}" requires a vector source`)):u==="vector"&&!i["source-layer"]?t.push(new L(r,i,`layer "${i.id}" must specify a "source-layer"`)):u==="raster-dem"&&o!=="hillshade"&&o!=="color-relief"?t.push(new L(r,i.source,"raster-dem source can only be used with layer type 'hillshade' or 'color-relief'.")):o==="line"&&i.paint&&i.paint["line-gradient"]&&(u!=="geojson"||!l.lineMetrics)&&t.push(new L(r,i,`layer "${i.id}" specifies a line-gradient, which requires a GeoJSON source with \`lineMetrics\` enabled.`)):t.push(new L(r,i.source,`source "${i.source}" not found`))}return o==="raster"&&i.paint?.resampling&&i.paint?.["raster-resampling"]&&t.push(new L(r,i.paint,`layer "${i.id}" redundantly specifies "resampling" and "raster-resampling" paint properties, but only one is allowed. It is advised to use "resampling".`)),t=t.concat(ai({key:r,value:i,valueSpec:n.layer,style:e.style,styleSpec:e.styleSpec,validateSpec:e.validateSpec,objectElementValidators:{"*"(){return[]},type(){return e.validateSpec({key:`${r}.type`,value:i.type,valueSpec:n.layer.type,style:e.style,styleSpec:e.styleSpec,validateSpec:e.validateSpec,object:i,objectKey:"type"})},filter:jd,layout(l){return ai({layer:i,key:l.key,value:l.value,style:l.style,styleSpec:l.styleSpec,validateSpec:l.validateSpec,objectElementValidators:{"*"(u){return l0(to({layerType:o},u))}}})},paint(l){return ai({layer:i,key:l.key,value:l.value,style:l.style,styleSpec:l.styleSpec,validateSpec:l.validateSpec,objectElementValidators:{"*"(u){return s0(to({layerType:o},u))}}})}}})),t}function Pr(e){let t=e.value,i=e.key,r=pe(t);return r==="string"?[]:[new L(i,t,`string expected, ${r} found`)]}function pT(e){let t=e.sourceName??"",i=e.value,r=e.styleSpec,a=r.source_raster_dem,n=e.style,o=[],s=pe(i);if(i===void 0)return o;if(s!=="object")return o.push(new L("source_raster_dem",i,`object expected, ${s} found`)),o;let l=it(i.encoding)==="custom",u=["redFactor","greenFactor","blueFactor","baseShift"],h=e.value.encoding?`"${e.value.encoding}"`:"Default";for(let c in i)!l&&u.includes(c)?o.push(new L(c,i[c],`In "${t}": "${c}" is only valid when "encoding" is set to "custom". ${h} encoding found`)):a[c]?o=o.concat(e.validateSpec({key:c,value:i[c],valueSpec:a[c],validateSpec:e.validateSpec,style:n,styleSpec:r})):o.push(new L(c,i[c],`unknown property "${c}"`));return o}var Wf={promoteId:fT};function h0(e){let t=e.value,i=e.key,r=e.styleSpec,a=e.style,n=e.validateSpec;if(!t.type)return[new L(i,t,'"type" is required')];let o=it(t.type),s;switch(o){case"vector":case"raster":return s=ai({key:i,value:t,valueSpec:r[`source_${o.replace("-","_")}`],style:e.style,styleSpec:r,objectElementValidators:Wf,validateSpec:n}),s;case"raster-dem":return s=pT({sourceName:i,value:t,style:e.style,styleSpec:r,validateSpec:n}),s;case"geojson":if(s=ai({key:i,value:t,valueSpec:r.source_geojson,style:a,styleSpec:r,validateSpec:n,objectElementValidators:Wf}),t.cluster)for(let l in t.clusterProperties){let[u,h]=t.clusterProperties[l],c=typeof u=="string"?[u,["accumulated"],["get",l]]:u;s.push(...Xa({key:`${i}.${l}.map`,value:h,validateSpec:n,expressionContext:"cluster-map"})),s.push(...Xa({key:`${i}.${l}.reduce`,value:c,validateSpec:n,expressionContext:"cluster-reduce"}))}return s;case"video":return ai({key:i,value:t,valueSpec:r.source_video,style:a,validateSpec:n,styleSpec:r});case"image":return ai({key:i,value:t,valueSpec:r.source_image,style:a,validateSpec:n,styleSpec:r});case"canvas":return[new L(i,null,"Please use runtime APIs to add canvas sources, rather than including them in stylesheets.","source.canvas")];default:return ao({key:`${i}.type`,value:t.type,valueSpec:{values:["vector","raster","raster-dem","geojson","video","image"]},style:a,validateSpec:n,styleSpec:r})}}function fT({key:e,value:t}){if(pe(t)==="string")return Pr({key:e,value:t});{let i=[];for(let r in t)i.push(...Pr({key:`${e}.${r}`,value:t[r]}));return i}}function c0(e){let t=e.value,i=e.styleSpec,r=i.light,a=e.style,n=[],o=pe(t);if(t===void 0)return n;if(o!=="object")return n=n.concat([new L("light",t,`object expected, ${o} found`)]),n;for(let s in t){let l=s.match(Rd);n=l&&r[l[1]]&&r[l[1]].transition?n.concat(e.validateSpec({key:s,value:t[s],valueSpec:i.transition,validateSpec:e.validateSpec,style:a,styleSpec:i})):r[s]?n.concat(e.validateSpec({key:s,value:t[s],valueSpec:r[s],validateSpec:e.validateSpec,style:a,styleSpec:i})):n.concat([new L(s,t[s],`unknown property "${s}"`)])}return n}function d0(e){let t=e.value,i=e.styleSpec,r=i.sky,a=e.style,n=pe(t);if(t===void 0)return[];if(n!=="object")return[new L("sky",t,`object expected, ${n} found`)];let o=[];for(let s in t){let l=s.match(Rd);o=l&&r[l[1]]&&r[l[1]].transition?o.concat(e.validateSpec({key:s,value:t[s],valueSpec:i.transition,style:a,styleSpec:i})):r[s]?o.concat(e.validateSpec({key:s,value:t[s],valueSpec:r[s],style:a,styleSpec:i})):o.concat([new L(s,t[s],`unknown property "${s}"`)])}return o}function p0(e){let t=e.value,i=e.styleSpec,r=i.terrain,a=e.style,n=[],o=pe(t);if(t===void 0)return n;if(o!=="object")return n=n.concat([new L("terrain",t,`object expected, ${o} found`)]),n;for(let s in t)n=r[s]?n.concat(e.validateSpec({key:s,value:t[s],valueSpec:r[s],validateSpec:e.validateSpec,style:a,styleSpec:i})):n.concat([new L(s,t[s],`unknown property "${s}"`)]);return n}function mT(e){return Pr(e).length===0?[]:Xa(e)}function gT(e){return Pr(e).length===0?[]:Xa(e)}function _T(e){let t=e.key,i=e.value;if(pe(i)==="array"){if(i.length<1||i.length>4)return[new L(t,i,`padding requires 1 to 4 values; ${i.length} values found`)];let r={type:"number"},a=[];for(let n=0;n<i.length;n++)a=a.concat(e.validateSpec({key:`${t}[${n}]`,value:i[n],validateSpec:e.validateSpec,valueSpec:r}));return a}return Vl({key:t,value:i,valueSpec:{}})}function yT(e){let t=e.key,i=e.value;if(pe(i)==="array"){let r={type:"number"};if(i.length<1)return[new L(t,i,"array length at least 1 expected, length 0 found")];let a=[];for(let n=0;n<i.length;n++)a=a.concat(e.validateSpec({key:`${t}[${n}]`,value:i[n],validateSpec:e.validateSpec,valueSpec:r}));return a}return Vl({key:t,value:i,valueSpec:{}})}function vT(e){let t=e.key,i=e.value;if(pe(i)==="array"){if(i.length<1)return[new L(t,i,"array length at least 1 expected, length 0 found")];let r=[];for(let a=0;a<i.length;a++)r=r.concat(Zh({key:`${t}[${a}]`,value:i[a],valueSpec:{}}));return r}return Zh({key:t,value:i,valueSpec:{}})}function xT(e){let t=e.key,i=e.value,r=pe(i),a=e.styleSpec;if(r!=="array"||i.length<1||i.length%2!=0)return[new L(t,i,"variableAnchorOffsetCollection requires a non-empty array of even length")];let n=[];for(let o=0;o<i.length;o+=2)n=n.concat(ao({key:`${t}[${o}]`,value:i[o],valueSpec:a.layout_symbol["text-anchor"]})),n=n.concat(Od({key:`${t}[${o+1}]`,value:i[o+1],valueSpec:{length:2,value:"number"},validateSpec:e.validateSpec,style:e.style,styleSpec:a}));return n}function f0(e){let t=[],i=e.value,r=e.key;if(Array.isArray(i)){let a=[],n=[];for(let o in i)i[o].id&&a.includes(i[o].id)&&t.push(new L(r,i,`all the sprites' ids must be unique, but ${i[o].id} is duplicated`)),a.push(i[o].id),i[o].url&&n.includes(i[o].url)&&t.push(new L(r,i,`all the sprites' URLs must be unique, but ${i[o].url} is duplicated`)),n.push(i[o].url),t=t.concat(ai({key:`${r}[${o}]`,value:i[o],valueSpec:{id:{type:"string",required:!0},url:{type:"string",required:!0}},validateSpec:e.validateSpec}));return t}return Pr({key:r,value:i})}function bT(e){let t=e.value,i=e.styleSpec,r=i.projection,a=e.style,n=pe(t);if(t===void 0)return[];if(n!=="object")return[new L("projection",t,`object expected, ${n} found`)];let o=[];for(let s in t)o=r[s]?o.concat(e.validateSpec({key:s,value:t[s],valueSpec:r[s],style:a,styleSpec:i})):o.concat([new L(s,t[s],`unknown property "${s}"`)]);return o}function wT(e){let t=e.key,i=e.value;i=i instanceof String?i.valueOf():i;let r=pe(i);return r==="array"&&!ET(i)&&!TT(i)?[new L(t,i,`projection expected, invalid array ${JSON.stringify(i)} found`)]:["array","string"].includes(r)?[]:[new L(t,i,`projection expected, invalid type "${r}" found`)]}function TT(e){return!!["interpolate","step","literal"].includes(e[0])}function ET(e){return Array.isArray(e)&&e.length===3&&typeof e[0]=="string"&&typeof e[1]=="string"&&typeof e[2]=="number"}function qh(e){return!!e&&e.constructor===Object}function m0(e){return qh(e.value)?[]:[new L(e.key,e.value,`object expected, ${pe(e.value)} found`)]}var Hf=1114111,DT=/^u\+(?:([0-9a-f]{1,6})(?:-([0-9a-f]{1,6}))?|([0-9a-f]{0,5}\?{1,6}))$/i;function ST(e,t){if(pe(t)!=="string")return[];let i=`${t}`,r=()=>[new L(e,t,'invalid unicode range, expected a value such as "U+26", "U+0-10FFFF" or "U+4??"')],a=i.match(DT);if(!a)return r();let[,n,o,s]=a;if(s!==void 0)return s.length>6?r():[];let l=parseInt(n,16),u=o===void 0?l:parseInt(o,16);return l>Hf||u>Hf?[new L(e,t,"unicode range is out of bounds, the maximum code point is U+10FFFF")]:l>u?[new L(e,t,`unicode range start must not be greater than its end, but ${i} is`)]:[]}function g0(e){let t=e.key??"font-faces",i=e.value,r=e.validateSpec,a=e.styleSpec??Q_,n=e.style;if(!qh(i))return[new L(t,i,`object expected, ${pe(i)} found`)];let o=[];for(let s in i){let l=i[s],u=pe(l);if(u==="string")o.push(...Pr({key:`${t}.${s}`,value:l}));else if(u==="array"){let h={url:{type:"string",required:!0},"unicode-range":{type:"array",value:"string"}};for(let[c,d]of l.entries()){let p=`${t}.${s}[${c}]`;o.push(...ai({key:p,value:d,valueSpec:h,styleSpec:a,style:n,validateSpec:r}));let f=qh(d)?d["unicode-range"]:void 0;if(pe(f)==="array")for(let[m,g]of f.entries())o.push(...ST(`${p}.unicode-range[${m}]`,g))}}else o.push(new L(`${t}.${s}`,l,`string or array expected, ${u} found`))}return o}var Xf={"*"(){return[]},array:Od,boolean:hT,number:Vl,color:Zh,constants:r0,enum:ao,filter:jd,function:a0,layer:u0,object:ai,source:h0,light:c0,sky:d0,terrain:p0,projection:bT,projectionDefinition:wT,string:Pr,formatted:mT,resolvedImage:gT,padding:_T,numberArray:yT,colorArray:vT,variableAnchorOffsetCollection:xT,sprite:f0,state:m0,fontFaces:g0};function Nn(e){let t=e.value,i=e.valueSpec,r=e.styleSpec;return e.validateSpec=Nn,i.expression&&Bl(it(t))?a0(e):i.expression&&Ol(Qr(t))?Xa(e):i.type&&Xf[i.type]?Xf[i.type](e):ai(to({},e,{valueSpec:i.type?r[i.type]:i}))}function _0(e){let t=e.value,i=e.key,r=Pr(e);return r.length||(t.indexOf("{fontstack}")===-1&&r.push(new L(i,t,'"glyphs" url must include a "{fontstack}" token')),t.indexOf("{range}")===-1&&r.push(new L(i,t,'"glyphs" url must include a "{range}" token'))),r}function ei(e,t=F){let i=[];return i=i.concat(Nn({key:"",value:e,valueSpec:t.$root,styleSpec:t,style:e,validateSpec:Nn,objectElementValidators:{glyphs:_0,"*"(){return[]}}})),e.constants&&(i=i.concat(r0({key:"constants",value:e.constants,style:e,styleSpec:t,validateSpec:Nn}))),y0(i)}ei.source=fi(pi(h0)),ei.sprite=fi(pi(f0)),ei.glyphs=fi(pi(_0)),ei.fontFaces=fi(pi(g0)),ei.light=fi(pi(c0)),ei.sky=fi(pi(d0)),ei.terrain=fi(pi(p0)),ei.state=fi(pi(m0)),ei.layer=fi(pi(u0)),ei.filter=fi(pi(jd)),ei.paintProperty=fi(pi(s0)),ei.layoutProperty=fi(pi(l0));function pi(e){return function(t){return e(Object.assign({},t,{validateSpec:Nn}))}}function y0(e){return[].concat(e).sort((t,i)=>t.line-i.line)}function fi(e){return function(...t){return y0(e.apply(this,t))}}var CT={type:"enum","property-type":"data-constant",expression:{interpolated:!1,parameters:["global-state"]},values:{visible:{},none:{}},transition:!1,default:"visible"},PT=class{constructor(e,t,i){this._rootKey=t,this._globalState=i,this.setValue(e)}evaluate(){return this._literalValue??this._compiledValue.evaluate({})}setValue(e){if(e==null||e==="visible"||e==="none"){this._literalValue=e==="none"?"none":"visible",this._compiledValue=void 0,this._globalStateRefs=new Set;return}let t=jl(e,this._rootKey,CT,this._globalState);if(t.result==="error")throw this._literalValue="visible",this._compiledValue=void 0,Error(t.value.map(i=>`${i.key}: ${i.message}`).join(", "));this._literalValue=void 0,this._compiledValue=t.value,this._globalStateRefs=Do(t.value.expression)}getGlobalStateRefs(){return this._globalStateRefs}};function AT(e,t,i){return new PT(e,t,i)}var Wt=ei,v0=new Set(Object.keys(F).filter(e=>e.startsWith("source_")).map(e=>e.slice(7).replaceAll("_","-")));function IT(e){return Object.entries(e.sources??{}).filter(([,t])=>!v0.has(t.type)).map(([t])=>`sources.${t}`)}function Yf(e,t){let i=IT(t);return Vd(e,Wt(t).filter(({message:r})=>!i.some(a=>r.startsWith(`${a}:`)||r.startsWith(`${a}.`))))}function Vd(e,t){let i=!1;for(let r of t){if(r.severity==="warning"){_e(r.message);continue}e.fire(new Y(Error(r.message))),i=!0}return i}function So(e,t,i,r){return r?.validate!==!1&&Vd(e,t({styleSpec:F,...i}))}var Wh=class x0{constructor(t,i,r){let a=this.cells=[];if(t instanceof ArrayBuffer){this.arrayBuffer=t;let o=new Int32Array(this.arrayBuffer);t=o[0],i=o[1],r=o[2],this.d=i+2*r;for(let u=0;u<this.d*this.d;u++){let h=o[3+u],c=o[3+u+1];a.push(h===c?null:o.subarray(h,c))}let s=o[3+a.length],l=o[3+a.length+1];this.keys=o.subarray(s,l),this.bboxes=o.subarray(l),this.insert=this._insertReadonly}else{this.d=i+2*r;for(let o=0;o<this.d*this.d;o++)a.push([]);this.keys=[],this.bboxes=[]}this.n=i,this.extent=t,this.padding=r,this.scale=i/t,this.uid=0;let n=r/i*t;this.min=-n,this.max=t+n}insert(t,i,r,a,n){this._forEachCell(i,r,a,n,this._insertCell,this.uid++,void 0,void 0),this.keys.push(t),this.bboxes.push(i),this.bboxes.push(r),this.bboxes.push(a),this.bboxes.push(n)}_insertReadonly(){throw Error("Cannot insert into a GridIndex created from an ArrayBuffer.")}_insertCell(t,i,r,a,n,o){this.cells[n].push(o)}query(t,i,r,a,n){let o=this.min,s=this.max;if(t<=o&&i<=o&&s<=r&&s<=a&&!n)return[...this.keys];{let l=[];return this._forEachCell(t,i,r,a,this._queryCell,l,{},n),l}}_queryCell(t,i,r,a,n,o,s,l){let u=this.cells[n];if(u!==null){let h=this.keys,c=this.bboxes;for(let d of u)if(s[d]===void 0){let p=d*4;(l?l(c[p+0],c[p+1],c[p+2],c[p+3]):t<=c[p+2]&&i<=c[p+3]&&r>=c[p+0]&&a>=c[p+1])?(s[d]=!0,o.push(h[d])):s[d]=!1}}}_forEachCell(t,i,r,a,n,o,s,l){let u=this._convertToCellCoord(t),h=this._convertToCellCoord(i),c=this._convertToCellCoord(r),d=this._convertToCellCoord(a);for(let p=u;p<=c;p++)for(let f=h;f<=d;f++){let m=this.d*f+p;if((!l||l(this._convertFromCellCoord(p),this._convertFromCellCoord(f),this._convertFromCellCoord(p+1),this._convertFromCellCoord(f+1)))&&n.call(this,t,i,r,a,m,o,s,l))return}}_convertFromCellCoord(t){return(t-this.padding)/this.scale}_convertToCellCoord(t){return Math.max(0,Math.min(this.d-1,Math.floor(t*this.scale)+this.padding))}toArrayBuffer(){if(this.arrayBuffer)return this.arrayBuffer;let t=this.cells,i=3+this.cells.length+1+1,r=0;for(let o of this.cells)r+=o.length;let a=new Int32Array(i+r+this.keys.length+this.bboxes.length);a[0]=this.extent,a[1]=this.n,a[2]=this.padding;let n=i;for(let o=0;o<t.length;o++){let s=t[o];a[3+o]=n,a.set(s,n),n+=s.length}return a[3+t.length]=n,a.set(this.keys,n),n+=this.keys.length,a[3+t.length+1]=n,a.set(this.bboxes,n),n+=this.bboxes.length,a.buffer}static serialize(t,i){let r=t.toArrayBuffer();return i&&i.push(r),{buffer:r}}static deserialize(t){return new x0(t.buffer)}},ar={};function G(e,t,i={}){if(ar[e])throw Error(`${e} is already registered.`);Object.defineProperty(t,"_classRegistryKey",{value:e,writeable:!1}),ar[e]={klass:t,omit:i.omit||[],shallow:i.shallow||[]}}G("Object",Object),G("Set",Set),G("TransferableGridIndex",Wh),G("Color",oe),G("Error",Error),G("AJAXError",Yn),G("ResolvedImage",Hi),G("StylePropertyFunction",Ky),G("StyleExpression",kd,{omit:["_evaluator"]}),G("ZoomDependentExpression",Qs),G("ZoomConstantExpression",io),G("CompoundExpression",oa,{omit:["_evaluate"]});for(let e in Ra)Ra[e]._classRegistryKey||G(`Expression_${e}`,Ra[e]);function b0(e){return e&&typeof ArrayBuffer<"u"&&(e instanceof ArrayBuffer||e.constructor?.name==="ArrayBuffer")}function Nd(e){let t=e.constructor;return e.$name||t._classRegistryKey}function MT(e){if(typeof e!="object"||!e)return!1;let t=Nd(e);return t&&t!=="Object"}function w0(e){return!MT(e)&&(e==null||typeof e=="boolean"||typeof e=="number"||typeof e=="string"||e instanceof Boolean||e instanceof Number||e instanceof String||e instanceof Date||e instanceof RegExp||e instanceof Blob||e instanceof Error||b0(e)||qr(e)||ArrayBuffer.isView(e)||e instanceof ImageData)}function Un(e,t){if(w0(e))return(b0(e)||qr(e))&&t&&t.push(e),ArrayBuffer.isView(e)&&t&&t.push(e.buffer),e instanceof ImageData&&t&&t.push(e.data.buffer),e;if(Array.isArray(e)){let n=[];for(let o of e)n.push(Un(o,t));return n}if(typeof e!="object")throw Error(`can't serialize object of type ${typeof e}`);let i=Nd(e);if(!i)throw Error(`can't serialize object of unregistered class ${e.constructor.name}`);if(!ar[i])throw Error(`${i} is not registered.`);let{klass:r}=ar[i],a=r.serialize?r.serialize(e,t):{};if(r.serialize){if(a===t?.[t.length-1])throw Error("statically serialized object won't survive transfer of $name property")}else{for(let n in e){if(!e.hasOwnProperty(n)||ar[i].omit.includes(n))continue;let o=e[n];o!==void 0&&(a[n]=ar[i].shallow.includes(n)?o:Un(o,t))}e instanceof Error&&(a.message=e.message)}if(a.$name)throw Error("$name property is reserved for worker serialization logic.");return i!=="Object"&&(a.$name=i),a}function $n(e){if(w0(e))return e;if(Array.isArray(e))return e.map($n);if(typeof e!="object")throw Error(`can't deserialize object of type ${typeof e}`);let t=Nd(e)||"Object";if(!ar[t])throw Error(`can't deserialize unregistered class ${t}`);let{klass:i}=ar[t];if(!i)throw Error(`can't deserialize unregistered class ${t}`);if(i.deserialize)return i.deserialize(e);let r=Object.create(i.prototype);for(let a of Object.keys(e)){if(a==="$name")continue;let n=e[a];r[a]=ar[t].shallow.includes(a)?n:$n(n)}return r}var Hh=class{constructor(){this.first=!0}update(e,t){let i=Math.floor(e);return this.first?(this.first=!1,this.lastIntegerZoom=i,this.lastIntegerZoomTime=0,this.lastZoom=e,this.lastFloorZoom=i,!0):(this.lastFloorZoom>i?(this.lastIntegerZoom=i+1,this.lastIntegerZoomTime=t):this.lastFloorZoom<i&&(this.lastIntegerZoom=i,this.lastIntegerZoomTime=t),e!==this.lastZoom&&(this.lastZoom=e,this.lastFloorZoom=i,!0))}},Ae=class{constructor(e,t){this.zoom=e,t?(this.now=t.now||0,this.fadeDuration=t.fadeDuration||0,this.zoomHistory=t.zoomHistory||new Hh,this.transition=t.transition||{}):(this.now=0,this.fadeDuration=0,this.zoomHistory=new Hh,this.transition={})}crossFadingFactor(){return this.fadeDuration===0?1:Math.min((this.now-this.zoomHistory.lastIntegerZoomTime)/this.fadeDuration,1)}getCrossfadeParameters(){let e=this.zoom,t=e-Math.floor(e),i=this.crossFadingFactor();return e>this.zoomHistory.lastIntegerZoom?{fromScale:2,toScale:1,t:t+(1-t)*i}:{fromScale:.5,toScale:1,t:1-(1-i)*t}}},no=class{constructor(e,t,i,r){this.property=e,this.value=t,this.expression=tT(t===void 0?e.specification.default:t,i,e.specification,r)}isDataDriven(){return this.expression.kind==="source"||this.expression.kind==="composite"}getGlobalStateRefs(){return this.expression.globalStateRefs||new Set}readsGlobalState(e){let t=this.getGlobalStateRefs();return e.some(i=>t.has(i))}possiblyEvaluate(e,t,i){return this.property.possiblyEvaluate(this,e,t,i)}},Xh=class{constructor(e,t,i){this.property=e,this.value=new no(e,void 0,t,i)}transitioned(e,t){return t.value===this.value?t:new Kf(this.property,this.value,t,q({},e.transition,this.transition),e.now)}untransitioned(){return new Kf(this.property,this.value,null,{},0)}},Nl=class{constructor(e,t,i){this._properties=e,this._values=Object.create(e.defaultTransitionablePropertyValues),this._globalState=i,this._rootKey=t}_propertyRootKey(e){return`${this._rootKey}.${String(e)}`}hasProperty(e){return e in this._properties.defaultTransitionablePropertyValues}getValue(e){return Ht(this._values[e].value.value)}setValue(e,t){Object.hasOwn(this._values,e)||(this._values[e]=new Xh(this._values[e].property,this._propertyRootKey(e),this._globalState)),this._values[e].value=new no(this._values[e].property,t===null?void 0:Ht(t),this._propertyRootKey(e),this._globalState)}setValues(e){for(let t in e){let i=e[t];t.endsWith("-transition")?this.setTransition(t.slice(0,-11),i):Vi(this._values[t].value.value,i)||this.setValue(t,i)}}getTransition(e){return Ht(this._values[e].transition)}setTransition(e,t){Object.hasOwn(this._values,e)||(this._values[e]=new Xh(this._values[e].property,this._propertyRootKey(e),this._globalState)),this._values[e].transition=Ht(t)||void 0}retainPriorGlobalState(e,t,i){for(let r of Object.keys(i._values))for(let a=i._values[r];a;a=a.prior){let{value:n}=a;n.property.specification.transition&&!n.isDataDriven()&&n.expression._globalState===this._globalState&&n.readsGlobalState(e)&&(a.value=new no(n.property,n.value,this._propertyRootKey(r),t))}}applyGlobalStateChange(e,t,i,r){this.retainPriorGlobalState(e,t,i);let a=!1;for(let n of Object.keys(this._values)){let{value:o}=this._values[n];o.readsGlobalState(e)&&(this.setValue(n,o.value),a=!0)}return a?this.transitioned(r,i):i}serialize(){let e={};for(let t of Object.keys(this._values)){let i=this.getValue(t);i!==void 0&&(e[t]=i);let r=this.getTransition(t);r!==void 0&&(e[`${t}-transition`]=r)}return e}transitioned(e,t){let i=new Jf(this._properties);for(let r of Object.keys(this._values))i._values[r]=this._values[r].transitioned(e,t._values[r]);return i}untransitioned(){let e=new Jf(this._properties);for(let t of Object.keys(this._values))e._values[t]=this._values[t].untransitioned();return e}},Kf=class{constructor(e,t,i,r,a){this.property=e,this.value=t,this.begin=a+r.delay||0,this.end=this.begin+r.duration||0,e.specification.transition&&(r.delay||r.duration)&&(this.prior=i)}possiblyEvaluate(e,t,i){let r=e.now||0,a=this.value.possiblyEvaluate(e,t,i),n=this.prior;if(!n)return a;if(r>this.end||this.value.isDataDriven())return this.prior=null,a;if(r<this.begin)return n.possiblyEvaluate(e,t,i);{let o=(r-this.begin)/(this.end-this.begin);return this.property.interpolate(n.possiblyEvaluate(e,t,i),a,Xb(o))}}},Jf=class{constructor(e){this._properties=e,this._values=Object.create(e.defaultTransitioningPropertyValues)}possiblyEvaluate(e,t,i){let r=new Ul(this._properties);for(let a of Object.keys(this._values))r._values[a]=this._values[a].possiblyEvaluate(e,t,i);return r}hasTransition(){for(let e of Object.keys(this._values))if(this._values[e].prior)return!0;return!1}},FT=class{constructor(e,t,i){this._properties=e,this._values=Object.create(e.defaultPropertyValues),this._globalState=i,this._rootKey=t}_propertyRootKey(e){return`${this._rootKey}.${String(e)}`}hasValue(e){return this._values[e].value!==void 0}hasProperty(e){return e in this._properties.defaultPropertyValues}getValue(e){return Ht(this._values[e].value)}setValue(e,t){this._values[e]=new no(this._values[e].property,t===null?void 0:Ht(t),this._propertyRootKey(e),this._globalState)}serialize(){let e={};for(let t of Object.keys(this._values)){let i=this.getValue(t);i!==void 0&&(e[t]=i)}return e}possiblyEvaluate(e,t,i){let r=new Ul(this._properties);for(let a of Object.keys(this._values))r._values[a]=this._values[a].possiblyEvaluate(e,t,i);return r}},xi=class{constructor(e,t,i){this.property=e,this.value=t,this.parameters=i}isConstant(){return this.value.kind==="constant"}constantOr(e){return this.value.kind==="constant"?this.value.value:e}evaluate(e,t,i,r){return this.property.evaluate(this.value,this.parameters,e,t,i,r)}},Ul=class{constructor(e){this._properties=e,this._values=Object.create(e.defaultPossiblyEvaluatedValues)}get(e){return this._values[e]}};function Qf(e){if(Array.isArray(e))return e.length;let t=e?.values;return Array.isArray(t)?t.length:void 0}function T0(e,t){let i=Qf(e),r=Qf(t);return i!==void 0&&r!==void 0&&i!==r}var U=class{constructor(e,t){this.specification=e,this.name=t}possiblyEvaluate(e,t){if(e.isDataDriven())throw Error("Value should not be data driven");return e.expression.evaluate(t)}interpolate(e,t,i){if(T0(e,t))return _e(`Property "${this.name}" is trying to interpolate arrays of different lengths. Rendering may 'jump'.`),t;let r=this.specification.type,a=He[r];return a?a(e,t,i):e}},ee=class{constructor(e,t,i){this.specification=e,this.name=t,this.overrides=i}possiblyEvaluate(e,t,i,r){return e.expression.kind==="constant"||e.expression.kind==="camera"?new xi(this,{kind:"constant",value:e.expression.evaluate(t,null,{},i,r)},t):new xi(this,e.expression,t)}interpolate(e,t,i){if(e.value.kind!=="constant"||t.value.kind!=="constant")return e;if(e.value.value===void 0||t.value.value===void 0)return new xi(this,{kind:"constant",value:void 0},e.parameters);if(T0(e.value.value,t.value.value))return _e(`Property "${this.name}" is trying to interpolate arrays of different lengths. Rendering may 'jump'.`),t;let r=this.specification.type,a=He[r];if(a){let n=a(e.value.value,t.value.value,i);return new xi(this,{kind:"constant",value:n},e.parameters)}return e}evaluate(e,t,i,r,a,n){return e.kind==="constant"?e.value:e.evaluate(t,i,r,a,n)}},oo=class extends ee{possiblyEvaluate(e,t,i,r){if(e.value===void 0)return new xi(this,{kind:"constant",value:void 0},t);if(e.expression.kind==="constant"){let a=e.expression.evaluate(t,null,{},i,r),n=e.property.specification.type==="resolvedImage"&&typeof a!="string"?a.name:a,o=this._calculate(n,n,n,t);return new xi(this,{kind:"constant",value:o},t)}if(e.expression.kind==="camera"){let a=this._calculate(e.expression.evaluate({zoom:t.zoom-1}),e.expression.evaluate({zoom:t.zoom}),e.expression.evaluate({zoom:t.zoom+1}),t);return new xi(this,{kind:"constant",value:a},t)}return new xi(this,e.expression,t)}evaluate(e,t,i,r,a,n){if(e.kind==="source"){let o=e.evaluate(t,i,r,a,n);return this._calculate(o,o,o,t)}return e.kind==="composite"?this._calculate(e.evaluate({zoom:Math.floor(t.zoom)-1},i,r),e.evaluate({zoom:Math.floor(t.zoom)},i,r),e.evaluate({zoom:Math.floor(t.zoom)+1},i,r),t):e.value}_calculate(e,t,i,r){return r.zoom>r.zoomHistory.lastIntegerZoom?{from:e,to:t}:{from:i,to:t}}interpolate(e){return e}},E0=class{constructor(e,t){this.specification=e,this.name=t}possiblyEvaluate(e,t,i,r){if(e.value!==void 0){if(e.expression.kind==="constant"){let a=e.expression.evaluate(t,null,{},i,r);return this._calculate(a,a,a,t)}return this._calculate(e.expression.evaluate(new Ae(Math.floor(t.zoom-1),t)),e.expression.evaluate(new Ae(Math.floor(t.zoom),t)),e.expression.evaluate(new Ae(Math.floor(t.zoom+1),t)),t)}}_calculate(e,t,i,r){return r.zoom>r.zoomHistory.lastIntegerZoom?{from:e,to:t}:{from:i,to:t}}interpolate(e){return e}},$l=class{constructor(e,t){this.specification=e,this.name=t}possiblyEvaluate(e,t,i,r){return!!e.expression.evaluate(t,null,{},i,r)}interpolate(){return!1}},wt=class{constructor(e){this.properties=e,this.defaultPropertyValues={},this.defaultTransitionablePropertyValues={},this.defaultTransitioningPropertyValues={},this.defaultPossiblyEvaluatedValues={},this.overridableProperties=[];for(let t in e){let i=e[t];i.specification.overridable&&this.overridableProperties.push(t);let r=this.defaultPropertyValues[t]=new no(i,void 0,i.name,void 0),a=this.defaultTransitionablePropertyValues[t]=new Xh(i,i.name,void 0);this.defaultTransitioningPropertyValues[t]=a.untransitioned(),this.defaultPossiblyEvaluatedValues[t]=r.possiblyEvaluate({})}}};G("DataDrivenProperty",ee),G("DataConstantProperty",U),G("CrossFadedDataDrivenProperty",oo),G("CrossFadedProperty",E0),G("ColorRampProperty",$l);var em=" is a PAINT property not a LAYOUT property. Use get/setPaintProperty instead?",Hu=" is a LAYOUT property not a PAINT property. Use get/setLayoutProperty instead?",ki=class extends ht{constructor(e,t,i){if(super(),this.id=e.id,this.type=e.type,this._globalState=i,this._featureFilter={filter:()=>!0,needGeometry:!1,getGlobalStateRefs:()=>new Set},this._visibilityExpression=AT(this.visibility,`layers[${this.id}].layout.visibility`,i),e.type!=="custom"&&(this.metadata=e.metadata,this.minzoom=e.minzoom,this.maxzoom=e.maxzoom,e.type!=="background"&&(this.source=e.source,this.sourceLayer=e["source-layer"],this.filter=e.filter,this._featureFilter=ro(e.filter,`layers[${this.id}].filter`,i)),t.layout&&(this._unevaluatedLayout=new FT(t.layout,`layers[${this.id}].layout`,i)),t.paint)){this._transitionablePaint=new Nl(t.paint,`layers[${this.id}].paint`,i);for(let r in e.paint)this.setPaintProperty(r,e.paint[r],{validate:!1});for(let r in e.layout)this.setLayoutProperty(r,e.layout[r],{validate:!1});this._transitioningPaint=this._transitionablePaint.untransitioned(),this.paint=new Ul(t.paint)}}setFilter(e){this.filter=e,this._featureFilter=ro(e,`layers[${this.id}].filter`,this._globalState)}getCrossfadeParameters(){return this._crossfadeParameters}getLayoutProperty(e){if(e==="visibility")return this.visibility;if(this._transitionablePaint?.hasProperty(e))throw Error(e+em);if(!this._unevaluatedLayout)throw Error(`Cannot get layout property "${e}" on layer type "${this.type}" which has no layout properties.`);return this._unevaluatedLayout.getValue(e)}getLayoutAffectingGlobalStateRefs(){let e=new Set;for(let t of this._visibilityExpression.getGlobalStateRefs())e.add(t);if(this._unevaluatedLayout)for(let t in this._unevaluatedLayout._values){let i=this._unevaluatedLayout._values[t];for(let r of i.getGlobalStateRefs())e.add(r)}for(let t of this._featureFilter.getGlobalStateRefs())e.add(t);return e}getPaintAffectingGlobalStateRefs(){let e=new globalThis.Map;if(this._transitionablePaint)for(let t in this._transitionablePaint._values){let i=this._transitionablePaint._values[t].value;for(let r of i.getGlobalStateRefs()){let a=e.get(r)??[];a.push({name:t,value:i.value}),e.set(r,a)}}return e}getVisibilityAffectingGlobalStateRefs(){return this._visibilityExpression.getGlobalStateRefs()}setLayoutProperty(e,t,i={}){if(e==="visibility"){this.visibility=t,this._visibilityExpression.setValue(t),this.recalculateVisibility();return}if(this._transitionablePaint?.hasProperty(e)){this.fire(new Y(Error(e+em)));return}t!=null&&this._validate(Wt.layoutProperty,`layers.${this.id}.layout.${e}`,e,t,i)||this._unevaluatedLayout.setValue(e,t)}getPaintProperty(e){if(e.endsWith("-transition")){let t=e.slice(0,-11);if(t==="visibility"||this._unevaluatedLayout?.hasProperty(t))throw Error(e+Hu);return this._transitionablePaint.getTransition(t)}if(e==="visibility"||this._unevaluatedLayout?.hasProperty(e))throw Error(e+Hu);return this._transitionablePaint.getValue(e)}setPaintProperty(e,t,i={}){if(e==="visibility"||this._unevaluatedLayout?.hasProperty(e))return this.fire(new Y(Error(e+Hu))),!1;if(t!=null&&this._validate(Wt.paintProperty,`layers.${this.id}.paint.${e}`,e,t,i))return!1;if(e.endsWith("-transition"))return this._transitionablePaint.setTransition(e.slice(0,-11),t||void 0),!1;{let r=this._transitionablePaint._values[e],a=r.property.specification["property-type"]==="cross-faded-data-driven",n=r.value.isDataDriven(),o=r.value;this._transitionablePaint.setValue(e,t),this._handleSpecialPaintPropertyUpdate(e);let s=this._transitionablePaint._values[e].value;return s.isDataDriven()||n||a||this._handleOverridablePaintPropertyUpdate(e,o,s)}}_handleSpecialPaintPropertyUpdate(e){}_handleOverridablePaintPropertyUpdate(e,t,i){return!1}isHidden(e=this.minzoom,t=!1){return this.minzoom&&e<(t?Math.floor(this.minzoom):this.minzoom)||this.maxzoom&&e>=this.maxzoom?!0:this._evaluatedVisibility==="none"}updateTransitions(e){this._transitioningPaint=this._transitionablePaint.transitioned(e,this._transitioningPaint)}retainPriorGlobalState(e,t){this._transitionablePaint?.retainPriorGlobalState(e,t,this._transitioningPaint)}hasTransition(){return this._transitioningPaint.hasTransition()}recalculateVisibility(){this._evaluatedVisibility=this._visibilityExpression.evaluate()}recalculate(e,t){e.getCrossfadeParameters&&(this._crossfadeParameters=e.getCrossfadeParameters()),this._unevaluatedLayout&&(this.layout=this._unevaluatedLayout.possiblyEvaluate(e,void 0,t)),this.paint=this._transitioningPaint.possiblyEvaluate(e,void 0,t)}serialize(){let e={id:this.id,type:this.type,source:this.source,"source-layer":this.sourceLayer,metadata:this.metadata,minzoom:this.minzoom,maxzoom:this.maxzoom,filter:this.filter,layout:this._unevaluatedLayout?.serialize(),paint:this._transitionablePaint?.serialize()};return this.visibility&&(e.layout||(e.layout={}),e.layout.visibility=this.visibility),V_(e,(t,i)=>t!==void 0&&!(i==="layout"&&!Object.keys(t).length)&&!(i==="paint"&&!Object.keys(t).length))}_validate(e,t,i,r,a={}){return So(this,e,{key:t,layerType:this.type,objectKey:i,value:r},a)}is3D(){return!1}isTileClipped(){return!1}hasOffscreenPass(){return!1}resize(){}isStateDependent(){for(let e in this.paint._values){let t=this.paint.get(e);if(t instanceof xi&&Wa(t.property.specification)&&(t.value.kind==="source"||t.value.kind==="composite")&&t.value.isStateDependent)return!0}return!1}},tm,zT=()=>tm||(tm=new wt({"raster-opacity":new U(F.paint_raster["raster-opacity"],"raster-opacity"),"raster-hue-rotate":new U(F.paint_raster["raster-hue-rotate"],"raster-hue-rotate"),"raster-brightness-min":new U(F.paint_raster["raster-brightness-min"],"raster-brightness-min"),"raster-brightness-max":new U(F.paint_raster["raster-brightness-max"],"raster-brightness-max"),"raster-saturation":new U(F.paint_raster["raster-saturation"],"raster-saturation"),"raster-contrast":new U(F.paint_raster["raster-contrast"],"raster-contrast"),resampling:new U(F.paint_raster.resampling,"resampling"),"raster-resampling":new U(F.paint_raster["raster-resampling"],"raster-resampling"),"raster-fade-duration":new U(F.paint_raster["raster-fade-duration"],"raster-fade-duration")})),RT={get paint(){return zT()}},Yh=e=>e.type==="raster",kT=class extends ki{constructor(e,t){super(e,RT,t)}},LT={Int8:Int8Array,Uint8:Uint8Array,Int16:Int16Array,Uint16:Uint16Array,Int32:Int32Array,Uint32:Uint32Array,Float32:Float32Array},Co=class{constructor(e,t){this._structArray=e,this._pos1=t*this.size,this._pos2=this._pos1/2,this._pos4=this._pos1/4,this._pos8=this._pos1/8}},Qe=class{constructor(){this.isTransferred=!1,this.capacity=-1,this.resize(0)}static serialize(e,t){return e._trim(),t&&(e.isTransferred=!0,t.push(e.arrayBuffer)),{length:e.length,arrayBuffer:e.arrayBuffer}}static deserialize(e){let t=Object.create(this.prototype);return t.arrayBuffer=e.arrayBuffer,t.length=e.length,t.capacity=e.arrayBuffer.byteLength/t.bytesPerElement,t._refreshViews(),t}_trim(){this.length!==this.capacity&&(this.capacity=this.length,this.arrayBuffer=this.arrayBuffer.slice(0,this.length*this.bytesPerElement),this._refreshViews())}clear(){this.length=0}resize(e){this.reserve(e),this.length=e}reserve(e){if(e>this.capacity){this.capacity=Math.max(e,Math.floor(this.capacity*5),128),this.arrayBuffer=new ArrayBuffer(this.capacity*this.bytesPerElement);let t=this.uint8;this._refreshViews(),t&&this.uint8.set(t)}}_refreshViews(){throw Error("_refreshViews() must be implemented by each concrete StructArray layout")}freeBufferAfterUpload(){this.arrayBuffer=new ArrayBuffer(0),this._refreshViews()}};function Je(e,t=1){let i=0,r=0;return{members:e.map(a=>{let n=BT(a.type),o=i=im(i,Math.max(t,n)),s=a.components||1;return r=Math.max(r,n),i+=n*s,{name:a.name,type:a.type,components:s,offset:o}}),size:im(i,Math.max(r,t)),alignment:t}}function BT(e){return LT[e].BYTES_PER_ELEMENT}function im(e,t){return Math.ceil(e/t)*t}var so=class extends Qe{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(e,t){let i=this.length;return this.resize(i+1),this.emplace(i,e,t)}emplace(e,t,i){let r=e*2;return this.int16[r+0]=t,this.int16[r+1]=i,e}};so.prototype.bytesPerElement=4,G("StructArrayLayout2i4",so);var tl=class extends Qe{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(e,t,i){let r=this.length;return this.resize(r+1),this.emplace(r,e,t,i)}emplace(e,t,i,r){let a=e*3;return this.int16[a+0]=t,this.int16[a+1]=i,this.int16[a+2]=r,e}};tl.prototype.bytesPerElement=6,G("StructArrayLayout3i6",tl);var Kh=class extends Qe{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(e,t,i,r){let a=this.length;return this.resize(a+1),this.emplace(a,e,t,i,r)}emplace(e,t,i,r,a){let n=e*4;return this.int16[n+0]=t,this.int16[n+1]=i,this.int16[n+2]=r,this.int16[n+3]=a,e}};Kh.prototype.bytesPerElement=8,G("StructArrayLayout4i8",Kh);var Jh=class extends Qe{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(e,t,i,r,a,n){let o=this.length;return this.resize(o+1),this.emplace(o,e,t,i,r,a,n)}emplace(e,t,i,r,a,n,o){let s=e*6;return this.int16[s+0]=t,this.int16[s+1]=i,this.int16[s+2]=r,this.int16[s+3]=a,this.int16[s+4]=n,this.int16[s+5]=o,e}};Jh.prototype.bytesPerElement=12,G("StructArrayLayout2i4i12",Jh);var Qh=class extends Qe{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer),this.int8=new Int8Array(this.arrayBuffer)}emplaceBack(e,t,i,r,a,n,o,s){let l=this.length;return this.resize(l+1),this.emplace(l,e,t,i,r,a,n,o,s)}emplace(e,t,i,r,a,n,o,s,l){let u=e*5,h=e*10;return this.int16[u+0]=t,this.int16[u+1]=i,this.uint8[h+4]=r,this.uint8[h+5]=a,this.uint8[h+6]=n,this.uint8[h+7]=o,this.int8[h+8]=s,this.int8[h+9]=l,e}};Qh.prototype.bytesPerElement=10,G("StructArrayLayout2i4ub2b10",Qh);var lo=class extends Qe{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(e,t){let i=this.length;return this.resize(i+1),this.emplace(i,e,t)}emplace(e,t,i){let r=e*2;return this.float32[r+0]=t,this.float32[r+1]=i,e}};lo.prototype.bytesPerElement=8,G("StructArrayLayout2f8",lo);var ec=class extends Qe{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(e,t,i,r,a,n,o,s,l,u){let h=this.length;return this.resize(h+1),this.emplace(h,e,t,i,r,a,n,o,s,l,u)}emplace(e,t,i,r,a,n,o,s,l,u,h){let c=e*10;return this.uint16[c+0]=t,this.uint16[c+1]=i,this.uint16[c+2]=r,this.uint16[c+3]=a,this.uint16[c+4]=n,this.uint16[c+5]=o,this.uint16[c+6]=s,this.uint16[c+7]=l,this.uint16[c+8]=u,this.uint16[c+9]=h,e}};ec.prototype.bytesPerElement=20,G("StructArrayLayout10ui20",ec);var tc=class extends Qe{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(e,t,i,r,a,n,o,s){let l=this.length;return this.resize(l+1),this.emplace(l,e,t,i,r,a,n,o,s)}emplace(e,t,i,r,a,n,o,s,l){let u=e*8;return this.uint16[u+0]=t,this.uint16[u+1]=i,this.uint16[u+2]=r,this.uint16[u+3]=a,this.uint16[u+4]=n,this.uint16[u+5]=o,this.uint16[u+6]=s,this.uint16[u+7]=l,e}};tc.prototype.bytesPerElement=16,G("StructArrayLayout8ui16",tc);var ic=class extends Qe{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(e,t,i,r,a,n,o,s,l,u,h,c,d){let p=this.length;return this.resize(p+1),this.emplace(p,e,t,i,r,a,n,o,s,l,u,h,c,d)}emplace(e,t,i,r,a,n,o,s,l,u,h,c,d,p){let f=e*14,m=e*7;return this.int16[f+0]=t,this.int16[f+1]=i,this.int16[f+2]=r,this.int16[f+3]=a,this.uint16[f+4]=n,this.uint16[f+5]=o,this.uint16[f+6]=s,this.uint16[f+7]=l,this.int16[f+8]=u,this.int16[f+9]=h,this.int16[f+10]=c,this.int16[f+11]=d,this.float32[m+6]=p,e}};ic.prototype.bytesPerElement=28,G("StructArrayLayout4i4ui4i1f28",ic);var rc=class extends Qe{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(e,t,i){let r=this.length;return this.resize(r+1),this.emplace(r,e,t,i)}emplace(e,t,i,r){let a=e*3;return this.float32[a+0]=t,this.float32[a+1]=i,this.float32[a+2]=r,e}};rc.prototype.bytesPerElement=12,G("StructArrayLayout3f12",rc);var ac=class extends Qe{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint32=new Uint32Array(this.arrayBuffer)}emplaceBack(e){let t=this.length;return this.resize(t+1),this.emplace(t,e)}emplace(e,t){let i=e*1;return this.uint32[i+0]=t,e}};ac.prototype.bytesPerElement=4,G("StructArrayLayout1ul4",ac);var nc=class extends Qe{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer),this.uint32=new Uint32Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(e,t,i,r,a,n,o,s,l){let u=this.length;return this.resize(u+1),this.emplace(u,e,t,i,r,a,n,o,s,l)}emplace(e,t,i,r,a,n,o,s,l,u){let h=e*10,c=e*5;return this.int16[h+0]=t,this.int16[h+1]=i,this.int16[h+2]=r,this.int16[h+3]=a,this.int16[h+4]=n,this.int16[h+5]=o,this.uint32[c+3]=s,this.uint16[h+8]=l,this.uint16[h+9]=u,e}};nc.prototype.bytesPerElement=20,G("StructArrayLayout6i1ul2ui20",nc);var oc=class extends Qe{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(e,t,i,r,a,n){let o=this.length;return this.resize(o+1),this.emplace(o,e,t,i,r,a,n)}emplace(e,t,i,r,a,n,o){let s=e*6;return this.int16[s+0]=t,this.int16[s+1]=i,this.int16[s+2]=r,this.int16[s+3]=a,this.int16[s+4]=n,this.int16[s+5]=o,e}};oc.prototype.bytesPerElement=12,G("StructArrayLayout2i2i2i12",oc);var sc=class extends Qe{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(e,t,i,r,a){let n=this.length;return this.resize(n+1),this.emplace(n,e,t,i,r,a)}emplace(e,t,i,r,a,n){let o=e*4,s=e*8;return this.float32[o+0]=t,this.float32[o+1]=i,this.float32[o+2]=r,this.int16[s+6]=a,this.int16[s+7]=n,e}};sc.prototype.bytesPerElement=16,G("StructArrayLayout2f1f2i16",sc);var lc=class extends Qe{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(e,t,i,r,a,n){let o=this.length;return this.resize(o+1),this.emplace(o,e,t,i,r,a,n)}emplace(e,t,i,r,a,n,o){let s=e*16,l=e*4,u=e*8;return this.uint8[s+0]=t,this.uint8[s+1]=i,this.float32[l+1]=r,this.float32[l+2]=a,this.int16[u+6]=n,this.int16[u+7]=o,e}};lc.prototype.bytesPerElement=16,G("StructArrayLayout2ub2f2i16",lc);var il=class extends Qe{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(e,t,i){let r=this.length;return this.resize(r+1),this.emplace(r,e,t,i)}emplace(e,t,i,r){let a=e*3;return this.uint16[a+0]=t,this.uint16[a+1]=i,this.uint16[a+2]=r,e}};il.prototype.bytesPerElement=6,G("StructArrayLayout3ui6",il);var uc=class extends Qe{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer),this.uint32=new Uint32Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(e,t,i,r,a,n,o,s,l,u,h,c,d,p,f,m,g,_){let y=this.length;return this.resize(y+1),this.emplace(y,e,t,i,r,a,n,o,s,l,u,h,c,d,p,f,m,g,_)}emplace(e,t,i,r,a,n,o,s,l,u,h,c,d,p,f,m,g,_,y){let v=e*26,x=e*13,b=e*52;return this.int16[v+0]=t,this.int16[v+1]=i,this.uint16[v+2]=r,this.uint16[v+3]=a,this.uint32[x+2]=n,this.uint32[x+3]=o,this.uint32[x+4]=s,this.uint16[v+10]=l,this.uint16[v+11]=u,this.uint16[v+12]=h,this.float32[x+7]=c,this.float32[x+8]=d,this.uint8[b+36]=p,this.uint8[b+37]=f,this.uint8[b+38]=m,this.uint32[x+10]=g,this.int16[v+22]=_,this.float32[x+12]=y,e}};uc.prototype.bytesPerElement=52,G("StructArrayLayout2i2ui3ul3ui2f3ub1ul1i1f52",uc);var hc=class extends Qe{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer),this.uint32=new Uint32Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(e,t,i,r,a,n,o,s,l,u,h,c,d,p,f,m,g,_,y,v,x,b,w,T,E,S,M,z,R){let I=this.length;return this.resize(I+1),this.emplace(I,e,t,i,r,a,n,o,s,l,u,h,c,d,p,f,m,g,_,y,v,x,b,w,T,E,S,M,z,R)}emplace(e,t,i,r,a,n,o,s,l,u,h,c,d,p,f,m,g,_,y,v,x,b,w,T,E,S,M,z,R,I){let D=e*34,P=e*17;return this.int16[D+0]=t,this.int16[D+1]=i,this.int16[D+2]=r,this.int16[D+3]=a,this.int16[D+4]=n,this.int16[D+5]=o,this.int16[D+6]=s,this.int16[D+7]=l,this.uint16[D+8]=u,this.uint16[D+9]=h,this.uint16[D+10]=c,this.uint16[D+11]=d,this.uint16[D+12]=p,this.uint16[D+13]=f,this.uint16[D+14]=m,this.uint16[D+15]=g,this.uint16[D+16]=_,this.uint16[D+17]=y,this.uint16[D+18]=v,this.uint16[D+19]=x,this.uint16[D+20]=b,this.uint16[D+21]=w,this.uint16[D+22]=T,this.uint32[P+12]=E,this.float32[P+13]=S,this.float32[P+14]=M,this.uint16[D+30]=z,this.uint16[D+31]=R,this.float32[P+16]=I,e}};hc.prototype.bytesPerElement=68,G("StructArrayLayout8i15ui1ul2f2ui1f68",hc);var rl=class extends Qe{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(e){let t=this.length;return this.resize(t+1),this.emplace(t,e)}emplace(e,t){let i=e*1;return this.float32[i+0]=t,e}};rl.prototype.bytesPerElement=4,G("StructArrayLayout1f4",rl);var cc=class extends Qe{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(e,t,i){let r=this.length;return this.resize(r+1),this.emplace(r,e,t,i)}emplace(e,t,i,r){let a=e*6,n=e*3;return this.uint16[a+0]=t,this.float32[n+1]=i,this.float32[n+2]=r,e}};cc.prototype.bytesPerElement=12,G("StructArrayLayout1ui2f12",cc);var dc=class extends Qe{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint32=new Uint32Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(e,t,i){let r=this.length;return this.resize(r+1),this.emplace(r,e,t,i)}emplace(e,t,i,r){let a=e*2,n=e*4;return this.uint32[a+0]=t,this.uint16[n+2]=i,this.uint16[n+3]=r,e}};dc.prototype.bytesPerElement=8,G("StructArrayLayout1ul2ui8",dc);var pc=class extends Qe{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(e,t){let i=this.length;return this.resize(i+1),this.emplace(i,e,t)}emplace(e,t,i){let r=e*2;return this.uint16[r+0]=t,this.uint16[r+1]=i,e}};pc.prototype.bytesPerElement=4,G("StructArrayLayout2ui4",pc);var fc=class extends Qe{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(e){let t=this.length;return this.resize(t+1),this.emplace(t,e)}emplace(e,t){let i=e*1;return this.uint16[i+0]=t,e}};fc.prototype.bytesPerElement=2,G("StructArrayLayout1ui2",fc);var mc=class extends Qe{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(e,t,i,r){let a=this.length;return this.resize(a+1),this.emplace(a,e,t,i,r)}emplace(e,t,i,r,a){let n=e*4;return this.float32[n+0]=t,this.float32[n+1]=i,this.float32[n+2]=r,this.float32[n+3]=a,e}};mc.prototype.bytesPerElement=16,G("StructArrayLayout4f16",mc);var D0=class extends Co{get anchorPointX(){return this._structArray.int16[this._pos2+0]}get anchorPointY(){return this._structArray.int16[this._pos2+1]}get x1(){return this._structArray.int16[this._pos2+2]}get y1(){return this._structArray.int16[this._pos2+3]}get x2(){return this._structArray.int16[this._pos2+4]}get y2(){return this._structArray.int16[this._pos2+5]}get featureIndex(){return this._structArray.uint32[this._pos4+3]}get sourceLayerIndex(){return this._structArray.uint16[this._pos2+8]}get bucketIndex(){return this._structArray.uint16[this._pos2+9]}get anchorPoint(){return new C(this.anchorPointX,this.anchorPointY)}};D0.prototype.size=20;var S0=class extends nc{get(e){return new D0(this,e)}};G("CollisionBoxArray",S0);var C0=class extends Co{get anchorX(){return this._structArray.int16[this._pos2+0]}get anchorY(){return this._structArray.int16[this._pos2+1]}get glyphStartIndex(){return this._structArray.uint16[this._pos2+2]}get numGlyphs(){return this._structArray.uint16[this._pos2+3]}get vertexStartIndex(){return this._structArray.uint32[this._pos4+2]}get lineStartIndex(){return this._structArray.uint32[this._pos4+3]}get lineLength(){return this._structArray.uint32[this._pos4+4]}get segment(){return this._structArray.uint16[this._pos2+10]}get lowerSize(){return this._structArray.uint16[this._pos2+11]}get upperSize(){return this._structArray.uint16[this._pos2+12]}get lineOffsetX(){return this._structArray.float32[this._pos4+7]}get lineOffsetY(){return this._structArray.float32[this._pos4+8]}get writingMode(){return this._structArray.uint8[this._pos1+36]}get placedOrientation(){return this._structArray.uint8[this._pos1+37]}set placedOrientation(e){this._structArray.uint8[this._pos1+37]=e}get hidden(){return this._structArray.uint8[this._pos1+38]}set hidden(e){this._structArray.uint8[this._pos1+38]=e}get crossTileID(){return this._structArray.uint32[this._pos4+10]}set crossTileID(e){this._structArray.uint32[this._pos4+10]=e}get associatedIconIndex(){return this._structArray.int16[this._pos2+22]}get heightOffset(){return this._structArray.float32[this._pos4+12]}};C0.prototype.size=52;var P0=class extends uc{get(e){return new C0(this,e)}};G("PlacedSymbolArray",P0);var A0=class extends Co{get anchorX(){return this._structArray.int16[this._pos2+0]}get anchorY(){return this._structArray.int16[this._pos2+1]}get rightJustifiedTextSymbolIndex(){return this._structArray.int16[this._pos2+2]}get centerJustifiedTextSymbolIndex(){return this._structArray.int16[this._pos2+3]}get leftJustifiedTextSymbolIndex(){return this._structArray.int16[this._pos2+4]}get verticalPlacedTextSymbolIndex(){return this._structArray.int16[this._pos2+5]}get placedIconSymbolIndex(){return this._structArray.int16[this._pos2+6]}get verticalPlacedIconSymbolIndex(){return this._structArray.int16[this._pos2+7]}get key(){return this._structArray.uint16[this._pos2+8]}get textBoxStartIndex(){return this._structArray.uint16[this._pos2+9]}get textBoxEndIndex(){return this._structArray.uint16[this._pos2+10]}get verticalTextBoxStartIndex(){return this._structArray.uint16[this._pos2+11]}get verticalTextBoxEndIndex(){return this._structArray.uint16[this._pos2+12]}get iconBoxStartIndex(){return this._structArray.uint16[this._pos2+13]}get iconBoxEndIndex(){return this._structArray.uint16[this._pos2+14]}get verticalIconBoxStartIndex(){return this._structArray.uint16[this._pos2+15]}get verticalIconBoxEndIndex(){return this._structArray.uint16[this._pos2+16]}get featureIndex(){return this._structArray.uint16[this._pos2+17]}get numHorizontalGlyphVertices(){return this._structArray.uint16[this._pos2+18]}get numVerticalGlyphVertices(){return this._structArray.uint16[this._pos2+19]}get numIconVertices(){return this._structArray.uint16[this._pos2+20]}get numVerticalIconVertices(){return this._structArray.uint16[this._pos2+21]}get useRuntimeCollisionCircles(){return this._structArray.uint16[this._pos2+22]}get crossTileID(){return this._structArray.uint32[this._pos4+12]}set crossTileID(e){this._structArray.uint32[this._pos4+12]=e}get textBoxScale(){return this._structArray.float32[this._pos4+13]}get collisionCircleDiameter(){return this._structArray.float32[this._pos4+14]}get textAnchorOffsetStartIndex(){return this._structArray.uint16[this._pos2+30]}get textAnchorOffsetEndIndex(){return this._structArray.uint16[this._pos2+31]}get heightOffset(){return this._structArray.float32[this._pos4+16]}};A0.prototype.size=68;var I0=class extends hc{get(e){return new A0(this,e)}};G("SymbolInstanceArray",I0);var M0=class extends rl{getoffsetX(e){return this.float32[e*1+0]}};G("GlyphOffsetArray",M0);var F0=class extends tl{getx(e){return this.int16[e*3+0]}gety(e){return this.int16[e*3+1]}gettileUnitDistanceFromAnchor(e){return this.int16[e*3+2]}};G("SymbolLineVertexArray",F0);var z0=class extends Co{get textAnchor(){return this._structArray.uint16[this._pos2+0]}get textOffset0(){return this._structArray.float32[this._pos4+1]}get textOffset1(){return this._structArray.float32[this._pos4+2]}};z0.prototype.size=12;var R0=class extends cc{get(e){return new z0(this,e)}};G("TextAnchorOffsetArray",R0);var k0=class extends Co{get featureIndex(){return this._structArray.uint32[this._pos4+0]}get sourceLayerIndex(){return this._structArray.uint16[this._pos2+2]}get bucketIndex(){return this._structArray.uint16[this._pos2+3]}};k0.prototype.size=8;var L0=class extends dc{get(e){return new k0(this,e)}};G("FeatureIndexArray",L0);var Gr=class extends so{},OT=class extends tl{},jT=class extends Kh{},VT=class extends so{},NT=class extends so{},UT=class extends Jh{},$T=class extends Qh{},GT=class extends lo{},va=class extends ec{},rm=class extends tc{},ZT=class extends ic{},qT=class extends rc{},WT=class extends ac{},am=class extends oc{},HT=class extends sc{},XT=class extends lc{},YT=class extends il{},Xi=class extends il{},gc=class extends pc{},KT=class extends fc{},_c=Je([{name:"a_pos",components:2,type:"Int16"}],4),JT=_c.members;_c.size,_c.alignment;var Ye=class Sa{constructor(t=[]){this._forceNewSegmentOnNextPrepare=!1,this.segments=t}prepareSegment(t,i,r,a){let n=this.segments[this.segments.length-1];return t>Sa.MAX_VERTEX_ARRAY_LENGTH&&_e(`Max vertices per segment is ${Sa.MAX_VERTEX_ARRAY_LENGTH}: bucket requested ${t}. Consider using the \`fillLargeMeshArrays\` function if you require meshes with more than ${Sa.MAX_VERTEX_ARRAY_LENGTH} vertices.`),this._forceNewSegmentOnNextPrepare||!n||n.vertexLength+t>Sa.MAX_VERTEX_ARRAY_LENGTH||n.sortKey!==a?this.createNewSegment(i,r,a):n}createNewSegment(t,i,r){let a={vertexOffset:t.length,primitiveOffset:i.length,vertexLength:0,primitiveLength:0,vaos:{}};return r!==void 0&&(a.sortKey=r),this._forceNewSegmentOnNextPrepare=!1,this.segments.push(a),a}getOrCreateLatestSegment(t,i,r){return this.prepareSegment(0,t,i,r)}forceNewSegmentOnNextPrepare(){this._forceNewSegmentOnNextPrepare=!0}get(){return this.segments}destroy(){for(let t of this.segments)for(let i in t.vaos)t.vaos[i].destroy()}static simpleSegment(t,i,r,a){return new Sa([{vertexOffset:t,primitiveOffset:i,vertexLength:r,primitiveLength:a,vaos:{},sortKey:0}])}};Ye.MAX_VERTEX_ARRAY_LENGTH=2**16-1,G("SegmentVector",Ye);function nm(e,t){return e=ie(Math.floor(e),0,255),t=ie(Math.floor(t),0,255),256*e+t}var QT=Je([{name:"a_pattern_from",components:4,type:"Uint16"},{name:"a_pattern_to",components:4,type:"Uint16"},{name:"a_pixel_ratio_from",components:1,type:"Uint16"},{name:"a_pixel_ratio_to",components:1,type:"Uint16"}]),eE=Je([{name:"a_dasharray_from",components:4,type:"Uint16"},{name:"a_dasharray_to",components:4,type:"Uint16"}]),tE=pd(((e,t)=>{function i(r,a){for(var n=r.length&3,o=r.length-n,s=a,l,u=3432918353,h=461845907,c,d=0;d<o;)c=r.charCodeAt(d)&255|(r.charCodeAt(++d)&255)<<8|(r.charCodeAt(++d)&255)<<16|(r.charCodeAt(++d)&255)<<24,++d,c=(c&65535)*u+(((c>>>16)*u&65535)<<16)&4294967295,c=c<<15|c>>>17,c=(c&65535)*h+(((c>>>16)*h&65535)<<16)&4294967295,s^=c,s=s<<13|s>>>19,l=(s&65535)*5+(((s>>>16)*5&65535)<<16)&4294967295,s=(l&65535)+27492+(((l>>>16)+58964&65535)<<16);switch(c=0,n){case 3:c^=(r.charCodeAt(d+2)&255)<<16;case 2:c^=(r.charCodeAt(d+1)&255)<<8;case 1:c^=r.charCodeAt(d)&255,c=(c&65535)*u+(((c>>>16)*u&65535)<<16)&4294967295,c=c<<15|c>>>17,c=(c&65535)*h+(((c>>>16)*h&65535)<<16)&4294967295,s^=c}return s^=r.length,s^=s>>>16,s=(s&65535)*2246822507+(((s>>>16)*2246822507&65535)<<16)&4294967295,s^=s>>>13,s=(s&65535)*3266489909+(((s>>>16)*3266489909&65535)<<16)&4294967295,s^=s>>>16,s>>>0}t!==void 0&&(t.exports=i)})),iE=pd(((e,t)=>{function i(r,a){for(var n=r.length,o=a^n,s=0,l;n>=4;)l=r.charCodeAt(s)&255|(r.charCodeAt(++s)&255)<<8|(r.charCodeAt(++s)&255)<<16|(r.charCodeAt(++s)&255)<<24,l=(l&65535)*1540483477+(((l>>>16)*1540483477&65535)<<16),l^=l>>>24,l=(l&65535)*1540483477+(((l>>>16)*1540483477&65535)<<16),o=(o&65535)*1540483477+(((o>>>16)*1540483477&65535)<<16)^l,n-=4,++s;switch(n){case 3:o^=(r.charCodeAt(s+2)&255)<<16;case 2:o^=(r.charCodeAt(s+1)&255)<<8;case 1:o^=r.charCodeAt(s)&255,o=(o&65535)*1540483477+(((o>>>16)*1540483477&65535)<<16)}return o^=o>>>13,o=(o&65535)*1540483477+(((o>>>16)*1540483477&65535)<<16),o^=o>>>15,o>>>0}t.exports=i})),al=fb(pd(((e,t)=>{var i=tE(),r=iE();t.exports=i,t.exports.murmur3=i,t.exports.murmur2=r}))(),1),B0=class O0{constructor(){this.ids=[],this.positions=[],this.indexed=!1}add(t,i,r,a){this.ids.push(om(t)),this.positions.push(i,r,a)}getPositions(t){if(!this.indexed)throw Error("Trying to get index, but feature positions are not indexed");let i=om(t),r=0,a=this.ids.length-1;for(;r<a;){let o=r+a>>1;this.ids[o]>=i?a=o:r=o+1}let n=[];for(;this.ids[r]===i;){let o=this.positions[3*r],s=this.positions[3*r+1],l=this.positions[3*r+2];n.push({index:o,start:s,end:l}),r++}return n}static serialize(t,i){let r=new Float64Array(t.ids),a=new Uint32Array(t.positions);return yc(r,a,0,r.length-1),i&&i.push(r.buffer,a.buffer),{ids:r,positions:a}}static deserialize(t){let i=new O0;return i.ids=t.ids,i.positions=t.positions,i.indexed=!0,i}};function om(e){let t=+e;return!isNaN(t)&&t<=2**53-1?t:(0,al.default)(String(e))}function yc(e,t,i,r){for(;i<r;){let a=e[i+r>>1],n=i-1,o=r+1;for(;;){do n++;while(e[n]<a);do o--;while(e[o]>a);if(n>=o)break;ls(e,n,o),ls(t,3*n,3*o),ls(t,3*n+1,3*o+1),ls(t,3*n+2,3*o+2)}o-i<r-o?(yc(e,t,i,o),i=o+1):(yc(e,t,o+1,r),r=o)}}function ls(e,t,i){let r=e[t];e[t]=e[i],e[i]=r}G("FeaturePositionMap",B0);var dr=class{constructor(e,t){this.gl=e.gl,this.location=t}},K=class extends dr{constructor(e,t){super(e,t),this.current=0}set(e){this.current!==e&&(this.current=e,this.gl.uniform1i(this.location,e))}},$=class extends dr{constructor(e,t){super(e,t),this.current=0}set(e){this.current!==e&&(this.current=e,this.gl.uniform1f(this.location,e))}},de=class extends dr{constructor(e,t){super(e,t),this.current=[0,0]}set(e){(e[0]!==this.current[0]||e[1]!==this.current[1])&&(this.current=e,this.gl.uniform2f(this.location,e[0],e[1]))}},Nt=class extends dr{constructor(e,t){super(e,t),this.current=[0,0,0]}set(e){(e[0]!==this.current[0]||e[1]!==this.current[1]||e[2]!==this.current[2])&&(this.current=e,this.gl.uniform3f(this.location,e[0],e[1],e[2]))}},Ya=class extends dr{constructor(e,t){super(e,t),this.current=[0,0,0,0]}set(e){(e[0]!==this.current[0]||e[1]!==this.current[1]||e[2]!==this.current[2]||e[3]!==this.current[3])&&(this.current=e,this.gl.uniform4f(this.location,e[0],e[1],e[2],e[3]))}},Ar=class extends dr{constructor(e,t){super(e,t),this.current=oe.transparent}set(e){(e.r!==this.current.r||e.g!==this.current.g||e.b!==this.current.b||e.a!==this.current.a)&&(this.current=e,this.gl.uniform4f(this.location,e.r,e.g,e.b,e.a))}},sm=class extends dr{constructor(e,t){super(e,t),this.current=[]}set(e){if(e!=this.current){this.current=e;let t=new Float32Array(e.length*4);for(let i=0;i<e.length;i++)t[4*i]=e[i].r,t[4*i+1]=e[i].g,t[4*i+2]=e[i].b,t[4*i+3]=e[i].a;this.gl.uniform4fv(this.location,t)}}},lm=class extends dr{constructor(e,t){super(e,t),this.current=[]}set(e){if(e!=this.current){this.current=e;let t=new Float32Array(e);this.gl.uniform1fv(this.location,t)}}},rE=new Float32Array(16),Fi=class extends dr{constructor(e,t){super(e,t),this.current=rE}set(e){if(e[12]!==this.current[12]||e[0]!==this.current[0]){this.current=e,this.gl.uniformMatrix4fv(this.location,!1,e);return}for(let t=1;t<16;t++)if(e[t]!==this.current[t]){this.current=e,this.gl.uniformMatrix4fv(this.location,!1,e);break}}};function vc(e){return[nm(255*e.r,255*e.g),nm(255*e.b,255*e.a)]}var kn=class{constructor(e,t,i){this.value=e,this.uniformNames=t.map(r=>`u_${r}`),this.type=i}setUniform(e,t,i){e.set(i.constantOr(this.value))}getBinding(e,t,i){return this.type==="color"?new Ar(e,t):new $(e,t)}},Or=class{constructor(e,t){this.uniformNames=t.map(i=>`u_${i}`),this.patternFrom=null,this.patternTo=null,this.pixelRatioFrom=1,this.pixelRatioTo=1}setConstantPatternPositions(e,t){this.pixelRatioFrom=t.pixelRatio,this.pixelRatioTo=e.pixelRatio,this.patternFrom=t.tlbr,this.patternTo=e.tlbr}setConstantDashPositions(e,t){this.dashTo=[0,e.y,e.height,e.width],this.dashFrom=[0,t.y,t.height,t.width]}setUniform(e,t,i,r){let a=null;r==="u_pattern_to"?a=this.patternTo:r==="u_pattern_from"?a=this.patternFrom:r==="u_dasharray_to"?a=this.dashTo:r==="u_dasharray_from"?a=this.dashFrom:r==="u_pixel_ratio_to"?a=this.pixelRatioTo:r==="u_pixel_ratio_from"&&(a=this.pixelRatioFrom),a!==null&&e.set(a)}getBinding(e,t,i){return i.startsWith("u_pattern")||i.startsWith("u_dasharray_")?new Ya(e,t):new $(e,t)}},Qi=class{constructor(e,t,i,r){this.expression=e,this.type=i,this.maxValue=0,this.paintVertexAttributes=t.map(a=>({name:`a_${a}`,type:"Float32",components:i==="color"?2:1,offset:0})),this.paintVertexArray=new r}populatePaintArray(e,t,i){let r=this.paintVertexArray.length,a=this.expression.evaluate(new Ae(0,i),t,{},i.canonical,[],i.formattedSection);this.paintVertexArray.resize(e),this._setPaintValue(r,e,a)}updatePaintArray(e,t,i,r,a){let n=this.expression.evaluate(new Ae(0,a),i,r);this._setPaintValue(e,t,n)}_setPaintValue(e,t,i){if(this.type==="color"){let r=vc(i);for(let a=e;a<t;a++)this.paintVertexArray.emplace(a,r[0],r[1])}else{for(let r=e;r<t;r++)this.paintVertexArray.emplace(r,i);this.maxValue=Math.max(this.maxValue,Math.abs(i))}}upload(e){this.paintVertexArray?.arrayBuffer.byteLength&&(this.paintVertexBuffer?.buffer?this.paintVertexBuffer.updateData(this.paintVertexArray):this.paintVertexBuffer=e.createVertexBuffer(this.paintVertexArray,this.paintVertexAttributes,this.expression.isStateDependent))}destroy(){this.paintVertexBuffer&&this.paintVertexBuffer.destroy()}},Di=class{constructor(e,t,i,r,a,n){this.expression=e,this.uniformNames=t.map(o=>`u_${o}_t`),this.type=i,this.useIntegerZoom=r,this.zoom=a,this.maxValue=0,this.paintVertexAttributes=t.map(o=>({name:`a_${o}`,type:"Float32",components:i==="color"?4:2,offset:0})),this.paintVertexArray=new n}populatePaintArray(e,t,i){let r=this.expression.evaluate(new Ae(this.zoom,i),t,{},i.canonical,[],i.formattedSection),a=this.expression.evaluate(new Ae(this.zoom+1,i),t,{},i.canonical,[],i.formattedSection),n=this.paintVertexArray.length;this.paintVertexArray.resize(e),this._setPaintValue(n,e,r,a)}updatePaintArray(e,t,i,r,a){let n=this.expression.evaluate(new Ae(this.zoom,a),i,r),o=this.expression.evaluate(new Ae(this.zoom+1,a),i,r);this._setPaintValue(e,t,n,o)}_setPaintValue(e,t,i,r){if(this.type==="color"){let a=vc(i),n=vc(r);for(let o=e;o<t;o++)this.paintVertexArray.emplace(o,a[0],a[1],n[0],n[1])}else{for(let a=e;a<t;a++)this.paintVertexArray.emplace(a,i,r);this.maxValue=Math.max(this.maxValue,Math.abs(i),Math.abs(r))}}upload(e){this.paintVertexArray?.arrayBuffer.byteLength&&(this.paintVertexBuffer?.buffer?this.paintVertexBuffer.updateData(this.paintVertexArray):this.paintVertexBuffer=e.createVertexBuffer(this.paintVertexArray,this.paintVertexAttributes,this.expression.isStateDependent))}destroy(){this.paintVertexBuffer&&this.paintVertexBuffer.destroy()}setUniform(e,t){let i=this.useIntegerZoom?Math.floor(t.zoom):t.zoom,r=ie(this.expression.interpolationFactor(i,this.zoom,this.zoom+1),0,1);e.set(r)}getBinding(e,t,i){return new $(e,t)}},yr=class{constructor(e,t,i,r,a,n){this.expression=e,this.type=t,this.useIntegerZoom=i,this.zoom=r,this.layerId=n,this.zoomInPaintVertexArray=new a,this.zoomOutPaintVertexArray=new a}populatePaintArray(e,t,i){let r=this.zoomInPaintVertexArray.length;this.zoomInPaintVertexArray.resize(e),this.zoomOutPaintVertexArray.resize(e),this._setPaintValues(r,e,this.getPositionIds(t),i)}updatePaintArray(e,t,i,r,a){this._setPaintValues(e,t,this.getPositionIds(i),a)}_setPaintValues(e,t,i,r){let a=this.getPositions(r);if(!a||!i)return;let n=a[i.min],o=a[i.mid],s=a[i.max];if(n&&o&&s)for(let l=e;l<t;l++)this.emplace(this.zoomInPaintVertexArray,l,n,o),this.emplace(this.zoomOutPaintVertexArray,l,s,o)}upload(e){if(this.zoomInPaintVertexArray?.arrayBuffer.byteLength&&this.zoomOutPaintVertexArray?.arrayBuffer.byteLength){let t=this.getVertexAttributes();this.zoomInPaintVertexBuffer=e.createVertexBuffer(this.zoomInPaintVertexArray,t,this.expression.isStateDependent),this.zoomOutPaintVertexBuffer=e.createVertexBuffer(this.zoomOutPaintVertexArray,t,this.expression.isStateDependent)}}destroy(){this.zoomOutPaintVertexBuffer&&this.zoomOutPaintVertexBuffer.destroy(),this.zoomInPaintVertexBuffer&&this.zoomInPaintVertexBuffer.destroy()}},j0=class extends yr{getPositions(e){return e.imagePositions}getPositionIds(e){return e.patterns?.[this.layerId]}getVertexAttributes(){return QT.members}emplace(e,t,i,r){e.emplace(t,i.tlbr[0],i.tlbr[1],i.tlbr[2],i.tlbr[3],r.tlbr[0],r.tlbr[1],r.tlbr[2],r.tlbr[3],i.pixelRatio,r.pixelRatio)}},V0=class extends yr{getPositions(e){return e.dashPositions}getPositionIds(e){return e.dashes?.[this.layerId]}getVertexAttributes(){return eE.members}emplace(e,t,i,r){e.emplace(t,0,i.y,i.height,i.width,0,r.y,r.height,r.width)}},N0=class{constructor(e,t,i){this.binders={},this._buffers=[];let r=[];for(let a in e.paint._values){if(!i(a))continue;let n=e.paint.get(a);if(!(n instanceof xi)||!Wa(n.property.specification))continue;let o=aE(a,e.type),s=n.value,l=n.property.specification.type,u=n.property.useIntegerZoom,h=n.property.specification["property-type"],c=h==="cross-faded"||h==="cross-faded-data-driven";if(s.kind==="constant")this.binders[a]=c?new Or(s.value,o):new kn(s.value,o,l),r.push(`/u_${a}`);else if(s.kind==="source"||c){let d=um(a,l,"source");this.binders[a]=c?a==="line-dasharray"?new V0(s,l,u,t,d,e.id):new j0(s,l,u,t,d,e.id):new Qi(s,o,l,d),r.push(`/a_${a}`)}else{let d=um(a,l,"composite");this.binders[a]=new Di(s,o,l,u,t,d),r.push(`/z_${a}`)}}this.cacheKey=r.sort().join("")}getMaxValue(e){let t=this.binders[e];return t instanceof Qi||t instanceof Di?t.maxValue:0}populatePaintArrays(e,t,i){for(let r in this.binders){let a=this.binders[r];(a instanceof Qi||a instanceof Di||a instanceof yr)&&a.populatePaintArray(e,t,i)}}setConstantPatternPositions(e,t){for(let i in this.binders){let r=this.binders[i];r instanceof Or&&r.setConstantPatternPositions(e,t)}}setConstantDashPositions(e,t){for(let i in this.binders){let r=this.binders[i];r instanceof Or&&r.setConstantDashPositions(e,t)}}updatePaintArrays(e,t,i,r,a){let n=!1;for(let o of e){let s=t.getPositions(o.id);for(let l of s){let u=i.feature(l.index);for(let h in this.binders){let c=this.binders[h];(c instanceof Qi||c instanceof Di||c instanceof yr)&&c.expression.isStateDependent===!0&&(c.expression=r.paint.get(h).value,c.updatePaintArray(l.start,l.end,u,o.state,a),n=!0)}}}return n}defines(){let e=[];for(let t in this.binders){let i=this.binders[t];(i instanceof kn||i instanceof Or)&&e.push(...i.uniformNames.map(r=>`#define HAS_UNIFORM_${r}`))}return e}getBinderAttributes(){let e=[];for(let t in this.binders){let i=this.binders[t];if(i instanceof Qi||i instanceof Di)for(let r of i.paintVertexAttributes)e.push(r.name);else if(i instanceof yr){let r=i.getVertexAttributes();for(let a of r)e.push(a.name)}}return e}getBinderUniforms(){let e=[];for(let t in this.binders){let i=this.binders[t];if(i instanceof kn||i instanceof Or||i instanceof Di)for(let r of i.uniformNames)e.push(r)}return e}getPaintVertexBuffers(){return this._buffers}getUniforms(e,t){let i=[];for(let r in this.binders){let a=this.binders[r];if(a instanceof kn||a instanceof Or||a instanceof Di){for(let n of a.uniformNames)if(t[n]){let o=a.getBinding(e,t[n],n);i.push({name:n,property:r,binding:o})}}}return i}setUniforms(e,t,i,r){for(let{name:a,property:n,binding:o}of t)this.binders[n].setUniform(o,r,i.get(n),a)}updatePaintBuffers(e){this._buffers=[];for(let t in this.binders){let i=this.binders[t];if(e&&i instanceof yr){let r=e.fromScale===2?i.zoomInPaintVertexBuffer:i.zoomOutPaintVertexBuffer;r&&this._buffers.push(r)}else(i instanceof Qi||i instanceof Di)&&i.paintVertexBuffer&&this._buffers.push(i.paintVertexBuffer)}}upload(e){for(let t in this.binders){let i=this.binders[t];(i instanceof Qi||i instanceof Di||i instanceof yr)&&i.upload(e)}this.updatePaintBuffers()}destroy(){for(let e in this.binders){let t=this.binders[e];(t instanceof Qi||t instanceof Di||t instanceof yr)&&t.destroy()}}},ea=class{constructor(e,t,i=()=>!0){this.programConfigurations={};for(let r of e)this.programConfigurations[r.id]=new N0(r,t,i);this.needsUpload=!1,this._featureMap=new B0,this._bufferOffset=0}populatePaintArrays(e,t,i,r){for(let a in this.programConfigurations)this.programConfigurations[a].populatePaintArrays(e,t,r);t.id!==void 0&&this._featureMap.add(t.id,i,this._bufferOffset,e),this._bufferOffset=e,this.needsUpload=!0}updatePaintArrays(e,t,i,r){for(let a of i)this.needsUpload=this.programConfigurations[a.id].updatePaintArrays(e,this._featureMap,t,a,r)||this.needsUpload}get(e){return this.programConfigurations[e]}upload(e){if(this.needsUpload){for(let t in this.programConfigurations)this.programConfigurations[t].upload(e);this.needsUpload=!1}}destroy(){for(let e in this.programConfigurations)this.programConfigurations[e].destroy()}};function aE(e,t){return{"text-opacity":["opacity"],"icon-opacity":["opacity"],"text-color":["fill_color"],"icon-color":["fill_color"],"text-halo-color":["halo_color"],"icon-halo-color":["halo_color"],"text-halo-blur":["halo_blur"],"icon-halo-blur":["halo_blur"],"text-halo-width":["halo_width"],"icon-halo-width":["halo_width"],"line-gap-width":["gapwidth"],"line-dasharray":["dasharray_to","dasharray_from"],"line-pattern":["pattern_to","pattern_from","pixel_ratio_to","pixel_ratio_from"],"fill-pattern":["pattern_to","pattern_from","pixel_ratio_to","pixel_ratio_from"],"fill-extrusion-pattern":["pattern_to","pattern_from","pixel_ratio_to","pixel_ratio_from"]}[e]||[e.replace(`${t}-`,"").replace(/-/g,"_")]}function nE(e){return{"line-pattern":{source:va,composite:va},"fill-pattern":{source:va,composite:va},"fill-extrusion-pattern":{source:va,composite:va},"line-dasharray":{source:rm,composite:rm}}[e]}function um(e,t,i){let r={color:{source:lo,composite:mc},number:{source:rl,composite:lo}};return nE(e)?.[i]||r[t][i]}G("ConstantBinder",kn),G("CrossFadedConstantBinder",Or),G("SourceExpressionBinder",Qi),G("CrossFadedPatternBinder",j0),G("CrossFadedDasharrayBinder",V0),G("CompositeExpressionBinder",Di),G("ProgramConfiguration",N0,{omit:["_buffers"]}),G("ProgramConfigurationSet",ea);var xc=2**14-1,hm=-xc-1;function sa(e){let t=k/e.extent,i=e.loadGeometry();for(let r of i)for(let a of r){let n=Math.round(a.x*t),o=Math.round(a.y*t);a.x=ie(n,hm,xc),a.y=ie(o,hm,xc),(n<a.x||n>a.x+1||o<a.y||o>a.y+1)&&_e("Geometry exceeds allowed extent, reduce your vector tile buffer size")}return i}function la(e,t){return{type:e.type,id:e.id,properties:e.properties,geometry:t?sa(e):[]}}var cm=-32768;function oE(e,t,i,r,a){e.emplaceBack(cm+t*8+r,cm+i*8+a)}var Ud=class{constructor(e){this.zoom=e.zoom,this.overscaling=e.overscaling,this.layers=e.layers,this.layerIds=this.layers.map(t=>t.id),this.index=e.index,this.hasDependencies=!1,this.layoutVertexArray=new VT,this.indexArray=new Xi,this.segments=new Ye,this.programConfigurations=new ea(e.layers,e.zoom),this.stateDependentLayerIds=this.layers.filter(t=>t.isStateDependent()).map(t=>t.id)}populate(e,t,i){let r=this.layers[0],a=[],n=null,o=!1,s=r.type==="heatmap";if(r.type==="circle"){let c=r;n=c.layout.get("circle-sort-key"),o=!n.isConstant(),s||(s=c.paint.get("circle-pitch-alignment")==="map")}let l=s?t.subdivisionGranularity.circle:1,u=new Ae(this.zoom),h=this.layers[0]._featureFilter.needGeometry;for(let{feature:c,id:d,index:p,sourceLayerIndex:f}of e){let m=la(c,h);if(!this.layers[0]._featureFilter.filter(u,m,i))continue;let g=o?n.evaluate(m,{},i):void 0,_={id:d,properties:c.properties,type:c.type,sourceLayerIndex:f,index:p,geometry:h?m.geometry:sa(c),patterns:{},sortKey:g};a.push(_)}o&&a.sort((c,d)=>c.sortKey-d.sortKey);for(let c of a){let{geometry:d,index:p,sourceLayerIndex:f}=c,m=e[p].feature;this.addFeature(c,d,p,i,l),t.featureIndex.insert(m,d,p,f,this.index)}}update(e,t,i){this.stateDependentLayers.length&&this.programConfigurations.updatePaintArrays(e,t,this.stateDependentLayers,{imagePositions:i})}addFeatures(e){}isEmpty(){return this.layoutVertexArray.length===0}uploadPending(){return!this.uploaded||this.programConfigurations.needsUpload}upload(e){this.uploaded||(this.layoutVertexBuffer=e.createVertexBuffer(this.layoutVertexArray,JT),this.indexBuffer=e.createIndexBuffer(this.indexArray)),this.programConfigurations.upload(e),this.uploaded=!0}destroy(){this.layoutVertexBuffer&&(this.layoutVertexBuffer.destroy(),this.indexBuffer.destroy(),this.programConfigurations.destroy(),this.segments.destroy())}addFeature(e,t,i,r,a=1){let n;switch(a){case 1:n=[0,7];break;case 3:n=[0,2,5,7];break;case 5:n=[0,1,3,4,6,7];break;case 7:n=[0,1,2,3,4,5,6,7];break;default:throw Error(`Invalid circle bucket granularity: ${a}; valid values are 1, 3, 5, 7.`)}let o=n.length;for(let s of t)for(let l of s){let u=l.x,h=l.y;if(u<0||u>=8192||h<0||h>=8192)continue;let c=this.segments.prepareSegment(o*o,this.layoutVertexArray,this.indexArray,e.sortKey),d=c.vertexLength;for(let p=0;p<o;p++)for(let f=0;f<o;f++)oE(this.layoutVertexArray,u,h,n[f],n[p]);for(let p=0;p<o-1;p++)for(let f=0;f<o-1;f++){let m=d+p*o+f,g=d+(p+1)*o+f;this.indexArray.emplaceBack(m,g+1,m+1),this.indexArray.emplaceBack(m,g,g+1)}c.vertexLength+=o*o,c.primitiveLength+=(o-1)*(o-1)*2}this.programConfigurations.populatePaintArrays(this.layoutVertexArray.length,e,i,{imagePositions:{},canonical:r})}};G("CircleBucket",Ud,{omit:["layers"]});function U0(e,t){for(let i of e)if(Ka(t,i))return!0;for(let i of t)if(Ka(e,i))return!0;return $d(e,t)}function Gl(e,t,i){return Ka(e,t)?!0:bc(t,e,i)}function $0(e,t){if(e.length===1)return dm(t,e[0]);for(let i of t)for(let r of i)if(Ka(e,r))return!0;for(let i of e)if(dm(t,i))return!0;for(let i of t)if($d(e,i))return!0;return!1}function sE(e,t,i){for(let r of t){if(e.length>=3){for(let a of r)if(Ka(e,a))return!0}if(lE(e,r,i))return!0}return!1}function lE(e,t,i){if(e.length>1){if($d(e,t))return!0;for(let r of t)if(bc(r,e,i))return!0}for(let r of e)if(bc(r,t,i))return!0;return!1}function $d(e,t){if(e.length===0||t.length===0)return!1;for(let i=0;i<e.length-1;i++){let r=e[i],a=e[i+1];for(let n=0;n<t.length-1;n++){let o=t[n],s=t[n+1];if(uE(r,a,o,s))return!0}}return!1}function uE(e,t,i,r){return wr(e,i,r)!==wr(t,i,r)&&wr(e,t,i)!==wr(e,t,r)}function bc(e,t,i){let r=i*i;if(t.length===1)return e.distSqr(t[0])<r;for(let a=1;a<t.length;a++){let n=t[a-1],o=t[a];if(G0(e,n,o)<r)return!0}return!1}function G0(e,t,i){let r=t.distSqr(i);if(r===0)return e.distSqr(t);let a=((e.x-t.x)*(i.x-t.x)+(e.y-t.y)*(i.y-t.y))/r;return a<0?e.distSqr(t):a>1?e.distSqr(i):e.distSqr(i.sub(t)._mult(a)._add(t))}function dm(e,t){let i=!1,r,a,n;for(let o of e){r=o;for(let s=0,l=r.length-1;s<r.length;l=s++)a=r[s],n=r[l],a.y>t.y!=n.y>t.y&&t.x<(n.x-a.x)*(t.y-a.y)/(n.y-a.y)+a.x&&(i=!i)}return i}function Ka(e,t){let i=!1;for(let r=0,a=e.length-1;r<e.length;a=r++){let n=e[r],o=e[a];n.y>t.y!=o.y>t.y&&t.x<(o.x-n.x)*(t.y-n.y)/(o.y-n.y)+n.x&&(i=!i)}return i}function hE(e,t,i,r,a){for(let o of e)if(t<=o.x&&i<=o.y&&r>=o.x&&a>=o.y)return!0;let n=[new C(t,i),new C(t,a),new C(r,a),new C(r,i)];if(e.length>2){for(let o of n)if(Ka(e,o))return!0}for(let o=0;o<e.length-1;o++){let s=e[o],l=e[o+1];if(cE(s,l,n))return!0}return!1}function cE(e,t,i){let r=i[0],a=i[2];if(e.x<r.x&&t.x<r.x||e.x>a.x&&t.x>a.x||e.y<r.y&&t.y<r.y||e.y>a.y&&t.y>a.y)return!1;let n=wr(e,t,i[0]);return n!==wr(e,t,i[1])||n!==wr(e,t,i[2])||n!==wr(e,t,i[3])}function ka(e,t,i){let r=t.paint.get(e).value;return r.kind==="constant"?r.value:i.programConfigurations.get(t.id).getMaxValue(e)}function Zl(e){return Math.sqrt(e[0]*e[0]+e[1]*e[1])}function ql(e,t,i,r,a){if(!t[0]&&!t[1])return e;let n=C.convert(t)._mult(a);i==="viewport"&&n._rotate(-r);let o=[];for(let s of e)o.push(s.sub(n));return o}function dE(e){let t=[];for(let i=0;i<e.length;i++){let r=e[i],a=t.at(-1);(i===0||a&&!r.equals(a))&&t.push(r)}return t}function pE(e,t){let i=[];for(let r of e){let a=dE(r),n=[];for(let o=0;o<a.length;o++){let s=a[o],l=a[o-1],u=a[o+1],h=o===0?new C(0,0):s.sub(l)._unit()._perp(),c=o===a.length-1?new C(0,0):u.sub(s)._unit()._perp(),d=h._add(c)._unit(),p=d.x*c.x+d.y*c.y;p!==0&&d._mult(1/p),n.push(d._mult(t)._add(s))}i.push(n)}return i}function fE({queryGeometry:e,size:t},i){return Gl(e,i,t)}function mE({queryGeometry:e,size:t,transform:i,unwrappedTileID:r,getElevation:a},n){return Gl(e,n,t*(i.projectTileCoordinates(n.x,n.y,r,a?.(n.x,n.y)).signedDistanceFromCamera/i.cameraToCenterDistance))}function gE({queryGeometry:e,size:t,transform:i,unwrappedTileID:r,getElevation:a},n){let o=i.projectTileCoordinates(n.x,n.y,r,a?.(n.x,n.y)).signedDistanceFromCamera,s=t*(i.cameraToCenterDistance/o);return Gl(e,Gd(n,i,r,a),s)}function _E({queryGeometry:e,size:t,transform:i,unwrappedTileID:r,getElevation:a},n){return Gl(e,Gd(n,i,r,a),t)}function Z0({queryGeometry:e,size:t,transform:i,unwrappedTileID:r,getElevation:a,pitchAlignment:n="map",pitchScale:o="map"},s){let l=n==="map"?o==="map"?fE:mE:o==="map"?gE:_E,u={queryGeometry:e,size:t,transform:i,unwrappedTileID:r,getElevation:a};for(let h of s)for(let c of h)if(l(u,c))return!0;return!1}function Gd(e,t,i,r){let a=t.projectTileCoordinates(e.x,e.y,i,r?.(e.x,e.y)).point;return new C((a.x*.5+.5)*t.width,(-a.y*.5+.5)*t.height)}function yE(e,t,i,r){return e.map(a=>Gd(a,t,i,r))}var pm,vE=()=>pm||(pm=new wt({"circle-sort-key":new ee(F.layout_circle["circle-sort-key"],"circle-sort-key")})),fm,xE=()=>fm||(fm=new wt({"circle-radius":new ee(F.paint_circle["circle-radius"],"circle-radius"),"circle-color":new ee(F.paint_circle["circle-color"],"circle-color"),"circle-blur":new ee(F.paint_circle["circle-blur"],"circle-blur"),"circle-opacity":new ee(F.paint_circle["circle-opacity"],"circle-opacity"),"circle-translate":new U(F.paint_circle["circle-translate"],"circle-translate"),"circle-translate-anchor":new U(F.paint_circle["circle-translate-anchor"],"circle-translate-anchor"),"circle-pitch-scale":new U(F.paint_circle["circle-pitch-scale"],"circle-pitch-scale"),"circle-pitch-alignment":new U(F.paint_circle["circle-pitch-alignment"],"circle-pitch-alignment"),"circle-stroke-width":new ee(F.paint_circle["circle-stroke-width"],"circle-stroke-width"),"circle-stroke-color":new ee(F.paint_circle["circle-stroke-color"],"circle-stroke-color"),"circle-stroke-opacity":new ee(F.paint_circle["circle-stroke-opacity"],"circle-stroke-opacity")})),bE={get paint(){return xE()},get layout(){return vE()}},wE=e=>e.type==="circle",TE=class extends ki{constructor(e,t){super(e,bE,t)}createBucket(e){return new Ud(e)}queryRadius(e){let t=e;return ka("circle-radius",this,t)+ka("circle-stroke-width",this,t)+Zl(this.paint.get("circle-translate"))}queryIntersectsFeature({queryGeometry:e,feature:t,featureState:i,geometry:r,transform:a,pixelsToTileUnits:n,unwrappedTileID:o,getElevation:s}){let l=ql(e,this.paint.get("circle-translate"),this.paint.get("circle-translate-anchor"),-a.bearingInRadians,n),u=this.paint.get("circle-radius").evaluate(t,i)+this.paint.get("circle-stroke-width").evaluate(t,i),h=this.paint.get("circle-pitch-scale"),c=this.paint.get("circle-pitch-alignment"),d,p;return c==="map"?(d=l,p=u*n):(d=yE(l,a,o,s),p=u),Z0({queryGeometry:d,size:p,transform:a,unwrappedTileID:o,getElevation:s,pitchAlignment:c,pitchScale:h},r)}},q0=class extends Ud{};G("HeatmapBucket",q0,{omit:["layers"]});var mm,EE=()=>mm||(mm=new wt({"heatmap-radius":new ee(F.paint_heatmap["heatmap-radius"],"heatmap-radius"),"heatmap-weight":new ee(F.paint_heatmap["heatmap-weight"],"heatmap-weight"),"heatmap-intensity":new U(F.paint_heatmap["heatmap-intensity"],"heatmap-intensity"),"heatmap-color":new $l(F.paint_heatmap["heatmap-color"],"heatmap-color"),"heatmap-opacity":new U(F.paint_heatmap["heatmap-opacity"],"heatmap-opacity")})),DE={get paint(){return EE()}};function Zd(e,{width:t,height:i},r,a){if(!a)a=new Uint8Array(t*i*r);else if(a instanceof Uint8ClampedArray)a=new Uint8Array(a.buffer);else if(a.length!==t*i*r)throw RangeError(`mismatched image size. expected: ${a.length} but got: ${t*i*r}`);return e.width=t,e.height=i,e.data=a,e}function W0(e,{width:t,height:i},r){if(t===e.width&&i===e.height)return;let a=Zd({},{width:t,height:i},r);qd(e,a,{x:0,y:0},{x:0,y:0},{width:Math.min(e.width,t),height:Math.min(e.height,i)},r),e.width=t,e.height=i,e.data=a.data}function qd(e,t,i,r,a,n){if(a.width===0||a.height===0)return t;if(a.width>e.width||a.height>e.height||i.x>e.width-a.width||i.y>e.height-a.height)throw RangeError("out of range source coordinates for image copy");if(a.width>t.width||a.height>t.height||r.x>t.width-a.width||r.y>t.height-a.height)throw RangeError("out of range destination coordinates for image copy");let o=e.data,s=t.data;if(o===s)throw Error("srcData equals dstData, so image is already copied");for(let l=0;l<a.height;l++){let u=((i.y+l)*e.width+i.x)*n,h=((r.y+l)*t.width+r.x)*n;for(let c=0;c<a.width*n;c++)s[h+c]=o[u+c]}return t}var Wd=class H0{constructor(t,i){Zd(this,t,1,i)}resize(t){W0(this,t,1)}clone(){return new H0({width:this.width,height:this.height},new Uint8Array(this.data))}static copy(t,i,r,a,n){qd(t,i,r,a,n,1)}},Ve=class X0{constructor(t,i){Zd(this,t,4,i)}resize(t){W0(this,t,4)}replace(t,i){i?this.data.set(t):this.data=t instanceof Uint8ClampedArray?new Uint8Array(t.buffer):t}clone(){return new X0({width:this.width,height:this.height},new Uint8Array(this.data))}static copy(t,i,r,a,n){qd(t,i,r,a,n,4)}setPixel(t,i,r){let a=(t*this.width+i)*4;this.data[a+0]=Math.round(r.r*255/r.a),this.data[a+1]=Math.round(r.g*255/r.a),this.data[a+2]=Math.round(r.b*255/r.a),this.data[a+3]=Math.round(r.a*255)}};function Xu(e){let t=new Uint8Array(e.length);for(let i=0;i<e.length;i+=4){let r=e[i+3];t[i+0]=Math.round(e[i+0]*r/255),t[i+1]=Math.round(e[i+1]*r/255),t[i+2]=Math.round(e[i+2]*r/255),t[i+3]=r}return t}G("AlphaImage",Wd),G("RGBAImage",Ve);function Y0(e){let t={},i=e.resolution||256,r=e.clips?e.clips.length:1,a=e.image||new Ve({width:i,height:r});if(!Kb(i))throw Error(`width is not a power of 2 - ${i}`);let n=(o,s,l)=>{t[e.evaluationKey]=l;let u=e.expression.evaluate(t);a.setPixel(o/4/i,s/4,u)};if(e.clips)for(let o=0,s=0;o<r;++o,s+=i*4)for(let l=0,u=0;l<i;l++,u+=4){let h=l/(i-1),{start:c,end:d}=e.clips[o],p=c*(1-h)+d*h;n(s,u,p)}else for(let o=0,s=0;o<i;o++,s+=4){let l=o/(i-1);n(0,s,l)}return a}var nl="big-fb",SE=e=>e.type==="heatmap",CE=class extends ki{createBucket(e){return new q0(e)}constructor(e,t){super(e,DE,t),this.heatmapFbos=new Map,this._updateColorRamp()}_handleSpecialPaintPropertyUpdate(e){e==="heatmap-color"&&this._updateColorRamp()}_updateColorRamp(){let e=this._transitionablePaint._values["heatmap-color"].value.expression;this.colorRamp=Y0({expression:e,evaluationKey:"heatmapDensity",image:this.colorRamp}),this.colorRampTexture=null}resize(){this.heatmapFbos.has("big-fb")&&this.heatmapFbos.delete(nl)}queryRadius(e){return ka("heatmap-radius",this,e)}queryIntersectsFeature({queryGeometry:e,feature:t,featureState:i,geometry:r,transform:a,pixelsToTileUnits:n,unwrappedTileID:o,getElevation:s}){return Z0({queryGeometry:e,size:this.paint.get("heatmap-radius").evaluate(t,i)*n,transform:a,unwrappedTileID:o,getElevation:s},r)}hasOffscreenPass(){return this.paint.get("heatmap-opacity")!==0&&!this.isHidden()}},gm,PE=()=>gm||(gm=new wt({"hillshade-illumination-direction":new U(F.paint_hillshade["hillshade-illumination-direction"],"hillshade-illumination-direction"),"hillshade-illumination-altitude":new U(F.paint_hillshade["hillshade-illumination-altitude"],"hillshade-illumination-altitude"),"hillshade-illumination-anchor":new U(F.paint_hillshade["hillshade-illumination-anchor"],"hillshade-illumination-anchor"),"hillshade-exaggeration":new U(F.paint_hillshade["hillshade-exaggeration"],"hillshade-exaggeration"),"hillshade-shadow-color":new U(F.paint_hillshade["hillshade-shadow-color"],"hillshade-shadow-color"),"hillshade-highlight-color":new U(F.paint_hillshade["hillshade-highlight-color"],"hillshade-highlight-color"),"hillshade-accent-color":new U(F.paint_hillshade["hillshade-accent-color"],"hillshade-accent-color"),"hillshade-method":new U(F.paint_hillshade["hillshade-method"],"hillshade-method"),resampling:new U(F.paint_hillshade.resampling,"resampling")})),AE={get paint(){return PE()}},IE=e=>e.type==="hillshade",ME=class extends ki{constructor(e,t){super(e,AE,t),this.recalculate({zoom:0,zoomHistory:{}},void 0)}getIlluminationProperties(){let e=this.paint.get("hillshade-illumination-direction").values,t=this.paint.get("hillshade-illumination-altitude").values,i=this.paint.get("hillshade-highlight-color").values,r=this.paint.get("hillshade-shadow-color").values,a=Math.max(e.length,t.length,i.length,r.length);e=e.concat(Array(a-e.length).fill(e.at(-1))),t=t.concat(Array(a-t.length).fill(t.at(-1))),i=i.concat(Array(a-i.length).fill(i.at(-1))),r=r.concat(Array(a-r.length).fill(r.at(-1)));let n=t.map(je);return{directionRadians:e.map(je),altitudeRadians:n,shadowColor:r,highlightColor:i}}hasOffscreenPass(){return this.paint.get("hillshade-exaggeration")!==0&&!this.isHidden()}},_m,FE=()=>_m||(_m=new wt({"color-relief-opacity":new U(F["paint_color-relief"]["color-relief-opacity"],"color-relief-opacity"),"color-relief-color":new $l(F["paint_color-relief"]["color-relief-color"],"color-relief-color"),resampling:new U(F["paint_color-relief"].resampling,"resampling")})),zE={get paint(){return FE()}};function us(e){return"data"in e}var pt=class{constructor(e,t,i,r){this.context=e,this.format=i,this.texture=e.gl.createTexture(),this._ownedHandle=this.texture,this.update(t,r)}update(e,t,i){let{width:r,height:a}=e,n=(this.size?.[0]!==r||this.size[1]!==a)&&!i,{context:o}=this,{gl:s}=o;this.useMipmap=!!t?.useMipmap,n&&this.size&&this.format===s.RGBA&&(s.deleteTexture(this.texture),this.texture=s.createTexture(),this._ownedHandle=this.texture,this.magFilter=void 0,this.minFilter=void 0,this.wrap=void 0),s.bindTexture(s.TEXTURE_2D,this.texture),o.pixelStoreUnpackFlipY.set(!1),o.pixelStoreUnpack.set(1);let l=this.format===s.RGBA&&t?.premultiply!==!1;if(n)if(this.size=[r,a],this.format===s.RGBA&&r>0&&a>0){let u=this.useMipmap?Math.floor(Math.log2(Math.max(r,a)))+1:1;if(s.texStorage2D(s.TEXTURE_2D,u,s.RGBA8,r,a),us(e)){o.pixelStoreUnpackPremultiplyAlpha.set(!1);let{data:h}=e;l&&h&&(h=Xu(h)),h&&s.texSubImage2D(s.TEXTURE_2D,0,0,0,r,a,s.RGBA,s.UNSIGNED_BYTE,h)}else o.pixelStoreUnpackPremultiplyAlpha.set(l),s.texSubImage2D(s.TEXTURE_2D,0,0,0,s.RGBA,s.UNSIGNED_BYTE,e)}else us(e)?(o.pixelStoreUnpackPremultiplyAlpha.set(!1),this._uploadRawData(e,l,r,a,s)):(o.pixelStoreUnpackPremultiplyAlpha.set(l),this._uploadDomImage(e,s));else{let{x:u,y:h}=i||{x:0,y:0};us(e)?(o.pixelStoreUnpackPremultiplyAlpha.set(!1),this._updateRawData(e,l,u,h,r,a,s)):(o.pixelStoreUnpackPremultiplyAlpha.set(l),this._updateDomImage(e,u,h,s))}this.useMipmap&&!(us(e)&&e.data===null)&&s.generateMipmap(s.TEXTURE_2D),o.pixelStoreUnpackFlipY.setDefault(),o.pixelStoreUnpack.setDefault(),o.pixelStoreUnpackPremultiplyAlpha.setDefault()}_uploadDomImage(e,t){t.texImage2D(t.TEXTURE_2D,0,this.format,this.format,t.UNSIGNED_BYTE,e)}_uploadRawData(e,t,i,r,a){let{data:n}=e;t&&n&&(n=Xu(n)),a.texImage2D(a.TEXTURE_2D,0,this.format,i,r,0,this.format,a.UNSIGNED_BYTE,n)}_updateDomImage(e,t,i,r){r.texSubImage2D(r.TEXTURE_2D,0,t,i,r.RGBA,r.UNSIGNED_BYTE,e)}_updateRawData(e,t,i,r,a,n,o){let{data:s}=e;t&&s&&(s=Xu(s)),o.texSubImage2D(o.TEXTURE_2D,0,i,r,a,n,o.RGBA,o.UNSIGNED_BYTE,s)}bind(e,t,i){let{context:r}=this,{gl:a}=r;this.texture!==this._ownedHandle&&(this.texture=this._ownedHandle),a.bindTexture(a.TEXTURE_2D,this.texture),(i===a.LINEAR_MIPMAP_NEAREST||i===a.LINEAR_MIPMAP_LINEAR)&&!this.useMipmap&&(i=a.LINEAR);let n=i||e;e!==this.magFilter&&(a.texParameteri(a.TEXTURE_2D,a.TEXTURE_MAG_FILTER,e),this.magFilter=e),n!==this.minFilter&&(a.texParameteri(a.TEXTURE_2D,a.TEXTURE_MIN_FILTER,n),this.minFilter=n),t!==this.wrap&&(a.texParameteri(a.TEXTURE_2D,a.TEXTURE_WRAP_S,t),a.texParameteri(a.TEXTURE_2D,a.TEXTURE_WRAP_T,t),this.wrap=t)}generateMipmap(){if(!this.useMipmap)return;let{gl:e}=this.context;e.bindTexture(e.TEXTURE_2D,this.texture),e.generateMipmap(e.TEXTURE_2D)}destroy(){let{gl:e}=this.context;e.deleteTexture(this.texture),this.texture=null,this._ownedHandle=null}},or,RE=(or=class{constructor(t,i,r,a=1,n=1,o=1,s=0){if(this.uid=t,i.height!==i.width)throw RangeError("DEM tiles must be square");if(r&&!["mapbox","terrarium","custom"].includes(r)){_e(`"${r}" is not a valid encoding type. Valid types include "mapbox", "terrarium" and "custom".`);return}this.stride=i.height;let l=this.dim=i.height-4;switch(this.data=new Uint32Array(i.data.buffer),or.byteViewCache.set(this,new Uint8Array(this.data.buffer)),r){case"terrarium":this.redFactor=256,this.greenFactor=1,this.blueFactor=1/256,this.baseShift=32768;break;case"custom":this.redFactor=a,this.greenFactor=n,this.blueFactor=o,this.baseShift=s;break;default:this.redFactor=6553.6,this.greenFactor=25.6,this.blueFactor=.1,this.baseShift=1e4}for(let h=-2;h<l+2;h++){let c=this._idx(0,Math.max(0,Math.min(l-1,h)));(h<0||h>=l)&&this.data.copyWithin(this._idx(0,h),c,c+l),this.data.fill(this.data[c],this._idx(-2,h),this._idx(0,h)),this.data.fill(this.data[c+l-1],this._idx(l,h),this._idx(l+1,h)+1)}let u=this._getByteView();this.min=2**53-1,this.max=-(2**53-1);for(let h=0;h<l;h++)for(let c=0;c<l;c++){let d=this._idx(h,c)*4,p=this._unpackAtIndex(u,d);p>this.max&&(this.max=p),p<this.min&&(this.min=p)}}get(t,i){let r=this._getByteView(),a=this._idx(t,i)*4;return this._unpackAtIndex(r,a)}sampleBilinear(t,i){let r=Math.floor(t),a=Math.floor(i);if(r<-1||r>=this.dim||a<-1||a>=this.dim)throw RangeError(`Out of range source coordinates for DEM data. x: ${t}, y: ${i}, dim: ${this.dim}`);let n=this._getByteView(),o=((a+2)*this.stride+r+2)*4,s=this.stride*4,l=t-r,u=i-a,h=this._unpackAtIndex(n,o),c=this._unpackAtIndex(n,o+4),d=this._unpackAtIndex(n,o+s),p=this._unpackAtIndex(n,o+s+4);return h*(1-l)*(1-u)+c*l*(1-u)+d*(1-l)*u+p*l*u}getUnpackVector(){return[this.redFactor,this.greenFactor,this.blueFactor,this.baseShift]}_idx(t,i){if(t<-2||t>=this.dim+2||i<-2||i>=this.dim+2)throw RangeError(`Out of range source coordinates for DEM data. x: ${t}, y: ${i}, dim: ${this.dim}`);return(i+2)*this.stride+(t+2)}unpack(t,i,r){return t*this.redFactor+i*this.greenFactor+r*this.blueFactor-this.baseShift}pack(t){return K0(t,this.getUnpackVector())}getPixels(){return new Ve({width:this.stride,height:this.stride},this._getByteView())}backfillBorder(t,i,r){if(this.dim!==t.dim)throw Error("dem dimension mismatch");let a=i*this.dim,n=i*this.dim+this.dim,o=r*this.dim,s=r*this.dim+this.dim;switch(i){case-1:a=n-2;break;case 1:n=a+2}switch(r){case-1:o=s-2;break;case 1:s=o+2}let l=-i*this.dim,u=-r*this.dim;for(let h=o;h<s;h++)for(let c=a;c<n;c++)this.data[this._idx(c,h)]=t.data[this._idx(c+l,h+u)]}_getByteView(){let t=or.byteViewCache.get(this);return t?.buffer!==this.data.buffer&&(t=new Uint8Array(this.data.buffer),or.byteViewCache.set(this,t)),t}_unpackAtIndex(t,i){return this.unpack(t[i],t[i+1],t[i+2])}},or.byteViewCache=new WeakMap,or);function K0(e,t){let i=t[0],r=t[1],a=t[2],n=t[3],o=[i,r,a].filter(h=>h!==0);if(o.length===0)return{r:0,g:0,b:0};let s=Math.min(...o),l=Math.round((e+n)/s),u=h=>h===0?0:Math.floor(l*s/h)%256;return{r:u(i),g:u(r),b:u(a)}}G("DEMData",RE);var kE=e=>e.type==="color-relief",LE=class extends ki{constructor(e,t){super(e,zE,t)}_createColorRamp(e){let t={elevationStops:[],colorStops:[]},i=this._transitionablePaint._values["color-relief-color"].value.expression;if(i instanceof io&&i._styleExpression.expression instanceof wi){this.colorRampExpression=i;let n=i._styleExpression.expression;t.elevationStops=n.labels,t.colorStops=[];for(let o of t.elevationStops)t.colorStops.push(n.evaluate({globals:{elevation:o}}))}if(t.elevationStops.length<1&&(t.elevationStops=[0],t.colorStops=[oe.transparent]),t.elevationStops.length<2&&(t.elevationStops.push(t.elevationStops[0]+1),t.colorStops.push(t.colorStops[0])),t.elevationStops.length<=e)return t;let r={elevationStops:[],colorStops:[]},a=(t.elevationStops.length-1)/(e-1);for(let n=0;n<t.elevationStops.length-.5;n+=a)r.elevationStops.push(t.elevationStops[Math.round(n)]),r.colorStops.push(t.colorStops[Math.round(n)]);return _e(`Too many colors in specification of ${this.id} color-relief layer, may not render properly. Max possible colors: ${e}, provided: ${t.elevationStops.length}`),r}_colorRampChanged(){return this.colorRampExpression!=this._transitionablePaint._values["color-relief-color"].value.expression}getColorRampTextures(e,t,i){if(this.colorRampTextures&&!this._colorRampChanged())return this.colorRampTextures;let r=this._createColorRamp(t),a=new Ve({width:r.colorStops.length,height:1}),n=new Ve({width:r.colorStops.length,height:1});for(let o=0;o<r.elevationStops.length;o++){let s=K0(r.elevationStops[o],i);n.setPixel(0,o,new oe(s.r/255,s.g/255,s.b/255,1)),a.setPixel(0,o,r.colorStops[o])}return this.colorRampTextures={elevationTexture:new pt(e,n,e.gl.RGBA),colorTexture:new pt(e,a,e.gl.RGBA)},this.colorRampTextures}hasOffscreenPass(){return!this.isHidden()&&!!this.colorRampTextures}},wc=Je([{name:"a_pos",components:2,type:"Int16"}],4),BE=wc.members;wc.size,wc.alignment;function ol(e,t,i){let r=i.patternDependencies,a=!1;for(let n of t){let o=n.paint.get(`${e}-pattern`);o.isConstant()||(a=!0);let s=o.constantOr(null);s&&(a=!0,r[s.to]=!0,r[s.from]=!0)}return a}function Hd(e,t,i,r,a){let{zoom:n}=r,o=a.patternDependencies;for(let s of t){let l=s.paint.get(`${e}-pattern`).value;if(l.kind!=="constant"){let u=l.evaluate({zoom:n-1},i,{},a.availableImages),h=l.evaluate({zoom:n},i,{},a.availableImages),c=l.evaluate({zoom:n+1},i,{},a.availableImages);u=u?.name?u.name:u,h=h?.name?h.name:h,c=c?.name?c.name:c,o[u]=!0,o[h]=!0,o[c]=!0,i.patterns[s.id]={min:u,mid:h,max:c}}}return i}var uo=new Set,Tc=!1;function OE(e,t,i=2){let r=t&&t.length,a=r?t[0]*i:e.length;uo.size&&uo.clear();let n=J0(e,0,a,i,!0),o=[];if(!n||n.next===n.prev)return o;let s=0,l=0,u=0;if(r&&(n=$E(e,t,n,i)),e.length>80*i){s=e[0],l=e[1];let h=s,c=l;for(let d=i;d<a;d+=i){let p=e[d],f=e[d+1];p<s&&(s=p),f<l&&(l=f),p>h&&(h=p),f>c&&(c=f)}u=Math.max(h-s,c-l),u=u===0?0:32767/u}return Ec(n,o,s,l,u),o}function J0(e,t,i,r,a){let n=null;if(a===iD(e,t,i,r)>0)for(let o=t;o<i;o+=r)n=xm(o/r|0,e[o],e[o+1],n);else for(let o=i-r;o>=t;o-=r)n=xm(o/r|0,e[o],e[o+1],n);return n&&ho(n,n.next)&&(po(n),n=n.next),n}function ta(e,t=e){let i=t===e,r=e,a;do a=!1,r!==r.next&&(uo.size===0||!uo.has(r))&&(ho(r,r.next)||dt(r.prev,r,r.next)===0)?((i||r===t)&&(t=r.prev),Tc=!0,po(r),r=r.prev,a=!0):(i||r!==t)&&(r=r.next,a=!i);while(a||r!==t);return t}function Ec(e,t,i,r,a){a&&YE(e,i,r,a);let n=e,o=!1;for(;e.prev!==e.next;){let s=e.prev,l=e.next;if(dt(s,e,l)<0&&(a?VE(e,i,r,a):jE(e))){t.push(s.i,e.i,l.i),po(e),e=l,n=l;continue}if(e=l,e===n){if(Tc=!1,e=ta(e),Tc){n=e;continue}if(!o){e=NE(e,t),n=e,o=!0;continue}UE(e,t,i,r,a);break}}}function jE(e){let t=e.prev,i=e,r=e.next,a=t.x,n=i.x,o=r.x,s=t.y,l=i.y,u=r.y,h=Math.min(a,n,o),c=Math.min(s,l,u),d=Math.max(a,n,o),p=Math.max(s,l,u),f=r.next;for(;f!==t;){if(f.x>=h&&f.x<=d&&f.y>=c&&f.y<=p&&(a!==f.x||s!==f.y)&&ll(a,s,n,l,o,u,f.x,f.y)&&dt(f.prev,f,f.next)>=0)return!1;f=f.next}return!0}function VE(e,t,i,r){let a=e.prev,n=e,o=e.next,s=a.x,l=n.x,u=o.x,h=a.y,c=n.y,d=o.y,p=Math.min(s,l,u),f=Math.min(h,c,d),m=Math.max(s,l,u),g=Math.max(h,c,d),_=Pc(p,f,t,i,r),y=Pc(m,g,t,i,r),v=e.prevZ;for(;v&&v.z>=_;){if(v.x>=p&&v.x<=m&&v.y>=f&&v.y<=g&&v!==o&&(s!==v.x||h!==v.y)&&ll(s,h,l,c,u,d,v.x,v.y)&&dt(v.prev,v,v.next)>=0)return!1;v=v.prevZ}let x=e.nextZ;for(;x&&x.z<=y;){if(x.x>=p&&x.x<=m&&x.y>=f&&x.y<=g&&x!==o&&(s!==x.x||h!==x.y)&&ll(s,h,l,c,u,d,x.x,x.y)&&dt(x.prev,x,x.next)>=0)return!1;x=x.nextZ}return!0}function NE(e,t){let i=e,r=!1;do{let a=i.prev,n=i.next.next;e1(a,i,i.next,n,!1)&&co(a,n)&&co(n,a)&&(t.push(a.i,i.i,n.i),po(i),po(i.next),i=e=n,r=!0),i=i.next}while(i!==e);return r?ta(i):i}function UE(e,t,i,r,a){let n=e;do{let o=n.next.next;for(;o!==n.prev;){if(n.i!==o.i&&QE(n,o)){let s=t1(n,o);n=ta(n,n.next),s=ta(s,s.next),Ec(n,t,i,r,a),Ec(s,t,i,r,a);return}o=o.next}n=n.next}while(n!==e)}var Dc=!1;function $E(e,t,i,r){let a=[];for(let n=0,o=t.length;n<o;n++){let s=J0(e,t[n]*r,n<o-1?t[n+1]*r:e.length,r,!1);s===s.next&&uo.add(s),a.push(JE(s))}a.sort(GE),qE(e.length/r,t.length),Q0(i,i),Dc=!0;for(let n=0;n<a.length;n++)i=ZE(a[n],i);return Dc=!1,ta(i)}function GE(e,t){return e.x-t.x||e.y-t.y||(e.next.y-e.y)/(e.next.x-e.x)-(t.next.y-t.y)/(t.next.x-t.x)}function ZE(e,t){let i=HE(e,t);if(!i)return t;let r=t1(i,e),a=r.next;return Q0(i,a.next),ta(r,r.next),ta(i,i.next)}var tt=new Float64Array,sl=0,Sc=[],Cc=[];function qE(e,t){let i=Math.ceil((e+2*t)/16)+t+2;tt.length<i*4&&(tt=new Float64Array(i*4)),sl=0}function Q0(e,t){let i=e;do{let r=sl++;Sc[r]=i;let a=i.x,n=i.y,o=i.x,s=i.y,l=0;do{let h=i.next;i.z=r,h.x<a&&(a=h.x),h.x>o&&(o=h.x),h.y<n&&(n=h.y),h.y>s&&(s=h.y),i=h}while(++l<16&&i!==t);Cc[r]=i;let u=r*4;tt[u]=a,tt[u+1]=n,tt[u+2]=o,tt[u+3]=s}while(i!==t)}function WE(e,t){let i=e.z*4;t.x<tt[i]&&(tt[i]=t.x),t.y<tt[i+1]&&(tt[i+1]=t.y),t.x>tt[i+2]&&(tt[i+2]=t.x),t.y>tt[i+3]&&(tt[i+3]=t.y)}function ym(e){let t=Cc[e];for(;t.prev.next!==t;)t=t.next;return Cc[e]=t,t}function vm(e){let t=Sc[e];for(;t.prev.next!==t;)t=t.next;return Sc[e]=t,t}function HE(e,t){let i=t,r=e.x,a=e.y,n=-1/0,o;if(ho(e,i))return i;for(let d=0,p=0;d<sl;d++,p+=4){if(a<tt[p+1]||a>tt[p+3]||tt[p]>r||tt[p+2]<=n)continue;let f=ym(d);i=vm(d);do{if(i.prev.next===i){if(ho(e,i.next))return i.next;if(a<=i.y&&a>=i.next.y&&i.next.y!==i.y){let m=i.x+(a-i.y)*(i.next.x-i.x)/(i.next.y-i.y);if(m<=r&&m>n&&(n=m,o=i.x<i.next.x?i:i.next,m===r))return o}}i=i.next}while(i!==f)}if(!o)return null;let s=o.x,l=o.y,u=Math.min(a,l),h=Math.max(a,l),c=1/0;for(let d=0,p=0;d<sl;d++,p+=4){if(tt[p+2]<s||tt[p]>r||tt[p+3]<u||tt[p+1]>h)continue;let f=ym(d);i=vm(d);do{if(i.prev.next===i&&r>=i.x&&i.x>=s&&r!==i.x&&ll(a<l?r:n,a,s,l,a<l?n:r,a,i.x,i.y)){let m=Math.abs(a-i.y)/(r-i.x);(co(i,e)||i.y===a&&i.next.y===a&&i.next.x>r)&&(m<c||m===c&&(i.x>o.x||i.x===o.x&&XE(o,i)))&&(o=i,c=m)}i=i.next}while(i!==f)}return o}function XE(e,t){return dt(e.prev,e,t.prev)<0&&dt(t.next,e,e.next)<0}var ti=[],Ca=[],kr=new Uint32Array,vn=new Uint32Array,xn=new Uint32Array(256);function YE(e,t,i,r){let a=e,n=0;do a.z=Pc(a.x,a.y,t,i,r),ti[n++]=a,a=a.next;while(a!==e);KE(n);let o=null;for(let s=0;s<n;s++){let l=ti[s];l.prevZ=o,o&&(o.nextZ=l),o=l}o.nextZ=null,ti.fill(null,0,n),Ca.fill(null,0,n)}function KE(e){if(e<=32){for(let t=1;t<e;t++){let i=ti[t],r=i.z,a=t-1;for(;a>=0&&ti[a].z>r;)ti[a+1]=ti[a],a--;ti[a+1]=i}return}kr.length<e&&(kr=new Uint32Array(e),vn=new Uint32Array(e),Ca=Array(e));for(let t=0;t<e;t++)kr[t]=ti[t].z;hs(e,ti,kr,Ca,vn,0),hs(e,Ca,vn,ti,kr,8),hs(e,ti,kr,Ca,vn,16),hs(e,Ca,vn,ti,kr,24)}function hs(e,t,i,r,a,n){xn.fill(0);for(let s=0;s<e;s++)xn[i[s]>>>n&255]++;let o=0;for(let s=0;s<256;s++){let l=xn[s];xn[s]=o,o+=l}for(let s=0;s<e;s++){let l=i[s],u=xn[l>>>n&255]++;r[u]=t[s],a[u]=l}}function Pc(e,t,i,r,a){return e=(e-i)*a|0,t=(t-r)*a|0,e=(e|e<<8)&16711935,e=(e|e<<4)&252645135,e=(e|e<<2)&858993459,e=(e|e<<1)&1431655765,t=(t|t<<8)&16711935,t=(t|t<<4)&252645135,t=(t|t<<2)&858993459,t=(t|t<<1)&1431655765,e|t<<1}function JE(e){let t=e,i=e;do(t.x<i.x||t.x===i.x&&t.y<i.y)&&(i=t),t=t.next;while(t!==e);return i}function ll(e,t,i,r,a,n,o,s){return(a-o)*(t-s)>=(e-o)*(n-s)&&(e-o)*(r-s)>=(i-o)*(t-s)&&(i-o)*(n-s)>=(a-o)*(r-s)}function QE(e,t){let i=ho(e,t)&&dt(e.prev,e,e.next)>0&&dt(t.prev,t,t.next)>0;return e.next.i!==t.i&&(i||co(e,t)&&co(t,e)&&(dt(e.prev,e,t.prev)!==0||dt(e,t.prev,t)!==0))&&!eD(e,t)&&(i||tD(e,t))}function dt(e,t,i){return(t.y-e.y)*(i.x-t.x)-(t.x-e.x)*(i.y-t.y)}function ho(e,t){return e.x===t.x&&e.y===t.y}function e1(e,t,i,r,a=!0){let n=dt(e,t,i),o=dt(e,t,r),s=dt(i,r,e),l=dt(i,r,t);return(n>0&&o<0||n<0&&o>0)&&(s>0&&l<0||s<0&&l>0)?!0:a?!!(n===0&&cs(e,i,t)||o===0&&cs(e,r,t)||s===0&&cs(i,e,r)||l===0&&cs(i,t,r)):!1}function cs(e,t,i){return t.x<=Math.max(e.x,i.x)&&t.x>=Math.min(e.x,i.x)&&t.y<=Math.max(e.y,i.y)&&t.y>=Math.min(e.y,i.y)}function eD(e,t){let i=Math.min(e.x,t.x),r=Math.max(e.x,t.x),a=Math.min(e.y,t.y),n=Math.max(e.y,t.y),o=e;do{let s=o.next;if(o.x>r&&s.x>r||o.x<i&&s.x<i||o.y>n&&s.y>n||o.y<a&&s.y<a){o=s;continue}if(o.i!==e.i&&s.i!==e.i&&o.i!==t.i&&s.i!==t.i&&e1(o,s,e,t))return!0;o=s}while(o!==e);return!1}function co(e,t){return dt(e.prev,e,e.next)<0?dt(e,t,e.next)>=0&&dt(e,e.prev,t)>=0:dt(e,t,e.prev)<0||dt(e,e.next,t)<0}function tD(e,t){let i=e,r=!1,a=(e.x+t.x)/2,n=(e.y+t.y)/2;do{let o=i.next;i.y>n!=o.y>n&&a<(o.x-i.x)*(n-i.y)/(o.y-i.y)+i.x&&(r=!r),i=o}while(i!==e);return r}function t1(e,t){let i=Ac(e.i,e.x,e.y),r=Ac(t.i,t.x,t.y),a=e.next,n=t.prev;return e.next=t,t.prev=e,i.next=a,a.prev=i,r.next=i,i.prev=r,n.next=r,r.prev=n,r}function xm(e,t,i,r){let a=Ac(e,t,i);return r?(a.next=r.next,a.prev=r,r.next.prev=a,r.next=a):(a.prev=a,a.next=a),a}function po(e){e.next.prev=e.prev,e.prev.next=e.next,e.prevZ&&(e.prevZ.nextZ=e.nextZ),e.nextZ&&(e.nextZ.prevZ=e.prevZ),Dc&&WE(e.prev,e.next)}function Ac(e,t,i){return{i:e,x:t,y:i,prev:null,next:null,z:0,prevZ:null,nextZ:null}}function iD(e,t,i,r){let a=0;for(let n=t,o=i-r;n<i;n+=r)a+=(e[o]-e[n])*(e[n+1]+e[o+1]),o=n;return a}var nr=class{constructor(e,t){if(t>e)throw Error("Min granularity must not be greater than base granularity.");this._baseZoomGranularity=e,this._minGranularity=t}getGranularityForZoomLevel(e){let t=1<<e;return Math.max(Math.floor(this._baseZoomGranularity/t),this._minGranularity,1)}},Yr,Xd=(Yr=class{constructor(t){this.fill=t.fill,this.line=t.line,this.tile=t.tile,this.stencil=t.stencil,this.circle=t.circle}},Yr.noSubdivision=new Yr({fill:new nr(0,0),line:new nr(0,0),tile:new nr(0,0),stencil:new nr(0,0),circle:1}),Yr);G("SubdivisionGranularityExpression",nr),G("SubdivisionGranularitySetting",Xd);var Gn=-32768,Zn=32767,rD=class{constructor(e,t){this._vertexBuffer=[],this._vertexDictionary=new Map,this._used=!1,this._granularity=e,this._granularityCellSize=k/e,this._canonical=t}_getKey(e,t){return e+=32768,t+=32768,e<<16|t<<0}_vertexToIndex(e,t){if(e<-32768||t<-32768||e>32767||t>32767)throw Error("Vertex coordinates are out of signed 16 bit integer range.");let i=Math.round(e)|0,r=Math.round(t)|0,a=this._getKey(i,r),n=this._vertexDictionary.get(a);if(n!==void 0)return n;let o=this._vertexBuffer.length/2;return this._vertexDictionary.set(a,o),this._vertexBuffer.push(i,r),o}_subdivideTrianglesScanline(e,t){if(this._granularity<2)return oD(this._vertexBuffer,nD(e,t));let i=[],r=e.length;for(let a=0;a<r;a+=3){let n=[t[e[a+0]],t[e[a+1]],t[e[a+2]]],o=[this._vertexBuffer[n[0]*2+0],this._vertexBuffer[n[0]*2+1],this._vertexBuffer[n[1]*2+0],this._vertexBuffer[n[1]*2+1],this._vertexBuffer[n[2]*2+0],this._vertexBuffer[n[2]*2+1]],s=1/0,l=1/0,u=-1/0,h=-1/0;for(let m=0;m<3;m++){let g=o[m*2],_=o[m*2+1];s=Math.min(s,g),u=Math.max(u,g),l=Math.min(l,_),h=Math.max(h,_)}if(s===u||l===h)continue;let c=Math.floor(s/this._granularityCellSize),d=Math.ceil(u/this._granularityCellSize),p=Math.floor(l/this._granularityCellSize),f=Math.ceil(h/this._granularityCellSize);if(c===d&&p===f){i.push(...n);continue}for(let m=p;m<f;m++){let g=this._scanlineGenerateVertexRingForCellRow(m,o,n);sD(this._vertexBuffer,g,i)}}return i}_scanlineGenerateVertexRingForCellRow(e,t,i){let r=e*this._granularityCellSize,a=r+this._granularityCellSize,n=[];for(let o=0;o<3;o++){let s=t[o*2],l=t[o*2+1],u=t[(o+1)*2%6],h=t[((o+1)*2+1)%6],c=t[(o+2)*2%6],d=t[((o+2)*2+1)%6],p=u-s,f=h-l,m=p===0,g=f===0,_=(r-l)/f,y=(a-l)/f,v=Math.min(_,y),x=Math.max(_,y);if(!g&&(v>=1||x<=0)||g&&(l<r||l>a)){h>=r&&h<=a&&n.push(i[(o+1)%3]);continue}if(!g&&v>0){let T=s+p*v,E=l+f*v;n.push(this._vertexToIndex(T,E))}let b=s+p*Math.max(v,0),w=s+p*Math.min(x,1);if(m||this._generateIntraEdgeVertices(n,s,l,u,h,b,w),!g&&x<1){let T=s+p*x,E=l+f*x;n.push(this._vertexToIndex(T,E))}(g||h>=r&&h<=a)&&n.push(i[(o+1)%3]),!g&&(h<=r||h>=a)&&this._generateInterEdgeVertices(n,s,l,u,h,c,d,w,r,a)}return n}_generateIntraEdgeVertices(e,t,i,r,a,n,o){let s=r-t,l=a-i,u=l===0,h=u?Math.min(t,r):Math.min(n,o),c=u?Math.max(t,r):Math.max(n,o),d=Math.floor(h/this._granularityCellSize)+1,p=Math.ceil(c/this._granularityCellSize)-1;if(u?t<r:n<o)for(let f=d;f<=p;f++){let m=f*this._granularityCellSize,g=i+l*(m-t)/s;e.push(this._vertexToIndex(m,g))}else for(let f=p;f>=d;f--){let m=f*this._granularityCellSize,g=i+l*(m-t)/s;e.push(this._vertexToIndex(m,g))}}_generateInterEdgeVertices(e,t,i,r,a,n,o,s,l,u){let h=a-i,c=n-r,d=o-a,p=(l-a)/d,f=(u-a)/d,m=Math.min(p,f),g=Math.max(p,f),_=r+c*m,y=Math.floor(Math.min(_,s)/this._granularityCellSize)+1,v=Math.ceil(Math.max(_,s)/this._granularityCellSize)-1,x=s<_,b=d===0;if(b&&(o===l||o===u))return;if(b||m>=1||g<=0){let T=t-n,E=i-o,S=(l-o)/E,M=(u-o)/E,z=n+T*Math.min(S,M);y=Math.floor(Math.min(z,s)/this._granularityCellSize)+1,v=Math.ceil(Math.max(z,s)/this._granularityCellSize)-1,x=s<z}let w=h>0?u:l;if(x)for(let T=y;T<=v;T++){let E=T*this._granularityCellSize;e.push(this._vertexToIndex(E,w))}else for(let T=v;T>=y;T--){let E=T*this._granularityCellSize;e.push(this._vertexToIndex(E,w))}}_generateOutline(e,t){let i=[],r=0;for(let a of e){let n=this._granularity<2?this._ringPathIndices(a,r,t):this._pointArrayToIndices(Zr(a,this._granularity,!0));r+=a.length;let o=[];for(let s=1;s<n.length;s++)o.push(n[s-1]),o.push(n[s]);i.push(o)}return i}_ringPathIndices(e,t,i){let r=i.slice(t,t+e.length);return r.length>=2&&r1(e)&&r.push(r[0]),r}_handlePoles(e){let t=!1,i=!1;this._canonical&&(this._canonical.y===0&&(t=!0),this._canonical.y===(1<<this._canonical.z)-1&&(i=!0)),(t||i)&&this._fillPoles(e,t,i)}_ensureNoPoleVertices(){let e=this._vertexBuffer;for(let t=0;t<e.length;t+=2){let i=e[t+1];i===-32768&&(e[t+1]=-32767),i===32767&&(e[t+1]=32766)}}_generatePoleQuad(e,t,i,r,a,n){r>a==(n===-32768)?(e.push(i),e.push(t),e.push(this._vertexToIndex(r,n)),e.push(this._vertexToIndex(a,n)),e.push(i),e.push(this._vertexToIndex(r,n))):(e.push(t),e.push(i),e.push(this._vertexToIndex(r,n)),e.push(i),e.push(this._vertexToIndex(a,n)),e.push(this._vertexToIndex(r,n)))}_fillPoles(e,t,i){let r=this._vertexBuffer,a=k,n=e.length;for(let o=2;o<n;o+=3){let s=e[o-2],l=e[o-1],u=e[o],h=r[s*2],c=r[s*2+1],d=r[l*2],p=r[l*2+1],f=r[u*2],m=r[u*2+1];t&&(c===0&&p===0&&this._generatePoleQuad(e,s,l,h,d,Gn),p===0&&m===0&&this._generatePoleQuad(e,l,u,d,f,Gn),m===0&&c===0&&this._generatePoleQuad(e,u,s,f,h,Gn)),i&&(c===a&&p===a&&this._generatePoleQuad(e,s,l,h,d,Zn),p===a&&m===a&&this._generatePoleQuad(e,l,u,d,f,Zn),m===a&&c===a&&this._generatePoleQuad(e,u,s,f,h,Zn))}}_initializeVertices(e){let t=[];for(let i=0;i<e.length;i+=2)t.push(this._vertexToIndex(e[i],e[i+1]));return t}subdividePolygonInternal(e,t){if(this._used)throw Error("Subdivision: multiple use not allowed.");this._used=!0;let{flattened:i,holeIndices:r}=aD(e),a=this._initializeVertices(i),n;try{let s=OE(i,r);n=this._subdivideTrianglesScanline(s,a)}catch(s){console.error(s)}let o=[];return t&&(o=this._generateOutline(e,a)),this._ensureNoPoleVertices(),this._handlePoles(n),this._granularity>=2&&this._canonical?.z===0&&(n=this._removeTrianglesOutsideTileX(n),o=o.map(s=>this._removeLinesOutsideTileX(s))),{verticesFlattened:this._vertexBuffer,indicesTriangles:n,indicesLineList:o}}_vertexOutsideTileX(e){let t=this._vertexBuffer[e*2];return t<0||t>8192}_removeTrianglesOutsideTileX(e){let t=[];for(let i=0;i<e.length;i+=3)this._vertexOutsideTileX(e[i])||this._vertexOutsideTileX(e[i+1])||this._vertexOutsideTileX(e[i+2])||t.push(e[i],e[i+1],e[i+2]);return t}_removeLinesOutsideTileX(e){let t=[];for(let i=0;i<e.length;i+=2)this._vertexOutsideTileX(e[i])||this._vertexOutsideTileX(e[i+1])||t.push(e[i],e[i+1]);return t}_pointArrayToIndices(e){let t=[];for(let i of e)t.push(this._vertexToIndex(i.x,i.y));return t}};function i1(e,t,i,r=!0){return new rD(i,t).subdividePolygonInternal(e,r)}function Zr(e,t,i=!1){if(!e||e.length<1||e.length<2)return[];let r=i&&r1(e);if(t<2)return r?[...e,e[0]]:[...e];let a=Math.floor(k/t),n=[];n.push(new C(e[0].x,e[0].y));let o=e.length,s=r?o:o-1;for(let l=0;l<s;l++){let u=e[l],h=l<o-1?e[l+1]:e[0],c=u.x,d=u.y,p=h.x,f=h.y,m=c!==p,g=d!==f;if(!m&&!g)continue;let _=p-c,y=f-d,v=Math.abs(_),x=Math.abs(y),b=c,w=d;for(;;){let E=_>0?(Math.floor(b/a)+1)*a:(Math.ceil(b/a)-1)*a,S=y>0?(Math.floor(w/a)+1)*a:(Math.ceil(w/a)-1)*a,M=Math.abs(b-E),z=Math.abs(w-S),R=Math.abs(b-p),I=Math.abs(w-f),D=m?M/v:1/0,P=g?z/x:1/0;if((R<=M||!m)&&(I<=z||!g))break;if(D<P&&m||!g){b=E,w+=y*D;let A=new C(b,Math.round(w));(n[n.length-1].x!==A.x||n[n.length-1].y!==A.y)&&n.push(A)}else{b+=_*P,w=S;let A=new C(Math.round(b),w);(n[n.length-1].x!==A.x||n[n.length-1].y!==A.y)&&n.push(A)}}let T=new C(p,f);(n[n.length-1].x!==T.x||n[n.length-1].y!==T.y)&&n.push(T)}return n}function r1(e){return!e[0].equals(e[e.length-1])}function aD(e){let t=[],i=[];for(let r of e)if(r.length!==0){r!==e[0]&&t.push(i.length/2);for(let a of r)i.push(a.x),i.push(a.y)}return{flattened:i,holeIndices:t}}function nD(e,t){let i=Array(e.length);for(let r=0;r<e.length;r++)i[r]=t[e[r]];return i}function oD(e,t){let i=[];for(let r=0;r<t.length;r+=3){let a=t[r],n=t[r+1],o=t[r+2],s=e[a*2],l=e[a*2+1],u=e[n*2],h=e[n*2+1],c=e[o*2],d=e[o*2+1],p=u-s,f=h-l,m=c-s;p*(d-l)-f*m>0?(i.push(a),i.push(o),i.push(n)):(i.push(a),i.push(n),i.push(o))}return i}function sD(e,t,i){if(t.length===0)throw Error("Subdivision vertex ring is empty.");let r=0,a=e[t[0]*2];for(let l=1;l<t.length;l++){let u=e[t[l]*2];u<a&&(a=u,r=l)}let n=t.length,o=r,s=(o+1)%n;for(;;){let l=o-1>=0?o-1:n-1,u=(s+1)%n,h=e[t[l]*2],c=e[t[l]*2+1],d=e[t[u]*2],p=e[t[u]*2+1],f=e[t[o]*2],m=e[t[o]*2+1],g=e[t[s]*2],_=e[t[s]*2+1],y=!1;if(h<d)y=!0;else if(h>d)y=!1;else{let v=_-m,x=-(g-f),b=m<_?1:-1;((h-f)*v+(c-m)*x)*b>((d-f)*v+(p-m)*x)*b&&(y=!0)}if(y){let v=t[l],x=t[o],b=t[s];v!==x&&v!==b&&x!==b&&i.push(b,x,v),o--,o<0&&(o=n-1)}else{let v=t[u],x=t[o],b=t[s];v!==x&&v!==b&&x!==b&&i.push(b,x,v),s++,s>=n&&(s=0)}if(l===u)break}}function a1(e,t,i,r,a,n,o,s,l){let u=a.length/2,h=o&&s&&l;if(u<Ye.MAX_VERTEX_ARRAY_LENGTH){let c=t.prepareSegment(u,i,r),d=c.vertexLength;for(let m=0;m<n.length;m+=3)r.emplaceBack(d+n[m],d+n[m+1],d+n[m+2]);c.vertexLength+=u,c.primitiveLength+=n.length/3;let p,f;h&&(f=o.prepareSegment(u,i,s),p=f.vertexLength,f.vertexLength+=u);for(let m=0;m<a.length;m+=2)e(a[m],a[m+1]);if(h)for(let m of l){for(let g=1;g<m.length;g+=2)s.emplaceBack(p+m[g-1],p+m[g]);f.primitiveLength+=m.length/2}}else lD(t,i,r,a,n,e),h&&uD(o,i,s,a,l,e),t.forceNewSegmentOnNextPrepare(),o?.forceNewSegmentOnNextPrepare()}function qn(e,t,i,r,a,n,o){if(n){let s=r.count;return i(t[a*2],t[a*2+1]),e[a]=r.count,r.count++,o.vertexLength++,s}return e[a]}function lD(e,t,i,r,a,n){let o=[];for(let c=0;c<r.length/2;c++)o.push(-1);let s={count:0},l=0,u=e.getOrCreateLatestSegment(t,i),h=u.vertexLength;for(let c=2;c<a.length;c+=3){let d=a[c-2],p=a[c-1],f=a[c],m=o[d]<l,g=o[p]<l,_=o[f]<l,y=+!!m+ +!!g+ +!!_;u.vertexLength+y>Ye.MAX_VERTEX_ARRAY_LENGTH&&(u=e.createNewSegment(t,i),l=s.count,m=!0,g=!0,_=!0,h=0);let v=qn(o,r,n,s,d,m,u),x=qn(o,r,n,s,p,g,u),b=qn(o,r,n,s,f,_,u);i.emplaceBack(h+v-l,h+x-l,h+b-l),u.primitiveLength++}}function uD(e,t,i,r,a,n){let o=[];for(let c=0;c<r.length/2;c++)o.push(-1);let s={count:0},l=0,u=e.getOrCreateLatestSegment(t,i),h=u.vertexLength;for(let c of a)for(let d=1;d<c.length;d+=2){let p=c[d-1],f=c[d],m=o[p]<l,g=o[f]<l,_=+!!m+ +!!g;u.vertexLength+_>Ye.MAX_VERTEX_ARRAY_LENGTH&&(u=e.createNewSegment(t,i),l=s.count,m=!0,g=!0,h=0);let y=qn(o,r,n,s,p,m,u),v=qn(o,r,n,s,f,g,u);i.emplaceBack(h+y-l,h+v-l),u.primitiveLength++}}var n1=class{constructor(e){this.zoom=e.zoom,this.overscaling=e.overscaling,this.layers=e.layers,this.layerIds=this.layers.map(t=>t.id),this.index=e.index,this.hasDependencies=!1,this.sdfPatterns={},this.patternFeatures=[],this.layoutVertexArray=new NT,this.indexArray=new Xi,this.indexArray2=new gc,this.programConfigurations=new ea(e.layers,e.zoom),this.segments=new Ye,this.segments2=new Ye,this.stateDependentLayerIds=this.layers.filter(t=>t.isStateDependent()).map(t=>t.id)}populate(e,t,i){this.hasDependencies=ol("fill",this.layers,t);let r=this.layers[0].layout.get("fill-sort-key"),a=!r.isConstant(),n=[],o=new Ae(this.zoom),s=this.layers[0]._featureFilter.needGeometry;for(let{feature:l,id:u,index:h,sourceLayerIndex:c}of e){let d=la(l,s);if(!this.layers[0]._featureFilter.filter(o,d,i))continue;let p=a?r.evaluate(d,{},i,t.availableImages):void 0,f={id:u,properties:l.properties,type:l.type,sourceLayerIndex:c,index:h,geometry:s?d.geometry:sa(l),patterns:{},sortKey:p};n.push(f)}a&&n.sort((l,u)=>l.sortKey-u.sortKey);for(let l of n){let{geometry:u,index:h,sourceLayerIndex:c}=l;if(this.hasDependencies){let p=Hd("fill",this.layers,l,{zoom:this.zoom},t);this.patternFeatures.push(p)}else this.addFeature(l,u,h,i,{},t.subdivisionGranularity);let d=e[h].feature;t.featureIndex.insert(d,u,h,c,this.index)}}update(e,t,i){this.stateDependentLayers.length&&this.programConfigurations.updatePaintArrays(e,t,this.stateDependentLayers,{imagePositions:i})}addFeatures({options:e,canonical:t,patternPositions:i,patternMap:r}){this.detectSdfPatterns(r);for(let a of this.patternFeatures)this.addFeature(a,a.geometry,a.index,t,i,e.subdivisionGranularity)}detectSdfPatterns(e){for(let t of this.patternFeatures)for(let i in t.patterns){let r=t.patterns[i];this.recordSdfPattern(i,e[r.min]),this.recordSdfPattern(i,e[r.mid]),this.recordSdfPattern(i,e[r.max])}for(let t of this.layers){let i=t.paint.get("fill-pattern").constantOr(null);i&&(this.recordSdfPattern(t.id,e[i.from.toString()]),this.recordSdfPattern(t.id,e[i.to.toString()]))}}recordSdfPattern(e,t){if(!t)return;let i=t.sdf===!0,r=this.sdfPatterns[e];r===void 0?this.sdfPatterns[e]=i:r!==i&&_e(`Style sheet warning: Cannot mix SDF and non-SDF fill patterns in layer "${e}"`)}isEmpty(){return this.layoutVertexArray.length===0}uploadPending(){return!this.uploaded||this.programConfigurations.needsUpload}upload(e){this.uploaded||(this.layoutVertexBuffer=e.createVertexBuffer(this.layoutVertexArray,BE),this.indexBuffer=e.createIndexBuffer(this.indexArray),this.indexBuffer2=e.createIndexBuffer(this.indexArray2)),this.programConfigurations.upload(e),this.uploaded=!0}destroy(){this.layoutVertexBuffer&&(this.layoutVertexBuffer.destroy(),this.indexBuffer.destroy(),this.indexBuffer2.destroy(),this.programConfigurations.destroy(),this.segments.destroy(),this.segments2.destroy())}addFeature(e,t,i,r,a,n){for(let o of zl(t,500)){let s=i1(o,r,n.fill.getGranularityForZoomLevel(r.z)),l=this.layoutVertexArray;a1((u,h)=>{l.emplaceBack(u,h)},this.segments,this.layoutVertexArray,this.indexArray,s.verticesFlattened,s.indicesTriangles,this.segments2,this.indexArray2,s.indicesLineList)}this.programConfigurations.populatePaintArrays(this.layoutVertexArray.length,e,i,{imagePositions:a,canonical:r})}};G("FillBucket",n1,{omit:["layers","patternFeatures"]});var bm,hD=()=>bm||(bm=new wt({"fill-sort-key":new ee(F.layout_fill["fill-sort-key"],"fill-sort-key")})),wm,cD=()=>wm||(wm=new wt({"fill-antialias":new U(F.paint_fill["fill-antialias"],"fill-antialias"),"fill-opacity":new ee(F.paint_fill["fill-opacity"],"fill-opacity"),"fill-layer-opacity":new U(F.paint_fill["fill-layer-opacity"],"fill-layer-opacity"),"fill-color":new ee(F.paint_fill["fill-color"],"fill-color"),"fill-outline-color":new ee(F.paint_fill["fill-outline-color"],"fill-outline-color"),"fill-translate":new U(F.paint_fill["fill-translate"],"fill-translate"),"fill-translate-anchor":new U(F.paint_fill["fill-translate-anchor"],"fill-translate-anchor"),"fill-pattern":new oo(F.paint_fill["fill-pattern"],"fill-pattern")})),dD={get paint(){return cD()},get layout(){return hD()}},pD=e=>e.type==="fill",fD=class extends ki{constructor(e,t){super(e,dD,t)}recalculate(e,t){super.recalculate(e,t);let i=this.paint._values["fill-outline-color"];i.value.kind==="constant"&&i.value.value===void 0&&(this.paint._values["fill-outline-color"]=this.paint._values["fill-color"])}createBucket(e){return new n1(e)}queryRadius(){return Zl(this.paint.get("fill-translate"))}queryIntersectsFeature({queryGeometry:e,geometry:t,transform:i,pixelsToTileUnits:r}){return $0(ql(e,this.paint.get("fill-translate"),this.paint.get("fill-translate-anchor"),-i.bearingInRadians,r),t)}isTileClipped(){return!0}},Ic=Je([{name:"a_pos",components:2,type:"Int16"},{name:"a_normal_ed",components:4,type:"Int16"}],4),mD=Je([{name:"a_centroid",components:2,type:"Int16"}],4),gD=Ic.members;Ic.size,Ic.alignment;var Ii=class Mc{constructor(){this.minX=1/0,this.maxX=-1/0,this.minY=1/0,this.maxY=-1/0}extend(t){return this.minX=Math.min(this.minX,t.x),this.minY=Math.min(this.minY,t.y),this.maxX=Math.max(this.maxX,t.x),this.maxY=Math.max(this.maxY,t.y),this}expandBy(t){return this.minX-=t,this.minY-=t,this.maxX+=t,this.maxY+=t,(this.minX>this.maxX||this.minY>this.maxY)&&(this.minX=1/0,this.maxX=-1/0,this.minY=1/0,this.maxY=-1/0),this}shrinkBy(t){return this.expandBy(-t)}map(t){let i=new Mc;return i.extend(t(new C(this.minX,this.minY))),i.extend(t(new C(this.maxX,this.minY))),i.extend(t(new C(this.minX,this.maxY))),i.extend(t(new C(this.maxX,this.maxY))),i}static fromPoints(t){let i=new Mc;for(let r of t)i.extend(r);return i}contains(t){return t.x>=this.minX&&t.x<=this.maxX&&t.y>=this.minY&&t.y<=this.maxY}empty(){return this.minX>this.maxX}width(){return this.maxX-this.minX}height(){return this.maxY-this.minY}covers(t){return!this.empty()&&!t.empty()&&t.minX>=this.minX&&t.maxX<=this.maxX&&t.minY>=this.minY&&t.maxY<=this.maxY}intersects(t){return!this.empty()&&!t.empty()&&t.minX<=this.maxX&&t.maxX>=this.minX&&t.minY<=this.maxY&&t.maxY>=this.minY}},_D=Ii.fromPoints([new C(0,0),new C(k,k)]);function ul(e,t){return e.x===t.x&&(e.x<0||e.x>8192)||e.y===t.y&&(e.y<0||e.y>8192)}function Tm(e){return e.every(t=>t.x<0)||e.every(t=>t.x>8192)||e.every(t=>t.y<0)||e.every(t=>t.y>8192)}var Po=class{constructor(e,t,i,r,a){for(this.properties=Object.create(null),this.extent=i,this.type=0,this.id=void 0,this._pbf=e,this._geometry=-1,this._keys=r,this._values=a;e.pos<t;){let n=e.readVarint();if(n===8)this.id=e.readVarint();else if(n===18){let o=e.readVarint()+e.pos;for(;e.pos<o;){let s=r[e.readVarint()],l=a[e.readVarint()];this.properties[s]=l}}else n===24?this.type=e.readVarint():(n===34&&(this._geometry=e.pos),e.skip(n))}}loadGeometry(){if(this._geometry<0)throw Error("feature has no geometry");let e=this._pbf;e.pos=this._geometry;let t=e.readVarint()+e.pos,i=[],r,a=1,n=0,o=0,s=0;for(;e.pos<t;){if(n<=0){let l=e.readVarint();if(a=l&7,n=l>>3,n===0)continue}if(n--,a===1)o+=e.readSVarint(),s+=e.readSVarint(),r&&i.push(r),r=[new C(o,s)];else if(a===2)o+=e.readSVarint(),s+=e.readSVarint(),r&&r.push(new C(o,s));else if(a===7)r&&r.push(r[0].clone());else throw Error(`unknown command ${a}`)}return r&&i.push(r),i}bbox(){if(this._geometry<0)throw Error("feature has no geometry");let e=this._pbf;e.pos=this._geometry;let t=e.readVarint()+e.pos,i=1,r=0,a=0,n=0,o=1/0,s=-1/0,l=1/0,u=-1/0;for(;e.pos<t;){if(r<=0){let h=e.readVarint();if(i=h&7,r=h>>3,r===0)continue}if(r--,i===1||i===2)a+=e.readSVarint(),n+=e.readSVarint(),a<o&&(o=a),a>s&&(s=a),n<l&&(l=n),n>u&&(u=n);else if(i!==7)throw Error(`unknown command ${i}`)}return[o,l,s,u]}toGeoJSON(e,t,i){let r=this.extent*2**i,a=this.extent*e,n=this.extent*t,o=this.loadGeometry();function s(c){return[(c.x+a)*360/r-180,360/Math.PI*Math.atan(Math.exp((1-(c.y+n)*2/r)*Math.PI))-90]}function l(c){return c.map(s)}let u;if(this.type===1){let c=[];for(let p of o)c.push(p[0]);let d=l(c);u=c.length===1?{type:"Point",coordinates:d[0]}:{type:"MultiPoint",coordinates:d}}else if(this.type===2){let c=o.map(l);u=c.length===1?{type:"LineString",coordinates:c[0]}:{type:"MultiLineString",coordinates:c}}else if(this.type===3){let c=o1(o),d=[];for(let p of c)d.push(p.map(l));u=d.length===1?{type:"Polygon",coordinates:d[0]}:{type:"MultiPolygon",coordinates:d}}else throw Error("unknown feature type");let h={type:"Feature",geometry:u,properties:this.properties};return this.id!=null&&(h.id=this.id),h}};Po.types=["Unknown","Point","LineString","Polygon"];function o1(e){let t=e.length;if(t<=1)return[e];let i=[],r,a;for(let n=0;n<t;n++){let o=yD(e[n]);o!==0&&(a===void 0&&(a=o<0),a===o<0?(r&&i.push(r),r=[e[n]]):r&&r.push(e[n]))}return r&&i.push(r),i}function yD(e){let t=0;for(let i=0,r=e.length,a=r-1,n,o;i<r;a=i++)n=e[i],o=e[a],t+=(o.x-n.x)*(n.y+o.y);return t}var vD=class{constructor(e,t){for(this.version=1,this.name="",this.extent=4096,this.length=0,this._pbf=e,this._keys=[],this._values=[],this._features=[],t===void 0&&(t=e.length);e.pos<t;){let i=e.readVarint();i===10?this.name=e.readString():i===18?(this._features.push(e.pos),e.skip(i)):i===26?this._keys.push(e.readString()):i===34?this._values.push(xD(e)):i===40?this.extent=e.readVarint():i===120?this.version=e.readVarint():e.skip(i)}this.length=this._features.length}feature(e){if(e<0||e>=this._features.length)throw Error("feature index out of bounds");this._pbf.pos=this._features[e];let t=this._pbf.readVarint()+this._pbf.pos;return new Po(this._pbf,t,this.extent,this._keys,this._values)}};function xD(e){let t=null,i=e.readVarint()+e.pos;for(;e.pos<i;){let r=e.readVarint();t=r===10?e.readString():r===21?e.readFloat():r===25?e.readDouble():r===32?e.readVarint(!0):r===40?e.readVarint():r===48?e.readSVarint():r===56?e.readBoolean():(e.skip(r),null)}if(t==null)throw Error("unknown feature value");return t}var bD=class{constructor(e,t=e.length){let i=Object.create(null);for(;e.pos<t;){let r=e.readVarint();if(r===26){let a=new vD(e,e.readVarint()+e.pos);a.length&&(i[a.name]=a)}else e.skip(r)}this.layers=i}},jt=63710088e-1,X=class Ln{constructor(t,i){if(isNaN(t)||isNaN(i))throw Error(`Invalid LngLat object: (${t}, ${i})`);if(this.lng=+t,this.lat=+i,this.lat>90||this.lat<-90)throw Error("Invalid LngLat latitude value: must be between -90 and 90")}wrap(){return new Ln(vi(this.lng,-180,180),this.lat)}toArray(){return[this.lng,this.lat]}toString(){return`LngLat(${this.lng}, ${this.lat})`}distanceTo(t){let i=Math.PI/180,r=this.lat*i,a=t.lat*i,n=Math.sin(r)*Math.sin(a)+Math.cos(r)*Math.cos(a)*Math.cos((t.lng-this.lng)*i);return jt*Math.acos(Math.min(n,1))}static convert(t){if(t instanceof Ln)return t;if(Array.isArray(t)&&(t.length===2||t.length===3))return new Ln(Number(t[0]),Number(t[1]));if(!Array.isArray(t)&&typeof t=="object"&&t)return new Ln(Number("lng"in t?t.lng:t.lon),Number(t.lat));throw Error("`LngLatLike` argument must be specified as a LngLat instance, an object {lng: <lng>, lat: <lat>}, an object {lon: <lng>, lat: <lat>}, or an array of [<lng>, <lat>]")}},s1=2*Math.PI*jt;function l1(e){return s1*Math.cos(e*Math.PI/180)}function Ja(e){return(180+e)/360}function Qa(e){return(180-180/Math.PI*Math.log(Math.tan(Math.PI/4+e*Math.PI/360)))/360}function en(e,t){return e/l1(t)}function Fc(e){return e*360-180}function fo(e){let t=180-e*360;return 360/Math.PI*Math.atan(Math.exp(t*Math.PI/180))-90}function u1(e,t){return e*l1(fo(t))}function wD(e){return 1/Math.cos(e*Math.PI/180)}var De=class h1{constructor(t,i,r=0){this.x=+t,this.y=+i,this.z=+r}static fromLngLat(t,i=0){let r=X.convert(t);return new h1(Ja(r.lng),Qa(r.lat),en(i,r.lat))}toLngLat(){return new X(Fc(this.x),fo(this.y))}toAltitude(){return u1(this.z,this.y)}meterInMercatorCoordinateUnits(){return 1/s1*wD(fo(this.y))}},La=89.25;function c1(e,t,i){let r=1/(1<<i.z);return new De(e/k*r+i.x*r,t/k*r+i.y*r)}function TD(e,t,i){return c1(e,t,i).toLngLat()}function Ui(e,t){let i=ie(t.lat,-85.051129,ur);return new C(Ja(t.lng)*e,Qa(i)*e)}function mo(e,t){return new De(t.x/e,t.y/e).toLngLat()}function Wn(e){return e.cameraToCenterDistance*Math.min(Math.tan(je(90-e.pitch))*.85,Math.tan(je(La-e.pitch)))}function Yu(e,t){let i=e.canonical,r=t/It(i.z),a=i.x+2**i.z*e.wrap,n=new Float64Array(16);return Mi(n),lt(n,n,[a*r,i.y*r,0]),kt(n,n,[r/k,r/k,1]),n}function d1(e,t,i,r,a){let n=De.fromLngLat(e,t),o=a*en(1,e.lat),{x:s,y:l,z:u}=zc(i,r),h=o*-s,c=o*-l,d=o*u;return new De(n.x+h,n.y+c,n.z+d)}function ED(e,t=e.center){let i=en(1,t.lat)*e.worldSize;return d1(t,e.elevation,e.pitch,e.bearing,e.cameraToCenterDistance/i)}function zc(e,t){let i=je(e),r=je(t),a=Math.cos(-i),n=Math.sin(i);return{x:n*Math.sin(r),y:-n*Math.cos(r),z:a}}function DD(e,t){return t<=0||!e||e.length===0?e:e.map(i=>AD(i,t))}function SD(e,t){let i=TD(k/2,k/2,t),r=De.fromLngLat(i).meterInMercatorCoordinateUnits(),a=(1<<t.z)*k;return e*r*a}var CD=Math.cos(35*Math.PI/180);function PD(e){let t=[null];for(let n=1;n<e.length;n++){let o=e[n].sub(e[n-1]),s=!ul(e[n],e[n-1])&&o.mag()>0;t.push(s?o._perp():null)}let i=e.length-1,r=i>1&&e[0].equals(e[i]),a=[null];for(let n=1;n<=i;n++){let o=t[n];if(!o){a.push(null);continue}let s=r&&n===1?t[i]:t[n-1],l=r&&n===i?t[1]:t[n+1];a.push({start:Em(o,s),end:Em(o,l)})}return a}function Em(e,t){if(!t)return e.unit();let i=e.mag(),r=t.mag();return e.x*t.x+e.y*t.y<CD*i*r||i>=2*r?e.unit():r>=2*i?t.unit():e.add(t)._unit()}function AD(e,t){if(!e||e.length<3)return e;let i=e[0].x===e[e.length-1].x&&e[0].y===e[e.length-1].y,r=i?e.length-1:e.length;if(r<3)return e;let a=[],n=ul(e[r-1],e[0]);for(let s=0;s<r;s++){let l=e[(s-1+r)%r],u=e[s],h=e[(s+1)%r],c=ul(u,h);n||c?a.push(u.clone()):MD(a,l,u,h,t),n=c}let o=ID(a);return o.length<3?e:(i&&o.push(o[0].clone()),o)}function ID(e){let t=[];for(let i of e){let r=i.round(),a=t[t.length-1];(a?.x!==r.x||a?.y!==r.y)&&t.push(r)}for(;t.length>1&&t[0].x===t[t.length-1].x&&t[0].y===t[t.length-1].y;)t.pop();return t}function MD(e,t,i,r,a){let n=t.sub(i),o=r.sub(i),s=n.mag(),l=o.mag();if(s<1e-6||l<1e-6){e.push(i.clone());return}n._div(s),o._div(l);let u=n.x*o.x+n.y*o.y;if(Math.abs(u)>Math.cos(5*Math.PI/180)){e.push(i.clone());return}let h=.2,c=Math.min(a,s*h,l*h),d=i.add(n.mult(c)),p=i.add(o.mult(c)),f=Math.sqrt((1+u)/2),m=i.add(n.add(o)._unit()._mult(c/f)),g=d.sub(m).angleWith(p.sub(m)),_=Math.max(2,Math.ceil(Math.abs(g)/(Math.PI/6)-1e-6));for(let y=0;y<=_;y++)e.push(d.rotateAround(y/_*g,m))}var Ku=8192;function bn(e,t,i,r,a,n,o,s){e.emplaceBack(t,i,Math.floor(r*Ku)*2+o,a*Ku*2,n*Ku*2,Math.round(s))}var p1=class{constructor(e){this.zoom=e.zoom,this.overscaling=e.overscaling,this.layers=e.layers,this.layerIds=this.layers.map(t=>t.id),this.index=e.index,this.hasDependencies=!1,this.layoutVertexArray=new UT,this.centroidVertexArray=new Gr,this.indexArray=new Xi,this.programConfigurations=new ea(e.layers,e.zoom),this.segments=new Ye,this.stateDependentLayerIds=this.layers.filter(t=>t.isStateDependent()).map(t=>t.id)}populate(e,t,i){this.features=[],this.hasDependencies=ol("fill-extrusion",this.layers,t);let r=new Ae(this.zoom),a=this.layers[0],n=a.layout.get("fill-extrusion-rounded-corner-distance"),o=n>0?SD(n,i):0,s=a._featureFilter.needGeometry;for(let{feature:l,id:u,index:h,sourceLayerIndex:c}of e){let d=la(l,s);if(!a._featureFilter.filter(r,d,i))continue;let p={id:u,sourceLayerIndex:c,index:h,geometry:DD(s?d.geometry:sa(l),o),properties:l.properties,type:l.type,patterns:{}};this.hasDependencies?this.features.push(Hd("fill-extrusion",this.layers,p,{zoom:this.zoom},t)):this.addFeature(p,p.geometry,h,i,{},t.subdivisionGranularity),t.featureIndex.insert(l,p.geometry,h,c,this.index,!0)}}addFeatures({options:e,canonical:t,patternPositions:i}){for(let r of this.features){let{geometry:a}=r;this.addFeature(r,a,r.index,t,i,e.subdivisionGranularity)}}update(e,t,i){this.stateDependentLayers.length&&this.programConfigurations.updatePaintArrays(e,t,this.stateDependentLayers,{imagePositions:i})}isEmpty(){return this.layoutVertexArray.length===0&&this.centroidVertexArray.length===0}uploadPending(){return!this.uploaded||this.programConfigurations.needsUpload}upload(e){this.uploaded||(this.layoutVertexBuffer=e.createVertexBuffer(this.layoutVertexArray,gD),this.centroidVertexBuffer=e.createVertexBuffer(this.centroidVertexArray,mD.members,!0),this.indexBuffer=e.createIndexBuffer(this.indexArray)),this.programConfigurations.upload(e),this.uploaded=!0}destroy(){this.layoutVertexBuffer&&(this.layoutVertexBuffer.destroy(),this.indexBuffer.destroy(),this.programConfigurations.destroy(),this.segments.destroy(),this.centroidVertexBuffer.destroy())}addFeature(e,t,i,r,a,n){for(let o of zl(t,500)){let s={x:0,y:0,sampleCount:0},l=this.layoutVertexArray.length;this.processPolygon(s,r,e,o,n);let u=this.layoutVertexArray.length-l,h=Math.floor(s.x/s.sampleCount),c=Math.floor(s.y/s.sampleCount);for(let d=0;d<u;d++)this.centroidVertexArray.emplaceBack(h,c)}this.programConfigurations.populatePaintArrays(this.layoutVertexArray.length,e,i,{imagePositions:a,canonical:r})}processPolygon(e,t,i,r,a){if(r.length<1||Tm(r[0]))return;for(let h of r)h.length!==0&&FD(e,h);let n={segment:this.segments.prepareSegment(4,this.layoutVertexArray,this.indexArray)},o=a.fill.getGranularityForZoomLevel(t.z),s=Po.types[i.type]==="Polygon";for(let h of r){if(h.length===0||Tm(h))continue;let c=Zr(h,o,s);this._generateSideFaces(c,n)}if(!s)return;let l=i1(r,t,o,!1),u=this.layoutVertexArray;a1((h,c)=>{bn(u,h,c,0,0,1,1,0)},this.segments,this.layoutVertexArray,this.indexArray,l.verticesFlattened,l.indicesTriangles)}_generateSideFaces(e,t){let i=0,r=this.layers[0].layout.get("fill-extrusion-rounded-corner-distance")>0?PD(e):null;for(let a=1;a<e.length;a++){let n=e[a],o=e[a-1];if(ul(n,o)||r&&!r[a])continue;t.segment.vertexLength+4>Ye.MAX_VERTEX_ARRAY_LENGTH&&(t.segment=this.segments.prepareSegment(4,this.layoutVertexArray,this.indexArray));let s=n.sub(o)._perp()._unit(),{start:l,end:u}=r?r[a]:{start:s,end:s},h=o.dist(n);i+h>32768&&(i=0),bn(this.layoutVertexArray,n.x,n.y,u.x,u.y,0,0,i),bn(this.layoutVertexArray,n.x,n.y,u.x,u.y,0,1,i),i+=h,bn(this.layoutVertexArray,o.x,o.y,l.x,l.y,0,0,i),bn(this.layoutVertexArray,o.x,o.y,l.x,l.y,0,1,i);let c=t.segment.vertexLength;this.indexArray.emplaceBack(c,c+2,c+1),this.indexArray.emplaceBack(c+1,c+2,c+3),t.segment.vertexLength+=4,t.segment.primitiveLength+=2}}};function FD(e,t){for(let i=0;i<t.length;i++){let r=t[i];(i!==t.length-1||t[0].x!==r.x||t[0].y!==r.y)&&(e.x+=r.x,e.y+=r.y,e.sampleCount++)}}G("FillExtrusionBucket",p1,{omit:["layers","features"]});var Dm,zD=()=>Dm||(Dm=new wt({"fill-extrusion-rounded-corner-distance":new U(F["layout_fill-extrusion"]["fill-extrusion-rounded-corner-distance"],"fill-extrusion-rounded-corner-distance")})),Sm,RD=()=>Sm||(Sm=new wt({"fill-extrusion-opacity":new U(F["paint_fill-extrusion"]["fill-extrusion-opacity"],"fill-extrusion-opacity"),"fill-extrusion-color":new ee(F["paint_fill-extrusion"]["fill-extrusion-color"],"fill-extrusion-color"),"fill-extrusion-translate":new U(F["paint_fill-extrusion"]["fill-extrusion-translate"],"fill-extrusion-translate"),"fill-extrusion-translate-anchor":new U(F["paint_fill-extrusion"]["fill-extrusion-translate-anchor"],"fill-extrusion-translate-anchor"),"fill-extrusion-pattern":new oo(F["paint_fill-extrusion"]["fill-extrusion-pattern"],"fill-extrusion-pattern"),"fill-extrusion-height":new ee(F["paint_fill-extrusion"]["fill-extrusion-height"],"fill-extrusion-height"),"fill-extrusion-base":new ee(F["paint_fill-extrusion"]["fill-extrusion-base"],"fill-extrusion-base"),"fill-extrusion-vertical-gradient":new U(F["paint_fill-extrusion"]["fill-extrusion-vertical-gradient"],"fill-extrusion-vertical-gradient")})),kD={get paint(){return RD()},get layout(){return zD()}},LD=e=>e.type==="fill-extrusion",BD=class extends ki{constructor(e,t){super(e,kD,t)}createBucket(e){return new p1(e)}queryRadius(){return Zl(this.paint.get("fill-extrusion-translate"))}is3D(){return!0}queryIntersectsFeature({queryGeometry:e,feature:t,featureState:i,geometry:r,transform:a,pixelsToTileUnits:n,pixelPosMatrix:o}){let s=ql(e,this.paint.get("fill-extrusion-translate"),this.paint.get("fill-extrusion-translate-anchor"),-a.bearingInRadians,n),l=this.paint.get("fill-extrusion-height").evaluate(t,i),u=this.paint.get("fill-extrusion-base").evaluate(t,i),h=VD(s,o,0),c=jD(r,u,l,o),d=c[0],p=c[1];return OD(d,p,h)}};function wn(e,t){return e.x*t.x+e.y*t.y}function Cm(e,t){if(e.length===1){let i=0,r=t[i++],a;for(;!a||r.equals(a);)if(a=t[i++],!a)return 1/0;for(;i<t.length;i++){let n=t[i],o=e[0],s=a.sub(r),l=n.sub(r),u=o.sub(r),h=wn(s,s),c=wn(s,l),d=wn(l,l),p=wn(u,s),f=wn(u,l),m=h*d-c*c,g=(d*p-c*f)/m,_=(h*f-c*p)/m,y=1-g-_,v=r.z*y+a.z*g+n.z*_;if(isFinite(v))return v}return 1/0}{let i=1/0;for(let r of t)i=Math.min(i,r.z);return i}}function OD(e,t,i){let r=1/0;$0(i,t)&&(r=Cm(i,t[0]));for(let a=0;a<t.length;a++){let n=t[a],o=e[a];for(let s=0;s<n.length-1;s++){let l=n[s],u=n[s+1],h=o[s],c=[l,u,o[s+1],h,l];U0(i,c)&&(r=Math.min(r,Cm(i,c)))}}return r!==1/0&&r}function jD(e,t,i,r){let a=[],n=[],o=r[8]*t,s=r[9]*t,l=r[10]*t,u=r[11]*t,h=r[8]*i,c=r[9]*i,d=r[10]*i,p=r[11]*i;for(let f of e){let m=[],g=[];for(let _ of f){let y=_.x,v=_.y,x=r[0]*y+r[4]*v+r[12],b=r[1]*y+r[5]*v+r[13],w=r[2]*y+r[6]*v+r[14],T=r[3]*y+r[7]*v+r[15],E=x+o,S=b+s,M=w+l,z=T+u,R=x+h,I=b+c,D=w+d,P=T+p,A=new C(E/z,S/z);A.z=M/z,m.push(A);let B=new C(R/P,I/P);B.z=D/P,g.push(B)}a.push(m),n.push(g)}return[a,n]}function VD(e,t,i){let r=[];for(let a of e){let n=[a.x,a.y,i,1];Pt(n,n,t),r.push(new C(n[0]/n[3],n[1]/n[3]))}return r}var Rc=Je([{name:"a_pos_normal",components:2,type:"Int16"},{name:"a_data",components:4,type:"Uint8"},{name:"a_offset_normal",components:2,type:"Int8"}],2),ND=Rc.members;Rc.size,Rc.alignment;var kc=Je([{name:"a_uv_x",components:1,type:"Float32"},{name:"a_split_index",components:1,type:"Float32"}]),UD=kc.members;kc.size,kc.alignment;var $D=Math.cos(75/2*(Math.PI/180)),f1=1/2,Pm=2**14/f1,m1=class{constructor(e){this.zoom=e.zoom,this.overscaling=e.overscaling,this.layers=e.layers,this.layerIds=this.layers.map(t=>t.id),this.index=e.index,this.hasDependencies=!1,this.patternFeatures=[],this.lineClipsArray=[],this.gradients={};for(let t of this.layers)this.gradients[t.id]={};this.layoutVertexArray=new $T,this.layoutVertexArray2=new GT,this.indexArray=new Xi,this.programConfigurations=new ea(e.layers,e.zoom),this.segments=new Ye,this.maxLineLength=0,this.stateDependentLayerIds=this.layers.filter(t=>t.isStateDependent()).map(t=>t.id)}populate(e,t,i){this.hasDependencies=ol("line",this.layers,t)||this.hasLineDasharray(this.layers);let r=this.layers[0].layout.get("line-sort-key"),a=!r.isConstant(),n=[],o=new Ae(this.zoom),s=this.layers[0]._featureFilter.needGeometry;for(let{feature:l,id:u,index:h,sourceLayerIndex:c}of e){let d=la(l,s);if(!this.layers[0]._featureFilter.filter(o,d,i))continue;let p=a?r.evaluate(d,{},i):void 0,f={id:u,properties:l.properties,type:l.type,sourceLayerIndex:c,index:h,geometry:s?d.geometry:sa(l),patterns:{},dashes:{},sortKey:p};n.push(f)}a&&n.sort((l,u)=>l.sortKey-u.sortKey);for(let l of n){let{geometry:u,index:h,sourceLayerIndex:c}=l;this.hasDependencies?(ol("line",this.layers,t)?Hd("line",this.layers,l,{zoom:this.zoom},t):this.hasLineDasharray(this.layers)&&this.addLineDashDependencies(this.layers,l,this.zoom,t),this.patternFeatures.push(l)):this.addFeature(l,u,h,i,{},{},t.subdivisionGranularity);let d=e[h].feature;t.featureIndex.insert(d,u,h,c,this.index)}}update(e,t,i,r){this.stateDependentLayers.length&&this.programConfigurations.updatePaintArrays(e,t,this.stateDependentLayers,{imagePositions:i,dashPositions:r})}addFeatures({options:e,canonical:t,patternPositions:i,dashPositions:r}){for(let a of this.patternFeatures)this.addFeature(a,a.geometry,a.index,t,i,r,e.subdivisionGranularity)}isEmpty(){return this.layoutVertexArray.length===0}uploadPending(){return!this.uploaded||this.programConfigurations.needsUpload}upload(e){this.uploaded||(this.layoutVertexArray2.length!==0&&(this.layoutVertexBuffer2=e.createVertexBuffer(this.layoutVertexArray2,UD)),this.layoutVertexBuffer=e.createVertexBuffer(this.layoutVertexArray,ND),this.indexBuffer=e.createIndexBuffer(this.indexArray)),this.programConfigurations.upload(e),this.uploaded=!0}destroy(){this.layoutVertexBuffer&&(this.layoutVertexBuffer.destroy(),this.indexBuffer.destroy(),this.programConfigurations.destroy(),this.segments.destroy())}lineFeatureClips(e){if(e.properties&&Object.hasOwn(e.properties,"geojsonvt_clip_start")&&Object.hasOwn(e.properties,"geojsonvt_clip_end"))return{start:+e.properties.geojsonvt_clip_start,end:+e.properties.geojsonvt_clip_end}}addFeature(e,t,i,r,a,n,o){let s=this.layers[0].layout,l=s.get("line-join").evaluate(e,{}),u=s.get("line-cap").evaluate(e,{}),h=s.get("line-miter-limit").evaluate(e,{}),c=s.get("line-round-limit").evaluate(e,{});this.lineClips=this.lineFeatureClips(e);for(let d of t)this.addLine(d,e,l,u,h,c,r,o);this.programConfigurations.populatePaintArrays(this.layoutVertexArray.length,e,i,{imagePositions:a,dashPositions:n,canonical:r})}addLine(e,t,i,r,a,n,o,s){this.distance=0,this.scaledDistance=0,this.totalDistance=0;let l=o?s.line.getGranularityForZoomLevel(o.z):1;if(e=Zr(e,l),this.lineClips){this.lineClipsArray.push(this.lineClips);for(let v=0;v<e.length-1;v++)this.totalDistance+=e[v].dist(e[v+1]);this.updateScaledDistance(),this.maxLineLength=Math.max(this.maxLineLength,this.totalDistance)}let u=Po.types[t.type]==="Polygon",h=e.length;for(;h>=2&&e[h-1].equals(e[h-2]);)h--;let c=0;for(;c<h-1&&e[c].equals(e[c+1]);)c++;if(h-c<(u?3:2))return;i==="bevel"&&(a=1.05);let d=this.overscaling<=16?15*k/(512*this.overscaling):0,p=this.segments.prepareSegment(h*10,this.layoutVertexArray,this.indexArray),f,m,g,_,y;this.e1=this.e2=-1,u&&(f=e[h-2],y=e[c].sub(f)._unit()._perp());for(let v=c;v<h;v++){if(g=v===h-1?u?e[c+1]:void 0:e[v+1],g&&e[v].equals(g))continue;y&&(_=y),f&&(m=f),f=e[v],y=g?g.sub(f)._unit()._perp():_,_||(_=y);let x=_.add(y);(x.x!==0||x.y!==0)&&x._unit();let b=_.x*y.x+_.y*y.y,w=x.x*y.x+x.y*y.y,T=w===0?1/0:1/w,E=2*Math.sqrt(2-2*w),S=w<$D&&m&&g,M=_.x*y.y-_.y*y.x>0,z=x.mult(Math.min(T,2)),R=ie((T-3)/5,0,1);if(S&&v>c){let P=f.dist(m);if(P>2*d){let A=f.sub(f.sub(m)._mult(d/P)._round());this.updateDistance(m,A),this.addCurrentVertex(A,_,0,0,p),m=A}}let I=m&&g,D=I?i:u?"butt":r;if(I&&D==="round"&&(T<n?D="miter":T<=2&&(D="fakeround")),D==="miter"&&T>a&&(D="bevel"),D==="bevel"&&(T>2&&(D="flipbevel"),T<a&&(D="miter")),m&&this.updateDistance(m,f),D==="miter")x._mult(T),this.addCurrentVertex(f,x,0,0,p,!1,z);else if(D==="flipbevel"){if(T>100)x=y.mult(-1);else{let P=T*_.add(y).mag()/_.sub(y).mag();x._perp()._mult(P*(M?-1:1))}this.addCurrentVertex(f,x,0,0,p,!1,z,R),this.addCurrentVertex(f,x.mult(-1),0,0,p,!1,z,R)}else if(D==="bevel"||D==="fakeround"){let P=-Math.sqrt(T*T-1),A=M?P:0,B=M?0:P;if(m&&this.addCurrentVertex(f,_,A,B,p,!1,z),D==="fakeround"){let j=Math.round(E*180/Math.PI/20);for(let V=1;V<j;V++){let J=V/j;if(J!==.5){let fe=J-.5,ye=1.0904+b*(-3.2452+b*(3.55645-b*1.43519)),Ge=.848013+b*(-1.06021+b*.215638);J+=J*fe*(J-1)*(ye*fe*fe+Ge)}let se=y.sub(_)._mult(J)._add(_)._unit()._mult(M?-1:1);this.addHalfVertex(f,se.x,se.y,M?-z.x:z.x,M?-z.y:z.y,!1,M,p)}}g&&this.addCurrentVertex(f,y,-A,-B,p,!1,z)}else if(D==="butt")this.addCurrentVertex(f,x,0,0,p,!1,z);else if(D==="square"){let P=m?1:-1;this.addCurrentVertex(f,x,P,P,p,!1,z)}else D==="round"&&(m&&(this.addCurrentVertex(f,_,0,0,p,!1,z,R),this.addCurrentVertex(f,_,1,1,p,!0,z,R)),g&&(this.addCurrentVertex(f,y,-1,-1,p,!0,z,R),this.addCurrentVertex(f,y,0,0,p,!1,z,R)));if(S&&v<h-1){let P=f.dist(g);if(P>2*d){let A=f.add(g.sub(f)._mult(d/P)._round());this.updateDistance(f,A),this.addCurrentVertex(A,y,0,0,p),f=A}}}}addCurrentVertex(e,t,i,r,a,n=!1,o=t,s=0){let l=t.x+t.y*i,u=t.y-t.x*i,h=-t.x+t.y*r,c=-t.y-t.x*r,d=o.x+(t.x-o.x)*s,p=o.y+(t.y-o.y)*s;this.addHalfVertex(e,l,u,d,p,n,!1,a),this.addHalfVertex(e,h,c,-d,-p,n,!0,a),this.distance>Pm/2&&this.totalDistance===0&&(this.distance=0,this.updateScaledDistance(),this.addCurrentVertex(e,t,i,r,a,n,o,s))}addHalfVertex({x:e,y:t},i,r,a,n,o,s,l){let u=(this.lineClips?this.scaledDistance*(Pm-1):this.scaledDistance)*f1;if(this.layoutVertexArray.emplaceBack((e<<1)+ +!!o,(t<<1)+ +!!s,Math.round(63*i)+128,Math.round(63*r)+128,(u&63)<<2,u>>6,Math.round(63*a),Math.round(63*n)),this.lineClips){let c=(this.scaledDistance-this.lineClips.start)/(this.lineClips.end-this.lineClips.start);this.layoutVertexArray2.emplaceBack(c,this.lineClipsArray.length)}let h=l.vertexLength++;this.e1>=0&&this.e2>=0&&(this.indexArray.emplaceBack(this.e1,h,this.e2),l.primitiveLength++),s?this.e2=h:this.e1=h}updateScaledDistance(){this.scaledDistance=this.lineClips?this.lineClips.start+(this.lineClips.end-this.lineClips.start)*this.distance/this.totalDistance:this.distance}updateDistance(e,t){this.distance+=e.dist(t),this.updateScaledDistance()}hasLineDasharray(e){for(let t of e){let i=t.paint.get("line-dasharray");if(i&&!i.isConstant())return!0}return!1}addLineDashDependencies(e,t,i,r){for(let a of e){let n=a.paint.get("line-dasharray");if(!n||n.value.kind==="constant")continue;let o=a.layout.get("line-cap").evaluate(t,{})==="round",s={dasharray:n.value.evaluate({zoom:i-1},t,{}),round:o},l={dasharray:n.value.evaluate({zoom:i},t,{}),round:o},u={dasharray:n.value.evaluate({zoom:i+1},t,{}),round:o},h=`${s.dasharray.join(",")},${s.round}`,c=`${l.dasharray.join(",")},${l.round}`,d=`${u.dasharray.join(",")},${u.round}`;r.dashDependencies[h]=s,r.dashDependencies[c]=l,r.dashDependencies[d]=u,t.dashes[a.id]={min:h,mid:c,max:d}}}};G("LineBucket",m1,{omit:["layers","patternFeatures"]});var Am,GD=()=>Am||(Am=new wt({"line-cap":new ee(F.layout_line["line-cap"],"line-cap"),"line-join":new ee(F.layout_line["line-join"],"line-join"),"line-miter-limit":new ee(F.layout_line["line-miter-limit"],"line-miter-limit"),"line-round-limit":new ee(F.layout_line["line-round-limit"],"line-round-limit"),"line-sort-key":new ee(F.layout_line["line-sort-key"],"line-sort-key")})),Im,ZD=()=>Im||(Im=new wt({"line-opacity":new ee(F.paint_line["line-opacity"],"line-opacity"),"line-layer-opacity":new U(F.paint_line["line-layer-opacity"],"line-layer-opacity"),"line-color":new ee(F.paint_line["line-color"],"line-color"),"line-translate":new U(F.paint_line["line-translate"],"line-translate"),"line-translate-anchor":new U(F.paint_line["line-translate-anchor"],"line-translate-anchor"),"line-width":new ee(F.paint_line["line-width"],"line-width"),"line-gap-width":new ee(F.paint_line["line-gap-width"],"line-gap-width"),"line-offset":new ee(F.paint_line["line-offset"],"line-offset"),"line-blur":new ee(F.paint_line["line-blur"],"line-blur"),"line-dasharray":new oo(F.paint_line["line-dasharray"],"line-dasharray"),"line-pattern":new oo(F.paint_line["line-pattern"],"line-pattern"),"line-gradient":new $l(F.paint_line["line-gradient"],"line-gradient")})),Mm={get paint(){return ZD()},get layout(){return GD()}},qD=class extends ee{possiblyEvaluate(e,t){return t=new Ae(Math.floor(t.zoom),{now:t.now,fadeDuration:t.fadeDuration,zoomHistory:t.zoomHistory,transition:t.transition}),super.possiblyEvaluate(e,t)}evaluate(e,t,i,r){return t=q({},t,{zoom:Math.floor(t.zoom)}),super.evaluate(e,t,i,r)}},ds,WD=e=>e.type==="line",HD=class extends ki{constructor(e,t){super(e,Mm,t),this.gradientVersion=0,ds||(ds=new qD(Mm.paint.properties["line-width"].specification,"line-floorwidth"),ds.useIntegerZoom=!0)}_handleSpecialPaintPropertyUpdate(e){if(e==="line-gradient"){let t=this.gradientExpression();this.stepInterpolant=eT(t)?t._styleExpression.expression instanceof Ed:!1,this.gradientVersion=(this.gradientVersion+1)%(2**53-1)}}gradientExpression(){return this._transitionablePaint._values["line-gradient"].value.expression}recalculate(e,t){super.recalculate(e,t),this.paint._values["line-floorwidth"]=ds.possiblyEvaluate(this._transitioningPaint._values["line-width"].value,e)}createBucket(e){return new m1(e)}queryRadius(e){let t=e,i=Fm(ka("line-width",this,t),ka("line-gap-width",this,t)),r=ka("line-offset",this,t);return i/2+Math.abs(r)+Zl(this.paint.get("line-translate"))}queryIntersectsFeature({queryGeometry:e,feature:t,featureState:i,geometry:r,transform:a,pixelsToTileUnits:n}){let o=ql(e,this.paint.get("line-translate"),this.paint.get("line-translate-anchor"),-a.bearingInRadians,n),s=n/2*Fm(this.paint.get("line-width").evaluate(t,i),this.paint.get("line-gap-width").evaluate(t,i)),l=this.paint.get("line-offset").evaluate(t,i);return l&&(r=pE(r,l*n)),sE(o,r,s)}isTileClipped(){return!0}};function Fm(e,t){return t>0?t+2*e:e}var XD=Je([{name:"a_pos_offset",components:4,type:"Int16"},{name:"a_data",components:4,type:"Uint16"},{name:"a_pixeloffset",components:4,type:"Int16"},{name:"a_height_offset",components:1,type:"Float32"}],4),YD=Je([{name:"a_projected_pos",components:3,type:"Float32"}],4);Je([{name:"a_fade_opacity",components:1,type:"Uint32"}],4);var KD=Je([{name:"a_placed",components:2,type:"Uint8"},{name:"a_shift",components:2,type:"Float32"},{name:"a_box_real",components:2,type:"Int16"}]);Je([{type:"Int16",name:"anchorPointX"},{type:"Int16",name:"anchorPointY"},{type:"Int16",name:"x1"},{type:"Int16",name:"y1"},{type:"Int16",name:"x2"},{type:"Int16",name:"y2"},{type:"Uint32",name:"featureIndex"},{type:"Uint16",name:"sourceLayerIndex"},{type:"Uint16",name:"bucketIndex"}]);var zm=Je([{name:"a_pos",components:2,type:"Int16"},{name:"a_anchor_pos",components:2,type:"Int16"},{name:"a_extrude",components:2,type:"Int16"}],4),JD=Je([{name:"a_pos",components:2,type:"Float32"},{name:"a_radius",components:1,type:"Float32"},{name:"a_flags",components:2,type:"Int16"}],4);Je([{name:"triangle",components:3,type:"Uint16"}]),Je([{type:"Int16",name:"anchorX"},{type:"Int16",name:"anchorY"},{type:"Uint16",name:"glyphStartIndex"},{type:"Uint16",name:"numGlyphs"},{type:"Uint32",name:"vertexStartIndex"},{type:"Uint32",name:"lineStartIndex"},{type:"Uint32",name:"lineLength"},{type:"Uint16",name:"segment"},{type:"Uint16",name:"lowerSize"},{type:"Uint16",name:"upperSize"},{type:"Float32",name:"lineOffsetX"},{type:"Float32",name:"lineOffsetY"},{type:"Uint8",name:"writingMode"},{type:"Uint8",name:"placedOrientation"},{type:"Uint8",name:"hidden"},{type:"Uint32",name:"crossTileID"},{type:"Int16",name:"associatedIconIndex"},{type:"Float32",name:"heightOffset"}]);var QD=Je([{type:"Int16",name:"anchorX"},{type:"Int16",name:"anchorY"},{type:"Int16",name:"rightJustifiedTextSymbolIndex"},{type:"Int16",name:"centerJustifiedTextSymbolIndex"},{type:"Int16",name:"leftJustifiedTextSymbolIndex"},{type:"Int16",name:"verticalPlacedTextSymbolIndex"},{type:"Int16",name:"placedIconSymbolIndex"},{type:"Int16",name:"verticalPlacedIconSymbolIndex"},{type:"Uint16",name:"key"},{type:"Uint16",name:"textBoxStartIndex"},{type:"Uint16",name:"textBoxEndIndex"},{type:"Uint16",name:"verticalTextBoxStartIndex"},{type:"Uint16",name:"verticalTextBoxEndIndex"},{type:"Uint16",name:"iconBoxStartIndex"},{type:"Uint16",name:"iconBoxEndIndex"},{type:"Uint16",name:"verticalIconBoxStartIndex"},{type:"Uint16",name:"verticalIconBoxEndIndex"},{type:"Uint16",name:"featureIndex"},{type:"Uint16",name:"numHorizontalGlyphVertices"},{type:"Uint16",name:"numVerticalGlyphVertices"},{type:"Uint16",name:"numIconVertices"},{type:"Uint16",name:"numVerticalIconVertices"},{type:"Uint16",name:"useRuntimeCollisionCircles"},{type:"Uint32",name:"crossTileID"},{type:"Float32",name:"textBoxScale"},{type:"Float32",name:"collisionCircleDiameter"},{type:"Uint16",name:"textAnchorOffsetStartIndex"},{type:"Uint16",name:"textAnchorOffsetEndIndex"},{type:"Float32",name:"heightOffset"}]);Je([{type:"Float32",name:"offsetX"}]),Je([{type:"Int16",name:"x"},{type:"Int16",name:"y"},{type:"Int16",name:"tileUnitDistanceFromAnchor"}]),Je([{type:"Uint16",name:"textAnchor"},{type:"Float32",components:2,name:"textOffset"}]);var hl=new class{constructor(){this.TIMEOUT=5e3,this.applyArabicShaping=null,this.processBidirectionalText=null,this.processStyledBidirectionalText=null,this.pluginStatus="unavailable",this.pluginURL=null,this.loadScriptResolve=()=>{}}setState(e){this.pluginStatus=e.pluginStatus,this.pluginURL=e.pluginURL}getState(){return{pluginStatus:this.pluginStatus,pluginURL:this.pluginURL}}setMethods(e){if(hl.isParsed())throw Error("RTL text plugin already registered.");this.applyArabicShaping=e.applyArabicShaping,this.processBidirectionalText=e.processBidirectionalText,this.processStyledBidirectionalText=e.processStyledBidirectionalText,this.loadScriptResolve()}isParsed(){return this.applyArabicShaping!=null&&this.processBidirectionalText!=null&&this.processStyledBidirectionalText!=null}getRTLTextPluginStatus(){return this.pluginStatus}async syncState(e,t){if(this.isParsed())return this.getState();if(e.pluginStatus!=="loading")return this.setState(e),e;let i=e.pluginURL,r=new Promise(n=>{this.loadScriptResolve=n}),a=new Promise(n=>setTimeout(()=>n(),this.TIMEOUT));if(await t(i),await Promise.race([r,a]),this.isParsed()){let n={pluginStatus:"loaded",pluginURL:i};return this.setState(n),n}throw this.setState({pluginStatus:"error",pluginURL:""}),Error(`RTL Text Plugin failed to import scripts from ${i}`)}};function eS(e){return/[\u0600-\u0604\u0606-\u060B\u060D-\u061A\u061C-\u061E\u0620-\u063F\u0641-\u064A\u0656-\u066F\u0671-\u06DC\u06DE-\u070D\u070F-\u074A\u074D-\u077F\u07C0-\u07FA\u07FD-\u07FF\u0840-\u085B\u085E\u0860-\u086A\u0870-\u0891\u0897-\u08E1\u08E3-\u08FF\u1800\u1801\u1804\u1806-\u1819\u1820-\u1878\u1880-\u18AA\uA840-\uA877\uFB50-\uFD3D\uFD40-\uFDCF\uFDF0-\uFDFF\uFE70-\uFE74\uFE76-\uFEFC]|\uD802[\uDEC0-\uDEE6\uDEEB-\uDEF6\uDF80-\uDF91\uDF99-\uDF9C\uDFA9-\uDFAF]|\uD803[\uDD00-\uDD27\uDD30-\uDD39\uDE60-\uDE7E\uDEC2-\uDEC7\uDED0-\uDED8\uDEFA-\uDEFF\uDF30-\uDF59\uDF70-\uDF89\uDFB0-\uDFCB]|\uD805[\uDE60-\uDE6C]|\uD82F[\uDC00-\uDC6A\uDC70-\uDC7C\uDC80-\uDC88\uDC90-\uDC99\uDC9C-\uDC9F]|\uD83A[\uDD00-\uDD4B\uDD50-\uDD59\uDD5E\uDD5F]|\uD83B[\uDE00-\uDE03\uDE05-\uDE1F\uDE21\uDE22\uDE24\uDE27\uDE29-\uDE32\uDE34-\uDE37\uDE39\uDE3B\uDE42\uDE47\uDE49\uDE4B\uDE4D-\uDE4F\uDE51\uDE52\uDE54\uDE57\uDE59\uDE5B\uDE5D\uDE5F\uDE61\uDE62\uDE64\uDE67-\uDE6A\uDE6C-\uDE72\uDE74-\uDE77\uDE79-\uDE7C\uDE7E\uDE80-\uDE89\uDE8B-\uDE9B\uDEA1-\uDEA3\uDEA5-\uDEA9\uDEAB-\uDEBB\uDEF0\uDEF1]/gim.test(String.fromCodePoint(e))}function tS(e){return/[\u0591-\u05C7\u05D0-\u05EA\u05EF-\u05F4\u0600-\u0604\u0606-\u060B\u060D-\u061A\u061C-\u061E\u0620-\u063F\u0641-\u064A\u0656-\u066F\u0671-\u06DC\u06DE-\u070D\u070F-\u074A\u074D-\u07B1\u07C0-\u07FA\u07FD-\u082D\u0830-\u083E\u0840-\u085B\u085E\u0860-\u086A\u0870-\u0891\u0897-\u08E1\u08E3-\u08FF\uFB1D-\uFB36\uFB38-\uFB3C\uFB3E\uFB40\uFB41\uFB43\uFB44\uFB46-\uFD3D\uFD40-\uFDCF\uFDF0-\uFDFF\uFE70-\uFE74\uFE76-\uFEFC]|\uD802[\uDC00-\uDC05\uDC08\uDC0A-\uDC35\uDC37\uDC38\uDC3C\uDC3F-\uDC55\uDC57-\uDC9E\uDCA7-\uDCAF\uDCE0-\uDCF2\uDCF4\uDCF5\uDCFB-\uDD1B\uDD1F-\uDD39\uDD3F-\uDD59\uDD80-\uDDB7\uDDBC-\uDDCF\uDDD2-\uDE03\uDE05\uDE06\uDE0C-\uDE13\uDE15-\uDE17\uDE19-\uDE35\uDE38-\uDE3A\uDE3F-\uDE48\uDE50-\uDE58\uDE60-\uDE9F\uDEC0-\uDEE6\uDEEB-\uDEF6\uDF00-\uDF35\uDF39-\uDF55\uDF58-\uDF72\uDF78-\uDF91\uDF99-\uDF9C\uDFA9-\uDFAF]|\uD803[\uDC00-\uDC48\uDC80-\uDCB2\uDCC0-\uDCF2\uDCFA-\uDD27\uDD30-\uDD39\uDD40-\uDD65\uDD69-\uDD85\uDD8E\uDD8F\uDE60-\uDE7E\uDE80-\uDEA9\uDEAB-\uDEAD\uDEB0\uDEB1\uDEC2-\uDEC7\uDED0-\uDED8\uDEFA-\uDF27\uDF30-\uDF59\uDF70-\uDF89\uDFB0-\uDFCB\uDFE0-\uDFF6]|\uD83A[\uDC00-\uDCC4\uDCC7-\uDCD6\uDD00-\uDD4B\uDD50-\uDD59\uDD5E\uDD5F]|\uD83B[\uDE00-\uDE03\uDE05-\uDE1F\uDE21\uDE22\uDE24\uDE27\uDE29-\uDE32\uDE34-\uDE37\uDE39\uDE3B\uDE42\uDE47\uDE49\uDE4B\uDE4D-\uDE4F\uDE51\uDE52\uDE54\uDE57\uDE59\uDE5B\uDE5D\uDE5F\uDE61\uDE62\uDE64\uDE67-\uDE6A\uDE6C-\uDE72\uDE74-\uDE77\uDE79-\uDE7C\uDE7E\uDE80-\uDE89\uDE8B-\uDE9B\uDEA1-\uDEA3\uDEA5-\uDEA9\uDEAB-\uDEBB\uDEF0\uDEF1]/gim.test(String.fromCodePoint(e))}function iS(e){return/[\u02EA\u02EB\u1100-\u11FF\u2E80-\u2FDF\u3000-\u30FF\u3105-\u312F\u3131-\u318E\u31A0-\u4DBF\u4E00-\uA48C\uA490-\uA4C6\uA960-\uA97C\uAC00-\uD7C6\uD7CB-\uD7FB\uF900-\uFA6D\uFA70-\uFAD9\uFE10-\uFE1F\uFE30-\uFE4F\uFF00-\uFFEF]|\uD81B[\uDFE0-\uDFFF]|[\uD81C-\uD822\uD840-\uD868\uD86A-\uD86D\uD86F-\uD872\uD874-\uD879\uD880-\uD883\uD885-\uD88C][\uDC00-\uDFFF]|\uD823[\uDC00-\uDCD5\uDCFF-\uDD1E\uDD80-\uDDF2]|\uD82B[\uDFF0-\uDFFF]|\uD82C[\uDC00-\uDEFB]|\uD83C[\uDE00-\uDEFF]|\uD869[\uDC00-\uDEDF\uDF00-\uDFFF]|\uD86E[\uDC00-\uDC1D\uDC20-\uDFFF]|\uD873[\uDC00-\uDEAD\uDEB0-\uDFFF]|\uD87A[\uDC00-\uDFE0\uDFF0-\uDFFF]|\uD87B[\uDC00-\uDE5D]|\uD87E[\uDC00-\uDE1D]|\uD884[\uDC00-\uDF4A\uDF50-\uDFFF]|\uD88D[\uDC00-\uDC79]/gim.test(String.fromCodePoint(e))}function rS(e){return/[\u02EA\u02EB\u2E80-\u2FDF\u2FF0-\u303F\u3041-\u3096\u309D-\u309F\u30A1-\u30FA\u30FD-\u30FF\u3105-\u312F\u31A0-\u4DBF\u4E00-\uA48C\uA490-\uA4C6\uF900-\uFA6D\uFA70-\uFAD9\uFE10-\uFE1F\uFE30-\uFE4F\uFF00-\uFFEF]|\uD81B[\uDFE0-\uDFFF]|[\uD81C-\uD822\uD840-\uD868\uD86A-\uD86D\uD86F-\uD872\uD874-\uD879\uD880-\uD883\uD885-\uD88C][\uDC00-\uDFFF]|\uD823[\uDC00-\uDCD5\uDCFF-\uDD1E\uDD80-\uDDF2]|\uD82B[\uDFF0-\uDFFF]|\uD82C[\uDC00-\uDEFB]|\uD83C[\uDE00-\uDEFF]|\uD869[\uDC00-\uDEDF\uDF00-\uDFFF]|\uD86E[\uDC00-\uDC1D\uDC20-\uDFFF]|\uD873[\uDC00-\uDEAD\uDEB0-\uDFFF]|\uD87A[\uDC00-\uDFE0\uDFF0-\uDFFF]|\uD87B[\uDC00-\uDE5D]|\uD87E[\uDC00-\uDE1D]|\uD884[\uDC00-\uDF4A\uDF50-\uDFFF]|\uD88D[\uDC00-\uDC79]/gim.test(String.fromCodePoint(e))}function Wl(e){return/[\u02EA\u02EB\u1100-\u11FF\u1401-\u167F\u18B0-\u18FF\u2065\u20DD-\u20E0\u20E2-\u20E4\u2B97\u2BF0-\u2BFF\u2E50\u2E51\u2E80-\u3007\u3012\u3013\u3020-\u302F\u3031-\u30FB\u30FD-\uA4CF\uA960-\uA97F\uAC00-\uD7FF\uF900-\uFAFF\uFE10-\uFE1F\uFE30-\uFE48\uFE50-\uFE57\uFE5F-\uFE62\uFE67-\uFE6F\uFF00-\uFF07\uFF0A-\uFF0C\uFF0E-\uFF19\uFF1F-\uFF3A\uFF3C\uFF3E\uFF40-\uFF5A\uFFE0-\uFFE2\uFFE4-\uFFE7\uFFF0-\uFFF8]|\uD802[\uDD80-\uDD9F]|\uD805[\uDD80-\uDDFF]|\uD806[\uDE00-\uDEBF]|[\uD80C-\uD810\uD81C-\uD822\uD83C\uD83D\uD840-\uD87E\uD880-\uD8BE][\uDC00-\uDFFF]|\uD811[\uDC00-\uDE7F]|\uD81B[\uDFE0-\uDFFF]|\uD823[\uDC00-\uDDFF]|\uD82B[\uDFF0-\uDFFF]|\uD82C[\uDC00-\uDEFF]|\uD833[\uDEC0-\uDFCF]|\uD834[\uDC00-\uDDFF\uDEE0-\uDF7F]|\uD836[\uDC00-\uDEAF]|\uD83E[\uDD00-\uDEFF]|[\uD87F\uD8BF][\uDC00-\uDFFD]/gim.test(String.fromCodePoint(e))}function aS(e){return/[\xA7\xA9\xAE\xB1\xBC-\xBE\xD7\xF7\u2016\u2020\u2021\u2030\u2031\u203B\u203C\u2042\u2047-\u2049\u2051\u2100-\u218F\u221E\u2234\u2235\u2300-\u2307\u230C-\u231F\u2324-\u2328\u232B\u237D-\u239A\u23BE-\u23CD\u23CF\u23D1-\u23DB\u23E2-\u2422\u2424-\u24FF\u25A0-\u2619\u2620-\u2767\u2776-\u2793\u2B12-\u2B2F\u2B50-\u2B59\u2BB8-\u2BEB\u3000-\u303F\u30A0-\u30FF\uE000-\uF8FF\uFE30-\uFE6F\uFF00-\uFFEF\uFFFC\uFFFD]|[\uDB80-\uDBFF][\uDC00-\uDFFF]/gim.test(String.fromCodePoint(e))}function nS(e){return/[\r\u0300-\u036F\u0483-\u0489\u0591-\u05BD\u05BF\u05C1\u05C2\u05C4\u05C5\u05C7\u0600-\u0605\u0610-\u061A\u064B-\u065F\u0670\u06D6-\u06DD\u06DF-\u06E4\u06E7\u06E8\u06EA-\u06ED\u070F\u0711\u0730-\u074A\u07A6-\u07B0\u07EB-\u07F3\u07FD\u0816-\u0819\u081B-\u0823\u0825-\u0827\u0829-\u082D\u0859-\u085B\u0890\u0891\u0897-\u089F\u08CA-\u0903\u093A-\u093C\u093E-\u094F\u0951-\u0957\u0962\u0963\u0981-\u0983\u09BC\u09BE-\u09C4\u09C7\u09C8\u09CB-\u09CD\u09D7\u09E2\u09E3\u09FE\u0A01-\u0A03\u0A3C\u0A3E-\u0A42\u0A47\u0A48\u0A4B-\u0A4D\u0A51\u0A70\u0A71\u0A75\u0A81-\u0A83\u0ABC\u0ABE-\u0AC5\u0AC7-\u0AC9\u0ACB-\u0ACD\u0AE2\u0AE3\u0AFA-\u0AFF\u0B01-\u0B03\u0B3C\u0B3E-\u0B44\u0B47\u0B48\u0B4B-\u0B4D\u0B55-\u0B57\u0B62\u0B63\u0B82\u0BBE-\u0BC2\u0BC6-\u0BC8\u0BCA-\u0BCD\u0BD7\u0C00-\u0C04\u0C3C\u0C3E-\u0C44\u0C46-\u0C48\u0C4A-\u0C4D\u0C55\u0C56\u0C62\u0C63\u0C81-\u0C83\u0CBC\u0CBE-\u0CC4\u0CC6-\u0CC8\u0CCA-\u0CCD\u0CD5\u0CD6\u0CE2\u0CE3\u0CF3\u0D00-\u0D03\u0D3B\u0D3C\u0D3E-\u0D44\u0D46-\u0D48\u0D4A-\u0D4E\u0D57\u0D62\u0D63\u0D81-\u0D83\u0DCA\u0DCF-\u0DD4\u0DD6\u0DD8-\u0DDF\u0DF2\u0DF3\u0E31\u0E33-\u0E3A\u0E47-\u0E4E\u0EB1\u0EB3-\u0EBC\u0EC8-\u0ECE\u0F18\u0F19\u0F35\u0F37\u0F39\u0F3E\u0F3F\u0F71-\u0F84\u0F86\u0F87\u0F8D-\u0F97\u0F99-\u0FBC\u0FC6\u102D-\u1037\u1039-\u103E\u1056-\u1059\u105E-\u1060\u1071-\u1074\u1082\u1084-\u1086\u108D\u109D\u1100-\u11FF\u135D-\u135F\u1712-\u1715\u1732-\u1734\u1752\u1753\u1772\u1773\u17B4-\u17D3\u17DD\u180B-\u180D\u180F\u1885\u1886\u18A9\u1920-\u192B\u1930-\u193B\u1A17-\u1A1B\u1A55-\u1A5E\u1A60\u1A62\u1A65-\u1A7C\u1A7F\u1AB0-\u1ADD\u1AE0-\u1AEB\u1B00-\u1B04\u1B34-\u1B44\u1B6B-\u1B73\u1B80-\u1B82\u1BA1-\u1BAD\u1BE6-\u1BF3\u1C24-\u1C37\u1CD0-\u1CD2\u1CD4-\u1CE8\u1CED\u1CF4\u1CF7-\u1CF9\u1DC0-\u1DFF\u200C\u200D\u20D0-\u20F0\u2CEF-\u2CF1\u2D7F\u2DE0-\u2DFF\u302A-\u302F\u3099\u309A\uA66F-\uA672\uA674-\uA67D\uA69E\uA69F\uA6F0\uA6F1\uA802\uA806\uA80B\uA823-\uA827\uA82C\uA880\uA881\uA8B4-\uA8C5\uA8E0-\uA8F1\uA8FF\uA926-\uA92D\uA947-\uA953\uA960-\uA97C\uA980-\uA983\uA9B3-\uA9C0\uA9E5\uAA29-\uAA36\uAA43\uAA4C\uAA4D\uAA7C\uAAB0\uAAB2-\uAAB4\uAAB7\uAAB8\uAABE\uAABF\uAAC1\uAAEB-\uAAEF\uAAF5\uAAF6\uABE3-\uABEA\uABEC\uABED\uAC00-\uD7A3\uD7B0-\uD7C6\uD7CB-\uD7FB\uFB1E\uFE00-\uFE0F\uFE20-\uFE2F\uFF9E\uFF9F]|\uD800[\uDDFD\uDEE0\uDF76-\uDF7A]|\uD802[\uDE01-\uDE03\uDE05\uDE06\uDE0C-\uDE0F\uDE38-\uDE3A\uDE3F\uDEE5\uDEE6]|\uD803[\uDD24-\uDD27\uDD69-\uDD6D\uDEAB\uDEAC\uDEFA-\uDEFF\uDF46-\uDF50\uDF82-\uDF85]|\uD804[\uDC00-\uDC02\uDC38-\uDC46\uDC70\uDC73\uDC74\uDC7F-\uDC82\uDCB0-\uDCBA\uDCBD\uDCC2\uDCCD\uDD00-\uDD02\uDD27-\uDD34\uDD45\uDD46\uDD73\uDD80-\uDD82\uDDB3-\uDDC0\uDDC2\uDDC3\uDDC9-\uDDCC\uDDCE\uDDCF\uDE2C-\uDE37\uDE3E\uDE41\uDEDF-\uDEEA\uDF00-\uDF03\uDF3B\uDF3C\uDF3E-\uDF44\uDF47\uDF48\uDF4B-\uDF4D\uDF57\uDF62\uDF63\uDF66-\uDF6C\uDF70-\uDF74\uDFB8-\uDFC0\uDFC2\uDFC5\uDFC7-\uDFCA\uDFCC-\uDFD2\uDFE1\uDFE2]|\uD805[\uDC35-\uDC46\uDC5E\uDCB0-\uDCC3\uDDAF-\uDDB5\uDDB8-\uDDC0\uDDDC\uDDDD\uDE30-\uDE40\uDEAB-\uDEB7\uDF1D-\uDF1F\uDF22-\uDF2B]|\uD806[\uDC2C-\uDC3A\uDD30-\uDD35\uDD37\uDD38\uDD3B-\uDD43\uDDD1-\uDDD7\uDDDA-\uDDE0\uDDE4\uDE01-\uDE0A\uDE33-\uDE39\uDE3B-\uDE3E\uDE47\uDE51-\uDE5B\uDE84-\uDE99\uDF60-\uDF67]|\uD807[\uDC2F-\uDC36\uDC38-\uDC3F\uDC92-\uDCA7\uDCA9-\uDCB6\uDD31-\uDD36\uDD3A\uDD3C\uDD3D\uDD3F-\uDD47\uDD8A-\uDD8E\uDD90\uDD91\uDD93-\uDD97\uDEF3-\uDEF6\uDF00-\uDF03\uDF34-\uDF3A\uDF3E-\uDF42\uDF5A]|\uD80D[\uDC40\uDC47-\uDC55]|\uD818[\uDD1E-\uDD2F]|\uD81A[\uDEF0-\uDEF4\uDF30-\uDF36]|\uD81B[\uDD63\uDD67-\uDD6A\uDF4F\uDF51-\uDF87\uDF8F-\uDF92\uDFE4\uDFF0\uDFF1]|\uD82F[\uDC9D\uDC9E]|\uD833[\uDF00-\uDF2D\uDF30-\uDF46]|\uD834[\uDD65-\uDD69\uDD6D-\uDD72\uDD7B-\uDD82\uDD85-\uDD8B\uDDAA-\uDDAD\uDE42-\uDE44]|\uD836[\uDE00-\uDE36\uDE3B-\uDE6C\uDE75\uDE84\uDE9B-\uDE9F\uDEA1-\uDEAF]|\uD838[\uDC00-\uDC06\uDC08-\uDC18\uDC1B-\uDC21\uDC23\uDC24\uDC26-\uDC2A\uDC8F\uDD30-\uDD36\uDEAE\uDEEC-\uDEEF]|\uD839[\uDCEC-\uDCEF\uDDEE\uDDEF\uDEE3\uDEE6\uDEEE\uDEEF\uDEF5]|\uD83A[\uDCD0-\uDCD6\uDD44-\uDD4A]|\uD83C[\uDDE6-\uDDFF\uDFFB-\uDFFF]|\uDB40[\uDC20-\uDC7F\uDD00-\uDDEF]/.test(e)}function Rm(e){return/[\u0E01-\u0E3A\u0E40-\u0E4E\u0E81\u0E82\u0E84\u0E86-\u0E8A\u0E8C-\u0EA3\u0EA5\u0EA7-\u0EBD\u0EC0-\u0EC4\u0EC6\u0EC8-\u0ECE\u0EDC-\u0EDF\u0F00-\u0F47\u0F49-\u0F6C\u0F71-\u0F97\u0F99-\u0FBC\u0FBE-\u0FCC\u0FCE-\u0FD4\u0FD9\u0FDA\u1000-\u103F\u1050-\u108F\u109A-\u109F\u1780-\u17D3\u17D7\u17DC\u17DD\u1950-\u196D\u1970-\u1974\u1980-\u19AB\u19B0-\u19C9\u19DE\u19DF\u1A20-\u1A5E\u1A60-\u1A7C\u1AA0-\u1AAD\u1B00-\u1B4C\u1B4E-\u1B7F\uA980-\uA9CD\uA9D0-\uA9D9\uA9DE-\uA9EF\uA9FA-\uA9FE\uAA60-\uAAC2\uAADB-\uAADF]|\uD805[\uDF00-\uDF1A\uDF1D-\uDF2B\uDF3A\uDF3B\uDF3F-\uDF46]/gim.test(String.fromCodePoint(e))}function oS(e,t){return/(?:[\u1039\u17D2\u1A60\u1BAB\u200D\uAAF6]|\uD802\uDE3F|\uD804[\uDD33\uDFD0]|\uD806[\uDD3E\uDE47\uDE99]|\uD807[\uDD45\uDD97\uDF42])$/.test(e)||/^\p{gc=Mc}/u.test(t)}var sS={C:"18g,1;g2,3;4nb,1",D:"17k,1;5,1;1,1;1,5;4,d;1,7;1,2;z,2;8,g;i,12;1,2;9,1;1,1;1,2;14,3;2,1;28,9;3,f;2,4;1,1;2,3;2,6;7a,1;2,5;1,1;g,a;5,2;2,6;1,f",R:"17m,4;1,1;1,1;5,4;l,1;14,3;1,3;g,i;12,1;2,9;1,1;1,1;2,2;1,1;o,2;2x,3;f,2;4,1;1,2;3,2;6u,j;b,1;r,3;1,1;2,2;6,1",T:"174,b;1,1;1a,l;g,1;2t,7;2,6;2,2;1,4;bt,9;16,o;1,t;1clb,1"},lS={1569:[65152,0,0,0],1570:[65153,65154,0,0],1571:[65155,65156,0,0],1572:[65157,65158,0,0],1573:[65159,65160,0,0],1574:[65161,65162,65163,65164],1575:[65165,65166,0,0],1576:[65167,65168,65169,65170],1577:[65171,65172,0,0],1578:[65173,65174,65175,65176],1579:[65177,65178,65179,65180],1580:[65181,65182,65183,65184],1581:[65185,65186,65187,65188],1582:[65189,65190,65191,65192],1583:[65193,65194,0,0],1584:[65195,65196,0,0],1585:[65197,65198,0,0],1586:[65199,65200,0,0],1587:[65201,65202,65203,65204],1588:[65205,65206,65207,65208],1589:[65209,65210,65211,65212],1590:[65213,65214,65215,65216],1591:[65217,65218,65219,65220],1592:[65221,65222,65223,65224],1593:[65225,65226,65227,65228],1594:[65229,65230,65231,65232],1601:[65233,65234,65235,65236],1602:[65237,65238,65239,65240],1603:[65241,65242,65243,65244],1604:[65245,65246,65247,65248],1605:[65249,65250,65251,65252],1606:[65253,65254,65255,65256],1607:[65257,65258,65259,65260],1608:[65261,65262,0,0],1609:[65263,65264,64488,64489],1610:[65265,65266,65267,65268],1611:[65136,0,0,65137],1612:[65138,0,0,0],1613:[65140,0,0,0],1614:[65142,0,0,65143],1615:[65144,0,0,65145],1616:[65146,0,0,65147],1617:[65148,0,0,65149],1618:[65150,0,0,65151],1649:[64336,64337,0,0],1655:[64477,0,0,0],1657:[64358,64359,64360,64361],1658:[64350,64351,64352,64353],1659:[64338,64339,64340,64341],1662:[64342,64343,64344,64345],1663:[64354,64355,64356,64357],1664:[64346,64347,64348,64349],1667:[64374,64375,64376,64377],1668:[64370,64371,64372,64373],1670:[64378,64379,64380,64381],1671:[64382,64383,64384,64385],1672:[64392,64393,0,0],1676:[64388,64389,0,0],1677:[64386,64387,0,0],1678:[64390,64391,0,0],1681:[64396,64397,0,0],1688:[64394,64395,0,0],1700:[64362,64363,64364,64365],1702:[64366,64367,64368,64369],1705:[64398,64399,64400,64401],1709:[64467,64468,64469,64470],1711:[64402,64403,64404,64405],1713:[64410,64411,64412,64413],1715:[64406,64407,64408,64409],1722:[64414,64415,0,0],1723:[64416,64417,64418,64419],1726:[64426,64427,64428,64429],1728:[64420,64421,0,0],1729:[64422,64423,64424,64425],1733:[64480,64481,0,0],1734:[64473,64474,0,0],1735:[64471,64472,0,0],1736:[64475,64476,0,0],1737:[64482,64483,0,0],1739:[64478,64479,0,0],1740:[64508,64509,64510,64511],1744:[64484,64485,64486,64487],1746:[64430,64431,0,0],1747:[64432,64433,0,0]},uS={\u0644\u0622:[65269,65270],\u0644\u0623:[65271,65272],\u0644\u0625:[65273,65274],\u0644\u0627:[65275,65276]},km=1604,hS=/[\u0600-\u06ff\u0750-\u077f\u0870-\u089f\u08a0-\u08ff\ufb50-\ufdff\ufe70-\ufeff]/;function cS(e,t,i){let r=0;for(let a of e.split(";")){let[n,o]=a.split(",").map(l=>parseInt(l,36)),s=r+n;for(let l=s;l<s+o;l++)i.set(l,t);r=s+o}}var g1=new Map;for(let[e,t]of Object.entries(sS))cS(t,e,g1);function dS(e){return g1.get(e)??"U"}function pS(e){return e==="D"||e==="L"||e==="C"}function fS(e){return e==="D"||e==="R"||e==="C"}function mS(e,t,i){return e==="D"?t&&i?3:t?1:i?2:0:e==="R"?+!!t:e==="L"?i?2:0:null}function gS(e){return[...e].map(t=>{let i=t.codePointAt(0);return{codePoint:i,type:dS(i),form:null}})}function _S(e){let t=e.filter(i=>i.type!=="T");for(let i=0;i<t.length;i++){let r=t[i],a=i>0&&pS(t[i-1].type),n=i+1<t.length&&fS(t[i+1].type);r.form=mS(r.type,a,n)}}function yS(e){let t=!1;for(let i of e)i.type==="T"?i.form=t?3:0:t=i.form===2||i.form===3}function vS(e){let t=[];for(let i=0;i<e.length;i++){let r=e[i];if(r.codePoint!==km){t.push(r);continue}let a=i+1;for(;a<e.length&&e[a].type==="T";)a++;let n=e[a],o=n&&uS[String.fromCodePoint(km,n.codePoint)];if(!o){t.push(r);continue}let s=r.form===3||r.form===1;t.push({codePoint:o[+!!s],type:"R",form:0}),t.push(...e.slice(i+1,a)),i=a}return t}function xS(e){if(e.form===null)return e.codePoint;let t=lS[e.codePoint];return t&&(t[e.form]||t[0])||e.codePoint}function bS(e){if(!hS.test(e))return e;let t=gS(e);return _S(t),yS(t),vS(t).map(i=>String.fromCodePoint(xS(i))).join("")}function wS(e,t,i){let r=t.layout.get("text-transform").evaluate(i,{});return r==="uppercase"?e=e.toLocaleUpperCase():r==="lowercase"&&(e=e.toLocaleLowerCase()),(hl.applyArabicShaping??bS)(e)}function TS(e,t,i){for(let r of e.sections)r.text=wS(r.text,t,i);return e}function Ju(e,t,i){let r=i?t.last.points:t.first.points,a=i?r[r.length-1]:r[0];return`${e}:${a.x}:${a.y}`}function ES(e){let t=e.first.points,i=t.length;for(let n=e.first.next;n;n=n.next)i+=n.points.length-1;let r=Array(i);for(let n=0;n<t.length;n++)r[n]=t[n];let a=t.length;for(let n=e.first.next;n;n=n.next){let o=n.points;for(let s=1;s<o.length;s++)r[a++]=o[s]}return r}function Lm(e,t,i,r,a){let n=t[i];delete t[i],t[r]=n;let o=e[n];return o.last.next=a.first,o.last=a.last,n}function Bm(e,t,i,r,a){let n=t[r];delete t[r],t[i]=n;let o=e[n];return a.last.next=o.first,o.first=a.first,n}function DS(e){let t={},i={},r=[];for(let n of e){let o=n.text?n.text.toString():null,s={points:n.geometry[0],next:null},l={feature:n,first:s,last:s};if(!o){r.push(l);continue}let u=Ju(o,l),h=Ju(o,l,!0);if(u in i&&h in t&&i[u]!==t[h]){let c=Bm(r,t,u,h,l),d=Lm(r,i,u,h,r[c]);delete t[u],delete i[h],i[Ju(o,r[d],!0)]=d,r[c].feature.geometry=null}else if(u in i)Lm(r,i,u,h,l);else if(h in t)Bm(r,t,u,h,l);else{let c=r.push(l)-1;t[u]=c,i[h]=c}}let a=[];for(let n of r){let o=n.feature;o.geometry&&(n.first.next&&(o.geometry[0]=ES(n)),a.push(o))}return a}var _1=typeof Intl<"u"&&"Segmenter"in Intl,Qu,eh;function Lc(e){if(!_1||!nS(e))return[...e];Qu??(Qu=new Intl.Segmenter(void 0,{granularity:"grapheme"}));let t=[];for(let{segment:i}of Qu.segment(e)){let r=t.length-1;r>=0&&oS(t[r],i)?t[r]+=i:t.push(i)}return t}function SS(e){let t=new Set;if(_1){eh??(eh=new Intl.Segmenter(void 0,{granularity:"word"}));for(let{index:r}of eh.segment(e))t.add(r);return t}let i=0;for(let r of e.split(/\b|(?=\p{Ideo})/u))t.add(i),i+=r.length;return t}function cl(e){let t=e.codePointAt(0);return e.length>(t>65535?2:1)}function Yd(e){return/\s/u.test(String.fromCodePoint(e))}function Bc(e){for(let t of e)if(Wl(t.codePointAt(0)))return!0;return!1}function CS(e){for(let t of e)if(!PS(t.codePointAt(0)))return!1;return!0}function PS(e){return!eS(e)}function Om(e){return!(Wl(e)||aS(e))}function y1(e){return/\p{sc=Arab}/u.test(String.fromCodePoint(e))}function v1(e){return tS(e)}function x1(e){for(let t of e)if(v1(t.codePointAt(0)))return!0;return!1}var Ia={"!":"\uFE15","#":"\uFF03",$:"\uFF04","%":"\uFF05","&":"\uFF06","(":"\uFE35",")":"\uFE36","*":"\uFF0A","+":"\uFF0B",",":"\uFE10","-":"\uFE32",".":"\u30FB","/":"\uFF0F",":":"\uFE13",";":"\uFE14","<":"\uFE3F","=":"\uFF1D",">":"\uFE40","?":"\uFE16","@":"\uFF20","[":"\uFE47","\\":"\uFF3C","]":"\uFE48","^":"\uFF3E",_:"\uFE33","`":"\uFF40","{":"\uFE37","|":"\u2015","}":"\uFE38","~":"\uFF5E","\xA2":"\uFFE0","\xA3":"\uFFE1","\xA5":"\uFFE5","\xA6":"\uFFE4","\xAC":"\uFFE2","\xAF":"\uFFE3","\u2013":"\uFE32","\u2014":"\uFE31","\u2018":"\uFE43","\u2019":"\uFE44","\u201C":"\uFE41","\u201D":"\uFE42","\u2026":"\uFE19","\u22EF":"\uFE19","\u2027":"\u30FB","\u20A9":"\uFFE6","\u3001":"\uFE11","\u3002":"\uFE12","\u3008":"\uFE3F","\u3009":"\uFE40","\u300A":"\uFE3D","\u300B":"\uFE3E","\u300C":"\uFE41","\u300D":"\uFE42","\u300E":"\uFE43","\u300F":"\uFE44","\u3010":"\uFE3B","\u3011":"\uFE3C","\u3014":"\uFE39","\u3015":"\uFE3A","\u3016":"\uFE17","\u3017":"\uFE18","\uFF01":"\uFE15","\uFF08":"\uFE35","\uFF09":"\uFE36","\uFF0C":"\uFE10","\uFF0D":"\uFE32","\uFF0E":"\u30FB","\uFF1A":"\uFE13","\uFF1B":"\uFE14","\uFF1C":"\uFE3F","\uFF1E":"\uFE40","\uFF1F":"\uFE16","\uFF3B":"\uFE47","\uFF3D":"\uFE48","\uFF3F":"\uFE33","\uFF5B":"\uFE37","\uFF5C":"\u2015","\uFF5D":"\uFE38","\uFF5F":"\uFE35","\uFF60":"\uFE36","\uFF61":"\uFE12","\uFF62":"\uFE41","\uFF63":"\uFE42"};function AS(e){let t="",i={premature:!0,value:void 0},r=e[Symbol.iterator](),a=r.next(),n=e[Symbol.iterator]();n.next();let o=n.next();for(;!a.done;)(o.done||!Om(o.value.codePointAt(0))||Ia[o.value])&&(i.premature||!Om(i.value.codePointAt(0))||Ia[i.value])&&Ia[a.value]?t+=Ia[a.value]:t+=a.value,i={value:a.value,premature:!1},a=r.next(),o=n.next();return t}var IS={10:!0,13:!0,32:!0,38:!0,41:!0,43:!0,45:!0,47:!0,173:!0,183:!0,8203:!0,8208:!0,8211:!0,8231:!0},MS={40:!0};function jm(e,t,i,r,a,n){if("fontStack"in t){let o=i[t.fontStack]?.default,s=o?.[e];if(s)return s.metrics.advance*t.scale+a;let l=0;for(let u of e){let h=o?.[u];h&&(l+=h.metrics.advance*t.scale+a)}return l}{let o=r[t.imageName];return o?o.displaySize[0]*t.scale*24/n+a:0}}function Vm(e,t,i,r){let a=(e-t)**2;return r?e<t?a/2:a*2:a+Math.abs(i)*i}function Nm(e){return/^\s+$/u.test(e)}function FS(e,t,i){let r=0;return(e===10||e===13)&&(r-=1e4),i&&(r+=150),(e===40||e===65288)&&(r+=50),(t===41||t===65289)&&(r+=50),r}function Um(e,t,i,r,a,n){let o=null,s=Vm(t,i,a,n);for(let l of r){let u=Vm(t-l.x,i,a,n)+l.badness;u<=s&&(o=l,s=u)}return{index:e,x:t,priorBreak:o,badness:s}}function b1(e){return e?b1(e.priorBreak).concat(e.index):[]}var Kd=class Oc{constructor(t="",i=[],r=[]){this.text=t,this.sections=i,this.sectionIndex=r,this.imageSectionID=null,this._graphemes=null}graphemes(){return this._graphemes??(this._graphemes=Lc(this.text)),this._graphemes}static fromFeature(t,i){let r=new Oc;for(let a of t.sections)a.image?r.addImageSection(a):r.addTextSection(a,i);return r}length(){return this.graphemes().length}getSection(t){return this.sections[this.sectionIndex[t]]}getSectionIndex(t){return this.sectionIndex[t]}verticalizePunctuation(){this.text=AS(this.text),this._graphemes=null}hasZeroWidthSpaces(){return this.text.includes("\u200B")}trim(){let t=this.graphemes(),i=0;for(;i<t.length&&Nm(t[i]);)i++;let r=t.length;for(;r>i&&Nm(t[r-1]);)r--;this.text=t.slice(i,r).join(""),this.sectionIndex=this.sectionIndex.slice(i,r),this._graphemes=null}substring(t,i){let r=this.graphemes().slice(t,i).join(""),a=this.sectionIndex.slice(t,i);return new Oc(r,this.sections,a)}toCodeUnitIndex(t){return this.graphemes().slice(0,t).join("").length}toString(){return this.text}getMaxScale(){return this.sectionIndex.reduce((t,i)=>Math.max(t,this.sections[i].scale),0)}getMaxImageSize(t){let i=0,r=0;for(let a=0;a<this.length();a++){let n=this.getSection(a);if("imageName"in n){let o=t[n.imageName];if(!o)continue;let s=o.displaySize;i=Math.max(i,s[0]),r=Math.max(r,s[1])}}return{maxImageWidth:i,maxImageHeight:r}}_appendSection(t,i){let r=this.graphemes(),a=r.length>0?r[r.length-1]:"",n=Lc(a+t);this.text+=t,this._graphemes=r.slice(0,a?-1:void 0).concat(n);let o=n.length-+!!a;for(let s=0;s<o;s++)this.sectionIndex.push(i)}addTextSection(t,i){this.sections.push({scale:t.scale||1,verticalAlign:t.verticalAlign||"bottom",fontStack:t.fontStack||i}),this._appendSection(t.text,this.sections.length-1)}addImageSection(t){let i=t.image?t.image.name:"";if(i.length===0){_e("Can't add FormattedSection with an empty image.");return}let r=this.getNextImageSectionCharCode();if(!r){_e("Reached maximum number of images 6401");return}this.sections.push({scale:1,verticalAlign:t.verticalAlign||"bottom",imageName:i}),this._appendSection(String.fromCharCode(r),this.sections.length-1)}getNextImageSectionCharCode(){return this.imageSectionID?this.imageSectionID>=63743?null:++this.imageSectionID:(this.imageSectionID=57344,this.imageSectionID)}determineLineBreaks(t,i,r,a,n){let o=this.determineTotalWidth(t,r,a,n);if(t>=0&&o>0&&o<=i&&!/[\n\r]/.test(this.text))return[this.length()];let s=[],l=o/Math.max(1,Math.ceil(o/i)),u=this.hasZeroWidthSpaces(),h=this.graphemes(),c=null,d=0,p=0;for(let f=0;f<h.length;f++){let m=h[f];if(f>0){let g=h[f-1].codePointAt(0),_=m.codePointAt(0),y=rS(g),v=Rm(g)&&Rm(_);(IS[g]||y||"imageName"in this.getSection(f-1)||h[f+1]!==void 0&&MS[_]||v&&(c??(c=SS(this.text))).has(p))&&s.push(Um(f,d,l,s,FS(g,_,y&&u),!1))}Yd(m.codePointAt(0))||(d+=jm(m,this.getSection(f),r,a,t,n)),p+=m.length}return b1(Um(this.length(),d,l,s,0,!0))}determineTotalWidth(t,i,r,a){let n=0,o=0;for(let s of this.graphemes()){let l=this.getSection(o);n+=jm(s,l,i,r,t,a),o++}return n}};function zS(){return(function(e){var t={R:"13k,1a,2,3,3,2+1j,ch+16,a+1,5+2,2+n,5,a,4,6+16,4+3,h+1b,4mo,179q,2+9,2+11,2i9+7y,2+68,4,3+4,5+13,4+3,2+4k,3+29,8+cf,1t+7z,w+17,3+3m,1t+3z,16o1+5r,8+30,8+mc,29+1r,29+4v,75+73",EN:"1c+9,3d+1,6,187+9,513,4+5,7+9,sf+j,175h+9,qw+q,161f+1d,4xt+a,25i+9",ES:"17,2,6dp+1,f+1,av,16vr,mx+1,4o,2",ET:"z+2,3h+3,b+1,ym,3e+1,2o,p4+1,8,6u,7c,g6,1wc,1n9+4,30+1b,2n,6d,qhx+1,h0m,a+1,49+2,63+1,4+1,6bb+3,12jj",AN:"16o+5,2j+9,2+1,35,ed,1ff2+9,87+u",CS:"18,2+1,b,2u,12k,55v,l,17v0,2,3,53,2+1,b",B:"a,3,f+2,2v,690",S:"9,2,k",WS:"c,k,4f4,1vk+a,u,1j,335",ON:"x+1,4+4,h+5,r+5,r+3,z,5+3,2+1,2+1,5,2+2,3+4,o,w,ci+1,8+d,3+d,6+8,2+g,39+1,9,6+1,2,33,b8,3+1,3c+1,7+1,5r,b,7h+3,sa+5,2,3i+6,jg+3,ur+9,2v,ij+1,9g+9,7+a,8m,4+1,49+x,14u,2+2,c+2,e+2,e+2,e+1,i+n,e+e,2+p,u+2,e+2,36+1,2+3,2+1,b,2+2,6+5,2,2,2,h+1,5+4,6+3,3+f,16+2,5+3l,3+81,1y+p,2+40,q+a,m+13,2r+ch,2+9e,75+hf,3+v,2+2w,6e+5,f+6,75+2a,1a+p,2+2g,d+5x,r+b,6+3,4+o,g,6+1,6+2,2k+1,4,2j,5h+z,1m+1,1e+f,t+2,1f+e,d+3,4o+3,2s+1,w,535+1r,h3l+1i,93+2,2s,b+1,3l+x,2v,4g+3,21+3,kz+1,g5v+1,5a,j+9,n+v,2,3,2+8,2+1,3+2,2,3,46+1,4+4,h+5,r+5,r+a,3h+2,4+6,b+4,78,1r+24,4+c,4,1hb,ey+6,103+j,16j+c,1ux+7,5+g,fsh,jdq+1t,4,57+2e,p1,1m,1m,1m,1m,4kt+1,7j+17,5+2r,d+e,3+e,2+e,2+10,m+4,w,1n+5,1q,4z+5,4b+rb,9+c,4+c,4+37,d+2g,8+b,l+b,5+1j,9+9,7+13,9+t,3+1,27+3c,2+29,2+3q,d+d,3+4,4+2,6+6,a+o,8+6,a+2,e+6,16+42,2+1i",BN:"0+8,6+d,2s+5,2+p,e,4m9,1kt+2,2b+5,5+5,17q9+v,7k,6p+8,6+1,119d+3,440+7,96s+1,1ekf+1,1ekf+1,1ekf+1,1ekf+1,1ekf+1,1ekf+1,1ekf+1,1ekf+1,1ekf+1,1ekf+1,1ekf+1,1ekf+75,6p+2rz,1ben+1,1ekf+1,1ekf+1",NSM:"lc+33,7o+6,7c+18,2,2+1,2+1,2,21+a,1d+k,h,2u+6,3+5,3+1,2+3,10,v+q,2k+a,1n+8,a,p+3,2+8,2+2,2+4,18+2,3c+e,2+v,1k,2,5+7,5,4+6,b+1,u,1n,5+3,9,l+1,r,3+1,1m,5+1,5+1,3+2,4,v+1,4,c+1,1m,5+4,2+1,5,l+1,n+5,2,1n,3,2+3,9,8+1,c+1,v,1q,d,1f,4,1m+2,6+2,2+3,8+1,c+1,u,1n,g+1,l+1,t+1,1m+1,5+3,9,l+1,u,21,8+2,2,2j,3+6,d+7,2r,3+8,c+5,23+1,s,2,2,1k+d,2+4,2+1,6+a,2+z,a,2v+3,2+5,2+1,3+1,q+1,5+2,h+3,e,3+1,7,g,jk+2,qb+2,u+2,u+1,v+1,1t+1,2+6,9,3+a,a,1a+2,3c+1,z,3b+2,5+1,a,7+2,64+1,3,1n,2+6,2,2,3+7,7+9,3,1d+g,1s+3,1d,2+4,2,6,15+8,d+1,x+3,3+1,2+2,1l,2+1,4,2+2,1n+7,3+1,49+2,2+c,2+6,5,7,4+1,5j+1l,2+4,k1+w,2db+2,3y,2p+v,ff+3,30+1,n9x+3,2+9,x+1,29+1,7l,4,5,q+1,6,48+1,r+h,e,13+7,q+a,1b+2,1d,3+3,3+1,14,1w+5,3+1,3+1,d,9,1c,1g,2+2,3+1,6+1,2,17+1,9,6n,3,5,fn5,ki+f,h+f,r2,6b,46+4,1af+2,2+1,6+3,15+2,5,4m+1,fy+3,as+1,4a+a,4x,1j+e,1l+2,1e+3,3+1,1y+2,11+4,2+7,1r,d+1,1h+8,b+3,3,2o+2,3,2+1,7,4h,4+7,m+1,1m+1,4,12+6,4+4,5g+7,3+2,2,o,2d+5,2,5+1,2+1,6n+3,7+1,2+1,s+1,2e+7,3,2+1,2z,2,3+5,2,2u+2,3+3,2+4,78+8,2+1,75+1,2,5,41+3,3+1,5,x+5,3+1,15+5,3+3,9,a+5,3+2,1b+c,2+1,bb+6,2+5,2d+l,3+6,2+1,2+1,3f+5,4,2+1,2+6,2,21+1,4,2,9o+1,f0c+4,1o+6,t5,1s+3,2a,f5l+1,43t+2,i+7,3+6,v+3,45+2,1j0+1i,5+1d,9,f,n+4,2+e,11t+6,2+g,3+6,2+1,2+4,7a+6,c6+3,15t+6,32+6,gzhy+6n",AL:"16w,3,2,e+1b,z+2,2+2s,g+1,8+1,b+m,2+t,s+2i,c+e,4h+f,1d+1e,1bwe+dp,3+3z,x+c,2+1,35+3y,2rm+z,5+7,b+5,dt+l,c+u,17nl+27,1t+27,4x+6n,3+d",LRO:"6ct",RLO:"6cu",LRE:"6cq",RLE:"6cr",PDF:"6cs",LRI:"6ee",RLI:"6ef",FSI:"6eg",PDI:"6eh"},i={},r={};i.L=1,r[1]="L",Object.keys(t).forEach(function(W,ce){i[W]=1<<ce+1,r[i[W]]=W}),Object.freeze(i);var a=i.LRI|i.RLI|i.FSI,n=i.L|i.R|i.AL,o=i.B|i.S|i.WS|i.ON|i.FSI|i.LRI|i.RLI|i.PDI,s=i.BN|i.RLE|i.LRE|i.RLO|i.LRO|i.PDF,l=i.S|i.WS|i.B|a|i.PDI|s,u=null;function h(){if(!u){u=new Map;var W=0;for(var ce in t)if(t.hasOwnProperty(ce))for(var re=t[ce],O="",we=void 0,H=!1,te=0,Z=0;Z<=re.length+1;Z+=1){var xe=re[Z];if(xe!==","&&Z!==re.length)xe==="+"?(H=!0,te=W=te+parseInt(O,36),O=""):O+=xe;else{H?we=W+parseInt(O,36):(te=W=te+parseInt(O,36),we=W),H=!1,O="",te=we;for(var Be=W;Be<we+1;Be+=1)u.set(Be,i[ce])}}}}function c(W){return h(),u.get(W.codePointAt(0))||i.L}function d(W){return r[c(W)]}var p={pairs:"14>1,1e>2,u>2,2wt>1,1>1,1ge>1,1wp>1,1j>1,f>1,hm>1,1>1,u>1,u6>1,1>1,+5,28>1,w>1,1>1,+3,b8>1,1>1,+3,1>3,-1>-1,3>1,1>1,+2,1s>1,1>1,x>1,th>1,1>1,+2,db>1,1>1,+3,3>1,1>1,+2,14qm>1,1>1,+1,4q>1,1e>2,u>2,2>1,+1",canonical:"6f1>-6dx,6dy>-6dx,6ec>-6ed,6ee>-6ed,6ww>2jj,-2ji>2jj,14r4>-1e7l,1e7m>-1e7l,1e7m>-1e5c,1e5d>-1e5b,1e5c>-14qx,14qy>-14qx,14vn>-1ecg,1ech>-1ecg,1edu>-1ecg,1eci>-1ecg,1eda>-1ecg,1eci>-1ecg,1eci>-168q,168r>-168q,168s>-14ye,14yf>-14ye"};function f(W,ce){var re=0,O=new Map,we=ce&&new Map,H;return W.split(",").forEach(function te(Z){if(Z.indexOf("+")!==-1)for(var xe=+Z;xe--;)te(H);else{H=Z;var Be=Z.split(">"),Te=Be[0],ot=Be[1];Te=String.fromCodePoint(re+=parseInt(Te,36)),ot=String.fromCodePoint(re+=parseInt(ot,36)),O.set(Te,ot),ce&&we.set(ot,Te)}}),{map:O,reverseMap:we}}var m,g,_;function y(){if(!m){var W=f(p.pairs,!0),ce=W.map,re=W.reverseMap;m=ce,g=re,_=f(p.canonical,!1).map}}function v(W){return y(),m.get(W)||null}function x(W){return y(),g.get(W)||null}function b(W){return y(),_.get(W)||null}var w=i.L,T=i.R,E=i.EN,S=i.ES,M=i.ET,z=i.AN,R=i.CS,I=i.B,D=i.S,P=i.ON,A=i.BN,B=i.NSM,j=i.AL,V=i.LRO,J=i.RLO,se=i.LRE,fe=i.RLE,ye=i.PDF,Ge=i.LRI,Le=i.RLI,Ze=i.FSI,ke=i.PDI;function Tt(W,ce){for(var re=125,O=new Uint32Array(W.length),we=0;we<W.length;we++)O[we]=c(W[we]);var H=new Map;function te(Gt,Ei){var Zt=O[Gt];O[Gt]=Ei,H.set(Zt,H.get(Zt)-1),Zt&o&&H.set(o,H.get(o)-1),H.set(Ei,(H.get(Ei)||0)+1),Ei&o&&H.set(o,(H.get(o)||0)+1)}for(var Z=new Uint8Array(W.length),xe=new Map,Be=[],Te=null,ot=0;ot<W.length;ot++)Te||Be.push(Te={start:ot,end:W.length-1,level:ce==="rtl"?1:ce==="ltr"?0:pf(ot,!1)}),O[ot]&I&&(Te.end=ot,Te=null);for(var Fr=fe|se|J|V|a|ke|ye|I,Ji=function(Gt){return Gt+(Gt&1?1:2)},Li=function(Gt){return Gt+(Gt&1?2:1)},Bt=0;Bt<Be.length;Bt++){Te=Be[Bt];var Re=[{_level:Te.level,_override:0,_isolate:0}],qe=void 0,hi=0,ci=0,ca=0;H.clear();for(var st=Te.start;st<=Te.end;st++){var Dt=O[st];if(qe=Re[Re.length-1],H.set(Dt,(H.get(Dt)||0)+1),Dt&o&&H.set(o,(H.get(o)||0)+1),Dt&Fr)if(Dt&(fe|se)){Z[st]=qe._level;var Vp=(Dt===fe?Li:Ji)(qe._level);Vp<=re&&!hi&&!ci?Re.push({_level:Vp,_override:0,_isolate:0}):hi||ci++}else if(Dt&(J|V)){Z[st]=qe._level;var Np=(Dt===J?Li:Ji)(qe._level);Np<=re&&!hi&&!ci?Re.push({_level:Np,_override:Dt&J?T:w,_isolate:0}):hi||ci++}else if(Dt&a){Dt&Ze&&(Dt=pf(st+1,!0)===1?Le:Ge),Z[st]=qe._level,qe._override&&te(st,qe._override);var Up=(Dt===Le?Li:Ji)(qe._level);Up<=re&&hi===0&&ci===0?(ca++,Re.push({_level:Up,_override:0,_isolate:1,_isolInitIndex:st})):hi++}else if(Dt&ke){if(hi>0)hi--;else if(ca>0){for(ci=0;!Re[Re.length-1]._isolate;)Re.pop();var au=Re[Re.length-1]._isolInitIndex;au!=null&&(xe.set(au,st),xe.set(st,au)),Re.pop(),ca--}qe=Re[Re.length-1],Z[st]=qe._level,qe._override&&te(st,qe._override)}else Dt&ye?(hi===0&&(ci>0?ci--:!qe._isolate&&Re.length>1&&(Re.pop(),qe=Re[Re.length-1])),Z[st]=qe._level):Dt&I&&(Z[st]=Te.level);else Z[st]=qe._level,qe._override&&Dt!==A&&te(st,qe._override)}for(var da=[],Bi=null,zr=Te.start;zr<=Te.end;zr++){var nu=O[zr];if(!(nu&s)){var $p=Z[zr],Gp=nu&a,Kx=nu===ke;Bi&&$p===Bi._level?(Bi._end=zr,Bi._endsWithIsolInit=Gp):da.push(Bi={_start:zr,_end:zr,_level:$p,_startsWithPDI:Kx,_endsWithIsolInit:Gp})}}for(var ou=[],Lo=0;Lo<da.length;Lo++){var Bo=da[Lo];if(!Bo._startsWithPDI||Bo._startsWithPDI&&!xe.has(Bo._start)){for(var su=[Bi=Bo],Zp=void 0;Bi&&Bi._endsWithIsolInit&&(Zp=xe.get(Bi._end))!=null;)for(var Oo=Lo+1;Oo<da.length;Oo++)if(da[Oo]._start===Zp){su.push(Bi=da[Oo]);break}for(var pa=[],lu=0;lu<su.length;lu++)for(var qp=su[lu],uu=qp._start;uu<=qp._end;uu++)pa.push(uu);for(var Jx=Z[pa[0]],Wp=Te.level,jo=pa[0]-1;jo>=0;jo--)if(!(O[jo]&s)){Wp=Z[jo];break}var hu=pa[pa.length-1],Qx=Z[hu],Hp=Te.level;if(!(O[hu]&a)){for(var Vo=hu+1;Vo<=Te.end;Vo++)if(!(O[Vo]&s)){Hp=Z[Vo];break}}ou.push({_seqIndices:pa,_sosType:Math.max(Wp,Jx)%2?T:w,_eosType:Math.max(Hp,Qx)%2?T:w})}}for(var cu=0;cu<ou.length;cu++){var du=ou[cu],ae=du._seqIndices,sn=du._sosType,eb=du._eosType,fa=Z[ae[0]]&1?T:w;if(H.get(B))for(var No=0;No<ae.length;No++){var Xp=ae[No];if(O[Xp]&B){for(var pu=sn,Uo=No-1;Uo>=0;Uo--)if(!(O[ae[Uo]]&s)){pu=O[ae[Uo]];break}te(Xp,pu&(a|ke)?P:pu)}}if(H.get(E))for(var $o=0;$o<ae.length;$o++){var Yp=ae[$o];if(O[Yp]&E)for(var Go=$o-1;Go>=-1;Go--){var Kp=Go===-1?sn:O[ae[Go]];if(Kp&n){Kp===j&&te(Yp,z);break}}}if(H.get(j))for(var fu=0;fu<ae.length;fu++){var Jp=ae[fu];O[Jp]&j&&te(Jp,T)}if(H.get(S)||H.get(R))for(var ln=1;ln<ae.length-1;ln++){var mu=ae[ln];if(O[mu]&(S|R)){for(var ma=0,gu=0,_u=ln-1;_u>=0&&(ma=O[ae[_u]],ma&s);_u--);for(var yu=ln+1;yu<ae.length&&(gu=O[ae[yu]],gu&s);yu++);ma===gu&&(O[mu]===S?ma===E:ma&(E|z))&&te(mu,ma)}}if(H.get(E)){for(var Oi=0;Oi<ae.length;Oi++)if(O[ae[Oi]]&E){for(var Zo=Oi-1;Zo>=0&&O[ae[Zo]]&(M|s);Zo--)te(ae[Zo],E);for(Oi++;Oi<ae.length&&O[ae[Oi]]&(M|s|E);Oi++)O[ae[Oi]]!==E&&te(ae[Oi],E)}}if(H.get(M)||H.get(S)||H.get(R))for(var un=0;un<ae.length;un++){var Qp=ae[un];if(O[Qp]&(M|S|R)){te(Qp,P);for(var qo=un-1;qo>=0&&O[ae[qo]]&s;qo--)te(ae[qo],P);for(var Wo=un+1;Wo<ae.length&&O[ae[Wo]]&s;Wo++)te(ae[Wo],P)}}if(H.get(E))for(var vu=0,ef=sn;vu<ae.length;vu++){var tf=ae[vu],xu=O[tf];xu&E?ef===w&&te(tf,w):xu&n&&(ef=xu)}if(H.get(o)){for(var hn=T|E|z,rf=hn|w,Ho=[],ga=[],_a=0;_a<ae.length;_a++)if(O[ae[_a]]&o){var cn=W[ae[_a]],af=void 0;if(v(cn)!==null)if(ga.length<63)ga.push({char:cn,seqIndex:_a});else break;else if((af=x(cn))!==null)for(var dn=ga.length-1;dn>=0;dn--){var bu=ga[dn].char;if(bu===af||bu===x(b(cn))||v(b(bu))===cn){Ho.push([ga[dn].seqIndex,_a]),ga.length=dn;break}}}Ho.sort(function(Gt,Ei){return Gt[0]-Ei[0]});for(var wu=0;wu<Ho.length;wu++){for(var nf=Ho[wu],Xo=nf[0],Tu=nf[1],of=!1,ji=0,Eu=Xo+1;Eu<Tu;Eu++){var sf=ae[Eu];if(O[sf]&rf){of=!0;var lf=O[sf]&hn?T:w;if(lf===fa){ji=lf;break}}}if(of&&!ji){ji=sn;for(var Du=Xo-1;Du>=0;Du--){var uf=ae[Du];if(O[uf]&rf){var hf=O[uf]&hn?T:w;ji=hf===fa?fa:hf;break}}}if(ji){if(O[ae[Xo]]=O[ae[Tu]]=ji,ji!==fa){for(var pn=Xo+1;pn<ae.length;pn++)if(!(O[ae[pn]]&s)){c(W[ae[pn]])&B&&(O[ae[pn]]=ji);break}}if(ji!==fa){for(var fn=Tu+1;fn<ae.length;fn++)if(!(O[ae[fn]]&s)){c(W[ae[fn]])&B&&(O[ae[fn]]=ji);break}}}}for(var pr=0;pr<ae.length;pr++)if(O[ae[pr]]&o){for(var cf=pr,Su=pr,Cu=sn,mn=pr-1;mn>=0;mn--)if(O[ae[mn]]&s)cf=mn;else{Cu=O[ae[mn]]&hn?T:w;break}for(var df=eb,gn=pr+1;gn<ae.length;gn++)if(O[ae[gn]]&(o|s))Su=gn;else{df=O[ae[gn]]&hn?T:w;break}for(var Pu=cf;Pu<=Su;Pu++)O[ae[Pu]]=Cu===df?Cu:fa;pr=Su}}}for(var Qt=Te.start;Qt<=Te.end;Qt++){var tb=Z[Qt],Yo=O[Qt];if(tb&1?Yo&(w|E|z)&&Z[Qt]++:Yo&T?Z[Qt]++:Yo&(z|E)&&(Z[Qt]+=2),Yo&s&&(Z[Qt]=Qt===0?Te.level:Z[Qt-1]),Qt===Te.end||c(W[Qt])&(D|I))for(var Ko=Qt;Ko>=0&&c(W[Ko])&l;Ko--)Z[Ko]=Te.level}}return{levels:Z,paragraphs:Be};function pf(Gt,Ei){for(var Zt=Gt;Zt<W.length;Zt++){var fr=O[Zt];if(fr&(T|j))return 1;if(fr&(I|w)||Ei&&fr===ke)return 0;if(fr&a){var ff=ib(Zt);Zt=ff===-1?W.length:ff}}return 0}function ib(Gt){for(var Ei=1,Zt=Gt+1;Zt<W.length;Zt++){var fr=O[Zt];if(fr&I)break;if(fr&ke){if(--Ei===0)return Zt}else fr&a&&Ei++}return-1}}var zt="14>1,j>2,t>2,u>2,1a>g,2v3>1,1>1,1ge>1,1wd>1,b>1,1j>1,f>1,ai>3,-2>3,+1,8>1k0,-1jq>1y7,-1y6>1hf,-1he>1h6,-1h5>1ha,-1h8>1qi,-1pu>1,6>3u,-3s>7,6>1,1>1,f>1,1>1,+2,3>1,1>1,+13,4>1,1>1,6>1eo,-1ee>1,3>1mg,-1me>1mk,-1mj>1mi,-1mg>1mi,-1md>1,1>1,+2,1>10k,-103>1,1>1,4>1,5>1,1>1,+10,3>1,1>8,-7>8,+1,-6>7,+1,a>1,1>1,u>1,u6>1,1>1,+5,26>1,1>1,2>1,2>2,8>1,7>1,4>1,1>1,+5,b8>1,1>1,+3,1>3,-2>1,2>1,1>1,+2,c>1,3>1,1>1,+2,h>1,3>1,a>1,1>1,2>1,3>1,1>1,d>1,f>1,3>1,1a>1,1>1,6>1,7>1,13>1,k>1,1>1,+19,4>1,1>1,+2,2>1,1>1,+18,m>1,a>1,1>1,lk>1,1>1,4>1,2>1,f>1,3>1,1>1,+3,db>1,1>1,+3,3>1,1>1,+2,14qm>1,1>1,+1,6>1,4j>1,j>2,t>2,u>2,2>1,+1",Ut;function $t(){if(!Ut){var W=f(zt,!0),ce=W.map;W.reverseMap.forEach(function(re,O){ce.set(O,re)}),Ut=ce}}function Et(W){return $t(),Ut.get(W)||null}function nt(W,ce,re,O){var we=W.length;re=Math.max(0,re==null?0:+re),O=Math.min(we-1,O==null?we-1:+O);for(var H=new Map,te=re;te<=O;te++)if(ce[te]&1){var Z=Et(W[te]);Z!==null&&H.set(te,Z)}return H}function Jt(W,ce,re,O){var we=W.length;re=Math.max(0,re==null?0:+re),O=Math.min(we-1,O==null?we-1:+O);var H=[];return ce.paragraphs.forEach(function(te){var Z=Math.max(re,te.start),xe=Math.min(O,te.end);if(Z<xe){for(var Be=ce.levels.slice(Z,xe+1),Te=xe;Te>=Z&&c(W[Te])&l;Te--)Be[Te]=te.level;for(var ot=te.level,Fr=1/0,Ji=0;Ji<Be.length;Ji++){var Li=Be[Ji];Li>ot&&(ot=Li),Li<Fr&&(Fr=Li|1)}for(var Bt=ot;Bt>=Fr;Bt--)for(var Re=0;Re<Be.length;Re++)if(Be[Re]>=Bt){for(var qe=Re;Re+1<Be.length&&Be[Re+1]>=Bt;)Re++;Re>qe&&H.push([qe+Z,Re+Z])}}}),H}function Ti(W,ce,re,O){var we=ui(W,ce,re,O),H=[].concat(W);return we.forEach(function(te,Z){H[Z]=(ce.levels[te]&1?Et(W[te]):null)||W[te]}),H.join("")}function ui(W,ce,re,O){for(var we=Jt(W,ce,re,O),H=[],te=0;te<W.length;te++)H[te]=te;return we.forEach(function(Z){for(var xe=Z[0],Be=Z[1],Te=H.slice(xe,Be+1),ot=Te.length;ot--;)H[Be-ot]=Te[ot]}),H}return e.closingToOpeningBracket=x,e.getBidiCharType=c,e.getBidiCharTypeName=d,e.getCanonicalBracket=b,e.getEmbeddingLevels=Tt,e.getMirroredCharacter=Et,e.getMirroredCharactersMap=nt,e.getReorderSegments=Jt,e.getReorderedIndices=ui,e.getReorderedString=Ti,e.openingToClosingBracket=v,Object.defineProperty(e,"__esModule",{value:!0}),e})({})}var Jd=zS(),RS=/[\u061c\u200e\u200f\u202a-\u202e\u2066-\u2069]/,kS=new Set(["WS","FSI","LRI","RLI","PDI"]),LS=new Set(["S","B"]);function BS(e,t,i,r){let a=[],n=i;for(let o of Lc(e.slice(i,r)))a.push({index:n,text:o,level:t[n]}),n+=o.length;return a}function OS(e,t){let i=!0;for(let r=e.length-1;r>=0;r--){let a=Jd.getBidiCharTypeName(e[r].text[0]);LS.has(a)?(e[r].level=t,i=!0):i&&kS.has(a)?e[r].level=t:i=!1}}function jS(e,t){let i=t,r=1/0;for(let{level:n}of e)n>i&&(i=n),(n|1)<r&&(r=n|1);let a=e.slice();for(let n=i;n>=r;n--)for(let o=0;o<a.length;o++){if(a[o].level<n)continue;let s=o;for(;s+1<a.length&&a[s+1].level>=n;)s++;for(let l=o,u=s;l<u;l++,u--)[a[l],a[u]]=[a[u],a[l]];o=s}return a}function VS(e){return e.level%2==0?e.text:Jd.getMirroredCharacter(e.text)??e.text}function NS(e,t){return e.find(i=>t>=i.start&&t<=i.end)?.level??0}function US(e,t,i,r,a){let n=BS(e,t,r,a);OS(n,i);let o="",s=[];for(let l of jS(n,i)){if(RS.test(l.text))continue;let u=VS(l);o+=u,s.push(...Array(u.length).fill(l.index))}return{text:o,sourceIndices:s}}function $S(e,t){let i=t.filter(n=>n>0&&n<e.length),r=[...new Set([0,...i,e.length])].sort((n,o)=>n-o),a=[];for(let n=0;n+1<r.length;n++)a.push([r[n],r[n+1]]);return a}function w1(e,t){let{levels:i,paragraphs:r}=Jd.getEmbeddingLevels(e);return $S(e,t.concat(r.map(a=>a.start))).map(([a,n])=>US(e,i,NS(r,a),a,n))}function GS(e,t){return w1(e,t).map(i=>i.text)}function ZS(e,t,i){return w1(e,i).map(r=>[r.text,r.sourceIndices.map(a=>t[a]??0)])}var $m=4294967296,Gm=typeof TextDecoder>"u"?null:new TextDecoder("utf-8"),T1=class{constructor(e){this.buf=ArrayBuffer.isView(e)?e:new Uint8Array(e),this.dataView=new DataView(this.buf.buffer,this.buf.byteOffset,this.buf.byteLength),this.pos=0,this.type=0,this._valueStart=-1,this.length=this.buf.length}readFields(e,t,i=this.length){let r;for(;r=this.nextField(i);)e(r,t,this);return t}readMessage(e,t){return this.readFields(e,t,this.readVarint()+this.pos)}readFixed32(){let e=this.dataView.getUint32(this.pos,!0);return this.pos+=4,e}readSFixed32(){let e=this.dataView.getInt32(this.pos,!0);return this.pos+=4,e}readFixed64(){let e=this.dataView.getUint32(this.pos,!0)+this.dataView.getUint32(this.pos+4,!0)*$m;return this.pos+=8,e}readSFixed64(){let e=this.dataView.getUint32(this.pos,!0)+this.dataView.getInt32(this.pos+4,!0)*$m;return this.pos+=8,e}readFloat(){let e=this.dataView.getFloat32(this.pos,!0);return this.pos+=4,e}readDouble(){let e=this.dataView.getFloat64(this.pos,!0);return this.pos+=8,e}readVarint(e){let t=this.buf,i=t[this.pos++];if(i<128)return i;let r=i&127,a;return a=t[this.pos++],r|=(a&127)<<7,a<128||(a=t[this.pos++],r|=(a&127)<<14,a<128)||(a=t[this.pos++],r|=(a&127)<<21,a<128)?r:(a=t[this.pos],r|=(a&15)<<28,qS(r,e,this))}readSVarint(){let e=this.readVarint();return e%2==1?(e+1)/-2:e/2}readBoolean(){return!!this.readVarint()}readString(){let e=this.readVarint()+this.pos,t=this.pos;return this.pos=e,e-t>=12&&Gm?Gm.decode(this.buf.subarray(t,e)):HS(this.buf,t,e)}readBytes(){let e=this.readVarint()+this.pos,t=this.buf.subarray(this.pos,e);return this.pos=e,t}readPackedVarint(e=[],t){let i=this.readPackedEnd();for(;this.pos<i;)e.push(this.readVarint(t));return e}readPackedSVarint(e=[]){let t=this.readPackedEnd();for(;this.pos<t;)e.push(this.readSVarint());return e}readPackedBoolean(e=[]){let t=this.readPackedEnd();for(;this.pos<t;)e.push(this.readBoolean());return e}readPackedFloat(e=[]){let t=this.readPackedEnd();for(;this.pos<t;)e.push(this.readFloat());return e}readPackedDouble(e=[]){let t=this.readPackedEnd();for(;this.pos<t;)e.push(this.readDouble());return e}readPackedFixed32(e=[]){let t=this.readPackedEnd();for(;this.pos<t;)e.push(this.readFixed32());return e}readPackedSFixed32(e=[]){let t=this.readPackedEnd();for(;this.pos<t;)e.push(this.readSFixed32());return e}readPackedFixed64(e=[]){let t=this.readPackedEnd();for(;this.pos<t;)e.push(this.readFixed64());return e}readPackedSFixed64(e=[]){let t=this.readPackedEnd();for(;this.pos<t;)e.push(this.readSFixed64());return e}readPackedEnd(){return this.type===2?this.readVarint()+this.pos:this.pos+1}nextField(e=this.length){if(this.pos===this._valueStart&&this.skip(this.type),this.pos>=e)return 0;let t=this.readVarint();return this.type=t&7,this._valueStart=this.pos,t>>>3}skip(e){let t=e&7;if(t===0)for(;this.buf[this.pos++]>127;);else if(t===2)this.pos=this.readVarint()+this.pos;else if(t===5)this.pos+=4;else if(t===1)this.pos+=8;else throw Error(`Unimplemented type: ${t}`)}};function qS(e,t,i){let r=i.buf,a,n;if(n=r[i.pos++],a=(n&112)>>4,n<128||(n=r[i.pos++],a|=(n&127)<<3,n<128)||(n=r[i.pos++],a|=(n&127)<<10,n<128)||(n=r[i.pos++],a|=(n&127)<<17,n<128)||(n=r[i.pos++],a|=(n&127)<<24,n<128)||(n=r[i.pos++],a|=(n&1)<<31,n<128))return WS(e,a,t);throw Error("Expected varint not more than 10 bytes")}function WS(e,t,i){return i?t*4294967296+(e>>>0):(t>>>0)*4294967296+(e>>>0)}function HS(e,t,i){let r="",a=t;for(;a<i;){let n=e[a],o=null,s=n>239?4:n>223?3:n>191?2:1;if(a+s>i)break;let l,u,h;s===1?n<128&&(o=n):s===2?(l=e[a+1],(l&192)==128&&(o=(n&31)<<6|l&63,o<=127&&(o=null))):s===3?(l=e[a+1],u=e[a+2],(l&192)==128&&(u&192)==128&&(o=(n&15)<<12|(l&63)<<6|u&63,(o<=2047||o>=55296&&o<=57343)&&(o=null))):s===4&&(l=e[a+1],u=e[a+2],h=e[a+3],(l&192)==128&&(u&192)==128&&(h&192)==128&&(o=(n&15)<<18|(l&63)<<12|(u&63)<<6|h&63,(o<=65535||o>=1114112)&&(o=null))),o===null?(o=65533,s=1):o>65535&&(o-=65536,r+=String.fromCharCode(o>>>10&1023|55296),o=56320|o&1023),r+=String.fromCharCode(o),a+=s}return r}function XS(e,t,i){e===1&&i.readMessage(YS,t)}function YS(e,t,i){if(e===3){let{id:r,bitmap:a,width:n,height:o,left:s,top:l,advance:u}=i.readMessage(KS,{});t.push({id:r,bitmap:new Wd({width:n+6,height:o+6},a),metrics:{width:n,height:o,left:s,top:l,advance:u}})}}function KS(e,t,i){e===1?t.id=i.readVarint():e===2?t.bitmap=i.readBytes():e===3?t.width=i.readVarint():e===4?t.height=i.readVarint():e===5?t.left=i.readSVarint():e===6?t.top=i.readSVarint():e===7&&(t.advance=i.readVarint())}function JS(e){return new T1(e).readFields(XS,[])}function dl(e){return typeof e?.renderWithWebGL=="function"}function QS(e){let{userImage:t}=e;return!t?.render||!t.render()?!1:(dl(t.data)||e.data.replace(new Uint8Array(t.data.buffer)),!0)}function E1(e){let t=0,i=0;for(let o of e)t+=o.w*o.h,i=Math.max(i,o.w);e.sort((o,s)=>s.h-o.h);let r=[{x:0,y:0,w:Math.max(Math.ceil(Math.sqrt(t/.95)),i),h:1/0}],a=0,n=0;for(let o of e)for(let s=r.length-1;s>=0;s--){let l=r[s];if(!(o.w>l.w||o.h>l.h)){if(o.x=l.x,o.y=l.y,n=Math.max(n,o.y+o.h),a=Math.max(a,o.x+o.w),o.w===l.w&&o.h===l.h){let u=r.pop();u&&s<r.length&&(r[s]=u)}else o.h===l.h?(l.x+=o.w,l.w-=o.w):o.w===l.w?(l.y+=o.h,l.h-=o.h):(r.push({x:l.x+o.w,y:l.y,w:l.w-o.w,h:o.h}),l.y+=o.h,l.h-=o.h);break}}return{w:a,h:n,fill:t/(a*n)||0}}var Qd=class{constructor(e,{pixelRatio:t,version:i,isWebGLImage:r=!1,stretchX:a,stretchY:n,content:o,textFitWidth:s,textFitHeight:l}){this.paddedRect=e,this.pixelRatio=t,this.stretchX=a,this.stretchY=n,this.content=o,this.version=i,this.needsFirstWebGLRender=r,this.textFitWidth=s,this.textFitHeight=l}get tl(){return[this.paddedRect.x+1,this.paddedRect.y+1]}get br(){return[this.paddedRect.x+this.paddedRect.w-1,this.paddedRect.y+this.paddedRect.h-1]}get tlbr(){return this.tl.concat(this.br)}get displaySize(){return[(this.paddedRect.w-2)/this.pixelRatio,(this.paddedRect.h-2)/this.pixelRatio]}},eC=class{constructor(e,t){let i={},r={};this.haveRenderCallbacks=[],this.patchedUpdateVersion=-1;let a=[];this.addImages(e,i,a),this.addImages(t,r,a);let{w:n,h:o}=E1(a),s=new Ve({width:n||1,height:o||1});for(let l in e){let u=e[l];if(u.isWebGLImage)continue;let h=i[l].paddedRect;Ve.copy(u.data,s,{x:0,y:0},{x:h.x+1,y:h.y+1},u.data)}for(let l in t){let u=t[l],h=r[l].paddedRect,c=h.x+1,d=h.y+1,p=u.data.width,f=u.data.height;Ve.copy(u.data,s,{x:0,y:0},{x:c,y:d},u.data),Ve.copy(u.data,s,{x:0,y:f-1},{x:c,y:d-1},{width:p,height:1}),Ve.copy(u.data,s,{x:0,y:0},{x:c,y:d+f},{width:p,height:1}),Ve.copy(u.data,s,{x:p-1,y:0},{x:c-1,y:d},{width:1,height:f}),Ve.copy(u.data,s,{x:0,y:0},{x:c+p,y:d},{width:1,height:f})}this.image=s,this.iconPositions=i,this.patternPositions=r}addImages(e,t,i){for(let r in e){let a=e[r],n={x:0,y:0,w:a.data.width+2,h:a.data.height+2};i.push(n),t[r]=new Qd(n,a),a.hasRenderCallback&&this.haveRenderCallbacks.push(r)}}patchUpdatedImages(e,t){if(e.dispatchRenderCallbacks(this.haveRenderCallbacks),this.patchedUpdateVersion!==e.updateVersion){this.patchedUpdateVersion=e.updateVersion;for(let i in this.iconPositions)this.patchUpdatedImage(this.iconPositions[i],e.getImage(i),t);for(let i in this.patternPositions)this.patchUpdatedImage(this.patternPositions[i],e.getImage(i),t)}}patchUpdatedImage(e,t,i){if(!e||!t||!e.needsFirstWebGLRender&&e.version===t.version)return;e.needsFirstWebGLRender=!1,e.version=t.version;let[r,a]=e.tl,n=t.userImage?.data;if(!dl(n)){i.update(t.data,void 0,{x:r,y:a});return}let{width:o,height:s}=t.data;i.context.setCustomLayerDefaults(),n.renderWithWebGL({gl:i.context.gl,texture:i.texture,x:r,y:a,width:o,height:s}),i.context.setDirty()}};G("ImagePosition",Qd),G("ImageAtlas",eC);var D1=(function(e){return e[e.none=0]="none",e[e.horizontal=1]="horizontal",e[e.vertical=2]="vertical",e[e.horizontalOnly=3]="horizontalOnly",e})(D1||{});function tC(e){for(let t of e)if(t.positionedGlyphs.length!==0)return!1;return!0}function iC(e,t){let i=[],r=0;for(let a of t)i.push(e.substring(r,a)),r=a;return r<e.length()&&i.push(e.substring(r,e.length())),i}var Zm=/^\p{gc=M}$/u;function rC(e){let t=[],i=0;for(;i<e.length;){if(!Zm.test(e[i])){t.push(i),i++;continue}let r=i;for(;r<e.length&&Zm.test(e[r]);)r++;let a=e[r];if(a!==void 0&&v1(a.codePointAt(0))){t.push(r);for(let n=r-1;n>=i;n--)t.push(n);i=r+1}else{for(let n=i;n<r;n++)t.push(n);i=r}}return t}function aC(e){let t=[],i=0;for(let r of e.graphemes())t.push(...Array(r.length).fill(e.sectionIndex[i])),i++;return t}function nC(e,t){let i=t.map(n=>e.toCodeUnitIndex(n)),r=hl.isParsed()?hl:null;if(e.sections.length===1)return r?r.processBidirectionalText(e.toString(),i).map(n=>qm(n,e.sections,[...n].map(()=>0))):GS(e.toString(),i).map(n=>jc([...n],e.sections,[...n].map(()=>0)));let a=aC(e);return r?r.processStyledBidirectionalText(e.text,a,i).map(([n,o])=>qm(n,e.sections,o)):ZS(e.text,a,i).map(([n,o])=>{let s=[...n];return jc(s,e.sections,S1(s).map(l=>o[l]??0))})}function jc(e,t,i){let r=new Kd(e.join(""),t,[]),a=0;for(let n of r.graphemes())r.sectionIndex.push(i[a]??0),a+=[...n].length;return r}function S1(e){let t=[],i=0;for(let r of e)t.push(i),i+=r.length;return t}function qm(e,t,i){let r=[...e],a=S1(r),n=rC(r);return jc(n.map(o=>r[o]),t,n.map(o=>i[a[o]]??0))}function ps(e,t,i,r,a,n,o,s,l,u,h,c,d,p,f){let m=Kd.fromFeature(e,a);c===2&&m.verticalizePunctuation();let g=m.determineLineBreaks(u,n,t,r,p),_=x1(m.text)?nC(m,g):iC(m,g),y=[],v={positionedLines:y,text:m.toString(),top:h[1],bottom:h[1],left:h[0],right:h[0],writingMode:c,iconsInText:!1,verticalizable:!1};return fC(v,t,i,r,_,o,s,l,c,u,d,f),!tC(y)&&v}function Hl(e){let t=.5,i=.5;switch(e){case"right":case"top-right":case"bottom-right":t=1;break;case"left":case"top-left":case"bottom-left":t=0}switch(e){case"bottom":case"bottom-right":case"bottom-left":i=1;break;case"top":case"top-right":case"top-left":i=0}return{horizontalAlign:t,verticalAlign:i}}function oC(e,t,i){let r=t.getMaxScale()*24,{maxImageWidth:a,maxImageHeight:n}=t.getMaxImageSize(e),o=Math.max(r,n*i);return{verticalLineContentWidth:Math.max(r,a*i),horizontalLineContentHeight:o}}function C1(e){switch(e){case"top":return 0;case"center":return .5;default:return 1}}function sC(e,t,i,r){if(e?.rect)return e;let a=t[i.fontStack]?.default?.[r];return a?{rect:null,metrics:a.metrics}:null}function lC(e,t,i){return!(e===1||!t&&!Wl(i)||t&&(Yd(i)||y1(i)))}function Os(e){return/\p{Nd}/u.test(String.fromCodePoint(e))}function P1(e){return/\p{Lu}/u.test(String.fromCodePoint(e))}function uC(e){return/[\p{P}\p{S}]/u.test(String.fromCodePoint(e))}function hC(e){let t=e.some(Os)&&e.every(r=>Os(r)||uC(r)),i=e.length<=3&&e.every(r=>P1(r)||Os(r));return t||i}function cC(e){return(Os(e)||P1(e))&&!y1(e)}function dC(e,t){let i=!1;for(let r=0;r<e.length;r++){if(t[r])continue;let a=Ia[e[r]];a&&(r===0||t[r-1])&&(r===e.length-1||t[r+1])&&(e[r]=a,t[r]=!0,i=!0)}return i}function pC(e){let t=e.graphemes().slice(),i=t.map(n=>n.codePointAt(0)),r=i.map(Wl),a=n=>!r[n]&&!Yd(i[n])&&!("imageName"in e.getSection(n));for(let n=0;n<i.length;n++){if(!a(n))continue;let o=n;for(;o+1<i.length&&a(o+1);)o++;if(hC(i.slice(n,o+1)))for(let s=n;s<=o;s++)r[s]=cC(i[s]);n=o}return dC(t,r)&&(e.text=t.join(""),e._graphemes=null),r}function fC(e,t,i,r,a,n,o,s,l,u,h,c){let d=0,p=0,f=0,m=0,g=s==="right"?1:s==="left"?0:.5,_=24/c,y=0;for(let b of a){b.trim();let w=b.getMaxScale(),T={positionedGlyphs:[],lineOffset:0};e.positionedLines[y]=T;let E=T.positionedGlyphs,S=0;if(!b.length()){p+=n,++y;continue}let M=oC(r,b,_),z=l===2&&!h?pC(b):null,R=b.graphemes();for(let P=0;P<R.length;P++){let A=b.getSection(P),B=R[P],j=B.codePointAt(0),V=z?z[P]:lC(l,h,j),J="fontStack"in A&&cl(B)&&!t[A.fontStack]?.default?.[B]?[...B]:[B];for(let se of J){let fe={glyph:se.codePointAt(0),grapheme:se,imageName:null,x:d,y:p+-17,vertical:V,scale:1,fontStack:"",sectionIndex:b.getSectionIndex(P),metrics:null,rect:null},ye;if("fontStack"in A){if(ye=mC(A,se,V,M,t,i),!ye)continue;fe.fontStack=A.fontStack}else{if(e.iconsInText=!0,A.scale*=_,ye=gC(A,V,w,M,r),!ye)continue;S=Math.max(S,ye.imageOffset),fe.imageName=A.imageName}let{rect:Ge,metrics:Le,baselineOffset:Ze}=ye;if(fe.y+=Ze,fe.scale=A.scale,fe.metrics=Le,fe.rect=Ge,E.push(fe),!V)d+=Le.advance*A.scale+u;else{e.verticalizable=!0;let ke="imageName"in A?Le.advance:24;d+=ke*A.scale+u}}}if(E.length!==0){let P=d-u;f=Math.max(P,f),_C(E,0,E.length-1,g)}d=0;let I=(w-1)*24;T.lineOffset=Math.max(S,I);let D=n*w+S;p+=D,m=Math.max(D,m),++y}let{horizontalAlign:v,verticalAlign:x}=Hl(o);yC(e.positionedLines,g,v,x,f,m,n,p,a.length),e.top+=-x*p,e.bottom=e.top+p,e.left+=-v*f,e.right=e.left+f}function mC(e,t,i,r,a,n){let o=n[e.fontStack]?.default?.[t],s=sC(o,a,e,t);if(s===null)return null;let l;if(i)l=r.verticalLineContentWidth-e.scale*24;else{let u=C1(e.verticalAlign);l=(r.horizontalLineContentHeight-e.scale*24)*u}return{rect:s.rect,metrics:s.metrics,baselineOffset:l}}function gC(e,t,i,r,a){let n=a[e.imageName];if(!n)return null;let o=n.paddedRect,s=n.displaySize,l={width:s[0],height:s[1],left:1,top:-3,advance:t?s[1]:s[0]},u;if(t)u=r.verticalLineContentWidth-s[1]*e.scale;else{let c=C1(e.verticalAlign);u=(r.horizontalLineContentHeight-s[1]*e.scale)*c}let h=(t?s[0]:s[1])*e.scale-24*i;return{rect:o,metrics:l,baselineOffset:u,imageOffset:h}}function _C(e,t,i,r){if(r===0)return;let a=e[i],n=a.metrics.advance*a.scale,o=(e[i].x+n)*r;for(let s=t;s<=i;s++)e[s].x-=o}function yC(e,t,i,r,a,n,o,s,l){let u=(t-i)*a,h=0;h=n===o?-r*l*o+.5*o:-s*r- -17;for(let c of e)for(let d of c.positionedGlyphs)d.x+=u,d.y+=h}function vC(e,t,i){let{horizontalAlign:r,verticalAlign:a}=Hl(i),n=t[0],o=t[1],s=n-e.displaySize[0]*r,l=s+e.displaySize[0],u=o-e.displaySize[1]*a;return{image:e,top:u,bottom:u+e.displaySize[1],left:s,right:l}}function A1(e){let t=e.left,i=e.top,r=e.right-t,a=e.bottom-i,n=e.image.content[2]-e.image.content[0],o=e.image.content[3]-e.image.content[1],s=e.image.textFitWidth??"stretchOrShrink",l=e.image.textFitHeight??"stretchOrShrink",u=n/o;if(l==="proportional"){if(s==="stretchOnly"&&r/a<u||s==="proportional"){let h=Math.ceil(a*u);t*=h/r,r=h}}else if(s==="proportional"&&l==="stretchOnly"&&u!==0&&r/a>u){let h=Math.ceil(r/u);i*=h/a,a=h}return{x1:t,y1:i,x2:t+r,y2:i+a}}function Wm(e,t,i,r,a,n){let o=e.image,s;if(o.content){let g=o.content,_=o.pixelRatio||1;s=[g[0]/_,g[1]/_,o.displaySize[0]-g[2]/_,o.displaySize[1]-g[3]/_]}let l=t.left*n,u=t.right*n,h,c,d,p;i==="width"||i==="both"?(p=a[0]+l-r[3],c=a[0]+u+r[1]):(p=a[0]+(l+u-o.displaySize[0])/2,c=p+o.displaySize[0]);let f=t.top*n,m=t.bottom*n;return i==="height"||i==="both"?(h=a[1]+f-r[0],d=a[1]+m+r[2]):(h=a[1]+(f+m-o.displaySize[1])/2,d=h+o.displaySize[1]),{image:o,top:h,right:c,bottom:d,left:p,collisionPadding:s}}var Hm=32640;function Xm(e,t){let{expression:i}=t;if(i.kind==="constant")return{kind:"constant",layoutSize:i.evaluate(new Ae(e+1))};if(i.kind==="source")return{kind:"source"};if(i.kind==="composite"){let{minZoom:r,maxZoom:a}=xC(i.zoomStops,e);return{kind:"composite",minZoom:r,maxZoom:a,interpolationType:i.interpolationType}}{let r=bC(i),a=i.evaluate(new Ae(e+1));return{kind:"camera",zoomStops:i.zoomStops,sizes:r,layoutSize:a,interpolationType:i.interpolationType}}}function xC(e,t){let i=0;for(;i<e.length&&e[i]<=t;)i++;i=Math.max(0,i-1);let r=i;for(;r<e.length&&e[r]<t+1;)r++;return r=Math.min(e.length-1,r),{minZoom:e[i],maxZoom:e[r]}}function bC(e){return e.zoomStops.map(t=>e.evaluate(new Ae(t===-1/0?e.zoomStops[1]-1:t)))}function ep(e,{uSize:t,uSizeT:i},{lowerSize:r,upperSize:a}){return e.kind==="source"?r/128:e.kind==="composite"?He.number(r/128,a/128,i):t}function Xl(e,t){let i=0,r=0;return e.kind==="constant"?r=e.layoutSize:e.kind==="camera"?r=wC(e,t):e.kind==="composite"&&(i=TC(e,t)),{uSizeT:i,uSize:r}}function wC({zoomStops:e,sizes:t,layoutSize:i,interpolationType:r},a){let n=e.length-1;for(;n>0&&e[n]>a;)n--;let o=Math.min(n+1,e.length-1),s=r?ie(wi.interpolationFactor(r,a,e[n],e[o]),0,1):0;return Math.min(He.number(t[n],t[o],s),i)}function TC({interpolationType:e,minZoom:t,maxZoom:i},r){return e?ie(wi.interpolationFactor(e,r,t,i),0,1):0}var Ba=class I1 extends C{constructor(t,i,r,a){super(t,i),this.angle=r,a!==void 0&&(this.segment=a)}clone(){return new I1(this.x,this.y,this.angle,this.segment)}};G("Anchor",Ba);function M1(e,t,i,r,a){if(t.segment===void 0||i===0)return!0;let n=t,o=t.segment+1,s=0;for(;s>-i/2;){if(o--,o<0)return!1;s-=e[o].dist(n),n=e[o]}s+=e[o].dist(e[o+1]),o++;let l=[],u=0;for(;s<i/2;){let h=e[o-1],c=e[o],d=e[o+1];if(!d)return!1;let p=h.angleTo(c)-c.angleTo(d);for(p=Math.abs((p+3*Math.PI)%(Math.PI*2)-Math.PI),l.push({distance:s,angleDelta:p}),u+=p;s-l[0].distance>r;)u-=l.shift().angleDelta;if(u>a)return!1;o++,s+=c.dist(d)}return!0}function F1(e){let t=0;for(let i=0;i<e.length-1;i++)t+=e[i].dist(e[i+1]);return t}function z1(e,t,i){return e?3/5*t*i:0}function R1(e,t){return Math.max(e?e.right-e.left:0,t?t.right-t.left:0)}function EC(e,t,i,r,a,n){let o=z1(i,a,n),s=R1(i,r)*n,l=0,u=F1(e)/2;for(let h=0;h<e.length-1;h++){let c=e[h],d=e[h+1],p=c.dist(d);if(l+p>u){let f=(u-l)/p,m=new Ba(He.number(c.x,d.x,f),He.number(c.y,d.y,f),d.angleTo(c),h);return m._round(),!o||M1(e,m,s,o,t)?m:void 0}l+=p}}function DC(e,t,i,r,a,n,o,s,l){let u=z1(r,n,o),h=R1(r,a),c=h*o,d=e[0].x===0||e[0].x===l||e[0].y===0||e[0].y===l;t-c<t/4&&(t=c+t/4);let p=n*2;return k1(e,d?t/2*s%t:(h/2+p)*o*s%t,t,u,i,c,d,!1,l)}function k1(e,t,i,r,a,n,o,s,l){let u=n/2,h=F1(e),c=0,d=t-i,p=[];for(let f=0;f<e.length-1;f++){let m=e[f],g=e[f+1],_=m.dist(g),y=g.angleTo(m);for(;d+i<c+_;){d+=i;let v=(d-c)/_,x=He.number(m.x,g.x,v),b=He.number(m.y,g.y,v);if(x>=0&&x<l&&b>=0&&b<l&&d-u>=0&&d+u<=h){let w=new Ba(x,b,y,f);w._round(),(!r||M1(e,w,n,r,a))&&p.push(w)}}c+=_}return!s&&!p.length&&!o&&(p=k1(e,c/2,i,r,a,n,o,!0,l)),p}function L1(e,t,i,r,a){let n=[];for(let o of e){let s;for(let l=0;l<o.length-1;l++){let u=o[l],h=o[l+1];u.x<t&&h.x<t||(u.x<t?u=new C(t,u.y+(h.y-u.y)*((t-u.x)/(h.x-u.x)))._round():h.x<t&&(h=new C(t,u.y+(h.y-u.y)*((t-u.x)/(h.x-u.x)))._round()),!(u.y<i&&h.y<i)&&(u.y<i?u=new C(u.x+(h.x-u.x)*((i-u.y)/(h.y-u.y)),i)._round():h.y<i&&(h=new C(u.x+(h.x-u.x)*((i-u.y)/(h.y-u.y)),i)._round()),!(u.x>=r&&h.x>=r)&&(u.x>=r?u=new C(r,u.y+(h.y-u.y)*((r-u.x)/(h.x-u.x)))._round():h.x>=r&&(h=new C(r,u.y+(h.y-u.y)*((r-u.x)/(h.x-u.x)))._round()),!(u.y>=a&&h.y>=a)&&(u.y>=a?u=new C(u.x+(h.x-u.x)*((a-u.y)/(h.y-u.y)),a)._round():h.y>=a&&(h=new C(u.x+(h.x-u.x)*((a-u.y)/(h.y-u.y)),a)._round()),(!s||!u.equals(s[s.length-1]))&&(s=[u],n.push(s)),s.push(h)))))}}return n}function Ym(e,t,i,r){let a=[],n=e.image,o=n.pixelRatio,s=n.paddedRect.w-2,l=n.paddedRect.h-2,u={x1:e.left,y1:e.top,x2:e.right,y2:e.bottom},h=n.stretchX||[[0,s]],c=n.stretchY||[[0,l]],d=(D,P)=>D+P[1]-P[0],p=h.reduce(d,0),f=c.reduce(d,0),m=s-p,g=l-f,_=0,y=p,v=0,x=f,b=0,w=m,T=0,E=g;if(n.content&&r){let D=n.content,P=D[2]-D[0],A=D[3]-D[1];(n.textFitWidth||n.textFitHeight)&&(u=A1(e)),_=fs(h,0,D[0]),v=fs(c,0,D[1]),y=fs(h,D[0],D[2]),x=fs(c,D[1],D[3]),b=D[0]-_,T=D[1]-v,w=P-y,E=A-x}let S=u.x1,M=u.y1,z=u.x2-S,R=u.y2-M,I=(D,P,A,B)=>{let j=ms(D.stretch-_,y,z,S),V=gs(D.fixed-b,w,D.stretch,p),J=ms(P.stretch-v,x,R,M),se=gs(P.fixed-T,E,P.stretch,f),fe=ms(A.stretch-_,y,z,S),ye=gs(A.fixed-b,w,A.stretch,p),Ge=ms(B.stretch-v,x,R,M),Le=gs(B.fixed-T,E,B.stretch,f),Ze=new C(j,J),ke=new C(fe,J),Tt=new C(fe,Ge),zt=new C(j,Ge),Ut=new C(V/o,se/o),$t=new C(ye/o,Le/o),Et=t*Math.PI/180;if(Et){let W=Math.sin(Et),ce=Math.cos(Et),re=[ce,-W,W,ce];Ze._matMult(re),ke._matMult(re),zt._matMult(re),Tt._matMult(re)}let nt=D.stretch+D.fixed,Jt=A.stretch+A.fixed,Ti=P.stretch+P.fixed,ui=B.stretch+B.fixed;return{tl:Ze,tr:ke,bl:zt,br:Tt,tex:{x:n.paddedRect.x+1+nt,y:n.paddedRect.y+1+Ti,w:Jt-nt,h:ui-Ti},writingMode:void 0,glyphOffset:[0,0],sectionIndex:0,pixelOffsetTL:Ut,pixelOffsetBR:$t,minFontScaleX:w/o/z,minFontScaleY:E/o/R,isSDF:i}};if(!r||!n.stretchX&&!n.stretchY)a.push(I({fixed:0,stretch:-1},{fixed:0,stretch:-1},{fixed:0,stretch:s+1},{fixed:0,stretch:l+1}));else{let D=Km(h,m,p),P=Km(c,g,f);for(let A=0;A<D.length-1;A++){let B=D[A],j=D[A+1];for(let V=0;V<P.length-1;V++){let J=P[V],se=P[V+1];a.push(I(B,J,j,se))}}}return a}function fs(e,t,i){let r=0;for(let a of e)r+=Math.max(t,Math.min(i,a[1]))-Math.max(t,Math.min(i,a[0]));return r}function Km(e,t,i){let r=[{fixed:-1,stretch:0}];for(let[a,n]of e){let o=r[r.length-1];r.push({fixed:a-o.stretch,stretch:o.stretch}),r.push({fixed:a-o.stretch,stretch:o.stretch+(n-a)})}return r.push({fixed:t+1,stretch:i}),r}function ms(e,t,i,r){return e/t*i+r}function gs(e,t,i,r){return e-t*i/r}function SC(e,t,i,r,a,n,o,s){let l=r.layout.get("text-rotate").evaluate(n,{})*Math.PI/180,u=[];for(let h of t.positionedLines)for(let c of h.positionedGlyphs){if(!c.rect)continue;let d=c.rect||{},p=4,f=!0,m=1,g=0,_=(a||s)&&c.vertical,y=c.metrics.advance*c.scale/2;if(s&&t.verticalizable){let B=(c.scale-1)*24,j=(24-c.metrics.width*c.scale)/2;g=h.lineOffset/2-(c.imageName?-j:B)}if(c.imageName){let B=o[c.imageName];f=B.sdf,m=B.pixelRatio,p=1/m}let v=a?[c.x+y,c.y]:[0,0],x=a?[0,0]:[c.x+y+i[0],c.y+i[1]-g],b=[0,0];_&&(b=x,x=[0,0]);let w=c.metrics.isDoubleResolution?2:1,T=(c.metrics.left-p)*c.scale-y+x[0],E=(-c.metrics.top-p)*c.scale+x[1],S=T+d.w/w*c.scale/m,M=E+d.h/w*c.scale/m,z=new C(T,E),R=new C(S,E),I=new C(T,M),D=new C(S,M);if(_){let B=new C(-y,y- -17),j=-Math.PI/2,V=12-y,J=c.imageName?V:0,se=new C(22-V,-J),fe=new C(...b);z._rotateAround(j,B)._add(se)._add(fe),R._rotateAround(j,B)._add(se)._add(fe),I._rotateAround(j,B)._add(se)._add(fe),D._rotateAround(j,B)._add(se)._add(fe)}if(l){let B=Math.sin(l),j=Math.cos(l),V=[j,-B,B,j];z._matMult(V),R._matMult(V),I._matMult(V),D._matMult(V)}let P=new C(0,0),A=new C(0,0);u.push({tl:z,tr:R,bl:I,br:D,tex:d,writingMode:t.writingMode,glyphOffset:v,sectionIndex:c.sectionIndex,isSDF:f,pixelOffsetTL:P,pixelOffsetBR:A,minFontScaleX:0,minFontScaleY:0})}return u}var _s=class{constructor(e,t,i,r,a,n,o,s,l,u){if(this.boxStartIndex=e.length,l){let h=n.top,c=n.bottom,d=n.collisionPadding;d&&(h-=d[1],c+=d[3]);let p=c-h;p>0&&(p=Math.max(10,p),this.circleDiameter=p)}else{let h=n.image?.content&&(n.image.textFitWidth||n.image.textFitHeight)?A1(n):{x1:n.left,y1:n.top,x2:n.right,y2:n.bottom};h.y1=h.y1*o-s[0],h.y2=h.y2*o+s[2],h.x1=h.x1*o-s[3],h.x2=h.x2*o+s[1];let c=n.collisionPadding;if(c&&(h.x1-=c[0]*o,h.y1-=c[1]*o,h.x2+=c[2]*o,h.y2+=c[3]*o),u){let d=new C(h.x1,h.y1),p=new C(h.x2,h.y1),f=new C(h.x1,h.y2),m=new C(h.x2,h.y2),g=u*Math.PI/180;d._rotate(g),p._rotate(g),f._rotate(g),m._rotate(g),h.x1=Math.min(d.x,p.x,f.x,m.x),h.x2=Math.max(d.x,p.x,f.x,m.x),h.y1=Math.min(d.y,p.y,f.y,m.y),h.y2=Math.max(d.y,p.y,f.y,m.y)}e.emplaceBack(t.x,t.y,h.x1,h.y1,h.x2,h.y2,i,r,a)}this.boxEndIndex=e.length}},CC=class{constructor(e=[],t=(i,r)=>i<r?-1:+(i>r)){if(this.data=e,this.length=this.data.length,this.compare=t,this.length>0)for(let i=(this.length>>1)-1;i>=0;i--)this._down(i)}push(e){this.data.push(e),this._up(this.length++)}pop(){if(this.length===0)return;let e=this.data[0],t=this.data.pop();return--this.length>0&&(this.data[0]=t,this._down(0)),e}peek(){return this.data[0]}_up(e){let{data:t,compare:i}=this,r=t[e];for(;e>0;){let a=e-1>>1,n=t[a];if(i(r,n)>=0)break;t[e]=n,e=a}t[e]=r}_down(e){let{data:t,compare:i}=this,r=this.length>>1,a=t[e];for(;e<r;){let n=(e<<1)+1,o=n+1;if(o<this.length&&i(t[o],t[n])<0&&(n=o),i(t[n],a)>=0)break;t[e]=t[n],e=n}t[e]=a}};function PC(e,t=1){let i=Ii.fromPoints(e[0]),r=Math.min(i.width(),i.height()),a=r/2,n=new CC([],AC),{minX:o,minY:s,maxX:l,maxY:u}=i;if(r===0)return new C(o,s);for(let d=o;d<l;d+=r)for(let p=s;p<u;p+=r)n.push(new Pa(d+a,p+a,a,e));let h=MC(e),c=h;for(;n.length;){let d=n.pop();(d.d>c.d||!c.d)&&(c=d),!(d.max-c.d<=t)&&(a=d.h/2,n.push(new Pa(d.p.x-a,d.p.y-a,a,e)),n.push(new Pa(d.p.x+a,d.p.y-a,a,e)),n.push(new Pa(d.p.x-a,d.p.y+a,a,e)),n.push(new Pa(d.p.x+a,d.p.y+a,a,e)))}return h.d>0&&c.d-h.d<=t?h.p:c.p}function AC(e,t){return t.max-e.max}var Pa=class{constructor(e,t,i,r){this.p=new C(e,t),this.h=i,this.d=IC(this.p,r),this.max=this.d+this.h*Math.SQRT2}};function IC(e,t){let i=!1,r=1/0;for(let a of t)for(let n=0,o=a.length,s=o-1;n<o;s=n++){let l=a[n],u=a[s];l.y>e.y!=u.y>e.y&&e.x<(u.x-l.x)*(e.y-l.y)/(u.y-l.y)+l.x&&(i=!i),r=Math.min(r,G0(e,l,u))}return(i?1:-1)*Math.sqrt(r)}function MC(e){let t=0,i=0,r=0,a=e[0];for(let n=0,o=a.length,s=o-1;n<o;s=n++){let l=a[n],u=a[s],h=l.x*u.y-u.x*l.y;i+=(l.x+u.x)*h,r+=(l.y+u.y)*h,t+=h*3}return new Pa(i/t,r/t,0,e)}var Vc=(function(e){return e[e.center=1]="center",e[e.left=2]="left",e[e.right=3]="right",e[e.top=4]="top",e[e.bottom=5]="bottom",e[e["top-left"]=6]="top-left",e[e["top-right"]=7]="top-right",e[e["bottom-left"]=8]="bottom-left",e[e["bottom-right"]=9]="bottom-right",e})({}),tp=1/0;function B1(e,t){function i(a,n){let o=0,s=0;n<0&&(n=0);let l=n/Math.SQRT2;switch(a){case"top-right":case"top-left":s=l-7;break;case"bottom-right":case"bottom-left":s=-l+7;break;case"bottom":s=-n+7;break;case"top":s=n-7}switch(a){case"top-right":case"bottom-right":o=-l;break;case"top-left":case"bottom-left":o=l;break;case"left":o=n;break;case"right":o=-n}return[o,s]}function r(a,n,o){let s=0,l=0;switch(n=Math.abs(n),o=Math.abs(o),a){case"top-right":case"top-left":case"top":l=o-7;break;case"bottom-right":case"bottom-left":case"bottom":l=-o+7}switch(a){case"top-right":case"bottom-right":case"right":s=-n;break;case"top-left":case"bottom-left":case"left":s=n}return[s,l]}return t[1]===tp?i(e,t[0]):r(e,t[0],t[1])}function O1(e,t,i){let r=e.layout,a=r.get("text-variable-anchor-offset")?.evaluate(t,{},i);if(a){let o=a.values,s=[];for(let l=0;l<o.length;l+=2){let u=s[l]=o[l],h=o[l+1].map(c=>c*24);u.startsWith("top")?h[1]-=7:u.startsWith("bottom")&&(h[1]+=7),s[l+1]=h}return new Wi(s)}let n=r.get("text-variable-anchor");if(n){let o;o=e._unevaluatedLayout.getValue("text-radial-offset")===void 0?r.get("text-offset").evaluate(t,{},i).map(l=>l*24):[r.get("text-radial-offset").evaluate(t,{},i)*24,tp];let s=[];for(let l of n)s.push(l,B1(l,o));return new Wi(s)}return null}function FC(e){var h;e.bucket.createArrays();let t=512*e.bucket.overscaling;e.bucket.tilePixelRatio=k/t,e.bucket.compareText={},e.bucket.iconsNeedLinear=!1;let i=e.bucket.layers[0],r=i.layout,a=i._unevaluatedLayout._values,n={layoutIconSize:a["icon-size"].possiblyEvaluate(new Ae(e.bucket.zoom+1),e.canonical),layoutTextSize:a["text-size"].possiblyEvaluate(new Ae(e.bucket.zoom+1),e.canonical),textMaxSize:a["text-size"].possiblyEvaluate(new Ae(18))};if(e.bucket.textSizeData.kind==="composite"){let{minZoom:c,maxZoom:d}=e.bucket.textSizeData;n.compositeTextSizes=[a["text-size"].possiblyEvaluate(new Ae(c),e.canonical),a["text-size"].possiblyEvaluate(new Ae(d),e.canonical)]}if(e.bucket.iconSizeData.kind==="composite"){let{minZoom:c,maxZoom:d}=e.bucket.iconSizeData;n.compositeIconSizes=[a["icon-size"].possiblyEvaluate(new Ae(c),e.canonical),a["icon-size"].possiblyEvaluate(new Ae(d),e.canonical)]}let o=r.get("text-line-height")*24,s=r.get("text-rotation-alignment")!=="viewport"&&r.get("symbol-placement")!=="point",l=r.get("text-keep-upright"),u=r.get("text-size");for(let c of e.bucket.features){let d=r.get("text-font").evaluate(c,{},e.canonical).join(","),p=u.evaluate(c,{},e.canonical),f=n.layoutTextSize.evaluate(c,{},e.canonical),m=n.layoutIconSize.evaluate(c,{},e.canonical),g={horizontal:{},vertical:void 0},_=c.text,y=[0,0];if(_){let w=_.toString(),T=r.get("text-letter-spacing").evaluate(c,{},e.canonical)*24,E=CS(w)?T:0,S=r.get("text-anchor").evaluate(c,{},e.canonical),M=O1(i,c,e.canonical);if(!M){let D=r.get("text-radial-offset").evaluate(c,{},e.canonical);y=D?B1(S,[D*24,tp]):r.get("text-offset").evaluate(c,{},e.canonical).map(P=>P*24)}let z=s?"center":r.get("text-justify").evaluate(c,{},e.canonical),R=r.get("symbol-placement")==="point"?r.get("text-max-width").evaluate(c,{},e.canonical)*24:1/0,I=()=>{e.bucket.allowVerticalPlacement&&Bc(w)&&(g.vertical=ps(_,e.glyphMap,e.glyphPositions,e.imagePositions,d,R,o,S,"left",E,y,2,!0,f,p))};if(!s&&M){let D=new Set;if(z==="auto")for(let A=0;A<M.values.length;A+=2)D.add(Nc(M.values[A]));else D.add(z);let P=!1;for(let A of D)if(!g.horizontal[A])if(P)g.horizontal[A]=g.horizontal[0];else{let B=ps(_,e.glyphMap,e.glyphPositions,e.imagePositions,d,R,o,"center",A,E,y,1,!1,f,p);B&&(g.horizontal[A]=B,P=B.positionedLines.length===1)}I()}else{z==="auto"&&(z=Nc(S));let D=ps(_,e.glyphMap,e.glyphPositions,e.imagePositions,d,R,o,S,z,E,y,1,!1,f,p);D&&(g.horizontal[z]=D),I(),Bc(w)&&s&&l&&(g.vertical=ps(_,e.glyphMap,e.glyphPositions,e.imagePositions,d,R,o,S,z,E,y,2,!1,f,p))}}let v,x=!1;if(c.icon?.name){let w=e.imageMap[c.icon.name];w&&(v=vC(e.imagePositions[c.icon.name],r.get("icon-offset").evaluate(c,{},e.canonical),r.get("icon-anchor").evaluate(c,{},e.canonical)),x=!!w.sdf,e.bucket.sdfIcons===void 0?e.bucket.sdfIcons=x:e.bucket.sdfIcons!==x&&_e("Style sheet warning: Cannot mix SDF and non-SDF icons in one buffer"),w.pixelRatio===e.bucket.pixelRatio?r.get("icon-rotate").constantOr(1)!==0&&(e.bucket.iconsNeedLinear=!0):e.bucket.iconsNeedLinear=!0)}let b=j1(g.horizontal)||g.vertical;(h=e.bucket).iconsInText||(h.iconsInText=b?b.iconsInText:!1),(b||v)&&zC(e.bucket,c,g,v,e.imageMap,n,f,m,y,x,e.canonical,e.subdivisionGranularity,e.hasPromoteId)}e.showCollisionBoxes&&e.bucket.generateCollisionDebugBuffers()}function Nc(e){switch(e){case"right":case"top-right":case"bottom-right":return"right";case"left":case"top-left":case"bottom-left":return"left"}return"center"}function zC(e,t,i,r,a,n,o,s,l,u,h,c,d){let p=n.textMaxSize.evaluate(t,{});p===void 0&&(p=o);let f=e.layers[0].layout,m=f.get("icon-offset").evaluate(t,{},h),g=j1(i.horizontal),_=o/24,y=e.tilePixelRatio*_,v=e.tilePixelRatio*p/24,x=e.tilePixelRatio*s,b=e.tilePixelRatio*f.get("symbol-spacing"),w=f.get("text-padding")*e.tilePixelRatio,T=GC(f,t,h,e.tilePixelRatio),E=f.get("text-max-angle")/180*Math.PI,S=f.get("text-rotation-alignment")!=="viewport"&&f.get("symbol-placement")!=="point",M=f.get("icon-rotation-alignment").constantOr("viewport")==="map"&&f.get("symbol-placement")!=="point",z=f.get("symbol-placement"),R=b/2,I=f.get("icon-text-fit"),D;r&&I!=="none"&&(e.allowVerticalPlacement&&i.vertical&&(D=Wm(r,i.vertical,I,f.get("icon-text-fit-padding"),m,_)),g&&(r=Wm(r,g,I,f.get("icon-text-fit-padding"),m,_)));let P=h?c.line.getGranularityForZoomLevel(h.z):1,A=(B,j)=>{j.x<0||j.x>=8192||j.y<0||j.y>=8192||kC(e,j,B,i,r,a,D,e.layers[0],e.collisionBoxArray,t.index,t.sourceLayerIndex,e.index,y,[w,w,w,w],S,l,x,T,M,m,t,n,u,h,o,d)};if(z==="line")for(let B of L1(t.geometry,0,0,k,k)){let j=Zr(B,P),V=DC(j,b,E,i.vertical||g,r,24,v,e.overscaling,k);for(let J of V){let se=g;(!se||!LC(e,se.text,R,J))&&A(j,J)}}else if(z==="line-center"){for(let B of t.geometry)if(B.length>1){let j=Zr(B,P),V=EC(j,E,i.vertical||g,r,24,v);V&&A(j,V)}}else if(t.type==="Polygon")for(let B of zl(t.geometry,0)){let j=PC(B,16);A(Zr(B[0],P,!0),new Ba(j.x,j.y,0))}else if(t.type==="LineString")for(let B of t.geometry){let j=Zr(B,P);A(j,new Ba(j[0].x,j[0].y,0))}else if(t.type==="Point")for(let B of t.geometry)for(let j of B)A([j],new Ba(j.x,j.y,0))}function RC(e,t){let i=e.length,r=t?.values;if(r?.length>0)for(let a=0;a<r.length;a+=2){let n=Vc[r[a]],o=r[a+1];e.emplaceBack(n,o[0],o[1])}return[i,e.length]}function Jm(e,t,i,r,a,n,o,s,l,u,h,c,d,p,f,m){let g=SC(t,i,s,a,n,o,r,e.allowVerticalPlacement),_=e.textSizeData,y=null;_.kind==="source"?(y=[128*a.layout.get("text-size").evaluate(o,{})],y[0]>32640&&_e(`${e.layerIds[0]}: Value for "text-size" is >= 255. Reduce your "text-size".`)):_.kind==="composite"&&(y=[128*f.compositeTextSizes[0].evaluate(o,{},m),128*f.compositeTextSizes[1].evaluate(o,{},m)],(y[0]>32640||y[1]>32640)&&_e(`${e.layerIds[0]}: Value for "text-size" is >= 255. Reduce your "text-size".`)),e.addSymbols(e.text,g,y,s,n,o,h,t,u.lineStartIndex,u.lineLength,p,m,l);for(let v of c)d[v]=e.text.placedSymbolArray.length-1;return g.length*4}function j1(e){for(let t in e)return e[t];return null}function kC(e,t,i,r,a,n,o,s,l,u,h,c,d,p,f,m,g,_,y,v,x,b,w,T,E,S){let M=e.addToLineVertexArray(t,i),z=s.layout.get("symbol-height-offset").evaluate(x,{},T);z>e.maxHeightOffset&&(e.maxHeightOffset=z);let R,I,D,P,A=0,B=0,j=0,V=0,J=-1,se=-1,fe={},ye=(0,al.default)("");if(e.allowVerticalPlacement&&r.vertical){let re=s.layout.get("text-rotate").evaluate(x,{},T)+90,O=r.vertical;D=new _s(l,t,u,h,c,O,d,p,f,re),o&&(P=new _s(l,t,u,h,c,o,g,_,f,re))}if(a){let re=s.layout.get("icon-rotate").evaluate(x,{}),O=s.layout.get("icon-text-fit")!=="none",we=Ym(a,re,w,O),H=o?Ym(o,re,w,O):void 0;I=new _s(l,t,u,h,c,a,g,_,!1,re),A=we.length*4;let te=e.iconSizeData,Z=null;te.kind==="source"?(Z=[128*s.layout.get("icon-size").evaluate(x,{})],Z[0]>32640&&_e(`${e.layerIds[0]}: Value for "icon-size" is >= 255. Reduce your "icon-size".`)):te.kind==="composite"&&(Z=[128*b.compositeIconSizes[0].evaluate(x,{},T),128*b.compositeIconSizes[1].evaluate(x,{},T)],(Z[0]>32640||Z[1]>32640)&&_e(`${e.layerIds[0]}: Value for "icon-size" is >= 255. Reduce your "icon-size".`)),e.addSymbols(e.icon,we,Z,v,y,x,0,t,M.lineStartIndex,M.lineLength,-1,T,z),J=e.icon.placedSymbolArray.length-1,H&&(B=H.length*4,e.addSymbols(e.icon,H,Z,v,y,x,2,t,M.lineStartIndex,M.lineLength,-1,T,z),se=e.icon.placedSymbolArray.length-1)}let Ge=Object.keys(r.horizontal);for(let re of Ge){let O=r.horizontal[re];R||(R=(ye=(0,al.default)(O.text),new _s(l,t,u,h,c,O,d,p,f,s.layout.get("text-rotate").evaluate(x,{},T))));let we=O.positionedLines.length===1;if(j+=Jm(e,t,O,n,s,f,x,m,z,M,r.vertical?1:3,we?Ge:[re],fe,J,b,T),we)break}r.vertical&&(V+=Jm(e,t,r.vertical,n,s,f,x,m,z,M,2,["vertical"],fe,se,b,T));let Le=R?R.boxStartIndex:e.collisionBoxArray.length,Ze=R?R.boxEndIndex:e.collisionBoxArray.length,ke=D?D.boxStartIndex:e.collisionBoxArray.length,Tt=D?D.boxEndIndex:e.collisionBoxArray.length,zt=I?I.boxStartIndex:e.collisionBoxArray.length,Ut=I?I.boxEndIndex:e.collisionBoxArray.length,$t=P?P.boxStartIndex:e.collisionBoxArray.length,Et=P?P.boxEndIndex:e.collisionBoxArray.length,nt=-1,Jt=(re,O)=>re?.circleDiameter?Math.max(re.circleDiameter,O):O;nt=Jt(R,nt),nt=Jt(D,nt),nt=Jt(I,nt),nt=Jt(P,nt);let Ti=+(nt>-1);Ti&&(nt*=E/24),e.glyphOffsetArray.length>=e.maxGlyphs&&_e("Too many glyphs being rendered in a tile. See https://github.com/mapbox/mapbox-gl-js/issues/2907"),x.sortKey!==void 0&&e.addToSortKeyRanges(e.symbolInstances.length,x.sortKey);let ui=O1(s,x,T),[W,ce]=RC(e.textAnchorOffsets,ui);S&&(ye=BC(ye,x)),e.symbolInstances.emplaceBack(t.x,t.y,fe.right>=0?fe.right:-1,fe.center>=0?fe.center:-1,fe.left>=0?fe.left:-1,fe.vertical||-1,J,se,ye,Le,Ze,ke,Tt,zt,Ut,$t,Et,u,j,V,A,B,Ti,0,d,nt,W,ce,z)}function LC(e,t,i,r){let a=e.compareText;if(!(t in a))a[t]=[];else{let n=a[t];for(let o=n.length-1;o>=0;o--)if(r.dist(n[o])<i)return!0}return a[t].push(r),!1}function BC(e,t){return t.id==null||t.properties?.cluster?e:(0,al.default)(String(t.id),e)}function pl(e,t,i){let r="never",a=e.get(t);return a?r=a:e.get(i)&&(r="always"),r}var OC=[{name:"a_fade_opacity",components:1,type:"Uint8",offset:0}];function ys(e,t,i,r,a,n,o,s,l,u,h,c,d,p){let f=s?Math.min(Hm,Math.round(s[0])):0,m=s?Math.min(Hm,Math.round(s[1])):0;e.emplaceBack(t,i,Math.round(r*32),Math.round(a*32),n,o,(f<<1)+ +!!l,m,u*16,h*16,c*256,d*256,p)}function fl(e,t,i){e.emplaceBack(t.x,t.y,i),e.emplaceBack(t.x,t.y,i),e.emplaceBack(t.x,t.y,i),e.emplaceBack(t.x,t.y,i)}function jC(e){for(let t of e.sections)if(x1(t.text))return!0;return!1}var Uc=class{constructor(e){this.layoutVertexArray=new ZT,this.indexArray=new Xi,this.programConfigurations=e,this.segments=new Ye,this.dynamicLayoutVertexArray=new qT,this.opacityVertexArray=new WT,this.hasVisibleVertices=!1,this.placedSymbolArray=new P0}isEmpty(){return this.layoutVertexArray.length===0&&this.indexArray.length===0&&this.dynamicLayoutVertexArray.length===0&&this.opacityVertexArray.length===0}upload(e,t,i,r){this.isEmpty()||(i&&(this.layoutVertexBuffer=e.createVertexBuffer(this.layoutVertexArray,XD.members),this.indexBuffer=e.createIndexBuffer(this.indexArray,t),this.dynamicLayoutVertexBuffer=e.createVertexBuffer(this.dynamicLayoutVertexArray,YD.members,!0),this.opacityVertexBuffer=e.createVertexBuffer(this.opacityVertexArray,OC,!0),this.opacityVertexBuffer.itemSize=1),(i||r)&&this.programConfigurations.upload(e))}destroy(){this.layoutVertexBuffer&&(this.layoutVertexBuffer.destroy(),this.indexBuffer.destroy(),this.programConfigurations.destroy(),this.segments.destroy(),this.dynamicLayoutVertexBuffer.destroy(),this.opacityVertexBuffer.destroy())}};G("SymbolBuffers",Uc);var $c=class{constructor(e,t,i){this.layoutVertexArray=new e,this.layoutAttributes=t,this.indexArray=new i,this.segments=new Ye,this.collisionVertexArray=new XT}upload(e){this.layoutVertexBuffer=e.createVertexBuffer(this.layoutVertexArray,this.layoutAttributes),this.indexBuffer=e.createIndexBuffer(this.indexArray),this.collisionVertexBuffer=e.createVertexBuffer(this.collisionVertexArray,KD.members,!0)}destroy(){this.layoutVertexBuffer&&(this.layoutVertexBuffer.destroy(),this.indexBuffer.destroy(),this.segments.destroy(),this.collisionVertexBuffer.destroy())}};G("CollisionBuffers",$c);var ml=class{constructor(e){this.collisionBoxArray=e.collisionBoxArray,this.zoom=e.zoom,this.overscaling=e.overscaling,this.layers=e.layers,this.layerIds=this.layers.map(o=>o.id),this.index=e.index,this.pixelRatio=e.pixelRatio,this.sourceLayerIndex=e.sourceLayerIndex,this.hasDependencies=!0,this.hasRTLText=!1,this.maxHeightOffset=0,this.sortKeyRanges=[],this.collisionCircleArray=[],this.maxGlyphs=65535;let t=this.layers[0]._unevaluatedLayout._values;this.textSizeData=Xm(this.zoom,t["text-size"]),this.iconSizeData=Xm(this.zoom,t["icon-size"]);let i=this.layers[0].layout,r=i.get("symbol-sort-key"),a=i.get("symbol-z-order");this.canOverlap=pl(i,"text-overlap","text-allow-overlap")!=="never"||pl(i,"icon-overlap","icon-allow-overlap")!=="never"||i.get("text-ignore-placement")||i.get("icon-ignore-placement"),this.sortFeaturesByKey=a!=="viewport-y"&&!r.isConstant();let n=a==="viewport-y"||a==="auto"&&!this.sortFeaturesByKey;this.sortFeaturesByY=n&&this.canOverlap,i.get("symbol-placement")==="point"&&(this.writingModes=i.get("text-writing-mode").map(o=>D1[o])),this.stateDependentLayerIds=this.layers.filter(o=>o.isStateDependent()).map(o=>o.id),this.sourceID=e.sourceID}createArrays(){this.text=new Uc(new ea(this.layers,this.zoom,e=>e.startsWith("text"))),this.icon=new Uc(new ea(this.layers,this.zoom,e=>e.startsWith("icon"))),this.glyphOffsetArray=new M0,this.lineVertexArray=new F0,this.symbolInstances=new I0,this.textAnchorOffsets=new R0}calculateGlyphDependencies(e,t,i,r,a){var l;let n=(r||this.allowVerticalPlacement)&&a,o=Kd.fromFeature(e,i),s=o.graphemes();for(let u=0;u<s.length;u++){let h=o.getSection(u);if("imageName"in h)continue;let c=(t[l=h.fontStack]||(t[l]={default:{}})).default,d=s[u];cl(d)&&(c[d]=!0);for(let p of d){if(c[p]=!0,!n)continue;let f=Ia[p];f&&(c[f]=!0)}}}populate(e,t,i){let r=this.layers[0],a=r.layout,n=a.get("text-font"),o=a.get("text-field"),s=a.get("icon-image"),l=(o.value.kind!=="constant"||o.value.value instanceof hr&&!o.value.value.isEmpty()||o.value.value.toString().length>0)&&(n.value.kind!=="constant"||n.value.value.length>0),u=s.value.kind!=="constant"||!!s.value.value||Object.keys(s.parameters).length>0,h=a.get("symbol-sort-key");if(this.features=[],!l&&!u)return;let c=t.iconDependencies,d=t.glyphDependencies,p=t.availableImages,f=new Ae(this.zoom);for(let{feature:m,id:g,index:_,sourceLayerIndex:y}of e){let v=r._featureFilter.needGeometry,x=la(m,v);if(!r._featureFilter.filter(f,x,i))continue;v||(x.geometry=sa(m));let b;if(l){let S=r.getValueAndResolveTokens("text-field",x,i,p),M=hr.factory(S);this.hasRTLText||(this.hasRTLText=jC(M)),b=TS(M,r,x)}let w;if(u){let S=r.getValueAndResolveTokens("icon-image",x,i,p);w=S instanceof Hi?S:Hi.fromString(S)}if(!b&&!w)continue;let T=this.sortFeaturesByKey?h.evaluate(x,{},i):void 0,E={id:g,text:b,icon:w,index:_,sourceLayerIndex:y,geometry:x.geometry,properties:m.properties,type:Po.types[m.type],sortKey:T};if(this.features.push(E),w&&(c[w.name]=!0),b){let S=n.evaluate(x,{},i).join(","),M=a.get("text-rotation-alignment")!=="viewport"&&a.get("symbol-placement")!=="point";this.allowVerticalPlacement=this.writingModes?.includes(2);let z=Bc(b.toString());this.calculateGlyphDependencies(b,d,S,M,z);for(let R of b.sections)R.image&&(c[R.image.name]=!0)}}a.get("symbol-placement")==="line"&&(this.features=DS(this.features)),this.sortFeaturesByKey&&this.features.sort((m,g)=>m.sortKey-g.sortKey)}update(e,t,i){this.stateDependentLayers.length&&(this.text.programConfigurations.updatePaintArrays(e,t,this.layers,{imagePositions:i}),this.icon.programConfigurations.updatePaintArrays(e,t,this.layers,{imagePositions:i}))}addFeatures({options:e,canonical:t,glyphMap:i,glyphPositions:r,iconMap:a,iconPositions:n,showCollisionBoxes:o}){FC({bucket:this,glyphMap:i,glyphPositions:r,imageMap:a,imagePositions:n,showCollisionBoxes:o,canonical:t,subdivisionGranularity:e.subdivisionGranularity,hasPromoteId:e.featureIndex.promoteId!=null})}isEmpty(){return this.symbolInstances.length===0}uploadPending(){return!this.uploaded||this.text.programConfigurations.needsUpload||this.icon.programConfigurations.needsUpload}upload(e){!this.uploaded&&this.hasDebugData()&&(this.textCollisionBox.upload(e),this.iconCollisionBox.upload(e)),this.text.upload(e,this.sortFeaturesByY,!this.uploaded,this.text.programConfigurations.needsUpload),this.icon.upload(e,this.sortFeaturesByY,!this.uploaded,this.icon.programConfigurations.needsUpload),this.uploaded=!0}destroyDebugData(){this.textCollisionBox.destroy(),this.iconCollisionBox.destroy()}destroy(){this.text.destroy(),this.icon.destroy(),this.hasDebugData()&&this.destroyDebugData()}addToLineVertexArray(e,t){let i=this.lineVertexArray.length;if(e.segment!==void 0){let r=e.dist(t[e.segment+1]),a=e.dist(t[e.segment]),n={};for(let o=e.segment+1;o<t.length;o++)n[o]={x:t[o].x,y:t[o].y,tileUnitDistanceFromAnchor:r},o<t.length-1&&(r+=t[o+1].dist(t[o]));for(let o=e.segment||0;o>=0;o--)n[o]={x:t[o].x,y:t[o].y,tileUnitDistanceFromAnchor:a},o>0&&(a+=t[o-1].dist(t[o]));for(let o=0;o<t.length;o++){let s=n[o];this.lineVertexArray.emplaceBack(s.x,s.y,s.tileUnitDistanceFromAnchor)}}return{lineStartIndex:i,lineLength:this.lineVertexArray.length-i}}addSymbols(e,t,i,r,a,n,o,s,l,u,h,c,d){let p=e.indexArray,f=e.layoutVertexArray,m=e.segments.prepareSegment(4*t.length,f,p,this.canOverlap?n.sortKey:void 0),g=this.glyphOffsetArray.length,_=m.vertexLength,y=this.allowVerticalPlacement&&o===2?Math.PI/2:0,v=n.text&&n.text.sections;for(let x=0;x<t.length;x++){let{tl:b,tr:w,bl:T,br:E,tex:S,pixelOffsetTL:M,pixelOffsetBR:z,minFontScaleX:R,minFontScaleY:I,glyphOffset:D,isSDF:P,sectionIndex:A}=t[x],B=m.vertexLength,j=D[1];ys(f,s.x,s.y,b.x,j+b.y,S.x,S.y,i,P,M.x,M.y,R,I,d),ys(f,s.x,s.y,w.x,j+w.y,S.x+S.w,S.y,i,P,z.x,M.y,R,I,d),ys(f,s.x,s.y,T.x,j+T.y,S.x,S.y+S.h,i,P,M.x,z.y,R,I,d),ys(f,s.x,s.y,E.x,j+E.y,S.x+S.w,S.y+S.h,i,P,z.x,z.y,R,I,d),fl(e.dynamicLayoutVertexArray,s,y),p.emplaceBack(B,B+2,B+1),p.emplaceBack(B+1,B+2,B+3),m.vertexLength+=4,m.primitiveLength+=2,this.glyphOffsetArray.emplaceBack(D[0]),(x===t.length-1||A!==t[x+1].sectionIndex)&&e.programConfigurations.populatePaintArrays(f.length,n,n.index,{imagePositions:{},canonical:c,formattedSection:v?.[A]})}e.placedSymbolArray.emplaceBack(s.x,s.y,g,this.glyphOffsetArray.length-g,_,l,u,s.segment,i?i[0]:0,i?i[1]:0,r[0],r[1],o,0,!1,0,h,d)}_addCollisionDebugVertex(e,t,i,r,a,n){return t.emplaceBack(0,0),e.emplaceBack(i.x,i.y,r,a,Math.round(n.x),Math.round(n.y))}addCollisionDebugVertices(e,t,i,r,a,n,o){let s=a.segments.prepareSegment(4,a.layoutVertexArray,a.indexArray),l=s.vertexLength,u=a.layoutVertexArray,h=a.collisionVertexArray,c=o.anchorX,d=o.anchorY;this._addCollisionDebugVertex(u,h,n,c,d,new C(e,t)),this._addCollisionDebugVertex(u,h,n,c,d,new C(i,t)),this._addCollisionDebugVertex(u,h,n,c,d,new C(i,r)),this._addCollisionDebugVertex(u,h,n,c,d,new C(e,r)),s.vertexLength+=4;let p=a.indexArray;p.emplaceBack(l,l+1),p.emplaceBack(l+1,l+2),p.emplaceBack(l+2,l+3),p.emplaceBack(l+3,l),s.primitiveLength+=4}addDebugCollisionBoxes(e,t,i,r){for(let a=e;a<t;a++){let n=this.collisionBoxArray.get(a),o=n.x1,s=n.y1,l=n.x2,u=n.y2;this.addCollisionDebugVertices(o,s,l,u,r?this.textCollisionBox:this.iconCollisionBox,n.anchorPoint,i)}}generateCollisionDebugBuffers(){this.hasDebugData()&&this.destroyDebugData(),this.textCollisionBox=new $c(am,zm.members,gc),this.iconCollisionBox=new $c(am,zm.members,gc);for(let e=0;e<this.symbolInstances.length;e++){let t=this.symbolInstances.get(e);this.addDebugCollisionBoxes(t.textBoxStartIndex,t.textBoxEndIndex,t,!0),this.addDebugCollisionBoxes(t.verticalTextBoxStartIndex,t.verticalTextBoxEndIndex,t,!0),this.addDebugCollisionBoxes(t.iconBoxStartIndex,t.iconBoxEndIndex,t,!1),this.addDebugCollisionBoxes(t.verticalIconBoxStartIndex,t.verticalIconBoxEndIndex,t,!1)}}_deserializeCollisionBoxesForSymbol(e,t,i,r,a,n,o,s,l){let u={};for(let h=t;h<i;h++){let c=e.get(h);u.textBox={x1:c.x1,y1:c.y1,x2:c.x2,y2:c.y2,anchorPointX:c.anchorPointX,anchorPointY:c.anchorPointY},u.textFeatureIndex=c.featureIndex;break}for(let h=r;h<a;h++){let c=e.get(h);u.verticalTextBox={x1:c.x1,y1:c.y1,x2:c.x2,y2:c.y2,anchorPointX:c.anchorPointX,anchorPointY:c.anchorPointY},u.verticalTextFeatureIndex=c.featureIndex;break}for(let h=n;h<o;h++){let c=e.get(h);u.iconBox={x1:c.x1,y1:c.y1,x2:c.x2,y2:c.y2,anchorPointX:c.anchorPointX,anchorPointY:c.anchorPointY},u.iconFeatureIndex=c.featureIndex;break}for(let h=s;h<l;h++){let c=e.get(h);u.verticalIconBox={x1:c.x1,y1:c.y1,x2:c.x2,y2:c.y2,anchorPointX:c.anchorPointX,anchorPointY:c.anchorPointY},u.verticalIconFeatureIndex=c.featureIndex;break}return u}deserializeCollisionBoxes(e){this.collisionArrays=[];for(let t=0;t<this.symbolInstances.length;t++){let i=this.symbolInstances.get(t);this.collisionArrays.push(this._deserializeCollisionBoxesForSymbol(e,i.textBoxStartIndex,i.textBoxEndIndex,i.verticalTextBoxStartIndex,i.verticalTextBoxEndIndex,i.iconBoxStartIndex,i.iconBoxEndIndex,i.verticalIconBoxStartIndex,i.verticalIconBoxEndIndex))}}hasTextData(){return this.text.segments.get().length>0}hasIconData(){return this.icon.segments.get().length>0}hasDebugData(){return this.textCollisionBox&&this.iconCollisionBox}hasTextCollisionBoxData(){return this.hasDebugData()&&this.textCollisionBox.segments.get().length>0}hasIconCollisionBoxData(){return this.hasDebugData()&&this.iconCollisionBox.segments.get().length>0}addIndicesForPlacedSymbol(e,t){let i=e.placedSymbolArray.get(t),r=i.vertexStartIndex+i.numGlyphs*4;for(let a=i.vertexStartIndex;a<r;a+=4)e.indexArray.emplaceBack(a,a+2,a+1),e.indexArray.emplaceBack(a+1,a+2,a+3)}getSortedSymbolIndexes(e){if(this.sortedAngle===e&&this.symbolInstanceIndexes!==void 0)return this.symbolInstanceIndexes;let t=Math.sin(e),i=Math.cos(e),r=[],a=[],n=[];for(let o=0;o<this.symbolInstances.length;++o){n.push(o);let s=this.symbolInstances.get(o);r.push(Math.round(t*s.anchorX+i*s.anchorY)|0),a.push(s.featureIndex)}return n.sort((o,s)=>r[o]-r[s]||a[s]-a[o]),n}addToSortKeyRanges(e,t){let i=this.sortKeyRanges[this.sortKeyRanges.length-1];i?.sortKey===t?i.symbolInstanceEnd=e+1:this.sortKeyRanges.push({sortKey:t,symbolInstanceStart:e,symbolInstanceEnd:e+1})}sortFeatures(e){if(this.sortFeaturesByY&&this.sortedAngle!==e&&!(this.text.segments.get().length>1||this.icon.segments.get().length>1)){this.symbolInstanceIndexes=this.getSortedSymbolIndexes(e),this.sortedAngle=e,this.text.indexArray.clear(),this.icon.indexArray.clear(),this.featureSortOrder=[];for(let t of this.symbolInstanceIndexes){let i=this.symbolInstances.get(t);this.featureSortOrder.push(i.featureIndex);let r=[i.rightJustifiedTextSymbolIndex,i.centerJustifiedTextSymbolIndex,i.leftJustifiedTextSymbolIndex];for(let a=0;a<r.length;a++){let n=r[a];n>=0&&r.indexOf(n)===a&&this.addIndicesForPlacedSymbol(this.text,n)}i.verticalPlacedTextSymbolIndex>=0&&this.addIndicesForPlacedSymbol(this.text,i.verticalPlacedTextSymbolIndex),i.placedIconSymbolIndex>=0&&this.addIndicesForPlacedSymbol(this.icon,i.placedIconSymbolIndex),i.verticalPlacedIconSymbolIndex>=0&&this.addIndicesForPlacedSymbol(this.icon,i.verticalPlacedIconSymbolIndex)}this.text.indexBuffer&&this.text.indexBuffer.updateData(this.text.indexArray),this.icon.indexBuffer&&this.icon.indexBuffer.updateData(this.icon.indexArray)}}};G("SymbolBucket",ml,{omit:["layers","collisionBoxArray","features","compareText"]});function VC(e,t){return t.replace(/{([^{}]+)}/g,(i,r)=>e&&r in e?String(e[r]):"")}var Qm,NC=()=>Qm||(Qm=new wt({"symbol-placement":new U(F.layout_symbol["symbol-placement"],"symbol-placement"),"symbol-spacing":new U(F.layout_symbol["symbol-spacing"],"symbol-spacing"),"symbol-avoid-edges":new U(F.layout_symbol["symbol-avoid-edges"],"symbol-avoid-edges"),"symbol-sort-key":new ee(F.layout_symbol["symbol-sort-key"],"symbol-sort-key"),"symbol-z-order":new U(F.layout_symbol["symbol-z-order"],"symbol-z-order"),"icon-allow-overlap":new U(F.layout_symbol["icon-allow-overlap"],"icon-allow-overlap"),"icon-overlap":new U(F.layout_symbol["icon-overlap"],"icon-overlap"),"icon-ignore-placement":new U(F.layout_symbol["icon-ignore-placement"],"icon-ignore-placement"),"icon-optional":new U(F.layout_symbol["icon-optional"],"icon-optional"),"icon-rotation-alignment":new ee(F.layout_symbol["icon-rotation-alignment"],"icon-rotation-alignment"),"icon-size":new ee(F.layout_symbol["icon-size"],"icon-size"),"icon-text-fit":new U(F.layout_symbol["icon-text-fit"],"icon-text-fit"),"icon-text-fit-padding":new U(F.layout_symbol["icon-text-fit-padding"],"icon-text-fit-padding"),"icon-image":new ee(F.layout_symbol["icon-image"],"icon-image"),"icon-rotate":new ee(F.layout_symbol["icon-rotate"],"icon-rotate"),"icon-padding":new ee(F.layout_symbol["icon-padding"],"icon-padding"),"icon-keep-upright":new U(F.layout_symbol["icon-keep-upright"],"icon-keep-upright"),"icon-offset":new ee(F.layout_symbol["icon-offset"],"icon-offset"),"icon-anchor":new ee(F.layout_symbol["icon-anchor"],"icon-anchor"),"icon-pitch-alignment":new U(F.layout_symbol["icon-pitch-alignment"],"icon-pitch-alignment"),"text-pitch-alignment":new U(F.layout_symbol["text-pitch-alignment"],"text-pitch-alignment"),"text-rotation-alignment":new U(F.layout_symbol["text-rotation-alignment"],"text-rotation-alignment"),"text-field":new ee(F.layout_symbol["text-field"],"text-field"),"text-font":new ee(F.layout_symbol["text-font"],"text-font"),"text-size":new ee(F.layout_symbol["text-size"],"text-size"),"text-max-width":new ee(F.layout_symbol["text-max-width"],"text-max-width"),"text-line-height":new U(F.layout_symbol["text-line-height"],"text-line-height"),"text-letter-spacing":new ee(F.layout_symbol["text-letter-spacing"],"text-letter-spacing"),"text-justify":new ee(F.layout_symbol["text-justify"],"text-justify"),"text-radial-offset":new ee(F.layout_symbol["text-radial-offset"],"text-radial-offset"),"text-variable-anchor":new U(F.layout_symbol["text-variable-anchor"],"text-variable-anchor"),"text-variable-anchor-offset":new ee(F.layout_symbol["text-variable-anchor-offset"],"text-variable-anchor-offset"),"text-anchor":new ee(F.layout_symbol["text-anchor"],"text-anchor"),"text-max-angle":new U(F.layout_symbol["text-max-angle"],"text-max-angle"),"text-writing-mode":new U(F.layout_symbol["text-writing-mode"],"text-writing-mode"),"text-rotate":new ee(F.layout_symbol["text-rotate"],"text-rotate"),"text-padding":new U(F.layout_symbol["text-padding"],"text-padding"),"text-keep-upright":new U(F.layout_symbol["text-keep-upright"],"text-keep-upright"),"text-transform":new ee(F.layout_symbol["text-transform"],"text-transform"),"text-offset":new ee(F.layout_symbol["text-offset"],"text-offset"),"text-allow-overlap":new U(F.layout_symbol["text-allow-overlap"],"text-allow-overlap"),"text-overlap":new U(F.layout_symbol["text-overlap"],"text-overlap"),"text-ignore-placement":new U(F.layout_symbol["text-ignore-placement"],"text-ignore-placement"),"text-optional":new U(F.layout_symbol["text-optional"],"text-optional"),"symbol-height-offset":new ee(F.layout_symbol["symbol-height-offset"],"symbol-height-offset"),"symbol-height-anchor":new U(F.layout_symbol["symbol-height-anchor"],"symbol-height-anchor")})),eg,UC=()=>eg||(eg=new wt({"icon-opacity":new ee(F.paint_symbol["icon-opacity"],"icon-opacity"),"icon-color":new ee(F.paint_symbol["icon-color"],"icon-color"),"icon-halo-color":new ee(F.paint_symbol["icon-halo-color"],"icon-halo-color"),"icon-halo-width":new ee(F.paint_symbol["icon-halo-width"],"icon-halo-width"),"icon-halo-blur":new ee(F.paint_symbol["icon-halo-blur"],"icon-halo-blur"),"icon-translate":new U(F.paint_symbol["icon-translate"],"icon-translate"),"icon-translate-anchor":new U(F.paint_symbol["icon-translate-anchor"],"icon-translate-anchor"),"text-opacity":new ee(F.paint_symbol["text-opacity"],"text-opacity"),"text-color":new ee(F.paint_symbol["text-color"],"text-color",{runtimeType:Ai,getOverride:e=>e.textColor,hasOverride:e=>!!e.textColor}),"text-halo-color":new ee(F.paint_symbol["text-halo-color"],"text-halo-color"),"text-halo-width":new ee(F.paint_symbol["text-halo-width"],"text-halo-width"),"text-halo-blur":new ee(F.paint_symbol["text-halo-blur"],"text-halo-blur"),"text-translate":new U(F.paint_symbol["text-translate"],"text-translate"),"text-translate-anchor":new U(F.paint_symbol["text-translate-anchor"],"text-translate-anchor")})),th={get paint(){return UC()},get layout(){return NC()}},V1=class{constructor(e){if(e.property.overrides===void 0)throw Error("overrides must be provided to instantiate FormatSectionOverride class");this.type=e.property.overrides?e.property.overrides.runtimeType:xo,this.defaultValue=e}evaluate(e){if(e.formattedSection){let t=this.defaultValue.property.overrides;if(t?.hasOverride(e.formattedSection))return t.getOverride(e.formattedSection)}return e.feature&&e.featureState?this.defaultValue.evaluate(e.feature,e.featureState):this.defaultValue.property.specification.default}eachChild(e){if(!this.defaultValue.isConstant()){let t=this.defaultValue.value;e(t._styleExpression.expression)}}outputDefined(){return!1}serialize(){return null}};G("FormatSectionOverride",V1,{omit:["defaultValue"]});var N1=e=>e.type==="symbol",$C=class Gc extends ki{constructor(t,i){super(t,th,i)}recalculate(t,i){super.recalculate(t,i);let r=this.layout.get("icon-rotation-alignment");if((r.value.kind!=="constant"||r.value.value==="auto")&&(this.layout._values["icon-rotation-alignment"]=new xi(r.property,{kind:"constant",value:this.layout.get("symbol-placement")==="point"?"viewport":"map"},r.parameters)),this.layout.get("text-rotation-alignment")==="auto"&&(this.layout.get("symbol-placement")==="point"?this.layout._values["text-rotation-alignment"]="viewport":this.layout._values["text-rotation-alignment"]="map"),this.layout.get("text-pitch-alignment")==="auto"&&(this.layout._values["text-pitch-alignment"]=this.layout.get("text-rotation-alignment")==="map"?"map":"viewport"),this.layout.get("icon-pitch-alignment")==="auto"&&(this.layout._values["icon-pitch-alignment"]=this.layout.get("icon-rotation-alignment").constantOr("viewport")),this.layout.get("symbol-placement")==="point"){let a=this.layout.get("text-writing-mode");if(a){let n=[];for(let o of a)n.includes(o)||n.push(o);this.layout._values["text-writing-mode"]=n}else this.layout._values["text-writing-mode"]=["horizontal"]}this._setPaintOverrides()}getValueAndResolveTokens(t,i,r,a){let n=this.layout.get(t).evaluate(i,{},r,a),o=this._unevaluatedLayout._values[t];return!o.isDataDriven()&&!Ol(o.value)&&n?VC(i.properties,n):n}createBucket(t){return new ml(t)}queryRadius(){return 0}queryIntersectsFeature(){throw Error("Should take a different path in FeatureIndex")}_setPaintOverrides(){for(let t of th.paint.overridableProperties){if(!Gc.hasPaintOverride(this.layout,t))continue;let i=this.paint.get(t),r=new kd(new V1(i),`layers[${this.id}].paint.${i.property.name}`,i.property.specification),a=null;a=i.value.kind==="constant"||i.value.kind==="source"?new io("source",r):new Qs("composite",r,i.value.zoomStops),this.paint._values[t]=new xi(i.property,a,i.parameters)}}_handleOverridablePaintPropertyUpdate(t,i,r){return!this.layout||i.isDataDriven()||r.isDataDriven()?!1:Gc.hasPaintOverride(this.layout,t)}static hasPaintOverride(t,i){let r=t.get("text-field"),a=th.paint.properties[i],n=!1,o=s=>{for(let l of s)if(a.overrides?.hasOverride(l)){n=!0;return}};if(r.value.kind==="constant"&&r.value.value instanceof hr)o(r.value.value.sections);else if(r.value.kind==="source"||r.value.kind==="composite"){let s=u=>{if(!n)if(u instanceof qa&&at(u.value)===bo){let h=u.value;o(h.sections)}else u instanceof fy?o(u.sections):u.eachChild(s)},l=r.value;l._styleExpression&&s(l._styleExpression.expression)}return n}};function GC(e,t,i,r=1){let a=e.get("icon-padding").evaluate(t,{},i)?.values;return[a[0]*r,a[1]*r,a[2]*r,a[3]*r]}var tg,ZC=()=>tg||(tg=new wt({"background-color":new U(F.paint_background["background-color"],"background-color"),"background-pattern":new E0(F.paint_background["background-pattern"],"background-pattern"),"background-opacity":new U(F.paint_background["background-opacity"],"background-opacity")})),qC={get paint(){return ZC()}},WC=e=>e.type==="background",HC=class extends ki{constructor(e,t){super(e,qC,t)}};function XC(e){let t=[],i=e.id;return i===void 0&&t.push(new L(`layers.${i}`,null,'missing required property "id"')),e.render===void 0&&t.push(new L(`layers.${i}`,null,'missing required method "render"')),e.renderingMode&&e.renderingMode!=="2d"&&e.renderingMode!=="3d"&&t.push(new L(`layers.${i}`,null,'property "renderingMode" must be either "2d" or "3d"')),t}var Yl=e=>e.type==="custom",YC=class extends ki{constructor(e,t){super(e,{},t),this.onAdd=i=>{this.implementation.onAdd&&this.implementation.onAdd(i,i.painter.context.gl)},this.onRemove=i=>{this.implementation.onRemove&&this.implementation.onRemove(i,i.painter.context.gl)},this.implementation=e}is3D(){return this.implementation.renderingMode==="3d"}hasOffscreenPass(){return this.implementation.prerender!==void 0}recalculate(){}updateTransitions(){}hasTransition(){return!1}serialize(){throw Error("Custom layers cannot be serialized")}};function ih(e,t){if(e.type==="custom")return new YC(e,t);switch(e.type){case"background":return new HC(e,t);case"circle":return new TE(e,t);case"color-relief":return new LE(e,t);case"fill":return new fD(e,t);case"fill-extrusion":return new BD(e,t);case"heatmap":return new CE(e,t);case"hillshade":return new ME(e,t);case"line":return new HD(e,t);case"raster":return new kT(e,t);case"symbol":return new $C(e,t)}}function js(e){let t=[];if(typeof e=="string")t.push({id:"default",url:e});else if(e&&e.length>0){let i=[];for(let{id:r,url:a}of e){let n=`${r}${a}`;i.includes(n)||(i.push(n),t.push({id:r,url:a}))}}return t}function ig(e,t,i){try{let r=new URL(e);return r.pathname+=`${t}${i}`,r.toString()}catch{throw Error(`Invalid sprite URL "${e}", must be absolute. Modify style specification directly or use TransformStyleFunction to correct the issue dynamically`)}}async function KC(e,t,i,r){let a=js(e),n=i>1?"@2x":"",o={},s={};for(let{id:l,url:u}of a){let h=await t.transformRequest(ig(u,n,".json"),"SpriteJSON");o[l]=Sl(h,r);let c=await t.transformRequest(ig(u,n,".png"),"SpriteImage");s[l]=Ci.getImage(c,r)}return await Promise.all([...Object.values(o),...Object.values(s)]),JC(o,s)}async function JC(e,t){let i={};for(let r in e){i[r]={};let a=(await t[r]).data;if(!a)throw Error(`Could not load sprite image for ${r}: the response is empty`);let n=Kt.getImageCanvasContext(a),o=(await e[r]).data;for(let s in o){let{width:l,height:u,x:h,y:c,sdf:d,pixelRatio:p,stretchX:f,stretchY:m,content:g,textFitWidth:_,textFitHeight:y}=o[s],v={width:l,height:u,x:h,y:c,context:n};i[r][s]={data:null,pixelRatio:p,sdf:d,stretchX:f,stretchY:m,content:g,textFitWidth:_,textFitHeight:y,spriteData:v}}}return i}var QC=class extends ht{constructor(){super(),this.images={},this.updateVersion=0,this.loaded=!1,this.requestors=[],this.missingImageResolver=null,this._spriteImagesIds={},this._imagesIds=null,this._renderCallbacksDispatchedThisFrame={}}destroy(){for(let e of Object.keys(this.images))this.removeImage(e);this._spriteImagesIds={}}isLoaded(){return this.loaded}setLoaded(e){if(this.loaded!==e&&(this.loaded=e,e)){for(let{ids:t,promiseResolve:i}of this.requestors)i(this._getImagesForIds(t));this.requestors=[]}}getImage(e){let t=this.images[e];if(t&&!t.data&&t.spriteData){let i=t.spriteData;t.data=new Ve({width:i.width,height:i.height},i.context.getImageData(i.x,i.y,i.width,i.height).data),t.spriteData=null}return t}addImage(e,t){if(this.images[e])throw Error(`Image id ${e} already exist, use updateImage instead`);this._validate(e,t)&&(this.images[e]=t,this._imagesIds=null,t.isWebGLImage&&this.updateImage(e,t,!1))}_validate(e,t){let i=!0,r=t.data||t.spriteData;return this._validateStretch(t.stretchX,r?.width)||(this.fire(new Y(Error(`Image "${e}" has invalid "stretchX" value`))),i=!1),this._validateStretch(t.stretchY,r?.height)||(this.fire(new Y(Error(`Image "${e}" has invalid "stretchY" value`))),i=!1),this._validateContent(t.content,t)||(this.fire(new Y(Error(`Image "${e}" has invalid "content" value`))),i=!1),i}_validateStretch(e,t){if(!e)return!0;let i=0;for(let r of e){if(r[0]<i||r[1]<r[0]||t<r[1])return!1;i=r[1]}return!0}_validateContent(e,t){if(!e)return!0;if(e.length!==4)return!1;let i=t.spriteData,r=i?.width||t.data.width,a=i?.height||t.data.height;return e[0]<0||r<e[0]||e[1]<0||a<e[1]||e[2]<0||r<e[2]||e[3]<0||a<e[3]||e[2]<e[0]?!1:e[3]>=e[1]}updateImage(e,t,i=!0){let r=this.images[e];if(i){let a=r.data||r.spriteData;if(a.width!==t.data.width||a.height!==t.data.height)throw Error(`size mismatch between old image (${a.width}x${a.height}) and new image (${t.data.width}x${t.data.height}).`)}t.version=(r.version??0)+1,this.images[e]=t,this.updateVersion++}removeImage(e){let t=this.images[e];t&&(delete this.images[e],this._imagesIds=null,t.userImage?.onRemove&&t.userImage.onRemove())}listImages(){return this._imagesIds??(this._imagesIds=Object.keys(this.images)),this._imagesIds}_getSpriteImageId(e,t){return e==="default"?t:`${e}:${t}`}setSpriteImages(e,t){let i=this._spriteImagesIds[e]??[],r=[];for(let o in t){let s=this._getSpriteImageId(e,o);r.push(s),s in this.images?this.updateImage(s,t[o],!1):this.addImage(s,t[o])}let a=new Set(r),n=i.filter(o=>!a.has(o));for(let o of n)this.removeImage(o);return this._spriteImagesIds[e]=r,{loaded:r,removed:n}}removeSpriteImages(e){let t=this._spriteImagesIds[e]??[];for(let i of t)this.removeImage(i);return delete this._spriteImagesIds[e],t}removeAllSpriteImages(){let e=Object.values(this._spriteImagesIds).flat();for(let t of e)this.removeImage(t);return this._spriteImagesIds={},e}setMissingImageResolver(e){this.missingImageResolver=e}getImages(e){return new Promise((t,i)=>{let r=!0;if(!this.isLoaded())for(let a of e)this.images[a]||(r=!1);this.isLoaded()||r?t(this._getImagesForIds(e)):this.requestors.push({ids:e,promiseResolve:t})})}async _getImagesForIds(e){let t=new Set(e.filter(a=>!this.getImage(a))),i=this.missingImageResolver;i&&await Promise.allSettled(Array.from(t,a=>i(a)));let r={};for(let a of e){let n=this.getImage(a);n&&(t.delete(a),r[a]={data:n.data.clone(),pixelRatio:n.pixelRatio,sdf:n.sdf,version:n.version,stretchX:n.stretchX,stretchY:n.stretchY,content:n.content,textFitWidth:n.textFitWidth,textFitHeight:n.textFitHeight,hasRenderCallback:!!n.userImage?.render,isWebGLImage:n.isWebGLImage})}for(let a of t)this.fire(new J_({id:a})),_e(`Image "${a}" could not be loaded. Please make sure you have added the image before it is needed with map.addImage(), resolved it with map.setMissingStyleImageResolver(), or included it in a "sprite" property in your style.`);return r}beginFrame(){this._renderCallbacksDispatchedThisFrame={}}dispatchRenderCallbacks(e){for(let t of e){if(this._renderCallbacksDispatchedThisFrame[t])continue;this._renderCallbacksDispatchedThisFrame[t]=!0;let i=this.getImage(t);i||_e(`Image with ID: "${t}" was not found`),QS(i)&&this.updateImage(t,i)}}cloneImages(){let e={};for(let t in this.images){let i=this.images[t];e[t]={...i,data:i.data?i.data.clone():null}}return e}},eP=class{constructor(e){this._imageManager=e,this._entries={},this._image=new Ve({width:1,height:1}),this._dirty=!0}destroy(){this._texture&&(this._texture=(this._texture.destroy(),null)),this._entries={},this._image=new Ve({width:1,height:1}),this._dirty=!0}getPixelSize(){let{width:e,height:t}=this._image;return{width:e,height:t}}getPattern(e){let t=this._imageManager.getImage(e);if(!t)return null;let i=this._entries[e];if(i?.image!==t){let r={w:t.data.width+2,h:t.data.height+2,x:0,y:0};this._entries[e]={bin:r,position:new Qd(r,t),image:t}}else if(i.position.version!==t.version)i.position.version=t.version;else return i.position;return this._update(),this._entries[e].position}isPatternMissing(e){if(!e)return!1;if(!e.from||!e.to)return!0;let t=this.getPattern(e.from.toString()),i=this.getPattern(e.to.toString());return!t||!i}bind(e){let t=e.gl;this._texture?this._dirty&&(this._dirty=(this._texture.update(this._image),!1)):(this._texture=new pt(e,this._image,t.RGBA),this._dirty=!1),this._texture.bind(t.LINEAR,t.CLAMP_TO_EDGE)}_update(){for(let a in this._entries)this._imageManager.getImage(a)||delete this._entries[a];let e=[];for(let a in this._entries)e.push(this._entries[a].bin);let{w:t,h:i}=E1(e),r=this._image;r.resize({width:t||1,height:i||1});for(let a in this._entries){let{bin:n}=this._entries[a],o=n.x+1,s=n.y+1,l=this._entries[a].image.data,u=l.width,h=l.height;Ve.copy(l,r,{x:0,y:0},{x:o,y:s},{width:u,height:h}),Ve.copy(l,r,{x:0,y:h-1},{x:o,y:s-1},{width:u,height:1}),Ve.copy(l,r,{x:0,y:0},{x:o,y:s+h},{width:u,height:1}),Ve.copy(l,r,{x:u-1,y:0},{x:o-1,y:s},{width:1,height:h}),Ve.copy(l,r,{x:0,y:0},{x:o+u,y:s},{width:1,height:h})}this._dirty=!0}},Zc=1114111,tP={start:0,end:Zc},iP=0;function rP(e){let t=/^u\+([0-9a-f]*)(\?+)$/i.exec(e);if(t){let[,a,n]=t;return a.length+n.length>6?null:rg(parseInt(`${a}${"0".repeat(n.length)}`,16),parseInt(`${a}${"f".repeat(n.length)}`,16))}let i=/^u\+([0-9a-f]{1,6})(?:-([0-9a-f]{1,6}))?$/i.exec(e);if(!i)return null;let r=parseInt(i[1],16);return rg(r,i[2]===void 0?r:parseInt(i[2],16))}function rg(e,t){return e>t||e>Zc?null:{start:e,end:Math.min(t,Zc)}}function aP(e,t){return e.ranges.some(({start:i,end:r})=>t>=i&&t<=r)}var nP=class{constructor(e){this.requestManager=e,this._faces={},this._registered=new Set}setFontFaces(e){this._unregisterAll(),this._faces={};for(let[t,i]of Object.entries(e??{})){let r=Array.isArray(i)?i:[i];this._faces[t]=r.map(a=>this._declareFontFace(t,a)).filter(a=>a!==null)}}hasFontFaces(){return Object.keys(this._faces).length>0}async getFontFamily(e,t){for(let i of e.split(","))for(let r of this._faces[i.trim()]??[])if(aP(r,t)&&(r.loaded??(r.loaded=this._loadFontFace(r)),await r.loaded))return r.family;return null}_declareFontFace(e,t){let i=typeof t=="string"?{url:t}:t;if(typeof i?.url!="string")return _e(`Ignoring the font face declared for "${e}": it has no URL.`),null;let r=`maplibre-gl-font-face-${iP++}`,a=i["unicode-range"];if(!a?.length)return{url:i.url,ranges:[tP],family:r};let n=[];for(let o of a){let s=rP(o);if(!s){_e(`Ignoring the unicode range "${o}" of the font face at ${i.url}: it is not a valid range.`);continue}n.push(s)}return n.length?{url:i.url,ranges:n,family:r}:null}async _loadFontFace(e){if(typeof FontFace>"u"||typeof document>"u"||!document.fonts)return _e(`Ignoring the font face at ${e.url}: this environment has no CSS Font Loading API.`),!1;let t;try{return t=new FontFace(e.family,await this._downloadFontFile(e.url)),Object.values(this._faces).some(i=>i.includes(e))?(document.fonts.add(t),this._registered.add(t),await t.load(),!0):!1}catch(i){return t&&this._unregister(t),_e(`Ignoring the font face at ${e.url}: ${bt(i).message}`),!1}}async _downloadFontFile(e){let t=await this.requestManager.transformRequest(e,"Glyphs"),i=await W_(t,new AbortController);if(!i?.data)throw Error(`the response was empty for the font file at ${e}`);return i.data}_unregister(e){document.fonts?.delete(e),this._registered.delete(e)}_unregisterAll(){for(let e of this._registered)document.fonts?.delete(e);this._registered.clear()}destroy(){this._unregisterAll(),this._faces={}}},qc=1e20,ip=new Float64Array(256);for(let e=0;e<256;e++){let t=.5-(e/255)**.45454545454545453;ip[e]=t*Math.abs(t)}ip[255]=-1e20;var oP=class{constructor({fontSize:e=24,buffer:t=3,radius:i=8,cutoff:r=.25,fontFamily:a="sans-serif",fontWeight:n="normal",fontStyle:o="normal",lang:s=null}={}){this.buffer=t,this.radius=i,this.cutoff=r,this.lang=s;let l=this.size=e+t*4,u=this._createCanvas(l),h=this.ctx=u.getContext("2d",{willReadFrequently:!0});h.font=`${o} ${n} ${e}px ${a}`,h.textBaseline="alphabetic",h.textAlign="left",h.fillStyle="black",this.gridOuter=new Float64Array(l*l),this.gridInner=new Float64Array(l*l),this.f=new Float64Array(l),this.z=new Float64Array(l+1),this.v=new Uint16Array(l)}_createCanvas(e){if(typeof OffscreenCanvas<"u")return new OffscreenCanvas(e,e);let t=document.createElement("canvas");return t.width=t.height=e,t}draw(e){let{width:t,actualBoundingBoxAscent:i,actualBoundingBoxDescent:r,actualBoundingBoxLeft:a,actualBoundingBoxRight:n}=this.ctx.measureText(e),o=Math.ceil(i),s=Math.floor(-a),l=Math.max(0,Math.min(this.size-this.buffer,Math.ceil(n)-s)),u=Math.max(0,Math.min(this.size-this.buffer,o+Math.ceil(r))),h=l+2*this.buffer,c=u+2*this.buffer,d=Math.max(h*c,0),p=new Uint8ClampedArray(d),f={data:p,width:h,height:c,glyphWidth:l,glyphHeight:u,glyphTop:o,glyphLeft:s,glyphAdvance:t};if(l===0||u===0)return f;let{ctx:m,buffer:g,gridInner:_,gridOuter:y}=this;this.lang&&(m.lang=this.lang),m.clearRect(g,g,l,u),m.fillText(e,g-s,g+o);let v=m.getImageData(g,g,l,u);y.fill(qc,0,d),_.fill(0,0,d);let x=3;for(let E=0;E<u;E++){let S=(E+g)*h+g;for(let M=0;M<l;M++,x+=4,S++){let z=v.data[x];if(z===0)continue;let R=ip[z];y[S]=Math.max(0,R),_[S]=Math.max(0,-R)}}ag(y,0,0,h,c,h,this.f,this.v,this.z);let b=Math.min(g,1);ag(_,g-b,g-b,l+2*b,u+2*b,h,this.f,this.v,this.z);let w=255/this.radius,T=255*(1-this.cutoff);for(let E=0;E<d;E++){let S=Math.sqrt(y[E])-Math.sqrt(_[E]);p[E]=Math.round(T-w*S)}return f}};function ag(e,t,i,r,a,n,o,s,l){for(let u=t;u<t+r;u++)ng(e,i*n+u,n,a,o,s,l);for(let u=i;u<i+a;u++)ng(e,u*n+t,1,r,o,s,l)}function ng(e,t,i,r,a,n,o){n[0]=0,o[0]=-1e20,o[1]=qc,a[0]=e[t];for(let s=1,l=0,u=0;s<r;s++){a[s]=e[t+s*i];let h=s*s;do{let c=n[l];u=(a[s]-a[c]+h-c*c)/(s-c)/2}while(u<=o[l]&&--l>-1);l++,n[l]=s,o[l]=u,o[l+1]=qc}for(let s=0,l=0;s<r;s++){for(;o[l+1]<s;)l++;let u=n[l],h=s-u;e[t+s*i]=a[u]+h*h}}var sP=F.layout_symbol["text-font"].default.join(","),lP=(e,t)=>{let i=new oP(e);return i.buffer=t,i},uP=class{constructor(e,t,i,r=lP){this.requestManager=e,this.localIdeographFontFamily=t,this.entries={},this.lang=i,this.fontFaceManager=new nP(e),this.createRasterizer=r}setURL(e){this.url=e}setFontFaces(e){this.fontFaceManager.setFontFaces(e),this.entries={}}async getGlyphs(e){var a;let t=[];for(let n in e)for(let o in e[n])for(let s of e[n][o])t.push(this._getAndCacheGlyphsPromise(n,s,o));let i=await Promise.all(t),r={};for(let{stack:n,id:o,variant:s,glyph:l}of i)r[n]||(r[n]={}),(a=r[n])[s]||(a[s]={}),r[n][s][o]=l&&{id:l.id,bitmap:l.bitmap.clone(),metrics:l.metrics};return r}async _getAndCacheGlyphsPromise(e,t,i){var l,u;(l=this.entries)[e]??(l[e]={glyphs:{default:{}},requests:{},ranges:{}});let r=this.entries[e],a=(u=r.glyphs)[i]||(u[i]={}),n=a[t];if(n!==void 0)return{stack:e,id:t,variant:i,glyph:n};if(i!=="default")return a[t]=null,{stack:e,id:t,variant:i,glyph:null};let o=t.codePointAt(0),s=this.fontFaceManager.hasFontFaces()?await this.fontFaceManager.getFontFamily(e,o):null;return s?(n=a[t]=await this._drawGlyph(r,e,t,s),{stack:e,id:t,variant:i,glyph:n}):!this.url||cl(t)||this._charUsesLocalIdeographFontFamily(o)?(n=a[t]=await this._drawGlyph(r,e,t),{stack:e,id:t,variant:i,glyph:n}):{...await this._downloadAndCacheRangePromise(e,t),variant:i}}async _downloadAndCacheRangePromise(e,t){var n;let i=t.codePointAt(0),r=this.entries[e],a=Math.floor(i/256);if(r.ranges[a])return{stack:e,id:t,glyph:null};(n=r.requests)[a]||(n[a]=this._loadGlyphRange(e,a));try{let o=await r.requests[a];for(let s in o)r.glyphs.default[String.fromCodePoint(+s)]=o[+s];return r.ranges[a]=!0,{stack:e,id:t,glyph:o[i]||null}}catch(o){let s=r.glyphs.default[t]=await this._drawGlyph(r,e,t);return this._warnOnMissingGlyphRange(s,a,i,bt(o)),{stack:e,id:t,glyph:s}}}async _loadGlyphRange(e,t){let i=t*256,r=i+255,a=await this.requestManager.transformRequest(this.url.replace("{fontstack}",e).replace("{range}",`${i}-${r}`),"Glyphs"),n=await W_(a,new AbortController);if(!n?.data)throw Error(`Could not load glyph range. range: ${t}, ${i}-${r}`);let o={};for(let s of JS(n.data))o[s.id]=s;return o}_warnOnMissingGlyphRange(e,t,i,r){let a=t*256;_e(`Unable to load glyph range ${t}, ${a}-${a+255}. Rendering codepoint U+${i.toString(16).padStart(4,"0").toUpperCase()} locally instead. ${r}`)}_charUsesLocalIdeographFontFamily(e){return!!this.localIdeographFontFamily&&iS(e)}async _drawGlyph(e,t,i,r){let a=(await this._getTinySDF(e,t,i,r)).draw(i),n=/^\p{gc=Cf}+$/u.test(i);return{id:i.codePointAt(0),bitmap:new Wd({width:a.width||60,height:a.height||60},a.data),metrics:{width:n?0:a.glyphWidth/2||24,height:a.glyphHeight/2||24,left:a.glyphLeft/2+.5||0,top:a.glyphTop/2-27.5||-8,advance:n?0:a.glyphAdvance/2||24,isDoubleResolution:!0}}}_getTinySDF(e,t,i,r){var l,u;let a=cl(i);if(r){let h=a?"clusterTinySDFs":"fontFaceTinySDFs";return e[h]??(e[h]={}),(l=e[h])[r]||(l[r]=this._createTinySDF(r,!1,a?3:1)),e[h][r]}let n=t===sP&&this.localIdeographFontFamily!==""&&this._charUsesLocalIdeographFontFamily(i.codePointAt(0)),o=n?this.localIdeographFontFamily:t;if(a)return e.clusterTinySDFs??(e.clusterTinySDFs={}),(u=e.clusterTinySDFs)[o]||(u[o]=this._createTinySDF(o,!0,3)),e.clusterTinySDFs[o];let s=n?"ideographTinySDF":"tinySDF";return e[s]||(e[s]=this._createTinySDF(o)),e[s]}async _createTinySDF(e,t=!0,i=1){let r=e?e.split(","):[];r.push("sans-serif");let a=r.map(s=>/[-\w]+/.test(s)?s:`'${CSS.escape(s)}'`).join(","),n=t?this._fontWeight(r[0]):void 0,o=t?this._fontStyle(r[0]):"normal";if(typeof document<"u"&&document.fonts?.load)try{await document.fonts.load(`${o} ${n||"normal"} 48px ${a}`)}catch(s){_e(`Failed to load font "${a}": ${bt(s).message}`)}return this.createRasterizer({fontSize:48,buffer:Math.max(6,Math.ceil(48*(i-1)/4)),radius:16,cutoff:.25,fontFamily:a,fontWeight:n,fontStyle:o,lang:this.lang},6)}_fontStyle(e){return/italic/i.test(e)?"italic":/oblique/i.test(e)?"oblique":"normal"}_fontWeight(e){let t={thin:100,hairline:100,"extra light":200,"ultra light":200,light:300,normal:400,regular:400,medium:500,semibold:600,demibold:600,bold:700,"extra bold":800,"ultra bold":800,black:900,heavy:900,"extra black":950,"ultra black":950},i;for(let[r,a]of Object.entries(t))RegExp(`\\b${r}\\b`,"i").test(e)&&(i=`${a}`);return i}destroy(){for(let e in this.entries){let t=this.entries[e];t.tinySDF=null,t.ideographTinySDF=null,t.fontFaceTinySDFs={},t.glyphs={default:{}},t.requests={},t.ranges={}}this.entries={},this.fontFaceManager.destroy()}},og,hP=()=>og||(og=new wt({anchor:new U(F.light.anchor,"anchor"),position:new U(F.light.position,"position"),color:new U(F.light.color,"color"),intensity:new U(F.light.intensity,"intensity")})),cP=class extends ht{constructor(e,t){super(),this._transitionable=new Nl(hP(),"light",t),this.setLight(e),this._transitioning=this._transitionable.untransitioned(),this.recalculate(new Ae(0))}getLight(){return this._transitionable.serialize()}getEvaluated(){return{anchor:this.properties.get("anchor"),position:this.properties.get("position"),color:this.properties.get("color"),intensity:this.properties.get("intensity")}}setLight(e,t={}){this._validate(Wt.light,e,t)||this._transitionable.setValues(e)}updateTransitions(e){this._transitioning=this._transitionable.transitioned(e,this._transitioning)}hasTransition(){return this._transitioning.hasTransition()}applyGlobalStateChange(e,t,i){this._transitioning=this._transitionable.applyGlobalStateChange(e,t,this._transitioning,i)}recalculate(e){this.properties=this._transitioning.possiblyEvaluate(e)}_validate(e,t,i){return So(this,e,{value:t},i)}},sg,dP=()=>sg||(sg=new wt({"sky-color":new U(F.sky["sky-color"],"sky-color"),"horizon-color":new U(F.sky["horizon-color"],"horizon-color"),"fog-color":new U(F.sky["fog-color"],"fog-color"),"fog-ground-blend":new U(F.sky["fog-ground-blend"],"fog-ground-blend"),"horizon-fog-blend":new U(F.sky["horizon-fog-blend"],"horizon-fog-blend"),"sky-horizon-blend":new U(F.sky["sky-horizon-blend"],"sky-horizon-blend"),"atmosphere-blend":new U(F.sky["atmosphere-blend"],"atmosphere-blend")})),pP=class extends ht{constructor(e,t){super(),this._transitionable=new Nl(dP(),"sky",t),this.setSky(e),this._transitioning=this._transitionable.untransitioned(),this.recalculate(new Ae(0))}setSky(e,t={}){return!this._validate(Wt.sky,e,t)&&(e||(e={"sky-color":"transparent","horizon-color":"transparent","fog-color":"transparent","fog-ground-blend":1,"atmosphere-blend":0}),this._transitionable.setValues(e),!0)}getSky(){return this._transitionable.serialize()}updateTransitions(e){this._transitioning=this._transitionable.transitioned(e,this._transitioning)}hasTransition(){return this._transitioning.hasTransition()}applyGlobalStateChange(e,t,i){this._transitioning=this._transitionable.applyGlobalStateChange(e,t,this._transitioning,i)}recalculate(e){this.properties=this._transitioning.possiblyEvaluate(e)}_validate(e,t,i={}){return So(this,e,{value:t},i)}getEvaluated(){return{"sky-color":this.properties.get("sky-color"),"horizon-color":this.properties.get("horizon-color"),"fog-color":this.properties.get("fog-color"),"fog-ground-blend":this.properties.get("fog-ground-blend"),"horizon-fog-blend":this.properties.get("horizon-fog-blend"),"sky-horizon-blend":this.properties.get("sky-horizon-blend"),"atmosphere-blend":this.properties.get("atmosphere-blend")}}};function fP(e){return e<60?0:e<70?(e-60)/10:1}var mP=class{constructor(e,t){this.width=e,this.height=t,this.nextRow=0,this.data=new Uint8Array(this.width*this.height),this.dashEntry={}}getDash(e,t){var r;let i=e.join(",")+String(t);return(r=this.dashEntry)[i]||(r[i]=this.addDash(e,t)),this.dashEntry[i]}getDashRanges(e,t,i){let r=e.length%2==1,a=[],n=r?-e[e.length-1]*i:0,o=e[0]*i,s=!0;a.push({left:n,right:o,isDash:s,zeroLength:e[0]===0});let l=e[0];for(let u=1;u<e.length;u++){s=!s;let h=e[u];n=l*i,l+=h,o=l*i,a.push({left:n,right:o,isDash:s,zeroLength:h===0})}return a}addRoundDash(e,t,i){let r=t/2;for(let a=-i;a<=i;a++){let n=this.nextRow+i+a,o=this.width*n,s=0,l=e[s];for(let u=0;u<this.width;u++){u/l.right>1&&(l=e[++s]);let h=Math.abs(u-l.left),c=Math.abs(u-l.right),d=Math.min(h,c),p,f=a/i*(r+1);if(l.isDash){let m=r-Math.abs(f);p=Math.sqrt(d*d+m*m)}else p=r-Math.sqrt(d*d+f*f);this.data[o+u]=Math.max(0,Math.min(255,p+128))}}}addRegularDash(e){for(let o=e.length-1;o>=0;--o){let s=e[o],l=e[o+1];s.zeroLength?e.splice(o,1):l?.isDash===s.isDash&&(l.left=s.left,e.splice(o,1))}let t=e[0],i=e[e.length-1];t.isDash===i.isDash&&(t.left=i.left-this.width,i.right=t.right+this.width);let r=this.width*this.nextRow,a=0,n=e[a];for(let o=0;o<this.width;o++){o/n.right>1&&(n=e[++a]);let s=Math.abs(o-n.left),l=Math.abs(o-n.right),u=Math.min(s,l),h=n.isDash?u:-u;this.data[r+o]=Math.max(0,Math.min(255,h+128))}}addDash(e,t){let i=t?7:0,r=2*i+1;if(this.nextRow+r>this.height)return _e("LineAtlas out of space"),null;let a=0;for(let o of e)a+=o;if(a!==0){let o=this.width/a,s=this.getDashRanges(e,this.width,o);t?this.addRoundDash(s,o,i):this.addRegularDash(s)}let n={y:this.nextRow+i,height:2*i,width:a};return this.nextRow+=r,this.dirty=!0,n}bind(e){let t=e.gl;this.texture?(t.bindTexture(t.TEXTURE_2D,this.texture),this.dirty&&(this.dirty=!1,t.texSubImage2D(t.TEXTURE_2D,0,0,0,this.width,this.height,t.ALPHA,t.UNSIGNED_BYTE,this.data))):(this.texture=t.createTexture(),t.bindTexture(t.TEXTURE_2D,this.texture),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_WRAP_S,t.REPEAT),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_WRAP_T,t.REPEAT),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_MIN_FILTER,t.LINEAR),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_MAG_FILTER,t.LINEAR),t.texImage2D(t.TEXTURE_2D,0,t.ALPHA,this.width,this.height,0,t.ALPHA,t.UNSIGNED_BYTE,this.data))}},gP=class{constructor(e){this._methodToThrottle=e,this._triggered=!1,this._channel=new MessageChannel,this._channel.port2.onmessage=()=>{this._triggered=!1,this._methodToThrottle()}}trigger(){this._triggered||(this._triggered=!0,this._channel?.port1.postMessage(!0))}remove(){delete this._channel,this._methodToThrottle=()=>{}}},_P={once:!0},yP=class{constructor(e,t){this.target=e,this.mapId=t,this.resolveRejects={},this.tasks={},this.taskQueue=[],this.abortControllers={},this.messageHandlers={},this.invoker=new gP(()=>this.process()),this.subscription=Hs(this.target,"message",i=>this.receive(i),!1),this.globalScope=$a(self)?e:window}registerMessageHandler(e,t){this.messageHandlers[e]=t}unregisterMessageHandler(e){delete this.messageHandlers[e]}sendAsync(e,t){return new Promise((i,r)=>{let a=Math.round(Math.random()*1e18).toString(36).substring(0,10),n=t?Hs(t.signal,"abort",()=>{n?.unsubscribe(),delete this.resolveRejects[a];let l={id:a,type:"<cancel>",origin:location.origin,targetMapId:e.targetMapId,sourceMapId:this.mapId};this.target.postMessage(l),r(new vo(t.signal.reason))},_P):null;this.resolveRejects[a]={resolve:l=>{n?.unsubscribe(),i(l)},reject:l=>{n?.unsubscribe(),r(l)}};let o=[],s={...e,id:a,sourceMapId:this.mapId,origin:location.origin,data:Un(e.data,o)};this.target.postMessage(s,{transfer:o})})}receive(e){let t=e.data,i=t.id,r=["file://","resource://android","null"],a=[t.origin,location.origin],n=t.origin===location.origin,o=a.some(s=>r.includes(s));if((n||o)&&!(t.targetMapId&&this.mapId!==t.targetMapId)){if(t.type==="<cancel>"){delete this.tasks[i];let s=this.abortControllers[i];delete this.abortControllers[i],s&&s.abort();return}if($a(self)||t.mustQueue){this.tasks[i]=t,this.taskQueue.push(i),this.invoker.trigger();return}this.processTask(i,t)}}process(){if(this.taskQueue.length===0)return;let e=this.taskQueue.shift(),t=this.tasks[e];delete this.tasks[e],this.taskQueue.length>0&&this.invoker.trigger(),t&&this.processTask(e,t)}async processTask(e,t){if(t.type==="<response>"){let a=this.resolveRejects[e];if(delete this.resolveRejects[e],!a)return;t.error?a.reject(bt($n(t.error))):a.resolve($n(t.data));return}if(!this.messageHandlers[t.type]){this.completeTask(e,null,null);return}let i=$n(t.data),r=new AbortController;this.abortControllers[e]=r;try{let a=await this.messageHandlers[t.type](t.sourceMapId,i,r);this.completeTask(e,null,a)}catch(a){this.completeTask(e,bt(a))}}completeTask(e,t,i){let r=[];delete this.abortControllers[e];let a={id:e,type:"<response>",sourceMapId:this.mapId,origin:location.origin,error:t?Un(t):null,data:Un(i,r)};this.target.postMessage(a,{transfer:r})}remove(){this.invoker.remove(),this.subscription.unsubscribe()}};function vP(e){if(!e)return!1;let t=globalThis.location;if(!t)return!1;try{return new URL(e,t.href).origin!==t.origin}catch{return!1}}function xP(){let e=window.location.href;if(!/^https?:/.test(e))return"";let t=e.endsWith("-dev.mjs")?"maplibre-gl-worker-dev.mjs":"maplibre-gl-worker.mjs",i=new URL(`./${t}`,e);return i.searchParams.set("v",fd),i.href}function bP(e){return!0}function rh(e,t){if(t)try{return new Worker(e,{type:"module"})}catch(i){console.warn("Module worker not supported, falling back to classic worker",i)}return new Worker(e)}async function wP(e){let t=await fetch(e);if(!t.ok)throw Error(`Failed to fetch worker script (${t.status}): ${e}`);let i=await t.text(),r=new Blob([i],{type:"text/javascript"});return URL.createObjectURL(r)}function TP(e){let t=new Blob([`import ${JSON.stringify(new URL(e,window.location.href).href)}`],{type:"text/javascript"});return URL.createObjectURL(t)}async function EP(){let e=si.WORKER_URL||xP(),t=!bP(e);if(!vP(e))return rh(e,t);if(t){let r=TP(e);try{return rh(r,t)}finally{URL.revokeObjectURL(r)}}let i=await wP(e);try{return rh(i,t)}finally{URL.revokeObjectURL(i)}}var rp="maplibre_preloaded_worker_pool",Kl=class U1{constructor(){this.active={},this.workersPromise=null}async acquire(t){if(this.active[t]=!0,!this.workersPromise){let i=[];for(;i.length<U1.workerCount;)i.push(EP());this.workersPromise=Promise.all(i)}return(await this.workersPromise).slice()}release(t){if(delete this.active[t],this.numActive()===0&&this.workersPromise){let i=this.workersPromise;this.workersPromise=null,i.then(r=>{for(let a of r)a.terminate()})}}isPreloaded(){return!!this.active[rp]}numActive(){return Object.keys(this.active).length}},DP=Math.floor(Kt.hardwareConcurrency/2);Kl.workerCount=tw(globalThis)?Math.max(Math.min(DP,3),1):1;var Hn;function ap(){return Hn||(Hn=new Kl),Hn}function SP(){ap().acquire(rp)}function CP(){let e=Hn;e&&(e.isPreloaded()&&e.numActive()===1?(e.release(rp),Hn=null):console.warn("Could not clear WebWorkers since there are active Map instances that still reference it. The pre-warmed WebWorker pool can only be cleared when all map instances have been removed with map.remove()"))}var $1=class extends ht{constructor(e,t){super(),this.workerPool=e,this.actors=[],this.currentActor=0,this.id=t,this.removed=!1,this.workerErrorSubscriptions=[],this.actorsPromise=this.initActors(t)}async initActors(e){let t=await this.workerPool.acquire(e);if(this.removed)return[];if(this.actors=t.map((i,r)=>{this.workerErrorSubscriptions.push(Hs(i,"error",()=>{this.fire(new Y(Error("Worker failed to load. Check that the worker URL is correct.")))},!1));let a=new yP(i,e);return a.name=`Worker ${r}`,a}),!this.actors.length)throw Error("No actors found");return this.actors}async broadcast(e,t){let i=await this.actorsPromise;return Promise.all(i.map(r=>r.sendAsync({type:e,data:t})))}async getActor(){let e=await this.actorsPromise;return this.currentActor=(this.currentActor+1)%e.length,e[this.currentActor]}async waitForInitComplete(){this.actors.length===0&&await this.actorsPromise}getReadyActor(){return this.currentActor=(this.currentActor+1)%this.actors.length,this.actors[this.currentActor]}remove(e=!0){this.removed=!0;for(let t of this.actors)t.remove();for(let t of this.workerErrorSubscriptions)t.unsubscribe();this.actors=[],this.workerErrorSubscriptions=[],this.setEventedParent(null),e&&this.workerPool.release(this.id)}async registerMessageHandler(e,t){let i=await this.actorsPromise;for(let r of i)r.registerMessageHandler(e,t)}async unregisterMessageHandler(e){let t=await this.actorsPromise;for(let i of t)i.unregisterMessageHandler(e)}},vs;function np(){return vs||(vs=new $1(ap(),Fh),vs.registerMessageHandler("GR",(e,t,i)=>Dl(t,i))),vs}function PP(e,t){let i=na();lt(i,i,[1,1,0]),kt(i,i,[e.width*.5,e.height*.5,1]);let r=e.getFastPathSimpleProjectionMatrix(t);return r?wa(i,i,r):i}function AP(e,t,i){if(e)for(let r of e){let a=t[r];if(a?.source===i&&a.type==="fill-extrusion")return!0}else for(let r in t){let a=t[r];if(a.source===i&&a.type==="fill-extrusion")return!0}return!1}function IP(e,t,i,r,a,n,o){let s=AP(a?.layers??null,t,e.id),l=n.maxPitchScaleFactor(),u=e.tilesIn(r,l,s);u.sort(G1);let h=[];for(let c of u)h.push({wrappedTileID:c.tileID.wrapped().key,queryResults:c.tile.queryRenderedFeatures(t,i,e.getState(),c.queryGeometry,c.cameraQueryGeometry,c.scale,a,n,l,PP(n,c.tileID),o?(d,p)=>o(c.tileID,d,p):void 0)});return RP(zP(h),e)}function MP(e,t,i,r,a,n,o){let s={},l=n.queryRenderedSymbols(r),u=[];for(let h of Object.keys(l).map(Number))u.push(o[h]);u.sort(G1);for(let h of u){let c=h.featureIndex.lookupSymbolFeatures(l[h.bucketInstanceId],t,h.bucketIndex,h.sourceLayerIndex,{filterSpec:a.filter,globalState:a.globalState},a.layers,a.availableImages,e);for(let d in c){s[d]||(s[d]=[]);let p=c[d];p.sort((f,m)=>{let g=h.featureSortOrder;if(g){let _=g.indexOf(f.featureIndex);return g.indexOf(m.featureIndex)-_}return m.featureIndex-f.featureIndex});for(let f of p)s[d].push(f)}}return kP(s,e,i)}function FP(e,t){let i=e.getRenderableIds().map(n=>e.getTileByID(n)),r=[],a={};for(let n of i){let o=n.tileID.canonical.key;a[o]||(a[o]=!0,n.querySourceFeatures(r,t))}return r}function G1(e,t){let i=e.tileID,r=t.tileID;return i.overscaledZ-r.overscaledZ||i.canonical.y-r.canonical.y||i.wrap-r.wrap||i.canonical.x-r.canonical.x}function zP(e){let t={},i={};for(let{queryResults:r,wrappedTileID:a}of e){i[a]||(i[a]={});let n=i[a];for(let o in r){let s=r[o];n[o]||(n[o]={});let l=n[o];t[o]||(t[o]=[]);for(let u of s)l[u.featureIndex]||(l[u.featureIndex]=!0,t[o].push(u))}}return t}function RP(e,t){for(let i in e)for(let r of e[i])Z1(r,t);return e}function kP(e,t,i){for(let r in e)for(let a of e[r]){let n=i[t[r].source];Z1(a,n)}return e}function Z1(e,t){let i=e.feature,r=t.getFeatureState(i.layer["source-layer"],i.id);i.source=i.layer.source,i.layer["source-layer"]&&(i.sourceLayer=i.layer["source-layer"]),i.state=r}async function q1(e,t,i,r){let a=e;if(e.url?a=(await Sl(await t.transformRequest(e.url,"Source"),i)).data:await Kt.frameAsync(i,r),!a)return null;let n=yo(q(a,e),["tiles","minzoom","maxzoom","attribution","bounds","scheme","tileSize","encoding"]);return"vector_layers"in a&&a.vector_layers&&(n.vectorLayerIds=a.vector_layers.map(o=>o.id)),n}var zi=class er{constructor(t,i){t&&(i?this.setSouthWest(t).setNorthEast(i):Array.isArray(t)&&(t.length===4?this.setSouthWest([t[0],t[1]]).setNorthEast([t[2],t[3]]):this.setSouthWest(t[0]).setNorthEast(t[1])))}setNorthEast(t){return this._ne=t instanceof X?new X(t.lng,t.lat):X.convert(t),this}setSouthWest(t){return this._sw=t instanceof X?new X(t.lng,t.lat):X.convert(t),this}extend(t){let i=this._sw,r=this._ne,a,n;if(t instanceof X)a=t,n=t;else if(t instanceof er){if(a=t._sw,n=t._ne,!a||!n)return this}else{if(Array.isArray(t)){if(t.length===4||t.every(Array.isArray)){let o=t;return this.extend(er.convert(o))}{let o=t;return this.extend(X.convert(o))}}return t&&("lng"in t||"lon"in t)&&"lat"in t?this.extend(X.convert(t)):this}return!i&&!r?(this._sw=new X(a.lng,a.lat),this._ne=new X(n.lng,n.lat)):(i.lng=Math.min(a.lng,i.lng),i.lat=Math.min(a.lat,i.lat),r.lng=Math.max(n.lng,r.lng),r.lat=Math.max(n.lat,r.lat)),this}getCenter(){return new X((this._sw.lng+this._ne.lng)/2,(this._sw.lat+this._ne.lat)/2)}getSouthWest(){return this._sw}getNorthEast(){return this._ne}getNorthWest(){return new X(this.getWest(),this.getNorth())}getSouthEast(){return new X(this.getEast(),this.getSouth())}getWest(){return this._sw.lng}getSouth(){return this._sw.lat}getEast(){return this._ne.lng}getNorth(){return this._ne.lat}toArray(){return[this._sw.toArray(),this._ne.toArray()]}toString(){return`LngLatBounds(${this._sw.toString()}, ${this._ne.toString()})`}isEmpty(){return!(this._sw&&this._ne)}contains(t){let{lng:i,lat:r}=X.convert(t),a=this._sw.lat<=r&&r<=this._ne.lat,n=this._sw.lng<=i&&i<=this._ne.lng;return this._sw.lng>this._ne.lng&&(n=this._sw.lng>=i&&i>=this._ne.lng),a&&n}intersects(t){if(t=er.convert(t),!(t.getNorth()>=this.getSouth()&&t.getSouth()<=this.getNorth()))return!1;let i=Math.abs(this.getEast()-this.getWest()),r=Math.abs(t.getEast()-t.getWest());if(i>=360||r>=360)return!0;let a=vi(this.getWest(),-180,180),n=vi(this.getEast(),-180,180),o=vi(t.getWest(),-180,180),s=vi(t.getEast(),-180,180),l=a>n,u=o>s;return l&&u?!0:l?s>=a||o<=n:u?n>=o||a<=s:o<=n&&s>=a}static convert(t){return t instanceof er||!t?t:new er(t)}static fromLngLat(t,i=0){let r=360*i/40075017,a=r/Math.cos(Math.PI/180*t.lat);return new er(new X(t.lng-a,t.lat-r),new X(t.lng+a,t.lat+r))}adjustAntiMeridian(){let t=new X(this._sw.lng,this._sw.lat),i=new X(this._ne.lng,this._ne.lat);return t.lng>i.lng?new er(t,new X(i.lng+360,i.lat)):new er(t,i)}},W1=class{constructor(e,t,i){this.bounds=zi.convert(this.validateBounds(e)),this.minzoom=t||0,this.maxzoom=i||24}validateBounds(e){return!Array.isArray(e)||e.length!==4?[-180,-90,180,90]:[Math.max(-180,e[0]),Math.max(-90,e[1]),Math.min(180,e[2]),Math.min(90,e[3])]}contains(e){let t=2**e.z,i={minX:Math.floor(Ja(this.bounds.getWest())*t),minY:Math.floor(Qa(this.bounds.getNorth())*t),maxX:Math.ceil(Ja(this.bounds.getEast())*t),maxY:Math.ceil(Qa(this.bounds.getSouth())*t)};return e.x>=i.minX&&e.x<i.maxX&&e.y>=i.minY&&e.y<i.maxY}},H1=class extends ht{constructor(e,t,i,r){if(super(),this.id=e,this.dispatcher=i,this.type="vector",this.minzoom=0,this.maxzoom=22,this.scheme="xyz",this.tileSize=512,this.reparseOverscaled=!0,this.isTileClipped=!0,this._loaded=!1,q(this,yo(t,["url","scheme","tileSize","promoteId","encoding"])),this._options=q({type:"vector"},t),this._collectResourceTiming=t.collectResourceTiming,this.tileSize!==512)throw Error("vector tile sources must have a tileSize of 512");this.setEventedParent(r)}async load(e=!1){this._loaded=!1,this.fire(new Ne("dataloading")),this._tileJSONRequest=new AbortController;try{let t=await q1(this._options,this.map._requestManager,this._tileJSONRequest,this.map._ownerWindow);this._tileJSONRequest=null,this._loaded=!0,t&&(q(this,t),t.bounds&&(this.tileBounds=new W1(t.bounds,this.minzoom,this.maxzoom)),this.fire(new Ne("data",{sourceDataType:"metadata"})),this.fire(new Ne("data",{sourceDataType:"content",sourceDataChanged:e})))}catch(t){this._tileJSONRequest=null,this._loaded=!0,Cr(t)||this.fire(new Y(bt(t)))}}loaded(){return this._loaded}hasTile(e){return!this.tileBounds||this.tileBounds.contains(e.canonical)}onAdd(e){this.map=e,this.load()}setSourceProperty(e){this._tileJSONRequest&&this._tileJSONRequest.abort(),e(),this.load(!0)}setTiles(e){return this.setSourceProperty(()=>{this.tiles=e,this._options.tiles=e}),this}setUrl(e){return this.setSourceProperty(()=>{this.url=e,this._options.url=e}),this}onRemove(){this._tileJSONRequest&&(this._tileJSONRequest=(this._tileJSONRequest.abort(),null))}serialize(){return q({},this._options)}async loadTile(e){let t=e.tileID.canonical.url(this.tiles,this.map.getPixelRatio(),this.scheme),i={request:await this.map._requestManager.transformRequest(t,"Tile"),uid:e.uid,tileID:e.tileID,zoom:e.tileID.overscaledZ,tileSize:this.tileSize*e.tileID.overscaleFactor(),type:this.type,source:this.id,pixelRatio:this.map.getPixelRatio(),showCollisionBoxes:this.map.showCollisionBoxes,promoteId:this.promoteId,subdivisionGranularity:this.map.style.projection.subdivisionGranularity,encoding:this.encoding,overzoomParameters:await this._getOverzoomParameters(e),etag:e.etag};if(i.request.collectResourceTiming=this._collectResourceTiming,await this.dispatcher.waitForInitComplete(),e.aborted)return;let r="RT";if(!e.actor||e.state==="expired")e.actor=this.dispatcher.getReadyActor(),r="LT";else if(e.state==="loading")return new Promise((a,n)=>{e.reloadPromise={resolve:a,reject:n}});e.abortController=new AbortController;try{let a=await e.actor.sendAsync({type:r,data:i},e.abortController);if(delete e.abortController,e.aborted)return;this._afterTileLoadWorkerResponse(e,a);let n={};return a?.etagUnmodified&&(n.unmodified=!0),n}catch(a){if(delete e.abortController,e.aborted||Cr(a))return;if(a&&a.status!==404)throw a;this._afterTileLoadWorkerResponse(e,null)}}async _getOverzoomParameters(e){if(e.tileID.canonical.z<=this.maxzoom||this.map._zoomLevelsToOverscale===void 0)return;let t=e.tileID.scaledTo(this.maxzoom).canonical,i=t.url(this.tiles,this.map.getPixelRatio(),this.scheme);return{maxZoomTileID:t,overzoomRequest:await this.map._requestManager.transformRequest(i,"Tile")}}_afterTileLoadWorkerResponse(e,t){if(t?.resourceTiming&&(e.resourceTiming=t.resourceTiming),t&&this.map._refreshExpiredTiles&&e.setExpiryData(t),e.etag=t?.etag,e.loadVectorData(t,this.map.style),e.reloadPromise){let i=e.reloadPromise;e.reloadPromise=null,this.loadTile(e).then(i.resolve).catch(i.reject)}}async abortTile(e){e.abortController&&(e.abortController.abort(),delete e.abortController),e.actor&&await e.actor.sendAsync({type:"AT",data:{uid:e.uid,type:this.type,source:this.id}})}async unloadTile(e){e.unloadVectorData(),e.actor&&await e.actor.sendAsync({type:"RMT",data:{uid:e.uid,type:this.type,source:this.id}})}hasTransition(){return!1}},op=class extends ht{constructor(e,t,i,r){super(),this.id=e,this.dispatcher=i,this.setEventedParent(r),this.type="raster",this.minzoom=0,this.maxzoom=22,this.roundZoom=!0,this.scheme="xyz",this.tileSize=512,this._loaded=!1,this._premultiplyAlpha=!0,this._options=q({type:"raster"},t),q(this,yo(t,["url","scheme","tileSize"]))}async load(e=!1){this._loaded=!1,this.fire(new Ne("dataloading")),this._tileJSONRequest=new AbortController;try{let t=await q1(this._options,this.map._requestManager,this._tileJSONRequest,this.map._ownerWindow);this._tileJSONRequest=null,this._loaded=!0,t&&(q(this,t),t.bounds&&(this.tileBounds=new W1(t.bounds,this.minzoom,this.maxzoom)),this.fire(new Ne("data",{sourceDataType:"metadata"})),this.fire(new Ne("data",{sourceDataType:"content",sourceDataChanged:e})))}catch(t){this._tileJSONRequest=null,this._loaded=!0,Cr(t)||this.fire(new Y(bt(t)))}}loaded(){return this._loaded}onAdd(e){this.map=e,this.load()}onRemove(){this._tileJSONRequest&&(this._tileJSONRequest=(this._tileJSONRequest.abort(),null))}setSourceProperty(e){this._tileJSONRequest&&(this._tileJSONRequest=(this._tileJSONRequest.abort(),null)),e(),this.load(!0)}setTiles(e){return this.setSourceProperty(()=>{this.tiles=e,this._options.tiles=e}),this}setUrl(e){return this.setSourceProperty(()=>{this.url=e,this._options.url=e}),this}serialize(){return q({},this._options)}setPremultiplyAlpha(e){return this._premultiplyAlpha===e||this.setSourceProperty(()=>{this._premultiplyAlpha=e}),this}hasTile(e){return!this.tileBounds||this.tileBounds.contains(e.canonical)}async loadTile(e){let t=e.tileID.canonical.url(this.tiles,this.map.getPixelRatio(),this.scheme),i=this._premultiplyAlpha,r=i?void 0:{premultiplyAlpha:"none"};e.abortController=new AbortController;try{let a=await Ci.transformAndGetImage(this.map._requestManager,t,"Tile",e.abortController,this.map._refreshExpiredTiles,r);if(delete e.abortController,e.aborted){e.state="unloaded";return}if(a){this.map._refreshExpiredTiles&&(a.cacheControl||a.expires)&&e.setExpiryData({cacheControl:a.cacheControl,expires:a.expires});let n=this.map.painter.context,o=n.gl,s=a.data??new Ve({width:1,height:1},new Uint8Array(4));e.texture=this.map.painter.getTileTexture(s.width),e.texture?e.texture.update(s,{useMipmap:!0,premultiply:i}):(e.texture=new pt(n,s,o.RGBA,{useMipmap:!0,premultiply:i}),e.texture.bind(o.LINEAR,o.CLAMP_TO_EDGE,o.LINEAR_MIPMAP_NEAREST)),e.state="loaded"}}catch(a){if(delete e.abortController,e.aborted)e.state="unloaded";else if(a)throw e.state="errored",a}}async abortTile(e){e.abortController&&(e.abortController.abort(),delete e.abortController)}async unloadTile(e){e.texture&&this.map.painter.saveTileTexture(e.texture)}hasTransition(){return!1}};function LP(e,t,i){return!(e<0||e>25||i<0||i>=2**e||t<0||t>=2**e)}function ah(e,t){let{x:i,y:r}=De.fromLngLat(t);return!(e<0||e>25||r<0||r>=1||i<0||i>=1)}var Jl=class{constructor(e,t,i){if(!LP(e,t,i))throw Error(`x=${t}, y=${i}, z=${e} outside of bounds. 0<=x<${2**e}, 0<=y<${2**e} 0<=z<=25 `);this.z=e,this.x=t,this.y=i,this.key=Oa(0,e,e,t,i)}equals(e){return this.z===e.z&&this.x===e.x&&this.y===e.y}url(e,t,i){let r=BP(this.x,this.y,this.z),a=OP(this.z,this.x,this.y);return e[(this.x+this.y)%e.length].replace(/{prefix}/g,(this.x%16).toString(16)+(this.y%16).toString(16)).replace(/{z}/g,String(this.z)).replace(/{x}/g,String(this.x)).replace(/{y}/g,String(i==="tms"?2**this.z-this.y-1:this.y)).replace(/{ratio}/g,t>1?"@2x":"").replace(/{quadkey}/g,a).replace(/{bbox-epsg-3857}/g,r)}isChildOf(e){let t=this.z-e.z;return t>0&&e.x===this.x>>t&&e.y===this.y>>t}getTilePoint(e){let t=2**this.z;return new C((e.x*t-this.x)*k,(e.y*t-this.y)*k)}toString(){return`${this.z}/${this.x}/${this.y}`}},gl=class{constructor(e,t){this.wrap=e,this.canonical=t,this.key=Oa(e,t.z,t.z,t.x,t.y)}},Ct=class gi{constructor(t,i,r,a,n){if(this.terrainRttPosMatrix32f=null,t<r)throw Error(`overscaledZ should be >= z; overscaledZ = ${t}; z = ${r}`);this.overscaledZ=t,this.wrap=i,this.canonical=new Jl(r,+a,+n),this.key=Oa(i,t,r,a,n)}clone(){return new gi(this.overscaledZ,this.wrap,this.canonical.z,this.canonical.x,this.canonical.y)}equals(t){return this.overscaledZ===t.overscaledZ&&this.wrap===t.wrap&&this.canonical.equals(t.canonical)}scaledTo(t){if(t>this.overscaledZ)throw Error(`targetZ > this.overscaledZ; targetZ = ${t}; overscaledZ = ${this.overscaledZ}`);let i=this.canonical.z-t;return t>this.canonical.z?new gi(t,this.wrap,this.canonical.z,this.canonical.x,this.canonical.y):new gi(t,this.wrap,t,this.canonical.x>>i,this.canonical.y>>i)}isOverscaled(){return this.overscaledZ>this.canonical.z}calculateScaledKey(t,i){if(t>this.overscaledZ)throw Error(`targetZ > this.overscaledZ; targetZ = ${t}; overscaledZ = ${this.overscaledZ}`);let r=this.canonical.z-t;return t>this.canonical.z?Oa(this.wrap*+i,t,this.canonical.z,this.canonical.x,this.canonical.y):Oa(this.wrap*+i,t,t,this.canonical.x>>r,this.canonical.y>>r)}isChildOf(t){if(t.wrap!==this.wrap||this.overscaledZ-t.overscaledZ<=0)return!1;if(t.overscaledZ===0)return this.overscaledZ>0;let i=this.canonical.z-t.canonical.z;return i<0?!1:t.canonical.x===this.canonical.x>>i&&t.canonical.y===this.canonical.y>>i}children(t){if(this.overscaledZ>=t)return[new gi(this.overscaledZ+1,this.wrap,this.canonical.z,this.canonical.x,this.canonical.y)];let i=this.canonical.z+1,r=this.canonical.x*2,a=this.canonical.y*2;return[new gi(i,this.wrap,i,r,a),new gi(i,this.wrap,i,r+1,a),new gi(i,this.wrap,i,r,a+1),new gi(i,this.wrap,i,r+1,a+1)]}isLessThan(t){return this.wrap<t.wrap?!0:this.wrap>t.wrap?!1:this.overscaledZ<t.overscaledZ?!0:this.overscaledZ>t.overscaledZ?!1:this.canonical.x<t.canonical.x?!0:this.canonical.x>t.canonical.x?!1:this.canonical.y<t.canonical.y}wrapped(){return new gi(this.overscaledZ,0,this.canonical.z,this.canonical.x,this.canonical.y)}unwrapTo(t){return new gi(this.overscaledZ,t,this.canonical.z,this.canonical.x,this.canonical.y)}overscaleFactor(){return 2**(this.overscaledZ-this.canonical.z)}toUnwrapped(){return new gl(this.wrap,this.canonical)}toString(){return`${this.overscaledZ}/${this.canonical.x}/${this.canonical.y}`}getTilePoint(t){return this.canonical.getTilePoint(new De(t.x-this.wrap,t.y))}normalizeCoordinates(t,i,r=k){if(t>=0&&t<r&&i>=0&&i<r)return{tileID:this,x:t,y:i};let a=Math.floor(t/r),n=Math.floor(i/r),o=t-a*r,s=i-n*r,l=this.canonical.z,u=1<<l,h=this.canonical.y+n;if(h<0||h>=u)return null;let c=this.canonical.x+a,d=this.wrap;return c<0?(d-=Math.ceil(-c/u),c=(c%u+u)%u):c>=u&&(d+=Math.floor(c/u),c%=u),{tileID:new gi(this.overscaledZ,d,l,c,h),x:o,y:s}}};function Oa(e,t,i,r,a){e*=2,e<0&&(e=e*-1-1);let n=1<<i;return(n*n*e+n*a+r).toString(36)+i.toString(36)+t.toString(36)}var nh=Math.PI*6378137;function BP(e,t,i){t=2**i-t-1;let r=lg(e*256,t*256,i),a=lg((e+1)*256,(t+1)*256,i);return`${r[0]},${r[1]},${a[0]},${a[1]}`}function lg(e,t,i){let r=2*nh/256/2**i;return[e*r-nh,t*r-nh]}function OP(e,t,i){let r="";for(let a=e;a>0;a--){let n=1<<a-1;r+=(t&n?1:0)+(i&n?2:0)}return r}function ug(e,t){let i=Math.abs(e.wrap*2)-+(e.wrap<0),r=Math.abs(t.wrap*2)-+(t.wrap<0);return e.overscaledZ-t.overscaledZ||r-i||t.canonical.y-e.canonical.y||t.canonical.x-e.canonical.x}G("CanonicalTileID",Jl),G("OverscaledTileID",Ct,{omit:["terrainRttPosMatrix32f"]});var X1=class extends op{constructor(e,t,i,r){super(e,t,i,r),this.type="raster-dem",this.maxzoom=22,this._options=q({type:"raster-dem"},t),this.encoding=t.encoding||"mapbox",this.redFactor=t.redFactor,this.greenFactor=t.greenFactor,this.blueFactor=t.blueFactor,this.baseShift=t.baseShift}async loadTile(e){let t=e.tileID.canonical.url(this.tiles,this.map.getPixelRatio(),this.scheme);e.neighboringTiles=this._getNeighboringTiles(e.tileID),e.abortController=new AbortController;try{let i=await Ci.transformAndGetImage(this.map._requestManager,t,"Tile",e.abortController,this.map._refreshExpiredTiles,{colorSpaceConversion:"none"});if(delete e.abortController,e.aborted){e.state="unloaded";return}if(i){if(this.map._refreshExpiredTiles&&(i.cacheControl||i.expires)&&e.setExpiryData({cacheControl:i.cacheControl,expires:i.expires}),!i.data){e.state="loaded";return}let r=i.data,a=qr(r)&&md()?r:await this.readImageNow(r),n={type:this.type,uid:e.uid,source:this.id,rawImageData:a,encoding:this.encoding,redFactor:this.redFactor,greenFactor:this.greenFactor,blueFactor:this.blueFactor,baseShift:this.baseShift};if(e.actor&&e.state!=="expired"&&e.state!=="reloading")return;await this.dispatcher.waitForInitComplete(),(!e.actor||e.state==="expired")&&(e.actor=this.dispatcher.getReadyActor()),e.dem=await e.actor.sendAsync({type:"LDT",data:n}),e.needsHillshadePrepare=!0,e.needsTerrainPrepare=!0,e.needsColorReliefPrepare=!0,e.state="loaded"}}catch(i){if(delete e.abortController,e.aborted)e.state="unloaded";else if(i)throw e.state="errored",i}}async readImageNow(e){if(typeof VideoFrame<"u"&&z_()){let t=e.width+4,i=e.height+4;try{return new Ve({width:t,height:i},await nw(e,-2,-2,t,i))}catch{}}return Kt.getImageData(e,2)}_getNeighboringTiles(e){let t=e.canonical,i=2**t.z,r=(t.x-1+i)%i,a=t.x===0?e.wrap-1:e.wrap,n=(t.x+1+i)%i,o=t.x+1===i?e.wrap+1:e.wrap,s={};return s[new Ct(e.overscaledZ,a,t.z,r,t.y).key]={backfilled:!1},s[new Ct(e.overscaledZ,o,t.z,n,t.y).key]={backfilled:!1},t.y>0&&(s[new Ct(e.overscaledZ,a,t.z,r,t.y-1).key]={backfilled:!1},s[new Ct(e.overscaledZ,e.wrap,t.z,t.x,t.y-1).key]={backfilled:!1},s[new Ct(e.overscaledZ,o,t.z,n,t.y-1).key]={backfilled:!1}),t.y+1<i&&(s[new Ct(e.overscaledZ,a,t.z,r,t.y+1).key]={backfilled:!1},s[new Ct(e.overscaledZ,e.wrap,t.z,t.x,t.y+1).key]={backfilled:!1},s[new Ct(e.overscaledZ,o,t.z,n,t.y+1).key]={backfilled:!1}),s}async unloadTile(e){e.demTexture&&this.map.painter.saveTileTexture(e.demTexture),e.fbo&&(e.fbo.destroy(),delete e.fbo),e.dem&&delete e.dem,delete e.neighboringTiles,e.state="unloaded",e.actor&&await e.actor.sendAsync({type:"RDT",data:{type:this.type,uid:e.uid,source:this.id}})}};function _l(e,t){return t?e.properties[t]:e.id}function jP(e,t){let i=new Map;if(e==null||e.type==null)return i;if(e.type==="Feature"){let r=_l(e,t);return r==null?void 0:(i.set(r,e),i)}if(e.type==="FeatureCollection"){let r=new Set;for(let a of e.features){let n=_l(a,t);if(n==null||r.has(n))return;r.add(n),i.set(n,a)}return i}}function VP(e,t,i){let r=[];if(t.removeAll)e.clear();else if(t.remove)for(let a of t.remove){let n=e.get(a);n&&(r.push(n.geometry),e.delete(a))}if(t.add)for(let a of t.add){let n=_l(a,i);if(n==null)continue;let o=e.get(n);o&&r.push(o.geometry),r.push(a.geometry),e.set(n,a)}if(t.update)for(let a of t.update){let n=e.get(a.id);if(!n)continue;let o=!!a.newGeometry,s=a.removeAllProperties||a.removeProperties?.length>0||a.addOrUpdateProperties?.length>0;if(!o&&!s)continue;r.push(n.geometry);let l={...n};if(e.set(a.id,l),o&&(r.push(a.newGeometry),l.geometry=a.newGeometry),s){if(l.properties=a.removeAllProperties?{}:{...l.properties||{}},a.removeProperties)for(let u of a.removeProperties)delete l.properties[u];if(a.addOrUpdateProperties)for(let{key:u,value:h}of a.addOrUpdateProperties)l.properties[u]=h}}return r}function NP(e,t,i){if(!e)return t||{};if(!t)return e||{};let r=hg(e,i),a=hg(t,i);UP(r,a);let n={};if((r.removeAll||a.removeAll)&&(n.removeAll=!0),n.remove=new Set([...r.remove,...a.remove]),n.add=new Map([...r.add,...a.add]),n.update=new Map([...r.update,...a.update]),n.remove.size&&n.add.size)for(let o of n.add.keys())n.remove.delete(o);return GP(n)}function UP(e,t){t.removeAll&&(e.add.clear(),e.update.clear(),e.remove.clear(),t.remove.clear());for(let i of t.remove)e.add.delete(i),e.update.delete(i);for(let[i,r]of t.update){let a=e.update.get(i);a&&(t.update.set(i,$P(a,r)),e.update.delete(i))}}function $P(e,t){let i={id:e.id};if(t.removeAllProperties&&(delete e.removeProperties,delete e.addOrUpdateProperties,delete t.removeProperties),t.removeProperties&&e.addOrUpdateProperties){let r=new Set(t.removeProperties);e.addOrUpdateProperties=e.addOrUpdateProperties.filter(a=>!r.has(a.key))}return(e.removeAllProperties||t.removeAllProperties)&&(i.removeAllProperties=!0),(e.removeProperties||t.removeProperties)&&(i.removeProperties=[...e.removeProperties||[],...t.removeProperties||[]]),(e.addOrUpdateProperties||t.addOrUpdateProperties)&&(i.addOrUpdateProperties=[...e.addOrUpdateProperties||[],...t.addOrUpdateProperties||[]]),(e.newGeometry||t.newGeometry)&&(i.newGeometry=t.newGeometry||e.newGeometry),i}function hg(e,t){if(!e)return{};let i={};return i.removeAll=e.removeAll,i.remove=new Set(e.remove||[]),i.add=new Map(e.add?.map(r=>[_l(r,t),r])),i.update=new Map(e.update?.map(r=>[r.id,r])),i}function GP(e){let t={};return e.removeAll&&(t.removeAll=e.removeAll),e.remove&&(t.remove=Array.from(e.remove)),e.add&&(t.add=Array.from(e.add.values())),e.update&&(t.update=Array.from(e.update.values())),t}function Y1(e){return!e||e.length===0?[]:typeof e[0]=="number"?[e]:e.flatMap(t=>Y1(t))}function Vs(e){return e.type==="GeometryCollection"?e.geometries.flatMap(t=>Vs(t)):Y1(e.coordinates)}function cg(e){let t=new zi,i;switch(e.type){case"FeatureCollection":i=e.features.flatMap(r=>Vs(r.geometry));break;case"Feature":i=Vs(e.geometry);break;default:i=Vs(e)}if(i.length===0)return t;for(let r of i){let[a,n]=r;t.extend([a,n])}return t}function ZP({x:e,y:t,z:i},r=0){let a=Fc((e-r)/2**i),n=fo((t+1+r)/2**i),o=Fc((e+1+r)/2**i),s=fo((t-r)/2**i);return new zi([a,n],[o,s])}var qP=class{constructor(e){this._waiting=[],this._sending=!1,this._replacedWhileSending=!1,this._handlers=e}isIdle(){return!this._sending&&this._waiting.length===0}top(){return this._waiting.length?this._waiting[this._waiting.length-1]:void 0}some(e){return this._waiting.some(e)}enqueue(e){this._waiting.push(e)}replace(e){this._waiting=[e],this._replacedWhileSending=this._sending}clear(){this._waiting=[]}flush(){if(this.isIdle())return Promise.resolve();if(!this._flushing){let t,i=new Promise(r=>{t=r});this._flushing={promise:i,resolve:t}}let{promise:e}=this._flushing;return this._next(),e}_next(){if(this._sending)return;let e=this._waiting.shift();if(e===void 0){this._flushing?.resolve(),this._flushing=void 0;return}this._sending=!0,this._replacedWhileSending=!1,this._send(e).finally(()=>this._next())}async _send(e){let t;try{t=await this._handlers.send(e)}catch(i){this._sending=!1,this._handlers.onError(e,i);return}this._sending=!1;try{this._handlers.onResult(e,t,this._replacedWhileSending)}catch(i){this._handlers.onError(e,i)}}},K1=class extends ht{constructor(e,t,i,r){super(),this.id=e,this.type="geojson",this.minzoom=0,this.maxzoom=18,this.tileSize=512,this.isTileClipped=!0,this.reparseOverscaled=!0,this._removed=!1,this._workerUpdates=new qP({send:a=>this._sendWorkerUpdate(a),onResult:(a,n,o)=>this._onWorkerUpdateResult(a,n,o),onError:(a,n)=>this._onWorkerUpdateError(n)}),t.data!==void 0&&this._workerUpdates.enqueue({data:t.data}),this.actorPromise=i.getActor(),this.setEventedParent(r),this._data=typeof t.data=="string"?{url:t.data}:{geojson:t.data},this._options=q({},t),this._collectResourceTiming=t.collectResourceTiming,t.maxzoom!==void 0&&(this.maxzoom=t.maxzoom),t.type&&(this.type=t.type),t.attribution&&(this.attribution=t.attribution),this.promoteId=t.promoteId,t.clusterMaxZoom!==void 0&&this.maxzoom<=t.clusterMaxZoom&&_e(`The maxzoom value "${this.maxzoom}" is expected to be greater than the clusterMaxZoom value "${t.clusterMaxZoom}".`),this.workerOptions=q({source:this.id,geojsonVtOptions:{buffer:this._pixelsToTileUnits(t.buffer===void 0?128:t.buffer),tolerance:this._pixelsToTileUnits(t.tolerance===void 0?.375:t.tolerance),extent:k,maxZoom:this.maxzoom,lineMetrics:t.lineMetrics||!1,generateId:t.generateId||!1,promoteId:this._promoteIdKey,cluster:t.cluster||!1,clusterOptions:{maxZoom:this._getClusterMaxZoom(t.clusterMaxZoom),minPoints:Math.max(2,t.clusterMinPoints||2),extent:k,radius:this._pixelsToTileUnits(t.clusterRadius||50),log:!1,generateId:t.generateId||!1}},clusterProperties:t.clusterProperties,filter:t.filter},t.workerOptions)}get _promoteIdKey(){return typeof this.promoteId=="string"?this.promoteId:void 0}_pixelsToTileUnits(e){return e*(k/this.tileSize)}_tileUnitsToPixels(e){return e/(k/this.tileSize)}_getClusterMaxZoom(e){let t=e?Math.round(e):this.maxzoom-1;return Number.isInteger(e)||e===void 0||_e(`Integer expected for option 'clusterMaxZoom': provided value "${e}" rounded to "${t}"`),t}async load(){if(this._workerUpdates.isIdle()){_e(`No pending worker updates for GeoJSONSource ${this.id}.`);return}await this._workerUpdates.flush()}onAdd(e){this.map=e,this.load()}setData(e){return this._data=typeof e=="string"?{url:e}:{geojson:e},this._workerUpdates.replace({data:e}),this._workerUpdates.flush()}updateData(e){let t=this._getWaitingWorkerChange();return t?t.diff=NP(t.diff,e,this._promoteIdKey):this._workerUpdates.enqueue({diff:e}),this._workerUpdates.flush()}async getData(){for(;this._data.url;)await this.once("data");return this._data.geojson?this._data.geojson:{type:"FeatureCollection",features:Array.from(this._data.updateable.values())}}async getBounds(){return cg(await this.getData())}setClusterOptions(e){if(this.workerOptions.geojsonVtOptions.cluster=e.cluster,e.clusterRadius!==void 0&&(this.workerOptions.geojsonVtOptions.clusterOptions.radius=this._pixelsToTileUnits(e.clusterRadius)),e.clusterMaxZoom!==void 0&&(this.workerOptions.geojsonVtOptions.clusterOptions.maxZoom=this._getClusterMaxZoom(e.clusterMaxZoom)),!this._workerUpdates.some(t=>"data"in t)){let t=this._getWaitingWorkerChange();t?t.updateCluster=!0:this._workerUpdates.enqueue({updateCluster:!0})}return this._workerUpdates.flush()}_getWaitingWorkerChange(){let e=this._workerUpdates.top();return e&&!("data"in e)?e:void 0}getClusterOptions(){let{cluster:e,clusterOptions:t}=this.workerOptions.geojsonVtOptions;return{cluster:e,clusterMaxZoom:t.maxZoom,clusterRadius:this._tileUnitsToPixels(t.radius)}}async getClusterExpansionZoom(e){return(await this.actorPromise).sendAsync({type:"GCEZ",data:{type:this.type,clusterId:e,source:this.id}})}async getClusterChildren(e){return(await this.actorPromise).sendAsync({type:"GCC",data:{type:this.type,clusterId:e,source:this.id}})}async getClusterLeaves(e,t,i){return(await this.actorPromise).sendAsync({type:"GCL",data:{type:this.type,source:this.id,clusterId:e,limit:t,offset:i}})}async _getLoadGeoJSONParameters(e){let t=q({type:this.type,source:this.id},this.workerOptions);return"data"in e?typeof e.data=="string"?(t.request=await this.map._requestManager.transformRequest(Kt.resolveURL(e.data),"Source"),t.request.collectResourceTiming=this._collectResourceTiming,t):(t.data=e.data,t):(e.diff&&(t.dataDiff=e.diff),e.updateCluster&&(t.updateCluster=!0),t)}async _sendWorkerUpdate(e){this.fire(new Ne("dataloading"));let t=await this._getLoadGeoJSONParameters(e);return(await this.actorPromise).sendAsync({type:"LD",data:t})}_onWorkerUpdateResult(e,t,i){if(this._removed||t.abandoned){this.fire(new Ne("dataabort"));return}t.data&&!i&&(this._data={geojson:t.data});let r="data"in e||i?void 0:e.diff,a=this._applyDiffToSource(r),n=!("data"in e)&&e.updateCluster?void 0:this._getShouldReloadTileOptions(a),o={};this._applyResourceTiming(o,t),this.fire(new Ne("data",{...o,sourceDataType:"metadata"})),this.fire(new Ne("data",{...o,sourceDataType:"content",shouldReloadTileOptions:n}))}_onWorkerUpdateError(e){if(this._removed){this.fire(new Ne("dataabort"));return}this.fire(new Y(bt(e)))}_applyResourceTiming(e,t){if(!this._collectResourceTiming)return;let i=t.resourceTiming?.[this.id];if(!i)return;let r=i.slice(0);r?.length&&q(e,{resourceTiming:r})}_applyDiffToSource(e){if(!e)return;let t=this._promoteIdKey;if(!this._data.url&&!this._data.updateable){let r=jP(this._data.geojson,t);if(!r)throw Error(`GeoJSONSource "${this.id}": GeoJSON data is not compatible with updateData`);this._data={updateable:r}}if(!this._data.updateable)return;let i=VP(this._data.updateable,e,t);if(!(e.removeAll||this.workerOptions.geojsonVtOptions.cluster))return i}_getShouldReloadTileOptions(e){if(e)return{affectedBounds:e.filter(Boolean).map(t=>cg(t))}}shouldReloadTile(e,{affectedBounds:t}){if(e.state==="loading")return!0;if(e.state==="unloaded")return!1;let{buffer:i,extent:r}=this.workerOptions.geojsonVtOptions,a=ZP(e.tileID.canonical,i/r);for(let n of t)if(a.intersects(n))return!0;return!1}loaded(){return this._workerUpdates.isIdle()}async loadTile(e){let t=e.actor?"RT":"LT";e.actor=await this.actorPromise;let i={type:this.type,uid:e.uid,tileID:e.tileID,zoom:e.tileID.overscaledZ,maxZoom:this.maxzoom,tileSize:this.tileSize,source:this.id,pixelRatio:this.map.getPixelRatio(),showCollisionBoxes:this.map.showCollisionBoxes,promoteId:this.promoteId,subdivisionGranularity:this.map.style.projection.subdivisionGranularity};e.abortController=new AbortController;try{let r=await(await this.actorPromise).sendAsync({type:t,data:i},e.abortController);delete e.abortController,e.unloadVectorData(),e.aborted||e.loadVectorData(r,this.map.style,t==="RT")}catch(r){if(delete e.abortController,e.aborted||Cr(r))return;throw r}}async abortTile(e){e.abortController&&(e.abortController.abort(),delete e.abortController),e.aborted=!0}async unloadTile(e){e.unloadVectorData(),await(await this.actorPromise).sendAsync({type:"RMT",data:{uid:e.uid,type:this.type,source:this.id}})}onRemove(){this._removed=!0,this._workerUpdates.clear(),this.actorPromise.then(e=>e.sendAsync({type:"RS",data:{type:this.type,source:this.id}}))}serialize(){return q({},this._options,{type:this.type,data:this._data.updateable?{type:"FeatureCollection",features:Array.from(this._data.updateable.values())}:this._data.url||this._data.geojson})}hasTransition(){return!1}},ja=[0,0,1],WP=(e,t)=>({u_tl_parent:new de(e,t.u_tl_parent),u_scale_parent:new $(e,t.u_scale_parent),u_buffer_scale:new $(e,t.u_buffer_scale),u_image_warp:new Nt(e,t.u_image_warp),u_fade_t:new $(e,t.u_fade_t),u_opacity:new $(e,t.u_opacity),u_image0:new K(e,t.u_image0),u_image1:new K(e,t.u_image1),u_brightness_low:new $(e,t.u_brightness_low),u_brightness_high:new $(e,t.u_brightness_high),u_saturation_factor:new $(e,t.u_saturation_factor),u_contrast_factor:new $(e,t.u_contrast_factor),u_spin_weights:new Nt(e,t.u_spin_weights),u_coords_top:new Ya(e,t.u_coords_top),u_coords_bottom:new Ya(e,t.u_coords_bottom)}),HP=(e,t,i,r,a,n)=>({u_tl_parent:e,u_scale_parent:t,u_buffer_scale:1,u_image_warp:n,u_fade_t:i.mix,u_opacity:i.opacity*r.paint.get("raster-opacity"),u_image0:0,u_image1:1,u_brightness_low:r.paint.get("raster-brightness-min"),u_brightness_high:r.paint.get("raster-brightness-max"),u_saturation_factor:KP(r.paint.get("raster-saturation")),u_contrast_factor:YP(r.paint.get("raster-contrast")),u_spin_weights:XP(r.paint.get("raster-hue-rotate")),u_coords_top:[a[0].x,a[0].y,a[1].x,a[1].y],u_coords_bottom:[a[3].x,a[3].y,a[2].x,a[2].y]});function XP(e){e*=Math.PI/180;let t=Math.sin(e),i=Math.cos(e);return[(2*i+1)/3,(-Math.sqrt(3)*t-i+1)/3,(Math.sqrt(3)*t-i+1)/3]}function YP(e){return e>0?1/(1-e):1+e}function KP(e){return e>0?1-1/(1.001-e):-e}var go=class{constructor(e,t,i){this.vertexBuffer=e,this.indexBuffer=t,this.segments=i}destroy(){this.vertexBuffer.destroy(),this.indexBuffer.destroy(),this.segments.destroy(),this.vertexBuffer=null,this.indexBuffer=null,this.segments=null}},Ma=Je([{name:"a_pos",type:"Int16",components:2}]);function J1(e,t){let i=Q1(t,"16bit"),r=Gr.deserialize({arrayBuffer:i.vertices,length:i.vertices.byteLength/2/2}),a=Xi.deserialize({arrayBuffer:i.indices,length:i.indices.byteLength/2/3});return new go(e.createVertexBuffer(r,Ma.members),e.createIndexBuffer(a),Ye.simpleSegment(0,0,r.length,a.length))}function Q1(e,t){let i=e.granularity===void 0?1:Math.max(e.granularity,1),r=i+(e.generateBorders?2:0),a=i+(e.extendToNorthPole||e.generateBorders?1:0)+(e.extendToSouthPole||e.generateBorders?1:0),n=r+1,o=a+1,s=e.generateBorders?-1:0,l=e.generateBorders||e.extendToNorthPole?-1:0,u=i+ +!!e.generateBorders,h=i+(e.generateBorders||e.extendToSouthPole?1:0),c=n*o,d=r*a*6,p=n*o>65536;if(p&&t==="16bit")throw Error("Granularity is too large and meshes would not fit inside 16 bit vertex indices.");let f=p||t==="32bit",m=new Int16Array(c*2),g=0;for(let v=l;v<=h;v++)for(let x=s;x<=u;x++){let b=x/i*k;x===-1&&(b=-64),x===i+1&&(b=8256);let w=v/i*k;v===-1&&(w=e.extendToNorthPole?Gn:-64),v===i+1&&(w=e.extendToSouthPole?Zn:8256),m[g++]=b,m[g++]=w}let _=f?new Uint32Array(d):new Uint16Array(d),y=0;for(let v=0;v<a;v++)for(let x=0;x<r;x++){let b=x+v*n,w=x+1+v*n,T=x+(v+1)*n,E=x+1+(v+1)*n;_[y++]=b,_[y++]=T,_[y++]=w,_[y++]=w,_[y++]=T,_[y++]=E}return{vertices:m.buffer.slice(0),indices:_.buffer.slice(0),uses32bitIndices:f}}var an=class extends ht{constructor(e,t,i,r){super(),this.imageWarp=ja,this.flippedWindingOrder=!1,this._warp="auto",this._imageDirty=!1,this._subdividedQuad=!1,this._subdividedMesh=null,this.id=e,this.dispatcher=i,this.coordinates=t.coordinates,this.type="image",this.minzoom=0,this.maxzoom=22,this.tileSize=512,this.tiles={},this._loaded=!1,this.setEventedParent(r),this.options=t}async load(e){if(this.options.url===void 0){this._loaded=!0,this._finishLoading();return}this._loaded=!1,this.fire(new Ne("dataloading")),this.url=this.options.url,this._abortController=new AbortController;try{let t=await Ci.transformAndGetImage(this.map._requestManager,this.url,"Image",this._abortController);this._abortController=null,this._loaded=!0,t?.data?(this._setImage(t.data),e&&(this.coordinates=e),this._finishLoading()):this.fire(new Y(Error(`Could not load image ${this.url}: the response is empty`)))}catch(t){if(Cr(t))return;this._abortController=null,this._loaded=!0,this.fire(new Y(bt(t)))}}loaded(){return this._loaded}updateImage(e){return this._abortController&&(this._abortController=(this._abortController.abort(),null)),"image"in e?(this._loaded=!0,this._setImage(e.image),e.coordinates&&(this.coordinates=e.coordinates),this._finishLoading(),this):e.url?(this.options.url=e.url,this.load(e.coordinates),this):this}_setImage(e){this.image=e,this._imageDirty=!0}getMesh(e,t){return!this._subdividedQuad||t?null:(this._subdividedMesh??(this._subdividedMesh=J1(e,{granularity:16})),this._subdividedMesh)}_disposeTexture(){this.texture?.destroy(),this.texture=null}_finishLoading(){if(this.map)try{this.setCoordinates(this.coordinates),this.fire(new Ne("data",{sourceDataType:"metadata"}))}catch(e){this.fire(new Y(bt(e)))}}onAdd(e){this.map=e,this.load()}onRemove(){this._abortController&&(this._abortController=(this._abortController.abort(),null)),this._disposeTexture(),this._subdividedMesh?.destroy(),this._subdividedMesh=null,this.image=null,this.tiles={}}setWarp(e){return this._warp===e?this:(this._warp=e,this.tileCoords&&this.setCoordinates(this.coordinates),this)}getWarp(){return this._warp}setCoordinates(e){this.coordinates=e;let t=e.map(De.fromLngLat);return this.tileID=JP(t),this.terrainTileRanges=this._getOverlappingTileRanges(t),this.minzoom=this.maxzoom=this.tileID.z,this.tileCoords=t.map(i=>this.tileID.getTilePoint(i)._round()),this.imageWarp=eA(this.tileCoords,this._warp),this._subdividedQuad=this.imageWarp[2]>0&&!ev(this.tileCoords),this.flippedWindingOrder=QP(this.tileCoords),this.fire(new Ne("data",{sourceDataType:"content"})),this}prepare(){if(Object.keys(this.tiles).length===0||!this.image)return;let e=this.map.painter.context,t=e.gl;this.texture?this._imageDirty&&(this.texture.update(this.image),this.texture.bind(t.LINEAR,t.CLAMP_TO_EDGE)):(this.texture=new pt(e,this.image,t.RGBA),this.texture.bind(t.LINEAR,t.CLAMP_TO_EDGE)),this._imageDirty=!1;let i=!1;for(let r in this.tiles){let a=this.tiles[r];a.state!=="loaded"&&(a.state="loaded",a.texture=this.texture,i=!0)}i&&this.fire(new Ne("data",{sourceDataType:"idle",sourceId:this.id}))}async loadTile(e){this.tileID?.equals(e.tileID.canonical)?(this.tiles[String(e.tileID.wrap)]=e,e.buckets={}):e.state="errored"}serialize(){let e={type:"image",coordinates:this.coordinates};return this.options.url!==void 0&&(e.url=this.options.url),e}hasTransition(){return!1}_getOverlappingTileRanges(e){let{minX:t,minY:i,maxX:r,maxY:a}=Ii.fromPoints(e),n={};for(let o=0;o<=25;o++){let s=2**o,l=Math.floor(t*s),u=Math.floor(i*s),h=Math.floor(r*s),c=Math.floor(a*s),d=(l%s+s)%s,p=h%s,f=Math.floor(l/s),m=Math.floor(h/s);n[o]={minWrap:f,maxWrap:m,minTileXWrapped:d,maxTileXWrapped:p,minTileY:u,maxTileY:c}}return n}};function JP(e){let t=Ii.fromPoints(e),i=t.width(),r=t.height(),a=Math.max(0,Math.floor(-Math.log(Math.max(i,r))/Math.LN2)),n=2**a;return new Jl(a,Math.floor((t.minX+t.maxX)/2*n),Math.floor((t.minY+t.maxY)/2*n))}function QP(e){let t=e[1].x-e[0].x,i=e[1].y-e[0].y,r=e[2].x-e[0].x;return t*(e[2].y-e[0].y)-i*r<0}function eA(e,t){if(t==="flat"||ev(e))return ja;let[i,r,a,n]=e,o=i.x-r.x+a.x-n.x,s=i.y-r.y+a.y-n.y,l=[r.x-a.x,r.y-a.y,n.x-a.x,n.y-a.y],[u,h,c,d]=l,p=_b(l),f=(o*d-c*s)/p,m=(u*s-o*h)/p,g=[1,1+f,1+f+m,1+m],_=Math.max(...g)/Math.min(...g),y=t==="perspective"?0:tA(_);return!(_>=1&&_<=512)||y>=1?ja:[f,m,y]}function tA(e){let t=(1-4/e)/.9921875;return Math.max(0,t)}function ev(e){let[t,i,r,a]=e;return t.x+r.x===i.x+a.x&&t.y+r.y===i.y+a.y}var tv=class extends an{constructor(e,t,i,r){super(e,t,i,r),this._onPlayingHandler=()=>{this.map?.triggerRepaint()},this.roundZoom=!0,this.type="video",this.options=t}async load(){this._loaded=!1;let e=this.options;this.urls=[];for(let t of e.urls)this.urls.push((await this.map._requestManager.transformRequest(t,"Source")).url);try{let t=await ww(this.urls);if(this._loaded=!0,!t)return;this.video=t,this.video.loop=!0,this.video.addEventListener("playing",this._onPlayingHandler),this.map&&this.video.play(),this._finishLoading()}catch(t){this.fire(new Y(bt(t)))}}pause(){this.video&&this.video.pause()}play(){this.video&&this.video.play()}seek(e){if(this.video){let t=this.video.seekable;e<t.start(0)||e>t.end(0)?this.fire(new Y(new L(`sources.${this.id}`,null,`Playback for this video can be set only between the ${t.start(0)} and ${t.end(0)}-second mark.`))):this.video.currentTime=e}}getVideo(){return this.video}onAdd(e){this.map||(this.map=e,this.load(),this.video&&(this.video.play(),this.setCoordinates(this.coordinates)))}onRemove(){super.onRemove(),this.video&&(this.video.removeEventListener("playing",this._onPlayingHandler),this.video.pause())}prepare(){if(Object.keys(this.tiles).length===0||this.video.readyState<2)return;let e=this.map.painter.context,t=e.gl;this.texture?this.video.paused||(this.texture.bind(t.LINEAR,t.CLAMP_TO_EDGE),t.texSubImage2D(t.TEXTURE_2D,0,0,0,t.RGBA,t.UNSIGNED_BYTE,this.video)):(this.texture=new pt(e,this.video,t.RGBA),this.texture.bind(t.LINEAR,t.CLAMP_TO_EDGE));let i=!1;for(let r in this.tiles){let a=this.tiles[r];a.state!=="loaded"&&(a.state="loaded",a.texture=this.texture,i=!0)}i&&this.fire(new Ne("data",{sourceDataType:"idle",sourceId:this.id}))}serialize(){return{type:"video",urls:this.urls,coordinates:this.coordinates}}hasTransition(){return this.video&&!this.video.paused}},iv=class extends an{constructor(e,t,i,r){super(e,t,i,r),t.coordinates?(!Array.isArray(t.coordinates)||t.coordinates.length!==4||t.coordinates.some(a=>!Array.isArray(a)||a.length!==2||a.some(n=>typeof n!="number")))&&this.fire(new Y(new L(`sources.${e}`,null,'"coordinates" property must be an array of 4 longitude/latitude array pairs'))):this.fire(new Y(new L(`sources.${e}`,null,'missing required property "coordinates"'))),t.animate&&typeof t.animate!="boolean"&&this.fire(new Y(new L(`sources.${e}`,null,'optional "animate" property must be a boolean value'))),t.canvas?typeof t.canvas!="string"&&!(t.canvas instanceof HTMLCanvasElement)&&this.fire(new Y(new L(`sources.${e}`,null,'"canvas" must be either a string representing the ID of the canvas element from which to read, or an HTMLCanvasElement instance'))):this.fire(new Y(new L(`sources.${e}`,null,'missing required property "canvas"'))),this.options=t,this.animate=t.animate===void 0||t.animate}async load(){if(this._loaded=!0,this.canvas||(this.canvas=this.options.canvas instanceof HTMLCanvasElement?this.options.canvas:document.getElementById(this.options.canvas)),this.width=this.canvas.width,this.height=this.canvas.height,this._hasInvalidDimensions()){this.fire(new Y(Error("Canvas dimensions cannot be less than or equal to zero.")));return}this.play=function(){this._playing=!0,this.map.triggerRepaint()},this.pause=function(){this._playing&&(this._playing=(this.prepare(),!1))},this._finishLoading()}getCanvas(){return this.canvas}onAdd(e){this.map=e,this.load(),this.canvas&&this.animate&&this.play()}onRemove(){this._playing=!1,super.onRemove()}prepare(){let e=!1;if(this.canvas.width!==this.width&&(this.width=this.canvas.width,e=!0),this.canvas.height!==this.height&&(this.height=this.canvas.height,e=!0),this._hasInvalidDimensions()||Object.keys(this.tiles).length===0)return;let t=this.map.painter.context,i=t.gl;this.texture?(e||this._playing)&&this.texture.update(this.canvas,{premultiply:!0}):(this.texture=new pt(t,this.canvas,i.RGBA,{premultiply:!0}),this.texture.bind(i.LINEAR,i.CLAMP_TO_EDGE));let r=!1;for(let a in this.tiles){let n=this.tiles[a];n.state!=="loaded"&&(n.state="loaded",n.texture=this.texture,r=!0)}r&&this.fire(new Ne("data",{sourceDataType:"idle",sourceId:this.id}))}serialize(){return{type:"canvas",animate:this.animate,canvas:this.options.canvas,coordinates:this.coordinates}}hasTransition(){return this._playing}_hasInvalidDimensions(){for(let e of[this.canvas.width,this.canvas.height])if(isNaN(e)||e<=0)return!0;return!1}},rv={},iA=(e,t,i,r)=>{let a=new(av(t.type))(e,t,i,r);if(a.id!==e)throw Error(`Expected Source id to be ${e} instead of ${a.id}`);return a},av=e=>{switch(e){case"geojson":return K1;case"image":return an;case"raster":return op;case"raster-dem":return X1;case"vector":return H1;case"video":return tv;case"canvas":return iv}return rv[e]},rA=(e,t)=>{rv[e]=t},aA=async(e,t)=>{if(av(e))throw Error(`A source type called "${e}" already exists.`);rA(e,t)};function nA(e,t){let i={};if(!t)return i;for(let r of e){let a=r.layerIds.map(n=>t.getLayer(n)).filter(Boolean);if(a.length!==0){r.layers=a,r.stateDependentLayerIds&&(r.stateDependentLayers=r.stateDependentLayerIds.map(n=>a.filter(o=>o.id===n)[0]));for(let n of a)i[n.id]=r}}return i}var Ns="_geojsonTileLayer",oA=class{constructor(e){this._stringToNumber={},this._numberToString=[];for(let t=0;t<e.length;t++){let i=e[t];this._stringToNumber[i]=t,this._numberToString[t]=i}}encode(e){return this._stringToNumber[e]}decode(e){if(e>=this._numberToString.length)throw Error(`Out of bounds. Index requested n=${e} can't be >= this._numberToString.length ${this._numberToString.length}`);return this._numberToString[e]}},nv=class{constructor(e,t,i,r,a){this.type="Feature",this._vectorTileFeature=e,this._x=i,this._y=r,this._z=t;for(let n in e.properties)typeof e.properties[n]=="string"&&e.properties[n].startsWith("__$json__:")&&(e.properties[n]=JSON.parse(e.properties[n].slice(10)));this.properties=e.properties,this.id=a}projectPoint(e,t,i,r){return[(e.x+t)*360/r-180,360/Math.PI*Math.atan(Math.exp((1-(e.y+i)*2/r)*Math.PI))-90]}projectLine(e,t,i,r){return e.map(a=>this.projectPoint(a,t,i,r))}get geometry(){if(this._geometry)return this._geometry;let e=this._vectorTileFeature,t=e.extent*2**this._z,i=e.extent*this._x,r=e.extent*this._y,a=e.loadGeometry();switch(e.type){case 1:{let n=[];for(let s of a)n.push(s[0]);let o=this.projectLine(n,i,r,t);this._geometry=n.length===1?{type:"Point",coordinates:o[0]}:{type:"MultiPoint",coordinates:o};break}case 2:{let n=a.map(o=>this.projectLine(o,i,r,t));this._geometry=n.length===1?{type:"LineString",coordinates:n[0]}:{type:"MultiLineString",coordinates:n};break}case 3:{let n=o1(a),o=[];for(let s of n)o.push(s.map(l=>this.projectLine(l,i,r,t)));this._geometry=o.length===1?{type:"Polygon",coordinates:o[0]}:{type:"MultiPolygon",coordinates:o};break}default:throw Error(`unknown feature type: ${e.type}`)}return this._geometry}set geometry(e){this._geometry=e}toJSON(){let e={geometry:this.geometry};for(let t in this)t!=="_geometry"&&t!=="_vectorTileFeature"&&t!=="_x"&&t!=="_y"&&t!=="_z"&&(e[t]=this[t]);return e}},ua=class{constructor(e,t,i){this._name=e,this.dataBuffer=t,typeof i=="number"?this._size=i:(this.nullabilityBuffer=i,this._size=i.size())}getValue(e){return this.nullabilityBuffer&&!this.nullabilityBuffer.get(e)?null:this.getValueFromBuffer(e)}has(e){return this.nullabilityBuffer?.get(e)||!this.nullabilityBuffer}get name(){return this._name}get size(){return this._size}},Ql=class extends ua{},sp=class extends Ql{getValueFromBuffer(e){return this.dataBuffer[e]}},lp=class extends Ql{getValueFromBuffer(e){return this.dataBuffer[e]}},ov=class extends ua{constructor(e,t,i,r){super(e,t,r),this.delta=i}},up=class extends ov{constructor(e,t,i,r,a){super(e,a?Int32Array.of(t):Uint32Array.of(t),i,r)}getValueFromBuffer(e){return this.dataBuffer[0]+e*this.delta}},hp=class extends ua{constructor(e,t,i,r){super(e,r?Int32Array.of(t):Uint32Array.of(t),i)}getValueFromBuffer(e){return this.dataBuffer[0]}},sA=class{constructor(e,t,i,r,a=4096){if(this._name=e,this._geometryVector=t,this._idVector=i,this._propertyVectors=r,this._extent=a,e.length===0)throw Error("Missing layer name")}get name(){return this._name}get idVector(){return this._idVector}get geometryVector(){return this._geometryVector}get propertyVectors(){return this._propertyVectors??[]}getPropertyVector(e){return this.propertyVectorsMap||(this.propertyVectorsMap=new Map(this.propertyVectors.map(t=>[t.name,t]))),this.propertyVectorsMap.get(e)}get numFeatures(){return this.geometryVector.numGeometries}get extent(){return this._extent}getFeatures(){let e=[],t=this.geometryVector.getGeometries();for(let i=0;i<this.numFeatures;i++){let r;if(this.idVector){let o=this.idVector.getValue(i);o!==null&&(r=this.containsMaxSafeIntegerValues(this.idVector)?Number(o):o)}let a={coordinates:t[i],type:this.geometryVector.geometryType(i)},n={};for(let o of this.propertyVectors){if(!o)continue;let s=o.name,l=o.getValue(i);l!==null&&(n[s]=l)}e.push({id:r,geometry:a,properties:n})}return e}containsMaxSafeIntegerValues(e){return e instanceof sp||e instanceof hp||e instanceof up||e instanceof lp}},Bn={FEATURE:0,VERTEX:1},Ee={BOOLEAN:0,INT_8:1,UINT_8:2,INT_32:3,UINT_32:4,INT_64:5,UINT_64:6,FLOAT:7,DOUBLE:8,STRING:9},Dr={GEOMETRY:0,STRUCT:1,MAP:2},sv={ID:0},lv=class{constructor(e){this.value=e}get(){return this.value}set(e){this.value=e}increment(){return this.value++}add(e){this.value+=e}},ue;(function(e){e.NONE="NONE",e.DELTA="DELTA",e.COMPONENTWISE_DELTA="COMPONENTWISE_DELTA",e.RLE="RLE",e.MORTON="MORTON"})(ue||(ue={}));var ni;(function(e){e.NONE="NONE",e.FAST_PFOR="FAST_PFOR",e.VARINT="VARINT"})(ni||(ni={}));var cp=new Uint32Array(33);cp[0]=0;for(let e=1;e<=32;e++)cp[e]=e===32?4294967295:4294967295>>>32-e;var Wc=cp,dp=65536;function pp(e,t){return e-e%t}function lA(e){return pp(e+31,32)}function uv(e){if(!Number.isFinite(e)||e<=0)return dp;let t=pp(Math.floor(e),256);return t===0?256:t}function uA(e){let t=e>>>0;return((t&255)<<24|(t&65280)<<8|t>>>8&65280|t>>>24&255)>>>0}function hA(e,t,i,r){let a=r,n=e[t]>>>0,o=e[t+1]>>>0;i[a++]=n>>>0&3,i[a++]=n>>>2&3,i[a++]=n>>>4&3,i[a++]=n>>>6&3,i[a++]=n>>>8&3,i[a++]=n>>>10&3,i[a++]=n>>>12&3,i[a++]=n>>>14&3,i[a++]=n>>>16&3,i[a++]=n>>>18&3,i[a++]=n>>>20&3,i[a++]=n>>>22&3,i[a++]=n>>>24&3,i[a++]=n>>>26&3,i[a++]=n>>>28&3,i[a++]=n>>>30&3,i[a++]=o>>>0&3,i[a++]=o>>>2&3,i[a++]=o>>>4&3,i[a++]=o>>>6&3,i[a++]=o>>>8&3,i[a++]=o>>>10&3,i[a++]=o>>>12&3,i[a++]=o>>>14&3,i[a++]=o>>>16&3,i[a++]=o>>>18&3,i[a++]=o>>>20&3,i[a++]=o>>>22&3,i[a++]=o>>>24&3,i[a++]=o>>>26&3,i[a++]=o>>>28&3,i[a]=o>>>30&3}function cA(e,t,i,r){let a=r,n=e[t]>>>0,o=e[t+1]>>>0,s=e[t+2]>>>0;i[a++]=n>>>0&7,i[a++]=n>>>3&7,i[a++]=n>>>6&7,i[a++]=n>>>9&7,i[a++]=n>>>12&7,i[a++]=n>>>15&7,i[a++]=n>>>18&7,i[a++]=n>>>21&7,i[a++]=n>>>24&7,i[a++]=n>>>27&7,i[a++]=(n>>>30|(o&1)<<2)&7,i[a++]=o>>>1&7,i[a++]=o>>>4&7,i[a++]=o>>>7&7,i[a++]=o>>>10&7,i[a++]=o>>>13&7,i[a++]=o>>>16&7,i[a++]=o>>>19&7,i[a++]=o>>>22&7,i[a++]=o>>>25&7,i[a++]=o>>>28&7,i[a++]=(o>>>31|(s&3)<<1)&7,i[a++]=s>>>2&7,i[a++]=s>>>5&7,i[a++]=s>>>8&7,i[a++]=s>>>11&7,i[a++]=s>>>14&7,i[a++]=s>>>17&7,i[a++]=s>>>20&7,i[a++]=s>>>23&7,i[a++]=s>>>26&7,i[a]=s>>>29&7}function dA(e,t,i,r){let a=r,n=e[t]>>>0,o=e[t+1]>>>0,s=e[t+2]>>>0,l=e[t+3]>>>0;i[a++]=n>>>0&15,i[a++]=n>>>4&15,i[a++]=n>>>8&15,i[a++]=n>>>12&15,i[a++]=n>>>16&15,i[a++]=n>>>20&15,i[a++]=n>>>24&15,i[a++]=n>>>28&15,i[a++]=o>>>0&15,i[a++]=o>>>4&15,i[a++]=o>>>8&15,i[a++]=o>>>12&15,i[a++]=o>>>16&15,i[a++]=o>>>20&15,i[a++]=o>>>24&15,i[a++]=o>>>28&15,i[a++]=s>>>0&15,i[a++]=s>>>4&15,i[a++]=s>>>8&15,i[a++]=s>>>12&15,i[a++]=s>>>16&15,i[a++]=s>>>20&15,i[a++]=s>>>24&15,i[a++]=s>>>28&15,i[a++]=l>>>0&15,i[a++]=l>>>4&15,i[a++]=l>>>8&15,i[a++]=l>>>12&15,i[a++]=l>>>16&15,i[a++]=l>>>20&15,i[a++]=l>>>24&15,i[a]=l>>>28&15}function pA(e,t,i,r){let a=r,n=e[t]>>>0,o=e[t+1]>>>0,s=e[t+2]>>>0,l=e[t+3]>>>0,u=e[t+4]>>>0;i[a++]=n>>>0&31,i[a++]=n>>>5&31,i[a++]=n>>>10&31,i[a++]=n>>>15&31,i[a++]=n>>>20&31,i[a++]=n>>>25&31,i[a++]=(n>>>30|(o&7)<<2)&31,i[a++]=o>>>3&31,i[a++]=o>>>8&31,i[a++]=o>>>13&31,i[a++]=o>>>18&31,i[a++]=o>>>23&31,i[a++]=(o>>>28|(s&1)<<4)&31,i[a++]=s>>>1&31,i[a++]=s>>>6&31,i[a++]=s>>>11&31,i[a++]=s>>>16&31,i[a++]=s>>>21&31,i[a++]=s>>>26&31,i[a++]=(s>>>31|(l&15)<<1)&31,i[a++]=l>>>4&31,i[a++]=l>>>9&31,i[a++]=l>>>14&31,i[a++]=l>>>19&31,i[a++]=l>>>24&31,i[a++]=(l>>>29|(u&3)<<3)&31,i[a++]=u>>>2&31,i[a++]=u>>>7&31,i[a++]=u>>>12&31,i[a++]=u>>>17&31,i[a++]=u>>>22&31,i[a]=u>>>27&31}function fA(e,t,i,r){let a=r,n=e[t]>>>0,o=e[t+1]>>>0,s=e[t+2]>>>0,l=e[t+3]>>>0,u=e[t+4]>>>0,h=e[t+5]>>>0;i[a++]=n>>>0&63,i[a++]=n>>>6&63,i[a++]=n>>>12&63,i[a++]=n>>>18&63,i[a++]=n>>>24&63,i[a++]=(n>>>30|(o&15)<<2)&63,i[a++]=o>>>4&63,i[a++]=o>>>10&63,i[a++]=o>>>16&63,i[a++]=o>>>22&63,i[a++]=(o>>>28|(s&3)<<4)&63,i[a++]=s>>>2&63,i[a++]=s>>>8&63,i[a++]=s>>>14&63,i[a++]=s>>>20&63,i[a++]=s>>>26&63,i[a++]=l>>>0&63,i[a++]=l>>>6&63,i[a++]=l>>>12&63,i[a++]=l>>>18&63,i[a++]=l>>>24&63,i[a++]=(l>>>30|(u&15)<<2)&63,i[a++]=u>>>4&63,i[a++]=u>>>10&63,i[a++]=u>>>16&63,i[a++]=u>>>22&63,i[a++]=(u>>>28|(h&3)<<4)&63,i[a++]=h>>>2&63,i[a++]=h>>>8&63,i[a++]=h>>>14&63,i[a++]=h>>>20&63,i[a]=h>>>26&63}function mA(e,t,i,r){let a=r,n=e[t]>>>0,o=e[t+1]>>>0,s=e[t+2]>>>0,l=e[t+3]>>>0,u=e[t+4]>>>0,h=e[t+5]>>>0,c=e[t+6]>>>0;i[a++]=n>>>0&127,i[a++]=n>>>7&127,i[a++]=n>>>14&127,i[a++]=n>>>21&127,i[a++]=(n>>>28|(o&7)<<4)&127,i[a++]=o>>>3&127,i[a++]=o>>>10&127,i[a++]=o>>>17&127,i[a++]=o>>>24&127,i[a++]=(o>>>31|(s&63)<<1)&127,i[a++]=s>>>6&127,i[a++]=s>>>13&127,i[a++]=s>>>20&127,i[a++]=(s>>>27|(l&3)<<5)&127,i[a++]=l>>>2&127,i[a++]=l>>>9&127,i[a++]=l>>>16&127,i[a++]=l>>>23&127,i[a++]=(l>>>30|(u&31)<<2)&127,i[a++]=u>>>5&127,i[a++]=u>>>12&127,i[a++]=u>>>19&127,i[a++]=(u>>>26|(h&1)<<6)&127,i[a++]=h>>>1&127,i[a++]=h>>>8&127,i[a++]=h>>>15&127,i[a++]=h>>>22&127,i[a++]=(h>>>29|(c&15)<<3)&127,i[a++]=c>>>4&127,i[a++]=c>>>11&127,i[a++]=c>>>18&127,i[a]=c>>>25&127}function gA(e,t,i,r){let a=r,n=e[t]>>>0,o=e[t+1]>>>0,s=e[t+2]>>>0,l=e[t+3]>>>0,u=e[t+4]>>>0,h=e[t+5]>>>0,c=e[t+6]>>>0,d=e[t+7]>>>0;i[a++]=n>>>0&255,i[a++]=n>>>8&255,i[a++]=n>>>16&255,i[a++]=n>>>24&255,i[a++]=o>>>0&255,i[a++]=o>>>8&255,i[a++]=o>>>16&255,i[a++]=o>>>24&255,i[a++]=s>>>0&255,i[a++]=s>>>8&255,i[a++]=s>>>16&255,i[a++]=s>>>24&255,i[a++]=l>>>0&255,i[a++]=l>>>8&255,i[a++]=l>>>16&255,i[a++]=l>>>24&255,i[a++]=u>>>0&255,i[a++]=u>>>8&255,i[a++]=u>>>16&255,i[a++]=u>>>24&255,i[a++]=h>>>0&255,i[a++]=h>>>8&255,i[a++]=h>>>16&255,i[a++]=h>>>24&255,i[a++]=c>>>0&255,i[a++]=c>>>8&255,i[a++]=c>>>16&255,i[a++]=c>>>24&255,i[a++]=d>>>0&255,i[a++]=d>>>8&255,i[a++]=d>>>16&255,i[a]=d>>>24&255}function _A(e,t,i,r){let a=r,n=e[t]>>>0,o=e[t+1]>>>0,s=e[t+2]>>>0,l=e[t+3]>>>0,u=e[t+4]>>>0,h=e[t+5]>>>0,c=e[t+6]>>>0,d=e[t+7]>>>0,p=e[t+8]>>>0;i[a++]=n>>>0&511,i[a++]=n>>>9&511,i[a++]=n>>>18&511,i[a++]=(n>>>27|(o&15)<<5)&511,i[a++]=o>>>4&511,i[a++]=o>>>13&511,i[a++]=o>>>22&511,i[a++]=(o>>>31|(s&255)<<1)&511,i[a++]=s>>>8&511,i[a++]=s>>>17&511,i[a++]=(s>>>26|(l&7)<<6)&511,i[a++]=l>>>3&511,i[a++]=l>>>12&511,i[a++]=l>>>21&511,i[a++]=(l>>>30|(u&127)<<2)&511,i[a++]=u>>>7&511,i[a++]=u>>>16&511,i[a++]=(u>>>25|(h&3)<<7)&511,i[a++]=h>>>2&511,i[a++]=h>>>11&511,i[a++]=h>>>20&511,i[a++]=(h>>>29|(c&63)<<3)&511,i[a++]=c>>>6&511,i[a++]=c>>>15&511,i[a++]=(c>>>24|(d&1)<<8)&511,i[a++]=d>>>1&511,i[a++]=d>>>10&511,i[a++]=d>>>19&511,i[a++]=(d>>>28|(p&31)<<4)&511,i[a++]=p>>>5&511,i[a++]=p>>>14&511,i[a]=p>>>23&511}function yA(e,t,i,r){let a=r,n=e[t]>>>0,o=e[t+1]>>>0,s=e[t+2]>>>0,l=e[t+3]>>>0,u=e[t+4]>>>0,h=e[t+5]>>>0,c=e[t+6]>>>0,d=e[t+7]>>>0,p=e[t+8]>>>0,f=e[t+9]>>>0;i[a++]=n>>>0&1023,i[a++]=n>>>10&1023,i[a++]=n>>>20&1023,i[a++]=(n>>>30|(o&255)<<2)&1023,i[a++]=o>>>8&1023,i[a++]=o>>>18&1023,i[a++]=(o>>>28|(s&63)<<4)&1023,i[a++]=s>>>6&1023,i[a++]=s>>>16&1023,i[a++]=(s>>>26|(l&15)<<6)&1023,i[a++]=l>>>4&1023,i[a++]=l>>>14&1023,i[a++]=(l>>>24|(u&3)<<8)&1023,i[a++]=u>>>2&1023,i[a++]=u>>>12&1023,i[a++]=u>>>22&1023,i[a++]=h>>>0&1023,i[a++]=h>>>10&1023,i[a++]=h>>>20&1023,i[a++]=(h>>>30|(c&255)<<2)&1023,i[a++]=c>>>8&1023,i[a++]=c>>>18&1023,i[a++]=(c>>>28|(d&63)<<4)&1023,i[a++]=d>>>6&1023,i[a++]=d>>>16&1023,i[a++]=(d>>>26|(p&15)<<6)&1023,i[a++]=p>>>4&1023,i[a++]=p>>>14&1023,i[a++]=(p>>>24|(f&3)<<8)&1023,i[a++]=f>>>2&1023,i[a++]=f>>>12&1023,i[a]=f>>>22&1023}function vA(e,t,i,r){let a=r,n=e[t]>>>0,o=e[t+1]>>>0,s=e[t+2]>>>0,l=e[t+3]>>>0,u=e[t+4]>>>0,h=e[t+5]>>>0,c=e[t+6]>>>0,d=e[t+7]>>>0,p=e[t+8]>>>0,f=e[t+9]>>>0,m=e[t+10]>>>0;i[a++]=n>>>0&2047,i[a++]=n>>>11&2047,i[a++]=(n>>>22|(o&1)<<10)&2047,i[a++]=o>>>1&2047,i[a++]=o>>>12&2047,i[a++]=(o>>>23|(s&3)<<9)&2047,i[a++]=s>>>2&2047,i[a++]=s>>>13&2047,i[a++]=(s>>>24|(l&7)<<8)&2047,i[a++]=l>>>3&2047,i[a++]=l>>>14&2047,i[a++]=(l>>>25|(u&15)<<7)&2047,i[a++]=u>>>4&2047,i[a++]=u>>>15&2047,i[a++]=(u>>>26|(h&31)<<6)&2047,i[a++]=h>>>5&2047,i[a++]=h>>>16&2047,i[a++]=(h>>>27|(c&63)<<5)&2047,i[a++]=c>>>6&2047,i[a++]=c>>>17&2047,i[a++]=(c>>>28|(d&127)<<4)&2047,i[a++]=d>>>7&2047,i[a++]=d>>>18&2047,i[a++]=(d>>>29|(p&255)<<3)&2047,i[a++]=p>>>8&2047,i[a++]=p>>>19&2047,i[a++]=(p>>>30|(f&511)<<2)&2047,i[a++]=f>>>9&2047,i[a++]=f>>>20&2047,i[a++]=(f>>>31|(m&1023)<<1)&2047,i[a++]=m>>>10&2047,i[a]=m>>>21&2047}function xA(e,t,i,r){let a=r,n=e[t]>>>0,o=e[t+1]>>>0,s=e[t+2]>>>0,l=e[t+3]>>>0,u=e[t+4]>>>0,h=e[t+5]>>>0,c=e[t+6]>>>0,d=e[t+7]>>>0,p=e[t+8]>>>0,f=e[t+9]>>>0,m=e[t+10]>>>0,g=e[t+11]>>>0;i[a++]=n>>>0&4095,i[a++]=n>>>12&4095,i[a++]=(n>>>24|(o&15)<<8)&4095,i[a++]=o>>>4&4095,i[a++]=o>>>16&4095,i[a++]=(o>>>28|(s&255)<<4)&4095,i[a++]=s>>>8&4095,i[a++]=s>>>20&4095,i[a++]=l>>>0&4095,i[a++]=l>>>12&4095,i[a++]=(l>>>24|(u&15)<<8)&4095,i[a++]=u>>>4&4095,i[a++]=u>>>16&4095,i[a++]=(u>>>28|(h&255)<<4)&4095,i[a++]=h>>>8&4095,i[a++]=h>>>20&4095,i[a++]=c>>>0&4095,i[a++]=c>>>12&4095,i[a++]=(c>>>24|(d&15)<<8)&4095,i[a++]=d>>>4&4095,i[a++]=d>>>16&4095,i[a++]=(d>>>28|(p&255)<<4)&4095,i[a++]=p>>>8&4095,i[a++]=p>>>20&4095,i[a++]=f>>>0&4095,i[a++]=f>>>12&4095,i[a++]=(f>>>24|(m&15)<<8)&4095,i[a++]=m>>>4&4095,i[a++]=m>>>16&4095,i[a++]=(m>>>28|(g&255)<<4)&4095,i[a++]=g>>>8&4095,i[a]=g>>>20&4095}function bA(e,t,i,r){let a=r,n=e[t]>>>0,o=e[t+1]>>>0,s=e[t+2]>>>0,l=e[t+3]>>>0,u=e[t+4]>>>0,h=e[t+5]>>>0,c=e[t+6]>>>0,d=e[t+7]>>>0,p=e[t+8]>>>0,f=e[t+9]>>>0,m=e[t+10]>>>0,g=e[t+11]>>>0,_=e[t+12]>>>0,y=e[t+13]>>>0,v=e[t+14]>>>0,x=e[t+15]>>>0;i[a++]=n>>>0&65535,i[a++]=n>>>16&65535,i[a++]=o>>>0&65535,i[a++]=o>>>16&65535,i[a++]=s>>>0&65535,i[a++]=s>>>16&65535,i[a++]=l>>>0&65535,i[a++]=l>>>16&65535,i[a++]=u>>>0&65535,i[a++]=u>>>16&65535,i[a++]=h>>>0&65535,i[a++]=h>>>16&65535,i[a++]=c>>>0&65535,i[a++]=c>>>16&65535,i[a++]=d>>>0&65535,i[a++]=d>>>16&65535,i[a++]=p>>>0&65535,i[a++]=p>>>16&65535,i[a++]=f>>>0&65535,i[a++]=f>>>16&65535,i[a++]=m>>>0&65535,i[a++]=m>>>16&65535,i[a++]=g>>>0&65535,i[a++]=g>>>16&65535,i[a++]=_>>>0&65535,i[a++]=_>>>16&65535,i[a++]=y>>>0&65535,i[a++]=y>>>16&65535,i[a++]=v>>>0&65535,i[a++]=v>>>16&65535,i[a++]=x>>>0&65535,i[a]=x>>>16&65535}function wA(e,t,i,r){let a=r,n=t;for(let o=0;o<8;o++){let s=e[n++]>>>0;i[a++]=s>>>0&1,i[a++]=s>>>1&1,i[a++]=s>>>2&1,i[a++]=s>>>3&1,i[a++]=s>>>4&1,i[a++]=s>>>5&1,i[a++]=s>>>6&1,i[a++]=s>>>7&1,i[a++]=s>>>8&1,i[a++]=s>>>9&1,i[a++]=s>>>10&1,i[a++]=s>>>11&1,i[a++]=s>>>12&1,i[a++]=s>>>13&1,i[a++]=s>>>14&1,i[a++]=s>>>15&1,i[a++]=s>>>16&1,i[a++]=s>>>17&1,i[a++]=s>>>18&1,i[a++]=s>>>19&1,i[a++]=s>>>20&1,i[a++]=s>>>21&1,i[a++]=s>>>22&1,i[a++]=s>>>23&1,i[a++]=s>>>24&1,i[a++]=s>>>25&1,i[a++]=s>>>26&1,i[a++]=s>>>27&1,i[a++]=s>>>28&1,i[a++]=s>>>29&1,i[a++]=s>>>30&1,i[a++]=s>>>31&1}}function TA(e,t,i,r){let a=r,n=t;for(let o=0;o<8;o++){let s=e[n++]>>>0,l=e[n++]>>>0;i[a++]=s>>>0&3,i[a++]=s>>>2&3,i[a++]=s>>>4&3,i[a++]=s>>>6&3,i[a++]=s>>>8&3,i[a++]=s>>>10&3,i[a++]=s>>>12&3,i[a++]=s>>>14&3,i[a++]=s>>>16&3,i[a++]=s>>>18&3,i[a++]=s>>>20&3,i[a++]=s>>>22&3,i[a++]=s>>>24&3,i[a++]=s>>>26&3,i[a++]=s>>>28&3,i[a++]=s>>>30&3,i[a++]=l>>>0&3,i[a++]=l>>>2&3,i[a++]=l>>>4&3,i[a++]=l>>>6&3,i[a++]=l>>>8&3,i[a++]=l>>>10&3,i[a++]=l>>>12&3,i[a++]=l>>>14&3,i[a++]=l>>>16&3,i[a++]=l>>>18&3,i[a++]=l>>>20&3,i[a++]=l>>>22&3,i[a++]=l>>>24&3,i[a++]=l>>>26&3,i[a++]=l>>>28&3,i[a++]=l>>>30&3}}function EA(e,t,i,r){let a=r,n=t;for(let o=0;o<8;o++){let s=e[n++]>>>0,l=e[n++]>>>0,u=e[n++]>>>0;i[a++]=s>>>0&7,i[a++]=s>>>3&7,i[a++]=s>>>6&7,i[a++]=s>>>9&7,i[a++]=s>>>12&7,i[a++]=s>>>15&7,i[a++]=s>>>18&7,i[a++]=s>>>21&7,i[a++]=s>>>24&7,i[a++]=s>>>27&7,i[a++]=(s>>>30|(l&1)<<2)&7,i[a++]=l>>>1&7,i[a++]=l>>>4&7,i[a++]=l>>>7&7,i[a++]=l>>>10&7,i[a++]=l>>>13&7,i[a++]=l>>>16&7,i[a++]=l>>>19&7,i[a++]=l>>>22&7,i[a++]=l>>>25&7,i[a++]=l>>>28&7,i[a++]=(l>>>31|(u&3)<<1)&7,i[a++]=u>>>2&7,i[a++]=u>>>5&7,i[a++]=u>>>8&7,i[a++]=u>>>11&7,i[a++]=u>>>14&7,i[a++]=u>>>17&7,i[a++]=u>>>20&7,i[a++]=u>>>23&7,i[a++]=u>>>26&7,i[a++]=u>>>29&7}}function DA(e,t,i,r){let a=r,n=t;for(let o=0;o<8;o++){let s=e[n++]>>>0,l=e[n++]>>>0,u=e[n++]>>>0,h=e[n++]>>>0;i[a++]=s>>>0&15,i[a++]=s>>>4&15,i[a++]=s>>>8&15,i[a++]=s>>>12&15,i[a++]=s>>>16&15,i[a++]=s>>>20&15,i[a++]=s>>>24&15,i[a++]=s>>>28&15,i[a++]=l>>>0&15,i[a++]=l>>>4&15,i[a++]=l>>>8&15,i[a++]=l>>>12&15,i[a++]=l>>>16&15,i[a++]=l>>>20&15,i[a++]=l>>>24&15,i[a++]=l>>>28&15,i[a++]=u>>>0&15,i[a++]=u>>>4&15,i[a++]=u>>>8&15,i[a++]=u>>>12&15,i[a++]=u>>>16&15,i[a++]=u>>>20&15,i[a++]=u>>>24&15,i[a++]=u>>>28&15,i[a++]=h>>>0&15,i[a++]=h>>>4&15,i[a++]=h>>>8&15,i[a++]=h>>>12&15,i[a++]=h>>>16&15,i[a++]=h>>>20&15,i[a++]=h>>>24&15,i[a++]=h>>>28&15}}function SA(e,t,i,r){let a=r,n=t;for(let o=0;o<8;o++){let s=e[n++]>>>0,l=e[n++]>>>0,u=e[n++]>>>0,h=e[n++]>>>0,c=e[n++]>>>0;i[a++]=s>>>0&31,i[a++]=s>>>5&31,i[a++]=s>>>10&31,i[a++]=s>>>15&31,i[a++]=s>>>20&31,i[a++]=s>>>25&31,i[a++]=(s>>>30|(l&7)<<2)&31,i[a++]=l>>>3&31,i[a++]=l>>>8&31,i[a++]=l>>>13&31,i[a++]=l>>>18&31,i[a++]=l>>>23&31,i[a++]=(l>>>28|(u&1)<<4)&31,i[a++]=u>>>1&31,i[a++]=u>>>6&31,i[a++]=u>>>11&31,i[a++]=u>>>16&31,i[a++]=u>>>21&31,i[a++]=u>>>26&31,i[a++]=(u>>>31|(h&15)<<1)&31,i[a++]=h>>>4&31,i[a++]=h>>>9&31,i[a++]=h>>>14&31,i[a++]=h>>>19&31,i[a++]=h>>>24&31,i[a++]=(h>>>29|(c&3)<<3)&31,i[a++]=c>>>2&31,i[a++]=c>>>7&31,i[a++]=c>>>12&31,i[a++]=c>>>17&31,i[a++]=c>>>22&31,i[a++]=c>>>27&31}}function CA(e,t,i,r){let a=r,n=t;for(let o=0;o<8;o++){let s=e[n++]>>>0,l=e[n++]>>>0,u=e[n++]>>>0,h=e[n++]>>>0,c=e[n++]>>>0,d=e[n++]>>>0;i[a++]=s>>>0&63,i[a++]=s>>>6&63,i[a++]=s>>>12&63,i[a++]=s>>>18&63,i[a++]=s>>>24&63,i[a++]=(s>>>30|(l&15)<<2)&63,i[a++]=l>>>4&63,i[a++]=l>>>10&63,i[a++]=l>>>16&63,i[a++]=l>>>22&63,i[a++]=(l>>>28|(u&3)<<4)&63,i[a++]=u>>>2&63,i[a++]=u>>>8&63,i[a++]=u>>>14&63,i[a++]=u>>>20&63,i[a++]=u>>>26&63,i[a++]=h>>>0&63,i[a++]=h>>>6&63,i[a++]=h>>>12&63,i[a++]=h>>>18&63,i[a++]=h>>>24&63,i[a++]=(h>>>30|(c&15)<<2)&63,i[a++]=c>>>4&63,i[a++]=c>>>10&63,i[a++]=c>>>16&63,i[a++]=c>>>22&63,i[a++]=(c>>>28|(d&3)<<4)&63,i[a++]=d>>>2&63,i[a++]=d>>>8&63,i[a++]=d>>>14&63,i[a++]=d>>>20&63,i[a++]=d>>>26&63}}function PA(e,t,i,r){let a=r,n=t;for(let o=0;o<8;o++){let s=e[n++]>>>0,l=e[n++]>>>0,u=e[n++]>>>0,h=e[n++]>>>0,c=e[n++]>>>0,d=e[n++]>>>0,p=e[n++]>>>0;i[a++]=s>>>0&127,i[a++]=s>>>7&127,i[a++]=s>>>14&127,i[a++]=s>>>21&127,i[a++]=(s>>>28|(l&7)<<4)&127,i[a++]=l>>>3&127,i[a++]=l>>>10&127,i[a++]=l>>>17&127,i[a++]=l>>>24&127,i[a++]=(l>>>31|(u&63)<<1)&127,i[a++]=u>>>6&127,i[a++]=u>>>13&127,i[a++]=u>>>20&127,i[a++]=(u>>>27|(h&3)<<5)&127,i[a++]=h>>>2&127,i[a++]=h>>>9&127,i[a++]=h>>>16&127,i[a++]=h>>>23&127,i[a++]=(h>>>30|(c&31)<<2)&127,i[a++]=c>>>5&127,i[a++]=c>>>12&127,i[a++]=c>>>19&127,i[a++]=(c>>>26|(d&1)<<6)&127,i[a++]=d>>>1&127,i[a++]=d>>>8&127,i[a++]=d>>>15&127,i[a++]=d>>>22&127,i[a++]=(d>>>29|(p&15)<<3)&127,i[a++]=p>>>4&127,i[a++]=p>>>11&127,i[a++]=p>>>18&127,i[a++]=p>>>25&127}}function AA(e,t,i,r){let a=r,n=t;for(let o=0;o<8;o++){let s=e[n++]>>>0,l=e[n++]>>>0,u=e[n++]>>>0,h=e[n++]>>>0,c=e[n++]>>>0,d=e[n++]>>>0,p=e[n++]>>>0,f=e[n++]>>>0;i[a++]=s>>>0&255,i[a++]=s>>>8&255,i[a++]=s>>>16&255,i[a++]=s>>>24&255,i[a++]=l>>>0&255,i[a++]=l>>>8&255,i[a++]=l>>>16&255,i[a++]=l>>>24&255,i[a++]=u>>>0&255,i[a++]=u>>>8&255,i[a++]=u>>>16&255,i[a++]=u>>>24&255,i[a++]=h>>>0&255,i[a++]=h>>>8&255,i[a++]=h>>>16&255,i[a++]=h>>>24&255,i[a++]=c>>>0&255,i[a++]=c>>>8&255,i[a++]=c>>>16&255,i[a++]=c>>>24&255,i[a++]=d>>>0&255,i[a++]=d>>>8&255,i[a++]=d>>>16&255,i[a++]=d>>>24&255,i[a++]=p>>>0&255,i[a++]=p>>>8&255,i[a++]=p>>>16&255,i[a++]=p>>>24&255,i[a++]=f>>>0&255,i[a++]=f>>>8&255,i[a++]=f>>>16&255,i[a++]=f>>>24&255}}function IA(e,t,i,r){let a=r,n=t;for(let o=0;o<128;o++){let s=e[n++]>>>0;i[a++]=s&65535,i[a++]=s>>>16&65535}}function MA(e,t,i,r,a){let n=Wc[a]>>>0,o=t,s=0,l=e[o]>>>0,u=r;for(let h=0;h<8;h++){for(let c=0;c<32;c++)if(s+a<=32){let d=l>>>s&n;i[u+c]=d|0,s+=a,s===32&&(s=0,o++,c!==31&&(l=e[o]>>>0))}else{let d=32-s,p=l>>>s;o++,l=e[o]>>>0;let f=a-d,m=-1>>>32-f>>>0,g=(p|(l&m)<<d)&n;i[u+c]=g|0,s=f}u+=32,s=0,h<7&&(l=e[o]>>>0)}}var Hc=uv(dp),FA=3*Hc/256+Hc|0;function hv(){let e=new Uint8Array(FA);return{dataToBePacked:Array(33),dataPointers:new Int32Array(33),byteContainer:e,byteContainerI32:new Int32Array(e.buffer,e.byteOffset,e.byteLength>>>2),exceptionSizes:new Int32Array(33)}}function zA(e=16){if(e<0)throw RangeError(`initialEncodedWordCapacity must be >= 0, got ${e}`);let t=Math.max(16,e|0);return{encodedWords:new Uint32Array(t),decoderWorkspace:hv()}}function RA(e,t){if(t<=e.encodedWords.length)return e.encodedWords;let i=new Uint32Array(Math.max(16,t*2));return e.encodedWords=i,i}function kA(e,t,i,r){r.byteContainer.length<i&&(r.byteContainer=new Uint8Array(i*2),r.byteContainerI32=void 0);let a=r.byteContainer,n=i>>>2;if(a.byteOffset&3)for(let s=0;s<n;s=s+1|0){let l=e[t+s|0]|0,u=s<<2;a[u]=l&255,a[u+1|0]=l>>>8&255,a[u+2|0]=l>>>16&255,a[u+3|0]=l>>>24&255}else{let s=r.byteContainerI32;(!s||s.buffer!==a.buffer||s.byteOffset!==a.byteOffset||s.length<n)&&(s=r.byteContainerI32=new Int32Array(a.buffer,a.byteOffset,a.byteLength>>>2)),s.set(e.subarray(t,t+n))}let o=i&3;if(o>0){let s=e[t+n|0]|0,l=n<<2;for(let u=0;u<o;u=u+1|0)a[l+u|0]=s>>>(u<<3)&255}return a}function LA(e,t,i){let r=e[t++]|0,a=i.dataToBePacked;for(let n=2;n<=32;n=n+1|0){if(!(r>>>n-1&1))continue;if(t>=e.length)throw Error(`FastPFOR decode: truncated exception stream header (bitWidth=${n}, streamWordIndex=${t}, needWords=1, availableWords=${e.length-t}, encodedWords=${e.length})`);let o=e[t++]>>>0,s=lA(o),l=o*n+31>>>5;if(t+l>e.length)throw Error(`FastPFOR decode: truncated exception stream (bitWidth=${n}, size=${o}, streamWordIndex=${t}, needWords=${l}, availableWords=${e.length-t}, encodedWords=${e.length})`);let u=a[n];(!u||u.length<s)&&(u=a[n]=new Uint32Array(s));let h=0;for(;h<o;h=h+32|0)qA(e,t,u,h,n),t=t+n|0;let c=h-o|0;t=t-(c*n>>>5)|0,i.exceptionSizes[n]=o}return t}function BA(e,t,i,r,a){switch(a){case 1:wA(e,t,i,r);break;case 2:TA(e,t,i,r);break;case 3:EA(e,t,i,r);break;case 4:DA(e,t,i,r);break;case 5:SA(e,t,i,r);break;case 6:CA(e,t,i,r);break;case 7:PA(e,t,i,r);break;case 8:AA(e,t,i,r);break;case 16:IA(e,t,i,r);break;default:MA(e,t,i,r,a)}return t+(a<<3)|0}function OA(e,t,i,r){if(i+2>t)throw Error(`FastPFOR decode: byteContainer underflow at block=${r} (need 2 bytes for [bitWidth, exceptionCount], bytePos=${i}, byteSize=${t})`);let a=e[i++],n=e[i++];if(a>32)throw Error(`FastPFOR decode: invalid bitWidth=${a} at block=${r} (expected 0..32). This likely indicates corrupted or truncated input.`);return{bitWidth:a,exceptionCount:n,bytePosIn:i}}function jA(e,t,i,r,a,n){if(i+1>t)throw Error(`FastPFOR decode: exception header underflow at block=${n} (need 1 byte for maxBits, bytePos=${i}, byteSize=${t})`);let o=e[i++];if(o<r||o>32)throw Error(`FastPFOR decode: invalid maxBits=${o} at block=${n} (bitWidth=${r}, expected ${r}..32)`);let s=o-r|0;if(s<1||s>32)throw Error(`FastPFOR decode: invalid exceptionBitWidth=${s} at block=${n} (bitWidth=${r}, maxBits=${o})`);if(i+a>t)throw Error(`FastPFOR decode: exception positions underflow at block=${n} (need=${a}, have=${t-i})`);return{maxBits:o,exceptionBitWidth:s,bytePosIn:i}}function VA(e,t,i,r,a,n,o,s,l){let{maxBits:u,exceptionBitWidth:h,bytePosIn:c}=jA(a,n,o,i,r,l);if(o=c,h===1){let g=1<<i;for(let _=0;_<r;_=_+1|0){let y=a[o++];e[y+t|0]|=g}return o}let d=s.dataToBePacked[h];if(!d)throw Error(`FastPFOR decode: missing exception stream for exceptionBitWidth=${h} (bitWidth=${i}, maxBits=${u}) at block ${l}`);let p=s.dataPointers,f=p[h]|0,m=s.exceptionSizes[h]|0;if(f+r>m)throw Error(`FastPFOR decode: exception stream overflow for exceptionBitWidth=${h} (ptr=${f}, need ${r}, size=${m}) at block ${l}`);for(let g=0;g<r;g=g+1|0){let _=a[o++],y=d[f++]|0;e[_+t|0]|=y<<i}return p[h]=f,o}function NA(e,t,i,r,a,n,o,s,l,u){let h=i|0,c=0;for(let d=0;d<o;d=d+1|0){let p=OA(s,l,c,d);c=p.bytePosIn;let f=p.bitWidth,m=p.exceptionCount,g=n+d*256|0;switch(f){case 0:a.fill(0,g,g+256);break;case 32:for(let _=0;_<256;_=_+1|0)a[g+_|0]=e[h+_|0]|0;h=h+256|0;break;default:h=BA(e,h,a,g,f)}m>0&&(c=VA(a,g,f,m,s,l,c,u,d))}if(h!==r)throw Error(`FastPFOR decode: packed region mismatch (pageStart=${t}, packedStart=${i}, consumedPackedEnd=${h}, expectedPackedEnd=${r}, packedWords=${r-i}, encoded.length=${e.length})`)}function UA(e,t,i,r,a,n){let o=i|0,s=e[o]|0;if(s<=0||o+s>e.length-1)throw Error(`FastPFOR decode: invalid whereMeta=${s} at pageStart=${o} (expected > 0 and pageStart+whereMeta < encoded.length=${e.length})`);let l=o+1|0,u=o+s|0,h=e[u]>>>0,c=h+3>>>2,d=u+1,p=d+c;if(p>=e.length)throw Error(`FastPFOR decode: invalid byteSize=${h} (metaInts=${c}, pageStart=${o}, packedEnd=${u}, byteContainerStart=${d}) causes bitmapPos=${p} out of bounds (encoded.length=${e.length})`);let f=kA(e,d,h,n),m=h,g=LA(e,p,n);return n.dataPointers.fill(0),NA(e,o,l,u,t,r|0,a/256|0,f,m,n),g}function $A(e,t,i,r,a,n){let o=r+pp(a,256),s=r,l=i;for(;s!==o;){let u=Math.min(Hc,o-s);l=UA(e,t,l,s,u,n),s=s+u|0}return l}function GA(e,t,i,r,a,n){if(n===0)return t;let o=0,s=t,l=t+i,u=a,h=a,c=a+n,d=0,p=0;for(;s<l&&h<c;){let f=e[s]>>>o&255;if(o+=8,s+=o>>>5,o&=31,d|=(f&127)<<p,f&128)r[h++]=d|0,d=0,p=0;else if(p+=7,p>28)throw Error(`FastPFOR VByte: unterminated value (expected MSB=1 terminator within 5 bytes; shift=${p}, partial=${d}, decoded=${h-u}/${n}, inPos=${s}, inEnd=${l})`)}if(h!==c)throw Error(`FastPFOR VByte: truncated stream (decoded=${h-u}, expected=${n}, consumedWords=${s-t}/${i}, vbyteStart=${t}, vbyteEnd=${l})`);return s}function ZA(e,t,i){let r=0,a=0,n=new Uint32Array(t),o=i??hv();if(e.length>0){let u=e[r]|0;if(r=r+1|0,u&255)throw Error(`FastPFOR decode: invalid alignedLength=${u} (expected multiple of 256)`);if(a+u>n.length)throw Error(`FastPFOR decode: output buffer too small (outPos=${a}, alignedLength=${u}, out.length=${n.length})`);r=$A(e,n,r,a,u,o),a=a+u|0}let s=e.length-r|0,l=t-a|0;return GA(e,r,s,n,a,l),n}function qA(e,t,i,r,a){switch(a){case 2:hA(e,t,i,r);return;case 3:cA(e,t,i,r);return;case 4:dA(e,t,i,r);return;case 5:pA(e,t,i,r);return;case 6:fA(e,t,i,r);return;case 7:mA(e,t,i,r);return;case 8:gA(e,t,i,r);return;case 9:_A(e,t,i,r);return;case 10:yA(e,t,i,r);return;case 11:vA(e,t,i,r);return;case 12:xA(e,t,i,r);return;case 16:bA(e,t,i,r);return;case 32:for(let u=0;u<32;u=u+1|0)i[r+u|0]=e[t+u|0]|0;return}let n=Wc[a]>>>0,o=t,s=0,l=e[o]>>>0;for(let u=0;u<32;u++)if(s+a<=32){let h=l>>>s&n;i[r+u]=h|0,s+=a,s===32&&(s=0,o++,u!==31&&(l=e[o]>>>0))}else{let h=32-s,c=l>>>s;o++,l=e[o]>>>0;let d=Wc[a-h]>>>0,p=(c|(l&d)<<h)&n;i[r+u]=p|0,s=a-h}}function WA(e,t,i,r){if(t<0||i<0||t+i>e.length)throw RangeError(`decodeBigEndianInt32sInto: out of bounds (offset=${t}, byteLength=${i}, bytes.length=${e.length})`);let a=Math.floor(i/4),n=i%4!=0,o=n?a+1:a;if(r.length<o)throw RangeError(`decodeBigEndianInt32sInto: out.length=${r.length} < ${o}`);if(a>0){let s=e.byteOffset+t;if(s&3)for(let l=0;l<a;l++){let u=t+l*4;r[l]=e[u]<<24|e[u+1]<<16|e[u+2]<<8|e[u+3]|0}else{let l=new Uint32Array(e.buffer,s,a);for(let u=0;u<a;u++)r[u]=uA(l[u])|0}}if(n){let s=t+a*4,l=i-a*4,u=0;for(let h=0;h<l;h++)u|=e[s+h]<<24-h*8;r[a]=u|0}return o}function Ft(e,t,i){let r=new Uint32Array(i),a=0,n=t.get();for(let o=0;o<r.length;o++){let s=e[n++],l=s&127;if(s<128){r[a++]=l;continue}if(s=e[n++],l|=(s&127)<<7,s<128){r[a++]=l;continue}if(s=e[n++],l|=(s&127)<<14,s<128){r[a++]=l;continue}if(s=e[n++],l|=(s&127)<<21,s<128){r[a++]=l;continue}s=e[n++],l|=(s&15)<<28,r[a++]=l}return t.set(n),r}function fp(e,t,i){let r=new BigUint64Array(i);for(let a=0;a<r.length;a++)r[a]=HA(e,t);return r}function HA(e,t){let i=0n,r=0,a=t.get();for(;a<e.length;){let n=e[a++];if(i|=BigInt(n&127)<<BigInt(r),!(n&128))break;if(r+=7,r>=64)throw Error("Varint too long")}return t.set(a),i}function XA(e,t,i){let r=new Float64Array(i);for(let a=0;a<i;a++)r[a]=YA(e,t);return r}function YA(e,t){let i,r;return r=e[t.get()],t.increment(),i=r&127,r<128||(r=e[t.get()],t.increment(),i|=(r&127)<<7,r<128)||(r=e[t.get()],t.increment(),i|=(r&127)<<14,r<128)||(r=e[t.get()],t.increment(),i|=(r&127)<<21,r<128)?i:(r=e[t.get()],i|=(r&15)<<28,KA(i,e,t))}function KA(e,t,i){let r,a;if(a=t[i.get()],i.increment(),r=(a&112)>>4,a<128||(a=t[i.get()],i.increment(),r|=(a&127)<<3,a<128)||(a=t[i.get()],i.increment(),r|=(a&127)<<10,a<128)||(a=t[i.get()],i.increment(),r|=(a&127)<<17,a<128)||(a=t[i.get()],i.increment(),r|=(a&127)<<24,a<128)||(a=t[i.get()],i.increment(),r|=(a&1)<<31,a<128))return r*4294967296+(e>>>0);throw Error("Expected varint not more than 10 bytes")}function JA(e,t,i,r){return QA(e,t,i,r,zA(i>>>2))}function QA(e,t,i,r,a){let n=r.get();if(i&3)throw Error(`FastPFOR: invalid encodedByteLength=${i} at offset=${n} (encodedBytes.length=${e.length}; expected a multiple of 4 bytes for an int32 big-endian word stream)`);let o=i>>>2,s=RA(a,o);WA(e,n,i,s);let l=ZA(s.subarray(0,o),t,a.decoderWorkspace);return r.add(i),l}function ve(e){return e>>>1^-(e&1)}function At(e){return e>>1n^-(e&1n)}function vr(e){return e%2==1?(e+1)/-2:e/2}function eI(e){let t=new Int32Array(e.length);for(let i=0;i<e.length;i++)t[i]=ve(e[i]);return t}function tI(e){let t=new BigInt64Array(e.length);for(let i=0;i<e.length;i++)t[i]=At(e[i]);return t}function iI(e){for(let t=0;t<e.length;t++)e[t]=vr(e[t])}function Xc(e,t,i){if(i===void 0){i=0;for(let n=0;n<t;n++)i+=e[n]}let r=new Uint32Array(i),a=0;for(let n=0;n<t;n++){let o=e[n],s=e[n+t];r.fill(s,a,a+o),a+=o}return r}function Yc(e,t,i){if(i===void 0){i=0;for(let n=0;n<t;n++)i+=Number(e[n])}let r=new BigUint64Array(i),a=0;for(let n=0;n<t;n++){let o=Number(e[n]),s=e[n+t];r.fill(s,a,a+o),a+=o}return r}function cv(e,t,i){let r=new Float64Array(i),a=0;for(let n=0;n<t;n++){let o=e[n],s=e[n+t];r.fill(s,a,a+o),a+=o}return r}function dg(e){let t=new Int32Array(e.length);t[0]=ve(e[0]);let i=e.length/4*4,r=1;if(i>=4)for(;r<i-4;r+=4){let a=e[r],n=e[r+1],o=e[r+2],s=e[r+3];t[r]=ve(a)+t[r-1],t[r+1]=ve(n)+t[r],t[r+2]=ve(o)+t[r+1],t[r+3]=ve(s)+t[r+2]}for(;r!==e.length;++r)t[r]=ve(e[r])+t[r-1];return t}function pg(e){let t=new BigInt64Array(e.length);t[0]=At(e[0]);let i=e.length/4*4,r=1;if(i>=4)for(;r<i-4;r+=4){let a=e[r],n=e[r+1],o=e[r+2],s=e[r+3];t[r]=At(a)+t[r-1],t[r+1]=At(n)+t[r],t[r+2]=At(o)+t[r+1],t[r+3]=At(s)+t[r+2]}for(;r!==t.length;++r)t[r]=At(e[r])+t[r-1];return t}function rI(e){e[0]=vr(e[0]);let t=e.length/4*4,i=1;if(t>=4)for(;i<t-4;i+=4){let r=e[i],a=e[i+1],n=e[i+2],o=e[i+3];e[i]=vr(r)+e[i-1],e[i+1]=vr(a)+e[i],e[i+2]=vr(n)+e[i+1],e[i+3]=vr(o)+e[i+2]}for(;i!==e.length;++i)e[i]=vr(e[i])+e[i-1]}function aI(e,t,i){if(i===void 0){i=0;for(let n=0;n<t;n++)i+=e[n]}let r=new Int32Array(i),a=0;for(let n=0;n<t;n++){let o=e[n],s=e[n+t];s=ve(s),r.fill(s,a,a+o),a+=o}return r}function nI(e,t,i){if(i===void 0){i=0;for(let n=0;n<t;n++)i+=Number(e[n])}let r=new BigInt64Array(i),a=0;for(let n=0;n<t;n++){let o=Number(e[n]),s=e[n+t];s=At(s),r.fill(s,a,a+o),a+=o}return r}function oI(e,t,i){let r=new Float64Array(i),a=0;for(let n=0;n<t;n++){let o=e[n],s=e[n+t];s=vr(s),r.fill(s,a,a+o),a+=o}return r}function mp(e){let t=e.length/4*4,i=1;if(t>=4)for(let r=e[0];i<t-4;i+=4)r=e[i]+=r,r=e[i+1]+=r,r=e[i+2]+=r,r=e[i+3]+=r;for(;i!==e.length;)e[i]+=e[i-1],++i}function sI(e){let t=0;for(let i=0;i<e.length;i++)e[i]+=t,t=e[i]}function lI(e){if(e.length<2)return new Int32Array(e);let t=new Int32Array(e.length);t[0]=ve(e[0]),t[1]=ve(e[1]);let i=e.length/4*4,r=2;if(i>=4)for(;r<i-4;r+=4){let a=e[r],n=e[r+1],o=e[r+2],s=e[r+3];t[r]=ve(a)+t[r-2],t[r+1]=ve(n)+t[r-1],t[r+2]=ve(o)+t[r],t[r+3]=ve(s)+t[r+1]}for(;r!==e.length;r+=2)t[r]=ve(e[r])+t[r-2],t[r+1]=ve(e[r+1])+t[r-1];return t}function dv(e,t,i,r){if(e.length<2)return new Int32Array(e);let a=new Int32Array(e.length),n=ve(e[0]),o=ve(e[1]);a[0]=gr(Math.round(n*t),i,r),a[1]=gr(Math.round(o*t),i,r);let s=e.length/16,l=2;if(s>=4)for(;l<s-4;l+=4){let u=e[l],h=e[l+1],c=ve(u)+n,d=ve(h)+o;a[l]=gr(Math.round(c*t),i,r),a[l+1]=gr(Math.round(d*t),i,r);let p=e[l+2],f=e[l+3];n=ve(p)+c,o=ve(f)+d,a[l+2]=gr(Math.round(n*t),i,r),a[l+3]=gr(Math.round(o*t),i,r)}for(;l!==e.length;l+=2)n+=ve(e[l]),o+=ve(e[l+1]),a[l]=gr(Math.round(n*t),i,r),a[l+1]=gr(Math.round(o*t),i,r);return a}function gr(e,t,i){return Math.min(i,Math.max(t,e))}function uI(e){let t=new Int32Array(e.length+1);t[0]=0,t[1]=ve(e[0]);let i=t[1];for(let r=2;r!==t.length;++r){let a=e[r-1],n=ve(a);i+=n,t[r]=t[r-1]+i}return new Uint32Array(t)}function hI(e,t,i){let r=new Int32Array(i+1);r[0]=0;let a=1,n=r[0];for(let o=0;o<t;o++){let s=e[o],l=e[o+t];l=ve(l);for(let u=a;u<a+s;u++)r[u]=l+n,n=r[u];a+=s}return r}function cI(e,t,i){let r=new Uint32Array(i+1);r[0]=0;let a=1,n=r[0];for(let o=0;o<t;o++){let s=e[o],l=e[o+t];for(let u=a;u<a+s;u++)r[u]=l+n,n=r[u];a+=s}return r}function dI(e,t,i){let r=new Int32Array(i),a=0,n=0;for(let o=0;o<t;o++){let s=e[o],l=e[o+t],u=ve(l);for(let h=0;h<s;h++)n+=u,r[a++]=n}return r}function pI(e,t,i){let r=new BigInt64Array(i),a=0,n=0n;for(let o=0;o<t;o++){let s=Number(e[o]),l=e[o+t],u=At(l);for(let h=0;h<s;h++)n+=u,r[a++]=n}return r}function fg(e){let t=new Uint32Array(e.length);t[0]=ve(e[0])>>>0;for(let i=1;i<e.length;i++)t[i]=t[i-1]+ve(e[i])>>>0;return t}function mg(e){let t=new BigUint64Array(e.length);t[0]=BigInt.asUintN(64,At(e[0]));for(let i=1;i<e.length;i++)t[i]=BigInt.asUintN(64,t[i-1]+At(e[i]));return t}function fI(e){if(e.length<2)return new Uint32Array(e);let t=new Uint32Array(e.length);t[0]=ve(e[0])>>>0,t[1]=ve(e[1])>>>0;for(let i=2;i<e.length;i+=2)t[i]=t[i-2]+ve(e[i])>>>0,t[i+1]=t[i-1]+ve(e[i+1])>>>0;return t}function mI(e,t,i,r){let a=dv(e,t,i,r);return new Uint32Array(a)}function gI(e){return e[1]}function _I(e){return ve(e[1])}function yI(e){if(e.length===2){let t=ve(e[1]);return[t,t]}return[ve(e[2]),ve(e[3])]}function vI(e){return e[1]}function xI(e){return At(e[1])}function bI(e){if(e.length===2){let t=At(e[1]);return[t,t]}return[At(e[2]),At(e[3])]}var rt;(function(e){e.PRESENT="PRESENT",e.DATA="DATA",e.OFFSET="OFFSET",e.LENGTH="LENGTH"})(rt||(rt={}));var Lt;(function(e){e.NONE="NONE",e.SINGLE="SINGLE",e.SHARED="SHARED",e.VERTEX="VERTEX",e.MORTON="MORTON",e.FSST="FSST"})(Lt||(Lt={}));var $i;(function(e){e.VERTEX="VERTEX",e.INDEX="INDEX",e.STRING="STRING",e.KEY="KEY"})($i||($i={}));var ct;(function(e){e.VAR_BINARY="VAR_BINARY",e.GEOMETRIES="GEOMETRIES",e.PARTS="PARTS",e.RINGS="RINGS",e.TRIANGLES="TRIANGLES",e.SYMBOL="SYMBOL",e.DICTIONARY="DICTIONARY"})(ct||(ct={}));var wI=[rt.PRESENT,rt.DATA,rt.OFFSET,rt.LENGTH],gg=[ue.NONE,ue.DELTA,ue.COMPONENTWISE_DELTA,ue.RLE,ue.MORTON],TI=[ni.NONE,ni.FAST_PFOR,ni.VARINT],EI=[Lt.NONE,Lt.SINGLE,Lt.SHARED,Lt.VERTEX,Lt.MORTON,Lt.FSST],DI=[$i.VERTEX,$i.INDEX,$i.STRING,$i.KEY],SI=[ct.VAR_BINARY,ct.GEOMETRIES,ct.PARTS,ct.RINGS,ct.TRIANGLES,ct.SYMBOL,ct.DICTIONARY];function $e(e,t){let i=AI(e,t);return i.logicalLevelTechnique1===ue.MORTON?CI(i,e,t):(ue.RLE===i.logicalLevelTechnique1||ue.RLE===i.logicalLevelTechnique2)&&ni.NONE!==i.physicalLevelTechnique?PI(i,e,t):i}function CI(e,t,i){let r=Ft(t,i,2);return{physicalStreamType:e.physicalStreamType,logicalStreamType:e.logicalStreamType,logicalLevelTechnique1:e.logicalLevelTechnique1,logicalLevelTechnique2:e.logicalLevelTechnique2,physicalLevelTechnique:e.physicalLevelTechnique,numValues:e.numValues,byteLength:e.byteLength,decompressedCount:e.decompressedCount,numBits:r[0],coordinateShift:r[1]}}function PI(e,t,i){let r=Ft(t,i,2);return{physicalStreamType:e.physicalStreamType,logicalStreamType:e.logicalStreamType,logicalLevelTechnique1:e.logicalLevelTechnique1,logicalLevelTechnique2:e.logicalLevelTechnique2,physicalLevelTechnique:e.physicalLevelTechnique,numValues:e.numValues,byteLength:e.byteLength,decompressedCount:r[1],runs:r[0],numRleValues:r[1]}}function AI(e,t){let i=e[t.get()],r=wI[i>>4],a={};switch(r){case rt.DATA:a={dictionaryType:EI[i&15]};break;case rt.OFFSET:a={offsetType:DI[i&15]};break;case rt.LENGTH:a={lengthType:SI[i&15]}}t.increment();let n=e[t.get()],o=gg[n>>5],s=gg[n>>2&7],l=TI[n&3];t.increment();let u=Ft(e,t,2),h=u[0],c=u[1];return{physicalStreamType:r,logicalStreamType:a,logicalLevelTechnique1:o,logicalLevelTechnique2:s,physicalLevelTechnique:l,numValues:h,byteLength:c,decompressedCount:h}}var Oe;(function(e){e[e.FLAT=0]="FLAT",e[e.CONST=1]="CONST",e[e.SEQUENCE=2]="SEQUENCE",e[e.DICTIONARY=3]="DICTIONARY",e[e.FSST_DICTIONARY=4]="FSST_DICTIONARY"})(Oe||(Oe={}));var Ri=class{constructor(e,t){this.values=e,this._size=t}get(e){let t=Math.floor(e/8),i=e%8;return(this.values[t]>>i&1)==1}set(e,t){let i=Math.floor(e/8),r=e%8;this.values[i]=this.values[i]|+!!t<<r}getInt(e){let t=Math.floor(e/8),i=e%8;return this.values[t]>>i&1}size(){return this._size}getBuffer(){return this.values}};function ha(e,t,i){if(!t)return e;let r=t.size(),a=e.constructor,n=new a(r),o=0;for(let s=0;s<r;s++)n[s]=t.get(s)?e[o++]:i;return n}function II(e,t,i){if(!i)return e;let r=i.size(),a=new Ri(e,t),n=new Ri(new Uint8Array(Math.ceil(r/8)),r),o=0;for(let s=0;s<r;s++){let l=i.get(s)?a.get(o++):!1;n.set(s,l)}return n.getBuffer()}function pv(e,t,i){for(let r=0;r<e;r++){let a=$e(t,i);i.add(a.byteLength)}}function nn(e,t,i,r,a){let n=MI(e,Math.ceil(t/8),i,r);return a?II(n,t,a):n}function MI(e,t,i,r){let a=new Uint8Array(t),n=0,o=r.get()+i;for(;n<t&&!(r.get()>=o);){let s=e[r.increment()];if(s<=127){let l=s+3,u=e[r.increment()],h=Math.min(n+l,t);a.fill(u,n,h),n=h}else{let l=256-s;for(let u=0;u<l&&n<t;u++)a[n++]=e[r.increment()]}}return r.set(o),a}function fv(e,t,i,r){let a=t.get(),n=a+i*Float32Array.BYTES_PER_ELEMENT,o=new Uint8Array(e.subarray(a,n)).buffer,s=new Float32Array(o);return t.set(n),r?ha(s,r,0):s}function mv(e,t,i,r){let a=t.get(),n=a+i*Float64Array.BYTES_PER_ELEMENT,o=new Uint8Array(e.subarray(a,n)).buffer,s=new Float64Array(o);return t.set(n),r?ha(s,r,0):s}function FI(e,t,i){let r=t.get(),a=i*Uint32Array.BYTES_PER_ELEMENT,n=new DataView(e.buffer,e.byteOffset,e.byteLength),o=new Uint32Array(i);for(let s=0;s<i;s++)o[s]=n.getUint32(r+s*Uint32Array.BYTES_PER_ELEMENT,!0);return t.add(a),o}function zI(e,t,i){let r=t.get(),a=i*BigUint64Array.BYTES_PER_ELEMENT,n=new DataView(e.buffer,e.byteOffset,e.byteLength),o=new BigUint64Array(i);for(let s=0;s<i;s++)o[s]=n.getBigUint64(r+s*BigUint64Array.BYTES_PER_ELEMENT,!0);return t.add(a),o}var RI=new TextDecoder;function gp(e,t,i){return i-t>=12?RI.decode(e.subarray(t,i)):kI(e,t,i)}function kI(e,t,i){let r="",a=t;for(;a<i;){let n=e[a],o=null,s=n>239?4:n>223?3:n>191?2:1;if(a+s>i)break;let l,u,h;s===1?n<128&&(o=n):s===2?(l=e[a+1],(l&192)==128&&(o=(n&31)<<6|l&63,o<=127&&(o=null))):s===3?(l=e[a+1],u=e[a+2],(l&192)==128&&(u&192)==128&&(o=(n&15)<<12|(l&63)<<6|u&63,(o<=2047||o>=55296&&o<=57343)&&(o=null))):s===4&&(l=e[a+1],u=e[a+2],h=e[a+3],(l&192)==128&&(u&192)==128&&(h&192)==128&&(o=(n&15)<<18|(l&63)<<12|(u&63)<<6|h&63,(o<=65535||o>=1114112)&&(o=null))),o===null?(o=65533,s=1):o>65535&&(o-=65536,r+=String.fromCharCode(o>>>10&1023|55296),o=56320|o&1023),r+=String.fromCharCode(o),a+=s}return r}function yl(e,t,i,r,a){return VI(on(e,t,i),i,r,a)}function St(e,t,i,r,a){return NI(on(e,t,i),i,r,a)}function xr(e,t,i){return $I(on(e,t,i),i)}function on(e,t,i){let r=i.physicalLevelTechnique;switch(r){case ni.FAST_PFOR:return JA(e,i.numValues,i.byteLength,t);case ni.VARINT:return Ft(e,t,i.numValues);case ni.NONE:return FI(e,t,i.numValues);default:throw Error(`Specified physicalLevelTechnique ${r} is not supported (yet).`)}}function Ao(e,t,i){let r=i.physicalLevelTechnique;switch(r){case ni.VARINT:return fp(e,t,i.numValues);case ni.NONE:return zI(e,t,i.numValues);default:throw Error(`Specified physicalLevelTechnique ${r} is not supported (yet).`)}}function LI(e,t,i){let r=on(e,t,i);return r.length===1?ve(r[0]):_I(r)}function _p(e,t,i){let r=on(e,t,i);return r.length===1?i.logicalLevelTechnique1===ue.DELTA?ve(r[0]):r[0]:gI(r)}function gv(e,t,i){return yI(on(e,t,i))}function _v(e,t,i){return bI(fp(e,t,i.numValues))}function yv(e,t,i,r){return xv(Ao(e,t,i),i,r)}function yp(e,t,i,r){return bv(Ao(e,t,i),i,r)}function BI(e,t,i,r){let a=OI(e,t,i,!1);return r?ha(a,r,0):a}function OI(e,t,i,r){if(i.physicalLevelTechnique===ni.VARINT)return UI(XA(e,t,i.numValues),i,r);let a=Ao(e,t,i),n=r?xv(a,i):bv(a,i);return Float64Array.from(n,Number)}function jI(e,t,i){let r=Ao(e,t,i);return r.length===1?At(r[0]):xI(r)}function vv(e,t,i){let r=Ao(e,t,i);return r.length===1?i.logicalLevelTechnique1===ue.DELTA?At(r[0]):r[0]:vI(r)}function VI(e,t,i,r){let a;switch(t.logicalLevelTechnique1){case ue.DELTA:if(t.logicalLevelTechnique2===ue.RLE){let n=t;if(!r)return dI(e,n.runs,n.numRleValues);e=Xc(e,n.runs,n.numRleValues),a=dg(e)}else a=dg(e);break;case ue.RLE:a=aI(e,t.runs,t.numRleValues);break;case ue.MORTON:mp(e),a=new Int32Array(e);break;case ue.COMPONENTWISE_DELTA:if(i&&!r)return dv(e,i.scale,i.min,i.max);a=lI(e);break;case ue.NONE:a=eI(e);break;default:throw Error(`The specified Logical level technique is not supported: ${t.logicalLevelTechnique1}`)}return r?ha(a,r,0):a}function NI(e,t,i,r){let a;switch(t.logicalLevelTechnique1){case ue.DELTA:if(t.logicalLevelTechnique2===ue.RLE){let n=t;a=fg(Xc(e,n.runs,n.numRleValues))}else a=fg(e);break;case ue.RLE:a=Xc(e,t.runs,t.numRleValues);break;case ue.MORTON:mp(e),a=e;break;case ue.COMPONENTWISE_DELTA:a=i&&!r?mI(e,i.scale,i.min,i.max):fI(e);break;case ue.NONE:a=e;break;default:throw Error(`The specified Logical level technique is not supported: ${t.logicalLevelTechnique1}`)}return r?ha(a,r,0):a}function xv(e,t,i){let r;switch(t.logicalLevelTechnique1){case ue.DELTA:if(t.logicalLevelTechnique2===ue.RLE){let a=t;if(!i)return pI(e,a.runs,a.numRleValues);e=Yc(e,a.runs,a.numRleValues),r=pg(e)}else r=pg(e);break;case ue.RLE:r=nI(e,t.runs,t.numRleValues);break;case ue.NONE:r=tI(e);break;default:throw Error(`The specified Logical level technique is not supported: ${t.logicalLevelTechnique1}`)}return i?ha(r,i,0n):r}function bv(e,t,i){let r;switch(t.logicalLevelTechnique1){case ue.DELTA:if(t.logicalLevelTechnique2===ue.RLE){let a=t;r=mg(Yc(e,a.runs,a.numRleValues))}else r=mg(e);break;case ue.RLE:r=Yc(e,t.runs,t.numRleValues);break;case ue.NONE:r=e;break;default:throw Error(`The specified Logical level technique is not supported: ${t.logicalLevelTechnique1}`)}return i?ha(r,i,0n):r}function UI(e,t,i){switch(t.logicalLevelTechnique1){case ue.DELTA:if(t.logicalLevelTechnique2===ue.RLE){let r=t;e=cv(e,r.runs,r.numRleValues)}return rI(e),e;case ue.RLE:return ZI(e,t,i);case ue.NONE:return i&&iI(e),e;default:throw Error(`The specified Logical level technique is not supported: ${t.logicalLevelTechnique1}`)}}function $I(e,t){if(t.logicalLevelTechnique1===ue.DELTA&&t.logicalLevelTechnique2===ue.NONE)return uI(e);if(t.logicalLevelTechnique1===ue.RLE&&t.logicalLevelTechnique2===ue.NONE){let i=t;return cI(e,i.runs,i.numRleValues)}if(t.logicalLevelTechnique1===ue.NONE&&t.logicalLevelTechnique2===ue.NONE){sI(e);let i=new Uint32Array(t.numValues+1);return i[0]=0,i.set(e,1),i}if(t.logicalLevelTechnique1===ue.DELTA&&t.logicalLevelTechnique2===ue.RLE){let i=t,r=hI(e,i.runs,i.numRleValues);return mp(r),new Uint32Array(r)}throw Error("Only delta encoding is supported for transforming length to offset streams yet.")}function eu(e,t,i,r,a="int32"){let n=e.logicalLevelTechnique1;if(n===ue.RLE)return e.runs===1?Oe.CONST:Oe.FLAT;if(n!==ue.DELTA||e.logicalLevelTechnique2!==ue.RLE)return e.numValues===1?Oe.CONST:Oe.FLAT;let o=t instanceof Ri?t.size():t,s=e;if(s.numRleValues!==o)return Oe.FLAT;if(s.runs===1)return Oe.SEQUENCE;if(s.runs!==2)return e.numValues===1?Oe.CONST:Oe.FLAT;let l=r.get();if(e.physicalLevelTechnique===ni.VARINT)return GI(i,r,a)?Oe.SEQUENCE:e.numValues===1?Oe.CONST:Oe.FLAT;let u=r.get(),h=new Int32Array(i.buffer,i.byteOffset+u,4);return r.set(l),h[2]===2&&h[3]===2?Oe.SEQUENCE:e.numValues===1?Oe.CONST:Oe.FLAT}function GI(e,t,i){let r=new lv(t.get());if(i==="int64"){let n=fp(e,r,4);return n[2]===2n&&n[3]===2n}let a=Ft(e,r,4);return a[2]===2&&a[3]===2}function ZI(e,t,i){return i?oI(e,t.runs,t.numRleValues):cv(e,t.runs,t.numRleValues)}var wv=class extends Ql{getValueFromBuffer(e){return this.dataBuffer[e]}},Tv=class extends ov{constructor(e,t,i,r,a){super(e,a?BigInt64Array.of(t):BigUint64Array.of(t),i,r)}getValueFromBuffer(e){return this.dataBuffer[0]+BigInt(e)*this.delta}};function vp(e,t,i){return{x:_g(e,t)-i,y:_g(e>>1,t)-i}}function _g(e,t){let i=0;for(let r=0;r<t;r++)i|=(e&1<<2*r)>>r;return i}var xt;(function(e){e[e.POINT=0]="POINT",e[e.LINESTRING=1]="LINESTRING",e[e.POLYGON=2]="POLYGON",e[e.MULTIPOINT=3]="MULTIPOINT",e[e.MULTILINESTRING=4]="MULTILINESTRING",e[e.MULTIPOLYGON=5]="MULTIPOLYGON"})(xt||(xt={}));var yg;(function(e){e[e.POINT=0]="POINT",e[e.LINESTRING=1]="LINESTRING",e[e.POLYGON=2]="POLYGON"})(yg||(yg={}));var Ir;(function(e){e[e.MORTON=0]="MORTON",e[e.VEC_2=1]="VEC_2",e[e.VEC_3=2]="VEC_3"})(Ir||(Ir={}));function qI(e){let t=Array(e.numGeometries),i=1,r=1,a=1,n=0,o=0,s=0,l=e.mortonSettings,u=e.topologyVector,h=u.geometryOffsets,c=u.partOffsets,d=u.ringOffsets,p=e.vertexOffsets,f=!p||p.length===0,m=e.containsPolygonGeometry(),g=e.vertexBuffer;for(let _=0;_<e.numGeometries;_++){let y=e.geometryType(_);switch(y){case xt.POINT:{let v,x;if(f)v=g[o++],x=g[o++];else if(e.vertexBufferType===Ir.MORTON){let b=g[p[s++]],w=vp(b,l.numBits,l.coordinateShift);v=w.x,x=w.y}else{let b=p[s++]*2;v=g[b],x=g[b+1]}t[n++]=[[new C(v,x)]],h&&a++,c&&i++,d&&r++}break;case xt.MULTIPOINT:{let v=h[a]-h[a-1];a++;let x;if(f){x=Array(v);for(let b=0;b<v;b++){let w=g[o++],T=g[o++];x[b]=new C(w,T)}}else x=Lr(e.vertexBufferType,g,p,s,v,!1,l),s+=v;t[n++]=x.map(b=>[b]),i+=v,r+=v}break;case xt.LINESTRING:{let v;m?(v=d[r]-d[r-1],r++):v=c[i]-c[i-1],i++;let x;f?(x=xa(g,o,v,!1),o+=v*2):(x=Lr(e.vertexBufferType,g,p,s,v,!1,l),s+=v),t[n++]=[x],h&&a++}break;case xt.POLYGON:{let v=c[i]-c[i-1];i++;let x=Array(v-1),b,w=d[r]-d[r-1];if(r++,f){b=xa(g,o,w,!0),o+=w*2;for(let T=0;T<x.length;T++)w=d[r]-d[r-1],r++,x[T]=xa(g,o,w,!0),o+=w*2}else{b=Lr(e.vertexBufferType,g,p,s,w,!0,l),s+=w;for(let T=0;T<x.length;T++)w=d[r]-d[r-1],r++,x[T]=Lr(e.vertexBufferType,g,p,s,w,!0,l),s+=w}t[n++]=[b].concat(x),h&&a++}break;case xt.MULTILINESTRING:{let v=h[a]-h[a-1];a++;let x=Array(v);for(let b=0;b<v;b++){let w;if(m?(w=d[r]-d[r-1],r++):w=c[i]-c[i-1],i++,f)x[b]=xa(g,o,w,!1),o+=w*2;else{let T=Lr(e.vertexBufferType,g,p,s,w,!1,l);x[b]=T,s+=w}}t[n++]=x}break;case xt.MULTIPOLYGON:{let v=h[a]-h[a-1];a++;let x=Array(v);for(let b=0;b<v;b++){let w=c[i]-c[i-1];i++;let T,E=Array(w-1),S=d[r]-d[r-1];r++,f?(T=xa(g,o,S,!0),o+=S*2):(T=Lr(e.vertexBufferType,g,p,s,S,!0,l),s+=S);for(let M=0;M<E.length;M++){let z=d[r]-d[r-1];r++,f?(E[M]=xa(g,o,z,!0),o+=z*2):(E[M]=Lr(e.vertexBufferType,g,p,s,z,!0,l),s+=z)}x[b]=[T].concat(E)}t[n++]=x.flat()}break;default:throw Error(`The specified geometry type (${y}) is currently not supported.`)}}return t}function Lr(e,t,i,r,a,n,o){return e===Ir.MORTON?HI(t,i,r,a,n,o):WI(t,i,r,a,n)}function xa(e,t,i,r){let a=Array(r?i+1:i);for(let n=0;n<i*2;n+=2){let o=e[t+n],s=e[t+n+1];a[n/2]=new C(o,s)}return r&&(a[a.length-1]=a[0]),a}function WI(e,t,i,r,a){let n=Array(a?r+1:r);for(let o=0;o<r*2;o+=2){let s=t[i+o/2]*2,l=e[s],u=e[s+1];n[o/2]=new C(l,u)}return a&&(n[n.length-1]=n[0]),n}function HI(e,t,i,r,a,n){let o=Array(a?r+1:r);for(let s=0;s<r;s++){let l=e[t[i+s]],u=vp(l,n.numBits,n.coordinateShift);o[s]=new C(u.x,u.y)}return a&&(o[o.length-1]=o[0]),o}var Ev=class{constructor(e,t,i,r,a){this._vertexBufferType=e,this._topologyVector=t,this._vertexOffsets=i,this._vertexBuffer=r,this._mortonSettings=a}get vertexBufferType(){return this._vertexBufferType}get topologyVector(){return this._topologyVector}get vertexOffsets(){return this._vertexOffsets}get vertexBuffer(){return this._vertexBuffer}getSimpleEncodedVertex(e){let t=this.vertexOffsets?this.vertexOffsets[e]*2:e*2;return[this.vertexBuffer[t],this.vertexBuffer[t+1]]}getVertex(e){if(this.vertexOffsets&&this.mortonSettings){let i=this.vertexOffsets[e],r=this.vertexBuffer[i],a=vp(r,this.mortonSettings.numBits,this.mortonSettings.coordinateShift);return[a.x,a.y]}let t=this.vertexOffsets?this.vertexOffsets[e]*2:e*2;return[this.vertexBuffer[t],this.vertexBuffer[t+1]]}getGeometries(){return qI(this)}get mortonSettings(){return this._mortonSettings}};function XI(e,t,i,r,a){return new Dv(e,t,Ir.VEC_2,i,r,a)}function YI(e,t,i,r,a,n){return new Dv(e,t,Ir.MORTON,i,r,a,n)}var Dv=class extends Ev{constructor(e,t,i,r,a,n,o){super(i,r,a,n,o),this._numGeometries=e,this._geometryType=t}geometryType(e){return this._geometryType}get numGeometries(){return this._numGeometries}containsPolygonGeometry(){return this._geometryType===xt.POLYGON||this._geometryType===xt.MULTIPOLYGON}containsSingleGeometryType(){return!0}};function Sv(e,t,i,r){return new Cv(Ir.VEC_2,e,t,i,r)}function KI(e,t,i,r,a){return new Cv(Ir.MORTON,e,t,i,r,a)}var Cv=class extends Ev{constructor(e,t,i,r,a,n){super(e,i,r,a,n),this._geometryTypes=t}geometryType(e){return this._geometryTypes[e]}get numGeometries(){return this._geometryTypes.length}containsPolygonGeometry(){for(let e=0;e<this.numGeometries;e++)if(this.geometryType(e)===xt.POLYGON||this.geometryType(e)===xt.MULTIPOLYGON)return!0;return!1}containsSingleGeometryType(){return!1}},Pv=class{constructor(e,t,i,r){this._triangleOffsets=e,this._indexBuffer=t,this._vertexBuffer=i,this._topologyVector=r}get triangleOffsets(){return this._triangleOffsets}get indexBuffer(){return this._indexBuffer}get vertexBuffer(){return this._vertexBuffer}get topologyVector(){return this._topologyVector}getGeometries(){if(!this._topologyVector)throw Error("Cannot convert GpuVector to coordinates without topology information");let e=new Uint32Array(this.numGeometries);for(let t=0;t<this.numGeometries;t++)e[t]=this.geometryType(t);return Sv(e,this._topologyVector,void 0,this._vertexBuffer).getGeometries()}[Symbol.iterator](){return null}};function vg(e,t,i,r,a,n){return new JI(e,t,i,r,a,n)}var JI=class extends Pv{constructor(e,t,i,r,a,n){super(i,r,a,n),this._numGeometries=e,this._geometryType=t}geometryType(e){return this._geometryType}get numGeometries(){return this._numGeometries}containsSingleGeometryType(){return!0}};function xg(e,t,i,r,a){return new QI(e,t,i,r,a)}var QI=class extends Pv{constructor(e,t,i,r,a){super(t,i,r,a),this._geometryTypes=e}geometryType(e){return this._geometryTypes[e]}get numGeometries(){return this._geometryTypes.length}containsSingleGeometryType(){return!1}};function eM(e,t,i,r,a){let n=$e(e,i),o=eu(n,r,e,i),s,l,u,h;if(o===Oe.CONST){let v=_p(e,i,n),x,b,w,T;for(let E=0;E<t-1;E++){let S=$e(e,i);switch(S.physicalStreamType){case rt.LENGTH:switch(S.logicalStreamType.lengthType){case ct.GEOMETRIES:x=xr(e,i,S);break;case ct.PARTS:b=xr(e,i,S);break;case ct.RINGS:w=xr(e,i,S);break;case ct.TRIANGLES:T=xr(e,i,S)}break;case rt.OFFSET:switch(S.logicalStreamType.offsetType){case $i.VERTEX:s=St(e,i,S);break;case $i.INDEX:h=St(e,i,S)}break;case rt.DATA:if(Lt.VERTEX===S.logicalStreamType.dictionaryType)l=yl(e,i,S,a);else{let M=S;u={numBits:M.numBits,coordinateShift:M.coordinateShift},l=St(e,i,S,a)}}}return h?x!==void 0||b!==void 0?vg(r,v,T,h,l,{geometryOffsets:x,partOffsets:b,ringOffsets:w}):vg(r,v,T,h,l):u===void 0?XI(r,v,{geometryOffsets:x,partOffsets:b,ringOffsets:w},s,l):YI(r,v,{geometryOffsets:x,partOffsets:b,ringOffsets:w},s,l,u)}let c=St(e,i,n),d,p,f,m;for(let v=0;v<t-1;v++){let x=$e(e,i);switch(x.physicalStreamType){case rt.LENGTH:switch(x.logicalStreamType.lengthType){case ct.GEOMETRIES:d=St(e,i,x);break;case ct.PARTS:p=St(e,i,x);break;case ct.RINGS:f=St(e,i,x);break;case ct.TRIANGLES:m=xr(e,i,x)}break;case rt.OFFSET:switch(x.logicalStreamType.offsetType){case $i.VERTEX:s=St(e,i,x);break;case $i.INDEX:h=St(e,i,x)}break;case rt.DATA:if(Lt.VERTEX===x.logicalStreamType.dictionaryType)l=yl(e,i,x,a);else{let b=x;u={numBits:b.numBits,coordinateShift:b.coordinateShift},l=St(e,i,x,a)}}}let g,_,y;return d?(g=oh(c,d,2),p&&f?(_=bg(c,g,p,!1),y=iM(c,g,_,f)):p&&(_=tM(c,g,p))):p&&f?(_=oh(c,p,1),y=bg(c,_,f,!0)):p&&(_=oh(c,p,0)),h&&!_?xg(c,m,h,l):h?xg(c,m,h,l,{geometryOffsets:g,partOffsets:_,ringOffsets:y}):u===void 0?Sv(c,{geometryOffsets:g,partOffsets:_,ringOffsets:y},s,l):KI(c,{geometryOffsets:g,partOffsets:_,ringOffsets:y},s,l,u)}function oh(e,t,i){let r=new Uint32Array(e.length+1),a=0;r[0]=a;let n=0;for(let o=0;o<e.length;o++)a=r[o+1]=a+(e[o]>i?t[n++]:1);return r}function bg(e,t,i,r){let a=new Uint32Array(t[t.length-1]+1),n=0;a[0]=n;let o=1,s=0;for(let l=0;l<e.length;l++){let u=e[l],h=t[l+1]-t[l];if(u===5||u===2||r&&(u===4||u===1))for(let c=0;c<h;c++)n=a[o++]=n+i[s++];else for(let c=0;c<h;c++)a[o++]=++n}return a}function tM(e,t,i){let r=new Uint32Array(t[t.length-1]+1),a=0;r[0]=a;let n=1,o=0;for(let s=0;s<e.length;s++){let l=e[s],u=t[s+1]-t[s];if(l===4||l===1)for(let h=0;h<u;h++)a=r[n++]=a+i[o++];else for(let h=0;h<u;h++)r[n++]=++a}return r}function iM(e,t,i,r){let a=new Uint32Array(i[i.length-1]+1),n=0;a[0]=n;let o=1,s=1,l=0;for(let u=0;u<e.length;u++){let h=e[u],c=t[u+1]-t[u];if(h!==0&&h!==3)for(let d=0;d<c;d++){let p=i[o]-i[o-1];o++;for(let f=0;f<p;f++)n=a[s++]=n+r[l++]}else for(let d=0;d<c;d++)a[s++]=++n,o++}return a}var rM=class extends ua{constructor(e,t,i){super(e,t.getBuffer(),i),this.dataVector=t}getValueFromBuffer(e){return this.dataVector.get(e)}},aM=class extends Ql{getValueFromBuffer(e){return this.dataBuffer[e]}},Av=class extends ua{constructor(e,t,i,r){super(e,r?BigInt64Array.of(t):BigUint64Array.of(t),i)}getValueFromBuffer(e){return this.dataBuffer[0]}},xp=class extends ua{constructor(e,t,i,r){super(e,i,r),this.offsetBuffer=t}},wg=class extends xp{constructor(e,t,i,r){super(e,t,i,r??t.length-1)}getValueFromBuffer(e){let t=this.offsetBuffer[e],i=this.offsetBuffer[e+1];return gp(this.dataBuffer,t,i)}},Va=class extends xp{constructor(e,t,i,r,a){super(e,i,r,a??t.length),this.indexBuffer=t,this.indexBuffer=t}getValueFromBuffer(e){let t=this.indexBuffer[e],i=this.offsetBuffer[t],r=this.offsetBuffer[t+1];return gp(this.dataBuffer,i,r)}};function nM(e,t){let i=0;for(let r=0;r<t.length;r++){let a=t[r];a===255?(i++,r++):i+=e[a]}return i}function oM(e,t,i){let r=new Uint32Array(t.length);for(let o=1;o<t.length;o++)r[o]=r[o-1]+t[o-1];let a=new Uint8Array(nM(t,i)),n=0;for(let o=0;o<i.length;o++){let s=i[o];if(s===255)o++,a[n++]=i[o];else{let l=t[s],u=r[s];for(;l-- >0;)a[n++]=e[u++]}}return a}var Iv=class extends xp{constructor(e,t,i,r,a,n,o,s){super(e,i,r,o??t.length),this.indexBuffer=t,this.symbolOffsetBuffer=a,this.symbolTableBuffer=n,this.sharedDictionaryCache=s}getValueFromBuffer(e){this.decodedDictionary??(this.decodedDictionary=this.sharedDictionaryCache?.decodedDictionary,this.decodedDictionary??(this.decodedDictionary=this.decodeDictionary(),this.sharedDictionaryCache&&(this.sharedDictionaryCache.decodedDictionary=this.decodedDictionary)));let t=this.indexBuffer[e],i=this.offsetBuffer[t],r=this.offsetBuffer[t+1];return gp(this.decodedDictionary,i,r)}decodeDictionary(){return this.symbolLengthBuffer??(this.symbolLengthBuffer=this.offsetToLengthBuffer(this.symbolOffsetBuffer)),oM(this.symbolTableBuffer,this.symbolLengthBuffer,this.dataBuffer)}offsetToLengthBuffer(e){let t=new Uint32Array(e.length-1),i=e[0];for(let r=1;r<e.length;r++){let a=e[r];t[r-1]=a-i,i=a}return t}};function Mv(e,t,i,r,a){let n,o,s,l,u,h=a,c,d;for(let p=0;p<r;p++){let f=$e(t,i);switch(f.physicalStreamType){case rt.PRESENT:{let m=new Ri(nn(t,f.numValues,f.byteLength,i),f.numValues);h=a??m;break}case rt.OFFSET:o=St(t,i,f,void 0,h);break;case rt.LENGTH:{let m=xr(t,i,f);ct.DICTIONARY===f.logicalStreamType.lengthType?n=m:ct.SYMBOL===f.logicalStreamType.lengthType?l=m:c=m;break}case rt.DATA:{let m=t.subarray(i.get(),i.get()+f.byteLength);i.add(f.byteLength);let g=f.logicalStreamType.dictionaryType;Lt.FSST===g?u=m:Lt.SINGLE===g||Lt.SHARED===g?s=m:Lt.NONE===g&&(d=m);break}}}return sM(e,u,o,n,s,l,h)??lM(e,s,o,n,h)??uM(e,c,d,o,h)}function sM(e,t,i,r,a,n,o){if(t){if(!i||!r||!a||!n)throw Error(`Incomplete FSST dictionary string column "${e}"`);return new Iv(e,i,r,a,n,t,o)}}function lM(e,t,i,r,a){if(t){if(!i||!r)throw Error(`Incomplete dictionary string column "${e}"`);return a?new Va(e,i,r,t,a):new Va(e,i,r,t)}}function uM(e,t,i,r,a){if(t&&i){if(r)return a?new Va(e,r,t,i,a):new Va(e,r,t,i);if(a&&a.size()!==t.length-1){let n=new Uint32Array(a.size()),o=0;for(let s=0;s<a.size();s++)a.get(s)?n[s]=o++:n[s]=0;return new Va(e,n,t,i,a)}return a?new wg(e,t,i,a):new wg(e,t,i)}}function hM(e,t,i,r){let a,n,o,s,l=!1;for(;!l;){let p=$e(e,t);switch(p.physicalStreamType){case rt.LENGTH:ct.DICTIONARY===p.logicalStreamType.lengthType?a=xr(e,t,p):o=xr(e,t,p);break;case rt.DATA:Lt.SINGLE===p.logicalStreamType.dictionaryType||Lt.SHARED===p.logicalStreamType.dictionaryType?(n=e.subarray(t.get(),t.get()+p.byteLength),l=!0):s=e.subarray(t.get(),t.get()+p.byteLength),t.add(p.byteLength)}}if(i.type!=="complexType")throw Error(`Shared dictionary column ${i.name} must be a complex (struct) column.`);if(!a||!n)throw Error(`Incomplete shared dictionary for column "${i.name}"`);let u=i.complexType.children,h=[],c=s?{}:void 0,d=0;for(let p of u){let f=Ft(e,t,1)[0];if(f===0)continue;let m=p.name?`${i.name}${p.name}`:i.name;if(r&&!r.has(m)){pv(f,e,t);continue}if(p.type!=="scalarField"||p.scalarField.physicalType!==Ee.STRING)throw Error("Currently only scalar string fields are implemented for a struct.");if(f>1&&!p.nullable||f===1&&p.nullable)throw Error(`The number of streams for the child field ${p.name} does not match its nullability. nullibilty: ${p.nullable}, numStreams: ${f}`);let g;if(p.nullable){let y=$e(e,t);g=new Ri(nn(e,y.numValues,y.byteLength,t),y.numValues)}let _=St(e,t,$e(e,t),void 0,g);if(s){if(!o)throw Error(`Incomplete shared FSST dictionary for column "${m}"`);h[d++]=new Iv(m,_,a,n,o,s,g,c)}else h[d++]=new Va(m,_,a,n,g)}return h}var Tg=class extends ua{constructor(e,t,i){super(e,new Uint8Array,i??t.length),this.values=t}getValueFromBuffer(e){return this.values[e]}},Gi;(function(e){e[e.STRING=1]="STRING",e[e.INT32=2]="INT32",e[e.UINT32=4]="UINT32",e[e.INT64=8]="INT64",e[e.UINT64=16]="UINT64",e[e.FLOAT=32]="FLOAT",e[e.DOUBLE=64]="DOUBLE",e[e.PRESENCE=128]="PRESENCE"})(Gi||(Gi={}));var Tr;(function(e){e[e.FALSE=0]="FALSE",e[e.TRUE=1]="TRUE",e[e.START_MAP=2]="START_MAP",e[e.START_LIST=3]="START_LIST",e[e.COUNT=4]="COUNT"})(Tr||(Tr={}));function cM(e,t,i,r){let a=dM(i);if(r===0)return a.map(h=>new Tg(h,[]));let n=pM(e,t,r),o=(n.presentStream?n.presentCount:n.lengthStream.length)/a.length,s=[],l=0,u=0;for(let h=0;h<a.length;h++){let c=yM(n,h,o,l,u);s.push(new Tg(a[h],c.value,c.nullabilityBuffer)),l=c.countsEnd,u=c.valuesEnd}return s}function dM(e){let t=e.type==="complexType"?e.complexType.children:void 0;return!t||t.length===0?[e.name]:t.map(i=>e.name+(i.name??""))}function pM(e,t,i){let r=e[t.get()];t.add(1);let a=St(e,t,$e(e,t)),n=i-1,o=[];r&Gi.STRING&&(n-=fM(e,t,o)),n-=mM(e,t,r,o),n-=gM(e,t,r,o);let s,l=0;if(r&Gi.PRESENCE){let h=_M(e,t);s=h.value,l=h.count,n--}let u=new Uint32Array;if(n>0&&(u=St(e,t,$e(e,t)),n--),n!==0)throw Error(`Unexpected number of remaining streams while decoding map column: ${n}`);return{lengthStream:a,dictionary:o,presentStream:s,presentCount:l,flattenedValues:u}}function fM(e,t,i){let r=e[t.get()];t.add(1);let a=Mv("",e,t,r);if(a)for(let n=0;n<a.size;n++)i.push(a.getValue(n));return r}function mM(e,t,i,r){let a=0;return i&Gi.INT32?(Fa(r,yl(e,t,$e(e,t))),a++):i&Gi.INT64&&(Fa(r,yv(e,t,$e(e,t))),a++),i&Gi.UINT32?(Fa(r,St(e,t,$e(e,t))),a++):i&Gi.UINT64&&(Fa(r,yp(e,t,$e(e,t))),a++),a}function gM(e,t,i,r){let a=0;return i&Gi.FLOAT&&(Fa(r,fv(e,t,$e(e,t).numValues)),a++),i&Gi.DOUBLE&&(Fa(r,mv(e,t,$e(e,t).numValues)),a++),a}function _M(e,t){let i=$e(e,t);if(i.physicalStreamType!==rt.PRESENT)throw Error(`Expected PRESENT stream for map column but found: ${i.physicalStreamType}`);let r=i.numValues,a=t.get(),n=new Ri(nn(e,r,i.byteLength,t),r);return t.set(a+i.byteLength),{value:n,count:r}}function yM(e,t,i,r,a){let{lengthStream:n,flattenedValues:o,presentStream:s,dictionary:l}=e,u=t*i,h=i,c;if(s){c=new Ri(new Uint8Array(Math.ceil(i/8)),i),h=0;for(let y=0;y<i;y++)s.get(u+y)&&(c.set(y,!0),h++)}let d=r+h;if(d>n.length)throw Error("Merged map counts underflow while decoding child streams");let p=Array(i),f=r,m=a;for(let y=0;y<i;y++){if(s&&!s.get(u+y)){p[y]=null;continue}let v=m+n[f++];if(v>o.length)throw Error("Map value stream underflow while decoding feature payload");let x=vM(o,m,v,l);p[y]=x.value,m=x.nextIndex}let g=0;for(let y=r;y<d;y++)g+=n[y];let _=a+g;if(m!==_)throw Error("Unused flattened map values remain after decode");return{value:p,nullabilityBuffer:c,countsEnd:d,valuesEnd:_}}function vM(e,t,i,r){return i-t===1||e[t]===Tr.START_LIST?bp(e,t,i,r):Fv(e,t,i,r)}function Fv(e,t,i,r){let a=Object.create(null),n=t;for(;n<i;){let o=zv(e[n++],r);if(typeof o!="string")throw Error(`Map key dictionary index does not resolve to a string: ${o}`);let s=bp(e,n,i,r);a[o]=s.value,n=s.nextIndex}return{value:a,nextIndex:n}}function bp(e,t,i,r){if(t>=i)throw Error("Unexpected end of map value stream");let a=e[t];if(a===Tr.FALSE)return{value:!1,nextIndex:t+1};if(a===Tr.TRUE)return{value:!0,nextIndex:t+1};if(a===Tr.START_MAP){let n=Eg(e,t,i);return{value:Fv(e,t+2,n,r).value,nextIndex:n}}if(a===Tr.START_LIST){let n=Eg(e,t,i),o=[],s=t+2;for(;s<n;){let l=bp(e,s,n,r);o.push(l.value),s=l.nextIndex}return{value:o,nextIndex:n}}return{value:zv(a,r),nextIndex:t+1}}function Eg(e,t,i){if(t+1>=i)throw Error("Missing length for nested map/list payload");let r=e[t+1];if(r<2)throw Error(`Invalid nested payload length: ${r}`);let a=t+r;if(a>i)throw Error("Nested payload exceeds containing payload bounds");return a}function zv(e,t){let i=e-Tr.COUNT;if(i<0||i>=t.length)throw Error(`Scalar dictionary index out of range: ${e}`);return t[i]}function Fa(e,t){for(let i of t)e.push(i)}function xM(e,t,i,r,a,n){return i.type==="scalarType"?n&&!n.has(i.name)?(pv(r,e,t),null):bM(r,e,t,a,i.scalarType,i):i.complexType?.physicalType===Dr.MAP?cM(e,t,i,r):r===0?null:hM(e,t,i,n)}function bM(e,t,i,r,a,n){let o;if(e===0)return null;if(n.nullable){let l=$e(t,i),u=l.numValues,h=i.get(),c=nn(t,u,l.byteLength,i);i.set(h+l.byteLength),o=new Ri(c,l.numValues)}let s=o??r;switch(a.physicalType){case Ee.UINT_32:case Ee.INT_32:return SM(t,i,n,a,s);case Ee.STRING:{let l=n.nullable?e-1:e;return Mv(n.name,t,i,l,o)??null}case Ee.BOOLEAN:return wM(t,i,n,r,s);case Ee.UINT_64:case Ee.INT_64:return DM(t,i,n,s,a);case Ee.FLOAT:return TM(t,i,n,s);case Ee.DOUBLE:return EM(t,i,n,s);default:throw Error(`The specified data type for the field is currently not supported: ${a}`)}}function wM(e,t,i,r,a){let n=$e(e,t),o=n.numValues,s=t.get(),l=Io(a)?a:void 0,u=nn(e,o,n.byteLength,t,l);t.set(s+n.byteLength);let h=new Ri(u,o);return new rM(i.name,h,a)}function TM(e,t,i,r){let a=$e(e,t),n=Io(r)?r:void 0,o=fv(e,t,a.numValues,n);return new aM(i.name,o,r)}function EM(e,t,i,r){let a=$e(e,t),n=Io(r)?r:void 0,o=mv(e,t,a.numValues,n);return new lp(i.name,o,r)}function DM(e,t,i,r,a){let n=$e(e,t),o=eu(n,r,e,t,"int64"),s=a.physicalType===Ee.INT_64;if(o===Oe.FLAT){let u=Io(r)?r:void 0,h=s?yv(e,t,n,u):yp(e,t,n,u);return new wv(i.name,h,r)}if(o===Oe.SEQUENCE){let u=_v(e,t,n);return new Tv(i.name,u[0],u[1],n.numRleValues,s)}let l=s?jI(e,t,n):vv(e,t,n);return new Av(i.name,l,r,s)}function SM(e,t,i,r,a){let n=$e(e,t),o=eu(n,a,e,t),s=r.physicalType===Ee.INT_32;if(o===Oe.FLAT){let u=Io(a)?a:void 0,h=s?yl(e,t,n,void 0,u):St(e,t,n,void 0,u);return new sp(i.name,h,a)}if(o===Oe.SEQUENCE){let u=gv(e,t,n);return new up(i.name,u[0],u[1],n.numRleValues,s)}let l=s?LI(e,t,n):_p(e,t,n);return new hp(i.name,l,a,s)}function Io(e){return e instanceof Ri}var ft={ID:0,ID_NULLABLE:1,ID_LONG:2,GEOMETRY:4,SCALAR_BASE:10,STRUCT:30,MAP:31};function Rv(e){switch(e){case ft.ID:case ft.ID|ft.ID_NULLABLE:case ft.ID|ft.ID_LONG:case ft.ID|ft.ID_LONG|ft.ID_NULLABLE:return{nullable:(e&ft.ID_NULLABLE)!==0,columnScope:Bn.FEATURE,type:"scalarType",scalarType:{longID:(e&ft.ID_LONG)!==0,type:"logicalType",logicalType:sv.ID}};case ft.GEOMETRY:return{nullable:!1,columnScope:Bn.FEATURE,type:"complexType",complexType:{type:"physicalType",physicalType:Dr.GEOMETRY,children:[]}};case ft.STRUCT:return{nullable:!1,columnScope:Bn.FEATURE,type:"complexType",complexType:{type:"physicalType",physicalType:Dr.STRUCT,children:[]}};case ft.MAP:return{nullable:!0,columnScope:Bn.FEATURE,type:"complexType",complexType:{type:"physicalType",physicalType:Dr.MAP,children:[]}};default:return MM(e)}}function CM(e){return e>=ft.SCALAR_BASE}function kv(e){return e===ft.STRUCT||e===ft.MAP}function PM(e){if(e.type==="scalarType"){let t=e.scalarType;if(t.type==="physicalType")switch(t.physicalType){case Ee.BOOLEAN:case Ee.INT_8:case Ee.UINT_8:case Ee.INT_32:case Ee.UINT_32:case Ee.INT_64:case Ee.UINT_64:case Ee.FLOAT:case Ee.DOUBLE:return!1;case Ee.STRING:return!0;default:return!1}if(t.type==="logicalType")return!1}else if(e.type==="complexType"){let t=e.complexType;if(t.type==="physicalType")switch(t.physicalType){case Dr.GEOMETRY:case Dr.STRUCT:case Dr.MAP:return!0;default:return!1}}return console.warn("Unexpected column type in hasStreamCount",e),!1}function AM(e){return e.type==="scalarType"&&e.scalarType?.type==="logicalType"&&e.scalarType.logicalType===sv.ID}function IM(e){return e.type==="complexType"&&e.complexType?.type==="physicalType"&&e.complexType.physicalType===Dr.GEOMETRY}function MM(e){let t;switch(e){case 10:case 11:t=Ee.BOOLEAN;break;case 12:case 13:t=Ee.INT_8;break;case 14:case 15:t=Ee.UINT_8;break;case 16:case 17:t=Ee.INT_32;break;case 18:case 19:t=Ee.UINT_32;break;case 20:case 21:t=Ee.INT_64;break;case 22:case 23:t=Ee.UINT_64;break;case 24:case 25:t=Ee.FLOAT;break;case 26:case 27:t=Ee.DOUBLE;break;case 28:case 29:t=Ee.STRING;break;default:return null}return{nullable:!!(e&1),columnScope:Bn.FEATURE,type:"scalarType",scalarType:{longID:!1,type:"physicalType",physicalType:t}}}var FM=new TextDecoder,Dg="0-3(ID), 4(GEOMETRY), 10-29(scalars), 30(STRUCT), 31(MAP)";function wp(e,t){let i=Ft(e,t,1)[0];if(i===0)return"";let r=t.get(),a=r+i,n=e.subarray(r,a);return t.add(i),FM.decode(n)}function zM(e){let t=e.name,i=e.nullable;return e.type==="scalarType"?{type:"scalarField",scalarField:e.scalarType,name:t,nullable:i}:{type:"complexField",complexField:e.complexType,name:t,nullable:i}}function Lv(e,t){let i=Ft(e,t,1)[0]>>>0,r=i>=ft.SCALAR_BASE?Rv(i):null;if(!r)throw Error(`Unsupported field type code ${i}. Supported: 10-29(scalars), 30(STRUCT), 31(MAP)`);let a={...r,name:wp(e,t)};if(a.type==="complexType"&&kv(i)){let n=a.complexType,o=Ft(e,t,1)[0]>>>0;n.children=Array(o);for(let s=0;s<o;s++)n.children[s]=Lv(e,t)}return zM(a)}function RM(e,t){let i=Ft(e,t,1)[0]>>>0,r=Rv(i);if(!r)throw Error(`Unsupported column type code ${i}. Supported: ${Dg}`);let a;if(CM(i))a=wp(e,t);else if(i<ft.GEOMETRY)a="id";else if(i===ft.GEOMETRY)a="geometry";else throw Error(`Unsupported column type code ${i}. Supported: ${Dg}`);let n={...r,name:a};if(n.type==="complexType"&&kv(i)){let o=Ft(e,t,1)[0]>>>0,s=n.complexType;s.children=Array(o);for(let l=0;l<o;l++)s.children[l]=Lv(e,t)}return n}function kM(e,t){let i={};i.featureTables=[];let r={};if(r.name=wp(e,t),r.name.length===0)throw Error("Missing layer name");let a=Ft(e,t,1)[0]>>>0,n=Ft(e,t,1)[0]>>>0;r.columns=Array(n);for(let o=0;o<n;o++)r.columns[o]=RM(e,t);return i.featureTables.push(r),[i,a]}function LM(e,t,i=!0){let r=new lv(0),a=[];for(;r.get()<e.length;){let n=Ft(e,r,1)[0]>>>0,o=r.get()+n;if(o>e.length)throw Error(`Block overruns tile: ${o} > ${e.length}`);let s=Ft(e,r,1)[0]>>>0;if(s!==1&&s!==2){r.set(o);continue}let[l,u]=kM(e,r),h=l.featureTables[0],c=null,d=null,p=[],f=0;for(let g of h.columns){let _=g.name;if(AM(g)){let y=null;if(g.nullable){let x=$e(e,r),b=r.get(),w=nn(e,x.numValues,x.byteLength,r);r.set(b+x.byteLength),y=new Ri(w,x.numValues)}let v=$e(e,r);f=y?y.size():v.decompressedCount,c=BM(e,g,r,_,v,y??f,i)}else if(IM(g)){let y=Ft(e,r,1)[0];if(f===0){let v=r.get();f=$e(e,r).decompressedCount,r.set(v)}t&&(t.scale=t.extent/u),d=eM(e,y,r,f,t)}else{let y=PM(g)?Ft(e,r,1)[0]:1;if(y===0)continue;let v=xM(e,r,g,y,f,void 0);if(v)if(Array.isArray(v))for(let x of v)p.push(x);else p.push(v)}}let m=new sA(h.name,d,c,p,u);a.push(m),r.set(o)}return a}function BM(e,t,i,r,a,n,o=!1){let s=t.scalarType?.longID?Ee.UINT_64:Ee.UINT_32,l=typeof n=="number"?void 0:n,u=eu(a,n,e,i,s===Ee.UINT_64?"int64":"int32");if(s===Ee.UINT_32)switch(u){case Oe.FLAT:return new sp(r,St(e,i,a,void 0,l),n);case Oe.SEQUENCE:{let h=gv(e,i,a);return new up(r,h[0],h[1],a.numRleValues,!1)}case Oe.CONST:return new hp(r,_p(e,i,a),n,!1)}switch(u){case Oe.FLAT:return o?new lp(r,BI(e,i,a,l),n):new wv(r,yp(e,i,a,l),n);case Oe.SEQUENCE:{let h=_v(e,i,a);return new Tv(r,h[0],h[1],a.numRleValues,!1)}case Oe.CONST:return new Av(r,vv(e,i,a),n,!1)}throw Error("Vector type not supported for id column.")}var sh=uv(dp);sh/32*4,3*sh/256+sh|0;var OM=class{constructor(e,t){switch(this._featureData=e,this.properties=this._featureData.properties||{},this._featureData.geometry?.type){case xt.POINT:case xt.MULTIPOINT:this.type=1;break;case xt.LINESTRING:case xt.MULTILINESTRING:this.type=2;break;case xt.POLYGON:case xt.MULTIPOLYGON:this.type=3;break;default:this.type=0}this.extent=t,this.id=Number(this._featureData.id)}loadGeometry(){let e=[];for(let t of this._featureData.geometry.coordinates){let i=[];for(let r of t)i.push(new C(r.x,r.y));e.push(i)}return e}},jM=class{constructor(e){this.features=[],this.featureTable=e,this.name=e.name,this.extent=e.extent,this.version=2,this.features=e.getFeatures(),this.length=this.features.length}feature(e){return new OM(this.features[e],this.extent)}},VM=class{constructor(e){this.layers={};let t=LM(new Uint8Array(e));this.layers=t.reduce((i,r)=>({...i,[r.name]:new jM(r)}),{})}};G("FeatureIndex",class{constructor(e,t){this.tileID=e,this.x=e.canonical.x,this.y=e.canonical.y,this.z=e.canonical.z,this.grid=new Wh(k,16,0),this.grid3D=new Wh(k,16,0),this.featureIndexArray=new L0,this.promoteId=t}insert(e,t,i,r,a,n){let o=this.featureIndexArray.length;this.featureIndexArray.emplaceBack(i,r,a);let s=n?this.grid3D:this.grid;for(let l of t){let u=[1/0,1/0,-1/0,-1/0];for(let h of l)u[0]=Math.min(u[0],h.x),u[1]=Math.min(u[1],h.y),u[2]=Math.max(u[2],h.x),u[3]=Math.max(u[3],h.y);u[0]<8192&&u[1]<8192&&u[2]>=0&&u[3]>=0&&s.insert(o,u[0],u[1],u[2],u[3])}}loadVTLayers(){return this.vtLayers||(this.encoding==="mlt"?this.vtLayers=new VM(this.rawTileData).layers:this.vtLayers=new bD(new T1(this.rawTileData)).layers,this.sourceLayerCoder=new oA(this.vtLayers?Object.keys(this.vtLayers).sort():[Ns])),this.vtLayers}query(e,t,i,r){this.loadVTLayers();let a=e.params,n=k/e.tileSize/e.scale,o=ro(a.filter,"queryRenderedFeatures filter",a.globalState),s=e.queryGeometry,l=e.queryPadding*n,u=Ii.fromPoints(s),h=this.grid.query(u.minX-l,u.minY-l,u.maxX+l,u.maxY+l),c=Ii.fromPoints(e.cameraQueryGeometry).expandBy(l),d=this.grid3D.query(c.minX,c.minY,c.maxX,c.maxY,(m,g,_,y)=>hE(e.cameraQueryGeometry,m-l,g-l,_+l,y+l));for(let m of d)h.push(m);h.sort(UM);let p={},f;for(let m of h){if(m===f)continue;f=m;let g=this.featureIndexArray.get(m),_=null;this.loadMatchingFeature(p,g.bucketIndex,g.sourceLayerIndex,g.featureIndex,o,a.layers,a.availableImages,t,i,r,(y,v,x)=>(_||(_=sa(y)),v.queryIntersectsFeature({queryGeometry:s,feature:y,featureState:x,geometry:_,zoom:this.z,transform:e.transform,pixelsToTileUnits:n,pixelPosMatrix:e.pixelPosMatrix,unwrappedTileID:this.tileID.toUnwrapped(),getElevation:e.getElevation})))}return p}loadMatchingFeature(e,t,i,r,a,n,o,s,l,u,h){let c=this.bucketLayerIDs[t];if(n&&!c.some(m=>n.has(m)))return;let d=this.sourceLayerCoder.decode(i),p=this.vtLayers[d].feature(r);if(a.needGeometry){let m=la(p,!0);if(!a.filter(new Ae(this.tileID.overscaledZ),m,this.tileID.canonical))return}else if(!a.filter(new Ae(this.tileID.overscaledZ),p))return;let f=this.getId(p,d);for(let m of c){if(n&&!n.has(m))continue;let g=s[m];if(!g)continue;let _={};f&&u&&(_=u.getState(g.sourceLayer||"_geojsonTileLayer",f));let y=q({},l[m]);y.paint=Sg(y.paint,g.paint,p,_,o),y.layout=Sg(y.layout,g.layout,p,_,o);let v=!h||h(p,g,_);if(!v)continue;let x=new nv(p,this.z,this.x,this.y,f);x.layer=y;let b=e[m];b===void 0&&(b=e[m]=[]),b.push({featureIndex:r,feature:x,intersectionZ:v})}}lookupSymbolFeatures(e,t,i,r,a,n,o,s){let l={};this.loadVTLayers();let u=ro(a.filterSpec,"queryRenderedFeatures symbol filter",a.globalState);for(let h of e)this.loadMatchingFeature(l,i,r,h,u,n,o,s,t);return l}hasLayer(e){for(let t of this.bucketLayerIDs)for(let i of t)if(e===i)return!0;return!1}getId(e,t){let i=e.id;if(this.promoteId){let r=typeof this.promoteId=="string"?this.promoteId:this.promoteId[t];i=e.properties[r],typeof i=="boolean"&&(i=Number(i)),i===void 0&&e.properties?.cluster&&this.promoteId&&(i=Number(e.properties.cluster_id))}return i}},{omit:["rawTileData","sourceLayerCoder"]});function NM(e){return typeof e=="object"&&!!e&&"evaluate"in e}function Sg(e,t,i,r,a){return vd(e,(n,o)=>{let s=t instanceof Ul?t.get(o):null;return NM(s)?s.evaluate(i,r,void 0,a):s})}function UM(e,t){return t-e}var Kc="RTLPluginLoaded",$M=class extends ht{constructor(...e){super(...e),this.status="unavailable",this.url=null,this.dispatcher=np()}_syncState(e){return this.status=e,this.dispatcher.broadcast("SRPS",{pluginStatus:e,pluginURL:this.url}).catch(t=>{throw this.status="error",t})}getRTLTextPluginStatus(){return this.status}clearRTLTextPlugin(){this.status="unavailable",this.url=null}async setRTLTextPlugin(e,t=!1){if(this.url)throw Error("setRTLTextPlugin cannot be called multiple times.");if(this.url=Kt.resolveURL(e),!this.url)throw Error(`requested url ${e} is invalid`);if(this.status==="unavailable")if(t)this.status="deferred",this._syncState(this.status);else return this._requestImport();else if(this.status==="requested")return this._requestImport()}async _requestImport(){await this._syncState("loading"),this.status="loaded",this.fire(new li(Kc))}lazyLoad(){this.status==="unavailable"?this.status="requested":this.status==="deferred"&&this._requestImport()}},lh=null;function _o(){return lh||(lh=new $M),lh}var Bv=class{constructor(e,t){this.timeAdded=0,this.fadeEndTime=0,this.fadeOpacity=1,this.tileID=e,this.uid=j_(),this.uses=0,this.tileSize=t,this.buckets={},this.expirationTime=null,this.queryPadding=0,this.hasSymbolBuckets=!1,this.hasRTLText=!1,this.dependencies={},this.rttObjects=[],this.rttFingerprint={},this.expiredRequestCount=0,this.state="loading",this.featureStateRevision=-1}isRenderable(e){return this.hasData()&&(!this.fadeEndTime||this.fadingDirection!==0||this.fadeOpacity>0)&&(e||!this.holdingForSymbolFade())}setCrossFadeLogic({fadingRole:e,fadingDirection:t,fadingParentID:i,fadeEndTime:r}){this.resetFadeLogic(),this.fadingRole=e,this.fadingDirection=t,this.fadingParentID=i,this.fadeEndTime=r}setSelfFadeLogic(e){this.resetFadeLogic(),this.selfFading=!0,this.fadeEndTime=e}resetFadeLogic(){this.fadingRole=null,this.fadingDirection=null,this.fadingParentID=null,this.selfFading=!1,this.timeAdded=Ie(),this.fadeEndTime=0,this.fadeOpacity=1}wasRequested(){return this.state==="errored"||this.state==="loaded"||this.state==="reloading"}clearTextures(e){this.demTexture&&e.saveTileTexture(this.demTexture),this.demTexture=null}getRTT(e){return this.rttObjects[e]}acquireRTT(e,t,i){return this.rttObjects[t]=e.acquireRTT(i)}releaseRTT(e){if(this.rttObjects.length!==0){for(let t of this.rttObjects)t&&e.releaseRTT(t);this.rttObjects.length=0}}loadVectorData(e,t,i){if(e?.etagUnmodified===!0){this.state="loaded";return}if(this.hasData()&&this.unloadVectorData(),this.state="loaded",!e){this.collisionBoxArray=new S0;return}e.featureIndex&&(this.latestFeatureIndex=e.featureIndex,e.rawTileData?(this.latestRawTileData=e.rawTileData,this.latestEncoding=e.encoding,this.latestFeatureIndex.rawTileData=e.rawTileData,this.latestFeatureIndex.encoding=e.encoding):this.latestRawTileData&&(this.latestFeatureIndex.rawTileData=this.latestRawTileData,this.latestFeatureIndex.encoding=this.latestEncoding)),this.collisionBoxArray=e.collisionBoxArray,this.buckets=nA(e.buckets,t),this.hasSymbolBuckets=!1;for(let r in this.buckets){let a=this.buckets[r];if(a instanceof ml)if(this.hasSymbolBuckets=!0,i)a.justReloaded=!0;else break}if(this.hasRTLText=!1,this.hasSymbolBuckets)for(let r in this.buckets){let a=this.buckets[r];if(a instanceof ml&&a.hasRTLText){this.hasRTLText=!0,_o().lazyLoad();break}}this.queryPadding=0;for(let r in this.buckets){let a=this.buckets[r];this.queryPadding=Math.max(this.queryPadding,t.getLayer(r).queryRadius(a))}e.imageAtlas&&(this.imageAtlas=e.imageAtlas),e.glyphAtlasImage&&(this.glyphAtlasImage=e.glyphAtlasImage),this.dashPositions=e.dashPositions}unloadVectorData(){for(let e in this.buckets)this.buckets[e].destroy();this.buckets={},this.imageAtlasTexture&&this.imageAtlasTexture.destroy(),this.glyphAtlasTexture&&this.glyphAtlasTexture.destroy(),this.imageAtlas=null,this.dashPositions=null,this.latestFeatureIndex=null,this.state="unloaded"}getBucket(e){return this.buckets[e.id]}upload(e){for(let i in this.buckets){let r=this.buckets[i];r.uploadPending()&&r.upload(e)}let t=e.gl;this.imageAtlas&&!this.imageAtlas.uploaded&&(this.imageAtlasTexture=new pt(e,this.imageAtlas.image,t.RGBA),this.imageAtlas.uploaded=!0),this.glyphAtlasImage&&(this.glyphAtlasImage=(this.glyphAtlasTexture=new pt(e,this.glyphAtlasImage,t.ALPHA),null))}prepare(e){this.imageAtlas&&this.imageAtlas.patchUpdatedImages(e,this.imageAtlasTexture)}queryRenderedFeatures(e,t,i,r,a,n,o,s,l,u,h){return this.latestFeatureIndex?.rawTileData?this.latestFeatureIndex.query({queryGeometry:r,cameraQueryGeometry:a,scale:n,tileSize:this.tileSize,pixelPosMatrix:u,transform:s,params:o,queryPadding:this.queryPadding*l,getElevation:h},e,t,i):{}}querySourceFeatures(e,t){let i=this.latestFeatureIndex;if(!i?.rawTileData)return;let r=i.loadVTLayers(),a=t?.sourceLayer?t.sourceLayer:"",n=r._geojsonTileLayer||r[a];if(!n)return;let o=ro(t?.filter,`querySourceFeatures[${a}].filter`,t?.globalState),{z:s,x:l,y:u}=this.tileID.canonical,h={z:s,x:l,y:u};for(let c=0;c<n.length;c++){let d=n.feature(c);if(o.needGeometry){let f=la(d,!0);if(!o.filter(new Ae(this.tileID.overscaledZ),f,this.tileID.canonical))continue}else if(!o.filter(new Ae(this.tileID.overscaledZ),d))continue;let p=new nv(d,s,l,u,i.getId(d,a));p.tile=h,e.push(p)}}hasData(){return this.state==="loaded"||this.state==="reloading"||this.state==="expired"}patternsLoaded(){return this.imageAtlas&&!!Object.keys(this.imageAtlas.patternPositions).length}setExpiryData(e){let t=this.expirationTime;if(e.cacheControl){let i=ew(e.cacheControl);i["max-age"]&&(this.expirationTime=Date.now()+i["max-age"]*1e3)}else e.expires&&(this.expirationTime=new Date(e.expires).getTime());if(this.expirationTime){let i=Date.now(),r=!1;if(this.expirationTime>i)r=!1;else if(!t)r=!0;else if(this.expirationTime<t)r=!0;else{let a=this.expirationTime-t;a?this.expirationTime=i+Math.max(a,3e4):r=!0}r?(this.expiredRequestCount++,this.state="expired"):this.expiredRequestCount=0}}getExpiryTimeout(){if(this.expirationTime)return this.expiredRequestCount?1e3*(1<<Math.min(this.expiredRequestCount-1,31)):Math.min(this.expirationTime-new Date().getTime(),2**31-1)}setFeatureState(e,t,i){if(!this.latestFeatureIndex?.rawTileData||Object.keys(e).length===0||this.featureStateRevision===i)return;this.featureStateRevision=i;let r=this.latestFeatureIndex.loadVTLayers();for(let a in this.buckets){if(!t.hasLayer(a))continue;let n=this.buckets[a],o=n.layers[0].sourceLayer||"_geojsonTileLayer",s=r[o],l=e[o];if(!s||!l||l.length===0)continue;n.update(l,s,this.imageAtlas?.patternPositions||{},this.dashPositions||{});let u=t.getLayer(a);u&&(this.queryPadding=Math.max(this.queryPadding,u.queryRadius(n)))}}holdingForSymbolFade(){return this.symbolFadeHoldUntil!==void 0}symbolFadeFinished(){return!this.symbolFadeHoldUntil||this.symbolFadeHoldUntil<Ie()}clearSymbolFadeHold(){this.symbolFadeHoldUntil=void 0}setSymbolHoldDuration(e){this.symbolFadeHoldUntil=Ie()+e}setDependencies(e,t){let i={};for(let r of t)i[r]=!0;this.dependencies[e]=i}hasDependency(e,t){for(let i of e){let r=this.dependencies[i];if(r){for(let a of t)if(r[a])return!0}}return!1}},GM=class{constructor(e,t){this.max=e,this.onRemove=t,this.reset()}reset(){for(let e in this.data)for(let t of this.data[e])t.timeout&&clearTimeout(t.timeout),this.onRemove(t.value);return this.data={},this.order=[],this}add(e,t,i){let r=e.wrapped().key;this.data[r]===void 0&&(this.data[r]=[]);let a={value:t,timeout:void 0};if(i!==void 0&&(a.timeout=setTimeout(()=>{this.remove(e,a)},i)),this.data[r].push(a),this.order.push(r),this.order.length>this.max){let n=this._getAndRemoveByKey(this.order[0]);n&&this.onRemove(n)}return this}has(e){return e.wrapped().key in this.data}getAndRemove(e){return this.has(e)?this._getAndRemoveByKey(e.wrapped().key):null}_getAndRemoveByKey(e){let t=this.data[e].shift();return t.timeout&&clearTimeout(t.timeout),this.data[e].length===0&&delete this.data[e],this.order.splice(this.order.indexOf(e),1),t.value}getByKey(e){let t=this.data[e];return t?t[0].value:null}get(e){return this.has(e)?this.data[e.wrapped().key][0].value:null}remove(e,t){if(!this.has(e))return this;let i=e.wrapped().key,r=t===void 0?0:this.data[i].indexOf(t),a=this.data[i][r];return this.data[i].splice(r,1),a.timeout&&clearTimeout(a.timeout),this.data[i].length===0&&delete this.data[i],this.onRemove(a.value),this.order.splice(this.order.indexOf(i),1),this}setMaxSize(e){for(this.max=e;this.order.length>this.max;){let t=this._getAndRemoveByKey(this.order[0]);t&&this.onRemove(t)}return this}filter(e){let t=[];for(let i in this.data)for(let r of this.data[i])e(r.value)||t.push(r);for(let i of t)this.remove(i.value.tileID,i)}};function Cg(e){let t=[];for(let i in e)t.push({id:i,state:e[i]});return t}var ZM=class{constructor(){this.state={},this.stateChanges={},this.deletedStates={},this.revision=0}updateState(e,t,i){var a,n;let r=String(t);if((a=this.stateChanges)[e]||(a[e]={}),(n=this.stateChanges[e])[r]||(n[r]={}),q(this.stateChanges[e][r],i),this.deletedStates[e]===null){this.deletedStates[e]={};for(let o in this.state[e])if(o===r){this.deletedStates[e][r]={};for(let s in this.state[e][o])i[s]===void 0&&(this.deletedStates[e][r][s]=null)}else this.deletedStates[e][o]=null}else if(this.deletedStates[e]?.[r]===null){this.deletedStates[e][r]={};for(let o in this.state[e][r])i[o]===void 0&&(this.deletedStates[e][r][o]=null)}else for(let o in i)this.deletedStates[e]?.[r]?.[o]===null&&delete this.deletedStates[e][r][o]}removeFeatureState(e,t,i){var a,n;if(this.deletedStates[e]===null)return;let r=String(t);if((a=this.deletedStates)[e]||(a[e]={}),i&&t!==void 0)this.deletedStates[e][r]!==null&&((n=this.deletedStates[e])[r]||(n[r]={}),this.deletedStates[e][r][i]=null);else if(t!==void 0)if(this.stateChanges[e]?.[r])for(i in this.deletedStates[e][r]={},this.stateChanges[e][r])this.deletedStates[e][r][i]=null;else this.deletedStates[e][r]=null;else this.deletedStates[e]=null}getState(e,t){let i=String(t),r=this.state[e]||{},a=this.stateChanges[e]||{},n=q({},r[i],a[i]);if(this.deletedStates[e]===null)return{};if(this.deletedStates[e]){let o=this.deletedStates[e][t];if(o===null)return{};for(let s in o)delete n[s]}return n}initializeTileState(e,t){let i={};for(let r in this.state)i[r]=Cg(this.state[r]);e.setFeatureState(i,t,this.revision)}coalesceChanges(e,t){var a,n,o;let i={};for(let s in this.stateChanges){(a=this.state)[s]||(a[s]={}),i[s]||(i[s]={});for(let l in this.stateChanges[s])(n=this.state[s])[l]||(n[l]={}),q(this.state[s][l],this.stateChanges[s][l]),i[s][l]=this.state[s][l]}for(let s in this.deletedStates)if((o=this.state)[s]||(o[s]={}),i[s]||(i[s]={}),this.deletedStates[s]===null)for(let l in this.state[s])this.state[s][l]={},i[s][l]={};else for(let l in this.deletedStates[s]){if(this.deletedStates[s][l]===null)this.state[s][l]={};else for(let u of Object.keys(this.deletedStates[s][l]))delete this.state[s][l][u];i[s][l]=this.state[s][l]}if(this.stateChanges={},this.deletedStates={},Object.keys(i).length===0)return;this.revision++;let r={};for(let s in i)r[s]=Cg(i[s]);e.setFeatureState(r,t,this.revision)}},Tp=class Ov{constructor(t,i){this.min=t,this.max=i,this.center=Ue([],yi([],this.min,this.max),.5)}quadrant(t){let i=[t%2==0,t<2],r=Ph(this.min),a=Ph(this.max);for(let n=0;n<i.length;n++)r[n]=i[n]?this.min[n]:this.center[n],a[n]=i[n]?this.center[n]:this.max[n];return a[2]=this.max[2],new Ov(r,a)}distanceX(t){return Math.max(Math.min(this.max[0],t[0]),this.min[0])-t[0]}distanceY(t){return Math.max(Math.min(this.max[1],t[1]),this.min[1])-t[1]}intersectsFrustum(t){let i=!0;for(let r of t.planes){let a=this.intersectsPlane(r);if(a===0)return 0;a===1&&(i=!1)}return i?2:t.aabb.min[0]>this.max[0]||t.aabb.min[1]>this.max[1]||t.aabb.min[2]>this.max[2]||t.aabb.max[0]<this.min[0]||t.aabb.max[1]<this.min[1]||t.aabb.max[2]<this.min[2]?0:1}intersectsPlane(t){let i=t[3],r=t[3];for(let a=0;a<3;a++)t[a]>0?(i+=t[a]*this.min[a],r+=t[a]*this.max[a]):(r+=t[a]*this.min[a],i+=t[a]*this.max[a]);return i>=0?2:r<0?0:1}},Ep=class jv{constructor(t,i,r){this.points=t,this.planes=i,this.aabb=r}static fromInvProjectionMatrix(t,i=1,r=0,a,n){let o=[[-1,1,-1,1],[1,1,-1,1],[1,-1,-1,1],[-1,-1,-1,1],[-1,1,1,1],[1,1,1,1],[1,-1,1,1],[-1,-1,1,1]],s=n?[[6,5,4],[0,1,2],[0,3,7],[2,1,5],[3,2,6],[0,4,5]]:[[0,1,2],[6,5,4],[0,3,7],[2,1,5],[3,2,6],[0,4,5]],l=2**r,u=o.map(p=>qM(p,t,i,l));a&&WM(u,s[0],a,n);let h=s.map(p=>{let f=Vt([],Yt([],lr([],u[p[0]],u[p[1]]),lr([],u[p[2]],u[p[1]]))),m=-ut(f,u[p[1]]);return f.concat(m)}),c=[1/0,1/0,1/0],d=[-1/0,-1/0,-1/0];for(let p of u)for(let f=0;f<3;f++)c[f]=Math.min(c[f],p[f]),d[f]=Math.max(d[f],p[f]);return new jv(u,h,new Tp(c,d))}};function qM(e,t,i,r){let a=Pt([],e,t),n=1/a[3]/i*r;return jb(a,a,[n,n,1/a[3],n])}function WM(e,t,i,r){let a=r?4:0,n=r?0:4,o=0,s=[],l=[];for(let c=0;c<4;c++){let d=lr([],e[c+n],e[c+a]),p=Pi(d);Ue(d,d,1/p),s.push(p),l.push(d)}for(let c=0;c<4;c++){let d=qb(e[c+a],l[c],i);o=d!==null&&d>=0?Math.max(o,d):Math.max(o,s[c])}let u=HM(e,t),h=XM(i,u);if(h!==null){let c=h/ut(l[0],u);o=Math.min(o,c)}for(let c=0;c<4;c++){let d=Math.min(o,s[c]);e[c+n]=[e[c+a][0]+l[c][0]*d,e[c+a][1]+l[c][1]*d,e[c+a][2]+l[c][2]*d,1]}}function HM(e,t){let i=lr([],e[t[0]],e[t[1]]),r=lr([],e[t[2]],e[t[1]]),a=[0,0,0,0];return Vt(a,Yt([],i,r)),a[3]=-ut(a,e[t[0]]),a}function XM(e,t){let i=Bb([],e,1/Ws(e)),r=lr([],t,Ue([],i,ut(t,i))),a=Ws(r);if(a>0){let n=Math.sqrt(1-i[3]*i[3]);return Ih(t,yi([],Ue([],i,-i[3]),Ue([],r,n/a)))}return null}function YM(e,t,i){let r=t.intersectsFrustum(e);if(!i||r===0)return r;let a=t.intersectsPlane(i);return a===0?0:r===2&&a===2?2:1}function Pg(e,t,i){let r=0,a=(i-t)/10;for(let n=0;n<10;n++){let o=t+(n+.5)/10*(i-t);r+=a*Math.cos(o)**+e}return r}function Jc(e,t){return function(i,r,a,n,o){let s=2*((e-1)/Mt(Math.cos(je(La-o))/Math.cos(je(La)))-1),l=Math.acos(a/n),u=2*Pg(s-1,0,je(o/2)),h=Math.min(je(La),l+je(o/2)),c=Math.min(h,l-je(o/2)),d=Pg(s-1,c,h),p=Math.atan(r/a),f=Math.hypot(r,a),m=i;return m+=Mt(n/f/Math.max(.5,Math.cos(je(o/2)))),m+=s*Mt(Math.cos(p))/2,m-=Mt(Math.max(1,d/u/t))/2,m}}var KM=Jc(9.314,3);function Dp(e,t){let i=(t.roundZoom?Math.round:Math.floor)(e.zoom+Mt(e.tileSize/t.tileSize));return Math.max(0,i)}function JM(e,t){let i=ie((15-(La-e.pitch-e.fov/2))/15,0,1),r=Math.max(500,t??0);return e.elevation+i*r}function QM(e,t,i){let r=e.planes[1],a=e.points.map(l=>{let u=r[0]*l[0]+r[1]*l[1]+r[2]*l[2]+r[3];if(Math.abs(u)>1e-6)return l;let h=[l[0]-i[0],l[1]-i[1],l[2]-i[2]],c=r[0]*h[0]+r[1]*h[1]+r[2]*h[2];if(c>=-1e-9)return l;let d=t/-c;return[l[0]+h[0]*d,l[1]+h[1]*d,l[2]+h[2]*d,l[3]]}),n=e.planes.map((l,u)=>u===1?[l[0],l[1],l[2],l[3]+t]:l),o=[1/0,1/0,1/0],s=[-1/0,-1/0,-1/0];for(let l of a)for(let u=0;u<3;u++)o[u]=Math.min(o[u],l[u]),s[u]=Math.max(s[u],l[u]);return new Ep(a,n,new Tp(o,s))}function e3(e,t,i,r){let a=Math.hypot(t[0],t[1],t[2]);if(a===0)return{frustum:e,plane:t};let n=1+r/jt,o=ie(-t[3]/a,-1,1),s=Math.cos(Math.acos(o)+Math.acos(1/n));return{frustum:QM(e,Math.sqrt(n*n-1),i),plane:[t[0],t[1],t[2],-s*a]}}function Mo(e,t){let i=e.getCameraFrustum(),r=e.getClippingPlane();r&&t.maxContentElevation>0&&({frustum:i,plane:r}=e3(i,r,e.cameraPosition,t.maxContentElevation));let a=e.getCoveringTilesDetailsProvider(),n=a.getCenter(e),o=ED(e,n),s=De.fromLngLat(n,e.elevation),l=JM(e,t.maxContentElevation),u=a.allowVariableZoom(e,t),h=Dp(e,t),c=t.minzoom||0,d=t.maxzoom===void 0?e.maxZoom:t.maxzoom,p=Math.min(Math.max(0,h),d),f=2**p,m=[f*o.x,f*o.y,0],g=[f*s.x,f*s.y,0],_=Math.hypot(s.x-o.x,s.y-o.y),y=Math.abs(s.z-o.z),v=Math.hypot(_,y),x=T=>({zoom:0,x:0,y:0,wrap:T,fullyVisible:!1}),b=[],w=[];if(e.renderWorldCopies&&a.allowWorldCopies())for(let T=1;T<=3;T++)b.push(x(-T)),b.push(x(T));for(b.push(x(0));b.length>0;){let T=b.pop(),E=T.x,S=T.y,M=T.fullyVisible,z={x:E,y:S,z:T.zoom},R=a.getTileBoundingVolume(z,T.wrap,l,t);if(!M){let A=YM(i,R,r);if(A===0)continue;M=A===2}let I=a.distanceToTile2d(o.x,o.y,z,R),D=h;u&&(D=(t.calculateTileZoom||KM)(e.zoom+Mt(e.tileSize/t.tileSize),I,y,v,e.fov)),D=(t.roundZoom?Math.round:Math.floor)(D),D=Math.max(0,D);let P=Math.min(D,d);if(T.wrap=a.getWrap(s,z,T.wrap),T.zoom>=P){if(T.zoom<c)continue;let A=p-T.zoom,B=m[0]-.5-(E<<A),j=m[1]-.5-(S<<A),V=t.reparseOverscaled?Math.max(T.zoom,D):T.zoom;w.push({tileID:new Ct(T.zoom===d?V:T.zoom,T.wrap,T.zoom,E,S),distanceSq:Zb([g[0]-.5-E,g[1]-.5-S]),tileDistanceToCamera:Math.sqrt(B*B+j*j)});continue}for(let A=0;A<4;A++){let B=(E<<1)+A%2,j=(S<<1)+(A>>1),V=T.zoom+1;b.push({zoom:V,x:B,y:j,wrap:T.wrap,fullyVisible:M})}}return w.sort((T,E)=>T.distanceSq-E.distanceSq).map(T=>T.tileID)}function Ag(e){return e==="raster"||e==="image"||e==="video"}function t3(e,t,i,r,a,n,o){let s=Ie(),l=Hb(t);for(let u of t){let h=e.getTileById(u.key);(h.fadingDirection===0||h.fadeOpacity===0)&&h.resetFadeLogic(),!i3(e,h,i,s,r,a,o)&&(r3(e,h,i,s,n,o)||a3(h,l,s,o)||h.resetFadeLogic())}}function i3(e,t,i,r,a,n,o){if(!t.hasData())return!1;let{tileID:s,fadingRole:l,fadingDirection:u,fadingParentID:h}=t;if(l===0&&u===1&&h)return i[h.key]=h,!0;let c=Math.max(s.overscaledZ-a,n);for(let d=s.overscaledZ-1;d>=c;d--){let p=s.scaledTo(d),f=e.getLoadedTile(p);if(f)return t.setCrossFadeLogic({fadingRole:0,fadingDirection:1,fadingParentID:f.tileID,fadeEndTime:r+o}),f.setCrossFadeLogic({fadingRole:1,fadingDirection:0,fadeEndTime:r+o}),i[p.key]=p,!0}return!1}function r3(e,t,i,r,a,n){if(!t.hasData())return!1;let o=t.tileID.children(a),s=Ig(e,t,o,i,r,a,n);if(s)return!0;for(let l of o)Ig(e,t,l.children(a),i,r,a,n)&&(s=!0);return s}function Ig(e,t,i,r,a,n,o){if(i[0].overscaledZ>n)return!1;let s=!1;for(let l of i){let u=e.getLoadedTile(l);if(!u)continue;let{fadingRole:h,fadingDirection:c,fadingParentID:d}=u;(h!==0||c!==0||!d)&&(u.setCrossFadeLogic({fadingRole:0,fadingDirection:0,fadingParentID:t.tileID,fadeEndTime:a+o}),t.setCrossFadeLogic({fadingRole:1,fadingDirection:1,fadeEndTime:a+o})),r[l.key]=l,s=!0}return s}function a3(e,t,i,r){let a=e.tileID;if(e.selfFading)return!0;if(e.hasData())return!1;if(t.has(a)){let n=i+r;return e.setSelfFadeLogic(n),!0}return!1}function n3(e,t){if(t<=0)return!1;let i=Ie();for(let r of e.getAllTiles())if(r.fadeEndTime>=i)return!0;return!1}function o3(e,t){let i=t.getRenderableIds();for(let r of i){if(!e.neighboringTiles?.[r])continue;let a=t.getTileById(r);e.neighboringTiles[r].backfilled||Mg(e,a),!a.neighboringTiles?.[e.tileID.key]?.backfilled&&Mg(a,e)}}function Mg(e,t){e.needsHillshadePrepare=!0,e.needsTerrainPrepare=!0,e.needsColorReliefPrepare=!0;let i=t.tileID.canonical.x-e.tileID.canonical.x,r=t.tileID.canonical.y-e.tileID.canonical.y,a=2**e.tileID.canonical.z,n=t.tileID.key;(i!==0||r!==0)&&(Math.abs(r)>1||(Math.abs(i)>1&&(Math.abs(i+a)===1?i+=a:Math.abs(i-a)===1&&(i-=a)),t.dem&&e.dem&&(e.dem.backfillBorder(t.dem,i,r),e.neighboringTiles?.[n]&&(e.neighboringTiles[n].backfilled=!0))))}var Fg=class{constructor(){this._tiles={}}handleWrapJump(e){let t={};for(let i in this._tiles){let r=this._tiles[i];r.tileID=r.tileID.unwrapTo(r.tileID.wrap+e),t[r.tileID.key]=r}this._tiles=t}setFeatureState(e,t,i){for(let r in this._tiles)this._tiles[r].setFeatureState(e,t,i)}getAllTiles(){return Object.values(this._tiles)}getAllIds(e=!1){return e?Object.values(this._tiles).map(t=>t.tileID).sort(ug).map(t=>t.key):Object.keys(this._tiles)}getTileById(e){return this._tiles[e]}setTile(e,t){this._tiles[e]=t}deleteTileById(e){delete this._tiles[e]}getLoadedTile(e){let t=this.getTileById(e.key);return t?.hasData()?t:null}isIdRenderable(e,t=!1){return this.getTileById(e)?.isRenderable(t)}getRenderableIds(e=0,t){let i=[];for(let r of this.getAllIds())this.isIdRenderable(r,t)&&i.push(this.getTileById(r));return t?i.sort((r,a)=>{let n=r.tileID,o=a.tileID,s=new C(n.canonical.x,n.canonical.y)._rotate(-e),l=new C(o.canonical.x,o.canonical.y)._rotate(-e);return n.overscaledZ-o.overscaledZ||l.y-s.y||l.x-s.x}).map(r=>r.tileID.key):i.map(r=>r.tileID).sort(ug).map(r=>r.key)}},sr,Qc=(sr=class extends ht{constructor(t,i,r){super(),this._maxContentElevationSeen=0,this.id=t,this.dispatcher=r,this.on("data",a=>{this._dataHandler(a)}),this.on("dataloading",()=>{this._sourceErrored=!1}),this.on("error",()=>{this._sourceErrored=this._source.loaded()}),this._source=iA(t,i,r,this),this._inViewTiles=new Fg,this._outOfViewCache=new GM(0,a=>this._unloadTile(a)),this._timers={},this._maxTileCacheSize=null,this._maxTileCacheZoomLevels=null,this._rasterFadeDuration=0,this._maxFadingAncestorLevels=5,this._state=new ZM,this._didEmitContent=!1,this._updated=!1}onAdd(t){this.map=t,this._maxTileCacheSize=t?t._maxTileCacheSize:null,this._maxTileCacheZoomLevels=t?t._maxTileCacheZoomLevels:null,this._source?.onAdd&&this._source.onAdd(t)}onRemove(t){for(let i of this._inViewTiles.getAllTiles())i.unloadVectorData();this.clearTiles(),this._source?.onRemove&&this._source.onRemove(t),this._inViewTiles=new Fg}loaded(){if(this._sourceErrored)return!0;if(!this._sourceLoaded||!this._source.loaded())return!1;if((this.used!==void 0||this.usedForTerrain!==void 0)&&!this.used&&!this.usedForTerrain)return!0;if(!this._updated)return!1;for(let t of this._inViewTiles.getAllTiles())if(t.state!=="loaded"&&t.state!=="errored")return!1;return!0}getSource(){return this._source}getState(){return this._state}pause(){this._paused=!0}resume(){if(!this._paused)return;let t=this._shouldReloadOnResume;this._paused=!1,this._shouldReloadOnResume=!1,t&&this.reload(),this.transform&&this.update(this.transform,this.terrain)}async _loadTile(t,i,r,a){try{let n=await this._source.loadTile(t);this._tileLoaded(t,i,r,a,n)}catch(n){t.state="errored",n.status===404?this.update(this.transform,this.terrain):this._source.fire(new Y(bt(n),{tile:t}))}}_unloadTile(t){this._source.unloadTile&&this._source.unloadTile(t)}_abortTile(t){this._source.abortTile&&this._source.abortTile(t),this._source.fire(new Ne("dataabort",{tile:t,coord:t.tileID}))}serialize(){return this._source.serialize()}prepare(t){this._source.prepare&&this._source.prepare(),this._state.coalesceChanges(this._inViewTiles,this.style);for(let i of this._inViewTiles.getAllTiles())i.upload(t),i.prepare(this.map.style.imageManager)}getIds(){return this._inViewTiles.getAllIds(!0)}getRenderableIds(t){return this._inViewTiles.getRenderableIds(this.transform?.bearingInRadians,t)}hasRenderableParent(t){let i=t.overscaledZ-1;if(i>=this._source.minzoom){let r=this.getLoadedTile(t.scaledTo(i));if(r)return this._inViewTiles.isIdRenderable(r.tileID.key)}return!1}reload(t,i=void 0){if(this._paused){this._shouldReloadOnResume=!0;return}this._outOfViewCache.reset();for(let r of this._inViewTiles.getAllIds()){let a=this._inViewTiles.getTileById(r);(!i||this._source.shouldReloadTile(a,i))&&(t?this._reloadTile(r,a.state==="errored"?"loading":"expired"):a.state!=="errored"&&this._reloadTile(r,"reloading"))}}async _reloadTile(t,i){let r=this._inViewTiles.getTileById(t);if(!r)return;let a=r.hasData();r.state!=="loading"&&(r.state=i),await this._loadTile(r,t,i,a)}_tileLoaded(t,i,r,a,n){a||(t.timeAdded=Ie(),t.selfFading&&(t.fadeEndTime=t.timeAdded+this._rasterFadeDuration)),r==="expired"&&(t.refreshedUponExpiration=!0),this._setTileReloadTimer(i,t),!n?.unmodified&&(this.getSource().type==="raster-dem"&&t.dem&&o3(t,this._inViewTiles),t.featureStateRevision=-1,this._state.initializeTileState(t,this.style),t.aborted||this._source.fire(new Ne("data",{tile:t,coord:t.tileID})))}getTile(t){return this.getTileByID(t.key)}getTileByID(t){return this._inViewTiles.getTileById(t)}_retainLoadedChildren(t,i){let r=this._getLoadedDescendents(i),a=new Set;for(let n of i){let o=r[n.key];if(!o?.length){a.add(n);continue}let s=n.overscaledZ+sr.maxOverzooming,l=o.filter(c=>c.tileID.overscaledZ<=s);if(!l.length){a.add(n);continue}let u=Math.min(...l.map(c=>c.tileID.overscaledZ)),h=l.filter(c=>c.tileID.overscaledZ===u).map(c=>c.tileID);for(let c of h)t[c.key]=c;this._areDescendentsComplete(h,u,n.overscaledZ)||a.add(n)}return a}_getLoadedDescendents(t){var r;let i={};for(let a of this._inViewTiles.getAllTiles().filter(n=>n.hasData()))for(let n of t)a.tileID.isChildOf(n)&&(i[r=n.key]||(i[r]=[]),i[n.key].push(a));return i}_areDescendentsComplete(t,i,r){return t.length===1&&t[0].isOverscaled()?t[0].overscaledZ===i:4**(i-r)===t.length}getLoadedTile(t){return this._inViewTiles.getLoadedTile(t)}updateCacheSize(t){let i=(Math.ceil(t.width/this._source.tileSize)+1)*(Math.ceil(t.height/this._source.tileSize)+1),r=this._maxTileCacheZoomLevels===null?si.MAX_TILE_CACHE_ZOOM_LEVELS:this._maxTileCacheZoomLevels,a=Math.floor(i*r),n=typeof this._maxTileCacheSize=="number"?Math.min(this._maxTileCacheSize,a):a;this._outOfViewCache.setMaxSize(n)}handleWrapJump(t){let i=(t-(this._prevLng===void 0?t:this._prevLng))/360,r=Math.round(i);this._prevLng=t,r&&(this._inViewTiles.handleWrapJump(r),this._resetTileReloadTimers())}_updateMaxContentElevation(){let t=this._maxContentElevationSeen,i=this.map?.style?._layers;if(!i)return t;let r=this._inViewTiles.getAllTiles();for(let a in i){let n=i[a];if(n.type!=="symbol"||n.source!==this.id||n.isHidden(this.transform.zoom))continue;let o=n;if(!o.layout)continue;let s=o.layout.get("symbol-height-offset");if(t=Math.max(t,s.constantOr(0)),!s.isConstant())for(let l of r){let u=l.getBucket(n);u&&u.maxHeightOffset>t&&(t=u.maxHeightOffset)}}return this._maxContentElevationSeen=t,t}update(t,i){if(!this._sourceLoaded||this._paused)return;this.transform=t,this.terrain=i,this.updateCacheSize(t),this.handleWrapJump(this.transform.center.lng);let r;!this.used&&!this.usedForTerrain?r=[]:this._source.tileID?r=t.getVisibleUnwrappedCoordinates(this._source.tileID).map(l=>new Ct(l.canonical.z,l.wrap,l.canonical.z,l.canonical.x,l.canonical.y)):(r=Mo(t,{tileSize:this.usedForTerrain?this.tileSize:this._source.tileSize,minzoom:this._source.minzoom,maxzoom:this._source.type==="vector"&&this.map._zoomLevelsToOverscale!==void 0?Math.max(this._source.maxzoom,t.maxZoom-this.map._zoomLevelsToOverscale):this._source.maxzoom,roundZoom:!this.usedForTerrain&&this._source.roundZoom,reparseOverscaled:this._source.reparseOverscaled,terrain:i,calculateTileZoom:this._source.calculateTileZoom,maxContentElevation:this._updateMaxContentElevation()}),this._source.hasTile&&(r=r.filter(l=>this._source.hasTile(l)))),this.usedForTerrain&&(r=this._addTerrainIdealTiles(r));let a=r.length===0&&!this._updated&&this._didEmitContent;this._updated=!0,a&&this.fire(new Ne("data",{sourceDataType:"idle",sourceId:this.id}));let n=Dp(t,this._source),o=this._updateRetainedTiles(r,n),s=Ag(this._source.type);s&&this._rasterFadeDuration>0&&!i&&t3(this._inViewTiles,r,o,this._maxFadingAncestorLevels,this._source.minzoom,this._source.maxzoom,this._rasterFadeDuration),s?this._cleanUpRasterTiles(o):this._cleanUpVectorTiles(o)}_cleanUpRasterTiles(t){for(let i of this._inViewTiles.getAllIds())t[i]||this._removeTile(i)}_cleanUpVectorTiles(t){for(let i of this._inViewTiles.getAllIds()){let r=this._inViewTiles.getTileById(i);if(t[i]){r.clearSymbolFadeHold();continue}if(!r.hasSymbolBuckets){this._removeTile(i);continue}r.holdingForSymbolFade()?r.symbolFadeFinished()&&this._removeTile(i):r.setSymbolHoldDuration(this.map._fadeDuration)}}_addTerrainIdealTiles(t){let i=[];for(let r of t)if(r.canonical.z>this._source.minzoom){let a=r.scaledTo(r.canonical.z-1);i.push(a);let n=r.scaledTo(Math.max(this._source.minzoom,Math.min(r.canonical.z,5)));i.push(n)}return t.concat(i)}releaseSymbolFadeTiles(){for(let t of this._inViewTiles.getAllIds())this._inViewTiles.getTileById(t).holdingForSymbolFade()&&this._removeTile(t)}_updateRetainedTiles(t,i){let r=new Set;for(let l of t)this._addTile(l).hasData()||r.add(l);let a=t.reduce((l,u)=>(l[u.key]=u,l),{}),n=this._retainLoadedChildren(a,r),o={},s=Math.max(i-sr.maxUnderzooming,this._source.minzoom);for(let l of n){let u=this._inViewTiles.getTileById(l.key),h=u?.wasRequested();for(let c=l.overscaledZ-1;c>=s;--c){let d=l.scaledTo(c);if(o[d.key])break;if(o[d.key]=!0,u=this.getTile(d),!u&&h&&(u=this._addTile(d)),u){let p=u.hasData();if((p||!this.map?.cancelPendingTileRequestsWhileZooming||h)&&(a[d.key]=d),h=u.wasRequested(),p)break}}}return a}_addTile(t){let i=this._inViewTiles.getTileById(t.key);if(i)return i;i=this._outOfViewCache.getAndRemove(t),i&&(i.resetFadeLogic(),this._setTileReloadTimer(t.key,i),i.tileID=t,this._state.initializeTileState(i,this.style));let r=i;return i||(i=new Bv(t,this._source.tileSize*t.overscaleFactor()),this._loadTile(i,t.key,i.state,!1)),i.uses++,this._inViewTiles.setTile(t.key,i),r||this._source.fire(new Ne("dataloading",{tile:i,coord:i.tileID})),i}_setTileReloadTimer(t,i){this._clearTileReloadTimer(t);let r=i.getExpiryTimeout();if(r){let a=()=>{this._reloadTile(t,"expired"),delete this._timers[t]};this._timers[t]=setTimeout(a,r)}}_clearTileReloadTimer(t){let i=this._timers[t];i&&(clearTimeout(i),delete this._timers[t])}_resetTileReloadTimers(){for(let t in this._timers)clearTimeout(this._timers[t]),delete this._timers[t];for(let t of this._inViewTiles.getAllIds()){let i=this._inViewTiles.getTileById(t);this._setTileReloadTimer(t,i)}}refreshTiles(t){for(let i of this._inViewTiles.getAllIds()){let r=this._inViewTiles.getTileById(i);(this._inViewTiles.isIdRenderable(i)||r.state=="errored")&&t.some(a=>a.equals(r.tileID.canonical))&&this._reloadTile(i,"expired")}}_removeTile(t){let i=this._inViewTiles.getTileById(t);i&&(i.uses--,this._inViewTiles.deleteTileById(t),this._clearTileReloadTimer(t),!(i.uses>0)&&(i.hasData()&&i.state!=="reloading"?this._outOfViewCache.add(i.tileID,i,i.getExpiryTimeout()):(i.aborted=!0,this._abortTile(i),this._unloadTile(i))))}_dataHandler(t){if(t.dataType==="source"){if(t.sourceDataType==="metadata"){this._sourceLoaded=!0;return}t.sourceDataType==="content"&&this._sourceLoaded&&!this._paused&&(this.reload(t.sourceDataChanged,t.shouldReloadTileOptions),this.transform&&this.update(this.transform,this.terrain),this._didEmitContent=!0)}}resetMaxContentElevation(){this._maxContentElevationSeen=0}clearTiles(){this._shouldReloadOnResume=!1,this._paused=!1,this.resetMaxContentElevation();for(let t of this._inViewTiles.getAllIds())this._removeTile(t);this._outOfViewCache.reset()}tilesIn(t,i,r){let a=[],n=this.transform;if(!n)return a;let o=n.getCoveringTilesDetailsProvider().allowWorldCopies(),s=r?n.getCameraQueryGeometry(t):t,l=p=>n.screenPointToMercatorCoordinate(p,this.terrain),u=this.transformBbox(t,l,!o),h=this.transformBbox(s,l,!o),c=this.getIds(),d=Ii.fromPoints(h);for(let p of c){let f=this._inViewTiles.getTileById(p);if(f.holdingForSymbolFade())continue;let m=o?[f.tileID]:[f.tileID.unwrapTo(-1),f.tileID.unwrapTo(0)],g=2**(n.zoom-f.tileID.overscaledZ),_=i*f.queryPadding*k/f.tileSize/g;for(let y of m){let v=d.map(x=>y.getTilePoint(new De(x.x,x.y)));if(v.expandBy(_),v.intersects(_D)){let x=u.map(w=>y.getTilePoint(w)),b=h.map(w=>y.getTilePoint(w));a.push({tile:f,tileID:o?y:y.unwrapTo(0),queryGeometry:x,cameraQueryGeometry:b,scale:g})}}}return a}transformBbox(t,i,r){let a=t.map(i);if(r){let n=Ii.fromPoints(t);n.shrinkBy(Math.min(n.width(),n.height())*.001);let o=n.map(i);Ii.fromPoints(a).covers(o)||(a=a.map(s=>s.x>.5?new De(s.x-1,s.y,s.z):s))}return a}getVisibleCoordinates(t){let i=this.getRenderableIds(t).map(r=>this._inViewTiles.getTileById(r).tileID);return this.transform&&this.transform.populateCache(i),i}hasTransition(){return this._source.hasTransition()?!0:Ag(this._source.type)&&n3(this._inViewTiles,this._rasterFadeDuration)}setRasterFadeDuration(t){this._rasterFadeDuration=t}setFeatureState(t,i,r){t||(t=Ns),this._state.updateState(t,i,r)}removeFeatureState(t,i,r){t||(t=Ns),this._state.removeFeatureState(t,i,r)}getFeatureState(t,i){return t||(t=Ns),this._state.getState(t,i)}setDependencies(t,i,r){let a=this._inViewTiles.getTileById(t);a&&a.setDependencies(i,r)}reloadTilesForDependencies(t,i){for(let r of this._inViewTiles.getAllIds())this._inViewTiles.getTileById(r).hasDependency(t,i)&&this._reloadTile(r,"reloading");this._outOfViewCache.filter(r=>!r.hasDependency(t,i))}areTilesLoaded(){for(let t of this._inViewTiles.getAllTiles())if(t.state!=="loaded"&&t.state!=="errored")return!1;return!0}},sr.maxUnderzooming=10,sr.maxOverzooming=3,sr),s3=class{constructor(e,t){this.reset(e,t)}reset(e,t){this.points=e||[],this._distances=[0];for(let i=1;i<this.points.length;i++)this._distances[i]=this._distances[i-1]+this.points[i].dist(this.points[i-1]);this.length=this._distances[this._distances.length-1],this.padding=Math.min(t||0,this.length*.5),this.paddedLength=this.length-this.padding*2}lerp(e){if(this.points.length===1)return this.points[0];e=ie(e,0,1);let t=1,i=this._distances[t],r=e*this.paddedLength+this.padding;for(;i<r&&t<this._distances.length;)i=this._distances[++t];let a=t-1,n=this._distances[a],o=i-n,s=o>0?(r-n)/o:0;return this.points[a].mult(1-s).add(this.points[t].mult(s))}};function Us(e,t,i,r,a){return a?e?e(t,i)+r:r===0?void 0:r:r}function xs(e,t){let i=!0;return e==="always"||(e==="never"||t==="never")&&(i=!1),i}var zg=class{constructor(e,t,i){let r=this.boxCells=[],a=this.circleCells=[];this.xCellCount=Math.ceil(e/i),this.yCellCount=Math.ceil(t/i);for(let n=0;n<this.xCellCount*this.yCellCount;n++)r.push([]),a.push([]);this.circleKeys=[],this.boxKeys=[],this.bboxes=[],this.circles=[],this.width=e,this.height=t,this.xScale=this.xCellCount/e,this.yScale=this.yCellCount/t,this.boxUid=0,this.circleUid=0}keysLength(){return this.boxKeys.length+this.circleKeys.length}insert(e,t,i,r,a){this._forEachCell(t,i,r,a,this._insertBoxCell,this.boxUid++),this.boxKeys.push(e),this.bboxes.push(t),this.bboxes.push(i),this.bboxes.push(r),this.bboxes.push(a)}insertCircle(e,t,i,r){this._forEachCell(t-r,i-r,t+r,i+r,this._insertCircleCell,this.circleUid++),this.circleKeys.push(e),this.circles.push(t),this.circles.push(i),this.circles.push(r)}_insertBoxCell(e,t,i,r,a,n){this.boxCells[a].push(n)}_insertCircleCell(e,t,i,r,a,n){this.circleCells[a].push(n)}_query(e,t,i,r,a,n,o){if(i<0||e>this.width||r<0||t>this.height)return[];let s=[];if(e<=0&&t<=0&&this.width<=i&&this.height<=r){if(a)return[{key:null,x1:e,y1:t,x2:i,y2:r}];for(let l=0;l<this.boxKeys.length;l++)s.push({key:this.boxKeys[l],x1:this.bboxes[l*4],y1:this.bboxes[l*4+1],x2:this.bboxes[l*4+2],y2:this.bboxes[l*4+3]});for(let l=0;l<this.circleKeys.length;l++){let u=this.circles[l*3],h=this.circles[l*3+1],c=this.circles[l*3+2];s.push({key:this.circleKeys[l],x1:u-c,y1:h-c,x2:u+c,y2:h+c})}}else{let l={hitTest:a,overlapMode:n,seenUids:{box:{},circle:{}}};this._forEachCell(e,t,i,r,this._queryCell,s,l,o)}return s}query(e,t,i,r){return this._query(e,t,i,r,!1,null)}hitTest(e,t,i,r,a,n){return this._query(e,t,i,r,!0,a,n).length>0}hitTestCircle(e,t,i,r,a){let n=e-i,o=e+i,s=t-i,l=t+i;if(o<0||n>this.width||l<0||s>this.height)return!1;let u=[],h={hitTest:!0,overlapMode:r,circle:{x:e,y:t,radius:i},seenUids:{box:{},circle:{}}};return this._forEachCell(n,s,o,l,this._queryCellCircle,u,h,a),u.length>0}_queryCell(e,t,i,r,a,n,o,s){let{seenUids:l,hitTest:u,overlapMode:h}=o,c=this.boxCells[a],d=1e-6;if(c!==null){let f=this.bboxes;for(let m of c)if(!l.box[m]){l.box[m]=!0;let g=m*4,_=this.boxKeys[m];if(e<=f[g+2]+d&&t<=f[g+3]+d&&i>=f[g+0]-d&&r>=f[g+1]-d&&(!s||s(_))&&(!u||!xs(h,_.overlapMode))&&(n.push({key:_,x1:f[g],y1:f[g+1],x2:f[g+2],y2:f[g+3]}),u))return!0}}let p=this.circleCells[a];if(p!==null){let f=this.circles;for(let m of p)if(!l.circle[m]){l.circle[m]=!0;let g=m*3,_=this.circleKeys[m];if(this._circleAndRectCollide(f[g],f[g+1],f[g+2],e,t,i,r)&&(!s||s(_))&&(!u||!xs(h,_.overlapMode))){let y=f[g],v=f[g+1],x=f[g+2];if(n.push({key:_,x1:y-x,y1:v-x,x2:y+x,y2:v+x}),u)return!0}}}return!1}_queryCellCircle(e,t,i,r,a,n,o,s){let{circle:l,seenUids:u,overlapMode:h}=o,c=this.boxCells[a];if(c!==null){let p=this.bboxes;for(let f of c)if(!u.box[f]){u.box[f]=!0;let m=f*4,g=this.boxKeys[f];if(this._circleAndRectCollide(l.x,l.y,l.radius,p[m+0],p[m+1],p[m+2],p[m+3])&&(!s||s(g))&&!xs(h,g.overlapMode))return n.push(!0),!0}}let d=this.circleCells[a];if(d!==null){let p=this.circles;for(let f of d)if(!u.circle[f]){u.circle[f]=!0;let m=f*3,g=this.circleKeys[f];if(this._circlesCollide(p[m],p[m+1],p[m+2],l.x,l.y,l.radius)&&(!s||s(g))&&!xs(h,g.overlapMode))return n.push(!0),!0}}}_forEachCell(e,t,i,r,a,n,o,s){let l=this._convertToXCellCoord(e),u=this._convertToYCellCoord(t),h=this._convertToXCellCoord(i),c=this._convertToYCellCoord(r);for(let d=l;d<=h;d++)for(let p=u;p<=c;p++){let f=this.xCellCount*p+d;if(a.call(this,e,t,i,r,f,n,o,s))return}}_convertToXCellCoord(e){return Math.max(0,Math.min(this.xCellCount-1,Math.floor(e*this.xScale)))}_convertToYCellCoord(e){return Math.max(0,Math.min(this.yCellCount-1,Math.floor(e*this.yScale)))}_circlesCollide(e,t,i,r,a,n){let o=r-e,s=a-t,l=i+n;return l*l>o*o+s*s}_circleAndRectCollide(e,t,i,r,a,n,o){let s=(n-r)/2,l=Math.abs(e-(r+s));if(l>s+i)return!1;let u=(o-a)/2,h=Math.abs(t-(a+u));if(h>u+i)return!1;if(l<=s||h<=u)return!0;let c=l-s,d=h-u;return c*c+d*d<=i*i}};function l3(e,t){let i=1/(t[0]*t[0]+t[1]*t[1]+t[2]*t[2]),r=1/(t[8]*t[8]+t[9]*t[9]+t[10]*t[10]),a=t[0]*i,n=t[4]*i,o=t[8]*r,s=t[1]*i,l=t[5]*i,u=t[9]*r,h=t[2]*i,c=t[6]*i,d=t[10]*r;e[0]=a,e[1]=n,e[2]=o,e[4]=s,e[5]=l,e[6]=u,e[8]=h,e[9]=c,e[10]=d;let p=t[12],f=t[13],m=t[14];return e[12]=-a*p-s*f-h*m,e[13]=-n*p-l*f-c*m,e[14]=-o*p-u*f-d*m,e[3]=0,e[7]=0,e[11]=0,e[15]=1,e}function u3(e,t){return e[0]=1/t[0],e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[5]=1/t[5],e[6]=0,e[7]=0,e[8]=0,e[9]=0,e[10]=0,e[11]=1/t[14],e[12]=0,e[13]=0,e[14]=-1,e[15]=t[10]/t[14],e}function h3(e,t){let i=1/(t[0]*t[5]-t[1]*t[4]);return e[0]=t[5]*i,e[1]=-t[1]*i,e[2]=0,e[3]=0,e[4]=-t[4]*i,e[5]=t[0]*i,e[6]=0,e[7]=0,e[8]=0,e[9]=0,e[10]=1/t[10],e[11]=0,e[12]=0,e[13]=0,e[14]=0,e[15]=1/t[15],e}var c3=na();function Sp(e,t,i){let r=na();if(!e){let{vecSouth:a,vecEast:n}=Cp(t),o=R_();o[0]=n[0],o[1]=n[1],o[2]=a[0],o[3]=a[1],gb(o,o),r[0]=o[0],r[1]=o[1],r[4]=o[2],r[5]=o[3]}return kt(r,r,[1/i,1/i,1]),r}function d3(e,t,i,r){if(e){let a=na();if(!t){let{vecSouth:n,vecEast:o}=Cp(i);a[0]=o[0],a[1]=o[1],a[4]=n[0],a[5]=n[1]}return kt(a,a,[r,r,1]),a}return i.pixelsToClipSpaceMatrix}function Cp(e){let t=Math.cos(e.rollInRadians),i=Math.sin(e.rollInRadians),r=Math.cos(e.pitchInRadians),a=Math.cos(e.bearingInRadians),n=Math.sin(e.bearingInRadians),o=Ah();o[0]=-a*r*i-n*t,o[1]=-n*r*i+a*t;let s=bf(o);s<1e-9?wf(o):xf(o,o,1/s);let l=Ah();l[0]=a*r*t-n*i,l[1]=n*r*t+a*i;let u=bf(l);return u<1e-9?wf(l):xf(l,l,1/u),{vecEast:l,vecSouth:o}}function ia(e,t,i){return Us(e.getElevation,t,i,e.heightOffset??0,e.heightAnchorGround??!0)}function Pp(e,t,i,r){let a;r==null?(a=[e,t,0,1],Ap(a,a,i)):(a=[e,t,r,1],Pt(a,a,i));let n=a[3];return{point:new C(a[0]/n,a[1]/n),signedDistanceFromCamera:n,isOccluded:!1}}function Vv(e,t){return .5+e/t*.5}function p3(e,t){return e.x>=-t[0]&&e.x<=t[0]&&e.y>=-t[1]&&e.y<=t[1]}function f3(e,t,i,r,a,n,o,s,l,u,h,c,d){let p=i?e.textSizeData:e.iconSizeData,f=Xl(p,t.frameRenderContext.transform.zoom),m=[256/t.width*2+1,256/t.height*2+1],g=i?e.text.dynamicLayoutVertexArray:e.icon.dynamicLayoutVertexArray;g.clear();let _=e.lineVertexArray,y=i?e.text.placedSymbolArray:e.icon.placedSymbolArray,v=t.frameRenderContext.transform.width/t.frameRenderContext.transform.height,x=!1;for(let b=0;b<y.length;b++){let w=y.get(b);if(w.hidden||w.writingMode===2&&!x){Na(w.numGlyphs,g);continue}x=!1;let T=new C(w.anchorX,w.anchorY),E={getElevation:d,pitchedLabelPlaneMatrix:r,lineVertexArray:_,pitchWithMap:n,projectionCache:{projections:{},offsets:{},cachedAnchorPoint:void 0,anyProjectionOccluded:!1},transform:t.frameRenderContext.transform,tileAnchorPoint:T,unwrappedTileID:l,width:u,height:h,translation:c},S=$v(w.anchorX,w.anchorY,E);if(!p3(S.point,m)){Na(w.numGlyphs,g);continue}let M=S.signedDistanceFromCamera,z=Vv(t.frameRenderContext.transform.cameraToCenterDistance,M),R=ep(p,f,w),I=n?R*t.frameRenderContext.transform.getPitchedTextCorrection(w.anchorX,w.anchorY,l)/z:R*z,D=kg({projectionContext:E,pitchedLabelPlaneMatrixInverse:a,symbol:w,fontSize:I,flip:!1,keepUpright:o,glyphOffsetArray:e.glyphOffsetArray,dynamicLayoutVertexArray:g,aspectRatio:v,rotateToLine:s});x=D.useVertical,(D.notEnoughRoom||x||D.needsFlipping&&kg({projectionContext:E,pitchedLabelPlaneMatrixInverse:a,symbol:w,fontSize:I,flip:!0,keepUpright:o,glyphOffsetArray:e.glyphOffsetArray,dynamicLayoutVertexArray:g,aspectRatio:v,rotateToLine:s}).notEnoughRoom)&&Na(w.numGlyphs,g)}i?e.text.dynamicLayoutVertexBuffer.updateData(g):e.icon.dynamicLayoutVertexBuffer.updateData(g)}function Nv(e,t,i,r,a,n,o,s){let l=n.glyphStartIndex+n.numGlyphs,u=n.lineStartIndex,h=n.lineStartIndex+n.lineLength,c=t.getoffsetX(n.glyphStartIndex),d=t.getoffsetX(l-1),p=vl(e*c,i,r,a,n.segment,u,h,s,o);if(!p)return null;let f=vl(e*d,i,r,a,n.segment,u,h,s,o);return!f||s.projectionCache.anyProjectionOccluded?null:{first:p,last:f}}function Rg(e,t,i,r){return e===1&&Math.abs(i.y-t.y)>Math.abs(i.x-t.x)*r?{useVertical:!0}:(e===2?t.y<i.y:t.x>i.x)?{needsFlipping:!0}:null}function kg(e){let{projectionContext:t,pitchedLabelPlaneMatrixInverse:i,symbol:r,fontSize:a,flip:n,keepUpright:o,glyphOffsetArray:s,dynamicLayoutVertexArray:l,aspectRatio:u,rotateToLine:h}=e,c=a/24,d=r.lineOffsetX*c,p=r.lineOffsetY*c,f;if(r.numGlyphs>1){let m=r.glyphStartIndex+r.numGlyphs,g=r.lineStartIndex,_=r.lineStartIndex+r.lineLength,y=Nv(c,s,d,p,n,r,h,t);if(!y)return{notEnoughRoom:!0};let v=bs(y.first.point.x,y.first.point.y,t,i),x=bs(y.last.point.x,y.last.point.y,t,i);if(o&&!n){let b=Rg(r.writingMode,v,x,u);if(b)return b}f=[y.first];for(let b=r.glyphStartIndex+1;b<m-1;b++){let w=vl(c*s.getoffsetX(b),d,p,n,r.segment,g,_,t,h);if(!w)return{notEnoughRoom:!0};f.push(w)}f.push(y.last)}else{if(o&&!n){let g=ra(t.tileAnchorPoint.x,t.tileAnchorPoint.y,t).point,_=r.lineStartIndex+r.segment+1,y=new C(t.lineVertexArray.getx(_),t.lineVertexArray.gety(_)),v=ra(y.x,y.y,t),x=v.signedDistanceFromCamera>0?v.point:Uv(t.tileAnchorPoint,y,g,1,t),b=bs(g.x,g.y,t,i),w=bs(x.x,x.y,t,i),T=Rg(r.writingMode,b,w,u);if(T)return T}let m=vl(c*s.getoffsetX(r.glyphStartIndex),d,p,n,r.segment,r.lineStartIndex,r.lineStartIndex+r.lineLength,t,h);if(!m||t.projectionCache.anyProjectionOccluded)return{notEnoughRoom:!0};f=[m]}for(let m of f)fl(l,m.point,m.angle);return{}}function Uv(e,t,i,r,a){let n=e.add(e.sub(t)._unit()),o=ra(n.x,n.y,a).point,s=i.sub(o);return i.add(s._mult(r/s.mag()))}function ed(e,t,i){let r=t.projectionCache;if(r.projections[e])return r.projections[e];let a=new C(t.lineVertexArray.getx(e),t.lineVertexArray.gety(e)),n=ra(a.x,a.y,t);if(n.signedDistanceFromCamera>0)return r.projections[e]=n.point,r.anyProjectionOccluded||(r.anyProjectionOccluded=n.isOccluded),n.point;let o=e-i.direction,s=i.distanceFromAnchor===0?t.tileAnchorPoint:new C(t.lineVertexArray.getx(o),t.lineVertexArray.gety(o)),l=i.absOffsetX-i.distanceFromAnchor+1;return Uv(s,a,i.previousVertex,l,t)}function ra(e,t,i){let r=e+i.translation[0],a=t+i.translation[1],n;return i.pitchWithMap?(n=Pp(r,a,i.pitchedLabelPlaneMatrix,ia(i,r,a)),n.isOccluded=!1):(n=i.transform.projectTileCoordinates(r,a,i.unwrappedTileID,ia(i,r,a)),n.point.x=(n.point.x*.5+.5)*i.width,n.point.y=(-n.point.y*.5+.5)*i.height),n}function bs(e,t,i,r){if(i.pitchWithMap){let a=[e,t,0,1];Pt(a,a,r);let n=a[0]/a[3],o=a[1]/a[3];return i.transform.projectTileCoordinates(n,o,i.unwrappedTileID,ia(i,n,o)).point}return{x:e/i.width*2-1,y:1-t/i.height*2}}function $v(e,t,i){return i.transform.projectTileCoordinates(e,t,i.unwrappedTileID,ia(i,e,t))}function td(e,t,i){return e._unit()._perp()._mult(t*i)}function m3(e,t,i,r,a,n,o,s,l){if(s.projectionCache.offsets[e])return s.projectionCache.offsets[e];let u=i.add(t);if(e+l.direction<r||e+l.direction>=a)return s.projectionCache.offsets[e]=u,u;let h=ed(e+l.direction,s,l),c=td(h.sub(i),o,l.direction),d=i.add(c),p=h.add(c);return s.projectionCache.offsets[e]=Qb(n,u,d,p)||u,s.projectionCache.offsets[e]}function vl(e,t,i,r,a,n,o,s,l){let u=r?e-t:e+t,h=u>0?1:-1,c=0;r&&(h*=-1,c=Math.PI),h<0&&(c+=Math.PI);let d=h>0?n+a:n+a+1,p;s.projectionCache.cachedAnchorPoint?p=s.projectionCache.cachedAnchorPoint:(p=ra(s.tileAnchorPoint.x,s.tileAnchorPoint.y,s).point,s.projectionCache.cachedAnchorPoint=p);let f=p,m=p,g,_,y=0,v=0,x=Math.abs(u),b=[],w;for(;y+v<=x;){if(d+=h,d<n||d>=o)return null;y+=v,m=f,_=g;let M={absOffsetX:x,direction:h,distanceFromAnchor:y,previousVertex:m};if(f=ed(d,s,M),i===0)b.push(m),w=f.sub(m);else{let z,R=f.sub(m);z=R.mag()===0?td(ed(d+h,s,M).sub(f),i,h):td(R,i,h),_||(_=m.add(z)),g=m3(d,z,f,n,o,_,i,s,M),b.push(_),w=g.sub(_)}v=w.mag()}let T=(x-y)/v,E=w._mult(T)._add(_||m),S=c+Math.atan2(f.y-m.y,f.x-m.x);return b.push(E),{point:E,angle:l?S:0,path:b}}var g3=new Float32Array([-1/0,-1/0,0,-1/0,-1/0,0,-1/0,-1/0,0,-1/0,-1/0,0]);function Na(e,t){for(let i=0;i<e;i++){let r=t.length;t.resize(r+4),t.float32.set(g3,r*3)}}function Ap(e,t,i){let r=t[0],a=t[1];return e[0]=i[0]*r+i[4]*a+i[12],e[1]=i[1]*r+i[5]*a+i[13],e[3]=i[3]*r+i[7]*a+i[15],e}function _3(e,t){let i=c3;return h3(i,t.pitchedLabelPlaneMatrix),e.map(r=>{let a=Pp(r.x,r.y,i,ia(t,r.x,r.y)),n=t.transform.projectTileCoordinates(a.point.x,a.point.y,t.unwrappedTileID,ia(t,a.point.x,a.point.y));return n.point.x=(n.point.x*.5+.5)*t.width,n.point.y=(-n.point.y*.5+.5)*t.height,n})}function y3(e){let t=0,i=0,r=0,a=0;for(let n=0;n<e.length;n++)e[n].isOccluded?(r=n+1,a=0):(a++,a>i&&(i=a,t=r));return e.slice(t,t+i)}var v3=class{constructor(e,t=new zg(e.width+200,e.height+200,25),i=new zg(e.width+200,e.height+200,25)){this.transform=e,this.grid=t,this.ignoredGrid=i,this.pitchFactor=Math.cos(e.pitch*Math.PI/180)*e.cameraToCenterDistance,this.screenRightBoundary=e.width+100,this.screenBottomBoundary=e.height+100,this.gridRightBoundary=e.width+200,this.gridBottomBoundary=e.height+200,this.perspectiveRatioCutoff=.6}placeCollisionBox(e,t,i,r,a,n,o,s,l,u,h,c,d=0,p=!0){let f=e.anchorPointX+s[0],m=e.anchorPointY+s[1],g=this.projectAndGetPerspectiveRatio(f,m,a,Us(u,f,m,d,p),c),_=i*g.perspectiveRatio,y;if(!n&&!o){let S=g.x+(h?h.x*_:0),M=g.y+(h?h.y*_:0);y={allPointsOccluded:!1,box:[S+e.x1*_,M+e.y1*_,S+e.x2*_,M+e.y2*_]}}else y=this._projectCollisionBox(e,_,r,a,n,o,s,g,u,h,c,d,p);let[v,x,b,w]=y.box,T=n?y.allPointsOccluded:g.isOccluded,E=T;return E||(E=g.perspectiveRatio<this.perspectiveRatioCutoff),E||(E=!this.isInsideGrid(v,x,b,w)),E||t!=="always"&&this.grid.hitTest(v,x,b,w,t,l)?{box:[v,x,b,w],placeable:!1,offscreen:!1,occluded:T}:{box:[v,x,b,w],placeable:!0,offscreen:this.isOffscreen(v,x,b,w),occluded:T}}placeCollisionCircles(e,t,i,r,a,n,o,s,l,u,h,c,d,p){let f=[],m=new C(t.anchorX,t.anchorY),g=this.getPerspectiveRatio(m.x,m.y,n,p?.(m.x,m.y)),_=(l?a*this.transform.getPitchedTextCorrection(t.anchorX,t.anchorY,n)/g:a*g)/24,y={projections:{},offsets:{},cachedAnchorPoint:void 0,anyProjectionOccluded:!1},v=t.lineOffsetX*_,x=t.lineOffsetY*_,b={getElevation:p,pitchedLabelPlaneMatrix:o,lineVertexArray:i,pitchWithMap:l,projectionCache:y,transform:this.transform,tileAnchorPoint:m,unwrappedTileID:n,width:this.transform.width,height:this.transform.height,translation:d},w=Nv(_,r,v,x,!1,t,!1,b),T=!1,E=!1,S=!0;if(w){let M=h*.5*g+c,z=new C(-100,-100),R=new C(this.screenRightBoundary,this.screenBottomBoundary),I=new s3,D=w.first,P=w.last,A=[];for(let V=D.path.length-1;V>=1;V--)A.push(D.path[V]);for(let V=1;V<P.path.length;V++)A.push(P.path[V]);let B=M*2.5;if(l){let V=this.projectPathToScreenSpace(A,b);A=V.some(J=>J.signedDistanceFromCamera<=0)?[]:V.map(J=>J.point)}let j=[];if(A.length>0){let V=A[0].clone(),J=A[0].clone();for(let se=1;se<A.length;se++)V.x=Math.min(V.x,A[se].x),V.y=Math.min(V.y,A[se].y),J.x=Math.max(J.x,A[se].x),J.y=Math.max(J.y,A[se].y);j=V.x>=z.x&&J.x<=R.x&&V.y>=z.y&&J.y<=R.y?[A]:J.x<z.x||V.x>R.x||J.y<z.y||V.y>R.y?[]:L1([A],z.x,z.y,R.x,R.y)}for(let V of j){I.reset(V,M*.25);let J=0;J=I.length<=.5*M?1:Math.ceil(I.paddedLength/B)+1;for(let se=0;se<J;se++){let fe=se/Math.max(J-1,1),ye=I.lerp(fe),Ge=ye.x+100,Le=ye.y+100;f.push(Ge,Le,M,0);let Ze=Ge-M,ke=Le-M,Tt=Ge+M,zt=Le+M;if(S&&(S=this.isOffscreen(Ze,ke,Tt,zt)),E||(E=this.isInsideGrid(Ze,ke,Tt,zt)),e!=="always"&&this.grid.hitTestCircle(Ge,Le,M,e,u)&&(T=!0,!s))return{circles:[],offscreen:!1,collisionDetected:T}}}}return{circles:!s&&T||!E||g<this.perspectiveRatioCutoff?[]:f,offscreen:S,collisionDetected:T}}projectPathToScreenSpace(e,t){return y3(_3(e,t))}queryRenderedSymbols(e){if(e.length===0||this.grid.keysLength()===0&&this.ignoredGrid.keysLength()===0)return{};let t=[],i=new Ii;for(let h of e){let c=new C(h.x+100,h.y+100);i.extend(c),t.push(c)}let{minX:r,minY:a,maxX:n,maxY:o}=i,s=this.grid.query(r,a,n,o).concat(this.ignoredGrid.query(r,a,n,o)),l={},u={};for(let h of s){let c=h.key;l[c.bucketInstanceId]===void 0&&(l[c.bucketInstanceId]={}),!l[c.bucketInstanceId][c.featureIndex]&&U0(t,[new C(h.x1,h.y1),new C(h.x2,h.y1),new C(h.x2,h.y2),new C(h.x1,h.y2)])&&(l[c.bucketInstanceId][c.featureIndex]=!0,u[c.bucketInstanceId]===void 0&&(u[c.bucketInstanceId]=[]),u[c.bucketInstanceId].push(c.featureIndex))}return u}insertCollisionBox(e,t,i,r,a,n){let o=i?this.ignoredGrid:this.grid,s={bucketInstanceId:r,featureIndex:a,collisionGroupID:n,overlapMode:t};o.insert(s,e[0],e[1],e[2],e[3])}insertCollisionCircles(e,t,i,r,a,n){let o=i?this.ignoredGrid:this.grid,s={bucketInstanceId:r,featureIndex:a,collisionGroupID:n,overlapMode:t};for(let l=0;l<e.length;l+=4)o.insertCircle(s,e[l],e[l+1],e[l+2])}projectAndGetPerspectiveRatio(e,t,i,r,a){if(a){let n;r==null?(n=[e,t,0,1],Ap(n,n,a)):(n=[e,t,r,1],Pt(n,n,a));let o=n[3];return{x:(n[0]/o+1)/2*this.transform.width+100,y:(-n[1]/o+1)/2*this.transform.height+100,perspectiveRatio:.5+.5*(this.transform.cameraToCenterDistance/o),isOccluded:!1,signedDistanceFromCamera:o}}{let n=this.transform.projectTileCoordinates(e,t,i,r);return{x:(n.point.x+1)/2*this.transform.width+100,y:(-n.point.y+1)/2*this.transform.height+100,perspectiveRatio:.5+.5*(this.transform.cameraToCenterDistance/n.signedDistanceFromCamera),isOccluded:n.isOccluded,signedDistanceFromCamera:n.signedDistanceFromCamera}}}getPerspectiveRatio(e,t,i,r){let a=this.transform.projectTileCoordinates(e,t,i,r);return .5+.5*(this.transform.cameraToCenterDistance/a.signedDistanceFromCamera)}isOffscreen(e,t,i,r){return i<100||e>=this.screenRightBoundary||r<100||t>this.screenBottomBoundary}isInsideGrid(e,t,i,r){return i>=0&&e<this.gridRightBoundary&&r>=0&&t<this.gridBottomBoundary}getViewportMatrix(){let e=Mi([]);return lt(e,e,[-100,-100,0]),e}_projectCollisionBox(e,t,i,r,a,n,o,s,l,u,h,c=0,d=!0){let p=1,f=0,m=0,g=1,_=e.anchorPointX+o[0],y=e.anchorPointY+o[1];if(n&&!a){let P=this.projectAndGetPerspectiveRatio(_+1,y,r,Us(l,_+1,y,c,d),h),A=P.x-s.x,B=P.y-s.y,j=Math.atan(B/A)+(A<0?Math.PI:0),V=Math.sin(j),J=Math.cos(j);p=J,f=V,m=-V,g=J}else if(!n&&a){let P=Cp(this.transform);p=P.vecEast[0],f=P.vecEast[1],m=P.vecSouth[0],g=P.vecSouth[1]}let v=s.x,x=s.y,b=t;if(a&&(v=_,x=y,b=2**-(this.transform.zoom-i.overscaledZ),b*=this.transform.getPitchedTextCorrection(_,y,r),!u)){let P=ie(.5+.5*(s.signedDistanceFromCamera/this.transform.cameraToCenterDistance),0,4);b*=P}u&&(v+=p*u.x*b+m*u.y*b,x+=f*u.x*b+g*u.y*b);let w=e.x1*b,T=e.x2*b,E=(w+T)/2,S=e.y1*b,M=e.y2*b,z=(S+M)/2,R=[{offsetX:w,offsetY:S},{offsetX:E,offsetY:S},{offsetX:T,offsetY:S},{offsetX:T,offsetY:z},{offsetX:T,offsetY:M},{offsetX:E,offsetY:M},{offsetX:w,offsetY:M},{offsetX:w,offsetY:z}],I=[];for(let{offsetX:P,offsetY:A}of R)I.push(new C(v+p*P+m*A,x+f*P+g*A));let D=!1;if(a){let P=I.map(A=>this.projectAndGetPerspectiveRatio(A.x,A.y,r,Us(l,A.x,A.y,c,d),h));D=P.some(A=>!A.isOccluded),I=P.map(A=>new C(A.x,A.y))}else D=!0;return{box:Wb(I),allPointsOccluded:!D}}},Lg=class{constructor(e,t,i,r){this.opacity=e?Math.max(0,Math.min(1,e.opacity+(e.placed?t:-t))):r&&i?1:0,this.placed=i}isHidden(){return this.opacity===0&&!this.placed}},Tn=class{constructor(e,t,i,r,a){this.text=new Lg(e?e.text:null,t,i,a),this.icon=new Lg(e?e.icon:null,t,r,a)}isHidden(){return this.text.isHidden()&&this.icon.isHidden()}},Bg=class{constructor(e,t,i){this.text=e,this.icon=t,this.skipFade=i}},x3=class{constructor(e,t,i,r,a){this.bucketInstanceId=e,this.featureIndex=t,this.sourceLayerIndex=i,this.bucketIndex=r,this.tileID=a}},b3=class{constructor(e){this.crossSourceCollisions=e,this.maxGroupID=0,this.collisionGroups={}}get(e){if(this.crossSourceCollisions)return{ID:0,predicate:null};if(!this.collisionGroups[e]){let t=++this.maxGroupID;this.collisionGroups[e]={ID:t,predicate:i=>i.collisionGroupID===t}}return this.collisionGroups[e]}};function Og(e,t,i,r,a){let{horizontalAlign:n,verticalAlign:o}=Hl(e),s=-(n-.5)*t,l=-(o-.5)*i;return new C(s+r[0]*a,l+r[1]*a)}var w3=QD.members.find(e=>e.name==="crossTileID").offset/4,T3=class{constructor(e,t,i,r,a){this.transform=e.clone(),this.terrain=t,this.collisionIndex=new v3(this.transform),this.placements={},this.opacities={},this.variableOffsets={},this.stale=!1,this.commitTime=0,this.fadeDuration=i,this.retainedQueryData={},this.collisionGroups=new b3(r),this.collisionCircleArrays={},this.collisionBoxArrays=new Map,this.lastOpacityInputs=new WeakMap,this.prevPlacement=a,a&&(a.prevPlacement=void 0),this.placedOrientations={}}_getTerrainElevationFunc(e){let t=this.terrain;if(t)return(i,r)=>t.getElevation(e,i,r)}getBucketParts(e,t,i,r){let a=i.getBucket(t),n=i.latestFeatureIndex;if(!a||!n||t.id!==a.layerIds[0])return;let o=i.collisionBoxArray,s=a.layers[0].layout,l=a.layers[0].paint,u=2**(this.transform.zoom-i.tileID.overscaledZ),h=i.tileSize/k,c=i.tileID.toUnwrapped(),d=s.get("text-rotation-alignment")==="map",p=oi(i,1,this.transform.zoom),f=Sr(this.collisionIndex.transform,i,l.get("text-translate"),l.get("text-translate-anchor")),m=Sr(this.collisionIndex.transform,i,l.get("icon-translate"),l.get("icon-translate-anchor")),g=Sp(d,this.transform,p);this.retainedQueryData[a.bucketInstanceId]=new x3(a.bucketInstanceId,n,a.sourceLayerIndex,a.index,i.tileID);let _={bucket:a,layout:s,translationText:f,translationIcon:m,unwrappedTileID:c,pitchedLabelPlaneMatrix:g,scale:u,textPixelRatio:h,holdingForFade:i.holdingForSymbolFade(),collisionBoxArray:o,partiallyEvaluatedTextSize:Xl(a.textSizeData,this.transform.zoom),collisionGroup:this.collisionGroups.get(a.sourceID)};if(r)for(let y of a.sortKeyRanges){let{sortKey:v,symbolInstanceStart:x,symbolInstanceEnd:b}=y;e.push({sortKey:v,symbolInstanceStart:x,symbolInstanceEnd:b,parameters:_})}else e.push({symbolInstanceStart:0,symbolInstanceEnd:a.symbolInstances.length,parameters:_})}attemptAnchorPlacement(e,t,i,r,a,n,o,s,l,u,h,c,d,p,f,m,g,_,y,v,x,b){let w=Vc[e.textAnchor],T=[e.textOffset0,e.textOffset1],E=Og(w,i,r,T,a),S=this.collisionIndex.placeCollisionBox(t,c,s,l,u,o,n,m,h.predicate,y,E,v,x,b);if((!_||this.collisionIndex.placeCollisionBox(_,c,s,l,u,o,n,g,h.predicate,y,E,v,x,b).placeable)&&S.placeable){let M;if(this.prevPlacement?.variableOffsets[d.crossTileID]&&this.prevPlacement?.placements[d.crossTileID]?.text&&(M=this.prevPlacement.variableOffsets[d.crossTileID].anchor),d.crossTileID===0)throw Error("symbolInstance.crossTileID can't be 0");return this.variableOffsets[d.crossTileID]={textOffset:T,width:i,height:r,anchor:w,textBoxScale:a,prevAnchor:M},this.markUsedJustification(p,w,d,f),p.allowVerticalPlacement&&(this.markUsedOrientation(p,f,d),this.placedOrientations[d.crossTileID]=f),{shift:E,placedGlyphBoxes:S}}}placeLayerBucketPart(e,t,i){let{bucket:r,layout:a,translationText:n,translationIcon:o,unwrappedTileID:s,pitchedLabelPlaneMatrix:l,textPixelRatio:u,holdingForFade:h,collisionBoxArray:c,partiallyEvaluatedTextSize:d,collisionGroup:p}=e.parameters,f=a.get("text-optional"),m=a.get("icon-optional"),g=pl(a,"text-overlap","text-allow-overlap"),_=g==="always",y=pl(a,"icon-overlap","icon-allow-overlap"),v=y==="always",x=a.get("text-rotation-alignment")==="map",b=a.get("text-pitch-alignment")==="map",w=a.get("icon-text-fit")!=="none",T=a.get("symbol-z-order")==="viewport-y",E=a.get("symbol-height-anchor")==="ground",S=_&&(v||!r.hasIconData()||m),M=v&&(_||!r.hasTextData()||f);!r.collisionArrays&&c&&r.deserializeCollisionBoxes(c);let z=this.retainedQueryData[r.bucketInstanceId].tileID,R=this._getTerrainElevationFunc(z),I=this.transform.getFastPathSimpleProjectionMatrix(z),D=(P,A,B)=>{if(t[P.crossTileID])return;if(h){this.placements[P.crossTileID]=new Bg(!1,!1,!1);return}let j=P.heightOffset,V=!1,J=!1,se=!0,fe=null,ye={box:null,placeable:!1,offscreen:null,occluded:!1},Ge={box:null,placeable:!1,offscreen:null},Le=null,Ze=null,ke=null,Tt=0,zt=0,Ut=0;A.textFeatureIndex?Tt=A.textFeatureIndex:P.useRuntimeCollisionCircles&&(Tt=P.featureIndex),A.verticalTextFeatureIndex&&(zt=A.verticalTextFeatureIndex);let $t=A.textBox;if($t){let ce=H=>{let te=1;if(r.allowVerticalPlacement&&!H&&this.prevPlacement){let Z=this.prevPlacement.placedOrientations[P.crossTileID];Z&&(this.placedOrientations[P.crossTileID]=Z,te=Z,this.markUsedOrientation(r,te,P))}return te},re=(H,te)=>{if(r.allowVerticalPlacement&&P.numVerticalGlyphVertices>0&&A.verticalTextBox){for(let Z of r.writingModes)if(Z===2?(ye=te(),Ge=ye):ye=H(),ye?.placeable)break}else ye=H()},O=P.textAnchorOffsetStartIndex,we=P.textAnchorOffsetEndIndex;if(we===O){let H=(te,Z)=>{let xe=this.collisionIndex.placeCollisionBox(te,g,u,z,s,b,x,n,p.predicate,R,void 0,I,j,E);return xe?.placeable&&(this.markUsedOrientation(r,Z,P),this.placedOrientations[P.crossTileID]=Z),xe};re(()=>H($t,1),()=>{let te=A.verticalTextBox;return r.allowVerticalPlacement&&P.numVerticalGlyphVertices>0&&te?H(te,2):{box:null,offscreen:null}}),ce(ye?.placeable)}else{let H=Vc[this.prevPlacement?.variableOffsets[P.crossTileID]?.anchor],te=(xe,Be,Te)=>{let ot=xe.x2-xe.x1,Fr=xe.y2-xe.y1,Ji=P.textBoxScale,Li=w&&y==="never"?Be:null,Bt=null,Re=g==="never"?1:2,qe="never";H&&Re++;for(let hi=0;hi<Re;hi++){for(let ci=O;ci<we;ci++){let ca=r.textAnchorOffsets.get(ci);if(H&&ca.textAnchor!==H)continue;let st=this.attemptAnchorPlacement(ca,xe,ot,Fr,Ji,x,b,u,z,s,p,qe,P,r,Te,n,o,Li,R,I,j,E);if(st&&(Bt=st.placedGlyphBoxes,Bt?.placeable))return V=!0,fe=st.shift,Bt}H?H=null:qe=g}return i&&!Bt&&(Bt={box:this.collisionIndex.placeCollisionBox($t,"always",u,z,s,b,x,n,p.predicate,R,void 0,I,j,E).box,offscreen:!1,placeable:!1,occluded:!1}),Bt};re(()=>te($t,A.iconBox,1),()=>{let xe=A.verticalTextBox,Be=ye?.placeable;return r.allowVerticalPlacement&&!Be&&P.numVerticalGlyphVertices>0&&xe?te(xe,A.verticalIconBox,2):{box:null,occluded:!0,offscreen:null}}),ye&&(V=ye.placeable,se=ye.offscreen);let Z=ce(ye?.placeable);if(!V&&this.prevPlacement){let xe=this.prevPlacement.variableOffsets[P.crossTileID];xe&&(this.variableOffsets[P.crossTileID]=xe,this.markUsedJustification(r,xe.anchor,P,Z))}}}if(Le=ye,V=Le?.placeable,se=Le?.offscreen,P.useRuntimeCollisionCircles&&P.centerJustifiedTextSymbolIndex>=0){let ce=r.text.placedSymbolArray.get(P.centerJustifiedTextSymbolIndex),re=ep(r.textSizeData,d,ce),O=a.get("text-padding"),we=P.collisionCircleDiameter;Ze=this.collisionIndex.placeCollisionCircles(g,ce,r.lineVertexArray,r.glyphOffsetArray,re,s,l,i,b,p.predicate,we,O,n,R),Ze.circles.length&&Ze.collisionDetected&&!i&&_e("Collisions detected, but collision boxes are not shown"),V=_||Ze.circles.length>0&&!Ze.collisionDetected,se&&(se=Ze.offscreen)}if(A.iconFeatureIndex&&(Ut=A.iconFeatureIndex),A.iconBox){let ce=re=>this.collisionIndex.placeCollisionBox(re,y,u,z,s,b,x,o,p.predicate,R,w&&fe?fe:void 0,I,j,E);Ge&&Ge.placeable&&A.verticalIconBox?(ke=ce(A.verticalIconBox),J=ke.placeable):(ke=ce(A.iconBox),J=ke.placeable),se&&(se=ke.offscreen)}let Et=f||P.numHorizontalGlyphVertices===0&&P.numVerticalGlyphVertices===0,nt=m||P.numIconVertices===0;!Et&&!nt?J=V=J&&V:nt?Et||J&&(J=V):V=J&&V;let Jt=V&&Le.placeable,Ti=J&&ke.placeable;if(Jt&&(Ge&&Ge.placeable&&zt?this.collisionIndex.insertCollisionBox(Le.box,g,a.get("text-ignore-placement"),r.bucketInstanceId,zt,p.ID):this.collisionIndex.insertCollisionBox(Le.box,g,a.get("text-ignore-placement"),r.bucketInstanceId,Tt,p.ID)),Ti&&this.collisionIndex.insertCollisionBox(ke.box,y,a.get("icon-ignore-placement"),r.bucketInstanceId,Ut,p.ID),Ze&&V&&this.collisionIndex.insertCollisionCircles(Ze.circles,g,a.get("text-ignore-placement"),r.bucketInstanceId,Tt,p.ID),i&&this.storeCollisionData(r.bucketInstanceId,B,A,Le,ke,Ze),P.crossTileID===0)throw Error("symbolInstance.crossTileID can't be 0");if(r.bucketInstanceId===0)throw Error("bucket.bucketInstanceId can't be 0");let ui=(V||S)&&!Le?.occluded,W=(J||M)&&!ke?.occluded;this.placements[P.crossTileID]=new Bg(ui,W,se||r.justReloaded),t[P.crossTileID]=!0};if(T){if(e.symbolInstanceStart!==0)throw Error("bucket.bucketInstanceId should be 0");let P=r.getSortedSymbolIndexes(-this.transform.bearingInRadians);for(let A=P.length-1;A>=0;--A){let B=P[A];D(r.symbolInstances.get(B),r.collisionArrays[B],B)}}else for(let P=e.symbolInstanceStart;P<e.symbolInstanceEnd;P++)D(r.symbolInstances.get(P),r.collisionArrays[P],P);r.justReloaded=!1}storeCollisionData(e,t,i,r,a,n){if(i.textBox||i.iconBox){let o;this.collisionBoxArrays.has(e)?o=this.collisionBoxArrays.get(e):(o=new Map,this.collisionBoxArrays.set(e,o));let s;o.has(t)?s=o.get(t):(s={text:null,icon:null},o.set(t,s)),i.textBox&&(s.text=r.box),i.iconBox&&(s.icon=a.box)}if(n){let o=this.collisionCircleArrays[e];o===void 0&&(o=this.collisionCircleArrays[e]=[]);for(let s=0;s<n.circles.length;s+=4)o.push(n.circles[s+0]-100),o.push(n.circles[s+1]-100),o.push(n.circles[s+2]),o.push(+!!n.collisionDetected)}}markUsedJustification(e,t,i,r){let a={left:i.leftJustifiedTextSymbolIndex,center:i.centerJustifiedTextSymbolIndex,right:i.rightJustifiedTextSymbolIndex},n;n=r===2?i.verticalPlacedTextSymbolIndex:a[Nc(t)];let o=[i.leftJustifiedTextSymbolIndex,i.centerJustifiedTextSymbolIndex,i.rightJustifiedTextSymbolIndex,i.verticalPlacedTextSymbolIndex];for(let s of o)s>=0&&(n>=0&&s!==n?e.text.placedSymbolArray.get(s).crossTileID=0:e.text.placedSymbolArray.get(s).crossTileID=i.crossTileID)}markUsedOrientation(e,t,i){let r=t===1||t===3?t:0,a=t===2?t:0,n=[i.leftJustifiedTextSymbolIndex,i.centerJustifiedTextSymbolIndex,i.rightJustifiedTextSymbolIndex];for(let o of n)e.text.placedSymbolArray.get(o).placedOrientation=r;i.verticalPlacedTextSymbolIndex&&(e.text.placedSymbolArray.get(i.verticalPlacedTextSymbolIndex).placedOrientation=a)}commit(e){this.commitTime=e,this.zoomAtLastRecencyCheck=this.transform.zoom;let t=this.prevPlacement,i=!1;this.prevZoomAdjustment=t?t.zoomAdjustment(this.transform.zoom):0;let r=t?t.symbolFadeChange(e):1,a=t?t.opacities:{},n=t?t.variableOffsets:{},o=t?t.placedOrientations:{};for(let s in this.placements){let l=this.placements[s],u=a[s];u?(this.opacities[s]=new Tn(u,r,l.text,l.icon),i||(i=l.text!==u.text.placed),i||(i=l.icon!==u.icon.placed)):(this.opacities[s]=new Tn(null,r,l.text,l.icon,l.skipFade),i||(i=l.text||l.icon))}for(let s in a){let l=a[s];if(!this.opacities[s]){let u=new Tn(l,r,!1,!1);u.isHidden()||(this.opacities[s]=u,i||(i=l.text.placed),i||(i=l.icon.placed))}}for(let s in n)!this.variableOffsets[s]&&this.opacities[s]&&!this.opacities[s].isHidden()&&(this.variableOffsets[s]=n[s]);for(let s in o)!this.placedOrientations[s]&&this.opacities[s]&&!this.opacities[s].isHidden()&&(this.placedOrientations[s]=o[s]);if(t&&t.lastPlacementChangeTime===void 0)throw Error("Last placement time for previous placement is not defined");i?this.lastPlacementChangeTime=e:typeof this.lastPlacementChangeTime!="number"&&(this.lastPlacementChangeTime=t?t.lastPlacementChangeTime:e)}updateLayerOpacities(e,t){let i={};for(let r of t){let a=r.getBucket(e);if(!a||!r.latestFeatureIndex||e.id!==a.layerIds[0])continue;let{duplicates:n,changed:o}=this._markDuplicates(a,i),s=!!a.hasDebugData()||a.bucketInstanceId in this.collisionCircleArrays;(o||s)&&this.updateBucketOpacities(a,r.tileID,n,r.collisionBoxArray),a.sortFeatures(-this.transform.bearingInRadians),this.retainedQueryData[a.bucketInstanceId]&&(this.retainedQueryData[a.bucketInstanceId].featureSortOrder=a.featureSortOrder)}}_markDuplicates(e,t){let i=e.symbolInstances.length,r=this.lastOpacityInputs.get(e),a=!1;r||(r={crossTileIDs:Array(i).fill(0),duplicates:Array(i).fill(!1)},this.lastOpacityInputs.set(e,r),a=!0);let{crossTileIDs:n,duplicates:o}=r,s=e.symbolInstances.uint32,l=e.symbolInstances.bytesPerElement/4;for(let u=0;u<i;u++){let h=s[u*l+w3],c=!!t[h];t[h]=!0,(n[u]!==h||o[u]!==c)&&(n[u]=h,o[u]=c,a=!0)}return{duplicates:o,changed:a}}updateBucketOpacities(e,t,i,r){e.hasTextData()&&(e.text.opacityVertexArray.clear(),e.text.hasVisibleVertices=!1),e.hasIconData()&&(e.icon.opacityVertexArray.clear(),e.icon.hasVisibleVertices=!1),e.hasIconCollisionBoxData()&&e.iconCollisionBox.collisionVertexArray.clear(),e.hasTextCollisionBoxData()&&e.textCollisionBox.collisionVertexArray.clear();let a=e.layers[0],n=a.layout,o=new Tn(null,0,!1,!1,!0),s=n.get("text-allow-overlap"),l=n.get("icon-allow-overlap"),u=a._unevaluatedLayout.hasValue("text-variable-anchor")||a._unevaluatedLayout.hasValue("text-variable-anchor-offset"),h=n.get("text-rotation-alignment")==="map",c=n.get("text-pitch-alignment")==="map",d=n.get("icon-text-fit")!=="none",p=new Tn(null,0,s&&(l||!e.hasIconData()||n.get("icon-optional")),l&&(s||!e.hasTextData()||n.get("text-optional")),!0);!e.collisionArrays&&r&&(e.hasIconCollisionBoxData()||e.hasTextCollisionBoxData())&&e.deserializeCollisionBoxes(r);let f=(g,_,y)=>{for(let v=0;v<_/4;v++)g.opacityVertexArray.emplaceBack(y);g.hasVisibleVertices||(g.hasVisibleVertices=y!==0)},m=this.collisionBoxArrays.get(e.bucketInstanceId);for(let g=0;g<e.symbolInstances.length;g++){let _=e.symbolInstances.get(g),{numHorizontalGlyphVertices:y,numVerticalGlyphVertices:v,crossTileID:x}=_,b=i[g],w=this.opacities[x];b?w=o:w||(w=p,this.opacities[x]=w);let T=y>0||v>0,E=_.numIconVertices>0,S=this.placedOrientations[_.crossTileID],M=S===2,z=S===1||S===3;if(T){let I=Vg(w.text),D=M?0:I;f(e.text,y,D);let P=z?0:I;f(e.text,v,P);let A=w.text.isHidden(),B=[_.rightJustifiedTextSymbolIndex,_.centerJustifiedTextSymbolIndex,_.leftJustifiedTextSymbolIndex];for(let J of B)J>=0&&(e.text.placedSymbolArray.get(J).hidden=A||M?1:0);_.verticalPlacedTextSymbolIndex>=0&&(e.text.placedSymbolArray.get(_.verticalPlacedTextSymbolIndex).hidden=A||z?1:0);let j=this.variableOffsets[_.crossTileID];j&&this.markUsedJustification(e,j.anchor,_,S);let V=this.placedOrientations[_.crossTileID];V&&(this.markUsedJustification(e,"left",_,V),this.markUsedOrientation(e,V,_))}if(E){let I=Vg(w.icon),D=!(d&&_.verticalPlacedIconSymbolIndex&&M);if(_.placedIconSymbolIndex>=0){let P=D?I:0;f(e.icon,_.numIconVertices,P),e.icon.placedSymbolArray.get(_.placedIconSymbolIndex).hidden=w.icon.isHidden()}if(_.verticalPlacedIconSymbolIndex>=0){let P=D?0:I;f(e.icon,_.numVerticalIconVertices,P),e.icon.placedSymbolArray.get(_.verticalPlacedIconSymbolIndex).hidden=w.icon.isHidden()}}let R=m?.has(g)?m.get(g):{text:null,icon:null};if(e.hasIconCollisionBoxData()||e.hasTextCollisionBoxData()){let I=e.collisionArrays[g];if(I){let D=new C(0,0);if(I.textBox||I.verticalTextBox){let P=!0;if(u){let A=this.variableOffsets[x];A?(D=Og(A.anchor,A.width,A.height,A.textOffset,A.textBoxScale),h&&D._rotate(c?-this.transform.bearingInRadians:this.transform.bearingInRadians)):P=!1}if(I.textBox||I.verticalTextBox){let A;I.textBox&&(A=M),I.verticalTextBox&&(A=z),jg(e.textCollisionBox.collisionVertexArray,w.text.placed,!P||A,R.text,D.x,D.y)}}if(I.iconBox||I.verticalIconBox){let P=!(z||!I.verticalIconBox),A;I.iconBox&&(A=P),I.verticalIconBox&&(A=!P),jg(e.iconCollisionBox.collisionVertexArray,w.icon.placed,A,R.icon,d?D.x:0,d?D.y:0)}}}}if(e.hasTextData()&&e.text.opacityVertexBuffer&&e.text.opacityVertexBuffer.updateData(e.text.opacityVertexArray),e.hasIconData()&&e.icon.opacityVertexBuffer&&e.icon.opacityVertexBuffer.updateData(e.icon.opacityVertexArray),e.hasIconCollisionBoxData()&&e.iconCollisionBox.collisionVertexBuffer&&e.iconCollisionBox.collisionVertexBuffer.updateData(e.iconCollisionBox.collisionVertexArray),e.hasTextCollisionBoxData()&&e.textCollisionBox.collisionVertexBuffer&&e.textCollisionBox.collisionVertexBuffer.updateData(e.textCollisionBox.collisionVertexArray),e.text.opacityVertexArray.length!==e.text.layoutVertexArray.length/4)throw Error(`bucket.text.opacityVertexArray.length (= ${e.text.opacityVertexArray.length}) !== bucket.text.layoutVertexArray.length (= ${e.text.layoutVertexArray.length}) / 4`);if(e.icon.opacityVertexArray.length!==e.icon.layoutVertexArray.length/4)throw Error(`bucket.icon.opacityVertexArray.length (= ${e.icon.opacityVertexArray.length}) !== bucket.icon.layoutVertexArray.length (= ${e.icon.layoutVertexArray.length}) / 4`);e.bucketInstanceId in this.collisionCircleArrays&&(e.collisionCircleArray=this.collisionCircleArrays[e.bucketInstanceId],delete this.collisionCircleArrays[e.bucketInstanceId])}symbolFadeChange(e){return this.fadeDuration===0?1:(e-this.commitTime)/this.fadeDuration+this.prevZoomAdjustment}zoomAdjustment(e){return Math.max(0,(this.transform.zoom-e)/1.5)}hasTransitions(e){return this.stale||e-this.lastPlacementChangeTime<this.fadeDuration}stillRecent(e,t){let i=this.zoomAtLastRecencyCheck===t?1-this.zoomAdjustment(t):1;return this.zoomAtLastRecencyCheck=t,this.commitTime+this.fadeDuration*i>e}setStale(){this.stale=!0}};function jg(e,t,i,r,a,n){(!r||r.length===0)&&(r=[0,0,0,0]);let o=r[0]-100,s=r[1]-100,l=r[2]-100,u=r[3]-100;e.emplaceBack(+!!t,+!!i,a||0,n||0,o,s),e.emplaceBack(+!!t,+!!i,a||0,n||0,l,s),e.emplaceBack(+!!t,+!!i,a||0,n||0,l,u),e.emplaceBack(+!!t,+!!i,a||0,n||0,o,u)}var E3=2**25,D3=2**24,S3=2**17,C3=2**16;function Vg(e){if(e.opacity===0&&!e.placed)return 0;if(e.opacity===1&&e.placed)return P3;let t=+!!e.placed,i=Math.floor(e.opacity*127);return i*E3+t*D3+i*S3+t*C3+i*512+t*256+i*2+t}var P3=4294967295,A3=class{constructor(e){this._sortAcrossTiles=e.layout.get("symbol-z-order")!=="viewport-y"&&!e.layout.get("symbol-sort-key").isConstant(),this._currentTileIndex=0,this._currentPartIndex=0,this._seenCrossTileIDs={},this._bucketParts=[]}continuePlacement(e,t,i,r,a){let n=this._bucketParts;for(;this._currentTileIndex<e.length;){let o=e[this._currentTileIndex];if(t.getBucketParts(n,r,o,this._sortAcrossTiles),this._currentTileIndex++,a())return!0}for(this._sortAcrossTiles&&(this._sortAcrossTiles=!1,n.sort((o,s)=>o.sortKey-s.sortKey));this._currentPartIndex<n.length;){let o=n[this._currentPartIndex];if(t.placeLayerBucketPart(o,this._seenCrossTileIDs,i),this._currentPartIndex++,a())return!0}return!1}},I3=class{constructor(e,t,i,r,a,n,o,s){this.placement=new T3(e,t,n,o,s),this._currentPlacementIndex=i.length-1,this._forceFullPlacement=r,this._showCollisionBoxes=a,this._done=!1}isDone(){return this._done}continuePlacement(e,t,i){let r=Ie(),a=()=>!this._forceFullPlacement&&Ie()-r>2;for(;this._currentPlacementIndex>=0;){let n=t[e[this._currentPlacementIndex]],o=this.placement.collisionIndex.transform.zoom;if(N1(n)&&n.layout&&(!n.minzoom||n.minzoom<=o)&&(!n.maxzoom||n.maxzoom>o)){if(this._inProgressLayer||(this._inProgressLayer=new A3(n)),this._inProgressLayer.continuePlacement(i[n.source],this.placement,this._showCollisionBoxes,n,a))return;delete this._inProgressLayer}this._currentPlacementIndex--}this._done=!0}commit(e){return this.placement.commit(e),this.placement}},Ng=[Int8Array,Uint8Array,Uint8ClampedArray,Int16Array,Uint16Array,Int32Array,Uint32Array,Float32Array,Float64Array],Xe=new Uint32Array(96),M3=class Gv{static from(t){if(!t||t.byteLength===void 0||t.buffer)throw Error("Data must be an instance of ArrayBuffer or SharedArrayBuffer.");let[i,r]=new Uint8Array(t,0,2);if(i!==219)throw Error("Data does not appear to be in a KDBush format.");let a=r>>4;if(a!==1)throw Error(`Got v${a} data when expected v1.`);let n=Ng[r&15];if(!n)throw Error("Unrecognized array type.");let[o]=new Uint16Array(t,2,1),[s]=new Uint32Array(t,4,1);return new Gv(s,o,n,void 0,t)}constructor(t,i=64,r=Float64Array,a=ArrayBuffer,n){if(isNaN(t)||t<0)throw Error(`Unexpected numItems value: ${t}.`);this.numItems=+t,this.nodeSize=Math.min(Math.max(+i,2),65535),this.ArrayType=r,this.IndexArrayType=t<65536?Uint16Array:Uint32Array;let o=Ng.indexOf(this.ArrayType),s=t*2*this.ArrayType.BYTES_PER_ELEMENT,l=t*this.IndexArrayType.BYTES_PER_ELEMENT,u=(8-l%8)%8;if(o<0)throw Error(`Unexpected typed array class: ${r}.`);if(n)this.data=n,this.ids=new this.IndexArrayType(n,8,t),this.coords=new r(n,8+l+u,t*2),this._pos=t*2,this._finished=!0;else{let h=this.data=new a(8+s+l+u);this.ids=new this.IndexArrayType(h,8,t),this.coords=new r(h,8+l+u,t*2),this._pos=0,this._finished=!1,new Uint8Array(h,0,2).set([219,16+o]),new Uint16Array(h,2,1)[0]=i,new Uint32Array(h,4,1)[0]=t}}add(t,i){let r=this._pos>>1;return this.ids[r]=r,this.coords[this._pos++]=t,this.coords[this._pos++]=i,r}finish(){let t=this._pos>>1;if(t!==this.numItems)throw Error(`Added ${t} items when expected ${this.numItems}.`);return id(this.ids,this.coords,this.nodeSize,0,this.numItems-1,0),this._finished=!0,this}range(t,i,r,a){if(!this._finished)throw Error("Data not yet indexed - call index.finish().");let{ids:n,coords:o,nodeSize:s}=this;Xe[0]=0,Xe[1]=n.length-1,Xe[2]=0;let l=3,u=[];for(;l>0;){let h=Xe[--l],c=Xe[--l],d=Xe[--l];if(c-d<=s){for(let g=d;g<=c;g++){let _=o[2*g],y=o[2*g+1];_>=t&&_<=r&&y>=i&&y<=a&&u.push(n[g])}continue}let p=d+c>>1,f=o[2*p],m=o[2*p+1];f>=t&&f<=r&&m>=i&&m<=a&&u.push(n[p]),(h===0?t<=f:i<=m)&&(Xe[l++]=d,Xe[l++]=p-1,Xe[l++]=1-h),(h===0?r>=f:a>=m)&&(Xe[l++]=p+1,Xe[l++]=c,Xe[l++]=1-h)}return u}within(t,i,r){let a=[];return this.withinInto(t,i,r,a),a}withinInto(t,i,r,a){if(!this._finished)throw Error("Data not yet indexed - call index.finish().");let{ids:n,coords:o,nodeSize:s}=this;Xe[0]=0,Xe[1]=n.length-1,Xe[2]=0;let l=3,u=0,h=r*r;for(;l>0;){let c=Xe[--l],d=Xe[--l],p=Xe[--l];if(d-p<=s){for(let _=p;_<=d;_++)Ug(o[2*_],o[2*_+1],t,i)<=h&&(a[u++]=n[_]);continue}let f=p+d>>1,m=o[2*f],g=o[2*f+1];Ug(m,g,t,i)<=h&&(a[u++]=n[f]),(c===0?t-r<=m:i-r<=g)&&(Xe[l++]=p,Xe[l++]=f-1,Xe[l++]=1-c),(c===0?t+r>=m:i+r>=g)&&(Xe[l++]=f+1,Xe[l++]=d,Xe[l++]=1-c)}return u}};function id(e,t,i,r,a,n){if(a-r<=i)return;let o=r+a>>1;Zv(e,t,o,r,a,n),id(e,t,i,r,o-1,1-n),id(e,t,i,o+1,a,1-n)}function Zv(e,t,i,r,a,n){for(;a>r;){if(a-r>600){let u=a-r+1,h=i-r+1,c=Math.log(u),d=.5*Math.exp(2*c/3),p=.5*Math.sqrt(c*d*(u-d)/u)*(h-u/2<0?-1:1);Zv(e,t,i,Math.max(r,Math.floor(i-h*d/u+p)),Math.min(a,Math.floor(i+(u-h)*d/u+p)),n)}let o=t[2*i+n],s=r,l=a;for(En(e,t,r,i),t[2*a+n]>o&&En(e,t,r,a);s<l;){for(En(e,t,s,l),s++,l--;t[2*s+n]<o;)s++;for(;t[2*l+n]>o;)l--}t[2*r+n]===o?En(e,t,r,l):(l++,En(e,t,l,a)),l<=i&&(r=l+1),i<=l&&(a=l-1)}}function En(e,t,i,r){uh(e,i,r),uh(t,2*i,2*r),uh(t,2*i+1,2*r+1)}function uh(e,t,i){let r=e[t];e[t]=e[i],e[i]=r}function Ug(e,t,i,r){let a=e-i,n=t-r;return a*a+n*n}var Dn=512/k/2,F3=class{constructor(e,t,i){this.tileID=e,this.bucketInstanceId=i,this._symbolsByKey={};let r=new Map;for(let a=0;a<t.length;a++){let n=t.get(a),o=n.key,s=r.get(o);s?s.push(n):r.set(o,[n])}for(let[a,n]of r){let o={positions:n.map(s=>({x:Math.floor(s.anchorX*Dn),y:Math.floor(s.anchorY*Dn)})),crossTileIDs:n.map(s=>s.crossTileID)};if(o.positions.length>128){let s=new M3(o.positions.length,16,Uint16Array);for(let{x:l,y:u}of o.positions)s.add(l,u);s.finish(),delete o.positions,o.index=s}this._symbolsByKey[a]=o}}getScaledCoordinates(e,t){let{x:i,y:r,z:a}=this.tileID.canonical,{x:n,y:o,z:s}=t.canonical,l=s-a,u=Dn/2**l,h=(n*k+e.anchorX)*u,c=(o*k+e.anchorY)*u,d=i*k*Dn,p=r*k*Dn;return{x:Math.floor(h-d),y:Math.floor(c-p)}}findMatches(e,t,i){let r=this.tileID.canonical.z<t.canonical.z?1:2**(this.tileID.canonical.z-t.canonical.z);for(let a=0;a<e.length;a++){let n=e.get(a);if(n.crossTileID)continue;let o=this._symbolsByKey[n.key];if(!o)continue;let s=this.getScaledCoordinates(n,t);o.index?this.findMatchesForIndexedEntry(o,n,s,r,i):o.positions&&this.findMatchesForNonIndexedEntry(o,n,s,r,i)}}findMatchesForIndexedEntry(e,t,i,r,a){let n=e.index.range(i.x-r,i.y-r,i.x+r,i.y+r),o=1/0;for(let s of n)s<o&&!a[e.crossTileIDs[s]]&&(o=s);if(o!==1/0){let s=e.crossTileIDs[o];a[s]=!0,t.crossTileID=s}}findMatchesForNonIndexedEntry(e,t,i,r,a){for(let n=0;n<e.positions.length;n++){let o=e.positions[n],s=e.crossTileIDs[n];if(Math.abs(o.x-i.x)<=r&&Math.abs(o.y-i.y)<=r&&!a[s]){a[s]=!0,t.crossTileID=s;break}}}getCrossTileIDsLists(){return Object.values(this._symbolsByKey).map(({crossTileIDs:e})=>e)}},z3=class{constructor(){this.maxCrossTileID=0}generate(){return++this.maxCrossTileID}},R3=class{constructor(){this.indexes={},this.usedCrossTileIDs={},this.lng=0}handleWrapJump(e){let t=Math.round((e-this.lng)/360);if(t!==0)for(let i in this.indexes){let r=this.indexes[i],a={};for(let n in r){let o=r[n];o.tileID=o.tileID.unwrapTo(o.tileID.wrap+t),a[o.tileID.key]=o}this.indexes[i]=a}this.lng=e}addBucket(e,t,i){var a,n;if(this.indexes[e.overscaledZ]?.[e.key]){if(this.indexes[e.overscaledZ][e.key].bucketInstanceId===t.bucketInstanceId)return!1;this.removeBucketCrossTileIDs(e.overscaledZ,this.indexes[e.overscaledZ][e.key])}for(let o=0;o<t.symbolInstances.length;o++){let s=t.symbolInstances.get(o);s.crossTileID=0}(a=this.usedCrossTileIDs)[n=e.overscaledZ]||(a[n]={});let r=this.usedCrossTileIDs[e.overscaledZ];for(let o in this.indexes){let s=this.indexes[o];if(Number(o)>e.overscaledZ)for(let l in s){let u=s[l];u.tileID.isChildOf(e)&&u.findMatches(t.symbolInstances,e,r)}else{let l=s[e.scaledTo(Number(o)).key];l&&l.findMatches(t.symbolInstances,e,r)}}for(let o=0;o<t.symbolInstances.length;o++){let s=t.symbolInstances.get(o);s.crossTileID||(s.crossTileID=i.generate(),r[s.crossTileID]=!0)}return this.indexes[e.overscaledZ]===void 0&&(this.indexes[e.overscaledZ]={}),this.indexes[e.overscaledZ][e.key]=new F3(e,t.symbolInstances,t.bucketInstanceId),!0}removeBucketCrossTileIDs(e,t){for(let i of t.getCrossTileIDsLists())for(let r of i)delete this.usedCrossTileIDs[e][r]}removeStaleBuckets(e){let t=!1;for(let i in this.indexes){let r=this.indexes[i];for(let a in r)e[r[a].bucketInstanceId]||(this.removeBucketCrossTileIDs(i,r[a]),delete r[a],t=!0)}return t}},k3=class{constructor(){this.layerIndexes={},this.crossTileIDs=new z3,this.maxBucketInstanceId=0,this.bucketsInCurrentPlacement={}}addLayer(e,t,i){let r=this.layerIndexes[e.id];r===void 0&&(r=this.layerIndexes[e.id]=new R3);let a=!1,n={};r.handleWrapJump(i);for(let o of t){let s=o.getBucket(e);e.id===s?.layerIds[0]&&(s.bucketInstanceId||(s.bucketInstanceId=(this.maxBucketInstanceId+=1,this.maxBucketInstanceId)),r.addBucket(o.tileID,s,this.crossTileIDs)&&(a=!0),n[s.bucketInstanceId]=!0)}return r.removeStaleBuckets(n)&&(a=!0),a}pruneUnusedLayers(e){let t={};for(let i of e)t[i]=!0;for(let i in this.layerIndexes)t[i]||delete this.layerIndexes[i]}},L3=`#ifdef GL_ES
|
|
3
|
+
precision mediump float;
|
|
4
|
+
#else
|
|
5
|
+
#if !defined(lowp)
|
|
6
|
+
#define lowp
|
|
7
|
+
#endif
|
|
8
|
+
#if !defined(mediump)
|
|
9
|
+
#define mediump
|
|
10
|
+
#endif
|
|
11
|
+
#if !defined(highp)
|
|
12
|
+
#define highp
|
|
13
|
+
#endif
|
|
14
|
+
#endif
|
|
15
|
+
out highp vec4 fragColor;layout(std140) uniform ProjectionUBO {highp mat4 u_projection_matrix;highp mat4 u_projection_fallback_matrix;highp vec4 u_projection_tile_mercator_coords;highp vec4 u_projection_clipping_plane;highp float u_projection_transition;highp int u_projection_clip_antimeridian;};layout(std140) uniform FrameUBO {highp vec2 u_units_to_pixels;highp vec2 u_world_size;highp float u_camera_to_center_distance;highp float u_symbol_fade_change;highp float u_aspect_ratio;highp float u_device_pixel_ratio;highp vec2 u_viewport_size;highp vec2 u_pixel_extrude_scale;highp float u_pitch;};`,B3=`#ifdef GL_ES
|
|
16
|
+
precision highp float;
|
|
17
|
+
#else
|
|
18
|
+
#if !defined(lowp)
|
|
19
|
+
#define lowp
|
|
20
|
+
#endif
|
|
21
|
+
#if !defined(mediump)
|
|
22
|
+
#define mediump
|
|
23
|
+
#endif
|
|
24
|
+
#if !defined(highp)
|
|
25
|
+
#define highp
|
|
26
|
+
#endif
|
|
27
|
+
#endif
|
|
28
|
+
vec2 unpack_float(const float packedValue) {int packedIntValue=int(packedValue);int v0=packedIntValue/256;return vec2(v0,packedIntValue-v0*256);}vec2 unpack_opacity(const uint packedOpacity) {return vec2(float(packedOpacity >> 1u)/127.0,float(packedOpacity & 1u));}vec4 decode_color(const vec2 encodedColor) {return vec4(unpack_float(encodedColor[0])/255.0,unpack_float(encodedColor[1])/255.0
|
|
29
|
+
);}float unpack_mix_vec2(const vec2 packedValue,const float t) {return mix(packedValue[0],packedValue[1],t);}vec4 unpack_mix_color(const vec4 packedColors,const float t) {vec4 minColor=decode_color(vec2(packedColors[0],packedColors[1]));vec4 maxColor=decode_color(vec2(packedColors[2],packedColors[3]));return mix(minColor,maxColor,t);}vec2 get_pattern_pos(const vec2 pixel_coord_upper,const vec2 pixel_coord_lower,const vec2 pattern_size,const float tile_units_to_pixels,const vec2 pos) {vec2 offset=mod(mod(mod(pixel_coord_upper,pattern_size)*256.0,pattern_size)*256.0+pixel_coord_lower,pattern_size);return (tile_units_to_pixels*pos+offset)/pattern_size;}mat3 rotationMatrixFromAxisAngle(vec3 u,float angle) {float c=cos(angle);float s=sin(angle);float c2=1.0-c;return mat3(u.x*u.x*c2+ c,u.x*u.y*c2-u.z*s,u.x*u.z*c2+u.y*s,u.y*u.x*c2+u.z*s,u.y*u.y*c2+ c,u.y*u.z*c2-u.x*s,u.z*u.x*c2-u.y*s,u.z*u.y*c2+u.x*s,u.z*u.z*c2+ c
|
|
30
|
+
);}
|
|
31
|
+
#ifdef TERRAIN3D
|
|
32
|
+
uniform sampler2D u_terrain;uniform highp sampler2D u_depth;layout(std140) uniform TerrainUBO {highp mat4 u_terrain_matrix;highp vec4 u_terrain_unpack;highp float u_terrain_dim;highp float u_terrain_exaggeration;};
|
|
33
|
+
#endif
|
|
34
|
+
const highp vec4 bitSh=vec4(256.*256.*256.,256.*256.,256.,1.);const highp vec4 bitShifts=vec4(1.)/bitSh;highp float unpack(highp vec4 color) {return dot(color,bitShifts);}highp float depthOpacity(vec3 frag) {
|
|
35
|
+
#ifdef TERRAIN3D
|
|
36
|
+
highp float d=unpack(texture(u_depth,frag.xy*0.5+0.5))+0.0001-frag.z;return 1.0-max(0.0,min(1.0,-d*500.0));
|
|
37
|
+
#else
|
|
38
|
+
return 1.0;
|
|
39
|
+
#endif
|
|
40
|
+
}float calculate_visibility(vec4 pos) {
|
|
41
|
+
#ifdef TERRAIN3D
|
|
42
|
+
vec3 frag=pos.xyz/pos.w;highp float d=depthOpacity(frag);if (d > 0.95) return 1.0;return (d+depthOpacity(frag+vec3(0.0,0.01,0.0)))/2.0;
|
|
43
|
+
#else
|
|
44
|
+
return 1.0;
|
|
45
|
+
#endif
|
|
46
|
+
}float ele(ivec2 pos) {
|
|
47
|
+
#ifdef TERRAIN3D
|
|
48
|
+
vec4 rgb=(texelFetch(u_terrain,pos,0)*255.0)*u_terrain_unpack;return rgb.r+rgb.g+rgb.b-u_terrain_unpack.a;
|
|
49
|
+
#else
|
|
50
|
+
return 0.0;
|
|
51
|
+
#endif
|
|
52
|
+
}float get_elevation(vec2 pos) {
|
|
53
|
+
#ifdef TERRAIN3D
|
|
54
|
+
#ifdef GLOBE
|
|
55
|
+
if ((pos.y <-32767.5) || (pos.y > 32766.5)) {return 0.0;}
|
|
56
|
+
#endif
|
|
57
|
+
vec2 coord=(u_terrain_matrix*vec4(pos,0.0,1.0)).xy*u_terrain_dim+1.5;vec2 f=fract(coord);ivec2 c=ivec2(floor(coord));ivec2 hi=textureSize(u_terrain,0)-1;float tl=ele(clamp(c,ivec2(0),hi));float tr=ele(clamp(c+ivec2(1,0),ivec2(0),hi));float bl=ele(clamp(c+ivec2(0,1),ivec2(0),hi));float br=ele(clamp(c+ivec2(1,1),ivec2(0),hi));float elevation=mix(mix(tl,tr,f.x),mix(bl,br,f.x),f.y);return elevation*u_terrain_exaggeration;
|
|
58
|
+
#else
|
|
59
|
+
return 0.0;
|
|
60
|
+
#endif
|
|
61
|
+
}const float PI=3.141592653589793;
|
|
62
|
+
#define PROJECTION_UBO
|
|
63
|
+
layout(std140) uniform ProjectionUBO {highp mat4 u_projection_matrix;highp mat4 u_projection_fallback_matrix;highp vec4 u_projection_tile_mercator_coords;highp vec4 u_projection_clipping_plane;highp float u_projection_transition;highp int u_projection_clip_antimeridian;};layout(std140) uniform FrameUBO {highp vec2 u_units_to_pixels;highp vec2 u_world_size;highp float u_camera_to_center_distance;highp float u_symbol_fade_change;highp float u_aspect_ratio;highp float u_device_pixel_ratio;highp vec2 u_viewport_size;highp vec2 u_pixel_extrude_scale;highp float u_pitch;};`,O3=`uniform vec4 u_color;uniform float u_opacity;void main() {fragColor=u_color*u_opacity;
|
|
64
|
+
#ifdef OVERDRAW_INSPECTOR
|
|
65
|
+
fragColor=vec4(1.0);
|
|
66
|
+
#endif
|
|
67
|
+
}`,j3="layout(location=0) in vec2 a_pos;void main() {gl_Position=projectTile(a_pos,a_pos);}",V3=`uniform vec2 u_pattern_tl_a;uniform vec2 u_pattern_br_a;uniform vec2 u_pattern_tl_b;uniform vec2 u_pattern_br_b;uniform vec2 u_texsize;uniform float u_mix;uniform float u_opacity;uniform sampler2D u_image;in vec2 v_pos_a;in vec2 v_pos_b;void main() {vec2 imagecoord=mod(v_pos_a,1.0);vec2 pos=mix(u_pattern_tl_a/u_texsize,u_pattern_br_a/u_texsize,imagecoord);vec4 color1=texture(u_image,pos);vec2 imagecoord_b=mod(v_pos_b,1.0);vec2 pos2=mix(u_pattern_tl_b/u_texsize,u_pattern_br_b/u_texsize,imagecoord_b);vec4 color2=texture(u_image,pos2);fragColor=mix(color1,color2,u_mix)*u_opacity;
|
|
68
|
+
#ifdef OVERDRAW_INSPECTOR
|
|
69
|
+
fragColor=vec4(1.0);
|
|
70
|
+
#endif
|
|
71
|
+
}`,N3="uniform vec2 u_pattern_size_a;uniform vec2 u_pattern_size_b;uniform vec2 u_pixel_coord_upper;uniform vec2 u_pixel_coord_lower;uniform float u_scale_a;uniform float u_scale_b;uniform float u_tile_units_to_pixels;layout(location=0) in vec2 a_pos;out vec2 v_pos_a;out vec2 v_pos_b;void main() {gl_Position=projectTile(a_pos,a_pos);v_pos_a=get_pattern_pos(u_pixel_coord_upper,u_pixel_coord_lower,u_scale_a*u_pattern_size_a,u_tile_units_to_pixels,a_pos);v_pos_b=get_pattern_pos(u_pixel_coord_upper,u_pixel_coord_lower,u_scale_b*u_pattern_size_b,u_tile_units_to_pixels,a_pos);}",U3=`in vec3 v_data;flat in float v_visibility;
|
|
72
|
+
#pragma maplibre: define highp vec4 color
|
|
73
|
+
#pragma maplibre: define mediump float radius
|
|
74
|
+
#pragma maplibre: define lowp float blur
|
|
75
|
+
#pragma maplibre: define lowp float opacity
|
|
76
|
+
#pragma maplibre: define highp vec4 stroke_color
|
|
77
|
+
#pragma maplibre: define mediump float stroke_width
|
|
78
|
+
#pragma maplibre: define lowp float stroke_opacity
|
|
79
|
+
void main() {
|
|
80
|
+
#pragma maplibre: initialize highp vec4 color
|
|
81
|
+
#pragma maplibre: initialize mediump float radius
|
|
82
|
+
#pragma maplibre: initialize lowp float blur
|
|
83
|
+
#pragma maplibre: initialize lowp float opacity
|
|
84
|
+
#pragma maplibre: initialize highp vec4 stroke_color
|
|
85
|
+
#pragma maplibre: initialize mediump float stroke_width
|
|
86
|
+
#pragma maplibre: initialize lowp float stroke_opacity
|
|
87
|
+
vec2 extrude=v_data.xy;float extrude_length=length(extrude);float antialiased_blur=v_data.z;float opacity_t=smoothstep(0.0,antialiased_blur,extrude_length-1.0);float color_t=stroke_width < 0.01 ? 0.0 : smoothstep(antialiased_blur,0.0,extrude_length-radius/(radius+stroke_width));fragColor=v_visibility*opacity_t*mix(color*opacity,stroke_color*stroke_opacity,color_t);const float epsilon=0.5/255.0;if (fragColor.r < epsilon && fragColor.g < epsilon && fragColor.b < epsilon && fragColor.a < epsilon) {discard;}
|
|
88
|
+
#ifdef OVERDRAW_INSPECTOR
|
|
89
|
+
fragColor=vec4(1.0);
|
|
90
|
+
#endif
|
|
91
|
+
}`,$3=`uniform bool u_scale_with_map;uniform bool u_pitch_with_map;uniform vec2 u_extrude_scale;uniform highp float u_globe_extrude_scale;uniform vec2 u_translate;layout(location=0) in ivec2 a_pos;out vec3 v_data;flat out float v_visibility;
|
|
92
|
+
#pragma maplibre: define highp vec4 color
|
|
93
|
+
#pragma maplibre: define mediump float radius
|
|
94
|
+
#pragma maplibre: define lowp float blur
|
|
95
|
+
#pragma maplibre: define lowp float opacity
|
|
96
|
+
#pragma maplibre: define highp vec4 stroke_color
|
|
97
|
+
#pragma maplibre: define mediump float stroke_width
|
|
98
|
+
#pragma maplibre: define lowp float stroke_opacity
|
|
99
|
+
void main(void) {
|
|
100
|
+
#pragma maplibre: initialize highp vec4 color
|
|
101
|
+
#pragma maplibre: initialize mediump float radius
|
|
102
|
+
#pragma maplibre: initialize lowp float blur
|
|
103
|
+
#pragma maplibre: initialize lowp float opacity
|
|
104
|
+
#pragma maplibre: initialize highp vec4 stroke_color
|
|
105
|
+
#pragma maplibre: initialize mediump float stroke_width
|
|
106
|
+
#pragma maplibre: initialize lowp float stroke_opacity
|
|
107
|
+
ivec2 pos_raw=a_pos+32768;vec2 extrude=vec2(pos_raw & 7)/7.0*2.0-1.0;vec2 circle_center=vec2(pos_raw >> 3)+u_translate;float ele=get_elevation(circle_center);v_visibility=calculate_visibility(projectTileWithElevation(circle_center,ele));if (u_pitch_with_map) {
|
|
108
|
+
#ifdef GLOBE
|
|
109
|
+
vec3 center_vector=projectToSphere(circle_center);
|
|
110
|
+
#endif
|
|
111
|
+
float angle_scale=u_globe_extrude_scale;vec2 corner_position=circle_center;if (u_scale_with_map) {angle_scale*=(radius+stroke_width);corner_position+=extrude*u_extrude_scale*(radius+stroke_width);} else {
|
|
112
|
+
#ifdef GLOBE
|
|
113
|
+
vec4 projected_center=interpolateProjection(circle_center,center_vector,ele);
|
|
114
|
+
#else
|
|
115
|
+
vec4 projected_center=projectTileWithElevation(circle_center,ele);
|
|
116
|
+
#endif
|
|
117
|
+
corner_position+=extrude*u_extrude_scale*(radius+stroke_width)*(projected_center.w/u_camera_to_center_distance);angle_scale*=(radius+stroke_width)*(projected_center.w/u_camera_to_center_distance);}
|
|
118
|
+
#ifdef GLOBE
|
|
119
|
+
vec2 angles=extrude*angle_scale;vec3 corner_vector=globeRotateVector(center_vector,angles);gl_Position=interpolateProjection(corner_position,corner_vector,ele);
|
|
120
|
+
#else
|
|
121
|
+
gl_Position=projectTileWithElevation(corner_position,ele);
|
|
122
|
+
#endif
|
|
123
|
+
} else {gl_Position=projectTileWithElevation(circle_center,ele);if (gl_Position.z/gl_Position.w > 1.0) {gl_Position.xy=vec2(10000.0);}if (u_scale_with_map) {gl_Position.xy+=extrude*(radius+stroke_width)*u_extrude_scale*u_camera_to_center_distance;} else {gl_Position.xy+=extrude*(radius+stroke_width)*u_extrude_scale*gl_Position.w;}}float antialiasblur=-max(1.0/u_device_pixel_ratio/(radius+stroke_width),blur);v_data=vec3(extrude.x,extrude.y,antialiasblur);}`,$g="void main() {fragColor=vec4(1.0);}",Zi={prelude:be(L3,B3),projectionMercator:be(`
|
|
124
|
+
void clipAntimeridian() {}`,"float projectLineThickness(float tileY) {return 1.0;}float projectCircleRadius(float tileY) {return 1.0;}vec4 projectTile(vec2 p) {vec4 result=u_projection_matrix*vec4(p,0.0,1.0);return result;}vec4 projectTile(vec2 p,vec2 rawPos) {vec4 result=u_projection_matrix*vec4(p,0.0,1.0);if (rawPos.y <-32767.5 || rawPos.y > 32766.5) {result.z=-10000000.0;}return result;}vec4 projectTileWithElevation(vec2 posInTile,float elevation) {return u_projection_matrix*vec4(posInTile,elevation,1.0);}vec4 projectTileFor3D(vec2 posInTile,float elevation) {return projectTileWithElevation(posInTile,elevation);}"),projectionGlobe:be("in highp float v_projection_tile_x;void clipAntimeridian() {if (u_projection_clip_antimeridian !=0 && (v_projection_tile_x < 0.0 || v_projection_tile_x >=8192.0)) {discard;}}",`#define GLOBE_RADIUS 6371008.8
|
|
125
|
+
#ifndef PROJECTION_UBO
|
|
126
|
+
uniform highp vec4 u_projection_tile_mercator_coords;uniform highp vec4 u_projection_clipping_plane;uniform highp float u_projection_transition;uniform mat4 u_projection_fallback_matrix;
|
|
127
|
+
#endif
|
|
128
|
+
out highp float v_projection_tile_x;vec3 globeRotateVector(vec3 vec,vec2 angles) {vec3 axisRight=vec3(vec.z,0.0,-vec.x);vec3 axisUp=cross(axisRight,vec);axisRight=normalize(axisRight);axisUp=normalize(axisUp);vec2 t=tan(angles);return normalize(vec+axisRight*t.x+axisUp*t.y);}mat3 globeGetRotationMatrix(vec3 spherePos) {vec3 axisRight=vec3(spherePos.z,0.0,-spherePos.x);vec3 axisDown=cross(axisRight,spherePos);axisRight=normalize(axisRight);axisDown=normalize(axisDown);return mat3(axisRight,axisDown,spherePos
|
|
129
|
+
);}float circumferenceRatioAtTileY(float tileY) {float mercator_pos_y=u_projection_tile_mercator_coords.y+u_projection_tile_mercator_coords.w*tileY;float t=exp(PI-(mercator_pos_y*PI*2.0));return (2.0*t)/(t*t+1.0);}float projectLineThickness(float tileY) {float thickness=1.0/circumferenceRatioAtTileY(tileY);if (u_projection_transition < 0.999) {return mix(1.0,thickness,u_projection_transition);} else {return thickness;}}vec3 projectToSphere(vec2 translatedPos,vec2 rawPos) {vec2 mercator_pos=u_projection_tile_mercator_coords.xy+u_projection_tile_mercator_coords.zw*translatedPos;float spherical_x=mercator_pos.x*PI*2.0+PI;float t=exp(PI-(mercator_pos.y*PI*2.0));float t2=t*t;float denom=t2+1.0;float sin_sy=(t2-1.0)/denom;float cos_sy=(2.0*t)/denom;vec3 pos=vec3(sin(spherical_x)*cos_sy,sin_sy,cos(spherical_x)*cos_sy
|
|
130
|
+
);if (rawPos.y <-32767.5) {pos=vec3(0.0,1.0,0.0);}if (rawPos.y > 32766.5) {pos=vec3(0.0,-1.0,0.0);}return pos;}vec3 projectToSphere(vec2 posInTile) {return projectToSphere(posInTile,vec2(0.0,0.0));}float globeComputeClippingZ(vec3 spherePos) {return (1.0-(dot(spherePos,u_projection_clipping_plane.xyz)+u_projection_clipping_plane.w));}vec4 interpolateProjection(vec2 posInTile,vec3 spherePos,float elevation) {v_projection_tile_x=posInTile.x;vec3 elevatedPos=spherePos*(1.0+elevation/GLOBE_RADIUS);vec4 globePosition=u_projection_matrix*vec4(elevatedPos,1.0);globePosition.z=globeComputeClippingZ(elevatedPos)*globePosition.w;if (u_projection_transition > 0.999) {return globePosition;}vec4 flatPosition=u_projection_fallback_matrix*vec4(posInTile,elevation,1.0);const float z_globeness_threshold=0.2;vec4 result=globePosition;result.z=mix(0.0,globePosition.z,clamp((u_projection_transition-z_globeness_threshold)/(1.0-z_globeness_threshold),0.0,1.0));result.xyw=mix(flatPosition.xyw,globePosition.xyw,u_projection_transition);if ((posInTile.y <-32767.5) || (posInTile.y > 32766.5)) {result=globePosition;const float poles_hidden_anim_percentage=0.02;result.z=mix(globePosition.z,100.0,pow(max((1.0-u_projection_transition)/poles_hidden_anim_percentage,0.0),8.0));}return result;}vec4 interpolateProjectionFor3D(vec2 posInTile,vec3 spherePos,float elevation) {v_projection_tile_x=posInTile.x;vec3 elevatedPos=spherePos*(1.0+elevation/GLOBE_RADIUS);vec4 globePosition=u_projection_matrix*vec4(elevatedPos,1.0);if (u_projection_transition > 0.999) {return globePosition;}vec4 fallbackPosition=u_projection_fallback_matrix*vec4(posInTile,elevation,1.0);return mix(fallbackPosition,globePosition,u_projection_transition);}vec4 projectTile(vec2 posInTile) {return interpolateProjection(posInTile,projectToSphere(posInTile),0.0);}vec4 projectTile(vec2 posInTile,vec2 rawPos) {return interpolateProjection(posInTile,projectToSphere(posInTile,rawPos),0.0);}vec4 projectTileWithElevation(vec2 posInTile,float elevation) {return interpolateProjection(posInTile,projectToSphere(posInTile),elevation);}vec4 projectTileFor3D(vec2 posInTile,float elevation) {vec3 spherePos=projectToSphere(posInTile,posInTile);return interpolateProjectionFor3D(posInTile,spherePos,elevation);}`),background:be(O3,j3),backgroundPattern:be(V3,N3),circle:be(U3,$3),clippingMask:be($g,"layout(location=0) in vec2 a_pos;void main() {gl_Position=projectTile(a_pos,a_pos);}"),heatmap:be(`uniform highp float u_intensity;in vec2 v_extrude;
|
|
131
|
+
#pragma maplibre: define highp float weight
|
|
132
|
+
#define GAUSS_COEF 0.3989422804014327
|
|
133
|
+
void main() {
|
|
134
|
+
#pragma maplibre: initialize highp float weight
|
|
135
|
+
float d=-0.5*3.0*3.0*dot(v_extrude,v_extrude);float val=weight*u_intensity*GAUSS_COEF*exp(d);fragColor=vec4(val,1.0,1.0,1.0);
|
|
136
|
+
#ifdef OVERDRAW_INSPECTOR
|
|
137
|
+
fragColor=vec4(1.0);
|
|
138
|
+
#endif
|
|
139
|
+
}`,`uniform float u_extrude_scale;uniform float u_opacity;uniform float u_intensity;uniform highp float u_globe_extrude_scale;layout(location=0) in ivec2 a_pos;out vec2 v_extrude;
|
|
140
|
+
#pragma maplibre: define highp float weight
|
|
141
|
+
#pragma maplibre: define mediump float radius
|
|
142
|
+
const highp float ZERO=1.0/255.0/16.0;
|
|
143
|
+
#define GAUSS_COEF 0.3989422804014327
|
|
144
|
+
void main(void) {
|
|
145
|
+
#pragma maplibre: initialize highp float weight
|
|
146
|
+
#pragma maplibre: initialize mediump float radius
|
|
147
|
+
ivec2 pos_raw=a_pos+32768;vec2 unscaled_extrude=vec2(pos_raw & 7)/7.0*2.0-1.0;float S=sqrt(-2.0*log(ZERO/weight/u_intensity/GAUSS_COEF))/3.0;v_extrude=S*unscaled_extrude;vec2 extrude=v_extrude*radius*u_extrude_scale;vec2 circle_center=vec2(pos_raw >> 3);
|
|
148
|
+
#ifdef GLOBE
|
|
149
|
+
vec2 angles=v_extrude*radius*u_globe_extrude_scale;vec3 center_vector=projectToSphere(circle_center);vec3 corner_vector=globeRotateVector(center_vector,angles);gl_Position=interpolateProjection(circle_center+extrude,corner_vector,0.0);
|
|
150
|
+
#else
|
|
151
|
+
gl_Position=projectTileFor3D(circle_center+extrude,get_elevation(circle_center));
|
|
152
|
+
#endif
|
|
153
|
+
}`),heatmapTexture:be(`uniform sampler2D u_image;uniform sampler2D u_color_ramp;uniform float u_opacity;in vec2 v_pos;void main() {float t=texture(u_image,v_pos).r;vec4 color=texture(u_color_ramp,vec2(t,0.5));fragColor=color*u_opacity;
|
|
154
|
+
#ifdef OVERDRAW_INSPECTOR
|
|
155
|
+
fragColor=vec4(0.0);
|
|
156
|
+
#endif
|
|
157
|
+
}`,"uniform mat4 u_matrix;layout(location=0) in vec2 a_pos;out vec2 v_pos;void main() {gl_Position=u_matrix*vec4(a_pos*u_world_size,0,1);v_pos.x=a_pos.x;v_pos.y=1.0-a_pos.y;}"),collisionBox:be("flat in float v_placed;flat in float v_notUsed;void main() {float alpha=0.5;fragColor=vec4(1.0,0.0,0.0,1.0)*alpha;if (v_placed > 0.5) {fragColor=vec4(0.0,0.0,1.0,0.5)*alpha;}if (v_notUsed > 0.5) {fragColor*=.1;}}","layout(location=0) in vec2 a_anchor_pos;layout(location=1) in vec2 a_placed;layout(location=2) in vec2 a_box_real;flat out float v_placed;flat out float v_notUsed;void main() {gl_Position=projectTileWithElevation(a_anchor_pos,get_elevation(a_anchor_pos));gl_Position.xy=((a_box_real+0.5)*u_pixel_extrude_scale*2.0-1.0)*vec2(1.0,-1.0)*gl_Position.w;if (gl_Position.z/gl_Position.w < 1.1) {gl_Position.z=0.5;}v_placed=a_placed.x;v_notUsed=a_placed.y;}"),collisionCircle:be("flat in float v_radius;in vec2 v_extrude;flat in float v_collision;void main() {float alpha=0.5;float stroke_radius=0.9;float distance_to_center=length(v_extrude);float distance_to_edge=abs(distance_to_center-v_radius);float opacity_t=smoothstep(-stroke_radius,0.0,-distance_to_edge);vec4 color=mix(vec4(0.0,0.0,1.0,0.5),vec4(1.0,0.0,0.0,1.0),v_collision);fragColor=color*alpha*opacity_t;}","layout(location=0) in vec2 a_pos;layout(location=1) in float a_radius;layout(location=2) in vec2 a_flags;flat out float v_radius;out vec2 v_extrude;flat out float v_collision;void main() {float radius=a_radius;float collision=a_flags.x;float vertexIdx=a_flags.y;vec2 quadVertexOffset=vec2(mix(-1.0,1.0,float(vertexIdx >=2.0)),mix(-1.0,1.0,float(vertexIdx >=1.0 && vertexIdx <=2.0)));vec2 quadVertexExtent=quadVertexOffset*radius;float padding_factor=1.2;v_radius=radius;v_extrude=quadVertexExtent*padding_factor;v_collision=collision;gl_Position=vec4((a_pos/u_viewport_size*2.0-1.0)*vec2(1.0,-1.0),0.0,1.0)+vec4(quadVertexExtent*padding_factor/u_viewport_size*2.0,0.0,0.0);}"),colorRelief:be(`#ifdef GL_ES
|
|
158
|
+
precision highp float;
|
|
159
|
+
#endif
|
|
160
|
+
uniform sampler2D u_image;uniform vec4 u_unpack;uniform sampler2D u_elevation_stops;uniform sampler2D u_color_stops;uniform int u_color_ramp_size;uniform float u_opacity;in vec2 v_pos;float getElevation(vec2 coord) {vec4 data=texture(u_image,coord)*255.0;data.a=-1.0;return dot(data,u_unpack);}float getElevationStop(int stop) {vec4 data=texelFetch(u_elevation_stops,ivec2(stop,0),0)*255.0;data.a=-1.0;return dot(data,u_unpack);}void main() {float el=getElevation(v_pos);int r=(u_color_ramp_size-1);int l=0;float el_l=getElevationStop(l);float el_r=getElevationStop(r);while(r-l > 1){int m=(r+l)/2;float el_m=getElevationStop(m);if(el < el_m){r=m;el_r=el_m;}else
|
|
161
|
+
{l=m;el_l=el_m;}}float x=(float(l)+(el-el_l)/(el_r-el_l)+0.5)/float(u_color_ramp_size);fragColor=u_opacity*texture(u_color_stops,vec2(x,0));
|
|
162
|
+
#ifdef OVERDRAW_INSPECTOR
|
|
163
|
+
fragColor=vec4(1.0);
|
|
164
|
+
#endif
|
|
165
|
+
}`,"uniform vec2 u_dimension;layout(location=0) in vec2 a_pos;out vec2 v_pos;void main() {gl_Position=projectTile(a_pos,a_pos);highp vec2 epsilon=2.0/u_dimension;float scale=(u_dimension.x-4.0)/u_dimension.x;v_pos=(a_pos/8192.0)*scale+epsilon;if (a_pos.y <-32767.5) {v_pos.y=0.0;}if (a_pos.y > 32766.5) {v_pos.y=1.0;}}"),debug:be("uniform highp vec4 u_color;uniform sampler2D u_overlay;in vec2 v_uv;void main() {vec4 overlay_color=texture(u_overlay,v_uv);fragColor=mix(u_color,overlay_color,overlay_color.a);}","layout(location=0) in vec2 a_pos;out vec2 v_uv;uniform float u_overlay_scale;void main() {v_uv=a_pos/8192.0;gl_Position=projectTileWithElevation(a_pos*u_overlay_scale,get_elevation(a_pos));}"),depth:be($g,`layout(location=0) in vec2 a_pos;void main() {
|
|
166
|
+
#ifdef GLOBE
|
|
167
|
+
gl_Position=projectTileFor3D(a_pos,0.0);
|
|
168
|
+
#else
|
|
169
|
+
gl_Position=u_projection_matrix*vec4(a_pos,0.0,1.0);
|
|
170
|
+
#endif
|
|
171
|
+
}`),fill:be(`#pragma maplibre: define highp vec4 color
|
|
172
|
+
#pragma maplibre: define lowp float opacity
|
|
173
|
+
void main() {
|
|
174
|
+
#pragma maplibre: initialize highp vec4 color
|
|
175
|
+
#pragma maplibre: initialize lowp float opacity
|
|
176
|
+
fragColor=color*opacity;
|
|
177
|
+
#ifdef OVERDRAW_INSPECTOR
|
|
178
|
+
fragColor=vec4(1.0);
|
|
179
|
+
#endif
|
|
180
|
+
}`,`uniform vec2 u_fill_translate;layout(location=0) in vec2 a_pos;
|
|
181
|
+
#pragma maplibre: define highp vec4 color
|
|
182
|
+
#pragma maplibre: define lowp float opacity
|
|
183
|
+
void main() {
|
|
184
|
+
#pragma maplibre: initialize highp vec4 color
|
|
185
|
+
#pragma maplibre: initialize lowp float opacity
|
|
186
|
+
if (opacity < 0.01) {gl_Position=vec4(-2.0,-2.0,-2.0,1.0);return;}gl_Position=projectTile(a_pos+u_fill_translate,a_pos);}`),fillOutline:be(`in vec2 v_pos;
|
|
187
|
+
#ifdef GLOBE
|
|
188
|
+
in float v_depth;
|
|
189
|
+
#endif
|
|
190
|
+
#pragma maplibre: define highp vec4 outline_color
|
|
191
|
+
#pragma maplibre: define lowp float opacity
|
|
192
|
+
void main() {
|
|
193
|
+
#pragma maplibre: initialize highp vec4 outline_color
|
|
194
|
+
#pragma maplibre: initialize lowp float opacity
|
|
195
|
+
float dist=length(v_pos-gl_FragCoord.xy);float alpha=1.0-smoothstep(0.0,1.0,dist);fragColor=outline_color*(alpha*opacity);
|
|
196
|
+
#ifdef GLOBE
|
|
197
|
+
if (v_depth > 1.0) {discard;}
|
|
198
|
+
#endif
|
|
199
|
+
#ifdef OVERDRAW_INSPECTOR
|
|
200
|
+
fragColor=vec4(1.0);
|
|
201
|
+
#endif
|
|
202
|
+
}`,`uniform vec2 u_fill_translate;layout(location=0) in vec2 a_pos;out vec2 v_pos;
|
|
203
|
+
#ifdef GLOBE
|
|
204
|
+
out float v_depth;
|
|
205
|
+
#endif
|
|
206
|
+
#pragma maplibre: define highp vec4 outline_color
|
|
207
|
+
#pragma maplibre: define lowp float opacity
|
|
208
|
+
void main() {
|
|
209
|
+
#pragma maplibre: initialize highp vec4 outline_color
|
|
210
|
+
#pragma maplibre: initialize lowp float opacity
|
|
211
|
+
if (opacity < 0.01) {gl_Position=vec4(-2.0,-2.0,-2.0,1.0);return;}gl_Position=projectTile(a_pos+u_fill_translate,a_pos);v_pos=(gl_Position.xy/gl_Position.w+1.0)/2.0*u_world_size;
|
|
212
|
+
#ifdef GLOBE
|
|
213
|
+
v_depth=gl_Position.z/gl_Position.w;
|
|
214
|
+
#endif
|
|
215
|
+
}`),fillOutlinePattern:be(`uniform vec2 u_texsize;uniform sampler2D u_image;uniform float u_fade;uniform bool u_sdf_pattern;in vec2 v_pos_a;in vec2 v_pos_b;in vec2 v_pos;
|
|
216
|
+
#ifdef GLOBE
|
|
217
|
+
in float v_depth;
|
|
218
|
+
#endif
|
|
219
|
+
#pragma maplibre: define lowp float opacity
|
|
220
|
+
#pragma maplibre: define highp vec4 color
|
|
221
|
+
#pragma maplibre: define lowp vec4 pattern_from
|
|
222
|
+
#pragma maplibre: define lowp vec4 pattern_to
|
|
223
|
+
void main() {
|
|
224
|
+
#pragma maplibre: initialize lowp float opacity
|
|
225
|
+
#pragma maplibre: initialize highp vec4 color
|
|
226
|
+
#pragma maplibre: initialize mediump vec4 pattern_from
|
|
227
|
+
#pragma maplibre: initialize mediump vec4 pattern_to
|
|
228
|
+
vec2 pattern_tl_a=pattern_from.xy;vec2 pattern_br_a=pattern_from.zw;vec2 pattern_tl_b=pattern_to.xy;vec2 pattern_br_b=pattern_to.zw;vec2 imagecoord=mod(v_pos_a,1.0);vec2 pos=mix(pattern_tl_a/u_texsize,pattern_br_a/u_texsize,imagecoord);vec4 color1=texture(u_image,pos);vec2 imagecoord_b=mod(v_pos_b,1.0);vec2 pos2=mix(pattern_tl_b/u_texsize,pattern_br_b/u_texsize,imagecoord_b);vec4 color2=texture(u_image,pos2);float dist=length(v_pos-gl_FragCoord.xy);float alpha=1.0-smoothstep(0.0,1.0,dist);if (u_sdf_pattern) {highp float sdf_edge=(256.0-64.0)/256.0;highp float sdf_gamma_a=max(fwidth(color1.a)*0.5,1.0/255.0/16.0);highp float sdf_gamma_b=max(fwidth(color2.a)*0.5,1.0/255.0/16.0);float sdf_alpha_a=smoothstep(sdf_edge-sdf_gamma_a,sdf_edge+sdf_gamma_a,color1.a);float sdf_alpha_b=smoothstep(sdf_edge-sdf_gamma_b,sdf_edge+sdf_gamma_b,color2.a);fragColor=mix(color*sdf_alpha_a,color*sdf_alpha_b,u_fade)*alpha*opacity;} else {fragColor=mix(color1,color2,u_fade)*alpha*opacity;}
|
|
229
|
+
#ifdef GLOBE
|
|
230
|
+
if (v_depth > 1.0) {discard;}
|
|
231
|
+
#endif
|
|
232
|
+
#ifdef OVERDRAW_INSPECTOR
|
|
233
|
+
fragColor=vec4(1.0);
|
|
234
|
+
#endif
|
|
235
|
+
}`,`uniform vec2 u_pixel_coord_upper;uniform vec2 u_pixel_coord_lower;uniform vec3 u_scale;uniform vec2 u_fill_translate;layout(location=0) in vec2 a_pos;out vec2 v_pos_a;out vec2 v_pos_b;out vec2 v_pos;
|
|
236
|
+
#ifdef GLOBE
|
|
237
|
+
out float v_depth;
|
|
238
|
+
#endif
|
|
239
|
+
#pragma maplibre: define lowp float opacity
|
|
240
|
+
#pragma maplibre: define highp vec4 color
|
|
241
|
+
#pragma maplibre: define lowp vec4 pattern_from
|
|
242
|
+
#pragma maplibre: define lowp vec4 pattern_to
|
|
243
|
+
#pragma maplibre: define lowp float pixel_ratio_from
|
|
244
|
+
#pragma maplibre: define lowp float pixel_ratio_to
|
|
245
|
+
void main() {
|
|
246
|
+
#pragma maplibre: initialize lowp float opacity
|
|
247
|
+
#pragma maplibre: initialize highp vec4 color
|
|
248
|
+
#pragma maplibre: initialize mediump vec4 pattern_from
|
|
249
|
+
#pragma maplibre: initialize mediump vec4 pattern_to
|
|
250
|
+
#pragma maplibre: initialize lowp float pixel_ratio_from
|
|
251
|
+
#pragma maplibre: initialize lowp float pixel_ratio_to
|
|
252
|
+
if (opacity < 0.01) {gl_Position=vec4(-2.0,-2.0,-2.0,1.0);return;}vec2 pattern_tl_a=pattern_from.xy;vec2 pattern_br_a=pattern_from.zw;vec2 pattern_tl_b=pattern_to.xy;vec2 pattern_br_b=pattern_to.zw;float tileRatio=u_scale.x;float fromScale=u_scale.y;float toScale=u_scale.z;gl_Position=projectTile(a_pos+u_fill_translate,a_pos);vec2 display_size_a=(pattern_br_a-pattern_tl_a)/pixel_ratio_from;vec2 display_size_b=(pattern_br_b-pattern_tl_b)/pixel_ratio_to;v_pos_a=get_pattern_pos(u_pixel_coord_upper,u_pixel_coord_lower,fromScale*display_size_a,tileRatio,a_pos);v_pos_b=get_pattern_pos(u_pixel_coord_upper,u_pixel_coord_lower,toScale*display_size_b,tileRatio,a_pos);v_pos=(gl_Position.xy/gl_Position.w+1.0)/2.0*u_world_size;
|
|
253
|
+
#ifdef GLOBE
|
|
254
|
+
v_depth=gl_Position.z/gl_Position.w;
|
|
255
|
+
#endif
|
|
256
|
+
}`),fillPattern:be(`#ifdef GL_ES
|
|
257
|
+
precision highp float;
|
|
258
|
+
#endif
|
|
259
|
+
uniform vec2 u_texsize;uniform float u_fade;uniform bool u_sdf_pattern;uniform sampler2D u_image;in vec2 v_pos_a;in vec2 v_pos_b;
|
|
260
|
+
#pragma maplibre: define lowp float opacity
|
|
261
|
+
#pragma maplibre: define highp vec4 color
|
|
262
|
+
#pragma maplibre: define lowp vec4 pattern_from
|
|
263
|
+
#pragma maplibre: define lowp vec4 pattern_to
|
|
264
|
+
void main() {
|
|
265
|
+
#pragma maplibre: initialize lowp float opacity
|
|
266
|
+
#pragma maplibre: initialize highp vec4 color
|
|
267
|
+
#pragma maplibre: initialize mediump vec4 pattern_from
|
|
268
|
+
#pragma maplibre: initialize mediump vec4 pattern_to
|
|
269
|
+
vec2 pattern_tl_a=pattern_from.xy;vec2 pattern_br_a=pattern_from.zw;vec2 pattern_tl_b=pattern_to.xy;vec2 pattern_br_b=pattern_to.zw;vec2 imagecoord=mod(v_pos_a,1.0);vec2 pos=mix(pattern_tl_a/u_texsize,pattern_br_a/u_texsize,imagecoord);vec4 color1=texture(u_image,pos);vec2 imagecoord_b=mod(v_pos_b,1.0);vec2 pos2=mix(pattern_tl_b/u_texsize,pattern_br_b/u_texsize,imagecoord_b);vec4 color2=texture(u_image,pos2);if (u_sdf_pattern) {highp float sdf_edge=(256.0-64.0)/256.0;highp float sdf_gamma_a=max(fwidth(color1.a)*0.5,1.0/255.0/16.0);highp float sdf_gamma_b=max(fwidth(color2.a)*0.5,1.0/255.0/16.0);float sdf_alpha_a=smoothstep(sdf_edge-sdf_gamma_a,sdf_edge+sdf_gamma_a,color1.a);float sdf_alpha_b=smoothstep(sdf_edge-sdf_gamma_b,sdf_edge+sdf_gamma_b,color2.a);fragColor=mix(color*sdf_alpha_a,color*sdf_alpha_b,u_fade)*opacity;} else {fragColor=mix(color1,color2,u_fade)*opacity;}
|
|
270
|
+
#ifdef OVERDRAW_INSPECTOR
|
|
271
|
+
fragColor=vec4(1.0);
|
|
272
|
+
#endif
|
|
273
|
+
}`,`uniform vec2 u_pixel_coord_upper;uniform vec2 u_pixel_coord_lower;uniform vec3 u_scale;uniform vec2 u_fill_translate;layout(location=0) in vec2 a_pos;out vec2 v_pos_a;out vec2 v_pos_b;
|
|
274
|
+
#pragma maplibre: define lowp float opacity
|
|
275
|
+
#pragma maplibre: define highp vec4 color
|
|
276
|
+
#pragma maplibre: define lowp vec4 pattern_from
|
|
277
|
+
#pragma maplibre: define lowp vec4 pattern_to
|
|
278
|
+
#pragma maplibre: define lowp float pixel_ratio_from
|
|
279
|
+
#pragma maplibre: define lowp float pixel_ratio_to
|
|
280
|
+
void main() {
|
|
281
|
+
#pragma maplibre: initialize lowp float opacity
|
|
282
|
+
#pragma maplibre: initialize highp vec4 color
|
|
283
|
+
#pragma maplibre: initialize mediump vec4 pattern_from
|
|
284
|
+
#pragma maplibre: initialize mediump vec4 pattern_to
|
|
285
|
+
#pragma maplibre: initialize lowp float pixel_ratio_from
|
|
286
|
+
#pragma maplibre: initialize lowp float pixel_ratio_to
|
|
287
|
+
if (opacity < 0.01) {gl_Position=vec4(-2.0,-2.0,-2.0,1.0);return;}vec2 pattern_tl_a=pattern_from.xy;vec2 pattern_br_a=pattern_from.zw;vec2 pattern_tl_b=pattern_to.xy;vec2 pattern_br_b=pattern_to.zw;float tileZoomRatio=u_scale.x;float fromScale=u_scale.y;float toScale=u_scale.z;vec2 display_size_a=(pattern_br_a-pattern_tl_a)/pixel_ratio_from;vec2 display_size_b=(pattern_br_b-pattern_tl_b)/pixel_ratio_to;gl_Position=projectTile(a_pos+u_fill_translate,a_pos);v_pos_a=get_pattern_pos(u_pixel_coord_upper,u_pixel_coord_lower,fromScale*display_size_a,tileZoomRatio,a_pos);v_pos_b=get_pattern_pos(u_pixel_coord_upper,u_pixel_coord_lower,toScale*display_size_b,tileZoomRatio,a_pos);}`),fillExtrusion:be(`in vec4 v_color;void main() {fragColor=v_color;
|
|
288
|
+
#ifdef OVERDRAW_INSPECTOR
|
|
289
|
+
fragColor=vec4(1.0);
|
|
290
|
+
#endif
|
|
291
|
+
}`,`uniform vec3 u_lightcolor;uniform lowp vec3 u_lightpos;uniform lowp vec3 u_lightpos_globe;uniform lowp float u_lightintensity;uniform float u_vertical_gradient;uniform lowp float u_opacity;uniform vec2 u_fill_translate;layout(location=0) in vec2 a_pos;layout(location=1) in ivec4 a_normal_ed;
|
|
292
|
+
#ifdef TERRAIN3D
|
|
293
|
+
layout(location=2) in vec2 a_centroid;
|
|
294
|
+
#endif
|
|
295
|
+
out vec4 v_color;
|
|
296
|
+
#pragma maplibre: define highp float base
|
|
297
|
+
#pragma maplibre: define highp float height
|
|
298
|
+
#pragma maplibre: define highp vec4 color
|
|
299
|
+
void main() {
|
|
300
|
+
#pragma maplibre: initialize highp float base
|
|
301
|
+
#pragma maplibre: initialize highp float height
|
|
302
|
+
#pragma maplibre: initialize highp vec4 color
|
|
303
|
+
vec3 normal=vec3(a_normal_ed.xyz);float gradient_base=max(0.0,base);float gradient_height=max(0.0,height);
|
|
304
|
+
#ifdef TERRAIN3D
|
|
305
|
+
float height_terrain3d_offset=get_elevation(a_centroid);float base_terrain3d_offset=height_terrain3d_offset-(base > 0.0 ? 0.0 : 10.0);
|
|
306
|
+
#else
|
|
307
|
+
float height_terrain3d_offset=0.0;float base_terrain3d_offset=0.0;
|
|
308
|
+
#endif
|
|
309
|
+
base=max(0.0,base)+base_terrain3d_offset;height=max(0.0,height)+height_terrain3d_offset;float t=float(a_normal_ed.x & 1);float elevation=t > 0.0 ? height : base;vec2 posInTile=a_pos+u_fill_translate;
|
|
310
|
+
#ifdef GLOBE
|
|
311
|
+
vec3 spherePos=projectToSphere(posInTile,a_pos);gl_Position=interpolateProjectionFor3D(posInTile,spherePos,elevation);
|
|
312
|
+
#else
|
|
313
|
+
gl_Position=u_projection_matrix*vec4(posInTile,elevation,1.0);
|
|
314
|
+
#endif
|
|
315
|
+
float colorvalue=color.r*0.2126+color.g*0.7152+color.b*0.0722;v_color=vec4(0.0,0.0,0.0,1.0);vec4 ambientlight=vec4(0.03,0.03,0.03,1.0);color+=ambientlight;vec3 normalForLighting=normal/16384.0;float directional=clamp(dot(normalForLighting,u_lightpos),0.0,1.0);
|
|
316
|
+
#ifdef GLOBE
|
|
317
|
+
mat3 rotMatrix=globeGetRotationMatrix(spherePos);normalForLighting=rotMatrix*normalForLighting;directional=mix(directional,clamp(dot(normalForLighting,u_lightpos_globe),0.0,1.0),u_projection_transition);
|
|
318
|
+
#endif
|
|
319
|
+
directional=mix((1.0-u_lightintensity),max((1.0-colorvalue+u_lightintensity),1.0),directional);if (normal.z==0.0) {directional*=((1.0-u_vertical_gradient)+(u_vertical_gradient*clamp((t+gradient_base)*pow(gradient_height/150.0,0.5),mix(0.7,0.98,1.0-u_lightintensity),1.0)));}v_color.r+=clamp(color.r*directional*u_lightcolor.r,mix(0.0,0.3,1.0-u_lightcolor.r),1.0);v_color.g+=clamp(color.g*directional*u_lightcolor.g,mix(0.0,0.3,1.0-u_lightcolor.g),1.0);v_color.b+=clamp(color.b*directional*u_lightcolor.b,mix(0.0,0.3,1.0-u_lightcolor.b),1.0);v_color*=u_opacity;}`),fillExtrusionPattern:be(`uniform vec2 u_texsize;uniform float u_fade;uniform sampler2D u_image;in vec2 v_pos_a;in vec2 v_pos_b;in vec4 v_lighting;
|
|
320
|
+
#pragma maplibre: define lowp float base
|
|
321
|
+
#pragma maplibre: define lowp float height
|
|
322
|
+
#pragma maplibre: define lowp vec4 pattern_from
|
|
323
|
+
#pragma maplibre: define lowp vec4 pattern_to
|
|
324
|
+
#pragma maplibre: define lowp float pixel_ratio_from
|
|
325
|
+
#pragma maplibre: define lowp float pixel_ratio_to
|
|
326
|
+
void main() {
|
|
327
|
+
#pragma maplibre: initialize lowp float base
|
|
328
|
+
#pragma maplibre: initialize lowp float height
|
|
329
|
+
#pragma maplibre: initialize mediump vec4 pattern_from
|
|
330
|
+
#pragma maplibre: initialize mediump vec4 pattern_to
|
|
331
|
+
#pragma maplibre: initialize lowp float pixel_ratio_from
|
|
332
|
+
#pragma maplibre: initialize lowp float pixel_ratio_to
|
|
333
|
+
vec2 pattern_tl_a=pattern_from.xy;vec2 pattern_br_a=pattern_from.zw;vec2 pattern_tl_b=pattern_to.xy;vec2 pattern_br_b=pattern_to.zw;vec2 imagecoord=mod(v_pos_a,1.0);vec2 pos=mix(pattern_tl_a/u_texsize,pattern_br_a/u_texsize,imagecoord);vec4 color1=texture(u_image,pos);vec2 imagecoord_b=mod(v_pos_b,1.0);vec2 pos2=mix(pattern_tl_b/u_texsize,pattern_br_b/u_texsize,imagecoord_b);vec4 color2=texture(u_image,pos2);vec4 mixedColor=mix(color1,color2,u_fade);fragColor=mixedColor*v_lighting;
|
|
334
|
+
#ifdef OVERDRAW_INSPECTOR
|
|
335
|
+
fragColor=vec4(1.0);
|
|
336
|
+
#endif
|
|
337
|
+
}`,`uniform vec2 u_pixel_coord_upper;uniform vec2 u_pixel_coord_lower;uniform float u_height_factor;uniform vec3 u_scale;uniform float u_vertical_gradient;uniform lowp float u_opacity;uniform vec2 u_fill_translate;uniform vec3 u_lightcolor;uniform lowp vec3 u_lightpos;uniform lowp vec3 u_lightpos_globe;uniform lowp float u_lightintensity;layout(location=0) in vec2 a_pos;layout(location=1) in ivec4 a_normal_ed;
|
|
338
|
+
#ifdef TERRAIN3D
|
|
339
|
+
layout(location=2) in vec2 a_centroid;
|
|
340
|
+
#endif
|
|
341
|
+
#ifdef GLOBE
|
|
342
|
+
out vec3 v_sphere_pos;
|
|
343
|
+
#endif
|
|
344
|
+
out vec2 v_pos_a;out vec2 v_pos_b;out vec4 v_lighting;
|
|
345
|
+
#pragma maplibre: define lowp float base
|
|
346
|
+
#pragma maplibre: define lowp float height
|
|
347
|
+
#pragma maplibre: define lowp vec4 pattern_from
|
|
348
|
+
#pragma maplibre: define lowp vec4 pattern_to
|
|
349
|
+
#pragma maplibre: define lowp float pixel_ratio_from
|
|
350
|
+
#pragma maplibre: define lowp float pixel_ratio_to
|
|
351
|
+
void main() {
|
|
352
|
+
#pragma maplibre: initialize lowp float base
|
|
353
|
+
#pragma maplibre: initialize lowp float height
|
|
354
|
+
#pragma maplibre: initialize mediump vec4 pattern_from
|
|
355
|
+
#pragma maplibre: initialize mediump vec4 pattern_to
|
|
356
|
+
#pragma maplibre: initialize lowp float pixel_ratio_from
|
|
357
|
+
#pragma maplibre: initialize lowp float pixel_ratio_to
|
|
358
|
+
vec2 pattern_tl_a=pattern_from.xy;vec2 pattern_br_a=pattern_from.zw;vec2 pattern_tl_b=pattern_to.xy;vec2 pattern_br_b=pattern_to.zw;float tileRatio=u_scale.x;float fromScale=u_scale.y;float toScale=u_scale.z;vec3 normal=vec3(a_normal_ed.xyz);float edgedistance=float(a_normal_ed.w);vec2 display_size_a=(pattern_br_a-pattern_tl_a)/pixel_ratio_from;vec2 display_size_b=(pattern_br_b-pattern_tl_b)/pixel_ratio_to;float gradient_base=max(0.0,base);float gradient_height=max(0.0,height);
|
|
359
|
+
#ifdef TERRAIN3D
|
|
360
|
+
float height_terrain3d_offset=get_elevation(a_centroid);float base_terrain3d_offset=height_terrain3d_offset-(base > 0.0 ? 0.0 : 10.0);
|
|
361
|
+
#else
|
|
362
|
+
float height_terrain3d_offset=0.0;float base_terrain3d_offset=0.0;
|
|
363
|
+
#endif
|
|
364
|
+
base=max(0.0,base)+base_terrain3d_offset;height=max(0.0,height)+height_terrain3d_offset;float t=float(a_normal_ed.x & 1);float elevation=t > 0.0 ? height : base;vec2 posInTile=a_pos+u_fill_translate;
|
|
365
|
+
#ifdef GLOBE
|
|
366
|
+
vec3 spherePos=projectToSphere(posInTile,a_pos);vec3 elevatedPos=spherePos*(1.0+elevation/GLOBE_RADIUS);v_sphere_pos=elevatedPos;gl_Position=interpolateProjectionFor3D(posInTile,spherePos,elevation);
|
|
367
|
+
#else
|
|
368
|
+
gl_Position=u_projection_matrix*vec4(posInTile,elevation,1.0);
|
|
369
|
+
#endif
|
|
370
|
+
vec2 pos=a_normal_ed.x==1 && a_normal_ed.y==0 && a_normal_ed.z==16384
|
|
371
|
+
? a_pos
|
|
372
|
+
: vec2(edgedistance,elevation*u_height_factor);v_pos_a=get_pattern_pos(u_pixel_coord_upper,u_pixel_coord_lower,fromScale*display_size_a,tileRatio,pos);v_pos_b=get_pattern_pos(u_pixel_coord_upper,u_pixel_coord_lower,toScale*display_size_b,tileRatio,pos);v_lighting=vec4(0.0,0.0,0.0,1.0);float directional=clamp(dot(normal/16383.0,u_lightpos),0.0,1.0);directional=mix((1.0-u_lightintensity),max((0.5+u_lightintensity),1.0),directional);if (normal.z==0.0) {directional*=((1.0-u_vertical_gradient)+(u_vertical_gradient*clamp((t+gradient_base)*pow(gradient_height/150.0,0.5),mix(0.7,0.98,1.0-u_lightintensity),1.0)));}v_lighting.rgb+=clamp(directional*u_lightcolor,mix(vec3(0.0),vec3(0.3),1.0-u_lightcolor),vec3(1.0));v_lighting*=u_opacity;}`),hillshadePrepare:be(`#ifdef GL_ES
|
|
373
|
+
precision highp float;
|
|
374
|
+
#endif
|
|
375
|
+
uniform sampler2D u_image;in vec2 v_pos;uniform vec2 u_dimension;uniform float u_zoom;uniform vec4 u_unpack;float getElevation(ivec2 texel) {vec4 data=texelFetch(u_image,texel,0)*255.0;data.a=-1.0;return dot(data,u_unpack);}void main() {ivec2 pos=ivec2(gl_FragCoord.xy)+ivec2(1);float tileSize=u_dimension.x-4.0;float a=getElevation(pos+ivec2(-1,-1));float b=getElevation(pos+ivec2(0,-1));float c=getElevation(pos+ivec2(1,-1));float d=getElevation(pos+ivec2(-1,0));float e=getElevation(pos);float f=getElevation(pos+ivec2(1,0));float g=getElevation(pos+ivec2(-1,1));float h=getElevation(pos+ivec2(0,1));float i=getElevation(pos+ivec2(1,1));float exaggerationFactor=u_zoom < 2.0 ? 0.4 : u_zoom < 4.5 ? 0.35 : 0.3;float exaggeration=u_zoom < 15.0 ? (u_zoom-15.0)*exaggerationFactor : 0.0;vec2 deriv=vec2((c+f+f+i)-(a+d+d+g),(g+h+h+i)-(a+b+b+c))*tileSize/pow(2.0,exaggeration+(28.2562-u_zoom));fragColor=clamp(vec4(deriv.x/8.0+128.0/255.0,deriv.y/8.0+128.0/255.0,1.0,1.0),0.0,1.0);
|
|
376
|
+
#ifdef OVERDRAW_INSPECTOR
|
|
377
|
+
fragColor=vec4(1.0);
|
|
378
|
+
#endif
|
|
379
|
+
}`,"uniform mat4 u_matrix;uniform vec2 u_dimension;layout(location=0) in vec2 a_pos;layout(location=1) in vec2 a_texture_pos;out vec2 v_pos;void main() {gl_Position=u_matrix*vec4(a_pos,0,1);highp vec2 epsilon=1.0/u_dimension;float scale=(u_dimension.x-2.0)/u_dimension.x;v_pos=(a_texture_pos/8192.0)*scale+epsilon;}"),hillshade:be(`uniform sampler2D u_image;in highp vec2 v_pos;uniform vec2 u_latrange;uniform float u_exaggeration;uniform vec4 u_accent;uniform int u_method;uniform float u_altitudes[NUM_ILLUMINATION_SOURCES];uniform float u_azimuths[NUM_ILLUMINATION_SOURCES];uniform vec4 u_shadows[NUM_ILLUMINATION_SOURCES];uniform vec4 u_highlights[NUM_ILLUMINATION_SOURCES];
|
|
380
|
+
#define PI 3.141592653589793
|
|
381
|
+
#define STANDARD 0
|
|
382
|
+
#define COMBINED 1
|
|
383
|
+
#define IGOR 2
|
|
384
|
+
#define MULTIDIRECTIONAL 3
|
|
385
|
+
#define BASIC 4
|
|
386
|
+
float get_aspect(vec2 deriv){return deriv.x !=0.0 ? atan(deriv.y,-deriv.x) : PI/2.0*(deriv.y > 0.0 ? 1.0 :-1.0);}void igor_hillshade(vec2 deriv){deriv=deriv*u_exaggeration*2.0;float aspect=get_aspect(deriv);float azimuth=u_azimuths[0]+PI;float slope_stength=atan(length(deriv))*2.0/PI;float aspect_strength=1.0-abs(mod((aspect+azimuth)/PI+0.5,2.0)-1.0);float shadow_strength=slope_stength*aspect_strength;float highlight_strength=slope_stength*(1.0-aspect_strength);fragColor=u_shadows[0]*shadow_strength+u_highlights[0]*highlight_strength;}void standard_hillshade(vec2 deriv){float azimuth=u_azimuths[0]+PI;float slope=atan(0.625*length(deriv));float aspect=get_aspect(deriv);float intensity=u_exaggeration;float base=1.875-intensity*1.75;float maxValue=0.5*PI;float scaledSlope=intensity !=0.5 ? ((pow(base,slope)-1.0)/(pow(base,maxValue)-1.0))*maxValue : slope;float accent=cos(scaledSlope);vec4 accent_color=(1.0-accent)*u_accent*clamp(intensity*2.0,0.0,1.0);float shade=abs(mod((aspect+azimuth)/PI+0.5,2.0)-1.0);vec4 shade_color=mix(u_shadows[0],u_highlights[0],shade)*sin(scaledSlope)*clamp(intensity*2.0,0.0,1.0);fragColor=accent_color*(1.0-shade_color.a)+shade_color;}void basic_hillshade(vec2 deriv){deriv=deriv*u_exaggeration*2.0;float azimuth=u_azimuths[0]+PI;float cos_az=cos(azimuth);float sin_az=sin(azimuth);float cos_alt=cos(u_altitudes[0]);float sin_alt=sin(u_altitudes[0]);float cang=(sin_alt-(deriv.y*cos_az*cos_alt-deriv.x*sin_az*cos_alt))/sqrt(1.0+dot(deriv,deriv));float shade=clamp(cang,0.0,1.0);if(shade > 0.5){fragColor=u_highlights[0]*(2.0*shade-1.0);}else
|
|
387
|
+
{fragColor=u_shadows[0]*(1.0-2.0*shade);}}void multidirectional_hillshade(vec2 deriv){deriv=deriv*u_exaggeration*2.0;fragColor=vec4(0,0,0,0);for(int i=0; i < NUM_ILLUMINATION_SOURCES; i++){float cos_alt=cos(u_altitudes[i]);float sin_alt=sin(u_altitudes[i]);float cos_az=-cos(u_azimuths[i]);float sin_az=-sin(u_azimuths[i]);float cang=(sin_alt-(deriv.y*cos_az*cos_alt-deriv.x*sin_az*cos_alt))/sqrt(1.0+dot(deriv,deriv));float shade=clamp(cang,0.0,1.0);if(shade > 0.5){fragColor+=u_highlights[i]*(2.0*shade-1.0)/float(NUM_ILLUMINATION_SOURCES);}else
|
|
388
|
+
{fragColor+=u_shadows[i]*(1.0-2.0*shade)/float(NUM_ILLUMINATION_SOURCES);}}}void combined_hillshade(vec2 deriv){deriv=deriv*u_exaggeration*2.0;float azimuth=u_azimuths[0]+PI;float cos_az=cos(azimuth);float sin_az=sin(azimuth);float cos_alt=cos(u_altitudes[0]);float sin_alt=sin(u_altitudes[0]);float cang=acos((sin_alt-(deriv.y*cos_az*cos_alt-deriv.x*sin_az*cos_alt))/sqrt(1.0+dot(deriv,deriv)));cang=clamp(cang,0.0,PI/2.0);float shade=cang*atan(length(deriv))*4.0/PI/PI;float highlight=(PI/2.0-cang)*atan(length(deriv))*4.0/PI/PI;fragColor=u_shadows[0]*shade+u_highlights[0]*highlight;}void main() {highp vec2 size=vec2(textureSize(u_image,0));highp vec2 texturePos=(v_pos*(size-2.0)+1.0)/size;vec4 pixel=texture(u_image,texturePos);float scaleFactor=cos(radians((u_latrange[0]-u_latrange[1])*(1.0-v_pos.y)+u_latrange[1]));vec2 deriv=(pixel.rg-128.0/255.0)*8.0/scaleFactor;if (u_method==BASIC) {basic_hillshade(deriv);} else if (u_method==COMBINED) {combined_hillshade(deriv);} else if (u_method==IGOR) {igor_hillshade(deriv);} else if (u_method==MULTIDIRECTIONAL) {multidirectional_hillshade(deriv);} else if (u_method==STANDARD) {standard_hillshade(deriv);} else {standard_hillshade(deriv);}
|
|
389
|
+
#ifdef OVERDRAW_INSPECTOR
|
|
390
|
+
fragColor=vec4(1.0);
|
|
391
|
+
#endif
|
|
392
|
+
}`,"uniform mat4 u_matrix;layout(location=0) in vec2 a_pos;out vec2 v_pos;void main() {gl_Position=projectTile(a_pos,a_pos);v_pos=a_pos/8192.0;if (a_pos.y <-32767.5) {v_pos.y=0.0;}if (a_pos.y > 32766.5) {v_pos.y=1.0;}}"),line:be(`flat in vec2 v_width2;in vec2 v_normal;in float v_gamma_scale;
|
|
393
|
+
#ifdef GLOBE
|
|
394
|
+
in float v_depth;
|
|
395
|
+
#endif
|
|
396
|
+
#pragma maplibre: define highp vec4 color
|
|
397
|
+
#pragma maplibre: define lowp float blur
|
|
398
|
+
#pragma maplibre: define lowp float opacity
|
|
399
|
+
void main() {
|
|
400
|
+
#pragma maplibre: initialize highp vec4 color
|
|
401
|
+
#pragma maplibre: initialize lowp float blur
|
|
402
|
+
#pragma maplibre: initialize lowp float opacity
|
|
403
|
+
clipAntimeridian();float dist=length(v_normal)*v_width2.s;float blur2=(blur+1.0/u_device_pixel_ratio)*v_gamma_scale;float alpha=clamp(min(dist-(v_width2.t-blur2),v_width2.s-dist)/blur2,0.0,1.0);fragColor=color*(alpha*opacity);
|
|
404
|
+
#ifdef GLOBE
|
|
405
|
+
if (v_depth > 1.0) {discard;}
|
|
406
|
+
#endif
|
|
407
|
+
#ifdef OVERDRAW_INSPECTOR
|
|
408
|
+
fragColor=vec4(1.0);
|
|
409
|
+
#endif
|
|
410
|
+
}`,`
|
|
411
|
+
#define scale 0.015873016
|
|
412
|
+
layout(location=0) in ivec2 a_pos_normal;layout(location=1) in uvec4 a_data;layout(location=2) in vec2 a_offset_normal;uniform vec2 u_translation;uniform mediump float u_ratio;out vec2 v_normal;flat out vec2 v_width2;out float v_gamma_scale;out highp float v_linesofar;
|
|
413
|
+
#ifdef GLOBE
|
|
414
|
+
out float v_depth;
|
|
415
|
+
#endif
|
|
416
|
+
#pragma maplibre: define highp vec4 color
|
|
417
|
+
#pragma maplibre: define lowp float blur
|
|
418
|
+
#pragma maplibre: define lowp float opacity
|
|
419
|
+
#pragma maplibre: define mediump float gapwidth
|
|
420
|
+
#pragma maplibre: define lowp float offset
|
|
421
|
+
#pragma maplibre: define mediump float width
|
|
422
|
+
void main() {
|
|
423
|
+
#pragma maplibre: initialize highp vec4 color
|
|
424
|
+
#pragma maplibre: initialize lowp float blur
|
|
425
|
+
#pragma maplibre: initialize lowp float opacity
|
|
426
|
+
#pragma maplibre: initialize mediump float gapwidth
|
|
427
|
+
#pragma maplibre: initialize lowp float offset
|
|
428
|
+
#pragma maplibre: initialize mediump float width
|
|
429
|
+
if (opacity < 0.01) {gl_Position=vec4(-2.0,-2.0,-2.0,1.0);return;}float ANTIALIASING=1.0/u_device_pixel_ratio/2.0;vec2 a_extrude=vec2(ivec2(a_data.xy)-128);v_linesofar=float((a_data.z >> 2u)+a_data.w*64u)*2.0;vec2 pos=vec2(a_pos_normal >> 1);mediump vec2 normal=vec2(a_pos_normal & 1);normal.y=normal.y*2.0-1.0;v_normal=normal;gapwidth=gapwidth/2.0;float halfwidth=width/2.0;offset=-1.0*offset;float inset=gapwidth+(gapwidth > 0.0 ? ANTIALIASING : 0.0);float outset=gapwidth+halfwidth*(gapwidth > 0.0 ? 2.0 : 1.0)+(halfwidth==0.0 ? 0.0 : ANTIALIASING);mediump vec2 dist=outset*a_extrude*scale;mediump vec2 offset2=offset*a_offset_normal*scale*normal.y;float adjustedThickness=projectLineThickness(pos.y);vec4 projected_no_extrude=projectTile(pos+offset2/u_ratio*adjustedThickness+u_translation);vec4 projected_with_extrude=projectTile(pos+offset2/u_ratio*adjustedThickness+u_translation+dist/u_ratio*adjustedThickness);gl_Position=projected_with_extrude;
|
|
430
|
+
#ifdef GLOBE
|
|
431
|
+
v_depth=gl_Position.z/gl_Position.w;
|
|
432
|
+
#endif
|
|
433
|
+
#ifdef TERRAIN3D
|
|
434
|
+
v_gamma_scale=1.0;
|
|
435
|
+
#else
|
|
436
|
+
float extrude_length_without_perspective=length(dist);float extrude_length_with_perspective=length((projected_with_extrude.xy-projected_no_extrude.xy)/projected_with_extrude.w*u_units_to_pixels);v_gamma_scale=extrude_length_without_perspective/extrude_length_with_perspective;
|
|
437
|
+
#endif
|
|
438
|
+
v_width2=vec2(outset,inset);}`),lineGradient:be(`uniform sampler2D u_image;flat in vec2 v_width2;in vec2 v_normal;in float v_gamma_scale;in highp vec2 v_uv;
|
|
439
|
+
#ifdef GLOBE
|
|
440
|
+
in float v_depth;
|
|
441
|
+
#endif
|
|
442
|
+
#pragma maplibre: define lowp float blur
|
|
443
|
+
#pragma maplibre: define lowp float opacity
|
|
444
|
+
void main() {
|
|
445
|
+
#pragma maplibre: initialize lowp float blur
|
|
446
|
+
#pragma maplibre: initialize lowp float opacity
|
|
447
|
+
clipAntimeridian();float dist=length(v_normal)*v_width2.s;float blur2=(blur+1.0/u_device_pixel_ratio)*v_gamma_scale;float alpha=clamp(min(dist-(v_width2.t-blur2),v_width2.s-dist)/blur2,0.0,1.0);vec4 color=texture(u_image,v_uv);fragColor=color*(alpha*opacity);
|
|
448
|
+
#ifdef GLOBE
|
|
449
|
+
if (v_depth > 1.0) {discard;}
|
|
450
|
+
#endif
|
|
451
|
+
#ifdef OVERDRAW_INSPECTOR
|
|
452
|
+
fragColor=vec4(1.0);
|
|
453
|
+
#endif
|
|
454
|
+
}`,`
|
|
455
|
+
#define scale 0.015873016
|
|
456
|
+
layout(location=0) in ivec2 a_pos_normal;layout(location=1) in uvec4 a_data;layout(location=2) in vec2 a_offset_normal;layout(location=3) in float a_uv_x;layout(location=4) in float a_split_index;uniform vec2 u_translation;uniform mediump float u_ratio;uniform float u_image_height;out vec2 v_normal;flat out vec2 v_width2;out float v_gamma_scale;out highp vec2 v_uv;
|
|
457
|
+
#ifdef GLOBE
|
|
458
|
+
out float v_depth;
|
|
459
|
+
#endif
|
|
460
|
+
#pragma maplibre: define lowp float blur
|
|
461
|
+
#pragma maplibre: define lowp float opacity
|
|
462
|
+
#pragma maplibre: define mediump float gapwidth
|
|
463
|
+
#pragma maplibre: define lowp float offset
|
|
464
|
+
#pragma maplibre: define mediump float width
|
|
465
|
+
void main() {
|
|
466
|
+
#pragma maplibre: initialize lowp float blur
|
|
467
|
+
#pragma maplibre: initialize lowp float opacity
|
|
468
|
+
#pragma maplibre: initialize mediump float gapwidth
|
|
469
|
+
#pragma maplibre: initialize lowp float offset
|
|
470
|
+
#pragma maplibre: initialize mediump float width
|
|
471
|
+
if (opacity < 0.01) {gl_Position=vec4(-2.0,-2.0,-2.0,1.0);return;}float ANTIALIASING=1.0/u_device_pixel_ratio/2.0;vec2 a_extrude=vec2(ivec2(a_data.xy)-128);highp float texel_height=1.0/u_image_height;highp float half_texel_height=0.5*texel_height;v_uv=vec2(a_uv_x,a_split_index*texel_height-half_texel_height);vec2 pos=vec2(a_pos_normal >> 1);mediump vec2 normal=vec2(a_pos_normal & 1);normal.y=normal.y*2.0-1.0;v_normal=normal;gapwidth=gapwidth/2.0;float halfwidth=width/2.0;offset=-1.0*offset;float inset=gapwidth+(gapwidth > 0.0 ? ANTIALIASING : 0.0);float outset=gapwidth+halfwidth*(gapwidth > 0.0 ? 2.0 : 1.0)+(halfwidth==0.0 ? 0.0 : ANTIALIASING);mediump vec2 dist=outset*a_extrude*scale;mediump vec2 offset2=offset*a_offset_normal*scale*normal.y;float adjustedThickness=projectLineThickness(pos.y);vec4 projected_no_extrude=projectTile(pos+offset2/u_ratio*adjustedThickness+u_translation);vec4 projected_with_extrude=projectTile(pos+offset2/u_ratio*adjustedThickness+u_translation+dist/u_ratio*adjustedThickness);gl_Position=projected_with_extrude;
|
|
472
|
+
#ifdef GLOBE
|
|
473
|
+
v_depth=gl_Position.z/gl_Position.w;
|
|
474
|
+
#endif
|
|
475
|
+
#ifdef TERRAIN3D
|
|
476
|
+
v_gamma_scale=1.0;
|
|
477
|
+
#else
|
|
478
|
+
float extrude_length_without_perspective=length(dist);float extrude_length_with_perspective=length((projected_with_extrude.xy-projected_no_extrude.xy)/projected_with_extrude.w*u_units_to_pixels);v_gamma_scale=extrude_length_without_perspective/extrude_length_with_perspective;
|
|
479
|
+
#endif
|
|
480
|
+
v_width2=vec2(outset,inset);}`),linePattern:be(`#ifdef GL_ES
|
|
481
|
+
precision highp float;
|
|
482
|
+
#endif
|
|
483
|
+
uniform vec2 u_texsize;uniform float u_fade;uniform mediump vec3 u_scale;uniform sampler2D u_image;in vec2 v_normal;flat in vec2 v_width2;in float v_linesofar;in float v_gamma_scale;flat in float v_width;
|
|
484
|
+
#ifdef GLOBE
|
|
485
|
+
in float v_depth;
|
|
486
|
+
#endif
|
|
487
|
+
#pragma maplibre: define lowp vec4 pattern_from
|
|
488
|
+
#pragma maplibre: define lowp vec4 pattern_to
|
|
489
|
+
#pragma maplibre: define lowp float pixel_ratio_from
|
|
490
|
+
#pragma maplibre: define lowp float pixel_ratio_to
|
|
491
|
+
#pragma maplibre: define lowp float blur
|
|
492
|
+
#pragma maplibre: define lowp float opacity
|
|
493
|
+
void main() {
|
|
494
|
+
#pragma maplibre: initialize mediump vec4 pattern_from
|
|
495
|
+
#pragma maplibre: initialize mediump vec4 pattern_to
|
|
496
|
+
#pragma maplibre: initialize lowp float pixel_ratio_from
|
|
497
|
+
#pragma maplibre: initialize lowp float pixel_ratio_to
|
|
498
|
+
#pragma maplibre: initialize lowp float blur
|
|
499
|
+
#pragma maplibre: initialize lowp float opacity
|
|
500
|
+
clipAntimeridian();vec2 pattern_tl_a=pattern_from.xy;vec2 pattern_br_a=pattern_from.zw;vec2 pattern_tl_b=pattern_to.xy;vec2 pattern_br_b=pattern_to.zw;float tileZoomRatio=u_scale.x;float fromScale=u_scale.y;float toScale=u_scale.z;vec2 display_size_a=(pattern_br_a-pattern_tl_a)/pixel_ratio_from;vec2 display_size_b=(pattern_br_b-pattern_tl_b)/pixel_ratio_to;vec2 pattern_size_a=vec2(display_size_a.x*fromScale/tileZoomRatio,display_size_a.y);vec2 pattern_size_b=vec2(display_size_b.x*toScale/tileZoomRatio,display_size_b.y);float aspect_a=display_size_a.y/v_width;float aspect_b=display_size_b.y/v_width;float dist=length(v_normal)*v_width2.s;float blur2=(blur+1.0/u_device_pixel_ratio)*v_gamma_scale;float alpha=clamp(min(dist-(v_width2.t-blur2),v_width2.s-dist)/blur2,0.0,1.0);float x_a=mod(v_linesofar/pattern_size_a.x*aspect_a,1.0);float x_b=mod(v_linesofar/pattern_size_b.x*aspect_b,1.0);float y=0.5*v_normal.y+0.5;vec2 texel_size=1.0/u_texsize;vec2 pos_a=mix(pattern_tl_a*texel_size-texel_size,pattern_br_a*texel_size+texel_size,vec2(x_a,y));vec2 pos_b=mix(pattern_tl_b*texel_size-texel_size,pattern_br_b*texel_size+texel_size,vec2(x_b,y));vec4 color=mix(texture(u_image,pos_a),texture(u_image,pos_b),u_fade);fragColor=color*alpha*opacity;
|
|
501
|
+
#ifdef GLOBE
|
|
502
|
+
if (v_depth > 1.0) {discard;}
|
|
503
|
+
#endif
|
|
504
|
+
#ifdef OVERDRAW_INSPECTOR
|
|
505
|
+
fragColor=vec4(1.0);
|
|
506
|
+
#endif
|
|
507
|
+
}`,`
|
|
508
|
+
#define scale 0.015873016
|
|
509
|
+
#define LINE_DISTANCE_SCALE 2.0
|
|
510
|
+
layout(location=0) in ivec2 a_pos_normal;layout(location=1) in uvec4 a_data;layout(location=2) in vec2 a_offset_normal;uniform vec2 u_translation;uniform mediump float u_ratio;out vec2 v_normal;flat out vec2 v_width2;out float v_linesofar;out float v_gamma_scale;flat out float v_width;
|
|
511
|
+
#ifdef GLOBE
|
|
512
|
+
out float v_depth;
|
|
513
|
+
#endif
|
|
514
|
+
#pragma maplibre: define lowp float blur
|
|
515
|
+
#pragma maplibre: define lowp float opacity
|
|
516
|
+
#pragma maplibre: define lowp float offset
|
|
517
|
+
#pragma maplibre: define mediump float gapwidth
|
|
518
|
+
#pragma maplibre: define mediump float width
|
|
519
|
+
#pragma maplibre: define lowp float floorwidth
|
|
520
|
+
#pragma maplibre: define lowp vec4 pattern_from
|
|
521
|
+
#pragma maplibre: define lowp vec4 pattern_to
|
|
522
|
+
#pragma maplibre: define lowp float pixel_ratio_from
|
|
523
|
+
#pragma maplibre: define lowp float pixel_ratio_to
|
|
524
|
+
void main() {
|
|
525
|
+
#pragma maplibre: initialize lowp float blur
|
|
526
|
+
#pragma maplibre: initialize lowp float opacity
|
|
527
|
+
#pragma maplibre: initialize lowp float offset
|
|
528
|
+
#pragma maplibre: initialize mediump float gapwidth
|
|
529
|
+
#pragma maplibre: initialize mediump float width
|
|
530
|
+
#pragma maplibre: initialize lowp float floorwidth
|
|
531
|
+
#pragma maplibre: initialize mediump vec4 pattern_from
|
|
532
|
+
#pragma maplibre: initialize mediump vec4 pattern_to
|
|
533
|
+
#pragma maplibre: initialize lowp float pixel_ratio_from
|
|
534
|
+
#pragma maplibre: initialize lowp float pixel_ratio_to
|
|
535
|
+
if (opacity < 0.01) {gl_Position=vec4(-2.0,-2.0,-2.0,1.0);return;}float ANTIALIASING=1.0/u_device_pixel_ratio/2.0;vec2 a_extrude=vec2(ivec2(a_data.xy)-128);float a_linesofar=float((a_data.z >> 2u)+a_data.w*64u)*LINE_DISTANCE_SCALE;vec2 pos=vec2(a_pos_normal >> 1);mediump vec2 normal=vec2(a_pos_normal & 1);normal.y=normal.y*2.0-1.0;v_normal=normal;gapwidth=gapwidth/2.0;float halfwidth=width/2.0;offset=-1.0*offset;float inset=gapwidth+(gapwidth > 0.0 ? ANTIALIASING : 0.0);float outset=gapwidth+halfwidth*(gapwidth > 0.0 ? 2.0 : 1.0)+(halfwidth==0.0 ? 0.0 : ANTIALIASING);mediump vec2 dist=outset*a_extrude*scale;mediump vec2 offset2=offset*a_offset_normal*scale*normal.y;float adjustedThickness=projectLineThickness(pos.y);vec4 projected_no_extrude=projectTile(pos+offset2/u_ratio*adjustedThickness+u_translation);vec4 projected_with_extrude=projectTile(pos+offset2/u_ratio*adjustedThickness+u_translation+dist/u_ratio*adjustedThickness);gl_Position=projected_with_extrude;
|
|
536
|
+
#ifdef GLOBE
|
|
537
|
+
v_depth=gl_Position.z/gl_Position.w;
|
|
538
|
+
#endif
|
|
539
|
+
#ifdef TERRAIN3D
|
|
540
|
+
v_gamma_scale=1.0;
|
|
541
|
+
#else
|
|
542
|
+
float extrude_length_without_perspective=length(dist);float extrude_length_with_perspective=length((projected_with_extrude.xy-projected_no_extrude.xy)/projected_with_extrude.w*u_units_to_pixels);v_gamma_scale=extrude_length_without_perspective/extrude_length_with_perspective;
|
|
543
|
+
#endif
|
|
544
|
+
v_linesofar=a_linesofar;v_width2=vec2(outset,inset);v_width=floorwidth;}`),lineSDF:be(`uniform lowp float u_lineatlas_width;uniform sampler2D u_image;uniform float u_mix;in vec2 v_normal;flat in vec2 v_width2;in vec2 v_tex_a;in vec2 v_tex_b;in float v_gamma_scale;
|
|
545
|
+
#ifdef GLOBE
|
|
546
|
+
in float v_depth;
|
|
547
|
+
#endif
|
|
548
|
+
#pragma maplibre: define highp vec4 color
|
|
549
|
+
#pragma maplibre: define lowp float blur
|
|
550
|
+
#pragma maplibre: define lowp float opacity
|
|
551
|
+
#pragma maplibre: define mediump float width
|
|
552
|
+
#pragma maplibre: define lowp float floorwidth
|
|
553
|
+
#pragma maplibre: define mediump vec4 dasharray_from
|
|
554
|
+
#pragma maplibre: define mediump vec4 dasharray_to
|
|
555
|
+
void main() {
|
|
556
|
+
#pragma maplibre: initialize highp vec4 color
|
|
557
|
+
#pragma maplibre: initialize lowp float blur
|
|
558
|
+
#pragma maplibre: initialize lowp float opacity
|
|
559
|
+
#pragma maplibre: initialize mediump float width
|
|
560
|
+
#pragma maplibre: initialize lowp float floorwidth
|
|
561
|
+
#pragma maplibre: initialize mediump vec4 dasharray_from
|
|
562
|
+
#pragma maplibre: initialize mediump vec4 dasharray_to
|
|
563
|
+
clipAntimeridian();float dist=length(v_normal)*v_width2.s;float blur2=(blur+1.0/u_device_pixel_ratio)*v_gamma_scale;float alpha=clamp(min(dist-(v_width2.t-blur2),v_width2.s-dist)/blur2,0.0,1.0);float sdfdist_a=texture(u_image,v_tex_a).a;float sdfdist_b=texture(u_image,v_tex_b).a;float sdfdist=mix(sdfdist_a,sdfdist_b,u_mix);float sdfgamma=(u_lineatlas_width/256.0/u_device_pixel_ratio)/min(dasharray_from.w,dasharray_to.w);alpha*=smoothstep(0.5-sdfgamma/floorwidth,0.5+sdfgamma/floorwidth,sdfdist);fragColor=color*(alpha*opacity);
|
|
564
|
+
#ifdef GLOBE
|
|
565
|
+
if (v_depth > 1.0) {discard;}
|
|
566
|
+
#endif
|
|
567
|
+
#ifdef OVERDRAW_INSPECTOR
|
|
568
|
+
fragColor=vec4(1.0);
|
|
569
|
+
#endif
|
|
570
|
+
}`,`
|
|
571
|
+
#define scale 0.015873016
|
|
572
|
+
#define LINE_DISTANCE_SCALE 2.0
|
|
573
|
+
layout(location=0) in ivec2 a_pos_normal;layout(location=1) in uvec4 a_data;layout(location=2) in vec2 a_offset_normal;uniform vec2 u_translation;uniform mediump float u_ratio;uniform float u_tileratio;uniform float u_crossfade_from;uniform float u_crossfade_to;uniform float u_lineatlas_height;out vec2 v_normal;flat out vec2 v_width2;out vec2 v_tex_a;out vec2 v_tex_b;out float v_gamma_scale;
|
|
574
|
+
#ifdef GLOBE
|
|
575
|
+
out float v_depth;
|
|
576
|
+
#endif
|
|
577
|
+
#pragma maplibre: define highp vec4 color
|
|
578
|
+
#pragma maplibre: define lowp float blur
|
|
579
|
+
#pragma maplibre: define lowp float opacity
|
|
580
|
+
#pragma maplibre: define mediump float gapwidth
|
|
581
|
+
#pragma maplibre: define lowp float offset
|
|
582
|
+
#pragma maplibre: define mediump float width
|
|
583
|
+
#pragma maplibre: define lowp float floorwidth
|
|
584
|
+
#pragma maplibre: define mediump vec4 dasharray_from
|
|
585
|
+
#pragma maplibre: define mediump vec4 dasharray_to
|
|
586
|
+
void main() {
|
|
587
|
+
#pragma maplibre: initialize highp vec4 color
|
|
588
|
+
#pragma maplibre: initialize lowp float blur
|
|
589
|
+
#pragma maplibre: initialize lowp float opacity
|
|
590
|
+
#pragma maplibre: initialize mediump float gapwidth
|
|
591
|
+
#pragma maplibre: initialize lowp float offset
|
|
592
|
+
#pragma maplibre: initialize mediump float width
|
|
593
|
+
#pragma maplibre: initialize lowp float floorwidth
|
|
594
|
+
#pragma maplibre: initialize mediump vec4 dasharray_from
|
|
595
|
+
#pragma maplibre: initialize mediump vec4 dasharray_to
|
|
596
|
+
if (opacity < 0.01) {gl_Position=vec4(-2.0,-2.0,-2.0,1.0);return;}float ANTIALIASING=1.0/u_device_pixel_ratio/2.0;vec2 a_extrude=vec2(ivec2(a_data.xy)-128);float a_linesofar=float((a_data.z >> 2u)+a_data.w*64u)*LINE_DISTANCE_SCALE;vec2 pos=vec2(a_pos_normal >> 1);mediump vec2 normal=vec2(a_pos_normal & 1);normal.y=normal.y*2.0-1.0;v_normal=normal;gapwidth=gapwidth/2.0;float halfwidth=width/2.0;offset=-1.0*offset;float inset=gapwidth+(gapwidth > 0.0 ? ANTIALIASING : 0.0);float outset=gapwidth+halfwidth*(gapwidth > 0.0 ? 2.0 : 1.0)+(halfwidth==0.0 ? 0.0 : ANTIALIASING);mediump vec2 dist=outset*a_extrude*scale;mediump vec2 offset2=offset*a_offset_normal*scale*normal.y;float adjustedThickness=projectLineThickness(pos.y);vec4 projected_no_extrude=projectTile(pos+offset2/u_ratio*adjustedThickness+u_translation);vec4 projected_with_extrude=projectTile(pos+offset2/u_ratio*adjustedThickness+u_translation+dist/u_ratio*adjustedThickness);gl_Position=projected_with_extrude;
|
|
597
|
+
#ifdef GLOBE
|
|
598
|
+
v_depth=gl_Position.z/gl_Position.w;
|
|
599
|
+
#endif
|
|
600
|
+
#ifdef TERRAIN3D
|
|
601
|
+
v_gamma_scale=1.0;
|
|
602
|
+
#else
|
|
603
|
+
float extrude_length_without_perspective=length(dist);float extrude_length_with_perspective=length((projected_with_extrude.xy-projected_no_extrude.xy)/projected_with_extrude.w*u_units_to_pixels);v_gamma_scale=extrude_length_without_perspective/extrude_length_with_perspective;
|
|
604
|
+
#endif
|
|
605
|
+
float u_patternscale_a_x=u_tileratio/dasharray_from.w/u_crossfade_from;float u_patternscale_a_y=-dasharray_from.z/2.0/u_lineatlas_height;float u_patternscale_b_x=u_tileratio/dasharray_to.w/u_crossfade_to;float u_patternscale_b_y=-dasharray_to.z/2.0/u_lineatlas_height;v_tex_a=vec2(a_linesofar*u_patternscale_a_x/floorwidth,normal.y*u_patternscale_a_y+(float(dasharray_from.y)+0.5)/u_lineatlas_height);v_tex_b=vec2(a_linesofar*u_patternscale_b_x/floorwidth,normal.y*u_patternscale_b_y+(float(dasharray_to.y)+0.5)/u_lineatlas_height);v_width2=vec2(outset,inset);}`),lineGradientSDF:be(`uniform sampler2D u_image;uniform sampler2D u_image_dash;uniform float u_mix;uniform lowp float u_lineatlas_width;in vec2 v_normal;flat in vec2 v_width2;in vec2 v_tex_a;in vec2 v_tex_b;in float v_gamma_scale;in highp vec2 v_uv;
|
|
606
|
+
#ifdef GLOBE
|
|
607
|
+
in float v_depth;
|
|
608
|
+
#endif
|
|
609
|
+
#pragma maplibre: define lowp float blur
|
|
610
|
+
#pragma maplibre: define lowp float opacity
|
|
611
|
+
#pragma maplibre: define mediump float width
|
|
612
|
+
#pragma maplibre: define lowp float floorwidth
|
|
613
|
+
#pragma maplibre: define mediump vec4 dasharray_from
|
|
614
|
+
#pragma maplibre: define mediump vec4 dasharray_to
|
|
615
|
+
void main() {
|
|
616
|
+
#pragma maplibre: initialize lowp float blur
|
|
617
|
+
#pragma maplibre: initialize lowp float opacity
|
|
618
|
+
#pragma maplibre: initialize mediump float width
|
|
619
|
+
#pragma maplibre: initialize lowp float floorwidth
|
|
620
|
+
#pragma maplibre: initialize mediump vec4 dasharray_from
|
|
621
|
+
#pragma maplibre: initialize mediump vec4 dasharray_to
|
|
622
|
+
clipAntimeridian();float dist=length(v_normal)*v_width2.s;float blur2=(blur+1.0/u_device_pixel_ratio)*v_gamma_scale;float alpha=clamp(min(dist-(v_width2.t-blur2),v_width2.s-dist)/blur2,0.0,1.0);vec4 color=texture(u_image,v_uv);float sdfdist_a=texture(u_image_dash,v_tex_a).a;float sdfdist_b=texture(u_image_dash,v_tex_b).a;float sdfdist=mix(sdfdist_a,sdfdist_b,u_mix);float sdfgamma=(u_lineatlas_width/256.0)/min(dasharray_from.w,dasharray_to.w);float dash_alpha=smoothstep(0.5-sdfgamma/floorwidth,0.5+sdfgamma/floorwidth,sdfdist);fragColor=color*(alpha*dash_alpha*opacity);
|
|
623
|
+
#ifdef GLOBE
|
|
624
|
+
if (v_depth > 1.0) {discard;}
|
|
625
|
+
#endif
|
|
626
|
+
#ifdef OVERDRAW_INSPECTOR
|
|
627
|
+
fragColor=vec4(1.0);
|
|
628
|
+
#endif
|
|
629
|
+
}`,`
|
|
630
|
+
#define scale 0.015873016
|
|
631
|
+
#define LINE_DISTANCE_SCALE 2.0
|
|
632
|
+
layout(location=0) in ivec2 a_pos_normal;layout(location=1) in uvec4 a_data;layout(location=2) in vec2 a_offset_normal;layout(location=3) in float a_uv_x;layout(location=4) in float a_split_index;uniform vec2 u_translation;uniform mediump float u_ratio;uniform float u_image_height;uniform float u_tileratio;uniform float u_crossfade_from;uniform float u_crossfade_to;uniform float u_lineatlas_height;out vec2 v_normal;flat out vec2 v_width2;out float v_gamma_scale;out highp vec2 v_uv;out vec2 v_tex_a;out vec2 v_tex_b;
|
|
633
|
+
#ifdef GLOBE
|
|
634
|
+
out float v_depth;
|
|
635
|
+
#endif
|
|
636
|
+
#pragma maplibre: define lowp float blur
|
|
637
|
+
#pragma maplibre: define lowp float opacity
|
|
638
|
+
#pragma maplibre: define mediump float gapwidth
|
|
639
|
+
#pragma maplibre: define lowp float offset
|
|
640
|
+
#pragma maplibre: define mediump float width
|
|
641
|
+
#pragma maplibre: define lowp float floorwidth
|
|
642
|
+
#pragma maplibre: define mediump vec4 dasharray_from
|
|
643
|
+
#pragma maplibre: define mediump vec4 dasharray_to
|
|
644
|
+
void main() {
|
|
645
|
+
#pragma maplibre: initialize lowp float blur
|
|
646
|
+
#pragma maplibre: initialize lowp float opacity
|
|
647
|
+
#pragma maplibre: initialize mediump float gapwidth
|
|
648
|
+
#pragma maplibre: initialize lowp float offset
|
|
649
|
+
#pragma maplibre: initialize mediump float width
|
|
650
|
+
#pragma maplibre: initialize lowp float floorwidth
|
|
651
|
+
#pragma maplibre: initialize mediump vec4 dasharray_from
|
|
652
|
+
#pragma maplibre: initialize mediump vec4 dasharray_to
|
|
653
|
+
if (opacity < 0.01) {gl_Position=vec4(-2.0,-2.0,-2.0,1.0);return;}float ANTIALIASING=1.0/u_device_pixel_ratio/2.0;vec2 a_extrude=vec2(ivec2(a_data.xy)-128);float a_linesofar=float((a_data.z >> 2u)+a_data.w*64u)*LINE_DISTANCE_SCALE;float texel_height=1.0/u_image_height;float half_texel_height=0.5*texel_height;v_uv=vec2(a_uv_x,a_split_index*texel_height-half_texel_height);vec2 pos=vec2(a_pos_normal >> 1);mediump vec2 normal=vec2(a_pos_normal & 1);normal.y=normal.y*2.0-1.0;v_normal=normal;gapwidth=gapwidth/2.0;float halfwidth=width/2.0;offset=-1.0*offset;float inset=gapwidth+(gapwidth > 0.0 ? ANTIALIASING : 0.0);float outset=gapwidth+halfwidth*(gapwidth > 0.0 ? 2.0 : 1.0)+(halfwidth==0.0 ? 0.0 : ANTIALIASING);mediump vec2 dist=outset*a_extrude*scale;mediump vec2 offset2=offset*a_offset_normal*scale*normal.y;float adjustedThickness=projectLineThickness(pos.y);vec4 projected_no_extrude=projectTile(pos+offset2/u_ratio*adjustedThickness+u_translation);vec4 projected_with_extrude=projectTile(pos+offset2/u_ratio*adjustedThickness+u_translation+dist/u_ratio*adjustedThickness);gl_Position=projected_with_extrude;
|
|
654
|
+
#ifdef GLOBE
|
|
655
|
+
v_depth=gl_Position.z/gl_Position.w;
|
|
656
|
+
#endif
|
|
657
|
+
#ifdef TERRAIN3D
|
|
658
|
+
v_gamma_scale=1.0;
|
|
659
|
+
#else
|
|
660
|
+
float extrude_length_without_perspective=length(dist);float extrude_length_with_perspective=length((projected_with_extrude.xy-projected_no_extrude.xy)/projected_with_extrude.w*u_units_to_pixels);v_gamma_scale=extrude_length_without_perspective/extrude_length_with_perspective;
|
|
661
|
+
#endif
|
|
662
|
+
float u_patternscale_a_x=u_tileratio/dasharray_from.w/u_crossfade_from;float u_patternscale_a_y=-dasharray_from.z/2.0/u_lineatlas_height;float u_patternscale_b_x=u_tileratio/dasharray_to.w/u_crossfade_to;float u_patternscale_b_y=-dasharray_to.z/2.0/u_lineatlas_height;v_tex_a=vec2(a_linesofar*u_patternscale_a_x/floorwidth,normal.y*u_patternscale_a_y+(float(dasharray_from.y)+0.5)/u_lineatlas_height);v_tex_b=vec2(a_linesofar*u_patternscale_b_x/floorwidth,normal.y*u_patternscale_b_y+(float(dasharray_to.y)+0.5)/u_lineatlas_height);v_width2=vec2(outset,inset);}`),layerOpacity:be(`uniform sampler2D u_image;uniform float u_opacity;in vec2 v_pos;void main() {fragColor=texture(u_image,v_pos)*u_opacity;
|
|
663
|
+
#ifdef OVERDRAW_INSPECTOR
|
|
664
|
+
fragColor=vec4(0.0);
|
|
665
|
+
#endif
|
|
666
|
+
}`,"layout(location=0) in vec2 a_pos;out vec2 v_pos;void main() {gl_Position=vec4(a_pos.x*2.0-1.0,1.0-a_pos.y*2.0,0.0,1.0);v_pos.x=a_pos.x;v_pos.y=1.0-a_pos.y;}"),raster:be(`uniform float u_fade_t;uniform float u_opacity;uniform sampler2D u_image0;uniform sampler2D u_image1;in vec3 v_pos0;in vec3 v_pos1;uniform float u_brightness_low;uniform float u_brightness_high;uniform float u_saturation_factor;uniform float u_contrast_factor;uniform vec3 u_spin_weights;void main() {vec4 color0=texture(u_image0,v_pos0.xy/v_pos0.z);vec4 color1=texture(u_image1,v_pos1.xy/v_pos1.z);if (color0.a > 0.0) {color0.rgb=color0.rgb/color0.a;}if (color1.a > 0.0) {color1.rgb=color1.rgb/color1.a;}vec4 color=mix(color0,color1,u_fade_t);color.a*=u_opacity;vec3 rgb=color.rgb;rgb=vec3(dot(rgb,u_spin_weights.xyz),dot(rgb,u_spin_weights.zxy),dot(rgb,u_spin_weights.yzx));float average=(color.r+color.g+color.b)/3.0;rgb+=(average-rgb)*u_saturation_factor;rgb=(rgb-0.5)*u_contrast_factor+0.5;vec3 u_high_vec=vec3(u_brightness_low,u_brightness_low,u_brightness_low);vec3 u_low_vec=vec3(u_brightness_high,u_brightness_high,u_brightness_high);fragColor=vec4(mix(u_high_vec,u_low_vec,rgb)*color.a,color.a);
|
|
667
|
+
#ifdef OVERDRAW_INSPECTOR
|
|
668
|
+
fragColor=vec4(1.0);
|
|
669
|
+
#endif
|
|
670
|
+
}`,`uniform vec2 u_tl_parent;uniform float u_scale_parent;uniform float u_buffer_scale;uniform vec3 u_image_warp;uniform vec4 u_coords_top;uniform vec4 u_coords_bottom;layout(location=0) in vec2 a_pos;out vec3 v_pos0;out vec3 v_pos1;void main() {vec2 fractionalPos=a_pos/8192.0;vec2 topLeft=u_coords_top.xy;vec2 topRight=u_coords_top.zw;vec2 bottomLeft=u_coords_bottom.xy;vec2 bottomRight=u_coords_bottom.zw;vec2 bilinearPos=mix(mix(topLeft,topRight,fractionalPos.x),mix(bottomLeft,bottomRight,fractionalPos.x),fractionalPos.y);float denominator=dot(u_image_warp.xy,fractionalPos)+1.0;vec2 acrossTop=topRight-topLeft+u_image_warp.x*topRight;vec2 downLeft=bottomLeft-topLeft+u_image_warp.y*bottomLeft;vec2 projectivePos=(acrossTop*fractionalPos.x+downLeft*fractionalPos.y+topLeft)/denominator;vec2 position=mix(projectivePos,bilinearPos,u_image_warp.z);gl_Position=projectTile(position,position);vec2 texturePos=((fractionalPos-0.5)/u_buffer_scale)+0.5;
|
|
671
|
+
#ifdef GLOBE
|
|
672
|
+
if (a_pos.y <-32767.5) {texturePos.y=0.0;}if (a_pos.y > 32766.5) {texturePos.y=1.0;}
|
|
673
|
+
#endif
|
|
674
|
+
float perspectiveRatio=mix(1.0/denominator,1.0,u_image_warp.z);v_pos0=vec3(texturePos*perspectiveRatio,perspectiveRatio);vec2 parentPos=(texturePos*u_scale_parent)+u_tl_parent;v_pos1=vec3(parentPos*perspectiveRatio,perspectiveRatio);}`),symbolIcon:be(`uniform sampler2D u_texture;in vec2 v_tex;flat in float v_total_opacity;void main() {fragColor=texture(u_texture,v_tex)*v_total_opacity;
|
|
675
|
+
#ifdef OVERDRAW_INSPECTOR
|
|
676
|
+
fragColor=vec4(1.0);
|
|
677
|
+
#endif
|
|
678
|
+
}`,`layout(location=0) in vec4 a_pos_offset;layout(location=1) in uvec4 a_data;layout(location=2) in vec4 a_pixeloffset;layout(location=3) in vec3 a_projected_pos;layout(location=4) in uint a_fade_opacity;layout(location=5) in float a_height_offset;uniform bool u_is_size_zoom_constant;uniform bool u_is_size_feature_constant;uniform highp float u_size_t;uniform highp float u_size;uniform bool u_rotate_symbol;uniform mat4 u_label_plane_matrix;uniform mat4 u_coord_matrix;uniform bool u_is_text;uniform bool u_pitch_with_map;uniform vec2 u_texsize;uniform bool u_is_along_line;uniform bool u_is_variable_anchor;uniform vec2 u_translation;uniform float u_pitched_scale;uniform bool u_is_offset;uniform bool u_height_anchor_ground;out vec2 v_tex;flat out float v_total_opacity;
|
|
679
|
+
#pragma maplibre: define lowp float opacity
|
|
680
|
+
void main() {
|
|
681
|
+
#pragma maplibre: initialize lowp float opacity
|
|
682
|
+
vec2 a_pos=a_pos_offset.xy;vec2 a_offset=a_pos_offset.zw;vec2 a_tex=vec2(a_data.xy);vec2 a_size=vec2(a_data.zw);float a_size_min=float(a_data.z >> 1u);vec2 a_pxoffset=a_pixeloffset.xy;vec2 a_minFontScale=a_pixeloffset.zw/256.0;float ele=a_height_offset+(u_height_anchor_ground ? get_elevation(a_pos) : 0.0);highp float segment_angle=-a_projected_pos[2];float size;if (!u_is_size_zoom_constant && !u_is_size_feature_constant) {size=mix(a_size_min,a_size[1],u_size_t)/128.0;} else if (u_is_size_zoom_constant && !u_is_size_feature_constant) {size=a_size_min/128.0;} else {size=u_size;}vec2 translated_a_pos=a_pos+u_translation;vec4 projectedPoint=projectTileWithElevation(translated_a_pos,ele);vec2 fade_opacity=unpack_opacity(a_fade_opacity);float fade_change=fade_opacity[1] > 0.5 ? u_symbol_fade_change :-u_symbol_fade_change;float visibility=calculate_visibility(projectedPoint);v_total_opacity=opacity*max(0.0,min(visibility,fade_opacity[0]+fade_change));if (v_total_opacity < 0.1){gl_Position=vec4(-2.,-2.,-2.,1.);return;}highp float camera_to_anchor_distance=projectedPoint.w;highp float distance_ratio=u_pitch_with_map ?
|
|
683
|
+
camera_to_anchor_distance/u_camera_to_center_distance :
|
|
684
|
+
u_camera_to_center_distance/camera_to_anchor_distance;highp float perspective_ratio=clamp(0.5+0.5*distance_ratio,0.0,4.0);if (!u_is_offset) {size*=perspective_ratio;}float fontScale=u_is_text ? size/24.0 : size;highp float symbol_rotation=0.0;if (u_rotate_symbol) {vec4 offsetProjectedPoint=projectTileWithElevation(translated_a_pos+vec2(1,0),ele);vec2 a=projectedPoint.xy/projectedPoint.w;vec2 b=offsetProjectedPoint.xy/offsetProjectedPoint.w;symbol_rotation=atan((b.y-a.y)/u_aspect_ratio,b.x-a.x);}highp float angle_sin=sin(segment_angle+symbol_rotation);highp float angle_cos=cos(segment_angle+symbol_rotation);mat2 rotation_matrix=mat2(angle_cos,-1.0*angle_sin,angle_sin,angle_cos);vec4 projected_pos;if (u_is_along_line || u_is_variable_anchor) {projected_pos=vec4(a_projected_pos.xy,ele,1.0);} else if (u_pitch_with_map) {projected_pos=u_label_plane_matrix*vec4(a_projected_pos.xy+u_translation,ele,1.0);} else {projected_pos=u_label_plane_matrix*projectTileWithElevation(a_projected_pos.xy+u_translation,ele);}float z=float(u_pitch_with_map)*projected_pos.z/projected_pos.w;float projectionScaling=1.0;
|
|
685
|
+
#ifdef GLOBE
|
|
686
|
+
if(u_pitch_with_map) {float anchor_pos_tile_y=(u_coord_matrix*vec4(projected_pos.xy/projected_pos.w,z,1.0)).y;projectionScaling=mix(projectionScaling,1.0/circumferenceRatioAtTileY(anchor_pos_tile_y)*u_pitched_scale,u_projection_transition);}
|
|
687
|
+
#endif
|
|
688
|
+
vec4 finalPos=u_coord_matrix*vec4(projected_pos.xy/projected_pos.w+rotation_matrix*(a_offset/32.0*max(a_minFontScale,fontScale)+a_pxoffset/16.0)*projectionScaling,z,1.0);if(u_pitch_with_map) {finalPos=projectTileWithElevation(finalPos.xy,finalPos.z);}gl_Position=finalPos;v_tex=a_tex/u_texsize;}`),symbolSDF:be(`#define SDF_PX 8.0
|
|
689
|
+
uniform bool u_is_halo;uniform bool u_is_plain;uniform sampler2D u_texture;uniform highp float u_gamma_scale;uniform bool u_is_text;in vec2 v_data0;in vec3 v_data1;
|
|
690
|
+
#pragma maplibre: define highp vec4 fill_color
|
|
691
|
+
#pragma maplibre: define highp vec4 halo_color
|
|
692
|
+
#pragma maplibre: define lowp float halo_width
|
|
693
|
+
#pragma maplibre: define lowp float halo_blur
|
|
694
|
+
void main() {
|
|
695
|
+
#pragma maplibre: initialize highp vec4 fill_color
|
|
696
|
+
#pragma maplibre: initialize highp vec4 halo_color
|
|
697
|
+
#pragma maplibre: initialize lowp float halo_width
|
|
698
|
+
#pragma maplibre: initialize lowp float halo_blur
|
|
699
|
+
float EDGE_GAMMA=0.105/u_device_pixel_ratio;vec2 tex=v_data0.xy;float gamma_scale=v_data1.x;float size=v_data1.y;float total_opacity=v_data1[2];float fontScale=u_is_text ? size/24.0 : size;highp float gamma=EDGE_GAMMA/(fontScale*u_gamma_scale);lowp float inner_edge=(256.0-64.0)/256.0;lowp float dist=texture(u_texture,tex).a;lowp vec4 color_alpha_out_text,color_alpha_out_halo;if (u_is_plain){highp float gamma_scaled=gamma*gamma_scale;highp float alpha=smoothstep(inner_edge-gamma_scaled,inner_edge+gamma_scaled,dist);color_alpha_out_text=total_opacity*alpha*fill_color;}if (u_is_halo) {float gamma_halo=(halo_blur*1.19/SDF_PX+EDGE_GAMMA)/(fontScale*u_gamma_scale);float inner_edge_halo=inner_edge+gamma_halo*gamma_scale;highp float gamma_scaled_halo=gamma_halo*gamma_scale;highp float alpha_halo=smoothstep(inner_edge_halo-gamma_scaled_halo,inner_edge_halo+gamma_scaled_halo,dist);highp float halo_edge=(6.0-halo_width/fontScale)/SDF_PX;alpha_halo= min(smoothstep(halo_edge-gamma_scaled_halo,halo_edge+gamma_scaled_halo,dist),1.0-alpha_halo);color_alpha_out_halo=total_opacity*alpha_halo*halo_color;}if (u_is_plain && u_is_halo) {fragColor=color_alpha_out_text+(1.-color_alpha_out_text.a)*color_alpha_out_halo;} else if (u_is_halo){fragColor=color_alpha_out_halo;} else {fragColor=color_alpha_out_text;}
|
|
700
|
+
#ifdef OVERDRAW_INSPECTOR
|
|
701
|
+
fragColor=vec4(1.0);
|
|
702
|
+
#endif
|
|
703
|
+
}`,`layout(location=0) in vec4 a_pos_offset;layout(location=1) in uvec4 a_data;layout(location=2) in vec4 a_pixeloffset;layout(location=3) in vec3 a_projected_pos;layout(location=4) in uint a_fade_opacity;layout(location=5) in float a_height_offset;uniform bool u_is_size_zoom_constant;uniform bool u_is_size_feature_constant;uniform highp float u_size_t;uniform highp float u_size;uniform mat4 u_label_plane_matrix;uniform mat4 u_coord_matrix;uniform bool u_is_text;uniform bool u_pitch_with_map;uniform bool u_is_along_line;uniform bool u_is_variable_anchor;uniform bool u_rotate_symbol;uniform vec2 u_texsize;uniform vec2 u_translation;uniform float u_pitched_scale;uniform bool u_is_offset;uniform bool u_height_anchor_ground;out vec2 v_data0;out vec3 v_data1;
|
|
704
|
+
#pragma maplibre: define highp vec4 fill_color
|
|
705
|
+
#pragma maplibre: define highp vec4 halo_color
|
|
706
|
+
#pragma maplibre: define lowp float opacity
|
|
707
|
+
#pragma maplibre: define lowp float halo_width
|
|
708
|
+
#pragma maplibre: define lowp float halo_blur
|
|
709
|
+
void main() {
|
|
710
|
+
#pragma maplibre: initialize highp vec4 fill_color
|
|
711
|
+
#pragma maplibre: initialize highp vec4 halo_color
|
|
712
|
+
#pragma maplibre: initialize lowp float opacity
|
|
713
|
+
#pragma maplibre: initialize lowp float halo_width
|
|
714
|
+
#pragma maplibre: initialize lowp float halo_blur
|
|
715
|
+
vec2 a_pos=a_pos_offset.xy;vec2 a_offset=a_pos_offset.zw;vec2 a_tex=vec2(a_data.xy);vec2 a_size=vec2(a_data.zw);float a_size_min=float(a_data.z >> 1u);vec2 a_pxoffset=a_pixeloffset.xy/16.0;vec2 a_minFontScale=a_pixeloffset.zw/256.0;float ele=a_height_offset+(u_height_anchor_ground ? get_elevation(a_pos) : 0.0);highp float segment_angle=-a_projected_pos[2];float size;if (!u_is_size_zoom_constant && !u_is_size_feature_constant) {size=mix(a_size_min,a_size[1],u_size_t)/128.0;} else if (u_is_size_zoom_constant && !u_is_size_feature_constant) {size=a_size_min/128.0;} else {size=u_size;}vec2 translated_a_pos=a_pos+u_translation;vec4 projectedPoint=projectTileWithElevation(translated_a_pos,ele);vec2 fade_opacity=unpack_opacity(a_fade_opacity);float visibility=calculate_visibility(projectedPoint);float fade_change=fade_opacity[1] > 0.5 ? u_symbol_fade_change :-u_symbol_fade_change;float interpolated_fade_opacity=max(0.0,min(visibility,fade_opacity[0]+fade_change));float total_opacity=opacity*interpolated_fade_opacity;if (total_opacity < 0.1){gl_Position=vec4(-2.,-2.,-2.,1.);return;}highp float camera_to_anchor_distance=projectedPoint.w;highp float distance_ratio=u_pitch_with_map ?
|
|
716
|
+
camera_to_anchor_distance/u_camera_to_center_distance :
|
|
717
|
+
u_camera_to_center_distance/camera_to_anchor_distance;highp float perspective_ratio=clamp(0.5+0.5*distance_ratio,0.0,4.0);if (!u_is_offset) {size*=perspective_ratio;}float fontScale=u_is_text ? size/24.0 : size;highp float symbol_rotation=0.0;if (u_rotate_symbol) {vec4 offsetProjectedPoint=projectTileWithElevation(translated_a_pos+vec2(1,0),ele);vec2 a=projectedPoint.xy/projectedPoint.w;vec2 b=offsetProjectedPoint.xy/offsetProjectedPoint.w;symbol_rotation=atan((b.y-a.y)/u_aspect_ratio,b.x-a.x);}highp float angle_sin=sin(segment_angle+symbol_rotation);highp float angle_cos=cos(segment_angle+symbol_rotation);mat2 rotation_matrix=mat2(angle_cos,-1.0*angle_sin,angle_sin,angle_cos);vec4 projected_pos;if (u_is_along_line || u_is_variable_anchor) {projected_pos=vec4(a_projected_pos.xy,ele,1.0);} else if (u_pitch_with_map) {projected_pos=u_label_plane_matrix*vec4(a_projected_pos.xy+u_translation,ele,1.0);} else {projected_pos=u_label_plane_matrix*projectTileWithElevation(a_projected_pos.xy+u_translation,ele);}float z=float(u_pitch_with_map)*projected_pos.z/projected_pos.w;float projectionScaling=1.0;
|
|
718
|
+
#ifdef GLOBE
|
|
719
|
+
if(u_pitch_with_map) {float anchor_pos_tile_y=(u_coord_matrix*vec4(projected_pos.xy/projected_pos.w,z,1.0)).y;projectionScaling=mix(projectionScaling,1.0/circumferenceRatioAtTileY(anchor_pos_tile_y)*u_pitched_scale,u_projection_transition);}
|
|
720
|
+
#endif
|
|
721
|
+
vec4 finalPos=u_coord_matrix*vec4(projected_pos.xy/projected_pos.w+rotation_matrix*(a_offset/32.0*max(a_minFontScale,fontScale)+a_pxoffset)*projectionScaling,z,1.0);if(u_pitch_with_map) {finalPos=projectTileWithElevation(finalPos.xy,finalPos.z);}float gamma_scale=finalPos.w;gl_Position=finalPos;v_data0=a_tex/u_texsize;v_data1=vec3(gamma_scale,size,total_opacity);}`),symbolTextAndIcon:be(`#define SDF_PX 8.0
|
|
722
|
+
#define SDF 1.0
|
|
723
|
+
#define ICON 0.0
|
|
724
|
+
uniform bool u_is_halo;uniform bool u_is_text;uniform sampler2D u_texture;uniform sampler2D u_texture_icon;uniform highp float u_gamma_scale;in vec4 v_data0;in vec3 v_data1;flat in float v_is_sdf;
|
|
725
|
+
#pragma maplibre: define highp vec4 fill_color
|
|
726
|
+
#pragma maplibre: define highp vec4 halo_color
|
|
727
|
+
#pragma maplibre: define lowp float halo_width
|
|
728
|
+
#pragma maplibre: define lowp float halo_blur
|
|
729
|
+
void main() {
|
|
730
|
+
#pragma maplibre: initialize highp vec4 fill_color
|
|
731
|
+
#pragma maplibre: initialize highp vec4 halo_color
|
|
732
|
+
#pragma maplibre: initialize lowp float halo_width
|
|
733
|
+
#pragma maplibre: initialize lowp float halo_blur
|
|
734
|
+
float total_opacity=v_data1[2];if (v_is_sdf==ICON) {vec2 tex_icon=v_data0.zw;fragColor=texture(u_texture_icon,tex_icon)*total_opacity;
|
|
735
|
+
#ifdef OVERDRAW_INSPECTOR
|
|
736
|
+
fragColor=vec4(1.0);
|
|
737
|
+
#endif
|
|
738
|
+
return;}vec2 tex=v_data0.xy;float EDGE_GAMMA=0.105/u_device_pixel_ratio;float gamma_scale=v_data1.x;float size=v_data1.y;float fontScale=size/24.0;highp float gamma=EDGE_GAMMA/(fontScale*u_gamma_scale);lowp float buff=(256.0-64.0)/256.0;lowp float dist=texture(u_texture,tex).a;lowp vec4 color_alpha_out,color_alpha_out_halo;if (u_is_text) {highp float gamma_scaled=gamma*gamma_scale;highp float alpha=smoothstep(buff-gamma_scaled,buff+gamma_scaled,dist);color_alpha_out=fill_color*(alpha*total_opacity);}if (u_is_halo) {highp float gamma_halo=(halo_blur*1.19/SDF_PX+EDGE_GAMMA)/(fontScale*u_gamma_scale);lowp float buff_halo=(6.0-halo_width/fontScale)/SDF_PX;highp float gamma_scaled_halo=gamma_halo*gamma_scale;highp float alpha_halo=smoothstep(buff_halo-gamma_scaled_halo,buff_halo+gamma_scaled_halo,dist);color_alpha_out_halo=halo_color*(alpha_halo*total_opacity);}if (u_is_text && u_is_halo) {fragColor=color_alpha_out+(1.-color_alpha_out.a)*color_alpha_out_halo;} else if (u_is_halo) {fragColor=color_alpha_out_halo;} else {fragColor=color_alpha_out;}
|
|
739
|
+
#ifdef OVERDRAW_INSPECTOR
|
|
740
|
+
fragColor=vec4(1.0);
|
|
741
|
+
#endif
|
|
742
|
+
}`,`layout(location=0) in vec4 a_pos_offset;layout(location=1) in uvec4 a_data;layout(location=2) in vec3 a_projected_pos;layout(location=3) in uint a_fade_opacity;layout(location=4) in float a_height_offset;uniform bool u_is_size_zoom_constant;uniform bool u_is_size_feature_constant;uniform highp float u_size_t;uniform highp float u_size;uniform mat4 u_label_plane_matrix;uniform mat4 u_coord_matrix;uniform bool u_is_text;uniform bool u_pitch_with_map;uniform bool u_rotate_symbol;uniform vec2 u_texsize;uniform vec2 u_texsize_icon;uniform bool u_is_along_line;uniform bool u_is_variable_anchor;uniform vec2 u_translation;uniform float u_pitched_scale;uniform bool u_is_offset;uniform bool u_height_anchor_ground;out vec4 v_data0;out vec3 v_data1;flat out float v_is_sdf;
|
|
743
|
+
#pragma maplibre: define highp vec4 fill_color
|
|
744
|
+
#pragma maplibre: define highp vec4 halo_color
|
|
745
|
+
#pragma maplibre: define lowp float opacity
|
|
746
|
+
#pragma maplibre: define lowp float halo_width
|
|
747
|
+
#pragma maplibre: define lowp float halo_blur
|
|
748
|
+
void main() {
|
|
749
|
+
#pragma maplibre: initialize highp vec4 fill_color
|
|
750
|
+
#pragma maplibre: initialize highp vec4 halo_color
|
|
751
|
+
#pragma maplibre: initialize lowp float opacity
|
|
752
|
+
#pragma maplibre: initialize lowp float halo_width
|
|
753
|
+
#pragma maplibre: initialize lowp float halo_blur
|
|
754
|
+
vec2 a_pos=a_pos_offset.xy;vec2 a_offset=a_pos_offset.zw;vec2 a_tex=vec2(a_data.xy);vec2 a_size=vec2(a_data.zw);float a_size_min=float(a_data.z >> 1u);float is_sdf=float(a_data.z & 1u);float ele=a_height_offset+(u_height_anchor_ground ? get_elevation(a_pos) : 0.0);highp float segment_angle=-a_projected_pos[2];float size;if (!u_is_size_zoom_constant && !u_is_size_feature_constant) {size=mix(a_size_min,a_size[1],u_size_t)/128.0;} else if (u_is_size_zoom_constant && !u_is_size_feature_constant) {size=a_size_min/128.0;} else {size=u_size;}vec2 translated_a_pos=a_pos+u_translation;vec4 projectedPoint=projectTileWithElevation(translated_a_pos,ele);vec2 fade_opacity=unpack_opacity(a_fade_opacity);float visibility=calculate_visibility(projectedPoint);float fade_change=fade_opacity[1] > 0.5 ? u_symbol_fade_change :-u_symbol_fade_change;float interpolated_fade_opacity=max(0.0,min(visibility,fade_opacity[0]+fade_change));float total_opacity=opacity*interpolated_fade_opacity;if (total_opacity < 0.1){gl_Position=vec4(-2.,-2.,-2.,1.);return;}highp float camera_to_anchor_distance=projectedPoint.w;highp float distance_ratio=u_pitch_with_map ?
|
|
755
|
+
camera_to_anchor_distance/u_camera_to_center_distance :
|
|
756
|
+
u_camera_to_center_distance/camera_to_anchor_distance;highp float perspective_ratio=clamp(0.5+0.5*distance_ratio,0.0,4.0);if (!u_is_offset) {size*=perspective_ratio;}float fontScale=size/24.0;highp float symbol_rotation=0.0;if (u_rotate_symbol) {vec4 offsetProjectedPoint=projectTileWithElevation(translated_a_pos+vec2(1,0),ele);vec2 a=projectedPoint.xy/projectedPoint.w;vec2 b=offsetProjectedPoint.xy/offsetProjectedPoint.w;symbol_rotation=atan((b.y-a.y)/u_aspect_ratio,b.x-a.x);}highp float angle_sin=sin(segment_angle+symbol_rotation);highp float angle_cos=cos(segment_angle+symbol_rotation);mat2 rotation_matrix=mat2(angle_cos,-1.0*angle_sin,angle_sin,angle_cos);vec4 projected_pos;if (u_is_along_line || u_is_variable_anchor) {projected_pos=vec4(a_projected_pos.xy,ele,1.0);} else if (u_pitch_with_map) {projected_pos=u_label_plane_matrix*vec4(a_projected_pos.xy+u_translation,ele,1.0);} else {projected_pos=u_label_plane_matrix*projectTileWithElevation(a_projected_pos.xy+u_translation,ele);}float z=float(u_pitch_with_map)*projected_pos.z/projected_pos.w;float projectionScaling=1.0;
|
|
757
|
+
#ifdef GLOBE
|
|
758
|
+
if(u_pitch_with_map && !u_is_along_line) {float anchor_pos_tile_y=(u_coord_matrix*vec4(projected_pos.xy/projected_pos.w,z,1.0)).y;projectionScaling=mix(projectionScaling,1.0/circumferenceRatioAtTileY(anchor_pos_tile_y)*u_pitched_scale,u_projection_transition);}
|
|
759
|
+
#endif
|
|
760
|
+
vec4 finalPos=u_coord_matrix*vec4(projected_pos.xy/projected_pos.w+rotation_matrix*(a_offset/32.0*fontScale)*projectionScaling,z,1.0);if(u_pitch_with_map) {finalPos=projectTileWithElevation(finalPos.xy,finalPos.z);}float gamma_scale=finalPos.w;gl_Position=finalPos;v_data0.xy=a_tex/u_texsize;v_data0.zw=a_tex/u_texsize_icon;v_data1=vec3(gamma_scale,size,total_opacity);v_is_sdf=is_sdf;}`),terrain:be("uniform sampler2D u_texture;uniform vec4 u_fog_color;uniform vec4 u_horizon_color;uniform float u_fog_ground_blend;uniform float u_fog_ground_blend_opacity;uniform float u_horizon_fog_blend;uniform bool u_is_globe_mode;in vec2 v_texture_pos;in float v_fog_depth;const float gamma=2.2;vec4 gammaToLinear(vec4 color) {return pow(color,vec4(gamma));}vec4 linearToGamma(vec4 color) {return pow(color,vec4(1.0/gamma));}void main() {vec4 surface_color=texture(u_texture,vec2(v_texture_pos.x,1.0-v_texture_pos.y));if (!u_is_globe_mode && u_fog_ground_blend_opacity > 0.0 && v_fog_depth > u_fog_ground_blend) {vec4 surface_color_linear=gammaToLinear(surface_color);float blend_color=smoothstep(0.0,1.0,max((v_fog_depth-u_horizon_fog_blend)/(1.0-u_horizon_fog_blend),0.0));vec4 fog_horizon_color_linear=mix(gammaToLinear(u_fog_color),gammaToLinear(u_horizon_color),blend_color);float factor_fog=max(v_fog_depth-u_fog_ground_blend,0.0)/(1.0-u_fog_ground_blend);fragColor=linearToGamma(mix(surface_color_linear,fog_horizon_color_linear,pow(factor_fog,2.0)*u_fog_ground_blend_opacity));} else {fragColor=surface_color;}}","layout(location=0) in vec3 a_pos3d;uniform mat4 u_fog_matrix;uniform float u_ele_delta;out vec2 v_texture_pos;out float v_fog_depth;void main() {float ele=get_elevation(a_pos3d.xy);float ele_delta=a_pos3d.z==1.0 ? u_ele_delta : 0.0;v_texture_pos=a_pos3d.xy/8192.0;gl_Position=projectTileFor3D(a_pos3d.xy,ele-ele_delta);vec4 pos=u_fog_matrix*vec4(a_pos3d.xy,ele,1.0);v_fog_depth=pos.z/pos.w*0.5+0.5;}"),terrainDepth:be("in float v_depth;const highp vec4 bitSh=vec4(256.*256.*256.,256.*256.,256.,1.);const highp vec4 bitMsk=vec4(0.,vec3(1./256.0));highp vec4 pack(highp float value) {highp vec4 comp=fract(value*bitSh);comp-=comp.xxyz*bitMsk;return comp;}void main() {fragColor=pack(v_depth);}","layout(location=0) in vec3 a_pos3d;uniform float u_ele_delta;out float v_depth;void main() {float ele=get_elevation(a_pos3d.xy);float ele_delta=a_pos3d.z==1.0 ? u_ele_delta : 0.0;gl_Position=projectTileFor3D(a_pos3d.xy,ele-ele_delta);v_depth=gl_Position.z/gl_Position.w;}"),terrainHeight:be("in highp float v_elevation;void main() {fragColor=vec4(v_elevation,0.0,0.0,1.0);}","layout(location=0) in vec3 a_pos3d;uniform vec4 u_tile_bounds;out highp float v_elevation;void main() {v_elevation=get_elevation(a_pos3d.xy);vec2 position=u_tile_bounds.xy+a_pos3d.xy/8192.0*u_tile_bounds.zw;gl_Position=vec4(position.x*2.0-1.0,1.0-position.y*2.0,0.0,1.0);}"),atmosphere:be(`#ifdef GL_ES
|
|
761
|
+
precision highp float;
|
|
762
|
+
#endif
|
|
763
|
+
in vec3 view_direction;uniform vec3 u_sun_pos;uniform vec3 u_globe_position;uniform float u_globe_radius;uniform float u_atmosphere_blend;/**Shader use from https:*Made some change to adapt to MapLibre Globe geometry*/const float PI=3.141592653589793;const int iSteps=5;const int jSteps=3;/*radius of the planet*/const float EARTH_RADIUS=6371e3;/*radius of the atmosphere*/const float ATMOS_RADIUS=6471e3;vec2 rsi(vec3 r0,vec3 rd,float sr) {float a=dot(rd,rd);float b=2.0*dot(rd,r0);float c=dot(r0,r0)-(sr*sr);float d=(b*b)-4.0*a*c;if (d < 0.0) return vec2(1e5,-1e5);return vec2((-b-sqrt(d))/(2.0*a),(-b+sqrt(d))/(2.0*a));}vec4 atmosphere(vec3 r,vec3 r0,vec3 pSun,float iSun,float rPlanet,float rAtmos,vec3 kRlh,float kMie,float shRlh,float shMie,float g) {pSun=normalize(pSun);r=normalize(r);vec2 p=rsi(r0,r,rAtmos);if (p.x > p.y) {return vec4(0.0,0.0,0.0,1.0);}if (p.x < 0.0) {p.x=0.0;}vec3 pos=r0+r*p.x;vec2 p2=rsi(r0,r,rPlanet);if (p2.x <=p2.y && p2.x > 0.0) {p.y=min(p.y,p2.x);}float iStepSize=(p.y-p.x)/float(iSteps);float iTime=p.x+iStepSize*0.5;vec3 totalRlh=vec3(0,0,0);vec3 totalMie=vec3(0,0,0);float iOdRlh=0.0;float iOdMie=0.0;float mu=dot(r,pSun);float mumu=mu*mu;float gg=g*g;float pRlh=3.0/(16.0*PI)*(1.0+mumu);float pMie=3.0/(8.0*PI)*((1.0-gg)*(mumu+1.0))/(pow(1.0+gg-2.0*mu*g,1.5)*(2.0+gg));for (int i=0; i < iSteps; i++) {vec3 iPos=r0+r*iTime;float iHeight=length(iPos)-rPlanet;float odStepRlh=exp(-iHeight/shRlh)*iStepSize;float odStepMie=exp(-iHeight/shMie)*iStepSize;iOdRlh+=odStepRlh;iOdMie+=odStepMie;float jStepSize=rsi(iPos,pSun,rAtmos).y/float(jSteps);float jTime=jStepSize*0.5;float jOdRlh=0.0;float jOdMie=0.0;for (int j=0; j < jSteps; j++) {vec3 jPos=iPos+pSun*jTime;float jHeight=length(jPos)-rPlanet;jOdRlh+=exp(-jHeight/shRlh)*jStepSize;jOdMie+=exp(-jHeight/shMie)*jStepSize;jTime+=jStepSize;}vec3 attn=exp(-(kMie*(iOdMie+jOdMie)+kRlh*(iOdRlh+jOdRlh)));totalRlh+=odStepRlh*attn;totalMie+=odStepMie*attn;iTime+=iStepSize;}float opacity=exp(-(length(kRlh)*length(totalRlh)+kMie*length(totalMie)));vec3 color=iSun*(pRlh*kRlh*totalRlh+pMie*kMie*totalMie);return vec4(color,opacity);}void main() {vec3 scale_camera_pos=-u_globe_position*EARTH_RADIUS/u_globe_radius;vec4 color=atmosphere(normalize(view_direction),scale_camera_pos,u_sun_pos,22.0,EARTH_RADIUS,ATMOS_RADIUS,vec3(5.5e-6,13.0e-6,22.4e-6),21e-6,8e3,1.2e3,0.758
|
|
764
|
+
);color.rgb=1.0-exp(-1.0*color.rgb);color=pow(color,vec4(1.0/2.2));fragColor=vec4(color.rgb,1.0-color.a)*u_atmosphere_blend;}`,"layout(location=0) in vec2 a_pos;uniform mat4 u_inv_proj_matrix;out vec3 view_direction;void main() {view_direction=(u_inv_proj_matrix*vec4(a_pos,0.0,1.0)).xyz;gl_Position=vec4(a_pos,0.0,1.0);}"),sky:be("uniform vec4 u_sky_color;uniform vec4 u_horizon_color;uniform vec2 u_horizon;uniform vec2 u_horizon_normal;uniform float u_sky_horizon_blend;uniform float u_sky_blend;uniform vec3 u_globe_position;uniform float u_globe_radius;uniform float u_atmosphere_blend;in vec3 v_view_direction;const float ATMOSPHERE_HEIGHT_TO_GLOBE_RADIUS=100000.0/6371000.0;void main() {float x=gl_FragCoord.x;float y=gl_FragCoord.y;float blend=(y-u_horizon.y)*u_horizon_normal.y+(x-u_horizon.x)*u_horizon_normal.x;float opacity=1.0;if (u_sky_blend > 0.0) {vec3 ray=normalize(v_view_direction);float globe_distance=length(u_globe_position);float angle_to_globe_center=acos(clamp(dot(ray,u_globe_position)/globe_distance,-1.0,1.0));float horizon_angle=asin(min(u_globe_radius/globe_distance,1.0));blend=mix(blend,((angle_to_globe_center-horizon_angle)*u_camera_to_center_distance+1.0)*u_device_pixel_ratio,u_sky_blend);float closest_approach=max(dot(ray,u_globe_position),0.0);float lowest_altitude=sqrt(max(globe_distance*globe_distance-closest_approach*closest_approach,0.0))-u_globe_radius;float atmosphere_height=u_globe_radius*ATMOSPHERE_HEIGHT_TO_GLOBE_RADIUS;float inside_atmosphere=1.0-smoothstep(atmosphere_height,10.0*atmosphere_height,globe_distance-u_globe_radius);float through_atmosphere=1.0-smoothstep(0.0,atmosphere_height,lowest_altitude);opacity=inside_atmosphere*through_atmosphere*(1.0-u_atmosphere_blend);}if (blend > 0.0) {if (blend < u_sky_horizon_blend) {fragColor=mix(u_sky_color,u_horizon_color,pow(1.0-blend/u_sky_horizon_blend,2.0));} else {fragColor=u_sky_color;}}fragColor*=mix(1.0,opacity,u_sky_blend);}","layout(location=0) in vec2 a_pos;uniform mat4 u_inv_proj_matrix;out vec3 v_view_direction;void main() {v_view_direction=(u_inv_proj_matrix*vec4(a_pos,0.0,1.0)).xyz;gl_Position=vec4(a_pos,1.0,1.0);}")};function be(e,t){let i=/#pragma maplibre: ([\w]+) ([\w]+) ([\w]+) ([\w]+)/g,r=t.match(/in ([\w]+) ([\w]+)/g),a=e.match(/uniform ([\w]+) ([\w]+)([\s]*)([\w]*)/g),n=t.match(/uniform ([\w]+) ([\w]+)([\s]*)([\w]*)/g),o=n?n.concat(a):a,s=r?r.length:0,l={};return e=e.replace(i,(u,h,c,d,p)=>(l[p]=!0,h==="define"?`
|
|
765
|
+
#ifndef HAS_UNIFORM_u_${p}
|
|
766
|
+
in ${c} ${d} ${p};
|
|
767
|
+
#else
|
|
768
|
+
uniform ${c} ${d} u_${p};
|
|
769
|
+
#endif
|
|
770
|
+
`:`
|
|
771
|
+
#ifdef HAS_UNIFORM_u_${p}
|
|
772
|
+
${c} ${d} ${p} = u_${p};
|
|
773
|
+
#endif
|
|
774
|
+
`)),t=t.replace(i,(u,h,c,d,p)=>{let f=d==="float"?"vec2":"vec4",m=p.match(/color/)?"color":f;return l[p]?h==="define"?`
|
|
775
|
+
#ifndef HAS_UNIFORM_u_${p}
|
|
776
|
+
uniform lowp float u_${p}_t;
|
|
777
|
+
layout(location = ${s++}) in ${c} ${f} a_${p};
|
|
778
|
+
out ${c} ${d} ${p};
|
|
779
|
+
#else
|
|
780
|
+
uniform ${c} ${d} u_${p};
|
|
781
|
+
#endif
|
|
782
|
+
`:m==="vec4"?`
|
|
783
|
+
#ifndef HAS_UNIFORM_u_${p}
|
|
784
|
+
${p} = a_${p};
|
|
785
|
+
#else
|
|
786
|
+
${c} ${d} ${p} = u_${p};
|
|
787
|
+
#endif
|
|
788
|
+
`:`
|
|
789
|
+
#ifndef HAS_UNIFORM_u_${p}
|
|
790
|
+
${p} = unpack_mix_${m}(a_${p}, u_${p}_t);
|
|
791
|
+
#else
|
|
792
|
+
${c} ${d} ${p} = u_${p};
|
|
793
|
+
#endif
|
|
794
|
+
`:h==="define"?`
|
|
795
|
+
#ifndef HAS_UNIFORM_u_${p}
|
|
796
|
+
uniform lowp float u_${p}_t;
|
|
797
|
+
layout(location = ${s++}) in ${c} ${f} a_${p};
|
|
798
|
+
#else
|
|
799
|
+
uniform ${c} ${d} u_${p};
|
|
800
|
+
#endif
|
|
801
|
+
`:m==="vec4"?`
|
|
802
|
+
#ifndef HAS_UNIFORM_u_${p}
|
|
803
|
+
${c} ${d} ${p} = a_${p};
|
|
804
|
+
#else
|
|
805
|
+
${c} ${d} ${p} = u_${p};
|
|
806
|
+
#endif
|
|
807
|
+
`:`
|
|
808
|
+
#ifndef HAS_UNIFORM_u_${p}
|
|
809
|
+
${c} ${d} ${p} = unpack_mix_${m}(a_${p}, u_${p}_t);
|
|
810
|
+
#else
|
|
811
|
+
${c} ${d} ${p} = u_${p};
|
|
812
|
+
#endif
|
|
813
|
+
`}),{fragmentSource:e,vertexSource:t,staticAttributes:r,staticUniforms:o}}var qv="#define PROJECTION_MERCATOR",Wv="mercator",rd=class{constructor(){this._cachedMesh=null}get name(){return"mercator"}get useSubdivision(){return!1}get shaderVariantName(){return Wv}get shaderDefine(){return qv}get shaderPreludeCode(){return Zi.projectionMercator}get vertexShaderPreludeCode(){return Zi.projectionMercator.vertexSource}get subdivisionGranularity(){return Xd.noSubdivision}get useGlobeControls(){return!1}get transitionState(){return 0}destroy(){}getMeshFromTileID(e,t,i,r,a){if(this._cachedMesh)return this._cachedMesh;let n=new Gr;n.emplaceBack(0,0),n.emplaceBack(k,0),n.emplaceBack(0,k),n.emplaceBack(k,k);let o=e.createVertexBuffer(n,Ma.members),s=Ye.simpleSegment(0,0,4,2),l=new Xi;l.emplaceBack(1,0,2),l.emplaceBack(1,2,3);let u=e.createIndexBuffer(l);return this._cachedMesh=new go(o,u,s),this._cachedMesh}recalculate(){}hasTransition(){return!1}},ad=class Hv{constructor(t=0,i=0,r=0,a=0){if(isNaN(t)||t<0||isNaN(i)||i<0||isNaN(r)||r<0||isNaN(a)||a<0)throw Error("Invalid value for edge-insets, top, bottom, left and right must all be numbers");this.top=t,this.bottom=i,this.left=r,this.right=a}interpolate(t,i,r){return i.top!=null&&t.top!=null&&(this.top=He.number(t.top,i.top,r)),i.bottom!=null&&t.bottom!=null&&(this.bottom=He.number(t.bottom,i.bottom,r)),i.left!=null&&t.left!=null&&(this.left=He.number(t.left,i.left,r)),i.right!=null&&t.right!=null&&(this.right=He.number(t.right,i.right,r)),this}getCenter(t,i){return new C(ie((this.left+t-this.right)/2,0,t),ie((this.top+i-this.bottom)/2,0,i))}equals(t){return this.top===t.top&&this.bottom===t.bottom&&this.left===t.left&&this.right===t.right}clone(){return new Hv(this.top,this.bottom,this.left,this.right)}toJSON(){return{top:this.top,bottom:this.bottom,left:this.left,right:this.right}}};function xl(e,t){if(!e.renderWorldCopies||e.lngRange)return;let i=t.lng-e.center.lng;t.lng+=i>180?-360:i<-180?360:0}function Gg(e){return Math.max(0,Math.floor(e))}var Ip=class{constructor(e,t){this.applyConstrain=(i,r)=>this._constrainOverride===null?this._callbacks.defaultConstrain(i,r):this._constrainOverride(i,r),this._callbacks=e,this._tileSize=512,this._renderWorldCopies=t?.renderWorldCopies===void 0||!!t?.renderWorldCopies,this._minZoom=t?.minZoom||0,this._maxZoom=t?.maxZoom||22,this._minPitch=t?.minPitch===void 0||t?.minPitch===null?0:t?.minPitch,this._maxPitch=t?.maxPitch===void 0||t?.maxPitch===null?60:t?.maxPitch,this._constrainOverride=t?.constrainOverride??null,this.setMaxBounds(),this._width=0,this._height=0,this._center=new X(0,0),this._elevation=0,this._zoom=0,this._tileZoom=Gg(this._zoom),this._scale=It(this._zoom),this._bearingInRadians=0,this._fovInRadians=.6435011087932844,this._pitchInRadians=0,this._rollInRadians=0,this._unmodified=!0,this._edgeInsets=new ad,this._minElevationForCurrentTile=0,this._autoCalculateNearFarZ=!0}apply(e,t){this._constrainOverride=e.constrainOverride,this._latRange=e.latRange,this._lngRange=e.lngRange,this._width=e.width,this._height=e.height,this._center=e.center,this._elevation=e.elevation,this._minElevationForCurrentTile=e.minElevationForCurrentTile,this._zoom=e.zoom,this._tileZoom=Gg(this._zoom),this._scale=It(this._zoom),this._bearingInRadians=e.bearingInRadians,this._fovInRadians=e.fovInRadians,this._pitchInRadians=e.pitchInRadians,this._rollInRadians=e.rollInRadians,this._unmodified=e.unmodified,this._edgeInsets=new ad(e.padding.top,e.padding.bottom,e.padding.left,e.padding.right),this._minZoom=e.minZoom,this._maxZoom=e.maxZoom,this._minPitch=e.minPitch,this._maxPitch=e.maxPitch,this._renderWorldCopies=e.renderWorldCopies,this._cameraToCenterDistance=e.cameraToCenterDistance,this._nearZ=e.nearZ,this._farZ=e.farZ,this._autoCalculateNearFarZ=e.autoCalculateNearFarZ,t&&this.constrainInternal(),this._calcMatrices()}get pixelsToClipSpaceMatrix(){return this._pixelsToClipSpaceMatrix}get clipSpaceToPixelsMatrix(){return this._clipSpaceToPixelsMatrix}get minElevationForCurrentTile(){return this._minElevationForCurrentTile}setMinElevationForCurrentTile(e){e!==this._minElevationForCurrentTile&&(this._minElevationForCurrentTile=e,this._calcMatrices())}get tileSize(){return this._tileSize}get tileZoom(){return this._tileZoom}get scale(){return this._scale}get width(){return this._width}get height(){return this._height}get bearingInRadians(){return this._bearingInRadians}get lngRange(){return this._lngRange}get latRange(){return this._latRange}get pixelsToGLUnits(){return this._pixelsToGLUnits}get minZoom(){return this._minZoom}setMinZoom(e){if(this._minZoom===e)return;this._minZoom=e;let t=this._unmodified;this.setZoom(this.applyConstrain(this._center,this.zoom).zoom),this._unmodified=t}get maxZoom(){return this._maxZoom}setMaxZoom(e){if(this._maxZoom===e)return;this._maxZoom=e;let t=this._unmodified;this.setZoom(this.applyConstrain(this._center,this.zoom).zoom),this._unmodified=t}get minPitch(){return this._minPitch}setMinPitch(e){if(this._minPitch===e)return;this._minPitch=e;let t=this._unmodified;this.setPitch(Math.max(this.pitch,e)),this._unmodified=t}get maxPitch(){return this._maxPitch}setMaxPitch(e){if(this._maxPitch===e)return;this._maxPitch=e;let t=this._unmodified;this.setPitch(Math.min(this.pitch,e)),this._unmodified=t}get renderWorldCopies(){return this._renderWorldCopies}setRenderWorldCopies(e){e===void 0?e=!0:e===null&&(e=!1),this._renderWorldCopies=e}get constrainOverride(){return this._constrainOverride}setConstrainOverride(e){e===void 0&&(e=null),this._constrainOverride!==e&&(this._constrainOverride=e,this.constrainInternal(),this._calcMatrices())}get worldSize(){return this._tileSize*this._scale}get centerOffset(){return this.centerPoint._sub(this.size._div(2))}get size(){return new C(this._width,this._height)}get bearing(){return this._bearingInRadians/Math.PI*180}setBearing(e){let t=vi(e,-180,180)*Math.PI/180;this._bearingInRadians!==t&&(this._unmodified=!1,this._bearingInRadians=t,this._calcMatrices(),this._rotationMatrix=R_(),yb(this._rotationMatrix,this._rotationMatrix,-this._bearingInRadians))}get rotationMatrix(){return this._rotationMatrix}get pitchInRadians(){return this._pitchInRadians}get pitch(){return this._pitchInRadians/Math.PI*180}setPitch(e){let t=ie(e,this.minPitch,this.maxPitch)/180*Math.PI;this._pitchInRadians!==t&&(this._unmodified=!1,this._pitchInRadians=t,this._calcMatrices())}get rollInRadians(){return this._rollInRadians}get roll(){return this._rollInRadians/Math.PI*180}setRoll(e){let t=e/180*Math.PI;this._rollInRadians!==t&&(this._unmodified=!1,this._rollInRadians=t,this._calcMatrices())}get fovInRadians(){return this._fovInRadians}get fov(){return Si(this._fovInRadians)}setFov(e){e=ie(e,.1,150),this.fov!==e&&(this._unmodified=!1,this._fovInRadians=je(e),this._calcMatrices())}get zoom(){return this._zoom}setZoom(e){let t=this.applyConstrain(this._center,e).zoom;this._zoom!==t&&(this._unmodified=!1,this._zoom=t,this._tileZoom=Math.max(0,Math.floor(t)),this._scale=It(t),this.constrainInternal(),this._calcMatrices())}get center(){return this._center}setCenter(e){(e.lat!==this._center.lat||e.lng!==this._center.lng)&&(this._unmodified=!1,this._center=e,this.constrainInternal(),this._calcMatrices())}get elevation(){return this._elevation}setElevation(e){e!==this._elevation&&(this._elevation=e,this.constrainInternal(),this._calcMatrices())}get padding(){return this._edgeInsets.toJSON()}setPadding(e){this._edgeInsets.equals(e)||(this._unmodified=!1,this._edgeInsets.interpolate(this._edgeInsets,e,1),this.constrainInternal(),this._calcMatrices())}get centerPoint(){return this._edgeInsets.getCenter(this._width,this._height)}get pixelsPerMeter(){return this._pixelPerMeter}get unmodified(){return this._unmodified}get cameraToCenterDistance(){return this._cameraToCenterDistance}get nearZ(){return this._nearZ}get farZ(){return this._farZ}get autoCalculateNearFarZ(){return this._autoCalculateNearFarZ}overrideNearFarZ(e,t){this._autoCalculateNearFarZ=!1,this._nearZ=e,this._farZ=t,this._calcMatrices()}clearNearFarZOverride(){this._autoCalculateNearFarZ=!0,this._calcMatrices()}isPaddingEqual(e){return this._edgeInsets.equals(e)}interpolatePadding(e,t,i){this._unmodified=!1,this._edgeInsets.interpolate(e,t,i),this.constrainInternal(),this._calcMatrices()}resize(e,t,i=!0){this._width=e,this._height=t,i&&this.constrainInternal(),this._calcMatrices()}getMaxBounds(){return this._latRange?.length!==2||this._lngRange?.length!==2?null:new zi([this._lngRange[0],this._latRange[0]],[this._lngRange[1],this._latRange[1]])}setMaxBounds(e){e?(this._lngRange=[e.getWest(),e.getEast()],this._latRange=[e.getSouth(),e.getNorth()],this.constrainInternal()):(this._lngRange=null,this._latRange=[-85.051129,ur])}getCameraQueryGeometry(e,t){if(t.length===1)return[t[0],e];{let{minX:i,minY:r,maxX:a,maxY:n}=Ii.fromPoints(t).extend(e);return[new C(i,r),new C(a,r),new C(a,n),new C(i,n),new C(i,r)]}}constrainInternal(){if(!this.center||!this._width||!this._height||this._constraining)return;this._constraining=!0;let e=this._unmodified,{center:t,zoom:i}=this.applyConstrain(this.center,this.zoom);this.setCenter(t),this.setZoom(i),this._unmodified=e,this._constraining=!1}_calcMatrices(){if(this._pixelPerMeter=en(1,this.center.lat)*this.worldSize,!this._width||!this._height)return;this._pixelsToGLUnits=[2/this._width,-2/this._height];let e=Mi(new Float64Array(16));kt(e,e,[this._width/2,-this._height/2,1]),lt(e,e,[1,-1,0]),this._clipSpaceToPixelsMatrix=e,e=Mi(new Float64Array(16)),kt(e,e,[1,-1,1]),lt(e,e,[-1,-1,0]),kt(e,e,[2/this._width,2/this._height,1]),this._pixelsToClipSpaceMatrix=e;let t=this.fovInRadians/2;this._cameraToCenterDistance=.5/Math.tan(t)*this._height,this._callbacks.calcMatrices()}calculateCenterFromCameraLngLatAlt(e,t,i,r){let a=i===void 0?this.bearing:i,n=r=r===void 0?this.pitch:r,{distanceToCenter:o,clampedElevation:s}=this._distanceToCenterFromAltElevationPitch(t,this.elevation,n),{x:l,y:u}=zc(n,a),h=De.fromLngLat(e,t),{centerMercator:c,dMercator:d}=this._centerAlongView(h,l,u,o,u1(1,h.y));return{center:c.toLngLat(),elevation:s,zoom:Mt(this.height/2/Math.tan(this.fovInRadians/2)/d/this.tileSize)}}recalculateZoomAndCenter(e){if(this.elevation-e===0)return;let t=this.pitch,i=this.bearing,{x:r,y:a,z:n}=zc(t,i),o=De.fromLngLat(this.center,this.elevation),s=1/en(1,this.center.lat),l=this.cameraToCenterDistance/this.worldSize,u=new De(o.x-r*l,o.y-a*l,o.z+n*l),{distanceToCenter:h,clampedElevation:c}=this._distanceToCenterFromAltElevationPitch(u.z*s,e,t),{centerMercator:d,dMercator:p}=this._centerAlongView(u,r,a,h,s),f=d.toLngLat(),m=Mt(this.cameraToCenterDistance/p/this.tileSize);this._elevation=c,this._center=f;let g=this._zoom;this.setZoom(m),this._zoom===g&&(this._unmodified=!1,this.constrainInternal(),this._calcMatrices())}_centerAlongView(e,t,i,r,a){let n=r/a,o=new De(e.x+t*n,e.y+i*n),s=1/0;for(let l=1;l<10;l++){let u=1/o.meterInMercatorCoordinateUnits(),h=Math.abs(u-a);if(h<=1e-12*a||h>=s)break;s=h,a=u,n=r/a,o=new De(e.x+t*n,e.y+i*n)}return{centerMercator:o,dMercator:n}}_distanceToCenterFromAltElevationPitch(e,t,i){let r=-Math.cos(je(i)),a=e-t,n,o=t;return r*a>=0||Math.abs(r)<Math.cos(je(89.25))?(n=1e4,o=e+n*r):n=-a/r,{distanceToCenter:n,clampedElevation:o}}getCameraPoint(){let e=this.pitchInRadians,t=Math.tan(e)*(this.cameraToCenterDistance||1);return this.centerPoint.add(new C(t*Math.sin(this.rollInRadians),t*Math.cos(this.rollInRadians)))}getMercatorTileCoordinates(e){if(!e)return[0,0,1,1];let t=e.canonical.z>=0?1<<e.canonical.z:2**e.canonical.z;return[e.canonical.x/t,e.canonical.y/t,1/t/k,1/t/k]}},G3=class{getCenter(e){return e.center}distanceToTile2d(e,t,i,r){let a=r,n=a.distanceX([e,t]),o=a.distanceY([e,t]);return Math.hypot(n,o)}getWrap(e,t,i){return i}getTileBoundingVolume(e,t,i,r){let a=Math.min(0,i),n=Math.max(0,i);if(r?.terrain){let s=new Ct(e.z,t,e.z,e.x,e.y),l=r.terrain.getMinMaxElevation(s);a=l.minElevation??a,n=l.maxElevation??n}let o=1<<e.z;return new Tp([t+e.x/o,e.y/o,a],[t+(e.x+1)/o,(e.y+1)/o,n])}allowVariableZoom(e,t){let i=ie(78.5-e.fov*(Math.abs(Math.cos(e.rollInRadians))*e.height+Math.abs(Math.sin(e.rollInRadians))*e.width)/e.height/2,0,60);return!!t.terrain||e.pitch>i}allowWorldCopies(){return!0}prepareNextFrame(){}},Zg=k*(1-1e-12),qg=-.5,Wg={covered:!1,demLoaded:!1,elevation:0},Z3=class{constructor(e,t){this.tileManager=e,this.exaggeration=t,this._samplerCache=new Map}reset(){this._samplerCache.clear(),this._index=void 0,this._ownDemIndex=void 0}getIndex(e=!1){return e?(this._ownDemIndex===void 0&&(this._ownDemIndex=this._build(!0)),this._ownDemIndex):(this._index===void 0&&(this._index=this._build(!1)),this._index)}sample(e,t=!1){let i=this.getIndex(t);if(!i)return;let r=De.fromLngLat(e),a=Fo(i,this.exaggeration,r.x,r.y);return a.demLoaded?a.elevation:void 0}getSampler(e){let t=e.key,i=this._samplerCache.get(t);if(i)return i;let r=this._createElevationSampler(e);return r&&this._samplerCache.set(t,r),r}_createElevationSampler(e){let t=this.tileManager.getSourceTile(e,!0),i=t?.dem;if(!t||!i)return null;let r=e.canonical.z-t.tileID.canonical.z,a=1<<r,n=i.dim/(k*a),o=(e.canonical.x-(e.canonical.x>>r<<r))/a*i.dim+qg,s=(e.canonical.y-(e.canonical.y>>r<<r))/a*i.dim+qg;return(l,u,h)=>{let c=h===8192?1:k/h;return i.sampleBilinear(l*c*n+o,u*c*n+s)}}_build(e){let{tileManager:t}=this,i=[],r=new Map,a=0,n=0;for(let o of t.getRenderableTiles()){if(!o)continue;let{canonical:s,wrap:l}=o.tileID;i.includes(s.z)||i.push(s.z);let u=e&&!t.getSourceTile(o.tileID)?.dem?null:this.getSampler(o.tileID);r.set(`${l}/${s.z}/${s.x}/${s.y}`,u);let h=t.getSourceTile(o.tileID,!0)?.dem;a=Math.min(a,(h?.min??0)*this.exaggeration),n=Math.max(n,(h?.max??0)*this.exaggeration)}return r.size===0?null:(i.sort((o,s)=>s-o),{zooms:i,samplerPerTile:r,minElevation:a-10,maxElevation:n+10})}};function Fo(e,t,i,r){if(r<0||r>=1)return Wg;let a=Math.floor(i),n=i-a;for(let o of e.zooms){let s=1<<o,l=n*s,u=r*s,h=Math.floor(l),c=Math.floor(u),d=`${a}/${o}/${h}/${c}`;if(!e.samplerPerTile.has(d))continue;let p=e.samplerPerTile.get(d);return p?{covered:!0,demLoaded:!0,elevation:p(Math.min((l-h)*k,Zg),Math.min((u-c)*k,Zg),k)*t}:{covered:!0,demLoaded:!1,elevation:0}}return Wg}function Mp(e,t){return e.covered&&t<=e.elevation+1e-6}function Xv(e,t,i,r,a){for(let n=0;n<40&&r-i>a;n++){let o=(i+r)/2;t(e,o)?r=o:i=o}return{lo:i,hi:r}}var bl=class Yv{get pixelsToClipSpaceMatrix(){return this._helper.pixelsToClipSpaceMatrix}get clipSpaceToPixelsMatrix(){return this._helper.clipSpaceToPixelsMatrix}get pixelsToGLUnits(){return this._helper.pixelsToGLUnits}get centerOffset(){return this._helper.centerOffset}get size(){return this._helper.size}get rotationMatrix(){return this._helper.rotationMatrix}get centerPoint(){return this._helper.centerPoint}get pixelsPerMeter(){return this._helper.pixelsPerMeter}setMinZoom(t){this._helper.setMinZoom(t)}setMaxZoom(t){this._helper.setMaxZoom(t)}setMinPitch(t){this._helper.setMinPitch(t)}setMaxPitch(t){this._helper.setMaxPitch(t)}setRenderWorldCopies(t){this._helper.setRenderWorldCopies(t)}setBearing(t){this._helper.setBearing(t)}setPitch(t){this._helper.setPitch(t)}setRoll(t){this._helper.setRoll(t)}setFov(t){this._helper.setFov(t)}setZoom(t){this._helper.setZoom(t)}setCenter(t){this._helper.setCenter(t)}setElevation(t){this._helper.setElevation(t)}setMinElevationForCurrentTile(t){this._helper.setMinElevationForCurrentTile(t)}setPadding(t){this._helper.setPadding(t)}interpolatePadding(t,i,r){this._helper.interpolatePadding(t,i,r)}isPaddingEqual(t){return this._helper.isPaddingEqual(t)}resize(t,i,r=!0){this._helper.resize(t,i,r)}getMaxBounds(){return this._helper.getMaxBounds()}setMaxBounds(t){this._helper.setMaxBounds(t)}setConstrainOverride(t){this._helper.setConstrainOverride(t)}overrideNearFarZ(t,i){this._helper.overrideNearFarZ(t,i)}clearNearFarZOverride(){this._helper.clearNearFarZOverride()}getCameraQueryGeometry(t){return this._helper.getCameraQueryGeometry(this.getCameraPoint(),t)}get tileSize(){return this._helper.tileSize}get tileZoom(){return this._helper.tileZoom}get scale(){return this._helper.scale}get worldSize(){return this._helper.worldSize}get width(){return this._helper.width}get height(){return this._helper.height}get lngRange(){return this._helper.lngRange}get latRange(){return this._helper.latRange}get minZoom(){return this._helper.minZoom}get maxZoom(){return this._helper.maxZoom}get zoom(){return this._helper.zoom}get center(){return this._helper.center}get minPitch(){return this._helper.minPitch}get maxPitch(){return this._helper.maxPitch}get pitch(){return this._helper.pitch}get pitchInRadians(){return this._helper.pitchInRadians}get roll(){return this._helper.roll}get rollInRadians(){return this._helper.rollInRadians}get bearing(){return this._helper.bearing}get bearingInRadians(){return this._helper.bearingInRadians}get fov(){return this._helper.fov}get fovInRadians(){return this._helper.fovInRadians}get elevation(){return this._helper.elevation}get minElevationForCurrentTile(){return this._helper.minElevationForCurrentTile}get padding(){return this._helper.padding}get unmodified(){return this._helper.unmodified}get renderWorldCopies(){return this._helper.renderWorldCopies}get cameraToCenterDistance(){return this._helper.cameraToCenterDistance}get constrainOverride(){return this._helper.constrainOverride}get nearZ(){return this._helper.nearZ}get farZ(){return this._helper.farZ}get autoCalculateNearFarZ(){return this._helper.autoCalculateNearFarZ}setTransitionState(t){}constructor(t,i){this._posMatrixCache=new Map,this._alignedPosMatrixCache=new Map,this._fogMatrixCacheF32=new Map,this.defaultConstrain=(r,a)=>{a=ie(+a,this.minZoom,this.maxZoom);let n={center:new X(r.lng,r.lat),zoom:a},o=this._helper._lngRange;!this._helper._renderWorldCopies&&o===null&&(o=[-179.9999999999,180-1e-10]);let s=this.tileSize*It(n.zoom),l=0,u=s,h=0,c=s,d=0,p=0,{top:f=0,bottom:m=0,left:g=0,right:_=0}=this.padding,y=this.width-g-_,v=this.height-f-m;if(this._helper._latRange){let S=this._helper._latRange;l=Qa(S[1])*s,u=Qa(S[0])*s,u-l<v&&(d=v/(u-l))}o&&(h=vi(Ja(o[0])*s,0,s),c=vi(Ja(o[1])*s,0,s),c<h&&(c+=s),c-h<y&&(p=y/(c-h)));let{x,y:b}=Ui(s,r),w,T,E=Math.max(p||0,d||0);if(E)return n.center=mo(s,new C(p?(c+h)/2:x,d?(u+l)/2:b)).wrap(),n.zoom+=Mt(E),n;if(this._helper._latRange){let S=v/2;b-S<l&&(T=l+S),b+S>u&&(T=u-S)}if(o){let S=(h+c)/2,M=x;this._helper._renderWorldCopies&&(M=vi(x,S-s/2,S+s/2));let z=y/2;M-z<h&&(w=h+z),M+z>c&&(w=c-z)}return(w!==void 0||T!==void 0)&&(n.center=mo(s,new C(w??x,T??b)).wrap()),n},this.applyConstrain=(r,a)=>this._helper.applyConstrain(r,a),this._helper=i??new Ip({calcMatrices:()=>this._calcMatrices(),defaultConstrain:(r,a)=>this.defaultConstrain(r,a)},t),this._coveringTilesDetailsProvider=new G3}clone(){let t=new Yv;return t.apply(this,!1),t}apply(t,i){this._helper.apply(t,i)}get cameraPosition(){return this._cameraPosition}get projectionMatrix(){return this._projectionMatrix}get modelViewProjectionMatrix(){return this._viewProjMatrix}get inverseProjectionMatrix(){return this._invProjMatrix}get mercatorMatrix(){return this._mercatorMatrix}getVisibleUnwrappedCoordinates(t){let i=[new gl(0,t)];if(this._helper._renderWorldCopies){let r=this.screenPointToMercatorCoordinate(new C(0,0)),a=this.screenPointToMercatorCoordinate(new C(this._helper._width,0)),n=this.screenPointToMercatorCoordinate(new C(this._helper._width,this._helper._height)),o=this.screenPointToMercatorCoordinate(new C(0,this._helper._height)),s=Math.floor(Math.min(r.x,a.x,n.x,o.x)),l=Math.floor(Math.max(r.x,a.x,n.x,o.x));for(let u=s-1;u<=l+1;u++)u!==0&&i.push(new gl(u,t))}return i}getCameraFrustum(){return Ep.fromInvProjectionMatrix(this._invViewProjMatrix,this.worldSize)}getClippingPlane(){return null}getCoveringTilesDetailsProvider(){return this._coveringTilesDetailsProvider}recalculateZoomAndCenter(t){for(let i=0;i<3;i++){let r=t&&this._terrainPointPastMaxZoom(t)||this.screenPointToLocation(this.centerPoint,t),a=t?t.getElevationForLngLat(r,this):0;if(this.pitch<90&&a>=this.getCameraAltitude()||(this._helper.recalculateZoomAndCenter(a),!t||Math.abs(t.getElevationForLngLat(this.center,this)-this.elevation)<=1e-4))return}}setLocationAtPoint(t,i,r=this.elevation){let a=r-this.elevation,n=this.screenPointToMercatorCoordinateAtZ(i,a),o=this.screenPointToMercatorCoordinateAtZ(this.centerPoint,0),s=De.fromLngLat(t),l=new De(s.x-(n.x-o.x),s.y-(n.y-o.y));this.setCenter(l?.toLngLat()),this._helper._renderWorldCopies&&this.setCenter(this.center.wrap())}locationToScreenPoint(t,i){return i?this.coordinatePoint(De.fromLngLat(t),i.getElevationForLngLat(t,this),this._pixelMatrix3D):this.coordinatePoint(De.fromLngLat(t))}screenPointToLocation(t,i){return this.screenPointToMercatorCoordinate(t,i)?.toLngLat()}screenPointToLocationAtElevation(t,i){return this.screenPointToMercatorCoordinateAtZ(t,i-this.elevation)?.toLngLat()}screenPointToMercatorCoordinate(t,i){if(i){let r=this.screenTerrainPointToMercatorCoordinate(t,i);if(r!=null)return r}return this.screenPointToMercatorCoordinateAtZ(t)}_terrainPointPastMaxZoom(t){let i=t.getCoverageIndex();if(!i)return null;let{near:r,far:a}=this.getRaySegmentFromPixel(this.centerPoint,-1),n=this.cameraToCenterDistance*It(this.zoom-this.maxZoom),o=Ib([],r,a,Math.max(0,(n-this.nearZ)/(this.farZ-this.nearZ)));return Mp(Fo(i,t.exaggeration,o[0]/this.worldSize,o[1]/this.worldSize),o[2])?null:this._raycastTerrain(o,a,t)?.toLngLat()??null}screenTerrainPointToMercatorCoordinate(t,i){let{near:r,far:a}=this.getRaySegmentFromPixel(t,-1);return this._raycastTerrain(r,a,i)}_raycastTerrain(t,i,r){let a=r.getCoverageIndex();if(!a)return null;let n=this.worldSize,o=i[0]-t[0],s=i[1]-t[1],l=i[2]-t[2],u={index:a,exaggeration:r.exaggeration,near:t,dx:o,dy:s,dz:l,worldSize:n},h=0,c=1;if(l===0){if(t[2]>a.maxElevation||t[2]<a.minElevation)return null}else{let g=(a.maxElevation-t[2])/l,_=(a.minElevation-t[2])/l;if(h=Math.max(h,Math.min(g,_)),c=Math.min(c,Math.max(g,_)),h>c)return null}let d=Math.hypot(o,s),p=ie(Math.ceil(d*(c-h)/4),1,512),f=0,m=!ws(u,0);for(let g=0;g<=p;g++){let _=h+(c-h)*g/p;if(!m)m=!ws(u,_);else if(ws(u,_)){let{lo:y,hi:v}=Xv(u,ws,f,_,.001/d),x=$s(u,y),b=$s(u,v),w=t[2]+y*l-x.elevation,T=t[2]+v*l-b.elevation,E=x.covered&&w>T?ie(y+w*(v-y)/(w-T),y,v):v;return new De((t[0]+E*o)/n,(t[1]+E*s)/n,$s(u,E).elevation)}f=_}return null}getRaySegmentFromPixel(t,i=0){let r=[t.x,t.y,i,1],a=[t.x,t.y,1,1];Pt(r,r,this._pixelMatrixInverse),Pt(a,a,this._pixelMatrixInverse);let n=r[3],o=a[3],s=this.elevation;return{near:[r[0]/n,r[1]/n,r[2]/n+s],far:[a[0]/o,a[1]/o,a[2]/o+s]}}screenPointToMercatorCoordinateAtZ(t,i){let r=i||0,{near:a,far:n}=this.getRaySegmentFromPixel(t),o=a[2]===n[2]?0:(r+this.elevation-a[2])/(n[2]-a[2]);return new De(He.number(a[0],n[0],o)/this.worldSize,He.number(a[1],n[1],o)/this.worldSize,r)}coordinatePoint(t,i=0,r=this._pixelMatrix){let a=this._coordinateClipPoint(t,i,r),n=a[3];return n>0?new C(a[0]/n,a[1]/n):this._offScreenPointBehindCamera(a[0],a[1],n)}_coordinateClipPoint(t,i,r){let a=[t.x*this.worldSize,t.y*this.worldSize,i,1];return Pt(a,a,r)}_offScreenPointBehindCamera(t,i,r){let a=this.width/2,n=this.height/2,o=t-a*r,s=i-n*r;o===0&&s===0&&(s=1);let l=a+this.width,u=n+this.height,h=Math.min(o===0?1/0:l/Math.abs(o),s===0?1/0:u/Math.abs(s));return new C(a+o*h,n+s*h)}getBounds(){let t=Math.max(0,this._helper._height/2-Wn(this));return new zi().extend(this.screenPointToLocation(new C(0,t))).extend(this.screenPointToLocation(new C(this._helper._width,t))).extend(this.screenPointToLocation(new C(this._helper._width,this._helper._height))).extend(this.screenPointToLocation(new C(0,this._helper._height)))}isPointOnMapSurface(t,i){return i?this.screenTerrainPointToMercatorCoordinate(t,i)!=null:t.y>this.centerPoint.y-Wn(this)}calculatePosMatrix(t,i=!1,r=!1){let a=t.key??Oa(t.wrap,t.canonical.z,t.canonical.z,t.canonical.x,t.canonical.y),n=i?this._alignedPosMatrixCache:this._posMatrixCache;if(n.has(a)){let l=n.get(a);return r?l.f32:l.f64}let o=Yu(t,this.worldSize);wa(o,i?this._alignedProjMatrix:this._viewProjMatrix,o);let s={f64:o,f32:new Float32Array(o)};return n.set(a,s),r?s.f32:s.f64}calculateFogMatrix(t){let i=t.key,r=this._fogMatrixCacheF32;if(r.has(i))return r.get(i);let a=Yu(t,this.worldSize);return wa(a,this._fogMatrix,a),r.set(i,new Float32Array(a)),r.get(i)}calculateCenterFromCameraLngLatAlt(t,i,r,a){return this._helper.calculateCenterFromCameraLngLatAlt(t,i,r,a)}calculateCameraOptionsFromTo(t,i,r,a){let n=De.fromLngLat(t,i),o=De.fromLngLat(r,a),s=o.x-n.x,l=o.y-n.y,u=o.z-n.z,h=Math.hypot(s,l,u);if(h===0)throw Error("Can't calculate camera options with same From and To");let c=Math.hypot(s,l),d=Mt(this.cameraToCenterDistance/h/this.tileSize),p=Si(Math.atan2(s,-l)),f=Si(Math.acos(c/h));return f=u<0?90-f:90+f,{center:o.toLngLat(),elevation:a,zoom:d,pitch:f,bearing:p}}_calculateNearFarZ(t,i,r){let a=Math.min(this.elevation,this.minElevationForCurrentTile,this.getCameraAltitude()-100),n=t-a*this._helper._pixelPerMeter/Math.cos(i),o=a<0?n:t,s=Math.PI/2+this.pitchInRadians,l=je(this.fov)*(Math.abs(Math.cos(je(this.roll)))*this.height+Math.abs(Math.sin(je(this.roll)))*this.width)/this.height*(.5+r.y/this.height),u=Math.sin(l)*o/Math.sin(ie(Math.PI-s-l,.01,Math.PI-.01)),h=Wn(this),c=Math.atan(h/this._helper.cameraToCenterDistance),d=je(.75),p=c>d?2*c*(.5+r.y/(h*2)):d,f=Math.sin(p)*o/Math.sin(ie(Math.PI-s-p,.01,Math.PI-.01)),m=Math.min(u,f);this._helper._farZ=(Math.cos(Math.PI/2-i)*m+o)*1.01,this._helper._nearZ=this._helper._height/50}_calcMatrices(t=this._helper.autoCalculateNearFarZ){let i=this.centerOffset,r=Ui(this.worldSize,this.center),a=r.x,n=r.y,o=je(Math.min(this.pitch,La)),s=Math.max(this._helper.cameraToCenterDistance/2,this._helper.cameraToCenterDistance+this._helper._elevation*this._helper._pixelPerMeter/Math.cos(o));t&&this._calculateNearFarZ(s,o,i);let l;l=new Float64Array(16),Ch(l,this.fovInRadians,this._helper._width/this._helper._height,this._helper._nearZ,this._helper._farZ),this._invProjMatrix=new Float64Array(16),u3(this._invProjMatrix,l),l[8]=-i.x*2/this._helper._width,l[9]=i.y*2/this._helper._height,this._projectionMatrix=Sh(l),kt(l,l,[1,-1,1]),lt(l,l,[0,0,-this._helper.cameraToCenterDistance]),br(l,l,-this.rollInRadians),Ua(l,l,this.pitchInRadians),br(l,l,-this.bearingInRadians),lt(l,l,[-a,-n,0]),this._mercatorMatrix=kt([],l,[this.worldSize,this.worldSize,this.worldSize]),kt(l,l,[1,1,this._helper._pixelPerMeter]),this._pixelMatrix=wa(new Float64Array(16),this.clipSpaceToPixelsMatrix,l),lt(l,l,[0,0,-this.elevation]),this._viewProjMatrix=l,this._invViewProjMatrix=Zs([],l);let u=[0,0,-1,1];Pt(u,u,this._invViewProjMatrix),this._cameraPosition=[u[0]/u[3],u[1]/u[3],u[2]/u[3]],this._fogMatrix=new Float64Array(16),Ch(this._fogMatrix,this.fovInRadians,this.width/this.height,s,this._helper._farZ),this._fogMatrix[8]=-i.x*2/this.width,this._fogMatrix[9]=i.y*2/this.height,kt(this._fogMatrix,this._fogMatrix,[1,-1,1]),lt(this._fogMatrix,this._fogMatrix,[0,0,-this.cameraToCenterDistance]),br(this._fogMatrix,this._fogMatrix,-this.rollInRadians),Ua(this._fogMatrix,this._fogMatrix,this.pitchInRadians),br(this._fogMatrix,this._fogMatrix,-this.bearingInRadians),lt(this._fogMatrix,this._fogMatrix,[-a,-n,0]),kt(this._fogMatrix,this._fogMatrix,[1,1,this._helper._pixelPerMeter]),lt(this._fogMatrix,this._fogMatrix,[0,0,-this.elevation]),this._pixelMatrix3D=wa(new Float64Array(16),this.clipSpaceToPixelsMatrix,l);let h=this._helper._width%2/2,c=this._helper._height%2/2,d=Math.cos(this.bearingInRadians),p=Math.sin(-this.bearingInRadians),f=a-Math.round(a)+d*h+p*c,m=n-Math.round(n)+d*c+p*h,g=new Float64Array(l);if(lt(g,g,[f>.5?f-1:f,m>.5?m-1:m,0]),this._alignedProjMatrix=g,l=Zs(new Float64Array(16),this._pixelMatrix),!l)throw Error("failed to invert matrix");this._pixelMatrixInverse=l,this._clearMatrixCaches()}_clearMatrixCaches(){this._posMatrixCache.clear(),this._alignedPosMatrixCache.clear(),this._fogMatrixCacheF32.clear()}maxPitchScaleFactor(){if(!this._pixelMatrixInverse)return 1;let t=this.screenPointToMercatorCoordinate(new C(0,0)),i=[t.x*this.worldSize,t.y*this.worldSize,0,1];return Pt(i,i,this._pixelMatrix)[3]/this._helper.cameraToCenterDistance}getCameraPoint(){return this._helper.getCameraPoint()}getCameraAltitude(){return Math.cos(this.pitchInRadians)*this.cameraToCenterDistance/this.pixelsPerMeter+this.elevation}getCameraLngLat(){let t=en(1,this.center.lat)*this.worldSize,i=this._helper.cameraToCenterDistance/t;return d1(this.center,this.elevation,this.pitch,this.bearing,i).toLngLat()}getProjectionData(t){let{overscaledTileID:i,aligned:r,applyTerrainMatrix:a}=t,n=this._helper.getMercatorTileCoordinates(i),o=i?this.calculatePosMatrix(i,r,!0):null,s;return s=i?.terrainRttPosMatrix32f&&a?i.terrainRttPosMatrix32f:o||O_(),{mainMatrix:s,tileMercatorCoords:n,clippingPlane:[0,0,0,0],projectionTransition:0,fallbackMatrix:s,clipAntimeridian:!1}}isLocationOccluded(t,i,r){if(!i?.getCoverageIndex())return!1;let a=De.fromLngLat(t);r??(r=i.getElevationForLngLat(t,this));let n=this._coordinateClipPoint(a,r,this._pixelMatrix3D),o=n[3];if(o<=0||n[2]>o)return!0;let s=new C(n[0]/o,n[1]/o),l=this.screenTerrainPointToMercatorCoordinate(s,i);if(l==null)return!1;let u=this.getRaySegmentFromPixel(s,-1),h=Hg(u,a.x*this.worldSize,a.y*this.worldSize,r);return Hg(u,l.x*this.worldSize,l.y*this.worldSize,l.z)<h*.99}getPixelScale(){return 1}getCircleRadiusCorrection(){return 1}getPitchedTextCorrection(t,i,r){return 1}transformLightDirection(t){return Ph(t)}getRayDirectionFromPixel(t){throw Error("Not implemented.")}projectTileCoordinates(t,i,r,a){let n=this.calculatePosMatrix(r),o;a==null?(o=[t,i,0,1],Ap(o,o,n)):(o=[t,i,a,1],Pt(o,o,n));let s=o[3];return{point:new C(o[0]/s,o[1]/s),signedDistanceFromCamera:s,isOccluded:!1}}populateCache(t){for(let i of t)this.calculatePosMatrix(i)}getProjectionDataForCustomLayer(t=!0){let i=new Ct(0,0,0,0,0),r=this.getProjectionData({overscaledTileID:i,applyGlobeMatrix:t}),a=Yu(i,this.worldSize);wa(a,this._viewProjMatrix,a);let n=[k,k,this.worldSize/this._helper.pixelsPerMeter],o=Ur();return kt(o,a,n),{...r,tileMercatorCoords:[0,0,1,1],fallbackMatrix:o,mainMatrix:o}}getFastPathSimpleProjectionMatrix(t){return this.calculatePosMatrix(t)}};function $s(e,t){return Fo(e.index,e.exaggeration,(e.near[0]+t*e.dx)/e.worldSize,(e.near[1]+t*e.dy)/e.worldSize)}function ws(e,t){return Mp($s(e,t),e.near[2]+t*e.dz)}function Hg({near:e,far:t},i,r,a){let n=t[0]-e[0],o=t[1]-e[1],s=t[2]-e[2];return((i-e[0])*n+(r-e[1])*o+(a-e[2])*s)/(n*n+o*o+s*s)}function Kv(){_e("Map cannot fit within canvas with the given bounds, padding, and/or offset.")}function Jv(e){if(e.useSlerp)if(e.k<1){let t=Ef(e.startEulerAngles.roll,e.startEulerAngles.pitch,e.startEulerAngles.bearing),i=Ef(e.endEulerAngles.roll,e.endEulerAngles.pitch,e.endEulerAngles.bearing),r=new Float64Array(4);Ms(r,t,i,e.k);let a=ow(r);e.tr.setRoll(a.roll),e.tr.setPitch(a.pitch),e.tr.setBearing(a.bearing)}else e.tr.setRoll(e.endEulerAngles.roll),e.tr.setPitch(e.endEulerAngles.pitch),e.tr.setBearing(e.endEulerAngles.bearing);else e.tr.setRoll(He.number(e.startEulerAngles.roll,e.endEulerAngles.roll,e.k)),e.tr.setPitch(He.number(e.startEulerAngles.pitch,e.endEulerAngles.pitch,e.k)),e.tr.setBearing(He.number(e.startEulerAngles.bearing,e.endEulerAngles.bearing,e.k))}function Qv(e,t,i,r,a,n){let o=Ui(n.worldSize,r.getNorthWest()),s=Ui(n.worldSize,r.getNorthEast()),l=Ui(n.worldSize,r.getSouthEast()),u=Ui(n.worldSize,r.getSouthWest()),h=je(-a),c=o.rotate(h),d=s.rotate(h),p=l.rotate(h),f=u.rotate(h),m=new C(Math.max(c.x,d.x,f.x,p.x),Math.max(c.y,d.y,f.y,p.y)),g=new C(Math.min(c.x,d.x,f.x,p.x),Math.min(c.y,d.y,f.y,p.y)),_=m.sub(g),y=n.width-(i.left+i.right+t.left+t.right),v=n.height-(i.top+i.bottom+t.top+t.bottom),x=y/_.x,b=v/_.y;if(b<0||x<0){Kv();return}let w=Math.min(Mt(n.scale*Math.min(x,b)),e.maxZoom),T=C.convert(e.offset),E=new C((t.left-t.right)/2,(t.top-t.bottom)/2).rotate(je(a)),S=T.add(E).mult(n.scale/It(w));return{center:mo(n.worldSize,o.add(l).div(2).sub(S)),zoom:w,bearing:a}}var wl=class{get useGlobeControls(){return!1}handlePanInertia(e,t){let i=e.mag(),r=Math.abs(Wn(t));return{easingOffset:e.mult(Math.min(r*.75/i,1)),easingCenter:t.center}}handleMapControlsRollPitchBearingZoom(e,t){e.bearingDelta&&t.setBearing(t.bearing+e.bearingDelta),e.pitchDelta&&t.setPitch(t.pitch+e.pitchDelta),e.rollDelta&&t.setRoll(t.roll+e.rollDelta),e.zoomDelta&&t.setZoom(t.zoom+e.zoomDelta)}handleMapControlsPan(e,t,i){e.around.distSqr(t.centerPoint)<.01||t.setLocationAtPoint(i,e.around,e.aroundElevation)}cameraForBoxAndBearing(e,t,i,r,a,n){return Qv(e,t,i,r,a,n)}handleJumpToCenterZoom(e,t){let i=t.zoom===void 0?e.zoom:+t.zoom;e.zoom!==i&&e.setZoom(+t.zoom),t.center!==void 0&&e.setCenter(X.convert(t.center))}handleEaseTo(e,t){let i=e.zoom,r=e.padding,a={roll:e.roll,pitch:e.pitch,bearing:e.bearing},n={roll:t.roll===void 0?e.roll:t.roll,pitch:t.pitch===void 0?e.pitch:t.pitch,bearing:t.bearing===void 0?e.bearing:t.bearing},o=t.zoom!==void 0,s=!e.isPaddingEqual(t.padding),l=!1,u=o?+t.zoom:e.zoom,h=e.centerPoint.add(t.offsetAsPoint),c=e.screenPointToLocation(h),{center:d,zoom:p}=e.applyConstrain(X.convert(t.center||c),u??i);xl(e,d);let f=Ui(e.worldSize,c),m=Ui(e.worldSize,d).sub(f),g=It(p-i);l=p!==i;let _=v=>{if(l&&e.setZoom(He.number(i,p,v)),U_(a,n)||Jv({startEulerAngles:a,endEulerAngles:n,tr:e,k:v,useSlerp:a.roll!=n.roll}),s&&(e.interpolatePadding(r,t.padding,v),h=e.centerPoint.add(t.offsetAsPoint)),t.around)e.setLocationAtPoint(t.around,t.aroundPoint);else{let x=It(e.zoom-i),b=(p>i?Math.min(2,g):Math.max(.5,g))**(1-v),w=mo(e.worldSize,f.add(m.mult(v*b)).mult(x));e.setLocationAtPoint(e.renderWorldCopies?w.wrap():w,h)}},y=this._transformAtAnimationEnd(e,p,n,t.padding);return t.around?y.setLocationAtPoint(t.around,t.aroundPoint):y.setLocationAtPoint(d,y.centerPoint.add(t.offsetAsPoint)),{easeFunc:_,isZooming:l,elevationCenter:y.center}}handleFlyTo(e,t){let i=t.zoom!==void 0,r=e.zoom,a=e.applyConstrain(X.convert(t.center||t.locationAtOffset),i?+t.zoom:r),n=a.center,o=a.zoom;xl(e,n);let s=e.worldSize,l=Ui(s,t.locationAtOffset),u=Ui(s,n).sub(l),h=u.mag(),c=It(o-r),d=t.minZoom===void 0?e.minZoom:+t.minZoom,p=Math.max(d,e.minZoom),f=Math.min(p,r,o),m=e.applyConstrain(n,f).zoom,g=It(m-r),_=(v,x,b,w)=>{e.setZoom(v===1?o:r+Mt(x));let T=v===1?n:mo(s,l.add(u.mult(b)));e.setLocationAtPoint(e.renderWorldCopies?T.wrap():T,w)},y=this._transformAtAnimationEnd(e,o,{roll:t.roll,pitch:t.pitch,bearing:t.bearing},t.padding);return y.setLocationAtPoint(n,y.centerPoint.add(t.offsetAsPoint)),{easeFunc:_,scaleOfZoom:c,targetCenter:y.center,scaleOfMinZoom:g,pixelPathLength:h}}_transformAtAnimationEnd(e,t,i,r){let a=e.clone();return a.setZoom(t),a.setRoll(i.roll),a.setPitch(i.pitch),a.setBearing(i.bearing),a.setPadding(r),a}},Xg,q3=()=>Xg||(Xg=new wt({type:new U(F.projection.type,"type")})),hh=new Xd({fill:new nr(128,2),line:new nr(512,0),tile:new nr(128,32),stencil:new nr(128,1),circle:3}),ex=class{constructor(){this._tileMeshCache={}}get name(){return"vertical-perspective"}get transitionState(){return 1}get useSubdivision(){return!0}get shaderVariantName(){return"globe"}get shaderDefine(){return"#define GLOBE"}get shaderPreludeCode(){return Zi.projectionGlobe}get vertexShaderPreludeCode(){return Zi.projectionMercator.vertexSource}get subdivisionGranularity(){return hh}get useGlobeControls(){return!0}destroy(){}_getMeshKey(e){return`${e.granularity.toString(36)}_${e.generateBorders?"b":""}${e.extendToNorthPole?"n":""}${e.extendToSouthPole?"s":""}`}getMeshFromTileID(e,t,i,r,a){let n=(a==="stencil"?hh.stencil:hh.tile).getGranularityForZoomLevel(t.z),o=t.y===0&&r,s=t.y===(1<<t.z)-1&&r;return this._getMesh(e,{granularity:n,generateBorders:i,extendToNorthPole:o,extendToSouthPole:s})}_getMesh(e,t){let i=this._getMeshKey(t);if(i in this._tileMeshCache)return this._tileMeshCache[i];let r=J1(e,t);return this._tileMeshCache[i]=r,r}recalculate(e){}hasTransition(){return!1}},Yg=class extends ht{constructor(e,t){super(),this._transitionable=new Nl(q3(),"projection",t),this.setProjection(e),this._transitioning=this._transitionable.untransitioned(),this.recalculate(new Ae(0)),this._mercatorProjection=new rd,this._verticalPerspectiveProjection=new ex}get transitionState(){let e=this.properties.get("type");if(typeof e=="string"&&e==="mercator")return 0;if(typeof e=="string"&&e==="vertical-perspective")return 1;if(e instanceof Mr){if(e.from===e.to)return e.from==="mercator"?0:1;if(e.from==="vertical-perspective"&&e.to==="mercator")return 1-e.transition;if(e.from==="mercator"&&e.to==="vertical-perspective")return e.transition}return 1}get useGlobeRendering(){return this.transitionState>0}get currentProjection(){return this.useGlobeRendering?this._verticalPerspectiveProjection:this._mercatorProjection}get name(){return"globe"}get useSubdivision(){return this.currentProjection.useSubdivision}get shaderVariantName(){return this.currentProjection.shaderVariantName}get shaderDefine(){return this.currentProjection.shaderDefine}get shaderPreludeCode(){return this.currentProjection.shaderPreludeCode}get vertexShaderPreludeCode(){return this.currentProjection.vertexShaderPreludeCode}get subdivisionGranularity(){return this.currentProjection.subdivisionGranularity}get useGlobeControls(){return this.transitionState>0}destroy(){this._mercatorProjection.destroy(),this._verticalPerspectiveProjection.destroy()}getMeshFromTileID(e,t,i,r,a){return this.currentProjection.getMeshFromTileID(e,t,i,r,a)}setProjection(e){this._transitionable.setValue("type",e?.type||"mercator")}updateTransitions(e){this._transitioning=this._transitionable.transitioned(e,this._transitioning)}hasTransition(){return this._transitioning.hasTransition()||this.currentProjection.hasTransition()}recalculate(e){this.properties=this._transitioning.possiblyEvaluate(e)}};function tx(e){let t=Xr(e.worldSize,e.center.lat);return 2*Math.PI*t}function W3(e,t,i){let r=ie(ut(mt(t),mt(i)),-1,1),a=Math.acos(r),n=tx(e);return a/(2*Math.PI)*n}function H3(e,t){return[Jr(e*Math.PI*2+Math.PI,Math.PI*2),2*Math.atan(Math.exp(Math.PI-t*Math.PI*2))-Math.PI*.5]}function X3(e,t){let i=Math.cos(t),r=new Float64Array(3);return r[0]=Math.sin(e)*i,r[1]=Math.sin(t),r[2]=Math.cos(e)*i,r}function _r(e,t,i,r,a){let n=1/(1<<a),o=e/k*n+i*n,s=t/k*n+r*n,l=Jr(o*Math.PI*2+Math.PI,Math.PI*2),u=2*Math.atan(Math.exp(Math.PI-s*Math.PI*2))-Math.PI*.5,h=Math.cos(u),c=new Float64Array(3);return c[0]=Math.sin(l)*h,c[1]=Math.sin(u),c[2]=Math.cos(l)*h,c}function mt(e){return X3(e.lng*Math.PI/180,e.lat*Math.PI/180)}function Xr(e,t){return e/(2*Math.PI)/aa(t)}function ix(e){let t=Pt(Nr(),[0,0,0,1],e.modelViewProjectionMatrix);return Pt(t,t,e.inverseProjectionMatrix),[t[0]/t[3],t[1]/t[3],t[2]/t[3]]}function Xn(e){let t=Math.asin(e[1])/Math.PI*180,i=Math.sqrt(e[0]*e[0]+e[2]*e[2]);if(i>1e-6){let r=e[0]/i,a=e[2]/i,n=Math.acos(a);return new X(vi((r>0?n:-n)/Math.PI*180,-180,180),t)}return new X(0,t)}function Y3(e,t){return _d(Nr(),-e.lng,-e.lat,t)}function K3(e){let t=e[0],i=e[1],r=e[2],a=e[3];return{lng:-Math.atan2(2*(a*t+i*r),1-2*(t*t+i*i))*180/Math.PI,lat:-Math.asin(ie(2*(a*i-r*t),-1,1))*180/Math.PI,bearing:Math.atan2(2*(a*r+t*i),1-2*(i*i+r*r))*180/Math.PI}}var ch=Math.PI*.98;function Kg(e,t){let i=e.cameraPosition,r=Pi(i);if(r<=1)return e.screenPointToLocation(t);let a=Pe();Vt(a,i);let n=e.getRayDirectionFromPixel(t),o=-ut(n,a),s=Pe();qs(s,n,a,o);let l=Pi(s);if(l<1e-9)return e.screenPointToLocation(t);let u=Math.atan2(l,o),h=Math.asin(1/r)*.9;if(u<h)return e.screenPointToLocation(t);let c=r*Math.sin(h),d=Math.asin(ie(c,-1,1))-h,p=r*Math.cos(h)/Math.sqrt(Math.max(1-c*c,1e-12))-1,f=ch-d,m=u-h,g=d+p*m*f/(f+p*m),_=Pe();Ue(_,s,1/l);let y=Pe();return Ue(y,a,Math.cos(ie(g,0,ch))),qs(y,y,_,Math.sin(ie(g,0,ch))),Vt(y,y),Xn(y)}function J3(e,t,i,r,a=!0){let n=Kg(e,i),o=t;if(r)o=Kg(e,i.sub(r));else if(!e.isPointOnMapSurface(i))return;let s=mt(n),l=mt(o),u=Y3(e.center,e.bearing),h=Yt(Pe(),l,s),c=Math.sqrt(ut(h,h)),d=Math.acos(ie(ut(l,s),-1,1))/2,p=Math.sin(d),f=c?_f(h[1]/c*p,-h[0]/c*p,h[2]/c*p,Math.cos(d)):_f(0,0,0,1),{lng:m,lat:g,bearing:_}=K3(Nb(Nr(),u,f)),y=e.center.lat,v=e.zoom,x=a?Q3(e,g,_):g,b=a?eF(e,i,r,m):m;e.setCenter(new X(vi(b,-180,180),x)),a||e.setBearing(_),e.setZoom(v+yt(y,e.center.lat))}function Q3(e,t,i){return Math.abs(qt(e.bearing,i))<=90?t:t>0?90:-90}function eF(e,t,i,r){let a=e.center.lng,n=e.center.lat,o=n>=0?90:-90,s=e.locationToScreenPoint(new X(0,o)),l=t.x-s.x,u=t.y-s.y,h=l*l+u*u,c=ie(1-(ur-Math.abs(n))/12,0,1),d=c*c*(3-2*c),p=Jr(r-a+180,360)-180,f=0;if(d>0&&i){let m=(l*i.y-u*i.x)/Math.max(h,400);f=(o>0?1:-1)*m*180/Math.PI}return a+(1-d)*p+d*f}function tF(e){let t=Pe();return t[0]=e[0]*-e[3],t[1]=e[1]*-e[3],t[2]=e[2]*-e[3],{center:t,radius:Math.sqrt(1-e[3]*e[3])}}function iF(e,t,i){let r=Pe();lr(r,i,e);let a=Pe();return qs(a,e,r,t/Ws(r)),a}function aa(e){return Math.cos(Math.min(Math.abs(e),ur)*Math.PI/180)}function yt(e,t){let i=aa(e);return Mt(aa(t)/i)}function rF(e,t){return 360/tx({worldSize:e,center:{lat:t}})}function aF(e,t){let i=e.rotate(t.bearingInRadians),r=t.zoom+yt(t.center.lat,0),a=za(1/aa(t.center.lat),1/aa(Math.min(Math.abs(t.center.lat),60)),On(r,7,3,0,1)),n=rF(t.worldSize,t.center.lat);return new X(t.center.lng-i.x*n*a,ie(t.center.lat+i.y*n,-90,90))}function dh(e){let t=.5*e,i=Math.sin(t),r=Math.cos(t);return Math.log(i+r)-Math.log(r-i)}function Jg(e,t,i,r){let a=ie(e.lat+i*r,-90,90),n=ie(e.lat,-85.051129,ur),o=ie(e.lat+i,-85.051129,ur);if(Math.abs(o-n)>1){let s=(Math.sign(o)===Math.sign(n)?Math.abs(n):-Math.abs(n))*Math.PI/180,l=Math.abs(o)*Math.PI/180,u=dh(s+r*(l-s)),h=dh(s),c=dh(l),d=(u-h)/(c-h);return new X(e.lng+t*d,a)}return new X(e.lng+t*r,a)}function Ts(e,t,i=1){let r=ut(e,t),a=i*i,n=Pe(),o=Pe();Ue(o,t,r),lr(n,e,o);let s=a-ut(n,n);if(s<0)return null;let l=ut(e,e)-a,u=-r+(r<0?1:-1)*Math.sqrt(s),h=l/u,c=u,d=Math.max(h,c);return d<0?null:{tMin:Math.min(h,c),tMax:d}}function rx(e,t){let i=t*.01569612305760477,r=ie((e-i)/(9*i),0,1);return r*r*(3-2*r)}var nF=class{constructor(e){this._cachePrevious=new Map,this._cache=new Map,this._hadAnyChanges=!1,this._boundingVolumeFactory=e}swapBuffers(){if(!this._hadAnyChanges)return;let e=this._cachePrevious;this._cachePrevious=this._cache,this._cache=e,this._cache.clear(),this._hadAnyChanges=!1}getTileBoundingVolume(e,t,i,r){let a=`${e.z}_${e.x}_${e.y}_${r?.terrain?"t":""}_${Math.round(i)}`,n=this._cache.get(a);if(n)return n;let o=this._cachePrevious.get(a);if(o)return this._cache.set(a,o),o;let s=this._boundingVolumeFactory(e,t,i,r);return this._cache.set(a,s),this._hadAnyChanges=!0,s}},ph=class nd{constructor(t,i,r,a){this.min=r,this.max=a,this.points=t,this.planes=i}static fromAabb(t,i){let r=[];for(let a=0;a<8;a++)r.push([(a>>0&1)==1?i[0]:t[0],(a>>1&1)==1?i[1]:t[1],(a>>2&1)==1?i[2]:t[2]]);return new nd(r,[[-1,0,0,i[0]],[1,0,0,-t[0]],[0,-1,0,i[1]],[0,1,0,-t[1]],[0,0,-1,i[2]],[0,0,1,-t[2]]],t,i)}static fromCenterSizeAngles(t,i,r){let a=_d([],r[0],r[1],r[2]),n=Mu([],[i[0],0,0],a),o=Mu([],[0,i[1],0],a),s=Mu([],[0,0,i[2]],a),l=[...t],u=[...t];for(let c=0;c<8;c++)for(let d=0;d<3;d++){let p=t[d]+n[d]*((c>>0&1)==1?1:-1)+o[d]*((c>>1&1)==1?1:-1)+s[d]*((c>>2&1)==1?1:-1);l[d]=Math.min(l[d],p),u[d]=Math.max(u[d],p)}let h=[];for(let c=0;c<8;c++){let d=[...t];yi(d,d,Ue([],n,(c>>0&1)==1?1:-1)),yi(d,d,Ue([],o,(c>>1&1)==1?1:-1)),yi(d,d,Ue([],s,(c>>2&1)==1?1:-1)),h.push(d)}return new nd(h,[[...n,-ut(n,h[0])],[...o,-ut(o,h[0])],[...s,-ut(s,h[0])],[-n[0],-n[1],-n[2],-ut(n,h[7])],[-o[0],-o[1],-o[2],-ut(o,h[7])],[-s[0],-s[1],-s[2],-ut(s,h[7])]],l,u)}intersectsFrustum(t){let i=!0,r=this.points.length,a=this.planes.length,n=t.planes.length,o=t.points.length;for(let s=0;s<n;s++){let l=t.planes[s],u=0;for(let h=0;h<r;h++){let c=this.points[h];l[0]*c[0]+l[1]*c[1]+l[2]*c[2]+l[3]>=0&&u++}if(u===0)return 0;u<r&&(i=!1)}if(i)return 2;for(let s=0;s<a;s++){let l=this.planes[s],u=0;for(let h=0;h<o;h++){let c=t.points[h];l[0]*c[0]+l[1]*c[1]+l[2]*c[2]+l[3]>=0&&u++}if(u===0)return 0}return 1}intersectsPlane(t){let i=this.points.length,r=0;for(let a=0;a<i;a++){let n=this.points[a];t[0]*n[0]+t[1]*n[1]+t[2]*n[2]+t[3]>=0&&r++}return r===i?2:r===0?0:1}};function Gs(e,t,i){let r=e-t;return r<0?-r:Math.max(0,r-i)}function fh(e,t,i,r,a){let n=e-i,o;return o=n<0?Math.min(-n,1+n-a):n>a?Math.min(Math.max(n-a,0),1-n):0,Math.max(o,Gs(t,r,a))}var oF=class{constructor(){this._boundingVolumeCache=new nF(this._computeTileBoundingVolume)}getCenter(e){return new X(e.center.lng,ie(e.center.lat,-85.051129,ur))}prepareNextFrame(){this._boundingVolumeCache.swapBuffers()}distanceToTile2d(e,t,i,r){let a=1<<i.z,n=1/a,o=i.x/a,s=i.y/a,l=.5,u=2;return u=Math.min(u,fh(e,t,o,s,n)),u=Math.min(u,fh(e,t,o+l,-s-n,n)),u=Math.min(u,fh(e,t,o+l,2-s-n,n)),u}getWrap(e,t,i){let r=1<<t.z,a=1/r,n=t.x/r,o=Gs(e.x,n,a),s=Gs(e.x,n-1,a),l=Gs(e.x,n+1,a),u=Math.min(o,s,l);return u===l?1:u===s?-1:0}allowVariableZoom(e,t){return Dp(e,t)>4}allowWorldCopies(){return!1}getTileBoundingVolume(e,t,i,r){return this._boundingVolumeCache.getTileBoundingVolume(e,t,i,r)}_computeTileBoundingVolume(e,t,i,r){let a=Math.min(0,i),n=Math.max(0,i);if(r?.terrain){let o=new Ct(e.z,t,e.z,e.x,e.y),s=r.terrain.getMinMaxElevation(o);a=s.minElevation??a,n=Math.max(s.maxElevation??n,n)}if(a/=jt,n/=jt,a+=1,n+=1,e.z<=0)return ph.fromAabb([-n,-n,-n],[n,n,n]);if(e.z===1)return ph.fromAabb([e.x===0?-n:0,e.y===0?0:-n,-n],[e.x===0?0:n,e.y===0?n:0,n]);{let o=[_r(0,0,e.x,e.y,e.z),_r(k,0,e.x,e.y,e.z),_r(k,k,e.x,e.y,e.z),_r(0,k,e.x,e.y,e.z)],s=[];for(let E of o)s.push(Ue([],E,n));if(n!==a)for(let E of o)s.push(Ue([],E,a));e.y===0&&s.push([0,1,0]),e.y===(1<<e.z)-1&&s.push([0,-1,0]);let l=[1,1,1],u=[-1,-1,-1];for(let E of s)for(let S=0;S<3;S++)l[S]=Math.min(l[S],E[S]),u[S]=Math.max(u[S],E[S]);let h=_r(k/2,k/2,e.x,e.y,e.z),c=Yt([],[0,1,0],h);Vt(c,c);let d=Yt([],h,c);Vt(d,d);let p=Yt([],o[2],o[1]);Vt(p,p);let f=Yt([],o[0],o[3]);Vt(f,f),s.push(Ue([],h,n)),e.y>=(1<<e.z)/2&&s.push(Ue([],_r(k/2,0,e.x,e.y,e.z),n)),e.y<(1<<e.z)/2&&s.push(Ue([],_r(k/2,k,e.x,e.y,e.z),n));let m=Qg(h,s),g=Qg(d,s),_=[-h[0],-h[1],-h[2],m.max],y=[h[0],h[1],h[2],-m.min],v=[-d[0],-d[1],-d[2],g.max],x=[d[0],d[1],d[2],-g.min],b=[...p,0],w=[...f,0],T=[];return e.y===0?T.push(di(w,b,_),di(w,b,y)):T.push(di(v,b,_),di(v,b,y),di(v,w,_),di(v,w,y)),e.y===(1<<e.z)-1?T.push(di(w,b,_),di(w,b,y)):T.push(di(x,b,_),di(x,b,y),di(x,w,_),di(x,w,y)),new ph(T,[_,y,v,x,b,w],l,u)}}};function Qg(e,t){let i=1/0,r=-1/0;for(let a of t){let n=ut(e,a);i=Math.min(i,n),r=Math.max(r,n)}return{min:i,max:r}}var e_=1e-12,ax=class nx{get pixelsToClipSpaceMatrix(){return this._helper.pixelsToClipSpaceMatrix}get clipSpaceToPixelsMatrix(){return this._helper.clipSpaceToPixelsMatrix}get pixelsToGLUnits(){return this._helper.pixelsToGLUnits}get centerOffset(){return this._helper.centerOffset}get size(){return this._helper.size}get rotationMatrix(){return this._helper.rotationMatrix}get centerPoint(){return this._helper.centerPoint}get pixelsPerMeter(){return this._helper.pixelsPerMeter}setMinZoom(t){this._helper.setMinZoom(t)}setMaxZoom(t){this._helper.setMaxZoom(t)}setMinPitch(t){this._helper.setMinPitch(t)}setMaxPitch(t){this._helper.setMaxPitch(t)}setRenderWorldCopies(t){this._helper.setRenderWorldCopies(t)}setBearing(t){this._helper.setBearing(t)}setPitch(t){this._helper.setPitch(t)}setRoll(t){this._helper.setRoll(t)}setFov(t){this._helper.setFov(t)}setZoom(t){this._helper.setZoom(t)}setCenter(t){this._helper.setCenter(t)}setElevation(t){this._helper.setElevation(t)}setMinElevationForCurrentTile(t){this._helper.setMinElevationForCurrentTile(t)}setPadding(t){this._helper.setPadding(t)}interpolatePadding(t,i,r){this._helper.interpolatePadding(t,i,r)}isPaddingEqual(t){return this._helper.isPaddingEqual(t)}resize(t,i){this._helper.resize(t,i)}getMaxBounds(){return this._helper.getMaxBounds()}setMaxBounds(t){this._helper.setMaxBounds(t)}setConstrainOverride(t){this._helper.setConstrainOverride(t)}overrideNearFarZ(t,i){this._helper.overrideNearFarZ(t,i)}clearNearFarZOverride(){this._helper.clearNearFarZOverride()}getCameraQueryGeometry(t){return this._helper.getCameraQueryGeometry(this.getCameraPoint(),t)}get tileSize(){return this._helper.tileSize}get tileZoom(){return this._helper.tileZoom}get scale(){return this._helper.scale}get worldSize(){return this._helper.worldSize}get width(){return this._helper.width}get height(){return this._helper.height}get lngRange(){return this._helper.lngRange}get latRange(){return this._helper.latRange}get minZoom(){return this._helper.minZoom}get maxZoom(){return this._helper.maxZoom}get zoom(){return this._helper.zoom}get center(){return this._helper.center}get minPitch(){return this._helper.minPitch}get maxPitch(){return this._helper.maxPitch}get pitch(){return this._helper.pitch}get pitchInRadians(){return this._helper.pitchInRadians}get roll(){return this._helper.roll}get rollInRadians(){return this._helper.rollInRadians}get bearing(){return this._helper.bearing}get bearingInRadians(){return this._helper.bearingInRadians}get fov(){return this._helper.fov}get fovInRadians(){return this._helper.fovInRadians}get elevation(){return this._helper.elevation}get minElevationForCurrentTile(){return this._helper.minElevationForCurrentTile}get padding(){return this._helper.padding}get unmodified(){return this._helper.unmodified}get renderWorldCopies(){return this._helper.renderWorldCopies}get constrainOverride(){return this._helper.constrainOverride}get nearZ(){return this._helper.nearZ}get farZ(){return this._helper.farZ}get autoCalculateNearFarZ(){return this._helper.autoCalculateNearFarZ}setTransitionState(t){}constructor(t,i){this._cachedClippingPlane=Nr(),this._projectionMatrix=Qo(),this._globeViewProjMatrix32f=O_(),this._globeViewProjMatrixF64=Qo(),this._globeViewProjMatrixF64Inverted=Qo(),this._globeProjMatrixInverted=Qo(),this._cameraPosition=Pe(),this.defaultConstrain=(r,a)=>{let n=ie(+a,this.minZoom+yt(0,r.lat),this.maxZoom),o=this._getMaxLatitude(n);return{center:new X(r.lng,ie(r.lat,-o,o)),zoom:n}},this.applyConstrain=(r,a)=>this._helper.applyConstrain(r,a),this._helper=i??new Ip({calcMatrices:()=>this._calcMatrices(),defaultConstrain:(r,a)=>this.defaultConstrain(r,a)},t),this._coveringTilesDetailsProvider=new oF}clone(){let t=new nx;return t.apply(this,!1),t}apply(t,i){this._helper.apply(t,i)}get projectionMatrix(){return this._projectionMatrix}get modelViewProjectionMatrix(){return this._globeViewProjMatrixF64}get inverseProjectionMatrix(){return this._globeProjMatrixInverted}get cameraPosition(){let t=Pe();return t[0]=this._cameraPosition[0],t[1]=this._cameraPosition[1],t[2]=this._cameraPosition[2],t}get cameraToCenterDistance(){return this._helper.cameraToCenterDistance}getProjectionData(t){let{overscaledTileID:i,applyGlobeMatrix:r}=t,a=this._helper.getMercatorTileCoordinates(i);return{mainMatrix:this._globeViewProjMatrix32f,tileMercatorCoords:a,clippingPlane:this._cachedClippingPlane,projectionTransition:+!!r,fallbackMatrix:this._globeViewProjMatrix32f,clipAntimeridian:i?.canonical.z===0}}_computeClippingPlane(t){let i=this.pitchInRadians,r=this.cameraToCenterDistance/t,a=Math.sin(i)*r,n=Math.cos(i)*r+1,o=1/Math.sqrt(a*a+n*n)*1,s=-a,l=n,u=Math.sqrt(s*s+l*l);s/=u,l/=u;let h=[0,s,l];Fu(h,h,[0,0,0],-this.bearingInRadians),_n(h,h,[0,0,0],-1*this.center.lat*Math.PI/180),ya(h,h,[0,0,0],this.center.lng*Math.PI/180);let c=1/Pi(h);return Ue(h,h,c),[...h,-o*c]}isLocationOccluded(t,i,r){let a=i?.getCoverageIndex();r??(r=a?i.getElevationForLngLat(t,this):0);let n=i_(t,r);if(!this.isSurfacePointVisible(n))return!0;if(!a)return!1;let o=this._projectSurfacePointToScreen(n),s=this.cameraPosition,l=this.getRayDirectionFromPixel(o),u=r_(s,l,n);if(u<=0)return!0;let h=this.screenTerrainPointToMercatorCoordinate(o,i);return h!=null&&r_(s,l,i_(h.toLngLat(),h.z))<u*.99}transformLightDirection(t){let i=this._helper._center.lng*Math.PI/180,r=this._helper._center.lat*Math.PI/180,a=Math.cos(r),n=[Math.sin(i)*a,Math.sin(r),Math.cos(i)*a],o=[n[2],0,-n[0]],s=[0,0,0];Yt(s,o,n),Vt(o,o),Vt(s,s);let l=[o[0]*t[0]+s[0]*t[1]+n[0]*t[2],o[1]*t[0]+s[1]*t[1]+n[1]*t[2],o[2]*t[0]+s[2]*t[1]+n[2]*t[2]],u=[0,0,0];return Vt(u,l),u}getPixelScale(){return 1/aa(this._helper._center.lat)}getCircleRadiusCorrection(){return aa(this._helper._center.lat)}getPitchedTextCorrection(t,i,r){let a=c1(t,i,r.canonical),n=H3(a.x,a.y);return this.getCircleRadiusCorrection()/Math.cos(n[1])}projectTileCoordinates(t,i,r,a){let n=r.canonical,o=_r(t,i,n.x,n.y,n.z),s=1+(a??0)/jt,l=o[0]*s,u=o[1]*s,h=o[2]*s,c=[l,u,h,1];Pt(c,c,this._globeViewProjMatrixF64);let d;if(s<=1){let p=this._cachedClippingPlane;d=p[0]*o[0]+p[1]*o[1]+p[2]*o[2]+p[3]<0}else d=this._isLineOfSightBlocked(l,u,h);return{point:new C(c[0]/c[3],c[1]/c[3]),signedDistanceFromCamera:c[3],isOccluded:d}}_isLineOfSightBlocked(t,i,r){let a=this._cameraPosition,n=t-a[0],o=i-a[1],s=r-a[2],l=n*n+o*o+s*s;if(l===0)return!1;let u=ie(-(a[0]*n+a[1]*o+a[2]*s)/l,0,1),h=a[0]+u*n,c=a[1]+u*o,d=a[2]+u*s;return h*h+c*c+d*d<1}_calcMatrices(t=this._helper.autoCalculateNearFarZ){let i=Xr(this.worldSize,this.center.lat),r=Ur();t&&(this._helper._nearZ=.5,this._helper._farZ=this.cameraToCenterDistance+i*2),Ch(r,this.fovInRadians,this.width/this.height,this._helper._nearZ,this._helper._farZ);let a=this.centerOffset;r[8]=-a.x*2/this._helper._width,r[9]=a.y*2/this._helper._height,this._projectionMatrix=Sh(r),this._globeProjMatrixInverted=Ur(),Zs(this._globeProjMatrixInverted,r),lt(r,r,[0,0,-this.cameraToCenterDistance]),br(r,r,this.rollInRadians),Ua(r,r,-this.pitchInRadians),br(r,r,this.bearingInRadians),lt(r,r,[0,0,-i]);let n=Pe();n[0]=i,n[1]=i,n[2]=i,Ua(r,r,this.center.lat*Math.PI/180),L_(r,r,-this.center.lng*Math.PI/180),kt(r,r,n),this._globeViewProjMatrixF64=r,this._globeViewProjMatrix32f=new Float32Array(r),this._globeViewProjMatrixF64Inverted=Ur(),Zs(this._globeViewProjMatrixF64Inverted,r);let o=Pe();this._cameraPosition=Pe(),this._cameraPosition[2]=this.cameraToCenterDistance/i,Fu(this._cameraPosition,this._cameraPosition,o,-this.rollInRadians),_n(this._cameraPosition,this._cameraPosition,o,this.pitchInRadians),Fu(this._cameraPosition,this._cameraPosition,o,-this.bearingInRadians),yi(this._cameraPosition,this._cameraPosition,[0,0,1]),_n(this._cameraPosition,this._cameraPosition,o,-this.center.lat*Math.PI/180),ya(this._cameraPosition,this._cameraPosition,o,this.center.lng*Math.PI/180),this._cachedClippingPlane=this._computeClippingPlane(i);let s=Sh(this._globeViewProjMatrixF64Inverted);kt(s,s,[1,1,-1]),this._cachedFrustum=Ep.fromInvProjectionMatrix(s,1,0,this._cachedClippingPlane,!0)}calculateFogMatrix(t){_e("calculateFogMatrix is not supported on globe projection.");let i=Ur();return Mi(i),i}getVisibleUnwrappedCoordinates(t){return[new gl(0,t)]}getCameraFrustum(){return this._cachedFrustum}getClippingPlane(){return this._cachedClippingPlane}getCoveringTilesDetailsProvider(){return this._coveringTilesDetailsProvider}recalculateZoomAndCenter(t){if(t){_e("terrain is not fully supported on vertical perspective projection.");return}this._helper.recalculateZoomAndCenter(0)}maxPitchScaleFactor(){return 1}getCameraPoint(){return this._helper.getCameraPoint()}getCameraAltitude(){return(Pi(this._cameraPosition)-1)*jt}getCameraLngLat(){let t=Pe();return Vt(t,this._cameraPosition),Xn(t)}populateCache(t){}getBounds(){let t=this.width*.5,i=this.height*.5,r=[new C(0,0),new C(t,0),new C(this.width,0),new C(this.width,i),new C(this.width,this.height),new C(t,this.height),new C(0,this.height),new C(0,i)],a=[];for(let c of r)a.push(this.unprojectScreenPoint(c));let n=0,o=0,s=0,l=0,u=this.center;for(let c of a){let d=qt(u.lng,c.lng),p=qt(u.lat,c.lat);d<o&&(o=d),d>n&&(n=d),p<l&&(l=p),p>s&&(s=p)}let h=[u.lng+o,u.lat+l,u.lng+n,u.lat+s];return this.isSurfacePointOnScreen([0,1,0])&&(h[3]=90,h[0]=-180,h[2]=180),this.isSurfacePointOnScreen([0,-1,0])&&(h[1]=-90,h[0]=-180,h[2]=180),new zi(h)}_getMaxLatitude(t){let i=je(4.948870999999997),r=Xr(this.tileSize*It(t),ur)*i,a=Math.min(this.width,this.height)/2,n=Math.min(r,a)*On(r,a,a*4,1,0);return ur+Si(i*n/r)}calculateCenterFromCameraLngLatAlt(t,i,r,a){return this._helper.calculateCenterFromCameraLngLatAlt(t,i,r,a)}calculateCameraOptionsFromTo(t,i,r,a){let n=X.convert(r),o=mt(X.convert(t));Ue(o,o,1+i/jt);let s=mt(n),l=Ue(Pe(),s,1+a/jt),u=gd(Pe(),o,s),h=Pi(u);if(h<e_||Pb(o,l)<e_)throw Error("Can't calculate camera options with same From and To");let c=Pe();ya(u,u,c,-je(n.lng)),_n(u,u,c,je(n.lat));let d=Si(Math.acos(ie(u[2]/h,-1,1))),p=Math.hypot(u[0],u[1])<h*1e-9?this.bearing:Si(Math.atan2(-u[0],-u[1]));return{center:n,elevation:a,zoom:Mt(this.cameraToCenterDistance/h/Xr(this.tileSize,n.lat)),pitch:d,bearing:p}}setLocationAtPoint(t,i,r){let a=mt(this.unprojectScreenPoint(i)),n=mt(t),o=Pe();zb(o);let s=Pe();ya(s,a,o,-this.center.lng*Math.PI/180),_n(s,s,o,this.center.lat*Math.PI/180);let l=n[0]*n[0]+n[2]*n[2],u=s[0]*s[0];if(l<u)return;let h=Math.sqrt(l-u),c=-h,d=es(n[0],n[2],s[0],h),p=es(n[0],n[2],s[0],c),f=Pe();ya(f,n,o,-d);let m=es(f[1],f[2],s[1],s[2]),g=Pe();ya(g,n,o,-p);let _=es(g[1],g[2],s[1],s[2]),y=Math.PI*.5,v=m>=-y&&m<=y,x=_>=-y&&_<=y,b,w;if(v&&x){let M=this.center.lng*Math.PI/180,z=this.center.lat*Math.PI/180,R=ts(d,M),I=ts(m,z),D=ts(p,M),P=ts(_,z);R+I<D+P?(b=d,w=m):(b=p,w=_)}else if(v)b=d,w=m;else if(x)b=p,w=_;else return;let T=b/Math.PI*180,E=w/Math.PI*180,S=this.center.lat;this.setCenter(new X(T,ie(E,-90,90))),this.setZoom(this.zoom+yt(S,this.center.lat))}locationToScreenPoint(t,i){let r=mt(t);return i&&Ue(r,r,1+i.getElevationForLngLat(t,this)/jt),this._projectSurfacePointToScreen(r)}_projectSurfacePointToScreen(t){let i=Nr();return Pt(i,[...t,1],this._globeViewProjMatrixF64),i[0]/=i[3],i[1]/=i[3],new C((i[0]*.5+.5)*this.width,(-i[1]*.5+.5)*this.height)}screenPointToMercatorCoordinate(t,i){if(i){let r=this.screenTerrainPointToMercatorCoordinate(t,i);if(r)return r}return De.fromLngLat(this.unprojectScreenPoint(t))}screenTerrainPointToMercatorCoordinate(t,i){let r=i.getCoverageIndex();if(!r)return null;let a=this.cameraPosition,n=this.getRayDirectionFromPixel(t),o=Ts(a,n,1+r.maxElevation/jt);if(!o)return null;let s=Ts(a,n,1+r.minElevation/jt),l=Math.max(o.tMin,0),u=s?s.tMin:o.tMax;if(u<=l)return null;let h={index:r,exaggeration:i.exaggeration,origin:a,direction:n},c=0;for(let d=0;d<=256;d++){let p=l+(u-l)*d/256;if(t_(h,p)){let{hi:f}=Xv(h,t_,c,p,1e-12),{sample:m,mercator:g}=ox(h,f);return new De(g.x,g.y,m.elevation)}c=p}return null}screenPointToLocation(t,i){return this.screenPointToMercatorCoordinate(t,i)?.toLngLat()}screenPointToLocationAtElevation(t,i){return this.screenPointToLocation(t)}isPointOnMapSurface(t,i){let r=this._cameraPosition;return!!Ts(r,this.getRayDirectionFromPixel(t))}getRayDirectionFromPixel(t){let i=Nr();i[0]=t.x/this.width*2-1,i[1]=(t.y/this.height*2-1)*-1,i[2]=1,i[3]=1,Pt(i,i,this._globeViewProjMatrixF64Inverted),i[0]/=i[3],i[1]/=i[3],i[2]/=i[3];let r=Pe();r[0]=i[0]-this._cameraPosition[0],r[1]=i[1]-this._cameraPosition[1],r[2]=i[2]-this._cameraPosition[2];let a=Pe();return Vt(a,r),a}isSurfacePointVisible(t){let i=this._cachedClippingPlane;return i[0]*t[0]+i[1]*t[1]+i[2]*t[2]+i[3]>=0}isSurfacePointOnScreen(t){if(!this.isSurfacePointVisible(t))return!1;let i=Nr();return Pt(i,[...t,1],this._globeViewProjMatrixF64),i[0]/=i[3],i[1]/=i[3],i[2]/=i[3],i[0]>-1&&i[0]<1&&i[1]>-1&&i[1]<1&&i[2]>-1&&i[2]<1}unprojectScreenPoint(t){let i=this._cameraPosition,r=this.getRayDirectionFromPixel(t),a=Ts(i,r);if(a){let h=Pe();yi(h,i,[r[0]*a.tMin,r[1]*a.tMin,r[2]*a.tMin]);let c=Pe();return Vt(c,h),Xn(c)}let n=this._cachedClippingPlane,o=n[0]*r[0]+n[1]*r[1]+n[2]*r[2],s=-Ih(n,i)/o,l=Pe();if(s>0)yi(l,i,[r[0]*s,r[1]*s,r[2]*s]);else{let h=Pe();yi(h,i,[r[0]*2,r[1]*2,r[2]*2]);let c=Ih(this._cachedClippingPlane,h);lr(l,h,[this._cachedClippingPlane[0]*c,this._cachedClippingPlane[1]*c,this._cachedClippingPlane[2]*c])}let u=tF(n);return Xn(iF(u.center,u.radius,l))}getProjectionDataForCustomLayer(t=!0){let i=this.getProjectionData({overscaledTileID:new Ct(0,0,0,0,0),applyGlobeMatrix:t});return i.tileMercatorCoords=[0,0,1,1],i}getFastPathSimpleProjectionMatrix(t){}};function ox(e,t){let i=Pe();qs(i,e.origin,e.direction,t);let r=Pi(i),a=Pe();Ue(a,i,1/r);let n=Xn(a),o=De.fromLngLat(n),s=new De(o.x,ie(o.y,0,.999999999)),l=Fo(e.index,e.exaggeration,s.x,s.y),u=Math.abs(n.lat)>85.051129?0:l.elevation;return{sample:{...l,elevation:u},radius:r,mercator:s}}function t_(e,t){let{sample:i,radius:r}=ox(e,t);return Mp(i,(r-1)*jt)}function i_(e,t){let i=mt(e);return Ue(i,i,1+t/jt)}function r_(e,t,i){return ut(gd(Pe(),i,e),t)}var a_=class sx{get pixelsToClipSpaceMatrix(){return this._helper.pixelsToClipSpaceMatrix}get clipSpaceToPixelsMatrix(){return this._helper.clipSpaceToPixelsMatrix}get pixelsToGLUnits(){return this._helper.pixelsToGLUnits}get centerOffset(){return this._helper.centerOffset}get size(){return this._helper.size}get rotationMatrix(){return this._helper.rotationMatrix}get centerPoint(){return this._helper.centerPoint}get pixelsPerMeter(){return this._helper.pixelsPerMeter}setMinZoom(t){this._helper.setMinZoom(t)}setMaxZoom(t){this._helper.setMaxZoom(t)}setMinPitch(t){this._helper.setMinPitch(t)}setMaxPitch(t){this._helper.setMaxPitch(t)}setRenderWorldCopies(t){this._helper.setRenderWorldCopies(t)}setBearing(t){this._helper.setBearing(t)}setPitch(t){this._helper.setPitch(t)}setRoll(t){this._helper.setRoll(t)}setFov(t){this._helper.setFov(t)}setZoom(t){this._helper.setZoom(t)}setCenter(t){this._helper.setCenter(t)}setElevation(t){this._helper.setElevation(t)}setMinElevationForCurrentTile(t){this._helper.setMinElevationForCurrentTile(t)}setPadding(t){this._helper.setPadding(t)}interpolatePadding(t,i,r){this._helper.interpolatePadding(t,i,r)}isPaddingEqual(t){return this._helper.isPaddingEqual(t)}resize(t,i,r=!0){this._helper.resize(t,i,r)}getMaxBounds(){return this._helper.getMaxBounds()}setMaxBounds(t){this._helper.setMaxBounds(t)}setConstrainOverride(t){this._helper.setConstrainOverride(t)}overrideNearFarZ(t,i){this._helper.overrideNearFarZ(t,i)}clearNearFarZOverride(){this._helper.clearNearFarZOverride()}getCameraQueryGeometry(t){return this._helper.getCameraQueryGeometry(this.getCameraPoint(),t)}get tileSize(){return this._helper.tileSize}get tileZoom(){return this._helper.tileZoom}get scale(){return this._helper.scale}get worldSize(){return this._helper.worldSize}get width(){return this._helper.width}get height(){return this._helper.height}get lngRange(){return this._helper.lngRange}get latRange(){return this._helper.latRange}get minZoom(){return this._helper.minZoom}get maxZoom(){return this._helper.maxZoom}get zoom(){return this._helper.zoom}get center(){return this._helper.center}get minPitch(){return this._helper.minPitch}get maxPitch(){return this._helper.maxPitch}get pitch(){return this._helper.pitch}get pitchInRadians(){return this._helper.pitchInRadians}get roll(){return this._helper.roll}get rollInRadians(){return this._helper.rollInRadians}get bearing(){return this._helper.bearing}get bearingInRadians(){return this._helper.bearingInRadians}get fov(){return this._helper.fov}get fovInRadians(){return this._helper.fovInRadians}get elevation(){return this._helper.elevation}get minElevationForCurrentTile(){return this._helper.minElevationForCurrentTile}get padding(){return this._helper.padding}get unmodified(){return this._helper.unmodified}get renderWorldCopies(){return this._helper.renderWorldCopies}get cameraToCenterDistance(){return this._helper.cameraToCenterDistance}get constrainOverride(){return this._helper.constrainOverride}get nearZ(){return this._helper.nearZ}get farZ(){return this._helper.farZ}get autoCalculateNearFarZ(){return this._helper.autoCalculateNearFarZ}get isGlobeRendering(){return this._globeness>0}setTransitionState(t){this._globeness=t,this._calcMatrices(),this._verticalPerspectiveTransform.getCoveringTilesDetailsProvider().prepareNextFrame(),this._mercatorTransform.getCoveringTilesDetailsProvider().prepareNextFrame()}get currentTransform(){return this.isGlobeRendering?this._verticalPerspectiveTransform:this._mercatorTransform}constructor(t){this._globeness=1,this.defaultConstrain=(i,r)=>this.currentTransform.defaultConstrain(i,r),this.applyConstrain=(i,r)=>this._helper.applyConstrain(i,r),this._helper=new Ip({calcMatrices:()=>this._calcMatrices(),defaultConstrain:(i,r)=>this.defaultConstrain(i,r)},t),this._globeness=1,this._mercatorTransform=new bl(void 0,this._helper),this._verticalPerspectiveTransform=new ax(void 0,this._helper)}clone(){let t=new sx;return t._globeness=this._globeness,t.apply(this,!1),t}apply(t,i){this._helper.apply(t,i)}get projectionMatrix(){return this.currentTransform.projectionMatrix}get modelViewProjectionMatrix(){return this.currentTransform.modelViewProjectionMatrix}get inverseProjectionMatrix(){return this.currentTransform.inverseProjectionMatrix}get cameraPosition(){return this.currentTransform.cameraPosition}getProjectionData(t){let i=this._mercatorTransform.getProjectionData(t),r=this._verticalPerspectiveTransform.getProjectionData(t);return{mainMatrix:this.isGlobeRendering?r.mainMatrix:i.mainMatrix,clippingPlane:r.clippingPlane,tileMercatorCoords:r.tileMercatorCoords,projectionTransition:t.applyGlobeMatrix?this._globeness:0,fallbackMatrix:i.fallbackMatrix,clipAntimeridian:r.clipAntimeridian}}isLocationOccluded(t,i,r){return this.currentTransform.isLocationOccluded(t,i,r)}transformLightDirection(t){return this.currentTransform.transformLightDirection(t)}getPixelScale(){return za(this._mercatorTransform.getPixelScale(),this._verticalPerspectiveTransform.getPixelScale(),this._globeness)}getCircleRadiusCorrection(){return za(this._mercatorTransform.getCircleRadiusCorrection(),this._verticalPerspectiveTransform.getCircleRadiusCorrection(),this._globeness)}getPitchedTextCorrection(t,i,r){return za(this._mercatorTransform.getPitchedTextCorrection(t,i,r),this._verticalPerspectiveTransform.getPitchedTextCorrection(t,i,r),this._globeness)}projectTileCoordinates(t,i,r,a){return this.currentTransform.projectTileCoordinates(t,i,r,a)}_calcMatrices(){this._helper._width&&this._helper._height&&(this._verticalPerspectiveTransform._calcMatrices(),this._mercatorTransform._calcMatrices(this.autoCalculateNearFarZ&&!this.isGlobeRendering))}calculateFogMatrix(t){return this.currentTransform.calculateFogMatrix(t)}getVisibleUnwrappedCoordinates(t){return this.currentTransform.getVisibleUnwrappedCoordinates(t)}getCameraFrustum(){return this.currentTransform.getCameraFrustum()}getClippingPlane(){return this.currentTransform.getClippingPlane()}getCoveringTilesDetailsProvider(){return this.currentTransform.getCoveringTilesDetailsProvider()}recalculateZoomAndCenter(t){this.currentTransform.recalculateZoomAndCenter(t)}maxPitchScaleFactor(){return this._mercatorTransform.maxPitchScaleFactor()}getCameraPoint(){return this._helper.getCameraPoint()}getCameraAltitude(){return this.currentTransform.getCameraAltitude()}getCameraLngLat(){return this.currentTransform.getCameraLngLat()}populateCache(t){this._mercatorTransform.populateCache(t),this._verticalPerspectiveTransform.populateCache(t)}getBounds(){return this.currentTransform.getBounds()}calculateCenterFromCameraLngLatAlt(t,i,r,a){return this._helper.calculateCenterFromCameraLngLatAlt(t,i,r,a)}calculateCameraOptionsFromTo(t,i,r,a){return this.currentTransform.calculateCameraOptionsFromTo(t,i,r,a)}setLocationAtPoint(t,i,r){this.currentTransform.setLocationAtPoint(t,i,r)}locationToScreenPoint(t,i){return this.currentTransform.locationToScreenPoint(t,i)}screenPointToMercatorCoordinate(t,i){return this.currentTransform.screenPointToMercatorCoordinate(t,i)}screenTerrainPointToMercatorCoordinate(t,i){return this.currentTransform.screenTerrainPointToMercatorCoordinate(t,i)}screenPointToLocation(t,i){return this.currentTransform.screenPointToLocation(t,i)}screenPointToLocationAtElevation(t,i){return this.currentTransform.screenPointToLocationAtElevation(t,i)}isPointOnMapSurface(t,i){return this.currentTransform.isPointOnMapSurface(t,i)}getRayDirectionFromPixel(t){return this._verticalPerspectiveTransform.getRayDirectionFromPixel(t)}getProjectionDataForCustomLayer(t=!0){let i=this._mercatorTransform.getProjectionDataForCustomLayer(t);if(!this.isGlobeRendering)return i;let r=this._verticalPerspectiveTransform.getProjectionDataForCustomLayer(t);return r.fallbackMatrix=i.mainMatrix,r.projectionTransition=this._globeness,r}getFastPathSimpleProjectionMatrix(t){return this.currentTransform.getFastPathSimpleProjectionMatrix(t)}},lx=class tr{get useGlobeControls(){return!0}handlePanInertia(t,i){let r=aF(t,i);return Math.abs(r.lng-i.center.lng)>180&&(r.lng=i.center.lng+179.5*Math.sign(r.lng-i.center.lng)),{easingCenter:r,easingOffset:new C(0,0)}}handleMapControlsRollPitchBearingZoom(t,i){let r=t.around,a=i.screenPointToLocation(r);t.bearingDelta&&i.setBearing(i.bearing+t.bearingDelta),t.pitchDelta&&i.setPitch(i.pitch+t.pitchDelta),t.rollDelta&&i.setRoll(i.roll+t.rollDelta);let n=i.zoom;t.zoomDelta&&i.setZoom(i.zoom+t.zoomDelta);let o=i.zoom-n;if(o===0)return;let s=qt(i.center.lng,a.lng),l=s/(Math.abs(s/180)+1),u=qt(i.center.lat,a.lat),h=i.getRayDirectionFromPixel(r),c=i.cameraPosition,d=ut(c,h)*-1,p=Pe();yi(p,c,[h[0]*d,h[1]*d,h[2]*d]);let f=Pi(p),m=f-1,g=Math.exp(-Math.max(m-.3,0)*.5),_=On(f,.95,.999,0,1),y=On(Xr(i.worldSize,i.center.lat)/Math.min(i.width,i.height),.9,.5,1,.25),v=Math.min(g,za(1,y,_)),x=(1-It(-o))*v,b=i.center.lat,w=i.zoom,T=new X(i.center.lng+l*x,ie(i.center.lat+u*x,-90,90));i.setLocationAtPoint(a,r);let E=i.center,S=On(Math.abs(s),45,85,0,1),M=Math.max(S,_)**.25,z=qt(E.lng,T.lng),R=qt(E.lat,T.lat);i.setCenter(new X(E.lng+z*M,ie(E.lat+R*M,-90,90)).wrap()),i.setZoom(w+yt(b,i.center.lat))}handleMapControlsPan(t,i,r){t.panDelta&&J3(i,r,i.isPointOnMapSurface(t.around)?t.around:i.centerPoint,t.panDelta)}cameraForBoxAndBearing(t,i,r,a,n,o){let s=Qv(t,i,r,a,n,o);if(!s)return;let l=i.left/o.width*2-1,u=(o.width-i.right)/o.width*2-1,h=i.top/o.height*-2+1,c=(o.height-i.bottom)/o.height*-2+1,d=qt(a.getWest(),a.getEast())<0,p=d?a.getEast():a.getWest(),f=d?a.getWest():a.getEast(),m=Math.max(a.getNorth(),a.getSouth()),g=Math.min(a.getNorth(),a.getSouth()),_=p+qt(p,f)*.5,y=m+qt(m,g)*.5,v=o.clone();v.setCenter(s.center),v.setPadding(r),v.setBearing(s.bearing),v.setPitch(0),v.setRoll(0),v.setZoom(s.zoom);let x=v.modelViewProjectionMatrix,b=[mt(a.getNorthWest()),mt(a.getNorthEast()),mt(a.getSouthWest()),mt(a.getSouthEast()),mt(new X(f,y)),mt(new X(p,y)),mt(new X(_,m)),mt(new X(_,g))],w=mt(s.center),T=1/0;for(let E of b)l<0&&(T=tr.getLesserNonNegativeNonNull(T,tr.solveVectorScale(E,w,x,"x",l))),u>0&&(T=tr.getLesserNonNegativeNonNull(T,tr.solveVectorScale(E,w,x,"x",u))),h>0&&(T=tr.getLesserNonNegativeNonNull(T,tr.solveVectorScale(E,w,x,"y",h))),c<0&&(T=tr.getLesserNonNegativeNonNull(T,tr.solveVectorScale(E,w,x,"y",c)));if(!Number.isFinite(T)||T===0){Kv();return}return s.zoom=Math.min(v.zoom+Mt(T),t.maxZoom),s}handleJumpToCenterZoom(t,i){let r=t.center.lat,a=i.center?X.convert(i.center):t.center;t.setCenter(t.applyConstrain(a,t.zoom).center.wrap());let n=i.zoom===void 0?t.zoom+yt(r,t.center.lat):+i.zoom;t.zoom!==n&&(t.setZoom(n),t.setCenter(t.applyConstrain(a,t.zoom).center.wrap()))}handleEaseTo(t,i){let r=t.zoom,a=t.center,n=t.padding,o={roll:t.roll,pitch:t.pitch,bearing:t.bearing},s={roll:i.roll===void 0?t.roll:i.roll,pitch:i.pitch===void 0?t.pitch:i.pitch,bearing:i.bearing===void 0?t.bearing:i.bearing},l=i.zoom!==void 0,u=!t.isPaddingEqual(i.padding),h=!1,c=i.center?X.convert(i.center):a,d=t.applyConstrain(c,l?+i.zoom:r).center;xl(t,d);let p=t.clone();p.setCenter(d),p.setZoom(l?+i.zoom:r+yt(a.lat,c.lat)),p.setBearing(i.bearing);let f=new C(ie(t.centerPoint.x+i.offsetAsPoint.x,0,t.width),ie(t.centerPoint.y+i.offsetAsPoint.y,0,t.height));p.setLocationAtPoint(d,f);let m=(i.offset&&i.offsetAsPoint.mag())>0?p.center:d,g=l?+i.zoom:r+yt(a.lat,m.lat),_=r+yt(a.lat,0),y=g+yt(m.lat,0),v=qt(a.lng,m.lng),x=qt(a.lat,m.lat),b=It(y-_);return h=g!==r,{easeFunc:w=>{if(U_(o,s)||Jv({startEulerAngles:o,endEulerAngles:s,tr:t,k:w,useSlerp:o.roll!=s.roll}),u&&t.interpolatePadding(n,i.padding,w),i.around)_e("Easing around a point is not supported under globe projection."),t.setLocationAtPoint(i.around,i.aroundPoint);else{let T=w*(y>_?Math.min(2,b):Math.max(.5,b))**(1-w),E=Jg(a,v,x,T);t.setCenter(E.wrap())}if(h){let T=He.number(_,y,w)+yt(0,t.center.lat);t.setZoom(T)}w===1&&!i.around&&t.setCenter(m.wrap())},isZooming:h,elevationCenter:m}}handleFlyTo(t,i){let r=i.zoom!==void 0,a=t.center,n=t.zoom,o=t.padding,s=!t.isPaddingEqual(i.padding),l=t.applyConstrain(X.convert(i.center||i.locationAtOffset),r?+i.zoom:n).center,u=r?+i.zoom:t.zoom+yt(t.center.lat,l.lat),h=t.clone();h.setCenter(l),h.setZoom(u),h.setBearing(i.bearing);let c=new C(ie(t.centerPoint.x+i.offsetAsPoint.x,0,t.width),ie(t.centerPoint.y+i.offsetAsPoint.y,0,t.height));h.setLocationAtPoint(l,c);let d=h.center;xl(t,d);let p=W3(t,a,d),f=n+yt(a.lat,0),m=u+yt(d.lat,0),g=It(m-f),_=typeof i.minZoom=="number"?+i.minZoom:t.minZoom,y=Math.max(_,t.minZoom)+yt(d.lat,0),v=Math.min(y,f,m)+yt(0,d.lat),x=It(t.applyConstrain(d,v).zoom+yt(d.lat,0)-f),b=qt(a.lng,d.lng),w=qt(a.lat,d.lat);return{easeFunc:(T,E,S,M)=>{let z=Jg(a,b,w,S);s&&t.interpolatePadding(o,i.padding,T);let R=T===1?d:z;t.setCenter(R.wrap());let I=f+Mt(E);t.setZoom(T===1?u:I+yt(0,R.lat)),T===1&&t.setCenter(d.wrap())},scaleOfZoom:g,targetCenter:d,scaleOfMinZoom:x,pixelPathLength:p}}static solveVectorScale(t,i,r,a,n){let o=n,s=a==="x"?[r[0],r[4],r[8],r[12]]:[r[1],r[5],r[9],r[13]],l=[r[3],r[7],r[11],r[15]],u=t[0]*s[0]+t[1]*s[1]+t[2]*s[2],h=t[0]*l[0]+t[1]*l[1]+t[2]*l[2],c=i[0]*s[0]+i[1]*s[1]+i[2]*s[2],d=i[0]*l[0]+i[1]*l[1]+i[2]*l[2],p=(c+s[3]-o*d-o*l[3])/(c-u-o*d+o*h);return c+o*h===u+o*d||l[3]*(u-c)+s[3]*(d-h)+u*d===c*h?null:p}static getLesserNonNegativeNonNull(t,i){return i!==null&&i>=0&&i<t?i:t}},n_=class{constructor(e){this._globe=e,this._mercatorCameraHelper=new wl,this._verticalPerspectiveCameraHelper=new lx}get useGlobeControls(){return this._globe.useGlobeRendering}get currentHelper(){return this.useGlobeControls?this._verticalPerspectiveCameraHelper:this._mercatorCameraHelper}handlePanInertia(e,t){return this.currentHelper.handlePanInertia(e,t)}handleMapControlsRollPitchBearingZoom(e,t){this.currentHelper.handleMapControlsRollPitchBearingZoom(e,t)}handleMapControlsPan(e,t,i){this.currentHelper.handleMapControlsPan(e,t,i)}cameraForBoxAndBearing(e,t,i,r,a,n){return this.currentHelper.cameraForBoxAndBearing(e,t,i,r,a,n)}handleJumpToCenterZoom(e,t){this.currentHelper.handleJumpToCenterZoom(e,t)}handleEaseTo(e,t){return this.currentHelper.handleEaseTo(e,t)}handleFlyTo(e,t){return this.currentHelper.handleFlyTo(e,t)}};function sF(e,t,i){let r={constrainOverride:t};if(Array.isArray(e)){let a=new Yg({type:e},i);return{projection:a,transform:new a_(r),cameraHelper:new n_(a)}}switch(e){case"mercator":return{projection:new rd,transform:new bl(r),cameraHelper:new wl};case"globe":{let a=new Yg({type:["interpolate",["linear"],["zoom"],11,"vertical-perspective",12,"mercator"]},{});return{projection:a,transform:new a_(r),cameraHelper:new n_(a)}}case"vertical-perspective":return{projection:new ex,transform:new ax(r),cameraHelper:new lx};default:return _e(`Unknown projection name: ${e}. Falling back to mercator projection.`),{projection:new rd,transform:new bl(r),cameraHelper:new wl}}}var lF=uT(),od=class extends ht{constructor(e,t={}){super(),this._rtlPluginLoaded=()=>{for(let r in this.tileManagers){let a=this.tileManagers[r].getSource().type;(a==="vector"||a==="geojson")&&this.tileManagers[r].reload()}},this.map=e,this.dispatcher=new $1(ap(),e._getMapId()).setEventedParent(this),this.dispatcher.registerMessageHandler("GG",(r,a)=>this.getGlyphs(r,a)),this.dispatcher.registerMessageHandler("GI",(r,a)=>this.getImages(r,a)),this.dispatcher.registerMessageHandler("GDA",(r,a)=>this.getDashes(r,a)),this.imageManager=new QC,this.imageManager.setEventedParent(this),this.imageManager.setMissingImageResolver(e._missingStyleImageResolver),this.patternAtlas=new eP(this.imageManager);let i=e._container?.lang||typeof document<"u"&&document.documentElement?.lang||void 0;this.glyphManager=new uP(e._requestManager,t.localIdeographFontFamily,i),this.lineAtlas=new mP(256,512),this.crossTileSymbolIndex=new k3,this._setInitialValues(),this._resetUpdates(),this.dispatcher.broadcast("SR",bd()),_o().on(Kc,this._rtlPluginLoaded),this.on("data",r=>{if(r.dataType!=="source"||r.sourceDataType!=="metadata")return;let a=this.tileManagers[r.sourceId];if(!a)return;let n=a.getSource();if(n?.vectorLayerIds)for(let o in this._layers){let s=this._layers[o];s.source===n.id&&this._validateLayer(s)}})}_setInitialValues(){this._layers={},this._order=[],this.tileManagers={},this.zoomHistory=new Hh,this._imagesListDirty=!1,this._globalState={},this._serializedLayers={},this.stylesheet=null,this.light=null,this.sky=null,this.projection&&(this.projection.destroy(),delete this.projection),this._loaded=!1,this._changed=!1,this._updatedLayers={},this._updatedSources={},this._changedImages={},this._glyphsDidChange=!1,this._updatedPaintProps={},this._layerOrderChanged=!1,this._symbolPlacementTriggered=!1,this._placedProjectionTransition=void 0,this.crossTileSymbolIndex=new(this.crossTileSymbolIndex?.constructor||Object),this.pauseablePlacement=void 0,this.placement=void 0,this.z=0}setGlobalStateProperty(e,t){this._checkLoaded();let i=t===null?this.stylesheet.state?.[e]?.default??null:t;return this._setGlobalStateValues({[e]:i}),this}getGlobalState(){return this._globalState}setGlobalState(e){this._checkLoaded();let t={};for(let i in e)t[i]=e[i].default;this._setGlobalStateValues(t)}_setGlobalStateValues(e){let t=[];for(let r in e)Vi(e[r],this._globalState[r])||t.push(r);if(t.length===0)return;let i={...this._globalState};for(let r of t)this._globalState[r]=e[r];this._applyGlobalStateChanges(t,i)}_applyGlobalStateChanges(e,t){let i=new Set,r={};for(let n of e)r[n]=this._globalState[n];for(let n in this._layers){let o=this._layers[n];o.retainPriorGlobalState(e,t);let s=o.getLayoutAffectingGlobalStateRefs(),l=o.getPaintAffectingGlobalStateRefs(),u=o.getVisibilityAffectingGlobalStateRefs();for(let h of e){if(s.has(h)&&i.add(o.source),l.has(h))for(let{name:c,value:d}of l.get(h))this._updatePaintProperty(o,c,d,{validate:!1});u?.has(h)&&(o.recalculateVisibility(),this._updateLayer(o))}}let a={now:Ie(),transition:this.getTransition()};this.light?.applyGlobalStateChange(e,t,a),this.sky?.applyGlobalStateChange(e,t,a),this.dispatcher.broadcast("UGS",r);for(let n in this.tileManagers)i.has(n)&&(this._reloadSource(n),this._changed=!0)}async loadURL(e,t={},i){this.fire(new _i("dataloading")),t.validate=typeof t.validate!="boolean"||t.validate,this._loadStyleRequest=new AbortController;let r=this._loadStyleRequest;try{let a=await this.map._requestManager.transformRequest(e,"Style");xd(r.signal);let n=await Sl(a,r);this._loadStyleRequest===r&&(this._loadStyleRequest=null),this._load(n.data,t,i)}catch(a){this._loadStyleRequest===r&&(this._loadStyleRequest=null),a&&!r.signal.aborted&&this.fire(new Y(bt(a)))}}loadJSON(e,t={},i){this.fire(new _i("dataloading")),this._frameRequest=new AbortController,Kt.frameAsync(this._frameRequest,this.map._ownerWindow).then(()=>{this._frameRequest=null,t.validate=t.validate!==!1,this._load(e,t,i)}).catch(()=>{})}loadEmpty(){this.fire(new _i("dataloading")),this._load(lF,{validate:!1})}_load(e,t,i){let r=t.transformStyle?t.transformStyle(i,e):e;if(!(t.validate&&Yf(this,r))){r={...r},this._loaded=!0,this.stylesheet=r;for(let a in r.sources)this.addSource(a,r.sources[a],{validate:!1});r.sprite?this._loadSprite(r.sprite):this.imageManager.setLoaded(!0),this.glyphManager.setURL(r.glyphs),this.glyphManager.setFontFaces(r["font-faces"]),this._createLayers(),this.light=new cP(this.stylesheet.light??{},this._globalState),this._setProjectionInternal(this.stylesheet.projection?.type||"mercator"),this.sky=new pP(this.stylesheet.sky,this._globalState),this.sky.setEventedParent(this),this.map.setTerrain(this.stylesheet.terrain??null,{validate:!1}),this.fire(new _i("data")),this.fire(new zh)}}_createLayers(){let e=Cf(this.stylesheet.layers);this.setGlobalState(this.stylesheet.state??null),this.dispatcher.broadcast("SL",e),this._order=e.map(t=>t.id),this._layers={},this._serializedLayers=null;for(let t of e){let i=ih(t,this._globalState);if(i.setEventedParent(this,{layer:{id:t.id}}),this._layers[t.id]=i,Yh(i)&&this.tileManagers[i.source]){let r=t.paint?.["raster-fade-duration"]??i.paint.get("raster-fade-duration");this.tileManagers[i.source].setRasterFadeDuration(r)}}}async _loadSprite(e,t=!1,i=void 0){this.imageManager.setLoaded(!1);let r=new AbortController;this._spriteRequest=r;let a;try{let n=await KC(e,this.map._requestManager,this.map.getPixelRatio(),r);if(!n)return;for(let o in n){let{loaded:s,removed:l}=this.imageManager.setSpriteImages(o,n[o]);this._markImagesChanged(l),t&&this._markImagesChanged(s)}}catch(n){a=n,r.signal.aborted||this.fire(new Y(a))}finally{this._spriteRequest=null,this.imageManager.setLoaded(!0),t&&(this._changed=!0),this.dispatcher.broadcast("SI",this.imageManager.listImages()),this.fire(new _i("data")),i?.(a)}}_unloadSprite(){this._markImagesChanged(this.imageManager.removeAllSpriteImages()),this._imagesListDirty=!0,this._changed=!0,this.fire(new _i("data"))}_validateLayer(e){let t=this.tileManagers[e.source];if(!t)return;let i=e.sourceLayer;if(!i)return;let r=t.getSource();(r.type==="geojson"||r.vectorLayerIds&&!r.vectorLayerIds.includes(i))&&this.fire(new Y(Error(`Source layer "${i}" does not exist on source "${r.id}" as specified by style layer "${e.id}".`)))}loaded(){if(!this._loaded||Object.keys(this._updatedSources).length)return!1;for(let e in this.tileManagers)if(!this.tileManagers[e].loaded())return!1;return this.imageManager.isLoaded()}_serializeByIds(e,t=!1){let i=this._serializedAllLayers();if(!e||e.length===0)return Object.values(t?Ht(i):i);let r=[];for(let a of e)if(i[a]){let n=t?Ht(i[a]):i[a];r.push(n)}return r}_serializedAllLayers(){let e=this._serializedLayers;if(e)return e;e=this._serializedLayers={};let t=Object.keys(this._layers);for(let i of t){let r=this._layers[i];r.type!=="custom"&&(e[i]=r.serialize())}return e}hasTransitions(){if(this.light?.hasTransition()||this.sky?.hasTransition()||this.projection?.hasTransition())return!0;for(let e in this.tileManagers)if(this.tileManagers[e].hasTransition())return!0;for(let e in this._layers)if(this._layers[e].hasTransition())return!0;return!1}_checkLoaded(){if(!this._loaded)throw Error("Style is not done loading.")}update(e){if(!this._loaded)return;let t=this._changed;if(t){this._imagesListDirty&&(this._imagesListDirty=(this.dispatcher.broadcast("SI",this.imageManager.listImages()),!1));let a=Object.keys(this._updatedLayers),n=Object.keys(this._removedLayers);(a.length||n.length)&&this._updateWorkerLayers(a,n);for(let o in this._updatedSources){let s=this._updatedSources[o];if(s==="reload")this._reloadSource(o);else if(s==="clear")this._clearSource(o);else throw Error(`Invalid action ${s}`)}this._updateTilesForChangedImages(),this._updateTilesForChangedGlyphs();for(let o in this._updatedPaintProps)this._layers[o].updateTransitions(e);this._resetUpdates()}let i={};for(let a in this.tileManagers){let n=this.tileManagers[a];i[a]=n.used,n.used=!1}let r=this.imageManager.listImages();for(let a of this._order){let n=this._layers[a];n.recalculate(e,r),!n.isHidden(e.zoom)&&n.source&&(this.tileManagers[n.source].used=!0)}for(let a in i){let n=this.tileManagers[a];!!i[a]!=!!n.used&&n.fire(new Ne("data",{sourceDataType:"visibility",sourceId:a}))}this.light.recalculate(e),this.sky.recalculate(e),this.projection.recalculate(e),this.z=e.zoom,t&&this.fire(new _i("data"))}_updateTilesForChangedImages(){let e=Object.keys(this._changedImages);if(e.length){for(let t in this.tileManagers)this.tileManagers[t].reloadTilesForDependencies(["icons","patterns"],e);this._changedImages={}}}_updateTilesForChangedGlyphs(){if(this._glyphsDidChange){for(let e in this.tileManagers)this.tileManagers[e].reloadTilesForDependencies(["glyphs"],[""]);this._glyphsDidChange=!1}}_updateWorkerLayers(e,t){this.dispatcher.broadcast("UL",{layers:this._serializeByIds(e,!1),removedIds:t})}resize(){for(let e of this._order)this._layers[e].resize()}_resetUpdates(){this._changed=!1,this._updatedLayers={},this._removedLayers={},this._updatedSources={},this._updatedPaintProps={},this._changedImages={},this._glyphsDidChange=!1}setState(e,t={}){this._checkLoaded();let i=this.serialize();if(e=t.transformStyle?t.transformStyle(i,e):e,(t.validate??!0)&&Yf(this,e))return!1;e=Ht(e),e.layers=Cf(e.layers);let r=Iw(i,e),a=this._getOperationsToPerform(r);if(a.unimplemented.length>0)throw Error(`Unimplemented: ${a.unimplemented.join(", ")}.`);if(a.operations.length===0)return!1;for(let n of a.operations)n();return this.stylesheet=e,this._serializedLayers=null,this.fire(new zh({style:this})),!0}_getOperationsToPerform(e){let t=[],i=[];for(let r of e)switch(r.command){case"setCenter":case"setZoom":case"setBearing":case"setPitch":case"setRoll":continue;case"addLayer":{let[a,n]=r.args;t.push(()=>this.addLayer(a,n));break}case"removeLayer":{let[a]=r.args;t.push(()=>this.removeLayer(a));break}case"setPaintProperty":{let[a,n,o]=r.args;t.push(()=>this.setPaintProperty(a,n,o));break}case"setLayoutProperty":{let[a,n,o]=r.args;t.push(()=>this.setLayoutProperty(a,n,o));break}case"setFilter":{let[a,n]=r.args;t.push(()=>this.setFilter(a,n));break}case"addSource":{let[a,n]=r.args;t.push(()=>this.addSource(a,n));break}case"removeSource":{let[a]=r.args;t.push(()=>this.removeSource(a));break}case"setLayerZoomRange":{let[a,n,o]=r.args;t.push(()=>this.setLayerZoomRange(a,n,o));break}case"setLight":{let[a]=r.args;t.push(()=>this.setLight(a));break}case"setGeoJSONSourceData":{let[a,n]=r.args;t.push(()=>this.setGeoJSONSourceData(a,n));break}case"setGlyphs":{let[a]=r.args;t.push(()=>this.setGlyphs(a));break}case"setFontFaces":{let[a]=r.args;t.push(()=>this.setFontFaces(a));break}case"setSprite":{let[a]=r.args;t.push(()=>this.setSprite(a));break}case"setTerrain":{let[a]=r.args;t.push(()=>this.map.setTerrain(a));break}case"setSky":{let[a]=r.args;t.push(()=>this.setSky(a));break}case"setProjection":{let[a]=r.args;t.push(()=>this.setProjection(a));break}case"setGlobalState":{let[a]=r.args;t.push(()=>this.setGlobalState(a));break}case"setTransition":t.push(()=>{});break;default:i.push(r.command)}return{operations:t,unimplemented:i}}addImage(e,t){if(this.getImage(e)){this.fire(new Y(Error(`An image named "${e}" already exists.`)));return}this.imageManager.addImage(e,t),this._afterImageUpdated(e)}updateImage(e,t){this.imageManager.updateImage(e,t)}getImage(e){return this.imageManager.getImage(e)}setMissingImageResolver(e){this.imageManager.setMissingImageResolver(e)}removeImage(e){if(!this.getImage(e)){this.fire(new Y(Error(`An image named "${e}" does not exist.`)));return}this.imageManager.removeImage(e),this._afterImageUpdated(e)}_markImagesChanged(e){for(let t of e)this._changedImages[t]=!0}_afterImageUpdated(e){this._changedImages[e]=!0,this._imagesListDirty=!0,this._changed=!0,this.fire(new _i("data"))}listImages(){return this._checkLoaded(),this.imageManager.listImages()}addSource(e,t,i={}){if(this._checkLoaded(),this.tileManagers[e]!==void 0)throw Error(`Source "${e}" already exists.`);if(!t.type)throw Error(`The type property must be defined, but only the following properties were given: ${Object.keys(t).join(", ")}.`);if(v0.has(t.type)&&this._validate(Wt.source,`sources.${e}`,t,null,i))return;this.map?._collectResourceTiming&&(t.collectResourceTiming=!0);let r=this.tileManagers[e]=new Qc(e,t,this.dispatcher);r.style=this,r.setEventedParent(this,()=>({isSourceLoaded:r.loaded(),source:r.serialize(),sourceId:e})),r.onAdd(this.map),this._changed=!0}removeSource(e){if(this._checkLoaded(),this.tileManagers[e]===void 0)throw Error(`There is no source with this ID=${e}`);for(let i in this._layers)if(this._layers[i].source===e)return this.fire(new Y(Error(`Source "${e}" cannot be removed while layer "${i}" is using it.`)));let t=this.tileManagers[e];delete this.tileManagers[e],delete this._updatedSources[e],t.fire(new Ne("data",{sourceDataType:"metadata",sourceId:e})),t.setEventedParent(null),t.onRemove(this.map),this._changed=!0}setGeoJSONSourceData(e,t){if(this._checkLoaded(),this.tileManagers[e]===void 0)throw Error(`There is no source with this ID=${e}`);let i=this.tileManagers[e].getSource();if(i.type!=="geojson")throw Error(`geojsonSource.type is ${i.type}, which is !== 'geojson`);i.setData(t),this._changed=!0}getSource(e){return this.tileManagers[e]?.getSource()}addLayer(e,t,i={}){this._checkLoaded();let r=e.id;if(this.getLayer(r)){this.fire(new Y(Error(`Layer "${r}" already exists on this map.`)));return}let a;if(e.type==="custom"){if(Vd(this,XC(e)))return;a=ih(e,this._globalState)}else{if("source"in e&&typeof e.source=="object"&&(this.addSource(r,e.source),e=Ht(e),e=q(e,{source:r})),this._validate(Wt.layer,`layers.${r}`,e,{arrayIndex:-1},i))return;a=ih(e,this._globalState),this._validateLayer(a),a.setEventedParent(this,{layer:{id:r}})}let n=t?this._order.indexOf(t):this._order.length;if(t&&n===-1){this.fire(new Y(Error(`Cannot add layer "${r}" before non-existing layer "${t}".`)));return}if(this._order.splice(n,0,r),this._layerOrderChanged=!0,this._layers[r]=a,this._removedLayers[r]&&a.source&&a.type!=="custom"){let o=this._removedLayers[r];delete this._removedLayers[r],o.type===a.type?(this._updatedSources[a.source]="reload",this.tileManagers[a.source].pause()):this._updatedSources[a.source]="clear"}this._updateLayer(a),a.onAdd&&a.onAdd(this.map)}moveLayer(e,t){if(this._checkLoaded(),this._changed=!0,!this._layers[e]){this.fire(new Y(Error(`The layer '${e}' does not exist in the map's style and cannot be moved.`)));return}if(e===t)return;if(t&&!this._order.includes(t)){this.fire(new Y(Error(`Cannot move layer "${e}" before non-existing layer "${t}".`)));return}let i=this._order.indexOf(e);this._order.splice(i,1);let r=t?this._order.indexOf(t):this._order.length;this._order.splice(r,0,e),this._layerOrderChanged=!0}removeLayer(e){this._checkLoaded();let t=this._layers[e];if(!t){this.fire(new Y(Error(`Cannot remove non-existing layer "${e}".`)));return}t.setEventedParent(null);let i=this._order.indexOf(e);this._order.splice(i,1),this._layerOrderChanged=!0,this._changed=!0,this._removedLayers[e]=t,delete this._layers[e],this._serializedLayers&&delete this._serializedLayers[e],delete this._updatedLayers[e],delete this._updatedPaintProps[e],t.type==="symbol"&&t.source&&this.tileManagers[t.source]?.resetMaxContentElevation(),t.onRemove&&t.onRemove(this.map)}getLayer(e){return this._layers[e]}getLayersOrder(){return[...this._order]}hasLayer(e){return e in this._layers}setLayerZoomRange(e,t,i){this._checkLoaded();let r=this.getLayer(e);if(!r){this.fire(new Y(Error(`Cannot set the zoom range of non-existing layer "${e}".`)));return}(r.minzoom!==t||r.maxzoom!==i)&&(t!=null&&(r.minzoom=t),i!=null&&(r.maxzoom=i),this._updateLayer(r))}setFilter(e,t,i={}){this._checkLoaded();let r=this.getLayer(e);if(!r){this.fire(new Y(Error(`Cannot filter non-existing layer "${e}".`)));return}if(!Vi(r.filter,t)){if(t==null){r.setFilter(void 0),this._updateLayer(r);return}this._validate(Wt.filter,`layers.${r.id}.filter`,t,null,i)||(r.setFilter(Ht(t)),this._updateLayer(r))}}getFilter(e){return Ht(this.getLayer(e).filter)}setLayoutProperty(e,t,i,r={}){this._checkLoaded();let a=this.getLayer(e);if(!a){this.fire(new Y(Error(`Cannot style non-existing layer "${e}".`)));return}Vi(a.getLayoutProperty(t),i)||(a.setLayoutProperty(t,i,r),this._updateLayer(a))}getLayoutProperty(e,t){let i=this.getLayer(e);if(!i){this.fire(new Y(Error(`Cannot get style of non-existing layer "${e}".`)));return}return i.getLayoutProperty(t)}setPaintProperty(e,t,i,r={}){this._checkLoaded();let a=this.getLayer(e);if(!a){this.fire(new Y(Error(`Cannot style non-existing layer "${e}".`)));return}Vi(a.getPaintProperty(t),i)||this._updatePaintProperty(a,t,i,r)}_updatePaintProperty(e,t,i,r={}){e.setPaintProperty(t,i,r)&&this._updateLayer(e),Yh(e)&&t==="raster-fade-duration"&&this.tileManagers[e.source].setRasterFadeDuration(i),this._changed=!0,this._updatedPaintProps[e.id]=!0,e.type==="symbol"&&this.triggerSymbolPlacement(),this._serializedLayers=null}getPaintProperty(e,t){return this.getLayer(e).getPaintProperty(t)}setFeatureState(e,t){this._checkLoaded();let i=e.source,r=e.sourceLayer,a=this.tileManagers[i];if(a===void 0){this.fire(new Y(Error(`The source '${i}' does not exist in the map's style.`)));return}let n=a.getSource().type;if(n==="geojson"&&r){this.fire(new Y(Error("GeoJSON sources cannot have a sourceLayer parameter.")));return}if(n==="vector"&&!r){this.fire(new Y(Error("The sourceLayer parameter must be provided for vector source types.")));return}if(e.id===void 0){this.fire(new Y(Error("The feature id parameter must be provided.")));return}let o=["__proto__","constructor","prototype"];if(t&&Object.keys(t).some(s=>o.includes(s))){this.fire(new Y(Error(`The feature state should not include one of the following keys: ${o}`)));return}a.setFeatureState(r,e.id,t)}removeFeatureState(e,t){this._checkLoaded();let i=e.source,r=this.tileManagers[i];if(r===void 0){this.fire(new Y(Error(`The source '${i}' does not exist in the map's style.`)));return}let a=r.getSource().type,n=a==="vector"?e.sourceLayer:void 0;if(a==="vector"&&!n){this.fire(new Y(Error("The sourceLayer parameter must be provided for vector source types.")));return}if(t&&typeof e.id!="string"&&typeof e.id!="number"){this.fire(new Y(Error("A feature id is required to remove its specific state property.")));return}r.removeFeatureState(n,e.id,t)}getFeatureState(e){this._checkLoaded();let t=e.source,i=e.sourceLayer,r=this.tileManagers[t];if(r===void 0){this.fire(new Y(Error(`The source '${t}' does not exist in the map's style.`)));return}if(r.getSource().type==="vector"&&!i){this.fire(new Y(Error("The sourceLayer parameter must be provided for vector source types.")));return}return e.id===void 0&&this.fire(new Y(Error("The feature id parameter must be provided."))),r.getFeatureState(i,e.id)}getTransition(){return q({duration:300,delay:0},this.stylesheet?.transition)}serialize(){if(!this._loaded)return;let e=vd(this.tileManagers,a=>a.serialize()),t=this._serializeByIds(this._order,!0),i=this.map.getTerrain()||void 0,r=this.stylesheet;return V_({version:r.version,name:r.name,metadata:r.metadata,light:r.light,sky:r.sky,center:r.center,zoom:r.zoom,bearing:r.bearing,pitch:r.pitch,sprite:r.sprite,glyphs:r.glyphs,"font-faces":r["font-faces"],transition:r.transition,projection:r.projection,state:r.state,sources:e,layers:t,terrain:i},a=>a!==void 0)}_updateLayer(e){this._updatedLayers[e.id]=!0,e.source&&!this._updatedSources[e.source]&&this.tileManagers[e.source].getSource().type!=="raster"&&(this._updatedSources[e.source]="reload",this.tileManagers[e.source].pause()),this._serializedLayers=null,this._changed=!0}_flattenAndSortRenderedFeatures(e){let t=n=>this._layers[n].type==="fill-extrusion",i={},r=[];for(let n=this._order.length-1;n>=0;n--){let o=this._order[n];if(t(o)){i[o]=n;for(let s of e){let l=s[o];if(l)for(let u of l)r.push(u)}}}r.sort((n,o)=>o.intersectionZ-n.intersectionZ);let a=[];for(let n=this._order.length-1;n>=0;n--){let o=this._order[n];if(t(o))for(let s=r.length-1;s>=0;s--){let l=r[s].feature;if(i[l.layer.id]<n)break;a.push(l),r.pop()}else for(let s of e){let l=s[o];if(l)for(let u of l)a.push(u.feature)}}return a}queryRenderedFeatures(e,t,i){t?.filter&&this._validate(Wt.filter,"queryRenderedFeatures.filter",t.filter,null,t);let r={};if(t?.layers){if(!(Array.isArray(t.layers)||t.layers instanceof Set))return this.fire(new Y(Error("parameters.layers must be an Array or a Set of strings"))),[];for(let l of t.layers){let u=this._layers[l];if(!u)return this.fire(new Y(Error(`The layer '${l}' does not exist in the map's style and cannot be queried for features.`))),[];r[u.source]=!0}}let a=[];t.availableImages=this.imageManager.listImages();let n=this._serializedAllLayers(),o=t.layers instanceof Set?t.layers:Array.isArray(t.layers)?new Set(t.layers):null,s={...t,layers:o,globalState:this._globalState};for(let l in this.tileManagers)(!t.layers||r[l])&&a.push(IP(this.tileManagers[l],this._layers,n,e,s,i,this.map.terrain?(u,h,c)=>this.map.terrain.getElevation(u,h,c):void 0));return this.placement&&a.push(MP(this._layers,n,this.tileManagers,e,s,this.placement.collisionIndex,this.placement.retainedQueryData)),this._flattenAndSortRenderedFeatures(a)}querySourceFeatures(e,t){t?.filter&&this._validate(Wt.filter,"querySourceFeatures.filter",t.filter,null,t);let i=this.tileManagers[e];return i?FP(i,t?{...t,globalState:this._globalState}:{globalState:this._globalState}):[]}getLight(){return this.light.getLight()}setLight(e,t={}){this._checkLoaded();let i=this.light.getLight(),r=!1;for(let n in e)if(!Vi(e[n],i[n])){r=!0;break}if(!r)return;let a={now:Ie(),transition:q({duration:300,delay:0},this.stylesheet.transition)};this.light.setLight(e,t),this.light.updateTransitions(a)}getProjection(){return this.stylesheet?.projection}setProjection(e){this._checkLoaded();let t=e??{type:"mercator"};if(this.stylesheet.projection=e,this.projection){if(this.projection.name===t.type)return;this.projection.destroy(),delete this.projection}this._setProjectionInternal(t.type)}getSky(){return this.stylesheet?.sky}setSky(e,t={}){this._checkLoaded();let i=this.getSky(),r=!1;if(!e&&!i)return;if(e&&!i)r=!0;else if(!e&&i)r=!0;else for(let n in e)if(!Vi(e[n],i[n])){r=!0;break}if(!r)return;let a={now:Ie(),transition:q({duration:300,delay:0},this.stylesheet.transition)};this.sky.setSky(e,t)&&(this.stylesheet.sky=e,this.sky.updateTransitions(a))}_setProjectionInternal(e){let t=sF(e,this.map._camera?.transform.constrainOverride,this._globalState);this.projection=t.projection,this.map.migrateProjection(t.transform,t.cameraHelper);for(let i in this.tileManagers)this.tileManagers[i].reload()}_validate(e,t,i,r,a={}){return a.validate!==!1&&So(this,e,{key:t,style:this.serialize(),value:i,...r},a)}_remove(e=!0){this._frameRequest&&(this._frameRequest=(this._frameRequest.abort(),null)),this._loadStyleRequest&&(this._loadStyleRequest=(this._loadStyleRequest.abort(),null)),this._spriteRequest&&(this._spriteRequest=(this._spriteRequest.abort(),null)),_o().off(Kc,this._rtlPluginLoaded);for(let t in this._layers)this._layers[t].setEventedParent(null);for(let t in this.tileManagers){let i=this.tileManagers[t];i.setEventedParent(null),i.onRemove(this.map)}this.imageManager.setEventedParent(null),this.setEventedParent(null),e&&this.dispatcher.broadcast("RM",void 0),this.dispatcher.remove(e)}_clearSource(e){this.tileManagers[e].clearTiles()}_reloadSource(e){this.tileManagers[e].resume(),this.tileManagers[e].reload()}_updateSources(e){for(let t in this.tileManagers)this.tileManagers[t].update(e,this.map.terrain)}_generateCollisionBoxes(){for(let e in this.tileManagers)this._reloadSource(e)}triggerSymbolPlacement(){this._symbolPlacementTriggered=!0}_placementInputsChanged(e,t,i){let r=this.pauseablePlacement;return!r||this._symbolPlacementTriggered||this._placedProjectionTransition!==this.projection?.transitionState||r._showCollisionBoxes!==t||r.placement.collisionGroups.crossSourceCollisions!==i||r.placement.transform.renderWorldCopies!==e.renderWorldCopies||!Sb(r.placement.transform.modelViewProjectionMatrix,e.modelViewProjectionMatrix)}_updatePlacement(e,t,i,r,a=!1){let n=!1,o=!1,s={};for(let h of this._order){let c=this._layers[h];if(c.type!=="symbol")continue;if(!s[c.source]){let p=this.tileManagers[c.source];s[c.source]=p.getRenderableIds(!0).map(f=>p.getTileByID(f)).sort((f,m)=>m.tileID.overscaledZ-f.tileID.overscaledZ||(f.tileID.isLessThan(m.tileID)?-1:1))}let d=this.crossTileSymbolIndex.addLayer(c,s[c.source],e.center.lng);n||(n=d)}this.crossTileSymbolIndex.pruneUnusedLayers(this._order),a||(a=this._layerOrderChanged||i===0);let l=n||this._placementInputsChanged(e,t,r),u=this.pauseablePlacement?.isDone()&&!this.placement.stillRecent(Ie(),e.zoom);if((a||!this.pauseablePlacement||u&&(l||this.placement.stale))&&(this._symbolPlacementTriggered=!1,this._placedProjectionTransition=this.projection?.transitionState,this.pauseablePlacement=new I3(e,this.map.terrain,this._order,a,t,i,r,this.placement),this._layerOrderChanged=!1),this.pauseablePlacement.isDone()?l&&this.placement.setStale():(this.pauseablePlacement.continuePlacement(this._order,this._layers,s),this.pauseablePlacement.isDone()&&(this.placement=this.pauseablePlacement.commit(Ie()),o=!0),n&&this.pauseablePlacement.placement.setStale()),o||n)for(let h of this._order){let c=this._layers[h];c.type==="symbol"&&this.placement.updateLayerOpacities(c,s[c.source])}return!this.pauseablePlacement.isDone()||this.placement.hasTransitions(Ie())}_releaseSymbolFadeTiles(){for(let e in this.tileManagers)this.tileManagers[e].releaseSymbolFadeTiles()}async getImages(e,t){let i=await this.imageManager.getImages(t.icons);this._updateTilesForChangedImages();let r=this.tileManagers[t.source];return r&&r.setDependencies(t.tileID.key,t.type,t.icons),i}async getGlyphs(e,t){let i=await this.glyphManager.getGlyphs(t.stacks),r=this.tileManagers[t.source];return r&&r.setDependencies(t.tileID.key,t.type,[""]),i}getGlyphsUrl(){return this.stylesheet.glyphs||null}setGlyphs(e,t={}){this._checkLoaded(),!(e&&this._validate(Wt.glyphs,"glyphs",e,null,t))&&(this._changed=!0,this._glyphsDidChange=!0,this.stylesheet.glyphs=e,this.glyphManager.entries={},this.glyphManager.setURL(e))}getFontFaces(){return this.stylesheet["font-faces"]||null}setFontFaces(e){this._checkLoaded(),this._changed=!0,this._glyphsDidChange=!0,this.stylesheet["font-faces"]=e,this.glyphManager.setFontFaces(e)}async getDashes(e,t){let i={};for(let[r,a]of Object.entries(t.dashes))i[r]=this.lineAtlas.getDash(a.dasharray,a.round);return i}addSprite(e,t,i={},r){this._checkLoaded();let a=[{id:e,url:t}],n=[...js(this.stylesheet.sprite),...a];this._validate(Wt.sprite,"sprite",n,null,i)||(this.stylesheet.sprite=n,this._loadSprite(a,!0,r))}removeSprite(e){this._checkLoaded();let t=js(this.stylesheet.sprite);if(!t.find(r=>r.id===e)){this.fire(new Y(Error(`Sprite "${e}" doesn't exists on this map.`)));return}let i=this.imageManager.removeSpriteImages(e);this._markImagesChanged(i),t.splice(t.findIndex(r=>r.id===e),1),this.stylesheet.sprite=t.length>0?t:void 0,this._imagesListDirty=!0,this._changed=!0,this.fire(new _i("data"))}getSprite(){return js(this.stylesheet.sprite)}setSprite(e,t={},i){this._checkLoaded(),!(e&&this._validate(Wt.sprite,"sprite",e,null,t))&&(this.stylesheet.sprite=e,e?this._loadSprite(e,!0,i):(this._unloadSprite(),i&&i(null)))}destroy(){this._frameRequest&&(this._frameRequest=(this._frameRequest.abort(),null)),this._loadStyleRequest&&(this._loadStyleRequest=(this._loadStyleRequest.abort(),null)),this._spriteRequest&&(this._spriteRequest=(this._spriteRequest.abort(),null));for(let e in this.tileManagers){let t=this.tileManagers[e];t.setEventedParent(null),t.onRemove(this.map)}this.tileManagers={},this.imageManager&&(this.imageManager.setEventedParent(null),this.imageManager.destroy(),this.patternAtlas.destroy()),this.glyphManager&&this.glyphManager.destroy();for(let e in this._layers){let t=this._layers[e];t.setEventedParent(null),t.onRemove&&t.onRemove(this.map)}this._setInitialValues(),this.setEventedParent(null),this.dispatcher.unregisterMessageHandler("GG"),this.dispatcher.unregisterMessageHandler("GI"),this.dispatcher.unregisterMessageHandler("GDA"),this.dispatcher.remove(!0),this._listeners={},this._oneTimeListeners={}}},uF=Je([{name:"a_pos",type:"Int16",components:2},{name:"a_texture_pos",type:"Int16",components:2}]),hF=class{constructor(e,t,i){this.context=e;let r=e.gl;this.buffer=r.createBuffer(),this.dynamicDraw=!!i,this.context.unbindVAO(),e.bindElementBuffer.set(this.buffer),r.bufferData(r.ELEMENT_ARRAY_BUFFER,t.arrayBuffer,this.dynamicDraw?r.DYNAMIC_DRAW:r.STATIC_DRAW),this.dynamicDraw||t.freeBufferAfterUpload()}bind(){this.context.bindElementBuffer.set(this.buffer)}updateData(e){let t=this.context.gl;if(!this.dynamicDraw)throw Error("Attempted to update data while not in dynamic mode.");this.context.unbindVAO(),this.bind(),t.bufferSubData(t.ELEMENT_ARRAY_BUFFER,0,e.arrayBuffer)}destroy(){let e=this.context.gl;this.buffer&&(e.deleteBuffer(this.buffer),delete this.buffer)}},o_={Int8:"BYTE",Uint8:"UNSIGNED_BYTE",Int16:"SHORT",Uint16:"UNSIGNED_SHORT",Int32:"INT",Uint32:"UNSIGNED_INT",Float32:"FLOAT"},cF=class{constructor(e,t,i,r){this.length=t.length,this.attributes=i,this.itemSize=t.bytesPerElement,this.dynamicDraw=r,this.context=e;let a=e.gl;this.buffer=a.createBuffer(),e.bindVertexBuffer.set(this.buffer),a.bufferData(a.ARRAY_BUFFER,t.arrayBuffer,this.dynamicDraw?a.DYNAMIC_DRAW:a.STATIC_DRAW),this.dynamicDraw||t.freeBufferAfterUpload()}bind(){this.context.bindVertexBuffer.set(this.buffer)}updateData(e){if(e.length!==this.length)throw Error(`Length of new data is ${e.length}, which doesn't match current length of ${this.length}`);let t=this.context.gl;this.bind(),t.bufferSubData(t.ARRAY_BUFFER,0,e.arrayBuffer)}enableAttributes(e,t){for(let i of this.attributes){let r=t.attributes[i.name];r!==void 0&&e.enableVertexAttribArray(r.location)}}setVertexAttribPointers(e,t,i){for(let r of this.attributes){let a=t.attributes[r.name];if(a!==void 0){let n=r.offset+this.itemSize*(i||0);a.isInteger?e.vertexAttribIPointer(a.location,r.components,e[o_[r.type]],this.itemSize,n):e.vertexAttribPointer(a.location,r.components,e[o_[r.type]],!1,this.itemSize,n)}}}destroy(){let e=this.context.gl;this.buffer&&(e.deleteBuffer(this.buffer),delete this.buffer)}},Fe=class{constructor(e){this.gl=e.gl,this.default=this.getDefault(),this.current=this.default,this.dirty=!1}get(){return this.current}set(e){}getDefault(){return this.default}setDefault(){this.set(this.default)}},dF=class extends Fe{getDefault(){return oe.transparent}set(e){let t=this.current;(e.r!==t.r||e.g!==t.g||e.b!==t.b||e.a!==t.a||this.dirty)&&(this.gl.clearColor(e.r,e.g,e.b,e.a),this.current=e,this.dirty=!1)}},pF=class extends Fe{getDefault(){return 1}set(e){(e!==this.current||this.dirty)&&(this.gl.clearDepth(e),this.current=e,this.dirty=!1)}},fF=class extends Fe{getDefault(){return 0}set(e){(e!==this.current||this.dirty)&&(this.gl.clearStencil(e),this.current=e,this.dirty=!1)}},mF=class extends Fe{getDefault(){return[!0,!0,!0,!0]}set(e){let t=this.current;(e[0]!==t[0]||e[1]!==t[1]||e[2]!==t[2]||e[3]!==t[3]||this.dirty)&&(this.gl.colorMask(e[0],e[1],e[2],e[3]),this.current=e,this.dirty=!1)}},gF=class extends Fe{getDefault(){return!0}set(e){(e!==this.current||this.dirty)&&(this.gl.depthMask(e),this.current=e,this.dirty=!1)}},_F=class extends Fe{getDefault(){return 255}set(e){(e!==this.current||this.dirty)&&(this.gl.stencilMask(e),this.current=e,this.dirty=!1)}},yF=class extends Fe{getDefault(){return{func:this.gl.ALWAYS,ref:0,mask:255}}set(e){let t=this.current;(e.func!==t.func||e.ref!==t.ref||e.mask!==t.mask||this.dirty)&&(this.gl.stencilFunc(e.func,e.ref,e.mask),this.current=e,this.dirty=!1)}},vF=class extends Fe{getDefault(){let e=this.gl;return[e.KEEP,e.KEEP,e.KEEP]}set(e){let t=this.current;(e[0]!==t[0]||e[1]!==t[1]||e[2]!==t[2]||this.dirty)&&(this.gl.stencilOp(e[0],e[1],e[2]),this.current=e,this.dirty=!1)}},xF=class extends Fe{getDefault(){return!1}set(e){if(e===this.current&&!this.dirty)return;let t=this.gl;e?t.enable(t.STENCIL_TEST):t.disable(t.STENCIL_TEST),this.current=e,this.dirty=!1}},bF=class extends Fe{getDefault(){return[0,1]}set(e){let t=this.current;(e[0]!==t[0]||e[1]!==t[1]||this.dirty)&&(this.gl.depthRange(e[0],e[1]),this.current=e,this.dirty=!1)}},wF=class extends Fe{getDefault(){return!1}set(e){if(e===this.current&&!this.dirty)return;let t=this.gl;e?t.enable(t.DEPTH_TEST):t.disable(t.DEPTH_TEST),this.current=e,this.dirty=!1}},TF=class extends Fe{getDefault(){return this.gl.LESS}set(e){(e!==this.current||this.dirty)&&(this.gl.depthFunc(e),this.current=e,this.dirty=!1)}},EF=class extends Fe{getDefault(){return!1}set(e){if(e===this.current&&!this.dirty)return;let t=this.gl;e?t.enable(t.BLEND):t.disable(t.BLEND),this.current=e,this.dirty=!1}},DF=class extends Fe{getDefault(){let e=this.gl;return[e.ONE,e.ZERO]}set(e){let t=this.current;(e[0]!==t[0]||e[1]!==t[1]||this.dirty)&&(this.gl.blendFunc(e[0],e[1]),this.current=e,this.dirty=!1)}},SF=class extends Fe{getDefault(){return oe.transparent}set(e){let t=this.current;(e.r!==t.r||e.g!==t.g||e.b!==t.b||e.a!==t.a||this.dirty)&&(this.gl.blendColor(e.r,e.g,e.b,e.a),this.current=e,this.dirty=!1)}},CF=class extends Fe{getDefault(){return this.gl.FUNC_ADD}set(e){(e!==this.current||this.dirty)&&(this.gl.blendEquation(e),this.current=e,this.dirty=!1)}},PF=class extends Fe{getDefault(){return!1}set(e){if(e===this.current&&!this.dirty)return;let t=this.gl;e?t.enable(t.CULL_FACE):t.disable(t.CULL_FACE),this.current=e,this.dirty=!1}},AF=class extends Fe{getDefault(){return this.gl.BACK}set(e){(e!==this.current||this.dirty)&&(this.gl.cullFace(e),this.current=e,this.dirty=!1)}},IF=class extends Fe{getDefault(){return this.gl.CCW}set(e){(e!==this.current||this.dirty)&&(this.gl.frontFace(e),this.current=e,this.dirty=!1)}},MF=class extends Fe{getDefault(){return null}set(e){(e!==this.current||this.dirty)&&(this.gl.useProgram(e),this.current=e,this.dirty=!1)}},FF=class extends Fe{getDefault(){return this.gl.TEXTURE0}set(e){(e!==this.current||this.dirty)&&(this.gl.activeTexture(e),this.current=e,this.dirty=!1)}},zF=class extends Fe{getDefault(){let e=this.gl;return[0,0,e.drawingBufferWidth,e.drawingBufferHeight]}set(e){let t=this.current;(e[0]!==t[0]||e[1]!==t[1]||e[2]!==t[2]||e[3]!==t[3]||this.dirty)&&(this.gl.viewport(e[0],e[1],e[2],e[3]),this.current=e,this.dirty=!1)}},RF=class extends Fe{getDefault(){return null}set(e){if(e===this.current&&!this.dirty)return;let t=this.gl;t.bindFramebuffer(t.FRAMEBUFFER,e),this.current=e,this.dirty=!1}},kF=class extends Fe{getDefault(){return null}set(e){if(e===this.current&&!this.dirty)return;let t=this.gl;t.bindRenderbuffer(t.RENDERBUFFER,e),this.current=e,this.dirty=!1}},LF=class extends Fe{getDefault(){return null}set(e){if(e===this.current&&!this.dirty)return;let t=this.gl;t.bindTexture(t.TEXTURE_2D,e),this.current=e,this.dirty=!1}},BF=class extends Fe{getDefault(){return null}set(e){if(e===this.current&&!this.dirty)return;let t=this.gl;t.bindBuffer(t.ARRAY_BUFFER,e),this.current=e,this.dirty=!1}},OF=class extends Fe{getDefault(){return null}set(e){let t=this.gl;t.bindBuffer(t.ELEMENT_ARRAY_BUFFER,e),this.current=e,this.dirty=!1}},jF=class extends Fe{getDefault(){return null}set(e){(e!==this.current||this.dirty)&&(this.gl.bindVertexArray(e),this.current=e,this.dirty=!1)}},VF=class extends Fe{getDefault(){return 4}set(e){if(e===this.current&&!this.dirty)return;let t=this.gl;t.pixelStorei(t.UNPACK_ALIGNMENT,e),this.current=e,this.dirty=!1}},NF=class extends Fe{getDefault(){return!1}set(e){if(e===this.current&&!this.dirty)return;let t=this.gl;t.pixelStorei(t.UNPACK_PREMULTIPLY_ALPHA_WEBGL,e),this.current=e,this.dirty=!1}},UF=class extends Fe{getDefault(){return!1}set(e){if(e===this.current&&!this.dirty)return;let t=this.gl;t.pixelStorei(t.UNPACK_FLIP_Y_WEBGL,e),this.current=e,this.dirty=!1}},Fp=class extends Fe{constructor(e,t){super(e),this.context=e,this.parent=t}getDefault(){return null}},$F=class extends Fp{setDirty(){this.dirty=!0}set(e){if(e===this.current&&!this.dirty)return;this.context.bindFramebuffer.set(this.parent);let t=this.gl;t.framebufferTexture2D(t.FRAMEBUFFER,t.COLOR_ATTACHMENT0,t.TEXTURE_2D,e,0),this.current=e,this.dirty=!1}},GF=class extends Fp{set(e){if(e===this.current&&!this.dirty)return;this.context.bindFramebuffer.set(this.parent);let t=this.gl;t.framebufferRenderbuffer(t.FRAMEBUFFER,t.DEPTH_ATTACHMENT,t.RENDERBUFFER,e),this.current=e,this.dirty=!1}},ZF=class extends Fp{set(e){if(e===this.current&&!this.dirty)return;this.context.bindFramebuffer.set(this.parent);let t=this.gl;t.framebufferRenderbuffer(t.FRAMEBUFFER,t.DEPTH_STENCIL_ATTACHMENT,t.RENDERBUFFER,e),this.current=e,this.dirty=!1}},qF=class{constructor(e,t,i,r,a){this.context=e,this.width=t,this.height=i;let n=e.gl,o=this.framebuffer=n.createFramebuffer();if(this.colorAttachment=new $F(e,o),r)this.depthAttachment=a?new ZF(e,o):new GF(e,o);else if(a)throw Error("Stencil cannot be set without depth")}destroy(){let e=this.context.gl,t=this.colorAttachment.get();if(t&&e.deleteTexture(t),this.depthAttachment){let i=this.depthAttachment.get();i&&e.deleteRenderbuffer(i)}e.deleteFramebuffer(this.framebuffer)}},tu={ProjectionUBO:0,TerrainUBO:1,FrameUBO:2};function WF(e,t){for(let[i,r]of Object.entries(tu)){let a=e.getUniformBlockIndex(t,i);a!==e.INVALID_INDEX&&e.uniformBlockBinding(t,a,r)}}var HF={float:[1,1],int:[1,1],vec2:[2,2],vec4:[4,4],mat4:[16,4]};function zp(e){let t={},i=0;for(let{name:r,type:a}of e){let[n,o]=HF[a];i=Math.ceil(i/o)*o,t[r]=i,i+=n}return{offsets:t,contentWords:i,sizeWords:Math.ceil(i/4)*4}}var Rp=class{constructor(e,t,i){this.context=e,this.binding=t,this.contentWords=i.contentWords;let r=e.gl;this.buffer=r.createBuffer(),r.bindBuffer(r.UNIFORM_BUFFER,this.buffer),r.bufferData(r.UNIFORM_BUFFER,i.sizeWords*4,r.DYNAMIC_DRAW),this.uploaded=new Float32Array(i.sizeWords),this.pending=new Float32Array(i.sizeWords),this.uploadedWords=new Uint32Array(this.uploaded.buffer),this.pendingWords=new Uint32Array(this.pending.buffer),this.hasData=!1}upload(){let e=this.context.gl,t=!this.hasData;if(!t){let i=this.pendingWords,r=this.uploadedWords;for(let a=0;a<this.contentWords;a++)if(i[a]!==r[a]){t=!0;break}}if(!t){this.bind();return}e.bindBufferBase(e.UNIFORM_BUFFER,this.binding,this.buffer),this.context.boundUniformBuffers[this.binding]=this.buffer,e.bufferData(e.UNIFORM_BUFFER,this.pending,e.DYNAMIC_DRAW),this.uploaded.set(this.pending),this.hasData=!0}bind(){let e=this.context.boundUniformBuffers;if(e[this.binding]===this.buffer)return;let t=this.context.gl;t.bindBufferBase(t.UNIFORM_BUFFER,this.binding,this.buffer),e[this.binding]=this.buffer}destroy(){let e=this.context.gl;this.buffer&&(e.deleteBuffer(this.buffer),delete this.buffer)}},ux=zp([{name:"u_projection_matrix",type:"mat4"},{name:"u_projection_fallback_matrix",type:"mat4"},{name:"u_projection_tile_mercator_coords",type:"vec4"},{name:"u_projection_clipping_plane",type:"vec4"},{name:"u_projection_transition",type:"float"},{name:"u_projection_clip_antimeridian",type:"int"}]),ba=ux.offsets;function hx(e){return new Rp(e,tu.ProjectionUBO,ux)}function s_(e,t){let i=e.pending;i.set(t.mainMatrix,ba.u_projection_matrix),i.set(t.fallbackMatrix,ba.u_projection_fallback_matrix),i.set(t.tileMercatorCoords,ba.u_projection_tile_mercator_coords),i.set(t.clippingPlane,ba.u_projection_clipping_plane),i[ba.u_projection_transition]=t.projectionTransition,e.pendingWords[ba.u_projection_clip_antimeridian]=+!!t.clipAntimeridian,e.upload()}function XF(e,t){if(!t){e.projectionUniformBuffer.bind();return}let i=t.uniformBufferKey;if(i===void 0){s_(e.projectionUniformBuffer,t);return}let r=e.keyedProjectionUniformBuffers.get(i);if(r){r.bind();return}let a=e.freeProjectionUniformBuffers.pop()??hx(e);e.keyedProjectionUniformBuffers.set(i,a),s_(a,t)}function YF(e){e.freeProjectionUniformBuffers.push(...e.keyedProjectionUniformBuffers.values()),e.keyedProjectionUniformBuffers.clear()}function KF(e){e.projectionUniformBuffer.destroy();for(let t of e.keyedProjectionUniformBuffers.values())t.destroy();for(let t of e.freeProjectionUniformBuffers)t.destroy()}var cx=zp([{name:"u_units_to_pixels",type:"vec2"},{name:"u_world_size",type:"vec2"},{name:"u_camera_to_center_distance",type:"float"},{name:"u_symbol_fade_change",type:"float"},{name:"u_aspect_ratio",type:"float"},{name:"u_device_pixel_ratio",type:"float"},{name:"u_viewport_size",type:"vec2"},{name:"u_pixel_extrude_scale",type:"vec2"},{name:"u_pitch",type:"float"}]),Ot=cx.offsets;function JF(e){return new Rp(e,tu.FrameUBO,cx)}function QF(e,t,i){let r=e.pending,a=e.context.gl;r[Ot.u_units_to_pixels]=1/t.pixelsToGLUnits[0],r[Ot.u_units_to_pixels+1]=1/t.pixelsToGLUnits[1],r[Ot.u_world_size]=a.drawingBufferWidth,r[Ot.u_world_size+1]=a.drawingBufferHeight,r[Ot.u_camera_to_center_distance]=t.cameraToCenterDistance,r[Ot.u_symbol_fade_change]=i.fadeDuration?i.symbolFadeChange:1,r[Ot.u_aspect_ratio]=t.width/t.height,r[Ot.u_device_pixel_ratio]=i.pixelRatio,r[Ot.u_viewport_size]=t.width,r[Ot.u_viewport_size+1]=t.height,r[Ot.u_pixel_extrude_scale]=1/t.width,r[Ot.u_pixel_extrude_scale+1]=1/t.height,r[Ot.u_pitch]=t.pitch/360*2*Math.PI,e.upload()}function l_(e,t,i){let r=e.pending;r[Ot.u_world_size]=t,r[Ot.u_world_size+1]=i,e.upload()}var dx=zp([{name:"u_terrain_matrix",type:"mat4"},{name:"u_terrain_unpack",type:"vec4"},{name:"u_terrain_dim",type:"float"},{name:"u_terrain_exaggeration",type:"float"}]),Es=dx.offsets;function e5(e){return new Rp(e,tu.TerrainUBO,dx)}function t5(e,t){let i=e.pending;i.set(t.u_terrain_matrix,Es.u_terrain_matrix),i.set(t.u_terrain_unpack,Es.u_terrain_unpack),i[Es.u_terrain_dim]=t.u_terrain_dim,i[Es.u_terrain_exaggeration]=t.u_terrain_exaggeration,e.upload()}var et=class{constructor(e,t,i){this.blendFunction=e,this.blendColor=t,this.mask=i}};et.Replace=[1,0],et.disabled=new et(et.Replace,oe.transparent,[!1,!1,!1,!1]),et.unblended=new et(et.Replace,oe.transparent,[!0,!0,!0,!0]),et.alphaBlended=new et([1,771],oe.transparent,[!0,!0,!0,!0]);var i5=class{constructor(e){this.gl=e,this.clearColor=new dF(this),this.clearDepth=new pF(this),this.clearStencil=new fF(this),this.colorMask=new mF(this),this.depthMask=new gF(this),this.stencilMask=new _F(this),this.stencilFunc=new yF(this),this.stencilOp=new vF(this),this.stencilTest=new xF(this),this.depthRange=new bF(this),this.depthTest=new wF(this),this.depthFunc=new TF(this),this.blend=new EF(this),this.blendFunc=new DF(this),this.blendColor=new SF(this),this.blendEquation=new CF(this),this.cullFace=new PF(this),this.cullFaceSide=new AF(this),this.frontFace=new IF(this),this.program=new MF(this),this.activeTexture=new FF(this),this.viewport=new zF(this),this.bindFramebuffer=new RF(this),this.bindRenderbuffer=new kF(this),this.bindTexture=new LF(this),this.bindVertexBuffer=new BF(this),this.bindElementBuffer=new OF(this),this.bindVertexArray=new jF(this),this.pixelStoreUnpack=new VF(this),this.pixelStoreUnpackPremultiplyAlpha=new NF(this),this.pixelStoreUnpackFlipY=new UF(this),this.extTextureFilterAnisotropic=e.getExtension("EXT_texture_filter_anisotropic"),this.extTextureFilterAnisotropic&&(this.extTextureFilterAnisotropicMax=e.getParameter(this.extTextureFilterAnisotropic.MAX_TEXTURE_MAX_ANISOTROPY_EXT)),this.maxTextureSize=e.getParameter(e.MAX_TEXTURE_SIZE),e.getExtension("EXT_color_buffer_half_float"),e.getExtension("EXT_color_buffer_float"),this.boundUniformBuffers=[],this.projectionUniformBuffer=hx(this),this.keyedProjectionUniformBuffers=new Map,this.freeProjectionUniformBuffers=[],this.terrainUniformBuffer=e5(this),this.frameUniformBuffer=JF(this)}destroy(){KF(this),this.terrainUniformBuffer.destroy(),this.frameUniformBuffer.destroy()}setDefault(){this.unbindVAO(),this.clearColor.setDefault(),this.clearDepth.setDefault(),this.clearStencil.setDefault(),this.colorMask.setDefault(),this.depthMask.setDefault(),this.stencilMask.setDefault(),this.stencilFunc.setDefault(),this.stencilOp.setDefault(),this.stencilTest.setDefault(),this.depthRange.setDefault(),this.depthTest.setDefault(),this.depthFunc.setDefault(),this.blend.setDefault(),this.blendFunc.setDefault(),this.blendColor.setDefault(),this.blendEquation.setDefault(),this.cullFace.setDefault(),this.cullFaceSide.setDefault(),this.frontFace.setDefault(),this.program.setDefault(),this.activeTexture.setDefault(),this.bindFramebuffer.setDefault(),this.pixelStoreUnpack.setDefault(),this.pixelStoreUnpackPremultiplyAlpha.setDefault(),this.pixelStoreUnpackFlipY.setDefault()}setDirty(){this.clearColor.dirty=!0,this.clearDepth.dirty=!0,this.clearStencil.dirty=!0,this.colorMask.dirty=!0,this.depthMask.dirty=!0,this.stencilMask.dirty=!0,this.stencilFunc.dirty=!0,this.stencilOp.dirty=!0,this.stencilTest.dirty=!0,this.depthRange.dirty=!0,this.depthTest.dirty=!0,this.depthFunc.dirty=!0,this.blend.dirty=!0,this.blendFunc.dirty=!0,this.blendColor.dirty=!0,this.blendEquation.dirty=!0,this.cullFace.dirty=!0,this.cullFaceSide.dirty=!0,this.frontFace.dirty=!0,this.program.dirty=!0,this.activeTexture.dirty=!0,this.viewport.dirty=!0,this.bindFramebuffer.dirty=!0,this.bindRenderbuffer.dirty=!0,this.bindTexture.dirty=!0,this.bindVertexBuffer.dirty=!0,this.bindElementBuffer.dirty=!0,this.bindVertexArray.dirty=!0,this.pixelStoreUnpack.dirty=!0,this.pixelStoreUnpackPremultiplyAlpha.dirty=!0,this.pixelStoreUnpackFlipY.dirty=!0,this.boundUniformBuffers=[]}setCustomLayerDefaults(){this.unbindVAO(),this.cullFace.setDefault(),this.activeTexture.setDefault(),this.pixelStoreUnpack.setDefault(),this.pixelStoreUnpackPremultiplyAlpha.setDefault(),this.pixelStoreUnpackFlipY.setDefault()}createIndexBuffer(e,t){return new hF(this,e,t)}createVertexBuffer(e,t,i){return new cF(this,e,t,i)}createRenderbuffer(e,t,i){let r=this.gl,a=r.createRenderbuffer();return this.bindRenderbuffer.set(a),r.renderbufferStorage(r.RENDERBUFFER,e,t,i),this.bindRenderbuffer.set(null),a}createFramebuffer(e,t,i,r){return new qF(this,e,t,i,r)}clear({color:e,depth:t,stencil:i}){let r=this.gl,a=0;e&&(a|=r.COLOR_BUFFER_BIT,this.clearColor.set(e),this.colorMask.set([!0,!0,!0,!0])),t!==void 0&&(a|=r.DEPTH_BUFFER_BIT,this.depthRange.set([0,1]),this.clearDepth.set(t),this.depthMask.set(!0)),i!==void 0&&(a|=r.STENCIL_BUFFER_BIT,this.clearStencil.set(i),this.stencilMask.set(255)),r.clear(a)}setCullFace(e){e.enable===!1?this.cullFace.set(!1):(this.cullFace.set(!0),this.cullFaceSide.set(e.mode),this.frontFace.set(e.frontFace))}setDepthMode(e){e.func===this.gl.ALWAYS&&!e.mask?this.depthTest.set(!1):(this.depthTest.set(!0),this.depthFunc.set(e.func),this.depthMask.set(e.mask),this.depthRange.set(e.range))}setStencilMode(e){e.test.func===this.gl.ALWAYS&&!e.mask?this.stencilTest.set(!1):(this.stencilTest.set(!0),this.stencilMask.set(e.mask),this.stencilOp.set([e.fail,e.depthFail,e.pass]),this.stencilFunc.set({func:e.test.func,ref:e.ref,mask:e.test.mask}))}setColorMode(e){Vi(e.blendFunction,et.Replace)?this.blend.set(!1):(this.blend.set(!0),this.blendFunc.set(e.blendFunction),this.blendColor.set(e.blendColor)),this.colorMask.set(e.mask)}createVertexArray(){return this.gl.createVertexArray()}deleteVertexArray(e){this.gl.deleteVertexArray(e)}unbindVAO(){this.bindVertexArray.set(null)}},r5=class{constructor(){this.boundProgram=null,this.boundLayoutVertexBuffer=null,this.boundPaintVertexBuffers=[],this.boundIndexBuffer=null,this.boundVertexOffset=null,this.boundDynamicVertexBuffer=null,this.vao=null}bind(e,t,i,r,a,n,o,s,l){this.context=e;let u=this.boundPaintVertexBuffers.length!==r.length;for(let h=0;!u&&h<r.length;h++)this.boundPaintVertexBuffers[h]!==r[h]&&(u=!0);!this.vao||this.boundProgram!==t||this.boundLayoutVertexBuffer!==i||u||this.boundIndexBuffer!==a||this.boundVertexOffset!==n||this.boundDynamicVertexBuffer!==o||this.boundDynamicVertexBuffer2!==s||this.boundDynamicVertexBuffer3!==l?this.freshBind(t,i,r,a,n,o,s,l):e.bindVertexArray.set(this.vao)}freshBind(e,t,i,r,a,n,o,s){let l=e.numAttributes,u=this.context,h=u.gl;this.vao&&this.destroy(),this.vao=u.createVertexArray(),u.bindVertexArray.set(this.vao),this.boundProgram=e,this.boundLayoutVertexBuffer=t,this.boundPaintVertexBuffers=i,this.boundIndexBuffer=r,this.boundVertexOffset=a,this.boundDynamicVertexBuffer=n,this.boundDynamicVertexBuffer2=o,this.boundDynamicVertexBuffer3=s,t.enableAttributes(h,e);for(let c of i)c.enableAttributes(h,e);n&&n.enableAttributes(h,e),o&&o.enableAttributes(h,e),s&&s.enableAttributes(h,e),t.bind(),t.setVertexAttribPointers(h,e,a);for(let c of i)c.bind(),c.setVertexAttribPointers(h,e,a);n&&(n.bind(),n.setVertexAttribPointers(h,e,a)),r&&r.bind(),o&&(o.bind(),o.setVertexAttribPointers(h,e,a)),s&&(s.bind(),s.setVertexAttribPointers(h,e,a)),u.currentNumAttributes=l}destroy(){this.vao&&(this.vao=(this.context.deleteVertexArray(this.vao),null))}},a5=(e,t)=>({u_depth:new K(e,t.u_depth),u_terrain:new K(e,t.u_terrain)}),n5=(e,t)=>({u_texture:new K(e,t.u_texture),u_ele_delta:new $(e,t.u_ele_delta),u_fog_matrix:new Fi(e,t.u_fog_matrix),u_fog_color:new Ar(e,t.u_fog_color),u_fog_ground_blend:new $(e,t.u_fog_ground_blend),u_fog_ground_blend_opacity:new $(e,t.u_fog_ground_blend_opacity),u_horizon_color:new Ar(e,t.u_horizon_color),u_horizon_fog_blend:new $(e,t.u_horizon_fog_blend),u_is_globe_mode:new $(e,t.u_is_globe_mode)}),o5=(e,t)=>({u_ele_delta:new $(e,t.u_ele_delta)}),s5=(e,t)=>({u_tile_bounds:new Ya(e,t.u_tile_bounds)}),l5=(e,t,i,r,a)=>({u_texture:0,u_ele_delta:e,u_fog_matrix:t,u_fog_color:i?i["fog-color"]:oe.white,u_fog_ground_blend:i?i["fog-ground-blend"]:1,u_fog_ground_blend_opacity:a?0:i?fP(r):0,u_horizon_color:i?i["horizon-color"]:oe.white,u_horizon_fog_blend:i?i["horizon-fog-blend"]:1,u_is_globe_mode:+!!a}),u5=e=>({u_ele_delta:e}),h5=e=>({u_tile_bounds:e});function mh(e){let t=[];for(let i of e){if(i===null)continue;let r=i.split(" ");t.push(r.pop())}return t}function c5(e,t){let i=new Set([e.INT,e.INT_VEC2,e.INT_VEC3,e.INT_VEC4,e.UNSIGNED_INT,e.UNSIGNED_INT_VEC2,e.UNSIGNED_INT_VEC3,e.UNSIGNED_INT_VEC4]),r=new Set,a=e.getProgramParameter(t,e.ACTIVE_ATTRIBUTES);for(let n=0;n<a;n++){let o=e.getActiveAttrib(t,n);o&&i.has(o.type)&&r.add(o.name)}return r}var d5=class{constructor(e,t,i,r,a,n,o,s,l=[]){let u=e.gl;this.program=u.createProgram();let h=mh(t.staticAttributes),c=i?i.getBinderAttributes():[],d=h.concat(c),p=Zi.prelude.staticUniforms?mh(Zi.prelude.staticUniforms):[],f=t.staticUniforms?mh(t.staticUniforms):[],m=i?i.getBinderUniforms():[],g=p.concat(f).concat(m),_=[];for(let S of g)_.includes(S)||_.push(S);let y=i?i.defines():[];y.unshift("#version 300 es"),a&&y.push("#define OVERDRAW_INSPECTOR;"),n&&y.push("#define TERRAIN3D;"),s&&y.push(s),l&&y.push(...l);let v=y.concat(Zi.prelude.fragmentSource,o.fragmentSource,t.fragmentSource).join(`
|
|
814
|
+
`),x=y.concat(Zi.prelude.vertexSource,o.vertexSource,t.vertexSource).join(`
|
|
815
|
+
`),b=u.createShader(u.FRAGMENT_SHADER);if(u.isContextLost()){this.failedToCreate=!0;return}u.shaderSource(b,v),u.compileShader(b),u.attachShader(this.program,b);let w=u.createShader(u.VERTEX_SHADER);if(u.isContextLost()){this.failedToCreate=!0;return}u.shaderSource(w,x),u.compileShader(w),u.attachShader(this.program,w),this.attributes={};let T={};if(this.numAttributes=d.length,u.linkProgram(this.program),!u.getProgramParameter(this.program,u.LINK_STATUS)){if(u.isContextLost()||u.getProgramParameter(this.program,u.ATTACHED_SHADERS)===0){this.failedToCreate=!0;return}throw u.getShaderParameter(b,u.COMPILE_STATUS)?u.getShaderParameter(w,u.COMPILE_STATUS)?Error(`Program failed to link: ${u.getProgramInfoLog(this.program)}`):Error(`Could not compile vertex shader: ${u.getShaderInfoLog(w)}`):Error(`Could not compile fragment shader: ${u.getShaderInfoLog(b)}`)}WF(u,this.program);let E=c5(u,this.program);for(let S of d){if(!S)continue;let M=u.getAttribLocation(this.program,S);M>=0&&(this.attributes[S]={location:M,isInteger:E.has(S)})}u.deleteShader(w),u.deleteShader(b);for(let S of _)if(S&&!T[S]){let M=u.getUniformLocation(this.program,S);M&&(T[S]=M)}this.fixedUniforms=r(e,T),this.terrainUniforms=a5(e,T),this.binderUniforms=i?i.getUniforms(e,T):[]}draw(e,t,i,r,a,n,o,s,l,u,h,c,d,p,f,m,g,_,y){var b;let v=e.gl;if(this.failedToCreate)return;if(e.program.set(this.program),e.terrainUniformBuffer.bind(),e.frameUniformBuffer.bind(),e.setDepthMode(i),e.setStencilMode(r),e.setColorMode(a),e.setCullFace(n),s){e.activeTexture.set(v.TEXTURE2),v.bindTexture(v.TEXTURE_2D,s.depthTexture),e.activeTexture.set(v.TEXTURE3),v.bindTexture(v.TEXTURE_2D,s.texture);for(let w in this.terrainUniforms)this.terrainUniforms[w].set(s[w]);t5(e.terrainUniformBuffer,s)}if(XF(e,l),o)for(let w in this.fixedUniforms)this.fixedUniforms[w].set(o[w]);m&&m.setUniforms(e,this.binderUniforms,p,{zoom:f});let x=0;switch(t){case v.LINES:x=2;break;case v.TRIANGLES:x=3;break;case v.LINE_STRIP:x=1}for(let w of d.get())w.vaos||(w.vaos={}),(b=w.vaos)[u]||(b[u]=new r5),w.vaos[u].bind(e,this,h,m?m.getPaintVertexBuffers():[],c,w.vertexOffset,g,_,y),v.drawElements(t,w.primitiveLength*x,v.UNSIGNED_SHORT,w.primitiveOffset*x*2)}};function px(e,t,i){let r=1/oi(i,1,t.frameRenderContext.transform.tileZoom),a=2**i.tileID.overscaledZ,n=i.tileSize*2**t.frameRenderContext.transform.tileZoom/a,o=n*(i.tileID.canonical.x+i.tileID.wrap*a),s=n*i.tileID.canonical.y;return{u_image:0,u_texsize:i.imageAtlasTexture.size,u_scale:[r,e.fromScale,e.toScale],u_fade:e.t,u_pixel_coord_upper:[o>>16,s>>16],u_pixel_coord_lower:[o&65535,s&65535]}}function p5(e,t,i,r){let a=i.patternAtlas.getPattern(e.from.toString()),n=i.patternAtlas.getPattern(e.to.toString()),{width:o,height:s}=i.patternAtlas.getPixelSize(),l=2**r.tileID.overscaledZ,u=r.tileSize*2**i.frameRenderContext.transform.tileZoom/l,h=u*(r.tileID.canonical.x+r.tileID.wrap*l),c=u*r.tileID.canonical.y;return{u_image:0,u_pattern_tl_a:a.tl,u_pattern_br_a:a.br,u_pattern_tl_b:n.tl,u_pattern_br_b:n.br,u_texsize:[o,s],u_mix:t.t,u_pattern_size_a:a.displaySize,u_pattern_size_b:n.displaySize,u_scale_a:t.fromScale,u_scale_b:t.toScale,u_tile_units_to_pixels:1/oi(r,1,i.frameRenderContext.transform.tileZoom),u_pixel_coord_upper:[h>>16,c>>16],u_pixel_coord_lower:[h&65535,c&65535]}}var f5=(e,t)=>({u_lightpos:new Nt(e,t.u_lightpos),u_lightpos_globe:new Nt(e,t.u_lightpos_globe),u_lightintensity:new $(e,t.u_lightintensity),u_lightcolor:new Nt(e,t.u_lightcolor),u_vertical_gradient:new $(e,t.u_vertical_gradient),u_opacity:new $(e,t.u_opacity),u_fill_translate:new de(e,t.u_fill_translate)}),m5=(e,t)=>({u_lightpos:new Nt(e,t.u_lightpos),u_lightpos_globe:new Nt(e,t.u_lightpos_globe),u_lightintensity:new $(e,t.u_lightintensity),u_lightcolor:new Nt(e,t.u_lightcolor),u_vertical_gradient:new $(e,t.u_vertical_gradient),u_height_factor:new $(e,t.u_height_factor),u_opacity:new $(e,t.u_opacity),u_fill_translate:new de(e,t.u_fill_translate),u_image:new K(e,t.u_image),u_texsize:new de(e,t.u_texsize),u_pixel_coord_upper:new de(e,t.u_pixel_coord_upper),u_pixel_coord_lower:new de(e,t.u_pixel_coord_lower),u_scale:new Nt(e,t.u_scale),u_fade:new $(e,t.u_fade)}),fx=(e,t,i,r,a)=>{let n=N_(t.position),o=k_();t.anchor==="viewport"&&xb(o,e.frameRenderContext.transform.bearingInRadians),Fb(n,n,o);let s=e.frameRenderContext.transform.transformLightDirection(n),l=t.color;return{u_lightpos:n,u_lightpos_globe:s,u_lightintensity:t.intensity,u_lightcolor:[l.r,l.g,l.b],u_vertical_gradient:+i,u_opacity:r,u_fill_translate:a}},g5=(e,t,i,r,a,n,o,s)=>q(fx(e,t,i,r,a),px(o,e,s),{u_height_factor:-(2**n.overscaledZ)/s.tileSize/8}),_5=(e,t)=>({u_fill_translate:new de(e,t.u_fill_translate)}),y5=(e,t)=>({u_image:new K(e,t.u_image),u_texsize:new de(e,t.u_texsize),u_pixel_coord_upper:new de(e,t.u_pixel_coord_upper),u_pixel_coord_lower:new de(e,t.u_pixel_coord_lower),u_scale:new Nt(e,t.u_scale),u_fade:new $(e,t.u_fade),u_sdf_pattern:new K(e,t.u_sdf_pattern),u_fill_translate:new de(e,t.u_fill_translate)}),v5=(e,t)=>({u_fill_translate:new de(e,t.u_fill_translate)}),x5=(e,t)=>({u_image:new K(e,t.u_image),u_texsize:new de(e,t.u_texsize),u_pixel_coord_upper:new de(e,t.u_pixel_coord_upper),u_pixel_coord_lower:new de(e,t.u_pixel_coord_lower),u_scale:new Nt(e,t.u_scale),u_fade:new $(e,t.u_fade),u_sdf_pattern:new K(e,t.u_sdf_pattern),u_fill_translate:new de(e,t.u_fill_translate)}),mx=(e,t,i,r,a)=>q(px(t,e,i),{u_fill_translate:r,u_sdf_pattern:+!!a}),b5=e=>({u_fill_translate:e}),w5=e=>({u_fill_translate:e}),T5=(e,t,i,r,a)=>mx(e,t,i,r,a),E5=(e,t)=>({u_scale_with_map:new K(e,t.u_scale_with_map),u_pitch_with_map:new K(e,t.u_pitch_with_map),u_extrude_scale:new de(e,t.u_extrude_scale),u_globe_extrude_scale:new $(e,t.u_globe_extrude_scale),u_translate:new de(e,t.u_translate)}),D5=(e,t,i,r,a)=>{let n=e.frameRenderContext.transform,o,s,l=0;if(i.paint.get("circle-pitch-alignment")==="map"){let u=oi(t,1,n.zoom);o=!0,s=[u,u],l=u/(k*2**t.tileID.overscaledZ)*2*Math.PI*a}else o=!1,s=n.pixelsToGLUnits;return{u_scale_with_map:+(i.paint.get("circle-pitch-scale")==="map"),u_pitch_with_map:+o,u_extrude_scale:s,u_globe_extrude_scale:l,u_translate:r}},S5=(e,t)=>({u_color:new Ar(e,t.u_color),u_overlay:new K(e,t.u_overlay),u_overlay_scale:new $(e,t.u_overlay_scale)}),u_=(e,t=1)=>({u_color:e,u_overlay:0,u_overlay_scale:t}),C5=(e,t)=>({u_extrude_scale:new $(e,t.u_extrude_scale),u_intensity:new $(e,t.u_intensity),u_globe_extrude_scale:new $(e,t.u_globe_extrude_scale)}),P5=(e,t)=>({u_matrix:new Fi(e,t.u_matrix),u_image:new K(e,t.u_image),u_color_ramp:new K(e,t.u_color_ramp),u_opacity:new $(e,t.u_opacity)}),gx=(e,t,i,r)=>{let a=oi(e,1,t)/(k*2**e.tileID.overscaledZ)*2*Math.PI*r;return{u_extrude_scale:oi(e,1,t),u_intensity:i,u_globe_extrude_scale:a}},_x=(e,t,i,r)=>{let a=na();return ir(a,0,e.width,e.height,0,0,1),{u_matrix:a,u_image:i,u_color_ramp:r,u_opacity:t.paint.get("heatmap-opacity")}},A5=(e,t)=>({u_image:new K(e,t.u_image),u_latrange:new de(e,t.u_latrange),u_exaggeration:new $(e,t.u_exaggeration),u_altitudes:new lm(e,t.u_altitudes),u_azimuths:new lm(e,t.u_azimuths),u_accent:new Ar(e,t.u_accent),u_method:new K(e,t.u_method),u_shadows:new sm(e,t.u_shadows),u_highlights:new sm(e,t.u_highlights)}),I5=(e,t)=>({u_matrix:new Fi(e,t.u_matrix),u_image:new K(e,t.u_image),u_dimension:new de(e,t.u_dimension),u_zoom:new $(e,t.u_zoom),u_unpack:new Ya(e,t.u_unpack)}),M5=(e,t,i)=>{let r=i.paint.get("hillshade-accent-color"),a;switch(i.paint.get("hillshade-method")){case"basic":a=4;break;case"combined":a=1;break;case"igor":a=2;break;case"multidirectional":a=3;break;default:a=0}let n=i.getIlluminationProperties();for(let o=0;o<n.directionRadians.length;o++)i.paint.get("hillshade-illumination-anchor")==="viewport"&&(n.directionRadians[o]+=e.frameRenderContext.transform.bearingInRadians);return{u_image:0,u_latrange:z5(e,t.tileID),u_exaggeration:i.paint.get("hillshade-exaggeration"),u_altitudes:n.altitudeRadians,u_azimuths:n.directionRadians,u_accent:r,u_method:a,u_highlights:n.highlightColor,u_shadows:n.shadowColor}},F5=(e,t)=>{let i=t.stride,r=na();return ir(r,0,k,-8192,0,0,1),lt(r,r,[0,-8192,0]),{u_matrix:r,u_image:1,u_dimension:[i,i],u_zoom:e.overscaledZ,u_unpack:t.getUnpackVector()}};function z5(e,t){let i=2**t.canonical.z,r=t.canonical.y;return[new De(0,r/i).toLngLat().lat,new De(0,(r+1)/i).toLngLat().lat]}var R5=(e,t)=>({u_image:new K(e,t.u_image),u_unpack:new Ya(e,t.u_unpack),u_dimension:new de(e,t.u_dimension),u_elevation_stops:new K(e,t.u_elevation_stops),u_color_stops:new K(e,t.u_color_stops),u_color_ramp_size:new K(e,t.u_color_ramp_size),u_opacity:new $(e,t.u_opacity)}),k5=(e,t,i=0)=>({u_image:0,u_unpack:t.getUnpackVector(),u_dimension:[t.stride,t.stride],u_elevation_stops:1,u_color_stops:4,u_color_ramp_size:i,u_opacity:e.paint.get("color-relief-opacity")}),L5=(e,t)=>({u_translation:new de(e,t.u_translation),u_ratio:new $(e,t.u_ratio)}),B5=(e,t)=>({u_translation:new de(e,t.u_translation),u_ratio:new $(e,t.u_ratio),u_image:new K(e,t.u_image),u_image_height:new $(e,t.u_image_height)}),O5=(e,t)=>({u_translation:new de(e,t.u_translation),u_texsize:new de(e,t.u_texsize),u_ratio:new $(e,t.u_ratio),u_image:new K(e,t.u_image),u_scale:new Nt(e,t.u_scale),u_fade:new $(e,t.u_fade)}),j5=(e,t)=>({u_translation:new de(e,t.u_translation),u_ratio:new $(e,t.u_ratio),u_image:new K(e,t.u_image),u_mix:new $(e,t.u_mix),u_tileratio:new $(e,t.u_tileratio),u_crossfade_from:new $(e,t.u_crossfade_from),u_crossfade_to:new $(e,t.u_crossfade_to),u_lineatlas_width:new $(e,t.u_lineatlas_width),u_lineatlas_height:new $(e,t.u_lineatlas_height)}),V5=(e,t)=>({u_translation:new de(e,t.u_translation),u_ratio:new $(e,t.u_ratio),u_image:new K(e,t.u_image),u_image_height:new $(e,t.u_image_height),u_tileratio:new $(e,t.u_tileratio),u_crossfade_from:new $(e,t.u_crossfade_from),u_crossfade_to:new $(e,t.u_crossfade_to),u_image_dash:new K(e,t.u_image_dash),u_mix:new $(e,t.u_mix),u_lineatlas_width:new $(e,t.u_lineatlas_width),u_lineatlas_height:new $(e,t.u_lineatlas_height)}),iu=(e,t,i,r)=>{let a=e.frameRenderContext.transform;return{u_translation:yx(e,t,i),u_ratio:r/oi(t,1,a.zoom)}},N5=(e,t,i,r,a)=>q(iu(e,t,i,r),{u_image:0,u_image_height:a}),U5=(e,t,i,r,a)=>{let n=e.frameRenderContext.transform,o=kp(t,n);return{u_translation:yx(e,t,i),u_texsize:t.imageAtlasTexture.size,u_ratio:r/oi(t,1,n.zoom),u_image:0,u_scale:[o,a.fromScale,a.toScale],u_fade:a.t}},$5=(e,t,i,r,a)=>{let n=e.frameRenderContext.transform,o=kp(t,n);return q(iu(e,t,i,r),{u_tileratio:o,u_crossfade_from:a.fromScale,u_crossfade_to:a.toScale,u_image:0,u_mix:a.t,u_lineatlas_width:e.lineAtlas.width,u_lineatlas_height:e.lineAtlas.height})},G5=(e,t,i,r,a,n)=>{let o=e.frameRenderContext.transform,s=kp(t,o);return q(iu(e,t,i,r),{u_image:0,u_image_height:n,u_tileratio:s,u_crossfade_from:a.fromScale,u_crossfade_to:a.toScale,u_image_dash:1,u_mix:a.t,u_lineatlas_width:e.lineAtlas.width,u_lineatlas_height:e.lineAtlas.height})};function kp(e,t){return 1/oi(e,1,t.tileZoom)}function yx(e,t,i){return Sr(e.frameRenderContext.transform,t,i.paint.get("line-translate"),i.paint.get("line-translate-anchor"))}var Z5=(e,t)=>({u_image:new K(e,t.u_image),u_opacity:new $(e,t.u_opacity)}),q5=(e,t)=>({u_image:t,u_opacity:e}),W5=(e,t)=>({u_is_size_zoom_constant:new K(e,t.u_is_size_zoom_constant),u_is_size_feature_constant:new K(e,t.u_is_size_feature_constant),u_size_t:new $(e,t.u_size_t),u_size:new $(e,t.u_size),u_rotate_symbol:new K(e,t.u_rotate_symbol),u_label_plane_matrix:new Fi(e,t.u_label_plane_matrix),u_coord_matrix:new Fi(e,t.u_coord_matrix),u_is_text:new K(e,t.u_is_text),u_pitch_with_map:new K(e,t.u_pitch_with_map),u_is_along_line:new K(e,t.u_is_along_line),u_is_variable_anchor:new K(e,t.u_is_variable_anchor),u_texsize:new de(e,t.u_texsize),u_texture:new K(e,t.u_texture),u_translation:new de(e,t.u_translation),u_pitched_scale:new $(e,t.u_pitched_scale),u_is_offset:new K(e,t.u_is_offset),u_height_anchor_ground:new K(e,t.u_height_anchor_ground)}),H5=(e,t)=>({u_is_size_zoom_constant:new K(e,t.u_is_size_zoom_constant),u_is_size_feature_constant:new K(e,t.u_is_size_feature_constant),u_size_t:new $(e,t.u_size_t),u_size:new $(e,t.u_size),u_rotate_symbol:new K(e,t.u_rotate_symbol),u_label_plane_matrix:new Fi(e,t.u_label_plane_matrix),u_coord_matrix:new Fi(e,t.u_coord_matrix),u_is_text:new K(e,t.u_is_text),u_pitch_with_map:new K(e,t.u_pitch_with_map),u_is_along_line:new K(e,t.u_is_along_line),u_is_variable_anchor:new K(e,t.u_is_variable_anchor),u_texsize:new de(e,t.u_texsize),u_texture:new K(e,t.u_texture),u_gamma_scale:new $(e,t.u_gamma_scale),u_is_halo:new K(e,t.u_is_halo),u_is_plain:new K(e,t.u_is_plain),u_translation:new de(e,t.u_translation),u_pitched_scale:new $(e,t.u_pitched_scale),u_is_offset:new K(e,t.u_is_offset),u_height_anchor_ground:new K(e,t.u_height_anchor_ground)}),X5=(e,t)=>({u_is_size_zoom_constant:new K(e,t.u_is_size_zoom_constant),u_is_size_feature_constant:new K(e,t.u_is_size_feature_constant),u_size_t:new $(e,t.u_size_t),u_size:new $(e,t.u_size),u_rotate_symbol:new K(e,t.u_rotate_symbol),u_label_plane_matrix:new Fi(e,t.u_label_plane_matrix),u_coord_matrix:new Fi(e,t.u_coord_matrix),u_is_text:new K(e,t.u_is_text),u_pitch_with_map:new K(e,t.u_pitch_with_map),u_is_along_line:new K(e,t.u_is_along_line),u_is_variable_anchor:new K(e,t.u_is_variable_anchor),u_texsize:new de(e,t.u_texsize),u_texsize_icon:new de(e,t.u_texsize_icon),u_texture:new K(e,t.u_texture),u_texture_icon:new K(e,t.u_texture_icon),u_gamma_scale:new $(e,t.u_gamma_scale),u_is_halo:new K(e,t.u_is_halo),u_translation:new de(e,t.u_translation),u_pitched_scale:new $(e,t.u_pitched_scale),u_is_offset:new K(e,t.u_is_offset),u_height_anchor_ground:new K(e,t.u_height_anchor_ground)}),vx=(e,t,i,r,a,n,o,s,l,u,h,c,d,p,f)=>({u_is_size_zoom_constant:+(e==="constant"||e==="source"),u_is_size_feature_constant:+(e==="constant"||e==="camera"),u_size_t:t?t.uSizeT:0,u_size:t?t.uSize:0,u_rotate_symbol:+i,u_label_plane_matrix:s,u_coord_matrix:l,u_is_text:+h,u_pitch_with_map:+r,u_is_along_line:a,u_is_variable_anchor:n,u_texsize:c,u_texture:0,u_translation:u,u_pitched_scale:d,u_is_offset:p,u_height_anchor_ground:+f}),xx=(e,t,i,r,a,n,o,s,l,u,h,c,d,p,f,m)=>{let g=o.frameRenderContext.transform;return q(vx(e,t,i,r,a,n,o,s,l,u,h,c,p,f,m),{u_gamma_scale:r?Math.cos(g.pitch*Math.PI/180)*g.cameraToCenterDistance:1,u_is_halo:+!!d,u_is_plain:1})},Y5=(e,t,i,r,a,n,o,s,l,u,h,c,d,p,f)=>q(xx(e,t,i,r,a,n,o,s,l,u,!0,h,!0,d,p,f),{u_texsize_icon:c,u_texture_icon:1}),K5=(e,t)=>({u_opacity:new $(e,t.u_opacity),u_color:new Ar(e,t.u_color)}),J5=(e,t)=>({u_opacity:new $(e,t.u_opacity),u_image:new K(e,t.u_image),u_pattern_tl_a:new de(e,t.u_pattern_tl_a),u_pattern_br_a:new de(e,t.u_pattern_br_a),u_pattern_tl_b:new de(e,t.u_pattern_tl_b),u_pattern_br_b:new de(e,t.u_pattern_br_b),u_texsize:new de(e,t.u_texsize),u_mix:new $(e,t.u_mix),u_pattern_size_a:new de(e,t.u_pattern_size_a),u_pattern_size_b:new de(e,t.u_pattern_size_b),u_scale_a:new $(e,t.u_scale_a),u_scale_b:new $(e,t.u_scale_b),u_pixel_coord_upper:new de(e,t.u_pixel_coord_upper),u_pixel_coord_lower:new de(e,t.u_pixel_coord_lower),u_tile_units_to_pixels:new $(e,t.u_tile_units_to_pixels)}),Q5=(e,t)=>({u_opacity:e,u_color:t}),ez=(e,t,i,r,a)=>q(p5(i,a,t,r),{u_opacity:e}),tz=(e,t)=>({u_sun_pos:new Nt(e,t.u_sun_pos),u_atmosphere_blend:new $(e,t.u_atmosphere_blend),u_globe_position:new Nt(e,t.u_globe_position),u_globe_radius:new $(e,t.u_globe_radius),u_inv_proj_matrix:new Fi(e,t.u_inv_proj_matrix)}),iz=(e,t,i,r,a)=>({u_sun_pos:e,u_atmosphere_blend:t,u_globe_position:i,u_globe_radius:r,u_inv_proj_matrix:a}),rz=(e,t)=>({u_sky_color:new Ar(e,t.u_sky_color),u_horizon_color:new Ar(e,t.u_horizon_color),u_horizon:new de(e,t.u_horizon),u_horizon_normal:new de(e,t.u_horizon_normal),u_sky_horizon_blend:new $(e,t.u_sky_horizon_blend),u_sky_blend:new $(e,t.u_sky_blend),u_inv_proj_matrix:new Fi(e,t.u_inv_proj_matrix),u_globe_position:new Nt(e,t.u_globe_position),u_globe_radius:new $(e,t.u_globe_radius),u_atmosphere_blend:new $(e,t.u_atmosphere_blend)}),az=(e,t,i)=>{let r=Math.cos(t.rollInRadians),a=Math.sin(t.rollInRadians),n=Wn(t),o=t.getProjectionData({overscaledTileID:null,applyGlobeMatrix:!0,applyTerrainMatrix:!0}).projectionTransition,s=ix(t),l=Xr(t.worldSize,t.center.lat);return{u_sky_color:e["sky-color"],u_horizon_color:e["horizon-color"],u_horizon:[(t.width/2-n*a)*i,(t.height/2+n*r)*i],u_horizon_normal:[-a,r],u_sky_horizon_blend:e["sky-horizon-blend"]*t.height/2*i,u_sky_blend:o,u_inv_proj_matrix:t.inverseProjectionMatrix,u_globe_position:s,u_globe_radius:l,u_atmosphere_blend:e["atmosphere-blend"]*rx(Pi(s)-l,l)}},Ds=(e,t)=>({}),nz={fillExtrusion:f5,fillExtrusionPattern:m5,fill:_5,fillPattern:y5,fillOutline:v5,fillOutlinePattern:x5,circle:E5,collisionBox:Ds,collisionCircle:Ds,debug:S5,depth:Ds,clippingMask:Ds,heatmap:C5,heatmapTexture:P5,hillshade:A5,hillshadePrepare:I5,colorRelief:R5,line:L5,lineGradient:B5,linePattern:O5,lineSDF:j5,lineGradientSDF:V5,layerOpacity:Z5,raster:WP,symbolIcon:W5,symbolSDF:H5,symbolTextAndIcon:X5,background:K5,backgroundPattern:J5,terrain:n5,terrainDepth:o5,terrainHeight:s5,atmosphere:tz,sky:rz},oz=class{constructor(e){this.programs={},this.context=e}getProgram(e){var s;let t=e.programConfiguration?e.programConfiguration.cacheKey:"",i=`/${e.projectionShaderVariant.name}`,r=e.showOverdrawInspector?"/overdraw":"",a=e.useTerrain?"/terrain":"",n=e.defines?`/${e.defines.join("/")}`:"",o=e.name+t+i+r+a+n;return(s=this.programs)[o]||(s[o]=new d5(this.context,Zi[e.name],e.programConfiguration,nz[e.name],e.showOverdrawInspector,e.useTerrain,e.projectionShaderVariant.prelude,e.projectionShaderVariant.define,e.defines)),this.programs[o]}destroy(){for(let e of Object.values(this.programs))e.program&&this.context.gl.deleteProgram(e.program);this.programs={}}},gh=7680,Se=class{constructor(e,t,i,r,a,n){this.test=e,this.ref=t,this.mask=i,this.fail=r,this.depthFail=a,this.pass=n}};Se.disabled=new Se({func:519,mask:0},0,0,gh,gh,gh);var h_=1029,_h=2305,Ce=class{constructor(e,t,i){this.enable=e,this.mode=t,this.frontFace=i}};Ce.disabled=new Ce(!1,h_,_h),Ce.backCCW=new Ce(!0,h_,_h),Ce.frontCCW=new Ce(!0,1028,_h);var ge=class{constructor(e,t,i){this.func=e,this.mask=t,this.range=i}};ge.ReadOnly=!1,ge.ReadWrite=!0,ge.disabled=new ge(519,ge.ReadOnly,[0,1]);var Ss;function c_(e,t,i,r,a,n){let o=e.context,s=o.gl,l=n.useProgram("collisionBox"),u=[],h=0,c=0;for(let _ of r){let y=t.getTile(_).getBucket(i);if(!y)continue;let v=a?y.textCollisionBox:y.iconCollisionBox,x=y.collisionCircleArray;x.length>0&&(u.push({circleArray:x,circleOffset:c,coord:_}),h+=x.length/4,c=h),v&&l.draw(o,s.LINES,ge.disabled,Se.disabled,n.colorModeForRenderPass(),Ce.disabled,null,n.getTerrainDataForTile(_),n.getProjectionDataForTile(_),i.id,v.layoutVertexBuffer,v.indexBuffer,v.segments,null,n.transform.zoom,null,null,v.collisionVertexBuffer)}if(!a||!u.length)return;let d=n.useProgram("collisionCircle"),p=new HT;p.resize(h*4),p._trim();let f=0;for(let _ of u)for(let y=0;y<_.circleArray.length/4;y++){let v=y*4,x=_.circleArray[v+0],b=_.circleArray[v+1],w=_.circleArray[v+2],T=_.circleArray[v+3];p.emplace(f++,x,b,w,T,0),p.emplace(f++,x,b,w,T,1),p.emplace(f++,x,b,w,T,2),p.emplace(f++,x,b,w,T,3)}(!Ss||Ss.length<h*2)&&(Ss=sz(h));let m=o.createIndexBuffer(Ss,!0),g=o.createVertexBuffer(p,JD.members,!0);for(let _ of u)d.draw(o,s.TRIANGLES,ge.disabled,Se.disabled,n.colorModeForRenderPass(),Ce.disabled,null,n.getTerrainDataForTile(_.coord),null,i.id,g,m,Ye.simpleSegment(0,_.circleOffset*2,_.circleArray.length,_.circleArray.length/2),null,n.transform.zoom,null,null,null);g.destroy(),m.destroy()}function sz(e){let t=e*2,i=new YT;i.resize(t),i._trim();for(let r=0;r<t;r++){let a=r*6;i.uint16[a+0]=r*4+0,i.uint16[a+1]=r*4+1,i.uint16[a+2]=r*4+2,i.uint16[a+3]=r*4+2,i.uint16[a+4]=r*4+3,i.uint16[a+5]=r*4+0}return i}var lz=Mi(new Float32Array(16));function uz(e,t,i,r,a){if(a.currentPass!=="translucent")return;let n=Se.disabled,o=a.colorModeForRenderPass();(i._unevaluatedLayout.hasValue("text-variable-anchor")||i._unevaluatedLayout.hasValue("text-variable-anchor-offset"))&&cz(r,e,i,t,i.layout.get("text-rotation-alignment"),i.layout.get("text-pitch-alignment"),i.paint.get("text-translate"),i.paint.get("text-translate-anchor"),a.data.variableOffsets),i.paint.get("icon-opacity").constantOr(1)!==0&&d_(e,t,i,r,!1,i.paint.get("icon-translate"),i.paint.get("icon-translate-anchor"),i.layout.get("icon-rotation-alignment").constantOr("viewport"),i.layout.get("icon-pitch-alignment"),i.layout.get("icon-keep-upright"),n,o,a),i.paint.get("text-opacity").constantOr(1)!==0&&d_(e,t,i,r,!0,i.paint.get("text-translate"),i.paint.get("text-translate-anchor"),i.layout.get("text-rotation-alignment"),i.layout.get("text-pitch-alignment"),i.layout.get("text-keep-upright"),n,o,a),t.map.showCollisionBoxes&&(c_(e,t,i,r,!0,a),c_(e,t,i,r,!1,a))}function hz(e,t,i,r,a,n){let{horizontalAlign:o,verticalAlign:s}=Hl(e),l=-(o-.5)*t,u=-(s-.5)*i;return new C((l/a+r[0])*n,(u/a+r[1])*n)}function cz(e,t,i,r,a,n,o,s,l){let u=t.frameRenderContext.transform,h=t.frameRenderContext.terrain,c=a==="map",d=n==="map";for(let p of e){let f=r.getTile(p),m=f.getBucket(i);if(!m?.text?.segments.get().length)continue;let g=m.textSizeData,_=Xl(g,u.zoom),y=oi(f,1,t.frameRenderContext.transform.zoom),v=Sp(c,t.frameRenderContext.transform,y),x=i.layout.get("icon-text-fit")!=="none"&&m.hasIconData();if(_){let b=2**(u.zoom-f.tileID.overscaledZ),w=h?(T,E)=>h.getElevation(p,T,E):void 0;pz(m,c,d,l,u,v,b,_,x,Sr(u,f,o,s),p.toUnwrapped(),w,i.layout.get("symbol-height-anchor")==="ground")}}}function dz(e,t,i,r,a,n){let o=t.tileAnchorPoint.add(new C(t.translation[0],t.translation[1]));if(t.pitchWithMap){let s=r.mult(n);i||(s=s.rotate(-a));let l=o.add(s);return Pp(l.x,l.y,t.pitchedLabelPlaneMatrix,ia(t,l.x,l.y)).point}if(i){let s=ra(t.tileAnchorPoint.x+1,t.tileAnchorPoint.y,t).point.sub(e),l=Math.atan(s.y/s.x)+(s.x<0?Math.PI:0);return e.add(r.rotate(l))}return e.add(r)}function pz(e,t,i,r,a,n,o,s,l,u,h,c,d){let p=e.text.placedSymbolArray,f=e.text.dynamicLayoutVertexArray,m=e.icon.dynamicLayoutVertexArray,g={};f.clear();for(let _=0;_<p.length;_++){let y=p.get(_),v=e.allowVerticalPlacement&&!y.placedOrientation,x=!y.hidden&&y.crossTileID&&!v?r[y.crossTileID]:null;if(!x)Na(y.numGlyphs,f);else{let b=new C(y.anchorX,y.anchorY),w={getElevation:c,heightOffset:y.heightOffset,heightAnchorGround:d,width:a.width,height:a.height,pitchedLabelPlaneMatrix:n,lineVertexArray:null,pitchWithMap:i,transform:a,projectionCache:null,tileAnchorPoint:b,translation:u,unwrappedTileID:h},T=i?$v(b.x,b.y,w):ra(b.x,b.y,w),E=Vv(a.cameraToCenterDistance,T.signedDistanceFromCamera),S=ep(e.textSizeData,s,y)*E/24;i&&(S*=e.tilePixelRatio/o);let{width:M,height:z,anchor:R,textOffset:I,textBoxScale:D}=x,P=hz(R,M,z,I,D,S),A=a.getPitchedTextCorrection(b.x+u[0],b.y+u[1],h),B=dz(T.point,w,t,P,-a.bearingInRadians,A),j=e.allowVerticalPlacement&&y.placedOrientation===2?Math.PI/2:0;for(let V=0;V<y.numGlyphs;V++)fl(f,B,j);l&&y.associatedIconIndex>=0&&(g[y.associatedIconIndex]={shiftedAnchor:B,angle:j})}}if(l){m.clear();let _=e.icon.placedSymbolArray;for(let y=0;y<_.length;y++){let v=_.get(y);if(v.hidden)Na(v.numGlyphs,m);else{let x=g[y];if(!x)Na(v.numGlyphs,m);else for(let b=0;b<v.numGlyphs;b++)fl(m,x.shiftedAnchor,x.angle)}}e.icon.dynamicLayoutVertexBuffer.updateData(m)}e.text.dynamicLayoutVertexBuffer.updateData(f)}function fz(e,t,i){return i.iconsInText&&t?"symbolTextAndIcon":e?"symbolSDF":"symbolIcon"}function d_(e,t,i,r,a,n,o,s,l,u,h,c,d){let p=e.context,f=p.gl,m=d.transform,g=s==="map",_=l==="map",y=s!=="viewport"&&i.layout.get("symbol-placement")!=="point",v=g&&!_&&!y,x=!i.layout.get("symbol-sort-key").isConstant(),b=!1,w=d.getDepthModeForSublayer(0,ge.ReadOnly),T=i._unevaluatedLayout.hasValue("text-variable-anchor")||i._unevaluatedLayout.hasValue("text-variable-anchor-offset"),E=[],S=m.getCircleRadiusCorrection();for(let R of r){let I=t.getTile(R),D=I.getBucket(i);if(!D)continue;let P=a?D.text:D.icon;if(!P?.segments.get().length||!P.hasVisibleVertices)continue;let A=P.programConfigurations.get(i.id),B=a||D.sdfIcons,j=a?D.textSizeData:D.iconSizeData,V=_||m.pitch!==0,J=d.useProgram(fz(B,a,D),A),se=Xl(j,m.zoom),fe=d.getTerrainDataForTile(R),ye,Ge=[0,0],Le,Ze,ke=null,Tt;if(a){if(Le=I.glyphAtlasTexture,Ze=f.LINEAR,ye=I.glyphAtlasTexture.size,D.iconsInText){Ge=I.imageAtlasTexture.size,ke=I.imageAtlasTexture;let Z=j.kind==="composite"||j.kind==="camera";Tt=V||d.data.rotating||d.data.zooming||Z?f.LINEAR:f.NEAREST}}else{let Z=i.layout.get("icon-size").constantOr(0)!==1||D.iconsNeedLinear;Le=I.imageAtlasTexture,Ze=B||d.data.rotating||d.data.zooming||Z||V?f.LINEAR:f.NEAREST,ye=I.imageAtlasTexture.size}let zt=oi(I,1,d.transform.zoom),Ut=Sp(g,d.transform,zt),$t=d3(_,g,d.transform,zt),Et=Sr(m,I,n,o),nt=d.getProjectionDataForTile(R),Jt=T&&D.hasTextData(),Ti=i.layout.get("icon-text-fit")!=="none"&&Jt&&D.hasIconData(),ui=i._unevaluatedLayout.hasValue("icon-offset"),W=i.layout.get("symbol-height-anchor")==="ground";if(y){let Z=na();l3(Z,Ut);let xe=d.terrain?(Be,Te)=>d.terrain.getElevation(R,Be,Te):void 0;f3(D,e,a,Ut,Z,_,u,i.layout.get("text-rotation-alignment")==="map",R.toUnwrapped(),m.width,m.height,Et,xe)}let ce=a&&T||Ti,re=_?Ut:d.transform.clipSpaceToPixelsMatrix,O=y||ce?lz:re,we=B&&i.paint.get(a?"text-halo-width":"icon-halo-width").constantOr(1)!==0,H;H=B?D.iconsInText?Y5(j.kind,se,v,_,y,ce,e,O,$t,Et,ye,Ge,S,ui,W):xx(j.kind,se,v,_,y,ce,e,O,$t,Et,a,ye,we,S,ui,W):vx(j.kind,se,v,_,y,ce,e,O,$t,Et,a,ye,S,ui,W);let te={program:J,buffers:P,uniformValues:H,projectionData:nt,atlasTexture:Le,atlasTextureIcon:ke,atlasInterpolation:Ze,atlasInterpolationIcon:Tt,isSDF:B,hasHalo:we};if(x&&D.canOverlap){b=!0;let Z=P.segments.get();for(let xe of Z)E.push({segments:new Ye([xe]),sortKey:xe.sortKey,state:te,terrainData:fe})}else E.push({segments:P.segments,sortKey:0,state:te,terrainData:fe})}b&&E.sort((R,I)=>R.sortKey-I.sortKey);let M=i.paint.get(a?"text-halo-width":"icon-halo-width").constantOr(null)??1/0,z=i.layout.get("text-letter-spacing").constantOr(0)*24<0||M>1;for(let R of E){let I=R.state;p.activeTexture.set(f.TEXTURE0),I.atlasTexture.bind(I.atlasInterpolation,f.CLAMP_TO_EDGE),I.atlasTextureIcon&&(p.activeTexture.set(f.TEXTURE1),I.atlasTextureIcon&&I.atlasTextureIcon.bind(I.atlasInterpolationIcon,f.CLAMP_TO_EDGE));let D=I.isSDF&&I.hasHalo;if(D){let P=I.uniformValues;P.u_is_halo=1,z&&(P.u_is_plain=0,p_(I.buffers,R.segments,i,e,I.program,w,h,c,P,I.projectionData,R.terrainData),P.u_is_halo=0,P.u_is_plain=1)}p_(I.buffers,R.segments,i,e,I.program,w,h,c,I.uniformValues,I.projectionData,R.terrainData),D&&!z&&(I.uniformValues.u_is_halo=0)}}function p_(e,t,i,r,a,n,o,s,l,u,h){let c=r.context,d=c.gl;a.draw(c,d.TRIANGLES,n,o,s,Ce.backCCW,l,h,u,i.id,e.layoutVertexBuffer,e.indexBuffer,t,i.paint,r.frameRenderContext.transform.zoom,e.programConfigurations.get(i.id),e.dynamicLayoutVertexBuffer,e.opacityVertexBuffer)}function mz(e,t,i,r,a){if(a.currentPass!=="translucent")return;let n=i.paint.get("circle-opacity"),o=i.paint.get("circle-stroke-width"),s=i.paint.get("circle-stroke-opacity"),l=!i.layout.get("circle-sort-key").isConstant();if(n.constantOr(1)===0&&(o.constantOr(1)===0||s.constantOr(1)===0))return;let u=e.context,h=u.gl,c=a.transform,d=a.getDepthModeForSublayer(0,ge.ReadOnly),p=Se.disabled,f=a.colorModeForRenderPass(),m=[],g=c.getCircleRadiusCorrection();for(let _ of r){let y=t.getTile(_),v=y.getBucket(i);if(!v)continue;let x=Sr(c,y,i.paint.get("circle-translate"),i.paint.get("circle-translate-anchor")),b=v.programConfigurations.get(i.id),w=a.useProgram("circle",b),T=v.layoutVertexBuffer,E=v.indexBuffer,S=a.getTerrainDataForTile(_),M={programConfiguration:b,program:w,layoutVertexBuffer:T,indexBuffer:E,uniformValues:D5(e,y,i,x,g),terrainData:S,projectionData:a.getProjectionDataForTile(_)};if(l){let z=v.segments.get();for(let R of z)m.push({segments:new Ye([R]),sortKey:R.sortKey,state:M})}else m.push({segments:v.segments,sortKey:0,state:M})}l&&m.sort((_,y)=>_.sortKey-y.sortKey);for(let _ of m){let{programConfiguration:y,program:v,layoutVertexBuffer:x,indexBuffer:b,uniformValues:w,terrainData:T,projectionData:E}=_.state,S=_.segments;v.draw(u,h.TRIANGLES,d,p,f,Ce.backCCW,w,T,E,i.id,x,b,S,i.paint,a.transform.zoom,y)}}function gz(e,t,i,r,a){if(i.paint.get("heatmap-opacity")===0)return;let n=e.context;if(a.terrain){for(let o of r){let s=t.getTile(o);t.hasRenderableParent(o)||(a.currentPass==="offscreen"?vz(e,s,i,o,a):a.currentPass==="translucent"&&xz(e,i,o,a))}n.viewport.set([0,0,e.width,e.height])}else a.currentPass==="offscreen"?_z(e,t,i,r,a):a.currentPass==="translucent"&&yz(e,i)}function _z(e,t,i,r,a){let n=e.context,o=n.gl,s=a.transform,l=Se.disabled,u=new et([o.ONE,o.ONE],oe.transparent,[!0,!0,!0,!0]);bz(n,e,i),n.clear({color:oe.transparent});for(let h of r){if(t.hasRenderableParent(h))continue;let c=t.getTile(h),d=c.getBucket(i);if(!d)continue;let p=d.programConfigurations.get(i.id),f=a.useProgram("heatmap",p),m=a.getProjectionDataForTile(h,{applyTerrainMatrix:!1}),g=s.getCircleRadiusCorrection();f.draw(n,o.TRIANGLES,ge.disabled,l,u,Ce.backCCW,gx(c,s.zoom,i.paint.get("heatmap-intensity"),g),null,m,i.id,d.layoutVertexBuffer,d.indexBuffer,d.segments,i.paint,s.zoom,p)}n.viewport.set([0,0,e.width,e.height])}function yz(e,t){let i=e.context,r=i.gl;i.setColorMode(e.frameRenderContext.colorModeForRenderPass());let a=t.heatmapFbos.get(nl);a&&(i.activeTexture.set(r.TEXTURE0),r.bindTexture(r.TEXTURE_2D,a.colorAttachment.get()),i.activeTexture.set(r.TEXTURE1),wx(i,t).bind(r.LINEAR,r.CLAMP_TO_EDGE),e.frameRenderContext.useProgram("heatmapTexture").draw(i,r.TRIANGLES,ge.disabled,Se.disabled,e.frameRenderContext.colorModeForRenderPass(),Ce.disabled,_x(e,t,0,1),null,null,t.id,e.viewportBuffer,e.quadTriangleIndexBuffer,e.viewportSegments,t.paint,e.frameRenderContext.transform.zoom))}function vz(e,t,i,r,a){let n=e.context,o=n.gl,s=Se.disabled,l=new et([o.ONE,o.ONE],oe.transparent,[!0,!0,!0,!0]),u=t.getBucket(i);if(!u)return;let h=r.key,c=i.heatmapFbos.get(h);c||(c=bx(n,t.tileSize,t.tileSize),i.heatmapFbos.set(h,c)),n.bindFramebuffer.set(c.framebuffer),n.viewport.set([0,0,t.tileSize,t.tileSize]),n.clear({color:oe.transparent});let d=u.programConfigurations.get(i.id),p=a.useProgram("heatmap",d,!a.data.isRenderingGlobe),f=a.getProjectionDataForTile(t.tileID),m=a.getTerrainDataForTile(r);p.draw(n,o.TRIANGLES,ge.disabled,s,l,Ce.disabled,gx(t,a.transform.zoom,i.paint.get("heatmap-intensity"),1),m,f,i.id,u.layoutVertexBuffer,u.indexBuffer,u.segments,i.paint,a.transform.zoom,d)}function xz(e,t,i,r){let a=e.context,n=a.gl,o=r.transform;a.setColorMode(r.colorModeForRenderPass());let s=wx(a,t),l=i.key,u=t.heatmapFbos.get(l);if(!u)return;a.activeTexture.set(n.TEXTURE0),n.bindTexture(n.TEXTURE_2D,u.colorAttachment.get()),a.activeTexture.set(n.TEXTURE1),s.bind(n.LINEAR,n.CLAMP_TO_EDGE);let h=r.getProjectionDataForTile(i,{applyTerrainMatrix:r.data.isRenderingGlobe});r.useProgram("heatmapTexture").draw(a,n.TRIANGLES,ge.disabled,Se.disabled,r.colorModeForRenderPass(),Ce.disabled,_x(e,t,0,1),null,h,t.id,e.rasterBoundsBuffer,e.quadTriangleIndexBuffer,e.rasterBoundsSegments,t.paint,o.zoom),u.destroy(),t.heatmapFbos.delete(l)}function bz(e,t,i){let r=e.gl;e.activeTexture.set(r.TEXTURE1),e.viewport.set([0,0,t.width/4,t.height/4]);let a=i.heatmapFbos.get(nl);a?(r.bindTexture(r.TEXTURE_2D,a.colorAttachment.get()),e.bindFramebuffer.set(a.framebuffer)):(a=bx(e,t.width/4,t.height/4),i.heatmapFbos.set(nl,a))}function bx(e,t,i){let r=e.gl,a=r.createTexture();r.bindTexture(r.TEXTURE_2D,a),r.texParameteri(r.TEXTURE_2D,r.TEXTURE_WRAP_S,r.CLAMP_TO_EDGE),r.texParameteri(r.TEXTURE_2D,r.TEXTURE_WRAP_T,r.CLAMP_TO_EDGE),r.texParameteri(r.TEXTURE_2D,r.TEXTURE_MIN_FILTER,r.LINEAR),r.texParameteri(r.TEXTURE_2D,r.TEXTURE_MAG_FILTER,r.LINEAR),r.texStorage2D(r.TEXTURE_2D,1,r.RGBA16F,t,i);let n=e.createFramebuffer(t,i,!1,!1);return n.colorAttachment.set(a),n}function wx(e,t){return t.colorRampTexture||(t.colorRampTexture=new pt(e,t.colorRamp,e.gl.RGBA)),t.colorRampTexture}function Tx(e,t,i){let r=e.context,a=r.bindFramebuffer.get(),n=r.viewport.get(),[,,o,s]=n;return wz(e,o,s),r.viewport.set([0,0,o,s]),r.clear({color:oe.transparent,depth:1,stencil:0}),e.frameRenderContext.invalidateTileClippingMasks(),e.frameRenderContext.renderTileClippingMasks(t,i),{compositeTarget:a,compositeViewport:n}}function wz(e,t,i){let r=e.context.gl;if(!e.layerOpacityFbo){let n=e.context.createFramebuffer(t,i,!0,!0),o=r.createTexture();r.bindTexture(r.TEXTURE_2D,o),r.texParameteri(r.TEXTURE_2D,r.TEXTURE_WRAP_S,r.CLAMP_TO_EDGE),r.texParameteri(r.TEXTURE_2D,r.TEXTURE_WRAP_T,r.CLAMP_TO_EDGE),r.texParameteri(r.TEXTURE_2D,r.TEXTURE_MIN_FILTER,r.LINEAR),r.texParameteri(r.TEXTURE_2D,r.TEXTURE_MAG_FILTER,r.LINEAR),r.texImage2D(r.TEXTURE_2D,0,r.RGBA,t,i,0,r.RGBA,r.UNSIGNED_BYTE,null),n.colorAttachment.set(o),n.depthAttachment.set(e.context.createRenderbuffer(r.DEPTH_STENCIL,t,i)),e.layerOpacityFbo=n,e.context.bindFramebuffer.set(e.layerOpacityFbo.framebuffer);return}if(e.layerOpacityFbo.width===t&&e.layerOpacityFbo.height===i){e.context.bindFramebuffer.set(e.layerOpacityFbo.framebuffer);return}let a=e.layerOpacityFbo;r.bindTexture(r.TEXTURE_2D,a.colorAttachment.get()),r.texImage2D(r.TEXTURE_2D,0,r.RGBA,t,i,0,r.RGBA,r.UNSIGNED_BYTE,null),e.context.bindRenderbuffer.set(a.depthAttachment.get()),r.renderbufferStorage(r.RENDERBUFFER,r.DEPTH_STENCIL,t,i),e.context.bindRenderbuffer.set(null),a.width=t,a.height=i,e.context.bindFramebuffer.set(a.framebuffer)}function Ex(e,t,i,r){let a=e.context,n=a.gl;a.bindFramebuffer.set(i.compositeTarget),a.viewport.set(i.compositeViewport),a.activeTexture.set(n.TEXTURE0),n.bindTexture(n.TEXTURE_2D,e.layerOpacityFbo.colorAttachment.get()),e.frameRenderContext.useProgram("layerOpacity").draw(a,n.TRIANGLES,ge.disabled,Se.disabled,e.frameRenderContext.colorModeForRenderPass(),Ce.disabled,q5(t,0),null,null,r.id,e.viewportBuffer,e.quadTriangleIndexBuffer,e.viewportSegments,r.paint,e.frameRenderContext.transform.zoom),e.frameRenderContext.invalidateTileClippingMasks()}function Dx(e,t,i,r,a,n,o,s){let l=256;if(a.stepInterpolant){let u=t.getSource().maxzoom,h=o.canonical.z===u?Math.ceil(1<<e.frameRenderContext.transform.maxZoom-o.canonical.z):1;l=ie(Jb(n.maxLineLength/k*1024*h),256,i.maxTextureSize)}return s.gradient=Y0({expression:a.gradientExpression(),evaluationKey:"lineProgress",resolution:l,image:s.gradient||void 0,clips:n.lineClipsArray}),s.texture?s.texture.update(s.gradient):s.texture=new pt(i,s.gradient,r.RGBA),s.version=a.gradientVersion,s.texture}function Tz(e,t,i,r,a){e.activeTexture.set(t.TEXTURE0),i.imageAtlasTexture.bind(t.LINEAR,t.CLAMP_TO_EDGE),r.updatePaintBuffers(a)}function Ez(e,t,i,r,a,n){(a||e.lineAtlas.dirty)&&(t.activeTexture.set(i.TEXTURE0),e.lineAtlas.bind(t)),r.updatePaintBuffers(n)}function Dz(e,t,i,r,a,n,o){let s=n.gradients[a.id],l=s.texture;a.gradientVersion!==s.version&&(l=Dx(e,t,i,r,a,n,o,s)),i.activeTexture.set(r.TEXTURE0),l.bind(a.stepInterpolant?r.NEAREST:r.LINEAR,r.CLAMP_TO_EDGE)}function Sz(e,t,i,r,a,n,o,s,l){let u=n.gradients[a.id],h=u.texture;a.gradientVersion!==u.version&&(h=Dx(e,t,i,r,a,n,o,u)),i.activeTexture.set(r.TEXTURE0),h.bind(a.stepInterpolant?r.NEAREST:r.LINEAR,r.CLAMP_TO_EDGE),i.activeTexture.set(r.TEXTURE1),e.lineAtlas.bind(i),s.updatePaintBuffers(l)}function Cz(e,t,i,r,a){if(a.currentPass!=="translucent")return;let n=i.paint.get("line-opacity"),o=i.paint.get("line-width"),s=i.paint.get("line-layer-opacity");if(n.constantOr(1)!==0&&o.constantOr(1)!==0&&s!==0){if(s<1){let l=Tx(e,i,r);f_(e,t,i,r,a),Ex(e,s,l,i);return}f_(e,t,i,r,a)}}function f_(e,t,i,r,a){let n=a.getDepthModeForSublayer(0,ge.ReadOnly),o=a.colorModeForRenderPass(),s=i.paint.get("line-dasharray"),l=s.constantOr(1),u=i.paint.get("line-pattern"),h=u.constantOr(1),c=i.paint.get("line-gradient"),d=i.getCrossfadeParameters(),p;p=h?"linePattern":l&&c?"lineGradientSDF":l?"lineSDF":c?"lineGradient":"line";let f=e.context,m=f.gl,g=a.transform,_=!0;for(let y of r){let v=t.getTile(y);if(h&&!v.patternsLoaded())continue;let x=v.getBucket(i);if(!x)continue;let b=x.programConfigurations.get(i.id),w=e.context.program.get(),T=a.useProgram(p,b),E=_||T.program!==w,S=a.getTerrainDataForTile(y),M=u.constantOr(null),z=s?.constantOr(null);if(M&&v.imageAtlas){let A=v.imageAtlas,B=A.patternPositions[M.to.toString()],j=A.patternPositions[M.from.toString()];B&&j&&b.setConstantPatternPositions(B,j)}else if(z){let A=i.layout.get("line-cap").constantOr(null)==="round",B=e.lineAtlas.getDash(z.to,A),j=e.lineAtlas.getDash(z.from,A);b.setConstantDashPositions(B,j)}let R=a.getProjectionDataForTile(y),I=g.getPixelScale(),D;h?(D=U5(e,v,i,I,d),Tz(f,m,v,b,d)):l&&c?(D=G5(e,v,i,I,d,x.lineClipsArray.length),Sz(e,t,f,m,i,x,y,b,d)):l?(D=$5(e,v,i,I,d),Ez(e,f,m,b,E,d)):c?(D=N5(e,v,i,I,x.lineClipsArray.length),Dz(e,t,f,m,i,x,y)):D=iu(e,v,i,I);let P=a.stencilModeForClipping(y);T.draw(f,m.TRIANGLES,n,P,o,Ce.disabled,D,S,R,i.id,x.layoutVertexBuffer,x.indexBuffer,x.segments,i.paint,a.transform.zoom,b,x.layoutVertexBuffer2),_=!1}}function Sx(e,t,i,r,a){if(!i||!r?.imageAtlas)return;let n=r.imageAtlas.patternPositions,o=n[i.to.toString()],s=n[i.from.toString()];if(!o&&s&&(o=s),!s&&o&&(s=o),!o||!s){let l=a.getPaintProperty(t);o=n[l],s=n[l]}o&&s&&e.setConstantPatternPositions(o,s)}function Pz(e,t,i,r,a){let n=i.paint.get("fill-color"),o=i.paint.get("fill-opacity"),s=i.paint.get("fill-layer-opacity");if(o.constantOr(1)===0||s===0)return;if(s<1){if(a.currentPass!=="translucent")return;let h=Tx(e,i,r);m_(e,t,i,r,a),Ex(e,s,h,i);return}let l=i.paint.get("fill-pattern"),u=a.opaquePassEnabledForLayer()&&!l.constantOr(1)&&n.constantOr(oe.transparent).a===1&&o.constantOr(0)===1;if(u&&a.currentPass==="opaque"){let h=a.colorModeForRenderPass();Lp(e,t,i,r,a.getDepthModeForSublayer(1,ge.ReadWrite),h,!1,a);return}if(u&&a.currentPass==="translucent"){Cx(e,t,i,r,a);return}a.currentPass==="translucent"&&m_(e,t,i,r,a)}function m_(e,t,i,r,a){let n=a.colorModeForRenderPass();Lp(e,t,i,r,a.getDepthModeForSublayer(1,ge.ReadOnly),n,!1,a),Cx(e,t,i,r,a)}function Cx(e,t,i,r,a){if(!i.paint.get("fill-antialias"))return;let n=a.colorModeForRenderPass();Lp(e,t,i,r,a.getDepthModeForSublayer(i.getPaintProperty("fill-outline-color")?2:0,ge.ReadOnly),n,!0,a)}function Lp(e,t,i,r,a,n,o,s){let l=e.context.gl,u="fill-pattern",h=i.paint.get(u),c=h?.constantOr(1),d=i.getCrossfadeParameters(),p,f,m,g,_,y=s.transform,v=i.paint.get("fill-translate"),x=i.paint.get("fill-translate-anchor");o?(f=c&&!i.getPaintProperty("fill-outline-color")?"fillOutlinePattern":"fillOutline",p=l.LINES):(f=c?"fillPattern":"fill",p=l.TRIANGLES);let b=h.constantOr(null);for(let w of r){let T=t.getTile(w);if(c&&!T.patternsLoaded())continue;let E=T.getBucket(i);if(!E)continue;let S=E.sdfPatterns[i.id]??!1,M=E.programConfigurations.get(i.id),z=s.useProgram(f,M),R=s.getTerrainDataForTile(w);c&&(e.context.activeTexture.set(l.TEXTURE0),T.imageAtlasTexture.bind(l.LINEAR,l.CLAMP_TO_EDGE),M.updatePaintBuffers(d)),Sx(M,u,b,T,i);let I=s.getProjectionDataForTile(w),D=Sr(y,T,v,x);o?(g=E.indexBuffer2,_=E.segments2,m=f==="fillOutlinePattern"&&c?T5(e,d,T,D,S):w5(D)):(g=E.indexBuffer,_=E.segments,m=c?mx(e,d,T,D,S):b5(D));let P=s.stencilModeForClipping(w);z.draw(e.context,p,a,P,n,Ce.backCCW,m,R,I,i.id,E.layoutVertexBuffer,g,_,i.paint,s.transform.zoom,M)}}function Az(e,t,i,r,a){let n=i.paint.get("fill-extrusion-opacity");if(n!==0&&a.currentPass==="translucent"){let o=new ge(e.context.gl.LEQUAL,ge.ReadWrite,a.depthRangeFor3D);if(n===1&&!i.paint.get("fill-extrusion-pattern").constantOr(1)){let s=a.colorModeForRenderPass();yh(e,t,i,r,o,Se.disabled,s,a)}else yh(e,t,i,r,o,Se.disabled,et.disabled,a),yh(e,t,i,r,o,a.stencilModeFor3D(),a.colorModeForRenderPass(),a)}}function yh(e,t,i,r,a,n,o,s){let l=e.context,u=l.gl,h="fill-extrusion-pattern",c=i.paint.get(h),d=c.constantOr(1),p=i.getCrossfadeParameters(),f=i.paint.get("fill-extrusion-opacity"),m=c.constantOr(null),g=s.transform;for(let _ of r){let y=t.getTile(_),v=y.getBucket(i);if(!v)continue;let x=s.getTerrainDataForTile(_),b=v.programConfigurations.get(i.id),w=s.useProgram(d?"fillExtrusionPattern":"fillExtrusion",b);d&&(e.context.activeTexture.set(u.TEXTURE0),y.imageAtlasTexture.bind(u.LINEAR,u.CLAMP_TO_EDGE),b.updatePaintBuffers(p));let T=s.getProjectionDataForTile(_);Sx(b,h,m,y,i);let E=Sr(g,y,i.paint.get("fill-extrusion-translate"),i.paint.get("fill-extrusion-translate-anchor")),S=i.paint.get("fill-extrusion-vertical-gradient"),M=d?g5(e,s.data.light,S,f,E,_,p,y):fx(e,s.data.light,S,f,E);w.draw(l,l.gl.TRIANGLES,a,n,o,Ce.backCCW,M,x,T,i.id,v.layoutVertexBuffer,v.indexBuffer,v.segments,i.paint,s.transform.zoom,b,s.terrain&&v.centroidVertexBuffer)}}function Iz(e,t,i,r,a){if(a.currentPass!=="offscreen"&&a.currentPass!=="translucent")return;let n=e.context,{useSubdivision:o}=a.data,s=a.getDepthModeForSublayer(0,ge.ReadOnly),l=a.colorModeForRenderPass();if(a.currentPass==="offscreen")Mz(e,t,r,i,s,Se.disabled,l),n.viewport.set([0,0,e.width,e.height]);else if(a.currentPass==="translucent")if(o){let[u,h,c]=a.stencilConfigForOverlapTwoPass(r);vh(e,t,i,c,u,s,l,!1,a),vh(e,t,i,c,h,s,l,!0,a)}else{let[u,h]=a.getStencilConfigForOverlapAndUpdateStencilID(r);vh(e,t,i,h,u,s,l,!1,a)}}function vh(e,t,i,r,a,n,o,s,l){let u=e.context,h=u.gl,c=[`#define NUM_ILLUMINATION_SOURCES ${i.paint.get("hillshade-highlight-color").values.length}`],d=l.useProgram("hillshade",null,!1,c),p=!l.data.moving;for(let f of r){let m=t.getTile(f),g=m.fbo;if(!g)continue;let _=l.getMeshFromTileID(f.canonical,s,!0,"raster"),y=l.getTerrainDataForTile(f);u.activeTexture.set(h.TEXTURE0),h.bindTexture(h.TEXTURE_2D,g.colorAttachment.get());let v=l.getProjectionDataForTile(f,{aligned:p});d.draw(u,h.TRIANGLES,n,a[f.overscaledZ],o,Ce.backCCW,M5(e,m,i),y,v,i.id,_.vertexBuffer,_.indexBuffer,_.segments)}}function Mz(e,t,i,r,a,n,o){let s=e.context,l=s.gl,u=r.paint.get("resampling")==="nearest"?l.NEAREST:l.LINEAR;for(let h of i){let c=t.getTile(h),d=c.dem;if(!d?.data||!c.needsHillshadePrepare)continue;let p=d.dim+2,f=d.stride,m=d.getPixels();if(s.activeTexture.set(l.TEXTURE1),s.pixelStoreUnpackPremultiplyAlpha.set(!1),c.demTexture||(c.demTexture=e.getTileTexture(f)),c.demTexture){let _=c.demTexture;_.update(m,{premultiply:!1}),_.bind(l.NEAREST,l.CLAMP_TO_EDGE)}else c.demTexture=new pt(s,m,l.RGBA,{premultiply:!1}),c.demTexture.bind(l.NEAREST,l.CLAMP_TO_EDGE);s.activeTexture.set(l.TEXTURE0);let g=c.fbo;if(!g){let _=new pt(s,{width:p,height:p,data:null},l.RGBA);_.bind(u,l.CLAMP_TO_EDGE),g=c.fbo=s.createFramebuffer(p,p,!0,!1),g.colorAttachment.set(_.texture)}s.bindFramebuffer.set(g.framebuffer),s.viewport.set([0,0,p,p]),e.frameRenderContext.useProgram("hillshadePrepare").draw(s,l.TRIANGLES,a,n,o,Ce.disabled,F5(c.tileID,d),null,null,r.id,e.rasterBoundsBuffer,e.quadTriangleIndexBuffer,e.rasterBoundsSegments),c.needsHillshadePrepare=!1}}function Fz(e,t,i,r,a){if(a.currentPass!=="translucent"||!r.length)return;let{useSubdivision:n}=a.data,o=a.getDepthModeForSublayer(0,ge.ReadOnly),s=a.colorModeForRenderPass();if(n){let[l,u,h]=a.stencilConfigForOverlapTwoPass(r);bh(e,t,i,h,l,o,s,!1,a),bh(e,t,i,h,u,o,s,!0,a)}else{let[l,u]=a.getStencilConfigForOverlapAndUpdateStencilID(r);bh(e,t,i,u,l,o,s,!1,a)}}var xh=0;function bh(e,t,i,r,a,n,o,s,l){let u=e.context,h=u.gl,c=l.useProgram("colorRelief"),d=!l.data.moving,p=i.paint.get("resampling")==="nearest"?h.NEAREST:h.LINEAR,f=!0,m=0;for(let g of r){let _=t.getTile(g),y=_.dem;if(!y?.data)continue;if(f){xh||(xh=h.getParameter(h.MAX_TEXTURE_SIZE));let T=xh,{elevationTexture:E,colorTexture:S}=i.getColorRampTextures(u,T,y.getUnpackVector());u.activeTexture.set(h.TEXTURE1),E.bind(h.NEAREST,h.CLAMP_TO_EDGE),u.activeTexture.set(h.TEXTURE4),S.bind(h.LINEAR,h.CLAMP_TO_EDGE),f=!1,m=E.size[0]}let v=y.stride;u.activeTexture.set(h.TEXTURE0),(!_.demTexture||_.needsColorReliefPrepare)&&(u.pixelStoreUnpackPremultiplyAlpha.set(!1),_.demTexture||(_.demTexture=e.getTileTexture(v)??new pt(u,{width:v,height:v,data:null},h.RGBA)),_.demTexture.update(y.getPixels(),{premultiply:!1}),_.needsColorReliefPrepare=!1),_.demTexture.bind(p,h.CLAMP_TO_EDGE);let x=l.getMeshFromTileID(g.canonical,s,!0,"raster"),b=l.getTerrainDataForTile(g),w=l.getProjectionDataForTile(g,{aligned:d});c.draw(u,h.TRIANGLES,n,a[g.overscaledZ],o,Ce.backCCW,k5(i,_.dem,m),b,w,i.id,x.vertexBuffer,x.indexBuffer,x.segments)}}var wh=[new C(0,0),new C(k,0),new C(k,k),new C(0,k)];function zz(e,t,i,r,a){if(a.currentPass!=="translucent"||i.paint.get("raster-opacity")===0||!r.length)return;let n=t.getSource(),{useSubdivision:o}=a.data;if(n instanceof an)Cs(e,t,i,r,null,!1,!1,n.tileCoords,n.imageWarp,n.flippedWindingOrder,a,n.getMesh(e.context,o));else if(o){let[s,l,u]=a.stencilConfigForOverlapTwoPass(r);Cs(e,t,i,u,s,!1,!0,wh,ja,!1,a),Cs(e,t,i,u,l,!0,!0,wh,ja,!1,a)}else{let[s,l]=a.getStencilConfigForOverlapAndUpdateStencilID(r);Cs(e,t,i,l,s,!1,!0,wh,ja,!1,a)}}function Cs(e,t,i,r,a,n,o,s,l,u=!1,h,c=null){let d=r[r.length-1].overscaledZ,p=e.context,f=p.gl,m=h.useProgram("raster"),g=h.colorModeForRenderPass(),_=!h.data.moving,y=i.paint.get("raster-opacity"),v=i.paint.get("resampling")==="nearest"||i.paint.get("raster-resampling")==="nearest"?f.NEAREST:f.LINEAR,x=i.paint.get("raster-fade-duration"),b=!!h.terrain;for(let w of r){let T=h.getDepthModeForSublayer(w.overscaledZ-d,y===1?ge.ReadWrite:ge.ReadOnly,f.LESS),E=t.getTile(w);p.activeTexture.set(f.TEXTURE0),E.texture.bind(v,f.CLAMP_TO_EDGE,f.LINEAR_MIPMAP_NEAREST),p.activeTexture.set(f.TEXTURE1);let{parentTile:S,parentScaleBy:M,parentTopLeft:z,fadeValues:R}=Rz(E,t,x,b);E.fadeOpacity=R.tileOpacity,S?(S.fadeOpacity=R.parentTileOpacity,S.texture.bind(v,f.CLAMP_TO_EDGE,f.LINEAR_MIPMAP_NEAREST)):E.texture.bind(v,f.CLAMP_TO_EDGE,f.LINEAR_MIPMAP_NEAREST),E.texture.useMipmap&&p.extTextureFilterAnisotropic&&h.transform.pitch>h.data.anisotropicFilterPitch&&f.texParameterf(f.TEXTURE_2D,p.extTextureFilterAnisotropic.TEXTURE_MAX_ANISOTROPY_EXT,p.extTextureFilterAnisotropicMax);let I=h.getTerrainDataForTile(w),D=h.getProjectionDataForTile(w,{aligned:_}),P=HP(z,M,R.fadeMix,i,s,l),A=c??h.getMeshFromTileID(w.canonical,n,o,"raster"),B=a?a[w.overscaledZ]:Se.disabled;m.draw(p,f.TRIANGLES,T,B,g,u?Ce.frontCCW:Ce.backCCW,P,I,D,i.id,A.vertexBuffer,A.indexBuffer,A.segments)}}function Rz(e,t,i,r){let a={parentTile:null,parentScaleBy:1,parentTopLeft:[0,0],fadeValues:{tileOpacity:1,parentTileOpacity:1,fadeMix:{opacity:1,mix:0}}};if(i===0||r)return a;if(e.fadingParentID){let n=t.getLoadedTile(e.fadingParentID);if(!n)return a;let o=2**(n.tileID.overscaledZ-e.tileID.overscaledZ);return{parentTile:n,parentScaleBy:o,parentTopLeft:[e.tileID.canonical.x*o%1,e.tileID.canonical.y*o%1],fadeValues:kz(e,n,i)}}return e.selfFading?{parentTile:null,parentScaleBy:1,parentTopLeft:[0,0],fadeValues:Lz(e,i)}:a}function kz(e,t,i){let r=Ie(),a=(r-e.timeAdded)/i,n=(r-t.timeAdded)/i,o=e.fadingDirection===1,s=ie(a,0,1),l=ie(1-n,0,1),u=o?s:l;return{tileOpacity:u,parentTileOpacity:o?l:s,fadeMix:{opacity:1,mix:1-u}}}function Lz(e,t){let i=ie((Ie()-e.timeAdded)/t,0,1);return{tileOpacity:i,fadeMix:{opacity:i,mix:0}}}function Bz(e,t,i,r,a){let n=i.paint.get("background-color"),o=i.paint.get("background-opacity");if(o===0)return;let s=e.context,l=s.gl,u=a.transform,h=u.tileSize,c=i.paint.get("background-pattern");if(e.patternAtlas.isPatternMissing(c))return;let d=!c&&n.a===1&&o===1&&a.opaquePassEnabledForLayer()?"opaque":"translucent";if(a.currentPass!==d)return;let p=Se.disabled,f=a.getDepthModeForSublayer(0,d==="opaque"?ge.ReadWrite:ge.ReadOnly),m=a.colorModeForRenderPass(),g=a.useProgram(c?"backgroundPattern":"background"),_=r||Mo(u,{tileSize:h,terrain:a.terrain});c&&(s.activeTexture.set(l.TEXTURE0),e.patternAtlas.bind(e.context));let y=i.getCrossfadeParameters();for(let v of _){let x=a.getProjectionDataForTile(v),b=c?ez(o,e,c,{tileID:v,tileSize:h},y):Q5(o,n),w=a.getTerrainDataForTile(v),T=a.getMeshFromTileID(v.canonical,!1,!0,"raster");g.draw(s,l.TRIANGLES,f,p,m,Ce.backCCW,b,w,x,i.id,T.vertexBuffer,T.indexBuffer,T.segments)}}var Oz=new oe(1,0,0,1),jz=new oe(0,1,0,1),Vz=new oe(0,0,1,1),Nz=new oe(1,0,1,1),Uz=new oe(0,1,1,1);function $z(e){let t=e.transform.padding;g_(e,e.transform.height-(t.top||0),3,Oz),g_(e,t.bottom||0,3,jz),__(e,t.left||0,3,Vz),__(e,e.transform.width-(t.right||0),3,Nz);let i=e.transform.centerPoint;Gz(e,i.x,e.transform.height-i.y,Uz)}function Gz(e,t,i,r){Tl(e,t-1,i-10,2,20,r),Tl(e,t-10,i-1,20,2,r)}function g_(e,t,i,r){Tl(e,0,t+i/2,e.transform.width,i,r)}function __(e,t,i,r){Tl(e,t-i/2,0,i,e.transform.height,r)}function Tl(e,t,i,r,a,n){let o=e.context,s=o.gl,l=e.data.pixelRatio;s.enable(s.SCISSOR_TEST),s.scissor(t*l,i*l,r*l,a*l),o.clear({color:n}),s.disable(s.SCISSOR_TEST)}function Zz(e,t,i,r){for(let a of i)qz(e,t,a,r)}function qz(e,t,i,r){let a=e.context,n=a.gl,o=r.useProgram("debug"),s=ge.disabled,l=Se.disabled,u=r.colorModeForRenderPass(),h="$debug",c=r.getTerrainDataForTile(i);a.activeTexture.set(n.TEXTURE0);let d=t.getTileByID(i.key).latestRawTileData?.byteLength||0,p=Math.floor(d/1024),f=t.getTile(i).tileSize,m=512/Math.min(f,512)*(i.overscaledZ/r.transform.zoom)*.5,g=i.canonical.toString();i.overscaledZ!==i.canonical.z&&(g+=` => ${i.overscaledZ}`),Wz(e,`${g} ${p}kB`);let _=r.getProjectionDataForTile(i);o.draw(a,n.TRIANGLES,s,l,et.alphaBlended,Ce.disabled,u_(oe.transparent,m),null,_,h,e.debugBuffer,e.quadTriangleIndexBuffer,e.debugSegments),o.draw(a,n.LINE_STRIP,s,l,u,Ce.disabled,u_(oe.red),c,_,h,e.debugBuffer,e.tileBorderIndexBuffer,e.debugSegments)}function Wz(e,t){e.initDebugOverlayCanvas();let i=e.debugOverlayCanvas,r=e.context.gl,a=e.debugOverlayCanvas.getContext("2d");a.clearRect(0,0,i.width,i.height),a.shadowColor="white",a.shadowBlur=2,a.lineWidth=1.5,a.strokeStyle="white",a.textBaseline="top",a.font="bold 36px Open Sans, sans-serif",a.fillText(t,5,5),a.strokeText(t,5,5),e.debugOverlayTexture.update(i),e.debugOverlayTexture.bind(r.LINEAR,r.CLAMP_TO_EDGE)}function Hz(e,t){let i=null,r=Object.values(e._layers).flatMap(s=>s.source&&!s.isHidden(t)?[e.tileManagers[s.source]]:[]),a=r.filter(s=>s.getSource().type==="vector"),n=r.filter(s=>s.getSource().type!=="vector"),o=s=>{(!i||i.getSource().maxzoom<s.getSource().maxzoom)&&(i=s)};for(let s of a)o(s);if(!i)for(let s of n)o(s);return i}function Xz(e,t,i){let r=e.context,a=r.gl,n=i.transform,o=et.unblended,s=new ge(a.LEQUAL,ge.ReadWrite,[0,1]),l=t.tileManager.getRenderableTiles(),u=i.useProgram("terrainDepth");r.bindFramebuffer.set(t.getFramebuffer().framebuffer),r.viewport.set([0,0,e.width/devicePixelRatio,e.height/devicePixelRatio]),r.clear({color:oe.white,depth:1});for(let h of l){let c=t.getTerrainMesh(h.tileID,i.data.isRenderingGlobe),d=t.getTerrainData(h.tileID),p=n.getProjectionData({overscaledTileID:h.tileID,applyTerrainMatrix:!1,applyGlobeMatrix:!0}),f=u5(t.getSkirtLength(n.zoom));u.draw(r,a.TRIANGLES,s,Se.disabled,o,Ce.backCCW,f,d,p,"terrain",c.vertexBuffer,c.indexBuffer,c.segments)}r.bindFramebuffer.set(null),r.viewport.set([0,0,e.width,e.height])}function Yz(e,t,i,r){let{isRenderingGlobe:a}=r.data,n=e.context,o=n.gl,s=r.transform,l=r.colorModeForRenderPass(),u=r.getDepthModeFor3D(),h=r.useProgram("terrain");n.bindFramebuffer.set(null),n.viewport.set([0,0,e.width,e.height]);for(let c of i){let d=t.getTerrainMesh(c.tileID,a),p=e.renderToTexture.getTexture(c),f=t.getTerrainData(c.tileID);n.activeTexture.set(o.TEXTURE0),p.bind(o.LINEAR,o.CLAMP_TO_EDGE,o.LINEAR_MIPMAP_LINEAR);let m=t.getSkirtLength(s.zoom),g=s.calculateFogMatrix(c.tileID.toUnwrapped()),_=l5(m,g,r.data.sky,s.pitch,a),y=r.getProjectionDataForTile(c.tileID,{applyTerrainMatrix:!1});h.draw(n,o.TRIANGLES,u,Se.disabled,l,Ce.backCCW,_,f,y,"terrain",d.vertexBuffer,d.indexBuffer,d.segments)}}function Kz(e,t,i){let r=e.context,a=r.gl,[n,o,s,l]=i.bounds;r.setDirty();let u=t.getHeightMapFramebuffer(i.texture);r.viewport.set([0,0,i.width,i.height]),r.clear({color:oe.transparent});let h=e.useProgram("terrainHeight",null,!0);for(let c of t.tileManager.getRenderableTiles()){let d=t.getTerrainData(c.tileID);if(!d.tile?.dem)continue;let{canonical:p,wrap:f}=c.tileID,m=1/(1<<p.z),g=h5([(p.x*m+f-n)/(s-n),(p.y*m-o)/(l-o),m/(s-n),m/(l-o)]),_=t.getTerrainMesh(c.tileID,e.data.isRenderingGlobe);h.draw(r,a.TRIANGLES,ge.disabled,Se.disabled,et.unblended,Ce.disabled,g,d,null,"terrain",_.vertexBuffer,_.indexBuffer,_.segments)}u.colorAttachment.set(null)}function Jz(e,t,i,r,a){if(a.isRenderingToTexture){Qz(e,i,r[0],a);return}let{isRenderingGlobe:n,projectionShaderVariant:o}=a.data,{terrain:s}=a,l=e.context,u=i.implementation,h=a.transform,c=h.getProjectionDataForCustomLayer(n),d={farZ:h.farZ,nearZ:h.nearZ,fov:h.fov*Math.PI/180,modelViewProjectionMatrix:h.modelViewProjectionMatrix,projectionMatrix:h.projectionMatrix,shaderData:{variantName:o.name,vertexShaderPrelude:`const float PI = 3.141592653589793;
|
|
816
|
+
uniform mat4 u_projection_matrix;
|
|
817
|
+
${o.prelude.vertexSource}`,define:o.define},defaultProjectionData:c,getProjectionData:f=>h.getProjectionData({overscaledTileID:new Ct(f.tileID.canonical.z,f.tileID.wrap??0,f.tileID.canonical.z,f.tileID.canonical.x,f.tileID.canonical.y),aligned:f.aligned,applyGlobeMatrix:f.applyGlobeMatrix,applyTerrainMatrix:f.applyTerrainMatrix}),renderTerrainHeightMap:s&&a.currentPass==="offscreen"?f=>Kz(a,s,f):void 0},p=u.renderingMode?u.renderingMode:"2d";if(a.currentPass==="offscreen"){let f=u.prerender;f&&(l.setCustomLayerDefaults(),l.setColorMode(a.colorModeForRenderPass()),f.call(u,l.gl,d),l.setDirty(),e.setBaseState())}else if(a.currentPass==="translucent"){l.setCustomLayerDefaults(),l.setColorMode(a.colorModeForRenderPass()),l.setStencilMode(Se.disabled);let f=p==="3d"?a.getDepthModeFor3D():a.getDepthModeForSublayer(0,ge.ReadOnly);l.setDepthMode(f),u.render(l.gl,d),l.setDirty(),e.setBaseState(),l.bindFramebuffer.set(null)}}function Qz(e,t,i,r){let a=e.context,n=a.bindFramebuffer.get(),o=a.viewport.get();a.setCustomLayerDefaults(),a.setColorMode(r.colorModeForRenderPass()),a.setDepthMode(ge.disabled),a.setStencilMode(Se.disabled),t.implementation.renderToTerrainTile(a.gl,{tileID:{canonical:i.canonical,wrap:i.wrap},width:o[2],height:o[3]}),a.setDirty(),e.setBaseState(),a.bindFramebuffer.set(n),a.viewport.set(o)}function eR(e,t,i){let r=e.context,a=r.gl,n=az(t,e.frameRenderContext.transform,i),o=new ge(a.LEQUAL,ge.ReadWrite,[0,1]),s=Se.disabled,l=e.frameRenderContext.colorModeForRenderPass(),u=e.frameRenderContext.useProgram("sky"),h=e.skyMesh;u.draw(r,a.TRIANGLES,o,s,l,Ce.disabled,n,null,void 0,"sky",h.vertexBuffer,h.indexBuffer,h.segments)}function tR(e,t){let i=N_(e.position);Ab(i,i);let r=Mi(new Float64Array(16));return e.anchor==="map"&&(br(r,r,t.rollInRadians),Ua(r,r,-t.pitchInRadians),br(r,r,t.bearingInRadians),Ua(r,r,t.center.lat*Math.PI/180),L_(r,r,-t.center.lng*Math.PI/180)),Mb(i,i,r),i}function iR(e,t,i){let r=e.context,a=r.gl,n=e.frameRenderContext.useProgram("atmosphere"),o=new ge(a.LEQUAL,ge.ReadOnly,[0,1]),s=e.frameRenderContext.transform,l=tR(i,e.frameRenderContext.transform),u=s.getProjectionData({overscaledTileID:null,applyGlobeMatrix:!0,applyTerrainMatrix:!0}),h=Xr(s.worldSize,s.center.lat),c=ix(s),d=rx(Pi(c)-h,h),p=t["atmosphere-blend"]*u.projectionTransition*d;if(p===0)return;let f=iz(l,p,c,h,s.inverseProjectionMatrix),m=e.skyMesh;n.draw(r,a.TRIANGLES,o,Se.disabled,et.alphaBlended,Ce.disabled,f,null,null,"atmosphere",m.vertexBuffer,m.indexBuffer,m.segments)}var rR={symbol:uz,circle:mz,heatmap:gz,line:Cz,fill:Pz,fillExtrusion:Az,hillshade:Iz,colorRelief:Fz,raster:zz,background:Bz,sky:eR,atmosphere:iR,custom:Jz,debug:Zz,debugPadding:$z,terrainDepth:Xz},y_=Qc.maxOverzooming+Qc.maxUnderzooming+1,v_=1/2**16,aR={name:Wv,define:qv,prelude:Zi.projectionMercator},nR=class{constructor(e){this.currentLayer=0,this.opaquePassCutoff=1/0,this.depthRangeFor3D=[0,1],this.isRenderingToTexture=!1,this.nextStencilID=1,this.tileClippingMaskIDs={},this.transform=e.transform,this.terrain=e.terrain,this.data=e.data,this.context=e.context,this.programCache=e.programCache,this.currentPass=e.currentPass,this.projection=e.projection}getProjectionDataForTile(e,t={}){let i=this.transform.getProjectionData({overscaledTileID:e,aligned:t.aligned,applyGlobeMatrix:!this.isRenderingToTexture,applyTerrainMatrix:t.applyTerrainMatrix??!0});return this.isRenderingToTexture||(i.uniformBufferKey=t.aligned?`${e.key}/aligned`:e.key),i}getTerrainDataForTile(e){return this.isRenderingToTexture?null:this.terrain?.getTerrainData(e)??null}getMeshFromTileID(e,t,i,r){return this.projection.getMeshFromTileID(this.context,e,t,i,r)}useProgram(e,t,i=!1,r=[]){return this.programCache.getProgram({name:e,programConfiguration:t,projectionShaderVariant:i?aR:this.data.projectionShaderVariant,showOverdrawInspector:this.data.showOverdrawInspector,useTerrain:this.terrain!==null,defines:r})}colorModeForRenderPass(){let e=this.context.gl;if(this.data.showOverdrawInspector){let t=.125;return new et([e.CONSTANT_COLOR,e.ONE],new oe(t,t,t,0),[!0,!0,!0,!0])}return this.currentPass==="opaque"?et.unblended:et.alphaBlended}getDepthModeForSublayer(e,t,i){if(!this.opaquePassEnabledForLayer())return ge.disabled;let r=1-((1+this.currentLayer)*y_+e)*v_;return new ge(i||this.context.gl.LEQUAL,t,[r,r])}getDepthModeFor3D(){return new ge(this.context.gl.LEQUAL,ge.ReadWrite,this.depthRangeFor3D)}setDepthRangeFor3D(e){this.depthRangeFor3D=[0,1-(e+2)*y_*v_]}opaquePassEnabledForLayer(){return this.currentLayer<this.opaquePassCutoff}clearStencil(){this.nextStencilID=1,this.currentStencilSource=void 0,this.context.clear({stencil:0})}invalidateTileClippingMasks(){this.currentStencilSource=void 0}renderTileClippingMasks(e,t){if(this.currentStencilSource===e.source||!e.isTileClipped()||!t?.length)return;this.currentStencilSource=e.source,this.nextStencilID+t.length>256&&this.clearStencil();let i=this.context;i.setColorMode(et.disabled),i.setDepthMode(ge.disabled);let r={};for(let a of t)r[a.key]=this.nextStencilID++;this.data.useSubdivision&&this.renderTileMasks(r,t,!0),this.renderTileMasks(r,t,!1),this.tileClippingMaskIDs=r}renderTileMasks(e,t,i){let r=this.context,a=r.gl,n=this.useProgram("clippingMask");for(let o of t){let s=e[o.key],l=this.getTerrainDataForTile(o),u=this.getMeshFromTileID(o.canonical,i,!0,"stencil"),h=this.getProjectionDataForTile(o);n.draw(r,a.TRIANGLES,ge.disabled,new Se({func:a.ALWAYS,mask:0},s,255,a.KEEP,a.KEEP,a.REPLACE),et.disabled,this.isRenderingToTexture?Ce.disabled:Ce.backCCW,null,l,h,"$clipping",u.vertexBuffer,u.indexBuffer,u.segments)}}stencilModeFor3D(){this.currentStencilSource=void 0,this.nextStencilID+1>256&&this.clearStencil();let e=this.nextStencilID++,t=this.context.gl;return new Se({func:t.NOTEQUAL,mask:255},e,255,t.KEEP,t.KEEP,t.REPLACE)}stencilModeForClipping(e){let t=this.context.gl;return new Se({func:t.EQUAL,mask:255},this.tileClippingMaskIDs[e.key],0,t.KEEP,t.KEEP,t.REPLACE)}getStencilConfigForOverlapAndUpdateStencilID(e){let t=this.context.gl,i=e.sort((n,o)=>o.overscaledZ-n.overscaledZ),r=i[i.length-1].overscaledZ,a=i[0].overscaledZ-r+1;if(a>1){this.currentStencilSource=void 0,this.nextStencilID+a>256&&this.clearStencil();let n={};for(let o=0;o<a;o++)n[o+r]=new Se({func:t.GEQUAL,mask:255},o+this.nextStencilID,255,t.KEEP,t.KEEP,t.REPLACE);return this.nextStencilID+=a,[n,i]}return[{[r]:Se.disabled},i]}stencilConfigForOverlapTwoPass(e){let t=this.context.gl,i=e.sort((n,o)=>o.overscaledZ-n.overscaledZ),r=i[i.length-1].overscaledZ,a=i[0].overscaledZ-r+1;if(this.clearStencil(),a>1){let n={},o={};for(let s=0;s<a;s++)n[s+r]=new Se({func:t.GREATER,mask:255},a+1+s,255,t.KEEP,t.KEEP,t.REPLACE),o[s+r]=new Se({func:t.GREATER,mask:255},1+s,255,t.KEEP,t.KEEP,t.REPLACE);return this.nextStencilID=a*2+1,[n,o,i]}return this.nextStencilID=3,[{[r]:new Se({func:t.GREATER,mask:255},2,255,t.KEEP,t.KEEP,t.REPLACE)},{[r]:new Se({func:t.GREATER,mask:255},1,255,t.KEEP,t.KEEP,t.REPLACE)},i]}},Kr,oR=(Kr=class{constructor(t){this.drawFunctions=rR,this.context=new i5(t),this.programCache=new oz(this.context),this.layerOpacityFbo=null,this._tileTextures={},this._rttObjectRecyclePool=[],this._rttSharedFbo=null,this.terrainFacilitator={depthDirty:!0,matrix:Mi(new Float64Array(16)),renderTime:0},this.setup()}resize(t,i,r){this.width=Math.round(t*r),this.height=Math.round(i*r),this.context.viewport.set([0,0,this.width,this.height])}setup(){let t=this.context,i=new Gr;i.emplaceBack(0,0),i.emplaceBack(k,0),i.emplaceBack(0,k),i.emplaceBack(k,k),this.tileExtentBuffer=t.createVertexBuffer(i,Ma.members),this.tileExtentSegments=Ye.simpleSegment(0,0,4,2);let r=new Gr;r.emplaceBack(0,0),r.emplaceBack(k,0),r.emplaceBack(0,k),r.emplaceBack(k,k),this.debugBuffer=t.createVertexBuffer(r,Ma.members),this.debugSegments=Ye.simpleSegment(0,0,4,5);let a=new jT;a.emplaceBack(0,0,0,0),a.emplaceBack(k,0,k,0),a.emplaceBack(0,k,0,k),a.emplaceBack(k,k,k,k),this.rasterBoundsBuffer=t.createVertexBuffer(a,uF.members),this.rasterBoundsSegments=Ye.simpleSegment(0,0,4,2);let n=new Gr;n.emplaceBack(0,0),n.emplaceBack(1,0),n.emplaceBack(0,1),n.emplaceBack(1,1),this.viewportBuffer=t.createVertexBuffer(n,Ma.members),this.viewportSegments=Ye.simpleSegment(0,0,4,2);let o=new KT;o.emplaceBack(0),o.emplaceBack(1),o.emplaceBack(3),o.emplaceBack(2),o.emplaceBack(0),this.tileBorderIndexBuffer=t.createIndexBuffer(o);let s=new Xi;s.emplaceBack(1,0,2),s.emplaceBack(1,2,3),this.quadTriangleIndexBuffer=t.createIndexBuffer(s),this.tileExtentMesh=new go(this.tileExtentBuffer,this.quadTriangleIndexBuffer,this.tileExtentSegments);let l=new Gr;l.emplaceBack(-1,-1),l.emplaceBack(1,-1),l.emplaceBack(1,1),l.emplaceBack(-1,1);let u=new Xi;u.emplaceBack(0,1,2),u.emplaceBack(0,2,3),this.skyMesh=new go(t.createVertexBuffer(l,Ma.members),t.createIndexBuffer(u),Ye.simpleSegment(0,0,l.length,u.length))}_renderTilesDepthBuffer(){let t=this.context,i=t.gl,r=this.frameRenderContext.transform,a=this.frameRenderContext.useProgram("depth"),n=this.frameRenderContext.getDepthModeFor3D(),o=Mo(r,{tileSize:r.tileSize});for(let s of o){let l=this.frameRenderContext.getTerrainDataForTile(s),u=this.frameRenderContext.getMeshFromTileID(s.canonical,!0,!0,"raster"),h=this.frameRenderContext.getProjectionDataForTile(s);a.draw(t,i.TRIANGLES,n,Se.disabled,et.disabled,Ce.backCCW,null,l,h,"$clipping",u.vertexBuffer,u.indexBuffer,u.segments)}}render(t,i,r){let a=this.frameRenderContext=new nR({transform:i,terrain:t.map.terrain??null,data:r,context:this.context,programCache:this.programCache,currentPass:"offscreen",projection:t.projection});this.lineAtlas=t.lineAtlas,this.patternAtlas=t.patternAtlas,QF(this.context.frameUniformBuffer,i,r),t.imageManager.beginFrame(),YF(this.context);let n=t._order,o=t.tileManagers,s={},l={},u={};for(let c in o){let d=o[c];d.used&&d.prepare(this.context),s[c]=d.getVisibleCoordinates(!1),l[c]=s[c].slice().reverse(),u[c]=d.getVisibleCoordinates(!0).reverse()}a.opaquePassCutoff=1/0;for(let c=0;c<n.length;c++){let d=n[c];if(t._layers[d].is3D()){a.opaquePassCutoff=c;break}}this.maybeDrawDepth(),this.renderToTexture&&(this.renderToTexture.prepareForRender(t,i.zoom,r.moving),a.opaquePassCutoff=0),a.currentPass="offscreen";for(let c of n){let d=t._layers[c];if(!d.hasOffscreenPass()||d.isHidden(i.zoom))continue;let p=l[d.source];(d.type==="custom"||p.length)&&this.renderLayer(this,o[d.source],d,p,a)}if(this.context.viewport.set([0,0,this.width,this.height]),this.context.bindFramebuffer.set(null),this.context.clear({color:r.showOverdrawInspector?oe.black:oe.transparent,depth:1}),a.clearStencil(),r.sky&&this.drawFunctions.sky(this,r.sky,r.pixelRatio),a.setDepthRangeFor3D(t._order.length),!this.renderToTexture)for(a.currentPass="opaque",a.currentLayer=n.length-1;a.currentLayer>=0;a.currentLayer--){let c=t._layers[n[a.currentLayer]];if(c.isHidden(i.zoom))continue;let d=o[c.source],p=s[c.source];a.renderTileClippingMasks(c,p),this.renderLayer(this,d,c,p,a)}a.currentPass="translucent";let h=!1;for(a.currentLayer=0;a.currentLayer<n.length;a.currentLayer++){let c=t._layers[n[a.currentLayer]];if(c.isHidden(i.zoom))continue;let d=o[c.source];if(this.renderToTexture?.renderLayer(c,t,a))continue;!a.opaquePassEnabledForLayer()&&!h&&(h=!0,r.isRenderingGlobe&&!a.terrain&&this._renderTilesDepthBuffer());let p=(c.type==="symbol"?u:l)[c.source];a.renderTileClippingMasks(c,s[c.source]),this.renderLayer(this,d,c,p,a)}if(r.isRenderingGlobe&&this.drawFunctions.atmosphere(this,r.sky,r.light),r.showTileBoundaries){let c=Hz(t,i.zoom);c&&this.drawFunctions.debug(this,c,c.getVisibleCoordinates(),a)}r.showPadding&&this.drawFunctions.debugPadding(a),this.renderToTexture&&!r.moving&&this.clearRTTPool(),this.context.setDefault()}markTerrainDepthDirty(){this.terrainFacilitator.depthDirty=!0}maybeDrawDepth(){if(!this.frameRenderContext.data.projectionShaderVariant||!this.frameRenderContext.terrain)return;let t=this.terrainFacilitator.matrix,i=this.frameRenderContext.transform.modelViewProjectionMatrix,r=this.terrainFacilitator.depthDirty;r||(r=!Cb(t,i)),r||(r=this.frameRenderContext.terrain.tileManager.anyTilesAfterTime(this.terrainFacilitator.renderTime)),r&&(wb(t,i),this.terrainFacilitator.renderTime=Ie(),this.terrainFacilitator.depthDirty=!1,this.drawFunctions.terrainDepth(this,this.frameRenderContext.terrain,this.frameRenderContext))}renderLayer(t,i,r,a,n){if(r.isHidden(n.transform.zoom)||r.type!=="background"&&r.type!=="custom"&&!(a||[]).length)return;let o=this.drawFunctions;N1(r)?o.symbol(t,i,r,a,n):wE(r)?o.circle(t,i,r,a,n):SE(r)?o.heatmap(t,i,r,a,n):WD(r)?o.line(t,i,r,a,n):pD(r)?o.fill(t,i,r,a,n):LD(r)?o.fillExtrusion(t,i,r,a,n):IE(r)?o.hillshade(t,i,r,a,n):kE(r)?o.colorRelief(t,i,r,a,n):Yh(r)?o.raster(t,i,r,a,n):WC(r)?o.background(t,i,r,a,n):Yl(r)&&o.custom(t,i,r,a,n)}saveTileTexture(t){let i=this._tileTextures[t.size[0]];i?i.length<Kr.MAX_TEXTURE_POOL_SIZE_PER_BUCKET?i.push(t):t.destroy():this._tileTextures[t.size[0]]=[t]}getTileTexture(t){let i=this._tileTextures[t];return i&&i.length>0?i.pop():null}acquireRTT(t){let i=this.context.gl,r=this._rttObjectRecyclePool.pop();if(r)return r.size!==t&&(r.texture.update({width:t,height:t,data:null},{premultiply:!1,useMipmap:!0}),r.texture.bind(i.LINEAR,i.CLAMP_TO_EDGE,i.LINEAR_MIPMAP_LINEAR),this.context.extTextureFilterAnisotropic&&i.texParameterf(i.TEXTURE_2D,this.context.extTextureFilterAnisotropic.TEXTURE_MAX_ANISOTROPY_EXT,this.context.extTextureFilterAnisotropicMax),r.size=t),r;let a=new pt(this.context,{width:t,height:t,data:null},i.RGBA,{premultiply:!1,useMipmap:!0});return a.bind(i.LINEAR,i.CLAMP_TO_EDGE,i.LINEAR_MIPMAP_LINEAR),this.context.extTextureFilterAnisotropic&&i.texParameterf(i.TEXTURE_2D,this.context.extTextureFilterAnisotropic.TEXTURE_MAX_ANISOTROPY_EXT,this.context.extTextureFilterAnisotropicMax),{texture:a,size:t}}bindRTT(t){let i=this.context.gl,r=t.size;if(!this._rttSharedFbo){let a=this.context.createFramebuffer(r,r,!0,!0),n=this.context.createRenderbuffer(i.DEPTH_STENCIL,r,r);a.depthAttachment.set(n),this._rttSharedFbo={fbo:a,depthRenderbuffer:n,size:r}}this._rttSharedFbo.size!==r&&(this.context.bindRenderbuffer.set(this._rttSharedFbo.depthRenderbuffer),i.renderbufferStorage(i.RENDERBUFFER,i.DEPTH_STENCIL,r,r),this.context.bindRenderbuffer.set(null),this._rttSharedFbo.fbo.width=r,this._rttSharedFbo.fbo.height=r,this._rttSharedFbo.size=r),this._rttSharedFbo.fbo.colorAttachment.set(t.texture.texture),this.context.bindFramebuffer.set(this._rttSharedFbo.fbo.framebuffer)}releaseRTT(t){this._rttObjectRecyclePool.push(t)}clearRTTPool(){for(let t of this._rttObjectRecyclePool)t.texture.destroy();this._rttObjectRecyclePool.length=0}destroyRTTResources(){if(this.clearRTTPool(),!this._rttSharedFbo)return;this._rttSharedFbo.fbo.colorAttachment.set(null),this._rttSharedFbo.fbo.depthAttachment.set(null);let t=this.context.gl;t.deleteRenderbuffer(this._rttSharedFbo.depthRenderbuffer),t.deleteFramebuffer(this._rttSharedFbo.fbo.framebuffer),this._rttSharedFbo=null}setBaseState(){let t=this.context.gl;this.context.cullFace.set(!1),this.context.viewport.set([0,0,this.width,this.height]),this.context.blendEquation.set(t.FUNC_ADD)}initDebugOverlayCanvas(){if(this.debugOverlayCanvas==null){this.debugOverlayCanvas=document.createElement("canvas"),this.debugOverlayCanvas.width=512,this.debugOverlayCanvas.height=512;let t=this.context.gl;this.debugOverlayTexture=new pt(this.context,this.debugOverlayCanvas,t.RGBA)}}destroy(){if(this._tileTextures){for(let t in this._tileTextures){let i=this._tileTextures[t];if(i)for(let r of i)r.destroy()}this._tileTextures={}}this.destroyRTTResources(),this.layerOpacityFbo?.destroy(),this.layerOpacityFbo=null,this.tileExtentBuffer&&this.tileExtentBuffer.destroy(),this.debugBuffer&&this.debugBuffer.destroy(),this.rasterBoundsBuffer&&this.rasterBoundsBuffer.destroy(),this.viewportBuffer&&this.viewportBuffer.destroy(),this.tileBorderIndexBuffer&&this.tileBorderIndexBuffer.destroy(),this.quadTriangleIndexBuffer&&this.quadTriangleIndexBuffer.destroy(),this.tileExtentMesh&&this.tileExtentMesh.vertexBuffer?.destroy(),this.tileExtentMesh&&this.tileExtentMesh.indexBuffer?.destroy(),this.skyMesh?.destroy(),this.skyMesh=null,this.debugOverlayTexture&&this.debugOverlayTexture.destroy(),this.context.destroy(),this.programCache.destroy(),this.context&&this.context.setDefault()}overLimit(){let{drawingBufferWidth:t,drawingBufferHeight:i}=this.context.gl;return this.width!==t||this.height!==i}},Kr.MAX_TEXTURE_POOL_SIZE_PER_BUCKET=50,Kr),Px=class extends Error{constructor(e,t){super("WebGL2 is required to display this map. We are sorry, but it seems that your browser does not support WebGL2, a technology for rendering 3D graphics on the web. Read more on https://wiki.openstreetmap.org/wiki/This_map_requires_WebGL"),this.name="GPUInitializationError",this.requestedAttributes=e,this.statusMessage=t?.statusMessage??null}};function Bp(e,t){let i=!1,r=null,a,n=()=>{r=null,i&&(i=(e(...a),r=setTimeout(n,t),!1))};return(...o)=>(i=!0,a=o,r||n(),r)}var Ax=class{constructor(e){this._getHashParams=()=>new URLSearchParams(window.location.hash.replace("#","")),this._getCurrentHash=()=>{let t=this._getHashParams();return this._hashName?(t.get(this._hashName)||"").split("/"):([...t.keys()][0]??"").split("/")},this._onHashChange=()=>{let t=this._getCurrentHash();if(!this._isValidHash(t))return!1;let i=this._map.dragRotate.isEnabled()&&this._map.touchZoomRotate.isEnabled()?+(t[3]||0):this._map.getBearing();return this._map.jumpTo({center:[+t[2],+t[1]],zoom:+t[0],bearing:i,pitch:+(t[4]||0)}),!0},this._updateHashUnthrottled=()=>{let t=window.location.href.replace(/(#.*)?$/,this.getHashString());window.history.replaceState(window.history.state,null,t)},this._removeHash=()=>{let t=this._getHashParams();if(this._hashName)t.delete(this._hashName);else{let n=Array.from(t.keys());n.length>0&&t.delete(n[0])}let i=decodeURIComponent(t.toString()).replace(/=&/g,"&").replace(/=$/g,""),r=i?`#${i}`:"",a=window.location.href.replace(/(#.+)?$/,r);a=a.replace("&&","&"),window.history.replaceState(window.history.state,null,a)},this._updateHash=Bp(this._updateHashUnthrottled,300),this._hashName=e&&encodeURIComponent(e)}addTo(e){return this._map=e,addEventListener("hashchange",this._onHashChange,!1),this._map.on("moveend",this._updateHash),this}remove(){return removeEventListener("hashchange",this._onHashChange,!1),this._map.off("moveend",this._updateHash),clearTimeout(this._updateHash()),this._removeHash(),delete this._map,this}getHashString(e){let t=this._map.getCenter(),i=Math.round(this._map.getZoom()*100)/100,r=10**Math.ceil((i*Math.LN2+Math.log(512/360/.5))/Math.LN10),a=Math.round(t.lng*r)/r,n=Math.round(t.lat*r)/r,o=this._map.getBearing(),s=this._map.getPitch(),l="";if(l+=e?`/${a}/${n}/${i}`:`${i}/${n}/${a}`,(o||s)&&(l+=`/${Math.round(o*10)/10}`),s&&(l+=`/${Math.round(s)}`),this._hashName){let u=this._getHashParams();return u.set(this._hashName,l),`#${decodeURIComponent(u.toString()).replace(/=&/g,"&").replace(/=$/g,"")}`}return`#${l}`}_isValidHash(e){if(e.length<3||e.some(a=>isNaN(+a)))return!1;try{new X(+e[2],+e[1])}catch{return!1}let t=+e[0],i=+(e[3]||0),r=+(e[4]||0);return t>=this._map.getMinZoom()&&t<=this._map.getMaxZoom()&&i>=-180&&i<=180&&r>=this._map.getMinPitch()&&r<=this._map.getMaxPitch()}},zo={linearity:.3,easing:yd(0,0,.3,1)},sR=q({deceleration:2500,maxSpeed:1400},zo),lR=q({deceleration:20,maxSpeed:1400},zo),uR=q({deceleration:1e3,maxSpeed:360},zo),hR=q({deceleration:1e3,maxSpeed:90},zo),cR=q({deceleration:1e3,maxSpeed:360},zo),dR=class{constructor(e){this._map=e,this.clear()}clear(){this._inertiaBuffer=[]}record(e){this._drainInertiaBuffer(),this._inertiaBuffer.push({time:Ie(),settings:e})}_drainInertiaBuffer(){let e=this._inertiaBuffer,t=Ie();for(;e.length>0&&t-e[0].time>160;)e.shift()}_getVelocityEntries(){let e=this._inertiaBuffer,t=Ie()-60,i=Math.max(0,e.length-2);for(;i>0&&e[i-1].time>=t;)i--;return e.slice(i)}_onMoveEnd(e){this._drainInertiaBuffer();let t=this._getVelocityEntries();if(t.length<2){this.clear();return}let i={zoom:0,bearing:0,pitch:0,roll:0,pan:new C(0,0),pinchAround:void 0,around:void 0};for(let{settings:n}of t)n.around&&(i.around=n.around),n.pinchAround&&(i.pinchAround=n.pinchAround);for(let{settings:n}of t.slice(1))i.zoom+=n.zoomDelta||0,i.bearing+=n.bearingDelta||0,i.pitch+=n.pitchDelta||0,i.roll+=n.rollDelta||0,n.panDelta&&i.pan._add(n.panDelta);if(!i.pan.mag()&&!i.zoom&&!i.bearing&&!i.pitch&&!i.roll){this.clear();return}let r=Ie()-t[0].time,a={};if(i.pan.mag()){let n=Cn(i.pan.mag(),r,q({},sR,e||{})),o=i.pan.mult(n.amount/i.pan.mag()),s=this._map._camera.cameraHelper.handlePanInertia(o,this._map._camera.transform);a.center=s.easingCenter,a.offset=s.easingOffset,Sn(a,n)}if(i.zoom){let n=Cn(i.zoom,r,lR);a.zoom=ri(this._map.getZoom()+n.amount,this._map.getZoomSnap(),n.amount),Sn(a,n)}if(i.bearing){let n=Cn(i.bearing,r,uR);a.bearing=this._map.getBearing()+ie(n.amount,-179,179),Sn(a,n)}if(i.pitch){let n=Cn(i.pitch,r,hR);a.pitch=this._map.getPitch()+n.amount,Sn(a,n)}if(i.roll){let n=Cn(i.roll,r,cR);a.roll=this._map.getRoll()+ie(n.amount,-179,179),Sn(a,n)}if(a.zoom||a.bearing){let n=i.pinchAround===void 0?i.around:i.pinchAround;a.around=n?this._map.unproject(n):this._map.getCenter()}return this.clear(),q(a,{noMoveStart:!0})}};function Sn(e,t){(!e.duration||e.duration<t.duration)&&(e.duration=t.duration,e.easing=t.easing)}function Cn(e,t,i){let{maxSpeed:r,linearity:a,deceleration:n}=i,o=ie(e*a/(t/1e3),-r,r),s=Math.abs(o)/(n*a);return{easing:i.easing,duration:s*1e3,amount:s/2*o}}var pR=class{constructor(e,t){this._map=e,this._clickTolerance=t.clickTolerance}reset(){delete this._mousedownPos}wheel(e){return this._firePreventable(new X_(this._map,e))}mousedown(e,t){return this._mousedownPos=t,this._firePreventable(new Xt(e.type,this._map,e))}mouseup(e){this._map.fire(new Xt(e.type,this._map,e))}click(e,t){this._mousedownPos&&this._mousedownPos.dist(t)>=this._clickTolerance||this._map.fire(new Xt(e.type,this._map,e))}dblclick(e){return this._firePreventable(new Xt(e.type,this._map,e))}mouseover(e){this._map.fire(new Xt(e.type,this._map,e))}mouseout(e){this._map.fire(new Xt(e.type,this._map,e))}touchstart(e){return this._firePreventable(new In(e.type,this._map,e))}touchmove(e){this._map.fire(new In(e.type,this._map,e))}touchend(e){this._map.fire(new In(e.type,this._map,e))}touchcancel(e){this._map.fire(new In(e.type,this._map,e))}_firePreventable(e){if(this._map.fire(e),e.defaultPrevented)return{}}isEnabled(){return!0}isActive(){return!1}enable(){}disable(){}},fR=class{constructor(e,t){this._map=e,this._clickTolerance=t.clickTolerance}reset(){this._delayContextMenu=!1,this._ignoreContextMenu=!0,delete this._contextMenuEvent,this._clearLongPress(),this._touchActive=!1}mousemove(e){this._map.fire(new Xt(e.type,this._map,e))}mousedown(){this._delayContextMenu=!0,this._ignoreContextMenu=!1}mouseup(){this._delayContextMenu=!1,this._contextMenuEvent&&(this._map.fire(new Xt("contextmenu",this._map,this._contextMenuEvent)),delete this._contextMenuEvent)}touchstart(e,t,i){if(this._clearLongPress(),this._touchActive=i.length>0,i.length!==1)return;this._longPressStart=t[0];let r=i[0];this._longPressTimer=setTimeout(()=>{this._longPressTimer=void 0;let a=new MouseEvent("contextmenu",{clientX:r.clientX,clientY:r.clientY,button:2,bubbles:!0,cancelable:!0});this._map.fire(new Xt("contextmenu",this._map,a))},500)}touchmove(e,t,i){this._longPressTimer&&(i.length!==1||!this._longPressStart||t[0].dist(this._longPressStart)>this._clickTolerance)&&this._clearLongPress()}touchend(){this._touchActive=!1,this._clearLongPress()}touchcancel(){this._touchActive=!1,this._clearLongPress()}_clearLongPress(){this._longPressTimer&&(this._longPressTimer=(clearTimeout(this._longPressTimer),void 0)),this._longPressStart=void 0}contextmenu(e){if(this._touchActive){e.preventDefault();return}this._delayContextMenu?this._contextMenuEvent=e:this._ignoreContextMenu||this._map.fire(new Xt(e.type,this._map,e)),this._map.listens("contextmenu")&&e.preventDefault()}isEnabled(){return!0}isActive(){return!1}enable(){}disable(){}},Ix=class{constructor(e,t,i){this._map=e,this._tr=i,this._el=e.getCanvasContainer(),this._container=e.getContainer(),this._clickTolerance=t.clickTolerance||1,t.boxZoom&&typeof t.boxZoom=="object"&&(this._boxZoomEnd=t.boxZoom.boxZoomEnd)}isEnabled(){return!!this._enabled}isActive(){return!!this._active}enable(){this.isEnabled()||(this._enabled=!0)}disable(){this.isEnabled()&&(this._enabled=!1)}mousedown(e,t){this.isEnabled()&&e.shiftKey&&e.button===0&&(ne.disableDrag(),this._startPos=this._lastPos=t,this._active=!0)}mousemoveWindow(e,t){if(!this._active)return;let i=t;if(this._lastPos.equals(i)||!this._box&&i.dist(this._startPos)<this._clickTolerance)return;let r=this._startPos;this._lastPos=i,this._box||(this._box=ne.create("div","maplibregl-boxzoom",this._container),this._container.classList.add("maplibregl-crosshair"),this._fireEvent("boxzoomstart",e));let a=Math.min(r.x,i.x),n=Math.max(r.x,i.x),o=Math.min(r.y,i.y),s=Math.max(r.y,i.y);this._box.style.transform=`translate(${a}px,${o}px)`,this._box.style.width=`${n-a}px`,this._box.style.height=`${s-o}px`}mouseupWindow(e,t){if(!this._active||e.button!==0)return;let i=this._startPos,r=t;if(this.reset(),ne.suppressClick(),i.x===r.x&&i.y===r.y)this._fireEvent("boxzoomcancel",e);else{if(this._map.fire(new Rh("boxzoomend",{originalEvent:e})),this._boxZoomEnd){this._boxZoomEnd(this._map,i,r,e);return}return{cameraAnimation:a=>a.fitScreenCoordinates(i,r,this._tr.bearing,{linear:!0})}}}keydown(e){this._active&&e.keyCode===27&&(this.reset(),this._fireEvent("boxzoomcancel",e))}reset(){this._active=!1,this._container.classList.remove("maplibregl-crosshair"),this._box&&(this._box=(this._box.remove(),null)),ne.enableDrag(),delete this._startPos,delete this._lastPos}_fireEvent(e,t){return this._map.fire(new Rh(e,{originalEvent:t}))}};function sd(e,t){if(e.length!==t.length)throw Error(`The number of touches and points are not equal - touches ${e.length}, points ${t.length}`);let i={};for(let r=0;r<e.length;r++)i[e[r].identifier]=t[r];return i}function mR(e){let t=new C(0,0);for(let i of e)t._add(i);return t.div(e.length)}var gR=class{constructor(e){this.reset(),this.numTouches=e.numTouches}reset(){delete this.centroid,delete this.startTime,delete this.touches,this.aborted=!1}touchstart(e,t,i){(this.centroid||i.length>this.numTouches)&&(this.aborted=!0),!this.aborted&&(this.startTime===void 0&&(this.startTime=e.timeStamp),i.length===this.numTouches&&(this.centroid=mR(t),this.touches=sd(i,t)))}touchmove(e,t,i){if(this.aborted||!this.centroid)return;let r=sd(i,t);for(let a in this.touches){let n=this.touches[a],o=r[a];(!o||o.dist(n)>30)&&(this.aborted=!0)}}touchend(e,t,i){if((!this.centroid||e.timeStamp-this.startTime>500)&&(this.aborted=!0),i.length===0){let r=!this.aborted&&this.centroid;if(this.reset(),r)return r}}},ld=class{constructor(e){this.singleTap=new gR(e),this.numTaps=e.numTaps,this.reset()}reset(){this.lastTime=1/0,delete this.lastTap,this.count=0,this.singleTap.reset()}touchstart(e,t,i){this.singleTap.touchstart(e,t,i)}touchmove(e,t,i){this.singleTap.touchmove(e,t,i)}touchend(e,t,i){let r=this.singleTap.touchend(e,t,i);if(r){let a=e.timeStamp-this.lastTime<500,n=!this.lastTap||this.lastTap.dist(r)<30;if((!a||!n)&&this.reset(),this.count++,this.lastTime=e.timeStamp,this.lastTap=r,this.count===this.numTaps)return this.reset(),r}}},_R=class{constructor(e,t){this._tr=t,this._zoomIn=new ld({numTouches:1,numTaps:2}),this._zoomOut=new ld({numTouches:2,numTaps:1}),this.reset()}reset(){this._active=!1,this._zoomIn.reset(),this._zoomOut.reset()}touchstart(e,t,i){this._zoomIn.touchstart(e,t,i),this._zoomOut.touchstart(e,t,i)}touchmove(e,t,i){this._zoomIn.touchmove(e,t,i),this._zoomOut.touchmove(e,t,i)}touchend(e,t,i){let r=this._zoomIn.touchend(e,t,i),a=this._zoomOut.touchend(e,t,i),n=this._tr;if(r)return this._active=!0,e.preventDefault(),setTimeout(()=>this.reset(),0),{cameraAnimation:o=>o.easeTo({duration:300,zoom:ri(n.zoom+1,o.getZoomSnap()),around:n.transform.isPointOnMapSurface(r)?n.unproject(r):void 0},{originalEvent:e})};if(a)return this._active=!0,e.preventDefault(),setTimeout(()=>this.reset(),0),{cameraAnimation:o=>o.easeTo({duration:300,zoom:ri(n.zoom-1,o.getZoomSnap()),around:n.transform.isPointOnMapSurface(a)?n.unproject(a):void 0},{originalEvent:e})}}touchcancel(){this.reset()}enable(){this._enabled=!0}disable(){this._enabled=!1,this.reset()}isEnabled(){return this._enabled}isActive(){return this._active}},Ro=class{constructor(e){this._enabled=!!e.enable,this._moveStateManager=e.moveStateManager,this._clickTolerance=e.clickTolerance||1,this._moveFunction=e.move,this._activateOnStart=!!e.activateOnStart,e.assignEvents(this),this.reset()}reset(e){this._active=!1,this._moved=!1,delete this._lastPoint,this._moveStateManager.endMove(e)}_move(...e){let t=this._moveFunction(...e);if(t.bearingDelta||t.pitchDelta||t.rollDelta||t.around||t.panDelta)return this._active=!0,t}dragStart(e,t){this.isEnabled()&&!this._lastPoint&&this._moveStateManager.isValidStartEvent(e)&&(this._moveStateManager.startMove(e),this._lastPoint=Array.isArray(t)?t[0]:t,this._activateOnStart&&this._lastPoint&&(this._active=!0))}dragMove(e,t){if(!this.isEnabled())return;let i=this._lastPoint;if(!i)return;if(e.preventDefault(),!this._moveStateManager.isValidMoveEvent(e)){this.reset(e);return}let r=Array.isArray(t)?t[0]:t;if(!(!this._moved&&r.dist(i)<this._clickTolerance))return this._moved=!0,this._lastPoint=r,this._move(i,r)}dragEnd(e){this.isEnabled()&&this._lastPoint&&this._moveStateManager.isValidEndEvent(e)&&(this._moved&&ne.suppressClick(),this.reset(e))}enable(){this._enabled=!0}disable(){this._enabled=!1,this.reset()}isEnabled(){return this._enabled}isActive(){return this._active}getClickTolerance(){return this._clickTolerance}},yR={0:1,2:2};function vR(e,t){let i=yR[t];return e.buttons===void 0||(e.buttons&i)!==i}var ko=class{constructor(e){this._correctEvent=e.checkCorrectEvent}startMove(e){this._eventButton=e.button}endMove(e){delete this._eventButton}isValidStartEvent(e){return this._correctEvent(e)}isValidMoveEvent(e){return!vR(e,this._eventButton)}isValidEndEvent(e){return e.button===this._eventButton}},xR=class{constructor(){this._firstTouch=void 0}_isOneFingerTouch(e){return e.targetTouches.length===1}_isSameTouchEvent(e){return e.targetTouches[0].identifier===this._firstTouch}startMove(e){this._firstTouch=e.targetTouches[0].identifier}endMove(e){delete this._firstTouch}isValidStartEvent(e){return this._isOneFingerTouch(e)}isValidMoveEvent(e){return this._isOneFingerTouch(e)&&this._isSameTouchEvent(e)}isValidEndEvent(e){return this._isOneFingerTouch(e)&&this._isSameTouchEvent(e)}},bR=class{constructor(e=new ko({checkCorrectEvent:()=>!0}),t=new xR){this.mouseMoveStateManager=e,this.oneFingerTouchMoveStateManager=t}_executeRelevantHandler(e,t,i){if(e instanceof MouseEvent)return t(e);if(typeof TouchEvent<"u"&&e instanceof TouchEvent)return i(e)}startMove(e){this._executeRelevantHandler(e,t=>{this.mouseMoveStateManager.startMove(t)},t=>{this.oneFingerTouchMoveStateManager.startMove(t)})}endMove(e){this._executeRelevantHandler(e,t=>{this.mouseMoveStateManager.endMove(t)},t=>{this.oneFingerTouchMoveStateManager.endMove(t)})}isValidStartEvent(e){return!!this._executeRelevantHandler(e,t=>this.mouseMoveStateManager.isValidStartEvent(t),t=>this.oneFingerTouchMoveStateManager.isValidStartEvent(t))}isValidMoveEvent(e){return!!this._executeRelevantHandler(e,t=>this.mouseMoveStateManager.isValidMoveEvent(t),t=>this.oneFingerTouchMoveStateManager.isValidMoveEvent(t))}isValidEndEvent(e){return!!this._executeRelevantHandler(e,t=>this.mouseMoveStateManager.isValidEndEvent(t),t=>this.oneFingerTouchMoveStateManager.isValidEndEvent(t))}},ru=e=>{e.mousedown=e.dragStart,e.mousemoveWindow=e.dragMove,e.mouseup=e.dragEnd,e.contextmenu=t=>{t.preventDefault()}};function wR({enable:e,clickTolerance:t}){return new Ro({clickTolerance:t,move:(i,r)=>({around:r,panDelta:r.sub(i)}),activateOnStart:!0,moveStateManager:new ko({checkCorrectEvent:i=>i.button===0&&!i.ctrlKey}),enable:e,assignEvents:ru})}function TR({enable:e,clickTolerance:t,aroundCenter:i=!0,minPixelCenterThreshold:r=100,rotateSpeed:a=.8},n){return new Ro({clickTolerance:t,move:(o,s)=>{let l=n();if(i&&Math.abs(l.y-o.y)>r)return{bearingDelta:$_(new C(o.x,s.y),s,l)};let u=(s.x-o.x)*a;return i&&s.y<l.y&&(u=-u),{bearingDelta:u}},moveStateManager:new ko({checkCorrectEvent:o=>o.button===0&&o.ctrlKey||o.button===2&&!o.ctrlKey}),enable:e,assignEvents:ru})}function ER({enable:e,clickTolerance:t,pitchSpeed:i=-.5}){return new Ro({clickTolerance:t,move:(r,a)=>({pitchDelta:(a.y-r.y)*i}),moveStateManager:new ko({checkCorrectEvent:r=>r.button===0&&r.ctrlKey||r.button===2}),enable:e,assignEvents:ru})}function DR({enable:e,clickTolerance:t,rollDegreesPerPixelMoved:i=.3},r){return new Ro({clickTolerance:t,move:(a,n)=>{let o=r(),s=(n.x-a.x)*i;return n.y<o.y&&(s=-s),{rollDelta:s}},moveStateManager:new ko({checkCorrectEvent:a=>a.button===2&&a.ctrlKey}),enable:e,assignEvents:ru})}var SR=class{constructor(e,t){this._clickTolerance=e.clickTolerance||1,this._map=t,this.reset()}reset(){this._active=!1,this._touches={},this._sum=new C(0,0)}_shouldBePrevented(e){return e<(this._map.cooperativeGestures.isEnabled()?2:1)}touchstart(e,t,i){return this._calculateTransform(e,t,i)}touchmove(e,t,i){if(this._active){if(this._shouldBePrevented(i.length)){this._map.cooperativeGestures.notifyGestureBlocked("touch_pan",e);return}return e.preventDefault(),this._calculateTransform(e,t,i)}}touchend(e,t,i){this._calculateTransform(e,t,i),this._active&&this._shouldBePrevented(i.length)&&this.reset()}touchcancel(){this.reset()}_calculateTransform(e,t,i){i.length>0&&(this._active=!0);let r=sd(i,t),a=new C(0,0),n=new C(0,0),o=0;for(let l in r){let u=r[l],h=this._touches[l];h&&(a._add(u),n._add(u.sub(h)),o++,r[l]=u)}if(this._touches=r,this._shouldBePrevented(o)||!n.mag())return;let s=n.div(o);if(this._sum._add(s),!(this._sum.mag()<this._clickTolerance))return{around:a.div(o),panDelta:s}}enable(){this._enabled=!0}disable(){this._enabled=!1,this.reset()}isEnabled(){return this._enabled}isActive(){return this._active}},Op=class{constructor(){this.reset()}reset(){this._active=!1,delete this._firstTwoTouches}touchstart(e,t,i){this._firstTwoTouches||i.length<2||(this._firstTwoTouches=[i[0].identifier,i[1].identifier],this._start([t[0],t[1]]))}touchmove(e,t,i){if(!this._firstTwoTouches)return;e.preventDefault();let[r,a]=this._firstTwoTouches,n=Ps(i,t,r),o=Ps(i,t,a);if(!n||!o)return;let s=this._aroundCenter?null:n.add(o).div(2);return this._move([n,o],s,e)}touchend(e,t,i){if(!this._firstTwoTouches)return;let[r,a]=this._firstTwoTouches,n=Ps(i,t,r),o=Ps(i,t,a);n&&o||(this._active&&ne.suppressClick(),this.reset())}touchcancel(){this.reset()}enable(e){this._enabled=!0,this._aroundCenter=!!e&&e.around==="center"}disable(){this._enabled=!1,this.reset()}isEnabled(){return!!this._enabled}isActive(){return!!this._active}};function Ps(e,t,i){for(let r=0;r<e.length;r++)if(e[r].identifier===i)return t[r]}var x_=.1;function b_(e,t){return Math.log(e/t)/Math.LN2}var Mx=class extends Op{constructor(){super(),this._zoomRate=1,this._zoomThreshold=x_}setZoomRate(e){this._zoomRate=e??1}setZoomThreshold(e){this._zoomThreshold=e??x_}reset(){super.reset(),delete this._distance,delete this._startDistance}_start(e){this._startDistance=this._distance=e[0].dist(e[1])}_move(e,t){let i=this._distance;if(this._distance=e[0].dist(e[1]),!(!this._active&&Math.abs(b_(this._distance,this._startDistance))<this._zoomThreshold))return this._active=!0,{zoomDelta:b_(this._distance,i)*this._zoomRate,pinchAround:t}}};function w_(e,t){return e.angleWith(t)*180/Math.PI}var Fx=class extends Op{reset(){super.reset(),delete this._minDiameter,delete this._startVector,delete this._vector}_start(e){this._startVector=this._vector=e[0].sub(e[1]),this._minDiameter=e[0].dist(e[1])}_move(e,t,i){let r=this._vector;if(this._vector=e[0].sub(e[1]),this._active||!this._isBelowThreshold(this._vector))return this._active=!0,{bearingDelta:w_(this._vector,r),pinchAround:t}}_isBelowThreshold(e){this._minDiameter=Math.min(this._minDiameter,e.mag());let t=25/(Math.PI*this._minDiameter)*360,i=w_(e,this._startVector);return Math.abs(i)<t}};function Th(e){return Math.abs(e.y)>Math.abs(e.x)}var zx=class extends Op{constructor(e){super(),this._currentTouchCount=0,this._map=e}reset(){super.reset(),this._valid=void 0,delete this._firstMove,delete this._lastPoints}touchstart(e,t,i){super.touchstart(e,t,i),this._currentTouchCount=i.length}_start(e){this._lastPoints=e,Th(e[0].sub(e[1]))&&(this._valid=!1)}_move(e,t,i){if(this._map.cooperativeGestures.isEnabled()&&this._currentTouchCount<3)return;let r=e[0].sub(this._lastPoints[0]),a=e[1].sub(this._lastPoints[1]);if(this._valid=this.gestureBeginsVertically(r,a,i.timeStamp),this._valid)return this._lastPoints=e,this._active=!0,{pitchDelta:(r.y+a.y)/2*-.5}}gestureBeginsVertically(e,t,i){if(this._valid!==void 0)return this._valid;let r=e.mag()>=2,a=t.mag()>=2;if(!r&&!a)return;if(!r||!a)return this._firstMove===void 0&&(this._firstMove=i),i-this._firstMove<100&&void 0;let n=e.y>0==t.y>0;return Th(e)&&Th(t)&&n}},CR={panStep:100,bearingStep:15,pitchStep:10},Rx=class{constructor(e,t){this._tr=t;let i=CR;this._panStep=i.panStep,this._bearingStep=i.bearingStep,this._pitchStep=i.pitchStep,this._rotationDisabled=!1}reset(){this._active=!1}keydown(e){if(e.altKey||e.ctrlKey||e.metaKey)return;let t=0,i=0,r=0,a=0,n=0;switch(e.keyCode){case 61:case 107:case 171:case 187:t=1;break;case 189:case 109:case 173:t=-1;break;case 37:e.shiftKey?i=-1:(e.preventDefault(),a=-1);break;case 39:e.shiftKey?i=1:(e.preventDefault(),a=1);break;case 38:e.shiftKey?r=1:(e.preventDefault(),n=-1);break;case 40:e.shiftKey?r=-1:(e.preventDefault(),n=1);break;default:return}return this._rotationDisabled&&(i=0,r=0),{cameraAnimation:o=>{let s=this._tr;o.easeTo({duration:300,easeId:"keyboardHandler",easing:PR,zoom:t?ri(s.zoom+t*(e.shiftKey?2:1),o.getZoomSnap()):s.zoom,bearing:s.bearing+i*this._bearingStep,pitch:s.pitch+r*this._pitchStep,offset:[-a*this._panStep,-n*this._panStep],center:s.center},{originalEvent:e})}}}enable(){this._enabled=!0}disable(){this._enabled=!1,this.reset()}isEnabled(){return this._enabled}isActive(){return this._active}disableRotation(){this._rotationDisabled=!0}enableRotation(){this._rotationDisabled=!1}};function PR(e){return e*(2-e)}var T_=4.000244140625,kx=class{constructor(e,t,i){this._onTimeout=r=>{this._type="wheel",this._delta-=this._lastValue,this._active||this._start(r)},this._map=e,this._tr=i,this._triggerRenderFrame=t,this._delta=0,this._defaultZoomRate=.01,this._wheelZoomRate=.0022222222222222222}setZoomRate(e){this._defaultZoomRate=e}setWheelZoomRate(e){this._wheelZoomRate=e}isEnabled(){return!!this._enabled}isActive(){return!!this._active||this._finishTimeout!==void 0}isZooming(){return!!this._zooming}enable(e){this.isEnabled()||(this._enabled=!0,this._aroundCenter=!!e&&e.around==="center")}disable(){this.isEnabled()&&(this._enabled=!1)}_shouldBePrevented(e){return this._map.cooperativeGestures.isEnabled()?!(e.ctrlKey||this._map.cooperativeGestures.isBypassed(e)):!1}wheel(e){if(!this.isEnabled())return;if(this._shouldBePrevented(e)){this._map.cooperativeGestures.notifyGestureBlocked("wheel_zoom",e);return}let t=e.deltaMode===WheelEvent.DOM_DELTA_LINE?e.deltaY*40:e.deltaY,i=Ie(),r=i-(this._lastWheelEventTime||0);this._lastWheelEventTime=i,t!==0&&t%T_==0?this._type="wheel":t!==0&&Math.abs(t)<4?this._type="trackpad":r>400?(this._type=null,this._lastValue=t,this._timeout=setTimeout(this._onTimeout,40,e)):this._type||(this._type=Math.abs(r*t)<200?"trackpad":"wheel",this._timeout&&(clearTimeout(this._timeout),this._timeout=null,t+=this._lastValue)),e.shiftKey&&t&&(t/=4),this._type&&(this._lastWheelEvent=e,this._delta-=t,this._active||this._start(e)),e.preventDefault()}_start(e){if(!this._delta)return;this._needsRerender=!1,this._active=!0,this.isZooming()||(this._zooming=!0),this._finishTimeout&&(clearTimeout(this._finishTimeout),delete this._finishTimeout);let t=ne.mousePos(this._map.getCanvas(),e),i=this._tr;this._aroundPoint=this._aroundCenter?i.transform.locationToScreenPoint(X.convert(i.center)):t,this._needsRerender||(this._needsRerender=!0,this._triggerRenderFrame())}renderFrame(){if(!this._needsRerender||(this._needsRerender=!1,!this.isActive()))return;let e=this._tr.transform;if(typeof this._lastExpectedZoom=="number"){let o=e.zoom-this._lastExpectedZoom;typeof this._startZoom=="number"&&(this._startZoom+=o),typeof this._targetZoom=="number"&&(this._targetZoom+=o)}if(this._delta!==0){let o=this._type==="wheel"&&Math.abs(this._delta)>T_?this._wheelZoomRate:this._defaultZoomRate,s=2/(1+Math.exp(-Math.abs(this._delta*o)));this._delta<0&&s!==0&&(s=1/s);let l=typeof this._targetZoom=="number"?It(this._targetZoom):e.scale,u=e.applyConstrain(e.getCameraLngLat(),Mt(l*s)).zoom,h=this._map.getZoomSnap();if(this._type==="wheel"&&h>0){let c=ri(e.zoom,h);this._targetZoom=ri(u,h,u-c)}else this._targetZoom=u;this._type==="wheel"&&(this._startZoom=e.zoom,this._easing=this._smoothOutEasing(200)),this._delta=0}let t=typeof this._targetZoom=="number"?this._targetZoom:e.zoom,i=this._startZoom,r=this._easing,a=!1,n;if(this._type==="wheel"&&i&&r){let o=Ie()-this._lastWheelEventTime,s=Math.min((o+5)/200,1),l=r(s);n=He.number(i,t,l),s<1?this._needsRerender=!0:a=!0}else n=t,a=!0;return this._active=!0,a&&(this._active=!1,this._finishTimeout=setTimeout(()=>{this._zooming=!1,this._triggerRenderFrame(),delete this._targetZoom,delete this._lastExpectedZoom,delete this._finishTimeout},200)),this._lastExpectedZoom=n,{noInertia:!0,needsRenderFrame:!a,zoomDelta:n-e.zoom,around:this._aroundPoint,originalEvent:this._lastWheelEvent}}_smoothOutEasing(e){let t=Mh;if(this._prevEase){let i=this._prevEase,r=(Ie()-i.start)/i.duration,a=i.easing(r+.01)-i.easing(r),n=.27/Math.sqrt(a*a+1e-4)*.01;t=yd(n,Math.sqrt(.0729-n*n),.25,1)}return this._prevEase={start:Ie(),duration:e,easing:t},t}reset(){this._active=!1,this._zooming=!1,delete this._targetZoom,delete this._lastExpectedZoom,this._finishTimeout&&(clearTimeout(this._finishTimeout),delete this._finishTimeout)}},Lx=class{constructor(e,t){this._clickZoom=e,this._tapZoom=t}enable(){this._clickZoom.enable(),this._tapZoom.enable()}disable(){this._clickZoom.disable(),this._tapZoom.disable()}isEnabled(){return this._clickZoom.isEnabled()&&this._tapZoom.isEnabled()}isActive(){return this._clickZoom.isActive()||this._tapZoom.isActive()}},AR=class{constructor(e,t){this._tr=t,this.reset()}reset(){this._active=!1}dblclick(e,t){return e.preventDefault(),{cameraAnimation:i=>{i.easeTo({duration:300,zoom:ri(this._tr.zoom+(e.shiftKey?-1:1),i.getZoomSnap()),around:this._tr.transform.isPointOnMapSurface(t)?this._tr.unproject(t):void 0},{originalEvent:e})}}}enable(){this._enabled=!0}disable(){this._enabled=!1,this.reset()}isEnabled(){return this._enabled}isActive(){return this._active}},IR=class{constructor(){this._tap=new ld({numTouches:1,numTaps:1}),this._zoomRate=1,this.reset()}setZoomRate(e){this._zoomRate=e??1}reset(){this._active=!1,delete this._swipePoint,delete this._swipeTouch,delete this._tapTime,delete this._tapPoint,this._tap.reset()}touchstart(e,t,i){if(!this._swipePoint)if(!this._tapTime)this._tap.touchstart(e,t,i);else{let r=t[0],a=e.timeStamp-this._tapTime<500,n=this._tapPoint.dist(r)<30;!a||!n?this.reset():i.length>0&&(this._swipePoint=r,this._swipeTouch=i[0].identifier)}}touchmove(e,t,i){if(!this._tapTime)this._tap.touchmove(e,t,i);else if(this._swipePoint){if(i[0].identifier!==this._swipeTouch)return;let r=t[0],a=r.y-this._swipePoint.y;return this._swipePoint=r,e.preventDefault(),this._active=!0,{zoomDelta:a/128*this._zoomRate}}}touchend(e,t,i){if(this._tapTime)this._swipePoint&&i.length===0&&this.reset();else{let r=this._tap.touchend(e,t,i);r&&(this._tapTime=e.timeStamp,this._tapPoint=r)}}touchcancel(){this.reset()}enable(){this._enabled=!0}disable(){this._enabled=!1,this.reset()}isEnabled(){return this._enabled}isActive(){return this._active}},Bx=class{constructor(e,t,i){this._el=e,this._mousePan=t,this._touchPan=i}enable(e){this._inertiaOptions=e||{},this._mousePan.enable(),this._touchPan.enable(),this._el.classList.add("maplibregl-touch-drag-pan")}disable(){this._mousePan.disable(),this._touchPan.disable(),this._el.classList.remove("maplibregl-touch-drag-pan")}isEnabled(){return this._mousePan.isEnabled()&&this._touchPan.isEnabled()}isActive(){return this._mousePan.isActive()||this._touchPan.isActive()}},Ox=class{constructor(e,t,i,r){this._pitchWithRotate=e.pitchWithRotate,this._rollEnabled=e.rollEnabled,this._mouseRotate=t,this._mousePitch=i,this._mouseRoll=r}enable(){this._mouseRotate.enable(),this._pitchWithRotate&&this._mousePitch.enable(),this._rollEnabled&&this._mouseRoll.enable()}disable(){this._mouseRotate.disable(),this._mousePitch.disable(),this._mouseRoll.disable()}isEnabled(){return this._mouseRotate.isEnabled()&&(!this._pitchWithRotate||this._mousePitch.isEnabled())&&(!this._rollEnabled||this._mouseRoll.isEnabled())}isActive(){return this._mouseRotate.isActive()||this._mousePitch.isActive()||this._mouseRoll.isActive()}},jx=class{constructor(e,t,i,r){this._el=e,this._touchZoom=t,this._touchRotate=i,this._tapDragZoom=r,this._rotationDisabled=!1,this._enabled=!0}enable(e){this._touchZoom.enable(e),this._rotationDisabled||this._touchRotate.enable(e),this._tapDragZoom.enable(),this._el.classList.add("maplibregl-touch-zoom-rotate")}disable(){this._touchZoom.disable(),this._touchRotate.disable(),this._tapDragZoom.disable(),this._el.classList.remove("maplibregl-touch-zoom-rotate")}isEnabled(){return this._touchZoom.isEnabled()&&(this._rotationDisabled||this._touchRotate.isEnabled())&&this._tapDragZoom.isEnabled()}isActive(){return this._touchZoom.isActive()||this._touchRotate.isActive()||this._tapDragZoom.isActive()}setZoomRate(e){this._touchZoom.setZoomRate(e),this._tapDragZoom.setZoomRate(e)}setZoomThreshold(e){this._touchZoom.setZoomThreshold(e)}disableRotation(){this._rotationDisabled=!0,this._touchRotate.disable()}enableRotation(){this._rotationDisabled=!1,this._touchZoom.isEnabled()&&this._touchRotate.enable()}},Vx=class{constructor(e,t){this._bypassKey=navigator.userAgent.includes("Mac")?"metaKey":"ctrlKey",this._map=e,this._options=t,this._enabled=!1}isActive(){return!1}reset(){}_setupUI(){if(this._container)return;let e=this._map.getCanvasContainer();e.classList.add("maplibregl-cooperative-gestures"),this._container=ne.create("div","maplibregl-cooperative-gesture-screen",e);let t=this._map._getUIString("CooperativeGesturesHandler.WindowsHelpText");this._bypassKey==="metaKey"&&(t=this._map._getUIString("CooperativeGesturesHandler.MacHelpText"));let i=this._map._getUIString("CooperativeGesturesHandler.MobileHelpText"),r=document.createElement("div");r.className="maplibregl-desktop-message",r.textContent=t,this._container.appendChild(r);let a=document.createElement("div");a.className="maplibregl-mobile-message",a.textContent=i,this._container.appendChild(a),this._container.setAttribute("aria-hidden","true")}_destroyUI(){this._container&&(this._container.remove(),this._map.getCanvasContainer().classList.remove("maplibregl-cooperative-gestures")),delete this._container}enable(){this._setupUI(),this._enabled=!0}disable(){this._enabled=!1,this._destroyUI()}isEnabled(){return this._enabled}isBypassed(e){return e[this._bypassKey]}notifyGestureBlocked(e,t){this._enabled&&(this._map.fire(new gt("cooperativegestureprevented",{gestureType:e,originalEvent:t})),this._container.classList.add("maplibregl-show"),setTimeout(()=>{this._container.classList.remove("maplibregl-show")},100))}},MR=class{constructor(e){this._camera=e}get transform(){return this._camera._requestedCameraState||this._camera.transform}get center(){return{lng:this.transform.center.lng,lat:this.transform.center.lat}}get zoom(){return this.transform.zoom}get pitch(){return this.transform.pitch}get bearing(){return this.transform.bearing}unproject(e){return this.transform.screenPointToLocation(C.convert(e),this._camera.terrain)}},As=e=>e.zoom||e.drag||e.roll||e.pitch||e.rotate,FR=class extends li{};function Eh(e){return e.panDelta?.mag()||e.zoomDelta||e.bearingDelta||e.pitchDelta||e.rollDelta}var zR=class{get _ownerDocument(){return this._el?.ownerDocument||document}get _ownerWindow(){return this._el?.ownerDocument?.defaultView||window}constructor(e,t,i){this._terrainGesture={inFlight:!1,anchorElevation:null,anchorCenterElevation:null},this.handleWindowEvent=a=>{this.handleEvent(a,`${a.type}Window`)},this.handleEvent=(a,n)=>{if(a.type==="blur"){this.stop(!0);return}this._updatingCamera=!0;let o=a.type==="renderFrame"?void 0:a,s={needsRenderFrame:!1},l={},u={};for(let{handlerName:d,handler:p,allowed:f}of this._handlers){if(!p.isEnabled())continue;let m;if(this._blockedByActive(u,f,d))p.reset();else if(p[n||a.type]){if(lw(a,n||a.type)){let g=ne.mousePos(this._map.getCanvas(),a);m=p[n||a.type](a,g)}else if(sw(a,n||a.type)){let g=a.touches,_=this._getMapTouches(g),y=ne.touchPos(this._map.getCanvas(),_);m=p[n||a.type](a,y,_)}else uw(n||a.type)||(m=p[n||a.type](a));this.mergeHandlerResult(s,l,m,d,o),m?.needsRenderFrame&&this._triggerRenderFrame()}(m||p.isActive())&&(u[d]=p)}let h={};for(let d in this._previousActiveHandlers)u[d]||(h[d]=o);this._previousActiveHandlers=u,(Object.keys(h).length||Eh(s))&&(this._changes.push([s,l,h]),this._triggerRenderFrame()),(Object.keys(u).length||Eh(s))&&this._camera.stop(!0),this._updatingCamera=!1;let{cameraAnimation:c}=s;c&&(this._inertia.clear(),this._fireEvents({},{},!0),this._changes=[],c(this._map))},this._map=e,this._camera=t,this._transformProvider=new MR(this._camera),this._el=this._map.getCanvasContainer(),this._handlers=[],this._handlersById={},this._changes=[],this._inertia=new dR(e),this._bearingSnap=i.bearingSnap,this._previousActiveHandlers={},this._eventsInProgress={},this._addDefaultHandlers(i);let r=this._el;this._listeners=[[r,"touchstart",{passive:!0}],[r,"touchmove",{passive:!1}],[r,"touchend",void 0],[r,"touchcancel",void 0],[r,"mousedown",void 0],[r,"mousemove",void 0],[r,"mouseup",void 0],[this._ownerDocument,"mousemove",{capture:!0}],[this._ownerDocument,"mouseup",void 0],[r,"mouseover",void 0],[r,"mouseout",void 0],[r,"dblclick",void 0],[r,"click",void 0],[r,"keydown",{capture:!1}],[r,"keyup",void 0],[r,"wheel",{passive:!1}],[r,"contextmenu",void 0],[this._ownerWindow,"blur",void 0]];for(let[a,n,o]of this._listeners)a.addEventListener(n,a===this._ownerDocument?this.handleWindowEvent:this.handleEvent,o)}destroy(){for(let[e,t,i]of this._listeners)e.removeEventListener(t,e===this._ownerDocument?this.handleWindowEvent:this.handleEvent,i)}_addDefaultHandlers(e){let t=this._map,i=t.getCanvasContainer();this._add("mapEvent",new pR(t,e));let r=t.boxZoom=new Ix(t,e,this._transformProvider);this._add("boxZoom",r),e.interactive&&e.boxZoom&&r.enable();let a=t.cooperativeGestures=new Vx(t,e.cooperativeGestures);this._add("cooperativeGestures",a),e.cooperativeGestures&&a.enable();let n=new _R(t,this._transformProvider),o=new AR(t,this._transformProvider);t.doubleClickZoom=new Lx(o,n),this._add("tapZoom",n),this._add("clickZoom",o),e.interactive&&e.doubleClickZoom&&t.doubleClickZoom.enable();let s=new IR;this._add("tapDragZoom",s);let l=t.touchPitch=new zx(t);this._add("touchPitch",l),e.interactive&&e.touchPitch&&t.touchPitch.enable(e.touchPitch);let u=()=>this._camera.transform.centerPoint,h=TR(e,u),c=ER(e),d=DR(e,u);t.dragRotate=new Ox(e,h,c,d),this._add("mouseRotate",h,["mousePitch"]),this._add("mousePitch",c,["mouseRotate","mouseRoll"]),this._add("mouseRoll",d,["mousePitch"]),e.interactive&&e.dragRotate&&t.dragRotate.enable();let p=wR(e),f=new SR(e,t);t.dragPan=new Bx(i,p,f),this._add("mousePan",p),this._add("touchPan",f,["touchZoom","touchRotate"]),e.interactive&&e.dragPan&&t.dragPan.enable(e.dragPan);let m=new Fx,g=new Mx;t.touchZoomRotate=new jx(i,g,m,s),this._add("touchRotate",m,["touchPan","touchZoom"]),this._add("touchZoom",g,["touchPan","touchRotate"]),e.interactive&&e.touchZoomRotate&&t.touchZoomRotate.enable(e.touchZoomRotate),this._add("blockableMapEvent",new fR(t,e),["touchPan"]);let _=t.scrollZoom=new kx(t,()=>this._triggerRenderFrame(),this._transformProvider);this._add("scrollZoom",_,["mousePan"]),e.interactive&&e.scrollZoom&&t.scrollZoom.enable(e.scrollZoom);let y=t.keyboard=new Rx(t,this._transformProvider);this._add("keyboard",y),e.interactive&&e.keyboard&&t.keyboard.enable()}_add(e,t,i){this._handlers.push({handlerName:e,handler:t,allowed:i}),this._handlersById[e]=t}stop(e){if(!this._updatingCamera){for(let{handler:t}of this._handlers)t.reset();this._inertia.clear(),this._fireEvents({},{},e),this._changes=[]}}isActive(){for(let{handler:e}of this._handlers)if(e.isActive())return!0;return!1}isZooming(){return!!this._eventsInProgress.zoom||this._map.scrollZoom.isZooming()}isRotating(){return!!this._eventsInProgress.rotate}isMoving(){return!!As(this._eventsInProgress)||this.isZooming()}_blockedByActive(e,t,i){for(let r in e)if(r!==i&&!t?.includes(r))return!0;return!1}_getMapTouches(e){let t=[];for(let i of e){let r=i.target;this._el.contains(r)&&t.push(i)}return t}mergeHandlerResult(e,t,i,r,a){if(!i)return;q(e,i);let n={handlerName:r,originalEvent:i.originalEvent||a};i.zoomDelta!==void 0&&(t.zoom=n),i.panDelta!==void 0&&(t.drag=n),i.rollDelta!==void 0&&(t.roll=n),i.pitchDelta!==void 0&&(t.pitch=n),i.bearingDelta!==void 0&&(t.rotate=n)}_applyChanges(){let e={},t={},i={};for(let[r,a,n]of this._changes)r.panDelta&&(e.panDelta=(e.panDelta||new C(0,0))._add(r.panDelta)),r.zoomDelta&&(e.zoomDelta=(e.zoomDelta||0)+r.zoomDelta),r.bearingDelta&&(e.bearingDelta=(e.bearingDelta||0)+r.bearingDelta),r.pitchDelta&&(e.pitchDelta=(e.pitchDelta||0)+r.pitchDelta),r.rollDelta&&(e.rollDelta=(e.rollDelta||0)+r.rollDelta),r.around!==void 0&&(e.around=r.around),r.pinchAround!==void 0&&(e.pinchAround=r.pinchAround),r.noInertia&&(e.noInertia=r.noInertia),q(t,a),q(i,n);this._updateMapTransform(e,t,i),this._changes=[]}_updateMapTransform(e,t,i){let r=this._map.terrain;if(!Eh(e)){this._fireEvents(t,i,!0);return}let a=this._camera.getTransformForUpdate();this._camera.stop(!0);let{panDelta:n,zoomDelta:o,bearingDelta:s,pitchDelta:l,rollDelta:u}=e;o>0&&this._terrainGesture.inFlight&&this._camera.moveCenterOntoTerrain(a,o);let{around:h,aroundOnSurface:c}=this._resolveAround(e,r,a),d=r?this._terrainGestureElevation(r,h,c,a,t):void 0,p={panDelta:n,zoomDelta:o,rollDelta:u,pitchDelta:l,bearingDelta:s,around:h,aroundElevation:d};this._camera.cameraHelper.useGlobeControls&&!a.isPointOnMapSurface(h)&&(h=a.centerPoint);let f=this._computePreZoomAroundLoc(a,h,n,d);this._handleMapControls({terrain:r,tr:a,deltasForHelper:p,preZoomAroundLoc:f,combinedEventsInProgress:t,panDelta:n}),this._camera.applyUpdatedTransform(a),this._map._update(),e.noInertia||this._inertia.record(e),this._fireEvents(t,i,!0)}_resolveAround(e,t,i){let r=e.pinchAround===void 0?e.around:e.pinchAround;return r||(r=this._camera.transform.centerPoint),t&&!i.isPointOnMapSurface(r)?{around:i.centerPoint,aroundOnSurface:!1}:{around:r,aroundOnSurface:!0}}_terrainGestureElevation(e,t,i,r,a){if(!i)return;if(this._terrainGesture.anchorCenterElevation!==r.elevation&&(a.drag||a.zoom)){let o=r.screenTerrainPointToMercatorCoordinate(t,e);this._terrainGesture.anchorElevation=o?o.z:void 0,this._terrainGesture.anchorCenterElevation=r.elevation}let n=this._terrainGesture.anchorElevation;if(n!=null&&!(t.distSqr(r.centerPoint)<.01)&&!(n-r.elevation>=.9*(r.getCameraAltitude()-r.elevation)))return n}_computePreZoomAroundLoc(e,t,i,r){if(t.distSqr(e.centerPoint)<.01)return e.center;let a=i?t.sub(i):t;return r===void 0?e.screenPointToLocation(a):e.screenPointToLocationAtElevation(a,r)}_handleMapControls({terrain:e,tr:t,deltasForHelper:i,preZoomAroundLoc:r,combinedEventsInProgress:a,panDelta:n}){let o=this._camera.cameraHelper;if(o.handleMapControlsRollPitchBearingZoom(i,t),!e&&!o.useGlobeControls&&!t.isPointOnMapSurface(i.around)){n&&t.setCenter(t.screenPointToLocation(t.centerPoint.sub(n)));return}if(!e){o.handleMapControlsPan(i,t,r);return}if(!this._terrainGesture.inFlight){this._terrainGesture.inFlight=!0,this._camera.holdElevation(t,"gesture"),o.handleMapControlsPan(i,t,r);return}if(!o.useGlobeControls&&i.aroundElevation===void 0&&a.drag&&n){t.setCenter(t.screenPointToLocation(t.centerPoint.sub(n)));return}o.handleMapControlsPan(i,t,r)}_fireEvents(e,t,i){let r=As(this._eventsInProgress),a=As(e),n={};for(let h in e){let{originalEvent:c}=e[h];this._eventsInProgress[h]||(n[`${h}start`]=c),this._eventsInProgress[h]=e[h]}!r&&a&&this._fireEvent("movestart",a.originalEvent);for(let h in n)this._fireEvent(h,n[h]);a&&this._fireEvent("move",a.originalEvent);for(let h in e){let{originalEvent:c}=e[h];this._fireEvent(h,c)}let o={},s;for(let h in this._eventsInProgress){let{handlerName:c,originalEvent:d}=this._eventsInProgress[h];this._handlersById[c].isActive()||(delete this._eventsInProgress[h],s=t[c]||d,o[`${h}end`]=s)}for(let h in o)this._fireEvent(h,o[h]);let l=As(this._eventsInProgress),u=(r||a)&&!l;if(u&&this._terrainGesture.inFlight){let h=this._camera.releaseElevation();this._terrainGesture={inFlight:!1,anchorElevation:null,anchorCenterElevation:null},this._camera.applyTransformChange(c=>{this._map.getCenterClampedToGround()&&(this._map.terrain?this._camera.putCenterBackOnTerrain(c,this._map.terrain,h):c.setElevation(0))})}if(i&&u){this._updatingCamera=!0;let h=this._inertia._onMoveEnd(this._map.dragPan._inertiaOptions),c=d=>d!==0&&-this._bearingSnap<d&&d<this._bearingSnap;h&&(h.essential||!Kt.prefersReducedMotion)?(c(h.bearing||this._map.getBearing())&&(h.bearing=0),h.freezeElevation=!0,this._map.easeTo(h,{originalEvent:s})):(this._fireEvent("moveend",s),c(this._map.getBearing())&&this._map.resetNorth()),this._updatingCamera=!1}}_fireEvent(e,t){this._camera.fire(new Q(e,t?{originalEvent:t}:{}))}_requestFrame(){return this._map.triggerRepaint(),this._map._renderTaskQueue.add(e=>{delete this._frameId,this.handleEvent(new FR("renderFrame",{timeStamp:e})),this._applyChanges()})}_triggerRenderFrame(){this._frameId===void 0&&(this._frameId=this._requestFrame())}},RR=class{constructor(e,t){this.holder=e,this.startedWithoutDem=t,this.lift=null,this._terrainChanged=!1,this.awaitsDem=t}get tookDem(){return this.startedWithoutDem&&!this.awaitsDem}noteTerrainChange(){this.startedWithoutDem&&(this._terrainChanged=!0)}take(e,t){let i=!1;if(this._terrainChanged&&(this._terrainChanged=!1,t.hasElevationForLngLat(e.center,e)||(e.setElevation(0),this.awaitsDem=!0,i=!0)),!this.awaitsDem)return i;let r=t.getDrawnElevationForLngLat(e.center,!0);if(r!==void 0)return e.setElevation(r),this.awaitsDem=!1,!0;let a=t.getDrawnElevationForLngLat(e.center);return a===void 0||a<=e.elevation||e.getCameraAltitude()>=t.getElevationForLngLatZoom(e.getCameraLngLat(),e.zoom)?i:(e.setElevation(a),!0)}},kR=class extends ht{constructor(e){super(),this._elevationHold=null,this._renderFrameCallback=()=>{let t=Math.min((Ie()-this._easeStart)/this._easeOptions.duration,1);this._onEaseFrame(this._easeOptions.easing(t)),t<1&&this._easeFrameId?this._easeFrameId=this._requestRenderFrame(this._renderFrameCallback):this.stop()},this.transform=new bl,this.cameraHelper=new wl,e.minZoom!==void 0&&this.transform.setMinZoom(e.minZoom),e.maxZoom!==void 0&&this.transform.setMaxZoom(e.maxZoom),e.minPitch!==void 0&&this.transform.setMinPitch(e.minPitch),e.maxPitch!==void 0&&this.transform.setMaxPitch(e.maxPitch),e.renderWorldCopies!==void 0&&this.transform.setRenderWorldCopies(e.renderWorldCopies),e.transformConstrain!==null&&this.transform.setConstrainOverride(e.transformConstrain),this._moving=!1,this._zooming=!1,this._bearingSnap=e.bearingSnap,this._zoomSnap=e.zoomSnap,this._requestRenderFrame=e.requestRenderFrame,this._cancelRenderFrame=e.cancelRenderFrame,this.terrain=e.terrain,this._centerClampedToGround=e.centerClampedToGround??!0,this.transformCameraUpdate=e.transformCameraUpdate??null,this._stopHandlers=e.stopHandlers??(()=>{}),this.on("moveend",()=>{delete this._requestedCameraState})}setTerrain(e){this.terrain=e,e&&this._elevationHold?.noteTerrainChange(),this.applyTerrainChange()}migrateProjection(e,t){if(e.apply(this.transform,!0),this.transform=e,this.cameraHelper=t,this._requestedCameraState){let i=e.clone();i.apply(this._requestedCameraState,!0),this._requestedCameraState=i}}getCenter(){return new X(this.transform.center.lng,this.transform.center.lat)}setCenter(e,t){return this.jumpTo({center:e},t)}getCenterElevation(){return this.transform.elevation}setCenterElevation(e,t){return this.jumpTo({elevation:e},t),this}getCenterClampedToGround(){return this._centerClampedToGround}setCenterClampedToGround(e){this._centerClampedToGround=e}panBy(e,t,i){return e=C.convert(e).mult(-1),this.panTo(this.transform.center,q({offset:e},t),i)}panTo(e,t,i){return this.easeTo(q({center:e},t),i)}getZoom(){return this.transform.zoom}setZoom(e,t){return this.jumpTo({zoom:e},t),this}zoomTo(e,t,i){return this.easeTo(q({zoom:e},t),i)}zoomIn(e,t){return this.zoomTo(ri(this.getZoom()+1,this._zoomSnap),e,t),this}zoomOut(e,t){return this.zoomTo(ri(this.getZoom()-1,this._zoomSnap),e,t),this}getVerticalFieldOfView(){return this.transform.fov}setVerticalFieldOfView(e,t){return e!=this.transform.fov&&(this.applyTransformChange(i=>i.setFov(e)),this.fire(new Q("movestart",t)).fire(new Q("move",t)).fire(new Q("moveend",t))),this}getBearing(){return this.transform.bearing}setZoomSnap(e){return this._zoomSnap=e,this}getZoomSnap(){return this._zoomSnap}setBearing(e,t){return this.jumpTo({bearing:e},t),this}getPadding(){return this.transform.padding}setPadding(e,t){return this.jumpTo({padding:e},t),this}rotateTo(e,t,i){return this.easeTo(q({bearing:e},t),i)}resetNorth(e,t){return this.rotateTo(0,q({duration:1e3},e),t),this}resetNorthPitch(e,t){return this.easeTo(q({bearing:0,pitch:0,roll:0,duration:1e3},e),t),this}snapToNorth(e,t){return Math.abs(this.getBearing())<this._bearingSnap?this.resetNorth(e,t):this}getPitch(){return this.transform.pitch}setPitch(e,t){return this.jumpTo({pitch:e},t),this}getRoll(){return this.transform.roll}setRoll(e,t){return this.jumpTo({roll:e},t),this}cameraForBounds(e,t){e=zi.convert(e).adjustAntiMeridian();let i=t?.bearing||0;return this._cameraForBoxAndBearing(e.getNorthWest(),e.getSouthEast(),i,t)}_cameraForBoxAndBearing(e,t,i,r){let a={top:0,bottom:0,right:0,left:0};if(r=q({padding:a,offset:[0,0],maxZoom:this.transform.maxZoom},r),typeof r.padding=="number"){let d=r.padding;r.padding={top:d,bottom:d,right:d,left:d}}let n=q(a,r.padding);r.padding=n;let o=this.transform,s=new zi(e,t),l={top:0,bottom:0,right:0,left:0},u=r.absolutePadding?l:n,h=r.absolutePadding?n:q(l,o.padding),c=this.cameraHelper.cameraForBoxAndBearing(r,u,h,s,i,o);if(c)return this._zoomSnap&&(c.zoom=ri(c.zoom,this._zoomSnap,-1)),r.absolutePadding?{...c,padding:n}:c}fitBounds(e,t,i){return this._fitInternal(this.cameraForBounds(e,t),t,i)}fitScreenCoordinates(e,t,i,r,a){return this._fitInternal(this._cameraForBoxAndBearing(this.transform.screenPointToLocation(C.convert(e)),this.transform.screenPointToLocation(C.convert(t)),i,r),r,a)}_fitInternal(e,t,i){return e?(t=q(e,t),t.absolutePadding?(t.padding=e.padding,delete t.absolutePadding):delete t.padding,t.linear?this.easeTo(t,i):this.flyTo(t,i)):this}jumpTo(e,t){this.stop(),e.zoom!==void 0&&this._zoomSnap&&(e.zoom=ri(e.zoom,this._zoomSnap));let i=this.getTransformForUpdate(),r=!1,a=!1,n=!1,o=i.zoom;this.terrain&&this.getCenterClampedToGround()&&i.setElevation(this.terrain.getElevationForLngLat(e.center?X.convert(e.center):i.center,i)),this.cameraHelper.handleJumpToCenterZoom(i,e);let s=i.zoom!==o;return e.elevation!==void 0&&i.elevation!==+e.elevation&&i.setElevation(+e.elevation),e.bearing!==void 0&&i.bearing!==+e.bearing&&(r=!0,i.setBearing(+e.bearing)),e.pitch!==void 0&&i.pitch!==+e.pitch&&(a=!0,i.setPitch(+e.pitch)),e.roll!==void 0&&i.roll!==+e.roll&&(n=!0,i.setRoll(+e.roll)),e.padding!=null&&!i.isPaddingEqual(e.padding)&&i.setPadding(e.padding),this.applyUpdatedTransform(i),this.fire(new Q("movestart",t)).fire(new Q("move",t)),s&&this.fire(new Q("zoomstart",t)).fire(new Q("zoom",t)).fire(new Q("zoomend",t)),r&&this.fire(new Q("rotatestart",t)).fire(new Q("rotate",t)).fire(new Q("rotateend",t)),a&&this.fire(new Q("pitchstart",t)).fire(new Q("pitch",t)).fire(new Q("pitchend",t)),n&&this.fire(new Q("rollstart",t)).fire(new Q("roll",t)).fire(new Q("rollend",t)),this.fire(new Q("moveend",t))}calculateAnchoredCameraOptions(e){let t=this.transform.clone(),i=X.convert(e.anchorLocation),r=C.convert(e.anchorScreenPoint),a={panDelta:r.sub(this.transform.locationToScreenPoint(i,this.terrain)),zoomDelta:e.zoom===void 0?0:e.zoom-t.zoom,bearingDelta:0,pitchDelta:0,rollDelta:0,around:r,aroundElevation:this.terrain?.getElevationForLngLat(i,t)};return this.cameraHelper.handleMapControlsRollPitchBearingZoom(a,t),this.cameraHelper.handleMapControlsPan(a,t,i),{center:t.center,zoom:t.zoom}}calculateCameraOptionsFromCameraLngLatAltRotation(e,t,i,r,a){let n=this.transform.calculateCenterFromCameraLngLatAlt(e,t,i,r);return{center:n.center,elevation:n.elevation,zoom:n.zoom,bearing:i,pitch:r,roll:a}}easeTo(e,t){this._stop(!1,e.easeId),e=q({offset:[0,0],duration:500,easing:Mh},e),e.zoom!==void 0&&this._zoomSnap&&(e.zoom=ri(e.zoom,this._zoomSnap)),(e.animate===!1||!e.essential&&Kt.prefersReducedMotion)&&(e.duration=0);let i=this.getTransformForUpdate(),r=this.getBearing(),a=i.pitch,n=i.roll,o=e.bearing===void 0?r:this._normalizeBearing(e.bearing,r),s=e.pitch===void 0?a:+e.pitch,l=e.roll===void 0?n:this._normalizeBearing(e.roll,n),u=e.padding===void 0?i.padding:e.padding,h=C.convert(e.offset),c,d;e.around&&(c=X.convert(e.around),d=i.locationToScreenPoint(c));let p={moving:this._moving,zooming:this._zooming,rotating:this._rotating,pitching:this._pitching,rolling:this._rolling},f=this.cameraHelper.handleEaseTo(i,{bearing:o,pitch:s,roll:l,padding:u,around:c,aroundPoint:d,offsetAsPoint:h,offset:e.offset,zoom:e.zoom,center:e.center});return this._rotating||(this._rotating=r!==o),this._pitching||(this._pitching=s!==a),this._rolling||(this._rolling=l!==n),this._padding=!i.isPaddingEqual(u),this._zooming||(this._zooming=f.isZooming),this._easeId=e.easeId,this._prepareEase(t,e.noMoveStart,p,{tr:i,center:f.elevationCenter,freeze:e.freezeElevation}),this._ease(m=>{f.easeFunc(m),this.terrain&&!e.freezeElevation&&this._updateElevation(m,i),this.applyUpdatedTransform(i),this._fireMoveEvents(t)},m=>{this._afterEase(t,m,e.freezeElevation)},e),this}_prepareEase(e,t,i={},r){this._moving=!0,this.terrain&&r&&(this._prepareElevation(r.center,r.tr),r.freeze&&this.holdElevation(r.tr,"animation")),!t&&!i.moving&&this.fire(new Q("movestart",e)),this._zooming&&!i.zooming&&this.fire(new Q("zoomstart",e)),this._rotating&&!i.rotating&&this.fire(new Q("rotatestart",e)),this._pitching&&!i.pitching&&this.fire(new Q("pitchstart",e)),this._rolling&&!i.rolling&&this.fire(new Q("rollstart",e))}_prepareElevation(e,t){this._elevationCenter=e,this._elevationStart=t.elevation,this._elevationTarget=this.terrain.getElevationForLngLat(e,t),this.elevationFreeze=!0}_updateElevation(e,t){(this._elevationStart===void 0||this._elevationCenter===void 0)&&this._prepareElevation(t.center,t),t.setMinElevationForCurrentTile(this.terrain.getMinTileElevationForLngLatZoom(this._elevationCenter,t.tileZoom));let i=this.terrain.getElevationForLngLat(this._elevationCenter,t);if(e<1&&i!==this._elevationTarget){let r=this._elevationTarget-this._elevationStart,a=(i-(r*e+this._elevationStart))/(1-e);this._elevationStart+=e*(r-a),this._elevationTarget=i}this.getCenterClampedToGround()&&t.setElevation(He.number(this._elevationStart,this._elevationTarget,e))}holdElevation(e,t){this.elevationFreeze=!0;let i=!!this.terrain&&this.getCenterClampedToGround()&&!this.terrain.hasElevationForLngLat(e.center,e);this._elevationHold=new RR(t,i)}releaseElevation(){let e=this._elevationHold?.tookDem??!1;return this.elevationFreeze=!1,this._elevationHold=null,e}putCenterBackOnTerrain(e,t,i){if(i&&t.getDrawnElevationForLngLat(e.center,!0)===void 0){e.setElevation(t.getElevationForLngLat(e.center,e));let r=this._raiseCameraByPitchAndZoom(e);r!==e&&e.apply(r,!1)}else e.recalculateZoomAndCenter(t)}_takeLandedElevation(e){return!this._elevationHold||!this.terrain||!this.getCenterClampedToGround()?!1:this._elevationHold.take(e,this.terrain)}applyTerrainChange(){if(this.elevationFreeze){let t=this._requestedCameraState;this._elevationHold?.holder==="gesture"&&t&&this._takeLandedElevation(t)&&this.applyUpdatedTransform(t);return}let e=this.transform;e.setMinElevationForCurrentTile(this.terrain?this.terrain.getMinTileElevationForLngLatZoom(e.center,e.tileZoom):0),this.getCenterClampedToGround()&&e.setElevation(this.terrain?this.terrain.getElevationForLngLat(e.center,e):0)}getTransformForUpdate(){return!this.transformCameraUpdate&&!this.terrain?this.transform:(this._requestedCameraState||(this._requestedCameraState=this.transform.clone()),this._requestedCameraState)}_keepCameraAboveTerrain(e){let t=this._elevationHold;if(!this.terrain||t?.holder!=="gesture"||e.pitch>=90||!this.getCenterClampedToGround()||e.getClippingPlane())return this._raiseCameraByPitchAndZoom(e);let i=t.lift&&t.lift.heldElevation+t.lift.height===e.elevation?t.lift:{heldElevation:e.elevation,height:0},r=Math.max(0,this._terrainHeightAboveCamera(e)+i.height);return r!==i.height&&e.setElevation(i.heldElevation+r),t.lift=r>0?{heldElevation:i.heldElevation,height:r}:null,e}_raiseCameraByPitchAndZoom(e){if(!this.terrain&&e.elevation>=0&&e.pitch<=90||e.getClippingPlane())return e;let t=e.getCameraLngLat(),i=this.terrain?this._terrainHeightAboveCamera(e):-e.getCameraAltitude();if(i<=0)return e;let r=e.clone();for(let a=0;a<3&&i>0;a++){let{zoom:n,pitch:o}=r.calculateCameraOptionsFromTo(t,r.getCameraAltitude()+i,r.center,r.elevation);r.setZoom(n),r.setPitch(o),i=this.terrain?this._terrainHeightAboveCamera(r):-r.getCameraAltitude()}return r}_terrainHeightAboveCamera(e){let t=this.terrain.getElevationForLngLat(e.getCameraLngLat(),e)-e.getCameraAltitude(),i=e.getClippingPlane()?null:this.terrain.getCoverageIndex();if(!i)return t;let[r,a,n,o]=e.getCameraFrustum().points;for(let s=0;s<=2;s++){let l=s/2;for(let u=0;u<=2;u++){let h=u/2,c=(1-h)*(1-l),d=h*(1-l),p=h*l,f=(1-h)*l,m=c*r[0]+d*a[0]+p*n[0]+f*o[0],g=c*r[1]+d*a[1]+p*n[1]+f*o[1],_=c*r[2]+d*a[2]+p*n[2]+f*o[2],y=Fo(i,this.terrain.exaggeration,m,g);y.covered&&(t=Math.max(t,y.elevation-_))}}return t}moveCenterOntoTerrain(e,t){if(!this.terrain||!this.getCenterClampedToGround()||e.getClippingPlane())return;let{center:i,elevation:r,zoom:a}=e;e.recalculateZoomAndCenter(this.terrain),(!(e.zoom>a-t&&e.zoom<e.maxZoom)||Math.abs(this.terrain.getElevationForLngLat(e.center,e)-e.elevation)>=1)&&(e.setZoom(a),e.setCenter(i),e.setElevation(r))}applyUpdatedTransform(e){this._takeLandedElevation(e);let t=this._keepCameraAboveTerrain(e);if(!this.transformCameraUpdate){t!==this.transform&&this.transform.apply(t,!1);return}let i=t.clone(),{center:r,zoom:a,roll:n,pitch:o,bearing:s,elevation:l}=this.transformCameraUpdate(i);r&&i.setCenter(r),l!==void 0&&i.setElevation(l),a!==void 0&&i.setZoom(a),n!==void 0&&i.setRoll(n),o!==void 0&&i.setPitch(o),s!==void 0&&i.setBearing(s),this.transform.apply(l===void 0?i:this._raiseCameraByPitchAndZoom(i),!1)}applyTransformChange(e){let t=this._requestedCameraState!==void 0,i=this.getTransformForUpdate();e(i),this.applyUpdatedTransform(i),t||delete this._requestedCameraState}_fireMoveEvents(e){this.fire(new Q("move",e)),this._zooming&&this.fire(new Q("zoom",e)),this._rotating&&this.fire(new Q("rotate",e)),this._pitching&&this.fire(new Q("pitch",e)),this._rolling&&this.fire(new Q("roll",e))}_afterEase(e,t,i=!1){this._takeLandedElevation(this.transform);let r=this.releaseElevation();if(this.terrain&&i&&this.getCenterClampedToGround()&&this.putCenterBackOnTerrain(this.transform,this.terrain,r),this._easeId&&t&&this._easeId===t)return;delete this._easeId;let a=this._zooming,n=this._rotating,o=this._pitching,s=this._rolling;this._moving=!1,this._zooming=!1,this._rotating=!1,this._pitching=!1,this._rolling=!1,this._padding=!1,a&&this.fire(new Q("zoomend",e)),n&&this.fire(new Q("rotateend",e)),o&&this.fire(new Q("pitchend",e)),s&&this.fire(new Q("rollend",e)),this.fire(new Q("moveend",e))}flyTo(e,t){if(!e.essential&&Kt.prefersReducedMotion){let I=yo(e,["center","zoom","bearing","pitch","roll","elevation","padding"]);return this.jumpTo(I,t)}this.stop(),e=q({offset:[0,0],speed:1.2,curve:1.42,easing:Mh},e),e.zoom!==void 0&&this._zoomSnap&&(e.zoom=ri(e.zoom,this._zoomSnap));let i=this.getTransformForUpdate(),r=i.bearing,a=i.pitch,n=i.roll,o=i.padding,s=e.bearing===void 0?r:this._normalizeBearing(e.bearing,r),l=e.pitch===void 0?a:+e.pitch,u=e.roll===void 0?n:this._normalizeBearing(e.roll,n),h=e.padding===void 0?i.padding:e.padding,c=C.convert(e.offset),d=i.centerPoint.add(c),p=i.screenPointToLocation(d),f=this.cameraHelper.handleFlyTo(i,{bearing:s,pitch:l,roll:u,padding:h,locationAtOffset:p,offsetAsPoint:c,center:e.center,minZoom:e.minZoom,zoom:e.zoom}),m=e.curve,g=Math.max(i.width,i.height),_=g/f.scaleOfZoom,y=f.pixelPathLength,v=g/f.scaleOfMinZoom;m=Math.min(m,Math.sqrt(v/y*2));let x=m*m;function b(I){let D=(_*_-g*g+(I?-1:1)*x*x*y*y)/(2*(I?_:g)*x*y);return Math.log(Math.sqrt(D*D+1)-D)}function w(I){return(Math.exp(I)-Math.exp(-I))/2}function T(I){return(Math.exp(I)+Math.exp(-I))/2}function E(I){return w(I)/T(I)}let S=b(!1),M=function(I){return T(S)/T(S+m*I)},z=function(I){return g*((T(S)*E(S+m*I)-w(S))/x)/y},R=(b(!0)-S)/m;if(Math.abs(y)<2e-6||!isFinite(R)){if(Math.abs(g-_)<1e-6)return this.easeTo(e,t);let I=_<g?-1:1;R=Math.abs(Math.log(_/g))/m,z=()=>0,M=D=>Math.exp(I*m*D)}if(e.duration!==void 0)e.duration=+e.duration;else{let I=e.screenSpeed===void 0?+e.speed:+e.screenSpeed/m;e.duration=1e3*R/I}return e.maxDuration&&e.duration>e.maxDuration&&(e.duration=0),this._zooming=!0,this._rotating=r!==s,this._pitching=l!==a,this._rolling=u!==n,this._padding=!i.isPaddingEqual(h),this._prepareEase(t,!1,{},{tr:i,center:f.targetCenter,freeze:e.freezeElevation}),this._ease(I=>{let D=I*R,P=1/M(D),A=z(D);this._rotating&&i.setBearing(He.number(r,s,I)),this._pitching&&i.setPitch(He.number(a,l,I)),this._rolling&&i.setRoll(He.number(n,u,I)),this._padding&&(i.interpolatePadding(o,h,I),d=i.centerPoint.add(c)),f.easeFunc(I,P,A,d),this.terrain&&!e.freezeElevation&&this._updateElevation(I,i),this.applyUpdatedTransform(i),this._fireMoveEvents(t)},()=>{this._afterEase(t,void 0,e.freezeElevation)},e),this}isEasing(){return!!this._easeFrameId}stop(e){return this._stop(e)}_stop(e,t){if(this._easeFrameId&&(this._cancelRenderFrame(this._easeFrameId),delete this._easeFrameId,delete this._onEaseFrame),this._onEaseEnd){let i=this._onEaseEnd;delete this._onEaseEnd,i.call(this,t)}return e||this._stopHandlers(),this}_ease(e,t,i){i.animate===!1||i.duration===0?(e(1),t()):(this._easeStart=Ie(),this._easeOptions=i,this._onEaseFrame=e,this._onEaseEnd=t,this._easeFrameId=this._requestRenderFrame(this._renderFrameCallback))}_normalizeBearing(e,t){e=vi(e,-180,180);let i=Math.abs(e-t);return Math.abs(e-360-t)<i&&(e-=360),Math.abs(e+360-t)<i&&(e+=360),e}isMoving(){return this._moving}isZooming(){return this._zooming}isRotating(){return this._rotating}},Nx={compact:!0,customAttribution:'<a href="https://maplibre.org/" target="_blank">MapLibre</a>'},Ux=class{constructor(e=Nx){this._toggleAttribution=()=>{this._container.classList.contains("maplibregl-compact")&&(this._container.classList.contains("maplibregl-compact-show")?(this._container.setAttribute("open",""),this._container.classList.remove("maplibregl-compact-show")):(this._container.classList.add("maplibregl-compact-show"),this._container.removeAttribute("open")))},this._updateData=t=>{t&&(t.type==="terrain"||t.dataType==="style"||t.dataType==="source"&&(t.sourceDataType==="metadata"||t.sourceDataType==="visibility"))&&this._updateAttributions()},this._updateCompact=()=>{this._map.getCanvasContainer().offsetWidth<=640||this._compact?this._compact===!1?this._container.setAttribute("open",""):!this._container.classList.contains("maplibregl-compact")&&!this._container.classList.contains("maplibregl-attrib-empty")&&(this._container.setAttribute("open",""),this._container.classList.add("maplibregl-compact","maplibregl-compact-show")):(this._container.setAttribute("open",""),this._container.classList.contains("maplibregl-compact")&&this._container.classList.remove("maplibregl-compact","maplibregl-compact-show"))},this._updateCompactMinimize=()=>{this._container.classList.contains("maplibregl-compact")&&this._container.classList.contains("maplibregl-compact-show")&&this._container.classList.remove("maplibregl-compact-show")},this.options=e}getDefaultPosition(){return"bottom-right"}onAdd(e){return this._map=e,this._compact=this.options.compact,this._container=ne.create("details","maplibregl-ctrl maplibregl-ctrl-attrib"),this._compactButton=ne.create("summary","maplibregl-ctrl-attrib-button",this._container),this._compactButton.addEventListener("click",this._toggleAttribution),this._setElementTitle(this._compactButton,"ToggleAttribution"),this._innerContainer=ne.create("div","maplibregl-ctrl-attrib-inner",this._container),this._updateAttributions(),this._updateCompact(),this._map.on("styledata",this._updateData),this._map.on("sourcedata",this._updateData),this._map.on("terrain",this._updateData),this._map.on("resize",this._updateCompact),this._map.on("drag",this._updateCompactMinimize),this._container}onRemove(){this._container.remove(),this._map.off("styledata",this._updateData),this._map.off("sourcedata",this._updateData),this._map.off("terrain",this._updateData),this._map.off("resize",this._updateCompact),this._map.off("drag",this._updateCompactMinimize),this._map=void 0,this._compact=void 0,this._attribHTML=void 0}_setElementTitle(e,t){let i=this._map._getUIString(`AttributionControl.${t}`);e.title=i,e.setAttribute("aria-label",i)}_updateAttributions(){if(!this._map.style)return;let e=[];if(this.options.customAttribution&&(Array.isArray(this.options.customAttribution)?e=e.concat(this.options.customAttribution.map(r=>typeof r=="string"?r:"")):typeof this.options.customAttribution=="string"&&e.push(this.options.customAttribution)),this._map.style.stylesheet){let r=this._map.style.stylesheet;this.styleOwner=r.owner,this.styleId=r.id}let t=this._map.style.tileManagers;for(let r in t){let a=t[r];if(a.used||a.usedForTerrain){let n=a.getSource();n.attribution&&!e.includes(n.attribution)&&e.push(n.attribution)}}e=e.filter(r=>String(r).trim()),e.sort((r,a)=>r.length-a.length),e=e.filter((r,a)=>{for(let n=a+1;n<e.length;n++)if(e[n].includes(r))return!1;return!0});let i=e.join(" | ");if(i!==this._attribHTML){if(this._attribHTML=i,e.length){let r=document.createDocumentFragment(),a=!0;for(let n of e){let o=ne.sanitize(n);o.hasChildNodes()&&(a||r.append(" | "),r.append(o),a=!1)}this._innerContainer.replaceChildren(r),this._container.classList.remove("maplibregl-attrib-empty")}else this._container.classList.add("maplibregl-attrib-empty");this._updateCompact(),this._editLink=null}}},$x=class{constructor(e={}){this._updateCompact=()=>{let t=this._container.children;if(t.length){let i=t[0];this._map.getCanvasContainer().offsetWidth<=640||this._compact?this._compact!==!1&&i.classList.add("maplibregl-compact"):i.classList.remove("maplibregl-compact")}},this.options=e}getDefaultPosition(){return"bottom-left"}onAdd(e){this._map=e,this._compact=this.options?.compact,this._container=ne.create("div","maplibregl-ctrl");let t=ne.create("a","maplibregl-ctrl-logo");return t.target="_blank",t.rel="noopener nofollow",t.href="https://maplibre.org/",t.setAttribute("aria-label",this._map._getUIString("LogoControl.Title")),t.setAttribute("rel","noopener nofollow"),this._container.appendChild(t),this._container.style.display="block",this._map.on("resize",this._updateCompact),this._updateCompact(),this._container}onRemove(){this._container.remove(),this._map.off("resize",this._updateCompact),this._map=void 0,this._compact=void 0}},LR=class{constructor(){this._queue=[],this._id=0,this._cleared=!1,this._currentlyRunning=!1}add(e){let t=++this._id;return this._queue.push({callback:e,id:t,cancelled:!1}),t}remove(e){let t=this._currentlyRunning,i=t?this._queue.concat(t):this._queue;for(let r of i)if(r.id===e){r.cancelled=!0;return}}run(e=0){if(this._currentlyRunning)throw Error("Attempting to run(), but is already running.");let t=this._currentlyRunning=this._queue;this._queue=[];let i=!1,r;for(let a of t)if(!a.cancelled){try{a.callback(e)}catch(n){i||(i=!0,r=n)}if(this._cleared)break}if(this._cleared=!1,this._currentlyRunning=!1,i)throw r}clear(){this._currentlyRunning&&(this._cleared=!0),this._queue=[]}},BR=Je([{name:"a_pos3d",type:"Int16",components:3}]),OR=class extends ht{constructor(e){super(),this._lastTilesetChange=Ie(),this.tileManager=e,this._tiles={},this._renderableTilesKeys=[],this._sourceTileCache={},this.minzoom=0,this.maxzoom=22,this.deltaZoom=1,this.tileSize=e._source.tileSize*2**this.deltaZoom,e.usedForTerrain=!0,e.tileSize=this.tileSize}destruct(){this.tileManager.usedForTerrain=!1,this.tileManager.tileSize=null,this.releaseAllRTT()}getSource(){return this.tileManager._source}update(e,t){this.tileManager.update(e,t),this._renderableTilesKeys=[];let i={},r=!1;for(let a of Mo(e,{tileSize:this.tileSize,minzoom:this.minzoom,maxzoom:this.maxzoom,reparseOverscaled:!1,terrain:t}))i[a.key]=!0,this._renderableTilesKeys.push(a.key),this._tiles[a.key]||(a.terrainRttPosMatrix32f=new Float32Array(16),ir(a.terrainRttPosMatrix32f,0,k,k,0,0,1),this._tiles[a.key]=new Bv(a,this.tileSize),this._lastTilesetChange=Ie(),r=!0);for(let a in this._tiles)i[a]||(this._tiles[a].releaseRTT(this.tileManager.map.painter),delete this._tiles[a],r=!0);return r}releaseRTT(e){for(let t in this._tiles){let i=this._tiles[t];(i.tileID.equals(e)||i.tileID.isChildOf(e)||e.isChildOf(i.tileID))&&i.releaseRTT(this.tileManager.map.painter)}}releaseAllRTT(){for(let e in this._tiles)this._tiles[e].releaseRTT(this.tileManager.map.painter)}getRenderableTiles(){return this._renderableTilesKeys.map(e=>this.getTileByID(e))}getTileByID(e){return this._tiles[e]}getTerrainCoords(e,t){return t?this._getTerrainCoordsForTileRanges(e,t):this._getTerrainCoordsForRegularTile(e)}_getTerrainCoordsForRegularTile(e){let t={};for(let i of this._renderableTilesKeys){let r=this._tiles[i].tileID,a=e.clone(),n=Ur();if(r.canonical.equals(e.canonical))ir(n,0,k,k,0,0,1);else if(r.canonical.isChildOf(e.canonical)){let o=r.canonical.z-e.canonical.z,s=r.canonical.x-(r.canonical.x>>o<<o),l=r.canonical.y-(r.canonical.y>>o<<o),u=k>>o;ir(n,0,u,u,0,0,1),lt(n,n,[-s*u,-l*u,0])}else if(e.canonical.isChildOf(r.canonical)){let o=e.canonical.z-r.canonical.z,s=e.canonical.x-(e.canonical.x>>o<<o),l=e.canonical.y-(e.canonical.y>>o<<o),u=k>>o;ir(n,0,k,k,0,0,1),lt(n,n,[s*u,l*u,0]),kt(n,n,[1/2**o,1/2**o,0])}else continue;a.terrainRttPosMatrix32f=new Float32Array(n),t[i]=a}return t}_getTerrainCoordsForTileRanges(e,t){let i={};for(let r of this._renderableTilesKeys){let a=this._tiles[r].tileID;if(!this._isWithinTileRanges(a,t))continue;let n=e.clone(),o=Ur();if(a.canonical.z===e.canonical.z){let s=e.canonical.x-a.canonical.x+e.wrap*(1<<e.canonical.z),l=e.canonical.y-a.canonical.y;ir(o,0,k,k,0,0,1),lt(o,o,[s*k,l*k,0])}else if(a.canonical.z>e.canonical.z){let s=a.canonical.z-e.canonical.z,l=a.canonical.x-(a.canonical.x>>s<<s)+e.wrap*(1<<a.canonical.z),u=a.canonical.y-(a.canonical.y>>s<<s),h=e.canonical.x-(a.canonical.x>>s),c=e.canonical.y-(a.canonical.y>>s),d=k>>s;ir(o,0,d,d,0,0,1),lt(o,o,[-l*d+h*k,-u*d+c*k,0])}else{let s=e.canonical.z-a.canonical.z,l=e.canonical.x-(e.canonical.x>>s<<s)+e.wrap*(1<<e.canonical.z),u=e.canonical.y-(e.canonical.y>>s<<s),h=(e.canonical.x>>s)-a.canonical.x,c=(e.canonical.y>>s)-a.canonical.y,d=k<<s;ir(o,0,d,d,0,0,1),lt(o,o,[l*k+h*d,u*k+c*d,0])}n.terrainRttPosMatrix32f=new Float32Array(o),i[r]=n}return i}getSourceTile(e,t){var n,o;let i=this.tileManager._source,r=e.overscaledZ-this.deltaZoom;if(r>i.maxzoom&&(r=i.maxzoom),r<i.minzoom)return;(n=this._sourceTileCache)[o=e.key]||(n[o]=e.scaledTo(r).key);let a=this.findTileInCaches(this._sourceTileCache[e.key]);if(!a?.dem&&t)for(;r>=i.minzoom&&!a?.dem;)a=this.findTileInCaches(e.scaledTo(r--).key);return a}findTileInCaches(e){let t=this.tileManager.getTileByID(e);return t||(t=this.tileManager._outOfViewCache.getByKey(e),t)}anyTilesAfterTime(e=Ie()){return this._lastTilesetChange>=e}_isWithinTileRanges(e,t){let i=t[e.canonical.z];return!!i&&(e.wrap>i.minWrap||e.wrap<i.maxWrap||e.canonical.x>=i.minTileXWrapped&&e.canonical.x<=i.maxTileXWrapped&&e.canonical.y>=i.minTileY&&e.canonical.y<=i.maxTileY)}},jR=class{constructor(e,t,i,r="auto"){this._meshCache={},this.painter=e,this.tileManager=new OR(t),this.options=i,this.exaggeration=typeof i.exaggeration=="number"?i.exaggeration:1,this._terrainSkirtLength=r,this.qualityFactor=2,this.meshSize=128,this._demMatrixCache=new Map,this.coverage=new Z3(this.tileManager,this.exaggeration)}destroy(){this._fbo&&(this._fbo=(this._fbo.destroy(),null)),this._heightMapFbo&&(this._heightMapFbo=(this._heightMapFbo.destroy(),null)),this._fboDepthTexture&&(this._fboDepthTexture=(this._fboDepthTexture.destroy(),null)),this._emptyDemTexture&&(this._emptyDemTexture=(this._emptyDemTexture.destroy(),null)),this._emptyDepthTexture&&(this._emptyDepthTexture=(this._emptyDepthTexture.destroy(),null));for(let e in this._meshCache)this._meshCache[e].destroy();this._meshCache={},this.tileManager.destruct()}getDEMElevation(e,t,i,r=k){let a=e.normalizeCoordinates(t,i,r);if(!a)return 0;let n=this.coverage.getSampler(a.tileID);return n?n(a.x,a.y,r):0}getElevationForLngLatZoom(e,t){if(!ah(t,e.wrap()))return 0;let{tileID:i,mercatorX:r,mercatorY:a}=this._getOverscaledTileIDFromLngLatZoom(e,t);return this.getElevation(i,r%k,a%k,k)}getElevationForLngLat(e,t){let i=this.getDrawnElevationForLngLat(e);return i===void 0?this.getElevationForLngLatZoom(e,this._getFallbackZoom(t)):i}getDrawnElevationForLngLat(e,t=!1){return this.coverage.sample(e,t)}hasElevationForLngLat(e,t){if(this.getDrawnElevationForLngLat(e)!==void 0)return!0;let i=this._getFallbackZoom(t);if(!ah(i,e.wrap()))return!1;let{tileID:r}=this._getOverscaledTileIDFromLngLatZoom(e,i);return!!this.tileManager.getSourceTile(r,!0)?.dem}_getFallbackZoom(e){return Math.min(e.tileZoom,this.tileManager.maxzoom)}getElevation(e,t,i,r=k){return this.getDEMElevation(e,t,i,r)*this.exaggeration}resetElevationCache(){this.coverage.reset()}getCoverageIndex(){return this.coverage.getIndex()}_getDEMTileMatrix(e,t){let i=`${t.tileID.key}/${e.key}`,r=this._demMatrixCache.get(i);if(r)return r;let a=e.canonical.z-t.tileID.canonical.z,n=e.canonical.x-(e.canonical.x>>a<<a),o=e.canonical.y-(e.canonical.y>>a<<a),s=Tb(new Float64Array(16),[1/(k<<a),1/(k<<a),0]);return lt(s,s,[n*k,o*k,0]),this._demMatrixCache.set(i,s),s}getTerrainData(e){if(!this._emptyDemTexture){let r=this.painter.context,a=new Ve({width:1,height:1},new Uint8Array(4));this._emptyDepthTexture=new pt(r,a,r.gl.RGBA,{premultiply:!1}),this._emptyDemUnpack=[0,0,0,0],this._emptyDemTexture=new pt(r,new Ve({width:1,height:1}),r.gl.RGBA,{premultiply:!1}),this._emptyDemTexture.bind(r.gl.NEAREST,r.gl.CLAMP_TO_EDGE),this._emptyDemMatrix=Mi([])}let t=this.tileManager.getSourceTile(e,!0);if(t?.dem&&(!t.demTexture||t.needsTerrainPrepare)){let r=this.painter.context;t.demTexture||(t.demTexture=this.painter.getTileTexture(t.dem.stride)),t.demTexture?t.demTexture.update(t.dem.getPixels(),{premultiply:!1}):t.demTexture=new pt(r,t.dem.getPixels(),r.gl.RGBA,{premultiply:!1}),t.demTexture.bind(r.gl.NEAREST,r.gl.CLAMP_TO_EDGE),t.needsTerrainPrepare=!1}let i=t?this._getDEMTileMatrix(e,t):this._emptyDemMatrix;return{u_depth:2,u_terrain:3,u_terrain_dim:t?.dem?.dim||1,u_terrain_matrix:i,u_terrain_unpack:t?.dem?.getUnpackVector()||this._emptyDemUnpack,u_terrain_exaggeration:this.exaggeration,texture:(t?.demTexture||this._emptyDemTexture).texture,depthTexture:(this._fboDepthTexture||this._emptyDepthTexture).texture,tile:t}}getFramebuffer(){let e=this.painter,t=e.width/devicePixelRatio,i=e.height/devicePixelRatio;return this._fbo&&(this._fbo.width!==t||this._fbo.height!==i)&&(this._fbo.destroy(),this._fboDepthTexture.destroy(),delete this._fbo,delete this._fboDepthTexture),this._fboDepthTexture||(this._fboDepthTexture=new pt(e.context,{width:t,height:i,data:null},e.context.gl.RGBA,{premultiply:!1}),this._fboDepthTexture.bind(e.context.gl.NEAREST,e.context.gl.CLAMP_TO_EDGE)),this._fbo||(this._fbo=e.context.createFramebuffer(t,i,!0,!1),this._fbo.depthAttachment.set(e.context.createRenderbuffer(e.context.gl.DEPTH_COMPONENT16,t,i))),this._fbo.colorAttachment.set(this._fboDepthTexture.texture),this._fbo}getHeightMapFramebuffer(e){return this._heightMapFbo||(this._heightMapFbo=this.painter.context.createFramebuffer(1,1,!1,!1)),this._heightMapFbo.colorAttachment.set(e),this._heightMapFbo}getTerrainMesh(e,t){let i=t&&e.canonical.y===0,r=t&&e.canonical.y===(1<<e.canonical.z)-1,a=`m_${i?"n":""}_${r?"s":""}`;if(this._meshCache[a])return this._meshCache[a];let n=this.painter.context,o=new OT,s=new Xi,l=this.meshSize,u=k/l,h=l*l;for(let d=0;d<=l;d++)for(let p=0;p<=l;p++)o.emplaceBack(p*u,d*u,0);for(let d=0;d<h;d+=l+1)for(let p=0;p<l;p++)s.emplaceBack(p+d,l+p+d+1,l+p+d+2),s.emplaceBack(p+d,l+p+d+2,p+d+1);this._terrainSkirtLength!=="none"&&this._buildSkirts(o,s,l,u,i,r);let c=new go(n.createVertexBuffer(o,BR.members),n.createIndexBuffer(s),Ye.simpleSegment(0,0,o.length,s.length));return this._meshCache[a]=c,c}getSkirtLength(e){return 2*Math.PI*jt/2**Math.max(e,0)/5}getMinTileElevationForLngLatZoom(e,t){if(!ah(t,e.wrap()))return 0;let{tileID:i}=this._getOverscaledTileIDFromLngLatZoom(e,t);return this.getMinMaxElevation(i).minElevation??0}getMinMaxElevation(e){let t=this.tileManager.getSourceTile(e,!0),i={minElevation:null,maxElevation:null};return t?.dem&&(i.minElevation=t.dem.min*this.exaggeration,i.maxElevation=t.dem.max*this.exaggeration),i}_getOverscaledTileIDFromLngLatZoom(e,t){let i=De.fromLngLat(e.wrap()),r=(1<<t)*k,a=i.x*r,n=i.y*r;return{tileID:new Ct(t,0,t,Math.floor(a/k),Math.floor(n/k)),mercatorX:a,mercatorY:n}}_buildSkirts(e,t,i,r,a,n){let o=e.length,s=o+(i+1),l=(i+1)*i,u=a?Gn:0,h=+!a,c=n?Zn:k,d=+!n;for(let m=0;m<=i;m++)e.emplaceBack(m*r,u,h);for(let m=0;m<=i;m++)e.emplaceBack(m*r,c,d);for(let m=0;m<i;m++)t.emplaceBack(l+m,s+m,s+m+1),t.emplaceBack(l+m,s+m+1,l+m+1),t.emplaceBack(0+m,o+m+1,o+m),t.emplaceBack(0+m,0+m+1,o+m+1);let p=e.length,f=p+(i+1)*2;for(let m of[0,1])for(let g=0;g<=i;g++)for(let _ of[0,1])e.emplaceBack(m*k,g*r,_);for(let m=0;m<i*2;m+=2)t.emplaceBack(p+m,p+m+1,p+m+3),t.emplaceBack(p+m,p+m+3,p+m+2),t.emplaceBack(f+m,f+m+3,f+m+1),t.emplaceBack(f+m,f+m+2,f+m+3)}},E_=["none","zoom","sourceTiles","visibleLayers","revision"],D_=class{constructor(e,t,i,r){this._tileKeys=e.map(a=>a.key).sort().join(),this._revision=t,this._zoom=i,this._visibleLayerIds=r}difference(e){return this._revision===e?._revision?this._visibleLayerIds===e._visibleLayerIds?this._tileKeys===e._tileKeys?this._zoom===e._zoom?"none":"zoom":"sourceTiles":"visibleLayers":"revision"}},Gx={background:!0,fill:!0,line:!0,raster:!0,hillshade:!0,"color-relief":!0};function S_(e){return Yl(e)?`custom-layer:${e.id}`:e.source}function C_(e){return Yl(e)?e.implementation.renderToTerrainTile!==void 0:Gx[e.type]===!0}var VR=class{constructor(e,t){this.needsFollowUpFrame=!1,this.painter=e,this.terrain=t,this.rttSize=t.tileManager.tileSize*t.qualityFactor}getTexture(e){return e.getRTT(this._stacks.length-1).texture}prepareForRender(e,t,i){let r=t!==this._lastPrepareZoom;this._lastPrepareZoom=t,this._stacks=[],this._prevRenderedToTexture=!1,this._rttTiles=[],this._renderableTiles=this.terrain.tileManager.getRenderableTiles(),this._renderableLayerIds=e._order.filter(l=>!e._layers[l].isHidden(t));let a=this._renderableLayerIds.join(),n=new Set;for(let l of this._renderableLayerIds){let u=e._layers[l],h=u.source;h&&Gx[u.type]&&n.add(h)}this._coordsAscending={},this._rttFingerprints={};for(let l of n){let u=e.tileManagers[l];if(!u)continue;this._coordsAscending[l]={};let h=this._coordsAscending[l],c=u.getSource(),d=c instanceof an?c.terrainTileRanges:null;for(let m of u.getVisibleCoordinates()){let g=this.terrain.tileManager.getTerrainCoords(m,d);for(let _ in g)h[_]||(h[_]=[]),h[_].push(g[_])}this._rttFingerprints[l]={};let p=this._rttFingerprints[l],f=u.getState().revision;for(let m in h)p[m]=new D_(h[m],f,t,a)}for(let l of this._renderableLayerIds){let u=e._layers[l];if(!Yl(u)||!C_(u))continue;let h=u.implementation.terrainTileRevision??0,c={};for(let d of this._renderableTiles)c[d.tileID.key]=new D_([d.tileID],h,t,a);this._rttFingerprints[S_(u)]=c}this.needsFollowUpFrame=!1;let o=r||i,s=!1;for(let l of this._renderableTiles){let u=this._textureDifference(l);u!=="none"&&(u==="zoom"&&o||u==="visibleLayers"&&r?this.needsFollowUpFrame=!0:u==="zoom"||u==="sourceTiles"?(s?this.needsFollowUpFrame=!0:l.releaseRTT(this.painter),s=!0):l.releaseRTT(this.painter))}}_textureDifference(e){let t="none";for(let i in this._rttFingerprints){let r=this._rttFingerprints[i][e.tileID.key];if(!r)continue;let a=r.difference(e.rttFingerprint[i]);E_.indexOf(a)>E_.indexOf(t)&&(t=a)}return t}renderLayer(e,t,i){if(e.isHidden(i.transform.zoom))return!1;let r=C_(e),a=this.painter,n=this._renderableLayerIds[this._renderableLayerIds.length-1]===e.id;if(r&&(this._prevRenderedToTexture||this._stacks.push([]),this._prevRenderedToTexture=!0,this._stacks[this._stacks.length-1].push(e.id),!n))return!0;if(this._prevRenderedToTexture||r&&n){this._prevRenderedToTexture=r;let o=this._stacks.length-1,s=this._stacks[o]||[];i.isRenderingToTexture=!0,l_(a.context.frameUniformBuffer,this.rttSize,this.rttSize);for(let l of this._renderableTiles){if(this._rttTiles.push(l),l.getRTT(o))continue;let u=l.acquireRTT(a,o,this.rttSize);a.bindRTT(u),a.context.clear({color:oe.transparent,stencil:0}),i.invalidateTileClippingMasks();for(let h of s){let c=t._layers[h],d=c.source?this._coordsAscending[c.source][l.tileID.key]:[l.tileID];a.context.viewport.set([0,0,this.rttSize,this.rttSize]),i.renderTileClippingMasks(c,d),a.renderLayer(a,t.tileManagers[c.source],c,d,i);let p=S_(c);p&&(l.rttFingerprint[p]=this._rttFingerprints[p][l.tileID.key])}u.texture.generateMipmap()}return i.isRenderingToTexture=!1,l_(a.context.frameUniformBuffer,a.context.gl.drawingBufferWidth,a.context.gl.drawingBufferHeight),Yz(this.painter,this.terrain,this._rttTiles,i),this._rttTiles=[],r}return!1}},NR={"AttributionControl.ToggleAttribution":"Toggle attribution","AttributionControl.MapFeedback":"Map feedback","FullscreenControl.Enter":"Enter fullscreen","FullscreenControl.Exit":"Exit fullscreen","GeolocateControl.FindMyLocation":"Find my location","GeolocateControl.LocationNotAvailable":"Location not available","LogoControl.Title":"MapLibre logo","Map.Title":"Map","Marker.Title":"Map marker","NavigationControl.ResetBearing":"Drag to rotate map, click to reset north","NavigationControl.ZoomIn":"Zoom in","NavigationControl.ZoomOut":"Zoom out","Popup.Close":"Close popup","ScaleControl.Feet":"ft","ScaleControl.Meters":"m","ScaleControl.Kilometers":"km","ScaleControl.Miles":"mi","ScaleControl.NauticalMiles":"nm","GlobeControl.Enable":"Enable globe","GlobeControl.Disable":"Disable globe","TerrainControl.Enable":"Enable terrain","TerrainControl.Disable":"Disable terrain","CooperativeGesturesHandler.WindowsHelpText":"Use Ctrl + scroll to zoom the map","CooperativeGesturesHandler.MacHelpText":"Use \u2318 + scroll to zoom the map","CooperativeGesturesHandler.MobileHelpText":"Use two fingers to move the map"},UR=fd,P_={hash:!1,interactive:!0,bearingSnap:7,zoomSnap:0,attributionControl:Nx,maplibreLogo:!1,refreshExpiredTiles:!0,canvasContextAttributes:{antialias:!1,preserveDrawingBuffer:!1,powerPreference:"high-performance",failIfMajorPerformanceCaveat:!1,desynchronized:!1,contextType:void 0},scrollZoom:!0,minZoom:-2,maxZoom:22,minPitch:0,maxPitch:60,boxZoom:!0,dragRotate:!0,dragPan:!0,keyboard:!0,doubleClickZoom:!0,touchZoomRotate:!0,touchPitch:!0,cooperativeGestures:!1,trackResize:!0,center:[0,0],elevation:0,zoom:0,bearing:0,pitch:0,roll:0,renderWorldCopies:!0,maxTileCacheSize:null,maxTileCacheZoomLevels:si.MAX_TILE_CACHE_ZOOM_LEVELS,transformRequest:null,transformCameraUpdate:null,transformConstrain:null,fadeDuration:300,crossSourceCollisions:!0,clickTolerance:3,localIdeographFontFamily:"sans-serif",pitchWithRotate:!0,rollEnabled:!1,rotateSpeed:.8,pitchSpeed:-.5,reduceMotion:void 0,validateStyle:!0,maxCanvasSize:[4096,4096],cancelPendingTileRequestsWhileZooming:!0,centerClampedToGround:!0,terrainSkirtLength:"auto",zoomLevelsToOverscale:4,anisotropicFilterPitch:20},$R=class extends ht{get _ownerWindow(){return this._container?.ownerDocument?.defaultView||window}constructor(e){super(),this._idleTriggered=!1,this._crossFadingFactor=1,this._renderTaskQueue=new LR,this._controls=[],this._mapId=j_(),this._styleUrl=null,this._missingStyleImageResolver=null,this._lostContextStyle={style:null,images:null},this._contextLost=a=>{if(a.preventDefault(),this._frameRequest&&(this._frameRequest=(this._frameRequest.abort(),null)),this.painter.destroy(),this._lostContextStyle=this._getStyleAndImages(),!this.style){this.fire(new Fs("webglcontextlost",{originalEvent:a}));return}for(let n of Object.values(this.style._layers))if(n.type==="custom"&&console.warn(`Custom layer with id '${n.id}' cannot be restored after WebGL context loss. You will need to re-add it manually after context restoration.`),n._listeners)for(let[o]of Object.entries(n._listeners))console.warn(`Custom layer with id '${n.id}' had event listeners for event '${o}' which cannot be restored after WebGL context loss. You will need to re-add them manually after context restoration.`);this.style.destroy(),this.style=null,this.fire(new Fs("webglcontextlost",{originalEvent:a}))},this._contextRestored=a=>{if(this._lostContextStyle.style&&this.setStyle(this._lostContextStyle.style,{diff:!1}),this._lostContextStyle.images&&this.style){this.style.imageManager.images=this._lostContextStyle.images;for(let n in this._lostContextStyle.images){let o=this._lostContextStyle.images[n];o.isWebGLImage&&this.style.imageManager.updateImage(n,o,!1)}}this._lostContextStyle={style:null,images:null};try{this._setupPainter()}catch(n){this.fire(new Y(n));return}this.resize(),this._update(),this._resizeInternal(),this.fire(new Fs("webglcontextrestored",{originalEvent:a}))},this._onMapScroll=a=>{if(a.target===this._container)return this._container.scrollTop=0,this._container.scrollLeft=0,!1},this._onWindowOnline=()=>{this._update()};let t={...P_,...e,canvasContextAttributes:{...P_.canvasContextAttributes,...e.canvasContextAttributes}};if(t.minZoom!=null&&t.maxZoom!=null&&t.minZoom>t.maxZoom)throw Error("maxZoom must be greater than or equal to minZoom");if(t.minPitch!=null&&t.maxPitch!=null&&t.minPitch>t.maxPitch)throw Error("maxPitch must be greater than or equal to minPitch");if(t.minPitch!=null&&t.minPitch<0)throw Error("minPitch must be greater than or equal to 0");if(t.maxPitch!=null&&t.maxPitch>180)throw Error("maxPitch must be less than or equal to 180");this._camera=new kR({minZoom:t.minZoom,maxZoom:t.maxZoom,minPitch:t.minPitch,maxPitch:t.maxPitch,bearingSnap:t.bearingSnap,zoomSnap:t.zoomSnap,renderWorldCopies:t.renderWorldCopies,centerClampedToGround:t.centerClampedToGround,terrain:this.terrain,transformConstrain:t.transformConstrain,requestRenderFrame:a=>this._requestRenderFrame(a),cancelRenderFrame:a=>this._cancelRenderFrame(a),transformCameraUpdate:t.transformCameraUpdate,stopHandlers:()=>this._handlers?.stop(!1)}),this._camera.setEventedParent(this),this._interactive=t.interactive,this._maxTileCacheSize=t.maxTileCacheSize,this._maxTileCacheZoomLevels=t.maxTileCacheZoomLevels,this._canvasContextAttributes={...t.canvasContextAttributes},this._trackResize=t.trackResize===!0,this._terrainSkirtLength=t.terrainSkirtLength,this._refreshExpiredTiles=t.refreshExpiredTiles===!0,this._fadeDuration=t.fadeDuration,this._crossSourceCollisions=t.crossSourceCollisions===!0,this._collectResourceTiming=t.collectResourceTiming===!0,this._locale={...NR,...t.locale},this._clickTolerance=t.clickTolerance,this._overridePixelRatio=t.pixelRatio,this._maxCanvasSize=t.maxCanvasSize,this._zoomLevelsToOverscale=t.zoomLevelsToOverscale,this.cancelPendingTileRequestsWhileZooming=t.cancelPendingTileRequestsWhileZooming===!0,this.setAnisotropicFilterPitch(t.anisotropicFilterPitch),t.reduceMotion!==void 0&&(Kt.prefersReducedMotion=t.reduceMotion),this._requestManager=new Tw(t.transformRequest),this._container=this._resolveContainer(t.container),t.maxBounds&&this.setMaxBounds(t.maxBounds),this._setupContainer();try{this._setupPainter()}catch(a){throw this._cleanupContainer(),a}this._imageQueueHandle=Ci.addThrottleControl(()=>this.isMoving()),this.on("move",()=>this._update(!1)),this.on("moveend",()=>this._update(!1)),this.on("zoom",()=>this._update(!0)),this.on("terrain",()=>{this.painter.markTerrainDepthDirty(),this._update(!0)}),this.once("idle",()=>this._idleTriggered=!0),this._handlers=new zR(this,this._camera,t),typeof window<"u"&&(this._ownerWindow.addEventListener("online",this._onWindowOnline,!1),this._setupResizeObserver());let i=typeof t.hash=="string"&&t.hash||void 0;this._hash=t.hash?new Ax(i).addTo(this):void 0,this._hash?._onHashChange()||(this.jumpTo({center:t.center,elevation:t.elevation,zoom:t.zoom,bearing:t.bearing,pitch:t.pitch,roll:t.roll}),t.bounds&&(this.resize(),this.fitBounds(t.bounds,q({},t.fitBoundsOptions,{duration:0}))));let r=typeof t.style=="string"||t.style?.projection?.type!=="globe";this.resize(null,r),this._localIdeographFontFamily=t.localIdeographFontFamily,this._validateStyle=t.validateStyle,t.style&&this.setStyle(t.style,{localIdeographFontFamily:t.localIdeographFontFamily}),t.attributionControl&&this.addControl(new Ux(typeof t.attributionControl=="boolean"?void 0:t.attributionControl)),t.maplibreLogo&&this.addControl(new $x,t.logoPosition),this.on("style.load",()=>{if(r||this._resizeTransform(),this._camera.transform.unmodified){let a=yo(this.style.stylesheet,["center","zoom","bearing","pitch","roll"]);this.jumpTo(a)}}),this.on("data",a=>{this._update(a.dataType==="style"),this.fire(a.dataType==="style"?new _i("styledata",a):new Ne("sourcedata",a))}),this.on("dataloading",a=>{this.fire(a.dataType==="style"?new _i("styledataloading",a):new Ne("sourcedataloading",a))}),this.on("dataabort",a=>{this.fire(new Ne("sourcedataabort",a))})}_getMapId(){return this._mapId}setGlobalStateProperty(e,t){return this.style.setGlobalStateProperty(e,t),this._update(!0)}getGlobalState(){return this.style.getGlobalState()}addControl(e,t){if(t===void 0&&(t=e.getDefaultPosition?e.getDefaultPosition():"top-right"),!e?.onAdd)return this.fire(new Y(Error("Invalid argument to map.addControl(). Argument must be a control with onAdd and onRemove methods.")));let i=e.onAdd(this);this._controls.push(e);let r=this._controlPositions[t];return t.includes("bottom")?r.insertBefore(i,r.firstChild):r.appendChild(i),this}removeControl(e){if(!e?.onRemove)return this.fire(new Y(Error("Invalid argument to map.removeControl(). Argument must be a control with onAdd and onRemove methods.")));let t=this._controls.indexOf(e);return t>-1&&this._controls.splice(t,1),e.onRemove(this),this}hasControl(e){return this._controls.includes(e)}coveringTiles(e){return Mo(this._camera.transform,e)}setTransformCameraUpdate(e){this._camera.transformCameraUpdate=e}getCenter(){return new X(this._camera.transform.center.lng,this._camera.transform.center.lat)}setCenter(e,t){return this._camera.setCenter(e,t),this}getCenterElevation(){return this._camera.transform.elevation}setCenterElevation(e,t){return this._camera.setCenterElevation(e,t),this}setCenterClampedToGround(e){this._camera.setCenterClampedToGround(e)}panBy(e,t,i){return this._camera.panBy(e,t,i),this}panTo(e,t,i){return this._camera.panTo(e,t,i),this}getZoom(){return this._camera.transform.zoom}setZoom(e,t){return this._camera.setZoom(e,t),this}zoomTo(e,t,i){return this._camera.zoomTo(e,t,i),this}zoomIn(e,t){return this._camera.zoomIn(e,t),this}zoomOut(e,t){return this._camera.zoomOut(e,t),this}getVerticalFieldOfView(){return this._camera.transform.fov}setVerticalFieldOfView(e,t){return this._camera.setVerticalFieldOfView(e,t),this}getBearing(){return this._camera.transform.bearing}setBearing(e,t){return this._camera.setBearing(e,t),this}getZoomSnap(){return this._camera.getZoomSnap()}setZoomSnap(e){return this._camera.setZoomSnap(e),this}getPadding(){return this._camera.transform.padding}setPadding(e,t){return this._camera.setPadding(e,t),this}rotateTo(e,t,i){return this._camera.rotateTo(e,t,i),this}resetNorth(e,t){return this._camera.resetNorth(e,t),this}resetNorthPitch(e,t){return this._camera.resetNorthPitch(e,t),this}snapToNorth(e,t){return this._camera.snapToNorth(e,t),this}getPitch(){return this._camera.transform.pitch}setPitch(e,t){return this._camera.setPitch(e,t),this}getRoll(){return this._camera.transform.roll}setRoll(e,t){return this._camera.setRoll(e,t),this}cameraForBounds(e,t){return this._camera.cameraForBounds(e,t)}fitBounds(e,t,i){return this._camera.fitBounds(e,t,i),this}fitScreenCoordinates(e,t,i,r,a){return this._camera.fitScreenCoordinates(e,t,i,r,a),this}jumpTo(e,t){return this._camera.jumpTo(e,t),this}calculateAnchoredCameraOptions(e){return this._camera.calculateAnchoredCameraOptions(e)}calculateCameraOptionsFromCameraLngLatAltRotation(e,t,i,r,a){return this._camera.calculateCameraOptionsFromCameraLngLatAltRotation(e,t,i,r,a)}easeTo(e,t){return this._camera.easeTo(e,t),this}flyTo(e,t){return this._camera.flyTo(e,t),this}stop(){return this._camera.stop(),this}queryTerrainElevation(e){return this.terrain?this.terrain.getElevationForLngLat(X.convert(e),this._camera.transform):null}getCenterClampedToGround(){return this._camera.getCenterClampedToGround()}calculateCameraOptionsFromTo(e,t,i,r){return r==null&&this.terrain&&(r=this.terrain.getElevationForLngLat(i,this._camera.transform)),this._camera.transform.calculateCameraOptionsFromTo(e,t,i,r??0)}resize(e,t=!0){if(this._lostContextStyle.style!==null)return this;this._resizeInternal(t);let i=!this._camera._moving;return i&&(this.stop(),this.fire(new Q("movestart",e)).fire(new Q("move",e))),this.fire(new gt("resize",e)),i&&this.fire(new Q("moveend",e)),this}_resizeInternal(e=!0){let[t,i]=this._containerDimensions();if(this._clampedPixelRatio=this._getClampedPixelRatio(t,i),this._resizeCanvas(t,i,this._clampedPixelRatio),this.painter.resize(t,i,this._clampedPixelRatio),this.painter.overLimit()){let r=this.painter.context.gl;this._maxCanvasSize=[r.drawingBufferWidth,r.drawingBufferHeight],this._clampedPixelRatio=this._getClampedPixelRatio(t,i),this._resizeCanvas(t,i,this._clampedPixelRatio),this.painter.resize(t,i,this._clampedPixelRatio)}this.style?.resize(),this._resizeTransform(e)}_resizeTransform(e=!0){let[t,i]=this._containerDimensions();this._camera.transform.resize(t,i,e),this._camera._requestedCameraState?.resize(t,i,e)}_getClampedPixelRatio(e,t){let{0:i,1:r}=this._maxCanvasSize,a=this.getPixelRatio(),n=e*a,o=t*a,s=n>i?i/n:1,l=o>r?r/o:1,u=Math.min(s,l);return u<1&&_e("The canvas is larger than maxCanvasSize and is rendered at a lower pixel ratio to fit. Increase maxCanvasSize, within MAX_TEXTURE_SIZE, to render at full resolution."),u*a}getPixelRatio(){return this._overridePixelRatio??devicePixelRatio}setPixelRatio(e){this._overridePixelRatio=e,this.resize()}getBounds(){return this._camera.transform.getBounds()}getMaxBounds(){return this._camera.transform.getMaxBounds()}setMaxBounds(e){return this._camera.applyTransformChange(t=>t.setMaxBounds(zi.convert(e))),this._update()}setMinZoom(e){if(e??(e=-2),e>=-2&&e<=this._camera.transform.maxZoom){let t=this._camera.transform.zoom;return this._camera.applyTransformChange(i=>i.setMinZoom(e)),this._update(),t!==this._camera.transform.zoom&&this.fire(new Q("zoomstart")).fire(new Q("zoom")).fire(new Q("zoomend")).fire(new Q("movestart")).fire(new Q("move")).fire(new Q("moveend")),this}throw Error("minZoom must be between -2 and the current maxZoom, inclusive")}getMinZoom(e=!1){let t=this._camera.transform;return e?t.applyConstrain(t.center,t.minZoom).zoom:t.minZoom}setMaxZoom(e){if(e??(e=22),e>=this._camera.transform.minZoom){let t=this._camera.transform.zoom;return this._camera.applyTransformChange(i=>i.setMaxZoom(e)),this._update(),t!==this._camera.transform.zoom&&this.fire(new Q("zoomstart")).fire(new Q("zoom")).fire(new Q("zoomend")).fire(new Q("movestart")).fire(new Q("move")).fire(new Q("moveend")),this}throw Error("maxZoom must be greater than the current minZoom")}getMaxZoom(){return this._camera.transform.maxZoom}setMinPitch(e){if(e??(e=0),e<0)throw Error("minPitch must be greater than or equal to 0");if(e>=0&&e<=this._camera.transform.maxPitch){let t=this._camera.transform.pitch;return this._camera.applyTransformChange(i=>i.setMinPitch(e)),this._update(),t!==this._camera.transform.pitch&&this.fire(new Q("pitchstart")).fire(new Q("pitch")).fire(new Q("pitchend")).fire(new Q("movestart")).fire(new Q("move")).fire(new Q("moveend")),this}throw Error("minPitch must be between 0 and the current maxPitch, inclusive")}getMinPitch(){return this._camera.transform.minPitch}setMaxPitch(e){if(e??(e=60),e>180)throw Error("maxPitch must be less than or equal to 180");if(e>=this._camera.transform.minPitch){let t=this._camera.transform.pitch;return this._camera.applyTransformChange(i=>i.setMaxPitch(e)),this._update(),t!==this._camera.transform.pitch&&this.fire(new Q("pitchstart")).fire(new Q("pitch")).fire(new Q("pitchend")).fire(new Q("movestart")).fire(new Q("move")).fire(new Q("moveend")),this}throw Error("maxPitch must be greater than the current minPitch")}getMaxPitch(){return this._camera.transform.maxPitch}getAnisotropicFilterPitch(){return this._anisotropicFilterPitch}setAnisotropicFilterPitch(e){if(e??(e=20),e>180)throw Error("anisotropicFilterPitch must be less than or equal to 180");if(e<0)throw Error("anisotropicFilterPitch must be greater than or equal to 0");return this._anisotropicFilterPitch=e,this._update()}getRenderWorldCopies(){return this._camera.transform.renderWorldCopies}setRenderWorldCopies(e){return this._camera.applyTransformChange(t=>t.setRenderWorldCopies(e)),this._update()}setTransformConstrain(e){return this._camera.applyTransformChange(t=>t.setConstrainOverride(e)),this._update()}project(e){return this._camera.transform.locationToScreenPoint(X.convert(e),this.style&&this.terrain)}unproject(e){return this._camera.transform.screenPointToLocation(C.convert(e),this.terrain)}isMoving(){return this._camera.isMoving()||this._handlers?.isMoving()||!1}isZooming(){return this._camera.isZooming()||this._handlers?.isZooming()||!1}isRotating(){return this._camera.isRotating()||this._handlers?.isRotating()||!1}_createDelegates(e,t,i){if(e==="mouseenter"||e==="mouseover"){let r=!1;return{mousemove:a=>{let n=t.filter(s=>this.getLayer(s)),o=n.length===0?[]:this.queryRenderedFeatures(a.point,{layers:n});o.length?r||(r=!0,i.call(this,new Xt(e,this,a.originalEvent,{features:o}))):r=!1},mouseout:()=>{r=!1}}}if(e==="mouseleave"||e==="mouseout"){let r=!1;return{mousemove:a=>{let n=t.filter(o=>this.getLayer(o));(n.length===0?[]:this.queryRenderedFeatures(a.point,{layers:n})).length?r=!0:r&&(r=!1,i.call(this,new Xt(e,this,a.originalEvent)))},mouseout:a=>{r&&(r=!1,i.call(this,new Xt(e,this,a.originalEvent)))}}}{let r=a=>{let n=t.filter(s=>this.getLayer(s)),o=n.length===0?[]:this.queryRenderedFeatures(a.point,{layers:n});o.length&&(a.features=o,i.call(this,a),delete a.features)};return{[e]:r}}}_addDelegatedListener(e,t){var i;this._delegatedListeners||(this._delegatedListeners={}),(i=this._delegatedListeners)[e]||(i[e]=[]),this._delegatedListeners[e].push(t);for(let r in t.delegates)this.on(r,t.delegates[r])}_removeDelegatedListener(e,t,i){if(!this._delegatedListeners?.[e])return;let r=this._delegatedListeners[e];for(let a=0;a<r.length;a++){let n=r[a];if(n.listener===i&&n.layers.length===t.length&&n.layers.every(o=>t.includes(o))){for(let o in n.delegates)this.off(o,n.delegates[o]);r.splice(a,1);return}}}on(e,t,i){if(i===void 0)return super.on(e,t);let r=typeof t=="string"?[t]:t,a={layers:r,listener:i,delegates:this._createDelegates(e,r,i)};return this._addDelegatedListener(e,a),{unsubscribe:()=>{this._removeDelegatedListener(e,r,i)}}}once(e,t,i){if(i===void 0)return super.once(e,t);let r=typeof t=="string"?[t]:t,a={layers:r,listener:i,delegates:this._createDelegates(e,r,n=>{this._removeDelegatedListener(e,r,i),i.call(this,n)})};return this._addDelegatedListener(e,a),this}off(e,t,i){if(i===void 0)return super.off(e,t);let r=typeof t=="string"?[t]:t;return this._removeDelegatedListener(e,r,i),this}queryRenderedFeatures(e,t){if(!this.style)return[];let i,r=e instanceof C||Array.isArray(e),a=r?e:[[0,0],[this._camera.transform.width,this._camera.transform.height]];if(t||(t=(r?{}:e)||{}),a instanceof C||typeof a[0]=="number")i=[C.convert(a)];else{let n=C.convert(a[0]),o=C.convert(a[1]);i=[n,new C(o.x,n.y),o,new C(n.x,o.y),n]}return this.style.queryRenderedFeatures(i,t,this._camera.transform)}querySourceFeatures(e,t){return this.style.querySourceFeatures(e,t)}setStyle(e,t){return t=q({},{localIdeographFontFamily:this._localIdeographFontFamily,validate:this._validateStyle},t),this._styleUrl=typeof e=="string"?e:null,t.diff!==!1&&t.localIdeographFontFamily===this._localIdeographFontFamily&&this.style&&e?(this._diffStyle(e,t),this):(this._localIdeographFontFamily=t.localIdeographFontFamily,this._updateStyle(e,t))}setTransformRequest(e){return this._requestManager.setTransformRequest(e),this}_getUIString(e){let t=this._locale[e];if(t==null)throw Error(`Missing UI string '${e}'`);return t}_updateStyle(e,t){if(this._diffStyleRequest?.abort(),this._diffStyleRequest=null,t.transformStyle&&this.style&&!this.style._loaded){this.style.once("style.load",()=>this._updateStyle(e,t));return}let i=this.style&&t.transformStyle?this.style.serialize():void 0;if(this.style&&(this.style.setEventedParent(null),this.style._remove(!e)),e)this.style=new od(this,t||{});else return this._frameRequest&&(this._frameRequest=(this._frameRequest.abort(),null)),this.style?.projection?.destroy(),delete this.style,this;return this.style.setEventedParent(this,{style:this.style}),typeof e=="string"?this.style.loadURL(e,t,i):this.style.loadJSON(e,t,i),this}_lazyInitEmptyStyle(){this.style||(this.style=new od(this,{}),this.style.setEventedParent(this,{style:this.style}),this.style.loadEmpty())}async _diffStyle(e,t){if(this._diffStyleRequest?.abort(),typeof e=="string"){let i=e;this._diffStyleRequest=new AbortController;let r=this._diffStyleRequest;try{let a=await this._requestManager.transformRequest(i,"Style");if(r.signal.aborted){this._diffStyleRequest=null;return}let n=await Sl(a,r);this._diffStyleRequest=null,this._updateDiff(n.data,t)}catch(a){this._diffStyleRequest=null,Cr(a)||this.fire(new Y(bt(a)))}}else typeof e=="object"&&(this._diffStyleRequest=null,this._updateDiff(e,t))}_updateDiff(e,t){try{this.style.setState(e,t)&&this._update(!0)}catch(i){_e(`Unable to perform style diff: ${bt(i).message}. Rebuilding the style from scratch.`),this._updateStyle(e,t)}}getStyle(){if(this.style)return this.style.serialize()}getStyleUrl(){return this._styleUrl}_getStyleAndImages(){return this.style?{style:this.style.serialize(),images:this.style.imageManager.cloneImages()}:{style:null,images:{}}}isStyleLoaded(){if(!this.style){_e("There is no style added to the map.");return}return this.style.loaded()}addSource(e,t){return this._lazyInitEmptyStyle(),this.style.addSource(e,t),this._update(!0)}isSourceLoaded(e){let t=this.style?.tileManagers[e];if(t===void 0){this.fire(new Y(Error(`There is no tile manager with ID '${e}'`)));return}return t.loaded()}setTerrain(e,t={}){if(this.style._checkLoaded(),e&&So(this,Wt.terrain,{value:e},t))return this;if(this._terrainDataCallback&&this.style.off("data",this._terrainDataCallback),!e)this.terrain&&this.terrain.destroy(),this.terrain=null,this.painter.renderToTexture=null,this.painter.destroyRTTResources(),this._camera.setTerrain(null);else{let i=this.style.tileManagers[e.source];if(!i)throw Error(`cannot load terrain, because there exists no source with ID: ${e.source}`);this.terrain===null&&i.reload();for(let r in this.style._layers){let a=this.style._layers[r];a.type==="hillshade"&&a.source===e.source&&_e("You are using the same source for a hillshade layer and for 3D terrain. Please consider using two separate sources to improve rendering quality."),a.type==="color-relief"&&a.source===e.source&&_e("You are using the same source for a color-relief layer and for 3D terrain. Please consider using two separate sources to improve rendering quality.")}this.terrain&&this.terrain.destroy(),this.terrain=new jR(this.painter,i,e,this._terrainSkirtLength),this.painter.renderToTexture=new VR(this.painter,this.terrain),this._camera.setTerrain(this.terrain),this._terrainDataCallback=r=>this._handleTerrainDataEvent(r,e.source),this.style.on("data",this._terrainDataCallback)}return this.style.triggerSymbolPlacement(),this.fire(new Y_({terrain:e})),this}_handleTerrainDataEvent(e,t){if(e.dataType==="style"){this.terrain.tileManager.releaseAllRTT();return}let i=e.sourceId===t;if(i&&(this.terrain.resetElevationCache(),this.style.triggerSymbolPlacement()),i&&e.tile&&(this.painter.markTerrainDepthDirty(),this._camera.applyTerrainChange()),e.tile){if(e.source?.type==="image"){this.terrain.tileManager.releaseAllRTT();return}this.terrain.tileManager.releaseRTT(e.tile.tileID)}}getTerrain(){return this.terrain?.options??null}areTilesLoaded(){let e=this.style?.tileManagers;for(let t of Object.values(e))if(!t.areTilesLoaded())return!1;return!0}removeSource(e){return this.style.removeSource(e),this._update(!0)}getSource(e){return this.style?.getSource(e)}setSourceTileLodParams(e,t,i){if(i){let r=this.getSource(i);if(!r)throw Error(`There is no source with ID "${i}", cannot set LOD parameters`);r.calculateTileZoom=Jc(Math.max(1,e),Math.max(1,t))}else for(let r in this.style.tileManagers)this.style.tileManagers[r].getSource().calculateTileZoom=Jc(Math.max(1,e),Math.max(1,t));return this._update(!0),this}refreshTiles(e,t){let i=this.style.tileManagers[e];if(!i)throw Error(`There is no tile manager with ID "${e}", cannot refresh tile`);t===void 0?i.reload(!0):i.refreshTiles(t.map(r=>new Jl(r.z,r.x,r.y)))}addImage(e,t,i={}){this._lazyInitEmptyStyle();let r=this._createStyleImage(t,i);return r?(this.style.addImage(e,r),r.userImage?.onAdd&&r.userImage.onAdd(this,e),this):this}setMissingStyleImageResolver(e){return this._missingStyleImageResolver=e,this.style?.setMissingImageResolver(e),this}_createStyleImage(e,t={}){let{pixelRatio:i=1,sdf:r=!1,stretchX:a,stretchY:n,content:o,textFitWidth:s,textFitHeight:l}=t;if(e instanceof HTMLImageElement||qr(e)){let{width:u,height:h,data:c}=Kt.getImageData(e);return{data:new Ve({width:u,height:h},c),pixelRatio:i,stretchX:a,stretchY:n,content:o,textFitWidth:s,textFitHeight:l,sdf:r,version:0}}if(e.width===void 0||e.height===void 0)return this.fire(new Y(Error("Invalid arguments to map.addImage(). The second argument must be an `HTMLImageElement`, `ImageData`, `ImageBitmap`, or object with `width`, `height`, and `data` properties with the same format as `ImageData`"))),null;{let{width:u,height:h,data:c}=e,d=e,p=dl(d.data);return{data:p?new Ve({width:u,height:h}):new Ve({width:u,height:h},new Uint8Array(c)),pixelRatio:i,stretchX:a,stretchY:n,content:o,textFitWidth:s,textFitHeight:l,sdf:r,version:0,isWebGLImage:p,userImage:d}}}updateImage(e,t){let i=this.style.getImage(e);if(!i)return this.fire(new Y(Error("The map has no image with that id. If you are adding a new image use `map.addImage(...)` instead.")));let{width:r,height:a,data:n}=t instanceof HTMLImageElement||qr(t)?Kt.getImageData(t):t;if(r===void 0||a===void 0)return this.fire(new Y(Error("Invalid arguments to map.updateImage(). The second argument must be an `HTMLImageElement`, `ImageData`, `ImageBitmap`, or object with `width`, `height`, and `data` properties with the same format as `ImageData`")));if(r!==i.data.width||a!==i.data.height)return this.fire(new Y(Error("The width and height of the updated image must be that same as the previous version of the image")));if(i.isWebGLImage=dl(n),i.isWebGLImage)i.userImage=t;else{let o=!(t instanceof HTMLImageElement||qr(t));i.data.replace(n,o)}return this.style.updateImage(e,i),this}getImage(e){return this.style.getImage(e)}hasImage(e){return e?!!this.style.getImage(e):(this.fire(new Y(Error("Missing required image id"))),!1)}removeImage(e){this.style.removeImage(e)}async loadImage(e){let t=await Ci.getImage(await this._requestManager.transformRequest(e,"Image"),new AbortController);if(!t.data)throw Error(`Could not load image ${e}: the response is empty`);return t}listImages(){return this.style?.listImages()??[]}addLayer(e,t){return this._lazyInitEmptyStyle(),this.style.addLayer(e,t),this._update(!0)}moveLayer(e,t){return this.style.moveLayer(e,t),this._update(!0)}removeLayer(e){return this.style.removeLayer(e),this._update(!0)}getLayer(e){return this.style?.getLayer(e)}getLayersOrder(){return this.style?.getLayersOrder()??[]}setLayerZoomRange(e,t,i){return this.style.setLayerZoomRange(e,t,i),this._update(!0)}setFilter(e,t,i={}){return this.style?.setFilter(e,t,i),this._update(!0)}getFilter(e){return this.style.getFilter(e)}setPaintProperty(e,t,i,r={}){return this.style?.setPaintProperty(e,t,i,r),this._update(!0)}getPaintProperty(e,t){return this.style.getPaintProperty(e,t)}setLayoutProperty(e,t,i,r={}){return this.style.setLayoutProperty(e,t,i,r),this._update(!0)}getLayoutProperty(e,t){return this.style.getLayoutProperty(e,t)}setGlyphs(e,t={}){return this._lazyInitEmptyStyle(),this.style.setGlyphs(e,t),this._update(!0)}getGlyphs(){return this.style.getGlyphsUrl()}setFontFaces(e){return this._lazyInitEmptyStyle(),this.style.setFontFaces(e),this._update(!0)}getFontFaces(){return this.style.getFontFaces()}addSprite(e,t,i={}){return this._lazyInitEmptyStyle(),this.style.addSprite(e,t,i,r=>{r||this._update(!0)}),this}removeSprite(e){return this._lazyInitEmptyStyle(),this.style.removeSprite(e),this._update(!0)}getSprite(){return this.style.getSprite()}setSprite(e,t={}){return this._lazyInitEmptyStyle(),this.style.setSprite(e,t,i=>{i||this._update(!0)}),this}setLight(e,t={}){return this._lazyInitEmptyStyle(),this.style.setLight(e,t),this._update(!0)}getLight(){return this.style.getLight()}setSky(e,t={}){return this._lazyInitEmptyStyle(),this.style.setSky(e,t),this._update(!0)}getSky(){return this.style.getSky()}setFeatureState(e,t){return this.style.setFeatureState(e,t),this._update()}removeFeatureState(e,t){return this.style.removeFeatureState(e,t),this._update()}getFeatureState(e){return this.style.getFeatureState(e)}getContainer(){return this._container}getCanvasContainer(){return this._canvasContainer}getCanvas(){return this._canvas}_containerDimensions(){let e=0,t=0;return this._container&&(e=Math.floor(this._container.clientWidth)||400,t=Math.floor(this._container.clientHeight)||300),[e,t]}_shouldHandleInitialResize(){if(!this._container?.clientWidth||!this._container.clientHeight)return!1;let[e,t]=this._containerDimensions();return e!==this._camera.transform.width||t!==this._camera.transform.height}_setupResizeObserver(){let e=!1,t=Bp(r=>{this._trackResize&&!this._removed&&(this.resize(r),this.redraw())},50),i=this._ownerWindow.ResizeObserver??ResizeObserver;this._resizeObserver=new i(r=>{!e&&(e=!0,!this._shouldHandleInitialResize())||t(r)}),this._resizeObserver.observe(this._container)}_resolveContainer(e){if(typeof e=="string"){let t=document.getElementById(e);if(!t)throw Error(`Container '${e}' not found.`);return t}if(e instanceof HTMLElement||e&&typeof e=="object"&&e.nodeType===1)return e;throw Error("Invalid type: 'container' must be a String or HTMLElement.")}_setupContainer(){let e=this._containerDimensions(),t=this._getClampedPixelRatio(e[0],e[1]),i=this._container;i.classList.add("maplibregl-map");let r=this._canvasContainer=ne.create("div","maplibregl-canvas-container",i);this._interactive&&r.classList.add("maplibregl-interactive"),this._canvas=ne.create("canvas","maplibregl-canvas",r),this._canvas.addEventListener("webglcontextlost",this._contextLost,!1),this._canvas.addEventListener("webglcontextrestored",this._contextRestored,!1),this._canvas.setAttribute("tabindex",this._interactive?"0":"-1"),this._canvas.setAttribute("aria-label",this._getUIString("Map.Title")),this._canvas.setAttribute("role","region"),this._resizeCanvas(e[0],e[1],t);let a=this._controlContainer=ne.create("div","maplibregl-control-container",i),n=this._controlPositions={};for(let o of["top-left","top-right","bottom-left","bottom-right"])n[o]=ne.create("div",`maplibregl-ctrl-${o} `,a);this._container.addEventListener("scroll",this._onMapScroll,!1)}_cleanupContainer(){this._canvas.removeEventListener("webglcontextrestored",this._contextRestored,!1),this._canvas.removeEventListener("webglcontextlost",this._contextLost,!1),this._canvasContainer.remove(),this._controlContainer.remove(),this._container.removeEventListener("scroll",this._onMapScroll,!1),this._container.classList.remove("maplibregl-map")}_resizeCanvas(e,t,i){let r=Math.round(i*e),a=Math.round(i*t);this._canvas.width=r,this._canvas.height=a,this._canvas.style.width=`${r/i}px`,this._canvas.style.height=`${a/i}px`}_setupPainter(){let e={...this._canvasContextAttributes,alpha:!0,depth:!0,stencil:!0,premultipliedAlpha:!0},t=null;this._canvas.addEventListener("webglcontextcreationerror",r=>{t=r},{once:!0});let i=this._canvas.getContext("webgl2",e);if(!i)throw new Px(e,t);this.painter=new oR(i)}migrateProjection(e,t){this._camera.migrateProjection(e,t),this.fire(new K_({newProjection:this.style.projection.name}))}loaded(){return!this._styleDirty&&!this._sourcesDirty&&!!this.style&&this.style.loaded()}_update(e){return this.style?._loaded?(this._styleDirty||(this._styleDirty=e),this._sourcesDirty=!0,this.triggerRepaint(),this):this}_requestRenderFrame(e){return this._update(),this._renderTaskQueue.add(e)}_cancelRenderFrame(e){this._renderTaskQueue.remove(e)}_render(e){let t=this._idleTriggered?this._fadeDuration:0,i=this.style.projection?.transitionState>0;if(this.painter.context.setDirty(),this.painter.setBaseState(),this._renderTaskQueue.run(e),this._removed)return;let r=!1;if(this.style&&this._styleDirty){this._styleDirty=!1;let l=this._camera.transform.zoom,u=Ie();this.style.zoomHistory.update(l,u);let h=new Ae(l,{now:u,fadeDuration:t,zoomHistory:this.style.zoomHistory,transition:this.style.getTransition()}),c=h.crossFadingFactor();(c!==1||c!==this._crossFadingFactor)&&(r=!0,this._crossFadingFactor=c),this.style.update(h)}let a=this.style.projection?.transitionState>0!==i;this._camera.transform.setTransitionState(this.style.projection?.transitionState),this.style&&(this._sourcesDirty||a)&&(this._sourcesDirty=!1,this.style._updateSources(this._camera.transform)),this.terrain?(this.terrain.tileManager.update(this._camera.transform,this.terrain)&&this.terrain.resetElevationCache(),this._camera.transform.setMinElevationForCurrentTile(this.terrain.getMinTileElevationForLngLatZoom(this._camera.transform.center,this._camera.transform.tileZoom)),!this._camera.elevationFreeze&&this.getCenterClampedToGround()&&this._camera.transform.setElevation(this.terrain.getElevationForLngLat(this._camera.transform.center,this._camera.transform))):(this._camera.transform.setMinElevationForCurrentTile(0),this.getCenterClampedToGround()&&this._camera.transform.setElevation(0)),this._placementDirty=this.style?._updatePlacement(this._camera.transform,this.showCollisionBoxes,t,this._crossSourceCollisions,a);let n=this.style.projection,o=n?.transitionState??0;this.painter.render(this.style,this._camera.transform,{showTileBoundaries:this.showTileBoundaries,showOverdrawInspector:this._showOverdrawInspector,rotating:this.isRotating(),zooming:this.isZooming(),moving:this.isMoving(),fadeDuration:t,symbolFadeChange:this.style.placement.symbolFadeChange(Ie()),variableOffsets:this.style.placement.variableOffsets,showPadding:this.showPadding,anisotropicFilterPitch:this.getAnisotropicFilterPitch(),projectionTransition:o,isRenderingGlobe:o>0,projectionShaderVariant:n?{name:n.shaderVariantName,define:n.shaderDefine,prelude:n.shaderPreludeCode}:void 0,useSubdivision:n?.useSubdivision??!1,pixelRatio:this._clampedPixelRatio,light:this.style.light?.getEvaluated(),sky:this.style.sky?.getEvaluated()}),this.fire(new gt("render")),this.loaded()&&!this._loaded&&(this._loaded=!0,this.fire(new gt("load"))),this.style&&(this.style.hasTransitions()||r)&&(this._styleDirty=!0),this.style&&!this._placementDirty&&this.style._releaseSymbolFadeTiles();let s=this._sourcesDirty||this._styleDirty||this._placementDirty||this.painter.renderToTexture?.needsFollowUpFrame;return s||this._repaint?this.triggerRepaint():!this.isMoving()&&this.loaded()&&this.fire(new gt("idle")),this._loaded&&!this._fullyLoaded&&!s&&(this._fullyLoaded=!0),this}redraw(){return this.style&&(this._frameRequest&&(this._frameRequest=(this._frameRequest.abort(),null)),this._render(0)),this}remove(){this._hash&&this._hash.remove();for(let t of this._controls)t.onRemove(this);this._controls=[],this._frameRequest&&(this._frameRequest=(this._frameRequest.abort(),null)),this._renderTaskQueue.clear(),this._diffStyleRequest?.abort(),this.painter.destroy(),this._handlers.destroy(),this.setStyle(null),typeof window<"u"&&this._ownerWindow.removeEventListener("online",this._onWindowOnline,!1),Ci.removeThrottleControl(this._imageQueueHandle),this._resizeObserver?.disconnect();let e=this.painter.context.gl.getExtension("WEBGL_lose_context");e?.loseContext&&e.loseContext(),this._cleanupContainer(),this._removed=!0,this.fire(new gt("remove"))}triggerRepaint(){this.style&&!this._frameRequest&&(this._frameRequest=new AbortController,Kt.frame(this._frameRequest,e=>{this._frameRequest=null;try{this._render(e)}catch(t){if(!Cr(t))throw t}},()=>{},this._ownerWindow))}get showTileBoundaries(){return!!this._showTileBoundaries}set showTileBoundaries(e){this._showTileBoundaries!==e&&(this._showTileBoundaries=e,this._update())}get showPadding(){return!!this._showPadding}set showPadding(e){this._showPadding!==e&&(this._showPadding=e,this._update())}get showCollisionBoxes(){return!!this._showCollisionBoxes}set showCollisionBoxes(e){this._showCollisionBoxes!==e&&(this._showCollisionBoxes=e,e?this.style._generateCollisionBoxes():this._update())}get showOverdrawInspector(){return!!this._showOverdrawInspector}set showOverdrawInspector(e){this._showOverdrawInspector!==e&&(this._showOverdrawInspector=e,this._update())}get repaint(){return!!this._repaint}set repaint(e){this._repaint!==e&&(this._repaint=e,this.triggerRepaint())}get vertices(){return!!this._vertices}set vertices(e){this._vertices=e,this._update()}get version(){return UR}getCameraTargetElevation(){return this._camera.transform.elevation}getProjection(){return this.style.getProjection()}setProjection(e){return this._lazyInitEmptyStyle(),this.style.setProjection(e),this._update(!0)}},GR={showCompass:!0,showZoom:!0,visualizePitch:!1,visualizeRoll:!0},ZR=class{constructor(e){this._updateZoomButtons=()=>{let t=this._map.getZoom(),i=t===this._map.getMaxZoom(),r=t===this._map.getMinZoom(!0);this._zoomInButton.disabled=i,this._zoomOutButton.disabled=r,this._zoomInButton.setAttribute("aria-disabled",i.toString()),this._zoomOutButton.setAttribute("aria-disabled",r.toString())},this._rotateCompassArrow=()=>{let t=this._map.getPitch(),i=this._map.getRoll(),r=this._map.getBearing(),a=1/Math.cos(je(t))**.5;if(this.options.visualizePitch&&this.options.visualizeRoll){this._compassIcon.style.transform=`scale(${a}) rotateZ(${-i}deg) rotateX(${t}deg) rotateZ(${-r}deg)`;return}if(this.options.visualizePitch){this._compassIcon.style.transform=`scale(${a}) rotateX(${t}deg) rotateZ(${-r}deg)`;return}if(this.options.visualizeRoll){this._compassIcon.style.transform=`rotate(${-r-i}deg)`;return}this._compassIcon.style.transform=`rotate(${-r}deg)`},this._setButtonTitle=(t,i)=>{let r=this._map._getUIString(`NavigationControl.${i}`);t.title=r,t.setAttribute("aria-label",r)},this.options=q({},GR,e),this._container=ne.create("div","maplibregl-ctrl maplibregl-ctrl-group"),this._container.addEventListener("contextmenu",t=>t.preventDefault()),this.options.showZoom&&(this._zoomInButton=this._createButton("maplibregl-ctrl-zoom-in",t=>this._map.zoomIn({},{originalEvent:t})),ne.create("span","maplibregl-ctrl-icon",this._zoomInButton).setAttribute("aria-hidden","true"),this._zoomOutButton=this._createButton("maplibregl-ctrl-zoom-out",t=>this._map.zoomOut({},{originalEvent:t})),ne.create("span","maplibregl-ctrl-icon",this._zoomOutButton).setAttribute("aria-hidden","true")),this.options.showCompass&&(this._compass=this._createButton("maplibregl-ctrl-compass",t=>{this.options.visualizePitch?this._map.resetNorthPitch({},{originalEvent:t}):this._map.resetNorth({},{originalEvent:t})}),this._compassIcon=ne.create("span","maplibregl-ctrl-icon",this._compass),this._compassIcon.setAttribute("aria-hidden","true"))}onAdd(e){return this._map=e,this.options.showZoom&&(this._setButtonTitle(this._zoomInButton,"ZoomIn"),this._setButtonTitle(this._zoomOutButton,"ZoomOut"),this._map.on("move",this._updateZoomButtons),this._updateZoomButtons()),this.options.showCompass&&(this._setButtonTitle(this._compass,"ResetBearing"),this.options.visualizePitch&&this._map.on("pitch",this._rotateCompassArrow),this.options.visualizeRoll&&this._map.on("roll",this._rotateCompassArrow),this._map.on("rotate",this._rotateCompassArrow),this._rotateCompassArrow(),this._handler=new qR(this._map,this._compass,this.options.visualizePitch)),this._container}onRemove(){this._container.remove(),this.options.showZoom&&this._map.off("move",this._updateZoomButtons),this.options.showCompass&&(this.options.visualizePitch&&this._map.off("pitch",this._rotateCompassArrow),this.options.visualizeRoll&&this._map.off("roll",this._rotateCompassArrow),this._map.off("rotate",this._rotateCompassArrow),this._handler.off(),delete this._handler),delete this._map}_createButton(e,t){let i=ne.create("button",e,this._container);return i.type="button",i.addEventListener("click",t),i}},qR=class{constructor(e,t,i=!1){this.mousedown=a=>{this.startMove(a,ne.mousePos(this.element,a)),window.addEventListener("mousemove",this.mousemove),window.addEventListener("mouseup",this.mouseup)},this.mousemove=a=>{this.move(a,ne.mousePos(this.element,a))},this.mouseup=a=>{this._rotatePitchHandler.dragEnd(a),this.offTemp()},this.touchstart=a=>{a.targetTouches.length===1?(this._startPos=this._lastPos=ne.touchPos(this.element,a.targetTouches)[0],this.startMove(a,this._startPos),window.addEventListener("touchmove",this.touchmove,{passive:!1}),window.addEventListener("touchend",this.touchend)):this.reset()},this.touchmove=a=>{a.targetTouches.length===1?(this._lastPos=ne.touchPos(this.element,a.targetTouches)[0],this.move(a,this._lastPos)):this.reset()},this.touchend=a=>{a.targetTouches.length===0&&this._startPos&&this._lastPos&&this._startPos.dist(this._lastPos)<this._clickTolerance&&this.element.click(),delete this._startPos,delete this._lastPos,this.offTemp()},this.reset=()=>{this._rotatePitchHandler.reset(),delete this._startPos,delete this._lastPos,this.offTemp()},this._clickTolerance=10,this.element=t;let r=new bR;this._rotatePitchHandler=new Ro({clickTolerance:3,move:(a,n)=>{let o=t.getBoundingClientRect(),s=new C((o.bottom-o.top)/2,(o.right-o.left)/2);return{bearingDelta:$_(new C(a.x,n.y),n,s),pitchDelta:i?(n.y-a.y)*-.5:void 0}},moveStateManager:r,enable:!0,assignEvents:()=>{}}),this.map=e,t.addEventListener("mousedown",this.mousedown),t.addEventListener("touchstart",this.touchstart,{passive:!1}),t.addEventListener("touchcancel",this.reset)}startMove(e,t){this._rotatePitchHandler.dragStart(e,t),ne.disableDrag()}move(e,t){let i=this.map,{bearingDelta:r,pitchDelta:a}=this._rotatePitchHandler.dragMove(e,t)||{};r&&i.setBearing(i.getBearing()+r),a&&i.setPitch(i.getPitch()+a)}off(){let e=this.element;e.removeEventListener("mousedown",this.mousedown),e.removeEventListener("touchstart",this.touchstart),window.removeEventListener("touchmove",this.touchmove),window.removeEventListener("touchend",this.touchend),e.removeEventListener("touchcancel",this.reset),this.offTemp()}offTemp(){ne.enableDrag(),window.removeEventListener("mousemove",this.mousemove),window.removeEventListener("mouseup",this.mouseup),window.removeEventListener("touchmove",this.touchmove),window.removeEventListener("touchend",this.touchend)}},Br;async function WR(e=!1){if(Br!==void 0&&!e)return Br;if(window.navigator.permissions===void 0)return Br=!!window.navigator.geolocation,Br;try{Br=(await window.navigator.permissions.query({name:"geolocation"})).state!=="denied"}catch{Br=!!window.navigator.geolocation}return Br}function Zx(e,t,i,r=!1){if(r||!i.getCoveringTilesDetailsProvider().allowWorldCopies())return e?.wrap();let a=new X(e.lng,e.lat);if(e=new X(e.lng,e.lat),t){let n=new X(e.lng-360,e.lat),o=new X(e.lng+360,e.lat),s=i.locationToScreenPoint(e).distSqr(t);i.locationToScreenPoint(n).distSqr(t)<s?e=n:i.locationToScreenPoint(o).distSqr(t)<s&&(e=o)}for(;Math.abs(e.lng-i.center.lng)>180;){let n=i.locationToScreenPoint(e);if(n.x>=0&&n.y>=0&&n.x<=i.width&&n.y<=i.height)break;e.lng>i.center.lng?e.lng-=360:e.lng+=360}return e.lng!==a.lng&&i.isPointOnMapSurface(i.locationToScreenPoint(e))?e:a}var jp={center:"translate(-50%,-50%)",top:"translate(-50%,0)","top-left":"translate(0,0)","top-right":"translate(-100%,0)",bottom:"translate(-50%,-100%)","bottom-left":"translate(0,-100%)","bottom-right":"translate(-100%,-100%)",left:"translate(0,-50%)",right:"translate(-100%,-50%)"};function qx(e,t,i){let r=e.classList;for(let a in jp)r.remove(`maplibregl-${i}-anchor-${a}`);r.add(`maplibregl-${i}-anchor-${t}`)}var A_={ArrowLeft:[-1,0],ArrowRight:[1,0],ArrowUp:[0,-1],ArrowDown:[0,1]},Wx="#3FB1CE";function mi(e,t,i=[]){let r=ne.createNS("http://www.w3.org/2000/svg",e);for(let a in t)r.setAttributeNS(null,a,t[a]);for(let a of i)r.appendChild(a);return r}var Dh;function HR(){return Dh||(Dh=mi("svg",{display:"block",height:"41px",width:"27px",viewBox:"0 0 27 41"},[mi("g",{"fill-rule":"nonzero"},[mi("g",{transform:"translate(3.0, 29.0)",fill:"#000000"},[["10.5","5.25002273"],["10.5","5.25002273"],["9.5","4.77275007"],["8.5","4.29549936"],["7.5","3.81822308"],["6.5","3.34094679"],["5.5","2.86367051"],["4.5","2.38636864"]].map(([e,t])=>mi("ellipse",{opacity:"0.04",cx:"10.5",cy:"5.80029008",rx:e,ry:t}))),mi("g",{fill:Wx},[mi("path",{d:"M27,13.5 C27,19.074644 20.250001,27.000002 14.75,34.500002 C14.016665,35.500004 12.983335,35.500004 12.25,34.500002 C6.7499993,27.000002 0,19.222562 0,13.5 C0,6.0441559 6.0441559,0 13.5,0 C20.955844,0 27,6.0441559 27,13.5 Z"})]),mi("g",{opacity:"0.25",fill:"#000000"},[mi("path",{d:"M13.5,0 C6.0441559,0 0,6.0441559 0,13.5 C0,19.222562 6.7499993,27 12.25,34.5 C13,35.522727 14.016664,35.500004 14.75,34.5 C20.250001,27 27,19.074644 27,13.5 C27,6.0441559 20.955844,0 13.5,0 Z M13.5,1 C20.415404,1 26,6.584596 26,13.5 C26,15.898657 24.495584,19.181431 22.220703,22.738281 C19.945823,26.295132 16.705119,30.142167 13.943359,33.908203 C13.743445,34.180814 13.612715,34.322738 13.5,34.441406 C13.387285,34.322738 13.256555,34.180814 13.056641,33.908203 C10.284481,30.127985 7.4148684,26.314159 5.015625,22.773438 C2.6163816,19.232715 1,15.953538 1,13.5 C1,6.584596 6.584596,1 13.5,1 Z"})]),mi("g",{transform:"translate(6.0, 7.0)",fill:"#FFFFFF"}),mi("g",{transform:"translate(8.0, 8.0)"},[mi("circle",{fill:"#000000",opacity:"0.25",cx:"5.5",cy:"5.5",r:"5.4999962"}),mi("circle",{fill:"#FFFFFF",cx:"5.5",cy:"5.5",r:"5.4999962"})])])]),Dh)}function XR(e){return e.firstElementChild.children[1]}var jr=class extends li{},Hx=class extends li{},ud=class extends ht{constructor(e){if(super(),this._onClick=t=>{this.fire(new Hx("click",{originalEvent:t}))},this._onKeyPress=t=>{(t.code==="Space"||t.code==="Enter")&&this.togglePopup()},this._onKeyDown=t=>{if(!this._defaultMarker||!this._draggable||!this._map||!this._lngLat||t.composedPath()[0]!==this._element||t.altKey||t.ctrlKey||t.metaKey)return;let i=A_[t.key];if(!i)return;t.preventDefault(),t.stopPropagation();let r=t.shiftKey?10:1,a=this._map.project(this._lngLat);this.setLngLat(this._map.unproject(new C(a.x+i[0]*r,a.y+i[1]*r))),this._keyboardDragActive||(this._keyboardDragActive=!0,this.fire(new jr("dragstart"))),this.fire(new jr("drag"))},this._onKeyUp=t=>{A_[t.key]&&this._endKeyboardDrag()},this._onBlur=()=>{this._endKeyboardDrag()},this._onMapClick=t=>{let i=t.originalEvent.target,r=this._element;this._popup&&(i===r||r.contains(i))&&this.togglePopup()},this._updateCoveredUnthrottled=()=>{let t=this._map?.terrain;if(!t||!this._isInViewport())return;let i=this._isCovered(t);i&&this._popup?.isOpen()&&this._popup.remove(),this._element.style.opacity=i?this._opacityWhenCovered:this._opacity,this._element.classList.toggle("maplibregl-marker-covered",i)},this._updateCovered=Bp(this._updateCoveredUnthrottled,100),this._update=t=>{if(!this._map)return;this._lngLat=Zx(this._lngLat,this._flatPos,this._map._camera.transform),this._flatPos=this._pos=this._map.project(this._lngLat)._add(this._offset),this._map.terrain&&(this._flatPos=this._map._camera.transform.locationToScreenPoint(this._lngLat)._add(this._offset));let i="";this._rotationAlignment==="viewport"||this._rotationAlignment==="auto"?i=`rotateZ(${this._rotation}deg)`:this._rotationAlignment==="map"&&(i=`rotateZ(${this._rotation-this._map.getBearing()}deg)`);let r="";this._pitchAlignment==="viewport"||this._pitchAlignment==="auto"?r="rotateX(0deg)":this._pitchAlignment==="map"&&(r=`rotateX(${this._map.getPitch()}deg)`),!this._subpixelPositioning&&t?.type!=="move"&&(this._pos=this._pos.round()),this._element.style.transform=`${jp[this._anchor]} translate(${this._pos.x}px, ${this._pos.y}px) ${r} ${i}`,this._updateOpacity()},this._onMove=t=>{if(!this._isDragging){let i=this._clickTolerance||this._map._clickTolerance;this._isDragging=t.point.dist(this._pointerdownPos)>=i}this._isDragging&&(this._pos=t.point.sub(this._positionDelta),this._lngLat=this._map.unproject(this._pos),this.setLngLat(this._lngLat),this._element.style.pointerEvents="none",this._state==="pending"&&(this._state="active",this.fire(new jr("dragstart"))),this.fire(new jr("drag")))},this._onUp=()=>{this._element.style.pointerEvents="auto",this._positionDelta=null,this._pointerdownPos=null,this._isDragging=!1,this._map.off("mousemove",this._onMove),this._map.off("touchmove",this._onMove),this._state==="active"&&this.fire(new jr("dragend")),this._state="inactive"},this._addDragHandler=t=>{this._element.contains(t.originalEvent.target)&&(t.preventDefault(),this._positionDelta=t.point.sub(this._pos).add(this._offset),this._pointerdownPos=t.point,this._state="pending",this._map.on("mousemove",this._onMove),this._map.on("touchmove",this._onMove),this._map.once("mouseup",this._onUp),this._map.once("touchend",this._onUp))},this._anchor=e?.anchor||"center",this._color=e?.color||Wx,this._scale=e?.scale||1,this._draggable=e?.draggable||!1,this._clickTolerance=e?.clickTolerance||0,this._subpixelPositioning=e?.subpixelPositioning||!1,this._isDragging=!1,this._roleManaged=!1,this._tabIndexManaged=!1,this._keyboardDragActive=!1,this._state="inactive",this._rotation=e?.rotation||0,this._rotationAlignment=e?.rotationAlignment||"auto",this._pitchAlignment=e?.pitchAlignment&&e.pitchAlignment!=="auto"?e.pitchAlignment:this._rotationAlignment,this.setOpacity(e?.opacity,e?.opacityWhenCovered),e?.element)this._element=e.element,this._offset=C.convert(e?.offset||[0,0]);else{this._defaultMarker=!0,this._element=ne.create("div");let t=HR().cloneNode(!0);t.setAttributeNS(null,"height",`${41*this._scale}px`),t.setAttributeNS(null,"width",`${27*this._scale}px`),XR(t).setAttributeNS(null,"fill",this._color),this._element.appendChild(t),this._offset=C.convert(e?.offset||[0,-14])}if(this._element.classList.add("maplibregl-marker"),this._element.addEventListener("dragstart",t=>{t.preventDefault()}),this._element.addEventListener("mousedown",t=>{t.preventDefault()}),qx(this._element,this._anchor,"marker"),e?.className)for(let t of e.className.split(" "))this._element.classList.add(t);this._popup=null}addTo(e){return this.remove(),this._map=e,this._defaultMarker&&!this._element.hasAttribute("aria-label")&&this._element.setAttribute("aria-label",e._getUIString("Marker.Title")),this._updateAccessibilityRole(),e.getCanvasContainer().appendChild(this._element),e.on("move",this._update),e.on("moveend",this._update),e.on("terrain",this._update),e.on("projectiontransition",this._update),e.on("idle",this._update),this._element.addEventListener("click",this._onClick),this.setDraggable(this._draggable),this._update(),this._map.on("click",this._onMapClick),this}remove(){return this._map&&(this._map.off("click",this._onMapClick),this._map.off("move",this._update),this._map.off("moveend",this._update),this._map.off("terrain",this._update),this._map.off("projectiontransition",this._update),this._map.off("idle",this._update),this._map.off("mousedown",this._addDragHandler),this._map.off("touchstart",this._addDragHandler),this._map.off("mouseup",this._onUp),this._map.off("touchend",this._onUp),this._map.off("mousemove",this._onMove),this._map.off("touchmove",this._onMove),delete this._map),this._element.removeEventListener("click",this._onClick),this._element.removeEventListener("keydown",this._onKeyDown),this._element.removeEventListener("keyup",this._onKeyUp),this._element.removeEventListener("blur",this._onBlur),this._element.removeEventListener("keypress",this._onKeyPress),this._keyboardDragActive=!1,this._element.remove(),this._popup&&this._popup.remove(),this}getLngLat(){return this._lngLat}setLngLat(e){return this._lngLat=X.convert(e),this._pos=null,this._update(),this._popup&&this._popup.setLngLat(this._lngLat),this}getElement(){return this._element}setPopup(e){if(this._popup&&(this._popup.remove(),this._popup=null,this._element.removeEventListener("keypress",this._onKeyPress)),e){if(!("offset"in e.options)){let t=13.5/Math.SQRT2;e.options.offset=this._defaultMarker?{top:[0,0],"top-left":[0,0],"top-right":[0,0],bottom:[0,-38.1],"bottom-left":[t,(24.6+t)*-1],"bottom-right":[-t,(24.6+t)*-1],left:[13.5,-24.6],right:[-13.5,-24.6]}:this._offset}this._popup=e,this._element.addEventListener("keypress",this._onKeyPress)}return this._updateTabIndex(),this._updateAccessibilityRole(),this}setSubpixelPositioning(e){return this._subpixelPositioning=e,this}_endKeyboardDrag(){this._keyboardDragActive&&(this._keyboardDragActive=!1,this.fire(new jr("dragend")))}getPopup(){return this._popup}togglePopup(){let e=this._popup;if(this._element.style.opacity===this._opacityWhenCovered)return this;if(e)e.isOpen()?e.remove():(e.setLngLat(this._lngLat),e.addTo(this._map));else return this;return this}_updateOpacity(){if(!this._isInViewport())return;let e=this._map?.terrain,t=this._map._camera.transform.isLocationOccluded(this._lngLat);if(!e||t){let i=t?this._opacityWhenCovered:this._opacity;this._element.style.opacity!==i&&(this._element.style.opacity=i,this._element.classList.toggle("maplibregl-marker-covered",t));return}this._updateCovered()}_isInViewport(){let{width:e,height:t}=this._map._camera.transform;return!!this._pos&&this._pos.x>=0&&this._pos.y>=0&&this._pos.x<=e&&this._pos.y<=t}_isCovered(e){let t=this._map._camera.transform,i=e.getElevationForLngLat(this._lngLat,t),r=Math.max(0,-this._offset.y)/t.pixelsPerMeter,a=Math.sin(this._map.getPitch()*Math.PI/180)*r;return t.isLocationOccluded(this._lngLat,e,i+a)}getOffset(){return this._offset}setOffset(e){return this._offset=C.convert(e),this._update(),this}addClassName(e){this._element.classList.add(e)}removeClassName(e){this._element.classList.remove(e)}toggleClassName(e){return this._element.classList.toggle(e)}setDraggable(e){return this._draggable=!!e,this._element.classList.toggle("maplibregl-marker-draggable",this._draggable),this._map&&(e?(this._map.on("mousedown",this._addDragHandler),this._map.on("touchstart",this._addDragHandler)):(this._map.off("mousedown",this._addDragHandler),this._map.off("touchstart",this._addDragHandler))),this._defaultMarker&&(this._draggable?(this._element.addEventListener("keydown",this._onKeyDown),this._element.addEventListener("keyup",this._onKeyUp),this._element.addEventListener("blur",this._onBlur)):(this._element.removeEventListener("keydown",this._onKeyDown),this._element.removeEventListener("keyup",this._onKeyUp),this._element.removeEventListener("blur",this._onBlur),this._endKeyboardDrag())),this._updateTabIndex(),this._updateAccessibilityRole(),this}isDraggable(){return this._draggable}_updateTabIndex(){this._popup||this._defaultMarker&&this._draggable?this._element.hasAttribute("tabindex")||(this._element.setAttribute("tabindex","0"),this._tabIndexManaged=!0):this._tabIndexManaged&&(this._tabIndexManaged=(this._element.getAttribute("tabindex")==="0"&&this._element.removeAttribute("tabindex"),!1))}_updateAccessibilityRole(){if(!this._defaultMarker||this._element.hasAttribute("role")&&!this._roleManaged)return;let e=this._draggable||this._popup?"button":"img";this._element.setAttribute("role",e),this._roleManaged=!0}setRotation(e){return this._rotation=e||0,this._update(),this}getRotation(){return this._rotation}setRotationAlignment(e){return this._rotationAlignment=e||"auto",this._update(),this}getRotationAlignment(){return this._rotationAlignment}setPitchAlignment(e){return this._pitchAlignment=e&&e!=="auto"?e:this._rotationAlignment,this._update(),this}getPitchAlignment(){return this._pitchAlignment}setOpacity(e,t){return(this._opacity===void 0||e===void 0&&t===void 0)&&(this._opacity="1",this._opacityWhenCovered="0.2"),e!==void 0&&(this._opacity=String(e)),t!==void 0&&(this._opacityWhenCovered=String(t)),this._map&&this._updateOpacity(),this}},YR={positionOptions:{enableHighAccuracy:!1,maximumAge:0,timeout:6e3},fitBoundsOptions:{maxZoom:15},trackUserLocation:!1,showAccuracyCircle:!0,showUserLocation:!0,zoomToUserAccuracy:!0},Is=0,Pn=!1,Vr=class extends li{},hd=class extends li{},Xx=class extends li{},KR=class extends ht{constructor(e){super(),this._onSuccess=t=>{if(this._map){if(this._isOutOfMapMaxBounds(t)){this._setErrorState(),this.fire(new hd("outofmaxbounds",t)),this._updateMarker(),this._finish();return}if(this.options.trackUserLocation)switch(this._lastKnownPosition=t,this._watchState){case"WAITING_ACTIVE":case"ACTIVE_LOCK":case"ACTIVE_ERROR":this._watchState="ACTIVE_LOCK",this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-waiting"),this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-active-error"),this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-active");break;case"BACKGROUND":case"BACKGROUND_ERROR":this._watchState="BACKGROUND",this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-waiting"),this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-background-error"),this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-background");break;default:throw Error(`Unexpected watchState ${this._watchState}`)}this.options.showUserLocation&&this._watchState!=="OFF"&&this._updateMarker(t),(!this.options.trackUserLocation||this._watchState==="ACTIVE_LOCK")&&this._updateCamera(t),this.options.showUserLocation&&this._dotElement.classList.remove("maplibregl-user-location-dot-stale"),this.fire(new hd("geolocate",t)),this._finish()}},this._updateCamera=t=>{let i=new X(t.coords.longitude,t.coords.latitude),r=this._map.getBearing(),a={geolocateSource:!0};if(!this.options.zoomToUserAccuracy){let l=q({},this.options.fitBoundsOptions,{center:i,bearing:r,zoom:this._map.getZoom()});l.linear?this._map.easeTo(l,a):this._map.flyTo(l,a);return}let n=t.coords.accuracy,o=q({bearing:r},this.options.fitBoundsOptions),s=zi.fromLngLat(i,n);this._map.fitBounds(s,o,a)},this._updateMarker=t=>{if(t){let i=new X(t.coords.longitude,t.coords.latitude);this._accuracyCircleMarker.setLngLat(i).addTo(this._map),this._userLocationDotMarker.setLngLat(i).addTo(this._map),this._accuracy=t.coords.accuracy,this._updateCircleRadiusIfNeeded()}else this._userLocationDotMarker.remove(),this._accuracyCircleMarker.remove()},this._onUpdate=()=>{this._updateCircleRadiusIfNeeded()},this._onError=t=>{if(this._map){if(t.code===1){this._watchState="OFF",this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-waiting"),this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-active"),this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-active-error"),this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-background"),this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-background-error"),this._geolocateButton.disabled=!0;let i=this._map._getUIString("GeolocateControl.LocationNotAvailable");this._geolocateButton.title=i,this._geolocateButton.setAttribute("aria-label",i),this._geolocationWatchID!==void 0&&this._clearWatch()}else{if(t.code===3&&Pn)return;this._setErrorState()}this._watchState!=="OFF"&&this.options.showUserLocation&&this._dotElement.classList.add("maplibregl-user-location-dot-stale"),this.fire(new Xx("error",t)),this._finish()}},this._finish=()=>{this._timeoutId&&clearTimeout(this._timeoutId),this._timeoutId=void 0},this._onMoveStart=t=>{if(!this._map)return;let i=t?.[0]instanceof ResizeObserverEntry;!t.geolocateSource&&this._watchState==="ACTIVE_LOCK"&&!i&&!this._map.isZooming()&&(this._watchState="BACKGROUND",this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-background"),this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-active"),this.fire(new Vr("trackuserlocationend")),this.fire(new Vr("userlocationlostfocus")))},this._setupUI=()=>{this._map&&(this._container.addEventListener("contextmenu",t=>{t.preventDefault()}),this._geolocateButton=ne.create("button","maplibregl-ctrl-geolocate",this._container),ne.create("span","maplibregl-ctrl-icon",this._geolocateButton).setAttribute("aria-hidden","true"),this._geolocateButton.type="button",this._geolocateButton.disabled=!0)},this._finishSetupUI=t=>{if(this._map){if(t===!1){_e("Geolocation support is not available so the GeolocateControl will be disabled.");let i=this._map._getUIString("GeolocateControl.LocationNotAvailable");this._geolocateButton.disabled=!0,this._geolocateButton.title=i,this._geolocateButton.setAttribute("aria-label",i)}else{let i=this._map._getUIString("GeolocateControl.FindMyLocation");this._geolocateButton.disabled=!1,this._geolocateButton.title=i,this._geolocateButton.setAttribute("aria-label",i)}this.options.trackUserLocation&&(this._geolocateButton.setAttribute("aria-pressed","false"),this._watchState="OFF"),this.options.showUserLocation&&(this._dotElement=ne.create("div","maplibregl-user-location-dot"),this._userLocationDotMarker=new ud({element:this._dotElement}),this._circleElement=ne.create("div","maplibregl-user-location-accuracy-circle"),this._accuracyCircleMarker=new ud({element:this._circleElement,pitchAlignment:"map"}),this.options.trackUserLocation&&(this._watchState="OFF"),this._map.on("zoom",this._onUpdate),this._map.on("move",this._onUpdate),this._map.on("rotate",this._onUpdate),this._map.on("pitch",this._onUpdate)),this._geolocateButton.addEventListener("click",()=>this.trigger()),this._setup=!0,this.options.trackUserLocation&&this._map.on("movestart",this._onMoveStart)}},this.options=q({},YR,e)}onAdd(e){return this._map=e,this._container=ne.create("div","maplibregl-ctrl maplibregl-ctrl-group"),this._setupUI(),WR().then(t=>this._finishSetupUI(t)),this._container}onRemove(){this._geolocationWatchID!==void 0&&(window.navigator.geolocation.clearWatch(this._geolocationWatchID),this._geolocationWatchID=void 0),this.options.showUserLocation&&this._userLocationDotMarker&&this._userLocationDotMarker.remove(),this.options.showAccuracyCircle&&this._accuracyCircleMarker&&this._accuracyCircleMarker.remove(),this._container.remove(),this._map.off("movestart",this._onMoveStart),this._map.off("zoom",this._onUpdate),this._map.off("move",this._onUpdate),this._map.off("rotate",this._onUpdate),this._map.off("pitch",this._onUpdate),this._map=void 0,Is=0,Pn=!1}_isOutOfMapMaxBounds(e){let t=this._map.getMaxBounds(),i=e.coords;return t&&(i.longitude<t.getWest()||i.longitude>t.getEast()||i.latitude<t.getSouth()||i.latitude>t.getNorth())}_setErrorState(){switch(this._watchState){case"WAITING_ACTIVE":this._watchState="ACTIVE_ERROR",this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-active"),this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-active-error");break;case"ACTIVE_LOCK":this._watchState="ACTIVE_ERROR",this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-active"),this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-active-error"),this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-waiting");break;case"BACKGROUND":this._watchState="BACKGROUND_ERROR",this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-background"),this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-background-error"),this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-waiting");break;case"ACTIVE_ERROR":case"BACKGROUND_ERROR":break;case"OFF":case void 0:break;default:throw Error(`Unexpected watchState ${this._watchState}`)}}_updateCircleRadiusIfNeeded(){let e=this._userLocationDotMarker.getLngLat();if(!this.options.showUserLocation||!this.options.showAccuracyCircle||!this._accuracy||!e)return;let t=this._map.project(e),i=this._map.unproject([t.x+100,t.y]),r=e.distanceTo(i)/100,a=2*this._accuracy/r;this._circleElement.style.width=`${a.toFixed(2)}px`,this._circleElement.style.height=`${a.toFixed(2)}px`}trigger(){if(!this._setup)return _e("Geolocate control triggered before added to a map"),!1;if(this.options.trackUserLocation){switch(this._watchState){case"OFF":this._watchState="WAITING_ACTIVE",this.fire(new Vr("trackuserlocationstart"));break;case"WAITING_ACTIVE":case"ACTIVE_LOCK":case"ACTIVE_ERROR":case"BACKGROUND_ERROR":Is--,Pn=!1,this._watchState="OFF",this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-waiting"),this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-active"),this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-active-error"),this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-background"),this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-background-error"),this.fire(new Vr("trackuserlocationend"));break;case"BACKGROUND":this._watchState="ACTIVE_LOCK",this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-background"),this._lastKnownPosition&&this._updateCamera(this._lastKnownPosition),this.fire(new Vr("trackuserlocationstart")),this.fire(new Vr("userlocationfocus"));break;default:throw Error(`Unexpected watchState ${this._watchState}`)}switch(this._watchState){case"WAITING_ACTIVE":this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-waiting"),this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-active");break;case"ACTIVE_LOCK":this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-active");break;case"OFF":break;default:throw Error(`Unexpected watchState ${this._watchState}`)}if(this._watchState==="OFF"&&this._geolocationWatchID!==void 0)this._clearWatch();else if(this._geolocationWatchID===void 0){this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-waiting"),this._geolocateButton.setAttribute("aria-pressed","true"),Is++;let e;Is>1?(e={maximumAge:6e5,timeout:0},Pn=!0):(e=this.options.positionOptions,Pn=!1),this._geolocationWatchID=window.navigator.geolocation.watchPosition(this._onSuccess,this._onError,e)}}else window.navigator.geolocation.getCurrentPosition(this._onSuccess,this._onError,this.options.positionOptions),this._timeoutId=setTimeout(this._finish,1e4);return!0}_clearWatch(){window.navigator.geolocation.clearWatch(this._geolocationWatchID),this._geolocationWatchID=void 0,this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-waiting"),this._geolocateButton.setAttribute("aria-pressed","false"),this.options.showUserLocation&&this._updateMarker(null)}},JR={maxWidth:100,unit:"metric"},QR=class{constructor(e){this._onMove=()=>{I_(this._map,this._container,this.options)},this.setUnit=t=>{this.options.unit=t,I_(this._map,this._container,this.options)},this.options={...JR,...e}}getDefaultPosition(){return"bottom-left"}onAdd(e){return this._map=e,this._container=ne.create("div","maplibregl-ctrl maplibregl-ctrl-scale",e.getContainer()),this._map.on("move",this._onMove),this._onMove(),this._container}onRemove(){this._container.remove(),this._map.off("move",this._onMove),this._map=void 0}};function I_(e,t,i){let r=i?.maxWidth||100,{width:a,height:n}=e._camera.transform,o=n/2,s=a/2,l=e.unproject([s-r/2,o]),u=e.unproject([s+r/2,o]),h=Math.round(e.project(u).x-e.project(l).x),c=Math.min(r,h,a),d=l.distanceTo(u);if(i?.unit==="imperial"){let p=3.2808*d;p>5280?An(t,c,p/5280,e._getUIString("ScaleControl.Miles")):An(t,c,p,e._getUIString("ScaleControl.Feet"))}else i?.unit==="nautical"?An(t,c,d/1852,e._getUIString("ScaleControl.NauticalMiles")):d>=1e3?An(t,c,d/1e3,e._getUIString("ScaleControl.Kilometers")):An(t,c,d,e._getUIString("ScaleControl.Meters"))}function An(e,t,i,r){let a=tk(i),n=a/i;e.style.width=`${t*n}px`;let o=`${a}\xA0${r}`;e.textContent!==o&&(e.textContent=o)}function ek(e){let t=10**Math.ceil(-Math.log(e)/Math.LN10);return Math.round(e*t)/t}function tk(e){let t=10**(`${Math.floor(e)}`.length-1),i=e/t;return i=i>=10?10:i>=5?5:i>=3?3:i>=2?2:i>=1?1:ek(i),t*i}var cd=class extends li{},ik=class extends ht{constructor(e={}){super(),this._onFullscreenChange=()=>{let t=window.document.fullscreenElement||window.document.webkitFullscreenElement;for(;t?.shadowRoot?.fullscreenElement;)t=t.shadowRoot.fullscreenElement;t===this._container!==this._fullscreen&&this._handleFullscreenChange()},this._onClickFullscreen=()=>{this._isFullscreen()?this._exitFullscreen():this._requestFullscreen()},this._fullscreen=!1,this._pseudo=e.pseudo??!1,e?.container&&(e.container instanceof HTMLElement?this._container=e.container:_e("Full screen control 'container' must be a DOM element.")),"onfullscreenchange"in document?this._fullscreenchange="fullscreenchange":"onmozfullscreenchange"in document?this._fullscreenchange="mozfullscreenchange":"onwebkitfullscreenchange"in document?this._fullscreenchange="webkitfullscreenchange":"onmsfullscreenchange"in document&&(this._fullscreenchange="MSFullscreenChange")}onAdd(e){return this._map=e,this._container||(this._container=this._map.getContainer()),this._controlContainer=ne.create("div","maplibregl-ctrl maplibregl-ctrl-group"),this._setupUI(),this._controlContainer}onRemove(){this._controlContainer.remove(),this._map=null,window.document.removeEventListener(this._fullscreenchange,this._onFullscreenChange)}_setupUI(){let e=this._fullscreenButton=ne.create("button","maplibregl-ctrl-fullscreen",this._controlContainer);ne.create("span","maplibregl-ctrl-icon",e).setAttribute("aria-hidden","true"),e.type="button",this._updateTitle(),this._fullscreenButton.addEventListener("click",this._onClickFullscreen),window.document.addEventListener(this._fullscreenchange,this._onFullscreenChange)}_updateTitle(){let e=this._getTitle();this._fullscreenButton.setAttribute("aria-label",e),this._fullscreenButton.title=e}_getTitle(){return this._map._getUIString(this._isFullscreen()?"FullscreenControl.Exit":"FullscreenControl.Enter")}_isFullscreen(){return this._fullscreen}_handleFullscreenChange(){this._fullscreen=!this._fullscreen,this._fullscreenButton.classList.toggle("maplibregl-ctrl-shrink"),this._fullscreenButton.classList.toggle("maplibregl-ctrl-fullscreen"),this._updateTitle(),this._fullscreen?(this.fire(new cd("fullscreenstart")),this._prevCooperativeGesturesEnabled=this._map.cooperativeGestures.isEnabled(),this._map.cooperativeGestures.disable()):(this.fire(new cd("fullscreenend")),this._prevCooperativeGesturesEnabled&&this._map.cooperativeGestures.enable())}_exitFullscreen(){this._pseudo?this._togglePseudoFullScreen():window.document.exitFullscreen?window.document.exitFullscreen():window.document.webkitCancelFullScreen?window.document.webkitCancelFullScreen():this._togglePseudoFullScreen()}_requestFullscreen(){this._pseudo?this._togglePseudoFullScreen():this._container.requestFullscreen?this._container.requestFullscreen():this._container.webkitRequestFullscreen?this._container.webkitRequestFullscreen():this._togglePseudoFullScreen()}_togglePseudoFullScreen(){this._container.classList.toggle("maplibregl-pseudo-fullscreen"),this._handleFullscreenChange(),this._map.resize()}},rk=class{constructor(e){this._toggleTerrain=()=>{this._map.getTerrain()?this._map.setTerrain(null):this._map.setTerrain(this.options),this._updateTerrainIcon()},this._updateTerrainIcon=()=>{this._terrainButton.classList.remove("maplibregl-ctrl-terrain"),this._terrainButton.classList.remove("maplibregl-ctrl-terrain-enabled"),this._map.terrain?(this._terrainButton.classList.add("maplibregl-ctrl-terrain-enabled"),this._terrainButton.title=this._map._getUIString("TerrainControl.Disable")):(this._terrainButton.classList.add("maplibregl-ctrl-terrain"),this._terrainButton.title=this._map._getUIString("TerrainControl.Enable"))},this.options=e}onAdd(e){return this._map=e,this._container=ne.create("div","maplibregl-ctrl maplibregl-ctrl-group"),this._terrainButton=ne.create("button","maplibregl-ctrl-terrain",this._container),ne.create("span","maplibregl-ctrl-icon",this._terrainButton).setAttribute("aria-hidden","true"),this._terrainButton.type="button",this._terrainButton.addEventListener("click",this._toggleTerrain),this._updateTerrainIcon(),this._map.on("terrain",this._updateTerrainIcon),this._container}onRemove(){this._container.remove(),this._map.off("terrain",this._updateTerrainIcon),this._map=void 0}},ak=class{constructor(){this._toggleProjection=()=>{let e=this._map.getProjection()?.type;e==="mercator"||!e?this._map.setProjection({type:"globe"}):this._map.setProjection({type:"mercator"}),this._updateGlobeIcon()},this._updateGlobeIcon=()=>{this._globeButton.classList.remove("maplibregl-ctrl-globe"),this._globeButton.classList.remove("maplibregl-ctrl-globe-enabled"),this._map.getProjection()?.type==="globe"?(this._globeButton.classList.add("maplibregl-ctrl-globe-enabled"),this._globeButton.title=this._map._getUIString("GlobeControl.Disable")):(this._globeButton.classList.add("maplibregl-ctrl-globe"),this._globeButton.title=this._map._getUIString("GlobeControl.Enable"))}}onAdd(e){return this._map=e,this._container=ne.create("div","maplibregl-ctrl maplibregl-ctrl-group"),this._globeButton=ne.create("button","maplibregl-ctrl-globe",this._container),ne.create("span","maplibregl-ctrl-icon",this._globeButton).setAttribute("aria-hidden","true"),this._globeButton.type="button",this._globeButton.addEventListener("click",this._toggleProjection),this._updateGlobeIcon(),this._map.on("styledata",this._updateGlobeIcon),this._map.on("projectiontransition",this._updateGlobeIcon),this._container}onRemove(){this._container.remove(),this._map.off("styledata",this._updateGlobeIcon),this._map.off("projectiontransition",this._updateGlobeIcon),this._globeButton.removeEventListener("click",this._toggleProjection),this._map=void 0}},nk={closeButton:!0,closeOnClick:!0,focusAfterOpen:!0,className:"",maxWidth:"240px",subpixelPositioning:!1,locationOccludedOpacity:void 0,padding:void 0},ok=["a[href]","[tabindex]:not([tabindex='-1'])","[contenteditable]:not([contenteditable='false'])","button:not([disabled])","input:not([disabled])","select:not([disabled])","textarea:not([disabled])"].join(", "),dd=class extends li{},sk=class extends ht{constructor(e){super(),this._updateOpacity=()=>{this.options.locationOccludedOpacity!==void 0&&(this._map._camera.transform.isLocationOccluded(this.getLngLat())?this._container.style.opacity=`${this.options.locationOccludedOpacity}`:this._container.style.opacity="")},this.remove=()=>(this._content&&this._content.remove(),this._container&&(this._container.remove(),delete this._container),this._map&&(this._map.off("move",this._update),this._map.off("move",this._onClose),this._map.off("click",this._onClose),this._map.off("remove",this.remove),this._map.off("terrain",this._update),this._map.off("projectiontransition",this._update),this._map.off("idle",this._update),this._map.off("mousemove",this._update),this._map.off("mouseup",this._update),this._map.off("drag",this._update),this._map._canvasContainer.classList.remove("maplibregl-track-pointer"),delete this._map,this.fire(new dd("close"))),this),this._update=t=>{let i=this._lngLat||this._trackPointer;if(!this._map||!i||!this._content)return;if(!this._container){if(this._container=ne.create("div","maplibregl-popup",this._map.getContainer()),this._tip=ne.create("div","maplibregl-popup-tip",this._container),this._container.appendChild(this._content),this.options.className)for(let l of this.options.className.split(" "))this._container.classList.add(l);this._closeButton&&this._closeButton.setAttribute("aria-label",this._map._getUIString("Popup.Close")),this._trackPointer&&this._container.classList.add("maplibregl-popup-track-pointer")}this.options.maxWidth&&this._container.style.maxWidth!==this.options.maxWidth&&(this._container.style.maxWidth=this.options.maxWidth),this._lngLat=Zx(this._lngLat,this._flatPos,this._map._camera.transform,this._trackPointer);let r;if(t&&"point"in t&&t.point&&(r=t.point),this._trackPointer&&!r)return;let a=this._flatPos=this._pos=this._trackPointer&&r?r:this._map.project(this._lngLat);this._map.terrain&&(this._flatPos=this._trackPointer&&r?r:this._map._camera.transform.locationToScreenPoint(this._lngLat));let n=this.options.anchor,o=Yx(this.options.offset);if(!n){let l=this._container.offsetWidth,u=this._container.offsetHeight,h=lk(this.options.padding),c;c=a.y+o.bottom.y<u+h.top?["top"]:a.y>this._map._camera.transform.height-u-h.bottom?["bottom"]:[],a.x<l/2+h.left?c.push("left"):a.x>this._map._camera.transform.width-l/2-h.right&&c.push("right"),n=c.length===0?"bottom":c.join("-")}let s=a.add(o[n]);this.options.subpixelPositioning||(s=s.round()),this._container.style.transform=`${jp[n]} translate(${s.x}px,${s.y}px)`,qx(this._container,n,"popup"),this._updateOpacity()},this._onClose=()=>{this.remove()},this.options=q(Object.create(nk),e)}addTo(e){return this._map&&this.remove(),this._map=e,this.options.closeOnClick&&this._map.on("click",this._onClose),this.options.closeOnMove&&this._map.on("move",this._onClose),this._map.on("remove",this.remove),this._map.on("terrain",this._update),this._map.on("projectiontransition",this._update),this._map.on("idle",this._update),this._update(),this._focusFirstElement(),this._trackPointer?(this._map.on("mousemove",this._update),this._map.on("mouseup",this._update),this._container&&this._container.classList.add("maplibregl-popup-track-pointer"),this._map._canvasContainer.classList.add("maplibregl-track-pointer")):this._map.on("move",this._update),this.fire(new dd("open")),this}isOpen(){return!!this._map}getLngLat(){return this._lngLat}setLngLat(e){return this._lngLat=X.convert(e),this._pos=null,this._flatPos=null,this._trackPointer=!1,this._update(),this._map&&(this._map.on("move",this._update),this._map.off("mousemove",this._update),this._container&&this._container.classList.remove("maplibregl-popup-track-pointer"),this._map._canvasContainer.classList.remove("maplibregl-track-pointer")),this}trackPointer(){return this._trackPointer=!0,this._pos=null,this._flatPos=null,this._update(),this._map&&(this._map.off("move",this._update),this._map.on("mousemove",this._update),this._map.on("drag",this._update),this._container&&this._container.classList.add("maplibregl-popup-track-pointer"),this._map._canvasContainer.classList.add("maplibregl-track-pointer")),this}getElement(){return this._container}setText(e){return this.setDOMContent(document.createTextNode(e))}setHTML(e){let t=document.createDocumentFragment(),i=document.createElement("body"),r;for(i.innerHTML=e;r=i.firstChild,r;)t.appendChild(r);return this.setDOMContent(t)}getMaxWidth(){return this._container?.style.maxWidth}setMaxWidth(e){return this.options.maxWidth=e,this._update(),this}setDOMContent(e){if(this._content)for(;this._content.hasChildNodes();)this._content.firstChild&&this._content.removeChild(this._content.firstChild);else this._content=ne.create("div","maplibregl-popup-content",this._container);return this._content.appendChild(e),this._createCloseButton(),this._update(),this._focusFirstElement(),this}addClassName(e){return this._container&&this._container.classList.add(e),this}removeClassName(e){return this._container&&this._container.classList.remove(e),this}setOffset(e){return this.options.offset=e,this._update(),this}toggleClassName(e){if(this._container)return this._container.classList.toggle(e)}setSubpixelPositioning(e){this.options.subpixelPositioning=e}setPadding(e){this.options.padding=e,this._update()}_createCloseButton(){this.options.closeButton&&(this._closeButton=ne.create("button","maplibregl-popup-close-button",this._content),this._closeButton.type="button",this._closeButton.innerHTML="×",this._closeButton.addEventListener("click",this._onClose))}_focusFirstElement(){if(!this.options.focusAfterOpen||!this._container)return;let e=this._container.querySelector(ok);e&&e.focus()}};function Yx(e){if(!e)return Yx(new C(0,0));if(typeof e=="number"){let t=Math.round(Math.abs(e)/Math.SQRT2);return{center:new C(0,0),top:new C(0,e),"top-left":new C(t,t),"top-right":new C(-t,t),bottom:new C(0,-e),"bottom-left":new C(t,-t),"bottom-right":new C(-t,-t),left:new C(e,0),right:new C(-e,0)}}if(e instanceof C||Array.isArray(e)){let t=C.convert(e);return{center:t,top:t,"top-left":t,"top-right":t,bottom:t,"bottom-left":t,"bottom-right":t,left:t,right:t}}return{center:C.convert(e.center||[0,0]),top:C.convert(e.top||[0,0]),"top-left":C.convert(e["top-left"]||[0,0]),"top-right":C.convert(e["top-right"]||[0,0]),bottom:C.convert(e.bottom||[0,0]),"bottom-left":C.convert(e["bottom-left"]||[0,0]),"bottom-right":C.convert(e["bottom-right"]||[0,0]),left:C.convert(e.left||[0,0]),right:C.convert(e.right||[0,0])}}function lk(e){return e?{top:e.top??0,right:e.right??0,bottom:e.bottom??0,left:e.left??0}:{top:0,right:0,bottom:0,left:0}}var uk=fd;function hk(e,t){return _o().setRTLTextPlugin(e,t)}function ck(){return _o().getRTLTextPluginStatus()}function dk(){return uk}function pk(){return Kl.workerCount}function fk(e){Kl.workerCount=e}function mk(){return si.MAX_PARALLEL_IMAGE_REQUESTS}function gk(e){si.MAX_PARALLEL_IMAGE_REQUESTS=e}function _k(){return si.WORKER_URL}function yk(e){si.WORKER_URL=e}async function vk(e){await np().broadcast("IS",e)}return lb(xk);})();
|
|
818
|
+
/*! Bundled license information:
|
|
819
|
+
|
|
820
|
+
maplibre-gl/dist/maplibre-gl.mjs:
|
|
821
|
+
(**
|
|
822
|
+
* MapLibre GL JS
|
|
823
|
+
* @license 3-Clause BSD. Full text of license: https://github.com/maplibre/maplibre-gl-js/blob/v6.13.0/LICENSE.txt
|
|
824
|
+
*)
|
|
825
|
+
*/
|