PageSourceSearch

https://doghealthy.netlify.app/_nuxt/CSVj-Sj2.js

js doghealthy.netlify.app collected 2026-10-03 10:41:01 UTC 1,923,620 bytes, 3,408 lines download raw bytes

1import{f as Jp,g as A1,u as C1,r as ei,K as ev,L as Gg,c as It,i as xi,a as je,t as Dt,j as Oe,l as Fd,m as Os,v as ol,I as fS,o as At,R as pS,h as iv,S as $g,d as Ar,T as M1,x as P1,q as Zu,D as mS,H as _S,b as To,w as nl,y as Ug,P as w1,F as Kx,k as Jx,e as gS,N as yS,U as xS,G as vS}from"#entry";import{Q as bS}from"./Y1HWn8AB.js";import{n as T1,u as S1}from"./BDkyKk_g.js";import{u as wS}from"./Z8EQgydt.js";import{u as TS}from"./Dy9pVEbO.js";import"./DKLWY9DJ.js";const SS={key:0,class:"fixed inset-0 z-50 flex items-center justify-center p-4 bg-black/50",role:"dialog","aria-modal":"true","aria-labelledby":"nfc-address-title"},ES={class:"bg-white rounded-2xl shadow-xl w-full max-w-lg max-h-[90vh] overflow-y-auto p-6"},IS={class:"text-sm text-gray-600 mb-5"},AS={key:0,class:"mb-4 rounded-lg border border-red-200 bg-red-50 px-3 py-2 text-sm text-red-700"},CS={class:"grid grid-cols-1 sm:grid-cols-2 gap-4"},MS={class:"flex flex-col-reverse sm:flex-row sm:justify-end gap-2 pt-2"},PS=["disabled"],RS=["disabled"],DS=Jp({__name:"NfcShippingAddressModal",props:{open:{type:Boolean},dogName:{default:""},dogId:{default:""},initial:{},confirmLabel:{default:"Save address & create tag"}},emits:["cancel","saved"],setup(Xr,{emit:Jt}){const vi=Xr,ri=Jt,br=A1(),Cn=C1(),cn=ei(!1),u=ei(""),F=ev({billing_name:"",address_line1:"",address_line2:"",address_city:"",address_postcode:"",address_country:"GB",phone:""});Gg(()=>vi.open,Ht=>{Ht&&(u.value="",F.billing_name=vi.initial?.billing_name||"",F.address_line1=vi.initial?.address_line1||"",F.address_line2=vi.initial?.address_line2||"",F.address_city=vi.initial?.address_city||"",F.address_postcode=vi.initial?.address_postcode||"",F.address_country=vi.initial?.address_country||"GB",F.phone=vi.initial?.phone||"")},{immediate:!0});const Yi=async()=>{cn.value=!0,u.value="";try{if(!br.userId)throw new Error("Please sign in again.");const Ht={billing_name:F.billing_name.trim(),address_line1:F.address_line1.trim(),address_line2:F.address_line2.trim()||null,address_city:F.address_city.trim(),address_postcode:F.address_postcode.trim().toUpperCase(),address_country:F.address_country||"GB",phone:F.phone.trim()||null};if(!Ht.billing_name||!Ht.address_line1||!Ht.address_city||!Ht.address_postcode)throw new Error("Please complete all required address fields.");const{error:Wt}=await Cn.from("doghealthy_users").update(Ht).eq("id",br.userId);if(Wt)throw Wt;ri("saved",{billing_name:Ht.billing_name,address_line1:Ht.address_line1,address_line2:Ht.address_line2||"",address_city:Ht.address_city,address_postcode:Ht.address_postcode,address_country:Ht.address_country,phone:Ht.phone||""})}catch(Ht){u.value=Ht?.message||"Failed to save address"}finally{cn.value=!1}};return(Ht,Wt)=>Xr.open?(At(),It("div",SS,[je("div",ES,[Wt[16]||(Wt[16]=je("h2",{id:"nfc-address-title",class:"text-xl font-bold text-gray-900 mb-2"}," Shipping address for NFC stickers ",-1)),je("p",IS," NFC Me will print and post stickers to this UK address for "+Dt(Xr.dogName||"your dog")+". Your QR code is ready online immediately — next you’ll confirm the sticker order. ",1),Oe(u)?(At(),It("div",AS,Dt(Oe(u)),1)):xi("",!0),je("form",{class:"space-y-4",onSubmit:Fd(Yi,["prevent"])},[je("div",null,[Wt[8]||(Wt[8]=je("label",{class:"block text-sm font-medium text-gray-700 mb-1",for:"billing_name"},"Full name",-1)),Os(je("input",{id:"billing_name","onUpdate:modelValue":Wt[0]||(Wt[0]=St=>Oe(F).billing_name=St),type:"text",required:"",autocomplete:"name",class:"w-full px-3 py-2 border border-gray-300 rounded-lg focus:outline-none focus:ring-2 focus:ring-blue-500"},null,512),[[ol,Oe(F).billing_name]])]),je("div",null,[Wt[9]||(Wt[9]=je("label",{class:"block text-sm font-medium text-gray-700 mb-1",for:"address_line1"},"Address line 1",-1)),Os(je("input",{id:"address_line1","onUpdate:modelValue":Wt[1]||(Wt[1]=St=>Oe(F).address_line1=St),type:"text",required:"",autocomplete:"address-line1",class:"w-full px-3 py-2 border border-gray-300 rounded-lg focus:outline-none focus:ring-2 focus:ring-blue-500"},null,512),[[ol,Oe(F).address_line1]])]),je("div",null,[Wt[10]||(Wt[10]=je("label",{class:"block text-sm font-medium text-gray-700 mb-1",for:"address_line2"},"Address line 2 (optional)",-1)),Os(je("input",{id:"address_line2","onUpdate:modelValue":Wt[2]||(Wt[2]=St=>Oe(F).address_line2=St),type:"text",autocomplete:"address-line2",class:"w-full px-3 py-2 border border-gray-300 rounded-lg focus:outline-none focus:ring-2 focus:ring-blue-500"},null,512),[[ol,Oe(F).address_line2]])]),je("div",CS,[je("div",null,[Wt[11]||(Wt[11]=je("label",{class:"block text-sm font-medium text-gray-700 mb-1",for:"address_city"},"Town / city",-1)),Os(je("input",{id:"address_city","onUpdate:modelValue":Wt[3]||(Wt[3]=St=>Oe(F).address_city=St),type:"text",required:"",autocomplete:"address-level2",class:"w-full px-3 py-2 border border-gray-300 rounded-lg focus:outline-none focus:ring-2 focus:ring-blue-500"},null,512),[[ol,Oe(F).address_city]])]),je("div",null,[Wt[12]||(Wt[12]=je("label",{class:"block text-sm font-medium text-gray-700 mb-1",for:"address_postcode"}
1,"Postcode",-1)),Os(je("input",{id:"address_postcode","onUpdate:modelValue":Wt[4]||(Wt[4]=St=>Oe(F).address_postcode=St),type:"text",required:"",autocomplete:"postal-code",class:"w-full px-3 py-2 border border-gray-300 rounded-lg focus:outline-none focus:ring-2 focus:ring-blue-500 uppercase"},null,512),[[ol,Oe(F).address_postcode]])])]),je("div",null,[Wt[14]||(Wt[14]=je("label",{class:"block text-sm font-medium text-gray-700 mb-1",for:"address_country"},"Country",-1)),Os(je("select",{id:"address_country","onUpdate:modelValue":Wt[5]||(Wt[5]=St=>Oe(F).address_country=St),class:"w-full px-3 py-2 border border-gray-300 rounded-lg focus:outline-none focus:ring-2 focus:ring-blue-500"},[...Wt[13]||(Wt[13]=[je("option",{value:"GB"},"United Kingdom",-1)])],512),[[fS,Oe(F).address_country]])]),je("div",null,[Wt[15]||(Wt[15]=je("label",{class:"block text-sm font-medium text-gray-700 mb-1",for:"ship_phone"},"UK mobile (optional)",-1)),Os(je("input",{id:"ship_phone","onUpdate:modelValue":Wt[6]||(Wt[6]=St=>Oe(F).phone=St),type:"tel",autocomplete:"tel",placeholder:"+447…",class:"w-full px-3 py-2 border border-gray-300 rounded-lg focus:outline-none focus:ring-2 focus:ring-blue-500"},null,512),[[ol,Oe(F).phone]])]),je("div",MS,[je("button",{type:"button",class:"px-4 py-2 rounded-lg border border-gray-300 text-gray-700 font-medium hover:bg-gray-50",disabled:Oe(cn),onClick:Wt[7]||(Wt[7]=St=>Ht.$emit("cancel"))}," Cancel ",8,PS),je("button",{type:"submit",class:"px-4 py-2 rounded-lg bg-blue-600 hover:bg-blue-700 disabled:opacity-60 text-white font-semibold",disabled:Oe(cn)},Dt(Oe(cn)?"Saving…":Xr.confirmLabel),9,RS)])],32)])])):xi("",!0)}});var jg={exports:{}},LS=jg.exports,E1;function zS(){return E1||(E1=1,(function(Xr,Jt){(function(vi,ri){Xr.exports=ri()})(LS,(function(){let vi,ri,br;typeof self<"u"&&(self.__mapboxImport=u=>import(u));function Cn(u,F){if(!vi)vi=F;else if(!ri)ri=F;else{const Yi={};vi(void 0,Yi),br=F(Yi);const Ht="self.onerror = function() { console.error('An error occurred while parsing the WebWorker bundle. This is most likely due to improper transpilation by Babel; please see https://docs.mapbox.com/mapbox-gl-js/guides/install/#transpiling'); }; var sharedChunk = {}; self.__mapboxImport = (u) => import(u); ("+vi+")(undefined, sharedChunk); ("+ri+")(undefined, sharedChunk); self.onerror = null;";typeof window<"u"&&window&&window.URL&&window.URL.createObjectURL&&(br.workerUrl=window.URL.createObjectURL(new Blob([Ht],{type:"text/javascript"})))}}Cn(["require","exports"],function(u,F){var Yi=1e-6,Ht=typeof Float32Array<"u"?Float32Array:Array;function Wt(r,e){var i=e[0],o=e[1],a=e[2],c=e[3],h=i*c-a*o;return h?(r[0]=c*(h=1/h),r[1]=-o*h,r[2]=-a*h,r[3]=i*h,r):null}function St(){var r=new Ht(9);return Ht!=Float32Array&&(r[1]=0,r[2]=0,r[3]=0,r[5]=0,r[6]=0,r[7]=0),r[0]=1,r[4]=1,r[8]=1,r}function Ti(r,e,i){var o=e[0],a=e[1],c=e[2],h=e[3],f=e[4],_=e[5],y=e[6],v=e[7],b=e[8],T=i[0],E=i[1],C=i[2],P=i[3],R=i[4],z=i[5],V=i[6],N=i[7],U=i[8];return r[0]=T*o+E*h+C*y,r[1]=T*a+E*f+C*v,r[2]=T*c+E*_+C*b,r[3]=P*o+R*h+z*y,r[4]=P*a+R*f+z*v,r[5]=P*c+R*_+z*b,r[6]=V*o+N*h+U*y,r[7]=V*a+N*f+U*v,r[8]=V*c+N*_+U*b,r}function mn(){var r=new Ht(16);return Ht!=Float32Array&&(r[1]=0,r[2]=0,r[3]=0,r[4]=0,r[6]=0,r[7]=0,r[8]=0,r[9]=0,r[11]=0,r[12]=0,r[13]=0,r[14]=0),r[0]=1,r[5]=1,r[10]=1,r[15]=1,r}function Nt(r){var e=new Ht(16);return e[0]=r[0],e[1]=r[1],e[2]=r[2],e[3]=r[3],e[4]=r[4],e[5]=r[5],e[6]=r[6],e[7]=r[7],e[8]=r[8],e[9]=r[9],e[10]=r[10],e[11]=r[11],e[12]=r[12],e[13]=r[13],e[14]=r[14],e[15]=r[15],e}function Si(r){return r[0]=1,r[1]=0,r[2]=0,r[3]=0,r[4]=0,r[5]=1,r[6]=0,r[7]=0,r[8]=0,r[9]=0,r[10]=1,r[11]=0,r[12]=0,r[13]=0,r[14]=0,r[15]=1,r}function co(r,e){var i=e[0],o=e[1],a=e[2],c=e[3],h=e[4],f=e[5],_=e[6],y=e[7],v=e[8],b=e[9],T=e[10],E=e[11],C=e[12],P=e[13],R=e[14],z=e[15],V=i*f-o*h,N=i*_-a*h,U=i*y-c*h,q=o*_-a*f,W=o*y-c*f,se=a*y-c*_,X=v*P-b*C,ie=v*R-T*C,re=v*z-E*C,oe=b*R-T*P,me=b*z-E*P,xe=T*z-E*R,we=V*xe-N*me+U*oe+q*re-W*ie+se*X;return we?(r[0]=(f*xe-_*me+y*oe)*(we=1/we),r[1]=(a*me-o*xe-c*oe)*we,r[2]=(P*se-R*W+z*q)*we,r[3]=(T*W-b*se-E*q)*we,r[4]=(_*re-h*xe-y*ie)*we,r[5]=(i*xe-a*re+c*ie)*we,r[6]=(R*U-C*se-z*N)*we,r[7]=(v*se-T*U+E*N)*we,r[8]=(h*me-f*re+y*X)*we,r[9]=(o*re-i*me-c*X)*we,r[10]=(C*W-P*U+z*V)*we,r[11]=(b*U-v*W-E*V)*we,r[12]=(f*ie-h*oe-_*X)*we,r[13]=(i*oe-o*ie+a*X)*we,r[14]=(P*N-C*q-R*V)*we,r[15]=(v*q-b*N+T*V)*we,r):null}function Ni(r,e,i){var o=e[0],a=e[1],c=e[2],h=e[3],f=e[4],_=e[5],y=e[6],v=e[7],b=e[8],T=e[9],E=e[10],C=e[11],P=e[12],R=e[13],z=e[14],V=e[15],N=i[0],U=i[1],q=i[2],W=i[3];return r[0]=N*o+U*f+q*b+W*P,r[1]=N*a+U*_+q*T+W*R,r[2]=N*c+U*y+q*E+W*z,r[3]=N*h+U*v+q*C+W*V,r[4]=(N=i[4])*o+(U=i[5])*f+(q=i[6])*b+(W=i[7])*P,r[5]=N*a+U*_+q*T+W*R,r[6]=N*c+U*y+q*E+W*z,r[7]=N*h+U*v+q*C+W*V,r[8]=(N=i[8])*o+(U=i[9])*f+(q=i[10])*b+(W=i[11])*P,r[9]=N*a+U*_+q*T+W*R,r[10]=N*c+U*y+q*E+W*z,r[11]=N*h+U*v+q*C+W*V,r[12]=(N=i[12])*o+(U=i[13])*f+(q=i[14])*b+(W=i[15])*P,r[13]=N*a+U*_+q*T+W*R,r[14]=N*c+U*y+q*E+W*z,r[15]=N*h+U*v+q*C+W*V,r}function Mn(r,e,i){var o,a,c,h,f,_,y,v,b,T,E,C,P=i[0],R=i[1],z=i[2];return e===r?(r[12]=e[0]*P+e[4]*R+e[8]*z+e[12],r[13]=e[1]*P+e[5]*R+e[9]*z+e[13],r[14]=e[2]*P+e[6]*R+e[10]*z+e[14],r[15]=e[3]*P+e[7]*R+e[11]*z+e[15]):(a=e[1],c=e[2],h=e[3],f=e[4],_=e[5],y=e[6],v=e[7],b=e[8],T=e[9],E=e[10],C=e[11],r[0]=o=e[0],r[1]=a,r[2]=c,r[3]=h,r[4]=f,r[5]=_,r[6]=y,r[7]=v,r[8]=b,r[9]=T,r[10]=E,r[11]=C,r[12]=o*P+f*R+b*z+e[12],r[13]=a*P+_*R+T*z+e[13],r[14]=c*P+y*R+E*z+e[14],r[15]=h*P+v*R+C*z+e[15]),r}function _n(r,e,i){var o=i[0],a=i[1],c=i[2];return r[0]=e[0]*o,r[1]=e[1]*o,r[2]=e[2]*o,r[3]=e[3]*o,r[4]=e[4]*a,r[5]=e[5]*a,r[6]=e[6]*a,r[7]=e[7]*a,r[8]=e[8]*c,r[9]=e[9]*c,r[10]=e[10]*c,r[11]=e[11]*c,r[12]=e[12],r[13]=e[13],r[14]=e[14],r[15]=e[15],r}function gn(r,e,i){var o=Math.sin(i),a=Math.cos(i),c=e[4],h=e[5],f=e[6],_=e[7],y=e[8],v=e[9],b=e[10],T=e[11];return e!==r&&(r[0]=e[0],r[1]=e[1],r[2]=e[2],r[3]=e[3],r[12]=e[12],r[13]=e[13],r[14]=e[14],r[15]=e[15]),r[4]=c*a+y*o,r[5]=h*a+v*o,r[6]=f*a+b*o,r[7]=_*a+T*o,r[8]=y*a-c*o,r[9]=v*a-h*o,r[10]=b*a-f*o,r[11]=T*a-_*o,r}function Pn(r,e,i){var o=Math.sin(i),a=Math.cos(i),c=e[0],h=e[1],f=e[2],_=e[3],y=e[8],v=e[9],b=e[10],T=e[11];return e!==r&&(r[4]=e[4],r[5]=e[5],r[6]=e[6],r[7]=e[7],r[12]=e[12],r[13]=e[13],r[14]=e[14],r[15]=e[15]),r[0]=c*a-y*o,r[1]=h*a-v*o,r[2]=f*a-b*o,r[3]=_*a-T*o,r[8]=c*o+y*a,r[9]=h*o+v*a,r[10]=f*o+b*a,r[11]=_*o+T*a,r}function un(r,e,i){var o=Math.sin(i),a=Math.cos(i),c=e[0],h=e[1],f=e[2],_=e[3],y=e[4],v=e[5],b=e[6],T=e[7];return e!==r&&(r[8]=e[8],r[9]=e[9],r[10]=e[10],r[11]=e[11],r[12]=e[12],r[13]=e[13],r[14]=e[14],r[15]=e[15]),r[0]=c*a+y*o,r[1]=h*a+v*o,r[2]=f*a+b*o,r[3]=_*a+T*o,r[4]=y*a-c*o,r[5]=v*a-h*o,r[6]=b*a-f*o,r[7]=T*a-_*o,r}function hn(r,e){return r[0]=1,r[1]=0,r[2]=0,r[3]=0,r[4]=0,r[5]=1,r[6]=0,r[7]=0,r[8]=0,r[9]=0,r[10]=1,r[11]=0,r[12]=e[0],r[13]=e[1],r[14]=e[2],r[15]=1,r}function So(r,e){return r[0]=e[0],r[1]=0,r[2]=0,r[3]=0,r[4]=0,r[5]=e[1],r[6]=0,r[7]=0,r[8]=0,r[9]=0,r[10]=e[2],r[11]=0,r[12]=0,r[13]=0,r[14]=0,r[15]=1,r}function uo(r,e,i){var o,a,c,h=i[0],f=i[1],_=i[2],y=Math.sqrt(h*h+f*f+_*_);return y<Yi?null:(h*=y=1/y,f*=y,_*=y,o=Math.sin(e),a=Math.cos(e),r[0]=h*h*(c=1-a)+a,r[1]=f*h*c+_*o,r[2]=_*h*c-f*o,r[3]=0,r[4]=h*f*c-_*o,r[5]=f*f*c+a,r[6]=_*f*c+h*o,r[7]=0,r[8]=h*_*c+f*o,r[9]=f*_*c-h*o,r[10]=_*_*c+a,r[11]=0,r[12]=0,r[13]=0,r[14]=0,r[15]=1,r)}function ho(r,e){var i=e[0],o=e[1],a=e[2],c=e[4],h=e[5],f=e[6],_=e[8],y=e[9],v=e[10];return r[0]=Math.sqrt(i*i+o*o+a*a),r[1]=Math.sqrt(c*c+h*h+f*f),r[2]=Math.sqrt(_*_+y*y+v*v),r}function Nn(r,e){var i=e[0],o=e[1],a=e[2],c=e[3],h=i+i,f=o+o,_=a+a,y=i*h,v=o*h,b=o*f,T=a*h,E=a*f,C=a*_,P=c*h,R=c*f,z=c*_;return r[0]=1-b-C,r[1]=v+z,r[2]=T-R,r[3]=0,r[4]=v-z,r[5]=1-y-C,r[6]=E+P,r[7]=0,r[8]=T+R,r[9]=E-P,r[10]=1-y-b,r[11]=0,r[12]=0,r[13]=0,r[14]=0,r[15]=1,r}var Sn=Ni;function Zt(){var r=new Ht(3);return Ht!=Float32Array&&(r[0]=0,r[1]=0,r[2]=0),r}function Eo(r){var e=new Ht(3);return e[0]=r[0],e[1]=r[1],e[2]=r[2],e}function Yr(r){var e=r[0],i=r[1],o=r[2];return Math.sqrt(e*e+i*i+o*o)}
vendor: 13,086 bytes, line 1
1function ur(r,e,i){var o=new Ht(3);return o[0]=r,o[1]=e,o[2]=i,o}function Li(r,e,i,o){return r[0]=e,r[1]=i,r[2]=o,r}function ji(r,e,i){return r[0]=e[0]+i[0],r[1]=e[1]+i[1],r[2]=e[2]+i[2],r}function dn(r,e,i){return r[0]=e[0]-i[0],r[1]=e[1]-i[1],r[2]=e[2]-i[2],r}function gs(r,e,i){return r[0]=e[0]*i[0],r[1]=e[1]*i[1],r[2]=e[2]*i[2],r}function Io(r,e,i){return r[0]=Math.min(e[0],i[0]),r[1]=Math.min(e[1],i[1]),r[2]=Math.min(e[2],i[2]),r}function Jn(r,e,i){return r[0]=Math.max(e[0],i[0]),r[1]=Math.max(e[1],i[1]),r[2]=Math.max(e[2],i[2]),r}function li(r,e,i){return r[0]=e[0]*i,r[1]=e[1]*i,r[2]=e[2]*i,r}function Kr(r,e,i,o){return r[0]=e[0]+i[0]*o,r[1]=e[1]+i[1]*o,r[2]=e[2]+i[2]*o,r}function ks(r,e){var i=e[0]-r[0],o=e[1]-r[1],a=e[2]-r[2];return Math.sqrt(i*i+o*o+a*a)}function yn(r,e){var i=e[0]-r[0],o=e[1]-r[1],a=e[2]-r[2];return i*i+o*o+a*a}function fn(r){var e=r[0],i=r[1],o=r[2];return e*e+i*i+o*o}function Jr(r,e){return r[0]=-e[0],r[1]=-e[1],r[2]=-e[2],r}function Mi(r,e){var i=e[0],o=e[1],a=e[2],c=i*i+o*o+a*a;return c>0&&(c=1/Math.sqrt(c)),r[0]=e[0]*c,r[1]=e[1]*c,r[2]=e[2]*c,r}function qi(r,e){return r[0]*e[0]+r[1]*e[1]+r[2]*e[2]}function tr(r,e,i){var o=e[0],a=e[1],c=e[2],h=i[0],f=i[1],_=i[2];return r[0]=a*_-c*f,r[1]=c*h-o*_,r[2]=o*f-a*h,r}function fo(r,e,i,o){var a=e[0],c=e[1],h=e[2];return r[0]=a+o*(i[0]-a),r[1]=c+o*(i[1]-c),r[2]=h+o*(i[2]-h),r}function ir(r,e,i){var o=e[0],a=e[1],c=e[2],h=i[3]*o+i[7]*a+i[11]*c+i[15];return r[0]=(i[0]*o+i[4]*a+i[8]*c+i[12])/(h=h||1),r[1]=(i[1]*o+i[5]*a+i[9]*c+i[13])/h,r[2]=(i[2]*o+i[6]*a+i[10]*c+i[14])/h,r}function Xo(r,e,i){var o=i[0],a=i[1],c=i[2],h=i[3],f=e[0],_=e[1],y=e[2],v=a*y-c*_,b=c*f-o*y,T=o*_-a*f;return r[0]=f+h*(v+=v)+a*(T+=T)-c*(b+=b),r[1]=_+h*b+c*v-o*T,r[2]=y+h*T+o*b-a*v,r}function Bs(r){return r[0]=0,r[1]=0,r[2]=0,r}function Rn(r,e){return r[0]===e[0]&&r[1]===e[1]&&r[2]===e[2]}var Zi=dn,Ia=gs,Dn=Yr;function ys(){var r=new Ht(4);return Ht!=Float32Array&&(r[0]=0,r[1]=0,r[2]=0,r[3]=0),r}function Yo(r,e,i){return r[0]=e[0]*i,r[1]=e[1]*i,r[2]=e[2]*i,r[3]=e[3]*i,r}function Ko(r,e){var i=e[0],o=e[1],a=e[2],c=e[3],h=i*i+o*o+a*a+c*c;return h>0&&(h=1/Math.sqrt(h)),r[0]=i*h,r[1]=o*h,r[2]=a*h,r[3]=c*h,r}function Ln(r,e,i){var o=e[0],a=e[1],c=e[2],h=e[3];return r[0]=i[0]*o+i[4]*a+i[8]*c+i[12]*h,r[1]=i[1]*o+i[5]*a+i[9]*c+i[13]*h,r[2]=i[2]*o+i[6]*a+i[10]*c+i[14]*h,r[3]=i[3]*o+i[7]*a+i[11]*c+i[15]*h,r}function Qn(){var r=new Ht(4);return Ht!=Float32Array&&(r[0]=0,r[1]=0,r[2]=0),r[3]=1,r}function Ao(r){return r[0]=0,r[1]=0,r[2]=0,r[3]=1,r}function Jo(r,e,i){i*=.5;var o=e[0],a=e[1],c=e[2],h=e[3],f=Math.sin(i),_=Math.cos(i);return r[0]=o*_+h*f,r[1]=a*_+c*f,r[2]=c*_-a*f,r[3]=h*_-o*f,r}function eo(r,e,i){i*=.5;var o=e[0],a=e[1],c=e[2],h=e[3],f=Math.sin(i),_=Math.cos(i);return r[0]=o*_-c*f,r[1]=a*_+h*f,r[2]=c*_+o*f,r[3]=h*_-a*f,r}Zt(),ys();var zr,to,Co,Aa=Ko,xs=(zr=Zt(),to=ur(1,0,0),Co=ur(0,1,0),function(r,e,i){var o=qi(e,i);return o<-.999999?(tr(zr,to,e),Dn(zr)<1e-6&&tr(zr,Co,e),Mi(zr,zr),(function(a,c,h){h*=.5;var f=Math.sin(h);a[0]=f*c[0],a[1]=f*c[1],a[2]=f*c[2],a[3]=Math.cos(h)})(r,zr,Math.PI),r):o>.999999?(r[0]=0,r[1]=0,r[2]=0,r[3]=1,r):(tr(zr,e,i),r[0]=zr[0],r[1]=zr[1],r[2]=zr[2],r[3]=1+o,Aa(r,r))});function rr(){var r=new Ht(2);return Ht!=Float32Array&&(r[0]=0,r[1]=0),r}function io(r,e){var i=new Ht(2);return i[0]=r,i[1]=e,i}function Qo(r,e,i){return r[0]=e,r[1]=i,r}function es(r,e,i){return r[0]=e[0]+i[0],r[1]=e[1]+i[1],r}function vs(r,e,i){return r[0]=e[0]-i[0],r[1]=e[1]-i[1],r}function Ns(r,e,i){return r[0]=e[0]*i,r[1]=e[1]*i,r}function ts(r){var e=r[0],i=r[1];return Math.sqrt(e*e+i*i)}function bs(r,e){var i=e[0],o=e[1],a=i*i+o*o;return a>0&&(a=1/Math.sqrt(a)),r[0]=e[0]*a,r[1]=e[1]*a,r}function Mo(r,e){return r[0]*e[0]+r[1]*e[1]}Qn(),Qn(),St();var Po=vs;function Ca(r,e,i,o){const a=3*r,c=3*(i-r)-a,h=1-a-c,f=3*e,_=3*(o-e)-f,y=1-f-_;return function(v,b=1e-6){if(v<=0)return 0;if(v>=1)return 1;let T=v;for(let P=0;P<8;P++){const R=((h*T+c)*T+a)*T-v;if(Math.abs(R)<b)return((y*T+_)*T+f)*T;const z=(3*h*T+2*c)*T+a;if(Math.abs(z)<1e-6)break;T-=R/z}let E=0,C=1;T=v;for(let P=0;P<20;P++){const R=((h*T+c)*T+a)*T;if(Math.abs(R-v)<b)break;v>R?E=T:C=T,T=.5*(E+C)}return((y*T+_)*T+f)*T}}function Ue(r,e){this.x=r,this.y=e}function ro(r,e){if(Array.isArray(r)){if(!Array.isArray(e)||r.length!==e.length)return!1;for(let i=0;i<r.length;i++)if(!ro(r[i],e[i]))return!1;return!0}if(typeof r=="object"&&r!==null&&e!==null){if(typeof e!="object")return!1;const i=r,o=e;if(Object.keys(i).length!==Object.keys(o).length)return!1;for(const a in i)if(!ro(i[a],o[a]))return!1;return!0}return r===e}function Ma(r,e,i=0,o=r.length-1,a=Vc){for(;o>i;){if(o-i>600){const _=o-i+1,y=e-i+1,v=Math.log(_),b=.5*Math.exp(2*v/3),T=.5*Math.sqrt(v*b*(_-b)/_)*(y-_/2<0?-1:1);Ma(r,e,Math.max(i,Math.floor(e-y*b/_+T)),Math.min(o,Math.floor(e+(_-y)*b/_+T)),a)}const c=r[e];let h=i,f=o;for(zn(r,i,e),a(r[o],c)>0&&zn(r,i,o);h<f;){for(zn(r,h,f),h++,f--;a(r[h],c)<0;)h++;for(;a(r[f],c)>0;)f--}a(r[i],c)===0?zn(r,i,f):(f++,zn(r,f,o)),f<=e&&(i=f+1),e<=f&&(o=f-1)}}function zn(r,e,i){const o=r[e];r[e]=r[i],r[i]=o}function Vc(r,e){return r<e?-1:r>e?1:0}function sa(r){let e=0;for(let i,o,a=0,c=r.length,h=c-1;a<c;h=a++)i=r[a],o=r[h],e+=(o.x-i.x)*(i.y+o.y);return e}function Vs(r,e){return e.area-r.area}function Ro(r,e){const i=r.length;if(i<=1)return[r];const o=[];let a,c;for(let h=0;h<i;h++){const f=sa(r[h]);f!==0&&(r[h].area=Math.abs(f),c===void 0&&(c=f<0),c===f<0?(a&&o.push(a),a=[r[h]]):a.push(r[h]))}if(a&&o.push(a),e>1)for(let h=0;h<o.length;h++){const f=o[h];f.length<=e||(Ma(f,e,1,f.length-1,Vs),o[h]=f.slice(0,e))}return o}function xn(r,e){r[0]=Math.min(r[0],e[0]),r[1]=Math.min(r[1],e[1]),r[2]=Math.max(r[2],e[0]),r[3]=Math.max(r[3],e[1])}function is(r,e){return!(r[0]<=e[0]||r[2]>=e[2]||r[1]<=e[1]||r[3]>=e[3])}function sl(r,e,i){const o=r[0]-e[0],a=r[1]-e[1],c=r[0]-i[0],h=r[1]-i[1];return o*h-c*a===0&&o*c<=0&&a*h<=0}function aa(r,e,i){return e[1]>r[1]!=i[1]>r[1]&&r[0]<(i[0]-e[0])*(r[1]-e[1])/(i[1]-e[1])+e[0]}function Qr(r,e,i=!1){let o=!1;for(let a=0,c=e.length;a<c;a++){const h=e[a];for(let f=0,_=h.length,y=_-1;f<_;y=f++){const v=h[y],b=h[f];if(sl(r,v,b))return i;aa(r,v,b)&&(o=!o)}}return o}function Pa(r,e,i,o){const a=o[0]-i[0],c=o[1]-i[1],h=(r[0]-i[0])*c-a*(r[1]-i[1]),f=(e[0]-i[0])*c-a*(e[1]-i[1]);return h>0&&f<0||h<0&&f>0}function ws(r,e,i,o){return(a=[o[0]-i[0],o[1]-i[1]])[0]*(c=[e[0]-r[0],e[1]-r[1]])[1]-a[1]*c[0]!==0&&!(!Pa(r,e,i,o)||!Pa(i,o,r,e));var a,c}function Us(r){const e=new Ue(Number.POSITIVE_INFINITY,Number.POSITIVE_INFINITY),i=new Ue(Number.NEGATIVE_INFINITY,Number.NEGATIVE_INFINITY);for(const o of r[0])e.x>o.x&&(e.x=o.x),e.y>o.y&&(e.y=o.y),i.x<o.x&&(i.x=o.x),i.y<o.y&&(i.y=o.y);return{min:e,max:i}}rr(),Ue.prototype={clone(){return new Ue(this.x,this.y)},add(r){return this.clone()._add(r)},sub(r){return this.clone()._sub(r)},multByPoint(r){return this.clone()._multByPoint(r)},divByPoint(r){return this.clone()._divByPoint(r)},mult(r){return this.clone()._mult(r)},div(r){return this.clone()._div(r)},rotate(r){return this.clone()._rotate(r)},rotateAround(r,e){return this.clone()._rotateAround(r,e)},matMult(r){return this.clone()._matMult(r)},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(r){return this.x===r.x&&this.y===r.y},dist(r){return Math.sqrt(this.distSqr(r))},distSqr(r){const e=r.x-this.x,i=r.y-this.y;return e*e+i*i},angle(){return Math.atan2(this.y,this.x)},angleTo(r){return Math.atan2(this.y-r.y,this.x-r.x)},angleWith(r){return this.angleWithSep(r.x,r.y)},angleWithSep(r,e){return Math.atan2(this.x*e-this.y*r,this.x*r+this.y*e)},_matMult(r){const e=r[2]*this.x+r[3]*this.y;return this.x=r[0]*this.x+r[1]*this.y,this.y=e,this},_add(r){return this.x+=r.x,this.y+=r.y,this},_sub(r){return this.x-=r.x,this.y-=r.y,this},_mult(r){return this.x*=r,this.y*=r,this},_div(r){return this.x/=r,this.y/=r,this},_multByPoint(r){return this.x*=r.x,this.y*=r.y,this},_divByPoint(r){return this.x/=r.x,this.y/=r.y,this},_unit(){return this._div(this.mag()),this},_perp(){const r=this.y;return this.y=this.x,this.x=-r,this},_rotate(r){const e=Math.cos(r),i=Math.sin(r),o=i*this.x+e*this.y;return this.x=e*this.x-i*this.y,this.y=o,this},_rotateAround(r,e){const i=Math.cos(r),o=Math.sin(r),a=e.y+o*(this.x-e.x)+i*(this.y-e.y);return this.x=e.x+i*(this.x-e.x)-o*(this.y-e.y),this.y=a,this},_round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this},constructor:Ue},Ue.convert=function(r){if(r instanceof Ue)return r;if(Array.isArray(r))return new Ue(+r[0],+r[1]);if(r.x!==void 0&&r.y!==void 0)return new Ue(+r.x,+r.y);throw new Error("Expected [x, y] or {x, y} point format")};const al=Math.PI/180,js=180/Math.PI,Zl=/^[0-9a-f]{8}-[0-9a-f]{4}-[4][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i;function Qt(r){return r*al}function en(r){return r*js}const pe=[[0,0],[1,0],[1,1],[0,1]];function O(r){if(r<=0)return 0;if(r>=1)return 1;const e=r*r,i=e*r;return 4*(r<.5?i:3*(r-e)+i-.75)}const j=Ca(.25,.1,.25,1);function Y(r,e,i){return Math.min(i,Math.max(e,r))}function ce(r,e,i){return(i=Y((i-r)/(e-r),0,1))*i*(3-2*i)}function he(r,e,i){const o=i-e,a=((r-e)%o+o)%o+e;return a===e?i:a}function ue(r,e,i){if(!r.length)return i(null,[]);let o=r.length;const a=new Array(r.length);let c=null;r.forEach((h,f)=>{e(h,(_,y)=>{_&&(c=_),a[f]=y,--o===0&&i(c,a)})})}function ne(r,e){const i={};for(let o=0;o<e.length;o++){const a=e[o];a in r&&(i[a]=r[a])}return i}let J=1;function H(r){return r<=1?1:Math.pow(2,Math.ceil(Math.log2(r)))}function ve(r,e){r.forEach(i=>{e[i]&&(e[i]=e[i].bind(e))})}function Le(r,e,i){const o={};for(const a in r)o[a]=e.call(this,r[a],a,r);return o}function Ee(r,e,i){const o={};for(const a in r)e.call(this,r[a],a,r)&&(o[a]=r[a]);return o}function it(r){return Array.isArray(r)?r.map(it):typeof r=="object"&&r?Le(r,it):r}function et(r,e){for(let i=0;i<r.length;i++)if(e.includes(r[i]))return!0;return!1}const Xt={};function ht(r){Xt[r]||(typeof console<"u"&&console.warn(r),Xt[r]=!0)}function Tt(r,e,i){return(i.y-r.y)*(e.x-r.x)>(e.y-r.y)*(i.x-r.x)}function Yt([r,e,i]){const o=Qt(e+90),a=Qt(i);return{x:r*Math.cos(o)*Math.sin(a),y:r*Math.sin(o)*Math.sin(a),z:r*Math.cos(a),azimuthal:e,polar:i}}function yi(r){return(typeof self<"u"||r!==void 0)&&typeof WorkerGlobalScope<"u"&&(r!==void 0?r:self)instanceof WorkerGlobalScope}function nr(r){const e={};if(r.replace(/(?:^|(?:\s*\,\s*))([^\x00-\x20\(\)<>@\,;\:\\"\/\[\]\?\=\{\}\x7F]+)(?:\=(?:([^\x00-\x20\(\)<>@\,;\:\\"\/\[\]\?\=\{\}\x7F]+)|(?:\"((?:[^"\\]|\\.)*)\")))?/g,(i,o,a,c)=>{const h=a||c;return e[o]=!h||h.toLowerCase(),""}),e["max-age"]){const i=parseInt(e["max-age"],10);isNaN(i)?delete e["max-age"]:e["max-age"]=i}return e}function dr(r,e){return[r[4*e],r[4*e+1],r[4*e+2],r[4*e+3]]}function jr(r){return r>0?1/(1.001-r):1+r}function fr(r){return r>0?1-1/(1.001-r):-r}function Gr(r,e,i){return(r-e.min)*(i.max-i.min)/(e.max-e.min)+i.min}let Vn,rs,Ki,Ji,or,Gi;function xr(){return Vn==null&&(Vn=self.OffscreenCanvas&&!!new OffscreenCanvas(1,1).getContext("2d")&&typeof self.createImageBitmap=="function"),Vn}const _r={requestIdleCallback:r=>{if(typeof requestIdleCallback<"u")return requestIdleCallback(r);setTimeout(()=>r({didTimeout:!1,timeRemaining:()=>50}),0)},now:()=>Ji!==void 0?Ji:performance.now(),setNow(r){Ji=r},restoreNow(){Ji=void 0},frame(r){const e=requestAnimationFrame(r);return{cancel:()=>cancelAnimationFrame(e)}},getImageData(r,e=0){const{width:i,height:o}=r;or||(or=document.createElement("canvas"));const a=or.getContext("2d",{willReadFrequently:!0});if(!a)throw new Error("failed to create canvas 2d context");return(i>or.width||o>or.height)&&(or.width=i,or.height=o),a.clearRect(-e,-e,i+2*e,o+2*e),a.drawImage(r,0,0,i,o),a.getImageData(-e,-e,i+2*e,o+2*e)},resolveURL:r=>(rs||(rs=document.createElement("a")),rs.href=r,rs.href),get devicePixelRatio(){return window.devicePixelRatio},get prefersReducedMotion(){return!!window.matchMedia&&(Ki==null&&(Ki=window.matchMedia("(prefers-reduced-motion: reduce)")),Ki.matches)},hasCanvasFingerprintNoise(){if(Gi!==void 0)return Gi;if(!xr())return Gi=!1,!1;const r=new OffscreenCanvas(85,1),e=r.getContext("2d",{willReadFrequently:!0});let i=0;for(let a=0;a<r.width;++a)e.fillStyle=`rgba(${i++},${i++},${i++}, 255)`,e.fillRect(a,0,1,1);const o=e.getImageData(0,0,r.width,r.height);i=0;for(let a=0;a<o.data.length;++a)if(a%4!=3&&i++!==o.data[a])return Gi=!0,!0;return Gi=!1,!1}};let pn;const bi={API_URL:"https://api.mapbox.com",API_URL_REGEX:/^((https?:)?\/\/)?([^\/]+\.)?mapbox\.c(n|om)(\/|\?|$)/i,API_TILEJSON_REGEX:/^((https?:)?\/\/)?([^\/]+\.)?mapbox\.c(n|om)(\/v[0-9]*\/.*\.json.*$)/i,API_SPRITE_REGEX:/^((https?:)?\/\/)?([^\/]+\.)?mapbox\.c(n|om)(\/styles\/v[0-9]*\/)(.*\/sprite.*\..*$)/i,API_FONTS_REGEX:/^((https?:)?\/\/)?([^\/]+\.)?mapbox\.c(n|om)(\/fonts\/v[0-9]*\/)(.*\.pbf.*$)/i,API_STYLE_REGEX:/^((https?:)?\/\/)?([^\/]+\.)?mapbox\.c(n|om)(\/styles\/v[0-9]*\/)(.*$)/i,API_CDN_URL_REGEX:/^((https?:)?\/\/)?api\.mapbox\.c(n|om)(\/mapbox-gl-js\/)(.*$)/i,get EVENTS_URL(){if(!bi.API_URL)return null;
1try{const r=new URL(bi.API_URL);return r.hostname==="api.mapbox.cn"?"https://events.mapbox.cn/events/v2":r.hostname==="api.mapbox.com"?"https://events.mapbox.com/events/v2":null}catch{return null}},SESSION_PATH:"/map-sessions/v1",FEEDBACK_URL:"https://apps.mapbox.com/feedback",TILE_URL_VERSION:"v4",RASTER_URL_PREFIX:"raster/v1",RASTERARRAYS_URL_PREFIX:"rasterarrays/v1",REQUIRE_ACCESS_TOKEN:!0,ACCESS_TOKEN:null,DEFAULT_STYLE:"mapbox://styles/mapbox/standard",MAX_PARALLEL_IMAGE_REQUESTS:16,DRACO_URL:"/mapbox-gl-js/draco_decoder_gltf_v1.5.6.wasm",MESHOPT_URL:"/mapbox-gl-js/meshopt_base_v0.20.wasm",MESHOPT_SIMD_URL:"/mapbox-gl-js/meshopt_simd_v0.20.wasm",BUILDING_GEN_URL:"/mapbox-gl-js/building-gen/building_gen_v1.2.4.wasm",GLYPHS_URL:"mapbox://fonts/mapbox/{fontstack}/{range}.pbf",TILES3D_URL_PREFIX:"3dtiles/v1",TILE_PROVIDER_URLS:Object.assign(Object.create(null),{pmtiles:"/mapbox-gl-js/plugins/mapbox-gl-pmtiles-provider/v0.0.2/mapbox-gl-pmtiles-provider.js"})};function Do(){return new URL(bi.DRACO_URL,bi.API_URL).href}function Pi(){if(typeof WebAssembly!="object")throw new Error("WebAssembly not supported, cannot instantiate meshoptimizer");return new URL((function(){if(pn===void 0){if(typeof WebAssembly!="object")return!1;const r=new Uint8Array([0,97,115,109,1,0,0,0,1,4,1,96,0,0,3,3,2,0,0,5,3,1,0,1,12,1,0,10,22,2,12,0,65,0,65,0,65,0,252,10,0,0,11,7,0,65,0,253,15,26,11]);pn=WebAssembly.validate(r)}return pn})()?bi.MESHOPT_SIMD_URL:bi.MESHOPT_URL,bi.API_URL).href}function Fr(){return new URL(bi.BUILDING_GEN_URL,bi.API_URL).href}const Ts={supported:!1,testSupport:function(r){!ll&&Or&&(Uc?em(r):tn=r)}};let tn,Or,ll=!1,Uc=!1;const Qp=typeof self<"u"?self:{};function em(r){const e=r.createTexture();r.bindTexture(r.TEXTURE_2D,e);try{if(r.texImage2D(r.TEXTURE_2D,0,r.RGBA,r.RGBA,r.UNSIGNED_BYTE,Or),r.isContextLost())return;Ts.supported=!0}
1catch{}r.deleteTexture(e),ll=!0}function tm(r,e){const i=r.indexOf("?");if(i<0)return`${r}?${new URLSearchParams(e).toString()}`;const o=new URLSearchParams(r.slice(i));for(const a in e)o.set(a,e[a]);return`${r.slice(0,i)}?${o.toString()}`}function Od(r,e={persistentParams:[]}){const i=r.indexOf("?");if(i<0)return r;const o=new URLSearchParams,a=new URLSearchParams(r.slice(i));for(const h of e.persistentParams){const f=a.get(h);f&&o.set(h,f)}const c=o.toString();return`${r.slice(0,i)}${c.length>0?`?${c}`:""}`}Qp.document&&(Or=Qp.document.createElement("img"),Or.onload=function(){tn&&em(tn),tn=null,Uc=!0},Or.onerror=function(){ll=!0,tn=null},Or.src="data:image/webp;base64,UklGRh4AAABXRUJQVlA4TBEAAAAvAQAAAAfQ//73v/+BiOh/AAA=");const im="mapbox-tiles";let rm=500,jc=50;const nm=["language","worldview","jobid"];let la;function om(){try{return caches}catch{}}function Un(){const r=om();r&&la==null&&(la=r.open(im))}let cl=1/0;function Wl(r){return bi.API_URL_REGEX.test(r)}function kd(r){return bi.API_SPRITE_REGEX.test(r)}const ul={Unknown:"Unknown",Style:"Style",Source:"Source",Tile:"Tile",Glyphs:"Glyphs",SpriteImage:"SpriteImage",SpriteJSON:"SpriteJSON",Iconset:"Iconset",Image:"Image",Model:"Model"};Object.freeze(ul);class Gc extends Error{constructor(e,i,o){super(),this.url=o,this.statusText=e,this.status=i}get message(){return this.status===401&&Wl(this.url)?`${this.statusText}: you may have provided an invalid Mapbox access token. See https://docs.mapbox.com/api/guides/#access-tokens-and-token-scopes`:this.statusText}toString(){return`${this.name}: ${this.message} (${this.status}): ${this.url}`}}function sm(r){return typeof r=="object"&&r!==null&&"status"in r&&r.status===404}const Xl=yi()?()=>self.worker.referrer:()=>(location.protocol==="blob:"?parent:self).location.href,hl=/^\w+:/,Xu=/[\r\n]+/;async function Bd(r,e){let i;return i=r.type==="arrayBuffer"?await e.arrayBuffer():r.type==="json"?await e.json():await e.text(),{data:i,headers:e.headers}}async function $c(r,e){return e&&e.throwIfAborted(),(i=r.url).startsWith("file:")||Xl().startsWith("file:")&&!hl.test(i)?(async function(o,a){return new Promise((c,h)=>{const f=new XMLHttpRequest,_=()=>{a.removeEventListener("abort",_),f.abort(),h(a.reason)};a&&a.addEventListener("abort",_),f.open(o.method||"GET",o.url,!0),o.type==="arrayBuffer"&&(f.responseType="arraybuffer");for(const y in o.headers)f.setRequestHeader(y,o.headers[y]);o.type==="json"&&(f.responseType="text",f.setRequestHeader("Accept","application/json")),f.withCredentials=o.credentials==="include",f.onerror=()=>{a&&a.removeEventListener("abort",_),h(new Error(f.statusText))},f.onload=()=>{if(a&&a.removeEventListener("abort",_),(f.status>=200&&f.status<300||f.status===0)&&f.response!==null){let y=f.response;if(o.type==="json")try{y=JSON.parse(f.response)}catch(b){return void h(b)}const v=new Headers;f.getAllResponseHeaders().trim().split(Xu).forEach(b=>{const T=b.split(": "),E=T.shift(),C=T.join(": ");E&&v.set(E,C)}),c({data:y,headers:v})}else h(new Gc(f.statusText,f.status,o.url))},f.send(o.body)})})(r,e):(async function(o,a){const c=new Request(o.url,{method:o.method||"GET",body:o.body,credentials:o.credentials,headers:o.headers,referrer:Xl(),referrerPolicy:o.referrerPolicy,signal:a}),h=(f=c.url).indexOf("sku=")>0&&Wl(f);var f;if(o.type==="json"&&c.headers.set("Accept","application/json"),h){let T=null;try{T=await(async function(E){if(Un(),la==null)return null;const C=await la;
vendor: 22,500 bytes, line 1
1let P=Od(E.url,{persistentParams:nm});const R=E.headers.get("Range");R&&(P=tm(P,{range:R}));const z=await C.match(P);if(!z)return null;const V=(function(N){if(!N)return!1;const U=new Date(N.headers.get("expires")||0),q=nr(N.headers.get("cache-control")||"");return Number(U)>Date.now()&&!q["no-cache"]})(z);return C.delete(P).catch(N=>ht(N.message)),V&&C.put(P,z.clone()).catch(N=>ht(N.message)),{response:z,fresh:V}})(c)}catch(E){E.message!=="SecurityError"&&ht(E.toString())}if(T&&T.fresh)return a&&a.throwIfAborted(),Bd(o,T.response)}const _=Date.now();let y;try{y=await fetch(c)}catch(T){throw T.name==="AbortError"?T:new Error(`${T.message} ${o.url}`,{cause:T})}if(a&&a.throwIfAborted(),!y.ok)throw new Gc(y.statusText,y.status,o.url);const v=h?y.clone():null,b=await Bd(o,y);return v&&(async function(T,E,C){if(Un(),la==null)return;const P=nr(E.headers.get("cache-control")||"");if(P["no-store"])return;const R={status:E.status,statusText:E.statusText,headers:new Headers(E.headers)};P["max-age"]&&R.headers.set("Expires",new Date(C+1e3*P["max-age"]).toUTCString());const z=R.headers.get("expires");if(!z||new Date(z).getTime()-C<42e4)return;let V=Od(T.url,{persistentParams:nm});if(E.status===206){const q=T.headers.get("Range");if(!q)return;R.status=200,V=tm(V,{range:q})}const N=new Response((U=E.status)!==200&&U!==404&&[101,103,204,205,304].includes(U)?null:E.body,R);var U;if(Un(),la!=null)try{await(await la).put(V,N)}catch(q){ht(q.message)}})(c,v,_),b})(r,e);var i}async function Gs(r,e){return $c(Object.assign(r,{type:"json"}),e)}async function Yl(r,e){return $c(Object.assign(r,{type:"arrayBuffer"}),e)}function am(r){const e=document.createElement("a");return e.href=r,e.protocol===location.protocol&&e.host===location.host}let Kl,Yu;function Ku(r,e=0){const a=r.length,c=a-(3&a);let h,f=0|e,_=0;for(;_<c;)h=255&r.charCodeAt(_)|(255&r.charCodeAt(_+1))<<8|(255&r.charCodeAt(_+2))<<16|(255&r.charCodeAt(_+3))<<24,_+=4,h=Math.imul(h,3432918353),h=h<<15|h>>>17,h=Math.imul(h,461845907),f^=h,f=f<<13|f>>>19,f=Math.imul(f,5)+3864292196|0;h=0;const y=3&a;return y>0&&(y>=3&&(h^=(255&r.charCodeAt(_+2))<<16),y>=2&&(h^=(255&r.charCodeAt(_+1))<<8),h^=255&r.charCodeAt(_),h=Math.imul(h,3432918353),h=h<<15|h>>>17,h=Math.imul(h,461845907),f^=h),f^=a,f^=f>>>16,f=Math.imul(f,2246822507),f^=f>>>13,f=Math.imul(f,3266489909),f^=f>>>16,f>>>0}Kl=[],Yu=0;class Lo{constructor(e,...i){Object.assign(this,i[0]||{}),this.type=e}}class Nd extends Lo{constructor(e,i={}){super("error",{error:e,...i})}}function Ju(r,e,i){i[r]&&i[r].includes(e)||(i[r]=i[r]||[],i[r].push(e))}function ca(r,e,i){if(i&&i[r]){const o=i[r].indexOf(e);o!==-1&&i[r].splice(o,1)}}class dl{on(e,i){return this._listeners=this._listeners||{},Ju(e,i,this._listeners),this}off(e,i){return ca(e,i,this._listeners),ca(e,i,this._oneTimeListeners),this}once(e,i){return i?(this._oneTimeListeners=this._oneTimeListeners||{},Ju(e,i,this._oneTimeListeners),this):new Promise(o=>{this.once(e,o)})}fire(e,i){const o=typeof e=="string"?new Lo(e,i):e,a=o.type;if(this.listens(a)){o.target=this;const c=this._listeners&&this._listeners[a]?this._listeners[a].slice():[];for(const _ of c)_.call(this,o);const h=this._oneTimeListeners&&this._oneTimeListeners[a]?this._oneTimeListeners[a].slice():[];for(const _ of h)ca(a,_,this._oneTimeListeners),_.call(this,o);const f=this._eventedParent;if(f){const _=typeof this._eventedParentData=="function"?this._eventedParentData():this._eventedParentData;Object.assign(o,_),f.fire(o)}}else o instanceof Nd&&console.error(o.error);return this}listens(e){return!!(this._listeners&&this._listeners[e]&&this._listeners[e].length>0||this._oneTimeListeners&&this._oneTimeListeners[e]&&this._oneTimeListeners[e].length>0||this._eventedParent&&this._eventedParent.listens(e))}setEventedParent(e,i){return this._eventedParent=e,this._eventedParentData=i,this}}class po{constructor(e){typeof e=="string"?this.name=e:(this.name=e.name,this.iconsetId=e.iconsetId)}static from(e){return new po(e)}static toString(e){return e.iconsetId?`${e.name}�${e.iconsetId}`:e.name}static parse(e){const[i,o]=e.split("�");return new po({name:i,iconsetId:o})}static isEqual(e,i){return e.name===i.name&&e.iconsetId===i.iconsetId}toString(){return po.toString(this)}serialize(){return{name:this.name,iconsetId:this.iconsetId}}}var Vd,Ud={},lm=(function(){if(Vd)return Ud;Vd=1;var r={transparent:[0,0,0,0],aliceblue:[240,248,255,1],antiquewhite:[250,235,215,1],aqua:[0,255,255,1],aquamarine:[127,255,212,1],azure:[240,255,255,1],beige:[245,245,220,1],bisque:[255,228,196,1],black:[0,0,0,1],blanchedalmond:[255,235,205,1],blue:[0,0,255,1],blueviolet:[138,43,226,1],brown:[165,42,42,1],burlywood:[222,184,135,1],cadetblue:[95,158,160,1],chartreuse:[127,255,0,1],chocolate:[210,105,30,1],coral:[255,127,80,1],cornflowerblue:[100,149,237,1],cornsilk:[255,248,220,1],crimson:[220,20,60,1],cyan:[0,255,255,1],darkblue:[0,0,139,1],darkcyan:[0,139,139,1],darkgoldenrod:[184,134,11,1],darkgray:[169,169,169,1],darkgreen:[0,100,0,1],darkgrey:[169,169,169,1],darkkhaki:[189,183,107,1],darkmagenta:[139,0,139,1],darkolivegreen:[85,107,47,1],darkorange:[255,140,0,1],darkorchid:[153,50,204,1],darkred:[139,0,0,1],darksalmon:[233,150,122,1],darkseagreen:[143,188,143,1],darkslateblue:[72,61,139,1],darkslategray:[47,79,79,1],darkslategrey:[47,79,79,1],darkturquoise:[0,206,209,1],darkviolet:[148,0,211,1],deeppink:[255,20,147,1],deepskyblue:[0,191,255,1],dimgray:[105,105,105,1],dimgrey:[105,105,105,1],dodgerblue:[30,144,255,1],firebrick:[178,34,34,1],floralwhite:[255,250,240,1],forestgreen:[34,139,34,1],fuchsia:[255,0,255,1],gainsboro:[220,220,220,1],ghostwhite:[248,248,255,1],gold:[255,215,0,1],goldenrod:[218,165,32,1],gray:[128,128,128,1],green:[0,128,0,1],greenyellow:[173,255,47,1],grey:[128,128,128,1],honeydew:[240,255,240,1],hotpink:[255,105,180,1],indianred:[205,92,92,1],indigo:[75,0,130,1],ivory:[255,255,240,1],khaki:[240,230,140,1],lavender:[230,230,250,1],lavenderblush:[255,240,245,1],lawngreen:[124,252,0,1],lemonchiffon:[255,250,205,1],lightblue:[173,216,230,1],lightcoral:[240,128,128,1],lightcyan:[224,255,255,1],lightgoldenrodyellow:[250,250,210,1],lightgray:[211,211,211,1],lightgreen:[144,238,144,1],lightgrey:[211,211,211,1],lightpink:[255,182,193,1],lightsalmon:[255,160,122,1],lightseagreen:[32,178,170,1],lightskyblue:[135,206,250,1],lightslategray:[119,136,153,1],lightslategrey:[119,136,153,1],lightsteelblue:[176,196,222,1],lightyellow:[255,255,224,1],lime:[0,255,0,1],limegreen:[50,205,50,1],linen:[250,240,230,1],magenta:[255,0,255,1],maroon:[128,0,0,1],mediumaquamarine:[102,205,170,1],mediumblue:[0,0,205,1],mediumorchid:[186,85,211,1],mediumpurple:[147,112,219,1],mediumseagreen:[60,179,113,1],mediumslateblue:[123,104,238,1],mediumspringgreen:[0,250,154,1],mediumturquoise:[72,209,204,1],mediumvioletred:[199,21,133,1],midnightblue:[25,25,112,1],mintcream:[245,255,250,1],mistyrose:[255,228,225,1],moccasin:[255,228,181,1],navajowhite:[255,222,173,1],navy:[0,0,128,1],oldlace:[253,245,230,1],olive:[128,128,0,1],olivedrab:[107,142,35,1],orange:[255,165,0,1],orangered:[255,69,0,1],orchid:[218,112,214,1],palegoldenrod:[238,232,170,1],palegreen:[152,251,152,1],paleturquoise:[175,238,238,1],palevioletred:[219,112,147,1],papayawhip:[255,239,213,1],peachpuff:[255,218,185,1],peru:[205,133,63,1],pink:[255,192,203,1],plum:[221,160,221,1],powderblue:[176,224,230,1],purple:[128,0,128,1],rebeccapurple:[102,51,153,1],red:[255,0,0,1],rosybrown:[188,143,143,1],royalblue:[65,105,225,1],saddlebrown:[139,69,19,1],salmon:[250,128,114,1],sandybrown:[244,164,96,1],seagreen:[46,139,87,1],seashell:[255,245,238,1],sienna:[160,82,45,1],silver:[192,192,192,1],skyblue:[135,206,235,1],slateblue:[106,90,205,1],slategray:[112,128,144,1],slategrey:[112,128,144,1],snow:[255,250,250,1],springgreen:[0,255,127,1],steelblue:[70,130,180,1],tan:[210,180,140,1],teal:[0,128,128,1],thistle:[216,191,216,1],tomato:[255,99,71,1],turquoise:[64,224,208,1],violet:[238,130,238,1],wheat:[245,222,179,1],white:[255,255,255,1],whitesmoke:[245,245,245,1],yellow:[255,255,0,1],yellowgreen:[154,205,50,1]};function e(c){return(c=Math.round(c))<0?0:c>255?255:c}function i(c){return e(c[c.length-1]==="%"?parseFloat(c)/100*255:parseInt(c))}function o(c){return(h=c[c.length-1]==="%"?parseFloat(c)/100:parseFloat(c))<0?0:h>1?1:h;var h}function a(c,h,f){return f<0?f+=1:f>1&&(f-=1),6*f<1?c+(h-c)*f*6:2*f<1?h:3*f<2?c+(h-c)*(2/3-f)*6:c}try{Ud.parseCSSColor=function(c){var h,f=c.replace(/ /g,"").toLowerCase();if(f in r)return r[f].slice();if(f[0]==="#")return f.length===4?(h=parseInt(f.substr(1),16))>=0&&h<=4095?[(3840&h)>>4|(3840&h)>>8,240&h|(240&h)>>4,15&h|(15&h)<<4,1]:null:f.length===7&&(h=parseInt(f.substr(1),16))>=0&&h<=16777215?[(16711680&h)>>16,(65280&h)>>8,255&h,1]:null;var _=f.indexOf("("),y=f.indexOf(")");if(_!==-1&&y+1===f.length){var v=f.substr(0,_),b=f.substr(_+1,y-(_+1)).split(","),T=1;switch(v){case"rgba":if(b.length!==4)return null;T=o(b.pop());case"rgb":return b.length!==3?null:[i(b[0]),i(b[1]),i(b[2]),T];case"hsla":if(b.length!==4)return null;T=o(b.pop());case"hsl":if(b.length!==3)return null;var E=(parseFloat(b[0])%360+360)%360/360,C=o(b[1]),P=o(b[2]),R=P<=.5?P*(C+1):P+C-P*C,z=2*P-R;return[e(255*a(z,R,E+1/3)),e(255*a(z,R,E)),e(255*a(z,R,E-1/3)),T];default:return null}}return null}}catch{}return Ud})();function vt(r,e,i){return r*(1-i)+e*i}const cm=new Map;class ai{constructor(e,i,o,a=1){this.r=e,this.g=i,this.b=o,this.a=a}static parse(e){if(!e)return;if(e instanceof ai)return e;if(typeof e!="string")return;const i=cm.get(e);if(i)return i;const o=lm.parseCSSColor(e);if(!o)return;const a=new ai(o[0]/255,o[1]/255,o[2]/255,o[3]);return cm.set(e,a),a}toString(){const{r:e,g:i,b:o,a}=this;return`rgba(${Math.round(255*e)},${Math.round(255*i)},${Math.round(255*o)},${a})`}toNonPremultipliedRenderColor(e){const{r:i,g:o,b:a,a:c}=this;return new jd(e,i,o,a,c)}toPremultipliedRenderColor(e){const{r:i,g:o,b:a,a:c}=this;return new Gd(e,i*c,o*c,a*c,c)}clone(){return new ai(this.r,this.g,this.b,this.a)}}class um{constructor(e,i,o,a,c,h=!1){if(this.premultiplied=!1,this.premultiplied=h,e){const f=e.image.height,_=f*f;this.premultiplied?(i=c===0?0:i/c*(f-1),o=c===0?0:o/c*(f-1),a=c===0?0:a/c*(f-1)):(i*=f-1,o*=f-1,a*=f-1),i=Math.max(0,Math.min(f-1,i)),o=Math.max(0,Math.min(f-1,o)),a=Math.max(0,Math.min(f-1,a));const y=Math.floor(i),v=Math.floor(o),b=Math.floor(a),T=Math.ceil(i),E=Math.ceil(o),C=Math.ceil(a),P=i-y,R=o-v,z=a-b,V=e.image.data,N=4*(y+v*_+b*f),U=4*(y+v*_+C*f),q=4*(y+E*_+b*f),W=4*(y+E*_+C*f),se=4*(T+v*_+b*f),X=4*(T+v*_+C*f),ie=4*(T+E*_+b*f),re=4*(T+E*_+C*f);this.r=vt(vt(vt(V[N],V[U],z),vt(V[q],V[W],z),R),vt(vt(V[se],V[X],z),vt(V[ie],V[re],z),R),P)/255*(this.premultiplied?c:1),this.g=vt(vt(vt(V[N+1],V[U+1],z),vt(V[q+1],V[W+1],z),R),vt(vt(V[se+1],V[X+1],z),vt(V[ie+1],V[re+1],z),R),P)/255*(this.premultiplied?c:1),this.b=vt(vt(vt(V[N+2],V[U+2],z),vt(V[q+2],V[W+2],z),R),vt(vt(V[se+2],V[X+2],z),vt(V[ie+2],V[re+2],z),R),P)/255*(this.premultiplied?c:1),this.a=c}else this.r=i,this.g=o,this.b=a,this.a=c}toArray(){const{r:e,g:i,b:o,a}=this;return[255*e,255*i,255*o,a]}toHslaArray(){let{r:e,g:i,b:o,a}=this;if(this.premultiplied){if(a===0)return[0,0,0,0];const C=1/a;e*=C,i*=C,o*=C}const c=Math.min(Math.max(e,0),1),h=Math.min(Math.max(i,0),1),f=Math.min(Math.max(o,0),1),_=Math.min(c,h,f),y=Math.max(c,h,f),v=y-_,b=.5*(_+y);if(v===0)return[0,0,100*b,a];const T=b>.5?v/(2-y-_):v/(y+_);let E;switch(y){case c:E=60*((h-f)/v+(h<f?6:0));break;case h:E=60*((f-c)/v+2);break;default:E=60*((c-h)/v+4)}return[E,100*T,100*b,a]}toArray01(){const{r:e,g:i,b:o,a}=this;return[e,i,o,a]}toArray01Scaled(e){const{r:i,g:o,b:a}=this;return[i*e,o*e,a*e]}toArray01Linear(){const{r:e,g:i,b:o,a}=this;return[Math.pow(e,2.2),Math.pow(i,2.2),Math.pow(o,2.2),a]}}class jd extends um{constructor(e,i,o,a,c){super(e,i,o,a,c,!1)}}class Gd extends um{constructor(e,i,o,a,c){super(e,i,o,a,c,!0)}}function _t(r,e,i){return r.map((o,a)=>vt(o,e[a],i))}ai.black=new ai(0,0,0,1),ai.white=new ai(1,1,1,1),ai.transparent=new ai(0,0,0,0),ai.red=new ai(1,0,0,1),ai.blue=new ai(0,0,1,1);var ct=Object.freeze({__proto__:null,array:_t,color:function(r,e,i){return new ai(vt(r.r,e.r,i),vt(r.g,e.g,i),vt(r.b,e.b,i),vt(r.a,e.a,i))},number:vt});class zo extends Error{constructor(e,i){super(i),this.message=i,this.key=e}}class Qu{constructor(e,i=[]){this.parent=e,this.bindings=Object.create(null);for(const[o,a]of i)this.bindings[o]=a}concat(e){return new Qu(this,e)}get(e){if(this.bindings[e])return this.bindings[e];if(this.parent)return this.parent.get(e);throw new Error(`${e} not found in scope.`)}has(e){return!!this.bindings[e]||!!this.parent&&this.parent.has(e)}}const Ra={kind:"null"},ft={kind:"number"},fi={kind:"string"},ci={kind:"boolean"},no={kind:"color"},$s={kind:"object"},pi={kind:"value"},Jl={kind:"collator"},oo={kind:"formatted"},Ql={kind:"resolvedImage"};function Fn(r,e){return{kind:"array",itemType:r,N:e}}function wr(r){if(r.kind==="array"){const e=wr(r.itemType);return typeof r.N=="number"?`array<${e}, ${r.N}>`:r.itemType.kind==="value"?"array":`array<${e}>`}return r.kind}const hm=[Ra,ft,fi,ci,no,oo,$s,Fn(pi),Ql];function ec(r,e){if(e.kind==="error")return null;if(r.kind==="array"){if(e.kind==="array"&&(e.N===0&&e.itemType.kind==="value"||!ec(r.itemType,e.itemType))&&(typeof r.N!="number"||r.N===e.N))return null}else{if(r.kind===e.kind)return null;if(r.kind==="value"){for(const i of hm)if(!ec(i,e))return null}}return`Expected ${wr(r)} but found ${wr(e)} instead.`}function eh(r,e){return e.some(i=>i.kind===r.kind)}function tc(r,e){return e.some(i=>i==="null"?r===null:i==="array"?Array.isArray(r):i==="object"?r&&!Array.isArray(r)&&typeof r=="object":i===typeof r)}function qc(r,e){return r.kind==="array"&&e.kind==="array"?r.N===e.N&&qc(r.itemType,e.itemType):r.kind===e.kind}class th{constructor(e,i,o){this.sensitivity=e?i?"variant":"case":i?"accent":"base",this.locale=o,this.collator=new Intl.Collator(this.locale?this.locale:[],{sensitivity:this.sensitivity,usage:"search"})}compare(e,i){return this.collator.compare(e,i)}resolvedLocale(){return new Intl.Collator(this.locale?this.locale:[]).resolvedOptions().locale}}class fl{constructor(e,i,o,a,c){this.text=e.normalize?e.normalize():e,this.image=i,this.scale=o,this.fontStack=a,this.textColor=c}}class rn{constructor(e){this.sections=e}static fromString(e){return new rn([new fl(e,null,null,null,null)])}isEmpty(){return this.sections.length===0||!this.sections.some(e=>e.text.length!==0||!!e.image&&e.image.hasPrimary())}static factory(e){return e instanceof rn?e:rn.fromString(e)}toString(){return this.sections.length===0?"":this.sections.map(e=>e.text).join("")}serialize(){const e=["format"];for(const i of this.sections){if(i.image){const a=i.image.getPrimary().id.toString();e.push(["image",a]);continue}e.push(i.text);const o={};i.fontStack&&(o["text-font"]=["literal",i.fontStack.split(",")]),i.scale&&(o["font-scale"]=i.scale),i.textColor&&(o["text-color"]=["rgba"].concat(i.textColor.toNonPremultipliedRenderColor(null).toArray())),e.push(o)}return e}}class Fo{constructor(e,i={}){this.id=po.from(e),this.params=i.params,this.sx=i.sx||1,this.sy=i.sy||1}toString(){return JSON.stringify(this)}static parse(e){let i,o,a,c;try{({id:i,params:o,sx:a,sy:c}=JSON.parse(e)||{})}catch{return null}return i?new Fo(i,{params:o,sx:a,sy:c}):null}scaleSelf(e,i=e){return this.sx*=e,this.sy*=i,this}}class nn{constructor(e,i,o,a,c=!1){this.primaryId=po.from(e),this.primaryOptions=i,o&&(this.secondaryId=po.from(o)),this.secondaryOptions=a,this.available=c}toString(){return this.primaryId&&this.secondaryId?`[${this.primaryId.name},${this.secondaryId.name}]`:this.primaryId.name}hasPrimary(){return!!this.primaryId}getPrimary(){return new Fo(this.primaryId,this.primaryOptions)}hasSecondary(){return!!this.secondaryId}getSecondary(){return this.secondaryId?new Fo(this.secondaryId,this.secondaryOptions):null}static from(e){return typeof e=="string"?nn.build({name:e}):e}static build(e,i,o,a){return!e||typeof e=="object"&&!("name"in e)?null:new nn(e,o,i,a)}}function ih(r,e,i,o){return typeof r=="number"&&r>=0&&r<=255&&typeof e=="number"&&e>=0&&e<=255&&typeof i=="number"&&i>=0&&i<=255?o===void 0||typeof o=="number"&&o>=0&&o<=1?null:`Invalid rgba value [${[r,e,i,o].join(", ")}]: 'a' must be between 0 and 1.`:`Invalid rgba value [${(typeof o=="number"?[r,e,i,o]:[r,e,i]).join(", ")}]: 'r', 'g', and 'b' must be between 0 and 255.`}function Oo(r){if(r===null||typeof r=="string"||typeof r=="boolean"||typeof r=="number"||r instanceof ai||r instanceof th||r instanceof rn||r instanceof nn)return!0;if(Array.isArray(r)){for(const e of r)if(!Oo(e))return!1;return!0}if(typeof r=="object"){for(const e in r)if(!Oo(r[e]))return!1;return!0}return!1}function Cr(r){if(r===null)return Ra;if(typeof r=="string")return fi;if(typeof r=="boolean")return ci;if(typeof r=="number")return ft;if(r instanceof ai)return no;if(r instanceof th)return Jl;if(r instanceof rn)return oo;if(r instanceof nn)return Ql;if(Array.isArray(r)){const e=r.length;let i;for(const o of r){const a=Cr(o);if(i){if(i===a)continue;i=pi;break}i=a}return Fn(i||pi,e)}return $s}function mt(r){return r===null?"":typeof r=="string"||typeof r=="number"||typeof r=="boolean"?String(r):r instanceof rn||r instanceof nn||r instanceof ai?r.toString():JSON.stringify(r)}class qs{constructor(e,i){this.type=e,this.value=i}static parse(e,i){if(e.length!==2)return i.error(`'literal' expression requires exactly one argument, but found ${e.length-1} instead.`);if(!Oo(e[1]))return i.error("invalid value");const o=e[1];let a=Cr(o);const c=i.expectedType;return a.kind!=="array"||a.N!==0||!c||c.kind!=="array"||typeof c.N=="number"&&c.N!==0||(a=c),new qs(a,o)}evaluate(){return this.value}eachChild(){}outputDefined(){return!0}serialize(){return this.type.kind==="array"||this.type.kind==="object"?["literal",this.value]:this.value instanceof ai?["rgba"].concat(this.value.toNonPremultipliedRenderColor(null).toArray()):this.value instanceof rn?this.value.serialize():this.value}}class Tr{constructor(e){this.name="ExpressionEvaluationError",this.message=e}toJSON(){return this.message}}const ic={string:fi,number:ft,boolean:ci,object:$s};class On{constructor(e,i){this.type=e,this.args=i}static parse(e,i){if(e.length<2)return i.error("Expected at least one argument.");let o,a=1;const c=e[0];if(c==="array"){let f,_;if(e.length>2){const y=e[1];if(typeof y!="string"||!(y in ic)||y==="object")return i.error('The item type argument of "array" must be one of string, number, boolean',1);f=ic[y],a++}else f=pi;if(e.length>3){if(e[2]!==null&&(typeof e[2]!="number"||e[2]<0||e[2]!==Math.floor(e[2])))return i.error('The length argument to "array" must be a positive integer literal',2);_=e[2],a++}o=Fn(f,_)}else o=ic[c];const h=[];for(;a<e.length;a++){const f=i.parse(e[a],a,pi);if(!f)return null;h.push(f)}return new On(o,h)}evaluate(e){for(let i=0;i<this.args.length;i++){const o=this.args[i].evaluate(e);if(!ec(this.type,Cr(o)))return o;if(i===this.args.length-1)throw new Tr(`The expression ${JSON.stringify(this.args[i].serialize())} evaluated to ${wr(Cr(o))} but was expected to be of type ${wr(this.type)}.`)}return null}eachChild(e){this.args.forEach(e)}outputDefined(){return this.args.every(e=>e.outputDefined())}serialize(){const e=this.type,i=[e.kind];if(e.kind==="array"){const o=e.itemType;if(o.kind==="string"||o.kind==="number"||o.kind==="boolean"){i.push(o.kind);const a=e.N;(typeof a=="number"||this.args.length>1)&&i.push(a)}}return i.concat(this.args.map(o=>o.serialize()))}}class yt{constructor(e){this.type=oo,this.sections=e}static parse(e,i){if(e.length<2)return i.error("Expected at least one argument.");const o=e[1];if(!Array.isArray(o)&&typeof o=="object")return i.error("First argument must be an image or text section.");const a=[];let c=!1;for(let h=1;h<=e.length-1;++h){const f=e[h];if(c&&typeof f=="object"&&!Array.isArray(f)){c=!1;let _=null;if(f["font-scale"]&&(_=i.parseObjectValue(f["font-scale"],h,"font-scale",ft),!_))return null;let y=null;if(f["text-font"]&&(y=i.parseObjectValue(f["text-font"],h,"text-font",Fn(fi)),!y))return null;let v=null;if(f["text-color"]&&(v=i.parseObjectValue(f["text-color"],h,"text-color",no),!v))return null;const b=a.at(-1);b.scale=_,b.font=y,b.textColor=v}else{const _=i.parse(e[h],h,pi);if(!_)return null;const y=_.type.kind;if(y!=="string"&&y!=="value"&&y!=="null"&&y!=="resolvedImage")return i.error("Formatted text type must be 'string', 'value', 'image' or 'null'.");c=!0,a.push({content:_,scale:null,font:null,textColor:null})}}return new yt(a)}evaluate(e){return new rn(this.sections.map(i=>{const o=i.content.evaluate(e);return qc(Cr(o),Ql)?new fl("",o,null,null,null):new fl(mt(o),null,i.scale?i.scale.evaluate(e):null,i.font?i.font.evaluate(e).join(","):null,i.textColor?i.textColor.evaluate(e):null)}))}eachChild(e){for(const i of this.sections)e(i.content),i.scale&&e(i.scale),i.font&&e(i.font),i.textColor&&e(i.textColor)}outputDefined(){return!1}serialize(){const e=["format"];for(const i of this.sections){e.push(i.content.serialize());const o={};i.scale&&(o["font-scale"]=i.scale.serialize()),i.font&&(o["text-font"]=i.font.serialize()),i.textColor&&(o["text-color"]=i.textColor.serialize()),e.push(o)}return e}}class Hc{constructor(e,i,o,a){this._imageWarnHistory={},this.type=Ql,this.namePrimary=e,this.nameSecondary=i,o&&(this.paramsPrimary=o.params,this.iconsetIdPrimary=o.iconset?o.iconset.id:void 0),a&&(this.paramsSecondary=a.params,this.iconsetIdSecondary=a.iconset?a.iconset.id:void 0)}static parse(e,i){if(e.length<2)return i.error("Expected two or more arguments.");let o=1;const a=[];function c(){if(o<e.length){const f=i.parse(e[o],o++,fi);return f?(a.push({image:f,options:{}}),!0):(i.error(a.length?"Secondary image variant is not a string.":"No image name provided."),!1)}return!0}function h(){if(o<e.length){const _=e[o];if((f=_)===null||typeof f!="object"||Array.isArray(f))return!0;const y=_.params,v=_.iconset,b=i.concat(o);if(!y&&!v)return o++,!0;if(y){if(typeof y!="object"||y.constructor!==Object)return b.error('Image options "params" should be an object'),!1;const T={},E=b.concat(void 0,"params");for(const C in y){if(!C)return E.error("Image parameter name should be non-empty"),!1;const P=E.concat(void 0,C).parse(y[C],void 0,no,void 0,{typeAnnotation:"coerce"});if(!P)return!1;T[C]=P}a.at(-1).options.params=T}if(v){if(typeof v!="object"||v.constructor!==Object)return b.error('Image options "iconset" should be an object'),!1;if(!v.id)return b.error('Image options "iconset" should have an "i
1d" property'),!1;a.at(-1).options.iconset=v}return o++,!0}var f;return!0}for(let f=0;f<2;f++)if(!c()||!h())return;return new Hc(a[0].image,a[1]?a[1].image:void 0,a[0].options,a[1]?a[1].options:void 0)}evaluateParams(e,i){const o={};if(i){for(const a in i)if(i[a])try{o[a]=i[a].evaluate(e)}catch{continue}if(Object.keys(o).length!==0)return{params:o}}}evaluate(e){const i={name:this.namePrimary.evaluate(e),iconsetId:this.iconsetIdPrimary},o=this.nameSecondary?{name:this.nameSecondary.evaluate(e),iconsetId:this.iconsetIdSecondary}:void 0,a=nn.build(i,o,this.paramsPrimary?this.evaluateParams(e,this.paramsPrimary):void 0,this.paramsSecondary?this.evaluateParams(e,this.paramsSecondary):void 0);if(a&&e.availableImages){const c=a.getPrimary().id;if(a.available=e.availableImages.some(h=>po.isEqual(h,c)),a.available){const h=a.getSecondary()?a.getSecondary().id:null;h&&(a.available=e.availableImages.some(f=>po.isEqual(f,h)))}}return a}eachChild(e){if(e(this.namePrimary),this.paramsPrimary)for(const i in this.paramsPrimary)this.paramsPrimary[i]&&e(this.paramsPrimary[i]);if(this.nameSecondary&&(e(this.nameSecondary),this.paramsSecondary))for(const i in this.paramsSecondary)this.paramsSecondary[i]&&e(this.paramsSecondary[i])}outputDefined(){return!1}serializeOptions(e,i){const o={};if(i&&(o.iconset={id:i}),e){o.params={};for(const a in e)e[a]&&(o.params[a]=e[a].serialize())}return Object.keys(o).length>0?o:void 0}serialize(){const e=["image",this.namePrimary.serialize()];if(this.paramsPrimary||this.iconsetIdPrimary){const i=this.serializeOptions(this.paramsPrimary,this.iconsetIdPrimary);i&&e.push(i)}if(this.nameSecondary&&(e.push(this.nameSecondary.serialize()),this.paramsSecondary||this.iconsetIdSecondary)){const i=this.serializeOptions(this.paramsSecondary,this.iconsetIdSecondary);i&&e.push(i)}return e}}function rc(r){return $d(r)?"string":Zc(r)?"number":fm(r)?"boolean":Array.isArray(r)?"array":r===null?"null":dm(r)?"object":typeof r}function dm(r){return r!=null&&!Array.isArray(r)&&typeof r!="function"&&!(r instanceof String||r instanceof Number||r instanceof Boolean)&&typeof r=="object"}function $d(r){return typeof r=="string"||r instanceof String}function Zc(r){return typeof r=="number"||r instanceof Number}function fm(r){return typeof r=="boolean"||r instanceof Boolean}const qg={"to-boolean":ci,"to-color":no,"to-number":ft,"to-string":fi};class Hs{constructor(e,i){this.type=e,this.args=i}static parse(e,i){if(e.length<2)return i.error("Expected at least one argument.");const o=e[0],a=[];let c=Ra;if(o==="to-array"){if(!Array.isArray(e[1]))return null;const h=e[1].length;if(i.expectedType){if(i.expectedType.kind!=="array")return i.error(`Expected ${i.expectedType.kind} but found array.`);c=Fn(i.expectedType.itemType,h)}else{if(!(h>0&&Oo(e[1][0])))return null;c=Fn(Cr(e[1][0]),h)}for(let f=0;f<h;f++){const _=e[1][f];let y;if(Array.isArray(_))y=i.parse(_,void 0,c.itemType);else{const v=rc(_);if(v!==c.itemType.kind)return i.error(`Expected ${c.itemType.kind} but found ${v}.`);y=i.registry.literal.parse(["literal",_===void 0?null:_],i)}if(!y)return null;a.push(y)}}else{if((o==="to-boolean"||o==="to-string")&&e.length!==2)return i.error("Expected one argument.");c=qg[o];for(let h=1;h<e.length;h++){const f=i.parse(e[h],h,pi);if(!f)return null;a.push(f)}}return new Hs(c,a)}evaluate(e){if(this.type.kind==="boolean")return!!this.args[0].evaluate(e);if(this.type.kind==="color"){let i,o;for(const a of this.args){if(i=a.evaluate(e),o=null,i instanceof ai)return i;if(typeof i=="string"){const c=e.parseColor(i);if(c)return c}else if(Array.isArray(i)&&(o=i.length<3||i.length>4?`Invalid rbga value ${JSON.stringify(i)}: expected an array containing either three or four numeric values.`:ih(i[0],i[1],i[2],i[3]),!o))return new ai(i[0]/255,i[1]/255,i[2]/255,i[3])}throw new Tr(o||`Could not parse color from value '${typeof i=="string"?i:String(JSON.stringify(i))}'`)}if(this.type.kind==="number"){let i=null;for(const o of this.args){if(i=o.evaluate(e),i===null)return 0;const a=Number(i);if(!isNaN(a))return a}throw new Tr(`Could not convert ${JSON.stringify(i)} to number.`)}return this.type.kind==="formatted"?rn.fromString(mt(this.args[0].evaluate(e))):this.type.kind==="resolvedImage"?nn.build(mt(this.args[0].evaluate(e))):this.type.kind==="array"?this.args.map(i=>i.evaluate(e)):mt(this.args[0].evaluate(e))}
vendor: 24,364 bytes, line 1
1eachChild(e){this.args.forEach(e)}outputDefined(){return this.args.every(e=>e.outputDefined())}serialize(){if(this.type.kind==="formatted")return new yt([{content:this.args[0],scale:null,font:null,textColor:null}]).serialize();if(this.type.kind==="resolvedImage")return new Hc(this.args[0]).serialize();const e=this.type.kind==="array"?[]:[`to-${this.type.kind}`];return this.eachChild(i=>{e.push(i.serialize())}),e}}const pl=["Unknown","Point","LineString","Polygon"];class Wc{constructor(e,i,o){this.globals=null,this.feature=null,this.featureState=null,this.formattedSection=null,this.availableImages=null,this.canonical=null,this.featureTileCoord=null,this.featureDistanceData=null,this.scope=e,this.options=i,this.iconImageUseTheme=o}id(){return this.feature&&this.feature.id!==void 0?this.feature.id:null}geometryType(){return this.feature?typeof this.feature.type=="number"?pl[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||{}}measureLight(e){return this.globals.brightness||0}distanceFromCenter(){if(this.featureTileCoord&&this.featureDistanceData){const e=this.featureDistanceData.center,i=this.featureDistanceData.scale,{x:o,y:a}=this.featureTileCoord;return this.featureDistanceData.bearing[0]*(o*i-e[0])+this.featureDistanceData.bearing[1]*(a*i-e[1])}return 0}parseColor(e){return ai.parse(e)}getConfig(e){return this.options?this.options.get(e):null}}class jn{constructor(e,i,o,a,c){this.name=e,this.type=i,this._evaluate=o,this.args=a,this._overloadIndex=c}evaluate(e){if(!this._evaluate){const i=jn.definitions[this.name];this._evaluate=Array.isArray(i)?i[2]:i.overloads[this._overloadIndex][1]}return this._evaluate(e,this.args)}eachChild(e){this.args.forEach(e)}outputDefined(){return!1}serialize(){return[this.name].concat(this.args.map(e=>e.serialize()))}static parse(e,i){const o=e[0],a=jn.definitions[o];if(!a)return i.error(`Unknown expression "${o}". If you wanted a literal array, use ["literal", [...]].`,0);const c=Array.isArray(a)?a[0]:a.type,h=Array.isArray(a)?[[a[1],a[2]]]:a.overloads,f=[];let _=null,y=-1;for(const[v,b]of h){if(Array.isArray(v)&&v.length!==e.length-1)continue;f.push(v),y++,_===null?_=i._forkForSignature():_.errors.length=0;const T=[];let E=!1;for(let C=1;C<e.length;C++){const P=e[C],R=Array.isArray(v)?v[C-1]:v.type,z=_.parse(P,1+T.length,R);if(!z){E=!0;break}T.push(z)}if(!E)if(Array.isArray(v)&&v.length!==T.length)_.error(`Expected ${v.length} arguments, but found ${T.length} instead.`);else{for(let C=0;C<T.length;C++){const P=Array.isArray(v)?v[C]:v.type;_.checkSubtype(P,T[C].type,C+1)}if(_.errors.length===0)return new jn(o,c,b,T,y)}}if(f.length===1)i.errors.push(..._.errors);else{const v=(f.length?f:h.map(([T])=>T)).map(qd).join(" | "),b=[];for(let T=1;T<e.length;T++){const E=i.parse(e[T],1+b.length);if(!E)return null;b.push(wr(E.type))}i.error(`Expected arguments of type ${v}, but found (${b.join(", ")}) instead.`)}return null}static register(e,i){jn.definitions=i;for(const o in i)e[o]=jn}}function qd(r){return Array.isArray(r)?`(${r.map(wr).join(", ")})`:`(${wr(r.type)}...)`}class Xc{constructor(e,i,o){this.type=Jl,this.locale=o,this.caseSensitive=e,this.diacriticSensitive=i}static parse(e,i){if(e.length!==2)return i.error("Expected one argument."),null;const o=e[1];if(typeof o!="object"||Array.isArray(o))return i.error("Collator options argument must be an object."),null;const a=o["case-sensitive"]===void 0?i.parse(!1,1,ci):i.parseObjectValue(o["case-sensitive"],1,"case-sensitive",ci);if(!a)return null;const c=o["diacritic-sensitive"]===void 0?i.parse(!1,1,ci):i.parseObjectValue(o["diacritic-sensitive"],1,"diacritic-sensitive",ci);if(!c)return null;let h=null;return o.locale&&(h=i.parseObjectValue(o.locale,1,"locale",fi),!h)?null:new Xc(a,c,h)}evaluate(e){return new th(this.caseSensitive.evaluate(e),this.diacriticSensitive.evaluate(e),this.locale?this.locale.evaluate(e):null)}eachChild(e){e(this.caseSensitive),e(this.diacriticSensitive),this.locale&&e(this.locale)}outputDefined(){return!1}serialize(){const e={};return e["case-sensitive"]=this.caseSensitive.serialize(),e["diacritic-sensitive"]=this.diacriticSensitive.serialize(),this.locale&&(e.locale=this.locale.serialize()),["collator",e]}}function Ss(r){return(180+r)/360}function vn(r){return(180-180/Math.PI*Math.log(Math.tan(Math.PI/4+r*Math.PI/360)))/360}function $r(r){return 360*r-180}function on(r){return 360/Math.PI*Math.atan(Math.exp((180-360*r)*Math.PI/180))-90}const Zs=8192;function Hd(r,e){const i=Ss(r[0]),o=vn(r[1]),a=Math.pow(2,e.z);return[Math.round(i*a*Zs),Math.round(o*a*Zs)]}function rh(r,e){for(let i=0;i<e.length;i++)if(Qr(r,e[i]))return!0;return!1}function Hg(r,e,i){for(const o of i)for(let a=0,c=o.length,h=c-1;a<c;h=a++)if(ws(r,e,o[h],o[a]))return!0;return!1}function Yc(r,e){for(let i=0;i<r.length;++i)if(!Qr(r[i],e))return!1;for(let i=0;i<r.length-1;++i)if(Hg(r[i],r[i+1],e))return!1;return!0}function Zg(r,e){for(let i=0;i<e.length;i++)if(Yc(r,e[i]))return!0;return!1}function nc(r,e,i){const o=[];for(let a=0;a<r.length;a++){const c=[];for(let h=0;h<r[a].length;h++){const f=Hd(r[a][h],i);xn(e,f),c.push(f)}o.push(c)}return o}function pm(r,e,i){const o=[];for(let a=0;a<r.length;a++){const c=nc(r[a],e,i);o.push(c)}return o}function nh(r,e,i,o){if(r[0]<i[0]||r[0]>i[2]){const a=.5*o;let c=r[0]-i[0]>a?-o:i[0]-r[0]>a?o:0;c===0&&(c=r[0]-i[2]>a?-o:i[2]-r[0]>a?o:0),r[0]+=c}xn(e,r)}function Zd(r,e,i,o){const a=Math.pow(2,o.z)*Zs,c=[o.x*Zs,o.y*Zs],h=[];if(!r)return h;for(const f of r)for(const _ of f){const y=[_.x+c[0],_.y+c[1]];nh(y,e,i,a),h.push(y)}return h}function oc(r,e,i,o){const a=Math.pow(2,o.z)*Zs,c=[o.x*Zs,o.y*Zs],h=[];if(!r)return h;for(const _ of r){const y=[];for(const v of _){const b=[v.x+c[0],v.y+c[1]];xn(e,b),y.push(b)}h.push(y)}if(e[2]-e[0]<=a/2){(f=e)[0]=f[1]=1/0,f[2]=f[3]=-1/0;for(const _ of h)for(const y of _)nh(y,e,i,a)}var f;return h}class ua{constructor(e,i){this.type=ci,this.geojson=e,this.geometries=i}static parse(e,i){if(e.length!==2)return i.error(`'within' expression requires exactly one argument, but found ${e.length-1} instead.`);if(Oo(e[1])){const o=e[1];if(o.type==="FeatureCollection")for(let a=0;a<o.features.length;++a){const c=o.features[a].geometry.type;if(c==="Polygon"||c==="MultiPolygon")return new ua(o,o.features[a].geometry)}else if(o.type==="Feature"){const a=o.geometry.type;if(a==="Polygon"||a==="MultiPolygon")return new ua(o,o.geometry)}else if(o.type==="Polygon"||o.type==="MultiPolygon")return new ua(o,o)}return i.error("'within' expression requires valid geojson object that contains polygon geometry type.")}evaluate(e){if(e.geometry()!=null&&e.canonicalID()!=null){if(e.geometryType()==="Point")return(function(i,o){const a=[1/0,1/0,-1/0,-1/0],c=[1/0,1/0,-1/0,-1/0],h=i.canonicalID();if(!h)return!1;if(o.type==="Polygon"){const f=nc(o.coordinates,c,h),_=Zd(i.geometry(),a,c,h);if(!is(a,c))return!1;for(const y of _)if(!Qr(y,f))return!1}if(o.type==="MultiPolygon"){const f=pm(o.coordinates,c,h),_=Zd(i.geometry(),a,c,h);if(!is(a,c))return!1;for(const y of _)if(!rh(y,f))return!1}return!0})(e,this.geometries);if(e.geometryType()==="LineString")return(function(i,o){const a=[1/0,1/0,-1/0,-1/0],c=[1/0,1/0,-1/0,-1/0],h=i.canonicalID();if(!h)return!1;if(o.type==="Polygon"){const f=nc(o.coordinates,c,h),_=oc(i.geometry(),a,c,h);if(!is(a,c))return!1;for(const y of _)if(!Yc(y,f))return!1}if(o.type==="MultiPolygon"){const f=pm(o.coordinates,c,h),_=oc(i.geometry(),a,c,h);if(!is(a,c))return!1;for(const y of _)if(!Zg(y,f))return!1}return!0})(e,this.geometries)}return!1}eachChild(){}outputDefined(){return!0}serialize(){return["within",this.geojson]}}class sc{constructor(e=[],i=(o,a)=>o<a?-1:o>a?1:0){if(this.data=e,this.length=this.data.length,this.compare=i,this.length>0)for(let o=(this.length>>1)-1;o>=0;o--)this._down(o)}push(e){this.data.push(e),this._up(this.length++)}pop(){if(this.length===0)return;const e=this.data[0],i=this.data.pop();return--this.length>0&&(this.data[0]=i,this._down(0)),e}peek(){return this.data[0]}_up(e){const{data:i,compare:o}=this,a=i[e];for(;e>0;){const c=e-1>>1,h=i[c];if(o(a,h)>=0)break;i[e]=h,e=c}i[e]=a}_down(e){const{data:i,compare:o}=this,a=this.length>>1,c=i[e];for(;e<a;){let h=1+(e<<1);const f=h+1;if(f<this.length&&o(i[f],i[h])<0&&(h=f),o(i[h],c)>=0)break;i[e]=i[h],e=h}i[e]=c}}var rt=8192;const oh=1/298.257223563,ac=oh*(2-oh),Wd=Math.PI/180;function Xd(r){const e=6378.137*Wd*1e3,i=Math.cos(r*Wd),o=1/(1-ac*(1-i*i)),a=Math.sqrt(o);return[e*a*i,e*a*o*(1-ac)]}function ml(r){for(;r<-180;)r+=360;for(;r>180;)r-=360;return r}function lc(r,e,i,o){const a=ml(r[0]-e[0])*i,c=(r[1]-e[1])*o;return Math.sqrt(a*a+c*c)}function Kc(r,e,i,o,a){let c=e[0],h=e[1],f=ml(i[0]-c)*o,_=(i[1]-h)*a;if(f!==0||_!==0){const y=(ml(r[0]-c)*o*f+(r[1]-h)*a*_)/(f*f+_*_);y>1?(c=i[0],h=i[1]):y>0&&(c+=f/o*y,h+=_/a*y)}return f=ml(r[0]-c)*o,_=(r[1]-h)*a,Math.sqrt(f*f+_*_)}function Es(r,e){return e.dist-r.dist}function mm(r){const e=[1/0,1/0,-1/0,-1/0];if(e.length!==r.length)return!1;for(let i=0;i<e.length;i++)if(e[i]!==r[i])return!1;return!0}function Jc(r){return r[1]-r[0]+1}function ha(r,e){const i=r[1]>=r[0]&&r[1]<e;return i||console.warn("Distance Expression: Index is out of range"),i}function Yd(r,e){if(r[0]>r[1])return[null,null];const i=Jc(r);if(e){if(i===2)return[r,null];const o=Math.floor(i/2);return[[r[0],r[0]+o],[r[0]+o,r[1]]]}{if(i===1)return[r,null];const o=Math.floor(i/2)-1;return[[r[0],r[0]+o],[r[0]+o+1,r[1]]]}}function _l(r,e){const i=[1/0,1/0,-1/0,-1/0];if(!ha(e,r.length))return i;for(let o=e[0];o<=e[1];++o)xn(i,r[o]);return i}function sh(r){const e=[1/0,1/0,-1/0,-1/0];for(let i=0;i<r.length;++i)for(let o=0;o<r[i].length;++o)xn(e,r[i][o]);return e}function Da(r,e,i,o){if(mm(r)||mm(e))return NaN;let a=0,c=0;return r[2]<e[0]&&(a=e[0]-r[2]),r[0]>e[2]&&(a=r[0]-e[2]),r[1]>e[3]&&(c=r[1]-e[3]),r[3]<e[1]&&(c=e[1]-r[3]),lc([0,0],[a,c],i,o)}function Qc(r,e,i=8192){const o=Math.pow(2,e.z),a=(r.y/i+e.y)/o;return[$r((r.x/i+e.x)/o),on(a)]}function _m(r,e){const i=[];for(let o=0;o<r.length;++o)i.push(Qc(r[o],e));return i}function Kd(r,e,i,o){const a=(function(c,h,f,_){let y=1/0,v=c[0][0],b=c[0][1];for(let T=0;T<c.length-1;T++){let E=c[T][0],C=c[T][1],P=ml(c[T+1][0]-E)*f,R=(c[T+1][1]-C)*_,z=0;P===0&&R===0||(z=(ml(h[0]-E)*f*P+(h[1]-C)*_*R)/(P*P+R*R),z>1?(E=c[T+1][0],C=c[T+1][1]):z>0&&(E+=P/f*z,C+=R/_*z)),P=ml(h[0]-E)*f,R=(h[1]-C)*_;const V=P*P+R*R;V<y&&(y=V,v=E,b=C)}return[v,b]})(e,r,i,o);return lc(r,a,i,o)}function Jd(r,e,i,o,a,c){const h=i.slice(o[0],o[1]+1);let f=1/0;for(let _=e[0];_<=e[1];++_)if((f=Math.min(f,Kd(r[_],h,a,c)))===0)return 0;return f}function ah(r,e,i,o,a,c){const h=Math.min(Kc(r,i,o,a,c),Kc(e,i,o,a,c)),f=Math.min(Kc(i,r,e,a,c),Kc(o,r,e,a,c));return Math.min(h,f)}function gm(r,e,i,o,a,c){if(!ha(e,r.length)||!ha(o,i.length))return NaN;let h=1/0;for(let f=e[0];f<e[1];++f)for(let _=o[0];_<o[1];++_){if(ws(r[f],r[f+1],i[_],i[_+1]))return 0;h=Math.min(h,ah(r[f],r[f+1],i[_],i[_+1],a,c))}return h}function Qd(r,e,i,o,a,c){if(!ha(e,r.length)||!ha(o,i.length))return NaN;let h=1/0;for(let f=e[0];f<=e[1];++f)for(let _=o[0];_<=o[1];++_)if((h=Math.min(h,lc(r[f],i[_],a,c)))===0)return h;return h}function ym(r,e,i,o){if(Qr(r,e,!0))return 0;let a=1/0;for(const c of e){const h=c.length;if(h<2)return console.warn("Distance Expression: Invalid polygon!"),NaN;if(c[0]!==c[h-1]&&(a=Math.min(a,Kc(r,c[h-1],c[0],i,o)))===0||(a=Math.min(a,Kd(r,c,i,o)))===0)return a}return a}function xm(r,e,i,o,a){if(!ha(e,r.length))return NaN;for(let h=e[0];h<=e[1];++h)if(Qr(r[h],i,!0))return 0;let c=1/0;for(let h=e[0];h<e[1];++h)for(const f of i)for(let _=0,y=f.length,v=y-1;_<y;v=_++){if(ws(r[h],r[h+1],f[v],f[_]))return 0;c=Math.min(c,ah(r[h],r[h+1],f[v],f[_],o,a))}return c}function ef(r,e){for(const i of r)for(let o=0;o<=i.length-1;++o)if(Qr(i[o],e,!0))return!0;return!1}function vm(r,e,i,o,a=1/0){const c=sh(r),h=sh(e);if(a!==1/0&&Da(c,h,i,o)>=a)return a;if(is(c,h)){if(ef(r,e))return 0}else if(ef(e,r))return 0;let f=a;for(const _ of r)for(let y=0,v=_.length,b=v-1;y<v;b=y++)for(const T of e)for(let E=0,C=T.length,P=C-1;E<C;P=E++){if(ws(_[b],_[y],T[P],T[E]))return 0;f=Math.min(f,ah(_[b],_[y],T[P],T[E],i,o))}return f}function eu(r,e,i,o,a,c,h,f){if(h===null||f===null)return;const _=Da(_l(a,h),_l(c,f),i,o);_<e&&r.push({dist:_,range1:h,range2:f})}function Wg(r,e,i,o,a,c=1/0){let h=Math.min(lc(r[0],i[0][0],o,a),c);if(h===0)return h;const f=new sc([{dist:0,range1:[0,r.length-1],range2:[0,0]}],Es),_=e?50:100,y=sh(i);for(;f.length;){const v=f.pop();if(v.dist>=h)continue;const b=v.range1;if(Jc(b)<=_){if(!ha(b,r.length))return NaN;if(e){const T=xm(r,b,i,o,a);if((h=Math.min(h,T))===0)return h}else for(let T=b[0];T<=b[1];++T){const E=ym(r[T],i,o,a);if((h=Math.min(h,E))===0)return h}}else{const T=Yd(b,e);if(T[0]!==null){const E=Da(_l(r,T[0]),y,o,a);E<h&&f.push({dist:E,range1:T[0],range2:[0,0]})}if(T[1]!==null){const E=Da(_l(r,T[1]),y,o,a);E<h&&f.push({dist:E,range1:T[1],range2:[0,0]})}}}return h}function bm(r,e,i,o,a,c,h=1/0){let f=Math.min(h,lc(r[0],i[0],a,c));if(f===0)return f;const _=new sc([{dist:0,range1:[0,r.length-1],range2:[0,i.length-1]}],Es),y=e?50:100,v=o?50:100;for(;_.length;){const b=_.pop();if(b.dist>=f)continue;const T=b.range1,E=b.range2;if(Jc(T)<=y&&Jc(E)<=v){if(!ha(T,r.length)||!ha(E,i.length))return NaN;if(e&&o?f=Math.min(f,gm(r,T,i,E,a,c)):e||o?e&&!o?f=Math.min(f,Jd(i,E,r,T,a,c)):!e&&o&&(f=Math.min(f,Jd(r,T,i,E,a,c))):f=Math.min(f,Qd(r,T,i,E,a,c)),f===0)return f}else{const C=Yd(T,e),P=Yd(E,o);eu(_,f,a,c,r,i,C[0],P[0]),eu(_,f,a,c,r,i,C[0],P[1]),eu(_,f,a,c,r,i,C[1],P[0]),eu(_,f,a,c,r,i,C[1],P[1])}}return f}function cc(r,e,i,o,a,c=1/0){let h=c;const f=_l(r,[0,r.length-1]);for(const _ of i)if(!(h!==1/0&&Da(f,_l(_,[0,_.length-1]),o,a)>=h)&&(h=Math.min(h,bm(r,e,_,!0,o,a,h)),h===0))return h;return h}function La(r,e,i,o,a,c=1/0){let h=c;const f=_l(r,[0,r.length-1]);for(const _ of i){if(h!==1/0&&Da(f,sh(_),o,a)>=h)continue;const y=Wg(r,e,_,o,a,h);if(isNaN(y))return y;if((h=Math.min(h,y))===0)return h}return h}function uc(r){return r==="Point"||r==="MultiPoint"||r==="LineString"||r==="MultiLineString"||r==="Polygon"||r==="MultiPolygon"}class za{constructor(e,i){this.type=ft,this.geojson=e,this.geometries=i}static parse(e,i){if(e.length!==2)return i.error(`'distance' expression requires either one argument, but found ' ${e.length-1} instead.`);if(Oo(e[1])){const o=e[1];if(o.type==="FeatureCollection"){for(let a=0;a<o.features.length;++a)if(uc(o.features[a].geometry.type))return new za(o,o.features[a].geometry)}else if(o.type==="Feature"){if(uc(o.geometry.type))return new za(o,o.geometry)}else if(uc(o.type))return new za(o,o)}return i.error("'distance' expression needs to be an array with format ['Distance', GeoJSONObj].")}evaluate(e){const i=e.geometry(),o=e.canonicalID();if(i!=null&&o!=null){if(e.geometryType()==="Point")return(function(a,c,h){const f=[];for(const v of a)for(const b of v)f.push(Qc(b,c));const[_,y]=Xd(f[0][1]);return h.type==="Point"||h.type==="MultiPoint"||h.type==="LineString"?bm(f,!1,h.type==="Point"?[h.coordinates]:h.coordinates,h.type==="LineString",_,y):h.type==="MultiLineString"?cc(f,!1,h.coordinates,_,y):h.type==="Polygon"||h.type==="MultiPolygon"?La(f,!1,h.type==="Polygon"?[h.coordinates]:h.coordinates,_,y):null})(i,o,this.geometries);if(e.geometryType()==="LineString")return(function(a,c,h){const f=[];for(const v of a){const b=[];for(const T of v)b.push(Qc(T,c));f.push(b)}const[_,y]=Xd(f[0][0][1]);if(h.type==="Point"||h.type==="MultiPoint"||h.type==="LineString")return cc(h.type==="Point"?[h.coordinates]:h.coordinates,h.type==="LineString",f,_,y);if(h.type==="MultiLineString"){let v=1/0;for(let b=0;b<h.coordinates.length;b++){const T=cc(h.coordinates[b],!0,f,_,y,v);if(isNaN(T))return T;if((v=Math.min(v,T))===0)return v}return v}if(h.type==="Polygon"||h.type==="MultiPolygon"){let v=1/0;for(let b=0;b<f.length;b++){const T=La(f[b],!0,h.type==="Polygon"?[h.coordinates]:h.coordinates,_,y,v);if(isNaN(T))return T;if((v=Math.min(v,T))===0)return v}return v}return null})(i,o,this.geometries);if(e.geometryType()==="Polygon")return(function(a,c,h){const f=[];for(const v of Ro(a,0)){const b=[];for(let T=0;T<v.length;++T)b.push(_m(v[T],c));f.push(b)}const[_,y]=Xd(f[0][0][0][1]);if(h.type==="Point"||h.type==="MultiPoint"||h.type==="LineString")return La(h.type==="Point"?[h.coordinates]:h.coordinates,h.type==="LineString",f,_,y);if(h.type==="MultiLineString"){let v=1/0;for(let b=0;b<h.coordinates.length;b++){const T=La(h.coordinates[b],!0,f,_,y,v);if(isNaN(T))return T;if((v=Math.min(v,T))===0)return v}return v}return h.type==="Polygon"||h.type==="MultiPolygon"?(function(v,b,T,E){let C=1/0;for(const P of v)for(const R of b){const z=vm(P,R,T,E,C);if(isNaN(z))return z;if((C=Math.min(C,z))===0)return C}return C})(h.type==="Polygon"?[h.coordinates]:h.coordinates,f,_,y):null})(i,o,this.geometries);console.warn("Distance Expression: currently only evaluates valid Point/LineString/Polygon geometries.")}else console.warn("Distance Expression: requires valid feature and canonical information.");return null}eachChild(){}outputDefined(){return!0}serialize(){return["distance",this.geojson]}}function Fa(r){if(r instanceof jn&&(r.name==="get"&&r.args.length===1||r.name==="feature-state"||r.name==="has"&&r.args.length===1||r.name==="properties"||r.name==="geometry-type"||r.name==="id"||r.name.startsWith("filter-"))||r instanceof ua||r instanceof za)return!1;if(r instanceof xl)return r.featureConstant;let e=!0;return r.eachChild(i=>{e&&!Fa(i)&&(e=!1)}),e}function gl(r){if(r instanceof jn&&r.name==="feature-state")return!1;let e=!0;return r.eachChild(i=>{e&&!gl(i)&&(e=!1)}),e}function lh(r,e){if(r instanceof jn&&e.has(r.name))return!1;let i=!0;return r.eachChild(o=>{i&&!lh(o,e)&&(i=!1)}),i}function Oa(r,e){return lh(r,new Set(e))}function wm(r,e,i){return[r,e,i].filter(Boolean).join("�")}function tf(r,e){switch(r){case"string":return mt(e);case"number":return+e;case"boolean":return!!e;case"color":return ai.parse(e);case"formatted":return rn.fromString(mt(e));case"resolvedImage":return nn.build(mt(e))}return e}function yl(r,e,i,o){return o!==void 0&&(r=o*Math.round(r/o)),e!==void 0&&r<e&&(r=e),i!==void 0&&r>i&&(r=i),r}class xl{constructor(e,i,o,a=!1){this.type=e,this.key=i,this.scope=o,this.featureConstant=a}static parse(e,i){let o=i.expectedType;if(o==null&&(o=pi),e.length<2||e.length>3)return i.error("Invalid number of arguments for 'config' expression.");const a=i.parse(e[1],1);if(!(a instanceof qs))return i.error("Key name of 'config' expression must be a string literal.");let c,h=!0;const f=mt(a.value);if(e.length>=3){const _=i.parse(e[2],2);if(!(_ instanceof qs))return i.error("Scope of 'config' expression must be a string literal.");c=mt(_.value)}if(i.options){const _=wm(f,c,i._scope),y=i.options.get(_);y&&(h=Fa(y.value||y.default))}return new xl(o,f,c,h)}evaluate(e){const i=wm(this.key,this.scope,e.scope),o=e.getConfig(i);if(!o)return null;const{type:a,value:c,values:h,minValue:f,maxValue:_,stepValue:y}=o,v=o.default.evaluate(e);let b=v;if(c){const T=e.scope;e.scope=(T||"").split("�").slice(1).join("�"),b=c.evaluate(e),e.scope=T}return a&&(b=tf(a,b)),b===void 0||f===void 0&&_===void 0&&y===void 0||(typeof b=="number"?b=yl(b,f,_,y):Array.isArray(b)&&(b=b.map(T=>typeof T=="number"?yl(T,f,_,y):T))),c!==void 0&&b!==void 0&&h&&!h.includes(b)&&(b=v,a&&(b=tf(a,b))),(a&&a!==this.type||b!==void 0&&!qc(Cr(b),this.type))&&(b=tf(this.type.kind,b)),b}eachChild(){}outputDefined(){return!1}serialize(){const e=["config",this.key];return this.scope&&e.concat(this.scope),e}}class Vt{constructor(e,i){this.type=i.type,this.name=e,this.boundExpression=i}static parse(e,i){if(e.length!==2||typeof e[1]!="string")return i.error("'var' expression requires exactly one string literal argument.");const o=e[1];return i.scope.has(o)?new Vt(o,i.scope.get(o)):i.error(`Unknown variable "${o}". Make sure "${o}" has been bound in an enclosing "let" expression before using it.`,1)}evaluate(e){return this.boundExpression.evaluate(e)}eachChild(){}outputDefined(){return!1}serialize(){return["var",this.name]}}class ch{constructor(e,i=[],o,a=new Qu,c=[],h,f,_){this.registry=e,this.path=i,this.scope=a,this.errors=c,this.expectedType=o,this._scope=h,this.options=f,this.iconImageUseTheme=_}get key(){let e="";for(let i=0;i<this.path.length;i++){const o=this.path[i];e+=typeof o=="string"?`['${o}']`:`[${o}]`}return e}parse(e,i,o,a,c={}){if(i||o){const h=this.expectedType,f=this.scope;a&&(this.scope=this.scope.concat(a)),this.expectedType=o||null;const _=typeof i=="number";_&&this.path.push(i);const y=this._parse(e,c);return _&&this.path.pop(),this.expectedType=h,this.scope=f,y}return this._parse(e,c)}parseObjectValue(e,i,o,a,c,h={}){const f=this.expectedType,_=this.scope;c&&(this.scope=this.scope.concat(c)),this.expectedType=a||null,this.path.push(i),this.path.push(o);const y=this._parse(e,h);return this.path.pop(),this.path.pop(),this.expectedType=f,this.scope=_,y}_parse(e,i){if(e!==null&&typeof e!="string"&&typeof e!="boolean"&&typeof e!="number"||(e=["literal",e]),Array.isArray(e)){if(e.length===0)return this.error('Expected an array with at least one element. If you wanted a literal array, use ["literal", []].');const o=typeof e[0]=="string"&&Object.hasOwn(this.registry,e[0])?this.registry[e[0]]:void 0;if(o){let a=o.parse(e,this);if(!a)return null;if(this.expectedType){const c=this.expectedType,h=a.type;if(c.kind!=="string"&&c.kind!=="number"&&c.kind!=="boolean"&&c.kind!=="object"&&c.kind!=="array"||h.kind!=="value")if(c.kind!=="color"&&c.kind!=="formatted"&&c.kind!=="resolvedImage"||h.kind!=="value"&&h.kind!=="string"){if(this.checkSubtype(c,h))return null}else a=Tm(a,c,i.typeAnnotation||"coerce");else a=Tm(a,c,i.typeAnnotation||"assert")}if(!(a instanceof qs)&&a.type.kind!=="resolvedImage"&&hc(a)){const c=new Wc(this._scope,this.options,this.iconImageUseTheme);try{a=new qs(a.type,a.evaluate(c))}catch(h){return this.error(h.message),null}}return a}return Hs.parse(["to-array",e],this)}return this.error(e===void 0?"'undefined' value invalid. Use null instead.":typeof e=="object"?'Bare objects invalid. Use ["literal", {...}] instead.':`Expected an array, but found ${typeof e} instead.`)}concat(e,i,o,a){const c=a?this.scope.concat(a):this.scope,h=this.path.slice();return typeof e=="number"&&h.push(e),typeof i=="string"&&h.push(i),new ch(this.registry,h,o||null,c,this.errors,this._scope,this.options,this.iconImageUseTheme)}_forkForSignature(){return new ch(this.registry,this.path.slice(),null,this.scope,[],this._scope,this.options,this.iconImageUseTheme)}error(e,...i){const o=`${this.key}${i.map(a=>`[${a}]`).join("")}`;this.errors.push(new zo(o,e))}checkSubtype(e,i,o){const a=ec(e,i);return a&&this.error(a,...typeof o=="number"?[o]:[]),a}}const Xg=new Set(["zoom","heatmap-density","worldview","line-progress","raster-value","sky-radial-progress","accumulated","is-supported-script","pitch","distance-from-center","measure-light","raster-particle-speed","is-active-floor"]);function Tm(r,e,i){return i==="assert"?new On(e,[r]):i==="coerce"?new Hs(e,[r]):r}function hc(r){if(r instanceof Vt)return hc(r.boundExpression);if(r instanceof jn&&r.name==="error"||r instanceof Xc||r instanceof ua||r instanceof za||r instanceof xl)return!1;const e=r instanceof Hs||r instanceof On;let i=!0;return r.eachChild(o=>{i=e?i&&hc(o):i&&o instanceof qs}),!!i&&Fa(r)&&lh(r,Xg)}function tu(r,e){const i=r.length-1;let o,a,c=0,h=i,f=0;for(;c<=h;)if(f=Math.floor((c+h)/2),o=r[f],a=r[f+1],o<=e){if(f===i||e<a)return f;c=f+1}else{if(!(o>e))throw new Tr("Input is not a number.");h=f-1}return 0}class ka{constructor(e,i,o){this.type=e,this.input=i,this.labels=[],this.outputs=[];for(const[a,c]of o)this.labels.push(a),this.outputs.push(c)}static parse(e,i){if(e.length-1<4)return i.error(`Expected at least 4 arguments, but found only ${e.length-1}.`);if((e.length-1)%2!=0)return i.error("Expected an even number of arguments.");const o=i.parse(e[1],1,ft);if(!o)return null;const a=[];let c=null;i.expectedType&&i.expectedType.kind!=="value"&&(c=i.expectedType);for(let h=1;h<e.length;h+=2){const f=h===1?-1/0:e[h],_=e[h+1],y=h,v=h+1;if(typeof f!="number")return i.error('Input/output pairs for "step" expressions must be defined using literal numeric values (not c
1omputed expressions) for the input values.',y);if(a.length&&a.at(-1)[0]>=f)return i.error('Input/output pairs for "step" expressions must be arranged with input values in strictly ascending order.',y);const b=i.parse(_,v,c);if(!b)return null;c=c||b.type,a.push([f,b])}return new ka(c,o,a)}evaluate(e){const i=this.labels,o=this.outputs;if(i.length===1)return o[0].evaluate(e);const a=this.input.evaluate(e);if(a<=i[0])return o[0].evaluate(e);const c=i.length;return a>=i[c-1]?o[c-1].evaluate(e):o[tu(i,a)].evaluate(e)}eachChild(e){e(this.input);for(const i of this.outputs)e(i)}outputDefined(){return this.outputs.every(e=>e.outputDefined())}serialize(){const e=["step",this.input.serialize()];for(let i=0;i<this.labels.length;i++)i>0&&e.push(this.labels[i]),e.push(this.outputs[i].serialize());return e}}const Sm=.95047,Em=1.08883,Im=4/29,da=6/29,Am=3*da*da,Yg=da*da*da,mo=Math.PI/180,rf=180/Math.PI;function dc(r){return r>Yg?Math.pow(r,1/3):r/Am+Im}function uh(r){return r>da?r*r*r:Am*(r-Im)}function iu(r){return 255*(r<=.0031308?12.92*r:1.055*Math.pow(r,1/2.4)-.055)}function nf(r){return(r/=255)<=.04045?r/12.92:Math.pow((r+.055)/1.055,2.4)}function Cm(r){const e=nf(r.r),i=nf(r.g),o=nf(r.b),a=dc((.4124564*e+.3575761*i+.1804375*o)/Sm),c=dc((.2126729*e+.7151522*i+.072175*o)/1);return{l:116*c-16,a:500*(a-c),b:200*(c-dc((.0193339*e+.119192*i+.9503041*o)/Em)),alpha:r.a}}function Mm(r){let e=(r.l+16)/116,i=isNaN(r.a)?e:e+r.a/500,o=isNaN(r.b)?e:e-r.b/200;return e=1*uh(e),i=Sm*uh(i),o=Em*uh(o),new ai(iu(3.2404542*i-1.5371385*e-.4985314*o),iu(-.969266*i+1.8760108*e+.041556*o),iu(.0556434*i-.2040259*e+1.0572252*o),r.alpha)}function Kg(r,e,i){const o=e-r;return r+i*(o>180||o<-180?o-360*Math.round(o/360):o)}const fc={forward:Cm,reverse:Mm,interpolate:function(r,e,i){return{l:vt(r.l,e.l,i),a:vt(r.a,e.a,i),b:vt(r.b,e.b,i),alpha:vt(r.alpha,e.alpha,i)}}},pc={forward:function(r){const{l:e,a:i,b:o}=Cm(r),a=Math.atan2(o,i)*rf;return{h:a<0?a+360:a,c:Math.sqrt(i*i+o*o),l:e,alpha:r.a}},reverse:function(r){const e=r.h*mo,i=r.c;return Mm({l:r.l,a:Math.cos(e)*i,b:Math.sin(e)*i,alpha:r.alpha})},interpolate:function(r,e,i){return{h:Kg(r.h,e.h,i),c:vt(r.c,e.c,i),l:vt(r.l,e.l,i),alpha:vt(r.alpha,e.alpha,i)}}};var vl=Object.freeze({__proto__:null,hcl:pc,lab:fc});class Gn{constructor(e,i,o,a,c){this.type=e,this.operator=i,this.interpolation=o,this.input=a,this.labels=[],this.outputs=[];for(const[h,f]of c)this.labels.push(h),this.outputs.push(f)}static interpolationFactor(e,i,o,a){let c=0;if(e.name==="exponential")c=hh(i,e.base,o,a);else if(e.name==="linear")c=hh(i,1,o,a);else if(e.name==="cubic-bezier"){const h=e.controlPoints;c=Ca(h[0],h[1],h[2],h[3])(hh(i,1,o,a))}return c}static parse(e,i){let[o,a,c,...h]=e;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"){const y=a[1];if(typeof y!="number")return i.error("Exponential interpolation requires a numeric base.",1,1);a={name:"exponential",base:y}}else{if(a[0]!=="cubic-bezier")return i.error(`Unknown interpolation type ${String(a[0])}`,1,0);{const y=a.slice(1);if(y.length!==4||y.some(v=>typeof v!="number"||v<0||v>1))return i.error("Cubic bezier interpolation requires four numeric arguments with values between 0 and 1.",1);a={name:"cubic-bezier",controlPoints:y}}}if(e.length-1<4)return i.error(`Expected at least 4 arguments, but found only ${e.length-1}.`);if(e.length-1>3&&(e.length-1)%2!=0)return i.error("Expected an even number of arguments.");if(c=i.parse(c,2,ft),!c)return null;const f=[];let _=null;o==="interpolate-hcl"||o==="interpolate-lab"?_=no:i.expectedType&&i.expectedType.kind!=="value"&&(_=i.expectedType);for(let y=0;y<h.length;y+=2){const v=h[y],b=h[y+1],T=y+3,E=y+4;if(typeof v!="number")return i.error('Input/output pairs for "interpolate" expressions must be defined using literal numeric values (not computed expressions) for the input values.',T);if(f.length&&f.at(-1)[0]>=v)return i.error('Input/output pairs for "interpolate" expressions must be arranged with input values in strictly ascending order.',T);const C=i.parse(b,E,_);if(!C)return null;_=_||C.type,f.push([v,C])}return _.kind==="number"||_.kind==="color"||_.kind==="array"&&_.itemType.kind==="number"&&typeof _.N=="number"?new Gn(_,o,a,c,f):i.error(`Type ${wr(_)} is not interpolatable.`)}evaluate(e){const i=this.labels,o=this.outputs;if(i.length===1)return o[0].evaluate(e);const a=this.input.evaluate(e);if(a<=i[0])return o[0].evaluate(e);const c=i.length;if(a>=i[c-1])return o[c-1].evaluate(e);const h=tu(i,a),f=Gn.interpolationFactor(this.interpolation,a,i[h],i[h+1]),_=o[h].evaluate(e),y=o[h+1].evaluate(e);return this.operator==="interpolate"?ct[this.type.kind.toLowerCase()](_,y,f):this.operator==="interpolate-hcl"?pc.reverse(pc.interpolate(pc.forward(_),pc.forward(y),f)):fc.reverse(fc.interpolate(fc.forward(_),fc.forward(y),f))}eachChild(e){e(this.input);for(const i of this.outputs)e(i)}outputDefined(){return this.outputs.every(e=>e.outputDefined())}serialize(){let e;e=this.interpolation.name==="linear"?["linear"]:this.interpolation.name==="exponential"?this.interpolation.base===1?["linear"]:["exponential",this.interpolation.base]:["cubic-bezier",...this.interpolation.controlPoints];const i=[this.operator,e,this.input.serialize()];for(let o=0;o<this.labels.length;o++)i.push(this.labels[o],this.outputs[o].serialize());return i}}function hh(r,e,i,o){const a=o-i,c=r-i;return a===0?0:e===1?c/a:(Math.pow(e,c)-1)/(Math.pow(e,a)-1)}class dh{constructor(e,i){this.type=e,this.args=i}static parse(e,i){if(e.length<2)return i.error("Expectected at least one argument."),null;let o=null;const a=i.expectedType;a&&a.kind!=="value"&&(o=a);const c=[];for(const f of e.slice(1)){const _=i.parse(f,1+c.length,o,void 0,{typeAnnotation:"omit"});if(!_)return null;o=o||_.type,c.push(_)}const h=a&&c.some(f=>ec(a,f.type));return new dh(h?pi:o,c)}evaluate(e){let i,o=null,a=0;for(const c of this.args){if(a++,o=c.evaluate(e),o&&o instanceof nn&&!o.available&&(i||(i=o),o=null,a===this.args.length))return i;if(o!==null)break}return o}
1eachChild(e){this.args.forEach(e)}outputDefined(){return this.args.every(e=>e.outputDefined())}serialize(){const e=["coalesce"];return this.eachChild(i=>{e.push(i.serialize())}),e}}const mc=/[^a-zA-Z0-9_]/;class fh{constructor(e,i){this.type=i.type,this.bindings=[].concat(e),this.result=i}evaluate(e){return this.result.evaluate(e)}eachChild(e){for(const i of this.bindings)e(i[1]);e(this.result)}static parse(e,i){if(e.length<4)return i.error(`Expected at least 3 arguments, but found ${e.length-1} instead.`);const o=[];for(let c=1;c<e.length-1;c+=2){const h=e[c];if(typeof h!="string")return i.error(`Expected string, but found ${typeof h} instead.`,c);if(mc.test(h))return i.error("Variable names must contain only alphanumeric characters or '_'.",c);const f=i.parse(e[c+1],c+1);if(!f)return null;o.push([h,f])}const a=i.parse(e.at(-1),e.length-1,i.expectedType,o);return a?new fh(o,a):null}outputDefined(){return this.result.outputDefined()}serialize(){const e=["let"];for(const[i,o]of this.bindings)e.push(i,o.serialize());return e.push(this.result.serialize()),e}}class of{constructor(e,i,o){this.type=e,this.index=i,this.input=o}static parse(e,i){if(e.length!==3)return i.error(`Expected 2 arguments, but found ${e.length-1} instead.`);const o=i.parse(e[1],1,ft),a=i.parse(e[2],2,Fn(i.expectedType||pi));return o&&a?new of(a.type.itemType,o,a):null}evaluate(e){const i=this.index.evaluate(e),o=this.input.evaluate(e);if(i<0)throw new Tr("Array index out of bounds: negative index");if(i>=o.length)throw new Tr("Array index out of bounds: index exceeds array size");if(i!==Math.floor(i))throw new Tr("Array index must be an integer. Use at-interpolated for fractional indices");return o[i]}eachChild(e){e(this.index),e(this.input)}outputDefined(){return!1}serialize(){return["at",this.index.serialize(),this.input.serialize()]}}class sf{constructor(e,i,o){this.type=e,this.index=i,this.input=o}static parse(e,i){if(e.length!==3)return i.error(`Expected 2 arguments, but found ${e.length-1} instead.`);const o=i.parse(e[1],1,ft),a=i.parse(e[2],2,Fn(i.expectedType||pi));return o&&a?new sf(a.type.itemType,o,a):null}evaluate(e){const i=this.index.evaluate(e),o=this.input.evaluate(e);if(i<0)throw new Tr(`Array index out of bounds: ${i} < 0.`);if(i>o.length-1)throw new Tr(`Array index out of bounds: ${i} > ${o.length-1}.`);if(i===Math.floor(i))return o[i];const a=Math.floor(i),c=Math.ceil(i),h=o[a],f=o[c];if(typeof h!="number"||typeof f!="number")throw new Tr(`Cannot interpolate between non-number values at index ${i}.`);return vt(h,f,i-a)}eachChild(e){e(this.index),e(this.input)}outputDefined(){return!1}serialize(){return["at-interpolated",this.index.serialize(),this.input.serialize()]}}class ph{constructor(e,i){this.type=ci,this.needle=e,this.haystack=i}static parse(e,i){if(e.length!==3)return i.error(`Expected 2 arguments, but found ${e.length-1} instead.`),null;const o=i.parse(e[1],1,pi),a=i.parse(e[2],2,pi);return o&&a?eh(o.type,[ci,fi,ft,Ra,pi])?new ph(o,a):(i.error(`Expected first argument to be of type boolean, string, number or null, but found ${wr(o.type)} instead`),null):null}evaluate(e){const i=this.needle.evaluate(e),o=this.haystack.evaluate(e);if(o==null)return!1;if(!tc(i,["boolean","string","number","null"]))throw new Tr(`Expected first argument to be of type boolean, string, number or null, but found ${wr(Cr(i))} instead.`);if(!tc(o,["string","array"]))throw new Tr(`Expected second argument to be of type array or string, but found ${wr(Cr(o))} instead.`);return o.includes(i)}eachChild(e){e(this.needle),e(this.haystack)}outputDefined(){return!0}serialize(){return["in",this.needle.serialize(),this.haystack.serialize()]}}class ru{constructor(e,i,o){this.type=ft,this.needle=e,this.haystack=i,this.fromIndex=o}static parse(e,i){if(e.length<=2||e.length>=5)return i.error(`Expected 3 or 4 arguments, but found ${e.length-1} instead.`),null;const o=i.parse(e[1],1,pi),a=i.parse(e[2],2,pi);if(!o||!a)return null;if(!eh(o.type,[ci,fi,ft,Ra,pi]))return i.error(`Expected first argument to be of type boolean, string, number or null, but found ${wr(o.type)} instead`),null;if(e.length===4){const c=i.parse(e[3],3,ft);return c?new ru(o,a,c):null}return new ru(o,a)}evaluate(e){const i=this.needle.evaluate(e),o=this.haystack.evaluate(e);if(!tc(i,["boolean","string","number","null"]))throw new Tr(`Expected first argument to be of type boolean, string, number or null, but found ${wr(Cr(i))} instead.`);if(!tc(o,["string","array"]))throw new Tr(`Expected second argument to be of type array or string, but found ${wr(Cr(o))} instead.`);if(this.fromIndex){const a=this.fromIndex.evaluate(e);return o.indexOf(i,a)}return o.indexOf(i)}eachChild(e){e(this.needle),e(this.haystack),this.fromIndex&&e(this.fromIndex)}outputDefined(){return!1}serialize(){if(this.fromIndex!=null&&this.fromIndex!==void 0){const e=this.fromIndex.serialize();return["index-of",this.needle.serialize(),this.haystack.serialize(),e]}return["index-of",this.needle.serialize(),this.haystack.serialize()]}}class mh{constructor(e,i,o,a,c,h){this.inputType=e,this.type=i,this.input=o,this.cases=a,this.outputs=c,this.otherwise=h}static parse(e,i){if(e.length<5)return i.error(`Expected at least 4 arguments, but found only ${e.length-1}.`);if(e.length%2!=1)return i.error("Expected an even number of arguments.");let o,a;i.expectedType&&i.expectedType.kind!=="value"&&(a=i.expectedType);const c={},h=[];for(let y=2;y<e.length-1;y+=2){let v=e[y];const b=e[y+1];if(Array.isArray(v)||(v=[v]),v.length===0)return i.error("Expected at least one branch label.",y);
vendor: 4,153 bytes, line 1
1for(const E of v){if(typeof E!="number"&&typeof E!="string")return i.error("Branch labels must be numbers or strings.",y);if(typeof E=="number"&&Math.abs(E)>Number.MAX_SAFE_INTEGER)return i.error(`Branch labels must be integers no larger than ${Number.MAX_SAFE_INTEGER}.`,y);if(typeof E=="number"&&Math.floor(E)!==E)return i.error("Numeric branch labels must be integer values.",y);if(o){if(i.checkSubtype(o,Cr(E),y))return null}else o=Cr(E);if(c[String(E)]!==void 0)return i.error("Branch labels must be unique.",y);c[String(E)]=h.length}const T=i.parse(b,y,a);if(!T)return null;a=a||T.type,h.push(T)}const f=i.parse(e[1],1,pi);if(!f)return null;const _=i.parse(e.at(-1),e.length-1,a);return _?f.type.kind!=="value"&&i.checkSubtype(o,f.type,1)?null:new mh(o,a,f,c,h,_):null}evaluate(e){const i=this.input.evaluate(e);return(qc(Cr(i),this.inputType)&&this.outputs[this.cases[i]]||this.otherwise).evaluate(e)}eachChild(e){e(this.input),this.outputs.forEach(e),e(this.otherwise)}outputDefined(){return this.outputs.every(e=>e.outputDefined())&&this.otherwise.outputDefined()}serialize(){const e=["match",this.input.serialize()],i=Object.keys(this.cases).sort(),o=[],a={};for(const h of i){const f=a[this.cases[h]];f===void 0?(a[this.cases[h]]=o.length,o.push([this.cases[h],[h]])):o[f][1].push(h)}const c=h=>this.inputType.kind==="number"?Number(h):h;for(const[h,f]of o)e.push(f.length===1?c(f[0]):f.map(c)),e.push(this.outputs[h].serialize());return e.push(this.otherwise.serialize()),e}}class _o{constructor(e,i,o){this.type=e,this.branches=i,this.otherwise=o}static parse(e,i){if(e.length<4)return i.error(`Expected at least 3 arguments, but found only ${e.length-1}.`),null;if(e.length%2!=0)return i.error("Expected an odd number of arguments."),null;let o;i.expectedType&&i.expectedType.kind!=="value"&&(o=i.expectedType);const a=[];for(let h=1;h<e.length-1;h+=2){const f=i.parse(e[h],h,ci);if(!f)return null;const _=i.parse(e[h+1],h+1,o);if(!_)return null;a.push([f,_]),o=o||_.type}const c=i.parse(e.at(-1),e.length-1,o);return c?new _o(o,a,c):null}evaluate(e){for(const[i,o]of this.branches)if(i.evaluate(e))return o.evaluate(e);return this.otherwise.evaluate(e)}eachChild(e){for(const[i,o]of this.branches)e(i),e(o);e(this.otherwise)}outputDefined(){return this.branches.every(([e,i])=>i.outputDefined())&&this.otherwise.outputDefined()}serialize(){const e=["case"];return this.eachChild(i=>{e.push(i.serialize())}),e}}class ko{constructor(e,i,o,a){this.type=e,this.input=i,this.beginIndex=o,this.endIndex=a}static parse(e,i){if(e.length<=2||e.length>=5)return i.error(`Expected 3 or 4 arguments, but found ${e.length-1} instead.`),null;const o=i.parse(e[1],1,pi),a=i.parse(e[2],2,ft);if(!o||!a)return null;if(!eh(o.type,[Fn(pi),fi,pi]))return i.error(`Expected first argument to be of type array or string, but found ${wr(o.type)} instead`),null;if(e.length===4){const c=i.parse(e[3],3,ft);return c?new ko(o.type,o,a,c):null}return new ko(o.type,o,a)}evaluate(e){const i=this.input.evaluate(e),o=this.beginIndex.evaluate(e);if(!tc(i,["string","array"]))throw new Tr(`Expected first argument to be of type array or string, but found ${wr(Cr(i))} instead.`);if(this.endIndex){const a=this.endIndex.evaluate(e);return i.slice(o,a)}return i.slice(o)}eachChild(e){e(this.input),e(this.beginIndex),this.endIndex&&e(this.endIndex)}outputDefined(){return!1}serialize(){if(this.endIndex!=null&&this.endIndex!==void 0){const e=this.endIndex.serialize();return["slice",this.input.serialize(),this.beginIndex.serialize(),e]}return["slice",this.input.serialize(),this.beginIndex.serialize()]}}class Ws{constructor(e,i){this.type=Fn(fi),this.str=e,this.delimiter=i}static parse(e,i){if(e.length!==3)return i.error(`Expected 2 arguments, but found ${e.length-1} instead.`);const o=i.parse(e[1],1,fi),a=i.parse(e[2],2,fi);return o&&a?new Ws(o,a):void 0}evaluate(e){const i=this.str.evaluate(e),o=this.delimiter.evaluate(e);return i.split(o)}eachChild(e){e(this.str),e(this.delimiter)}outputDefined(){return!1}serialize(){return["split",this.str.serialize(),this.delimiter.serialize()]}}function Is(r,e){return r==="=="||r==="!="?e.kind==="boolean"||e.kind==="str
1ing"||e.kind==="number"||e.kind==="null"||e.kind==="value":e.kind==="string"||e.kind==="number"||e.kind==="value"}function fa(r,e,i,o){return o.compare(e,i)===0}function pa(r,e,i){const o=r!=="=="&&r!=="!=";return class R1{constructor(c,h,f){this.type=ci,this.lhs=c,this.rhs=h,this.collator=f,this.hasUntypedArgument=c.type.kind==="value"||h.type.kind==="value"}static parse(c,h){if(c.length!==3&&c.length!==4)return h.error("Expected two or three arguments.");const f=c[0];let _=h.parse(c[1],1,pi);if(!_)return null;if(!Is(f,_.type))return h.error(`"${f}" comparisons are not supported for type '${wr(_.type)}'.`,1);let y=h.parse(c[2],2,pi);if(!y)return null;if(!Is(f,y.type))return h.error(`"${f}" comparisons are not supported for type '${wr(y.type)}'.`,2);if(_.type.kind!==y.type.kind&&_.type.kind!=="value"&&y.type.kind!=="value")return h.error(`Cannot compare types '${wr(_.type)}' and '${wr(y.type)}'.`);o&&(_.type.kind==="value"&&y.type.kind!=="value"?_=new On(y.type,[_]):_.type.kind!=="value"&&y.type.kind==="value"&&(y=new On(_.type,[y])));let v=null;if(c.length===4){if(_.type.kind!=="string"&&y.type.kind!=="string"&&_.type.kind!=="value"&&y.type.kind!=="value")return h.error("Cannot use collator to compare non-string types.");if(v=h.parse(c[3],3,Jl),!v)return null}return new R1(_,y,v)}evaluate(c){const h=this.lhs.evaluate(c),f=this.rhs.evaluate(c);if(o&&this.hasUntypedArgument){const _=Cr(h),y=Cr(f);if(_.kind!==y.kind||_.kind!=="string"&&_.kind!=="number")throw new Tr(`Expected arguments for "${r}" to be (string, string) or (number, number), but found (${_.kind}, ${y.kind}) instead.`)}if(this.collator&&!o&&this.hasUntypedArgument){const _=Cr(h),y=Cr(f);if(_.kind!=="string"||y.kind!=="string")return e(c,h,f)}return this.collator?i(c,h,f,this.collator.evaluate(c)):e(c,h,f)}eachChild(c){c(this.lhs),c(this.rhs),this.collator&&c(this.collator)}outputDefined(){return!0}serialize(){const c=[r];return this.eachChild(h=>{c.push(h.serialize())}),c}}}const Pm=pa("==",function(r,e,i){return e===i},fa),_h=pa("!=",function(r,e,i){return e!==i},function(r,e,i,o){return!fa(0,e,i,o)}),Rm=pa("<",function(r,e,i){return e<i},function(r,e,i,o){return o.compare(e,i)<0}),Jg=pa(">",function(r,e,i){return e>i},function(r,e,i,o){return o.compare(e,i)>0}),_c=pa("<=",function(r,e,i){return e<=i},function(r,e,i,o){return o.compare(e,i)<=0}),af=pa(">=",function(r,e,i){return e>=i},function(r,e,i,o){return o.compare(e,i)>=0});class gh{constructor(e,i,o,a,c,h){this.type=fi,this.number=e,this.locale=i,this.currency=o,this.unit=a,this.minFractionDigits=c,this.maxFractionDigits=h}static parse(e,i){if(e.length!==3)return i.error("Expected two arguments.");const o=i.parse(e[1],1,ft);if(!o)return null;const a=e[2];if(typeof a!="object"||Array.isArray(a))return i.error("NumberFormat options argument must be an object.");let c=null;if(a.locale&&(c=i.parseObjectValue(a.locale,2,"locale",fi),!c))return null;let h=null;if(a.currency&&(h=i.parseObjectValue(a.currency,2,"currency",fi),!h))return null;let f=null;if(a.unit&&(f=i.parseObjectValue(a.unit,2,"unit",fi),!f))return null;let _=null;if(a["min-fraction-digits"]!==void 0&&(_=i.parseObjectValue(a["min-fraction-digits"],2,"min-fraction-digits",ft),!_))return null;let y=null;return a["max-fraction-digits"]===void 0||(y=i.parseObjectValue(a["max-fraction-digits"],2,"max-fraction-digits",ft),y)?new gh(o,c,h,f,_,y):null}evaluate(e){return new Intl.NumberFormat(this.locale?this.locale.evaluate(e):[],{style:(this.currency?"currency":this.unit&&"unit")||"decimal",currency:this.currency?this.currency.evaluate(e):void 0,unit:this.unit?this.unit.evaluate(e):void 0,minimumFractionDigits:this.minFractionDigits?this.minFractionDigits.evaluate(e):void 0,maximumFractionDigits:this.maxFractionDigits?this.maxFractionDigits.evaluate(e):void 0}).format(this.number.evaluate(e))}eachChild(e){e(this.number),this.locale&&e(this.locale),this.currency&&e(this.currency),this.unit&&e(this.unit),this.minFractionDigits&&e(this.minFractionDigits),this.maxFractionDigits&&e(this.maxFractionDigits)}outputDefined(){return!1}serialize(){const e={};return this.locale&&(e.locale=this.locale.serialize()),this.currency&&(e.currency=this.currency.serialize()),this.unit&&(e.unit=this.unit.serialize()),this.minFractionDigits&&(e["min-fraction-digits"]=this.minFractionDigits.serialize()),this.maxFractionDigits&&(e["max-fraction-digits"]=this.maxFractionDigits.serialize()),["number-format",this.number.serialize(),e]}}class Ba{constructor(e){this.type=ft,this.input=e}static parse(e,i){if(e.length!==2)return i.error(`Expected 1 argument, but found ${e.length-1} instead.`),null;const o=i.parse(e[1],1);return o?o.type.kind!=="array"&&o.type.kind!=="string"&&o.type.kind!=="value"?(i.error(`Expected argument of type string or array, but found ${wr(o.type)} instead.`),null):new Ba(o):null}evaluate(e){const i=this.input.evaluate(e);if(typeof i=="string"||Array.isArray(i))return i.length;throw new Tr(`Expected value to be of type string or array, but found ${wr(Cr(i))} instead.`)}eachChild(e){e(this.input)}outputDefined(){return!1}serialize(){const e=["length"];return this.eachChild(i=>{e.push(i.serialize())}),e}}function gc(r){return function(){r=1831565813+(r|=0)|0;let e=Math.imul(r^r>>>15,1|r);return e=e+Math.imul(e^e>>>7,61|e)^e,((e^e>>>14)>>>0)/4294967296}}const yc={"==":Pm,"!=":_h,">":Jg,"<":Rm,">=":af,"<=":_c,array:On,at:of,"at-interpolated":sf,boolean:On,case:_o,coalesce:dh,collator:Xc,format:yt,image:Hc,in:ph,"index-of":ru,interpolate:Gn,"interpolate-hcl":Gn,"interpolate-lab":Gn,length:Ba,let:fh,literal:qs,match:mh,number:On,"number-format":gh,object:On,slice:ko,step:ka,str
vendor: 39,633 bytes, line 1
1ing:On,"to-boolean":Hs,"to-color":Hs,"to-number":Hs,"to-string":Hs,var:Vt,within:ua,distance:za,config:xl,split:Ws};function bl(r,[e,i,o,a]){e=e.evaluate(r),i=i.evaluate(r),o=o.evaluate(r);const c=a?a.evaluate(r):1,h=ih(e,i,o,c);if(h)throw new Tr(h);return new ai(e/255,i/255,o/255,c)}function Dm(r,[e,i,o,a]){e=e.evaluate(r),i=i.evaluate(r),o=o.evaluate(r);const c=a?a.evaluate(r):1,h=(function(y,v,b,T){return typeof y=="number"&&y>=0&&y<=360?typeof v=="number"&&v>=0&&v<=100&&typeof b=="number"&&b>=0&&b<=100?T===void 0||typeof T=="number"&&T>=0&&T<=1?null:`Invalid hsla value [${[y,v,b,T].join(", ")}]: 'a' must be between 0 and 1.`:`Invalid hsla value [${(typeof T=="number"?[y,v,b,T]:[y,v,b]).join(", ")}]: 's', and 'l' must be between 0 and 100.`:`Invalid hsla value [${(typeof T=="number"?[y,v,b,T]:[y,v,b]).join(", ")}]: 'h' must be between 0 and 360.`})(e,i,o,c);if(h)throw new Tr(h);const f=`hsla(${e}, ${i}%, ${o}%, ${c})`,_=ai.parse(f);if(!_)throw new Tr(`Failed to parse HSLA color: ${f}`);return _}function Lm(r,e){return r in e}function nu(r,e){const i=e[r];return i===void 0?null:i}function Na(r){return{type:r}}function yh(r){if(r instanceof xl)return new Set([r.key]);let e=new Set;return r.eachChild(i=>{e=new Set([...e,...yh(i)])}),e}function ou(r){if(r instanceof jn&&r.name==="is-active-floor")return!0;let e=!1;return r.eachChild(i=>{!e&&ou(i)&&(e=!0)}),e}function zm(r){return{result:"success",value:r}}function Va(r){return{result:"error",value:r}}function lf(r,e){return!!r&&!!r.parameters&&r.parameters.includes(e)}function xh(r){return r["property-type"]==="data-driven"}function Fm(r){return lf(r.expression,"measure-light")}function cf(r){return lf(r.expression,"zoom")}function vh(r){return!!r.expression&&r.expression.interpolated}function Xs(r){return typeof r=="object"&&r!==null&&!Array.isArray(r)}function Om(r){return r}function km(r,e){const i=e.type==="color",o=r.stops&&typeof r.stops[0][0]=="object",a=o||!(o||r.property!==void 0),c=r.type||(vh(e)?"exponential":"interval");if(i&&((r={...r}).stops&&(r.stops=r.stops.map(y=>[y[0],ai.parse(y[1])])),r.default=ai.parse(r.default?r.default:e.default)),r.colorSpace&&r.colorSpace!=="rgb"&&!vl[r.colorSpace])throw new Error(`Unknown color space: ${r.colorSpace}`);let h,f,_;if(c==="exponential")h=Bm;else if(c==="interval")h=bh;else if(c==="categorical"){h=Qg,f=Object.create(null);for(const y of r.stops)f[y[0]]=y[1];_=typeof r.stops[0][0]}else{if(c!=="identity")throw new Error(`Unknown function type "${c}"`);h=Nm}if(o){const y={},v=[];for(let E=0;E<r.stops.length;E++){const C=r.stops[E],P=C[0].zoom;y[P]===void 0&&(y[P]={zoom:P,type:r.type,property:r.property,default:r.default,stops:[]},v.push(P)),y[P].stops.push([C[0].value,C[1]])}const b=[];for(const E of v)b.push([y[E].zoom,km(y[E],e)]);const T={name:"linear"};return{kind:"composite",interpolationType:T,interpolationFactor:Gn.interpolationFactor.bind(void 0,T),zoomStops:b.map(E=>E[0]),evaluate:({zoom:E},C)=>Bm({stops:b,base:r.base},e,E).evaluate(E,C)}}if(a){const y=c==="exponential"?{name:"exponential",base:r.base!==void 0?r.base:1}:null;return{kind:"camera",interpolationType:y,interpolationFactor:Gn.interpolationFactor.bind(void 0,y),zoomStops:r.stops.map(v=>v[0]),evaluate:({zoom:v})=>h(r,e,v,f,_)}}return{kind:"source",evaluate(y,v){const b=v&&v.properties?v.properties[r.property]:void 0;return b===void 0?su(r.default,e.default):h(r,e,b,f,_)}}}function su(r,e,i){return r!==void 0?r:e!==void 0?e:i!==void 0?i:void 0}function Qg(r,e,i,o,a){return su(typeof i===a?o[i]:void 0,r.default,e.default)}function bh(r,e,i){if(!Zc(i))return su(r.default,e.default);const o=r.stops.length;if(o===1||i<=r.stops[0][0])return r.stops[0][1];if(i>=r.stops[o-1][0])return r.stops[o-1][1];const a=tu(r.stops.map(c=>c[0]),i);return r.stops[a][1]}function Bm(r,e,i){const o=r.base!==void 0?r.base:1;if(!Zc(i))return su(r.default,e.default);const a=r.stops.length;if(a===1||i<=r.stops[0][0])return r.stops[0][1];if(i>=r.stops[a-1][0])return r.stops[a-1][1];const c=tu(r.stops.map(v=>v[0]),i),h=(function(v,b,T,E){const C=E-T,P=v-T;return C===0?0:b===1?P/C:(Math.pow(b,P)-1)/(Math.pow(b,C)-1)})(i,o,r.stops[c][0],r.stops[c+1][0]),f=r.stops[c][1],_=r.stops[c+1][1];let y=ct[e.type]||Om;if(r.colorSpace&&r.colorSpace!=="rgb"){const v=vl[r.colorSpace];y=(b,T)=>v.reverse(v.interpolate(v.forward(b),v.forward(T),h))}return typeof f.evaluate=="function"?{evaluate(...v){const b=f.evaluate.apply(void 0,v),T=_.evaluate.apply(void 0,v);if(b!==void 0&&T!==void 0)return y(b,T,h)}}:y(f,_,h)}function Nm(r,e,i){return e.type==="color"?i=ai.parse(i):e.type==="formatted"?i=rn.fromString(i.toString()):e.type==="resolvedImage"?i=nn.build(i.toString()):rc(i)===e.type||e.type==="enum"&&e.values[i]||(i=void 0),su(i,r.default,e.default)}jn.register(yc,{error:[{kind:"error"},[fi],(r,[e])=>{throw new Tr(e.evaluate(r))}],typeof:[fi,[pi],(r,[e])=>wr(Cr(e.evaluate(r)))],"to-rgba":[Fn(ft,4),[no],(r,[e])=>e.evaluate(r).toNonPremultipliedRenderColor(null).toArray()],"to-hsla":[Fn(ft,4),[no],(r,[e])=>e.evaluate(r).toNonPremultipliedRenderColor(null).toHslaArray()],rgb:[no,[ft,ft,ft],bl],rgba:[no,[ft,ft,ft,ft],bl],hsl:[no,[ft,ft,ft],Dm],hsla:[no,[ft,ft,ft,ft],Dm],has:{type:ci,overloads:[[[fi],(r,[e])=>Lm(e.evaluate(r),r.properties())],[[fi,$s],(r,[e,i])=>Lm(e.evaluate(r),i.evaluate(r))]]},get:{type:pi,overloads:[[[fi],(r,[e])=>nu(e.evaluate(r),r.properties())],[[fi,$s],(r,[e,i])=>nu(e.evaluate(r),i.evaluate(r))]]},"feature-state":[pi,[fi],(r,[e])=>nu(e.evaluate(r),r.featureState||{})],properties:[$s,[],r=>r.properties()],"geometry-type":[fi,[],r=>r.geometryType()],worldview:[fi,[],r=>r.globals.worldview||""],"is-active-floor":[ci,Na(fi),(r,e)=>{if(!(r.globals&&r.globals.activeFloors&&r.globals.activeFloors.size>0))return!1;if(e.length===0)return!0;const i=r.globals.activeFloors;return e.some(o=>{const a=o.evaluate(r);return i.has(a)})}],id:[pi,[],r=>r.id()],zoom:[ft,[],r=>r.globals.zoom],pitch:[ft,[],r=>r.globals.pitch||0],"distance-from-center":[ft,[],r=>r.distanceFromCenter()],"measure-light":[ft,[fi],(r,[e])=>r.measureLight(e.evaluate(r))],"heatmap-density":[ft,[],r=>r.globals.heatmapDensity||0],"line-progress":[ft,[],r=>r.globals.lineProgress||0],"raster-value":[ft,[],r=>r.globals.rasterValue||0],"raster-particle-speed":[ft,[],r=>r.globals.rasterParticleSpeed||0],"sky-radial-progress":[ft,[],r=>r.globals.skyRadialProgress||0],accumulated:[pi,[],r=>r.globals.accumulated===void 0?null:r.globals.accumulated],"+":[ft,Na(ft),(r,e)=>{let i=0;for(const o of e)i+=o.evaluate(r);return i}],"*":[ft,Na(ft),(r,e)=>{let i=1;for(const o of e)i*=o.evaluate(r);return i}],"-":{type:ft,overloads:[[[ft,ft],(r,[e,i])=>e.evaluate(r)-i.evaluate(r)],[[ft],(r,[e])=>-e.evaluate(r)]]},"/":[ft,[ft,ft],(r,[e,i])=>e.evaluate(r)/i.evaluate(r)],"%":[ft,[ft,ft],(r,[e,i])=>e.evaluate(r)%i.evaluate(r)],ln2:[ft,[],()=>Math.LN2],pi:[ft,[],()=>Math.PI],e:[ft,[],()=>Math.E],"^":[ft,[ft,ft],(r,[e,i])=>Math.pow(e.evaluate(r),i.evaluate(r))],sqrt:[ft,[ft],(r,[e])=>Math.sqrt(e.evaluate(r))],log10:[ft,[ft],(r,[e])=>Math.log(e.evaluate(r))/Math.LN10],ln:[ft,[ft],(r,[e])=>Math.log(e.evaluate(r))],log2:[ft,[ft],(r,[e])=>Math.log2(e.evaluate(r))],sin:[ft,[ft],(r,[e])=>Math.sin(e.evaluate(r))],cos:[ft,[ft],(r,[e])=>Math.cos(e.evaluate(r))],tan:[ft,[ft],(r,[e])=>Math.tan(e.evaluate(r))],asin:[ft,[ft],(r,[e])=>Math.asin(e.evaluate(r))],acos:[ft,[ft],(r,[e])=>Math.acos(e.evaluate(r))],atan:[ft,[ft],(r,[e])=>Math.atan(e.evaluate(r))],min:[ft,Na(ft),(r,e)=>Math.min(...e.map(i=>i.evaluate(r)))],max:[ft,Na(ft),(r,e)=>Math.max(...e.map(i=>i.evaluate(r)))],abs:[ft,[ft],(r,[e])=>Math.abs(e.evaluate(r))],round:[ft,[ft],(r,[e])=>{const i=e.evaluate(r);return i<0?-Math.round(-i):Math.round(i)}],floor:[ft,[ft],(r,[e])=>Math.floor(e.evaluate(r))],ceil:[ft,[ft],(r,[e])=>Math.ceil(e.evaluate(r))],"filter-==":[ci,[fi,pi],(r,[e,i])=>r.properties()[e.value]===i.value],"filter-id-==":[ci,[pi],(r,[e])=>r.id()===e.value],"filter-type-==":[ci,[fi],(r,[e])=>r.geometryType()===e.value],"filter-<":[ci,[fi,pi],(r,[e,i])=>{const o=r.properties()[e.value],a=i.value;return typeof o==typeof a&&o<a}],"filter-id-<":[ci,[pi],(r,[e])=>{const i=r.id(),o=e.value;return typeof i==typeof o&&i<o}],"filter->":[ci,[fi,pi],(r,[e,i])=>{const o=r.properties()[e.value],a=i.value;return typeof o==typeof a&&o>a}],"filter-id->":[ci,[pi],(r,[e])=>{const i=r.id(),o=e.value;return typeof i==typeof o&&i>o}],"filter-<=":[ci,[fi,pi],(r,[e,i])=>{const o=r.properties()[e.value],a=i.value;return typeof o==typeof a&&o<=a}],"filter-id-<=":[ci,[pi],(r,[e])=>{const i=r.id(),o=e.value;return typeof i==typeof o&&i<=o}],"filter->=":[ci,[fi,pi],(r,[e,i])=>{const o=r.properties()[e.value],a=i.value;return typeof o==typeof a&&o>=a}],"filter-id->=":[ci,[pi],(r,[e])=>{const i=r.id(),o=e.value;return typeof i==typeof o&&i>=o}],"filter-has":[ci,[pi],(r,[e])=>e.value in r.properties()],"filter-has-id":[ci,[],r=>r.id()!==null&&r.id()!==void 0],"filter-type-in":[ci,[Fn(fi)],(r,[e])=>e.value.includes(r.geometryType())],"filter-id-in":[ci,[Fn(pi)],(r,[e])=>e.value.includes(r.id())],"filter-in-small":[ci,[fi,Fn(pi)],(r,[e,i])=>i.value.includes(r.properties()[e.value])],"filter-in-large":[ci,[fi,Fn(pi)],(r,[e,i])=>(function(o,a,c,h){for(;c<=h;){const f=c+h>>1;if(a[f]===o)return!0;a[f]>o?h=f-1:c=f+1}return!1})(r.properties()[e.value],i.value,0,i.value.length-1)],all:{type:ci,overloads:[[[ci,ci],(r,[e,i])=>e.evaluate(r)&&i.evaluate(r)],[Na(ci),(r,e)=>{for(const i of e)if(!i.evaluate(r))return!1;return!0}]]},any:{type:ci,overloads:[[[ci,ci],(r,[e,i])=>e.evaluate(r)||i.evaluate(r)],[Na(ci),(r,e)=>{for(const i of e)if(i.evaluate(r))return!0;return!1}]]},"!":[ci,[ci],(r,[e])=>!e.evaluate(r)],"is-supported-script":[ci,[fi],(r,[e])=>{const i=r.globals&&r.globals.isSupportedScript;return!i||i(e.evaluate(r))}],upcase:[fi,[fi],(r,[e])=>e.evaluate(r).toUpperCase()],downcase:[fi,[fi],(r,[e])=>e.evaluate(r).toLowerCase()],concat:[fi,Na(pi),(r,e)=>e.map(i=>mt(i.evaluate(r))).join("")],"resolved-locale":[fi,[Jl],(r,[e])=>e.evaluate(r).resolvedLocale()],random:[ft,[ft,ft,pi],(r,e)=>{const[i,o,a]=e.map(h=>h.evaluate(r));if(i>o||i===o)return i;let c;if(typeof a=="string")c=(function(h){let f=0;if(h.length===0)return f;for(let _=0;_<h.length;_++)f=(f<<5)-f+h.charCodeAt(_),f&=f;return f})(a);else{if(typeof a!="number")throw new Tr(`Invalid seed input: ${a}`);c=a}return i+gc(c)()*(o-i)}]});class uf{constructor(e,i,o,a,c){this.expression=e,this._warningHistory={},this._scope=o,this._options=a,this._iconImageUseTheme=c,this._evaluator=new Wc(o,a,c),this._defaultValue=i?(function(h){return h.type==="color"&&(Xs(h.default)||Array.isArray(h.default))?new ai(0,0,0,0):h.type==="color"?ai.parse(h.default)||null:h.default===void 0?null:h.default})(i):null,this._enumValues=i&&i.type==="enum"?i.values:null,this.configDependencies=yh(e),this.isIndoorDependent=ou(e)}evaluateWithoutErrorHandling(e,i,o,a,c,h,f,_){return this._evaluator.globals=e,this._evaluator.feature=i,this._evaluator.featureState=o,this._evaluator.canonical=a||null,this._evaluator.availableImages=c||null,this._evaluator.formattedSection=h,this._evaluator.featureTileCoord=f||null,this._evaluator.featureDistanceData=_||null,this.expression.evaluate(this._evaluator)}evaluate(e,i,o,a,c,h,f,_,y){this._evaluator||(this._evaluator=new Wc(this._scope,this._options,this._iconImageUseTheme)),this._evaluator.globals=e,this._evaluator.feature=i||null,this._evaluator.featureState=o||null,this._evaluator.canonical=a||null,this._evaluator.availableImages=c||null,this._evaluator.formattedSection=h||null,this._evaluator.featureTileCoord=f||null,this._evaluator.featureDistanceData=_||null,this._evaluator.iconImageUseTheme=y||null;try{const v=this.expression.evaluate(this._evaluator);if(v==null||typeof v=="number"&&v!=v)return this._defaultValue;if(this._enumValues&&!(v in this._enumValues))throw new Tr(`Expected value to be one of ${Object.keys(this._enumValues).map(b=>JSON.stringify(b)).join(", ")}, but found ${JSON.stringify(v)} instead.`);return v}catch(v){const b=v;return this._warningHistory[b.message]||(this._warningHistory[b.message]=!0,typeof console<"u"&&console.warn(`Failed to evaluate expression "${JSON.stringify(this.expression.serialize())}". ${b.message}`)),this._defaultValue}}}function au(r){return Array.isArray(r)&&r.length>0&&typeof r[0]=="string"&&Object.hasOwn(yc,r[0])}function xc(r,e,i,o,a){const c=new ch(yc,[],e?(function(f){const _={color:no,string:fi,number:ft,enum:fi,boolean:ci,formatted:oo,resolvedImage:Ql};return f.type==="array"?Fn(_[f.value]||pi,f.length):_[f.type]})(e):void 0,void 0,void 0,i,o,a),h=c.parse(r,void 0,void 0,void 0,e&&e.type==="string"?{typeAnnotation:"coerce"}:void 0);return h?zm(new uf(h,e,i,o,a)):Va(c.errors)}class wh{constructor(e,i,o,a){this.kind=e,this._styleExpression=i,this.isLightConstant=o,this.isLineProgressConstant=a,this.isStateDependent=e!=="constant"&&!gl(i.expression),this.configDependencies=yh(i.expression),this.isIndoorDependent=ou(i.expression)}evaluateWithoutErrorHandling(e,i,o,a,c,h){return this._styleExpression.evaluateWithoutErrorHandling(e,i,o,a,c,h)}evaluate(e,i,o,a,c,h,f){return this._styleExpression.evaluate(e,i,o,a,c,h,void 0,void 0,f)}}class lu{constructor(e,i,o,a,c,h){this.kind=e,this.zoomStops=o,this._styleExpression=i,this.isStateDependent=e!=="camera"&&!gl(i.expression),this.isIndoorDependent=ou(i.expression),this.isLightConstant=c,this.isLineProgressConstant=h,this.configDependencies=yh(i.expression),this.interpolationType=a}evaluateWithoutErrorHandling(e,i,o,a,c,h){return this._styleExpression.evaluateWithoutErrorHandling(e,i,o,a,c,h)}evaluate(e,i,o,a,c,h){return this._styleExpression.evaluate(e,i,o,a,c,h)}interpolationFactor(e,i,o){return this.interpolationType?Gn.interpolationFactor(this.interpolationType,e,i,o):0}}function Vm(r,e,i,o,a){if((r=xc(r,e,i,o,a)).result==="error")return r;const c=r.value.expression,h=Fa(c);if(!h&&!xh(e))return Va([new zo("","data expressions not supported")]);const f=Oa(c,["zoom","pitch","distance-from-center"]);if(!f&&!cf(e))return Va([new zo("","zoom expressions not supported")]);const _=Oa(c,["measure-light"]);if(!_&&!Fm(e))return Va([new zo("","measure-light expression not supported")]);const y=Oa(c,["line-progress"]);if(!y&&!(function(T){return lf(T.expression,"line-progress")})(e))return Va([new zo("","line-progress expression not supported")]);const v=e.expression&&e.expression.relaxZoomRestriction,b=$n(c);return b||f||v?b instanceof zo?Va([b]):b instanceof Gn&&!vh(e)?Va([new zo("",'"interpolate" expressions cannot be used with this property')]):zm(b?new lu(h&&y?"camera":"composite",r.value,b.labels,b instanceof Gn?b.interpolation:void 0,_,y):new wh(h&&y?"constant":"source",r.value,_,y)):Va([new zo("",'"zoom" expression may only be used as input to a top-level "step" or "interpolate" expression, or in the properties of atmosphere.')])}class Th{constructor(e,i){this._parameters=e,this._specification=i,Object.assign(this,km(this._parameters,this._specification))}static deserialize(e){return new Th(e._parameters,e._specification)}static serialize(e){return{_parameters:e._parameters,_specification:e._specification}}}function $n(r){let e=null;if(r instanceof fh)e=$n(r.result);else if(r instanceof dh){for(const i of r.args)if(e=$n(i),e)break}else(r instanceof ka||r instanceof Gn)&&r.input instanceof jn&&r.input.name==="zoom"&&(e=r);return e instanceof zo||r.eachChild(i=>{const o=$n(i);o instanceof zo?e=o:e&&o&&e!==o&&(e=new zo("",'Only one zoom-based "step" or "interpolate" subexpression may be used in an expression.'))}),e}class vc{constructor(e,i,o){if(this.boxSeen=new Uint32Array(0),this.circleSeen=new Uint32Array(0),this.generation=0,e instanceof ArrayBuffer){const a=new Int32Array(e);this.width=a[0],this.height=a[1],this.xCellCount=a[2],this.yCellCount=a[3],this.boxUid=a[4],this.circleUid=a[5];const c=this.xCellCount*this.yCellCount,h=[];for(let v=0;v<c;v++){const b=a[6+v],T=a[6+v+1];h.push(b===T?null:a.subarray(b,T))}const f=a[6+c],_=[];for(let v=0;v<c;v++){const b=a[f+v],T=a[f+v+1];_.push(b===T?null:a.subarray(b,T))}let y=a[f+c];this.boxCells=h,this.circleCells=_,this.boxKeys=a.subarray(y,y+this.boxUid),y+=this.boxUid,this.circleKeys=a.subarray(y,y+this.circleUid),y+=this.circleUid,this.bboxes=a.subarray(y,y+4*this.boxUid),y+=4*this.boxUid,this.circles=a.subarray(y,y+3*this.circleUid)}else{this.width=e,this.height=i,this.xCellCount=Math.ceil(e/o),this.yCellCount=Math.ceil(i/o);const a=this.xCellCount*this.yCellCount,c=[],h=[];for(let f=0;f<a;f++)c.push([]),h.push([]);this.boxCells=c,this.circleCells=h,this.boxKeys=[],this.circleKeys=[],this.bboxes=[],this.circles=[],this.boxUid=0,this.circleUid=0}this.xScale=this.xCellCount/this.width,this.yScale=this.yCellCount/this.height}keysLength(){return this.boxKeys.length+this.circleKeys.length}clear(){for(const e of this.boxCells)e&&(e.length=0);for(const e of this.circleCells)e&&(e.length=0);this.circleKeys.length=0,this.boxKeys.length=0,this.bboxes.length=0,this.circles.length=0,this.boxUid=0,this.circleUid=0}insert(e,i,o,a,c){const h=this.boxUid++,f=this._xCell(i),_=this._yCell(o),y=this._xCell(a),v=this._yCell(c);for(let b=f;b<=y;b++)for(let T=_;T<=v;T++)this.boxCells[this.xCellCount*T+b].push(h);this.boxKeys.push(e),this.bboxes.push(i,o,a,c)}insertCircle(e,i,o,a){const c=this.circleUid++,h=this._xCell(i-a),f=this._yCell(o-a),_=this._xCell(i+a),y=this._yCell(o+a);for(let v=h;v<=_;v++)for(let b=f;b<=y;b++)this.circleCells[this.xCellCount*b+v].push(c);this.circleKeys.push(e),this.circles.push(i,o,a)}query(e,i,o,a,c){const h=[];if(o<0||e>this.width||a<0||i>this.height)return h;const f=this._nextGen(),{boxCells:_,circleCells:y,boxKeys:v,circleKeys:b,bboxes:T,circles:E,boxSeen:C,circleSeen:P,xCellCount:R}=this,z=this._xCell(e),V=this._yCell(i),N=this._xCell(o),U=this._yCell(a);for(let q=z;q<=N;q++)for(let W=V;W<=U;W++){const se=R*W+q,X=_[se];if(X)for(let re=0;re<X.length;re++){const oe=X[re];if(C[oe]===f)continue;C[oe]=f;const me=4*oe,xe=T[me],we=T[me+1],Ce=T[me+2],Se=T[me+3];e<=Ce&&i<=Se&&o>=xe&&a>=we&&(!c||c(v[oe]))&&h.push({key:v[oe],x1:xe,y1:we,x2:Ce,y2:Se})}const ie=y[se];if(ie)for(let re=0;re<ie.length;re++){const oe=ie[re];if(P[oe]===f)continue;P[oe]=f;const me=3*oe,xe=E[me],we=E[me+1],Ce=E[me+2];!this._circleAndRectCollide(xe,we,Ce,e,i,o,a)||c&&!c(b[oe])||h.push({key:b[oe],x1:xe-Ce,y1:we-Ce,x2:xe+Ce,y2:we+Ce})}}return h}queryKeys(e,i,o,a,c){const h=[];if(o<0||e>this.width||a<0||i>this.height)return h;const f=this._nextGen(),{boxCells:_,boxKeys:y,bboxes:v,boxSeen:b,xCellCount:T,xScale:E,yScale:C}=this,P=this._xCell(e),R=this._yCell(i),z=this._xCell(o),V=this._yCell(a);for(let N=P;N<=z;N++)for(let U=R;U<=V;U++){if(c&&!c(N/E,U/C,(N+1)/E,(U+1)/C))continue;const q=_[T*U+N];if(q)for(let W=0;W<q.length;W++){const se=q[W];if(b[se]===f)continue;b[se]=f;const X=4*se,ie=v[X],re=v[X+1],oe=v[X+2],me=v[X+3];(c?c(ie,re,oe,me):e<=oe&&i<=me&&o>=ie&&a>=re)&&h.push(y[se])}}return h}hitTest(e,i,o,a,c){if(o<0||e>this.width||a<0||i>this.height)return!1;const h=this._nextGen(),{boxCells:f,circleCells:_,boxKeys:y,circleKeys:v,bboxes:b,circles:T,boxSeen:E,circleSeen:C,xCellCount:P}=this,R=this._xCell(e),z=this._yCell(i),V=this._xCell(o),N=this._yCell(a);for(let U=R;U<=V;U++)for(let q=z;q<=N;q++){const W=P*q+U,se=f[W];if(se)for(let ie=0;ie<se.length;ie++){const re=se[ie];if(E[re]===h)continue;E[re]=h;const oe=4*re;if(e<=b[oe+2]&&i<=b[oe+3]&&o>=b[oe]&&a>=b[oe+1]&&(!c||c(y[re])))return!0}const X=_[W];if(X)for(let ie=0;ie<X.length;ie++){const re=X[ie];if(C[re]===h)continue;C[re]=h;const oe=3*re;if(this._circleAndRectCollide(T[oe],T[oe+1],T[oe+2],e,i,o,a)&&(!c||c(v[re])))return!0}}return!1}hitTestCircle(e,i,o,a){const c=e-o,h=i-o,f=e+o,_=i+o;if(f<0||c>this.width||_<0||h>this.height)return!1;const y=this._nextGen(),{boxCells:v,circleCells:b,boxKeys:T,circleKeys:E,bboxes:C,circles:P,boxSeen:R,circleSeen:z,xCellCount:V}=this,N=this._xCell(c),U=this._yCell(h),q=this._xCell(f),W=this._yCell(_);for(let se=N;se<=q;se++)for(let X=U;X<=W;X++){const ie=V*X+se,re=v[ie];if(re)for(let me=0;me<re.length;me++){const xe=re[me];if(R[xe]===y)continue;R[xe]=y;const we=4*xe;if(this._circleAndRectCollide(e,i,o,C[we],C[we+1],C[we+2],C[we+3])&&(!a||a(T[xe])))return!0}const oe=b[ie];if(oe)for(let me=0;me<oe.length;me++){const xe=oe[me];if(z[xe]===y)continue;z[xe]=y;const we=3*xe;if(this._circlesCollide(P[we],P[we+1],P[we+2],e,i,o)&&(!a||a(E[xe])))return!0}}return!1}static serialize(e,i){const o=e.toArrayBuffer();return i&&i.add(o),{buffer:o}}static deserialize(e){return new vc(e.buffer)}toArrayBuffer(){const e=this.xCellCount*this.yCellCount;let i=0,o=0;for(let f=0;f<e;f++)i+=this.boxCells[f].length,o+=this.circleCells[f].length;const a=new Int32Array(6+(e+1)+i+(e+1)+o+this.boxUid+this.circleUid+4*this.boxUid+3*this.circleUid);a[0]=this.width,a[1]=this.height,a[2]=this.xCellCount,a[3]=this.yCellCount,a[4]=this.boxUid,a[5]=this.circleUid;let c=6+(e+1);for(let f=0;f<e;f++){a[6+f]=c;const _=this.boxCells[f];a.set(_,c),c+=_.length}a[6+e]=c;const h=c;c+=e+1;for(let f=0;f<e;f++){a[h+f]=c;const _=this.circleCells[f];a.set(_,c),c+=_.length}return a[h+e]=c,a.set(this.boxKeys,c),c+=this.boxUid,a.set(this.circleKeys,c),c+=this.circleUid,a.set(this.bboxes,c),c+=4*this.boxUid,a.set(this.circles,c),a.buffer}_xCell(e){return Math.max(0,Math.min(this.xCellCount-1,Math.floor(e*this.xScale)))}_yCell(e){return Math.max(0,Math.min(this.yCellCount-1,Math.floor(e*this.yScale)))}_nextGen(){return this.boxSeen.length<this.boxUid&&(this.boxSeen=new Uint32Array(this.boxUid)),this.circleSeen.length<this.circleUid&&(this.circleSeen=new Uint32Array(this.circleUid)),this.generation=this.generation+1>>>0,this.generation===0&&(this.boxSeen.fill(0),this.circleSeen.fill(0),this.generation=1),this.generation}_circlesCollide(e,i,o,a,c,h){const f=a-e,_=c-i,y=o+h;return y*y>f*f+_*_}_circleAndRectCollide(e,i,o,a,c,h,f){const _=(h-a)/2,y=Math.abs(e-(a+_));if(y>_+o)return!1;const v=(f-c)/2,b=Math.abs(i-(c+v));if(b>v+o)return!1;if(y<=_||b<=v)return!0;const T=y-_,E=b-v;return T*T+E*E<=o*o}}const Ua={};function nt(r,e,i={}){Object.defineProperty(r,"_classRegistryKey",{value:e,writable:!1}),Ua[e]={klass:r,omit:i.omit||[]}}nt(Object,"Object"),nt(vc,"Grid"),delete Ue.prototype.constructor,nt(ai,"Color"),nt(rn,"Formatted"),nt(fl,"FormattedSection"),nt(nn,"ResolvedImage"),nt(Th,"StylePropertyFunction"),nt(uf,"StyleExpression",{omit:["_evaluator"]}),nt(po,"ImageId"),nt(Fo,"ImageVariant"),nt(lu,"ZoomDependentExpression"),nt(wh,"ZoomConstantExpression"),nt(jn,"CompoundExpression",{omit:["_evaluate"]});for(const r in yc)Ua[yc[r]._classRegistryKey]||nt(yc[r],`Expression${r}`);function Um(r){return r&&(r instanceof ArrayBuffer||r.constructor&&r.constructor.name==="ArrayBuffer")}const hf={Error,TypeError,RangeError,SyntaxError,ReferenceError,URIError,EvalError},jm=new Set(["message","stack","cause","errors","name","class"]);function Bo(r,e){if(r===null)return null;const i=typeof r;if(i!=="object")return i==="bigint"?{$name:"BigInt",value:r.toString()}:r;if(Array.isArray(r)){const h=r.length,f=[];f.length=h;for(let _=0;_<h;_++)f[_]=Bo(r[_],e);return f}if(ArrayBuffer.isView(r))return e&&e.add(r.buffer),r;if(Um(r)||r instanceof ImageBitmap)return e&&e.add(r),r;if(r instanceof ImageData)return e&&e.add(r.data.buffer),r;if(r instanceof Map){const h={$name:"Map",entries:[]};for(const[f,_]of r.entries())h.entries.push(Bo(f),Bo(_,e));return h}if(r instanceof Headers)return{$name:"Headers",entries:[...r]};if(r instanceof Set){const h={$name:"Set"};let f=0;for(const _ of r.values())h[++f]=Bo(_);return h}if(r instanceof Date||r instanceof RegExp||r instanceof Boolean||r instanceof Number||r instanceof String)return r;if(r instanceof Error){const h=r,f=h.constructor&&h.constructor.name||"Error",_={$name:"$Error",class:h instanceof Gc?"AJAXError":h instanceof DOMException?"DOMException":h instanceof AggregateError?"AggregateError":hf[f]?f:"Error",name:h.name,message:h.message};h.stack&&(_.stack=h.stack),"cause"in h&&h.cause!==h&&(_.cause=Bo(h.cause,e)),h instanceof AggregateError&&(_.errors=h.errors.filter(v=>v!==h).map(v=>Bo(v,e)));const y=h;for(const v in y)Object.hasOwn(y,v)&&(jm.has(v)||(_[v]=Bo(y[v],e)));return _}const o=r.constructor||Object,a=o._classRegistryKey;if(!a)throw new Error(`Can't serialize object of unregistered class "${o.name}".`);const c=o.serialize?o.serialize(r,e):{};if(!o.serialize){const h=Ua[a].omit,f=r;for(const _ in f)Object.hasOwn(f,_)&&(h.includes(_)||(c[_]=Bo(f[_],e)))}if(c.$name)throw new Error("$name property is reserved for worker serialization logic.");return a!=="Object"&&(c.$name=a),c}function As(r){if(r===null||typeof r!="object")return r;if(Array.isArray(r)){for(let a=0;a<r.length;a++)r[a]=As(r[a]);return r}if(ArrayBuffer.isView(r)||Um(r)||r instanceof ImageBitmap||r instanceof ImageData||r instanceof Date||r instanceof RegExp||r instanceof Boolean||r instanceof Number||r instanceof String)return r;const e=r.$name||"Object";if(e==="Map"){const a=r.entries||[],c=new Map;for(let h=0;h<a.length;h+=2)c.set(As(a[h]),As(a[h+1]));return c}if(e==="Headers")return new Headers(r.entries);if(e==="Set"){const a=new Set;for(const c in r)c!=="$name"&&a.add(As(r[c]));return a}if(e==="BigInt")return BigInt(r.value);if(e==="$Error"){const a=r.class||"Error",c=r.name||a,h=r.message||"";let f;f=a==="DOMException"?new DOMException(h,c):a==="AggregateError"?new AggregateError((r.errors||[]).map(As),h):a==="AJAXError"?new Gc(r.statusText,r.status,r.url):new(hf[a]||Error)(h),a!=="DOMException"&&(f.name=c),r.stack&&(f.stack=r.stack),"cause"in r&&(f.cause=As(r.cause));const _=f;for(const y in r)Object.hasOwn(r,y)&&(y==="$name"||jm.has(y)||(_[y]=As(r[y])));return f}const{klass:i}=Ua[e];if(!i)throw new Error(`Can't deserialize unregistered class "${e}".`);if(i.deserialize)return i.deserialize(r);const o=Object.create(i.prototype);for(const a in r)a!=="$name"&&(o[a]=As(r[a]));return o}const cu=r=>r>=1536&&r<=1791,df=r=>r>=1872&&r<=1919,ff=r=>r>=2208&&r<=2303,Sh=r=>r>=11904&&r<=12031,pf=r=>r>=12032&&r<=12255,mf=r=>r>=12272&&r<=12287,bc=r=>r>=12288&&r<=12351,uu=r=>r>=12352&&r<=12447,wl=r=>r>=12448&&r<=12543,_f=r=>r>=12544&&r<=12591,gf=r=>r>=12704&&r<=12735,yf=r=>r>=12736&&r<=12783,xf=r=>r>=12784&&r<=12799,wc=r=>r>=12800&&r<=13055,Gm=r=>r>=13056&&r<=13311,vf=r=>r>=13312&&r<=19903,Eh=r=>r>=19968&&r<=40959,$m=r=>r>=40960&&r<=42127,qm=r=>r>=42128&&r<=42191,bf=r=>r>=44032&&r<=55215,wf=r=>r>=63744&&r<=64255,Ih=r=>r>=64336&&r<=65023,Hm=r=>r>=65040&&r<=65055,jt=r=>r>=65072&&r<=65103,hu=r=>r>=65104&&r<=65135,du=r=>r>=65136&&r<=65279,fu=r=>r>=65280&&r<=65519;function Tl(r){for(const e of r)if(Ch(e.charCodeAt(0)))return!0;return!1}function Zm(r){for(const e of r)if(!Wm(e.charCodeAt(0)))return!1;return!0}function Wm(r){return!(cu(r)||df(r)||ff(r)||Ih(r)||du(r))}function Ah(r){return!(r<11904||!(gf(r)||_f(r)||jt(r)||wf(r)||Gm(r)||Sh(r)||yf(r)||bc(r)||vf(r)||Eh(r)||wc(r)||fu(r)||uu(r)||mf(r)||pf(r)||xf(r)||wl(r)||Hm(r)||qm(r)||$m(r)))}function Ch(r){return!(r!==746&&r!==747&&(r<4352||!(gf(r)||_f(r)||jt(r)&&!(r>=65097&&r<=65103)||wf(r)||Gm(r)||Sh(r)||yf(r)||!(!bc(r)||r>=12296&&r<=12305||r>=12308&&r<=12319||r===12336)||vf(r)||Eh(r)||wc(r)||(e=>e>=12592&&e<=12687)(r)||(e=>e>=43360&&e<=43391)(r)||(e=>e>=55216&&e<=55295)(r)||(e=>e>=4352&&e<=4607)(r)||bf(r)||uu(r)||mf(r)||(e=>e>=12688&&e<=12703)(r)||pf(r)||xf(r)||wl(r)&&r!==12540||!(!fu(r)||r===65288||r===65289||r===65293||r>=65306&&r<=65310||r===65339||r===65341||r===65343||r>=65371&&r<=65503||r===65507||r>=65512&&r<=65519)||!(!hu(r)||r>=65112&&r<=65118||r>=65123&&r<=65126)||(e=>e>=5120&&e<=5759)(r)||(e=>e>=6320&&e<=6399)(r)||Hm(r)||(e=>e>=19904&&e<=19967)(r)||$m(r)||qm(r))))}function Mh(r){return r===12307||r===12312||r===12313||r===12316||r===12448||r===12540||r>=8592&&r<=8595||r===8208||r===8213||r===8229||r===8741||r>=9472&&r<=9547||r===65294||r===65309||r===65374||r===65507}function No(r){return!(Ch(r)||(function(e){return!!((i=>i>=128&&i<=255)(e)&&(e===167||e===169||e===174||e===177||e===188||e===189||e===190||e===215||e===247)||(i=>i>=8192&&i<=8303)(e)&&(e===8214||e===8224||e===8225||e===8240||e===8241||e===8251||e===8252||e===8258||e===8263||e===8264||e===8265||e===8273)||(i=>i>=8448&&i<=8527)(e)||(i=>i>=8528&&i<=8591)(e)||(i=>i>=8960&&i<=9215)(e)&&(e>=8960&&e<=8967||e>=8972&&e<=8991||e>=8996&&e<=9e3||e===9003||e>=9085&&e<=9114||e>=9150&&e<=9165||e===9167||e>=9169&&e<=9179||e>=9186&&e<=9215)||(i=>i>=9216&&i<=9279)(e)&&e!==9251||(i=>i>=9280&&i<=9311)(e)||(i=>i>=9312&&i<=9471)(e)||(i=>i>=9632&&i<=9727)(e)||(i=>i>=9728&&i<=9983)(e)&&!(e>=9754&&e<=9759)||(i=>i>=11008&&i<=11263)(e)&&(e>=11026&&e<=11055||e>=11088&&e<=11097||e>=11192&&e<=11243)||bc(e)||wl(e)||(i=>i>=57344&&i<=63743)(e)||jt(e)||hu(e)||fu(e)||e===8734||e===8756||e===8757||e>=9984&&e<=10087||e>=10102&&e<=10131||e===65532||e===65533)})(r))}function Tf(r){return cu(r)||df(r)||ff(r)||Ih(r)||du(r)}function Ph(r){return r>=1424&&r<=2303||Ih(r)||du(r)}function Xm(r,e){return!(!e&&Ph(r)||r>=2304&&r<=3583||r>=3840&&r<=4255||(i=>i>=6016&&i<=6143)(r))}function Ym(r){for(const e of r)if(Ph(e.charCodeAt(0)))return!0;return!1}const so={unavailable:"unavailable",deferred:"deferred",loading:"loading",parsing:"parsing",parsed:"parsed",loaded:"loaded",error:"error"};let Sf=null,qn=so.unavailable,ja=null;const Ef=function(r){r&&(qn=so.error),Sf&&Sf(r)};function If(){Sl.fire(new Lo("pluginStateChange",{pluginStatus:qn,pluginURL:ja}))}const Sl=new dl,Rh=function(){return qn},Km=function(){if(qn!==so.deferred||!ja)throw new Error("rtl-text-plugin cannot be downloaded unless a pluginURL is specified");qn=so.loading,If(),ja&&Yl({url:ja}).then(()=>{qn=so.loaded,If()}).catch(r=>{Ef(r)})},Ys={applyArabicShaping:null,processBidirectionalText:null,processStyledBidirectionalText:null,isLoaded:()=>qn===so.loaded||Ys.applyArabicShaping!=null,isLoading:()=>qn===so.loading,setState(r){qn=r.pluginStatus,ja=r.pluginURL},isParsing:()=>qn===so.parsing,isParsed:()=>qn===so.parsed,getPluginURL:()=>ja};class xt{constructor(e,i){this.zoom=e,i?(this.now=i.now,this.fadeDuration=i.fadeDuration,this.transition=i.transition,this.pitch=i.pitch,this.brightness=i.brightness,this.worldview=i.worldview,this.activeFloors=i.activeFloors):(this.now=0,this.fadeDuration=0,this.transition={},this.pitch=0,this.brightness=0)}isSupportedScript(e){return(function(i,o){for(const a of i)if(!Xm(a.charCodeAt(0),o))return!1;return!0})(e,Ys.isLoaded())}}class pu{constructor(e,i,o,a,c){this.property=e,this.value=i,this.expression=(function(h,f,_,y,v){if(Xs(h))return new Th(h,f);if(au(h)||Array.isArray(h)&&h.length>0){const b=Vm(h,f,_,y,v);if(b.result==="error")throw new Error(b.value.map(T=>`${T.key}: ${T.message}`).join(", "));return b.value}{let b=h;return typeof h=="string"&&f.type==="color"&&(b=ai.parse(h)),{kind:"constant",configDependencies:new Set,isIndoorDependent:!1,evaluate:()=>b}}})(i===void 0?e.specification.default:i,e.specification,o,a,c)}isIndoorDependent(){return this.expression.isIndoorDependent}isDataDriven(){return this.expression.kind==="source"||this.expression.kind==="composite"}possiblyEvaluate(e,i,o,a){return this.property.possiblyEvaluate(this,e,i,o,a)}}class Dh{constructor(e,i,o,a){this.property=e,this.value=new pu(e,void 0,i,o,a)}transitioned(e,i){return new Qm(this.property,this.value,i,{...e.transition,...this.transition},e.now)}untransitioned(){return new Qm(this.property,this.value,null,{},0)}}class Jm{constructor(e,i,o,a){this._properties=e,this._values=Object.create(e.defaultTransitionablePropertyValues),this._scope=i,this._options=o,this._iconImageUseTheme=a,this._isIndoorDependent=!1,this.configDependencies=new Set}getValue(e){return it(this._values[e].value.value)}setValue(e,i){Object.hasOwn(this._values,e)||(this._values[e]=new Dh(this._values[e].property,this._scope,this._options,this._iconImageUseTheme)),this._values[e].value=new pu(this._values[e].property,i===null?void 0:it(i),this._scope,this._options,this._iconImageUseTheme),this._values[e].value.expression.configDependencies&&(this.configDependencies=new Set([...this.configDependencies,...this._values[e].value.expression.configDependencies]),this._isIndoorDependent=this._isIndoorDependent||this._values[e].value.isIndoorDependent())}setTransitionOrValue(e,i){i&&(this._options=i);const o=this._properties.properties;if(e)for(const a in e){const c=e[a];if(a.endsWith("-transition")){const h=a.slice(0,-11);o[h]&&this.setTransition(h,c)}else Object.hasOwn(o,a)&&this.setValue(a,c)}}getTransition(e){return it(this._values[e].transition)}setTransition(e,i){Object.hasOwn(this._values,e)||(this._values[e]=new Dh(this._values[e].property)),this._values[e].transition=it(i)||void 0}serialize(){const e={};for(const i of Object.keys(this._values)){const o=this.getValue(i);o!==void 0&&(e[i]=o);const a=this.getTransition(i);a!==void 0&&(e[`${i}-transition`]=a)}return e}transitioned(e,i){const o=new mu(this._properties);for(const a of Object.keys(this._values))o._values[a]=this._values[a].transitioned(e,i._values[a]);return o}untransitioned(){const e=new mu(this._properties);for(const i of Object.keys(this._values))e._values[i]=this._values[i].untransitioned();return e}isIndoorDependent(){return this._isIndoorDependent}}class Qm{constructor(e,i,o,a,c){const h=a.delay||0,f=a.duration||0;c=c||0,this.property=e,this.value=i,this.begin=c+h,this.end=this.begin+f,e.specification.transition&&(a.delay||a.duration)&&(this.prior=o)}possiblyEvaluate(e,i,o){const a=e.now||0,c=this.value.possiblyEvaluate(e,i,o),h=this.prior;if(h){if(a>this.end)return this.prior=null,c;if(this.value.isDataDriven())return this.prior=null,c;if(a<this.begin)return h.possiblyEvaluate(e,i,o);{const f=(a-this.begin)/(this.end-this.begin);return this.property.interpolate(h.possiblyEvaluate(e,i,o),c,O(f))}}return c}}class mu{constructor(e){this._properties=e,this._values=Object.create(e.defaultTransitioningPropertyValues)}possiblyEvaluate(e,i,o){const a=new Ks(this._properties);for(const c of Object.keys(this._values))a._values[c]=this._values[c].possiblyEvaluate(e,i,o);return a}hasTransition(){for(const e of Object.keys(this._values))if(this._values[e].prior)return!0;return!1}}class Tc{constructor(e,i,o,a){this._properties=e,this._values=Object.create(e.defaultPropertyValues),this._scope=i,this._options=o,this._iconImageUseTheme=a,this._isIndoorDependent=!1,this.configDependencies=new Set}getValue(e){return it(this._values[e].value)}setValue(e,i){this._values[e]=new pu(this._values[e].property,i===null?void 0:it(i),this._scope,this._options,this._iconImageUseTheme),this._values[e].expression.configDependencies&&(this.configDependencies=new Set([...this.configDependencies,...this._values[e].expression.configDependencies]),this._isIndoorDependent=this._isIndoorDependent||this._values[e].isIndoorDependent())}serialize(){const e={};for(const i of Object.keys(this._values)){const o=this.getValue(i);o!==void 0&&(e[i]=o)}return e}possiblyEvaluate(e,i,o,a){const c=new Ks(this._properties);for(const h of Object.keys(this._values))c._values[h]=this._values[h].possiblyEvaluate(e,i,o,a);return c}isIndoorDependent(){return this._isIndoorDependent}}class ns{constructor(e,i,o,a){this.property=e,this.value=i,this.parameters=o,this.iconImageUseTheme=a}isConstant(){return this.value.kind==="constant"}constantOr(e){return this.value.kind==="constant"?this.value.value:e}evaluate(e,i,o,a,c){return this.property.evaluate(this.value,this.parameters,e,i,o,a,this.iconImageUseTheme,c)}}class Ks{constructor(e){this._properties=e,this._values=Object.create(e.defaultPossiblyEvaluatedValues)}get(e){return this._values[e]}}class We{constructor(e){this.specification=e}possiblyEvaluate(e,i){return e.expression.evaluate(i)}interpolate(e,i,o){const a=ct[this.specification.type];return a?a(e,i,o):e}}class Xe{constructor(e,i){this.specification=e,this.overrides=i}possiblyEvaluate(e,i,o,a,c){return e.expression.kind==="constant"||e.expression.kind==="camera"?new ns(this,{kind:"constant",value:e.expression.evaluate(i,null,{},o,a,void 0,c)},i):new ns(this,e.expression,i,c)}interpolate(e,i,o){if(e.value.kind!=="constant"||i.value.kind!=="constant")return e;if(e.value.value===void 0||i.value.value===void 0)return new ns(this,{kind:"constant",value:void 0},e.parameters);const a=ct[this.specification.type];return a?new ns(this,{kind:"constant",value:a(e.value.value,i.value.value,o)},e.parameters):e}evaluate(e,i,o,a,c,h,f,_){return e.kind==="constant"?e.value:e.evaluate(i,o,a,c,h,_,f)}}class El{constructor(e){this.specification=e}possiblyEvaluate(e,i,o,a){return!!e.expression.evaluate(i,null,{},o,a)}interpolate(){return!1}}class Vi{constructor(e){this.properties=e,this.defaultPropertyValues={},this.defaultTransitionablePropertyValues={},this.defaultTransitioningPropertyValues={},this.defaultPossiblyEvaluatedValues={},this.overridableProperties=[];const i=new xt(0,{});for(const o in e){const a=e[o],c=a.specification;c&&c.overridable&&this.overridableProperties.push(o);const h=this.defaultPropertyValues[o]=new pu(a,void 0),f=this.defaultTransitionablePropertyValues[o]=new Dh(a);this.defaultTransitioningPropertyValues[o]=f.untransitioned(),this.defaultPossiblyEvaluatedValues[o]=h.possiblyEvaluate(i)}}}nt(Xe,"DataDrivenProperty"),nt(We,"DataConstantProperty"),nt(El,"ColorRampProperty");var _e=JSON.parse('{"expression":1,"transition":{"duration":{"type":"number","default":300,"minimum":0},"delay":{"type":"number","default":0,"minimum":0}},"appearance":{"condition":{"type":"boolean","expression":{"interpolated":1,"parameters":["distance-from-center","feature","feature-state","measure-light","pitch","zoom"]},"property-type":"data-driven"},"name":{"type":"string"},"properties":{"type":"*"}},"function":{"type":{"type":"enum","default":"exponential","values":{"identity":1,"exponential":1,"interval":1,"categorical":1}},"default":{"type":"*"},"expression":1,"stops":{"type":"array","value":"function_stop"},"base":{"type":"number","default":1,"minimum":0},"property":{"type":"string","default":"$zoom"},"colorSpace":{"type":"enum","default":"rgb","values":{"rgb":1,"lab":1,"hcl":1}}},"$version":8,"$root":{"transition":{"type":"transition"},"version":{"type":"enum","values":[8]},"fragment":{"type":"boolean"},"name":{"type":"string"},"metadata":{"type":"*"},"center":{"type":"array","value":"number"},"zoom":{"type":"number"},"bearing":{"type":"number","default":0},"pitch":{"type":"number","default":0},"light":{"type":"light"},"lights":{"type":"array","value":"light-3d"},"terrain":{"type":"terrain","optional":true},"fog":{"type":"fog"},"snow":{"type":"snow"},"rain":{"type":"rain"},"camera":{"type":"camera"},"color-theme":{"type":"colorTheme"},"indoor":{"type":"indoor"},"imports":{"type":"array","value":"import"},"iconsets":{"type":"iconsets"},"schema":{"type":"schema"},"sources":{"type":"sources"},"sprite":{"type":"string"},"glyphs":{"type":"string","default":"mapbox://fonts/mapbox/{fontstack}/{range}.pbf"},"projection":{"type":"projection"},"layers":{"type":"array","value":"layer"},"models":{"type":"models"},"featuresets":{"type":"featuresets"}},"featuresets":{"*":{"type":"featureset"}},"featureset":{"metadata":{"type":"*"},"selectors":{"type":"array","value":"selector"}},"selector":{"layer":{"type":"string"},"properties":{"type":"selectorProperty"},"featureNamespace":{"type":"string"},"_uniqueFeatureID":{"type":"boolean"}},"selectorProperty":{"*":{"type":"*"}},"model":{"type":"string"},"import":{"id":{"type":"string"},"url":{"type":"string"},"config":{"type":"config"},"data":{"type":"$root"},"color-theme":{"type":"colorTheme","optional":true}},"config":{"*":{"type":"*"}},"schema":{"*":{"type":"option"}},"option":{"type":{"type":"enum","values":{"string":1,"number":1,"boolean":1,"color":1
vendor: 41,124 bytes, line 1
1}},"default":{"type":"*","expression":1},"values":{"type":"array","value":"*"},"array":{"type":"boolean"},"minValue":{"type":"number"},"maxValue":{"type":"number"},"stepValue":{"type":"number"},"metadata":{"type":"*"}},"models":{"*":{"type":"model"}},"light-3d":{"type":{"type":"enum","values":{"ambient":{},"directional":{},"flat":{}}},"id":{"type":"string"},"properties":{"type":"properties"}},"properties":["properties_light_directional","properties_light_ambient","properties_light_flat"],"properties_light_directional":{"direction":{"type":"array","default":[210,30],"minimum":[0,0],"maximum":[360,90],"length":2,"value":"number","expression":{"interpolated":1,"parameters":["zoom"]},"transition":1},"color":{"type":"color","default":"#ffffff","expression":{"interpolated":1,"parameters":["zoom"]},"transition":1,"use-theme":1},"intensity":{"type":"number","default":0.5,"minimum":0,"maximum":1,"expression":{"interpolated":1,"parameters":["zoom"]},"transition":1},"cast-shadows":{"type":"boolean","default":false},"shadow-quality":{"type":"number","default":1,"minimum":0,"maximum":1,"expression":{"parameters":["zoom"]}},"shadow-intensity":{"type":"number","default":1,"minimum":0,"maximum":1,"expression":{"interpolated":1,"parameters":["zoom"]},"transition":1},"shadow-draw-before-layer":{"type":"string"}},"properties_light_ambient":{"color":{"type":"color","default":"#ffffff","expression":{"interpolated":1,"parameters":["zoom"]},"transition":1,"use-theme":1},"intensity":{"type":"number","default":0.5,"minimum":0,"maximum":1,"expression":{"interpolated":1,"parameters":["zoom"]},"transition":1}},"properties_light_flat":{"anchor":{"type":"enum","default":"viewport","values":{"map":1,"viewport":1},"expression":{"parameters":["zoom"]}},"position":{"type":"array","default":[1.15,210,30],"length":3,"value":"number","expression":{"interpolated":1,"parameters":["zoom"]},"transition":1},"color":{"type":"color","default":"#ffffff","expression":{"interpolated":1,"parameters":["zoom"]},"transition":1,"use-theme":1},"intensity":{"type":"number","default":0.5,"minimum":0,"maximum":1,"expression":{"interpolated":1,"parameters":["zoom"]},"transition":1}},"iconsets":{"*":{"type":"iconset"}},"iconset":["iconset_sprite","iconset_source"],"iconset_sprite":{"type":{"type":"enum","values":{"sprite":1}},"url":{"type":"string"}},"iconset_source":{"type":{"type":"enum","values":{"source":1}},"source":{"type":"string"}},"sources":{"*":{"type":"source"}},"source":["source_vector","source_raster","source_raster_dem","source_raster_array","source_geojson","source_video","source_image","source_model"],"source_vector":{"type":{"type":"enum","values":{"vector":1}},"url":{"type":"string"},"tiles":{"type":"array","value":"string"},"bounds":{"type":"array","default":[-180,-85.051129,180,85.051129],"length":4,"value":"number"},"extra_bounds":{"type":"array","value":{"type":"array","length":4,"value":"number"}},"scheme":{"type":"enum","default":"xyz","values":{"xyz":1,"tms":1}},"minzoom":{"type":"number","default":0},"maxzoom":{"type":"number","default":22},"attribution":{"type":"string"},"promoteId":{"type":"promoteId"},"volatile":{"type":"boolean","default":false},"*":{"type":"*"}},"source_raster":{"type":{"type":"enum","values":{"raster":1}},"url":{"type":"string"},"tiles":{"type":"array","value":"string"},"bounds":{"type":"array","default":[-180,-85.051129,180,85.051129],"length":4,"value":"number"},"extra_bounds":{"type":"array","value":{"type":"array","length":4,"value":"number"}},"minzoom":{"type":"number","default":0},"maxzoom":{"type":"number","default":22},"tileSize":{"type":"number","default":512},"scheme":{"type":"enum","default":"xyz","values":{"xyz":1,"tms":1}},"attribution":{"type":"string"},"volatile":{"type":"boolean","default":false},"*":{"type":"*"}},"source_raster_dem":{"type":{"type":"enum","values":{"raster-dem":1}},"url":{"type":"string"},"tiles":{"type":"array","value":"string"},"bounds":{"type":"array","default":[-180,-85.051129,180,85.051129],"length":4,"value":"number"},"extra_bounds":{"type":"array","value":{"type":"array","length":4,"value":"number"}},"minzoom":{"type":"number","default":0},"maxzoom":{"type":"number","default":22},"tileSize":{"type":"number","default":512},"attribution":{"type":"string"},"encoding":{"type":"enum","default":"mapbox","values":{"terrarium":1,"mapbox":1}},"volatile":{"type":"boolean","default":false},"*":{"type":"*"}},"source_raster_array":{"type":{"type":"enum","values":{"raster-array":1}},"url":{"type":"string"},"tiles":{"type":"array","value":"string"},"bounds":{"type":"array","default":[-180,-85.051129,180,85.051129],"length":4,"value":"number"},"extra_bounds":{"type":"array","value":{"type":"array","length":4,"value":"number"}},"minzoom":{"type":"number","default":0},"maxzoom":{"type":"number","default":22},"tileSize":{"type":"number","default":512},"attribution":{"type":"string"},"rasterLayers":{"type":"*"},"volatile":{"type":"boolean","default":false},"*":{"type":"*"}},"source_geojson":{"type":{"type":"enum","values":{"geojson":1}},"data":{"type":"*"},"maxzoom":{"type":"number","default":18},"minzoom":{"type":"number","default":0},"attribution":{"type":"string"},"buffer":{"type":"number","default":128,"minimum":0,"maximum":512},"filter":{"type":"*"},"tolerance":{"type":"number","default":0.375},"cluster":{"type":"boolean","default":false},"clusterRadius":{"type":"number","default":50,"minimum":0},"clusterMaxZoom":{"type":"number"},"clusterMinPoints":{"type":"number"},"clusterProperties":{"type":"*"},"lineMetrics":{"type":"boolean","default":false},"generateId":{"type":"boolean","default":false},"promoteId":{"type":"promoteId"},"dynamic":{"type":"boolean","default":false}},"source_video":{"type":{"type":"enum","values":{"video":1}},"urls":{"type":"array","value":"string"},"coordinates":{"type":"array","length":4,"value":{"type":"array","length":2,"value":"number"}}},"source_image":{"type":{"type":"enum","values":{"image":1}},"url":{"type":"string"},"coordinates":{"type":"array","length":4,"value":{"type":"array","length":2,"value":"number"}}},"modelNodeOverride":{"orientation":{"type":"array","default":[0,0,0],"length":3,"value":"number"}},"modelLightOverrides":{"light-ambient-color":{"type":"color"},"light-ambient-intensity":{"type":"number"},"light-directional-color":{"type":"color"},"light-directional-intensity":{"type":"number"}},"modelNodeOverrides":{"*":{"type":"modelNodeOverride"}},"modelMaterialOverride":{"model-color":{"type":"color"},"model-color-mix-intensity":{"type":"number"},"model-opacity":{"type":"number"},"model-emissive-strength":{"type":"number"}},"modelMaterialOverrides":{"*":{"type":"modelMaterialOverride"}},"modelSourceModel":{"uri":{"type":"string"},"position":{"type":"array","default":[0,0],"minimum":[-180,-90],"maximum":[180,90],"length":2,"value":"number"},"orientation":{"type":"array","default":[0,0,0],"length":3,"value":"number"},"lightOverrides":{"type":"modelLightOverrides"},"nodeOverrides":{"type":"modelNodeOverrides"},"materialOverrides":{"type":"modelMaterialOverrides"},"nodeOverrideNames":{"type":"array","value":"string"},"materialOverrideNames":{"type":"array","value":"string"},"featureProperties":{"type":"*"}},"modelSourceModels":{"*":{"type":"modelSourceModel"}},"source_model":{"type":{"type":"enum","values":{"model":1,"batched-model":1}},"url":{"type":"string"},"maxzoom":{"type":"number","default":18},"minzoom":{"type":"number","default":0},"tiles":{"type":"array","value":"string"},"models":{"type":"modelSourceModels"}},"layer":{"type":{"type":"enum","values":{"fill":{},"line":{},"symbol":{},"circle":{},"heatmap":{},"fill-extrusion":{},"building":{},"raster":{},"raster-particle":{},"hillshade":{},"model":{},"background":{},"sky":{},"slot":{},"clip":{}}},"id":{"type":"string"},"metadata":{"type":"*"},"source":{"type":"string"},"source-layer":{"type":"string"},"slot":{"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"},"appearances":{"type":"array","value":"appearance"}},"layout":["layout_clip","layout_fill","layout_line","layout_circle","layout_heatmap","layout_fill-extrusion","layout_building","layout_symbol","layout_raster","layout_raster-particle","layout_hillshade","layout_background","layout_sky","layout_model"],"layout_background":{"visibility":{"type":"enum","default":"visible","values":{"visible":1,"none":1},"expression":1}},"layout_sky":{"visibility":{"type":"enum","default":"visible","values":{"visible":1,"none":1},"expression":1}},"layout_model":{"visibility":{"type":"enum","default":"visible","values":{"visible":1,"none":1},"expression":1},"model-id":{"type":"string","default":"","expression":{"parameters":["feature","zoom"]},"property-type":"data-driven"},"model-allow-density-reduction":{"type":"boolean","default":true}},"layout_clip":{"clip-layer-types":{"type":"array","default":[],"value":"enum","values":{"model":1,"symbol":1},"expression":1},"clip-layer-scope":{"type":"array","default":[],"value":"string","expression":1},"visibility":{"type":"enum","default":"visible","values":{"visible":1,"none":1},"expression":1}},"layout_fill":{"fill-sort-key":{"type":"number","expression":{"parameters":["feature","zoom"]},"property-type":"data-driven"},"visibility":{"type":"enum","default":"visible","values":{"visible":1,"none":1},"expression":1},"fill-elevation-reference":{"type":"enum","default":"none","values":{"none":1,"hd-road-base":1,"hd-road-markup":1},"expression":1},"fill-construct-bridge-guard-rail":{"type":"boolean","default":"true","expression":{"parameters":["feature","zoom"]},"property-type":"data-driven"}},"layout_circle":{"circle-sort-key":{"type":"number","expression":{"parameters":["feature","zoom"]},"property-type":"data-driven"},"circle-elevation-reference":{"type":"enum","default":"none","values":{"none":1,"hd-road-markup":1},"expression":1},"visibility":{"type":"enum","default":"visible","values":{"visible":1,"none":1},"expression":1}},"layout_heatmap":{"visibility":{"type":"enum","default":"visible","values":{"visible":1,"none":1},"expression":1}},"layout_fill-extrusion":{"visibility":{"type":"enum","default":"visible","values":{"visible":1,"none":1},"expression":1},"fill-extrusion-edge-radius":{"type":"number","default":0,"minimum":0,"maximum":1,"expression":1},"source-max-zoom":{"type":"number","minimum":0,"maximum":24}},"layout_building":{"visibility":{"type":"enum","default":"visible","values":{"visible":1,"none":1},"expression":1},"building-facade":{"type":"boolean","default":false,"expression":{"parameters":["feature"]},"property-type":"data-driven"},"building-facade-floors":{"type":"number","default":3,"minimum":1,"maximum":200,"expression":{"parameters":["feature"]},"property-type":"data-driven"},"building-facade-unit-width":{"type":"number","default":3.1,"minimum":1,"maximum":20,"expression":{"parameters":["feature"]},"property-type":"data-driven"},"building-facade-window":{"type":"array","default":[0.9,0.9],"minimum":0.1,"maximum":1,"length":2,"value":"number","expression":{"parameters":["feature"]},"property-type":"data-driven"},"building-roof-shape":{"type":"enum","default":"flat","values":{"flat":1,"hipped":1,"gabled":1,"parapet":1,"mansard":1,"skillion":1,"pyramidal":1},"expression":{"parameters":["feature"]},"property-type":"data-driven"},"building-height":{"type":"number","default":0,"minimum":0,"expression":1,"transition":1,"property-type":"data-driven"},"building-base":{"type":"number","default":0,"minimum":0,"expression":1,"transition":1,"property-type":"data-driven"},"building-flood-light-wall-radius":{"type":"number","default":0,"minimum":0,"expression":{"interpolated":1,"parameters":["feature","feature-state"]},"transition":1,"property-type":"data-driven"},"building-flood-light-ground-radius":{"type":"number","default":0,"expression":{"interpolated":1,"parameters":["feature","feature-state"]},"transition":1,"property-type":"data-driven"},"building-flip-roof-orientation":{"type":"boolean","default":false,"expression":{"interpolated":1,"parameters":["feature","feature-state"]},"transition":1,"property-type":"data-driven"}},"layout_line":{"line-cap":{"type":"enum","default":"butt","values":{"butt":1,"round":1,"square":1},"expression":{"parameters":["feature","zoom"]},"property-type":"data-driven"},"line-join":{"type":"enum","default":"miter","values":{"bevel":1,"round":1,"miter":1,"none":1},"expression":{"parameters":["feature","zoom"]},"property-type":"data-driven"},"line-miter-limit":{"type":"number","default":2,"expression":{"interpolated":1,"parameters":["zoom"]}},"line-round-limit":{"type":"number","default":1.05,"expression":{"interpolated":1,"parameters":["zoom"]}},"line-sort-key":{"type":"number","expression":{"parameters":["feature","zoom"]},"property-type":"data-driven"},"line-z-offset":{"type":"number","default":0,"expression":{"parameters":["feature","line-progress","zoom"]},"property-type":"data-driven"},"line-elevation-reference":{"type":"enum","default":"none","values":{"none":1,"sea":1,"ground":1,"hd-road-markup":1},"expression":1},"line-cross-slope":{"type":"number","expression":1},"visibility":{"type":"enum","default":"visible","values":{"visible":1,"none":1},"expression":1},"line-width-unit":{"type":"enum","default":"pixels","values":{"pixels":1,"meters":1},"expression":{"parameters":["zoom"]}},"line-elevation-ground-scale":{"type":"number","default":0,"minimum":0,"maximum":1,"expression":{"interpolated":1,"parameters":["feature","line-progress","zoom"]},"transition":1,"property-type":"data-driven"}},"layout_symbol":{"symbol-placement":{"type":"enum","default":"point","values":{"point":1,"line":1,"line-center":1},"expression":{"parameters":["zoom"]}},"symbol-spacing":{"type":"number","default":250,"minimum":1,"expression":{"interpolated":1,"parameters":["zoom"]}},"symbol-avoid-edges":{"type":"boolean","default":false,"expression":{"parameters":["zoom"]}},"symbol-sort-key":{"type":"number","expression":{"parameters":["feature","zoom"]},"property-type":"data-driven"},"symbol-z-order":{"type":"enum","default":"auto","values":{"auto":1,"viewport-y":1,"source":1},"expression":{"parameters":["zoom"]}},"symbol-z-elevate":{"type":"boolean","default":false,"expression":{"parameters":["zoom"]}},"symbol-elevation-reference":{"type":"enum","default":"ground","values":{"sea":1,"ground":1,"hd-road-markup":1},"expression":{"parameters":["zoom"]}},"icon-allow-overlap":{"type":"boolean","default":false,"expression":{"parameters":["zoom"]}},"icon-ignore-placement":{"type":"boolean","default":false,"expression":{"parameters":["zoom"]}},"icon-optional":{"type":"boolean","default":false,"expression":{"parameters":["zoom"]}},"icon-rotation-alignment":{"type":"enum","default":"auto","values":{"map":1,"viewport":1,"auto":1},"expression":{"parameters":["zoom"]}},"icon-size":{"type":"number","default":1,"minimum":0,"expression":{"interpolated":1,"parameters":["feature","zoom"]},"property-type":"data-driven","appearance":1},"icon-size-scale-range":{"type":"array","default":[0.8,2],"minimum":[0.1,0.1],"maximum":[10,10],"length":2,"value":"number","expression":1},"icon-text-fit":{"type":"enum","default":"none","values":{"none":1,"width":1,"height":1,"both":1},"expression":{"parameters":["feature","zoom"]},"property-type":"data-driven"},"icon-text-fit-padding":{"type":"array","default":[0,0,0,0],"length":4,"value":"number","expression":{"interpolated":1,"parameters":["feature","zoom"]},"property-type":"data-driven"},"icon-image":{"type":"resolvedImage","expression":{"parameters":["feature","zoom"]},"use-theme":1,"property-type":"data-driven","appearance":1,"tokens":1},"icon-rotate":{"type":"number","default":0,"expression":{"interpolated":1,"parameters":["feature","zoom"]},"property-type":"data-driven","appearance":1},"icon-padding":{"type":"number","default":2,"minimum":0,"expression":{"interpolated":1,"parameters":["zoom"]}},"icon-keep-upright":{"type":"boolean","default":false,"expression":{"parameters":["zoom"]}},"icon-offset":{"type":"array","default":[0,0],"length":2,"value":"number","expression":{"interpolated":1,"parameters":["feature","zoom"]},"property-type":"data-driven","appearance":1},"icon-anchor":{"type":"enum","default":"center","values":{"center":1,"left":1,"right":1,"top":1,"bottom":1,"top-left":1,"top-right":1,"bottom-left":1,"bottom-right":1},"expression":{"parameters":["feature","zoom"]},"property-type":"data-driven"},"icon-pitch-alignment":{"type":"enum","default":"auto","values":{"map":1,"viewport":1,"auto":1},"expression":{"parameters":["zoom"]}},"text-pitch-alignment":{"type":"enum","default":"auto","values":{"map":1,"viewport":1,"auto":1},"expression":{"parameters":["zoom"]}},"text-rotation-alignment":{"type":"enum","default":"auto","values":{"map":1,"viewport":1,"auto":1},"expression":{"parameters":["zoom"]}},"text-field":{"type":"formatted","default":"","expression":{"parameters":["feature","zoom"]},"property-type":"data-driven","tokens":1},"text-font":{"type":"array","default":["Open Sans Regular","Arial Unicode MS Regular"],"value":"string","expression":{"parameters":["feature","zoom"]},"property-type":"data-driven"},"text-size":{"type":"number","default":16,"minimum":0,"expression":{"interpolated":1,"parameters":["feature","zoom"]},"property-type":"data-driven","appearance":1},"text-size-scale-range":{"type":"array","default":[0.8,2],"minimum":[0.1,0.1],"maximum":[10,10],"length":2,"value":"number","expression":1},"text-max-width":{"type":"number","default":10,"minimum":0,"expression":{"interpolated":1,"parameters":["feature","zoom"]},"property-type":"data-driven"},"text-line-height":{"type":"number","default":1.2,"expression":{"interpolated":1,"parameters":["feature","zoom"]},"property-type":"data-driven"},"text-letter-spacing":{"type":"number","default":0,"expression":{"interpolated":1,"parameters":["feature","zoom"]},"property-type":"data-driven"},"text-justify":{"type":"enum","default":"center","values":{"auto":1,"left":1,"center":1,"right":1},"expression":{"parameters":["feature","zoom"]},"property-type":"data-driven"},"text-radial-offset":{"type":"number","default":0,"expression":{"interpolated":1,"parameters":["feature","zoom"]},"property-type":"data-driven"},"text-variable-anchor":{"type":"array","value":"enum","values":{"center":1,"left":1,"right":1,"top":1,"bottom":1,"top-left":1,"top-right":1,"bottom-left":1,"bottom-right":1},"expression":{"parameters":["zoom"]}},"text-anchor":{"type":"enum","default":"center","values":{"center":1,"left":1,"right":1,"top":1,"bottom":1,"top-left":1,"top-right":1,"bottom-left":1,"bottom-right":1},"expression":{"parameters":["feature","zoom"]},"property-type":"data-driven"},"text-max-angle":{"type":"number","default":45,"expression":{"interpolated":1,"parameters":["zoom"]}},"text-writing-mode":{"type":"array","value":"enum","values":{"horizontal":1,"vertical":1},"expression":{"parameters":["zoom"]}},"text-rotate":{"type":"number","default":0,"expression":{"interpolated":1,"parameters":["feature","zoom"]},"property-type":"data-driven","appearance":1},"text-padding":{"type":"number","default":2,"minimum":0,"expression":{"interpolated":1,"parameters":["zoom"]}},"text-keep-upright":{"type":"boolean","default":true,"expression":{"parameters":["zoom"]}},"text-transform":{"type":"enum","default":"none","values":{"none":1,"uppercase":1,"lowercase":1},"expression":{"parameters":["feature","zoom"]},"property-type":"data-driven"},"text-offset":{"type":"array","default":[0,0],"length":2,"value":"number","expression":{"interpolated":1,"parameters":["feature","zoom"]},"property-type":"data-driven","appearance":1},"text-allow-overlap":{"type":"boolean","default":false,"expression":{"parameters":["zoom"]}},"text-ignore-placement":{"type":"boolean","default":false,"expression":{"parameters":["zoom"]}},"text-optional":{"type":"boolean","default":false,"expression":{"parameters":["zoom"]}},"visibility":{"type":"enum","default":"visible","values":{"visible":1,"none":1},"expression":1}},"layout_raster":{"visibility":{"type":"enum","default":"visible","values":{"visible":1,"none":1},"expression":1}},"layout_raster-particle":{"visibility":{"type":"enum","default":"visible","values":{"visible":1,"none":1},"expression":1}},"layout_hillshade":{"visibility":{"type":"enum","default":"visible","values":{"visible":1,"none":1},"expression":1}},"filter":{"type":"array","value":"*"},"filter_symbol":{"type":"boolean","default":false,"expression":{"parameters":["distance-from-center","feature","pitch","zoom"]},"property-type":"data-driven"},"filter_fill":{"type":"boolean","default":false,"expression":{"parameters":["feature","zoom"]},"property-type":"data-driven"},"filter_hillshade":{"type":"boolean","default":false,"expression":{"parameters":["feature","zoom"]},"property-type":"data-driven"},"filter_raster":{"type":"boolean","default":false,"expression":{"parameters":["feature","zoom"]},"property-type":"data-driven"},"filter_raster-particle":{"type":"boolean","default":false,"expression":{"parameters":["feature","zoom"]},"property-type":"data-driven"},"filter_clip":{"type":"boolean","default":false,"expression":{"parameters":["feature","zoom"]},"property-type":"data-driven"},"filter_model":{"type":"boolean","default":false,"expression":{"parameters":["feature","zoom"]},"property-type":"data-driven"},"filter_line":{"type":"boolean","default":false,"expression":{"parameters":["feature","zoom"]},"property-type":"data-driven"},"filter_circle":{"type":"boolean","default":false,"expression":{"parameters":["feature","zoom"]},"property-type":"data-driven"},"filter_fill-extrusion":{"type":"boolean","default":false,"expression":{"parameters":["feature","zoom"]},"property-type":"data-driven"},"filter_building":{"type":"boolean","default":false,"expression":{"parameters":["feature","zoom"]},"property-type":"data-driven"},"filter_heatmap":{"type":"boolean","default":false,"expression":{"parameters":["feature","zoom"]},"property-type":"data-driven"},"filter_operator":{"type":"enum","values":{"==":1,"!=":1,">":1,">=":1,"<":1,"<=":1,"in":1,"!in":1,"all":1,"any":1,"none":1,"has":1,"!has":1}},"geometry_type":{"type":"enum","values":{"Point":1,"LineString":1,"Polygon":1}},"function_stop":{"type":"array","minimum":0,"maximum":24,"length":2,"value":["number","color"]},"fog":{"range":{"type":"array","default":[0.5,10],"minimum":-20,"maximum":20,"length":2,"value":"number","expression":{"interpolated":1,"parameters":["measure-light","zoom"],"relaxZoomRestriction":1},"transition":1},"color":{"type":"color","default":"#ffffff","expression":{"interpolated":1,"parameters":["measure-light","zoom"],"relaxZoomRestriction":1},"transition":1,"use-theme":1},"high-color":{"type":"color","default":"#245cdf","expression":{"interpolated":1,"parameters":["measure-light","zoom"],"relaxZoomRestriction":1},"transition":1,"use-theme":1},"space-color":{"type":"color","default":["interpolate",["linear"],["zoom"],4,"#010b19",7,"#367ab9"],"expression":{"interpolated":1,"parameters":["measure-light","zoom"],"relaxZoomRestriction":1},"transition":1,"use-theme":1},"horizon-blend":{"type":"number","default":["interpolate",["linear"],["zoom"],4,0.2,7,0.1],"minimum":0,"maximum":1,"expression":{"interpolated":1,"parameters":["measure-light","zoom"],"relaxZoomRestriction":1},"transition":1},"star-intensity":{"type":"number","default":["interpolate",["linear"],["zoom"],5,0.35,6,0],"minimum":0,"maximum":1,"expression":{"interpolated":1,"parameters":["measure-light","zoom"],"relaxZoomRestriction":1},"transition":1},"vertical-range":{"type":"array","default":[0,0],"minimum":0,"length":2,"value":"number","expression":{"interpolated":1,"parameters":["measure-light","zoom"],"relaxZoomRestriction":1},"transition":1}},"snow":{"density":{"type":"number","default":["interpolate",["linear"],["zoom"],11,0,13,0.85],"minimum":0,"maximum":1,"expression":{"interpolated":1,"parameters":["measure-light","zoom"],"relaxZoomRestriction":1},"transition":1},"intensity":{"type":"number","default":1,"minimum":0,"maximum":1,"expression":{"interpolated":1,"parameters":["measure-light","zoom"],"relaxZoomRestriction":1},"transition":1},"color":{"type":"color","default":"#ffffff","expression":{"interpolated":1,"parameters":["measure-light","zoom"],"relaxZoomRestriction":1},"transition":1,"use-theme":1},"opacity":{"type":"number","default":1,"minimum":0,"maximum":1,"expression":{"interpolated":1,"parameters":["measure-light","zoom"],"relaxZoomRestriction":1},"transition":1},"vignette":{"type":"number","default":["interpolate",["linear"],["zoom"],11,0,13,0.3],"minimum":0,"maximum":1,"expression":{"interpolated":1,"parameters":["measure-light","zoom"],"relaxZoomRestriction":1},"transition":1},"vignette-color":{"type":"color","default":"#ffffff","expression":{"interpolated":1,"parameters":["measure-light","zoom"],"relaxZoomRestriction":1},"transition":1,"use-theme":1},"center-thinning":{"type":"number","default":0.4,"minimum":0,"maximum":1,"expression":{"interpolated":1,"parameters":["measure-light","zoom"],"relaxZoomRestriction":1},"transition":1},"direction":{"type":"array","default":[0,50],"minimum":0,"maximum":360,"length":2,"value":"number","expression":{"interpolated":1,"parameters":["measure-light","zoom"],"relaxZoomRestriction":1},"transition":1},"flake-size":{"type":"number","default":0.71,"minimum":0,"maximum":5,"expression":{"interpolated":1,"parameters":["measure-light","zoom"],"relaxZoomRestriction":1},"transition":1}},"rain":{"density":{"type":"number","default":["interpolate",["linear"],["zoom"],11,0,13,0.5],"minimum":0,"maximum":1,"expression":{"interpolated":1,"parameters":["measure-light","zoom"],"relaxZoomRestriction":1},"transition":1},"intensity":{"type":"number","default":1,"minimum":0,"maximum":1,"expression":{"interpolated":1,"parameters":["measure-light","zoom"],"relaxZoomRestriction":1},"transition":1},"color":{"type":"color","default":["interpolate",["linear"],["measure-light","brightness"],0,"#03113d",0.3,"#a8adbc"],"expression":{"interpolated":1,"parameters":["measure-light","zoom"],"relaxZoomRestriction":1},"transition":1,"use-theme":1},"opacity":{"type":"number","default":["interpolate",["linear"],["measure-light","brightness"],0,0.88,1,0.7],"minimum":0,"maximum":1,"expression":{"interpolated":1,"parameters":["measure-light","zoom"],"relaxZoomRestriction":1},"transition":1},"vignette":{"type":"number","default":["interpolate",["linear"],["zoom"],11,0,13,1],"minimum":0,"maximum":1,"expression":{"interpolated":1,"parameters":["measure-light","zoom"],"relaxZoomRestriction":1},"transition":1},"vignette-color":{"type":"color","default":["interpolate",["linear"],["measure-light","brightness"],0,"#001736",0.3,"#464646"],"expression":{"interpolated":1,"parameters":["measure-light","zoom"],"relaxZoomRestriction":1},"transition":1,"use-theme":1},"center-thinning":{"type":"number","default":0.57,"minimum":0,"maximum":1,"expression":{"interpolated":1,"parameters":["measure-light","zoom"],"relaxZoomRestriction":1},"transition":1},"direction":{"type":"array","default":[0,80],"minimum":0,"maximum":360,"length":2,"value":"number","expression":{"interpolated":1,"parameters":["measure-light","zoom"],"relaxZoomRestriction":1},"transition":1},"droplet-size":{"type":"array","default":[2.6,18.2],"minimum":0,"maximum":50,"length":2,"value":"number","expression":{"interpolated":1,"parameters":["measure-light","zoom"],"relaxZoomRestriction":1},"transition":1},"distortion-strength":{"type":"number","default":0.7,"minimum":0,"maximum":1,"expression":{"interpolated":1,"parameters":["measure-light","zoom"],"relaxZoomRestriction":1},"transition":1}},"camera":{"camera-projection":{"type":"enum","default":"perspective","values":{"perspective":1,"orthographic":1}}},"colorTheme":{"data":{"type":"string","expression":1}},"indoor_source":{"sourceId":{"type":"string"},"sourceLayers":{"type":"array","value":"string"}},"indoor":{"*":{"type":"indoor_source"}},"light":{"anchor":{"type":"enum","default":"viewport","values":{"map":1,"viewport":1},"expression":{"parameters":["zoom"]}},"position":{"type":"array","default":[1.15,210,30],"length":3,"value":"number","expression":{"interpolated":1,"parameters":["zoom"]},"transition":1},"color":{"type":"color","default":"#ffffff","expression":{"interpolated":1,"parameters":["zoom"]},"transition":1,"use-theme":1},"intensity":{"type":"number","default":0.5,"minimum":0,"maximum":1,"expression":{"interpolated":1,"parameters":["zoom"]},"transition":1}},"projection":{"name":{"type":"enum","default":"mercator","values":{"albers":1,"equalEarth":1,"equirectangular":1,"lambertConformalConic":1,"mercator":1,"naturalEarth":1,"winkelTripel":1,"globe":1}},"center":{"type":"array","minimum":[-180,-90],"maximum":[180,90],"length":2,"value":"number"},"parallels":{"type":"array","minimum":[-90,-90],"maximum":[90,90],"length":2,"value":"number"}},"terrain":{"source":{"type":"string"},"exaggeration":{"type":"number","default":1,"minimum":0,"maximum":1000,"expression":{"interpolated":1,"parameters":["zoom"]},"transition":1}},"paint":["paint_fill","paint_line","paint_circle","paint_heatmap","paint_fill-extrusion","paint_building","paint_symbol","paint_raster","paint_raster-particle","paint_hillshade","paint_background","paint_sky","paint_model"],"paint_fill":{"fill-antialias":{"type":"boolean","default":true,"expression":{"parameters":["zoom"]}},"fill-opacity":{"type":"number","default":1,"minimum":0,"maximum":1,"expression":{"interpolated":1,"parameters":["feature","feature-state","measure-light","zoom"]},"transition":1,"property-type":"data-driven"},"fill-color":{"type":"color","default":"#000000","expression":{"interpolated":1,"parameters":["feature","feature-state","measure-light","zoom"]},"transition":1,"use-theme":1,"property-type":"data-driven"},"fill-outline-color":{"type":"color","expression":{"interpolated":1,"parameters":["feature","feature-state","measure-light","zoom"]},"transition":1,"use-theme":1,"property-type":"data-driven"},"fill-translate":{"type":"array","default":[0,0],"length":2,"value":"number","expression":{"interpolated":1,"parameters":["zoom"]},"transition":1},"fill-translate-anchor":{"type":"enum","default":"map","values":{"map":1,"viewport":1},"expression":{"parameters":["zoom"]}},"fill-pattern":{"type":"resolvedImage","expression":{"parameters":["feature","zoom"]},"property-type":"data-driven"},"fill-pattern-cross-fade":{"type":"number","default":0,"minimum":0,"maximum":1,"expression":{"interpolated":1,"parameters":["measure-light","zoom"]}},"fill-emissive-strength":{"type":"number","default":0,"minimum":0,"expression":{"interpolated":1,"parameters":["measure-light","zoom"]},"transition":1},"fill-z-offset":{"type":"number","default":0,"minimum":0,"expression":{"interpolated":1,"parameters":["feature","zoom"]},"transition":1,"property-type":"data-driven"},"fill-bridge-guard-rail-color":{"type":"color","default":"rgba(241, 236, 225, 255)","expression":{"interpolated":1,"parameters":["feature","measure-light","zoom"]},"transition":1,"use-theme":1,"property-type":"data-driven"},"fill-tunnel-structure-color":{"type":"color","default":"rgba(241, 236, 225, 255)","expression":{"interpolated":1,"parameters":["feature","measure-light","zoom"]},"transition":1,"use-theme":1,"property-type":"data-driven"}},"paint_fill-extrusion":{"fill-extrusion-opacity":{"type":"number","default":1,"minimum":0,"maximum":1,"expression":{"interpolated":1,"parameters":["zoom"]},"transition":1},"fill-extrusion-color":{"type":"color","default":"#000000","expression":{"interpolated":1,"parameters":["feature","feature-state","measure-light","zoom"]},"transition":1,"use-theme":1,"property-type":"data-driven"},"fill-extrusion-translate":{"type":"array","default":[0,0],"length":2,"value":"number","expression":{"interpolated":1,"parameters":["zoom"]},"transition":1},"fill-extrusion-translate-anchor":{"type":"enum","default":"map","values":{"map":1,"viewport":1},"expression":{"parameters":["zoom"]}},"fill-extrusion-pattern":{"type":"resolvedImage","expression":{"parameters":["feature","zoom"]},"property-type":"data-driven"},"fill-extrusion-pattern-cross-fade":{"type":"number","default":0,"minimum":0,"maximum":1,"expression":{"interpolated":1,"parameters":["measure-light","zoom"]}},"fill-extrusion-height":{"type":"number","default":0,"minimum":0,"expression":{"interpolated":1,"parameters":["feature","feature-state","zoom"]},"transition":1,"property-type":"data-driven"},"fill-extrusion-base":{"type":"number","default":0,"minimum":0,"expression":{"interpolated":1,"parameters":["feature","feature-state","zoom"]},"transition":1,"property-type":"data-driven"},"fill-extrusion-height-alignment":{"type":"enum","default":"flat","values":{"terrain":1,"flat":1}},"fill-extrusion-base-alignment":{"type":"enum","default":"terrain","values":{"terrain":1,"flat":1}},"fill-extrusion-vertical-gradient":{"type":"boolean","default":true,"expression":{"parameters":["zoom"]}},"fill-extrusion-ambient-occlusion-intensity":{"type":"number","default":0,"minimum":0,"maximum":1,"expression":{"interpolated":1,"parameters":["zoom"]},"transition":1},"fill-extrusion-ambient-occlusion-radius":{"type":"number","default":3,"minimum":0,"expression":{"interpolated":1,"parameters":["zoom"]},"transition":1},"fill-extrusion-ambient-occlusion-wall-radius":{"type":"number","default":3,"minimum":0,"expression":{"interpolated":1,"parameters":["zoom"]},"transition":1},"fill-extrusion-ambient-occlusion-ground-radius":{"type":"number","default":3,"minimum":0,"expression":{"interpolated":1,"parameters":["zoom"]},"transition":1},"fill-extrusion-ambient-occlusion-ground-attenuation":{"type":"number","default":0.69,"minimum":0,"maximum":1,"expression":{"interpolated":1,"parameters":["zoom"]},"transition":1},"fill-extrusion-flood-light-color":{"type":"color","default":"#ffffff","expression":{"interpolated":1,"parameters":["measure-light","zoom"]},"transition":1,"use-theme":1},"fill-extrusion-flood-light-intensity":{"type":"number","default":0,"minimum":0,"maximum":1,"expression":{"interpolated":1,"parameters":["measure-light","zoom"]},"transition":1},"fill-extrusion-flood-light-wall-radius":{"type":"number","default":0,"minimum":0,"expression":{"interpolated":1,"parameters":["feature","feature-state"]},"transition":1,"property-type":"data-driven"},"fill-extrusion-flood-light-ground-radius":{"type":"number","default":0,"expression":{"interpolated":1,"parameters":["feature","feature-state"]},"transition":1,"property-type":"data-driven"},"fill-extrusion-flood-light-ground-attenuation":{"type":"number","default":0.69,"minimum":0,"maximum":1,"expression":{"interpolated":1,"parameters":["zoom"]},"transition":1},"fill-extrusion-vertical-scale":{"type":"number","default":1,"minimum":0,"expression":{"interpolated":1,"parameters":["zoom"]},"transition":1},"fill-extrusion-rounded-roof":{"type":"boolean","default":true,"expression":{"parameters":["zoom"]}},"fill-extrusion-cutoff-fade-range":{"type":"number","default":0,"minimum":0,"maximum":1,"expression":1},"fill-extrusion-front-cutoff":{"type":"array","default":[0,0,1],"minimum":[0,0,0],"maximum":[1,1,1],"length":3,"value":"number","expression":{"interpolated":1,"parameters":["zoom"]}},"fill-extrusion-emissive-strength":{"type":"number","default":0,"minimum":0,"expression":{"interpolated":1,"parameters":["feature-state","measure-light","zoom"]},"transition":1,"property-type":"data-driven"},"fill-extrusion-line-width":{"type":"number","default":0,"minimum":0,"expression":{"interpolated":1,"parameters":["feature","feature-state","measure-light","zoom"]},"transition":1,"property-type":"data-driven"},"fill-extrusion-cast-shadows":{"type":"boolean","default":true}},"paint_building":{"building-opacity":{"type":"number","default":1,"minimum":0,"maximum":1,"expression":{"interpolated":1,"parameters":["zoom"]},"transition":1},"building-ambient-occlusion-intensity":{"type":"number","default":0,"minimum":0,"maximum":1,"expression":{"parameters":[]},"transition":1},"building-ambient-occlusion-ground-intensity":{"type":"number","default":0,"minimum":0,"maximum":1,"expression":{"interpolated":1,"parameters":["zoom"]},"transition":1},"building-ambient-occlusion-ground-radius":{"type":"number","default":3,"minimum":0,"expression":{"interpolated":1,"parameters":["zoom"]},"transition":1},"building-ambient-occlusion-ground-attenuation":{"type":"number","default":0.69,"minimum":0,"maximum":1,"expression":{"interpolated":1,"parameters":["zoom"]},"transition":1},"building-vertical-scale":{"type":"number","default":1,"minimum":0,"expression":{"interpolated":1,"parameters":["zoom"]},"transition":1},"building-cast-shadows":{"type":"boolean","default":true},"building-color":{"type":"color","default":"rgba(193, 154, 127, 1)","expression":{"interpolated":1,"parameters":["feature","feature-state","measure-light"]},"use-theme":1,"property-type":"data-driven"},"building-emissive-strength":{"type":"number","default":0,"minimum":0,"maximum":5,"expression":{"interpolated":1,"parameters":["feature","feature-state","measure-light"]},"property-type":"data-driven"},"building-facade-emissive-chance":{"type":"number","default":0.35,"minimum":0,"maximum":1,"expression":{"interpolated":1,"parameters":["measure-light","zoom"]}},"building-cutoff-fade-range":{"type":"number","default":0,"minimum":0,"maximum":1,"expression":1},"building-front-cutoff":{"type":"array","default":[0,0,1],"minimum":[0,0,0],"maximum":[1,1,1],"length":3,"value":"number","expression":{"interpolated":1,"parameters":["zoom"]}},"building-flood-light-color":{"type":"color","default":"#ffffff","expression":{"interpolated":1,"parameters":["measure-light","zoom"]},"transition":1,"use-theme":1},"building-flood-light-intensity":{"type":"number","default":0,"minimum":0,"maximum":1,"expression":{"interpolated":1,"parameters":["measure-light","zoom"]},"transition":1},"building-flood-light-ground-attenuation":{"type":"number","default":0.69,"minimum":0,"maximum":1,"expression":{"interpolated":1,"parameters":["zoom"]},"transition":1}},"paint_line":{"line-opacity":{"type":"number","default":1,"minimum":0,"maximum":1,"expression":{"interpolated":1,"parameters":["feature","feature-state","measure-light","zoom"]},"transition":1,"property-type":"data-driven"},"line-color":{"type":"color","default":"#000000","expression":{"interpolated":1,"parameters":["feature","feature-state","measure-light","zoom"]},"transition":1,"use-theme":1,"property-type":"data-driven"},"line-translate":{"type":"array","default":[0,0],"length":2,"value":"number","expression":{"interpolated":1,"parameters":["zoom"]},"transition":1},"line-translate-anchor":{"type":"enum","default":"map","values":{"map":1,"viewport":1},"expression":{"parameters":["zoom"]}},"line-width":{"type":"number","default":1,"minimum":0,"expression":{"interpolated":1,"parameters":["feature","feature-state","line-progress","measure-light","zoom"]},"transition":1,"property-type":"data-driven"},"line-gap-width":{"type":"number","default":0,"minimum":0,"expression":{"interpolated":1,"parameters":["feature","feature-state","measure-light","zoom"]},"transition":1,"property-type":"data-driven"},"line-offset":{"type":"number","default":0,"expression":{"interpolated":1,"parameters":["feature","feature-state","measure-light","zoom"]},"transition":1,"property-type":"data-driven"},"line-blur":{"type":"number","default":0,"minimum":0,"expression":{"interpolated":1,"parameters":["feature","feature-state","measure-light","zoom"]},"transition":1,"property-type":"data-driven"},"line-dasharray":{"type":"array","minimum":0,"value":"number","expression":{"parameters":["feature","zoom"]},"property-type":"data-driven"},"line-pattern":{"type":"resolvedImage","expression":{"parameters":["feature","zoom"]},"property-type":"data-driven"},"line-pattern-cross-fade":{"type":"number","default":0,"minimum":0,"maximum":1,"expression":{"interpolated":1,"parameters":["measure-light","zoom"]}},"line-gradient":{"type":"color","expression":{"interpolated":1,"parameters":["line-progress"]},"use-theme":1},"line-trim-offset":{"type":"array","default":[0,0],"minimum":[0,0],"maximum":[1,1],"length":2,"value":"number"},"line-trim-fade-range":{"type":"array","default":[0,0],"minimum":[0,0],"maximum":[1,1],"length":2,"value":"number","expression":{"interpolated":1,"parameters":["measure-light","zoom"]}},"line-trim-color":{"type":"color","default":"transparent","expression":{"interpolated":1,"parameters":["measure-light","zoom"]},"transition":1,"use-theme":1},"line-emissive-strength":{"type":"number","default":0,"minimum":0,"expression":{"interpolated":1,"parameters":["line-progress","measure-light","zoom"]},"transition":1,"property-type":"data-driven"},"line-border-width":{"type":"number","default":0,"minimum":0,"expression":{"interpolated":1,"parameters":["feature","feature-state","zoom"]},"transition":1,"property-type":"data-driven"},"line-border-color":{"type":"color","default":"rgba(0, 0, 0, 0)","expression":{"interpolated":1,"parameters":["feature","feature-state","zoom"]},"transition":1,"use-theme":1,"property-type":"data-driven"},"line-
1occlusion-opacity":{"type":"number","default":0,"minimum":0,"maximum":1,"expression":{"interpolated":1,"parameters":["zoom"]},"transition":1},"line-blend-mode":{"type":"enum","default":"default","values":{"default":1,"multiply":1,"additive":1},"expression":{"parameters":["zoom"]}},"line-blend-additive-clamp":{"type":"number","default":0,"minimum":0,"expression":{"interpolated":1,"parameters":["zoom"]}}},"paint_circle":{"circle-radius":{"type":"number","default":5,"minimum":0,"expression":{"interpolated":1,"parameters":["feature","feature-state","measure-light","zoom"]},"transition":1,"property-type":"data-driven"},"circle-color":{"type":"color","default":"#000000","expression":{"interpolated":1,"parameters":["feature","feature-state","measure-light","zoom"]},"transition":1,"use-theme":1,"property-type":"data-driven"},"circle-blur":{"type":"number","default":0,"expression":{"interpolated":1,"parameters":["feature","feature-state","measure-light","zoom"]},"transition":1,"property-type":"data-driven"},"circle-opacity":{"type":"number","default":1,"minimum":0,"maximum":1,"expression":{"interpolated":1,"parameters":["feature","feature-state","measure-light","zoom"]},"transition":1,"property-type":"data-driven"},"circle-translate":{"type":"array","default":[0,0],"length":2,"value":"number","expression":{"interpolated":1,"parameters":["zoom"]},"transition":1},"circle-translate-anchor":{"type":"enum","default":"map","values":{"map":1,"viewport":1},"expression":{"parameters":["zoom"]}},"circle-pitch-scale":{"type":"enum","default":"map","values":{"map":1,"viewport":1},"expression":{"parameters":["zoom"]}},"circle-pitch-alignment":{"type":"enum","default":"viewport","values":{"map":1,"viewport":1},"expression":{"parameters":["zoom"]}},"circle-stroke-width":{"type":"number","default":0,"minimum":0,"expression":{"interpolated":1,"parameters":["feature","feature-state","measure-light","zoom"]},"transition":1,"property-type":"data-driven"},"circle-stroke-color":{"type":"color","default":"#000000","expression":{"interpolated":1,"parameters":["feature","feature-state","measure-light","zoom"]},"transition":1,"use-theme":1,"property-type":"data-driven"},"circle-stroke-opacity":{"type":"number","default":1,"minimum":0,"maximum":1,"expression":{"interpolated":1,"parameters":["feature","feature-state","measure-light","zoom"]},"transition":1,"property-type":"data-driven"},"circle-emissive-strength":{"type":"number","default":0,"minimum":0,"expression":{"interpolated":1,"parameters":["measure-light","zoom"]},"transition":1}},"paint_heatmap":{"heatmap-radius":{"type":"number","default":30,"minimum":1,"expression":{"interpolated":1,"parameters":["feature","feature-state","measure-light","zoom"]},"transition":1,"property-type":"data-driven"},"heatmap-weight":{"type":"number","default":1,"minimum":0,"expression":{"interpolated":1,"parameters":["feature","feature-state","measure-light","zoom"]},"property-type":"data-driven"},"heatmap-intensity":{"type":"number","default":1,"minimum":0,"expression":{"interpolated":1,"parameters":["zoom"]},"transition":1},"heatmap-color":{"type":"color","default":["interpolate",["linear"],["heatmap-density"],0,"rgba(0, 0, 255, 0)",0.1,"royalblue",0.3,"cyan",0.5,"lime",0.7,"yellow",1,"red"],"expression":{"interpolated":1,"parameters":["heatmap-density"]},"use-theme":1},"heatmap-opacity":{"type":"number","default":1,"minimum":0,"maximum":1,"expression":{"interpolated":1,"parameters":["zoom"]},"transition":1}},"paint_symbol":{"icon-opacity":{"type":"number","default":1,"minimum":0,"maximum":1,"expression":{"interpolated":1,"parameters":["feature","feature-state","measure-light","zoom"]},"transition":1,"property-type":"data-driven","appearance":1},"icon-occlusion-opacity":{"type":"number","default":0,"minimum":0,"maximum":1,"expression":{"interpolated":1,"parameters":["feature","feature-state","measure-light","zoom"]},"transition":1,"property-type":"data-driven","appearance":1},"icon-emissive-strength":{"type":"number","default":1,"minimum":0,"expression":{"interpolated":1,"parameters":["feature-state","measure-light","zoom"]},"transition":1,"property-type":"data-driven","appearance":1},"text-emissive-strength":{"type":"number","default":1,"minimum":0,"expression":{"interpolated":1,"parameters":["feature-state","measure-light","zoom"]},"transition":1,"property-type":"data-driven","appearance":1},"icon-color":{"type":"color","default":"#000000","expression":{"interpolated":1,"parameters":["feature","feature-state","measure-light","zoom"]},"transition":1,"use-theme":1,"property-type":"data-driven","appearance":1},"icon-halo-color":{"type":"color","default":"rgba(0, 0, 0, 0)","expression":{"interpolated":1,"parameters":["feature","feature-state","measure-light","zoom"]},"transition":1,"use-theme":1,"property-type":"data-driven","appearance":1},"icon-halo-width":{"type":"number","default":0,"minimum":0,"expression":{"interpolated":1,"parameters":["feature","feature-state","measure-light","zoom"]},"transition":1,"property-type":"data-driven","appearance":1},"icon-halo-blur":{"type":"number","default":0,"minimum":0,"expression":{"interpolated":1,"parameters":["feature","feature-state","measure-light","zoom"]},"transition":1,"property-type":"data-driven","appearance":1},"icon-translate":{"type":"array","default":[0,0],"length":2,"value":"number","expression":{"interpolated":1,"parameters":["zoom"]},"transition":1,"appearance":1},"icon-translate-anchor":{"type":"enum","default":"map","values":{"map":1,"viewport":1},"expression":{"parameters":["zoom"]}},"icon-image-cross-fade":{"type":"number","default":0,"minimum":0,"maximum":1,"expression":{"interpolated":1,"parameters":["measure-light","zoom"]}},"text-opacity":{"type":"number","default":1,"minimum":0,"maximum":1,"expression":{"interpolated":1,"parameters":["feature","feature-state","measure-light","zoom"]},"transition":1,"property-type":"data-driven","appearance":1},"text-occlusion-opacity":{"type":"number","default":0,"minimum":0,"maximum":1,"expression":{"interpolated":1,"parameters":["feature","feature-state","measure-light","zoom"]},"transition":1,"property-type":"data-driven","appearance":1},"text-color":{"type":"color","default":"#000000","expression":{"interpolated":1,"parameters":["feature","feature-state","measure-light","zoom"]},"transition":1,"use-theme":1,"property-type":"data-driven","appearance":1,"overridable":1},"text-halo-color":{"type":"color","default":"rgba(0, 0, 0, 0)","expression":{"interpolated":1,"parameters":["feature","feature-state","measure-light","zoom"]},"transition":1,"use-theme":1,"property-type":"data-driven","appearance":1},"text-halo-width":{"type":"number","default":0,"minimum":0,"expression":{"interpolated":1,"parameters":["feature","feature-state","measure-light","zoom"]},"transition":1,"property-type":"data-driven","appearance":1},"text-halo-blur":{"type":"number","default":0,"minimum":0,"expression":{"interpolated":1,"parameters":["feature","feature-state","measure-light","zoom"]},"transition":1,"property-type":"data-driven","appearance":1},"text-translate":{"type":"array","default":[0,0],"length":2,"value":"number","expression":{"interpolated":1,"parameters":["zoom"]},"transition":1,"appearance":1},"text-translate-anchor":{"type":"enum","default":"map","values":{"map":1,"viewport":1},"expression":{"parameters":["zoom"]}},"icon-color-saturation":{"type":"number","default":0,"minimum":-1,"maximum":1,"expression":1},"icon-color-contrast":{"type":"number","default":0,"minimum":-1,"maximum":1,"expression":1},"icon-color-brightness-min":{"type":"number","default":0,"minimum":0,"maximum":1,"expression":1},"icon-color-brightness-max":{"type":"number","default":1,"minimum":0,"maximum":1,"expression":1},"symbol-z-offset":{"type":"number","default":0,"minimum":0,"expression":{"interpolated":1,"parameters":["feature","zoom"]},"transition":1,"property-type":"data-driven","appearance":1}},"paint_raster":{"raster-opacity":{"type":"number","default":1,"minimum":0,"maximum":1,"expression":{"interpolated":1,"parameters":["zoom"]},"transition":1},"raster-color":{"type":"color","expression":{"interpolated":1,"parameters":["raster-value"]},"use-theme":1},"raster-color-mix":{"type":"array","default":[0.2126,0.7152,0.0722,0],"length":4,"value":"number","expression":{"interpolated":1,"parameters":["zoom"]},"transition":1},"raster-color-range":{"type":"array","length":2,"value":"number","expression":{"interpolated":1,"parameters":["zoom"]},"transition":1},"raster-hue-rotate":{"type":"number","default":0,"expression":{"interpolated":1,"parameters":["zoom"]},"transition":1},"raster-brightness-min":{"type":"number","default":0,"minimum":0,"maximum":1,"expression":{"interpolated":1,"parameters":["zoom"]},"transition":1},"raster-brightness-max":{"type":"number","default":1,"minimum":0,"maximum":1,"expression":{"interpolated":1,"parameters":["zoom"]},"transition":1},"raster-saturation":{"type":"number","default":0,"minimum":-1,"maximum":1,"expression":{"interpolated":1,"parameters":["zoom"]},"transition":1},"raster-contrast":{"type":"number","default":0,"minimum":-1,"maximum":1,"expression":{"interpolated":1,"parameters":["zoom"]},"transition":1},"raster-resampling":{"type":"enum","default":"linear","values":{"linear":1,"nearest":1},"expression":{"parameters":["zoom"]}},"raster-fade-duration":{"type":"number","default":300,"minimum":0,"expression":{"interpolated":1,"parameters":["zoom"]}},"raster-emissive-strength":{"type":"number","default":0,"minimum":0,"expression":{"interpolated":1,"parameters":["measure-light","zoom"]},"transition":1},"raster-array-band":{"type":"string"},"raster-elevation":{"type":"number","default":0,"minimum":0,"expression":{"interpolated":1,"parameters":["zoom"]},"transition":1},"raster-elevation-reference":{"type":"enum","default":"sea","values":{"sea":1,"ground":1},"expression":1}},"paint_raster-particle":{"raster-particle-array-band":{"type":"string"},"raster-particle-count":{"type":"number","default":512,"minimum":1},"raster-particle-color":{"type":"color","expression":{"interpolated":1,"parameters":["raster-particle-speed"]},"use-theme":1},"raster-particle-max-speed":{"type":"number","default":1,"minimum":1},"raster-particle-speed-factor":{"type":"number","default":0.2,"minimum":0,"maximum":1,"expression":{"interpolated":1,"parameters":["zoom"]},"transition":1},"raster-particle-fade-opacity-factor":{"type":"number","default":0.98,"minimum":0,"maximum":1,"expression":{"interpolated":1,"parameters":["zoom"]},"transition":1},"raster-particle-reset-rate-factor":{"type":"number","default":0.8,"minimum":0,"maximum":1},"raster-particle-elevation":{"type":"number","default":0,"minimum":0,"expression":{"interpolated":1,"parameters":["zoom"]},"transition":1}},"paint_hillshade":{"hillshade-illumination-direction":{"type":"number","default":335,"minimum":0,"maximum":359,"expression":{"interpolated":1,"parameters":["zoom"]}},"hillshade-illumination-anchor":{"type":"enum","default":"viewport","values":{"map":1,"viewport":1},"expression":{"parameters":["zoom"]}},"hillshade-exaggeration":{"type":"number","default":0.5,"minimum":0,"maximum":1,"expression":{"interpolated":1,"parameters":["zoom"]},"transition":1},"hillshade-shadow-color":{"type":"color","default":"#000000","expression":{"interpolated":1,"parameters":["measure-light","zoom"]},"transition":1,"use-theme":1},"hillshade-highlight-color":{"type":"color","default":"#FFFFFF","expression":{"interpolated":1,"parameters":["measure-light","zoom"]},"transition":1,"use-theme":1},"hillshade-accent-color":{"type":"color","default":"#000000","expression":{"interpolated":1,"parameters":["measure-light","zoom"]},"transition":1,"use-theme":1},"hillshade-emissive-strength":{"type":"number","default":0,"minimum":0,"expression":{"interpolated":1,"parameters":["measure-light","zoom"]},"transition":1}},"paint_background":{"background-pitch-alignment":{"type":"enum","default":"map","values":{"map":1,"viewport":1},"expression":{"parameters":[]}},"background-color":{"type":"color","default":"#000000","expression":{"interpolated":1,"parameters":["measure-light","zoom"]},"transition":1,"use-theme":1},"background-pattern":{"type":"resolvedImage","expression":{"parameters":["zoom"]}},"background-opacity":{"type":"number","default":1,"minimum":0,"maximum":1,"expression":{"interpolated":1,"parameters":["zoom"]},"transition":1},"background-emissive-strength":{"type":"number","default":0,"minimum":0,"expression":{"interpolated":1,"parameters":["measure-light","zoom"]},"transition":1}},"paint_sky":{"sky-type":{"type":"enum","default":"atmosphere","values":{"gradient":1,"atmosphere":1},"expression":{"parameters":["zoom"]}},"sky-atmosphere-sun":{"type":"array","minimum":[0,0],"maximum":[360,180],"length":2,"value":"number","expression":{"parameters":["zoom"]}},"sky-atmosphere-sun-intensity":{"type":"number","default":10,"minimum":0,"maximum":100},"sky-gradient-center":{"type":"array","default":[0,0],"minimum":[0,0],"maximum":[360,180],"length":2,"value":"number","expression":{"parameters":["zoom"]}},"sky-gradient-radius":{"type":"number","default":90,"minimum":0,"maximum":180,"expression":{"parameters":["zoom"]}},"sky-gradient":{"type":"color","default":["interpolate",["linear"],["sky-radial-progress"],0.8,"#87ceeb",1,"white"],"expression":{"interpolated":1,"parameters":["sky-radial-progress"]},"use-theme":1},"sky-atmosphere-halo-color":{"type":"color","default":"white","use-theme":1},"sky-atmosphere-color":{"type":"color","default":"white","use-theme":1},"sky-opacity":{"type":"number","default":1,"minimum":0,"maximum":1,"expression":{"interpolated":1,"parameters":["zoom"]},"transition":1}},"paint_model":{"model-opacity":{"type":"number","default":1,"minimum":0,"maximum":1,"expression":{"interpolated":1,"parameters":["feature","feature-state","zoom"]},"transition":1,"property-type":"data-driven"},"model-rotation":{"type":"array","default":[0,0,0],"length":3,"value":"number","expression":{"interpolated":1,"parameters":["feature","feature-state","zoom"]},"transition":1,"property-type":"data-driven"},"model-scale":{"type":"array","default":[1,1,1],"length":3,"value":"number","expression":{"interpolated":1,"parameters":["feature","feature-state","zoom"]},"transition":1,"property-type":"data-driven"},"model-translation":{"type":"array","default":[0,0,0],"length":3,"value":"number","expression":{"interpolated":1,"parameters":["feature","feature-state","zoom"]},"transition":1,"property-type":"data-driven"},"model-color":{"type":"color","default":"#ffffff","expression":{"interpolated":1,"parameters":["feature","feature-state","measure-light","zoom"]},"transition":1,"use-theme":1,"property-type":"data-driven"},"model-color-mix-intensity":{"type":"number","default":0,"minimum":0,"maximum":1,"expression":{"interpolated":1,"parameters":["feature","feature-state","measure-light"]},"transition":1,"property-type":"data-driven"},"model-type":{"type":"enum","default":"common-3d","values":{"common-3d":1,"location-indicator":1}},"model-cast-shadows":{"type":"boolean","default":true},"model-receive-shadows":{"type":"boolean","default":true},"model-ambient-occlusion-intensity":{"type":"number","default":1,"minimum":0,"maximum":1,"expression":{"interpolated":1,"parameters":["zoom"]},"transition":1},"model-emissive-strength":{"type":"number","default":0,"minimum":0,"maximum":5,"expression":{"interpolated":1,"parameters":["feature","feature-state","measure-light"]},"transition":1,"property-type":"data-driven"},"model-roughness":{"type":"number","default":1,"minimum":0,"maximum":1,"expression":{"interpolated":1,"parameters":["feature","feature-state"]},"transition":1,"property-type":"data-driven"},"model-height-based-emissive-strength-multiplier":{"type":"array","default":[1,1,1,1,0],"length":5,"value":"number","expression":{"interpolated":1,"parameters":["feature","feature-state","measure-light"]},"transition":1,"property-type":"data-driven"},"model-cutoff-fade-range":{"type":"number","default":0,"minimum":0,"maximum":1,"expression":1},"model-front-cutoff":{"type":"array","default":[0,0,1],"minimum":[0,0,0],"maximum":[1,1,1],"length":3,"value":"number","expression":{"interpolated":1,"parameters":["zoom"]}},"model-elevation-reference":{"type":"enum","default":"ground","values":{"sea":1,"ground":1,"hd-road-markup":1},"expression":1},"model-line-cutout-mode":{"type":"enum","default":"enabled","values
1":{"enabled":1,"disabled":1,"enabled-above-cutout":1},"expression":1}},"promoteId":{"*":{"type":"*"}}}');function e_(r){return r instanceof Number||r instanceof String||r instanceof Boolean?r.valueOf():r}function Lh(r){if(Array.isArray(r))return r.map(Lh);if(r instanceof Object&&!(r instanceof Number||r instanceof String||r instanceof Boolean)){const e={},i=r;for(const o in i)e[o]=Lh(i[o]);return e}return e_(r)}function Af(r){if(r===!0||r===!1)return!0;if(!Array.isArray(r)||r.length===0)return!1;switch(r[0]){case"has":return r.length>=2&&r[1]!=="$id"&&r[1]!=="$type";case"in":return r.length>=3&&(typeof r[1]!="string"||Array.isArray(r[2]));case"!in":case"!has":case"none":return!1;case"==":case"!=":case">":case">=":case"<":case"<=":return r.length!==3||Array.isArray(r[1])||Array.isArray(r[2]);case"any":case"all":for(const e of r.slice(1))if(!Af(e)&&typeof e!="boolean")return!1;return!0;default:return!0}}function zh(r,e="",i=null,o="fill"){if(r==null)return{filter:()=>!0,needGeometry:!1,needFeature:!1};Af(r)||(r=kh(r));const a=r;let c=!0;try{c=(function(v){if(!ma(v))return v;let b=Lh(v);return _u(b),b=Fh(b),b})(a)}catch{console.warn(`Failed to extract static filter. Filter will continue working, but at higher memory usage and slower framerate.
2This is most likely a bug, please report this via https://github.com/mapbox/mapbox-gl-js/issues/new?assignees=&labels=&template=Bug_report.md
3and paste the contents of this message in the report.
4Thank you!
5Filter Expression:
6${JSON.stringify(a,null,2)}
7        `)}let h=null,f=null;if(o!=="background"&&o!=="sky"&&o!=="slot"){f=_e[`filter_${o}`];const v=xc(c,f,e,i);if(v.result==="error")throw new Error(v.value.map(b=>`${b.key}: ${b.message}`).join(", "));h=(b,T,E)=>v.value.evaluate(b,T,{},E)}let _=null,y=null;if(c!==a){const v=xc(a,f,e,i);if(v.result==="error")throw new Error(v.value.map(b=>`${b.key}: ${b.message}`).join(", "));_=(b,T,E,C,P)=>v.value.evaluate(b,T,{},E,void 0,void 0,C,P),y=!Fa(v.value.expression)}return{filter:h,dynamicFilter:_||void 0,needGeometry:t_(c),needFeature:!!y}}function Fh(r){if(!Array.isArray(r))return r;const e=(function(i){if(ey.has(i[0])){for(let o=1;o<i.length;o++)if(ma(i[o]))return!0}return i})(r);return e===!0?e:e.map(i=>Fh(i))}function _u(r){let e=!1;const i=[];if(r[0]==="case"){for(let o=1;o<r.length-1;o+=2)e=e||ma(r[o]),i.push(r[o+1]);i.push(r.at(-1))}else if(r[0]==="match"){e=e||ma(r[1]);for(let o=2;o<r.length-1;o+=2)i.push(r[o+1]);i.push(r.at(-1))}else if(r[0]==="step"){e=e||ma(r[1]);for(let o=1;o<r.length-1;o+=2)i.push(r[o+1])}e&&(r.length=0,r.push("any",...i));for(let o=1;o<r.length;o++)_u(r[o])}function ma(r){if(!Array.isArray(r))return!1;if((e=r[0])==="pitch"||e==="distance-from-center")return!0;var e;
vendor: 13,120 bytes, line 7
7for(let i=1;i<r.length;i++)if(ma(r[i]))return!0;return!1}const ey=new Set(["in","==","!=",">",">=","<","<=","to-boolean"]);function Oh(r,e){return r<e?-1:r>e?1:0}function t_(r){if(!Array.isArray(r))return!1;if(r[0]==="within"||r[0]==="distance")return!0;for(let e=1;e<r.length;e++)if(t_(r[e]))return!0;return!1}function kh(r){if(!r)return!0;const e=r[0];return r.length<=1?e!=="any":e==="=="?Cf(r[1],r[2],"=="):e==="!="?Bh(Cf(r[1],r[2],"==")):e==="<"||e===">"||e==="<="||e===">="?Cf(r[1],r[2],e):e==="any"?(i=r.slice(1),["any"].concat(i.map(kh))):e==="all"?["all"].concat(r.slice(1).map(kh)):e==="none"?["all"].concat(r.slice(1).map(kh).map(Bh)):e==="in"?i_(r[1],r.slice(2)):e==="!in"?Bh(i_(r[1],r.slice(2))):e==="has"?r_(r[1]):e!=="!has"||Bh(r_(r[1]));var i}function Cf(r,e,i){switch(r){case"$type":return[`filter-type-${i}`,e];case"$id":return[`filter-id-${i}`,e];default:return[`filter-${i}`,r,e]}}function i_(r,e){if(e.length===0)return!1;switch(r){case"$type":return["filter-type-in",["literal",e]];case"$id":return["filter-id-in",["literal",e]];default:return e.length>200&&!e.some(i=>typeof i!=typeof e[0])?["filter-in-large",r,["literal",e.sort(Oh)]]:["filter-in-small",r,["literal",e]]}}function r_(r){switch(r){case"$type":return!0;case"$id":return["filter-has-id"];default:return["filter-has",r]}}function Bh(r){return["!",r]}const gu="�";function Nh(r,e){return e?`${r}${gu}${e}`:r}function Il(r){const e=r.indexOf(gu);return e>=0?r.slice(e+1):""}let n_;const Cs=()=>n_||(n_=new Vi({"icon-size":new Xe(_e.layout_symbol["icon-size"]),"icon-image":new Xe(_e.layout_symbol["icon-image"]),"icon-rotate":new Xe(_e.layout_symbol["icon-rotate"]),"icon-offset":new Xe(_e.layout_symbol["icon-offset"]),"text-size":new Xe(_e.layout_symbol["text-size"]),"text-rotate":new Xe(_e.layout_symbol["text-rotate"]),"text-offset":new Xe(_e.layout_symbol["text-offset"])}));let Mf;const o_=()=>Mf||(Mf=new Vi({"icon-opacity":new Xe(_e.paint_symbol["icon-opacity"]),"icon-occlusion-opacity":new Xe(_e.paint_symbol["icon-occlusion-opacity"]),"icon-emissive-strength":new Xe(_e.paint_symbol["icon-emissive-strength"]),"text-emissive-strength":new Xe(_e.paint_symbol["text-emissive-strength"]),"icon-color":new Xe(_e.paint_symbol["icon-color"]),"icon-halo-color":new Xe(_e.paint_symbol["icon-halo-color"]),"icon-halo-width":new Xe(_e.paint_symbol["icon-halo-width"]),"icon-halo-blur":new Xe(_e.paint_symbol["icon-halo-blur"]),"icon-translate":new Xe(_e.paint_symbol["icon-translate"]),"text-opacity":new Xe(_e.paint_symbol["text-opacity"]),"text-occlusion-opacity":new Xe(_e.paint_symbol["text-occlusion-opacity"]),"text-color":new Xe(_e.paint_symbol["text-color"],{runtimeType:no,getOverride:r=>r.textColor,hasOverride:r=>!!r.textColor}),"text-halo-color":new Xe(_e.paint_symbol["text-halo-color"]),"text-halo-width":new Xe(_e.paint_symbol["text-halo-width"]),"text-halo-blur":new Xe(_e.paint_symbol["text-halo-blur"]),"text-translate":new Xe(_e.paint_symbol["text-translate"]),"symbol-z-offset":new Xe(_e.paint_symbol["symbol-z-offset"]),"icon-color-use-theme":new Xe({type:"string",default:"default","property-type":"data-driven"}),"icon-halo-color-use-theme":new Xe({type:"string",default:"default","property-type":"data-driven"}),"text-color-use-theme":new Xe({type:"string",default:"default","property-type":"data-driven"}),"text-halo-color-use-theme":new Xe({type:"string",default:"default","property-type":"data-driven"})}));class ty{constructor(e,i,o,a,c,h){this._conditionSpec=e,this._propertiesSpec=o;const f=xc(e,_e.appearance.condition);if(f.result==="success"&&(this.condition=f.value),this.name=i,o){this.layoutProperties=new Ks(Cs()),this.unevaluatedLayout=new Tc(Cs(),a,c,h),this.paintProperties=new Ks(o_()),this.unevaluatedPaint=new Tc(o_(),a,c,"");for(const _ in o)_ in this.unevaluatedLayout._values?this.unevaluatedLayout.setValue(_,o[_]):_ in this.unevaluatedPaint._values&&this.unevaluatedPaint.setValue(_,o[_])}}isActive(e){return!(this.condition||!e.isHidden||this.name!=="hidden")||this.condition.evaluate(e.globals,e.feature,e.featureState,e.canonical)}getCondition(){return this.condition}getName(){return this.name}getLayoutProperty(e){return this.layoutProperties.get(e)}getPaintProperty(e){return this.paintProperties.get(e)}getUnevaluatedLayoutProperties(){return this.unevaluatedLayout}getUnevaluatedLayoutProperty(e){return this.unevaluatedLayout._values[e]}getUnevaluatedPaintProperty(e){return this.unevaluatedPaint._values[e]}recalculate(e,i,o){this.unevaluatedLayout&&(this.layoutProperties=this.unevaluatedLayout.possiblyEvaluate(e,void 0,i,o)),this.unevaluatedPaint&&(this.paintProperties=this.unevaluatedPaint.possiblyEvaluate(e,void 0,i,""))}serialize(){const e={};e.condition=this.condition.expression.serialize(),this.name&&(e.name=this.name);const i={...this.unevaluatedLayout?this.unevaluatedLayout.serialize():{},...this.unevaluatedPaint?this.unevaluatedPaint.serialize():{}};return Object.keys(i).length>0&&(e.properties=i),e}hasIconLayoutProperties(){const e=this.hasLayoutProperty("icon-image"),i=this.hasLayoutProperty("icon-size"),o=this.hasLayoutProperty("icon-offset"),a=this.hasLayoutProperty("icon-rotate");return e||i||o||a}hasTextLayoutProperties(){const e=this.hasLayoutProperty("text-size"),i=this.hasLayoutProperty("text-offset"),o=this.hasLayoutProperty("text-rotate");return e||i||o}hasIconPaintProperties(){return!!this.unevaluatedPaint&&Object.keys(this.unevaluatedPaint._values).filter(e=>!e.endsWith("-use-theme")).some(e=>(e.startsWith("icon-")||e==="symbol-z-offset")&&this.hasPaintProperty(e))}hasTextPaintProperties(){return!!this.unevaluatedPaint&&Object.keys(this.unevaluatedPaint._values).filter(e=>!e.endsWith("-use-theme")).some(e=>(e.startsWith("text-")||e==="symbol-z-offset")&&this.hasPaintProperty(e))}hasLayoutProperty(e){return this.unevaluatedLayout&&this.unevaluatedLayout._values[e].value!==void 0}hasPaintProperty(e){return this.unevaluatedPaint&&this.unevaluatedPaint._values[e].value!==void 0}}const Pf="-transition",Rf=new Set(["fill","line","background","hillshade","raster"]);class Hn extends dl{constructor(e,i,o,a,c,h){if(super(),this.id=e.id,this.fqid=Nh(this.id,o),this.type=e.type,this.scope=o,this.lut=a,this.options=c,this.iconImageUseTheme=h,this.appearances=new Array,this.appearancesVersion=0,this._featureFilter={filter:()=>!0,needGeometry:!1,needFeature:!1},this._filterCompiled=!1,e.type!=="custom"&&(this.metadata=e.metadata,this.minzoom=e.minzoom,this.maxzoom=e.maxzoom,e.type&&e.type!=="background"&&e.type!=="sky"&&e.type!=="slot"&&(this.source=e.source,this.sourceLayer=e["source-layer"],this.filter=e.filter),e.slot&&(this.slot=e.slot),e.appearances&&this.setAppearances(e.appearances),i.layout&&(this._unevaluatedLayout=new Tc(i.layout,this.scope,c,this.iconImageUseTheme)),i.paint)){this._transitionablePaint=new Jm(i.paint,this.scope,c);for(const f in e.paint)this.setPaintProperty(f,e.paint[f]);for(const f in e.layout)this.setLayoutProperty(f,e.layout[f]);this._transitioningPaint=this._transitionablePaint.untransitioned(),this.paint=new Ks(i.paint)}}onAdd(e){}onRemove(e){}isDraped(e){return!this.is3D(!0)&&Rf.has(this.type)}getLayoutProperty(e){return e==="visibility"?this.visibility:this._unevaluatedLayout.getValue(e)}setLayoutProperty(e,i){if(this.type==="custom"&&e==="visibility")return void(this.visibility=i);const o=this._unevaluatedLayout;o._properties.properties[e]&&(o.setValue(e,i),e==="visibility"&&this.possiblyEvaluateVisibility())}setAppearances(e){this.appearances=[],e.forEach(i=>{this.appearances.push(new ty(i.condition,i.name,i.properties,this.scope,this.options,this.iconImageUseTheme))}),this.appearancesVersion++}possiblyEvaluateVisibility(){this._unevaluatedLayout._values.visibility&&(this.visibility=this._unevaluatedLayout._values.visibility.possiblyEvaluate({zoom:0}))}getPaintProperty(e){return e.endsWith(Pf)?this._transitionablePaint.getTransition(e.slice(0,-11)):this._transitionablePaint.getValue(e)}isPaintProperty(e){return!!this._transitionablePaint._properties.properties[e]}setPaintProperty(e,i){const o=this._transitionablePaint,a=o._properties.properties;if(e.endsWith(Pf)){const b=e.slice(0,-11);return a[b]&&o.setTransition(b,i||void 0),!1}if(!a[e])return!1;const c=o._values[e],h=c.value.isDataDriven(),f=c.value;o.setValue(e,i),this._handleSpecialPaintPropertyUpdate(e);const _=o._values[e].value,y=_.isDataDriven(),v=e.endsWith("pattern")||e==="line-dasharray";return y||h||v||this._handleOverridablePaintPropertyUpdate(e,f,_)}_handleSpecialPaintPropertyUpdate(e){}getProgramIds(){return null}getDefaultProgramParams(e,i,o){return null}_handleOverridablePaintPropertyUpdate(e,i,o){return!1}isHidden(e){return!!(this.minzoom&&e<this.minzoom)||!!(this.maxzoom&&e>=this.maxzoom)||this.visibility==="none"}updateTransitions(e){this._transitioningPaint=this._transitionablePaint.transitioned(e,this._transitioningPaint)}hasTransition(){return this._transitioningPaint.hasTransition()}recalculate(e,i){this._unevaluatedLayout&&(this.layout=this._unevaluatedLayout.possiblyEvaluate(e,void 0,i,this.iconImageUseTheme)),this.paint=this._transitioningPaint.possiblyEvaluate(e,void 0,i)}serialize(){const e={id:this.id,type:this.type,slot:this.slot,source:this.source,"source-layer":this.sourceLayer,metadata:this.metadata,minzoom:this.minzoom,maxzoom:this.maxzoom,filter:this.filter,layout:this._unevaluatedLayout&&this._unevaluatedLayout.serialize(),paint:this._transitionablePaint&&this._transitionablePaint.serialize()};return this.appearances.length!==0&&(e.appearances=this.appearances.map(i=>i.serialize())),Ee(e,(i,o)=>!(i===void 0||o==="layout"&&!Object.keys(i).length||o==="paint"&&!Object.keys(i).length))}is3D(e){return!1}hasElevation(){return!1}mayUse(e){return!1}prepare(){return Promise.resolve()}isSky(){return!1}isTileClipped(){return!1}hasOffscreenPass(){return!1}hasShadowPass(){return!1}canCastShadows(){return!1}hasLightBeamPass(){return!1}cutoffRange(){return 0}tileCoverLift(){return 0}resize(){}_clear(){}isStateDependent(){for(const e in this.paint._values){const i=this.paint.get(e);if(i instanceof ns&&xh(i.property.specification)&&(i.value.kind==="source"||i.value.kind==="composite")&&i.value.isStateDependent)return!0}for(const e of this.appearances)if(!gl(e.condition.expression))return!0;return!1}compileFilter(e){this._filterCompiled||(this._featureFilter=zh(this.filter,this.scope,e),this._filterCompiled=!0)}invalidateCompiledFilter(){this._filterCompiled=!1}dynamicFilter(){return this._featureFilter.dynamicFilter}dynamicFilterNeedsFeature(){return this._featureFilter.needFeature}dynamicFilterNeedsGeometry(){return this._featureFilter.needGeometry}getLayerRenderingStats(){return this._stats}resetLayerRenderingStats(e){this._stats&&(e.renderPass==="shadow"?this._stats.numRenderedVerticesInShadowPass=0:this._stats.numRenderedVerticesInTransparentPass=0)}getAppearances(){return this.appearances}queryRenderedFeatures(e,i,o){return{}}queryRadius(e){}queryIntersectsFeature(e,i,o,a,c,h,f,_,y,v){}}function Vh(r,e,i){if(!r._unevaluatedLayout)return!1;const o=r._unevaluatedLayout.getValue(e);return o!==void 0&&(typeof o!="string"||i(o))}function Sc(r,e,i=2){const o=e&&e.length,a=o?e[0]*i:r.length;let c=s_(r,0,a,i,!0);const h=[];if(!c||c.next===c.prev)return h;let f,_,y;if(o&&(c=(function(v,b,T,E){const C=[];for(let P=0,R=b.length;P<R;P++){const z=s_(v,b[P]*E,P<R-1?b[P+1]*E:v.length,E,!1);z===z.next&&(z.steiner=!0),C.push(Cl(z))}C.sort(ny);for(let P=0;P<C.length;P++)T=oy(C[P],T);return T})(r,e,c,i)),r.length>80*i){f=r[0],_=r[1];let v=f,b=_;for(let T=i;T<a;T+=i){const E=r[T],C=r[T+1];E<f&&(f=E),C<_&&(_=C),E>v&&(v=E),C>b&&(b=C)}y=Math.max(v-f,b-_),y=y!==0?32767/y:0}return yu(c,h,i,f,_,y,0),h}function s_(r,e,i,o,a){let c;if(a===(function(h,f,_,y){let v=0;for(let b=f,T=_-y;b<_;b+=y)v+=(h[T]-h[b])*(h[b+1]+h[T+1]),T=b;return v})(r,e,i,o)>0)for(let h=e;h<i;h+=o)c=Of(h/o|0,r[h],r[h+1],c);else for(let h=i-o;h>=e;h-=o)c=Of(h/o|0,r[h],r[h+1],c);return c&&Ml(c,c.next)&&(wu(c),c=c.next),c}function Al(r,e){if(!r)return r;e||(e=r);let i,o=r;do if(i=!1,o.steiner||!Ml(o,o.next)&&Sr(o.prev,o,o.next)!==0)o=o.next;else{if(wu(o),o=e=o.prev,o===o.next)break;i=!0}while(i||o!==e);return e}function yu(r,e,i,o,a,c,h){if(!r)return;!h&&c&&(function(_,y,v,b){let T=_;do T.z===0&&(T.z=zf(T.x,T.y,y,v,b)),T.prevZ=T.prev,T.nextZ=T.next,T=T.next;while(T!==_);T.prevZ.nextZ=null,T.prevZ=null,(function(E){let C,P=1;do{let R,z=E;E=null;let V=null;for(C=0;z;){C++;let N=z,U=0;for(let W=0;W<P&&(U++,N=N.nextZ,N);W++);let q=P;for(;U>0||q>0&&N;)U!==0&&(q===0||!N||z.z<=N.z)?(R=z,z=z.nextZ,U--):(R=N,N=N.nextZ,q--),V?V.nextZ=R:E=R,R.prevZ=V,V=R;z=N}V.nextZ=null,P*=2}while(C>1)})(T)})(r,o,a,c);let f=r;for(;r.prev!==r.next;){const _=r.prev,y=r.next;if(c?Df(r,o,a,c):iy(r))e.push(_.i,r.i,y.i),wu(r),r=y.next,f=y.next;else if((r=y)===f){h?h===1?yu(r=ry(Al(r),e),e,i,o,a,c,2):h===2&&Lf(r,e,i,o,a,c):yu(Al(r),e,i,o,a,c,1);break}}}function iy(r){const e=r.prev,i=r,o=r.next;if(Sr(e,i,o)>=0)return!1;const a=e.x,c=i.x,h=o.x,f=e.y,_=i.y,y=o.y,v=Math.min(a,c,h),b=Math.min(f,_,y),T=Math.max(a,c,h),E=Math.max(f,_,y);let C=o.next;for(;C!==e;){if(C.x>=v&&C.x<=T&&C.y>
vendor: 1,289 bytes, line 7
7=b&&C.y<=E&&vu(a,f,c,_,h,y,C.x,C.y)&&Sr(C.prev,C,C.next)>=0)return!1;C=C.next}return!0}function Df(r,e,i,o){const a=r.prev,c=r,h=r.next;if(Sr(a,c,h)>=0)return!1;const f=a.x,_=c.x,y=h.x,v=a.y,b=c.y,T=h.y,E=Math.min(f,_,y),C=Math.min(v,b,T),P=Math.max(f,_,y),R=Math.max(v,b,T),z=zf(E,C,e,i,o),V=zf(P,R,e,i,o);let N=r.prevZ,U=r.nextZ;for(;N&&N.z>=z&&U&&U.z<=V;){if(N.x>=E&&N.x<=P&&N.y>=C&&N.y<=R&&N!==a&&N!==h&&vu(f,v,_,b,y,T,N.x,N.y)&&Sr(N.prev,N,N.next)>=0||(N=N.prevZ,U.x>=E&&U.x<=P&&U.y>=C&&U.y<=R&&U!==a&&U!==h&&vu(f,v,_,b,y,T,U.x,U.y)&&Sr(U.prev,U,U.next)>=0))return!1;U=U.nextZ}for(;N&&N.z>=z;){if(N.x>=E&&N.x<=P&&N.y>=C&&N.y<=R&&N!==a&&N!==h&&vu(f,v,_,b,y,T,N.x,N.y)&&Sr(N.prev,N,N.next)>=0)return!1;N=N.prevZ}for(;U&&U.z<=V;){if(U.x>=E&&U.x<=P&&U.y>=C&&U.y<=R&&U!==a&&U!==h&&vu(f,v,_,b,y,T,U.x,U.y)&&Sr(U.prev,U,U.next)>=0)return!1;U=U.nextZ}return!0}function ry(r,e){let i=r;do{const o=i.prev,a=i.next.next;!Ml(o,a)&&Ff(o,i,i.next,a)&&bu(o,a)&&bu(a,o)&&(e.push(o.i,i.i,a.i),wu(i),wu(i.next),i=r=a),i=i.next}while(i!==r);return Al(i)}function Lf(r,e,i,o,a,c){let h=r;do{let f=h.next.next;for(;f!==h.prev;){if(h.i!==f.i&&sy(h,f)){let _=l_(h,f);return h=Al(h,h.next),_=Al(_,_.next),yu(h,e,i,o,a,c,0),void yu(_,e,i,o,a,c,0)}f=f.next}h=h.next}while(h!==r)}function ny(r,e){let i=r.x-e.x;
vendor: 11,453 bytes, line 7
7return i===0&&(i=r.y-e.y,i===0)&&(i=(r.next.y-r.y)/(r.next.x-r.x)-(e.next.y-e.y)/(e.next.x-e.x)),i}function oy(r,e){const i=(function(a,c){let h=c;const f=a.x,_=a.y;let y,v=-1/0;if(Ml(a,h))return h;do{if(Ml(a,h.next))return h.next;if(_<=h.y&&_>=h.next.y&&h.next.y!==h.y){const P=h.x+(_-h.y)*(h.next.x-h.x)/(h.next.y-h.y);if(P<=f&&P>v&&(v=P,y=h.x<h.next.x?h:h.next,P===f))return y}h=h.next}while(h!==c);if(!y)return null;const b=y,T=y.x,E=y.y;let C=1/0;h=y;do{if(f>=h.x&&h.x>=T&&f!==h.x&&xu(_<E?f:v,_,T,E,_<E?v:f,_,h.x,h.y)){const P=Math.abs(_-h.y)/(f-h.x);bu(h,a)&&(P<C||P===C&&(h.x>y.x||h.x===y.x&&a_(y,h)))&&(y=h,C=P)}h=h.next}while(h!==b);return y})(r,e);if(!i)return e;const o=l_(i,r);return Al(o,o.next),Al(i,i.next)}function a_(r,e){return Sr(r.prev,r,e.prev)<0&&Sr(e.next,r,r.next)<0}function zf(r,e,i,o,a){return(r=1431655765&((r=858993459&((r=252645135&((r=16711935&((r=(r-i)*a|0)|r<<8))|r<<4))|r<<2))|r<<1))|(e=1431655765&((e=858993459&((e=252645135&((e=16711935&((e=(e-o)*a|0)|e<<8))|e<<4))|e<<2))|e<<1))<<1}function Cl(r){let e=r,i=r;do(e.x<i.x||e.x===i.x&&e.y<i.y)&&(i=e),e=e.next;while(e!==r);return i}function xu(r,e,i,o,a,c,h,f){return(a-h)*(e-f)>=(r-h)*(c-f)&&(r-h)*(o-f)>=(i-h)*(e-f)&&(i-h)*(c-f)>=(a-h)*(o-f)}function vu(r,e,i,o,a,c,h,f){return!(r===h&&e===f)&&xu(r,e,i,o,a,c,h,f)}function sy(r,e){return r.next.i!==e.i&&r.prev.i!==e.i&&!(function(i,o){let a=i;do{if(a.i!==i.i&&a.next.i!==i.i&&a.i!==o.i&&a.next.i!==o.i&&Ff(a,a.next,i,o))return!0;a=a.next}while(a!==i);return!1})(r,e)&&(bu(r,e)&&bu(e,r)&&(function(i,o){let a=i,c=!1;const h=(i.x+o.x)/2,f=(i.y+o.y)/2;do a.y>f!=a.next.y>f&&a.next.y!==a.y&&h<(a.next.x-a.x)*(f-a.y)/(a.next.y-a.y)+a.x&&(c=!c),a=a.next;while(a!==i);return c})(r,e)&&(Sr(r.prev,r,e.prev)||Sr(r,e.prev,e))||Ml(r,e)&&Sr(r.prev,r,r.next)>0&&Sr(e.prev,e,e.next)>0)}function Sr(r,e,i){return(e.y-r.y)*(i.x-e.x)-(e.x-r.x)*(i.y-e.y)}function Ml(r,e){return r.x===e.x&&r.y===e.y}function Ff(r,e,i,o){const a=Uh(Sr(r,e,i)),c=Uh(Sr(r,e,o)),h=Uh(Sr(i,o,r)),f=Uh(Sr(i,o,e));return a!==c&&h!==f||!(a!==0||!go(r,i,e))||!(c!==0||!go(r,o,e))||!(h!==0||!go(i,r,o))||!(f!==0||!go(i,e,o))}function go(r,e,i){return e.x<=Math.max(r.x,i.x)&&e.x>=Math.min(r.x,i.x)&&e.y<=Math.max(r.y,i.y)&&e.y>=Math.min(r.y,i.y)}function Uh(r){return r>0?1:r<0?-1:0}function bu(r,e){return Sr(r.prev,r,r.next)<0?Sr(r,e,r.next)>=0&&Sr(r,r.prev,e)>=0:Sr(r,e,r.prev)<0||Sr(r,r.next,e)<0}function l_(r,e){const i=Hi(r.i,r.x,r.y),o=Hi(e.i,e.x,e.y),a=r.next,c=e.prev;return r.next=e,e.prev=r,i.next=a,a.prev=i,o.next=i,i.prev=o,c.next=o,o.prev=c,o}function Of(r,e,i,o){const a=Hi(r,e,i);return o?(a.next=o.next,a.prev=o,o.next.prev=a,o.next=a):(a.prev=a,a.next=a),a}function wu(r){r.next.prev=r.prev,r.prev.next=r.next,r.prevZ&&(r.prevZ.nextZ=r.nextZ),r.nextZ&&(r.nextZ.prevZ=r.prevZ)}function Hi(r,e,i){return{i:r,x:e,y:i,prev:null,next:null,z:0,prevZ:null,nextZ:null,steiner:!1}}function c_(r,e,i=1){if(!r)return null;const o=typeof r=="string"?nn.from(r).getPrimary():r.getPrimary(),a=typeof r=="string"?null:r.getSecondary();for(const c of[o,a]){if(!c)continue;const h=c.id.toString();e.has(h)||e.set(h,[]),c.scaleSelf(i),e.get(h).push(c)}return{primary:o.toString(),secondary:a?a.toString():null}}function kf(r,e,i,o){const a=o.patternDependencies;let c=!1;for(const h of e){const f=h.paint.get(`${r}-pattern`);f.isConstant()||(c=!0),c_(f.constantOr(null),a,i)&&(c=!0)}return c}function Bf(r,e,i,o,a,c){const h=c.patternDependencies;for(const f of e){const _=f.paint.get(`${r}-pattern`).value;if(_.kind!=="constant"){const y=c_(_.evaluate({zoom:o},i,{},void 0,c.availableImages),h,a);if(!y)continue;const{primary:v,secondary:b}=y;v&&(i.patterns[f.id]=[v,b].filter(Boolean))}}return i}const Zn=rt/Math.PI/2,Pl=64,Nf=[Pl,32,16],os=-Zn,ss=Zn;function Ec(r,e,i,o=Zn){return i=Qt(i),[r*Math.sin(i)*o,-e*o,r*Math.cos(i)*o]}function Rl(r,e,i){return Ec(Math.cos(Qt(r)),Math.sin(Qt(r)),e,i)}const Ic=63710088e-1,Vf=2*Math.PI*Ic;class ui{constructor(e,i){if(isNaN(e)||isNaN(i))throw new Error(`Invalid LngLat object: (${e}, ${i})`);if(this.lng=+e,this.lat=+i,this.lat>90||this.lat<-90)throw new Error("Invalid LngLat latitude value: must be between -90 and 90")}wrap(){return new ui(he(this.lng,-180,180),this.lat)}toArray(){return[this.lng,this.lat]}toString(){return`LngLat(${this.lng}, ${this.lat})`}distanceTo(e){const i=Math.PI/180,o=this.lat*i,a=e.lat*i,c=Math.sin(o)*Math.sin(a)+Math.cos(o)*Math.cos(a)*Math.cos((e.lng-this.lng)*i);return Ic*Math.acos(Math.min(c,1))}toBounds(e=0){const i=360*e/40075017,o=i/Math.cos(Math.PI/180*this.lat);return new Ga({lng:this.lng-o,lat:this.lat-i},{lng:this.lng+o,lat:this.lat+i})}toEcef(e){return Rl(this.lat,this.lng,Zn+e*Zn/Ic)}static convert(e){if(e instanceof ui)return e;if(Array.isArray(e)&&(e.length===2||e.length===3))return new ui(Number(e[0]),Number(e[1]));if(!Array.isArray(e)&&typeof e=="object"&&e!==null)return new ui(Number("lng"in e?e.lng:e.lon),Number(e.lat));throw new 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>]")}}class Ga{constructor(e,i){e&&(i?this.setSouthWest(e).setNorthEast(i):Array.isArray(e)&&e.length===4?this.setSouthWest([e[0],e[1]]).setNorthEast([e[2],e[3]]):this.setSouthWest(e[0]).setNorthEast(e[1]))}setNorthEast(e){return this._ne=e instanceof ui?new ui(e.lng,e.lat):ui.convert(e),this}setSouthWest(e){return this._sw=e instanceof ui?new ui(e.lng,e.lat):ui.convert(e),this}extend(e){const i=this._sw,o=this._ne;let a,c;if(e instanceof ui)a=e,c=e;else{if(!(e instanceof Ga))return Array.isArray(e)?e.length===4||e.every(Array.isArray)?this.extend(Ga.convert(e)):this.extend(ui.convert(e)):typeof e=="object"&&e!==null&&Object.hasOwn(e,"lat")&&(Object.hasOwn(e,"lon")||Object.hasOwn(e,"lng"))?this.extend(ui.convert(e)):this;if(a=e._sw,c=e._ne,!a||!c)return this}return i||o?(i.lng=Math.min(a.lng,i.lng),i.lat=Math.min(a.lat,i.lat),o.lng=Math.max(c.lng,o.lng),o.lat=Math.max(c.lat,o.lat)):(this._sw=new ui(a.lng,a.lat),this._ne=new ui(c.lng,c.lat)),this}getCenter(){return new ui((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 ui(this.getWest(),this.getNorth())}getSouthEast(){return new ui(this.getEast(),this.getSouth())}getWest(){return this._sw.lng}getSouth(){return this._sw.lat}getEast(){return this._ne.lng}getNorth(){return this._ne.lat}toArray(){return[this._sw.toArray(),this._ne.toArray()]}toString(){return`LngLatBounds(${this._sw.toString()}, ${this._ne.toString()})`}isEmpty(){return!(this._sw&&this._ne)}contains(e){const{lng:i,lat:o}=ui.convert(e);let a=this._sw.lng<=i&&i<=this._ne.lng;return this._sw.lng>this._ne.lng&&(a=this._sw.lng>=i&&i>=this._ne.lng),this._sw.lat<=o&&o<=this._ne.lat&&a}static convert(e){if(e)return e instanceof Ga?e:new Ga(e)}}function Uf(r){return Vf*Math.cos(r*Math.PI/180)}function Wn(r,e){return r/Uf(e)}function jf(r,e){return r*Uf(on(e))}const as=85.051129;function u_(r){return Math.cos(Qt(Y(r,-85.051129,as)))}function Dl(r,e){const i=Y(e,0,25.5),o=Math.pow(2,i);return u_(r)*Vf/(512*o)}function h_(r){return 1/Math.cos(r*Math.PI/180)}function yo(r,e=0){const i=Math.exp(Math.PI*(1-(r.y+e/rt)/(1<<r.z)*2));return 80150034*i/(i*i+1)/rt/(1<<r.z)}class kn{constructor(e,i,o=0){this.x=+e,this.y=+i,this.z=+o}static fromLngLat(e,i=0){const o=ui.convert(e);return new kn(Ss(o.lng),vn(o.lat),Wn(i,o.lat))}toLngLat(){return new ui($r(this.x),on(this.y))}toAltitude(){return jf(this.z,this.y)}meterInMercatorCoordinateUnits(){return 1/Vf*h_(on(this.y))}}function Gf(r,e,i,o,a,c,h,f,_){const y=(e+o)/2,v=(i+a)/2,b=new Ue(y,v);f(b),(function(T,E,C,P,R,z){const V=C-R,N=P-z;return Math.abs((P-E)*V-(C-T)*N)/Math.hypot(V,N)})(b.x,b.y,c.x,c.y,h.x,h.y)>=_?(Gf(r,e,i,y,v,c,b,f,_),Gf(r,y,v,o,a,b,h,f,_)):r.push(h)}function d_(r,e,i){let o=r[0],a=o.x,c=o.y;e(o);const h=[o];for(let f=1;f<r.length;f++){const _=r[f],{x:y,y:v}=_;e(_),Gf(h,a,c,y,v,o,_,e,i),a=y,c=v,o=_}return h}function $f(r,e,i,o){if(o(e,i)){const a=e.add(i)._mult(.5);$f(r,e,a,o),$f(r,a,i,o)}else r.push(i)}function ay(r,e){let i=r[0];const o=[i];for(let a=1;a<r.length;a++){const c=r[a];$f(o,i,c,e),i=c}return o}const qf=Math.pow(2,14)-1,f_=-qf-1;function ly(r,e){const i=Math.round(r.x*e),o=Math.round(r.y*e);return r.x=Y(i,f_,qf),r.y=Y(o,f_,qf),(i<r.x||i>r.x+1||o<r.y||o>r.y+1)&&ht("Geometry exceeds allowed extent, reduce your vector tile buffer size"),r}function ls(r,e,i){const o=r.loadGeometry(),a=r.extent,c=rt/a;if(e&&i&&i.projection.isReprojectedInTileSpace){const h=1<<e.z,{scale:f,x:_,y,projection:v}=i,b=T=>{const E=$r((e.x+T.x/a)/h),C=on((e.y+T.y/a)/h),P=v.project(E,C);T.x=(P.x*f-_)*a,T.y=(P.y*f-y)*a};for(let T=0;T<o.length;T++)if(r.type!==1)o[T]=d_(o[T],b,1);else{const E=[];for(const C of o[T])C.x<0||C.x>=a||C.y<0||C.y>=a||(b(C),E.push(C));o[T]=E}}for(const h of o)for(const f of h)ly(f,c);return o}function Vo(r,e){return{type:r.type,id:r.id,properties:r.properties,geometry:e?ls(r):[]}}const jh={Int8:Int8Array,Uint8:Uint8Array,Int16:Int16Array,Uint16:Uint16Array,Int32:Int32Array,Uint32:Uint32Array,Float32:Float32Array};class Ac{constructor(e,i){this._structArray=e,this._pos1=i*this.size,this._pos2=this._pos1/2,this._pos4=this._pos1/4,this._pos8=this._pos1/8}}const cy=new ArrayBuffer(0);class zi{constructor(){this._reallocCount=0,this.capacity=0,this.length=0}static serialize(e,i){return e._trim(),i&&e.arrayBuffer&&i.add(e.arrayBuffer),{length:e.length,arrayBuffer:e.arrayBuffer}}static deserialize(e){const i=Object.create(this.prototype);return i.arrayBuffer=e.arrayBuffer,i.length=e.length,e.arrayBuffer?i.capacity=e.arrayBuffer.byteLength/i.bytesPerElement:(i.capacity=0,i.arrayBuffer=cy),i._refreshViews(),i}_trim(){this.length!==this.capacity&&(this.capacity=this.length,this.arrayBuffer=this.arrayBuffer.slice(0,this.length*this.bytesPerElement),this._refreshViews())}clear(){this.length=0}resize(e){this.reserve(e),this.length=e}resizeExact(e){this.reserveExact(e),this.length=e}reserve(e){e>this.capacity&&this._allocate(Math.max(e,Math.floor(5*this.capacity),128))}reserveExact(e){(e>this.capacity||!this.arrayBuffer)&&this._allocate(e)}_allocate(e){this._reallocCount++,this.capacity=e,this.arrayBuffer=new ArrayBuffer(this.capacity*this.bytesPerElement);const i=this.uint8;this._refreshViews(),i&&this.uint8.set(i)}reserveForAdditional(e){this.reserve(this.length+e)}_refreshViews(){throw new Error("StructArray#_refreshViews() must be implemented by each concrete StructArray layout")}emplace(...e){throw new Error("StructArray#emplace() must be implemented by each concrete StructArray layout")}emplaceBack(...e){throw new Error("StructArray#emplaceBack() must be implemented by each concrete StructArray layout")}destroy(){this.int8=this.uint8=this.int16=this.uint16=this.int32=this.uint32=this.float32=null,this.arrayBuffer=null}}function Gt(r,e=1){let i=0,o=0;return{members:r.map(a=>{const c=jh[a.type].BYTES_PER_ELEMENT,h=i=Hf(i,Math.max(e,c)),f=a.components||1;return o=Math.max(o,c),i+=c*f,{name:a.name,type:a.type,components:f,offset:h}}),size:Hf(i,Math.max(o,e)),alignment:e}}function Hf(r,e){return Math.ceil(r/e)*e}class _a extends zi{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(e,i){const o=this.length;return this.resize(o+1),this.emplace(o,e,i)}emplace(e,i,o){const a=2*e;return this.int16[a+0]=i,this.int16[a+1]=o,e}}
vendor: 20,782 bytes, line 7
7_a.prototype.bytesPerElement=4,nt(_a,"StructArrayLayout2i4");class Ms extends zi{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(e,i,o){const a=this.length;return this.resize(a+1),this.emplace(a,e,i,o)}emplace(e,i,o,a){const c=3*e;return this.int16[c+0]=i,this.int16[c+1]=o,this.int16[c+2]=a,e}}Ms.prototype.bytesPerElement=6,nt(Ms,"StructArrayLayout3i6");class Gh extends zi{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(e,i,o,a){const c=this.length;return this.resize(c+1),this.emplace(c,e,i,o,a)}emplace(e,i,o,a,c){const h=4*e;return this.int16[h+0]=i,this.int16[h+1]=o,this.uint16[h+2]=a,this.uint16[h+3]=c,e}}Gh.prototype.bytesPerElement=8,nt(Gh,"StructArrayLayout2i2ui8");class Js extends zi{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(e){const i=this.length;return this.resize(i+1),this.emplace(i,e)}emplace(e,i){return this.float32[1*e+0]=i,e}}Js.prototype.bytesPerElement=4,nt(Js,"StructArrayLayout1f4");class Tu extends zi{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(e,i,o){const a=this.length;return this.resize(a+1),this.emplace(a,e,i,o)}emplace(e,i,o,a){const c=4*e,h=2*e;return this.int16[c+0]=i,this.int16[c+1]=o,this.float32[h+1]=a,e}}Tu.prototype.bytesPerElement=8,nt(Tu,"StructArrayLayout2i1f8");class Zf extends zi{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(e,i,o){const a=this.length;return this.resize(a+1),this.emplace(a,e,i,o)}emplace(e,i,o,a){const c=4*e;return this.int16[c+0]=i,this.int16[c+1]=o,this.int16[c+2]=a,e}}Zf.prototype.bytesPerElement=8,nt(Zf,"StructArrayLayout3i8");class Wf extends zi{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(e,i,o,a){const c=this.length;return this.resize(c+1),this.emplace(c,e,i,o,a)}emplace(e,i,o,a,c){const h=4*e;return this.int16[h+0]=i,this.int16[h+1]=o,this.int16[h+2]=a,this.int16[h+3]=c,e}}Wf.prototype.bytesPerElement=8,nt(Wf,"StructArrayLayout4i8");class $h extends zi{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(e,i,o,a,c){const h=this.length;return this.resize(h+1),this.emplace(h,e,i,o,a,c)}emplace(e,i,o,a,c,h){const f=5*e;return this.int16[f+0]=i,this.int16[f+1]=o,this.int16[f+2]=a,this.int16[f+3]=c,this.int16[f+4]=h,e}}$h.prototype.bytesPerElement=10,nt($h,"StructArrayLayout5i10");class qh extends zi{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(e,i,o,a,c,h,f){const _=this.length;return this.resize(_+1),this.emplace(_,e,i,o,a,c,h,f)}emplace(e,i,o,a,c,h,f,_){const y=6*e,v=12*e,b=3*e;return this.int16[y+0]=i,this.int16[y+1]=o,this.uint8[v+4]=a,this.uint8[v+5]=c,this.uint8[v+6]=h,this.uint8[v+7]=f,this.float32[b+2]=_,e}}qh.prototype.bytesPerElement=12,nt(qh,"StructArrayLayout2i4ub1f12");class cs extends zi{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(e,i,o){const a=this.length;return this.resize(a+1),this.emplace(a,e,i,o)}emplace(e,i,o,a){const c=3*e;return this.float32[c+0]=i,this.float32[c+1]=o,this.float32[c+2]=a,e}}cs.prototype.bytesPerElement=12,nt(cs,"StructArrayLayout3f12");class $a extends zi{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(e,i,o,a,c){const h=this.length;return this.resize(h+1),this.emplace(h,e,i,o,a,c)}emplace(e,i,o,a,c,h){const f=6*e,_=3*e;return this.uint16[f+0]=i,this.uint16[f+1]=o,this.uint16[f+2]=a,this.uint16[f+3]=c,this.float32[_+2]=h,e}}$a.prototype.bytesPerElement=12,nt($a,"StructArrayLayout4ui1f12");class Cc extends zi{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(e,i,o,a){const c=this.length;return this.resize(c+1),this.emplace(c,e,i,o,a)}emplace(e,i,o,a,c){const h=4*e;return this.uint16[h+0]=i,this.uint16[h+1]=o,this.uint16[h+2]=a,this.uint16[h+3]=c,e}}Cc.prototype.bytesPerElement=8,nt(Cc,"StructArrayLayout4ui8");class Su extends zi{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(e,i,o,a,c,h){const f=this.length;return this.resize(f+1),this.emplace(f,e,i,o,a,c,h)}emplace(e,i,o,a,c,h,f){const _=6*e;return this.int16[_+0]=i,this.int16[_+1]=o,this.int16[_+2]=a,this.int16[_+3]=c,this.int16[_+4]=h,this.int16[_+5]=f,e}}Su.prototype.bytesPerElement=12,nt(Su,"StructArrayLayout6i12");class Hh extends zi{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(e,i,o,a,c,h,f,_,y,v,b,T){const E=this.length;return this.resize(E+1),this.emplace(E,e,i,o,a,c,h,f,_,y,v,b,T)}emplace(e,i,o,a,c,h,f,_,y,v,b,T,E){const C=12*e;return this.int16[C+0]=i,this.int16[C+1]=o,this.int16[C+2]=a,this.int16[C+3]=c,this.uint16[C+4]=h,this.uint16[C+5]=f,this.uint16[C+6]=_,this.uint16[C+7]=y,this.int16[C+8]=v,this.int16[C+9]=b,this.int16[C+10]=T,this.int16[C+11]=E,e}}Hh.prototype.bytesPerElement=24,nt(Hh,"StructArrayLayout4i4ui4i24");class Zh extends zi{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(e,i,o,a,c,h){const f=this.length;return this.resize(f+1),this.emplace(f,e,i,o,a,c,h)}emplace(e,i,o,a,c,h,f){const _=10*e,y=5*e;return this.int16[_+0]=i,this.int16[_+1]=o,this.int16[_+2]=a,this.float32[y+2]=c,this.float32[y+3]=h,this.float32[y+4]=f,e}}Zh.prototype.bytesPerElement=20,nt(Zh,"StructArrayLayout3i3f20");class ga extends zi{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(e,i,o,a){const c=this.length;return this.resize(c+1),this.emplace(c,e,i,o,a)}emplace(e,i,o,a,c){const h=4*e;return this.float32[h+0]=i,this.float32[h+1]=o,this.float32[h+2]=a,this.float32[h+3]=c,e}}ga.prototype.bytesPerElement=16,nt(ga,"StructArrayLayout4f16");class Xf extends zi{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint32=new Uint32Array(this.arrayBuffer)}emplaceBack(e){const i=this.length;return this.resize(i+1),this.emplace(i,e)}emplace(e,i){return this.uint32[1*e+0]=i,e}}Xf.prototype.bytesPerElement=4,nt(Xf,"StructArrayLayout1ul4");class us extends zi{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(e,i){const o=this.length;return this.resize(o+1),this.emplace(o,e,i)}emplace(e,i,o){const a=2*e;return this.uint16[a+0]=i,this.uint16[a+1]=o,e}}us.prototype.bytesPerElement=4,nt(us,"StructArrayLayout2ui4");class Yf extends zi{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer),this.uint32=new Uint32Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(e,i,o,a,c,h,f,_,y,v,b,T,E){const C=this.length;return this.resize(C+1),this.emplace(C,e,i,o,a,c,h,f,_,y,v,b,T,E)}emplace(e,i,o,a,c,h,f,_,y,v,b,T,E,C){const P=20*e,R=10*e;return this.int16[P+0]=i,this.int16[P+1]=o,this.int16[P+2]=a,this.int16[P+3]=c,this.int16[P+4]=h,this.float32[R+3]=f,this.float32[R+4]=_,this.float32[R+5]=y,this.float32[R+6]=v,this.int16[P+14]=b,this.uint32[R+8]=T,this.uint16[P+18]=E,this.uint16[P+19]=C,e}}Yf.prototype.bytesPerElement=40,nt(Yf,"StructArrayLayout5i4f1i1ul2ui40");class Wh extends zi{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(e,i,o,a,c,h,f){const _=this.length;return this.resize(_+1),this.emplace(_,e,i,o,a,c,h,f)}emplace(e,i,o,a,c,h,f,_){const y=8*e;return this.int16[y+0]=i,this.int16[y+1]=o,this.int16[y+2]=a,this.int16[y+4]=c,this.int16[y+5]=h,this.int16[y+6]=f,this.int16[y+7]=_,e}}Wh.prototype.bytesPerElement=16,nt(Wh,"StructArrayLayout3i2i2i16");class Kf extends zi{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(e,i,o,a,c){const h=this.length;return this.resize(h+1),this.emplace(h,e,i,o,a,c)}emplace(e,i,o,a,c,h){const f=4*e,_=8*e;return this.float32[f+0]=i,this.float32[f+1]=o,this.float32[f+2]=a,this.int16[_+6]=c,this.int16[_+7]=h,e}}Kf.prototype.bytesPerElement=16,nt(Kf,"StructArrayLayout2f1f2i16");class Jf extends zi{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(e,i,o,a,c,h){const f=this.length;return this.resize(f+1),this.emplace(f,e,i,o,a,c,h)}emplace(e,i,o,a,c,h,f){const _=20*e,y=5*e;return this.uint8[_+0]=i,this.uint8[_+1]=o,this.float32[y+1]=a,this.float32[y+2]=c,this.float32[y+3]=h,this.float32[y+4]=f,e}}Jf.prototype.bytesPerElement=20,nt(Jf,"StructArrayLayout2ub4f20");class sn extends zi{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(e,i,o){const a=this.length;return this.resize(a+1),this.emplace(a,e,i,o)}emplace(e,i,o,a){const c=3*e;return this.uint16[c+0]=i,this.uint16[c+1]=o,this.uint16[c+2]=a,e}}sn.prototype.bytesPerElement=6,nt(sn,"StructArrayLayout3ui6");class Xh extends zi{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer),this.uint32=new Uint32Array(this.arrayBuffer)}emplaceBack(e,i,o,a,c,h,f,_,y,v,b,T,E,C,P,R,z,V,N,U,q){const W=this.length;return this.resize(W+1),this.emplace(W,e,i,o,a,c,h,f,_,y,v,b,T,E,C,P,R,z,V,N,U,q)}emplace(e,i,o,a,c,h,f,_,y,v,b,T,E,C,P,R,z,V,N,U,q,W){const se=30*e,X=15*e,ie=60*e;return this.int16[se+0]=i,this.int16[se+1]=o,this.int16[se+2]=a,this.float32[X+2]=c,this.float32[X+3]=h,this.uint16[se+8]=f,this.uint16[se+9]=_,this.uint32[X+5]=y,this.uint32[X+6]=v,this.uint32[X+7]=b,this.uint16[se+16]=T,this.uint16[se+17]=E,this.uint16[se+18]=C,this.float32[X+10]=P,this.float32[X+11]=R,this.uint8[ie+48]=z,this.uint8[ie+49]=V,this.uint8[ie+50]=N,this.uint32[X+13]=U,this.int16[se+28]=q,this.uint8[ie+58]=W,e}}Xh.prototype.bytesPerElement=60,nt(Xh,"StructArrayLayout3i2f2ui3ul3ui2f3ub1ul1i1ub60");class Qf extends zi{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer),this.uint32=new Uint32Array(this.arrayBuffer)}emplaceBack(e,i,o,a,c,h,f,_,y,v,b,T,E,C,P,R,z,V,N,U,q,W,se,X,ie,re,oe,me,xe,we,Ce,Se,qe){const Me=this.length;return this.resize(Me+1),this.emplace(Me,e,i,o,a,c,h,f,_,y,v,b,T,E,C,P,R,z,V,N,U,q,W,se,X,ie,re,oe,me,xe,we,Ce,Se,qe)}emplace(e,i,o,a,c,h,f,_,y,v,b,T,E,C,P,R,z,V,N,U,q,W,se,X,ie,re,oe,me,xe,we,Ce,Se,qe,Me){const Ie=20*e,Pe=40*e,Ne=80*e;return this.float32[Ie+0]=i,this.float32[Ie+1]=o,this.int16[Pe+4]=a,this.int16[Pe+5]=c,this.int16[Pe+6]=h,this.int16[Pe+7]=f,this.int16[Pe+8]=_,this.int16[Pe+9]=y,this.int16[Pe+10]=v,this.int16[Pe+11]=b,this.int16[Pe+12]=T,this.uint16[Pe+13]=E,this.uint16[Pe+14]=C,this.uint16[Pe+15]=P,this.uint16[Pe+16]=R,this.uint16[Pe+17]=z,this.uint16[Pe+18]=V,this.uint16[Pe+19]=N,this.uint16[Pe+20]=U,this.uint16[Pe+21]=q,this.uint16[Pe+22]=W,this.uint16[Pe+23]=se,this.uint16[Pe+24]=X,this.uint16[Pe+25]=ie,this.uint16[Pe+26]=re,this.uint16[Pe+27]=oe,this.uint32[Ie+14]=me,this.float32[Ie+15]=xe,this.float32[Ie+16]=we,this.float32[Ie+17]=Ce,this.float32[Ie+18]=Se,this.uint8[Ne+76]=qe,this.uint16[Pe+39]=Me,e}}Qf.prototype.bytesPerElement=80,nt(Qf,"StructArrayLayout2f9i15ui1ul4f1ub1ui80");class Yh extends zi{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(e,i,o,a,c,h){const f=this.length;return this.resize(f+1),this.emplace(f,e,i,o,a,c,h)}emplace(e,i,o,a,c,h,f){const _=6*e;return this.float32[_+0]=i,this.float32[_+1]=o,this.float32[_+2]=a,this.float32[_+3]=c,this.float32[_+4]=h,this.float32[_+5]=f,e}}Yh.prototype.bytesPerElement=24,nt(Yh,"StructArrayLayout6f24");class qa extends zi{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(e,i,o,a,c){const h=this.length;return this.resize(h+1),this.emplace(h,e,i,o,a,c)}emplace(e,i,o,a,c,h){const f=5*e;return this.float32[f+0]=i,this.float32[f+1]=o,this.float32[f+2]=a,this.float32[f+3]=c,this.float32[f+4]=h,e}}qa.prototype.bytesPerElement=20,nt(qa,"StructArrayLayout5f20");class Kh extends zi{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(e,i,o,a,c,h,f){const _=this.length;return this.resize(_+1),this.emplace(_,e,i,o,a,c,h,f)}emplace(e,i,o,a,c,h,f,_){const y=7*e;return this.float32[y+0]=i,this.float32[y+1]=o,this.float32[y+2]=a,this.float32[y+3]=c,this.float32[y+4]=h,this.float32[y+5]=f,this.float32[y+6]=_,e}}Kh.prototype.bytesPerElement=28,nt(Kh,"StructArrayLayout7f28");class Jh extends zi{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(e,i,o,a,c,h,f,_,y,v,b){const T=this.length;return this.resize(T+1),this.emplace(T,e,i,o,a,c,h,f,_,y,v,b)}emplace(e,i,o,a,c,h,f,_,y,v,b,T){const E=11*e;return this.float32[E+0]=i,this.float32[E+1]=o,this.float32[E+2]=a,this.float32[E+3]=c,this.float32[E+4]=h,this.float32[E+5]=f,this.float32[E+6]=_,this.float32[E+7]=y,this.float32[E+8]=v,this.float32[E+9]=b,this.float32[E+10]=T,e}}Jh.prototype.bytesPerElement=44,nt(Jh,"StructArrayLayout11f44");class ep extends zi{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(e,i,o,a,c,h,f,_,y){const v=this.length;return this.resize(v+1),this.emplace(v,e,i,o,a,c,h,f,_,y)}emplace(e,i,o,a,c,h,f,_,y,v){const b=9*e;return this.float32[b+0]=i,this.float32[b+1]=o,this.float32[b+2]=a,this.float32[b+3]=c,this.float32[b+4]=h,this.float32[b+5]=f,this.float32[b+6]=_,this.float32[b+7]=y,this.float32[b+8]=v,e}}ep.prototype.bytesPerElement=36,nt(ep,"StructArrayLayout9f36");class xo extends zi{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(e,i){const o=this.length;return this.resize(o+1),this.emplace(o,e,i)}emplace(e,i,o){const a=2*e;return this.float32[a+0]=i,this.float32[a+1]=o,e}}xo.prototype.bytesPerElement=8,nt(xo,"StructArrayLayout2f8");class tp extends zi{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint32=new Uint32Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(e,i,o,a){const c=this.length;return this.resize(c+1),this.emplace(c,e,i,o,a)}emplace(e,i,o,a,c){const h=6*e;return this.uint32[3*e+0]=i,this.uint16[h+2]=o,this.uint16[h+3]=a,this.uint16[h+4]=c,e}}tp.prototype.bytesPerElement=12,nt(tp,"StructArrayLayout1ul3ui12");class Qh extends zi{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(e){const i=this.length;return this.resize(i+1),this.emplace(i,e)}emplace(e,i){return this.uint16[1*e+0]=i,e}}Qh.prototype.bytesPerElement=2,nt(Qh,"StructArrayLayout1ui2");class Ha extends zi{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(e,i,o,a,c,h,f,_,y,v,b,T,E,C,P,R){const z=this.length;return this.resize(z+1),this.emplace(z,e,i,o,a,c,h,f,_,y,v,b,T,E,C,P,R)}emplace(e,i,o,a,c,h,f,_,y,v,b,T,E,C,P,R,z){const V=16*e;return this.float32[V+0]=i,this.float32[V+1]=o,this.float32[V+2]=a,this.float32[V+3]=c,this.float32[V+4]=h,this.float32[V+5]=f,this.float32[V+6]=_,this.float32[V+7]=y,this.float32[V+8]=v,this.float32[V+9]=b,this.float32[V+10]=T,this.float32[V+11]=E,this.float32[V+12]=C,this.float32[V+13]=P,this.float32[V+14]=R,this.float32[V+15]=z,e}}Ha.prototype.bytesPerElement=64,nt(Ha,"StructArrayLayout16f64");class ed extends zi{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(e,i,o,a,c,h,f){const _=this.length;return this.resize(_+1),this.emplace(_,e,i,o,a,c,h,f)}emplace(e,i,o,a,c,h,f,_){const y=10*e,v=5*e;return this.uint16[y+0]=i,this.uint16[y+1]=o,this.uint16[y+2]=a,this.uint16[y+3]=c,this.float32[v+2]=h,this.float32[v+3]=f,this.float32[v+4]=_,e}}ed.prototype.bytesPerElement=20,nt(ed,"StructArrayLayout4ui3f20");class Ll extends zi{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(e){const i=this.length;return this.resize(i+1),this.emplace(i,e)}emplace(e,i){return this.int16[1*e+0]=i,e}}Ll.prototype.bytesPerElement=2,nt(Ll,"StructArrayLayout1i2");class Eu extends zi{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer)}emplaceBack(e){const i=this.length;return this.resize(i+1),this.emplace(i,e)}emplace(e,i){return this.uint8[1*e+0]=i,e}}Eu.prototype.bytesPerElement=1,nt(Eu,"StructArrayLayout1ub1");class Iu extends Ac{get projectedAnchorX(){return this._structArray.int16[this._pos2+0]}get projectedAnchorY(){return this._structArray.int16[this._pos2+1]}get projectedAnchorZ(){return this._structArray.int16[this._pos2+2]}get tileAnchorX(){return this._structArray.int16[this._pos2+3]}get tileAnchorY(){return this._structArray.int16[this._pos2+4]}get x1(){return this._structArray.float32[this._pos4+3]}get y1(){return this._structArray.float32[this._pos4+4]}get x2(){return this._structArray.float32[this._pos4+5]}get y2(){return this._structArray.float32[this._pos4+6]}get padding(){return this._structArray.int16[this._pos2+14]}get featureIndex(){return this._structArray.uint32[this._pos4+8]}get sourceLayerIndex(){return this._structArray.uint16[this._pos2+18]}get bucketIndex(){return this._structArray.uint16[this._pos2+19]}}Iu.prototype.size=40;class ip extends Yf{get(e){return new Iu(this,e)}}nt(ip,"CollisionBoxArray");class p_ extends Ac{get projectedAnchorX(){return this._structArray.int16[this._pos2+0]}get projectedAnchorY(){return this._structArray.int16[this._pos2+1]}get projectedAnchorZ(){return this._structArray.int16[this._pos2+2]}get tileAnchorX(){return this._structArray.float32[this._pos4+2]}get tileAnchorY(){return this._structArray.float32[this._pos4+3]}get glyphStartIndex(){return this._structArray.uint16[this._pos2+8]}get numGlyphs(){return this._structArray.uint16[this._pos2+9]}get vertexStartIndex(){return this._structArray.uint32[this._pos4+5]}get lineStartIndex(){return this._structArray.uint32[this._pos4+6]}get lineLength(){return this._structArray.uint32[this._pos4+7]}get segment(){return this._structArray.uint16[this._pos2+16]}get lowerSize(){return this._structArray.uint16[this._pos2+17]}get upperSize(){return this._structArray.uint16[this._pos2+18]}get lineOffsetX(){return this._structArray.float32[this._pos4+10]}get lineOffsetY(){return this._structArray.float32[this._pos4+11]}get writingMode(){return this._structArray.uint8[this._pos1+48]}get placedOrientation(){return this._structArray.uint8[this._pos1+49]}set placedOrientation(e){this._structArray.uint8[this._pos1+49]=e}get hidden(){return this._structArray.uint8[this._pos1+50]}set hidden(e){this._structArray.uint8[this._pos1+50]=e}get crossTileID(){return this._structArray.uint32[this._pos4+13]}set crossTileID(e){this._structArray.uint32[this._pos4+13]=e}get associatedIconIndex(){return this._structArray.int16[this._pos2+28]}get flipState(){return this._structArray.uint8[this._pos1+58]}set flipState(e){this._structArray.uint8[this._pos1+58]=e}}p_.prototype.size=60;class m_ extends Xh{get(e){return new p_(this,e)}}nt(m_,"PlacedSymbolArray");class td extends Ac{get tileAnchorX(){return this._structArray.float32[this._pos4+0]}get tileAnchorY(){return this._structArray.float32[this._pos4+1]}get projectedAnchorX(){return this._structArray.int16[this._pos2+4]}get projectedAnchorY(){return this._structArray.int16[this._pos2+5]}get projectedAnchorZ(){return this._structArray.int16[this._pos2+6]}get rightJustifiedTextSymbolIndex(){return this._structArray.int16[this._pos2+7]}get centerJustifiedTextSymbolIndex(){return this._structArray.int16[this._pos2+8]}get leftJustifiedTextSymbolIndex(){return this._structArray.int16[this._pos2+9]}
vendor: 19,947 bytes, line 7
7get verticalPlacedTextSymbolIndex(){return this._structArray.int16[this._pos2+10]}get placedIconSymbolIndex(){return this._structArray.int16[this._pos2+11]}get verticalPlacedIconSymbolIndex(){return this._structArray.int16[this._pos2+12]}get key(){return this._structArray.uint16[this._pos2+13]}get textBoxStartIndex(){return this._structArray.uint16[this._pos2+14]}get textBoxEndIndex(){return this._structArray.uint16[this._pos2+15]}get verticalTextBoxStartIndex(){return this._structArray.uint16[this._pos2+16]}get verticalTextBoxEndIndex(){return this._structArray.uint16[this._pos2+17]}get iconBoxStartIndex(){return this._structArray.uint16[this._pos2+18]}get iconBoxEndIndex(){return this._structArray.uint16[this._pos2+19]}get verticalIconBoxStartIndex(){return this._structArray.uint16[this._pos2+20]}get verticalIconBoxEndIndex(){return this._structArray.uint16[this._pos2+21]}get featureIndex(){return this._structArray.uint16[this._pos2+22]}get numHorizontalGlyphVertices(){return this._structArray.uint16[this._pos2+23]}get numVerticalGlyphVertices(){return this._structArray.uint16[this._pos2+24]}get numIconVertices(){return this._structArray.uint16[this._pos2+25]}get numVerticalIconVertices(){return this._structArray.uint16[this._pos2+26]}get useRuntimeCollisionCircles(){return this._structArray.uint16[this._pos2+27]}get crossTileID(){return this._structArray.uint32[this._pos4+14]}set crossTileID(e){this._structArray.uint32[this._pos4+14]=e}get textOffset0(){return this._structArray.float32[this._pos4+15]}get textOffset1(){return this._structArray.float32[this._pos4+16]}get collisionCircleDiameter(){return this._structArray.float32[this._pos4+17]}get zOffset(){return this._structArray.float32[this._pos4+18]}set zOffset(e){this._structArray.float32[this._pos4+18]=e}get hasIconTextFit(){return this._structArray.uint8[this._pos1+76]}get elevationFeatureIndex(){return this._structArray.uint16[this._pos2+39]}}td.prototype.size=80;class id extends Qf{get(e){return new td(this,e)}}nt(id,"SymbolInstanceArray");class rd extends Js{getoffsetX(e){return this.float32[1*e+0]}}nt(rd,"GlyphOffsetArray");class rp extends _a{getx(e){return this.int16[2*e+0]}gety(e){return this.int16[2*e+1]}}nt(rp,"SymbolLineVertexArray");class __ extends Ac{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]}get layoutVertexArrayOffset(){return this._structArray.uint16[this._pos2+4]}}__.prototype.size=12;class Au extends tp{get(e){return new __(this,e)}}nt(Au,"FeatureIndexArray");class Cu extends us{geta_centroid_pos0(e){return this.uint16[2*e+0]}geta_centroid_pos1(e){return this.uint16[2*e+1]}}nt(Cu,"FillExtrusionCentroidArray");class nd extends Ac{get a_join_normal_inside0(){return this._structArray.int16[this._pos2+0]}get a_join_normal_inside1(){return this._structArray.int16[this._pos2+1]}get a_join_normal_inside2(){return this._structArray.int16[this._pos2+2]}}nd.prototype.size=6;class np extends Ms{get(e){return new nd(this,e)}}nt(np,"FillExtrusionWallArray");const g_=Gt([{name:"a_pos",components:2,type:"Int16"}],4),y_=Gt([{name:"a_road_z_offset",components:1,type:"Float32"}],4),op=Gt([{name:"a_pos",components:2,type:"Int16"},{name:"a_height",components:1,type:"Float32"}],4),x_=Gt([{name:"a_pos_normal_3",components:3,type:"Int16"}],4);class Fi{constructor(e=[]){this.segments=e}_prepareSegment(e,i,o,a,c){let h=this.segments.at(-1);return e>Fi.MAX_VERTEX_ARRAY_LENGTH&&ht(`Max vertices per segment is ${Fi.MAX_VERTEX_ARRAY_LENGTH}: bucket requested ${e}`),(!h||h.vertexLength+e>Fi.MAX_VERTEX_ARRAY_LENGTH||h.sortKey!==a||c!==void 0&&h&&h.batchIndex!==void 0&&h.batchIndex!==c)&&(h={vertexOffset:i,primitiveOffset:o,vertexLength:0,primitiveLength:0},a!==void 0&&(h.sortKey=a),c!==void 0&&(h.batchIndex=c),this.segments.push(h)),h}prepareSegment(e,i,o,a,c){return this._prepareSegment(e,i.length,o.length,a,c)}get(){return this.segments}destroy(){for(const e of this.segments)for(const i in e.vaos)e.vaos[i].destroy()}static simpleSegment(e,i,o,a){return new Fi([{vertexOffset:e,primitiveOffset:i,vertexLength:o,primitiveLength:a,vaos:{},sortKey:0}])}}function Mc(r,e){return 256*(r=Y(Math.floor(r),0,255))+Y(Math.floor(e),0,255)}Fi.MAX_VERTEX_ARRAY_LENGTH=Math.pow(2,16)-1,nt(Fi,"SegmentVector");const uy=Gt([{name:"a_pattern",components:4,type:"Uint16"},{name:"a_pixel_ratio",components:1,type:"Float32"}]),hy=Gt([{name:"a_pattern_b",components:4,type:"Uint16"}]),dy=Gt([{name:"a_dash",components:4,type:"Uint16"}]);class Mu{constructor(){this.ids=[],this.uniqueIds=[],this.positions=[],this.indexed=!1}add(e,i,o,a){this.ids.push(v_(e)),this.positions.push(i,o,a)}eachPosition(e,i){const o=v_(e);let a=0,c=this.ids.length-1;for(;a<c;){const h=a+c>>1;this.ids[h]>=o?c=h:a=h+1}for(;this.ids[a]===o;)i(this.positions[3*a],this.positions[3*a+1],this.positions[3*a+2]),a++}static serialize(e,i){const o=new Float64Array(e.ids),a=new Uint32Array(e.positions);return sp(o,a,0,o.length-1),i&&(i.add(o.buffer),i.add(a.buffer)),{ids:o,positions:a}}static deserialize(e){const i=new Mu;let o;i.ids=e.ids,i.positions=e.positions;for(const a of i.ids)a!==o&&i.uniqueIds.push(a),o=a;return i.indexed=!0,i}}function v_(r){const e=+r;return Number.isSafeInteger(e)?e:Ku(String(r))}function sp(r,e,i,o){for(;i<o;){const a=r[i+o>>1];let c=i-1,h=o+1;for(;;){do c++;while(r[c]<a);do h--;while(r[h]>a);if(c>=h)break;od(r,c,h),od(e,3*c,3*h),od(e,3*c+1,3*h+1),od(e,3*c+2,3*h+2)}h-i<o-h?(sp(r,e,i,h),i=h+1):(sp(r,e,h+1,o),o=h)}}function od(r,e,i){const o=r[e];r[e]=r[i],r[i]=o}nt(Mu,"FeaturePositionMap");class Qs{constructor(e){this.gl=e.gl,this.initialized=!1}fetchUniformLocation(e,i){return this.location||this.initialized||(this.location=this.gl.getUniformLocation(e,i),this.initialized=!0),!!this.location}set(e,i,o){throw new Error("Uniform#set() must be implemented by each concrete Uniform")}}class Pu extends Qs{constructor(e){super(e),this.current=0}set(e,i,o){this.fetchUniformLocation(e,i)&&this.current!==o&&(this.current=o,this.gl.uniform1i(this.location,o))}}class gr extends Qs{constructor(e){super(e),this.current=0}set(e,i,o){this.fetchUniformLocation(e,i)&&this.current!==o&&(this.current=o,this.gl.uniform1f(this.location,o))}}class ao extends Qs{constructor(e){super(e),this.current=[0,0]}set(e,i,o){this.fetchUniformLocation(e,i)&&(o[0]===this.current[0]&&o[1]===this.current[1]||(this.current=o,this.gl.uniform2f(this.location,o[0],o[1])))}}class Ru extends Qs{constructor(e){super(e),this.current=[0,0,0]}set(e,i,o){this.fetchUniformLocation(e,i)&&(o[0]===this.current[0]&&o[1]===this.current[1]&&o[2]===this.current[2]||(this.current=o,this.gl.uniform3f(this.location,o[0],o[1],o[2])))}}class fy extends Qs{constructor(e){super(e),this.current=[0,0,0,0]}set(e,i,o){this.fetchUniformLocation(e,i)&&(o[0]===this.current[0]&&o[1]===this.current[1]&&o[2]===this.current[2]&&o[3]===this.current[3]||(this.current=o,this.gl.uniform4ui(this.location,o[0],o[1],o[2],o[3])))}}class ea extends Qs{constructor(e){super(e),this.current=[0,0,0,0]}set(e,i,o){this.fetchUniformLocation(e,i)&&(o[0]===this.current[0]&&o[1]===this.current[1]&&o[2]===this.current[2]&&o[3]===this.current[3]||(this.current=o,this.gl.uniform4f(this.location,o[0],o[1],o[2],o[3])))}}class ap extends Qs{constructor(e){super(e),this.current=ai.transparent.toPremultipliedRenderColor(null)}set(e,i,o){this.fetchUniformLocation(e,i)&&(o.r===this.current.r&&o.g===this.current.g&&o.b===this.current.b&&o.a===this.current.a||(this.current=o,this.gl.uniform4f(this.location,o.r,o.g,o.b,o.a)))}}class ta extends Qs{constructor(e){super(e),this.current=new Float32Array(16)}set(e,i,o){if(!this.fetchUniformLocation(e,i))return;const a=this.current;if(o[12]!==a[12]||o[0]!==a[0])return a.set(o),void this.gl.uniformMatrix4fv(this.location,!1,a);for(let c=1;c<16;c++)if(o[c]!==a[c]){a.set(o),this.gl.uniformMatrix4fv(this.location,!1,a);break}}}class lp extends Qs{constructor(e){super(e),this.current=new Float32Array(4)}set(e,i,o){if(!this.fetchUniformLocation(e,i))return;const a=this.current;for(let c=0;c<4;c++)if(o[c]!==a[c]){a.set(o),this.gl.uniformMatrix2fv(this.location,!1,a);break}}}function cp(r){return[Mc(255*r.r,255*r.g),Mc(255*r.b,255*r.a)]}function sd(r,e,i,o,a,c,h,f){return!!r&&(r.kind==="composite"||r.kind==="source"?r.evaluate(new xt(0,{brightness:c,worldview:f}),e,i,a,o,h)==="none":r.value==="none")}class ad{constructor(e,i,o,a){this.value=e,this.uniformNames=i.map(c=>`u_${c}`),this.type=o,this.context=a}setUniform(e,i,o,a,c){const h=a.constantOr(this.value);i.set(e,c,h instanceof ai?h.toPremultipliedRenderColor(this.lutExpression&&this.lutExpression.kind==="constant"&&this.lutExpression.value==="none"?null:this.context.lut):h)}getBinding(e,i){return this.type==="color"?new ap(e):new gr(e)}}class Du{constructor(e,i){this.uniformNames=i.map(o=>`u_${o}`),this.pattern=null,this.patternTransition=null,this.pixelRatio=1}setConstantPatternPositions(e,i){this.pixelRatio=e.pixelRatio||1,this.pattern=e.tl.concat(e.br),this.patternTransition=i?i.tl.concat(i.br):this.pattern}setUniform(e,i,o,a,c){let h=null;c!=="u_pattern"&&c!=="u_dash"||(h=this.pattern),c==="u_pattern_b"&&(h=this.patternTransition),c==="u_pixel_ratio"&&(h=this.pixelRatio),h&&i.set(e,c,h)}getBinding(e,i){return i==="u_pattern"||i==="u_pattern_b"||i==="u_dash"?new fy(e):new gr(e)}}class ya{constructor(e,i,o,a){this.expression=e,this.type=o,this.maxValue=0,this.paintVertexAttributes=i.map(c=>({name:`a_${c}`,type:"Float32",components:o==="color"?2:1,offset:0})),this.paintVertexArray=new a}populatePaintArray(e,i,o,a,c,h,f,_){const y=this.paintVertexArray.length,v=this.expression.kind==="composite"||this.expression.kind==="source"?this.expression.evaluate(new xt(0,{brightness:h,worldview:_}),i,{},c,a,f):this.expression.kind==="constant"&&this.expression.value,b=sd(this.lutExpression,i,{},a,c,h,f,_);this.paintVertexArray.resize(e),this._setPaintValue(y,e,v,b?null:this.context.lut)}updatePaintArray(e,i,o,a,c,h,f,_){const y=this.expression.kind==="composite"||this.expression.kind==="source"?this.expression.evaluate({zoom:0,brightness:f,worldview:_},o,a,void 0,c):this.expression.kind==="constant"&&this.expression.value,v=sd(this.lutExpression,o,a,c,void 0,f,void 0,_);this._setPaintValue(e,i,y,v?null:this.context.lut)}_setPaintValue(e,i,o,a){if(this.type==="color"){const c=cp(o.toPremultipliedRenderColor(a));for(let h=e;h<i;h++)this.paintVertexArray.emplace(h,c[0],c[1])}else{for(let c=e;c<i;c++)this.paintVertexArray.emplace(c,o);this.maxValue=Math.max(this.maxValue,Math.abs(o))}}upload(e){this.paintVertexArray&&this.paintVertexArray.arrayBuffer&&(this.paintVertexBuffer&&this.paintVertexBuffer.buffer?this.paintVertexBuffer.updateData(this.paintVertexArray):this.paintVertexBuffer=e.createVertexBuffer(this.paintVertexArray,this.paintVertexAttributes,this.lutExpression&&this.lutExpression.kind!=="constant"&&(this.lutExpression.isStateDependent||!this.lutExpression.isLightConstant)||this.expression.kind!=="constant"&&(this.expression.isStateDependent||!this.expression.isLightConstant)))}destroy(){this.paintVertexBuffer&&this.paintVertexBuffer.destroy()}}class ia{constructor(e,i,o,a,c,h){this.expression=e,this.uniformNames=i.map(f=>`u_${f}_t`),this.type=o,this.useIntegerZoom=a,this.context=c,this.maxValue=0,this.paintVertexAttributes=i.map(f=>({name:`a_${f}`,type:"Float32",components:o==="color"?4:2,offset:0})),this.paintVertexArray=new h}populatePaintArray(e,i,o,a,c,h,f,_){const y=this.expression.evaluate(new xt(this.context.zoom,{brightness:h,worldview:_}),i,{},c,a,f),v=this.expression.evaluate(new xt(this.context.zoom+1,{brightness:h,worldview:_}),i,{},c,a,f),b=sd(this.lutExpression,i,{},a,c,h,f,_),T=this.paintVertexArray.length;this.paintVertexArray.resize(e),this._setPaintValue(T,e,y,v,b?null:this.context.lut)}updatePaintArray(e,i,o,a,c,h,f,_){const y=this.expression.evaluate({zoom:this.context.zoom,brightness:f,worldview:_},o,a,void 0,c),v=this.expression.evaluate({zoom:this.context.zoom+1,brightness:f,worldview:_},o,a,void 0,c),b=sd(this.lutExpression,o,a,c,void 0,f,void 0,_);this._setPaintValue(e,i,y,v,b?null:this.context.lut)}_setPaintValue(e,i,o,a,c){if(this.type==="color"){const h=cp(o.toPremultipliedRenderColor(c)),f=cp(a.toPremultipliedRenderColor(c));for(let _=e;_<i;_++)this.paintVertexArray.emplace(_,h[0],h[1],f[0],f[1])}else{for(let h=e;h<i;h++)this.paintVertexArray.emplace(h,o,a);this.maxValue=Math.max(this.maxValue,Math.abs(o),Math.abs(a))}}upload(e){this.paintVertexArray&&this.paintVertexArray.arrayBuffer&&(this.paintVertexBuffer&&this.paintVertexBuffer.buffer?this.paintVertexBuffer.updateData(this.paintVertexArray):this.paintVertexBuffer=e.createVertexBuffer(this.paintVertexArray,this.paintVertexAttributes,this.expression.isStateDependent||!this.expression.isLightConstant))}destroy(){this.paintVertexBuffer&&this.paintVertexBuffer.destroy()}setUniform(e,i,o,a,c){const h=this.useIntegerZoom?Math.floor(o.zoom):o.zoom,f=Y(this.expression.interpolationFactor(h,this.context.zoom,this.context.zoom+1),0,1);i.set(e,c,f)}getBinding(e,i){return new gr(e)}}class vo{constructor(e,i,o,a,c){this.expression=e,this.layerId=c,this.paintVertexAttributes=(o==="array"?dy:uy).members;for(let h=0;h<i.length;++h);this.paintVertexArray=new a,this.paintTransitionVertexArray=new Cc}populatePaintArray(e,i,o,a){const c=this.paintVertexArray.length;this.paintVertexArray.resize(e),this._setPaintValues(c,e,i.patterns&&i.patterns[this.layerId],o)}updatePaintArray(e,i,o,a,c,h,f){this._setPaintValues(e,i,o.patterns&&o.patterns[this.layerId],h)}_setPaintValues(e,i,o,a){if(!a||!o)return;const c=a[o[0]],h=a[o[1]];if(c){if(c){const{tl:f,br:_,pixelRatio:y}=c;for(let v=e;v<i;v++)this.paintVertexArray.emplace(v,f[0],f[1],_[0],_[1],y)}if(h){this.paintTransitionVertexArray.resize(this.paintVertexArray.length);const{tl:f,br:_}=h;for(let y=e;y<i;y++)this.paintTransitionVertexArray.emplace(y,f[0],f[1],_[0],_[1])}}}upload(e){const i=this.expression.isStateDependent||!this.expression.isLightConstant;this.paintVertexArray&&this.paintVertexArray.arrayBuffer&&(this.paintVertexBuffer=e.createVertexBuffer(this.paintVertexArray,this.paintVertexAttributes,i)),this.paintTransitionVertexArray&&this.paintTransitionVertexArray.length&&(this.paintTransitionVertexBuffer=e.createVertexBuffer(this.paintTransitionVertexArray,hy.members,i))}destroy(){this.paintVertexBuffer&&this.paintVertexBuffer.destroy(),this.paintTransitionVertexBuffer&&this.paintTransitionVertexBuffer.destroy()}}class ra{constructor(e,i,o=()=>!0){this.binders={},this._buffers=[],this.context=i;const a=[],c=e;for(const h in e.paint._values){const f=c.paint.get(h);if(h.endsWith("-use-theme")||!o(h)||!(f instanceof ns&&xh(f.property.specification)))continue;const _=b_(h,e.type),y=f.value,v=f.property.specification.type,b=!!f.property.useIntegerZoom,T=h==="line-dasharray"||h.endsWith("pattern"),E=c.paint.get(`${h}-use-theme`),C=h==="line-dasharray"&&c.layout.get("line-cap").value.kind!=="constant"||E&&E.value.kind!=="constant";if(y.kind!=="constant"||C)if(y.kind==="source"||C||T){const P=up(h,v,"source");this.binders[h]=T?new vo(y,_,v,P,e.id):new ya(y,_,v,P),a.push(`/a_${h}`)}else{const P=up(h,v,"composite");this.binders[h]=new ia(y,_,v,b,i,P),a.push(`/z_${h}`)}else this.binders[h]=T?new Du(y.value,_):new ad(y.value,_,v,i),a.push(`/u_${h}`);E&&(this.binders[h].lutExpression=E.value)}this.cacheKey=a.sort().join("")}updateExpressions(e){const i=e;for(const o in this.binders){const a=this.binders[o];if(a instanceof ya||a instanceof ia||a instanceof vo){const c=i.paint.get(o);a.expression=c.value}}}getMaxValue(e){const i=this.binders[e];return i instanceof ya||i instanceof ia?i.maxValue:0}populatePaintArrays(e,i,o,a,c,h,f,_){for(const y in this.binders){const v=this.binders[y];v.context=this.context,(v instanceof ya||v instanceof ia||v instanceof vo)&&v.populatePaintArray(e,i,o,a,c,h,f,_)}}setConstantPatternPositions(e,i){for(const o in this.binders){const a=this.binders[o];a instanceof Du&&a.setConstantPatternPositions(e,i)}}getPatternTransitionVertexBuffer(e){const i=this.binders[e];return i instanceof vo?i.paintTransitionVertexBuffer:null}updatePaintArrays(e,i,o,a,c,h,f,_,y,v){let b=!1;const T=Object.keys(e),E=T.length!==0&&!_,C=E?T:i.uniqueIds;this.context.lut=c.lut;for(const P in this.binders){const R=this.binders[P];if(R.context=this.context,(R instanceof ya||R instanceof ia||R instanceof vo)&&R.expression&&R.expression.kind&&R.expression.kind!=="constant"&&(R.expression.isStateDependent===!0||R.expression.isLightConstant===!1)){const z=c.paint.get(P);R.expression=z.value;for(const V of C){const N=e[V.toString()];i.eachPosition(V,(U,q,W)=>{const se=a.feature(U);R.updatePaintArray(q,W,se,N,h,f,y,v)})}if(!E)for(const V of o.uniqueIds){const N=e[V.toString()];o.eachPosition(V,(U,q,W)=>{const se=a.feature(U);R.updatePaintArray(q,W,se,N,h,f,y,v)})}b=!0}}return b}defines(){const e=[];for(const i in this.binders){const o=this.binders[i];(o instanceof ad||o instanceof Du)&&e.push(...o.uniformNames.map(a=>`#define HAS_UNIFORM_${a}`))}return e}getPaintVertexBuffers(){return this._buffers}getUniforms(e){const i=[];for(const o in this.binders){const a=this.binders[o];if(a instanceof ad||a instanceof Du||a instanceof ia)for(const c of a.uniformNames)i.push({name:c,property:o,binding:a.getBinding(e,c)})}return i}setUniforms(e,i,o,a,c){for(const{name:h,property:f,binding:_}of o)this.binders[f].setUniform(e,_,c,a.get(f),h)}updatePaintBuffers(){this._buffers=[];for(const e in this.binders){const i=this.binders[e];(i instanceof ya||i instanceof ia||i instanceof vo)&&i.paintVertexBuffer&&this._buffers.push(i.paintVertexBuffer),i instanceof vo&&i.paintTransitionVertexBuffer&&this._buffers.push(i.paintTransitionVertexBuffer)}}upload(e){for(const i in this.binders){const o=this.binders[i];(o instanceof ya||o instanceof ia||o instanceof vo)&&o.upload(e)}this.updatePaintBuffers()}destroy(){for(const e in this.binders){const i=this.binders[e];(i instanceof ya||i instanceof ia||i instanceof vo)&&i.destroy()}}}class hs{constructor(e,i,o=()=>!0){this.programConfigurations={};for(const a of e)this.programConfigurations[a.id]=new ra(a,i,o);this.needsUpload=!1,this._featureMap=new Mu,this._featureMapWithoutIds=new Mu,this._bufferOffset=0,this._idlessCounter=0}populatePaintArrays(e,i,o,a,c,h,f,_,y){for(const v in this.programConfigurations)this.programConfigurations[v].populatePaintArrays(e,i,a,c,h,f,_,y);i.id!==void 0?this._featureMap.add(i.id,o,this._bufferOffset,e):(this._featureMapWithoutIds.add(this._idlessCounter,o,this._bufferOffset,e),this._idlessCounter+=1),this._bufferOffset=e,this.needsUpload=!0}updatePaintArrays(e,i,o,a,c,h,f,_){for(const y of o)this.needsUpload=this.programConfigurations[y.id].updatePaintArrays(e,this._featureMap,this._featureMapWithoutIds,i,y,a,c,h,f||0,_)||this.needsUpload}get(e){return this.programConfigurations[e]}upload(e){if(this.needsUpload){for(const i in this.programConfigurations)this.programConfigurations[i].upload(e);this.needsUpload=!1}}destroy(){for(const e in this.programConfigurations)this.programConfigurations[e].destroy()}updateExpressions(e){const i=new Set;for(const o of e){const a=this.programConfigurations[o.id];a&&(a.updateExpressions(o),i.add(o.id))}for(const o in this.programConfigurations)i.has(o)||delete this.programConfigurations[o]}}const py={"text-opacity":["opacity"],"icon-opacity":["opacity"],"text-occlusion-opacity":["occlusion_opacity"],"icon-occlusion-opacity":["occlusion_opacity"],"text-color":["fill_color"],"icon-color":["fill_color"],"text-emissive-strength":["emissive_strength"],"icon-emissive-strength":["emissive_strength"],"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"],"symbol-z-offset":["z_offset"],"line-gap-width":["ga
7pwidth"],"line-pattern":["pattern","pixel_ratio","pattern_b"],"fill-pattern":["pattern","pixel_ratio","pattern_b"],"fill-extrusion-pattern":["pattern","pixel_ratio","pattern_b"],"line-dasharray":["dash"],"fill-bridge-guard-rail-color":["structure_color"],"fill-tunnel-structure-color":["structure_color"]};function b_(r,e){return py[r]||[r.replace(`${e}-`,"").replace(/-/g,"_")]}const my={"line-pattern":{source:$a,composite:$a},"fill-pattern":{source:$a,composite:$a},"fill-extrusion-pattern":{source:$a,composite:$a},"line-dasharray":{source:Cc,composite:Cc}},_y={color:{source:xo,composite:ga},number:{source:Js,composite:xo}};function up(r,e,i){const o=my[r];return o&&o[i]||_y[e][i]}nt(ad,"ConstantBinder"),nt(Du,"PatternConstantBinder"),nt(ya,"SourceExpressionBinder",{omit:["expression"]}),nt(vo,"PatternCompositeBinder",{omit:["expression"]}),nt(ia,"CompositeExpressionBinder",{omit:["expression"]}),nt(ra,"ProgramConfiguration",{omit:["_buffers"]}),nt(hs,"ProgramConfigurationSet");class Pc{constructor(e,i,o){this.layoutVertexArray=new _a,this.indexArray=new sn,this.lineIndexArray=new us,this.triangleSegments=new Fi,this.lineSegments=new Fi,this.programConfigurations=new hs(e,{zoom:i,lut:o}),this.uploaded=!1}update(e,i,o,a,c,h,f,_){this.programConfigurations.updatePaintArrays(e,i,c,o,a,h,f,_)}isEmpty(){return this.layoutVertexArray.length===0}needsUpload(){return this.programConfigurations.needsUpload}upload(e){this.uploaded||(this.layoutVertexBuffer=e.createVertexBuffer(this.layoutVertexArray,g_.members),this.indexBuffer=e.createIndexBuffer(this.indexArray),this.lineIndexBuffer=e.createIndexBuffer(this.lineIndexArray)),this.programConfigurations.upload(e),this.uploaded=!0}destroy(){this.layoutVertexBuffer&&(this.layoutVertexBuffer.destroy(),this.indexBuffer.destroy(),this.lineIndexBuffer.destroy(),this.programConfigurations.destroy(),this.triangleSegments.destroy(),this.lineSegments.destroy())}populatePaintArrays(e,i,o,a,c,h,f){this.programConfigurations.populatePaintArrays(this.layoutVertexArray.length,e,i,o,a,c,h,void 0,f)}}nt(Pc,"FillBufferData");class hp{constructor(e){this.zoom=e.zoom,this.pixelRatio=e.pixelRatio,this.overscaling=e.overscaling,this.layers=e.layers,this.layerIds=this.layers.map(i=>i.fqid),this.index=e.index,this.hasPattern=!1,this.patternFeatures=[],this.lut=e.lut,this.bufferData=new Pc(e.layers,e.zoom,e.lut),this.stateDependentLayerIds=this.layers.filter(i=>i.isStateDependent()).map(i=>i.id),this.projection=e.projection,this.sourceLayerIndex=e.sourceLayerIndex,this.sourceLayerName=e.sourceLayerName||"",this.worldview=e.worldview,this.hasAppearances=null}updateFootprints(e,i){}updateAppearances(e,i,o,a){return{hasLayoutChanges:!1,hasUboChanges:!1}}populate(e,i,o,a){this.hasPattern=kf("fill",this.layers,this.pixelRatio,i);const c=this.layers[0].layout.get("fill-sort-key"),h=[];for(const{feature:f,id:_,index:y,sourceLayerIndex:v}of e){const b=this.layers[0]._featureFilter.needGeometry,T=Vo(f,b);if(!this.layers[0]._featureFilter.filter(new xt(this.zoom,{worldview:this.worldview,activeFloors:i.activeFloors}),T,o))continue;const E=c?c.evaluate(T,{},o,i.availableImages):void 0,C={id:_,properties:f.properties,type:f.type,sourceLayerIndex:v,index:y,geometry:b?T.geometry:ls(f,o,a),patterns:{},sortKey:E};h.push(C)}c&&h.sort((f,_)=>f.sortKey-_.sortKey);for(const f of h){const{geometry:_,index:y,sourceLayerIndex:v}=f;if(this.hasPattern){const b=Bf("fill",this.layers,f,this.zoom,this.pixelRatio,i);this.patternFeatures.push(b)}else this.addFeature(f,_,y,o,{},i.availableImages,i.brightness,i.elevationFeatures);i.featureIndex.insert(e[y].feature,_,y,v,this.index)}!this.hasPattern&&this.hdExt&&this.hdExt.buildFrcSegments(this)}update(e,i,o,a,c,h,f){this.bufferData.update(e,i,o,a,c,h,f,this.worldview),this.hdExt&&this.hdExt.update(e,i,o,a,c,h,f,this.worldview)}updateExpressions(e){this.bufferData.programConfigurations.updateExpressions(e),this.hdExt&&this.hdExt.updateExpressions(e)}addFeatures(e,i,o,a,c,h){for(const f of this.patternFeatures)this.addFeature(f,f.geometry,f.index,i,o,a,h,e.elevationFeatures);this.hdExt&&this.hdExt.buildFrcSegments(this)}isEmpty(){return this.bufferData.isEmpty()&&(!this.hdExt||this.hdExt.isEmpty())}uploadPending(){return!this.uploaded||this.bufferData.needsUpload()||this.hdExt!=null&&this.hdExt.needsUpload()}upload(e){this.bufferData.upload(e),this.hdExt&&this.hdExt.upload(e)}destroy(){this.bufferData.destroy(),this.hdExt&&this.hdExt.destroy()}
vendor: 41,344 bytes, line 7
7addFeature(e,i,o,a,c,h=[],f,_){const y=this.hdExt?this.hdExt.trackFeatureFrc(e.properties):null,v=this.bufferData.indexArray.length,b=Ro(i,500);this.hdExt!=null&&this.hdExt.handleFeature(e,b,o,a,_,this)||this.addGeometry(b,this.bufferData),this.bufferData.populatePaintArrays(e,o,c,h,a,f,this.worldview),this.hdExt&&this.hdExt.populatePaintArrays(e,o,c,h,a,f,this.worldview),this.hdExt&&this.hdExt.recordFeatureRange(this,v,this.bufferData.indexArray.length,y)}addGeometry(e,i,o,a){let c=Number.POSITIVE_INFINITY,h=Number.NEGATIVE_INFINITY,f=null;o&&(f=o.elevationSampler.constantElevation(o.elevation,o.bias),f!=null&&(c=f,h=f));const _=o?i:null,y=(v,b,T)=>{if(o!=null)if(b.push(v),f!=null)_.elevatedLayoutVertexArray.emplaceBack(f),T.push(f);else{const E=o.elevationSampler.pointElevation(v,o.elevation,o.bias);_.elevatedLayoutVertexArray.emplaceBack(E),T.push(E),c=Math.min(c,E),h=Math.max(h,E)}};for(const v of e){let b=0;for(const q of v)b+=q.length;const T=i.triangleSegments.prepareSegment(b,i.layoutVertexArray,i.indexArray),E=T.vertexLength,C=[],P=[],R=[],z=[],V=[],N=i.layoutVertexArray.length;for(const q of v){if(q.length===0)continue;q!==v[0]&&P.push(C.length/2);const W=i.lineSegments.prepareSegment(q.length,i.layoutVertexArray,i.lineIndexArray),se=W.vertexLength;o&&V.push(i.layoutVertexArray.length-N),y(q[0],R,z),i.layoutVertexArray.emplaceBack(q[0].x,q[0].y),i.lineIndexArray.emplaceBack(se+q.length-1,se),C.push(q[0].x),C.push(q[0].y);for(let X=1;X<q.length;X++)y(q[X],R,z),i.layoutVertexArray.emplaceBack(q[X].x,q[X].y),i.lineIndexArray.emplaceBack(se+X-1,se+X),C.push(q[X].x),C.push(q[X].y);W.vertexLength+=q.length,W.primitiveLength+=q.length}const U=Sc(C,P);for(let q=0;q<U.length;q+=3)i.indexArray.emplaceBack(E+U[q],E+U[q+1],E+U[q+2]);if(U.length>0&&o&&a){const q=o.elevation.isTunnel(),W=o.elevation.safeArea,se=a.addVertices(R,z);a.addTriangles(U,se,q);const X=V.length;if(X>0){for(let ie=0;ie<X-1;ie++)a.addRenderableRing(o.index,V[ie]+se,V[ie+1]-V[ie],q,W,o.featureInfo);a.addRenderableRing(o.index,V[X-1]+se,R.length-V[X-1],q,W,o.featureInfo)}}T.vertexLength+=b,T.primitiveLength+=U.length/3}return[c,h]}}nt(hp,"FillBucket",{omit:["layers","patternFeatures"]});const gy=Gt([{name:"a_pos_normal",components:2,type:"Int16"},{name:"a_data",components:4,type:"Uint8"},{name:"a_linesofar",components:1,type:"Float32"}],4),yy=Gt([{name:"a_z_offset_width",components:4,type:"Float32"}],4),xy=Gt([{name:"a_elevation_id_col",components:3,type:"Float32"}],4),vy=Gt([{name:"a_elevation_ground_scale",components:1,type:"Float32"}],4),{members:ld}=gy,cd=Gt([{name:"a_packed",components:3,type:"Float32"}]),{members:Uo}=cd,ud=Gt([{name:"a_pattern_data",components:3,type:"Float32"}]),{members:by}=ud;class Za{constructor(e,i,o,a,c){for(this.properties=Object.create(null),this.extent=o,this.type=0,this.id=void 0,this._pbf=e,this._geometry=-1,this._keys=a,this._values=c;e.pos<i;){const h=e.readVarint();if(h===8)this.id=e.readVarint();else if(h===18){const f=e.readVarint()+e.pos;for(;e.pos<f;){const _=a[e.readVarint()],y=c[e.readVarint()];this.properties[_]=y}}else h===24?this.type=e.readVarint():(h===34&&(this._geometry=e.pos),e.skip(h))}}loadGeometry(){if(this._geometry<0)throw new Error("feature has no geometry");const e=this._pbf;e.pos=this._geometry;const i=e.readVarint()+e.pos,o=[];let a,c=1,h=0,f=0,_=0;for(;e.pos<i;){if(h<=0){const y=e.readVarint();if(c=7&y,h=y>>3,h===0)continue}if(h--,c===1)f+=e.readSVarint(),_+=e.readSVarint(),a&&o.push(a),a=[new Ue(f,_)];else if(c===2)f+=e.readSVarint(),_+=e.readSVarint(),a&&a.push(new Ue(f,_));else{if(c!==7)throw new Error(`unknown command ${c}`);a&&a.push(a[0].clone())}}return a&&o.push(a),o}bbox(){if(this._geometry<0)throw new Error("feature has no geometry");const e=this._pbf;e.pos=this._geometry;const i=e.readVarint()+e.pos;let o=1,a=0,c=0,h=0,f=1/0,_=-1/0,y=1/0,v=-1/0;for(;e.pos<i;){if(a<=0){const b=e.readVarint();if(o=7&b,a=b>>3,a===0)continue}if(a--,o===1||o===2)c+=e.readSVarint(),h+=e.readSVarint(),c<f&&(f=c),c>_&&(_=c),h<y&&(y=h),h>v&&(v=h);else if(o!==7)throw new Error(`unknown command ${o}`)}return[f,y,_,v]}toGeoJSON(e,i,o){const a=this.extent*Math.pow(2,o),c=this.extent*e,h=this.extent*i,f=this.loadGeometry();function _(T){return[360*(T.x+c)/a-180,360/Math.PI*Math.atan(Math.exp((1-2*(T.y+h)/a)*Math.PI))-90]}function y(T){return T.map(_)}let v;if(this.type===1){const T=[];for(const C of f)T.push(C[0]);const E=y(T);v=T.length===1?{type:"Point",coordinates:E[0]}:{type:"MultiPoint",coordinates:E}}else if(this.type===2){const T=f.map(y);v=T.length===1?{type:"LineString",coordinates:T[0]}:{type:"MultiLineString",coordinates:T}}else{if(this.type!==3)throw new Error("unknown feature type");{const T=(function(C){const P=C.length;if(P<=1)return[C];const R=[];let z,V;for(let N=0;N<P;N++){const U=wy(C[N]);U!==0&&(V===void 0&&(V=U<0),V===U<0?(z&&R.push(z),z=[C[N]]):z&&z.push(C[N]))}return z&&R.push(z),R})(f),E=[];for(const C of T)E.push(C.map(y));v=E.length===1?{type:"Polygon",coordinates:E[0]}:{type:"MultiPolygon",coordinates:E}}}const b={type:"Feature",geometry:v,properties:this.properties};return this.id!=null&&(b.id=this.id),b}}function wy(r){let e=0;for(let i,o,a=0,c=r.length,h=c-1;a<c;h=a++)i=r[a],o=r[h],e+=(o.x-i.x)*(i.y+o.y);return e}Za.types=["Unknown","Point","LineString","Polygon"];class Ty{constructor(e,i){for(this.version=1,this.name="",this.extent=4096,this.length=0,this._pbf=e,this._keys=[],this._values=[],this._features=[],i===void 0&&(i=e.length);e.pos<i;){const o=e.readVarint();o===10?this.name=e.readString():o===18?(this._features.push(e.pos),e.skip(o)):o===26?this._keys.push(e.readString()):o===34?this._values.push(dp(e)):o===40?this.extent=e.readVarint():o===120?this.version=e.readVarint():e.skip(o)}this.length=this._features.length}feature(e){if(e<0||e>=this._features.length)throw new Error("feature index out of bounds");this._pbf.pos=this._features[e];const i=this._pbf.readVarint()+this._pbf.pos;return new Za(this._pbf,i,this.extent,this._keys,this._values)}}function dp(r){let e=null;const i=r.readVarint()+r.pos;for(;r.pos<i;){const o=r.readVarint();e=o===10?r.readString():o===21?r.readFloat():o===25?r.readDouble():o===32?r.readVarint(!0):o===40?r.readVarint():o===48?r.readSVarint():o===56?r.readBoolean():(r.skip(o),null)}if(e==null)throw new Error("unknown feature value");return e}class fp{constructor(e,i=e.length){const o=Object.create(null);for(;e.pos<i;){const a=e.readVarint();if(a===26){const c=new Ty(e,e.readVarint()+e.pos);c.length&&(o[c.name]=c)}else e.skip(a)}this.layers=o}}function Lu(r,e){for(let i=0;i<r.length;i++)if(na(e,r[i]))return!0;for(let i=0;i<e.length;i++)if(na(r,e[i]))return!0;return!!mp(r,e)}function Sy(r,e,i){return!!na(r,e)||!!hd(e,r,i)}function pp(r,e){if(r.length===1)return T_(e,r[0]);for(let i=0;i<e.length;i++){const o=e[i];for(let a=0;a<o.length;a++)if(na(r,o[a]))return!0}for(let i=0;i<r.length;i++)if(T_(e,r[i]))return!0;for(let i=0;i<e.length;i++)if(mp(r,e[i]))return!0;return!1}function Ey(r,e,i){if(r.length>1){if(mp(r,e))return!0;for(let o=0;o<e.length;o++)if(hd(e[o],r,i))return!0}for(let o=0;o<r.length;o++)if(hd(r[o],e,i))return!0;return!1}function mp(r,e){if(r.length===0||e.length===0)return!1;for(let i=0;i<r.length-1;i++){const o=r[i],a=r[i+1];for(let c=0;c<e.length-1;c++)if(w_(o,a,e[c],e[c+1]))return!0}return!1}function w_(r,e,i,o){return Tt(r,i,o)!==Tt(e,i,o)&&Tt(r,e,i)!==Tt(r,e,o)}function zu(r,e,i){return(r.x-i.x)*(e.y-i.y)-(r.y-i.y)*(e.x-i.x)}function Iy(r,e,i,o){const a=zu(r,e,o),c=zu(r,e,i);if(Math.sign(a)===Math.sign(c))return;const h=zu(i,o,r),f=h+c-a;return Math.sign(h)!==Math.sign(f)?[h/(h-f),c/(c-a)]:void 0}function hd(r,e,i){const o=i*i;if(e.length===1)return r.distSqr(e[0])<o;for(let a=1;a<e.length;a++)if(_p(r,e[a-1],e[a])<o)return!0;return!1}function _p(r,e,i){const o=e.distSqr(i);if(o===0)return r.distSqr(e);const a=((r.x-e.x)*(i.x-e.x)+(r.y-e.y)*(i.y-e.y))/o;return r.distSqr(a<0?e:a>1?i:i.sub(e)._mult(a)._add(e))}function T_(r,e){let i,o,a,c=!1;for(let h=0;h<r.length;h++){i=r[h];for(let f=0,_=i.length-1;f<i.length;_=f++)o=i[f],a=i[_],o.y>e.y!=a.y>e.y&&e.x<(a.x-o.x)*(e.y-o.y)/(a.y-o.y)+o.x&&(c=!c)}return c}function na(r,e){let i=!1;for(let o=0,a=r.length-1;o<r.length;a=o++){const c=r[o],h=r[a];c.y>e.y!=h.y>e.y&&e.x<(h.x-c.x)*(e.y-c.y)/(h.y-c.y)+c.x&&(i=!i)}return i}function Fu(r,e,i,o,a){for(const h of r)if(e<=h.x&&i<=h.y&&o>=h.x&&a>=h.y)return!0;const c=[new Ue(e,i),new Ue(e,a),new Ue(o,a),new Ue(o,i)];if(r.length>2){for(const h of c)if(na(r,h))return!0}for(let h=0;h<r.length-1;h++)if(zl(r[h],r[h+1],c))return!0;return!1}function zl(r,e,i){const o=i[0],a=i[2];if(r.x<o.x&&e.x<o.x||r.x>a.x&&e.x>a.x||r.y<o.y&&e.y<o.y||r.y>a.y&&e.y>a.y)return!1;const c=Tt(r,e,i[0]);return c!==Tt(r,e,i[1])||c!==Tt(r,e,i[2])||c!==Tt(r,e,i[3])}function Rc(r,e,i,o,a,c){let h=e.y-r.y,f=r.x-e.x;if(c=c||0){const _=h*h+f*f;if(_===0)return!0;const y=Math.sqrt(_);h/=y,f/=y}return!((i.x-r.x)*h+(i.y-r.y)*f-c<0||(o.x-r.x)*h+(o.y-r.y)*f-c<0||(a.x-r.x)*h+(a.y-r.y)*f-c<0)}function dd(r,e,i,o,a,c,h){return!(Rc(r,e,o,a,c,h)||Rc(e,i,o,a,c,h)||Rc(i,r,o,a,c,h)||Rc(o,a,r,e,i,h)||Rc(a,c,r,e,i,h)||Rc(c,o,r,e,i,h))}class Fl extends Ue{constructor(e,i,o){super(e,i),this.z=o}}class fd extends Fl{constructor(e,i,o,a){super(e,i,o),this.w=a}}function S_(r,e,i,o){const a=i==="x"?"y":"x",c=(o-r[i])/(e[i]-r[i]);r[a]=Math.round(r[a]+(e[a]-r[a])*c),r[i]=o,Object.hasOwn(r,"z")&&(r.z=vt(r.z,e.z,c)),Object.hasOwn(r,"w")&&(r.w=vt(r.w,e.w,c))}function E_(r,e,i,o){const a=i,c=o;for(const h of["x","y"]){let f=r,_=e;f[h]>=_[h]&&(f=e,_=r),f[h]<a&&_[h]>a&&S_(f,_,h,a),f[h]<c&&_[h]>c&&S_(_,f,h,c)}}function pd(r,e,i,o,a,c){const h=[];for(let f=0;f<r.length;f++){const _=r[f];let y;const v=h.length;let b=0;for(let T=0;T<_.length-1;T++){let E=_[T],C=_[T+1],P=0;const R=b;let z,V;c&&(P=Math.hypot(C.x-E.x,C.y-E.y),b+=P,z=E,V=C),E.x<e&&C.x<e||(E.x<e?E=new Ue(e,E.y+(e-E.x)/(C.x-E.x)*(C.y-E.y))._round():C.x<e&&(C=new Ue(e,E.y+(e-E.x)/(C.x-E.x)*(C.y-E.y))._round()),E.y<i&&C.y<i||(E.y<i?E=new Ue(E.x+(i-E.y)/(C.y-E.y)*(C.x-E.x),i)._round():C.y<i&&(C=new Ue(E.x+(i-E.y)/(C.y-E.y)*(C.x-E.x),i)._round()),E.x>=o&&C.x>=o||(E.x>=o?E=new Ue(o,E.y+(o-E.x)/(C.x-E.x)*(C.y-E.y))._round():C.x>=o&&(C=new Ue(o,E.y+(o-E.x)/(C.x-E.x)*(C.y-E.y))._round()),E.y>=a&&C.y>=a||(E.y>=a?E=new Ue(E.x+(a-E.y)/(C.y-E.y)*(C.x-E.x),a)._round():C.y>=a&&(C=new Ue(E.x+(a-E.y)/(C.y-E.y)*(C.x-E.x),a)._round()),y&&E.equals(y.at(-1))||(y=[E],h.push(y),c&&c.push({progress:{min:R+gp(z,V,E)*P,max:1},parentIndex:f,prevPoint:z,nextPoint:V})),y.push(C),c&&(c.at(-1).progress.max=R+gp(z,V,C)*P,c.at(-1).nextPoint=V)))))}if(c&&b>0)for(let T=v;T<h.length;T++)c[T].progress.min/=b,c[T].progress.max/=b}return h}function Ay(r,e,i,o,a){if(r.length<2)return void o.push(r);const c=[];for(;e.valid();){const[y,v]=e.get();for(let b=0;b<r.length-1;b++){const T=r[b],E=r[b+1],C=Iy(T,E,y,v);if(C){const[P]=C,R=new Ue(vt(T.x,E.x,P),vt(T.y,E.y,P));c.push({t:b+P,distance:0,point:R})}}e.next()}if(c.length===0)return void o.push(r);c.sort((y,v)=>y.t-v.t);let h=0,f=0,_=[];for(o.push(_);h!==r.length;){if(f===c.length){for(;h!==r.length;)_.length!==0&&_.at(-1).equals(r[h])||_.push(r[h]),h++;break}c[f].t<=h?(_.length!==0&&_.at(-1).equals(c[f].point)||_.push(c[f].point),Math.trunc(c[f].t),f++):(_.length!==0&&_.at(-1).equals(r[h])||_.push(r[h]),h++)}}function gp(r,e,i){return r.x!==e.x?(i.x-r.x)/(e.x-r.x):r.y!==e.y?(i.y-r.y)/(e.y-r.y):0}function I_(r,{width:e,height:i},o,a){if(a){if(a instanceof Uint8ClampedArray)a=new Uint8Array(a.buffer);else if(a.length!==e*i*o)throw new RangeError("mismatched image size")}else a=new Uint8Array(e*i*o);return r.width=e,r.height=i,r.data=a,r}function A_(r,e,i){const{width:o,height:a}=e;o===r.width&&a===r.height||(yp(r,e,{x:0,y:0},{x:0,y:0},{width:Math.min(r.width,o),height:Math.min(r.height,a)},i,null),r.width=o,r.height=a,r.data=e.data)}function yp(r,e,i,o,a,c,h,f){if(a.width===0||a.height===0)return e;if(a.width>r.width||a.height>r.height||i.x>r.width-a.width||i.y>r.height-a.height)throw new RangeError("out of range source coordinates for image copy");if(a.width>e.width||a.height>e.height||o.x>e.width-a.width||o.y>e.height-a.height)throw new RangeError("out of range destination coordinates for image copy");const _=r.data,y=e.data,v=c===4&&f;for(let b=0;b<a.height;b++){const T=((i.y+b)*r.width+i.x)*c,E=((o.y+b)*e.width+o.x)*c;if(v)for(let C=0;C<a.width;C++){const P=T+C*c+3,R=E+C*c;y[R+0]=255,y[R+1]=255,y[R+2]=255,y[R+3]=_[P]}else if(h)for(let C=0;C<a.width;C++){const P=T+C*c,R=E+C*c,z=new ai(_[P+0]/255,_[P+1]/255,_[P+2]/255,_[P+3]).toNonPremultipliedRenderColor(h).toArray();y[R+0]=z[0],y[R+1]=z[1],y[R+2]=z[2],y[R+3]=z[3]}else for(let C=0;C<a.width*c;C++)y[E+C]=_[T+C]}return e}class Wa{constructor(e,i){I_(this,e,1,i)}resize(e){A_(this,new Wa(e),1)}clone(){return new Wa({width:this.width,height:this.height},new Uint8Array(this.data))}static copy(e,i,o,a,c){yp(e,i,o,a,c,1,null)}}class bn{constructor(e,i){I_(this,e,4,i)}resize(e){A_(this,new bn(e),4)}replace(e,i){i?this.data.set(e):this.data=e instanceof Uint8ClampedArray?new Uint8Array(e.buffer):e}clone(){return new bn({width:this.width,height:this.height},new Uint8Array(this.data))}static copy(e,i,o,a,c,h,f){yp(e,i,o,a,c,4,h,f)}}class C_{constructor(e,i){this.width=e.width,this.height=e.height,this.data=i instanceof Uint8Array?new Float32Array(i.buffer):i}}nt(Wa,"AlphaImage"),nt(bn,"RGBAImage");class M_{constructor(e,i){this.width=e,this.height=i,this.nextRow=0,this.image=new Wa({width:e,height:i}),this.positions={},this.uploaded=!1}getDash(e,i){const o=this.getKey(e,i);return this.positions[o]}trim(){const e=this.width,i=this.height=H(this.nextRow);this.image.resize({width:e,height:i})}getKey(e,i){return e.join(",")+i}getDashRanges(e,i,o){const a=[];let c=e.length%2==1?-e.at(-1)*o:0,h=e[0]*o,f=!0;a.push({left:c,right:h,isDash:f,zeroLength:e[0]===0});let _=e[0];for(let y=1;y<e.length;y++){f=!f;const v=e[y];c=_*o,_+=v,h=_*o,a.push({left:c,right:h,isDash:f,zeroLength:v===0})}return a}addRoundDash(e,i,o){const a=i/2;for(let c=-o;c<=o;c++){const h=this.width*(this.nextRow+o+c);let f=0,_=e[f];for(let y=0;y<this.width;y++){y/_.right>1&&(_=e[++f]);const v=Math.abs(y-_.left),b=Math.abs(y-_.right),T=Math.min(v,b);let E;const C=c/o*(a+1);if(_.isDash){const P=a-Math.abs(C);E=Math.sqrt(T*T+P*P)}else E=a-Math.sqrt(T*T+C*C);this.image.data[h+y]=Math.max(0,Math.min(255,E+128))}}}addRegularDash(e,i){for(let _=e.length-1;_>=0;--_){const y=e[_],v=e[_+1];y.zeroLength?e.splice(_,1):v&&v.isDash===y.isDash&&(v.left=y.left,e.splice(_,1))}const o=e[0],a=e.at(-1);o.isDash===a.isDash&&(o.left=a.left-this.width,a.right=o.right+this.width);const c=this.width*this.nextRow;let h=0,f=e[h];for(let _=0;_<this.width;_++){_/f.right>1&&(f=e[++h]);const y=Math.abs(_-f.left),v=Math.abs(_-f.right),b=Math.min(y,v);this.image.data[c+_]=Math.max(0,Math.min(255,(f.isDash?b:-b)+i+128))}}addDash(e,i){const o=this.getKey(e,i);if(this.positions[o])return this.positions[o];const a=i==="round",c=a?7:0,h=2*c+1;if(this.nextRow+h>this.height)return ht("LineAtlas out of space"),null;e.length===0&&e.push(1);let f=0;for(let b=0;b<e.length;b++)e[b]<0&&(ht("Negative value is found in line dasharray, replacing values with 0"),e[b]=0),f+=e[b];if(f!==0){const b=this.width/f,T=this.getDashRanges(e,this.width,b);a?this.addRoundDash(T,b,c):this.addRegularDash(T,i==="square"?.5*b:0)}const _=this.nextRow+c;this.nextRow+=h;const y=Math.floor(f),v={tl:[_,c],br:[y,Math.round(65535*(f-y))]};return this.positions[o]=v,v}}nt(M_,"LineAtlas");const Ps="3d_elevation_id",P_="level",md=Za.types,Cy=Math.cos(Math.PI/180*37.5),My=Math.cos(Math.PI/180*5);class Dc{constructor(e){this.evaluationGlobals={zoom:0,lineProgress:void 0},this.elevationType="none",this.isSeaLevelReference=!1,this.showElevationIdDebug=!1,this.terrainEnabled=!1,this.zoom=e.zoom,this.evaluationGlobals.zoom=this.zoom,this.overscaling=e.overscaling,this.pixelRatio=e.pixelRatio,this.layers=e.layers,this.layerIds=this.layers.map(i=>i.fqid),this.index=e.index,this.projection=e.projection,this.hasPattern=!1,this.hasCrossSlope=!1,this.patternFeatures=[],this.lineClipsArray=[],this.gradients={},this.layers.forEach(i=>{this.gradients[i.id]={}}),this.layoutVertexArray=new qh,this.layoutVertexArray2=new cs,this.patternVertexArray=new cs,this.indexArray=new sn,this.programConfigurations=new hs(e.layers,{zoom:e.zoom,lut:e.lut}),this.segments=new Fi,this.sourceLayerName=e.sourceLayerName||"",this.maxLineLength=0,this.zOffsetVertexArray=new ga,this.elevationIdColVertexArray=new cs,this.elevationGroundScaleVertexArray=new Js,this.stateDependentLayerIds=this.layers.filter(i=>i.isStateDependent()).map(i=>i.id),this.tessellationStep=e.tessellationStep?e.tessellationStep:128,this.worldview=e.worldview,this.hasAppearances=null}updateFootprints(e,i){}updateAppearances(e,i,o,a){return{hasLayoutChanges:!1,hasUboChanges:!1}}populate(e,i,o,a){this.showElevationIdDebug=i.showElevationIdDebug,this.terrainEnabled=i.terrainEnabled,this.hasPattern=kf("line",this.layers,this.pixelRatio,i);const c=this.layers[0].layout.get("line-sort-key");this.tileToMeter=yo(o);const h=this.layers[0].layout.get("line-elevation-reference");if(h==="hd-road-markup")this.elevationType="road";else{const T=this.layers[0].layout.get("line-z-offset"),E=T.isConstant()&&!T.constantOr(0);this.elevationType=h!=="sea"&&h!=="ground"&&E?"none":"offset",this.elevationType==="offset"&&h==="none"&&ht(`line-elevation-reference: ground is used for the layer ${this.layerIds[0]} because non-zero line-z-offset value was found.`),this.isSeaLevelReference=h==="sea"}const f=this.layers[0].layout.get("line-cross-slope");this.hasCrossSlope=this.elevationType==="offset"&&f!==void 0;const _=[];for(const{feature:T,id:E,index:C,sourceLayerIndex:P}of e){const R=this.layers[0]._featureFilter.needGeometry,z=Vo(T,R);if(!this.layers[0]._featureFilter.filter(new xt(this.zoom,{worldview:this.worldview,activeFloors:i.activeFloors}),z,o))continue;const V=c?c.evaluate(z,{},o):void 0,N={id:E,properties:T.properties,type:T.type,sourceLayerIndex:P,index:C,geometry:R?z.geometry:ls(T,o,a),patterns:{},sortKey:V};_.push(N)}c&&_.sort((T,E)=>T.sortKey-E.sortKey);const{lineAtlas:y,featureIndex:v}=i,b=this.addConstantDashes(y);for(const T of _){const{geometry:E,index:C,sourceLayerIndex:P}=T;if(b&&this.addFeatureDashes(T,y),this.hasPattern){const R=Bf("line",this.layers,T,this.zoom,this.pixelRatio,i);this.patternFeatures.push(R)}else this.addFeature(T,E,C,o,y.positions,i.availableImages,i.brightness,i.elevationFeatures,i.elevationParams,i.crossSourceElevationEnabled);v.insert(e[C].feature,E,C,P,this.index)}!this.hasPattern&&this.hdExt&&this.hdExt.buildFrcSegments(this),this.hdExt&&this.hdExt.endPopulate()}addConstantDashes(e){let i=!1;for(const o of this.layers){const a=o.paint.get("line-dasharray").value,c=o.layout.get("line-cap").value;if(a.kind!=="constant"||c.kind!=="constant")i=!0;else{const h=c.value,f=a.value;if(!f)continue;e.addDash(f,h)}}return i}addFeatureDashes(e,i){const o=this.zoom;for(const a of this.layers){const c=a.paint.get("line-dasharray").value,h=a.layout.get("line-cap").value;if(c.kind==="constant"&&h.kind==="constant")continue;let f,_;if(c.kind==="constant"){if(f=c.value,!f)continue}else f=c.evaluate({zoom:o},e);_=h.kind==="constant"?h.value:h.evaluate({zoom:o},e),i.addDash(f,_),e.patterns[a.id]=[i.getKey(f,_)]}}update(e,i,o,a,c,h,f,_,y){this.programConfigurations.updatePaintArrays(e,i,c,o,a,h,f,y)}updateExpressions(e){this.programConfigurations.updateExpressions(e)}addFeatures(e,i,o,a,c,h){for(const f of this.patternFeatures)this.addFeature(f,f.geometry,f.index,i,o,a,h,e.elevationFeatures,e.elevationParams,e.crossSourceElevationEnabled);this.hdExt&&(this.hdExt.buildFrcSegments(this),this.hdExt.endPopulate())}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,Uo)),this.patternVertexArray.length!==0&&(this.patternVertexBuffer=e.createVertexBuffer(this.patternVertexArray,by)),!this.zOffsetVertexBuffer&&this.zOffsetVertexArray.length>0&&(this.zOffsetVertexBuffer=e.createVertexBuffer(this.zOffsetVertexArray,yy.members,!0)),!this.elevationIdColVertexBuffer&&this.elevationIdColVertexArray.length>0&&(this.elevationIdColVertexBuffer=e.createVertexBuffer(this.elevationIdColVertexArray,xy.members,!0)),!this.elevationGroundScaleVertexBuffer&&this.elevationGroundScaleVertexArray.length>0&&(this.elevationGroundScaleVertexBuffer=e.createVertexBuffer(this.elevationGroundScaleVertexArray,vy.members,!0)),this.layoutVertexBuffer=e.createVertexBuffer(this.layoutVertexArray,ld),this.indexBuffer=e.createIndexBuffer(this.indexArray)),this.programConfigurations.upload(e),this.uploaded=!0}destroy(){this.layoutVertexBuffer&&(this.zOffsetVertexBuffer&&this.zOffsetVertexBuffer.destroy(),this.elevationIdColVertexBuffer&&this.elevationIdColVertexBuffer.destroy(),this.elevationGroundScaleVertexBuffer&&this.elevationGroundScaleVertexBuffer.destroy(),this.layoutVertexBuffer.destroy(),this.indexBuffer.destroy(),this.programConfigurations.destroy(),this.segments.destroy())}lineFeatureClips(e,i){let o,a;if(i&&i>0?(o=`mapbox_clip_start_${i}`,a=`mapbox_clip_end_${i}`):(o="mapbox_clip_start",a="mapbox_clip_end"),e.properties&&Object.hasOwn(e.properties,o)&&Object.hasOwn(e.properties,a))return{start:+e.properties[o],end:+e.properties[a]}}addFeature(e,i,o,a,c,h,f,_,y,v){const b=this.layers[0].layout,T=this.hdExt?this.hdExt.trackFeatureFrc(e.properties):null,E=this.indexArray.length,C=b.get("line-join").evaluate(e,{}),P=b.get("line-cap").evaluate(e,{}),R=b.get("line-miter-limit"),z=b.get("line-round-limit");this.lineClips=this.lineFeatureClips(e),this.lineFeature=e;const V=!(!e.properties||!Object.hasOwn(e.properties,"mapbox_line_metrics"))&&e.properties.mapbox_line_metrics;this.zOffsetValue=b.get("line-z-offset").value;const N=this.layers[0].paint,U=N.get("line-width").value;U.kind!=="constant"&&U.isLineProgressConstant===!1&&(this.variableWidthValue=U);const q=N.get("line-emissive-strength").value;if(q.kind!=="constant"&&q.isLineProgressConstant===!1&&(this.variableEmissiveStrengthValue=q),this.isSeaLevelReference){const W=b.get("line-elevation-ground-scale").value;W.kind==="constant"&&W.value===0||(this.elevationGroundScaleValue=W)}if(this.hdExt==null||!this.hdExt.handleFeature(e,i,a,_,y,!!v,C,P,R,z,this))for(let W=0;W<i.length;W++)this.addLine(i[W],e,a,C,P,R,z,void 0,V&&W>0?W:null);this.programConfigurations.populatePaintArrays(this.layoutVertexArray.length,e,o,c,h,a,f,void 0,this.worldview),this.hdExt&&this.hdExt.recordFeatureRange(this,E,this.indexArray.length,T)}fillNonElevatedRoadSegment(e){for(let i=Math.max(e,this.zOffsetVertexArray.length);i<this.layoutVertexArray.length;i++)this.zOffsetVertexArray.emplaceBack(0,0,0,0),this.showElevationIdDebug&&this.elevationIdColVertexArray.emplaceBack(0,0,0)}addLine(e,i,o,a,c,h,f,_,y){this.distance=0,this.prevDistance=0,this.scaledDistance=0,this.totalDistance=0,this.totalFeatureLength=0,this.lineSoFar=0,this.currentVertex=void 0,this.lineClips=y?this.lineFeatureClips(i,y):this.lineClips;const v=a==="none";this.patternJoinNone=this.hasPattern&&v,this.currentLineJoinType=a,this.segmentStart=0,this.segmentStartf32=0,this.segmentPoints=[];const b=_&&_.progress.min>0,T=_&&_.progress.max<1;if(this.lineClips){let ie={min:this.lineClips.start,max:this.lineClips.end},re=1;if(_){const xe=this.lineClips.end-this.lineClips.start;ie=(function(we,Ce,Se){return{min:Gr(we.min,Ce,Se),max:Gr(we.max,Ce,Se)}})(_.progress,{min:0,max:1},ie),xe>0&&(re=(ie.max-ie.min)/xe)}const oe=+i.properties.mapbox_clip_feature_len,me=+i.properties.mapbox_clip_seg_len;if(Number.isNaN(oe)||Number.isNaN(me)){for(let we=0;we<e.length-1;we++)this.totalDistance+=e[we].dist(e[we+1]);const xe=this.totalDistance/(ie.max-ie.min);this.totalFeatureLength=Number.isFinite(xe)?xe:0,this.lineClips.start=ie.min,this.lineClips.end=ie.max,this.maxLineLength=Math.max(this.maxLineLength,this.totalDistance)}else this.totalFeatureLength=oe,this.distance=me*re,this.lineClips.start=ie.min,this.lineClips.end=ie.max,this.maxLineLength=Math.max(this.maxLineLength,this.distance);this.lineClipsArray.push(this.lineClips),this.updateScaledDistance()}const E=md[i.type]==="Polygon";let C=e.length;for(;C>=2&&e[C-1].equals(e[C-2]);)C--;let P=0;for(;P<C-1&&e[P].equals(e[P+1]);)P++;if(C<(E?3:2))return;a==="bevel"&&(h=1.05);const R=this.segments.prepareSegment(10*C,this.layoutVertexArray,this.indexArray);let z,V,N,U,q,W,se,X;_&&_.prevDir&&(W=_.prevDir.perp()),_&&_.nextDir&&(se=_.nextDir.perp()),this.e1=this.e2=-1,E&&(z=e[C-2],q=e[P].sub(z)._unit()._perp());for(let ie=P;ie<C;ie++){if(N=ie===C-1?E?e[P+1]:void 0:e[ie+1],N&&e[ie].equals(N))continue;q&&(U=q),z&&(V=z),z=e[ie],X=this.evaluateLineProgressFeatures(V?V.dist(z):0),q=N?N.sub(z)._unit()._perp():U,U=U||q;const re=V&&N;let oe=re?a:E||v?"butt":c;const me=U.x*q.x+U.y*q.y;if(v){const Pe=function(Ne){if(Ne.patternJoinNone){const ke=Ne.segmentPoints.length/2,$e=Ne.lineSoFar-Ne.segmentStart;for(let ze=0;ze<ke;++ze){const He=Ne.segmentPoints[2*ze+1],Ye=Math.round(Ne.segmentPoints[2*ze])+.5+.25*He;Ne.patternVertexArray.emplaceBack(Ye,$e,Ne.segmentStart),Ne.patternVertexArray.emplaceBack(Ye,$e,Ne.segmentStart)}Ne.segmentPoints.length=0}Ne.e1=Ne.e2=-1};if(re&&me<My){this.updateDistance(V,z),this.addCurrentVertex(z,U,1,1,R,X),Pe(this),this.addCurrentVertex(z,q,-1,-1,R,X);continue}if(V){if(!N){this.updateDistance(V,z),this.addCurrentVertex(z,U,1,1,R,X),Pe(this);continue}oe="miter"}}let xe=U.add(q);xe.x===0&&xe.y===0||xe._unit();const we=xe.x*q.x+xe.y*q.y,Ce=we!==0?1/we:1/0,Se=2*Math.sqrt(2-2*we),qe=we<Cy&&V&&N,Me=U.x*q.y-U.y*q.x>0,Ie=this.overscaling<=16?122880/(512*this.overscaling):0;if(re&&oe==="round"){if(Ce<f)oe="miter";else if(Ce<=2){const Pe=xp(z,-10,8202);oe=this.elevationType==="offset"&&(Pe||this.hasCrossSlope)?"miter":"fakeround"}}if(oe==="miter"&&Ce>h&&(oe="bevel"),oe==="bevel"&&(Ce>2&&(oe="flipbevel"),Ce<h&&(oe="miter")),V&&!(oe==="miter"&&qe)&&this.updateDistance(V,z),oe==="miter")if(qe){const Pe=z.dist(V);if(Pe>2*Ie){const ke=z.sub(z.sub(V)._mult(Ie/Pe)._round());this.updateDistance(V,ke),this.addCurrentVertex(ke,U,0,0,R,X),V=ke}this.updateDistance(V,z),xe._mult(Ce),this.addCurrentVertex(z,xe,0,0,R,X);const Ne=z.dist(N);if(Ne>2*Ie){const ke=z.add(N.sub(z)._mult(Ie/Ne)._round());this.updateDistance(z,ke),this.addCurrentVertex(ke,q,0,0,R,X),z=ke}}else xe._mult(Ce),this.addCurrentVertex(z,xe,0,0,R,X);else if(oe==="flipbevel"){if(Ce>100)xe=q.mult(-1);else{const Pe=Ce*U.add(q).mag()/U.sub(q).mag();xe._perp()._mult(Pe*(Me?-1:1))}this.addCurrentVertex(z,xe,0,0,R,X),this.addCurrentVertex(z,xe.mult(-1),0,0,R,X)}else if(oe==="bevel"||oe==="fakeround"){const Pe=z.dist(V);let Ne=1;if(this.elevationType==="offset"&&oe==="bevel"&&this.currentLineJoinType!=="round"&&!this.patternJoinNone&&X!=null&&V&&N){const st=4*Ie;Pe<st&&(Ne=Math.max(0,Pe/st))}X!=null&&V&&this.addCurrentVertex(z,se||U,-Ne,-Ne,R,X);const ke=Pe<=2*Ie&&oe!=="bevel",$e=xe.mult(Me?1:-1);$e._mult(Ce);const ze=q.mult(Me?-1:1),He=U.mult(Me?-1:1),Ye=this.evaluateLineProgressFeatures(this.distance);if(X==null&&(this.addHalfVertex(z,$e.x,$e.y,!1,!Me,0,R,Ye),ke||this.addHalfVertex(z,$e.x+2*He.x,$e.y+2*He.y,!1,Me,0,R,Ye)),oe==="fakeround"){const st=Math.round(180*Se/Math.PI/20);this.addHalfVertex(z,He.x,He.y,!1,Me,0,R,Ye);for(let Je=0;Je<st;Je++){let Qe=Je/st;if(Qe!==.5){const wt=Qe-.5;Qe+=Qe*wt*(Qe-1)*((1.0904+me*(me*(3.55645-1.43519*me)-3.2452))*wt*wt+(.848013+me*(.215638*me-1.06021)))}const dt=ze.sub(He)._mult(Qe)._add(He)._unit();this.addHalfVertex(z,dt.x,dt.y,!1,Me,0,R,Ye)}this.addHalfVertex(z,ze.x,ze.y,!1,Me,0,R,Ye)}ke||X!=null||this.addHalfVertex(z,$e.x+2*ze.x,$e.y+2*ze.y,!1,Me,0,R,Ye),X!=null&&N&&this.addCurrentVertex(z,W||q,Ne,Ne,R,X)}else if(oe==="butt")this.addCurrentVertex(z,xe,0,0,R,X);else if(oe==="square"){if(!V){const Pe=b?0:-1;this.addCurrentVertex(z,xe,Pe,Pe,R,X)}if(this.addCurrentVertex(z,xe,0,0,R,X),V){const Pe=T?0:1;this.addCurrentVertex(z,xe,Pe,Pe,R,X)}}else if(oe==="round"){if(V){const Pe=!re&&se?se:U;this.addCurrentVertex(z,Pe,0,0,R,X),!re&&T||this.addCurrentVertex(z,Pe,1,1,R,X,!0)}if(N){const Pe=!re&&W?W:q;!re&&b||this.addCurrentVertex(z,Pe,-1,-1,R,X,!0),this.addCurrentVertex(z,Pe,0,0,R,X)}}}}addVerticesTo(e,i,o,a,c,h,f,_,y,v){const b=(i.w-e.w)/this.tessellationStep|0;let T=0;const E=this.scaledDistance;if(b>1){this.lineSoFar=e.w;const P=(i.x-e.x)/b,R=(i.y-e.y)/b,z=(i.z-e.z)/b,V=(i.w-e.w)/b,N=i.x-e.x,U=i.y-e.y,q=Math.sqrt(N*N+U*U);if(q===0)return;const W=-U/q,se=N/q,X=W,ie=se,re=-W,oe=-se;for(let me=1;me<b;++me){e.x+=P,e.y+=R,e.z+=z,this.lineSoFar+=V,T+=V;const xe=this.evaluateLineProgressFeatures(this.prevDistance+T);this.scaledDistance=(this.prevDistance+T)/this.totalDistance,this.addHalfVertex(e,X,ie,v,!1,0,y,xe),this.addHalfVertex(e,re,oe,v,!0,0,y,xe)}}this.lineSoFar=i.w,this.scaledDistance=E;const C=this.evaluateLineProgressFeatures(this.distance);this.addHalfVertex(i,o,a,v,!1,f,y,C),this.addHalfVertex(i,c,h,v,!0,-_,y,C)}evaluateLineProgressFeatures(e){if(!this.variableWidthValue&&!this.variableEmissiveStrengthValue&&this.elevationType!=="offset")return null;this.evaluationGlobals.lineProgress=0,this.lineClips?this.evaluationGlobals.lineProgress=Math.min(1,(this.totalFeatureLength*this.lineClips.start+e)/this.totalFeatureLength):ht(`line-progress evaluation for ${this.layerIds[0]} requires enabling 'lineMetrics' for the source.`);let i=0;this.variableWidthValue&&this.variableWidthValue.kind!=="constant"&&(i=this.variableWidthValue.evaluate(this.evaluationGlobals,this.lineFeature)||0,i*=.5);let o=0;this.variableEmissiveStrengthValue&&this.variableEmissiveStrengthValue.kind!=="constant"&&(o=this.variableEmissiveStrengthValue.evaluate(this.evaluationGlobals,this.lineFeature)||0);const a=this.evaluateElevationGroundScale();return this.elevationType!=="offset"?{zOffset:0,variableWidth:i,elevationGroundScale:a,variableEmissiveStrength:o}:this.zOffsetValue.kind==="constant"?{zOffset:this.zOffsetValue.value,variableWidth:i,elevationGroundScale:a,variableEmissiveStrength:o}:{zOffset:this.zOffsetValue.evaluate(this.evaluationGlobals,this.lineFeature)||0,variableWidth:i,elevationGroundScale:a,variableEmissiveStrength:o}}evaluateElevationGroundScale(){return this.elevationGroundScaleValue?this.elevationGroundScaleValue.kind==="constant"?this.elevationGroundScaleValue.value:this.elevationGroundScaleValue.evaluate(this.evaluationGlobals,this.lineFeature)||0:0}addCurrentVertex(e,i,o,a,c,h,f=!1){const _=i.x+i.y*o,y=i.y-i.x*o,v=i.y*a-i.x,b=-i.y-i.x*a;if(h!=null){const T=this.elevationType==="offset",E=this.elevationType==="offset"?2:10,C=-E,P=rt+E,R=h.zOffset,z=new fd(e.x,e.y,R,this.lineSoFar),V=!!T&&xp(e,C,P),N=this.lineSoFar,U=this.distance;if(this.currentVertex)if(V){const q=this.currentVertexIsOutside,W=this.currentVertex,se=new fd(e.x,e.y,R,this.lineSoFar);if(E_(W,se,C,P),!xp(se,C,P)){if(q){this.e1=this.e2=-1,this.distance-=W.dist(z),this.lineSoFar=W.w;const X=this.evaluateLineProgressFeatures(W.w-this.totalFeatureLength*(this.lineClips?this.lineClips.start:0));this.addHalfVertex(W,_,y,f,!1,o,c,X),this.addHalfVertex(W,v,b,f,!0,-a,c,X),this.prevDistance=this.distance}this.distance=this.prevDistance+W.dist(se),this.scaledDistance=this.distance/this.totalDistance,this.addVerticesTo(W,se,_,y,v,b,o,a,c,f),this.distance=U,this.scaledDistance=this.distance/this.totalDistance}}else{const q=this.currentVertex;if(this.currentVertexIsOutside){E_(q,z,C,P),this.e1=this.e2=-1,this.distance-=q.dist(z),this.scaledDistance=this.distance/this.totalDistance,this.lineSoFar=q.w;const W=this.evaluateLineProgressFeatures(q.w-this.totalFeatureLength*(this.lineClips?this.lineClips.start:0));this.addHalfVertex(q,_,y,f,!1,o,c,W),this.addHalfVertex(q,v,b,f,!0,-a,c,W),this.prevDistance=this.distance,this.distance=U,this.scaledDistance=this.distance/this.totalDistance}this.addVerticesTo(q,z,_,y,v,b,o,a,c,f)}else V||(this.addHalfVertex(e,_,y,f,!1,o,c,h),this.addHalfVertex(e,v,b,f,!0,-a,c,h));this.currentVertex=z,this.currentVertexIsOutside=V,this.lineSoFar=N}else this.addHalfVertex(e,_,y,f,!1,o,c,h),this.addHalfVertex(e,v,b,f,!0,-a,c,h)}addHalfVertex({x:e,y:i},o,a,c,h,f,_,y){if(this.patternJoinNone&&(this.segmentPoints.length===0&&(this.segmentStart=this.lineSoFar,this.segmentStartf32=Math.fround(this.lineSoFar)),h||this.segmentPoints.push(this.lineSoFar-this.segmentStart,f)),this.layoutVertexArray.emplaceBack((e<<1)+(c?1:0),(i<<1)+(h?1:0),Math.round(63*o)+128,Math.round(63*a)+128,1+(f===0?0:f<0?-1:1),0,this.lineSoFar-this.segmentStartf32),this.lineClips){const b=vt(this.lineClips.start,this.lineClips.end,this.scaledDistance);this.layoutVertexArray2.emplaceBack(this.scaledDistance,this.lineClipsArray.length,b)}const v=_.vertexLength++;if(this.e1>=0&&this.e2>=0&&(this.indexArray.emplaceBack(this.e1,this.e2,v),_.primitiveLength++),h?this.e2=v:this.e1=v,y!=null&&(this.zOffsetVertexArray.emplaceBack(y.zOffset,y.variableWidth,y.variableWidth,y.variableEmissiveStrength),this.showElevationIdDebug&&this.elevationIdColVertexArray.emplaceBack(0,0,0)),this.elevationGroundScaleValue){const b=y?y.elevationGroundScale:this.evaluateElevationGroundScale();this.elevationGroundScaleVertexArray.emplaceBack(b)}}updateScaledDistance(){this.lineClips?(this.scaledDistance=this.distance/this.totalDistance,this.lineSoFar=this.totalFeatureLength*this.lineClips.start+this.distance):this.lineSoFar=this.distance}updateDistance(e,i){this.prevDistance=this.distance,this.distance+=e.dist(i),this.updateScaledDistance()}}function xp(r,e,i){return r.x<e||r.x>i||r.y<e||r.y>i}nt(Dc,"LineBucket",{omit:["layers","patternFeatures","currentVertex","currentVertexIsOutside"]});const R_=Gt([{name:"a_pos",components:2,type:"Int16"}],4),Py=Gt([{name:"a_circle_z_offset",components:1,type:"Float32"}],4),Ry=Gt([{name:"a_pos_3",components:3,type:"Int16"},{name:"a_pos_normal_3",components:3,type:"Int16"}]);class Ou{constructor(e){this.zoom=e.zoom,this.overscaling=e.overscaling,this.layers=e.layers,this.layerIds=this.layers.map(i=>i.fqid),this.index=e.index,this.hasPattern=!1,this.projection=e.projection,this.layoutVertexArray=new _a,this.indexArray=new sn,this.segments=new Fi,this.programConfigurations=new hs(e.layers,{zoom:e.zoom,lut:e.lut}),this.stateDependentLayerIds=this.layers.filter(i=>i.isStateDependent()).map(i=>i.id),this.worldview=e.worldview,this.hasAppearances=null}updateFootprints(e,i){}updateAppearances(e,i,o,a){return{hasLayoutChanges:!1,hasUboChanges:!1}}populate(e,i,o,a){const c=this.layers[0],h=[];let f=null;c.type==="circle"&&(f=c.layout.get("circle-sort-key"));for(const{feature:y,id:v,index:b,sourceLayerIndex:T}of e){const E=this.layers[0]._featureFilter.needGeometry,C=Vo(y,E);if(!this.layers[0]._featureFilter.filter(new xt(this.zoom,{worldview:this.worldview,activeFloors:i.activeFloors}),C,o))continue;const P=f?f.evaluate(C,{},o):void 0,R={id:v,properties:y.properties,type:y.type,sourceLayerIndex:T,index:b,geometry:E?C.geometry:ls(y,o,a),patterns:{},sortKey:P};h.push(R)}f&&h.sort((y,v)=>y.sortKey-v.sortKey);let _=null;a.projection.name==="globe"&&(this.globeExtVertexArray=new Su,_=a.projection);for(const y of h){const{geometry:v,index:b,sourceLayerIndex:T}=y,E=e[b].feature;this.addFeature(y,v,b,i.availableImages,o,_,i.brightness,i.elevationFeatures),i.featureIndex.insert(E,v,b,T,this.index)}this.hdExt&&this.hdExt.finalize()}update(e,i,o,a,c,h,f){this.programConfigurations.updatePaintArrays(e,i,c,o,a,h,f,this.worldview)}updateExpressions(e){this.programConfigurations.updateExpressions(e)}isEmpty(){return this.layoutVertexArray.length===0}uploadPending(){return!this.uploaded||this.programConfigurations.needsUpload}upload(e){this.uploaded||(this.layoutVertexBuffer=e.createVertexBuffer(this.layoutVertexArray,R_.members),this.indexBuffer=e.createIndexBuffer(this.indexArray),this.globeExtVertexArray&&(this.globeExtVertexBuffer=e.createVertexBuffer(this.globeExtVertexArray,Ry.members)),this.hdExt&&this.hdExt.upload(e)),this.programConfigurations.upload(e),this.uploaded=!0}destroy(){this.layoutVertexBuffer&&(this.layoutVertexBuffer.destroy(),this.indexBuffer.destroy(),this.programConfigurations.destroy(),this.segments.destroy(),this.globeExtVertexBuffer&&this.globeExtVertexBuffer.destroy(),this.hdExt&&this.hdExt.destroy())}addFeature(e,i,o,a,c,h,f,_){this.hdExt&&this.hdExt.beginFeature(e,_,c);for(const y of i)for(const v of y){const b=v.x,T=v.y;if(b<0||b>=rt||T<0||T>=rt)continue;if(h){const P=h.projectTilePoint(b,T,c),R=h.upVector(c,b,T);this.addGlobeExtVertex(P,R),this.addGlobeExtVertex(P,R),this.addGlobeExtVertex(P,R),this.addGlobeExtVertex(P,R)}const E=this.segments.prepareSegment(4,this.layoutVertexArray,this.indexArray,e.sortKey),C=E.vertexLength;this.addCircleVertex(b,T,-1,-1),this.addCircleVertex(b,T,1,-1),this.addCircleVertex(b,T,1,1),this.addCircleVertex(b,T,-1,1),this.hdExt&&this.hdExt.writeVertexQuad(b,T),this.indexArray.emplaceBack(C,C+1,C+2),this.indexArray.emplaceBack(C,C+2,C+3),E.vertexLength+=4,E.primitiveLength+=2}this.programConfigurations.populatePaintArrays(this.layoutVertexArray.length,e,o,{},a,c,f,void 0,this.worldview)}addCircleVertex(e,i,o,a){this.layoutVertexArray.emplaceBack(2*e+(o+1)/2,2*i+(a+1)/2)}addGlobeExtVertex(e,i){this.globeExtVertexArray.emplaceBack(e.x,e.y,e.z,i[0]*16384,i[1]*16384,i[2]*16384)}}nt(Ou,"CircleBucket",{omit:["layers"]});const D_=Gt([{name:"a_pos_offset",components:4,type:"Int16"},{name:"a_tex_size",components:4,type:"Uint16"},{name:"a_pixeloffset",components:4,type:"Int16"}],4),L_=Gt([{name:"a_globe_anchor",components:3,type:"Int16"},{name:"a_globe_normal",components:3,type:"Float32"}],4),Dy=Gt([{name:"a_projected_pos",components:4,type:"Float32"}],4);Gt([{name:"a_fade_opacity",components:1,type:"Uint32"}],4);const Ly=Gt([{name:"a_auto_z_offset",components:1,type:"Float32"}],4),z_=Gt([{name:"a_feature_index",components:1,type:"Float32"}],4),zy=Gt([{name:"a_x_axis",components:3,type:"Float32"},{name:"a_y_axis",components:3,type:"Float32"}]),Fy=Gt([{name:"a_texb",components:2,type:"Uint16"}]),Oy=Gt([{name:"a_placed",components:2,type:"Uint8"},{name:"a_shift",components:2,type:"Float32"},{name:"a_elevation_from_sea",components:2,type:"Float32"}]),ky=Gt([{name:"a_size_scale",components:1,type:"Float32"},{name:"a_padding",components:2,type:"Float32"},{name:"a_auto_z_offset",components:1,type:"Float32"}]);Gt([{type:"Int16",name:"projectedAnchorX"},{type:"Int16",name:"projectedAnchorY"},{type:"Int16",name:"projectedAnchorZ"},{type:"Int16",name:"tileAnchorX"},{type:"Int16",name:"tileAnchorY"},{type:"Float32",name:"x1"},{type:"Float32",name:"y1"},{type:"Float32",name:"x2"},{type:"Float32",name:"y2"},{type:"Int16",name:"padding"},{type:"Uint32",name:"featureIndex"},{type:"Uint16",name:"sourceLayerIndex"},{type:"Uint16",name:"bucketIndex"}]);const F_=Gt([{name:"a_pos",components:3,type:"Int16"},{name:"a_anchor_pos",components:2,type:"Int16"},{name:"a_extrude",components:2,type:"Int16"}],4),By=Gt([{name:"a_pos_2f",components:2,type:"Float32"},{name:"a_radius",components:1,type:"Float32"},{name:"a_flags",components:2,type:"Int16"}],4);Gt([{name:"triangle",components:3,type:"Uint16"}]),Gt([{type:"Int16",name:"projectedAnchorX"},{type:"Int16",name:"projectedAnchorY"},{type:"Int16",name:"projectedAnchorZ"},{type:"Float32",name:"tileAnchorX"},{type:"Float32",name:"tileAnchorY"},{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:"Uint8",name:"flipState"}]),Gt([{type:"Float32",name:"tileAnchorX"},{type:"Float32",name:"tileAnchorY"},{type:"Int16",name:"projectedAnchorX"},{type:"Int16",name:"projectedAnchorY"},{type:"Int16",name:"projectedAnchorZ"},{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",components:2,name:"textOffset"},{type:"Float32",name:"collisionCircleDiameter"},{type:"Float32",name:"zOffset"},{type:"Uint8",name:"hasIconTextFit"},{type:"Uint16",name:"elevationFeatureIndex"}
7]),Gt([{type:"Float32",name:"offsetX"}]),Gt([{type:"Int16",name:"x"},{type:"Int16",name:"y"}]);const Xa=class Wu{static getBlockIndices(e){let i=Wu._blockIndicesTemplate;if(!i){i=Wu._blockIndicesTemplate=new Uint32Array(e);for(let o=0;o<e;o++)i[o]=o}return i}constructor(e,i,o,a){this.batchIndex=i,this.headerBuffer=null,this.propertiesBuffer=null,this.blockIndicesBuffer=null,this.context=e||null,this.propsDwords=o,this.totalBytes=4*this.propsDwords,this.headerData=a,this.propertiesData=new Float32Array(this.propsDwords),this._headerDirty=!0,this._propsDirtyMin=-1,this._propsDirtyMax=-1,this._blockIndicesDirty=!0,e&&this._initBuffers(e)}_initBuffers(e){const i=e.gl;if(this.totalBytes>e.maxUniformBlockSize)throw new Error(`UBO size ${this.totalBytes} exceeds device limit ${e.maxUniformBlockSize}`);if(this.headerBuffer=i.createBuffer(),!this.headerBuffer)throw new Error("Failed to create header UBO buffer");if(i.bindBuffer(i.UNIFORM_BUFFER,this.headerBuffer),i.bufferData(i.UNIFORM_BUFFER,Wu.HEADER_BYTES,i.DYNAMIC_DRAW),this.propertiesBuffer=i.createBuffer(),!this.propertiesBuffer)throw new Error("Failed to create properties UBO buffer");if(i.bindBuffer(i.UNIFORM_BUFFER,this.propertiesBuffer),i.bufferData(i.UNIFORM_BUFFER,this.totalBytes,i.DYNAMIC_DRAW),this.blockIndicesBuffer=i.createBuffer(),!this.blockIndicesBuffer)throw new Error("Failed to create block-indices UBO buffer");i.bindBuffer(i.UNIFORM_BUFFER,this.blockIndicesBuffer),i.bufferData(i.UNIFORM_BUFFER,this.totalBytes,i.DYNAMIC_DRAW),i.bindBuffer(i.UNIFORM_BUFFER,null)}writeDataDrivenBlock(e,i){const o=this.headerData,a=4*o[2];if(a===0)return;const c=i*a;if(c+a>this.propertiesData.length)throw new Error(`UBO write out of bounds: feature index ${i} exceeds propertiesData capacity`);const h=o[0],f=o[1],_=f>>>16;for(let v=0;v<9;v++)h&1<<v&&this._copyFromFlat(c+o[3+v],v,e,Wu.EVAL_FLAT_OFFSETS[v],f,_);(this._propsDirtyMin===-1||c<this._propsDirtyMin)&&(this._propsDirtyMin=c);const y=c+a;y>this._propsDirtyMax&&(this._propsDirtyMax=y)}rightSizeForTransfer(){const e=this._propsDirtyMax===-1?0:this._propsDirtyMax;e<this.propertiesData.length&&(this.propertiesData=this.propertiesData.slice(0,e))}_copyFromFlat(e,i,o,a,c,h){const f=i<2,_=i===8,y=!!(c&1<<i);if(this.propertiesData.set(o.subarray(a,a+(f||_&&y?4:_||y?2:1)),e),h&1<<i){const v=f||_?4:2,b=Wu.EVAL_FLAT_ZOOM_OFFSETS[i];this.propertiesData[e+v]=o[b],this.propertiesData[e+v+1]=o[b+1]}}upload(e){this.context||(this.context=e);const i=e.gl;this.headerBuffer&&this.propertiesBuffer&&this.blockIndicesBuffer||this._initBuffers(e);let o=!1;if(this._headerDirty&&(i.bindBuffer(i.UNIFORM_BUFFER,this.headerBuffer),i.bufferSubData(i.UNIFORM_BUFFER,0,this.headerData),this._headerDirty=!1,o=!0),this._propsDirtyMin!==-1){const a=this._propsDirtyMin,c=this._propsDirtyMax;i.bindBuffer(i.UNIFORM_BUFFER,this.propertiesBuffer),i.bufferSubData(i.UNIFORM_BUFFER,4*a,this.propertiesData,a,c-a),this._propsDirtyMin=-1,this._propsDirtyMax=-1,o=!0}this._blockIndicesDirty&&(i.bindBuffer(i.UNIFORM_BUFFER,this.blockIndicesBuffer),i.bufferSubData(i.UNIFORM_BUFFER,0,Wu.getBlockIndices(this.propsDwords)),this._blockIndicesDirty=!1,o=!0),o&&i.bindBuffer(i.UNIFORM_BUFFER,null)}bind(e,i){const o=e.gl,a=(h,f,_)=>{if(!f)return;const y=o.getUniformBlockIndex(i,h);y!==o.INVALID_INDEX&&(o.uniformBlockBinding(i,y,_),o.bindBufferBase(o.UNIFORM_BUFFER,_,f))},c=3*this.batchIndex;a("SymbolPaintPropertiesHeaderUniform",this.headerBuffer,c),a("SymbolPaintPropertiesUniform",this.propertiesBuffer,c+1),a("SymbolPaintPropertiesIndexUniform",this.blockIndicesBuffer,c+2)}destroy(){if(this.context){const e=this.context.gl;this.headerBuffer&&(e.deleteBuffer(this.headerBuffer),this.headerBuffer=null),this.propertiesBuffer&&(e.deleteBuffer(this.propertiesBuffer),this.propertiesBuffer=null),this.blockIndicesBuffer&&(e.deleteBuffer(this.blockIndicesBuffer),this.blockIndicesBuffer=null)}}};Xa.HEADER_DWORDS=12,Xa.HEADER_BYTES=48,Xa.EVAL_FLAT_OFFSETS=[0,4,8,10,12,14,16,18,20],Xa.EVAL_FLAT_ZOOM_OFFSETS=[24,26,28,30,32,34,36,38,40],Xa.EVAL_FLAT_TOTAL=42,Xa._blockIndicesTemplate=null;let Ya=Xa;function O_(r,e,i,o,a,c,h,f){return!!r&&(r.kind==="constant"?r.value==="none":r.evaluate({zoom:0,brightness:c,worldview:f},e,i,a,o,h)==="none")}function Rs(r){if(!(r instanceof ns))return!1;const e=r.value;return(e.kind==="source"||e.kind==="composite")&&e.isStateDependent}nt(Ya,"SymbolPropertiesUBO",{omit:["headerBuffer","propertiesBuffer","blockIndicesBuffer"]});const Ol=["icon","text"].map(r=>[`${r}-color`,`${r}-halo-color`,`${r}-opacity`,`${r}-halo-width`,`${r}-halo-blur`,`${r}-emissive-strength`,`${r}-occlusion-opacity`,"symbol-z-offset",`${r}-translate`]),an=new Float32Array(Ya.EVAL_FLAT_TOTAL),_d=[0,0],k_=new WeakMap;class Ka{constructor(e,i,o,a,c="",h,f){this.layer=e,this.zoom=i,this.lut=o,this.isText=a,this.worldview=c,this.maxUniformBufferBindings=h||24,this.uboSizeDwords=f||4096,this.allFeatureVtIndices=[],this.allFeatureIds=[],this.allFormattedSections=[],this.featureVertexRangesFromId=null,this.featureVertexRangesFromVtIndex=null,this.ubos=[],this.featureCount=0,this.cachedConstantUniforms=null,this.cachedConstantRenderZoom=null,this.cachedConstantBrightness=void 0,this.cachedConstantPaint=null,this.activeAppearanceByVtIndex=null,this.sharedZoomRanges=new Float32Array(18),this._zoomRangeScratch=new Float32Array(2),this._floorZoom=Math.floor(this.zoom),this.header=new Uint32Array(Ya.HEADER_DWORDS),this.updateHeader(),this.isAllConstant=this.header[0]===0;const _=4*this.header[2];this.maxFeaturesPerBatch=_===0?Number.MAX_SAFE_INTEGER:Math.floor(this.uboSizeDwords/_)}updateHeader(){const e=this.layer.paint;let i=0,o=0,a=0,c=0,h=0,f=!0;const _=this._floorZoom,y=Ol[+this.isText];for(let b=0;b<9;b++){const T=y[b],E=b<2,C=b===8,P=e.get(T),R=!(!P||typeof P.isConstant!="function"||P.isConstant()),z=this._appearancesHavePaintProperties(T);if(!R&&!z){const X=this._layerUnevaluated(T);X&&X.expression&&X.expression.kind==="camera"&&(c|=1<<b);continue}i|=1<<b;const V=this._collectZoomSignatures(T,_),N=V.hasZoom,U=V.differs;N&&(o|=1<<b),U&&(a|=1<<b);const q=P&&P.value;let W,se;q&&q.isLightConstant===!1&&(f=!1),U?(W=!0,se=E||C?8:4):(W=E||C&&N,se=W?4:C||N?2:1),W&&h%4!=0?h=h+3&-4:C&&h%4==3&&h++,this.header[3+b]=h,h+=se,N&&!U&&V.representative&&this._computeZoomRange(V.representative,_,this.sharedZoomRanges,2*b)}const v=h===0?0:h+3&-4;this.header[0]=i,this.header[1]=o|a<<16,this.header[2]=v/4,this.isLightConstant=f,this.cameraMask=c}_recomputeSharedRanges(){const e=this._floorZoom,i=Ol[+this.isText];let o=0;for(let a=0;a<9;a++){const c=i[a];if(this.header[0]&1<<a){if(this.header[1]&1<<a&&!(this.header[1]>>>16&1<<a)){const h=this._collectZoomSignatures(c,e);h.representative&&this._computeZoomRange(h.representative,e,this.sharedZoomRanges,2*a)}}else{const h=this._layerUnevaluated(c);h&&h.expression&&h.expression.kind==="camera"&&(o|=1<<a)}}this.cameraMask=o}_collectZoomSignatures(e,i){let o=!1,a=!1,c=null,h=0,f=0;const _=y=>{if(!y)return;this._computeZoomRange(y,i,this._zoomRangeScratch,0);const v=this._zoomRangeScratch[0],b=this._zoomRangeScratch[1];o?v===h&&b===f||(a=!0):(o=!0,h=v,f=b,c=y)};_(this._zoomExprOf(this._layerUnevaluated(e)));for(const y of this.layer.getAppearances()||[])y.hasPaintProperty(e)&&_(this._zoomExprOf(y.getUnevaluatedPaintProperty(e)));return{hasZoom:o,differs:a,representative:c}}evaluateAllProperties(e,i,o,a,c,h,f){const _={brightness:c,worldview:this.worldview},y={feature:e,featureState:i,canonical:o,availableImages:a,params:new xt(this.zoom,_),paramsNext:new xt(this.zoom+1,_),formattedSection:h,activeAppearance:f},v=this.header,b=Ol[+this.isText],T=v[1]>>>16;for(let E=0;E<9;E++){const C=b[E],P=E===8,R=!!(v[1]&1<<E),z=!!(T&1<<E),V=Ya.EVAL_FLAT_OFFSETS[E],N=Ya.EVAL_FLAT_ZOOM_OFFSETS[E];E<2?this._evaluateColorValue(C,R,z,N,y,V):P?this._evaluateTranslateValue(C,R,z,N,y,V):this._evaluateFloatValue(C,R,z,N,y,V)}return an}_resolveProp(e,i,o=!1,a){const c=this.layer.paint,h=c.get(e),f=e,_=!(!i||!i.hasPaintProperty(f)),y=_?a&&h&&h.property.overrides&&h.property.overrides.hasOverride(a)?h:i.paintProperties.get(f):c.get(e);if(o||!y||typeof y.isConstant!="function"||!y.isConstant())return y;const v=_?i.getUnevaluatedPaintProperty(f):this._layerUnevaluated(e);return this._unbakeCamera(y,v)}_unbakeCamera(e,i){const o=i&&i.expression;
vendor: 13,403 bytes, line 7
7if(!o||o.kind!=="camera")return e;let a=k_.get(i);return a||(a=new ns(e.property,o,e.parameters,e.iconImageUseTheme),k_.set(i,a)),a}_layerUnevaluated(e){const i=this.layer._transitionablePaint._values[e];return i&&i.value}_zoomExprOf(e){const i=e&&e.expression;return!i||i.kind!=="composite"&&i.kind!=="camera"?null:i}_evalAt(e,i,o){return e.property.evaluate(e.value,i,o.feature,o.featureState,o.canonical,o.availableImages,e.iconImageUseTheme,o.formattedSection)}_evaluateColorValue(e,i,o,a,c,h){const f=this._resolveProp(e,c.activeAppearance,!1,c.formattedSection);if(o&&this._writeZoomRange(f,a),!f)return an[h]=0,an[h+1]=0,an[h+2]=0,void(an[h+3]=1);const _=this._resolveProp(`${e}-use-theme`,c.activeAppearance,!0),y=O_(_&&typeof _!="string"?_.value:void 0,c.feature,c.featureState,c.availableImages,c.canonical,c.params.brightness,c.formattedSection,this.worldview)?null:this.lut,v=(f.isConstant()?f.constantOr(ai.transparent):this._evalAt(f,c.params,c)||ai.transparent).toNonPremultipliedRenderColor(y);if(an[h]=Mc(255*v.r,255*v.g),an[h+1]=Mc(255*v.b,255*v.a),i){const b=(this._evalAt(f,c.paramsNext,c)||ai.transparent).toNonPremultipliedRenderColor(y);an[h+2]=Mc(255*b.r,255*b.g),an[h+3]=Mc(255*b.b,255*b.a)}else an[h+2]=0,an[h+3]=0}_computeZoomRange(e,i,o,a){let c=0,h=1;const f=!e||e.kind!=="composite"&&e.kind!=="camera"?null:e.zoomStops;if(f&&f.length>0)if(e.interpolationType==null){c=h=1;for(const _ of f)if(_>i&&_<i+1){c=h=_-i;break}}else f[0]>i&&f[0]<i+1&&(c=f[0]-i);o[a]=c,o[a+1]=h}_writeZoomRange(e,i){this._computeZoomRange(e&&e.value,this._floorZoom,an,i)}_evaluateFloatValue(e,i,o,a,c,h){const f=e.endsWith("opacity")?1:0,_=this._resolveProp(e,c.activeAppearance);o&&this._writeZoomRange(_,a);const y=_?_.isConstant()?_.constantOr(f):this._evalAt(_,c.params,c):f;if(an[h]=y??f,i){const v=this._evalAt(_,c.paramsNext,c);an[h+1]=v??f}else an[h+1]=0}_evaluateTranslateValue(e,i,o,a,c,h){const f=this._resolveProp(e,c.activeAppearance);o&&this._writeZoomRange(f,a);const _=!!f&&typeof f.isConstant=="function"&&!f.isConstant(),y=f?typeof f.isConstant!="function"?f:_?this._evalAt(f,c.params,c):f.constantOr(_d):void 0;if(an[h]=y?y[0]:0,an[h+1]=y?y[1]:0,i){const v=_?this._evalAt(f,c.paramsNext,c):y;an[h+2]=v?v[0]:0,an[h+3]=v?v[1]:0}else an[h+2]=0,an[h+3]=0}_appearancesHavePaintProperties(e){return this.layer.getAppearances().some(i=>i.hasPaintProperty(e))}hasStateDependentPaint(e){const i=e.paint,o=Ol[+this.isText];for(const a of o)if(Rs(i.get(a)))return!0;for(const a of e.getAppearances()||[])for(const c of o){const h=c;if(a.hasPaintProperty(h)&&Rs(a.paintProperties.get(h)))return!0}return!1}hasPerFeatureTranslate(){return!!(256&this.header[0])}getCurrentBatchIndex(){return this.maxFeaturesPerBatch===0?0:Math.floor(this.featureCount/this.maxFeaturesPerBatch)}_writeFeatureBlock(e,i){const o=this.isAllConstant?0:e;let a=Math.floor(o/this.maxFeaturesPerBatch),c=o%this.maxFeaturesPerBatch;this._batchExceedsDeviceLimit(a)&&(a=0,c=0);const h=this.ubos[a];return!!h&&(h.writeDataDrivenBlock(i,c),!0)}_batchExceedsDeviceLimit(e){return 3*e+2>=this.maxUniformBufferBindings}_reevaluateAt(e,i,o,a,c,h){if(!i)return;const f=this.allFeatureVtIndices[e],_=i.feature(f);if(!_)return;const y=this.allFeatureIds[e],v=y!=null&&c[y]||{},b={type:_.type,id:y,properties:_.properties||{},geometry:[]},T=this.activeAppearanceByVtIndex?this.activeAppearanceByVtIndex.get(f):void 0,E=this.evaluateAllProperties(b,v,o,a,h,(this.allFormattedSections?this.allFormattedSections[e]:void 0)||void 0,T);this._writeFeatureBlock(e,E)}_ensureRangeMaps(){if(!this.featureVertexRangesFromId){this.featureVertexRangesFromId=new Map,this.featureVertexRangesFromVtIndex=new Map;for(let e=0;e<this.allFeatureVtIndices.length;e++){const i=this.allFeatureIds[e];if(i!=null){let c=this.featureVertexRangesFromId.get(i);c||this.featureVertexRangesFromId.set(i,c=[]),c.push(e)}const o=this.allFeatureVtIndices[e];let a=this.featureVertexRangesFromVtIndex.get(o);a||this.featureVertexRangesFromVtIndex.set(o,a=[]),a.push(e)}}}populateUBO(e,i,o,a,c,h){const f=e.id,_=this.header,y=this.evaluateAllProperties(e,{},o,a,c,h);let v,b;this.isAllConstant?(v=0,b=this.featureCount===0,b&&(this.featureCount=1)):(v=this.featureCount++,b=!0);let T=Math.floor(v/this.maxFeaturesPerBatch),E=v%this.maxFeaturesPerBatch;return b&&(this._batchExceedsDeviceLimit(T)?(ht(`Too many symbol features: batch ${T} requires binding points up to ${3*T+2}, device limit ${this.maxUniformBufferBindings}. Some features will render incorrectly.`),T=0,E=0):(this.ubos[T]||(this.ubos[T]=new Ya(null,T,this.uboSizeDwords,_)),this.ubos[T].writeDataDrivenBlock(y,E))),this.allFeatureVtIndices.push(i),this.allFeatureIds.push(f),this.allFormattedSections.push(h||null),E}updateFeatures(e,i,o,a,c,h,f){this.layer=i,this.cachedConstantUniforms=null,this._ensureRangeMaps();for(const _ of e){const y=this.featureVertexRangesFromId.get(_);if(y)for(const v of y)this._reevaluateAt(v,o,a,c,h,f)}}updateDynamicExpressions(e,i,o,a,c,h){if(this.layer=e,this.cachedConstantUniforms=null,this._recomputeSharedRanges(),this.header[0]!==0)for(let f=0;f<this.allFeatureVtIndices.length;f++)this._reevaluateAt(f,i,o,a,c,h)}updateFeaturePaintForAppearance(e,i,o,a,c,h,f){if(!this.layer||(this.activeAppearanceByVtIndex||(this.activeAppearanceByVtIndex=new Map),this.activeAppearanceByVtIndex.set(e,f||null),this.header[0]===0))return!1;this._ensureRangeMaps();const _=this.featureVertexRangesFromVtIndex.get(e);if(!_)return!1;let y=!1;for(const v of _){const b=this.evaluateAllProperties(i,o,a,c,h,(this.allFormattedSections?this.allFormattedSections[v]:void 0)||void 0,f);y=this._writeFeatureBlock(v,b)||y}return y}getConstantUniformValues(e,i){const o=this.header,a=!!this.cameraMask,c=!!o[1];if(this.cachedConstantUniforms&&this.cachedConstantPaint===this.layer.paint&&this.cachedConstantBrightness===i&&(!a&&!c||this.cachedConstantRenderZoom===e))return this.cachedConstantUniforms;const h=this.layer.paint,f=a?new xt(e,{brightness:i,worldview:this.worldview}):null,_={type:1,id:void 0,properties:{},geometry:[]},y=Ol[+this.isText],v=C=>{const P=y[C],R=h.get(P);if(!R)return[0,0,0,1];const z=h.get(`${P}-use-theme`),V=O_(z&&typeof z!="string"?z.value:void 0,_,{},[],void 0,i,void 0,this.worldview)?null:this.lut;return(this.cameraMask&1<<C&&f?R.property.evaluate(R.value,f,_,{},void 0,[])||ai.transparent:R.constantOr(ai.transparent)).toNonPremultipliedRenderColor(V).toArray01()},b=(C,P)=>{const R=h.get(y[C]);if(!R)return P;if(this.cameraMask&1<<C&&f){const z=R.property.evaluate(R.value,f,_,{},void 0,[]);return z??P}return R.constantOr(P)},T=new Float32Array(9);if(c){const C=e-Math.floor(e);for(let P=0;P<9;P++){if(!(o[1]&1<<P))continue;const R=this.sharedZoomRanges[2*P],z=this.sharedZoomRanges[2*P+1];T[P]=R===z?C>=R?1:0:Math.max(0,Math.min(1,(C-R)/(z-R)))}}const E={fill_np_color:v(0),halo_np_color:v(1),opacity:b(2,1),halo_width:b(3,0),halo_blur:b(4,0),emissive_strength:b(5,0),occlusion_opacity:b(6,1),z_offset:b(7,0),zoomFactors:T};return this.cachedConstantUniforms=E,this.cachedConstantRenderZoom=e,this.cachedConstantBrightness=i,this.cachedConstantPaint=this.layer.paint,E}finalize(){for(const e of this.ubos)e.rightSizeForTransfer()}upload(e){for(const i of this.ubos)i.upload(e)}bind(e,i,o=0){this.ubos[o]&&this.ubos[o].bind(e,i)}destroy(){for(const e of this.ubos)e.destroy();this.ubos=[],this.featureVertexRangesFromId=null,this.featureVertexRangesFromVtIndex=null,this.allFeatureVtIndices=[],this.allFeatureIds=[],this.featureCount=0,this.maxFeaturesPerBatch=0}}nt(Ka,"SymbolPropertyBinderUBO",{omit:["layer","cachedConstantUniforms","cachedConstantRenderZoom","cachedConstantBrightness","cachedConstantPaint","activeAppearanceByVtIndex","featureVertexRangesFromId","featureVertexRangesFromVtIndex"]});const Mr=24;function Ny(r,e,i){return r.sections.forEach(o=>{o.text=(function(a,c,h){const f=c.layout.get("text-transform").evaluate(h,{});return f==="uppercase"?a=a.toLocaleUpperCase():f==="lowercase"&&(a=a.toLocaleLowerCase()),Ys.applyArabicShaping&&(a=Ys.applyArabicShaping(a)),a})(o.text,e,i)}),r}const ku={"!":"︕","#":"#",$:"$","%":"%","&":"&","(":"︵",")":"︶","*":"*","+":"+",",":"︐","-":"︲",".":"・","/":"/",":":"︓",";":"︔","<":"︿","=":"=",">":"﹀","?":"︖","@":"@","[":"﹇","\\":"\","]":"﹈","^":"^",_:"︳","`":"`","{":"︷","|":"―","}":"︸","~":"~","¢":"¢","£":"£","¥":"¥","¦":"¦","¬":"¬","¯":" ̄","–":"︲","—":"︱","‘":"﹃","’":"﹄","“":"﹁","”":"﹂","…":"︙","‧":"・","₩":"₩","、":"︑","。":"︒","〈":"︿","〉":"﹀","《":"︽","》":"︾","「":"﹁","」":"﹂","『":"﹃","』":"﹄","【":"︻","】":"︼","〔":"︹","〕":"︺","〖":"︗","〗":"︘","!":"︕","(":"︵",")":"︶",",":"︐","-":"︲",".":"・",":":"︓",";":"︔","<":"︿",">":"﹀","?":"︖","[":"﹇","]":"﹈","_":"︳","{":"︷","|":"―","}":"︸","⦅":"︵","⦆":"︶","。":"︒","「":"﹁","」":"﹂"};function Vy(r){return r==="︶"||r==="﹈"||r==="︸"||r==="﹄"||r==="﹂"||r==="︾"||r==="︼"||r==="︺"||r==="︘"||r==="﹀"||r==="︐"||r==="︓"||r==="︔"||r==="`"||r===" ̄"||r==="︑"||r==="︒"}function Uy(r){return r==="︵"||r==="﹇"||r==="︷"||r==="﹃"||r==="﹁"||r==="︽"||r==="︻"||r==="︹"||r==="︗"||r==="︿"}const gd=4294967296,yd=1/gd,vp=typeof TextDecoder>"u"?null:new TextDecoder("utf-8");class bp{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,i,o=this.length){let a;for(;a=this.nextField(o);)e(a,i,this);return i}readMessage(e,i){return this.readFields(e,i,this.readVarint()+this.pos)}readFixed32(){const e=this.dataView.getUint32(this.pos,!0);return this.pos+=4,e}readSFixed32(){const e=this.dataView.getInt32(this.pos,!0);return this.pos+=4,e}readFixed64(){const e=this.dataView.getUint32(this.pos,!0)+this.dataView.getUint32(this.pos+4,!0)*gd;return this.pos+=8,e}readSFixed64(){const e=this.dataView.getUint32(this.pos,!0)+this.dataView.getInt32(this.pos+4,!0)*gd;return this.pos+=8,e}readFloat(){const e=this.dataView.getFloat32(this.pos,!0);return this.pos+=4,e}readDouble(){const e=this.dataView.getFloat64(this.pos,!0);return this.pos+=8,e}readVarint(e){const i=this.buf,o=i[this.pos++];if(o<128)return o;let a,c=127&o;return a=i[this.pos++],c|=(127&a)<<7,a<128?c:(a=i[this.pos++],c|=(127&a)<<14,a<128?c:(a=i[this.pos++],c|=(127&a)<<21,a<128?c:(a=i[this.pos],c|=(15&a)<<28,(function(h,f,_){const y=_.buf;let v,b;if(b=y[_.pos++],v=(112&b)>>4,b<128||(b=y[_.pos++],v|=(127&b)<<3,b<128)||(b=y[_.pos++],v|=(127&b)<<10,b<128)||(b=y[_.pos++],v|=(127&b)<<17,b<128)||(b=y[_.pos++],v|=(127&b)<<24,b<128)||(b=y[_.pos++],v|=(1&b)<<31,b<128))return s(h,v,f);throw new Error("Expected varint not more than 10 bytes")})(c,e,this))))}readSVarint(){const e=this.readVarint();return e%2==1?(e+1)/-2:e/2}readBoolean(){return!!this.readVarint()}readString(){const e=this.readVarint()+this.pos,i=this.pos;return this.pos=e,e-i>=12&&vp?vp.decode(this.buf.subarray(i,e)):(function(o,a,c){let h="",f=a;for(;f<c;){const _=o[f];let y,v,b,T=null,E=_>239?4:_>223?3:_>191?2:1;if(f+E>c)break;E===1?_<128&&(T=_):E===2?(y=o[f+1],(192&y)==128&&(T=(31&_)<<6|63&y,T<=127&&(T=null))):E===3?(y=o[f+1],v=o[f+2],(192&y)==128&&(192&v)==128&&(T=(15&_)<<12|(63&y)<<6|63&v,(T<=2047||T>=55296&&T<=57343)&&(T=null))):E===4&&(y=o[f+1],v=o[f+2],b=o[f+3],(192&y)==128&&(192&v)==128&&(192&b)==128&&(T=(15&_)<<18|(63&y)<<12|(63&v)<<6|63&b,(T<=65535||T>=1114112)&&(T=null))),T===null?(T=65533,E=1):T>65535&&(T-=65536,h+=String.fromCharCode(T>>>10&1023|55296),T=56320|1023&T),h+=String.fromCharCode(T),f+=E}return h})(this.buf,i,e)}readBytes(){const e=this.readVarint()+this.pos,i=this.buf.subarray(this.pos,e);return this.pos=e,i}readPackedVarint(e=[],i){const o=this.readPackedEnd();for(;this.pos<o;)e.push(this.readVarint(i));return e}readPackedSVarint(e=[]){const i=this.readPackedEnd();for(;this.pos<i;)e.push(this.readSVarint());return e}readPackedBoolean(e=[]){const i=this.readPackedEnd();for(;this.pos<i;)e.push(this.readBoolean());return e}readPackedFloat(e=[]){const i=this.readPackedEnd();for(;this.pos<i;)e.push(this.readFloat());return e}readPackedDouble(e=[]){const i=this.readPackedEnd();for(;this.pos<i;)e.push(this.readDouble());return e}readPackedFixed32(e=[]){const i=this.readPackedEnd();for(;this.pos<i;)e.push(this.readFixed32());return e}readPackedSFixed32(e=[]){const i=this.readPackedEnd();for(;this.pos<i;)e.push(this.readSFixed32());return e}readPackedFixed64(e=[]){const i=this.readPackedEnd();for(;this.pos<i;)e.push(this.readFixed64());return e}readPackedSFixed64(e=[]){const i=this.readPackedEnd();for(;this.pos<i;)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;const i=this.readVarint();return this.type=7&i,this._valueStart=this.pos,i>>>3}skip(e){const i=7&e;if(i===0)for(;this.buf[this.pos++]>127;);else if(i===2)this.pos=this.readVarint()+this.pos;else if(i===5)this.pos+=4;else{if(i!==1)throw new Error(`Unimplemented type: ${i}`);this.pos+=8}}}function s(r,e,i){return i?4294967296*e+(r>>>0):4294967296*(e>>>0)+(r>>>0)}
7function t(r,e,i){const o=e<=16383?1:e<=2097151?2:e<=268435455?3:Math.floor(Math.log(e)/(7*Math.LN2));i.realloc(o),i.buf.copyWithin(r+o,r,i.pos)}function n(r,e){const i=r.length;let o=e.buf,a=e.pos,c=e.length;for(let h=0;h<i;h++){let f=r[h];if(f<0||a+10>c)e.pos=a,e.writeVarint(f),o=e.buf,a=e.pos,c=e.length;else{for(;f>127;)o[a++]=f%128|128,f=Math.floor(f/128);o[a++]=f}}e.pos=a}function l(r,e){for(let i=0;i<r.length;i++)e.writeSVarint(r[i])}function d(r,e){for(let i=0;i<r.length;i++)e.writeFloat(r[i])}function p(r,e){for(let i=0;i<r.length;i++)e.writeDouble(r[i])}function m(r,e){for(let i=0;i<r.length;i++)e.writeBoolean(r[i])}function g(r,e){for(let i=0;i<r.length;i++)e.writeFixed32(r[i])}function x(r,e){for(let i=0;i<r.length;i++)e.writeSFixed32(r[i])}function w(r,e){for(let i=0;i<r.length;i++)e.writeFixed64(r[i])}function S(r,e){for(let i=0;i<r.length;i++)e.writeSFixed64(r[i])}function A(r,e,i){let o;for(;o=r.nextField(e);)o===3?i.glyphs.push(I(r,r.readVarint()+r.pos)):o===4?i.ascender=r.readSVarint():o===5&&(i.descender=r.readSVarint())}function I(r,e){let i,o,a=0,c=0,h=0,f=0,_=0,y=0;for(;o=r.nextField(e);)o===1?a=r.readVarint():o===2?i=r.readBytes():o===3?c=r.readVarint():o===4?h=r.readVarint():o===5?f=r.readSVarint():o===6?_=r.readSVarint():o===7&&(y=r.readVarint());return{id:a,bitmap:new Wa({width:c+6,height:h+6},i),metrics:{width:c,height:h,left:f,top:_,advance:y}}}const M={horizontal:1,vertical:2,horizontalOnly:3};class D{constructor(){this.scale=1,this.fontStack="",this.image=null}static forText(e,i){const o=new D;return o.scale=e||1,o.fontStack=i,o}static forImage(e){const i=new D;return i.image=e,i}}class L{constructor(){this.text="",this.sectionIndex=[],this.sections=[],this.imageSectionID=null}static fromFeature(e,i,o,a=1){const c=new L;for(let h=0;h<e.sections.length;h++){const f=e.sections[h];f.image?c.addImageSection(f,o,a):c.addTextSection(f,i)}return c}length(){return this.text.length}getSection(e){return this.sections[this.sectionIndex[e]]}getSections(){return this.sections}getSectionIndex(e){return this.sectionIndex[e]}getCodePoint(e){return this.text.codePointAt(e)}verticalizePunctuation(e){this.text=(function(i,o){let a="";for(let c=0;c<i.length;c++){const h=i.charCodeAt(c+1)||null,f=i.charCodeAt(c-1)||null;a+=!o&&(h&&No(h)&&!ku[i[c+1]]||f&&No(f)&&!ku[i[c-1]])||!ku[i[c]]?i[c]:ku[i[c]]}return a})(this.text,e)}trim(){let e=0;for(let o=0;o<this.text.length&&B[this.text.charCodeAt(o)];o++)e++;let i=this.text.length;for(let o=this.text.length-1;o>=0&&o>=e&&B[this.text.charCodeAt(o)];o--)i--;this.text=this.text.substring(e,i),this.sectionIndex=this.sectionIndex.slice(e,i)}substring(e,i){const o=new L;return o.text=this.text.substring(e,i),o.sectionIndex=this.sectionIndex.slice(e,i),o.sections=this.sections,o}toString(){return this.text}getMaxScale(){return this.sectionIndex.reduce((e,i)=>Math.max(e,this.sections[i].scale),0)}addTextSection(e,i){this.text+=e.text,this.sections.push(D.forText(e.scale,e.fontStack||i));const o=this.sections.length-1;for(let a=0;a<e.text.length;++a)this.sectionIndex.push(o)}addImageSection(e,i,o=1){const a=e.image?e.image.getPrimary():null;if(!a)return void ht("Can't add FormattedSection with an empty image.");a.scaleSelf(i*o);const c=this.getNextImageSectionCharCode();c?(this.text+=String.fromCodePoint(c),this.sections.push(D.forImage(a)),this.sectionIndex.push(this.sections.length-1)):ht("Reached maximum number of images 6401")}getNextImageSectionCharCode(){return this.imageSectionID?this.imageSectionID>=63743?null:++this.imageSectionID:(this.imageSectionID=57344,this.imageSectionID)}}function k(r,e,i,o,a,c,h,f,_,y,v,b,T,E,C,P=1,R=1){const z=L.fromFeature(r,a,P,R);b===M.vertical&&z.verticalizePunctuation(T);let V=[];const N=(function(X,ie,re,oe,me,xe,we=1){if(!X)return[];const Ce=[],Se=(function(Ie,Pe,Ne,ke,$e,ze,He=1){let Ye=0;for(let st=0;st<Ie.length();st++){const Je=Ie.getSection(st);Ye+=Z(Ie.getCodePoint(st),Je,ke,$e,Pe,ze,He)}return Ye/Math.max(1,Math.ceil(Ye/Ne))})(X,ie,re,oe,me,xe,we),qe=X.text.includes("​");let Me=0;for(let Ie=0;Ie<X.length();Ie++){const Pe=X.getSection(Ie),Ne=X.getCodePoint(Ie);if(B[Ne]||(Me+=Z(Ne,Pe,oe,me,ie,xe,we)),Ie<X.length()-1){const ke=Ah(Ne);($[Ne]||ke||Pe.image)&&Ce.push(ee(Ie+1,Me,Se,Ce,te(Ne,X.getCodePoint(Ie+1),ke&&qe),!1))}}return le(ee(X.length(),Me,Se,Ce,0,!0))})(z,y,c,e,o,E,R),{processBidirectionalText:U,processStyledBidirectionalText:q}=Ys;if(U&&z.sections.length===1){const X=U(z.toString(),N);for(const ie of X){const re=new L;re.text=ie,re.sections=z.sections;for(let oe=0;oe<ie.length;oe++)re.sectionIndex.push(0);V.push(re)}}else if(q){const X=q(z.text,z.sectionIndex,N);for(const ie of X){const re=new L;re.text=ie[0],re.sectionIndex=ie[1],re.sections=z.sections,V.push(re)}}else V=(function(X,ie){const re=[],oe=X.text;let me=0;for(const xe of ie)re.push(X.substring(me,xe)),me=xe;return me<oe.length&&re.push(X.substring(me,oe.length)),re})(z,N);const W=[],se={positionedLines:W,text:z.toString(),top:v[1],bottom:v[1],left:v[0],right:v[0],writingMode:b,iconsInText:!1,verticalizable:!1,hasBaseline:!1};if((function(X,ie,re,oe,me,xe,we,Ce,Se,qe,Me,Ie,Pe=1){let Ne=0,ke=0,$e=0;const ze=Ce==="right"?1:Ce==="left"?0:.5;let He=!1;for(const dt of me){const wt=dt.getSections();for(const Bt of wt){if(Bt.image)continue;const lt=ie[Bt.fontStack];if(lt&&(He=lt.ascender!==void 0&&lt.descender!==void 0,!He))break}if(!He)break}let Ye=0;for(const dt of me){dt.trim();const wt=dt.getMaxScale(),Bt=(wt-1)*Mr,lt={positionedGlyphs:[],lineOffset:0};X.positionedLines[Ye]=lt;const Et=lt.positionedGlyphs;let Rt=0;if(!dt.length()){ke+=xe,++Ye;continue}let ki=0,qt=0;for(let _i=0;_i<dt.length();_i++){const $i=dt.getSection(_i),Ir=dt.getSectionIndex(_i),gi=dt.getCodePoint(_i);let Ri=$i.scale,mr=null,ln=null,hr=null,zt=Mr,yr=0,Tn=Se;Tn===M.vertical&&Mh(gi)&&(Tn=M.horizontal);const Zr=!(Tn===M.horizontal||!Me&&!Ch(gi)||Me&&(B[gi]||Tf(gi)));if($i.image){const Wr=oe.get($i.image.toString());if(!Wr)continue;hr=$i.image,X.iconsInText=X.iconsInText||!0,ln=Wr.paddedRect;const er=Wr.displaySize,Bi=er[0]*Pe,Di=er[1]*Pe;Ri=Ri*Mr/Ie,mr={width:Bi,height:Di,left:0,top:-3,advance:Zr?Di:Bi,localGlyph:!1},yr=He?-mr.height*Ri:wt*Mr-17-Di*Ri,zt=mr.advance;const vr=(Zr?Bi:Di)*Ri-Mr*wt;vr>0&&vr>Rt&&(Rt=vr)}else{const Wr=re[$i.fontStack];if(!Wr)continue;Wr[gi]&&(ln=Wr[gi]);const er=ie[$i.fontStack];if(!er)continue;const Bi=er.glyphs[gi];if(!Bi)continue;if(mr=Bi.metrics,zt=gi!==8203?Mr:0,He){const Di=er.ascender!==void 0?Math.abs(er.ascender):0,vr=er.descender!==void 0?Math.abs(er.descender):0,Rr=(Di+vr)*Ri;ki<Rr&&(ki=Rr,qt=(Di-vr)/2*Ri),yr=-Di*Ri}
vendor: 29,293 bytes, line 7
7else yr=(wt-Ri)*Mr-17}Zr?(X.verticalizable=!0,Et.push({glyph:gi,image:hr,x:Ne,y:ke+yr,vertical:Zr,scale:Ri,localGlyph:mr.localGlyph,fontStack:$i.fontStack,sectionIndex:Ir,metrics:mr,rect:ln}),Ne+=zt*Ri+qe):(Et.push({glyph:gi,image:hr,x:Ne,y:ke+yr,vertical:Zr,scale:Ri,localGlyph:mr.localGlyph,fontStack:$i.fontStack,sectionIndex:Ir,metrics:mr,rect:ln}),Ne+=mr.advance*Ri+qe)}Et.length!==0&&($e=Math.max(Ne-qe,$e),He?Q(Et,ze,Rt,qt,xe*wt/2):Q(Et,ze,Rt,0,xe/2)),Ne=0;const ni=xe*wt+Rt;lt.lineOffset=Math.max(Rt,Bt),ke+=ni,++Ye}const st=ke,{horizontalAlign:Je,verticalAlign:Qe}=K(we);(function(dt,wt,Bt,lt,Et,Rt){const ki=(wt-Bt)*Et,qt=-Rt*lt;for(const ni of dt)for(const _i of ni.positionedGlyphs)_i.x+=ki,_i.y+=qt})(X.positionedLines,ze,Je,Qe,$e,st),X.top+=-Qe*st,X.bottom=X.top+st,X.left+=-Je*$e,X.right=X.left+$e,X.hasBaseline=He})(se,e,i,o,V,h,f,_,b,y,T,C,R),!(function(X){for(const ie of X)if(ie.positionedGlyphs.length!==0)return!1;return!0})(W))return se}const B={9:!0,10:!0,11:!0,12:!0,13:!0,32:!0},$={10:!0,32:!0,38:!0,40:!0,41:!0,43:!0,45:!0,47:!0,173:!0,183:!0,8203:!0,8208:!0,8211:!0,8231:!0};function Z(r,e,i,o,a,c,h=1){if(e.image){const f=o.get(e.image.toString());return f?f.displaySize[0]*h*e.scale*Mr/c+a:0}{const f=i[e.fontStack],_=f&&f.glyphs[r];return _?_.metrics.advance*e.scale+a:0}}function G(r,e,i,o){const a=Math.pow(r-e,2);return o?r<e?a/2:2*a:a+Math.abs(i)*i}function te(r,e,i){let o=0;return r===10&&(o-=1e4),i&&(o+=150),r!==40&&r!==65288||(o+=50),e!==41&&e!==65289||(o+=50),o}function ee(r,e,i,o,a,c){let h=null,f=G(e,i,a,c);for(const _ of o){const y=G(e-_.x,i,a,c)+_.badness;y<=f&&(h=_,f=y)}return{index:r,x:e,priorBreak:h,badness:f}}function le(r){return r?le(r.priorBreak).concat(r.index):[]}function K(r){let e=.5,i=.5;switch(r){case"right":case"top-right":case"bottom-right":e=1;break;case"left":case"top-left":case"bottom-left":e=0}switch(r){case"bottom":case"bottom-right":case"bottom-left":i=1;break;case"top":case"top-right":case"top-left":i=0}return{horizontalAlign:e,verticalAlign:i}}function Q(r,e,i,o,a){if(!(e||i||o||a))return;const c=r.length-1,h=r[c],f=(h.x+h.metrics.advance*h.scale)*e;for(let _=0;_<=c;_++)r[_].x-=f,r[_].y+=i+o+a}function ae(r){return r.imagePrimary!==void 0&&r.top!==void 0&&r.bottom!==void 0&&r.left!==void 0&&r.right!==void 0}function de(r,e,i,o){const{horizontalAlign:a,verticalAlign:c}=K(o),h=i[0]-r.displaySize[0]*a,f=i[1]-r.displaySize[1]*c;return{imagePrimary:r,imageSecondary:e,top:f,bottom:f+r.displaySize[1],left:h,right:h+r.displaySize[0]}}function fe(r,e,i,o,a,c){const h=r.imagePrimary;let f;if(h.content){const R=h.content,z=h.pixelRatio||1;f=[R[0]/z,R[1]/z,h.displaySize[0]-R[2]/z,h.displaySize[1]-R[3]/z]}const _=e.left*c,y=e.right*c;let v,b,T,E;i==="width"||i==="both"?(E=a[0]+_-o[3],b=a[0]+y+o[1]):(E=a[0]+(_+y-h.displaySize[0])/2,b=E+h.displaySize[0]);const C=e.top*c,P=e.bottom*c;return i==="height"||i==="both"?(v=a[1]+C-o[0],T=a[1]+P+o[2]):(v=a[1]+(C+P-h.displaySize[1])/2,T=v+h.displaySize[1]),{imagePrimary:h,imageSecondary:void 0,top:v,right:b,bottom:T,left:E,collisionPadding:f}}function be(r){return!r.imagePrimary.stretchX}function Te(r){return!r.imagePrimary.stretchY}function Ve(r){return{width:r.right-r.left,height:r.bottom-r.top}}const ye=128;function Ae(r,e,i,o){const{expression:a}=e;if(a.kind==="constant")return{kind:"constant",layoutSize:a.evaluate(new xt(r+1,{worldview:i}),void 0,void 0,void 0,o)};if(a.kind==="source")return{kind:"source"};{const{zoomStops:c,interpolationType:h}=a;let f=0;for(;f<c.length&&c[f]<=r;)f++;f=Math.max(0,f-1);let _=f;for(;_<c.length&&c[_]<r+1;)_++;_=Math.min(c.length-1,_);const y=c[f],v=c[_];return a.kind==="composite"?{kind:"composite",minZoom:y,maxZoom:v,interpolationType:h}:{kind:"camera",minZoom:y,maxZoom:v,minSize:a.evaluate(new xt(y,{worldview:i}),void 0,void 0,void 0,o),maxSize:a.evaluate(new xt(v,{worldview:i}),void 0,void 0,void 0,o),interpolationType:h}}}function ge(r,{uSize:e,uSizeT:i},{lowerSize:o,upperSize:a}){return r.kind==="source"?o/ye:r.kind==="composite"?vt(o/ye,a/ye,i):e}function Fe(r,e,i=1){let o=0,a=0;if(r.kind==="constant")a=r.layoutSize*i;else if(r.kind!=="source"){const{interpolationType:c,minZoom:h,maxZoom:f}=r,_=c?Y(Gn.interpolationFactor(c,e,h,f),0,1):0;r.kind==="camera"?a=vt(r.minSize,r.maxSize,_)*i:o=_*i}return{uSizeT:o,uSize:a}}class Re extends Ue{constructor(e,i,o,a,c){super(e,i),this.angle=a,this.z=o,c!==void 0&&(this.segment=c)}clone(){return new Re(this.x,this.y,this.z,this.angle,this.segment)}}function De(r,e,i,o,a){if(e.segment===void 0)return!0;let c=e,h=e.segment+1,f=0;for(;f>-i/2;){if(h--,h<0)return!1;f-=r[h].dist(c),c=r[h]}f+=r[h].dist(r[h+1]),h++;const _=[];let y=0;for(;f<i/2;){const v=r[h],b=r[h+1];if(!b)return!1;let T=r[h-1].angleTo(v)-v.angleTo(b);for(T=Math.abs((T+3*Math.PI)%(2*Math.PI)-Math.PI),_.push({distance:f,angleDelta:T}),y+=T;f-_[0].distance>o;)y-=_.shift().angleDelta;if(y>a)return!1;h++,f+=v.dist(b)}return!0}function Ke(r){let e=0;for(let i=0;i<r.length-1;i++)e+=r[i].dist(r[i+1]);return e}function Be(r,e,i){return r?.6*e*i:0}function Ge(r,e){return Math.max(r?r.right-r.left:0,e?e.right-e.left:0)}function Ze(r,e,i,o,a,c){const h=Be(i,a,c),f=Ge(i,o)*c;let _=0;const y=Ke(r)/2;for(let v=0;v<r.length-1;v++){const b=r[v],T=r[v+1],E=b.dist(T);if(_+E>y){const C=(y-_)/E,P=vt(b.x,T.x,C),R=vt(b.y,T.y,C),z=new Re(P,R,0,T.angleTo(b),v);return!h||De(r,z,f,h,e)?z:void 0}_+=E}}function tt(r,e,i,o,a,c,h,f,_){const y=Be(o,c,h),v=Ge(o,a),b=v*h,T=r[0].x===0||r[0].x===_||r[0].y===0||r[0].y===_;return e-b<e/4&&(e=b+e/4),ot(r,T?e/2*f%e:(v/2+2*c)*h*f%e,e,y,i,b,T,!1,_)}function ot(r,e,i,o,a,c,h,f,_){const y=c/2,v=Ke(r);let b=0,T=e-i,E=[];for(let C=0;C<r.length-1;C++){const P=r[C],R=r[C+1],z=P.dist(R),V=R.angleTo(P);for(;T+i<b+z;){T+=i;const N=(T-b)/z,U=vt(P.x,R.x,N),q=vt(P.y,R.y,N);if(U>=0&&U<_&&q>=0&&q<_&&T-y>=0&&T+y<=v){const W=new Re(U,q,0,V,C);o&&!De(r,W,c,o,a)||E.push(W)}}b+=z}return f||E.length||h||(E=ot(r,b/2,i,o,a,c,h,!0,_)),E}function at(r){let e=0,i=0;for(const h of r)e+=h.w*h.h,i=Math.max(i,h.w);r.sort((h,f)=>f.h-h.h);const o=[{x:0,y:0,w:Math.max(Math.ceil(Math.sqrt(e/.95)),i),h:1/0}];let a=0,c=0;for(const h of r)for(let f=o.length-1;f>=0;f--){const _=o[f];if(!(h.w>_.w||h.h>_.h)){if(h.x=_.x,h.y=_.y,c=Math.max(c,h.y+h.h),a=Math.max(a,h.x+h.w),h.w===_.w&&h.h===_.h){const y=o.pop();y&&f<o.length&&(o[f]=y)}else h.h===_.h?(_.x+=h.w,_.w-=h.w):h.w===_.w?(_.y+=h.h,_.h-=h.h):(o.push({x:_.x+h.w,y:_.y,w:_.w-h.w,h:h.h}),_.y+=h.h,_.h-=h.h);break}}return{w:a,h:c,fill:e/(a*c)||0}}function ut(r,e){return r.id<e.id?-1:r.id>e.id?1:r.version<e.version?-1:r.version>e.version?1:r.sx<e.sx?-1:r.sx>e.sx?1:r.sy<e.sy?-1:r.sy>e.sy?1:0}function bt(r){let e=0;for(let i=0;i<r.length;i++)e=(e<<5)-e+r.charCodeAt(i),e&=e;return e}function pt(r,e){return(r<<5)-r+e}function Lt(r,e,i,o){for(const[a]of r.entries()){const c=o&&o.get(a)||Fo.parse(a),h=c.id.toString(),f=e.get(h)||0;i.push({id:a,version:f,sx:c.sx,sy:c.sy})}}nt(Re,"Anchor");class kt{constructor(e,i,o,a,c="",h){this.scope=c,this.iconDescriptors=[],this.patternDescriptors=[],this.requiresMipMaps=i.size>0,Lt(e,o,this.iconDescriptors,h),Lt(i,o,this.patternDescriptors,h),this.iconDescriptors.sort(ut),this.patternDescriptors.sort(ut);let f=0;f=pt(f,bt(c)),f=pt(f,1);const _=a?a.data:"";_&&(f=pt(f,bt(_))),f=pt(f,1);for(const y of this.iconDescriptors)f=pt(f,bt(y.id)),f=pt(f,y.version),f=pt(f,y.sx),f=pt(f,y.sy);f=pt(f,1);for(const y of this.patternDescriptors)f=pt(f,bt(y.id)),f=pt(f,y.version),f=pt(f,y.sx),f=pt(f,y.sy);this.hash=f}subsetOf(e){return this.scope===e.scope&&this.isSubsetArray(this.iconDescriptors,e.iconDescriptors,ut)&&this.isSubsetArray(this.patternDescriptors,e.patternDescriptors,ut)}isSubsetArray(e,i,o){let a=0,c=0;if(e.length>i.length)return!1;for(;a<e.length&&c<i.length;){const h=o(e[a],i[c]);if(h===0)a++,c++;else{if(h<0)return!1;c++}}return a===e.length}}function gt(r){switch(r){case WebGL2RenderingContext.RGBA8:case WebGL2RenderingContext.RGBA16F:return WebGL2RenderingContext.RGBA;case WebGL2RenderingContext.DEPTH_COMPONENT16:return WebGL2RenderingContext.DEPTH_COMPONENT;case WebGL2RenderingContext.DEPTH24_STENCIL8:return WebGL2RenderingContext.DEPTH_STENCIL;case WebGL2RenderingContext.R8:case WebGL2RenderingContext.R32F:return WebGL2RenderingContext.RED}}function Pt(r){switch(r){case WebGL2RenderingContext.RGBA8:return WebGL2RenderingContext.UNSIGNED_BYTE;case WebGL2RenderingContext.RGBA16F:return WebGL2RenderingContext.HALF_FLOAT;case WebGL2RenderingContext.DEPTH_COMPONENT16:return WebGL2RenderingContext.UNSIGNED_SHORT;case WebGL2RenderingContext.DEPTH24_STENCIL8:return WebGL2RenderingContext.UNSIGNED_INT_24_8;case WebGL2RenderingContext.R8:return WebGL2RenderingContext.UNSIGNED_BYTE;case WebGL2RenderingContext.R32F:return WebGL2RenderingContext.FLOAT}}nt(kt,"AtlasContentDescriptor");class Ct{constructor(e,i,o,a){this.context=e,this.format=o,this.useMipmap=a&&a.useMipmap,this.texture=e.gl.createTexture(),this.update(i,{premultiply:a&&a.premultiply})}update(e,i){const o=e&&e instanceof HTMLVideoElement&&e.width===0?e.videoWidth:e.width,a=e&&e instanceof HTMLVideoElement&&e.height===0?e.videoHeight:e.height,{context:c}=this,{gl:h}=c,{x:f,y:_}=i&&i.position?i.position:{x:0,y:0},y=f+o,v=_+a;this.size&&(this.size[0]!==y||this.size[1]!==v)&&(!i||i.recreateWhenResize===void 0||i.recreateWhenResize)&&(h.bindTexture(h.TEXTURE_2D,null),h.deleteTexture(this.texture),this.texture=h.createTexture(),this.size=null),h.bindTexture(h.TEXTURE_2D,this.texture),c.pixelStoreUnpackFlipY.set(!1),c.pixelStoreUnpack.set(1),c.pixelStoreUnpackPremultiplyAlpha.set(this.format===h.RGBA8&&(!i||i.premultiply!==!1));const b=e instanceof HTMLImageElement||e instanceof HTMLCanvasElement||e instanceof HTMLVideoElement||e instanceof ImageData||ImageBitmap&&e instanceof ImageBitmap;if(!this.size&&y>0&&v>0){const T=this.useMipmap?Math.floor(Math.log2(Math.max(y,v)))+1:1;h.texStorage2D(h.TEXTURE_2D,T,this.format,y,v),this.size=[y,v]}this.size&&(b?h.texSubImage2D(h.TEXTURE_2D,0,f,_,gt(this.format),Pt(this.format),e):"data"in e&&e.data&&h.texSubImage2D(h.TEXTURE_2D,0,f,_,o,a,gt(this.format),Pt(this.format),e.data)),this.useMipmap&&h.generateMipmap(h.TEXTURE_2D)}bind(e,i,o=!1){const{context:a}=this,{gl:c}=a;c.bindTexture(c.TEXTURE_2D,this.texture),e!==this.minFilter&&(c.texParameteri(c.TEXTURE_2D,c.TEXTURE_MAG_FILTER,e),c.texParameteri(c.TEXTURE_2D,c.TEXTURE_MIN_FILTER,this.useMipmap&&!o?e===c.NEAREST?c.NEAREST_MIPMAP_NEAREST:c.LINEAR_MIPMAP_LINEAR:e),this.minFilter=e),i!==this.wrapS&&(c.texParameteri(c.TEXTURE_2D,c.TEXTURE_WRAP_S,i),c.texParameteri(c.TEXTURE_2D,c.TEXTURE_WRAP_T,i),this.wrapS=i)}bindExtraParam(e,i,o,a,c){const{context:h}=this,{gl:f}=h;f.bindTexture(f.TEXTURE_2D,this.texture),i!==this.magFilter&&(f.texParameteri(f.TEXTURE_2D,f.TEXTURE_MAG_FILTER,i),this.magFilter=i),e!==this.minFilter&&(f.texParameteri(f.TEXTURE_2D,f.TEXTURE_MIN_FILTER,this.useMipmap?e===f.NEAREST?f.NEAREST_MIPMAP_NEAREST:f.LINEAR_MIPMAP_LINEAR:e),this.minFilter=e),o!==this.wrapS&&(f.texParameteri(f.TEXTURE_2D,f.TEXTURE_WRAP_S,o),this.wrapS=o),a!==this.wrapT&&(f.texParameteri(f.TEXTURE_2D,f.TEXTURE_WRAP_T,a),this.wrapT=a),c!==this.compareMode&&(c?(f.texParameteri(f.TEXTURE_2D,f.TEXTURE_COMPARE_MODE,f.COMPARE_REF_TO_TEXTURE),f.texParameteri(f.TEXTURE_2D,f.TEXTURE_COMPARE_FUNC,c)):f.texParameteri(f.TEXTURE_2D,f.TEXTURE_COMPARE_MODE,f.NONE),this.compareMode=c)}destroy(){const{gl:e}=this.context;e.deleteTexture(this.texture),this.texture=null}}class Ut{static getImagePositionScale(e,i,o){if(i&&e){const{sx:a,sy:c}=e;return{x:a,y:c}}return{x:o,y:o}}constructor(e,i,o,a){this.paddedRect=e;const{pixelRatio:c,version:h,stretchX:f,stretchY:_,content:y,sdf:v,usvg:b}=i;this.pixelRatio=c,this.stretchX=f,this.stretchY=_,this.content=y,this.version=h,this.padding=o,this.sdf=v,this.usvg=b,this.scale=Ut.getImagePositionScale(a,b,c)}get tl(){return[this.paddedRect.x+this.padding,this.paddedRect.y+this.padding]}get br(){return[this.paddedRect.x+this.paddedRect.w-this.padding,this.paddedRect.y+this.paddedRect.h-this.padding]}get displaySize(){return[(this.paddedRect.w-2*this.padding)/this.scale.x,(this.paddedRect.h-2*this.padding)/this.scale.y]}}function oi(r,e,i){const o=Fo.parse(r),a=(function(c,h,f=[1,1]){return{x:0,y:0,w:(c.data?c.data.width:c.width*f[0])+2*h,h:(c.data?c.data.height:c.height*f[1])+2*h}})(e,i,[o.sx,o.sy]);return{bin:a,imagePosition:new Ut(a,e,i,o),imageVariant:o}}function Ci(r,e){const i=[];for(const[a,c]of r.entries()){const h=Fo.parse(a);h&&(i.push({key:a,value:c,variant:h}),e&&e.set(a,h))}i.sort((a,c)=>{const h=a.variant.id.toString().localeCompare(c.variant.id.toString());return h!==0?h:a.variant.sx!==c.variant.sx?a.variant.sx-c.variant.sx:a.variant.sy!==c.variant.sy?a.variant.sy-c.variant.sy:a.key.localeCompare(c.key)});const o=new Map;for(const a of i)o.set(a.key,a.value);return o}class hi{constructor(e){this.sourceAtlasHash=e}}class Kt{constructor(e,i,o,a,c=""){const h=new Map,f=new Map;this.haveRenderCallbacks=[];const _=[],y=a!==void 0,v=y?new Map:void 0,b=y?Ci(e,v):e,T=y?Ci(i,v):i;this.addImages(b,h,1,_),this.addImages(T,f,2,_);const{w:E,h:C}=at(_),P=new bn({width:E||1,height:C||1});for(const[R,z]of b.entries()){const V=h.get(R).paddedRect;bn.copy(z.data,P,{x:0,y:0},{x:V.x+1,y:V.y+1},z.data,null,z.sdf)}for(const[R,z]of T.entries()){const V=f.get(R),N=V.paddedRect;let U=V.padding;const q=N.x+U,W=N.y+U,se=z.data.width,X=z.data.height;U=U>1?U-1:U,bn.copy(z.data,P,{x:0,y:0},{x:q,y:W},z.data,o),bn.copy(z.data,P,{x:0,y:X-U},{x:q,y:W-U},{width:se,height:U},o),bn.copy(z.data,P,{x:0,y:0},{x:q,y:W+X},{width:se,height:U},o),bn.copy(z.data,P,{x:se-U,y:0},{x:q-U,y:W},{width:U,height:X},o),bn.copy(z.data,P,{x:0,y:0},{x:q+se,y:W},{width:U,height:X},o),bn.copy(z.data,P,{x:se-U,y:X-U},{x:q-U,y:W-U},{width:U,height:U},o),bn.copy(z.data,P,{x:0,y:X-U},{x:q+se,y:W-U},{width:U,height:U},o),bn.copy(z.data,P,{x:0,y:0},{x:q+se,y:W+X},{width:U,height:U},o),bn.copy(z.data,P,{x:se-U,y:0},{x:q-U,y:W+X},{width:U,height:U},o)}this.lut=o,this.image=P,this.iconPositions=h,this.patternPositions=f,y&&(this.contentDescriptor=new kt(b,T,a,o,c,v))}addImages(e,i,o,a){for(const[c,h]of e.entries()){const{bin:f,imagePosition:_,imageVariant:y}=oi(c,h,o);i.set(c,_),a.push(f),h.hasRenderCallback&&this.haveRenderCallbacks.push(y.id)}}patchUpdatedImages(e,i,o,a){this.haveRenderCallbacks=this.haveRenderCallbacks.filter(c=>e.hasImage(c,o)),e.dispatchRenderCallbacks(this.haveRenderCallbacks,o);for(const c of e.getUpdatedImages(o)){for(const h of this.iconPositions.keys()){const f=Fo.parse(h);if(po.isEqual(f.id,c)){const _=e.getImage(c,o);this.patchUpdatedImage(this.iconPositions.get(h),_,i,null)}}for(const h of this.patternPositions.keys()){const f=Fo.parse(h);if(po.isEqual(f.id,c)){const _=e.getImage(c,o);this.patchUpdatedImage(this.patternPositions.get(h),_,i,a||this.lut)}}}}patchUpdatedImage(e,i,o,a=null){if(!e||!i||e.version===i.version)return;e.version=i.version;const[c,h]=e.tl,f=e.sdf;if(this.lut||f){const _={width:i.data.width,height:i.data.height},y=new bn(_);bn.copy(i.data,y,{x:0,y:0},{x:0,y:0},_,a,f),o.update(y,{position:{x:c,y:h},recreateWhenResize:!1})}else o.update(i.data,{position:{x:c,y:h},recreateWhenResize:!1})}}nt(Ut,"ImagePosition"),nt(Kt,"ImageAtlas",{omit:["lut"]}),nt(hi,"ImageAtlasReference");class Ei{constructor(e){this.pendingRequests=new Map,this.cachedRanges=new Map,this.fontstackCompositing=e&&e.fontstackCompositing||"client"}loadGlyphRange(e,i,o,a,c){if(this.fontstackCompositing==="server")return void Ei.loadGlyphRange(e,i,o,a,c);const h=e.split(",").map(f=>f.trim()).filter(f=>f.length>0);h.length!==0?h.length!==1?this._loadMultipleFonts(h,i,o,a,c):this._loadFont(h[0],i,o,a,c):c(new Error("Empty fontstack"))}_loadMultipleFonts(e,i,o,a,c){const h=e.map(()=>null),f={completed:0,firstError:null,callbackCalled:!1},_=(y,v,b)=>{if(!f.callbackCalled&&(v&&!f.firstError&&(f.firstError=v),b&&(h[y]=b),f.completed++,f.completed===e.length)){f.callbackCalled=!0;const T=h.filter(C=>C!==null);if(T.length===0)return void c(f.firstError||new Error("All fonts failed to load"));const E=this._composeGlyphs(T);c(null,E)}};for(let y=0;y<e.length;y++)this._loadFont(e[y],i,o,a,(v,b)=>{_(y,v,b)})}_loadFont(e,i,o,a,c){const h=`${e}:${i}`;if(this.cachedRanges.has(h)){const _=this.cachedRanges.get(h);return void _r.frame(()=>c(null,_))}const f=this.pendingRequests.get(h);f?f.push(c):(this.pendingRequests.set(h,[c]),Ei.loadGlyphRange(e,i,o,a,(_,y)=>{_||this.cachedRanges.set(h,y||null);const v=this.pendingRequests.get(h);if(this.pendingRequests.delete(h),v)for(const b of v)b(_,y)}))}_composeGlyphs(e){const i={};let o,a;for(const c of e)if(o===void 0&&c.ascender!==void 0&&(o=c.ascender),a===void 0&&c.descender!==void 0&&(a=c.descender),c.glyphs)for(const h in c.glyphs)i[h]===void 0&&(i[h]=c.glyphs[h]);return{glyphs:i,ascender:o,descender:a}}}Ei.loadGlyphRange=async function(r,e,i,o,a){const c=256*e,h=c+255;let f;try{const _=await o.transformRequest(o.normalizeGlyphsURL(i).replace("{fontstack}",r).replace("{range}",`${c}-${h}`),ul.Glyphs),{data:y}=await Yl(_),v={},b=(function(T){return(function(E){const C={glyphs:[]};let P;for(;P=E.nextField();)P===1&&A(E,E.readVarint()+E.pos,C);return C})(new bp(T))})(y);for(const T of b.glyphs)v[T.id]=T;f={glyphs:v,ascender:b.ascender,descender:b.descender}}catch(_){return a(_)}a(null,f)};const mi=1e20,Qi=new Float64Array(256);for(let r=0;r<256;r++){const e=.5-Math.pow(r/255,.45454545454545453);Qi[r]=e*Math.abs(e)}function Ot(r,e,i,o,a,c,h,f,_){for(let y=e;y<e+o;y++)$t(r,i*c+y,c,a,h,f,_);for(let y=i;y<i+a;y++)$t(r,y*c+e,1,o,h,f,_)}function $t(r,e,i,o,a,c,h){c[0]=0,h[0]=-mi,h[1]=mi,a[0]=r[e];for(let f=1,_=0,y=0;f<o;f++){a[f]=r[e+f*i];const v=f*f;do{const b=c[_];y=(a[f]-a[b]+v-b*b)/(f-b)/2}while(y<=h[_]&&--_>-1);_++,c[_]=f,h[_]=y,h[_+1]=mi}for(let f=0,_=0;f<o;f++){for(;h[_+1]<f;)_++;const y=c[_],v=f-y;r[e+f*i]=a[y]+v*v}}Qi[255]=-mi;const Mt=/bold/i,Ii=/medium/i,wi=/light/i,sr={none:0,ideographs:1,all:2};class Wi{constructor(e,i,o,a){this.requestManager=e,this.localGlyphMode=i,this.localFontFamily=o,this.url="",this.entries={},this.localGlyphs={200:{},400:{},500:{},900:{}},this.glyphLoader=new Ei({fontstackCompositing:a})}setURL(e){this.url=e}prefetchRange(e,i){const o=this.url||bi.GLYPHS_URL;if(!o)return;let a=this.entries[e];a||(a=this.entries[e]={glyphs:{},requests:{},ranges:{}}),a.ranges[i]||a.requests[i]||(a.requests[i]=[],this.glyphLoader.loadGlyphRange(e,i,o,this.requestManager,(c,h)=>{if(h){a.ascender=h.ascender,a.descender=h.descender;for(const f in h.glyphs)this._doesCharSupportLocalGlyph(+f)||(a.glyphs[+f]=h.glyphs[+f]);a.ranges[i]=!0}for(const f of a.requests[i]||[])f(c,h);delete a.requests[i]}))}getGlyphs(e,i){const o=[],a=this.url||bi.GLYPHS_URL;for(const c in e)for(const h of e[c])o.push({stack:c,id:h});ue(o,({stack:c,id:h},f)=>{let _=this.entries[c];_||(_=this.entries[c]={glyphs:{},requests:{},ranges:{},ascender:void 0,descender:void 0});let y=_.glyphs[h];if(y!==void 0)return void f(null,{stack:c,id:h,glyph:y});if(y=this._tinySDF(_,c,h),y)return _.glyphs[h]=y,void f(null,{stack:c,id:h,glyph:y});const v=Math.floor(h/256);if(256*v>65535)return ht("glyphs > 65535 not supported"),void f(null,{stack:c,id:h,glyph:y});if(_.ranges[v])return void f(null,{stack:c,id:h,glyph:y});let b=_.requests[v];b||(b=_.requests[v]=[],this.glyphLoader.loadGlyphRange(c,v,a,this.requestManager,(T,E)=>{if(E){_.ascender=E.ascender,_.descender=E.descender;for(const C in E.glyphs)this._doesCharSupportLocalGlyph(+C)||(_.glyphs[+C]=E.glyphs[+C]);_.ranges[v]=!0}for(const C of b)C(T,E);delete _.requests[v]})),b.push((T,E)=>{T?f(T):E&&f(null,{stack:c,id:h,glyph:E.glyphs[h]||null})})},(c,h)=>{if(c)i(c);else if(h){const f={};for(const{stack:_,id:y,glyph:v}of h)f[_]===void 0&&(f[_]={}),f[_].glyphs===void 0&&(f[_].glyphs={}),f[_].glyphs[y]=v&&{id:v.id,bitmap:v.bitmap.clone(),metrics:v.metrics},f[_].ascender=this.entries[_].ascender,f[_].descender=this.entries[_].descender;i(null,f)}})}_doesCharSupportLocalGlyph(e){return this.localGlyphMode!==sr.none&&(this.localGlyphMode===sr.all?!!this.localFontFamily:!!this.localFontFamily&&(Eh(e)||bf(e)||uu(e)||wl(e)||bc(e)||vf(e)||(i=e)>=131072&&i<=173791||(o=>o>=66736&&o<=66815)(e)));var i}_tinySDF(e,i,o){const a=this.localFontFamily;if(!a||!this._doesCharSupportLocalGlyph(o))return;let c=e.tinySDF;if(!c){let R="400";Mt.test(i)?R="900":Ii.test(i)?R="500":wi.test(i)&&(R="200"),c=e.tinySDF=new Wi.TinySDF({fontFamily:a,fontWeight:R,fontSize:48,buffer:6,radius:16}),c.fontWeight=R}const h=c.fontWeight;if(this.localGlyphs[h][o])return this.localGlyphs[h][o];const f=String.fromCodePoint(o),{data:_,width:y,height:v,glyphWidth:b,glyphHeight:T,glyphLeft:E,glyphTop:C,glyphAdvance:P}=c.draw(f);return this.localGlyphs[h][o]={id:o,bitmap:new Wa({width:y,height:v},_),metrics:{width:b/2,height:T/2,left:E/2,top:C/2-27,advance:P/2,localGlyph:!0}}}}function Pr(r,e){return r+e[1]-e[0]}function kr(r,e,i,o,a=1){const c=[],h=r.imagePrimary,f=h.pixelRatio,_=h.paddedRect.w-2,y=h.paddedRect.h-2,v=(r.right-r.left)*a,b=(r.bottom-r.top)*a,T=h.stretchX||[[0,_]],E=h.stretchY||[[0,y]],C=T.reduce(Pr,0),P=E.reduce(Pr,0),R=_-C,z=y-P;let V=0,N=C,U=0,q=P,W=0,se=R,X=0,ie=z;if(h.content&&o){const oe=h.content;V=qr(T,0,oe[0]),U=qr(E,0,oe[1]),N=qr(T,oe[0],oe[2]),q=qr(E,oe[1],oe[3]),W=oe[0]-V,X=oe[1]-U,se=oe[2]-oe[0]-N,ie=oe[3]-oe[1]-q}const re=(oe,me,xe,we)=>{const Ce=Ui(oe.stretch-V,N,v,r.left*a),Se=Oi(oe.fixed-W,se,oe.stretch,C),qe=Ui(me.stretch-U,q,b,r.top*a),Me=Oi(me.fixed-X,ie,me.stretch,P),Ie=Ui(xe.stretch-V,N,v,r.left*a),Pe=Oi(xe.fixed-W,se,xe.stretch,C),Ne=Ui(we.stretch-U,q,b,r.top*a),ke=Oi(we.fixed-X,ie,we.stretch,P),$e=new Ue(Ce,qe),ze=new Ue(Ie,qe),He=new Ue(Ie,Ne),Ye=new Ue(Ce,Ne),st=new Ue(Se/f,Me/f),Je=new Ue(Pe/f,ke/f),Qe=e*Math.PI/180;if(Qe){const Rt=Math.sin(Qe),ki=Math.cos(Qe),qt=[ki,-Rt,Rt,ki];$e._matMult(qt),ze._matMult(qt),Ye._matMult(qt),He._matMult(qt)}const dt=oe.stretch+oe.fixed,wt=xe.stretch+xe.fixed,Bt=me.stretch+me.fixed,lt=we.stretch+we.fixed,Et=r.imageSecondary;return{tl:$e,tr:ze,bl:Ye,br:He,texPrimary:{x:h.paddedRect.x+1+dt,y:h.paddedRect.y+1+Bt,w:wt-dt,h:lt-Bt},texSecondary:Et?{x:Et.paddedRect.x+1+dt,y:Et.paddedRect.y+1+Bt,w:wt-dt,h:lt-Bt}:void 0,writingMode:void 0,glyphOffset:[0,0],sectionIndex:0,pixelOffsetTL:st,pixelOffsetBR:Je,minFontScaleX:se/f/v,minFontScaleY:ie/f/b,isSDF:i}};if(h.stretchX||h.stretchY){const oe=ti(T,R,C),me=ti(E,z,P);for(let xe=0;xe<oe.length-1;xe++){const we=oe[xe],Ce=oe[xe+1];for(let Se=0;Se<me.length-1;Se++)c.push(re(we,me[Se],Ce,me[Se+1]))}}else c.push(re({fixed:0,stretch:-1},{fixed:0,stretch:-1},{fixed:0,stretch:_+1},{fixed:0,stretch:y+1}));return c}function En(r,e){const i=r.stretchY||[[0,r.paddedRect.h-2]];return r.stretchX||r.stretchY?ar(r.stretchX||[[0,r.paddedRect.w-2]])*ar(i):1}function qr(r,e,i){let o=0;for(const a of r)o+=Math.max(e,Math.min(i,a[1]))-Math.max(e,Math.min(i,a[0]));return o}function ti(r,e,i){const o=[{fixed:-1,stretch:0}];for(const[a,c]of r){const h=o.at(-1);o.push({fixed:a-h.stretch,stretch:h.stretch}),o.push({fixed:a-h.stretch,stretch:h.stretch+(c-a)})}return o.push({fixed:e+1,stretch:i}),o}function ar(r){return 2*r.length+1}function Ui(r,e,i,o){return r/e*i+o}function Oi(r,e,i,o){return r-e*i/o}function ii(r,e,i,o){const a=e+r.positionedLines[o].lineOffset;return o===0?i+a/2:i+(a+(e+r.positionedLines[o-1].lineOffset))/2}function di(r,e,i,o,a,c,h,f,_,y=1){const v=[];if(e.positionedLines.length===0)return v;const b=(_!==void 0?_:o.layout.get("text-rotate").evaluate(c,{}))*Math.PI/180,T=(function(z){const V=z[0],N=z[1],U=V*N;return U>0?[V,-N]:U<0?[-V,N]:V===0?[N,V]:[N,-V]})(i);let E=Math.abs(e.top-e.bottom);for(const z of e.positionedLines)E-=z.lineOffset;const C=e.positionedLines.length,P=E/C;let R=e.top-i[1];for(let z=0;z<C;++z){const V=e.positionedLines[z];R=ii(e,P,R,z);for(const N of V.positionedGlyphs){if(!N.rect)continue;const U=N.rect||{};let q=4,W=!0,se=1,X=0;if(N.image){const He=h.get(N.image.toString());if(!He)continue;if(He.sdf){ht("SDF images are not supported in formatted text and will be ignored.");continue}W=!1,se=He.pixelRatio,q=1/se,He.usvg||(se/=y)}const ie=(a||f)&&N.vertical,re=N.metrics.advance*N.scale/2,oe=N.metrics,me=N.rect;if(me===null)continue;f&&e.verticalizable&&(X=N.image?re-N.metrics.width*N.scale/2:0);const xe=a?[N.x+re,N.y]:[0,0];let we=[0,0],Ce=[0,0],Se=!1;a||(ie?(Ce=[N.x+re+T[0],N.y+T[1]-X],Se=!0):we=[N.x+re+i[0],N.y+i[1]-X]);const qe=me.w*N.scale/(se*(N.localGlyph?2:1)),Me=me.h*N.scale/(se*(N.localGlyph?2:1));let Ie,Pe,Ne,ke;if(ie){const He=N.y-R,Ye=new Ue(-re,re-He),st=-Math.PI/2,Je=new Ue(...Ce);Ie=new Ue(-re+we[0],we[1]),Ie._rotateAround(st,Ye)._add(Je),Ie.x+=-He+re,Ie.y-=(oe.left-q)*N.scale;const Qe=N.image?oe.advance*N.scale:Mr*N.scale,dt=String.fromCodePoint(N.glyph);Vy(dt)?Ie.x+=(1-q)*N.scale:Uy(dt)?Ie.x+=Qe-oe.height*N.scale+(-q-1)*N.scale:Ie.x+=N.image||oe.width+2*q===me.w&&oe.height+2*q===me.h?(Qe-Me)/2:(Qe-(oe.height+2*q)*N.scale)/2,Pe=new Ue(Ie.x,Ie.y-qe),Ne=new Ue(Ie.x+Me,Ie.y),ke=new Ue(Ie.x+Me,Ie.y-qe)}else{const He=(oe.left-q)*N.scale-re+we[0],Ye=(-oe.top-q)*N.scale+we[1],st=He+qe,Je=Ye+Me;Ie=new Ue(He,Ye),Pe=new Ue(st,Ye),Ne=new Ue(He,Je),ke=new Ue(st,Je)}if(b){let He;He=a?new Ue(0,0):Se?new Ue(T[0],T[1]):new Ue(i[0],i[1]),Ie._rotateAround(b,He),Pe._rotateAround(b,He),Ne._rotateAround(b,He),ke._rotateAround(b,He)}const $e=new Ue(0,0),ze=new Ue(0,0);v.push({tl:Ie,tr:Pe,bl:Ne,br:ke,texPrimary:U,texSecondary:void 0,writingMode:e.writingMode,glyphOffset:xe,sectionIndex:N.sectionIndex,isSDF:W,pixelOffsetTL:$e,pixelOffsetBR:ze,minFontScaleX:0,minFontScaleY:0})}}return v}function si(r,e=1,i=!1){let o=1/0,a=1/0,c=-1/0,h=-1/0;const f=r[0];for(let E=0;E<f.length;E++){const C=f[E];(!E||C.x<o)&&(o=C.x),(!E||C.y<a)&&(a=C.y),(!E||C.x>c)&&(c=C.x),(!E||C.y>h)&&(h=C.y)}const _=Math.min(c-o,h-a);let y=_/2;const v=new sc([],Ai);if(_===0)return new Ue(o,a);for(let E=o;E<c;E+=_)for(let C=a;C<h;C+=_)v.push(new pr(E+y,C+y,y,r));let b=(function(E){let C=0,P=0,R=0;const z=E[0];for(let V=0,N=z.length,U=N-1;V<N;U=V++){const q=z[V],W=z[U],se=q.x*W.y-W.x*q.y;P+=(q.x+W.x)*se,R+=(q.y+W.y)*se,C+=3*se}return new pr(P/C,R/C,0,E)})(r),T=v.length;for(;v.length;){const E=v.pop();(E.d>b.d||!b.d)&&(b=E,i&&console.log("found best %d after %d probes",Math.round(1e4*E.d)/1e4,T)),E.max-b.d<=e||(y=E.h/2,v.push(new pr(E.p.x-y,E.p.y-y,y,r)),v.push(new pr(E.p.x+y,E.p.y-y,y,r)),v.push(new pr(E.p.x-y,E.p.y+y,y,r)),v.push(new pr(E.p.x+y,E.p.y+y,y,r)),T+=4)}return i&&(console.log(`num probes: ${T}`),console.log(`best distance: ${b.d}`)),b.p}function Ai(r,e){return e.max-r.max}Wi.TinySDF=class{constructor({fontSize:r=24,buffer:e=3,radius:i=8,cutoff:o=.25,fontFamily:a="sans-serif",fontWeight:c="normal",fontStyle:h="normal",lang:f=null}={}){this.buffer=e,this.radius=i,this.cutoff=o,this.lang=f;const _=this.size=r+4*e,y=this._createCanvas(_),v=this.ctx=y.getContext("2d",{willReadFrequently:!0});v.font=`${h} ${c} ${r}px ${a}`,v.textBaseline="alphabetic",v.textAlign="left",v.fillStyle="black",this.gridOuter=new Float64Array(_*_),this.gridInner=new Float64Array(_*_),this.f=new Float64Array(_),this.z=new Float64Array(_+1),this.v=new Uint16Array(_)}_createCanvas(r){if(typeof OffscreenCanvas<"u")return new OffscreenCanvas(r,r);const e=document.createElement("canvas");return e.width=e.height=r,e}draw(r){const{width:e,actualBoundingBoxAscent:i,actualBoundingBoxDescent:o,actualBoundingBoxLeft:a,actualBoundingBoxRight:c}=this.ctx.measureText(r),h=Math.ceil(i),f=Math.floor(-a),_=Math.max(0,Math.min(this.size-this.buffer,Math.ceil(c)-f)),y=Math.max(0,Math.min(this.size-this.buffer,h+Math.ceil(o))),v=_+2*this.buffer,b=y+2*this.buffer,T=Math.max(v*b,0),E=new Uint8ClampedArray(T),C={data:E,width:v,height:b,glyphWidth:_,glyphHeight:y,glyphTop:h,glyphLeft:f,glyphAdvance:e};if(_===0||y===0)return C;const{ctx:P,buffer:R,gridInner:z,gridOuter:V}=this;this.lang&&(P.lang=this.lang),P.clearRect(R,R,_,y),P.fillText(r,R-f,R+h);const N=P.getImageData(R,R,_,y);V.fill(mi,0,T),z.fill(0,0,T);let U=3;for(let X=0;X<y;X++){let ie=(X+R)*v+R;for(let re=0;re<_;re++,U+=4,ie++){const oe=N.data[U];if(oe===0)continue;const me=Qi[oe];V[ie]=Math.max(0,me),z[ie]=Math.max(0,-me)}}Ot(V,0,0,v,b,v,this.f,this.v,this.z);const q=Math.min(R,1);Ot(z,R-q,R-q,_+2*q,y+2*q,v,this.f,this.v,this.z);const W=255/this.radius,se=255*(1-this.cutoff);for(let X=0;X<T;X++){const ie=Math.sqrt(V[X])-Math.sqrt(z[X]);E[X]=Math.round(se-W*ie)}return C}};class pr{constructor(e,i,o,a){this.p=new Ue(e,i),this.h=o,this.d=(function(c,h){let f=!1,_=1/0;for(let y=0;y<h.length;y++){const v=h[y];for(let b=0,T=v.length,E=T-1;b<T;E=b++){const C=v[b],P=v[E];C.y>c.y!=P.y>c.y&&c.x<(P.x-C.x)*(c.y-C.y)/(P.y-C.y)+C.x&&(f=!f),_=Math.min(_,_p(c,C,P))}}return(f?1:-1)*Math.sqrt(_)})(this.p,a),this.max=this.d+this.h*Math.SQRT2}}const Xi=Object.keys,Er=Number.POSITIVE_INFINITY,jo=Math.sqrt(2);function wn(r,e,i,o,a,c){const h=ae(r)&&r.collisionPadding?r.collisionPadding:[0,0,0,0],f={top:r.top-h[1],bottom:r.bottom+h[3],left:r.left-h[0],right:r.right+h[2],scaled:!1};return o!==void 0&&(function(_,y){_.top*=y,_.bottom*=y,_.left*=y,_.right*=y,_.scaled=!0})(f,o),c&&(f.left+=c[0],f.right+=c[0],f.top+=c[1],f.bottom+=c[1]),i&&(function(_,y,v){if(!y)return;const b=Qt(y),T=new Ue(v?v[0]:0,v?v[1]:0),E=new Ue(_.left,_.top),C=new Ue(_.right,_.top),P=new Ue(_.left,_.bottom),R=new Ue(_.right,_.bottom);
7E._rotateAround(b,T),C._rotateAround(b,T),P._rotateAround(b,T),R._rotateAround(b,T),_.left=Math.min(E.x,C.x,P.x,R.x),_.right=Math.max(E.x,C.x,P.x,R.x),_.top=Math.min(E.y,C.y,P.y,R.y),_.bottom=Math.max(E.y,C.y,P.y,R.y)})(f,i,a),e?{top:Math.min(e.top,f.top),bottom:Math.max(e.bottom,f.bottom),left:Math.min(e.left,f.left),right:Math.max(e.right,f.right),scaled:e.scaled||f.scaled}:f}function Go(r,[e,i]){let o=0,a=0;if(i===Er){e<0&&(e=0);const c=e/jo;switch(r){case"top-right":case"top-left":a=c-7;break;case"bottom-right":case"bottom-left":a=7-c;break;case"bottom":a=7-e;break;case"top":a=e-7}switch(r){case"top-right":case"bottom-right":o=-c;break;case"top-left":case"bottom-left":o=c;break;case"left":o=e;break;case"right":o=-e}}else{switch(e=Math.abs(e),i=Math.abs(i),r){case"top-right":case"top-left":case"top":a=i-7;break;case"bottom-right":case"bottom-left":case"bottom":a=7-i}switch(r){case"top-right":case"bottom-right":case"right":o=-e;break;case"top-left":case"bottom-left":case"left":o=e}}return[o,a]}function xa(r,e,i,o,a,c,h,f,_,y,v,b,T,E,C){const P=r.layers[0],R=P.appearances;if(R.length===0)return{iconBBox:null,iconVerticalBBox:null,textBBox:null,textVerticalBBox:null};const z={iconBBox:null,iconVerticalBBox:null},V={textBBox:null,textVerticalBBox:null},{baseIconRotate:N,baseTextRotate:U,iconScaleFactor:q}=(function(se,X,ie){const re=se.get("icon-rotate").evaluate(X,{},ie),oe=se.get("text-rotate").evaluate(X,{},ie),[me,xe]=se.get("icon-size-scale-range");return{baseIconRotate:re,baseTextRotate:oe,iconScaleFactor:Y(1,me,xe)}})(o,a,c);e&&(z.iconBBox=wn(e,z.iconBBox,N),i)&&(z.iconVerticalBBox=wn(i,z.iconVerticalBBox,N+90));const W=V_(b.horizontal);W&&(V.textBBox=wn(W,V.textBBox,U,1,E)),b.vertical&&(V.textVerticalBBox=wn(b.vertical,V.textVerticalBBox,U+90,1,E));for(const se of R)se.hasIconLayoutProperties()&&bo(z,r,P,se,a,c,f,N,h,_,e,y,q,v,C),se.hasTextLayoutProperties()&&Ja(V,P,se,a,c,E,U,T,W,b.vertical);return{iconBBox:z.iconBBox,iconVerticalBBox:z.iconVerticalBBox,textBBox:V.textBBox,textVerticalBBox:V.textVerticalBBox}}function bo(r,e,i,o,a,c,h,f,_,y,v,b,T,E,C){const{appearanceIconOffset:P,appearanceIconRotate:R,appearanceIconSize:z}=Xn(o,i,a,c,h,f,_,y.iconScaleFactor);let V=null,N=null,U=null;o.hasLayoutProperty("icon-image")?U=(function(W,se,X,ie,re,oe,me,xe){let we=null;const Ce=se.getAppearanceValueAndResolveTokens(X,"icon-image",ie,re,xe);if(Ce){const Se=W.getResolvedImageFromTokens(Ce),qe=X.hasLayoutProperty("icon-size")?X.getUnevaluatedLayoutProperty("icon-size"):se._unevaluatedLayout._values["icon-size"],Me=va(Se,Ae(W.zoom,qe,W.worldview,xe),qe,re,W.zoom,ie,W.pixelRatio,me,W.worldview,xe);we=oe.get(Me.iconPrimary.toString())}return we})(e,i,o,a,c,b,T,C):v&&(U=v.imagePrimary),U&&(V=de(U,null,P,E),e.allowVerticalPlacement&&(N=de(U,null,P,E)));const q=_>0?z/_:1;V&&(r.iconBBox=wn(V,r.iconBBox,R,q!==1?q:void 0)),N&&(r.iconVerticalBBox=wn(N,r.iconVerticalBBox,R+90,q!==1?q:void 0))}function Xn(r,e,i,o,a,c,h,f){const _=r.hasLayoutProperty("icon-offset")?e.getAppearanceValueAndResolveTokens(r,"icon-offset",i,o,[]):null,y=_&&Array.isArray(_)?_:a,v=r.hasLayoutProperty("icon-rotate")?e.getAppearanceValueAndResolveTokens(r,"icon-rotate",i,o,[]):null,b=typeof v=="number"?v:c,T=r.hasLayoutProperty("icon-size")?e.getAppearanceValueAndResolveTokens(r,"icon-size",i,o,[]):null;return{appearanceIconOffset:y,appearanceIconRotate:b,appearanceIconSize:typeof T=="number"?T*f:h}}function Ja(r,e,i,o,a,c,h,f,_,y){const{appearanceTextOffset:v,appearanceTextRotate:b,appearanceTextSize:T}=In(i,e,o,a,c,h,f),E=T/f,C=[(v[0]-c[0])*E,(v[1]-c[1])*E],P=C[0]!==0||C[1]!==0;_&&(r.textBBox=wn(_,r.textBBox,b,E,v,P?C:void 0)),y&&(r.textVerticalBBox=wn(y,r.textVerticalBBox,b+90,E,v,P?C:void 0))}function In(r,e,i,o,a,c,h){const f=r.hasLayoutProperty("text-offset")?e.getAppearanceValueAndResolveTokens(r,"text-offset",i,o,[]):null,_=f&&Array.isArray(f)?[f[0]*Mr,f[1]*Mr]:a,y=r.hasLayoutProperty("text-rotate")?e.getAppearanceValueAndResolveTokens(r,"text-rotate",i,o,[]):null,v=typeof y=="number"?y:c,b=r.hasLayoutProperty("text-size")?e.getAppearanceValueAndResolveTokens(r,"text-size",i,o,[]):null;return{appearanceTextOffset:_,appearanceTextRotate:v,appearanceTextSize:typeof b=="number"?b:h}}function $o(r,e,i,o,a,c,h,f,_){if(!e||!e.usvg)return;const y=Ve(o),v=Ve(a),b=c!=="both"&&c!=="width"||!be(o)?1:v.width/y.width,T=c!=="both"&&c!=="height"||!Te(o)?1:v.height/y.height;i.scaleSelf(b,T);const E=i.toString();h.set(E,i),f.set(E,e);const{imagePosition:C}=oi(E,e,1);_.set(E,C)}function Lc(r,e,i,o,a,c,h,f,_,y){if(!r)return;const v=(function(b,T,E,C,P,R,z){if(b.kind==="camera")return b.maxSize;if(b.kind==="composite"){const V=T.possiblyEvaluate(new xt(b.maxZoom,{worldview:R}),E,z).evaluate(P,{},E,z),N=T.possiblyEvaluate(new xt(b.minZoom,{worldview:R}),E,z).evaluate(P,{},E,z);return Math.max(V,N)}return T.possiblyEvaluate(new xt(C,{worldview:R}),E,z).evaluate(P,{},E,z)})(e,i,o,a,c,_,y);return r.scaleSelf(v*f*h)}function va(r,e,i,o,a,c,h,f,_,y){return{iconPrimary:Lc(r.getPrimary(),e,i,o,a,c,h,f,_,y),iconSecondary:Lc(r.getSecondary(),e,i,o,a,c,h,f,_,y)}}function B_(r,e,i){if(!e)return;const o=i.get(r.toString()),a=i.get(e.toString());o&&a&&(o.paddedRect.w===a.paddedRect.w&&o.paddedRect.h===a.paddedRect.h||ht(`Mismatch in icon variant sizes: ${r.toString()} and ${e.toString()}`),o.usvg!==a.usvg&&ht(`Mismatch in icon variant image types: ${r.id} and ${e.id}`))}function N_(r,e,i,o){if(!r)return;const a=e.get(i.toString());if(a&&(r.imagePrimary=a),o){const c=e.get(o.toString());r.imageSecondary=c}}function D1(r,e){for(const i in r.horizontal)rv(r.horizontal[i],e);rv(r.vertical,e)}function rv(r,e){if(r){for(const i of r.positionedLines)for(const o of i.positionedGlyphs)if(o.image!==null){const a=o.image.toString();o.rect=e.get(a).paddedRect}}}function jy(r){switch(r){case"right":case"top-right":case"bottom-right":return"right";case"left":case"top-left":case"bottom-left":return"left"}return"center"}function L1(r,e,i,o,a,c,h,f,_){const y=V_(c.horizontal)||c.vertical,v=i.get("icon-text-fit-padding").evaluate(o,{},a);let b,T=e;return e&&_!=="none"&&(r.allowVerticalPlacement&&c.vertical&&(b=fe(e,c.vertical,_,v,f,h)),y&&(T=fe(e,y,_,v,f,h))),{defaultShapedIcon:T,verticallyShapedIcon:b}}function nv(r,e){return r*e/24}function z1(r,e,i,o,a,c,h,f,_,y,v,b,T,E,C,P,R,z,V,N,U,q,W,se,X,ie,re,oe,me=65535){let xe=h.textMaxSize.evaluate(e,{},T);xe===void 0?xe=f*h.textScaleFactor:xe*=h.textScaleFactor;const we=r.layers[0].layout,Ce=nv(f,h.textScaleFactor),Se=V_(i.horizontal)||i.vertical,qe=r.hasAnyAppearanceLayoutProperty(["text-size","text-offset","text-rotate"]),Me=r.getAppearanceFeatureData(e.index);(R!=="none"||qe)&&Me&&(Me.textShaping=Se,Me.iconTextFitPadding=we.get("icon-text-fit-padding").evaluate(e,{},T),Me.fontScale=Ce,Me.textScaleFactor=h.textScaleFactor);const Ie=E.name==="globe",Pe=r.tilePixelRatio*xe/24,Ne=(st=r.overscaling,r.zoom>18&&st>2&&(st>>
7=1),Math.max(rt/(512*st),1)*we.get("symbol-spacing")),ke=we.get("text-padding")*r.tilePixelRatio,$e=we.get("icon-padding")*r.tilePixelRatio,ze=Qt(we.get("text-max-angle")),He=we.get("icon-rotation-alignment")==="map"&&N!=="point",Ye=Ne/2;var st;r.hasAnyIconTextFit===!1&&R!=="none"&&(r.hasAnyIconTextFit=!0);const Je=(Qe,dt,wt)=>{if(dt.x<0||dt.x>=rt||dt.y<0||dt.y>=rt||ie&&ie.length>0&&e.properties&&oe&&oe(ie,e.properties,dt,T,re))return;let Bt=null;if(Ie){const{x:lt,y:Et,z:Rt}=E.projectTilePoint(dt.x,dt.y,wt);Bt={anchor:new Re(lt,Et,Rt,0,void 0),up:E.upVector(wt,dt.x,dt.y)}}(function(lt,Et,Rt,ki,qt,ni,_i,$i,Ir,gi,Ri,mr,ln,hr,zt,yr,Tn,Zr,Wr,er,Bi,Di,vr,Rr,Kn,An,Fg,Wp,Og,kg,Gl,il){const $l=lt.addToLineVertexArray(Et,ki);let rl,Ft,Dr,cr,Nr,zs,Zo,ds=0,fs=0,Bg=0,Ng=0,qu=-1,Rd=-1;const Fs={};let Vr=Ku("");const Lr=Rt?Rt.anchor:Et,Ur=Wp!=="none";let ps=0,Bn=0;if(Ir._unevaluatedLayout.getValue("text-radial-offset")===void 0){const lo=Ir.layout.get("text-offset").evaluate(Bi,{},Kn);ps=lo[0]*Mr,Bn=lo[1]*Mr}else ps=Ir.layout.get("text-radial-offset").evaluate(Bi,{},Kn)*Mr,Bn=Er;if(lt.allowVerticalPlacement&&qt.vertical){const lo=qt.vertical;if(zt)zs=qy(lo),$i&&(Zo=qy($i));else{const ms=Ir.layout.get("text-rotate").evaluate(Bi,{},Kn)+90;Dr=U_(gi,Lr,Et,Ri,mr,ln,lo,hr,ms,yr,il),$i&&(cr=U_(gi,Lr,Et,Ri,mr,ln,$i,Zr,ms,null,Gl))}}if(ni){const lo=Ir.layout.get("icon-rotate").evaluate(Bi,{},Kn),ms=kr(ni,lo,vr,Ur,Di.iconScaleFactor),Ea=$i?kr($i,lo,vr,Ur,Di.iconScaleFactor):void 0;Ft=U_(gi,Lr,Et,Ri,mr,ln,ni,Zr,lo,null,kg);const ql=(function(Hu,oS,f1,sS,aS,p1,m1,lS,FI,Yx){const _1=Hu.layers[0],g1=_1.appearances;let Ld=oS.length;if(f1&&(Ld=Math.max(Ld,f1.length)),g1.length===0)return Ld;const[cS,uS]=sS.get("icon-size-scale-range"),hS=Y(1,cS,uS);for(const Vg of g1)if(Vg.hasLayoutProperty("icon-image")){const y1=_1.getAppearanceValueAndResolveTokens(Vg,"icon-image",p1,m1,Yx);if(y1){const x1=Hu.getResolvedImageFromTokens(y1);if(x1){const v1=Vg.hasLayoutProperty("icon-size")?Vg.getUnevaluatedLayoutProperty("icon-size"):aS._values["icon-size"],dS=va(x1,Ae(Hu.zoom,v1,Hu.worldview,Yx),v1,m1,Hu.zoom,p1,Hu.pixelRatio,hS,Hu.worldview,Yx),b1=lS.get(dS.iconPrimary.toString());b1&&(Ld=Math.max(Ld,En(b1)))}}}return Ld})(lt,ms,Ea,Ir.layout,Ir._unevaluatedLayout,Bi,Kn,lt.iconAtlasPositions,0,Rr);ds=4*ql;const Xp=Ir.layout.get("icon-size").evaluate(Bi,{},Kn,Rr),Yp=Di.compositeIconSizes?Di.compositeIconSizes[0].evaluate(Bi,{},Kn,Rr):0,Kp=Di.compositeIconSizes?Di.compositeIconSizes[1].evaluate(Bi,{},Kn,Rr):0,d1=$y(lt.layerIds[0],lt.iconSizeData,Xp,ni.imagePrimary.usvg?1:Di.iconScaleFactor,Yp,Kp);lt.addSymbols(lt.icon,ms,d1,er,Wr,Bi,void 0,Rt,Et,$l.lineStartIndex,$l.lineLength,-1,Rr,Kn,An,Fg,lt.symbolInstances.length,ql),qu=lt.icon.placedSymbolArray.length-1,Ea&&(fs=4*ql,lt.addSymbols(lt.icon,Ea,d1,er,Wr,Bi,M.vertical,Rt,Et,$l.lineStartIndex,$l.lineLength,-1,Rr,Kn,An,Fg,lt.symbolInstances.length,ql),Rd=lt.icon.placedSymbolArray.length-1)}for(const lo in qt.horizontal){const ms=lo,Ea=qt.horizontal[ms];rl||(Vr=Ku(Ea.text),zt?Nr=qy(Ea):rl=U_(gi,Lr,Et,Ri,mr,ln,Ea,hr,Ir.layout.get("text-rotate").evaluate(Bi,{},Kn),yr,il));const ql=Ea.positionedLines.length===1;if(Bg+=ov(lt,Rt,Et,Ea,_i,Ir,zt,Bi,yr,$l,qt.vertical?M.horizontal:M.horizontalOnly,ql?Xi(qt.horizontal):[ms],Fs,qu,Di,Rr,Kn,lt.symbolInstances.length,An),ql)break}qt.vertical&&(Ng+=ov(lt,Rt,Et,qt.vertical,_i,Ir,zt,Bi,yr,$l,M.vertical,["vertical"],Fs,Rd,Di,Rr,Kn,lt.symbolInstances.length,An));let Wo=-1;const Sa=(lo,ms)=>lo?Math.max(lo,ms):ms;Wo=Sa(Nr,Wo),Wo=Sa(zs,Wo),Wo=Sa(Zo,Wo);const Dd=Wo>-1?1:0;lt.glyphOffsetArray.length>=65535&&ht("Too many glyphs being rendered in a tile. See https://github.com/mapbox/mapbox-gl-js/issues/2907"),Bi.sortKey!==void 0&&lt.addToSortKeyRanges(lt.symbolInstances.length,Bi.sortKey),lt.symbolInstances.emplaceBack(Et.x,Et.y,Lr.x,Lr.y,Lr.z,Fs.right>=0?Fs.right:-1,Fs.center>=0?Fs.center:-1,Fs.left>=0?Fs.left:-1,Fs.vertical>=0?Fs.vertical:-1,qu,Rd,Vr,rl!==void 0?rl:lt.collisionBoxArray.length,rl!==void 0?rl+1:lt.collisionBoxArray.length,Dr!==void 0?Dr:lt.collisionBoxArray.length,Dr!==void 0?Dr+1:lt.collisionBoxArray.length,Ft!==void 0?Ft:lt.collisionBoxArray.length,Ft!==void 0?Ft+1:lt.collisionBoxArray.length,cr||lt.collisionBoxArray.length,cr?cr+1:lt.collisionBoxArray.length,Ri,Bg,Ng,ds,fs,Dd,0,ps,Bn,Wo,0,Ur?1:0,Og)})(r,dt,Bt,Qe,i,o,c,a,r.layers[0],r.collisionBoxArray,e.index,e.sourceLayerIndex,r.index,ke,V,y,0,$e,He,z,e,h,v,b,T,C,P,R,me,U,q,W)};if(N==="line")for(const Qe of pd(e.geometry,0,0,rt,rt)){const dt=tt(Qe,Ne,ze,i.vertical||Se,o,24,Pe,r.overscaling,rt);for(const wt of dt)Se&&F1(r,Se.text,Ye,wt)||Je(Qe,wt,T)}else if(N==="line-center"){for(const Qe of e.geometry)if(Qe.length>1){const dt=Ze(Qe,ze,i.vertical||Se,o,24,Pe);dt&&Je(Qe,dt,T)}}else if(e.type==="Polygon")for(const Qe of Ro(e.geometry,0)){const dt=si(Qe,16);Je(Qe[0],new Re(dt.x,dt.y,0,0,void 0),T)}else if(e.type==="LineString")for(const Qe of e.geometry)Je(Qe,new Re(Qe[0].x,Qe[0].y,0,0,void 0),T);else if(e.type==="Point")for(const Qe of e.geometry)for(const dt of Qe)Je([dt],new Re(dt.x,dt.y,0,0,void 0),T)}const Gy=255,Bu=Gy*ye;function ov(r,e,i,o,a,c,h,f,_,y,v,b,T,E,C,P,R,z,V){const N=di(0,o,_,c,h,f,a,r.allowVerticalPlacement,void 0,C.textScaleFactor),U=c.layout.get("text-size").evaluate(f,{},R),q=C.compositeTextSizes?C.compositeTextSizes[0].evaluate(f,{},R):0,W=C.compositeTextSizes?C.compositeTextSizes[1].evaluate(f,{},R):0,se=$y(r.layerIds[0],r.textSizeData,U,C.textScaleFactor,q,W);r.addSymbols(r.text,N,se,_,h,f,v,e,i,y.lineStartIndex,y.lineLength,E,P,R,V,!1,z,N.length);for(const X of b)T[X]=r.text.placedSymbolArray.length-1;return 4*N.length}function $y(r,e,i,o,a,c){const h=e;let f=null;return h.kind==="source"?(f=[ye*i*o],f[0]>Bu&&ht(`${r}: Value for "text-size" or "icon-size" is >= ${Gy}
7. Reduce your "text-size" or "icon-size".`)):h.kind==="composite"&&(f=[ye*a*o,ye*c*o],(f[0]>Bu||f[1]>Bu)&&ht(`${r}: Value for "text-size" or "icon-size" is >= ${Gy}. Reduce your "text-size" or "icon-size".`)),f}function V_(r){for(const e in r)return r[e];return null}function U_(r,e,i,o,a,c,h,f,_,y,v){let b,T,E,C;if(b=v?v.top:h.top,T=v?v.bottom:h.bottom,E=v?v.left:h.left,C=v?v.right:h.right,ae(h)&&h.collisionPadding){const P=h.collisionPadding;E-=P[0],b-=P[1],C+=P[2],T+=P[3]}if(_){const P=new Ue(E,b),R=new Ue(C,b),z=new Ue(E,T),V=new Ue(C,T),N=Qt(_);let U=new Ue(0,0);y&&(U=new Ue(y[0],y[1])),P._rotateAround(N,U),R._rotateAround(N,U),z._rotateAround(N,U),V._rotateAround(N,U),E=Math.min(P.x,R.x,z.x,V.x),C=Math.max(P.x,R.x,z.x,V.x),b=Math.min(P.y,R.y,z.y,V.y),T=Math.max(P.y,R.y,z.y,V.y)}return r.emplaceBack(e.x,e.y,e.z,i.x,i.y,E,b,C,T,f,o,a,c),r.length-1}function qy(r){ae(r)&&r.collisionPadding&&(r.top-=r.collisionPadding[1],r.bottom+=r.collisionPadding[3]);const e=r.bottom-r.top;return e>0?Math.max(10,e):null}function F1(r,e,i,o){const a=r.compareText;if(e in a){const c=a[e];for(let h=c.length-1;h>=0;h--)if(o.dist(c[h])<i)return!0}else a[e]=[];return a[e].push(o),!1}const O1=Gt([{type:"Float32",name:"a_globe_pos",components:3},{type:"Float32",name:"a_uv",components:2}]),{members:j_}=O1,k1=Gt([{name:"a_pos_3",components:3,type:"Int16"}]);var sv=Gt([{name:"a_pos",type:"Int16",components:2}]);class B1{constructor(e,i){this.pos=e,this.dir=i}intersectsPlane(e,i,o){const a=Mo(i,this.dir);if(Math.abs(a)<1e-6)return!1;const c=((e[0]-this.pos[0])*i[0]+(e[1]-this.pos[1])*i[1])/a;return o[0]=this.pos[0]+this.dir[0]*c,o[1]=this.pos[1]+this.dir[1]*c,!0}}class Hy{constructor(e,i){this.pos=e,this.dir=i}intersectsPlane(e,i,o){const a=qi(i,this.dir);if(Math.abs(a)<1e-6)return!1;const c=((e[0]-this.pos[0])*i[0]+(e[1]-this.pos[1])*i[1]+(e[2]-this.pos[2])*i[2])/a;return o[0]=this.pos[0]+this.dir[0]*c,o[1]=this.pos[1]+this.dir[1]*c,o[2]=this.pos[2]+this.dir[2]*c,!0}closestPointOnSphere(e,i,o){if((function(E,C){var P=E[0],R=E[1],z=E[2],V=C[0],N=C[1],U=C[2];return Math.abs(P-V)<=Yi*Math.max(1,Math.abs(P),Math.abs(V))&&Math.abs(R-N)<=Yi*Math.max(1,Math.abs(R),Math.abs(N))&&Math.abs(z-U)<=Yi*Math.max(1,Math.abs(z),Math.abs(U))})(this.pos,e)||i===0)return o[0]=o[1]=o[2]=0,!1;const[a,c,h]=this.dir,f=this.pos[0]-e[0],_=this.pos[1]-e[1],y=this.pos[2]-e[2],v=a*a+c*c+h*h,b=2*(f*a+_*c+y*h),T=b*b-4*v*(f*f+_*_+y*y-i*i);if(T<0){const E=Math.max(-b/2,0),C=f+a*E,P=_+c*E,R=y+h*E,z=Math.hypot(C,P,R);return o[0]=C*i/z,o[1]=P*i/z,o[2]=R*i/z,!1}{const E=(-b-Math.sqrt(T))/(2*v);if(E<0){const C=Math.hypot(f,_,y);return o[0]=f*i/C,o[1]=_*i/C,o[2]=y*i/C,!1}return o[0]=f+a*E,o[1]=_+c*E,o[2]=y+h*E,!0}}}class Zy{constructor(e,i,o,a,c){this.TL=e,this.TR=i,this.BR=o,this.BL=a,this.horizon=c}static fromInvProjectionMatrix(e,i,o){const a=[-1,1,1],c=[1,1,1],h=[1,-1,1],f=[-1,-1,1],_=ir(a,a,e),y=ir(c,c,e),v=ir(h,h,e),b=ir(f,f,e);return new Zy(_,y,v,b,i/o)}}function Wy(r,e,i,o){const a=e[0],c=e[1],h=e[2],f=i[0],_=i[1],y=i[2];let v=1/0,b=-1/0;for(let T=0;T<r.length;T++){const E=r[T],C=(E[0]-a)*f+(E[1]-c)*_+(E[2]-h)*y;C<v&&(v=C),C>b&&(b=C)}return o[0]=v,o[1]=b,o}function av(r,e){let i=!0;for(let o=0;o<r.planes.length;o++){const a=r.planes[o];let c=0;for(let h=0;h<e.length;h++)c+=+(qi(a,e[h])+a[3]>=0);if(c===0)return 0;c!==e.length&&(i=!1)}return i?2:1}const N1=[0,0];function lv(r,e){for(const i of r.projections){const o=Wy(e,r.points[0],i.axis,N1);if(i.projection[1]<o[0]||i.projection[0]>o[1])return 0}return 1}function cv(r,e){const i=e[0],o=e[1],a=e[2],c=e[3];for(let h=0;h<r.length;h++){const f=r[h];if(i*f[0]+o*f[1]+a*f[2]+c>=0)return!0}return!1}class Xy{constructor(e,i){this.points=e||new Array(8).fill([0,0,0]),this.planes=i||new Array(6).fill([0,0,0,0]),this.bounds=lr.fromPoints(this.points),this.projections=[],this.frustumEdges=[Zi([],this.points[2],this.points[3]),Zi([],this.points[0],this.points[3]),Zi([],this.points[4],this.points[0]),Zi([],this.points[5],this.points[1]),Zi([],this.points[6],this.points[2]),Zi([],this.points[7],this.points[3])];for(const o of this.frustumEdges){const a=[0,-o[2],o[1]],c=[o[2],0,-o[0]];this.projections.push({axis:a,projection:Wy(this.points,this.points[0],a,[0,0])}),this.projections.push({axis:c,projection:Wy(this.points,this.points[0],c,[0,0])})}}static fromInvProjectionMatrix(e,i,o,a){const c=Math.pow(2,o),h=[[-1,1,-1,1],[1,1,-1,1],[1,-1,-1,1],[-1,-1,-1,1],[-1,1,1,1],[1,1,1,1],[1,-1,1,1],[-1,-1,1,1]].map(y=>{const v=Ln([],y,e),b=1/v[3]/i*c;return(T=v)[0]=(E=v)[0]*(C=[b,b,a?1/v[3]:b,b])[0],T[1]=E[1]*C[1],T[2]=E[2]*C[2],T[3]=E[3]*C[3],T;var T,E,C}),f=[[0,1,2],[6,5,4],[0,3,7],[2,1,5],[3,2,6],[0,4,5]].map(y=>{const v=Mi([],tr([],Zi([],h[y[0]],h[y[1]]),Zi([],h[y[2]],h[y[1]]))),b=-qi(v,h[y[1]]);return v.concat(b)}),_=[];for(let y=0;y<h.length;y++)_.push([h[y][0],h[y][1],h[y][2]]);return new Xy(_,f)}intersectsPrecise(e,i,o){for(let _=0;_<i.length;_++)if(!cv(e,i[_]))return 0;for(let _=0;_<this.planes.length;_++)if(!cv(e,this.planes[_]))return 0;const a=this.points,c=a[0][0],h=a[0][1],f=a[0][2];for(const _ of o)for(const y of this.frustumEdges){const v=_[1]*y[2]-_[2]*y[1],b=_[2]*y[0]-_[0]*y[2],T=_[0]*y[1]-_[1]*y[0];if(v===0&&b===0&&T===0)continue;let E=1/0,C=-1/0;for(let z=0;z<a.length;z++){const V=a[z],N=(V[0]-c)*v+(V[1]-h)*b+(V[2]-f)*T;N<E&&(E=N),N>C&&(C=N)}let P=1/0,R=-1/0;for(let z=0;z<e.length;z++){const V=e[z],N=(V[0]-c)*v+(V[1]-h)*b+(V[2]-f)*T;N<P&&(P=N),N>R&&(R=N)}if(E>R||P>C)return 0}return 1}containsPoint(e){for(const i of this.planes){const o=i[3];if(qi([i[0],i[1],i[2]],e)+o<0)return!1}return!0}}class lr{static fromPoints(e){const i=[1/0,1/0,1/0],o=[-1/0,-1/0,-1/0];for(const a of e)Io(i,i,a),Jn(o,o,a);return new lr(i,o)}static fromTileIdAndHeight(e,i,o){const a=1<<e.canonical.z,c=e.canonical.x,h=e.canonical.y;
vendor: 14,387 bytes, line 7
7return new lr([c/a,h/a,i],[(c+1)/a,(h+1)/a,o])}static applyTransform(e,i){const o=e.getCorners();for(let a=0;a<o.length;++a)ir(o[a],o[a],i);return lr.fromPoints(o)}static applyTransformFast(e,i){const o=[i[12],i[13],i[14]],a=[...o];for(let c=0;c<3;c++)for(let h=0;h<3;h++){const f=i[4*h+c],_=f*e.min[h],y=f*e.max[h];o[c]+=Math.min(_,y),a[c]+=Math.max(_,y)}return new lr(o,a)}static projectAabbCorners(e,i){const o=e.getCorners();for(let a=0;a<o.length;++a)ir(o[a],o[a],i);return o}constructor(e,i){this.min=e,this.max=i,this.center=li([],ji([],this.min,this.max),.5)}quadrant(e){const i=[e%2==0,e<2],o=Eo(this.min),a=Eo(this.max);for(let c=0;c<i.length;c++)o[c]=i[c]?this.min[c]:this.center[c],a[c]=i[c]?this.center[c]:this.max[c];return a[2]=this.max[2],new lr(o,a)}distanceX(e){return Math.max(Math.min(this.max[0],e[0]),this.min[0])-e[0]}distanceY(e){return Math.max(Math.min(this.max[1],e[1]),this.min[1])-e[1]}distanceZ(e){return Math.max(Math.min(this.max[2],e[2]),this.min[2])-e[2]}getCorners(){const e=this.min,i=this.max;return[[e[0],e[1],e[2]],[i[0],e[1],e[2]],[i[0],i[1],e[2]],[e[0],i[1],e[2]],[e[0],e[1],i[2]],[i[0],e[1],i[2]],[i[0],i[1],i[2]],[e[0],i[1],i[2]]]}intersects(e){return this.intersectsAabb(e.bounds)?av(e,this.getCorners()):0}intersectsFlat(e){return this.intersectsAabb(e.bounds)?av(e,[[this.min[0],this.min[1],0],[this.max[0],this.min[1],0],[this.max[0],this.max[1],0],[this.min[0],this.max[1],0]]):0}intersectsPrecise(e,i){return i||this.intersects(e)?lv(e,this.getCorners()):0}intersectsPreciseFlat(e,i){return i||this.intersectsFlat(e)?lv(e,[[this.min[0],this.min[1],0],[this.max[0],this.min[1],0],[this.max[0],this.max[1],0],[this.min[0],this.max[1],0]]):0}intersectsAabb(e){for(let i=0;i<3;++i)if(this.min[i]>e.max[i]||e.min[i]>this.max[i])return!1;return!0}intersectsAabbXY(e){return!(this.min[0]>e.max[0]||e.min[0]>this.max[0]||this.min[1]>e.max[1]||e.min[1]>this.max[1])}encapsulate(e){for(let i=0;i<3;i++)this.min[i]=Math.min(this.min[i],e.min[i]),this.max[i]=Math.max(this.max[i],e.max[i])}encapsulatePoint(e){for(let i=0;i<3;i++)this.min[i]=Math.min(this.min[i],e[i]),this.max[i]=Math.max(this.max[i],e[i])}closestPoint(e){return[Math.max(Math.min(this.max[0],e[0]),this.min[0]),Math.max(Math.min(this.max[1],e[1]),this.min[1]),Math.max(Math.min(this.max[2],e[2]),this.min[2])]}}function G_(r){return r*Zn/Ic}nt(lr,"Aabb");const V1=[new lr([os,os,os],[ss,ss,ss]),new lr([os,os,os],[0,0,ss]),new lr([0,os,os],[ss,0,ss]),new lr([os,0,os],[0,ss,ss]),new lr([0,0,os],[ss,ss,ss])];function uv(r,e,i,o=!0){const a=li([],r._camera.position,r.worldSize),c=[e,i,1,1];Ln(c,c,r.pixelMatrixInverse),Yo(c,c,1/c[3]);const h=Mi([],Zi([],c,a)),f=r.globeMatrix,_=[f[12],f[13],f[14]],y=Zi([],_,a),v=Yr(y),b=Mi([],y),T=r.worldSize/(2*Math.PI),E=qi(b,h),C=Math.asin(T/v);if(C<Math.acos(E)){if(!o)return null;const re=[],oe=[];li(re,h,v/E),Mi(oe,Zi(oe,re,y)),Mi(h,ji(h,y,li(h,oe,Math.tan(C)*v)))}const P=[];new Hy(a,h).closestPointOnSphere(_,T,P);const R=Mi([],dr(f,0)),z=Mi([],dr(f,1)),V=Mi([],dr(f,2)),N=qi(R,P),U=qi(z,P),q=qi(V,P),W=en(Math.asin(-U/T));let se=en(Math.atan2(N,q));se=r.center.lng+(function(re,oe){const me=(oe-re+180)%360-180;return me<-180?me+360:me})(r.center.lng,se);const X=Ss(se),ie=Y(vn(W),0,1);return new kn(X,ie)}class U1{constructor(e,i,o){this.a=Zi([],e,o),this.b=Zi([],i,o),this.center=o;const a=Mi([],this.a),c=Mi([],this.b);this.angle=Math.acos(qi(a,c))}}function Yy(r,e){if(r.angle===0)return null;let i;return i=r.a[e]===0?1/r.angle*.5*Math.PI:1/r.angle*Math.atan(r.b[e]/r.a[e]/Math.sin(r.angle)-1/Math.tan(r.angle)),i<0||i>1?null:(function(o,a,c,h){const f=Math.sin(c);return o*(Math.sin((1-h)*c)/f)+a*(Math.sin(h*c)/f)})(r.a[e],r.b[e],r.angle,Y(i,0,1))+r.center[e]}function Qa(r){if(r.z<=1)return V1[r.z+2*r.y+r.x];const e=Ky($_(r));return lr.fromPoints(e)}function kl(r,e,i){return li(r,r,1-i),Kr(r,r,e,i)}function hv(r,e,i){for(const o of r)ir(o,o,e),li(o,o,i)}function dv(r,e,i,o){const a=e/r.worldSize,c=r.globeMatrix;if(i.z<=1){const ie=Qa(i).getCorners();return hv(ie,c,a),lr.fromPoints(ie)}const h=$_(i,o),f=Ky(h,Zn+G_(r._tileCoverLift));hv(f,c,a);const _=Number.MAX_VALUE,y=[-_,-_,-_],v=[_,_,_];if(h.contains(r.center)){for(const oe of f)Io(v,v,oe),Jn(y,y,oe);y[2]=0;const ie=r.point,re=[ie.x*a,ie.y*a,0];return Io(v,v,re),Jn(y,y,re),new lr(v,y)}if(r._tileCoverLift>0){for(const ie of f)Io(v,v,ie),Jn(y,y,ie);return new lr(v,y)}const b=[c[12]*a,c[13]*a,c[14]*a],T=h.getCenter(),E=Y(r.center.lat,-85.051129,as),C=Y(T.lat,-85.051129,as),P=Ss(r.center.lng),R=vn(E);let z=P-Ss(T.lng);const V=R-vn(C);z>.5?z-=1:z<-.5&&(z+=1);let N=0;Math.abs(z)>Math.abs(V)?N=z>=0?1:3:(N=V>=0?0:2,Kr(b,b,[c[4]*a,c[5]*a,c[6]*a],-Math.sin(Qt(V>=0?h.getSouth():h.getNorth()))*Zn));const U=f[N],q=f[(N+1)%4],W=new U1(U,q,b),se=[Yy(W,0)||U[0],Yy(W,1)||U[1],Yy(W,2)||U[2]],X=zc(r.zoom);if(X>0){const ie=(function({x:oe,y:me,z:xe},we,Ce,Se,qe){const Me=1/(1<<xe);let Ie=oe*Me,Pe=Ie+Me,Ne=me*Me,ke=Ne+Me,$e=0;const ze=(Ie+Pe)/2-Se;return ze>.5?$e=-1:ze<-.5&&($e=1),Ie=((Ie+$e)*we-(Se*=we))*Ce+Se,Pe=((Pe+$e)*we-Se)*Ce+Se,Ne=(Ne*we-(qe*=we))*Ce+qe,ke=(ke*we-qe)*Ce+qe,[[Ie,ke,0],[Pe,ke,0],[Pe,Ne,0],[Ie,Ne,0]]})(i,e,r._pixelsPerMercatorPixel,P,R);for(let oe=0;oe<f.length;oe++)kl(f[oe],ie[oe],X);const re=ji([],ie[N],ie[(N+1)%4]);li(re,re,.5),kl(se,re,X)}for(const ie of f)Io(v,v,ie),Jn(y,y,ie);return v[2]=Math.min(U[2],q[2]),Io(v,v,se),Jn(y,y,se),new lr(v,y)}function $_({x:r,y:e,z:i},o=!1){const a=1/(1<<i),c=new ui($r(r*a),e===(1<<i)-1&&o?-90:on((e+1)*a)),h=new ui($r((r+1)*a),e===0&&o?90:on(e*a));return new Ga(c,h)}function Ky(r,e=Zn){const i=Qt(r.getNorth()),o=Qt(r.getSouth()),a=Math.cos(i),c=Math.cos(o),h=Math.sin(i),f=Math.sin(o),_=r.getWest(),y=r.getEast();return[Ec(c,f,_,e),Ec(c,f,y,e),Ec(a,h,y,e),Ec(a,h,_,e)]}function wp(r,e,i,o){const a=1<<i.z,c=(r/rt+i.x)/a;return Rl(on((e/rt+i.y)/a),$r(c),o)}function q_({min:r,max:e}){return 16383/Math.max(e[0]-r[0],e[1]-r[1],e[2]-r[2])}const H_=new Float64Array(16);function Z_(r){const e=q_(r),i=So(H_,[e,e,e]);return Mn(i,i,Jr([],r.min))}function Jy(r){const e=1/q_(r);return hn(H_,r.min),_n(H_,H_,[e,e,e])}function Qy(r){const e=rt/(2*Math.PI);return r/(2*Math.PI)/e}function fv(r,e){return rt/(512*Math.pow(2,r))*q_(Qa(e))}function pv(r,e,i,o,a){const c=Qy(i),h=[r,e,-i/(2*Math.PI)],f=Si(new Float64Array(16));return Mn(f,f,h),_n(f,f,[c,c,c]),gn(f,f,Qt(-a)),Pn(f,f,Qt(-o)),f}function zc(r){return ce(5,6,r)}function mv(r,e){const i=Rl(e.lat,e.lng),o=(function(C){const P=Rl(C._center.lat,C._center.lng);let R=tr([],ur(0,1,0),P);const z=uo([],-C.angle,P);R=ir(R,R,z),uo(z,-C._pitch,R);const V=Mi([],P);return li(V,V,G_(C.cameraToCenterDistance/C.pixelsPerMeter)),ir(V,V,z),ji([],P,V)})(r);return h=(a=dn([],o,i))[0],f=a[1],_=a[2],y=(c=i)[0],v=c[1],b=c[2],E=(T=Math.sqrt((h*h+f*f+_*_)*(y*y+v*v+b*b)))&&qi(a,c)/T,Math.acos(Math.min(Math.max(E,-1),1));var a,c,h,f,_,y,v,b,T,E}function ex(r,e){return mv(r,e)>Math.PI/2*1.01}const _v=Qt(85),j1=Math.cos(_v),G1=Math.sin(_v);function gv(r,e){const i=r.fovAboveCenter,o=r.elevation?r.elevation.getMinElevationBelowMSL()*e:0,a=Math.min(o,r.isOrthographic?-10*e:0),c=(r._camera.position[2]*r.worldSize-a)/Math.cos(r._pitch),h=Math.sin(i)*c/Math.sin(Math.max(Math.PI/2-r._pitch-i,.01));let f=Math.sin(r._pitch)*h+c;const _=c*(1/r._horizonShift);if(!r.elevation||r.elevation.exaggeration()===0){let y=Math.max(r.zoom-17,0);r.isOrthographic&&(y/=10),f*=1+y}return Math.min(1.01*f,_)}class Tp{constructor(e,i,o){this.z=e,this.x=i,this.y=o,this.key=xd(0,e,e,i,o)}equals(e){return this.z===e.z&&this.x===e.x&&this.y===e.y}isChildOf(e){const i=this.z-e.z;return e.z===0||e.z<this.z&&e.x===this.x>>i&&e.y===this.y>>i}url(e,i){const o=(function(c,h,f){const _=2**f,y=2*Math.PI*6378137,v=y*(c/_-.5),b=y*(.5-(h+1)/_);return`${v},${b},${v+y/_},${b+y/_}`})(this.x,this.y,this.z),a=(function(c,h,f){let _,y="";for(let v=c;v>0;v--)_=1<<v-1,y+=(h&_?1:0)+(f&_?2:0);return y})(this.z,this.x,this.y);return e[(this.x+this.y)%e.length].replace("{prefix}",(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"?Math.pow(2,this.z)-this.y-1:this.y)).replace("{quadkey}",a).replace("{bbox-epsg-3857}",o)}toString(){return`${this.z}/${this.x}/${this.y}`}}class yv{constructor(e,i){this.wrap=e,this.canonical=i,this.key=xd(e,i.z,i.z,i.x,i.y)}}class Yn{constructor(e,i,o,a,c){this.overscaledZ=e,this.wrap=i,this.canonical=new Tp(o,+a,+c),this.key=i===0&&e===o?this.canonical.key:xd(i,e,o,a,c)}equals(e){return this.overscaledZ===e.overscaledZ&&this.wrap===e.wrap&&this.canonical.equals(e.canonical)}scaledTo(e){const i=this.canonical.z-e;return e>this.canonical.z?new Yn(e,this.wrap,this.canonical.z,this.canonical.x,this.canonical.y):new Yn(e,this.wrap,e,this.canonical.x>>i,this.canonical.y>>i)}calculateScaledKey(e,i=!0){if(this.overscaledZ===e&&i)return this.key;if(e>this.canonical.z)return xd(this.wrap*+i,e,this.canonical.z,this.canonical.x,this.canonical.y);{const o=this.canonical.z-e;return xd(this.wrap*+i,e,e,this.canonical.x>>o,this.canonical.y>>o)}}isChildOf(e){if(e.wrap!==this.wrap)return!1;const i=this.canonical.z-e.canonical.z;return e.overscaledZ===0||e.overscaledZ<this.overscaledZ&&e.canonical.z<this.canonical.z&&e.canonical.x===this.canonical.x>>i&&e.canonical.y===this.canonical.y>>i}children(e){if(this.overscaledZ>=e)return[new Yn(this.overscaledZ+1,this.wrap,this.canonical.z,this.canonical.x,this.canonical.y)];const i=this.canonical.z+1,o=2*this.canonical.x,a=2*this.canonical.y;return[new Yn(i,this.wrap,i,o,a),new Yn(i,this.wrap,i,o+1,a),new Yn(i,this.wrap,i,o,a+1),new Yn(i,this.wrap,i,o+1,a+1)]}isLessThan(e){return this.wrap<e.wrap||!(this.wrap>e.wrap)&&(this.overscaledZ<e.overscaledZ||!(this.overscaledZ>e.overscaledZ)&&(this.canonical.x<e.canonical.x||!(this.canonical.x>e.canonical.x)&&this.canonical.y<e.canonical.y))}wrapped(){return new Yn(this.overscaledZ,0,this.canonical.z,this.canonical.x,this.canonical.y)}unwrapTo(e){return new Yn(this.overscaledZ,e,this.canonical.z,this.canonical.x,this.canonical.y)}overscaleFactor(){return Math.pow(2,this.overscaledZ-this.canonical.z)}toUnwrapped(){return new yv(this.wrap,this.canonical)}toString(){return`${this.overscaledZ}/${this.canonical.x}/${this.canonical.y}`}}function xd(r,e,i,o,a){const c=1<<Math.min(i,22);let h=c*(a%c)+o%c;return r&&i<22&&(h+=c*c*((r<0?-2*r-1:2*r)%(1<<2*(22-i)))),16*(32*h+i)+(e-i)}const $1=[r=>{let e=r.canonical.x-1,i=r.wrap;return e<0&&(e=(1<<r.canonical.z)-1,i--),new Yn(r.overscaledZ,i,r.canonical.z,e,r.canonical.y)},r=>{let e=r.canonical.x+1,i=r.wrap;return e===1<<r.canonical.z&&(e=0,i++),new Yn(r.overscaledZ,i,r.canonical.z,e,r.canonical.y)},r=>new Yn(r.overscaledZ,r.wrap,r.canonical.z,r.canonical.x,(r.canonical.y===0?1<<r.canonical.z:r.canonical.y)-1),r=>new Yn(r.overscaledZ,r.wrap,r.canonical.z,r.canonical.x,r.canonical.y===(1<<r.canonical.z)-1?0:r.canonical.y+1)];function tx(r,e){if(!e.isReprojectedInTileSpace)return{scale:1<<r.z,x:r.x,y:r.y,x2:r.x+1,y2:r.y+1,projection:e};const i=Math.pow(2,-r.z),o=r.x*i,a=(r.x+1)*i,c=r.y*i,h=(r.y+1)*i,f=$r(o),_=$r(a),y=on(c),v=on(h),b=e.project(f,y),T=e.project(_,y),E=e.project(_,v),C=e.project(f,v);let P=Math.min(b.x,T.x,E.x,C.x),R=Math.min(b.y,T.y,E.y,C.y),z=Math.max(b.x,T.x,E.x,C.x),V=Math.max(b.y,T.y,E.y,C.y);const N=i/16;function U(W,se,X,ie,re,oe){const me=(X+re)/2,xe=(ie+oe)/2,we=e.project($r(me),on(xe)),Ce=Math.max(0,P-we.x,R-we.y,we.x-z,we.y-V);P=Math.min(P,we.x),z=Math.max(z,we.x),R=Math.min(R,we.y),V=Math.max(V,we.y),Ce>N&&(U(W,we,X,ie,me,xe),U(we,se,me,xe,re,oe))}U(b,T,o,c,a,c),U(T,E,a,c,a,h),U(E,C,a,h,o,h),U(C,b,o,h,o,c),P-=N,R-=N,z+=N,V+=N;const q=1/Math.max(z-P,V-R);return{scale:q,x:P*q,y:R*q,x2:z*q,y2:V*q,projection:e}}nt(Tp,"CanonicalTileID"),nt(Yn,"OverscaledTileID",{omit:["projMatrix","expandedProjMatrix"]});const q1=Si(new Float32Array(16));class Fc{constructor(e){this.spec=e,this.name=e.name,this.wrap=!1,this.requiresDraping=!1,this.supportsWorldCopies=!1,this.supportsTerrain=!1,this.supportsFog=!1,this.supportsFreeCamera=!1,this.zAxisUnit="meters",this.isReprojectedInTileSpace=!0,this.unsupportedLayers=["custom"],this.center=[0,0],this.range=[3.5,7]}project(e,i){return{x:0,y:0,z:0}}unproject(e,i){return new ui(0,0)}projectTilePoint(e,i,o){return{x:e,y:i,z:0}}locationPoint(e,i,o,a=!0){return e._coordinatePoint(e.locationCoordinate(i,o),a)}pixelsPerMeter(e,i){return Wn(1,e)*i}pixelSpaceConversion(e,i,o){return 1}farthestPixelDistance(e){return gv(e,e.pixelsPerMeter)}pointCoordinate(e,i,o,a){const c=e.horizonLineFromTop(!1),h=new Ue(i,Math.max(c,o));return e.rayIntersectionCoordinate(e.pointRayIntersection(h,a))}pointCoordinate3D(e,i,o){const a=new Ue(i,o);if(e.elevation)return e.elevation.pointCoordinate(a);{const c=this.pointCoordinate(e,a.x,a.y,0);return[c.x,c.y,c.z]}}isPointAboveHorizon(e,i){if(e.elevation&&e.elevation.visibleDemTiles.length)return!this.pointCoordinate3D(e,i.x,i.y);const o=e.horizonLineFromTop();return i.y<o}createInversionMatrix(e,i){return q1}createTileMatrix(e,i,o){let a,c,h;const f=o.canonical,_=Si(new Float64Array(16));if(this.isReprojectedInTileSpace){const y=tx(f,this);a=1,c=y.x+o.wrap*y.scale,h=y.y,_n(_,_,[a/y.scale,a/y.scale,e.pixelsPerMeter/i])}else a=i/e.zoomScale(f.z),c=(f.x+Math.pow(2,f.z)*o.wrap)*a,h=f.y*a;return Mn(_,_,[c,h,0]),_n(_,_,[a/rt,a/rt,1]),_}upVector(e,i,o){return[0,0,1]}upVectorScale(e,i,o){return{metersToTile:1}}}class H1 extends Fc{constructor(e){super(e),this.range=[4,7],this.center=e.center||[-96,37.5];const[i,o]=this.parallels=e.parallels||[29.5,45.5],a=Math.sin(Qt(i));this.n=(a+Math.sin(Qt(o)))/2,this.c=1+a*(2*this.n-a),this.r0=Math.sqrt(this.c)/this.n}project(e,i){const{n:o,c:a,r0:c}=this,h=Qt(e-this.center[0]),f=Qt(i),_=Math.sqrt(a-2*o*Math.sin(f))/o;return{x:_*Math.sin(h*o),y:_*Math.cos(h*o)-c,z:0}}unproject(e,i){const{n:o,c:a,r0:c}=this,h=c+i;let f=Math.atan2(e,Math.abs(h))*Math.sign(h);h*o<0&&(f-=Math.PI*Math.sign(e)*Math.sign(h));const _=Qt(this.center[0])*o;f=he(f,-Math.PI-_,Math.PI-_);const y=Y(en(f/o)+this.center[0],-180,180),v=Math.asin(Y((a-(e*e+h*h)*o*o)/(2*o),-1,1)),b=Y(en(v),-85.051129,as);return new ui(y,b)}}const Sp=1.340264,Ep=-.081106,Ip=893e-6,Ap=.003796,W_=Math.sqrt(3)/2;class Z1 extends Fc{project(e,i){i=i/180*Math.PI,e=e/180*Math.PI;const o=Math.asin(W_*Math.sin(i)),a=o*o,c=a*a*a;return{x:.5*(e*Math.cos(o)/(W_*(Sp+3*Ep*a+c*(7*Ip+9*Ap*a)))/Math.PI+.5),y:1-.5*(o*(Sp+E
vendor: 5,001 bytes, line 7
7p*a+c*(Ip+Ap*a))/Math.PI+1),z:0}}unproject(e,i){e=(2*e-.5)*Math.PI;let o=i=(2*(1-i)-1)*Math.PI,a=o*o,c=a*a*a;for(let v,b,T,E=0;E<12&&(b=o*(Sp+Ep*a+c*(Ip+Ap*a))-i,T=Sp+3*Ep*a+c*(7*Ip+9*Ap*a),v=b/T,o=Y(o-v,-Math.PI/3,Math.PI/3),a=o*o,c=a*a*a,!(Math.abs(v)<1e-12));++E);const h=W_*e*(Sp+3*Ep*a+c*(7*Ip+9*Ap*a))/Math.cos(o),f=Math.asin(Math.sin(o)/W_),_=Y(180*h/Math.PI,-180,180),y=Y(180*f/Math.PI,-85.051129,as);return new ui(_,y)}}class W1 extends Fc{constructor(e){super(e),this.wrap=!0,this.supportsWorldCopies=!0}project(e,i){return{x:.5+e/360,y:.5-i/360,z:0}}unproject(e,i){const o=360*(e-.5),a=Y(360*(.5-i),-85.051129,as);return new ui(o,a)}}const vd=Math.PI/2;function X_(r){return Math.tan((vd+r)/2)}class X1 extends Fc{constructor(e){super(e),this.center=e.center||[0,30];const[i,o]=this.parallels=e.parallels||[30,30];let a=Qt(i),c=Qt(o);this.southernCenter=a+c<0,this.southernCenter&&(a=-a,c=-c);const h=Math.cos(a),f=X_(a);this.n=a===c?Math.sin(a):Math.log(h/Math.cos(c))/Math.log(X_(c)/f),this.f=h*Math.pow(X_(a),this.n)/this.n}project(e,i){i=Qt(i),this.southernCenter&&(i=-i),e=Qt(e-this.center[0]);const o=1e-6,{n:a,f:c}=this;c>0?i<-vd+o&&(i=-vd+o):i>vd-o&&(i=vd-o);const h=c/Math.pow(X_(i),a);let f=h*Math.sin(a*e),_=c-h*Math.cos(a*e);return f=.5*(f/Math.PI+.5),_=.5*(_/Math.PI+.5),{x:f,y:this.southernCenter?_:1-_,z:0}}unproject(e,i){e=(2*e-.5)*Math.PI,this.southernCenter&&(i=1-i),i=(2*(1-i)-.5)*Math.PI;const{n:o,f:a}=this,c=a-i,h=Math.sign(c),f=Math.sign(o)*Math.sqrt(e*e+c*c);let _=Math.atan2(e,Math.abs(c))*h;c*o<0&&(_-=Math.PI*Math.sign(e)*h);const y=Y(en(_/o)+this.center[0],-180,180),v=Y(en(2*Math.atan(Math.pow(a/f,1/o))-vd),-85.051129,as);return new ui(y,this.southernCenter?-v:v)}}class xv extends Fc{constructor(e){super(e),this.wrap=!0,this.supportsWorldCopies=!0,this.supportsTerrain=!0,this.supportsFog=!0,this.supportsFreeCamera=!0,this.isReprojectedInTileSpace=!1,this.unsupportedLayers=[],this.range=null}project(e,i){return{x:Ss(e),y:vn(i),z:0}}unproject(e,i){const o=$r(e),a=on(i);return new ui(o,a)}}const vv=Qt(as);class Y1 extends Fc{project(e,i){const o=(i=Qt(i))*i,a=o*o;return{x:.5*((e=Qt(e))*(.8707-.131979*o+a*(a*(.003971*o-.001529*a)-.013791))/Math.PI+.5),y:1-.5*(i*(1.007226+o*(.015085+a*(.028874*o-.044475-.005916*a)))/Math.PI+1),z:0}}unproject(e,i){e=(2*e-.5)*Math.PI;let o=i=(2*(1-i)-1)*Math.PI,a=25,c=0,h=o*o;do{h=o*o;const y=h*h;c=(o*(1.007226+h*(.015085+y*(.028874*h-.044475-.005916*y)))-i)/(1.007226+h*(.045255+y*(.259866*h-.311325-.005916*11*y))),o=Y(o-c,-vv,vv)}while(Math.abs(c)>1e-6&&--a>0);h=o*o;const f=Y(en(e/(.8707+h*(h*(h*h*h*(.003971-.001529*h)-.013791)-.131979))),-180,180),_=en(o);return new ui(f,_)}}const bv=Qt(as);class K1 extends Fc{project(e,i){i=Qt(i),e=Qt(e);const o=Math.cos(i),a=2/Math.PI,c=Math.acos(o*Math.cos(e/2)),h=Math.sin(c)/c,f=.5*(e*a+2*o*Math.sin(e/2)/h)||0,_=.5*(i+Math.sin(i)/h)||0;return{x:.5*(f/Math.PI+.5),y:1-.5*(_/Math.PI+1),z:0}}unproject(e,i){let o=e=(2*e-.5)*Math.PI,a=i=(2*(1-i)-1)*Math.PI,c=25;const h=1e-6;let f=0,_=0;do{const y=Math.cos(a),v=Math.sin(a),b=2*v*y,T=v*v,E=y*y,C=Math.cos(o/2),P=Math.sin(o/2),R=2*C*P,z=P*P,V=1-E*C*C,N=V?1/V:0,U=V?Math.acos(y*C)*Math.sqrt(1/V):0,q=.5*(2*U*y*P+2*o/Math.PI)-e,W=.5*(U*v+a)-i,se=.5*N*(E*z+U*y*C*T)+1/Math.PI,X=N*(R*b/4-U*v*P),ie=.125*N*(b*P-U*v*E*R),re=.5*N*(T*C+U*z*y)+.5,oe=X*ie-re*se;f=(W*X-q*re)/oe,_=(q*ie-W*se)/oe,o=Y(o-f,-Math.PI,Math.PI),a=Y(a-_,-bv,bv)}while((Math.abs(f)>h||Math.abs(_)>h)&&--c>0);return new ui(en(o),en(a))}}class wv extends Fc{constructor(e){super(e),this.center=e.center||[0,0],this.parallels=e.parallels||[0,0],this.cosPhi=Math.max(.01,Math.cos(Qt(this.parallels[0]))),this.scale=1/(2*Math.max(Math.PI*this.cosPhi,1/this.cosPhi)),this.wrap=!0,this.supportsWorldCopies=!0}project(e,i){const{scale:o,cosPhi:a}=this;return{x:Qt(e)*a*o+.5,y:-Math.sin(Qt(i))/a*o+.5,z:0}}unproject(e,i){const{scale:o,cosPhi:a}=this,c=-(i-.5)/o,h=Y(en((e-.5)/o)/a,-180,180),f=Math.asin(Y(c*a,-1,1)),_=Y(en(f),-85.051129,as);return new ui(h,_)}}class J1 extends xv{constructor(e){super(e),this.requiresDraping=!0,this.supportsWorldCopies=!1,this.supportsFog=!0,this.zAxisUnit="pixels",this.unsupportedLayers=["debug"],this.range=[3,5]}projectTilePoint(e,i,o){const a=wp(e,i,o);return ir(a,a,Z_(Qa(o))),{x:a[0],y:a[1],z:a[2]}}locationPoint(e,i,o){const a=Rl(i.lat,i.lng),c=Mi([],a),h=o?e._centerAltitude+o:e.elevation?e.elevation.getAtPointOrZero(e.locationCoordinate(i),e._centerAltitude):e._centerAltitude;Kr(a,a,c,Wn(1,0)*rt*h);const f=Si(new Float64Array(16));return Ni(f,e.pixelMatrix,e.globeMatrix),ir(a,a,f),new Ue(a[0],a[1])}pixelsPerMeter(e,i){return Wn(1,0)*i}pixelSpaceConversion(e,i,o){const a=Wn(1,e)*i,c=vt(Wn(1,45)*i,a,o);return this.pixelsPerMeter(e,i)/c}createTileMatrix(e,i,o){const a=Jy(Qa(o.canonical));return Ni(new Float64Array(16),e.globeMatrix,a)}createInversionMatrix(e,i){const{center:o}=e,a=Z_(Qa(i));return Pn(a,a,Qt(o.lng)),gn(a,a,Qt(o.lat)),_n(a,a,[e._pixelsPerMercatorPixel,e._pixelsPerMercatorPixel,1]),Float32Array.from(a)}
vendor: 123,941 bytes, line 7
7pointCoordinate(e,i,o,a){return uv(e,i,o,!0)||new kn(0,0)}pointCoordinate3D(e,i,o){const a=this.pointCoordinate(e,i,o,0);return[a.x,a.y,a.z]}isPointAboveHorizon(e,i){return!uv(e,i.x,i.y,!1)}farthestPixelDistance(e){const i=(function(a,c){const h=a.cameraToCenterDistance,f=a._centerAltitude*c,_=a._camera,y=a._camera.forward(),v=ji([],li([],y,-h),[0,0,f]),b=a.worldSize/(2*Math.PI),T=[0,0,-b],E=a.width/a.height,C=Math.tan(a.fovAboveCenter),P=li([],_.up(),C),R=li([],_.right(),C*E),z=Mi([],ji([],ji([],y,P),R)),V=[];let N;if(new Hy(v,z).closestPointOnSphere(T,b,V)){const U=ji([],V,T),q=Zi([],U,v);N=Math.cos(a.fovAboveCenter)*Yr(q)}else{const U=Zi([],v,T),q=Zi([],T,v);Mi(q,q);const W=Yr(U)-b;N=Math.sqrt(W*(W+2*b));const se=Math.acos(N/(b+W))-Math.acos(qi(y,q));N*=Math.cos(se)}return 1.01*N})(e,this.pixelsPerMeter(e.center.lat,e.worldSize)),o=zc(e.zoom);if(o>0){const a=gv(e,Wn(1,e.center.lat)*e.worldSize),c=e.worldSize/(2*Math.PI),h=Math.max(e.width,e.height)/e.worldSize*Math.PI;return vt(i,a+c*(1-Math.cos(h)),Math.pow(o,10))}return i}upVector(e,i,o){return wp(i,o,e,1)}upVectorScale(e){return{metersToTile:G_(q_(Qa(e)))}}}function Tv(r){const e=r.parallels,i=!!e&&Math.abs(e[0]+e[1])<.01;switch(r.name){case"mercator":return new xv(r);case"equirectangular":return new W1(r);case"naturalEarth":return new Y1(r);case"equalEarth":return new Z1(r);case"winkelTripel":return new K1(r);case"albers":return i?new wv(r):new H1(r);case"lambertConformalConic":return i?new wv(r):new X1(r);case"globe":return new J1(r)}throw new Error(`Invalid projection name: ${r.name}`)}const Cp=Number.MAX_SAFE_INTEGER,Q1=Cp-1;function Sv(r,e,i,o){return r.order<e||r.order===Cp||!(r.clipMask&i)||(function(a,c){if(c.length===0)return!1;let h=a;for(;h!=="";){if(c.includes(h))return!1;h=Il(h)}return!0})(o,r.clipScope)}function Y_(r,e){return r.x-e.x||r.y-e.y}function Ev(r,e){return Y_(r.min,e.min)===0&&Y_(r.max,e.max)===0}function ix(r,e){return!(r.min.x>e.max.x||r.max.x<e.min.x||r.min.y>e.max.y||r.max.y<e.min.y)}function K_(r,e){if(r.length!==e.length)return!1;for(let i=0;i<r.length;i++)if(r[i].sourceId!==e[i].sourceId||!Ev(r[i],e[i])||r[i].order!==e[i].order||r[i].clipMask!==e[i].clipMask||!ro(r[i].clipScope,e[i].clipScope))return!1;return!0}function Iv(r,e,i){const o=1/rt,a=1/(1<<i.canonical.z),c=(e.x*o+i.canonical.x)*a+i.wrap,h=(e.y*o+i.canonical.y)*a;return{min:new Ue((r.x*o+i.canonical.x)*a+i.wrap,(r.y*o+i.canonical.y)*a),max:new Ue(c,h)}}function ew(r,e,i){const o=1<<i.canonical.z,a=((e.x-i.wrap)*o-i.canonical.x)*rt,c=(e.y*o-i.canonical.y)*rt;return{min:new Ue(((r.x-i.wrap)*o-i.canonical.x)*rt,(r.y*o-i.canonical.y)*rt),max:new Ue(a,c)}}function rx(r,e,i,o,a,c,h){const f=r.indices,_=r.vertices,y=[];for(let v=o;v<o+a;v+=3){const b=e[i[v+0]+c],T=e[i[v+1]+c],E=e[i[v+2]+c],C=Math.min(b.x,T.x,E.x),P=Math.max(b.x,T.x,E.x),R=Math.min(b.y,T.y,E.y),z=Math.max(b.y,T.y,E.y);y.length=0,r.grid.query(new Ue(C,R),new Ue(P,z),y);for(let V=0;V<y.length;V++){const N=y[V];if(dd(_[f[3*N+0]],_[f[3*N+1]],_[f[3*N+2]],b,T,E,h))return!0}}return!1}function Av(r,e,i,o){if(!r||!i)return!1;let a=r.vertices;if(!e.canonical.equals(o.canonical)||e.wrap!==o.wrap){if(i.vertices.length<r.vertices.length)return Av(i,o,r,e);const c=e.canonical,h=o.canonical,f=Math.pow(2,h.z-c.z);a=r.vertices.map(_=>new Ue((_.x+c.x*rt)*f-h.x*rt,(_.y+c.y*rt)*f-h.y*rt))}return rx(i,a,r.indices,0,r.indices.length,0,0)}function Cv(r,e,i,o){const a=Math.pow(2,o.z-i.z);return new Ue((r+i.x*rt)*a-o.x*rt,(e+i.y*rt)*a-o.y*rt)}function Mv(r,e){const i=[];e.grid.queryPoint(r,i);const o=e.indices,a=e.vertices;for(let c=0;c<i.length;c++){const h=i[c];if(na([a[o[3*h+0]],a[o[3*h+1]],a[o[3*h+2]]],r))return!0}return!1}class tw{constructor(e,i){this.lastParams=null,this.lastAllFeaturesIndex=-2,this.appearancesVersion=i,this.appearances=e;const o=e.map(a=>(function(c){if(!c.condition)return{featureDependent:!1,stateDependent:!1,zoomDependent:!1,pitchDependent:!1,brightnessDependent:!1,worldviewDependent:!1};const h=c.condition.expression;return{featureDependent:!Fa(h),stateDependent:!gl(h),zoomDependent:!Oa(h,["zoom"]),pitchDependent:!Oa(h,["pitch"]),brightnessDependent:!Oa(h,["brightness","measure-light"]),worldviewDependent:!Oa(h,["worldview"])}})(a));this.anyFeatureDependent=o.some(a=>a.featureDependent),this.anyStateDependent=o.some(a=>a.stateDependent)}update(e,i){const o=this.lastParams,a=!o||o.zoom!==e.zoom||o.pitch!==(e.pitch||0)||o.brightness!==(e.brightness||0)||o.worldview!==e.worldview;this.lastParams={zoom:e.zoom,pitch:e.pitch||0,brightness:e.brightness||0,worldview:e.worldview};const c=i&&this.anyStateDependent;if(!a&&!c&&this.lastAllFeaturesIndex!==-2)return{kind:"no-changes"};if(!this.anyFeatureDependent&&!c){const h=this.evaluateAllFeatures(e);return h===this.lastAllFeaturesIndex?{kind:"no-changes"}:(this.lastAllFeaturesIndex=h,{kind:"all-features",appearanceIndex:h})}return{kind:"per-feature"}}evaluateAllFeatures(e){for(let i=0;i<this.appearances.length;i++){const o=this.appearances[i];if(o.condition&&o.condition.evaluate(e,void 0,void 0,void 0))return i}return-1}}const iw=Za.types,rw=[{name:"a_fade_opacity",components:1,type:"Uint8",offset:0}];function Mp(r,e,i,o,a,c,h,f,_,y,v,b,T){const E=f?Math.min(Bu,Math.round(f[0])):0,C=f?Math.min(Bu,Math.round(f[1])):0;r.emplaceBack(e,i,Math.round(32*o),Math.round(32*a),c,h,(E<<1)+(_?1:0),0+(C<<1),16*y,16*v,256*b,256*T)}function Pp(r,e,i){r.emplaceBack(e,i)}function Rp(r,e,i,o,a,c,h){r.emplaceBack(e,i,o,a,c,h)}function bd(r,e,i,o,a){r.emplaceBack(e,i,o,a),r.emplaceBack(e,i,o,a),r.emplaceBack(e,i,o,a),r.emplaceBack(e,i,o,a)}function nw(r){for(const e of r.sections)if(Ym(e.text))return!0;return!1}const wd=12;class nx{constructor(e){this.layoutVertexArray=new Hh,this.indexArray=new sn,this.programConfigurations=e,this.segments=new Fi,this.dynamicLayoutVertexArray=new ga,this.opacityVertexArray=new Xf,this.placedSymbolArray=new m_,this.iconTransitioningVertexArray=new us,this.globeExtVertexArray=new Zh,this.zOffsetVertexArray=new Js,this.orientationVertexArray=new Yh,this.symbolInstanceIndices=[],this.uboBinder=null,this.featureIdArray=new Js,this.featureIdBuffer=null,this.cachedBatchIndices=null,this.cachedBatchSegments=null}isEmpty(){return this.layoutVertexArray.length===0&&this.indexArray.length===0&&this.dynamicLayoutVertexArray.length===0&&this.opacityVertexArray.length===0&&this.iconTransitioningVertexArray.length===0}getBatchGrouping(e){const i=e.get().length===this.segments.get().length;if(i&&this.cachedBatchIndices&&this.cachedBatchSegments)return{batchIndices:this.cachedBatchIndices,batchSegments:this.cachedBatchSegments};const o=new Map;for(const h of e.get()){const f=h.batchIndex!==void 0?h.batchIndex:0;o.has(f)||o.set(f,[]),o.get(f).push(h)}const a=Array.from(o.keys()).sort((h,f)=>h-f),c=new Map;for(const h of a){const f=o.get(h);c.set(h,new Fi(f))}return i&&(this.cachedBatchIndices=a,this.cachedBatchSegments=c),{batchIndices:a,batchSegments:c}}snapshotSymbolVertexData(e,i){const o=e*wd;return this.layoutVertexArray.uint16.slice(o,o+i*wd)}restoreSymbolVertexData(e,i){this.layoutVertexArray.uint16.set(i,e*wd)}snapshotIconTransitioningVertexData(e,i){const o=2*e;return this.iconTransitioningVertexArray.uint16.slice(o,o+2*i)}restoreIconTransitioningVertexData(e,i){this.iconTransitioningVertexArray.uint16.set(i,2*e)}updateSymbolVertexData(e,i,o,a,c,h,f,_,y,v,b,T,E){const C=this.layoutVertexArray.uint16,P=e*wd;C[P]=i,C[P+1]=o,C[P+2]=a,C[P+3]=c,C[P+4]=h,C[P+5]=f,C[P+6]=_,C[P+7]=y,C[P+8]=v,C[P+9]=b,C[P+10]=T,C[P+11]=E}upload(e,i,o,a,c,h){this.isEmpty()||(o&&(this.cachedBatchIndices=null,this.cachedBatchSegments=null,this.layoutVertexBuffer=e.createVertexBuffer(this.layoutVertexArray,D_.members,!!h),this.indexBuffer=e.createIndexBuffer(this.indexArray,i),this.dynamicLayoutVertexBuffer=e.createVertexBuffer(this.dynamicLayoutVertexArray,Dy.members,!0),this.opacityVertexBuffer=e.createVertexBuffer(this.opacityVertexArray,rw,!0),this.iconTransitioningVertexArray.length>0&&(this.iconTransitioningVertexBuffer=e.createVertexBuffer(this.iconTransitioningVertexArray,Fy.members,!0)),this.globeExtVertexArray.length>0&&(this.globeExtVertexBuffer=e.createVertexBuffer(this.globeExtVertexArray,L_.members,!0)),!this.zOffsetVertexBuffer&&(this.zOffsetVertexArray.length>0||c)&&(this.zOffsetVertexBuffer=e.createVertexBuffer(this.zOffsetVertexArray,Ly.members,!0)),!this.orientationVertexBuffer&&this.orientationVertexArray&&this.orientationVertexArray.length>0&&(this.orientationVertexBuffer=e.createVertexBuffer(this.orientationVertexArray,zy.members,!0)),this.opacityVertexBuffer.itemSize=1,this.featureIdArray.length>0&&(this.featureIdBuffer=e.createVertexBuffer(this.featureIdArray,z_.members,!1))),(o||a)&&(this.programConfigurations.upload(e),this.uboBinder&&this.uboBinder.upload(e)))}destroy(){this.layoutVertexBuffer&&(this.layoutVertexBuffer.destroy(),this.indexBuffer.destroy(),this.programConfigurations.destroy(),this.segments.destroy(),this.dynamicLayoutVertexBuffer.destroy(),this.opacityVertexBuffer.destroy(),this.iconTransitioningVertexBuffer&&this.iconTransitioningVertexBuffer.destroy(),this.globeExtVertexBuffer&&this.globeExtVertexBuffer.destroy(),this.zOffsetVertexBuffer&&this.zOffsetVertexBuffer.destroy(),this.orientationVertexBuffer&&this.orientationVertexBuffer.destroy(),this.featureIdBuffer&&this.featureIdBuffer.destroy(),this.uboBinder&&this.uboBinder.destroy())}}nt(nx,"SymbolBuffers",{omit:["cachedBatchIndices","cachedBatchSegments"]});class ox{constructor(e,i,o){this.layoutVertexArray=new e,this.layoutAttributes=i,this.indexArray=new o,this.segments=new Fi,this.collisionVertexArray=new Jf,this.collisionVertexArrayExt=new ga}upload(e){this.layoutVertexBuffer=e.createVertexBuffer(this.layoutVertexArray,this.layoutAttributes),this.indexBuffer=e.createIndexBuffer(this.indexArray),this.collisionVertexBuffer=e.createVertexBuffer(this.collisionVertexArray,Oy.members,!0),this.collisionVertexBufferExt=e.createVertexBuffer(this.collisionVertexArrayExt,ky.members,!0)}destroy(){this.layoutVertexBuffer&&(this.layoutVertexBuffer.destroy(),this.indexBuffer.destroy(),this.segments.destroy(),this.collisionVertexBuffer.destroy(),this.collisionVertexBufferExt.destroy())}}nt(ox,"CollisionBuffers");class J_{constructor(e){this.collisionBoxArray=e.collisionBoxArray,this.zoom=e.zoom,this.overscaling=e.overscaling,this.layers=e.layers,this.layerIds=this.layers.map(h=>h.fqid),this.index=e.index,this.pixelRatio=e.pixelRatio,this.sourceLayerIndex=e.sourceLayerIndex,this.hasPattern=!1,this.hasRTLText=!1,this.fullyClipped=!1,this.hasAnyIconTextFit=!1,this.sortKeyRanges=[],this.collisionCircleArray=[],this.placementInvProjMatrix=Si([]),this.placementViewportMatrix=Si([]);const i=this.layers[0]._unevaluatedLayout._values;this.worldview=e.worldview,this.localizable=e.localizable,this.maxUniformBufferBindings=e.maxUniformBufferBindings,this.maxUniformBlockSizeDwords=e.maxUniformBlockSizeDwords,this.textSizeData=Ae(this.zoom,i["text-size"],this.worldview,e.availableImages),this.iconSizeData=Ae(this.zoom,i["icon-size"],this.worldview,e.availableImages);const o=this.layers[0].layout,a=o.get("symbol-sort-key"),c=o.get("symbol-z-order");this.lut=e.lut,this.canOverlap=o.get("text-allow-overlap")||o.get("icon-allow-overlap")||o.get("text-ignore-placement")||o.get("icon-ignore-placement"),this.sortFeaturesByKey=c!=="viewport-y"&&a.constantOr(1)!==void 0,this.sortFeaturesByY=(c==="viewport-y"||c==="auto"&&!this.sortFeaturesByKey)&&this.canOverlap,this.writingModes=o.get("text-writing-mode").map(h=>M[h]),this.stateDependentLayerIds=this.layers.filter(h=>h.isStateDependent()).map(h=>h.id),this.sourceID=e.sourceID,this.projection=e.projection,this.hasAnyZOffset=!1,this.zOffsetSortDirty=!1,this.zOffsetBuffersNeedUpload=!1,this.elevationType="none",this.activeReplacements=[],this.replacementUpdateTime=0,this.hasAnySecondaryIcon=!1,this.hasAppearances=null,this.featureAppearances=null,this.featureAppearanceData=new Map}hasAnyAppearanceLayoutProperty(e){const i=this.layers[0].getAppearances();if(!i||i.length===0)return!1;const o=Array.isArray(e)?e:[e];return i.some(a=>o.some(c=>a.hasLayoutProperty(c)))}getAppearanceFeatureData(e){return this.featureAppearanceData.get(e)}createArrays(){this.text=new nx(new hs(this.layers,{zoom:this.zoom,lut:this.lut},e=>e.startsWith("text")||e.startsWith("symbol"))),this.icon=new nx(new hs(this.layers,{zoom:this.zoom,lut:this.lut},e=>e.startsWith("icon")||e.startsWith("symbol"))),this.text.uboBinder=new Ka(this.layers[0],this.zoom,this.lut,!0,"",this.maxUniformBufferBindings,this.maxUniformBlockSizeDwords),this.icon.uboBinder=new Ka(this.layers[0],this.zoom,this.lut,!1,"",this.maxUniformBufferBindings,this.maxUniformBlockSizeDwords),this.glyphOffsetArray=new rd,this.lineVertexArray=new rp,this.symbolInstances=new id}calculateGlyphDependencies(e,i,o,a,c){for(const h of e){const f=h.codePointAt(0);if(f===void 0)break;if(i[f]=!0,a&&c&&f<=65535){const _=ku[h];_&&(i[_.charCodeAt(0)]=!0)}}}calculateEffectiveAppearanceIconSize(e,i,o,a,c,h,f){if(!e.hasLayoutProperty("icon-size"))return f*h;let _=1;const y=e.getUnevaluatedLayoutProperty("icon-size"),v=Ae(this.zoom,y,this.worldview,c),b=Fe(v,i);if(v.kind!=="constant"&&v.kind!=="camera"||(_=b.uSize),v.kind==="composite"){const{minZoom:T,maxZoom:E}=v,C=y.possiblyEvaluate(new xt(T,{worldview:this.worldview}),a),P=y.possiblyEvaluate(new xt(E,{worldview:this.worldview}),a),R=C.evaluate(o,{},a,c);_=R+(P.evaluate(o,{},a,c)-R)*b.uSizeT}return v.kind==="source"&&(_=y.possiblyEvaluate(new xt(this.zoom,{worldview:this.worldview}),a).evaluate(o,{},a,c)),_*h}updateFootprints(e,i){}updateReplacement(e,i){if(i.updateTime===this.replacementUpdateTime)return!1;this.replacementUpdateTime=i.updateTime;const o=i.getReplacementRegionsForTile(e.toUnwrapped(),!0);return!K_(this.activeReplacements,o)&&(this.activeReplacements=o,!0)}getResolvedImageFromTokens(e){return typeof e=="string"?nn.build(e):e}populate(e,i,o,a){const c=this.layers[0],h=c.layout,f=this.projection.name==="globe",_=h.get("text-font"),y=h.get("text-field"),v=h.get("icon-image"),[b,T]=h.get("icon-size-scale-range"),E=Y(i.scaleFactor||1,b,T),[C,P]=h.get("text-size-scale-range"),R=Y(i.scaleFactor||1,C,P),z=(y.value.kind!=="constant"||y.value.value instanceof rn&&!y.value.value.isEmpty()||y.value.value.toString().length>0)&&(_.value.kind!=="constant"||_.value.value.length>0),V=v.value.kind!=="constant"||!!v.value.value||Object.keys(v.parameters).length>0,N=this.hasAnyAppearanceLayoutProperty("icon-image"),U=h.get("symbol-sort-key");if(this.features=[],this.featureAppearanceData=new Map,!z&&!V&&!N)return;const q=i.iconDependencies,W=i.glyphDependencies,se=i.availableImages,X=new xt(this.zoom,{worldview:this.worldview,activeFloors:i.activeFloors}),ie=re=>{const oe=re.id.toString();q.has(oe)?q.get(oe).push(re):q.set(oe,[re])};for(const re of e){const{feature:oe,id:me,index:xe,sourceLayerIndex:we}=re,Ce=c._featureFilter.needGeometry,Se=Vo(oe,Ce);if(!c._featureFilter.filter(X,Se,o))continue;if(Ce||(Se.geometry=ls(oe,o,a)),f&&oe.type!==1&&o.z<=5){const ze=Se.geometry,He=.98078528056,Ye=(st,Je)=>qi(wp(st.x,st.y,o,1),wp(Je.x,Je.y,o,1))<He;for(let st=0;st<ze.length;st++)ze[st]=ay(ze[st],Ye)}let qe,Me;if(z){const ze=c.getValueAndResolveTokens("text-field",Se,o,se),He=rn.factory(ze);nw(He)&&(this.hasRTLText=!0),(!this.hasRTLText||Rh()==="unavailable"||this.hasRTLText&&Ys.isParsed())&&(qe=Ny(He,c,Se))}if(V){const ze=c.getValueAndResolveTokens("icon-image",Se,o,se);Me=this.getResolvedImageFromTokens(ze)}const Ie=this.layers[0];let Pe=!1;if(!Me&&N){const ze=Ie.getAppearances();for(const He of ze)if(He.getLayoutProperty("icon-image")){const Ye=Ie.getAppearanceValueAndResolveTokens(He,"icon-image",Se,o,se);if(Ye){Me=this.getResolvedImageFromTokens(Ye),Pe=!0;break}}}if(!qe&&!Me)continue;const Ne=this.sortFeaturesByKey?U.evaluate(Se,{},o):void 0,ke={id:me,text:qe,icon:Me,index:xe,sourceLayerIndex:we,geometry:Se.geometry,properties:oe.properties,type:iw[oe.type],sortKey:Ne};if(this.features.push(ke),this.featureAppearanceData.set(xe,{id:me,properties:oe.properties,usesAppearanceIconAsPlaceholder:Pe}),Me){const ze=Ie._unevaluatedLayout._values,{iconPrimary:He,iconSecondary:Ye}=va(Me,this.iconSizeData,ze["icon-size"],o,this.zoom,ke,this.pixelRatio,E,this.worldview,se);ie(He),Ye&&(this.hasAnySecondaryIcon=!0,ie(Ye))}const $e=Ie.getAppearances();if($e.length!==0&&$e.forEach(ze=>{if(!ze.getLayoutProperty("icon-image"))return;const{iconPrimary:He,iconSecondary:Ye}=this.getCombinedIconVariants(ze,Ie,Se,o,se,ke,E);He&&(ie(He),Ye&&(this.hasAnySecondaryIcon=!0,ie(Ye)))}),qe){const ze=_.evaluate(Se,{},o).join(","),He=h.get("text-rotation-alignment")==="map"&&h.get("symbol-placement")!=="point";this.allowVerticalPlacement=this.writingModes&&this.writingModes.includes(M.vertical);for(const Ye of qe.sections)if(Ye.image){const st=Ye.image.getPrimary().scaleSelf(this.pixelRatio*R),Je=st.id.toString(),Qe=q.get(Je)||[];Qe.push(st),q.set(Je,Qe)}else{const st=Tl(qe.toString()),Je=Ye.fontStack||ze,Qe=W[Je]=W[Je]||{};this.calculateGlyphDependencies(Ye.text,Qe,He,this.allowVerticalPlacement,st)}}}h.get("symbol-placement")==="line"&&(this.features=(function(re){const oe={},me={},xe=[];let we=0;function Ce(Ie){xe.push(re[Ie]),we++}function Se(Ie,Pe,Ne){const ke=me[Ie];return delete me[Ie],me[Pe]=ke,xe[ke].geometry[0].pop(),xe[ke].geometry[0]=xe[ke].geometry[0].concat(Ne[0]),ke}function qe(Ie,Pe,Ne){const ke=oe[Pe];return delete oe[Pe],oe[Ie]=ke,xe[ke].geometry[0].shift(),xe[ke].geometry[0]=Ne[0].concat(xe[ke].geometry[0]),ke}function Me(Ie,Pe,Ne){const ke=Ne?Pe[0].at(-1):Pe[0][0];return`${Ie}:${ke.x}:${ke.y}`}for(let Ie=0;Ie<re.length;Ie++){const Pe=re[Ie],Ne=Pe.geometry,ke=Pe.text?Pe.text.toString():null;if(!ke||Ne.length>1){Ce(Ie);continue}const $e=Me(ke,Ne,!1),ze=Me(ke,Ne,!0);if($e in me&&ze in oe&&me[$e]!==oe[ze]){const He=qe($e,ze,Ne),Ye=Se($e,ze,xe[He].geometry);delete oe[$e],delete me[ze],me[Me(ke,xe[Ye].geometry,!0)]=Ye,xe[He].geometry=null}else $e in me?Se($e,ze,Ne):ze in oe?qe($e,ze,Ne):(Ce(Ie),oe[$e]=we-1,me[ze]=we-1)}return xe.filter(Ie=>Ie.geometry)})(this.features)),h.get("symbol-elevation-reference")==="hd-road-markup"?(this.elevationType="road",this.hdExt&&(this.hdExt.configureCrossSource(o,i.elevationParams,i.crossSourceElevationEnabled,i.terrainEnabled),i.elevationFeatures&&i.elevationFeatures.length>0&&this.hdExt.addElevationFeatures(i.elevationFeatures,o))):h.get("symbol-z-elevate")&&(this.elevationType="offset"),this.elevationType!=="none"&&(this.zOffsetBuffersNeedUpload=!0),this.sortFeaturesByKey&&this.features.sort((re,oe)=>re.sortKey-oe.sortKey)}getCombinedIconVariants(e,i,o,a,c,h,f){let _;if(e.hasLayoutProperty("icon-image")){const y=i.getAppearanceValueAndResolveTokens(e,"icon-image",o,a,c);_=this.getResolvedImageFromTokens(y)}else{const y=i.getValueAndResolveTokens("icon-image",o,a,c);_=this.getResolvedImageFromTokens(y)}if(_){const y=e.hasLayoutProperty("icon-size")?e.getUnevaluatedLayoutProperty("icon-size"):i._unevaluatedLayout._values["icon-size"],v=Ae(this.zoom,y,this.worldview,c),{iconPrimary:b,iconSecondary:T}=va(_,v,y,a,this.zoom,h,this.pixelRatio,f,this.worldview,c);return{iconPrimary:b,iconSecondary:T}}return{iconPrimary:void 0,iconSecondary:void 0}}getCombinedIconPrimary(e,i,o,a,c,h,f){return this.getCombinedIconVariants(e,i,o,a,c,h,f).iconPrimary}updateSymbolInstanceIconVertices(e,i,o,a,c,h){const{canonical:f,availableImages:_,globalProperties:y,layer:v,iconScaleFactor:b,featureState:T,layoutIconOffset:E,layoutIconSize:C,layoutIconRotate:P}=h;if(e.placedIconSymbolIndex<0)return{vertexOffsetDelta:0,hasChanges:!1};if(i.activeAppearanceIndex===o)return{vertexOffsetDelta:e.numIconVertices,hasChanges:!1};const R=o>=0?v.appearances[o]:null;if(R){const z={sortKey:void 0,text:void 0,icon:null,index:e.featureIndex,sourceLayerIndex:e.featureIndex,geometry:[],properties:i.properties,type:"Point",id:i.id},{iconPrimary:V,iconSecondary:N}=this.getCombinedIconVariants(R,v,a,f,_,z,b);if(!V)return{vertexOffsetDelta:0,hasChanges:!1};const U=V.toString(),q=this.iconAtlasPositions&&this.iconAtlasPositions.get(U);if(q){const{appearanceIconOffset:W,appearanceIconRotate:se}=Xn(R,v,a,f,E,P,C,b),X=v.layout.get("icon-anchor").evaluate(a,T,f);let ie=de(q,N?this.iconAtlasPositions&&this.iconAtlasPositions.get(N.toString()):void 0,W,X);const re=q.sdf,oe=v.layout.get("icon-text-fit").constantOr("none");oe!=="none"&&i.textShaping&&i.iconTextFitPadding&&i.fontScale&&(ie=fe(ie,i.textShaping,oe,i.iconTextFitPadding,W,i.fontScale));const me=this.calculateEffectiveAppearanceIconSize(R,y.zoom,a,f,_,b,C),xe=0,we=1+(Math.min(Bu,Math.round(me*ye))<<1),Ce=kr(ie,se,re,oe!=="none",b),Se=this.icon.iconTransitioningVertexArray.length>0;i.isUsingAppearanceIconVertexData||(i.isUsingAppearanceIconVertexData=!0,i.layoutBasedIconVertexData=this.icon.snapshotSymbolVertexData(c,e.numIconVertices),Se&&(i.layoutBasedIconTransitioningVertexData=this.icon.snapshotIconTransitioningVertexData(c,e.numIconVertices)));const qe=Math.floor(e.numIconVertices/4),Me=Math.min(Ce.length,qe);let Ie=c;const Pe=Se?this.icon.iconTransitioningVertexArray.uint16:null;for(let ke=0;ke<Me;++ke){const $e=Ce[ke],ze=i.layoutBasedIconVertexData[0]||e.tileAnchorX,He=i.layoutBasedIconVertexData[1]||e.tileAnchorY,Ye=16*$e.pixelOffsetTL.x,st=16*$e.pixelOffsetTL.y,Je=16*$e.pixelOffsetBR.x,Qe=16*$e.pixelOffsetBR.y,dt=16*$e.minFontScaleX,wt=16*$e.minFontScaleY;if(this.icon.updateSymbolVertexData(Ie,ze,He,Math.round(32*$e.tl.x),Math.round(32*$e.tl.y),$e.texPrimary.x,$e.texPrimary.y,xe,we,Ye,st,dt,wt),this.icon.updateSymbolVertexData(Ie+1,ze,He,Math.round(32*$e.tr.x),Math.round(32*$e.tr.y),$e.texPrimary.x+$e.texPrimary.w,$e.texPrimary.y,xe,we,Je,st,dt,wt),this.icon.updateSymbolVertexData(Ie+2,ze,He,Math.round(32*$e.bl.x),Math.round(32*$e.bl.y),$e.texPrimary.x,$e.texPrimary.y+$e.texPrimary.h,xe,we,Ye,Qe,dt,wt),this.icon.updateSymbolVertexData(Ie+3,ze,He,Math.round(32*$e.br.x),Math.round(32*$e.br.y),$e.texPrimary.x+$e.texPrimary.w,$e.texPrimary.y+$e.texPrimary.h,xe,we,Je,Qe,dt,wt),Pe){const Bt=$e.texSecondary?$e.texSecondary:$e.texPrimary,lt=2*Ie;Pe[lt]=Bt.x,Pe[lt+1]=Bt.y,Pe[lt+2]=Bt.x+Bt.w,Pe[lt+3]=Bt.y,Pe[lt+4]=Bt.x,Pe[lt+5]=Bt.y+Bt.h,Pe[lt+6]=Bt.x+Bt.w,Pe[lt+7]=Bt.y+Bt.h}Ie+=4}const Ne=e.numIconVertices-4*Me;for(let ke=0;ke<Ne;++ke)this.icon.updateSymbolVertexData(Ie+ke,0,0,0,0,0,0,0,0,0,0,0,0);return{vertexOffsetDelta:e.numIconVertices,hasChanges:!0}}}else{if(i.usesAppearanceIconAsPlaceholder)return this.icon.updateSymbolVertexData(c,0,0,0,0,0,0,0,0,0,0,0,0),this.icon.updateSymbolVertexData(c+1,0,0,0,0,0,0,0,0,0,0,0,0),this.icon.updateSymbolVertexData(c+2,0,0,0,0,0,0,0,0,0,0,0,0),this.icon.updateSymbolVertexData(c+3,0,0,0,0,0,0,0,0,0,0,0,0),{vertexOffsetDelta:e.numIconVertices,hasChanges:!0};if(i.isUsingAppearanceIconVertexData)return this.icon.restoreSymbolVertexData(c,i.layoutBasedIconVertexData),i.layoutBasedIconTransitioningVertexData&&this.icon.restoreIconTransitioningVertexData(c,i.layoutBasedIconTransitioningVertexData),i.isUsingAppearanceIconVertexData=!1,{vertexOffsetDelta:i.layoutBasedIconVertexData.length/wd,hasChanges:!0}}return{vertexOffsetDelta:e.numIconVertices,hasChanges:!1}}updateSymbolInstanceTextVertices(e,i,o,a,c,h){const{canonical:f,layer:_,textScaleFactor:y,imageMap:v,featureState:b,layoutTextOffset:T,layoutTextSize:E,layoutTextRotate:C,layoutMinZoomSize:P,layoutMaxZoomSize:R,layoutTextSizeMinZoom:z,layoutTextSizeMaxZoom:V,availableImages:N}=h,U=e.numHorizontalGlyphVertices>0||e.numVerticalGlyphVertices>0;if(!U)return{vertexOffsetDelta:U?e.numHorizontalGlyphVertices+e.numVerticalGlyphVertices:0,hasChanges:!1};if(i.activeAppearanceIndex===o)return{vertexOffsetDelta:e.numHorizontalGlyphVertices+e.numVerticalGlyphVertices,hasChanges:!1};const q=o>=0?_.appearances[o]:null;if(q&&i.textShaping){const{appearanceTextOffset:W,appearanceTextRotate:se,appearanceTextSize:X}=In(q,_,a,f,T,C,E);i.fontScale=nv(X,i.textScaleFactor);const ie=q.getUnevaluatedLayoutProperty("text-size");let re=this.textSizeData,oe=z,me=V;q.hasLayoutProperty("text-size")&&(re=Ae(this.zoom,ie,this.worldview,N),oe=this.textSizeData.kind==="composite"?this.textSizeData.minZoom:0,me=this.textSizeData.kind==="composite"?this.textSizeData.maxZoom:0);const xe=i.textShaping.bottom-T[1],we=i.textShaping.left-T[0],Ce=i.textShaping.right-T[0];i.textShaping.top=W[1]+(i.textShaping.top-T[1]),i.textShaping.bottom=W[1]+xe,i.textShaping.left=W[0]+we,i.textShaping.right=W[0]+Ce;const Se=di(0,i.textShaping,W,_,!1,a,v,this.allowVerticalPlacement,se),qe=X&&re.kind==="composite"?ie.possiblyEvaluate(new xt(oe,{}),f).evaluate(a,b,f):P,Me=X&&re.kind==="composite"?ie.possiblyEvaluate(new xt(me,{}),f).evaluate(a,b,f):R,Ie=$y(q.name,re,X,y,qe,Me),Pe=Array.isArray(Ie)?Ie[1]:X,Ne=0,ke=1+(Math.min(Bu,Math.round(Pe*ye))<<1);i.isUsingAppearanceTextVertexData||(i.isUsingAppearanceTextVertexData=!0,i.layoutBasedTextVertexData=this.text.snapshotSymbolVertexData(c,e.numHorizontalGlyphVertices+e.numVerticalGlyphVertices));for(let $e=0;$e<Se.length&&$e<(e.numHorizontalGlyphVertices+e.numVerticalGlyphVertices)/4;++$e){const ze=Se[$e],He=ze.glyphOffset[1],Ye=e.tileAnchorX,st=e.tileAnchorY,Je=c+4*$e;this.text.updateSymbolVertexData(Je,Ye,st,Math.round(32*ze.tl.x),Math.round(32*(He+ze.tl.y)),ze.texPrimary.x,ze.texPrimary.y,Ne,ke,ze.pixelOffsetTL.x,ze.pixelOffsetTL.y,ze.minFontScaleX,ze.minFontScaleY),this.text.updateSymbolVertexData(Je+1,Ye,st,Math.round(32*ze.tr.x),Math.round(32*(He+ze.tr.y)),ze.texPrimary.x+ze.texPrimary.w,ze.texPrimary.y,Ne,ke,ze.pixelOffsetBR.x,ze.pixelOffsetTL.y,ze.minFontScaleX,ze.minFontScaleY),this.text.updateSymbolVertexData(Je+2,Ye,st,Math.round(32*ze.bl.x),Math.round(32*(He+ze.bl.y)),ze.texPrimary.x,ze.texPrimary.y+ze.texPrimary.h,Ne,ke,ze.pixelOffsetTL.x,ze.pixelOffsetBR.y,ze.minFontScaleX,ze.minFontScaleY),this.text.updateSymbolVertexData(Je+3,Ye,st,Math.round(32*ze.br.x),Math.round(32*(He+ze.br.y)),ze.texPrimary.x+ze.texPrimary.w,ze.texPrimary.y+ze.texPrimary.h,Ne,ke,ze.pixelOffsetBR.x,ze.pixelOffsetBR.y,ze.minFontScaleX,ze.minFontScaleY)}return{vertexOffsetDelta:e.numHorizontalGlyphVertices+e.numVerticalGlyphVertices,hasChanges:!0}}return i.isUsingAppearanceTextVertexData?(this.text.restoreSymbolVertexData(c,i.layoutBasedTextVertexData),i.isUsingAppearanceTextVertexData=!1,{vertexOffsetDelta:i.layoutBasedTextVertexData.length/wd,hasChanges:!0}):{vertexOffsetDelta:e.numHorizontalGlyphVertices+e.numVerticalGlyphVertices,hasChanges:!1}}updateExpressions(e){this.text&&this.text.programConfigurations.updateExpressions(e),this.icon&&this.icon.programConfigurations.updateExpressions(e)}update(e,i,o,a,c,h,f,_){if(this.text.uboBinder||this.text.programConfigurations.updatePaintArrays(e,i,c,o,a,h,f,this.worldview),this.icon.uboBinder||this.icon.programConfigurations.updatePaintArrays(e,i,c,o,a,h,f,this.worldview),_){if(h)for(const y of[this.text.uboBinder,this.icon.uboBinder])y&&!y.isLightConstant&&y.updateDynamicExpressions(c[0],i,_,o,e,f);else if(Object.keys(e).length>0){const y=c[0],v=[this.text.uboBinder,this.icon.uboBinder].filter(b=>b&&b.hasStateDependentPaint(y));if(v.length>0){const b=new Set(Object.keys(e).map(T=>{const E=Number(T);return!isNaN(E)&&Number.isSafeInteger(E)&&String(E)===T?E:T}));for(const T of v)T.updateFeatures(b,y,i,_,o,e,f)}}}}updateZOffset(){const e=(c,h,f)=>{o+=h,o>c.length&&c.resize(o);for(let _=-h;_<0;_++)c.emplace(_+o,f)},i=(c,h,f)=>{a+=h,a>c.length&&c.resize(a);for(let _=-h;_<0;_++)c.emplace(_+a,f)};if(!this.zOffsetBuffersNeedUpload)return;this.zOffsetBuffersNeedUpload=!1;let o=0,a=0;for(let c=0;c<this.symbolInstances.length;c++){const h=this.symbolInstances.get(c),{numHorizontalGlyphVertices:f,numVerticalGlyphVertices:_,numIconVertices:y}=h,v=h.zOffset,b=y>0;if((f>0||_>0)&&(e(this.text.zOffsetVertexArray,f,v),e(this.text.zOffsetVertexArray,_,v)),b){const{placedIconSymbolIndex:T,verticalPlacedIconSymbolIndex:E}=h;T>=0&&i(this.icon.zOffsetVertexArray,y,v),E>=0&&i(this.icon.zOffsetVertexArray,h.numVerticalIconVertices,v)}}this.text.zOffsetVertexBuffer&&this.text.zOffsetVertexBuffer.updateData(this.text.zOffsetVertexArray),this.icon.zOffsetVertexBuffer&&this.icon.zOffsetVertexBuffer.updateData(this.icon.zOffsetVertexArray)}isEmpty(){return this.symbolInstances.length===0&&!this.hasRTLText}uploadPending(){return!this.uploaded||this.text.programConfigurations.needsUpload||this.icon.programConfigurations.needsUpload}upload(e,i,o,a,c){!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.zOffsetBuffersNeedUpload,this.hasAppearances),this.hasAppearances===null&&(this.hasAppearances=this.layers.some(h=>h.appearances&&h.appearances.length>0)),this.icon.upload(e,this.sortFeaturesByY,!this.uploaded,this.icon.programConfigurations.needsUpload,this.zOffsetBuffersNeedUpload,this.hasAppearances),this.uploaded=!0}updateAppearances(e,i,o,a,c,h=!1){const f={hasLayoutChanges:!1,hasUboChanges:!1};if(!e||!o||!this.featureAppearanceData)return f;const _=i||{},y=this.icon.layoutVertexArray&&this.icon.layoutVertexArray.length>0&&this.icon.layoutVertexArray.arrayBuffer,v=this.text.layoutVertexArray&&this.text.layoutVertexArray.length>0&&this.text.layoutVertexArray.arrayBuffer;if(!y&&!v)return f;const b=this.layers[0],T=b.layout;this.featureAppearances&&this.featureAppearances.appearancesVersion===b.appearancesVersion||(this.featureAppearances=new tw(b.appearances,b.appearancesVersion));const E=this.featureAppearances.update(a,h);if(E.kind==="no-changes")return f;let C=1,P=0,R=!1,z=!1;if(y){const[se,X]=T.get("icon-size-scale-range");C=Y(1,se,X)}let V=1,N=0,U=!1;if(v){const[se,X]=T.get("text-size-scale-range");V=Y(1,se,X)}const q=new Map;if(c&&o)for(const se of o){const X=c.getImage(se,b.scope);if(X){const ie=new Fo(se.toString());q.set(ie.toString(),X)}}const W=[this.text.uboBinder,this.icon.uboBinder];for(let se=0;se<this.symbolInstances.length;se++){const X=this.symbolInstances.get(se),ie=this.getAppearanceFeatureData(X.featureIndex);if(!ie)continue;const re=ie.id,oe=re!==void 0?_[String(re)]:void 0,me={type:"Point",id:ie.id,properties:ie.properties,geometry:[]};let xe;if(E.kind==="all-features")xe=E.appearanceIndex;else{const Ce=b.appearances?b.appearances.findIndex(Se=>Se.isActive({globals:a,feature:me,canonical:e,featureState:oe})):-1;xe=Ce>=0?Ce:-1}const we=ie.activeAppearanceIndex!==xe;if(v){const Ce=T.get("text-size"),Se=this.textSizeData.kind==="composite"?this.textSizeData.minZoom:0,qe=this.textSizeData.kind==="composite"?this.textSizeData.maxZoom:0,Me={canonical:e,layer:b,featureState:oe,availableImages:o,textScaleFactor:V,imageMap:q,layoutTextOffset:T.get("text-offset").evaluate(me,oe,e).map(Pe=>Pe*Mr),layoutTextSize:Ce.evaluate(me,oe,e),layoutTextRotate:T.get("text-rotate").evaluate(me,oe,e),layoutMinZoomSize:Ce.evaluate(me,{zoom:Se},e),layoutMaxZoomSize:Ce.evaluate(me,{zoom:qe},e),layoutTextSizeMinZoom:Se,layoutTextSizeMaxZoom:qe},Ie=this.updateSymbolInstanceTextVertices(X,ie,xe,me,N,Me);N+=Ie.vertexOffsetDelta,U=U||Ie.hasChanges}if(y){const Ce={canonical:e,layer:b,featureState:oe,availableImages:o,globalProperties:a,iconScaleFactor:C,layoutIconOffset:T.get("icon-offset").evaluate(me,oe,e),layoutIconSize:T.get("icon-size").evaluate(me,oe,e,o),layoutIconRotate:T.get("icon-rotate").evaluate(me,oe,e)},Se=this.updateSymbolInstanceIconVertices(X,ie,xe,me,P,Ce);P+=Se.vertexOffsetDelta,R=R||Se.hasChanges}if(we){const Ce=X.featureIndex,Se=a?a.brightness:null,qe=oe||{},Me=xe>=0?b.appearances[xe]:null;for(const Ie of W)Ie&&(Ie.layer=b,z=Ie.updateFeaturePaintForAppearance(Ce,me,qe,e,o,Se,Me)||z)}ie.activeAppearanceIndex=xe}return R&&this.icon.layoutVertexBuffer&&this.icon.layoutVertexArray.arrayBuffer!==null&&this.icon.layoutVertexArray.length===this.icon.layoutVertexBuffer.length&&this.icon.layoutVertexBuffer.updateData(this.icon.layoutVertexArray),R&&this.icon.iconTransitioningVertexBuffer&&this.icon.iconTransitioningVertexArray.length>0&&this.icon.iconTransitioningVertexArray.length===this.icon.iconTransitioningVertexBuffer.length&&this.icon.iconTransitioningVertexBuffer.updateData(this.icon.iconTransitioningVertexArray),U&&this.text.layoutVertexBuffer&&this.text.layoutVertexArray.arrayBuffer!==null&&this.text.layoutVertexArray.length===this.text.layoutVertexBuffer.length&&this.text.layoutVertexBuffer.updateData(this.text.layoutVertexArray),{hasLayoutChanges:R||U,hasUboChanges:z}}destroyDebugData(){this.textCollisionBox.destroy(),this.iconCollisionBox.destroy()}getProjection(){return this.projectionInstance||(this.projectionInstance=Tv(this.projection)),this.projectionInstance}destroy(){this.text.destroy(),this.icon.destroy(),this.hasDebugData()&&this.destroyDebugData()}addToLineVertexArray(e,i){const o=this.lineVertexArray.length;if(e.segment!==void 0)for(const{x:a,y:c}of i)this.lineVertexArray.emplaceBack(a,c);return{lineStartIndex:o,lineLength:this.lineVertexArray.length-o}}addSymbols(e,i,o,a,c,h,f,_,y,v,b,T,E,C,P,R,z,V){const N=e.indexArray,U=e.layoutVertexArray,q=e.globeExtVertexArray,W=V,se=e.uboBinder?e.uboBinder.getCurrentBatchIndex():void 0,X=e.segments.prepareSegment(4*W,U,N,this.canOverlap?h.sortKey:void 0,se),ie=this.glyphOffsetArray.length,re=X.vertexLength,oe=this.allowVerticalPlacement&&f===M.vertical?Math.PI/2:0,me=h.text&&h.text.sections;let xe=U.length,we=-1;for(let qe=0;qe<i.length;qe++){const{tl:Me,tr:Ie,bl:Pe,br:Ne,texPrimary:ke,texSecondary:$e,pixelOffsetTL:ze,pixelOffsetBR:He,minFontScaleX:Ye,minFontScaleY:st,glyphOffset:Je,isSDF:Qe,sectionIndex:dt}=i[qe],wt=X.vertexLength,Bt=Je[1];if(Mp(U,y.x,y.y,Me.x,Bt+Me.y,ke.x,ke.y,o,Qe,ze.x,ze.y,Ye,st),Mp(U,y.x,y.y,Ie.x,Bt+Ie.y,ke.x+ke.w,ke.y,o,Qe,He.x,ze.y,Ye,st),Mp(U,y.x,y.y,Pe.x,Bt+Pe.y,ke.x,ke.y+ke.h,o,Qe,ze.x,He.y,Ye,st),Mp(U,y.x,y.y,Ne.x,Bt+Ne.y,ke.x+ke.w,ke.y+ke.h,o,Qe,He.x,He.y,Ye,st),_){const{x:lt,y:Et,z:Rt}=_.anchor,[ki,qt,ni]=_.up;Rp(q,lt,Et,Rt,ki,qt,ni),Rp(q,lt,Et,Rt,ki,qt,ni),Rp(q,lt,Et,Rt,ki,qt,ni),Rp(q,lt,Et,Rt,ki,qt,ni),bd(e.dynamicLayoutVertexArray,lt,Et,Rt,oe)}else bd(e.dynamicLayoutVertexArray,y.x,y.y,y.z,oe);if(R){const lt=$e||ke;Pp(e.iconTransitioningVertexArray,lt.x,lt.y),Pp(e.iconTransitioningVertexArray,lt.x+lt.w,lt.y),Pp(e.iconTransitioningVertexArray,lt.x,lt.y+lt.h),Pp(e.iconTransitioningVertexArray,lt.x+lt.w,lt.y+lt.h)}if(N.emplaceBack(wt,wt+1,wt+2),N.emplaceBack(wt+1,wt+2,wt+3),X.vertexLength+=4,X.primitiveLength+=2,this.glyphOffsetArray.emplaceBack(Je[0]),(qe===i.length-1||dt!==i[qe+1].sectionIndex)&&(e.uboBinder||e.programConfigurations.populatePaintArrays(U.length,h,h.index,{},E,C,P,me&&me[dt],this.worldview),e.uboBinder)){const lt=e.uboBinder.populateUBO(h,h.index,C,E,P,me&&me[dt]);we=lt;const Et=U.length-xe;for(let Rt=0;Rt<Et;Rt++)e.featureIdArray.emplaceBack(lt);xe=U.length}}const Ce=V-i.length;if(Ce!==0&&(this._addNullVertices(Ce,U,o,_,q,e,R,X,N),e.uboBinder&&we>=0)){const qe=4*Ce;for(let Me=0;Me<qe;Me++)e.featureIdArray.emplaceBack(we)}const Se=_?_.anchor:y;e.placedSymbolArray.emplaceBack(Se.x,Se.y,Se.z,y.x,y.y,ie,this.glyphOffsetArray.length-ie,re,v,b,y.segment,o?o[0]:0,o?o[1]:0,a[0],a[1],f,0,0,0,T,0),e.symbolInstanceIndices.push(z)}_addNullVertices(e,i,o,a,c,h,f,_,y){for(let v=0;v<e;v++){for(let T=0;T<4;T++)Mp(i,0,0,0,0,0,0,o,!1,0,0,0,0),a&&Rp(c,0,0,0,0,0,0),bd(h.dynamicLayoutVertexArray,0,0,0,0),f&&Pp(h.iconTransitioningVertexArray,0,0);const b=_.vertexLength;y.emplaceBack(b,b+1,b+2),y.emplaceBack(b+1,b+2,b+3),_.vertexLength+=4,_.primitiveLength+=2,this.glyphOffsetArray.emplaceBack(0)}}_commitLayoutVertex(e,i,o,a,c,h,f){e.emplaceBack(i,o,a,c,h,Math.round(f.x),Math.round(f.y))}_addCollisionDebugVertices(e,i,o,a,c,h,f){const _=o.segments.prepareSegment(4,o.layoutVertexArray,o.indexArray),y=_.vertexLength,v=f.tileAnchorX,b=f.tileAnchorY;for(let E=0;E<4;E++)o.collisionVertexArray.emplaceBack(0,0,0,0,0,0);this._commitDebugCollisionVertexUpdate(o.collisionVertexArrayExt,i,e.padding,f.zOffset),this._commitLayoutVertex(o.layoutVertexArray,a,c,h,v,b,new Ue(e.x1,e.y1)),this._commitLayoutVertex(o.layoutVertexArray,a,c,h,v,b,new Ue(e.x2,e.y1)),this._commitLayoutVertex(o.layoutVertexArray,a,c,h,v,b,new Ue(e.x2,e.y2)),this._commitLayoutVertex(o.layoutVertexArray,a,c,h,v,b,new Ue(e.x1,e.y2)),_.vertexLength+=4;const T=o.indexArray;T.emplaceBack(y,y+1),T.emplaceBack(y+1,y+2),T.emplaceBack(y+2,y+3),T.emplaceBack(y+3,y),_.primitiveLength+=4}_addTextDebugCollisionBoxes(e,i,o,a,c,h){for(let f=a;f<c;f++){const _=o.get(f),y=this.getSymbolInstanceTextSize(e,h,i,f);this._addCollisionDebugVertices(_,y,this.textCollisionBox,_.projectedAnchorX,_.projectedAnchorY,_.projectedAnchorZ,h)}}_addIconDebugCollisionBoxes(e,i,o,a,c,h){for(let f=a;f<c;f++){const _=o.get(f),y=this.getSymbolInstanceIconSize(e,i,h.placedIconSymbolIndex);this._addCollisionDebugVertices(_,y,this.iconCollisionBox,_.projectedAnchorX,_.projectedAnchorY,_.projectedAnchorZ,h)}}generateCollisionDebugBuffers(e,i,o){this.hasDebugData()&&this.destroyDebugData(),this.textCollisionBox=new ox(Wh,F_.members,us),this.iconCollisionBox=new ox(Wh,F_.members,us);const a=Fe(this.iconSizeData,e),c=Fe(this.textSizeData,e,o);for(let h=0;h<this.symbolInstances.length;h++){const f=this.symbolInstances.get(h);this._addTextDebugCollisionBoxes(c,e,i,f.textBoxStartIndex,f.textBoxEndIndex,f),this._addTextDebugCollisionBoxes(c,e,i,f.verticalTextBoxStartIndex,f.verticalTextBoxEndIndex,f),this._addIconDebugCollisionBoxes(a,e,i,f.iconBoxStartIndex,f.iconBoxEndIndex,f),this._addIconDebugCollisionBoxes(a,e,i,f.verticalIconBoxStartIndex,f.verticalIconBoxEndIndex,f)}}getSymbolInstanceTextSize(e,i,o,a){const c=this.text.placedSymbolArray.get(i.rightJustifiedTextSymbolIndex>=0?i.rightJustifiedTextSymbolIndex:i.centerJustifiedTextSymbolIndex>=0?i.centerJustifiedTextSymbolIndex:i.leftJustifiedTextSymbolIndex>=0?i.leftJustifiedTextSymbolIndex:i.verticalPlacedTextSymbolIndex>=0?i.verticalPlacedTextSymbolIndex:a),h=ge(this.textSizeData,e,c)/Mr;return this.tilePixelRatio*h}getSymbolInstanceIconSize(e,i,o){const a=this.icon.placedSymbolArray.get(o),c=ge(this.iconSizeData,e,a);return this.tilePixelRatio*c}_commitDebugCollisionVertexUpdate(e,i,o,a){e.emplaceBack(i,-o,-o,a),e.emplaceBack(i,o,-o,a),e.emplaceBack(i,o,o,a),e.emplaceBack(i,-o,o,a)}_updateTextDebugCollisionBoxes(e,i,o,a,c,h,f){for(let _=a;_<c;_++){const y=o.get(_),v=this.getSymbolInstanceTextSize(e,h,i,_);this._commitDebugCollisionVertexUpdate(this.textCollisionBox.collisionVertexArrayExt,v,y.padding,h.zOffset)}}_updateIconDebugCollisionBoxes(e,i,o,a,c,h,f){for(let _=a;_<c;_++){const y=o.get(_),v=this.getSymbolInstanceIconSize(e,i,h.placedIconSymbolIndex);this._commitDebugCollisionVertexUpdate(this.iconCollisionBox.collisionVertexArrayExt,v,y.padding,h.zOffset)}}updateCollisionDebugBuffers(e,i,o,a){if(!this.hasDebugData())return;this.hasTextCollisionBoxData()&&this.textCollisionBox.collisionVertexArrayExt.clear(),this.hasIconCollisionBoxData()&&this.iconCollisionBox.collisionVertexArrayExt.clear();const c=Fe(this.iconSizeData,e,a),h=Fe(this.textSizeData,e,o);for(let f=0;f<this.symbolInstances.length;f++){const _=this.symbolInstances.get(f);this._updateTextDebugCollisionBoxes(h,e,i,_.textBoxStartIndex,_.textBoxEndIndex,_,o),this._updateTextDebugCollisionBoxes(h,e,i,_.verticalTextBoxStartIndex,_.verticalTextBoxEndIndex,_,o),this._updateIconDebugCollisionBoxes(c,e,i,_.iconBoxStartIndex,_.iconBoxEndIndex,_,a),this._updateIconDebugCollisionBoxes(c,e,i,_.verticalIconBoxStartIndex,_.verticalIconBoxEndIndex,_,a)}this.hasTextCollisionBoxData()&&this.textCollisionBox.collisionVertexBufferExt&&this.textCollisionBox.collisionVertexBufferExt.updateData(this.textCollisionBox.collisionVertexArrayExt),this.hasIconCollisionBoxData()&&this.iconCollisionBox.collisionVertexBufferExt&&this.iconCollisionBox.collisionVertexBufferExt.updateData(this.iconCollisionBox.collisionVertexArrayExt)}_deserializeCollisionBoxesForSymbol(e,i,o,a,c,h,f,_,y){const v={};if(i<o){const{x1:b,y1:T,x2:E,y2:C,padding:P,projectedAnchorX:R,projectedAnchorY:z,projectedAnchorZ:V,tileAnchorX:N,tileAnchorY:U,featureIndex:q}=e.get(i);v.textBox={x1:b,y1:T,x2:E,y2:C,padding:P,projectedAnchorX:R,projectedAnchorY:z,projectedAnchorZ:V,tileAnchorX:N,tileAnchorY:U},v.textFeatureIndex=q}if(a<c){const{x1:b,y1:T,x2:E,y2:C,padding:P,projectedAnchorX:R,projectedAnchorY:z,projectedAnchorZ:V,tileAnchorX:N,tileAnchorY:U,featureIndex:q}=e.get(a);v.verticalTextBox={x1:b,y1:T,x2:E,y2:C,padding:P,projectedAnchorX:R,projectedAnchorY:z,projectedAnchorZ:V,tileAnchorX:N,tileAnchorY:U},v.verticalTextFeatureIndex=q}if(h<f){const{x1:b,y1:T,x2:E,y2:C,padding:P,projectedAnchorX:R,projectedAnchorY:z,projectedAnchorZ:V,tileAnchorX:N,tileAnchorY:U,featureIndex:q}=e.get(h);v.iconBox={x1:b,y1:T,x2:E,y2:C,padding:P,projectedAnchorX:R,projectedAnchorY:z,projectedAnchorZ:V,tileAnchorX:N,tileAnchorY:U},v.iconFeatureIndex=q}if(_<y){const{x1:b,y1:T,x2:E,y2:C,padding:P,projectedAnchorX:R,projectedAnchorY:z,projectedAnchorZ:V,tileAnchorX:N,tileAnchorY:U,featureIndex:q}=e.get(_);v.verticalIconBox={x1:b,y1:T,x2:E,y2:C,padding:P,projectedAnchorX:R,projectedAnchorY:z,projectedAnchorZ:V,tileAnchorX:N,tileAnchorY:U},v.verticalIconFeatureIndex=q}return v}deserializeCollisionBoxes(e){this.collisionArrays=[];for(let i=0;i<this.symbolInstances.length;i++){const o=this.symbolInstances.get(i);this.collisionArrays.push(this._deserializeCollisionBoxesForSymbol(e,o.textBoxStartIndex,o.textBoxEndIndex,o.verticalTextBoxStartIndex,o.verticalTextBoxEndIndex,o.iconBoxStartIndex,o.iconBoxEndIndex,o.verticalIconBoxStartIndex,o.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}hasIconTextFit(){return this.hasAnyIconTextFit}addIndicesForPlacedSymbol(e,i){const o=e.placedSymbolArray.get(i),a=o.vertexStartIndex+4*o.numGlyphs;for(let c=o.vertexStartIndex;c<a;c+=4)e.indexArray.emplaceBack(c,c+1,c+2),e.indexArray.emplaceBack(c+1,c+2,c+3)}getSortedSymbolIndexes(e){if(this.sortedAngle===e&&this.symbolInstanceIndexes!==void 0)return this.symbolInstanceIndexes;const i=Math.sin(e),o=Math.cos(e),a=[],c=[],h=[];for(let f=0;f<this.symbolInstances.length;++f){h.push(f);const _=this.symbolInstances.get(f);a.push(0|Math.round(i*_.tileAnchorX+o*_.tileAnchorY)),c.push(_.featureIndex)}return h.sort((f,_)=>a[f]-a[_]||c[_]-c[f]),h}getSortedIndexesByZOffset(){if(!this.zOffsetSortDirty)return this.symbolInstanceIndexesSortedZOffset;if(!this.symbolInstanceIndexesSortedZOffset){this.symbolInstanceIndexesSortedZOffset=[];for(let e=0;e<this.symbolInstances.length;++e)this.symbolInstanceIndexesSortedZOffset.push(e)}return this.zOffsetSortDirty=!1,this.symbolInstanceIndexesSortedZOffset.sort((e,i)=>this.symbolInstances.get(i).zOffset-this.symbolInstances.get(e).zOffset)}addToSortKeyRanges(e,i){const o=this.sortKeyRanges.at(-1);o&&o.sortKey===i?o.symbolInstanceEnd=e+1:this.sortKeyRanges.push({sortKey:i,symbolInstanceStart:e,symbolInstanceEnd:e+1})}sortFeatures(e){if(this.sortFeaturesByY&&this.sortedAngle!==e)if(this.text.segments.get().length>1||this.icon.segments.get().length>1)this.sortFeaturesByY=!1;else{this.symbolInstanceIndexes=this.getSortedSymbolIndexes(e),this.sortedAngle=e,this.text.indexArray.clear(),this.icon.indexArray.clear(),this.featureSortOrder=[];for(const i of this.symbolInstanceIndexes){const o=this.symbolInstances.get(i);this.featureSortOrder.push(o.featureIndex);const{rightJustifiedTextSymbolIndex:a,centerJustifiedTextSymbolIndex:c,leftJustifiedTextSymbolIndex:h,verticalPlacedTextSymbolIndex:f,placedIconSymbolIndex:_,verticalPlacedIconSymbolIndex:y}=o;a>=0&&this.addIndicesForPlacedSymbol(this.text,a),c>=0&&c!==a&&this.addIndicesForPlacedSymbol(this.text,c),h>=0&&h!==c&&h!==a&&this.addIndicesForPlacedSymbol(this.text,h),f>=0&&this.addIndicesForPlacedSymbol(this.text,f),_>=0&&this.addIndicesForPlacedSymbol(this.icon,_),y>=0&&this.addIndicesForPlacedSymbol(this.icon,y)}this.text.indexBuffer&&this.text.indexBuffer.updateData(this.text.indexArray),this.icon.indexBuffer&&this.icon.indexBuffer.updateData(this.icon.indexArray)}}}nt(J_,"SymbolBucket",{omit:["layers","collisionBoxArray","compareText","features"]}),J_.addDynamicAttributes=bd;class Pv extends Pc{constructor(e,i,o){super(e,i,o),this.elevatedLayoutVertexArray=new Js}upload(e){const i=this.uploaded;super.upload(e),!i&&this.elevatedLayoutVertexArray.length>0&&(this.elevatedLayoutVertexBuffer=e.createVertexBuffer(this.elevatedLayoutVertexArray,y_.members))}destroy(){this.elevatedLayoutVertexBuffer&&this.elevatedLayoutVertexBuffer.destroy(),super.destroy()}}nt(Pv,"ElevatedFillBufferData");class Bl{constructor(){this.portals=[]}static isOnBorder(e,i){return e<=0&&i<=0||e>=rt&&i>=rt}static evaluate(e){if(e.length===0)return new Bl;let i=[];for(const _ of e)i.push(..._.portals);if(i.length===0)return new Bl;for(const _ of i){const y=_.va,v=_.vb;(Bl.isOnBorder(y.x,v.x)||Bl.isOnBorder(y.y,v.y))&&(_.type="border")}const o=i.filter(_=>_.type!=="unevaluated"),a=i.filter(_=>_.type==="unevaluated");if(a.length===0)return new Bl;a.sort((_,y)=>_.hash===y.hash?_.isTunnel===y.isTunnel?0:_.isTunnel?-1:1:_.hash<y.hash?1:-1),i=o.concat(a);let c=o.length,h=c,f=c;do if(h++,h===i.length||i[c].hash!==i[h].hash){if(h-c===2){f<c&&(i[f]=i[c],i[c]=null);const _=i[f],y=i[h-1];_.type=_.isTunnel!==y.isTunnel?"tunnel":"polygon",_.connection={a:_.connection.a,b:y.connection.a},f++}c=h}while(c!==i.length);return i.splice(f),i.sort((_,y)=>_.hash<y.hash?1:-1),{portals:i}}}nt(Bl,"ElevationPortalGraph");class ow{constructor(e,i,o){this.outPositions=e,this.outNormals=i,this.outIndices=o,this.vertexLookup=new Map}addVertex(e,i,o){let a=e[2];o!=null&&(a*=o);const c=`${e[0]},${e[1]},${e[2]},${i[0]},${i[1]},${i[2]}`,h=this.vertexLookup.get(c);if(h!=null)return h;const f=this.outPositions.length;this.vertexLookup.set(c,f);const _=Math.trunc(16384*i[0]),y=Math.trunc(16384*i[1]),v=Math.trunc(16384*i[2]);return this.outPositions.emplaceBack(e[0],e[1],a),this.outNormals.emplaceBack(_,y,v),f}addTriangle(e,i,o){this.outIndices.emplaceBack(e,i,o)}addTriangles(e,i,o,a=0){if(e.length===0)return;const c=Zt(),h=Zt();for(let f=0;f<e.length;f+=3){const _=i[e[f+0]],y=i[e[f+1]],v=i[e[f+2]],b=o[e[f+1]]+a,T=o[e[f+2]]+a;Li(c,_.x,_.y,o[e[f+0]]+a);const E=this.addVertex(c,h);Li(c,y.x,y.y,b);const C=this.addVertex(c,h);Li(c,v.x,v.y,T);const P=this.addVertex(c,h);this.outIndices.emplaceBack(E,C,P)}}addQuad(e,i,o,a,c,h){const f=this.addVertex(e,c,h),_=this.addVertex(i,c,h),y=this.addVertex(o,c,h),v=this.addVertex(a,c,h);this.addTriangle(f,_,y),this.addTriangle(y,v,f)}getVertexCount(){return this.outPositions.length}clearVertexLookup(){this.vertexLookup.clear()}}class qo{constructor(e,i,o,a){this.unevaluatedPortals=new Bl,this.bridgeFeatureSections=[],this.tunnelFeatureSections=[],this.vertexHashLookup=new Map,this.unevalVertices=[],this.unevalHeights=[],this.unevalTriangles=[],this.unevalTunnelTriangles=[],this.unevalEdges=[],this.vertexPositions=new Tu,this.vertexNormals=new Zf,this.indexArray=new sn,this.tileToMeters=yo(e),this.bridgeProgramConfigurations=new hs(i,{zoom:o,lut:a},c=>c!=="fill-tunnel-structure-color"),this.tunnelProgramConfigurations=new hs(i,{zoom:o,lut:a},c=>c!=="fill-bridge-guard-rail-color")}addVertices(e,i){const o=this.unevalVertices.length;for(let a=0;a<e.length;a++)this.unevalVertices.push(e[a]),this.unevalHeights.push(i[a]);return o}addTriangles(e,i,o){const a=o?this.unevalTunnelTriangles:this.unevalTriangles;for(const c of e)a.push(c+i)}addRenderableRing(e,i,o,a,c,h){const f=[new Ue(c.min.x,c.min.y),new Ue(c.max.x,c.min.y),new Ue(c.max.x,c.max.y),new Ue(c.min.x,c.max.y)];for(let _=0;_<o-1;_++){const y=i+_,v=y+1,b=this.unevalVertices[y],T=this.unevalVertices[v];if(!(b.x>=c.min.x&&b.x<=c.max.x&&b.y>=c.min.y&&b.y<=c.max.y||T.x>=c.min.x&&T.x<=c.max.x&&T.y>=c.min.y&&T.y<=c.max.y||zl(b,T,f))||this.isOnBorder(b.x,T.x)||this.isOnBorder(b.y,T.y))continue;const E=qo.computeEdgeHash(this.unevalVertices[y],this.unevalVertices[v]);let C,P=this.vertexHashLookup.get(qo.computePosHash(b));P!=null?C=P.next:(P=this.vertexHashLookup.get(qo.computePosHash(T)),C=P!=null?P.prev:E),this.unevalEdges.push({polygonIdx:e,a:y,b:v,hash:E,portalHash:C,isTunnel:a,type:"unevaluated",featureInfo:h})}}addPortalCandidates(e,i,o,a,c){if(i.length!==0){this.vertexHashLookup.clear();for(const h of i){if(h.length===0)continue;const f=h[0];let _=qo.computeEdgeHash(f[f.length-2],f.at(-1));for(let y=0;y<f.length-1;y++){const v=f[y+0],b=f[y+1],T=io(b.x-v.x,b.y-v.y),E=ts(T);if(E===0)continue;let C="unevaluated";const P=a.pointElevation(v),R=a.pointElevation(b);Math.abs(P)<.01&&Math.abs(R)<.01?C="entrance":(this.isOnBorder(v.x,b.x)||this.isOnBorder(v.y,b.y))&&(C="border");const z=qo.computeEdgeHash(v,b);this.unevaluatedPortals.portals.push({connection:{a:e,b:void 0},va:v,vb:b,vab:T,length:E,hash:z,isTunnel:o,type:C});const V=qo.computePosHash(v);this.vertexHashLookup.set(V,{prev:_,next:z}),_=z}}}}construct(e){if(this.unevalVertices.length===0)return;const i=()=>({vertexOffset:0,primitiveOffset:this.indexArray.length}),o=T=>{T.primitiveLength=this.indexArray.length-T.primitiveOffset},a=new ow(this.vertexPositions,this.vertexNormals,this.indexArray);this.prepareEdges(e.portals,this.unevalEdges);const c=i(),h=i(),f=i(),_=(T,E)=>{T.sort((P,R)=>P.type===E&&R.type!==E?-1:P.type!==E&&R.type===E?1:0);const C=T.findIndex(P=>P.type!==E);return C>=0?C:T.length};let y=0;this.unevalEdges.length>0&&(y=_(this.unevalEdges,"none"),this.constructBridgeStructures(a,this.unevalVertices,this.unevalHeights,this.unevalEdges,{min:0,max:y},this.tileToMeters)),o(f);const v=i(),b=i();if(this.unevalEdges.length>0){const T=this.unevalEdges.splice(y),E=_(T,"tunnel")+y;this.unevalEdges.push(...T),this.constructTunnelStructures(a,this.unevalVertices,this.unevalHeights,this.unevalEdges,{min:0,max:y},{min:y,max:E})}o(v),a.addTriangles(this.unevalTriangles,this.unevalVertices,this.unevalHeights),o(b),a.addTriangles(this.unevalTunnelTriangles,this.unevalVertices,this.unevalHeights),o(h),a.addTriangles(this.unevalTunnelTriangles,this.unevalVertices,this.unevalHeights,4),o(c),this.maskSegments=Fi.simpleSegment(0,b.primitiveOffset,0,b.primitiveLength),this.depthSegments=Fi.simpleSegment(0,h.primitiveOffset,0,h.primitiveLength),this.renderableBridgeSegments=Fi.simpleSegment(0,f.primitiveOffset,0,f.primitiveLength),this.renderableTunnelSegments=Fi.simpleSegment(0,v.primitiveOffset,0,v.primitiveLength),this.shadowCasterSegments=Fi.simpleSegment(0,c.primitiveOffset,0,c.primitiveLength)}update(e,i,o,a,c,h,f,_){this.bridgeProgramConfigurations.updatePaintArrays(e,i,c,o,a,h,f,_),this.tunnelProgramConfigurations.updatePaintArrays(e,i,c,o,a,h,f,_)}upload(e){this.vertexBuffer||this.vertexPositions.length===0||this.vertexNormals.length===0||this.indexArray.length===0||(this.vertexBuffer=e.createVertexBuffer(this.vertexPositions,op.members),this.vertexBufferNormal=e.createVertexBuffer(this.vertexNormals,x_.members),this.indexBuffer=e.createIndexBuffer(this.indexArray),this.bridgeProgramConfigurations.upload(e),this.tunnelProgramConfigurations.upload(e))}destroy(){this.vertexBuffer&&(this.vertexBuffer.destroy(),this.vertexBufferNormal.destroy(),this.indexBuffer.destroy()),this.maskSegments&&(this.maskSegments.destroy(),this.depthSegments.destroy(),this.renderableBridgeSegments.destroy(),this.renderableTunnelSegments.destroy(),this.shadowCasterSegments.destroy()),this.bridgeProgramConfigurations.destroy(),this.tunnelProgramConfigurations.destroy()}populatePaintArrays(e,i,o,a,c){const h=(f,_)=>{for(let y=0;y<_.length-1;y++){const v=_[y].featureIndex,b=_[y+1].vertexStart,T=e.feature(v);f.populatePaintArrays(b,T,v,{},o,i,a,void 0,c)}};h(this.bridgeProgramConfigurations,this.bridgeFeatureSections),h(this.tunnelProgramConfigurations,this.tunnelFeatureSections)}computeVertexConnections(e,i,o,a,c){const h=new Map;for(let f=a;f<c;f++){const _=o[f],y=_.a,v=_.b,b=qo.computePosHash(e[y]),T=qo.computePosHash(e[v]);let E=h.get(b);E||(E={},h.set(b,E));let C=h.get(T);C||(C={},h.set(T,C)),i[y]<=0&&i[v]<=0||(E.to=v,C.from=y)}return h}isTerminalVertex(e,i){const o=qo.computePosHash(this.unevalVertices[e]),a=i.get(o);return!a||!a.from||!a.to}constructBridgeStructures(e,i,o,a,c,h){e.clearVertexLookup();const f=this.computeVertexConnections(i,o,a,c.min,c.max),_=1/h,y=.5*_,v=(Ce,Se)=>Li(Ce,i[Se].x,i[Se].y,o[Se]*_),b=Zt(),T=Zt(),E=Zt(),C=Zt(),P=Zt(),R=(Ce,Se)=>{const qe=f.get(qo.computePosHash(i[Se])),Me=qe.from,Ie=qe.to;if(!Me||!Ie)return;v(b,Me),v(T,Se),v(E,Ie),Bs(C),Rn(b,T)||(Zi(P,T,b),Mi(C,P)),Rn(E,T)||(Zi(P,E,T),ji(C,C,Mi(P,P)));const Pe=Dn(C);return Pe>0?li(Ce,C,1/Pe):void 0};let z=Number.POSITIVE_INFINITY;this.sortSubarray(a,c.min,c.max,(Ce,Se)=>Ce.featureInfo.featureIndex-Se.featureInfo.featureIndex);const V=Zt(),N=Zt(),U=Zt(),q=Zt(),W=Zt(),se=Zt(),X=Zt(),ie=Zt(),re=Zt(),oe=[Zt(),Zt(),Zt(),Zt()],me=[Zt(),Zt(),Zt(),Zt()],xe=[{coord:new Ue(0,0),height:0},{coord:new Ue(0,0),height:0}],we=(Ce,Se)=>Ce>Se;for(let Ce=c.min;Ce<c.max;Ce++){const Se=a[Ce];if(!Se.featureInfo.guardRailEnabled||!this.prepareEdgePoints(xe,i,o,Se,we))continue;const[qe,Me]=xe;if(Li(V,qe.coord.x,qe.coord.y,_*qe.height),Li(N,Me.coord.x,Me.coord.y,_*Me.height),Rn(V,N))continue;Zi(U,N,V),Mi(U,U);const Ie=R(ie,Se.a)||U,Pe=R(re,Se.b)||U;Li(q,Ie[1],-Ie[0],0),Mi(q,q),Li(W,Pe[1],-Pe[0],0),Mi(W,W),tr(ie,q,Ie),Mi(se,ie),tr(ie,W,Pe),Mi(X,ie),ji(oe[0],V,li(ie,Zi(ie,q,se),y)),ji(oe[1],V,li(ie,ji(ie,q,se),y)),ji(oe[2],V,li(ie,se,y)),oe[3]=V,ji(me[0],N,li(ie,Zi(ie,W,X),y)),ji(me[1],N,li(ie,ji(ie,W,X),y)),ji(me[2],N,li(ie,X,y)),me[3]=N,z=this.addFeatureSection(Se.featureInfo.featureIndex,z,this.bridgeFeatureSections,e);const Ne=e.addVertex(oe[0],q,h),ke=e.addVertex(oe[1],q,h),$e=e.addVertex(me[0],W,h),ze=e.addVertex(me[1],W,h);e.addTriangle(Ne,ke,$e),e.addTriangle(ke,ze,$e);const He=e.addVertex(oe[1],se,h),Ye=e.addVertex(oe[2],se,h),st=e.addVertex(me[1],X,h),Je=e.addVertex(me[2],X,h);e.addTriangle(He,Ye,st),e.addTriangle(Ye,Je,st),Jr(q,q),Jr(W,W);const Qe=e.addVertex(oe[2],q,h),dt=e.addVertex(oe[3],q,h),wt=e.addVertex(me[2],W,h),Bt=e.addVertex(me[3],W,h);e.addTriangle(Qe,dt,wt),e.addTriangle(dt,Bt,wt);const lt=this.isTerminalVertex(Se.a,f),Et=this.isTerminalVertex(Se.b,f);qe.height<.01&&lt&&e.addQuad(oe[3],oe[2],oe[1],oe[0],Jr(Ie,Ie),h),Me.height<.01&&Et&&e.addQuad(me[0],me[1],me[2],me[3],Pe,h)}this.bridgeFeatureSections.push({featureIndex:Number.POSITIVE_INFINITY,vertexStart:e.getVertexCount()})}constructTunnelStructures(e,i,o,a,c,h){e.clearVertexLookup();let f=Number.POSITIVE_INFINITY;const _=(z,V)=>z.featureInfo.featureIndex-V.featureInfo.featureIndex;this.sortSubarray(a,c.min,c.max,_),this.sortSubarray(a,h.min,h.max,_);const y=z=>Mi(z,z),v=[{coord:new Ue(0,0),height:0},{coord:new Ue(0,0),height:0}],b=(z,V)=>z<V,T=Zt(),E=Zt(),C=Zt(),P=Zt(),R=Zt();for(let z=c.min;z<c.max;z++){if(!this.prepareEdgePoints(v,i,o,a[z],b))continue;const[V,N]=v,U=y(Li(R,-(N.coord.y-V.coord.y),N.coord.x-V.coord.x,0));f=this.addFeatureSection(a[z].featureInfo.featureIndex,f,this.tunnelFeatureSections,e),e.addQuad(Li(T,V.coord.x,V.coord.y,V.height),Li(E,N.coord.x,N.coord.y,N.height),Li(C,N.coord.x,N.coord.y,a[z].isTunnel?N.height+4:0),Li(P,V.coord.x,V.coord.y,a[z].isTunnel?V.height+4:0),U)}for(let z=h.min;z<h.max;z++){const V=a[z];V.isTunnel&&([V.a,V.b]=[V.b,V.a]);const N=i[V.a],U=i[V.b],q=y(Li(R,-(U.y-N.y),U.x-N.x,0));f=this.addFeatureSection(V.featureInfo.featureIndex,f,this.tunnelFeatureSections,e),e.addQuad(Li(T,U.x,U.y,0),Li(E,N.x,N.y,0),Li(C,N.x,N.y,o[V.a]+4),Li(P,U.x,U.y,o[V.b]+4),q),e.addQuad(Li(T,N.x,N.y,0),Li(E,U.x,U.y,0),Li(C,U.x,U.y,o[V.b]+4),Li(P,N.x,N.y,o[V.a]+4),q)}this.tunnelFeatureSections.push({featureIndex:Number.POSITIVE_INFINITY,vertexStart:e.getVertexCount()})}setElevatedPoint(e,i,o,a){e.coord.x=i,e.coord.y=o,e.height=a}prepareEdgePoints(e,i,o,a,c){let h=i[a.a].x,f=i[a.a].y,_=i[a.b].x,y=i[a.b].y,v=o[a.a],b=o[a.b];const T=c(v,0),E=c(b,0);if(T&&E)return this.setElevatedPoint(e[0],h,f,v),this.setElevatedPoint(e[1],_,y,b),!0;if(!T&&!E)return!1;if(T){if(!E){const C=b/(b-v);_=vt(_,h,C),y=vt(y,f,C),b=vt(b,v,C)}}else{const C=v/(v-b);h=vt(h,_,C),f=vt(f,y,C),v=vt(v,b,C)}return this.setElevatedPoint(e[0],h,f,v),this.setElevatedPoint(e[1],_,y,b),!0}prepareEdges(e,i){if(i.length===0)return;i.sort((f,_)=>f.hash===_.hash?_.polygonIdx-f.polygonIdx:_.hash>f.hash?1:-1);let o=0,a=0,c=0,h=i[o].polygonIdx;do a++,(a===i.length||i[o].hash!==i[a].hash)&&((a-o===1||i[a-1].polygonIdx!==h)&&(c<o&&(i[c]=i[o],i[o]=null),i[c].type="none",c++),o=a,o!==i.length&&(h=i[o].polygonIdx));while(o!==i.length);if(i.splice(c),i.length!==0&&e.length!==0){i.sort((y,v)=>y.portalHash<v.portalHash?1:-1);let f=0,_=0;for(;f!==i.length&&_!==e.length;){const y=i[f],v=e[_];y.portalHash>v.hash?f++:v.hash>y.portalHash?_++:(y.type=v.type,f++)}}}isOnBorder(e,i){return e<=0&&i<=0||e>=rt&&i>=rt}addFeatureSection(e,i,o,a){return e!==i&&(i=e,o.push({featureIndex:e,vertexStart:a.getVertexCount()}),a.clearVertexLookup()),i}sortSubarray(e,i,o,a){const c=e.slice(i,o);c.sort(a),e.splice(i,c.length,...c)}static computeEdgeHash(e,i){return(e.y===i.y&&e.x>i.x||e.y>i.y)&&([e,i]=[i,e]),BigInt(qo.computePosHash(e))<<32n|BigInt(qo.computePosHash(i))}static computePosHash(e){return((65535&e.x)<<16|65535&e.y)>>>0}}class sw{constructor(){this._valid=!1}reset(e){return this.feature=e,this._valid=!0,this._geometry=e.loadGeometry(),this._geometry.length!==0&&this._geometry[0].length!==0||(this._valid=!1),this}geometry(e,i){return this._valid&&e(i(this._geometry)),this}require(e,i,o){return this.get(e,!0,i,o)}optional(e,i,o){return this.get(e,!1,i,o)}success(){return this._valid}get(e,i,o,a){const c=Object.hasOwn(this.feature.properties,e)?+this.feature.properties[e]:void 0;return this._valid&&c!==void 0&&!Number.isNaN(c)?o(a?a(c):c):i&&(this._valid=!1),this}}class Rv{constructor(e,i){this.featureFunc=e,this.vertexFunc=i}parseFeature(e,i,o){return this.featureFunc(e,i,o)}parseVertex(e,i,o){return this.vertexFunc(e,i,o)}}const aw=new Rv((r,e,i)=>r.reset(e).require(Ps,o=>{i.id=o}).optional("fixed_height_relative",o=>{i.constantHeight=o},Nl.decodeRelativeHeight).geometry(o=>{i.bounds=o},Us).success(),(r,e,i)=>r.reset(e).require(Ps,o=>{i.id=o}).require("elevation_idx",o=>{i.idx=o}).require("extent",o=>{i.extent=o}).require("height_relative",o=>{i.height=o},Nl.decodeRelativeHeight).geometry(o=>{i.position=o},Nl.getPoint).success()),lw=new Rv((r,e,i)=>r.reset(e).require(Ps,o=>{i.id=o}).optional("fixed_height",o=>{i.constantHeight=o},Nl.decodeMetricHeight).geometry(o=>{i.bounds=o},Us).success(),(r,e,i)=>r.reset(e).require(Ps,o=>{i.id=o}).require("elevation_idx",o=>{i.idx=o}).require("extent",o=>{i.extent=o}).require("height",o=>{i.height=o},Nl.decodeMetricHeight).geometry(o=>{i.position=o},Nl.getPoint).success());class Nl{static getPoint(e){return io(e[0][0].x,e[0][0].y)}static decodeRelativeHeight(e){return 1e-4*e*5}static decodeMetricHeight(e){return 1e-4*e}static getVersionSchema(e){return e?e==="1.0.1"?lw:void 0:aw}static parse(e){const i=[],o=[],a=e.length,c=new sw;for(let h=0;h<a;h++){const f=e.feature(h),_=f.properties.version,y=Nl.getVersionSchema(_);if(y===void 0){ht(`Unknown elevation feature version number ${_||"(unknown)"}`);continue}const v=f.properties.type;if(!v)continue;const b=Za.types[f.type];if(b==="Point"&&v==="curve_point"){const T={};y.parseVertex(c,f,T)&&i.push(T)}else if(b==="Polygon"&&v==="curve_meta"){const T={};y.parseFeature(c,f,T)&&o.push(T)}}return{vertices:i,features:o}}}const cw=[rr(),rr(),rr(),rr(),rr(),rr(),rr()],Nu=rr(),Vu=rr();function Q_(r){return[r[0],r[1]]}function eg(r){return io(r[0],r[1])}class Dv{constructor(e,i,o=null){this.feature=e,this.metersToTile=i,this.sampler=o,this.index=0}get(){const e=this.feature.vertices[this.index],i=this.feature.vertexProps[this.index].dir,o=i[1],a=-i[0],c=(e.extent+1)*this.metersToTile,h=this.sampler?this.sampler.pointTransform(e.position):e.position;return[new Ue(Math.trunc(h[0]+o*c),Math.trunc(h[1]+a*c)),new Ue(Math.trunc(h[0]-o*c),Math.trunc(h[1]-a*c))]}next(){this.index++}valid(){return this.index<this.feature.vertices.length}}class Vl{constructor(e,i,o,a,c,h){if(this.vertices=new Array,this.vertexProps=new Array,this.edges=new Array,this.edgeProps=new Array,this.id=e,this.heightRange={min:o,max:o},this.safeArea=i,this.constantHeight=o,this.constantHeight==null&&(this.constantHeight!=null||a.length!==0)){this.vertices=a,this.edges=c;for(let f=0;f<this.vertices.length;f++)this.vertices[f].index=this.vertices[f].index!==void 0?this.vertices[f].index:f;this.edges=this.edges.filter(f=>{return f.a<this.vertices.length&&f.b<this.vertices.length&&!((_=this.vertices[f.a].position)[0]===(y=this.vertices[f.b].position)[0]&&_[1]===y[1]);var _,y}),this.heightRange={min:Number.POSITIVE_INFINITY,max:Number.NEGATIVE_INFINITY};for(const f of this.vertices)this.vertexProps.push({dir:io(0,0)}),this.heightRange.min=Math.min(this.heightRange.min,f.height),this.heightRange.max=Math.max(this.heightRange.max,f.height);for(const f of this.edges){const _=this.vertices[f.a].position,y=this.vertices[f.b].position,v=vs(rr(),y,_),b=ts(v),T=Ns(rr(),v,1/b);this.edgeProps.push({vec:v,dir:T,len:b});const E=this.vertexProps[f.a].dir,C=this.vertexProps[f.b].dir;es(E,E,T),es(C,C,T)}for(const f of this.vertexProps)f.dir[0]===0&&f.dir[1]===0||bs(f.dir,f.dir);this.tessellate(h)}}pointElevation(e){if(this.constantHeight!=null)return this.constantHeight;const i=this.getClosestEdge(e);if(i==null)return 0;const[o,a]=i;return vt(this.vertices[this.edges[o].a].height,this.vertices[this.edges[o].b].height,a)}computeSlopeNormal(e,i){const o=this.getClosestEdge(e);if(!o)return ur(0,0,1);const a=o[0],c=this.edges[a],h=this.edgeProps[a].vec,f=ur(h[0],h[1],(this.vertices[c.b].height-this.vertices[c.a].height)*i),_=ur(f[1],-f[0],0);tr(_,_,f);const y=Yr(_);return y>0?li(_,_,1/y):Li(_,0,0,1)}getSafeArea(){return this.safeArea}isTunnel(){return this.heightRange.max<=-5}getClosestEdge(e){if(this.edges.length===0)return;let i=0,o=Number.POSITIVE_INFINITY,a=0;const[c,h,f,_,y,v,b]=cw;Qo(b,e.x,e.y);const T=new B1(b,null);for(let E=0;E<this.edges.length;E++){const C=this.edges[E],P=this.edgeProps[E].dir;T.dir=P;const R=this.vertices[C.a].position,z=this.vertices[C.b].position,V=T.intersectsPlane(R,this.vertexProps[C.a].dir,c),N=T.intersectsPlane(z,this.vertexProps[C.b].dir,h);if(!V||!N)continue;vs(f,h,c),vs(_,b,c);const U=Mo(f,f),q=U>0?Mo(_,f)/U:0,W=Y(q,0,1),se=Math.abs((q-W)*this.edgeProps[E].len);vs(y,b,R),Qo(v,P[1],-P[0]);const X=se+Math.abs(Mo(y,v));X<o&&(i=E,o=X,a=W)}return[i,a]}tessellate(e){const i=Zt(),o=Zt(),a=Zt(),c=Zt();for(let h=this.edges.length-1;h>=0;--h){const f=this.edges[h].a,_=this.edges[h].b,{position:y,height:v,extent:b}=this.vertices[f],{position:T,height:E,extent:C}=this.vertices[_],P=this.vertexProps[f].dir,R=this.vertexProps[_].dir;if(Li(i,y[0]/e,y[1]/e,v),Li(o,T[0]/e,T[1]/e,E),Li(a,P[1],-P[0],0),li(a,a,b),Li(c,R[1],-R[0],0),li(c,c,C),this.distSqLines(ur(i[0]+.5*a[0],i[1]+.5*a[1],i[2]+.5*a[2]),ur(o[0]-.5*c[0],o[1]-.5*c[1],o[2]-.5*c[2]),ur(i[0]-.5*a[0],i[1]-.5*a[1],i[2]-.5*a[2]),ur(o[0]+.5*c[0],o[1]+.5*c[1],o[2]+.5*c[2]))<=.0025000000000000005)continue;const z=this.vertices.length,V=es(rr(),y,T);this.vertices.push({position:Ns(V,V,.5),height:.5*(v+E),extent:.5*(b+C),index:.5*((this.vertices[f].index!==void 0?this.vertices[f].index:f)+(this.vertices[_].index!==void 0?this.vertices[_].index:_))});const N=es(rr(),P,R);this.vertexProps.push({dir:bs(N,N)}),this.edges.splice(h,1),this.edgeProps.splice(h,1),this.edges.push({a:f,b:z}),this.edges.push({a:z,b:_});const U=vs(rr(),this.vertices[z].position,y),q=ts(U),W={vec:U,dir:Ns(rr(),U,1/q),len:q};this.edgeProps.push(W),this.edgeProps.push(W)}}distSqLines(e,i,o,a){const c=dn(Zt(),i,e),h=dn(Zt(),a,o),f=dn(Zt(),e,o),_=qi(c,c),y=qi(c,h),v=qi(c,f),b=qi(h,h),T=qi(h,f),E=_*b-y*y;if(E===0)return yn(fo(c,o,a,qi(f,h)/qi(h,h)),e);const C=(_*T-y*v)/E;return yn(fo(c,e,i,(y*T-v*b)/E),fo(h,o,a,C))}static serialize(e,i){const o={id:e.id,heightRange:{min:e.heightRange.min,max:e.heightRange.max},safeArea:(a=e.safeArea,{min:{x:a.min.x,y:a.min.y},max:{x:a.max.x,y:a.max.y}})};var a;return e.constantHeight!=null?(o.constantHeight=e.constantHeight,o):e.vertices.length===0?(o.vertices=[],o.vertexProps=[],o.edges=[],o.edgeProps=[],o):(o.vertices=e.vertices.map(c=>({position:Q_(c.position),height:c.height,extent:c.extent,index:c.index})),o.vertexProps=e.vertexProps.map(c=>({dir:Q_(c.dir)})),o.edges=e.edges.map(c=>({a:c.a,b:c.b})),o.edgeProps=e.edgeProps.map(c=>({vec:Q_(c.vec),dir:Q_(c.dir),len:c.len})),o)}static deserialize(e){const i=(function(a){return{min:new Ue(a.min.x,a.min.y),max:new Ue(a.max.x,a.max.y)}})(e.safeArea);if(e.constantHeight!=null)return new Vl(e.id,i,e.constantHeight);if(!e.vertices||e.vertices.length===0){const a=Object.create(Vl.prototype);return a.id=e.id,a.constantHeight=void 0,a.heightRange={min:e.heightRange.min,max:e.heightRange.max},a.safeArea=i,a.vertices=[],a.vertexProps=[],a.edges=[],a.edgeProps=[],a}const o=Object.create(Vl.prototype);return o.id=e.id,o.constantHeight=void 0,o.heightRange={min:e.heightRange.min,max:e.heightRange.max},o.safeArea=i,o.vertices=e.vertices.map(a=>({position:eg(a.position),height:a.height,extent:a.extent,index:a.index})),o.vertexProps=(e.vertexProps||[]).map(a=>({dir:eg(a.dir)})),o.edges=(e.edges||[]).map(a=>({a:a.a,b:a.b})),o.edgeProps=(e.edgeProps||[]).map(a=>({vec:eg(a.vec),dir:eg(a.dir),len:a.len})),o}}class Td{constructor(e,i){this.zScale=1,this.xOffset=0,this.yOffset=0,e.equals(i)||(this.zScale=Math.pow(2,i.z-e.z),this.xOffset=(e.x*this.zScale-i.x)*rt,this.yOffset=(e.y*this.zScale-i.y)*rt)}pointTransform(e){return io(e[0]*this.zScale+this.xOffset,e[1]*this.zScale+this.yOffset)}pointTransformInPlace(e){e[0]=e[0]*this.zScale+this.xOffset,e[1]=e[1]*this.zScale+this.yOffset}constantElevation(e,i){if(e.constantHeight!=null)return this.computeBiasedHeight(e.constantHeight,i)}pointElevation(e,i,o){const a=this.constantElevation(i,o);return a??(e.x=e.x*this.zScale+this.xOffset,e.y=e.y*this.zScale+this.yOffset,this.computeBiasedHeight(i.pointElevation(e),o))}computeBiasedHeight(e,i){return i<=0?e:e+i*ce(0,i,e>=0?e:Math.abs(.5*e))}}function uw(r){if(r===0)return[0,0,0];const e=gc(r);return[e(),e(),e()]}function Lv(r,e){let i=0,o=r.length-1;for(;i<=o;){const a=i+o>>1;r[a].feature.id<e?i=a+1:o=a-1}return i<r.length&&r[i].feature.id===e?i:-1}function Dp(r,e,i,o){if(!r.properties)return;const a=+r.properties[Ps];if(Number.isNaN(a))return;if(e){const h=e.find(f=>f.id===a);if(h&&o)return{tileId:o,feature:h}}if(!i||i.length===0)return;const c=Lv(i,a);if(!(c<0)){if(o){for(let h=c;h<i.length&&i[h].feature.id===a;h++)if(i[h].tileId.key===o.key)return i[h]}return i[c]}}function hw(r,e){return r>e?1:r<e?-1:0}nt(Vl,"ElevationFeature");class sx{constructor(e=hw,i=!1){this._compare=e,this._root=null,this._size=0,this._noDuplicates=!!i}rotateLeft(e){var i=e.right;i&&(e.right=i.left,i.left&&(i.left.parent=e),i.parent=e.parent),e.parent?e===e.parent.left?e.parent.left=i:e.parent.right=i:this._root=i,i&&(i.left=e),e.parent=i}rotateRight(e){var i=e.left;i&&(e.left=i.right,i.right&&(i.right.parent=e),i.parent=e.parent),e.parent?e===e.parent.left?e.parent.left=i:e.parent.right=i:this._root=i,i&&(i.right=e),e.parent=i}_splay(e){for(;e.parent;){var i=e.parent;i.parent?i.left===e&&i.parent.left===i?(this.rotateRight(i.parent),this.rotateRight(i)):i.right===e&&i.parent.right===i?(this.rotateLeft(i.parent),this.rotateLeft(i)):i.left===e&&i.parent.right===i?(this.rotateRight(i),this.rotateLeft(i)):(this.rotateLeft(i),this.rotateRight(i)):i.left===e?this.rotateRight(i):this.rotateLeft(i)}}splay(e){for(var i,o,a,c,h;e.parent;)(o=(i=e.parent).parent)&&o.parent?((a=o.parent).left===o?a.left=e:a.right=e,e.parent=a):(e.parent=null,this._root=e),c=e.left,h=e.right,e===i.left?(o&&(o.left===i?(i.right?(o.left=i.right,o.left.parent=o):o.left=null,i.right=o,o.parent=i):(c?(o.right=c,c.parent=o):o.right=null,e.left=o,o.parent=e)),h?(i.left=h,h.parent=i):i.left=null,e.right=i,i.parent=e):(o&&(o.right===i?(i.left?(o.right=i.left,o.right.parent=o):o.right=null,i.left=o,o.parent=i):(h?(o.left=h,h.parent=o):o.left=null,e.right=o,o.parent=e)),c?(i.right=c,c.parent=i):i.right=null,e.left=i,i.parent=e)}replace(e,i){e.parent?e===e.parent.left?e.parent.left=i:e.parent.right=i:this._root=i,i&&(i.parent=e.parent)}minNode(e=this._root){if(e)for(;e.left;)e=e.left;return e}maxNode(e=this._root){if(e)for(;e.right;)e=e.right;return e}insert(e,i){var o=this._root,a=null,c=this._compare;if(this._noDuplicates)for(;o;){if(a=o,c(o.key,e)===0)return;o=c(o.key,e)<0?o.right:o.left}else for(;o;)a=o,o=c(o.key,e)<0?o.right:o.left;return o={key:e,data:i,left:null,right:null,parent:a},a?c(a.key,o.key)<0?a.right=o:a.left=o:this._root=o,this.splay(o),this._size++,o}find(e){for(var i=this._root,o=this._compare;i;){var a=o(i.key,e);if(a<0)i=i.right;else{if(!(a>0))return i;i=i.left}}return null}contains(e){for(var i=this._root,o=this._compare;i;){var a=o(e,i.key);if(a===0)return!0;i=a<0?i.left:i.right}return!1}remove(e){var i=this.find(e);if(!i)return!1;if(this.splay(i),i.left)if(i.right){var o=this.minNode(i.right);o.parent!==i&&(this.replace(o,o.right),o.right=i.right,o.right.parent=o),this.replace(i,o),o.left=i.left,o.left.parent=o}else this.replace(i,i.left);else this.replace(i,i.right);return this._size--,!0}removeNode(e){if(!e)return!1;if(this.splay(e),e.left)if(e.right){var i=this.minNode(e.right);i.parent!==e&&(this.replace(i,i.right),i.right=e.right,i.right.parent=i),this.replace(e,i),i.left=e.left,i.left.parent=i}else this.replace(e,e.left);else this.replace(e,e.right);return this._size--,!0}erase(e){var i=this.find(e);if(i){this.splay(i);var o=i.left,a=i.right,c=null;o&&(o.parent=null,c=this.maxNode(o),this.splay(c),this._root=c),a&&(o?c.right=a:this._root=a,a.parent=c),this._size--}}pop(){var e=this._root,i=null;if(e){for(;e.left;)e=e.left;i={key:e.key,data:e.data},this.remove(e.key)}return i}next(e){var i=e;if(i)if(i.right)for(i=i.right;i&&i.left;)i=i.left;else for(i=e.parent;i&&i.right===e;)e=i,i=i.parent;return i}prev(e){var i=e;if(i)if(i.left)for(i=i.left;i&&i.right;)i=i.right;else for(i=e.parent;i&&i.left===e;)e=i,i=i.parent;return i}forEach(e){for(var i=this._root,o=[],a=!1,c=0;!a;)i?(o.push(i),i=i.left):o.length>0?(e(i=o.pop(),c++),i=i.right):a=!0;return this}range(e,i,o,a){const c=[],h=this._compare;let f,_=this._root;for(;c.length!==0||_;)if(_)c.push(_),_=_.left;else{if(_=c.pop(),f=h(_.key,i),f>0)break;if(h(_.key,e)>=0&&o.call(a,_))return this;_=_.right}return this}keys(){for(var e=this._root,i=[],o=[],a=!1;!a;)e?(i.push(e),e=e.left):i.length>0?(e=i.pop(),o.push(e.key),e=e.right):a=!0;return o}values(){for(var e=this._root,i=[],o=[],a=!1;!a;)e?(i.push(e),e=e.left):i.length>0?(e=i.pop(),o.push(e.data),e=e.right):a=!0;return o}at(e){for(var i=this._root,o=[],a=!1,c=0;!a;)if(i)o.push(i),i=i.left;else if(o.length>0){if(i=o.pop(),c===e)return i;c++,i=i.right}else a=!0;return null}load(e=[],i=[],o=!1){if(this._size!==0)throw new Error("bulk-load: tree is not empty");const a=e.length;return o&&lx(e,i,0,a-1,this._compare),this._root=ax(null,e,i,0,a),this._size=a,this}min(){var e=this.minNode(this._root);return e?e.key:null}max(){var e=this.maxNode(this._root);return e?e.key:null}isEmpty(){return this._root===null}get size(){return this._size}static createTree(e,i,o,a,c){return new sx(o,c).load(e,i,a)}}function ax(r,e,i,o,a){const c=a-o;if(c>0){const h=o+Math.floor(c/2),f={key:e[h],data:i[h],parent:r};return f.left=ax(f,e,i,o,h),f.right=ax(f,e,i,h+1,a),f}return null}function lx(r,e,i,o,a){if(i>=o)return;const c=r[i+o>>1];let h=i-1,f=o+1;for(;;){do h++;while(a(r[h],c)<0);do f--;while(a(r[f],c)>0);if(h>=f)break;let _=r[h];r[h]=r[f],r[f]=_,_=e[h],e[h]=e[f],e[f]=_}lx(r,e,i,f,a),lx(r,e,f+1,o,a)}const zv=11102230246251565e-32,wo=134217729,dw=(3+8*zv)*zv;function cx(r,e,i,o,a){let c,h,f,_,y=e[0],v=o[0],b=0,T=0;v>y==v>-y?(c=y,y=e[++b]):(c=v,v=o[++T]);let E=0;if(b<r&&T<i)for(v>y==v>-y?(h=y+c,f=c-(h-y),y=e[++b]):(h=v+c,f=c-(h-v),v=o[++T]),c=h,f!==0&&(a[E++]=f);b<r&&T<i;)v>y==v>-y?(h=c+y,_=h-c,f=c-(h-_)+(y-_),y=e[++b]):(h=c+v,_=h-c,f=c-(h-_)+(v-_),v=o[++T]),c=h,f!==0&&(a[E++]=f);for(;b<r;)h=c+y,_=h-c,f=c-(h-_)+(y-_),y=e[++b],c=h,f!==0&&(a[E++]=f);for(;T<i;)h=c+v,_=h-c,f=c-(h-_)+(v-_),v=o[++T],c=h,f!==0&&(a[E++]=f);return c===0&&E!==0||(a[E++]=c),E}function Lp(r){return new Float64Array(r)}const Sd=Lp(4),Fv=Lp(8),Ov=Lp(12),kv=Lp(16),Ho=Lp(4);function zp(r,e,i){e===null?(r.inOut=!1,r.otherInOut=!0):(r.isSubject===e.isSubject?(r.inOut=!e.inOut,r.otherInOut=e.otherInOut):(r.inOut=!e.otherInOut,r.otherInOut=e.isVertical()?!e.inOut:e.inOut),e&&(r.prevInResult=!Bv(e,i)||e.isVertical()?e.prevInResult:e)),r.resultTransition=Bv(r,i)?(function(o,a){let c,h=!o.inOut,f=!o.otherInOut;switch(a){case 0:c=h&&f;break;case 1:c=h||f;break;case 3:c=h!==f;break;case 2:c=o.isSubject?h&&!f:f&&!h}return c?1:-1})(r,i):0}function Bv(r,e){switch(r.type){case 0:switch(e){case 0:return!r.otherInOut;case 1:return r.otherInOut;case 2:return r.isSubject&&r.otherInOut||!r.isSubject&&!r.otherInOut;case 3:return!0}break;case 2:return e===0||e===1;case 3:return e===2;case 1:return!1}return!1}class Ed{constructor(e,i,o,a,c){this.left=i,this.point=e,this.otherEvent=o,this.isSubject=a??!1,this.type=c||0,this.inOut=!1,this.otherInOut=!1,this.prevInResult=null,this.resultTransition=0,this.otherPos=-1,this.outputContourId=-1,this.isExteriorRing=!0}isBelow(e){const i=this.point,o=this.otherEvent.point;return this.left?(i[0]-e[0])*(o[1]-e[1])-(o[0]-e[0])*(i[1]-e[1])>0:(o[0]-e[0])*(i[1]-e[1])-(i[0]-e[0])*(o[1]-e[1])>0}isAbove(e){return!this.isBelow(e)}isVertical(){return this.point[0]===this.otherEvent.point[0]}get inResult(){return this.resultTransition!==0}clone(){const e=new Ed(this.point,this.left,this.otherEvent,this.isSubject,this.type);return e.contourId=this.contourId,e.resultTransition=this.resultTransition,e.prevInResult=this.prevInResult,e.isExteriorRing=this.isExteriorRing,e.inOut=this.inOut,e.otherInOut=this.otherInOut,e}}function el(r,e){return r[0]===e[0]&&r[1]===e[1]}function ux(r,e,i){const o=(function(a,c,h,f,_,y){const v=(c-y)*(h-_),b=(a-_)*(f-y),T=v-b;if(v===0||b===0||v>0!=b>0)return T;const E=Math.abs(v+b);return Math.abs(T)>=33306690738754716e-32*E?T:-(function(C,P,R,z,V,N,U){let q,W,se,X,ie,re,oe,me,xe,we,Ce,Se,qe,Me,Ie,Pe,Ne,ke;const $e=C-V,ze=R-V,He=P-N,Ye=z-N;Me=$e*Ye,re=wo*$e,oe=re-(re-$e),me=$e-oe,re=wo*Ye,xe=re-(re-Ye),we=Ye-xe,Ie=me*we-(Me-oe*xe-me*xe-oe*we),Pe=He*ze,re=wo*He,oe=re-(re-He),me=He-oe,re=wo*ze,xe=re-(re-ze),we=ze-xe,Ne=me*we-(Pe-oe*xe-me*xe-oe*we),Ce=Ie-Ne,ie=Ie-Ce,Sd[0]=Ie-(Ce+ie)+(ie-Ne),Se=Me+Ce,ie=Se-Me,qe=Me-(Se-ie)+(Ce-ie),Ce=qe-Pe,ie=qe-Ce,Sd[1]=qe-(Ce+ie)+(ie-Pe),ke=Se+Ce,ie=ke-Se,Sd[2]=Se-(ke-ie)+(Ce-ie),Sd[3]=ke;let st=(function(Bt,lt){let Et=lt[0];for(let Rt=1;Rt<4;Rt++)Et+=lt[Rt];return Et})(0,Sd),Je=22204460492503146e-32*U;if(st>=Je||-st>=Je||(ie=C-$e,q=C-($e+ie)+(ie-V),ie=R-ze,se=R-(ze+ie)+(ie-V),ie=P-He,W=P-(He+ie)+(ie-N),ie=z-Ye,X=z-(Ye+ie)+(ie-N),q===0&&W===0&&se===0&&X===0)||(Je=11093356479670487e-47*U+dw*Math.abs(st),st+=$e*X+Ye*q-(He*se+ze*W),st>=Je||-st>=Je))return st;Me=q*Ye,re=wo*q,oe=re-(re-q),me=q-oe,re=wo*Ye,xe=re-(re-Ye),we=Ye-xe,Ie=me*we-(Me-oe*xe-me*xe-oe*we),Pe=W*ze,re=wo*W,oe=re-(re-W),me=W-oe,re=wo*ze,xe=re-(re-ze),we=ze-xe,Ne=me*we-(Pe-oe*xe-me*xe-oe*we),Ce=Ie-Ne,ie=Ie-Ce,Ho[0]=Ie-(Ce+ie)+(ie-Ne),Se=Me+Ce,ie=Se-Me,qe=Me-(Se-ie)+(Ce-ie),Ce=qe-Pe,ie=qe-Ce,Ho[1]=qe-(Ce+ie)+(ie-Pe),ke=Se+Ce,ie=ke-Se,Ho[2]=Se-(ke-ie)+(Ce-ie),Ho[3]=ke;const Qe=cx(4,Sd,4,Ho,Fv);Me=$e*X,re=wo*$e,oe=re-(re-$e),me=$e-oe,re=wo*X,xe=re-(re-X),we=X-xe,Ie=me*we-(Me-oe*xe-me*xe-oe*we),Pe=He*se,re=wo*He,oe=re-(re-He),me=He-oe,re=wo*se,xe=re-(re-se),we=se-xe,Ne=me*we-(Pe-oe*xe-me*xe-oe*we),Ce=Ie-Ne,ie=Ie-Ce,Ho[0]=Ie-(Ce+ie)+(ie-Ne),Se=Me+Ce,ie=Se-Me,qe=Me-(Se-ie)+(Ce-ie),Ce=qe-Pe,ie=qe-Ce,Ho[1]=qe-(Ce+ie)+(ie-Pe),ke=Se+Ce,ie=ke-Se,Ho[2]=Se-(ke-ie)+(Ce-ie),Ho[3]=ke;const dt=cx(Qe,Fv,4,Ho,Ov);Me=q*X,re=wo*q,oe=re-(re-q),me=q-oe,re=wo*X,xe=re-(re-X),we=X-xe,Ie=me*we-(Me-oe*xe-me*xe-oe*we),Pe=W*se,re=wo*W,oe=re-(re-W),me=W-oe,re=wo*se,xe=re-(re-se),we=se-xe,Ne=me*we-(Pe-oe*xe-me*xe-oe*we),Ce=Ie-Ne,ie=Ie-Ce,Ho[0]=Ie-(Ce+ie)+(ie-Ne),Se=Me+Ce,ie=Se-Me,qe=Me-(Se-ie)+(Ce-ie),Ce=qe-Pe,ie=qe-Ce,Ho[1]=qe-(Ce+ie)+(ie-Pe),ke=Se+Ce,ie=ke-Se,Ho[2]=Se-(ke-ie)+(Ce-ie),Ho[3]=ke;const wt=cx(dt,Ov,4,Ho,kv);return kv[wt-1]})(a,c,h,f,_,y,E)})(r[0],r[1],e[0],e[1],i[0],i[1]);return o>0?-1:o<0?1:0}function Oc(r,e){const i=r.point,o=e.point;return i[0]>o[0]?1:i[0]<o[0]?-1:i[1]!==o[1]?i[1]>o[1]?1:-1:(function(a,c,h){return a.left!==c.left?a.left?1:-1:ux(h,a.otherEvent.point,c.otherEvent.point)!==0?a.isBelow(c.otherEvent.point)?-1:1:!a.isSubject&&c.isSubject?1:-1})(r,e,i)}function kc(r,e,i){const o=new Ed(e,!1,r,r.isSubject),a=new Ed(e,!0,r.otherEvent,r.isSubject);return el(r.point,r.otherEvent.point)&&console.warn("what is that, a collapsed segment?",r),o.contourId=a.contourId=r.contourId,Oc(a,r.otherEvent)>0&&(r.otherEvent.left=!0,a.left=!1),r.otherEvent.otherEvent=a,r.otherEvent=o,i.push(a),i.push(o),i}function tg(r,e){return r[0]*e[1]-r[1]*e[0]}function hx(r,e){return r[0]*e[0]+r[1]*e[1]}function dx(r,e,i){const o=(function(_,y,v,b){const T=[y[0]-_[0],y[1]-_[1]],E=[b[0]-v[0],b[1]-v[1]];function C(se,X,ie){return[se[0]+X*ie[0],se[1]+X*ie[1]]}const P=[v[0]-_[0],v[1]-_[1]];let R=tg(T,E),z=R*R;const V=hx(T,T);if(z>0){const se=tg(P,E)/R;if(se<0||se>1)return null;const X=tg(P,T)/R;return X<0||X>1?null:se===0||se===1?[C(_,se,T)]:X===0||X===1?[C(v,X,E)]:[C(_,se,T)]}if(R=tg(P,T),z=R*R,z>0)return null;const N=hx(T,P)/V,U=N+hx(T,E)/V,q=Math.min(N,U),W=Math.max(N,U);return q<=1&&W>=0?q===1?[C(_,q>0?q:0,T)]:W===0?[C(_,W<1?W:1,T)]:[C(_,q>0?q:0,T),C(_,W<1?W:1,T)]:null})(r.point,r.otherEvent.point,e.point,e.otherEvent.point),a=o?o.length:0;if(a===0||a===1&&(el(r.point,e.point)||el(r.otherEvent.point,e.otherEvent.point))||a===2&&r.isSubject===e.isSubject)return 0;if(a===1)return!el(r.point,o[0])&&!el(r.otherEvent.point,o[0])&&kc(r,o[0],i),!el(e.point,o[0])&&!el(e.otherEvent.point,o[0])&&kc(e,o[0],i),1;const c=[];let h=!1,f=!1;return el(r.point,e.point)?h=!0:Oc(r,e)===1?c.push(e,r):c.push(r,e),el(r.otherEvent.point,e.otherEvent.point)?f=!0:Oc(r.otherEvent,e.otherEvent)===1?c.push(e.otherEvent,r.otherEvent):c.push(r.otherEvent,e.otherEvent),h&&f||h?(e.type=1,r.type=e.inOut===r.inOut?2:3,h&&!f&&kc(c[1].otherEvent,c[0].point,i),2):f?(kc(c[0],c[1].point,i),3):c[0]!==c[3].otherEvent?(kc(c[0],c[1].point,i),kc(c[1],c[2].point,i),3):(kc(c[0],c[1].point,i),kc(c[3].otherEvent,c[2].point,i),3)}function fw(r,e){if(r===e)return 0;if(ux(r.point,r.otherEvent.point,e.point)!==0||ux(r.point,r.otherEvent.point,e.otherEvent.point)!==0)return el(r.point,e.point)?r.isBelow(e.otherEvent.point)?-1:1:r.point[0]===e.point[0]?r.point[1]<e.point[1]?-1:1:Oc(r,e)===1?e.isAbove(r.point)?-1:1:r.isBelow(e.point)?-1:1;if(r.isSubject!==e.isSubject)return r.isSubject?-1:1;{let i=r.point,o=e.point;if(i[0]===o[0]&&i[1]===o[1])return i=r.otherEvent.point,o=e.otherEvent.point,i[0]===o[0]&&i[1]===o[1]?0:(r.contourId??0)>(e.contourId??0)?1:-1}return Oc(r,e)===1?1:-1}class pw{constructor(){this.points=[],this.holeIds=[],this.holeOf=null,this.depth=null}isExterior(){return this.holeOf==null}}function mw(r,e,i,o){let a,c=r+1,h=e[r].point;const f=e.length;for(c<f&&(a=e[c].point);c<f&&a[0]===h[0]&&a[1]===h[1];){if(!i[c])return c;c++,c<f&&(a=e[c].point)}for(c=r-1;i[c]&&c>o;)c--;return c}function _w(r,e,i){const o=new pw;if(r.prevInResult!=null){const a=r.prevInResult,c=a.outputContourId;if(a.resultTransition>0){const h=e[c];if(h.holeOf!=null){const f=h.holeOf;e[f].holeIds.push(i),o.holeOf=f,o.depth=e[c].depth}else e[c].holeIds.push(i),o.holeOf=c,o.depth=e[c].depth+1}else o.holeOf=null,o.depth=e[c].depth}else o.holeOf=null,o.depth=0;return o}const Nv=Math.max,Vv=Math.min;let ig=0;function Uv(r,e,i,o,a,c){let h,f,_,y,v,b;for(h=0,f=r.length-1;h<f;h++){if(_=r[h],y=r[h+1],v=new Ed(_,!1,void 0,e),b=new Ed(y,!1,v,e),v.otherEvent=b,_[0]===y[0]&&_[1]===y[1])continue;v.contourId=b.contourId=i,c||(v.isExteriorRing=!1,b.isExteriorRing=!1),Oc(v,b)>0?b.left=!0:v.left=!0;const T=_[0],E=_[1];a[0]=Vv(a[0],T),a[1]=Vv(a[1],E),a[2]=Nv(a[2],T),a[3]=Nv(a[3],E),o.push(v),o.push(b)}}const rg=[];function jv(r,e,i){let o=r,a=e;typeof r[0][0][0]=="number"&&(o=[r]),typeof e[0][0][0]=="number"&&(a=[e]);let c=(function(T,E,C){let P=null;return T.length*E.length===0&&(C===0?P=rg:C===2?P=T:(C===1||C===3)&&(P=T.length===0?E:T)),P})(o,a,i);if(c)return c===rg?null:c;const h=[1/0,1/0,-1/0,-1/0],f=[1/0,1/0,-1/0,-1/0],_=(function(T,E,C,P,R){const z=new sc(void 0,Oc);let V,N,U,q,W,se;for(U=0,q=T.length;U<q;U++)for(V=T[U],W=0,se=V.length;W<se;W++)N=W===0,N&&ig++,Uv(V[W],!0,ig,z,C,N);for(U=0,q=E.length;U<q;U++)for(V=E[U],W=0,se=V.length;W<se;W++)N=W===0,R===2&&(N=!1),N&&ig++,Uv(V[W],!1,ig,z,P,N);return z})(o,a,h,f,i);if(c=(function(T,E,C,P,R){let z=null;return(C[0]>P[2]||P[0]>C[2]||C[1]>P[3]||P[1]>C[3])&&(R===0?z=rg:R===2?z=T:(R===1||R===3)&&(z=T.concat(E))),z})(o,a,h,f,i),c)return c===rg?null:c;const y=(function(T,E,C,P,R,z){const V=new sx(fw),N=[],U=Math.min(P[2],R[2]);let q,W,se;for(;T.length!==0;){let X=T.pop();if(N.push(X),z===0&&X.point[0]>U||z===2&&X.point[0]>P[2])break;if(X.left){W=q=V.insert(X),se=V.minNode(),q=q!==se?V.prev(q):null,W=V.next(W);const ie=q?q.key:null;let re;if(zp(X,ie,z),W&&dx(X,W.key,T)===2&&(zp(X,ie,z),zp(W.key,X,z)),q&&dx(q.key,X,T)===2){let oe=q;oe=oe!==se?V.prev(oe):null,re=oe?oe.key:null,zp(ie,re,z),zp(X,ie,z)}}else X=X.otherEvent,W=q=V.find(X),q&&W&&(q=q!==se?V.prev(q):null,W=V.next(W),V.remove(X),W&&q&&dx(q.key,W.key,T))}return N})(_,0,0,h,f,i),v=(function(T){let E,C;const P=(function(V){let N,U,q,W,se;const X=[];for(U=0,q=V.length;U<q;U++)N=V[U],(N.left&&N.inResult||!N.left&&N.otherEvent.inResult)&&X.push(N);let ie=!1;for(;!ie;)for(ie=!0,U=0,q=X.length;U<q;U++)U+1<q&&Oc(X[U],X[U+1])===1&&(W=X[U],X[U]=X[U+1],X[U+1]=W,ie=!1);for(U=0,q=X.length;U<q;U++)N=X[U],N.otherPos=U;for(U=0,q=X.length;U<q;U++)N=X[U],N.left||(se=N.otherPos,N.otherPos=N.otherEvent.otherPos,N.otherEvent.otherPos=se);return X})(T),R={},z=[];for(E=0,C=P.length;E<C;E++){if(R[E])continue;const V=z.length,N=_w(P[E],z,V),U=se=>{R[se]=!0,se<P.length&&P[se]&&(P[se].outputContourId=V)};let q=E,W=E;for(N.points.push(P[E].point);U(q),q=P[q].otherPos,U(q),N.points.push(P[q].point),q=mw(q,P,R,W),!(q==W||q>=P.length)&&P[q];);z.push(N)}return z})(y),b=[];for(let T=0;T<v.length;T++){let E=v[T];if(E.isExterior()){let C=[E.points];for(let P=0;P<E.holeIds.length;P++)C.push(v[E.holeIds[P]].points);b.push(C)}}return b}function gw(r,e){const i=jv(fx(r),fx([e]),0);return i==null?[]:$v(i)}function yw(r,e,i=0){let a=fx(r,65536);const c=[];for(;e.valid();e.next()){const[h,f]=e.get();let _=h.x*65536,y=h.y*65536,v=f.x*65536,b=f.y*65536;const T=v-_,E=b-y,C=Math.hypot(T,E);if(C===0)continue;_-=T*i,y-=E*i,v+=T*i,b+=E*i;const P=Math.trunc(E/C*3),R=-Math.trunc(T/C*3);c.push([[[_,y],[v,b],[v+P,b+R],[_+P,y+R],[_,y]]])}return c.length>0&&(a=jv(a,c,2)),$v(a,1/65536,.001)}function fx(r,e=1){return[r.map(i=>i.map(o=>[o.x*e,o.y*e]))]}function Gv(r,e){const i=Math.floor(r)+.5;return Math.abs(r-i)<=e?Math.round(i):Math.round(r)}class xw{constructor(e){this.xs=[],this.ys=[],this.ixs=[],this.iys=[],this.buckets=new Map,this.tolerance=e}canonicalize(e,i){const o=this.tolerance,a=Math.floor(e/o),c=Math.floor(i/o);for(let _=-1;_<=1;_++){const y=this.buckets.get(a+_);if(y)for(let v=-1;v<=1;v++){const b=y.get(c+v);if(b){for(const T of b)if(Math.abs(this.xs[T]-e)<=o&&Math.abs(this.ys[T]-i)<=o){const E=this.ixs[T],C=this.iys[T];return this.xs[T]===e&&this.ys[T]===i||this.store(e,i,E,C,a,c),[E,C]}}}}const h=Gv(e,o),f=Gv(i,o);return this.store(e,i,h,f,a,c),[h,f]}store(e,i,o,a,c,h){const f=this.xs.length;this.xs.push(e),this.ys.push(i),this.ixs.push(o),this.iys.push(a);let _=this.buckets.get(c);_||(_=new Map,this.buckets.set(c,_));let y=_.get(h);y||(y=[],_.set(h,y)),y.push(f)}}function $v(r,e=1,i){const o=i!=null?new xw(i):null;return r.map(a=>a.map((c,h)=>{const f=c.map(_=>{const y=_[0]*e,v=_[1]*e;if(o){const[b,T]=o.canonicalize(y,v);return new Ue(b,T)}return new Ue(Math.round(y),Math.round(v))});return h>0&&f.reverse(),f}))}class px{constructor(){this.frcCoverage=new Set,this.featureTriSegments=[],this.frcPerLevel=new Map,this.frcNonRoadSegments=new Fi}empty(){return this.frcCoverage.size===0}}function qv(r,e,i){if(r.frcCoverage.size===0||r.featureTriSegments.length===0)return;const o=i.get(),a=e.uint16,c=[];r.featureTriSegments.sort((b,T)=>b.segIdx!==T.segIdx?b.segIdx-T.segIdx:b.frc===null&&T.frc===null?0:b.frc===null?-1:T.frc===null?1:T.frc-b.frc);const h=new Map;let f=0,_=r.featureTriSegments[0].frc,y={vertexOffset:o[f].vertexOffset,primitiveOffset:0,vertexLength:o[f].vertexLength,primitiveLength:0,vaos:{},sortKey:void 0};const v=()=>{y.primitiveLength>0&&(h.has(_)||h.set(_,[]),h.get(_).push({...y}))};for(const b of r.featureTriSegments){b.segIdx!==f&&(v(),f=b.segIdx,_=b.frc,y={vertexOffset:o[f].vertexOffset,primitiveOffset:c.length/3,vertexLength:o[f].vertexLength,primitiveLength:0,vaos:{},sortKey:void 0}),b.frc!==_&&(v(),_=b.frc,y={...y,primitiveOffset:c.length/3,primitiveLength:0});for(let T=b.start;T<b.end;T++)c.push(a[T]);y.primitiveLength+=(b.end-b.start)/3}v();for(let b=0;b<c.length;b++)a[b]=c[b];for(const[b,T]of h)b!==null?r.frcPerLevel.set(b,new Fi(T)):r.frcNonRoadSegments=new Fi(T);r.featureTriSegments=[]}nt(px,"FrcSegmentData");const vw={motorway:0,motorway_link:0,trunk:1,trunk_link:1,primary:2,primary_link:2,secondary:3,secondary_link:3,tertiary:4,tertiary_link:4,unclassified:5,unclassified_link:5,street:6,street_limited:6,residential:6,service:7,living_street:7,pedestrian:8,track:8,path:8,footway:8,cycleway:8,sidewalk:8,crossing:8};function ng(r){for(const e of["class","incident_class"]){const i=r[e];if(typeof i!="string")continue;const o=vw[i];if(o!==void 0)return o}return null}function mx(r,e,i){for(const o of r)if(o.startsWith("(")){const a=o.indexOf(")");if(a===-1)continue;if(o.slice(1,a)===e&&o.slice(a+1)===i)return!0}else if(o===i)return!0;return!1}class Hv{constructor(e,i,o){this.elevationMode=i,i&&(this.elevationBufferData=new Pv(e.layers,e.zoom,e.lut)),o&&(this.frcData=new px)}isEmpty(){const e=!this.elevationBufferData||this.elevationBufferData.isEmpty(),i=!this.frcData||this.frcData.empty();return e&&i}needsUpload(){return!!this.elevationBufferData&&this.elevationBufferData.needsUpload()}trackFeatureFrc(e){if(!this.frcData)return null;const i=ng(e||{});return i!==null&&this.frcData.frcCoverage.add(i),i}recordFeatureRange(e,i,o,a){if(!this.frcData||o<=i)return;const c=e.bufferData.triangleSegments.get();this.frcData.featureTriSegments.push({start:3*i,end:3*o,segIdx:c.length>0?c.length-1:0,frc:a})}buildFrcSegments(e){this.frcData&&!this.frcData.empty()&&qv(this.frcData,e.bufferData.indexArray,e.bufferData.triangleSegments)}handleFeature(e,i,o,a,c,h){const f=new Array;if(!this.elevationMode)return!1;const _=Dp(e,c,void 0,a);if(!_)return!1;{const v=this.clipPolygonsToTile(i,1);v.length>0&&f.push({polygons:v,elevationFeature:_.feature,elevationTileID:_.tileId})}const y={guardRailEnabled:h.layers[0].layout.get("fill-construct-bridge-guard-rail").evaluate(e,{},a),featureIndex:o};for(const v of f)if(v.elevationFeature){if(this.elevationMode==="hd-road-base"){this.elevatedStructures||(this.elevatedStructures=new qo(v.elevationTileID,h.layers,h.zoom,h.lut));const T=v.elevationFeature.isTunnel();let E=0;Object.hasOwn(e.properties,P_)&&(E=+e.properties[P_]),this.elevatedStructures.addPortalCandidates(v.elevationFeature.id,v.polygons,T,v.elevationFeature,E)}v.elevationFeature.constantHeight==null&&(v.polygons=this.prepareElevatedPolygons(v.polygons,v.elevationFeature,v.elevationTileID));const b=new Td(a,v.elevationTileID);this.addElevatedGeometry(h,v.polygons,b,v.elevationFeature,this.elevationMode==="hd-road-base"?0:.05,o,y)}return!0}populatePaintArrays(e,i,o,a,c,h,f){this.elevationBufferData&&this.elevationBufferData.populatePaintArrays(e,i,o,a,c,h,f)}update(e,i,o,a,c,h,f,_){this.elevationBufferData&&this.elevationBufferData.update(e,i,o,a,c,h,f,_),this.elevatedStructures&&this.elevatedStructures.update(e,i,o,a,c,h,f,_)}updateExpressions(e){this.elevationBufferData&&this.elevationBufferData.programConfigurations.updateExpressions(e),this.elevatedStructures&&(this.elevatedStructures.bridgeProgramConfigurations.updateExpressions(e),this.elevatedStructures.tunnelProgramConfigurations.updateExpressions(e))}upload(e){this.elevationBufferData&&this.elevationBufferData.upload(e),this.elevatedStructures&&this.elevatedStructures.upload(e)}destroy(){this.elevationBufferData&&this.elevationBufferData.destroy(),this.elevatedStructures&&this.elevatedStructures.destroy()}getUnevaluatedPortalGraph(){return this.elevatedStructures?this.elevatedStructures.unevaluatedPortals:void 0}setEvaluatedPortalGraph(e,i,o,a,c,h){this.elevatedStructures&&(this.elevatedStructures.construct(e),this.elevatedStructures.populatePaintArrays(i,o,a,c,h))}addElevatedGeometry(e,i,o,a,c,h,f){const _={elevation:a,elevationSampler:o,bias:c,index:h,featureInfo:f},[y,v]=e.addGeometry(i,this.elevationBufferData,_,this.elevatedStructures);this.elevationBufferData.heightRange==null?this.elevationBufferData.heightRange={min:y,max:v}:(this.elevationBufferData.heightRange.min=Math.min(this.elevationBufferData.heightRange.min,y),this.elevationBufferData.heightRange.max=Math.max(this.elevationBufferData.heightRange.max,v))}prepareElevatedPolygons(e,i,o){const a=1/yo(o),c=[];for(const h of e){const f=yw(h,new Dv(i,a),.1);c.push(...f)}return c}clipPolygonsToTile(e,i){const o=-i,a=-i,c=rt+i,h=rt+i;let f=0;const _=[],y=[];for(;f<e.length;f++){const T=e[f],E=Us(T);(E.min.x>=o&&E.max.x<=c&&E.min.y>=a&&E.max.y<=h?_:y).push(T)}if(_.length===e.length)return e;const v=[new Ue(o,a),new Ue(c,a),new Ue(c,h),new Ue(o,h),new Ue(o,a)],b=_;for(const T of y)b.push(...gw(T,v));return b}}function bw(r,e){return r.nextPoint.sub(e.at(-2)).unit()}function ww(r,e){return e[1].sub(r.prevPoint).unit()}nt(Hv,"FillHDExtension"),nt(qo,"ElevatedStructures");class Zv{constructor(e,i){this.elevationEnabled=e,this.hasDeferredElevationFeatures=!1,i&&(this.frcData=new px)}isEmpty(){const e=!this.elevationEnabled||this.heightRange===void 0,i=!this.frcData||this.frcData.empty();return e&&i}trackFeatureFrc(e){if(!this.frcData)return null;const i=ng(e||{});return i!==null&&this.frcData.frcCoverage.add(i),i}recordFeatureRange(e,i,o,a){if(!this.frcData||o<=i)return;const c=e.segments.get();this.frcData.featureTriSegments.push({start:3*i,end:3*o,segIdx:c.length>0?c.length-1:0,frc:a})}buildFrcSegments(e){this.frcData&&!this.frcData.empty()&&qv(this.frcData,e.indexArray,e.segments)}handleFeature(e,i,o,a,c,h,f,_,y,v,b){if(!this.elevationEnabled)return!1;if(!b.terrainEnabled){const R=Dp(e,a,c?c.registry:void 0,o),z=e.properties!=null&&Object.hasOwn(e.properties,Ps)&&!Number.isNaN(+e.properties[Ps]);if(!R&&z&&h&&(!c||!c.allProvidersReady))return this.hasDeferredElevationFeatures=!0,!0;if(R){let V=R.feature,N=R.tileId;if(!R.tileId.equals(o)){const W=this.mergedFeatureCache?this.mergedFeatureCache.get(V.id):void 0;if(W)V=W,N=o;else{const se=(function(X,ie,re){if(!X.properties||!ie||ie.length===0)return[];const oe=+X.properties[Ps];if(Number.isNaN(oe))return[];const me=Lv(ie,oe);if(me<0)return[];const xe=[];for(let we=me;we<ie.length&&ie[we].feature.id===oe;we++){const Ce=ie[we];(Ce.tileId.isChildOf(re)||re.isChildOf(Ce.tileId)||Ce.feature.constantHeight!=null)&&xe.push(Ce)}return xe})(e,c?c.registry:void 0,o);se.length>1&&(V=(function(X,ie){const re=ie.slice().sort((Me,Ie)=>Ie.tileId.z-Me.tileId.z),oe=new Ue(Number.POSITIVE_INFINITY,Number.POSITIVE_INFINITY),me=new Ue(Number.NEGATIVE_INFINITY,Number.NEGATIVE_INFINITY),xe=[];for(const Me of re){const Ie=new Td(Me.tileId,X);for(const Ne of Me.feature.vertices)xe.push({position:Ie.pointTransform(Ne.position),height:Ne.height,extent:Ne.extent,index:Ne.index});const Pe=Me.feature.safeArea;Nu[0]=Pe.min.x,Nu[1]=Pe.min.y,Vu[0]=Pe.max.x,Vu[1]=Pe.max.y,Ie.pointTransformInPlace(Nu),Ie.pointTransformInPlace(Vu),oe.x=Math.min(oe.x,Nu[0],Vu[0]),oe.y=Math.min(oe.y,Nu[1],Vu[1]),me.x=Math.max(me.x,Nu[0],Vu[0]),me.y=Math.max(me.y,Nu[1],Vu[1])}const we={min:oe,max:me};if(re[0].feature.constantHeight!=null)return new Vl(re[0].feature.id,we,re[0].feature.constantHeight);xe.sort((Me,Ie)=>Me.index-Ie.index);const Ce=[];for(const Me of xe)Ce.length!==0&&Ce.at(-1).index===Me.index||Ce.push(Me);const Se=[];for(let Me=1;Me<Ce.length;Me++)Ce[Me].index-Ce[Me-1].index<=1&&Se.push({a:Me-1,b:Me});const qe=1/yo(X);return new Vl(re[0].feature.id,we,void 0,Ce,Se,qe)})(o,se),N=o,this.mergedFeatureCache||(this.mergedFeatureCache=new Map),this.mergedFeatureCache.set(V.id,V))}}const U=pd(i,-1,-1,8193,8193),q=this.prepareElevatedLines(U,V,N,o);for(const W of q){const se=b.layoutVertexArray.length;b.addLine(W,e,o,f,_,y,v);const X=new Td(o,N),ie=b.showElevationIdDebug?uw(V.id):null;for(let re=se;re<b.layoutVertexArray.length;re++){const oe=new Ue(b.layoutVertexArray.int16[6*re]>>1,b.layoutVertexArray.int16[6*re+1]>>1),me=X.pointElevation(oe,V,.05);this.updateHeightRange(me),re<b.zOffsetVertexArray.length?b.zOffsetVertexArray.float32[4*re]=me:b.zOffsetVertexArray.emplaceBack(me,0,0,0),ie?re<b.elevationIdColVertexArray.length?(b.elevationIdColVertexArray.float32[3*re]=ie[0],b.elevationIdColVertexArray.float32[3*re+1]=ie[1],b.elevationIdColVertexArray.float32[3*re+2]=ie[2]):b.elevationIdColVertexArray.emplaceBack(ie[0],ie[1],ie[2]):b.showElevationIdDebug&&(re<b.elevationIdColVertexArray.length?(b.elevationIdColVertexArray.float32[3*re]=0,b.elevationIdColVertexArray.float32[3*re+1]=0,b.elevationIdColVertexArray.float32[3*re+2]=0):b.elevationIdColVertexArray.emplaceBack(0,0,0))}}return!0}if(z&&h&&c&&c.allProvidersReady&&c.hasCoveringTile)return!0}const T=!(!e.properties||!Object.hasOwn(e.properties,"mapbox_line_metrics"))&&e.properties.mapbox_line_metrics,E=b.layoutVertexArray.length,C=[],P=pd(i,-1,-1,8193,8193,C);for(let R=0;R<P.length;R++){const z=P[R],V=C[R],N={progress:{min:V.progress.min,max:V.progress.max},nextDir:bw(V,z),prevDir:ww(V,z)};b.addLine(z,e,o,f,_,y,v,N,T&&V.parentIndex>0?V.parentIndex:null)}return b.fillNonElevatedRoadSegment(E),!0}prepareElevatedLines(e,i,o,a){if(i.constantHeight!=null)return e;const c=[],h=1/yo(a),f=o.equals(a)?null:new Td(o,a);for(const _ of e)Ay(_,new Dv(i,h,f),0,c);return c}updateHeightRange(e){this.heightRange?(this.heightRange.min=Math.min(this.heightRange.min,e),this.heightRange.max=Math.max(this.heightRange.max,e)):this.heightRange={min:e,max:e}}endPopulate(){this.mergedFeatureCache=void 0}}nt(Zv,"LineHDExtension");class Wv{constructor(){this.elevatedLayoutVertexArray=new Js,this.hasElevation=!1}beginFeature(e,i,o){const a=Dp(e,i,void 0,o);this.currentFeatureElevation=a?a.feature:void 0}writeVertexQuad(e,i){const o=this.currentFeatureElevation?this.currentFeatureElevation.pointElevation(new Ue(e,i)):0;this.hasElevation=this.hasElevation||o!==0;for(let a=0;a<4;a++)this.elevatedLayoutVertexArray.emplaceBack(o)}finalize(){this.hasElevation||(this.elevatedLayoutVertexArray=void 0)}upload(e){this.elevatedLayoutVertexArray&&!this.elevatedLayoutVertexBuffer&&(this.elevatedLayoutVertexBuffer=e.createVertexBuffer(this.elevatedLayoutVertexArray,Py.members))}destroy(){this.elevatedLayoutVertexBuffer&&this.elevatedLayoutVertexBuffer.destroy()}}nt(Wv,"CircleHDExtension");const og=(r,e,i,o)=>{for(let a=0;a<e;a++)r.emplaceBack(i[0],i[1],i[2],o[0],o[1],o[2])};class Xv{constructor(){this.elevationFeatures=[],this.elevationFeatureTileIds=[],this.elevationFeatureIdToIndex=new Map,this.elevationStateComplete=!1,this.hasDeferredElevationFeatures=!1,this.elevationParams=null,this.crossSourceElevationEnabled=!1,this.terrainEnabled=!1}configureCrossSource(e,i,o,a){this.consumerCanonical=e,this.elevationParams=i,this.crossSourceElevationEnabled=o,this.terrainEnabled=a}addElevationFeatures(e,i){for(const o of e)this.elevationFeatureIdToIndex.set(o.id,this.elevationFeatures.length),this.elevationFeatures.push(o),this.elevationFeatureTileIds.push(i)}resolveRoadElevation(e,i){const o=this.elevationFeatureIdToIndex.get(i);if(o!==void 0)return o;if(this.terrainEnabled||!this.crossSourceElevationEnabled)return 65535;const a=Dp(e,void 0,this.elevationParams?this.elevationParams.registry:void 0,this.consumerCanonical);if(a){const c=this.elevationFeatures.length;return this.elevationFeatureIdToIndex.set(i,c),this.elevationFeatures.push(a.feature),this.elevationFeatureTileIds.push(a.tileId),c}return this.elevationParams&&this.elevationParams.allProvidersReady?65535:(this.hasDeferredElevationFeatures=!0,"defer")}getElevationFeatureSampler(e,i){if(i.equals(e))return new Td(e,i);this.elevationFeatureSamplerCache||(this.elevationFeatureSamplerCache=new Map);let o=this.elevationFeatureSamplerCache.get(i.key);return o||(o=new Td(e,i),this.elevationFeatureSamplerCache.set(i.key,o)),o}isCrossTileRoadElevation(e,i){if(e===65535||e>=this.elevationFeatures.length)return!1;const o=this.elevationFeatureTileIds[e];return o!=null&&!o.equals(i)}getRoadFeatureHeightAtAnchor(e,i,o){if(e===65535||e>=this.elevationFeatures.length)return null;const a=this.elevationFeatures[e],c=this.elevationFeatureTileIds[e];return c.equals(o)?a.pointElevation(i):this.getElevationFeatureSampler(o,c).pointElevation(new Ue(i.x,i.y),a,0)}sampleRoadFeatureHeight(e,i,o){const a=this.getRoadFeatureHeightAtAnchor(e,i,o);return a===null?void 0:a}clearWorkerState(){this.consumerCanonical=void 0,this.elevationParams=null,this.crossSourceElevationEnabled=!1,this.terrainEnabled=!1,this.elevationFeatureIdToIndex.clear()}updateRoadElevation(e,i){if(this.elevationStateComplete)return;this.elevationStateComplete=!0,e.hasAnyZOffset=!1;let o=!1;const a=yo(i),c=1/a;let h=!1,f=!1;for(let _=0;_<e.symbolInstances.length;_++){const y=e.symbolInstances.get(_),v=ur(1,0,0),b=ur(0,1,0),{numHorizontalGlyphVertices:T,numVerticalGlyphVertices:E,numIconVertices:C,numVerticalIconVertices:P}=y,R=T>0||E>0,z=C>0,V=y.elevationFeatureIndex,N=V<this.elevationFeatures.length?this.elevationFeatures[V]:void 0;if(N){const U=new Ue(y.tileAnchorX,y.tileAnchorY),q=this.sampleRoadFeatureHeight(V,U,i),W=q!==void 0?.075+q:.075;y.zOffset!==W&&(o=!0,y.zOffset=W),W!==0&&(e.hasAnyZOffset=!0);const se=N.computeSlopeNormal(U,c),X=xs(Qn(),ur(0,0,1),se);Xo(v,v,X),Xo(b,b,X),v[2]*=a,b[2]*=a,v[0]===1&&v[1]===0&&v[2]===0&&b[0]===0&&b[1]===1&&b[2]===0||(h=h||R,f=f||z)}if(R&&(og(e.text.orientationVertexArray,T,v,b),og(e.text.orientationVertexArray,E,v,b)),z){const{placedIconSymbolIndex:U,verticalPlacedIconSymbolIndex:q}=y;U>=0&&og(e.icon.orientationVertexArray,C,v,b),q>=0&&og(e.icon.orientationVertexArray,P,v,b)}}h||(e.text.orientationVertexArray=void 0),f||(e.icon.orientationVertexArray=void 0),o&&(e.zOffsetBuffersNeedUpload=!0,e.zOffsetSortDirty=!0)}getRoadFeatureHeightForPlacedSymbol(e,i,o,a,c){const h=e.symbolInstances.get(i.symbolInstanceIndices[o]);return this.getRoadFeatureHeightAtAnchor(h.elevationFeatureIndex,a,c)}getElevationFeatureForPlacedSymbol(e,i,o){const a=e.symbolInstances.get(i.symbolInstanceIndices[o]).elevationFeatureIndex;if(a<this.elevationFeatures.length)return this.elevationFeatures[a]}makeRoadSymbolElevationParams(e,i,o,a,c,h,f,_,y){const v=this.getElevationFeatureForPlacedSymbol(e,i,o),b=v!==void 0?v:null,T=e.symbolInstances.get(i.symbolInstanceIndices[o]);return this.isCrossTileRoadElevation(T.elevationFeatureIndex,a.canonical)?{getElevation:E=>{const C=this.getRoadFeatureHeightForPlacedSymbol(e,i,o,E,a.canonical);return(function(P,R,z,V,N,U){const q=V.upVector(R,z.x,z.y);return li(q,q,P*V.upVectorScale(R,N,U).metersToTile),[q[0],q[1],q[2]]})(C!==null?C:0,a.canonical,E,f,_,y)},elevation:h,elevationFeature:null}:{getElevation:c,elevation:h,elevationFeature:b}}}nt(Xv,"SymbolHDExtension",{omit:["consumerCanonical","elevationParams","crossSourceElevationEnabled","terrainEnabled","hasDeferredElevationFeatures","elevationFeatureIdToIndex"]});let ba=null,sg=null,_x=null,ag=null;const Yv=5120,Kv=5121,Jv=5122,Qv=5123,e0=5125,t0=5126,lg={[Yv]:Int8Array,[Kv]:Uint8Array,[Jv]:Int16Array,[Qv]:Uint16Array,[e0]:Uint32Array,[t0]:Float32Array},Tw={[Yv]:"DT_INT8",[Kv]:"DT_UINT8",[Jv]:"DT_INT16",[Qv]:"DT_UINT16",[e0]:"DT_UINT32",[t0]:"DT_FLOAT32"},Fp={SCALAR:1,VEC2:2,VEC3:3,VEC4:4,MAT2:4,MAT3:9,MAT4:16};function i0(r,e,i){const o=i.json.bufferViews.length,a=i.buffers.length;e.bufferView=o,i.json.bufferViews[o]={buffer:a,byteLength:r.byteLength},i.buffers[a]=r}const gx="KHR_draco_mesh_compression";function Sw(r,e){const i=r.extensions&&r.extensions[gx];if(!i)return;const o=new ba.Decoder,a=s0(e,i.bufferView),c=new ba.Mesh;if(!o.DecodeArrayToMesh(a,a.byteLength,c))throw new Error("Failed to decode Draco mesh");const h=e.json.accessors[r.indices],f=lg[h.componentType],_=h.count*f.BYTES_PER_ELEMENT,y=ba._malloc(_);f===Uint16Array?o.GetTrianglesUInt16Array(c,_,y):o.GetTrianglesUInt32Array(c,_,y),i0(ba.memory.buffer.slice(y,y+_),h,e),ba._free(y);for(const v of Object.keys(i.attributes)){const b=o.GetAttributeByUniqueId(c,i.attributes[v]),T=e.json.accessors[r.attributes[v]],E=Tw[T.componentType],C=T.count*Fp[T.type]*lg[T.componentType].BYTES_PER_ELEMENT,P=ba._malloc(C);o.GetAttributeDataArrayForAllPoints(c,b,ba[E],C,P),i0(ba.memory.buffer.slice(P,P+C),T,e),ba._free(P)}o.destroy(),c.destroy(),delete r.extensions[gx]}const cg="EXT_meshopt_compression";function Ew(r,e){if(!r.extensions||!r.extensions[cg])return;const i=r.extensions[cg],o=new Uint8Array(e.buffers[i.buffer],i.byteOffset||0,i.byteLength||0),a=new Uint8Array(i.count*i.byteStride);_x.decodeGltfBuffer(a,i.count,i.byteStride,o,i.mode,i.filter),r.buffer=e.buffers.length,r.byteOffset=0,e.buffers[r.buffer]=a.buffer,delete r.extensions[cg]}const r0=1179937895,n0=new TextDecoder("utf8");function o0(r,e){return new URL(r,e).href}async function Iw(r,e,i,o,a){const c=await fetch(o0(r.uri,o),{signal:a}),h=await c.arrayBuffer();e.buffers[i]=h}function s0(r,e){const i=r.json.bufferViews[e];return new Uint8Array(r.buffers[i.buffer],i.byteOffset||0,i.byteLength)}async function Aw(r,e,i,o,a){if(r.uri){const c=o0(r.uri,o),h=await fetch(c,{signal:a}),f=await h.blob(),_=await createImageBitmap(f);e.images[i]=_}else if(r.bufferView!==void 0){const c=s0(e,r.bufferView),h=new Blob([c],{type:r.mimeType}),f=await createImageBitmap(h);e.images[i]=f}}async function a0(r,e=0,i,o){const a={json:null,images:[],buffers:[]};if(new Uint32Array(r,e,1)[0]===r0){const E=new Uint32Array(r,e);let C=2;const P=(E[C++]>>2)-3,R=E[C++]>>2;if(C++,a.json=JSON.parse(n0.decode(E.subarray(C,C+R))),C+=R,C<P){const z=E[C++];C++;const V=e+(C<<2);a.buffers[0]=r.slice(V,V+z)}}else a.json=JSON.parse(n0.decode(new Uint8Array(r,e)));const{buffers:c,images:h,meshes:f,extensionsUsed:_,bufferViews:y}=a.json;if(c){const E=[];for(let C=0;C<c.length;C++){const P=c[C];P.uri?E.push(Iw(P,a,C,i,o)):a.buffers[C]||(a.buffers[C]=null)}await Promise.all(E)}o&&o.throwIfAborted();const v=[],b=_&&_.includes(gx),T=_&&_.includes(cg);if(b&&v.push((function(){if(!ba)return sg!=null||(sg=(function(E){let C,P=null;function R(){C=new Uint8Array(P.buffer)}function z(){throw new Error("Unexpected Draco error.")}return WebAssembly.instantiateStreaming(E,{a:{a:z,d:function(V,N,U){return C.copyWithin(V,N,N+U)},c:function(V){const N=C.length,U=Math.max(V>>>0,Math.ceil(1.2*N)),q=Math.ceil((U-N)/65536);try{return P.grow(q),R(),!0}catch{return!1}},b:z}}).then(V=>{const{Rb:N,Qb:U,P:q,T:W,X:se,Ja:X,La:ie,Qa:re,Va:oe,Wa:me,eb:xe,jb:we,f:Ce,e:Se,yb:qe,zb:Me,Ab:Ie,Bb:Pe,Db:Ne,Gb:ke}=V.instance.exports;P=Se;const $e=(()=>{let ze=0,He=0,Ye=0,st=0;return Je=>{Ye&&(N(st),N(ze),He+=Ye,Ye=ze=0),ze||(He+=128,ze=U(He));const Qe=Je.length+7&-8;let dt=ze;Qe>=He&&(Ye=Qe,dt=st=U(Qe));for(let wt=0;wt<Je.length;wt++)C[dt+wt]=Je[wt];return dt}})();return R(),Ce(),{memory:Se,_free:N,_malloc:U,Mesh:class{constructor(){this.ptr=q()}destroy(){W(this.ptr)}},Decoder:class{constructor(){this.ptr=X()}destroy(){we(this.ptr)}DecodeArrayToMesh(ze,He,Ye){const st=$e(ze),Je=ie(this.ptr,st,He,Ye.ptr);return!!se(Je)}GetAttributeByUniqueId(ze,He){return{ptr:re(this.ptr,ze.ptr,He)}}GetTrianglesUInt16Array(ze,He,Ye){oe(this.ptr,ze.ptr,He,Ye)}GetTrianglesUInt32Array(ze,He,Ye){me(this.ptr,ze.ptr,He,Ye)}GetAttributeDataArrayForAllPoints(ze,He,Ye,st,Je){xe(this.ptr,ze.ptr,He.ptr,Ye,st,Je)}},DT_INT8:qe(),DT_UINT8:Me(),DT_INT16:Ie(),DT_UINT16:Pe(),DT_UINT32:Ne(),DT_FLOAT32:ke()}})})(fetch(Do())).then(E=>{ba=E,sg=null})),sg})()),T&&v.push((function(){var E;if(!_x)return ag!=null||(ag=(E=fetch(Pi()),WebAssembly.instantiateStreaming(E,{}).then(C=>{const{sbrk:P,memory:R,meshopt_decodeVertexBuffer:z,meshopt_decodeIndexBuffer:V,meshopt_decodeIndexSequence:N,meshopt_decodeFilterOct:U,meshopt_decodeFilterQuat:q,meshopt_decodeFilterExp:W}=C.instance.exports,se={ATTRIBUTES:z,TRIANGLES:V,INDICES:N},X={OCTAHEDRAL:U,QUATERNION:q,EXPONENTIAL:W};return C.instance.exports.__wasm_call_ctors(),{decodeGltfBuffer(ie,re,oe,me,xe,we){const Ce=re+3&-4,Se=P(Ce*oe),qe=P(me.length),Me=new Uint8Array(R.buffer);Me.set(me,qe);const Ie=se[xe](Se,re,oe,qe,me.length);if(Ie===0&&X[we]&&X[we](Se,Ce,oe),ie.set(Me.subarray(Se,Se+re*oe)),P(Se-P(0)),Ie!==0)throw new Error(`Malformed buffer data: ${Ie}`)}}})).then(C=>{_x=C,ag=null})),ag})()),h)for(let E=0;E<h.length;E++)v.push(Aw(h[E],a,E,i,o));if(v.length&&await Promise.all(v),o&&o.throwIfAborted(),b&&f)for(const{primitives:E}of f)for(const C of E)Sw(C,a);if(T&&f&&y)for(const E of y)Ew(E,a);return a}async function l0(r,e){const{data:i}=await Yl({url:r},e);return a0(i,0,r,e)}class ug{constructor(e,i,o,a){if(this.triangleCount=i.length/3,this.min=new Ue(0,0),this.max=new Ue(0,0),this.xScale=0,this.yScale=0,this.cellsX=0,this.cellsY=0,this.cells=[],this.payload=[],this.triangleCount===0||e.length===0)return;const[c,h]=[e[0].clone(),e[0].clone()];for(let b=1;b<e.length;++b){const T=e[b];c.x=Math.min(c.x,T.x),c.y=Math.min(c.y,T.y),h.x=Math.max(h.x,T.x),h.y=Math.max(h.y,T.y)}if(a){const b=Math.ceil(Math.max(h.x-c.x,h.y-c.y)/a);o=Math.max(o,b)}if(o===0)return;this.min=c,this.max=h;const f=this.max.sub(this.min);f.x=Math.max(f.x,1),f.y=Math.max(f.y,1);const _=Math.max(f.x,f.y)/o;this.cellsX=Math.max(1,Math.ceil(f.x/_)),this.cellsY=Math.max(1,Math.ceil(f.y/_)),this.xScale=1/_,this.yScale=1/_;const y=[];for(let b=0;b<this.triangleCount;b++){const T=e[i[3*b+0]].sub(this.min),E=e[i[3*b+1]].sub(this.min),C=e[i[3*b+2]].sub(this.min),P=tl(Math.floor(Math.min(T.x,E.x,C.x)),this.xScale,this.cellsX),R=tl(Math.floor(Math.max(T.x,E.x,C.x)),this.xScale,this.cellsX),z=tl(Math.floor(Math.min(T.y,E.y,C.y)),this.yScale,this.cellsY),V=tl(Math.floor(Math.max(T.y,E.y,C.y)),this.yScale,this.cellsY),N=new Ue(0,0),U=new Ue(0,0),q=new Ue(0,0),W=new Ue(0,0);for(let se=z;se<=V;++se){N.y=U.y=se*_,q.y=W.y=(se+1)*_;for(let X=P;X<=R;++X)N.x=q.x=X*_,U.x=W.x=(X+1)*_,(dd(T,E,C,N,U,W)||dd(T,E,C,N,W,q))&&y.push({cellIdx:se*this.cellsX+X,triIdx:b})}}if(y.length===0)return;y.sort((b,T)=>b.cellIdx-T.cellIdx||b.triIdx-T.triIdx);let v=0;for(;v<y.length;){const b=y[v].cellIdx,T={start:this.payload.length,len:0};for(;v<y.length&&y[v].cellIdx===b;)++T.len,this.payload.push(y[v++].triIdx);this.cells[b]=T}}_lazyInitLookup(){this.lookup||(this.lookup=new Uint8Array(Math.ceil(this.triangleCount/8))),this.lookup.fill(0)}queryPoint(e,i){if(this.triangleCount===0||this.cells.length===0||e.x>this.max.x||this.min.x>e.x||e.y>this.max.y||this.min.y>e.y)return;const o=tl(e.x-this.min.x,this.xScale,this.cellsX),a=tl(e.y-this.min.y,this.yScale,this.cellsY),c=this.cells[a*this.cellsX+o];if(c){this._lazyInitLookup();for(let h=0;h<c.len;h++){const f=this.payload[c.start+h],_=Math.floor(f/8),y=1<<f%8;if(!(this.lookup[_]&y)&&(this.lookup[_]|=y,i.push(f),i.length===this.triangleCount))return}}}query(e,i,o){if(this.triangleCount===0||this.cells.length===0||e.x>this.max.x||this.min.x>i.x||e.y>this.max.y||this.min.y>i.y)return;this._lazyInitLookup();const a=tl(e.x-this.min.x,this.xScale,this.cellsX),c=tl(i.x-this.min.x,this.xScale,this.cellsX),h=tl(e.y-this.min.y,this.yScale,this.cellsY),f=tl(i.y-this.min.y,this.yScale,this.cellsY);for(let _=h;_<=f;_++)for(let y=a;y<=c;y++){const v=this.cells[_*this.cellsX+y];if(v)for(let b=0;b<v.len;b++){const T=this.payload[v.start+b],E=Math.floor(T/8),C=1<<T%8;if(!(this.lookup[E]&C)&&(this.lookup[E]|=C,o.push(T),o.length===this.triangleCount))return}}}}function tl(r,e,i){return Math.max(0,Math.min(i-1,Math.floor(r*e)))}nt(ug,"TriangleGridIndex");const Cw=Gt([{name:"a_pos_3f",components:3,type:"Float32"}]),Mw=Gt([{name:"a_color_3f",components:3,type:"Float32"}]),Pw=Gt([{name:"a_color_4f",components:4,type:"Float32"}]),Rw=Gt([{name:"a_uv_2f",components:2,type:"Float32"}]),Dw=Gt([{name:"a_normal_3f",components:3,type:"Float32"}]),Lw=Gt([{name:"a_normal_matrix0",components:4,type:"Float32"},{name:"a_normal_matrix1",components:4,type:"Float32"},{name:"a_normal_matrix2",components:4,type:"Float32"},{name:"a_normal_matrix3",components:4,type:"Float32"}]),zw=Gt([{name:"a_pbr",components:4,type:"Uint16"},{name:"a_heightBasedEmissiveStrength",components:3,type:"Float32"}]);function c0(r,e){const i=hg(r.projection,r.zoom,r.width,r.height),o=(function(c,h,f,_,y){const v=new ui(f.lng-180*Bc,f.lat),b=new ui(f.lng+180*Bc,f.lat),T=c.project(v.lng,v.lat),E=c.project(b.lng,b.lat),C=-Math.atan2(E.y-T.y,E.x-T.x),P=kn.fromLngLat(f);P.y=Y(P.y,-1+Bc,1-Bc);const R=P.toLngLat(),z=c.project(R.lng,R.lat),V=kn.fromLngLat(R);V.x+=Bc;const N=V.toLngLat(),U=c.project(N.lng,N.lat),q=h0(U.x-z.x,U.y-z.y,C),W=kn.fromLngLat(R);W.y+=Bc;const se=W.toLngLat(),X=c.project(se.lng,se.lat),ie=h0(X.x-z.x,X.y-z.y,C),re=Math.abs(q.x)/Math.abs(ie.y),oe=Si([]);un(oe,oe,-C*(1-(y?0:_)));const me=Si([]);return _n(me,me,[1,1-(1-re)*_,1]),me[4]=-ie.x/ie.y*_,un(me,me,C),Ni(me,oe,me),me})(r.projection,0,r.center,i,e),a=u0(r);return _n(o,o,[a,a,1]),o}function u0(r){const e=r.projection,i=hg(r.projection,r.zoom,r.width,r.height),o=yx(e,r.center),a=yx(e,ui.convert(e.center));return Math.pow(2,o*i+(1-i)*a)}function hg(r,e,i,o,a=1/0){const c=r.range;if(!c)return 0;const h=Math.min(a,Math.max(i,o)),f=Math.log2(h/1024);return ce(c[0]+f,c[1]+f,e)}const Bc=1/4e4;function yx(r,e){const i=Y(e.lat,-85.051129,as),o=new ui(e.lng-180*Bc,i),a=new ui(e.lng+180*Bc,i),c=r.project(o.lng,i),h=r.project(a.lng,i),f=kn.fromLngLat(o),_=kn.fromLngLat(a),y=h.x-c.x,v=h.y-c.y,b=_.x-f.x,T=_.y-f.y,E=Math.sqrt((b*b+T*T)/(y*y+v*v));return Math.log2(E)}function h0(r,e,i){const o=Math.cos(i),a=Math.sin(i);return{x:r*o-e*a,y:r*a+e*o}}const Fw=new Float64Array([1,0,0,0,0,0,1,0,0,1,0,0,0,0,0,1]);function d0(r,e,i){Si(r),un(r,r,Qt(e[2])),gn(r,r,Qt(e[0])),Pn(r,r,Qt(e[1])),_n(r,r,i),Ni(r,r,Fw)}function dg(r,e,i,o,a,c,h,f){const _=[i[0]-e[0],i[1]-e[1],0],y=[o[0]-e[0],o[1]-e[1],0];if(Yr(_)<1e-12||Yr(y)<1e-12)return Ao(r);const v=tr([],_,y);Mi(v,v),dn(y,o,e),_[2]=(c-a)*f,y[2]=(h-a)*f;const b=_;return tr(b,_,y),Mi(b,b),xs(r,v,b)}function fg(r,e,i=!1){const o=zc(e.zoom),a=(function(c,h,f){const _=h.worldSize,y=[c[12],c[13],c[14]],v=on(y[1]/_),b=$r(y[0]/_),T=Si([]),E=Wn(1,v)*_,C=Wn(1,0)*_*Dl(v,h.zoom),P=1/Qy(_);let R=C*P;if(f){const U=hg(h.projection,h.zoom,h.width,h.height,1024);R=P*h.projection.pixelSpaceConversion(h.center.lat,_,U)}const z=Rl(v,b);ji(z,z,li([],Mi([],z),E*R*y[2]));const V=(function(U){const q=[U[0],U[1],U[2]];let W=[0,1,0];const se=tr([],W,q);return tr(W,q,se),fn(W)===0&&(W=[0,1,0],tr(se,q,W)),Mi(se,se),Mi(W,W),Mi(q,q),[se[0],se[1],se[2],0,W[0],W[1],W[2],0,q[0],q[1],q[2],0,U[0],U[1],U[2],1]})(z);_n(T,T,[R,R,R*E]),Mn(T,T,[-y[0],-y[1],-y[2]]);const N=Ni([],h.globeMatrix,V);return Ni(N,N,T),Ni(N,N,c),N})(r,e,i);if(o>0){const c=(function(h,f){const _=f.worldSize,y=Wn(1,0)*_*Dl(f.center.lat,f.zoom)/Qy(_),v=Wn(1,f.center.lat)*_,b=Si([]);Pn(b,b,Qt(f.center.lng)),gn(b,b,Qt(f.center.lat)),Mn(b,b,[0,0,Zn]),_n(b,b,[y,y,y*v]);const T=f.point;return Mn(b,b,[-T.x,-T.y,0]),Ni(b,b,h),Ni(b,f.globeMatrix,b)})(r,e);return(function(h,f,_){const y=(C,P,R)=>{const z=Yr(C),V=Yr(P),N=kl(C,P,R);return li(N,N,1/Yr(N)*vt(z,V,R))},v=y([h[0],h[1],h[2]],[f[0],f[1],f[2]],_),b=y([h[4],h[5],h[6]],[f[4],f[5],f[6]],_),T=y([h[8],h[9],h[10]],[f[8],f[9],f[10]],_),E=kl([h[12],h[13],h[14]],[f[12],f[13],f[14]],_);return[v[0],v[1],v[2],0,b[0],b[1],b[2],0,T[0],T[1],T[2],0,E[0],E[1],E[2],1]})(a,c,o)}return a}function xx(r,e,i,o){const a=lr.projectAabbCorners(o,i);let c=Number.MAX_VALUE;for(let f=0;f<a.length;++f){const _=a[f];_[0]=(.5*_[0]+.5)*e.width,_[1]=(.5-.5*_[1])*e.height,_[2]<c&&(c=_[2])}const h=(function(f){const _=[];let y=0;for(let E=1;E<f.length;E++)(f[E][0]<f[y][0]||f[E][0]===f[y][0]&&f[E][1]<f[y][1])&&(y=E);let v,b=y;const T=new Uint8Array(f.length);do{if(T[b])break;_.push(new Ue(f[b][0],f[b][1])),T[b]=1,v=(b+1)%f.length;for(let E=0;E<f.length;E++){if(f[E][0]===f[v][0]&&f[E][1]===f[v][1]||f[E][0]===f[b][0]&&f[E][1]===f[b][1])continue;const C=[f[E][0]-f[b][0],f[E][1]-f[b][1]],P=[f[v][0]-f[b][0],f[v][1]-f[b][1]],R=C[0]*P[1]-C[1]*P[0];(R>0||R===0&&C[0]*P[0]+C[1]*P[1]>=0&&C[0]*C[0]+C[1]*C[1]>P[0]*P[0]+P[1]*P[1])&&(v=E)}b=v}while(b!==y);return _.length>0&&_.push(_[0]),_})(a);if(Lu(r,h))return c}const Uu=64,Id={CoordinateSpaceTile:1,HasMapboxMeshFeatures:4,HasMeshoptCompression:8};function pg(r,e,i,o,a,c,h,f,_,y=!1){const v=i.zoom,b=i.project(o),T=Dl(o.lat,v),E=1/T;Si(r),Mn(r,r,[b.x+h[0]*E,b.y+h[1]*E,h[2]]);let C=1,P=1;const R=i.worldSize;if(y){if(i.projection.name==="mercator"){let U=0;i.elevation&&(U=i.elevation.getAtPointOrZero(new kn(b.x/R,b.y/R),0));const q=Ln([],[b.x,b.y,U,1],i.projMatrix)[3]/i.cameraToCenterDistance;C=q,P=q*Dl(i.center.lat,v)}else if(i.projection.name==="globe"){const U=fg(r,i),q=[0,0,0,1];Ln(q,q,Ni([],i.projMatrix,U));const W=q[3]/i.cameraToCenterDistance,se=zc(v),X=i.projection.pixelsPerMeter(o.lat,R)*Dl(o.lat,v),ie=i.projection.pixelsPerMeter(i.center.lat,R)*Dl(i.center.lat,v);C=W/vt(X,u_(i.center.lat),se),P=W*T/X,C*=ie,P*=ie}}else C=E;_n(r,r,[C,C,P]);const z=[...r],V=e.orientation,N=[];if(d0(N,[V[0]+(a?a[0]:0),V[1]+(a?a[1]:0),V[2]+(a?a[2]:0)],c),Ni(r,z,N),f&&i.elevation){let U=0;const q=[];if(_&&i.elevation){U=(function(se,X,ie,re,oe){const me=X.elevation;if(!me)return 0;const xe=lr.projectAabbCorners(ie,re),we=Wn(1,oe.lat)*X.worldSize,Ce=(function(Ye,st){const Je=[0,0,1],Qe=[{corners:[0,1,3,2],dotProductWithUp:0},{corners:[1,5,2,6],dotProductWithUp:0},{corners:[0,4,1,5],dotProductWithUp:0},{corners:[2,6,3,7],dotProductWithUp:0},{corners:[4,7,5,6],dotProductWithUp:0},{corners:[0,3,4,7],dotProductWithUp:0}];for(const dt of Qe){const wt=Ye[dt.corners[0]],Bt=Ye[dt.corners[1]],lt=Ye[dt.corners[2]],Et=[Bt[0]-wt[0],Bt[1]-wt[1],st*(Bt[2]-wt[2])],Rt=tr(Et,Et,[lt[0]-wt[0],lt[1]-wt[1],st*(lt[2]-wt[2])]);Mi(Rt,Rt),dt.dotProductWithUp=qi(Rt,Je)}return Qe.sort((dt,wt)=>dt.dotProductWithUp-wt.dotProductWithUp),Qe[0].corners})(xe,we),Se=xe[Ce[0]],qe=xe[Ce[1]],Me=xe[Ce[2]],Ie=xe[Ce[3]],Pe=me.getAtPointOrZero(new kn(Se[0]/X.worldSize,Se[1]/X.worldSize),0),Ne=me.getAtPointOrZero(new kn(qe[0]/X.worldSize,qe[1]/X.worldSize),0),ke=me.getAtPointOrZero(new kn(Me[0]/X.worldSize,Me[1]/X.worldSize),0),$e=me.getAtPointOrZero(new kn(Ie[0]/X.worldSize,Ie[1]/X.worldSize),0),ze=(Pe+$e)/2,He=(Ne+ke)/2;return ze>He?Ne<ke?dg(se,qe,Ie,Se,Ne,$e,Pe,we):dg(se,Me,Se,Ie,ke,Pe,$e,we):Pe<$e?dg(se,Se,qe,Me,Pe,Ne,ke,we):dg(se,Ie,Me,qe,$e,ke,Ne,we),Math.max(ze,He)})(q,i,e.aabb,r,o);const W=Ni([],Nn([],q),N);Ni(r,z,W)}else U=i.elevation.getAtPointOrZero(new kn(b.x/R,b.y/R),0);U!==0&&(r[14]+=U)}}class f0{constructor(e,i,o,a,c){this.materialOverrides=new Map,this.nodeOverrides=new Map,this.materialOverrideNames=[],this.nodeOverrideNames=[],this.featureProperties={},this.id=e,this.uri=i,this.position=o!=null?new ui(o[0],o[1]):new ui(0,0),this.orientation=a??[0,0,0],this.nodes=c,this.uploaded=!1,this.aabb=new lr([1/0,1/0,1/0],[-1/0,-1/0,-1/0]),this.matrix=[]}_applyTransformations(e,i){Ni(e.globalMatrix,i,e.localMatrix);const o=this.nodeOverrides.get(e.name);if(o!==void 0){if(o.orientation){const h=[];c=o.orientation,Si(a=h),Pn(a,a,Qt(c[1])),un(a,a,Qt(c[2])),gn(a,a,Qt(c[0])),Ni(e.globalMatrix,e.globalMatrix,h)}o.minZoom&&(e.minZoom=o.minZoom),o.maxZoom&&(e.maxZoom=o.maxZoom)}var a,c;if(e.meshes)for(const h of e.meshes){const f=lr.applyTransformFast(h.aabb,e.globalMatrix);this.aabb.encapsulate(f)}if(e.children)for(const h of e.children)this._applyTransformations(h,e.globalMatrix)}computeBoundsAndApplyParent(){const e=Si([]);this.aabb=new lr([1/0,1/0,1/0],[-1/0,-1/0,-1/0]);for(const i of this.nodes)this._applyTransformations(i,e)}computeModelMatrix(e,i,o,a,c,h,f=!1){pg(this.matrix,this,e.transform,this.position,i,o,a,c,h,f)}upload(e){if(!this.uploaded){for(const i of this.nodes)vx(i,e);for(const i of this.nodes)mg(i);this.uploaded=!0}}destroy(){for(const e of this.nodes)bx(e)}}function Op(r,e,i=!1){r.uploaded||(r.gfxTexture=new Ct(e,r.image,i?e.gl.R8:e.gl.RGBA8,{useMipmap:r.sampler.minFilter>=e.gl.NEAREST_MIPMAP_NEAREST}),r.uploaded=!0,r.image=null)}function p0(r,e,i){r.indexBuffer=e.createIndexBuffer(r.indexArray,!1,!0),r.vertexBuffer=e.createVertexBuffer(r.vertexArray,Cw.members,!1,!0),r.normalArray&&(r.normalBuffer=e.createVertexBuffer(r.normalArray,Dw.members,!1,!0)),r.texcoordArray&&(r.texcoordBuffer=e.createVertexBuffer(r.texcoordArray,Rw.members,!1,!0)),r.colorArray&&(r.colorBuffer=e.createVertexBuffer(r.colorArray,(r.colorArray.bytesPerElement===12?Mw:Pw).members,!1,!0)),r.featureArray&&(r.pbrBuffer=e.createVertexBuffer(r.featureArray,zw.members,!0)),r.segments=Fi.simpleSegment(0,0,r.vertexArray.length,r.indexArray.length);const o=r.material;o.pbrMetallicRoughness.baseColorTexture&&Op(o.pbrMetallicRoughness.baseColorTexture,e),o.pbrMetallicRoughness.metallicRoughnessTexture&&Op(o.pbrMetallicRoughness.metallicRoughnessTexture,e),o.normalTexture&&Op(o.normalTexture,e),o.occlusionTexture&&Op(o.occlusionTexture,e,i),o.emissionTexture&&Op(o.emissionTexture,e)}function vx(r,e,i){if(r.meshes)for(const o of r.meshes)p0(o,e,i);if(r.lodMeshes)for(const o of r.lodMeshes)p0(o,e,i);if(r.children)for(const o of r.children)vx(o,e,i)}function m0(r){r.indexArray.destroy(),r.vertexArray.destroy(),r.colorArray&&r.colorArray.destroy(),r.normalArray&&r.normalArray.destroy(),r.texcoordArray&&r.texcoordArray.destroy(),r.featureArray&&r.featureArray.destroy()}function mg(r){if(r.meshes)for(const e of r.meshes)m0(e);if(r.lodMeshes)for(const e of r.lodMeshes)m0(e);if(r.children)for(const e of r.children)mg(e)}function _0(r){var e;r.vertexBuffer&&(r.vertexBuffer.destroy(),r.indexBuffer.destroy(),r.normalBuffer&&r.normalBuffer.destroy(),r.texcoordBuffer&&r.texcoordBuffer.destroy(),r.colorBuffer&&r.colorBuffer.destroy(),r.pbrBuffer&&r.pbrBuffer.destroy(),r.segments.destroy(),r.material&&((e=r.material).pbrMetallicRoughness.baseColorTexture&&e.pbrMetallicRoughness.baseColorTexture.gfxTexture&&e.pbrMetallicRoughness.baseColorTexture.gfxTexture.destroy(),e.pbrMetallicRoughness.metallicRoughnessTexture&&e.pbrMetallicRoughness.metallicRoughnessTexture.gfxTexture&&e.pbrMetallicRoughness.metallicRoughnessTexture.gfxTexture.destroy(),e.normalTexture&&e.normalTexture.gfxTexture&&e.normalTexture.gfxTexture.destroy(),e.emissionTexture&&e.emissionTexture.gfxTexture&&e.emissionTexture.gfxTexture.destroy(),e.occlusionTexture&&e.occlusionTexture.gfxTexture&&e.occlusionTexture.gfxTexture.destroy()))}function bx(r){if(r.meshes)for(const e of r.meshes)_0(e);if(r.lodMeshes)for(const e of r.lodMeshes)_0(e);if(r.footprintDebugMesh&&(r.footprintDebugMesh.vertexBuffer.destroy(),r.footprintDebugMesh.indexBuffer.destroy(),r.footprintDebugMesh.segments.destroy()),r.children)for(const e of r.children)bx(e)}function wx(r,e,i,o){return r[0]<=o[0]&&e[0]>=i[0]&&r[1]<=o[1]&&e[1]>=i[1]&&r[2]<=o[2]&&e[2]>=i[2]}function Ow(r,e,i,o,a,c,h,f,_,y,v){const b=.5*(y[0]+v[0]),T=.5*(y[1]+v[1]),E=.5*(y[2]+v[2]),C=.5*(v[0]-y[0]),P=.5*(v[1]-y[1]),R=.5*(v[2]-y[2]),z=r-b,V=e-T,N=i-E,U=o-b,q=a-T,W=c-E,se=h-b,X=f-T,ie=_-E,re=U-z,oe=q-V,me=W-N,xe=se-U,we=X-q,Ce=ie-W,Se=z-se,qe=V-X,Me=N-ie;let Ie,Pe,Ne,ke,$e,ze;if(Ie=N*oe-V*me,Pe=W*oe-q*me,Ne=ie*oe-X*me,ke=Math.min(Ie,Pe,Ne),$e=Math.max(Ie,Pe,Ne),ze=Math.abs(me)*P+Math.abs(oe)*R,ke>ze||$e<-ze||(Ie=N*we-V*Ce,Pe=W*we-q*Ce,Ne=ie*we-X*Ce,ke=Math.min(Ie,Pe,Ne),$e=Math.max(Ie,Pe,Ne),ze=Math.abs(Ce)*P+Math.abs(we)*R,ke>ze||$e<-ze)||(Ie=N*qe-V*Me,Pe=W*qe-q*Me,Ne=ie*qe-X*Me,ke=Math.min(Ie,Pe,Ne),$e=Math.max(Ie,Pe,Ne),ze=Math.abs(Me)*P+Math.abs(qe)*R,ke>ze||$e<-ze)||(Ie=z*me-N*re,Pe=U*me-W*re,Ne=se*me-ie*re,ke=Math.min(Ie,Pe,Ne),$e=Math.max(Ie,Pe,Ne),ze=Math.abs(me)*C+Math.abs(re)*R,ke>ze||$e<-ze)||(Ie=z*Ce-N*xe,Pe=U*Ce-W*xe,Ne=se*Ce-ie*xe,ke=Math.min(Ie,Pe,Ne),$e=Math.max(Ie,Pe,Ne),ze=Math.abs(Ce)*C+Math.abs(xe)*R,ke>ze||$e<-ze)||(Ie=z*Me-N*Se,Pe=U*Me-W*Se,Ne=se*Me-ie*Se,ke=Math.min(Ie,Pe,Ne),$e=Math.max(Ie,Pe,Ne),ze=Math.abs(Me)*C+Math.abs(Se)*R,ke>ze||$e<-ze)||(Ie=V*re-z*oe,Pe=q*re-U*oe,Ne=X*re-se*oe,ke=Math.min(Ie,Pe,Ne),$e=Math.max(Ie,Pe,Ne),ze=Math.abs(oe)*C+Math.abs(re)*P,ke>ze||$e<-ze)||(Ie=V*xe-z*we,Pe=q*xe-U*we,Ne=X*xe-se*we,ke=Math.min(Ie,Pe,Ne),$e=Math.max(Ie,Pe,Ne),ze=Math.abs(we)*C+Math.abs(xe)*P,ke>ze||$e<-ze)||(Ie=V*Se-z*qe,Pe=q*Se-U*qe,Ne=X*Se-se*qe,ke=Math.min(Ie,Pe,Ne),$e=Math.max(Ie,Pe,Ne),ze=Math.abs(qe)*C+Math.abs(Se)*P,ke>ze||$e<-ze)||(ke=Math.min(z,U,se),$e=Math.max(z,U,se),ke>C||$e<-C)||(ke=Math.min(V,q,X),$e=Math.max(V,q,X),ke>P||$e<-P)||(ke=Math.min(N,W,ie),$e=Math.max(N,W,ie),ke>R||$e<-R))return!1;const He=oe*Ce-me*we,Ye=me*xe-re*Ce,st=re*we-oe*xe,Je=-(He*z+Ye*V+st*N);return ze=C*Math.abs(He)+P*Math.abs(Ye)+R*Math.abs(st),!(Math.abs(Je)>ze)}const kw=[];class g0{serializeFromGltf(e,i,o,a){if(e.length<7)return;let c=0;if(e[c++]!==109||e[c++]!==98||e[c++]!==120||e[c++]!==98||e[c++]!==118||e[c++]!==104||e[c++]!==43)return;const h=new DataView(e.buffer,e.byteOffset),f=h.getUint16(c,!0);if(c+=2,f===0)return;this._nodes=[];let _=0;for(let v=0;v<f;v++){const b=[i[3*_],i[3*_+1],i[3*_+2]],T=[o[3*_],o[3*_+1],o[3*_+2]];_++;const E=h.getUint16(c,!0);c+=2;let C=0,P=0;E===65535&&(C=h.getUint16(c,!0),c+=2,P=h.getUint32(c,!0),c+=4),this._nodes.push({aabbMin:b,aabbMax:T,backChild:E,indexCount:C,indexOffset:P})}const y=h.getUint32(c,!0);this._indices=a.slice(0,y)}setVertices(e){this._vertices=e}findHighestPoint(e,i){if(!this._nodes||this._nodes.length===0||!wx(this._nodes[0].aabbMin,this._nodes[0].aabbMax,e,i))return null;const o=kw;o.length=0,o.push(0);let a=-1/0;for(;o.length>0;){const c=o.pop(),h=this._nodes[c];if(h.aabbMax[2]<=a)continue;if(h.backChild===65535){for(let E=0;E<h.indexCount;E+=3){const C=3*this._indices[h.indexOffset+E],P=3*this._indices[h.indexOffset+E+1],R=3*this._indices[h.indexOffset+E+2];Ow(this._vertices[C],this._vertices[C+1],this._vertices[C+2],this._vertices[P],this._vertices[P+1],this._vertices[P+2],this._vertices[R],this._vertices[R+1],this._vertices[R+2],e,i)&&(a=Math.max(a,this._vertices[C+2],this._vertices[P+2],this._vertices[R+2]))}continue}const f=c+1,_=h.backChild,y=this._nodes[f],v=this._nodes[_],b=wx(y.aabbMin,y.aabbMax,e,i),T=wx(v.aabbMin,v.aabbMax,e,i);b&&T?y.aabbMax[2]<v.aabbMax[2]?(o.push(f),o.push(_)):(o.push(_),o.push(f)):b?o.push(f):T&&o.push(_)}return a>=0?a:null}}function ju(r,e){const i=r.json.bufferViews[e.bufferView],o=lg[e.componentType];return new o(r.buffers[i.buffer],(e.byteOffset||0)+(i.byteOffset||0),e.count*(i.byteStride&&i.byteStride!==Fp[e.type]*o.BYTES_PER_ELEMENT?i.byteStride/o.BYTES_PER_ELEMENT:Fp[e.type]))}function Tx(r,e,i,o){const a=lg[e.componentType],c=(function(b){switch(b){case Int8Array:return 1/127;case Uint8Array:return 1/255;case Int16Array:return 1/32767;case Uint16Array:return 1/65535;default:return 1}})(a),h=r.json.bufferViews[e.bufferView],f=h.byteStride?h.byteStride/a.BYTES_PER_ELEMENT:Fp[e.type],_=i.float32,y=_.length/i.capacity,v=e.count*f;for(let b=0,T=0;b<v;b+=f,T+=y)for(let E=0;E<y;E++)_[T+E]=o[b+E]*c}function Bw(r,e,i){const o=r.indices,a=r.attributes,c={};c.indexArray=new sn;const h=e.json.accessors[o],f=ju(e,h);
7c.indexArray.resizeExact(h.count/3),c.indexArray.uint16.set(f),c.vertexArray=new cs;const _=e.json.accessors[a.POSITION],y=ju(e,_);c.vertexArray.resizeExact(_.count),c.vertexArray.float32.set(y),c.aabb=new lr(_.min,_.max);const[v,b,T]=_.min,[E,C,P]=_.max;if(c.centroid=[.5*(v+E),.5*(b+C),.5*(T+P)],a.COLOR_0!==void 0){const z=e.json.accessors[a.COLOR_0],V=Fp[z.type],N=ju(e,z);c.colorArray=V===3?new cs:new ga,c.colorArray.resizeExact(z.count),Tx(e,z,c.colorArray,N)}if(a.NORMAL!==void 0){c.normalArray=new cs;const z=e.json.accessors[a.NORMAL];c.normalArray.resizeExact(z.count);const V=ju(e,z);Tx(e,z,c.normalArray,V)}if(a.TEXCOORD_0!==void 0&&i.length>0){c.texcoordArray=new xo;const z=e.json.accessors[a.TEXCOORD_0];c.texcoordArray.resizeExact(z.count);const V=ju(e,z);Tx(e,z,c.texcoordArray,V)}if(a._FEATURE_ID_RGBA4444!==void 0){const z=e.json.accessors[a._FEATURE_ID_RGBA4444];e.json.extensionsUsed&&e.json.extensionsUsed.includes("EXT_meshopt_compression")&&(c.featureData=ju(e,z))}a._FEATURE_RGBA4444!==void 0&&(c.featureData=new Uint32Array(ju(e,e.json.accessors[a._FEATURE_RGBA4444]).buffer));const R=r.material;return c.material=(function(z,V){const{emissiveFactor:N=[0,0,0],alphaMode:U="OPAQUE",alphaCutoff:q=.5,normalTexture:W,occlusionTexture:se,emissiveTexture:X,doubleSided:ie,name:re}
vendor: 108,464 bytes, line 7
7=z,{baseColorFactor:oe=[1,1,1,1],metallicFactor:me=1,roughnessFactor:xe=1,baseColorTexture:we,metallicRoughnessTexture:Ce}=z.pbrMetallicRoughness||{},Se=se?V[se.index]:void 0;if(se&&se.extensions&&se.extensions.KHR_texture_transform&&Se){const qe=se.extensions.KHR_texture_transform;Se.offsetScale=[qe.offset[0],qe.offset[1],qe.scale[0],qe.scale[1]]}return{name:re,pbrMetallicRoughness:{baseColorFactor:new ai(...oe),metallicFactor:me,roughnessFactor:xe,baseColorTexture:we?V[we.index]:void 0,metallicRoughnessTexture:Ce?V[Ce.index]:void 0},doubleSided:ie,emissiveFactor:new ai(...N),alphaMode:U,alphaCutoff:q,normalTexture:W?V[W.index]:void 0,occlusionTexture:Se,emissionTexture:X?V[X.index]:void 0,defined:z.defined===void 0}})(R!==void 0?e.json.materials[R]:{defined:!1},i),c}function Sx(r,e,i){const{matrix:o,rotation:a,translation:c,scale:h,mesh:f,extras:_,children:y,name:v}=r,b={};if(b.name=v,b.localMatrix=o||(function(T,E,C,P){var R=E[0],z=E[1],V=E[2],N=E[3],U=R+R,q=z+z,W=V+V,se=R*U,X=R*q,ie=R*W,re=z*q,oe=z*W,me=V*W,xe=N*U,we=N*q,Ce=N*W,Se=P[0],qe=P[1],Me=P[2];return T[0]=(1-(re+me))*Se,T[1]=(X+Ce)*Se,T[2]=(ie-we)*Se,T[3]=0,T[4]=(X-Ce)*qe,T[5]=(1-(se+me))*qe,T[6]=(oe+xe)*qe,T[7]=0,T[8]=(ie+we)*Me,T[9]=(oe-xe)*Me,T[10]=(1-(se+re))*Me,T[11]=0,T[12]=C[0],T[13]=C[1],T[14]=C[2],T[15]=1,T})([],a||[0,0,0,1],c||[0,0,0],h||[1,1,1]),b.globalMatrix=Nt(b.localMatrix),f!==void 0){b.meshes=i[f];const T=b.anchor=[0,0];for(const E of b.meshes){const{min:C,max:P}=E.aabb;T[0]+=C[0]+P[0],T[1]+=C[1]+P[1]}T[0]=Math.floor(T[0]/b.meshes.length/2),T[1]=Math.floor(T[1]/b.meshes.length/2)}if(_&&(_.id&&(b.id=_.id),_.lights&&(b.lights=(function(T){if(!T.length)return[];const E=(function(V){const N=atob(V),U=new Uint8Array(N.length);for(let q=0;q<N.length;q++)U[q]=N.codePointAt(q);return U})(T),C=[],P=E.length/24,R=new Uint16Array(E.buffer),z=new Float32Array(E.buffer);for(let V=0;V<P;V++){const N=R[2*V*6]/30,U=R[2*V*6+1]/30,q=R[2*V*6+10]/100,W=z[6*V+1],se=z[6*V+2],X=z[6*V+3],ie=z[6*V+4],re=X-W,oe=ie-se,me=Math.hypot(re,oe);C.push({pos:[W+.5*re,se+.5*oe,U],normal:[oe/me,-re/me,0],width:me,height:N,depth:q,points:[W,se,X,ie]})}return C})(_.lights)),_.MAPBOX_geometry_bloom&&(b.isGeometryBloom=_.MAPBOX_geometry_bloom),_.MAPBOX_zoom_min&&(b.minZoom=_.MAPBOX_zoom_min),_.MAPBOX_zoom_max&&(b.maxZoom=_.MAPBOX_zoom_max)),y){const T=[];for(const E of y)T.push(Sx(e.json.nodes[E],e,i));b.children=T}if(r.extensions&&r.extensions.mbx_bvh&&(b.meshBVH=(function(T,E,C){const P=E.binaryAccessor,R=E.positionMinAccessor,z=E.positionMaxAccessor,V=E.indexAccessor;if(!(Number.isInteger(P)&&Number.isInteger(R)&&Number.isInteger(z)&&Number.isInteger(V)))return null;const N=T.json.accessors;if(P>=N.length||R>=N.length||z>=N.length||V>=N.length)return null;const U=N[P],q=N[R],W=N[z],se=N[V];if(U.bufferView===void 0||q.bufferView===void 0||W.bufferView===void 0||se.bufferView===void 0)return null;const X=T.json.bufferViews;if(U.bufferView>=X.length||q.bufferView>=X.length||W.bufferView>=X.length||se.bufferView>=X.length)return null;const ie=X[U.bufferView],re=X[q.bufferView],oe=X[W.bufferView],me=X[se.bufferView];if(ie.buffer>=T.buffers.length||re.buffer>=T.buffers.length||oe.buffer>=T.buffers.length||me.buffer>=T.buffers.length)return null;const xe=($e,ze,He)=>$e>=0&&$e<=He&&ze<=He-$e,we=U.byteOffset||0,Ce=q.byteOffset||0,Se=W.byteOffset||0,qe=se.byteOffset||0;if(!(xe(we,0,ie.byteLength)&&xe(Ce,3*q.count*4,re.byteLength)&&xe(Se,3*W.count*4,oe.byteLength)&&xe(qe,4*se.count,me.byteLength)))return null;const Me=new Uint8Array(T.buffers[ie.buffer],(ie.byteOffset||0)+we,ie.byteLength-we),Ie=new Float32Array(T.buffers[re.buffer],(re.byteOffset||0)+Ce,3*q.count),Pe=new Float32Array(T.buffers[oe.buffer],(oe.byteOffset||0)+Se,3*W.count),Ne=new Uint32Array(T.buffers[me.buffer],(me.byteOffset||0)+qe,se.count),ke=new g0;if(ke.serializeFromGltf(Me,Ie,Pe,Ne),C!==void 0&&T.json.meshes&&T.json.meshes[C]){const $e=T.json.meshes[C].primitives[0];if($e&&$e.attributes.POSITION!==void 0&&$e.attributes.POSITION<N.length){const ze=N[$e.attributes.POSITION];if(ze.bufferView!==void 0&&ze.bufferView<X.length){const He=X[ze.bufferView];if(He.buffer<T.buffers.length){const Ye=ze.byteOffset||0,st=He.byteStride?He.byteStride/4:3;if(xe(Ye,ze.count*st*4,He.byteLength)){const Je=(He.byteOffset||0)+Ye;if(st===3)ke.setVertices(new Float32Array(T.buffers[He.buffer],Je,3*ze.count));else{const Qe=new Float32Array(T.buffers[He.buffer],Je,ze.count*st),dt=new Float32Array(3*ze.count);for(let wt=0;wt<ze.count;wt++)dt[3*wt]=Qe[wt*st],dt[3*wt+1]=Qe[wt*st+1],dt[3*wt+2]=Qe[wt*st+2];ke.setVertices(dt)}}}}}}return ke})(e,r.extensions.mbx_bvh,f)),!b.meshBVH&&b.children){for(const T of b.children)if(T.meshBVH){b.meshBVH=T.meshBVH;break}}return b}function Nw(r){if(r.vertices.length===0||r.indices.length===0)return null;const e=new ug(r.vertices,r.indices,8,256),[i,o]=[e.min.clone(),e.max.clone()];return{vertices:r.vertices,indices:r.indices,grid:e,min:i,max:o}}function Vw(r){if(!r.extras||!r.extras.ground)return null;const e=r.extras.ground;if(!e||!Array.isArray(e)||e.length===0)return null;const i=e[0];if(!i||!Array.isArray(i)||i.length===0)return null;const o=[];for(const h of i){if(!Array.isArray(h)||h.length!==2)continue;const f=h[0],_=h[1];typeof f=="number"&&typeof _=="number"&&o.push(new Ue(f,_))}if(o.length<3)return null;o.length>1&&o.at(-1).equals(o[0])&&o.pop();let a=0;for(let h=0;h<o.length;h++){const f=o[h],_=o[(h+1)%o.length],y=o[(h+2)%o.length];a+=(f.x-_.x)*(y.y-_.y)-(y.x-_.x)*(f.y-_.y)}a>0&&o.reverse();const c=Sc(o.flatMap(h=>[h.x,h.y]),[]);return c.length===0?null:{vertices:o,indices:c}}function Uw(r,e){const i=[],o=[];let a=0;const c=[];for(const h of r){a=i.length;const f=h.vertexArray.float32,_=h.indexArray.uint16;for(let y=0;y<h.vertexArray.length;y++)c[0]=f[3*y+0],c[1]=f[3*y+1],c[2]=f[3*y+2],ir(c,c,e),i.push(new Ue(c[0],c[1]));for(let y=0;y<3*h.indexArray.length;y++)o.push(_[y]+a)}if(o.length%3!=0)return null;for(let h=0;h<o.length;h+=3){const f=i[o[h+0]],_=i[o[h+1]],y=i[o[h+2]];(f.x-_.x)*(y.y-_.y)-(y.x-_.x)*(f.y-_.y)>0&&([o[h+1],o[h+2]]=[o[h+2],o[h+1]])}return{vertices:i,indices:o}}function y0(r,e){for(let i=0;i<r.length;i++)if(r[i].name===e)return i;return-1}function Ex(r){const e=(function(v,b){const T=[],E=WebGL2RenderingContext;if(v.json.textures)for(const C of v.json.textures){const P={magFilter:E.LINEAR,minFilter:E.NEAREST,wrapS:E.REPEAT,wrapT:E.REPEAT};C.sampler!==void 0&&Object.assign(P,v.json.samplers[C.sampler]),T.push({image:b[C.source],sampler:P,uploaded:!1})}return T})(r,r.images),i=(function(v,b){const T=[];if(!v.json.meshes)return T;for(const E of v.json.meshes){const C=[];for(const P of E.primitives)C.push(Bw(P,v,b));T.push(C)}return T})(r,e),{scenes:o,scene:a,nodes:c}=r.json;let h=o?y0(o,"Default Scene"):-1;h<0&&(h=a||0);const f=o&&o[h]?o[h].nodes||[]:[...c.keys()],_=[];for(const v of f)_.push(Sx(c[v],r,i));(function(v,b,T){const E={},C=new Set;for(let P=0;P<v.length;P++){const R=T[b[P]];if(!R.extras)continue;const z=R.extras["mapbox:footprint:version"],V=R.extras["mapbox:footprint:id"];(z||V)&&C.add(P),z==="1.0.0"&&V&&(E[V]=P)}for(let P=0;P<v.length;P++){if(C.has(P))continue;const R=v[P],z=T[b[P]];if(!z.extras)continue;let V=null;R.id in E&&(V=Uw(v[E[R.id]].meshes,R.localMatrix)),V||(V=Vw(z)),V&&(R.footprint=Nw(V))}if(C.size>0){const P=Array.from(C.values()).sort((R,z)=>R-z);for(let R=P.length-1;R>=0;R--)v.splice(P[R],1)}})(_,f,r.json.nodes);const y=o?y0(o,"LOD"):-1;if(y>=0){const v=o[y].nodes,b=new Map;for(const T of v){const E=Sx(c[T],r,i);E.id&&b.set(E.id,E)}for(const T of _)if(T.id){const E=b.get(T.id);E&&E.meshes&&(T.lodMeshes=E.meshes,E.meshBVH&&(T.meshBVH=E.meshBVH))}}return _}function jw(r){r.heightmap=new Float32Array(4096),r.heightmap.fill(-1);const e=r.vertexArray.float32,i=r.aabb.min[0]-1,o=r.aabb.min[1]-1,a=Uu/(r.aabb.max[0]-i+2),c=Uu/(r.aabb.max[1]-o+2);for(let h=0;h<e.length;h+=3){const f=e[h+2],_=(e[h+0]-i)*a|0,y=(e[h+1]-o)*c|0;f>r.heightmap[y*Uu+_]&&(r.heightmap[y*Uu+_]=f)}}function x0(r,e,i,o,a){i.reserve(i.length+4*r.length),o.reserve(o.length+10*r.length),a.reserve(a.length+10*r.length);let c=o.length;for(const h of r){const f=Math.min(10,Math.max(4,1.3*h.height))*e,_=[-h.normal[1],h.normal[0],0],y=Math.min(.29,.1*h.width/h.depth),v=h.width-2*h.depth*e*(y+.01),b=Kr([],h.pos,_,v/2),T=Kr([],h.pos,_,-v/2),E=[b[0],b[1],b[2]+h.height],C=[T[0],T[1],T[2]+h.height],P=Kr([],h.normal,_,y);li(P,P,f);const R=Kr([],h.normal,_,-y);li(R,R,f),ji(P,b,P),ji(R,T,R),b[2]+=.1,T[2]+=.1,o.emplaceBack(P[0],P[1],P[2]),o.emplaceBack(R[0],R[1],R[2]),o.emplaceBack(b[0],b[1],b[2]),o.emplaceBack(T[0],T[1],T[2]),o.emplaceBack(E[0],E[1],E[2]),o.emplaceBack(C[0],C[1],C[2]),o.emplaceBack(b[0],b[1],b[2]),o.emplaceBack(T[0],T[1],T[2]),o.emplaceBack(P[0],P[1],P[2]),o.emplaceBack(R[0],R[1],R[2]);const z=v/f/2;a.emplaceBack(-z-y,-1,z,.8),a.emplaceBack(z+y,-1,z,.8),a.emplaceBack(-z,0,z,1.3),a.emplaceBack(z,0,z,1.3),a.emplaceBack(z+y,-.8,z,.7),a.emplaceBack(z+y,-.8,z,.7),a.emplaceBack(0,0,z,1.3),a.emplaceBack(0,0,z,1.3),a.emplaceBack(z+y,-1.2,z,.8),a.emplaceBack(z+y,-1.2,z,.8),i.emplaceBack(6+c,4+c,8+c),i.emplaceBack(7+c,9+c,5+c),i.emplaceBack(0+c,1+c,2+c),i.emplaceBack(1+c,3+c,2+c),c+=10}}function Gw(r,e){const i={};i.indexArray=new sn,i.vertexArray=new cs,i.colorArray=new ga,i.indexArray.reserveExact(4*r.length),i.vertexArray.reserveExact(10*r.length),i.colorArray.reserveExact(10*r.length),x0(r,e,i.indexArray,i.vertexArray,i.colorArray);const o={defined:!0};o.emissiveFactor=ai.black;const a={};return a.baseColorFactor=ai.white,o.pbrMetallicRoughness=a,i.material=o,i.aabb=new lr([1/0,1/0,1/0],[-1/0,-1/0,-1/0]),i}nt(g0,"ModelBVH");const v0=Gt([{name:"a_pos_3f",components:3,type:"Float32"}]),$w=Gt([{name:"a_normal_3",components:3,type:"Int16"}]),qw=Gt([{name:"a_centroid_3",components:3,type:"Int16"}]),b0=Gt([{name:"a_part_color_emissive",components:2,type:"Uint16"}]),Hw=Gt([{name:"a_faux_facade_color_emissive",components:2,type:"Uint16"}]),Zw=Gt([{name:"a_faux_facade_data",components:4,type:"Uint16"}]),Ww=Gt([{name:"a_faux_facade_vertical_range",components:2,type:"Uint16"}]),Xw=Gt([{name:"a_bloom_attenuation",components:4,type:"Float32"}]),Yw=Gt([{name:"a_flood_light_wall_radius_1i16",components:1,type:"Int16"}]),Kw=Gt([{name:"a_pos_normal_ed",components:4,type:"Int16"}]),Jw=Gt([{name:"a_pos_end",components:4,type:"Int16"},{name:"a_angular_offset_factor",components:1,type:"Int16"}]),Qw=Gt([{name:"a_flood_light_ground_radius",components:1,type:"Float32"}]),eT=Gt([{name:"a_centroid_pos",components:2,type:"Uint16"}]),tT=Gt([{name:"a_join_normal_inside",components:3,type:"Int16"}]),iT=Gt([{name:"a_hidden_by_landmark",components:1,type:"Uint8"}]),rT=Gt([{name:"a_pos_3",components:3,type:"Int16"},{name:"a_pos_normal_3",components:3,type:"Int16"}]),{members:nT}=Kw;function _g(r,e,i,o){const a=[],c=o===0?(h,f,_,y,v,b)=>{h.push(new Ue(b,_+(b-f)/(y-f)*(v-_)))}:(h,f,_,y,v,b)=>{h.push(new Ue(f+(b-_)/(v-_)*(y-f),b))};for(const h of r){const f=[];for(const _ of h){if(_.length<=2)continue;const y=[];for(let T=0;T<_.length-1;T++){const E=_[T].x,C=_[T].y,P=_[T+1].x,R=_[T+1].y,z=o===0?E:C,V=o===0?P:R;z<e?V>e&&c(y,E,C,P,R,e):z>i?V<i&&c(y,E,C,P,R,i):y.push(_[T]),V<e&&z>=e&&c(y,E,C,P,R,e),V>i&&z<=i&&c(y,E,C,P,R,i)}let v=_.at(-1);const b=o===0?v.x:v.y;b>=e&&b<=i&&y.push(v),y.length&&(v=y.at(-1),y[0].x===v.x&&y[0].y===v.y||y.push(y[0]),f.push(y))}f.length&&a.push(f)}return a}const gg={None:0,Model:1,Symbol:2,FillExtrusion:4},Ix=[new Ue(0,0),new Ue(rt,0),new Ue(rt,rt),new Ue(0,rt)];function w0(r,e){const i=[];let o=[];if(!e||r.length<2)return[r];if(r.length===2)return zl(r[0],r[1],Ix)?[r]:[];for(let a=0;a<r.length+2;a++){const c=a===0?r.at(-1):r[(a-1)%r.length],h=r[a%r.length],f=r[(a+1)%r.length],_=zl(c,h,Ix),y=zl(h,f,Ix),v=_||y;v&&o.push(h),v&&y||o.length>0&&(o.length>1&&i.push(o),o=[])}return o.length>1&&i.push(o),i}const Ax=Za.types,oT=["fill-extrusion-base","fill-extrusion-height","fill-extrusion-color","fill-extrusion-pattern","fill-extrusion-flood-light-wall-radius","fill-extrusion-line-width","fill-extrusion-emissive-strength"],sT=["fill-extrusion-flood-light-ground-radius"],aT=Math.pow(2,13),lT=Math.pow(2,15)-1,yg=new Ue(0,1),Ul=2147483648,xg=1073741824;function kp(r,e,i,o,a,c,h,f){r.emplaceBack((e<<1)+h,(i<<1)+c,(Math.floor(o*aT)<<1)+a,Math.round(f))}function Bp(r,e,i){r.emplaceBack(e.x*rt,e.y*rt,i?1:0)}function vg(r,e,i,o,a,c){r.emplaceBack(e.x,e.y,(i.x<<1)+o,(i.y<<1)+a,c)}function Np(r,e,i){r.emplaceBack(e.x,e.y,e.z,i[0]*16384,i[1]*16384,i[2]*16384)}class T0{constructor(){this.vertexOffset=0,this.vertexCount=0,this.indexOffset=0,this.indexCount=0}}class bg{constructor(){this.data=[]}get length(){return this.data.length}push(e){this.data.push(e)}get(e){return this.data[e]}static serialize(e,i){const o=e.data.length,a=new Uint32Array(4*o),c=[];c.length=o;for(let h=0;h<o;h++){const f=e.data[h],_=4*h;a[_]=f.vertexOffset,a[_+1]=f.vertexCount,a[_+2]=f.indexOffset,a[_+3]=f.indexCount,c[h]=f.ringIndices}return i&&i.add(a.buffer),{scalars:a,rings:c}}static deserialize(e){const{scalars:i,rings:o}=e,a=i.length/4,c=new bg,h=[];h.length=a,c.data=h;for(let f=0;f<a;f++){const _=4*f,y=new T0;y.vertexOffset=i[_],y.vertexCount=i[_+1],y.indexOffset=i[_+2],y.indexCount=i[_+3],y.ringIndices=o[f],c.data[f]=y}return c}}class wg{constructor(){this.centroidXY=new Ue(0,0),this.vertexArrayOffset=0,this.vertexCount=0,this.groundVertexArrayOffset=0,this.groundVertexCount=0,this.flags=0,this.footprintSegIdx=-1,this.footprintSegLen=0,this.polygonSegIdx=-1,this.polygonSegLen=0,this.min=new Ue(Number.MAX_VALUE,Number.MAX_VALUE),this.max=new Ue(-Number.MAX_VALUE,-Number.MAX_VALUE),this.height=0,this.buildingId=0,this.groupCentroidPos=new Ue(0,0)}span(){return new Ue(this.max.x-this.min.x,this.max.y-this.min.y)}}class Tg{constructor(){this.data=[],this.buffer=null}get length(){return this.data.length}push(e){this.data.push(e)}get(e){return this.data[e]}find(e){return this.data.find(e)}[Symbol.iterator](){return this.data[Symbol.iterator]()}static serialize(e,i){const o=e.data.length,a=new Float64Array(15*o);for(let c=0;c<o;c++){const h=e.data[c],f=15*c;a[f]=h.centroidXY.x,a[f+1]=h.centroidXY.y,a[f+2]=h.min.x,a[f+3]=h.min.y,a[f+4]=h.max.x,a[f+5]=h.max.y,a[f+6]=h.groupCentroidPos.x,a[f+7]=h.groupCentroidPos.y,a[f+8]=h.vertexArrayOffset,a[f+9]=h.vertexCount,a[f+10]=h.groundVertexArrayOffset,a[f+11]=h.groundVertexCount,a[f+12]=h.footprintSegLen,a[f+13]=h.height,a[f+14]=h.buildingId}return i&&i.add(a.buffer),{buffer:a}}static deserialize(e){const i=e.buffer,o=i.length/15,a=new Tg;a.buffer=i;const c=[];c.length=o,a.data=c;let h=0;for(let f=0;f<o;f++){const _=15*f,y=new wg;y.centroidXY=new Ue(i[_],i[_+1]),y.min=new Ue(i[_+2],i[_+3]),y.max=new Ue(i[_+4],i[_+5]),y.groupCentroidPos=new Ue(i[_+6],i[_+7]),y.vertexArrayOffset=i[_+8],y.vertexCount=i[_+9],y.groundVertexArrayOffset=i[_+10],y.groundVertexCount=i[_+11],y.footprintSegLen=i[_+12],y.height=i[_+13],y.buildingId=i[_+14],y.footprintSegIdx=h,h+=y.footprintSegLen,a.data[f]=y}return a}}class Cx{constructor(){this.acc=new Ue(0,0),this.accCount=0,this.centroidDataIndex=0}startRing(e,i){e.min.x===Number.MAX_VALUE&&(e.min.x=e.max.x=i.x,e.min.y=e.max.y=i.y)}appendEdge(e,i,o){this.accCount++,this.acc._add(i);let a=!!this.borders;i.x<e.min.x?(e.min.x=i.x,a=!0):i.x>e.max.x&&(e.max.x=i.x,a=!0),i.y<e.min.y?(e.min.y=i.y,a=!0):i.y>e.max.y&&(e.max.y=i.y,a=!0),((i.x===0||i.x===rt)&&i.x===o.x)!=((i.y===0||i.y===rt)&&i.y===o.y)&&this.processBorderOverlap(i,o),a&&this.checkBorderIntersection(i,o)}checkBorderIntersection(e,i){i.x<0!=e.x<0&&this.addBorderIntersection(0,vt(i.y,e.y,(0-i.x)/(e.x-i.x))),i.x>rt!=e.x>rt&&this.addBorderIntersection(1,vt(i.y,e.y,(rt-i.x)/(e.x-i.x))),i.y<0!=e.y<0&&this.addBorderIntersection(2,vt(i.x,e.x,(0-i.y)/(e.y-i.y))),i.y>rt!=e.y>rt&&this.addBorderIntersection(3,vt(i.x,e.x,(rt-i.y)/(e.y-i.y)))}addBorderIntersection(e,i){this.borders||(this.borders=[[Number.MAX_VALUE,-Number.MAX_VALUE],[Number.MAX_VALUE,-Number.MAX_VALUE],[Number.MAX_VALUE,-Number.MAX_VALUE],[Number.MAX_VALUE,-Number.MAX_VALUE]]);const o=this.borders[e];i<o[0]&&(o[0]=i),i>o[1]&&(o[1]=i)}processBorderOverlap(e,i){if(e.x===i.x){if(e.y===i.y)return;const o=e.x===0?0:1;this.addBorderIntersection(o,i.y),this.addBorderIntersection(o,e.y)}else{const o=e.y===0?2:3;this.addBorderIntersection(o,i.x),this.addBorderIntersection(o,e.x)}}centroid(){return this.accCount===0?new Ue(0,0):new Ue(Math.floor(Math.max(0,this.acc.x)/this.accCount),Math.floor(Math.max(0,this.acc.y)/this.accCount))}intersectsCount(){return this.borders?this.borders.reduce((e,i)=>e+ +(i[0]!==Number.MAX_VALUE),0):0}}function S0(r,e){const i=r.add(e)._unit(),o=Y(r.x*i.x+r.y*i.y,-1,1);var a,c,h;return h=Math.acos(o),Math.min(4,Math.max(-4,Math.tan(h)))/4*lT*((a=r).x*(c=e).y-a.y*c.x<0?-1:1)}const cT=[r=>r.x<0,r=>r.x>rt,r=>r.y<0,r=>r.y>rt];function uT(r,e,i,o){const a=[4];if(o===0)return a;i._mult(o);const c=r.sub(i),h=e.sub(i),f=[r,e,c,h];for(let _=0;_<4;_++)for(const y of f)if(cT[_](y)){a.push(_);break}return a}class Mx{constructor(e){this.groundRadiusArray=null,this.groundRadiusBuffer=null,this.vertexArray=new $h,this.indexArray=new sn,this.programConfigurations=new hs(e.layers,{zoom:e.zoom,lut:e.lut},i=>sT.includes(i)),this._segments=new Fi,this.hiddenByLandmarkVertexArray=new Eu,this._segmentToGroundQuads={},this._segmentToGroundQuads[0]=[],this._segmentToRegionTriCounts={},this._segmentToRegionTriCounts[0]=[0,0,0,0,0],this.regionSegments={},this.regionSegments[4]=new Fi}getDefaultSegment(){return this.regionSegments[4]}hasData(){return this.vertexArray.length!==0}addData(e,i,o,a=!1){const c=e.length;if(c>2){let h=Math.max(0,this._segments.get().length-1);const f=this._segments._prepareSegment(4*c,this.vertexArray.length,2*this._segmentToGroundQuads[h].length);let _;h!==this._segments.get().length-1&&(h++,this._segmentToGroundQuads[h]=[],this._segmentToRegionTriCounts[h]=[0,0,0,0,0]);{const y=e[0],v=e[1];_=S0(y.sub(e[c-1])._perp()._unit(),v.sub(y)._perp()._unit())}for(let y=0;y<c;y++){const v=y===c-1?0:y+1,b=e[y],T=e[v],E=e[v===c-1?0:v+1],C=T.sub(b)._perp()._unit(),P=S0(C,E.sub(T)._perp()._unit()),R=_,z=P;if(Px(b,T,i)||a&&A0(b,i)&&A0(T,i)){_=P;continue}const V=f.vertexLength;vg(this.vertexArray,b,T,1,1,R),vg(this.vertexArray,b,T,1,0,R),vg(this.vertexArray,b,T,0,1,z),vg(this.vertexArray,b,T,0,0,z),f.vertexLength+=4;const N=uT(b,T,C,o);for(const U of N)this._segmentToGroundQuads[h].push({id:V,region:U}),this._segmentToRegionTriCounts[h][U]+=2,f.primitiveLength+=2;_=P}}}prepareBorderSegments(){if(!this.hasData())return;const e=this._segments.get(),i=e.length;for(let o=0;o<i;o++)this._segmentToGroundQuads[o].sort((a,c)=>a.region-c.region);for(let o=0;o<i;o++){const a=this._segmentToGroundQuads[o],c=e[o],h=this._segmentToRegionTriCounts[o];h.reduce((_,y)=>_+y,0);let f=0;for(let _=0;_<=4;_++){const y=h[_];if(y!==0){let v=this.regionSegments[_];v||(v=this.regionSegments[_]=new Fi);const b={vertexOffset:c.vertexOffset,primitiveOffset:c.primitiveOffset+f,vertexLength:c.vertexLength,primitiveLength:y};v.get().push(b)}f+=y}for(let _=0;_<a.length;_++){const y=a[_].id;this.indexArray.emplaceBack(y,y+1,y+3),this.indexArray.emplaceBack(y,y+3,y+2)}}this._segmentToGroundQuads=null,this._segmentToRegionTriCounts=null,this._segments.destroy(),this._segments=null}addPaintPropertiesData(e,i,o,a,c,h,f){this.hasData()&&this.programConfigurations.populatePaintArrays(this.vertexArray.length,e,i,o,a,c,h,void 0,f)}upload(e){this.hasData()&&(this.vertexBuffer=e.createVertexBuffer(this.vertexArray,Jw.members),this.indexBuffer=e.createIndexBuffer(this.indexArray),this.groundRadiusArray!=null&&(this.groundRadiusBuffer=e.createVertexBuffer(this.groundRadiusArray,Qw.members)))}uploadPaintProperties(e){this.hasData()&&this.programConfigurations.upload(e)}update(e,i,o,a,c,h,f,_){this.hasData()&&this.programConfigurations.updatePaintArrays(e,i,o,a,c,h,f,_)}updateHiddenByLandmark(e){this.updateHiddenByLandmarkRange(e.groundVertexArrayOffset,e.groundVertexCount,!!(e.flags&Ul||e.flags&xg))}updateHiddenByLandmarkRange(e,i,o){if(!this.hasData())return;const a=i+e;if(i!==0){for(let c=e;c<a;++c)this.hiddenByLandmarkVertexArray.emplace(c,o?1:0);this._needsHiddenByLandmarkUpdate=!0}}uploadHiddenByLandmark(e){this.hasData()&&this._needsHiddenByLandmarkUpdate&&(!this.hiddenByLandmarkVertexBuffer&&this.hiddenByLandmarkVertexArray.length>0?this.hiddenByLandmarkVertexBuffer=e.createVertexBuffer(this.hiddenByLandmarkVertexArray,iT.members,!0):this.hiddenByLandmarkVertexBuffer&&this.hiddenByLandmarkVertexBuffer.updateData(this.hiddenByLandmarkVertexArray),this._needsHiddenByLandmarkUpdate=!1)}destroy(){if(this.vertexBuffer){this.vertexBuffer.destroy(),this.indexBuffer.destroy(),this.hiddenByLandmarkVertexBuffer&&this.hiddenByLandmarkVertexBuffer.destroy(),this.groundRadiusBuffer&&this.groundRadiusBuffer.destroy(),this._segments&&this._segments.destroy(),this.programConfigurations.destroy();for(let e=0;e<=4;e++){const i=this.regionSegments[e];i&&i.destroy()}}}}class Sg{constructor(e){this.zoom=e.zoom,this.canonical=e.canonical,this.overscaling=e.overscaling,this.layers=e.layers,this.pixelRatio=e.pixelRatio,this.layerIds=this.layers.map(i=>i.fqid),this.index=e.index,this.hasPattern=!1,this.edgeRadius=0,this.projection=e.projection,this.activeReplacements=[],this.replacementUpdateTime=0,this.centroidData=new Tg,this.footprintIndices=new sn,this.footprintVertices=new _a,this.footprintSegments=new bg,this.layoutVertexArray=new Wf,this.centroidVertexArray=new Cu,this.wallVertexArray=new np,this.indexArray=new sn,this.programConfigurations=new hs(e.layers,{zoom:e.zoom,lut:e.lut},i=>oT.includes(i)),this.segments=new Fi,this.stateDependentLayerIds=this.layers.filter(i=>i.isStateDependent()).map(i=>i.id),this.groundEffect=new Mx(e),this.maxHeight=0,this.partLookup={},this.triangleSubSegments=[],this.polygonSegments=[],this.buildingGroups=new Map,this.worldview=e.worldview,this.hasAppearances=null}updateFootprints(e,i){}updateAppearances(e,i,o,a){return{hasLayoutChanges:!1,hasUboChanges:!1}}populate(e,i,o,a){this.features=[],this.hasPattern=kf("fill-extrusion",this.layers,this.pixelRatio,i),this.featuresOnBorder=[],this.borderFeatureIndices=[[],[],[],[]],this.borderDoneWithNeighborZ=[-1,-1,-1,-1],this.selfDEMTileTimestamp=Number.MAX_VALUE,this.borderDEMTileTimestamp=[Number.MAX_VALUE,Number.MAX_VALUE,Number.MAX_VALUE,Number.MAX_VALUE],this.tileToMeter=yo(o),this.edgeRadius=this.layers[0].layout.get("fill-extrusion-edge-radius")/this.tileToMeter,this.wallMode=this.layers[0].paint.get("fill-extrusion-line-width").constantOr(1)!==0;for(const{feature:c,id:h,index:f,sourceLayerIndex:_}of e){const y=this.layers[0]._featureFilter.needGeometry,v=Vo(c,y);if(!this.layers[0]._featureFilter.filter(new xt(this.zoom,{worldview:this.worldview,activeFloors:i.activeFloors}),v,o))continue;const b={id:h,sourceLayerIndex:_,index:f,geometry:y?v.geometry:ls(c,o,a),properties:c.properties,type:c.type,patterns:{}},T=this.layoutVertexArray.length,E=Ax[b.type]==="Polygon";if(this.hasPattern)this.features.push({featureId:c.id,feature:Bf("fill-extrusion",this.layers,b,this.zoom,this.pixelRatio,i)});else if(this.wallMode)for(const C of b.geometry)for(const P of w0(C,E))this.addFeature(c.id,b,[P],f,o,{},i.availableImages,a,i.brightness);else this.addFeature(c.id,b,b.geometry,f,o,{},i.availableImages,a,i.brightness);i.featureIndex.insert(c,b.geometry,f,_,this.index,T)}this._finalizeBuildingGroups(),this.sortBorders(),this.projection.name==="mercator"&&this.splitToSubtiles(),this.groundEffect.prepareBorderSegments(),this.polygonSegments.length=0}addFeatures(e,i,o,a,c,h){for(const{featureId:f,feature:_}of this.features){const y=Ax[_.type]==="Polygon",{geometry:v}=_;if(this.wallMode)for(const b of v)for(const T of w0(b,y))this.addFeature(f,_,[T],_.index,i,o,a,c,h);else this.addFeature(f,_,v,_.index,i,o,a,c,h)}this._finalizeBuildingGroups(),this.sortBorders(),this.projection.name==="mercator"&&this.splitToSubtiles()}update(e,i,o,a,c,h,f){this.programConfigurations.updatePaintArrays(e,i,c,o,a,h,f,this.worldview),this.groundEffect.update(e,i,c,o,a,h,f,this.worldview)}updateExpressions(e){this.programConfigurations.updateExpressions(e),this.groundEffect.programConfigurations.updateExpressions(e)}isEmpty(){return this.layoutVertexArray.length===0}uploadPending(){return!this.uploaded||this.programConfigurations.needsUpload||this.groundEffect.programConfigurations.needsUpload}upload(e){this.uploaded||(this.layoutVertexBuffer=e.createVertexBuffer(this.layoutVertexArray,nT),this.indexBuffer=e.createIndexBuffer(this.indexArray),this.wallVertexBuffer=e.createVertexBuffer(this.wallVertexArray,tT.members),this.layoutVertexExtArray&&(this.layoutVertexExtBuffer=e.createVertexBuffer(this.layoutVertexExtArray,rT.members,!0)),this.groundEffect.upload(e)),this.groundEffect.uploadPaintProperties(e),this.programConfigurations.upload(e),this.uploaded=!0}uploadCentroid(e){this.groundEffect.uploadHiddenByLandmark(e),this.needsCentroidUpdate&&(!this.centroidVertexBuffer&&this.centroidVertexArray.length>0?this.centroidVertexBuffer=e.createVertexBuffer(this.centroidVertexArray,eT.members,!0):this.centroidVertexBuffer&&this.centroidVertexBuffer.updateData(this.centroidVertexArray),this.needsCentroidUpdate=!1)}destroy(){this.layoutVertexBuffer&&(this.layoutVertexBuffer.destroy(),this.centroidVertexBuffer&&this.centroidVertexBuffer.destroy(),this.layoutVertexExtBuffer&&this.layoutVertexExtBuffer.destroy(),this.groundEffect.destroy(),this.indexBuffer.destroy(),this.programConfigurations.destroy(),this.segments.destroy())}addFeature(e,i,o,a,c,h,f,_,y){const v=this.layers[0].paint.get("fill-extrusion-flood-light-ground-radius").evaluate(i,{})/this.tileToMeter,b=[new Ue(0,0),new Ue(rt,rt)],T=_.projection,E=T.name==="globe",C=this.wallMode||Ax[i.type]==="Polygon",P=new Cx;P.centroidDataIndex=this.centroidData.length;const R=new wg;R.buildingId=e,i.properties&&Object.hasOwn(i.properties,"building_id")&&(R.buildingId=Number(i.properties.building_id)),P.buildingId=R.buildingId;const z=this.layers[0].paint.get("fill-extrusion-base").evaluate(i,{},c)<=0,V=this.layers[0].paint.get("fill-extrusion-height").evaluate(i,{},c);let N;if(R.height=V,R.vertexArrayOffset=this.layoutVertexArray.length,R.groundVertexArrayOffset=this.groundEffect.vertexArray.length,E&&!this.layoutVertexExtArray&&(this.layoutVertexExtArray=new Su),this.wallMode){if(E)return void ht("Non zero fill-extrusion-line-width is not yet supported on globe.");if(o.length!==1)return;N=(function(re){const oe=re[0].x===re.at(-1).x&&re[0].y===re.at(-1).y;(function(He){let Ye=0;const st=He.length;for(let Je=0;Je<st;Je++)Ye+=(He[(Je+1)%st].x-He[Je].x)*(He[(Je+1)%st].y+He[Je].y);return Ye>=0})(re)||(re=re.reverse());const xe={geometry:[],joinNormals:[],indices:[]},we=[],Ce=[],Se=[];let qe=re.length;for(;qe>=2&&re[qe-1].equals(re[qe-2]);)qe--;if(qe<(oe?3:2))return xe;let Me,Ie,Pe,Ne,ke,$e=0;for(;$e<qe-1&&re[$e].equals(re[$e+1]);)$e++;oe&&(Me=re[qe-2],ke=re[$e].sub(Me)._unit()._perp());for(let He=$e;He<qe;He++){if(Pe=He===qe-1?oe?re[$e+1]:void 0:re[He+1],Pe&&re[He].equals(Pe))continue;ke&&(Ne=ke),Me&&(Ie=Me),Me=re[He],ke=Pe?Pe.sub(Me)._unit()._perp():Ne,Ne=Ne||ke;let Ye=Ne.add(ke);Ye.x===0&&Ye.y===0||Ye._unit();const st=Ye.x*ke.x+Ye.y*ke.y,Je=st!==0?1/st:1/0,Qe=Ne.x*ke.y-Ne.y*ke.x>0;let dt="miter";const wt=2;dt==="miter"&&Je>wt&&(dt="bevel"),dt==="bevel"&&(Je>100&&(dt="flipbevel"),Je<wt&&(dt="miter"));const Bt=(lt,Et,Rt,ki)=>{const qt=new Ue(lt.x,lt.y),ni=new Ue(lt.x,lt.y);qt.x+=Et.x*ki,qt.y+=Et.y*ki,ni.x-=Et.x*Math.max(Rt,1),ni.y-=Et.y*Math.max(Rt,1),Se.push(Et),we.push(qt),Ce.push(ni)};if(dt==="miter")Ye._mult(Je),Bt(Me,Ye,0,0);else if(dt==="flipbevel")Ye=ke.mult(-1),Bt(Me,Ye,0,0),Bt(Me,Ye.mult(-1),0,0);else{const lt=-Math.sqrt(Je*Je-1),Et=Qe?lt:0,Rt=Qe?0:lt;Ie&&Bt(Me,Ne,Et,Rt),Pe&&Bt(Me,ke,Et,Rt)}}xe.geometry=[...we,...Ce.reverse(),we[0]],xe.joinNormals=[...Se,...Se.reverse(),Se.at(-1)];const ze=xe.geometry.length-1;for(let He=0;He<ze/2;He++)if(He+1<ze/2){let Ye=He,st=He+1,Je=ze-1-He,Qe=ze-2-He;Ye=Ye===0?ze-1:Ye-1,st=st===0?ze-1:st-1,Je=Je===0?ze-1:Je-1,Qe=Qe===0?ze-1:Qe-1,xe.indices.push(Je),xe.indices.push(st),xe.indices.push(Ye),xe.indices.push(Je),xe.indices.push(Qe),xe.indices.push(st)}return xe})(o[0]),o=[N.geometry]}const U=(re,oe)=>re<(oe.length-1)/2||re===oe.length-1,q=this.wallMode?[o]:Ro(o,500);for(let re=q.length-1;re>=0;re--){const oe=q[re];(oe.length===0||dT(oe[0]))&&q.splice(re,1)}let W;if(E)W=R0(q,b,c);else{W=[];for(const re of q)W.push({polygon:re,bounds:b})}const se=C?this.edgeRadius:0,X=se>0&&this.zoom<17,ie=(re,oe)=>{if(re.length===0)return!1;const me=re.at(-1);return oe.x===me.x&&oe.y===me.y};for(const{polygon:re,bounds:oe}of W){let me=0,xe=0;for(const qe of re)C&&!qe[0].equals(qe.at(-1))&&qe.push(qe[0]),xe+=C?qe.length-1:qe.length;const we=this.segments.prepareSegment((C?5:4)*xe,this.layoutVertexArray,this.indexArray);R.footprintSegIdx<0&&(R.footprintSegIdx=this.footprintSegments.length),R.polygonSegIdx<0&&(R.polygonSegIdx=this.polygonSegments.length);const Ce={triangleArrayOffset:this.indexArray.length,triangleCount:0,triangleSegIdx:this.segments.segments.length-1},Se=new T0;if(Se.vertexOffset=this.footprintVertices.length,Se.indexOffset=3*this.footprintIndices.length,Se.ringIndices=[],C){const qe=[],Me=[];me=we.vertexLength;for(let Pe=0;Pe<re.length;Pe++){const Ne=re[Pe];Ne.length&&Pe!==0&&Me.push(qe.length/2);const ke=[];let $e,ze;$e=Ne[1].sub(Ne[0])._perp()._unit(),Se.ringIndices.push(Ne.length-1);for(let He=1;He<Ne.length;He++){const Ye=Ne[He],st=Ne[He===Ne.length-1?1:He+1],Je=Ye.clone();if(se){ze=st.sub(Ye)._perp()._unit();const Qe=$e.add(ze)._unit(),dt=se*Math.min(4,1/($e.x*Qe.x+$e.y*Qe.y));Je.x+=dt*Qe.x,Je.y+=dt*Qe.y,Je.x=Math.round(Je.x),Je.y=Math.round(Je.y),$e=ze}if(!z||se!==0&&!X||ie(ke,Je)||ke.push(Je),kp(this.layoutVertexArray,Je.x,Je.y,0,0,1,1,0),this.wallMode){const Qe=U(He,Ne);Bp(this.wallVertexArray,N.joinNormals[He],!Qe)}we.vertexLength++,this.footprintVertices.emplaceBack(Ye.x,Ye.y),qe.push(Ye.x,Ye.y),E&&Np(this.layoutVertexExtArray,T.projectTilePoint(Je.x,Je.y,c),T.upVector(c,Je.x,Je.y))}z&&(se===0||X)&&(ke.length!==0&&ie(ke,ke[0])&&ke.pop(),this.groundEffect.addData(ke,oe,v))}const Ie=this.wallMode?N.indices:Sc(qe,Me);for(let Pe=0;Pe<Ie.length;Pe+=3)this.footprintIndices.emplaceBack(Se.vertexOffset+Ie[Pe+0],Se.vertexOffset+Ie[Pe+1],Se.vertexOffset+Ie[Pe+2]),this.indexArray.emplaceBack(me+Ie[Pe],me+Ie[Pe+2],me+Ie[Pe+1]),we.primitiveLength++;Se.indexCount+=Ie.length,Se.vertexCount+=this.footprintVertices.length-Se.vertexOffset}for(let qe=0;qe<re.length;qe++){const Me=re[qe];P.startRing(R,Me[0]);let Ie=Me.length>4&&C0(Me[Me.length-2],Me[0],Me[1]),Pe=se?hT(Me[Me.length-2],Me[0],Me[1],se):0;const Ne=[];let ke,$e,ze;$e=Me[1].sub(Me[0])._perp()._unit();let He=!0;for(let Ye=1,st=0;Ye<Me.length;Ye++){let Je=Me[Ye-1],Qe=Me[Ye];const dt=Me[Ye===Me.length-1?1:Ye+1];if(P.appendEdge(R,Qe,Je),Px(Qe,Je,oe)){se&&($e=dt.sub(Qe)._perp()._unit(),He=!He);continue}const wt=Qe.sub(Je)._perp(),Bt=wt.x/(Math.abs(wt.x)+Math.abs(wt.y)),lt=wt.y>0?1:0,Et=Je.dist(Qe);if(st+Et>32768&&(st=0),se){ze=dt.sub(Qe)._perp()._unit();let ni=I0(Je,Qe,dt,E0($e,ze),se);isNaN(ni)&&(ni=0);const _i=Qe.sub(Je)._unit();Je=Je.add(_i.mult(Pe))._round(),Qe=Qe.add(_i.mult(-ni))._round(),Pe=ni,$e=ze,z&&this.zoom>=17&&(ie(Ne,Je)||Ne.push(Je),ie(Ne,Qe)||Ne.push(Qe))}const Rt=we.vertexLength,ki=Me.length>4&&C0(Je,Qe,dt);let qt=M0(st,Ie,He);if(kp(this.layoutVertexArray,Je.x,Je.y,Bt,lt,0,0,qt),kp(this.layoutVertexArray,Je.x,Je.y,Bt,lt,0,1,qt),this.wallMode){const ni=U(Ye-1,Me),_i=N.joinNormals[Ye-1];Bp(this.wallVertexArray,_i,ni),Bp(this.wallVertexArray,_i,ni)}if(st+=Et,qt=M0(st,ki,!He),Ie=ki,kp(this.layoutVertexArray,Qe.x,Qe.y,Bt,lt,0,0,qt),kp(this.layoutVertexArray,Qe.x,Qe.y,Bt,lt,0,1,qt),this.wallMode){const ni=U(Ye,Me),_i=N.joinNormals[Ye];Bp(this.wallVertexArray,_i,ni),Bp(this.wallVertexArray,_i,ni)}if(we.vertexLength+=4,this.indexArray.emplaceBack(Rt+0,Rt+1,Rt+2),this.indexArray.emplaceBack(Rt+1,Rt+3,Rt+2),we.primitiveLength+=2,se){const ni=me+(Ye===1?Me.length-2:Ye-2),_i=Ye===1?me:ni+1;if(this.indexArray.emplaceBack(Rt+1,ni,Rt+3),this.indexArray.emplaceBack(ni,_i,Rt+3),we.primitiveLength+=2,ke===void 0&&(ke=Rt),!Px(dt,Me[Ye],oe)){const $i=Ye===Me.length-1?ke:we.vertexLength;this.indexArray.emplaceBack(Rt+2,Rt+3,$i),this.indexArray.emplaceBack(Rt+3,$i+1,$i),this.indexArray.emplaceBack(Rt+3,_i,$i+1),we.primitiveLength+=3}He=!He}if(E){const ni=this.layoutVertexExtArray,_i=T.projectTilePoint(Je.x,Je.y,c),$i=T.projectTilePoint(Qe.x,Qe.y,c),Ir=T.upVector(c,Je.x,Je.y),gi=T.upVector(c,Qe.x,Qe.y);Np(ni,_i,Ir),Np(ni,_i,Ir),Np(ni,$i,gi),Np(ni,$i,gi)}}C&&(me+=Me.length-1),z&&se&&this.zoom>=17&&(Ne.length!==0&&ie(Ne,Ne[0])&&Ne.pop(),this.groundEffect.addData(Ne,oe,v,se>0))}this.footprintSegments.push(Se),Ce.triangleCount=this.indexArray.length-Ce.triangleArrayOffset,this.polygonSegments.push(Ce),++R.footprintSegLen,++R.polygonSegLen}if(R.vertexCount=this.layoutVertexArray.length-R.vertexArrayOffset,R.groundVertexCount=this.groundEffect.vertexArray.length-R.groundVertexArrayOffset,R.vertexCount!==0){if(R.centroidXY=P.borders?yg:this.encodeCentroid(P,R),i.properties&&Object.hasOwn(i.properties,"building_id")){const re=R.buildingId;let oe=this.buildingGroups.get(re);oe||(oe={accX:0,accY:0,accCount:0,mergedMin:new Ue(Number.MAX_VALUE,Number.MAX_VALUE),mergedMax:new Ue(-Number.MAX_VALUE,-Number.MAX_VALUE),partIndices:[]},this.buildingGroups.set(re,oe)),oe.accX+=P.acc.x,oe.accY+=P.acc.y,oe.accCount+=P.accCount,oe.mergedMin.x=Math.min(oe.mergedMin.x,R.min.x),oe.mergedMin.y=Math.min(oe.mergedMin.y,R.min.y),oe.mergedMax.x=Math.max(oe.mergedMax.x,R.max.x),oe.mergedMax.y=Math.max(oe.mergedMax.y,R.max.y),oe.partIndices.push(this.centroidData.length)}if(this.centroidData.push(R),P.borders){this.featuresOnBorder.push(P);const re=this.featuresOnBorder.length-1;for(let oe=0;oe<P.borders.length;oe++)P.borders[oe][0]!==Number.MAX_VALUE&&this.borderFeatureIndices[oe].push(re)}this.programConfigurations.populatePaintArrays(this.layoutVertexArray.length,i,a,h,f,c,y,void 0,this.worldview),this.groundEffect.addPaintPropertiesData(i,a,h,f,c,y,this.worldview),this.maxHeight=Math.max(this.maxHeight,V)}}_finalizeBuildingGroups(){for(const[,e]of this.buildingGroups){if(e.partIndices.length===0)continue;const i=new Cx;i.acc=new Ue(e.accX,e.accY),i.accCount=e.accCount;const o=new wg;o.min=e.mergedMin,o.max=e.mergedMax;const a=this.encodeCentroid(i,o),c=i.centroid();for(const h of e.partIndices){const f=this.centroidData.get(h);f.centroidXY.x===yg.x&&f.centroidXY.y===yg.y||(f.centroidXY=a),f.min=e.mergedMin,f.max=e.mergedMax,f.groupCentroidPos=c}}this.buildingGroups.clear()}sortBorders(){for(let e=0;e<this.borderFeatureIndices.length;e++)this.borderFeatureIndices[e].sort((i,o)=>this.featuresOnBorder[i].borders[e][0]-this.featuresOnBorder[o].borders[e][0])}splitToSubtiles(){const e=[];for(let f=0;f<this.centroidData.length;f++){const _=this.centroidData.get(f),y=+(_.min.y+_.max.y>rt),v=2*y+(+(_.min.x+_.max.x>rt)^y);for(let b=0;b<_.polygonSegLen;b++){const T=_.polygonSegIdx+b;e.push({centroidIdx:f,subtile:v,polygonSegmentIdx:T,triangleSegmentIdx:this.polygonSegments[T].triangleSegIdx})}}const i=new sn;e.sort((f,_)=>f.triangleSegmentIdx===_.triangleSegmentIdx?f.subtile-_.subtile:f.triangleSegmentIdx-_.triangleSegmentIdx);let o=0,a=0,c=0;for(const f of e){if(f.triangleSegmentIdx!==o)break;c++}const h=e.length;for(;a!==e.length;){o=e[a].triangleSegmentIdx;let f=0,_=a,y=a;for(let v=_;v<c&&e[v].subtile===f;v++)y++;for(;_!==c;){const v=e[_];f=v.subtile;const b=this.centroidData.get(v.centroidIdx).min.clone(),T=this.centroidData.get(v.centroidIdx).max.clone(),E={vertexOffset:this.segments.segments[o].vertexOffset,primitiveOffset:i.length,vertexLength:this.segments.segments[o].vertexLength,primitiveLength:0,sortKey:void 0,vaos:{}};for(let C=_;C<y;C++){const P=e[C],R=this.polygonSegments[P.polygonSegmentIdx],z=this.centroidData.get(P.centroidIdx).min,V=this.centroidData.get(P.centroidIdx).max,N=this.indexArray.uint16;for(let U=R.triangleArrayOffset;U<R.triangleArrayOffset+R.triangleCount;U++)i.emplaceBack(N[3*U],N[3*U+1],N[3*U+2]);E.primitiveLength+=R.triangleCount,b.x=Math.min(b.x,z.x),b.y=Math.min(b.y,z.y),T.x=Math.max(T.x,V.x),T.y=Math.max(T.y,V.y)}E.primitiveLength>0&&this.triangleSubSegments.push({segment:E,min:b,max:T}),_=y;for(let C=_;C<c&&e[C].subtile===e[_].subtile;C++)y++}a=c;for(let v=a;v<h&&e[v].triangleSegmentIdx===e[a].triangleSegmentIdx;v++)c++}i._trim(),this.indexArray=i}getVisibleSegments(e,i,o){const a=new Fi;if(this.wallMode){for(const P of this.triangleSubSegments)a.segments.push(P.segment);return a}let c=0,h=0;const f=1<<e.canonical.z;if(i){const P=i.getMinMaxForTile(e);P&&(c=P.min,h=P.max)}h+=this.maxHeight;const _=e.toUnwrapped();let y;const v=[_.canonical.x/f+_.wrap,_.canonical.y/f],b=[(_.canonical.x+1)/f+_.wrap,(_.canonical.y+1)/f],T=(P,R,z)=>[vt(P[0],R[0],z[0]),vt(P[1],R[1],z[1])],E=[],C=[];for(const P of this.triangleSubSegments){E[0]=P.min.x/rt,E[1]=P.min.y/rt,C[0]=P.max.x/rt,C[1]=P.max.y/rt;const R=T(v,b,E),z=T(v,b,C);if(new lr([R[0],R[1],c],[z[0],z[1],h]).intersectsPrecise(o)===0){y&&(a.segments.push(y),y=void 0);continue}const V=P.segment;y&&y.vertexOffset!==V.vertexOffset&&(a.segments.push(y),y=void 0),y?(y.vertexLength+=V.vertexLength,y.primitiveLength+=V.primitiveLength):y={vertexOffset:V.vertexOffset,primitiveLength:V.primitiveLength,vertexLength:V.vertexLength,primitiveOffset:V.primitiveOffset,sortKey:void 0,vaos:{}}}return y&&a.segments.push(y),a}encodeCentroid(e,i){const o=e.centroid(),a=i.span(),c=Math.min(7,Math.round(a.x*this.tileToMeter/10)),h=Math.min(6,Math.round(a.y*this.tileToMeter/10));return new Ue(Y(o.x,1,8191)<<3|c,Y(o.y,1,8191)<<3|h)}encodeBorderCentroid(e){if(!e.borders)return new Ue(0,0);const i=e.borders,o=Number.MAX_VALUE;if(i[0][0]!==o||i[1][0]!==o){const a=i[0][0]!==o?0:1;return new Ue(6|(i[0][0]!==o?0:65528),(i[a][0]+i[a][1])/2<<3|6)}{const a=i[2][0]!==o?2:3;return new Ue((i[a][0]+i[a][1])/2<<3|6,6|(i[2][0]!==o?0:65528))}}showCentroid(e){const i=this.centroidData.get(e.centroidDataIndex);if(i.flags&=Ul,i.groupCentroidPos.x!==0||i.groupCentroidPos.y!==0){const o=i.span(),a=Math.min(7,Math.round(o.x*this.tileToMeter/10)),c=Math.min(6,Math.round(o.y*this.tileToMeter/10));i.centroidXY=new Ue(Y(i.groupCentroidPos.x,1,8191)<<3|a,Y(i.groupCentroidPos.y,1,8191)<<3|c)}else i.centroidXY=new Ue(0,0);this.writeCentroidToBuffer(i)}writeCentroidToBuffer(e){this.groundEffect.updateHiddenByLandmark(e);const i=e.vertexArrayOffset,o=e.vertexCount+e.vertexArrayOffset,a=-1073741824&e.flags?yg:e.centroidXY,c=this.centroidVertexArray.geta_centroid_pos0(i);if(this.centroidVertexArray.geta_centroid_pos1(i)!==a.y||c!==a.x){for(let h=i;h<o;++h)this.centroidVertexArray.emplace(h,a.x,a.y);this.needsCentroidUpdate=!0}}createCentroidsBuffer(){this.centroidVertexArray.resize(this.layoutVertexArray.length),this.groundEffect.hiddenByLandmarkVertexArray.resize(this.groundEffect.vertexArray.length);for(const e of this.centroidData)this.writeCentroidToBuffer(e)}updateReplacement(e,i,o){if(i.updateTime===this.replacementUpdateTime)return;this.replacementUpdateTime=i.updateTime;const a=i.getReplacementRegionsForTile(e.toUnwrapped());if(K_(this.activeReplacements,a))return;if(this.activeReplacements=a,this.centroidVertexArray.length===0)this.createCentroidsBuffer();else for(const h of this.centroidData)h.flags&=1073741823;const c=[];for(const h of this.activeReplacements){if(h.order<o)continue;const f=Math.max(1,Math.pow(2,h.footprintTileId.canonical.z-e.canonical.z));if(h.footprint.buildingIds)for(const _ of this.centroidData)_.flags&Ul||_.flags&xg||h.min.x>_.max.x||_.min.x>h.max.x||h.min.y>_.max.y||_.min.y>h.max.y||h.footprint.buildingIds.has(_.buildingId)&&(_.flags|=h.clipMask!==gg.None?-1073741824:Ul);else for(const _ of this.centroidData)if(!(_.flags&Ul||_.flags&xg||h.min.x>_.max.x||_.min.x>h.max.x||h.min.y>_.max.y||_.min.y>h.max.y))for(let y=0;y<_.footprintSegLen;y++){const v=this.footprintSegments.get(_.footprintSegIdx+y);if(c.length=0,fT(this.footprintVertices,v.vertexOffset,v.vertexCount,h.footprintTileId.canonical,e.canonical,c),rx(h.footprint,c,this.footprintIndices.uint16,v.indexOffset,v.indexCount,-v.vertexOffset,-f)){_.flags|=h.clipMask!==gg.None?-1073741824:Ul;break}}}for(const h of this.centroidData)this.writeCentroidToBuffer(h);this.borderDoneWithNeighborZ=[-1,-1,-1,-1]}footprintContainsPoint(e,i,o){let a=!1;for(let c=0;c<o.footprintSegLen;c++){const h=this.footprintSegments.get(o.footprintSegIdx+c);let f=0;for(const _ of h.ringIndices){for(let y=f,v=_+f-1;y<_+f;v=y++){const b=this.footprintVertices.int16[2*(y+h.vertexOffset)+0],T=this.footprintVertices.int16[2*(y+h.vertexOffset)+1],E=this.footprintVertices.int16[2*(v+h.vertexOffset)+1];T>i!=E>i&&e<(this.footprintVertices.int16[2*(v+h.vertexOffset)+0]-b)*(i-T)/(E-T)+b&&(a=!a)}f=_}}return a}getHeightAtTileCoord(e,i){let o=Number.NEGATIVE_INFINITY,a=!0;const c=4*(e+rt)*rt+(i+rt);if(Object.hasOwn(this.partLookup,c)){const _=this.partLookup[c];return _?{height:_.height,hidden:!!(_.flags&Ul)}:void 0}const h=this.centroidData.buffer,f=this.centroidData.length;for(let _=0;_<f;_++){const y=15*_;if(e>h[y+4]||h[y+2]>e||i>h[y+5]||h[y+3]>i)continue;const v=h[y+13];if(v<=o)continue;const b=this.centroidData.get(_);this.footprintContainsPoint(e,i,b)&&(o=v,this.partLookup[c]=b,a=!!(b.flags&Ul))}if(o!==Number.NEGATIVE_INFINITY)return{height:o,hidden:a};this.partLookup[c]=void 0}}function E0(r,e){const i=r.add(e)._unit();return r.x*i.x+r.y*i.y}function hT(r,e,i,o){const a=e.sub(r)._perp()._unit(),c=i.sub(e)._perp()._unit();return I0(r,e,i,E0(a,c),o)}function I0(r,e,i,o,a){const c=Math.sqrt(1-o*o);return Math.min(r.dist(e)/3,e.dist(i)/3,a*c/o)}function Px(r,e,i){return r.x<i[0].x&&e.x<i[0].x||r.x>i[1].x&&e.x>i[1].x||r.y<i[0].y&&e.y<i[0].y||r.y>i[1].y&&e.y>i[1].y}function A0(r,e){return r.x<e[0].x||r.x>e[1].x||r.y<e[0].y||r.y>e[1].y}function dT(r){return r.every(e=>e.x<=0)||r.every(e=>e.x>=rt)||r.every(e=>e.y<=0)||r.every(e=>e.y>=rt)}function C0(r,e,i){if(r.x<0||r.x>=rt||e.x<0||e.x>=rt||i.x<0||i.x>=rt)return!1;const o=i.sub(e),a=o.perp(),c=r.sub(e);return(o.x*c.x+o.y*c.y)/Math.sqrt((o.x*o.x+o.y*o.y)*(c.x*c.x+c.y*c.y))>-.866&&a.x*c.x+a.y*c.y<0}function M0(r,e,i){const o=e?2|r:-3&r;return i?1|o:-2&o}function P0(){const r=Math.PI/32,e=Math.tan(r),i=Ic;return i*Math.sqrt(1+2*e*e)-i}function R0(r,e,i){const o=1<<i.z,a=$r(i.x/o),c=$r((i.x+1)/o),h=on(i.y/o),f=on((i.y+1)/o);return(function(_,y,v,b,T=0,E){const C=[];if(!_.length||!v||!b)return C;const P=(W,se)=>{for(const X of W)C.push({polygon:X,bounds:se})},R=Math.ceil(Math.log2(v)),z=Math.ceil(Math.log2(b)),V=R-z,N=[];for(let W=0;W<Math.abs(V);W++)N.push(V>0?0:1);for(let W=0;W<Math.min(R,z);W++)N.push(0),N.push(1);let U=_;if(U=_g(U,y[0].y-T,y[1].y+T,1),U=_g(U,y[0].x-T,y[1].x+T,0),!U.length)return C;const q=[];for(N.length?q.push({polygons:U,bounds:y,depth:0}):P(U,y);q.length;){const W=q.pop(),se=W.depth,X=N[se],ie=W.bounds[0],re=W.bounds[1],oe=X===0?ie.x:ie.y,me=X===0?re.x:re.y,xe=E?E(X,oe,me):.5*(oe+me),we=_g(W.polygons,oe-T,xe+T,X),Ce=_g(W.polygons,xe-T,me+T,X);if(we.length){const Se=[ie,new Ue(X===0?xe:re.x,X===1?xe:re.y)];N.length>se+1?q.push({polygons:we,bounds:Se,depth:se+1}):P(we,Se)}if(Ce.length){const Se=[new Ue(X===0?xe:ie.x,X===1?xe:ie.y),re];N.length>se+1?q.push({polygons:Ce,bounds:Se,depth:se+1}):P(Ce,Se)}}return C})(r,e,Math.ceil((c-a)/11.25),Math.ceil((h-f)/11.25),1,(_,y,v)=>{if(_===0)return .5*(y+v);{const b=on((i.y+y/rt)/o);return(vn(.5*(on((i.y+v/rt)/o)+b))*o-i.y)*rt}})}function fT(r,e,i,o,a,c){const h=Math.pow(2,o.z-a.z);for(let f=0;f<i;f++){let _=r.int16[2*(f+e)+0],y=r.int16[2*(f+e)+1];_=(_+a.x*rt)*h-o.x*rt,y=(y+a.y*rt)*h-o.y*rt,c.push(new Ue(_,y))}}nt(Sg,"FillExtrusionBucket",{omit:["layers","features"]}),nt(wg,"PartData"),nt(Tg,"PartDataArray"),nt(bg,"FootprintSegmentArray"),nt(Cx,"BorderCentroidData"),nt(Mx,"GroundEffect");const Rx=4096;class pT{constructor(e){this.module=e,this.memoryStack=this.module.malloc(Rx),this.memoryStackNextFree=this.memoryStack}createIntArray(e){const i=this.memoryStackNextFree;return this.memoryStackNextFree+=e.length*Int32Array.BYTES_PER_ELEMENT,this.memoryStackNextFree-this.memoryStack>Rx?-1:(new Int32Array(this.module.heap32.buffer,i,e.length).set(e),i)}createFloatArray(e){const i=this.memoryStackNextFree;return this.memoryStackNextFree+=e.length*Float32Array.BYTES_PER_ELEMENT,this.memoryStackNextFree-this.memoryStack>Rx?-1:(new Float32Array(this.module.heapF32.buffer,i,e.length).set(e),i)}readStringBuffer(e){let i="";for(;this.module.heapU8[e]!==0;)i+=String.fromCharCode(this.module.heapU8[e]),++e;return i}setStyle(e){const i=e.normalScale;this.module.setStyle(i[0],i[1],i[2],e.tileToMeters)}setAOOptions(e,i){this.module.setAOOptions(e?1:0,i)}setMetricOptions(e,i){this.module.setMetricOptions(e?1:0,i)}setStructuralOptions(e){this.module.setStructuralOptions(e?1:0)}setFacadeOptions(e,i){this.module.setFacadeOptions(e,i?1:0)}setFauxFacadeOptions(e,i,o){this.module.setFauxFacadeOptions(e?1:0,i?1:0,o)}setFacadeClassifierOptions(e){this.module.setFacadeClassifierOptions(e)}generateMesh(e,i){this.memoryStackNextFree=this.memoryStack;for(const f of e){const _=this.createIntArray(f.ringIndices),y=this.createFloatArray(f.coordinates);if(_===-1||y===-1)return`building_gen: Out of stack memory: ${this.memoryStackNextFree-this.memoryStack}/4096`;this.module.addFeature(f.id,f.sourceId,f.minHeight,f.height,f.roofType,y,_,f.ringIndices.length-1)}for(const f of i){let _;_=f.entrances?JSON.parse(f.entrances):[];const y=this.createFloatArray(_),v=this.createFloatArray(f.coordinates);if(y===-1||v===-1)return`building_gen: Out of stack memory: ${this.memoryStackNextFree-this.memoryStack}/4096`;this.module.addFacade(f.sourceId,f.crossPerc,f.distanceToRoad,y,_.length,v,f.coordinates.length)}if(!this.module.generateMesh()){const f=this.module.getLastError();return this.readStringBuffer(f)}const o=this.module.getMeshCount(),a=new Array(o);for(let f=0;f<o;f++){const _=this.module.getPositionsPtr(f),y=this.module.getPositionsLength(f),v=new Float32Array(this.module.heapF32.buffer,_,y),b=this.module.getNormalsPtr(f),T=this.module.getNormalsLength(f),E=new Float32Array(this.module.heapF32.buffer,b,T),C=this.module.getAOPtr(f),P=this.module.getAOLength(f),R=new Float32Array(this.module.heapF32.buffer,C,P),z=this.module.getUVPtr(f),V=this.module.getUVLength(f),N=new Float32Array(this.module.heapF32.buffer,z,V),U=this.module.getFauxFacadePtr(f),q=this.module.getFauxFacadeLength(f),W=new Uint8Array(this.module.heapU8.buffer,U,q),se=this.module.getIndicesPtr(f),X=this.module.getIndicesLength(f),ie=new Int16Array(this.module.heap16.buffer,se,X),re=this.module.getBuildingPart(f);a[f]={positions:v,normals:E,ao:R,uv:N,isFauxFacade:W,indices:ie,buildingPart:re}}const c=this.module.getRingCount(),h=[];for(let f=0;f<c;f++){const _=this.module.getRingPtr(f),y=this.module.getRingLength(f),v=new Float32Array(this.module.heapF32.buffer,_,y);h.push(v)}return{meshes:a,outerRingLength:this.module.getOuterRingLength(),modifiedPolygonRings:h}}}const D0=Za.types,Eg=32767;function mT(r,e){const i=rt+e;for(const o of r)for(const a of o)if(a.x<-e||a.x>i||a.y<-e||a.y>i)return!1;return!0}function _T(r){switch(r){case"flat":return 3;case"hipped":return 1;case"gabled":return 2;case"parapet":return 0;case"mansard":return 4;case"skillion":return 5;case"pyramidal":return 6;default:throw new Error(`Unknown roof shape: ${r}`)}}let L0,z0,Ad=null,F0=null,Ds=null;class Dx{constructor(){this.layoutVertexArray=new cs,this.layoutAttenuationArray=new ga,this.layoutColorArray=new us,this.indexArray=new sn,this.indexArrayForConflation=new sn,this.segmentsBucket=new Fi}}class Lx{constructor(e){this.layoutFacadePaintArray=null,this.layoutFacadeDataArray=null,this.layoutFacadeVerticalRangeArray=null,this.segmentsBucket=new Fi,this.entranceBloom=new Dx;const i=66560;this.layoutVertexArray=new cs,this.layoutVertexArray.reserve(i),this.layoutNormalArray=new Ms,this.layoutNormalArray.reserve(i),this.layoutCentroidArray=new Ms,this.layoutCentroidArray.reserve(i),this.layoutColorArray=new us,this.layoutColorArray.reserve(i),this.layoutFloodLightDataArray=new Ll,this.layoutFloodLightDataArray.reserve(i),this.layoutAOArray=new Eu,this.layoutAOArray.reserve(i),this.indexArray=new sn,this.indexArray.reserve(66560),this.indexArrayForConflation=new sn,this.segmentsBucket=new Fi,this.entranceBloom=new Dx,e&&(this.layoutFacadePaintArray=new us,this.layoutFacadeDataArray=new Cc,this.layoutFacadeVerticalRangeArray=new us)}reserve(e,i,o){this.layoutVertexArray.reserveForAdditional(e),this.layoutCentroidArray.reserveForAdditional(e),this.layoutFloodLightDataArray.reserveForAdditional(e),this.layoutNormalArray.reserveForAdditional(e),this.layoutAOArray.reserveForAdditional(e),this.layoutColorArray.reserveForAdditional(e),this.indexArray.reserveForAdditional(i),o&&(this.layoutFacadePaintArray.reserveForAdditional(e),this.layoutFacadeDataArray.reserveForAdditional(e),this.layoutFacadeVerticalRangeArray.reserveForAdditional(e))}}class O0{constructor(e){this.requiresHDRuntime=!0,this.colorBufferUploaded=!1,this.maxHeight=0,this.replacementUpdateTime=0,this.activeReplacements=[],this.footprints=[],this.footprintsVertices=new xo,this.footprintsIndices=new Qh,this.footprintsMin=new Ue(1/0,1/0),this.footprintsMax=new Ue(-1/0,-1/0),this.featuresOnBorder=[],this.buildingWithoutFacade=new Lx(!1),this.buildingWithFacade=new Lx(!0),this.indexArrayForConflationUploaded=!1,this.featureFootprintLookup=new Map,this.buildingIds=new Set,this.footprintLookup={},this.zoom=e.zoom,this.canonical=e.canonical,this.layers=e.layers,this.layerIds=this.layers.map(i=>i.fqid),this.index=e.index,this.hasPattern=!1,this.worldview=e.worldview,this.lut=e.lut,this.programConfigurations=new hs(e.layers,{zoom:e.zoom,lut:e.lut}),this.stateDependentLayerIds=this.layers.filter(i=>i.isStateDependent()).map(i=>i.id),this.projection=e.projection,this.groundEffect=new Mx(e),this.groundEffect.groundRadiusArray=new Js,this.hasAppearances=null}updateFootprints(e,i){const o=new ug([],[],1),a={vertices:[],indices:new Uint32Array(0),grid:o,min:this.footprintsMin,max:this.footprintsMax,buildingIds:this.buildingIds};i.push({footprint:a,id:e})}updateAppearances(e,i,o,a){return{hasLayoutChanges:!1,hasUboChanges:!1}}populate(e,i,o,a){if(!Ds)return;const c=yo(o);this.tileToMeter=c,this.brightness=i.brightness,Ds.setStyle({normalScale:[1,-1,c],tileToMeters:c}),Ds.setAOOptions(!1,.3),Ds.setMetricOptions(!1,16),Ds.setStructuralOptions(!0),Ds.setFacadeClassifierOptions(3);const h=new Map,f=new Map;let _=0;for(const{feature:R}of e){if(D0[R.type]!=="LineString"){h.set(R.id,R.properties.source_id);continue}const z=this.layers[0]._featureFilter.needGeometry;if(z&&!this.layers[0]._featureFilter.filter(new xt(this.zoom),R,o))continue;const V=Vo(R,z);if(!z&&!this.layers[0]._featureFilter.filter(new xt(this.zoom),V,o))continue;const N=z?V.geometry:ls(R,o,a),U=[];for(const X of N)for(const ie of X)U.push(ie.x),U.push(ie.y);const q={coordinates:U,crossPerc:R.properties.cross_perc,distanceToRoad:R.properties.distance_to_road,entrances:R.properties.entrances,sourceId:0},W=R.properties.source_id;let se=f.get(W);se||(se=[],f.set(W,se)),se.push(q),++_}this.maxHeight=0;const y=new Array,v=new Set,b=R=>{R!=null&&v.add(R)},T=(R,z)=>{R!=null&&y.push({buildingId:R,footprintIndex:z})},E=64*(e.length-_),C=E/2;this.buildingWithFacade.reserve(E,C,!0),this.buildingWithoutFacade.reserve(2*E,2*C,!1),this.footprintsIndices.reserve(16*(e.length-_)),this.footprintsVertices.reserve(8*(e.length-_));for(const{feature:R,id:z,index:V,sourceLayerIndex:N}of e){if(D0[R.type]==="LineString")continue;const U=this.layers[0]._featureFilter.needGeometry;if(U&&!this.layers[0]._featureFilter.filter(new xt(this.zoom),R,o))continue;let q=null;if(R.properties&&Object.hasOwn(R.properties,"building_id")&&(q=Number(R.properties.building_id),v.has(q)))continue;const W=Vo(R,U);if(!U&&!this.layers[0]._featureFilter.filter(new xt(this.zoom),W,o))continue;const se=U?W.geometry:ls(R,o,a),X=Ro(se,500);let ie=!1;for(const Ft of X)if(Ft.length!==1){ie=!0;break}if(ie){b(q);continue}if(!mT(se,163)){b(q);continue}const re=this.layers[0],oe=_T(re.layout.get("building-roof-shape").evaluate(R,{},o)),me=re.layout.get("building-base").evaluate(R,{},o),xe=re.layout.get("building-height").evaluate(R,{},o),we=re.layout.get("building-flood-light-ground-radius").evaluate(R,{},o),Ce=re.paint.get("building-ambient-occlusion-intensity"),Se=we/this.tileToMeter;R.properties["building-part"]="roof";const qe=re.paint.get("building-color").evaluate(R,{},this.canonical).toPremultipliedRenderColor(this.lut),Me=re.paint.get("building-emissive-strength").evaluate(R,{},this.canonical);R.properties["building-part"]="wall";const Ie=re.paint.get("building-color").evaluate(R,{},this.canonical).toPremultipliedRenderColor(this.lut),Pe=re.paint.get("building-emissive-strength").evaluate(R,{},this.canonical);R.properties["building-part"]="window";const Ne=re.paint.get("building-color").evaluate(R,{},this.canonical).toPremultipliedRenderColor(this.lut),ke=re.paint.get("building-emissive-strength").evaluate(R,{},this.canonical);R.properties["building-part"]="door";const $e=re.paint.get("building-color").evaluate(R,{},this.canonical).toPremultipliedRenderColor(this.lut),ze=re.paint.get("building-emissive-strength").evaluate(R,{},this.canonical);let He=re.layout.get("building-flood-light-wall-radius").evaluate(R,{},o);He=Y(He,0,2048);const Ye=He/2048*Eg,st=h.get(z),Je=f.get(st)||[],Qe=Je.length!==0&&re.layout.get("building-facade").evaluate(R,{},o);Ds.setFacadeOptions(4,!0),Ds.setFauxFacadeOptions(Qe,!1,1);let dt=0,wt=0,Bt=0,lt=0,Et=0,Rt=0,ki=0,qt=0,ni=0,_i=0,$i=0;if(Qe){let Ft=Math.round(re.layout.get("building-facade-floors").evaluate(R,{},o));if(me===0){Ft=Math.max(1,Ft-(Je.length>0?1:0));let cr=4;if(xe>100){const Nr=[10,13,15];cr=Nr[R.id?R.id%Nr.length:0]}else xe<=10&&(cr=3);Ds.setFacadeOptions(cr,!0),Et=(xe<15?1.3:1.61803)*cr/c}else Et=me/c;Rt=xe/c,Et=Math.min(Et,Rt),Bt=re.layout.get("building-facade-unit-width").evaluate(R,{},o)/c,lt=(Rt-Et)/Ft,Ds.setFauxFacadeOptions(!0,!0,Bt);const Dr=re.layout.get("building-facade-window").evaluate(R,{},o);dt=Dr[0],wt=Dr[1],ki=Math.floor(65535*Math.min(1,Et/rt)),qt=Math.floor(65535*Math.min(1,Rt/rt)),ni=Math.floor(255*dt)<<8|Math.floor(255*wt),_i=Math.floor(65535*Math.min(1,Bt/rt)),$i=Math.floor(65535*Math.min(1,lt/rt))}const Ir=Array(X.length),gi={x:1/0,y:1/0},Ri={x:-1/0,y:-1/0},mr={x:0,y:0};let ln=0;for(let Ft=0;Ft<X.length;Ft++){const Dr=X[Ft];if(Dr.length>0){const cr=[],Nr=Array(Dr.length+1);Nr[0]=0;for(let zs=0;zs<Dr.length;zs++){const Zo=Dr[zs];for(let ds=0;ds<Zo.length;ds++){const fs=Zo[Zo.length-ds-1];gi.x=Math.min(gi.x,fs.x),gi.y=Math.min(gi.y,fs.y),Ri.x=Math.max(Ri.x,fs.x),Ri.y=Math.max(Ri.y,fs.y),mr.x+=fs.x,mr.y+=fs.y,ln++,cr.push(fs.x),cr.push(fs.y)}Nr[zs+1]=cr.length}Ir[Ft]={id:R.id?R.id:0,height:xe,minHeight:me,sourceId:0,roofType:oe,coordinates:cr,ringIndices:Nr}}}mr.x/=ln||1,mr.y/=ln||1;const hr=Ds.generateMesh(Ir,Je);if(typeof hr=="string"){ht(`Unable to generate building ${R.id}: ${hr}`),b(q);continue}if(hr.meshes.length===0||hr.modifiedPolygonRings.length===0){b(q);continue}const zt=Qe?this.buildingWithFacade:this.buildingWithoutFacade;let yr=0;for(const Ft of hr.meshes)yr+=Ft.positions.length/3;const Tn=zt.segmentsBucket.prepareSegment(yr,zt.layoutVertexArray,zt.indexArray),Zr=[];let Wr=null,er=0,Bi=-1;const Di=zt.layoutVertexArray.length,vr=Di+yr;zt.layoutVertexArray.resize(vr),zt.layoutCentroidArray.resize(vr),zt.layoutNormalArray.resize(vr),zt.layoutAOArray.resize(vr),zt.layoutColorArray.resize(vr),zt.layoutFloodLightDataArray.resize(vr),Qe&&(zt.layoutFacadePaintArray.resize(vr),zt.layoutFacadeDataArray.resize(vr),zt.layoutFacadeVerticalRangeArray.resize(vr));const Rr=zt.indexArray.length;let Kn=0,An=Di;for(const Ft of hr.meshes){let Dr,cr;if(Ft.buildingPart===1)Dr=qe,cr=Me;else if(Ft.buildingPart===0)Dr=Ie,cr=Pe;else if(Ft.buildingPart===2)Dr=Ne,cr=ke;else{if(Ft.buildingPart!==3)continue;Dr=$e,cr=ze}if(cr=Y(cr,0,1),Ft.buildingPart===3){const Vr=new Array;for(let Bn=0;Bn<Ft.positions.length;Bn+=12){const Wo=Ft.positions[Bn+0],Sa=Ft.positions[Bn+1],Dd=Ft.positions[Bn+3],lo=Ft.positions[Bn+4],ms=Ft.positions[Bn+2],Ea=Ft.positions[Bn+8]-ms,ql=1,Xp=Dd-Wo,Yp=lo-Sa,Kp=Math.hypot(Xp,Yp);Vr.push({pos:[Wo+.5*Xp,Sa+.5*Yp,ms],normal:[Yp/Kp,-Xp/Kp,0],width:Kp,height:Ea,depth:ql,points:[Wo,Sa,Dd,lo]})}const Lr=zt.entranceBloom.segmentsBucket.prepareSegment(10*Vr.length,zt.entranceBloom.layoutVertexArray,zt.entranceBloom.indexArray),Ur=zt.entranceBloom.layoutVertexArray.length;er=zt.entranceBloom.indexArray.length,x0(Vr,.5/this.tileToMeter,zt.entranceBloom.indexArray,zt.entranceBloom.layoutVertexArray,zt.entranceBloom.layoutAttenuationArray);const ps=zt.entranceBloom.layoutVertexArray.length-Ur;Bi=zt.entranceBloom.indexArray.length-er;for(let Bn=0;Bn<ps;Bn++)zt.entranceBloom.layoutColorArray.emplaceBack(255*$e.r<<8|255*$e.g,255*$e.b<<8|51*ze);Lr.vertexLength+=ps,Lr.primitiveLength+=Bi,Wr={part:Ft.buildingPart,vertexOffset:Ur,vertexLength:ps}}zt.layoutVertexArray.float32.set(Ft.positions,3*An);const Nr=Ft.positions.length/3;for(let Vr=0;Vr<Nr;++Vr){const Lr=3*Vr;Kn=Math.max(Kn,Ft.positions[Lr+2]);const Ur=Ft.normals[Lr+1]*Eg,ps=Ft.normals[Lr+2]*Eg,Bn=3*(An+Vr);zt.layoutNormalArray.int16[Bn]=Ft.normals[Lr]*Eg,zt.layoutNormalArray.int16[Bn+1]=Ur,zt.layoutNormalArray.int16[Bn+2]=ps;const Wo=Ft.ao[Vr];zt.layoutAOArray.uint8[An+Vr]=255*Wo;const Sa=1+(Wo-1)*Ce,Dd=255*Dr.b*Sa<<8|255*cr;zt.layoutColorArray.uint16[2*(An+Vr)]=255*Dr.r*Sa<<8|255*Dr.g*Sa,zt.layoutColorArray.uint16[2*(An+Vr)+1]=Dd}const zs=Math.min(8191,Math.max(0,Math.floor(mr.x))),Zo=Math.min(8191,Math.max(0,Math.floor(mr.y))),ds=Math.floor(xe),fs=20,Bg=4*zs+Math.min(3,Math.round((Ri.x-gi.x)*this.tileToMeter/fs)),Ng=4*Zo+Math.min(3,Math.round((Ri.y-gi.y)*this.tileToMeter/fs));for(let Vr=0;Vr<Nr;++Vr){const Lr=3*(An+Vr);zt.layoutCentroidArray.int16[Lr]=Bg,zt.layoutCentroidArray.int16[Lr+1]=Ng,zt.layoutCentroidArray.int16[Lr+2]=ds}if(zt.layoutFloodLightDataArray.int16.fill(Ft.buildingPart===0?Ye:0,An,An+Nr),Qe){const Vr=255*Ne.r<<8|255*Ne.g,Lr=255*Ne.b<<8|255*ke;for(let Ur=0;Ur<Nr;++Ur){const ps=2*(An+Ur);zt.layoutFacadePaintArray.uint16[ps]=Vr,zt.layoutFacadePaintArray.uint16[ps+1]=Lr}for(let Ur=0;Ur<Nr;++Ur)if(Ft.isFauxFacade[Ur]){const ps=Math.min(65535,Math.floor(Ft.uv[2*Ur]*hr.outerRingLength));zt.layoutFacadeDataArray.emplace(An+Ur,1|ps,ni,_i,$i),zt.layoutFacadeVerticalRangeArray.emplace(An+Ur,ki,qt)}else zt.layoutFacadeDataArray.emplace(An+Ur,0,0,0,0),zt.layoutFacadeVerticalRangeArray.emplace(An+Ur,0,0)}const qu=Tn.vertexLength,Rd=Ft.indices.length/3,Fs=zt.indexArray.length;zt.indexArray.resize(Fs+Rd);for(let Vr=0;Vr<Rd;++Vr){const Lr=3*Vr,Ur=3*Fs+Lr;zt.indexArray.uint16[Ur]=qu+Ft.indices[Lr],zt.indexArray.uint16[Ur+1]=qu+Ft.indices[Lr+1],zt.indexArray.uint16[Ur+2]=qu+Ft.indices[Lr+2]}Ft.buildingPart!==1&&Ft.buildingPart!==0&&Ft.buildingPart!==2&&Ft.buildingPart!==3||Zr.push({part:Ft.buildingPart,vertexOffset:An,vertexLength:Ft.positions.length/3}),An+=Nr,Tn.vertexLength+=Nr,Tn.primitiveLength+=Ft.indices.length/3}this.maxHeight=Math.max(this.maxHeight,Kn);const Fg=zt.indexArray.length-Rr,Wp=this.footprintsIndices.length,Og=this.footprintsVertices.length,kg=[],Gl=new Ue(1/0,1/0),il=new Ue(-1/0,-1/0),$l=this.groundEffect.vertexArray.length;for(const Ft of hr.modifiedPolygonRings){const Dr=[],cr=new Ue(1/0,1/0),Nr=new Ue(-1/0,-1/0);for(let zs=0;zs<Ft.length;zs+=2){const Zo=Ft.length-zs-2;cr.x=Math.min(cr.x,Ft[Zo]),cr.y=Math.min(cr.y,Ft[Zo+1]),Nr.x=Math.max(Nr.x,Ft[Zo]),Nr.y=Math.max(Nr.y,Ft[Zo+1]);const ds=new Ue(Ft[Zo],Ft[Zo+1]);Dr.push(ds),kg.push(ds.x,ds.y),this.footprintsVertices.emplaceBack(ds.x,ds.y)}Gl.x=Math.min(Gl.x,cr.x),Gl.y=Math.min(Gl.y,cr.y),il.x=Math.max(il.x,Nr.x),il.y=Math.max(il.y,Nr.y),this.groundEffect.addData(Dr,[cr,Nr],Se)}const rl=this.groundEffect.vertexArray.length-$l;this.groundEffect.groundRadiusArray.reserveForAdditional(rl);for(let Ft=0;Ft<rl;Ft++)this.groundEffect.groundRadiusArray.emplaceBack(we);(gi.x<0||Ri.x>rt||gi.y<0||Ri.y>rt)&&this.featuresOnBorder.push({featureId:R.id,footprintIndex:this.footprints.length});{const Ft=Sc(kg,null,2);this.footprintsIndices.resize(this.footprintsIndices.length+Ft.length),this.footprintsIndices.uint16.set(Ft,Wp),this.buildingIds.add(q??R.id),this.footprintsMin.x=Math.min(this.footprintsMin.x,Gl.x),this.footprintsMin.y=Math.min(this.footprintsMin.y,Gl.y),this.footprintsMax.x=Math.max(this.footprintsMax.x,il.x),this.footprintsMax.y=Math.max(this.footprintsMax.y,il.y);const Dr={footprintVertexOffset:Og,footprintVertexLength:this.footprintsVertices.length-Og,footprintIndexOffset:Wp,footprintIndexLength:this.footprintsIndices.length-Wp,min:Gl,max:il,hiddenFlags:0,indicesOffset:Rr,indicesLength:Fg,bloomIndicesOffset:er,bloomIndicesLength:Bi,groundEffectVertexOffset:$l,groundEffectVertexLength:rl,hasFauxFacade:Qe,height:Kn,promoteId:z,feature:W,parts:Zr,buildingBloom:Wr},cr=this.footprints.length;R.id!==void 0&&this.featureFootprintLookup.set(R.id,cr),T(q,cr),this.footprints.push(Dr)}this.programConfigurations.populatePaintArrays(zt.layoutVertexArray.length,R,V,{},i.availableImages,o,i.brightness),this.groundEffect.addPaintPropertiesData(R,V,{},i.availableImages,o,i.brightness),i.featureIndex.insert(R,se,V,N,this.index,Di)}y.forEach(({buildingId:R,footprintIndex:z})=>{v.has(R)&&(this.footprints[z].hiddenFlags|=4)});const P=new Set;this.buildingIds.forEach((R,z,V)=>{v.has(R)||P.add(R)}),this.buildingIds=P,this.groundEffect.prepareBorderSegments()}update(e,i,o,a,c,h,f){this.programConfigurations.updatePaintArrays(e,i,c,o,a,h,f),this.groundEffect.update(e,i,c,o,a,h,f),this.evaluate(this.layers[0],e),this.colorBufferUploaded=!1}updateExpressions(e){this.programConfigurations.updateExpressions(e),this.groundEffect.programConfigurations.updateExpressions(e)}isEmpty(){return this.buildingWithoutFacade.layoutVertexArray.length===0&&this.buildingWithFacade.layoutVertexArray.length===0}uploadPending(){return!this.uploaded||this.programConfigurations.needsUpload||this.groundEffect.programConfigurations.needsUpload}upload(e){const i=o=>{o.layoutVertexBuffer=e.createVertexBuffer(o.layoutVertexArray,v0.members),o.layoutNormalBuffer=e.createVertexBuffer(o.layoutNormalArray,$w.members),o.layoutCentroidBuffer=e.createVertexBuffer(o.layoutCentroidArray,qw.members),o.layoutFloodLightDataBuffer=e.createVertexBuffer(o.layoutFloodLightDataArray,Yw.members),o.layoutFacadeDataArray&&o.layoutFacadeDataArray.length&&(o.layoutFacadeDataBuffer=e.createVertexBuffer(o.layoutFacadeDataArray,Zw.members)),o.layoutFacadeVerticalRangeArray&&o.layoutFacadeVerticalRangeArray.length&&(o.layoutFacadeVerticalRangeBuffer=e.createVertexBuffer(o.layoutFacadeVerticalRangeArray,Ww.members)),o.entranceBloom.layoutVertexArray.length&&(o.entranceBloom.layoutVertexBuffer=e.createVertexBuffer(o.entranceBloom.layoutVertexArray,v0.members),o.entranceBloom.layoutAttenuationBuffer=e.createVertexBuffer(o.entranceBloom.layoutAttenuationArray,Xw.members)),this.uploadUpdatedColorBuffer(e),this.uploadUpdatedIndexBuffer(e)};this.uploaded||(i(this.buildingWithoutFacade),i(this.buildingWithFacade),this.groundEffect.upload(e)),this.groundEffect.uploadPaintProperties(e),this.programConfigurations.upload(e),this.uploaded=!0}destroy(){const e=i=>{i.layoutVertexBuffer&&(i.layoutVertexBuffer.destroy(),i.layoutNormalBuffer.destroy(),i.layoutColorBuffer.destroy(),i.segmentsBucket.destroy(),i.indexBuffer&&i.indexBuffer.destroy(),i.entranceBloom.layoutVertexBuffer&&(i.entranceBloom.layoutVertexBuffer.destroy(),i.entranceBloom.layoutColorBuffer.destroy(),i.entranceBloom.layoutAttenuationBuffer.destroy(),i.entranceBloom.indexBuffer.destroy(),i.entranceBloom.segmentsBucket.destroy()))};e(this.buildingWithoutFacade),e(this.buildingWithFacade),this.groundEffect.destroy(),this.programConfigurations.destroy()}updateFootprintHiddenFlags(e,i,o=!0){let a=!1;const c=o?i:0,h=0|(o?-1:~i);this.groundEffect.hiddenByLandmarkVertexArray.length===0&&this.groundEffect.hiddenByLandmarkVertexArray.resize(this.groundEffect.vertexArray.length);for(const f of e){const _=this.footprints[f],y=_.hiddenFlags&h|c;_.hiddenFlags!==y&&(_.hiddenFlags=y,a=!0,this.groundEffect.updateHiddenByLandmarkRange(_.groundEffectVertexOffset,_.groundEffectVertexLength,_.hiddenFlags!==0))}return a&&(this.indexArrayForConflationUploaded=!1),a}uploadUpdatedIndexBuffer(e){if(this.groundEffect.uploadHiddenByLandmark(e),this.indexArrayForConflationUploaded)return;const i=a=>{a.indexArray.length!==0&&(a.indexArrayForConflation.resize(a.indexArray.length),a.indexArrayForConflation.uint16.set(a.indexArray.uint16),a.entranceBloom.indexArrayForConflation.resize(a.entranceBloom.indexArray.length),a.entranceBloom.indexArrayForConflation.uint16.set(a.entranceBloom.indexArray.uint16))};i(this.buildingWithoutFacade),i(this.buildingWithFacade);for(const a of this.footprints){const c=a.hasFauxFacade?this.buildingWithFacade:this.buildingWithoutFacade,h=a.indicesOffset+a.indicesLength;if(a.hiddenFlags!==0){for(let _=a.indicesOffset;_<h;_++)c.indexArrayForConflation.uint16[3*_+0]=0,c.indexArrayForConflation.uint16[3*_+1]=0,c.indexArrayForConflation.uint16[3*_+2]=0;const f=a.bloomIndicesOffset+a.bloomIndicesLength;for(let _=a.bloomIndicesOffset;_<f;_++)c.entranceBloom.indexArrayForConflation.uint16[3*_+0]=0,c.entranceBloom.indexArrayForConflation.uint16[3*_+1]=0,c.entranceBloom.indexArrayForConflation.uint16[3*_+2]=0}}const o=a=>{a.indexArray.length!==0&&(a.indexBuffer?a.indexBuffer.updateData(a.indexArrayForConflation):a.indexBuffer=e.createIndexBuffer(a.indexArrayForConflation,!0),a.entranceBloom.indexBuffer?a.entranceBloom.indexBuffer.updateData(a.entranceBloom.indexArrayForConflation):a.entranceBloom.indexBuffer=e.createIndexBuffer(a.entranceBloom.indexArrayForConflation,!0))};o(this.buildingWithoutFacade),o(this.buildingWithFacade),this.indexArrayForConflationUploaded=!0}uploadUpdatedColorBuffer(e){const i=o=>{o.layoutColorBuffer?o.layoutColorBuffer.updateData(o.layoutColorArray):o.layoutColorBuffer=e.createVertexBuffer(o.layoutColorArray,b0.members,!0),o.layoutFacadePaintArray&&(o.layoutFacadePaintBuffer?o.layoutFacadePaintBuffer.updateData(o.layoutFacadePaintArray):o.layoutFacadePaintBuffer=e.createVertexBuffer(o.layoutFacadePaintArray,Hw.members,!0)),o.entranceBloom.layoutColorBuffer?o.entranceBloom.layoutColorBuffer.updateData(o.entranceBloom.layoutColorArray):o.entranceBloom.layoutColorBuffer=e.createVertexBuffer(o.entranceBloom.layoutColorArray,b0.members,!0)};i(this.buildingWithoutFacade),i(this.buildingWithFacade),this.colorBufferUploaded=!0}evaluate(e,i){const o=e.paint.get("building-ambient-occlusion-intensity");for(const a of this.footprints){if(4&a.hiddenFlags)continue;const c=i[a.promoteId],h=a.feature;h.properties["building-part"]="roof";const f=e.paint.get("building-color").evaluate(h,c,this.canonical).toPremultipliedRenderColor(this.lut),_=e.paint.get("building-emissive-strength").evaluate(h,c,this.canonical);h.properties["building-part"]="wall";const y=e.paint.get("building-color").evaluate(h,c,this.canonical).toPremultipliedRenderColor(this.lut),v=e.paint.get("building-emissive-strength").evaluate(h,c,this.canonical);h.properties["building-part"]="window";const b=e.paint.get("building-color").evaluate(h,c,this.canonical).toPremultipliedRenderColor(this.lut),T=e.paint.get("building-emissive-strength").evaluate(h,c,this.canonical);h.properties["building-part"]="door";const E=e.paint.get("building-color").evaluate(h,c,this.canonical).toPremultipliedRenderColor(this.lut),C=e.paint.get("building-emissive-strength").evaluate(h,c,this.canonical),P=a.hasFauxFacade?this.buildingWithFacade:this.buildingWithoutFacade;for(const z of a.parts){let V,N=f;z.part===1?(N=f,V=_):z.part===0?(N=y,V=v):z.part===2?(N=b,V=T):z.part===3&&(N=E,V=C),V=Y(V,0,1);for(let U=0;U<z.vertexLength;U++){const q=z.vertexOffset+U,W=1+(P.layoutAOArray.uint8[q]/255-1)*o;P.layoutColorArray.emplace(q,N.r*W*255<<8|N.g*W*255,N.b*W*255<<8|255*V),a.hasFauxFacade&&P.layoutFacadePaintArray.emplace(q,255*b.r<<8|255*b.g,255*b.b<<8|255*T)}}const R=a.buildingBloom;if(R)for(let z=0;z<R.vertexLength;z++)P.entranceBloom.layoutColorArray.emplace(R.vertexOffset+z,255*E.r<<8|255*E.g,255*E.b<<8|51*C)}}needsEvaluation(){return!this.colorBufferUploaded}updateReplacement(e,i,o){if(i.updateTime===this.replacementUpdateTime)return;this.replacementUpdateTime=i.updateTime;const a=i.getReplacementRegionsForTile(e.toUnwrapped());if(K_(this.activeReplacements,a))return;this.activeReplacements=a;for(const h of this.footprints)h.hiddenFlags&=-2;const c=[];for(const h of this.activeReplacements){if(h.order<o)continue;const f=Math.max(1,Math.pow(2,h.footprintTileId.canonical.z-e.canonical.z));for(const _ of this.footprints)_.min.x>h.max.x||_.max.x<h.min.x||_.min.y>h.max.y||_.max.y<h.min.y||(c.length=0,yT(this.footprintsVertices,_.footprintVertexOffset,_.footprintVertexLength,h.footprintTileId.canonical,e.canonical,c),rx(h.footprint,c,this.footprintsIndices.uint16,_.footprintIndexOffset,_.footprintIndexLength,0,-f)&&(_.hiddenFlags|=1))}this.groundEffect.hiddenByLandmarkVertexArray.length===0&&this.groundEffect.hiddenByLandmarkVertexArray.resize(this.groundEffect.vertexArray.length);for(const h of this.footprints)this.groundEffect.updateHiddenByLandmarkRange(h.groundEffectVertexOffset,h.groundEffectVertexLength,h.hiddenFlags!==0);this.indexArrayForConflationUploaded=!1}getFootprint(e){if(e.id!==void 0){const i=this.featureFootprintLookup.get(e.id);return this.footprints[i]}return null}getHeightAtTileCoord(e,i){let o=Number.NEGATIVE_INFINITY,a=!0;const c=4*(e+rt)*rt+(i+rt);if(Object.hasOwn(this.footprintLookup,c)){const f=this.footprintLookup[c];return f?{height:f.height,hidden:f.hiddenFlags!==0}:void 0}const h=new Ue(e,i);for(const f of this.footprints)e>f.max.x||f.min.x>e||i>f.max.y||f.min.y>i||f.height<=o||gT(h,this.footprintsVertices.float32.subarray(2*f.footprintVertexOffset,2*(f.footprintVertexOffset+f.footprintVertexLength)),this.footprintsIndices.uint16.subarray(f.footprintIndexOffset,f.footprintIndexOffset+f.footprintIndexLength))&&(o=f.height,this.footprintLookup[c]=f,a=f.hiddenFlags!==0);if(o!==Number.NEGATIVE_INFINITY)return{height:o,hidden:a};this.footprintLookup[c]=void 0}}function gT(r,e,i){for(let o=0;o<i.length;o+=3){const a=i[o],c=i[o+1],h=i[o+2],f=e[2*a+0],_=e[2*a+1],y=e[2*c+0],v=e[2*c+1],b=e[2*h+0],T=e[2*h+1],E=(f-b)*(r.y-T)-(_-T)*(r.x-b),C=(y-f)*(r.y-_)-(v-_)*(r.x-f);if(E<0!=C<0&&E!==0&&C!==0)continue;const P=(b-y)*(r.y-v)-(T-v)*(r.x-y);if(P===0||P<0==E+C<=0)return!0}return!1}function yT(r,e,i,o,a,c){const h=Math.pow(2,o.z-a.z);for(let f=0;f<i;f++){let _=r.float32[2*(f+e)+0],y=r.float32[2*(f+e)+1];_=(_+a.x*rt)*h-o.x*rt,y=(y+a.y*rt)*h-o.y*rt,c.push(new Ue(_,y))}}nt(O0,"BuildingBucket",{omit:["layers"]}),nt(Lx,"BuildingGeometry"),nt(Dx,"BuildingBloomGeometry");class k0{constructor(e=0,i=[]){this.frcMask=e,this.rings=i}hasGeometry(){return this.rings.length>0&&this.rings[0].length>0}}async function Ig(){}function Cd(r,e,i){const o=e.paint.get(r).value;return o.kind==="constant"?o.value:i.programConfigurations.get(e.id).getMaxValue(r)}function Ag(r){return Math.sqrt(r[0]*r[0]+r[1]*r[1])}function B0(r,e,i,o,a){if(!e[0]&&!e[1])return r;const c=Ue.convert(e)._mult(a);i==="viewport"&&c._rotate(-o);const h=[];for(let f=0;f<r.length;f++)h.push(r[f].sub(c));return h}function N0(r,e,i,o){const a=Ue.convert(r)._mult(o);return e==="viewport"&&a._rotate(-i),a}nt(k0,"FrcCoveragePolygon");const xT=mn(),V0=r=>{const e=[];return r.paint.get("circle-pitch-alignment")==="map"&&e.push("PITCH_WITH_MAP"),r.paint.get("circle-pitch-scale")==="map"&&e.push("SCALE_WITH_MAP"),e};function U0(r,e,i,o,a,c,h,f,_){if(c&&r.queryGeometry.isAboveHorizon)return!1;c&&(_*=r.pixelToTileUnitsFactor);const y=r.tileID.canonical,v=i.projection.upVectorScale(y,i.center.lat,i.worldSize).metersToTile;for(const b of e)for(const T of b){const E=T.add(f),C=a&&i.elevation?i.elevation.exaggeration()*a.getElevationAt(E.x,E.y,!0):0,P=i.projection.projectTilePoint(E.x,E.y,y);if(C>0){const N=i.projection.upVector(y,E.x,E.y);P.x+=N[0]*v*C,P.y+=N[1]*v*C,P.z+=N[2]*v*C}const R=c?E:vT(P.x,P.y,P.z,o),z=c?r.tilespaceRays.map(N=>wT(N,C)):r.queryGeometry.screenGeometry,V=Ln([],[P.x,P.y,P.z,1],o);if(!h&&c?_*=V[3]/i.cameraToCenterDistance:h&&!c&&(_*=i.cameraToCenterDistance/V[3]),c){const N=on((T.y/rt+y.y)/(1<<y.z));_/=i.projection.pixelsPerMeter(N,1)/Wn(1,N)}if(Sy(z,R,_))return!0}return!1}function vT(r,e,i,o){const a=Ln([],[r,e,i,1],o);return new Ue(a[0]/a[3],a[1]/a[3])}const j0=ur(0,0,0),bT=ur(0,0,1);function wT(r,e){const i=Zt();return j0[2]=e,r.intersectsPlane(j0,bT,i),new Ue(i[0],i[1])}class G0 extends Ou{}let $0,q0,H0,Z0,W0,X0,Y0,K0,J0,Q0,eb,tb,ib,rb;function Vp(r){const e={},i=r.resolution||256,o=r.clips?r.clips.length:1,a=r.image||new bn({width:i,height:o}),c=r.lut||null,h=(f,_,y)=>{e[r.evaluationKey]=y;const v=r.expression.evaluate(e),b=v?v.toNonPremultipliedRenderColor(c):null;b&&(a.data[f+_+0]=Math.floor(255*b.r),a.data[f+_+1]=Math.floor(255*b.g),a.data[f+_+2]=Math.floor(255*b.b),a.data[f+_+3]=Math.floor(255*b.a))};if(r.clips)for(let f=0,_=0;f<o;++f,_+=4*i)for(let y=0,v=0;y<i;y++,v+=4){const b=y/(i-1),{start:T,end:E}=r.clips[f];h(_,v,vt(T,E,b))}else for(let f=0,_=0;f<i;f++,_+=4)h(0,_,f/(i-1));return a}nt(G0,"HeatmapBucket",{omit:["layers"]});class nb{constructor(e){this.zoom=e.zoom,this.layers=e.layers,this.layerIds=this.layers.map(i=>i.fqid),this.index=e.index,this.hasPattern=!1,this.stateDependentLayerIds=this.layers.filter(i=>i.isStateDependent()).map(i=>i.id),this.footprints=[],this.worldview=e.worldview,this.hasAppearances=null}updateFootprints(e,i){for(const o of this.footprints)i.push({footprint:o,id:e})}updateAppearances(e,i,o,a){return{hasLayoutChanges:!1,hasUboChanges:!1}}populate(e,i,o,a){const c=[];for(const{feature:h,id:f,index:_,sourceLayerIndex:y}of e){const v=this.layers[0]._featureFilter.needGeometry,b=Vo(h,v);if(!this.layers[0]._featureFilter.filter(new xt(this.zoom,{worldview:this.worldview,activeFloors:i.activeFloors}),b,o))continue;const T={id:f,properties:h.properties,type:h.type,sourceLayerIndex:y,index:_,geometry:v?b.geometry:ls(h,o,a),patterns:{}};c.push(T)}for(const h of c){const{geometry:f,index:_,sourceLayerIndex:y}=h;this.addFeature(h,f,_,o,{},i.availableImages,i.brightness),i.featureIndex.insert(e[_].feature,f,_,y,this.index)}}isEmpty(){return this.footprints.length===0}uploadPending(){return!1}upload(e){}update(e,i,o,a,c,h,f){}destroy(){}addFeature(e,i,o,a,c,h=[],f){for(const _ of Ro(i,2)){const y=[],v=[],b=[],T=new Ue(1/0,1/0),E=new Ue(-1/0,-1/0);for(const R of _)if(R.length!==0){R!==_[0]&&b.push(v.length/2);for(let z=0;z<R.length;z++)v.push(R[z].x),v.push(R[z].y),y.push(R[z]),T.x=Math.min(T.x,R[z].x),T.y=Math.min(T.y,R[z].y),E.x=Math.max(E.x,R[z].x),E.y=Math.max(E.y,R[z].y)}const C=Sc(v,b),P=new ug(y,C,8,256);this.footprints.push({vertices:y,indices:C,grid:P,min:T,max:E})}}}function Up(r,e){return r.x*e.x+r.y*e.y}function ob(r,e){if(r.length===1){let i=0;const o=e[i++];let a;for(;!a||o.equals(a);)if(a=e[i++],!a)return 1/0;for(;i<e.length;i++){const c=e[i],h=r[0],f=a.sub(o),_=c.sub(o),y=h.sub(o),v=Up(f,f),b=Up(f,_),T=Up(_,_),E=Up(y,f),C=Up(y,_),P=v*T-b*b,R=(T*E-b*C)/P,z=(v*C-b*E)/P,V=o.z*(1-R-z)+a.z*R+c.z*z;if(isFinite(V))return V}return 1/0}{let i=1/0;for(const o of e)i=Math.min(i,o.z);return i}}function sb(r,e,i){let o=1/0;pp(i,e)&&(o=ob(i,e[0]));for(let a=0;a<e.length;a++){const c=e[a],h=r[a];for(let f=0;f<c.length-1;f++){const _=c[f],y=[_,c[f+1],h[f+1],h[f],_];Lu(i,y)&&(o=Math.min(o,ob(i,y)))}}return o!==1/0&&o}function ab(r,e,i,o,a,c,h,f,_,y,v){return r.projection.name==="globe"?(function(b,T,E,C,P,R,z,V,N,U,q){const W=[],se=[],X=b.projection.upVectorScale(q,b.center.lat,b.worldSize).metersToTile,ie=[0,0,0,1],re=[0,0,0,1],oe=(xe,we,Ce,Se)=>{xe[0]=we,xe[1]=Ce,xe[2]=Se,xe[3]=1},me=P0();E>0&&(E+=me),C+=me;for(const xe of T){const we=[],Ce=[];for(const Se of xe){const qe=Se.x+P.x,Me=Se.y+P.y,Ie=b.projection.projectTilePoint(qe,Me,q),Pe=b.projection.upVector(q,Se.x,Se.y);let Ne=E,ke=C;if(z){const $e=lb(qe,Me,E,C,z,V,N,U);Ne+=$e.base,ke+=$e.top}E!==0?oe(ie,Ie.x+Pe[0]*X*Ne,Ie.y+Pe[1]*X*Ne,Ie.z+Pe[2]*X*Ne):oe(ie,Ie.x,Ie.y,Ie.z),oe(re,Ie.x+Pe[0]*X*ke,Ie.y+Pe[1]*X*ke,Ie.z+Pe[2]*X*ke),ir(ie,ie,R),ir(re,re,R),we.push(new Fl(ie[0],ie[1],ie[2])),Ce.push(new Fl(re[0],re[1],re[2]))}W.push(we),se.push(Ce)}return[W,se]})(r,e,i,o,a,c,h,f,_,y,v):h?(function(b,T,E,C,P,R,z,V,N){const U=[],q=[],W=[0,0,0,1];for(const se of b){const X=[],ie=[];for(const re of se){const oe=re.x+C.x,me=re.y+C.y,xe=lb(oe,me,T,E,R,z,V,N);W[0]=oe,W[1]=me,W[2]=xe.base,W[3]=1,Ln(W,W,P),W[3]=Math.max(W[3],1e-5);const we=new Fl(W[0]/W[3],W[1]/W[3],W[2]/W[3]);W[0]=oe,W[1]=me,W[2]=xe.top,W[3]=1,Ln(W,W,P),W[3]=Math.max(W[3],1e-5);const Ce=new Fl(W[0]/W[3],W[1]/W[3],W[2]/W[3]);X.push(we),ie.push(Ce)}U.push(X),q.push(ie)}return[U,q]})(e,i,o,a,c,h,f,_,y):(function(b,T,E,C,P){const R=[],z=[],V=P[8]*T,N=P[9]*T,U=P[10]*T,q=P[11]*T,W=P[8]*E,se=P[9]*E,X=P[10]*E,ie=P[11]*E;for(const re of b){const oe=[],me=[];for(const xe of re){const we=xe.x+C.x,Ce=xe.y+C.y,Se=P[0]*we+P[4]*Ce+P[12],qe=P[1]*we+P[5]*Ce+P[13],Me=P[2]*we+P[6]*Ce+P[14],Ie=P[3]*we+P[7]*Ce+P[15],Pe=Se+V,Ne=qe+N,ke=Me+U,$e=Math.max(Ie+q,1e-5),ze=Se+W,He=qe+se,Ye=Me+X,st=Math.max(Ie+ie,1e-5);oe.push(new Fl(Pe/$e,Ne/$e,ke/$e)),me.push(new Fl(ze/st,He/st,Ye/st))}R.push(oe),z.push(me)}return[R,z]})(e,i,o,a,c)}function lb(r,e,i,o,a,c,h,f){const _=h*a.getElevationAt(r,e,!0,!0),y=c[0]!==0,v=y?c[1]===0?h*(c[0]/7-450):h*(function(b,T,E){const C=Math.floor(T[0]/8),P=Math.floor(T[1]/8),R=10*(T[0]-8*C),z=10*(T[1]-8*P),V=b.getElevationAt(C,P,!0,!0),N=b.getMeterToDEM(E),U=Math.floor(.5*(R*N-1)),q=Math.floor(.5*(z*N-1)),W=b.tileCoordToPixel(C,P),se=2*U+1,X=2*q+1,ie=(function(Ce,Se,qe,Me,Ie){return[Ce.getElevationAtPixel(Se,qe,!0),Ce.getElevationAtPixel(Se+Ie,qe,!0),Ce.getElevationAtPixel(Se,qe+Ie,!0),Ce.getElevationAtPixel(Se+Me,qe+Ie,!0)]})(b,W.x-U,W.y-q,se,X),re=Math.abs(ie[0]-ie[1]),oe=Math.abs(ie[2]-ie[3]),me=Math.abs(ie[0]-ie[2])+Math.abs(ie[1]-ie[3]),xe=Math.min(.25,.5*N*(re+oe)/se),we=Math.min(.25,.5*N*me/X);return V+Math.max(xe*R,we*z)})(a,c,f):_;return{base:_+(i===0?-1:i),top:y?Math.max(v+o,_+i+2):_+o}}function cb(r,e,i){return e*(rt/(r.tileSize*Math.pow(2,i-r.tileID.overscaledZ)))}function ub(r,e){return 1/cb(r,1,e.tileZoom)}function hb(r,e,i,o){return r.translatePosMatrix(o||e.tileID.projMatrix,e,i.paint.get("line-translate"),i.paint.get("line-translate-anchor"))}nt(nb,"ClipBucket",{omit:["layers"]});const db=r=>{const e=[];fb(r)&&e.push("RENDER_LINE_DASH"),r.paint.get("line-gradient")&&e.push("RENDER_LINE_GRADIENT"),r.paint.get("line-blend-mode")==="multiply"&&e.push("LINE_BLEND_MULTIPLY"),r.paint.get("line-blend-mode")==="additive"&&e.push("LINE_BLEND_ADDITIVE");const i=r.paint.get("line-trim-offset");i[0]===0&&i[1]===0||e.push("RENDER_LINE_TRIM_OFFSET"),r.paint.get("line-border-width").constantOr(1)!==0&&e.push("RENDER_LINE_BORDER");const o=r.layout.get("line-join").constantOr("miter")==="none",a=!!r.paint.get("line-pattern").constantOr(1);return o&&a&&e.push("LINE_JOIN_NONE"),e};function fb(r){const e=r.paint.get("line-dasharray").value;return e.kind!=="constant"||e.value}let zx;const pb=()=>zx||(zx={layout:ib||(ib=new Vi({"line-cap":new Xe(_e.layout_line["line-cap"]),"line-join":new Xe(_e.layout_line["line-join"]),"line-miter-limit":new We(_e.layout_line["line-miter-limit"]),"line-round-limit":new We(_e.layout_line["line-round-limit"]),"line-sort-key":new Xe(_e.layout_line["line-sort-key"]),"line-z-offset":new Xe(_e.layout_line["line-z-offset"]),"line-elevation-reference":new We(_e.layout_line["line-elevation-reference"]),"line-cross-slope":new We(_e.layout_line["line-cross-slope"]),visibility:new We(_e.layout_line.visibility),"line-width-unit":new We(_e.layout_line["line-width-unit"]),"line-elevation-ground-scale":new Xe(_e.layout_line["line-elevation-ground-scale"])})),paint:rb||(rb=new Vi({"line-opacity":new Xe(_e.paint_line["line-opacity"]),"line-color":new Xe(_e.paint_line["line-color"]),"line-translate":new We(_e.paint_line["line-translate"]),"line-translate-anchor":new We(_e.paint_line["line-translate-anchor"]),"line-width":new Xe(_e.paint_line["line-width"]),"line-gap-width":new Xe(_e.paint_line["line-gap-width"]),"line-offset":new Xe(_e.paint_line["line-offset"]),"line-blur":new Xe(_e.paint_line["line-blur"]),"line-dasharray":new Xe(_e.paint_line["line-dasharray"]),"line-pattern":new Xe(_e.paint_line["line-pattern"]),"line-pattern-cross-fade":new We(_e.paint_line["line-pattern-cross-fade"]),"line-gradient":new El(_e.paint_line["line-gradient"]),"line-trim-offset":new We(_e.paint_line["line-trim-offset"]),"line-trim-fade-range":new We(_e.paint_line["line-trim-fade-range"]),"line-trim-color":new We(_e.paint_line["line-trim-color"]),"line-emissive-strength":new Xe(_e.paint_line["line-emissive-strength"]),"line-border-width":new Xe(_e.paint_line["line-border-width"]),"line-border-color":new Xe(_e.paint_line["line-border-color"]),"line-occlusion-opacity":new We(_e.paint_line["line-occlusion-opacity"]),"line-blend-mode":new We(_e.paint_line["line-blend-mode"]),"line-blend-additive-clamp":new We(_e.paint_line["line-blend-additive-clamp"]),"line-color-use-theme":new Xe({type:"string",default:"default","property-type":"data-driven"}),"line-gradient-use-theme":new Xe({type:"string",default:"default","property-type":"data-driven"}),"line-trim-color-use-theme":new Xe({type:"string",default:"default","property-type":"data-driven"}),"line-border-color-use-theme":new Xe({type:"string",default:"default","property-type":"data-driven"})}))},zx);class TT extends Xe{possiblyEvaluate(e,i){return i=new xt(Math.floor(i.zoom),{now:i.now,fadeDuration:i.fadeDuration,transition:i.transition,worldview:i.worldview}),super.possiblyEvaluate(e,i)}evaluate(e,i,o,a){return i={...i,zoom:Math.floor(i.zoom)},super.evaluate(e,i,o,a)}}let jp,mb,_b,Fx;function gb(r,e){return e>0?e+2*r:r}function yb(r,e){return e.replace(/{([^{}]+)}/g,(i,o)=>o in r?String(r[o]):"")}class xb{constructor(e){this.type=e.property.overrides?e.property.overrides.runtimeType:Ra,this.defaultValue=e}evaluate(e){if(e.formattedSection){const i=this.defaultValue.property.overrides;if(i&&i.hasOverride(e.formattedSection))return i.getOverride(e.formattedSection)}return e.feature&&e.featureState?this.defaultValue.evaluate(e.feature,e.featureState):this.defaultValue.property.specification.default}eachChild(e){this.defaultValue.isConstant()||e(this.defaultValue.value._styleExpression.expression)}outputDefined(){return!1}serialize(){return null}}nt(xb,"FormatSectionOverride",{omit:["defaultValue"]});const Ox=()=>Fx||(Fx={layout:mb||(mb=new Vi({"symbol-placement":new We(_e.layout_symbol["symbol-placement"]),"symbol-spacing":new We(_e.layout_symbol["symbol-spacing"]),"symbol-avoid-edges":new We(_e.layout_symbol["symbol-avoid-edges"]),"symbol-sort-key":new Xe(_e.layout_symbol["symbol-sort-key"]),"symbol-z-order":new We(_e.layout_symbol["symbol-z-order"]),"symbol-z-elevate":new We(_e.layout_symbol["symbol-z-elevate"]),"symbol-elevation-reference":new We(_e.layout_symbol["symbol-elevation-reference"]),"icon-allow-overlap":new We(_e.layout_symbol["icon-allow-overlap"]),"icon-ignore-placement":new We(_e.layout_symbol["icon-ignore-placement"]),"icon-optional":new We(_e.layout_symbol["icon-optional"]),"icon-rotation-alignment":new We(_e.layout_symbol["icon-rotation-alignment"]),"icon-size":new Xe(_e.layout_symbol["icon-size"]),"icon-size-scale-range":new We(_e.layout_symbol["icon-size-scale-range"]),"icon-text-fit":new Xe(_e.layout_symbol["icon-text-fit"]),"icon-text-fit-padding":new Xe(_e.layout_symbol["icon-text-fit-padding"]),"icon-image":new Xe(_e.layout_symbol["icon-image"]),"icon-image-use-theme":new We({type:"string",default:"default","property-type":"data-constant"}),"icon-rotate":new Xe(_e.layout_symbol["icon-rotate"]),"icon-padding":new We(_e.layout_symbol["icon-padding"]),"icon-keep-upright":new We(_e.layout_symbol["icon-keep-upright"]),"icon-offset":new Xe(_e.layout_symbol["icon-offset"]),"icon-anchor":new Xe(_e.layout_symbol["icon-anchor"]),"icon-pitch-alignment":new We(_e.layout_symbol["icon-pitch-alignment"]),"text-pitch-alignment":new We(_e.layout_symbol["text-pitch-alignment"]),"text-rotation-alignment":new We(_e.layout_symbol["text-rotation-alignment"]),"text-field":new Xe(_e.layout_symbol["text-field"]),"text-font":new Xe(_e.layout_symbol["text-font"]),"text-size":new Xe(_e.layout_symbol["text-size"]),"text-size-scale-range":new We(_e.layout_symbol["text-size-scale-range"]),"text-max-width":new Xe(_e.layout_symbol["text-max-width"]),"text-line-height":new Xe(_e.layout_symbol["text-line-height"]),"text-letter-spacing":new Xe(_e.layout_symbol["text-letter-spacing"]),"text-justify":new Xe(_e.layout_symbol["text-justify"]),"text-radial-offset":new Xe(_e.layout_symbol["text-radial-offset"]),"text-variable-anchor":new We(_e.layout_symbol["text-variable-anchor"]),"text-anchor":new Xe(_e.layout_symbol["text-anchor"]),"text-max-angle":new We(_e.layout_symbol["text-max-angle"]),"text-writing-mode":new We(_e.layout_symbol["text-writing-mode"]),"text-rotate":new Xe(_e.layout_symbol["text-rotate"]),"text-padding":new We(_e.layout_symbol["text-padding"]),"text-keep-upright":new We(_e.layout_symbol["text-keep-upright"]),"text-transform":new Xe(_e.layout_symbol["text-transform"]),"text-offset":new Xe(_e.layout_symbol["text-offset"]),"text-allow-overlap":new We(_e.layout_symbol["text-allow-overlap"]),"text-ignore-placement":new We(_e.layout_symbol["text-ignore-placement"]),"text-optional":new We(_e.layout_symbol["text-optional"]),visibility:new We(_e.layout_symbol.visibility)})),paint:_b||(_b=new Vi({"icon-opacity":new Xe(_e.paint_symbol["icon-opacity"]),"icon-occlusion-opacity":new Xe(_e.paint_symbol["icon-occlusion-opacity"]),"icon-emissive-strength":new Xe(_e.paint_symbol["icon-emissive-strength"]),"text-emissive-strength":new Xe(_e.paint_symbol["text-emissive-strength"]),"icon-color":new Xe(_e.paint_symbol["icon-color"]),"icon-halo-color":new Xe(_e.paint_symbol["icon-halo-color"]),"icon-halo-width":new Xe(_e.paint_symbol["icon-halo-width"]),"icon-halo-blur":new Xe(_e.paint_symbol["icon-halo-blur"]),"icon-translate":new We(_e.paint_symbol["icon-translate"]),"icon-translate-anchor":new We(_e.paint_symbol["icon-translate-anchor"]),"icon-image-cross-fade":new We(_e.paint_symbol["icon-image-cross-fade"]),"text-opacity":new Xe(_e.paint_symbol["text-opacity"]),"text-occlusion-opacity":new Xe(_e.paint_symbol["text-occlusion-opacity"]),"text-color":new Xe(_e.paint_symbol["text-color"],{runtimeType:no,getOverride:r=>r.textColor,hasOverride:r=>!!r.textColor}),"text-halo-color":new Xe(_e.paint_symbol["text-halo-color"]),"text-halo-width":new Xe(_e.paint_symbol["text-halo-width"]),"text-halo-blur":new Xe(_e.paint_symbol["text-halo-blur"]),"text-translate":new We(_e.paint_symbol["text-translate"]),"text-translate-anchor":new We(_e.paint_symbol["text-translate-anchor"]),"icon-color-saturation":new We(_e.paint_symbol["icon-color-saturation"]),"icon-color-contrast":new We(_e.paint_symbol["icon-color-contrast"]),"icon-color-brightness-min":new We(_e.paint_symbol["icon-color-brightness-min"]),"icon-color-brightness-max":new We(_e.paint_symbol["icon-color-brightness-max"]),"symbol-z-offset":new Xe(_e.paint_symbol["symbol-z-offset"]),"icon-color-use-theme":new Xe({type:"string",default:"default","property-type":"data-driven"}),"icon-halo-color-use-theme":new Xe({type:"string",default:"default","property-type":"data-driven"}),"text-color-use-theme":new Xe({type:"string",default:"default","property-type":"data-driven"}),"text-halo-color-use-theme":new Xe({type:"string",default:"default","property-type":"data-driven"})}))},Fx);class Cg extends Hn{constructor(e,i,o,a){super(e,Ox(),i,o,a,e.layout?e.layout["icon-image-use-theme"]:null),this._colorAdjustmentMatrix=Si([]),this.hasOcclusionOpacityProperties=e.paint!==void 0&&("icon-occlusion-opacity"in e.paint||"text-occlusion-opacity"in e.paint)}_handleSpecialPaintPropertyUpdate(e){e!=="icon-occlusion-opacity"&&e!=="text-occlusion-opacity"||(this.hasOcclusionOpacityProperties=!0)}recalculate(e,i){super.recalculate(e,i),this.appearances&&this.appearances.forEach(a=>{a.recalculate(e,i,this.iconImageUseTheme)}),this.layout.get("icon-rotation-alignment")==="auto"&&(this.layout._values["icon-rotation-alignment"]=this.layout.get("symbol-placement")!=="point"?"map":"viewport"),this.layout.get("text-rotation-alignment")==="auto"&&(this.layout._values["text-rotation-alignment"]=this.layout.get("symbol-placement")!=="point"?"map":"viewport"),this.layout.get("text-pitch-alignment")==="auto"&&(this.layout._values["text-pitch-alignment"]=this.layout.get("text-rotation-alignment")),this.layout.get("icon-pitch-alignment")==="auto"&&(this.layout._values["icon-pitch-alignment"]=this.layout.get("icon-rotation-alignment"));const o=this.layout.get("text-writing-mode");if(o){const a=[];for(const c of o)a.includes(c)||a.push(c);this.layout._values["text-writing-mode"]=a}else this.layout._values["text-writing-mode"]=this.layout.get("symbol-placement")==="point"?["horizontal"]:["horizontal","vertical"];this._setPaintOverrides()}getColorAdjustmentMatrix(e,i,o,a){return this._saturation===e&&this._contrast===i&&this._brightnessMin===o&&this._brightnessMax===a||(this._colorAdjustmentMatrix=(function(c,h,f,_){c=fr(c),h=jr(h);const y=mn(),v=c/3,b=1-2*v,T=[b,v,v,0,v,b,v,0,v,v,b,0,0,0,0,1],E=.5-.5*h,C=_-f;return Ni(y,[C,0,0,0,0,C,0,0,0,0,C,0,f,f,f,1],[h,0,0,0,0,h,0,0,0,0,h,0,E,E,E,1]),Ni(y,y,T),y})(e,i,o,a),this._saturation=e,this._contrast=i,this._brightnessMin=o,this._brightnessMax=a),this._colorAdjustmentMatrix}getValueAndResolveTokens(e,i,o,a){const c=this.layout.get(e).evaluate(i,{},o,a),h=this._unevaluatedLayout._values[e];return h.isDataDriven()||au(h.value)||!c?c:yb(i.properties,c)}getAppearanceValueAndResolveTokens(e,i,o,a,c){const h=e.getLayoutProperty(i);if(!h)return;const f=h.evaluate(o,{},a,c),_=e.getUnevaluatedLayoutProperties()._values[i];return _.isDataDriven()||au(_.value)||!f||typeof f!="string"?f:yb(o.properties,f)}createBucket(e){return new J_(e)}queryRadius(){return 0}queryIntersectsFeature(){return!1}_setPaintOverrides(){for(const e of Ox().paint.overridableProperties){if(!Cg.hasPaintOverride(this.layout,e))continue;const i=this.paint.get(e),o=new xb(i),a=new uf(o,i.property.specification,this.scope,this.options,this.layout.get("icon-image-use-theme"));let c=null;c=i.value.kind==="constant"||i.value.kind==="source"?new wh("source",a):new lu("composite",a,i.value.zoomStops,i.value.interpolationType),this.paint._values[e]=new ns(i.property,c,i.parameters)}}_handleOverridablePaintPropertyUpdate(e,i,o){return!(!this.layout||i.isDataDriven()||o.isDataDriven())&&Cg.hasPaintOverride(this.layout,e)}static hasPaintOverride(e,i){const o=e.get("text-field"),a=Ox().paint.properties[i];let c=!1;const h=f=>{for(const _ of f)if(a.overrides&&a.overrides.hasOverride(_))return void(c=!0)};if(o.value.kind==="constant"&&o.value.value instanceof rn)h(o.value.value.sections);else if(o.value.kind==="source"){const f=y=>{c||(y instanceof qs&&Cr(y.value)===oo?h(y.value.sections):y instanceof yt?h(y.sections):y.eachChild(f))},_=o.value;_._styleExpression&&f(_._styleExpression.expression)}return c}getProgramIds(){return["symbol"]}getDefaultProgramParams(e,i,o){return{config:new ra(this,{zoom:i,lut:o}),overrideFog:!1}}hasElevation(){return this.layout&&this.layout.get("symbol-elevation-reference")==="hd-road-markup"}mayUse(e){return e==="HD"&&Vh(this,"symbol-elevation-reference",i=>i==="hd-road-markup")}prepare(){return this.mayUse("HD")?Ig():Promise.resolve()}}let vb,bb,wb,Tb;const kx=1024,ST=(Math.pow(kx,2)-1)/268170240;class Sb extends Hn{constructor(e,i,o,a){super(e,{layout:wb||(wb=new Vi({visibility:new We(_e.layout_raster.visibility)})),paint:Tb||(Tb=new Vi({"raster-opacity":new We(_e.paint_raster["raster-opacity"]),"raster-color":new El(_e.paint_raster["raster-color"]),"raster-color-mix":new We(_e.paint_raster["raster-color-mix"]),"raster-color-range":new We(_e.paint_raster["raster-color-range"]),"raster-hue-rotate":new We(_e.paint_raster["raster-hue-rotate"]),"raster-brightness-min":new We(_e.paint_raster["raster-brightness-min"]),"raster-brightness-max":new We(_e.paint_raster["raster-brightness-max"]),"raster-saturation":new We(_e.paint_raster["raster-saturation"]),"raster-contrast":new We(_e.paint_raster["raster-contrast"]),"raster-resampling":new We(_e.paint_raster["raster-resampling"]),"raster-fade-duration":new We(_e.paint_raster["raster-fade-duration"]),"raster-emissive-strength":new We(_e.paint_raster["raster-emissive-strength"]),"raster-array-band":new We(_e.paint_raster["raster-array-band"]),"raster-elevation":new We(_e.paint_raster["raster-elevation"]),"raster-elevation-reference":new We(_e.paint_raster["raster-elevation-reference"]),"raster-color-use-theme":new Xe({type:"string",default:"default","property-type":"data-driven"})}))},i,o,a),this.updateColorRamp(),this._curRampRange=[NaN,NaN]}getProgramIds(){return["raster"]}hasColorMap(){return!!this._transitionablePaint._values["raster-color"].value.value}tileCoverLift(){return this.paint.get("raster-elevation")}isDraped(e){const i=e?e._source:null;return(!i||i.type!=="image"&&i.type!=="video"&&i.type!=="canvas"||!i.onNorthPole&&!i.onSouthPole)&&this.paint.get("raster-elevation")===0}_handleSpecialPaintPropertyUpdate(e){e!=="raster-color"&&e!=="raster-color-range"||(this._curRampRange=[NaN,NaN],this.updateColorRamp())}_clear(){this.colorRampTexture&&(this.colorRampTexture.destroy(),this.colorRampTexture=null)}updateColorRamp(e){if(!this.hasColorMap()||!this._curRampRange)return;const i=this._transitionablePaint._values["raster-color"].value.expression,[o,a]=e||this._transitionablePaint._values["raster-color-range"].value.expression.evaluate({zoom:0})||[NaN,NaN];isNaN(o)&&isNaN(a)||o===this._curRampRange[0]&&a===this._curRampRange[1]||(this.colorRamp=Vp({expression:i,evaluationKey:"rasterValue",image:this.colorRamp,clips:[{start:o,end:a}],resolution:kx}),this.colorRampTexture=null,this._curRampRange=[o,a])}is3D(e){return this.paint.get("raster-elevation")>0}}let Eb,Ib,Ab,Cb,Mb,Pb,Rb;class Db extends Hn{constructor(e,i,o,a){super(e,{layout:Eb||(Eb=new Vi({visibility:new We(_e["layout_raster-particle"].visibility)})),paint:Ib||(Ib=new Vi({"raster-particle-array-band":new We(_e["paint_raster-particle"]["raster-particle-array-band"]),"raster-particle-count":new We(_e["paint_raster-particle"]["raster-particle-count"]),"raster-particle-color":new El(_e["paint_raster-particle"]["raster-particle-color"]),"raster-particle-max-speed":new We(_e["paint_raster-particle"]["raster-particle-max-speed"]),"raster-particle-speed-factor":new We(_e["paint_raster-particle"]["raster-particle-speed-factor"]),"raster-particle-fade-opacity-factor":new We(_e["paint_raster-particle"]["raster-particle-fade-opacity-factor"]),"raster-particle-reset-rate-factor":new We(_e["paint_raster-particle"]["raster-particle-reset-rate-factor"]),"raster-particle-elevation":new We(_e["paint_raster-particle"]["raster-particle-elevation"]),"raster-particle-color-use-theme":new Xe({type:"string",default:"default","property-type":"data-driven"})}))},i,o,a),this._updateColorRamp(),this.lastInvalidatedAt=_r.now()}mayUse(e){return e==="HD"}_clear(){this.colorRampTexture&&(this.colorRampTexture.destroy(),this.colorRampTexture=null),this.tileFramebuffer&&(this.tileFramebuffer.destroy(),this.tileFramebuffer=null),this.particleFramebuffer&&(this.particleFramebuffer.destroy(),this.particleFramebuffer=null)}onRemove(e){this.colorRampTexture&&this.colorRampTexture.destroy(),this.tileFramebuffer&&this.tileFramebuffer.destroy(),this.particleFramebuffer&&this.particleFramebuffer.destroy()}hasColorMap(){return!!this._transitionablePaint._values["raster-particle-color"].value.value}getProgramIds(){return["rasterParticle"]}hasOffscreenPass(){return this.visibility!=="none"}isDraped(e){return!1}_handleSpecialPaintPropertyUpdate(e){e!=="raster-particle-color"&&e!=="raster-particle-max-speed"||(this._updateColorRamp(),this._invalidateAnimationState()),e==="raster-particle-count"&&this._invalidateAnimationState()}_updateColorRamp(){if(!this.hasColorMap())return;const e=this._transitionablePaint._values["raster-particle-color"].value.expression,i=this._transitionablePaint._values["raster-particle-max-speed"].value.expression.evaluate({zoom:0});this.colorRamp=Vp({expression:e,evaluationKey:"rasterParticleSpeed",image:this.colorRamp,clips:[{start:0,end:i}],resolution:256}),this.colorRampTexture=null}_invalidateAnimationState(){this.lastInvalidatedAt=_r.now()}tileCoverLift(){return this.paint.get("raster-particle-elevation")}}class ET extends Hn{constructor(e,i){super(e,{},i,null),this.implementation=e,e.slot&&(this.slot=e.slot)}is3D(e){return this.implementation.renderingMode==="3d"}hasOffscreenPass(){return this.implementation.prerender!==void 0}isDraped(e){return this.implementation.renderToTile!==void 0}shouldRedrape(){return!!this.implementation.shouldRerenderTiles&&this.implementation.shouldRerenderTiles()}recalculate(){}updateTransitions(){}hasTransition(){return!1}serialize(){}onAdd(e){this.implementation.onAdd&&this.implementation.onAdd(e,e.painter.context.gl)}onRemove(e){this.implementation.onRemove&&this.implementation.onRemove(e,e.painter.context.gl)}}function Bx(r,e,i){const o=[0,0,1],a=Ao([]);return eo(a,a,i?-Qt(r)+Math.PI:Qt(r)),Jo(a,a,-Qt(e)),Xo(o,o,a),Mi(o,o)}class Lb{constructor(e,i){this.feature=e,this.instancedDataOffset=i,this.instancedDataCount=0,this.rotation=[0,0,0],this.scale=[1,1,1],this.translation=[0,0,0]}}class zb{constructor(){this.maxScale=1,this.maxXYTranslationDistance=0,this.instancedDataArray=new Ha,this.instancesEvaluatedElevation=[],this.features=[],this.idToFeaturesIndex={}}colorForInstance(e){const i=16*e,o=this.instancedDataArray.float32;let a=Math.floor(o[i+2]);const c=1.05*(o[i+2]-a);return a/=100,[o[i]%1*1.05,o[i+1]%1*1.05,c,a]}tileCoordinatesForInstance(e){const i=16*e,o=this.instancedDataArray.float32;let a=o[i+0];return a=a>rt?a-rt:a,new Ue(Math.trunc(a),Math.trunc(o[i+1]))}translationForInstance(e){const i=16*e,o=this.instancedDataArray.float32;return[o[i+4],o[i+5],o[i+6]]}rotationScaleForInstance(e){const i=16*e,o=this.instancedDataArray.float32;return[o[i+7],o[i+8],o[i+9],o[i+10],o[i+11],o[i+12],o[i+13],o[i+14],o[i+15]]}transformForInstance(e){const i=16*e,o=this.instancedDataArray.float32;return[o[i+7],o[i+8],o[i+9],o[i+4],o[i+10],o[i+11],o[i+12],o[i+5],o[i+13],o[i+14],o[i+15],o[i+6],0,0,0,1]}}class Nx{constructor(e){this.requiresStandardRuntime=!0,this.zoom=e.zoom,this.canonical=e.canonical,this.overscaledZ=this.canonical.z+Math.log2(e.overscaling),this.layers=e.layers,this.layerIds=this.layers.map(i=>i.fqid),this.projection=e.projection,this.index=e.index,this.worldview=e.worldview,this.hasZoomDependentProperties=this.layers[0].isZoomDependent(),this.stateDependentLayerIds=this.layers.filter(i=>i.isStateDependent()).map(i=>i.id),this.hasPattern=!1,this.instancesPerModel={},this.validForExaggeration=0,this.maxVerticalOffset=0,this.maxScale=0,this.maxHeight=0,this.lookupDim=this.zoom>this.canonical.z+1?0:this.zoom>this.canonical.z?256:this.zoom>15?75:100,this.instanceCount=0,this.terrainElevationMin=0,this.terrainElevationMax=0,this.validForDEMTile={id:null,timestamp:0},this.modelUris=[],this.modelsRequested=!1,this.activeReplacements=[],this.replacementUpdateTime=0,this.styleDefinedModelURLs=e.styleDefinedModelURLs,this.hasAppearances=null}updateFootprints(e,i){}updateAppearances(e,i,o,a){return{hasLayoutChanges:!1,hasUboChanges:!1}}populate(e,i,o,a){this.tileToMeter=yo(o);const c=this.layers[0]._featureFilter.needGeometry;this.lookup=new Uint8Array(this.lookupDim*this.lookupDim);const h=this.layers[0].paint.get("model-elevation-reference")==="hd-road-markup"?i.elevationFeatures:void 0;for(const{feature:f,id:_,index:y,sourceLayerIndex:v}of e){const b=_??(f.properties&&Object.hasOwn(f.properties,"id")?f.properties.id:void 0),T=Vo(f,c);if(!this.layers[0]._featureFilter.filter(new xt(this.zoom,{worldview:this.worldview,activeFloors:i.activeFloors}),T,o))continue;const E={id:b,sourceLayerIndex:v,index:y,geometry:c?T.geometry:ls(f,o,a),properties:f.properties,type:f.type,patterns:{}},C=this.addFeature(E,E.geometry,T,h,o);C&&i.featureIndex.insert(f,E.geometry,y,v,this.index,this.instancesPerModel[C].instancedDataArray.length,256)}this.lookup=null}evaluateQueryRenderedFeaturePadding(){const e=this.layers[0].modelManager,i=this.layers[0].scope;let o=0;for(const a of this.modelUris){const c=e.getModel(a,i);if(!c)continue;const h=this.instancesPerModel[a];if(h){const f=.5*ks(c.aabb.max,c.aabb.min)*h.maxScale+h.maxXYTranslationDistance,_=Math.min(rt,Math.max(f/this.tileToMeter,256));o=Math.max(_,o)}}return o}update(e,i,o,a){for(const c in this.instancesPerModel){const h=this.instancesPerModel[c];for(const f in e)Object.hasOwn(h.idToFeaturesIndex,f)&&(this.evaluate(h.features[h.idToFeaturesIndex[f]],e[f],h,!0),this.uploaded=!1)}this.maxHeight=0}updateZoomBasedPaintProperties(){if(!this.hasZoomDependentProperties)return!1;let e=!1;for(const i in this.instancesPerModel){const o=this.instancesPerModel[i];for(const a of o.features){const c=this.layers[0],h=a.feature,f=this.canonical,_=c.paint.get("model-rotation").evaluate(h,{},f),y=c.paint.get("model-scale").evaluate(h,{},f),v=c.paint.get("model-translation").evaluate(h,{},f);Rn(a.rotation,_)&&Rn(a.scale,y)&&Rn(a.translation,v)||(this.evaluate(a,a.featureStates,o,!0),e=!0)}}return e}updateReplacement(e,i,o,a){if(i.updateTime===this.replacementUpdateTime)return!1;this.replacementUpdateTime=i.updateTime;const c=i.getReplacementRegionsForTile(e.toUnwrapped(),!0);if(K_(this.activeReplacements,c))return!1;this.activeReplacements=c;let h=!1;for(const f in this.instancesPerModel){const _=this.instancesPerModel[f],y=_.instancedDataArray;for(const v of _.features){const b=v.instancedDataOffset,T=v.instancedDataCount;for(let E=0;E<T;E++){const C=16*(E+b);let P=y.float32[C+0];const R=P>rt;P=R?P-rt:P;const z=Math.floor(P),V=Math.floor(y.float32[C+1]);let N=!1;for(const U of this.activeReplacements)if(!Sv(U,o,gg.Model,a)&&!(U.min.x>z||z>U.max.x||U.min.y>V||V>U.max.y)&&(N=Mv(Cv(z,V,e.canonical,U.footprintTileId.canonical),U.footprint),N))break;y.float32[C]=N?P+rt:P,h=h||N!==R}}}return h}isEmpty(){for(const e in this.instancesPerModel)if(this.instancesPerModel[e].instancedDataArray.length!==0)return!1;return!0}uploadPending(){return!this.uploaded}upload(e){if(!this.uploaded)for(const i in this.instancesPerModel){const o=this.instancesPerModel[i];o.instancedDataArray.length<0||o.instancedDataArray.length===0||(o.instancedDataBuffer?o.instancedDataBuffer.updateData(o.instancedDataArray):o.instancedDataBuffer=e.createVertexBuffer(o.instancedDataArray,Lw.members,!0,void 0,this.instanceCount))}this.uploaded=!0}destroy(e){for(const o in this.instancesPerModel){const a=this.instancesPerModel[o];a.instancedDataArray.length!==0&&a.instancedDataBuffer&&a.instancedDataBuffer.destroy()}const i=this.layers[0].modelManager;if(e&&i&&this.modelUris&&this.modelsRequested)for(const o of this.modelUris)i.removeModel(o,"",!0)}addFeature(e,i,o,a,c){const h=this.layers[0],f=h.layout.get("model-id"),_=h.layout.get("model-allow-density-reduction"),y=f.evaluate(o,{},this.canonical);if(!y)return ht(`modelId is not evaluated for layer ${h.id} and it is not going to get rendered.`),y;!y.includes("://")&&!this.styleDefinedModelURLs[y]||this.modelUris.includes(y)||this.modelUris.push(y),this.instancesPerModel[y]||(this.instancesPerModel[y]=new zb);const v=this.instancesPerModel[y],b=v.instancedDataArray,T=new Lb(o,b.length);let E;if(a){const C=Dp(e,a,void 0,c);E=C?C.feature:void 0}for(const C of i)for(const P of C){if(P.x<0||P.x>=rt||P.y<0||P.y>=rt)continue;if(this.lookupDim!==0&&_){const z=(this.lookupDim-1)/rt,V=this.lookupDim*(P.y*z|0)+P.x*z|0;if(this.lookup){if(this.lookup[V]!==0)continue;this.lookup[V]=1}}this.instanceCount++;const R=b.length;if(b.resize(R+1),a){v.instancesRoadElevation||(v.instancesRoadElevation=[]);const z=E?E.pointElevation(new Ue(P.x,P.y)):0;v.instancesRoadElevation.push(z)}v.instancesEvaluatedElevation.push(0),b.float32[16*R]=P.x,b.float32[16*R+1]=P.y}return T.instancedDataCount=v.instancedDataArray.length-T.instancedDataOffset,T.instancedDataCount>0&&(e.id&&(v.idToFeaturesIndex[e.id]=v.features.length),v.features.push(T),this.evaluate(T,{},v,!1)),y}getModelUris(){return this.modelUris}evaluate(e,i,o,a){const c=this.layers[0],h=e.feature,f=this.canonical,_=e.rotation=c.paint.get("model-rotation").evaluate(h,i,f),y=e.scale=c.paint.get("model-scale").evaluate(h,i,f),v=e.translation=c.paint.get("model-translation").evaluate(h,i,f),{r:b,g:T,b:E}=c.paint.get("model-color").evaluate(h,i,f),C=c.paint.get("model-color-mix-intensity").evaluate(h,i,f),P=[];this.maxVerticalOffset<v[2]&&(this.maxVerticalOffset=v[2]);const R=v[0]*v[0]+v[1]*v[1],z=R>0?Math.sqrt(R):0;o.maxScale=Math.max(Math.max(o.maxScale,y[0]),Math.max(y[1],y[2])),o.maxXYTranslationDistance=Math.max(o.maxXYTranslationDistance,z),this.maxScale=Math.max(Math.max(this.maxScale,y[0]),Math.max(y[1],y[2])),d0(P,_,y);const V=Math.round(100*C)+E/1.05;for(let N=0;N<e.instancedDataCount;++N){const U=e.instancedDataOffset+N,q=16*U,W=o.instancedDataArray.float32;let se=0;a&&(se=W[q+6]-o.instancesEvaluatedElevation[U]);const X=0|W[q+1];W[q]=(0|W[q])+b/1.05,W[q+1]=X+T/1.05,W[q+2]=V,W[q+3]=1/(f.z>10?this.tileToMeter:yo(f,X)),W[q+4]=v[0],W[q+5]=v[1],W[q+6]=v[2]+(o.instancesRoadElevation?o.instancesRoadElevation[U]:0)+se,W[q+7]=P[0],W[q+8]=P[1],W[q+9]=P[2],W[q+10]=P[4],W[q+11]=P[5],W[q+12]=P[6],W[q+13]=P[8],W[q+14]=P[9],W[q+15]=P[10],o.instancesEvaluatedElevation[U]=v[2]}}}nt(Nx,"ModelBucket",{omit:["layers"]}),nt(zb,"PerModelAttributes"),nt(Lb,"ModelFeature");class Md{constructor(e,i,o){this._demTile=e,this._dem=this._demTile.dem,this._scale=i,this._offset=o}static create(e,i,o){const a=o||e.findDEMTileFor(i);if(!a||!a.dem)return;const c=a.dem,h=a.tileID,f=1<<i.canonical.z-h.canonical.z;return new Md(a,c.dim/rt/f,[(i.canonical.x/f-h.canonical.x)*c.dim,(i.canonical.y/f-h.canonical.y)*c.dim])}tileCoordToPixel(e,i){const o=i*this._scale+this._offset[1];return new Ue(Math.floor(e*this._scale+this._offset[0]),Math.floor(o))}getElevationAt(e,i,o,a){const c=e*this._scale+this._offset[0],h=i*this._scale+this._offset[1],f=Math.floor(c),_=Math.floor(h),y=this._dem;return a=!!a,o?vt(vt(y.get(f,_,a),y.get(f,_+1,a),h-_),vt(y.get(f+1,_,a),y.get(f+1,_+1,a),h-_),c-f):y.get(f,_,a)}getElevationAtPixel(e,i,o){return this._dem.get(e,i,!!o)}getMeterToDEM(e){return(1<<this._demTile.tileID.canonical.z)*Wn(1,e)*this._dem.stride}}const Vx=new Float32Array(262144),Gu=new Uint8Array(262144),Mg=[0,0,0],Pg=[0,0,0];function Fb(r){let e=0;if(r.meshes)for(const i of r.meshes)e=Math.max(e,i.aabb.max[2]);if(r.children)for(const i of r.children)e=Math.max(e,Fb(i));return e}function Ob(r,e,i){if(r.meshes)for(const o of r.meshes){if(o.aabb.min[0]===1/0)continue;const a=lr.applyTransform(o.aabb,r.globalMatrix);i.insert(e,a.min[0],a.min[1],a.max[0],a.max[1])}if(r.children)for(const o of r.children)Ob(o,e,i)}const Rg=["","wall","door","roof","window","lamp","logo"];class kb{constructor(e){this.node=e,this.evaluatedRMEA=[[1,0,0,1],[1,0,0,1],[1,0,0,1],[1,0,0,1],[.4,1,0,1],[1,0,0,1],[1,0,0,1]],this.hiddenByReplacement=!1,this.evaluatedTranslation=[0,0,0],this.evaluatedScale=[1,1,1],this.evaluatedColor=[],this.emissionHeightBasedParams=[],this.cameraCollisionOpacity=1,this.targetLod=-1,this.feature={type:"Point",id:e.id,geometry:[],properties:{height:Fb(e)}},this.aabb=this._getLocalBounds(),this.state=null}_getLocalBounds(){if(!this.node.meshes)return new lr([1/0,1/0,1/0],[-1/0,-1/0,-1/0]);if(!this.aabb){let e=0;const i=new lr([1/0,1/0,1/0],[-1/0,-1/0,-1/0]);for(const o of this.node.meshes)this.node.lightMeshIndex!==e&&(o.transformedAabb=lr.applyTransformFast(o.aabb,this.node.globalMatrix),i.encapsulate(o.transformedAabb)),e++;this.aabb=i}return this.aabb}}class Dg{constructor(e,i,o,a,c,h,f,_){this.requiresStandardRuntime=!0,this.id=o,this.layers=e,this.layerIds=this.layers.map(y=>y.fqid),this.stateDependentLayerIds=this.layers.filter(y=>y.isStateDependent()).map(y=>y.id),this.modelTraits|=Id.CoordinateSpaceTile,this.uploaded=!1,this.hasPattern=!1,a&&(this.modelTraits|=Id.HasMapbox
7MeshFeatures),c&&(this.modelTraits|=Id.HasMeshoptCompression),this.zoom=-1,this.terrainExaggeration=1,this.projection={name:"mercator"},this.replacementUpdateTime=0,this.elevationReadFromZ=255,this.brightness=h,this.worldview=_,this.dirty=!0,this.needsUpload=!1,this.filter=null,this.nodesInfo=[];for(const y of i)this.nodesInfo.push(new kb(y)),Ob(y,f.featureIndexArray.length,f.grid),f.featureIndexArray.emplaceBack(this.nodesInfo.length-1,0,f.bucketLayerIDs.length-1,0);this.states={},this.hasAppearances=null}updateFootprints(e,i){for(const o of this.getNodesInfo()){const a=o.node;a.footprint&&i.push({footprint:a.footprint,id:e})}}updateAppearances(e,i,o,a){return{hasLayoutChanges:!1,hasUboChanges:!1}}update(e){const i=Object.keys(e).length!==0;if(i&&!this.stateDependentLayers.length)return;const o=i?this.stateDependentLayers:this.layers;if(!ro(e,this.states))for(const a of o)this.evaluate(a,e);this.states=structuredClone(e)}populate(){console.log("populate 3D model bucket")}uploadPending(){return!this.uploaded||this.needsUpload}upload(e){if(!this.needsUpload)return;const i=this.getNodesInfo();for(const o of i){const a=o.node;this.uploaded?this.updatePbrBuffer(a):vx(a,e,!0)}for(const o of i)mg(o.node);this.uploaded=!0,this.needsUpload=!1}updatePbrBuffer(e){let i=!1;if(!e.meshes)return i;for(const o of e.meshes)o.pbrBuffer&&(o.pbrBuffer.updateData(o.featureArray),i=!0);if(e.lodMeshes)for(const o of e.lodMeshes)o.pbrBuffer&&(o.pbrBuffer.updateData(o.featureArray),i=!0);return i}needsReEvaluation(e,i,o){const a=e.transform.projectionOptions,c=e.style.getBrightness(),h=this.brightness!==c;if(!this.uploaded||this.dirty||a.name!==this.projection.name||Gp(o.paint.get("model-color").value,h)||Gp(o.paint.get("model-color-mix-intensity").value,h)||Gp(o.paint.get("model-roughness").value,h)||Gp(o.paint.get("model-emissive-strength").value,h)||Gp(o.paint.get("model-height-based-emissive-strength-multiplier").value,h)){this.projection=a,this.brightness=c;const f=this.getNodesInfo();for(const _ of f)_.state=null;return!0}return!1}evaluateTransform(e,i){if(e.transform.zoom===this.zoom)return;this.zoom=e.transform.zoom;const o=this.getNodesInfo(),a=this.id.canonical;for(const c of o){const h=c.feature;c.evaluatedTranslation=i.paint.get("model-translation").evaluate(h,{},a),c.evaluatedScale=i.paint.get("model-scale").evaluate(h,{},a)}}evaluate(e,i){const o=this.getNodesInfo();for(const a of o){if(!a.node.meshes)continue;const c=a.feature,h=i&&i[c.id];if(ro(h,a.state))continue;a.state=structuredClone(h);const f=a.node.meshes&&a.node.meshes[0].featureData,_=a.evaluatedColor[2],y=a.evaluatedRMEA[2],v=this.id.canonical;if(a.hasTranslucentParts=!1,f){for(let b=0;b<Rg.length;b++){const T=Rg[b];T.length&&(c.properties.part=T);const E=e.paint.get("model-color").evaluate(c,h,v).toPremultipliedRenderColor(null),C=e.paint.get("model-color-mix-intensity").evaluate(c,h,v);a.evaluatedColor[b]=[E.r,E.g,E.b,C],a.evaluatedRMEA[b][0]=e.paint.get("model-roughness").evaluate(c,h,v),a.evaluatedRMEA[b][2]=e.paint.get("model-emissive-strength").evaluate(c,h,v),a.evaluatedRMEA[b][3]=E.a,a.emissionHeightBasedParams[b]=e.paint.get("model-height-based-emissive-strength-multiplier").evaluate(c,h,v),!a.hasTranslucentParts&&E.a<1&&(a.hasTranslucentParts=!0)}delete c.properties.part,AT(a,_!==a.evaluatedColor[2]||y!==a.evaluatedRMEA[2],this.modelTraits)}else a.evaluatedRMEA[0][2]=e.paint.get("model-emissive-strength").evaluate(c,h,v);a.evaluatedTranslation=e.paint.get("model-translation").evaluate(c,h,v),a.evaluatedScale=e.paint.get("model-scale").evaluate(c,h,v),this.updatePbrBuffer(a.node)||(this.needsUpload=!0)}this.dirty=!1}elevationUpdate(e,i,o,a){const c=e.findDEMTileFor(o);if(c&&(c.tileID.canonical!==this.terrainTile||i!==this.terrainExaggeration)){if(c.dem&&c.tileID.overscaledZ!==this.elevationReadFromZ){this.elevationReadFromZ=c.tileID.overscaledZ;const h=Md.create(e,o,c);if(!h)return;this.modelTraits&Id.HasMapboxMeshFeatures&&this.updateDEM(e,h,o,a);for(const f of this.getNodesInfo()){const _=f.node;if(!_.footprint||!_.footprint.vertices||!_.footprint.vertices.length)continue;const y=_.footprint.vertices;let v=h.getElevationAt(y[0].x,y[0].y,!0,!0);for(let b=1;b<y.length;b++)v=Math.min(v,h.getElevationAt(y[b].x,y[b].y,!0,!0));_.elevation=v}}this.terrainTile=c.tileID.canonical,this.terrainExaggeration=i}}updateDEM(e,i,o,a){let c=i._dem._modifiedForSources[a];if(c===void 0&&(i._dem._modifiedForSources[a]=[],c=i._dem._modifiedForSources[a]),c.includes(o.canonical))return;const h=i._dem.dim;c.push(o.canonical);let f=!1;for(const _ of this.getNodesInfo()){const y=_.node;if(!y.footprint||!y.footprint.grid)continue;const v=y.footprint.grid,b=i.tileCoordToPixel(v.min.x,v.min.y),T=i.tileCoordToPixel(v.max.x,v.max.y),E=Math.min(Math.min(h-T.y,b.x),Math.min(b.y,h-T.x));if(E<0)continue;const C=Y(E,2,5);let P=Math.max(0,b.x-C),R=Math.max(0,b.y-C),z=Math.min(T.x+C,h-1),V=Math.min(T.y+C,h-1);for(let W=R;W<=V;++W)for(let se=P;se<=z;++se)Gu[W*h+se]=255;let N=0,U=0;for(let W=0;W<v.cellsY;++W)for(let se=0;se<v.cellsX;++se){if(!v.cells[W*v.cellsX+se])continue;const X=i.tileCoordToPixel(v.min.x+se/v.xScale,v.min.y+W/v.yScale),ie=i.tileCoordToPixel(v.min.x+(se+1)/v.xScale,v.min.y+(W+1)/v.yScale);for(let re=X.y;re<=Math.min(ie.y+1,h-1);++re)for(let oe=X.x;oe<=Math.min(ie.x+1,h-1);++oe)Gu[re*h+oe]===255&&(Gu[re*h+oe]=0,N+=i.getElevationAtPixel(oe,re),U++)}const q=N/U;P=Math.max(1,b.x-C),R=Math.max(1,b.y-C),z=Math.min(T.x+C,h-2),V=Math.min(T.y+C,h-2),f=!0;for(let W=R;W<=V;++W)for(let se=P;se<=z;++se)Gu[W*h+se]===0&&(Vx[W*h+se]=i._dem.set(se,W,q));for(let W=1;W<C;++W){P=Math.max(1,b.x-W),R=Math.max(1,b.y-W),z=Math.min(T.x+W,h-2),V=Math.min(T.y+W,h-2);for(let se=R;se<=V;++se)for(let X=P;X<=z;
7++X){const ie=se*h+X;if(Gu[ie]===255){let re=0,oe=0,me=-1,xe=-1;for(let we=-1;we<=1;++we)for(let Ce=-1;Ce<=1;++Ce){const Se=(se+we)*h+X+Ce;if(Gu[Se]>=W)continue;const qe=Vx[Se],Me=Math.abs(qe);Me>oe&&(re=qe,oe=Me,me=Ce,xe=we)}if(oe>.1){const we=1-(W+.5*Math.abs(me*xe))/C;let Ce=i._dem.get(X,se)+re*we;const Se=i._dem.get(X+me,se+xe),qe=i._dem.get(X-me,se-xe,!0);(Ce-Se)*(Ce-qe)>0&&(Ce=(Se+qe)/2),Vx[ie]=i._dem.set(X,se,Ce),Gu[ie]=W}}}}}f&&(i._demTile.needsDEMTextureUpload=!0,i._dem._timestamp=_r.now())}setFilter(e){this.filter=e?zh(e):null}getNodesInfo(){return this.filter?this.nodesInfo.filter(e=>this.filter.filter(new xt(this.id.overscaledZ,{worldview:this.worldview}),e.feature,this.id.canonical)):this.nodesInfo}destroy(){const e=this.getNodesInfo();for(const i of e)mg(i.node),bx(i.node)}isEmpty(){return!this.nodesInfo.length}updateReplacement(e,i){if(i.updateTime===this.replacementUpdateTime)return;this.replacementUpdateTime=i.updateTime;const o=i.getReplacementRegionsForTile(e.toUnwrapped());for(const a of this.getNodesInfo()){const c=a.node.footprint;a.hiddenByReplacement=!!c&&!o.some(h=>h.footprint===c)}}getHeightAtTileCoord(e,i){const o=[0,0,0],a=Si([]);for(const c of this.getNodesInfo()){const h=c.node.meshes[0],f=h.transformedAabb;if(e<f.min[0]||i<f.min[1]||e>f.max[0]||i>f.max[1])continue;if(c.node.hidden===!0)return{height:1/0,maxHeight:c.feature.properties.height,hidden:!1,verticalScale:c.evaluatedScale[2]};if(co(a,c.node.globalMatrix),o[0]=e,o[1]=i,o[2]=0,ir(o,o,a),c.node.meshBVH){const b=o[0],T=o[1];Mg[0]=b-1,Mg[1]=T-1,Mg[2]=-1e3,Pg[0]=b+1,Pg[1]=T+1,Pg[2]=1e3;const E=c.node.meshBVH.findHighestPoint(Mg,Pg);if(E!==null)return{height:E,maxHeight:c.feature.properties.height,hidden:c.hiddenByReplacement,verticalScale:c.evaluatedScale[2]};continue}const _=(o[0]-h.aabb.min[0])/(h.aabb.max[0]-h.aabb.min[0])*Uu|0,y=Math.min(63,(o[1]-h.aabb.min[1])/(h.aabb.max[1]-h.aabb.min[1])*Uu|0)*Uu+Math.min(63,_),v=h.heightmap[y];if(v<0&&c.node.footprint){const b=[];if(c.node.footprint.grid.query(new Ue(e,i),new Ue(e,i),b),b.length>0)return{height:void 0,maxHeight:c.feature.properties.height,hidden:c.hiddenByReplacement,verticalScale:c.evaluatedScale[2]};continue}return c.hiddenByReplacement?void 0:{height:v,maxHeight:c.feature.properties.height,hidden:!1,verticalScale:c.evaluatedScale[2]}}}}function Gp(r,e){return r instanceof wh&&!r.isLightConstant&&e}function IT(r){const e=Y(r,0,2);return Math.min(Math.round(.5*e*255),255)}const Bb=new Float64Array(10*Rg.length);function Nb(r,e,i,o,a){if(!r.featureData)return;const c=r.featureArray=new ed;c.reserveExact(r.featureData.length),(function(y,v,b){const T=b-v;for(let E=0;E<Rg.length;E++){const C=y.evaluatedRMEA[E],P=y.evaluatedColor[E],R=y.emissionHeightBasedParams[E],z=Y(R[0],0,1),V=Y(R[1],0,1);let N=65535,U=0,q=1,W=1;if(z!==V&&T!==0){const ie=Y(R[2],0,1),re=Y(R[3],0,1),oe=T*(V-z);U=1/oe,q=-(v+T*z)/oe,W=Math.pow(10,Y(R[4],-1,1)),N=255*ie<<8|255*re}const se=Bb,X=10*E;se[X]=255*P[0],se[X+1]=255*P[1],se[X+2]=255*P[2],se[X+3]=P[3],se[X+4]=Math.floor(255*C[3]),se[X+5]=IT(C[2])<<8|15*C[0]<<4|15*C[1],se[X+6]=N,se[X+7]=U,se[X+8]=q,se[X+9]=W}})(e,r.aabb.min[2],r.aabb.max[2]);const h=Bb,f=e.node;let _=a&&!!f.lights;for(const y of r.featureData){const v=y>>i&65535,b=y>>o&15,T=b<8?b:0,E=10*T;let C=(61440&v|(61440&v)>>4)>>8,P=(3840&v|(3840&v)>>4)>>4,R=240&v|(240&v)>>4;const z=(15&v|(15&v)<<4)/255,V=h[E+3];V>0&&(C=vt(C,h[E],V),P=vt(P,h[E+1],V),R=vt(R,h[E+2],V)),C*=z,P*=z,R*=z;const N=C<<8|P,U=R<<8|h[E+4],q=h[E+5],W=h[E+6],se=h[E+7],X=h[E+8],ie=h[E+9];if(c.emplaceBack(N,U,q,W,se,X,ie),_&&T===2){_=!1;const re=10*f.lights.length,oe=new ed;oe.reserveExact(re);for(let me=0;me<re;me++)oe.emplaceBack(N,U,q,W,se,X,ie);f.meshes[f.lightMeshIndex].featureArray=oe}}}function AT(r,e,i){const o=r.node,a=i&Id.HasMeshoptCompression,c=a?0:16,h=a?16:0;for(let f=0;f<o.meshes.length;f++)o.lights&&o.lightMeshIndex===f||Nb(o.meshes[f],r,c,h,e);if(o.lodMeshes)for(const f of o.lodMeshes)Nb(f,r,c,h,!1)}nt(Dg,"Tiled3dModelBucket",{omit:["layers"]}),nt(kb,"Tiled3dModelFeature");const CT=["id","tile","layer","source","sourceLayer","state"];class $u{constructor(e,i,o,a,c){this.type="Feature",this._vectorTileFeature=e,this._z=i,this._x=o,this._y=a,this.properties=e?e.properties:{},this.id=c}clone(){const e=new $u(this._vectorTileFeature,this._z,this._x,this._y,this.id);return this.state&&(e.state={...this.state}),this.layer&&(e.layer={...this.layer}),this.source&&(e.source=this.source),this.sourceLayer&&(e.sourceLayer=this.sourceLayer),e}get geometry(){return this._geometry===void 0&&this._vectorTileFeature&&(this._geometry=this._vectorTileFeature.toGeoJSON(this._x,this._y,this._z).geometry),this._geometry}set geometry(e){this._geometry=e}toJSON(){const e={type:"Feature",state:void 0,geometry:this.geometry,properties:this.properties};for(const i of CT)this[i]!==void 0&&(e[i]=this[i]);return e}}class jl extends dl{constructor(e,i,o,a){super(),this.id=e,this.type="model",this.models=[],this._options=i,this._modelsInfo=new Map,this._abortController=null}cancelModelRequests(){this._abortController&&(this._abortController.abort(),this._abortController=null)}async loadGLTFFromURI(e,i){return l0((await this.map._requestManager.transformRequest(e,ul.Model,i)).url,
vendor: 28,217 bytes, line 7
7i)}async loadModel(e,i,o){try{const a=await this.loadGLTFFromURI(i.uri,o);if(o.aborted)return;const c=this._modelsInfo.get(e);if(!c)return;const h=Ex(a),f=c.modelSpec,_=new f0(e,f.uri,f.position,f.orientation,h);jl.applyModelSpecification(_,f),_.computeBoundsAndApplyParent(),this.models.push(_),c.model=_}catch(a){if(o.aborted)return;this.fire(new Nd(new Error(`Could not load model ${e} from ${i.uri}`,{cause:a})))}}async load(){this._abortController||(this._abortController=new AbortController);const e=this._abortController.signal,i=[];for(const o in this._options.models){const a=this._options.models[o],c=this._modelsInfo.get(o);if(c&&c.model){c.modelSpec=a;const h=c.model;h.position=a.position!=null?new ui(a.position[0],a.position[1]):new ui(0,0),h.orientation=a.orientation!=null?a.orientation:[0,0,0],jl.applyModelSpecification(h,a),h.computeBoundsAndApplyParent(),this.models.push(h)}else c?c.modelSpec=a:(this._modelsInfo.set(o,{modelSpec:a,model:null}),i.push(this.loadModel(o,a,e)))}i.length!==0?(await Promise.allSettled(i),e.aborted||this.fire(new Lo("data",{dataType:"source",sourceDataType:"metadata"}))):this.loaded()&&this.fire(new Lo("data",{dataType:"source",sourceDataType:"metadata"}))}static arrayFromColorSpecification(e){const i=e;if(i===void 0)return;if(Array.isArray(i))return[i[0],i[1],i[2]];const o=ai.parse(i);return o?[o.r,o.g,o.b]:void 0}static applyModelSpecification(e,i){if(i.nodeOverrides&&jl.convertNodeOverrides(e,i.nodeOverrides),i.materialOverrides&&jl.convertMaterialOverrides(e,i.materialOverrides),i.nodeOverrideNames&&(e.nodeOverrideNames=[...i.nodeOverrideNames]),i.materialOverrideNames&&(e.materialOverrideNames=[...i.materialOverrideNames]),i.featureProperties&&(e.featureProperties=i.featureProperties),i.lightOverrides){const o=i.lightOverrides,a=jl.arrayFromColorSpecification(o["light-ambient-color"]),c=jl.arrayFromColorSpecification(o["light-directional-color"]);e.lightOverrides={ambientIntensity:o["light-ambient-intensity"],ambientColor:a,directionalIntensity:o["light-directional-intensity"],directionalColor:c}}else e.lightOverrides=void 0}static convertNodeOverrides(e,i){if(Array.isArray(i)&&i.every(o=>typeof o=="string")){e.nodeOverrideNames=[];for(const o of i)e.nodeOverrideNames.push(o)}else Object.entries(i).forEach(([o,a])=>{const c={orientation:[0,0,0],minZoom:void 0,maxZoom:void 0};if(Object.hasOwn(a,"orientation")){const h=a.orientation;h&&(c.orientation=h)}Object.hasOwn(a,"minzoom")&&(c.minZoom=a.minzoom),Object.hasOwn(a,"maxzoom")&&(c.maxZoom=a.maxzoom),e.nodeOverrides.set(o,c)})}static convertMaterialOverrides(e,i){if(Array.isArray(i)&&i.every(o=>typeof o=="string")){e.materialOverrideNames=[];for(const o of i)e.materialOverrideNames.push(o)}else Object.entries(i).forEach(([o,a])=>{const c=a["model-color"],h={color:c!==void 0?new ai(c[0],c[1],c[2]):new ai(1,1,1),colorMix:0,emissionStrength:0,opacity:1},f=a["model-color-mix-intensity"];f!==void 0&&(h.colorMix=f);const _=a["model-emissive-strength"];_!==void 0&&(h.emissionStrength=_);const y=a["model-opacity"];y!==void 0&&(h.opacity=y),e.materialOverrides.set(o,h)})}onAdd(e){this.map=e,this.load()}hasTransition(){return!1}loaded(){if(this._modelsInfo.size===0)return!0;for(const e of this._modelsInfo.values())if(e.model==null)return!1;return!0}getModels(){return this.models}loadTile(e,i){}serialize(){return this._options}setProperty(e,i){return!1}reload(){this.cancelModelRequests();const e=Nh(this.id,this.scope);this.map.style.clearSource(e),this.models=[],this._modelsInfo.clear(),this.load()}onRemove(e){this.cancelModelRequests()}setModels(e){this.models=[];const i=new Map;for(const o in e){const a=e[o],c=this._modelsInfo.get(o);c&&c.modelSpec.uri===a.uri&&i.set(o,c)}if(this._modelsInfo.size!==i.size){this.cancelModelRequests();for(const[o,a]of i)a.model||i.delete(o)}this._modelsInfo=i,this._options.models=e,this.load()}}function Ux(r,e,i,o){const a=1<<r.z;e.lat=on((o/rt+r.y)/a),e.lng=$r((i/rt+r.x)/a)}function MT(r,e,i,o){const a=r.getNodesInfo()[e];if(!a||a.hiddenByReplacement||!a.node.meshes)return;let c=Number.MAX_VALUE;const h=a.node,f=i.tile,_=o.calculatePosMatrix(f.tileID.toUnwrapped(),o.worldSize),y=a.evaluatedScale;let v=0;o.elevation&&h.elevation&&(v=h.elevation*o.elevation.exaggeration()),Mn(_,_,[(h.anchor?h.anchor[0]:0)*(y[0]-1),(h.anchor?h.anchor[1]:0)*(y[1]-1),v]),_n(_,_,y);const b=i.queryGeometry,T=b.isPointQuery()?b.screenBounds:b.screenGeometry,E=function(P){const R=Ni([],_,P.globalMatrix);Ni(R,o.expandedFarZProjMatrix,R);for(let z=0;z<P.meshes.length;++z){const V=P.meshes[z];if(z===P.lightMeshIndex)continue;const N=xx(T,o,R,V.aabb);N!=null&&(c=Math.min(N,c))}if(P.children)for(const z of P.children)E(z)};if(E(h),c===Number.MAX_VALUE)return;const C=new ui(0,0);return Ux(f.tileID.canonical,C,a.node.anchor[0],a.node.anchor[1]),{intersectionZ:c,position:C,feature:a.feature}}const PT={circle:class extends Hn{constructor(r,e,i,o){super(r,{layout:L0||(L0=new Vi({"circle-sort-key":new Xe(_e.layout_circle["circle-sort-key"]),"circle-elevation-reference":new We(_e.layout_circle["circle-elevation-reference"]),visibility:new We(_e.layout_circle.visibility)})),paint:z0||(z0=new Vi({"circle-radius":new Xe(_e.paint_circle["circle-radius"]),"circle-color":new Xe(_e.paint_circle["circle-color"]),"circle-blur":new Xe(_e.paint_circle["circle-blur"]),"circle-opacity":new Xe(_e.paint_circle["circle-opacity"]),"circle-translate":new We(_e.paint_circle["circle-translate"]),"circle-translate-anchor":new We(_e.paint_circle["circle-translate-anchor"]),"circle-pitch-scale":new We(_e.paint_circle["circle-pitch-scale"]),"circle-pitch-alignment":new We(_e.paint_circle["circle-pitch-alignment"]),"circle-stroke-width":new Xe(_e.paint_circle["circle-stroke-width"]),"circle-stroke-color":new Xe(_e.paint_circle["circle-stroke-color"]),"circle-stroke-opacity":new Xe(_e.paint_circle["circle-stroke-opacity"]),"circle-emissive-strength":new We(_e.paint_circle["circle-emissive-strength"]),"circle-color-use-theme":new Xe({type:"string",default:"default","property-type":"data-driven"}),"circle-stroke-color-use-theme":new Xe({type:"string",default:"default","property-type":"data-driven"})}))},e,i,o)}createBucket(r){return new Ou(r)}queryRadius(r){const e=r;return Cd("circle-radius",this,e)+Cd("circle-stroke-width",this,e)+Ag(this.paint.get("circle-translate"))}queryIntersectsFeature(r,e,i,o,a,c,h,f){const _=N0(this.paint.get("circle-translate"),this.paint.get("circle-translate-anchor"),c.angle,r.pixelToTileUnitsFactor),y=this.paint.get("circle-radius").evaluate(e,i)+this.paint.get("circle-stroke-width").evaluate(e,i);return U0(r,o,c,h,f,this.paint.get("circle-pitch-alignment")==="map",this.paint.get("circle-pitch-scale")==="map",_,y)}getProgramIds(){return["circle"]}getDefaultProgramParams(r,e,i){const o=V0(this);return{config:new ra(this,{zoom:e,lut:i}),defines:o,overrideFog:!1}}is3D(r){return!r&&!!this.layout&&this.layout.get("circle-elevation-reference")!=="none"}hasElevation(){return this.layout&&this.layout.get("circle-elevation-reference")!=="none"}mayUse(r){return r==="HD"&&Vh(this,"circle-elevation-reference",e=>e==="hd-road-markup")}prepare(){return this.mayUse("HD")?Ig():Promise.resolve()}},heatmap:class extends Hn{createBucket(r){return new G0(r)}constructor(r,e,i,o){super(r,{layout:$0||($0=new Vi({visibility:new We(_e.layout_heatmap.visibility)})),paint:q0||(q0=new Vi({"heatmap-radius":new Xe(_e.paint_heatmap["heatmap-radius"]),"heatmap-weight":new Xe(_e.paint_heatmap["heatmap-weight"]),"heatmap-intensity":new We(_e.paint_heatmap["heatmap-intensity"]),"heatmap-color":new El(_e.paint_heatmap["heatmap-color"]),"heatmap-opacity":new We(_e.paint_heatmap["heatmap-opacity"]),"heatmap-color-use-theme":new Xe({type:"string",default:"default","property-type":"data-driven"})}))},e,i,o),this._updateColorRamp()}_handleSpecialPaintPropertyUpdate(r){r==="heatmap-color"&&this._updateColorRamp()}_updateColorRamp(){this.colorRamp=Vp({expression:this._transitionablePaint._values["heatmap-color"].value.expression,evaluationKey:"heatmapDensity",image:this.colorRamp}),this.colorRampTexture=null}resize(){this.heatmapFbo&&(this.heatmapFbo.destroy(),this.heatmapFbo=null)}_clear(){this.heatmapFbo&&(this.heatmapFbo.destroy(),this.heatmapFbo=null),this.colorRampTexture&&(this.colorRampTexture.destroy(),this.colorRampTexture=null)}queryRadius(r){return Cd("heatmap-radius",this,r)}queryIntersectsFeature(r,e,i,o,a,c,h,f){const _=this.paint.get("heatmap-radius").evaluate(e,i);return U0(r,o,c,h,f,!0,!0,new Ue(0,0),_)}hasOffscreenPass(){return this.paint.get("heatmap-opacity")!==0&&this.visibility!=="none"}getProgramIds(){return["heatmap","heatmapTexture"]}getDefaultProgramParams(r,e,i){return r==="heatmap"?{config:new ra(this,{zoom:e,lut:i}),overrideFog:!1}:{}}},hillshade:class extends Hn{constructor(r,e,i,o){super(r,{layout:H0||(H0=new Vi({visibility:new We(_e.layout_hillshade.visibility)})),paint:Z0||(Z0=new Vi({"hillshade-illumination-direction":new We(_e.paint_hillshade["hillshade-illumination-direction"]),"hillshade-illumination-anchor":new We(_e.paint_hillshade["hillshade-illumination-anchor"]),"hillshade-exaggeration":new We(_e.paint_hillshade["hillshade-exaggeration"]),"hillshade-shadow-color":new We(_e.paint_hillshade["hillshade-shadow-color"]),"hillshade-highlight-color":new We(_e.paint_hillshade["hillshade-highlight-color"]),"hillshade-accent-color":new We(_e.paint_hillshade["hillshade-accent-color"]),"hillshade-emissive-strength":new We(_e.paint_hillshade["hillshade-emissive-strength"]),"hillshade-shadow-color-use-theme":new Xe({type:"string",default:"default","property-type":"data-driven"}),"hillshade-highlight-color-use-theme":new Xe({type:"string",default:"default","property-type":"data-driven"}),"hillshade-accent-color-use-theme":new Xe({type:"string",default:"default","property-type":"data-driven"})}))},e,i,o)}shouldRedrape(){return this.hasOffscreenPass()&&this.paint.get("hillshade-illumination-anchor")==="viewport"}hasOffscreenPass(){return this.paint.get("hillshade-exaggeration")!==0&&this.visibility!=="none"}getProgramIds(){return["hillshade","hillshadePrepare"]}getDefaultProgramParams(r,e,i){return{overrideFog:!1}}},fill:class extends Hn{constructor(r,e,i,o){super(r,{layout:W0||(W0=new Vi({"fill-sort-key":new Xe(_e.layout_fill["fill-sort-key"]),visibility:new We(_e.layout_fill.visibility),"fill-elevation-reference":new We(_e.layout_fill["fill-elevation-reference"]),"fill-construct-bridge-guard-rail":new Xe(_e.layout_fill["fill-construct-bridge-guard-rail"])})),paint:X0||(X0=new Vi({"fill-antialias":new We(_e.paint_fill["fill-antialias"]),"fill-opacity":new Xe(_e.paint_fill["fill-opacity"]),"fill-color":new Xe(_e.paint_fill["fill-color"]),"fill-outline-color":new Xe(_e.paint_fill["fill-outline-color"]),"fill-translate":new We(_e.paint_fill["fill-translate"]),"fill-translate-anchor":new We(_e.paint_fill["fill-translate-anchor"]),"fill-pattern":new Xe(_e.paint_fill["fill-pattern"]),"fill-pattern-cross-fade":new We(_e.paint_fill["fill-pattern-cross-fade"]),"fill-emissive-strength":new We(_e.paint_fill["fill-emissive-strength"]),"fill-z-offset":new Xe(_e.paint_fill["fill-z-offset"]),"fill-bridge-guard-rail-color":new Xe(_e.paint_fill["fill-bridge-guard-rail-color"]),"fill-tunnel-structure-color":new Xe(_e.paint_fill["fill-tunnel-structure-color"]),"fill-color-use-theme":new Xe({type:"string",default:"default","property-type":"data-driven"}),"fill-outline-color-use-theme":new Xe({type:"string",default:"default","property-type":"data-driven"}),"fill-bridge-guard-rail-color-use-theme":new Xe({type:"string",default:"default","property-type":"data-driven"}),"fill-tunnel-structure-color-use-theme":new Xe({type:"string",default:"default","property-type":"data-driven"})}))},e,i,o)}getProgramIds(){const r=this.paint.get("fill-pattern"),e=r&&r.constantOr(1),i=[e?"fillPattern":"fill"];return this.paint.get("fill-antialias")&&i.push(e&&!this.getPaintProperty("fill-outline-color")?"fillOutlinePattern":"fillOutline"),i}getDefaultProgramParams(r,e,i){return{config:new ra(this,{zoom:e,lut:i}),overrideFog:!1}}recalculate(r,e){super.recalculate(r,e);const 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(r){return new hp(r)}queryRadius(){return Ag(this.paint.get("fill-translate"))}queryIntersectsFeature(r,e,i,o,a,c){return!r.queryGeometry.isAboveHorizon&&pp(B0(r.tilespaceGeometry,this.paint.get("fill-translate"),this.paint.get("fill-translate-anchor"),c.angle,r.pixelToTileUnitsFactor),o)}isTileClipped(){return this.paint.get("fill-z-offset").constantOr(1)===0}is3D(r){if(this.paint.get("fill-z-offset").constantOr(1)!==0)return!0;const e=this.layout&&this.layout.get("fill-elevation-reference")!=="none";return r!=null?e&&!r:e}hasElevation(){return this.layout&&this.layout.get("fill-elevation-reference")!=="none"}mayUse(r){return r==="HD"&&Vh(this,"fill-elevation-reference",e=>e!=="none")}prepare(){return this.mayUse("HD")?Ig():Promise.resolve()}hasShadowPass(){return this.layout&&this.layout.get("fill-elevation-reference")!=="none"}},"fill-extrusion":class extends Hn{constructor(r,e,i,o){super(r,{layout:J0||(J0=new Vi({visibility:new We(_e["layout_fill-extrusion"].visibility),"fill-extrusion-edge-radius":new We(_e["layout_fill-extrusion"]["fill-extrusion-edge-radius"]),"source-max-zoom":new We(_e["layout_fill-extrusion"]["source-max-zoom"])})),paint:Q0||(Q0=new Vi({"fill-extrusion-opacity":new We(_e["paint_fill-extrusion"]["fill-extrusion-opacity"]),"fill-extrusion-color":new Xe(_e["paint_fill-extrusion"]["fill-extrusion-color"]),"fill-extrusion-translate":new We(_e["paint_fill-extrusion"]["fill-extrusion-translate"]),"fill-extrusion-translate-anchor":new We(_e["paint_fill-extrusion"]["fill-extrusion-translate-anchor"]),"fill-extrusion-pattern":new Xe(_e["paint_fill-extrusion"]["fill-extrusion-pattern"]),"fill-extrusion-pattern-cross-fade":new We(_e["paint_fill-extrusion"]["fill-extrusion-pattern-cross-fade"]),"fill-extrusion-height":new Xe(_e["paint_fill-extrusion"]["fill-extrusion-height"]),"fill-extrusion-base":new Xe(_e["paint_fill-extrusion"]["fill-extrusion-base"]),"fill-extrusion-height-alignment":new We(_e["paint_fill-extrusion"]["fill-extrusion-height-alignment"]),"fill-extrusion-base-alignment":new We(_e["paint_fill-extrusion"]["fill-extrusion-base-alignment"]),"fill-extrusion-vertical-gradient":new We(_e["paint_fill-extrusion"]["fill-extrusion-vertical-gradient"]),"fill-extrusion-ambient-occlusion-intensity":new We(_e["paint_fill-extrusion"]["fill-extrusion-ambient-occlusion-intensity"]),"fill-extrusion-ambient-occlusion-radius":new We(_e["paint_fill-extrusion"]["fill-extrusion-ambient-occlusion-radius"]),"fill-extrusion-ambient-occlusion-wall-radius":new We(_e["paint_fill-extrusion"]["fill-extrusion-ambient-occlusion-wall-radius"]),"fill-extrusion-ambient-occlusion-ground-radius":new We(_e["paint_fill-extrusion"]["fill-extrusion-ambient-occlusion-ground-radius"]),"fill-extrusion-ambient-occlusion-ground-attenuation":new We(_e["paint_fill-extrusion"]["fill-extrusion-ambient-occlusion-ground-attenuation"]),"fill-extrusion-flood-light-color":new We(_e["paint_fill-extrusion"]["fill-extrusion-flood-light-color"]),"fill-extrusion-flood-light-intensity":new We(_e["paint_fill-extrusion"]["fill-extrusion-flood-light-intensity"]),"fill-extrusion-flood-light-wall-radius":new Xe(_e["paint_fill-extrusion"]["fill-extrusion-flood-light-wall-radius"]),"fill-extrusion-flood-light-ground-radius":new Xe(_e["paint_fill-extrusion"]["fill-extrusion-flood-light-ground-radius"]),"fill-extrusion-flood-light-ground-attenuation":new We(_e["paint_fill-extrusion"]["fill-extrusion-flood-light-ground-attenuation"]),"fill-extrusion-vertical-scale":new We(_e["paint_fill-extrusion"]["fill-extrusion-vertical-scale"]),"fill-extrusion-rounded-roof":new We(_e["paint_fill-extrusion"]["fill-extrusion-rounded-roof"]),"fill-extrusion-cutoff-fade-range":new We(_e["paint_fill-extrusion"]["fill-extrusion-cutoff-fade-range"]),"fill-extrusion-front-cutoff":new We(_e["paint_fill-extrusion"]["fill-extrusion-front-cutoff"]),"fill-extrusion-emissive-strength":new Xe(_e["paint_fill-extrusion"]["fill-extrusion-emissive-strength"]),"fill-extrusion-line-width":new Xe(_e["paint_fill-extrusion"]["fill-extrusion-line-width"]),"fill-extrusion-cast-shadows":new We(_e["paint_fill-extrusion"]["fill-extrusion-cast-shadows"]),"fill-extrusion-color-use-theme":new Xe({type:"string",default:"default","property-type":"data-driven"}),"fill-extrusion-flood-light-color-use-theme":new Xe({type:"string",default:"default","property-type":"data-driven"})}))},e,i,o),this._stats={numRenderedVerticesInShadowPass:0,numRenderedVerticesInTransparentPass:0}}createBucket(r){return new Sg(r)}queryRadius(){return Ag(this.paint.get("fill-extrusion-translate"))}is3D(r){return!0}hasShadowPass(){return this.paint.get("fill-extrusion-cast-shadows")}cutoffRange(){return this.paint.get("fill-extrusion-cutoff-fade-range")}canCastShadows(){return!0}getProgramIds(){return[this.paint.get("fill-extrusion-pattern").constantOr(1)?"fillExtrusionPattern":"fillExtrusion"]}queryIntersectsFeature(r,e,i,o,a,c,h,f,_){const y=N0(this.paint.get("fill-extrusion-translate"),this.paint.get("fill-extrusion-translate-anchor"),c.angle,r.pixelToTileUnitsFactor),v=this.paint.get("fill-extrusion-height").evaluate(e,i),b=this.paint.get("fill-extrusion-base").evaluate(e,i),T=[0,0],E=f&&c.elevation,C=c.elevation?c.elevation.exaggeration():1,P=r.tile.getBucket(this);if(P instanceof Sg){const U=P.centroidData.find(q=>_>=q.vertexArrayOffset&&_<q.vertexArrayOffset+q.vertexCount);if(U&&U.flags&xg)return!1;if(E){const q=P.centroidVertexArray,W=_+1;W<q.length&&(T[0]=q.geta_centroid_pos0(W),T[1]=q.geta_centroid_pos1(W))}}if(T[0]===0&&T[1]===1)return!1;c.projection.name==="globe"&&(o=R0([o],[new Ue(0,0),new Ue(rt,rt)],r.tileID.canonical).map(U=>U.polygon).flat());const R=E?f:null,[z,V]=ab(c,o,b,v,y,h,R,T,C,c.center.lat,r.tileID.canonical),N=r.queryGeometry;return sb(z,V,N.isPointQuery()?N.screenBounds:N.screenGeometry)}},building:class extends Hn{constructor(r,e,i,o){super(r,{layout:eb||(eb=new Vi({visibility:new We(_e.layout_building.visibility),"building-facade":new Xe(_e.layout_building["building-facade"]),"building-facade-floors":new Xe(_e.layout_building["building-facade-floors"]),"building-facade-unit-width":new Xe(_e.layout_building["building-facade-unit-width"]),"building-facade-window":new Xe(_e.layout_building["building-facade-window"]),"building-roof-shape":new Xe(_e.layout_building["building-roof-shape"]),"building-height":new Xe(_e.layout_building["building-height"]),"building-base":new Xe(_e.layout_building["building-base"]),"building-flood-light-wall-radius":new Xe(_e.layout_building["building-flood-light-wall-radius"]),"building-flood-light-ground-radius":new Xe(_e.layout_building["building-flood-light-ground-radius"]),"building-flip-roof-orientation":new Xe(_e.layout_building["building-flip-roof-orientation"])})),paint:tb||(tb=new Vi({"building-opacity":new We(_e.paint_building["building-opacity"]),"building-ambient-occlusion-intensity":new We(_e.paint_building["building-ambient-occlusion-intensity"]),"building-ambient-occlusion-ground-intensity":new We(_e.paint_building["building-ambient-occlusion-ground-intensity"]),"building-ambient-occlusion-ground-radius":new We(_e.paint_building["building-ambient-occlusion-ground-radius"]),"building-ambient-occlusion-ground-attenuation":new We(_e.paint_building["building-ambient-occlusion-ground-attenuation"]),"building-vertical-scale":new We(_e.paint_building["building-vertical-scale"]),"building-cast-shadows":new We(_e.paint_building["building-cast-shadows"]),"building-color":new Xe(_e.paint_building["building-color"]),"building-emissive-strength":new Xe(_e.paint_building["building-emissive-strength"]),"building-facade-emissive-chance":new We(_e.paint_building["building-facade-emissive-chance"]),"building-cutoff-fade-range":new We(_e.paint_building["building-cutoff-fade-range"]),"building-front-cutoff":new We(_e.paint_building["building-front-cutoff"]),"building-flood-light-color":new We(_e.paint_building["building-flood-light-color"]),"building-flood-light-intensity":new We(_e.paint_building["building-flood-light-intensity"]),"building-flood-light-ground-attenuation":new We(_e.paint_building["building-flood-light-ground-attenuation"]),"building-color-use-theme":new Xe({type:"string",default:"default","property-type":"data-driven"}),"building-flood-light-color-use-theme":new Xe({type:"string",default:"default","property-type":"data-driven"})}))},e,i,o),this._stats={numRenderedVerticesInShadowPass:0,numRenderedVerticesInTransparentPass:0}}mayUse(r){return r==="HD"}prepare(){return(async function(){return(function(){if(!yi(self)||Ds!=null||F0!=null)return null;if(Ad!=null)return Ad;const r=fetch(Fr());return Ad=(function(e){let i,o,a,c,h;function f(){i=new Uint8Array(h.buffer),o=new Int16Array(h.buffer),a=new Int32Array(h.buffer),c=new Float32Array(h.buffer)}function _(){throw new Error("Unexpected BuildingGen error.")}const y=()=>{},v={a:{a:_,f:function(b){const T=i.length,E=Math.max(b>>>0,Math.ceil(1.2*T)),C=Math.ceil((E-T)/65536);try{return h.grow(C),f(),!0}catch{return!1}},g:_,b:y,c:y,d:y,e:y}};return(WebAssembly.instantiateStreaming?WebAssembly.instantiateStreaming(e,v):e.then(b=>b.arrayBuffer()).then(b=>WebAssembly.instantiate(b,v))).then(b=>{const T=b.instance.exports;return(0,T.g)(),h=T.f,f(),new pT({setStyle:T.h,setAOOptions:T.i,setMetricOptions:T.j,setStructuralOptions:T.k,setFacadeOptions:T.l,setFauxFacadeOptions:T.m,setFacadeClassifierOptions:T.n,addFeature:T.o,addFacade:T.p,generateMesh:T.q,getLastError:T.r,getOuterRingLength:T.s,getMeshCount:T.t,getPositionsPtr:T.u,getPositionsLength:T.v,getNormalsPtr:T.w,getNormalsLength:T.x,getAOPtr:T.y,getAOLength:T.z,getUVPtr:T.A,getUVLength:T.B,getFauxFacadePtr:T.C,getFauxFacadeLength:T.D,getIndicesPtr:T.E,getIndicesLength:T.F,getBuildingPart:T.G,getRingCount:T.H,getRingPtr:T.I,getRingLength:T.J,malloc:T.K,free:T.L,heapU8:i,heap16:o,heap32:a,heapF32:c})})})(r).then(e=>{Ad=null,Ds=e}).catch(e=>{ht("Could not load building-gen"),Ad=null,F0=e}),Ad})()})()}createBucket(r){return new O0(r)}cutoffRange(){return this.paint.get("building-cutoff-fade-range")}hasShadowPass(){return this.paint.get("building-cast-shadows")}hasLightBeamPass(){return!0}canCastShadows(){return!0}is3D(r){return!0}queryRadius(r){return 0}queryIntersectsFeature(r,e,i,o,a,c,h,f,_,y){let v=this.layout.get("building-height").evaluate(e,i);const b=this.layout.get("building-base").evaluate(e,i),T=r.tile.getBucket(this).getFootprint(e);if(T){if(T.hiddenFlags!==0)return!1;v=T.height}const[E,C]=ab(c,o,b,v,new Ue(0,0),h,null,[0,0],1,c.center.lat,r.tileID.canonical),P=r.queryGeometry;return sb(E,C,P.isPointQuery()?P.screenBounds:P.screenGeometry)}},line:class extends Hn{constructor(r,e,i,o){const a=pb();super(r,a,e,i,o),a.layout&&(this.layout=new Ks(a.layout)),this.gradientVersion=0,this.hasElevatedBuckets=!1,this.hasNonElevatedBuckets=!1,this.lineBlendFbos=null,this.lineBlendDensityReadback=null}_handleSpecialPaintPropertyUpdate(r){if(r==="line-gradient"){const e=this._transitionablePaint._values["line-gradient"].value.expression;this.stepInterpolant=e._styleExpression&&e._styleExpression.expression instanceof ka,this.gradientVersion=(this.gradientVersion+1)%Number.MAX_SAFE_INTEGER}else r==="line-gradient-use-theme"&&(this.gradientVersion=(this.gradientVersion+1)%Number.MAX_SAFE_INTEGER)}gradientExpression(){return this._transitionablePaint._values["line-gradient"].value.expression}widthExpression(){return this._transitionablePaint._values["line-width"].value.expression}emissiveStrengthExpression(){return this._transitionablePaint._values["line-emissive-strength"].value.expression}recalculate(r,e){super.recalculate(r,e),this.paint._values["line-floorwidth"]=(()=>{if(jp)return jp;const i=pb();return jp=new TT(i.paint.properties["line-width"].specification),jp.useIntegerZoom=!0,jp})().possiblyEvaluate(this._transitioningPaint._values["line-width"].value,r)}createBucket(r){return new Dc(r)}getProgramIds(){const r=[this.paint.get("line-pattern").constantOr(1)?"linePattern":"line"];return this.paint.get("line-blend-mode")!=="default"&&r.push("lineBlendComposite"),r}getDefaultProgramParams(r,e,i){if(r==="lineBlendComposite")return{};const o=db(this);return{config:new ra(this,{zoom:e,lut:i}),defines:o,overrideFog:!1}}queryRadius(r){const e=r,i=gb(Cd("line-width",this,e),Cd("line-gap-width",this,e)),o=Cd("line-offset",this,e);return i/2+Math.abs(o)+Ag(this.paint.get("line-translate"))}queryIntersectsFeature(r,e,i,o,a,c){if(r.queryGeometry.isAboveHorizon)return!1;const h=B0(r.tilespaceGeometry,this.paint.get("line-translate"),this.paint.get("line-translate-anchor"),c.angle,r.pixelToTileUnitsFactor),f=r.pixelToTileUnitsFactor/2*gb(this.paint.get("line-width").evaluate(e,i),this.paint.get("line-gap-width").evaluate(e,i)),_=this.paint.get("line-offset").evaluate(e,i);return _&&(o=(function(y,v){const b=[],T=new Ue(0,0);for(let E=0;E<y.length;E++){const C=y[E],P=[];for(let R=0;R<C.length;R++){const z=C[R],V=C[R+1],N=R===0?T:z.sub(C[R-1])._unit()._perp(),U=R===C.length-1?T:V.sub(z)._unit()._perp(),q=N._add(U)._unit();q._mult(1/(q.x*U.x+q.y*U.y)),P.push(q._mult(v)._add(z))}b.push(P)}return b})(o,_*r.pixelToTileUnitsFactor)),(function(y,v,b){for(let T=0;T<v.length;T++){const E=v[T];if(y.length>=3){for(let C=0;C<E.length;C++)if(na(y,E[C]))return!0}if(Ey(y,E,b))return!0}return!1})(h,o,f)}isTileClipped(){return this.hasNonElevatedBuckets}isDraped(r){return!this.hasElevatedBuckets||this.layout&&this.layout.get("line-elevation-reference")==="hd-road-markup"}hasElevation(){return this.layout&&this.layout.get("line-elevation-reference")!=="none"}mayUse(r){return r==="HD"&&Vh(this,"line-elevation-reference",e=>e==="hd-road-markup")}prepare(){return this.mayUse("HD")?Ig():Promise.resolve()}hasOffscreenPass(){return this.paint.get("line-blend-mode")!=="default"&&this.paint.get("line-opacity").constantOr(1)!==0&&this.paint.get("line-width").constantOr(1)!==0&&this.visibility!=="none"}resize(){this._destroyLineBlendFbo()}onRemove(r){this._destroyLineBlendFbo(r.painter&&r.painter.context&&r.painter.context.gl||void 0)}_clear(){this._destroyLineBlendFbo()}_destroyLineBlendFbo(r){this.lineBlendFbos&&(this.lineBlendFbos.destroy(),this.lineBlendFbos=null),r&&this.lineBlendDensityReadback&&this.lineBlendDensityReadback.destroy(r),this.lineBlendDensityReadback=null}},symbol:Cg,background:class extends Hn{constructor(r,e,i,o){super(r,{layout:vb||(vb=new Vi({visibility:new We(_e.layout_background.visibility)})),paint:bb||(bb=new Vi({"background-pitch-alignment":new We(_e.paint_background["background-pitch-alignment"]),"background-color":new We(_e.paint_background["background-color"]),"background-pattern":new We(_e.paint_background["background-pattern"]),"background-opacity":new We(_e.paint_background["background-opacity"]),"background-emissive-strength":new We(_e.paint_background["background-emissive-strength"]),"background-color-use-theme":new Xe({type:"string",default:"default","property-type":"data-driven"})}))},e,i,o)}getProgramIds(){return[this.paint.get("background-pattern")?"backgroundPattern":"background"]}getDefaultProgramParams(r,e,i){return{overrideFog:!1}}is3D(r){return this.paint.get("background-pitch-alignment")==="viewport"}},raster:Sb,"raster-particle":Db,sky:class extends Hn{constructor(r,e,i,o){super(r,{layout:Ab||(Ab=new Vi({visibility:new We(_e.layout_sky.visibility)})),paint:Cb||(Cb=new Vi({"sky-type":new We(_e.paint_sky["sky-type"]),"sky-atmosphere-sun":new We(_e.paint_sky["sky-atmosphere-sun"]),"sky-atmosphere-sun-intensity":new We(_e.paint_sky["sky-atmosphere-sun-intensity"]),"sky-gradient-center":new We(_e.paint_sky["sky-gradient-center"]),"sky-gradient-radius":new We(_e.paint_sky["sky-gradient-radius"]),"sky-gradient":new El(_e.paint_sky["sky-gradient"]),"sky-atmosphere-halo-color":new We(_e.paint_sky["sky-atmosphere-halo-color"]),"sky-atmosphere-color":new We(_e.paint_sky["sky-atmosphere-color"]),"sky-opacity":new We(_e.paint_sky["sky-opacity"]),"sky-gradient-use
7-theme":new Xe({type:"string",default:"default","property-type":"data-driven"}),"sky-atmosphere-halo-color-use-theme":new Xe({type:"string",default:"default","property-type":"data-driven"}),"sky-atmosphere-color-use-theme":new Xe({type:"string",default:"default","property-type":"data-driven"})}))},e,i,o),this._updateColorRamp()}_clear(){this.skyboxFbo&&(this.skyboxFbo.destroy(),this.skyboxFbo=null),this.colorRampTexture&&(this.colorRampTexture.destroy(),this.colorRampTexture=null),this._skyboxInvalidated=!0}_handleSpecialPaintPropertyUpdate(r){r==="sky-gradient"?this._updateColorRamp():r!=="sky-atmosphere-sun"&&r!=="sky-atmosphere-halo-color"&&r!=="sky-atmosphere-color"&&r!=="sky-atmosphere-sun-intensity"||(this._skyboxInvalidated=!0)}_updateColorRamp(){this.colorRamp=Vp({expression:this._transitionablePaint._values["sky-gradient"].value.expression,evaluationKey:"skyRadialProgress"}),this.colorRampTexture&&(this.colorRampTexture.destroy(),this.colorRampTexture=null)}needsSkyboxCapture(r){if(this._skyboxInvalidated||!this.skyboxTexture||!this.skyboxGeometry)return!0;if(!this.paint.get("sky-atmosphere-sun")){const e=r.style.light.properties.get("position");return this._lightPosition.azimuthal!==e.azimuthal||this._lightPosition.polar!==e.polar}return!1}getCenter(r,e){if(this.paint.get("sky-type")==="atmosphere"){const o=this.paint.get("sky-atmosphere-sun"),a=!o,c=r.style.light,h=c.properties.get("position");return a&&c.properties.get("anchor")==="viewport"&&ht("The sun direction is attached to a light with viewport anchor, lighting may behave unexpectedly."),a?Bx(h.azimuthal,90-h.polar,e):Bx(o[0],90-o[1],e)}const i=this.paint.get("sky-gradient-center");return Bx(i[0],90-i[1],e)}isSky(){return!0}markSkyboxValid(r){this._skyboxInvalidated=!1,this._lightPosition=r.style.light.properties.get("position")}hasOffscreenPass(){return!0}getProgramIds(){const r=this.paint.get("sky-type");return r==="atmosphere"?["skyboxCapture","skybox"]:r==="gradient"?["skyboxGradient"]:null}},slot:class extends Hn{constructor(r,e,i,o){super(r,{paint:Mb||(Mb=new Vi({}))},e,null)}},model:class extends Hn{constructor(r,e,i,o){super(r,{layout:Pb||(Pb=new Vi({visibility:new We(_e.layout_model.visibility),"model-id":new Xe(_e.layout_model["model-id"]),"model-allow-density-reduction":new We(_e.layout_model["model-allow-density-reduction"])})),paint:Rb||(Rb=new Vi({"model-opacity":new Xe(_e.paint_model["model-opacity"]),"model-rotation":new Xe(_e.paint_model["model-rotation"]),"model-scale":new Xe(_e.paint_model["model-scale"]),"model-translation":new Xe(_e.paint_model["model-translation"]),"model-color":new Xe(_e.paint_model["model-color"]),"model-color-mix-intensity":new Xe(_e.paint_model["model-color-mix-intensity"]),"model-type":new We(_e.paint_model["model-type"]),"model-cast-shadows":new We(_e.paint_model["model-cast-shadows"]),"model-receive-shadows":new We(_e.paint_model["model-receive-shadows"]),"model-ambient-occlusion-intensity":new We(_e.paint_model["model-ambient-occlusion-intensity"]),"model-emissive-strength":new Xe(_e.paint_model["model-emissive-strength"]),"model-roughness":new Xe(_e.paint_model["model-roughness"]),"model-height-based-emissive-strength-multiplier":new Xe(_e.paint_model["model-height-based-emissive-strength-multiplier"]),"model-cutoff-fade-range":new We(_e.paint_model["model-cutoff-fade-range"]),"model-front-cutoff":new We(_e.paint_model["model-front-cutoff"]),"model-elevation-reference":new We(_e.paint_model["model-elevation-reference"]),"model-line-cutout-mode":new We(_e.paint_model["model-line-cutout-mode"]),"model-color-use-theme":new Xe({type:"string",default:"default","property-type":"data-driven"})}))},e,i,o),this.layer=r,this._stats={numRenderedVerticesInShadowPass:0,numRenderedVerticesInTransparentPass:0}}mayUse(r){return r==="Standard"}prepare(){return(async function(){return Promise.resolve()})()}createBucket(r){return new Nx(r)}getProgramIds(){return["model"]}is3D(r){return!0}hasShadowPass(){return!0}canCastShadows(){return!0}hasLightBeamPass(){return!0}cutoffRange(){return this.paint.get("model-cutoff-fade-range")}queryRadius(r){return r instanceof Dg?8191:0}queryRenderedFeatures(r,e,i){const o=e.getSource();if(!(o&&o instanceof jl))return{};const a=o,c={};c[this.id]=[];const h=c[this.id];let f=0;for(const _ of a.models){const y=e.getFeatureState(this.sourceLayer,_.id),v={type:"Unknown",id:_.id,properties:_.featureProperties},b=this.paint.get("model-rotation").evaluate(v,y),T=this.paint.get("model-scale").evaluate(v,y),E=this.paint.get("model-translation").evaluate(v,y),C=this.paint.get("model-elevation-reference");let P=[];pg(P,_,i,_.position,b,T,E,C==="ground",C==="ground",!1),i.projection.name==="globe"&&(P=fg(P,i));const R=Ni([],i.projMatrix,P),z=xx(r.isPointQuery()?r.screenBounds:r.screenGeometry,i,R,_.aabb);if(z!=null){const V=new $u(void 0,0,0,0,_.id);V.layer=this.layer,V.properties=structuredClone(_.featureProperties),V.properties.layer=this.id,V.properties.uri=_.ur
vendor: 40,185 bytes, line 7
7i,V.properties.orientation=_.orientation,V.sourceLayer=this.sourceLayer,V.geometry={type:"Point",coordinates:[_.position.lng,_.position.lat]},V.state=y,V.source=this.source,h.push({featureIndex:f,feature:V,intersectionZ:z})}++f}return c}queryIntersectsFeature(r,e,i,o,a,c,h,f,_,y){if(!this.modelManager)return!1;const v=this.modelManager,b=r.tile.getBucket(this);if(!(b&&b instanceof Nx))return!1;for(const T in b.instancesPerModel){const E=b.instancesPerModel[T],C=e.id!==void 0?e.id:e.properties&&Object.hasOwn(e.properties,"id")?e.properties.id:void 0;if(Object.hasOwn(E.idToFeaturesIndex,C)){const P=E.features[E.idToFeaturesIndex[C]],R=v.getModel(T,y||this.scope);if(!R)return!1;let z=[];const V=new ui(0,0),N=b.canonical;let U=Number.MAX_VALUE;for(let q=0;q<P.instancedDataCount;++q){const W=16*(P.instancedDataOffset+q),se=E.instancedDataArray.float32,X=[se[W+4],se[W+5],se[W+6]];Ux(N,V,Math.floor(se[W]),Math.floor(se[W+1])),pg(z,R,c,V,P.rotation,P.scale,X,!1,!1,!1),c.projection.name==="globe"&&(z=fg(z,c));const ie=Ni([],c.projMatrix,z),re=r.queryGeometry,oe=xx(re.isPointQuery()?re.screenBounds:re.screenGeometry,c,ie,R.aabb);oe!=null&&(U=Math.min(oe,U))}return U!==Number.MAX_VALUE&&U}}return!1}_handleOverridablePaintPropertyUpdate(r,e,i){return!(!this.layout||e.isDataDriven()||i.isDataDriven()||r!=="model-color"&&r!=="model-color-mix-intensity"&&r!=="model-rotation"&&r!=="model-scale"&&r!=="model-translation"&&r!=="model-emissive-strength")}_isPropertyZoomDependent(r){const e=this._transitionablePaint._values[r];return e!=null&&e.value!=null&&e.value.expression!=null&&e.value.expression instanceof lu}isZoomDependent(){return this._isPropertyZoomDependent("model-scale")||this._isPropertyZoomDependent("model-rotation")||this._isPropertyZoomDependent("model-translation")}},clip:class extends Hn{constructor(r,e,i,o){super(r,{layout:Y0||(Y0=new Vi({"clip-layer-types":new We(_e.layout_clip["clip-layer-types"]),"clip-layer-scope":new We(_e.layout_clip["clip-layer-scope"]),visibility:new We(_e.layout_clip.visibility)})),paint:K0||(K0=new Vi({}))},e,i,o)}recalculate(r,e){super.recalculate(r,e)}createBucket(r){return new nb(r)}is3D(r){return!0}}};class jx{constructor(e){this.capacity=e,this.cache=new Map}get(e){if(!this.cache.has(e))return;const i=this.cache.get(e);return this.cache.delete(e),this.cache.set(e,i),i}put(e,i){this.cache.has(e)?this.cache.delete(e):this.cache.size===this.capacity&&this.cache.delete(this.cache.keys().next().value),this.cache.set(e,i)}delete(e){this.cache.delete(e)}}nt(jx,"LRUCache");class RT{constructor(e){this._callback=e,this._triggered=!1,typeof MessageChannel<"u"&&(this._channel=new MessageChannel,this._channel.port2.onmessage=()=>{this._triggered=!1,this._callback()})}trigger(){this._triggered||(this._triggered=!0,this._channel?this._channel.port1.postMessage(!0):setTimeout(()=>{this._triggered=!1,this._callback()},0))}remove(){this._channel&&(this._channel.port1.close(),this._channel.port2.close()),this._callback=()=>{}}}const Vb={Other:0,Symbol:1,FillExtrusion:2,HdRoadCoverage:3,HdRoadElevation:4};class DT{constructor(){this.tasks=new Map,ve(["process"],this),this.invoker=new RT(this.process),this.nextId=0}add(e,i){const o=this.nextId++,a=(function({type:c,renderSourceType:h,zoom:f}){f=f||0;const _=h===Vb.Symbol;return c==="message"?0:c!=="maybePrepare"||_?c!=="parseTile"||_?c==="parseTile"&&_?300-f:c==="maybePrepare"&&_?400-f:500:200-f:100-f})(i);if(a===0){try{e()}finally{}return null}return this.tasks.set(o,{fn:e,metadata:i,priority:a,id:o}),this.invoker.trigger(),{cancel:()=>{this.tasks.delete(o)}}}process(){try{const e=this.pick();if(!e)return;this.tasks.delete(e.id),this.tasks.size>0&&this.invoker.trigger(),e.fn()}finally{}}pick(){let e=null,i=1/0;for(const o of this.tasks.values())o.priority<i&&(i=o.priority,e=o);return e}remove(){this.tasks.clear(),this.invoker.remove()}}const Ub={type:"message"};class jb{constructor(e){this._stringToNumber={},this._numberToString=[];for(let i=0;i<e.length;i++){const o=e[i];this._stringToNumber[o]=i,this._numberToString[i]=o}}encode(e){return this._stringToNumber[e]}decode(e){return this._numberToString[e]}}class Gb{constructor(e,i){this.tileID=e,this.x=e.canonical.x,this.y=e.canonical.y,this.z=e.canonical.z,this.grid=new vc(rt,rt,512),this.featureIndexArray=new Au,this.promoteId=i,this.is3DTile=!1,this.serializedLayersCache=new Map}insert(e,i,o,a,c,h=0,f=0){const _=this.featureIndexArray.length;this.featureIndexArray.emplaceBack(o,a,c,h);const y=this.grid;for(let v=0;v<i.length;v++){const b=i[v],T=[1/0,1/0,-1/0,-1/0];for(let E=0;E<b.length;E++){const C=b[E];T[0]=Math.min(T[0],C.x),T[1]=Math.min(T[1],C.y),T[2]=Math.max(T[2],C.x),T[3]=Math.max(T[3],C.y)}f!==0&&(T[0]-=f,T[1]-=f,T[2]+=f,T[3]+=f),T[0]<rt&&T[1]<rt&&T[2]>=0&&T[3]>=0&&y.insert(_,T[0],T[1],T[2],T[3])}}loadVTLayers(){if(!this.vtLayers){this.vtLayers=new fp(new bp(this.rawTileData)).layers,this.sourceLayerCoder=new jb(this.vtLayers?Object.keys(this.vtLayers).sort():["_geojsonTileLayer"]),this.vtFeatures={};for(const e in this.vtLayers)this.vtFeatures[e]=[]}return this.vtLayers}query(e,i){const{tilespaceGeometry:o,transform:a,tileTransform:c,pixelPosMatrix:h,availableImages:f,worldview:_}=i;this.loadVTLayers(),this.serializedLayersCache.clear();const y=i.queryRadius?i.queryRadius:0,v=o.bufferedTilespaceBounds,b=this.grid.queryKeys(v.min.x,v.min.y,v.max.x,v.max.y,(P,R,z,V)=>Fu(o.bufferedTilespaceGeometry,P-y,R-y,z+y,V+y));b.sort(LT);let T=null;a.elevation&&b.length>0&&(T=Md.create(a.elevation,this.tileID));const E={};let C;for(let P=0;P<b.length;P++){const R=b[P];if(R===C)continue;C=R;const z=this.featureIndexArray.get(R);let V=null;this.is3DTile?this.loadMatchingModelFeature(E,z,e,o,a,_):this.loadMatchingFeature(E,z,e,f,_,(N,U,q,W=0)=>(V||(V=ls(N,this.tileID.canonical,c)),U.queryIntersectsFeature(o,N,q,V,this.z,a,h,T,W,i.scope)))}return E}loadMatchingFeature(e,i,o,a,c,h){const{featureIndex:f,bucketIndex:_,sourceLayerIndex:y,layoutVertexArrayOffset:v}=i,b=this.bucketLayerIDs[_],T=o.layers,E=Object.keys(T);if(E.length&&!et(E,b))return;const C=o.sourceCache,P=this.sourceLayerCoder.decode(y),R=this.vtLayers[P].feature(f),z=this.getId(R,P);for(let V=0;V<b.length;V++){const N=b[V];if(!T[N])continue;const{styleLayer:U,targets:q}=T[N];let W={};z!==void 0&&(W=C.getFeatureState(U.sourceLayer,z));const se=!h||h(R,U,W,v);if(!se)continue;const X=new $u(R,this.z,this.x,this.y,z);X.tile=this.tileID.canonical,X.state=W;let ie=this.serializedLayersCache.get(N);ie||(ie=U.serialize(),ie.id=N,this.serializedLayersCache.set(N,ie)),X.source=ie.source,X.sourceLayer=ie["source-layer"],X.layer={...ie},X.layer.paint=$b(ie.paint,U.paint,R,W,a),X.layer.layout=$b(ie.layout,U.layout,R,W,a);const re=new xt(this.tileID.overscaledZ,{worldview:c});let oe=!1;for(const me of q){this.updateFeatureProperties(X,me);const{filter:xe}=me;if(xe){if(R.properties=X.properties,xe.needGeometry){const we=Vo(R,!0);if(!xe.filter(re,we,this.tileID.canonical))continue}else if(!xe.filter(re,R))continue}oe=!0,me.targetId&&this.addFeatureVariant(X,me)}oe&&this.appendToResult(e,N,f,X,se)}}loadMatchingModelFeature(e,i,o,a,c,h){const{featureIndex:f,bucketIndex:_}=i,y=this.bucketLayerIDs[_],v=o.layers,b=Object.keys(v);if(!b.length||et(b,y))for(let T=0;T<y.length;T++){const E=y[T],{styleLayer:C,targets:P}=v[E];if(C.type!=="model")continue;const R=a.tile,z=R.getBucket(C);if(!(z&&z instanceof Dg))continue;const V=MT(z,f,a,c);if(!V)continue;const{z:N,x:U,y:q}=R.tileID.canonical,{feature:W,intersectionZ:se,position:X}=V;let ie={};W.id!==void 0&&(ie=o.sourceCache.getFeatureState(C.sourceLayer,W.id));const re=new $u({},N,U,q,W.id);re.tile=this.tileID.canonical,re.state=ie,re.properties=W.properties,re.geometry={type:"Point",coordinates:[X.lng,X.lat]};let oe=this.serializedLayersCache.get(E);oe||(oe=C.serialize(),oe.id=E,this.serializedLayersCache.set(E,oe)),re.source=oe.source,re.sourceLayer=oe["source-layer"],re.layer={...oe};const me=new xt(this.tileID.overscaledZ,{worldview:h});let xe=!1;for(const we of P){this.updateFeatureProperties(re,we);const{filter:Ce}=we;if(Ce){if(W.properties=re.properties,Ce.needGeometry){if(!Ce.filter(me,W,this.tileID.canonical))continue}else if(!Ce.filter(me,W))continue}xe=!0,we.targetId&&this.addFeatureVariant(re,we)}xe&&this.appendToResult(e,E,f,re,se)}}updateFeatureProperties(e,i,o){if(i.properties){const a={};for(const c in i.properties){const h=i.properties[c].evaluate({zoom:this.z},e._vectorTileFeature,e.state,e.tile,o);h!=null&&(a[c]=h)}e.properties=a}}addFeatureVariant(e,i,o){const a={target:i.target,namespace:i.namespace,uniqueFeatureID:i.uniqueFeatureID};i.properties&&(a.properties=e.properties),e.variants=e.variants||{},e.variants[i.targetId]=e.variants[i.targetId]||[],e.variants[i.targetId].push(a)}appendToResult(e,i,o,a,c){let h=e[i];h===void 0&&(h=e[i]=[]),h.push({featureIndex:o,feature:a,intersectionZ:c})}lookupSymbolFeatures(e,i,o,a,c,h){const f={};this.loadVTLayers();for(const _ of e)this.loadMatchingFeature(f,{bucketIndex:i,sourceLayerIndex:o,featureIndex:_,layoutVertexArrayOffset:0},a,c,h);return f}loadFeature(e){const{featureIndex:i,sourceLayerIndex:o}=e;this.loadVTLayers();const a=this.sourceLayerCoder.decode(o),c=this.vtFeatures[a];if(c[i])return c[i];const h=this.vtLayers[a].feature(i);return c[i]=h,h}hasLayer(e){for(const i of this.bucketLayerIDs)for(const o of i)if(e===o)return!0;return!1}getId(e,i){let o=e.id;if(this.promoteId){const a=Array.isArray(this.promoteId)||typeof this.promoteId!="object"?this.promoteId:this.promoteId[i];if(a!=null)if(Array.isArray(a)){if(!this.promoteIdExpression){const c=xc(a);if(c.result!=="success"){const h=c.value.map(f=>`${f.key}: ${f.message}`).join(", ");return void ht(`Failed to create expression for promoteId: ${h}`)}this.promoteIdExpression=c.value}o=this.promoteIdExpression.evaluate({zoom:0},e)}else o=e.properties[a];typeof o=="boolean"&&(o=Number(o))}return o}}function $b(r,e,i,o,a){return Le(r,(c,h)=>{const f=e instanceof Ks?e.get(h):null;return f&&f.evaluate?f.evaluate(i,o,void 0,a):f})}function LT(r,e){return e-r}function zT(r,e){const i={};let o;for(;o=r.nextField(e);)o===1?(i.delta_filter=FT(r,r.readVarint()+r.pos),i.filter="delta_filter"):o===2?(r.readVarint(),i.filter="zigzag_filter"):o===3?(r.readVarint(),i.filter="bitshuffle_filter"):o===4&&(r.readVarint(),i.filter="byteshuffle_filter");return i}function FT(r,e){const i={blockSize:0};let o;for(;o=r.nextField(e);)o===1&&(i.blockSize=r.readVarint());return i}function OT(r,e){const i={};let o;for(;o=r.nextField(e);)o===1?(r.readVarint(),i.codec="gzip_data"):o===2?(r.readVarint(),i.codec="jpeg_image"):o===3?(r.readVarint(),i.codec="webp_image"):o===4&&(r.readVarint(),i.codec="png_image");return i}function kT(r,e){const i={firstByte:0,lastByte:0,filters:[],codec:null,offset:0,scale:0,bands:[]};let o,a=0,c=0;for(;o=r.nextField(e);)o===1?i.firstByte=r.readFixed64():o===2?i.lastByte=r.readFixed64():o===3?i.filters.push(zT(r,r.readVarint()+r.pos)):o===4?i.codec=OT(r,r.readVarint()+r.pos):o===5?c=r.readFloat():o===6?a=r.readFloat():o===7?i.bands.push(r.readString()):o===8?i.offset=r.readDouble():o===9&&(i.scale=r.readDouble());return i.offset===0&&(i.offset=c),i.scale===0&&(i.scale=a),i}function BT(r,e){const i={version:0,name:"",units:"",tileSize:0,buffer:0,pixelFormat:0,dataIndex:[]};let o;for(;o=r.nextField(e);)o===1?i.version=r.readVarint():o===2?i.name=r.readString():o===3?i.units=r.readString():o===4?i.tileSize=r.readVarint():o===5?i.buffer=r.readVarint():o===6?i.pixelFormat=r.readVarint():o===7&&i.dataIndex.push(kT(r,r.readVarint()+r.pos));return i}function NT(r,e,i){let o;for(;o=r.nextField(e);)if(o===1){let a=0;const c=r.readVarint()+r.pos;for(;r.pos<c;)i[a++]=r.readVarint()}return i}function VT(r,e){if(e.length!==4)throw new Error(`Expected data of dimension 4 but got ${e.length}.`);let i=e[3];for(let o=2;o>=1;o--){const a=o===1?1:0,c=o===2?1:0;for(let h=0;h<e[0];h++){const f=e[1]*h;for(let _=a;_<e[1];_++){const y=e[2]*(_+f);for(let v=c;v<e[2];v++){const b=e[3]*(v+y);for(let T=0;T<e[3];T++){const E=b+T;r[E]+=r[E-i]}}}}i*=e[o]}return r}function UT(r){for(let e=0,i=r.length;e<i;e++)r[e]=r[e]>>>1^-(1&r[e]);return r}function jT(r,e){switch(e){case"uint32":return r;case"uint16":for(let i=0;i<r.length;i+=2){const o=r[i],a=r[i+1];r[i]=(240&o)>>4|(61440&o)>>8|(240&a)<<4|61440&a,r[i+1]=15&o|(3840&o)>>4|(15&a)<<8|(3840&a)<<4}return r;case"uint8":for(let i=0;i<r.length;i+=4){const o=r[i],a=r[i+1],c=r[i+2],h=r[i+3];r[i+0]=(192&o)>>6|(192&a)>>4|(192&c)>>2|192&h,r[i+1]=(48&o)>>4|(48&a)>>2|48&c|(48&h)<<2,r[i+2]=(12&o)>>2|12&a|(12&c)<<2|(12&h)<<4,r[i+3]=3&o|(3&a)<<2|(3&c)<<4|(3&h)<<6}return r;default:throw new Error(`Invalid pixel format, "${e}"`)}}nt(Gb,"FeatureIndex",{omit:["rawTileData","sourceLayerCoder"]});var Ls=Uint8Array,$p=Uint16Array,GT=Int32Array,qb=new Ls([0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0,0,0,0]),Hb=new Ls([0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13,0,0]),$T=new Ls([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),Zb=function(r,e){for(var i=new $p(31),o=0;o<31;++o)i[o]=e+=1<<r[o-1];var a=new GT(i[30]);for(o=1;o<30;++o)for(var c=i[o];c<i[o+1];++c)a[c]=c-i[o]<<5|o;return{b:i,r:a}},Wb=Zb(qb,2),Xb=Wb.b,qT=Wb.r;Xb[28]=258,qT[258]=28;for(var HT=Zb(Hb,0).b,Yb=new $p(32768),Br=0;Br<32768;++Br){var Pd=(43690&Br)>>1|(21845&Br)<<1;Yb[Br]=((65280&(Pd=(61680&(Pd=(52428&Pd)>>2|(13107&Pd)<<2))>>4|(3855&Pd)<<4))>>8|(255&Pd)<<8)>>1}var qp=function(r,e,i){for(var o=r.length,a=0,c=new $p(e);a<o;++a)r[a]&&++c[r[a]-1];var h,f=new $p(e);for(a=1;a<e;++a)f[a]=f[a-1]+c[a-1]<<1;h=new $p(1<<e);var _=15-e;for(a=0;a<o;++a)if(r[a])for(var y=a<<4|r[a],v=e-r[a],b=f[r[a]-1]++<<v,T=b|(1<<v)-1;b<=T;++b)h[Yb[b]>>_]=y;return h},Hp=new Ls(288);for(Br=0;Br<144;++Br)Hp[Br]=8;for(Br=144;Br<256;++Br)Hp[Br]=9;for(Br=256;Br<280;++Br)Hp[Br]=7;for(Br=280;Br<288;++Br)Hp[Br]=8;var Kb=new Ls(32);for(Br=0;Br<32;++Br)Kb[Br]=5;var ZT=qp(Hp,9),WT=qp(Kb,5),Gx=function(r){for(var e=r[0],i=1;i<r.length;++i)r[i]>e&&(e=r[i]);return e},wa=function(r,e,i){var o=e/8|0;return(r[o]|r[o+1]<<8)>>(7&e)&i},$x=function(r,e){var i=e/8|0;return(r[i]|r[i+1]<<8|r[i+2]<<16)>>(7&e)},XT=function(r){return(r+7)/8|0},YT=["unexpected EOF","invalid block type","invalid length/literal","invalid distance","stream finished","no stream handler",,"no callback","invalid UTF-8 data","extra field too long","date not in range 1980-2099","filename too long","stream finishing","invalid zip data"],Ta=function(r,e,i){var o=new Error(e||YT[r]);if(o.code=r,Error.captureStackTrace&&Error.captureStackTrace(o,Ta),!i)throw o;return o},KT=new Ls(0),JT=typeof TextDecoder<"u"&&new TextDecoder;try{JT.decode(KT,{stream:!0})}catch{}const QT={gzip_data:"gzip"};class oa extends Error{constructor(e){super(e),this.name="MRTError"}}const eS={0:"uint32",1:"uint32",2:"uint16",3:"uint8"},Jb={uint32:1,uint16:2,uint8:4},tS={uint32:Uint32Array,uint16:Uint16Array,uint8:Uint8Array};let qx;class Lg{constructor(e=5){this.x=NaN,this.y=NaN,this.z=NaN,this.layers={},this._cacheSize=e}getLayer(e){const i=this.layers[e];if(!i)throw new oa(`Layer '${e}' not found`);return i}getHeaderLength(e){const i=new Uint8Array(e),o=new DataView(e);if(i[0]!==13)throw new oa("File is not a valid MRT.");return o.getUint32(1,!0)}parseHeader(e){const i=new Uint8Array(e),o=this.getHeaderLength(e);if(i.length<o)throw new oa(`Expected header with length >= ${o} but got buffer of length ${i.length}`);const a=(function(c){const h={headerLength:0,x:0,y:0,z:0,layers:[]};let f;for(;f=c.nextField(void 0);)f===1?h.headerLength=c.readFixed32():f===2?h.x=c.readVarint():f===3?h.y=c.readVarint():f===4?h.z=c.readVarint():f===5&&h.layers.push(BT(c,c.readVarint()+c.pos));return h})(new qx(i.subarray(0,o)));if(!isNaN(this.x)&&(this.x!==a.x||this.y!==a.y||this.z!==a.z))throw new oa(`Invalid attempt to parse header ${a.z}/${a.x}/${a.y} for tile ${this.z}/${this.x}/${this.y}`);this.x=a.x,this.y=a.y,this.z=a.z;for(const c of a.layers)this.layers[c.name]=new Qb(c,{cacheSize:this._cacheSize});return this}createDecodingTask(e){const i=[],o=this.getLayer(e.layerName);for(let a of e.blockIndices){const c=o.dataIndex[a],h=c.firstByte-e.firstByte,f=c.lastByte-e.firstByte;if(o._blocksInProgress.has(a))continue;const _={layerName:o.name,firstByte:h,lastByte:f,pixelFormat:o.pixelFormat,blockIndex:a,blockShape:[c.bands.length].concat(o.bandShape),buffer:o.buffer,codec:c.codec.codec,filters:c.filters.map(y=>y.filter)};o._blocksInProgress.add(a),i.push(_)}return new e1(i,()=>{i.forEach(a=>o._blocksInProgress.delete(a.blockIndex))},(a,c)=>{if(i.forEach(h=>o._blocksInProgress.delete(h.blockIndex)),a)throw a;c.forEach(h=>{this.getLayer(h.layerName).processDecodedData(h)})})}}class Qb{constructor({version:e,name:i,units:o,tileSize:a,pixelFormat:c,buffer:h,dataIndex:f},_){if(this.version=e,this.version!==1)throw new oa(`Cannot parse raster layer encoded with MRT version ${e}`);this.name=i,this.units=o,this.tileSize=a,this.buffer=h,this.pixelFormat=eS[c],this.dataIndex=f,this.bandShape=[a+2*h,a+2*h,Jb[this.pixelFormat]],this._decodedBlocks=new jx(_?_.cacheSize:5),this._blocksInProgress=new Set}get dimension(){return Jb[this.pixelFormat]}get cacheSize(){return this._decodedBlocks.capacity}getBandList(){return this.dataIndex.map(({bands:e})=>e).flat()}processDecodedData(e){const i=e.blockIndex.toString();this._decodedBlocks.get(i)||this._decodedBlocks.put(i,e.data)}getBlockForBand(e){let i=0;switch(typeof e){case"string":for(const[o,a]of this.dataIndex.entries()){for(const[c,h]of a.bands.entries())if(h===e)return{bandIndex:i+c,blockIndex:o,blockBandIndex:c};i+=a.bands.length}break;case"number":for(const[o,a]of this.dataIndex.entries()){if(e>=i&&e<i+a.bands.length)return{bandIndex:e,blockIndex:o,blockBandIndex:e-i};i+=a.bands.length}break;default:throw new oa(`Invalid band \`${JSON.stringify(e)}\`. Expected string or integer.`)}return{blockIndex:-1,blockBandIndex:-1}}getDataRange(e){let i=1/0,o=-1/0;const a=[],c=new Set;for(const h of e){const{blockIndex:f}=this.getBlockForBand(h);if(f<0)throw new oa(`Invalid band: ${JSON.stringify(h)}`);const _=this.dataIndex[f];a.includes(f)||a.push(f),c.add(f),i=Math.min(i,_.firstByte),o=Math.max(o,_.lastByte)}if(c.size>this.cacheSize)throw new oa(`Number of blocks to decode (${c.size}) exceeds cache size (${this.cacheSize}).`);return{layerName:this.name,firstByte:i,lastByte:o,blockIndices:a}}hasBand(e){const{blockIndex:i}=this.getBlockForBand(e);return i>=0}hasDataForBand(e){const{blockIndex:i}=this.getBlockForBand(e);return i>=0&&!!this._decodedBlocks.get(i.toString())}getBandView(e){const{blockIndex:i,blockBandIndex:o}=this.getBlockForBand(e);if(i<0)throw new oa(`Band not found: ${JSON.stringify(e)}`);const a=this._decodedBlocks.get(i.toString());if(!a)throw new oa(`Data for band ${JSON.stringify(e)} of layer "${this.name}" not decoded.`);const c=this.dataIndex[i],h=this.bandShape.reduce((y,v)=>y*v,1),f=o*h,_=a.subarray(f,f+h);return{data:_,bytes:new Uint8Array(_.buffer).subarray(_.byteOffset,_.byteOffset+_.byteLength),tileSize:this.tileSize,buffer:this.buffer,pixelFormat:this.pixelFormat,dimension:this.dimension,offset:c.offset,scale:c.scale}}}Lg.setPbf=function(r){qx=r};class e1{constructor(e,i,o){this.tasks=e,this._onCancel=i,this._onComplete=o,this._finalized=!1}cancel(){this._finalized||(this._onCancel(),this._finalized=!0)}complete(e,i){this._finalized||(this._onComplete(e,i),this._finalized=!0)}}function t1(r,e,i){try{e=(function(a){if(!a.variants)return a;if(!Array.isArray(a.variants))throw new Error("variants must be an array");for(const c of a.variants){if(c==null||typeof c!="object"||c.constructor!==Object)throw new Error("variant must be an object");if(!Array.isArray(c.capabilities))throw new Error("capabilities must be an array");if(c.capabilities.length===1&&c.capabilities[0]==="meshopt")return Object.assign(a,c)}return a})(e)}catch(a){return new Error("Failed to process TileJSON variants",{cause:a})}const o=ne({...e,...r},["tilejson","tiles","minzoom","maxzoom","attribution","mapbox_logo","bounds","extra_bounds","scheme","tileSize","encoding","vector_layers","raster_layers","worldview_options","worldview_default","worldview"]);return r.url&&e.tiles&&r.tiles&&(o.tiles=e.tiles),o.tiles=i.canonicalizeTileset(o,r.url),o}Lg.performDecoding=function(r,e){const i=new Uint8Array(r);return Promise.all(e.tasks.map(o=>{const{layerName:a,firstByte:c,lastByte:h,pixelFormat:f,blockShape:_,blockIndex:y,filters:v,codec:b}=o,T=i.subarray(c,h+1),E=new Uint32Array(_[0]*_[1]*_[2]);let C;if(b!=="gzip_data")throw new oa(`Unhandled codec: ${b}`);return C=(function(P,R){if(!globalThis.DecompressionStream&&R==="gzip_data")return Promise.resolve((q=(function(X){X[0]==31&&X[1]==139&&X[2]==8||Ta(6,"invalid gzip data");var ie=X[3],re=10;4&ie&&(re+=2+(X[10]|X[11]<<8));for(var oe=(ie>>3&1)+(ie>>4&1);oe>0;oe-=!X[re++]);return re+(2&ie)})(z=P),q+8>z.length&&Ta(6,"invalid gzip data"),(function(X,ie,re,oe){var me=X.length;if(!me||ie.f&&!ie.l)return re||new Ls(0);var xe=!re,we=xe||ie.i!=2,Ce=ie.i;xe&&(re=new Ls(3*me));var Se=function(Di){var vr=re.length;if(Di>vr){var Rr=new Ls(Math.max(2*vr,Di));Rr.set(re),re=Rr}},qe=ie.f||0,Me=ie.p||0,Ie=ie.b||0,Pe=ie.l,Ne=ie.d,ke=ie.m,$e=ie.n,ze=8*me;do{if(!Pe){qe=wa(X,Me,1);var He=wa(X,Me+1,3);if(Me+=3,!He){var Ye=X[(qt=XT(Me)+4)-4]|X[qt-3]<<8,st=qt+Ye;if(st>me){Ce&&Ta(0);break}we&&Se(Ie+Ye),re.set(X.subarray(qt,st),Ie),ie.b=Ie+=Ye,ie.p=Me=8*st,ie.f=qe;continue}if(He==1)Pe=ZT,Ne=WT,ke=9,$e=5;else if(He==2){var Je=wa(X,Me,31)+257,Qe=wa(X,Me+10,15)+4,dt=Je+wa(X,Me+5,31)+1;Me+=14;for(var wt=new Ls(dt),Bt=new Ls(19),lt=0;lt<Qe;++lt)Bt[$T[lt]]=wa(X,Me+3*lt,7);Me+=3*Qe;var Et=Gx(Bt),Rt=(1<<Et)-1,ki=qp(Bt,Et);for(lt=0;lt<dt;){var qt,ni=ki[wa(X,Me,Rt)];if(Me+=15&ni,(qt=ni>>4)<16)wt[lt++]=qt;else{var _i=0,$i=0;for(qt==16?($i=3+wa(X,Me,3),Me+=2,_i=wt[lt-1]):qt==17?($i=3+wa(X,Me,7),Me+=3):qt==18&&($i=11+wa(X,Me,127),Me+=7);$i--;)wt[lt++]=_i}}var Ir=wt.subarray(0,Je),gi=wt.subarray(Je);ke=Gx(Ir),$e=Gx(gi),Pe=qp(Ir,ke),Ne=qp(gi,$e)}else Ta(1);if(Me>ze){Ce&&Ta(0);break}}we&&Se(Ie+131072);for(var Ri=(1<<ke)-1,mr=(1<<$e)-1,ln=Me;;ln=Me){var hr=(_i=Pe[$x(X,Me)&Ri])>>4;if((Me+=15&_i)>ze){Ce&&Ta(0);break}if(_i||Ta(2),hr<256)re[Ie++]=hr;else{if(hr==256){ln=Me,Pe=null;break}var zt=hr-254;hr>264&&(zt=wa(X,Me,(1<<(Zr=qb[lt=hr-257]))-1)+Xb[lt],Me+=Zr);var yr=Ne[$x(X,Me)&mr],Tn=yr>>4;if(yr||Ta(3),Me+=15&yr,gi=HT[Tn],Tn>3){var Zr=Hb[Tn];gi+=$x(X,Me)&(1<<Zr)-1,Me+=Zr}if(Me>ze){Ce&&Ta(0);break}we&&Se(Ie+131072);var Wr=Ie+zt;if(Ie<gi){var er=0-gi,Bi=Math.min(gi,Wr);for(er+Ie<0&&Ta(3);Ie<Bi;++Ie)re[Ie]=oe[er+Ie]}for(;Ie<Wr;++Ie)re[Ie]=re[Ie-gi]}}ie.l=Pe,ie.p=ln,ie.b=Ie,ie.f=qe,Pe&&(qe=1,ie.m=ke,ie.d=Ne,ie.n=$e)}while(!qe);return Ie!=re.length&&xe?(function(Di,vr,Rr){return(Rr==null||Rr>Di.length)&&(Rr=Di.length),new Ls(Di.subarray(0,Rr))})(re,0,Ie):re.subarray(0,Ie)})(z.subarray(q,-8),{i:2},new Ls(((N=z)[(U=N.length)-4]|N[U-3]<<8|N[U-2]<<16|N[U-1]<<24)>>>0),V)));var z,V,N,U,q;const W=QT[R];if(!W)throw new Error(`Unhandled codec: ${R}`);const se=new globalThis.DecompressionStream(W);return new Response(new Blob([P]).stream().pipeThrough(se)).arrayBuffer().then(X=>new Uint8Array(X))})(T,b).then(P=>((function(R,z){let V;for(;V=R.nextField();)if(V===2)NT(R,R.readVarint()+R.pos,z);else if(V===3)throw new Error("Not implemented")})(new qx(P),E),new tS[f](E.buffer))),C.then(P=>{for(let R=v.length-1;R>=0;R--)switch(v[R]){case"delta_filter":VT(P,_);break;case"zigzag_filter":UT(P);break;case"bitshuffle_filter":jT(P,f);break;default:throw new oa(`Unhandled filter "${v[R]}"`)}return{layerName:a,blockIndex:y,data:P}}).catch(P=>{throw P})}))},nt(e1,"MRTDecodingBatch",{omit:["_onCancel","_onComplete"]}),nt(Lg,"MapboxRasterTile"),nt(Qb,"MapboxRasterLayer",{omit:["_blocksInProgress"]});const Hx=new Map,i1=new Map;class r1{constructor(e){this.size=e,this.minimums=[],this.maximums=[],this.leaves=[]}getElevation(e,i){const o=this.toIdx(e,i);return{min:this.minimums[o],max:this.maximums[o]}}isLeaf(e,i){return this.leaves[this.toIdx(e,i)]}toIdx(e,i){return i*this.size+e}}function n1(r,e,i,o){let a=0,c=Number.MAX_VALUE;for(let h=0;h<3;h++)if(Math.abs(o[h])<1e-15){if(i[h]<r[h]||i[h]>e[h])return null}else{const f=1/o[h];let _=(r[h]-i[h])*f,y=(e[h]-i[h])*f;if(_>y){const v=_;_=y,y=v}if(_>a&&(a=_),y<c&&(c=y),a>c)return null}return a}function o1(r,e,i,o,a,c,h,f,_,y,v){const b=o-r,T=a-e,E=c-i,C=h-r,P=f-e,R=_-i,z=v[1]*R-v[2]*P,V=v[2]*C-v[0]*R,N=v[0]*P-v[1]*C,U=b*z+T*V+E*N;if(Math.abs(U)<1e-15)return null;const q=1/U,W=y[0]-r,se=y[1]-e,X=y[2]-i,ie=(W*z+se*V+X*N)*q;if(ie<0||ie>1)return null;const re=se*E-X*T,oe=X*b-W*E,me=W*T-se*b,xe=(v[0]*re+v[1]*oe+v[2]*me)*q;return xe<0||ie+xe>1?null:(C*re+P*oe+R*me)*q}function s1(r,e,i,o,a,c,h,f,_){const y=1<<i,v=c-o,b=h-a,T=(r+1)/y*v+o,E=(e+0)/y*b+a,C=(e+1)/y*b+a;f[0]=(r+0)/y*v+o,f[1]=E,_[0]=T,_[1]=C}class a1{constructor(e){if(this.maximums=[],this.minimums=[],this.leaves=[],this.childOffsets=[],this.nodeCount=0,this.dem=e,this._siblingOffset=[[0,0],[1,0],[0,1],[1,1]],!this.dem)return;const i=(function(c){const h=c.dim,f=Math.ceil(Math.log2(h/8)),_=[];let y=Math.ceil(Math.pow(2,f));const v=(R,z,V,N,U)=>{const q=N?1:0,W=(R+1)*V-q,se=z*V,X=(z+1)*V-q;U[0]=R*V,U[1]=se,U[2]=W,U[3]=X};let b=new r1(y);const T=1/y,{floatView:E,stride:C}=c,P=[];for(let R=0;R<y*y;R++){const z=Math.floor(R/y),V=R%y;v(V,z,T,!1,P);const N=Nc(P[0],P[1],c),U=Nc(P[2],P[1],c),q=Nc(P[2],P[3],c),W=Nc(P[0],P[3],c),se=Math.min(N,U,q,W),X=Math.max(0,8*V-1),ie=Math.min(h-1,8*(V+1)),re=Math.max(0,8*z-1),oe=Math.min(h-1,8*(z+1));let me=-1/0;for(let xe=re;xe<=oe;xe++){const we=(xe+1)*C;for(let Ce=X;Ce<=ie;Ce++){const Se=E[we+Ce+1];Se>me&&(me=Se)}}b.minimums.push(se),b.maximums.push(me),b.leaves.push(1)}for(_.push(b),y/=2;y>=1;y/=2){const R=_.at(-1);b=new r1(y);for(let z=0;z<y*y;z++){v(z%y,Math.floor(z/y),2,!0,P);const V=R.getElevation(P[0],P[1]),N=R.getElevation(P[2],P[1]),U=R.getElevation(P[2],P[3]),q=R.getElevation(P[0],P[3]),W=R.isLeaf(P[0],P[1]),se=R.isLeaf(P[2],P[1]),X=R.isLeaf(P[2],P[3]),ie=R.isLeaf(P[0],P[3]),re=Math.min(V.min,N.min,U.min,q.min),oe=Math.max(V.max,N.max,U.max,q.max),me=W&&se&&X&&ie;b.maximums.push(oe),b.minimums.push(re),b.leaves.push(oe-re<=5&&me?1:0)}_.push(b)}return _})(this.dem),o=i.length-1,a=i[o];this._addNode(a.minimums[0],a.maximums[0],a.leaves[0]),this._construct(i,0,0,o,0)}raycastRoot(e,i,o,a,c,h,f=1){return n1([e,i,-100],[o,a,this.maximums[0]*f],c,h)}raycast(e,i,o,a,c,h,f=1){if(!this.nodeCount)return null;const _=this.raycastRoot(e,i,o,a,c,h,f);if(_==null)return null;const y=[],v=[],b=[],T=[],E=[{idx:0,t:_,nodex:0,nodey:0,depth:0}];for(;E.length>0;){const{idx:C,t:P,nodex:R,nodey:z,depth:V}=E.pop();if(this.leaves[C]){s1(R,z,V,e,i,o,a,b,T);const U=1<<V,q=R/U,W=(R+1)/U,se=z/U,X=(z+1)/U,{dim:ie,floatView:re,stride:oe}=this.dem,me=Math.floor(q*ie),xe=Math.ceil(W*ie),we=Math.floor(se*ie),Ce=xe-me,Se=Math.ceil(X*ie)-we;if(Ce<=0||Se<=0)continue;const qe=b[0],Me=b[1],Ie=(T[0]-qe)/Ce,Pe=(T[1]-Me)/Se,Ne=Math.max(0,P),ke=c[0]+h[0]*Ne,$e=c[1]+h[1]*Ne,ze=Math.abs(h[0])>1e-10,He=Math.abs(h[1])>1e-10,Ye=h[0]>=0?1:-1,st=h[1]>=0?1:-1;let Je=Math.max(0,Math.min(Ce-1,Math.floor((ke-qe)/Ie))),Qe=Math.max(0,Math.min(Se-1,Math.floor(($e-Me)/Pe)));const dt=ze?Math.abs(Ie/h[0]):Number.MAX_VALUE,wt=He?Math.abs(Pe/h[1]):Number.MAX_VALUE;let Bt=ze?Ne+(qe+(h[0]>=0?Je+1:Je)*Ie-ke)/h[0]:Number.MAX_VALUE,lt=He?Ne+(Me+(h[1]>=0?Qe+1:Qe)*Pe-$e)/h[1]:Number.MAX_VALUE;const Et=(hr,zt)=>re[(zt+1)*oe+hr+1]*f;let Rt=Et(me+Je,we+Qe),ki=Et(me+Je+1,we+Qe),qt=Et(me+Je,we+Qe+1),ni=Et(me+Je+1,we+Qe+1),_i=null;for(let hr=0;hr<Ce+Se;hr++){const zt=Math.min(Bt,lt);if(h[2]>=0||c[2]+h[2]*zt<=Math.max(Rt,ki,qt,ni)){const Tn=qe+Je*Ie,Zr=Tn+Ie,Wr=Me+Qe*Pe,er=Wr+Pe,Bi=o1(Zr,Wr,ki,Tn,Wr,Rt,Tn,er,qt,c,h),Di=o1(Tn,er,qt,Zr,er,ni,Zr,Wr,ki,c,h);Bi!=null&&Bi>=0&&(_i===null||Bi<_i)&&(_i=Bi),Di!=null&&Di>=0&&(_i===null||Di<_i)&&(_i=Di)}const yr=Bt<lt;if(yr?(Je+=Ye,Bt+=dt):(Qe+=st,lt+=wt),Je<0||Je>=Ce||Qe<0||Qe>=Se||_i!==null&&zt>_i)break;yr?Ye>0?(Rt=ki,qt=ni,ki=Et(me+Je+1,we+Qe),ni=Et(me+Je+1,we+Qe+1)):(ki=Rt,ni=qt,Rt=Et(me+Je,we+Qe),qt=Et(me+Je,we+Qe+1)):st>0?(Rt=qt,ki=ni,qt=Et(me+Je,we+Qe+1),ni=Et(me+Je+1,we+Qe+1)):(qt=Rt,ni=ki,Rt=Et(me+Je,we+Qe),ki=Et(me+Je+1,we+Qe))}if(_i!==null)return _i||0;const $i=Kr([],c,h,P),Ir=($i[0]-b[0])/(T[0]-b[0]),gi=($i[1]-b[1])/(T[1]-b[1]),Ri=Nc(q,se,this.dem)*f,mr=Nc(W,se,this.dem)*f,ln=Nc(W,X,this.dem)*f;if(l1(Ri,mr,Nc(q,X,this.dem)*f,ln,Ir,gi)>=$i[2])return P;continue}let N=0;for(let U=0;U<this._siblingOffset.length;U++){s1((R<<1)+this._siblingOffset[U][0],(z<<1)+this._siblingOffset[U][1],V+1,e,i,o,a,b,T),b[2]=-100,T[2]=this.maximums[this.childOffsets[C]+U]*f;const q=n1(b,T,c,h);if(q!=null){const W=q;y[U]=W;let se=!1;for(let X=0;X<N&&!se;X++)W>=y[v[X]]&&(v.splice(X,0,U),se=!0);se||(v[N]=U),N++}}for(let U=0;U<N;U++){const q=v[U];E.push({idx:this.childOffsets[C]+q,t:y[q],nodex:(R<<1)+this._siblingOffset[q][0],nodey:(z<<1)+this._siblingOffset[q][1],depth:V+1})}}return null}_addNode(e,i,o){return this.minimums.push(e),this.maximums.push(i),this.leaves.push(o),this.childOffsets.push(0),this.nodeCount++}_construct(e,i,o,a,c){if(e[a].isLeaf(i,o)===1)return;this.childOffsets[c]||(this.childOffsets[c]=this.nodeCount);const h=a-1,f=e[h];let _=0,y=0;for(let v=0;v<this._siblingOffset.length;v++){const b=2*i+this._siblingOffset[v][0],T=2*o+this._siblingOffset[v][1],E=f.getElevation(b,T),C=f.isLeaf(b,T),P=this._addNode(E.min,E.max,C);C&&(_|=1<<v),y||(y=P)}for(let v=0;v<this._siblingOffset.length;v++)_&1<<v||this._construct(e,2*i+this._siblingOffset[v][0],2*o+this._siblingOffset[v][1],h,y+v)}}function l1(r,e,i,o,a,c){return vt(vt(r,i,c),vt(e,o,c),a)}function Nc(r,e,i){const o=i.dim,a=Y(r*o-.5,0,o-1),c=Y(e*o-.5,0,o-1),h=Math.floor(a),f=Math.floor(c),_=Math.min(h+1,o-1),y=Math.min(f+1,o-1);return l1(i.get(h,f),i.get(_,f),i.get(h,y),i.get(_,y),a-h,c-f)}const iS={mapbox:[6553.6,25.6,.1,1e4],terrarium:[256,1,1/256,32768]};function rS(r,e,i){return(256*r*256+256*e+i)/10-1e4}function nS(r,e,i){return 256*r+e+i/256-32768}class zg{get tree(){return this._tree||this._buildQuadTree(),this._tree}constructor(e,i,o,a=!1){if(this.uid=e,i.height!==i.width)throw new RangeError("DEM tiles must be square");if(o&&o!=="mapbox"&&o!=="terrarium")return void ht(`"${o}" is not a valid encoding type. Valid types include "mapbox" and "terrarium".`);this.stride=i.height;const c=this.dim=i.height-2,h=new Uint32Array(i.data.buffer);if(this.pixels=new Uint8Array(i.data.buffer),this.floatView=new Float32Array(i.data.buffer),this.borderReady=a,this._modifiedForSources={},!a){for(let _=0;_<c;_++)h[this._idx(-1,_)]=h[this._idx(0,_)],h[this._idx(c,_)]=h[this._idx(c-1,_)],h[this._idx(_,-1)]=h[this._idx(_,0)],h[this._idx(_,c)]=h[this._idx(_,c-1)];h[this._idx(-1,-1)]=h[this._idx(0,0)],h[this._idx(c,-1)]=h[this._idx(c-1,0)],h[this._idx(-1,c)]=h[this._idx(0,c-1)],h[this._idx(c,c)]=h[this._idx(c-1,c-1)]}const f=o==="terrarium"?nS:rS;for(let _=0;_<h.length;++_){const y=4*_;this.floatView[_]=f(this.pixels[y],this.pixels[y+1],this.pixels[y+2])}this._timestamp=_r.now()}_buildQuadTree(){this._tree=new a1(this)}get(e,i,o=!1){o&&(e=Y(e,-1,this.dim),i=Y(i,-1,this.dim));const a=this._idx(e,i);return this.floatView[a]}set(e,i,o){const a=this._idx(e,i),c=this.floatView[a];return this.floatView[a]=o,o-c}static getUnpackVector(e){return iS[e]}_idx(e,i){if(e<-1||e>=this.dim+1||i<-1||i>=this.dim+1)throw new RangeError("out of range source coordinates for DEM data");return(i+1)*this.stride+(e+1)}static pack(e,i){const o=[0,0,0,0],a=zg.getUnpackVector(i);let c=Math.floor((e+a[3])/a[2]);return o[2]=c%256,c=Math.floor(c/256),o[1]=c%256,c=Math.floor(c/256),o[0]=c,o}getPixels(){return new C_({width:this.stride,height:this.stride},this.pixels)}backfillBorder(e,i,o){if(this.dim!==e.dim)throw new Error("dem dimension mismatch");let a=i*this.dim,c=i*this.dim+this.dim,h=o*this.dim,f=o*this.dim+this.dim;switch(i){case-1:a=c-1;break;case 1:c=a+1}switch(o){case-1:h=f-1;break;case 1:f=h+1}const _=-i*this.dim,y=-o*this.dim;for(let v=h;v<f;v++)for(let b=a;b<c;b++){const T=4*this._idx(b,v),E=4*this._idx(b+_,v+y);this.pixels[T+0]=e.pixels[E+0],this.pixels[T+1]=e.pixels[E+1],this.pixels[T+2]=e.pixels[E+2],this.pixels[T+3]=e.pixels[E+3]}}onDeserialize(){this._tree&&(this._tree.dem=this)}}nt(zg,"DEMData"),nt(a1,"DemMinMaxQuadTree",{omit:["dem"]});const c1=[Int8Array,Uint8Array,Uint8ClampedArray,Int16Array,Uint16Array,Int32Array,Uint32Array,Float32Array,Float64Array],Hr=new Uint32Array(96);class Zx{static from(e){if(!e||e.byteLength===void 0||e.buffer)throw new Error("Data must be an instance of ArrayBuffer or SharedArrayBuffer.");const[i,o]=new Uint8Array(e,0,2);if(i!==219)throw new Error("Data does not appear to be in a KDBush format.");const a=o>>4;if(a!==1)throw new Error(`Got v${a} data when expected v1.`);const c=c1[15&o];if(!c)throw new Error("Unrecognized array type.");const[h]=new Uint16Array(e,2,1),[f]=new Uint32Array(e,4,1);return new Zx(f,h,c,void 0,e)}constructor(e,i=64,o=Float64Array,a=ArrayBuffer,c){if(isNaN(e)||e<0)throw new Error(`Unexpected numItems value: ${e}.`);this.numItems=+e,this.nodeSize=Math.min(Math.max(+i,2),65535),this.ArrayType=o,this.IndexArrayType=e<65536?Uint16Array:Uint32Array;const h=c1.indexOf(this.ArrayType),f=2*e*this.ArrayType.BYTES_PER_ELEMENT,_=e*this.IndexArrayType.BYTES_PER_ELEMENT,y=(8-_%8)%8;if(h<0)throw new Error(`Unexpected typed array class: ${o}.`);if(c)this.data=c,this.ids=new this.IndexArrayType(c,8,e),this.coords=new o(c,8+_+y,2*e),this._pos=2*e,this._finished=!0;else{const v=this.data=new a(8+f+_+y);this.ids=new this.IndexArrayType(v,8,e),this.coords=new o(v,8+_+y,2*e),this._pos=0,this._finished=!1,new Uint8Array(v,0,2).set([219,16+h]),new Uint16Array(v,2,1)[0]=i,new Uint32Array(v,4,1)[0]=e}}add(e,i){const o=this._pos>>1;return this.ids[o]=o,this.coords[this._pos++]=e,this.coords[this._pos++]=i,o}finish(){const e=this._pos>>1;if(e!==this.numItems)throw new Error(`Added ${e} items when expected ${this.numItems}.`);return Wx(this.ids,this.coords,this.nodeSize,0,this.numItems-1,0),this._finished=!0,this}range(e,i,o,a){if(!this._finished)throw new Error("Data not yet indexed - call index.finish().");const{ids:c,coords:h,nodeSize:f}=this;Hr[0]=0,Hr[1]=c.length-1,Hr[2]=0;let _=3;const y=[];for(;_>0;){const v=Hr[--_],b=Hr[--_],T=Hr[--_];if(b-T<=f){for(let R=T;R<=b;R++){const z=h[2*R],V=h[2*R+1];z>=e&&z<=o&&V>=i&&V<=a&&y.push(c[R])}continue}const E=T+b>>1,C=h[2*E],P=h[2*E+1];C>=e&&C<=o&&P>=i&&P<=a&&y.push(c[E]),(v===0?e<=C:i<=P)&&(Hr[_++]=T,Hr[_++]=E-1,Hr[_++]=1-v),(v===0?o>=C:a>=P)&&(Hr[_++]=E+1,Hr[_++]=b,Hr[_++]=1-v)}return y}within(e,i,o){const a=[];return this.withinInto(e,i,o,a),a}withinInto(e,i,o,a){if(!this._finished)throw new Error("Data not yet indexed - call index.finish().");const{ids:c,coords:h,nodeSize:f}=this;Hr[0]=0,Hr[1]=c.length-1,Hr[2]=0;let _=3,y=0;const v=o*o;for(;_>0;){const b=Hr[--_],T=Hr[--_],E=Hr[--_];if(T-E<=f){for(let z=E;z<=T;z++)h1(h[2*z],h[2*z+1],e,i)<=v&&(a[y++]=c[z]);continue}const C=E+T>>1,P=h[2*C],R=h[2*C+1];h1(P,R,e,i)<=v&&(a[y++]=c[C]),(b===0?e-o<=P:i-o<=R)&&(Hr[_++]=E,Hr[_++]=C-1,Hr[_++]=1-b),(b===0?e+o>=P:i+o>=R)&&(Hr[_++]=C+1,Hr[_++]=T,Hr[_++]=1-b)}return y}}function Wx(r,e,i,o,a,c){if(a-o<=i)return;const h=o+a>>1;u1(r,e,h,o,a,c),Wx(r,e,i,o,h-1,1-c),Wx(r,e,i,h+1,a,1-c)}function u1(r,e,i,o,a,c){for(;a>o;){if(a-o>600){const y=a-o+1,v=i-o+1,b=Math.log(y),T=.5*Math.exp(2*b/3),E=.5*Math.sqrt(b*T*(y-T)/y)*(v-y/2<0?-1:1);u1(r,e,i,Math.max(o,Math.floor(i-v*T/y+E)),Math.min(a,Math.floor(i+(y-v)*T/y+E)),c)}const h=e[2*i+c];let f=o,_=a;for(Zp(r,e,o,i),e[2*a+c]>h&&Zp(r,e,o,a);f<_;){for(Zp(r,e,f,_),f++,_--;e[2*f+c]<h;)f++;for(;e[2*_+c]>h;)_--}e[2*o+c]===h?Zp(r,e,o,_):(_++,Zp(r,e,_,a)),_<=i&&(o=_+1),i<=_&&(a=_-1)}}function Zp(r,e,i,o){Xx(r,i,o),Xx(e,2*i,2*o),Xx(e,2*i+1,2*o+1)}function Xx(r,e,i){const o=r[e];r[e]=r[i],r[i]=o}function h1(r,e,i,o){const a=r-i,c=e-o;return a*a+c*c}F.$=fm,F.A=Nd,F.B=Lo,F.C=ai,F.D=Fo,F.E=dl,F.F=2,F.G=Ut,F.H=at,F.I=po,F.J=dm,F.K=e_,F.L=jx,F.M=rc,F.N=Zc,F.O=vh,F.P=Ue,F.Q=xh,F.R=ul,F.S=cf,F.T=Ct,F.U=au,F.V=Lh,F.W=Vm,F.X=Oa,F.Y=Fa,F.Z=gl,F._=jn,F.a=function(r){return bi.API_CDN_URL_REGEX.test(r)},F.a$=vn,F.a0=$d,F.a1=Af,F.a2=/^(.*)-use-theme$/,F.a3=/^(.*)-transition$/,F.a4=Xs,F.a5=Fm,F.a6=Jm,F.a7=Vi,F.a8=We,F.a9=class{constructor(r){this.specification=r}possiblyEvaluate(r,e){return Yt(r.expression.evaluate(e))}interpolate(r,e,i){return{x:vt(r.x,e.x,i),y:vt(r.y,e.y,i),z:vt(r.z,e.z,i),azimuthal:vt(r.azimuthal,e.azimuthal,i),polar:vt(r.polar,e.polar,i)}}},F.aA=function(r,e,i){i*=.5;var o=e[0],a=e[1],c=e[2],h=e[3],f=Math.sin(i),_=Math.cos(i);return r[0]=o*_+a*f,r[1]=a*_-o*f,r[2]=c*_+h*f,r[3]=h*_-c*f,r},F.aB=Jo,F.aC=Si,F.aD=dr,F.aE=co,F.aF=So,F.aG=Mn,F.aH=function(r,e){return r[0]=-e[0],r[1]=-e[1],r[2]=-e[2],r[3]=e[3],r},F.aI=Nn,F.aJ=function(r,e,i,o,a){var c=1/Math.tan(e/2);if(r[0]=c/i,r[1]=0,r[2]=0,r[3]=0,r[4]=0,r[5]=c,r[6]=0,r[7]=0,r[8]=0,r[9]=0,r[11]=-1,r[12]=0,r[13]=0,r[15]=0,a!=null&&a!==1/0){var h=1/(o-a);r[10]=(a+o)*h,r[14]=2*a*o*h}else r[10]=-1,r[14]=-2*o;return r},F.aK=function(r,e,i,o,a,c,h){var f=1/(e-i),_=1/(o-a),y=1/(c-h);return r[0]=-2*f,r[1]=0,r[2]=0,r[3]=0,r[4]=0,r[5]=-2*_,r[6]=0,r[7]=0,r[8]=0,r[9]=0,r[10]=2*y,r[11]=0,r[12]=(e+i)*f,r[13]=(a+o)*_,r[14]=(h+c)*y,r[15]=1,r},F.aL=Wn,F.aM=on,F.aN=function(r,e,i){r[4*e+0]=i[0],r[4*e+1]=i[1],r[4*e+2]=i[2],r[4*e+3]=i[3]},F.aO=Ln,F.aP=Ni,F.aQ=Nt,F.aR=un,F.aS=mn,F.aT=function(r,e){const{x:i,y:o}=r.point,a=pv(i,o,r.worldSize/r._pixelsPerMercatorPixel,0,0);return Ni(a,a,Jy(Qa(e)))},F.aU=Wt,F.aV=Bs,F.aW=Zi,F.aX=ks,F.aY=Kr,F.aZ=Fe,F.a_=Ss,F.aa=xt,F.ab=lu,F.ac=kn,F.ad=ir,F.ae=Yr,F.af=ce,F.ag=Ks,F.ah=zc,F.ai=vt,F.aj=rt,F.ak=_t,F.al=Qt,F.am=function(){return J++},F.an=class{constructor(r,e,i){this.target=r,this.parent=e,this.mapId=i,this.pendingResponses=new Map,ve(["receive"],this),this.target.addEventListener("message",this.receive,!1),this.scheduler=new DT}send(r,e,i){const{signal:o,targetMapId:a,metadata:c}=i||{},h=Math.round(1e18*Math.random()).toString(36).substring(0,10),f=new Set;return o&&o.aborted?Promise.reject(o.reason):(this.target.postMessage({id:h,type:r,targetMapId:a,sourceMapId:this.mapId,data:Bo(e,f)},[...f]),new Promise((_,y)=>{const v={resolve:_,reject:y,metadata:c||Ub};if(o){const b=()=>{this.pendingResponses.delete(h),y(o.reason)};o.addEventListener("abort",b,{once:!0}),v.detach=()=>o.removeEventListener("abort",b)}this.pendingResponses.set(h,v)}))}notify(r,e,i){const{targetMapId:o}=i||{},a=new Set;this.target.postMessage({type:r,targetMapId:o,sourceMapId:this.mapId,data:Bo(e,a)},[...a])}sendCancelable(r,e,i,o){const a=new AbortController;return this.send(r,e,{...i,signal:a.signal}).then(c=>o(null,c)).catch(c=>{c.name!=="AbortError"&&o(c)}),a}getWorkerSourceActor(r){return{scheduler:this.scheduler,send:(e,i,o)=>this.send(e,i,{...o,targetMapId:r}),notify:(e,i)=>{this.notify(e,i,{targetMapId:r})},sendCancelable:(e,i,o,a)=>this.sendCancelable(e,i,{...o,targetMapId:r},a)}}receive(r){const e=r.data;if(!e)return;const i=e.id;if(!e.targetMapId||this.mapId===e.targetMapId)if(yi(self)){const o=this.pendingResponses.get(i);this.scheduler.add(()=>{this.processTask(i,e)},o&&o.metadata||Ub)}else this.processTask(i,e)}async processTask(r,e){if(e.type==="<response>"){const a=this.pendingResponses.get(r);if(this.pendingResponses.delete(r),a){a.detach&&a.detach();try{e.error?a.reject(As(e.error)):a.resolve(As(e.data))}catch(c){a.reject(c)}}return}const i=new Set,o=As(e.data);try{let a;if(this.parent[e.type])a=await this.parent[e.type](e.sourceMapId,o);else{if(!this.parent.getWorkerSource)throw new Error(`Could not find function ${e.type}`);{const c=e.type.split("."),{source:h,scope:f}=o;a=await this.parent.getWorkerSource(e.sourceMapId,{type:c[0],source:h,scope:f,uid:0})[c[1]](o)}}if(!r)return;this.target.postMessage({id:r,type:"<response>",sourceMapId:this.mapId,error:null,data:Bo(a,i)},[...i])}catch(a){this.target.postMessage({id:r,type:"<response>",sourceMapId:this.mapId,error:Bo(a),data:null},[])}}remove(){for(const r of this.pendingResponses.values())r.detach&&r.detach(),r.reject(new DOMException("Actor removed","AbortError"));this.pendingResponses.clear(),this.scheduler.remove(),this.target.removeEventListener("message",this.receive,!1)}},F.ao=class{constructor(r){this.specification=r}
7possiblyEvaluate(r,e){return(function([i,o]){const a=Yt([1,i,o]);return{x:a.x,y:a.y,z:a.z}})(r.expression.evaluate(e))}interpolate(r,e,i){return{x:vt(r.x,e.x,i),y:vt(r.y,e.y,i),z:vt(r.z,e.z,i)}}},F.ap=ta,F.aq=Ru,F.ar=gr,F.as=Y,F.at=he,F.au=Mi,F.av=li,F.aw=qi,F.ax=tr,F.ay=Dn,F.az=Ao,F.b=function(r){return bi.API_FONTS_REGEX.test(r)},F.b$=ao,F.b0=M,F.b1=ge,F.b2=function(r,e,i,o,a){const c=5*e+2;r.float32[c+0]=i,r.float32[c+1]=o,r.float32[c+2]=a},F.b3=bd,F.b4=ui,F.b5=ne,F.b6=Tv,F.b7=ro,F.b8=function(r,e){return r[0]===e[0]&&r[1]===e[1]&&r[2]===e[2]&&r[3]===e[3]},F.b9=Rn,F.bA=as,F.bB=Yo,F.bC=Hy,F.bD=6,F.bE=function(r){const e=Si(new Float64Array(16));Ni(e,r.pixelMatrix,r.globeMatrix);const i=[0,os,0],o=[0,ss,0];return ir(i,i,e),ir(o,o,e),[i[0]>0&&i[0]<=r.width&&i[1]>0&&i[1]<=r.height&&!ex(r,new ui(r.center.lat,90)),o[0]>0&&o[0]<=r.width&&o[1]>0&&o[1]<=r.height&&!ex(r,new ui(r.center.lat,-90))]},F.bF=Ga,F.bG=function(r,e){const{scale:i}=r.tileTransform,o=i*rt/(r.tileSize*Math.pow(2,e.zoom-r.tileID.overscaledZ+r.tileID.canonical.z)),a=e.inverseAdjustmentMatrix;return new Float32Array([a[0]*o,a[1]*o,a[2]*o,a[3]*o])},F.bH=hg,F.bI=Sn,F.bJ=c0,F.bK=function(r){const e=c0(r,!0);return Wt([],[e[0],e[1],e[4],e[5]])},F.bL=_n,F.bM=Zy,F.bN=gn,F.bO=function(r,e){return r[0]=e[0],r[1]=e[1],r[2]=e[2],r[3]=e[3],r[4]=e[4],r[5]=e[5],r[6]=e[6],r[7]=e[7],r[8]=e[8],r[9]=e[9],r[10]=e[10],r[11]=e[11],r[12]=e[12],r[13]=e[13],r[14]=e[14],r[15]=e[15],r},F.bP=function(r){const{x:e,y:i}=r.point,{lng:o,lat:a}=r._center;return pv(e,i,r.worldSize,o,a)},F.bQ=gs,F.bR=hn,F.bS=en,F.bT=zl,F.bU=5,F.bV=function(r,e,i){let o=0;for(let a=0;a<2;++a)r[a]>0&&(o+=(r[a]-0)*(r[a]-0)),e[a]<0&&(o+=(0-e[a])*(0-e[a]));return o},F.bW=function(r){return r*r*r*r*r},F.bX=Uf,F.bY=45,F.bZ=ea,F.b_=Pu,F.ba=function(r){var e=r[0],i=r[1],o=r[2],a=r[3];return Math.sqrt(e*e+i*i+o*o+a*a)},F.bb=Aa,F.bc=Xo,F.bd=yv,F.be=3,F.bf=2,F.bg=7,F.bh=6,F.bi=fo,F.bj=Zt,F.bk=Eo,F.bl=0,F.bm=1,F.bn=4,F.bo=5,F.bp=Fu,F.bq=xd,F.br=Yn,F.bs=Xy,F.bt=u0,F.bu=Tp,F.bv=dv,F.bw=function(r,e,i,o,a,c,h,f,_){if(_.name==="globe")return dv(r,e,new Tp(i,o,a),!1);const y=tx({z:i,x:o,y:a},_);
vendor: 29,173 bytes, line 7
7return new lr([(c+y.x/y.scale)*e,e*(y.y/y.scale),h],[(c+y.x2/y.scale)*e,e*(y.y2/y.scale),f])},F.bx=function(r,e,i){return r[0]=Math.min(e[0],i[0]),r[1]=Math.min(e[1],i[1]),r[2]=Math.min(e[2],i[2]),r[3]=Math.min(e[3],i[3]),r},F.by=function(r,e,i){return r[0]=Math.max(e[0],i[0]),r[1]=Math.max(e[1],i[1]),r[2]=Math.max(e[2],i[2]),r[3]=Math.max(e[3],i[3]),r},F.bz=function(r){const e=Math.round((r+45+360)%360/90)%4;return pe[e]},F.c=kd,F.c$=ls,F.c0=$1,F.c1=cb,F.c2=St,F.c3=function(r,e){var i=Math.sin(e),o=Math.cos(e);return r[0]=o,r[1]=i,r[2]=0,r[3]=-i,r[4]=o,r[5]=0,r[6]=0,r[7]=0,r[8]=1,r},F.c4=function(r,e,i){var o=e[0],a=e[1],c=e[2];return r[0]=o*i[0]+a*i[3]+c*i[6],r[1]=o*i[1]+a*i[4]+c*i[7],r[2]=o*i[2]+a*i[5]+c*i[8],r},F.c5=function(r,e,i){const o=Math.sqrt(r*r+e*e+i*i),a=o>0?Math.acos(i/o)*js:0;let c=r!==0||e!==0?Math.atan2(-e,-r)*js+90:0;return c<0&&(c+=360),[o,c,a]},F.c6=ur,F.c7=function(r){return[Math.pow(r[0],1/2.2),Math.pow(r[1],1/2.2),Math.pow(r[2],1/2.2)]},F.c8=Yt,F.c9=ap,F.cA=dn,F.cB=Sg,F.cC=P0,F.cD=nn,F.cE=Ul,F.cF=450,F.cG=7,F.cH=4,F.cI=2,F.cJ=Lu,F.cK=pp,F.cL=ve,F.cM=class{static calculate(r,e,i){const o=new Set,a=new Map,c=new Set,h=new Set;for(const _ of Object.values(r))for(const[y,v]of Object.entries(_.floors)){c.add(y),v.isDefault&&h.add(y),v.conflicts&&a.set(y,v.conflicts);const b=y===e,T=v.connections&&e&&v.connections.has(e);(b||T)&&o.add(y)}const f=_=>{const y=a.get(_)||new Set;for(const v of o)if((a.get(v)||new Set).has(_)||y.has(v))return!0;return!1};if(i)for(const _ of i)c.has(_)&&(f(_)||o.add(_));for(const _ of h)o.has(_)||f(_)||o.add(_);return o}},F.cN=class extends Qs{constructor(r){super(r),this.current=new Float32Array(9)}set(r,e,i){if(!this.fetchUniformLocation(r,e))return;const o=this.current;for(let a=0;a<9;a++)if(i[a]!==o[a]){o.set(i),this.gl.uniformMatrix3fv(this.location,!1,o);break}}},F.cO=tx,F.cP=$r,F.cQ=Gh,F.cR=Gt,F.cS=ip,F.cT=J_,F.cU=function(){Ys.isLoading()||Ys.isLoaded()||Rh()!=="deferred"||Km()},F.cV=zh,F.cW=Vo,F.cX=$u,F.cY=nr,F.cZ=Dc,F.c_=hp,F.ca=lr,F.cb=Jr,F.cc=Dl,F.cd=Qn,F.ce=ho,F.cf=function(r,e){var i=new Ht(3);ho(i,e);var o=1/i[0],a=1/i[1],c=1/i[2],h=e[0]*o,f=e[1]*a,_=e[2]*c,y=e[4]*o,v=e[5]*a,b=e[6]*c,T=e[8]*o,E=e[9]*a,C=e[10]*c,P=h+v+C,R=0;return P>0?(R=2*Math.sqrt(P+1),r[3]=.25*R,r[0]=(b-E)/R,r[1]=(T-_)/R,r[2]=(f-y)/R):h>v&&h>C?(R=2*Math.sqrt(1+h-v-C),r[3]=(b-E)/R,r[0]=.25*R,r[1]=(f+y)/R,r[2]=(T+_)/R):v>C?(R=2*Math.sqrt(1+v-h-C),r[3]=(T-_)/R,r[0]=(f+y)/R,r[1]=.25*R,r[2]=(b+E)/R):(R=2*Math.sqrt(1+C-h-v),r[3]=(f-y)/R,r[0]=(T+_)/R,r[1]=(b+E)/R,r[2]=.25*R),r},F.cg=function(r,e){var i=2*Math.acos(e[3]),o=Math.sin(i/2);return o>Yi?(r[0]=e[0]/o,r[1]=e[1]/o,r[2]=e[2]/o):(r[0]=1,r[1]=0,r[2]=0),i},F.ch=Ux,F.ci=pg,F.cj=fg,F.ck=Id,F.cl=function(r,e){if(r===e){var i=e[1],o=e[2],a=e[3],c=e[6],h=e[7],f=e[11];r[1]=e[4],r[2]=e[8],r[3]=e[12],r[4]=i,r[6]=e[9],r[7]=e[13],r[8]=o,r[9]=c,r[11]=e[14],r[12]=a,r[13]=h,r[14]=f}else r[0]=e[0],r[1]=e[4],r[2]=e[8],r[3]=e[12],r[4]=e[1],r[5]=e[5],r[6]=e[9],r[7]=e[13],r[8]=e[2],r[9]=e[6],r[10]=e[10],r[11]=e[14],r[12]=e[3],r[13]=e[7],r[14]=e[11],r[15]=e[15];return r},F.cm=Mv,F.cn=yo,F.co=_a,F.cp=sn,F.cq=sv,F.cr=Fi,F.cs=Md,F.ct=class{constructor(r,e,i,o){this.context=r,this.format=o,this.size=i,this.texture=r.gl.createTexture();const[a,c,h]=this.size,{gl:f}=r;f.bindTexture(f.TEXTURE_3D,this.texture),r.pixelStoreUnpackFlipY.set(!1),r.pixelStoreUnpack.set(1),r.pixelStoreUnpackPremultiplyAlpha.set(!1),"data"in e&&e.data&&f.texImage3D(f.TEXTURE_3D,0,this.format,a,c,h,0,gt(this.format),Pt(this.format),e.data)}bind(r,e){const{context:i}=this,{gl:o}=i;o.bindTexture(o.TEXTURE_3D,this.texture),r!==this.minFilter&&(o.texParameteri(o.TEXTURE_3D,o.TEXTURE_MAG_FILTER,r),o.texParameteri(o.TEXTURE_3D,o.TEXTURE_MIN_FILTER,r),this.minFilter=r),e!==this.wrapS&&(o.texParameteri(o.TEXTURE_3D,o.TEXTURE_WRAP_S,e),o.texParameteri(o.TEXTURE_3D,o.TEXTURE_WRAP_T,e),this.wrapS=e)}destroy(){const{gl:r}=this.context;r.deleteTexture(this.texture),this.texture=null}},F.cu=[1,1,1],F.cv=function(r,e,i,o){var a=new Ht(4);return a[0]=r,a[1]=e,a[2]=i,a[3]=o,a},F.cw=ys,F.cx=function(r,e,i,o){var a=e[0],c=e[1],h=e[2],f=e[3];return r[0]=a+o*(i[0]-a),r[1]=c+o*(i[1]-c),r[2]=h+o*(i[2]-h),r[3]=f+o*(i[3]-f),r},F.cy=function(r){return r>>>=0,r=Math.imul(2747636419^r,2654435769)>>>0,r=Math.imul(r^r>>>16,2654435769)>>>0,(r=Math.imul(r^r>>>16,2654435769)>>>0)/4294967296},F.cz=ji,F.d=function(r){return bi.API_TILEJSON_REGEX.test(r)},F.d$=K,F.d0=Qh,F.d1=Sc,F.d2=function(r,e){const i=zc(e.zoom);if(i===0)return Qa(r);const o=$_(r),a=Ky(o),c=Ss(o.getWest())*e.worldSize,h=Ss(o.getEast())*e.worldSize,f=vn(o.getNorth())*e.worldSize,_=vn(o.getSouth())*e.worldSize,y=[c,f,0],v=[h,f,0],b=[c,_,0],T=[h,_,0],E=co([],e.globeMatrix);return ir(y,y,E),ir(v,v,E),ir(b,b,E),ir(T,T,E),a[0]=kl(a[0],b,i),a[1]=kl(a[1],T,i),a[2]=kl(a[2],v,i),a[3]=kl(a[3],y,i),lr.fromPoints(a)},F.d3=Z_,F.d4=wp,F.d5=kl,F.d6=Ms,F.d7=k1,F.d8=Lg,F.d9=bp,F.dA=Vb,F.dB=ue,F.dC="hd_road_coverage",F.dD=function(r){const e=r.indexOf(gu);return e>=0?r.slice(0,e):r},F.dE=Il,F.dF=function(r,e,i=0,o=!0){const a=new Ue(i,i),c=r.sub(a),h=e.add(a),f=[c,new Ue(h.x,c.y),h,new Ue(c.x,h.y)];return o&&f.push(c.clone()),f},F.dG=function(r,e){const i=[];for(let o=0;o<r.length;o++){const a=he(o-1,-1,r.length-1),c=he(o+1,-1,r.length-1),h=r[o],f=r[c],_=r[a].sub(h).unit(),y=f.sub(h).unit(),v=y.angleWithSep(_.x,_.y),b=_.add(y).unit().mult(-1*e/Math.sin(v/2));i.push(h.add(b))}return i},F.dH=function(r,{x:e,y:i},o=0){return new Ue(((e-o)*r.scale-r.x)*rt,(i*r.scale-r.y)*rt)},F.dI=function(r,e,i=0){return ur(((e.x-i)*r.scale-r.x)*rt,(e.y*r.scale-r.y)*rt,jf(e.z,e.y))},F.dJ=function(r){let e=1/0,i=1/0,o=-1/0,a=-1/0;for(const c of r)e=Math.min(e,c.x),i=Math.min(i,c.y),o=Math.max(o,c.x),a=Math.max(a,c.y);return{min:new Ue(e,i),max:new Ue(o,a)}},F.dK=Zn,F.dL=na,F.dM=d_,F.dN=class{constructor(r){this.entries={},this.scheduler=r}request(r,e,i,o){const a=this.entries[r]=this.entries[r]||{callbacks:[]};if(a.result){const[c,h]=a.result;return this.scheduler?this.scheduler.add(()=>{o(c,h)},e):o(c,h),()=>{}}return a.callbacks.push(o),a.cancel||(a.cancel=i((c,h)=>{a.result=[c,h];for(const f of a.callbacks)this.scheduler?this.scheduler.add(()=>{f(c,h)},e):f(c,h);setTimeout(()=>delete this.entries[r],3e3)})),()=>{a.result||(a.callbacks=a.callbacks.filter(c=>c!==o),a.callbacks.length||(a.cancel(),delete this.entries[r]))}}},F.dO=function(r,e,i){const o=JSON.stringify(r.request);return r.data&&(this.deduped.entries[o]={result:[null,r.data]}),this.deduped.request(o,{type:"parseTile",renderSourceType:r.renderSourceType,zoom:r.tileZoom},a=>{const c=new AbortController;return Yl(r.request,c.signal).then(({data:h,headers:f})=>{a(null,{rawData:h,vectorTile:i?void 0:new fp(new bp(h)),headers:f})}).catch(h=>{c.signal.aborted||(sm(h)?a(null,null):a(h))}),()=>{c.abort(),a(null,null)}},e)},F.dP=class{constructor(r,e){this.context=r,this.texture=e}bind(r,e){const{context:i}=this,{gl:o}=i;o.bindTexture(o.TEXTURE_2D,this.texture),r!==this.minFilter&&(o.texParameteri(o.TEXTURE_2D,o.TEXTURE_MAG_FILTER,r),o.texParameteri(o.TEXTURE_2D,o.TEXTURE_MIN_FILTER,r),this.minFilter=r),e!==this.wrapS&&(o.texParameteri(o.TEXTURE_2D,o.TEXTURE_WRAP_S,e),o.texParameteri(o.TEXTURE_2D,o.TEXTURE_WRAP_T,e),this.wrapS=e)}},F.dQ=function(r,e,i,o){for(;e<i;){const a=e+i>>1;r[a]<=o?e=a+1:i=a}return e},F.dR=function(r,e,i,o){for(;e<i;){const a=e+i>>1;r[a]<o?e=a+1:i=a}return e},F.dS=Pl,F.dT=function(r,e){var i=e[0],o=e[1],a=e[2],c=e[3],h=e[4],f=e[5],_=e[6],y=e[7],v=e[8];return r[0]=h*v-f*y,r[1]=a*y-o*v,r[2]=o*f-a*h,r[3]=f*_-c*v,r[4]=i*v-a*_,r[5]=a*c-i*f,r[6]=c*y-h*_,r[7]=o*_-i*y,r[8]=i*h-o*c,r},F.dU=Ti,F.dV=async function(r){const e=document.createElement("video");e.muted=!0;for(const i of r){const o=document.createElement("source");am(i)||(e.crossOrigin="Anonymous"),o.src=i,e.appendChild(o)}return await new Promise((i,o)=>{e.onloadstart=()=>i(),e.onerror=()=>o(new Error(`Could not load video: ${r.join(", ")}`))}),e},F.dW=jl,F.dX=["type","source","source-layer","minzoom","maxzoom","filter","layout"],F.dY=Sv,F.dZ=gg,F.d_=Cv,F.da=Yl,F.db=function(r){if("provider"in r&&!r.provider)return null;let e=r.provider;if(!e&&"url"in r&&r.url&&(e=(function(a){try{const c=new URL(a).pathname.split("/").pop()||"",h=c.lastIndexOf(".");return h>=0?c.slice(h+1):""}catch{return""}})(r.url)),!e)return null;const i=bi.TILE_PROVIDER_URLS[e];if(!i)return null;let o;try{o=new URL(i,bi.API_URL).href}catch{return new Error(`TileProvider "${e}" has an invalid URL: "${i}"`)}return{name:e,url:o}},F.dc=function(r,e,i,o,a){const c=function(f,_){if(f)return a(f);if(_){r.url&&_.tiles&&r.tiles&&delete r.tiles;const y=t1(r,_,e);if(y instanceof Error)return a(y);a(null,y)}},h=(function(f,_,y){if(!f)return null;if(!_&&!y)return f;y=y||f.worldview_default;const v=Object.values(f.language||{});if(v.length===0)return null;const b=Object.values(f.worldview||{});if(b.length===0)return null;const T=v.every(C=>C===_),E=b.every(C=>C===y);return T&&E?f:_ in(f.language_options||{})||y in(f.worldview_options||{})?null:f.language_options&&f.worldview_options?f:null})(r.data,i,o);if(h)return _r.frame(()=>c(null,h));if(r.url){const f=new AbortController;return(async()=>{const _=await e.transformRequest(e.normalizeSourceURL(r.url,null,i,o),ul.Source,f.signal),{data:y}=await Gs(_,f.signal);c(null,y)})().catch(_=>{f.signal.aborted||c(_)}),{cancel:()=>f.abort()}}return _r.frame(()=>{const{data:f,..._}=r;c(null,_)})},F.dd=function(r){return r?{cacheControl:r.get("cache-control"),expires:r.get("expires")}:{cacheControl:void 0,expires:void 0}},F.de=function(r){cl++,cl>jc&&(r.getActor().notify("enforceCacheSizeLimit",rm),cl=0)},F.df=async function(r,e,i){const o=r.url&&!r.tiles?await e.transformRequest(r.url,ul.Source,i):void 0;return{request:o,options:o?{...r,url:o.url}:r}},F.dg=async function(r,e){const i=i1.get(r);if(i)return i;const o=Hx.get(r);if(o!==void 0)return o;const a=self.__mapboxImport(e).catch(c=>{throw new Error(`TileProvider "${r}" failed to load: ${c instanceof Error?c.message:String(c)}`)}).then(c=>{const h=c.default;if(typeof h!="function")throw new Error(`TileProvider "${r}" module must default-export a class`);if(typeof h.prototype.loadTile!="function")throw new Error(`TileProvider "${r}" class must have a loadTile method`);return i1.set(r,h),h}).finally(()=>{Hx.delete(r)});return Hx.set(r,a),a},F.dh=function(r,e,i){return e?t1(r,e,i):r.tiles&&r.tiles.length>0?{tiles:r.tiles}:new Error('TileJSON is missing required "tiles" property')},F.di=Sb,F.dj=Db,F.dk=Ll,F.dl=$_,F.dm=function(r){const e=80.051129;r=Y(r,-80.051129,e)/e*90;const i=Math.pow(Math.abs(Math.sin(Qt(r))),3);return Math.round(i*(Nf.length-1))},F.dn=Qa,F.dp=function(r){const e=r.pixelsPerMeter,i=e/Wn(1,r.center.lat),o=Si(new Float64Array(16));return Mn(o,o,[r.point.x,r.point.y,0]),_n(o,o,[i,i,e]),Float32Array.from(o)},F.dq=function(r,e,i,o){const a=e.getNorth(),c=e.getSouth(),h=e.getWest(),f=e.getEast(),_=1<<r.z,y=f-h,v=a-c,b=y/Pl,T=-v/Nf[i],E=[0,b,0,T,0,0,a,h,0];if(r.z>0){const C=180/o;Ti(E,E,[C/y+1,0,0,0,C/v+1,0,-.5*C/b,.5*C/T,1])}return E[2]=_,E[5]=r.x,E[8]=r.y,E},F.dr=256,F.ds=xo,F.dt=gc,F.du=Ic,F.dv=ep,F.dw=Jh,F.dx=jf,F.dy=sm,F.dz=function(r,e){const i=[];for(const o in r)o in e||i.push(o);return i},F.e=function(r){return r.indexOf("mapbox:")===0},F.e$=function(r,e){var i=e[0],o=e[1],a=e[2],c=e[3],h=e[4],f=e[5],_=e[6],y=e[7],v=e[8],b=v*h-f*y,T=-v*c+f*_,E=y*c-h*_,C=i*b+o*T+a*E;return C?(r[0]=b*(C=1/C),r[1]=(-v*o+a*y)*C,r[2]=(f*o-a*h)*C,r[3]=T*C,r[4]=(v*i-a*_)*C,r[5]=(-f*i+a*c)*C,r[6]=E*C,r[7]=(-y*i+o*_)*C,r[8]=(h*i-o*c)*C,r):null},F.e0=Go,F.e1=jy,F.e2=vc,F.e3=io,F.e4=Ns,F.e5=es,F.e6=Po,F.e7=class{isDataAvailableAtPoint(r){const e=this._source();if(this.isUsingMockSource()||!e||r.y<0||r.y>1)return!1;const i=e.getSource().maxzoom,o=1<<i,a=Math.floor(r.x),c=Math.floor((r.x-a)*o),h=Math.floor(r.y*o),f=this.findDEMTileFor(new Yn(i,a,i,c,h));return!(!f||!f.dem)}getAtPointOrZero(r,e=0){return this.getAtPoint(r,e)||0}getAtPoint(r,e,i=!0){if(this.isUsingMockSource())return null;e==null&&(e=null);const o=this._source();if(!o||r.y<0||r.y>1)return e;const a=o.getSource().maxzoom,c=1<<a,h=Math.floor(r.x),f=r.x-h,_=new Yn(a,h,a,Math.floor(f*c),Math.floor(r.y*c)),y=this.findDEMTileFor(_);if(!y||!y.dem)return e;const v=y.dem,b=1<<y.tileID.canonical.z,T=(f*b-y.tileID.canonical.x)*v.dim,E=(r.y*b-y.tileID.canonical.y)*v.dim,C=Math.floor(T),P=Math.floor(E);return(i?this.exaggeration():1)*vt(vt(v.get(C,P),v.get(C,P+1),E-P),vt(v.get(C+1,P),v.get(C+1,P+1),E-P),T-C)}static getAtTileOffset(r,e,i,o){const a=1<<r.canonical.z;return o?o.pointElevation(e):i?i.getAtPointOrZero(new kn(r.wrap+(r.canonical.x+e.x/rt)/a,(r.canonical.y+e.y/rt)/a)):0}static getAtTileOffsetFunc(r,e,i,o){return(a,c,h)=>{const f=this.getAtTileOffset(r,a,c,h),_=o.upVector(r.canonical,a.x,a.y);return li(_,_,f*o.upVectorScale(r.canonical,e,i).metersToTile),_}}getForTilePoints(r,e,i,o){if(this.isUsingMockSource())return!1;const a=Md.create(this,r,o);return!!a&&(e.forEach(c=>{c[2]=this.exaggeration()*a.getElevationAt(c[0],c[1],i,!0)}),!0)}getMinMaxForTile(r){if(this.isUsingMockSource())return null;const e=this.findDEMTileFor(r);if(!e||!e.dem)return null;const i=e.dem.tree,o=e.tileID,a=1<<r.canonical.z-o.canonical.z;let c=r.canonical.x/a-o.canonical.x,h=r.canonical.y/a-o.canonical.y,f=0;for(let _=0;_<r.canonical.z-o.canonical.z&&!i.leaves[f];_++){c*=2,h*=2;const y=2*Math.floor(h)+Math.floor(c);f=i.childOffsets[f]+y,c%=1,h%=1}return{min:this.exaggeration()*i.minimums[f],max:this.exaggeration()*i.maximums[f]}}getMinElevationBelowMSL(){throw new Error("Pure virtual method called.")}raycast(r,e,i){throw new Error("Pure virtual method called.")}pointCoordinate(r){throw new Error("Pure virtual method called.")}_source(){throw new Error("Pure virtual method called.")}isUsingMockSource(){throw new Error("Pure virtual method called.")}exaggeration(){throw new Error("Pure virtual method called.")}findDEMTileFor(r){throw new Error("Pure virtual method called.")}get visibleDemTiles(){throw new Error("Getter must be implemented in subclass.")}getMinMaxForVisibleTiles(){const r=this.visibleDemTiles;if(r.length===0)return null;let e=!1,i=Number.MAX_VALUE,o=Number.MIN_VALUE;for(const a of r){const c=this.getMinMaxForTile(a.tileID);c&&(i=Math.min(i,c.min),o=Math.max(o,c.max),e=!0)}return e?{min:i,max:o}:null}},F.e8=pd,F.e9=Mr,F.eA=fv,F.eB=kx,F.eC=jr,F.eD=fr,F.eE=function(r,e){const i=[0,0,0];return ir(i,i,Z_(Qa(e.canonical))),ir(i,i,r),i},F.eF=r=>({u_matrix:new ta(r),u_texsize:new ao(r),u_pixels_to_tile_units:new lp(r),u_device_pixel_ratio:new gr(r),u_width_scale:new gr(r),u_floor_width_scale:new gr(r),u_image:new Pu(r),u_units_to_pixels:new ao(r),u_tile_units_to_pixels:new gr(r),u_alpha_discard_threshold:new gr(r),u_trim_offset:new ao(r),u_trim_fade_range:new ao(r),u_trim_gradient_mix_range:new ao(r),u_trim_color:new ea(r),u_zbias_factor:new gr(r),u_tile_to_meter:new gr(r),u_ground_shadow_factor:new Ru(r),u_pattern_transition:new gr(r),u_opacity_multiplier:new gr(r)}),F.eG=r=>({u_matrix:new ta(r),u_pixels_to_tile_units:new lp(r),u_device_pixel_ratio:new gr(r),u_width_scale:new gr(r),u_floor_width_scale:new gr(r),u_units_to_pixels:new ao(r),u_dash_image:new Pu(r),u_gradient_image:new Pu(r),u_image_height:new gr(r),u_texsize:new ao(r),u_tile_units_to_pixels:new gr(r),u_alpha_discard_threshold:new gr(r),u_trim_offset:new ao(r),u_trim_fade_range:new ao(r),u_trim_gradient_mix_range:new ao(r),u_trim_color:new ea(r),u_zbias_factor:new gr(r),u_tile_to_meter:new gr(r),u_ground_shadow_factor:new Ru(r),u_opacity_multiplier:new gr(r)}),F.eH=r=>({u_camera_to_center_distance:new gr(r),u_extrude_scale:new lp(r),u_device_pixel_ratio:new gr(r),u_matrix:new ta(r),u_inv_rot_matrix:new ta(r),u_merc_center:new ao(r),u_tile_id:new Ru(r),u_zoom_transition:new gr(r),u_up_dir:new Ru(r),u_emissive_strength:new gr(r)}),F.eI=Kf,F.eJ=By,F.eK=V0,F.eL=(r,e,i,o,a,c)=>{const h=r.transform,f=h.projection.name==="globe";let _;if(c.paint.get("circle-pitch-alignment")==="map")if(f){const v=fv(h.zoom,e.canonical)*h._pixelsPerMercatorPixel;_=Float32Array.from([v,0,0,v])}else _=h.calculatePixelsToTileUnitsMatrix(i);else _=new Float32Array([h.pixelsToGLUnits[0],0,0,h.pixelsToGLUnits[1]]);const y={u_camera_to_center_distance:r.transform.getCameraToCenterDistance(h.projection),u_matrix:r.translatePosMatrix(e.projMatrix,i,c.paint.get("circle-translate"),c.paint.get("circle-translate-anchor")),u_device_pixel_ratio:_r.devicePixelRatio,u_extrude_scale:_,u_inv_rot_matrix:xT,u_merc_center:[0,0],u_tile_id:[0,0,0],u_zoom_transition:0,u_up_dir:[0,0,0],u_emissive_strength:c.paint.get("circle-emissive-strength")};if(f){y.u_inv_rot_matrix=o,y.u_merc_center=a,y.u_tile_id=[e.canonical.x,e.canonical.y,1<<e.canonical.z],y.u_zoom_transition=zc(h.zoom);const v=a[0]*rt,b=a[1]*rt;y.u_up_dir=h.projection.upVector(new Tp(0,0,0),v,b)}return y},F.eM=db,F.eN=(r,e,i,o,a,c,h,f,_,y)=>{const v=r.transform,b=v.pitch<15?vt(.07,.7,Y((14-v.zoom)/5,0,1)):.07,T=i.paint.get("line-trim-color-use-theme").constantOr("default")==="none";return{u_matrix:hb(r,e,i,o),u_texsize:e.imageAtlasTexture?e.imageAtlasTexture.size:[0,0],u_pixels_to_tile_units:v.calculatePixelsToTileUnitsMatrix(e),u_device_pixel_ratio:a,u_width_scale:c,u_floor_width_scale:h,u_image:0,u_tile_units_to_pixels:ub(e,v),u_units_to_pixels:[1/v.pixelsToGLUnits[0],1/v.pixelsToGLUnits[1]],u_alpha_discard_threshold:0,u_trim_offset:f,u_trim_fade_range:i.paint.get("line-trim-fade-range"),u_trim_gradient_mix_range:[1,1],u_trim_color:i.paint.get("line-trim-color").toPremultipliedRenderColor(T?null:i.lut).toArray01(),u_zbias_factor:b,u_tile_to_meter:yo(e.tileID.canonical,0),u_ground_shadow_factor:_,u_pattern_transition:y,u_opacity_multiplier:1}},F.eO=(r,e,i,o,a,c,h,f,_,y)=>{const v=r.transform,b=v.calculatePixelsToTileUnitsMatrix(e),T=i.paint.get("line-trim-color-use-theme").constantOr("default")==="none",E=v.pitch<15?vt(.07,.7,Y((14-v.zoom)/5,0,1)):.07;return{u_matrix:hb(r,e,i,o),u_pixels_to_tile_units:b,u_device_pixel_ratio:c,u_width_scale:h,u_floor_width_scale:f,u_units_to_pixels:[1/v.pixelsToGLUnits[0],1/v.pixelsToGLUnits[1]],u_dash_image:0,u_gradient_image:1,u_image_height:a,u_texsize:fb(i)&&e.lineAtlasTexture?e.lineAtlasTexture.size:[0,0],u_tile_units_to_pixels:ub(e,r.transform),u_alpha_discard_threshold:0,u_trim_offset:_,u_trim_fade_range:i.paint.get("line-trim-fade-range"),u_trim_gradient_mix_range:[1,1],u_trim_color:i.paint.get("line-trim-color").toPremultipliedRenderColor(T?null:i.lut).toArray01(),u_zbias_factor:E,u_tile_to_meter:yo(e.tileID.canonical,0),u_ground_shadow_factor:y,u_opacity_multiplier:1}},F.eP=H,F.eQ=Vp,F.eR=ST,F.eS=Jy,F.eT=cs,F.eU=function(r,e){var i=Math.sin(e),o=Math.cos(e);return r[0]=o,r[1]=0,r[2]=-i,r[3]=0,r[4]=0,r[5]=1,r[6]=0,r[7]=0,r[8]=i,r[9]=0,r[10]=o,r[11]=0,r[12]=0,r[13]=0,r[14]=0,r[15]=1,r},F.eV=function(r,e){var i=Math.sin(e),o=Math.cos(e);return r[0]=1,r[1]=0,r[2]=0,r[3]=0,r[4]=0,r[5]=o,r[6]=i,r[7]=0,r[8]=0,r[9]=-i,r[10]=o,r[11]=0,r[12]=0,r[13]=0,r[14]=0,r[15]=1,r},F.eW=function(r,e){return r[0]=e[0],r[1]=e[1],r[2]=e[2],r[3]=e[4],r[4]=e[5],r[5]=e[6],r[6]=e[8],r[7]=e[9],r[8]=e[10],r},F.eX=qa,F.eY=Kh,F.eZ=function(r,e,i,o,a){return Y((r-e)/(i-e)*(a-o)+o,o,a)},F.e_=eo,F.ea=Zx,F.eb=l0,F.ec=Ex,F.ed=f0,F.ee=function(){return{API_URL:bi.API_URL,DRACO_URL:bi.DRACO_URL,MESHOPT_URL:bi.MESHOPT_URL,MESHOPT_SIMD_URL:bi.MESHOPT_SIMD_URL,BUILDING_GEN_URL:bi.BUILDING_GEN_URL}},F.ef=Xl,F.eg=Wi,F.eh=sr,F.ei=Ef,F.ej=Od,F.ek=Ku,F.el=it,F.em=function(r){return r.includes(gu)},F.en=function(r){const e=r.lastIndexOf(gu);return e>=0?r.slice(e+1):""},F.eo=function(r){const e=[],i=r.id;return i===void 0&&e.push({message:`layers.${i}: missing required property "id"`}),r.render===void 0&&e.push({message:`layers.${i}: missing required method "render"`}),r.renderingMode&&r.renderingMode!=="2d"&&r.renderingMode!=="3d"&&e.push({message:`layers.${i}: property "renderingMode" must be either "2d" or "3d"`}),e},F.ep=function(r,e,i,o){return r.type==="custom"?new ET(r,e):new PT[r.type](r,e,i,o)},F.eq=Ee,F.er=class extends $u{constructor(r,e){super(r._vectorTileFeature,r._z,r._x,r._y,r.id),r.state&&(this.state={...r.state}),this.target=e.target,this.namespace=e.namespace,e.properties&&(this.properties=e.properties),this.target&&("featuresetId"in this.target&&!this.target.importId||"layerId"in this.target)&&(this.source=r.source,this.sourceLayer=r.sourceLayer,this.layer=r.layer)}toJSON(){const r=super.toJSON();return r.target=this.target,r.namespace=this.namespace,r}},F.es=Sl,F.et=function(r){return r({pluginStatus:qn,pluginURL:ja}),Sl.on("pluginStateChange",r),r},F.eu=O,F.ev=function(r,e,i){const o=zc(i.zoom),a=r.style.map._antialias,c=r.terrain&&r.terrain.exaggeration()>0;return o===0&&!a&&!c},F.ew=function(r,e,i){const o=Si(new Float64Array(16)),a=(e/(1<<r)-.5)*Math.PI*2;return Pn(o,i.globeMatrix,a),Float32Array.from(o)},F.ex=C_,F.ey=G_,F.ez=function(r,e){return[Math.pow(r[0],2.2)*e,Math.pow(r[1],2.2)*e,Math.pow(r[2],2.2)*e]},F.f=Wl,F.f$=function(r,e,i,o,a,c,h,f,_,y){r.iconAtlasPositions=y.iconPositions;const{featureData:v,sizes:b,textAlongLine:T,symbolPlacement:E,coveragePolygons:C,coverageTileZoom:P,symbolAnchorInFrcCoverage:R}=e,z=e.hasAnySecondaryIcon||r.hasAnySecondaryIcon;for(const V of v){const{shapedIcon:N,verticallyShapedIcon:U,feature:q,shapedTextOrientations:W,shapedText:se,layoutTextSize:X,textOffset:ie,isSDFIcon:re,iconPrimary:oe,iconSecondary:me,iconTextFit:xe,iconOffset:we,iconCollisionBounds:Ce,iconVerticalCollisionBounds:Se,textCollisionBounds:qe,elevationFeatureIndex:Me}=V;N_(N,y.iconPositions,oe,me),N_(U,y.iconPositions,oe,me),D1(W,y.iconPositions),B_(oe,me,y.iconPositions),(se||N)&&z1(r,q,W,N,U,_,b,X,0,ie,re,o,a,h,f,z,xe,we,T,E,Ce,Se,qe,0,0,C,P,R,Me)}i&&r.generateCollisionDebugBuffers(c,r.collisionBoxArray,b.textScaleFactor),r.text.uboBinder&&r.text.uboBinder.finalize(),r.icon.uboBinder&&r.icon.uboBinder.finalize()},F.f0=us,F.f1=class{constructor(){this._updateTime=0,this._sourceIds=[],this._activeRegions=[],this._prevRegions=[],this._globalClipBounds={min:new Ue(1/0,1/0),max:new Ue(-1/0,-1/0)}}clear(){this._activeRegions.length>0&&++this._updateTime,this._activeRegions=[],this._prevRegions=[]}get updateTime(){return this._updateTime}getReplacementRegionsForTile(r,e=!1){const i=Iv(new Ue(0,0),new Ue(rt,rt),r),o=[];if(e&&!ix(i,this._globalClipBounds))return o;for(const a of this._activeRegions){if(a.hiddenByOverlap||!ix(i,a))continue;const c=ew(a.min,a.max,r);o.push({min:c.min,max:c.max,sourceId:this._sourceIds[a.priority],footprint:a.footprint,footprintTileId:a.tileId,order:a.order,clipMask:a.clipMask,clipScope:a.clipScope})}return o}setSources(r){this._setSources(r.map(e=>({getSourceId:()=>e.cache.id,getFootprints:()=>{const i=[];for(const o of e.cache.getVisibleCoordinates()){const a=e.cache.getTile(o).buckets[e.layer];a&&a.updateFootprints(o.toUnwrapped(),i)}return i},getOrder:()=>e.order,getClipMask:()=>e.clipMask,getClipScope:()=>e.clipScope})))}_addSource(r){const e=r.getFootprints();if(e.length===0)return;const i=r.getOrder(),o=r.getClipMask(),a=r.getClipScope();for(const c of e){if(!c.footprint)continue;const h=Iv(c.footprint.min,c.footprint.max,c.id);this._activeRegions.push({min:h.min,max:h.max,hiddenByOverlap:!1,priority:this._sourceIds.length,tileId:c.id,footprint:c.footprint,order:i,clipMask:o,clipScope:a})}this._sourceIds.push(r.getSourceId())}_computeReplacement(){this._activeRegions.sort((e,i)=>e.priority-i.priority||Y_(e.min,i.min)||Y_(e.max,i.max)||e.order-i.order||e.clipMask-i.clipMask||(function(o,a){const c=(h,f)=>h+f;return o.length-a.length||o.reduce(c,"").localeCompare(a.reduce(c,""))})(e.clipScope,i.clipScope));let r=this._activeRegions.length!==this._prevRegions.length;if(!r){let e=0;for(;!r&&e!==this._activeRegions.length;){const i=this._activeRegions[e],o=this._prevRegions[e];r=i.priority!==o.priority||!Ev(i,o)||i.order!==o.order||i.clipMask!==o.clipMask||!ro(i.clipScope,o.clipScope),this._activeRegions[e].hiddenByOverlap=o.hiddenByOverlap,++e}}if(r){++this._updateTime;for(const i of this._activeRegions)i.order!==Cp&&(this._globalClipBounds.min.x=Math.min(this._globalClipBounds.min.x,i.min.x),this._globalClipBounds.min.y=Math.min(this._globalClipBounds.min.y,i.min.y),this._globalClipBounds.max.x=Math.max(this._globalClipBounds.max.x,i.max.x),this._globalClipBounds.max.y=Math.max(this._globalClipBounds.max.y,i.max.y));const e=i=>{const o=this._activeRegions;if(i>=o.length)return i;const a=o[i].priority;for(;i<o.length&&o[i].priority===a;)++i;return i};if(this._sourceIds.length>1){let i=0,o=e(i);for(;i!==o;){let a=i;const c=i;for(;a!==o;){const h=this._activeRegions[a];h.hiddenByOverlap=!1;for(let f=0;f<c;f++){const _=this._activeRegions[f];if(!_.hiddenByOverlap&&h.order===Cp&&ix(h,_)&&(h.hiddenByOverlap=Av(h.footprint,h.tileId,_.footprint,_.tileId),h.hiddenByOverlap))break}++a}i=o,o=e(i)}}}}_setSources(r){[this._prevRegions,this._activeRegions]=[this._activeRegions,[]],this._sourceIds=[];for(let e=r.length-1;e>=0;e--)this._addSource(r[e]);this._computeReplacement()}},F.f2=Cp,F.f3=class{constructor(r){this._createGrid(r),this._createPoles(r)}destroy(){this._poleIndexBuffer.destroy(),this._gridBuffer.destroy(),this._gridIndexBuffer.destroy(),this._poleNorthVertexBuffer.destroy(),this._poleSouthVertexBuffer.destroy();for(const r of this._poleSegments)r.destroy();for(const r of this._gridSegments)r.withSkirts.destroy(),r.withoutSkirts.destroy()}_fillGridMeshWithLods(r,e){const i=new _a,o=new sn,a=[],c=r+1+2,h=e[0]+1,f=e[0]+1+(1+e.length),_=(y,v,b)=>{let T=y===c-1?y-2:y===0?y:y-1;return T+=b?24575:0,[T,v]};for(let y=0;y<c;++y)i.emplaceBack(..._(y,0,!0));for(let y=0;y<h;++y)for(let v=0;v<c;++v)i.emplaceBack(..._(v,y,(v===0||v===c-1)&&!0));for(let y=0;y<e.length;++y){const v=e[y];for(let b=0;b<c;++b)i.emplaceBack(..._(b,v,!0))}for(let y=0;y<e.length;++y){const v=o.length,b=e[y]+1+2,T=new sn;for(let P=0;P<b-1;P++){const R=P===b-2,z=R?c*(f-e.length+y-P):c;for(let V=0;V<c-1;V++){const N=P*c+V;P===0||R||V===0||V===c-2?(T.emplaceBack(N+1,N,N+z),T.emplaceBack(N+z,N+z+1,N+1)):(o.emplaceBack(N+1,N,N+z),o.emplaceBack(N+z,N+z+1,N+1))}}const E=Fi.simpleSegment(0,v,i.length,o.length-v);for(let P=0;P<T.uint16.length;P+=3)o.emplaceBack(T.uint16[P],T.uint16[P+1],T.uint16[P+2]);const C=Fi.simpleSegment(0,v,i.length,o.length-v);a.push({withoutSkirts:E,withSkirts:C})}return{vertices:i,indices:o,segments:a}}_createGrid(r){const e=this._fillGridMeshWithLods(Pl,Nf);this._gridSegments=e.segments,this._gridBuffer=r.createVertexBuffer(e.vertices,sv.members),this._gridIndexBuffer=r.createIndexBuffer(e.indices,!0)}_createPoles(r){const e=new sn;for(let h=0;h<=Pl;h++)e.emplaceBack(0,h+1,h+2);this._poleIndexBuffer=r.createIndexBuffer(e,!0);const i=new qa,o=new qa,a=new qa,c=new qa;this._poleSegments=[];for(let h=0,f=0;h<6;h++){const _=360/(1<<h);i.emplaceBack(0,-Zn,0,.5,0),o.emplaceBack(0,-Zn,0,.5,1),a.emplaceBack(0,-Zn,0,.5,.5),c.emplaceBack(0,-Zn,0,.5,.5);for(let y=0;y<=Pl;y++){let v=y/Pl,b=0;const T=vt(0,_,v),[E,C,P]=Ec(j1,G1,T,Zn);i.emplaceBack(E,C,P,v,b),o.emplaceBack(E,C,P,v,1-b);const R=Qt(T);v=.5+.5*Math.sin(R),b=.5+.5*Math.cos(R),a.emplaceBack(E,C,P,v,b),c.emplaceBack(E,C,P,v,1-b)}this._poleSegments.push(Fi.simpleSegment(f,0,66,64)),f+=66}this._poleNorthVertexBuffer=r.createVertexBuffer(i,j_,!1),this._poleSouthVertexBuffer=r.createVertexBuffer(o,j_,!1),this._texturedPoleNorthVertexBuffer=r.createVertexBuffer(a,j_,!1),this._texturedPoleSouthVertexBuffer=r.createVertexBuffer(c,j_,!1)}getGridBuffers(r,e){return[this._gridBuffer,this._gridIndexBuffer,e?this._gridSegments[r].withSkirts:this._gridSegments[r].withoutSkirts]}getPoleBuffers(r,e){return[e?this._texturedPoleNorthVertexBuffer:this._poleNorthVertexBuffer,e?this._texturedPoleSouthVertexBuffer:this._poleSouthVertexBuffer,this._poleIndexBuffer,this._poleSegments[r]]}},F.f4=Q1,F.f5=Ca,F.f6=function(){return!!document.fullscreenElement||!!document.webkitFullscreenElement},F.f7=j,F.f8=h_,F.f9=function(r,e,i){return r[0]=e[0]/i[0],r[1]=e[1]/i[1],r[2]=e[2]/i[2],r},F.fA=Bl,F.fB=k0,F.fC=ng,F.fD=Qr,F.fE=Qc,F.fF=function(r,e){const i=r.layers[0].layout.get("fill-elevation-reference"),o=i==="hd-road-base"||i==="hd-road-markup"?i:null,a=!!e&&e.length>0&&mx(e,r.layers[0].source,r.sourceLayerName);(o||a)&&(r.hdExt=new Hv(r,o,a))},F.fG=function(r,e){const i=r.layers[0].layout.get("line-elevation-reference")==="hd-road-markup",o=!!e&&e.length>0&&mx(e,r.layers[0].source,r.sourceLayerName);(i||o)&&(r.hdExt=new Zv(i,o))},F.fH=Ou,F.fI=function(r){const e=r.layers[0];e.type==="circle"&&e.layout.get("circle-elevation-reference")==="hd-road-markup"&&(r.hdExt=new Wv)},F.fJ=function(r){r.layers[0].layout.get("symbol-elevation-reference")==="hd-road-markup"&&(r.hdExt=new Xv)},F.fK=nt,F.fL=Wa,F.fM=2,F.fN=jb,F.fO=Gb,F.fP=M_,F.fQ=mx,F.fR=Ps,F.fS=function(r,e){const i=ng(r);return i!==null&&!!(e&1<<i)},F.fT=Le,F.fU=oi,F.fV=1,F.fW=function(r,e,i,o,a,c,h,f=1,_,y,v,b,T,E,C,P,R){r.createArrays(),r.tilePixelRatio=rt/(512*r.overscaling),r.compareText={},r.iconsNeedLinear=!1;const z=r.layers[0].layout,V=r.layers[0]._unevaluatedLayout._values,N={};N.scaleFactor=f,N.textSizeScaleRange=z.get("text-size-scale-range"),N.iconSizeScaleRange=z.get("icon-size-scale-range");
7const[U,q]=N.textSizeScaleRange,[W,se]=N.iconSizeScaleRange;N.textScaleFactor=Y(N.scaleFactor,U,q),N.iconScaleFactor=Y(N.scaleFactor,W,se);const X=V["text-size"],ie=V["icon-size"];if(r.textSizeData.kind==="composite"){const{minZoom:Se,maxZoom:qe}=r.textSizeData;N.compositeTextSizes=[X.possiblyEvaluate(new xt(Se,{worldview:v}),c),X.possiblyEvaluate(new xt(qe,{worldview:v}),c)]}if(r.iconSizeData.kind==="composite"){const{minZoom:Se,maxZoom:qe}=r.iconSizeData;N.compositeIconSizes=[ie.possiblyEvaluate(new xt(Se,{worldview:v}),c,b),ie.possiblyEvaluate(new xt(qe,{worldview:v}),c,b)]}N.layoutTextSize=X.possiblyEvaluate(new xt(h+1,{worldview:v}),c),N.layoutIconSize=ie.possiblyEvaluate(new xt(h+1,{worldview:v}),c,b),N.textMaxSize=X.possiblyEvaluate(new xt(18,{worldview:v}),c);const re=z.get("symbol-placement"),oe=z.get("text-rotation-alignment")==="map"&&re!=="point",me=z.get("text-size");let xe=!1;const we=[],Ce=T!=null&&T!==0;for(const Se of r.features){if(Ce&&Se.properties&&P&&P(Se.properties,T))continue;let qe=65535;if(r.hdExt&&Se.properties&&Object.hasOwn(Se.properties,Ps)){const gi=+Se.properties[Ps];if(!Number.isNaN(gi)){const Ri=r.hdExt.resolveRoadElevation(Se,gi);if(Ri==="defer")continue;qe=Ri}}const Me=z.get("text-font").evaluate(Se,{},c).join(","),Ie=me.evaluate(Se,{},c)*N.textScaleFactor,Pe=N.layoutTextSize.evaluate(Se,{},c)*N.textScaleFactor,Ne=N.layoutIconSize.evaluate(Se,{},c,b)*N.iconScaleFactor,ke={horizontal:{},vertical:void 0},$e=Se.text;let ze,He=[0,0];if($e){const gi=$e.toString(),Ri=z.get("text-letter-spacing").evaluate(Se,{},c)*Mr,mr=z.get("text-line-height").evaluate(Se,{},c)*Mr,ln=Zm(gi)?Ri:0,hr=z.get("text-anchor").evaluate(Se,{},c),zt=z.get("text-variable-anchor");if(!zt){const er=z.get("text-radial-offset").evaluate(Se,{},c);if(er)He=Go(hr,[er*Mr,Er]);else{const Bi=z.get("text-offset").evaluate(Se,{},c);He=[Bi[0]*Mr,Bi[1]*Mr]}}let yr=oe?"center":z.get("text-justify").evaluate(Se,{},c);const Tn=re==="point",Zr=Tn?z.get("text-max-width").evaluate(Se,{},c)*Mr:1/0,Wr=er=>{r.allowVerticalPlacement&&Tl(gi)&&(ke.vertical=k($e,e,i,a,Me,Zr,mr,hr,er,ln,He,M.vertical,!0,Pe,Ie,_,N.textScaleFactor))};if(!oe&&zt){const er=yr==="auto"?zt.map(Di=>jy(Di)):[yr];let Bi=!1;for(let Di=0;Di<er.length;Di++){const vr=er[Di];if(!ke.horizontal[vr])if(Bi)ke.horizontal[vr]=ke.horizontal[0];else{const Rr=k($e,e,i,a,Me,Zr,mr,"center",vr,ln,He,M.horizontal,!1,Pe,Ie,_,N.textScaleFactor);Rr&&(ke.horizontal[vr]=Rr,Bi=Rr.positionedLines.length===1)}}Wr("left")}else{if(yr==="auto"&&(yr=jy(hr)),Tn||z.get("text-writing-mode").includes("horizontal")||!Tl(gi)){const er=k($e,e,i,a,Me,Zr,mr,hr,yr,ln,He,M.horizontal,!1,Pe,Ie,_,N.textScaleFactor);er&&(ke.horizontal[yr]=er)}Wr(Tn?"left":yr)}}let Ye,st,Je,Qe,dt,wt,Bt=!1;const lt=z.get("icon-text-fit").evaluate(Se,{},c);if(Se.icon&&Se.icon.hasPrimary()){const gi=va(Se.icon,r.iconSizeData,V["icon-size"],c,r.zoom,
7Se,_,N.iconScaleFactor,v,b);Ye=gi.iconPrimary,Je=gi.iconSecondary;const Ri=Ye.toString();if(st=o.get(Ri),st&&(dt=z.get("icon-offset").evaluate(Se,{},c),wt=z.get("icon-anchor").evaluate(Se,{},c),ze=de(a.get(Ri),Je?a.get(Je.toString()):void 0,dt,wt),Bt=st.sdf,r.sdfIcons===void 0?r.sdfIcons=st.sdf:r.sdfIcons!==st.sdf&&ht("Style sheet warning: Cannot mix SDF and non-SDF icons in one buffer"),(st.pixelRatio!==r.pixelRatio||z.get("icon-rotate").constantOr(1)!==0)&&(r.iconsNeedLinear=!0)),Je){const mr=Je.toString();Qe=o.get(mr)}}xe=xe||!(!Se.icon||!Se.icon.hasSecondary());const Et=V_(ke.horizontal)||ke.vertical;r.iconsInText||(r.iconsInText=!!Et&&Et.iconsInText);const Rt=Pe*N.textScaleFactor/Mr,{defaultShapedIcon:ki,verticallyShapedIcon:qt}=L1(r,ze,z,Se,c,ke,Rt,dt,lt);lt!=="none"&&ze&&(be(ze)||Te(ze))&&($o(0,st,Ye,ze,ki,lt,y,o,a),$o(0,Qe,Je,ze,ki,lt,y,o,a),qt&&($o(0,st,Ye,ze,qt,lt,y,o,a),$o(0,Qe,Je,ze,qt,lt,y,o,a))),ze=ki;const{iconBBox:ni,iconVerticalBBox:_i,textBBox:$i,textVerticalBBox:Ir}=xa(r,ze,qt,z,Se,c,Ne,dt,N,a,wt,ke,Pe,He,b);we.push({feature:Se,shapedTextOrientations:ke,shapedText:Et,shapedIcon:ze,iconPrimary:Ye,iconSecondary:Je,iconOffset:dt,iconAnchor:wt,verticallyShapedIcon:qt,layoutTextSize:Pe,layoutIconSize:Ne,textOffset:He,isSDFIcon:Bt,iconTextFit:lt,iconCollisionBounds:ni,iconVerticalCollisionBounds:_i,textCollisionBounds:$i,textVerticalCollisionBounds:Ir,elevationFeatureIndex:qe})}return r.hdExt&&r.hdExt.clearWorkerState(),{featureData:we,sizes:N,hasAnySecondaryIcon:xe,textAlongLine:oe,symbolPlacement:re,coverageFrcMask:T,coveragePolygons:E,coverageTileZoom:C,isFeatureCoveredByFrcMask:P,symbolAnchorInFrcCoverage:R}}
vendor: 20,095 bytes, line 7
7,F.fX=Ci,F.fY=kt,F.fZ=hi,F.f_=Kt,F.fa=Ia,F.fb=Rl,F.fc=fn,F.fd=Li,F.fe=function([r,e,i]){const o=Math.hypot(r,e,i),a=Math.atan2(r,i),c=.5*Math.PI-Math.acos(-e/o);return new ui(en(a),en(c))},F.ff=Ko,F.fg=yx,F.fh=function(r,e){rm=r,jc=e},F.fi=ex,F.fj=mv,F.fk=function(r){const e=[0,0,0],i=Si(new Float64Array(16));return Ni(i,r.pixelMatrix,r.globeMatrix),ir(e,e,i),new Ue(e[0],e[1])},F.fl=function(r,e){if(!r||!e)throw new Error("TileProvider name and URL are required");bi.TILE_PROVIDER_URLS[r]=_r.resolveURL(e)},F.fm=Rh,F.fn=function(r,e,i=!1){if(qn===so.deferred||qn===so.loading||qn===so.loaded)throw new Error("setRTLTextPlugin cannot be called multiple times.");ja=_r.resolveURL(r),qn=so.deferred,Sf=e,If(),i||Km()},F.fo=function(r){bi.BUILDING_GEN_URL=_r.resolveURL(r)},F.fp=Fr,F.fq=function(r){const e=_r.resolveURL(r);bi.MESHOPT_URL=e,bi.MESHOPT_SIMD_URL=e},F.fr=Pi,F.fs=function(r){bi.DRACO_URL=_r.resolveURL(r)},F.ft=Do,F.fu=function(r){const e=om();if(!e)return;const i=e.delete(im);r&&i.then(()=>r()).catch(r)},F.fv=function(r){bi.MAX_PARALLEL_IMAGE_REQUESTS=r},F.fw=function(r){bi.API_URL=r},F.fx=function(r){bi.ACCESS_TOKEN=r},F.fy="hd_road_elevation",F.fz=class{static parseFrom(r,e){const i=Nl.parse(r);if(!i)return[];let{vertices:o,features:a}=i;const c=1/yo(e);a.sort((y,v)=>y.id-v.id),o.sort((y,v)=>y.id-v.id||y.idx-v.idx),o=o.filter((y,v,b)=>v===b.findIndex(T=>T.id===y.id&&T.idx===y.idx));const h=new Array;let f=0;const _=o.length;for(const y of a){if(y.constantHeight){h.push(new Vl(y.id,y.bounds,y.constantHeight));continue}for(;f!==_&&o[f].id<y.id;)f++;if(f===_||o[f].id!==y.id)continue;const v=new Array,b=new Array,T=f;for(;f!==_&&o[f].id===y.id;){const E=o[f];if(v.push({position:E.position,height:E.height,extent:E.extent,index:E.idx}),f!==T&&o[f-1].idx===E.idx-1){const C=f-T;b.push({a:C-1,b:C})}f++}h.push(new Vl(y.id,y.bounds,void 0,v,b,c))}return h}},F.g=bi,F.g0=fp,F.g1=function(r){return r<=1?1:Math.pow(2,Math.floor(Math.log2(r)))},F.g2=zg,F.g3=Za,F.g4=class{constructor(r=new Uint8Array(16)){this.buf=ArrayBuffer.isView(r)?r:new Uint8Array(r),this.dataView=new DataView(this.buf.buffer,this.buf.byteOffset,this.buf.byteLength),this.pos=0,this.length=this.buf.length}writeTag(r,e){this.writeVarint(r<<3|e)}realloc(r){let e=this.length||16;for(;e<this.pos+r;)e*=2;if(e!==this.length){const i=new Uint8Array(e);i.set(this.buf),this.buf=i,this.dataView=new DataView(i.buffer),this.length=e}}finish(){return this.length=this.pos,this.pos=0,this.buf.subarray(0,this.length)}writeFixed32(r){this.realloc(4),this.dataView.setInt32(this.pos,r,!0),this.pos+=4}writeSFixed32(r){this.realloc(4),this.dataView.setInt32(this.pos,r,!0),this.pos+=4}writeFixed64(r){this.realloc(8),this.dataView.setInt32(this.pos,-1&r,!0),this.dataView.setInt32(this.pos+4,Math.floor(r*yd),!0),this.pos+=8}writeSFixed64(r){this.realloc(8),this.dataView.setInt32(this.pos,-1&r,!0),this.dataView.setInt32(this.pos+4,Math.floor(r*yd),!0),this.pos+=8}writeVarint(r){if((r=+r||0)>=0&&r<128)return this.pos>=this.length&&this.realloc(1),void(this.buf[this.pos++]=r);r>268435455||r<0?(function(e,i){let o,a;if(e>=0?(o=e%4294967296|0,a=e/4294967296|0):(o=~(-e%4294967296),a=~(-e/4294967296),4294967295^o?o=o+1|0:(o=0,a=a+1|0)),e>=18446744073709552e3||e<-18446744073709552e3)throw new Error("Given varint doesn't fit into 10 bytes");i.realloc(10),(function(c,h,f){f.buf[f.pos++]=127&c|128,c>>>=7,f.buf[f.pos++]=127&c|128,c>>>=7,f.buf[f.pos++]=127&c|128,c>>>=7,f.buf[f.pos++]=127&c|128,f.buf[f.pos]=127&(c>>>=7)})(o,0,i),(function(c,h){const f=(7&c)<<4;h.buf[h.pos++]|=f|((c>>>=3)?128:0),c&&(h.buf[h.pos++]=127&c|((c>>>=7)?128:0),c&&(h.buf[h.pos++]=127&c|((c>>>=7)?128:0),c&&(h.buf[h.pos++]=127&c|((c>>>=7)?128:0),c&&(h.buf[h.pos++]=127&c|((c>>>=7)?128:0),c&&(h.buf[h.pos++]=127&c)))))})(a,i)})(r,this):(this.realloc(4),this.buf[this.pos++]=127&r|(r>127?128:0),r<=127||(this.buf[this.pos++]=127&(r>>>=7)|(r>127?128:0),r<=127||(this.buf[this.pos++]=127&(r>>>=7)|(r>127?128:0),r<=127||(this.buf[this.pos++]=r>>>7&127))))}writeSVarint(r){this.writeVarint(r<0?2*-r-1:2*r)}writeBoolean(r){this.writeVarint(+r)}writeString(r){r=String(r),this.realloc(4*r.length),this.pos++;const e=this.pos;this.pos=(function(o,a,c){for(let h,f,_=0;_<a.length;_++){if(h=a.charCodeAt(_),h>55295&&h<57344){if(!f){h>56319||_+1===a.length?(o[c++]=239,o[c++]=191,o[c++]=189):f=h;continue}if(h<56320){o[c++]=239,o[c++]=191,o[c++]=189,f=h;continue}h=f-55296<<10|h-56320|65536,f=null}else f&&(o[c++]=239,o[c++]=191,o[c++]=189,f=null);h<128?o[c++]=h:(h<2048?o[c++]=h>>6|192:(h<65536?o[c++]=h>>12|224:(o[c++]=h>>18|240,o[c++]=h>>12&63|128),o[c++]=h>>6&63|128),o[c++]=63&h|128)}return c})(this.buf,r,this.pos);const i=this.pos-e;i>=128&&t(e,i,this),this.pos=e-1,this.writeVarint(i),this.pos+=i}writeFloat(r){this.realloc(4),this.dataView.setFloat32(this.pos,r,!0),this.pos+=4}writeDouble(r){this.realloc(8),this.dataView.setFloat64(this.pos,r,!0),this.pos+=8}writeBytes(r){const e=r.length;this.writeVarint(e),this.realloc(e),this.buf.set(r,this.pos),this.pos+=e}writeRawMessage(r,e){this.pos++;const i=this.pos;r(e,this);const o=this.pos-i;o>=128&&t(i,o,this),this.pos=i-1,this.writeVarint(o),this.pos+=o}writeMessage(r,e,i){this.writeTag(r,2),this.writeRawMessage(e,i)}writePackedVarint(r,e){e.length&&this.writeMessage(r,n,e)}writePackedSVarint(r,e){e.length&&this.writeMessage(r,l,e)}writePackedBoolean(r,e){e.length&&this.writeMessage(r,m,e)}writePackedFloat(r,e){e.length&&this.writeMessage(r,d,e)}writePackedDouble(r,e){e.length&&this.writeMessage(r,p,e)}writePackedFixed32(r,e){e.length&&this.writeMessage(r,g,e)}writePackedSFixed32(r,e){e.length&&this.writeMessage(r,x,e)}writePackedFixed64(r,e){e.length&&this.writeMessage(r,w,e)}writePackedSFixed64(r,e){e.length&&this.writeMessage(r,S,e)}writeBytesField(r,e){this.writeTag(r,2),this.writeBytes(e)}writeFixed32Field(r,e){this.writeTag(r,5),this.writeFixed32(e)}writeSFixed32Field(r,e){this.writeTag(r,5),this.writeSFixed32(e)}writeFixed64Field(r,e){this.writeTag(r,1),this.writeFixed64(e)}writeSFixed64Field(r,e){this.writeTag(r,1),this.writeSFixed64(e)}writeVarintField(r,e){this.writeTag(r,0),this.writeVarint(e)}writeSVarintField(r,e){this.writeTag(r,0),this.writeSVarint(e)}writeStringField(r,e){this.writeTag(r,2),this.writeString(e)}writeFloatField(r,e){this.writeTag(r,5),this.writeFloat(e)}writeDoubleField(r,e){this.writeTag(r,1),this.writeDouble(e)}writeBooleanField(r,e){this.writeVarintField(r,+e)}},F.g5=function(r){let e=0;if(new Uint32Array(r,0,1)[0]!==r0){const i=new Uint32Array(r,0,7),[,,o,a,c,h]=i;e=i.byteLength+a+c+h+c,(o!==r.byteLength||e>=r.byteLength)&&ht("Invalid b3dm header information.")}return a0(r,e)},F.g6=function(r,e){const i=r.json.extensionsUsed&&r.json.extensionsUsed.includes("mbx_bvh"),o=Ex(r);for(const a of o){if(!i)for(const c of a.meshes)jw(c);a.lights&&(a.lightMeshIndex=a.meshes.length,a.meshes.push(Gw(a.lights,e)))}return o},F.g7=Dg,F.g8=yi,F.g9=Ys,F.ga=so,F.gb=function(r){Un(),la?.then(e=>{e.keys().then(i=>{for(let o=0;o<i.length-r;o++)e.delete(i[o]).catch(a=>ht(a.message))}).catch(i=>ht(i.message))}).catch(e=>ht(e.message))},F.h=async function(r,e){return $c(Object.assign(r,{method:"GET"}),e)},F.i=function(r){return bi.API_STYLE_REGEX.test(r)&&!kd(r)},F.j=function(r){return btoa(encodeURIComponent(r).replace(/%([0-9A-F]{2})/g,(e,i)=>String.fromCharCode(+("0x"+i))))},F.k=Ts,F.l=function(r){return decodeURIComponent(atob(r).split("").map(e=>"%"+("00"+e.charCodeAt(0).toString(16)).slice(-2)).join(""))},F.m=_e,F.n=xc,F.o=Gs,F.p=async function(r,e){return $c(Object.assign(r,{method:"POST"}),e)},F.q=async function(r,e){Ts.supported&&(r.headers||(r.headers={}),r.headers.accept="image/webp,*/*");const i=await(function(o){return new Promise((a,c)=>{if(o&&o.aborted)return void c(o.reason);const h=()=>{const y=Kl.shift();y?y():Yu--};if(Yu<bi.MAX_PARALLEL_IMAGE_REQUESTS)return Yu++,void a(h);const f=()=>{o&&o.removeEventListener("abort",_),a(h)},_=()=>{const y=Kl.indexOf(f);y!==-1&&Kl.splice(y,1),c(o.reason)};o&&o.addEventListener("abort",_),Kl.push(f)})})(e);try{const{data:o,headers:a}=await Yl(r,e);let c;try{c=await createImageBitmap(new Blob([new Uint8Array(o)],{type:"image/png"}))}catch(h){throw new Error(`Could not load image because of ${h.message}. Please make sure to use a supported image type such as PNG or JPEG. Note that SVGs are not supported.`,{cause:h})}return e&&e.throwIfAborted(),{data:c,headers:a}}finally{i()}},F.r=_r,F.s=function(r){try{const e=self[r];return e.setItem("_mapbox_test_",1),e.removeItem("_mapbox_test_"),!0}catch{return!1}},F.t=bn,F.u=function(){return(function r(e){return e?(e^Math.random()*(16>>e/4)).toString(16):([1e7]+-[1e3]+-4e3+-8e3+-1e11).replace(/[018]/g,r)})()},F.v=function(r){return!!r&&Zl.test(r)},F.w=ht,F.x=xr,F.y=Nh,F.z=class{constructor(r){this.cache=new Map,this.textures=new Map,this.textureAccessTimes=new Map,this.textureMemoryUsed=0,this.maxTextureMemory=1024*(r&&r.maxTextureMemoryMB?r.maxTextureMemoryMB:256)*1024,this.currentFrameAtlases=new Set,this.finalizationRegistry=new FinalizationRegistry(e=>{this.cache.delete(e),this.clearExpiredTextures()})}beginFrame(){this.currentFrameAtlases.clear()}calculateTextureMemory(r){return r.image?Math.ceil(r.image.width*r.image.height*4*(r.patternPositions.size>0?1.33:1)):0}evictTexture(r){const e=this.textures.get(r);if(e){const i=this.calculateTextureMemory(r);e.destroy(),this.textures.delete(r),this.textureAccessTimes.delete(r),this.textureMemoryUsed-=i,r.uploaded=!1}}evictTexturesIfNeeded(r){for(;this.textureMemoryUsed+r>this.maxTextureMemory&&this.textures.size>0;){let e=null,i=1/0;for(const[o]of this.textures.entries()){if(this.currentFrameAtlases.has(o))continue;const a=this.textureAccessTimes.get(o)||0;a<i&&(i=a,e=o)}if(!e)break;this.evictTexture(e)}}findCachedAtlas(r){const e=this.cache.get(r.hash);if(e){const i=e.deref();if(i&&i.contentDescriptor&&this.isMipmapCompatible(r,i.contentDescriptor))return i}for(const[,i]of this.cache.entries()){const o=i.deref();if(o&&o.contentDescriptor){const a=r.subsetOf(o.contentDescriptor),c=this.isMipmapCompatible(r,o.contentDescriptor);if(a&&c)return o}}}getTextureForAtlas(r,e,i){this.textureAccessTimes.set(r,performance.now()),this.currentFrameAtlases.add(r);let o=this.textures.get(r);if(o)return o;if(r.image){const a=this.calculateTextureMemory(r);return this.evictTexturesIfNeeded(a),o=new Ct(e,r.image,i,{useMipmap:!!r.patternPositions.size}),this.textures.set(r,o),this.textureMemoryUsed+=a,o}return null}clearExpiredTextures(){for(const[r]of this.textures.entries())if(!this.isAtlasCached(r)){const e=this.textures.get(r);if(e){const i=this.calculateTextureMemory(r);e.destroy(),this.textureMemoryUsed-=i}this.textures.delete(r),this.textureAccessTimes.delete(r)}}isAtlasCached(r){if(!r.contentDescriptor)return!1;const e=this.cache.get(r.contentDescriptor.hash);return!!e&&e.deref()===r}getOrCache(r){if(!("image"in r)){const a=this.cache.get(r.sourceAtlasHash);if(a){const c=a.deref();if(c)return c}return ht("ImageAtlasReference points to GC'd atlas - atlas may have been evicted"),null}if(!r.contentDescriptor)return r;const e=r.contentDescriptor,i=e.hash,o=this.cache.get(i);if(o){const a=o.deref();if(a&&a.contentDescriptor&&this.isMipmapCompatible(e,a.contentDescriptor))return a}return this.cache.set(i,new WeakRef(r)),this.finalizationRegistry.register(r,i,r),r}isMipmapCompatible(r,e){return!r.requiresMipMaps||e.requiresMipMaps}destroyTextures(){for(const r of this.textures.values())r&&r.destroy();this.textures.clear(),this.textureAccessTimes.clear(),this.textureMemoryUsed=0}clear(){for(const r of this.textures.values())r&&r.destroy();this.cache.clear(),this.textures.clear(),this.textureAccessTimes.clear(),this.textureMemoryUsed=0}}}),Cn(["require","./shared"],function(u,F){function Yi(pe){const O=pe?pe.url.toString():void 0;return O?performance.getEntriesByName(O):[]}function Ht(pe,O){if(Object.hasOwn(pe.layers,F.fy))return F.fz.parseFrom(pe.layers[F.fy],O)}function Wt({buckets:pe,data:O,sourceLayerCoder:j,canonical:Y,options:ce}){if(!ce.elevationFeatures||ce.elevationFeatures.length===0)return;const he=[];for(const ne of Object.values(pe))if(ne instanceof F.c_&&ne.hdExt){const J=ne.hdExt.getUnevaluatedPortalGraph();J&&he.push(J)}const ue=F.fA.evaluate(he);for(const ne of Object.values(pe))if(ne instanceof F.c_&&ne.hdExt){const J=O.layers[j.decode(ne.sourceLayerIndex)];ne.hdExt.setEvaluatedPortalGraph(ue,J,Y,ce.availableImages,ce.brightness,ne.worldview)}}function St(pe){const O=[];for(let j=0;j<pe.length;j++){const Y=pe.feature(j),ce=Y.properties.frc_mask;if(ce==null)continue;const he=Number(ce);if(!he)continue;const ue=Y.loadGeometry();if(ue.length>0){let J=!1;for(const H of ue[0])if(H.x<0||H.x>F.aj||H.y<0||H.y>F.aj){J=!0;break}if(J)continue}const ne=ue.length===1&&ue[0].length===5&&ue[0].some(J=>J.x<=0&&J.y<=0)&&ue[0].some(J=>J.x>=F.aj&&J.y<=0)&&ue[0].some(J=>J.x>=F.aj&&J.y>=F.aj)&&ue[0].some(J=>J.x<=0&&J.y>=F.aj);O.push(new F.fB(he,ne?[]:ue))}return O}function Ti(pe,O,j,Y,ce){const he=F.fC(O);if(he===null)return!1;let ue=j.x,ne=j.y;const J=ce??Y.z;if(Y.z!==J){const H=1<<Y.z-J,ve=F.aj/H;ue=Y.x%H*ve+j.x/H,ne=Y.y%H*ve+j.y/H}for(const H of pe){if(!(H.hasGeometry()&&H.frcMask&1<<he))continue;const ve=H.rings.map(Le=>Le.map(Ee=>[Ee.x,Ee.y]));if(F.fD([ue,ne],ve))return!0}return!1}function mn(pe,O,j,Y){const ce=O.indoorState.activeFloorsVisible;if(!O.sourceLayers)return ce?O.indoorState.activeFloors:void 0;const he=(function(J,H){if(!J)return F.w("No source layers defined in indoor specification"),H;if(J.size===0)return H;const ve=J.difference(H);for(const Le of ve)F.w(`Missing source layer required in indoor specification: ${Le}`);return H.intersection(H)})(O.sourceLayers,new Set(Object.keys(pe.layers))),ue=O.indoorState,ne=(function(J,H,ve,Le,Ee){const it={};for(const et of H){const Xt=J.layers[et];if(Xt)for(let ht=0;ht<Xt.length;ht++){const Tt=Xt.feature(ht);if(_n(Tt)){const{id:Yt,center:yi}=co(Tt);Nt(it,Yt,yi);continue}if(gn(Tt)){const Yt=Ni(Tt,Ee);Si(it,Yt.buildings,Yt.id,Yt)}}else F.w(`indoor source layer not found: ${et}`)}return{buildings:it,activeFloors:F.cM.calculate(it,Le,ve)}})(pe,he,ue.activeFloors,ue.selectedFloorId,Y);return j.notify("setIndoorData",ne),ce?ne.activeFloors:void 0}function Nt(pe,O,j){pe[O]?j&&(pe[O].center=j):pe[O]={floorIds:new Set,center:j||[0,0],floors:{}}}function Si(pe,O,j,Y){for(const ce of O)Nt(pe,ce),pe[ce].floors[j]=Y,pe[ce].floorIds.add(j)}function co(pe){return{id:pe.properties.id.toString(),center:[pe.properties.center_lon||0,pe.properties.center_lat||0]}}function Ni(pe,O){const j=pe.properties.id.toString(),Y=!!pe.properties.is_default&&pe.properties.is_default,ce=pe.properties.connected_floor_ids?new Set(pe.properties.connected_floor_ids.toString().split(";")):new Set,he=pe.properties.conflicted_floor_ids?new Set(pe.properties.conflicted_floor_ids.toString().split(";")):new Set,ue=pe.properties.structure_ids?new Set(pe.properties.structure_ids.toString().split(";")):new Set,ne=pe.properties.name.toString(),J=pe.properties.z_index,H=(function(ve,Le){const Ee=ve.loadGeometry();if(!Ee||Ee.length===0)return;const it=Ee.map(et=>et.map(Xt=>F.fE(Xt,Le,ve.extent)));return it.length===0?void 0:{type:"Polygon",coordinates:[it[0]]}})(pe,O);return{id:j,isDefault:Y,connections:ce,conflicts:he,buildings:ue,name:ne,zIndex:J,geometry:H}}function Mn(pe,O){return O.every(j=>pe.properties&&pe.properties[j]!=null)}function _n(pe){return Mn(pe,["type","id","name"])&&pe.properties.type==="structure"}function gn(pe){return Mn(pe,["type","id","name","z_index"])&&pe.properties.type==="floor"}function Pn(pe,O){pe instanceof F.c_?F.fF(pe,O):pe instanceof F.cZ?F.fG(pe,O):pe instanceof F.fH?F.fI(pe):pe instanceof F.cT&&F.fJ(pe)}function un(pe){for(const O in pe){const j=pe[O];if(j instanceof F.cZ&&j.hdExt&&j.hdExt.hasDeferredElevationFeatures||j instanceof F.cT&&j.hdExt&&j.hdExt.hasDeferredElevationFeatures)return!0}return!1}function hn(pe){if(typeof pe=="number"||typeof pe=="boolean"||typeof pe=="string"||pe==null)return JSON.stringify(pe);if(Array.isArray(pe)){let j="[";for(const Y of pe)j+=`${hn(Y)},`;return`${j}]`}let O="{";for(const j of Object.keys(pe).sort())O+=`${j}:${hn(pe[j])},`;return`${O}}`}function So(pe){let O="";for(const j of F.dX)O+=`/${hn(pe[j])}`;return O}function uo(pe,O){return(function j(Y){return typeof Y=="string"&&Y===O||(Array.isArray(Y)?Y.some(j):!(!Y||typeof Y!="object")&&Object.values(Y).some(j))})(pe)}class ho{constructor(O){this.keyCache=Object.create(null),this._layers=Object.create(null),this._layerConfigs=Object.create(null),O&&this.replace(O)}replace(O,j){this._layerConfigs=Object.create(null),this._layers=Object.create(null),this.update(O,[],j)}update(O,j,Y){this._options=Y;for(const he of O)this._layerConfigs[he.id]=he,(this._layers[he.id]=F.ep(he,this.scope,null,this._options)).compileFilter(Y),this.keyCache[he.id]&&delete this.keyCache[he.id];for(const he of j)delete this.keyCache[he],delete this._layerConfigs[he],delete this._layers[he];this.familiesBySource=Object.create(null);const ce=(function(he,ue){const ne=Object.create(null);for(let H=0;H<he.length;H++){const ve=he[H];let Le=ue&&ue[ve.id];Le||(ve.type==="symbol"?Le=ve.id:(Le=So(ve),ve.type==="line"&&ve.paint&&(uo(ve.paint["line-width"],"line-progress")&&(Le+=`/${hn(ve.paint["line-width"])}`),uo(ve.paint["line-emissive-strength"],"line-progress")&&(Le+=`/${hn(ve.paint["line-emissive-strength"])}`)))),ue&&(ue[ve.id]=Le);let Ee=ne[Le];Ee||(Ee=ne[Le]=[]),Ee.push(ve)}const J=[];for(const H in ne)J.push(ne[H]);return J})(Object.values(this._layerConfigs),this.keyCache);for(const he of ce){const ue=he.map(Ee=>this._layers[Ee.id]),ne=ue[0];if(ne.visibility==="none")continue;const J=ne.source||"";let H=this.familiesBySource[J];H||(H=this.familiesBySource[J]=Object.create(null));const ve=ne.sourceLayer||"_geojsonTileLayer";let Le=H[ve];Le||(Le=H[ve]=[]),Le.push(ue)}}}const Nn=1*F.fM;class Sn{constructor(O){const j={},Y=[];for(const ne in O){const J=O[ne],H=j[ne]={};for(const ve in J.glyphs){const Le=J.glyphs[+ve];if(!Le||Le.bitmap.width===0||Le.bitmap.height===0)continue;const Ee=Le.metrics.localGlyph?Nn:1,it={x:0,y:0,w:Le.bitmap.width+2*Ee,h:Le.bitmap.height+2*Ee};Y.push(it),H[ve]=it}}const{w:ce,h:he}=F.H(Y),ue=new F.fL({width:ce||1,height:he||1});for(const ne in O){const J=O[ne];for(const H in J.glyphs){const ve=J.glyphs[+H];if(!ve||ve.bitmap.width===0||ve.bitmap.height===0)continue;const Le=j[ne][H],Ee=ve.metrics.localGlyph?Nn:1;F.fL.copy(ve.bitmap,ue,{x:0,y:0},{x:Le.x+Ee,y:Le.y+Ee},ve.bitmap)}}this.image=ue,this.positions=j}}function Zt(pe){for(const O of pe)if(O.hdExt!=null||O.requiresHDRuntime)return!0;return!1}function Eo(pe){for(const O of pe)if(O.requiresStandardRuntime)return!0;return!1}function Yr(pe,O,j){const Y=pe!=null&&!!F.fQ&&F.fQ(pe.sourceLayers,O,j);return{applies:Y,frcMask:Y&&pe?pe.frcMask:null,polygons:Y&&pe?pe.polygons:null,tileZoom:Y&&pe?pe.tileZoom:null}}F.fK(Sn,"GlyphAtlas");class ur{constructor(O){this.tileID=new F.br(O.tileID.overscaledZ,O.tileID.wrap,O.tileID.canonical.z,O.tileID.canonical.x,O.tileID.canonical.y),this.tileZoom=O.tileZoom,this.uid=O.uid,this.zoom=O.zoom,this.lut=O.lut,this.canonical=O.tileID.canonical,this.pixelRatio=O.pixelRatio,this.tileSize=O.tileSize,this.source=O.source,this.scope=O.scope,this.overscaling=this.tileID.overscaleFactor(),this.showCollisionBoxes=O.showCollisionBoxes,this.showElevationIdDebug=O.showElevationIdDebug,this.collectResourceTiming=!!O.request&&O.request.collectResourceTiming,this.promoteId=O.promoteId,this.renderSourceType=O.renderSourceType,this.frcCoverage=O.frcCoverage||null,this.elevation=O.elevation||null,this.crossSourceElevationEnabled=!!O.crossSourceElevationEnabled,this.terrainEnabled=!!O.terrainEnabled,this.deferRoadStructure=!1,this.tileTransform=F.cO(O.tileID.canonical,O.projection),this.projection=O.projection,this.worldview=O.worldview,this.localizableLayerIds=O.localizableLayerIds,this.brightness=O.brightness,this.extraShadowCaster=!!O.extraShadowCaster,this.tessellationStep=O.tessellationStep,this.scaleFactor=O.scaleFactor,this.worldview=O.worldview,this.indoor=O.indoor}
7isLayerActiveForTile(O){return!(this.renderSourceType===F.dA.Symbol&&O.type!=="symbol"||this.renderSourceType===F.dA.FillExtrusion&&O.type!=="fill-extrusion"||this.renderSourceType===F.dA.Other&&(O.type==="symbol"||O.type==="fill-extrusion")||this.renderSourceType===F.dA.HdRoadElevation||O.minzoom&&this.zoom<Math.floor(O.minzoom)||O.maxzoom&&this.zoom>=O.maxzoom||O.visibility==="none")}parse(O,j,Y,ce,he,ue){this._parseAfterHD(O,j,Y,ce,he,ue)}_parseAfterHD(O,j,Y,ce,he,ue){let ne;if(this.status="parsing",this.data=O,this.renderSourceType===F.dA.HdRoadCoverage){const ht=O.layers[F.dC];ne=ht&&St?St(ht):[]}this.collisionBoxArray=new F.cS;const J=new F.fN(Object.keys(O.layers).sort()),H=new F.fO(this.tileID,this.promoteId);H.bucketLayerIDs=[];const ve={},Le=new F.fP(256,256),Ee={featureIndex:H,iconDependencies:new Map,patternDependencies:new Map,glyphDependencies:{},lineAtlas:Le,availableImages:Y,brightness:this.brightness,scaleFactor:this.scaleFactor,showElevationIdDebug:this.showElevationIdDebug,elevationFeatures:void 0,elevationParams:this.elevation,crossSourceElevationEnabled:this.crossSourceElevationEnabled,terrainEnabled:this.terrainEnabled,activeFloors:void 0};this.indoor&&mn&&(Ee.activeFloors=mn(O,this.indoor,he,this.canonical));const it=[],et=j.familiesBySource[this.source];if(this.renderSourceType===F.dA.HdRoadElevation){const ht=Ht&&Ht(O,this.canonical)||[],Tt=new Sn({});return this.status="done",void ue(null,{buckets:[],containsHdExt:!1,containsStandardExt:!1,featureIndex:H,collisionBoxArray:this.collisionBoxArray,glyphAtlasImage:Tt.image,lineAtlas:Le,imageAtlas:null,brightness:this.brightness,parsedElevationFeatures:ht})}if(this.deferRoadStructure=!1,this.renderSourceType!==F.dA.HdRoadCoverage&&this.frcCoverage!=null&&!this.frcCoverage.resolved&&this.frcCoverage.frcMask===null){for(const ht in et)if(F.fQ&&F.fQ(this.frcCoverage.sourceLayers,this.source,ht)){this.deferRoadStructure=!0;break}}for(const ht in et){const Tt=O.layers[ht];if(!Tt)continue;let Yt=!1,yi=!1,nr=!1,dr=!1;for(const Ki of et[ht])Ki[0].type==="symbol"?Yt=!0:Ki[0].type==="fill-extrusion"?yi=!0:nr=!0,Ki[0].is3D()&&Ki[0].type!=="model"&&(dr=!0);if(this.extraShadowCaster&&!dr||this.renderSourceType===F.dA.Symbol&&!Yt||this.renderSourceType===F.dA.FillExtrusion&&!yi||(this.renderSourceType===F.dA.Other||this.renderSourceType===F.dA.HdRoadCoverage)&&!nr)continue;const jr=this.frcCoverage!=null&&!!F.fQ&&F.fQ(this.frcCoverage.sourceLayers,this.source,ht);if(this.deferRoadStructure&&jr)continue;Tt.version===1&&F.w(`Vector tile source "${this.source}" layer "${ht}" does not use vector tile spec v2 and therefore may have some rendering errors.`);const fr=J.encode(ht),Gr=[],Vn=this.localizableLayerIds&&this.localizableLayerIds.has(ht);let rs=!1;for(let Ki=0,Ji=0;Ki<Tt.length;Ki++){const or=Tt.feature(Ki),Gi=H.getId(or,ht),xr=or.properties?or.properties.worldview:null;if(Vn&&this.worldview&&typeof xr=="string")if(xr==="all")or.properties.$localized=!0;else{if(!xr.split(",").includes(this.worldview))continue;or.properties.$localized=!0,or.properties.worldview=this.worldview}!rs&&or.properties&&Object.hasOwn(or.properties,F.fR)&&(rs=!0),jr&&this.frcCoverage&&this.frcCoverage.frcMask&&or.properties&&F.fS&&F.fS(or.properties,this.frcCoverage.frcMask)||(Gr.push({feature:or,id:Gi,index:Ji,sourceLayerIndex:fr}),Ji++)}rs&&!Ee.elevationFeatures&&Ht&&(Ee.elevationFeatures=Ht(O,this.canonical));for(const Ki of et[ht]){const Ji=Ki[0];if(this.extraShadowCaster&&(!Ji.is3D()||Ji.type==="model")||this.renderSourceType===F.dA.Symbol&&Ji.type!=="symbol"||this.renderSourceType===F.dA.FillExtrusion&&Ji.type!=="fill-extrusion"||!(this.renderSourceType!==F.dA.Other&&this.renderSourceType!==F.dA.HdRoadCoverage||Ji.type!=="symbol"&&Ji.type!=="fill-extrusion")||!this.isLayerActiveForTile(Ji))continue;Li(Ki,this.zoom,Ee.brightness,Y,this.worldview,Ee.activeFloors);const or=H.bucketLayerIDs.length;H.bucketLayerIDs.push(Ki.map(xr=>F.y(xr.id,xr.scope)));const Gi=()=>{const xr=ve[Ji.id]=Ji.createBucket({index:or,layers:Ki,zoom:this.zoom,lut:this.lut,canonical:this.canonical,pixelRatio:this.pixelRatio,overscaling:this.overscaling,collisionBoxArray:this.collisionBoxArray,sourceLayerIndex:fr,sourceLayerName:ht,sourceID:this.source,projection:this.projection.spec,tessellationStep:this.tessellationStep,styleDefinedModelURLs:ce,worldview:this.worldview,localizable:Vn,availableImages:Y,maxUniformBufferBindings:this.maxUniformBufferBindings,maxUniformBlockSizeDwords:this.maxUniformBlockSizeDwords});Pn&&Pn(xr,this.frcCoverage?this.frcCoverage.sourceLayers:null),xr.populate(Gr,Ee,this.tileID.canonical,this.tileTransform)};Ji.mayUse("HD")||Ji.mayUse("Standard")?it.push(Ji.prepare().then(()=>Gi())):Gi()}}const Xt=()=>{Le.trim();const ht=!(!Ee.elevationFeatures||!Ee.elevationFeatures.some(Ki=>Ki.heightRange.min<0));let Tt,Yt,yi,nr,dr,jr,fr;const Gr={type:"maybePrepare",renderSourceType:this.renderSourceType,zoom:this.zoom},Vn=()=>
vendor: 9,851 bytes, line 7
7{if(Tt)return this.status="done",ue(Tt);if(this.extraShadowCaster){this.status="done";const Ki=Object.values(ve).filter(or=>!or.isEmpty()),Ji=Ee.elevationFeatures;ue(null,{buckets:Ki,containsHdExt:Zt(Ki),containsStandardExt:Eo(Ki),featureIndex:H,collisionBoxArray:null,hasTunnelGeometry:ht,glyphAtlasImage:null,lineAtlas:null,imageAtlas:null,brightness:Ee.brightness,hasDeferredElevationFeatures:!!un&&un(ve),parsedElevationFeatures:Ji,glyphMap:null,iconMap:null,glyphPositions:null})}else if(Yt&&yi&&nr&&fr){const Ji=new Sn(Yt),or=new Map;for(const[xr,_r]of yi.entries()){const{imagePosition:pn}=F.fU(xr,_r,F.fV);or.set(xr,pn)}const Gi={};for(const xr in ve){const _r=ve[xr];if(_r instanceof F.cT){Li(_r.layers,this.zoom,Ee.brightness,Y,this.worldview,Ee.activeFloors);const pn=Yr(this.frcCoverage,this.source,_r.layers[0].sourceLayer);Gi[xr]=F.fW(_r,Yt,Ji.positions,yi,or,this.tileID.canonical,this.tileZoom,this.scaleFactor,this.pixelRatio,dr,this.worldview,Y,pn.frcMask,pn.polygons,pn.tileZoom,F.fS||null,Ti||null)}}dr.size||jr.size?this.rasterizeTask=he.sendCancelable("rasterizeImages",{scope:this.scope,iconTasks:dr,patternTasks:jr},{},(xr,_r)=>{if(!xr)for(const[pn,bi]of _r.entries())yi.has(pn)&&yi.set(pn,Object.assign(yi.get(pn),{data:bi})),nr.has(pn)&&nr.set(pn,Object.assign(nr.get(pn),{data:bi}));rs(Gi,Ji,void 0,fr)}):rs(Gi,Ji,void 0,fr)}},rs=(Ki,Ji,or,Gi)=>{const xr=yi.size>0||nr.size>0,_r=Object.keys(Ki).length>0,pn=Ee.elevationFeatures;if(!xr&&!_r){this.status="done";const Do=Object.values(ve).filter(Pi=>!Pi.isEmpty());return void ue(null,{buckets:Do,containsHdExt:Zt(Do),containsStandardExt:Eo(Do),featureIndex:H,collisionBoxArray:this.collisionBoxArray,hasTunnelGeometry:ht,glyphAtlasImage:Ji.image,lineAtlas:Le,imageAtlas:null,brightness:Ee.brightness,hasDeferredRoadStructure:this.deferRoadStructure,frcCoveragePolygons:ne,hasDeferredElevationFeatures:!!un&&un(ve),parsedElevationFeatures:pn})}const bi=(Do,Pi)=>{for(const Ts in ve){const tn=ve[Ts];if(Ts in Ki)F.f$(tn,Ki[Ts],this.showCollisionBoxes,Y,this.tileID.canonical,this.tileZoom,this.projection,this.brightness,yi,Pi);else if(tn.hasPattern&&(tn instanceof F.cZ||tn instanceof F.c_||tn instanceof F.cB)){Li(tn.layers,this.zoom,Ee.brightness,Y,this.worldview,Ee.activeFloors);const Or=Object.fromEntries(Pi.patternPositions);tn.addFeatures(Ee,this.tileID.canonical,Or,Y,this.tileTransform,this.brightness)}}this.status="done";const Fr=Object.values(ve).filter(Ts=>!Ts.isEmpty());ue(null,{buckets:Fr,containsHdExt:Zt(Fr),containsStandardExt:Eo(Fr),featureIndex:H,collisionBoxArray:this.collisionBoxArray,hasTunnelGeometry:ht,glyphAtlasImage:Ji.image,lineAtlas:Le,imageAtlas:Do,brightness:Ee.brightness,hasDeferredRoadStructure:this.deferRoadStructure,frcCoveragePolygons:ne,hasDeferredElevationFeatures:!!un&&un(ve),parsedElevationFeatures:pn})};if(xr){const Do=new Map,Pi=F.fX(yi,Do),Fr=F.fX(nr,Do),Ts=new F.fY(Pi,Fr,Gi,this.lut,this.scope,Do);he.send("checkAtlasCache",{descriptor:Ts,scope:this.scope}).then(tn=>{let Or,ll;if(tn)Or=new F.fZ(tn.sourceHash),ll=tn;else{const Uc=new F.f_(yi,nr,this.lut,Gi,this.scope);Or=Uc,ll=Uc}bi(Or,ll)}).catch(tn=>{tn.name!=="AbortError"&&F.w(`[Worker] Error checking atlas cache: ${tn.message}`);const Or=new F.f_(yi,nr,this.lut,Gi,this.scope);bi(Or,Or)})}else bi(null,{iconPositions:new Map,patternPositions:new Map})};if(!this.extraShadowCaster){const Ki=F.fT(Ee.glyphDependencies,Gi=>Object.keys(Gi).map(Number));Object.keys(Ki).length?he.send("getGlyphs",{uid:this.uid,stacks:Ki},{metadata:Gr}).then(Gi=>{Tt||(Yt=Gi,Vn())}).catch(Gi=>{Tt||(Tt=Gi,Vn())}):Yt={},fr=new Map;const Ji=Array.from(Ee.iconDependencies.keys()).map(Gi=>F.I.parse(Gi)),or=Array.from(Ee.patternDependencies.keys()).map(Gi=>F.I.parse(Gi));Ji.length||or.length?he.send("getImages",{icons:Ji,patterns:or,source:this.source,scope:this.scope,tileID:this.tileID},{metadata:Gr}).then(Gi=>{if(!Tt){yi=new Map,nr=new Map,dr=this.updateImageMapAndGetImageTaskQueue(yi,Gi.images,Ee.iconDependencies),jr=this.updateImageMapAndGetImageTaskQueue(nr,Gi.images,Ee.patternDependencies);for(const[xr,_r]of Gi.versions.entries())fr.set(xr,_r);Vn()}}).catch(Gi=>{Tt||(Tt=Gi,Vn())}):(yi=new Map,nr=new Map,dr=new Map,jr=new Map)}Wt&&Wt({buckets:ve,data:O,sourceLayerCoder:J,canonical:this.tileID.canonical,options:Ee}),Vn()};it.length>0?Promise.allSettled(it).then(Xt).catch(ue):Xt()}updateParameters(O){this.scaleFactor=O.scaleFactor,this.showCollisionBoxes=O.showCollisionBoxes,this.showElevationIdDebug=O.showElevationIdDebug,this.projection=O.projection,this.brightness=O.brightness,this.tileTransform=F.cO(O.tileID.canonical,O.projection),this.extraShadowCaster=O.extraShadowCaster,this.lut=O.lut,this.worldview=O.worldview,this.indoor=O.indoor,this.frcCoverage=O.frcCoverage||null,this.elevation=O.elevation||null,this.terrainEnabled=!!O.terrainEnabled}updateImageMapAndGetImageTaskQueue(O,j,Y){const ce=new Map;for(const he of j.keys()){const ue=Y.get(he)||[];for(const ne of ue){const J=ne.toString(),H=j.get(ne.id.toString());H.usvg?ce.has(J)||(ce.set(J,ne),O.set(J,{...H})):O.set(J,H)}}return ce}cancelRasterize(){this.rasterizeTask&&this.rasterizeTask.abort()}}function Li(pe,O,j,Y,ce,he){const ue=new F.aa(O,{brightness:j,worldview:ce,activeFloors:he});for(const ne of pe)ne.recalculate(ue,Y)}class ji extends F.E{constructor({actor:O,layerIndex:j,availableImages:Y,availableModels:ce,isSpriteLoaded:he,tileProvider:ue,brightness:ne,maxUniformBufferBindings:J,maxUniformBlockSizeDwords:H}){super(),this.actor=O,this.layerIndex=j,this.availableImages=Y,this.availableModels=ce,this.loadVectorData=F.dO,this.tileProvider=ue,this.loading={},this.loaded={},this.deduped=new F.dN(O.scheduler),this.isSpriteLoaded=he,this.scheduler=O.scheduler,this.brightness=ne,this.maxUniformBufferBindings=J,this.maxUniformBlockSizeDwords=H}loadTileData(O,j){if(!this.tileProvider)return this.loadVectorData(O,j);const Y=new AbortController;return this.loadTileWithProvider(this.tileProvider,O,Y,j),()=>Y.abort()}async loadTileWithProvider(O,j,Y,ce){const{z:he,x:ue,y:ne}=j.tileID.canonical;try{const J=await O.loadTile({z:he,x:ue,y:ne},{request:j.request,signal:Y.signal});if(Y.signal.aborted)return;if(J==null){const ve=new Error("Tile not found");return ve.status=404,ce(ve)}if(J.data==null)return ce(null,null);if(J.data instanceof ImageBitmap)return ce(new Error("Vector tiles require ArrayBuffer data"));const H=new Headers;J.expires&&H.set("expires",J.expires),J.cacheControl&&H.set("cache-control",J.cacheControl),ce(null,{rawData:J.data,headers:H})}catch(J){if(Y.signal.aborted)return;ce(J instanceof Error?J:new Error(String(J)))}}_fetchTileData(O,j){return new Promise((Y,ce)=>{O.abort=this.loadTileData(j,(he,ue)=>{he?ce(he):Y(ue)})})}async _parse(O,j){const Y=!this.isSpriteLoaded;return Y&&await this.once("isSpriteLoaded"),new Promise((ce,he)=>{const ue=()=>O.parse(O.vectorTile,this.layerIndex,this.availableImages,this.availableModels,this.actor,(ne,J)=>{ne?he(ne):ce(J)});Y&&this.scheduler?this.scheduler.add(ue,{type:"parseTile",renderSourceType:j.renderSourceType,zoom:j.tileZoom}):ue()})}async loadTile(O){const j=O.uid,Y=O&&O.request,ce=Y&&Y.collectResourceTiming,he=this.loading[j]=new ur(O);he.maxUniformBufferBindings=this.maxUniformBufferBindings,he.maxUniformBlockSizeDwords=this.maxUniformBlockSizeDwords;const ue=(et,Xt)=>{const ht=he.reloadCallback;ht&&(delete he.reloadCallback,et||!Xt?ht(et,null):he.parse(he.vectorTile,this.layerIndex,this.availableImages,this.availableModels,this.actor,ht))};let ne,J;try{ne=await this._fetchTileData(he,O)}catch(et){J=et}const H=!this.loading[j];if(delete this.loading[j],he.cancelRasterize(),J||H||!ne){if(he.status="done",H||(this.loaded[j]=he),J)throw J;return null}const ve=ne.rawData;let Le;he.vectorTile=ne.vectorTile||new F.g0(new F.d9(ve)),this.loaded=this.loaded||{},this.loaded[j]=he;try{Le=await this._parse(he,O)}catch(et){throw ue(et),et}if(!Le)return ue(null,null),null;const Ee={};if(ce){const et=Yi(Y);et.length>0&&(Ee.resourceTiming=JSON.parse(JSON.stringify(et)))}const it={rawTileData:ve.slice(0),headers:ne.headers,...Le,...Ee};return ue(null,Le),it}async reloadTile(O){const j=this.loaded,Y=O.uid;if(j&&j[Y])return new Promise((ce,he)=>{const ue=j[Y];ue.updateParameters(O);const ne=(J,H)=>{const ve=ue.reloadCallback;ve&&(delete ue.reloadCallback,ue.parse(ue.vectorTile,this.layerIndex,this.availableImages,this.availableModels,this.actor,ve)),J?he(J):ce(H)};ue.status==="parsing"?ue.reloadCallback=ne:ue.status==="done"?ue.vectorTile?ue.parse(ue.vectorTile,this.layerIndex,this.availableImages,this.availableModels,this.actor,ne):ne():ce(void 0)})}abortTile(O){const j=O.uid,Y=this.loading[j];Y&&(Y.abort&&Y.abort(),delete this.loading[j])}removeTile(O){const j=this.loaded,Y=O.uid;j&&j[Y]&&delete j[Y]}}class dn{constructor(O){this.tileProvider=O.tileProvider,this.loading={}}async loadTile(O){const j=O.uid,Y=new AbortController;if(this.loading[j]={cancel:()=>Y.abort()},this.tileProvider)return this.loadTileWithProvider(this.tileProvider,j,O,Y);try{const{data:ce,headers:he}=await F.da(O.request,Y.signal);if(!ce)return null;const ue=await this.decodeTile(j,ce,O.encoding);return ue.headers=he,ue}catch(ce){if(Y.signal.aborted)return null;throw ce}finally{delete this.loading[j]}}async decodeTile(O,j,Y){const ce=j instanceof ImageBitmap?j:await createImageBitmap(new Blob([new Uint8Array(j)],{type:"image/png"})),he=1-(ce.width-F.g1(ce.width))/2,ue=he<1,ne=this.getImageData(ce,he);return ce.close(),{dem:new F.g2(O,ne,Y,ue),borderReady:ue}}async loadTileWithProvider(O,j,Y,ce){const{z:he,x:ue,y:ne}=Y.tileID.canonical;try{const J=await O.loadTile({z:he,x:ue,y:ne},{request:Y.request,signal:ce.signal});if(ce.signal.aborted)return null;if(J==null){const Le=new Error("Tile not found");throw Le.status=404,Le}if(J.data==null)return null;const H=await this.decodeTile(j,J.data,Y.encoding);
7if(ce.signal.aborted)return null;const ve=new Headers;return J.expires&&ve.set("expires",J.expires),J.cacheControl&&ve.set("cache-control",J.cacheControl),H.headers=ve,H}catch(J){if(ce.signal.aborted)return null;throw J}finally{delete this.loading[j]}}async reloadTile(O){}abortTile(O){const j=O.uid,Y=this.loading[j];Y&&(Y.cancel(),delete this.loading[j])}removeTile(O){}getImageData(O,j){this.offscreenCanvas&&this.offscreenCanvasContext||(this.offscreenCanvas=new OffscreenCanvas(O.width,O.height),this.offscreenCanvasContext=this.offscreenCanvas.getContext("2d",{willReadFrequently:!0})),this.offscreenCanvas.width=O.width,this.offscreenCanvas.height=O.height,this.offscreenCanvasContext.drawImage(O,0,0,O.width,O.height);const Y=this.offscreenCanvasContext.getImageData(-j,-j,O.width+2*j,O.height+2*j);return this.offscreenCanvasContext.clearRect(0,0,this.offscreenCanvas.width,this.offscreenCanvas.height),Y}}F.d8.setPbf(F.d9);class gs{constructor(O){this._mrt=new F.d8(O.partial?30:1/0),this._isHeaderLoaded=!1,this.uid=O.uid,this.tileID=O.tileID,this.source=O.source}async parse(O){const j=this._mrt;this.status="parsing",this._entireBuffer=O,j.parseHeader(O),this._isHeaderLoaded=!0;const Y=[];for(const ce in j.layers){const he=j.getLayer(ce),ue=he.getDataRange(he.getBandList()),ne=j.createDecodingTask(ue),J=O.slice(ue.firstByte,ue.lastByte+1);Y.push(F.d8.performDecoding(J,ne).then(H=>ne.complete(null,H)).catch(H=>ne.complete(H,null)))}return await Promise.allSettled(Y),j}}class Io{constructor({actor:O}){this.actor=O,this.loading={},this.loaded={}}async loadTile(O){const j=O.uid,Y=new AbortController,ce=this.loading[j]=new gs(O);ce.abort=()=>Y.abort();try{const{data:he,headers:ue}=await F.da(O.request,Y.signal);return he?(this.loaded[j]=ce,{mrt:await ce.parse(he),headers:ue}):(ce.status="done",this.loaded[j]=ce,null)}catch(he){if(Y.signal.aborted)return null;throw ce.status="done",this.loaded[j]=ce,he}finally{delete this.loading[j]}}async reloadTile(O){}abortTile(O){const j=O.uid,Y=this.loading[j];Y&&(Y.abort&&Y.abort(),delete this.loading[j])}removeTile(O){const j=O.uid;this.loaded[j]&&delete this.loaded[j]}async decodeRasterArray(O){return F.d8.performDecoding(O.buffer,O.task)}}const Jn=F.g3.prototype.toGeoJSON;class li{constructor(O){this._feature=O,this.extent=F.aj,this.type=O.type,this.properties=O.tags,"id"in O&&!isNaN(O.id)&&(this.id=parseInt(O.id,10))}loadGeometry(){if(this._feature.type===1){const O=[];for(const j of this._feature.geometry)O.push([new F.P(j[0],j[1])]);return O}{const O=[];for(const j of this._feature.geometry){const Y=[];for(const ce of j)Y.push(new F.P(ce[0],ce[1]));O.push(Y)}return O}}toGeoJSON(O,j,Y){return Jn.call(this,O,j,Y)}}class Kr{constructor(O,j){this.name=O,this.extent=F.aj,this.length=j.length,this._jsonFeatures=j}feature(O){return new li(this._jsonFeatures[O])}}class ks{constructor(O){this.layers={},this.extent=F.aj;for(const j of Object.keys(O))this.layers[j]=new Kr(j,O[j])}}const yn=64/4096;class fn{constructor(){this.features=new Map}clear(){this.features.clear()}load(O=[],j){for(const Y of O){const ce=Y.id;if(ce==null)continue;let he=this.features.get(ce);he&&this.updateCache(he,j),Y.geometry?(he=Mi(Y),this.updateCache(he,j),this.features.set(ce,he)):this.features.delete(ce),this.updateCache(he,j)}}updateCache(O,j){for(const{canonical:Y,uid:ce}of Object.values(j)){const{z:he,x:ue,y:ne}=Y;Jr(O,Math.pow(2,he),ue,ne)&&delete j[ce]}}getTile(O,j,Y){const ce=Math.pow(2,O),he=[];for(const ue of this.features.values())Jr(ue,ce,j,Y)&&he.push(ir(ue,ce,j,Y));return{features:he}}getFeatures(){return[...this.features.values()]}}function Jr({minX:pe,minY:O,maxX:j,maxY:Y},ce,he,ue){return pe<(he+1+yn)/ce&&O<(ue+1+yn)/ce&&j>(he-yn)/ce&&Y>(ue-yn)/ce}function Mi(pe){const{id:O,geometry:j,properties:Y}=pe;if(!j)return;if(j.type==="GeometryCollection")throw new Error("GeometryCollection not supported in dynamic mode.");const{type:ce,coordinates:he}=j,ue={id:O,type:1,geometry:[],tags:Y,minX:1/0,minY:1/0,maxX:-1/0,maxY:-1/0},ne=ue.geometry;if(ce==="Point")qi(he,ne,ue);else if(ce==="MultiPoint")for(const J of he)qi(J,ne,ue);else if(ce==="LineString")ue.type=2,tr(he,ne,ue);else if(ce==="MultiLineString")ue.type=2,fo(he,ne,ue);else if(ce==="Polygon")ue.type=3,fo(he,ne,ue,!0);else{if(ce!=="MultiPolygon")throw new Error("Input data is not a valid GeoJSON object.");ue.type=3;for(const J of he)fo(J,ne,ue,!0)}return ue}function qi([pe,O],j,Y){const ce=F.a_(pe);let he=F.a$(O);he=he<0?0:he>1?1:he,j.push(ce,he),Y.minX=Math.min(Y.minX,ce),Y.minY=Math.min(Y.minY,he),Y.maxX=Math.max(Y.maxX,ce),Y.maxY=Math.max(Y.maxY,he)}function tr(pe,O,j,Y=!1,ce=!1){const he=[];for(const ue of pe)qi(ue,he,j);
7O.push(he),Y&&(function(ue,ne){let J=0;for(let H=0,ve=ue.length,Le=ve-2;H<ve;Le=H,H+=2)J+=(ue[H]-ue[Le])*(ue[H+1]+ue[Le+1]);if(J>0===ne)for(let H=0,ve=ue.length;H<ve/2;H+=2){const Le=ue[H],Ee=ue[H+1];ue[H]=ue[ve-2-H],ue[H+1]=ue[ve-1-H],ue[ve-2-H]=Le,ue[ve-1-H]=Ee}})(he,ce)}function fo(pe,O,j,Y=!1){for(let ce=0;ce<pe.length;ce++)tr(pe[ce],O,j,Y,ce===0)}function ir(pe,O,j,Y){const{id:ce,type:he,geometry:ue,tags:ne}=pe,J=[];if(he===1)(function(H,ve,Le,Ee,it){for(let et=0;et<H.length;et+=2){const Xt=Math.round(F.aj*(H[et+0]*ve-Le)),ht=Math.round(F.aj*(H[et+1]*ve-Ee));it.push([Xt,ht])}})(ue,O,j,Y,J);else if(he===2)for(const H of ue)Xo(H,O,j,Y,J);else if(he===3)for(const H of ue)Bs(H,O,j,Y,J);return{id:ce,type:he,geometry:J,tags:ne}}function Xo(pe,O,j,Y,ce){const ue=F.aj+128;let ne;for(let J=0;J<pe.length-2;J+=2){let H=Math.round(F.aj*(pe[J+0]*O-j)),ve=Math.round(F.aj*(pe[J+1]*O-Y)),Le=Math.round(F.aj*(pe[J+2]*O-j)),Ee=Math.round(F.aj*(pe[J+3]*O-Y));const it=Le-H,et=Ee-ve;H<-128&&Le<-128||(H<-128?(ve+=Math.round(et*((-128-H)/it)),H=-128):Le<-128&&(Ee=ve+Math.round(et*((-128-H)/it)),Le=-128),ve<-128&&Ee<-128||(ve<-128?(H+=Math.round(it*((-128-ve)/et)),ve=-128):Ee<-128&&(Le=H+Math.round(it*((-128-ve)/et)),Ee=-128),H>=ue&&Le>=ue||(H>=ue?(ve+=Math.round(et*((ue-H)/it)),H=ue):Le>=ue&&(Ee=ve+Math.round(et*((ue-H)/it)),Le=ue),ve>=ue&&Ee>=ue||(ve>=ue?(H+=Math.round(it*((ue-ve)/et)),ve=ue):Ee>=ue&&(Le=H+Math.round(it*((ue-ve)/et)),Ee=ue),ne&&H===ne.at(-1)[0]&&ve===ne.at(-1)[1]||(ne=[[H,ve]],ce.push(ne)),ne.push([Le,Ee])))))}}function Bs(pe,O,j,Y,ce){const he=(j-yn)/O,ue=(Y-yn)/O,ne=(j+1+yn)/O,J=(Y+1+yn)/O;function H(Ee,it){let et=0;return Ee<he?et|=1:Ee>ne&&(et|=2),it<ue?et|=4:it>J&&(et|=8),et}let ve=[];for(let Ee=1;Ee<=8;Ee*=2){let it=pe[pe.length-2],et=pe.at(-1),Xt=!(H(it,et)&Ee);for(let ht=0;ht<pe.length;ht+=2){const Tt=pe[ht],Yt=pe[ht+1],yi=!(H(Tt,Yt)&Ee);yi!==Xt&&(8&Ee?ve.push(it+(Tt-it)*(J-et)/(Yt-et),J):4&Ee?ve.push(it+(Tt-it)*(ue-et)/(Yt-et),ue):2&Ee?ve.push(ne,et+(Yt-et)*(ne-it)/(Tt-it)):1&Ee&&ve.push(he,et+(Yt-et)*(he-it)/(Tt-it))),yi&&ve.push(Tt,Yt),it=Tt,et=Yt,Xt=yi}if(!(pe=ve).length||Ee===8)break;ve=[]}const Le=[];for(let Ee=0;Ee<ve.length;Ee+=2)Le.push([Math.round(F.aj*(ve[Ee]*O-j)),Math.round(F.aj*(ve[Ee+1]*O-Y))]);Le.length&&ce.push(Le)}function Rn({name:pe,features:O},j){j.writeStringField(1,pe),j.writeVarintField(5,F.aj);const Y=new Map,ce=new Map,he={keys:Y,values:ce,feature:null};for(const ue of O)he.feature=ue,j.writeMessage(2,Zi,he);for(const ue of Y.keys())j.writeStringField(3,ue);for(const ue of ce.keys())j.writeMessage(4,Ko,ue)}function Zi(pe,O){const j=pe.feature;j.id!==void 0&&Number.isSafeInteger(+j.id)&&O.writeVarintField(1,+j.id),j.tags&&O.writeMessage(2,Ia,pe),O.writeVarintField(3,j.type),O.writeMessage(4,Yo,j)}function Ia({keys:pe,values:O,feature:j},Y){for(const ce of Object.keys(j.tags)){let he=j.tags[ce];if(he===null)continue;let ue=pe.get(ce);ue===void 0&&(ue=pe.size,pe.set(ce,ue)),Y.writeVarint(ue);const ne=typeof he;ne!=="string"&&ne!=="boolean"&&ne!=="number"&&(he=JSON.stringify(he));let J=O.get(he);J===void 0&&(J=O.size,O.set(he,J)),Y.writeVarint(J)}}function Dn(pe,O){return(O<<3)+(7&pe)}function ys(pe){return pe<<1^pe>>31}function Yo(pe,O){const{geometry:j,type:Y}=pe;let ce=0,he=0;if(Y===1){O.writeVarint(Dn(1,j.length));for(const ue of j){const ne=ue[0]-ce,J=ue[1]-he;O.writeVarint(ys(ne)),O.writeVarint(ys(J)),ce+=ne,he+=J}}else for(const ue of j){if(ue.length===0)continue;O.writeVarint(Dn(1,1));const ne=ue.length-(Y===3?1:0);for(let J=0;J<ne;J++){J===1&&O.writeVarint(Dn(2,ne-1));const H=ue[J][0]-ce,ve=ue[J][1]-he;O.writeVarint(ys(H)),O.writeVarint(ys(ve)),ce+=H,he+=ve}Y===3&&O.writeVarint(Dn(7,1))}}function Ko(pe,O){const j=typeof pe;j==="string"?O.writeStringField(1,pe):j==="boolean"?O.writeBooleanField(7,pe):j==="number"&&(pe%1!=0?O.writeDoubleField(3,pe):pe<0?O.writeSVarintField(6,pe):O.writeVarintField(5,pe))}const Ln={minZoom:0,maxZoom:16,minPoints:2,radius:40,extent:512,nodeSize:64,log:!1,generateId:!1,reduce:null,map:pe=>pe},Qn=Math.fround||(Ao=new Float32Array(1),pe=>(Ao[0]=+pe,Ao[0]));var Ao;class Jo{constructor(O){this.options=Object.assign(Object.create(Ln),O),this.trees=new Array(this.options.maxZoom+1),this.stride=this.options.reduce?7:6,this.clusterProps=[]}load(O){const{log:j,minZoom:Y,maxZoom:ce}=this.options;j&&console.time("total time");const he=`prepare ${O.length} points`;j&&console.time(he),this.points=O;const ue=[];for(let J=0;J<O.length;J++){const H=O[J];
vendor: 11,098 bytes, line 7
7if(!H.geometry)continue;const[ve,Le]=H.geometry.coordinates,Ee=Qn(to(ve)),it=Qn(Co(Le));ue.push(Ee,it,1/0,J,-1,1),this.options.reduce&&ue.push(0)}let ne=this.trees[ce+1]=this._createTree(ue);j&&console.timeEnd(he);for(let J=ce;J>=Y;J--){const H=+Date.now();ne=this.trees[J]=this._createTree(this._cluster(ne,J)),j&&console.log("z%d: %d clusters in %dms",J,ne.numItems,+Date.now()-H)}return j&&console.timeEnd("total time"),this}getClusters(O,j){let Y=((O[0]+180)%360+360)%360-180;const ce=Math.max(-90,Math.min(90,O[1]));let he=O[2]===180?180:((O[2]+180)%360+360)%360-180;const ue=Math.max(-90,Math.min(90,O[3]));if(O[2]-O[0]>=360)Y=-180,he=180;else if(Y>he){const Le=this.getClusters([Y,ce,180,ue],j),Ee=this.getClusters([-180,ce,he,ue],j);return Le.concat(Ee)}const ne=this.trees[this._limitZoom(j)],J=ne.range(to(Y),Co(ue),to(he),Co(ce)),H=ne.data,ve=[];for(const Le of J){const Ee=this.stride*Le;ve.push(H[Ee+5]>1?eo(H,Ee,this.clusterProps):this.points[H[Ee+3]])}return ve}getChildren(O){const j=this._getOriginId(O),Y=this._getOriginZoom(O),ce="No cluster with the specified id.",he=this.trees[Y];if(!he)throw new Error(ce);const ue=he.data;if(j*this.stride>=ue.length)throw new Error(ce);const ne=this.options.radius/(this.options.extent*Math.pow(2,Y-1)),J=he.within(ue[j*this.stride],ue[j*this.stride+1],ne),H=[];for(const ve of J){const Le=ve*this.stride;ue[Le+4]===O&&H.push(ue[Le+5]>1?eo(ue,Le,this.clusterProps):this.points[ue[Le+3]])}if(H.length===0)throw new Error(ce);return H}getLeaves(O,j,Y){const ce=[];return this._appendLeaves(ce,O,j=j||10,Y=Y||0,0),ce}getTile(O,j,Y){const ce=this.trees[this._limitZoom(O)],he=Math.pow(2,O),{extent:ue,radius:ne}=this.options,J=ne/ue,H=(Y-J)/he,ve=(Y+1+J)/he,Le={features:[]};return this._addTileFeatures(ce.range((j-J)/he,H,(j+1+J)/he,ve),ce.data,j,Y,he,Le),j===0&&this._addTileFeatures(ce.range(1-J/he,H,1,ve),ce.data,he,Y,he,Le),j===he-1&&this._addTileFeatures(ce.range(0,H,J/he,ve),ce.data,-1,Y,he,Le),Le.features.length?Le:null}getClusterExpansionZoom(O){let j=this._getOriginZoom(O)-1;for(;j<=this.options.maxZoom;){const Y=this.getChildren(O);if(j++,Y.length!==1)break;O=Y[0].properties.cluster_id}return j}_appendLeaves(O,j,Y,ce,he){const ue=this.getChildren(j);for(const ne of ue){const J=ne.properties;if(J&&J.cluster?he+J.point_count<=ce?he+=J.point_count:he=this._appendLeaves(O,J.cluster_id,Y,ce,he):he<ce?he++:O.push(ne),O.length===Y)break}return he}_createTree(O){const j=new F.ea(O.length/this.stride|0,this.options.nodeSize,Float32Array);for(let Y=0;Y<O.length;Y+=this.stride)j.add(O[Y],O[Y+1]);return j.finish(),j.data=O,j}_addTileFeatures(O,j,Y,ce,he,ue){for(const ne of O){const J=ne*this.stride,H=j[J+5]>1;let ve,Le,Ee;if(H)ve=zr(j,J,this.clusterProps),Le=j[J],Ee=j[J+1];else{const Xt=this.points[j[J+3]];ve=Xt.properties;const[ht,Tt]=Xt.geometry.coordinates;Le=to(ht),Ee=Co(Tt)}const it={type:1,geometry:[[Math.round(this.options.extent*(Le*he-Y)),Math.round(this.options.extent*(Ee*he-ce))]],tags:ve};let et;et=H||this.options.generateId?j[J+3]:this.points[j[J+3]].id,et!==void 0&&(it.id=et),ue.features.push(it)}}_limitZoom(O){return Math.max(this.options.minZoom,Math.min(Math.floor(+O),this.options.maxZoom+1))}_cluster(O,j){const{radius:Y,extent:ce,reduce:he,minPoints:ue}=this.options,ne=Y/(ce*Math.pow(2,j)),J=O.data,H=[],ve=this.stride;for(let Le=0;Le<J.length;Le+=ve){if(J[Le+2]<=j)continue;J[Le+2]=j;const Ee=J[Le],it=J[Le+1],et=O.within(J[Le],J[Le+1],ne),Xt=J[Le+5];let ht=Xt;for(const Tt of et){const Yt=Tt*ve;J[Yt+2]>j&&(ht+=J[Yt+5])}if(ht>Xt&&ht>=ue){let Tt,Yt=Ee*Xt,yi=it*Xt,nr=-1;const dr=(Le/ve<<5)+(j+1)+this.points.length;for(const jr of et){const fr=jr*ve;if(J[fr+2]<=j)continue;J[fr+2]=j;const Gr=J[fr+5];Yt+=J[fr]*Gr,yi+=J[fr+1]*Gr,J[fr+4]=dr,he&&(Tt||(Tt=this._map(J,Le,!0),nr=this.clusterProps.length,this.clusterProps.push(Tt)),he(Tt,this._map(J,fr)))}J[Le+4]=dr,H.push(Yt/ht,yi/ht,1/0,dr,-1,ht),he&&H.push(nr)}else{for(let Tt=0;Tt<ve;Tt++)H.push(J[Le+Tt]);if(ht>1)for(const Tt of et){const Yt=Tt*ve;if(!(J[Yt+2]<=j)){J[Yt+2]=j;for(let yi=0;yi<ve;yi++)H.push(J[Yt+yi])}}}}return H}_getOriginId(O){return O-this.points.length>>5}_getOriginZoom(O){return(O-this.points.length)%32}_map(O,j,Y){if(O[j+5]>1){const ue=this.clusterProps[O[j+6]];return Y?Object.assign({},ue):ue}const ce=this.points[O[j+3]].properties,he=this.options.map(ce);return Y&&he===ce?Object.assign({},he):he}}function eo(pe,O,j){return{type:"Feature",id:pe[O+3],properties:zr(pe,O,j),geometry:{type:"Point",coordinates:[(Y=pe[O],360*(Y-.5)),Aa(pe[O+1])]}};var Y}function zr(pe,O,j){const Y=pe[O+5],ce=Y>=1e4?`${Math.round(Y/1e3)}k`:Y>=1e3?Math.round(Y/100)/10+"k":Y,he=pe[O+6],ue=he===-1?{}:Object.assign({},j[he]);return Object.assign(ue,{cluster:!0,cluster_id:pe[O+3],point_count:Y,point_count_abbreviated:ce})}function to(pe){return pe/360+.5}function Co(pe){const O=Math.sin(pe*Math.PI/180),j=.5-.25*Math.log((1+O)/(1-O))/Math.PI;return j<0?0:j>1?1:j}function Aa(pe){const O=(180-360*pe)*Math.PI/180;return 360*Math.atan(Math.exp(O))/Math.PI-90}function xs(pe,O,j,Y){let ce=Y;const he=O+(j-O>>1);let ue,ne=j-O;const J=pe[O],H=pe[O+1],ve=pe[j],Le=pe[j+1];for(let Ee=O+3;Ee<j;Ee+=3){const it=rr(pe[Ee],pe[Ee+1],J,H,ve,Le);if(it>ce)ue=Ee,ce=it;else if(it===ce){const et=Math.abs(Ee-he);et<ne&&(ue=Ee,ne=et)}}ce>Y&&(ue-O>3&&xs(pe,O,ue,Y),pe[ue+2]=ce,j-ue>3&&xs(pe,ue,j,Y))}function rr(pe,O,j,Y,ce,he){let ue=ce-j,ne=he-Y;if(ue!==0||ne!==0){const J=((pe-j)*ue+(O-Y)*ne)/(ue*ue+ne*ne);J>1?(j=ce,Y=he):J>0&&(j+=ue*J,Y+=ne*J)}return ue=pe-j,ne=O-Y,ue*ue+ne*ne}function io(pe,O,j,Y){const ce={id:pe??null,type:O,geometry:j,tags:Y,minX:1/0,minY:1/0,maxX:-1/0,maxY:-1/0};if(O==="Point"||O==="MultiPoint"||O==="LineString")Qo(ce,j);else if(O==="Polygon")Qo(ce,j[0]);else if(O==="MultiLineString")for(const he of j)Qo(ce,he);else if(O==="MultiPolygon")for(const he of j)Qo(ce,he[0]);return ce}function Qo(pe,O){for(let j=0;j<O.length;j+=3)pe.minX=Math.min(pe.minX,O[j]),pe.minY=Math.min(pe.minY,O[j+1]),pe.maxX=Math.max(pe.maxX,O[j]),pe.maxY=Math.max(pe.maxY,O[j+1])}function es(pe,O,j,Y){if(!O.geometry)return;const ce=O.geometry.coordinates;if(ce&&ce.length===0)return;const he=O.geometry.type,ue=Math.pow(j.tolerance/((1<<j.maxZoom)*j.extent),2);let ne=[],J=O.id;if(j.promoteId?J=O.properties[j.promoteId]:j.generateId&&(J=Y||0),he==="Point")vs(ce,ne);else if(he==="MultiPoint")for(const H of ce)vs(H,ne);else if(he==="LineString")Ns(ce,ne,ue,!1);else if(he==="MultiLineString"){if(j.lineMetrics){for(const H of ce)ne=[],Ns(H,ne,ue,!1),pe.push(io(J,"LineString",ne,O.properties));return}ts(ce,ne,ue,!1)}else if(he==="Polygon")ts(ce,ne,ue,!0);else{if(he!=="MultiPolygon"){if(he==="GeometryCollection"){for(const H of O.geometry.geometries)es(pe,{id:J,geometry:H,properties:O.properties},j,Y);return}throw new Error("Input data is not a valid GeoJSON object.")}for(const H of ce){const ve=[];ts(H,ve,ue,!0),ne.push(ve)}}pe.push(io(J,he,ne,O.properties))}function vs(pe,O){O.push(bs(pe[0]),Mo(pe[1]),0)}function Ns(pe,O,j,Y){let ce,he,ue=0;for(let J=0;J<pe.length;J++){const H=bs(pe[J][0]),ve=Mo(pe[J][1]);O.push(H,ve,0),J>0&&(ue+=Y?(ce*ve-H*he)/2:Math.sqrt(Math.pow(H-ce,2)+Math.pow(ve-he,2))),ce=H,he=ve}const ne=O.length-3;O[2]=1,xs(O,0,ne,j),O[ne+2]=1,O.size=Math.abs(ue),O.start=0,O.end=O.size}function ts(pe,O,j,Y){for(let ce=0;ce<pe.length;ce++){const he=[];Ns(pe[ce],he,j,Y),O.push(he)}}function bs(pe){return pe/360+.5}function Mo(pe){const O=Math.sin(pe*Math.PI/180),j=.5-.25*Math.log((1+O)/(1-O))/Math.PI;return j<0?0:j>1?1:j}function Po(pe,O,j,Y,ce,he,ue,ne){if(Y/=O,he>=(j/=O)&&ue<Y)return pe;if(ue<j||he>=Y)return null;const J=[];for(const H of pe){const ve=H.geometry;let Le=H.type;const Ee=ce===0?H.minX:H.minY,it=ce===0?H.maxX:H.maxY;if(Ee>=j&&it<Y){J.push(H);continue}if(it<j||Ee>=Y)continue;let et=[];if(Le==="Point"||Le==="MultiPoint")Ca(ve,et,j,Y,ce);else if(Le==="LineString")Ue(ve,et,j,Y,ce,!1,ne.lineMetrics);else if(Le==="MultiLineString")Ma(ve,et,j,Y,ce,!1);else if(Le==="Polygon")Ma(ve,et,j,Y,ce,!0);else if(Le==="MultiPolygon")for(const Xt of ve){const ht=[];Ma(Xt,ht,j,Y,ce,!0),ht.length&&et.push(ht)}if(et.length){if(ne.lineMetrics&&Le==="LineString"){for(const Xt of et)J.push(io(H.id,Le,Xt,H.tags));continue}Le!=="LineString"&&Le!=="MultiLineString"||(et.length===1?(Le="LineString",et=et[0]):Le="MultiLineString"),Le!=="Point"&&Le!=="MultiPoint"||(Le=et.length===3?"Point":"MultiPoint"),J.push(io(H.id,Le,et,H.tags))}}return J.length?J:null}function Ca(pe,O,j,Y,ce){for(let he=0;he<pe.length;he+=3){const ue=pe[he+ce];ue>=j&&ue<=Y&&zn(O,pe[he],pe[he+1],pe[he+2])}}function Ue(pe,O,j,Y,ce,he,ue){let ne=ro(pe);const J=ce===0?Vc:sa;let H,ve,Le=pe.start;for(let ht=0;ht<pe.length-3;ht+=3){const Tt=pe[ht],Yt=pe[ht+1],yi=pe[ht+2],nr=pe[ht+3],dr=pe[ht+4],jr=ce===0?Tt:Yt,fr=ce===0?nr:dr;let Gr=!1;ue&&(H=Math.sqrt(Math.pow(Tt-nr,2)+Math.pow(Yt-dr,2))),jr<j?fr>=j&&(ve=J(ne,Tt,Yt,nr,dr,j),ue&&(ne.start=Le+H*ve)):jr>Y?fr<=Y&&(ve=J(ne,Tt,Yt,nr,dr,Y),ue&&(ne.start=Le+H*ve)):zn(ne,Tt,Yt,yi),fr<j&&jr>=j&&(ve=J(ne,Tt,Yt,nr,dr,j),Gr=!0),fr>Y&&jr<=Y&&(ve=J(ne,Tt,Yt,nr,dr,Y),Gr=!0),!he&&Gr&&(ue&&(ne.end=Le+H*ve),O.push(ne),ne=ro(pe)),ue&&(Le+=H)}let Ee=pe.length-3;const it=pe[Ee],et=pe[Ee+1],Xt=ce===0?it:et;Xt>=j&&Xt<=Y&&zn(ne,it,et,pe[Ee+2]),Ee=ne.length-3,he&&Ee>=3&&(ne[Ee]!==ne[0]||ne[Ee+1]!==ne[1])&&zn(ne,ne[0],ne[1],ne[2]),ne.length&&O.push(ne)}function ro(pe){const O=[];return O.size=pe.size,O.start=pe.start,O.end=pe.end,O}function Ma(pe,O,j,Y,ce,he){for(const ue of pe)Ue(ue,O,j,Y,ce,he,!1)}function zn(pe,O,j,Y){pe.push(O,j,Y)}function Vc(pe,O,j,Y,ce,he){const ue=(he-O)/(Y-O);return zn(pe,he,j+(ce-j)*ue,1),ue}function sa(pe,O,j,Y,ce,he){const ue=(he-j)/(ce-j);return zn(pe,O+(Y-O)*ue,he,1),ue}function Vs(pe,O){const j=[];for(let Y=0;Y<pe.length;Y++){const ce=pe[Y],he=ce.type;let ue;if(he==="Point"||he==="MultiPoint"||he==="LineString")ue=Ro(ce.geometry,O);else if(he==="MultiLineString"||he==="Polygon"){ue=[];for(const ne of ce.geometry)ue.push(Ro(ne,O))}else if(he==="MultiPolygon"){ue=[];for(const ne of ce.geometry){const J=[];for(const H of ne)J.push(Ro(H,O));ue.push(J)}}j.push(io(ce.id,he,ue,ce.tags))}return j}function Ro(pe,O){const j=[];j.size=pe.size,pe.start!==void 0&&(j.start=pe.start,j.end=pe.end);for(let Y=0;Y<pe.length;Y+=3)j.push(pe[Y]+O,pe[Y+1],pe[Y+2]);return j}function xn(pe,O){if(pe.transformed)return pe;const j=1<<pe.z,Y=pe.x,ce=pe.y;for(const he of pe.features){const ue=he.geometry,ne=he.type;if(he.geometry=[],ne===1)for(let J=0;J<ue.length;J+=2)he.geometry.push(is(ue[J],ue[J+1],O,j,Y,ce));else for(let J=0;J<ue.length;J++){const H=[];for(let ve=0;ve<ue[J].length;ve+=2)H.push(is(ue[J][ve],ue[J][ve+1],O,j,Y,ce));he.geometry.push(H)}}return pe.transformed=!0,pe}function is(pe,O,j,Y,ce,he){return[Math.round(j*(pe*Y-ce)),Math.round(j*(O*Y-he))]}function sl(pe,O,j,Y,ce){const he=O===ce.maxZoom?0:ce.tolerance/((1<<O)*ce.extent),ue={features:[],numPoints:0,numSimplified:0,numFeatures:pe.length,source:null,x:j,y:Y,z:O,transformed:!1,minX:2,minY:1,maxX:-1,maxY:0};for(const ne of pe)aa(ue,ne,he,ce);return ue}function aa(pe,O,j,Y){const ce=O.geometry,he=O.type,ue=[];
7if(pe.minX=Math.min(pe.minX,O.minX),pe.minY=Math.min(pe.minY,O.minY),pe.maxX=Math.max(pe.maxX,O.maxX),pe.maxY=Math.max(pe.maxY,O.maxY),he==="Point"||he==="MultiPoint")for(let ne=0;ne<ce.length;ne+=3)ue.push(ce[ne],ce[ne+1]),pe.numPoints++,pe.numSimplified++;else if(he==="LineString")Qr(ue,ce,pe,j,!1,!1);else if(he==="MultiLineString"||he==="Polygon")for(let ne=0;ne<ce.length;ne++)Qr(ue,ce[ne],pe,j,he==="Polygon",ne===0);else if(he==="MultiPolygon")for(let ne=0;ne<ce.length;ne++){const J=ce[ne];for(let H=0;H<J.length;H++)Qr(ue,J[H],pe,j,!0,H===0)}if(ue.length){let ne=O.tags||null;if(he==="LineString"&&Y.lineMetrics){ne={};for(const H in O.tags)ne[H]=O.tags[H];ne.mapbox_clip_start=ce.start/ce.size,ne.mapbox_clip_end=ce.end/ce.size}const J={geometry:ue,type:he==="Polygon"||he==="MultiPolygon"?3:he==="LineString"||he==="MultiLineString"?2:1,tags:ne};O.id!==null&&(J.id=O.id),pe.features.push(J)}}function Qr(pe,O,j,Y,ce,he){const ue=Y*Y;if(Y>0&&O.size<(ce?ue:Y))return void(j.numPoints+=O.length/3);const ne=[];for(let J=0;J<O.length;J+=3)(Y===0||O[J+2]>ue)&&(j.numSimplified++,ne.push(O[J],O[J+1])),j.numPoints++;ce&&(function(J,H){let ve=0;for(let Le=0,Ee=J.length,it=Ee-2;Le<Ee;it=Le,Le+=2)ve+=(J[Le]-J[it])*(J[Le+1]+J[it+1]);if(ve>0===H)for(let Le=0,Ee=J.length;Le<Ee/2;Le+=2){const it=J[Le],et=J[Le+1];J[Le]=J[Ee-2-Le],J[Le+1]=J[Ee-1-Le],J[Ee-2-Le]=it,J[Ee-1-Le]=et}})(ne,he),pe.push(ne)}const Pa={maxZoom:14,indexMaxZoom:5,indexMaxPoints:1e5,tolerance:3,extent:4096,buffer:64,lineMetrics:!1,promoteId:null,generateId:!1,debug:0};class ws{constructor(O,j){const Y=(j=this.options=(function(he,ue){for(const ne in ue)he[ne]=ue[ne];return he})(Object.create(Pa),j)).debug;if(Y&&console.time("preprocess data"),j.maxZoom<0||j.maxZoom>24)throw new Error("maxZoom should be in the 0-24 range");if(j.promoteId&&j.generateId)throw new Error("promoteId and generateId cannot be used together.");let ce=(function(he,ue){const ne=[];if(he.type==="FeatureCollection")for(let J=0;J<he.features.length;J++)es(ne,he.features[J],ue,J);else es(ne,he.type==="Feature"?he:{geometry:he},ue);return ne})(O,j);this.tiles={},this.tileCoords=[],Y&&(console.timeEnd("preprocess data"),console.log("index: maxZoom: %d, maxPoints: %d",j.indexMaxZoom,j.indexMaxPoints),console.time("generate tiles"),this.stats={},this.total=0),ce=(function(he,ue){const ne=ue.buffer/ue.extent;let J=he;const H=Po(he,1,-1-ne,ne,0,-1,2,ue),ve=Po(he,1,1-ne,2+ne,0,-1,2,ue);return(H||ve)&&(J=Po(he,1,-ne,1+ne,0,-1,2,ue)||[],H&&(J=Vs(H,1).concat(J)),ve&&(J=J.concat(Vs(ve,-1)))),J})(ce,j),ce.length&&this.splitTile(ce,0,0,0),Y&&(ce.length&&console.log("features: %d, points: %d",this.tiles[0].numFeatures,this.tiles[0].numPoints),console.timeEnd("generate tiles"),console.log("tiles generated:",this.total,JSON.stringify(this.stats)))}splitTile(O,j,Y,ce,he,ue,ne){const J=[O,j,Y,ce],H=this.options,ve=H.debug;for(;J.length;){ce=J.pop(),Y=J.pop(),j=J.pop(),O=J.pop();const Le=1<<j,Ee=Us(j,Y,ce);let it=this.tiles[Ee];if(!it&&(ve>1&&console.time("creation"),it=this.tiles[Ee]=sl(O,j,Y,ce,H),this.tileCoords.push({z:j,x:Y,y:ce}),ve)){ve>1&&(console.log("tile z%d-%d-%d (features: %d, points: %d, simplified: %d)",j,Y,ce,it.numFeatures,it.numPoints,it.numSimplified),console.timeEnd("creation"));const Gr=`z${j}`;this.stats[Gr]=(this.stats[Gr]||0)+1,this.total++}if(it.source=O,he==null){if(j===H.indexMaxZoom||it.numPoints<=H.indexMaxPoints)continue}else{if(j===H.maxZoom||j===he)continue;if(he!=null){const Gr=he-j;if(Y!==ue>>Gr||ce!==ne>>Gr)continue}}if(it.source=null,O.length===0)continue;ve>1&&console.time("clipping");const et=.5*H.buffer/H.extent,Xt=.5-et,ht=.5+et,Tt=1+et;let Yt=null,yi=null,nr=null,dr=null;const jr=Po(O,Le,Y-et,Y+ht,0,it.minX,it.maxX,H),fr=Po(O,Le,Y+Xt,Y+Tt,0,it.minX,it.maxX,H);jr&&(Yt=Po(jr,Le,ce-et,ce+ht,1,it.minY,it.maxY,H),yi=Po(jr,Le,ce+Xt,ce+Tt,1,it.minY,it.maxY,H)),fr&&(nr=Po(fr,Le,ce-et,ce+ht,1,it.minY,it.maxY,H),dr=Po(fr,Le,ce+Xt,ce+Tt,1,it.minY,it.maxY,H)),ve>1&&console.timeEnd("clipping"),J.push(Yt||[],j+1,2*Y,2*ce),J.push(yi||[],j+1,2*Y,2*ce+1),J.push(nr||[],j+1,2*Y+1,2*ce),J.push(dr||[],j+1,2*Y+1,2*ce+1)}}getTile(O,j,Y){O=+O,j=+j,Y=+Y;const ce=this.options,{extent:he,debug:ue}=ce;if(O<0||O>24)return null;const ne=1<<O,J=Us(O,j=j+ne&ne-1,Y);if(this.tiles[J])return xn(this.tiles[J],he);ue>1&&console.log("drilling down to z%d-%d-%d",O,j,Y);let H,ve=O,Le=j,Ee=Y;for(;!H&&ve>0;)ve--,Le>>=1,Ee>>=1,H=this.tiles[Us(ve,Le,Ee)];return H&&H.source?(ue>1&&(console.log("found parent tile z%d-%d-%d",ve,Le,Ee),console.time("drilling down")),this.splitTile(H.source,ve,Le,Ee,O,j,Y),ue>1&&console.timeEnd("drilling down"),this.tiles[J]?xn(this.tiles[J],he):null):null}}function Us(pe,O,j){return 32*((1<<pe)*j+O)+pe}function al(pe,O){const j=pe.tileID.canonical;if(!this._geoJSONIndex)return void O(null,null);const Y=this._geoJSONIndex.getTile(j.z,j.x,j.y);if(!Y)return void O(null,null);const ce=H=>H.tags&&"3d_elevation_id"in H.tags&&"source"in H.tags&&H.tags.source==="elevation",he=Y.features.filter(H=>ce(H));let ue={_geojsonTileLayer:Y.features};he.length>0&&(ue={_geojsonTileLayer:Y.features.filter(H=>!ce(H)),hd_road_elevation:he});const ne=new ks(ue),J=(function(H){const ve=new F.g4;for(const Le of Object.keys(H))ve.writeMessage(3,Rn,{name:Le,features:H[Le]});return ve.finish()})(ue).buffer;O(null,{vectorTile:ne,rawData:J,headers:new Headers})}class js extends ji{constructor(O){super(O),this.loadVectorData=al,this._dynamicIndex=new fn}async loadData(O){const j=O&&O.request,Y=j&&j.collectResourceTiming;this._geoJSONIndex=null;
vendor: 4,197 bytes, line 7
7let ce=await new Promise((ue,ne)=>{this.loadGeoJSON(O,(J,H)=>{J?ne(J):ue(H)})});if(!ce)return{};if(typeof ce!="object")throw new Error(`Input data given to '${O.source}' is not a valid GeoJSON object.`);if(O.filter){const ue=F.n(O.filter,{type:"boolean","property-type":"data-driven",overridable:!1,transition:!1});if(ue.result==="error")throw new Error(ue.value.map(ne=>`${ne.key}: ${ne.message}`).join(", "));ce.features=ce.features.filter(ne=>ue.value.evaluate({zoom:0},ne))}O.dynamic?(ce.type==="Feature"&&(ce={type:"FeatureCollection",features:[ce]}),O.append||(this._dynamicIndex.clear(),this.loaded={}),this._dynamicIndex.load(ce.features,this.loaded),O.cluster&&(ce.features=this._dynamicIndex.getFeatures())):this.loaded={},this._geoJSONIndex=O.cluster?new Jo((function({superclusterOptions:ue,clusterProperties:ne}){if(!ne||!ue)return ue;const J={},H={},ve={accumulated:null,zoom:0},Le={properties:null},Ee=Object.keys(ne);for(const it of Ee){const[et,Xt]=ne[it],ht=F.n(Xt),Tt=F.n(typeof et=="string"?[et,["accumulated"],["get",it]]:et);J[it]=ht.value,H[it]=Tt.value}return ue.map=it=>{Le.properties=it;const et={};for(const Xt of Ee)et[Xt]=J[Xt].evaluate(ve,Le);return et},ue.reduce=(it,et)=>{Le.properties=et;for(const Xt of Ee)ve.accumulated=it[Xt],it[Xt]=H[Xt].evaluate(ve,Le)},ue})(O)).load(ce.features):O.dynamic?this._dynamicIndex:(function(ue,ne){return new ws(ue,ne)})(ce,O.geojsonVtOptions);const he={};if(Y){const ue=Yi(j);ue&&(he.resourceTiming={},he.resourceTiming[O.source]=JSON.parse(JSON.stringify(ue)))}return he}async reloadTile(O){const j=this.loaded;return j&&j[O.uid]?O.partial?void 0:super.reloadTile(O):this.loadTile(O)}loadGeoJSON(O,j){if(O.request)F.o(O.request).then(({data:Y})=>j(null,Y)).catch(Y=>j(Y));else{if(typeof O.data!="string")return j(new Error(`Input data given to '${O.source}' is not a valid GeoJSON object.`));setTimeout(()=>{try{return j(null,JSON.parse(O.data))}catch{return j(new Error(`Input data given to '${O.source}' is not a valid GeoJSON object.`))}},0)}}getClusterExpansionZoom(O){return this._geoJSONIndex.getClusterExpansionZoom(O.clusterId)}getClusterChildren(O){return this._geoJSONIndex.getChildren(O.clusterId)}getClusterLeaves(O){return this._geoJSONIndex.getLeaves(O.clusterId,O.limit,O.offset)}}class Zl{constructor(O,j,Y){this.tileID=new F.br(O.tileID.overscaledZ,O.tileID.wrap,O.tileID.canonical.z,O.tileID.canonical.x,O.tileID.canonical.y),this.tileZoom=O.tileZoom,this.uid=O.uid,this.zoom=O.zoom,this.canonical=O.tileID.canonical,this.pixelRatio=O.pixelRatio,this.tileSize=O.tileSize,this.source=O.source,this.overscaling=this.tileID.overscaleFactor(),this.projection=O.projection,this.brightness=j,this.worldview=Y}async parse(O,j,Y){this.status="parsing";const ce=new F.br(Y.tileID.overscaledZ,Y.tileID.wrap,Y.tileID.canonical.z,Y.tileID.canonical.x,Y.tileID.canonical.y),he=[],ue=j.familiesBySource[Y.source],ne=new F.fO(ce,Y.promoteId);ne.bucketLayerIDs=[],ne.is3DTile=!0;const J=await F.g5(O),H=J.json.extensionsUsed&&J.json.extensionsUsed.includes("MAPBOX_mesh_features")||J.json.asset.extras&&J.json.asset.extras.MAPBOX_mesh_features,ve=J.json.extensionsUsed&&J.json.extensionsUsed.includes("EXT_meshopt_compression"),Le=new F.aa(this.zoom,{brightness:this.brightness,worldview:this.worldview});for(const Ee in ue)for(const it of ue[Ee]){const et=it[0];ne.bucketLayerIDs.push(it.map(Tt=>F.y(Tt.id,Tt.scope))),et.recalculate(Le,[]);const Xt=F.g6(J,1/F.cn(Y.tileID.canonical)),ht=new F.g7(it,Xt,ce,H,ve,this.brightness,ne,this.worldview);H||(ht.needsUpload=!0),he.push(ht),ht.evaluate(et)}return this.status="done",{buckets:he,featureIndex:ne,collisionBoxArray:null,glyphAtlasImage:null,lineAtlas:null,imageAtlas:null,brightness:null}}}class Qt{constructor({actor:O,layerIndex:j,availableImages:Y,availableModels:ce,brightness:he,worldview:ue}){this.actor=O,this.layerIndex=j,this.availableImages=Y,this.availableModels=ce,this.brightness=he,this.loading={},this.loaded={},this.worldview=ue}async loadTile(O){const j=O.uid,Y=new AbortController,ce=this.loading[j]=new Zl(O,this.brightness,this.worldview);ce.abort=()=>Y.abort();const he=(ne,J)=>{const H=ce.reloadCallback;H&&(delete ce.reloadCallback,H(ne,J))};let ue;
7try{ue=(await F.da(O.request,Y.signal)).data}catch(ne){if(delete this.loading[j],ce.status="done",this.loaded[j]=ce,Y.signal.aborted)return null;throw ne}if(delete this.loading[j],!ue||ue.byteLength===0)return ce.status="done",this.loaded[j]=ce,null;try{const ne=await ce.parse(ue,this.layerIndex,O);return this.loaded[j]=ce,he(null,ne),ne}catch(ne){throw this.loaded[j]=ce,he(ne),ne}}async reloadTile(O){const j=this.loaded&&this.loaded[O.uid];if(j)return j.projection=O.projection,j.brightness=O.brightness,j.status==="parsing"&&await new Promise((Y,ce)=>{j.reloadCallback=he=>{he?ce(he):Y()}}),this.loadTile(O)}abortTile(O){const j=O.uid,Y=this.loading[j];Y&&(Y.abort&&Y.abort(),delete this.loading[j])}removeTile(O){const j=this.loaded,Y=O.uid;j&&j[Y]&&delete j[Y]}}class en{constructor(O){this.self=O,this.actor=new F.an(O,this),this.layerIndexes={},this.availableImages={},this.availableModels={},this.isSpriteLoaded={},this.rtlPluginParsingListeners=[],this.projections={},this.defaultProjection=F.b6({name:"mercator"}),this.workerSourceTypes={vector:ji,geojson:js,"raster-dem":dn,"raster-array":Io,"batched-model":Qt},this.workerSources={},this.self.registerWorkerSource=(j,Y)=>{if(this.workerSourceTypes[j])throw new Error(`Worker source with name "${j}" already registered.`);this.workerSourceTypes[j]=Y},this.self.registerRTLTextPlugin=j=>{if(F.g9.isParsed())throw new Error("RTL text plugin already registered.");F.g9.setState({pluginStatus:F.ga.parsed,pluginURL:F.g9.getPluginURL()}),F.g9.applyArabicShaping=j.applyArabicShaping,F.g9.processBidirectionalText=j.processBidirectionalText,F.g9.processStyledBidirectionalText=j.processStyledBidirectionalText;for(const{resolve:Y}of this.rtlPluginParsingListeners)Y(!0);this.rtlPluginParsingListeners=[]}}clearCaches(O,j){delete this.layerIndexes[O],delete this.availableImages[O],delete this.availableModels[O],delete this.workerSources[O],delete this.isSpriteLoaded[O]}checkIfReady(O,j){}spriteLoaded(O,j){const{scope:Y}=j;if(this.isSpriteLoaded[O]||(this.isSpriteLoaded[O]={}),this.isSpriteLoaded[O][Y]=!0,this.workerSources[O]&&this.workerSources[O][Y])for(const ce in this.workerSources[O][Y]){const he=this.workerSources[O][Y][ce];for(const ue in he){const ne=he[ue];ne instanceof ji&&(ne.isSpriteLoaded=!0,ne.fire(new F.B("isSpriteLoaded")))}}}setImages(O,j){this.availableImages[O]||(this.availableImages[O]={});const{scope:Y,images:ce}=j;if(this.availableImages[O][Y]=ce,j.isSpriteLoaded&&this.spriteLoaded(O,{scope:Y}),this.workerSources[O]&&this.workerSources[O][Y])for(const he in this.workerSources[O][Y]){const ue=this.workerSources[O][Y][he];for(const ne in ue)ue[ne].availableImages=ce}}setModels(O,{scope:j,models:Y}){if(this.availableModels[O]||(this.availableModels[O]={}),this.availableModels[O][j]=Y,this.workerSources[O]&&this.workerSources[O][j])for(const ce in this.workerSources[O][j]){const he=this.workerSources[O][j][ce];for(const ue in he)he[ue].availableModels=Y}}setProjection(O,j){this.projections[O]=F.b6(j)}setGlobalParams(O,j){if(this.referrer=j.referrer,Object.assign(F.g,j.config),j.contextOptions){const{maxBindingPoints:Y,maxUniformBlockSizeDwords:ce}=j.contextOptions;this.maxUniformBufferBindings=Y,this.maxUniformBlockSizeDwords=ce}}upsertRenderParams(O,j){j.brightness!==void 0&&(this.brightness=j.brightness),j.worldview!==void 0&&(this.worldview=j.worldview)}setLayers(O,j){this.getLayerIndex(O,j.scope).replace(j.layers,j.options)}updateLayers(O,j){this.getLayerIndex(O,j.scope).update(j.layers,j.removedIds,j.options)}loadTile(O,j){return j.projection=this.projections[O]||this.defaultProjection,this.getWorkerSource(O,j).loadTile(j)}decodeRasterArray(O,j){return this.getWorkerSource(O,j).decodeRasterArray(j)}reloadTile(O,j){return j.projection=this.projections[O]||this.defaultProjection,this.getWorkerSource(O,j).reloadTile(j)}abortTile(O,j){return this.getWorkerSource(O,j).abortTile(j)}removeTile(O,j){return this.getWorkerSource(O,j).removeTile(j)}removeSource(O,j){if(!(this.workerSources[O]&&this.workerSources[O][j.scope]&&this.workerSources[O][j.scope][j.type]&&this.workerSources[O][j.scope][j.type][j.source]))return;const Y=this.workerSources[O][j.scope][j.type][j.source];return delete this.workerSources[O][j.scope][j.type][j.source],Y.removeSource!==void 0?Y.removeSource(j):void 0}async loadTileProvider(O,j){const Y=new(await F.dg(j.name,j.url))(j.options);return this.getWorkerSource(O,{type:j.type,source:j.source,scope:j.scope},Y),Y.load&&j.request?Y.load({request:j.request}):null}
vendor: 5,241 bytes, line 7
7async syncRTLPluginState(O,j){if(F.g9.isParsed())return!0;if(F.g9.isParsing())return new Promise((ce,he)=>{this.rtlPluginParsingListeners.push({resolve:ce,reject:he})});F.g9.setState(j);const Y=F.g9.getPluginURL();if(!F.g9.isLoaded()||F.g9.isParsed()||F.g9.isParsing())return!1;F.g9.setState({pluginStatus:F.ga.parsing,pluginURL:Y});try{return await self.__mapboxImport(Y),!!F.g9.isParsed()||new Promise((ce,he)=>{this.rtlPluginParsingListeners.push({resolve:ce,reject:he})})}catch(ce){F.g9.setState({pluginStatus:F.ga.error,pluginURL:Y});for(const{reject:he}of this.rtlPluginParsingListeners)he(ce);throw this.rtlPluginParsingListeners=[],ce}}getAvailableImages(O,j){this.availableImages[O]||(this.availableImages[O]={});let Y=this.availableImages[O][j];return Y||(Y=[]),Y}getAvailableModels(O,j){this.availableModels[O]||(this.availableModels[O]={});let Y=this.availableModels[O][j];return Y||(Y={}),Y}getLayerIndex(O,j){this.layerIndexes[O]||(this.layerIndexes[O]={});let Y=this.layerIndexes[O][j];return Y||(Y=this.layerIndexes[O][j]=new ho,Y.scope=j),Y}getWorkerSource(O,j,Y){const{type:ce,source:he,scope:ue}=j,ne=this.workerSources;if(ne[O]||(ne[O]={}),ne[O][ue]||(ne[O][ue]={}),ne[O][ue][ce]||(ne[O][ue][ce]={}),this.isSpriteLoaded[O]||(this.isSpriteLoaded[O]={}),ne[O][ue][ce][he])Y&&(ne[O][ue][ce][he].tileProvider=Y);else{const J=this.actor.getWorkerSourceActor(O),H=this.workerSourceTypes[ce];if(!H)throw new Error(`Unknown worker source type "${ce}".`);ne[O][ue][ce][he]=new H({actor:J,layerIndex:this.getLayerIndex(O,ue),availableImages:this.getAvailableImages(O,ue),availableModels:this.getAvailableModels(O,ue),isSpriteLoaded:this.isSpriteLoaded[O][ue],tileProvider:Y,brightness:this.brightness,worldview:this.worldview,maxUniformBufferBindings:this.maxUniformBufferBindings,maxUniformBlockSizeDwords:this.maxUniformBlockSizeDwords})}return ne[O][ue][ce][he]}enforceCacheSizeLimit(O,j){F.gb(j)}}return F.g8(self)&&(self.worker=new en(self)),en}),Cn(["./shared"],function(u){const F={antialias:!1,alpha:!0,stencil:!0,depth:!0};let Yi,Ht;function Wt(s){const t=document.createElement("canvas"),n=Object.create(F);n.failIfMajorPerformanceCaveat=s;const l=t.getContext("webgl2",n);if(!l)return!1;let d;try{d=l.createShader(l.VERTEX_SHADER)}catch{return!1}return!(!d||l.isContextLost())&&(l.shaderSource(d,"void main() {}"),l.compileShader(d),l.getShaderParameter(d,l.COMPILE_STATUS)===!0)}var St="3.27.0";const Ti=/firefox/i,mn=/macintosh/i;function Nt(s,t,n){const l=document.createElement(s);return t!=null&&(l.className=t),n&&n.appendChild(l),l}function Si(s,t,n){const l=document.createElementNS("http://www.w3.org/2000/svg",s);for(const d of Object.keys(t))l.setAttributeNS(null,d,String(t[d]));return n&&n.appendChild(l),l}const co=typeof document<"u"?document.documentElement&&document.documentElement.style:null,Ni=co&&co.userSelect!==void 0?"userSelect":"WebkitUserSelect";let Mn;function _n(){co&&Ni&&(Mn=co[Ni],co[Ni]="none")}function gn(){co&&Ni&&(co[Ni]=Mn)}function Pn(s){s.preventDefault(),s.stopPropagation(),window.removeEventListener("click",Pn,!0)}function un(){window.addEventListener("click",Pn,!0),window.setTimeout(()=>{window.removeEventListener("click",Pn,!0)},0)}function hn(s,t){const n=s.getBoundingClientRect();return ho(s,n,t)}function So(s,t){const n=s.getBoundingClientRect(),l=[];for(let d=0;d<t.length;d++)l.push(ho(s,n,t[d]));return l}function uo(s){return Ti.test(navigator.userAgent)&&mn.test(navigator.userAgent)&&s.button===2&&s.ctrlKey?0:s.button}function ho(s,t,n){const l=s.offsetWidth===t.width?1:s.offsetWidth/t.width;return new u.P((n.clientX-t.left)*l,(n.clientY-t.top)*l)}const Nn="01",Sn={create:"create",load:"load",fullLoad:"fullLoad"},Zt={mark(s){performance.mark(s)},measure(s,t,n){performance.measure(s,t,n)}};function Eo(s){const t=s.name.split("?")[0];return u.a(t)&&t.includes("mapbox-gl.js")?"javascript":u.a(t)&&t.includes("mapbox-gl.css")?"css":u.b(t)?"fontRange":u.c(t)?"sprite":u.i(t)?"style":u.d(t)?"tilejson":"other"}const Yr=/(\.(png|jpg)\d*)(?=$)/,ur=/^.+\/v4\//,Li=/\.[\w]+$/,ji=/^(\/v4\/|\/(raster|rasterarrays)\/v1\/)/,dn=/^access_token=(.*)$/,gs="NO_ACCESS_TOKEN";class Io{constructor(t,n,l){this._transformRequestFn=t,this._customAccessToken=n,this._silenceAuthErrors=!!l,this._createSkuToken()}_createSkuToken(){const t=(function(){let n="";for(let l=0;l<10;l++)n+="0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"[Math.floor(62*Math.random())];return{token:["1",Nn,n].join(""),tokenExpiresAt:Date.now()+432e5}})();this._skuToken=t.token,this._skuTokenExpiresAt=t.tokenExpiresAt}_isSkuTokenExpired(){return Date.now()>this._skuTokenExpiresAt}async transformRequest(t,n,l){if(!this._transformRequestFn)return{url:t};const d=l?{signal:l}:{};return await this._transformRequestFn(t,n,d)||{url:t}}normalizeStyleURL(t,n){if(!u.e(t))return t;const l=li(t);return l.params.push(`sdk=js-${St}`),l.path=`/styles/v1${l.path}`,this._makeAPIURL(l,this._customAccessToken||n)}normalizeGlyphsURL(t,n){if(!u.e(t))return t;const l=li(t);return l.path=`/fonts/v1${l.path}`,this._makeAPIURL(l,this._customAccessToken||n)}normalizeModelURL(t,n){if(!u.e(t))return t;const l=li(t);return l.path=`/models/v1${l.path}`,this._makeAPIURL(l,this._customAccessToken||n)}
7normalizeSourceURL(t,n,l,d){if(!u.e(t))return t;const p=li(t);return p.path=`/v4/${p.authority}.json`,p.params.push("secure"),l&&p.params.push(`language=${l}`),d&&p.params.push(`worldview=${d}`),this._makeAPIURL(p,this._customAccessToken||n)}normalizeIconsetURL(t,n){const l=li(t);return u.e(t)?(l.path=`/styles/v1${l.path}/iconset.pbf`,this._makeAPIURL(l,this._customAccessToken||n)):Kr(l)}normalizeSpriteURL(t,n,l,d){const p=li(t);return u.e(t)?(p.path=`/styles/v1${p.path}/sprite${n}${l}`,this._makeAPIURL(p,this._customAccessToken||d)):(p.path+=`${n}${l}`,Kr(p))}normalizeTileURL(t,n,l){if(this._isSkuTokenExpired()&&this._createSkuToken(),t&&!u.e(t))return t;const d=li(t);d.path=d.path.replace(Yr,`${n||l&&d.authority!=="raster"&&l===512?"@2x":""}${u.k.supported?".webp":"$1"}`),d.authority==="raster"?d.path=`/${u.g.RASTER_URL_PREFIX}${d.path}`:d.authority==="rasterarrays"?d.path=`/${u.g.RASTERARRAYS_URL_PREFIX}${d.path}`:d.authority==="3dtiles"?d.path=`/${u.g.TILES3D_URL_PREFIX}${d.path}`:(d.path=d.path.replace(ur,"/"),d.path=`/${u.g.TILE_URL_VERSION}${d.path}`);const p=this._customAccessToken||(function(m){for(const g of m){const x=g.match(dn);if(x)return x[1]}return null})(d.params)||u.g.ACCESS_TOKEN;return u.g.REQUIRE_ACCESS_TOKEN&&p&&this._skuToken&&d.params.push(`sku=${this._skuToken}`),this._makeAPIURL(d,p)}canonicalizeTileURL(t,n){const l=li(t);if(!ji.test(l.path)||!Li.test(l.path))return t;let d="mapbox://";l.path.startsWith("/raster/v1/")?d+=`raster/${l.path.replace(`/${u.g.RASTER_URL_PREFIX}/`,"")}`:l.path.startsWith("/rasterarrays/v1/")?d+=`rasterarrays/${l.path.replace(`/${u.g.RASTERARRAYS_URL_PREFIX}/`,"")}`:d+=`tiles/${l.path.replace(`/${u.g.TILE_URL_VERSION}/`,"")}`;let p=l.params;return n&&(p=p.filter(m=>!m.match(dn))),p.length&&(d+=`?${p.join("&")}`),d}canonicalizeTileset(t,n){const l=!!n&&u.e(n),d=[];for(const p of t.tiles||[])u.f(p)?d.push(this.canonicalizeTileURL(p,l)):d.push(p);return d}_makeAPIURL(t,n){const l="See https://docs.mapbox.com/api/overview/#access-tokens-and-token-scopes",d=li(u.g.API_URL);if(t.protocol=d.protocol,t.authority=d.authority,t.protocol==="http"){const p=t.params.indexOf("secure");p>=0&&t.params.splice(p,1)}if(d.path!=="/"&&(t.path=`${d.path}${t.path}`),!u.g.REQUIRE_ACCESS_TOKEN)return Kr(t);if(n=n||u.g.ACCESS_TOKEN,!this._silenceAuthErrors){if(!n)throw new Error(`An API access token is required to use Mapbox GL. ${l}`);if(n[0]==="s")throw new Error(`Use a public access token (pk.*) with Mapbox GL, not a secret access token (sk.*). ${l}`)}return t.params=t.params.filter(p=>!p.includes("access_token")),t.params.push(`access_token=${n||""}`),Kr(t)}}const Jn=/^(\w+):\/\/([^/?]*)(\/[^?]+)?\??(.+)?/;function li(s){const t=s.match(Jn);if(!t)throw new Error("Unable to parse URL object");return{protocol:t[1],authority:t[2],path:t[3]||"/",params:t[4]?t[4].split("&"):[]}}function Kr(s){const t=s.params.length?`?${s.params.join("&")}`:"";return`${s.protocol}://${s.authority}${s.path}${t}`}const ks="mapbox.eventData";function yn(s){if(!s)return null;const t=s.split(".");if(!t||t.length!==3)return null;try{return JSON.parse(u.l(t[1]))}catch{return null}}function fn(s){return!(!u.g.EVENTS_URL||!s&&!u.g.ACCESS_TOKEN)}let Jr;const Mi=/^[\w.+-]+(\/[\w.+-]+)?$/;let qi="other";class tr{constructor(t){this.type=t,this.anonId=null,this.anonIdTimestamp=null,this.eventData={},this.queue=[],this.pendingRequest=!1}getStorageKey(t){const n=yn(u.g.ACCESS_TOKEN);let l="";return l=n&&n.u?u.j(n.u):u.g.ACCESS_TOKEN||"",t?`${ks}.${t}:${l}`:`${ks}:${l}`}fetchEventData(){const t=u.s("localStorage"),n=this.getStorageKey(),l=this.getStorageKey("uuid"),d=this.getStorageKey("uuidTimestamp");if(t)try{const p=localStorage.getItem(n);p&&(this.eventData=JSON.parse(p));const m=localStorage.getItem(l);m&&(this.anonId=m);const g=localStorage.getItem(d);g&&(this.anonIdTimestamp=Number(g));const x=Date.now()-864e5;(!this.anonIdTimestamp||this.anonIdTimestamp<x)&&this.refreshUUID()}catch{u.w("Unable to read from LocalStorage")}}refreshUUID(){this.anonId=u.u(),this.anonIdTimestamp=Date.now()}saveEventData(){const t=u.s("localStorage"),n=this.getStorageKey(),l=this.getStorageKey("uuid"),d=this.getStorageKey("uuidTimestamp"),p=this.anonId,m=this.anonIdTimestamp;if(t&&p)try{localStorage.setItem(l,p),Object.keys(this.eventData).length>=1&&localStorage.setItem(n,JSON.stringify(this.eventData)),m&&localStorage.setItem(d,m.toString())}catch{u.w("Unable to write to LocalStorage")}}processRequests(){}
vendor: 57,907 bytes, lines 7-8
7postEvent(t,n,l,d){if(!u.g.EVENTS_URL)return;const p=li(u.g.EVENTS_URL);p.params.push(`access_token=${d||u.g.ACCESS_TOKEN||""}`);const m={event:this.type,created:new Date(t).toISOString()},g=n?Object.assign(m,n):m,x={url:Kr(p),headers:{"Content-Type":"text/plain"},body:JSON.stringify([g])};this.pendingRequest=!0,u.p(x).then(()=>{this.pendingRequest=!1,l(null),this.saveEventData(),this.processRequests()}).catch(w=>{this.pendingRequest=!1,l(w),this.saveEventData(),this.processRequests()})}queueRequest(t,n){this.queue.push({...t,customAccessToken:n}),this.processRequests()}}class fo extends tr{constructor(t){super("metrics"),t&&(this.data=t)}postMetricsEvent(t){if(!fn(t))return;this.anonId||this.fetchEventData(),u.v(this.anonId)||this.refreshUUID();const n={...this.data,sessionId:this.anonId};this.queueRequest({timestamp:Date.now(),payload:n},t)}processRequests(){if(this.pendingRequest||this.queue.length===0)return;const{timestamp:t,payload:n,customAccessToken:l}=this.queue.shift();this.postEvent(t,n,()=>{},l)}}const ir=new class extends tr{constructor(s){super("appUserTurnstile"),this._customAccessToken=s}postTurnstileEvent(s,t){fn(t)&&Array.isArray(s)&&s.some(n=>u.e(n)||u.f(n))&&this.queueRequest({timestamp:Date.now()},t)}processRequests(){if(this.pendingRequest||this.queue.length===0)return;this.anonId&&this.anonIdTimestamp&&this.eventData.lastSuccess&&this.eventData.tokenU||this.fetchEventData();const s=yn(u.g.ACCESS_TOKEN),t=s?s.u:u.g.ACCESS_TOKEN;let n=t!==this.eventData.tokenU;u.v(this.anonId)||(this.refreshUUID(),n=!0);const{timestamp:l,customAccessToken:d}=this.queue.shift();if(this.eventData.lastSuccess){const m=new Date(this.eventData.lastSuccess),g=new Date(l),x=(l-this.eventData.lastSuccess)/864e5;n=n||x>=1||x<-1||m.getDate()!==g.getDate()}else n=!0;if(!n)return void this.processRequests();const p={version:"2.2",sdkIdentifier:"mapbox-gl-js",sdkVersion:St,skuId:Nn,"enabled.telemetry":!1,userId:this.anonId,bundleFormat:"umd",bundleDistribution:qi};Jr&&(p.sdkInfo=Jr),this.postEvent(l,p,m=>{m||(this.eventData.lastSuccess=l,this.eventData.tokenU=t)},d)}},Xo=ir.postTurnstileEvent.bind(ir),Bs=new class extends tr{constructor(){super("map.load"),this.success={},this.skuToken=""}postMapLoadEvent(s,t,n,l){this.skuToken=t,this.errorCb=l,u.g.EVENTS_URL&&(n||u.g.ACCESS_TOKEN?this.queueRequest({id:s,timestamp:Date.now()},n):this.errorCb(new Error(gs)))}processRequests(){if(this.pendingRequest||this.queue.length===0)return;const{id:s,timestamp:t,customAccessToken:n}=this.queue.shift();if(s&&this.success[s])return;this.anonId&&this.anonIdTimestamp||this.fetchEventData(),u.v(this.anonId)||this.refreshUUID();const l={version:"2.2",sdkIdentifier:"mapbox-gl-js",sdkVersion:St,skuId:Nn,skuToken:this.skuToken,userId:this.anonId,bundleFormat:"umd",bundleDistribution:qi};Jr&&(l.sdkInfo=Jr),this.postEvent(t,l,d=>{d?this.errorCb(d):s&&(this.success[s]=!0)},n)}remove(){this.errorCb=null}},Rn=Bs.postMapLoadEvent.bind(Bs),Zi=new class extends tr{constructor(){super("style.load"),this.eventIdPerMapInstanceMap=new Map,this.mapInstanceIdMap=new WeakMap}getMapInstanceId(s){let t=this.mapInstanceIdMap.get(s);return t||(t=u.u(),this.mapInstanceIdMap.set(s,t)),t}getEventId(s){const t=this.eventIdPerMapInstanceMap.get(s)||0;return this.eventIdPerMapInstanceMap.set(s,t+1),t}postStyleLoadEvent(s,t){const{map:n,style:l,importedStyles:d}=t;if(!fn(s))return;const p=this.getMapInstanceId(n),m={mapInstanceId:p,eventId:this.getEventId(p),style:l};d.length&&(m.importedStyles=d),this.queueRequest({timestamp:Date.now(),payload:m},s)}processRequests(){if(this.pendingRequest||this.queue.length===0)return;const{timestamp:s,payload:t,customAccessToken:n}=this.queue.shift();this.postEvent(s,t,()=>{},n)}},Ia=Zi.postStyleLoadEvent.bind(Zi),Dn=new fo({attributes:[{name:"maps/js/layer-animations/style-with-appearances"}]}),ys=Dn.postMetricsEvent.bind(Dn),Yo=new fo({attributes:[{name:"maps/js/layer-animations/runtime-appearances"}]}),Ko=Yo.postMetricsEvent.bind(Yo),Ln=new class extends tr{constructor(){super("gljs.performance")}postPerformanceEvent(s,t){fn(s)&&this.queueRequest({timestamp:Date.now(),performanceData:t},s)}processRequests(){if(this.pendingRequest||this.queue.length===0)return;const{timestamp:s,performanceData:t,customAccessToken:n}=this.queue.shift(),l=(function(d){const p=performance.getEntriesByType("resource"),m=performance.getEntriesByType("mark"),g=(function(M){const D={};if(M){for(const L in M)if(L!=="other")for(const k of M[L]){const B=`${L}ResolveRangeMin`,$=`${L}ResolveRangeMax`,Z=`${L}RequestCount`,G=`${L}RequestCachedCount`;D[B]=Math.min(D[B]||1/0,k.startTime),D[$]=Math.max(D[$]||-1/0,k.responseEnd);const te=ee=>{D[ee]===void 0&&(D[ee]=0),++D[ee]};k.transferSize!==void 0&&k.transferSize===0&&te(G),te(Z)}}return D})((function(M,D){const L={};if(M)for(const k of M){const B=D(k);L[B]===void 0&&(L[B]=[]),L[B].push(k)}return L})(p,Eo)),x=window.devicePixelRatio,w=navigator.connection||navigator.mozConnection||navigator.webkitConnection,S=w?w.effectiveType:void 0,A={counters:[],metadata:[],attributes:[]},I=(M,D,L)=>{L!=null&&M.push({name:D,value:L.toString()})};for(const M in g)I(A.counters,M,g[M]);if(d.interactionRange[0]!==1/0&&d.interactionRange[1]!==-1/0&&(I(A.counters,"interactionRangeMin",d.interactionRange[0]),I(A.counters,"interactionRangeMax",d.interactionRange[1])),m)for(const M of Object.values(Sn)){const D=m.find(L=>L.name===M);D&&I(A.counters,M,D.startTime)}return I(A.counters,"visibilityHidden",d.visibilityHidden),I(A.attributes,"style",(function(M){if(M)for(const D of M){const L=D.name.split("?")[0];if(u.i(L)){const k=L.split("/").slice(-2);if(k.length===2)return`mapbox://styles/${k[0]}/${k[1]}`}}})(p)),I(A.attributes,"terrainEnabled",d.terrainEnabled?"true":"false"),I(A.attributes,"fogEnabled",d.fogEnabled?"true":"false"),I(A.attributes,"projection",d.projection),I(A.attributes,"zoom",d.zoom),I(A.metadata,"devicePixelRatio",x),I(A.metadata,"connectionEffectiveType",S),I(A.metadata,"navigatorUserAgent",navigator.userAgent),I(A.metadata,"screenWidth",window.screen.width),I(A.metadata,"screenHeight",window.screen.height),I(A.metadata,"windowWidth",window.innerWidth),I(A.metadata,"windowHeight",window.innerHeight),I(A.metadata,"mapWidth",d.width/x),I(A.metadata,"mapHeight",d.height/x),I(A.metadata,"webglRenderer",d.renderer),I(A.metadata,"webglVendor",d.vendor),I(A.metadata,"sdkVersion",St),I(A.metadata,"sdkIdentifier","mapbox-gl-js"),A})(t);for(const d of l.metadata);for(const d of l.counters);for(const d of l.attributes);this.postEvent(s,l,()=>{},n)}},Qn=Ln.postPerformanceEvent.bind(Ln),Ao=new class extends tr{constructor(){super("map.auth"),this.success={},this.skuToken=""}getSession(s,t,n,l){if(!u.g.API_URL||!u.g.SESSION_PATH)return;const d=li(u.g.API_URL+u.g.SESSION_PATH);d.params.push(`sku=${t||""}`),d.params.push(`access_token=${l||u.g.ACCESS_TOKEN||""}`);const p={url:Kr(d),headers:{"Content-Type":"text/plain"}};this.pendingRequest=!0,u.h(p).then(()=>{this.pendingRequest=!1,n(null),this.saveEventData(),this.processRequests()}).catch(m=>{this.pendingRequest=!1,n(m),this.saveEventData(),this.processRequests()})}getSessionAPI(s,t,n,l){this.skuToken=t,this.errorCb=l,u.g.EVENTS_URL&&u.g.SESSION_PATH&&u.g.API_URL&&(n||u.g.ACCESS_TOKEN?this.queueRequest({id:s,timestamp:Date.now()},n):this.errorCb(new Error(gs)))}processRequests(){if(this.pendingRequest||this.queue.length===0)return;const{id:s,timestamp:t,customAccessToken:n}=this.queue.shift();s&&this.success[s]||this.getSession(t,this.skuToken,l=>{l?this.errorCb(l):s&&(this.success[s]=!0)},n)}remove(){this.errorCb=null}},Jo=Ao.getSessionAPI.bind(Ao),eo=new Set;function zr(s,t){t?eo.add(s):eo.delete(s)}class to{constructor(){this._changed=!1,this._updatedLayers=Object.create(null),this._removedLayers=Object.create(null),this._updatedSourceCaches=Object.create(null),this._updatedPaintProps=new Set,this._updatedImages=Object.create(null)}isDirty(){return this._changed}setDirty(){this._changed=!0}getUpdatedSourceCaches(){return this._updatedSourceCaches}updateSourceCache(t,n){this._updatedSourceCaches[t]=n,this.setDirty()}discardSourceCacheUpdate(t){delete this._updatedSourceCaches[t]}updateLayer(t){const n=t.scope;this._updatedLayers[n]=this._updatedLayers[n]||new Set,this._updatedLayers[n].add(t.id),this.setDirty()}removeLayer(t){const n=t.scope;this._removedLayers[n]=this._removedLayers[n]||{},this._updatedLayers[n]=this._updatedLayers[n]||new Set,this._removedLayers[n][t.id]=t,this._updatedLayers[n].delete(t.id),this._updatedPaintProps.delete(t.fqid),this.setDirty()}getRemovedLayer(t){return this._removedLayers[t.scope]?this._removedLayers[t.scope][t.id]:null}discardLayerRemoval(t){this._removedLayers[t.scope]&&delete this._removedLayers[t.scope][t.id]}getLayerUpdatesByScope(){const t={};for(const n in this._updatedLayers)t[n]=t[n]||{},t[n].updatedIds=Array.from(this._updatedLayers[n].values());for(const n in this._removedLayers)t[n]=t[n]||{},t[n].removedIds=Object.keys(this._removedLayers[n]);return t}getUpdatedPaintProperties(){return this._updatedPaintProps}updatePaintProperties(t){this._updatedPaintProps.add(t.fqid),this.setDirty()}getUpdatedImages(t){return this._updatedImages[t]?Array.from(this._updatedImages[t].values()):[]}updateImage(t,n){this._updatedImages[n]=this._updatedImages[n]||new Set,this._updatedImages[n].add(u.I.toString(t)),this.setDirty()}resetUpdatedImages(t){this._updatedImages[t]&&this._updatedImages[t].clear()}reset(){this._changed=!1,this._updatedLayers=Object.create(null),this._removedLayers=Object.create(null),this._updatedSourceCaches=Object.create(null),this._updatedPaintProps.clear(),this._updatedImages=Object.create(null)}}class Co{constructor(t){this._layer=t,this._filterDependencies=void 0}invalidateFilter(){this._filterDependencies=void 0}get _filterDeps(){return this._filterDependencies===void 0&&(this._filterDependencies=this._computeFilterDependencies()),this._filterDependencies}_computeFilterDependencies(){const t=this._layer;if(!t.type||t.type==="custom"||t.type==="background"||t.type==="sky"||t.type==="slot")return null;const n=u.n(t.filter,u.m[`filter_${t.type}`]);return n.result==="error"?null:{configDependencies:n.value.configDependencies,isIndoorDependent:n.value.isIndoorDependent}}hasConfigDependency(t){const{_unevaluatedLayout:n,_transitionablePaint:l}=this._layer;if(n&&n.configDependencies.has(t)||l&&l.configDependencies.has(t))return!0;const d=this._filterDeps;return!!d&&d.configDependencies.has(t)}get isConfigDependent(){const{_unevaluatedLayout:t,_transitionablePaint:n}=this._layer;if(t&&t.configDependencies.size!==0||n&&n.configDependencies.size!==0)return!0;const l=this._filterDeps;return!!l&&l.configDependencies.size!==0}get isIndoorDependent(){const{_unevaluatedLayout:t,_transitionablePaint:n}=this._layer;if(t&&t.isIndoorDependent()||n&&n.isIndoorDependent())return!0;const l=this._filterDeps;return!!l&&l.isIndoorDependent}}function Aa(s){const{userImage:t}=s;return!!(t&&t.render&&t.render())&&(s.data.replace(new Uint8Array(t.data.buffer)),!0)}const xs=new u.C(0,0,0);function rr(s,t){const n=[],l=s[`stretch_${t}`];let d=null;for(let p=0;p<l.length;p++)d===null?d=n.length===0?l[0]:n.at(-1)[1]+l[p]:(n.push([d,d+l[p]]),d=null);s[`stretch_${t}_areas`]=n}function io(s,t){const n={name:void 0};let l;for(;l=s.nextField(t);)l===1?n.name=s.readString():l===2?n.metadata=Qo(s,s.readVarint()+s.pos):l===3&&(n.usvg_tree=Ns(s,s.readVarint()+s.pos),n.data="usvg_tree");return(function(d){if(d.usvg_tree.height||(d.usvg_tree.height=d.usvg_tree.width),!d.metadata)return d;const{metadata:p}=d;if(p.content_area){const{content_area:m}=p;m.left==null&&(m.left=0),m.top==null&&(m.top=m.left),m.width==null&&(m.width=d.usvg_tree.width),m.height==null&&(m.height=m.width)}if(p.text_placeholder){const{text_placeholder:m}=p;m.top==null&&(m.top=m.left),m.height==null&&(m.height=m.width)}return p.stretch_x&&p.stretch_x.length&&rr(p,"x"),p.stretch_y&&p.stretch_y.length&&rr(p,"y"),d})(n)}function Qo(s,t){const n={stretch_x:null,stretch_y:null,stretch_x_areas:null,stretch_y_areas:null,variables:[]};let l;for(;l=s.nextField(t);)l===1?n.stretch_x=s.readPackedVarint():l===2?n.stretch_y=s.readPackedVarint():l===3?n.content_area=es(s,s.readVarint()+s.pos):l===4?n.variables.push(vs(s,s.readVarint()+s.pos)):l===5&&(n.text_placeholder=es(s,s.readVarint()+s.pos));return n}function es(s,t){const n={};let l;for(;l=s.nextField(t);)l===1?n.left=s.readVarint():l===2?n.width=s.readVarint():l===3?n.top=s.readVarint():l===4&&(n.height=s.readVarint());return n}function vs(s,t){const n={name:void 0};let l;for(;l=s.nextField(t);)l===1?n.name=s.readString():l===2&&(n.rgb_color=ro(s.readVarint()),n.value="rgb_color");return n}function Ns(s,t){const n={width:20,children:[],linear_gradients:[],radial_gradients:[],clip_paths:[],masks:[],height:20};let l;for(;l=s.nextField(t);)l===1?n.width=n.height=s.readVarint():l===2?n.height=s.readVarint():l===3?n.children.push(ts(s,s.readVarint()+s.pos)):l===4?n.linear_gradients.push(Ma(s,s.readVarint()+s.pos)):l===5?n.radial_gradients.push(Vc(s,s.readVarint()+s.pos)):l===7?n.clip_paths.push(sa(s,s.readVarint()+s.pos)):l===8&&n.masks.push(Vs(s,s.readVarint()+s.pos));return n}function ts(s,t){const n={};let l;for(;l=s.nextField(t);)l===1?(n.group=bs(s,s.readVarint()+s.pos),n.node="group"):l===2&&(n.path=Po(s,s.readVarint()+s.pos),n.node="path");return n}function bs(s,t){const n={opacity:255,children:[]};let l;for(;l=s.nextField(t);)l===1?n.transform=Mo(s,s.readVarint()+s.pos):l===2?n.opacity=s.readVarint():l===5?n.clip_path_idx=s.readVarint():l===6?n.mask_idx=s.readVarint():l===7&&n.children.push(ts(s,s.readVarint()+s.pos));return n}function Mo(s,t){const n={sx:1,ky:0,kx:0,sy:1,tx:0,ty:0};let l;for(;l=s.nextField(t);)l===1?n.sx=s.readFloat():l===2?n.ky=s.readFloat():l===3?n.kx=s.readFloat():l===4?n.sy=s.readFloat():l===5?n.tx=s.readFloat():l===6&&(n.ty=s.readFloat());return n}function Po(s,t){const n={paint_order:1,commands:[],step:1,diffs:[],rule:1};let l;for(;l=s.nextField(t);)l===1?n.fill=Ca(s,s.readVarint()+s.pos):l===2?n.stroke=Ue(s,s.readVarint()+s.pos):l===3?n.paint_order=s.readVarint():l===5?s.readPackedVarint(n.commands):l===6?n.step=s.readFloat():l===7?s.readPackedSVarint(n.diffs):l===8&&(n.rule=s.readVarint());return n}function Ca(s,t){const n={rgb_color:xs,paint:"rgb_color",opacity:255};let l;for(;l=s.nextField(t);)l===1?(n.rgb_color=ro(s.readVarint()),n.paint="rgb_color"):l===2?(n.linear_gradient_idx=s.readVarint(),n.paint="linear_gradient_idx"):l===3?(n.radial_gradient_idx=s.readVarint(),n.paint="radial_gradient_idx"):l===5&&(n.opacity=s.readVarint());return n}function Ue(s,t){const n={rgb_color:xs,paint:"rgb_color",dasharray:[],dashoffset:0,miterlimit:4,opacity:255,width:1,linecap:1,linejoin:1};let l;for(;l=s.nextField(t);)l===1?(n.rgb_color=ro(s.readVarint()),n.paint="rgb_color"):l===2?(n.linear_gradient_idx=s.readVarint(),n.paint="linear_gradient_idx"):l===3?(n.radial_gradient_idx=s.readVarint(),n.paint="radial_gradient_idx"):l===5?s.readPackedFloat(n.dasharray):l===6?n.dashoffset=s.readFloat():l===7?n.miterlimit=s.readFloat():l===8?n.opacity=s.readVarint():l===9?n.width=s.readFloat():l===10?n.linecap=s.readVarint():l===11&&(n.linejoin=s.readVarint());return n}function ro(s){return new u.C((s>>16&255)/255,(s>>8&255)/255,(255&s)/255,1)}function Ma(s,t){const n={spread_method:1,stops:[],x1:0,y1:0,x2:1,y2:0};let l;for(;l=s.nextField(t);)l===1?n.transform=Mo(s,s.readVarint()+s.pos):l===2?n.spread_method=s.readVarint():l===3?n.stops.push(zn(s,s.readVarint()+s.pos)):l===4?n.x1=s.readFloat():l===5?n.y1=s.readFloat():l===6?n.x2=s.readFloat():l===7&&(n.y2=s.readFloat());return n}function zn(s,t){const n={offset:0,opacity:255,rgb_color:xs};let l;for(;l=s.nextField(t);)l===1?n.offset=s.readFloat():l===2?n.opacity=s.readVarint():l===3&&(n.rgb_color=ro(s.readVarint()));return n}function Vc(s,t){const n={spread_method:1,stops:[],cx:.5,cy:.5,r:.5,fx:.5,fy:.5,fr:0};let l;for(;l=s.nextField(t);)l===1?n.transform=Mo(s,s.readVarint()+s.pos):l===2?n.spread_method=s.readVarint():l===3?n.stops.push(zn(s,s.readVarint()+s.pos)):l===4?n.cx=s.readFloat():l===5?n.cy=s.readFloat():l===6?n.r=s.readFloat():l===7?n.fx=s.readFloat():l===8?n.fy=s.readFloat():l===9&&(n.fr=s.readFloat());return n}function sa(s,t){const n={children:[]};let l;for(;l=s.nextField(t);)l===1?n.transform=Mo(s,s.readVarint()+s.pos):l===2?n.clip_path_idx=s.readVarint():l===3&&n.children.push(ts(s,s.readVarint()+s.pos));return n}function Vs(s,t){const n={left:0,width:20,mask_type:1,children:[]};let l;for(;l=s.nextField(t);)l===1?n.left=n.top=s.readFloat():l===2?n.width=n.height=s.readFloat():l===3?n.top=s.readFloat():l===4?n.height=s.readFloat():l===5?n.mask_type=s.readVarint():l===6?n.mask_idx=s.readVarint():l===7&&n.children.push(ts(s,s.readVarint()+s.pos));return n.height==null&&(n.height=n.width),n.top==null&&(n.top=n.left),n}class Ro{static calculate(t={},n=[]){const l=new Map,d=new Map;if(Object.keys(t).length===0)return l;n.forEach(p=>{d.set(p.name,p.rgb_color||new u.C(0,0,0))});for(const[p,m]of Object.entries(t))d.has(p)?l.set(d.get(p).toString(),m):console.warn(`Ignoring unknown image variable "${p}"`);return l}}function xn(s,t=255,n){const l=n.get(s.toString())||s;return t===255?l.toString():new u.C(l.r,l.g,l.b,l.a*t/255).toString()}const is=[];let sl=0;function aa(s,t){if(sl>=is.length){const l=u.x()?new OffscreenCanvas(s,t).getContext("2d",{willReadFrequently:!0}):document.createElement("canvas").getContext("2d",{willReadFrequently:!0});is.push(l)}const n=is[sl++];return n.canvas.width=s,n.canvas.height=t,n}function Qr(){sl--}function Pa(s,t,n,l,d){for(const p of l.children)ws(s,t,n,p,d)}function ws(s,t,n,l,d){l.group?(s.save(),(function(p,m,g,x,w){const S=x.mask_idx!=null?g.masks[x.mask_idx]:null,A=x.clip_path_idx!=null?g.clip_paths[x.clip_path_idx]:null;if(x.transform&&(m=j(x.transform).preMultiplySelf(m)),!(function(M,D,L){return M.opacity!==255||D||L})(x,A!=null,S!=null))return void Pa(p,m,g,x,w);const I=aa(p.canvas.width,p.canvas.height);Pa(I,m,g,x,w),A&&pe(I,m,g,A),S&&O(I,m,g,S,w),p.globalAlpha=x.opacity/255,p.drawImage(I.canvas,0,0),Qr()})(s,t,n,l.group,d),s.restore()):l.path&&(s.save(),(function(p,m,g,x,w){p.setTransform(m),x.paint_order===1?(Us(p,g,x,w),js(p,g,x,w)):(js(p,g,x,w),Us(p,g,x,w))})(s,t,n,l.path,d),s.restore())}function Us(s,t,n,l){const d=n.fill;if(!d)return;const p=d.opacity/255;switch(s.save(),s.beginPath(),Y(n,s),d.paint){case"rgb_color":s.fillStyle=xn(d.rgb_color,d.opacity,l);break;case"linear_gradient_idx":{const m=t.linear_gradients[d.linear_gradient_idx];m.transform&&s.setTransform(j(m.transform).preMultiplySelf(s.getTransform())),s.fillStyle=Zl(s,m,p,l);break}case"radial_gradient_idx":{const m=t.radial_gradients[d.radial_gradient_idx];m.transform&&s.setTransform(j(m.transform).preMultiplySelf(s.getTransform())),s.fillStyle=Qt(s,m,p,l)}}s.fill(al(n)),s.restore()}function al(s){return s.rule===1?"nonzero":s.rule===2?"evenodd":void 0}function js(s,t,n,l){const d=n.stroke;if(!d)return;const p=ce(n);s.lineWidth=d.width,s.miterLimit=d.miterlimit,s.setLineDash(d.dasharray),s.lineDashOffset=d.dashoffset;const m=d.opacity/255;switch(d.paint){case"rgb_color":s.strokeStyle=xn(d.rgb_color,d.opacity,l);break;case"linear_gradient_idx":s.strokeStyle=Zl(s,t.linear_gradients[d.linear_gradient_idx],m,l,!0);break;case"radial_gradient_idx":s.strokeStyle=Qt(s,t.radial_gradients[d.radial_gradient_idx],m,l,!0)}switch(d.linejoin){case 2:case 1:s.lineJoin="miter";break;case 3:s.lineJoin="round";break;case 4:s.lineJoin="bevel"}switch(d.linecap){case 1:s.lineCap="butt";break;case 2:s.lineCap="round";break;case 3:s.lineCap="square"}s.stroke(p)}function Zl(s,t,n,l,d=!1){if(t.stops.length===1){const I=t.stops[0];return xn(I.rgb_color,I.opacity*n,l)}const{x1:p,y1:m,x2:g,y2:x}=t;let w=new DOMPoint(p,m),S=new DOMPoint(g,x);if(d){const I=j(t.transform);w=I.transformPoint(w),S=I.transformPoint(S)}const A=s.createLinearGradient(w.x,w.y,S.x,S.y);for(const I of t.stops)A.addColorStop(I.offset,xn(I.rgb_color,I.opacity*n,l));return A}function Qt(s,t,n,l,d=!1){if(t.stops.length===1){const B=t.stops[0];return xn(B.rgb_color,B.opacity*n,l)}const p=j(t.transform),{fx:m,fy:g,fr:x,cx:w,cy:S,r:A}=t;let I=new DOMPoint(m,g),M=new DOMPoint(w,S),D=x,L=A;if(d){I=p.transformPoint(I),M=p.transformPoint(M);const B=(p.a+p.d)/2;D=x*B,L=t.r*B}const k=s.createRadialGradient(I.x,I.y,D,M.x,M.y,L);for(const B of t.stops)k.addColorStop(B.offset,xn(B.rgb_color,B.opacity*n,l));return k}function en(s,t,n,l){const d=l.transform?j(l.transform).preMultiplySelf(t):t,p=aa(s.canvas.width,s.canvas.height);for(const g of l.children)if(g.group)en(p,d,n,g.group);else if(g.path){const x=g.path,w=new Path2D;w.addPath(ce(x),d),p.fill(w,al(x))}const m=l.clip_path_idx!=null?n.clip_paths[l.clip_path_idx]:null;m&&pe(p,d,n,m),s.globalCompositeOperation="source-over",s.drawImage(p.canvas,0,0),Qr()}function pe(s,t,n,l){const d=aa(s.canvas.width,s.canvas.height);en(d,t,n,l),s.globalCompositeOperation="destination-in",s.drawImage(d.canvas,0,0),Qr()}function O(s,t,n,l,d){if(l.children.length===0)return;const p=l.mask_idx!=null?n.masks[l.mask_idx]:null;p&&O(s,t,n,p,d);const m=s.canvas.width,g=s.canvas.height,x=aa(m,g),w=l.width,S=l.height,A=l.left,I=l.top,M=new Path2D,D=new Path2D;D.rect(A,I,w,S),M.addPath(D,t),x.clip(M);for(const B of l.children)ws(x,t,n,B,d);const L=x.getImageData(0,0,m,g),k=L.data;if(l.mask_type===1)for(let B=0;B<k.length;B+=4)k[B+3]=k[B+3]/255*(.2126*k[B]+.7152*k[B+1]+.0722*k[B+2]);x.putImageData(L,0,0),s.globalCompositeOperation="destination-in",s.drawImage(x.canvas,0,0),Qr()}function j(s){return s?new DOMMatrix([s.sx,s.ky,s.kx,s.sy,s.tx,s.ty]):new DOMMatrix}function Y(s,t){const n=s.step;let l=s.diffs[0]*n,d=s.diffs[1]*n;t.moveTo(l,d);for(let p=0,m=2;p<s.commands.length;p++)switch(s.commands[p]){case 1:l+=s.diffs[m++]*n,d+=s.diffs[m++]*n,t.moveTo(l,d);break;case 2:l+=s.diffs[m++]*n,d+=s.diffs[m++]*n,t.lineTo(l,d);break;case 3:{const g=l+s.diffs[m++]*n,x=d+s.diffs[m++]*n;l=g+s.diffs[m++]*n,d=x+s.diffs[m++]*n,t.quadraticCurveTo(g,x,l,d);break}case 4:{const g=l+s.diffs[m++]*n,x=d+s.diffs[m++]*n,w=g+s.diffs[m++]*n,S=x+s.diffs[m++]*n;l=w+s.diffs[m++]*n,d=S+s.diffs[m++]*n,t.bezierCurveTo(g,x,w,S,l,d);break}case 5:t.closePath()}return t}function ce(s){return Y(s,new Path2D)}class he{constructor(){this.cacheMap=new Map,this.cacheDependenciesMap=new Map}static _getImage(t){return new u.t(t,t.data)}getFromCache(t,n,l){return this.cacheMap.has(l)||this.cacheMap.set(l,new u.L(150)),this.cacheMap.get(l).get(u.y(t.toString(),n))}setInCache(t,n,l,d){this.cacheDependenciesMap.has(d)||this.cacheDependenciesMap.set(d,new Map),this.cacheMap.has(d)||this.cacheMap.set(d,new u.L(150));const p=this.cacheDependenciesMap.get(d),m=u.y(t.id.toString(),l);p.get(m)||p.set(m,new Set);const g=this.cacheMap.get(d),x=t.toString();p.get(m).add(x),g.put(u.y(t.toString(),l),n)}removeImagesFromCacheByIds(t,n,l=0){if(!this.cacheMap.has(l)||!this.cacheDependenciesMap.has(l))return;const d=this.cacheMap.get(l),p=this.cacheDependenciesMap.get(l);for(const m of t){const g=u.y(m.toString(),n);if(p.has(g)){for(const x of p.get(g))d.delete(x);p.delete(g)}}}rasterize(t,n,l,d){const p=this.getFromCache(t,l,d);if(p)return p.clone();const m=(function(x,w){const S=Ro.calculate(w.params,x.metadata?x.metadata.variables:[]),A=x.usvg_tree,I=A.width,M=A.height,D=Math.max(1,Math.round(I*w.sx)),L=Math.max(1,Math.round(M*w.sy)),k=new DOMMatrix([D/I,0,0,L/M,0,0]),B=aa(D,L);Pa(B,k,A,A,S);const $=B.getImageData(0,0,D,L);return Qr(),$})(n.icon,t),g=he._getImage(m);return this.setInCache(t,g,l,d),g.clone()}}class ue extends u.E{constructor(t){super(),this.imageProviders=new Map,this.images=new Map,this.updatedImages=new Map,this.callbackDispatchedThisFrame=new Map,this.imageVersions=new Map,this.loaded=new Map,this.requestors=[],this.patterns=new Map,this.patternsInFlight=new Set,this.atlasImage=new Map,this.atlasTexture=new Map,this.imageAtlasCache=new u.z,this.dirty=!0,this.spriteFormat=t,this.imageRasterizer=new he}addScope(t){this.loaded.set(t,!1),this.imageProviders.set(t,new Map),this.images.set(t,new Map),this.updatedImages.set(t,new Set),this.callbackDispatchedThisFrame.set(t,new Set),this.imageVersions.set(t,new Map),this.patterns.set(t,new Map),this.atlasImage.set(t,new u.t({width:1,height:1}))}removeScope(t){this.loaded.delete(t),this.imageProviders.delete(t),this.images.delete(t),this.updatedImages.delete(t),this.callbackDispatchedThisFrame.delete(t),this.imageVersions.delete(t),this.patterns.delete(t),this.atlasImage.delete(t);const n=this.atlasTexture.get(t);n&&(n.destroy(),this.atlasTexture.delete(t))}addImageProvider(t,n){this.imageProviders.has(n)||this.imageProviders.set(n,new Map),this.imageProviders.get(n).set(t.id,t)}removeImageProvider(t,n){this.imageProviders.has(n)&&this.imageProviders.get(n).delete(t)}getPendingImageProviders(){const t=[];for(const n of this.imageProviders.values())for(const l of n.values())l.hasPendingRequests()&&t.push(l);return t}isLoaded(){for(const t of this.loaded.keys())if(!this.loaded.get(t))return!1;return!0}setLoaded(t,n){if(this.loaded.get(n)!==t&&(this.loaded.set(n,t),t)){for(const{ids:l,callback:d}of this.requestors)this._notify(l,n,d);this.requestors=[]}}hasImage(t,n){return!!this.getImage(t,n)}getImage(t,n){return this.images.get(n).get(t.toString())}addImage(t,n,l){if(this._validate(t,l)){this.images.get(n).set(t.toString(),l);const d=this.imageVersions.get(n),p=d.get(t.toString())||0;d.set(t.toString(),p+1)}}_validate(t,n){let l=!0;return this._validateStretch(n.stretchX,n.data&&n.data.width)||(this.fire(new u.A(new Error(`Image "${t.name}" has invalid "stretchX" value`))),l=!1),this._validateStretch(n.stretchY,n.data&&n.data.height)||(this.fire(new u.A(new Error(`Image "${t.name}" has invalid "stretchY" value`))),l=!1),this._validateContent(n.content,n)||(this.fire(new u.A(new Error(`Image "${t.name}" has invalid "content" value`))),l=!1),l}_validateStretch(t,n){if(!t)return!0;let l=0;for(const d of t){if(d[0]<l||d[1]<d[0]||n<d[1])return!1;l=d[1]}return!0}_validateContent(t,n){return t?t.length!==4||!n.usvg&&(t[0]<0||n.data.width<t[0]||t[1]<0||n.data.height<t[1]||t[2]<0||n.data.width<t[2]||t[3]<0||n.data.height<t[3])?!1:!(t[2]<t[0]||t[3]<t[1]):!0}updateImage(t,n,l){const d=this.images.get(n).get(t.toString());l.version=d.version+1,this.images.get(n).set(t.toString(),l),this.updatedImages.get(n).add(t);const p=this.imageVersions.get(n),m=p.get(t.toString())||0;p.set(t.toString(),m+1),this.removeFromImageRasterizerCache(t,n)}clearUpdatedImages(t){this.updatedImages.get(t).clear()}removeFromImageRasterizerCache(t,n){this.spriteFormat!=="raster"&&this.imageRasterizer.removeImagesFromCacheByIds([t],n)}removeImage(t,n){const l=this.images.get(n),d=l.get(t.toString());l.delete(t.toString());const p=this.imageVersions.get(n),m=p.get(t.toString())||0;p.set(t.toString(),m+1),this.patterns.get(n).delete(t.toString()),this.removeFromImageRasterizerCache(t,n),d.userImage&&d.userImage.onRemove&&d.userImage.onRemove()}listImages(t){return Array.from(this.images.get(t).keys()).map(n=>u.I.from(n))}getImageVersions(t){return this.imageVersions.get(t)||new Map}getImages(t,n,l){const d=[],p=[],m=this.imageProviders.get(n);for(const S of t){if(!S.iconsetId){d.push(S);continue}const A=m.get(S.iconsetId);A&&(this.getImage(S,n)?p.push(S):A.addPendingRequest(S))}if(d.length===0)return void this._notify(p,n,l);let g=!0;const x=!!this.loaded.get(n),w=this.images.get(n);if(!x)for(const S of d)w.has(S.toString())||(g=!1);x||g?this._notify(d,n,l):this.requestors.push({ids:d,scope:n,callback:l})}rasterizeImages(t,n){const l=new Map,{iconTasks:d,patternTasks:p,scope:m}=t;for(const g of[d,p])for(const[x,w]of g.entries()){const S=this.getImage(w.id,m);S&&l.set(x,{image:S,imageVariant:w})}n(null,this._rasterizeImages(m,l))}_rasterizeImages(t,n){const l=new Map;for(const[d,{image:p,imageVariant:m}]of n.entries())l.set(d,this.imageRasterizer.rasterize(m,p,t,0));return l}getUpdatedImages(t){return this.updatedImages.get(t)||new Set}_notify(t,n,l){const d=this.images.get(n),p=new Map;for(const m of t){if(!d.get(m.toString())){if(m.iconsetId)continue;this.fire(new u.B("styleimagemissing",{id:m.name}))}const g=d.get(m.toString());if(!g){u.w(`Image "${m.name}" could not be loaded. Please make sure you have added the image with map.addImage() or a "sprite" property in your style. You can provide missing images by listening for the "styleimagemissing" map event.`);continue}const x={data:g.usvg?null:g.data.clone(),pixelRatio:g.pixelRatio,sdf:g.sdf,usvg:g.usvg,stretchX:g.stretchX,stretchY:g.stretchY,content:g.content,hasRenderCallback:!!(g.userImage&&g.userImage.render)};g.usvg&&Object.assign(x,{width:g.icon.usvg_tree.width,height:g.icon.usvg_tree.height}),p.set(u.I.toString(m),x)}l(null,{images:p,versions:this.getImageVersions(n)})}getPixelSize(t){const{width:n,height:l}=this.atlasImage.get(t);return{width:n,height:l}}getPattern(t,n,l){const d=t.toString(),p=this.patterns.get(n),m=p.get(d),g=this.getImage(t,n);if(!g)return null;if(m){if(m.position.version===g.version)return m.position;m.position.version=g.version}else{if(g.usvg&&!g.data){const x=this.getPatternInFlightId(d,n);if(this.patternsInFlight.has(x))return null;this.patternsInFlight.add(x);const w=new u.D(t).scaleSelf(u.r.devicePixelRatio),S=new Map([[w.toString(),{image:g,imageVariant:w}]]),A=this._rasterizeImages(n,S);return this.storePatternImage(w,n,g,l,A),null}this.storePattern(t,n,g)}return this._updatePatternAtlas(n,l),p.get(d).position}getPatternInFlightId(t,n){return u.y(t,n)}hasPatternsInFlight(){return this.patternsInFlight.size!==0}storePatternImage(t,n,l,d,p){const m=t.toString(),g=p?p.get(m):void 0;g&&(l.data=g,this.storePattern(t.id,n,l),this._updatePatternAtlas(n,d),this.patternsInFlight.delete(this.getPatternInFlightId(t.id.toString(),n)))}storePattern(t,n,l){const d={w:l.data.width+2*u.F,h:l.data.height+2*u.F,x:0,y:0},p=new u.G(d,l,u.F);this.patterns.get(n).set(t.toString(),{bin:d,position:p})}destroyAtlasTextures(){for(const t of this.atlasTexture.values())t&&t.destroy();this.atlasTexture.clear()}bind(t,n){const l=t.gl;let d=this.atlasTexture.get(n);d?this.dirty&&(d.update(this.atlasImage.get(n)),this.dirty=!1):(d=new u.T(t,this.atlasImage.get(n),l.RGBA8),this.atlasTexture.set(n,d)),d.bind(l.LINEAR,l.CLAMP_TO_EDGE)}_updatePatternAtlas(t,n){const l=this.patterns.get(t),d=Array.from(l.values()).map(({bin:w})=>w),{w:p,h:m}=u.H(d),g=this.atlasImage.get(t);g.resize({width:p||1,height:m||1});const x=this.images.get(t);for(const[w,{bin:S,position:A}]of l.entries()){let I=A.padding;const M=S.x+I,D=S.y+I,L=x.get(w).data,k=L.width,B=L.height;I=I>1?I-1:I,u.t.copy(L,g,{x:0,y:0},{x:M,y:D},{width:k,height:B},n),u.t.copy(L,g,{x:0,y:B-I},{x:M,y:D-I},{width:k,height:I},n),u.t.copy(L,g,{x:0,y:0},{x:M,y:D+B},{width:k,height:I},n),u.t.copy(L,g,{x:k-I,y:0},{x:M-I,y:D},{width:I,height:B},n),u.t.copy(L,g,{x:0,y:0},{x:M+k,y:D},{width:I,height:B},n),u.t.copy(L,g,{x:k-I,y:B-I},{x:M-I,y:D-I},{width:I,height:I},n),u.t.copy(L,g,{x:0,y:B-I},{x:M+k,y:D-I},{width:I,height:I},n),u.t.copy(L,g,{x:0,y:0},{x:M+k,y:D+B},{width:I,height:I},n),u.t.copy(L,g,{x:k-I,y:0},{x:M-I,y:D+B},{width:I,height:I},n)}this.dirty=!0}beginFrame(){for(const t of this.images.keys())this.callbackDispatchedThisFrame.set(t,new Set);this.imageAtlasCache.beginFrame()}dispatchRenderCallbacks(t,n){const l=this.images.get(n);for(const d of t){if(this.callbackDispatchedThisFrame.get(n).has(d.toString()))continue;this.callbackDispatchedThisFrame.get(n).add(d.toString());const p=l.get(d.toString());Aa(p)&&this.updateImage(d,n,p)}}}class ne{constructor(t,n,l,d){this.message=(t?`${t}: `:"")+l,d&&(this.identifier=d),n!=null&&n.__line__&&(this.line=n.__line__)}}class J extends ne{}function H(s){const t=s.value,n=s.valueSpec,l=s.style,d=s.styleSpec,p=s.key,m=s.arrayElementValidator||Pi;if(!Array.isArray(t))return[new ne(p,t,`array expected, ${u.M(t)} found`)];if(n.length&&t.length!==n.length)return[new ne(p,t,`array length ${n.length} expected, length ${t.length} found`)];if(n["min-length"]&&t.length<n["min-length"])return[new ne(p,t,`array length at least ${n["min-length"]} expected, length ${t.length} found`)];let g={type:n.value,values:n.values,minimum:n.minimum,maximum:n.maximum,function:void 0};d.$version<7&&(g.function=n.function),u.J(n.value)&&(g=n.value);let x=[];for(let w=0;w<t.length;w++)x=x.concat(m({array:t,arrayIndex:w,value:t[w],valueSpec:g,style:l,styleSpec:d,key:`${p}[${w}]`},!0));return x}function ve(s){const t=s.key,n=s.value,l=s.valueSpec;if(!u.N(n))return[new ne(t,n,`number expected, ${u.M(n)} found`)];if(n!=n)return[new ne(t,n,"number expected, NaN found")];if("minimum"in l){let d=l.minimum;if(Array.isArray(l.minimum)&&(d=l.minimum[s.arrayIndex]),n<d)return[new ne(t,n,`${n} is less than the minimum value ${d}`)]}if("maximum"in l){let d=l.maximum;if(Array.isArray(l.maximum)&&(d=l.maximum[s.arrayIndex]),n>d)return[new ne(t,n,`${n} is greater than the maximum value ${d}`)]}return[]}function Le(s){const t=s.key,n=s.value;if(!u.J(n))return[new ne(t,n,`object expected, ${u.M(n)} found`)];const l=s.valueSpec,d=u.K(n.type);let p,m,g,x={};const w=d!=="categorical"&&n.property===void 0,S=!w,A=(function(L){const k=L.stops;return Array.isArray(k)&&Array.isArray(k[0])&&u.J(k[0][0])})(n),I=Fr({key:s.key,value:s.value,valueSpec:s.styleSpec.function,style:s.style,styleSpec:s.styleSpec,objectElementValidators:{stops:function(L){if(d==="identity")return[new ne(L.key,L.value,'identity function may not have a "stops" property')];let k=[];const B=L.value;return k=k.concat(H({key:L.key,value:B,valueSpec:L.valueSpec,style:L.style,styleSpec:L.styleSpec,arrayElementValidator:M})),Array.isArray(B)&&B.length===0&&k.push(new ne(L.key,B,"array must have at least one stop")),k},default:function(L){return Pi({key:L.key,value:L.value,valueSpec:l,style:L.style,styleSpec:L.styleSpec})}}});return d==="identity"&&w&&I.push(new ne(s.key,s.value,'missing required property "property"')),d==="identity"||n.stops||I.push(new ne(s.key,s.value,'missing required property "stops"')),d==="exponential"&&l.expression&&!u.O(l)&&I.push(new ne(s.key,s.value,"exponential functions not supported")),s.styleSpec.$version>=8&&(S&&!u.Q(l)?I.push(new ne(s.key,s.value,"property functions not supported")):w&&!u.S(l)&&I.push(new ne(s.key,s.value,"zoom functions not supported"))),d!=="categorical"&&!A||n.property!==void 0||I.push(new ne(s.key,s.value,'"property" property is required')),I;function M(L){let k=[];const B=L.value,$=L.key;if(!Array.isArray(B))return[new ne($,B,`array expected, ${u.M(B)} found`)];if(B.length!==2)return[new ne($,B,`array length 2 expected, length ${B.length} found`)];if(A){if(!u.J(B[0]))return[new ne($,B,`object expected, ${u.M(B[0])} found`)];const Z=B[0];if(Z.zoom===void 0)return[new ne($,B,"object stop key must have zoom")];if(Z.value===void 0)return[new ne($,B,"object stop key must have value")];const G=u.K(Z.zoom);if(typeof G!="number")return[new ne($,Z.zoom,"stop zoom values must be numbers")];if(g&&g>G)return[new ne($,Z.zoom,"stop zoom values must appear in ascending order")];G!==g&&(g=G,m=void 0,x={}),k=k.concat(Fr({key:`${$}[0]`,value:B[0],valueSpec:{zoom:{}},style:L.style,styleSpec:L.styleSpec,objectElementValidators:{zoom:ve,value:D}}))}else k=k.concat(D({key:`${$}[0]`,value:B[0],style:L.style,styleSpec:L.styleSpec},B));return u.U(u.V(B[1]))?k.concat([new ne(`${$}[1]`,B[1],"expressions are not allowed in function stops.")]):k.concat(Pi({key:`${$}[1]`,value:B[1],valueSpec:l,style:L.style,styleSpec:L.styleSpec}))}function D(L,k){const B=u.M(L.value),$=u.K(L.value),Z=L.value!==null?L.value:k;if(p){if(B!==p)return[new ne(L.key,Z,`${B} stop domain type must match previous stop domain type ${p}`)]}else p=B;if(B!=="number"&&B!=="string"&&B!=="boolean"&&typeof $!="number"&&typeof $!="string"&&typeof $!="boolean")return[new ne(L.key,Z,"stop domain value must be a number, string, or boolean")];if(B!=="number"&&d!=="categorical"){let G=`number expected, ${B} found`;return u.Q(l)&&d===void 0&&(G+='\nIf you intended to use a categorical function, specify `"type": "categorical"`.'),[new ne(L.key,Z,G)]}return d!=="categorical"||B!=="number"||typeof $=="number"&&isFinite($)&&Math.floor($)===$?d!=="categorical"&&B==="number"&&typeof $=="number"&&typeof m=="number"&&m!==void 0&&$<m?[new ne(L.key,Z,"stop domain values must appear in ascending order")]:(m=$,d==="categorical"&&$ in x?[new ne(L.key,Z,"stop domain values must be unique")]:(x[$]=!0,[])):[new ne(L.key,Z,`integer expected, found ${String($)}`)]}}function Ee(s){const t=(s.expressionContext==="property"?u.W:u.n)(u.V(s.value),s.valueSpec);if(t.result==="error")return t.value.map(l=>new ne(`${s.key}${l.key}`,s.value,l.message));const n=t.value.expression||t.value._styleExpression.expression;if(s.expressionContext==="property"&&s.propertyKey==="text-font"&&!n.outputDefined())return[new ne(s.key,s.value,`Invalid data expression for "${s.propertyKey}". Output values must be contained as literals within the expression.`)];if(s.expressionContext==="property"&&s.propertyType==="layout"&&!u.Z(n))return[new ne(s.key,s.value,'"feature-state" data expressions are not supported with layout properties.')];if(s.expressionContext==="filter")return it(n,s);if(s.expressionContext==="appearance")return ht(n,s);if(s.expressionContext&&s.expressionContext.indexOf("cluster")===0){if(!u.X(n,["zoom","feature-state"]))return[new ne(s.key,s.value,'"zoom" and "feature-state" expressions are not supported with cluster properties.')];if(s.expressionContext==="cluster-initial"&&!u.Y(n))return[new ne(s.key,s.value,"Feature data expressions are not supported with initial expression part of cluster properties.")]}return[]}function it(s,t){const n=new Set(["zoom","feature-state","pitch","distance-from-center"]);if(t.valueSpec&&t.valueSpec.expression)for(const d of t.valueSpec.expression.parameters)n.delete(d);if(n.size===0)return[];const l=[];return s instanceof u._&&n.has(s.name)?[new ne(t.key,t.value,`["${s.name}"] expression is not supported in a filter for a ${t.object.type} layer with id: ${t.object.id}`)]:(s.eachChild(d=>{l.push(...it(d,t))}),l)}const et=new Set(["get","has","properties","geometry-type","id"]),Xt=new Set(["zoom","pitch","distance-from-center","feature","feature-state","measure-light","heatmap-density","line-progress","raster-value","raster-particle-speed","sky-radial-progress"]);function ht(s,t){if(t.valueSpec&&t.valueSpec.expression)for(const l of t.valueSpec.expression.parameters)Xt.delete(l);if(Xt.size===0)return[];const n=[];if(s instanceof u._){const l=et.has(s.name)?"feature":s.name;if(Xt.has(l))return[new ne(t.key,t.value,`["${s.name}"] is not an allowed parameter`)]}return s.eachChild(l=>{n.push(...ht(l,t))}),n}function Tt(s){const t=s.key,n=s.value,l=s.valueSpec,d=[];return Array.isArray(l.values)?l.values.includes(u.K(n))||d.push(new ne(t,n,`expected one of [${l.values.join(", ")}], ${JSON.stringify(n)} found`)):Object.keys(l.values).includes(u.K(n))||d.push(new ne(t,n,`expected one of [${Object.keys(l.values).join(", ")}], ${JSON.stringify(n)} found`)),d}function Yt(s){if(u.a1(u.V(s.value))){const t=s.layerType||"fill";return Ee({...s,expressionContext:"filter",valueSpec:s.styleSpec[`filter_${t}`]})}return yi(s)}function yi(s){const t=s.value,n=s.key;if(!Array.isArray(t))return[new ne(n,t,`array expected, ${u.M(t)} found`)];if(t.length<1)return[new ne(n,t,"filter array must have at least 1 element")];const l=s.styleSpec;let d=Tt({key:`${n}[0]`,value:t[0],valueSpec:l.filter_operator});const p=()=>{t.length>=2&&(u.a0(t[1])||d.push(new ne(`${n}[1]`,t[1],`string expected, ${u.M(t[1])} found`)));for(let m=2;m<t.length;m++)u.K(t[1])==="$type"?d=d.concat(Tt({key:`${n}[${m}]`,value:t[m],valueSpec:l.geometry_type})):u.a0(t[m])||u.N(t[m])||u.$(t[m])||d.push(new ne(`${n}[${m}]`,t[m],`string, number, or boolean expected, ${u.M(t[m])} found.`))};switch(u.K(t[0])){case"<":case"<=":case">":case">=":t.length>=2&&u.K(t[1])==="$type"&&d.push(new ne(n,t,`"$type" cannot be use with operator "${t[0]}"`)),t.length!==3&&d.push(new ne(n,t,`filter array for operator "${t[0]}" must have 3 elements`)),p();break;case"==":case"!=":t.length!==3&&d.push(new ne(n,t,`filter array for operator "${t[0]}" must have 3 elements`)),p();break;case"in":case"!in":p();break;case"any":case"all":case"none":for(let m=1;m<t.length;m++)d=d.concat(yi({key:`${n}[${m}]`,value:t[m],style:s.style,styleSpec:s.styleSpec}));break;case"has":case"!has":t.length!==2?d.push(new ne(n,t,`filter array for "${t[0]}" operator must have 2 elements`)):u.a0(t[1])||d.push(new ne(`${n}[1]`,t[1],`string expected, ${u.M(t[1])} found`))}return d}const nr=/^{([^}]+)}$/;function dr(s,t){const n=s.key,l=s.style,d=s.layer,p=s.styleSpec,m=s.value,g=s.objectKey,x=p[`${t}_${s.layerType}`];if(!x)return[];const w=g.match(u.a2);if(w&&x[w[1]])return u.U(u.V(m))?[].concat(Pi({key:n,value:m,valueSpec:{type:"string",expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"data-driven"},style:l,styleSpec:p,expressionContext:"property",propertyType:t,propertyKey:g})):Pi({key:n,value:m,valueSpec:{type:"string"},style:l,styleSpec:p});const S=g.match(u.a3);if(t==="paint"&&S&&x[S[1]]&&x[S[1]].transition)return Pi({key:n,value:m,valueSpec:p.transition,style:l,styleSpec:p});const A=s.valueSpec||x[g];if(!A)return[new J(n,m,`unknown property "${g}"`)];let I;if(u.a0(m)&&u.Q(A)&&!A.tokens&&(I=nr.exec(m))){const D=`\`{ "type": "identity", "property": ${I?JSON.stringify(I[1]):'"_"'} }\``;return[new ne(n,m,`"${g}" does not support interpolation syntax
8Use an identity property function instead: ${D}.`)]}const M=[];if(s.layerType==="symbol")g!=="text-field"||!l||l.glyphs||l.imports||M.push(new ne(n,m,'use of "text-field" requires a style "glyphs" property')),g==="text-font"&&u.a4(u.V(m))&&u.K(m.type)==="identity"&&M.push(new ne(n,m,'"text-font" does not support identity functions'));else if(s.layerType==="model"&&t==="paint"&&d&&d.layout&&Object.hasOwn(d.layout,"model-id")&&u.Q(A)&&(u.a5(A)||u.S(A))){const D=u.W(u.V(m),A).value,L="expression"in D&&D.expression||"_styleExpression"in D&&D._styleExpression&&D._styleExpression.expression;L&&!u.X(L,["measure-light"])&&(g==="model-emissive-strength"&&u.Y(L)&&u.Z(L)||M.push(new ne(n,m,`${g} does not support measure-light expressions when the model layer source is vector tile or GeoJSON.`)))}return M.concat(Pi({key:s.key,value:m,valueSpec:A,style:l,styleSpec:p,expressionContext:"property",propertyType:t,propertyKey:g}))}function jr(s){return dr(s,"paint")}function fr(s){return dr(s,"layout")}function Gr(s){let t=[];const n=s.value,l=s.key,d=s.style,p=s.styleSpec;if(!u.J(n))return[new ne(l,n,"object expected")];n.type||n.ref||t.push(new ne(l,n,'either "type" or "ref" is required'));let m=u.K(n.type);const g=u.K(n.ref);if(n.id){const x=u.K(n.id);for(let w=0;w<s.arrayIndex;w++){const S=d.layers[w];u.K(S.id)===x&&t.push(new ne(l,n.id,`duplicate layer id "${x}", previously used at line ${S.id.__line__}`))}}if("ref"in n){let x;["type","source","source-layer","filter","layout"].forEach(w=>{w in n&&t.push(new ne(l,n[w],`"${w}" is prohibited for ref layers`))}),d.layers.forEach(w=>{u.K(w.id)===g&&(x=w)}),x?x.ref?t.push(new ne(l,n.ref,"ref cannot reference another ref layer")):m=u.K(x.type):typeof g=="string"&&t.push(new ne(l,n.ref,`ref layer "${g}" not found`))}else if(m!=="background"&&m!=="sky"&&m!=="slot")if(n.source)if(u.a0(n.source)){const x=d.sources&&Object.hasOwn(d.sources,n.source)?d.sources[n.source]:void 0,w=x&&u.K(x.type);x?w==="vector"&&m==="raster"?t.push(new ne(l,n.source,`layer "${n.id}" requires a raster source`)):w==="raster"&&m!=="raster"?t.push(new ne(l,n.source,`layer "${n.id}" requires a vector source`)):w!=="vector"||n["source-layer"]?w==="raster-dem"&&m!=="hillshade"?t.push(new ne(l,n.source,"raster-dem source can only be used with layer type 'hillshade'.")):w!=="raster-array"||["raster","raster-particle"].includes(m)?m==="line"&&n.paint&&n.paint["line-gradient"]&&w==="geojson"&&!x.lineMetrics?t.push(new ne(l,n,`layer "${n.id}" specifies a line-gradient, which requires the GeoJSON source to have \`lineMetrics\` enabled.`)):m==="line"&&n.paint&&n.paint["line-trim-offset"]&&w==="geojson"&&!x.lineMetrics?t.push(new ne(l,n,`layer "${n.id}" specifies a line-trim-offset, which requires the GeoJSON source to have \`lineMetrics\` enabled.`)):m==="raster-particle"&&w!=="raster-array"&&t.push(new ne(l,n.source,`layer "${n.id}" requires a 'raster-array' source.`)):t.push(new ne(l,n.source,"raster-array source can only be used with layer type 'raster'.")):t.push(new ne(l,n,`layer "${n.id}" must specify a "source-layer"`)):t.push(new ne(l,n.source,`source "${n.source}" not found`))}else t.push(new ne(`${l}.source`,n.source,'"source" must be a string'));else t.push(new ne(l,n,'missing required property "source"'));return t=t.concat(Fr({key:l,value:n,valueSpec:p.layer,style:s.style,styleSpec:s.styleSpec,objectElementValidators:{"*":()=>[],type:()=>Pi({key:`${l}.type`,value:n.type,valueSpec:p.layer.type,style:s.style,styleSpec:s.styleSpec,object:n,objectKey:"type"}),filter:x=>Yt({layerType:m,...x}),layout:x=>Fr({layer:n,key:x.key,value:x.value,valueSpec:{},style:x.style,styleSpec:x.styleSpec,objectElementValidators:{"*":w=>fr({layerType:m,...w})}}),paint:x=>Fr({layer:n,key:x.key,value:x.value,valueSpec:{},style:x.style,styleSpec:x.styleSpec,objectElementValidators:{"*":w=>jr({layerType:m,layer:n,...w})}}),appearances(x){const w=H({key:x.key,value:x.value,valueSpec:x.valueSpec,style:x.style,styleSpec:x.styleSpec,arrayElementValidator:I=>(function(M){const{key:D,layer:L,layerType:k}=M,B=u.K(M.value),$=u.K(B.name),Z=u.K(B.condition),G=Fr({key:D,value:B,valueSpec:M.styleSpec.appearance,style:M.style,styleSpec:M.styleSpec,objectElementValidators:{condition:te=>(function(ee){const le=[];return le.push(...Ee({key:ee.key,value:ee.object.condition,valueSpec:u.m.appearance.condition,expressionContext:"appearance"})),le})({...te}),properties:te=>(function(ee){const le=[],{styleSpec:K,layer:Q,layerType:ae}=ee,de=K[`paint_${ae}`],fe=K[`layout_${ae}`],be=ee.object[ee.objectKey];for(const Te in be){const Ve=Te in de?"paint":Te in fe?"layout":void 0;if(!Ve){le.push(new ne(ee.key,Te,`unknown property "${Te}" for layer type "${ae}"`));continue}const ye={...ee,key:`${ee.key}.${Te}`,objectKey:Te,layer:Q,layerType:ae,value:be[Te],valueSpec:Ve==="paint"?de[Te]:fe[Te]};le.push(...dr(ye,Ve))}return le})({layer:L,layerType:k,...te})}});return $!=="hidden"&&Z===void 0&&G.push(new ne(M.key,"name",'Appearance with name different than "hidden" must have a condition')),G})({layerType:m,layer:n,...I})}),S=Array.isArray(x.value)?x.value:[],A=new Set;return S.forEach((I,M)=>{const D=u.K(I.name);if(D)if(A.has(D)){const L=u.K(n.id);w.push(new ne(x.key,D,`Duplicated appearance name "${D}" for layer "${L}"`))}else A.add(D)}),w}}})),t}function Vn({key:s,value:t}){return u.a0(t)?[]:[new ne(s,t,`string expected, ${u.M(t)} found`)]}const rs={promoteId:function s({key:t,value:n}){if(u.a0(n))return Vn({key:t,value:n});if(Array.isArray(n)){const d=[],p=u.V(n),m=u.n(p);return m.result==="error"?(m.value.forEach(g=>{d.push(new ne(`${t}${g.key}`,null,`${g.message}`))}),d):(u.X(m.value.expression,["zoom","heatmap-density","line-progress","raster-value","sky-radial-progress","accumulated","is-supported-script","pitch","distance-from-center","measure-light","raster-particle-speed"])||d.push(new ne(`${t}`,null,"promoteId expression should be only feature dependent")),d)}if(!u.J(n))return[new ne(t,n,`string, expression or object expected, "${u.M(n)}" found`)];const l=[];for(const d in n)l.push(...s({key:`${t}.${d}`,value:n[d]}));return l}};function Ki(s){const t=s.value,n=s.key,l=s.styleSpec,d=s.style;if(!u.J(t))return[new ne(n,t,`object expected, ${u.M(t)} found`)];if(!("type"in t))return[new ne(n,t,'"type" is required')];const p=u.K(t.type);let m=[];switch(["vector","raster","raster-dem","raster-array"].includes(p)&&("url"in t||"tiles"in t||m.push(new J(n,t,'Either "url" or "tiles" is required.'))),p){case"vector":case"raster":case"raster-dem":case"raster-array":return m=m.concat(Fr({key:n,value:t,valueSpec:l[`source_${p.replace("-","_")}`],style:s.style,styleSpec:l,objectElementValidators:rs})),m;case"geojson":if(m=Fr({key:n,value:t,valueSpec:l.source_geojson,style:d,styleSpec:l,objectElementValidators:rs}),"cluster"in t&&"clusterProperties"in t){if(!u.J(t.clusterProperties))return[new ne(`${n}.clusterProperties`,t,`object expected, ${u.M(t)} found`)];for(const g in t.clusterProperties){const x=t.clusterProperties[g];if(!Array.isArray(x))return[new ne(`${n}.clusterProperties.${g}`,x,"array expected")];const[w,S]=x,A=typeof w=="string"?[w,["accumulated"],["get",g]]:w;m.push(...Ee({key:`${n}.${g}.map`,value:S,expressionContext:"cluster-map"})),m.push(...Ee({key:`${n}.${g}.reduce`,value:A,expressionContext:"cluster-reduce"}))}}return m;case"video":return Fr({key:n,value:t,valueSpec:l.source_video,style:d,styleSpec:l});case"image":return Fr({key:n,value:t,valueSpec:l.source_image,style:d,styleSpec:l});case"canvas":return[new ne(n,null,"Please use runtime APIs to add canvas sources, rather than including them in stylesheets.","source.canvas")];default:return Tt({key:`${n}.type`,value:t.type,valueSpec:{values:Ji(l)}})}}function Ji(s){return s.source.reduce((t,n)=>{const l=s[n];return l.type.type==="enum"&&(t=t.concat(Object.keys(l.type.values||{}))),t},[])}function or(s,t){const n=!s.includes("://");try{return new URL(s,n&&t?"http://example.com":void 0),!0}catch{return!1}}function Gi(s){const t=s.value;return t?u.a0(t)?or(t,!0)?[]:[new ne(s.key,t,`invalid url "${t}"`)]:[new ne(s.key,t,`string expected, "${u.M(t)}" found`)]:[]}function xr(s){const t=s.value,n=s.styleSpec,l=n.light,d=s.style;if(t===void 0)return[];if(!u.J(t))return[new ne("light",t,`object expected, ${u.M(t)} found`)];let p=[];for(const m in t){const g=m.match(u.a3),x=m.match(u.a2);p=p.concat(x&&l[x[1]]?Pi({key:m,value:t[m],valueSpec:{type:"string"},style:d,styleSpec:n}):g&&l[g[1]]&&l[g[1]].transition?Pi({key:m,value:t[m],valueSpec:n.transition,style:d,styleSpec:n}):l[m]?Pi({key:m,value:t[m],valueSpec:l[m],style:d,styleSpec:n}):[new ne(m,t[m],`unknown property "${m}"`)])}return p}function _r(s){const t=s.value;if(!t)return[];const n=s.key;if(!u.J(t))return[new ne(n,t,`object expected, ${u.M(t)} found`)];let l=[];const d=s.styleSpec,p=d["light-3d"],m=s.style,g=s.style.lights;for(const S of["type","id"])if(!(S in t))return l=l.concat([new ne(n,t,`missing property "${S}"`)]),l;if(!u.a0(t.type))return l=l.concat([new ne(`${n}.type`,t.type,"string expected")]),l;if(g)for(let S=0;S<s.arrayIndex;S++){const A=u.K(t.type),I=g[S];u.K(I.type)===A&&l.push(new ne(n,t.id,`duplicate light type "${t.type}", previously defined at line ${I.id.__line__}`))}const x=`properties_light_${t.type}`;if(!(x in d))return l=l.concat([new ne(`${n}.type`,t,`Invalid light type ${t.type}`)]),l;const w=d[x];for(const S in t)if(S==="properties"){const A=t[S];if(!u.J(A))return l=l.concat([new ne("properties",A,`object expected, ${u.M(A)} found`)]),l;for(const I in A){const M=I.match(u.a3),D=I.match(u.a2);l=l.concat(D&&w[D[1]]?Pi({key:S,value:A[I],valueSpec:{type:"string"},style:m,styleSpec:d}):M&&w[M[1]]&&w[M[1]].transition?Pi({key:S,value:t[S],valueSpec:d.transition,style:m,styleSpec:d}):w[I]?Pi({key:I,value:A[I],valueSpec:w[I],style:m,styleSpec:d}):[new J(s.key,A[I],`unknown property "${I}"`)])}}else l=l.concat(p[S]?Pi({key:S,value:t[S],valueSpec:p[S],style:m,styleSpec:d}):[new J(S,t[S],`unknown property "${S}"`)]);return l}function pn(s){const t=s.value,n=s.key,l=s.style,d=s.styleSpec,p=d.terrain;if(t==null)return[];if(!u.J(t))return[new ne("terrain",t,`object expected, ${u.M(t)} found`)];let m=[];for(const g in t){const x=g.match(u.a3),w=g.match(u.a2);m=m.concat(w&&p[w[1]]?Pi({key:g,value:t[g],valueSpec:{type:"string"},style:l,styleSpec:d}):x&&p[x[1]]&&p[x[1]].transition?Pi({key:g,value:t[g],valueSpec:d.transition,style:l,styleSpec:d}):p[g]?Pi({key:g,value:t[g],valueSpec:p[g],style:l,styleSpec:d}):[new J(g,t[g],`unknown property "${g}"`)])}if(t.source)if(u.a0(t.source)){const g=l.sources&&Object.hasOwn(l.sources,t.source)?l.sources[t.source]:void 0,x=g&&u.K(g.type);g?x!=="raster-dem"&&m.push(new ne(`${n}.source`,t.source,`terrain cannot be used with a source of type ${x}, it only be used with a "raster-dem" source type`)):m.push(new ne(`${n}.source`,t.source,`source "${t.source}" not found`))}else m.push(new ne(`${n}.source`,t.source,"source must be a string"));else m.push(new ne(n,t,'terrain is missing required property "source"'));return m}function bi(s){const t=s.value,n=s.style,l=s.styleSpec,d=l.fog;if(t===void 0)return[];if(!u.J(t))return[new ne("fog",t,`object expected, ${u.M(t)} found`)];let p=[];for(const m in t){const g=m.match(u.a3),x=m.match(u.a2);p=p.concat(x&&d[x[1]]?Pi({key:m,value:t[m],valueSpec:{type:"string"},style:n,styleSpec:l}):g&&d[g[1]]&&d[g[1]].transition?Pi({key:m,value:t[m],valueSpec:l.transition,style:n,styleSpec:l}):d[m]?Pi({key:m,value:t[m],valueSpec:d[m],style:n,styleSpec:l}):[new J(m,t[m],`unknown property "${m}"`)])}return p}const Do={"*":()=>[],array:H,boolean:function(s){const t=s.value,n=s.key;return u.$(t)?[]:[new ne(n,t,`boolean expected, ${u.M(t)} found`)]},number:ve,color:function({key:s,value:t}){return u.a0(t)?u.C.parse(u.K(t))===void 0?[new ne(s,t,`color expected, "${t}" found`)]:[]:[new ne(s,t,`color expected, ${u.M(t)} found`)]},enum:Tt,filter:Yt,function:Le,layer:Gr,object:Fr,source:Ki,model:Gi,light:xr,"light-3d":_r,terrain:pn,fog:bi,string:Vn,formatted:function(s){return Vn(s).length===0?[]:Ee(s)},resolvedImage:function(s){return Vn(s).length===0?[]:Ee(s)},projection:function(s){const t=s.value,n=s.styleSpec,l=n.projection,d=s.style;if(u.J(t)){let p=[];for(const m in t)p=p.concat(Pi({key:m,value:t[m],valueSpec:l[m],style:d,styleSpec:n}));return p}return u.a0(t)?[]:[new ne("projection",t,`object or string expected, ${u.M(t)} found`)]},import:function(s){const t=s.key,{value:n,styleSpec:l}=s;if(!u.J(n))return[new ne(t,n,"import must be an object")];const{data:d,...p}=n;Object.defineProperty(p,"__line__",{value:n.__line__,enumerable:!1});let m=Fr({...s,value:p,valueSpec:l.import});u.K(p.id)===""&&m.push(new ne(`${s.key}.id`,p,"import id can't be an empty string"));const g=u.K(p.id);return g!=="__proto__"&&g!=="constructor"&&g!=="prototype"||m.push(new ne(`${s.key}.id`,p,`import id can't be "${String(g)}"`)),d&&(m=m.concat(tn(d,l,{key:`${s.key}.data`}))),m},iconset:function(s){const t=s.value,n=s.key,l=s.styleSpec,d=s.style;if(!u.J(t))return[new ne(n,t,"object expected")];if(!t.type)return[new ne(n,t,'"type" is required')];const p=u.K(t.type);let m=[];if(m=m.concat(Fr({key:n,value:t,valueSpec:l[`iconset_${p}`],style:d,styleSpec:l})),(function(g,x){return!(g!=="source"||!x.source)})(p,t)){const g=d.sources&&Object.hasOwn(d.sources,t.source)?d.sources[t.source]:void 0,x=g&&u.K(g.type);g?x!=="raster-array"&&m.push(new ne(n,t.source,`iconset cannot be used with a source of type ${String(x)}, it only be used with a "raster-array" source type`)):m.push(new ne(n,t.source,`source "${t.source}" not found`))}return m},option:function(s){const t=s.styleSpec,n=s.value,l=u.J(n)&&u.K(n.array)===!0||!u.J(n)?void 0:u.K(n.type);return Fr({...s,valueSpec:t.option,objectElementValidators:l?{default:d=>Array.isArray(d.value)?Pi({...d,valueSpec:{...d.valueSpec,type:l}}):Pi(d)}:void 0})}};function Pi(s,t=!1){const n=s.value,l=s.valueSpec,d=s.styleSpec;if(l.expression){if(u.a4(u.K(n)))return Le(s);if(u.U(u.V(n)))return Ee(s)}if(l.type&&Do[l.type]){const p=Do[l.type](s);return t===!0&&p.length>0&&Array.isArray(s.value)?Ee(s):p}return Fr({...s,valueSpec:l.type?d[l.type]:l})}function Fr(s){const t=s.key,n=s.value,l=s.valueSpec||{},d=s.objectElementValidators||{},p=s.style,m=s.styleSpec;if(!u.J(n))return[new ne(t,n,`object expected, ${u.M(n)} found`)];let g=[];for(const x in n){if(!Object.hasOwn(n,x))continue;const w=x.split(".")[0],S=Object.hasOwn(l,w),A=Object.hasOwn(l,"*"),I=S?l[w]:A?l["*"]:void 0;let M;Object.hasOwn(d,w)?M=d[w]:S?M=Pi:Object.hasOwn(d,"*")?M=d["*"]:A&&(M=Pi),M?g=g.concat(M({key:(t&&`${t}.`)+x,value:n[x],valueSpec:I,style:p,styleSpec:m,object:n,objectKey:x},n)):g.push(new J(t,n[x],`unknown property "${x}"`))}for(const x in l){if(!Object.hasOwn(l,x)||Object.hasOwn(d,x))continue;const w=l[x];!w.required||w.default!==void 0||Object.hasOwn(n,x)&&n[x]!==void 0||g.push(new ne(t,n,`missing required property "${x}"`))}return g}function Ts({key:s,value:t}){const n=Vn({key:s,value:t});if(n.length)return n;const l=t;return l.includes("{fontstack}")||n.push(new ne(s,t,'"glyphs" url must include a "{fontstack}" token')),l.includes("{range}")||n.push(new ne(s,t,'"glyphs" url must include a "{range}" token')),n}function tn(s,t=u.m,n={}){return Fr({key:n.key||"",value:s,valueSpec:{...t.$root,"*":{type:"*"}},styleSpec:t,style:s,objectElementValidators:{glyphs:Ts}})}function Or(s,t=u.m){return Un(tn(s,t))}const ll=s=>Un(Ki(s)),Uc=s=>Un(xr(s)),Qp=s=>Un(_r(s)),em=s=>Un(pn(s)),tm=s=>Un(bi(s)),Od=s=>Un((function(t){const n=t.value,l=t.style,d=t.styleSpec,p=d.snow;if(n===void 0)return[];if(!u.J(n))return[new ne("snow",n,`object expected, ${u.M(n)} found`)];let m=[];for(const g in n){const x=g.match(u.a3);m=m.concat(x&&p[x[1]]&&p[x[1]].transition?Pi({key:g,value:n[g],valueSpec:d.transition,style:l,styleSpec:d}):p[g]?Pi({key:g,value:n[g],valueSpec:p[g],style:l,styleSpec:d}):[new J(g,n[g],`unknown property "${g}"`)])}return m})(s)),im=s=>Un((function(t){const n=t.value,l=t.style,d=t.styleSpec,p=d.rain;if(n===void 0)return[];if(!u.J(n))return[new ne("rain",n,`object expected, ${u.M(n)} found`)];let m=[];for(const g in n){const x=g.match(u.a3);m=m.concat(x&&p[x[1]]&&p[x[1]].transition?Pi({key:g,value:n[g],valueSpec:d.transition,style:l,styleSpec:d}):p[g]?Pi({key:g,value:n[g],valueSpec:p[g],style:l,styleSpec:d}):[new J(g,n[g],`unknown property "${g}
8"`)])}return m})(s)),rm=s=>Un(Gr(s)),jc=s=>Un(Yt(s)),nm=s=>Un(jr(s)),la=s=>Un(fr(s)),om=s=>Un(Gi(s));function Un(s){return s.slice().sort((t,n)=>t.line&&n.line?t.line-n.line:0)}function cl(s,t){let n=!1;if(t&&t.length)for(const l of t)l instanceof J?u.w(l.message):(s.fire(new u.A(new Error(l.message))),n=!0);return n}const Wl=u.m.light;let kd;class ul extends u.E{constructor(t,n="flat"){super(),this._transitionable=new u.a6(kd||(kd=new u.a7({anchor:new u.a8(Wl.anchor),position:new u.a9(Wl.position),color:new u.a8(Wl.color),intensity:new u.a8(Wl.intensity)}))),this.setLight(t,n),this._transitioning=this._transitionable.untransitioned()}getLight(){return this._transitionable.serialize()}setLight(t,n,l={}){this._validate(Uc,t,l)||(this._transitionable.setTransitionOrValue(t),this.id=n)}updateTransitions(t){this._transitioning=this._transitionable.transitioned(t,this._transitioning)}hasTransition(){return this._transitioning.hasTransition()}recalculate(t){this.properties=this._transitioning.possiblyEvaluate(t)}_validate(t,n,l){return(!l||l.validate!==!1)&&cl(this,t.call(Or,{value:n,style:{glyphs:!0,sprite:!0},styleSpec:u.m}))}}const Gc=u.m.terrain;let sm=class extends u.E{constructor(s,t,n,l,d){super(),this.scope=n,this._transitionable=new u.a6(new u.a7({source:new u.a8(Gc.source),exaggeration:new u.a8(Gc.exaggeration)}),n,l),this._transitionable.setTransitionOrValue(s,l),this._transitioning=this._transitionable.untransitioned(),this.drapeRenderMode=t,this.worldview=d}get(){return this._transitionable.serialize()}set(s,t){this._transitionable.setTransitionOrValue(s,t)}updateTransitions(s){this._transitioning=this._transitionable.transitioned(s,this._transitioning)}hasTransition(){return this._transitioning.hasTransition()}recalculate(s){this.properties=this._transitioning.possiblyEvaluate(s)}getExaggeration(s){return this._transitioning.possiblyEvaluate(new u.aa(s,{worldview:this.worldview})).get("exaggeration")}getAttenuationRange(){if(!this.isZoomDependent())return null;const s=this._transitionable._values.exaggeration;if(!s)return null;const t=s.value.expression;if(!t)return null;let n=-1,l=-1,d=1;for(const p of t.zoomStops)d=t.evaluate(new u.aa(p,{worldview:this.worldview})),d>.01?(n=p,l=-1):l=p;return d<.01&&n>0&&l>n?[n,l]:null}isZoomDependent(){const s=this._transitionable._values.exaggeration;return s!=null&&s.value!=null&&s.value.expression!=null&&s.value.expression instanceof u.ab}};function Xl(s,t){const n=s?s.terrain:null;return!!n&&(!t||!!t.projection.requiresDraping||!n.isZoomDependent()||n.getExaggeration(t.zoom)>0)}const hl=.05;function Xu(s,t,n){const l=u.af(45,65,n),[d,p]=s.range;let m=1-Math.min(1,Math.exp((t-d)/(p-d)*-6));return m*=m*m,m=Math.min(1,1.00747*m),m*l*s.alpha}function Bd(s,t,n,l,d){const p=u.ad([],[t,n,l],d.mercatorFogMatrix);return Xu(s,u.ae(p),d.pitch)}function $c(s,t,n,l,d,p,m){const g=[[n,l,0],[d,l,0],[d,p,0],[n,p,0]];let x=Number.MAX_VALUE,w=-Number.MAX_VALUE;for(const S of g){const A=u.ad([],S,t),I=u.ae(A);x=Math.min(x,I),w=Math.max(w,I)}return[Xu(s,x,m.pitch),Xu(s,w,m.pitch)]}const Gs=u.m.fog;class Yl extends u.E{constructor(t,n,l,d){super();const p=new u.a7({range:new u.a8(Gs.range),color:new u.a8(Gs.color),"color-use-theme":new u.a8({type:"string","property-type":"data-constant",default:"default"}),"high-color":new u.a8(Gs["high-color"]),"high-color-use-theme":new u.a8({type:"string","property-type":"data-constant",default:"default"}),"space-color":new u.a8(Gs["space-color"]),"space-color-use-theme":new u.a8({type:"string","property-type":"data-constant",default:"default"}),"horizon-blend":new u.a8(Gs["horizon-blend"]),"star-intensity":new u.a8(Gs["star-intensity"]),"vertical-range":new u.a8(Gs["vertical-range"])});this._transitionable=new u.a6(p,l,d),this.set(t,d),this._transitioning=this._transitionable.untransitioned(),this._transform=n,this.properties=new u.ag(p),this.scope=l}get state(){const t=this._transform,n=t.projection.name==="globe",l=u.ah(t.zoom),d=this.properties.get("range"),p=[2,4.5],m=.5/Math.tan(.5*t._fov),g=[d[0]+m,d[1]+m];return{range:n?[u.ai(p[0],g[0],l),u.ai(p[1],g[1],l)]:g,horizonBlend:this.properties.get("horizon-blend"),alpha:this.properties.get("color").a}}get(){return this._transitionable.serialize()}set(t,n,l={}
vendor: 10,843 bytes, line 8
8){if(this._validate(tm,t,l))return;const d={...t};for(const p of Object.keys(Gs))d[p]===void 0&&(d[p]=Gs[p].default);this._options=d,this._transitionable.setTransitionOrValue(this._options,n)}getOpacity(t){if(!this._transform.projection.supportsFog)return 0;const n=this.properties&&this.properties.get("color")||1;return(this._transform.projection.name==="globe"?1:u.af(45,65,t))*n.a}getOpacityAtLatLng(t,n){return this._transform.projection.supportsFog?(function(l,d,p){const m=u.ac.fromLngLat(d),g=p.elevation?p.elevation.getAtPointOrZero(m):0;return Bd(l,m.x,m.y,g,p)})(this.state,t,n):0}getOpacityForTile(t){if(!this._transform.projection.supportsFog)return[1,1];const n=this._transform.calculateFogTileMatrix(t.toUnwrapped());return $c(this.state,n,0,0,u.aj,u.aj,this._transform)}getOpacityForBounds(t,n,l,d,p){return this._transform.projection.supportsFog?$c(this.state,t,n,l,d,p,this._transform):[1,1]}getRangeForProjection(){return this._transform.projection.supportsFog?this.state.range:[0,1]}isVisibleOnFrustum(t){if(!this._transform.projection.supportsFog)return!1;const n=[4,5,6,7];for(const l of n){const d=t.points[l];let p;if(d[2]>=0)p=d;else{const m=t.points[l-4];p=u.ak(m,d,m[2]/(m[2]-d[2]))}if(Bd(this.state,p[0],p[1],0,this._transform)>=hl)return!0}return!1}updateConfig(t){this._transitionable.setTransitionOrValue(this._options,t)}updateTransitions(t){this._transitioning=this._transitionable.transitioned(t,this._transitioning)}hasTransition(){return this._transitioning.hasTransition()}recalculate(t){this.properties=this._transitioning.possiblyEvaluate(t)}_validate(t,n,l){return(!l||l.validate!==!1)&&cl(this,t.call(Or,{value:n,style:{glyphs:!0,sprite:!0},styleSpec:u.m}))}}let am,Kl,Yu=class extends u.E{constructor(s,t,n,l){super();const d=am||(am=new u.a7({density:new u.a8(u.m.snow.density),intensity:new u.a8(u.m.snow.intensity),color:new u.a8(u.m.snow.color),opacity:new u.a8(u.m.snow.opacity),vignette:new u.a8(u.m.snow.vignette),"vignette-color":new u.a8(u.m.snow["vignette-color"]),"center-thinning":new u.a8(u.m.snow["center-thinning"]),direction:new u.a8(u.m.snow.direction),"flake-size":new u.a8(u.m.snow["flake-size"])}));this._transitionable=new u.a6(d,n,l),this.set(s,l),this._transitioning=this._transitionable.untransitioned(),this.properties=new u.ag(d),this.scope=n}get state(){const s=this.properties.get("opacity"),t=this.properties.get("color"),n=this.properties.get("direction"),l=u.al(n[0]),d=-Math.max(u.al(n[1]),.01),p=[Math.cos(l)*Math.cos(d),Math.sin(l)*Math.cos(d),Math.sin(d)],m=this.properties.get("vignette"),g=this.properties.get("vignette-color"),x=new u.C(g.r,g.g,g.b,m);return{density:this.properties.get("density"),intensity:this.properties.get("intensity"),color:new u.C(t.r,t.g,t.b,t.a*s),direction:p,centerThinning:this.properties.get("center-thinning"),flakeSize:this.properties.get("flake-size"),vignetteColor:x}}get(){return this._transitionable.serialize()}set(s,t,n={}){if(this._validate(Od,s,n))return;const l={...s},d=u.m.snow;for(const p of Object.keys(d))l[p]===void 0&&(l[p]=d[p].default);this._options=l,this._transitionable.setTransitionOrValue(this._options,t)}updateConfig(s){this._transitionable.setTransitionOrValue(this._options,s)}updateTransitions(s){this._transitioning=this._transitionable.transitioned(s,this._transitioning)}hasTransition(){return this._transitioning.hasTransition()}recalculate(s){this.properties=this._transitioning.possiblyEvaluate(s)}_validate(s,t,n){return(!n||n.validate!==!1)&&cl(this,s.call(Or,{value:t,style:{glyphs:!0,sprite:!0},styleSpec:u.m}))}},Ku=class extends u.E{constructor(s,t,n,l){super();const d=Kl||(Kl=new u.a7({density:new u.a8(u.m.rain.density),intensity:new u.a8(u.m.rain.intensity),color:new u.a8(u.m.rain.color),opacity:new u.a8(u.m.rain.opacity),vignette:new u.a8(u.m.rain.vignette),"vignette-color":new u.a8(u.m.rain["vignette-color"]),"center-thinning":new u.a8(u.m.rain["center-thinning"]),direction:new u.a8(u.m.rain.direction),"droplet-size":new u.a8(u.m.rain["droplet-size"]),"distortion-strength":new u.a8(u.m.rain["distortion-strength"])}));this._transitionable=new u.a6(d,n,l),this.set(s,l),this._transitioning=this._transitionable.untransitioned(),this.properties=new u.ag(d),this.scope=n}get state(){const s=this.properties.get("opacity"),t=this.properties.get("color"),n=this.properties.get("direction"),l=u.al(n[0]),d=-Math.max(u.al(n[1]),.01),p=[Math.cos(l)*Math.cos(d),Math.sin(l)*Math.cos(d),Math.sin(d)],m=this.properties.get("vignette-color"),g=new u.C(m.r,m.g,m.b,this.properties.get("vignette"));return{density:this.properties.get("density"),intensity:this.properties.get("intensity"),color:new u.C(t.r,t.g,t.b,t.a*s),direction:p,centerThinning:this.properties.get("center-thinning"),dropletSize:this.properties.get("droplet-size"),distortionStrength:this.properties.get("distortion-strength"),vignetteColor:g}}get(){return this._transitionable.serialize()}set(s,t,n={}){if(this._validate(im,s,n))return;const l={...s},d=u.m.rain;for(const p of Object.keys(d))l[p]===void 0&&(l[p]=d[p].default);this._options=l,this._transitionable.setTransitionOrValue(this._options,t)}updateConfig(s){this._transitionable.setTransitionOrValue(this._options,s)}updateTransitions(s){this._transitioning=this._transitionable.transitioned(s,this._transitioning)}hasTransition(){return this._transitioning.hasTransition()}recalculate(s){this.properties=this._transitioning.possiblyEvaluate(s)}_validate(s,t,n){return(!n||n.validate!==!1)&&cl(this,s.call(Or,{value:t,style:{glyphs:!0,sprite:!0},styleSpec:u.m}))}};const Lo={workerUrl:"",workerClass:null,workerParams:void 0};function Nd(s){return Lo.workerClass!=null?new Lo.workerClass:new self.Worker(Lo.workerUrl,{name:s,type:"module",...Lo.workerParams})}const Ju="mapboxgl_preloaded_worker_pool";class ca{constructor(t){this.active={},this.name=t}acquire(t,n=ca.workerCount){if(!this.workers)for(this.workers=[];this.workers.length<n;){const l=Nd(`${this.name||""}WorkerPool: ${t}-${this.workers.length}`);this.workers.push(l)}return this.active[t]=!0,this.workers.slice()}release(t){delete this.active[t],this.workers&&this.numActive()===0&&(this.workers.forEach(n=>{n.terminate()}),this.workers=null)}isPreloaded(){return!!this.active[Ju]}numActive(){return Object.keys(this.active).length}}ca.workerCount=2;class dl{constructor(t,n,l="Worker",d=ca.workerCount){this.workerPool=t,this.actors=[],this.currentActor=0,this.id=u.am();const p=this.workerPool.acquire(this.id,d);for(let m=0;m<p.length;m++){const g=new dl.Actor(p[m],n,this.id);g.name=`${l} ${m}`,this.actors.push(g)}this.ready=!1,this.send("checkIfReady",null).then(()=>{this.ready=!0}).catch(()=>{})}send(t,n,l){return Promise.all(this.actors.map(d=>d.send(t,n,l)))}broadcast(t,n){for(const l of this.actors)l.notify(t,n)}getActor(){return this.currentActor=(this.currentActor+1)%this.actors.length,this.actors[this.currentActor]}remove(){this.actors.forEach(t=>{t.remove()}),this.actors=[],this.workerPool.release(this.id)}}dl.Actor=u.an;class po extends u.E{constructor(t,n,l,d){super(),this.scope=l,this._options=t,this.properties=new u.ag(n),this._transitionable=new u.a6(n,l,d),this._transitionable.setTransitionOrValue(t.properties),this._transitioning=this._transitionable.untransitioned()}updateConfig(t){this._transitionable.setTransitionOrValue(this._options.properties,t)}updateTransitions(t){this._transitioning=this._transitionable.transitioned(t,this._transitioning)}hasTransition(){return this._transitioning.hasTransition()}recalculate(t){this.properties=this._transitioning.possiblyEvaluate(t)}get(){return this._options.properties=this._transitionable.serialize(),this._options}set(t,n){this._options=t,this._transitionable.setTransitionOrValue(t.properties,n)}shadowsEnabled(){return!!this.properties&&this.properties.get("cast-shadows")===!0}}let Vd;const Ud=()=>Vd||(Vd=new u.a7({color:new u.a8(u.m.properties_light_ambient.color),"color-use-theme":new u.a8({type:"string",default:"default","property-type":"data-constant"}),intensity:new u.a8(u.m.properties_light_ambient.intensity)}));let lm;const vt=()=>lm||(lm=new u.a7({direction:new u.ao(u.m.properties_light_directional.direction),color:new u.a8(u.m.properties_light_directional.color),"color-use-theme":new u.a8({type:"string",default:"default","property-type":"data-constant"}),intensity:new u.a8(u.m.properties_light_directional.intensity),"cast-shadows":new u.a8(u.m.properties_light_directional["cast-shadows"]),"shadow-quality":new u.a8(u.m.properties_light_directional["shadow-quality"]),"shadow-intensity":new u.a8(u.m.properties_light_directional["shadow-intensity"]),"shadow-draw-before-layer":new u.a8(u.m.properties_light_directional["shadow-draw-before-layer"])})),cm=(s,t,n,l,d,p,m,g,x,w=[0,0,1])=>({u_matrix:s,u_normal_matrix:t,u_opacity:n,u_faux_facade_ao_intensity:l,u_camera_pos:d,u_tile_to_meter:p,u_facade_emissive_chance:m,u_flood_light_color:g,u_flood_light_intensity:x,u_front_cutoff_params:w}),ai=s=>({u_matrix:s}),um=s=>({u_matrix:s}),jd=1029,Gd=2305;class _t{constructor(t,n,l){this.enable=t,this.mode=n,this.frontFace=l}}_t.disabled=new _t(!1,jd,Gd),_t.backCCW=new _t(!0,jd,Gd),_t.backCW=new _t(!0,jd,2304),_t.frontCW=new _t(!0,1028,2304),_t.frontCCW=new _t(!0,1028,Gd);class ct{constructor(t,n,l){this.func=t,this.mask=n,this.range=l}}ct.ReadOnly=!1,ct.ReadWrite=!0,ct.disabled=new ct(519,ct.ReadOnly,[0,1]);class zo{constructor(t=0,n=0,l=0,d=0){if(isNaN(t)||t<0||isNaN(n)||n<0||isNaN(l)||l<0||isNaN(d)||d<0)throw new Error("Invalid value for edge-insets, top, bottom, left and right must all be numbers");this.top=t,this.bottom=n,this.left=l,this.right=d}interpolate(t,n,l){return n.top!=null&&t.top!=null&&(this.top=u.ai(t.top,n.top,l)),n.bottom!=null&&t.bottom!=null&&(this.bottom=u.ai(t.bottom,n.bottom,l)),n.left!=null&&t.left!=null&&(this.left=u.ai(t.left,n.left,l)),n.right!=null&&t.right!=null&&(this.right=u.ai(t.right,n.right,l)),this}getCenter(t,n){const l=u.as((this.left+t-this.right)/2,0,t),d=u.as((this.top+n-this.bottom)/2,0,n);return new u.P(l,d)}equals(t){return this.top===t.top&&this.bottom===t.bottom&&this.left===t.left&&this.right===t.right}clone(){return new zo(this.top,this.bottom,this.left,this.right)}toJSON(){return{top:this.top,bottom:this.bottom,left:this.left,right:this.right}}}function Qu(s,t){const n=u.aD(s,3);u.aI(s,t),u.aN(s,3,n)}function Ra(s,t){const n=u.az([]);return u.aA(n,n,-t),u.aB(n,n,-s),n}function ft(s,t){const n=[s[0],s[1],0],l=[t[0],t[1],0];if(u.ae(n)>=1e-15){const m=u.au([],n);u.av(l,m,u.aw(l,m)),t[0]=l[0],t[1]=l[1]}const d=u.ax([],t,s);if(u.ay(d)<1e-15)return null;const p=Math.atan2(-d[1],d[0]);return Ra(Math.atan2(Math.sqrt(s[0]*s[0]+s[1]*s[1]),-s[2]),p)}class fi{constructor(t,n){this.position=t,this.orientation=n}get position(){return this._position}set position(t){if(t){const n=t instanceof u.ac?t:new u.ac(t[0],t[1],t[2]);
8this._renderWorldCopies&&(n.x=u.at(n.x,0,1)),this._position=n}else this._position=null}lookAtPoint(t,n,l){if(this.orientation=null,!this.position)return;const d=this.position,p=l||(this._elevation?this._elevation.getAtPointOrZero(u.ac.fromLngLat(t)):0),m=u.ac.fromLngLat(t,p),g=[m.x-d.x,m.y-d.y,m.z-d.z];n||(n=[0,0,1]),n[2]=Math.abs(n[2]),this.orientation=ft(g,n)}setPitchBearing(t,n){this.orientation=Ra(u.al(t),u.al(-n))}}class ci{constructor(t,n){this._transform=u.aC([]),this.orientation=n,this.position=t}get mercatorPosition(){const t=this.position;return new u.ac(t[0],t[1],t[2])}get position(){const t=u.aD(this._transform,3);return[t[0],t[1],t[2]]}set position(t){var n;t&&u.aN(this._transform,3,[(n=t)[0],n[1],n[2],1])}get orientation(){return this._orientation}set orientation(t){this._orientation=t||u.az([]),t&&Qu(this._transform,this._orientation)}getPitchBearing(){const t=this.forward(),n=this.right();return{bearing:Math.atan2(-n[1],n[0]),pitch:Math.atan2(Math.sqrt(t[0]*t[0]+t[1]*t[1]),-t[2])}}setPitchBearing(t,n){this._orientation=Ra(t,n),Qu(this._transform,this._orientation)}forward(){const t=u.aD(this._transform,2);return[-t[0],-t[1],-t[2]]}up(){const t=u.aD(this._transform,1);return[-t[0],-t[1],-t[2]]}right(){const t=u.aD(this._transform,0);return[t[0],t[1],t[2]]}getCameraToWorld(t,n){const l=new Float64Array(16);return u.aE(l,this.getWorldToCamera(t,n)),l}getCameraToWorldMercator(){return this._transform}getWorldToCameraPosition(t,n,l){const d=this.position;u.av(d,d,-t);const p=new Float64Array(16);return u.aF(p,[l,l,l]),u.aG(p,p,d),p[10]*=n,p}getWorldToCamera(t,n){const l=new Float64Array(16),d=new Float64Array(4),p=this.position;return u.aH(d,this._orientation),u.av(p,p,-t),u.aI(l,d),u.aG(l,l,p),l[1]*=-1,l[5]*=-1,l[9]*=-1,l[13]*=-1,l[8]*=n,l[9]*=n,l[10]*=n,l[11]*=n,l}getCameraToClipPerspective(t,n,l,d){const p=new Float64Array(16);return u.aJ(p,t,n,l,d),p}getCameraToClipOrthographic(t,n,l,d,p,m){const g=new Float64Array(16);return u.aK(g,t,n,l,d,p,m),g}getDistanceToElevation(t,n=!1){const l=t===0?0:u.aL(t,n?u.aM(this.position[1]):this.position[1]),d=this.forward();return(l-this.position[2])/d[2]}clone(){return new ci([...this.position],[...this.orientation])}}const no=Math.tan(85*Math.PI/180);function $s(s,t,n,l,d,p,m){const g=u.aS();if(n)if(p.name==="globe"){const x=u.aT(d,t);u.aP(g,g,x)}else{const x=u.aU([],m);g[0]=x[0],g[1]=x[1],g[4]=x[2],g[5]=x[3],l||u.aR(g,g,d.angle)}else u.aP(g,d.labelPlaneMatrix,s);return g}function pi(s,t,n,l,d,p,m){const g=$s(s,t,n,l,d,p,m);return p.name==="globe"&&n||(g[2]=g[6]=g[10]=g[14]=0),g}function Jl(s,t,n,l,d,p,m){if(n){if(p.name==="globe"){const g=$s(s,t,n,l,d,p,m);return u.aE(g,g),u.aP(g,s,g),g}{const g=u.aQ(s),[x,w,S,A]=m,[I,M,D,L,k,B,$,Z]=g;return g[0]=x*I+w*k,g[1]=x*M+w*B,g[2]=x*D+w*$,g[3]=x*L+w*Z,g[4]=S*I+A*k,g[5]=S*M+A*B,g[6]=S*D+A*$,g[7]=S*L+A*Z,l||u.aR(g,g,-d.angle),g}}return d.glCoordMatrix}function oo(s,t,n,l){const d=[s,t,n,1];n?u.aO(d,d,l):Fo(d,d,l);const p=d[3];return d[0]/=p,d[1]/=p,d[2]/=p,d}function Ql(s,t){return Math.min(.5+s/t*.5,1.5)}function Fn(s,t){const n=s[0]/s[3],l=s[1]/s[3];return n>=-t[0]&&n<=t[0]&&l>=-t[1]&&l<=t[1]}function wr(s,t,n,l,d,p,m,g,x,w,S=1){const A=n.transform,I=l?s.textSizeData:s.iconSizeData,M=u.aZ(I,n.transform.zoom,S),D=A.projection.name==="globe",L=(()=>{if(!D)return null;const K=u.ah(A.zoom);return K===0?null:{t:K,invMatrix:A.projection.createInversionMatrix(A,w.canonical),mercCenter:[u.a_(A.center.lng),u.a$(A.center.lat)]}})(),k=[256/n.width*2+1,256/n.height*2+1],B=l?s.text.dynamicLayoutVertexArray:s.icon.dynamicLayoutVertexArray;B.clear();let $=null;D&&($=l?s.text.globeExtVertexArray:s.icon.globeExtVertexArray);const Z=s.lineVertexArray,G=l?s.text.placedSymbolArray:s.icon.placedSymbolArray,te=n.transform.width/n.transform.height;let ee,le=!1;for(let K=0;K<G.length;K++){const Q=G.get(K),{numGlyphs:ae,writingMode:de}=Q;if(de!==u.b0.vertical||le||ee===u.b0.horizontal||(le=!0),ee=de,(Q.hidden||de===u.b0.vertical)&&!le){rn(ae,B);continue}le=!1;const fe=new u.P(Q.tileAnchorX,Q.tileAnchorY),be=s.elevationType==="road",Te=!!A.elevation||be;let{x:Ve,y:ye,z:Ae}=A.projection.projectTilePoint(fe.x,fe.y,w.canonical);if(L){const[bt,pt,Lt]=tc(fe,w.canonical,L);
vendor: 12,032 bytes, line 8
8Ve+=(bt-Ve)*L.t,ye+=(pt-ye)*L.t,Ae+=(Lt-Ae)*L.t}let ge=null;if(Te){ge=be&&s.hdExt?s.hdExt.makeRoadSymbolElevationParams(s,l?s.text:s.icon,K,w,x,A.elevation,A.projection,A.center.lat,A.worldSize):{getElevation:x,elevation:A.elevation,elevationFeature:null};const[bt,pt,Lt]=ge.getElevation(fe,A.elevation,ge.elevationFeature);Ve+=bt,ye+=pt,Ae+=Lt}const Fe=[Ve,ye,Ae,1];if(u.aO(Fe,Fe,t),!Fn(Fe,k)){rn(ae,B);continue}const Re=Fe[3],De=Ql(n.transform.getCameraToCenterDistance(A.projection),Re),Ke=u.b1(I,M,Q),Be=m?Ke/De:Ke*De,Ge=oo(Ve,ye,Ae,d);if(Ge[3]<=0){rn(ae,B);continue}let Ze={};const tt=u.al(s.layers[0].layout.get("text-max-angle")),ot=Math.cos(tt),at=m?null:ge,ut=eh(Q,Be,!1,g,t,d,p,s.glyphOffsetArray,Z,B,$,Ge,fe,Ze,te,at,A.projection,w,m,ot,L);le=ut.useVertical,at&&ut.needsFlipping&&(Ze={}),(ut.notEnoughRoom||le||ut.needsFlipping&&eh(Q,Be,!0,g,t,d,p,s.glyphOffsetArray,Z,B,$,Ge,fe,Ze,te,at,A.projection,w,m,ot,L).notEnoughRoom)&&rn(ae,B)}l?(s.text.dynamicLayoutVertexBuffer.updateData(B),$&&s.text.globeExtVertexBuffer&&s.text.globeExtVertexBuffer.updateData($)):(s.icon.dynamicLayoutVertexBuffer.updateData(B),$&&s.icon.globeExtVertexBuffer&&s.icon.globeExtVertexBuffer.updateData($))}function hm(s,t,n,l,d,p,m,g,x,w,S,A,I,M,D,L,k,B){const{lineStartIndex:$,glyphStartIndex:Z,segment:G}=g,te=Z+g.numGlyphs,ee=$+g.lineLength,le=t.getoffsetX(Z),K=t.getoffsetX(te-1),Q=fl(s*le,n,l,d,p,m,G,$,ee,x,w,S,A,I,!0,M,D,L,k,B);if(!Q)return null;const ae=fl(s*K,n,l,d,p,m,G,$,ee,x,w,S,A,I,!0,M,D,L,k,B);return ae?{first:Q,last:ae}:null}function ec(s,t,n,l){return s===u.b0.horizontal&&Math.abs(l)>Math.abs(n)?{useVertical:!0}:s===u.b0.vertical?l>0?{needsFlipping:!0}:null:t!==0&&(function(d,p){return d===0||Math.abs(p/d)>no})(n,l)?t===1?{needsFlipping:!0}:null:n<0?{needsFlipping:!0}:null}function eh(s,t,n,l,d,p,m,g,x,w,S,A,I,M,D,L,k,B,$,Z,G){const te=t/24,ee=s.lineOffsetX*te,le=s.lineOffsetY*te,{lineStartIndex:K,glyphStartIndex:Q,numGlyphs:ae,segment:de,writingMode:fe,flipState:be}=s,Te=K+s.lineLength,Ve=ye=>{if(S){const[Re,De,Ke]=ye.up,Be=w.length;u.b2(S,Be+0,Re,De,Ke),u.b2(S,Be+1,Re,De,Ke),u.b2(S,Be+2,Re,De,Ke),u.b2(S,Be+3,Re,De,Ke)}const[Ae,ge,Fe]=ye.point;u.b3(w,Ae,ge,Fe,ye.angle)};if(ae>1){const ye=hm(te,g,ee,le,n,A,I,s,x,p,M,L,!1,k,B,$,Z,G);if(!ye)return{notEnoughRoom:!0};if(l&&!n){let[Ae,ge,Fe]=ye.first.point,[Re,De,Ke]=ye.last.point;[Ae,ge]=oo(Ae,ge,Fe,m),[Re,De]=oo(Re,De,Ke,m);const Be=ec(fe,be,(Re-Ae)*D,De-ge);if(s.flipState=Be&&Be.needsFlipping?1:2,Be)return Be}Ve(ye.first);for(let Ae=Q+1;Ae<Q+ae-1;Ae++){const ge=fl(te*g.getoffsetX(Ae),ee,le,n,A,I,de,K,Te,x,p,M,L,!1,!1,k,B,$,Z,G);if(!ge)return w.length-=4*(Ae-Q),{notEnoughRoom:!0};Ve(ge)}Ve(ye.last)}else{if(l&&!n){const Ae=oo(I.x,I.y,0,d),ge=K+de+1,Fe=new u.P(x.getx(ge),x.gety(ge)),Re=oo(Fe.x,Fe.y,0,d),De=Re[3]>0?Re:th(I,Fe,Ae,1,d,void 0,k,B.canonical),Ke=ec(fe,be,(De[0]-Ae[0])*D,De[1]-Ae[1]);if(s.flipState=Ke&&Ke.needsFlipping?1:2,Ke)return Ke}const ye=fl(te*g.getoffsetX(Q),ee,le,n,A,I,de,K,Te,x,p,M,L,!1,!1,k,B,$,Z,G);if(!ye)return{notEnoughRoom:!0};Ve(ye)}return{}}function tc(s,t,n){const l=1<<t.z;let d=(s.x/u.aj+t.x)/l-n.mercCenter[0];const p=(s.y/u.aj+t.y)/l-n.mercCenter[1];d-=Math.round(d);const m=[d*u.aj,p*u.aj,u.aj/(2*Math.PI),1];return u.aO(m,m,n.invMatrix),[m[0],m[1],m[2]]}function qc(s,t,n,l,d,p){let{x:m,y:g,z:x}=l.projectTilePoint(s.x,s.y,t);if(p){const[I,M,D]=tc(s,t,p);m+=(I-m)*p.t,g+=(M-g)*p.t,x+=(D-x)*p.t}if(!d)return oo(m,g,x,n);const[w,S,A]=d.getElevation(s,d.elevation,d.elevationFeature);return oo(m+w,g+S,x+A,n)}function th(s,t,n,l,d,p,m,g,x){const w=qc(s.sub(t)._unit()._add(s),g,d,m,p,x);return u.aW(w,n,w),u.au(w,w),u.aY(w,n,w,l)}function fl(s,t,n,l,d,p,m,g,x,w,S,A,I,M,D,L,k,B,$,Z){const G=l?s-t:s+t;let te=G>0?1:-1,ee=0;l&&(te*=-1,ee=Math.PI),te<0&&(ee+=Math.PI);let le=g+m+(te>0?0:1)|0,K=d,Q=d,ae=0,de=0;const fe=Math.abs(G),be=[],Te=[];let Ve=p,ye=Ve,Ae=u.aV([]);const ge=()=>th(ye,Ve,Q,fe-ae+1,S,I,L,k.canonical,Z);for(;ae+de<=fe;){if(le+=te,le<g||le>=x)return null;if(Q=K,ye=Ve,be.push(Q),M&&Te.push(ye),Ve=new u.P(w.getx(le),w.gety(le)),K=A[le],!K){const at=qc(Ve,k.canonical,S,L,I,Z);K=at[3]>0?A[le]=at:ge()}ae+=de;const tt=u.aW([],K,Q),ot=u.aX(Q,K);if(n&&ot>0&&de>0&&u.aw(Ae,tt)/(de*ot)<$)return null;de=ot,Ae=tt}D&&I&&(A[le]&&(K=ge(),de=u.aX(Q,K),Ae=u.aW([],K,Q)),A[le]=K);const Fe=(fe-ae)/de,Re=Ve.sub(ye)._mult(Fe)._add(ye),De=u.aY([],Q,Ae,Fe);let Ke=[0,0,1],Be=Ae[0],Ge=Ae[1];if(B&&(Ke=L.upVector(k.canonical,Re.x,Re.y),Ke[0]!==0||Ke[1]!==0||Ke[2]!==1)){const tt=[Ke[2],0,-Ke[0]],ot=u.ax([],Ke,tt);u.au(tt,tt),u.au(ot,ot),Be=u.aw(Ae,tt),Ge=u.aw(Ae,ot)}if(n){const tt=u.ax([],Ke,Ae);u.au(tt,tt),u.aY(De,De,tt,n*te)}const Ze=ee+Math.atan2(Ge,Be);return be.push(De),M&&Te.push(Re),{point:De,angle:Ze,path:be,tilePath:Te,up:Ke}}function rn(s,t){const n=t.length,l=n+4*s;t.resize(l),t.float32.fill(-1/0,4*n,4*l)}function Fo(s,t,n){const l=t[0],d=t[1];return s[0]=n[0]*l+n[4]*d+n[12],s[1]=n[1]*l+n[5]*d+n[13],s[3]=n[3]*l+n[7]*d+n[15],s}const nn=15;class ih{constructor(t,n,l,d,p,m,g){this.tileSize=512,this._renderWorldCopies=p===void 0||p,this._minZoom=t||0,this._maxZoom=n||22,this._minPitch=l??0,this._maxPitch=d??60,this.setProjection(m),this.setMaxBounds(g),this.width=0,this.height=0,this._center=new u.b4(0,0),this.zoom=0,this.angle=0,this._fov=.6435011087932844,this._pitch=0,this._nearZ=0,this._farZ=0,this._nearClipOffset=0,this._unmodified=!0,this._edgeInsets=new zo,this._projMatrixCache={},this._alignedProjMatrixCache={},this._fogTileMatrixCache={},this._expandedProjMatrixCache={},this._distanceTileDataCache={},this._camera=new ci,this._centerAltitude=0,this._averageElevation=0,this.cameraElevationReference="ground",this._pixelsPerMercatorPixel=1,this.globeRadius=0,this.globeCenterInViewSpace=[0,0,0],this._tileCoverLift=0,this.freezeTileCoverage=!1,this._horizonShift=.1,this._orthographicProjectionAtLowPitch=!1,this._allowWorldUnderZoom=!1,this.mercatorMatrix=new Float64Array(16),this.mercatorFogMatrix=new Float32Array(16),this.invProjMatrix=new Float64Array(16),this._expandedFarZProjMatrixBuf=new Float64Array(16),this.expandedFarZProjMatrix=this._expandedFarZProjMatrixBuf,this.starsProjMatrix=new Float32Array(16),this.skyboxMatrix=new Float32Array(16),this._mat4Scratch=new Float64Array(16),this.alignedProjMatrix=new Float64Array(16),this.labelPlaneMatrix=new Float32Array(16),this.glCoordMatrix=new Float32Array(16),this.pixelMatrix=new Float64Array(16),this.pixelMatrixInverse=new Float64Array(16)}clone(){const t=new ih(this._minZoom,this._maxZoom,this._minPitch,this.maxPitch,this._renderWorldCopies,this.getProjection(),this.maxBounds);return t._elevation=this._elevation,t._centerAltitude=this._centerAltitude,t._centerAltitudeValidForExaggeration=this._centerAltitudeValidForExaggeration,t.tileSize=this.tileSize,t.mercatorFromTransition=this.mercatorFromTransition,t.width=this.width,t.height=this.height,t.cameraElevationReference=this.cameraElevationReference,t._center=this._center,t._setZoom(this.zoom),t._seaLevelZoom=this._seaLevelZoom,t.angle=this.angle,t._fov=this._fov,t._pitch=this._pitch,t._nearZ=this._nearZ,t._farZ=this._farZ,t._nearClipOffset=this._nearClipOffset,t._averageElevation=this._averageElevation,t._orthographicProjectionAtLowPitch=this._orthographicProjectionAtLowPitch,t._unmodified=this._unmodified,t._edgeInsets=this._edgeInsets.clone(),t._camera=this._camera.clone(),t._calcMatrices(),t.freezeTileCoverage=this.freezeTileCoverage,t.frustumCorners=this.frustumCorners,t._allowWorldUnderZoom=this._allowWorldUnderZoom,t}get isOrthographic(){return this.projection.name!=="globe"&&this._orthographicProjectionAtLowPitch&&this.pitch<nn}get elevation(){return this._elevation}set elevation(t){this._elevation!==t&&(this._elevation=t,this._updateCameraOnTerrain(),this._calcMatrices())}get nearClipOffset(){return this._nearClipOffset}set nearClipOffset(t){this._nearClipOffset=t,this._calcMatrices()}get depthOcclusionForSymbolsAndCircles(){return this.projection.name!=="globe"&&!this.isOrthographic}updateElevation(t,n=!1){const l=this._elevation&&this._elevation.exaggeration()!==this._centerAltitudeValidForExaggeration;(this._seaLevelZoom==null||l)&&this._updateCameraOnTerrain(),(t||l)&&this._constrainCamera(n),this._calcMatrices()}getProjection(){return u.b5(this.projection,["name","center","parallels"])}setProjection(t){this.projectionOptions=t||{name:"mercator"};const n=this.projection?this.getProjection():void 0;this.projection=u.b6(this.projectionOptions);const l=this.getProjection(),d=!u.b7(n,l);return d&&this._calcMatrices(),this.mercatorFromTransition=!1,d}setOrthographicProjectionAtLowPitch(t){return this._orthographicProjectionAtLowPitch!==t&&(this._orthographicProjectionAtLowPitch=t,this._calcMatrices(),!0)}setMercatorFromTransition(){const t=this.projection.name;this.mercatorFromTransition=!0,this.projectionOptions={name:"mercator"},this.projection=u.b6({name:"mercator"});const n=t!==this.projection.name;return n&&this._calcMatrices(),n}get minZoom(){return this._minZoom}set minZoom(t){this._minZoom!==t&&(this._minZoom=t,this.zoom=Math.max(this.zoom,t))}get maxZoom(){return this._maxZoom}set maxZoom(t){this._maxZoom!==t&&(this._maxZoom=t,this.zoom=Math.min(this.zoom,t))}get minPitch(){return this._minPitch}set minPitch(t){this._minPitch!==t&&(this._minPitch=t,this.pitch=Math.max(this.pitch,t))}get maxPitch(){return this._maxPitch}set maxPitch(t){this._maxPitch!==t&&(this._maxPitch=t,this.pitch=Math.min(this.pitch,t))}get renderWorldCopies(){return this._renderWorldCopies&&this.projection.supportsWorldCopies===!0}set renderWorldCopies(t){t===void 0?t=!0:t===null&&(t=!1),this._renderWorldCopies=t}get worldSize(){return this.tileSize*this.scale}get cameraWorldSizeForFog(){const t=Math.max(this._camera.getDistanceToElevation(this._averageElevation),Number.EPSILON);return this._worldSizeFromZoom(this._zoomFromMercatorZ(t))}get cameraWorldSize(){const t=Math.max(this._camera.getDistanceToElevation(this._averageElevation,!0),Number.EPSILON);return this._worldSizeFromZoom(this._zoomFromMercatorZ(t))}get pixelsPerMeter(){return this.projection.pixelsPerMeter(this.center.lat,this.worldSize)}get cameraPixelsPerMeter(){return u.aL(1,this.center.lat)*this.cameraWorldSizeForFog}get centerOffset(){return this.centerPoint._sub(this.size._div(2))}get size(){return new u.P(this.width,this.height)}get bearing(){return u.at(this.rotation,-180,180)}set bearing(t){this.rotation=t}get rotation(){return-this.angle/Math.PI*180}set rotation(t){const n=-t*Math.PI/180;if(this.angle===n)return;this._unmodified=!1,this.angle=n,this._calcMatrices();const l=Math.sin(this.angle),d=Math.cos(this.angle);this.rotationMatrix=[d,l,-l,d]}get pitch(){return this._pitch/Math.PI*180}set pitch(t){const n=u.as(t,this.minPitch,this.maxPitch)/180*Math.PI;this._pitch!==n&&(this._unmodified=!1,this._pitch=n,this._calcMatrices())}get aspect(){return this.width/this.height}get fov(){return this._fov/Math.PI*180}set fov(t){t=Math.max(.01,Math.min(60,t)),this._fov!==t&&(this._unmodified=!1,this._fov=u.al(t),this._calcMatrices())}get fovX(){return this._fov}get fovY(){const t=1/Math.tan(.5*this.fovX);return 2*Math.atan(1/this.aspect/t)}get averageElevation(){return this._averageElevation}set averageElevation(t){this._averageElevation=t,this._calcFogMatrices(),this._distanceTileDataCache={}}get zoom(){return this._zoom}set zoom(t){const n=Math.min(Math.max(t,this.minZoom),this.maxZoom);this._zoom!==n&&(this._unmodified=!1,this._setZoom(n),this._updateSeaLevelZoom(),this._constrain(),this._calcMatrices())}_setZoom(t){this._zoom=t,this.scale=this.zoomScale(t),this.tileZoom=Math.floor(t),this.zoomFraction=t-this.tileZoom}get tileCoverLift(){return this._tileCoverLift}set tileCoverLift(t){this._tileCoverLift!==t&&(this._tileCoverLift=t)}_updateCameraOnTerrain(){const t=this.elevation?this.elevation.getAtPoint(this.locationCoordinate(this.center),Number.NEGATIVE_INFINITY):Number.NEGATIVE_INFINITY,n=this.elevation&&t===Number.NEGATIVE_INFINITY&&this.elevation.visibleDemTiles.length>0&&this.elevation.exaggeration()>
80&&this._centerAltitudeValidForExaggeration;if(!this._elevation||t===Number.NEGATIVE_INFINITY&&(!n||!this._centerAltitude))return this._centerAltitude=0,this._seaLevelZoom=null,void(this._centerAltitudeValidForExaggeration=void 0);const l=this._elevation;n||this._centerAltitude&&this._centerAltitudeValidForExaggeration&&l.exaggeration()&&this._centerAltitudeValidForExaggeration!==l.exaggeration()?(this._centerAltitude=this._centerAltitude/this._centerAltitudeValidForExaggeration*l.exaggeration(),this._centerAltitudeValidForExaggeration=l.exaggeration()):(this._centerAltitude=t||0,this._centerAltitudeValidForExaggeration=l.exaggeration()),this._updateSeaLevelZoom()}_updateSeaLevelZoom(){if(this._centerAltitudeValidForExaggeration===void 0)return;const t=Math.max(0,(this.pixelsPerMeter*this._centerAltitude+this.cameraToCenterDistance)/this.worldSize);this._seaLevelZoom=this._zoomFromMercatorZ(t)}sampleAverageElevation(){if(!this._elevation)return 0;const t=this._elevation,n=[[.5,.2],[.3,.5],[.5,.5],[.7,.5],[.5,.8]],l=this.horizonLineFromTop();let d=0,p=0;for(let m=0;m<n.length;m++){const g=new u.P(n[m][0]*this.width,l+n[m][1]*(this.height-l)),x=t.pointCoordinate(g);if(!x)continue;const w=1/Math.hypot(x[0]-this._camera.position[0],x[1]-this._camera.position[1]);d+=x[3]*w,p+=w}return p===0?NaN:d/p}get center(){return this._center}set center(t){t.lat===this._center.lat&&t.lng===this._center.lng||(this._unmodified=!1,this._center=t,this._terrainEnabled()&&(this.cameraElevationReference==="ground"?this._updateCameraOnTerrain():this._updateZoomFromElevation()),this._constrain(),this._calcMatrices())}_updateZoomFromElevation(){if(this._seaLevelZoom==null||!this._elevation)return;const t=this._seaLevelZoom,n=this._elevation.getAtPointOrZero(this.locationCoordinate(this.center)),l=this.pixelsPerMeter/this.worldSize*n,d=this._mercatorZfromZoom(t),p=this._mercatorZfromZoom(this._maxZoom),m=Math.max(d-l,p);this._setZoom(this._zoomFromMercatorZ(m))}get padding(){return this._edgeInsets.toJSON()}set padding(t){this._edgeInsets.equals(t)||(this._unmodified=!1,this._edgeInsets.interpolate(this._edgeInsets,t,1),this._calcMatrices())}equals(t){const n=this.elevation,l=t.elevation,d=n!=null!=(l!=null)||n&&l&&n.exaggeration()!==l.exaggeration();return this.width===t.width&&this.height===t.height&&this.center.lng===t.center.lng&&this.center.lat===t.center.lat&&this.zoom===t.zoom&&this.bearing===t.bearing&&this.pitch===t.pitch&&this.fov===t.fov&&this.projection.name===t.projection.name&&this._edgeInsets.equals(t.padding)&&!d}computeZoomRelativeTo(t){const n=this.rayIntersectionCoordinate(this.pointRayIntersection(this.centerPoint,t.toAltitude()));let l;l=t.z<this._camera.position[2]?[n.x,n.y,n.z]:[t.x,t.y,t.z];const d=u.ae(u.aW([],this._camera.position,l));return u.as(this._zoomFromMercatorZ(d),this._minZoom,this._maxZoom)}setFreeCameraOptions(t){if(!this.height||!t.position&&!t.orientation)return;this._updateCameraState();let n=!1;if(t.orientation&&!u.b8(t.orientation,this._camera.orientation)&&(n=this._setCameraOrientation(t.orientation)),t.position){const l=[t.position.x,t.position.y,t.position.z];u.b9(l,this._camera.position)||(this._setCameraPosition(l),n=!0)}n&&(this._updateStateFromCamera(),this.recenterOnTerrain())}getFreeCameraOptions(){this._updateCameraState();const t=this._camera.position,n=new fi;return n.position=new u.ac(t[0],t[1],t[2]),n.orientation=this._camera.orientation,n._elevation=this.elevation,n._renderWorldCopies=this.renderWorldCopies,n}_setCameraOrientation(t){if(!u.ba(t))return!1;u.bb(t,t);const n=u.bc([],[0,0,-1],t),l=u.bc([],[0,-1,0],t);if(l[2]<0)return!1;const d=ft(n,l);return!!d&&(this._camera.orientation=d,!0)}_setCameraPosition(t){const n=this.zoomScale(this.minZoom)*this.tileSize,l=this.zoomScale(this.maxZoom)*this.tileSize,d=this.cameraToCenterDistance;t[2]=u.as(t[2],d/l,d/n),this._camera.position=t}get centerPoint(){return this._edgeInsets.getCenter(this.width,this.height)}get fovAboveCenter(){return this._fov*(.5+this.centerOffset.y/this.height)}isPaddingEqual(t){return this._edgeInsets.equals(t)}interpolatePadding(t,n,l){this._unmodified=!1,this._edgeInsets.interpolate(t,n,l),this._constrain(),this._calcMatrices()}coveringZoomLevel(t){const n=(t.roundZoom?Math.round:Math.floor)(this.zoom+this.scaleZoom(this.tileSize/t.tileSize));return Math.max(0,n)}getVisibleUnwrappedCoordinates(t){const n=[new u.bd(0,t)];if(this.renderWorldCopies){const l=this.pointCoordinate(new u.P(0,0)),d=this.pointCoordinate(new u.P(this.width,0)),p=this.pointCoordinate(new u.P(this.width,this.height)),m=this.pointCoordinate(new u.P(0,this.height)),g=Math.floor(Math.min(l.x,d.x,p.x,m.x)),x=Math.floor(Math.max(l.x,d.x,p.x,m.x)),w=1;for(let S=g-w;S<=x+w;S++)S!==0&&n.push(new u.bd(S,t))}return n}isLODDisabled(t){return(!t||this.pitch<=60)&&this._edgeInsets.top<=this._edgeInsets.bottom&&!this._elevation&&!this.projection.isReprojectedInTileSpace}extendTileCover(t,n,l,d){let p=[];const m=l!=null,g=!m;if(g&&this.zoom<n||m&&l[0]===0&&l[1]===0)return p;const x=new Set,w=(A,I,M,D,L)=>{const k=u.bq(I,A,M,D,L);x.has(k)||(p.push(new u.br(A,I,M,D,L)),x.add(k))};for(let A=0;A<t.length;A++){const I=t[A];
8if(g&&I.canonical.z!==n||m&&d!==void 0&&d>I.canonical.z)continue;const M=I.canonical,D=I.overscaledZ,L=I.wrap,k=1<<M.z,B=M.x+1<k,$=M.x>0,Z=M.y+1<k,G=M.y>0,te=I.wrap-($?0:1),ee=I.wrap+(B?0:1),le=$?M.x-1:k-1,K=B?M.x+1:0;if(m)l[0]<0?(w(D,ee,M.z,K,M.y),l[1]<0&&Z&&(w(D,L,M.z,M.x,M.y+1),w(D,ee,M.z,K,M.y+1)),l[1]>0&&G&&(w(D,L,M.z,M.x,M.y-1),w(D,ee,M.z,K,M.y-1))):l[0]>0?(w(D,te,M.z,le,M.y),l[1]<0&&Z&&(w(D,L,M.z,M.x,M.y+1),w(D,te,M.z,le,M.y+1)),l[1]>0&&G&&(w(D,L,M.z,M.x,M.y-1),w(D,te,M.z,le,M.y-1))):l[1]<0&&Z?w(D,L,M.z,M.x,M.y+1):G&&w(D,L,M.z,M.x,M.y-1);else{const Q=I.visibleQuadrants;1&Q&&(w(D,te,M.z,le,M.y),G&&(w(D,L,M.z,M.x,M.y-1),w(D,te,M.z,le,M.y-1))),2&Q&&(w(D,ee,M.z,K,M.y),G&&(w(D,L,M.z,M.x,M.y-1),w(D,ee,M.z,K,M.y-1))),4&Q&&(w(D,te,M.z,le,M.y),Z&&(w(D,L,M.z,M.x,M.y+1),w(D,te,M.z,le,M.y+1))),8&Q&&(w(D,ee,M.z,K,M.y),Z&&(w(D,L,M.z,M.x,M.y+1),w(D,ee,M.z,K,M.y+1)))}}const S=[];for(const A of p)p.some(I=>A.isChildOf(I))||S.push(A);if(p=S.filter(A=>!t.some(I=>!!(A.overscaledZ<n&&I.isChildOf(A))||A.equals(I)||A.isChildOf(I))),g){const A=1<<n,I=this.projection.name==="globe"?this._camera.mercatorPosition:this.pointCoordinate(this.getCameraPoint()),M=[A*I.x,A*I.y],D=4,L=D*D;p=p.filter(k=>{const B=k.canonical.x+.5-M[0],$=k.canonical.y+.5-M[1];return B*B+$*$<L})}return p}extendTileCoverToNearPlane(t,n,l){const d=[],p=new Set;for(const $ of t)p.add($.key);const m=($,Z,G,te,ee)=>{const le=u.bq(Z,$,G,te,ee);p.has(le)||(d.push(new u.br($,Z,G,te,ee)),p.add(le))},g=t.reduce(($,Z)=>Math.max($,Z.overscaledZ),l),x=1<<l,w=[new u.P(0,0),new u.P(u.aj,0),new u.P(u.aj,u.aj),new u.P(0,u.aj)],S=new u.P(0,0),A=new u.P(0,0),I=($,Z)=>{const G=Math.floor($[0]),te=Math.floor($[1]),ee=($[0]-G)*u.aj,le=($[1]-te)*u.aj,K=Math.floor(Z[0]),Q=Math.floor(Z[1]),ae=(Z[0]-K)*u.aj,de=(Z[1]-Q)*u.aj;for(let fe=-1;fe<=1;fe++){const be=G+fe;if(!(be<0||be>=x)){S.x=ee-fe*u.aj,A.x=ae-(be-K)*u.aj;for(let Te=-1;Te<=1;Te++){const Ve=te+Te;S.y=le-Te*u.aj,A.y=de-(Ve-Q)*u.aj,u.bT(S,A,w)&&m(g,0,l,be,Ve)}}}},M=n.points,D=M[u.be],L=M[u.bf],k=this._projectToGround(D,M[u.bg]),B=this._projectToGround(L,M[u.bh]);return I(D,k),I(L,B),d}_projectToGround(t,n){return u.bi(u.bj(),t,n,t[2]/(t[2]-n[2]))}_projectToZ(t,n,l){const d=t[2]-n[2];return Math.abs(d)<1e-6?u.bk(t):u.bi(u.bj(),t,n,(t[2]-l)/d)}extendTileCoverForTunnels(t,n,l,d){if(l<18)return[];const p=n.points,m=p[u.bl],g=p[u.bm],x=p[u.bn],w=p[u.bo];if(x[2]>=0&&w[2]>=0||m[2]<=0||g[2]<=0)return[];const S=x[2]<0?this._projectToZ(m,x,0):x,A=w[2]<0?this._projectToZ(g,w,0):w,I=-d,M=x[2]<I?this._projectToZ(m,x,I):x,D=w[2]<I?this._projectToZ(g,w,I):w,L=this._findExtensionTilesInQuad(t,l,[D,M,A,S],[.5*(S[0]+A[0]),.5*(S[1]+A[1])]);return L.length>3&&(L.length=3),L}_findExtensionTilesInQuad(t,n,l,d){const p=[],m=new Set;for(const K of t)m.add(K.key);const g=t.reduce((K,Q)=>Math.max(K,Q.overscaledZ),n),x=1<<n,w=[new u.P(l[0][0],l[0][1]),new u.P(l[1][0],l[1][1]),new u.P(l[3][0],l[3][1]),new u.P(l[2][0],l[2][1]),new u.P(l[0][0],l[0][1])],S=l[0][0],A=l[1][0],I=l[2][0],M=l[3][0],D=l[0][1],L=l[1][1],k=l[2][1],B=l[3][1],$=Math.max(0,Math.floor(Math.min(S,A,I,M))),Z=Math.min(x-1,Math.ceil(Math.max(S,A,I,M))-1),G=Math.max(0,Math.floor(Math.min(D,L,k,B))),te=Math.min(x-1,Math.ceil(Math.max(D,L,k,B))-1);for(let K=G;K<=te;K++)for(let Q=$;Q<=Z;Q++){if(!u.bp(w,Q,K,Q+1,K+1))continue;const ae=u.bq(0,g,n,Q,K);m.has(ae)||(p.push(new u.br(g,0,n,Q,K)),m.add(ae))}const ee=d[0],le=d[1];return p.sort((K,Q)=>{const ae=K.canonical.x+.5-ee,de=K.canonical.y+.5-le,fe=Q.canonical.x+.5-ee,be=Q.canonical.y+.5-le;return ae*ae+de*de-(fe*fe+be*be)||K.canonical.x-Q.canonical.x||K.canonical.y-Q.canonical.y}),p}coveringTiles(t){let n=this.coveringZoomLevel(t);const l=n,d=this.elevation&&this.elevation.exaggeration(),p=d&&!t.isTerrainDEM,m=this.projection.name==="mercator";if(t.minzoom!==void 0&&n<t.minzoom)return[];t.maxzoom!==void 0&&n>t.maxzoom&&(n=t.maxzoom);const g=this.locationCoordinate(this.center),x=this.center.lat,w=1<<n,S=[w*g.x,w*g.y,0],A=this.projection.name==="globe",I=!A,M=u.bs.fromInvProjectionMatrix(this.invProjMatrix,this.worldSize,n,I),D=A?this._camera.mercatorPosition:this.pointCoordinate(this.getCameraPoint()),L=w*u.aL(1,this.center.lat),k=this._camera.position[2]/u.aL(1,this.center.lat),B=[w*D.x,w*D.y,k*(I?1:L)],$=A||d,Z=this.cameraToCenterDistance/t.tileSize*(t.roundZoom?1:.502),G=this.isLODDisabled(!0)?n:0;let te;if(this._elevation&&t.isTerrainDEM)te=1e4*this._elevation.exaggeration();else if(this._elevation){const ge=this._elevation.getMinMaxForVisibleTiles();te=ge?ge.max:this._centerAltitude}else te=this._centerAltitude;const ee=t.isTerrainDEM?-te:this._elevation?this._elevation.getMinElevationBelowMSL():0,le=this.projection.isReprojectedInTileSpace?u.bt(this):1,K=ge=>{const Re=new u.ac(ge.x+25e-6,ge.y,ge.z),De=new u.ac(ge.x,ge.y+25e-6,ge.z),Ke=ge.toLngLat(),Be=Re.toLngLat(),Ge=De.toLngLat(),Ze=this.locationCoordinate(Ke),tt=this.locationCoordinate(Be),ot=this.locationCoordinate(Ge),at=Math.hypot(tt.x-Ze.x,tt.y-Ze.y),ut=Math.hypot(ot.x-Ze.x,ot.y-Ze.y);return Math.sqrt(at*ut)*le/25e-6},Q=ge=>{const Fe=te,Re=ee;return{aabb:u.bw(this,w,0,0,0,ge,Re,Fe,this.projection),zoom:0,x:0,y:0,minZ:Re,maxZ:Fe,wrap:ge,fullyVisible:!1}},ae=[];let de=[];const fe=n,be=t.reparseOverscaled?l:n,Te=(k-this._centerAltitude)*L,Ve=ge=>{if(!this._elevation||!ge.tileID||!m)return;const Fe=this._elevation.getMinMaxForTile(ge.tileID),Re=ge.aabb;Fe?(Re.min[2]=Fe.min,Re.max[2]=Fe.max,Re.center[2]=(Re.min[2]+Re.max[2])/2):(ge.shouldSplit=Ae(ge),ge.shouldSplit||(Re.min[2]=Re.max[2]=Re.center[2]=this._centerAltitude))},ye=(ge,Fe)=>{if(.707*Fe<ge)return 1;const Re=Fe/ge;return Re/(1.4144271570014144+(Math.pow(1.1,Re-1.4144271570014144+1)-1)/(1.1-1)-1)},Ae=ge=>{if(ge.zoom<G)return!0;
vendor: 13,280 bytes, line 8
8if(ge.zoom===fe)return!1;if(ge.shouldSplit!=null)return ge.shouldSplit;const Fe=ge.aabb.distanceX(B),Re=ge.aabb.distanceY(B);let De=Te,Ke=1;if(A){De=ge.aabb.distanceZ(B);const ut=Math.pow(2,ge.zoom),bt=u.aM((ge.y+1)/ut),pt=u.aM(ge.y/ut),Lt=Math.min(Math.max(x,bt),pt),kt=u.bX(Lt)/u.bX(x);if(Ke=Lt===x?1/Math.max(1,this._mercatorScaleRatio-.3):Math.min(1,kt/this._mercatorScaleRatio),this.zoom<=u.bU&&ge.zoom===fe-1&&kt>=.9)return!0}else if(p&&(De=ge.aabb.distanceZ(B)*L),this.projection.isReprojectedInTileSpace&&l<=5){const ut=Math.pow(2,ge.zoom),bt=K(new u.ac((ge.x+.5)/ut,(ge.y+.5)/ut));Ke=bt>.85?1:bt}if(!m&&!A){const ut=Math.sqrt(Fe*Fe+Re*Re+De*De);let bt=(1<<fe-ge.zoom)*Z*Ke;return bt*=ye(Math.max(De,Te),ut),ut<bt}let Be=Number.MAX_VALUE,Ge=0;const Ze=ge.aabb.getCorners(),tt=[0,0,0];for(const ut of Ze){u.aW(tt,ut,B),A||(p?tt[2]*=L:tt[2]=Te);const bt=u.aw(tt,this._camera.forward());bt<Be&&(Be=bt,Ge=Math.abs(tt[2]))}let ot=(1<<fe-ge.zoom)*Z*Ke;if(ot*=ye(Math.max(Ge,Te),Be),Be<ot)return!0;const at=ge.aabb.closestPoint(S);return at[0]===S[0]&&at[1]===S[1]};if(this.renderWorldCopies)for(let ge=1;ge<=3;ge++)ae.push(Q(-ge)),ae.push(Q(ge));for(ae.push(Q(0));ae.length>0;){const ge=ae.pop(),Fe=ge.x,Re=ge.y;let De=ge.fullyVisible;const Ke=()=>this.projection.name==="globe"&&(ge.y===0||ge.y===(1<<ge.zoom)-1);if(!De){let Be=$?ge.aabb.intersects(M):ge.aabb.intersectsFlat(M);if(Be===0&&Ke()){const Ge=new u.bu(ge.zoom,Fe,Re);Be=u.bv(this,w,Ge,!0).intersects(M)}if(Be===0)continue;De=Be===2}if(ge.zoom===fe||!Ae(ge)){const Be=ge.zoom===fe?be:ge.zoom;if(t.minzoom&&t.minzoom>Be)continue;let Ge=0;if(!De){let at=$?ge.aabb.intersectsPrecise(M):ge.aabb.intersectsPreciseFlat(M);if(at===0&&Ke()){const ut=new u.bu(ge.zoom,Fe,Re);at=u.bv(this,w,ut,!0).intersectsPrecise(M)}if(at===0)continue;if(t.calculateQuadrantVisibility)if(M.containsPoint(ge.aabb.center))Ge=15;else for(let ut=0;ut<4;ut++)ge.aabb.quadrant(ut).intersects(M)!==0&&(Ge|=1<<ut)}const Ze=S[0]-(.5+Fe+(ge.wrap<<ge.zoom))*(1<<n-ge.zoom),tt=S[1]-.5-Re,ot=ge.tileID?ge.tileID:new u.br(Be,ge.wrap,ge.zoom,Fe,Re);t.calculateQuadrantVisibility&&(ot.visibleQuadrants=Ge),de.push({tileID:ot,distanceSq:Ze*Ze+tt*tt});continue}for(let Be=0;Be<4;Be++){const Ge=(Fe<<1)+Be%2,Ze=(Re<<1)+(Be>>1),tt={aabb:m?ge.aabb.quadrant(Be):u.bw(this,w,ge.zoom+1,Ge,Ze,ge.wrap,ge.minZ,ge.maxZ,this.projection),zoom:ge.zoom+1,x:Ge,y:Ze,wrap:ge.wrap,fullyVisible:De,tileID:void 0,shouldSplit:void 0,minZ:ge.minZ,maxZ:ge.maxZ};p&&!A&&(tt.tileID=new u.br(ge.zoom+1===fe?be:ge.zoom+1,ge.wrap,ge.zoom+1,Ge,Ze),Ve(tt)),ae.push(tt)}}if(this.fogCullDistSq){const ge=this.fogCullDistSq,Fe=this.horizonLineFromTop();de=de.filter(Re=>{const De=[0,0,0,1],Ke=[u.aj,u.aj,0,1],Be=this.calculateFogTileMatrix(Re.tileID.toUnwrapped());u.aO(De,De,Be),u.aO(Ke,Ke,Be);const Ge=u.bx([],De,Ke),Ze=u.by([],De,Ke),tt=u.bV(Ge,Ze);if(tt===0)return!0;let ot=!1;const at=this._elevation;if(at&&tt>ge&&Fe!==0){const ut=this.calculateProjMatrix(Re.tileID.toUnwrapped());let bt;t.isTerrainDEM||(bt=at.getMinMaxForTile(Re.tileID)),bt||(bt={min:ee,max:te});const pt=u.bz(this.rotation),Lt=[pt[0]*u.aj,pt[1]*u.aj,bt.max];u.ad(Lt,Lt,ut),ot=(1-Lt[1])*this.height*.5<Fe}return tt<ge||ot})}return de.sort((ge,Fe)=>ge.distanceSq-Fe.distanceSq).map(ge=>ge.tileID)}resize(t,n){this.width=t,this.height=n,this.pixelsToGLUnits=[2/t,-2/n],this._constrain(),this._calcMatrices()}get unmodified(){return this._unmodified}zoomScale(t){return Math.pow(2,t)}scaleZoom(t){return Math.log2(t)}project(t){const n=u.as(t.lat,-u.bA,u.bA),l=this.projection.project(t.lng,n);return new u.P(l.x*this.worldSize,l.y*this.worldSize)}unproject(t){return this.projection.unproject(t.x/this.worldSize,t.y/this.worldSize)}get point(){return this.project(this.center)}get pointMerc(){return this.point._div(this.worldSize)}get pixelsPerMeterRatio(){return this.pixelsPerMeter/u.aL(1,this.center.lat)/this.worldSize}setLocationAtPoint(t,n){let l,d;const p=this.centerPoint;if(this.projection.name==="globe"){const g=this.worldSize;l=(n.x-p.x)/g,d=(n.y-p.y)/g}else{const g=this.pointCoordinate(n),x=this.pointCoordinate(p);l=g.x-x.x,d=g.y-x.y}const m=this.locationCoordinate(t);this.setLocation(new u.ac(m.x-l,m.y-d))}setLocation(t){this.center=this.coordinateLocation(t),this.projection.wrap&&(this.center=this.center.wrap())}locationPoint(t,n){return this.projection.locationPoint(this,t,n)}locationPoint3D(t,n){return this.projection.locationPoint(this,t,n,!0)}pointLocation(t){return this.coordinateLocation(this.pointCoordinate(t))}pointLocation3D(t,n){return this.coordinateLocation(this.pointCoordinate3D(t,n))}locationCoordinate(t,n){const l=n?u.aL(n,t.lat):void 0,d=this.projection.project(t.lng,t.lat);return new u.ac(d.x,d.y,l)}coordinateLocation(t){return this.projection.unproject(t.x,t.y)}pointRayIntersection(t,n){const l=n??this._centerAltitude,d=[t.x,t.y,0,1],p=[t.x,t.y,1,1];u.aO(d,d,this.pixelMatrixInverse),u.aO(p,p,this.pixelMatrixInverse);const m=p[3];u.bB(d,d,1/d[3]),u.bB(p,p,1/m);const g=d[2],x=p[2];return{p0:d,p1:p,t:g===x?0:(l-g)/(x-g)}}screenPointToMercatorRay(t){const n=[t.x,t.y,0,1],l=[t.x,t.y,1,1];return u.aO(n,n,this.pixelMatrixInverse),u.aO(l,l,this.pixelMatrixInverse),u.bB(n,n,1/n[3]),u.bB(l,l,1/l[3]),n[2]=u.aL(n[2],this._center.lat)*this.worldSize,l[2]=u.aL(l[2],this._center.lat)*this.worldSize,u.bB(n,n,1/this.worldSize),u.bB(l,l,1/this.worldSize),new u.bC([n[0],n[1],n[2]],u.au([],u.aW([],l,n)))}rayIntersectionCoordinate(t){const{p0:n,p1:l,t:d}=t,p=u.aL(n[2],this._center.lat),m=u.aL(l[2],this._center.lat);return new u.ac(u.ai(n[0],l[0],d)/this.worldSize,u.ai(n[1],l[1],d)/this.worldSize,u.ai(p,m,d))}pointCoordinate(t,n=this._centerAltitude){return this.projection.pointCoordinate(this,t.x,t.y,n)}pointCoordinate3D(t,n){if(!this.elevation)return this.pointCoordinate(t,n);let l=this.projection.pointCoordinate3D(this,t.x,t.y);if(l)return new u.ac(l[0],l[1],l[2]);let d=0,p=this.horizonLineFromTop();if(t.y>p)return this.pointCoordinate(t,n);const m=.02*p,g=t.clone();for(let x=0;x<10&&p-d>m;x++){g.y=u.ai(d,p,.66);const w=this.projection.pointCoordinate3D(this,g.x,g.y);w?(p=g.y,l=w):d=g.y}return l?new u.ac(l[0],l[1],l[2]):this.pointCoordinate(t)}isPointAboveHorizon(t){return this.projection.isPointAboveHorizon(this,t)}isPointOnSurface(t){if(t.y<0||t.y>this.height||t.x<0||t.x>this.width)return!1;if(this.elevation||this.zoom>=u.bD)return!this.isPointAboveHorizon(t);const n=this.pointCoordinate(t);return n.y>=0&&n.y<=1}_coordinatePoint(t,n){const l=n&&this.elevation?this.elevation.getAtPointOrZero(t,this._centerAltitude):this._centerAltitude,d=[t.x*this.worldSize,t.y*this.worldSize,l+t.toAltitude(),1];return u.aO(d,d,this.pixelMatrix),d[3]>0?new u.P(d[0]/d[3],d[1]/d[3]):new u.P(Number.MAX_VALUE,Number.MAX_VALUE)}_getBoundsNonRectangular(){const{top:t,left:n}=this._edgeInsets,l=this.height-this._edgeInsets.bottom,d=this.width-this._edgeInsets.right,p=this.pointLocation3D(new u.P(n,t)),m=this.pointLocation3D(new u.P(d,t)),g=this.pointLocation3D(new u.P(d,l)),x=this.pointLocation3D(new u.P(n,l));let w=Math.min(p.lng,m.lng,g.lng,x.lng),S=Math.max(p.lng,m.lng,g.lng,x.lng),A=Math.min(p.lat,m.lat,g.lat,x.lat),I=Math.max(p.lat,m.lat,g.lat,x.lat);const M=Math.pow(2,-this.zoom)/16*270,D=this.projection.name==="globe"?1:4,L=(k,B,$,Z,G)=>{const te=(k+$)/2,ee=(B+Z)/2,le=new u.P(te,ee),{lng:K,lat:Q}=this.pointLocation3D(le),ae=Math.max(0,w-K,A-Q,K-S,Q-I);w=Math.min(w,K),S=Math.max(S,K),A=Math.min(A,Q),I=Math.max(I,Q),(G<D||ae>M)&&(L(k,B,te,ee,G+1),L(te,ee,$,Z,G+1))};if(L(n,t,d,t,1),L(d,t,d,l,1),L(d,l,n,l,1),L(n,l,n,t,1),this.projection.name==="globe"){const[k,B]=u.bE(this);k?(I=90,S=180,w=-180):B&&(A=-90,S=180,w=-180)}return new u.bF(new u.b4(w,A),new u.b4(S,I))}_getBoundsRectangular(t,n){const{top:l,left:d}=this._edgeInsets,p=this.height-this._edgeInsets.bottom,m=this.width-this._edgeInsets.right,g=new u.P(d,l),x=new u.P(m,l),w=new u.P(m,p),S=new u.P(d,p);let A=this.pointCoordinate(g,t),I=this.pointCoordinate(x,t);const M=this.pointCoordinate(w,n),D=this.pointCoordinate(S,n),L=(k,B)=>(B.y-k.y)/(B.x-k.x);return A.y>1&&I.y>=0?A=new u.ac((1-D.y)/L(D,A)+D.x,1):A.y<0&&I.y<=1&&(A=new u.ac(-D.y/L(D,A)+D.x,0)),I.y>1&&A.y>=0?I=new u.ac((1-M.y)/L(M,I)+M.x,1):I.y<0&&A.y<=1&&(I=new u.ac(-M.y/L(M,I)+M.x,0)),new u.bF().extend(this.coordinateLocation(A)).extend(this.coordinateLocation(I)).extend(this.coordinateLocation(D)).extend(this.coordinateLocation(M))}_getBoundsRectangularTerrain(){const t=this.elevation;if(!t.visibleDemTiles.length||t.isUsingMockSource())return this._getBoundsRectangular(0,0);const n=t.visibleDemTiles.reduce((l,d)=>{if(d.dem){const p=d.dem.tree;l.min=Math.min(l.min,p.minimums[0]),l.max=Math.max(l.max,p.maximums[0])}return l},{min:Number.MAX_VALUE,max:0});return this._getBoundsRectangular(n.min*t.exaggeration(),n.max*t.exaggeration())}getBounds(){return this.projection.name==="mercator"||this.projection.name==="equirectangular"?this._terrainEnabled()?this._getBoundsRectangularTerrain():this._getBoundsRectangular(0,0):this._getBoundsNonRectangular()}horizonLineFromTop(t=!0){const n=this.height/2/Math.tan(this._fov/2)/Math.tan(Math.max(this._pitch,.1))-this.centerOffset.y,l=this.height/2-n*(1-this._horizonShift);return t?Math.max(0,l):l}getMaxBounds(){return this.maxBounds}setMaxBounds(t){this.maxBounds=t,this.minLat=-u.bA,this.maxLat=u.bA,this.minLng=-180,this.maxLng=180,t&&(this.minLat=t.getSouth(),this.maxLat=t.getNorth(),this.minLng=t.getWest(),this.maxLng=t.getEast(),this.maxLng<this.minLng&&(this.maxLng+=360)),this.worldMinX=u.a_(this.minLng)*this.tileSize,this.worldMaxX=u.a_(this.maxLng)*this.tileSize,this.worldMinY=u.a$(this.maxLat)*this.tileSize,this.worldMaxY=u.a$(this.minLat)*this.tileSize,this._constrain()}calculatePosMatrix(t,n){return this.projection.createTileMatrix(this,n,t)}calculateDistanceTileData(t){const n=t.key,l=this._distanceTileDataCache;if(l[n])return l[n];const d=t.canonical,p=1/this.height,m=this.cameraWorldSize,g=m/this.zoomScale(d.z),x=(d.x+Math.pow(2,d.z)*t.wrap)*g,w=d.y*g,S=this.point;S.x*=m/this.worldSize,S.y*=m/this.worldSize;const A=this.angle,I=Math.sin(-A),M=-Math.cos(-A);return l[n]={bearing:[I,M],center:[(S.x-x)*p,(S.y-w)*p],scale:g/u.aj*p},l[n]}calculateFogTileMatrix(t){const n=t.key,l=this._fogTileMatrixCache;if(l[n])return l[n];const d=this.projection.createTileMatrix(this,this.cameraWorldSizeForFog,t);return u.aP(d,this.worldToFogMatrix,d),l[n]=new Float32Array(d),l[n]}calculateProjMatrix(t,n=!1,l=!1){const d=t.key;let p;if(p=l?this._expandedProjMatrixCache:n?this._alignedProjMatrixCache:this._projMatrixCache,p[d])return p[d];const m=this.calculatePosMatrix(t,this.worldSize);let g;return g=this.projection.isReprojectedInTileSpace?this.mercatorMatrix:l?this.expandedFarZProjMatrix:n?this.alignedProjMatrix:this.projMatrix,u.aP(m,g,m),p[d]=new Float32Array(m),p[d]}calculatePixelsToTileUnitsMatrix(t){const n=t.tileID.key,l=this._pixelsToTileUnitsCache;if(l[n])return l[n];const d=u.bG(t,this);return l[n]=d,l[n]}customLayerMatrix(){return this.mercatorMatrix.slice()}globeToMercatorMatrix(){if(this.projection.name==="globe"){const t=1/this.worldSize,n=u.aF([],[t,t,t]);return u.aP(n,n,this.globeMatrix),n}}recenterOnTerrain(){if(!this._elevation||this.projection.name==="globe")return;const t=this._elevation;this._updateCameraState();const n=u.aL(1,this._center.lat)*this.worldSize,l=this._computeCameraPosition(n),d=this._camera.forward(),p=u.aL(1,this._center.lat);l[2]/=p,d[2]/=p,u.au(d,d);const m=t.raycast(l,d,t.exaggeration());if(m){const g=u.aY([],l,d,m),x=new u.ac(g[0],g[1],u.aL(g[2],u.aM(g[1]))),w=(x.z+u.ae([x.x-l[0],x.y-l[1],x.z-l[2]*p]))*this._pixelsPerMercatorPixel;this._seaLevelZoom=this._zoomFromMercatorZ(w),this._centerAltitude=x.toAltitude(),this._center=this.coordinateLocation(x),this._updateZoomFromElevation(),this._constrain(),this._calcMatrices()}}_constrainCamera(t=!1){if(!this._elevation)return;const n=this._elevation,l=u.aL(1,this._center.lat)*this.worldSize,d=this._computeCameraPosition(l),p=n.getAtPointOrZero(new u.ac(...d)),m=this.pixelsPerMeter/this.worldSize*p,g=this._minimumHeightOverTerrain(),x=d[2]-m;if(x<=g)if(x<0||t){const w=this.locationCoordinate(this._center,this._centerAltitude),S=[d[0],d[1],w.z-d[2]],A=u.ae(S);S[2]-=(g-x)/this._pixelsPerMercatorPixel;const I=u.ae(S);if(I===0)return;u.av(S,S,A/I*this._pixelsPerMercatorPixel),this._camera.position=[d[0],d[1],w.z*this._pixelsPerMercatorPixel-S[2]],this._updateStateFromCamera()}else this._isCameraConstrained=!0}_constrain(){if(!this.center||!this.width||!this.height||this._constraining)return;this._constraining=!0;const t=this.projection.name==="globe"||this.mercatorFromTransition;if(this.projection.isReprojectedInTileSpace||t){const I=this.center;return I.lat=u.as(I.lat,this.minLat,this.maxLat),(this.maxBounds||!this.renderWorldCopies&&!t)&&(I.lng=u.as(I.lng,this.minLng,this.maxLng)),this.center=I,void(this._constraining=!1)}const n=this._unmodified,{x:l,y:d}=this.point;let p=0,m=l,g=d;const x=this.width/2,w=this.height/2,S=this.worldMinY*this.scale,A=this.worldMaxY*this.scale;if(d-w<S&&(g=S+w),d+w>A&&(g=A-w),A-S<this.height&&(p=Math.max(p,this.height/(A-S)),g=(A+S)/2),this.maxBounds||!this._renderWorldCopies||!this.projection.wrap){const I=this.worldMinX*this.scale,M=this.worldMaxX*this.scale,D=this.worldSize/2-(I+M)/2;
8m=(l+D+this.worldSize)%this.worldSize-D,m-x<I&&(m=I+x),m+x>M&&(m=M-x),M-I<this.width&&(p=Math.max(p,this.width/(M-I)),m=(M+I)/2)}m===l&&g===d||this._allowWorldUnderZoom||(this.center=this.unproject(new u.P(m,g))),p&&!this._allowWorldUnderZoom&&(this.zoom+=this.scaleZoom(p)),this._constrainCamera(),this._unmodified=n,this._constraining=!1}_minZoomForBounds(){let t=Math.max(0,this.scaleZoom(Math.max(0,this.height)/(this.worldMaxY-this.worldMinY)));return this.maxBounds&&(t=Math.max(t,this.scaleZoom(this.width/(this.worldMaxX-this.worldMinX)))),t}_maxCameraBoundsDistance(){return this._mercatorZfromZoom(this._minZoomForBounds())}_calcMatrices(){if(!this.height)return;const t=this.centerOffset,n=this.projection.name==="globe",l=this.pixelsPerMeter;this.projection.name==="globe"&&(this._mercatorScaleRatio=u.aL(1,this.center.lat)/u.aL(1,u.bY));const d=u.bH(this.projection,this.zoom,this.width,this.height,1024);this._pixelsPerMercatorPixel=this.projection.pixelSpaceConversion(this.center.lat,this.worldSize,d),this.cameraToCenterDistance=.5/Math.tan(.5*this._fov)*this.height*this._pixelsPerMercatorPixel,this._updateCameraState(),this._farZ=this.projection.farthestPixelDistance(this),this._nearZ=this.height/50;const p=this.projection.zAxisUnit==="meters"?l:1,m=this._camera.getWorldToCamera(this.worldSize,p);let g;const x=this._camera.getCameraToClipPerspective(this._fov,this.width/this.height,this._nearZ,this._farZ);if(x[8]=2*-t.x/this.width,x[9]=2*t.y/this.height,this.isOrthographic){let te=.5*this.height/Math.tan(this._fov/2)*1*Math.tan(.5*this._fov),ee=te*this.aspect,le=-ee,K=-te;ee-=t.x,le-=t.x,te+=t.y,K+=t.y,g=this._camera.getCameraToClipOrthographic(le,ee,K,te,this._nearZ+this._nearClipOffset,this._farZ),((Q,ae,de,fe)=>{for(let be=0;be<16;be++)Q[be]=u.ai(ae[be],de[be],fe)})(g,g,x,u.bW(this.pitch>=nn?1:this.pitch/nn))}else g=x;const w=u.bI([],x,m),S=u.bI([],g,m);if(this.projection.isReprojectedInTileSpace){const te=this.locationCoordinate(this.center);u.aC(this._mat4Scratch);const ee=this._mat4Scratch;u.aG(ee,ee,[te.x*this.worldSize,te.y*this.worldSize,0]),u.aP(ee,ee,u.bJ(this)),u.aG(ee,ee,[-te.x*this.worldSize,-te.y*this.worldSize,0]),u.aP(S,S,ee),u.aP(w,w,ee),this.inverseAdjustmentMatrix=u.bK(this)}else this.inverseAdjustmentMatrix=[1,0,0,1];if(u.bL(this.mercatorMatrix,S,[this.worldSize,this.worldSize,this.worldSize/p,1]),this.projMatrix=S,u.aE(this.invProjMatrix,this.projMatrix),n){const te=this._camera.getCameraToClipPerspective(this._fov,this.width/this.height,this._nearZ,1/0);te[8]=2*-t.x/this.width,te[9]=2*t.y/this.height,u.bI(this._expandedFarZProjMatrixBuf,te,m),this.expandedFarZProjMatrix=this._expandedFarZProjMatrixBuf}else this.expandedFarZProjMatrix=this.projMatrix;u.aE(this._mat4Scratch,g),this.frustumCorners=u.bM.fromInvProjectionMatrix(this._mat4Scratch,this.horizonLineFromTop(),this.height),this.cameraFrustum=u.bs.fromInvProjectionMatrix(this.invProjMatrix,this.worldSize,0,!n),u.aF(this.skyboxMatrix,[1,-1,1]),u.bN(this.skyboxMatrix,this.skyboxMatrix,this._pitch),u.aR(this.skyboxMatrix,this.skyboxMatrix,this.angle),u.aJ(this.starsProjMatrix,this._fov,this.width/this.height,this._nearZ,this._farZ);const A=(Math.PI/2-this._pitch)*(this.height/this._fov)*this._horizonShift;u.bO(this._mat4Scratch,this.starsProjMatrix),this._mat4Scratch[8]=2*-t.x/this.width,this._mat4Scratch[9]=2*(t.y+A)/this.height,u.aP(this.skyboxMatrix,this._mat4Scratch,this.skyboxMatrix);const I=this.point,M=I.x,D=I.y,L=this.width%2/2,k=this.height%2/2,B=Math.cos(this.angle),$=Math.sin(this.angle),Z=M-Math.round(M)+B*L+$*k,G=D-Math.round(D)+B*k+$*L;if(u.bO(this.alignedProjMatrix,S),u.aG(this.alignedProjMatrix,this.alignedProjMatrix,[Z>.5?Z-1:Z,G>.5?G-1:G,0]),u.aF(this.labelPlaneMatrix,[this.width/2,-this.height/2,1]),u.aG(this.labelPlaneMatrix,this.labelPlaneMatrix,[1,-1,0]),u.aF(this.glCoordMatrix,[1,-1,1]),u.aG(this.glCoordMatrix,this.glCoordMatrix,[-1,-1,0]),u.bL(this.glCoordMatrix,this.glCoordMatrix,[2/this.width,2/this.height,1]),u.aP(this.pixelMatrix,this.labelPlaneMatrix,w),this._calcFogMatrices(),this._distanceTileDataCache={},!u.aE(this.pixelMatrixInverse,this.pixelMatrix))throw new Error("failed to invert matrix");if(this.projection.name==="globe"||this.mercatorFromTransition){this.globeMatrix=u.bP(this);const te=[this.globeMatrix[12],this.globeMatrix[13],this.globeMatrix[14]];this.globeCenterInViewSpace=u.ad(te,te,m),this.globeRadius=this.worldSize/2/Math.PI-1}else this.globeMatrix=this.pixelMatrixInverse;this._projMatrixCache={},this._alignedProjMatrixCache={},this._pixelsToTileUnitsCache={},this._expandedProjMatrixCache={}}_calcFogMatrices(){this._fogTileMatrixCache={};const t=this.cameraWorldSizeForFog,n=this.cameraPixelsPerMeter,l=this._camera.position,d=1/this.height/this._pixelsPerMercatorPixel,p=[t,t,n];u.av(p,p,d),u.av(l,l,-1),u.bQ(l,l,p),u.bR(this.mercatorFogMatrix,l),u.bL(this.mercatorFogMatrix,this.mercatorFogMatrix,p),this.worldToFogMatrix=this._camera.getWorldToCameraPosition(t,n,d)}_computeCameraPosition(t){const n=(t=t||this.pixelsPerMeter)/this.pixelsPerMeter,l=this._camera.forward(),d=this.point,p=this._mercatorZfromZoom(this._seaLevelZoom?this._seaLevelZoom:this._zoom)*n-t/this.worldSize*this._centerAltitude;return[d.x/this.worldSize-l[0]*p,d.y/this.worldSize-l[1]*p,t/this.worldSize*this._centerAltitude-l[2]*p]}_updateCameraState(){this.height&&(this._camera.setPitchBearing(this._pitch,this.angle),this._camera.position=this._computeCameraPosition())}_translateCameraConstrained(t){const n=this._maxCameraBoundsDistance()*Math.cos(this._pitch),l=this._camera.position[2],d=t[2];let p=1;this.projection.wrap&&(this.center=this.center.wrap()),d>0&&(p=Math.min((n-l)/d,1)),this._camera.position=u.aY([],this._camera.position,t,p),this._updateStateFromCamera()}_updateStateFromCamera(){const t=this._camera.position,n=this._camera.forward(),{pitch:l,bearing:d}=this._camera.getPitchBearing(),p=u.aL(this._centerAltitude,this.center.lat)*this._pixelsPerMercatorPixel,m=this._mercatorZfromZoom(this._maxZoom)*Math.cos(u.al(this._maxPitch)),g=Math.max((t[2]-p)/Math.cos(l),m),x=this._zoomFromMercatorZ(g);u.aY(t,t,n,g),this._pitch=u.as(l,u.al(this.minPitch),u.al(this.maxPitch)),this.angle=u.at(d,-Math.PI,Math.PI),this._setZoom(u.as(x,this._minZoom,this._maxZoom)),this._updateSeaLevelZoom(),this._center=this.coordinateLocation(new u.ac(t[0],t[1],t[2])),this._unmodified=!1,this._constrain(),this._calcMatrices()}_worldSizeFromZoom(t){return Math.pow(2,t)*this.tileSize}_mercatorZfromZoom(t){return this.cameraToCenterDistance/this._worldSizeFromZoom(t)}_minimumHeightOverTerrain(){const t=Math.min(this._seaLevelZoom!=null?this._seaLevelZoom:this._zoom,this._maxZoom)+4;return this._mercatorZfromZoom(t)}_zoomFromMercatorZ(t){return this.scaleZoom(this.cameraToCenterDistance/(Math.max(0,t)*this.tileSize))}zoomFromMercatorZAdjusted(t){let n=0,l=u.bD,d=0,p=1/0;for(;l-n>1e-6&&l>n;){const m=n+.5*(l-n),g=this.tileSize*Math.pow(2,m),x=this.getCameraToCenterDistance(this.projection,m,g),w=this.scaleZoom(x/(Math.max(0,t)*this.tileSize)),S=Math.abs(m-w);S<p&&(p=S,d=m),m<w?n=m:l=m}return d}_terrainEnabled(){return!(!this._elevation||!this.projection.supportsTerrain&&(u.w("Terrain is not yet supported with alternate projections. Use mercator or globe to enable terrain."),1))}anyCornerOffEdge(t,n){const l=Math.min(t.x,n.x),d=Math.max(t.x,n.x),p=Math.min(t.y,n.y),m=Math.max(t.y,n.y);if(p<this.horizonLineFromTop(!1))return!0;
8if(this.projection.name!=="mercator")return!1;const g=[new u.P(l,p),new u.P(d,m),new u.P(l,m),new u.P(d,p)],x=this.renderWorldCopies?-3:0,w=this.renderWorldCopies?4:1;for(const S of g){const A=this.pointRayIntersection(S);if(A.t<0)return!0;const I=this.rayIntersectionCoordinate(A);if(I.x<x||I.y<0||I.x>w||I.y>1)return!0}return!1}isHorizonVisible(){return this.pitch+u.bS(this.fovAboveCenter)>88||this.anyCornerOffEdge(new u.P(0,0),new u.P(this.width,this.height))}zoomDeltaToMovement(t,n){const l=u.ae(u.aW([],this._camera.position,t)),d=this._zoomFromMercatorZ(l)+n;return l-this._mercatorZfromZoom(d)}getCameraPoint(){if(this.projection.name==="globe"){const t=(function([n,l,d],p){const m=[n,l,d,1];u.aO(m,m,p);const g=m[3]=Math.max(m[3],1e-6);return m[0]/=g,m[1]/=g,m[2]/=g,m})([this.globeMatrix[12],this.globeMatrix[13],this.globeMatrix[14]],this.pixelMatrix);return new u.P(t[0],t[1])}{const t=Math.tan(this._pitch)*(this.cameraToCenterDistance||1);return this.centerPoint.add(new u.P(0,t))}}getCameraToCenterDistance(t,n=this.zoom,l=this.worldSize){const d=u.bH(t,n,this.width,this.height,1024),p=t.pixelSpaceConversion(this.center.lat,l,d);let m=.5/Math.tan(.5*this._fov)*this.height*p;return this.isOrthographic&&(m=u.ai(1,m,u.bW(this.pitch>=nn?1:this.pitch/nn))),m}getWorldToCameraMatrix(){const t=this._camera.getWorldToCamera(this.worldSize,this.projection.zAxisUnit==="meters"?this.pixelsPerMeter:1);return this.projection.name==="globe"&&u.aP(t,t,this.globeMatrix),t}getFrustum(t){return u.bs.fromInvProjectionMatrix(this.invProjMatrix,this.worldSize,t,this.projection.zAxisUnit==="meters")}}const Oo=(s,t)=>{if(t<=0||s.terrain)return{shouldRenderCutoff:!1,uniformValues:{u_cutoff_params:[0,0,0,1]}};const n=s.transform,l=n.pitch,d=n.isLODDisabled(!1)?60:30;if(l<d-15)return{shouldRenderCutoff:!1,uniformValues:{u_cutoff_params:[0,0,0,1]}};const p=n._farZ-n._nearZ,m=t*n.height*1.3,g=Math.pow(2,.85*Math.max(n._zoom-s.minCutoffZoom,0)),x=1.4*n.cameraToCenterDistance*g,w=u.af(d-15,d,l),S=u.ai(n._farZ+m,x,w),A=Math.min(m,S-n._nearZ);return{shouldRenderCutoff:w>0,uniformValues:{u_cutoff_params:[n._nearZ,n._farZ,(S-n._nearZ)/p,(S-A-n._nearZ)/p]}}},Cr=7680;class mt{constructor(t,n,l,d,p,m){this.test=t,this.ref=n,this.mask=l,this.fail=d,this.depthFail=p,this.pass=m}}mt.disabled=new mt({func:519,mask:0},0,0,Cr,Cr,Cr);const qs=new Float32Array(16);function Tr(s,t,n,l,d,p,m,g,x,w,S,A,I,M,D,L,k,B,$,Z,G){const te=t.context,ee=te.gl,le=t.transform,K=t.transform.zoom,Q=[],ae=s.translate,de=s.translateAnchor,fe=s.edgeRadius,be=Oo(t,s.cutoffFadeRange);S==="clear"?(Q.push("CLEAR_SUBPASS"),Z&&(Q.push("CLEAR_FROM_TEXTURE"),te.activeTexture.set(ee.TEXTURE0),Z.bind(ee.LINEAR,ee.CLAMP_TO_EDGE))):S==="sdf"?Q.push("SDF_SUBPASS"):S==="emissive"&&(Q.push("USE_MRT1"),te.activeTexture.set(ee.TEXTURE0),Z.bind(ee.LINEAR,ee.CLAMP_TO_EDGE)),B&&Q.push("HAS_CENTROID"),be.shouldRenderCutoff&&Q.push("RENDER_CUTOFF");const Te=(Ve,ye,Ae,ge,Fe)=>{let Re=Q;ye.groundRadiusBuffer!=null&&(Re=Q.concat("HAS_ATTRIBUTE_a_flood_light_ground_radius"));const De=ye.programConfigurations.get(l.id),Ke=t.isTileAffectedByFog(Ve),Be=t.getOrCreateProgram("fillExtrusionGroundEffect",{config:De,defines:Re,overrideFog:Ke}),Ge=((tt,ot,at,ut,bt,pt,Lt,kt,gt,Pt)=>({u_matrix:tt,u_opacity:ot,u_ao_pass:at?1:0,u_meter_to_tile:ut,u_ao:bt,u_flood_light_intensity:pt,u_flood_light_color:Lt,u_attenuation:kt,u_edge_radius:gt,u_fb:0,u_fb_size:Pt,u_dynamic_offset:1}))(ge,A,w,Fe,[I,M*Fe],D,L,k,K>=17?0:fe*Fe,Z?Z.size[0]:0),Ze=[];B&&Ze.push(ye.hiddenByLandmarkVertexBuffer),ye.groundRadiusBuffer!=null&&Ze.push(ye.groundRadiusBuffer),t.uploadCommonUniforms(te,Be,Ve.toUnwrapped(),null,be),Be.draw(t,te.gl.TRIANGLES,p,m,g,x,Ge,l.id,ye.vertexBuffer,ye.indexBuffer,Ae,l.paint,K,De,Ze)};for(const Ve of d){const ye=n.getTile(Ve),Ae=ye.getBucket(l);if(!Ae||Ae.projection.name!==le.projection.name||!Ae.groundEffect||Ae.groundEffect&&!Ae.groundEffect.hasData())continue;const ge=Ae.groundEffect,Fe=1/Ae.tileToMeter;{const Re=t.translatePosMatrix(Ve.projMatrix,ye,ae,de),De=ge.getDefaultSegment();Te(Ve,ge,De,Re,Fe)}if($)for(let Re=0;Re<4;Re++){const De=u.c0[Re](Ve),Ke=n.getTile(De);if(!Ke)continue;const Be=Ke.getBucket(l);if(!Be||Be.projection.name!==le.projection.name||!Be.groundEffect||Be.groundEffect&&!Be.groundEffect.hasData())continue;const Ge=Be.groundEffect;let Ze,tt;Re===0?(Ze=[-u.aj,0,0],tt=1):Re===1?(Ze=[u.aj,0,0],tt=0):Re===2?(Ze=[0,-u.aj,0],tt=3):(Ze=[0,u.aj,0],tt=2);const ot=Ge.regionSegments[tt];ot&&(u.aG(qs,Ve.projMatrix,Ze),Te(Ve,Ge,ot,t.translatePosMatrix(qs,ye,ae,de),Fe))}}}const ic=770,On=771;class yt{constructor(t,n,l,d){this.blendFunction=t,this.blendColor=n.toNonPremultipliedRenderColor(null),this.mask=l,this.blendEquation=d}}
8function Hc(s,t,n=0){const l=Math.pow(2,t.tileID.overscaledZ),d=t.tileSize*Math.pow(2,s.transform.tileZoom)/l,p=d*(t.tileID.canonical.x+t.tileID.wrap*l),m=d*t.tileID.canonical.y;return{u_image:0,u_texsize:t.imageAtlasTexture?t.imageAtlasTexture.size:[0,0],u_tile_units_to_pixels:1/u.c1(t,1,s.transform.tileZoom),u_pixel_coord_upper:[p>>16,m>>16],u_pixel_coord_lower:[65535&p,65535&m],u_pattern_transition:n}}yt.Replace=[1,0,1,0],yt.disabled=new yt(yt.Replace,u.C.transparent,[!1,!1,!1,!1]),yt.unblended=new yt(yt.Replace,u.C.transparent,[!0,!0,!0,!0]),yt.alphaBlended=new yt([1,On,1,On],u.C.transparent,[!0,!0,!0,!0]),yt.alphaBlendedNonPremultiplied=new yt([ic,On,ic,On],u.C.transparent,[!0,!0,!0,!0]),yt.multiply=new yt([774,0,774,0],u.C.transparent,[!0,!0,!0,!0]),yt.multiplyAccumulateAlpha=new yt([774,0,1,On],u.C.transparent,[!0,!0,!0,!0]),yt.additive=new yt([1,1,1,1],u.C.transparent,[!0,!0,!0,!0]),yt.additiveAlphaWeighted=new yt([ic,1,773,1],u.C.transparent,[!0,!0,!0,!0]),yt.additiveAlphaWeightedUnboundedAlpha=new yt([ic,1,1,1],u.C.transparent,[!0,!0,!0,!0]);const rc={terrain:0,flat:1},dm=u.aS(),$d=[0,0,0],Zc=(s,t,n,l,d,p,m,g,x,w,S,A,I,M,D,L,k,B,$=[0,0,1],Z=!1)=>{let G=$d,te=0,ee=$d;if(!Z){const Q=t.style.light,ae=Q.properties.get("position");if(G=[ae.x,ae.y,ae.z],Q.properties.get("anchor")==="viewport"){const fe=u.c2();u.c3(fe,-t.transform.angle),u.c4(G,G,fe)}const de=Q.properties.get("color").toPremultipliedRenderColor(null);te=Q.properties.get("intensity"),ee=[de.r,de.g,de.b]}const le=t.transform,K={u_matrix:s,u_lightpos:G,u_lightintensity:te,u_lightcolor:ee,u_vertical_gradient:+n,u_opacity:l,u_tile_id:[0,0,0],u_zoom_transition:0,u_inv_rot_matrix:dm,u_merc_center:[0,0],u_up_dir:[0,0,0],u_height_lift:0,u_height_type:rc[w],u_base_type:rc[S],u_ao:d,u_edge_radius:p,u_width_scale:m,u_flood_light_color:D,u_vertical_scale:L,u_flood_light_intensity:k,u_ground_shadow_factor:B,u_front_cutoff_params:$};return le.projection.name==="globe"&&(K.u_tile_id=[g.canonical.x,g.canonical.y,1<<g.canonical.z],K.u_zoom_transition=A,K.u_inv_rot_matrix=M,K.u_merc_center=I,K.u_up_dir=le.projection.upVector(new u.bu(0,0,0),I[0]*u.aj,I[1]*u.aj),K.u_height_lift=x),K},fm=(s,t,n,l,d,p)=>({u_matrix:s,u_edge_radius:t,u_width_scale:n,u_vertical_scale:l,u_height_type:rc[d],u_base_type:rc[p]}),qg=(s,t,n,l,d,p,m,g,x,w,S,A,I,M,D,L,k,B,$=!1)=>{const Z=Zc(s,t,n,l,d,p,m,g,w,S,A,I,M,D,L,k,1,[0,0,0],[0,0,1],$),G={u_height_factor:-Math.pow(2,g.overscaledZ)/x.tileSize/8};return Object.assign(Z,Hc(t,x,B),G)};function Hs(s){const t=s.properties.get("direction"),n=u.c5(t.x,t.y,t.z);n[2]=u.as(n[2],0,75);const l=u.c8([n[0],n[1],n[2]]);return u.c6(l.x,l.y,l.z)}function pl(s,t,n){const l=t.properties.get("color-use-theme")==="none",d=t.properties.get("color"),p=t.properties.get("intensity"),m=t.properties.get("direction"),g=[m.x,m.y,m.z],x=n.properties.get("color-use-theme")==="none",w=n.properties.get("color"),S=n.properties.get("intensity"),A=Math.max(u.aw([0,0,1],g),0),I=[0,0,0];u.av(I,w.toPremultipliedRenderColor(x?null:s.getLut(t.scope)).toArray01Linear().slice(0,3),S);const M=[0,0,0];return u.av(M,d.toPremultipliedRenderColor(l?null:s.getLut(n.scope)).toArray01Linear().slice(0,3),A*p),u.c7([I[0]>0?I[0]/(I[0]+M[0]):0,I[1]>0?I[1]/(I[1]+M[1]):0,I[2]>0?I[2]/(I[2]+M[2]):0])}const Wc=new Float32Array(u.aC([])),jn=[0,0,0],qd=(s,t,n,l,d,p,m,g,x,w,S,A,I,M=[0,0,0],D,L,k,B=1,$=!1)=>{let Z=jn,G=0,te=jn;if(!$){const Q=d.style.light,ae=Q.properties.get("position");if(Z=[-ae.x,-ae.y,ae.z],Q.properties.get("anchor")==="viewport"){const fe=u.c2();u.c3(fe,-d.transform.angle),u.c4(Z,Z,fe)}const de=Q.properties.get("color").toNonPremultipliedRenderColor(null);G=Q.properties.get("intensity"),te=[de.r,de.g,de.b]}const ee=S.alphaMode==="MASK",le=I.paint.get("model-ambient-occlusion-intensity"),K=I.paint.get("model-color").constantOr(u.C.white).toNonPremultipliedRenderColor(null);return K.a=I.paint.get("model-color-mix-intensity").constantOr(0),k&&(K.r=k[0],K.g=k[1],K.b=k[2],K.a=k[3]),L&&(K.r=L.color.r,K.g=L.color.g,K.b=L.color.b,K.a=L.colorMix,A=L.emissionStrength,p*=L.opacity),{u_matrix:s,u_lighting_matrix:t,u_normal_matrix:n,u_node_matrix:l||Wc,u_lightpos:Z,u_lightintensity:G,u_lightcolor:te,u_camera_pos:M,u_opacity:p,u_baseTextureIsAlpha:0,u_alphaMask:+ee,u_alphaCutoff:S.alphaCutoff,u_baseColorFactor:m.toNonPremultipliedRenderColor(null).toArray01(),u_emissiveFactor:g.toNonPremultipliedRenderColor(null).toArray01(),u_metallicFactor:x,u_roughnessFactor:w,u_baseColorTexture:5,u_metallicRoughnessTexture:6,u_normalTexture:7,u_occlusionTexture:8,u_emissionTexture:9,u_lutTexture:10,u_color_mix:K.toArray01(),u_aoIntensity:le,u_emissive_strength:A,u_occlusionTextureTransform:D||[0,0,0,0],u_dithered_discard_threshold:B}},Xc=(s,t=Wc,n=Wc)=>({u_matrix:s,u_instance:t,u_node_matrix:n}),Ss=(s,t,n=1)=>({u_matrix:s,u_color:t,u_overlay:0,u_overlay_scale:n}),vn=new Float64Array(16),$r=new Float64Array(16),on=new Float64Array(16),Zs=new Float64Array(16),Hd=new Float64Array(16),rh=new Float64Array(16),Hg=new Float64Array(16),Yc=[0,0,0],Zg=new Float32Array(16),nc=[0,0,0],pm=[0,0,0],nh=[];function Zd(s,t,n){const l=n.cameraWorldSizeForFog/n.worldSize;return u.bL(s,n.worldToFogMatrix,[l,l,1]),u.aP(s,s,t),s}function oc(s,t,n,l){return u.aG(s,t,n),u.b9(l,u.cu)||u.bL(s,s,l),s}function ua(s,t,n,l,d){const p=n.material,m=l.context,{baseColorTexture:g,metallicRoughnessTexture:x}=p.pbrMetallicRoughness,{normalTexture:w,occlusionTexture:S,emissionTexture:A}=p;function I(D,L,k){if(D&&(s.push(L),m.activeTexture.set(m.gl.TEXTURE0+k),D.gfxTexture)){const{minFilter:B,magFilter:$,wrapS:Z,wrapT:G}=D.sampler;D.gfxTexture.bindExtraParam(B,$,Z,G)}}I(g,"HAS_TEXTURE_u_baseColorTexture",5),I(x,"HAS_TEXTURE_u_metallicRoughnessTexture",6),I(w,"HAS_TEXTURE_u_normalTexture",7),I(S,"HAS_TEXTURE_u_occlusionTexture",8),I(A,"HAS_TEXTURE_u_emissionTexture",9),d&&(d.texture||(d.texture=new u.ct(l.context,d.image,[d.image.height,d.image.height,d.image.height],m.gl.RGBA8)),m.activeTexture.set(m.gl.TEXTURE0+10),d.texture&&d.texture.bind(m.gl.LINEAR,m.gl.CLAMP_TO_EDGE),s.push("APPLY_LUT_ON_GPU")),n.texcoordBuffer&&(s.push("HAS_ATTRIBUTE_a_uv_2f"),t.push(n.texcoordBuffer)),n.colorBuffer&&(s.push(n.colorBuffer.itemSize===12?"HAS_ATTRIBUTE_a_color_3f":"HAS_ATTRIBUTE_a_color_4f"),t.push(n.colorBuffer)),n.normalBuffer&&(s.push("HAS_ATTRIBUTE_a_normal_3f"),t.push(n.normalBuffer)),n.pbrBuffer&&(s.push("HAS_ATTRIBUTE_a_pbr"),s.push("HAS_ATTRIBUTE_a_heightBasedEmissiveStrength"),t.push(n.pbrBuffer)),p.alphaMode!=="OPAQUE"&&p.alphaMode!=="MASK"||s.push("UNPREMULT_TEXTURE_IN_SHADER"),p.defined||s.push("DIFFUSE_SHADED");const M=l.shadowRenderer;M&&(s.push("RENDER_SHADOWS"),M.useNormalOffset&&s.push("NORMAL_OFFSET"))}function sc(s,t,n,l,d,p){const m=s.modelOpacity,g=t.context,x=new ct(t.context.gl.LEQUAL,s.isLightMesh?ct.ReadOnly:ct.ReadWrite,t.depthRangeFor3D),w=t.transform,S=s.mesh,A=S.material,I=A.pbrMetallicRoughness,M=t.style.fog;t.transform.projection.zAxisUnit==="pixels"?vn.set(s.nodeModelMatrix):u.aP(vn,l.zScaleMatrix,s.nodeModelMatrix),u.aP(vn,l.negCameraPosMatrix,vn),u.aE($r,vn),u.cl($r,$r);
vendor: 9,846 bytes, line 8
8const D=n.paint.get("model-color-use-theme").constantOr("default")==="none",L=n.paint.get("model-emissive-strength").constantOr(0),k={defines:[]},B=[],$=t.shadowRenderer;$&&($.useNormalOffset=!1),ua(k.defines,B,S,t,D?null:n.lut);let Z=null;if(M&&(Z=Zd(on,s.nodeModelMatrix,t.transform),w.projection.name!=="globe")){const le=S.aabb.min,K=S.aabb.max,[Q,ae]=M.getOpacityForBounds(Z,le[0],le[1],K[0],K[1]);k.overrideFog=Q>=hl||ae>=hl}const G=Oo(t,n.paint.get("model-cutoff-fade-range"));G.shouldRenderCutoff&&k.defines.push("RENDER_CUTOFF");const te=t.getOrCreateProgram("model",k),ee=qd(s.worldViewProjection,vn,$r,null,t,m,I.baseColorFactor,A.emissiveFactor,I.metallicFactor,I.roughnessFactor,A,L,n,void 0,void 0,s.materialOverride,s.modelColor,1,te.fixedDefines.includes("LIGHTING_3D_MODE"));t.uploadCommonUniforms(g,te,null,Z,G,s.lightOverrides),t.renderPass!=="shadow"&&$&&$.setupShadowsFromMatrix(s.nodeModelMatrix,te),te.draw(t,g.gl.TRIANGLES,x,d,p,S.material.doubleSided?_t.disabled:_t.backCCW,ee,n.id,S.vertexBuffer,S.indexBuffer,S.segments,n.paint,t.transform.zoom,void 0,B)}function rt(s,t){return s.style._importedAsBasemap?"basemap":t.scope}function oh(s,t,n,l,d,p,m,g,x,w,S){const A=s.transform,I=!!t.isGeometryBloom&&t.isGeometryBloom;if(t.minZoom!==void 0&&s.transform.zoom<t.minZoom||t.maxZoom!==void 0&&s.transform.zoom>t.maxZoom||I&&s.renderPass==="shadow")return;const M=A.projection.name==="globe"?u.cj(n,A):[...n];u.aP(M,M,t.globalMatrix);const D=u.aP([],l,M);if(t.meshes)for(const L of t.meshes){const k=g.get(L.material.name);if(k&&k.opacity<=0)continue;if(L.material.alphaMode!=="BLEND"){m.push({mesh:L,depth:0,modelIndex:d,worldViewProjection:D,nodeModelMatrix:M,isLightMesh:I,materialOverride:k,modelOpacity:x,modelColor:w,lightOverrides:S,node:t,modelMatrix:n});continue}const B=u.ad([],L.centroid,D);!A.isOrthographic&&B[2]<=0||p.push({mesh:L,depth:B[2],modelIndex:d,worldViewProjection:D,nodeModelMatrix:M,isLightMesh:I,materialOverride:k,modelOpacity:x,modelColor:w,lightOverrides:S,node:t,modelMatrix:n})}if(t.children)for(const L of t.children)oh(s,L,n,l,d,p,m,g,x,w,S)}function ac(s,t,n,l,d){const p=n.shadowRenderer;if(!p)return;const m=p.getShadowPassDepthMode(),g=d||p.calculateShadowPassMatrixFromMatrix(t),x=Xc(g);n.getOrCreateProgram("modelDepth").draw(n,n.context.gl.TRIANGLES,m,mt.disabled,yt.disabled,_t.disabled,x,l.id,s.vertexBuffer,s.indexBuffer,s.segments,l.paint,n.transform.zoom,void 0,void 0)}function Wd(s,t,n,l){const d=(function(S,A){if(A.footprintDebugMesh)return A.footprintDebugMesh;if(!A.footprint)return null;const I=S.context,M=A.footprint.vertices,D=A.footprint.indices,L=new u.co;L.reserve(M.length);for(const ae of M)L.emplaceBack(ae.x,ae.y);const k=new u.cp;k.reserve(D.length);for(let ae=0;ae<D.length;ae+=3)k.emplaceBack(D[ae],D[ae+1],D[ae+2]);const B=I.createVertexBuffer(L,u.cq.members),$=I.createIndexBuffer(k),Z=u.cr.simpleSegment(0,0,M.length,D.length),G=A.id||A.name||"footprint";let te;const ee=parseInt(G,10);te=isNaN(ee)?(function(ae){let de=0;for(let fe=0;fe<ae.length;fe++)de=(de<<5)-de+ae.charCodeAt(fe)|0;return de})(G):ee;const le=u.cy(te),K=u.cy(te+1),Q=u.cy(te+2);return A.footprintDebugMesh={vertexBuffer:B,indexBuffer:$,segments:Z,color:new u.C(le,K,Q,.5)},A.footprintDebugMesh})(s,n);if(!d)return;const p=s.context,m=p.gl,g=s.getOrCreateProgram("debug"),x=d.color,w=ct.disabled;p.activeTexture.set(m.TEXTURE0),s.emptyTexture.bind(m.LINEAR,m.CLAMP_TO_EDGE),g.draw(s,m.TRIANGLES,w,mt.disabled,yt.alphaBlended,_t.disabled,Ss(l,x.toPremultipliedRenderColor(null)),"$debug",d.vertexBuffer,d.indexBuffer,d.segments)}function Xd(s,t,n,l,d,p){for(const m of d){const g={...l};g.part=m;const x={type:"Unknown",id:t,properties:g},w={orientation:s.paint.get("model-rotation").evaluate(x,n)};p.set(m,w)}}function ml(s,t,n,l,d,p){for(const m of d){const g={...l};g.part=m;const x={type:"Unknown",id:t,properties:g},w={color:s.paint.get("model-color").evaluate(x,n),colorMix:s.paint.get("model-color-mix-intensity").evaluate(x,n),opacity:s.paint.get("model-opacity").evaluate(x,n),emissionStrength:s.paint.get("model-emissive-strength").evaluate(x,n)};p.set(m,w)}}function lc(s,t,n,l,d){let p=!1;for(const g of l)g.modelOpacity!==1&&(sc(g,s,t,d[g.modelIndex],mt.disabled,yt.disabled),p=!0);for(const g of l)sc(g,s,t,d[g.modelIndex],g.modelOpacity!==1?s.stencilModeFor3D():mt.disabled,s.colorModeForRenderPass());p&&s.resetStencilClippingMasks();const m=yt.additive;for(const g of n)sc(g,s,t,d[g.modelIndex],mt.disabled,g.isLightMesh?m:s.colorModeForRenderPass())}function Kc(s,t,n){const l=t.updateZoomBasedPaintProperties(),d=(function(p,m,g){let x,w,S,A=p.terrain?p.terrain.exaggeration():0;if(p.terrain&&A>0){const I=p.terrain,M=I.findDEMTileFor(g);M&&M.dem?x=u.cs.create(I,g,M):A=0}if(A===0&&(m.terrainElevationMin=0,m.terrainElevationMax=0),A===m.validForExaggeration&&(A===0||x&&x._demTile&&x._demTile.tileID===m.validForDEMTile.id&&x._dem._timestamp===m.validForDEMTile.timestamp))return!1;for(const I in m.instancesPerModel){const M=m.instancesPerModel[I];for(let D=0;D<M.instancedDataArray.length;++D){const L=(x?A*x.getElevationAt(0|M.instancedDataArray.float32[16*D],0|M.instancedDataArray.float32[16*D+1],!0,!0):0)+M.instancesEvaluatedElevation[D];M.instancedDataArray.float32[16*D+6]=L,w=w?Math.min(m.terrainElevationMin,L):L,S=S?Math.max(m.terrainElevationMax,L):L}}return m.terrainElevationMin=w||0,m.terrainElevationMax=S||0,m.validForExaggeration=A,m.validForDEMTile=x&&x._demTile?{id:x._demTile.tileID,timestamp:x._dem._timestamp}:{id:void 0,timestamp:0},!0})(s,t,n);(l||d)&&(t.uploaded=!1,t.upload(s.context))}const Es={shadowUniformsInitialized:!1,useSingleShadowCascade:!1,tileMatrix:new Float64Array(16),shadowTileMatrix:new Float32Array(16),aabb:new u.ca([0,0,0],[u.aj,u.aj,0])};function mm(s,t){const n=1<<s.canonical.z,l=t.getFreeCameraOptions().position,d=t.elevation,p=s.canonical.x/n,m=(s.canonical.x+1)/n,g=s.canonical.y/n,x=(s.canonical.y+1)/n;let w=t._centerAltitude;if(d){const M=d.getMinMaxForTile(s);M&&M.max>w&&(w=M.max)}const S=u.as(l.x,p,m)-l.x,A=u.as(l.y,g,x)-l.y,I=u.aL(w,t.center.lat)-l.z;return t._zoomFromMercatorZ(Math.sqrt(S*S+A*A+I*I))}function Jc(s,t,n,l,d,p,m){const g=s.context,x=s.renderPass==="shadow",w=s.shadowRenderer,S=x&&w?w.getShadowPassDepthMode():new ct(g.gl.LEQUAL,ct.ReadWrite,s.depthRangeFor3D),A=s.isTileAffectedByFog(p),I=s.transform.projection.name==="globe";if(n.meshes)for(const M of n.meshes){const D=I?[]:["MODEL_POSITION_ON_GPU"],L=[];let k,B,$;const Z=!I&&l.instancedDataArray.length>20;Z&&D.push("INSTANCED_ARRAYS");const G=Oo(s,t.paint.get("model-cutoff-fade-range"));if(G.shouldRenderCutoff&&D.push("RENDER_CUTOFF"),x&&w)k=s.getOrCreateProgram("modelDepth",{defines:D}),B=Xc(m.shadowTileMatrix,m.shadowTileMatrix,n.globalMatrix),$=yt.disabled;else{ua(D,L,M,s,t.paint.get("model-color-use-theme").constantOr("default")==="none"?null:t.lut),k=s.getOrCreateProgram("model",{defines:D,overrideFog:A});const ee=M.material,le=ee.pbrMetallicRoughness,K=t.paint.get("model-opacity").constantOr(1),Q=t.paint.get("model-emissive-strength").constantOr(0);B=qd(p.expandedProjMatrix,n.globalMatrix,Zg,null,s,K,le.baseColorFactor,ee.emissiveFactor,le.metallicFactor,le.roughnessFactor,ee,Q,t,d,void 0,void 0,void 0,1,k.fixedDefines.includes("LIGHTING_3D_MODE")),w&&(m.shadowUniformsInitialized?k.setShadowUniformValues(g,w.getShadowUniformValues()):(w.setupShadows(p.toUnwrapped(),k,"model-tile"),m.shadowUniformsInitialized=!0)),$=G.shouldRenderCutoff||K<1||ee.alphaMode!=="OPAQUE"?yt.alphaBlended:yt.unblended}s.uploadCommonUniforms(g,k,p.toUnwrapped(),null,G);const te=M.material.doubleSided?_t.disabled:_t.backCCW;if(Z)L.push(l.instancedDataBuffer),k.draw(s,g.gl.TRIANGLES,S,mt.disabled,$,te,B,t.id,M.vertexBuffer,M.indexBuffer,M.segments,t.paint,s.transform.zoom,void 0,L,l.instancedDataArray.length);else{const ee=x?"u_instance":"u_normal_matrix";for(let le=0;le<l.instancedDataArray.length;++le)B[ee]=new Float32Array(l.instancedDataArray.arrayBuffer,64*le,16),k.draw(s,g.gl.TRIANGLES,S,mt.disabled,$,te,B,t.id,M.vertexBuffer,M.indexBuffer,M.segments,t.paint,s.transform.zoom,void 0,L)}}if(n.children)for(const M of n.children)Jc(s,t,M,l,d,p,m)}function ha(s,t,n,l,d){const p=s.node;if(p.lodMeshes&&p.lodMeshes.length>0)if(s.targetLod<0)s.targetLod=t>l?1:0;else{const m=d>0?n/1e3/d:1;s.targetLod=u.as(t>l?s.targetLod+m:s.targetLod-m,0,1)}else s.targetLod=0}function Yd(s,t,n,l){if(!n.modelManager)return!0;const d=n.modelManager;if(!n.shadowRenderer)return!0;const p=n.shadowRenderer,m=t.aabb;let g=!0,x=s.maxHeight;if(x===0){let S=0;for(const A in s.instancesPerModel){const I=d.getModel(A,l);I?S=Math.max(S,Math.max(Math.max(I.aabb.max[0],I.aabb.max[1]),I.aabb.max[2])):g=!1}x=s.maxScale*S*1.41+s.maxVerticalOffset,g&&(s.maxHeight=x)}m.max[2]=x,m.min[2]+=s.terrainElevationMin,m.max[2]+=s.terrainElevationMax,u.ad(m.min,m.min,t.tileMatrix),u.ad(m.max,m.max,t.tileMatrix);const w=m.intersects(p.getCurrentCascadeFrustum());return n.currentShadowCascade===0&&(s.isInsideFirstShadowMapFrustum=w===2),w===0}function _l(s,t){const n=s.uniformValues.u_cutoff_params[0],l=s.uniformValues.u_cutoff_params[1],d=s.uniformValues.u_cutoff_params[2],p=s.uniformValues.u_cutoff_params[3];return l===n||p===d?1:u.as(((t-n)/(l-n)-d)/(p-d),0,1)}function sh(s,t,n,l){if(t.pitch<20)return 1;const d=t.getWorldToCameraMatrix();u.aP(d,d,s);const p=u.cv(n.min[0],n.min[1],n.min[2],1);let m=u.aO(u.cw(),p,d),g=m,x=m;p[1]=n.max[1],m=u.aO(u.cw(),p,d),g=m[1]<g[1]?m:g,x=m[1]>x[1]?m:x,p[0]=n.max[0],m=u.aO(u.cw(),p,d),g=m[1]<g[1]?m:g,x=m[1]>x[1]?m:x,p[1]=n.min[1],m=u.aO(u.cw(),p,d),g=m[1]<g[1]?m:g,x=m[1]>x[1]?m:x;const w=u.as(l[0],0,1),S=100*t.pixelsPerMeter*u.as(l[1],0,1),A=u.as(l[2],0,1),I=u.cx(u.cw(),g,x,w),M=Math.tan(.5*t.fovX),D=-I[2]*M;if(S===0)return I[1]<-Math.abs(D)?A:1;const L=(-Math.abs(D)-I[1])/S,k=u.as(u.ai(1,A,L),A,1);
8return u.ai(1,k,u.as((t.pitch-20)/20,0,1))}var Da=`
9#define EPSILON 0.0000001
10#define PI 3.141592653589793
11#ifdef RENDER_CUTOFF
12float cutoff_opacity(vec4 cutoff_params,float depth) {float near=cutoff_params.x;float far=cutoff_params.y;float cutoffStart=cutoff_params.z;float cutoffEnd=cutoff_params.w;float linearDepth=(depth-near)/(far-near);return clamp((linearDepth-cutoffStart)/(cutoffEnd-cutoffStart),0.0,1.0);}
13#endif`,Qc=`
14#if defined(VIEWPORT_ORIGIN_TOP_LEFT) || defined(FLIP_Y)
15#define FLIP_VIEWPORT_UV_Y(uv) (uv).y=1.0-(uv).y
16#else
17#define FLIP_VIEWPORT_UV_Y(uv)
18#endif
19#ifdef DUAL_SOURCE_BLENDING
20layout(location=0,index=0) out vec4 glFragColor;layout(location=0,index=1) out vec4 glFragColorSrc1;
21#elif defined(FLOAT_RENDER_TARGET)
22layout(location=0) out highp vec4 glFragColor;
23#else
24layout(location=0) out vec4 glFragColor;
25#endif
26#ifdef USE_MRT1
27layout(location=1) out vec4 out_Target1;
28#endif
29highp float unpack_depth(highp vec4 rgba_depth)
30{const highp vec4 bit_shift=vec4(1.0/(255.0*255.0*255.0),1.0/(255.0*255.0),1.0/255.0,1.0);return dot(rgba_depth,bit_shift)*2.0-1.0;}highp vec4 pack_depth(highp float ndc_z) {
31#ifdef CLIP_ZERO_TO_ONE
32highp float depth=ndc_z;
33#else
34highp float depth=ndc_z*0.5+0.5;
35#endif
36const highp vec4 bit_shift=vec4(255.0*255.0*255.0,255.0*255.0,255.0,1.0);const highp vec4 bit_mask =vec4(0.0,1.0/255.0,1.0/255.0,1.0/255.0);highp vec4 res=fract(depth*bit_shift);res-=res.xxyz*bit_mask;return res;}const float DITHER_THRESHOLDS[16]=float[16](
371.0/17.0, 9.0/17.0, 3.0/17.0,11.0/17.0,13.0/17.0, 5.0/17.0,15.0/17.0, 7.0/17.0,4.0/17.0,12.0/17.0, 2.0/17.0,10.0/17.0,16.0/17.0, 8.0/17.0,14.0/17.0, 6.0/17.0
38);int viewport_dither_index(vec2 fragCoordXY) {return (int(fragCoordXY.x) % 4)*4+(int(fragCoordXY.y) % 4);}
39#ifdef DEBUG_WIREFRAME
40#define HANDLE_WIREFRAME_DEBUG \\
41glFragColor=vec4(0.7,0.0,0.0,0.7); \\
42gl_FragDepth=gl_FragCoord.z-0.0001;
43#else
44#define HANDLE_WIREFRAME_DEBUG
45#endif
46#ifdef RENDER_CUTOFF
47uniform highp vec4 u_cutoff_params;in float v_cutoff_opacity;
48#endif
49vec4 textureLodCustom(sampler2D image,highp vec2 pos,highp vec2 lod_coord) {highp vec2 size=vec2(textureSize(image,0));highp vec2 dx=dFdx(lod_coord.xy*size);highp vec2 dy=dFdy(lod_coord.xy*size);highp float delta_max_sqr=max(dot(dx,dx),dot(dy,dy));highp float lod=0.5*log2(delta_max_sqr);return textureLod(image,pos,lod);}vec4 premultiplyColor(vec3 nonPremultipliedColor,float a) {return vec4(nonPremultipliedColor*a,a);}vec3 unpremultiplyColor(vec4 premultipliedColor) {if (premultipliedColor.a > 0.0) {return premultipliedColor.rgb/premultipliedColor.a;}return premultipliedColor.rgb;}vec3 applyLUT(highp sampler3D lut,vec3 col) {vec3 size=vec3(textureSize(lut,0));vec3 uvw=(col.rbg*float(size-1.0)+0.5)/size;return texture(lut,uvw).rgb;}vec4 applyLUT(highp sampler3D lut,vec4 premultipliedColor) {return premultiplyColor(applyLUT(lut,unpremultiplyColor(premultipliedColor)),premultipliedColor.a);}`,_m=`
50#define EXTENT 8192.0
51#define RAD_TO_DEG 180.0/PI
52#define DEG_TO_RAD PI/180.0
53#define GLOBE_RADIUS EXTENT/PI/2.0
54float wrap(float n,float min,float max) {float d=max-min;float w=mod(mod(n-min,d)+d,d)+min;return (w==min) ? max : w;}
55#ifdef PROJECTION_GLOBE_VIEW
56vec3 mercator_tile_position(mat4 matrix,vec2 tile_anchor,vec3 tile_id,vec2 mercator_center) {
57#ifndef PROJECTED_POS_ON_VIEWPORT
58float tiles=tile_id.z;vec2 mercator=(tile_anchor/EXTENT+tile_id.xy)/tiles;mercator-=mercator_center;mercator.x=wrap(mercator.x,-0.5,0.5);vec4 mercator_tile=vec4(mercator.xy*EXTENT,EXTENT/(2.0*PI),1.0);mercator_tile=matrix*mercator_tile;return mercator_tile.xyz;
59#else
60return vec3(0.0);
61#endif
62}vec3 mix_globe_mercator(vec3 globe,vec3 mercator,float t) {return mix(globe,mercator,t);}mat3 globe_mercator_surface_vectors(vec3 pos_normal,vec3 up_dir,float zoom_transition) {vec3 normal=zoom_transition==0.0 ? pos_normal : normalize(mix(pos_normal,up_dir,zoom_transition));vec3 xAxis=normalize(vec3(normal.z,0.0,-normal.x));vec3 yAxis=normalize(cross(normal,xAxis));return mat3(xAxis,yAxis,normal);}
63#endif
64vec2 unpack_float(const float packedValue) {int packedIntValue=int(packedValue);int v0=packedIntValue/256;return vec2(v0,packedIntValue-v0*256);}vec4 decode_color(const vec2 encodedColor) {return vec4(
65unpack_float(encodedColor[0])/255.0,unpack_float(encodedColor[1])/255.0
66);}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 vec2 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);
66return (units_to_pixels*pos+offset)/pattern_size;}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) {return get_pattern_pos(pixel_coord_upper,pixel_coord_lower,pattern_size,vec2(tile_units_to_pixels),pos);}float mercatorXfromLng(float lng) {return (180.0+lng)/360.0;}float mercatorYfromLat(float lat) {return (180.0-(RAD_TO_DEG*log(tan(PI/4.0+lat/2.0*DEG_TO_RAD))))/360.0;}vec3 latLngToECEF(vec2 latLng) {latLng=DEG_TO_RAD*latLng;float cosLat=cos(latLng[0]);float sinLat=sin(latLng[0]);float cosLng=cos(latLng[1]);float sinLng=sin(latLng[1]);float sx=cosLat*sinLng*GLOBE_RADIUS;float sy=-sinLat*GLOBE_RADIUS;float sz=cosLat*cosLng*GLOBE_RADIUS;return vec3(sx,sy,sz);}
67#ifdef RENDER_CUTOFF
68uniform vec4 u_cutoff_params;out float v_cutoff_opacity;
69#endif
70const vec4 AWAY=vec4(-1000.0,-1000.0,-1000.0,1);const float skirtOffset=24575.0;vec3 decomposeToPosAndSkirt(ivec2 posWithComposedSkirt)
71{float skirt=float(float(posWithComposedSkirt.x) >=skirtOffset);vec2 pos=vec2(posWithComposedSkirt)-vec2(skirt*skirtOffset,0.0);return vec3(pos,skirt);}
72#ifndef HAS_SHADER_STORAGE_BLOCK_material_buffer
73#define GET_ATTRIBUTE_float(attrib,matInfo,attrib_id) attrib
74#define GET_ATTRIBUTE_vec4(attrib,matInfo,attrib_id) attrib
75#define GET_ATTRIBUTE_vec2(attrib,matInfo,attrib_id) attrib
76#define DECLARE_MATERIAL_TABLE_INFO
77#endif`,Kd="in highp vec3 a_pos_3f;uniform lowp mat4 u_matrix;out highp vec3 v_uv;void main() {const mat3 half_neg_pi_around_x=mat3(1.0,0.0, 0.0,0.0,0.0,-1.0,0.0,1.0, 0.0);v_uv=half_neg_pi_around_x*a_pos_3f;vec4 pos=u_matrix*vec4(a_pos_3f,1.0);gl_Position=pos.xyww;}",Jd=`
78#define ELEVATION_SCALE 7.0
79#define ELEVATION_OFFSET 450.0
80#ifdef PROJECTION_GLOBE_VIEW
81uniform vec3 u_tile_tl_up;uniform vec3 u_tile_tr_up;uniform vec3 u_tile_br_up;uniform vec3 u_tile_bl_up;uniform float u_tile_up_scale;
82#endif
83vec3 elevationVector(vec2 pos) {
84#ifdef PROJECTION_GLOBE_VIEW
85vec2 uv=pos/EXTENT;vec3 up=normalize(mix(
86mix(u_tile_tl_up,u_tile_tr_up,uv.xxx),mix(u_tile_bl_up,u_tile_br_up,uv.xxx),uv.yyy));return up*u_tile_up_scale;
87#else
88return vec3(0,0,1);
89#endif
90}
91#ifdef TERRAIN
92uniform highp sampler2D u_dem;uniform highp sampler2D u_dem_prev;uniform vec2 u_dem_tl;uniform vec2 u_dem_tl_prev;uniform float u_dem_scale;uniform float u_dem_scale_prev;uniform float u_dem_size;uniform float u_dem_lerp;uniform float u_exaggeration;uniform float u_meter_to_dem;uniform mat4 u_label_plane_matrix_inv;vec4 tileUvToDemSample(vec2 uv,float dem_size,float dem_scale,vec2 dem_tl) {vec2 pos=dem_size*(uv*dem_scale+dem_tl)+1.0;vec2 f=fract(pos);return vec4((pos-f+0.5)/(dem_size+2.0),f);}float currentElevation(vec2 apos) {
93#ifdef TERRAIN_DEM_FLOAT_FORMAT
94vec2 pos=(u_dem_size*(apos/8192.0*u_dem_scale+u_dem_tl)+1.5)/(u_dem_size+2.0);return u_exaggeration*texture(u_dem,pos).r;
95#else
96float dd=1.0/(u_dem_size+2.0);vec4 r=tileUvToDemSample(apos/8192.0,u_dem_size,u_dem_scale,u_dem_tl);vec2 pos=r.xy;vec2 f=r.zw;float tl=texture(u_dem,pos).r;float tr=texture(u_dem,pos+vec2(dd,0)).r;float bl=texture(u_dem,pos+vec2(0,dd)).r;float br=texture(u_dem,pos+vec2(dd,dd)).r;return u_exaggeration*mix(mix(tl,tr,f.x),mix(bl,br,f.x),f.y);
97#endif
98}float prevElevation(vec2 apos) {
99#ifdef TERRAIN_DEM_FLOAT_FORMAT
100vec2 pos=(u_dem_size*(apos/8192.0*u_dem_scale_prev+u_dem_tl_prev)+1.5)/(u_dem_size+2.0);return u_exaggeration*texture(u_dem_prev,pos).r;
101#else
102float dd=1.0/(u_dem_size+2.0);vec4 r=tileUvToDemSample(apos/8192.0,u_dem_size,u_dem_scale_prev,u_dem_tl_prev);vec2 pos=r.xy;vec2 f=r.zw;float tl=texture(u_dem_prev,pos).r;float tr=texture(u_dem_prev,pos+vec2(dd,0)).r;float bl=texture(u_dem_prev,pos+vec2(0,dd)).r;float br=texture(u_dem_prev,pos+vec2(dd,dd)).r;return u_exaggeration*mix(mix(tl,tr,f.x),mix(bl,br,f.x),f.y);
103#endif
104}vec4 fourSample(vec2 pos,vec2 off) {float tl=texture(u_dem,pos).r;float tr=texture(u_dem,pos+vec2(off.x,0.0)).r;float bl=texture(u_dem,pos+vec2(0.0,off.y)).r;float br=texture(u_dem,pos+off).r;return vec4(tl,tr,bl,br);}float flatElevation(vec2 pack) {vec2 apos=floor(pack/8.0);vec2 span=10.0*(pack-apos*8.0);vec2 uvTex=(apos-vec2(1.0,1.0))/8190.0;float size=u_dem_size+2.0;float dd=1.0/size;vec2 pos=u_dem_size*(uvTex*u_dem_scale+u_dem_tl)+1.0;vec2 f=fract(pos);pos=(pos-f+0.5)*dd;vec4 h=fourSample(pos,vec2(dd));float z=mix(mix(h.x,h.y,f.x),mix(h.z,h.w,f.x),f.y);vec2 w=floor(0.5*(span*u_meter_to_dem-1.0));vec2 d=dd*w;h=fourSample(pos-d,2.0*d+vec2(dd));vec4 diff=abs(h.xzxy-h.ywzw);vec2 slope=min(vec2(0.25),u_meter_to_dem*0.5*(diff.xz+diff.yw)/(2.0*w+vec2(1.0)));vec2 fix=slope*span;float base=z+max(fix.x,fix.y);return u_exaggeration*base;}float elevationFromUint16(float word) {return u_exaggeration*(word/ELEVATION_SCALE-ELEVATION_OFFSET);}
105#endif
106float elevation(vec2 apos) {
107#ifdef TERRAIN
108#ifdef ZERO_EXAGGERATION
109return 0.0;
110#endif
111#ifdef TERRAIN_VERTEX_MORPHING
112float nextElevation=currentElevation(apos);float prevElevation=prevElevation(apos);return mix(prevElevation,nextElevation,u_dem_lerp);
113#else
114return currentElevation(apos);
115#endif
116#else
117return 0.0;
118#endif
119}
120#ifdef DEPTH_OCCLUSION
121uniform highp sampler2D u_depth;uniform highp vec2 u_depth_size_inv;uniform highp vec2 u_depth_range_unpack;uniform highp float u_occluder_half_size;uniform highp float u_occlusion_depth_offset;
122#ifdef DEPTH_D24
123float unpack_depth(float depth) {return depth*u_depth_range_unpack.x+u_depth_range_unpack.y;}vec4 unpack_depth4(vec4 depth) {return depth*u_depth_range_unpack.x+vec4(u_depth_range_unpack.y);}
124#else
125highp float unpack_depth_rgba(vec4 rgba_depth)
126{const highp vec4 bit_shift=vec4(1.0/(255.0*255.0*255.0),1.0/(255.0*255.0),1.0/255.0,1.0);return dot(rgba_depth,bit_shift)*2.0-1.0;}
127#endif
128bool isOccluded(vec4 frag) {vec3 coord=frag.xyz/frag.w;
129#ifdef CLIP_ZERO_TO_ONE
130coord.z=-1.0+2.0*coord.z; 
131#endif
132#ifdef DEPTH_D24
133float depth=unpack_depth(texture(u_depth,(coord.xy+1.0)*0.5).r);
134#else
135float depth=unpack_depth_rgba(texture(u_depth,(coord.xy+1.0)*0.5));
136#endif
137return coord.z+u_occlusion_depth_offset > depth;}highp vec4 getCornerDepths(vec2 coord) {highp vec3 df=vec3(u_occluder_half_size*u_depth_
137size_inv,0.0);highp vec2 uv=0.5*coord.xy+0.5;
138#ifdef DEPTH_D24
139highp vec4 depth=vec4(
140texture(u_depth,uv-df.xz).r,texture(u_depth,uv+df.xz).r,texture(u_depth,uv-df.zy).r,texture(u_depth,uv+df.zy).r
141);depth=unpack_depth4(depth);
142#else
143highp vec4 depth=vec4(
144unpack_depth_rgba(texture(u_depth,uv-df.xz)),unpack_depth_rgba(texture(u_depth,uv+df.xz)),unpack_depth_rgba(texture(u_depth,uv-df.zy)),unpack_depth_rgba(texture(u_depth,uv+df.zy))
145);
146#endif
147return depth;}highp float occlusionFadeMultiSample(vec4 frag) {highp vec3 coord=frag.xyz/frag.w;highp vec2 uv=0.5*coord.xy+0.5;
148#ifdef CLIP_ZERO_TO_ONE
149coord.z=-1.0+2.0*coord.z; 
150#endif
151int NX=3;int NY=4;highp vec2 df=u_occluder_half_size*u_depth_size_inv;highp vec2 oneStep=2.0*u_occluder_half_size*u_depth_size_inv/vec2(NX-1,NY-1);highp float res=0.0;for (int y=0; y < NY;++y) {for (int x=0; x < NX;++x) {
152#ifdef DEPTH_D24
153highp float depth=unpack_depth(texture(u_depth,uv-df+vec2(float(x)*oneStep.x,float(y)*oneStep.y)).r);
154#else
155highp float depth=unpack_depth_rgba(texture(u_depth,uv-df+vec2(float(x)*oneStep.x,float(y)*oneStep.y)));
156#endif
157res+=1.0-clamp(300.0*(coord.z+u_occlusion_depth_offset-depth),0.0,1.0);}}res=clamp(2.0*res/float(NX*NY)-0.5,0.0,1.0);return res;}highp float occlusionFade(vec4 frag) {highp vec3 coord=frag.xyz/frag.w;
158#ifdef CLIP_ZERO_TO_ONE
159coord.z=-1.0+2.0*coord.z; 
160#endif
161highp vec4 depth=getCornerDepths(coord.xy);return dot(vec4(0.25),vec4(1.0)-clamp(300.0*(vec4(coord.z+u_occlusion_depth_offset)-depth),0.0,1.0));}
162#else
163bool isOccluded(vec4 frag) { return false; }highp float occlusionFade(vec4 frag) { return 1.0; }highp float occlusionFadeMultiSample(vec4 frag) { return 1.0; }
164#endif`,ah=`#ifdef FOG
165uniform mediump vec4 u_fog_color;uniform mediump vec2 u_fog_range;uniform mediump float u_fog_horizon_blend;uniform mediump mat4 u_fog_matrix;out vec3 v_fog_pos;float fog_range(float depth) {return (depth-u_fog_range[0])/(u_fog_range[1]-u_fog_range[0]);}float fog_horizon_blending(vec3 camera_dir) {float t=max(0.0,camera_dir.z/u_fog_horizon_blend);return u_fog_color.a*exp(-3.0*t*t);}float fog_opacity(float t) {const float decay=6.0;float falloff=1.0-min(1.0,exp(-decay*t));falloff*=falloff*falloff;return u_fog_color.a*min(1.0,1.00747*falloff);}vec3 fog_position(vec3 pos) {return (u_fog_matrix*vec4(pos,1.0)).xyz;}vec3 fog_position(vec2 pos) {return fog_position(vec3(pos,0.0));}float fog(vec3 pos) {float depth=length(pos);float opacity=fog_opacity(fog_range(depth));return opacity*fog_horizon_blending(pos/depth);}
166#endif`,gm=`#ifdef FOG
167uniform mediump vec4 u_fog_color;uniform mediump vec2 u_fog_range;uniform mediump float u_fog_horizon_blend;uniform mediump vec2 u_fog_vertical_limit;uniform mediump float u_fog_temporal_offset;in vec3 v_fog_pos;uniform highp vec3 u_frustum_tl;uniform highp vec3 u_frustum_tr;uniform highp vec3 u_frustum_br;uniform highp vec3 u_frustum_bl;uniform highp vec3 u_globe_pos;uniform highp float u_globe_radius;uniform highp vec2 u_viewport;uniform float u_globe_transition;uniform int u_is_globe;float fog_range(float depth) {return (depth-u_fog_range[0])/(u_fog_range[1]-u_fog_range[0]);}float fog_horizon_blending(vec3 camera_dir) {float t=max(0.0,camera_dir.z/u_fog_horizon_blend);return u_fog_color.a*exp(-3.0*t*t);}float fog_opacity(float t) {const float decay=6.0;float falloff=1.0-min(1.0,exp(-decay*t));falloff*=falloff*falloff;return u_fog_color.a*min(1.0,1.00747*falloff);}float globe_glow_progress() {highp vec2 uv=gl_FragCoord.xy/u_viewport;FLIP_VIEWPORT_UV_Y(uv);highp vec3 ray_dir=mix(
168mix(u_frustum_tl,u_frustum_tr,uv.x),mix(u_frustum_bl,u_frustum_br,uv.x),1.0-uv.y);highp vec3 dir=normalize(ray_dir);highp vec3 closest_point=dot(u_globe_pos,dir)*dir;highp float sdf=length(closest_point-u_globe_pos)/u_globe_radius;return sdf+PI*0.5;}float fog_opacity(vec3 pos) {float depth=length(pos);return fog_opacity(fog_range(depth));}vec3 fog_apply(vec3 color,vec3 pos,float opacity_limit) {float depth=length(pos);float opacity;if (u_is_globe==1) {float glow_progress=globe_glow_progress();float t=mix(glow_progress,depth,u_globe_transition);opacity=fog_opacity(fog_range(t));} else {opacity=fog_opacity(fog_range(depth));opacity*=fog_horizon_blending(pos/depth);}return mix(color,u_fog_color.rgb,min(opacity,opacity_limit));}vec3 fog_apply(vec3 color,vec3 pos) {return fog_apply(color,pos,1.0);}vec4 fog_apply_from_vert(vec4 color,float fog_opac) {float alpha=EPSILON+color.a;color.rgb=mix(color.rgb/alpha,u_fog_color.rgb,fog_opac)*alpha;return color;}
168vec3 fog_apply_sky_gradient(vec3 camera_ray,vec3 sky_color) {float horizon_blend=fog_horizon_blending(normalize(camera_ray));return mix(sky_color,u_fog_color.rgb,horizon_blend);}vec4 fog_apply_premultiplied(vec4 color,vec3 pos) {float alpha=EPSILON+color.a;color.rgb=fog_apply(color.rgb/alpha,pos)*alpha;return color;}vec4 fog_apply_premultiplied(vec4 color,vec3 pos,float heightMeters) {float verticalProgress=(u_fog_vertical_limit.x > 0.0 || u_fog_vertical_limit.y > 0.0) ? smoothstep(u_fog_vertical_limit.x,u_fog_vertical_limit.y,heightMeters) : 0.0;float opacityLimit=1.0-smoothstep(0.9,1.0,fog_opacity(pos));return mix(fog_apply_premultiplied(color,pos),color,min(verticalProgress,opacityLimit));}vec3 fog_dither(vec3 color) {return color;}vec4 fog_dither(vec4 color) {return vec4(fog_dither(color.rgb),color.a);}
169#endif`,Qd=`
170#ifdef LIGHTING_3D_MODE
171uniform mediump vec3 u_lighting_ambient_color;uniform mediump vec3 u_lighting_directional_dir;uniform mediump vec3 u_lighting_directional_color;uniform mediump vec3 u_ground_radiance;float calculate_ambient_directional_factor(vec3 normal) {float NdotL=dot(normal,u_lighting_directional_dir);const float factor_reduction_max=0.3;float dir_luminance=dot(u_lighting_directional_color,vec3(0.2126,0.7152,0.0722));float directional_factor_min=1.0-factor_reduction_max*min(dir_luminance,1.0);float ambient_directional_factor=mix(directional_factor_min,1.0,min((NdotL+1.0),1.0));const float vertical_factor_min=0.92;float vertical_factor=mix(vertical_factor_min,1.0,normal.z*0.5+0.5);return vertical_factor*ambient_directional_factor;}vec3 linearProduct(vec3 srgbIn,vec3 k) {return srgbIn*pow(k,vec3(1./2.2));}vec3 apply_lighting(vec3 color,vec3 normal,float dir_factor) {float ambient_directional_factor=calculate_ambient_directional_factor(normal);vec3 ambient_contrib=ambient_directional_factor*u_lighting_ambient_color;vec3 directional_contrib=u_lighting_directional_color*dir_factor;return linearProduct(color,ambient_contrib+directional_contrib);}vec4 apply_lighting(vec4 color,vec3 normal,float dir_factor) {return vec4(apply_lighting(color.rgb,normal,dir_factor),color.a);}vec3 apply_lighting(vec3 color,vec3 normal) {float dir_factor=max(dot(normal,u_lighting_directional_dir),0.0);return apply_lighting(color.rgb,normal,dir_factor);}vec4 apply_lighting(vec4 color,vec3 normal) {float dir_factor=max(dot(normal,u_lighting_directional_dir),0.0);return vec4(apply_lighting(color.rgb,normal,dir_factor),color.a);}vec3 apply_lighting_ground(vec3 color) {return color*u_ground_radiance;}vec4 apply_lighting_ground(vec4 color) {return vec4(apply_lighting_ground(color.rgb),color.a);}float calculate_NdotL(vec3 normal) {const float ext=0.70710678118;return (clamp(dot(normal,u_lighting_directional_dir),-ext,1.0)+ext)/(1.0+ext);}vec4 apply_lighting_with_emission_ground(vec4 color,float emissive_strength) {return mix(apply_lighting_ground(color),color,emissive_strength);}vec3 compute_flood_lighting(vec3 flood_light_color,float fully_occluded_factor,float occlusion,vec3 ground_shadow_factor) {vec3 fully_occluded_color=flood_light_color*mix(ground_shadow_factor,vec3(1.0),fully_occluded_factor);float occlusion_ramp=smoothstep(0.0,0.2,1.0-occlusion);return mix(fully_occluded_color,flood_light_color,occlusion_ramp);}vec3 compute_emissive_draped(vec3 unlit_color,float fully_occluded_factor,float occlusion,vec3 ground_shadow_factor) {vec3 fully_occluded_color=unlit_color*mix(ground_shadow_factor,vec3(1.0),fully_occluded_factor);return mix(fully_occluded_color,unlit_color,1.0-occlusion);}
172#endif`,ym=`#ifdef RASTER_ARRAY
173uniform highp sampler2D u_image0;uniform sampler2D u_image1;const vec4 NODATA=vec4(1);ivec4 _raTexLinearCoord(highp vec2 texCoord,highp vec2 texResolution,out highp vec2 fxy) {texCoord=texCoord*texResolution-0.5;fxy=fract(texCoord);texCoord-=fxy;return ivec4(texCoord.xxyy+vec2(1.5,0.5).xyxy);}vec2 _raTexLinearMix(highp vec2 fxy,highp vec4 colorMix,highp float colorOffset,highp vec4 t00,highp vec4 t10,highp vec4 t01,highp vec4 t11) {vec2 c00=t00==NODATA ? vec2(0) : vec2(colorOffset+dot(t00,colorMix),1);vec2 c10=t10==NODATA ? vec2(0) : vec2(colorOffset+dot(t10,colorMix),1);vec2 c01=t01==NODATA ? vec2(0) : vec2(colorOffset+dot(t01,colorMix),1);vec2 c11=t11==NODATA ? vec2(0) : vec2(colorOffset+dot(t11,colorMix),1);return mix(mix(c01,c11,fxy.x),mix(c00,c10,fxy.x),fxy.y);}
173vec2 raTexture2D_image0_linear(highp vec2 texCoord,highp vec2 texResolution,highp vec4 colorMix,highp float colorOffset) {vec2 fxy;ivec4 c=_raTexLinearCoord(texCoord,texResolution,fxy);return _raTexLinearMix(fxy,colorMix,colorOffset,texelFetch(u_image0,c.yz,0),texelFetch(u_image0,c.xz,0),texelFetch(u_image0,c.yw,0),texelFetch(u_image0,c.xw,0)
174);}vec2 raTexture2D_image1_linear(highp vec2 texCoord,highp vec2 texResolution,highp vec4 colorMix,highp float colorOffset) {vec2 fxy;ivec4 c=_raTexLinearCoord(texCoord,texResolution,fxy);return _raTexLinearMix(fxy,colorMix,colorOffset,texelFetch(u_image1,c.yz,0),texelFetch(u_image1,c.xz,0),texelFetch(u_image1,c.yw,0),texelFetch(u_image1,c.xw,0)
175);}vec2 raTexture2D_image0_nearest(highp vec2 texCoord,highp vec2 texResolution,highp vec4 colorMix,highp float colorOffset) {vec4 t=texelFetch(u_image0,ivec2(texCoord*texResolution),0);return t==NODATA ? vec2(0) : vec2(colorOffset+dot(t,colorMix),1);}vec2 raTexture2D_image1_nearest(highp vec2 texCoord,highp vec2 texResolution,highp vec4 colorMix,highp float colorOffset) {vec4 t=texelFetch(u_image1,ivec2(texCoord*texResolution),0);return t==NODATA ? vec2(0) : vec2(colorOffset+dot(t,colorMix),1);}
176#endif`,xm=`#ifdef RENDER_SHADOWS
177uniform mediump vec3 u_shadow_direction;uniform highp vec3 u_shadow_normal_offset;vec3 shadow_normal_offset(vec3 normal) {float tileInMeters=u_shadow_normal_offset[0];vec3 n=vec3(-normal.xy,tileInMeters*normal.z);float dotScale=min(1.0-dot(normal,u_shadow_direction),1.0)*0.5+0.5;return n*dotScale;}vec3 shadow_normal_offset_model(vec3 normal) {vec3 transformed_normal=vec3(-normal.xy,normal.z);float NDotL=dot(normalize(transformed_normal),u_shadow_direction);float dotScale=min(1.0-NDotL,1.0)*0.5+0.5;return normal*dotScale;}float shadow_normal_offset_multiplier0() {return u_shadow_normal_offset[1];}float shadow_normal_offset_multiplier1() {return u_shadow_normal_offset[2];}
178#endif`,ef=`#ifdef RENDER_SHADOWS
179precision highp sampler2DShadow;uniform sampler2DShadow u_shadowmap_0;uniform sampler2DShadow u_shadowmap_1;uniform float u_shadow_intensity;uniform float u_shadow_map_resolution;uniform float u_shadow_texel_size;uniform highp vec3 u_shadow_normal_offset;uniform vec2 u_fade_range;uniform mediump vec3 u_shadow_direction;uniform highp vec3 u_shadow_bias;highp vec2 shadow_map_ndc_to_uv(highp vec2 ndc_xy) {
180#ifdef SHADOW_MAP_FLIP_Y
181return ndc_xy*vec2(0.5,-0.5)+0.5;
182#else
183return ndc_xy*0.5+0.5;
184#endif
185}highp vec3 shadow_map_ndc_to_sample_space(highp vec3 ndc) {
186#ifdef CLIP_ZERO_TO_ONE
187return vec3(shadow_map_ndc_to_uv(ndc.xy),ndc.z);
188#else
189return vec3(shadow_map_ndc_to_uv(ndc.xy),ndc.z*0.5+0.5);
190#endif
191}float shadow_sample(sampler2DShadow shadowmap,highp vec3 pos,highp float bias) {
192#ifdef CLIP_ZERO_TO_ONE
193highp vec3 coord=vec3(shadow_map_ndc_to_uv(pos.xy),pos.z-bias);
194#else
195highp vec3 coord=vec3(shadow_map_ndc_to_uv(pos.xy),pos.z*0.5+0.5-bias);
196#endif
197return texture(shadowmap,coord);}float shadow_occlusion(highp vec4 light_view_pos0,highp vec4 light_view_pos1,float view_depth,highp float bias) {light_view_pos0.xyz/=light_view_pos0.w;
198#ifdef SHADOWS_SINGLE_CASCADE
199vec2 abs_bounds=abs(light_view_pos0.xy);if (abs_bounds.x >=1.0 || abs_bounds.y >=1.0) {return 0.0;}return shadow_sample(u_shadowmap_0,light_view_pos0.xyz,bias);
200#else
201light_view_pos1.xyz/=light_view_pos1.w;vec4 abs_bounds=abs(vec4(light_view_pos0.xy,light_view_pos1.xy));if (abs_bounds.x < 1.0 && abs_bounds.y < 1.0) {return shadow_sample(u_shadowmap_0,light_view_pos0.xyz,bias);}if (abs_bounds.z >=1.0 || abs_bounds.w >=1.0) {return 0.0;}float occlusion1=shadow_sample(u_shadowmap_1,light_view_pos1.xyz,bias);return clamp(mix(occlusion1,0.0,smoothstep(u_fade_range.x,u_fade_range.y,view_depth)),0.0,1.0);
202#endif
203}highp float calculate_shadow_bias(float NDotL) {
204#ifdef NORMAL_OFFSET
205return 0.5*u_shadow_bias.x;
206#else
207return 0.5*(u_shadow_bias.x+clamp(u_shadow_bias.y*tan(acos(NDotL)),0.0,u_shadow_bias.z));
208#endif
209}float shadowed_light_factor_normal(vec3 N,highp vec4 light_view_pos0,highp vec4 light_view_pos1,float view_depth) {float NDotL=dot(N,u_shadow_direction);float bias=calculate_shadow_bias(NDotL);float occlusion=shadow_occlusion(light_view_pos0,light_view_pos1,view_depth,bias);return mix(0.0,(1.0-(u_shadow_intensity*occlusion))*NDotL,step(0.0,NDotL));}float shadowed_light_factor_normal_opacity(vec3 N,highp vec4 light_view_pos0,highp vec4 light_view_pos1,float view_depth,float shadow_opacity) {float NDotL=dot(N,u_shadow_direction);float bias=calculate_shadow_bias(NDotL);float occlusion=shadow_occlusion(light_view_pos0,light_view_pos1,view_depth,bias)*shadow_opacity;return mix(0.0,(1.0-(u_shadow_intensity*occlusion))*NDotL,step(0.0,NDotL));}float shadowed_light_factor_normal_unbiased(vec3 N,highp vec4 light_view_pos0,highp vec4 light_view_pos1,float view_depth) {float NDotL=dot(N,u_shadow_direction);float bias=0.0;float occlusion=shadow_occlusion(light_view_pos0,light_view_pos1,view_depth,bias);return mix(0.0,(1.0-(u_shadow_intensity*occlusion))*NDotL,step(0.0,NDotL));}highp vec2 compute_receiver_plane_depth_bias(highp vec3 pos_dx,highp vec3 pos_dy)
210{highp vec2 biasUV=vec2(
211pos_dy.y*pos_dx.z-pos_dx.y*pos_dy.z,pos_dx.x*pos_dy.z-pos_dy.x*pos_dx.z);biasUV*=1.0/((pos_dx.x*pos_dy.y)-(pos_dx.y*pos_dy.x));return biasUV;}float shadowed_light_factor_plane_bias(highp vec4 light_view_pos0,highp vec4 light_view_pos1,float view_depth) {highp vec3 light_view_pos0_xyz=shadow_map_ndc_to_sample_space(light_view_pos0.xyz/light_view_pos0.w);highp vec3 light_view_pos0_ddx=dFdx(light_view_pos0_xyz);highp vec3 light_view_pos0_ddy=dFdy(light_view_pos0_xyz);highp vec2 plane_depth_bias=compute_receiver_plane_depth_bias(light_view_pos0_ddx,light_view_pos0_ddy);highp float bias=dot(vec2(u_shadow_texel_size,u_shadow_texel_size),plane_depth_bias)+0.0001;float occlusion=shadow_occlusion(light_view_pos0,light_view_pos1,view_depth,bias);return 1.0-(u_shadow_intensity*occlusion);}float shadowed_light_factor(highp vec4 light_view_pos0,highp vec4 light_view_pos1,float view_depth) {float bias=0.0;float occlusion=shadow_occlusion(light_view_pos0,light_view_pos1,view_depth,bias);return 1.0-(u_shadow_intensity*occlusion);}float shadow_occlusion(float ndotl,highp vec4 light_view_pos0,highp vec4 light_view_pos1,float view_depth) {float bias=calculate_shadow_bias(ndotl);return shadow_occlusion(light_view_pos0,light_view_pos1,view_depth,bias);}
212#endif`;const vm=/^#include\s+"([^"]+)"\s*\r?\n/gm,eu=/#pragma mapbox: ([\
212w\-]+) ([\w]+) ([\w]+) ([\w]+)/g,Wg=/\b[A-Za-z_][A-Za-z0-9_]*\b/g,bm=new Set(["ifdef","ifndef","elif","if","defined"]),cc=new Set;yl(Da,cc),yl(_m,cc),yl(Qc,cc);const La={"_prelude_fog.vertex.glsl":ah,"_prelude_terrain.vertex.glsl":Jd,"_prelude_shadow.vertex.glsl":xm,"_prelude_material_table.vertex.glsl":`#ifdef HAS_SHADER_STORAGE_BLOCK_material_buffer
213#define MATERIAL_TABLE_DEBUG 0
214uniform int u_material_offset;uniform int u_vertex_offset;layout(std140,binding=0)readonly buffer material_buffer{uvec4 material_data[];};struct MaterialInfo{uint dataOffset;
215#if MATERIAL_TABLE_DEBUG
216vec4 colorDebug;
217#endif
218};uint read_buf_no_offset(uint iDword) {return material_data[iDword/4u][iDword % 4u];}uint read_buf(uint iDword) {iDword+=uint(u_material_offset/4);return read_buf_no_offset(iDword);}float read_buf_float(uint iDword){return uintBitsToFloat(read_buf(iDword));}uint read_buf_uint8(uint iDword,uint iUint8){uint dwordOffset=iDword+(iUint8/4u);uint byteOffset=iUint8 & 3u;uint bitOffset=8u*byteOffset;uint mask=0xffu << bitOffset;uint dwordVal=read_buf(dwordOffset);return (dwordVal & mask) >> bitOffset;}uint read_buf_uint16(uint iDword,uint iUint16){uint dwordOffset=iDword+(iUint16 >> 1u);uint bitOffset=(iUint16 & 1u)*16u;uint mask=0xffffu << bitOffset;uint dwordVal=read_buf(dwordOffset);return (dwordVal & mask) >> bitOffset;}uint nrDwordsForVertexIdEntries(uint nrMaterialLookupEntries) {return nrMaterialLookupEntries;}uint nrDwordsForMaterialIdEntries(uint nrMaterialLookupEntries) {return (nrMaterialLookupEntries*2u+3u)/4u;}uint findRangeBinarySearch(uint vertexId,uint numRanges,uint dwordOffset) {uint left=0u;uint right=numRanges-1u;for (uint i=0u; i < 16u; i++) { 
219if (left > right) {break;}uint mid=(left+right)/2u;uint start=read_buf(dwordOffset+mid);uint nextStart=(mid+1u < numRanges) ? read_buf(dwordOffset+mid+1u) : 0xffffffffu;if (vertexId >=start && vertexId < nextStart) {return mid;} else if (vertexId < start) {if (mid==0u) {break;}right=mid-1u;} else {left=mid+1u;}}return 0u; 
220}uint readVertexId(uint dwordOffset,uint iMaterialLookupEntry) {return read_buf(dwordOffset+iMaterialLookupEntry);}uint findRange(uint vertexId,uint numRanges,uint dwordOffset) {uint iRange;if(numRanges <=64u){uint vertexBegin;for(iRange=0u; iRange < numRanges;++iRange) {vertexBegin=readVertexId(dwordOffset,iRange);if(vertexBegin > vertexId) {break;}}iRange=iRange==0u? 0u : iRange-1u;} else { 
221iRange=findRangeBinarySearch(vertexId,numRanges,dwordOffset);}return iRange;}MaterialInfo read_material_info(uint vertex_id) {MaterialInfo info;
222#if MATERIAL_TABLE_DEBUG
223const vec4 red=vec4(1.0,0.0,0.0,1.0);const vec4 orange=vec4(1.0,0.5,0.0,1.0);const vec4 yellow=vec4(1.0,1.0,0.0,1.0);const vec4 green=vec4(0.0,1.0,0.0,1.0);const vec4 indigo=vec4(0.294,0.0,0.510,1.0);const vec4 blue=vec4(0.0,0.0,1.0,1.0);const vec4 purple=vec4(0.5,0.0,0.5,1.0);const vec4 pink=vec4(1.0,0.0,1.0,1.0);info.colorDebug=green;
224#endif
225uint offset=0u;
226#if MATERIAL_TABLE_DEBUG
227bool keepFinding=true;uint magic=read_buf(offset);if(magic !=0xCAFEBABEu) {info.colorDebug=red;keepFinding=false;return info;}
228#endif
229offset++;
230#if MATERIAL_TABLE_DEBUG
231uint nrMaterials=read_buf(offset);uint nrVertices=read_buf(offset+1u);if(keepFinding && vertex_id >=nrVertices) {info.colorDebug=red;keepFinding=false;}
232#endif
233offset+=2u;uint nrMaterialLookupEntries=read_buf(offset++);uint perMaterialEntrySizeDwords=read_buf(offset++);
234#if MATERIAL_TABLE_DEBUG
235if(keepFinding && perMaterialEntrySizeDwords !=1u) {info.colorDebug=red;keepFinding=false;}
236#endif
237uint iMaterialLookup=findRange(vertex_id,nrMaterialLookupEntries,offset);
238#if MATERIAL_TABLE_DEBUG
239if(keepFinding)
240{uint vertexBeginCheck=readVertexId(offset,iMaterialLookup);if(vertexBeginCheck > vertex_id) {info.colorDebug=red;keepFinding=false;}if(iMaterialLookup < nrMaterialLookupEntries-1u) {uint vertexEndCheck=readVertexId(offset,iMaterialLookup+1u);if(vertexEndCheck <=vertex_id) {info.colorDebug=red;keepFinding=false;}}}
241#endif
242offset+=nrDwordsForVertexIdEntries(nrMaterialLookupEntries);uint materialId=iMaterialLookup;
243#if MATERIAL_TABLE_DEBUG
244if(keepFinding) {if(materialId >=nrMaterialLookupEntries) {info.colorDebug=red;}}
245#endif
246info.dataOffset=offset+materialId*perMaterialEntrySizeDwords;return info;}uint get_data_location(const MaterialInfo matInfo,uint attribOffsetBytes)
247{uint attribFieldOffsetDwords=attribOffsetBytes/4u;return matInfo.dataOffset+attribFieldOffsetDwords;}vec4 read_material_vec4(const MaterialInfo matInfo,uint attribOffsetBytes){uint loc=get_data_location(matInfo,attribOffsetBytes);return vec4(read_buf_float(loc),read_buf_float(loc+1u),read_buf_float(loc+2u),read_buf_float(loc+3u));}vec2 read_material_vec2(const MaterialInfo matInfo,uint attribOffsetBytes){uint loc=get_data_location(matInfo,attribOffsetBytes);return vec2(read_buf_float(loc),read_buf_float(loc+1u));}float read_material_float(const MaterialInfo matInfo,uint attribOffsetBytes){uint loc=get_data_location(matInfo,attribOffsetBytes);return read_buf_float(loc);}
248#define GET_ATTRIBUTE_float(attrib,matInfo,attrib_offset) read_material_float(matInfo,attrib_offset)
249#define GET_ATTRIBUTE_vec4(attrib,matInfo,attrib_offset) read_material_vec4(matInfo,attrib_offset)
250#define GET_ATTRIBUTE_vec2(attrib,matInfo,attrib_offset) read_material_vec2(matInfo,attrib_offset)
251#define DECLARE_MATERIAL_TABLE_INFO MaterialInfo materialInfo=read_material_info(uint(gl_VertexID));
252#define DECLARE_MATERIAL_TABLE_INFO_DEBUG(dbgColor) MaterialInfo materialInfo=read_material_info(uint(gl_VertexID)); dbgColor=materialInfo.colorDebug;
253#endif`,"_prelude_fog.fragment.glsl":gm,"_prelude_shadow.fragment.glsl":ef,"_prelude_lighting.glsl":Qd,"_prelude_raster_array.glsl":ym,"_prelude_indicator_cutout.fragment.glsl":`
254#ifdef INDICATOR_CUTOUT
255uniform vec3 u_indicator_cutout_centers;uniform vec4 u_indicator_cutout_params;
256#endif
257vec4 applyCutout(vec4 color,float height) {
258#ifdef INDICATOR_CUTOUT
259float verticalFadeRange=u_indicator_cutout_centers.z*0.25;float holeMinOpacity=mix(1.0,u_indicator_cutout_params.x,smoothstep(u_indicator_cutout_centers.z,u_indicator_cutout_centers.z+verticalFadeRange,height));float holeRadius=max(u_indicator_cutout_params.y,0.0);float holeAspectRatio=u_indicator_cutout_params.z;
259float fadeStart=u_indicator_cutout_params.w;float distA=distance(vec2(gl_FragCoord.x,gl_FragCoord.y*holeAspectRatio),vec2(u_indicator_cutout_centers[0],u_indicator_cutout_centers[1]*holeAspectRatio));return color*min(smoothstep(fadeStart,holeRadius,distA)+holeMinOpacity,1.0);
260#else
261return color;
262#endif
263}float cutoutGroundRoofOpacity(vec4 groundRoof) {
264#ifdef INDICATOR_CUTOUT
265float fadeStartX=u_indicator_cutout_params.w;float holeRadius=u_indicator_cutout_params.y;float holeMinOpacity=mix(u_indicator_cutout_params.x,1.0,smoothstep(u_indicator_cutout_params.z,u_indicator_cutout_centers.z,groundRoof.y));float distX=abs(u_indicator_cutout_centers.x-groundRoof.x);float roofOpacity=mix(holeMinOpacity,1.0,smoothstep(fadeStartX,holeRadius,u_indicator_cutout_centers.y-groundRoof.w));float groundOpacity=min(smoothstep(fadeStartX,holeRadius,distX)+holeMinOpacity,1.0);return max(roofOpacity,groundOpacity);
266#else
267return 1.0;
268#endif
269}`,"_prelude_feature_cutout.fragment.glsl":`// feature cutout (gl-native only)
270`,"_prelude_feature_cutout.vertex.glsl":`// feature cutout (gl-native only)
271`},uc={},za="precision highp float;",Fa="precision mediump float;",gl=`
272#if defined(GL_EXT_blend_func_extended) && defined(DUAL_SOURCE_BLENDING)
273#extension GL_EXT_blend_func_extended : require
274#endif`,lh={preludeTerrain:Vt("",Jd),preludeFog:Vt(gm,ah),preludeShadow:Vt(ef,xm),preludeRasterArray:Vt(ym,""),preludeLighting:Vt(Qd,Qd),preludePrecisionQualifiers:Vt(Fa,za),prelude:Vt(Qc,_m),preludeExtensions:Vt(gl,"")},Oa=[gl,Fa,Da,lh.prelude.fragmentSource].join(`
275`),wm=[za,Da,lh.prelude.vertexSource].join(`
276`);var tf={background:Vt(`#include "_prelude_fog.fragment.glsl"
277#include "_prelude_feature_cutout.fragment.glsl"
278uniform vec4 u_color;uniform float u_opacity;uniform mediump float u_emissive_strength;
279#ifdef LIGHTING_3D_MODE
280in vec4 v_color;
281#endif
282void main() {vec4 out_color;
283#ifdef FEATURE_CUTOUT
284vec2 uv=fragcoord_to_viewport_uv(gl_FragCoord.xy,u_inv_viewport_size.xy);float factorTex=min(texture(u_cutout_factor_image,uv).r,1.0);float cutoutFactor=(1.0-u_feature_cutout_params.x)*factorTex;out_color=u_color*(1.0-cutoutFactor);
285#else
286#ifdef LIGHTING_3D_MODE
287out_color=v_color;
288#else
289out_color=u_color;
290#endif
291#ifdef FOG
292out_color=fog_dither(fog_apply_premultiplied(out_color,v_fog_pos));
293#endif
294#endif
295glFragColor=out_color*u_opacity;
296#ifdef USE_MRT1
297out_Target1=vec4(u_emissive_strength*glFragColor.a,0.0,0.0,glFragColor.a);
298#endif
299#ifdef OVERDRAW_INSPECTOR
300glFragColor=vec4(1.0);
301#endif
302HANDLE_WIREFRAME_DEBUG;}`,`#include "_prelude_fog.vertex.glsl"
303#include "_prelude_lighting.glsl"
304in ivec2 a_pos;uniform mat4 u_matrix;uniform mediump float u_emissive_strength;
305#ifdef LIGHTING_3D_MODE
306uniform mediump vec4 u_color;out vec4 v_color;
307#endif
308void main() {gl_Position=u_matrix*vec4(a_pos,0,1);
309#ifndef FEATURE_CUTOUT
310#ifdef LIGHTING_3D_MODE
311v_color=apply_lighting_with_emission_ground(u_color,u_emissive_strength);
312#endif
313#ifdef FOG
314v_fog_pos=fog_position(vec2(a_pos));
315#endif
316#endif
317}`),backgroundPattern:Vt(`#include "_prelude_fog.fragment.glsl"
318#include "_prelude_lighting.glsl"
319uniform vec2 u_pattern_tl;uniform vec2 u_pattern_br;uniform vec2 u_texsize;uniform float u_opacity;uniform float u_emissive_strength;uniform sampler2D u_image;in highp vec2 v_pos;void main() {highp vec2 imagecoord=mod(v_pos,1.0);highp vec2 pos=mix(u_pattern_tl/u_texsize,u_pattern_br/u_texsize,imagecoord);vec4 out_color=textureLodCustom(u_image,pos,v_pos);
320#ifdef LIGHTING_3D_MODE
321out_color=apply_lighting_with_emission_ground(out_color,u_emissive_strength);
322#endif
323#ifdef FOG
324out_color=fog_dither(fog_apply_premultiplied(out_color,v_fog_pos));
325#endif
326glFragColor=out_color*u_opacity;
327#ifdef USE_MRT1
328out_Target1=vec4(u_emissive_strength*glFragColor.a,0.0,0.0,glFragColor.a);
329#endif
330#ifdef OVERDRAW_INSPECTOR
331glFragColor=vec4(1.0);
332#endif
333HANDLE_WIREFRAME_DEBUG;}`,`#include "_prelude_fog.vertex.glsl"
334uniform mat4 u_matrix;uniform vec2 u_pattern_size;uniform vec2 u_pixel_coord_upper;uniform vec2 u_pixel_coord_lower;uniform vec2 u_pattern_units_to_pixels;in ivec2 a_pos;out highp vec2 v_pos;void main() {vec2 pos=vec2(a_pos);gl_Position=u_matrix*vec4(pos,0,1);v_pos=get_pattern_pos(u_pixel_coord_upper,u_pixel_coord_lower,u_pattern_size,u_pattern_units_to_pixels,pos);
335#ifdef FOG
336v_fog_pos=fog_position(pos);
337#endif
338}`),circle:Vt
vendor: 7,212 bytes, lines 338-464
338(`#include "_prelude_fog.fragment.glsl"
339#include "_prelude_lighting.glsl"
340in vec3 v_data;in float v_visibility;
341#pragma mapbox: define highp vec4 color
342#pragma mapbox: define mediump float radius
343#pragma mapbox: define lowp float blur
344#pragma mapbox: define lowp float opacity
345#pragma mapbox: define highp vec4 stroke_color
346#pragma mapbox: define mediump float stroke_width
347#pragma mapbox: define lowp float stroke_opacity
348uniform float u_emissive_strength;void main() {
349#pragma mapbox: initialize highp vec4 color
350#pragma mapbox: initialize mediump float radius
351#pragma mapbox: initialize lowp float blur
352#pragma mapbox: initialize lowp float opacity
353#pragma mapbox: initialize highp vec4 stroke_color
354#pragma mapbox: initialize mediump float stroke_width
355#pragma mapbox: initialize lowp float stroke_opacity
356vec2 extrude=v_data.xy;float blur_positive=blur < 0.0 ? 0.0 : 1.0;lowp float antialiasblur=v_data.z;float extrude_length=length(extrude)+antialiasblur*(1.0-blur_positive);float antialiased_blur=-max(abs(blur),antialiasblur);float antialiase_blur_opacity=smoothstep(0.0,antialiasblur,extrude_length-1.0);float opacity_t=blur_positive==1.0 ? 
357smoothstep(0.0,-antialiased_blur,1.0-extrude_length) : 
358smoothstep(antialiased_blur,0.0,extrude_length-1.0)-antialiase_blur_opacity;float color_t=stroke_width < 0.01 ? 0.0 : smoothstep(
359antialiased_blur,0.0,extrude_length-radius/(radius+stroke_width)
360);vec4 out_color=mix(color*opacity,stroke_color*stroke_opacity,color_t);
361#ifdef LIGHTING_3D_MODE
362out_color=apply_lighting_with_emission_ground(out_color,u_emissive_strength);
363#endif
364#ifdef FOG
365out_color=fog_apply_premultiplied(out_color,v_fog_pos);
366#endif
367glFragColor=out_color*(v_visibility*opacity_t);
368#ifdef OVERDRAW_INSPECTOR
369glFragColor=vec4(1.0);
370#endif
371}`,`#include "_prelude_fog.vertex.glsl"
372#include "_prelude_terrain.vertex.glsl"
373#define NUM_VISIBILITY_RINGS 2
374#define INV_SQRT2 0.70710678
375#define ELEVATION_BIAS 0.0001
376#define NUM_SAMPLES_PER_RING 16
377uniform mat4 u_matrix;uniform mat2 u_extrude_scale;uniform lowp float u_device_pixel_ratio;uniform highp float u_camera_to_center_distance;in ivec2 a_pos;
378#ifdef PROJECTION_GLOBE_VIEW
379in ivec4 a_pos_3;in ivec4 a_pos_normal_3;uniform mat4 u_inv_rot_matrix;uniform vec2 u_merc_center;uniform vec3 u_tile_id;uniform float u_zoom_transition;uniform vec3 u_up_dir;
380#endif
381#ifdef ELEVATED_ROADS
382in float a_circle_z_offset;
383#endif
384out vec3 v_data;out float v_visibility;
385#pragma mapbox: define highp vec4 color
386#pragma mapbox: define mediump float radius
387#pragma mapbox: define lowp float blur
388#pragma mapbox: define lowp float opacity
389#pragma mapbox: define highp vec4 stroke_color
390#pragma mapbox: define mediump float stroke_width
391#pragma mapbox: define lowp float stroke_opacity
392vec2 calc_offset(vec2 extrusion,float radius,float stroke_width, float view_scale) {return extrusion*(radius+stroke_width)*u_extrude_scale*view_scale;}float cantilevered_elevation(vec2 pos,float radius,float stroke_width,float view_scale) {vec2 c1=pos+calc_offset(vec2(-1.0,-1.0),radius,stroke_width,view_scale);vec2 c2=pos+calc_offset(vec2(1.0,-1.0),radius,stroke_width,view_scale);vec2 c3=pos+calc_offset(vec2(1.0,1.0),radius,stroke_width,view_scale);vec2 c4=pos+calc_offset(vec2(-1.0,1.0),radius,stroke_width,view_scale);float h1=elevation(c1)+ELEVATION_BIAS;float h2=elevation(c2)+ELEVATION_BIAS;float h3=elevation(c3)+ELEVATION_BIAS;float h4=elevation(c4)+ELEVATION_BIAS;return max(h4,max(h3,max(h1,h2)));}float circle_elevation(vec2 pos) {
393#if defined(TERRAIN)
394return elevation(pos)+ELEVATION_BIAS;
395#else
396return 0.0;
397#endif
398}vec4 project_vertex(vec2 extrusion,vec4 world_center,vec4 projected_center,float radius,float stroke_width, float view_scale,mat3 surface_vectors) {vec2 sample_offset=calc_offset(extrusion,radius,stroke_width,view_scale);
399#ifdef PITCH_WITH_MAP
400#ifdef PROJECTION_GLOBE_VIEW
401return u_matrix*( world_center+vec4(sample_offset.x*surface_vectors[0]+sample_offset.y*surface_vectors[1],0) );
402#else
403return u_matrix*( world_center+vec4(sample_offset,0,0) );
404#endif
405#else
406return projected_center+vec4(sample_offset,0,0);
407#endif
408}float get_sample_step() {
409#ifdef PITCH_WITH_MAP
410return 2.0*PI/float(NUM_SAMPLES_PER_RING);
411#else
412return PI/float(NUM_SAMPLES_PER_RING);
413#endif
414}void main() {
415#pragma mapbox: initialize highp vec4 color
416#pragma mapbox: initialize mediump float radius
417#pragma mapbox: initialize lowp float blur
418#pragma mapbox: initialize lowp float opacity
419#pragma mapbox: initialize highp vec4 stroke_color
420#pragma mapbox: initialize mediump float stroke_width
421#pragma mapbox: initialize lowp float stroke_opacity
422vec2 pos2=vec2(a_pos);vec2 extrude=vec2(mod(pos2,2.0)*2.0-1.0);vec2 circle_center=floor(pos2*0.5);float height=circle_elevation(circle_center);vec4 world_center;mat3 surface_vectors;
423#ifdef PROJECTION_GLOBE_VIEW
424surface_vectors=globe_mercator_surface_vectors(vec3(a_pos_normal_3)/16384.0,u_up_dir,u_zoom_transition);vec3 surface_extrusion=extrude.x*surface_vectors[0]+extrude.y*surface_vectors[1];vec3 globe_elevation=elevationVector(circle_center)*height;vec3 globe_pos=vec3(a_pos_3)+surface_extrusion+globe_elevation;vec3 mercator_elevation=u_up_dir*u_tile_up_scale*height;vec3 merc_pos=mercator_tile_position(u_inv_rot_matrix,circle_center,u_tile_id,u_merc_center)+surface_extrusion+mercator_elevation;vec3 pos=mix_globe_mercator(globe_pos,merc_pos,u_zoom_transition);world_center=vec4(pos,1);
425#else 
426surface_vectors=mat3(1.0);world_center=vec4(circle_center,height,1);
427#endif
428#ifdef ELEVATED_ROADS
429world_center.z+=a_circle_z_offset+ELEVATION_BIAS;
430#endif
431vec4 projected_center=u_matrix*world_center;float view_scale=0.0;
432#ifdef PITCH_WITH_MAP
433#ifdef SCALE_WITH_MAP
434view_scale=1.0;
435#else
436view_scale=projected_center.w/u_camera_to_center_distance;
437#endif
438#else
439#ifdef SCALE_WITH_MAP
440view_scale=u_camera_to_center_distance;
441#else
442view_scale=projected_center.w;
443#endif
444#endif
445gl_Position=project_vertex(extrude,world_center,projected_center,radius,stroke_width,view_scale,surface_vectors);float visibility=0.0;
446#ifdef TERRAIN
447float step=get_sample_step();vec4 occlusion_world_center;vec4 occlusion_projected_center;
448#ifdef PITCH_WITH_MAP
449float cantilevered_height=cantilevered_elevation(circle_center,radius,stroke_width,view_scale);occlusion_world_center=vec4(circle_center,cantilevered_height,1);occlusion_projected_center=u_matrix*occlusion_world_center;
450#else
451occlusion_world_center=world_center;occlusion_projected_center=projected_center;
452#endif
453for(int ring=0; ring < NUM_VISIBILITY_RINGS; ring++) {float scale=(float(ring)+1.0)/float(NUM_VISIBILITY_RINGS);for(int i=0; i < NUM_SAMPLES_PER_RING; i++) {vec2 extrusion=vec2(cos(step*float(i)),-sin(step*float(i)))*scale;vec4 frag_pos=project_vertex(extrusion,occlusion_world_center,occlusion_projected_center,radius,stroke_width,view_scale,surface_vectors);visibility+=float(!isOccluded(frag_pos));}}visibility/=float(NUM_VISIBILITY_RINGS)*float(NUM_SAMPLES_PER_RING);
454#else
455visibility=1.0;
456#endif
457#ifdef PROJECTION_GLOBE_VIEW
458visibility=1.0;
459#endif
460v_visibility=visibility;lowp float antialiasblur=1.0/u_device_pixel_ratio/(radius+stroke_width);v_data=vec3(extrude.x,extrude.y,antialiasblur);
461#ifdef FOG
462v_fog_pos=fog_position(world_center.xyz);
463#endif
464}`),clippingMask:
464Vt("void main() {glFragColor=vec4(1.0);}","in ivec2 a_pos;uniform mat4 u_matrix;void main() {gl_Position=u_matrix*vec4(a_pos,0,1);}"),heatmap:Vt(`#include "_prelude_fog.fragment.glsl"
465uniform highp float u_intensity;in vec2 v_extrude;
466#pragma mapbox: define highp float weight
467#define GAUSS_COEF 0.3989422804014327
468void main() {
469#pragma mapbox: initialize highp float weight
470float d=-0.5*3.0*3.0*dot(v_extrude,v_extrude);float val=weight*u_intensity*GAUSS_COEF*exp(d);glFragColor=vec4(val,1.0,1.0,1.0);
471#ifdef FOG
472if (u_is_globe==0) {glFragColor.r*=pow(1.0-fog_opacity(v_fog_pos),2.0);}
473#endif
474#ifdef OVERDRAW_INSPECTOR
475glFragColor=vec4(1.0);
476#endif
477HANDLE_WIREFRAME_DEBUG;}`,`#include "_prelude_terrain.vertex.glsl"
478#include "_prelude_fog.vertex.glsl"
479uniform mat4 u_matrix;uniform float u_extrude_scale;uniform float u_intensity;in ivec2 a_pos;
480#ifdef PROJECTION_GLOBE_VIEW
481in ivec4 a_pos_3;in ivec4 a_pos_normal_3;uniform mat4 u_inv_rot_matrix;uniform vec2 u_merc_center;uniform vec3 u_tile_id;uniform float u_zoom_transition;uniform vec3 u_up_dir;
482#endif
483out vec2 v_extrude;
484#pragma mapbox: define highp float weight
485#pragma mapbox: define mediump float radius
486const highp float ZERO=1.0/255.0/16.0;
487#define GAUSS_COEF 0.3989422804014327
488void main() {
489#pragma mapbox: initialize highp float weight
490#pragma mapbox: initialize mediump float radius
491vec2 unscaled_extrude=vec2(mod(vec2(a_pos),2.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 tilePos=floor(vec2(a_pos)*0.5);vec3 pos;
492#ifdef PROJECTION_GLOBE_VIEW
493vec3 pos_normal_3=vec3(a_pos_normal_3)/16384.0;mat3 surface_vectors=globe_mercator_surface_vectors(pos_normal_3,u_up_dir,u_zoom_transition);vec3 surface_extrusion=extrude.x*surface_vectors[0]+extrude.y*surface_vectors[1];vec3 globe_elevation=elevationVector(tilePos)*elevation(tilePos);vec3 globe_pos=vec3(a_pos_3)+surface_extrusion+globe_elevation;vec3 mercator_elevation=u_up_dir*u_tile_up_scale*elevation(tilePos);vec3 merc_pos=mercator_tile_position(u_inv_rot_matrix,tilePos,u_tile_id,u_merc_center)+surface_extrusion+mercator_elevation;pos=mix_globe_mercator(globe_pos,merc_pos,u_zoom_transition);
494#else
495pos=vec3(tilePos+extrude,elevation(tilePos));
496#endif
497gl_Position=u_matrix*vec4(pos,1);
498#ifdef FOG
499v_fog_pos=fog_position(pos);
500#endif
501}`),heatmapTexture:Vt(`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));glFragColor=color*u_opacity;
502#ifdef OVERDRAW_INSPECTOR
503glFragColor=vec4(0.0);
504#endif
505HANDLE_WIREFRAME_DEBUG;}`,"in ivec2 a_pos;out vec2 v_pos;void main() {gl_Position=vec4(a_pos,0,1);v_pos=vec2(a_pos)*0.5+0.5;}"),collisionBox:Vt("in float v_placed;in float v_notUsed;void main() {vec4 red =vec4(1.0,0.0,0.0,1.0);vec4 blue=vec4(0.0,0.0,1.0,0.5);glFragColor =mix(red,blue,step(0.5,v_placed))*0.5;glFragColor*=mix(1.0,0.1,step(0.5,v_notUsed));}",`#include "_prelude_terrain.vertex.glsl"
506in ivec4 a_pos;in ivec2 a_anchor_pos;in ivec2 a_extrude;in uvec2 a_placed;in vec2 a_shift;in vec2 a_elevation_from_sea;in float a_size_scale;in vec2 a_padding;in float a_auto_z_offset;uniform mat4 u_matrix;uniform vec2 u_extrude_scale;uniform float u_camera_to_center_distance;
507#ifdef PROJECTION_GLOBE_VIEW
508uniform vec3 u_tile_id;uniform mat4 u_inv_rot_matrix;uniform vec2 u_merc_center;uniform float u_zoom_transition;
509#endif
510out float v_placed;out float v_notUsed;void main() {vec2 anchor_pos=vec2(a_anchor_pos);float feature_elevation=a_elevation_from_sea.x+a_auto_z_offset;float terrain_elevation=(a_elevation_from_sea.y==1.0 ? 0.0 : elevation(anchor_pos));vec3 proj_pos=vec3(a_pos)+elevationVector(anchor_pos)*(feature_elevation+terrain_elevation);
511#ifdef PROJECTION_GLOBE_VIEW
512#ifndef PROJECTED_POS_ON_VIEWPORT
513vec3 globe_pos=proj_pos;vec3 mercator_pos=mercator_tile_position(u_inv_rot_matrix,anchor_pos,u_tile_id,u_merc_center);proj_pos=mix_globe_mercator(globe_pos,mercator_pos,u_zoom_transition);
514#endif
515#endif
516vec4 projectedPoint=u_matrix*vec4(proj_pos,1);highp float camera_to_anchor_distance=projectedPoint.w;highp float collision_perspective_ratio=clamp(
5170.5+0.5*(u_camera_to_center_distance/camera_to_anchor_distance),0.0,1.5);gl_Position=projectedPoint;gl_Position.xy+=(vec2(a_extrude)*a_size_scale+a_shift+a_padding)*u_extrude_scale*gl_Position.w*collision_perspective_ratio;v_placed=float(a_placed.x);v_notUsed=float(a_placed.y);}`),collisionCircle:Vt("in float v_radius;in vec2 v_extrude;in float v_perspective_ratio;in float v_collision;void main() {float alpha=0.5*min(v_perspective_ratio,1.0);float stroke_radius=0.9*max(v_perspective_ratio,1.0);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);glFragColor=color*alpha*opacity_t;}",`in vec2 a_pos_2f;in float a_radius;in ivec2 a_flags;uniform mat4 u_matrix;uniform mat4 u_inv_matrix;uniform vec2 u_viewport_size;uniform float u_camera_to_center_distance;out float v_radius;out vec2 v_extrude;out float v_perspective_ratio;out float v_collision;vec3 toTilePosition(vec2 screenPos) {vec4 rayStart=u_inv_matrix*vec4(screenPos,-1.0,1.0);vec4 rayEnd  =u_inv_matrix*vec4(screenPos, 1.0,1.0);rayStart.xyz/=rayStart.w;rayEnd.xyz  /=rayEnd.w;highp float t=(0.0-rayStart.z)/(rayEnd.z-rayStart.z);return mix(rayStart.xyz,rayEnd.xyz,t);}void main() {vec2 quadCenterPos=a_pos_2f;float radius=a_radius;int vertexIdx=a_flags.y;vec2 quadVertexOffset=vec2(
518mix(-1.0,1.0,float(vertexIdx >=2)),mix(-1.0,1.0,float(vertexIdx >=1 && vertexIdx <=2)));vec2 quadVertexExtent=quadVertexOffset*radius;vec3 tilePos=toTilePosition(quadCenterPos);vec4 clipPos=u_matrix*vec4(tilePos,1.0);highp float camera_to_anchor_distance=clipPos.w;highp float collision_perspective_ratio=clamp(
5190.5+0.5*(u_camera_to_center_distance/camera_to_anchor_distance),0.0,4.0);float padding_factor=1.2;v_radius=radius;v_extrude=quadVertexExtent*padding_factor;v_perspective_ratio=collision_perspective_ratio;v_collision=float(a_flags.x);gl_Position=vec4(clipPos.xyz/clipPos.w,1.0)+vec4(quadVertexExtent*padding_factor/u_viewport_size*2.0,0.0,0.0);}`),debug:Vt("uniform highp vec4 u_color;uniform sampler2D u_overlay;in vec2 v_uv;void main() {vec4 overlay_color=texture(u_overlay,v_uv);glFragColor=mix(u_color,overlay_color,overlay_color.a);}",`#include "_prelude_terrain.vertex.glsl"
520in ivec2 a_pos;
521#ifdef PROJECTION_GLOBE_VIEW
522in ivec4 a_pos_3;
523#endif
524out vec2 v_uv;uniform mat4 u_matrix;uniform float u_overlay_scale;void main() {vec2 pos=vec2(a_pos);float h=elevation(pos);v_uv=pos/8192.0;
525#ifdef PROJECTION_GLOBE_VIEW
526gl_Position=u_matrix*vec4(vec3(a_pos_3)+elevationVector(pos)*h,1);
527#else
528gl_Position=u_matrix*vec4(pos*u_overlay_scale,h,1);
529#endif
530}`),fill:Vt(`#include "_prelude_fog.fragment.glsl"
531#include "_prelude_lighting.glsl"
532#include "_prelude_shadow.fragment.glsl"
533#include "_prelude_indicator_cutout.fragment.glsl"
534#include "_prelude_feature_cutout.fragment.glsl"
535#pragma mapbox: define highp vec4 color
536#pragma mapbox: define lowp float opacity
537uniform float u_emissive_strength;uniform lowp float u_opacity_multiplier;
538#ifdef RENDER_SHADOWS
539uniform vec3 u_ground_shadow_factor;in highp vec4 v_pos_light_view_0;in highp vec4 v_pos_light_view_1;in highp float v_depth;
540#endif
541#ifdef ELEVATED_ROADS
542in highp float v_road_z_offset;
543#endif
544#ifdef INDICATOR_CUTOUT
545in highp float v_z_offset;
546#endif
547void main() {
548#pragma mapbox: initialize highp vec4 color
549#pragma mapbox: initialize lowp float opacity
550vec2 cutout_factors=vec2(0.0);
551#ifdef FEATURE_CUTOUT
552cutout_factors=get_cutout_factors(gl_FragCoord);
553#endif
554vec4 out_color=color;
555#ifdef LIGHTING_3D_MODE
556out_color=apply_lighting_with_emission_ground(out_color,u_emissive_strength);
557#ifdef RENDER_SHADOWS
558float light=shadowed_light_factor(v_pos_light_view_0,v_pos_light_view_1,v_depth);light=mix(light,1.0,cutout_factors.y);out_color.rgb*=mix(u_ground_shadow_factor,vec3(1.0),light);
559#endif
560#endif
561#ifdef FOG
562out_color=fog_dither(fog_apply_premultiplied(out_color,v_fog_pos));
563#endif
564out_color*=(opacity*u_opacity_multiplier);
565#ifdef INDICATOR_CUTOUT
566if (v_z_offset >=0.0) {out_color=applyCutout(out_color,v_z_offset);}
567#endif
568#ifdef FEATURE_CUTOUT
569float z=0.0;
570#ifdef ELEVATED_ROADS
571z=v_road_z_offset;
572#endif
573out_color=apply_feature_cutout(out_color,gl_FragCoord,cutout_factors.x,z);
574#endif
575glFragColor=out_color;
576#ifdef USE_MRT1
577out_Target1=vec4(u_emissive_strength*glFragColor.a,0.0,0.0,glFragColor.a);
578#endif
579#ifdef OVERDRAW_INSPECTOR
580glFragColor=vec4(1.0);
581#endif
582HANDLE_WIREFRAME_DEBUG;}`,`#include "_prelude_fog.vertex.glsl"
583#include "_prelude_shadow.vertex.glsl"
584in ivec2 a_pos;
585#ifdef ELEVATED_ROADS
586in float a_road_z_offset;out highp float v_road_z_offset;
587#endif
588#ifdef RENDER_SHADOWS
589uniform mat4 u_light_matrix_0;uniform mat4 u_light_matrix_1;out highp vec4 v_pos_light_view_0;out highp vec4 v_pos_light_view_1;out highp float v_depth;
590#endif
591#ifdef INDICATOR_CUTOUT
592out highp float v_z_offset;
593#endif
594uniform mat4 u_matrix;uniform lowp float u_opacity_multiplier;
595#pragma mapbox: define highp vec4 color
596#pragma mapbox: define lowp float opacity
597#pragma mapbox: define highp float z_offset
598void main() {
599#pragma mapbox: initialize highp vec4 color
600#pragma mapbox: initialize lowp float opacity
601#pragma mapbox: initialize highp float z_offset
602#ifdef ELEVATED_ROADS
603z_offset+=a_road_z_offset;v_road_z_offset=z_offset;
604#endif
605float hidden=float(opacity==0.0);gl_Position=mix(u_matrix*vec4(a_pos,z_offset,1),AWAY,hidden);
606#ifdef RENDER_SHADOWS
607vec3 shd_pos0=vec3(a_pos,z_offset);vec3 shd_pos1=vec3(a_pos,z_offset);
608#ifdef NORMAL_OFFSET
609vec3 offset=shadow_normal_offset(vec3(0.0,0.0,1.0));shd_pos0+=offset*shadow_normal_offset_multiplier0();shd_pos1+=offset*shadow_normal_offset_multiplier1();
610#endif
611v_pos_light_view_0=u_light_matrix_0*vec4(shd_pos0,1);v_pos_light_view_1=u_light_matrix_1*vec4(shd_pos1,1);v_depth=gl_Position.w;
612#endif
613#ifdef FOG
614v_fog_pos=fog_position(vec2(a_pos));
615#endif
616#ifdef INDICATOR_CUTOUT
617v_z_offset=z_offset;
618#endif
619}`),fillOutline:Vt(`#include "_prelude_fog.fragment.glsl"
620#include "_prelude_lighting.glsl"
621#include "_prelude_shadow.fragment.glsl"
622#include "_prelude_feature_cutout.fragment.glsl"
623in highp vec2 v_pos;uniform float u_emissive_strength;uniform lowp float u_opacity_multiplier;
624#ifdef ELEVATED_ROADS
625in highp float v_road_z_offset;
626#endif
627#ifdef RENDER_SHADOWS
628uniform vec3 u_ground_shadow_factor;in highp vec4 v_pos_light_view_0;in highp vec4 v_pos_light_view_1;in highp float v_depth;
629#endif
630#pragma mapbox: define highp vec4 outline_color
631#pragma mapbox: define lowp float opacity
632void main() {
633#pragma mapbox: initialize highp vec4 outline_color
634#pragma mapbox: initialize lowp float opacity
635float dist=length(v_pos-gl_FragCoord.xy);float alpha=1.0-smoothstep(0.0,1.0,dist);vec4 out_color=outline_color;vec2 cutout_factors=vec2(0.0);
636#ifdef FEATURE_CUTOUT
637cutout_factors=get_cutout_factors(gl_FragCoord);
638#endif
639#ifdef LIGHTING_3D_MODE
640out_color=apply_lighting_with_emission_ground(out_color,u_emissive_strength);
641#ifdef RENDER_SHADOWS
642float light=shadowed_light_factor(v_pos_light_view_0,v_pos_light_view_1,v_depth);light=mix(light,1.0,cutout_factors.y);out_color.rgb*=mix(u_ground_shadow_factor,vec3(1.0),light);
643#endif
644#endif
645#ifdef FOG
646out_color=fog_dither(fog_apply_premultiplied(out_color,v_fog_pos));
647#endif
648#ifdef FEATURE_CUTOUT
649float z=0.0;
650#ifdef ELEVATED_ROADS
651z=v_road_z_offset;
652#endif
653out_color=apply_feature_cutout(out_color,gl_FragCoord,cutout_factors.x,z);
654#endif
655glFragColor=out_color*(alpha*opacity*u_opacity_multiplier);
656#ifdef USE_MRT1
657out_Target1=vec4(u_emissive_strength*glFragColor.a,0.0,0.0,glFragColor.a);
658#endif
659#ifdef OVERDRAW_INSPECTOR
660glFragColor=vec4(1.0);
661#endif
662HANDLE_WIREFRAME_DEBUG;}`,`#include "_prelude_fog.vertex.glsl"
663#include "_prelude_shadow.vertex.glsl"
664in ivec2 a_pos;
665#ifdef ELEVATED_ROADS
666in float a_road_z_offset;out highp float v_road_z_offset;
667#endif
668#ifdef RENDER_SHADOWS
669uniform mat4 u_light_matrix_0;uniform mat4 u_light_matrix_1;out highp vec4 v_pos_light_view_0;out highp vec4 v_pos_light_view_1;out highp float v_depth;
670#endif
671uniform mat4 u_matrix;uniform vec2 u_world;uniform lowp float u_opacity_multiplier;out highp vec2 v_pos;
672#pragma mapbox: define highp vec4 outline_color
673#pragma mapbox: define lowp float opacity
674#pragma mapbox: define highp float z_offset
675void main() {
676#pragma mapbox: initialize highp vec4 outline_color
677#pragma mapbox: initialize lowp float opacity
678#pragma mapbox: initialize highp float z_offset
679#ifdef ELEVATED_ROADS
680z_offset+=a_road_z_offset;v_road_z_offset=z_offset;
681#endif
682float hidden=float(opacity==0.0);gl_Position=mix(u_matrix*vec4(a_pos,z_offset,1),AWAY,hidden);
683#ifdef FLIP_Y
684v_pos=(vec2(gl_Position.x,-gl_Position.y)/gl_Position.w+1.0)/2.0*u_world;
685#else
686v_pos=(gl_Position.xy/gl_Position.w+1.0)/2.0*u_world;
687#endif
688#ifdef RENDER_SHADOWS
689vec3 shd_pos0=vec3(a_pos,z_offset);vec3 shd_pos1=vec3(a_pos,z_offset);
690#ifdef NORMAL_OFFSET
691vec3 offset=shadow_normal_offset(vec3(0.0,0.0,1.0));shd_pos0+=offset*shadow_normal_offset_multiplier0();shd_pos1+=offset*shadow_normal_offset_multiplier1();
692#endif
693v_pos_light_view_0=u_light_matrix_0*vec4(shd_pos0,1);v_pos_light_view_1=u_light_matrix_1*vec4(shd_pos1,1);v_depth=gl_Position.w;
694#endif
695#ifdef FOG
696v_fog_pos=fog_position(vec2(a_pos));
697#endif
698}`),fillOutlinePattern:Vt(`#include "_prelude_fog.fragment.glsl"
699#include "_prelude_lighting.glsl"
700#include "_prelude_shadow.fragment.glsl"
701#include "_prelude_feature_cutout.fragment.glsl"
702uniform vec2 u_texsize;uniform sampler2D u_image;
703#ifdef FILL_PATTERN_TRANSITION
704uniform float u_pattern_transition;
705#endif
706uniform float u_emissive_strength;uniform lowp float u_opacity_multiplier;
707#ifdef APPLY_LUT_ON_GPU
708uniform highp sampler3D u_lutTexture;
709#endif
710#ifdef RENDER_SHADOWS
711uniform vec3 u_ground_shadow_factor;in highp vec4 v_pos_light_view_0;in highp vec4 v_pos_light_view_1;in highp float v_depth;
712#endif
713#ifdef ELEVATED_ROADS
714in highp float v_road_z_offset;
715#endif
716in highp vec2 v_pos;in highp vec2 v_pos_world;
717#pragma mapbox: define lowp float opacity
718#pragma mapbox: define lowp uvec4 pattern
719#ifdef FILL_PATTERN_TRANSITION
720#pragma mapbox: define mediump uvec4 pattern_b
721#endif
722void main() {
723#pragma mapbox: initialize lowp float opacity
724#pragma mapbox: initialize mediump uvec4 pattern
725#ifdef FILL_PATTERN_TRANSITION
726#pragma mapbox: initialize mediump uvec4 pattern_b
727#endif
728vec2 pattern_tl=vec2(pattern.xy);vec2 pattern_br=vec2(pattern.zw);highp vec2 imagecoord=mod(v_pos,1.0);highp vec2 pos=mix(pattern_tl/u_texsize,pattern_br/u_texsize,imagecoord);highp vec2 lod_pos=mix(pattern_tl/u_texsize,pattern_br/u_texsize,v_pos);float dist=length(v_pos_world-gl_FragCoord.xy);float alpha=1.0-smoothstep(0.0,1.0,dist);vec4 out_color=textureLodCustom(u_image,pos,lod_pos);
729#ifdef APPLY_LUT_ON_GPU
730out_color=applyLUT(u_lutTexture,out_color);
731#endif
732#ifdef FILL_PATTERN_TRANSITION
733vec2 pattern_b_tl=vec2(pattern_b.xy);vec2 pattern_b_br=vec2(pattern_b.zw);highp vec2 pos_b=mix(pattern_b_tl/u_texsize,pattern_b_br/u_texsize,imagecoord);vec4 color_b=textureLodCustom(u_image,pos_b,lod_pos);out_color=out_color*(1.0-u_pattern_transition)+color_b*u_pattern_transition;
734#endif
735vec2 cutout_factors=vec2(0.0);
736#ifdef FEATURE_CUTOUT
737cutout_factors=get_cutout_factors(gl_FragCoord);
738#endif
739#ifdef LIGHTING_3D_MODE
740out_color=apply_lighting_with_emission_ground(out_color,u_emissive_strength);
741#ifdef RENDER_SHADOWS
742float light=shadowed_light_factor(v_pos_light_view_0,v_pos_light_view_1,v_depth);light=mix(light,1.0,cutout_factors.y);out_color.rgb*=mix(u_ground_shadow_factor,vec3(1.0),light);
743#endif
744#endif
745#ifdef FEATURE_CUTOUT
746float z=0.0;
747#ifdef ELEVATED_ROADS
748z=v_road_z_offset;
749#endif
750out_color=apply_feature_cutout(out_color,gl_FragCoord,cutout_factors.x,z);
751#endif
752#ifdef FOG
753out_color=fog_dither(fog_apply_premultiplied(out_color,v_fog_pos));
754#endif
755glFragColor=out_color*(alpha*opacity*u_opacity_multiplier);
756#ifdef USE_MRT1
757out_Target1=vec4(u_emissive_strength*glFragColor.a,0.0,0.0,glFragColor.a);
758#endif
759#ifdef OVERDRAW_INSPECTOR
760glFragColor=vec4(1.0);
761#endif
762HANDLE_WIREFRAME_DEBUG;}`,`#include "_prelude_fog.vertex.glsl"
763#include "_prelude_shadow.vertex.glsl"
764uniform mat4 u_matrix;uniform vec2 u_world;uniform lowp float u_opacity_multiplier;uniform vec2 u_pixel_coord_upper;uniform vec2 u_pixel_coord_lower;uniform float u_tile_units_to_pixels;in ivec2 a_pos;
765#ifdef ELEVATED_ROADS
766in float a_road_z_offset;out highp float v_road_z_offset;
767#endif
768#ifdef RENDER_SHADOWS
769uniform mat4 u_light_matrix_0;uniform mat4 u_light_matrix_1;out highp vec4 v_pos_light_view_0;out highp vec4 v_pos_light_view_1;out highp float v_depth;
770#endif
771out highp vec2 v_pos;out highp vec2 v_pos_world;
772#pragma mapbox: define lowp float opacity
773#pragma mapbox: define lowp uvec4 pattern
774#ifdef FILL_PATTERN_TRANSITION
775#pragma mapbox: define mediump uvec4 pattern_b
776#endif
777#pragma mapbox: define lowp float pixel_ratio
778#pragma mapbox: define highp float z_offset
779void main() {
780#pragma mapbox: initialize lowp float opacity
781#pragma mapbox: initialize mediump uvec4 pattern
782#ifdef FILL_PATTERN_TRANSITION
783#pragma mapbox: initialize mediump uvec4 pattern_b
784#endif
785#pragma mapbox: initialize lowp float pixel_ratio
786#pragma mapbox: initialize highp float z_offset
787vec2 pattern_tl=vec2(pattern.xy);vec2 pattern_br=vec2(pattern.zw);
788#ifdef ELEVATED_ROADS
789z_offset+=a_road_z_offset;v_road_z_offset=z_offset;
790#endif
791float hidden=float(opacity==0.0);vec2 pos=vec2(a_pos);gl_Position=mix(u_matrix*vec4(pos,z_offset,1),AWAY,hidden);vec2 display_size=(pattern_br-pattern_tl)/pixel_ratio;v_pos=get_pattern_pos(u_pixel_coord_upper,u_pixel_coord_lower,display_size,u_tile_units_to_pixels,pos);
792#ifdef FLIP_Y
793v_pos_world=(vec2(gl_Position.x,-gl_Position.y)/gl_Position.w+1.0)/2.0*u_world;
794#else
795v_pos_world=(gl_Position.xy/gl_Position.w+1.0)/2.0*u_world;
796#endif
797#ifdef RENDER_SHADOWS
798vec3 shd_pos0=vec3(pos,z_offset);vec3 shd_pos1=vec3(pos,z_offset);
799#ifdef NORMAL_OFFSET
800vec3 offset=shadow_normal_offset(vec3(0.0,0.0,1.0));shd_pos0+=offset*shadow_normal_offset_multiplier0();shd_pos1+=offset*shadow_normal_offset_multiplier1();
801#endif
802v_pos_light_view_0=u_light_matrix_0*vec4(shd_pos0,1);v_pos_light_view_1=u_light_matrix_1*vec4(shd_pos1,1);v_depth=gl_Position.w;
803#endif
804#ifdef FOG
805v_fog_pos=fog_position(pos);
806#endif
807}`),fillPattern:Vt(`#include "_prelude_fog.fragment.glsl"
808#include "_prelude_lighting.glsl"
809#include "_prelude_shadow.fragment.glsl"
810#include "_prelude_feature_cutout.fragment.glsl"
811uniform vec2 u_texsize;uniform sampler2D u_image;
812#ifdef FILL_PATTERN_TRANSITION
813uniform float u_pattern_transition;
814#endif
815in highp vec2 v_pos;uniform float u_emissive_strength;uniform lowp float u_opacity_multiplier;
816#ifdef RENDER_SHADOWS
817uniform vec3 u_ground_shadow_factor;in highp vec4 v_pos_light_view_0;in highp vec4 v_pos_light_view_1;in highp float v_depth;
818#endif
819#ifdef ELEVATED_ROADS
820in highp float v_road_z_offset;
821#endif
822#ifdef APPLY_LUT_ON_GPU
823uniform highp sampler3D u_lutTexture;
824#endif
825#pragma mapbox: define lowp float opacity
826#pragma mapbox: define lowp uvec4 pattern
827#ifdef FILL_PATTERN_TRANSITION
828#pragma mapbox: define mediump uvec4 pattern_b
829#endif
830void main() {
831#pragma mapbox: initialize lowp float opacity
832#pragma mapbox: initialize mediump uvec4 pattern
833#ifdef FILL_PATTERN_TRANSITION
834#pragma mapbox: initialize mediump uvec4 pattern_b
835#endif
836vec2 pattern_tl=vec2(pattern.xy);vec2 pattern_br=vec2(pattern.zw);highp vec2 imagecoord=mod(v_pos,1.0);highp vec2 pos=mix(pattern_tl/u_texsize,pattern_br/u_texsize,imagecoord);highp vec2 lod_pos=mix(pattern_tl/u_texsize,pattern_br/u_texsize,v_pos);vec4 out_color=textureLodCustom(u_image,pos,lod_pos);
837#ifdef APPLY_LUT_ON_GPU
838out_color=applyLUT(u_lutTexture,out_color);
839#endif
840#ifdef FILL_PATTERN_TRANSITION
841vec2 pattern_b_tl=vec2(pattern_b.xy);vec2 pattern_b_br=vec2(pattern_b.zw);highp vec2 pos_b=mix(pattern_b_tl/u_texsize,pattern_b_br/u_texsize,imagecoord);vec4 color_b=textureLodCustom(u_image,pos_b,lod_pos);out_color=out_color*(1.0-u_pattern_transition)+color_b*u_pattern_transition;
842#endif
843vec2 cutout_factors=vec2(0.0);
844#ifdef FEATURE_CUTOUT
845cutout_factors=get_cutout_factors(gl_FragCoord);
846#endif
847#ifdef LIGHTING_3D_MODE
848out_color=apply_lighting_with_emission_ground(out_color,u_emissive_strength);
849#ifdef RENDER_SHADOWS
850float light=shadowed_light_factor(v_pos_light_view_0,v_pos_light_view_1,v_depth);light=mix(light,1.0,cutout_factors.y);
851#ifdef ELEVATED_ROADS
852out_color.rgb*=mix(v_road_z_offset !=0.0 ? u_ground_shadow_factor : vec3(1.0),vec3(1.0),light);
853#else
854out_color.rgb*=mix(u_ground_shadow_factor,vec3(1.0),light);
855#endif
856#endif
857#endif
858#ifdef FEATURE_CUTOUT
859float z=0.0;
860#ifdef ELEVATED_ROADS
861z=v_road_z_offset;
862#endif
863out_color=apply_feature_cutout(out_color,gl_FragCoord,cutout_factors.x,z);
864#endif
865#ifdef FOG
866out_color=fog_dither(fog_apply_premultiplied(out_color,v_fog_pos));
867#endif
868glFragColor=out_color*(opacity*u_opacity_multiplier);
869#ifdef USE_MRT1
870out_Target1=vec4(u_emissive_strength*glFragColor.a,0.0,0.0,glFragColor.a);
871#endif
872#ifdef OVERDRAW_INSPECTOR
873glFragColor=vec4(1.0);
874#endif
875HANDLE_WIREFRAME_DEBUG;}`,`#include "_prelude_fog.vertex.glsl"
876#include "_prelude_shadow.vertex.glsl"
877uniform mat4 u_matrix;uniform lowp float u_opacity_multiplier;uniform vec2 u_pixel_coord_upper;uniform vec2 u_pixel_coord_lower;uniform float u_tile_units_to_pixels;in ivec2 a_pos;
878#ifdef ELEVATED_ROADS
879in float a_road_z_offset;out highp float v_road_z_offset;
880#endif
881#ifdef RENDER_SHADOWS
882uniform mat4 u_light_matrix_0;uniform mat4 u_light_matrix_1;out highp vec4 v_pos_light_view_0;out highp vec4 v_pos_light_view_1;out highp float v_depth;
883#endif
884out highp vec2 v_pos;
885#pragma mapbox: define lowp float opacity
886#pragma mapbox: define lowp uvec4 pattern
887#ifdef FILL_PATTERN_TRANSITION
888#pragma mapbox: define mediump uvec4 pattern_b
889#endif
890#pragma mapbox: define lowp float pixel_ratio
891#pragma mapbox: define highp float z_offset
892void main() {
893#pragma mapbox: initialize lowp float opacity
894#pragma mapbox: initialize mediump uvec4 pattern
895#pragma mapbox: initialize lowp float pixel_ratio
896#pragma mapbox: initialize highp float z_offset
897#ifdef FILL_PATTERN_TRANSITION
898#pragma mapbox: initialize mediump uvec4 pattern_b
899#endif
900vec2 pattern_tl=vec2(pattern.xy);vec2 pattern_br=vec2(pattern.zw);vec2 display_size=(pattern_br-pattern_tl)/pixel_ratio;
901#ifdef ELEVATED_ROADS
902z_offset+=a_road_z_offset;v_road_z_offset=z_offset;
903#endif
904float hidden=float(opacity==0.0);vec2 pos=vec2(a_pos);gl_Position=mix(u_matrix*vec4(pos,z_offset,1),AWAY,hidden);v_pos=get_pattern_pos(u_pixel_coord_upper,u_pixel_coord_lower,display_size,u_tile_units_to_pixels,pos);
905#ifdef RENDER_SHADOWS
906vec3 shd_pos0=vec3(pos,z_offset);vec3 shd_pos1=vec3(pos,z_offset);
907#ifdef NORMAL_OFFSET
908vec3 offset=shadow_normal_offset(vec3(0.0,0.0,1.0));shd_pos0+=offset*shadow_normal_offset_multiplier0();shd_pos1+=offset*shadow_normal_offset_multiplier1();
909#endif
910v_pos_light_view_0=u_light_matrix_0*vec4(shd_pos0,1);v_pos_light_view_1=u_light_matrix_1*vec4(shd_pos1,1);v_depth=gl_Position.w;
911#e
911ndif
912#ifdef FOG
913v_fog_pos=fog_position(pos);
914#endif
915}`),lineBlendComposite:Vt(`uniform highp sampler2D u_image;uniform float u_opacity;uniform int u_blend_mode;uniform highp float u_max_density;in vec2 v_pos;
916#define ADDITIVE 1
917void main() {vec4 color=texture(u_image,v_pos);if (u_blend_mode==ADDITIVE) {if (color.a <=0.0) {discard;}highp float density=color.a;vec3 avgColor=color.rgb/max(density,0.001);highp float n=density/max(u_max_density,0.001);highp float t=sqrt(n/(n+1.0));glFragColor=vec4(avgColor*t,t);} else {vec3 multiplyFactor=color.rgb*u_opacity+(1.0-u_opacity);glFragColor=vec4(multiplyFactor,1.0);}
918#ifdef OVERDRAW_INSPECTOR
919glFragColor=vec4(0.0);
920#endif
921HANDLE_WIREFRAME_DEBUG;}`,"in ivec2 a_pos;out vec2 v_pos;void main() {gl_Position=vec4(a_pos,0,1);v_pos=vec2(a_pos)*0.5+0.5;}"),lineBlendReduce:Vt("uniform highp sampler2D u_image;uniform vec2 u_texel_size;uniform bool u_first_pass;in vec2 v_pos;void main() {vec2 o=u_texel_size*0.5;vec4 s0=texture(u_image,v_pos+vec2(-o.x,-o.y));vec4 s1=texture(u_image,v_pos+vec2( o.x,-o.y));vec4 s2=texture(u_image,v_pos+vec2(-o.x, o.y));vec4 s3=texture(u_image,v_pos+vec2( o.x, o.y));float r0; float g0;float r1; float g1;float r2; float g2;float r3; float g3;if (u_first_pass) {float a0=s0.a;float a1=s1.a;float a2=s2.a;float a3=s3.a;r0=a0; g0=a0 > 0.0 ? 1.0 : 0.0;r1=a1; g1=a1 > 0.0 ? 1.0 : 0.0;r2=a2; g2=a2 > 0.0 ? 1.0 : 0.0;r3=a3; g3=a3 > 0.0 ? 1.0 : 0.0;} else {r0=s0.r; g0=s0.g;r1=s1.r; g1=s1.g;r2=s2.r; g2=s2.g;r3=s3.r; g3=s3.g;}glFragColor=vec4((r0+r1+r2+r3)*0.25,(g0+g1+g2+g3)*0.25,0.0,0.0);}","in ivec2 a_pos;out vec2 v_pos;void main() {gl_Position=vec4(a_pos,0,1);v_pos=vec2(a_pos)*0.5+0.5;}"),fillExtrusion:Vt(`#include "_prelude_fog.fragment.glsl"
922#include "_prelude_shadow.fragment.glsl"
923#include "_prelude_lighting.glsl"
924#include "_prelude_indicator_cutout.fragment.glsl"
925#include "_prelude_feature_cutout.fragment.glsl"
926in vec4 v_color;in vec4 v_flat;
927#ifdef RENDER_SHADOWS
928in highp vec4 v_pos_light_view_0;in highp vec4 v_pos_light_view_1;
929#endif
930uniform lowp float u_opacity;
931#ifdef RENDER_FRONT_CUTOFF
932in float v_front_cutoff_opacity;
933#endif
934#ifdef INDICATOR_CUTOUT
935#ifdef FEATURE_CUTOUT
936in vec4 v_ground_roof;
937#endif
938#endif
939#ifdef FAUX_AO
940uniform lowp vec2 u_ao;in vec2 v_ao;
941#endif
942#if defined(ZERO_ROOF_RADIUS) && !defined(LIGHTING_3D_MODE)
943in vec4 v_roof_color;
944#endif
945#if defined(ZERO_ROOF_RADIUS) || defined(RENDER_SHADOWS) || defined(LIGHTING_3D_MODE)
946in highp vec3 v_normal;
947#endif
948uniform vec3 u_flood_light_color;uniform highp float u_vertical_scale;uniform float u_flood_light_intensity;uniform vec3 u_ground_shadow_factor;
949#if defined(LIGHTING_3D_MODE) && defined(FLOOD_LIGHT)
950in float v_flood_radius;in float v_has_floodlight;
951#endif
952in float v_height;
953#pragma mapbox: define highp float emissive_strength
954void main() {
955#pragma mapbox: initialize highp float emissive_strength
956#if defined(ZERO_ROOF_RADIUS) || defined(RENDER_SHADOWS) || defined(LIGHTING_3D_MODE)
957vec3 normal=normalize(v_normal);
958#endif
959float z;vec4 color=v_color;
960#ifdef ZERO_ROOF_RADIUS
961z=float(normal.z > 0.00001);
962#ifdef LIGHTING_3D_MODE
963normal=mix(normal,vec3(0.0,0.0,1.0),z);
964#else
965color=mix(v_color,v_roof_color,z);
966#endif
967#endif
968float h=max(0.0,v_height);float ao_shade=1.0;
969#ifdef FAUX_AO
970float intensity=u_ao[0];float h_floors=h/(u_ao[1]*u_vertical_scale);float y_shade=1.0-0.9*intensity*min(v_ao.y,1.0);ao_shade=(1.0-0.08*intensity)*(y_shade+(1.0-y_shade)*(1.0-pow(1.0-min(h_floors/16.0,1.0),16.0)))+0.08*intensity*min(h_floors/160.0,1.0);float concave=v_ao.x*v_ao.x;
971#ifdef ZERO_ROOF_RADIUS
972concave*=(1.0-z);
973#endif
974float x_shade=mix(1.0,mix(0.6,0.75,min(h_floors/30.0,1.0)),intensity)+0.1*intensity*min(h,1.0);ao_shade*=mix(1.0,x_shade*x_shade*x_shade,concave);
975#ifdef LIGHTING_3D_MODE
976#ifdef FLOOD_LIGHT
977color.rgb*=mix(ao_shade,1.0,v_has_floodlight);
978#else
979color.rgb*=ao_shade;
980#endif
981#else
982color.rgb*=ao_shade;
983#endif
984#endif
985#ifdef LIGHTING_3D_MODE
986float flood_radiance=0.0;
987#ifdef FLOOD_LIGHT
988flood_radiance=(1.0-min(h/v_flood_radius,1.0))*u_flood_light_intensity*v_has_floodlight;
989#endif
990#ifdef RENDER_SHADOWS
991#ifdef FLOOD_LIGHT
992float ndotl_unclamped=dot(normal,u_shadow_direction);float ndotl=max(0.0,ndotl_unclamped);float occlusion=ndotl_unclamped < 0.0 ? 1.0 : shadow_occlusion(ndotl,v_pos_light_view_0,v_pos_light_view_1,1.0/gl_FragCoord.w);vec3 litColor=apply_lighting(color.rgb,normal,(1.0-u_shadow_intensity*occlusion)*ndotl);vec3 floodLitColor=compute_flood_lighting(u_flood_light_color*u_opacity,1.0-u_shadow_intensity,occlusion,u_ground_shadow_factor);color.rgb=mix(litColor,floodLitColor,flood_radiance);
993#else
994float shadowed_lighting_factor;
995#ifdef RENDER_CUTOFF
996shadowed_lighting_factor=shadowed_light_factor_normal_opacity(normal,v_pos_light_view_0,v_pos_light_view_1,1.0/gl_FragCoord.w,v_cutoff_opacity);if (v_cutoff_opacity==0.0) {discard;}
997#else
998shadowed_lighting_factor=shadowed_light_factor_normal(normal,v_pos_light_view_0,v_pos_light_view_1,1.0/gl_FragCoord.w);
999#endif
1000color.rgb=apply_lighting(color.rgb,normal,shadowed_lighting_factor);
1001#endif
1002#else
1003color.rgb=apply_lighting(color.rgb,normal);
1004#ifdef FLOOD_LIGHT
1005color.rgb=mix(color.rgb,u_flood_light_color*u_opacity,flood_radiance);
1006#endif
1007#endif
1008color.rgb=mix(color.rgb,v_flat.rgb,emissive_strength);color*=u_opacity;
1009#endif
1010#ifdef FOG
1011color=fog_dither(fog_apply_premultiplied(color,v_fog_pos,h));
1012#endif
1013#ifdef INDICATOR_CUTOUT
1014#ifdef FEATURE_CUTOUT
1015{float ditherOpacity=cutoutGroundRoofOpacity(v_ground_roof);if (ditherOpacity < 1.0) {int index=viewport_dither_index(gl_FragCoord.xy);if (ditherOpacity < DITHER_THRESHOLDS[index]) {discard;}}}
1016#else
1017color=applyCutout(color,h);
1018#endif
1019#endif
1020#ifdef RENDER_FRONT_CUTOFF
1021if (v_front_cutoff_opacity < 1.0) {int index=viewport_dither_index(gl_FragCoord.xy);if (v_front_cutoff_opacity < DITHER_THRESHOLDS[index]) {discard;}}
1022#endif
1023#ifdef FEATURE_CUTOUT
1024color=apply_feature_cutout(color,gl_FragCoord,get_cutout_factors(gl_FragCoord).x,0.0);
1025#endif
1026glFragColor=color;
1027#ifdef OVERDRAW_INSPECTOR
1028glFragColor=vec4(1.0);
1029#endif
1030HANDLE_WIREFRAME_DEBUG;}`,`#include "_prelude_fog.vertex.glsl"
1031#include "_prelude_terrain.vertex.glsl"
1032#include "_prelude_shadow.vertex.glsl"
1033#include "_prelude_lighting.glsl"
1034#include "_prelude_material_table.vertex.glsl"
1035uniform mat4 u_matrix;
1036#ifndef LIGHTING_3D_MODE
1037uniform vec3 u_lightcolor;uniform lowp vec3 u_lightpos;uniform lowp float u_lightintensity;
1038#endif
1039uniform float u_vertical_gradient;uniform lowp float u_opacity;uniform float u_edge_radius;uniform float u_width_scale;in ivec4 a_pos_normal_ed;
1040#if defined(HAS_CENTROID) || defined(TERRAIN)
1041in uvec2 a_centroid_pos;
1042#endif
1043#ifdef RENDER_WALL_MODE
1044in ivec4 a_join_normal_inside;
1045#endif
1046#ifdef PROJECTION_GLOBE_VIEW
1047in ivec4 a_pos_3;in ivec4 a_pos_normal_3;uniform mat4 u_inv_rot_matrix;uniform vec2 u_merc_center;uniform vec3 u_tile_id;uniform float u_zoom_transition;uniform vec3 u_up_dir;uniform float u_height_lift;
1048#endif
1049#ifdef TERRAIN
1050uniform int u_height_type;uniform int u_base_type;
1051#endif
1052uniform highp float u_vertical_scale;
1053#ifdef RENDER_FRONT_CUTOFF
1054uniform vec3 u_front_cutoff_params;out float v_front_cutoff_opacity;
1055#endif
1056out vec4 v_color;out vec4 v_flat;
1057#ifdef RENDER_SHADOWS
1058uniform mat4 u_light_matrix_0;uniform mat4 u_light_matrix_1;out highp vec4 v_pos_light_view_0;out highp vec4 v_pos_light_view_1;
1059#endif
1060#if defined(ZERO_ROOF_RADIUS) && !defined(LIGHTING_3D_MODE)
1061out vec4 v_roof_color;
1062#endif
1063#if defined(ZERO_ROOF_RADIUS) || defined(RENDER_SHADOWS) || defined(LIGHTING_3D_MODE)
1064out highp vec3 v_normal;
1065#endif
1066#ifdef FAUX_AO
1067uniform lowp vec2 u_ao;out vec2 v_ao;
1068#endif
1069#if defined(LIGHTING_3D_MODE) && defined(FLOOD_LIGHT)
1070out float v_flood_radius;out float v_has_floodlight;
1071#endif
1072out float v_height;
1073#ifdef INDICATOR_CUTOUT
1074#ifdef FEATURE_CUTOUT
1075out vec4 v_ground_roof;
1076#endif
1077#endif
1078vec3 linearTosRGB(vec3 color) {return pow(color,vec3(1./2.2));}vec3 sRGBToLinear(vec3 srgbIn) {return pow(srgbIn,vec3(2.2));}
1079#pragma mapbox: define highp float base
1080#pragma mapbox: define highp float height
1081#pragma mapbox: define highp vec4 color
1082#pragma mapbox: define highp float flood_light_wall_radius
1083#pragma mapbox: define highp float line_width
1084#pragma mapbox: define highp float emissive_strength
1085void main() {DECLARE_MATERIAL_TABLE_INFO
1086#pragma mapbox: initialize highp float base
1087#pragma mapbox: initialize highp float height
1088#pragma mapbox: initialize highp vec4 color
1089#pragma mapbox: initialize highp float flood_light_wall_radius
1090#pragma mapbox: initialize highp float line_width
1091#pragma mapbox: initialize highp float emissive_strength
1092base*=u_vertical_scale;height*=u_vertical_scale;vec4 top_up_ny_start=vec4(a_pos_normal_ed & 1);vec4 pos_nx=vec4(a_pos_normal_ed >> 1);float x_normal=pos_nx.z/8192.0;vec3 normal=top_up_ny_start.y==1.0 ? vec3(0.0,0.0,1.0) : normalize(vec3(x_normal,(2.0*top_up_ny_start.z-1.0)*(1.0-abs(x_normal)),0.0));
1093#if defined(ZERO_ROOF_RADIUS) || defined(RENDER_SHADOWS) || defined(LIGHTING_3D_MODE)
1094v_normal=normal;
1095#endif
1096base=max(0.0,base);float attr_height=height;height=max(0.0,top_up_ny_start.y==0.0 && top_up_ny_start.x==1.0 ? height-u_edge_radius : height);float t=top_up_ny_start.x;vec2 centroid_pos=vec2(0.0);
1097#if defined(HAS_CENTROID) || defined(TERRAIN)
1098centroid_pos=vec2(a_centroid_pos);
1099#endif
1100float ele=0.0;float h=0.0;float c_ele=0.0;vec3 pos;
1101#ifdef TERRAIN
1102bool is_flat_height=centroid_pos.x !=0.0 && u_height_type==1;bool is_flat_base=centroid_pos.x !=0.0 && u_base_type==1;ele=elevation(pos_nx.xy);bool is_elevation_encoded=centroid_pos.y==0.0 || (centroid_pos.y > 0.0 && (int(centroid_pos.y) & 7)==7);c_ele=is_flat_height || is_flat_base ? (is_elevation_encoded ? elevationFromUint16(centroid_pos.x) : flatElevation(centroid_pos)) : ele;float h_height=is_flat_height ? max(c_ele+height,ele+base+2.0) : ele+height;float h_base=is_flat_base ? max(c_ele+base,ele+base) : ele+(base==0.0 ?-5.0 : base);h=t > 0.0 ? max(h_base,h_height) : h_base;
1103#else
1104h=t > 0.0 ? height : base;
1105#endif
1106pos=vec3(pos_nx.xy,h);
1107#ifdef PROJECTION_GLOBE_VIEW
1108float lift=float((t+base) > 0.0)*u_height_lift;h+=lift;vec3 globe_normal=normalize(mix(vec3(a_pos_normal_3)/16384.0,u_up_dir,u_zoom_transition));vec3 globe_pos=vec3(a_pos_3)+globe_normal*(u_tile_up_scale*h);vec3 merc_pos=mercator_tile_position(u_inv_rot_matrix,pos.xy,u_tile_id,u_merc_center)+u_up_dir*u_tile_up_scale*pos.z;pos=mix_globe_mercator(globe_pos,merc_pos,u_zoom_transition);
1109#endif
1110float cutoff=1.0;vec3 scaled_pos=pos;
1111#if defined(RENDER_CUTOFF) || defined(RENDER_FRONT_CUTOFF)
1112vec2 centroid_decoded=pos.xy;bool isBorderCentroid=false;if (centroid_pos.x > 0.0 && centroid_pos.y > 0.0) {int iy=int(centroid_pos.y);int spanYbits=iy & 7;if (spanYbits==7) {isBorderCentroid=true;int borderID=(iy >> 3) & 3;float coordAlongBorder=float(iy >> 5)*4.0;if (borderID==0) centroid_decoded=vec2(0.0,coordAlongBorder);else if (borderID==1) centroid_decoded=vec2(EXTENT,coordAlongBorder);else if (borderID==2) centroid_decoded=vec2(coordAlongBorder,0.0);else centroid_decoded=vec2(coordAlongBorder,EXTENT);} else {centroid_decoded=floor(centroid_pos/8.0);}}
1113#endif
1114#if defined(RENDER_CUTOFF) || defined(RENDER_FRONT_CUTOFF)
1115vec4 ground=u_matrix*vec4(centroid_decoded,ele,1.0);
1116#endif
1117#ifdef RENDER_CUTOFF
1118#ifdef CLIP_ZERO_TO_ONE
1119cutoff=cutoff_opacity(u_cutoff_params,ground.z*2.0-ground.w);
1120#else
1121cutoff=cutoff_opacity(u_cutoff_params,ground.z);
1122#endif
1123if (centroid_pos.y !=0.0 && centroid_pos.x !=0.0) {vec3 centroid_random=vec3(centroid_pos.xy,centroid_pos.x+centroid_pos.y+1.0);vec3 ground_pos=centroid_random/8.0;vec3 g=floor(ground_pos);vec3 mod_=centroid_random-g*8.0;float seed=min(1.0,0.1*(min(3.5,max(mod_.x+mod_.y,0.2*attr_height))*0.35+mod_.z));if (cutoff < 0.8-seed) {cutoff=0.0;}}float cutoff_scale=cutoff;v_cutoff_opacity=cutoff;scaled_pos.z=mix(c_ele,h,cutoff_scale);
1124#endif
1125float hidden=float((centroid_pos.x==0.0 && centroid_pos.y==1.0) || (cutoff==0.0 && centroid_pos.x !=0.0) || (color.a==0.0));
1126#ifdef RENDER_FRONT_CUTOFF
1127v_front_cutoff_opacity=1.0;if (centroid_pos.x > 0.0 && centroid_pos.y > 0.0) {hidden=max(hidden,float(ground.w <=0.0));float ndc_y=ground.y/max(ground.w,0.001);float threshold=u_front_cutoff_params.x*2.0-1.0;float range_ndc=u_front_cutoff_params.y*2.0;if (!isBorderCentroid) {hidden=max(hidden,float(ndc_y < threshold-range_ndc));}float t=clamp((ndc_y-(threshold-range_ndc))/max(range_ndc,0.001),0.0,1.0);v_front_cutoff_opacity=mix(u_front_cutoff_params.z,1.0,t);}
1128#endif
1129#ifdef RENDER_WALL_MODE
1130vec3 join_normal_inside=vec3(a_join_normal_inside);vec2 wall_offset=u_width_scale*line_width*(join_normal_inside.xy/EXTENT);scaled_pos.xy+=(1.0-join_normal_inside.z)*wall_offset*0.5;scaled_pos.xy-=join_normal_inside.z*wall_offset*0.5;
1131#endif
1132gl_Position=mix(u_matrix*vec4(scaled_pos,1),AWAY,hidden);h=h-ele;v_height=h;
1133#ifdef RENDER_SHADOWS
1134vec3 shd_pos0=pos;vec3 shd_pos1=pos;
1135#ifdef NORMAL_OFFSET
1136vec3 offset=shadow_normal_offset(normal);shd_pos0+=offset*shadow_normal_offset_multiplier0();shd_pos1+=offset*shadow_normal_offset_multiplier1();
1137#endif
1138v_pos_light_view_0=u_light_matrix_0*vec4(shd_pos0,1);v_pos_light_view_1=u_light_matrix_1*vec4(shd_pos1,1);
1139#endif
1140float NdotL=0.0;float colorvalue=0.0;
1141#ifndef LIGHTING_3D_MODE
1142colorvalue=color.r*0.2126+color.g*0.7152+color.b*0.0722;vec4 ambientlight=vec4(0.03,0.03,0.03,1.0);color+=ambientlight;NdotL=clamp(dot(normal,u_lightpos),0.0,1.0);NdotL=mix((1.0-u_lightintensity),max((1.0-colorvalue+u_lightintensity),1.0),NdotL);if (normal.y !=0.0) {float r=0.84;r=mix(0.7,0.98,1.0-u_lightintensity);NdotL*=(
1143(1.0-u_vertical_gradient)+(u_vertical_gradient*clamp((t+base)*pow(height/150.0,0.5),r,1.0)));}
1144#endif
1145#ifdef FAUX_AO
1146float concave=pos_nx.w-floor(pos_nx.w*0.5)*2.0;float start=top_up_ny_start.w;float y_ground=1.0-clamp(t+base,0.0,1.0);float top_height=height;
1147#ifdef TERRAIN
1148top_height=mix(max(c_ele+height,ele+base+2.0),ele+height,float(ce
1148ntroid_pos.x==0.0))-ele;y_ground+=y_ground*5.0/max(3.0,top_height);
1149#endif
1150v_ao=vec2(mix(concave,-concave,start),y_ground);NdotL*=(1.0+0.05*(1.0-top_up_ny_start.y)*u_ao[0]);
1151#ifdef PROJECTION_GLOBE_VIEW
1152top_height+=u_height_lift;
1153#endif
1154gl_Position.z-=(0.0000006*(min(top_height,500.)+2.0*min(base,500.0)+60.0*concave+3.0*start))*gl_Position.w;
1155#endif
1156#ifdef LIGHTING_3D_MODE
1157#ifdef FLOOD_LIGHT
1158float is_wall=1.0-float(t > 0.0 && top_up_ny_start.y > 0.0);v_has_floodlight=float(flood_light_wall_radius > 0.0 && is_wall > 0.0);v_flood_radius=flood_light_wall_radius*u_vertical_scale;
1159#endif
1160v_color=vec4(color.rgb,1.0);float ndotl=calculate_NdotL(normal);v_flat.rgb=sRGBToLinear(color.rgb);v_flat.rgb=v_flat.rgb*(ndotl+(1.0-min(ndotl*57.29,1.0))*emissive_strength);v_flat=vec4(linearTosRGB(v_flat.rgb),1.0);
1161#else
1162v_color=vec4(0.0,0.0,0.0,1.0);v_color.rgb+=clamp(color.rgb*NdotL*u_lightcolor,mix(vec3(0.0),vec3(0.3),1.0-u_lightcolor),vec3(1.0));v_color*=u_opacity;
1163#endif
1164#if defined(ZERO_ROOF_RADIUS) && !defined(LIGHTING_3D_MODE)
1165float roofNdotL=clamp(u_lightpos.z,0.0,1.0);roofNdotL=mix((1.0-u_lightintensity),max((1.0-colorvalue+u_lightintensity),1.0),roofNdotL);v_roof_color=vec4(0.0,0.0,0.0,1.0);v_roof_color.rgb+=clamp(color.rgb*roofNdotL*u_lightcolor,mix(vec3(0.0),vec3(0.3),1.0-u_lightcolor),vec3(1.0));v_roof_color*=u_opacity;
1166#endif
1167#ifdef FOG
1168v_fog_pos=fog_position(pos);
1169#endif
1170#ifdef INDICATOR_CUTOUT
1171#ifdef FEATURE_CUTOUT
1172vec4 pos_ground=u_matrix*vec4(pos.xy,ele,1.0);vec4 pos_roof=u_matrix*vec4(pos.xy,ele+height,1.0);v_ground_roof=vec4(pos_ground.xy/pos_ground.w,pos_roof.xy/pos_roof.w);
1173#endif
1174#endif
1175}`),fillExtrusionPattern:Vt(`#include "_prelude_fog.fragment.glsl"
1176#include "_prelude_lighting.glsl"
1177#include "_prelude_indicator_cutout.fragment.glsl"
1178uniform vec2 u_texsize;uniform sampler2D u_image;
1179#ifdef FILL_EXTRUSION_PATTERN_TRANSITION
1180uniform float u_pattern_transition;
1181#endif
1182#ifdef FAUX_AO
1183uniform lowp vec2 u_ao;in vec3 v_ao;
1184#endif
1185#ifdef LIGHTING_3D_MODE
1186in vec3 v_normal;
1187#endif
1188#ifdef APPLY_LUT_ON_GPU
1189uniform highp sampler3D u_lutTexture;
1190#endif
1191in highp vec2 v_pos;in vec4 v_lighting;uniform lowp float u_opacity;
1192#pragma mapbox: define highp float base
1193#pragma mapbox: define highp float height
1194#pragma mapbox: define mediump uvec4 pattern
1195#ifdef FILL_EXTRUSION_PATTERN_TRANSITION
1196#pragma mapbox: define mediump uvec4 pattern_b
1197#endif
1198#pragma mapbox: define highp float pixel_ratio
1199void main() {
1200#pragma mapbox: initialize highp float base
1201#pragma mapbox: initialize highp float height
1202#pragma mapbox: initialize mediump uvec4 pattern
1203#ifdef FILL_EXTRUSION_PATTERN_TRANSITION
1204#pragma mapbox: initialize mediump uvec4 pattern_b
1205#endif
1206#pragma mapbox: initialize highp float pixel_ratio
1207vec2 pattern_tl=vec2(pattern.xy);vec2 pattern_br=vec2(pattern.zw);highp vec2 imagecoord=mod(v_pos,1.0);highp vec2 pos=mix(pattern_tl/u_texsize,pattern_br/u_texsize,imagecoord);highp vec2 lod_pos=mix(pattern_tl/u_texsize,pattern_br/u_texsize,v_pos);vec4 out_color=textureLodCustom(u_image,pos,lod_pos);
1208#ifdef APPLY_LUT_ON_GPU
1209out_color=applyLUT(u_lutTexture,out_color);
1210#endif
1211#ifdef FILL_EXTRUSION_PATTERN_TRANSITION
1212vec2 pattern_b_tl=vec2(pattern_b.xy);vec2 pattern_b_br=vec2(pattern_b.zw);highp vec2 pos_b=mix(pattern_b_tl/u_texsize,pattern_b_br/u_texsize,imagecoord);vec4 color_b=textureLodCustom(u_image,pos_b,lod_pos);out_color=out_color*(1.0-u_pattern_transition)+color_b*u_pattern_transition;
1213#endif
1214#ifdef LIGHTING_3D_MODE
1215out_color=apply_lighting(out_color,normalize(v_normal))*u_opacity;
1216#else
1217out_color=out_color*v_lighting;
1218#endif
1219#ifdef FAUX_AO
1220float intensity=u_ao[0];float h=max(0.0,v_ao.z);float h_floors=h/u_ao[1];float y_shade=1.0-0.9*intensity*min(v_ao.y,1.0);float shade=(1.0-0.08*intensity)*(y_shade+(1.0-y_shade)*(1.0-pow(1.0-min(h_floors/16.0,1.0),16.0)))+0.08*intensity*min(h_floors/160.0,1.0);float concave=v_ao.x*v_ao.x;float x_shade=mix(1.0,mix(0.6,0.75,min(h_floors/30.0,1.0)),intensity)+0.1*intensity*min(h,1.0);shade*=mix(1.0,x_shade*x_shade*x_shade,concave);out_color.rgb=out_color.rgb*shade;
1221#endif
1222#ifdef FOG
1223out_color=fog_dither(fog_apply_premultiplied(out_color,v_fog_pos));
1224#endif
1225#ifdef INDICATOR_CUTOUT
1226out_color=applyCutout(out_color,height);
1227#endif
1228glFragColor=out_color;
1229#ifdef OVERDRAW_INSPECTOR
1230glFragColor=vec4(1.0);
1231#endif
1232HANDLE_WIREFRAME_DEBUG;}`,
vendor: 5,532 bytes, lines 1232-1328
1232`#include "_prelude_fog.vertex.glsl"
1233#include "_prelude_terrain.vertex.glsl"
1234#include "_prelude_lighting.glsl"
1235#include "_prelude_material_table.vertex.glsl"
1236uniform mat4 u_matrix;uniform vec2 u_pixel_coord_upper;uniform vec2 u_pixel_coord_lower;uniform float u_height_factor;uniform float u_tile_units_to_pixels;uniform float u_vertical_gradient;uniform lowp float u_opacity;uniform float u_width_scale;
1237#ifndef LIGHTING_3D_MODE
1238uniform vec3 u_lightcolor;uniform lowp vec3 u_lightpos;uniform lowp float u_lightintensity;
1239#endif
1240in ivec4 a_pos_normal_ed;
1241#if defined(HAS_CENTROID) || defined(TERRAIN)
1242in uvec2 a_centroid_pos;
1243#endif
1244#ifdef RENDER_WALL_MODE
1245in ivec4 a_join_normal_inside;
1246#endif
1247#ifdef PROJECTION_GLOBE_VIEW
1248in ivec4 a_pos_3;in ivec4 a_pos_normal_3;uniform mat4 u_inv_rot_matrix;uniform vec2 u_merc_center;uniform vec3 u_tile_id;uniform float u_zoom_transition;uniform vec3 u_up_dir;uniform float u_height_lift;
1249#endif
1250#ifdef TERRAIN
1251uniform int u_height_type;uniform int u_base_type;
1252#endif
1253out highp vec2 v_pos;out vec4 v_lighting;
1254#ifdef FAUX_AO
1255uniform lowp vec2 u_ao;out vec3 v_ao;
1256#endif
1257#ifdef LIGHTING_3D_MODE
1258out vec3 v_normal;
1259#endif
1260#pragma mapbox: define highp float base
1261#pragma mapbox: define highp float height
1262#pragma mapbox: define highp vec4 color
1263#pragma mapbox: define mediump uvec4 pattern
1264#ifdef FILL_EXTRUSION_PATTERN_TRANSITION
1265#pragma mapbox: define mediump uvec4 pattern_b
1266#endif
1267#pragma mapbox: define highp float pixel_ratio
1268#pragma mapbox: define highp float line_width
1269void main() {DECLARE_MATERIAL_TABLE_INFO
1270#pragma mapbox: initialize highp float base
1271#pragma mapbox: initialize highp float height
1272#pragma mapbox: initialize highp vec4 color
1273#pragma mapbox: initialize mediump uvec4 pattern
1274#ifdef FILL_EXTRUSION_PATTERN_TRANSITION
1275#pragma mapbox: initialize mediump uvec4 pattern_b
1276#endif
1277#pragma mapbox: initialize highp float pixel_ratio
1278#pragma mapbox: initialize highp float line_width
1279vec2 pattern_tl=vec2(pattern.xy);vec2 pattern_br=vec2(pattern.zw);vec4 top_up_ny_start=vec4(a_pos_normal_ed & 1);vec4 pos_nx=vec4(a_pos_normal_ed >> 1);float x_normal=pos_nx.z/8192.0;vec3 normal=top_up_ny_start.y==1.0 ? vec3(0.0,0.0,1.0) : normalize(vec3(x_normal,(2.0*top_up_ny_start.z-1.0)*(1.0-abs(x_normal)),0.0));float edgedistance=float(a_pos_normal_ed.w);vec2 display_size=(pattern_br-pattern_tl)/pixel_ratio;base=max(0.0,base);height=max(0.0,height);float t=top_up_ny_start.x;float z=t > 0.0 ? height : base;vec2 centroid_pos=vec2(0.0);
1280#if defined(HAS_CENTROID) || defined(TERRAIN)
1281centroid_pos=vec2(a_centroid_pos);
1282#endif
1283float ele=0.0;float h=z;vec3 p;float c_ele;
1284#ifdef TERRAIN
1285bool is_flat_height=centroid_pos.x !=0.0 && u_height_type==1;bool is_flat_base=centroid_pos.x !=0.0 && u_base_type==1;ele=elevation(pos_nx.xy);bool is_elevation_encoded=centroid_pos.y==0.0 || (centroid_pos.y > 0.0 && int(centroid_pos.y)-(int(centroid_pos.y)/8)*8==7);c_ele=is_flat_height || is_flat_base ? (is_elevation_encoded ? elevationFromUint16(centroid_pos.x) : flatElevation(centroid_pos)) : ele;float h_height=is_flat_height ? max(c_ele+height,ele+base+2.0) : ele+height;float h_base=is_flat_base ? max(c_ele+base,ele+base) : ele+(base==0.0 ?-5.0 : base);h=t > 0.0 ? max(h_base,h_height) : h_base;p=vec3(pos_nx.xy,h);
1286#else
1287p=vec3(pos_nx.xy,z);
1288#endif
1289#ifdef PROJECTION_GLOBE_VIEW
1290float lift=float((t+base) > 0.0)*u_height_lift;h+=lift;vec3 globe_normal=normalize(mix(vec3(a_pos_normal_3)/16384.0,u_up_dir,u_zoom_transition));vec3 globe_pos=vec3(a_pos_3)+globe_normal*(u_tile_up_scale*(p.z+lift));vec3 merc_pos=mercator_tile_position(u_inv_rot_matrix,p.xy,u_tile_id,u_merc_center)+u_up_dir*u_tile_up_scale*p.z;p=mix_globe_mercator(globe_pos,merc_pos,u_zoom_transition);
1291#endif
1292#ifdef RENDER_WALL_MODE
1293vec3 join_normal_inside=vec3(a_join_normal_inside);vec2 wall_offset=u_width_scale*line_width*(join_normal_inside.xy/EXTENT);p.xy+=(1.0-join_normal_inside.z)*wall_offset*0.5;p.xy-=join_normal_inside.z*wall_offset*0.5;
1294#endif
1295float hidden=float((centroid_pos.x==0.0 && centroid_pos.y==1.0) || (color.a==0.0));gl_Position=mix(u_matrix*vec4(p,1),AWAY,hidden);vec2 pos=normal.z==1.0
1296? pos_nx.xy
1297: vec2(edgedistance,z*u_height_factor);v_pos=get_pattern_pos(u_pixel_coord_upper,u_pixel_coord_lower,display_size,u_tile_units_to_pixels,pos);v_lighting=vec4(0.0,0.0,0.0,1.0);float NdotL=0.0;
1298#ifdef LIGHTING_3D_MODE
1299NdotL=calculate_NdotL(normal);
1300#else
1301NdotL=clamp(dot(normal,u_lightpos),0.0,1.0);NdotL=mix((1.0-u_lightintensity),max((0.5+u_lightintensity),1.0),NdotL);
1302#endif
1303if (normal.y !=0.0) {float r=0.84;
1304#ifndef LIGHTING_3D_MODE
1305r=mix(0.7,0.98,1.0-u_lightintensity);
1306#endif
1307NdotL*=(
1308(1.0-u_vertical_gradient)+(u_vertical_gradient*clamp((t+base)*pow(height/150.0,0.5),r,1.0)));}
1309#ifdef FAUX_AO
1310float concave=pos_nx.w-floor(pos_nx.w*0.5)*2.0;float start=top_up_ny_start.w;float y_ground=1.0-clamp(t+base,0.0,1.0);float top_height=height;
1311#ifdef TERRAIN
1312top_height=mix(max(c_ele+height,ele+base+2.0),ele+height,float(centroid_pos.x==0.0))-ele;y_ground+=y_ground*5.0/max(3.0,top_height);
1313#endif
1314v_ao=vec3(mix(concave,-concave,start),y_ground,h-ele);NdotL*=(1.0+0.05*(1.0-top_up_ny_start.y)*u_ao[0]);
1315#ifdef PROJECTION_GLOBE_VIEW
1316top_height+=u_height_lift;
1317#endif
1318gl_Position.z-=(0.0000006*(min(top_height,500.)+2.0*min(base,500.0)+60.0*concave+3.0*start))*gl_Position.w;
1319#endif
1320#ifdef LIGHTING_3D_MODE
1321v_normal=normal;
1322#else
1323v_lighting.rgb+=clamp(NdotL*u_lightcolor,mix(vec3(0.0),vec3(0.3),1.0-u_lightcolor),vec3(1.0));v_lighting*=u_opacity;
1324#endif
1325#ifdef FOG
1326v_fog_pos=fog_position(p);
1327#endif
1328}`),
1328hillshadePrepare:Vt(`precision highp float;uniform highp sampler2D u_image;in vec2 v_pos;uniform vec2 u_dimension;uniform float u_zoom;float getElevation(vec2 coord) {return texture(u_image,coord).r/4.0;}void main() {vec2 epsilon=1.0/u_dimension;float a=getElevation(v_pos+vec2(-epsilon.x,-epsilon.y));float b=getElevation(v_pos+vec2(0,-epsilon.y));float c=getElevation(v_pos+vec2(epsilon.x,-epsilon.y));float d=getElevation(v_pos+vec2(-epsilon.x,0));float e=getElevation(v_pos+vec2(epsilon.x,0));float f=getElevation(v_pos+vec2(-epsilon.x,epsilon.y));float g=getElevation(v_pos+vec2(0,epsilon.y));float h=getElevation(v_pos+vec2(epsilon.x,epsilon.y));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(
1329(c+e+e+h)-(a+d+d+f),(f+g+g+h)-(a+b+b+c)
1330)/pow(2.0,exaggeration+(19.2562-u_zoom));glFragColor=clamp(vec4(
1331deriv.x/2.0+0.5,deriv.y/2.0+0.5,1.0,1.0),0.0,1.0);}`,"uniform mat4 u_matrix;uniform vec2 u_dimension;in ivec2 a_pos;in uvec2 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=(vec2(a_texture_pos)/8192.0)*scale+epsilon;}"),hillshade:Vt(`#include "_prelude_fog.fragment.glsl"
1332#include "_prelude_lighting.glsl"
1333uniform sampler2D u_image;in vec2 v_pos;uniform vec2 u_latrange;uniform vec2 u_light;uniform vec4 u_shadow;uniform vec4 u_highlight;uniform vec4 u_accent;uniform float u_emissive_strength;void main() {vec4 pixel=texture(u_image,v_pos);vec2 deriv=((pixel.rg*2.0)-1.0);float scaleFactor=cos(radians((u_latrange[0]-u_latrange[1])*(1.0-v_pos.y)+u_latrange[1]));float slope=atan(1.25*length(deriv)/scaleFactor);float aspect=deriv.x !=0.0 ? atan(deriv.y,-deriv.x) : PI/2.0*(deriv.y > 0.0 ? 1.0 :-1.0);float intensity=u_light.x;float azimuth=u_light.y+PI;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_shadow,u_highlight,shade)*sin(scaledSlope)*clamp(intensity*2.0,0.0,1.0);glFragColor=accent_color*(1.0-shade_color.a)+shade_color;
1334#ifdef LIGHTING_3D_MODE
1335glFragColor=apply_lighting_with_emission_ground(glFragColor,u_emissive_strength);
1336#endif
1337#ifdef FOG
1338glFragColor=fog_dither(fog_apply_premultiplied(glFragColor,v_fog_pos));
1339#endif
1340#ifdef USE_MRT1
1341out_Target1=vec4(u_emissive_strength*glFragColor.a,0.0,0.0,glFragColor.a);
1342#endif
1343#ifdef OVERDRAW_INSPECTOR
1344glFragColor=vec4(1.0);
1345#endif
1346HANDLE_WIREFRAME_DEBUG;}`,`#include "_prelude_fog.vertex.glsl"
1347uniform mat4 u_matrix;in ivec2 a_pos;in uvec2 a_texture_pos;out vec2 v_pos;void main() {gl_Position=u_matrix*vec4(a_pos,0,1);v_pos=vec2(a_texture_pos)/8192.0;
1348#ifdef VIEWPORT_ORIGIN_TOP_LEFT
1349v_pos.y=1.0-v_pos.y;
1350#endif
1351#ifdef FOG
1352v_fog_pos=fog_position(vec2(a_pos));
1353#endif
1354}`),line:Vt(`#include "_prelude_fog.fragment.glsl"
1355#include "_prelude_lighting.glsl"
1356#include "_prelude_shadow.fragment.glsl"
1357#include "_prelude_indicator_cutout.fragment.glsl"
1358#include "_prelude_feature_cutout.fragment.glsl"
1359uniform lowp float u_device_pixel_ratio;uniform highp float u_width_scale;uniform float u_alpha_discard_threshold;uniform lowp float u_opacity_multiplier;uniform bool u_clip_to_tile_borders;in vec4 v_width2_dilute;in vec2 v_normal;in float v_gamma_scale;in vec2 v_tile_pos;
1360#ifdef ELEVATED_ROADS
1361in highp float v_road_z_offset;
1362#endif
1363#ifdef VARIABLE_LINE_WIDTH
1364in float stub_side;
1365#endif
1366#ifdef RENDER_LINE_DASH
1367uniform sampler2D u_dash_image;uniform highp float u_floor_width_scale;in vec2 v_tex;
1368#endif
1369#ifdef DEBUG_ELEVATION_ID
1370in vec3 v_elevation_id_col;
1371#endif
1372#if defined(RENDER_LINE_GRADIENT) || defined(RENDER_LINE_TRIM_OFFSET)
1373in highp vec3 v_uv;
1374#endif
1375#ifdef RENDER_LINE_GRADIENT
1376uniform sampler2D u_gradient_image;
1377#endif
1378#ifdef RENDER_LINE_TRIM_OFFSET
1379uniform highp vec2 u_trim_offset;uniform highp vec2 u_trim_fade_range;uniform highp vec2 u_trim_gradient_mix_range;uniform lowp vec4 u_trim_color;
1380#endif
1381#ifdef INDICATOR_CUTOUT
1382in highp float v_z_offset;
1383#endif
1384#ifdef RENDER_SHADOWS
1385uniform bool u_emissive_in_shadows;uniform vec3 u_ground_shadow_factor;in highp vec4 v_pos_light_view_0;in highp vec4 v_pos_light_view_1;in highp float v_depth;
1386#endif
1387float luminance(vec3 c) {return (c.r+c.r+c.b+c.g+c.g+c.g)*0.1667;}
1388#pragma mapbox: define highp vec4 color
1389#pragma mapbox: define lowp float floorwidth
1390#pragma mapbox: define mediump uvec4 dash
1391#pragma mapbox: define lowp float blur
1392#pragma mapbox: define lowp float opacity
1393#pragma mapbox: define mediump float side_z_offset
1394#pragma mapbox: define lowp float border_width
1395#pragma mapbox: define lowp vec4 border_color
1396#pragma mapbox: define lowp float emissive_strength
1397float linearstep(float edge0,float edge1,float x) {return  clamp((x-edge0)/(edge1-edge0),0.0,1.0);}void main() {
1398#pragma mapbox: initialize highp vec4 color
1399#pragma mapbox: initialize lowp float floorwidth
1400#pragma mapbox: initialize mediump uvec4 dash
1401#pragma mapbox: initialize lowp float blur
1402#pragma mapbox: initialize lowp float opacity
1403#pragma mapbox: initialize mediump float side_z_offset
1404#pragma mapbox: initialize lowp float border_width
1405#pragma mapbox: initialize lowp vec4 border_color
1406#pragma mapbox: initialize lowp float emissive_strength
1407float dist=length(v_normal)*v_width2_dilute.x;float ANTIALIASING=1.0/u_device_pixel_ratio/2.0;
1408#ifdef RENDER_LINE_BORDER
1409#ifndef VARIABLE_LINE_WIDTH
1410ANTIALIASING*=8.0;
1411#endif
1412#endif
1413#ifdef VARIABLE_LINE_WIDTH
1414blur=mix(blur,0.0,stub_side);
1415#endif
1416float diluted_opacity=opacity*v_width2_dilute.z;float blur2=(u_width_scale*blur+1.0/u_device_pixel_ratio)*v_gamma_scale;float alpha=clamp(min(dist-(v_width2_dilute.y-blur2),v_width2_dilute.x-dist)/blur2,0.0,1.0);float pxStep;float delta;
1417#ifdef RENDER_LINE_BORDER
1418#ifndef VARIABLE_LINE_WIDTH
1419pxStep=fwidth(dist);float out_edge=v_width2_dilute.x-dist;float in_edge=dist-(v_width2_dilute.y-2.0*ANTIALIASING);delta=v_width2_dilute.y > 0.0 ? min(in_edge,out_edge) : out_edge;float edge=ANTIALIASING;alpha=delta > 0.0 ? smoothstep(edge-pxStep,u_width_scale*blur+edge+pxStep,delta) : 0.0;
1420#endif
1421#endif
1422#ifdef RENDER_LINE_DASH
1423float sdfdist=texture(u_dash_image,v_tex).r;float sdfgamma=ANTIALIASING/(float(dash.z)+float(dash.w)/65535.0);float scaled_floorwidth=(floorwidth*u_floor_width_scale);alpha*=linearstep(0.5-sdfgamma/scaled_floorwidth,0.5+sdfgamma/scaled_floorwidth,sdfdist);
1424#endif
1425highp vec4 out_color;
1426#ifdef RENDER_LINE_GRADIENT
1427out_color=texture(u_gradient_image,v_uv.xy);
1428#else
1429out_color=color;
1430#endif
1431float trim_alpha=1.0;
1432#ifdef RENDER_LINE_TRIM_OFFSET
1433highp float trim_start=u_trim_offset[0];highp float trim_end=u_trim_offset[1];highp float line_progress=v_uv[2];if (trim_end > trim_start) {highp float start_transition=max(0.0,min(1.0,(line_progress-trim_start)/max(u_trim_fade_range[0],1.0e-9)));highp float end_transition=max(0.0,min(1.0,(trim_end-line_progress)/max(u_trim_fade_range[1],1.0e-9)));highp float transition_factor=min(start_transition,end_transition);highp float gradient_trim_color_mix_factor=0.0;
1434#ifdef RENDER_LINE_GRADIENT
1435gradient_trim_color_mix_factor=smoothstep(u_trim_gradient_mix_range.x,u_trim_gradient_mix_range.y,line_progress);
1436#endif
1437highp vec4 trim_color=mix(u_trim_color,out_color,gradient_trim_color_mix_factor);out_color=mix(u_trim_gradient_mix_range.x < 1.0 ? color : out_color,trim_color,transition_factor);trim_alpha=1.0-transition_factor;}
1438#endif
1439if (u_alpha_discard_threshold !=0.0) {if (alpha < u_alpha_discard_threshold) {discard;}}
1440#ifdef RENDER_LINE_BORDER
1441#ifndef VARIABLE_LINE_WIDTH
1442float edge2=border_width*u_width_scale+ANTIALIASING;float alpha2=smoothstep(edge2-pxStep,edge2+pxStep,delta);if (alpha2 < 1.) {if (border_color.a==0.0) {
1443#ifndef RENDER_LINE_GRADIENT
1444float Y=(out_color.a > 0.01) ? luminance(out_color.rgb/out_color.a) : 1.;float adjustment=(Y > 0.) ? 0.5/Y : 0.45;if (out_color.a > 0.25 && Y < 0.25) {vec3 borderColor=(Y > 0.) ? out_color.rgb : vec3(1,1,1)*out_color.a;out_color.rgb=out_color.rgb+borderColor*(adjustment*(1.0-alpha2));} else {out_color.rgb*=(0.6+0.4*alpha2);}
1445#else
1446out_color.rgb*=(0.6+0.4*alpha2);
1447#endif
1448} else {out_color=mix(border_color*trim_alpha,out_color,alpha2);}out_color*=v_width2_dilute.w;}
1449#endif
1450#endif
1451vec2 cutout_factors=vec2(0.0);
1452#ifdef FEATURE_CUTOUT
1453cutout_factors=get_cutout_factors(gl_FragCoord);
1454#endif
1455#ifdef LIGHTING_3D_MODE
1456out_color=apply_lighting_with_emission_ground(out_color,emissive_strength);
1457#ifdef RENDER_SHADOWS
1458float light=shadowed_light_factor(v_pos_light_view_0,v_pos_light_view_1,v_depth);light=mix(light,1.0,cutout_factors.y);light=u_emissive_in_shadows ? mix(light,1.0,emissive_strength) : light;
1459#ifdef ELEVATED_ROADS
1460out_color.rgb*=mix(v_road_z_offset !=0.0 ? u_ground_shadow_factor : vec3(1.0),vec3(1.0),light);
1461#else
1462out_color.rgb*=mix(u_ground_shadow_factor,vec3(1.0),light);
1463#endif
1464#endif
1465#endif
1466#ifdef FOG
1467out_color=fog_dither(fog_apply_premultiplied(out_color,v_fog_pos));
1468#endif
1469out_color*=(alpha*diluted_opacity*u_opacity_multiplier);
1470#ifdef INDICATOR_CUTOUT
1471out_color=applyCutout(out_color,v_z_offset);
1472#endif
1473#ifdef FEATURE_CUTOUT
1474float z=0.0;
1475#ifdef ELEVATED_ROADS
1476z=v_road_z_offset;
1477#endif
1478out_color=apply_feature_cutout(out_color,gl_FragCoord,cutout_factors.x,z);
1479#endif
1480#ifdef LINE_BLEND_ADDITIVE
1481{float cov=alpha*diluted_opacity;glFragColor=vec4(cov > 0.0 ? out_color.rgb/cov : vec3(0.0),cov);}
1482#else
1483#ifdef LINE_BLEND_MULTIPLY
1484glFragColor=vec4(out_color.rgb+(1.0-out_color.a),1.0);
1485#else
1486glFragColor=out_color;
1487#endif
1488#endif
1489#ifdef DUAL_SOURCE_BLENDING
1490glFragColorSrc1=vec4(vec3(0.0),emissive_strength);
1491#else
1492#ifdef USE_MRT1
1493out_Target1=vec4(emissive_strength*glFragColor.a,0.0,0.0,glFragColor.a);
1494#endif
1495#endif
1496#ifdef OVERDRAW_INSPECTOR
1497glFragColor=vec4(1.0);
1498#endif
1499#ifdef DEBUG_ELEVATION_ID
1500glFragColor=vec4(v_elevation_id_col,1.0);
1501#endif
1502if (u_clip_to_tile_borders) {if (v_tile_pos.x > 1.0 || v_tile_pos.y > 1.0 || v_tile_pos.x < 0.0 || v_tile_pos.y < 0.0) {discard;}}HANDLE_WIREFRAME_DEBUG;}`,`#include "_prelude_fog.vertex.glsl"
1503#include "_prelude_shadow.vertex.glsl"
1504#include "_prelude_terrain.vertex.glsl"
1505#define EXTRUDE_SCALE 0.015873016
1506in ivec2 a_pos_normal;in uvec4 a_data;
1507#if defined(ELEVATED) || defined(ELEVATED_ROADS) || defined(VARIABLE_LINE_WIDTH) || defined(VARIABLE_LINE_EMISSIVE_STRENGTH)
1508in vec4 a_z_offset_width;
1509#endif
1510#ifdef DEBUG_ELEVATION_ID
1511in vec3 a_elevation_id_col;
1512#endif
1513#ifdef DEBUG_ELEVATION_ID
1514out vec3 v_elevation_id_col;
1515#endif
1516#ifdef ELEVATION_GROUND_SCALE
1517in float a_elevation_ground_scale;
1518#endif
1519#if defined(RENDER_LINE_GRADIENT) || defined(RENDER_LINE_TRIM_OFFSET) || defined(RENDER_LINE_CURVE)
1520in highp vec3 a_packed;
1521#endif
1522#ifdef RENDER_LINE_DASH
1523in float a_linesofar;
1524#endif
1525uniform mat4 u_matrix;uniform mat2 u_pixels_to_tile_units;uniform vec2 u_units_to_pixels;uniform lowp float u_device_pixel_ratio;uniform float u_width_scale;uniform float u_z_offset;
1526#ifdef RENDER_LINE_CURVE
1527uniform mat3 u_curve_points_x;uniform mat3 u_curve_points_y;uniform mat3 u_curve_points_z;uniform float u_curve_point_count;
1528#endif
1529#ifdef ELEVATED
1530uniform lowp float u_zbias_factor;uniform lowp float u_tile_to_meter;float sample_elevation(vec2 apos) {
1531#ifdef ELEVATION_REFERENCE_SEA
1532return 0.0;
1533#else
1534return elevation(apos);
1535#endif
1536}
1537#endif
1538out vec2 v_normal;out vec4 v_width2_dilute;out float v_gamma_scale;out vec2 v_tile_pos;
1539#ifdef ELEVATED_ROADS
1540out highp float v_road_z_offset;
1541#endif
1542#ifdef VARIABLE_LINE_WIDTH
1543out float stub_side;
1544#endif
1545#ifdef RENDER_LINE_DASH
1546uniform highp float u_floor_width_scale;uniform vec2 u_texsize;uniform float u_tile_units_to_pixels;out vec2 v_tex;
1547#endif
1548#if defined(RENDER_LINE_GRADIENT) || defined(RENDER_LINE_TRIM_OFFSET)
1549out highp vec3 v_uv;
1550#endif
1551#ifdef RENDER_LINE_GRADIENT
1552uniform float u_image_height;
1553#endif
1554#ifdef INDICATOR_CUTOUT
1555out highp float v_z_offset;
1556#endif
1557#ifdef RENDER_SHADOWS
1558uniform mat4 u_light_matrix_0;uniform mat4 u_light_matrix_1;out highp vec4 v_pos_light_view_0;out highp vec4 v_pos_light_view_1;out highp float v_depth;
1559#endif
1560#pragma mapbox: define highp vec4 color
1561#pragma mapbox: define lowp float floorwidth
1562#pragma mapbox: define mediump uvec4 dash
1563#pragma mapbox: define lowp float blur
1564#pragma mapbox: define lowp float opacity
1565#pragma mapbox: define mediump float gapwidth
1566#pragma mapbox: define lowp float offset
1567#pragma mapbox: define mediump float width
1568#pragma mapbox: define mediump float side_z_offset
1569#pragma mapbox: define lowp float border_width
1570#pragma mapbox: define lowp vec4 border_color
1571#pragma mapbox: define lowp float emissive_strength
1572#ifdef RENDER_LINE_CURVE
1573vec3 getCurvePoint(int index) {int row=index/3;int col=index-row*3;float x=u_curve_points_x[row][col];float y=u_curve_points_y[row][col];float z=u_curve_points_z[row][col];return vec3(x,y,z);}vec3 catmullRom(vec3 p0,vec3 p1,vec3 p2,vec3 p3,float t) {float t2
1573=t*t;float t3=t2*t;return 0.5*(
15742.0*p1+(-p0+p2)*t+(2.0*p0-5.0*p1+4.0*p2-p3)*t2+(-p0+3.0*p1-3.0*p2+p3)*t3
1575);}vec2 catmullRomTangent(vec2 p0,vec2 p1,vec2 p2,vec2 p3,float t) {float t2=t*t;return 0.5*(
1576(-p0+p2)+(2.0*p0-5.0*p1+4.0*p2-p3)*2.0*t+(-p0+3.0*p1-3.0*p2+p3)*3.0*t2
1577);}struct CurveResult {vec3 point;vec2 tangent;};CurveResult calculateCurve(float line_progress) {float curve_progress=line_progress*(u_curve_point_count-1.0);float curve_progress_local=fract(curve_progress);float curve_segment=floor(curve_progress);int seg=int(curve_segment);vec3 p1=getCurvePoint(seg);vec3 p2=getCurvePoint(seg+1);float is_first_seg=step(curve_segment,0.5);vec3 p0_extrapolated=p1-(p2-p1);vec3 p0_fetched=getCurvePoint(max(seg-1,0));vec3 p0=mix(p0_fetched,p0_extrapolated,is_first_seg);int last_seg=int(u_curve_point_count)-2;float is_last_seg=step(float(last_seg)-0.5,curve_segment);vec3 p3_extrapolated=p2+(p2-p1);vec3 p3_fetched=getCurvePoint(min(seg+2,int(u_curve_point_count)-1));vec3 p3=mix(p3_fetched,p3_extrapolated,is_last_seg);vec3 point=catmullRom(p0,p1,p2,p3,curve_progress_local);vec2 tangent=catmullRomTangent(p0.xy,p1.xy,p2.xy,p3.xy,curve_progress_local)*(u_curve_point_count-1.0);CurveResult result;result.point=point;result.tangent=tangent;return result;}
1578#endif
1579void main() {
1580#pragma mapbox: initialize highp vec4 color
1581#pragma mapbox: initialize lowp float floorwidth
1582#pragma mapbox: initialize mediump uvec4 dash
1583#pragma mapbox: initialize lowp float blur
1584#pragma mapbox: initialize lowp float opacity
1585#pragma mapbox: initialize mediump float gapwidth
1586#pragma mapbox: initialize lowp float offset
1587#pragma mapbox: initialize mediump float width
1588#pragma mapbox: initialize mediump float side_z_offset
1589#pragma mapbox: initialize lowp float border_width
1590#pragma mapbox: initialize lowp vec4 border_color
1591#pragma mapbox: initialize lowp float emissive_strength
1592#ifdef VARIABLE_LINE_EMISSIVE_STRENGTH
1593emissive_strength=a_z_offset_width.w;
1594#endif
1595float a_z_offset=u_z_offset;
1596#if defined(ELEVATED) || defined(ELEVATED_ROADS)
1597a_z_offset+=a_z_offset_width.x;
1598#endif
1599#ifdef DEBUG_ELEVATION_ID
1600v_elevation_id_col=a_elevation_id_col;
1601#endif
1602highp float line_progress=0.0;
1603#if defined(RENDER_LINE_GRADIENT) || defined(RENDER_LINE_TRIM_OFFSET) || defined(RENDER_LINE_CURVE)
1604line_progress=a_packed[2];
1605#endif
1606float ANTIALIASING=1.0/u_device_pixel_ratio/2.0;
1607#ifdef RENDER_LINE_BORDER
1608#ifndef VARIABLE_LINE_WIDTH
1609ANTIALIASING*=8.0;
1610#endif
1611#endif
1612vec2 a_extrude=vec2(a_data.xy)-128.0;float a_direction=float(a_data.z & 3u)-1.0;vec2 pos_normal=vec2(a_pos_normal);vec2 pos=floor(pos_normal*0.5);mediump vec2 normal=pos_normal-2.0*pos;normal.y=normal.y*2.0-1.0;v_normal=normal;offset=-1.0*offset*u_width_scale;bool left=normal.y==1.0;
1613#ifdef RENDER_LINE_CURVE
1614CurveResult curve=calculateCurve(line_progress);pos=curve.point.xy*8192.0;a_extrude=length(a_extrude)*normalize(curve.tangent);a_extrude=left ? vec2(-a_extrude.y,a_extrude.x) : vec2(a_extrude.y,-a_extrude.x);a_z_offset+=curve.point.z;
1615#endif
1616gapwidth=gapwidth/2.0;float halfwidth;float dilute_scale=1.0;float dilute_border_scale=1.0;float symmetric_outset=0.0;
1617#ifdef VARIABLE_LINE_WIDTH
1618float left_width=a_z_offset_width.y;float right_width=a_z_offset_width.z;halfwidth=u_width_scale*(left ? left_width : right_width);if (side_z_offset !=0.0) {float left_f=step(1.0,normal.y);float is_negative=step(side_z_offset,0.0);float apply=mix(1.0-left_f,left_f,is_negative);a_extrude*=apply;a_z_offset+=abs(side_z_offset)*apply;v_normal*=apply;}offset=border_width > 0.0 ? (left_width+right_width)*u_width_scale : offset;halfwidth=border_width > 0.0 ? border_width*u_width_scale*0.5 : halfwidth;bool zero_right_width=border_width==0.0 && right_width==0.0;symmetric_outset=zero_right_width ? u_width_scale*left_width : halfwidth;stub_side=zero_right_width ?-normal.y : 0.0;v_normal=!left && zero_right_width ? vec2(0.0) : v_normal;ANTIALIASING=!left && zero_right_width ? 0.0 : ANTIALIASING;
1619#else
1620halfwidth=(u_width_scale*width)/2.0;
1621#endif
1622float inset=gapwidth+(gapwidth > 0.0 ? ANTIALIASING : 0.0);float outset=gapwidth+halfwidth*(gapwidth > 0.0 ? 2.0 : 1.0)+(halfwidth > 0.0 ? ANTIALIASING : 0.0);mediump vec2 dist=outset*a_extrude*EXTRUDE_SCALE;mediump float u=0.5*a_direction;mediump float t=1.0-abs(u);mediump vec2 offset2=offset*a_extrude*EXTRUDE_SCALE*normal.y*mat2(t,-u,u,t);float hidden=float(opacity==0.0);vec2 extrude=dist*u_pixels_to_tile_units;
1622vec4 projected_extrude=u_matrix*vec4(extrude,0.0,0.0);vec2 projected_extrude_xy=projected_extrude.xy;
1623#ifdef ELEVATED_ROADS
1624v_road_z_offset=a_z_offset;v_tile_pos=pos+offset2*u_pixels_to_tile_units;gl_Position=u_matrix*vec4(v_tile_pos,a_z_offset,1.0);
1625#else
1626#ifdef ELEVATED
1627vec2 offsetTile=offset2*u_pixels_to_tile_units;vec2 offset_pos=pos+offsetTile;float ele=0.0;float scaled_z_offset=a_z_offset;
1628#ifdef ELEVATION_GROUND_SCALE
1629scaled_z_offset=a_z_offset*mix(1.0,u_exaggeration,a_elevation_ground_scale);
1630#endif
1631#ifdef CROSS_SLOPE_VERTICAL
1632float top=pos_normal.y-2.0*floor(pos_normal.y*0.5);float line_height=2.0*u_tile_to_meter*outset*top*u_pixels_to_tile_units[1][1]+scaled_z_offset;ele=sample_elevation(offset_pos)+line_height;projected_extrude=vec4(0);
1633#else
1634#ifdef CROSS_SLOPE_HORIZONTAL
1635float ele0=sample_elevation(offset_pos);float ele1=max(sample_elevation(offset_pos+extrude),sample_elevation(offset_pos+extrude/2.0));float ele2=max(sample_elevation(offset_pos-extrude),sample_elevation(offset_pos-extrude/2.0));float ele_max=max(ele0,max(ele1,ele2));ele=ele_max+scaled_z_offset;
1636#else
1637float ele0=sample_elevation(offset_pos);float ele1=max(sample_elevation(offset_pos+extrude),sample_elevation(offset_pos+extrude/2.0));float ele2=max(sample_elevation(offset_pos-extrude),sample_elevation(offset_pos-extrude/2.0));float ele_max=max(ele0,0.5*(ele1+ele2));ele=ele_max-ele0+ele1+scaled_z_offset;
1638#endif
1639#endif
1640v_tile_pos=offset_pos;gl_Position=u_matrix*vec4(v_tile_pos,ele,1.0)+projected_extrude;float z=clamp(gl_Position.z/gl_Position.w,0.5,1.0);float zbias=max(0.00005,(pow(z,0.8)-z)*u_zbias_factor*u_exaggeration);gl_Position.z-=(gl_Position.w*zbias);gl_Position=mix(gl_Position,AWAY,hidden);
1641#else
1642v_tile_pos=pos+offset2*u_pixels_to_tile_units;gl_Position=u_matrix*vec4(v_tile_pos,0.0,1.0);
1643#endif
1644#endif
1645#ifndef ELEVATED
1646#ifndef VARIABLE_LINE_WIDTH
1647#ifndef RENDER_TO_TEXTURE
1648float base_w=gl_Position.w;vec2 screen_width=abs(projected_extrude.xy/base_w*u_units_to_pixels);float max_extrude_component=max(screen_width.x,screen_width.y);if (width >=1.0 && base_w > 0.0 && max_extrude_component > 0.0001) {float min_pixel=1.05;if (max_extrude_component < min_pixel) {vec2 abs_pos=abs(gl_Position.xy);float is_out=max(abs_pos.x,abs_pos.y)/base_w;dilute_scale=mix(max_extrude_component/min_pixel,1.0,smoothstep(2.5,4.5,is_out));projected_extrude/=dilute_scale;}else if (gapwidth > 0.0) {float visible_ratio=(halfwidth+ANTIALIASING)/outset;vec2 visible_screen_width=screen_width*visible_ratio;float max_visible_component=max(visible_screen_width.x,visible_screen_width.y);dilute_scale=min(1.0,max_visible_component/min_pixel);}else
1649{
1650#ifdef RENDER_LINE_BORDER
1651float border_ratio=(border_width*u_width_scale+ANTIALIASING)/outset;screen_width*=border_ratio;float max_border_component=max(screen_width.x,screen_width.y);dilute_border_scale=min(1.0,max_border_component/min_pixel);
1652#endif
1653}}
1654#endif
1655#endif
1656v_tile_pos=(v_tile_pos+extrude)/EXTENT;
1657#ifdef ELEVATED_ROADS
1658gl_Position=gl_Position+projected_extrude;
1659#else
1660gl_Position=mix(gl_Position+projected_extrude,AWAY,hidden);
1661#endif
1662#endif
1663#ifdef ELEVATED_ROADS
1664#ifdef RENDER_SHADOWS
1665vec3 shd_pos=vec3(pos+(offset2+dist)*u_pixels_to_tile_units,a_z_offset);vec3 shd_pos0=shd_pos;vec3 shd_pos1=shd_pos;
1666#ifdef NORMAL_OFFSET
1667vec3 shd_pos_offset=shadow_normal_offset(vec3(0.0,0.0,1.0));shd_pos0+=shd_pos_offset*shadow_normal_offset_multiplier0();shd_pos1+=shd_pos_offset*shadow_normal_offset_multiplier1();
1668#endif
1669v_pos_light_view_0=u_light_matrix_0*vec4(shd_pos0,1);v_pos_light_view_1=u_light_matrix_1*vec4(shd_pos1,1);v_depth=gl_Position.w;
1670#endif
1671#endif
1672#ifndef RENDER_TO_TEXTURE
1673float epsilon=0.0001;float extrude_length_without_perspective=max(length(dist),epsilon);float extrude_length_with_perspective=max(length(projected_extrude_xy/gl_Position.w*u_units_to_pixels),epsilon);v_gamma_scale=mix(extrude_length_without_perspective/extrude_length_with_perspective,1.0,step(0.01,blur));
1674#else
1675v_gamma_scale=1.0;
1676#endif
1677#if defined(RENDER_LINE_GRADIENT) || defined(RENDER_LINE_TRIM_OFFSET)
1678highp float a_uv_x=a_packed[0];float a_split_index=a_packed[1];
1679#ifdef RENDER_LINE_GRADIENT
1680highp float texel_height=1.0/u_image_height;highp float half_texel_height=0.5*texel_height;v_uv=vec3(a_uv_x,a_split_index*texel_height-half_texel_height,line_progress);
1681#else
1682v_uv=vec3(a_uv_x,0.0,line_progress);
1683#endif
1684#endif
1685#ifdef RENDER_LINE_DASH
1686vec4 dashf=vec4(dash);float totalLength=dashf.z+dashf.w/65535.0;float scale=totalLength==0.0 ? 0.0 : u_tile_units_to_pixels/totalLength;v_tex=vec2(a_linesofar*scale/(floorwidth*u_floor_width_scale),(-normal.y*dashf.y+dashf.x+0.5)/u_texsize.y);
1687#endif
1688v_width2_dilute=vec4(outset,inset,dilute_scale,dilute_border_scale);
1689#ifdef VARIABLE_LINE_WIDTH
1690v_width2_dilute.x=symmetric_outset;
1691#endif
1692#ifdef FOG
1693v_fog_pos=fog_position(pos);
1694#endif
1695#ifdef INDICATOR_CUTOUT
1696v_z_offset=a_z_offset;
1697#endif
1698}`),linePattern:Vt(`#include "_prelude_fog.fragment.glsl"
1699#include "_prelude_lighting.glsl"
1700#include "_prelude_shadow.fragment.glsl"
1701#include "_prelude_indicator_cutout.fragment.glsl"
1702uniform highp float u_device_pixel_ratio;uniform highp float u_width_scale;
1702uniform highp float u_alpha_discard_threshold;uniform lowp float u_opacity_multiplier;uniform highp vec2 u_texsize;uniform highp float u_tile_units_to_pixels;uniform highp vec2 u_trim_offset;uniform highp vec2 u_trim_fade_range;uniform lowp vec4 u_trim_color;uniform sampler2D u_image;
1703#ifdef APPLY_LUT_ON_GPU
1704uniform highp sampler3D u_lutTexture;
1705#endif
1706#ifdef LINE_PATTERN_TRANSITION
1707uniform float u_pattern_transition;
1708#endif
1709in vec2 v_normal;in vec2 v_width2;in highp float v_linesofar;in float v_gamma_scale;in float v_width;
1710#ifdef RENDER_LINE_TRIM_OFFSET
1711in highp vec3 v_uv;
1712#endif
1713#ifdef ELEVATED_ROADS
1714in highp float v_road_z_offset;
1715#endif
1716#ifdef LINE_JOIN_NONE
1717in vec2 v_pattern_data;
1718#endif
1719#ifdef INDICATOR_CUTOUT
1720in highp float v_z_offset;
1721#endif
1722#ifdef RENDER_SHADOWS
1723uniform vec3 u_ground_shadow_factor;in highp vec4 v_pos_light_view_0;in highp vec4 v_pos_light_view_1;in highp float v_depth;
1724#endif
1725#pragma mapbox: define mediump uvec4 pattern
1726#ifdef LINE_PATTERN_TRANSITION
1727#pragma mapbox: define mediump uvec4 pattern_b
1728#endif
1729#pragma mapbox: define mediump float pixel_ratio
1730#pragma mapbox: define mediump float blur
1731#pragma mapbox: define mediump float opacity
1732#pragma mapbox: define lowp float emissive_strength
1733void main() {
1734#pragma mapbox: initialize mediump uvec4 pattern
1735#ifdef LINE_PATTERN_TRANSITION
1736#pragma mapbox: initialize mediump uvec4 pattern_b
1737#endif
1738#pragma mapbox: initialize mediump float pixel_ratio
1739#pragma mapbox: initialize mediump float blur
1740#pragma mapbox: initialize mediump float opacity
1741#pragma mapbox: initialize lowp float emissive_strength
1742vec2 pattern_tl=vec2(pattern.xy);vec2 pattern_br=vec2(pattern.zw);vec2 display_size=(pattern_br-pattern_tl)/pixel_ratio;highp float pattern_size=display_size.x/u_tile_units_to_pixels;float aspect=display_size.y/v_width;float dist=length(v_normal)*v_width2.s;float blur2=(u_width_scale*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);highp float pattern_x=v_linesofar/pattern_size*aspect;highp float x=mod(pattern_x,1.0);highp float y=0.5*v_normal.y+0.5;vec2 texel_size=1.0/u_texsize;highp vec2 pos=mix(pattern_tl*texel_size-texel_size,pattern_br*texel_size+texel_size,vec2(x,y));highp vec2 lod_pos=mix(pattern_tl*texel_size-texel_size,pattern_br*texel_size+texel_size,vec2(pattern_x,y));vec4 color=textureLodCustom(u_image,pos,lod_pos);
1743#ifdef APPLY_LUT_ON_GPU
1744color=applyLUT(u_lutTexture,color);
1745#endif
1746#ifdef LINE_PATTERN_TRANSITION
1747vec2 pattern_b_tl=vec2(pattern_b.xy);vec2 pattern_b_br=vec2(pattern_b.zw);highp vec2 pos_b=mix(pattern_b_tl*texel_size-texel_size,pattern_b_br*texel_size+texel_size,vec2(x,y));vec4 color_b=textureLodCustom(u_image,pos_b,lod_pos);color=color*(1.0-u_pattern_transition)+color_b*u_pattern_transition;
1748#endif
1749#ifdef RENDER_LINE_TRIM_OFFSET
1750highp float trim_start=u_trim_offset[0];highp float trim_end=u_trim_offset[1];highp float line_progress=v_uv[2];if (trim_end > trim_start) {highp float start_transition=max(0.0,min(1.0,(line_progress-trim_start)/max(u_trim_fade_range[0],1.0e-9)));highp float end_transition=max(0.0,min(1.0,(trim_end-line_progress)/max(u_trim_fade_range[1],1.0e-9)));highp float transition_factor=min(start_transition,end_transition);color=mix(color,color.a*u_trim_color,transition_factor);}
1751#endif
1752#ifdef LINE_JOIN_NONE
1753highp float pattern_len=pattern_size/aspect;highp float segment_phase=pattern_len-mod(v_linesofar-v_pattern_data.x+pattern_len,pattern_len);highp float visible_start=segment_phase-step(pattern_len*0.5,segment_phase)*pattern_len;highp float visible_end=floor((v_pattern_data.y-segment_phase)/pattern_len)*pattern_len+segment_phase;visible_end+=step(pattern_len*0.5,v_pattern_data.y-visible_end)*pattern_len;if (v_pattern_data.x < visible_start || v_pattern_data.x >=visible_end) {color=vec4(0.0);}
1754#endif
1755#ifdef LIGHTING_3D_MODE
1756color=apply_lighting_with_emission_ground(color,emissive_strength);
1757#ifdef RENDER_SHADOWS
1758float light=shadowed_light_factor(v_pos_light_view_0,v_pos_light_view_1,v_depth);
1759#ifdef ELEVATED_ROADS
1760color.rgb*=mix(v_road_z_offset !=0.0 ? u_ground_shadow_factor : vec3(1.0),vec3(1.0),light);
1761#else
1762color.rgb*=mix(u_ground_shadow_factor,vec3(1.0),light);
1763#endif
1764#endif
1765#endif
1766#ifdef FOG
1767color=fog_dither(fog_apply_premultiplied(color,v_fog_pos));
1768#endif
1769color*=(alpha*opacity*u_opacity_multiplier);if (u_alpha_discard_threshold !=0.0) {if (color.a < u_alpha_discard_threshold) {discard;}}
1770#ifdef INDICATOR_CUTOUT
1771color=applyCutout(color,v_z_offset);
1772#endif
1773glFragColor=color;
1774#ifdef DUAL_SOURCE_BLENDING
1775glFragColorSrc1=vec4(vec3(0.0),emissive_strength);
1776#else
1777#ifdef USE_MRT1
1778out_Target1=vec4(emissive_strength*glFragColor.a,0.0,0.0,glFragColor.a);
1779#endif
1780#endif
1781#ifdef OVERDRAW_INSPECTOR
1782glFragColor=vec4(1.0);
1783#endif
1784HANDLE_WIREFRAME_DEBUG;}`,`#include "_prelude_fog.vertex.glsl"
1785#include "_prelude_shadow.vertex.glsl"
1786#include "_prelude_terrain.vertex.glsl"
1787#define scale 0.015873016
1788in ivec2 a_pos_normal;in uvec4 a_data;
1789#if defined(ELEVATED) || defined(ELEVATED_ROADS)
1790in vec4 a_z_offset_width;
1791#endif
1792#ifdef ELEVATION_GROUND_SCALE
1793in float a_elevation_ground_scale;
1794#endif
1795#ifdef RENDER_LINE_TRIM_OFFSET
1796in highp vec3 a_packed;
1797#endif
1798in highp float a_linesofar;
1799#ifdef LINE_JOIN_NONE
1800in highp vec3 a_pattern_data;out vec2 v_pattern_data;
1801#endif
1802#ifdef INDICATOR_CUTOUT
1803out highp float v_z_offset;
1804#endif
1805uniform mat4 u_matrix;uniform float u_tile_units_to_pixels;uniform vec2 u_units_to_pixels;uniform mat2 u_pixels_to_tile_units;uniform float u_device_pixel_ratio;uniform float u_width_scale;uniform float u_floor_width_scale;
1806#ifdef ELEVATED
1807uniform lowp float u_zbias_factor;uniform lowp float u_tile_to_meter;float sample_elevation(vec2 apos) {
1808#ifdef ELEVATION_REFERENCE_SEA
1809return 0.0;
1810#else
1811return elevation(apos);
1812#endif
1813}
1814#endif
1815out vec2 v_normal;out vec2 v_width2;out highp float v_linesofar;out float v_gamma_scale;out float v_width;
1816#ifdef RENDER_LINE_TRIM_OFFSET
1817out highp vec3 v_uv;
1818#endif
1819#ifdef ELEVATED_ROADS
1820out highp float v_road_z_offset;
1821#endif
1822#ifdef RENDER_SHADOWS
1823uniform mat4 u_light_matrix_0;uniform mat4 u_light_matrix_1;out highp vec4 v_pos_light_view_0;out highp vec4 v_pos_light_view_1;out highp float v_depth;
1824#endif
1825#pragma mapbox: define mediump float blur
1826#pragma mapbox: define mediump float opacity
1827#pragma mapbox: define mediump float offset
1828#pragma mapbox: define mediump float gapwidth
1829#pragma mapbox: define mediump float width
1830#pragma mapbox: define mediump float floorwidth
1831#pragma mapbox: define mediump uvec4 pattern
1832#ifdef LINE_PATTERN_TRANSITION
1833#pragma mapbox: define mediump uvec4 pattern_b
1834#endif
1835#pragma mapbox: define mediump float pixel_ratio
1836#pragma mapbox: define lowp float emissive_strength
1837void main() {
1838#pragma mapbox: initialize mediump float blur
1839#pragma mapbox: initialize mediump float opacity
1840#pragma mapbox: initialize mediump float offset
1841#pragma mapbox: initialize mediump float gapwidth
1842#pragma mapbox: initialize mediump float width
1843#pragma mapbox: initialize mediump float floorwidth
1844#pragma mapbox: initialize mediump uvec4 pattern
1845#ifdef LINE_PATTERN_TRANSITION
1846#pragma mapbox: initialize mediump uvec4 pattern_b
1847#endif
1848#pragma mapbox: initialize mediump float pixel_ratio
1849#pragma mapbox: initialize lowp float emissive_strength
1850float a_z_offset;
1851#if defined(ELEVATED) || defined(ELEVATED_ROADS)
1852a_z_offset=a_z_offset_width.x;
1853#endif
1854float ANTIALIASING=1.0/u_device_pixel_ratio/2.0;vec2 a_extrude=vec2(a_data.xy)-128.0;float a_direction=float(a_data.z & 3u)-1.0;vec2 pos_normal=vec2(a_pos_normal);vec2 pos=floor(pos_normal*0.5);vec2 normal=pos_normal-2.0*pos;normal.y=normal.y*2.0-1.0;v_normal=normal;gapwidth=gapwidth/2.0;float halfwidth=(u_width_scale*width)/2.0;offset=-1.0*offset*u_width_scale;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);vec2 dist=outset*a_extrude*scale;float u=0.5*a_direction;float t=1.0-abs(u);vec2 offset2=offset*a_extrude*scale*normal.y*mat2(t,-u,u,t);float hidden=float(opacity==0.0);vec2 extrude=dist*u_pixels_to_tile_units;
1854vec4 projected_extrude=u_matrix*vec4(extrude,0.0,0.0);vec2 projected_extrude_xy=projected_extrude.xy;
1855#ifdef ELEVATED_ROADS
1856v_road_z_offset=a_z_offset;gl_Position=u_matrix*vec4(pos+offset2*u_pixels_to_tile_units,a_z_offset,1.0)+projected_extrude;
1857#else
1858#ifdef ELEVATED
1859vec2 offsetTile=offset2*u_pixels_to_tile_units;vec2 offset_pos=pos+offsetTile;float ele=0.0;float scaled_z_offset=a_z_offset;
1860#ifdef ELEVATION_GROUND_SCALE
1861scaled_z_offset=a_z_offset*mix(1.0,u_exaggeration,a_elevation_ground_scale);
1862#endif
1863#ifdef CROSS_SLOPE_VERTICAL
1864float top=pos_normal.y-2.0*floor(pos_normal.y*0.5);float line_height=2.0*u_tile_to_meter*outset*top*u_pixels_to_tile_units[1][1]+scaled_z_offset;ele=sample_elevation(offset_pos)+line_height;projected_extrude=vec4(0);
1865#else
1866#ifdef CROSS_SLOPE_HORIZONTAL
1867float ele0=sample_elevation(offset_pos);float ele1=max(sample_elevation(offset_pos+extrude),sample_elevation(offset_pos+extrude/2.0));float ele2=max(sample_elevation(offset_pos-extrude),sample_elevation(offset_pos-extrude/2.0));float ele_max=max(ele0,max(ele1,ele2));ele=ele_max+scaled_z_offset;
1868#else
1869float ele0=sample_elevation(offset_pos);float ele1=max(sample_elevation(offset_pos+extrude),sample_elevation(offset_pos+extrude/2.0));float ele2=max(sample_elevation(offset_pos-extrude),sample_elevation(offset_pos-extrude/2.0));float ele_max=max(ele0,0.5*(ele1+ele2));ele=ele_max-ele0+ele1+scaled_z_offset;
1870#endif
1871#endif
1872gl_Position=u_matrix*vec4(offset_pos,ele,1.0)+projected_extrude;float z=clamp(gl_Position.z/gl_Position.w,0.5,1.0);float zbias=max(0.00005,(pow(z,0.8)-z)*u_zbias_factor*u_exaggeration);gl_Position.z-=(gl_Position.w*zbias);gl_Position=mix(gl_Position,AWAY,hidden);
1873#else
1874gl_Position=mix(u_matrix*vec4(pos+offset2*u_pixels_to_tile_units,0.0,1.0)+projected_extrude,AWAY,hidden);
1875#endif
1876#endif
1877#ifdef ELEVATED_ROADS
1878#ifdef RENDER_SHADOWS
1879vec3 shd_pos=vec3(pos+(offset2+dist)*u_pixels_to_tile_units,a_z_offset);vec3 shd_pos0=shd_pos;vec3 shd_pos1=shd_pos;
1880#ifdef NORMAL_OFFSET
1881vec3 shd_pos_offset=shadow_normal_offset(vec3(0.0,0.0,1.0));shd_pos0+=shd_pos_offset*shadow_normal_offset_multiplier0();shd_pos1+=shd_pos_offset*shadow_normal_offset_multiplier1();
1882#endif
1883v_pos_light_view_0=u_light_matrix_0*vec4(shd_pos0,1);v_pos_light_view_1=u_light_matrix_1*vec4(shd_pos1,1);v_depth=gl_Position.w;
1884#endif
1885#endif
1886#ifndef RENDER_TO_TEXTURE
1887float extrude_length_without_perspective=length(dist);float extrude_length_with_perspective=length(projected_extrude_xy/gl_Position.w*u_units_to_pixels);v_gamma_scale=mix(extrude_length_without_perspective/extrude_length_with_perspective,1.0,step(0.01,blur));
1888#else
1889v_gamma_scale=1.0;
1890#endif
1891#ifdef RENDER_LINE_TRIM_OFFSET
1892highp float a_uv_x=a_packed[0];highp float line_progress=a_packed[2];v_uv=vec3(a_uv_x,0.0,line_progress);
1893#endif
1894v_linesofar=a_linesofar;v_width2=vec2(outset,inset);v_width=(floorwidth*u_floor_width_scale);
1895#ifdef LINE_JOIN_NONE
1896v_width=(floorwidth*u_floor_width_scale)+ANTIALIASING;mediump float pixels_to_tile_units=1.0/u_tile_units_to_pixels;mediump float pixel_ratio_inverse=1.0/pixel_ratio;mediump float aspect=v_width/(float(pattern.w-pattern.y)*pixel_ratio_inverse);highp float subt_multiple=float(pattern.z-pattern.x)*pixel_ratio_inverse*pixels_to_tile_units*aspect*32.0;highp float subt=floor(a_pattern_data.z/subt_multiple)*subt_multiple;float offset_sign=(fract(a_pattern_data.x)-0.5)*4.0;float line_progress_offset=offset_sign*v_width*0.5*pixels_to_tile_units;v_linesofar=(a_pattern_data.z-subt)+a_linesofar+line_progress_offset;v_pattern_data=vec2(a_pattern_data.x+line_progress_offset,a_pattern_data.y);
1897#endif
1898#ifdef FOG
1899v_fog_pos=fog_position(pos);
1900#endif
1901#ifdef INDICATOR_CUTOUT
1902v_z_offset=a_z_offset;
1903#endif
1904}`),raster:Vt(`#include "_prelude_fog.fragment.glsl"
1905#include "_prelude_lighting.glsl"
1906#include "_prelude_raster_array.glsl"
1907uniform float u_fade_t;uniform float u_opacity;uniform highp float u_raster_elevation;uniform highp float u_zoom_transition;in vec2 v_pos0;in vec2 v_pos1;in float v_depth;
1908#ifdef PROJECTION_GLOBE_VIEW
1909in float v_split_fade;
1910#endif
1911uniform float u_brightness_low;uniform float u_brightness_high;uniform float u_saturation_factor;uniform float u_contrast_factor;uniform vec3 u_spin_weights;uniform float u_emissive_strength;
1912#ifndef RASTER_ARRAY
1913uniform highp sampler2D u_image0;uniform sampler2D u_image1;
1914#endif
1915#ifdef RASTER_COLOR
1916uniform sampler2D u_color_ramp;uniform highp vec4 u_colorization_mix;uniform highp float u_colorization_offset;uniform vec2 u_texture_res;
1917#endif
1918void main() {vec4 color0,color1,color;vec2 value;
1919#ifdef RASTER_COLOR
1920#ifdef RASTER_ARRAY
1921#ifdef RASTER_ARRAY_LINEAR
1922value=mix(
1923raTexture2D_image0_linear(v_pos0,u_texture_res,u_colorization_mix,u_colorization_offset),raTexture2D_image1_linear(v_pos1,u_texture_res,u_colorization_mix,u_colorization_offset),u_fade_t
1924);
1925#else
1926value=mix(
1927raTexture2D_image0_nearest(v_pos0,u_texture_res,u_colorization_mix,u_colorization_offset),raTexture2D_image1_nearest(v_pos1,u_texture_res,u_colorization_mix,u_colorization_offset),u_fade_t
1928);
1929#endif
1930if (value.y > 0.0) value.x/=value.y;
1931#else
1932color=mix(texture(u_image0,v_pos0),texture(u_image1,v_pos1),u_fade_t);value=vec2(u_colorization_offset+dot(color.rgb,u_colorization_mix.rgb),color.a);
1933#endif
1934color=texture(u_color_ramp,vec2(value.x,0.5));if (color.a > 0.0) color.rgb/=color.a;color.a*=value.y;
1935#else
1936color0=texture(u_image0,v_pos0);color1=texture(u_image1,v_pos1);if (color0.a > 0.0) color0.rgb/=color0.a;if (color1.a > 0.0) color1.rgb/=color1.a;color=mix(color0,color1,u_fade_t);
1937#endif
1938color.a*=u_opacity;
1939#ifdef GLOBE_POLES
1940color.a*=1.0-smoothstep(0.0,0.05,u_zoom_transition);
1941#endif
1942vec3 rgb=color.rgb;rgb=vec3(
1943dot(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);vec3 out_color=mix(u_high_vec,u_low_vec,rgb);
1944#ifdef LIGHTING_3D_MODE
1945out_color=apply_lighting_with_emission_ground(vec4(out_color,1.0),u_emissive_strength).rgb;
1946#endif
1947#ifdef FOG
1948highp float fog_limit_high_meters=1000000.0;highp float fog_limit_low_meters=600000.0;float fog_limit=1.0-smoothstep(fog_limit_low_meters,fog_limit_high_meters,u_raster_elevation);out_color=fog_dither(fog_apply(out_color,v_fog_pos,fog_limit));
1949#endif
1950glFragColor=vec4(out_color*color.a,color.a);
1951#ifdef PROJECTION_GLOBE_VIEW
1952glFragColor*=mix(1.0,1.0-smoothstep(0.0,0.05,u_zoom_transition),smoothstep(0.8,0.9,v_split_fade));
1953#endif
1954#ifdef RENDER_CUTOFF
1955glFragColor=glFragColor*cutoff_opacity(u_cutoff_params,v_depth);
1956#endif
1957#ifdef OVERDRAW_INSPECTOR
1958glFragColor=vec4(1.0);
1959#endif
1960#ifdef USE_MRT1
1961out_Target1=vec4(u_emissive_strength*glFragColor.a,0.0,0.0,glFragColor.a);
1962#endif
1963HANDLE_WIREFRAME_DEBUG;}`,`#include "_prelude_fog.vertex.glsl"
1964#include "_prelude_terrain.vertex.glsl"
1965uniform mat4 u_matrix;uniform mat4 u_normalize_matrix;uniform mat4 u_globe_matrix;uniform mat4 u_merc_matrix;uniform mat3 u_grid_matrix;uniform vec2 u_tl_parent;uniform float u_scale_parent;uniform vec2 u_perspective_transform;uniform vec2 u_texture_offset;uniform float u_raster_elevation;uniform float u_zoom_transition;uniform vec2 u_merc_center;
1966#ifdef ELEVATED
1967uniform lowp float u_zbias_factor;
1968#endif
1969#define GLOBE_UPSCALE GLOBE_RADIUS/6371008.8
1970#ifdef GLOBE_POLES
1971in vec3 a_globe_pos;in vec2 a_uv;
1972#else
1973in ivec2 a_pos;in uvec2 a_texture_pos;
1974#endif
1975out vec2 v_pos0;out vec2 v_pos1;out float v_depth;
1976#ifdef PROJECTION_GLOBE_VIEW
1977out float v_split_fade;
1978#endif
1979void main() {vec2 uv;
1980#ifdef GLOBE_POLES
1981vec3 globe_pos=a_globe_pos;uv=a_uv;float ele=u_raster_elevation;
1982#ifdef ELEVATION_REFERENCE_GROUND
1983ele+=elevation(uv*EXTENT);
1984#endif
1985globe_pos+=normalize(globe_pos)*ele*GLOBE_UPSCALE;gl_Position=u_matrix*u_globe_matrix*vec4(globe_pos,1.0);
1986#ifdef FOG
1987v_fog_pos=fog_position((u_normalize_matrix*vec4(a_globe_pos,1.0)).xyz);
1988#endif
1989#else
1990vec4 world_pos;
1991#ifdef PROJECTION_GLOBE_VIEW
1992vec2 texture_pos=vec2(a_texture_pos);uv=texture_pos/8192.0;vec3 decomposed_pos_and_skirt=decomposeToPosAndSkirt(a_pos);vec3 latLng=u_grid_matrix*vec3(decomposed_pos_and_skirt.xy,1.0);float mercatorY=mercatorYfromLat(latLng[0]);float mercatorX=mercatorXfromLng(latLng[1]);  
1993float tiles=u_grid_matrix[0][2];
1993if (tiles > 0.0) {float idx=u_grid_matrix[1][2];float idy=u_grid_matrix[2][2];float uvY=mercatorY*tiles-idy;float uvX=mercatorX*tiles-idx;uv=vec2(uvX,uvY);}float ele=u_raster_elevation;
1994#ifdef ELEVATION_REFERENCE_GROUND
1995ele+=elevation(uv*EXTENT)-decomposed_pos_and_skirt.z;
1996#endif
1997vec4 merc_world_pos=vec4(0.0);   
1998v_split_fade=0.0;if (u_zoom_transition > 0.0) {vec2 merc_pos=vec2(mercatorX,mercatorY);merc_world_pos=vec4(merc_pos,ele,1.0);merc_world_pos.xy-=u_merc_center;merc_world_pos.x=wrap(merc_world_pos.x,-0.5,0.5);merc_world_pos=u_merc_matrix*merc_world_pos;float opposite_merc_center=mod(u_merc_center.x+0.5,1.0);float dist_from_poles=(abs(mercatorY-0.5)*2.0);float range=0.1;v_split_fade=abs(opposite_merc_center-mercatorX);v_split_fade=clamp(1.0-v_split_fade,0.0,1.0);v_split_fade=max(smoothstep(1.0-range,1.0,dist_from_poles),max(smoothstep(1.0-range,1.0,v_split_fade),smoothstep(1.0-range,1.0,1.0-v_split_fade)));}vec3 globe_pos=latLngToECEF(latLng.xy);globe_pos+=normalize(globe_pos)*ele*GLOBE_UPSCALE;vec4 globe_world_pos=u_globe_matrix*vec4(globe_pos,1.0);world_pos=vec4(mix(globe_world_pos.xyz,merc_world_pos.xyz,u_zoom_transition),1.0);
1999#ifdef FOG
2000v_fog_pos=fog_position((u_normalize_matrix*vec4(globe_pos,1.0)).xyz);
2001#endif
2002#else
2003float ele=0.0;vec2 decodedPos=vec2(a_pos);
2004#ifdef ELEVATION_REFERENCE_GROUND
2005vec3 decomposedPosAndSkirt=decomposeToPosAndSkirt(a_pos);float skirt=decomposedPosAndSkirt.z;decodedPos=decomposedPosAndSkirt.xy;uv=decodedPos/8192.0;ele=elevation(decodedPos)-skirt;
2006#else
2007uv=vec2(a_texture_pos)/8192.0;
2008#endif
2009world_pos=vec4(decodedPos,(u_raster_elevation+ele),1.0);
2010#ifdef FOG
2011v_fog_pos=fog_position(decodedPos);
2012#endif
2013#endif
2014float w=1.0+dot(uv*EXTENT,u_perspective_transform);gl_Position=u_matrix*world_pos*w;
2015#endif
2016v_pos0=uv;v_pos1=(v_pos0*u_scale_parent)+u_tl_parent;v_pos0=u_texture_offset.x+u_texture_offset.y*v_pos0;v_pos1=u_texture_offset.x+u_texture_offset.y*v_pos1;
2017#ifdef ELEVATED
2018float z=clamp(gl_Position.z/gl_Position.w,0.5,1.0);float zbias=max(0.00005,(pow(z,0.8)-z)*u_zbias_factor);gl_Position.z-=(gl_Position.w*zbias);
2019#endif
2020#ifdef RENDER_CUTOFF
2021v_depth=gl_Position.z;
2022#endif
2023}`),symbol:Vt(`#include "_prelude_lighting.glsl"
2024#include "_prelude_shadow.fragment.glsl"
2025#include "_prelude_indicator_cutout.fragment.glsl"
2026#include "_prelude_feature_cutout.fragment.glsl"
2027#define SDF_PX 8.0
2028#define SDF 1.0
2029#define ICON 0.0
2030uniform sampler2D u_texture;
2031#ifdef RENDER_TEXT_AND_SYMBOL
2032uniform sampler2D u_texture_icon;
2033#endif
2034uniform highp float u_gamma_scale;uniform lowp float u_device_pixel_ratio;uniform bool u_is_text;uniform bool u_is_sdf;uniform lowp float u_scale_factor;uniform lowp float u_opacity_multiplier;
2035#ifdef ICON_TRANSITION
2036uniform float u_icon_transition;
2037#endif
2038#ifdef COLOR_ADJUSTMENT
2039uniform mat4 u_color_adj_mat;
2040#endif
2041#ifdef INDICATOR_CUTOUT
2042in highp float v_z_offset;
2043#else
2044#ifdef RENDER_SHADOWS
2045in highp float v_z_offset;
2046#endif
2047#endif
2048in vec2 v_tex_a;
2049#ifdef ICON_TRANSITION
2050in vec2 v_tex_b;
2051#endif
2052in float v_draw_halo;in vec3 v_gamma_scale_size_fade_opacity;
2053#ifdef RENDER_TEXT_AND_SYMBOL
2054in float is_sdf;in vec2 v_tex_a_icon;
2055#endif
2056#ifdef RENDER_SHADOWS
2057uniform vec3 u_ground_shadow_factor;in highp vec4 v_pos_light_view_0;in highp vec4 v_pos_light_view_1;in highp float v_depth;
2058#endif
2059#ifdef APPLY_LUT_ON_GPU
2060uniform highp sampler3D u_lutTexture;
2061#endif
2062in lowp float v_opacity;in lowp vec4 v_fill_np_color;in lowp vec4 v_halo_np_color;in lowp float v_halo_width;in lowp float v_halo_blur;
2063#ifdef LIGHTING_3D_MODE
2064in lowp float v_emissive_strength;
2065#endif
2066void main() {lowp float opacity=v_opacity;lowp vec4 fill_color=vec4(0.0);lowp vec4 halo_color=vec4(0.0);lowp float halo_width=0.0;lowp float halo_blur=0.0;if (u_is_sdf) {fill_color=vec4(v_fill_np_color.rgb*v_fill_np_color.a,v_fill_np_color.a);halo_color=vec4(v_halo_np_color.rgb*v_halo_np_color.a,v_halo_np_color.a);halo_width=v_halo_width;halo_blur=v_halo_blur;}lowp float emissive_strength=0.0;
2067#ifdef LIGHTING_3D_MODE
2068emissive_strength=v_emissive_strength;
2069#endif
2070vec4 out_color;float fade_opacity=v_gamma_scale_size_fade_opacity[2];
2071#ifdef RENDER_TEXT_AND_SYMBOL
2072if (is_sdf==ICON) {vec2 tex_icon=v_tex_a_icon;lowp float alpha=opacity*fade_opacity*u_opacity_multiplier;
2072glFragColor=texture(u_texture_icon,tex_icon)*alpha;
2073#ifdef OVERDRAW_INSPECTOR
2074glFragColor=vec4(1.0);
2075#endif
2076return;}
2077#endif
2078vec2 cutout_factors=vec2(0.0);
2079#ifdef FEATURE_CUTOUT
2080cutout_factors=get_cutout_factors(gl_FragCoord);
2081#endif
2082if (u_is_sdf) {float EDGE_GAMMA=0.105/u_device_pixel_ratio;float gamma_scale=v_gamma_scale_size_fade_opacity.x;float size=v_gamma_scale_size_fade_opacity.y;float fontScale=u_is_text ? size/24.0 : size;out_color=fill_color;highp float gamma=EDGE_GAMMA/(fontScale*u_gamma_scale);lowp float buff=(256.0-64.0)/256.0;bool draw_halo=v_draw_halo > 0.0;if (draw_halo) {out_color=halo_color;gamma=(halo_blur*u_scale_factor*1.19/SDF_PX+EDGE_GAMMA)/(fontScale*u_gamma_scale);buff=(6.0-halo_width*u_scale_factor/fontScale)/SDF_PX;}lowp float dist=texture(u_texture,v_tex_a).r;highp float gamma_scaled=gamma*gamma_scale;highp float alpha=smoothstep(buff-gamma_scaled,buff+gamma_scaled,dist);out_color*=alpha;} else {
2083#ifdef ICON_TRANSITION
2084vec4 a=texture(u_texture,v_tex_a)*(1.0-u_icon_transition);vec4 b=texture(u_texture,v_tex_b)*u_icon_transition;out_color=(a+b);
2085#else
2086out_color=texture(u_texture,v_tex_a);
2087#endif
2088#ifdef APPLY_LUT_ON_GPU
2089out_color=applyLUT(u_lutTexture,out_color);
2090#endif
2091#ifdef COLOR_ADJUSTMENT
2092out_color=u_color_adj_mat*out_color;
2093#endif
2094}out_color*=opacity*fade_opacity*u_opacity_multiplier;
2095#ifdef LIGHTING_3D_MODE
2096out_color=apply_lighting_with_emission_ground(out_color,emissive_strength);
2097#ifdef RENDER_SHADOWS
2098float light=shadowed_light_factor(v_pos_light_view_0,v_pos_light_view_1,v_depth);light=mix(light,1.0,cutout_factors.y);
2099#ifdef TERRAIN
2100out_color.rgb*=mix(u_ground_shadow_factor,vec3(1.0),light);
2101#else
2102out_color.rgb*=mix(v_z_offset !=0.0 ? u_ground_shadow_factor : vec3(1.0),vec3(1.0),light);
2103#endif
2104#endif
2105#endif
2106#ifdef INDICATOR_CUTOUT
2107out_color=applyCutout(out_color,v_z_offset);
2108#endif
2109#ifdef FEATURE_CUTOUT
2110out_color=apply_feature_cutout(out_color,gl_FragCoord,cutout_factors.x,0.0);
2111#endif
2112glFragColor=out_color;
2113#ifdef OVERDRAW_INSPECTOR
2114glFragColor=vec4(1.0);
2115#endif
2116HANDLE_WIREFRAME_DEBUG;}`,`#include "_prelude_terrain.vertex.glsl"
2117#include "_prelude_shadow.vertex.glsl"
2118#define USING_APPEARANCE 1.0
2119in ivec4 a_pos_offset;in uvec4 a_tex_size;in ivec4 a_pixeloffset;in vec4 a_projected_pos;in uint a_fade_opacity;
2120#ifdef Z_OFFSET
2121in float a_auto_z_offset;
2122#endif
2123#ifdef PROJECTION_GLOBE_VIEW
2124in ivec4 a_globe_anchor;in vec3 a_globe_normal;
2125#endif
2126#ifdef ICON_TRANSITION
2127in uvec2 a_texb;
2128#endif
2129#ifdef OCCLUSION_QUERIES
2130in float a_occlusion_query_opacity;
2131#endif
2132#ifdef ELEVATED_ROADS
2133in vec3 a_x_axis;in vec3 a_y_axis;uniform float u_normal_scale;
2134#endif
2135#ifdef INDICATOR_CUTOUT
2136out highp float v_z_offset;
2137#else
2138#ifdef RENDER_SHADOWS
2139out highp float v_z_offset;
2140#endif
2141#endif
2142uniform 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_matrix;
2143#ifdef RENDER_SHADOWS
2144uniform mat4 u_inv_matrix;
2145#endif
2146uniform mat4 u_label_plane_matrix;uniform mat4 u_coord_matrix;uniform bool u_is_text;uniform bool u_elevation_from_sea;uniform bool u_pitch_with_map;uniform bool u_rotate_symbol;uniform highp float u_aspect_ratio;uniform highp float u_camera_to_center_distance;uniform float u_fade_change;uniform vec2 u_texsize;
2147#ifdef PROJECTION_GLOBE_VIEW
2148uniform vec3 u_up_vector;
2149#endif
2150#ifdef RENDER_TEXT_AND_SYMBOL
2151uniform vec2 u_texsize_icon;
2152#endif
2153uniform bool u_is_halo;
2154#ifdef PROJECTION_GLOBE_VIEW
2155uniform vec3 u_tile_id;uniform mat4 u_inv_rot_matrix;uniform vec2 u_merc_center;uniform vec3 u_camera_forward;uniform float u_zoom_transition;uniform vec3 u_ecef_origin;uniform mat4 u_tile_matrix;
2156#endif
2157out vec2 v_tex_a;
2158#ifdef ICON_TRANSITION
2159out vec2 v_tex_b;
2160#endif
2161out float v_draw_halo;out vec3 v_gamma_scale_size_fade_opacity;
2162#ifdef RENDER_TEXT_AND_SYMBOL
2163out float is_sdf;out vec2 v_tex_a_icon;
2164#endif
2165#ifdef RENDER_SHADOWS
2166uniform mat4 u_light_matrix_0;uniform mat4 u_light_matrix_1;out highp vec4 v_pos_light_view_0;out highp vec4 v_pos_light_view_1;out highp float v_depth;
2167#endif
2168#ifndef MAX_UBO_SIZE_VEC4
2169#define MAX_UBO_SIZE_VEC4 1024u
2170#endif
2171#define SPP_HEADER_SIZE_VEC4 3u
2172#define DWORDS_PER_VEC4 4u
2173struct SymbolPaintProperties {vec4 fill_np_color;vec4 halo_np_color;float opacity;float halo_width;float halo_blur;float emissive_strength;float occlusion_opacity;float z_offset;vec2 translate;};struct PropertyType {bool isDataDriven;bool isZoomDependent;uint offsetDwords;float zoomFactor;bool hasAppearanceZoomStops;};struct SymbolPropertyHeader {uint dataDrivenBlockSizeVec4;PropertyType fill_np_color;PropertyType halo_np_color;PropertyType opacity;PropertyType halo_width;PropertyType halo_blur;PropertyType emissive_strength;PropertyType occlusion_opacity;PropertyType z_offset;PropertyType translate;};uniform lowp vec4 u_spp_fill_np_color;uniform lowp vec4 u_spp_halo_np_color;uniform lowp float u_spp_opacity;uniform lowp float u_spp_halo_width;uniform lowp float u_spp_halo_blur;uniform lowp float u_spp_emissive_strength;uniform lowp float u_spp_occlusion_opacity;uniform highp float u_spp_z_offset;uniform lowp vec2 u_spp_translate_rotation;uniform highp float u_spp_fill_color_zoom_factor;uniform highp float u_spp_halo_color_zoom_factor;uniform highp float u_spp_opacity_zoom_factor;uniform highp float u_spp_halo_width_zoom_factor;uniform highp float u_spp_halo_blur_zoom_factor;uniform highp float u_spp_emissive_strength_zoom_factor;uniform highp float u_spp_occlusion_opacity_zoom_factor;uniform highp float u_spp_z_offset_zoom_factor;uniform highp float u_spp_translate_zoom_factor;uniform highp float u_spp_zoom_fraction;in float a_feature_index;layout(std140) uniform SymbolPaintPropertiesHeaderUniform {uvec4 header[SPP_HEADER_SIZE_VEC4];} u_spp_header;layout(std140) uniform SymbolPaintPropertiesUniform {vec4 properties[MAX_UBO_SIZE_VEC4];} u_spp_properties;layout(std140) uniform SymbolPaintPropertiesIndexUniform {uvec4 block_indices[MAX_UBO_SIZE_VEC4];} u_spp_index;out lowp float v_opacity;out lowp vec4 v_fill_np_color;out lowp vec4 v_halo_np_color;out lowp float v_halo_width;out lowp float v_halo_blur;
2174#ifdef LIGHTING_3D_MODE
2175out lowp float v_emissive_strength;
2176#endif
2177PropertyType getPropertyType(uint propertyIndex,uint dataDrivenMask,uint zoomDependentMask,uint appearanceZoomStopsMask,uint offsetDwords,float zoomFactor) {PropertyType type;type.isDataDriven=(dataDrivenMask & (1u << propertyIndex)) !=0u;type.isZoomDependent=(zoomDependentMask & (1u << propertyIndex)) !=0u;type.offsetDwords=offsetDwords;type.zoomFactor=zoomFactor;type.hasAppearanceZoomStops=(appearanceZoomStopsMask & (1u << propertyIndex)) !=0u;return type;}SymbolPropertyHeader readSymbolPropertiesHeader() {SymbolPropertyHeader header;uint dataDrivenMask           =u_spp_header.header[0][0];uint zoomMask                 =u_spp_header.header[0][1];uint zoomDependentMask        =zoomMask & 0xFFFFu;uint appearanceZoomStopsMask  =zoomMask >> 16u;header.dataDrivenBlockSizeVec4=u_spp_header.header[0][2];header.fill_np_color    =getPropertyType(0u,dataDrivenMask,zoomDependentMask,appearanceZoomStopsMask,u_spp_header.header[0][3],u_spp_fill_color_zoom_factor);header.halo_np_color    =getPropertyType(1u,dataDrivenMask,zoomDependentMask,appearanceZoomStopsMask,u_spp_header.header[1][0],u_spp_halo_color_zoom_factor);header.opacity          =getPropertyType(2u,dataDrivenMask,zoomDependentMask,appearanceZoomStopsMask,u_spp_header.header[1][1],u_spp_opacity_zoom_factor);header.halo_width       =getPropertyType(3u,dataDrivenMask,zoomDependentMask,appearanceZoomStopsMask,u_spp_header.header[1][2],u_spp_halo_width_zoom_factor);header.halo_blur        =getPropertyType(4u,dataDrivenMask,zoomDependentMask,appearanceZoomStopsMask,u_spp_header.header[1][3],u_spp_halo_blur_zoom_factor);header.emissive_strength=getPropertyType(5u,dataDrivenMask,zoomDependentMask,appearanceZoomStopsMask,u_spp_header.header[2][0],u_spp_emissive_strength_zoom_factor);header.occlusion_opacity=getPropertyType(6u,dataDrivenMask,zoomDependentMask,appearanceZoomStopsMask,u_spp_header.header[2][1],u_spp_occlusion_opacity_zoom_factor);header.z_offset         =getPropertyType(7u,dataDrivenMask,zoomDependentMask,appearanceZoomStopsMask,u_spp_header.header[2][2],u_spp_z_offset_zoom_factor);header.translate        =getPropertyType(8u,dataDrivenMask,zoomDependentMask,appearanceZoomStopsMask,u_spp_header.header[2][3],u_spp_translate_zoom_factor);return header;}float appearanceZoomStopsFactor(float zm,float zM) {if (zm==zM) {return u_spp_zoom_fraction >=zm ? 1.0 : 0.0;}return clamp((u_spp_zoom_fraction-zm)/(zM-zm),0.0,1.0);}uint uvec4At(uvec4 v,uint index) {return (index==0u) ? v.x :
2178(index==1u) ? v.y :
2179(index==2u) ? v.z : v.w;}float vec4At(vec4 v,uint index) {return (index==0u) ? v.x :
2180(index==1u) ? v.y :
2181(index==2u) ? v.z : v.w;}vec4 readVec4(uint baseOffsetVec4,uint propertyOffsetDwords) {return u_spp_properties.properties[baseOffsetVec4+propertyOffsetDwords/DWORDS_PER_VEC4];}float readFloat(vec4 slot,uint propertyOffsetDwords) {return vec4At(slot,propertyOffsetDwords % DWORDS_PER_VEC4);}uint readUint(uvec4 slot,uint offset) {return uvec4At(slot,offset % DWORDS_PER_VEC4);}vec2 readVec2(vec4 slot,uint propertyOffsetDwords) {float x=vec4At(slot,propertyOffsetDwords % DWORDS_PER_VEC4);float y=vec4At(slot,propertyOffsetDwords % DWORDS_PER_VEC4+1u);return vec2(x,y);}uint getDataDrivenBlockOffsetVec4(uint dataDrivenBlockSizeVec4) {uint featureIndex=uint(a_feature_index);uvec4 slot=u_spp_index.block_indices[featureIndex/DWORDS_PER_VEC4];uint blockIndex=uvec4At(slot,featureIndex % DWORDS_PER_VEC4);return blockIndex*dataDrivenBlockSizeVec4;}vec4 readColorProperty(PropertyType propertyType,uint dataDrivenBlockSizeVec4) {uint blockOffsetVec4=getDataDrivenBlockOffsetVec4(dataDrivenBlockSizeVec4);vec4 color=readVec4(blockOffsetVec4,propertyType.offsetDwords);if (propertyType.isZoomDependent) {float t=propertyType.zoomFactor;if (propertyType.hasAppearanceZoomStops) {vec4 zoomRange=readVec4(blockOffsetVec4,propertyType.offsetDwords+4u);t=appearanceZoomStopsFactor(zoomRange.x,zoomRange.y);}color=unpack_mix_color(color,t);} else {vec2 packedColor=readVec2(color,propertyType.offsetDwords);color=decode_color(packedColor);}return color;}vec2 readVec2Property(PropertyType propertyType,uint dataDrivenBlockSizeVec4) {uint blockOffsetVec4=getDataDrivenBlockOffsetVec4(dataDrivenBlockSizeVec4);vec4 slot=readVec4(blockOffsetVec4,propertyType.offsetDwords);if (propertyType.isZoomDependent) {float t=propertyType.zoomFactor;if (propertyType.hasAppearanceZoomStops) {vec4 zoomRange=readVec4(blockOffsetVec4,propertyType.offsetDwords+4u);t=appearanceZoomStopsFactor(zoomRange.x,zoomRange.y);}return mix(slot.xy,slot.zw,t);}return readVec2(slot,propertyType.offsetDwords);}float readFloatProperty(PropertyType propertyType,uint dataDrivenBlockSizeVec4) {uint blockOffsetVec4=getDataDrivenBlockOffsetVec4(dataDrivenBlockSizeVec4);vec4 slot=readVec4(blockOffsetVec4,propertyType.offsetDwords);float value;if (propertyType.isZoomDependent) {vec2 packedValues=readVec2(slot,propertyType.offsetDwords);float t=propertyType.hasAppearanceZoomStops
2182? appearanceZoomStopsFactor(readFloat(slot,propertyType.offsetDwords+2u),readFloat(slot,propertyType.offsetDwords+3u))
2183: propertyType.zoomFactor;value=unpack_mix_vec2(packedValues,t);} else {value=readFloat(slot,propertyType.offsetDwords);}return value;}SymbolPaintProperties readSymbolPaintProperties() {SymbolPropertyHeader header=readSymbolPropertiesHeader();uint sizeVec4=header.dataDrivenBlockSizeVec4;SymbolPaintProperties props;props.fill_np_color       =header.fill_np_color.isDataDriven     ? readColorProperty(header.fill_np_color,sizeVec4)     : u_spp_fill_np_color;props.halo_np_color       =header.halo_np_color.isDataDriven     ? readColorProperty(header.halo_np_color,sizeVec4)     : u_spp_halo_np_color;props.opacity             =header.opacity.isDataDriven           ? readFloatProperty(header.opacity,sizeVec4)           : u_spp_opacity;props.halo_width          =header.halo_width.isDataDriven        ? readFloatProperty(header.halo_width,sizeVec4)        : u_spp_halo_width;props.halo_blur           =header.halo_blur.isDataDriven         ? readFloatProperty(header.halo_blur,sizeVec4)         : u_spp_halo_blur;props.emissive_strength   =header.emissive_strength.isDataDriven ? readFloatProperty(header.emissive_strength,sizeVec4) : u_spp_emissive_strength;props.occlusion_opacity   =header.occlusion_opacity.isDataDriven ? readFloatProperty(header.occlusion_opacity,sizeVec4) : u_spp_occlusion_opacity;props.z_offset            =header.z_offset.isDataDriven          ? readFloatProperty(header.z_offset,sizeVec4)          : u_spp_z_offset;props.translate           =header.translate.isDataDriven         ? readVec2Property(header.translate,sizeVec4)          : vec2(0.0);return props;}vec2 unpack_opacity(uint packedOpacity) {return vec2(float(packedOpacity/2u)/127.0,float(packedOpacity & 1u));}void main() {SymbolPaintProperties paint_properties=readSymbolPaintProperties();lowp float opacity=paint_properties.opacity;v_opacity=opacity;v_fill_np_color=paint_properties.fill_np_color;v_halo_np_color=paint_properties.halo_np_color;v_halo_width=paint_properties.halo_width;v_halo_blur=paint_properties.halo_blur;
2184#ifdef LIGHTING_3D_MODE
2185v_emissive_strength=paint_properties.emissive_strength;
2186#endif
2187lowp float occlusion_opacity=paint_properties.occlusion_opacity;highp float z_offset=paint_properties.z_offset;vec2 a_pos=vec2(a_pos_offset.xy);vec2 a_offset=vec2(a_pos_offset.zw);vec2 a_tex=vec2(a_tex_size.xy);vec2 a_size=vec2(a_tex_size.zw);float a_size_min=floor(a_size[0]*0.5);float a_size_max= floor(a_size[1]*0.5);float a_apperance=a_size[1]-2.0*a_size_max;vec2 a_pxoffset=vec2(a_pixeloffset.xy);vec2 a_min_font_scale=vec2(a_pixeloffset.zw)/256.0;highp float segment_angle=-a_projected_pos[3];float size;if (a_apperance==USING_APPEARANCE) {size=a_size_max/128.0;} else if (!u_is_size_zoom_constant && !u_is_size_feature_constant) {size=mix(a_size_min,a_size_max,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 tile_anchor=a_pos;float e=u_elevation_from_sea ? z_offset : z_offset+elevation(tile_anchor);
2188#ifdef Z_OFFSET
2189e+=a_auto_z_offset;
2190#endif
2191vec3 h=elevationVector(tile_anchor)*e;float globe_occlusion_fade;vec3 world_pos;vec3 mercator_pos;vec3 world_pos_globe;
2192#ifdef PROJECTION_GLOBE_VIEW
2193mercator_pos=mercator_tile_position(u_inv_rot_matrix,tile_anchor,u_tile_id,u_merc_center);world_pos_globe=vec3(a_globe_anchor)+h;world_pos=mix_globe_mercator(world_pos_globe,mercator_pos,u_zoom_transition);vec4 ecef_point=u_tile_matrix*vec4(world_pos,1.0);vec3 origin_to_point=ecef_point.xyz-u_ecef_origin;globe_occlusion_fade=dot(origin_to_point,u_camera_forward) >=0.0 ? 0.0 : 1.0;
2194#else
2195world_pos=vec3(tile_anchor,0)+h;globe_occlusion_fade=1.0;
2196#endif
2197vec4 projected_point=u_matrix*vec4(world_pos,1);highp float camera_to_anchor_distance=projected_point.w;highp float distance_ratio=u_pitch_with_map ?
2198camera_to_anchor_distance/u_camera_to_center_distance :
2199u_camera_to_center_distance/camera_to_anchor_distance;highp float perspective_ratio=clamp(
22000.5+0.5*distance_ratio,0.0,1.5);size*=perspective_ratio;float font_scale=u_is_text ? size/24.0 : size;highp float symbol_rotation=0.0;if (u_rotate_symbol) {vec4 offsetprojected_point;vec2 a;
2201#ifdef PROJECTION_GLOBE_VIEW
2202vec3 displacement=vec3(a_globe_normal.z,0,-a_globe_normal.x);
2202offsetprojected_point=u_matrix*vec4(vec3(a_globe_anchor)+displacement,1);vec4 projected_point_globe=u_matrix*vec4(world_pos_globe,1);a=projected_point_globe.xy/projected_point_globe.w;
2203#else
2204offsetprojected_point=u_matrix*vec4(tile_anchor+vec2(1,0),0,1);a=projected_point.xy/projected_point.w;
2205#endif
2206vec2 b=offsetprojected_point.xy/offsetprojected_point.w;symbol_rotation=atan((b.y-a.y)/u_aspect_ratio,b.x-a.x);}vec4 projected_pos;
2207#ifdef PROJECTION_GLOBE_VIEW
2208#ifdef PROJECTED_POS_ON_VIEWPORT
2209projected_pos=u_label_plane_matrix*vec4(a_projected_pos.xyz+h,1.0);
2210#else
2211vec3 proj_pos=mix_globe_mercator(a_projected_pos.xyz,mercator_pos,u_zoom_transition)+h;projected_pos=u_label_plane_matrix*vec4(proj_pos,1.0);    
2212#endif
2213#else
2214projected_pos=u_label_plane_matrix*vec4(a_projected_pos.xy,h.z,1.0);
2215#endif
2216highp 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);float z=0.0;vec2 offset=rotation_matrix*(a_offset/32.0*max(a_min_font_scale,font_scale)+a_pxoffset/16.0);
2217#ifdef TERRAIN
2218#ifdef PITCH_WITH_MAP_TERRAIN
2219vec4 tile_pos=u_label_plane_matrix_inv*vec4(a_projected_pos.xy+offset,0.0,1.0);z=elevation(tile_pos.xy);
2220#endif
2221#endif
2222#ifdef Z_OFFSET
2223z+=u_pitch_with_map ? a_auto_z_offset+z_offset : 0.0;
2224#else
2225z+=u_pitch_with_map ? z_offset : 0.0;
2226#endif
2227float occlusion_fade=globe_occlusion_fade;vec2 fade_opacity=unpack_opacity(a_fade_opacity);float fade_change=fade_opacity[1] > 0.5 ? u_fade_change :-u_fade_change;float out_fade_opacity=max(0.0,min(occlusion_fade,fade_opacity[0]+fade_change));
2228#ifdef DEPTH_OCCLUSION
2229float depth_occlusion=occlusionFadeMultiSample(projected_point);float depth_occlusion_multplier=mix(occlusion_opacity,1.0,depth_occlusion);out_fade_opacity*=depth_occlusion_multplier;
2230#endif
2231#ifdef OCCLUSION_QUERIES
2232float occludedFadeMultiplier=mix(occlusion_opacity,1.0,a_occlusion_query_opacity);out_fade_opacity*=occludedFadeMultiplier;
2233#endif
2234#ifdef Z_TEST_OCCLUSION
2235out_fade_opacity*=occlusion_opacity;
2236#endif
2237float alpha=opacity*out_fade_opacity;float hidden=float(alpha==0.0 || projected_point.w <=0.0 || occlusion_fade==0.0);vec3 pos;
2238#ifdef PROJECTION_GLOBE_VIEW
2239vec3 xAxis=u_pitch_with_map ? normalize(cross(a_globe_normal,u_up_vector)) : vec3(1,0,0);vec3 yAxis=u_pitch_with_map ? normalize(cross(a_globe_normal,xAxis)) : vec3(0,1,0);pos=projected_pos.xyz/projected_pos.w+xAxis*offset.x+yAxis*offset.y;
2240#else
2241#ifdef ELEVATED_ROADS
2242vec3 xAxis=vec3(a_x_axis.xy,a_x_axis.z*u_normal_scale);vec3 yAxis=vec3(a_y_axis.xy,a_y_axis.z*u_normal_scale);pos=projected_pos.xyz/projected_pos.w+xAxis*offset.x+yAxis*offset.y;
2243#else
2244pos=vec3(projected_pos.xy/projected_pos.w+offset,z);
2245#endif
2246#endif
2247gl_Position=mix(u_coord_matrix*vec4(pos,1.0),AWAY,hidden);{vec2 tr=paint_properties.translate;vec2 rotated_tr=vec2(
2248u_spp_translate_rotation.x*tr.x-u_spp_translate_rotation.y*tr.y,u_spp_translate_rotation.y*tr.x+u_spp_translate_rotation.x*tr.y
2249);gl_Position.xy+=(u_coord_matrix*vec4(rotated_tr,0.0,0.0)).xy;}float gamma_scale=gl_Position.w;v_draw_halo=(u_is_halo && float(gl_InstanceID)==0.0) ? 1.0 : 0.0;v_gamma_scale_size_fade_opacity=vec3(gamma_scale,size,out_fade_opacity);v_tex_a=a_tex/u_texsize;
2250#ifdef RENDER_TEXT_AND_SYMBOL
2251is_sdf=a_size[0]-2.0*a_size_min;v_tex_a_icon=a_tex/u_texsize_icon;
2252#endif
2253#ifdef ICON_TRANSITION
2254v_tex_b=vec2(a_texb)/u_texsize;
2255#endif
2256#ifdef RENDER_SHADOWS
2257vec4 shd_pos=u_inv_matrix*vec4(pos,1.0);vec3 shd_pos0=shd_pos.xyz;vec3 shd_pos1=shd_pos.xyz;
2258#ifdef NORMAL_OFFSET
2259vec3 shd_pos_offset=shadow_normal_offset(vec3(0.0,0.0,1.0));shd_pos0+=shd_pos_offset*shadow_normal_offset_multiplier0();shd_pos1+=shd_pos_offset*shadow_normal_offset_multiplier1();
2260#endif
2261v_pos_light_view_0=u_light_matrix_0*vec4(shd_pos0,1);v_pos_light_view_1=u_light_matrix_1*vec4(shd_pos1,1);v_depth=gl_Position.w;
2262#endif
2263#ifdef INDICATOR_CUTOUT
2264v_z_offset=e;
2265#else
2266#ifdef RENDER_SHADOWS
2267v_z_offset=e;
2268#endif
2269#endif
2270}`),terrainRaster:Vt(`#include "_prelude_fog.fragment.glsl"
2271#include "_prelude_shadow.fragment.glsl"
2272#include "_prelude_lighting.glsl"
2273uniform sampler2D u_image0;
2274#ifdef LIGHTING_3D_ALPHA_EMISSIVENESS
2275uniform sampler2D u_image1;uniform float u_emissive_texture_available;
2276#endif
2277in vec2 v_pos0;
2278#ifdef FOG
2279in float v_fog_opacity;
2280#endif
2281#ifdef RENDER_SHADOWS
2282in vec4 v_pos_light_view_0;in vec4 v_pos_light_view_1;
2283#endif
2284uniform vec3 u_ground_shadow_factor;void main() {vec4 image_color=texture(u_image0,v_pos0);vec4 color;
2285#ifdef LIGHTING_3D_MODE
2286const vec3 normal=vec3(0.0,0.0,1.0);
2287#ifdef RENDER_SHADOWS
2288float cutoffOpacity=1.0;
2289#ifdef RENDER_CUTOFF
2290cutoffOpacity=cutoff_opacity(u_cutoff_params,1.0/gl_FragCoord.w);
2291#endif
2292#ifdef LIGHTING_3D_ALPHA_EMISSIVENESS
2293float emissive_strength=u_emissive_texture_available > 0.5 ? texture(u_image1,v_pos0).r : image_color.a;vec3 unlit_base=image_color.rgb*(1.0-emissive_strength);vec3 emissive_base=image_color.rgb*emissive_strength;float ndotl=u_shadow_direction.z;float occlusion=ndotl < 0.0 ? 1.0 : shadow_occlusion(v_pos_light_view_0,v_pos_light_view_1,1.0/gl_FragCoord.w,0.0);ndotl=max(0.0,ndotl);vec3 lit=apply_lighting(unlit_base,normal,mix(1.0,(1.0-(u_shadow_intensity*occlusion))*ndotl,cutoffOpacity));vec3 emissive=compute_emissive_draped(emissive_base,1.0-u_shadow_intensity,occlusion,u_ground_shadow_factor);color.rgb=lit+emissive;color.a=1.0;
2294#else
2295float lighting_factor=shadowed_light_factor_normal_unbiased(normal,v_pos_light_view_0,v_pos_light_view_1,1.0/gl_FragCoord.w);color=apply_lighting(image_color,normal,mix(1.0,lighting_factor,cutoffOpacity));
2296#endif
2297#else
2298float lighting_factor=u_lighting_directional_dir.z;color=apply_lighting(image_color,normal,lighting_factor);
2299#ifdef LIGHTING_3D_ALPHA_EMISSIVENESS
2300float emissive_strength=u_emissive_texture_available > 0.5 ? texture(u_image1,v_pos0).r : image_color.a;color.rgb=mix(color.rgb,image_color.rgb,emissive_strength);color.a=1.0;
2301#endif
2302#endif
2303#else
2304color=image_color;
2305#endif
2306#ifdef FOG
2307#ifdef ZERO_EXAGGERATION
2308color=fog_dither(fog_apply_premultiplied(color,v_fog_pos));
2309#else
2310color=fog_dither(fog_apply_from_vert(color,v_fog_opacity));
2311#endif
2312#endif
2313glFragColor=color;
2314#ifdef OVERDRAW_INSPECTOR
2315glFragColor=vec4(1.0);
2316#endif
2317HANDLE_WIREFRAME_DEBUG;}`,`#include "_prelude_fog.vertex.glsl"
2318#include "_prelude_terrain.vertex.glsl"
2319uniform mat4 u_matrix;uniform float u_skirt_height;in ivec2 a_pos;out vec2 v_pos0;
2320#ifdef FOG
2321out float v_fog_opacity;
2322#endif
2323#ifdef RENDER_SHADOWS
2324uniform mat4 u_light_matrix_0;uniform mat4 u_light_matrix_1;out vec4 v_pos_light_view_0;out vec4 v_pos_light_view_1;
2325#endif
2326void main() {vec3 decomposedPosAndSkirt=decomposeToPosAndSkirt(a_pos);float skirt=decomposedPosAndSkirt.z;vec2 decodedPos=decomposedPosAndSkirt.xy;float elevation=elevation(decodedPos)-skirt*u_skirt_height;v_pos0=decodedPos/8192.0;
2327#ifdef VIEWPORT_ORIGIN_TOP_LEFT
2328v_pos0.y=1.0-v_pos0.y;
2329#endif
2330gl_Position=u_matrix*vec4(decodedPos,elevation,1.0);
2331#ifdef FOG
2332#ifdef ZERO_EXAGGERATION
2333v_fog_pos=fog_position(decodedPos);
2334#else
2335v_fog_opacity=fog(fog_position(vec3(decodedPos,elevation)));
2336#endif
2337#endif
2338#ifdef RENDER_SHADOWS
2339vec3 pos=vec3(decodedPos,elevation);v_pos_light_view_0=u_light_matrix_0*vec4(pos,1.);v_pos_light_view_1=u_light_matrix_1*vec4(pos,1.);
2340#endif
2341}`),terrainDepth:Vt("precision highp float;in float v_depth;void main() {glFragColor=pack_depth(v_depth);}",`#include "_prelude_terrain.vertex.glsl"
2342uniform mat4 u_matrix;in ivec2 a_pos;out float v_depth;void main() {float elevation=elevation(vec2(a_pos));gl_Position=u_matrix*vec4(a_pos,elevation,1.0);v_depth=gl_Position.z/gl_Position.w;}`),skybox:Vt(`#include "_prelude_fog.fragment.glsl"
2343in lowp vec3 v_uv;uniform lowp samplerCube u_cubemap;uniform lowp float u_opacity;uniform highp float u_temporal_offset;uniform highp vec3 u_sun_direction;float sun_disk(highp vec3 ray_direction,highp vec3 sun_direction) {highp float cos_angle=dot(normalize(ray_direction),sun_direction);const highp float cos_sun_angular_diameter=0.99996192306;const highp float smoothstep_delta=1e-5;return smoothstep(
2344cos_sun_angular_diameter-smoothstep_delta,cos_sun_angular_diameter+smoothstep_delta,cos_angle);}float map(float value,float start,float end,float new_start,float new_end) {return ((value-start)*(new_end-new_start))/(e
2344nd-start)+new_start;}void main() {vec3 uv=v_uv;const float y_bias=0.015;uv.y+=y_bias;uv.y=pow(abs(uv.y),1.0/5.0);uv.y=map(uv.y,0.0,1.0,-1.0,1.0);vec3 sky_color=texture(u_cubemap,uv).rgb;
2345#ifdef FOG
2346sky_color=fog_apply_sky_gradient(v_uv.xzy,sky_color);
2347#endif
2348sky_color+=0.1*sun_disk(v_uv,u_sun_direction);glFragColor=vec4(sky_color*u_opacity,u_opacity);
2349#ifdef OVERDRAW_INSPECTOR
2350glFragColor=vec4(1.0);
2351#endif
2352}`,Kd),skyboxGradient:Vt(`#include "_prelude_fog.fragment.glsl"
2353in highp vec3 v_uv;uniform lowp sampler2D u_color_ramp;uniform highp vec3 u_center_direction;uniform lowp float u_radius;uniform lowp float u_opacity;uniform highp float u_temporal_offset;void main() {float progress=acos(dot(normalize(v_uv),u_center_direction))/u_radius;vec4 color=texture(u_color_ramp,vec2(progress,0.5));
2354#ifdef FOG
2355color.rgb=fog_apply_sky_gradient(v_uv.xzy,color.rgb/color.a)*color.a;
2356#endif
2357color*=u_opacity;glFragColor=color;
2358#ifdef OVERDRAW_INSPECTOR
2359glFragColor=vec4(1.0);
2360#endif
2361}`,Kd),skyboxCapture:Vt(`
2362in highp vec3 v_position;uniform highp float u_sun_intensity;uniform highp float u_luminance;uniform lowp vec3 u_sun_direction;uniform highp vec4 u_color_tint_r;uniform highp vec4 u_color_tint_m;precision highp float;
2363#define BETA_R                  vec3(5.5e-6,13.0e-6,22.4e-6)
2364#define BETA_M                  vec3(21e-6,21e-6,21e-6)
2365#define MIE_G                   0.76
2366#define DENSITY_HEIGHT_SCALE_R  8000.0
2367#define DENSITY_HEIGHT_SCALE_M  1200.0
2368#define PLANET_RADIUS           6360e3
2369#define ATMOSPHERE_RADIUS       6420e3
2370#define SAMPLE_STEPS            10
2371#define DENSITY_STEPS           4
2372float ray_sphere_exit(vec3 orig,vec3 dir,float radius) {float a=dot(dir,dir);float b=2.0*dot(dir,orig);float c=dot(orig,orig)-radius*radius;float d=sqrt(b*b-4.0*a*c);return (-b+d)/(2.0*a);}vec3 extinction(vec2 density) {return exp(-vec3(BETA_R*u_color_tint_r.a*density.x+BETA_M*u_color_tint_m.a*density.y));}vec2 local_density(vec3 point) {float height=max(length(point)-PLANET_RADIUS,0.0);float exp_r=exp(-height/DENSITY_HEIGHT_SCALE_R);float exp_m=exp(-height/DENSITY_HEIGHT_SCALE_M);return vec2(exp_r,exp_m);}float phase_ray(float cos_angle) {return (3.0/(16.0*PI))*(1.0+cos_angle*cos_angle);}
2372float phase_mie(float cos_angle) {return (3.0/(8.0*PI))*((1.0-MIE_G*MIE_G)*(1.0+cos_angle*cos_angle))/((2.0+MIE_G*MIE_G)*pow(1.0+MIE_G*MIE_G-2.0*MIE_G*cos_angle,1.5));}vec2 density_to_atmosphere(vec3 point,vec3 light_dir) {float ray_len=ray_sphere_exit(point,light_dir,ATMOSPHERE_RADIUS);float step_len=ray_len/float(DENSITY_STEPS);vec2 density_point_to_atmosphere=vec2(0.0);for (int i=0; i < DENSITY_STEPS;++i) {vec3 point_on_ray=point+light_dir*((float(i)+0.5)*step_len);density_point_to_atmosphere+=local_density(point_on_ray)*step_len;;}return density_point_to_atmosphere;}vec3 atmosphere(vec3 ray_dir,vec3 sun_direction,float sun_intensity) {vec2 density_orig_to_point=vec2(0.0);vec3 scatter_r=vec3(0.0);vec3 scatter_m=vec3(0.0);vec3 origin=vec3(0.0,PLANET_RADIUS,0.0);float ray_len=ray_sphere_exit(origin,ray_dir,ATMOSPHERE_RADIUS);float step_len=ray_len/float(SAMPLE_STEPS);for (int i=0; i < SAMPLE_STEPS;++i) {vec3 point_on_ray=origin+ray_dir*((float(i)+0.5)*step_len);vec2 density=local_density(point_on_ray)*step_len;density_orig_to_point+=density;vec2 density_point_to_atmosphere=density_to_atmosphere(point_on_ray,sun_direction);vec2 density_orig_to_atmosphere=density_orig_to_point+density_point_to_atmosphere;vec3 extinction=extinction(density_orig_to_atmosphere);scatter_r+=density.x*extinction;scatter_m+=density.y*extinction;}float cos_angle=dot(ray_dir,sun_direction);float phase_r=phase_ray(cos_angle);float phase_m=phase_mie(cos_angle);vec3 beta_r=BETA_R*u_color_tint_r.rgb*u_color_tint_r.a;vec3 beta_m=BETA_M*u_color_tint_m.rgb*u_color_tint_m.a;return (scatter_r*phase_r*beta_r+scatter_m*phase_m*beta_m)*sun_intensity;}const float A=0.15;const float B=0.50;const float C=0.10;const float D=0.20;const float E=0.02;const float F=0.30;vec3 uncharted2_tonemap(vec3 x) {return ((x*(A*x+C*B)+D*E)/(x*(A*x+B)+D*F))-E/F;}void main() {vec3 ray_direction=v_position;ray_direction.y=pow(ray_direction.y,5.0);const float y_bias=0.015;ray_direction.y+=y_bias;vec3 color=atmosphere(normalize(ray_direction),u_sun_direction,u_sun_intensity);float white_scale=1.0748724675633854;color=uncharted2_tonemap((log2(2.0/pow(u_luminance,4.0)))*color)*white_scale;glFragColor=vec4(color,1.0);}`,`in highp vec3 a_pos_3f;uniform mat3 u_matrix_3f;out highp vec3 v_position;float map(float value,float start,float end,float new_start,float new_end) {return ((value-start)*(new_end-new_start))/(e
2372nd-start)+new_start;}void main() {vec4 pos=vec4(u_matrix_3f*a_pos_3f,1.0);v_position=pos.xyz;
2373#ifndef VIEWPORT_ORIGIN_TOP_LEFT
2374v_position.y*=-1.0;
2375#endif
2376v_position.y=map(v_position.y,-1.0,1.0,0.0,1.0);gl_Position=vec4(a_pos_3f.xy,0.0,1.0);}`),globeRaster:Vt(`#include "_prelude_fog.fragment.glsl"
2377#include "_prelude_lighting.glsl"
2378uniform sampler2D u_image0;
2379#ifdef LIGHTING_3D_ALPHA_EMISSIVENESS
2380uniform sampler2D u_image1;uniform float u_emissive_texture_available;
2381#endif
2382uniform float u_far_z_cutoff;in vec2 v_pos0;
2383#ifndef FOG
2384uniform highp vec3 u_frustum_tl;uniform highp vec3 u_frustum_tr;uniform highp vec3 u_frustum_br;uniform highp vec3 u_frustum_bl;uniform highp vec3 u_globe_pos;uniform highp float u_globe_radius;uniform vec2 u_viewport;
2385#endif
2386void main() {vec4 color;
2387#ifdef CUSTOM_ANTIALIASING
2388highp vec2 uv=gl_FragCoord.xy/u_viewport;FLIP_VIEWPORT_UV_Y(uv);highp vec3 ray_dir=mix(
2389mix(u_frustum_tl,u_frustum_tr,uv.x),mix(u_frustum_bl,u_frustum_br,uv.x),1.0-uv.y);highp vec3 dir=normalize(ray_dir);highp vec3 closest_point=dot(u_globe_pos,dir)*dir;highp float norm_dist_from_center=1.0-length(closest_point-u_globe_pos)/u_globe_radius;const float antialias_pixel=2.0;highp float antialias_factor=antialias_pixel*fwidth(norm_dist_from_center);highp float antialias=smoothstep(0.0,antialias_factor,norm_dist_from_center);vec4 raster=texture(u_image0,v_pos0);
2390#ifdef LIGHTING_3D_MODE
2391#ifdef LIGHTING_3D_ALPHA_EMISSIVENESS
2392float emissive_strength=u_emissive_texture_available > 0.5 ? texture(u_image1,v_pos0).r : raster.a;raster=apply_lighting_with_emission_ground(raster,emissive_strength);color=vec4(clamp(raster.rgb,vec3(0),vec3(1))*antialias,antialias);
2393#else
2394raster=apply_lighting_ground(raster);color=vec4(raster.rgb*antialias,raster.a*antialias);
2395#endif
2396#else
2397color=vec4(raster.rgb*antialias,raster.a*antialias);
2398#endif
2399#else
2400color=texture(u_image0,v_pos0);
2401#ifdef LIGHTING_3D_MODE
2402#ifdef LIGHTING_3D_ALPHA_EMISSIVENESS
2403float emissive_strength=u_emissive_texture_available > 0.5 ? texture(u_image1,v_pos0).r : color.a;color=apply_lighting_with_emission_ground(color,emissive_strength);color.a=1.0;
2404#else
2405color=apply_lighting_ground(color);
2406#endif
2407#endif
2408#endif
2409#ifdef FOG
2410color=fog_dither(fog_apply_premultiplied(color,v_fog_pos));
2411#endif
2412color*=1.0-step(u_far_z_cutoff,1.0/gl_FragCoord.w);glFragColor=color;
2413#ifdef OVERDRAW_INSPECTOR
2414glFragColor=vec4(1.0);
2415#endif
2416HANDLE_WIREFRAME_DEBUG;}`,`#include "_prelude_fog.vertex.glsl"
2417#include "_prelude_terrain.vertex.glsl"
2418uniform mat4 u_proj_matrix;uniform mat4 u_normalize_matrix;uniform mat4 u_globe_matrix;
2419#ifndef GLOBE_POLES
2420uniform mat4 u_merc_matrix;
2421#endif
2422uniform float u_zoom_transition;uniform vec2 u_merc_center;
2423#ifndef GLOBE_POLES
2424uniform mat3 u_grid_matrix;
2425#endif
2426uniform float u_skirt_height;
2427#ifdef GLOBE_POLES
2428in vec3 a_globe_pos;in vec2 a_uv;
2429#else
2430in ivec2 a_pos;
2431#endif
2432out vec2 v_pos0;void main() {
2433#ifdef GLOBE_POLES
2434vec3 globe_pos=a_globe_pos;vec2 uv=a_uv;
2435#else
2436float tiles=u_grid_matrix[0][2];float idx=u_grid_matrix[1][2];float idy=u_grid_matrix[2][2];vec3 decomposed_pos_and_skirt=decomposeToPosAndSkirt(a_pos);vec3 latLng=u_grid_matrix*vec3(decomposed_pos_and_skirt.xy,1.0);float mercatorY=mercatorYfromLat(latLng[0]);float uvY=mercatorY*tiles-idy;float mercatorX=mercatorXfromLng(latLng[1]);float uvX=mercatorX*tiles-idx;vec3 globe_pos=latLngToECEF(latLng.xy);vec2 merc_pos=vec2(mercatorX,mercatorY);vec2 uv=vec2(uvX,uvY);
2437#endif
2438v_pos0=uv;
2439#ifdef VIEWPORT_ORIGIN_TOP_LEFT
2440v_pos0.y=1.0-v_pos0.y;
2441#endif
2442vec2 tile_pos=uv*EXTENT;vec3 globe_derived_up_vector=normalize(globe_pos)*u_tile_up_scale;
2443#ifdef GLOBE_POLES
2444vec3 up_vector=globe_derived_up_vector;
2445#else
2446vec3 up_vector=elevationVector(tile_pos);
2447#endif
2448float height=elevation(tile_pos);globe_pos+=up_vector*height;
2449#ifndef GLOBE_POLES
2450globe_pos-=globe_derived_up_vector*u_skirt_height*decomposed_pos_and_skirt.z;
2451#endif
2452#ifdef GLOBE_POLES
2453vec4 interpolated_pos=u_globe_matrix*vec4(globe_pos,1.0);
2454#else
2455vec4 globe_world_pos=u_globe_matrix*vec4(globe_pos,1.0);vec4 merc_world_pos=vec4(0.0);if (u_zoom_transition > 0.0) {merc_world_pos=vec4(merc_pos,height-u_skirt_height*decomposed_pos_and_skirt.z,1.0);merc_world_pos.xy-=u_merc_center;merc_world_pos.x=wrap(merc_world_pos.x,-0.5,0.5);merc_world_pos=u_merc_matrix*merc_world_pos;}vec4 interpolated_pos=vec4(mix(globe_world_pos.xyz,merc_world_pos.xyz,u_zoom_transition),1.0);
2456#endif
2457gl_Position=u_proj_matrix*interpolated_pos;
2458#ifdef FOG
2459v_fog_pos=fog_position((u_normalize_matrix*vec4(globe_pos,1.0)).xyz);
2460#endif
2461}`),globeAtmosphere:Vt(`#include "_prelude_fog.fragment.glsl"
2462uniform float u_transition;uniform highp float u_fadeout_range;uniform highp float u_temporal_offset;uniform vec4 u_atmosphere_fog_color;uniform vec4 u_high_color;uniform vec4 u_space_color;uniform float u_horizon_angle;in highp vec3 v_ray_dir;in highp vec3 v_horizon_dir;void main() {highp vec3 dir=normalize(v_ray_dir);float globe_pos_dot_dir;
2463#ifdef PROJECTION_GLOBE_VIEW
2464globe_pos_dot_dir=dot(u_globe_pos,dir);highp vec3 closest_point_forward=abs(globe_pos_dot_dir)*dir;float norm_dist_from_center=length(closest_point_forward-u_globe_pos)/u_globe_radius;if (norm_dist_from_center < 0.98) {
2465#ifdef ALPHA_PASS
2466glFragColor=vec4(0,0,0,0);return;
2467#else
2468#ifdef NATIVE
2469glFragColor=vec4(1,1,1,1);
2470#else
2471glFragColor=vec4(0,0,0,1);
2472#endif
2473return;
2474#endif
2475}
2476#endif
2477highp vec3 horizon_dir=normalize(v_horizon_dir);float horizon_angle_mercator=dir.y < horizon_dir.y ?
24780.0 : max(acos(clamp(dot(dir,horizon_dir),-1.0,1.0)),0.0);float horizon_angle;
2479#ifdef PROJECTION_GLOBE_VIEW
2480highp vec3 closest_point=globe_pos_dot_dir*dir;highp float closest_point_to_center=length(closest_point-u_globe_pos);highp float theta=asin(clamp(closest_point_to_center/length(u_globe_pos),-1.0,1.0));horizon_angle=globe_pos_dot_dir < 0.0 ?
2481PI-theta-u_horizon_angle : theta-u_horizon_angle;float angle_t=pow(u_transition,10.0);horizon_angle=mix(horizon_angle,horizon_angle_mercator,angle_t);
2482#else
2483horizon_angle=horizon_angle_mercator;
2484#endif
2485horizon_angle/=PI;float t=exp(-horizon_angle/u_fadeout_range);float alpha_0=u_atmosphere_fog_color.a;float alpha_1=u_high_color.a;float alpha_2=u_space_color.a;vec3 color_stop_0=u_atmosphere_fog_color.rgb;vec3 color_stop_1=u_high_color.rgb;
2485vec3 color_stop_2=u_space_color.rgb;
2486#ifdef ALPHA_PASS
2487float a0=mix(alpha_2,1.0,alpha_1);float a1=mix(a0,1.0,alpha_0);float a2=mix(a0,a1,t);float a =mix(alpha_2,a2,t);glFragColor=vec4(1.0,1.0,1.0,a);
2488#else
2489vec3 c0=mix(color_stop_2,color_stop_1,alpha_1);vec3 c1=mix(c0,color_stop_0,alpha_0);vec3 c2=mix(c0,c1,t);vec3 c=c2;glFragColor=vec4(c*t,t);
2490#endif
2491}`,`in vec3 a_pos;in vec2 a_uv;uniform vec3 u_frustum_tl;uniform vec3 u_frustum_tr;uniform vec3 u_frustum_br;uniform vec3 u_frustum_bl;uniform float u_horizon;out highp vec3 v_ray_dir;out highp vec3 v_horizon_dir;void main() {v_ray_dir=mix(
2492mix(u_frustum_tl,u_frustum_tr,a_uv.x),mix(u_frustum_bl,u_frustum_br,a_uv.x),a_uv.y);v_horizon_dir=mix(
2493mix(u_frustum_tl,u_frustum_bl,u_horizon),mix(u_frustum_tr,u_frustum_br,u_horizon),a_uv.x);gl_Position=vec4(a_pos,1.0);}`),stars:Vt(`in highp vec2 v_uv;in mediump float v_intensity;float shapeCircle(in vec2 uv)
2494{float beginFade=0.6;float lengthFromCenter=length(v_uv);return 1.0-clamp((lengthFromCenter-beginFade)/(1.0-beginFade),0.0,1.0);}void main() {float alpha=shapeCircle(v_uv);vec3 color=vec3(1.0,1.0,1.0);alpha*=v_intensity;glFragColor=vec4(color*alpha,alpha);HANDLE_WIREFRAME_DEBUG;}`,`
2495in vec3 a_pos_3f;in vec2 a_uv;in float a_size_scale;in float a_opacity;uniform mat4 u_matrix;uniform vec3 u_up;uniform vec3 u_right;uniform float u_intensity_multiplier;out highp vec2 v_uv;out mediump float v_intensity;void main() {v_uv=a_uv;v_intensity=a_opacity*u_intensity_multiplier;vec3 pos=a_pos_3f;pos+=a_uv.x*u_right*a_size_scale;pos+=a_uv.y*u_up*a_size_scale;gl_Position=u_matrix*vec4(pos,1.0);}`),occlusion:Vt("uniform vec4 u_color;void main() {glFragColor=u_color;}",`#include "_prelude_terrain.vertex.glsl"
2496in highp vec2 a_offset_xy;uniform highp vec3 u_anchorPos;uniform mat4 u_matrix;uniform vec2 u_screenSizePx;uniform vec2 u_occluderSizePx;void main() {vec3 world_pos=u_anchorPos;
2497#ifdef TERRAIN
2498float e=elevation(world_pos.xy);world_pos.z+=e;
2499#endif
2500vec4 projected_point=u_matrix*vec4(world_pos,1.0);projected_point.xy+=projected_point.w*a_offset_xy*0.5*u_occluderSizePx/u_screenSizePx;gl_Position=projected_point;}`)};function yl(s,t){const n=s.split(`
2501`);for(let l of n){if(l=l.trimStart(),l[0]!=="#"||!l.includes("if")||l.startsWith("#endif"))continue;const d=l.match(Wg);if(d)for(const p of d)bm.has(p)||t.add(p)}}function xl(s){return new Set(["uint","int","uvec2","ivec2","uvec3","ivec3","uvec4","ivec4"]).has(s)}function Vt(s,t){const n=new Set,l=[],d=[];s=s.replace(vm,(m,g)=>(d.push(g),"")),t=t.replace(vm,(m,g)=>(l.push(g),""));let p=new Set(cc);yl(s,p),yl(t,p);for(const m of[...l,...d])uc[m]||(uc[m]=new Set,yl(La[m],uc[m])),p=new Set([...p,...uc[m]]);return{fragmentSource:s=s.replace(eu,(m,g,x,w,S)=>(n.add(S),g==="define"?`
2502#ifndef HAS_UNIFORM_u_${S}
2503${xl(w)?"flat ":""}in ${x} ${w} ${S};
2504#else
2505uniform ${x} ${w} u_${S};
2506#endif
2507`:g==="initialize"?`
2508#ifdef HAS_UNIFORM_u_${S}
2509    ${x} ${w} ${S} = u_${S};
2510#endif
2511`:g==="define-attribute"?`
2512#ifdef HAS_ATTRIBUTE_a_${S}
2513    in ${x}
2513 ${w} ${S};
2514#endif
2515`:g==="initialize-attribute"?"":void 0)),vertexSource:t=t.replace(eu,(m,g,x,w,S)=>{const A=`MATERIAL_ATTRIBUTE_OFFSET_${S}`,I=w==="float"?"vec2":w,M=`GET_ATTRIBUTE_${I}(a_${S}, materialInfo, ${A})`,D=S.includes("color")?"color":I;return g==="define-attribute-vertex-shader-only"?`
2516#ifdef HAS_ATTRIBUTE_a_${S}
2517in ${x} ${w} a_${S};
2518#endif
2519`:n.has(S)?g==="define"?`
2520#ifndef HAS_UNIFORM_u_${S}
2521uniform lowp float u_${S}_t;
2522    #if !defined(${A})
2523        in ${x} ${I} a_${S};
2524    #endif
2525${xl(w)?"flat ":""}out ${x} ${w} ${S};
2526#else
2527uniform ${x} ${w} u_${S};
2528#endif
2529`:g==="initialize"?D==="vec4"||D==="uvec4"?`
2530#ifndef HAS_UNIFORM_u_${S}
2531    ${S} = a_${S};
2532#else
2533    ${x} ${w} ${S} = u_${S};
2534#endif
2535`:`
2536#if !defined(HAS_UNIFORM_u_${S})
2537    #ifdef ${A}
2538        ${S} = unpack_mix_${D}(${M}, u_${S}_t);
2539    #else
2540        ${S} = unpack_mix_${D}(a_${S}, u_${S}_t);
2541    #endif
2542#else
2543    ${x} ${w} ${S} = u_${S};
2544#endif
2545`:g==="define-attribute"?`
2546#ifdef HAS_ATTRIBUTE_a_${S}
2547    in ${x} ${w} a_${S};
2548    out ${x} ${w} ${S};
2549#endif
2550`:g==="initialize-attribute"?`
2551#ifdef HAS_ATTRIBUTE_a_${S}
2552    ${S} = a_${S};
2553#endif
2554`:void 0:g==="define"?`
2555#ifndef HAS_UNIFORM_u_${S}
2556uniform lowp float u_${S}_t;
2557    #if !defined(${A})
2558        in ${x} ${I} a_${S};
2559    #endif
2560#else
2561uniform ${x} ${w} u_${S};
2562#endif
2563`:g==="define-instanced"?D==="mat4"?`
2564#ifdef INSTANCED_ARRAYS
2565in vec4 a_${S}0;
2566in vec4 a_${S}1;
2567in vec4 a_${S}2;
2568in vec4 a_${S}3;
2569#else
2570uniform ${x} ${w} u_${S};
2571#endif
2572`:`
2573#ifdef INSTANCED_ARRAYS
2574in ${x} ${I} a_${S};
2575#else
2576uniform ${x} ${w} u_${S};
2577#endif
2578`:g==="initialize-attribute-custom"?`
2579#ifdef HAS_ATTRIBUTE_a_${S}
2580    ${x} ${w} ${S} = a_${S};
2581#endif
2582`:D==="vec4"||D==="uvec4"?`
2583#ifndef HAS_UNIFORM_u_${S}
2584    #ifdef ${A}
2585        ${x} ${w} ${S} = ${M};
2586    #else
2587        ${x} ${w} ${S} = a_${S};
2588    #endif
2589#else
2590    ${x} ${w} ${S} = u_${S};
2591#endif
2592`:`
2593#ifndef HAS_UNIFORM_u_${S}
2594    #ifdef ${A}
2595        ${x} ${w} ${S} = unpack_mix_${D}(${M}, u_${S}_t);
2596    #else
2597        ${x} ${w} ${S} = unpack_mix_${D}(a_${S}, u_${S}_t);
2598    #endif
2599#else
2600    ${x} ${w} ${S} = u_${S};
2601#endif
2602`}),usedDefines:p,vertexIncludes:l,fragmentIncludes:d}}var ch={model:Vt(`#include "_prelude_fog.fragment.glsl"
2603#include "_prelude_shadow.fragment.glsl"
2604#include "_prelude_lighting.glsl"
2605#include "_prelude_indicator_cutout.fragment.glsl"
2606#include "_prelude_feature_cutout.fragment.glsl"
2607uniform float u_opacity;
2608#ifdef DITHERED_DISCARD
2609uniform float u_dithered_discard_threshold;
2610#endif
2611#ifndef LIGHTING_3D_MODE
2612uniform vec3 u_lightcolor;uniform vec3 u_lightpos;uniform float u_lightintensity;
2613#endif
2614uniform vec4 u_baseColorFactor;uniform vec4 u_emissiveFactor;uniform float u_metallicFactor;uniform float u_roughnessFactor;uniform float u_emissive_strength;in highp vec4 v_position_height;in lowp vec4 v_color_mix;
2615#ifdef RENDER_SHADOWS
2616in highp vec4 v_pos_light_view_0;in highp vec4 v_pos_light_view_1;in float v_depth_shadows;
2617#endif
2618#ifdef OCCLUSION_TEXTURE_TRANSFORM
2619uniform vec4 u_occlusionTextureTransform;
2620#endif
2621#pragma mapbox: define-attribute highp vec3 normal_3f
2622#pragma mapbox: define-attribute highp vec3 color_3f
2623#pragma mapbox: define-attribute highp vec4 color_4f
2624#pragma mapbox: define-attribute highp vec2 uv_2f
2625#pragma mapbox: initialize-attribute highp vec3 normal_3f
2626#pragma mapbox: initialize-attribute highp vec3 color_3f
2627#pragma mapbox: initialize-attribute highp vec4 color_4f
2628#pragma mapbox: initialize-attribute highp vec2 uv_2f
2629#ifdef HAS_ATTRIBUTE_a_pbr
2630in lowp vec4 v_roughness_metallic_emissive_alpha;in mediump vec4 v_height_based_emission_params;
2631#endif
2632#ifdef HAS_TEXTURE_u_baseColorTexture
2633uniform sampler2D u_baseColorTexture;uniform bool u_baseTextureIsAlpha;uniform bool u_alphaMask;uniform float u_alphaCutoff;
2634#endif
2635#ifdef HAS_TEXTURE_u_metallicRoughnessTexture
2636uniform sampler2D u_metallicRoughnessTexture;
2637#endif
2638#ifdef HAS_TEXTURE_u_occlusionTexture
2639uniform sampler2D u_occlusionTexture;uniform float u_aoIntensity;
2640#endif
2641#ifdef HAS_TEXTURE_u_normalTexture
2642uniform sampler2D u_normalTexture;
2643#endif
2644#ifdef HAS_TEXTURE_u_emissionTexture
2645uniform sampler2D u_emissionTexture;
2646#endif
2647#ifdef APPLY_LUT_ON_GPU
2648uniform highp sampler3D u_lutTexture;
2649#endif
2650#ifdef FEATURE_CUTOUT_VERTEX
2651in highp float v_cutout_factor;
2652#endif
2653#ifdef TERRAIN_FRAGMENT_OCCLUSION
2654in highp float v_depth;uniform highp sampler2D u_depthTexture;
2654uniform highp vec2 u_inv_depth_size;uniform highp vec2 u_depth_range_unpack;
2655#ifdef DEPTH_D24
2656highp float unpack_depth(highp float depth) {return  depth*u_depth_range_unpack.x+u_depth_range_unpack.y;}
2657#else
2658highp float unpack_depth_rgba(highp vec4 rgba_depth)
2659{const highp vec4 bit_shift=vec4(1.0/(255.0*255.0*255.0),1.0/(255.0*255.0),1.0/255.0,1.0);return dot(rgba_depth,bit_shift)*2.0-1.0;}
2660#endif
2661bool isOccluded() {highp vec2 coord=gl_FragCoord.xy*u_inv_depth_size;
2662#ifdef FLIP_Y
2663coord.y=1.0-coord.y;
2664#endif
2665#ifdef DEPTH_D24
2666highp float depth=unpack_depth(texture(u_depthTexture,coord).r);
2667#else
2668highp float depth=unpack_depth_rgba(texture(u_depthTexture,coord));
2669#endif
2670return v_depth > depth+0.0005;}
2671#endif
2672#define saturate(_x) clamp(_x,0.,1.)
2673vec3 linearTosRGB(vec3 color) {return pow(color,vec3(1./2.2));}vec3 sRGBToLinear(vec3 srgbIn) {return pow(srgbIn,vec3(2.2));}float calculate_NdotL(vec3 normal,vec3 lightDir) {const float ext=0.70710678118;return (clamp(dot(normal,lightDir),-ext,1.0)+ext)/(1.0+ext);}vec3 getDiffuseShadedColor(vec3 albedo,vec3 normal,vec3 lightDir,vec3 lightColor)
2674{
2675#ifdef LIGHTING_3D_MODE
2676vec3 transformed_normal=vec3(-normal.xy,normal.z);float lighting_factor;
2677#ifdef RENDER_SHADOWS
2678lighting_factor=shadowed_light_factor_normal(transformed_normal,v_pos_light_view_0,v_pos_light_view_1,v_depth_shadows);
2679#else
2680lighting_factor=saturate(dot(transformed_normal,u_lighting_directional_dir));
2681#endif
2682return apply_lighting(albedo,transformed_normal,lighting_factor);
2683#else
2684vec3 n=normal;float colorvalue=((albedo.x*0.2126)+(albedo.y*0.7152))+(albedo.z*0.0722);vec3 c=vec3(0.03,0.03,0.03);float directional=clamp(dot(n,vec3(lightDir)),0.0,1.0);directional=mix(1.0-u_lightintensity,max((1.0-colorvalue)+u_lightintensity,1.0),directional);vec3 c3=c+clamp((albedo*directional)*lightColor,mix(vec3(0.0),vec3(0.3),vec3(1.0)-lightColor),vec3(1.0));return c3;
2685#endif
2686}vec4 getBaseColor() {vec4 albedo=u_baseColorFactor;
2687#ifdef HAS_ATTRIBUTE_a_color_3f
2688albedo*=vec4(color_3f,1.0);
2689#endif
2690#ifdef HAS_ATTRIBUTE_a_pbr
2691#else
2692#ifdef HAS_ATTRIBUTE_a_color_4f
2693albedo*=color_4f;
2694#endif
2695#endif
2696#if defined (HAS_TEXTURE_u_baseColorTexture) && defined (HAS_ATTRIBUTE_a_uv_2f)
2697vec4 texColor=texture(u_baseColorTexture,uv_2f);if(u_alphaMask) {if (texColor.w < u_alphaCutoff) {discard;}}
2698#ifdef UNPREMULT_TEXTURE_IN_SHADER
2699texColor=vec4(unpremultiplyColor(texColor),1.0);
2700#endif
2701if(u_baseTextureIsAlpha) {if (texColor.r < 0.5) {discard;}} else {texColor.rgb=sRGBToLinear(texColor.rgb);albedo*=texColor;}
2702#endif
2703vec4 color=vec4(mix(albedo.rgb,v_color_mix.rgb,v_color_mix.a),albedo.a);
2704#ifdef APPLY_LUT_ON_GPU
2705color=applyLUT(u_lutTexture,color);
2706#endif
2707return color;}highp mat3 cotangentFrame(highp vec3 N,highp vec3 p,highp vec2 uv ) {
2708#ifdef HAS_TEXTURE_u_normalTexture
2709highp vec3 dp1=vec3(dFdx(p.x),dFdx(p.y),dFdx(p.z));highp vec3 dp2=vec3(dFdy(p.x),dFdy(p.y),dFdy(p.z));highp vec2 duv1=vec2(dFdx(uv.x),dFdx(uv.y));highp vec2 duv2=vec2(dFdy(uv.x),dFdy(uv.y));highp vec3 dp2perp=cross( dp2,N );highp vec3 dp1perp=cross( N,dp1 );highp vec3 T=dp2perp*duv1.x+dp1perp*duv2.x;highp vec3 B=dp2perp*duv1.y+dp1perp*duv2.y;
2710#ifdef FLIP_Y
2711T=-T;B=-B;
2712#endif
2713highp float lengthT=dot(T,T);highp float lengthB=dot(B,B);highp float maxLength=max(lengthT,lengthB);highp float invmax=inversesqrt( maxLength );highp mat3 res=mat3( T*invmax,B*invmax,N );return res;
2714#else
2715return mat3(1.0);
2716#endif
2717}highp vec3 getNormal(){highp vec3 n;
2718#ifdef HAS_ATTRIBUTE_a_normal_3f
2719n=normalize(normal_3f);
2720#else
2721highp vec3 fdx=vec3(dFdx(v_position_height.x),dFdx(v_position_height.y),dFdx(v_position_height.z));highp vec3 fdy=vec3(dFdy(v_position_height.x),dFdy(v_position_height.y),dFdy(v_position_height.z));
2722#ifdef FLIP_Y
2723n=normalize(cross(fdx,fdy));
2724#else
2725n=normalize(cross(fdx,fdy))*-1.0;
2726#endif
2727#endif
2728#if defined(HAS_TEXTURE_u_normalTexture) && defined(HAS_ATTRIBUTE_a_uv_2f)
2729vec3 nMap=texture( u_normalTexture,uv_2f).xyz;nMap=normalize(2.0*nMap-vec3(1.0));highp vec3 v=normalize(-v_position_height.xyz);highp mat3 TBN=cotangentFrame(n,v,uv_2f);n=normalize(TBN*nMap);
2730#endif
2731return n;}struct Material {float perceptualRoughness;float alphaRoughness;float metallic;vec3 f90;vec4 baseColor;vec3 diffuseColor;vec3 specularColor;highp vec3 normal;};Material getPBRMaterial() {Material mat;mat.baseColor=getBaseColor();mat.perceptualRoughness=u_roughnessFactor;mat.metallic=u_metallicFactor;
2732#ifdef HAS_ATTRIBUTE_a_pbr
vendor: 4,221 bytes, lines 2732-2767
2732
2733mat.perceptualRoughness=v_roughness_metallic_emissive_alpha.x;mat.metallic=v_roughness_metallic_emissive_alpha.y;mat.baseColor.w*=v_roughness_metallic_emissive_alpha.w;
2734#endif
2735#if defined(HAS_TEXTURE_u_metallicRoughnessTexture) && defined(HAS_ATTRIBUTE_a_uv_2f)
2736vec4 mrSample=texture(u_metallicRoughnessTexture,uv_2f);mat.perceptualRoughness*=mrSample.g;mat.metallic*=mrSample.b;
2737#endif
2738const float c_minRoughness=0.04;mat.perceptualRoughness=clamp(mat.perceptualRoughness,c_minRoughness,1.0);mat.metallic=saturate(mat.metallic);mat.alphaRoughness=mat.perceptualRoughness*mat.perceptualRoughness;const vec3 f0=vec3(0.04);mat.diffuseColor=mat.baseColor.rgb*(vec3(1.0)-f0);mat.diffuseColor*=1.0-mat.metallic;mat.specularColor=mix(f0,mat.baseColor.rgb,mat.metallic);highp float reflectance=max(max(mat.specularColor.r,mat.specularColor.g),mat.specularColor.b);highp float reflectance90=saturate(reflectance*25.0);mat.f90=vec3(reflectance90);mat.normal=getNormal();return mat;}float V_GGX(float NdotL,float NdotV,float roughness)
2739{float a2=roughness*roughness;float GGXV=NdotL*sqrt(NdotV*NdotV*(1.0-a2)+a2);float GGXL=NdotV*sqrt(NdotL*NdotL*(1.0-a2)+a2);return 0.5/(GGXV+GGXL);}float V_GGXFast(float NdotL,float NdotV,float roughness) {float a=roughness;float GGXV=NdotL*(NdotV*(1.0-a)+a);float GGXL=NdotV*(NdotL*(1.0-a)+a);return 0.5/(GGXV+GGXL);}vec3 F_Schlick(vec3 specularColor,vec3 f90,float VdotH)
2740{return specularColor+(f90-specularColor)*pow(clamp(1.0-VdotH,0.0,1.0),5.0);}vec3 F_SchlickFast(vec3 specularColor,float VdotH)
2741{float x=1.0-VdotH;float x4=x*x*x*x;return specularColor+(1.0-specularColor)*x4*x;}float D_GGX(highp float NdotH,float alphaRoughness)
2742{highp float a4=alphaRoughness*alphaRoughness;highp float f=(NdotH*a4-NdotH)*NdotH+1.0;return a4/(PI*f*f);}vec3 diffuseBurley(Material mat,float LdotH,float NdotL,float NdotV)
2743{float f90=2.0*LdotH*LdotH*mat.alphaRoughness-0.5;return (mat.diffuseColor/PI)*(1.0+f90*pow((1.0-NdotL),5.0))*(1.0+f90*pow((1.0-NdotV),5.0));}vec3 diffuseLambertian(Material mat)
2744{
2745#ifdef LIGHTING_3D_MODE
2746return mat.diffuseColor;
2747#else
2748return mat.diffuseColor/PI;
2749#endif
2750}vec3 EnvBRDFApprox(vec3 specularColor,float roughness,highp float NdotV)
2751{vec4 c0=vec4(-1,-0.0275,-0.572,0.022);vec4 c1=vec4(1,0.0425,1.04,-0.04);highp vec4 r=roughness*c0+c1;highp float a004=min(r.x*r.x,exp2(-9.28*NdotV))*r.x+r.y;vec2 AB=vec2(-1.04,1.04)*a004+r.zw;return specularColor*AB.x+AB.y;}vec3 computeIndirectLightContribution(Material mat,float NdotV,vec3 normal)
2752{vec3 env_light=vec3(0.65,0.65,0.65);
2753#ifdef LIGHTING_3D_MODE
2754float ambient_factor=calculate_ambient_directional_factor(normal);env_light=u_lighting_ambient_color*ambient_factor;
2755#endif
2756vec3 envBRDF=EnvBRDFApprox(mat.specularColor,mat.perceptualRoughness,NdotV);vec3 indirectSpecular= envBRDF*env_light;vec3 indirectDiffuse=mat.diffuseColor*env_light;return indirectSpecular+indirectDiffuse;}vec3 computeLightContribution(Material mat,vec3 lightPosition,vec3 lightColor)
2757{highp vec3 n=mat.normal;highp vec3 v=normalize(-v_position_height.xyz);highp vec3 l=normalize(lightPosition);highp vec3 h=normalize(v+l);float NdotV=clamp(abs(dot(n,v)),0.001,1.0);float NdotL=saturate(dot(n,l));highp float NdotH=saturate(dot(n,h));float VdotH=saturate(dot(v,h));vec3 f=F_SchlickFast(mat.specularColor,VdotH);float g=V_GGXFast(NdotL,NdotV,mat.alphaRoughness);float d=D_GGX(NdotH,mat.alphaRoughness);vec3 diffuseTerm=(1.0-f)*diffuseLambertian(mat);vec3 specularTerm=f*g*d;vec3 transformed_normal=vec3(-n.xy,n.z);float lighting_factor;
2758#ifdef RENDER_SHADOWS
2759lighting_factor=shadowed_light_factor_normal(transformed_normal,v_pos_light_view_0,v_pos_light_view_1,v_depth_shadows);
2760#else
2761lighting_factor=NdotL;
2762#endif
2763vec3 directLightColor=(specularTerm+diffuseTerm)*lighting_factor*lightColor;vec3 indirectLightColor=computeIndirectLightContribution(mat,NdotV,transformed_normal);vec3 color=(saturate(directLightColor)+indirectLightColor);float intensityFactor=1.0;
2764#if !defined(LIGHTING_3D_MODE)
2765const vec3 luminosityFactor=vec3(0.2126,0.7152,0.0722);float luminance=dot(diffuseTerm,luminosityFactor);intensityFactor=mix((1.0-u_lightintensity),max((1.0-luminance+u_lightintensity),1.0),NdotL);
2766#endif
2767color*=intensityFactor;return color;}void main() {
2767
2768#ifdef TERRAIN_FRAGMENT_OCCLUSION
2769if (isOccluded()) {discard;}
2770#endif
2771vec3 lightDir;vec3 lightColor;
2772#ifdef LIGHTING_3D_MODE
2773lightDir=u_lighting_directional_dir;lightDir.xy=-lightDir.xy;lightColor=u_lighting_directional_color;
2774#else
2775lightDir=u_lightpos;lightColor=u_lightcolor;
2776#endif
2777vec4 finalColor;
2778#ifdef DIFFUSE_SHADED
2779vec3 N=getNormal();vec3 baseColor=getBaseColor().rgb;vec3 diffuse=getDiffuseShadedColor(baseColor,N,lightDir,lightColor);
2780#ifdef HAS_TEXTURE_u_occlusionTexture
2781float ao=(texture(u_occlusionTexture,uv_2f).r-1.0)*u_aoIntensity+1.0;diffuse*=ao;
2782#endif
2783finalColor=vec4(mix(diffuse,baseColor,u_emissive_strength),1.0)*u_opacity;
2784#else
2785Material mat=getPBRMaterial();vec3 color=computeLightContribution(mat,lightDir,lightColor);float ao=1.0;
2786#if defined (HAS_TEXTURE_u_occlusionTexture) && defined(HAS_ATTRIBUTE_a_uv_2f)
2787#ifdef OCCLUSION_TEXTURE_TRANSFORM
2788vec2 uv=uv_2f.xy*u_occlusionTextureTransform.zw+u_occlusionTextureTransform.xy;
2789#else
2790vec2 uv=uv_2f;
2791#endif
2792ao=(texture(u_occlusionTexture,uv).x-1.0)*u_aoIntensity+1.0;color*=ao;
2793#endif
2794vec4 emissive=u_emissiveFactor;
2795#if defined(HAS_TEXTURE_u_emissionTexture) && defined(HAS_ATTRIBUTE_a_uv_2f)
2796emissive.rgb*=sRGBToLinear(texture(u_emissionTexture,uv_2f).rgb);
2797#endif
2798#ifdef APPLY_LUT_ON_GPU
2799float emissiveFactorLength=max(length(u_emissiveFactor.rgb),0.001);emissive.rgb=sRGBToLinear(applyLUT(u_lutTexture,linearTosRGB(emissive.rgb/emissiveFactorLength).rbg))*emissiveFactorLength;
2800#endif
2801color+=emissive.rgb;float opacity=mat.baseColor.w*u_opacity;
2802#ifdef HAS_ATTRIBUTE_a_pbr
2803float resEmission=v_roughness_metallic_emissive_alpha.z;resEmission*=v_height_based_emission_params.z+v_height_based_emission_params.w*pow(clamp(v_height_based_emission_params.x,0.0,1.0),v_height_based_emission_params.y);vec3 color_mix=v_color_mix.rgb;
2804#ifdef APPLY_LUT_ON_GPU
2805color_mix=applyLUT(u_lutTexture,color_mix);
2806#endif
2807color=mix(color,color_mix,min(1.0,resEmission));
2808#ifdef HAS_ATTRIBUTE_a_color_4f
2809float distance=length(vec2(1.3*max(0.0,abs(color_4f.x)-color_4f.z),color_4f.
2809y));distance+= mix(0.5,0.0,clamp(resEmission-1.0,0.0,1.0));opacity*=v_roughness_metallic_emissive_alpha.w*saturate(1.0-distance*distance);
2810#endif
2811#endif
2812vec3 unlitColor=mat.baseColor.rgb*ao+emissive.rgb;color=mix(color,unlitColor,u_emissive_strength);color=linearTosRGB(color);color*=opacity;finalColor=vec4(color,opacity);
2813#endif
2814#ifdef DITHERED_DISCARD
2815if (abs(u_dithered_discard_threshold) < 1.0) {float ditherValue=fract(52.9829189*fract(0.06711056*gl_FragCoord.x+0.00583715*gl_FragCoord.y));float compareValue=mix(1.0-ditherValue,ditherValue,step(0.0,u_dithered_discard_threshold));if (abs(u_dithered_discard_threshold) < compareValue) {discard;}}
2816#endif
2817#ifdef FOG
2818finalColor=fog_dither(fog_apply_premultiplied(finalColor,v_fog_pos,v_position_height.w));
2819#endif
2820#ifdef RENDER_CUTOFF
2821finalColor*=v_cutoff_opacity;
2822#endif
2823#ifdef INDICATOR_CUTOUT
2824finalColor=applyCutout(finalColor,v_position_height.w);
2825#endif
2826#ifdef FEATURE_CUTOUT_VERTEX
2827apply_feature_cutout_dither(gl_FragCoord,v_cutout_factor);
2828#else
2829#ifdef FEATURE_CUTOUT
2830finalColor=apply_feature_cutout(finalColor,gl_FragCoord,get_cutout_factors(gl_FragCoord).x,0.0);
2831#endif
2832#endif
2833glFragColor=finalColor;
2834#ifdef OVERDRAW_INSPECTOR
2835glFragColor=vec4(1.0);
2836#endif
2837HANDLE_WIREFRAME_DEBUG;}`,`#include "_prelude_fog.vertex.glsl"
2838#include "_prelude_shadow.vertex.glsl"
2839#include "_prelude_feature_cutout.vertex.glsl"
2840in vec3 a_pos_3f;
2841#pragma mapbox: define-attribute highp vec3 normal_3f
2842#pragma mapbox: define-attribute highp vec2 uv_2f
2843#pragma mapbox: define-attribute highp vec3 color_3f
2844#pragma mapbox: define-attribute highp vec4 color_4f
2845#pragma mapbox: define-attribute-vertex-shader-only highp uvec4 pbr
2846#pragma mapbox: define-attribute-vertex-shader-only highp vec3 heightBasedEmissiveStrength
2847uniform mat4 u_matrix;uniform mat4 u_node_matrix;uniform mat4 u_lighting_matrix;uniform vec3 u_camera_pos;uniform vec4 u_color_mix;
2848#ifdef INSTANCED_ARRAYS
2849in vec4 a_normal_matrix0;in vec4 a_normal_matrix1;in vec4 a_normal_matrix2;in vec4 a_normal_matrix3;
2850#else
2851uniform highp mat4 u_normal_matrix;
2852#endif
2853#ifdef RENDER_SHADOWS
2854uniform mat4 u_light_matrix_0;uniform mat4 u_light_matrix_1;out highp vec4 v_pos_light_view_0;out highp vec4 v_pos_light_view_1;out float v_depth_shadows;
2855#endif
2856out vec4 v_position_height;out lowp vec4 v_color_mix;
2857#ifdef TERRAIN_FRAGMENT_OCCLUSION
2858out highp float v_depth;
2859#endif
2860#ifdef FEATURE_CUTOUT_VERTEX
2861out highp float v_cutout_factor;
2862#endif
2863#ifdef HAS_ATTRIBUTE_a_pbr
2864out lowp vec4 v_roughness_metallic_emissive_alpha;out mediump vec4 v_height_based_emission_params;
2865#endif
2866vec3 sRGBToLinear(vec3 srgbIn) {return pow(srgbIn,vec3(2.2));}void main() {
2867#pragma mapbox: initialize-attribute highp vec3 normal_3f
2868#pragma mapbox: initialize-attribute highp vec2 uv_2f
2869#pragma mapbox: initialize-attribute highp vec3 color_3f
2870#pragma mapbox: initialize-attribute highp vec4 color_4f
2871#pragma mapbox: initialize-attribute-custom highp uvec4 pbr
2872#pragma mapbox: initialize-attribute-custom highp vec3 heightBasedEmissiveStrength
2873highp mat4 normal_matrix;
2874#ifdef INSTANCED_ARRAYS
2875normal_matrix=mat4(a_normal_matrix0,a_normal_matrix1,a_normal_matrix2,a_normal_matrix3);
2876#else
2877normal_matrix=u_normal_matrix;
2878#endif
2879#ifdef FEATURE_CUTOUT_VERTEX
2880v_cutout_factor=1.0;
2881#endif
2882vec3 local_pos;mat3 rs;
2883#ifdef MODEL_POSITION_ON_GPU
2884vec3 pos_color=normal_matrix[0].xyz;vec4 translate=normal_matrix[1];vec3 pos_a=floor(pos_color);vec3 rgb=1.05*(pos_color-pos_a);float hidden=float(pos_a.x > EXTENT);float color_mix=pos_a.z/100.0;v_color_mix=vec4(sRGBToLinear(rgb),color_mix);float meter_to_tile=normal_matrix[0].w;vec4 pos=vec4(pos_a.xy,translate.z,1.0);rs[0].x=normal_matrix[1].w;rs[0].yz=normal_matrix[2].xy;rs[1].xy=normal_matrix[2].zw;rs[1].z=normal_matrix[3].x;rs[2].xyz=normal_matrix[3].yzw;vec4 pos_node=u_lighting_matrix*vec4(a_pos_3f,1.0);vec3 rotated_pos_node=rs*pos_node.xyz;vec3 pos_model_tile=(rotated_pos_node+vec3(translate.xy,0.0))*vec3(meter_to_tile,meter_to_tile,1.0);pos.xyz+=pos_model_tile;local_pos=pos.xyz;gl_Position=mix(u_matrix*pos,AWAY,hidden);pos.z*=meter_to_tile;v_position_height.xyz=pos.xyz-u_camera_pos;
2885#ifdef FEATURE_CUTOUT_VERTEX
2886highp vec4 ground_pos=vec4(pos_a.xy,0.0,1.0);highp vec4 cutout_clip_pos=mix(u_matrix*ground_pos,AWAY,hidden);highp vec3 cutout_ndc=cutout_clip_pos.xyz/cutout_clip_pos.w;vec2 uv=cutout_ndc.xy*0.5+0.5;highp float fragDepthNDC=cutout_ndc.z*0.5+0.5;
2887#ifdef FLIP_Y
2888fragDepthNDC=cutout_ndc.z;
2889#endif
2890highp float cutoutFactor=get_cutout_factors_vert(uv).x;highp float cutoutDepthNDC=sample_cutout_depth(u_cutout_depth_image,uv);highp float groundThreshold=0.001;
2890highp float groundLimit=clamp((fragDepthNDC+groundThreshold-cutoutDepthNDC)/groundThreshold+0.5,0.0,1.0);v_cutout_factor=mix(1.0-cutoutFactor,1.0,groundLimit);
2891#endif
2892#else
2893local_pos=a_pos_3f;gl_Position=u_matrix*vec4(a_pos_3f,1);v_position_height.xyz=vec3(u_lighting_matrix*vec4(a_pos_3f,1));v_color_mix=vec4(sRGBToLinear(u_color_mix.rgb),u_color_mix.a);
2894#endif
2895v_position_height.w=a_pos_3f.z;
2896#ifdef HAS_ATTRIBUTE_a_pbr
2897vec4 albedo_c=decode_color(vec2(pbr.xy));vec2 e_r_m=unpack_float(float(pbr.z));vec2 r_m= unpack_float(e_r_m.y*16.0);r_m.r=r_m.r*16.0;v_color_mix=vec4(albedo_c.rgb,1.0);v_roughness_metallic_emissive_alpha=vec4(vec3(r_m,e_r_m.x)/255.0,albedo_c.a);v_roughness_metallic_emissive_alpha.z*=2.0;float heightBasedRelativeIntepolation=a_pos_3f.z*heightBasedEmissiveStrength.x+heightBasedEmissiveStrength.y;v_height_based_emission_params.x=heightBasedRelativeIntepolation;v_height_based_emission_params.y=heightBasedEmissiveStrength.z;vec2 emissionMultiplierValues=unpack_float(float(pbr.w))/256.0;v_height_based_emission_params.z=emissionMultiplierValues.x;v_height_based_emission_params.w=emissionMultiplierValues.y-emissionMultiplierValues.x;
2898#endif
2899#ifdef FOG
2900v_fog_pos=fog_position(local_pos);
2901#endif
2902#ifdef RENDER_CUTOFF
2903v_cutoff_opacity=cutoff_opacity(u_cutoff_params,gl_Position.z);
2904#endif
2905#ifdef TERRAIN_FRAGMENT_OCCLUSION
2906v_depth=gl_Position.z/gl_Position.w;
2907#ifdef CLIP_ZERO_TO_ONE
2908v_depth=-1.0+2.0*v_depth; 
2909#endif
2910#endif
2911#ifdef HAS_ATTRIBUTE_a_normal_3f
2912#ifdef MODEL_POSITION_ON_GPU
2913float x_squared_scale=dot(rs[0],rs[0]);float y_squared_scale=dot(rs[1],rs[1]);float z_squared_scale=dot(rs[2],rs[2]);vec3 squared_scale=vec3(x_squared_scale,y_squared_scale,z_squared_scale);normal_3f=rs*((u_lighting_matrix*vec4(normal_3f,0.0)).xyz/squared_scale);normal_3f=normalize(normal_3f);
2914#else
2915normal_3f=vec3(normal_matrix*vec4(normal_3f,0));
2916#endif
2917#endif
2918#ifdef HAS_ATTRIBUTE_a_pbr
2919#ifdef HAS_ATTRIBUTE_a_color_4f
2920v_roughness_metallic_emissive_alpha.w=clamp(color_4f.a*v_roughness_metallic_emissive_alpha.w*(v_roughness_metallic_emissive_alpha.z-1.0),0.0,1.0);
2921#endif
2922#endif
2923#ifdef RENDER_SHADOWS
2924vec4 shadow_pos=u_node_matrix*vec4(local_pos,1.0);
2925#ifdef NORMAL_OFFSET
2926#ifdef HAS_ATTRIBUTE_a_normal_3f
2927#ifdef MODEL_POSITION_ON_GPU
2928vec3 offset=shadow_normal_offset(vec3(-normal_3f.xy,normal_3f.z));shadow_pos.xyz+=offset*shadow_normal_offset_multiplier0();
2929#else
2930vec3 offset=shadow_normal_offset_model(normal_3f);shadow_pos.xyz+=offset*shadow_normal_offset_multiplier0();
2931#endif
2932#endif
2933#endif
2934v_pos_light_view_0=u_light_matrix_0*shadow_pos;v_pos_light_view_1=u_light_matrix_1*shadow_pos;v_depth_shadows=gl_Position.w;
2935#endif
2936}`),modelDepth:Vt("void main() {}",`in vec3 a_pos_3f;uniform mat4 u_matrix;
2937#ifdef MODEL_POSITION_ON_GPU
2938#ifdef INSTANCED_ARRAYS
2939in vec4 a_normal_matrix0;in vec4 a_normal_matrix1;in vec4 a_normal_matrix2;in vec4 a_normal_matrix3;
2940#else
2941uniform highp mat4 u_instance;
2942#endif
2943uniform highp mat4 u_node_matrix;
2944#endif
2945void main() {
2946#ifdef MODEL_POSITION_ON_GPU
2947highp mat4 instance;
2948#ifdef INSTANCED_ARRAYS
2949instance=mat4(a_normal_matrix0,a_normal_matrix1,a_normal_matrix2,a_normal_matrix3);
2950#else
2951instance=u_instance;
2952#endif
2953vec3 pos_color=instance[0].xyz;vec4 translate=instance[1];vec3 pos_a=floor(pos_color);float hidden=float(pos_a.x > EXTENT);float meter_to_tile=instance[0].w;vec4 pos=vec4(pos_a.xy,translate.z,1.0);mat3 rs;rs[0].x=instance[1].w;rs[0].yz=instance[2].xy;
2953rs[1].xy=instance[2].zw;rs[1].z=instance[3].x;rs[2].xyz=instance[3].yzw;vec4 pos_node=u_node_matrix*vec4(a_pos_3f,1.0);vec3 rotated_pos_node=rs*pos_node.xyz;vec3 pos_model_tile=(rotated_pos_node+vec3(translate.xy,0.0))*vec3(meter_to_tile,meter_to_tile,1.0);pos.xyz+=pos_model_tile;gl_Position=mix(u_matrix*pos,AWAY,hidden);
2954#else
2955gl_Position=u_matrix*vec4(a_pos_3f,1);
2956#endif
2957}`),fillExtrusionDepth:Vt("void main() {}",`#include "_prelude_terrain.vertex.glsl"
2958#include "_prelude_material_table.vertex.glsl"
2959uniform mat4 u_matrix;uniform float u_edge_radius;uniform float u_width_scale;uniform float u_vertical_scale;
2960#ifdef TERRAIN
2961uniform int u_height_type;uniform int u_base_type;
2962#endif
2963in ivec4 a_pos_normal_ed;
2964#if defined(HAS_CENTROID) || defined(TERRAIN)
2965in uvec2 a_centroid_pos;
2966#endif
2967#ifdef RENDER_WALL_MODE
2968in ivec4 a_join_normal_inside;
2969#endif
2970#pragma mapbox: define highp float base
2971#pragma mapbox: define highp float height
2972#pragma mapbox: define highp float line_width
2973#pragma mapbox: define highp vec4 color
2974void main() {DECLARE_MATERIAL_TABLE_INFO
2975#pragma mapbox: initialize highp float base
2976#pragma mapbox: initialize highp float height
2977#pragma mapbox: initialize highp float line_width
2978#pragma mapbox: initialize highp vec4 color
2979base*=u_vertical_scale;height*=u_vertical_scale;vec3 top_up_ny=vec3(a_pos_normal_ed.xyz & 1);vec3 pos_nx=vec3(a_pos_normal_ed.xyz >> 1);base=max(0.0,base);height=max(0.0,top_up_ny.y==0.0 && top_up_ny.x==1.0 ? height-u_edge_radius : height);float t=top_up_ny.x;vec2 centroid_pos=vec2(0.0);
2980#if defined(HAS_CENTROID) || defined(TERRAIN)
2981centroid_pos=vec2(a_centroid_pos);
2982#endif
2983vec3 pos;
2984#ifdef TERRAIN
2985bool is_flat_height=centroid_pos.x !=0.0 && u_height_type==1;bool is_flat_base=centroid_pos.x !=0.0 && u_base_type==1;float ele=elevation(pos_nx.xy);bool is_elevation_encoded=centroid_pos.y==0.0 || (centroid_pos.y > 0.0 && int(centroid_pos.y)-(int(centroid_pos.y)/8)*8==7);float c_ele=is_flat_height || is_flat_base ? (is_elevation_encoded ? elevationFromUint16(centroid_pos.x) : flatElevation(centroid_pos)) : ele;float h_height=is_flat_height ? max(c_ele+height,ele+base+2.0) : ele+height;float h_base=is_flat_base ? max(c_ele+base,ele+base) : ele+(base==0.0 ?-5.0 : base);float h=t > 0.0 ? max(h_base,h_height) : h_base;pos=vec3(pos_nx.xy,h);
2986#else
2987pos=vec3(pos_nx.xy,t > 0.0 ? height : base);
2988#endif
2989#ifdef RENDER_WALL_MODE
2990vec3 join_normal_inside=vec3(a_join_normal_inside);vec2 wall_offset=u_width_scale*line_width*(join_normal_inside.xy/EXTENT);pos.xy+=(1.0-join_normal_inside.z)*wall_offset*0.5;pos.xy-=join_normal_inside.z*wall_offset*0.5;
2991#endif
2992float hidden=float((centroid_pos.x==0.0 && centroid_pos.y==1.0) || (color.a==0.0));gl_Position=mix(u_matrix*vec4(pos,1),AWAY,hidden);}`),fillExtrusionGroundEffect:Vt(`uniform highp float u_ao_pass;uniform highp float u_opacity;uniform highp float u_flood_light_intensity;uniform highp vec3 u_flood_light_color;uniform highp float u_attenuation;uniform sampler2D u_fb;uniform float u_fb_size;
2993#ifdef SDF_SUBPASS
2994in highp vec2 v_pos;in highp vec4 v_line_segment;in highp float v_flood_light_radius_tile;in highp vec2 v_ao;float line_df(highp vec2 a,highp vec2 b,highp vec2 p) {highp vec2 ba=b-a;highp vec2 pa=p-a;highp float r=clamp(dot(pa,ba)/dot(ba,ba),0.0,1.0);return length(pa-r*ba);}
2995#ifdef FOG
2996in highp float v_fog;
2997#endif
2998#endif
2999void main() {
3000#ifdef CLEAR_SUBPASS
3001vec4 color=vec4(1.0);
3002#ifdef CLEAR_FROM_TEXTURE
3003color=texture(u_fb,gl_FragCoord.xy/vec2(u_fb_size));
3004#endif
3005glFragColor=color;
3006#else
3007#ifdef SDF_SUBPASS
3008highp float d=line_df(v_line_segment.xy,v_line_segment.zw,v_pos);highp float effect_radius=mix(v_flood_light_radius_tile,v_ao.y,u_ao_pass);d/=effect_radius;d=min(d,1.0);d=1.0-pow(1.0-d,u_attenuation);highp float effect_intensity=mix(u_flood_light_intensity,v_ao.x,u_ao_pass);highp float fog=1.0;
3009#ifdef FOG
3010fog=v_fog;
3011#endif
3012#ifdef RENDER_CUTOFF
3013fog*=v_cutoff_opacity;
3014#endif
3015glFragColor=vec4(vec3(0.0),mix(1.0,d,effect_intensity*u_opacity*fog));
3016#else
3017#ifdef USE_MRT1
3018out_Target1=vec4(1.0-texture(u_fb,gl_FragCoord.xy/vec2(u_fb_size)).a,0.0,0.0,0.0);
3019#else
3020vec4 color=mix(vec4(u_flood_light_color,1.0),vec4(vec3(0.0),1.0),u_ao_pass);
3021#ifdef OVERDRAW_INSPECTOR
3022color=vec4(1.0);
3023#endif
3024glFragColor=color;
3025#endif
3026#endif
3027HANDLE_WIREFRAME_DEBUG;
3028#endif
3029}`,`#include "_prelude_fog.vertex.glsl"
3030in highp ivec4 a_pos_end;in highp int a_angular_offset_factor;in highp uint a_hidden_by_landmark;
3031#ifdef SDF_SUBPASS
3032out highp vec2 v_pos;out highp vec4 v_line_segment;out highp float v_flood_light_radius_tile;out highp vec2 v_ao;
3033#ifdef FOG
3034out highp float v_fog;
3035#endif
3036#endif
3037uniform highp float u_flood_light_intensity;uniform highp mat4 u_matrix;uniform highp float u_ao_pass;uniform highp float u_meter_to_tile;uniform highp float u_edge_radius;uniform highp float u_dynamic_offset;uniform highp vec2 u_ao;
3038#pragma mapbox: define highp float flood_light_ground_radius
3039const float TANGENT_CUTOFF=4.0;const float NORM=32767.0;void main() {
3040#pragma mapbox: initialize highp float flood_light_ground_radius
3041vec4 pos_end=vec4(a_pos_end);vec2 p=pos_end.xy;vec2 q=floor(pos_end.zw*0.5);vec2 start_bottom=pos_end.zw-q*2.0;float fl_ground_radius=abs(flood_light_ground_radius);float direction=flood_light_ground_radius < 0.0 ?-1.0 : 1.0;float flood_radius_tile=fl_ground_radius*u_meter_to_tile;vec2 v=normalize(q-p);float ao_radius=u_ao.y/3.5;float effect_radius=mix(flood_radius_tile,ao_radius,u_ao_pass)+u_edge_radius;float angular_offset_factor=float(a_angular_offset_factor)/NORM*TANGENT_CUTOFF;float angular_offset=direction*angular_offset_factor*effect_radius;float top=1.0-start_bottom.y;float side=(0.5-start_bottom.x)*2.0;vec2 extrusion_parallel=v*side*mix(u_dynamic_offset,angular_offset,top);vec2 perp=vec2(v.y,-v.x);vec2 extrusion_perp=direction*perp*effect_radius*top;vec3 pos=vec3(mix(q,p,start_bottom.x),0.0);pos.xy+=extrusion_parallel+extrusion_perp;
3042#ifdef SDF_SUBPASS
3043v_pos=pos.xy;v_line_segment=vec4(p,q)+perp.xyxy*u_edge_radius;v_flood_light_radius_tile=flood_radius_tile;v_ao=vec2(u_ao.x,ao_radius);
3044#ifdef FOG
3045v_fog_pos=fog_position(pos);v_fog=1.0-fog(v_fog_pos);
3046#endif
3047#endif
3048float hidden_by_landmark=0.0;
3049#ifdef HAS_CENTROID
3050hidden_by_landmark=float(a_hidden_by_landmark);
3051#endif
3052float isFloodlit=float(fl_ground_radius > 0.0 && u_flood_light_intensity > 0.0);float hidden=mix(1.0-isFloodlit,isFloodlit,u_ao_pass);hidden+=hidden_by_landmark;gl_Position=mix(u_matrix*vec4(pos,1.0),AWAY,float(hidden > 0.0));
3053#ifdef RENDER_CUTOFF
3054v_cutoff_opacity=cutoff_opacity(u_cutoff_params,gl_Position.z);
3055#endif
3056}`),groundShadow:Vt(`#include "_prelude_shadow.fragment.glsl"
3057#include "_prelude_indicator_cutout.fragment.glsl"
3058#include "_prelude_feature_cutout.fragment.glsl"
3059precision highp float;uniform vec3 u_ground_shadow_factor;in vec4 v_pos_light_view_0;in vec4 v_pos_light_view_1;
3060#ifdef FOG
3061in float v_fog_opacity;
3062#endif
3063void main() {float light=shadowed_light_factor_plane_bias(v_pos_light_view_0,v_pos_light_view_1,1.0/gl_FragCoord.w);vec3 shadow=mix(u_ground_shadow_factor,vec3(1.0),light);
3064#ifdef RENDER_CUTOFF
3065shadow=mix(vec3(1.0),shadow,cutoff_opacity(u_cutoff_params,1.0/gl_FragCoord.w));
3066#endif
3067#ifdef FOG
3068shadow=mix(shadow,vec3(1.0),v_fog_opacity);
3069#endif
3070#ifdef INDICATOR_CUTOUT
3071shadow=mix(shadow,vec3(1.0),1.0-applyCutout(vec4(1.0),0.0).r);
3072#endif
3073#ifdef FEATURE_CUTOUT
3074vec2 uv=gl_FragCoord.xy*u_inv_viewport_size.xy;
3075#ifdef FLIP_Y
3076uv.y=1.0-uv.y;
3077#endif
3078highp float cutoutFactor=get_cutout_factors(gl_FragCoord).y;highp float cutoutDepthNDC=sample_cutout_depth_bilinear(u_cutout_depth_image,uv);highp float fragDepthNDC=gl_FragCoord.z/u_feature_cutout_params.w;highp float groundThreshold=-0.001;highp float groundLimit=clamp((fragDepthNDC+groundThreshold-cutoutDepthNDC)/groundThreshold+0.5,0.0,1.0);cutoutFactor=mix(0.0,cutoutFactor,groundLimit);shadow=mix(shadow,vec3(1.0),cutoutFactor);
3079#endif
3080glFragColor=vec4(shadow,1.0);}`,`#include "_prelude_fog.vertex.glsl"
3081uniform mat4 u_matrix;uniform mat4 u_light_matrix_0;uniform mat4 u_light_matrix_1;in ivec2 a_pos;out vec4 v_pos_light_view_0;out vec4 v_pos_light_view_1;
3082#ifdef FOG
3083out float v_fog_opacity;
3084#endif
3085void main() {gl_Position=u_matrix*vec4(a_pos,0.0,1.0);v_pos_light_view_0=u_light_matrix_0*vec4(a_pos,0.0,1.0);v_pos_light_view_1=u_light_matrix_1*vec4(a_pos,0.0,1.0);
3086#ifdef FOG
3087v_fog_pos=fog_position(vec2(a_pos));v_fog_opacity=fog(v_fog_pos);
3088#endif
3089}`)};const Xg=(s,t)=>({u_matrix:s,u_ground_shadow_factor:t}),Tm={model:s=>({u_matrix:new u.ap(s),u_lighting_matrix:new u.ap(s),u_normal_matrix:new u.ap(s),u_node_matrix:new u.ap(s),u_lightpos:new u.aq(s),u_lightintensity:new u.ar(s),u_lightcolor:new u.aq(s),u_camera_pos:new u.aq(s),u_opacity:new u.ar(s),u_baseColorFactor:new u.bZ(s),u_emissiveFactor:new u.bZ(s),u_metallicFactor:new u.ar(s),u_roughnessFactor:new u.ar(s),u_baseTextureIsAlpha:new u.b_(s),u_alph
3089aMask:new u.b_(s),u_alphaCutoff:new u.ar(s),u_baseColorTexture:new u.b_(s),u_metallicRoughnessTexture:new u.b_(s),u_normalTexture:new u.b_(s),u_occlusionTexture:new u.b_(s),u_emissionTexture:new u.b_(s),u_lutTexture:new u.b_(s),u_color_mix:new u.bZ(s),u_aoIntensity:new u.ar(s),u_emissive_strength:new u.ar(s),u_occlusionTextureTransform:new u.bZ(s),u_dithered_discard_threshold:new u.ar(s)}),modelDepth:s=>({u_matrix:new u.ap(s),u_instance:new u.ap(s),u_node_matrix:new u.ap(s)}),groundShadow:s=>({u_matrix:new u.ap(s),u_ground_shadow_factor:new u.aq(s)}),fillExtrusionDepth:s=>({u_matrix:new u.ap(s),u_edge_radius:new u.ar(s),u_width_scale:new u.ar(s),u_vertical_scale:new u.ar(s),u_height_type:new u.b_(s),u_base_type:new u.b_(s)}),fillExtrusionGroundEffect:s=>({u_matrix:new u.ap(s),u_opacity:new u.ar(s),u_ao_pass:new u.ar(s),u_meter_to_tile:new u.ar(s),u_ao:new u.b$(s),u_flood_light_intensity:new u.ar(s),u_flood_light_color:new u.aq(s),u_attenuation:new u.ar(s),u_edge_radius:new u.ar(s),u_fb:new u.b_(s),u_fb_size:new u.ar(s),u_dynamic_offset:new u.ar(s)})},hc=[];function tu(s){return hc[s]=hc[s]||new Float64Array(16)}const ka=[],Sm=new Float32Array(16);class Em{constructor(t,n){this.aabb=t,this.lastCascade=n}}class Im{add(t,n){const l=this.receivers[t.key];l!==void 0?(l.aabb.min[0]=Math.min(l.aabb.min[0],n.min[0]),l.aabb.min[1]=Math.min(l.aabb.min[1],n.min[1]),l.aabb.min[2]=Math.min(l.aabb.min[2],n.min[2]),l.aabb.max[0]=Math.max(l.aabb.max[0],n.max[0]),l.aabb.max[1]=Math.max(l.aabb.max[1],n.max[1]),l.aabb.max[2]=Math.max(l.aabb.max[2],n.max[2])):this.receivers[t.key]=new Em(n,null)}clear(){this.receivers={}}get(t){return this.receivers[t.key]}computeRequiredCascades(t,n,l){const d=u.ca.fromPoints(t.points);let p=0;for(const m in this.receivers){const g=this.receivers[m];if(!g||!d.intersectsAabb(g.aabb))continue;g.aabb.min=d.closestPoint(g.aabb.min),g.aabb.max=d.closestPoint(g.aabb.max);const x=g.aabb.getCorners();for(let w=0;w<l.length;w++){let S=!0;for(const A of x){const I=[A[0]*n,A[1]*n,A[2]];if(u.ad(I,I,l[w].matrix),I[0]<-1||I[0]>1||I[1]<-1||I[1]>1){S=!1;break}}if(g.lastCascade=w,p=Math.max(p,w),S)break}}return p+1}}function da(s,t,n){const l=u.aW([],n,t),d=u.aW([],s,t),p=u.ax([],l,d),m=u.ae(p);return m===0?[0,0,1,0]:(u.av(p,p,1/m),[p[0],p[1],p[2],-u.aw(p,t)])}function Am(s,t,n,l,d,p){const m=s.zoom,g=s.scale,x=s.worldSize,w=1/x,S=s.aspect,A=Math.sqrt(1+S*S)*Math.tan(.5*s.fovX),I=A*A,M=l-n,D=l+n;let L,k;I>M/D?(L=l,k=l*A):(L=.5*D*(1+I),k=.5*Math.sqrt(M*M+2*(l*l+n*n)*I+D*D*I*I));const B=s.projection.pixelsPerMeter(s.center.lat,x),$=s._camera.getCameraToWorldMercator(),Z=[0,0,-L*w];u.ad(Z,Z,$);let G=k*w;const te=function(De){return De[0]/=g,De[1]/=g,De[2]=u.aL(De[2],s._center.lat),De},ee=s._edgeInsets;if(!(ee.left===0&&ee.top===0&&ee.right===0&&ee.bottom===0||ee.left===ee.right&&ee.top===ee.bottom)){const De=s._camera.getWorldToCamera(s.worldSize,s.projection.zAxisUnit==="meters"?B:1),Ke=s._camera.getCameraToClipPerspective(s._fov,s.width/s.height,n,l);Ke[8]=2*-s.centerOffset.x/s.width,Ke[9]=2*s.centerOffset.y/s.height;const Be=new Float64Array(16);u.bI(Be,Ke,De);const Ge=new Float64Array(16);u.aE(Ge,Be);const Ze=u.bs.fromInvProjectionMatrix(Ge,x,m,!0);for(const tt of Ze.points){const ot=te(tt);G=Math.max(G,u.ay(u.cA([],Z,ot)))}}G*=d/(d-1);const le=Math.acos(t[2]),K=Math.atan2(-t[0],-t[1]),Q=new ci;Q.position=Z,Q.setPitchBearing(le,K);const ae=Q.getWorldToCamera(x,B),de=G*x,fe=Math.min(s._mercatorZfromZoom(17)*x*-2,-2*de),be=Q.getCameraToClipOrthographic(-de,de,-de,de,fe,(de+p*B)/t[2]),Te=new Float64Array(16);u.aP(Te,be,ae);const Ve=u.c6(Math.floor(1e6*Z[0])/1e6*x,Math.floor(1e6*Z[1])/1e6*x,0),ye=.5*d,Ae=[0,0,0];u.ad(Ae,Ve,Te),u.av(Ae,Ae,ye);const ge=[Math.floor(Ae[0]),Math.floor(Ae[1]),Math.floor(Ae[2])],Fe=[0,0,0];u.aW(Fe,Ae,ge),u.av(Fe,Fe,-1/ye);const Re=new Float64Array(16);return u.aC(Re),u.aG(Re,Re,Fe),u.aP(Te,Re,Te),[Te,de]}const Yg={loaded:!0,drawModels:function(s,t,n,l){if(s.renderPass==="opaque")return;const d=n.paint.get("model-opacity").constantOr(1),p=n.paint.get("model-elevation-reference"),m=p==="ground",g=p==="ground";if(d===0)return;const x=n.paint.get("model-cast-shadows");
vendor: 16,754 bytes, line 3089
3089if(s.renderPass==="shadow"&&(!x||s.terrain&&d<.65&&n._transitionablePaint._values["model-opacity"].value.expression instanceof u.ab))return;const w=s.shadowRenderer,S=n.paint.get("model-receive-shadows");w&&(w.useNormalOffset=!0,S||(w.enabled=!1));const A=()=>{w&&(w.useNormalOffset=!0,S||(w.enabled=!0))},I=t.getSource();if(s.renderPass==="light-beam"&&I.type!=="batched-model")return;if(I.type==="vector"||I.type==="geojson")return(function(G,te,ee,le,K){const Q=G.transform,ae=Q.projection.name==="globe",de=Q.getFreeCameraOptions().position;if(!G.modelManager)return;const fe=G.modelManager;ee.modelManager=fe;const be=G.shadowRenderer;if(!Object.hasOwn(ee._unevaluatedLayout._values,"model-id"))return;const Te=ee._unevaluatedLayout._values["model-id"],Ve={...ee.layout.get("model-id").parameters},ye=G.style.order.indexOf(ee.fqid),Ae=ee.paint.get("model-opacity").constantOr(1);for(const ge of le){const Fe=te.getTile(ge).getBucket(ee);if(!Fe||Fe.projection.name!==Q.projection.name)continue;const Re=Fe.getModelUris();if(Re&&!Fe.modelsRequested&&(fe.addModelsFromBucket(Re,K),Fe.modelsRequested=!0),ae)Ve.zoom=ge.overscaledZ;else{const at=mm(ge,Q);Ve.zoom=at}const De=Te.possiblyEvaluate(Ve);if(Kc(G,Fe,ge),Es.shadowUniformsInitialized=!1,Es.useSingleShadowCascade=!!be&&be.getMaxCascadeForTile(ge.toUnwrapped())===0,G.renderPass==="shadow"&&be){if(G.currentShadowCascade===1&&Fe.isInsideFirstShadowMapFrustum)continue;const at=Q.calculatePosMatrix(ge.toUnwrapped(),Q.worldSize);if(Es.tileMatrix.set(at),Es.shadowTileMatrix.set(be.calculateShadowPassMatrixFromMatrix(at)),Es.aabb.min=[0,0,0],Es.aabb.max[0]=Es.aabb.max[1]=u.aj,Es.aabb.max[2]=0,Yd(Fe,Es,G,ee.scope))continue}const Ke=1<<ge.canonical.z,Be=[((de.x-ge.wrap)*Ke-ge.canonical.x)*u.aj,(de.y*Ke-ge.canonical.y)*u.aj,de.z*Ke*u.aj];G.conflationActive&&Object.keys(Fe.instancesPerModel).length>0&&G.style.isLayerClipped(ee,te.getSource())&&Fe.updateReplacement(ge,G.replacementSource,ye,ee.scope)&&(Fe.uploaded=!1,Fe.upload(G.context));let Ge=0;const Ze=new Array,tt=new Array,ot=new Array;for(let at in Fe.instancesPerModel){const ut=Fe.instancesPerModel[at];ut.features.length>0&&!ae&&(at=De.evaluate(ut.features[0].feature,{}));const bt=fe.getModel(at,K);if(bt||fe.hasURLBeenRequested(at)||Fe.modelUris.includes(at)||(Fe.modelUris.push(at),Fe.modelsRequested=!1),bt&&bt.uploaded)if(ae){const pt=u.av([],[de.x,de.y,de.z],G.transform.worldSize);u.cb(pt,pt);for(let Lt=0;Lt<ut.instancedDataArray.length;++Lt){const kt=[0,0,0],gt=[1,1,1],Pt=u.cd(),Ct=ut.tileCoordinatesForInstance(Lt),Ut=ut.transformForInstance(Lt);u.ce(gt,Ut),u.cf(Pt,Ut),u.cg(kt,Pt);const oi=ut.translationForInstance(Lt),Ci=new u.b4(0,0);u.ch(Fe.canonical,Ci,Ct.x,Ct.y);const hi=u.aS();u.ci(hi,bt,G.transform,Ci,kt,gt,oi,!0,!1,!1);const Kt=ut.colorForInstance(Lt),Ei=u.bR([],pt),mi=u.cc(Ci.lat,G.transform.zoom),Qi=u.aF([],[1,1,1/mi]);ot.push({zScaleMatrix:Qi,negCameraPosMatrix:Ei});for(const Ot of bt.nodes)oh(G,Ot,hi,G.transform.expandedFarZProjMatrix,Ge,Ze,tt,bt.materialOverrides,Ae,Kt);++Ge}}else for(const pt of bt.nodes)Jc(G,ee,pt,ut,Be,ge,Es)}if(ae)if(G.renderPass==="shadow"){for(const at of tt)ac(at.mesh,at.nodeModelMatrix,G,ee);for(const at of Ze)ac(at.mesh,at.nodeModelMatrix,G,ee)}else lc(G,ee,Ze,tt,ot)}})(s,t,n,l,rt(s,n)),void A();if(!I.loaded())return;if(I.type==="batched-model")return(function(G,te,ee,le){ee.resetLayerRenderingStats(G);const K=G.context,Q=G.transform,ae=G.style.fog,de=G.shadowRenderer;if(Q.projection.name!=="mercator")return void u.w(`Drawing 3D landmark models for ${Q.projection.name} projection is not yet implemented`);const fe=G.transform.getFreeCameraOptions().position,be=u.av([],[fe.x,fe.y,fe.z],G.transform.worldSize),Te=u.cb([],be),Ve=u.bR([],Te),ye=u.cc(Q.center.lat,Q.zoom),Ae=u.aF([],[1,1,1/ye]),ge=u.aP([],Ve,Ae),Fe=ee.paint.get("model-opacity").constantOr(1),Re=new ct(K.gl.LEQUAL,ct.ReadWrite,G.depthRangeFor3D),De=new ct(K.gl.LEQUAL,ct.ReadOnly,G.depthRangeFor3D),Ke=new u.ca([1/0,1/0,1/0],[-1/0,-1/0,-1/0]),Be=G.renderPass==="shadow",Ge=G.renderPass==="light-beam",Ze=ee.paint.get("model-color-use-theme").constantOr("default")==="none",tt=Be&&de?de.getCurrentCascadeFrustum():Q.getFrustum(Q.scaleZoom(Q.worldSize)),ot=ee.paint.get("model-front-cutoff"),at=ot[2]<1,ut=Oo(G,ee.paint.get("model-cutoff-fade-range")),bt=ee.getLayerRenderingStats();(function(pt,Lt,kt,gt){const Pt=pt.terrain?pt.terrain.exaggeration():0,Ct=pt.transform.zoom;for(const Ut of gt){const oi=Lt.getTile(Ut).getBucket(kt);oi&&(oi.setFilter(kt.filter),pt.conflationActive&&oi.updateReplacement(Ut,pt.replacementSource),oi.evaluateTransform(pt,kt),pt.terrain&&Pt>0&&oi.elevationUpdate(pt.terrain,Pt,Ut,kt.source),oi.needsReEvaluation(pt,Ct,kt)&&oi.evaluate(kt))}})(G,te,ee,le),(function(){const pt=new Map;let Lt,kt,gt;at?(Lt=le.length-1,kt=-1,gt=-1):(Lt=0,kt=le.length,gt=1);const Pt=u.bj(),Ct=new u.P(0,0);for(let Ut=Lt;Ut!==kt;Ut+=gt){const oi=le[Ut],Ci=te.getTile(oi).getBucket(ee);if(!Ci||!Ci.uploaded)continue;let hi=!1;de&&(hi=de.getMaxCascadeForTile(oi.toUnwrapped())===0);const Kt=Q.calculatePosMatrix(oi.toUnwrapped(),Q.worldSize),Ei=!!(Ci.modelTraits&u.ck.HasMapboxMeshFeatures);u.aP(Zs,ge,Kt),u.aP(Hd,Q.expandedFarZProjMatrix,Kt),u.aE(rh,Zs),u.cl(rh,rh);const mi=!Be&&de&&de.enabled?de.computeCascadeTileMatrices(Kt):null;!Be&&at&&(u.aE($r,Kt),u.ad(Pt,be,$r),Ct.x=Pt[0],Ct.y=Pt[1]);const Qi=[];Ci.setFilter(ee.filter);for(const Ot of Ci.getNodesInfo()){if(Ot.hiddenByReplacement||!Ot.node.meshes)continue;const $t=Ot.node;let Mt=0;G.terrain&&$t.elevation&&(Mt=$t.elevation*G.terrain.exaggeration());const Ii=(()=>{const Oi=Ot.aabb,ii=Ke.min,di=Ke.max;return ii[0]=Oi.min[0],ii[1]=Oi.min[1],ii[2]=Oi.min[2]+Mt,di[0]=Oi.max[0],di[1]=Oi.max[1],di[2]=Oi.max[2]+Mt,u.ad(ii,ii,Kt),u.ad(di,di,Kt),Ke})(),wi=Ot.evaluatedScale;if(wi[0]<=1&&wi[1]<=1&&wi[2]<=1&&Ii.intersects(tt)===0)continue;if(!Be){const Oi=Ii.min,ii=Ii.max;nc[0]=.5*(Oi[0]+ii[0]),nc[1]=.5*(Oi[1]+ii[1]),nc[2]=.5*(Oi[2]+ii[2]);const di=u.aX(be,nc)*ye,si=G._debugParams.lodSwitchDistance,Ai=si>=0;if(Ai&&si>=9999)Ot.targetLod=0;else{let pr;if(Ai)pr=si;else{const Xi=(ii[2]-Oi[2])*ye*wi[2],Er=Math.max(ii[0]-Oi[0],ii[1]-Oi[1])*ye*Math.max(wi[0],wi[1]);let jo;jo=Xi>=30?1:Er>=80?.5:Math.max(Xi,Er)>=20?.25:0,pr=2e3+3e3*jo}ha(Ot,di,Math.min(G.frameTimeDelta,1e3/30),pr,G._debugParams.lodSwitchFadeDuration)}}if(!Be&&at){const Oi=.16666666666666666;Ot.cameraCollisionOpacity=be[0]>Ii.min[0]&&be[0]<Ii.max[0]&&be[1]>Ii.min[1]&&be[1]<Ii.max[1]&&be[2]*ye<Ii.max[2]&&$t.footprint&&u.cm(Ct,$t.footprint)?Math.max(Ot.cameraCollisionOpacity-Oi,0):Math.min(1,Ot.cameraCollisionOpacity+Oi)}const sr=1/u.cn(oi.canonical),Wi=$t.anchor?$t.anchor[0]:0,Pr=$t.anchor?$t.anchor[1]:0,kr=[Wi*(wi[0]-1)+Ot.evaluatedTranslation[0]*sr,Pr*(wi[1]-1)+Ot.evaluatedTranslation[1]*sr,Mt+Ot.evaluatedTranslation[2]],En=oc(new Float64Array(16),Kt,kr,wi),qr=u.aP([],En,$t.globalMatrix),ti=u.aP([],Q.expandedFarZProjMatrix,qr),ar=ti[2]*Wi+ti[6]*Pr+ti[10]*Mt+ti[14];$t.hidden=!1;let Ui=Fe;Be||(at&&(Ui*=Ot.cameraCollisionOpacity,Ui*=sh(En,Q,Ot.aabb,ot)),Ui*=_l(ut,ar)),Ui!==0?Qi.push({nodeInfo:Ot,depth:ar,opacity:Ui,wvpForNode:ti,nodeModelMatrix:qr,tileModelMatrix:En,tileTranslation:kr}):$t.hidden=!0}Be||Qi.sort((Ot,$t)=>!at||Ot.opacity===1&&$t.opacity===1?Ot.depth<$t.depth?-1:1:Ot.opacity===1?-1:$t.opacity===1?1:Ot.depth>$t.depth?-1:1);for(const Ot of Qi){const $t=Ot.nodeInfo,Mt=$t.node;let Ii=null;if(G._debugParams.show3DModelFootprints&&Mt.footprint){const Ui=Mt.id||Mt.name||"footprint";if(!pt.has(Ui)){const Oi=oc(new Float64Array(16),Hd,Ot.tileTranslation,Ot.nodeInfo.evaluatedScale);pt.set(Ui,{node:Mt,mvp:Oi})}}const wi=Ot.nodeInfo.evaluatedScale;oc(vn,Zs,Ot.tileTranslation,wi),Yc[0]=1/wi[0],Yc[1]=-1/wi[1],Yc[2]=1/wi[2],u.bL($r,rh,Yc),u.aP(vn,vn,Mt.globalMatrix);const sr=Ei?0:$t.evaluatedRMEA[0][2],Wi=$t.targetLod,Pr=Mt.lodMeshes&&Mt.lodMeshes.length>0,kr=Pr&&Wi>0&&Wi<1;if(Be&&Pr&&Math.round(Wi)===1)continue;const En=!Be&&ae?Zd(on,Ot.nodeModelMatrix,G.transform):null,qr=Be&&de?de.calculateShadowPassMatrixFromMatrix(Ot.nodeModelMatrix):null,ti=kr?2:1,ar=Pr&&Math.round(Wi)===1;for(let Ui=0;Ui<ti;++Ui){const Oi=kr?Ui===1:ar,ii=Oi?Mt.lodMeshes:Mt.meshes,di=kr?Oi?-Wi:1-Wi:1;for(let si=0;si<ii.length;++si){const Ai=ii[si],pr=!Oi&&si===Mt.lightMeshIndex;let Xi=Ot.wvpForNode;if(pr){if(!Ge&&!G.terrain&&G.shadowRenderer){G.currentLayer<G.firstLightBeamLayer&&(G.firstLightBeamLayer=G.currentLayer);continue}Xi=oc(Hg,Hd,Ot.tileTranslation,Ot.nodeInfo.evaluatedScale)}else if(Ge)continue;const Er={defines:[]},jo=[],wn=!!Ai.normalBuffer;if(!Be&&de&&(de.useNormalOffset=wn),ua(Er.defines,jo,Ai,G,Ze?null:ee.lut),Ei||Er.defines.push("DIFFUSE_SHADED"),hi&&Er.defines.push("SHADOWS_SINGLE_CASCADE"),bt&&(Be?bt.numRenderedVerticesInShadowPass+=Ai.vertexArray.length:bt.numRenderedVerticesInTransparentPass+=Ai.vertexArray.length),Be){ac(Ai,Ot.nodeModelMatrix,G,ee,qr);continue}if(ae&&Q.projection.name!=="globe"){const In=Ai.aabb.min,$o=Ai.aabb.max,[Lc,va]=ae.getOpacityForBounds(En,In[0],In[1],$o[0],$o[1]);Er.overrideFog=Lc>=hl||va>=hl}const Go=Ai.material;let xa;Go.occlusionTexture&&Go.occlusionTexture.offsetScale&&(xa=Go.occlusionTexture.offsetScale,Er.defines.push("OCCLUSION_TEXTURE_TRANSFORM")),kr&&Er.defines.push("DITHERED_DISCARD");const bo=G.getOrCreateProgram("model",Er);if(!Be&&de&&de.enabled)if(Ii!==wn){for(let In=0;In<mi.length;In++)oc(nh[In]=nh[In]||new Float64Array(16),mi[In],Ot.tileTranslation,Ot.nodeInfo.evaluatedScale);de.setupShadowsFromCascadeMatrices(nh,bo,wn),Ii=wn}else bo.setShadowUniformValues(K,de.getShadowUniformValues());G.uploadCommonUniforms(K,bo,null,En);const Xn=Go.pbrMetallicRoughness;Xn.metallicFactor=.9,Xn.roughnessFactor=.5;const Ja=qd(Xi,vn,$r,Mt.globalMatrix,G,Ot.opacity,Xn.baseColorFactor,Go.emissiveFactor,Xn.metallicFactor,Xn.roughnessFactor,Go,sr,ee,pm,xa,void 0,void 0,di,bo.fixedDefines.includes("LIGHTING_3D_MODE"));!pr&&($t.hasTranslucentParts||Ot.opacity<1)&&bo.draw(G,K.gl.TRIANGLES,Re,mt.disabled,yt.disabled,_t.backCCW,Ja,ee.id,Ai.vertexBuffer,Ai.indexBuffer,Ai.segments,ee.paint,G.transform.zoom,void 0,jo),bo.draw(G,K.gl.TRIANGLES,pr?De:Re,mt.disabled,pr||Ot.opacity<1||$t.hasTranslucentParts?yt.alphaBlended:yt.unblended,_t.backCCW,Ja,ee.id,Ai.vertexBuffer,Ai.indexBuffer,Ai.segments,ee.paint,G.transform.zoom,void 0,jo)}}}}if(G._debugParams.show3DModelFootprints&&pt.size>0){const Ut=Array.from(pt.keys()).sort();for(const oi of Ut){const{node:Ci,mvp:hi}=pt.get(oi);Wd(G,0,Ci,hi)}}})()})(s,t,n,l),void A();if(I.type!=="model")return;const M=I.getModels(),D=[],L=s.transform.getFreeCameraOptions().position,k=u.av([],[L.x,L.y,L.z],s.transform.worldSize);u.cb(k,k);const B=[],$=[];let Z=0;for(const G of M){const te=t.getFeatureState("",G.id),ee={type:"Unknown",id:G.id,properties:G.featureProperties},le=n.paint.get("model-rotation").evaluate(ee,te),K=n.paint.get("model-scale").evaluate(ee,te),Q=n.paint.get("model-translation").evaluate(ee,te),ae=n.paint.get("model-opacity").evaluate(ee,te);Xd(n,G.id,te,G.featureProperties,G.nodeOverrideNames,G.nodeOverrides),ml(n,G.id,te,G.featureProperties,G.materialOverrideNames,G.materialOverrides),G.nodeOverrides.size>0&&G.computeBoundsAndApplyParent(),G.computeModelMatrix(s,le,K,Q,g,m,!1);const de=u.bR([],k),fe=u.cc(G.position.lat,s.transform.zoom),be=u.aF([],[1,1,1/fe]);D.push({zScaleMatrix:be,negCameraPosMatrix:de});for(const Te of G.nodes)oh(s,Te,G.matrix,s.transform.expandedFarZProjMatrix,Z,B,$,G.materialOverrides,ae,void 0,G.lightOverrides);Z++}if(B.sort((G,te)=>te.depth-G.depth),s.renderPass!=="shadow"){if(s._debugParams.show3DModelFootprints){const G=s.transform.projMatrix,te=new Map,ee=(K,Q)=>{if(K.footprint){const ae=K.id||K.name||"footprint";if(!te.has(ae)){const de=u.aP([],G,Q);te.set(ae,{node:K,mvp:de})}}};for(const K of $)ee(K.node,K.modelMatrix);for(const K of B)ee(K.node,K.modelMatrix);const le=Array.from(te.keys()).sort();for(const K of le){const{node:Q,mvp:ae}=te.get(K);Wd(s,0,Q,ae)}}lc(s,n,B,$,D),A()}else{for(const G of $)ac(G.mesh,G.nodeModelMatrix,s,n);for(const G of B)ac(G.mesh,G.nodeModelMatrix,s,n);A()}},prepare:function(s,t,n){const l=t.getSource();if(!l.loaded())return;if(l.type==="vector"||l.type==="geojson")return void(n.modelManager&&n.modelManager.upload(n,rt(n,s)));if(l.type==="batched-model"||l.type!=="model")return;const d=l.getModels();for(const p of d)p.upload(n.context)},shaders:ch,programUniforms:Tm,ShadowRenderer:class{constructor(s){this.painter=s,this._enabled=!1,this._drawShadowAfterLayer=-1,this._numCascadesToRender=0,this._cascades=[],this._groundShadowTiles=[],this._receivers=new Im,this._depthMode=new ct(s.context.gl.LEQUAL,ct.ReadWrite,[0,1]),this._uniformValues={u_light_matrix_0:new Float32Array(16),u_light_matrix_1:new Float32Array(16),u_shadow_intensity:0,u_fade_range:[0,0],u_shadow_normal_offset:[1,1,1],u_shadow_texel_size:1,u_shadow_map_resolution:1,u_shadow_direction:[0,0,1],u_shadow_bias:[36e-5,.0012,.012],u_shadowmap_0:0,u_shadowmap_1:0},this._forceDisable=!1,this._devtoolsFolder=null,this.useNormalOffset=!1,this._shadowParameters={cascadeCount:2,normalOffset:3,shadowMapResolution:2048}}destroy(){for(const s of this._cascades)s.texture.destroy(),s.framebuffer.destroy();this._cascades=[]}updateShadowParameters(s,t){const n=this.painter;if(this._enabled=!1,this._drawShadowAfterLayer=-1,this._receivers.clear(),!t||!t.properties)return;const l=t.properties.get("shadow-intensity"),d=t.properties.get("shadow-draw-before-layer");if(!t.shadowsEnabled()||l<=0)return;let p=-1,m=0;for(const k of n.style.order){const B=n.style._mergedLayers[k];B.hasShadowPass()&&!B.isHidden(s.zoom)&&(p=m),!d||d!==k&&d!==B.slot||(this._drawShadowAfterLayer=m>0?m-1:0),m+=1}if(this._enabled=p>=0,!this.enabled)return;this._drawShadowAfterLayer<0&&(this._drawShadowAfterLayer=p);const g=n.context,x=this._shadowParameters.shadowMapResolution,w=this._shadowParameters.shadowMapResolution;if(this._cascades.length===0||this._shadowParameters.shadowMapResolution!==this._cascades[0].texture.size[0]){this._cascades=[];for(let k=0;k<this._shadowParameters.cascadeCount;++k){const B=g.gl,$=g.createFramebuffer(x,w,0,"texture"),Z=new u.T(g,{width:x,height:w,data:null},B.DEPTH_COMPONENT16);$.depthAttachment.set(Z.texture),this._cascades.push({framebuffer:$,texture:Z,matrix:[],far:0,boundingSphereRadius:0,frustum:new u.bs,scale:0})}}this.shadowDirection=Hs(t);let S=0;if(s.elevation){const k=s.elevation,B=[1e4,-1e4];k.visibleDemTiles.filter($=>$.dem).forEach($=>{const Z=$.dem.tree;B[0]=Math.min(B[0],Z.minimums[0]),B[1]=Math.max(B[1],Z.maximums[0])}),B[0]!==1e4&&(S=(B[1]-B[0])*k.exaggeration())}const A=1.5*s.cameraToCenterDistance,I=3*A,M=new Float64Array(16);for(let k=0;k<this._cascades.length;++k){const B=this._cascades[k];let $=s.height/50,Z=1;this._shadowParameters.cascadeCount===1?Z=I:k===0?Z=A:($=A,Z=I);const[G,te]=Am(s,this.shadowDirection,$,Z,this._shadowParameters.shadowMapResolution,S);B.scale=s.scale,B.matrix=G,B.boundingSphereRadius=te,u.aE(M,B.matrix),B.frustum=u.bs.fromInvProjectionMatrix(M,1,0,!0),B.far=Z}const D=this._cascades.length-1;this._uniformValues.u_fade_range=[.75*this._cascades[D].far,this._cascades[D].far],this._uniformValues.u_shadow_intensity=l,this._uniformValues.u_shadow_direction=[this.shadowDirection[0],this.shadowDirection[1],this.shadowDirection[2]],this._uniformValues.u_shadow_texel_size=1/this._shadowParameters.shadowMapResolution,this._uniformValues.u_shadow_map_resolution=this._shadowParameters.shadowMapResolution,this._uniformValues.u_shadowmap_0=11,this._uniformValues.u_shadowmap_1=12,this._groundShadowTiles=n.transform.coveringTiles({tileSize:512,renderWorldCopies:!0});const L=n.transform.elevation;for(const k of this._groundShadowTiles){let B={min:0,max:0};if(L){const $=L.getMinMaxForTile(k);$&&(B=$)}this.addShadowReceiver(k.toUnwrapped(),B.min,B.max)}}get enabled(){return this._enabled&&!this._forceDisable}set enabled(s){this._enabled=s}drawShadowPass(s,t){if(!this.enabled)return;const n=this.painter,l=n.context;this._numCascadesToRender=this._receivers.computeRequiredCascades(n.transform.getFrustum(0),n.transform.worldSize,this._cascades),l.viewport.set([0,0,this._shadowParameters.shadowMapResolution,this._shadowParameters.shadowMapResolution]);for(let d=0;d<this._numCascadesToRender;++d){n.currentShadowCascade=d,l.bindFramebuffer.set(this._cascades[d].framebuffer.framebuffer),l.clear({color:u.C.white,depth:1});for(const p of s.order){const m=s._mergedLayers[p];if(!m.hasShadowPass()||m.isHidden(n.transform.zoom))continue;const g=s.getLayerSourceCache(m),x=g?t[g.id]:void 0;(m.type==="model"||x&&x.length)&&n.renderLayer(n,g,m,x)}}n.currentShadowCascade=0}drawGroundShadows(){if(!this.enabled)return;const s=this.painter,t=s.style,n=s.context,l=n.gl,d=t.directionalLight,p=t.ambientLight;
3089if(!d||!p)return;const m=[],g=Oo(s,s.longestCutoffRange);g.shouldRenderCutoff&&m.push("RENDER_CUTOFF"),m.push("RENDER_SHADOWS"),this.useNormalOffset&&m.push("NORMAL_OFFSET");const x=pl(t,d,p),w=new ct(l.LEQUAL,ct.ReadOnly,s.depthRangeFor3D),S=new mt({func:l.EQUAL,mask:255},0,255,l.KEEP,l.KEEP,l.KEEP);for(const A of this._groundShadowTiles){const I=A.toUnwrapped(),M=s.isTileAffectedByFog(A),D=s.getOrCreateProgram("groundShadow",{defines:m,overrideFog:M});this.setupShadows(I,D),s.uploadCommonUniforms(n,D,I,null,g);const L=Xg(s.transform.calculateProjMatrix(I),x);D.draw(s,l.TRIANGLES,w,S,yt.multiply,_t.disabled,L,"ground_shadow",s.tileExtentBuffer,s.quadTriangleIndexBuffer,s.tileExtentSegments,null,s.transform.zoom,null,null)}}getShadowPassDepthMode(){return this._depthMode}getGroundShadowLayerIndex(){return this._drawShadowAfterLayer}calculateShadowPassMatrixFromTile(s){const t=this.painter.transform,n=t.calculatePosMatrix(s,t.worldSize);return u.aP(n,this._cascades[this.painter.currentShadowCascade].matrix,n),Float32Array.from(n)}calculateShadowPassMatrixFromMatrix(s){return u.aP(Sm,this._cascades[this.painter.currentShadowCascade].matrix,s)}setupShadows(s,t,n){if(!this.enabled)return;const l=this.painter.transform,d=this.painter.context,p=d.gl,m=this._uniformValues,g=l.calculatePosMatrix(s,l.worldSize);for(let x=0;x<this._cascades.length;x++){const w=tu(x);u.aP(w,this._cascades[x].matrix,g),m[x===0?"u_light_matrix_0":"u_light_matrix_1"]=w,d.activeTexture.set(p.TEXTURE0+11+x),this._cascades[x].texture.bindExtraParam(p.LINEAR,p.LINEAR,p.CLAMP_TO_EDGE,p.CLAMP_TO_EDGE,p.GREATER)}if(this.useNormalOffset=!!n,this.useNormalOffset){const x=u.cn(s.canonical),w=2/l.tileSize*u.aj/this._shadowParameters.shadowMapResolution,S=w*this._cascades[0].boundingSphereRadius,A=w*this._cascades.at(-1).boundingSphereRadius,I=(n==="vector-tile"?1:3)*(function(M){const D=u.as((M-22)/-22,0,1
vendor: 15,050 bytes, line 3089
3089);return .125*(1-D)+4*D})(l.zoom);m.u_shadow_normal_offset=[x,S*I,A*I],m.u_shadow_bias=[1e-4,.0012,.012]}else m.u_shadow_bias=[36e-5,.0012,.012];t.setShadowUniformValues(d,m)}computeCascadeTileMatrices(s){const t=this._shadowParameters.cascadeCount;for(let n=0;n<t;n++){const l=ka[n]=ka[n]||new Float64Array(16);u.aP(l,this._cascades[n].matrix,s)}return ka.length=t,ka}setupShadowsFromMatrix(s,t,n=!1){if(!this.enabled)return;const l=this._shadowParameters.cascadeCount;for(let d=0;d<l;d++)u.aP(tu(d),this._cascades[d].matrix,s);hc.length=l,this.setupShadowsFromCascadeMatrices(hc,t,n)}setupShadowsFromCascadeMatrices(s,t,n=!1){if(!this.enabled)return;const l=this.painter.context,d=l.gl,p=this._uniformValues;for(let m=0;m<this._shadowParameters.cascadeCount;m++)p[m===0?"u_light_matrix_0":"u_light_matrix_1"]=s[m],l.activeTexture.set(d.TEXTURE0+11+m),this._cascades[m].texture.bindExtraParam(d.LINEAR,d.LINEAR,d.CLAMP_TO_EDGE,d.CLAMP_TO_EDGE,d.GREATER);if(this.useNormalOffset=n,n){const m=this._shadowParameters.normalOffset;p.u_shadow_normal_offset=[1,m,m],p.u_shadow_bias=[6e-5,.0012,.012]}else p.u_shadow_bias=[36e-5,.0012,.012];t.setShadowUniformValues(l,p)}getShadowUniformValues(){return this._uniformValues}getCurrentCascadeFrustum(){return this._cascades[this.painter.currentShadowCascade].frustum}computeSimplifiedTileShadowVolume(s,t,n,l){if(l[2]>=0)return{};const d=(function(g,x,w){const S=w/(1<<g.canonical.z);return new u.ca([g.canonical.x*S+g.wrap*w,g.canonical.y*S+g.wrap*w,0],[(g.canonical.x+1)*S+g.wrap*w,(g.canonical.y+1)*S+g.wrap*w,x])})(s,t,n).getCorners(),p=t/-l[2];l[0]<0?(u.cz(d[0],d[0],[l[0]*p,0,0]),u.cz(d[3],d[3],[l[0]*p,0,0])):l[0]>0&&(u.cz(d[1],d[1],[l[0]*p,0,0]),u.cz(d[2],d[2],[l[0]*p,0,0])),l[1]<0?(u.cz(d[0],d[0],[0,l[1]*p,0]),u.cz(d[1],d[1],[0,l[1]*p,0])):l[1]>0&&(u.cz(d[2],d[2],[0,l[1]*p,0]),u.cz(d[3],d[3],[0,l[1]*p,0]));const m={};return m.vertices=d,m.planes=[da(d[1],d[0],d[4]),da(d[2],d[1],d[5]),da(d[3],d[2],d[6]),da(d[0],d[3],d[7])],m}addShadowReceiver(s,t,n){this._receivers.add(s,u.ca.fromTileIdAndHeight(s,t,n))}getMaxCascadeForTile(s){const t=this._receivers.get(s);return t&&t.lastCascade?t.lastCascade:0}},drawGroundEffect:Tr},mo=Yg;async function rf(){return Promise.resolve()}function dc(s,t,n,l,d,p,m,g){n.resetLayerRenderingStats(s);const x=s.context,w=x.gl,S=s.transform,A=n.paint.get("fill-extrusion-pattern"),I=n.paint.get("fill-extrusion-pattern-cross-fade"),M=A.constantOr(null),D=A.constantOr(1),L=n.paint.get("fill-extrusion-opacity"),k=s.style.enable3dLights(),B=n.paint.get(k&&!D?"fill-extrusion-ambient-occlusion-wall-radius":"fill-extrusion-ambient-occlusion-radius"),$=[n.paint.get("fill-extrusion-ambient-occlusion-intensity"),B],Z=n.layout.get("fill-extrusion-edge-radius"),G=Z>0&&!n.paint.get("fill-extrusion-rounded-roof"),te=G?0:Z,ee=S.projection.name==="globe"?u.cC():0,le=S.projection.name==="globe",K=le?u.ah(S.zoom):0,Q=[u.a_(S.center.lng),u.a$(S.center.lat)],ae=n.paint.get("fill-extrusion-flood-light-color-use-theme").constantOr("default")==="none",de=n.paint.get("fill-extrusion-flood-light-color").toNonPremultipliedRenderColor(ae?null:n.lut).toArray01().slice(0,3),fe=n.paint.get("fill-extrusion-flood-light-intensity"),be=n.paint.get("fill-extrusion-vertical-scale"),Te=n.paint.get("fill-extrusion-line-width").constantOr(1)!==0,Ve=n.paint.get("fill-extrusion-height-alignment"),ye=n.paint.get("fill-extrusion-base-alignment"),Ae=Oo(s,n.paint.get("fill-extrusion-cutoff-fade-range")),ge=n.paint.get("fill-extrusion-front-cutoff"),Fe=iu(S.pitch,ge,!!s.terrain),Re=Fe[2]<1;Re&&(s.maxFrontCutoffRawStart=Math.max(s.maxFrontCutoffRawStart,ge[0]));const De=[];let Ke;le&&De.push("PROJECTION_GLOBE_VIEW"),$[0]>0&&De.push("FAUX_AO"),G&&De.push("ZERO_ROOF_RADIUS"),g&&De.push("HAS_CENTROID"),fe>0&&De.push("FLOOD_LIGHT"),Ae.shouldRenderCutoff&&De.push("RENDER_CUTOFF"),Re&&De.push("RENDER_FRONT_CUTOFF"),Te&&De.push("RENDER_WALL_MODE");const Be=s.renderPass==="shadow",Ge=s.shadowRenderer,Ze=Be&&!!Ge,tt=Be?_t.disabled:_t.backCCW;s.shadowRenderer&&(s.shadowRenderer.useNormalOffset=!0);let ot=[0,0,0];if(Ge){const bt=s.style.directionalLight,pt=s.style.ambientLight;bt&&pt&&(ot=pl(s.style,bt,pt)),Be||(De.push("RENDER_SHADOWS"),Ge.useNormalOffset&&De.push("NORMAL_OFFSET")),Ke=De.concat(["SHADOWS_SINGLE_CASCADE"])}const at=Ze?"fillExtrusionDepth":D?"fillExtrusionPattern":"fillExtrusion",ut=n.getLayerRenderingStats();for(const bt of l){const pt=t.getTile(bt),Lt=pt.getBucket(n);if(!Lt||Lt.projection.name!==S.projection.name)continue;let kt=!1;Ge&&(kt=Ge.getMaxCascadeForTile(bt.toUnwrapped())===0);const gt=s.isTileAffectedByFog(bt),Pt=Lt.programConfigurations.get(n.id);let Ct=!1;if(M&&pt.imageAtlas){const mi=pt.imageAtlas,Qi=u.cD.from(M),Ot=Qi.getPrimary().scaleSelf(u.r.devicePixelRatio).toString(),$t=Qi.getSecondary(),Mt=mi.patternPositions.get(Ot),Ii=$t?mi.patternPositions.get($t.scaleSelf(u.r.devicePixelRatio).toString()):null;Ct=!!Mt&&!!Ii,Mt&&Pt.setConstantPatternPositions(Mt,Ii)}I>0&&(Ct||Pt.getPatternTransitionVertexBuffer("fill-extrusion-pattern"))&&De.push("FILL_EXTRUSION_PATTERN_TRANSITION");const Ut=s.getOrCreateProgram(at,{config:Pt,defines:kt?Ke:De,overrideFog:gt});if(s.terrain&&s.terrain.setupElevationDraw(pt,Ut,{useMeterToDem:!0}),!Lt.centroidVertexBuffer){const mi=Ut.getAttributeLocation(w,"a_centroid_pos");mi!==-1&&w.vertexAttribI4ui(mi,0,0,0,0)}!Be&&Ge&&Ge.setupShadows(pt.tileID.toUnwrapped(),Ut,"vector-tile"),D&&(s.context.activeTexture.set(w.TEXTURE0),pt.imageAtlasTexture&&pt.imageAtlasTexture.bind(w.LINEAR,w.CLAMP_TO_EDGE),Pt.updatePaintBuffers());const oi=n.paint.get("fill-extrusion-vertical-gradient"),Ci=1/Lt.tileToMeter;let hi;if(Be&&Ge){if(fc(pt.tileID,Lt.maxHeight,s))continue;const mi=Ge.calculateShadowPassMatrixFromTile(pt.tileID.toUnwrapped());hi=fm(mi,te,Ci,be,Ve,ye)}else{const mi=s.translatePosMatrix(bt.expandedProjMatrix,pt,n.paint.get("fill-extrusion-translate"),n.paint.get("fill-extrusion-translate-anchor")),Qi=S.projection.createInversionMatrix(S,bt.canonical),Ot=Ut.fixedDefines.includes("LIGHTING_3D_MODE");hi=D?qg(mi,s,oi,L,$,te,Ci,bt,pt,ee,Ve,ye,K,Q,Qi,de,be,I,Ot):Zc(mi,s,oi,L,$,te,Ci,bt,ee,Ve,ye,K,Q,Qi,de,be,fe,ot,Fe,Ot)}s.uploadCommonUniforms(x,Ut,bt.toUnwrapped(),null,Ae);let Kt=Lt.segments;if(S.projection.name==="mercator"&&!Be&&(Kt=Lt.getVisibleSegments(pt.tileID,s.terrain,s.transform.getFrustum(0)),!Kt.get().length))continue;if(ut)if(Be)for(const mi of Kt.get())ut.numRenderedVerticesInShadowPass+=mi.primitiveLength;else for(const mi of Kt.get())ut.numRenderedVerticesInTransparentPass+=mi.primitiveLength;const Ei=[];(s.terrain||g)&&Ei.push(Lt.centroidVertexBuffer),le&&Ei.push(Lt.layoutVertexExtBuffer),Te&&Ei.push(Lt.wallVertexBuffer),Ut.draw(s,x.gl.TRIANGLES,d,p,m,tt,hi,n.id,Lt.layoutVertexBuffer,Lt.indexBuffer,Kt,n.paint,s.transform.zoom,Pt,Ei)}s.shadowRenderer&&(s.shadowRenderer.useNormalOffset=!1)}class uh{constructor(){this.translate=[0,0],this.translateAnchor="map",this.edgeRadius=0,this.cutoffFadeRange=0}}function iu(s,t,n){if(!(t[2]<1)||n)return[0,0,1];const l=180*s/Math.PI;if(l<15)return[-.5,t[1],t[2]];const d=Math.min(1,Math.max(0,(l-15)/5)),p=d*d*(3-2*d);return[-.5*(1-p)+t[0]*p,t[1],t[2]]}function nf(s,t,n,l,d,p,m){l.centroidVertexArray.length===0&&l.createCentroidsBuffer();const g=p?p.findDEMTileFor(n):null;if(!(g&&g.dem||m))return;p&&g&&g.dem&&l.selfDEMTileTimestamp!==g.dem._timestamp&&(l.borderDoneWithNeighborZ=[-1,-1,-1,-1],l.selfDEMTileTimestamp=g.dem._timestamp);const x=(B,$)=>{(B.flags|$.flags)&u.cE?(B.flags|=u.cE,$.flags|=u.cE):(B.flags&=~u.cE,$.flags&=~u.cE)},w=B=>new u.P(Math.ceil((B+u.cF)*u.cG),0),S=(B,$,Z)=>{const G=Math.ceil((B+u.cF)*u.cG),te=Math.floor(Math.max(0,Math.min(u.aj-1,Z))/4);return new u.P(G,te<<5|(3&$)<<3|7)},A=B=>{const $=t.getSource().minzoom,Z=te=>{const ee=t.getTileByID(te);if(ee&&ee.hasData())return ee.getBucket(d)},G=[0,-1,1];for(const te of G){if(B.overscaledZ+te<$)continue;const ee=Z(B.calculateScaledKey(B.overscaledZ+te));if(ee)return ee}},I=[0,0,0],M=(B,$)=>(I[0]=Math.min(B.min.y,$.min.y),I[1]=Math.max(B.max.y,$.max.y),I[2]=u.aj-$.min.x>B.max.x?$.min.x-u.aj:B.max.x,I),D=(B,$)=>(I[0]=Math.min(B.min.x,$.min.x),I[1]=Math.max(B.max.x,$.max.x),I[2]=u.aj-$.min.y>B.max.y?$.min.y-u.aj:B.max.y,I),L=[(B,$)=>M(B,$),(B,$)=>M($,B),(B,$)=>D(B,$),(B,$)=>D($,B)],k=(B,$,Z,G,te,ee,le)=>{if(!p)return 0;const K=[[ee?Z:B,ee?B:Z,0],[ee?Z:$,ee?$:Z,0]],Q=le<0?u.aj+le:le,ae=[ee?Q:(B+$)/2,ee?(B+$)/2:Q,0];return Z===0&&le<0||Z!==0&&le>0?p.getForTilePoints(te,[ae],!0,G):K.push(ae),p.getForTilePoints(n,K,!0,g),Math.max(K[0][2],K[1][2],ae[2])/p.exaggeration()};for(let B=0;B<4;B++){const $=l.borderFeatureIndices[B];if($.length===0)continue;const Z=u.c0[B](n),G=A(Z);if(!(G&&G instanceof u.cB))continue;const te=p?p.findDEMTileFor(Z):null;if(!(te&&te.dem||m)||(p&&te&&te.dem&&l.borderDEMTileTimestamp[B]!==te.dem._timestamp&&(l.borderDoneWithNeighborZ[B]=-1,l.borderDEMTileTimestamp[B]=te.dem._timestamp),l.borderDoneWithNeighborZ[B]===G.canonical.z))continue;G.centroidVertexArray.length===0&&G.createCentroidsBuffer();const ee=(B<2?1:5)-B,le=G.borderDoneWithNeighborZ[ee]!==l.canonical.z,K=G.borderFeatureIndices[ee];let Q=0;if(l.canonical.z!==G.canonical.z){for(const be of $)l.showCentroid(l.featuresOnBorder[be]);if(le)for(const be of K)G.showCentroid(G.featuresOnBorder[be]);l.borderDoneWithNeighborZ[B]=G.canonical.z,G.borderDoneWithNeighborZ[ee]=l.canonical.z;continue}const ae=new Map,de=new Set,fe=new Set;for(let be=0;be<K.length;be++){const Te=G.featuresOnBorder[K[be]];Te.buildingId!==void 0&&ae.set(Te.buildingId,be)}for(const be of $){const Te=l.featuresOnBorder[be],Ve=l.centroidData.get(Te.centroidDataIndex);if(Te.buildingId===void 0)continue;const ye=ae.get(Te.buildingId);if(ye===void 0)continue;const Ae=G.featuresOnBorder[K[ye]],ge=G.centroidData.get(Ae.centroidDataIndex);de.add(be),fe.add(ye),m&&x(Ve,ge);const Fe=Ve.groupCentroidPos.x!==0||Ve.groupCentroidPos.y!==0?Ve.groupCentroidPos:Te.centroid(),Re=ge.groupCentroidPos.x!==0||ge.groupCentroidPos.y!==0?ge.groupCentroidPos:Ae.centroid(),De=B<2?Math.round((Fe.y+Re.y)/2):Math.round((Fe.x+Re.x)/2),Ke=Te.intersectsCount()>1||Ae.intersectsCount()>1;{let Be=0;if(te&&te.dem&&!Ke){const Ge=L[B](Ve,ge),Ze=B%2?u.aj-1:0;Be=k(Ge[0],Math.min(u.aj-1,Ge[1]),Ze,te,Z,B<2,Ge[2])}Ve.centroidXY=S(Be,B,De),ge.centroidXY=S(Be,ee,De)}if(l.writeCentroidToBuffer(Ve),G.writeCentroidToBuffer(ge),Te.buildingId!==void 0){for(const Be of l.centroidData)Be.buildingId===Te.buildingId&&Be!==Ve&&(Be.centroidXY=Ve.centroidXY,l.writeCentroidToBuffer(Be));for(const Be of G.centroidData)Be.buildingId===Te.buildingId&&Be!==ge&&(Be.centroidXY=ge.centroidXY,G.writeCentroidToBuffer(Be))}}for(const be of $){if(de.has(be))continue;const Te=l.featuresOnBorder[be],Ve=l.centroidData.get(Te.centroidDataIndex),ye=Te.borders[B];let Ae;for(;Q<K.length;){if(fe.has(Q)){Q++;continue}Ae=G.featuresOnBorder[K[Q]];const ge=Ae.borders[ee];if(ge[1]>ye[0]+3||ge[0]>ye[0]-3)break;G.showCentroid(Ae),Q++}if(Ae&&Q<K.length){let ge=Q,Fe=0;for(;;)if(fe.has(Q)){if(++Q===K.length)break;Ae=G.featuresOnBorder[K[Q]]}else{if(Ae.borders[ee][0]>ye[1]-3||(Fe++,++Q===K.length))break;Ae=G.featuresOnBorder[K[Q]]}for(;ge<K.length&&fe.has(ge);)ge++;if(ge>=K.length){l.showCentroid(Te);continue}Ae=G.featuresOnBorder[K[ge]];let Re=!1;if(Fe>=1){const Be=Ae.borders[ee];Math.abs(ye[0]-Be[0])<3&&Math.abs(ye[1]-Be[1])<3&&(Fe=1,Re=!0,Q=ge+1)}else if(Fe===0){l.showCentroid(Te);continue}const De=G.centroidData.get(Ae.centroidDataIndex);m&&Re&&x(Ve,De);const Ke=Te.intersectsCount()>1||Ae.intersectsCount()>1;if(Fe>1)Q=ge,Ve.centroidXY=De.centroidXY=new u.P(0,0);else if(te&&te.dem&&!Ke){const Be=L[B](Ve,De),Ge=B%2?u.aj-1:0,Ze=k(Be[0],Math.min(u.aj-1,Be[1]),Ge,te,Z,B<2,Be[2]);Ve.centroidXY=De.centroidXY=w(Ze)}else Ke?Ve.centroidXY=De.centroidXY=new u.P(0,0):(Ve.centroidXY=l.encodeBorderCentroid(Te),De.centroidXY=G.encodeBorderCentroid(Ae));l.writeCentroidToBuffer(Ve),G.writeCentroidToBuffer(De)}else l.showCentroid(Te)}l.borderDoneWithNeighborZ[B]=G.canonical.z,G.borderDoneWithNeighborZ[ee]=l.canonical.z}(l.needsCentroidUpdate||!l.centroidVertexBuffer&&l.centroidVertexArray.length!==0)&&l.uploadCentroid(s)}const Cm=[1,0,0],Mm=[0,1,0],Kg=[0,0,1];function fc(s,t,n){const l=n.transform,d=n.shadowRenderer;if(!d)return!0;const p=n.frameCounter,m=n.currentShadowCascade;let g=n._shadowCullCache;if(!g||g.frame!==p||g.cascade!==m){const B=l.tileSize*d._cascades[m].scale,$=l.scaleZoom(B),Z=d.shadowDirection,G=[Z[0],Z[1],-Z[2]],te=[Cm,Mm,Kg,G,[G[0],0,G[2]],[0,G[1],G[2]]];g={frame:p,cascade:m,cameraFrustum:u.bs.fromInvProjectionMatrix(l.invProjMatrix,l.worldSize,$,l.projection.name!=="globe"),edges:te,shadowDir:G,ws:B,zoom:$},n._shadowCullCache=g}const{cameraFrustum:x,edges:w,shadowDir:S,ws:A,zoom:I}=g;let M=t;if(l.elevation){const B=l.elevation.getMinMaxForTile(s);B&&(M+=B.max)}M/=u.cc(l.center.lat,I);const D=d.computeSimplifiedTileShadowVolume(s.toUnwrapped(),M,A,S);if(!D)return!1;const{vertices:L,planes:k}=D;return x.intersectsPrecise(L,k,w)===0||d.getCurrentCascadeFrustum().intersectsPrecise(L,k,w)===0}const pc=new Float32Array(16),vl=new Float32Array(16);function Gn(s){const{painter:t,source:n,layer:l,coords:d}=s;let p=s.defines;const m=t.context,g=t.renderPass==="shadow",x=t.renderPass==="light-beam",w=t.shadowRenderer,S=u.cc(t.transform.center.lat,t.transform.zoom),A=Oo(t,l.paint.get("building-cutoff-fade-range"));A.shouldRenderCutoff&&(p=p.concat("RENDER_CUTOFF"));const I=l.paint.get("building-front-cutoff"),M=I[2]<1&&!t.terrain,D=iu(t.transform.pitch,I,!!t.terrain);M&&(p=p.concat("RENDER_FRONT_CUTOFF"),t.maxFrontCutoffRawStart=Math.max(t.maxFrontCutoffRawStart,I[0])),s.floodLightIntensity>0&&(p=p.concat("FLOOD_LIGHT"));for(const L of d){const k=n.getTile(L),B=k.getBucket(l);if(!B)continue;w&&w.getMaxCascadeForTile(L.toUnwrapped())===0&&(p=p.concat("SHADOWS_SINGLE_CASCADE"));const $=B.programConfigurations.get(l.id);let Z,G;const te=t.translatePosMatrix(L.expandedProjMatrix,k,[0,0],"map");u.bL(pc,te,[1,1,s.verticalScale]);const ee=pc;let le;if(g&&w){if(fc(k.tileID,B.maxHeight*S,t))continue;const Q=w.calculateShadowPassMatrixFromTile(k.tileID.toUnwrapped());u.bL(Q,Q,[1,1,s.verticalScale]),le=um(Q),Z=G=t.getOrCreateProgram("buildingDepth",{config:$,defines:p,overrideFog:!1})}else if(x)Z=G=t.getOrCreateProgram("buildingBloom",{config:$,defines:p,overrideFog:!1}),le=ai(ee);else{const Q=t.transform.calculatePosMatrix(L.toUnwrapped(),t.transform.worldSize);u.bL(Q,Q,[1,1,s.verticalScale]),u.bL(vl,Q,[1,-1,1/S]),u.aE(vl,vl),u.cl(vl,vl);const ae=vl,de=t.transform.getFreeCameraOptions().position,fe=1<<L.canonical.z;if(le=cm(ee,ae,s.opacity,s.facadeAOIntensity,[((de.x-L.wrap)*fe-L.canonical.x)*u.aj,(de.y*fe-L.canonical.y)*u.aj,de.z*fe*u.aj],B.tileToMeter,s.facadeEmissiveChance,s.floodLightColor,s.floodLightIntensity,D),G=t.getOrCreateProgram("building",{config:$,defines:p,overrideFog:!1}),s.depthOnly===!0)Z=G;else{const be=p.concat(["BUILDING_FAUX_FACADE","HAS_ATTRIBUTE_a_faux_facade_color_emissive"]);Z=t.getOrCreateProgram("building",{config:$,defines:be,overrideFog:!1})}
vendor: 4,213 bytes, line 3089
3089w&&(w.setupShadowsFromMatrix(Q,G,!0),Z!==G&&Z.setShadowUniformValues(m,w.getShadowUniformValues()))}const K=(Q,ae)=>{if(x){const de=Q.entranceBloom;ae.draw(t,m.gl.TRIANGLES,s.depthMode,mt.disabled,s.blendMode,_t.disabled,le,l.id,de.layoutVertexBuffer,de.indexBuffer,de.segmentsBucket,l.paint,t.transform.zoom,$,[de.layoutAttenuationBuffer,de.layoutColorBuffer])}else{const de=Q.segmentsBucket;let fe=[Q.layoutNormalBuffer,Q.layoutCentroidBuffer,Q.layoutColorBuffer,Q.layoutFloodLightDataBuffer];Q.layoutFacadePaintBuffer&&(fe=fe.concat([Q.layoutFacadeDataBuffer,Q.layoutFacadeVerticalRangeBuffer,Q.layoutFacadePaintBuffer])),ae.draw(t,m.gl.TRIANGLES,s.depthMode,mt.disabled,s.blendMode,g?_t.disabled:_t.backCW,le,l.id,Q.layoutVertexBuffer,Q.indexBuffer,de,l.paint,t.transform.zoom,$,fe)}};t.uploadCommonUniforms(m,G,L.toUnwrapped(),null,A),B.buildingWithoutFacade&&K(B.buildingWithoutFacade,G),B.buildingWithFacade&&(Z!==G&&t.uploadCommonUniforms(m,Z,L.toUnwrapped(),null,A),K(B.buildingWithFacade,Z))}}function hh(s,t,n,l,d,p,m,g,x,w,S,A,I,M){const D=s.context.gl,L=s.depthModeForSublayer(1,ct.ReadOnly,D.LEQUAL,!0),k=u.ai(.1,3,S),B=s._showOverdrawInspector,$=A,Z=new uh;B||Tr(Z,s,t,n,l,L,new mt({func:D.ALWAYS,mask:255},255,255,D.KEEP,D.KEEP,D.REPLACE),new yt([D.ONE,D.ONE,D.ONE,D.ONE],u.C.transparent,[!1,!1,!1,!0],D.MIN),_t.disabled,d,"sdf",p,m,g,x,w,k,$,!1,void 0);{const G=B?mt.disabled:new mt({func:D.EQUAL,mask:255},255,255,D.KEEP,D.DECR,D.DECR),te=B?s.colorModeForRenderPass():new yt([D.ONE_MINUS_DST_ALPHA,D.DST_ALPHA,D.ONE,D.ONE],u.C.transparent,[!0,!0,!0,!0]);Tr(Z,s,t,n,l,L,G,te,_t.disabled,d,"color",p,m,g,x,w,k,$,!1,void 0)}}class dh{constructor(){this._previousClosestBuildingId=null,this._hysteresisRatio=.8,this._indoorMinimumZoom=16}findClosestBuilding(t,n,l,d,p){if(l<this._indoorMinimumZoom)return this._previousClosestBuildingId=null,null;let m=null,g=Number.MAX_VALUE,x=Number.MAX_VALUE,w=!1;const S=this._previousClosestBuildingId?t[this._previousClosestBuildingId]:null;this._previousClosestBuildingId&&S&&this._isBuildingVisible(S,d,p)&&(w=!0,x=this._calculateDistance(n,S));for(const[A,I]of Object.entries(t)){if(!this._isBuildingVisible(I,d,p))continue;const M=this._calculateDistance(n,I);M<g&&(g=M,m=A)}return w&&m&&this._previousClosestBuildingId&&m!==this._previousClosestBuildingId?g>x*this._hysteresisRatio&&(m=this._previousClosestBuildingId):w&&!m&&(m=this._previousClosestBuildingId),this._previousClosestBuildingId=m,m}_calculateDistance(t,n){if(!n.center)return Number.MAX_VALUE;const l=t.lat-n.center[1],d=t.lng-n.center[0];return l*l+d*d}_isBuildingVisible(t,n,l){if(!l)return!1;for(const d of t.floorIds){const p=t.floors[d];if(!p.geometry)continue;const m=p.geometry;if(m.type==="Polygon"){const g=this._convertRingToPoints(m.coordinates[0]);if(u.cJ(g,l))return!0}else if(m.type==="MultiPolygon"){const g=this._convertMultiPolygonToPoints(m.coordinates);if(u.cK(l,g))return!0}}return!1}_convertRingToPoints(t){return t.map(n=>new u.P(n[0],n[1]))}_convertMultiPolygonToPoints(t){return t.map(n=>n.length===0?[]:n[0].map(l=>new u.P(l[0],l[1])))}}const mc=.05,fh=(s,t,n,l,d,p,m,g,x,w,S,A)=>({u_matrix:s,u_normalize_matrix:t,u_globe_matrix:n,u_merc_matrix:l,u_grid_matrix:d,u_tl_parent:p,u_scale_parent:w,u_fade_t:S.mix,u_opacity:S.opacity,u_image0:0,u_image1:1,u_raster_elevation:A,u_zoom_transition:m,u_merc_center:g,u_cutoff_params:x}),of=(s,t,n,l,d,p,m,g,x,w)=>({u_particle_texture:s,u_particle_texture_side_len:t,u_tile_offset:n,u_velocity:l,u_color_ramp:p,u_velocity_res:d,u_max_speed:m,u_uv_offset:g,u_data_scale:[255*x[0],255*x[1]],u_data_offset:w,u_particle_pos_scale:1.1,u_particle_pos_offset:[mc,mc]}),sf=(s,t,n,l,d,p,m,g,x,w)=>({u_particle_texture:s,u_particle_texture_side_len:t,u_velocity:n,u_velocity_res:l,u_max_speed:d,u_speed_factor:p,u_reset_rate:m,u_rand_seed:Math.random(),u_uv_offset:g,u_data_scale:[255*x[0],255*x[1]],u_data_offset:w,u_particle_pos_scale:1.1,u_particle_pos_offset:[mc,mc]});function ph(s,[t,n,l,d],[p,m]){if(p===m)return[0,0,0,0];const g=255*(s-1)/(s*(m-p));return[t*g,n*g,l*g,d*g]}function ru(s,t,[n,l]){return n===l?0:.5/s+(t-n)*(s-1)/(s*(l-n))}function mh(s,t){const n={};if(!t)return n;for(const l of s){const d=l.layerIds.map(p=>
vendor: 38,562 bytes, lines 3089-3112
3089t.getLayer(p)).filter(Boolean);if(d.length!==0){l.layers=d,l.stateDependentLayerIds&&(l.stateDependentLayers=l.stateDependentLayerIds.map(p=>d.filter(m=>m.id===p)[0])),l.updateExpressions&&l.updateExpressions(d);for(const p of d)n[p.fqid]=l}}return n}const _o=32,ko=33,Ws=new Uint16Array(8184);for(let s=0;s<2046;s++){let t=s+2,n=0,l=0,d=0,p=0,m=0,g=0;for(1&t?d=p=m=_o:n=l=g=_o;(t>>=1)>1;){const w=n+d>>1,S=l+p>>1;1&t?(d=n,p=l,n=m,l=g):(n=d,l=p,d=m,p=g),m=w,g=S}const x=4*s;Ws[x+0]=n,Ws[x+1]=l,Ws[x+2]=d,Ws[x+3]=p}const Is=new Uint16Array(2178),fa=new Uint8Array(1089),pa=new Uint16Array(1089);function Pm(s){return s===0?-.03125:s===32?.03125:0}var _h=u.cR([{name:"a_pos",type:"Int16",components:2},{name:"a_texture_pos",type:"Uint16",components:2}]);const Rm={type:2,extent:u.aj,loadGeometry:()=>[[new u.P(0,0),new u.P(u.aj+1,0),new u.P(u.aj+1,u.aj+1),new u.P(0,u.aj+1),new u.P(0,0)]]};let Jg=0;class _c{constructor(t,n,l,d,p,m){this.tileID=t,this.uid=u.am(),this.uses=0,this.tileSize=n,this.tileZoom=l,this.buckets={},this.expirationTime=null,this.queryPadding=0,this.hasSymbolBuckets=!1,this.hasTunnelGeometry=!1,this.hasRTLText=!1,this.dependencies={},this.isRaster=p,d&&d.style&&(this._lastUpdatedBrightness=d.style.getBrightness()),this._lastAvailableImagesCount=0,this._firstPrepareComplete=!1,this.expiredRequestCount=0,this.state="loading",d&&d.transform&&(this.projection=d.transform.projection),this.worldview=m,this._hasAppearances=null}registerFadeDuration(t){const n=t+this.timeAdded;n<u.r.now()||this.fadeEndTime!==void 0&&n<this.fadeEndTime||(this.fadeEndTime=n)}wasRequested(){return this.state==="errored"||this.state==="loaded"||this.state==="reloading"}get tileTransform(){return this._tileTransform||(this._tileTransform=u.cO(this.tileID.canonical,this.projection)),this._tileTransform}loadVectorData(t,n,l){if(this.unloadVectorData(),this.state="loaded",t){t.featureIndex&&(this.latestFeatureIndex=t.featureIndex,t.rawTileData?(this.latestRawTileData=t.rawTileData,this.latestFeatureIndex.rawTileData=t.rawTileData):this.latestRawTileData&&(this.latestFeatureIndex.rawTileData=this.latestRawTileData)),this.collisionBoxArray=t.collisionBoxArray,this.buckets=mh(t.buckets,n.style),t.frcCoveragePolygons&&t.frcCoveragePolygons.length>0&&(this.frcCoveragePolygons=t.frcCoveragePolygons),this.hasDeferredRoadStructure=!!t.hasDeferredRoadStructure,t.parsedElevationFeatures!==void 0&&(this.parsedElevationFeatures=t.parsedElevationFeatures,this.parsedElevationGeneration=++Jg),this.hasDeferredElevationFeatures=!!t.hasDeferredElevationFeatures,this.hasSymbolBuckets=!1,this.hasTunnelGeometry=!!t.hasTunnelGeometry;for(const d in this.buckets){const p=this.buckets[d];if(p instanceof u.cT){if(this.hasSymbolBuckets=!0,!l)break;p.justReloaded=!0}}if(this.hasRTLText=!1,this.hasSymbolBuckets)for(const d in this.buckets){const p=this.buckets[d];if(p instanceof u.cT&&p.hasRTLText){this.hasRTLText=!0,u.cU();break}}this.queryPadding=0;for(const d in this.buckets){const p=this.buckets[d],m=n.style.getOwnLayer(d);if(!m)continue;const g=m.queryRadius(p)||0;this.queryPadding=Math.max(this.queryPadding,g)}t.imageAtlas&&(this.imageAtlas=n.style.imageManager.imageAtlasCache.getOrCache(t.imageAtlas)),t.glyphAtlasImage&&(this.glyphAtlasImage=t.glyphAtlasImage),t.lineAtlas&&(this.lineAtlas=t.lineAtlas),this._lastUpdatedBrightness=t.brightness}else this.collisionBoxArray=new u.cS}unloadVectorData(){if(this.hasData()){for(const t in this.buckets)this.buckets[t].destroy();this.buckets={},this.imageAtlas&&(this.imageAtlas=null),this.lineAtlas&&(this.lineAtlas=null),this.imageAtlasTexture&&(this.imageAtlasTexture=null),this.glyphAtlasTexture&&this.glyphAtlasTexture.destroy(),this.lineAtlasTexture&&this.lineAtlasTexture.destroy(),this._tileBoundsBuffer&&(this._tileBoundsBuffer.destroy(),this._tileBoundsIndexBuffer.destroy(),this._tileBoundsSegments.destroy(),this._tileBoundsBuffer=null),this._tileDebugBuffer&&(this._tileDebugBuffer.destroy(),this._tileDebugSegments.destroy(),this._tileDebugBuffer=null),this._tileDebugIndexBuffer&&(this._tileDebugIndexBuffer.destroy(),this._tileDebugIndexBuffer=null),this._globeTileDebugBorderBuffer&&(this._globeTileDebugBorderBuffer.destroy(),this._globeTileDebugBorderBuffer=null),this._tileDebugTextBuffer&&(this._tileDebugTextBuffer.destroy(),this._tileDebugTextSegments.destroy(),this._tileDebugTextIndexBuffer.destroy(),this._tileDebugTextBuffer=null),this._globeTileDebugTextBuffer&&(this._globeTileDebugTextBuffer.destroy(),this._globeTileDebugTextBuffer=null),this.latestFeatureIndex=null,this.state="unloaded"}}loadModelData(t,n,l){t&&(t.resourceTiming&&(this.resourceTiming=t.resourceTiming),this.buckets={...this.buckets,...mh(t.buckets,n.style)},t.featureIndex&&(this.latestFeatureIndex=t.featureIndex))}getBucket(t){return this.buckets[t.fqid]}upload(t,n){for(const p in this.buckets){const m=this.buckets[p];if(m.uploadPending()){let g={},x=[],w={zoom:0,pitch:0,brightness:0,worldview:""};if(n){if(n.style){x=n.style.listImages();const S=m.layers[0],A=S.sourceLayer||"_geojsonTileLayer",I=n.style.getLayerSourceCache(S);I&&(g=I._state.getState(A,void 0))}w={zoom:n.transform.zoom||0,pitch:n.transform.pitch||0,brightness:n.style.getBrightness()||0,worldview:n.worldview||""}}m.upload(t,this.tileID.canonical,g,x,w)}}const l=t.gl,d=this.imageAtlas;d&&n&&(this.imageAtlasTexture=n.style.imageManager.imageAtlasCache.getTextureForAtlas(d,t,l.RGBA8),d.uploaded=!0),this.glyphAtlasImage&&(this.glyphAtlasTexture=new u.T(t,this.glyphAtlasImage,l.R8),this.glyphAtlasImage=null),this.lineAtlas&&!this.lineAtlas.uploaded&&(this.lineAtlasTexture=new u.T(t,this.lineAtlas.image,l.R8),this.lineAtlas.uploaded=!0)}prepare(t,n,l){if(this.imageAtlas&&this.imageAtlasTexture&&n){const I=n.style.getLut(l);this.imageAtlas.patchUpdatedImages(t,this.imageAtlasTexture,l,I)}if(!n||!this.latestFeatureIndex||!this.latestFeatureIndex.rawTileData)return;const d=n.style.getBrightness(),p=n.style.listImages(),m=p.length,g=n.style._changes.getUpdatedPaintProperties(),x=Object.keys(this.buckets).some(I=>this.buckets[I].layers.some(M=>g.has(M.fqid))),w=Object.keys(this.buckets).some(I=>this.buckets[I].layers.some(M=>M.hasTransition&&M.hasTransition())),S=this._firstPrepareComplete&&m!==this._lastAvailableImagesCount;this._hasAppearances===null&&(this._hasAppearances=this.hasAppearances(n));const A=this._lastUpdatedBrightness!==d;this._lastAvailableImagesCount=m,this._firstPrepareComplete=!0,(this._lastUpdatedBrightness||d||this._hasAppearances||x||w||S)&&(!(this._hasAppearances||x||w||S)&&this._lastUpdatedBrightness&&d&&Math.abs(this._lastUpdatedBrightness-d)<.001||(this.updateBuckets(n,A,void 0,S||x||w,g,p),this._lastUpdatedBrightness=d))}evaluateQueryRenderedFeaturePadding(){let t=0;for(const n in this.buckets){const l=this.buckets[n];l.evaluateQueryRenderedFeaturePadding&&(t=Math.max(t,l.evaluateQueryRenderedFeaturePadding()))}return t}queryRenderedFeatures(t,n,l,d,p,m,g){if(!this.latestFeatureIndex||!this.latestFeatureIndex.rawTileData&&!this.latestFeatureIndex.is3DTile)return{};const x=this.evaluateQueryRenderedFeaturePadding(),w=(function(S,A){const I=u.aF([],[.5*S.width,.5*-S.height,1]);return u.aG(I,I,[1,-1,0]),u.aP(I,I,S.calculateProjMatrix(A.toUnwrapped())),Float32Array.from(I)})(p,this.tileID);return this.latestFeatureIndex.query(t,{tilespaceGeometry:n,pixelPosMatrix:w,transform:d,availableImages:l,tileTransform:this.tileTransform,worldview:this.worldview,queryRadius:x,scope:g})}querySourceFeatures(t,n){const l=this.latestFeatureIndex;if(!l||!l.rawTileData)return;const d=l.loadVTLayers(),p=n?n.sourceLayer:"",m=d._geojsonTileLayer||d[p];if(!m)return;const g=u.cV(n&&n.filter),{z:x,x:w,y:S}=this.tileID.canonical,A={z:x,x:w,y:S};for(let I=0;I<m.length;I++){const M=m.feature(I);if(g.needGeometry){const k=u.cW(M,!0);if(!g.filter(new u.aa(this.tileID.overscaledZ,{worldview:this.worldview}),k,this.tileID.canonical))continue}else if(!g.filter(new u.aa(this.tileID.overscaledZ,{worldview:this.worldview}),M))continue;const D=l.getId(M,p),L=new u.cX(M,x,w,S,D);L.tile=A,t.push(L)}}loaded(){return this.state==="loaded"||this.state==="errored"}hasData(){return this.state==="loaded"||this.state==="reloading"||this.state==="expired"}patternsLoaded(){return!!this.imageAtlas&&!!this.imageAtlas.patternPositions.size}setExpiryData(t){const n=this.expirationTime;if(t.cacheControl){const l=u.cY(t.cacheControl);l["max-age"]&&(this.expirationTime=Date.now()+1e3*l["max-age"])}else t.expires&&(this.expirationTime=new Date(t.expires).getTime());if(this.expirationTime){const l=Date.now();let d=!1;if(this.expirationTime>l)d=!1;else if(n)if(this.expirationTime<n)d=!0;else{const p=this.expirationTime-n;p?this.expirationTime=l+Math.max(p,3e4):d=!0}else d=!0;d?(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-Date.now(),Math.pow(2,31)-1)}refreshFeatureState(t,n){if(!this.latestFeatureIndex||!this.latestFeatureIndex.rawTileData&&!this.latestFeatureIndex.is3DTile||!t)return;const l=t.style.listImages();this.updateBuckets(t,!1,n,void 0,void 0,l)}hasAppearances(t){for(const n in this.buckets)if(t.style.hasLayer(n)&&this.buckets[n].layers.some(l=>l.appearances&&l.appearances.length>0))return!0;return!1}updateBuckets(t,n,l,d,p,m){if(!this.latestFeatureIndex||!t.style)return;const g=m||t.style.listImages(),x=t.style.getBrightness(),w=p||new Set;for(const S in this.buckets){if(!t.style.hasLayer(S))continue;const A=this.buckets[S],I=A.layers[0],M=I.sourceLayer||"_geojsonTileLayer",D=t.style.getLayerSourceCache(I),L=A.layers.some(ee=>w.has(ee.fqid)),k=(d||L)&&A instanceof u.cT?t.style.getOwnLayer(S):void 0;let B=l&&l[M]||{};D&&!l&&(B=D._state.getState(M,void 0));const $=this.imageAtlas?Object.fromEntries(this.imageAtlas.patternPositions):{},Z=Object.keys(B).length>0&&!n;A.hasAppearances=A.layers.some(ee=>ee.appearances&&ee.appearances.length>0);const G=Z?A.stateDependentLayers:A.layers;if(Z&&A.stateDependentLayers.length!==0||n||L||d){const ee=this.latestFeatureIndex.loadVTLayers()[M];if(A.update(B,ee,g,$,G,n,x,this.tileID.canonical),(d||L)&&(!n||n&&A instanceof u.cT&&(!A.text.uboBinder||A.text.uboBinder.isLightConstant||!A.icon.uboBinder||A.icon.uboBinder.isLightConstant))&&A instanceof u.cT&&k&&k.type==="symbol"){const le=A;le.text&&le.text.uboBinder&&le.text.uboBinder.updateDynamicExpressions(k,ee,this.tileID.canonical,g,B,x),le.icon&&le.icon.uboBinder&&le.icon.uboBinder.updateDynamicExpressions(k,ee,this.tileID.canonical,g,B,x)}if(A instanceof u.cT){const le=A,K=t.context;le.text&&le.text.uboBinder&&le.text.uboBinder.upload(K),le.icon&&le.icon.uboBinder&&le.icon.uboBinder.upload(K)}}if(Z&&A.stateDependentLayers.length!==0||n||A.hasAppearances){const ee={zoom:t.transform.zoom,pitch:t.transform.pitch,brightness:t.style.getBrightness()||0,worldview:t.worldview},le=A.updateAppearances(this.tileID.canonical,B,g,ee,t.imageManager,Z&&A.stateDependentLayers.length!==0);if(le&&le.hasUboChanges){const K=t.context;A instanceof u.cT&&A.text&&A.text.uboBinder&&A.text.uboBinder.upload(K),A instanceof u.cT&&A.icon&&A.icon.uboBinder&&A.icon.uboBinder.upload(K)}}(A instanceof u.cZ||A instanceof u.c_)&&t._terrain&&t._terrain.enabled&&D&&A.uploadPending()&&t._terrain._clearRenderCacheForTile(D.id,this.tileID);const te=t&&t.style&&t.style.getOwnLayer(S);te&&(this.queryPadding=Math.max(this.queryPadding,te.queryRadius(A)||0))}}holdingForFade(){return this.symbolFadeHoldUntil!==void 0}symbolFadeFinished(){return!this.symbolFadeHoldUntil||this.symbolFadeHoldUntil<u.r.now()}clearFadeHold(){this.symbolFadeHoldUntil=void 0}setHoldDuration(t){this.symbolFadeHoldUntil=u.r.now()+t}setTexture(t,n){const l=n.context,d=l.gl;this.texture=this.texture||n.getTileTexture(t.width),this.texture&&this.texture instanceof u.T?this.texture.update(t):(this.texture=new u.T(l,t,d.RGBA8,{useMipmap:!0}),this.texture.bind(d.LINEAR,d.CLAMP_TO_EDGE))}setDependencies(t,n){const l={};for(const d of n)l[d]=!0;this.dependencies[t]=l}hasDependency(t,n){for(const l of t){const d=this.dependencies[l];if(d){for(const p of n)if(d[p])return!0}}return!1}clearQueryDebugViz(){}_makeDebugTileBoundsBuffers(t,n){if(!n||n.name==="mercator"||this._tileDebugBuffer)return;const l=u.c$(Rm,this.tileID.canonical,this.tileTransform)[0],d=new u.co,p=new u.d0;for(let m=0;m<l.length;m++){const{x:g,y:x}=l[m];d.emplaceBack(g,x),p.emplaceBack(m)}p.emplaceBack(0),this._tileDebugIndexBuffer=t.createIndexBuffer(p),this._tileDebugBuffer=t.createVertexBuffer(d,u.cq.members),this._tileDebugSegments=u.cr.simpleSegment(0,0,d.length,p.length)}_makeTileBoundsBuffers(t,n){if(this._tileBoundsBuffer||!n||n.name==="mercator")return;const l=u.c$(Rm,this.tileID.canonical,this.tileTransform)[0];let d,p;if(this.isRaster){const m=(function(g,x){const w=u.cO(g,x),S=Math.pow(2,g.z);for(let k=0;k<ko;k++)for(let B=0;B<ko;B++){const $=u.cP((g.x+(B+Pm(B))/_o)/S),Z=u.aM((g.y+(k+Pm(k))/_o)/S),G=x.project($,Z),te=k*ko+B;Is[2*te+0]=Math.round((G.x*w.scale-w.x)*u.aj),Is[2*te+1]=Math.round((G.y*w.scale-w.y)*u.aj)}fa.fill(0),pa.fill(0);for(let k=2045;k>=0;k--){const B=4*k,$=Ws[B+0],Z=Ws[B+1],G=Ws[B+2],te=Ws[B+3],ee=$+G>>1,le=Z+te>>1,K=ee+le-Z,Q=le+$-ee,ae=Z*ko+$,de=te*ko+G,fe=le*ko+ee,be=Math.hypot((Is[2*ae+0]+Is[2*de+0])/2-Is[2*fe+0],(Is[2*ae+1]+Is[2*de+1])/2-Is[2*fe+1])>=16;fa[fe]=fa[fe]||(be?1:0),k<1022&&(fa[fe]=fa[fe]||fa[(Z+Q>>1)*ko+($+K>>1)]||fa[(te+Q>>1)*ko+(G+K>>1)])}const A=new u.cQ,I=new u.cp;let M=0;function D(k,B){const $=B*ko+k;return pa[$]===0&&(A.emplaceBack(Is[2*$+0],Is[2*$+1],k*u.aj/_o,B*u.aj/_o),pa[$]=++M),pa[$]-1}function L(k,B,$,Z,G,te){const ee=k+$>>1,le=B+Z>>1;if(Math.abs(k-G)+Math.abs(B-te)>1&&fa[le*ko+ee])L(G,te,k,B,ee,le),L($,Z,G,te,ee,le);else{const K=D(k,B),Q=D($,Z),ae=D(G,te);I.emplaceBack(K,Q,ae)}}return L(0,0,_o,_o,_o,0),L(_o,_o,0,0,0,_o),{vertices:A,indices:I}})(this.tileID.canonical,n);d=m.vertices,p=m.indices}else{d=new u.cQ,p=new u.cp;for(const{x:g,y:x}of l)d.emplaceBack(g,x,0,0);const m=u.d1(d.int16.subarray(0,4*d.length),void 0,4);for(let g=0;g<m.length;g+=3)p.emplaceBack(m[g],m[g+1],m[g+2])}this._tileBoundsBuffer=t.createVertexBuffer(d,_h.members),this._tileBoundsIndexBuffer=t.createIndexBuffer(p),this._tileBoundsSegments=u.cr.simpleSegment(0,0,d.length,p.length)}_makeGlobeTileDebugBuffers(t,n){const l=n.projection;if(!l||l.name!=="globe"||n.freezeTileCoverage)return;const d=this.tileID.canonical,p=u.d2(d,n),m=u.d3(p),g=u.ah(n.zoom);let x;g>0&&(x=u.aE(new Float64Array(16),n.globeMatrix)),this._makeGlobeTileDebugBorderBuffer(t,d,n,m,x,g),this._makeGlobeTileDebugTextBuffer(t,d,n,m,x,g)}_globePoint(t,n,l,d,p,m,g){let x=u.d4(t,n,l);if(m){const w=1<<l.z,S=u.a_(d.center.lng),A=u.a$(d.center.lat),I=(l.x+.5)/w-S;let M=0;I>.5?M=-1:I<-.5&&(M=1);let D=(t/u.aj+l.x)/w+M,L=(n/u.aj+l.y)/w;D=(D-S)*d._pixelsPerMercatorPixel+S,L=(L-A)*d._pixelsPerMercatorPixel+A;const k=[D*d.worldSize,L*d.worldSize,0];u.ad(k,k,m),x=u.d5(x,k,g)}return u.ad(x,x,p)}_makeGlobeTileDebugBorderBuffer(t,n,l,d,p,m){const g=new u.co,x=new u.d0,w=new u.d6,S=(I,M,D,L,k)=>{const B=(D-I)/(k-1),$=(L-M)/(k-1),Z=g.length;for(let G=0;G<k;G++){const te=I+G*B,ee=M+G*$;g.emplaceBack(te,ee);const le=this._globePoint(te,ee,n,l,d,p,m);w.emplaceBack(le[0],le[1],le[2]),x.emplaceBack(Z+G)}},A=u.aj;S(0,0,A,0,16),S(A,0,A,A,16),S(A,A,0,A,16),S(0,A,0,0,16),this._tileDebugIndexBuffer=t.createIndexBuffer(x),this._tileDebugBuffer=t.createVertexBuffer(g,u.cq.members),this._globeTileDebugBorderBuffer=t.createVertexBuffer(w,u.d7.members),this._tileDebugSegments=u.cr.simpleSegment(0,0,g.length,x.length)}_makeGlobeTileDebugTextBuffer(t,n,l,d,p,m){const g=u.aj/4,x=new u.co,w=new u.cp,S=new u.d6,A=25;w.reserve(32),x.reserve(A),S.reserve(A);const I=(M,D)=>A*M+D;for(let M=0;M<A;M++){const D=M*g;for(let L=0;L<A;L++){const k=L*g;x.emplaceBack(k,D);const B=this._globePoint(k,D,n,l,d,p,m);S.emplaceBack(B[0],B[1],B[2])}}for(let M=0;M<4;M++)for(let D=0;D<4;D++){const L=I(M,D),k=I(M,D+1),B=I(M+1,D),$=I(M+1,D+1);w.emplaceBack(L,k,B),w.emplaceBack(B,k,$)}this._tileDebugTextIndexBuffer=t.createIndexBuffer(w),this._tileDebugTextBuffer=t.createVertexBuffer(x,u.cq.members),this._globeTileDebugTextBuffer=t.createVertexBuffer(S,u.d7.members),this._tileDebugTextSegments=u.cr.simpleSegment(0,0,A,32)}destroy(t=!0){for(const n in this.buckets)this.buckets[n].destroy(t);this.buckets={},this.imageAtlas&&(this.imageAtlas=null),this.lineAtlas&&(this.lineAtlas=null),this.imageAtlasTexture&&delete this.imageAtlasTexture,this.glyphAtlasTexture&&(this.glyphAtlasTexture.destroy(),delete this.glyphAtlasTexture),this.lineAtlasTexture&&(this.lineAtlasTexture.destroy(),delete this.lineAtlasTexture),this._tileBoundsBuffer&&(this._tileBoundsBuffer.destroy(),this._tileBoundsIndexBuffer.destroy(),this._tileBoundsSegments.destroy(),this._tileBoundsBuffer=null),this._tileDebugBuffer&&(this._tileDebugBuffer.destroy(),this._tileDebugSegments.destroy(),this._tileDebugBuffer=null),this._tileDebugIndexBuffer&&(this._tileDebugIndexBuffer.destroy(),this._tileDebugIndexBuffer=null),this._globeTileDebugBorderBuffer&&(this._globeTileDebugBorderBuffer.destroy(),this._globeTileDebugBorderBuffer=null),this._tileDebugTextBuffer&&(this._tileDebugTextBuffer.destroy(),this._tileDebugTextSegments.destroy(),this._tileDebugTextIndexBuffer.destroy(),this._tileDebugTextBuffer=null),this._globeTileDebugTextBuffer&&(this._globeTileDebugTextBuffer.destroy(),this._globeTileDebugTextBuffer=null),t&&this.texture&&this.texture instanceof u.T&&(this.texture.destroy(),delete this.texture),this.emissiveTexture&&this.emissiveTexture instanceof u.T&&(this.emissiveTexture.destroy(),delete this.emissiveTexture),this.hillshadeFBO&&(this.hillshadeFBO.destroy(),delete this.hillshadeFBO),this.dem&&delete this.dem,this.neighboringTiles&&delete this.neighboringTiles,this.demTexture&&(this.demTexture.destroy(),delete this.demTexture),this.rasterParticleState&&(this.rasterParticleState.destroy(),delete this.rasterParticleState),this.latestFeatureIndex=null,this.state="unloaded"}}u.d8.setPbf(u.d9);class af extends _c{constructor(t,n,l,d,p){super(t,n,l,d,p),this._workQueuePerLayer=new Map,this._fetchQueuePerLayer=new Map,this._taskQueue=new Map,this._isHeaderLoaded=!1,this.textureDescriptorPerLayer=new Map,this.texturePerLayer=new Map}getLayers(){return this._mrt?Object.values(this._mrt.layers):[]}getLayer(t){return this._mrt&&this._mrt.getLayer(t)}setTexturePerLayer(t,n,l){const d=l.context,p=d.gl;let m=this.texturePerLayer.get(t)||l.getTileTexture(n.width);m&&m instanceof u.T?m.update(n,{premultiply:!1}):m=new u.T(d,n,p.RGBA8,{premultiply:!1}),this.texturePerLayer.has(t)||this.texturePerLayer.set(t,m)}flushQueues(t){const n=this._workQueuePerLayer.get(t)||[],l=this._fetchQueuePerLayer.get(t)||[];for(;n.length;)n.pop()();for(;l.length;)l.pop()()}flushAllQueues(){for(const t of this._workQueuePerLayer.keys()){const n=this._workQueuePerLayer.get(t)||[];for(;n.length;)n.pop()()}for(const t of this._fetchQueuePerLayer.keys()){const n=this._fetchQueuePerLayer.get(t)||[];for(;n.length;)n.pop()()}}fetchHeader(t=16384,n){const l=this._mrt=new u.d8(30),d={...this.requestParams,headers:{Range:"bytes=0-"+(t-1)}};this.entireBuffer=null;const p=new AbortController;return this.request=p,u.da(d,p.signal).then(({data:m,headers:g})=>{try{const x=l.getHeaderLength(m);if(x>t)return void(this.request=this.fetchHeader(x,n));l.parseHeader(m),this._isHeaderLoaded=!0;let w=0;for(const S of Object.values(l.layers))w=Math.max(w,S.dataIndex.at(-1).lastByte);m.byteLength>=w&&(this.entireBuffer=m),n(null,this.entireBuffer||m,g)}catch(x){n(x)}}).catch(m=>{p.signal.aborted||n(m)}),this.request}fetchBandForRender(t,n,l,d){this.fetchBand(t,n,l,p=>{if(p)return void d(p);this.updateTextureDescriptor(t,n,l);const m=this.textureDescriptorPerLayer.get(n);d(null,m?m.img:null)})}fetchBand(t,n,l,d){const p=this._mrt;if(!this._isHeaderLoaded||!p)return void d(new Error("Tile header is not ready"));const m=this.actor;if(!m)return void d(new Error("Can't fetch tile band without an actor"));let g;const x=u.y(String(l),u.y(this.tileID.key,t));let w=this._taskQueue.get(x);w?w.add(d):(w=new Set,w.add(d),this._taskQueue.set(x,w));const S=(D,L)=>{g.complete(D,L),D?d(D):(w.forEach(k=>k(null,L)),this._taskQueue.delete(x))},A=(D,L)=>{if(D)return d(D);const k=m.sendCancelable("decodeRasterArray",{type:"raster-array",source:this.source,scope:this.scope,tileID:this.tileID,uid:this.uid,buffer:L,task:g},{},S);if(n!==null){const B=this._workQueuePerLayer.get(n)||[];B.push(()=>{k.abort(),g.cancel()}),this._workQueuePerLayer.has(n)||this._workQueuePerLayer.set(n,B)}};let I;try{I=p.getLayer(t)}catch(D){if(this.state==="reloading")return;throw D}if(!I)return void d(new Error(`Unknown sourceLayer "${t}"`));if(I.hasDataForBand(l))return w.forEach(D=>D(null,null)),void this._taskQueue.delete(x);const M=I.getDataRange([l]);if(g=p.createDecodingTask(M),!g||g.tasks.length)if(n!==null&&this.flushQueues(n),this.entireBuffer)A(null,this.entireBuffer.slice(M.firstByte,M.lastByte+1));else{const D={...this.requestParams,headers:{Range:`bytes=${M.firstByte}-${M.lastByte}`}},L=new AbortController;if(u.da(D,L.signal).then(({data:k})=>A(null,k)).catch(k=>{L.signal.aborted||A(k)}),n!==null){const k=this._fetchQueuePerLayer.get(n)||[];k.push(()=>{L.abort(),g.cancel()}),this._fetchQueuePerLayer.has(n)||this._fetchQueuePerLayer.set(n,k)}}}updateNeeded(t,n){return(!this.textureDescriptorPerLayer.get(t)||this.textureDescriptorPerLayer.get(t).band!==n||this.refreshedUponExpiration)&&this.state!=="errored"}updateTextureDescriptor(t,n,l){if(!this._mrt)return;const d=this._mrt.getLayer(t);if(!d||!d.hasBand(l)||!d.hasDataForBand(l))return;const{bytes:p,tileSize:m,buffer:g,offset:x,scale:w}=d.getBandView(l),S=m+2*g,A=new u.t({width:S,height:S},p),I=this.texturePerLayer.get(n);I&&I instanceof u.T&&I.update(A,{premultiply:!1}),this.textureDescriptorPerLayer.set(n,{layer:t,band:l,img:A,buffer:g,offset:x,tileSize:m,format:d.pixelFormat,mix:[w,256*w,65536*w,16777216*w]})}destroy(t=!1){if(super.destroy(t),delete this._mrt,!t)for(const n of this.texturePerLayer.values())n&&n instanceof u.T&&n.destroy();this.texturePerLayer.clear(),this.textureDescriptorPerLayer.clear(),this.fbo&&(this.fbo.destroy(),delete this.fbo),delete this.request,delete this.requestParams,this._isHeaderLoaded=!1}}function gh(s,t){const n=Math.pow(2,t.z),l=Math.floor(u.a_(s.getWest())*n),d=Math.floor(u.a$(s.getNorth())*n),p=Math.ceil(u.a_(s.getEast())*n),m=Math.ceil(u.a$(s.getSouth())*n);return t.x>=l&&t.x<p&&t.y>=d&&t.y<m}class Ba{constructor(t,n,l){this.bounds=t?u.bF.convert(this.validateBounds(t)):null,this.minzoom=n||0,this.maxzoom=l||24}validateBounds(t){return Array.isArray(t)&&t.length===4?[Math.max(-180,t[0]),Math.max(-90,t[1]),Math.min(180,t[2]),Math.min(90,t[3])]:[-180,-90,180,90]}addExtraBounds(t){if(t){this.extraBounds||(this.extraBounds=[]);for(const n of t)this.extraBounds.push(u.bF.convert(this.validateBounds(n)))}}contains(t){if(t.z>this.maxzoom||t.z<this.minzoom||this.bounds&&!gh(this.bounds,t))return!1;if(!this.extraBounds)return!0;for(const n of this.extraBounds)if(gh(n,t))return!0;return!1}static fromTileJSON(t){if(!t.bounds&&!t.extra_bounds)return null;const n=new Ba(t.bounds,t.minzoom,t.maxzoom);return n.addExtraBounds(t.extra_bounds),n}}class gc extends u.E{constructor(t,n,l,d){super(),this.id=t,this.dispatcher=l,this.setEventedParent(d),this.type="raster",this.minzoom=0,this.maxzoom=22,this.roundZoom=!0,this.scheme="xyz",this.tileSize=512,this._loaded=!1,this._options={type:"raster",...n},Object.assign(this,u.b5(n,["url","scheme","tileSize"]))}load(t){this._loaded=!1,this.fire(new u.B("dataloading",{dataType:"source"}));const n=this.map.getWorldview(),l=(p,m)=>{this._tileJSONRequest=null,this._loaded=!0,p?this.fire(new u.A(p)):m&&(Object.assign(this,m),m.raster_layers&&(this.rasterLayers=m.raster_layers,this.rasterLayerIds=this.rasterLayers.map(g=>g.id)),this.tileBounds=Ba.fromTileJSON(m),Xo(m.tiles),this.fire(new u.B("data",{dataType:"source",sourceDataType:"metadata"})),this.fire(new u.B("data",{dataType:"source",sourceDataType:"content"}))),t&&t(p)};this.provider=typeof this._options.provider=="string"?this._options.provider:void 0,this._tileProvider=void 0;const d=u.db(this._options);return d instanceof Error?(this._loaded=!0,this.fire(new u.A(d)),void(t&&t())):this.provider&&!d?(this._loaded=!0,this.fire(new u.A(new Error(`TileProvider "${this.provider}" is not registered`))),void(t&&t())):void(this._tileJSONRequest=d?this.loadTileJSONWithProvider(d,l):u.dc(this._options,this.map._requestManager,null,n,l))}loadTileJSONWithProvider(t,n){this.provider=t.name;const l=new AbortController;return(async()=>{const{request:d,options:p}=await u.df(this._options,this.map._requestManager,l.signal);if(l.signal.aborted)return;const m=await u.dg(t.name,t.url);if(l.signal.aborted)return;const g=new m(p);let x=null;if(g.load&&d&&(x=await g.load({request:d}),l.signal.aborted))return;this._tileProvider=g;const w=u.dh(this._options,x,this.map._requestManager);w instanceof Error?n(w):n(null,w)})().catch(d=>{l.signal.aborted||n(new Error(`Could not load tile provider ${t.name}`,{cause:d}))}),{cancel:()=>l.abort()}}loaded(){return this._loaded}onAdd(t){this.map=t,this.load()}reload(){this.cancelTileJSONRequest();const t=u.y(this.id,this.scope);this.load(()=>this.map.style.clearSource(t))}setTiles(t){return this._options.tiles=t,this.reload(),this}setUrl(t){return this.url=t,this._options.url=t,this.reload(),this}onRemove(t){this.cancelTileJSONRequest()}serialize(){return{...this._options}}hasTile(t){return!this.tileBounds||this.tileBounds.contains(t.canonical)}async loadTile(t,n){const l=u.r.devicePixelRatio>=2,d=this.map._requestManager.normalizeTileURL(t.tileID.canonical.url(this.tiles,this.scheme),l,this.tileSize),p=new AbortController;if(t.request=p,this._tileProvider)this.loadTileWithProvider(t,this._tileProvider,d,p,n);else try{const m=await this.map._requestManager.transformRequest(d,u.R.Tile,p.signal);if(p.signal.aborted)return delete t.request,n(null);const{data:g,headers:x}=await u.q(m,p.signal);if(delete t.request,t.aborted)return n(null);const w=u.dd(x);this.map._refreshExpiredTiles&&t.setExpiryData(w),t.setTexture(g,this.map.painter),t.state="loaded",u.de(this.dispatcher),n(null)}catch(m){if(delete t.request,p.signal.aborted)return n(null);t.state="errored",n(m)}}async loadTileWithProvider(t,n,l,d,p){const{z:m,x:g,y:x}=t.tileID.canonical;try{const w=await this.map._requestManager.transformRequest(l,u.R.Tile,d.signal);if(d.signal.aborted)return p(null);const S=await n.loadTile({z:m,x:g,y:x},{request:w,signal:d.signal});if(d.signal.aborted)return p(null);if(S==null){const I=new Error("Tile not found");return I.status=404,t.state="errored",p(I)}if(S.data==null)return t.state="loaded",p(null);const A=S.data instanceof ImageBitmap?S.data:await createImageBitmap(new Blob([S.data]));if(d.signal.aborted)return p(null);t.setTexture(A,this.map.painter),t.state="loaded",this.map._refreshExpiredTiles&&t.setExpiryData({cacheControl:S.cacheControl,expires:S.expires}),p(null)}catch(w){if(d.signal.aborted)return p(null);t.state="errored",p(new Error(`Could not load tile from ${l}`,{cause:w}))}finally{delete t.request}}abortTile(t,n){t.request&&(t.request.abort(),delete t.request),n&&n()}unloadTile(t,n){t.texture&&t.texture instanceof u.T?(t.destroy(!1),t.texture&&t.texture instanceof u.T&&this.map.painter.saveTileTexture(t.texture)):t.destroy(),n&&n()}hasTransition(){return!1}cancelTileJSONRequest(){this._tileJSONRequest&&(this._tileJSONRequest.cancel(),this._tileJSONRequest=null)}}function yc([s,t],n,l,{scaled:d=!0}={}){const{tileSize:p,buffer:m}=l,{x:g,y:x,z:w}=n;if(!isFinite(g)||!isFinite(x)||!isFinite(w))throw new Error("Invalid MRT header");const S=2**w,A=S*u.a_(s),I=S*u.a$(t);return(function([M,D],L,{scaled:k=!0}={}){if(!L)throw new Error("bandView is undefined");const{data:B,tileSize:$,buffer:Z,offset:G,scale:te,dimension:ee}=L;if(M<-Z||M>$+Z||D<-Z||D>$+Z)throw new Error(`Point (${M}, ${D}) out of bounds for tileSize=${$}, buffer=${Z}`);const le=(D+Z)*($+2*Z)+(M+Z);if(new Uint32Array(B.buffer)[le]===4294967295)return null;let K=[];K=k?[]:new L.data.constructor(ee);for(let Q=0;Q<ee;Q++)K[Q]=Math.round(1e12*(B[ee*le+Q]*te+G))/1e12;return K})([Math.min(Math.max(-m,Math.floor((A-g)*p)),p-1+m),Math.min(Math.max(-m,Math.floor((I-x)*p)),p-1+m)],l,{scaled:d})}class bl extends gc{constructor(t,n,l,d){super(t,n,l,d),this.type="raster-array",this.maxzoom=22,this.partial=!0,this._loadTilePending={},this._loadTileLoaded={},this._options={type:"raster-array",...n}}triggerRepaint(t){const n=this.map.painter._terrain,l=this.map.style.getSourceCache(this.id);n&&n.enabled&&l&&n._clearRenderCacheForTile(l.id,t.tileID),this.map.triggerRepaint()}async loadTile(t,n){const l=this.map._requestManager.normalizeTileURL(t.tileID.canonical.url(this.tiles,this.scheme),!1,this.tileSize);t.source=this.id,t.scope=this.scope,t.actor||(t.actor=this.dispatcher.getActor());const d=new AbortController;t.request=d;const p=(m,g,x)=>{if(delete t.request,t.aborted)return n(null);if(m)return t.state="errored",n(m);if(this.map._refreshExpiredTiles&&g&&t.setExpiryData(u.dd(x)),this.partial&&t.state!=="expired")t.state="empty";else if(!this.partial){if(!g)return n(null);t.state="loaded",t._isHeaderLoaded=!0,t._mrt=g}n(null)};try{const m=await this.map._requestManager.transformRequest(l,u.R.Tile,d.signal);if(d.signal.aborted)return n(null);t.requestParams=m;const g={request:m,uid:t.uid,tileID:t.tileID,type:this.type,source:this.id,scope:this.scope,partial:this.partial};t.request=this.partial?t.fetchHeader(void 0,(x,w,S)=>{p(x,w,S)}):t.actor.sendCancelable("loadTile",g,{},(x,w)=>x?p(x):w?void p(null,w.mrt,w.headers):p(null,null))}catch(m){if(d.signal.aborted)return n(null);t.state="errored",n(m)}}abortTile(t){t.request&&(t.request.abort(),delete t.request),t.actor&&t.actor.notify("abortTile",{uid:t.uid,type:this.type,source:this.id,scope:this.scope})}unloadTile(t,n){const l=t.texturePerLayer;if(t.flushAllQueues(),l.size){t.destroy(!1);for(const d of l.values())this.map.painter.saveTileTexture(d)}else t.destroy()}prepareTile(t,n,l,d){t._isHeaderLoaded&&(t.state!=="empty"&&(t.state="reloading"),t.fetchBandForRender(n,l,d,(p,m)=>{p?(t.state="errored",this.fire(new u.A(p))):m&&(t._isHeaderLoaded=!0,t.setTexturePerLayer(l,m,this.map.painter),t.state="loaded"),this.triggerRepaint(t)}))}getInitialBand(t){if(!this.rasterLayers)return 0;const n=this.rasterLayers.find(({id:p})=>p===t),l=n&&n.fields,d=l&&l.bands&&l.bands;return d?d[0]:0}getTextureDescriptor(t,n,l){if(!t)return;const d=n.sourceLayer||this.rasterLayerIds&&this.rasterLayerIds[0];if(!d)return;let p=null;n instanceof u.di?p=n.paint.get("raster-array-band"):n instanceof u.dj&&(p=n.paint.get("raster-particle-array-band"));const m=p||this.getInitialBand(d);if(m!=null)if(t.textureDescriptorPerLayer.get(n.id)){if(!t.updateNeeded(n.id,m)||l)return{...t.textureDescriptorPerLayer.get(n.id),texture:t.texturePerLayer.get(n.id)}}else this.prepareTile(t,d,n.id,m)}getImages(t,n){const l=new Map;for(const d of t)for(const p of n){const[m,g]=p.split("/"),x=d.getLayer(m);if(!x||!x.hasBand(g)||!x.hasDataForBand(g))continue;const{bytes:w,tileSize:S,buffer:A}=x.getBandView(g),I=S+2*A,M={data:new u.t({width:I,height:I},w),pixelRatio:2,sdf:!1,usvg:!1,version:0};l.set(p,M)}return l}queryRasterArrayValueByBandId(t,n,l){const d=n._mrt;return new Promise(p=>{const m={},g=new Set;for(const[x,w]of Object.entries(d.layers)){if(l.layerName&&x!==l.layerName)continue;const S={};m[x]=S;for(const{bands:A}of w.dataIndex)for(const I of A)l.bands&&!l.bands.includes(I)||(g.add(u.y(x,I)),n.fetchBand(x,null,I,M=>{u.r.frame(()=>{S[I]=M?null:yc([t.lng,t.lat],d,w.getBandView(I)),g.delete(u.y(x,I)),g.size===0&&p(m)})}))}g.size===0&&p(m)})}_loadTileForQuery(t){if(this._loadTileLoaded[t.uid])return Promise.resolve(t._mrt);if(t.uid in this._loadTilePending)return this._loadTilePending[t.uid];const n=this._fetchTileForQuery(t);return this._loadTilePending[t.uid]=n,n}async _fetchTileForQuery(t){const n=this.map._requestManager.normalizeTileURL(t.tileID.canonical.url(this.tiles,this.scheme),!1,this.tileSize);try{const l={request:await this.map._requestManager.transformRequest(n,u.R.Tile),uid:t.uid,tileID:t.tileID,type:this.type,source:this.id,scope:this.scope,partial:!1},d=await t.actor.send("loadTile",l);if(!d)return null;const p=d.mrt;return this.map._refreshExpiredTiles&&t.setExpiryData(u.dd(d.headers)),t._mrt=p,t._isHeaderLoaded=!0,t.state="loaded",this._loadTileLoaded[t.uid]=!0,p}finally{delete this._loadTilePending[t.uid]}}async queryRasterArrayValueByAllBands(t,n,l){return await this._loadTileForQuery(n)?this.queryRasterArrayValueByBandId(t,n,l):null}queryRasterArrayValue(t,n){const l=u.b4.convert(t),d=this.findLoadedParent(l);return d&&d._mrt?n.bands||!this.partial?this.queryRasterArrayValueByBandId(l,d,n):this.queryRasterArrayValueByAllBands(l,d,n):Promise.resolve(null)}findLoadedParent(t){const n=u.ac.fromLngLat(t,this.map.transform.tileSize),l=this.maxzoom+1,d=1<<l,p=Math.floor(n.x),m=Math.floor((n.x-p)*d),g=Math.floor(n.y*d);if(m<0||m>=d||g<0||g>=d)return null;const x=this.map.style.getSourceCache(this.id),w=new u.br(l,p,l,m,g);return x.findLoadedParent(w,this.minzoom)}}var Dm=u.cR([{name:"a_index",type:"Int16",components:1}]);class Lm{constructor(t,n,l,d){const p={width:l[0],height:l[1],data:null},m=t.gl;this.targetColorTexture=new u.T(t,p,m.RGBA8,{useMipmap:!1}),this.backgroundColorTexture=new u.T(t,p,m.RGBA8,{useMipmap:!1}),this.context=t,this.updateParticleTexture(n,d),this.lastInvalidatedAt=0}updateParticleTexture(t,n){if(this.particleTextureDimension===n.width)return;(this.particleTexture0||this.particleTexture1||this.particleIndexBuffer||this.particleSegment)&&(this.particleTexture0.destroy(),this.particleTexture1.destroy(),this.particleIndexBuffer.destroy(),this.particleSegment.destroy());const l=this.context.gl,d=n.width*n.height;this.particleTexture0=new u.T(this.context,n,l.RGBA8,{premultiply:!1,useMipmap:!1}),this.particleTexture1=new u.T(this.context,n,l.RGBA8,{premultiply:!1,useMipmap:!1});const p=new u.dk;p.reserve(d);for(let m=0;m<d;m++)p.emplaceBack(m);this.particleIndexBuffer=this.context.createVertexBuffer(p,Dm.members,!0),this.particleSegment=u.cr.simpleSegment(0,0,this.particleIndexBuffer.length,0),this.particleTextureDimension=n.width}update(t){return!(this.lastInvalidatedAt<t&&(this.lastInvalidatedAt=u.r.now(),1))}destroy(){this.targetColorTexture.destroy(),this.backgroundColorTexture.destroy(),this.particleIndexBuffer.destroy(),this.particleTexture0.destroy(),this.particleTexture1.destroy(),this.particleSegment.destroy()}}function nu(s,t,n,l,d){if(d>0){const p=u.r.now(),m=(p-s.timeAdded)/d,g=t?(p-t.timeAdded)/d:-1,x=n.getSource(),w=l.coveringZoomLevel({tileSize:x.tileSize,roundZoom:x.roundZoom}),S=!t||Math.abs(t.tileID.overscaledZ-w)>Math.abs(s.tileID.overscaledZ-w),A=S&&s.refreshedUponExpiration?1:u.as(S?m:1-g,0,1);return t?{opacity:1,mix:1-A,isFading:m<1}:{opacity:A,mix:0,isFading:m<1}}return{opacity:1,mix:0,isFading:!1}}function Na(s,t,n){if(!s)return null;const l=t.getTextureDescriptor(s,n,!0);if(!l)return null;let{texture:d,mix:p,offset:m,tileSize:g,buffer:x,format:w}=l;if(!d||!w)return null;let S=!1;return w==="uint32"&&(S=!0,p[3]=0,p=ph(u.dr,p,[0,n.paint.get("raster-particle-max-speed")]),m=ru(u.dr,m,[0,n.paint.get("raster-particle-max-speed")])),{texture:d,textureOffset:[x/(g+2*x),g/(g+2*x)],tileSize:g,scalarData:S,scale:p,offset:m,defines:["RASTER_ARRAY",{uint8:"DATA_FORMAT_UINT8",uint16:"DATA_FORMAT_UINT16",uint32:"DATA_FORMAT_UINT32"}[w]]}}function yh(s){const t=s._nearZ,n=s.projection.farthestPixelDistance(s),l=n-t,d=.2*s.height,p=t+d;return[t,n,(p-d-t)/l,(p-t)/l]}var ou=`#ifdef RASTER_ARRAY
3090uniform sampler2D u_velocity;uniform mediump vec2 u_velocity_res;uniform mediump float u_max_speed;const vec4 NO_DATA=vec4(1);const vec2 INVALID_VELOCITY=vec2(-1);uniform highp vec2 u_uv_offset;uniform highp float u_data_offset;uniform highp vec2 u_data_scale;ivec4 rasterArrayLinearCoord(highp vec2 texCoord,highp vec2 texResolution,out highp vec2 fxy) {texCoord=texCoord*texResolution-0.5;fxy=fract(texCoord);texCoord-=fxy;return ivec4(texCoord.xxyy+vec2(1.5,0.5).xyxy);}highp vec2 lookup_velocity(highp vec2 uv) {uv=u_uv_offset.x+u_uv_offset.y*uv;highp vec2 fxy;ivec4 c=rasterArrayLinearCoord(uv,u_velocity_res,fxy);highp vec4 tl=texelFetch(u_velocity,c.yz,0);highp vec4 tr=texelFetch(u_velocity,c.xz,0);highp vec4 bl=texelFetch(u_velocity,c.yw,0);highp vec4 br=texelFetch(u_velocity,c.xw,0);if (tl==NO_DATA) {return INVALID_VELOCITY;}if (tr==NO_DATA) {return INVALID_VELOCITY;}if (bl==NO_DATA) {return INVALID_VELOCITY;}if (br==NO_DATA) {return INVALID_VELOCITY;}highp vec4 t=mix(mix(bl,br,fxy.x),mix(tl,tr,fxy.x),fxy.y);highp vec2 velocity=u_data_offset+vec2(dot(t.rg,u_data_scale),dot(t.ba,u_data_scale));velocity.y=-velocity.y;velocity/=max(u_max_speed,length(velocity));return velocity;}
3091#endif
3092uniform highp float u_particle_pos_scale;uniform highp vec2 u_particle_pos_offset;highp vec4 pack_pos_to_rgba(highp vec2 p) {highp vec2 v=(p+u_particle_pos_offset)/u_particle_pos_scale;highp vec4 r=vec4(v.x,fract(v.x*255.0),v.y,fract(v.y*255.0));return vec4(r.x-r.y/255.0,r.y,r.z-r.w/255.0,r.w);}highp vec2 unpack_pos_from_rgba(highp vec4 v) {v=floor(v*255.0+0.5)/255.0;highp vec2 p=vec2(v.x+(v.y/255.0),v.z+(v.w/255.0));return u_particle_pos_scale*p-u_particle_pos_offset;}`;La["_prelude_raster_particle.glsl"]||(La["_prelude_raster_particle.glsl"]=ou);var zm={building:Vt(`#include "_prelude_fog.fragment.glsl"
3093#include "_prelude_shadow.fragment.glsl"
3094#include "_prelude_lighting.glsl"
3095#include "_prelude_indicator_cutout.fragment.glsl"
3096#include "_prelude_feature_cutout.fragment.glsl"
3097const float window_depth=0.5;const float ao_radius=0.2;in vec4 v_color;in highp vec3 v_normal;in highp vec3 v_pos;
3098#ifdef RENDER_FRONT_CUTOFF
3099in float v_front_cutoff_opacity;
3100#endif
3101#ifdef INDICATOR_CUTOUT
3102#ifdef FEATURE_CUTOUT
3103in vec4 v_ground_roof;
3104#endif
3105#endif
3106#ifdef BUILDING_FAUX_FACADE
3107in lowp float v_faux_facade;in highp float v_faux_facade_ed;in highp vec2 v_faux_facade_window;in highp vec2 v_faux_facade_floor;in highp vec2 v_faux_facade_range;in highp float v_aspect;in highp vec3 v_tbn_0;in highp vec3 v_tbn_1;in highp vec3 v_tbn_2;in highp vec4 v_faux_color_emissive;uniform float u_faux_facade_ao_intensity;
3108#endif
3109#ifdef RENDER_SHADOWS
3110in highp vec4 v_pos_light_view_0;in highp vec4 v_pos_light_view_1;
3111#endif
3112#ifdef FLOOD_LIGHT
3113in highp float v_flood_radius;in float v_has_flood_light;
3114#endif
3115uniform lowp float u_opacity;uniform vec3 u_camera_pos;uniform highp float u_tile_to_meter;uniform float u_facade_emissive_chance;uniform vec3 u_flood_light_color;uniform float u_flood_light_intensity;vec3 linearTosRGB(in vec3 color) {return pow(color,vec3(1./2.2));}
3116#ifdef BUILDING_FAUX_FACADE
3117highp float hash12(in highp vec2 p) {highp vec3 p3 =fract(vec3(p.xyx)*0.1031);p3+=dot(p3,p3.yzx+33.33);return fract((p3.x+p3.y)*p3.z);}float min3(in vec3 v) {return min(min(v.x,v.y),v.z);}highp vec2 get_uv_mask_id(in highp vec2 q,out highp float mask,out highp vec2 id) {highp vec2 p=q;mask=step(v_faux_facade_range.x,p.y)*step(p.y,v_faux_facade_range.y);p.y=p.y-v_faux_facade_range.x;highp vec2 uv=modf(p/v_faux_facade_floor,id);highp vec4 d=(v_faux_facade_floor.xyxy+vec4(-v_faux_facade_window,v_faux_facade_window))*0.5;highp vec4 edge=d/v_faux_facade_floor.xyxy;highp vec2 m=step(edge.xy,uv)*step(uv,edge.zw);mask*=m.x*m.y;uv-=vec2(0.5);uv*=vec2(0.5)/(vec2(0.5)-edge.xy);uv+=vec2(0.5);return uv;}highp float ray_unit_box(in highp vec3 ray_o,in highp vec3 ray_d,in highp vec3 bmin,in highp vec3 bmax) {highp vec3 planes=mix(bmin,bmax,step(0.0,ray_d));highp vec3 t=(planes-ray_o)/ray_d;return min3(t);}float get_emissive(in vec2 id) {if (u_facade_emissive_chance > 0.0) {return (step(hash12(id),u_facade_emissive_chance)+0.05)*v_faux_color_emissive.a;}return 0.0;}vec3 get_shade_info(in highp vec3 v,in highp vec3 v_normalized,in vec3 color,in vec2 id,in mat3 tbn,inout vec3 out_normal,inout float out_emissive) {vec3 out_color=color;highp vec3 abs_v=abs(v_normalized);bool x_major=abs_v.x >=abs_v.y && abs_v.x >=abs_v.z;bool y_major=abs_v.y >=abs_v.x && abs_v.y >=abs_v.z;bool z_major=abs_v.z >=abs_v.x && abs_v.z >=abs_v.y;
3118#if 0
3119if (x_major) {out_color=v.x > 0.0 ? vec3(1.0,0.0,0.0) : vec3(0.0,1.0,1.0);} else if (y_major) {out_color=v.y > 0.0 ? vec3(0.0,1.0,0.0) : vec3(1.0,0.0,1.0);} else if (z_major) {out_color=v.z > 0.0 ? vec3(0.0,0.0,1.0) : vec3(1.0,1.0,0.0);}out_emissive=1.0;
3120#else
3121if (x_major) {out_normal=-sign(v.x)*tbn[0];} else if (y_major) {out_normal=vec3(0.0,0.0,-sign(v.y));} else if (z_major) {out_color=v_faux_color_emissive.rgb;out_emissive=v.z <=0.0 ? get_emissive(id) : out_emissive;}float ao=1.0;if (u_faux_facade_ao_intensity > 0.0) {vec4 ao_range=v_faux_facade_window.xxyy*0.5-vec4(0,ao_radius,0,ao_radius);vec2 ao_range_z=vec2(window_depth*0.5)-vec2(0.0,ao_radius);if (x_major || y_major) {ao*=smoothstep(-ao_range_z.x,-ao_range_z.y,v.z);} else if (z_major) {ao*=smoothstep(-ao_range.x,-ao_range.y,v.x)*(1.0-smoothstep(ao_range.y,ao_range.x,v.x));ao*=smoothstep(-ao_range.z,-ao_range.w,v.y)*(1.0-smoothstep(ao_range.w,ao_range.z,v.y));}ao=mix(1.0,min(1.0,ao+0.25),u_faux_facade_ao_intensity);}out_color*=ao;
3122#endif
3123return out_color;}
3124#endif
3125vec3 apply_lighting_linear(in vec3 color,in vec3 normal,in float dir_factor) {float ambient_directional_factor=calculate_ambient_directional_factor(normal);vec3 ambient_contrib=ambient_directional_factor*u_lighting_ambient_color;vec3 directional_contrib=u_lighting_directional_color*dir_factor;return color*(ambient_contrib+directional_contrib);}void main() {vec3 normal=normalize(v_normal);vec3 base_color=v_color.rgb;float emissive=v_color.a;
3126#ifdef BUILDING_FAUX_FACADE
3127if (v_faux_facade > 0.0) {highp mat3 tbn=mat3(v_tbn_0,v_tbn_1,v_tbn_2);highp vec3 v=vec3(v_pos.xy,v_pos.z/u_tile_to_meter)-u_camera_pos;highp vec3 view_tangent=transpose(tbn)*v;highp vec2 q=vec2(v_faux_facade_ed,v_pos.z);float mask=0.0;vec2 id=vec2(0.0);highp vec2 uv=get_uv_mask_id(q,mask,id);uv*=v_faux_facade_window;highp vec3 bmin=vec3(0.0,0.0,-window_depth);highp vec3 bmax=bmin+vec3(v_faux_facade_window,window_depth);highp vec3 ray_o=vec3(uv,0.0);highp vec3 ray_d=normalize(view_tangent);highp float t_min=ray_unit_box(ray_o,ray_d,bmin,bmax);highp vec3 hit=ray_o+t_min*ray_d;highp vec3 r=vec3(v_faux_facade_window,-window_depth);hit-=r*0.5;highp vec3 normalized=hit/r;vec3 out_normal=normal;float out_emissive=emissive;vec3 room_color=get_shade_info(hit,normalized,base_color,id,tbn,out_normal,out_emissive);base_color=mix(base_color,room_color,mask);normal=mix(normal,out_normal,mask);emissive=mix(emissive,out_emissive,mask);}
3128#endif
3129vec4 color=vec4(base_color,1.0);vec3 xy_flipped_normal=vec3(-normal.xy,normal.z);float shadowed_lighting_factor=0.0;
3130#ifdef RENDER_SHADOWS
3131#ifdef RENDER_CUTOFF
3132shadowed_lighting_factor=shadowed_light_factor_normal_opacity(xy_flipped_normal,v_pos_light_view_0,v_pos_light_view_1,1.0/gl_FragCoord.w,v_cutoff_opacity);if (v_cutoff_opacity==0.0) {discard;}
3133#else
3134shadowed_lighting_factor=shadowed_light_factor_normal(xy_flipped_normal,v_pos_light_view_0,v_pos_light_view_1,1.0/gl_FragCoord.w);
3135#endif
3136#else
3137shadowed_lighting_factor=max(0.0,dot(xy_flipped_normal,u_lighting_directional_dir));
3138#endif
3139color.rgb=apply_lighting_linear(color.rgb,xy_flipped_normal,shadowed_lighting_factor);color.rgb=linearTosRGB(color.rgb);
3140#ifdef FLOOD_LIGHT
3141float flood_radiance=(1.0-min(v_pos.z/v_flood_radius,1.0))*u_flood_light_intensity*v_has_flood_light;color.rgb=mix(color.rgb,u_flood_light_color,flood_radiance);
3142#endif
3143color.rgb=mix(color.rgb,linearTosRGB(base_color.rgb),emissive);
3144#ifdef FOG
3145color=fog_dither(fog_apply_premultiplied(color,v_fog_pos,v_pos.z));
3146#endif
3147color*=u_opacity;
3148#ifdef INDICATOR_CUTOUT
3149#ifdef FEATURE_CUTOUT
3150{float ditherOpacity=cutoutGroundRoofOpacity(v_ground_roof);if (ditherOpacity < 1.0) {int index=viewport_dither_index(gl_FragCoord.xy);if (ditherOpacity < DITHER_THRESHOLDS[index]) {discard;}}}
3151#else
3152color=applyCutout(color,v_pos.z);
3153#endif
3154#endif
3155#ifdef RENDER_FRONT_CUTOFF
3156if (v_front_cutoff_opacity < 1.0) {int index=viewport_dither_index(gl_FragCoord.xy);if (v_front_cutoff_opacity < DITHER_THRESHOLDS[index]) {discard;}}
3157#endif
3158#ifdef FEATURE_CUTOUT
3159color=apply_feature_cutout(color,gl_FragCoord,get_cutout_factors(gl_FragCoord).x,0.0);
3160#endif
3161glFragColor=color;
3162#ifdef DEBUG_SHOW_NORMALS
3163color.rgb=xy_flipped_normal*0.5+vec3(0.5,0.5,0.5);color.a=1.0;glFragColor=color;
3164#endif
3165#ifdef OVERDRAW_INSPECTOR
3166glFragColor=vec4(1.0);
3167#endif
3168HANDLE_WIREFRAME_DEBUG;}`,`#include "_prelude_fog.vertex.glsl"
3169#include "_prelude_shadow.vertex.glsl"
3170in vec3 a_pos_3f;in ivec4 a_normal_3;in ivec4 a_centroid_3;
3171#ifdef FLOOD_LIGHT
3172in int a_flood_light_wall_radius_1i16;
3173#endif
3174#ifdef BUILDING_FAUX_FACADE
3175in uvec4 a_faux_facade_data;in uvec2 a_faux_facade_vertical_range;
3176#endif
3177uniform mat4 u_matrix;uniform mat4 u_normal_matrix;uniform highp float u_tile_to_meter;
3178#ifdef RENDER_FRONT_CUTOFF
3179uniform vec3 u_front_cutoff_params;out float v_front_cutoff_opacity;
3180#endif
3181#ifdef INDICATOR_CUTOUT
3182#ifdef FEATURE_CUTOUT
3183out vec4 v_ground_roof;
3184#endif
3185#endif
3186out vec4 v_color;out vec3 v_normal;out highp vec3 v_pos;
3187#ifdef BUILDING_FAUX_FACADE
3188out lowp float v_faux_facade;out highp float v_faux_facade_ed;out highp vec2 v_faux_facade_window;out highp vec2 v_faux_facade_floor;out highp vec2 v_faux_facade_range;out highp float v_aspect;out highp vec3 v_tbn_0;out highp vec3 v_tbn_1;out highp vec3 v_tbn_2;out highp vec4 v_faux_color_emissive;
3189#endif
3190#ifdef RENDER_SHADOWS
3191uniform mat4 u_light_matrix_0;uniform mat4 u_light_matrix_1;out highp vec4 v_pos_light_view_0;out highp vec4 v_pos_light_view_1;
3192#endif
3193#ifdef FLOOD_LIGHT
3194out highp float v_flood_radius;out float v_has_flood_light;
3195#endif
3196const float MAX_UINT_16=65535.0;const float MAX_INT_16=32767.0;const float MAX_UINT_8=255.0;const float TWO_POW_8=256.0;const float FLOOD_LIGHT_MAX_RADIUS_METER=2048.0;vec3 sRGBToLinear(vec3 srgbIn) {return pow(srgbIn,vec3(2.2));}
3197#ifdef BUILDING_FAUX_FACADE
3198mat3 get_tbn(in vec3 normal) {const vec3 bitangent=vec3(0.0,0.0,1.0);vec3 tangent=normalize(vec3(normal.y,-normal.x,0.0));return mat3(tangent,bitangent,normal);}
3199#endif
3200#pragma mapbox: define-attribute-vertex-shader-only highp uvec2 part_color_emissive
3201#pragma mapbox: define-attribute-vertex-shader-only highp uvec2 faux_facade_color_emissive
3202void main() {
3203#pragma mapbox: initialize-attribute-custom highp uvec2 part_color_emissive
3204#pragma mapbox: initialize-attribute-custom highp uvec2 faux_facade_color_emissive
3205#ifdef FLOOD_LIGHT
3206v_flood_radius=(float(a_flood_light_wall_radius_1i16)/MAX_INT_16*FLOOD_LIGHT_MAX_RADIUS_METER);v_has_flood_light=step(0.0,v_flood_radius);
3207#endif
3208vec4 color_emissive=decode_color(vec2(part_color_emissive));v_color=vec4(sRGBToLinear(color_emissive.rgb),color_emissive.a);vec3 a_normal_3f=vec3(a_normal_3)/MAX_INT_16;v_normal=vec3(u_normal_matrix*vec4(a_normal_3f,0.0));float hidden=0.0;float depth_offset=0.0;vec2 centroid_xy=vec2(a_centroid_3.xy >> 2);vec2 spanBits=vec2(a_centroid_3.xy & 3);
3209#ifdef BUILDING_FAUX_FACADE
3210vec4 faux_facade_data=vec4(a_faux_facade_data);v_faux_facade=faux_facade_data.x;if (v_faux_facade > 0.0) {v_faux_facade_ed=faux_facade_data.x *u_tile_to_meter;float window_x_perc=floor(faux_facade_data.y/TWO_POW_8);float window_y_perc=faux_facade_data.y-TWO_POW_8*window_x_perc;vec2 window_perc=vec2(window_x_perc,window_y_perc)/MAX_UINT_8;v_faux_facade_floor=(faux_facade_data.zw/MAX_UINT_16*EXTENT)*u_tile_to_meter;v_faux_facade_window=window_perc*v_faux_facade_floor;v_faux_facade_range=(vec2(a_faux_facade_vertical_range)/MAX_UINT_16*EXTENT)*u_tile_to_meter;v_aspect=v_faux_facade_window.x/v_faux_facade_window.y;mat3 tbn=get_tbn(normalize(v_normal));v_tbn_0=tbn[0];v_tbn_1=tbn[1];v_tbn_2=tbn[2];v_faux_color_emissive=decode_color(vec2(faux_facade_color_emissive));v_faux_color_emissive.rgb=sRGBToLinear(v_faux_color_emissive.rgb);depth_offset=min(1000.0,float(a_centroid_3.z))*0.0000002;}
3211#endif
3212v_pos=a_pos_3f;
3213#if defined(RENDER_CUTOFF) || defined(RENDER_FRONT_CUTOFF)
3214float halfSpanX=spanBits.x*10.0/u_tile_to_meter;float halfSpanY=spanBits.y*10.0/u_tile_to_meter;
3214vec2 screenUpInTile=vec2(u_matrix[0][1],u_matrix[1][1]);vec2 spanOffset=vec2(halfSpanX,halfSpanY)*sign(screenUpInTile);vec2 cutoff_highestCorner=centroid_xy+spanOffset;vec2 cutoff_lowestCorner=centroid_xy-spanOffset;
3215#endif
3216#if defined(RENDER_CUTOFF) || defined(RENDER_FRONT_CUTOFF)
3217vec4 ground=u_matrix*vec4(centroid_xy,0.0,1.0);
3218#endif
3219#ifdef RENDER_CUTOFF
3220v_cutoff_opacity=cutoff_opacity(u_cutoff_params,ground.z);hidden=float(v_cutoff_opacity==0.0);v_pos.z*=v_cutoff_opacity;
3221#endif
3222#ifdef RENDER_SHADOWS
3223vec3 shadow_pos=v_pos;
3224#ifdef NORMAL_OFFSET
3225vec3 offset=shadow_normal_offset_model(v_normal);shadow_pos+=offset*shadow_normal_offset_multiplier0();
3226#endif
3227v_pos_light_view_0=u_light_matrix_0*vec4(shadow_pos,1.0);v_pos_light_view_1=u_light_matrix_1*vec4(shadow_pos,1.0);
3228#endif
3229#ifdef FOG
3230v_fog_pos=fog_position(v_pos);
3231#endif
3232#ifdef RENDER_FRONT_CUTOFF
3233v_front_cutoff_opacity=1.0;{hidden=max(hidden,float(ground.w <=0.0));float ndc_y=ground.y/max(ground.w,0.001);float threshold=u_front_cutoff_params.x*2.0-1.0;float range_ndc=u_front_cutoff_params.y*2.0;hidden=max(hidden,float(ndc_y < threshold-range_ndc));float t=clamp((ndc_y-(threshold-range_ndc))/max(range_ndc,0.001),0.0,1.0);v_front_cutoff_opacity=mix(u_front_cutoff_params.z,1.0,t);}
3234#endif
3235gl_Position=mix(u_matrix*vec4(v_pos,1),AWAY,hidden);gl_Position.z-=depth_offset*gl_Position.w;
3236#ifdef INDICATOR_CUTOUT
3237#ifdef FEATURE_CUTOUT
3238vec4 ic_ground=u_matrix*vec4(v_pos.xy,0.0,1.0);vec4 ic_roof=u_matrix*vec4(v_pos.xy,v_pos.z,1.0);v_ground_roof=vec4(ic_ground.xy/ic_ground.w,ic_roof.xy/ic_roof.w);
3239#endif
3240#endif
3241}`),buildingBloom:Vt(`in vec4 v_color_emissive;
3242#pragma mapbox: define-attribute highp vec4 bloom_attenuation
3243float saturate(float val) {return clamp(val,0.0,1.0);}void main() {
3244#pragma mapbox: initialize-attribute highp vec4 bloom_attenuation
3245float emission=v_color_emissive.a;float opacity=1.0;
3246#ifdef HAS_ATTRIBUTE_a_bloom_attenuation
3247float distance=length(vec2(1.3*max(0.0,abs(bloom_attenuation.x)-bloom_attenuation.z),bloom_attenuation.y));distance+= mix(0.5,0.0,clamp(emission-1.0,0.0,1.0));opacity*=saturate(1.0-distance*distance);
3248#endif
3249#ifdef RENDER_CUTOFF
3250opacity*=v_cutoff_opacity;
3251#endif
3252glFragColor=vec4(v_color_emissive.rgb,1.0)*opacity;}`,`in vec3 a_pos_3f;
3253#pragma mapbox: define-attribute-vertex-shader-only highp uvec2 part_color_emissive
3254#pragma mapbox: define-attribute highp vec4 bloom_attenuation
3255out vec4 v_color_emissive;uniform mat4 u_matrix;vec3 sRGBToLinear(vec3 srgbIn) {return pow(srgbIn,vec3(2.2));}void main() {
3256#pragma mapbox: initialize-attribute-custom highp uvec2 part_color_emissive
3257#pragma mapbox: initialize-attribute highp vec4 bloom_attenuation
3258#ifdef HAS_ATTRIBUTE_a_part_color_emissive
3259vec4 color_emissive=decode_color(vec2(part_color_emissive));float part_emissive=color_emissive.a*5.0;v_color_emissive=vec4(sRGBToLinear(color_emissive.rgb),part_emissive);
3260#else
3261v_color_emissive=vec4(1.0);
3262#endif
3263gl_Position=u_matrix*vec4(a_pos_3f,1.0);
3264#ifdef RENDER_CUTOFF
3265v_cutoff_opacity=cutoff_opacity(u_cutoff_params,gl_Position.z);
3266#endif
3267}`),buildingDepth:Vt("void main() {}","in vec3 a_pos_3f;uniform mat4 u_matrix;void main() {gl_Position=u_matrix*vec4(a_pos_3f,1.0);}"),rasterParticle:Vt(`#include "_prelude_fog.fragment.glsl"
3268#include "_prelude_lighting.glsl"
3269uniform float u_fade_t;uniform float u_opacity;uniform highp float u_raster_elevation;in vec2 v_pos0;in vec2 v_pos1;uniform sampler2D u_image0;uniform sampler2D u_image1;void main() {vec4 color0,color1,color;color0=texture(u_image0,v_pos0);color1=texture(u_image1,v_pos1);if (color0.a > 0.0) color0.rgb/=color0.a;if (color1.a > 0.0) color1.rgb/=color1.a;color=mix(color0,color1,u_fade_t);color.a*=u_opacity;vec3 out_color=color.rgb;
3270#ifdef LIGHTING_3D_MODE
3271out_color=apply_lighting_with_emission_ground(vec4(out_color,1.0),1.0).rgb;
3272#endif
3273#ifdef FOG
3274highp float fog_limit_high_meters=1000000.0;highp float fog_limit_low_meters=600000.0;float fog_limit=1.0-smoothstep(fog_limit_low_meters,fog_limit_high_meters,u_raster_elevation);out_color=fog_dither(fog_apply(out_color,v_fog_pos,fog_limit));
3275#endif
3276glFragColor=vec4(out_color*color.a,color.a);
3277#ifdef OVERDRAW_INSPECTOR
3278glFragColor=vec4(1.0);
3279#endif
3280HANDLE_WIREFRAME_DEBUG;}`,`#include "_prelude_fog.vertex.glsl"
3281uniform mat4 u_matrix;uniform mat4 u_normalize_matrix;uniform mat4 u_globe_matrix;uniform mat4 u_merc_matrix;uniform mat3 u_grid_matrix;uniform vec2 u_tl_parent;uniform float u_scale_parent;uniform float u_raster_elevation;uniform float u_zoom_transition;uniform vec2 u_merc_center;
3282#define GLOBE_UPSCALE GLOBE_RADIUS/6371008.8
3283in ivec2 a_pos;in uvec2 a_texture_pos;out vec2 v_pos0;out vec2 v_pos1;void main() {float w=1.0;vec2 uv;
3284#ifdef PROJECTION_GLOBE_VIEW
3285vec3 decomposed_pos_and_skirt=decomposeToPosAndSkirt(a_pos);vec3 latLng=u_grid_matrix*vec3(decomposed_pos_and_skirt.xy,1.0);float mercatorY=mercatorYfromLat(latLng[0]);float mercatorX=mercatorXfromLng(latLng[1]);float tiles=u_grid_matrix[0][2];float idx=u_grid_matrix[1][2];float idy=u_grid_matrix[2][2];float uvX=mercatorX*tiles-idx;float uvY=mercatorY*tiles-idy;uv=vec2(uvX,uvY);vec3 globe_pos=latLngToECEF(latLng.xy);globe_pos+=normalize(globe_pos)*u_raster_elevation*GLOBE_UPSCALE;vec4 globe_world_pos=u_globe_matrix*vec4(globe_pos,1.0);vec4 merc_world_pos=vec4(0.0);if (u_zoom_transition > 0.0) {vec2 merc_pos=vec2(mercatorX,mercatorY);merc_world_pos=vec4(merc_pos,u_raster_elevation,1.0);merc_world_pos.xy-=u_merc_center;merc_world_pos.x=wrap(merc_world_pos.x,-0.5,0.5);merc_world_pos=u_merc_matrix*merc_world_pos;}vec4 interpolated_pos=vec4(mix(globe_world_pos.xyz,merc_world_pos.xyz,u_zoom_transition)*w,w);gl_Position=u_matrix*interpolated_pos;
3286#ifdef FOG
3287v_fog_pos=fog_position((u_normalize_matrix*vec4(globe_pos,1.0)).xyz);
3288#endif
3289#else
3290uv=vec2(a_texture_pos)/8192.0;
3290gl_Position=u_matrix*vec4(vec2(a_pos)*w,u_raster_elevation*w,w);
3291#ifdef FOG
3292v_fog_pos=fog_position(vec2(a_pos));
3293#endif
3294#endif
3295v_pos0=uv;
3296#ifdef VIEWPORT_ORIGIN_TOP_LEFT
3297v_pos0.y=1.0-v_pos0.y;
3298#endif
3299v_pos1=(v_pos0*u_scale_parent)+u_tl_parent;}`),rasterParticleDraw:Vt("uniform sampler2D u_color_ramp;in float v_particle_speed;void main() {glFragColor=texture(u_color_ramp,vec2(v_particle_speed,0.5));}",`#include "_prelude_raster_particle.glsl"
3300in int a_index;uniform sampler2D u_particle_texture;uniform float u_particle_texture_side_len;uniform vec2 u_tile_offset;out float v_particle_speed;void main() {ivec2 pixel_coord=ivec2(
3301mod(float(a_index),u_particle_texture_side_len),float(a_index)/u_particle_texture_side_len);vec4 pixel=texelFetch(u_particle_texture,pixel_coord,0);vec2 pos=unpack_pos_from_rgba(pixel)+u_tile_offset;vec2 tex_coord=fract(pos);vec2 velocity=lookup_velocity(tex_coord);if (velocity==INVALID_VELOCITY) {gl_Position=AWAY;v_particle_speed=0.0;} else {gl_Position=vec4(2.0*pos-1.0,0,1);v_particle_speed=length(velocity);}gl_PointSize=1.0;}`),rasterParticleTexture:Vt("uniform sampler2D u_texture;uniform float u_opacity;in vec2 v_tex_pos;void main() {vec4 color=texture(u_texture,v_tex_pos);glFragColor=vec4(floor(255.0*color*u_opacity)/255.0);}",`in ivec2 a_pos;out vec2 v_tex_pos;void main() {vec2 uv=0.5*vec2(a_pos)+vec2(0.5);v_tex_pos=uv;
3302#ifdef VIEWPORT_ORIGIN_TOP_LEFT
3303v_tex_pos.y=1.0-v_tex_pos.y;
3304#endif
3305gl_Position=vec4(a_pos,0.0,1.0);}`),rasterParticleUpdate:Vt(`#include "_prelude_raster_particle.glsl"
3306uniform sampler2D u_particle_texture;uniform mediump float u_particle_texture_side_len;uniform mediump float u_speed_factor;uniform highp float u_reset_rate;uniform highp float u_rand_seed;in highp vec2 v_tex_coord;vec2 linearstep(vec2 edge0,vec2 edge1,vec2 x) {return  clamp((x-edge0)/(edge1-edge0),vec2(0),vec2(1));}const highp vec3 rand_constants=vec3(12.9898,78.233,4375.85453);highp float rand(const highp vec2 co) {highp float t=dot(rand_constants.xy,co);return fract(sin(t)*(rand_constants.z+t));}void main() {ivec2 pixel_coord=ivec2(v_tex_coord*u_particle_texture_side_len);highp vec4 pixel=texelFetch(u_particle_texture,pixel_coord,0);highp vec2 pos=unpack_pos_from_rgba(pixel);highp vec2 velocity=lookup_velocity(clamp(pos,0.0,1.0));highp vec2 dp=velocity==INVALID_VELOCITY ? vec2(0) : velocity*u_speed_factor;pos=pos+dp;highp vec2 seed=(pos+v_tex_coord)*u_rand_seed;highp vec2 random_pos=vec2(rand(seed+1.3),rand(seed+2.1));highp vec2 persist_rate=pow(
3307linearstep(vec2(-u_particle_pos_offset),vec2(0),pos)*linearstep(vec2(1.0+u_particle_pos_offset),vec2(1),pos),vec2(4)
3308);highp vec2 per_frame_persist=pow(persist_rate,abs(dp)/u_particle_pos_offset);highp float drop_rate=1.0-per_frame_persist.x*per_frame_persist.y;drop_rate=any(greaterThanEqual(abs(pos-0.5),vec2(0.5+u_particle_pos_offset))) ? 1.0 : drop_rate;highp float drop=step(1.0-drop_rate-u_reset_rate,rand(seed));highp vec2 next_pos=mix(pos,random_pos,drop);glFragColor=pack_pos_to_rgba(next_pos);}`,"in ivec2 a_pos;out vec2 v_tex_coord;void main() {v_tex_coord=0.5*vec2(a_pos+ivec2(1));gl_Position=vec4(a_pos,0.0,1.0);}"),snowParticle:Vt("in highp vec2 uv;in highp float alphaMultiplier;uniform vec4 u_particleColor;uniform vec2 u_simpleShapeParameters;void main() {float t=clamp((length(uv)-u_simpleShapeParameters.x)/(1.0-u_simpleShapeParameters.x),0.0,1.0);float alpha=1.0-pow(t,pow(10.0,u_simpleShapeParameters.y));alpha*=alphaMultiplier;alpha*=u_particleColor.a;vec3 color=u_particleColor.rgb*alpha;glFragColor=vec4(color,alpha) ;HANDLE_WIREFRAME_DEBUG;}",`
3309in highp vec3 a_pos_3f;in highp vec2 a_uv;in highp vec4 a_snowParticleData;in highp vec4 a_snowParticleDataHorizontalOscillation;uniform mat4 u_modelview;uniform mat4 u_projection;uniform vec3 u_cam_pos;uniform vec2 u_screenSize;uniform float u_time;uniform float u_boxSize;uniform float u_velocityConeAperture; 
3310uniform float u_velocity;uniform vec3 u_direction;uniform float u_horizontalOscillationRadius; 
3311uniform float u_horizontalOscillationRate; 
3312uniform float u_billboardSize;uniform vec2 u_thinningCenterPos;uniform vec3 u_thinningShape;uniform float u_thinningAffectedRatio;uniform float u_thinningParticleOffset;out highp vec2 uv;out highp float alphaMultiplier;void main() {vec3 pos=a_pos_3f;float halfBoxSize=0.5*u_boxSize;pos.xyz*=halfBoxSize;pos+=u_cam_pos;float velocityConeApertureRad=radians(u_velocityConeAperture*0.5);float coneAnglePichRad=velocityConeApertureRad*a_snowParticleData.z;float coneAngleHeadingRad=a_snowParticleData.w*radians(360.0);vec3 localZ=normalize(u_direction);vec3 localX=normalize(cross(localZ,vec3(1,0,0)));vec3 localY=normalize(cross(localZ,localX));vec3 direction;direction.x=cos(coneAngleHeadingRad)*sin(coneAnglePichRad);direction.y=sin(coneAngleHeadingRad)*sin(coneAnglePichRad);direction.z=cos(coneAnglePichRad);direction=normalize(direction);vec3 simPosLocal=vec3(0,0,0);float velocityScale=(1.0+3.0*a_snowParticleData.y)*u_velocity;simPosLocal+=direction*velocityScale*u_time;float horizontalOscillationRadius=u_horizontalOscillationRadius*a_snowParticleDataHorizontalOscillation.x;float horizontalOscillationAngle=u_horizontalOscillationRate*u_time*(-1.0+2.0*a_snowParticleDataHorizontalOscillation.y);
3312simPosLocal.xy+=horizontalOscillationRadius*vec2(cos(horizontalOscillationAngle),sin(horizontalOscillationAngle));vec3 simPos=localX*simPosLocal.x+
3313localY*simPosLocal.y+localZ*simPosLocal.z;pos+=simPos;pos=fract((pos+vec3(halfBoxSize))/vec3(u_boxSize))*u_boxSize-vec3(halfBoxSize);float clipZ=-u_cam_pos.z+pos.z;vec4 posView=u_modelview*vec4(pos,1.0);float size=u_billboardSize;alphaMultiplier=1.0;vec4 posScreen=u_projection*posView;posScreen/=posScreen.w;posScreen.xy=vec2(0.5)+posScreen.xy*0.5;posScreen.xy*=u_screenSize;vec2 thinningCenterPos=u_thinningCenterPos.xy;thinningCenterPos.y=u_screenSize.y-thinningCenterPos.y;float screenDist=length((thinningCenterPos-posScreen.xy)/(0.5*u_screenSize));screenDist+=a_snowParticleData.x*u_thinningParticleOffset;float scaleFactorMode=0.0;float thinningShapeDist=u_thinningShape.x+u_thinningShape.y;if (screenDist < thinningShapeDist) {float thinningFadeRatio=clamp((screenDist-u_thinningShape.x)/u_thinningShape.y,0.0,1.0);thinningFadeRatio=pow(thinningFadeRatio,u_thinningShape.z);if (a_snowParticleData.x < u_thinningAffectedRatio) {scaleFactorMode=1.0-thinningFadeRatio;alphaMultiplier=thinningFadeRatio;}}vec4 posScreen1=u_projection*vec4(posView.x-size,posView.yzw);posScreen1/=posScreen1.w;vec4 posScreen2=u_projection*vec4(posView.x+size,posView.yzw);posScreen2/=posScreen2.w;posScreen1.xy=vec2(0.5)+posScreen1.xy*0.5;posScreen1.xy*=u_screenSize;posScreen2.xy=vec2(0.5)+posScreen2.xy*0.5;posScreen2.xy*=u_screenSize;float screenLength=length(posScreen1.xy-posScreen2.xy);float screenEpsilon=3.0;float scaleFactor=1.0;if (screenLength < screenEpsilon) {scaleFactor=screenEpsilon/max(screenLength,0.01);scaleFactor=mix(scaleFactor,1.0,scaleFactorMode);}float screenEpsilon2=15.0;if (screenLength > screenEpsilon2) {scaleFactor=screenEpsilon2/max(screenLength,0.01);}size*=scaleFactor;vec2 right=size*vec2(1,0);vec2 up=size*vec2(0,1);posView.xy+=right*a_uv.x;posView.xy+=up*a_uv.y;uv=a_uv;gl_Position=u_projection*posView;}`),rainParticle:Vt("in highp vec2 uv;in highp float particleRandomValue;uniform sampler2D u_texScreen;uniform float u_distortionStrength;uniform vec4 u_color;uniform vec2 u_thinningCenterPos;uniform vec3 u_thinningShape;uniform float u_thinningAffectedRatio;uniform float u_thinningParticleOffset;uniform float u_shapeDirectionalPower;uniform float u_mode;void main() {vec2 st=uv*0.5+vec2(0.5);vec2 uvm=uv;uvm.y=-1.0+2.0*pow(st.y,u_shapeDirectionalPower);float shape=clamp(1.0-length(uvm),0.0,1.0);float alpha=abs(shape)*u_color.a;vec2 screenSize=vec2(textureSize(u_texScreen,0));vec2 thinningCenterPos=u_thinningCenterPos.xy;thinningCenterPos.y=screenSize.y-thinningCenterPos.y;float screenDist=length((thinningCenterPos-gl_FragCoord.xy)/(0.5*screenSize));screenDist+=(0.5+0.5*particleRandomValue)*u_thinningParticleOffset;float thinningShapeDist=u_thinningShape.x+u_thinningShape.y;float thinningAlpha=1.0;if (screenDist < thinningShapeDist) {float thinningFadeRatio=clamp((screenDist-u_thinningShape.x)/u_thinningShape.y,0.0,1.0);thinningFadeRatio=pow(thinningFadeRatio,u_thinningShape.z);thinningAlpha*=thinningFadeRatio;}vec2 offsetXY=normalize(uvm)*abs(shape);vec2 stScreen=(gl_FragCoord.xy+offsetXY*u_distortionStrength*thinningAlpha)/screenSize;vec3 colorScreen=texture(u_texScreen,stScreen).rgb;alpha*=thinningAlpha;glFragColor=mix(vec4(colorScreen,1.0),vec4(u_color.rgb*alpha,alpha),u_mode);HANDLE_WIREFRAME_DEBUG;}",`
3314in highp vec3 a_pos_3f;in highp vec2 a_uv;in highp vec4 a_rainParticleData;uniform mat4 u_modelview;uniform mat4 u_projection;uniform vec3 u_cam_pos;uniform float u_time;uniform float u_boxSize;uniform float u_velocityConeAperture; 
3315uniform float u_velocity; 
3316uniform vec2 u_rainDropletSize;uniform vec3 u_rainDirection;out highp vec2 uv;out highp float particleRandomValue;void main() {vec3 pos=a_pos_3f;float halfBoxSize=0.5*u_boxSize;pos*=halfBoxSize; 
3317pos+=u_cam_pos;float velocityConeApertureRad=radians(u_velocityConeAperture*0.5);float coneAnglePichRad=velocityConeApertureRad*a_rainParticleData.z;float coneAngleHeadingRad=a_rainParticleData.w*radians(360.0);vec3 localZ=normalize(u_rainDirection);vec3 localX=normalize(cross(localZ,vec3(1,0,0)));vec3 localY=normalize(cross(localZ,localX));vec3 directionLocal;directionLocal.x=cos(coneAngleHeadingRad)*sin(coneAnglePichRad);directionLocal.y=sin(coneAngleHeadingRad)*sin(coneAnglePichRad);directionLocal.z=cos(coneAnglePichRad);directionLocal=normalize(directionLocal);vec3 directionWorld=localX*directionLocal.x+localY*directionLocal.y+localZ*directionLocal.z;float velocityScale=(1.0+3.0*a_rainParticleData.y)*u_velocity;vec3 simPosLocal=vec3(0,0,0);simPosLocal+=directionLocal*velocityScale*u_time;vec3 simPos=localX*simPosLocal.x+
3318localY*simPosLocal.y+localZ*simPosLocal.z;pos+=simPos;pos=fract((pos+vec3(halfBoxSize))/vec3(u_boxSize))*u_boxSize-vec3(halfBoxSize);vec4 posView=u_modelview*vec4(pos,1.0);vec3 directionView=normalize((u_modelview*vec4(directionWorld,0.0)).xyz);vec3 side=cross(directionView,normalize(posView.xyz));posView.xyz+=side*a_uv.x*u_rainDropletSize.x;posView.xyz+=directionView*a_uv.y*u_rainDropletSize.y;uv=a_uv;particleRandomValue=a_rainParticleData.x;gl_Position=u_projection*posView;}`),vignette:Vt("uniform vec3 u_vignetteShape;uniform vec4 u_vignetteColor;in vec2 st;void main() {float screenDist=length(st);float alpha=clamp((screenDist-u_vignetteShape.x)/u_vignetteShape.y,0.0,1.0);alpha=pow(alpha,u_vignetteShape.z)*u_vignetteColor.a;vec3 color=u_vignetteColor.rgb;glFragColor=vec4(color*alpha,alpha) ;}","in vec2 a_pos_2f;out vec2 st;void main() {st=a_pos_2f;gl_Position=vec4(a_pos_2f,0,1);}"),elevatedStructuresDepth:Vt("void main() {}","in ivec2 a_pos;in float a_height;uniform mat4 u_matrix;uniform float u_depth_bias;void main() {gl_Position=u_matrix*vec4(a_pos,a_height,1);gl_Position.z=gl_Position.z+u_depth_bias;}"),elevatedStructures:Vt(`#include "_prelude_fog.fragment.glsl"
3319#include "_prelude_lighting.glsl"
3320#include "_prelude_shadow.fragment.glsl"
3321#include "_prelude_indicator_cutout.fragment.glsl"
3322#include "_prelude_feature_cutout.fragment.glsl"
3323in vec3 v_normal;in float v_height;
3324#ifdef RENDER_SHADOWS
3325in highp vec4 v_pos_light_view_0;in highp vec4 v_pos_light_view_1;in float v_depth;
3326#endif
3327vec3 linearTosRGB(vec3 color) {return pow(color,vec3(1./2.2));}vec3 sRGBToLinear(vec3 srgbIn) {return pow(srgbIn,vec3(2.2));}
3327vec3 compute_view_dependent_emissive_color(float ndotl,float emissive_strength,vec3 color)
3328{color=sRGBToLinear(color);color=color*(ndotl+(1.0-min(ndotl*57.29,1.0))*emissive_strength);color=linearTosRGB(color.rgb);return color;}uniform float u_emissive_strength;uniform float u_opacity_multiplier;
3329#pragma mapbox: define highp vec4 structure_color
3330void main() {
3331#pragma mapbox: initialize highp vec4 structure_color
3332vec3 color=structure_color.xyz;vec2 cutout_factors=vec2(0.0);
3333#ifdef FEATURE_CUTOUT
3334cutout_factors=get_cutout_factors(gl_FragCoord);
3335#endif
3336#ifdef LIGHTING_3D_MODE
3337vec3 normal=normalize(v_normal);vec3 transformed_normal=vec3(-normal.xy,normal.z);float ndotl=calculate_NdotL(transformed_normal);float emissive_strength=u_emissive_strength;emissive_strength=0.0;vec3 emissive_color=compute_view_dependent_emissive_color(ndotl,emissive_strength,color.xyz);
3338#ifdef RENDER_SHADOWS
3339float light=shadowed_light_factor_normal(transformed_normal,v_pos_light_view_0,v_pos_light_view_1,v_depth);light=mix(light,1.0,cutout_factors.y);color.rgb=apply_lighting(color.rgb,transformed_normal,light);
3340#else
3341color=apply_lighting(color,transformed_normal);
3342#endif
3343color=mix(color,emissive_color,emissive_strength);if (v_height < 0.0) {float penetration=max(v_height+7.5,0.0);float occlusion=1.0-1.0/PI*acos(1.0-penetration/4.0);color=color*(1.0-pow(occlusion,2.0)*0.3);}
3344#endif
3345#ifdef FOG
3346color=fog_apply(color,v_fog_pos);
3347#endif
3348vec4 out_color=vec4(color,1.0);
3349#ifdef INDICATOR_CUTOUT
3350out_color=applyCutout(out_color,v_height);
3351#endif
3352#ifdef FEATURE_CUTOUT
3353out_color=apply_feature_cutout(out_color,gl_FragCoord,cutout_factors.x,v_height);
3354#endif
3355out_color*=u_opacity_multiplier;glFragColor=out_color;HANDLE_WIREFRAME_DEBUG;}`,`#include "_prelude_fog.vertex.glsl"
3356#include "_prelude_shadow.vertex.glsl"
3357in ivec2 a_pos;in float a_height;in ivec4 a_pos_normal_3;uniform mat4 u_matrix;out vec3 v_normal;out float v_height;
3358#ifdef RENDER_SHADOWS
3359uniform mat4 u_light_matrix_0;uniform mat4 u_light_matrix_1;out highp vec4 v_pos_light_view_0;out highp vec4 v_pos_light_view_1;out float v_depth;
3360#endif
3361#pragma mapbox: define highp vec4 structure_color
3362void main() {
3363#pragma mapbox: initialize highp vec4 structure_color
3364v_normal=vec3(a_pos_normal_3)/16384.0;v_height=a_height;vec3 pos=vec3(vec2(a_pos),a_height);gl_Position=u_matrix*vec4(pos,1);
3365#ifdef RENDER_SHADOWS
3366vec3 shd_pos0=pos;vec3 shd_pos1=pos;
3367#ifdef NORMAL_OFFSET
3368vec3 offset=shadow_normal_offset(vec3(-v_normal.xy,v_normal.z));shd_pos0+=offset*shadow_normal_offset_multiplier0();shd_pos1+=offset*shadow_normal_offset_multiplier1();
3369#endif
3370v_pos_light_view_0=u_light_matrix_0*vec4(shd_pos0,1);v_pos_light_view_1=u_light_matrix_1*vec4(shd_pos1,1);v_depth=gl_Position.w;
3371#endif
3372#ifdef FOG
3373v_fog_pos=fog_position(vec2(a_pos));
3374#endif
3375}`),elevatedStructuresDepthReconstruct:Vt(`#include "_prelude_feature_cutout.fragment.glsl"
3376#ifdef DEPTH_RECONSTRUCTION
3377in float v_height;
3378#endif
3379void main() {
3380#ifdef DEPTH_RECONSTRUCTION
3381if (v_height >=0.0)
3382discard;
3383#else
3384#ifdef FEATURE_CUTOUT
3385apply_feature_cutout(vec4(0.0,0.0,0.0,1.0),gl_FragCoord,get_cutout_factors(gl_FragCoord).x,0.0);
3386#endif
3387#endif
3388glFragColor=vec4(1.0,0.0,0.0,1.0);}`,`in ivec2 a_pos;in float a_height;uniform mat4 u_matrix;uniform vec3 u_camera_pos;uniform highp float u_depth_bias;uniform lowp float u_height_scale;uniform lowp float u_reset_depth;
3389#ifdef DEPTH_RECONSTRUCTION
3390out float v_height;
3391#endif
3392void main() {vec3 vpos=vec3(a_pos,a_height*u_height_scale);
3393#ifdef DEPTH_RECONSTRUCTION
3394if (u_camera_pos.z > vpos.z) {vpos-=(u_camera_pos-vpos)*(vpos.z/(u_camera_pos.z-vpos.z));}v_height=a_height;
3395#endif
3396gl_Position=u_matrix*vec4(vpos,1);gl_Position.z=u_reset_depth==1.0 ? gl_Position.w : gl_Position.z+u_depth_bias;}`)};Vt(ou,"");const Va=u.cR([{type:"Float32",name:"a_pos_3f",components:3},{type:"Float32",name:"a_uv",components:2},{type:"Float32",name:"a_rainParticleData",components:4}]),lf=u.cR([{type:"Float32",name:"a_pos_2f",components:2}]);class xh{destroy(){this.vignetteVx&&this.vignetteVx.destroy(),this.vignetteIdx&&this.vignetteIdx.destroy()}draw(t,n){const l=t.getOrCreateProgram("vignette");
vendor: 59,078 bytes, line 3396
3396if(!this.vignetteVx||!this.vignetteIdx){const m=new u.ds,g=new u.cp;m.emplaceBack(-1,-1),m.emplaceBack(1,-1),m.emplaceBack(1,1),m.emplaceBack(-1,1),g.emplaceBack(0,1,2),g.emplaceBack(0,2,3),this.vignetteVx=t.context.createVertexBuffer(m,lf.members),this.vignetteIdx=t.context.createIndexBuffer(g)}const d=u.cr.simpleSegment(0,0,4,6);if(this.vignetteVx&&this.vignetteIdx){t.uploadCommonUniforms(t.context,l);const m={u_vignetteShape:(p={vignetteShape:[n.start,n.range,Math.pow(10,n.fadePower)],vignetteColor:[n.color.r,n.color.g,n.color.b,n.color.a*n.strength]}).vignetteShape,u_vignetteColor:p.vignetteColor};l.draw(t,t.context.gl.TRIANGLES,ct.disabled,mt.disabled,yt.alphaBlended,_t.disabled,m,"vignette",this.vignetteVx,this.vignetteIdx,d)}var p}}class Fm{constructor(){this._accumulatedOffsetX=0,this._accumulatedOffsetY=0,this._accumulatedElevation=0}update(t,n){const l=t.getFreeCameraOptions().position,d=l.toAltitude(),p=l.toLngLat(),m=u.al(p.lng),g=u.al(p.lat),x=t.pixelsPerMeter/n,w=m*u.du,S=u.du*Math.log(Math.tan(Math.PI/4+g/2));if(this._offsetXPrev===void 0)this._offsetXPrev=0,this._offsetYPrev=0,this._elevationPrev=0,this._accumulatedOffsetX=0,this._accumulatedOffsetY=0,this._accumulatedElevation=0;else{const A=-this._offsetYPrev+S,I=-this._elevationPrev+d;this._accumulatedOffsetX+=(-this._offsetXPrev+w)*x,this._accumulatedOffsetY+=A*x,this._accumulatedElevation+=I*x,this._offsetXPrev=w,this._offsetYPrev=S,this._elevationPrev=d}}getPosition(){return[this._accumulatedOffsetX,this._accumulatedOffsetY,this._accumulatedElevation]}}function cf(s,t){return[-(s[0]-Math.floor(s[0]/t)*t),-(s[1]-Math.floor(s[1]/t)*t),-(s[2]-Math.floor(s[2]/t)*t)]}function vh(s){const t=u.dt(1323123451230),n=[];for(let l=0;l<s;++l){const d=2*t()-1,p=2*t()-1,m=2*t()-1;n.push(u.c6(d,p,m))}return n}function Xs(s,t,n,l,d){const p=u.as((d-n)/(l-n),0,1);return u.ai(s,t,p)}class Om{constructor(t){this._movement=new Fm,this._accumulatedTimeFromStart=0,this._prevTime=Date.now()/1e3,this._vignette=new xh,this._ppmScaleFactor=t}destroy(){this.particlesVx&&this.particlesVx.destroy(),this.particlesIdx&&this.particlesIdx.destroy(),this._vignette&&this._vignette.destroy()}updateOnRender(t,n){const l=t.transform;this._movement.update(l,this._ppmScaleFactor);const d=l.starsProjMatrix,p=u.az([]);u.aB(p,p,u.al(90)-l._pitch),u.aA(p,p,-l.angle);const m=u.aI(new Float32Array(16),p),g=new Float32Array([1,0,0,0,0,0,1,0,0,-1,0,0,0,0,0,1]),x=u.cl([],g),w=u.aP([],x,m),S=Date.now()/1e3;return this._accumulatedTimeFromStart+=(S-this._prevTime)*n,this._prevTime=S,{projectionMatrix:d,modelviewMatrix:w}}}const km=u.cR([{type:"Float32",name:"a_pos_3f",components:3},{type:"Float32",name:"a_uv",components:2},{type:"Float32",name:"a_snowParticleData",components:4},{type:"Float32",name:"a_snowParticleDataHorizontalOscillation",components:2}]),su=(s,t)=>({u_matrix:s,u_depth_bias:t}),Qg=(s,t)=>({u_matrix:s,u_ground_shadow_factor:t,u_opacity_multiplier:1}),bh=(s,t,n,l,d)=>({u_matrix:s,u_camera_pos:[t[0],t[1],t[2]],u_depth_bias:n,u_height_scale:l,u_reset_depth:d}),Bm={building:s=>({u_matrix:new u.ap(s),u_normal_matrix:new u.ap(s),u_opacity:new u.ar(s),u_faux_facade_ao_intensity:new u.ar(s),u_camera_pos:new u.aq(s),u_tile_to_meter:new u.ar(s),u_facade_emissive_chance:new u.ar(s),u_flood_light_color:new u.aq(s),u_flood_light_intensity:new u.ar(s),u_front_cutoff_params:new u.aq(s)}),buildingBloom:s=>({u_matrix:new u.ap(s)}),buildingDepth:s=>({u_matrix:new u.ap(s)}),elevatedStructuresDepth:s=>({u_matrix:new u.ap(s),u_depth_bias:new u.ar(s)}),elevatedStructures:s=>({u_matrix:new u.ap(s),u_ground_shadow_factor:new u.aq(s),u_opacity_multiplier:new u.ar(s)}),elevatedStructuresDepthReconstruct:s=>({u_matrix:new u.ap(s),u_camera_pos:new u.aq(s),u_depth_bias:new u.ar(s),u_height_scale:new u.ar(s),u_reset_depth:new u.ar(s)}),rasterParticle:s=>({u_matrix:new u.ap(s),u_normalize_matrix:new u.ap(s),u_globe_matrix:new u.ap(s),u_merc_matrix:new u.ap(s),u_grid_matrix:new u.cN(s),u_tl_parent:new u.b$(s),u_scale_parent:new u.ar(s),u_fade_t:new u.ar(s),u_opacity:new u.ar(s),u_image0:new u.b_(s),u_image1:new u.b_(s),u_raster_elevation:new u.ar(s),u_zoom_transition:new u.ar(s),u_merc_center:new u.b$(s),u_cutoff_params:new u.bZ(s)}),rasterParticleTexture:s=>({u_texture:new u.b_(s),u_opacity:new u.ar(s)}),rasterParticleDraw:s=>({u_particle_texture:new u.b_(s),u_particle_texture_side_len:new u.ar(s),u_tile_offset:new u.b$(s),u_velocity:new u.b_(s),u_color_ramp:new u.b_(s),u_velocity_res:new u.b$(s),u_max_speed:new u.ar(s),u_uv_offset:new u.b$(s),u_data_scale:new u.b$(s),u_data_offset:new u.ar(s),u_particle_pos_scale:new u.ar(s),u_particle_pos_offset:new u.b$(s)}),rasterParticleUpdate:s=>({u_particle_texture:new u.b_(s),u_particle_texture_side_len:new u.ar(s),u_velocity:new u.b_(s),u_velocity_res:new u.b$(s),u_max_speed:new u.ar(s),u_speed_factor:new u.ar(s),u_reset_rate:new u.ar(s),u_rand_seed:new u.ar(s),u_uv_offset:new u.b$(s),u_data_scale:new u.b$(s),u_data_offset:new u.ar(s),u_particle_pos_scale:new u.ar(s),u_particle_pos_offset:new u.b$(s)}),snowParticle:s=>({u_modelview:new u.ap(s),u_projection:new u.ap(s),u_time:new u.ar(s),u_cam_pos:new u.aq(s),u_velocityConeAperture:new u.ar(s),u_velocity:new u.ar(s),u_horizontalOscillationRadius:new u.ar(s),u_horizontalOscillationRate:new u.ar(s),u_boxSize:new u.ar(s),u_billboardSize:new u.ar(s),u_simpleShapeParameters:new u.b$(s),u_screenSize:new u.b$(s),u_thinningCenterPos:new u.b$(s),u_thinningShape:new u.aq(s),u_thinningAffectedRatio:new u.ar(s),u_thinningParticleOffset:new u.ar(s),u_particleColor:new u.bZ(s),u_direction:new u.aq(s)}),rainParticle:s=>({u_modelview:new u.ap(s),u_projection:new u.ap(s),u_time:new u.ar(s),u_cam_pos:new u.aq(s),u_texScreen:new u.b_(s),u_velocityConeAperture:new u.ar(s),u_velocity:new u.ar(s),u_boxSize:new u.ar(s),u_rainDropletSize:new u.b$(s),u_distortionStrength:new u.ar(s),u_rainDirection:new u.aq(s),u_color:new u.bZ(s),u_screenSize:new u.b$(s),u_thinningCenterPos:new u.b$(s),u_thinningShape:new u.aq(s),u_thinningAffectedRatio:new u.ar(s),u_thinningParticleOffset:new u.ar(s),u_shapeDirectionalPower:new u.ar(s),u_shapeNormalPower:new u.ar(s),u_mode:new u.ar(s)}),vignette:s=>({u_vignetteShape:new u.aq(s),u_vignetteColor:new u.bZ(s)})};function Nm(s,t){const n=1<<s.canonical.z,l=(t.x*n-s.canonical.x-s.wrap*n)*u.aj,d=(t.y*n-s.canonical.y)*u.aj,p=u.dx(t.z,t.y);return u.c6(l,d,p)}function uf(s){let t=0;for(const n of s)t|=n.frcMask;return t}class au{constructor(t=[]){this.tiles=t}getTile(t){for(const n of this.tiles)if(n.tileId.z===t.z&&n.tileId.x===t.x&&n.tileId.y===t.y)return n;return null}getTileOrParent(t){for(let n=t.z;n>0;--n){const l=Math.floor(t.x/(1<<t.z-n)),d=Math.floor(t.y/(1<<t.z-n));for(const p of this.tiles)if(p.tileId.z===n&&p.tileId.x===l&&p.tileId.y===d&&p.frcMask!==0)return p}return null}getFullCoverageMask(t){let n=null,l=0;for(let A=t.z;A>0;--A){const I=Math.floor(t.x/(1<<t.z-A)),M=Math.floor(t.y/(1<<t.z-A));for(const D of this.tiles)if(D.tileId.z===A&&D.tileId.x===I&&D.tileId.y===M){n=D,l=A;break}if(n)break}if(!n||n.frcMask===0)return null;const d=1<<t.z-l,p=u.aj/d,m=t.x%d*p,g=t.y%d*p,x=m+p,w=g+p;let S=0;for(const A of n.polygons)A.frcMask!==0&&(A.hasGeometry()?A.rings.length===0||t.z<=l||xc(A.rings,m,g,x,w)&&(S|=A.frcMask):S|=A.frcMask);return S!==0?S:null}equals(t){if(this.tiles.length!==t.length)return!1;for(let n=0;n<this.tiles.length;++n){const l=this.tiles[n],d=t[n];if(l.tileId.z!==d.tileId.z||l.tileId.x!==d.tileId.x||l.tileId.y!==d.tileId.y||l.frcMask!==d.frcMask||l.polygons.length!==d.polygons.length)return!1}return!0}empty(){return this.tiles.length===0}}function xc(s,t,n,l,d){const p=[0,0,0,0],m=[t,l,l,t],g=[n,n,d,d];for(const x of s){const w=x.length;if(!(w<2))for(let S=0,A=w-1;S<w;A=S++){const I=x[A].x,M=x[A].y,D=x[S].x,L=x[S].y;for(let $=0;$<4;++$)M>g[$]!=L>g[$]&&m[$]<I+(D-I)*(g[$]-M)/(L-M)&&p[$]++;let k=0,B=0;if(I<t?k|=1:I>l&&(k|=2),M<n?k|=4:M>d&&(k|=8),D<t?B|=1:D>l&&(B|=2),L<n?B|=4:L>d&&(B|=8),!(k&B)&&(k===0||B===0||wh(I,M,D,L,t,n,l,d)))return!1}}for(let x=0;x<4;++x)if(!(1&p[x]))return!1;return!0}function wh(s,t,n,l,d,p,m,g){const x=(w,S,A,I,M,D,L,k)=>{const B=(A-w)*(D-S)-(I-S)*(M-w),$=(A-w)*(k-S)-(I-S)*(L-w);if(B>0&&$>0||B<0&&$<0)return!1;const Z=(L-M)*(S-D)-(k-D)*(w-M),G=(L-M)*(I-D)-(k-D)*(A-M);return!(Z>0&&G>0||Z<0&&G<0)};return!!(x(s,t,n,l,d,p,m,p)||x(s,t,n,l,m,p,m,g)||x(s,t,n,l,d,g,m,g)||x(s,t,n,l,d,p,d,g))}class lu{constructor(){this._tileCoverages=[],this._snapshot=new au}clear(){this._tileCoverages=[]}addTileCoverage(t,n){this._tileCoverages.push({tileId:t,polygons:n,frcMask:uf(n)})}empty(){return this._tileCoverages.length===0}updateSnapshotIfNeeded(){if(this._snapshot.equals(this._tileCoverages))return this._snapshot;const t=this._tileCoverages.map(n=>({tileId:n.tileId,polygons:n.polygons,frcMask:n.frcMask}));return this._snapshot=new au(t),this._snapshot}}class Vm{constructor(t,n){this.max=t,this.onRemove=n,this.reset()}reset(){for(const t in this.data)for(const n of this.data[t])n.timeout&&clearTimeout(n.timeout),this.onRemove(n.value);return this.data={},this.order=[],this}add(t,n,l){const d=t.wrapped().key;this.data[d]===void 0&&(this.data[d]=[]);const p={value:n,timeout:void 0};if(l!==void 0&&(p.timeout=setTimeout(()=>{this.remove(t,p)},l)),this.data[d].push(p),this.order.push(d),this.order.length>this.max){const m=this._getAndRemoveByKey(this.order[0]);m&&this.onRemove(m)}return this}has(t){return t.wrapped().key in this.data}getAndRemove(t){return this.has(t)?this._getAndRemoveByKey(t.wrapped().key):null}_getAndRemoveByKey(t){const n=this.data[t].shift();return n.timeout&&clearTimeout(n.timeout),this.data[t].length===0&&delete this.data[t],this.order.splice(this.order.indexOf(t),1),n.value}getByKey(t){const n=this.data[t];return n?n[0].value:null}get(t){return this.has(t)?this.data[t.wrapped().key][0].value:null}remove(t,n){if(!this.has(t))return this;const l=t.wrapped().key,d=n===void 0?0:this.data[l].indexOf(n),p=this.data[l][d];return this.data[l].splice(d,1),p.timeout&&clearTimeout(p.timeout),this.data[l].length===0&&delete this.data[l],this.onRemove(p.value),this.order.splice(this.order.indexOf(l),1),this}setMaxSize(t){for(this.max=t;this.order.length>this.max;){const n=this._getAndRemoveByKey(this.order[0]);n&&this.onRemove(n)}return this}filter(t){const n=[];for(const l in this.data)for(const d of this.data[l])t(d.value)||n.push(d);for(const l of n)this.remove(l.value.tileID,l)}}class Th{constructor(){this.state=Object.create(null),this.stateChanges=Object.create(null),this.deletedStates=Object.create(null)}updateState(t,n,l){const d=String(n);if(this.stateChanges[t]=this.stateChanges[t]||Object.create(null),this.stateChanges[t][d]=this.stateChanges[t][d]||Object.create(null),Object.assign(this.stateChanges[t][d],l),this.deletedStates[t]===null){this.deletedStates[t]=Object.create(null);for(const p in this.state[t])p!==d&&(this.deletedStates[t][p]=null)}else if(this.deletedStates[t]&&this.deletedStates[t][d]===null){this.deletedStates[t][d]=Object.create(null);for(const p in this.state[t][d])l[p]||(this.deletedStates[t][d][p]=null)}else for(const p in l)this.deletedStates[t]&&this.deletedStates[t][d]&&this.deletedStates[t][d][p]===null&&delete this.deletedStates[t][d][p]}removeFeatureState(t,n,l){if(this.deletedStates[t]===null)return;const d=String(n);if(this.deletedStates[t]=this.deletedStates[t]||Object.create(null),l&&n!==void 0)this.deletedStates[t][d]!==null&&(this.deletedStates[t][d]=this.deletedStates[t][d]||Object.create(null),this.deletedStates[t][d][l]=null);else if(n!==void 0)if(this.stateChanges[t]&&this.stateChanges[t][d])for(l in this.deletedStates[t][d]=Object.create(null),this.stateChanges[t][d])this.deletedStates[t][d][l]=null;else this.deletedStates[t][d]=null;else this.deletedStates[t]=null}getState(t,n){const l=this.state[t]||Object.create(null),d=this.stateChanges[t]||Object.create(null),p=this.deletedStates[t];if(p===null)return Object.create(null);if(n!==void 0){const g=String(n),x=Object.assign(Object.create(null),l[g],d[g]);if(p){const w=p[n];if(w===null)return Object.create(null);for(const S in w)delete x[S]}return x}const m=Object.assign(Object.create(null),l,d);if(p)for(const g in p)delete m[g];return m}initializeTileState(t,n){t.refreshFeatureState(n)}coalesceChanges(t,n){const l=Object.create(null);for(const d in this.stateChanges){this.state[d]=this.state[d]||Object.create(null);const p=Object.create(null);for(const m in this.stateChanges[d])this.state[d][m]||(this.state[d][m]=Object.create(null)),Object.assign(this.state[d][m],this.stateChanges[d][m]),p[m]=this.state[d][m];l[d]=p}for(const d in this.deletedStates){this.state[d]=this.state[d]||Object.create(null);const p=Object.create(null);if(this.deletedStates[d]===null)for(const m in this.state[d])p[m]=Object.create(null),this.state[d][m]=Object.create(null);else for(const m in this.deletedStates[d]){if(this.deletedStates[d][m]===null)this.state[d][m]=Object.create(null);else if(this.state[d][m])for(const g of Object.keys(this.deletedStates[d][m]))delete this.state[d][m][g];p[m]=this.state[d][m]}l[d]=l[d]||Object.create(null),Object.assign(l[d],p)}if(this.stateChanges=Object.create(null),this.deletedStates=Object.create(null),Object.keys(l).length!==0)for(const d in t)t[d].refreshFeatureState(n,l)}}class $n extends u.E{constructor(t,n,l){super(),this.id=t,this._renderSourceType=l,this._maxzoomOverride=null,n.on("data",d=>{d.dataType==="source"&&d.sourceDataType==="metadata"&&(this._sourceLoaded=!0),this._sourceLoaded&&!this._paused&&d.dataType==="source"&&d.sourceDataType==="content"&&(this.reload(),this.transform&&this.update(this.transform))}),n.on("error",()=>{this._sourceErrored=!0}),this._source=n,this._tiles={},this._cache=new Vm(0,this._unloadTile.bind(this)),this._timers={},this._cacheTimers={},this._minTileCacheSize=n.minTileCacheSize,this._maxTileCacheSize=n.maxTileCacheSize,this._loadedParentTiles={},this.castsShadows=!1,this.tileCoverLift=0,this._coveredTiles={},this._shadowCasterTiles={},this._state=new Th,this._isRaster=this._source.type==="raster"||this._source.type==="raster-dem"||this._source.type==="raster-array"||this._source.type==="custom"&&"_dataType"in this._source&&this._source._dataType==="raster",this._supportsFading=this._source.type==="raster"||this._source.type==="raster-array"||this._source.type==="image"||this._source.type==="video"||this._source.type==="custom",this._isRasterElevatedOverTerrain=!1}onAdd(t){this.map=t,this._minTileCacheSize=this._minTileCacheSize===void 0&&t?t._minTileCacheSize:this._minTileCacheSize,this._maxTileCacheSize=this._maxTileCacheSize===void 0&&t?t._maxTileCacheSize:this._maxTileCacheSize}loaded(){if(this._sourceErrored)return!0;if(!this._sourceLoaded||!this._source.loaded())return!1;for(const t in this._tiles)if(!this._tiles[t].loaded())return!1;return!0}getSource(){return this._source}pause(){this._paused=!0}resume(){if(!this._paused)return;const t=this._shouldReloadOnResume;this._paused=!1,this._shouldReloadOnResume=!1,t&&this.reload(),this.transform&&this.update(this.transform)}setMaxzoomOverride(t){this._maxzoomOverride=t}_loadTile(t,n){return t.renderSourceType=this._renderSourceType,t.isExtraShadowCaster=this._shadowCasterTiles[t.tileID.key],this._source.loadTile(t,n)}_unloadTile(t){if(this._source.unloadTile)return this._source.unloadTile(t)}_abortTile(t){if(this._source.abortTile)return this._source.abortTile(t)}serialize(){return this._source.serialize()}prepare(t){this._source.prepare&&this._source.prepare(),this._state.coalesceChanges(this._tiles,this.map?this.map.painter:null);for(const n in this._tiles){const l=this._tiles[n];l.upload(t,this.map?this.map.painter:void 0),l.prepare(this.map.style.imageManager,this.map?this.map.painter:null,this._source.scope)}}getIds(){return Object.values(this._tiles).map(t=>t.tileID).sort(vc).map(t=>t.key)}getRenderableIds(t,n){const l=[];for(const d in this._tiles)this._isIdRenderable(+d,t,n)&&l.push(this._tiles[d]);return t?l.sort((d,p)=>{const m=d.tileID,g=p.tileID,x=new u.P(m.canonical.x,m.canonical.y)._rotate(this.transform.angle),w=new u.P(g.canonical.x,g.canonical.y)._rotate(this.transform.angle);return m.overscaledZ-g.overscaledZ||w.y-x.y||w.x-x.x}).map(d=>d.tileID.key):l.map(d=>d.tileID).sort(vc).map(d=>d.key)}hasRenderableParent(t){const n=this.findLoadedParent(t,0);return!!n&&this._isIdRenderable(n.tileID.key)}_isIdRenderable(t,n,l){return this._tiles[t]&&this._tiles[t].hasData()&&!this._coveredTiles[t]&&(n||!this._tiles[t].holdingForFade())&&(l||!this._shadowCasterTiles[t])}reload(){if(this._paused)this._shouldReloadOnResume=!0;else{this._cache.reset();for(const t in this._tiles)this._tiles[t].state!=="errored"&&this._reloadTile(+t,"reloading")}}_reloadTile(t,n){const l=this._tiles[t];l&&(l.state!=="loading"&&(l.state=n),this._loadTile(l,this._tileLoaded.bind(this,l,t,n)))}_tileLoaded(t,n,l,d,p){if(d){if(t.state="errored",u.dy(d)){if(this._source.fire(new u.B("data",{dataType:"source",sourceDataType:"error",sourceId:this._source.id,tile:t})),!(t.tileID.key in this._loadedParentTiles))return;if(this._source.type==="raster-dem"&&this.usedForTerrain&&this.map.painter.terrain){const g=this.map.painter.terrain;this.update(this.transform,g.getScaledDemTileSize(),!0),g.resetTileLookupCache(this.id)}else this.update(this.transform)}else this._source.fire(new u.A(d,{tile:t}));return}t.timeAdded=u.r.now(),l==="expired"&&(t.refreshedUponExpiration=!0),this._setTileReloadTimer(n,t),this._source.type==="raster-dem"&&t.dem&&this._backfillDEM(t),this._state.initializeTileState(t,this.map?this.map.painter:null);let m=new Headers;p&&p.headers&&(m=p.headers),this._source.fire(new u.B("data",{dataType:"source",tile:t,coord:t.tileID,sourceCacheId:this.id,responseHeaders:m}))}_hasTunnelGeometry(){for(const t in this._tiles){const n=this._tiles[t];if(n&&n.hasTunnelGeometry)return!0}return!1}_backfillDEM(t){const n=this.getRenderableIds();for(let d=0;d<n.length;d++){const p=n[d];if(t.neighboringTiles&&t.neighboringTiles[p]){const m=this.getTileByID(p);l(t,m),l(m,t)}}function l(d,p){if(!d.dem||d.dem.borderReady)return;d.needsHillshadePrepare=!0,d.needsDEMTextureUpload=!0;let m=p.tileID.canonical.x-d.tileID.canonical.x;const g=p.tileID.canonical.y-d.tileID.canonical.y,x=Math.pow(2,d.tileID.canonical.z),w=p.tileID.key;m===0&&g===0||Math.abs(g)>1||(Math.abs(m)>1&&(Math.abs(m+x)===1?m+=x:Math.abs(m-x)===1&&(m-=x)),p.dem&&d.dem&&(d.dem.backfillBorder(p.dem,m,g),d.neighboringTiles&&d.neighboringTiles[w]&&(d.neighboringTiles[w].backfilled=!0)))}}getTile(t){return this.getTileByID(t.key)}getTileByID(t){return this._tiles[t]}_retainLoadedChildren(t,n,l,d){for(const p in this._tiles){let m=this._tiles[p];if(d[p]||!m.hasData()||m.tileID.overscaledZ<=n||m.tileID.overscaledZ>l)continue;let g=m.tileID;for(;m&&m.tileID.overscaledZ>n+1;){const w=m.tileID.scaledTo(m.tileID.overscaledZ-1);m=this._tiles[w.key],m&&m.hasData()&&(g=w)}let x=g;for(;x.overscaledZ>n;)if(x=x.scaledTo(x.overscaledZ-1),t[x.key]){d[g.key]=g;break}}}findLoadedParent(t,n){if(t.key in this._loadedParentTiles){const l=this._loadedParentTiles[t.key];return l&&l.tileID.overscaledZ>=n?l:null}for(let l=t.overscaledZ-1;l>=n;l--){const d=t.scaledTo(l),p=this._getLoadedTile(d);if(p)return p}}_getLoadedTile(t){const n=this._tiles[t.key];return n&&n.hasData()?n:this._cache.getByKey(this._source.reparseOverscaled?t.wrapped().key:t.canonical.key)}updateCacheSize(t,n){n=n||this._source.tileSize;const l=Math.ceil(t.width/n)+1,d=Math.ceil(t.height/n)+1,p=Math.floor(l*d*5),m=typeof this._minTileCacheSize=="number"?Math.max(this._minTileCacheSize,p):p,g=typeof this._maxTileCacheSize=="number"?Math.min(this._maxTileCacheSize,m):m;this._cache.setMaxSize(g)}handleWrapJump(t){const n=Math.round((t-(this._prevLng===void 0?t:this._prevLng))/360);if(this._prevLng=t,n){const l={};for(const d in this._tiles){const p=this._tiles[d];p.tileID=p.tileID.unwrapTo(p.tileID.wrap+n),l[p.tileID.key]=p}this._tiles=l;for(const d in this._timers)clearTimeout(this._timers[d]),delete this._timers[d];for(const d in this._tiles)this._setTileReloadTimer(+d,this._tiles[d])}}update(t,n,l,d,p){if(this.transform=t,!this._sourceLoaded||this._paused||this.transform.freezeTileCoverage||this.usedForTerrain&&!l)return;this.updateCacheSize(t,n),this.transform.projection.name!=="globe"&&this.handleWrapJump(this.transform.center.lng),this._shadowCasterTiles={},this._coveredTiles={};const m=this._source.type==="batched-model";let g,x=this._source.maxzoom;this._maxzoomOverride!==null&&(x=Math.min(x,this._maxzoomOverride));const w=this.map&&this.map.painter?this.map.painter._terrain:null;if(w&&w.sourceCache===this&&w.attenuationRange()){const M=w.attenuationRange()[0],D=Math.floor(M)-Math.log2(w.getDemUpscale());x>D&&(x=D)}const S=this._maxzoomOverride===null&&this._source.reparseOverscaled;if(this.used||this.usedForTerrain){if(this._source.tileID)g=t.getVisibleUnwrappedCoordinates(this._source.tileID).map(M=>new u.br(M.canonical.z,M.wrap,M.canonical.z,M.canonical.x,M.canonical.y));else if(this.tileCoverLift!==0){const M=t.clone();M.tileCoverLift=this.tileCoverLift,g=M.coveringTiles({tileSize:n||this._source.tileSize,minzoom:this._source.minzoom,maxzoom:x,roundZoom:this._source.roundZoom&&!l,reparseOverscaled:S,isTerrainDEM:this.usedForTerrain,calculateQuadrantVisibility:m}),this._source.minzoom<=1&&t.projection.name==="globe"&&(g.push(new u.br(1,0,1,0,0)),g.push(new u.br(1,0,1,1,0)),g.push(new u.br(1,0,1,0,1)),g.push(new u.br(1,0,1,1,1)))}else if(g=t.coveringTiles({tileSize:n||this._source.tileSize,minzoom:this._source.minzoom,maxzoom:x,roundZoom:this._source.roundZoom&&!l,reparseOverscaled:S,isTerrainDEM:this.usedForTerrain,calculateQuadrantVisibility:m}),this._source.hasTile){const M=this._source.hasTile.bind(this._source);g=g.filter(D=>M(D))}}else g=[];if(g.length>0&&this.transform.projection.name!=="globe"&&!this.usedForTerrain&&!this._supportsFading){const M=t.coveringZoomLevel({tileSize:n||this._source.tileSize,roundZoom:this._source.roundZoom&&!l}),D=Math.min(M,x);if(m){const L=t.extendTileCover(g,D);for(const k of L)g.push(k)}else if(p){const L=this.transform.getFrustum(D),k=t.extendTileCoverToNearPlane(g,L,D);for(const B of k)g.push(B);if(D>=18&&this._hasTunnelGeometry()){const B=t.extendTileCoverForTunnels(g,L,D,20);for(const $ of B)g.push($)}}else if(this.castsShadows&&d){const L=t.extendTileCover(g,D,d,16);for(const k of L)this._shadowCasterTiles[k.key]=!0,g.push(k)}}const A=this._updateRetainedTiles(g);if(this._supportsFading&&g.length!==0){const M={},D={},L=u.r.now(),k=Object.keys(A);for(const $ of k){const Z=A[$],G=this._tiles[$];if(!G||G.fadeEndTime!==void 0&&G.fadeEndTime<=L)continue;const te=this.findLoadedParent(Z,Math.max(Z.overscaledZ-$n.maxOverzooming,this._source.minzoom));te&&(this._addTile(te.tileID),M[te.tileID.key]=te.tileID),D[$]=Z}const B=g.at(-1).overscaledZ;for(const $ in this._tiles){const Z=this._tiles[$];if(A[$]||!Z.hasData())continue;let G=Z.tileID;for(;G.overscaledZ>B;){G=G.scaledTo(G.overscaledZ-1);const te=this._tiles[G.key];if(te&&te.hasData()&&D[G.key]){A[$]=Z.tileID;break}}}for(const $ in M)A[$]||(this._coveredTiles[$]=!0,A[$]=M[$])}for(const M in A)this._tiles[M].clearFadeHold();const I=u.dz(this._tiles,A);for(const M of I){const D=this._tiles[M];D.hasSymbolBuckets&&!D.holdingForFade()?D.setHoldDuration(this.map._fadeDuration):D.hasSymbolBuckets&&!D.symbolFadeFinished()||this._removeTile(+M)}this._updateLoadedParentTileCache(),this._renderSourceType===u.dA.Symbol&&this._source.afterUpdate&&this._source.afterUpdate()}releaseSymbolFadeTiles(){for(const t in this._tiles)this._tiles[t].holdingForFade()&&this._removeTile(+t)}_updateRetainedTiles(t){const n={};if(t.length===0)return n;const l={},d=t.reduce((w,S)=>Math.min(w,S.overscaledZ),1/0),p=t[0].overscaledZ,m=Math.max(p-$n.maxOverzooming,this._source.minzoom),g=Math.max(p+$n.maxUnderzooming,this._source.minzoom),x={};for(const w of t){const S=this._addTile(w);n[w.key]=w,S.hasData()||d<this._source.maxzoom&&(x[w.key]=w)}this._retainLoadedChildren(x,d,g,n);for(const w of t){let S=this._tiles[w.key];if(S.hasData())continue;if(w.canonical.z>=this._source.maxzoom){const I=w.children(this._source.maxzoom)[0],M=this.getTile(I);if(M&&M.hasData()){n[I.key]=I;continue}}else{const I=w.children(this._source.maxzoom);if(n[I[0].key]&&n[I[1].key]&&n[I[2].key]&&n[I[3].key])continue}let A=S.wasRequested();for(let I=w.overscaledZ-1;I>=m;--I){const M=w.scaledTo(I);if(l[M.key]||(l[M.key]=!0,S=this.getTile(M),!S&&A&&(S=this._addTile(M)),S&&(n[M.key]=M,A=S.wasRequested(),S.hasData())))break}}return n}_updateLoadedParentTileCache(){this._loadedParentTiles={};for(const t in this._tiles){const n=[];let l,d=this._tiles[t].tileID;for(;d.overscaledZ>0;){if(d.key in this._loadedParentTiles){l=this._loadedParentTiles[d.key];break}n.push(d.key);const p=d.scaledTo(d.overscaledZ-1);if(l=this._getLoadedTile(p),l)break;d=p}for(const p of n)this._loadedParentTiles[p]=l}}_addTile(t){let n=this._tiles[t.key];if(n)return n.isExtraShadowCaster!==!0||this._shadowCasterTiles[t.key]||this._reloadTile(t.key,"reloading"),n;n=this._cache.getAndRemove(t),n&&(this._setTileReloadTimer(t.key,n),n.tileID=t,this._state.initializeTileState(n,this.map?this.map.painter:null),this._cacheTimers[t.key]&&(clearTimeout(this._cacheTimers[t.key]),delete this._cacheTimers[t.key],this._setTileReloadTimer(t.key,n)));const l=!!n;if(!l){const d=this.map?this.map.painter:null,p=this._source.tileSize*t.overscaleFactor();n=this._source.type==="raster-array"?new af(t,p,this.transform.tileZoom,d,this._isRaster):new _c(t,p,this.transform.tileZoom,d,this._isRaster,this._source.worldview),this._loadTile(n,this._tileLoaded.bind(this,n,t.key,n.state))}return n.uses++,this._tiles[t.key]=n,l||this._source.fire(new u.B("dataloading",{tile:n,coord:n.tileID,dataType:"source"})),n}_setTileReloadTimer(t,n){t in this._timers&&(clearTimeout(this._timers[t]),delete this._timers[t]);const l=n.getExpiryTimeout();l&&(this._timers[t]=setTimeout(()=>{this._reloadTile(t,"expired"),delete this._timers[t]},l))}_removeTile(t){const n=this._tiles[t];n&&(n.uses--,delete this._tiles[t],this._timers[t]&&(clearTimeout(this._timers[t]),delete this._timers[t]),n.uses>0||(n.hasData()&&n.state!=="reloading"||n.state==="empty"?this._cache.add(n.tileID,n,n.getExpiryTimeout()):(n.aborted=!0,this._abortTile(n),this._unloadTile(n))))}clearTiles(){this._shouldReloadOnResume=!1,this._paused=!1;for(const t in this._tiles)this._removeTile(+t);this._source._clear&&this._source._clear(),this._cache.reset(),this.map&&this.usedForTerrain&&this.map.painter.terrain&&this.map.painter.terrain.resetTileLookupCache(this.id)}tilesIn(t,n,l){const d=[],p=this.transform;if(!p)return d;const m=p.projection.name==="globe",g=u.a_(p.center.lng),x=p.getFreeCameraOptions().position||new u.ac(0,0,0);for(const w in this._tiles){const S=this._tiles[w];if(l&&S.clearQueryDebugViz(),S.holdingForFade())continue;let A;if(m){const I=S.tileID.canonical;if(I.z===0){const M=[Math.abs(u.as(g,...Ua(I,-1))-g),Math.abs(u.as(g,...Ua(I,1))-g)];A=[0,2*M.indexOf(Math.min(...M))-1]}else{const M=[Math.abs(u.as(g,...Ua(I,-1))-g),Math.abs(u.as(g,...Ua(I,0))-g),Math.abs(u.as(g,...Ua(I,1))-g)];A=[M.indexOf(Math.min(...M))-1]}}else A=[0];for(const I of A){const M=t.containsTile(S,p,n,I,x);M&&d.push(M)}}return d}getShadowCasterCoordinates(){return this._getRenderableCoordinates(!1,!0)}getVisibleCoordinates(t){return this._getRenderableCoordinates(t)}_getRenderableCoordinates(t,n){if(!this.transform)return[];const l=this.getRenderableIds(t,n).map(p=>this._tiles[p].tileID),d=this.transform.projection.name==="globe";for(const p of l)p.projMatrix=this.transform.calculateProjMatrix(p.toUnwrapped()),p.expandedProjMatrix=d?this.transform.calculateProjMatrix(p.toUnwrapped(),!1,!0):p.projMatrix;return l}sortCoordinatesByDistance(t){if(!this.transform)return t.slice();const n=t.slice(),l=this.transform._camera.position,d=this.transform._camera.forward(),p={};for(const m of n){const g=1/(1<<m.canonical.z);p[m.key]=((m.canonical.x+.5)*g+m.wrap-l[0])*d[0]+((m.canonical.y+.5)*g-l[1])*d[1]-l[2]*d[2]}return n.sort((m,g)=>p[m.key]-p[g.key]),n}hasTransition(){if(this._source.hasTransition())return!0;if(this._supportsFading){const t=u.r.now();for(const n in this._tiles){const l=this._tiles[n];if(l.fadeEndTime!==void 0&&l.fadeEndTime>=t)return!0}}return!1}setFeatureState(t,n,l){this._state.updateState(t=t||"_geojsonTileLayer",n,l)}removeFeatureState(t,n,l){this._state.removeFeatureState(t=t||"_geojsonTileLayer",n,l)}getFeatureState(t,n){return this._state.getState(t=t||"_geojsonTileLayer",n)}setDependencies(t,n,l){const d=this._tiles[t];d&&d.setDependencies(n,l)}reloadTilesForDependencies(t,n){for(const l in this._tiles)this._tiles[l].hasDependency(t,n)&&this._reloadTile(+l,"reloading");this._cache.filter(l=>!l.hasDependency(t,n))}_preloadTiles(t,n){if(!this._sourceLoaded){const x=()=>{this._sourceLoaded&&(this._source.off("data",x),this._preloadTiles(t,n))};return void this._source.on("data",x)}const l=new Map,d=Array.isArray(t)?t:[t],p=this.map.painter.terrain,m=this.usedForTerrain&&p?p.getScaledDemTileSize():this._source.tileSize;for(const x of d){const w=x.coveringTiles({tileSize:m,minzoom:this._source.minzoom,maxzoom:this._source.maxzoom,roundZoom:this._source.roundZoom&&!this.usedForTerrain,reparseOverscaled:this._source.reparseOverscaled,isTerrainDEM:this.usedForTerrain});for(const S of w)l.set(S.key,S);this.usedForTerrain&&x.updateElevation(!1)}const g=Array.from(l.values());u.dB(g,(x,w)=>{const S=new _c(x,this._source.tileSize*x.overscaleFactor(),this.transform.tileZoom,this.map.painter,this._isRaster,this._source.worldview);this._loadTile(S,A=>{this._source.type==="raster-dem"&&S.dem&&this._backfillDEM(S),w(A,S)})},n)}}function vc(s,t){const n=Math.abs(2*s.wrap)-+(s.wrap<0),l=Math.abs(2*t.wrap)-+(t.wrap<0);return s.overscaledZ-t.overscaledZ||l-n||t.canonical.y-s.canonical.y||t.canonical.x-s.canonical.x}function Ua(s,t){const n=1<<s.z;return[s.x/n+t,(s.x+1)/n+t]}function nt(s,t){if(s.z<=t.z){const l=t.z-s.z;return t.x>>l===s.x&&t.y>>l===s.y}const n=s.z-t.z;return s.x>>n===t.x&&s.y>>n===t.y}function Um(s,t){return s.sourceFQID!==t.sourceFQID?s.sourceFQID<t.sourceFQID?-1:1:s.tileId.z!==t.tileId.z?s.tileId.z-t.tileId.z:s.tileId.x!==t.tileId.x?s.tileId.x-t.tileId.x:s.tileId.y-t.tileId.y}$n.maxOverzooming=10,$n.maxUnderzooming=3;class hf{constructor(t=[]){this.tiles=t}getTilesIntersecting(t){const n=[];for(const l of this.tiles)nt(l.tileId,t)&&n.push(l);return n}equals(t){if(this.tiles.length!==t.length)return!1;for(let n=0;n<this.tiles.length;++n){const l=this.tiles[n],d=t[n];if(l.sourceFQID!==d.sourceFQID||l.tileId.z!==d.tileId.z||l.tileId.x!==d.tileId.x||l.tileId.y!==d.tileId.y||l.generation!==d.generation)return!1}return!0}empty(){return this.tiles.length===0}}class jm{constructor(){this._tiles=[],this._snapshot=new hf,this._snapshotChanged=!1}clear(){this._tiles.length=0}consumeSnapshotChanged(){const t=this._snapshotChanged;return this._snapshotChanged=!1,t}addTileElevation(t,n,l,d){this._tiles.push({sourceFQID:t,tileId:n,features:l,generation:d})}updateSnapshotIfNeeded(){return this._tiles.sort(Um),this._snapshot.equals(this._tiles)||(this._snapshot=new hf(this._tiles.slice()),this._snapshotChanged=!0),this._snapshot}}function Bo(s,t){const n=[];for(const l of s.getTilesIntersecting(t))n.push(`${l.tileId.z}/${l.tileId.x}/${l.tileId.y}:${l.generation}`);return n.sort(),n.join("|")}function As(s,t){const n=u.dE(s);return n===t||!n&&!t}function cu(s,t){return s._mergedOtherSourceCaches[t]||s._mergedSymbolSourceCaches[t]||s._mergedHdRoadElevationSourceCaches[t]}function df(s){const t=s.sourceLayer;return!!t&&t.startsWith("hd_road_")}function ff(s){return!!s.layout&&(s.type==="line"&&s.layout.get("line-elevation-reference")==="hd-road-markup"||s.type==="circle"&&s.layout.get("circle-elevation-reference")==="hd-road-markup"||s.type==="symbol"&&s.layout.get("symbol-elevation-reference")==="hd-road-markup"||s.type==="fill"&&s.layout.get("fill-elevation-reference")==="hd-road-markup")}function Sh(s){const t=new Set;for(const n in s._mergedLayers){const l=s._mergedLayers[n];ff(l)&&t.add(u.y(l.source,l.scope))}return t}function pf(s){const t=Sh(s),n=new Set;for(const l in s._mergedLayers){const d=s._mergedLayers[l];if(!d.source||!df(d))continue;const p=u.y(d.source,d.scope);t.has(p)||n.add(p)}return n}function mf(s){const t=Sh(s);if(t.size===0)return!1;const n=bc(s);for(const l of t)for(const d of n)if(l!==d)return!0;return!1}function bc(s){const t=new Set;for(const n in s._mergedLayers){const l=s._mergedLayers[n];l.source&&df(l)&&t.add(u.y(l.source,l.scope))}return t}function uu(s,t,n){const l=Sh(s);if(l.size===0)return;if(!n){const p=bc(s);for(const m of p)l.delete(m)}if(l.size===0)return;const d=[s._mergedOtherSourceCaches,s._mergedSymbolSourceCaches];for(const p of d)for(const m in p){if(!l.has(m))continue;const g=p[m];for(const x in g._tiles){const w=g._tiles[x];w&&(t&&!t(w)||(w.hasDeferredElevationFeatures=!1,g._reloadTile(+x,"reloading")))}}}class wl{constructor(){this.elevationSourceCaches={},this.manager=new jm,this._needsCrossSourceElevation=!1,this._ingestFQIDs=new Set,this._terrainActiveLast=void 0}}function _f(s){s.map&&s.map.painter&&(s.map.painter.elevationCoverageSnapshot=null,s.map.painter.elevationProvidersReady=void 0)}function gf(s){s._crossSourceElevationActive=!1,(function(t){const n=t._hdElevation,l=!!(t.map&&t.map.painter&&t.map.painter.elevationCoverageSnapshot);return n?!n._needsCrossSourceElevation&&n._ingestFQIDs.size===0&&n.manager._tiles.length===0&&!l:!l})(s)||(_f(s),s._hdElevation&&(s._hdElevation._needsCrossSourceElevation=!1,s._hdElevation._ingestFQIDs.clear(),s._hdElevation.manager.clear(),s._hdElevation._terrainActiveLast=void 0))}function yf(s,t,n){const l=u.y(n.id,s.scope);if(t.elevationSourceCaches[l])return;const d=`hd-road-elevation:${n.id}`,p=u.y(d,s.scope),m=s._sourceCaches[d]=new $n(p,n,u.dA.HdRoadElevation);t.elevationSourceCaches[l]=m,m.onAdd(s.map);const g=s._otherSourceCaches[n.id];g&&g._sourceLoaded&&(m._sourceLoaded=!0)}function xf(s,t){if(Xl(s,s.map&&s.map.transform))return t.manager.clear(),void(s.map.painter&&(s.map.painter.elevationCoverageSnapshot=null));if(!t._needsCrossSourceElevation)return void _f(s);for(const g of t._ingestFQIDs){const x=cu(s,g);x&&(x.used=!0)}t.manager.clear();let n=!0;for(const g of t._ingestFQIDs){const x=cu(s,g);if(!x)continue;const w=x._tiles;for(const S in w){const A=w[S];if(!A||!A.loaded())continue;const I=A.parsedElevationFeatures;I!==void 0?t.manager.addTileElevation(g,A.tileID.canonical,I,A.parsedElevationGeneration):n=!1}}const l=t.manager._snapshot,d=t.manager.updateSnapshotIfNeeded();s.map.painter&&(s.map.painter.elevationCoverageSnapshot=d.empty()?null:d);const p=n&&(function(g,x){for(const w of x){const S=cu(g,w);if(!S||!S._sourceLoaded)return!1;for(const A in S._tiles){const I=S._tiles[A];if(I&&(I.state==="loading"||I.state==="reloading"))return!1}}return!0})(s,pf(s));s.map.painter&&(s.map.painter.elevationProvidersReady=p);const m=t.manager.consumeSnapshotChanged();(m||p)&&uu(s,g=>{return!!g.hasDeferredElevationFeatures||m&&(x=d,Bo(l,w=g.tileID.canonical)!==Bo(x,w));var x,w})}const wc=s=>({u_matrix:s});function Gm(s,t){const n=s.context.gl;return new mt({func:n.EQUAL,mask:255},s._tileClippingMaskIDs[t.key]||0,0,n.KEEP,n.KEEP,n.KEEP)}function vf(s,t){const n=s.context.gl;return new mt({func:n.EQUAL,mask:255},255&~(s._tileClippingMaskIDs[t.key]||0),0,n.KEEP,n.KEEP,n.KEEP)}function Eh(s,t){if(!s.frcCoverageSnapshot||!s.frcCoverageRenderer)return null;const n=s.frcCoverageSnapshot.getTileOrParent(t.canonical);if(!n||n.frcMask===0)return null;const l=s.frcCoverageRenderer.getBuffers(n.tileId);if(!l)return null;const d=new u.bu(n.tileId.z,n.tileId.x,n.tileId.y),p=new u.bd(t.wrap,d);return{buffers:l,projMatrix:s.transform.calculateProjMatrix(p),coverageTile:n}}function $m(s,t,n){if(!s.frcCoverageSnapshot)return;const l=s.context,d=l.gl,p=s.getOrCreateProgram("clippingMask");l.setColorMode(yt.disabled),l.setDepthMode(ct.disabled);for(const m of t){const g=Eh(s,m);if(!g)continue;const x=g.buffers.frcLevelSegments[n];x&&p.draw(s,d.TRIANGLES,ct.disabled,new mt({func:d.EQUAL,mask:255},s._tileClippingMaskIDs[m.key]||0,255,d.KEEP,d.KEEP,d.INVERT),yt.disabled,_t.disabled,wc(g.projMatrix),`$frc_coverage_${n}`,g.buffers.vertexBuffer,g.buffers.indexBuffer,x)}}function qm(s,t,n){if(!s.frcCoverageSnapshot)return;const l=s.context,d=l.gl,p=s.getOrCreateProgram("clippingMask");l.setColorMode(yt.disabled),l.setDepthMode(ct.disabled);for(const m of t){const g=Eh(s,m);if(!g)continue;const x=g.buffers.frcLevelSegments[n];x&&p.draw(s,d.TRIANGLES,ct.disabled,new mt({func:d.EQUAL,mask:255},255&~(s._tileClippingMaskIDs[m.key]||0),255,d.KEEP,d.KEEP,d.INVERT),yt.disabled,_t.disabled,wc(g.projMatrix),`$frc_coverage_restore_${n}`,g.buffers.vertexBuffer,g.buffers.indexBuffer,x)}}function bf(s,t,n,l,d){if(t.length===0)return;let p=0;for(const g of t)p|=g.frcMask;const m=t.map(g=>g.coord);for(let g=0;g<9;++g)if(p&1<<g){if($m(s,m,g),l)for(const x of t)x.frcMask&1<<g&&l(x,g,Gm(s,x.coord));if(n>0&&d)for(const x of t)x.frcMask&1<<g&&d(x,g,vf(s,x.coord));qm(s,m,g)}}function wf(s){for(const t of s)if(t.rings.length>0&&t.rings[0].length>0)return!0;return!1}function Ih(s){const t=s.frcCoverageFadeRange;return!t||t[1]<=t[0]?0:1-Math.max(0,Math.min(1,(s.transform.zoom-t[0])/(t[1]-t[0])))}const Hm={loaded:!0,drawBuilding:function(s,t,n,l){s.currentLayer<s.firstLightBeamLayer&&(s.firstLightBeamLayer=s.currentLayer);const d=n.paint.get("building-ambient-occlusion-ground-intensity"),p=n.paint.get("building-ambient-occlusion-ground-radius"),m=n.paint.get("building-ambient-occlusion-ground-attenuation"),g=n.paint.get("building-opacity");if(g<=0)return;let x=d>0&&p>0,w=!0;const S=n.paint.get("building-vertical-scale");if(S<=0)return;s.shadowRenderer||(w=!1);const A=s.conflationActive&&s.style.isLayerClipped(n,t.getSource()),I=s.style.order.indexOf(n.fqid);if((function(M,D,L,k,B,$){for(const Z of $){const G=D.getTile(Z).getBucket(L);G&&(B&&G.updateReplacement(Z,M.replacementSource,k),G.uploadUpdatedIndexBuffer(M.context))}})(s,t,n,I,A,l),(function(M,D,L,k){for(const B of k){const $=D.getTile(B).getBucket(L);$&&$.needsEvaluation()&&$.uploadUpdatedColorBuffer(M.context)}})(s,t,n,l),n.resetLayerRenderingStats(s),s.shadowRenderer&&(s.shadowRenderer.useNormalOffset=!0),s.renderPass==="shadow"&&s.shadowRenderer){const M=[],D=s.shadowRenderer.getShadowPassDepthMode();Gn({painter:s,source:t,layer:n,coords:l,defines:M,blendMode:yt.disabled,depthMode:D,opacity:g,verticalScale:S,facadeEmissiveChance:0,facadeAOIntensity:0,floodLightIntensity:0,floodLightColor:[0,0,0]})}else if(s.renderPass==="translucent"){let M=["HAS_ATTRIBUTE_a_part_color_emissive","LIGHTING_3D_MODE"];w&&(M=M.concat("RENDER_SHADOWS")),s.shadowRenderer&&s.shadowRenderer.useNormalOffset&&(M=M.concat("NORMAL_OFFSET"));const D=n.paint.get("building-facade-emissive-chance"),L=n.paint.get("building-ambient-occlusion-intensity"),k=n.paint.get("building-flood-light-intensity"),B=n.paint.get("building-flood-light-color-use-theme").constantOr("default")==="none",$=n.paint.get("building-flood-light-color").toNonPremultipliedRenderColor(B?null:n.lut).toArray01().slice(0,3),Z=n.paint.get("building-flood-light-ground-attenuation"),G=k>0,te=new ct(s.context.gl.LEQUAL,ct.ReadWrite,s.depthRangeFor3D);g<1&&Gn({painter:s,source:t,layer:n,coords:l,defines:M,blendMode:yt.disabled,depthMode:te,opacity:g,verticalScale:S,facadeEmissiveChance:D,facadeAOIntensity:L,floodLightIntensity:k,floodLightColor:$,depthOnly:!0});const ee=s.colorModeForRenderPass();Gn({painter:s,source:t,layer:n,coords:l,defines:M,blendMode:ee,depthMode:te,opacity:g,verticalScale:S,facadeEmissiveChance:D,facadeAOIntensity:L,floodLightIntensity:k,floodLightColor:$});const le=n.paint.get("building-front-cutoff");iu(s.transform.pitch,le,!!s.terrain),x&&hh(s,t,n,l,!0,g,d,p,k,$,m,A),G&&hh(s,t,n,l,!1,g,d,p,k,$,Z,A)}else if(s.renderPass==="light-beam"){const M=["HAS_ATTRIBUTE_a_part_color_emissive","HAS_ATTRIBUTE_a_bloom_attenuation"],D=new ct(s.context.gl.LEQUAL,ct.ReadOnly,s.depthRangeFor3D);Gn({painter:s,source:t,layer:n,coords:l,defines:M,blendMode:yt.alphaBlended,depthMode:D,opacity:g,verticalScale:S,facadeEmissiveChance:0,facadeAOIntensity:0,floodLightIntensity:0,floodLightColor:[0,0,0]})}s.shadowRenderer&&(s.shadowRenderer.useNormalOffset=!1),s.resetStencilClippingMasks()},BuildingTileBorderManager:class{constructor(){this.visibleTiles=[]}updateBorders(s,t){const n=[],l=[],d=s._getRenderableCoordinates(!1,!0);for(const g of d){const x=s.getTile(g);if(!x.hasData())continue;const w=x.getBucket(t);w&&(w.isEmpty()||(n.push(g.key),l.push({bucket:w,tileID:g.canonical})))}let p=n.length!==this.visibleTiles.length;if(!p){n.sort();for(let g=0;g<n.length;g++)if(n[g]!==this.visibleTiles[g]){p=!0;break}}if(!p)return;const m=new Set;this.visibleTiles=n,l.sort((g,x)=>g.tileID.z-x.tileID.z||g.tileID.x-x.tileID.x||g.tileID.y-x.tileID.y);for(const g of l){const x=new Array,w=new Array,S=g.bucket;for(const A of S.featuresOnBorder)S.footprints[A.footprintIndex].hiddenFlags&u.cH||(m.has(A.featureId)?w.push(A.footprintIndex):(m.add(A.featureId),x.push(A.footprintIndex)));S.updateFootprintHiddenFlags(x,u.cI,!1),S.updateFootprintHiddenFlags(w,u.cI,!0)}}},drawRasterParticle:function(s,t,n,l,d,p){s.renderPass==="offscreen"&&(function(m,g,x,w){if(!w.length)return;const S=m.context,A=S.gl,I=g.getSource();if(!(I instanceof bl))return;const M=Math.ceil(Math.sqrt(x.paint.get("raster-particle-count")));let D=x.particlePositionRGBAImage;if(!D||D.width!==M){const Z=(function(G){const te=G*G,ee=new Uint8Array(4*te),le=.9090909090909091;for(let K=0;K<te;K++){const Q=le*(u.cy(2*K+0)+mc),ae=le*(u.cy(2*K+1)+mc),de=255*Q%1,fe=255*ae%1,be=de,Te=ae-fe/255,Ve=fe;ee[4*K+0]=255*(Q-de/255),ee[4*K+1]=255*be,ee[4*K+2]=255*Te,ee[4*K+3]=255*Ve}return ee})(M);D=x.particlePositionRGBAImage=new u.t({width:M,height:M},Z)}let L=x.particleFramebuffer;L?L.width!==M&&(L.destroy(),L=x.particleFramebuffer=S.createFramebuffer(M,M,1,null)):L=x.particleFramebuffer=S.createFramebuffer(M,M,1,null);const k=[];for(const Z of w){const G=g.getTile(Z);if(!(G instanceof af))continue;const te=Na(G,I,x);if(!te)continue;const ee=[G.tileSize,G.tileSize];let le=x.tileFramebuffer;le||(le=x.tileFramebuffer=S.createFramebuffer(ee[0],ee[1],1,null));let K=G.rasterParticleState;K||(K=G.rasterParticleState=new Lm(S,Z,ee,D));const Q=K.update(x.lastInvalidatedAt);K.particleTextureDimension!==M&&K.updateParticleTexture(Z,D);const ae=K.targetColorTexture;K.targetColorTexture=K.backgroundColorTexture,K.backgroundColorTexture=ae;const de=K.particleTexture0;K.particleTexture0=K.particleTexture1,K.particleTexture1=de,k.push([Z,te,K,Q])}if(k.length===0)return;const B=u.r.now(),$=x.previousDrawTimestamp?.001*(B-x.previousDrawTimestamp):.0167;if(x.previousDrawTimestamp=B,x.hasColorMap()){S.activeTexture.set(A.TEXTURE0+2);let Z=x.colorRampTexture;Z||(Z=x.colorRampTexture=new u.T(S,x.colorRamp,A.RGBA8)),Z.bind(A.LINEAR,A.CLAMP_TO_EDGE)}S.bindFramebuffer.set(x.tileFramebuffer.framebuffer),(function(Z,G,te){const ee=Z.context,le=ee.gl,K=G.tileFramebuffer;ee.activeTexture.set(le.TEXTURE0);const Q={u_texture:0,u_opacity:1.05*(de=G.paint.get("raster-particle-fade-opacity-factor"))/(de+.05)},ae=Z.getOrCreateProgram("rasterParticleTexture",{defines:[],overrideFog:!1});var de;for(const fe of te){const[,,be,Te]=fe;K.colorAttachment0.set(be.targetColorTexture.texture),ee.viewport.set([0,0,K.width,K.height]),ee.clear({color:u.C.transparent}),Te&&(be.backgroundColorTexture.bind(le.NEAREST,le.CLAMP_TO_EDGE),ae.draw(Z,le.TRIANGLES,ct.disabled,mt.disabled,yt.alphaBlended,_t.disabled,Q,G.id,Z.viewportBuffer,Z.quadTriangleIndexBuffer,Z.viewportSegments))}})(m,x,k),(function(Z,G,te,ee){const le=Z.context,K=le.gl,Q=te.tileFramebuffer,ae=Z.transform.projection.name==="globe",de=te.paint.get("raster-particle-max-speed");for(const fe of ee){const[be,Te,Ve]=fe;le.activeTexture.set(K.TEXTURE0+0),Te.texture.bind(K.LINEAR,K.CLAMP_TO_EDGE),Q.colorAttachment0.set(Ve.targetColorTexture.texture);const ye=Z.getOrCreateProgram("rasterParticleDraw",{defines:Te.defines,overrideFog:!1});le.activeTexture.set(K.TEXTURE0+1);const Ae=Te.scalarData?[]:[0,1,2,3].map(Re=>u.c0[Re](be));Ae.push(be);const ge=be.canonical.x,Fe=be.canonical.y;for(const Re of Ae){const De=G.getTile(ae?Re.wrapped():Re);if(!De)continue;const Ke=De.rasterParticleState;if(!Ke)continue;const Be=Re.canonical.x+(1<<Re.canonical.z)*(Re.wrap-be.wrap),Ge=Re.canonical.y;Ke.particleTexture0.bind(K.NEAREST,K.CLAMP_TO_EDGE);const Ze=of(1,Ke.particleTexture0.size[0],[Be-ge,Ge-Fe],0,Te.texture.size,2,de,Te.textureOffset,Te.scale,Te.offset);ye.draw(Z,K.POINTS,ct.disabled,mt.disabled,yt.alphaBlended,_t.disabled,Ze,te.id,Ke.particleIndexBuffer,void 0,Ke.particleSegment)}}})(m,g,x,k),S.bindFramebuffer.set(x.particleFramebuffer.framebuffer),(function(Z,G,te,ee){const le=Z.context,K=le.gl,Q=G.paint.get("raster-particle-max-speed"),ae=ee*G.paint.get("raster-particle-speed-factor")*.15,de=(function(be){return Math.pow(be,6)})(.01+1*G.paint.get("raster-particle-reset-rate-factor")),fe=G.particleFramebuffer;le.viewport.set([0,0,fe.width,fe.height]);for(const be of te){const[,Te,Ve]=be;le.activeTexture.set(K.TEXTURE0+0),Te.texture.bind(K.LINEAR,K.CLAMP_TO_EDGE),le.activeTexture.set(K.TEXTURE0+1);const ye=Ve.particleTexture0;ye.bind(K.NEAREST,K.CLAMP_TO_EDGE);const Ae=sf(1,ye.size[0],0,Te.texture.size,Q,ae,de,Te.textureOffset,Te.scale,Te.offset);fe.colorAttachment0.set(Ve.particleTexture1.texture),le.clear({color:u.C.transparent}),Z.getOrCreateProgram("rasterParticleUpdate",{defines:Te.defines}).draw(Z,K.TRIANGLES,ct.disabled,mt.disabled,yt.unblended,_t.disabled,Ae,G.id,Z.viewportBuffer,Z.quadTriangleIndexBuffer,Z.viewportSegments)}})(m,x,k,$)})(s,t,n,l),s.renderPass==="translucent"&&((function(m,g,x,w){const S=m.context,A=S.gl,I=g.getSource().tileSize,M=5*(1-u.af(u.bD,u.bD+1,m.transform.zoom))*I+x.paint.get("raster-particle-elevation"),D=!m.options.moving,L=m.transform.projection.name==="globe";if(!w.length)return;const[k,B]=m.stencilConfigForOverlap(w),$=[];L&&$.push("PROJECTION_GLOBE_VIEW");const Z=m.stencilModeFor3D();for(const G of B){const te=G.toUnwrapped(),ee=g.getTile(G);if(!ee.rasterParticleState)continue;const le=ee.rasterParticleState,K=100;ee.registerFadeDuration(K);const Q=g.findLoadedParent(G,0),ae=nu(ee,Q,g,m.transform,K);let de,fe;m.terrain&&m.terrain.prepareDrawTile(),S.activeTexture.set(A.TEXTURE0),le.targetColorTexture.bind(A.LINEAR,A.CLAMP_TO_EDGE),S.activeTexture.set(A.TEXTURE1),Q&&Q.rasterParticleState?(Q.rasterParticleState.targetColorTexture.bind(A.LINEAR,A.CLAMP_TO_EDGE),de=Math.pow(2,Q.tileID.overscaledZ-ee.tileID.overscaledZ),fe=[ee.tileID.canonical.x*de%1,ee.tileID.canonical.y*de%1]):le.targetColorTexture.bind(A.LINEAR,A.CLAMP_TO_EDGE);const be=L?m.transform.expandedFarZProjMatrix:m.transform.calculateProjMatrix(te,D),Te=m.transform,Ve=yh(Te),ye=u.dl(G.canonical),Ae=u.dm(ye.getCenter().lat);let ge,Fe,Re,De,Ke;L?(ge=Float32Array.from(u.d3(u.dn(G.canonical))),Fe=Float32Array.from(Te.globeMatrix),Re=Float32Array.from(u.dp(Te)),De=[u.a_(Te.center.lng),u.a$(Te.center.lat)],Ke=Float32Array.from(u.dq(G.canonical,ye,Ae,Te.worldSize/Te._pixelsPerMercatorPixel))):(ge=new Float32Array(16),Fe=new Float32Array(9),Re=new Float32Array(16),De=[0,0],Ke=new Float32Array(9));const Be=fh(be,ge,Fe,Re,Ke,fe||[0,0],u.ah(m.transform.zoom),De,Ve,de||1,ae,M),Ge=m.isTileAffectedByFog(G),Ze=m.getOrCreateProgram("rasterParticle",{defines:$,overrideFog:Ge});if(m.uploadCommonUniforms(S,Ze,te),L){const tt=new ct(A.LEQUAL,ct.ReadOnly,m.depthRangeFor3D),ot=0,at=m.globeSharedBuffers;if(at){const[ut,bt,pt]=at.getGridBuffers(Ae,ot!==0);Ze.draw(m,A.TRIANGLES,tt,Z,yt.alphaBlended,m.renderElevatedRasterBackface?_t.frontCCW:_t.backCCW,Be,x.id,ut,bt,pt)}}else{const tt=m.depthModeForSublayer(0,ct.ReadOnly),ot=k[G.overscaledZ],{tileBoundsBuffer:at,tileBoundsIndexBuffer:ut,tileBoundsSegments:bt}=m.getTileBoundsBuffers(ee);Ze.draw(m,A.TRIANGLES,tt,ot,yt.alphaBlended,_t.disabled,Be,x.id,at,ut,bt)}}m.resetStencilClippingMasks()})(s,t,n,l),s.style.map.triggerRepaint())},prepareRasterParticle:function(s,t,n){const l=t.getSource();if(!(l instanceof bl&&l.loaded()))return;const d=s.sourceLayer||l.rasterLayerIds&&l.rasterLayerIds[0];if(!d)return;const p=s.paint.get("raster-particle-array-band")||l.getInitialBand(d);if(p==null)return;const m=t.getIds().map(g=>t.getTileByID(g));for(const g of m)g.updateNeeded(s.id,p)&&l.prepareTile(g,d,s.id,p)},Rain:class extends Om{constructor(){super(4.25),this._params={intensity:.5,timeFactor:1,velocityConeAperture:0,velocity:300,boxSize:2500,dropletSizeX:1,dropletSizeYScale:10,distortionStrength:70,screenThinning:{intensity:.57,start:.46,range:1.17,fadePower:.17,affectedRatio:1,particleOffset:-.2},color:{r:.66,g:.68,b:.74,a:.7},direction:{x:-50,y:-35},shapeDirPower:2,shapeNormalPower:1},this._vignetteParams={strength:1,start:.7,range:1,fadePower:.4,color:{r:.27,g:.27,b:.27,a:1}},this.particlesCount=16e3,this._devtoolsFolder=null,this._painter=null}destroy(){super.destroy()}update(s){const t=s.context;if(!this.particlesVx){const n=vh(this.particlesCount),l=new u.dv,d=new u.cp;let p=0;const m=u.dt(1323123451230);for(let g=0;g<n.length;++g){const x=n[g],w=[2*m()-1,m(),m(),m()];l.emplaceBack(x[0],x[1],x[2],-1,-1,...w),l.emplaceBack(x[0],x[1],x[2],1,-1,...w),l.emplaceBack(x[0],x[1],x[2],1,1,...w),l.emplaceBack(x[0],x[1],x[2],-1,1,...w),d.emplaceBack(p+0,p+1,p+2),d.emplaceBack(p+0,p+2,p+3),p+=4}this.particlesVx=t.createVertexBuffer(l,Va.members),this.particlesIdx=t.createIndexBuffer(d)}}getDrawParams(s){if(!s.style.rain)return null;const t=s.style.rain.state,n=structuredClone(this._params);n.intensity=t.density,n.timeFactor=t.intensity,n.color=structuredClone(t.color),n.screenThinning.intensity=t.centerThinning,n.dropletSizeX=t.dropletSize[0],n.dropletSizeYScale=t.dropletSize[1]/t.dropletSize[0],n.distortionStrength=100*t.distortionStrength;const l=structuredClone(this._vignetteParams);return l.strength=1,l.color=structuredClone(t.vignetteColor),{params:n,vignetteParams:l,revealParams:{revealStart:0,revealRange:.01},direction:structuredClone(t.direction)}}draw(s){const t=this.getDrawParams(s);if(!t)return;const{params:n,revealParams:l,direction:d,vignetteParams:p}=t,m=s.transform.zoom;if(l.revealStart>m)return;const g=Xs(0,1,l.revealStart,l.revealStart+l.revealRange,m);if(!this.particlesVx||!this.particlesIdx)return;p.strength*=g;const x=this.updateOnRender(s,n.timeFactor),w=s.context,S=w.gl,A=s.transform;this.screenTexture&&this.screenTexture.size[0]===s.width&&this.screenTexture.size[1]===s.height||(this.screenTexture=new u.T(w,{width:s.width,height:s.height,data:null},S.RGBA8)),n.distortionStrength>0&&(w.activeTexture.set(S.TEXTURE0),this.screenTexture.bind(S.LINEAR,S.CLAMP_TO_EDGE),S.copyTexSubImage2D(S.TEXTURE_2D,0,0,0,0,0,s.width,s.height));const I=s.getOrCreateProgram("rainParticle");s.uploadCommonUniforms(w,I),w.activeTexture.set(S.TEXTURE0),this.screenTexture.bind(S.LINEAR,S.CLAMP_TO_EDGE);const M=[n.color.r,n.color.g,n.color.b,n.color.a],D=(L,k)=>{const B=cf(this._movement.getPosition(),L),$=n.dropletSizeX,Z=n.dropletSizeX*n.dropletSizeYScale,G=s.width/2,te=s.height/2,ee=Xs(0,n.screenThinning.start,0,1,n.screenThinning.intensity),le=Xs(.001,n.screenThinning.range,0,1,n.screenThinning.intensity),K=Xs(0,n.screenThinning.particleOffset,0,1,n.screenThinning.intensity),Q=(ae={modelview:x.modelviewMatrix,projection:x.projectionMatrix,time:this._accumulatedTimeFromStart,camPos:B,velocityConeAperture:n.velocityConeAperture,velocity:n.velocity,boxSize:L,rainDropletSize:[$,Z],distortionStrength:n.distortionStrength,rainDirection:d,color:M,screenSize:[A.width,A.height],thinningCenterPos:[G,te],thinningShape:[ee,le,Math.pow(10,n.screenThinning.fadePower)],thinningAffectedRatio:n.screenThinning.affectedRatio,thinningParticleOffset:K,shapeDirectionalPower:n.shapeDirPower,shapeNormalPower:n.shapeNormalPower,mode:k?0:1},{u_modelview:Float32Array.from(ae.modelview),u_projection:Float32Array.from(ae.projection),u_time:ae.time,u_cam_pos:ae.camPos,u_texScreen:0,u_velocityConeAperture:ae.velocityConeAperture,u_velocity:ae.velocity,u_boxSize:ae.boxSize,u_rainDropletSize:ae.rainDropletSize,u_distortionStrength:ae.distortionStrength,u_rainDirection:ae.rainDirection,u_color:ae.color,u_screenSize:ae.screenSize,u_thinningCenterPos:ae.thinningCenterPos,u_thinningShape:ae.thinningShape,u_thinningAffectedRatio:ae.thinningAffectedRatio,u_thinningParticleOffset:ae.thinningParticleOffset,u_shapeDirectionalPower:ae.shapeDirectionalPower,u_shapeNormalPower:ae.shapeNormalPower,u_mode:ae.mode});var ae;const de=Math.round(n.intensity*this.particlesCount),fe=u.cr.simpleSegment(0,0,4*de,2*de);I.draw(s,S.TRIANGLES,ct.disabled,mt.disabled,yt.alphaBlended,_t.disabled,Q,"rain_particles",this.particlesVx,this.particlesIdx,fe)};n.distortionStrength>0&&D(n.boxSize,!0),D(n.boxSize,!1),this._vignette.draw(s,p)}},Snow:class extends Om{constructor(){super(2.25),this._params={intensity:.85,timeFactor:.75,velocityConeAperture:70,velocity:40,horizontalOscillationRadius:4,horizontalOscillationRate:1.5,boxSize:2e3,billboardSize:2,shapeFadeStart:.27,shapeFadePower:.21,screenThinning:{intensity:.4,start:.15,range:1.4,fadePower:.24,affectedRatio:1,particleOffset:-.2},color:{r:1,g:1,b:1,a:1},direction:{x:-50,y:-35}},this._vignetteParams={strength:.3,start:.78,range:.46,fadePower:.2,color:{r:1,g:1,b:1,a:1}},this.particlesCount=16e3,this._devtoolsFolder=null,this._painter=null}destroy(){super.destroy()}update(s){const t=s.context;if(!this.particlesVx){const n=vh(this.particlesCount),l=new u.dw,d=new u.cp;let p=0;const m=u.dt(1323123451230);for(let g=0;g<n.length;++g){const x=n[g],w=m(),S=m(),A=m(),I=[g/n.length,w,S,A],M=[m(),m()];l.emplaceBack(x[0],x[1],x[2],-1,-1,...I,...M),l.emplaceBack(x[0],x[1],x[2],1,-1,...I,...M),l.emplaceBack(x[0],x[1],x[2],1,1,...I,...M),l.emplaceBack(x[0],x[1],x[2],-1,1,...I,...M),d.emplaceBack(p+0,p+1,p+2),d.emplaceBack(p+0,p+2,p+3),p+=4}this.particlesVx=t.createVertexBuffer(l,km.members),this.particlesIdx=t.createIndexBuffer(d)}}getDrawParams(s){if(!s.style.snow)return null;const t=s.style.snow.state,n=structuredClone(this._params);n.intensity=t.density,n.timeFactor=t.intensity,n.color=structuredClone(t.color),n.screenThinning.intensity=t.centerThinning,n.billboardSize=2.79*t.flakeSize;const l=structuredClone(this._vignetteParams);return l.strength=1,l.color=structuredClone(t.vignetteColor),{params:n,vignetteParams:l,revealParams:{revealStart:0,revealRange:.01},direction:structuredClone(t.direction)}}draw(s){const t=this.getDrawParams(s);if(!t)return;const{params:n,revealParams:l,direction:d,vignetteParams:p}=t,m=s.transform.zoom;if(l.revealStart>m)return;const g=Xs(0,1,l.revealStart,l.revealStart+l.revealRange,m);p.strength*=g;const x=this.updateOnRender(s,n.timeFactor);if(!this.particlesVx||!this.particlesIdx)return;const w=s.context,S=w.gl,A=s.transform,I=s.getOrCreateProgram("snowParticle");s.uploadCommonUniforms(w,I),((M,D,L)=>{const k=cf(this._movement.getPosition(),M),B=A.width/2,$=A.height/2,Z=Xs(0,L.screenThinning.start,0,1,L.screenThinning.intensity),G=Xs(.001,L.screenThinning.range,0,1,L.screenThinning.intensity),te=Xs(0,L.screenThinning.particleOffset,0,1,L.screenThinning.intensity),ee=(le={modelview:x.modelviewMatrix,projection:x.projectionMatrix,time:this._accumulatedTimeFromStart,camPos:k,velocityConeAperture:L.velocityConeAperture,velocity:L.velocity,horizontalOscillationRadius:L.horizontalOscillationRadius,horizontalOscillationRate:L.horizontalOscillationRate,boxSize:M,billboardSize:1*L.billboardSize,simpleShapeParameters:[L.shapeFadeStart,L.shapeFadePower],screenSize:[A.width,A.height],thinningCenterPos:[B,$],thinningShape:[Z,G,Math.pow(10,L.screenThinning.fadePower)],thinningAffectedRatio:L.screenThinning.affectedRatio,thinningParticleOffset:te,color:[L.color.r,L.color.g,L.color.b,L.color.a],direction:d},{u_modelview:Float32Array.from(le.modelview),u_projection:Float32Array.from(le.projection),u_time:le.time,u_cam_pos:le.camPos,u_velocityConeAperture:le.velocityConeAperture,u_velocity:le.velocity,u_horizontalOscillationRadius:le.horizontalOscillationRadius,u_horizontalOscillationRate:le.horizontalOscillationRate,u_boxSize:le.boxSize,u_billboardSize:le.billboardSize,u_simpleShapeParameters:le.simpleShapeParameters,u_screenSize:le.screenSize,u_thinningCenterPos:le.thinningCenterPos,u_thinningShape:le.thinningShape,u_thinningAffectedRatio:le.thinningAffectedRatio,u_thinningParticleOffset:le.thinningParticleOffset,u_particleColor:le.color,u_direction:le.direction});var le;const K=Math.round(L.intensity*this.particlesCount),Q=u.cr.simpleSegment(0,0,4*K,2*K);this.particlesVx&&this.particlesIdx&&I.draw(s,S.TRIANGLES,ct.disabled,mt.disabled,yt.alphaBlended,_t.disabled,ee,"snow_particles",this.particlesVx,this.particlesIdx,Q)})(n.boxSize,0,n),this._vignette.draw(s,p)}},shaders:zm,programUniforms:Bm,drawElevatedStructures:function(s){const{painter:t,sourceCache:n,layer:l,coords:d,colorMode:p}=s,m=t.context.gl,g=s.painter.shadowRenderer,x=!!g&&g.enabled,w=new ct(t.context.gl.LEQUAL,ct.ReadOnly,t.depthRangeFor3D);let S=[0,0,0];if(x){const I=t.style.directionalLight,M=t.style.ambientLight;I&&M&&(S=pl(t.style,I,M))}const A=I=>{for(const M of d){const D=n.getTile(M),L=D.getBucket(l);if(!L)continue;const k=L.hdExt?L.hdExt.elevatedStructures:void 0;if(!k)continue;let B,$;if(I?(B=k.renderableBridgeSegments,$=k.bridgeProgramConfigurations.get(l.id)):(B=k.renderableTunnelSegments,$=k.tunnelProgramConfigurations.get(l.id)),!B||B.segments[0].primitiveLength===0)continue;$.updatePaintBuffers(),t.prepareDrawTile();const Z=t.isTileAffectedByFog(M),G=[];x&&G.push("RENDER_SHADOWS","NORMAL_OFFSET");const te=t.getOrCreateProgram("elevatedStructures",{config:$,overrideFog:Z,defines:G}),ee=t.translatePosMatrix(M.projMatrix,D,l.paint.get("fill-translate"),l.paint.get("fill-translate-anchor"));x&&g.setupShadows(D.tileID.toUnwrapped(),te,"vector-tile");const le=Qg(ee,S);t.uploadCommonUniforms(t.context,te,M.toUnwrapped()),te.draw(t,m.TRIANGLES,w,mt.disabled,p,_t.backCCW,le,l.id,k.vertexBuffer,k.indexBuffer,B,l.paint,t.transform.zoom,$,[k.vertexBufferNormal])}};A(!0),A(!1)},drawElevatedFillShadows:function(s){const{painter:t,sourceCache:n,layer:l,coords:d}=s,p=t.context.gl,m=s.painter.shadowRenderer;for(const g of d){const x=n.getTile(g),w=x.getBucket(l);if(!w)continue;const S=w.hdExt?w.hdExt.elevatedStructures:void 0;if(!S||!S.shadowCasterSegments||S.shadowCasterSegments.segments[0].primitiveLength===0)continue;t.prepareDrawTile();const A=w.bufferData.programConfigurations.get(l.id),I=t.isTileAffectedByFog(g),M=t.getOrCreateProgram("elevatedStructuresDepth",{config:A,overrideFog:I}),D=m.calculateShadowPassMatrixFromTile(x.tileID.toUnwrapped());t.uploadCommonUniforms(t.context,M,g.toUnwrapped());const L=su(D,0);M.draw(t,p.TRIANGLES,m.getShadowPassDepthMode(),mt.disabled,yt.disabled,_t.disabled,L,l.id,S.vertexBuffer,S.indexBuffer,S.shadowCasterSegments,l.paint,t.transform.zoom,A)}}
3396,drawDepthPrepass:function(s,t,n,l,d){if(!t||!n.layout||n.layout.get("fill-elevation-reference")==="none"||n.paint.get("fill-opacity").constantOr(1)===0)return;const p=s.context.gl,m=new ct(s.context.gl.LEQUAL,ct.ReadWrite,s.depthRangeFor3D),g=new ct(s.context.gl.GREATER,ct.ReadWrite,s.depthRangeFor3D),x=(function(M){let D=.01;return M.isOrthographic&&(D=u.ai(1e-4,D,u.bW(M.pitch>=nn?1:M.pitch/nn))),2*D})(s.transform),w=s.transform.getFreeCameraOptions().position,S="elevatedStructuresDepthReconstruct",A=s.getOrCreateProgram(S,{defines:["DEPTH_RECONSTRUCTION"]}),I=s.getOrCreateProgram(S);for(const M of l){const D=t.getTile(M),L=D.getBucket(n);if(!L||!L.hdExt)continue;const k=L.hdExt.elevatedStructures,B=L.hdExt.elevationBufferData;if(!k||!k.depthSegments||!B)continue;const $=B.heightRange,Z=Nm(M.toUnwrapped(),w),G=s.translatePosMatrix(M.projMatrix,D,n.paint.get("fill-translate"),n.paint.get("fill-translate-anchor"));let te,ee,le,K;if(d==="initialize"){if(!$||$.min>=1||k.depthSegments.segments[0].primitiveLength===0)continue;te=bh(G,Z,x,1,0),ee=m,le=k.depthSegments,K=A}else if(d==="reset"){if(!$||$.min>=0||k.maskSegments.segments[0].primitiveLength===0)continue;te=bh(G,Z,0,0,1),ee=g,le=k.maskSegments,K=A}else if(d==="geometry"){if(k.depthSegments.segments[0].primitiveLength===0)continue;te=bh(G,Z,x,1,0),ee=m,le=k.depthSegments,K=I}K.draw(s,p.TRIANGLES,ee,mt.disabled,yt.disabled,_t.disabled,te,n.id,k.vertexBuffer,k.indexBuffer,le,n.paint,s.transform.zoom)}},drawGroundShadowMask:function(s,t,n,l){if(!t||!n.layout||n.layout.get("fill-elevation-reference")==="none"||n.paint.get("fill-opacity").constantOr(1)===0)return;const d=s.context.gl,p=new ct(d.LEQUAL,ct.ReadOnly,s.depthRangeFor3D),m=new mt({func:d.ALWAYS,mask:255},255,255,d.KEEP,d.KEEP,d.REPLACE),g=s.transform.getFreeCameraOptions().position,x=s.getOrCreateProgram("elevatedStructuresDepthReconstruct");for(const w of l){const S=t.getTile(w),A=S.getBucket(n);if(!A)continue;const I=A.hdExt?A.hdExt.elevatedStructures:void 0;if(!I||!I.depthSegments||I.depthSegments.segments[0].primitiveLength===0)continue;const M=Nm(w.toUnwrapped(),g),D=s.translatePosMatrix(w.projMatrix,S,n.paint.get("fill-translate"),n.paint.get("fill-translate-anchor")),L=bh(D,M,0,1,0);x.draw(s,d.TRIANGLES,p,m,yt.disabled,_t.disabled,L,n.id,I.vertexBuffer,I.indexBuffer,I.depthSegments,n.paint,s.transform.zoom)}},IndoorManager:class extends u.E{constructor(s,t=!1){super(),this._style=s,this._buildings={},this._activeFloors=new Set,this._closestBuildingId=null,this._indoorState={selectedFloorId:null,activeFloorsVisible:!0,activeFloors:this._activeFloors},this._buildingDetectionStrategy=new dh,this._initialLoadDone=!1,u.cL(["_updateUI"],this);const n=()=>{this._style.isIndoorEnabled()&&(this._style.map.on("load",()=>{this._initialLoadDone=!0,this._indoorState&&this._indoorState.needsUpdate&&(this._indoorState.needsUpdate=!1,this._style.updateIndoorDependentLayers()),this._updateUI()}),this._style.map.on("move",this._updateUI),this._style.map.on("idle",this._updateUI))};t?(this._initialLoadDone=!0,n()):this._style.on("style.load",n)}destroy(){this._buildings={},this._activeFloors=new Set,this._indoorState=null}selectFloor(s){s===this._selectedFloorId&&this._indoorState&&this._indoorState.activeFloorsVisible||(this._selectedFloorId=s,this._recalculateActiveFloors())}setActiveFloorsVisibility(s){this._updateActiveFloors(s),this._updateIndoorSelector()}setIndoorData(s){let t=!1;for(const[n,l]of Object.entries(s.buildings))if(this._buildings[n])for(const d of l.floorIds)this._buildings[n].floorIds.add(d),this._buildings[n].floors[d]?this._mergeFloors(this._buildings[n].floors[d],l.floors[d]):(this._buildings[n].floors[d]=l.floors[d],t=!0);else this._buildings[n]=l,t=!0;t&&this._recalculateActiveFloors()}getIndoorTileOptions(s,t){return this._indoorState?{sourceLayers:this._style.getIndoorSourceLayers(s,t),indoorState:this._indoorState}:null}getControlState(){const s=this._buildings,t=this._closestBuildingId,n=t&&s?s[t]:void 0;if(!n)return{selectedFloorId:null,activeFloorsVisible:!!this._indoorState&&this._indoorState.activeFloorsVisible,floors:[]};let l=null;for(const p of n.floorIds)if(this._activeFloors&&this._activeFloors.has(p
vendor: 79,487 bytes, line 3396
3396)){l=p;break}const d=Array.from(n.floorIds).map(p=>({id:p,name:n.floors[p].name,zIndex:n.floors[p].zIndex})).sort((p,m)=>m.zIndex-p.zIndex).filter((p,m,g)=>m===0||p.zIndex!==g[m-1].zIndex);return{selectedFloorId:l,activeFloorsVisible:!!this._indoorState&&this._indoorState.activeFloorsVisible,floors:d}}_updateUI(){this._initialLoadDone=!0;const s=this._style.map.transform,t=this._buildingDetectionStrategy.findClosestBuilding(this._buildings,s.center,s.zoom,s.getBounds(),this._makeViewportPolygon());if(t!==this._closestBuildingId){const n=this._closestBuildingId;this._closestBuildingId=t,this._onBuildingTransition(n,t),this._updateIndoorSelector()}}_onBuildingTransition(s,t){if(!this._indoorState)return;!t&&s?(this._indoorState.activeFloors=new Set,this._indoorState.activeFloorsVisible=!1,this._style.updateIndoorDependentLayers()):!!t&&!s&&(this._recalculateActiveFloors(),this._updateActiveFloors(!0))}_updateIndoorSelector(){this.fire(new u.B("selector-update",this.getControlState()))}_updateActiveFloors(s){this._indoorState={selectedFloorId:this._selectedFloorId,activeFloorsVisible:s,activeFloors:this._activeFloors},this._initialLoadDone?this._style.updateIndoorDependentLayers():this._indoorState.needsUpdate=!0}_recalculateActiveFloors(){if(!this._buildings)return;const s=u.cM.calculate(this._buildings,this._selectedFloorId,this._activeFloors);(function(t,n){if(t===n)return!0;if(!t||!n||t.size!==n.size)return!1;for(const l of t)if(!n.has(l))return!1;return!0})(s,this._activeFloors)||(this._activeFloors=s,this._updateActiveFloors(!!this._indoorState&&this._indoorState.activeFloorsVisible),this._updateIndoorSelector())}_mergeFloors(s,t){t.geometry&&(s.geometry?(s.geometry.type==="Polygon"&&(s.geometry={type:"MultiPolygon",coordinates:[s.geometry.coordinates]}),t.geometry.type==="Polygon"?s.geometry.coordinates.push(t.geometry.coordinates):t.geometry.type==="MultiPolygon"&&s.geometry.coordinates.push(...t.geometry.coordinates)):s.geometry=t.geometry)}_makeViewportPolygon(){const s=this._style.map.transform,t=s.width,n=s.height;return[s.pointLocation(new u.P(0,0)),s.pointLocation(new u.P(t,0)),s.pointLocation(new u.P(t,n)),s.pointLocation(new u.P(0,n))].map(l=>new u.P(l.lng,l.lat))}},HdCoverageState:class{constructor(){this.coverageSourceCaches={},this.manager=new lu}},updateFrcCoverage:function(s,t){t.manager.clear();for(const l in s._mergedHdRoadCoverageSourceCaches){const d=s._mergedHdRoadCoverageSourceCaches[l]._tiles;for(const p in d){const m=d[p];if(!m||!m.loaded())continue;const g=m.frcCoveragePolygons;t.manager.addTileCoverage(m.tileID.canonical,g&&g.length>0?g:[])}}const n=t.manager.updateSnapshotIfNeeded();if(s.map.painter&&(s.map.painter.frcCoverageSnapshot=n.empty()?null:n),!n.empty()){const l=[s._mergedOtherSourceCaches,s._mergedSymbolSourceCaches];for(const d of l)for(const p in d){const m=d[p];for(const g in m._tiles){const x=m._tiles[g];x&&x.hasDeferredRoadStructure&&(x.hasDeferredRoadStructure=!1,m._reloadTile(+g,"reloading"))}}}},updateHdCoverageSourceCache:function(s,t,n){if(n.type!=="fill"||n.sourceLayer!==u.dC||t.coverageSourceCaches[n.source])return;const l=s.getOwnSource(n.source);if(!l||l.type!=="vector")return;const d=`hd-road-coverage:${n.source}`,p=u.y(d,s.scope),m=s._sourceCaches[d]=new $n(p,l,u.dA.HdRoadCoverage);t.coverageSourceCaches[n.source]=m,m.setMaxzoomOverride(14),m.onAdd(s.map);const g=s._otherSourceCaches[n.source];g&&g._sourceLoaded&&(m._sourceLoaded=!0)},updateFrcCoverageFadeRange:function(s,t){let n=null,l=null;const d={globals:{zoom:0}};s.forEachFragmentStyle(p=>{if(n)return;const m=p.stylesheet?p.stylesheet.schema:null;if(!m||!m.sdCoverageFadeRange)return;const g=u.y("sdCoverageFadeRange",p.scope),x=p.options?p.options.get(g):void 0,w=x?x.value||x.default:null;if(w){const M=w.evaluate(d);Array.isArray(M)&&M.length===2&&(M[0]>0||M[1]>0)&&(n=[M[0],M[1]])}const S=u.y("sdCoverageSourceLayers",p.scope),A=p.options?p.options.get(S):void 0,I=A?A.value||A.default:null;if(I){const M=I.evaluate(d);Array.isArray(M)&&M.length>0&&(l=M)}else{const M=s.stylesheet&&s.stylesheet.imports||[];for(const D of M)if(D.id===p.scope){const L=D.config?D.config.sdCoverageSourceLayers:void 0;Array.isArray(L)&&L.length>0&&(l=L);break}}}),t.frcCoverageFadeRange=n,t.frcCoverageSourceLayers=n!=null?l||["road","structure"]:[]},HdElevationState:wl,setupAndUpdateElevationCoverage:function(s){if(!(function(p){for(const m in p._mergedLayers)if(ff(p._mergedLayers[m]))return!0;return!1})(s))return void gf(s);const t=Xl(s,s.map&&s.map.transform);s._hdElevation||(s._hdElevation=new wl);const n=s._hdElevation._terrainActiveLast;if(s._hdElevation._terrainActiveLast=t,n!==void 0&&n!==t&&uu(s,void 0,!0),t)return void(s.map.painter&&(s.map.painter.elevationCoverageSnapshot=null));if(!mf(s))return void gf(s);n===void 0&&uu(s,void 0,!0);const l=s._hdElevation;l._needsCrossSourceElevation=!0,s._crossSourceElevationActive=!0,l._ingestFQIDs=bc(s);const d=pf(s);s.forEachFragmentStyle(p=>{for(const m of d){if(!As(m,p.scope))continue;const g=u.dD(m);if(p._otherSourceCaches[g]||p._symbolSourceCaches[g])continue;const x=p.getOwnSource(g);x&&x.type==="vector"&&(p._hdElevation||(p._hdElevation=new wl),yf(p,p._hdElevation,x))}}),s.mergeSources(),xf(s,l)},updateElevationCoverage:xf,updateHdElevationSourceCache:yf,markElevationIngestSourceCachesUsed:function(s){if(!s._hdElevation||!s._hdElevation._needsCrossSourceElevation)return;const t=s._hdElevation._ingestFQIDs;if(t)for(const n of t){const l=cu(s,n);l&&(l.used=!0)}},updateCrossSourceElevationGate:function(s){s._crossSourceElevationActive=mf(s);const t=s._mergedHdRoadElevationSourceCaches;t&&Object.keys(t).length!==0&&(s._hdElevation||(s._hdElevation=new wl),s._hdElevation._needsCrossSourceElevation=s._crossSourceElevationActive)},buildElevationRequestParams:function(s,t,n){if(t.renderSourceType===u.dA.HdRoadElevation||Xl(s.style,s.transform)||!n)return null;const l=s.painter?s.painter.elevationCoverageSnapshot:null,d=!(!s.painter||!s.painter.elevationProvidersReady);return l?(function(p,m,g){const x=p.getTilesIntersecting(m);if(x.length===0)return{registry:[],hasCoveringTile:!1,allProvidersReady:g};const w=[];for(const S of x)for(const A of S.features)w.push({tileId:S.tileId,feature:A});return w.sort((S,A)=>S.feature.id-A.feature.id),{registry:w,hasCoveringTile:!0,allProvidersReady:g}})(l,t.tileID.canonical,d):{registry:[],hasCoveringTile:!1,allProvidersReady:d}},FrcCoverageRenderer:class{constructor(){this.tileBuffers=new Map,this._context=null}update(s,t){this._context=s;const n=new Set;for(const l of t){if(l.frcMask===0)continue;let d=!1;for(const m of l.polygons)if(m.hasGeometry()){d=!0;break}if(!d)continue;const p=`${l.tileId.z}/${l.tileId.x}/${l.tileId.y}`;if(n.add(p),!this.tileBuffers.has(p)){const m=this._createBuffers(s,l);m&&this.tileBuffers.set(p,m)}}for(const l of this.tileBuffers.keys())if(!n.has(l)){const d=this.tileBuffers.get(l);d.vertexBuffer.destroy(),d.indexBuffer.destroy();for(const p of d.frcLevelSegments)p&&p.destroy();this.tileBuffers.delete(l)}}getBuffers(s){return this.tileBuffers.get(`${s.z}/${s.x}/${s.y}`)||null}destroy(){for(const s of this.tileBuffers.values()){s.vertexBuffer.destroy(),s.indexBuffer.destroy();for(const t of s.frcLevelSegments)t&&t.destroy()}this.tileBuffers.clear()}_createBuffers(s,t){const n=new u.co,l=new u.cp,d=[];for(const m of t.polygons){if(!m.hasGeometry()||m.rings.length===0)continue;const g=n.length,x=l.length,w=n.length,S=[],A=[];let I=0;for(let D=0;D<m.rings.length;D++){const L=m.rings[D];if(!(L.length<3)){D>0&&A.push(I);for(const k of L)n.emplaceBack(k.x,k.y),S.push(k.x,k.y),I++}}const M=u.d1(S,A.length>0?A:void 0);for(let D=0;D<M.length;D+=3)l.emplaceBack(w+M[D],w+M[D+1],w+M[D+2]);d.push({vertexOffset:g,indexOffset:x,vertexCount:n.length-g,indexCount:l.length-x,frcMask:m.frcMask})}if(n.length===0)return null;const p=new Array(9).fill(null);for(let m=0;m<9;++m){const g=1<<m;if((t.frcMask&g)===0)continue;let x=1/0,w=0,S=0,A=!1;for(const I of d)(I.frcMask&g)!==0&&(x=Math.min(x,I.indexOffset),w=Math.max(w,I.indexOffset+I.indexCount),S=Math.max(S,I.vertexOffset+I.vertexCount),A=!0);A&&(p[m]=u.cr.simpleSegment(0,x,S,w-x))}return{vertexBuffer:s.createVertexBuffer(n,u.cq.members),indexBuffer:s.createIndexBuffer(l),frcLevelSegments:p}}},drawFillFrcCoverageFirstPass:function(s){const{painter:t,bucket:n,coord:l,elevatedGeometry:d}=s,p=n.sourceLayerName==="road",m=n.sourceLayerName==="structure";if(!p&&!m||!t.frcCoverageSnapshot||d)return"fallthrough";const g=t.frcCoverageSnapshot.getTileOrParent(l.canonical);if(!g||g.frcMask===0)return"fallthrough";const x=n.hdExt&&n.hdExt.frcData,w=!!x&&!x.empty(),S=wf(g.polygons);if(m&&!S)return"skip";if(m&&S)return s.polygonCoverageTiles.push({coord:s.coord,bufferData:s.bufferData,program:s.program,programConfiguration:s.programConfiguration,uniformValues:s.uniformValues,depthMode:s.depthMode,dynamicBuffers:s.dynamicBuffers,indexBuffer:s.indexBuffer,segments:s.segments,frcMask:g.frcMask}),"deferred";if(p&&w&&x){const A=g.frcMask,I=t.transform.zoom;for(const[M,D]of x.frcPerLevel)A&1<<M||D.segments.length!==0&&s.program.draw(t,s.drawMode,s.depthMode,s.stencilMode,s.colorMode,_t.disabled,s.uniformValues,s.layer.id,s.bufferData.layoutVertexBuffer,s.indexBuffer,D,s.layer.paint,I,s.programConfiguration,s.dynamicBuffers);return x.frcNonRoadSegments.segments.length>0&&s.program.draw(t,s.drawMode,s.depthMode,s.stencilMode,s.colorMode,_t.disabled,s.uniformValues,s.layer.id,s.bufferData.layoutVertexBuffer,s.indexBuffer,x.frcNonRoadSegments,s.layer.paint,I,s.programConfiguration,s.dynamicBuffers),"drawn"}return"fallthrough"},drawFillFrcCoverageSecondPass:function(s,t,n,l,d){if(n.length===0)return;const p=Ih(s),m=s.transform.zoom,g=(x,w,S)=>{S!==1&&(x.uniformValues.u_opacity_multiplier=S),x.program.draw(s,l,x.depthMode,w,d,_t.disabled,x.uniformValues,t.id,x.bufferData.layoutVertexBuffer,x.indexBuffer,x.segments,t.paint,m,x.programConfiguration,x.dynamicBuffers),S!==1&&(x.uniformValues.u_opacity_multiplier=1)};bf(s,n,p,(x,w,S)=>g(x,S,1),(x,w,S)=>g(x,S,p))},drawLineFrcCoverageDetect:function(s,t,n,l,d,p,m,g,x,w){const S=t.hdExt&&t.hdExt.frcData;if(!S||S.frcPerLevel.size===0||!s.frcCoverageSnapshot||l)return null;const A=s.frcCoverageSnapshot.getTileOrParent(n.canonical);if(!A||A.frcMask===0)return null;const I=wf(A.polygons),M=s.frcCoverageFadeRange,D=M!=null&&s.transform.zoom>=M[0];if(I&&D){let L=!1;for(const k of S.frcPerLevel.keys())if(A.frcMask&1<<k){L=!0;break}L&&w.push({coord:n,bucket:t,uniformValues:d,programConfiguration:p,program:m,depthMode:g,colorMode:x,frcMask:A.frcMask})}return{coverageTile:A,frcMask:A.frcMask,active:D,hasPolygonGeometry:I}},drawLineFrcRenderLine:function(s,t,n,l){const d=s.hdExt&&s.hdExt.frcData;if(!d)return;const p=t.frcMask;for(const[g,x]of d.frcPerLevel)p&1<<g||l(n,x);const m=d.frcNonRoadSegments;m.segments.length>0&&l(n,m)},drawLineFrcFadePass:function(s,t,n,l,d,p,m){if(l.hasPolygonGeometry)return;const g=t.hdExt&&t.hdExt.frcData;if(!g||!s.frcCoverageFadeRange)return;const[x,w]=s.frcCoverageFadeRange;if(x>=w)return;const S=1-Math.max(0,Math.min(1,(s.transform.zoom-x)/(w-x)));if(S<=0)return;const A=d?p:s.stencilModeForClipping(n),I=l.frcMask;for(const[M,D]of g.frcPerLevel)I&1<<M&&m(A,D,S)},drawLineFrcCoverageSecondPass:function(s,t,n){if(n.length===0)return;const l=s.context.gl,d=Ih(s),p=s.transform.zoom,m=(g,x,w,S)=>{const A=g.bucket.hdExt&&g.bucket.hdExt.frcData,I=A&&A.frcPerLevel.get(x);I&&I.segments.length!==0&&(S!==1&&(g.uniformValues.u_opacity_multiplier=S),g.program.draw(s,l.TRIANGLES,g.depthMode,w,g.colorMode,_t.disabled,g.uniformValues,t.id,g.bucket.layoutVertexBuffer,g.bucket.indexBuffer,I,t.paint,p,g.programConfiguration,[g.bucket.layoutVertexBuffer2,g.bucket.patternVertexBuffer,g.bucket.zOffsetVertexBuffer,g.bucket.elevationIdColVertexBuffer,g.bucket.elevationGroundScaleVertexBuffer]),S!==1&&(g.uniformValues.u_opacity_multiplier=1))};bf(s,n,d,(g,x,w)=>m(g,x,w,1),(g,x,w)=>m(g,x,w,d))}},jt=Hm;async function hu(){return Promise.resolve()}class du{constructor(t,n,l){this.screenBounds=t,this.cameraPoint=l.getCameraPoint(),this._screenRaycastCache={},this._cameraRaycastCache={},this.isAboveHorizon=n,this.screenGeometry=this.bufferedScreenGeometry(0),this.screenGeometryMercator=this._bufferedScreenMercator(0,l)}static createFromScreenPoints(t,n){let l,d;if(t instanceof u.P||typeof t[0]=="number"){const p=u.P.convert(t);l=[p],d=n.isPointAboveHorizon(p)}else{const p=u.P.convert(t[0]),m=u.P.convert(t[1]),g=p.add(m)._div(2);l=[p,m],d=u.dF(p,m).every(x=>n.isPointAboveHorizon(x))&&n.isPointAboveHorizon(g)}return new du(l,d,n)}isPointQuery(){return this.screenBounds.length===1}bufferedScreenGeometry(t){return u.dF(this.screenBounds[0],this.screenBounds.length===1?this.screenBounds[0]:this.screenBounds[1],t)}bufferedCameraGeometry(t){const n=this.screenBounds[0],l=this.screenBounds.length===1?this.screenBounds[0].add(new u.P(1,1)):this.screenBounds[1],d=u.dF(n,l,0,!1);return this.cameraPoint.y>l.y&&(this.cameraPoint.x>n.x&&this.cameraPoint.x<l.x?d.splice(3,0,this.cameraPoint):this.cameraPoint.x>=l.x?d[2]=this.cameraPoint:this.cameraPoint.x<=n.x&&(d[3]=this.cameraPoint)),u.dG(d,t)}bufferedCameraGeometryGlobe(t){const n=this.screenBounds[0],l=this.screenBounds.length===1?this.screenBounds[0].add(new u.P(1,1)):this.screenBounds[1],d=u.dF(n,l,t),p=this.cameraPoint.clone(),m=+(p.x>n.x)+ +(p.x>l.x);switch(3*(+(p.y>n.y)+ +(p.y>l.y))+m){case 0:d[0]=p,d[4]=p.clone();break;case 1:d.splice(1,0,p);break;case 2:d[1]=p;break;case 3:d.splice(4,0,p);break;case 5:d.splice(2,0,p);break;case 6:d[3]=p;break;case 7:d.splice(3,0,p);break;case 8:d[2]=p}return d}containsTile(t,n,l,d=0,p){const m=Math.max(t.queryPadding,t.evaluateQueryRenderedFeaturePadding())/n._pixelsPerMercatorPixel+1,g=l?this._bufferedCameraMercator(m,n):this._bufferedScreenMercator(m,n);let x=t.tileID.wrap+(g.unwrapped?d:0);const w=g.polygon.map(k=>u.dH(t.tileTransform,k,x));if(!u.bp(w,0,0,u.aj,u.aj))return;x=t.tileID.wrap+(this.screenGeometryMercator.unwrapped?d:0);const S=this.screenGeometryMercator.polygon.map(k=>u.dI(t.tileTransform,k,x)),A=S.map(k=>new u.P(k[0],k[1])),I=u.dI(t.tileTransform,p,x),M=S.map(k=>{const B=u.aW(k,k,I);return u.au(B,B),new u.bC(I,B)}),D=u.c1(t,1,n.zoom)*n._pixelsPerMercatorPixel;return{queryGeometry:this,tilespaceGeometry:A,tilespaceRays:M,bufferedTilespaceGeometry:w,bufferedTilespaceBounds:(L=u.dJ(w),L.min.x=u.as(L.min.x,0,u.aj),L.min.y=u.as(L.min.y,0,u.aj),L.max.x=u.as(L.max.x,0,u.aj),L.max.y=u.as(L.max.y,0,u.aj),L),tile:t,tileID:t.tileID,pixelToTileUnitsFactor:D};var L}_bufferedScreenMercator(t,n){const l=Zm(t);if(this._screenRaycastCache[l])return this._screenRaycastCache[l];{let d;return d=n.projection.name==="globe"?this._projectAndResample(this.bufferedScreenGeometry(t),n):{polygon:this.bufferedScreenGeometry(t).map(p=>n.pointCoordinate3D(p)),unwrapped:!0},this._screenRaycastCache[l]=d,d}}_bufferedCameraMercator(t,n){const l=Zm(t);if(this._cameraRaycastCache[l])return this._cameraRaycastCache[l];{let d;return d=n.projection.name==="globe"?this._projectAndResample(this.bufferedCameraGeometryGlobe(t),n):{polygon:this.bufferedCameraGeometry(t).map(p=>n.pointCoordinate3D(p)),unwrapped:!0},this._cameraRaycastCache[l]=d,d}}_projectAndResample(t,n){const l=(function(p,m){const g=u.aP([],m.pixelMatrix,m.globeMatrix),x=[0,-u.dK,0,1],w=[0,u.dK,0,1],S=[0,0,0,1];u.aO(x,x,g),u.aO(w,w,g),u.aO(S,S,g);const A=new u.P(x[0]/x[3],x[1]/x[3]),I=new u.P(w[0]/w[3],w[1]/w[3]),M=u.dL(p,A)&&x[3]<S[3],D=u.dL(p,I)&&w[3]<S[3];if(!M&&!D)return null;const L=(function(K,Q,ae){for(let de=1;de<K.length;de++){const fe=Tl(Q.pointCoordinate3D(K[de-1]).x),be=Tl(Q.pointCoordinate3D(K[de]).x);if(ae<0){if(fe<be)return{idx:de,t:-fe/(be-1-fe)}}else if(be<fe)return{idx:de,t:(1-fe)/(be+1-fe)}}return null})(p,m,M?-1:1);if(!L)return null;const{idx:k,t:B}=L;let $=k>1?fu(p.slice(0,k),m):[],Z=k<p.length?fu(p.slice(k),m):[];$=$.map(K=>new u.P(Tl(K.x),K.y)),Z=Z.map(K=>new u.P(Tl(K.x),K.y));const G=[...$];G.length===0&&G.push(Z.at(-1));const te=G.at(-1),ee=u.ai(te.y,(Z.length===0?$[0]:Z[0]).y,B);let le;return le=M?[new u.P(0,ee),new u.P(0,0),new u.P(1,0),new u.P(1,ee)]:[new u.P(1,ee),new u.P(1,1),new u.P(0,1),new u.P(0,ee)],G.push(...le),Z.length===0?G.push($[0]):G.push(...Z),{polygon:G.map(K=>new u.ac(K.x,K.y)),unwrapped:!1}})(t,n);if(l)return l;const d=(function(p,m){let g=!1,x=-1/0,w=0;for(let A=0;A<p.length-1;A++)p[A].x>x&&(x=p[A].x,w=A);for(let A=0;A<p.length-1;A++){const I=(w+A)%(p.length-1),M=p[I],D=p[I+1];Math.abs(M.x-D.x)>.5&&(M.x<D.x?(M.x+=1,I===0&&(p.at(-1).x+=1)):(D.x+=1,I+1===p.length-1&&(p[0].x+=1)),g=!0)}const S=u.a_(m.center.lng);return g&&S<Math.abs(S-1)&&p.forEach(A=>{A.x-=1}),{polygon:p,unwrapped:g}})(fu(t,n).map(p=>new u.P(Tl(p.x),p.y)),n);return{polygon:d.polygon.map(p=>new u.ac(p.x,p.y)),unwrapped:d.unwrapped}}}function fu(s,t){return u.dM(s,n=>{const l=t.pointCoordinate3D(n);n.x=l.x,n.y=l.y},1/256)}function Tl(s){return s<0?1+s%1:s%1}function Zm(s){return 100*s|0}class Wm extends u.E{constructor(t,n,l,d){if(super(),this.id=t,this.dispatcher=l,this.type="vector",this.provider=n.provider,this.minzoom=0,this.maxzoom=22,this.scheme="xyz",this.tileSize=512,this.reparseOverscaled=!0,this.isTileClipped=!0,this._loaded=!1,Object.assign(this,u.b5(n,["url","scheme","tileSize","promoteId"])),this._options={type:"vector",...n},this._collectResourceTiming=!!n.collectResourceTiming,this.tileSize!==512)throw new Error("vector tile sources must have a tileSize of 512");this.setEventedParent(d),this._tileWorkers={},this._deduped=new u.dN}load(t){this._loaded=!1,this.fire(new u.B("dataloading",{dataType:"source"}));const n=Array.isArray(this.map._language)?this.map._language.join():this.map._language,l=this.map.getWorldview(),d=(m,g)=>{this._tileJSONRequest=null,this._loaded=!0,m?(n&&console.warn(`Ensure that your requested language string is a valid BCP-47 code or list of codes. Found: ${n}`),l&&console.warn(`Requested worldview strings must be a valid ISO alpha-2 code. Found: ${l}`),this.fire(new u.A(m))):g&&(this._setTileJSON(g),jt.updateCrossSourceElevationGate&&this.map.style&&jt.updateCrossSourceElevationGate(this.map.style),Xo(g.tiles,this.map._requestManager._customAccessToken),this.fire(new u.B("data",{dataType:"source",sourceDataType:"metadata"})),this.fire(new u.B("data",{dataType:"source",sourceDataType:"content"}))),t&&t(m)};this.provider=this._options.provider;const p=u.db(this._options);return p instanceof Error?(this._loaded=!0,this.fire(new u.A(p)),void(t&&t())):this.provider&&!p?(this._loaded=!0,this.fire(new u.A(new Error(`TileProvider "${this.provider}" is not registered`))),void(t&&t())):void(this._tileJSONRequest=p?this.loadTileJSONWithProvider(p,d):u.dc(this._options,this.map._requestManager,n,l,d))}loadTileJSONWithProvider(t,n){this.provider=t.name;const l=new AbortController;return(async()=>{const{request:d,options:p}=await u.df(this._options,this.map._requestManager,l.signal);if(l.signal.aborted)return;const m=await this.dispatcher.send("loadTileProvider",{name:t.name,url:t.url,source:this.id,scope:this.scope,type:this.type,options:p,request:d},{signal:l.signal});if(l.signal.aborted)return;const g=m?m.find(w=>w!=null):null,x=u.dh(this._options,g,this.map._requestManager);x instanceof Error?n(x):n(null,x)})().catch(d=>{l.signal.aborted||n(d)}),{cancel:()=>l.abort()}}_setTileJSON(t){if(Object.assign(this,t),this.hasWorldviews=!!t.worldview_options,t.worldview_default&&(this.worldviewDefault=t.worldview_default),t.vector_layers){this.vectorLayers=t.vector_layers,this.vectorLayerIds=[],this.localizableLayerIds=new Set;for(const n of t.vector_layers)this.vectorLayerIds.push(n.id),t.worldview&&t.worldview[n.source]&&this.localizableLayerIds.add(n.id)}this.tileBounds=Ba.fromTileJSON(t)}loaded(){return this._loaded}hasTile(t){return!this.tileBounds||this.tileBounds.contains(t.canonical)}onAdd(t){this.map=t,this.load()}reload(){this.cancelTileJSONRequest();const t=u.y(this.id,this.scope);this.load(()=>this.map.style.clearSource(t))}setTiles(t){return this._options.tiles=t,this.reload(),this}setUrl(t){return this.url=t,this._options.url=t,this.reload(),this}onRemove(t){this.cancelTileJSONRequest()}serialize(){return{...this._options}}async loadTile(t,n){const l=t.tileID.canonical.url(this.tiles,this.scheme),d=this.map._requestManager.normalizeTileURL(l),p=!t.actor||t.state==="expired";if(!p&&t.state==="loading")return void(t.reloadCallback=n);p&&(t.actor=this._tileWorkers[d]=this._tileWorkers[d]||this.dispatcher.getActor());const m=new AbortController;t.request=m;try{const g=await this.map._requestManager.transformRequest(d,u.R.Tile,m.signal);if(m.signal.aborted)return n(null);this.dispatchTile(t,d,l,g,m,p,n)}catch(g){if(m.signal.aborted)return n(null);n(g)}}dispatchTile(t,n,l,d,p,m,g){const x=this.map.style?this.map.style.getLut(this.scope):null,w=x?{image:x.image.clone()}:null,S=!(!this.map.style||!this.map.style._crossSourceElevationActive),A=!(!this.map.style||!S),I={request:d,data:void 0,uid:t.uid,tileID:t.tileID,tileZoom:t.tileZoom,zoom:t.tileID.overscaledZ,maxZoom:this.maxzoom,lut:w,tileSize:this.tileSize*t.tileID.overscaleFactor(),type:this.type,source:this.id,scope:this.scope,pixelRatio:u.r.devicePixelRatio,showCollisionBoxes:this.map.showCollisionBoxes,showElevationIdDebug:!!this.map.painter&&this.map.painter._debugParams.showElevationIdDebug,promoteId:this.promoteId,renderSourceType:t.renderSourceType,frcCoverage:(()=>{const D=this.map.painter,L=D?D.frcCoverageFadeRange:null;if(L==null)return null;const k=D?D.frcCoverageSnapshot:null,B=this.map.transform.zoom<L[0],$=k?k.getTileOrParent(t.tileID.canonical):null,Z=t.tileID.overscaledZ>=Math.ceil(L[1]),G=k&&Z?k.getFullCoverageMask(t.tileID.canonical):null;return{frcMask:Z&&G!=null?G:null,resolved:B||k!=null,polygons:$&&$.frcMask!==0?$.polygons:null,tileZoom:$&&$.frcMask!==0?$.tileId.z:null,sourceLayers:D?D.frcCoverageSourceLayers:["road","structure"]}})(),terrainEnabled:Xl(this.map.style,this.map.transform),crossSourceElevationEnabled:A,elevation:jt.buildElevationRequestParams?jt.buildElevationRequestParams(this.map,t,S):null,brightness:this.map.style&&this.map.style.getBrightness()||0,extraShadowCaster:t.isExtraShadowCaster,tessellationStep:this.map._tessellationStep,scaleFactor:this.map.getScaleFactor(),worldview:this.map.getWorldview()||this.worldviewDefault,indoor:this.map.getIndoorTileOptions(this.id,this.scope)};if(this.hasWorldviews&&u.e(l)&&(I.localizableLayerIds=this.localizableLayerIds),I.request.collectResourceTiming=this._collectResourceTiming,m)if(this.dispatcher.ready||this.provider)t.request=t.actor.sendCancelable("loadTile",I,{},M.bind(this));else{const D=u.dO.call({deduped:this._deduped},I,(L,k)=>{t.aborted||(L||!k?M.call(this,L):(I.data={rawData:k.rawData.slice(0),headers:k.headers},t.actor&&(t.request=t.actor.sendCancelable("loadTile",I,{},M.bind(this)))))},!0);p.signal.addEventListener("abort",D,{once:!0})}else t.request=t.actor.sendCancelable("reloadTile",I,{},M.bind(this));function M(D,L){return delete t.request,t.aborted?g(null):D?g(D):(L&&L.resourceTiming&&(t.resourceTiming=L.resourceTiming),this.map._refreshExpiredTiles&&L&&t.setExpiryData(u.dd(L.headers)),void(function(){if(t.aborted)return g(null);t.loadVectorData(L,this.map.painter),u.de(this.dispatcher),g(null,L),t.reloadCallback&&(this.loadTile(t,t.reloadCallback),t.reloadCallback=null)}).call(this))}}abortTile(t){t.request&&(t.request.abort(),delete t.request),t.actor&&t.actor.notify("abortTile",{uid:t.uid,type:this.type,source:this.id,scope:this.scope})}unloadTile(t,n){t.actor&&t.actor.notify("removeTile",{uid:t.uid,type:this.type,source:this.id,scope:this.scope}),t.destroy()}hasTransition(){return!1}afterUpdate(){this._tileWorkers={}}cancelTileJSONRequest(){this._tileJSONRequest&&(this._tileJSONRequest.cancel(),this._tileJSONRequest=null)}}function Ah(s,t,n,l,d,p,m,g){const x=[s,t,1,n,l,1,d,p,1],w=[m,g,1],S=u.dT([],x),[A,I,M]=u.c4(w,w,S);return u.dU(x,x,[A,0,0,0,I,0,0,0,M])}function Ch(s,t,n,l,d,p,m,g){const x=(function(w,S,A,I,M,D,L,k){const B=Ah(0,0,1,0,1,1,0,1),$=Ah(w,S,A,I,M,D,L,k),Z=u.dT([],B);return u.dU($,$,Z)})(s,t,n,l,d,p,m,g);return[x[2]/x[8]/u.aj,x[5]/x[8]/u.aj]}function Mh(s){return[s[0],Math.min(Math.max(s[1],-u.bA),u.bA)]}class No extends u.E{constructor(t,n,l,d){super(),this.id=t,this.dispatcher=l,this.coordinates=n.coordinates,this.type="image",this.minzoom=0,this.maxzoom=22,this.tileSize=512,this.tiles={},this._loaded=!1,this.onNorthPole=!1,this.onSouthPole=!1,this.setEventedParent(d),this.options=n,this._dirty=!1}async load(t,n){if(this._loaded=n||!1,this.fire(new u.B("dataloading",{dataType:"source"})),this.url=this.options.url,!this.url)return t&&(this.coordinates=t),this._loaded=!0,void this._finishLoading();const l=new AbortController;this._imageRequest=l;try{const d=await this.map._requestManager.transformRequest(this.url,u.R.Image,l.signal),{data:p}=await u.q(d,l.signal);this._imageRequest=null,this._loaded=!0,this.image=p,this._dirty=!0,this.width=this.image.width,this.height=this.image.height,t&&(this.coordinates=t),this._finishLoading()}catch(d){if(l.signal.aborted)return;this._imageRequest=null,this._loaded=!0,this.fire(new u.A(d))}}loaded(){return this._loaded}updateImage(t){return t.url?(this._imageRequest&&t.url!==this.options.url&&(this._imageRequest.abort(),this._imageRequest=null),this.options.url=t.url,this.load(t.coordinates,this._loaded),this):this}setTexture(t){if(!(t.handle instanceof WebGLTexture))throw new Error("The provided handle is not a WebGLTexture instance");return this.texture=new u.dP(this.map.painter.context,t.handle),this.width=t.dimensions[0],this.height=t.dimensions[1],this._dirty=!1,this._loaded=!0,this._finishLoading(),this}_finishLoading(){this.map&&(this.setCoordinates(this.coordinates),this.fire(new u.B("data",{dataType:"source",sourceDataType:"metadata"})))}onAdd(t){this.map=t,this.load()}onRemove(t){this._imageRequest&&(this._imageRequest.abort(),this._imageRequest=null),!this.texture||this.texture instanceof u.dP||this.texture.destroy(),this.boundsBuffer&&(this.boundsBuffer.destroy(),this.elevatedGlobeVertexBuffer&&this.elevatedGlobeVertexBuffer.destroy(),this.elevatedGlobeIndexBuffer&&this.elevatedGlobeIndexBuffer.destroy())}setCoordinates(t){if(this.coordinates=t,this._boundsArray=void 0,this._unsupportedCoords=!1,!t.length)return this;this.onNorthPole=!1,this.onSouthPole=!1;let n=t[0][1],l=t[0][1];for(const p of t)p[1]>l&&(l=p[1]),p[1]<n&&(n=p[1]);const d=(l+n)/2;if(d>u.bA?this.onNorthPole=!0:d<-u.bA&&(this.onSouthPole=!0),!this.onNorthPole&&!this.onSouthPole){const p=t.map(u.ac.fromLngLat);this.tileID=(function(m){let g=1/0,x=1/0,w=-1/0,S=-1/0;for(const L of m)g=Math.min(g,L.x),x=Math.min(x,L.y),w=Math.max(w,L.x),S=Math.max(S,L.y);const A=Math.max(w-g,S-x),I=Math.max(0,Math.floor(-Math.log2(A))),M=Math.pow(2,I);let D=Math.floor((g+w)/2*M);return D>1&&(D-=1),new u.bu(I,D,Math.floor((x+S)/2*M))})(p),this.minzoom=this.maxzoom=this.tileID.z}return this.fire(new u.B("data",{dataType:"source",sourceDataType:"content"})),this}_clear(){!this.texture||this.texture instanceof u.dP||(this.texture.destroy(),this._dirty=!0),this.texture=null,this._boundsArray=void 0,this._unsupportedCoords=!1}_prepareData(t){for(const te in this.tiles){const ee=this.tiles[te];ee.state!=="loaded"&&(ee.state="loaded",ee.texture=this.texture)}if(this._boundsArray||this.onNorthPole||this.onSouthPole||this._unsupportedCoords)return;const n=u.cO(new u.bu(0,0,0),this.map.transform.projection),l=[n.projection.project(this.coordinates[0][0],this.coordinates[0][1]),n.projection.project(this.coordinates[1][0],this.coordinates[1][1]),n.projection.project(this.coordinates[2][0],this.coordinates[2][1]),n.projection.project(this.coordinates[3][0],this.coordinates[3][1])];if(!(function(te){const ee=te[1].x-te[0].x,le=te[1].y-te[0].y,K=te[2].x-te[1].x,Q=te[2].y-te[1].y,ae=te[3].x-te[2].x,de=te[3].y-te[2].y,fe=te[0].x-te[3].x,be=te[0].y-te[3].y,Te=ee*Q-K*le,Ve=K*de-ae*Q,ye=ae*be-fe*de,Ae=fe*le-ee*be;return Te>0&&Ve>0&&ye>0&&Ae>0||Te<0&&Ve<0&&ye<0&&Ae<0})(l))return console.warn("Image source coordinates are defining non-convex area in the Mercator projection"),void(this._unsupportedCoords=!0);const d=u.cO(this.tileID,this.map.transform.projection),[p,m,g,x]=this.coordinates.map(te=>{const ee=d.projection.project(te[0],te[1]);return u.dH(d,ee)._round()});this.perspectiveTransform=Ch(p.x,p.y,m.x,m.y,g.x,g.y,x.x,x.y);const w=this._boundsArray=new u.cQ;w.emplaceBack(p.x,p.y,0,0),w.emplaceBack(m.x,m.y,u.aj,0),w.emplaceBack(x.x,x.y,0,u.aj),w.emplaceBack(g.x,g.y,u.aj,u.aj),this.boundsBuffer&&(this.boundsBuffer.destroy(),this.elevatedGlobeVertexBuffer&&this.elevatedGlobeVertexBuffer.destroy(),this.elevatedGlobeIndexBuffer&&this.elevatedGlobeIndexBuffer.destroy()),this.boundsBuffer=t.createVertexBuffer(w,_h.members),this.boundsSegments=u.cr.simpleSegment(0,0,4,2);const S=u.dS,A=S+1,I=S+1,M=A*I,D=S*S*2,L=[],k=(function(te){return[Mh(te[0]),Mh(te[1]),Mh(te[2]),Mh(te[3])]})(this.coordinates),[B,$,Z,G]=(function(te){let ee=te[0][0],le=ee,K=te[0][1],Q=K;for(let ae=1;ae<te.length;ae++)te[ae][0]<ee?ee=te[ae][0]:te[ae][0]>le&&(le=te[ae][0]),te[ae][1]<K?K=te[ae][1]:te[ae][1]>Q&&(Q=te[ae][1]);return[ee,K,le-ee,Q-K]})(k);{const te=new u.cQ,[ee,le,K,Q]=(function(De){let Ke=De[0].x,Be=Ke,Ge=De[0].y,Ze=Ge;for(let tt=1;tt<De.length;tt++)De[tt].x<Ke?Ke=De[tt].x:De[tt].x>Be&&(Be=De[tt].x),De[tt].y<Ge?Ge=De[tt].y:De[tt].y>Ze&&(Ze=De[tt].y);return[Ke,Ge,Be-Ke,Ze-Ge]})(l),ae=De=>[(De.x-ee)/K,(De.y-le)/Q],[de,fe,be,Te]=l.map(ae),Ve=(function(De,Ke,Be,Ge,Ze,tt,ot,at){const ut=Ah(0,0,1,0,1,1,0,1),bt=Ah(De,Ke,Be,Ge,Ze,tt,ot,at),pt=u.dT([],bt);return u.dU(ut,ut,pt)})(de[0],de[1],fe[0],fe[1],be[0],be[1],Te[0],Te[1]);this.elevatedGlobePerspectiveTransform=Ch(de[0],de[1],fe[0],fe[1],be[0],be[1],Te[0],Te[1]);const ye=(De,Ke)=>{L.push(De.lng);const Be=Math.round((De.lng-B)/Z*u.aj),Ge=Math.round((De.lat-$)/G*u.aj),Ze=ae(Ke),tt=u.c4([],[Ze[0],Ze[1],1],Ve),ot=Math.round(tt[0]/tt[2]*u.aj),at=Math.round(tt[1]/tt[2]*u.aj);te.emplaceBack(Be,Ge,ot,at)},Ae=l[3].x-l[0].x,ge=l[3].y-l[0].y,Fe=l[2].x-l[1].x,Re=l[2].y-l[1].y;for(let De=0;De<I;De++){const Ke=De/S,Be=[l[0].x+Ke*Ae,l[0].y+Ke*ge],Ge=[l[1].x+Ke*Fe,l[1].y+Ke*Re],Ze=Ge[0]-Be[0],tt=Ge[1]-Be[1];for(let ot=0;ot<A;ot++){const at=ot/S,ut={x:Be[0]+Ze*at,y:Be[1]+tt*at};ye(n.projection.unproject(ut.x,ut.y),ut)}}this.elevatedGlobeVertexBuffer=t.createVertexBuffer(te,_h.members)}{this.maxLongitudeTriangleSize=0;let te=[],ee=new u.cp;const le=(K,Q,ae)=>{ee.emplaceBack(K,Q,ae);const de=L[K],fe=L[Q],be=L[ae],Te=Math.min(Math.min(de,fe),be),Ve=Math.max(Math.max(de,fe),be)-Te;Ve>this.maxLongitudeTriangleSize&&(this.maxLongitudeTriangleSize=Ve),te.push(Te+Ve/2)};for(let K=0;K<S;K++)for(let Q=0;Q<S;Q++){const ae=K*A+Q,de=ae+1,fe=ae+A,be=fe+1;le(ae,fe,de),le(de,fe,be)}[te,ee]=(function(K,Q){const ae=Array.from({length:K.length},(be,Te)=>Te);ae.sort((be,Te)=>K[be]-K[Te]);const de=[],fe=new u.cp;for(let be=0;be<ae.length;be++){const Te=ae[be];de.push(K[Te]);const Ve=3*Te,ye=Ve+1;fe.emplaceBack(Q.uint16[Ve],Q.uint16[ye],Q.uint16[ye+1])}return[de,fe]})(te,ee),this.elevatedGlobeTrianglesCenterLongitudes=te,this.elevatedGlobeIndexBuffer=t.createIndexBuffer(ee)}this.elevatedGlobeSegments=u.cr.simpleSegment(0,0,M,D),this.elevatedGlobeGridMatrix=new Float32Array([0,Z/u.aj,0,G/u.aj,0,0,$,B,0])}prepare(){const t=Object.keys(this.tiles).length!==0;if(this.tileID&&!t)return;const n=this.map.painter.context,l=n.gl;!this._dirty||this.texture instanceof u.dP||(this.texture?this.texture.update(this.image):(this.texture=new u.T(n,this.image,l.RGBA8),this.texture.bind(l.LINEAR,l.CLAMP_TO_EDGE)),this._dirty=!1),t&&this._prepareData(n)}loadTile(t,n){this.tileID&&this.tileID.equals(t.tileID.canonical)?(this.tiles[String(t.tileID.wrap)]=t,t.buckets={},n(null)):(t.state="errored",n(null))}serialize(){return{type:"image",url:this.options.url,coordinates:this.coordinates}}hasTransition(){return!1}getSegmentsForLongitude(t){const n=this.elevatedGlobeSegments;if(!this.elevatedGlobeTrianglesCenterLongitudes||!n)return null;const l=this.elevatedGlobeTrianglesCenterLongitudes;let d=(p=t+180)+360*Math.round((l[0]-p)/360);var p;const m=new u.cr,g=(A,I)=>{m.segments.push({vertexOffset:0,primitiveOffset:A,vertexLength:n.segments[0].vertexLength,primitiveLength:I,sortKey:void 0,vaos:{}})},x=.51*this.maxLongitudeTriangleSize;if(Math.abs(l[0]-d)<=x){const A=u.dQ(l,0,l.length,d+x);return A===l.length||g(A,u.dR(l,A+1,l.length,d+360-x)-A),m}d<l[0]&&(d+=360);const w=u.dR(l,0,l.length,d-x);if(w===l.length)return g(0,l.length),m;g(0,w-0);const S=u.dQ(l,w+1,l.length,d+x);return S!==l.length&&g(S,l.length-S),m}}const Tf={vector:Wm,raster:gc,"raster-dem":class extends gc{constructor(s,t,n,l){super(s,t,n,l),this.type="raster-dem",this.maxzoom=22,this._options={type:"raster-dem",...t},this.encoding=t.encoding||"mapbox"}loadTileJSONWithProvider(s,t){this.provider=s.name;const n=new AbortController;return(async()=>{const{request:l,options:d}=await u.df(this._options,this.map._requestManager,n.signal);if(n.signal.aborted)return;const p=await this.dispatcher.send("loadTileProvider",{name:s.name,url:s.url,source:this.id,scope:this.scope,type:this.type,options:d,request:l},{signal:n.signal});if(n.signal.aborted)return;const m=p?p.find(x=>x!=null):null,g=u.dh(this._options,m,this.map._requestManager);g instanceof Error?t(g):t(null,g)})().catch(l=>{n.signal.aborted||t(l)}),{cancel:()=>n.abort()}}async loadTile(s,t){if(s.actor&&s.state!=="expired")return;const n=this.map._requestManager.normalizeTileURL(s.tileID.canonical.url(this.tiles,this.scheme),!1,this.tileSize);s.actor=this.dispatcher.getActor();const l=new AbortController;s.request=l;try{const d=await this.map._requestManager.transformRequest(n,u.R.Tile,l.signal);if(l.signal.aborted)return t(null);s.request=s.actor.sendCancelable("loadTile",{uid:s.uid,tileID:s.tileID,source:this.id,type:this.type,scope:this.scope,request:d,encoding:this.encoding},{},(function(p,m){return delete s.request,s.aborted?t(null):p?(s.state="errored",t(p)):(m&&(this.map._refreshExpiredTiles&&s.setExpiryData(u.dd(m.headers)),m.borderReady||s.neighboringTiles||(s.neighboringTiles=this._getNeighboringTiles(s.tileID)),s.dem=m.dem,s.dem.onDeserialize(),s.needsHillshadePrepare=!0,s.needsDEMTextureUpload=!0),s.state="loaded",void t(null))}).bind(this))}catch(d){if(l.signal.aborted)return t(null);s.state="errored",t(d)}}abortTile(s,t){s.request&&(s.request.abort(),delete s.request),s.actor&&s.actor.notify("abortTile",{uid:s.uid,type:this.type,source:this.id,scope:this.scope}),t&&t()}_getNeighboringTiles(s){const t=s.canonical,n=Math.pow(2,t.z),l=(t.x-1+n)%n,d=t.x===0?s.wrap-1:s.wrap,p=(t.x+1+n)%n,m=t.x+1===n?s.wrap+1:s.wrap,g={};return g[new u.br(s.overscaledZ,d,t.z,l,t.y).key]={backfilled:!1},g[new u.br(s.overscaledZ,m,t.z,p,t.y).key]={backfilled:!1},t.y>0&&(g[new u.br(s.overscaledZ,d,t.z,l,t.y-1).key]={backfilled:!1},g[new u.br(s.overscaledZ,s.wrap,t.z,t.x,t.y-1).key]={backfilled:!1},g[new u.br(s.overscaledZ,m,t.z,p,t.y-1).key]={backfilled:!1}),t.y+1<n&&(g[new u.br(s.overscaledZ,d,t.z,l,t.y+1).key]={backfilled:!1},g[new u.br(s.overscaledZ,s.wrap,t.z,t.x,t.y+1).key]={backfilled:!1},g[new u.br(s.overscaledZ,m,t.z,p,t.y+1).key]={backfilled:!1}),g}},"raster-array":bl,geojson:class extends u.E{constructor(s,t,n,l){super(),this.id=s,this.type="geojson",this.minzoom=0,this.maxzoom=18,this.tileSize=512,this.isTileClipped=!0,this.reparseOverscaled=!0,this._loaded=!1,this.actor=n.getActor(),this.setEventedParent(l),this._data=t.data,this._options={...t},this._collectResourceTiming=t.collectResourceTiming,t.maxzoom!==void 0&&(this.maxzoom=t.maxzoom),t.minzoom!==void 0&&(this.minzoom=t.minzoom),t.type&&(this.type=t.type),t.attribution&&(this.attribution=t.attribution),this.promoteId=t.promoteId;const d=u.aj/this.tileSize;this.workerOptions={source:this.id,scope:this.scope,cluster:t.cluster||!1,geojsonVtOptions:{buffer:(t.buffer!==void 0?t.buffer:128)*d,tolerance:(t.tolerance!==void 0?t.tolerance:.375)*d,extent:u.aj,maxZoom:this.maxzoom,lineMetrics:t.lineMetrics||!1,generateId:t.generateId||!1},superclusterOptions:{maxZoom:t.clusterMaxZoom!==void 0?t.clusterMaxZoom:this.maxzoom-1,minPoints:Math.max(2,t.clusterMinPoints||2),extent:u.aj,radius:(t.clusterRadius!==void 0?t.clusterRadius:50)*d,log:!1,generateId:t.generateId||!1},clusterProperties:t.clusterProperties,filter:t.filter,dynamic:t.dynamic,...t.workerOptions}}onAdd(s){this.map=s,this.setData(this._data)}setData(s){return this._data=s,this._updateWorkerData(),this}updateData(s){if(!this._options.dynamic)return this.fire(new u.A(new Error("Can't call updateData on a GeoJSON source with dynamic set to false.")));if(typeof s!="string"&&(s.type==="Feature"&&(s={type:"FeatureCollection",features:[s]}),s.type!=="FeatureCollection"))return this.fire(new u.A(new Error("Data to update should be a feature or a feature collection.")));if(this._coalesce&&typeof s!="string"&&typeof this._data!="string"&&this._data.type==="FeatureCollection"){const t=new Map;for(const n of this._data.features)t.set(n.id,n);for(const n of s.features)t.set(n.id,n);this._data.features=[...t.values()]}else this._data=s;return this._updateWorkerData(!0),this}getClusterExpansionZoom(s,t){return this.actor.send("geojson.getClusterExpansionZoom",{clusterId:s,source:this.id,scope:this.scope}).then(n=>t(null,n)).catch(n=>t(n)),this}getClusterChildren(s,t){return this.actor.send("geojson.getClusterChildren",{clusterId:s,source:this.id,scope:this.scope}).then(n=>t(null,n)).catch(n=>t(n)),this}getClusterLeaves(s,t,n,l){return this.actor.send("geojson.getClusterLeaves",{source:this.id,scope:this.scope,clusterId:s,limit:t,offset:n}).then(d=>l(null,d)).catch(d=>l(d)),this}async _updateWorkerData(s=!1){if(this._pendingLoad)return void(this._coalesce=!0);this.fire(new u.B("dataloading",{dataType:"source"})),this._loaded=!1;const t={append:s,...this.workerOptions};t.scope=this.scope;const n=this._data,l=new AbortController;this._pendingLoad=l;try{if(typeof n=="string"){if(t.request=await this.map._requestManager.transformRequest(u.r.resolveURL(n),u.R.Source,l.signal),l.signal.aborted)return this._pendingLoad=null,void(this._coalesce=!1);t.request.collectResourceTiming=this._collectResourceTiming}else t.data=JSON.stringify(n);const d=await this.actor.send(`${this.type}.loadData`,t,{signal:l.signal});this._loaded=!0,this._pendingLoad=null;const p={dataType:"source",sourceDataType:this._metadataFired?"content":"metadata"};this._collectResourceTiming&&d&&d.resourceTiming&&d.resourceTiming[this.id]&&(p.resourceTiming=d.resourceTiming[this.id]),s&&(this._partialReload=!0),this.fire(new u.B("data",p)),this._partialReload=!1,this._metadataFired=!0}catch(d){if(l.signal.aborted)return this._pendingLoad=null,void(this._coalesce=!1);this._loaded=!0,this._pendingLoad=null,this.fire(new u.A(d))}this._coalesce&&(this._updateWorkerData(s),this._coalesce=!1)}loaded(){return this._loaded}reload(){const s=u.y(this.id,this.scope);this.map.style.clearSource(s),this._updateWorkerData()}loadTile(s,t){const n=s.actor?"reloadTile":"loadTile";s.actor=this.actor;const l=this.map.style?this.map.style.getLut(this.scope):null,d=l?{image:l.image.clone()}:null,p=this._partialReload,m={type:this.type,uid:s.uid,tileID:s.tileID,tileZoom:s.tileZoom,zoom:s.tileID.overscaledZ,maxZoom:this.maxzoom,tileSize:this.tileSize,source:this.id,lut:d,scope:this.scope,pixelRatio:u.r.devicePixelRatio,showCollisionBoxes:this.map.showCollisionBoxes,showElevationIdDebug:!!this.map.painter&&this.map.painter._debugParams.showElevationIdDebug,promoteId:this.promoteId,brightness:this.map.style&&this.map.style.getBrightness()||0,extraShadowCaster:s.isExtraShadowCaster,scaleFactor:this.map.getScaleFactor(),partial:p,worldview:this.map.getWorldview(),indoor:this.map.getIndoorTileOptions(this.id,this.scope)};s.request=this.actor.sendCancelable(n,m,{},(g,x)=>p&&!x?(s.state="loaded",t(null)):(delete s.request,s.destroy(!1),s.aborted?t(null):g?t(g):(s.loadVectorData(x,this.map.painter,n==="reloadTile"),void t(null))))}abortTile(s){s.request&&(s.request.abort(),delete s.request),s.aborted=!0}unloadTile(s,t){this.actor.notify("removeTile",{uid:s.uid,type:this.type,source:this.id,scope:this.scope}),s.destroy()}onRemove(s){this._pendingLoad&&this._pendingLoad.abort()}serialize(){return{...this._options,type:this.type,data:this._data}}hasTransition(){return!1}},video:class extends No{constructor(s,t,n,l){super(s,t,n,l),this.roundZoom=!0,this.type="video",this.options=t}async load(){this._loaded=!1;const s=this.options,t=new AbortController;this._imageRequest=t;try{const n=await Promise.all(s.urls.map(async d=>(await this.map._requestManager.transformRequest(d,u.R.Source,t.signal)).url));if(t.signal.aborted)return;this.urls=n;const l=await u.dV(n);if(t.signal.aborted)return;this._imageRequest=null,this.video=l,this.video.loop=!0,this.video.setAttribute("playsinline",""),this.video.addEventListener("playing",()=>{this.map.triggerRepaint()}),this.map&&this.video.play(),this._finishLoading()}catch(n){if(t.signal.aborted)return;this.fire(new u.A(n))}finally{this._loaded=!0}}pause(){this.video&&this.video.pause()}play(){this.video&&this.video.play()}seek(s){if(this.video){const t=this.video.seekable;s<t.start(0)||s>t.end(0)?this.fire(new u.A(new ne(`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=s}}getVideo(){return this.video}onAdd(s){this.map||(this.map=s,this.load(),this.video&&(this.video.play(),this.setCoordinates(this.coordinates)))}prepare(){if(Object.keys(this.tiles).length===0||this.video.readyState<2)return;const s=this.map.painter.context,t=s.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 u.T(s,this.video,t.RGBA8),this.texture.bind(t.LINEAR,t.CLAMP_TO_EDGE),this.width=this.video.videoWidth,this.height=this.video.videoHeight),this._prepareData(s)}serialize(){return{type:"video",urls:this.options.urls,coordinates:this.coordinates}}hasTransition(){return this.video&&!this.video.paused}},image:No,model:u.dW,"batched-model":class extends u.E{constructor(s,t,n,l){super(),this.type="batched-model",this.id=s,this.tileSize=512,this._options=t,this.tiles=this._options.tiles,this.maxzoom=t.maxzoom||19,this.minzoom=t.minzoom||0,this.roundZoom=!0,this.usedInConflation=!0,this.dispatcher=n,this.reparseOverscaled=!1,this.scheme="xyz",this._loaded=!1,this.setEventedParent(l)}onAdd(s){this.map=s,this.load()}reload(){this.cancelTileJSONRequest();const s=u.y(this.id,this.scope);this.load(()=>this.map.style.clearSource(s))}cancelTileJSONRequest(){this._tileJSONRequest&&(this._tileJSONRequest.cancel(),this._tileJSONRequest=null)}load(s){this._loaded=!1,this.fire(new u.B("dataloading",{dataType:"source"}));const t=Array.isArray(this.map._language)?this.map._language.join():this.map._language,n=this.map.getWorldview();this._tileJSONRequest=u.dc(this._options,this.map._requestManager,t,n,(l,d)=>{this._tileJSONRequest=null,this._loaded=!0,l?(t&&console.warn(`Ensure that your requested language string is a valid BCP-47 code or list of codes. Found: ${t}`),n&&n.length!==2&&console.warn(`Requested worldview strings must be a valid ISO alpha-2 code. Found: ${n}`),this.fire(new u.A(l))):d&&(Object.assign(this,d),d.bounds&&(this.tileBounds=new Ba(d.bounds,this.minzoom,this.maxzoom)),Xo(d.tiles,this.map._requestManager._customAccessToken),this.fire(new u.B("data",{dataType:"source",sourceDataType:"metadata"})),this.fire(new u.B("data",{dataType:"source",sourceDataType:"content"}))),s&&s(l)})}hasTransition(){return!1}hasTile(s){return!this.tileBounds||this.tileBounds.contains(s.canonical)}loaded(){return this._loaded}async loadTile(s,t){const n=this.map._requestManager.normalizeTileURL(s.tileID.canonical.url(this.tiles,this.scheme)),l=!s.actor||s.state==="expired";if(l)s.actor=this.dispatcher.getActor();else{if(s.state==="loading")return void(s.reloadCallback=t);if(s.buckets){const g=Object.values(s.buckets);for(const x of g)x.dirty=!0;return void(s.state="loaded")}}const d=l?"loadTile":"reloadTile",p=new AbortController;s.request=p;const m=(g,x)=>(delete s.request,s.aborted?t(null):g&&!u.dy(g)?t(g):(this.map._refreshExpiredTiles&&x&&s.setExpiryData(u.dd(x.headers)),s.loadModelData(x,this.map.painter),s.state="loaded",t(null),void(s.reloadCallback&&(this.loadTile(s,s.reloadCallback),s.reloadCallback=null))));try{const g=await this.map._requestManager.transformRequest(n,u.R.Tile,p.signal);if(p.signal.aborted)return t(null);const x={request:g,data:void 0,uid:s.uid,tileID:s.tileID,tileZoom:s.tileZoom,zoom:s.tileID.overscaledZ,tileSize:this.tileSize*s.tileID.overscaleFactor(),type:this.type,source:this.id,scope:this.scope,showCollisionBoxes:this.map.showCollisionBoxes,renderSourceType:s.renderSourceType,brightness:this.map.style&&this.map.style.getBrightness()||0,pixelRatio:u.r.devicePixelRatio,promoteId:this.promoteId};s.request=s.actor.sendCancelable(d,x,{},m)}catch(g){if(p.signal.aborted)return t(null);t(g)}}abortTile(s){s.request&&(s.request.abort(),delete s.request),s.actor&&s.actor.notify("abortTile",{uid:s.uid,type:this.type,source:this.id,scope:this.scope})}serialize(){return{...this._options}}},canvas:class extends No{constructor(s,t,n,l){super(s,t,n,l),t.coordinates?Array.isArray(t.coordinates)&&t.coordinates.length===4&&!t.coordinates.some(d=>!Array.isArray(d)||d.length!==2||d.some(p=>typeof p!="number"))||this.fire(new u.A(new ne(`sources.${s}`,null,'"coordinates" property must be an array of 4 longitude/latitude array pairs'))):this.fire(new u.A(new ne(`sources.${s}`,null,'missing required property "coordinates"'))),t.animate&&typeof t.animate!="boolean"&&this.fire(new u.A(new ne(`sources.${s}`,null,'optional "animate" property must be a boolean value'))),t.canvas?typeof t.canvas=="string"||t.canvas instanceof HTMLCanvasElement||this.fire(new u.A(new ne(`sources.${s}`,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 u.A(new ne(`sources.${s}`,null,'missing required property "canvas"'))),this.options=t,this.animate=t.animate===void 0||t.animate}async load(){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 u.A(new Error("Canvas dimensions cannot be less than or equal to zero."))):(this.play=function(){this._playing=!0,this.map.triggerRepaint()},this.pause=function(){this._playing&&(this.prepare(),this._playing=!1)},this._finishLoading())}getCanvas(){return this.canvas}onAdd(s){this.map=s,this.load(),this.canvas&&this.animate&&this.play()}onRemove(s){this.pause()}prepare(){let s=!1;if(this.canvas.width!==this.width&&(this.width=this.canvas.width,s=!0),this.canvas.height!==this.height&&(this.height=this.canvas.height,s=!0),this._hasInvalidDimensions()||Object.keys(this.tiles).length===0)return;const t=this.map.painter.context;this.texture?!s&&!this._playing||this.texture instanceof u.dP||this.texture.update(this.canvas,{premultiply:!0}):this.texture=new u.T(t,this.canvas,t.gl.RGBA8,{premultiply:!0}),this._prepareData(t)}serialize(){return{type:"canvas",coordinates:this.coordinates}}hasTransition(){return this._playing}_hasInvalidDimensions(){for(const s of[this.canvas.width,this.canvas.height])if(isNaN(s)||s<=0)return!0;return!1}},custom:class extends u.E{constructor(s,t,n,l){super(),this.id=s,this.type="custom",this._dataType="raster",this._dispatcher=n,this._implementation=t,this.setEventedParent(l),this.scheme="xyz",this.minzoom=0,this.maxzoom=22,this.tileSize=512,this._loaded=!1,this.roundZoom=!0,this._implementation||this.fire(new u.A(new Error(`Missing implementation for ${this.id} custom source`))),this._implementation.loadTile||this.fire(new u.A(new Error(`Missing loadTile implementation for ${this.id} custom source`))),this._implementation.bounds&&(this.tileBounds=new Ba(this._implementation.bounds,this.minzoom,this.maxzoom));const d=t;d.update=this._update.bind(this),d.clearTiles=this._clearTiles.bind(this),d.coveringTiles=this._coveringTiles.bind(this),Object.assign(this,u.b5(t,["dataType","scheme","minzoom","maxzoom","tileSize","attribution","minTileCacheSize","maxTileCacheSize"]))}serialize(){return u.b5(this,["type","scheme","minzoom","maxzoom","tileSize","attribution"])}load(){this._loaded=!0,this.fire(new u.B("data",{dataType:"source",sourceDataType:"metadata"})),this.fire(new u.B("data",{dataType:"source",sourceDataType:"content"}))}loaded(){return this._loaded}onAdd(s){this.map=s,this._loaded=!1,this.fire(new u.B("dataloading",{dataType:"source"})),this._implementation.onAdd&&this._implementation.onAdd(s),this.load()}onRemove(s){this._implementation.onRemove&&this._implementation.onRemove(s)}hasTile(s){if(this._implementation.hasTile){const{x:t,y:n,z:l}=s.canonical;return this._implementation.hasTile({x:t,y:n,z:l})}return!this.tileBounds||this.tileBounds.contains(s.canonical)}async loadTile(s,t){const{x:n,y:l,z:d}=s.tileID.canonical,p=new AbortController;s.request=p;try{const m=await this._implementation.loadTile({x:n,y:l,z:d},{signal:p.signal});if(delete s.request,s.aborted)return s.state="unloaded",t(null);if(m===void 0)return s.state="errored",t(null);if(m===null)return this.loadTileData(s,{width:this.tileSize,height:this.tileSize,data:null}),s.state="loaded",t(null);if(!(function(g){return g instanceof ImageData||g instanceof HTMLCanvasElement||g instanceof ImageBitmap||g instanceof HTMLImageElement})(m))return s.state="errored",t(new Error(`Can't infer data type for ${this.id}, only raster data supported at the moment`));this.loadTileData(s,m),s.state="loaded",t(null)}catch(m){if(p.signal.aborted)return;s.state="errored",t(m)}}loadTileData(s,t){s.setTexture(t,this.map.painter)}unloadTile(s,t){if(s.texture&&s.texture instanceof u.T?(s.destroy(!1),s.texture&&s.texture instanceof u.T&&this.map.painter.saveTileTexture(s.texture)):s.destroy(),this._implementation.unloadTile){const{x:n,y:l,z:d}=s.tileID.canonical;this._implementation.unloadTile({x:n,y:l,z:d})}t&&t()}abortTile(s,t){s.request&&(s.request.abort(),delete s.request),t&&t()}hasTransition(){return!1}_coveringTiles(){return this.map.transform.coveringTiles({tileSize:this.tileSize,minzoom:this.minzoom,maxzoom:this.maxzoom,roundZoom:this.roundZoom}).map(s=>({x:s.canonical.x,y:s.canonical.y,z:s.canonical.z}))}_clearTiles(){const s=u.y(this.id,this.scope);this.map.style.clearSource(s)}_update(){this.fire(new u.B("data",{dataType:"source",sourceDataType:"content"}))}}},Ph=function(s,t,n,l){const d=Xm(t.type);if(!d)throw new Error(`Unknown source type "${t.type}"`);const p=new d(s,t,n,l);if(p.id!==s)throw new Error(`Expected Source id to be ${s} instead of ${p.id}`);return u.cL(["load","abort","unload","serialize","prepare"],p),p},Xm=function(s){return Object.hasOwn(Tf,s)?Tf[s]:void 0};function Ym(s,t,n=""){return`${n}:${t.id||""}:${t.layer.id}:${(function(l){if("layerId"in l)return`layer:${l.layerId}`;{const{featuresetId:d,importId:p}=l;return`featureset:${d}${p?`:import:${p}`:""}`}})(s.target)}`}function so(s,t,n,l=""){if(s.uniqueFeatureID){const d=Ym(s,t,l);if(n.has(d))return!0;n.add(d)}return!1}function Sf(s,t,n,l,d=!1,p=void 0){const m=t.sourceCache.transform,g=t.sourceCache.tilesIn(s,t.has3DLayers,d);g.sort(Ef);const x=[];for(const w of g){const S=w.tile.queryRenderedFeatures(t,w,n,l,m,d,p);Object.keys(S).length&&x.push({wrappedTileID:w.tile.tileID.wrapped().key,queryResults:S})}for(const w in t.layers){const S=t.layers[w];if(S.styleLayer){const A=S.styleLayer.queryRenderedFeatures(s,t.sourceCache,l);Object.keys(A).length&&x.push({wrappedTileID:0,queryResults:A})}}return x.length===0?{}:(function(w){const S={},A={};for(const I of w){const M=I.queryResults,D=I.wrappedTileID,L=A[D]=A[D]||{};for(const k in M){const B=M[k],$=L[k]=L[k]||{},Z=S[k]=S[k]||[];for(const G of B)$[G.featureIndex]||($[G.featureIndex]=!0,Z.push(G))}}return S})(x)}function qn(s,t,n,l,d,p){const m={},g=l.queryRenderedSymbols(s),x=[];for(const w of Object.keys(g).map(Number))x.push(d[w]);x.sort(Ef);for(const w of x){const S=w.featureIndex.lookupSymbolFeatures(g[w.bucketInstanceId],w.bucketIndex,w.sourceLayerIndex,t,n,p);for(const A in S){const I=m[A]=m[A]||[],M=S[A];M.sort((D,L)=>{const k=w.featureSortOrder;if(k){const B=k.indexOf(D.featureIndex);return k.indexOf(L.featureIndex)-B}return L.featureIndex-D.featureIndex});for(const D of M)I.push(D)}}return m}function ja(s,t){const n=s.getRenderableIds().map(p=>s.getTileByID(p)),l=[],d={};for(let p=0;p<n.length;p++){const m=n[p],g=m.tileID.canonical.key;d[g]||(d[g]=!0,m.querySourceFeatures(l,t))}return l}function Ef(s,t){const n=s.tileID,l=t.tileID;return n.overscaledZ-l.overscaledZ||n.canonical.y-l.canonical.y||n.wrap-l.wrap||n.canonical.x-l.canonical.x}class If{constructor(t){this.style=t,this.layersGotHidden=!1,this.layers=[]}processLayersChanged(){this.layers=[];const t=!1,n=!1;for(const l in this.style._mergedLayers){const d=this.style._mergedLayers[l];if(d.type==="fill-extrusion"||d.type==="building")this.layers.push({layer:d,visible:t,visibilityChanged:n});else if(d.type==="model"){const p=this.style.getLayerSource(d);p&&p.type==="batched-model"&&this.layers.push({layer:d,visible:t,visibilityChanged:n})}}}onNewFrame(t){this.layersGotHidden=!1;for(const n of this.layers){const l=n.layer;let d=!1;l.type==="fill-extrusion"?d=!l.isHidden(t)&&l.paint.get("fill-extrusion-opacity")>0:l.type==="building"?d=!l.isHidden(t)&&l.paint.get("building-opacity")>0:l.type==="model"&&(d=!l.isHidden(t)&&l.paint.get("model-opacity").constantOr(1)>0),this.layersGotHidden=this.layersGotHidden||!d&&n.visible,n.visible=d}}updateZOffset(t,n){this.currentBuildingBuckets=[];for(const d of this.layers){const p=d.layer,m=this.style.getLayerSourceCache(p);let g=1;p.type==="fill-extrusion"?g=d.visible?p.paint.get("fill-extrusion-vertical-scale"):0:p.type==="building"&&(g=d.visible?p.paint.get("building-vertical-scale"):0);let x=m?m.getTile(n):null;if(!x&&m)for(const w in m._tiles){const S=m._tiles[w];if(n.canonical.isChildOf(S.tileID.canonical)){x=S;break}}this.currentBuildingBuckets.push({bucket:x?x.getBucket(p):null,tileID:x?x.tileID:n,verticalScale:g})}t.hasAnyZOffset=!1;let l=!1;for(let d=0;d<t.symbolInstances.length;d++){const p=t.symbolInstances.get(d),m=p.zOffset,g=this._getHeightAtTileOffset(n,p.tileAnchorX,p.tileAnchorY);p.zOffset=g!==Number.NEGATIVE_INFINITY?g:m,l||m===p.zOffset||(l=!0),t.hasAnyZOffset||p.zOffset===0||(t.hasAnyZOffset=!0)}l&&(t.zOffsetBuffersNeedUpload=!0,t.zOffsetSortDirty=!0)}hasLayerForSourceCache(t){for(const{layer:n}of this.layers){const l=this.style.getLayerSourceCache(n);if(l&&l.id===t)return!0}return!1}_mapCoordToOverlappingTile(t,n,l,d){let p=n,m=l;if(t.canonical.z!==d.canonical.z){const g=d.canonical,x=1/(1<<t.canonical.z-g.z);p=(n+t.canonical.x*u.aj)*x-g.x*u.aj|0,m=(l+t.canonical.y*u.aj)*x-g.y*u.aj|0}return{tileX:p,tileY:m}}_getHeightAtTileOffset(t,n,l){let d,p;for(let m=0;m<this.layers.length;++m){const g=this.layers[m].layer;if(g.type!=="fill-extrusion"&&g.type!=="building")continue;const{bucket:x,tileID:w,verticalScale:S}=this.currentBuildingBuckets[m];if(!x)continue;const{tileX:A,tileY:I}=this._mapCoordToOverlappingTile(t,n,l,w),M=x.getHeightAtTileCoord(A,I);M&&M.height!==void 0&&(M.hidden?d=M.height:p=Math.max(M.height*S,p||0))}if(p!==void 0)return p;for(let m=0;m<this.layers.length;++m){const g=this.layers[m];if(g.layer.type!=="model"||!g.visible)continue;const{bucket:x,tileID:w}=this.currentBuildingBuckets[m];if(!x)continue;const{tileX:S,tileY:A}=this._mapCoordToOverlappingTile(t,n,l,w),I=x.getHeightAtTileCoord(S,A);if(I&&!I.hidden)return I.height===void 0&&d!==void 0?Math.min(I.maxHeight,d)*I.verticalScale:I.height?I.height*I.verticalScale:Number.NEGATIVE_INFINITY}return this.layersGotHidden?0:Number.NEGATIVE_INFINITY}}let Sl;function Rh(){return Sl||(Sl=new ca),Sl}function Km(s,t){const n={},l=s,d=t,p=n;for(const m in l)m!=="ref"&&(p[m]=l[m]);return u.dX.forEach(m=>{m in d&&(p[m]=d[m])}),n}function Ys(s){s=s.slice();const t=Object.create(null);for(const n of s)t[n.id]=n;for(let n=0;n<s.length;n++){const l=s[n];if(l&&"ref"in l){const d=t[l.ref];d&&(s[n]=Km(l,d))}}return s}const xt={setStyle:"setStyle",addLayer:"addLayer",removeLayer:"removeLayer",setPaintProperty:"setPaintProperty",setLayoutProperty:"setLayoutProperty",setSlot:"setSlot",setFilter:"setFilter",addSource:"addSource",removeSource:"removeSource",setGeoJSONSourceData:"setGeoJSONSourceData",setLayerZoomRange:"setLayerZoomRange",setLayerProperty:"setLayerProperty",setCenter:"setCenter",setZoom:"setZoom",setBearing:"setBearing",setPitch:"setPitch",setSprite:"setSprite",setGlyphs:"setGlyphs",setTransition:"setTransition",setLight:"setLight",setTerrain:"setTerrain",setFog:"setFog",setSnow:"setSnow",setRain:"setRain",setCamera:"setCamera",setLights:"setLights",setProjection:"setProjection",addImport:"addImport",removeImport:"removeImport",updateImport:"updateImport",addIconset:"addIconset",removeIconset:"removeIconset"};function pu(s,t,n){n.push({command:xt.addSource,args:[s,t[s]]})}function Dh(s,t,n){t.push({command:xt.removeSource,args:[s]}),n[s]=!0}function Jm(s,t,n,l){Dh(s,n,l),pu(s,t,n)}function Qm(s,t,n){let l;for(l in s[n])if(Object.hasOwn(s[n],l)&&l!=="data"&&!u.b7(s[n][l],t[n][l]))return!1;for(l in t[n])if(Object.hasOwn(t[n],l)&&l!=="data"&&!u.b7(s[n][l],t[n][l]))return!1;return!0}function mu(s,t,n,l,d,p){let m;for(m in t=t||{},s=s||{})Object.hasOwn(s,m)&&(u.b7(s[m],t[m])||n.push({command:p,args:[l,m,t[m],d]}));for(m in t)Object.hasOwn(t,m)&&!Object.hasOwn(s,m)&&(u.b7(s[m],t[m])||n.push({command:p,args:[l,m,t[m],d]}))}function Tc(s){return s.id}function ns(s,t){return s[t.id]=t,s}function Ks(s,t,n){const l=t.createTileMatrix(s,s.worldSize,n.toUnwrapped());return u.aP(new Float32Array(16),s.projMatrix,l)}function We(s,t,n){if(t.projection.name===n.projection.name)return s.projMatrix;const l=n.clone();return l.setProjection(t.projection),Ks(l,t.getProjection(),s)}function Xe(s,t,n){return t.name===n.projection.name?s.projMatrix:Ks(n,t,s)}class El{constructor(t,n,l,d){this.opacity=t?Math.max(0,Math.min(1,t.opacity+(t.placed?n:-n))):d&&l?1:0,this.placed=l}isHidden(){return this.opacity===0&&!this.placed}}class Vi{constructor(t,n,l,d,p,m=!1){this.text=new El(t?t.text:null,n,l,p),this.icon=new El(t?t.icon:null,n,d,p),this.clipped=m}isHidden(){return this.text.isHidden()&&this.icon.isHidden()}}class _e{constructor(t,n,l,d=!1){this.text=t,this.icon=n,this.skipFade=l,this.clipped=d}}class e_{constructor(){this.invProjMatrix=u.aS(),this.viewportMatrix=u.aS(),this.circles=[]}}class Lh{constructor(t,n,l,d,p){this.bucketInstanceId=t,this.featureIndex=n,this.sourceLayerIndex=l,this.bucketIndex=d,this.tileID=p}}class Af{constructor(t){this.crossSourceCollisions=t,this.maxGroupID=0,this.collisionGroups={}}get(t){if(this.crossSourceCollisions)return{ID:0,predicate:null};if(!this.collisionGroups[t]){const n=++this.maxGroupID;this.collisionGroups[t]={ID:n,predicate:l=>l.collisionGroupID===n}}return this.collisionGroups[t]}}function zh(s,t,n,l,d){const{horizontalAlign:p,verticalAlign:m}=u.d$(s),g=-(p-.5)*t,x=-(m-.5)*n,w=u.e0(s,l);return new u.P(g+w[0]*d,x+w[1]*d)}function Fh(s,t,n,l,d){const p=new u.P(s,t);return n&&p._rotate(l?d:-d),p}function _u(s,t,n,l){const{leftJustifiedTextSymbolIndex:d,centerJustifiedTextSymbolIndex:p,rightJustifiedTextSymbolIndex:m,verticalPlacedTextSymbolIndex:g,crossTileID:x}=n,w=u.e1(t),S=l===u.b0.vertical?g:w==="left"?d:w==="center"?p:w==="right"?m:-1;d>=0&&(s.text.placedSymbolArray.get(d).crossTileID=S>=0&&d!==S?0:x),p>=0&&(s.text.placedSymbolArray.get(p).crossTileID=S>=0&&p!==S?0:x),m>=0&&(s.text.placedSymbolArray.get(m).crossTileID=S>=0&&m!==S?0:x),g>=0&&(s.text.placedSymbolArray.get(g).crossTileID=S>=0&&g!==S?0:x)}function ma(s,t,n){const l=t===u.b0.horizontal||t===u.b0.horizontalOnly?t:0,d=t===u.b0.vertical?t:0,{leftJustifiedTextSymbolIndex:p,centerJustifiedTextSymbolIndex:m,rightJustifiedTextSymbolIndex:g,verticalPlacedTextSymbolIndex:x}=n,w=s.text.placedSymbolArray;p>=0&&(w.get(p).placedOrientation=l),m>=0&&(w.get(m).placedOrientation=l),g>=0&&(w.get(g).placedOrientation=l),x>=0&&(w.get(x).placedOrientation=d)}class ey{constructor(t,n,l,d,p,m,g,x){this.transform=t.clone(),this.projection=t.projection.name,this.algorithm=d,this.collisionIndex=this.algorithm.createCollisionDetector(this.transform,m,x),this.buildingIndex=g,this.frontCutoffStart=0,this.placements={},this.opacities={},this.variableOffsets={},this.stale=!1,this.commitTime=0,this.fadeDuration=n,this.retainedQueryData={},this.collisionGroups=new Af(l),this.collisionCircleArrays={},this.prevPlacement=p,p&&(p.prevPlacement=void 0),this.placedOrientations={},this.lastReplacementSourceUpdateTime=0}getBucketParts(t,n,l,d,p=1){const m=l.getBucket(n),g=l.latestFeatureIndex;if(!m||!g||n.fqid!==m.layerIds[0])return;const x=m.layers[0].layout,w=m.layers[0].paint,S=l.collisionBoxArray,A=Math.pow(2,this.transform.zoom-l.tileID.overscaledZ),I=l.tileSize/u.aj,M=l.tileID.toUnwrapped();this.transform.setProjection(m.projection);const D=(L=l.tileID,k=m.getProjection(),B=this.transform,k.name===this.projection?B.calculateProjMatrix(L.toUnwrapped()):Ks(B,k,L));var L,k,B;const $=x.get("text-pitch-alignment")==="map",Z=x.get("text-rotation-alignment")==="map";n.compileFilter(n.options);const G=n.dynamicFilter(),te=n.dynamicFilterNeedsFeature(),ee=n.dynamicFilterNeedsGeometry(),le=this.transform.calculatePixelsToTileUnitsMatrix(l),K=pi(D,l.tileID.canonical,$,Z,this.transform,m.getProjection(),le);let Q=null;const ae=m.getProjection().createInversionMatrix(this.transform,l.tileID.canonical);if($){const Fe=Jl(D,l.tileID.canonical,$,Z,this.transform,m.getProjection(),le);Q=u.aP([],this.transform.labelPlaneMatrix,Fe)}let de=null;G&&l.latestFeatureIndex&&(de={unwrappedTileID:M,dynamicFilter:G,dynamicFilterNeedsFeature:te,needGeometry:ee}),this.retainedQueryData[m.bucketInstanceId]=new Lh(m.bucketInstanceId,g,m.sourceLayerIndex,m.index,l.tileID);const[fe,be]=m.layers[0].layout.get("text-size-scale-range"),Te=u.as(p,fe,be),[Ve,ye]=x.get("icon-size-scale-range"),Ae=u.as(p,Ve,ye),ge={bucket:m,layout:x,paint:w,posMatrix:D,invMatrix:ae,mercatorCenter:[u.a_(this.transform.center.lng),u.a$(this.transform.center.lat)],textLabelPlaneMatrix:K,labelToScreenMatrix:Q,clippingData:de,scale:A,textPixelRatio:I,holdingForFade:l.holdingForFade(),collisionBoxArray:S,partiallyEvaluatedTextSize:u.aZ(m.textSizeData,this.transform.zoom,Te),partiallyEvaluatedIconSize:u.aZ(m.iconSizeData,this.transform.zoom,Ae),collisionGroup:this.collisionGroups.get(m.sourceID),latestFeatureIndex:l.latestFeatureIndex};if(d)for(const Fe of m.sortKeyRanges){const{sortKey:Re,symbolInstanceStart:De,symbolInstanceEnd:Ke}=Fe;t.push({sortKey:Re,symbolInstanceStart:De,symbolInstanceEnd:Ke,parameters:ge})}else t.push({symbolInstanceStart:0,symbolInstanceEnd:m.symbolInstances.length,parameters:ge})}placeLayerBucketPart(t,n,l,d,p=1){this.algorithm.placeLayerBucketPart(this,t,n,l,d,p)}commit(t){this.commitTime=t,this.zoomAtLastRecencyCheck=this.transform.zoom;const n=this.prevPlacement;let l=!1;this.prevZoomAdjustment=n?n.zoomAdjustment(this.transform.zoom):0;const d=n?n.symbolFadeChange(t):1,p=n?n.opacities:{},m=n?n.variableOffsets:{},g=n?n.placedOrientations:{};for(const x in this.placements){const w=this.placements[x],S=p[x];S?(this.opacities[x]=new Vi(S,d,w.text,w.icon,null,w.clipped),l=l||w.text!==S.text.placed||w.icon!==S.icon.placed):(this.opacities[x]=new Vi(null,d,w.text,w.icon,w.skipFade,w.clipped),l=l||w.text||w.icon)}for(const x in p){const w=p[x];if(!this.opacities[x]){const S=new Vi(w,d,!1,!1);S.isHidden()||(this.opacities[x]=S,l=l||w.text.placed||w.icon.placed)}}for(const x in m)this.variableOffsets[x]||!this.opacities[x]||this.opacities[x].isHidden()||(this.variableOffsets[x]=m[x]);for(const x in g)this.placedOrientations[x]||!this.opacities[x]||this.opacities[x].isHidden()||(this.placedOrientations[x]=g[x]);l?this.lastPlacementChangeTime=t:typeof this.lastPlacementChangeTime!="number"&&(this.lastPlacementChangeTime=n?n.lastPlacementChangeTime:t)}updateLayerOpacities(t,n,l,d){d&&(this.lastReplacementSourceUpdateTime=d.updateTime);const p=new Set;for(const m of n){const g=m.getBucket(t);g&&m.latestFeatureIndex&&t.fqid===g.layerIds[0]&&(this.updateBucketOpacities(g,p,m,m.collisionBoxArray,l,d,m.tileID,t.scope),g.elevationType==="offset"&&this.buildingIndex&&this.buildingIndex.updateZOffset(g,m.tileID),g.elevationType==="road"&&g.hdExt&&g.hdExt.updateRoadElevation(g,m.tileID.canonical),g.updateZOffset())}}updateBucketOpacities(t,n,l,d,p,m,g,x){t.hasTextData()&&t.text.opacityVertexArray.clear(),t.hasIconData()&&t.icon.opacityVertexArray.clear(),t.hasIconCollisionBoxData()&&t.iconCollisionBox.collisionVertexArray.clear(),t.hasTextCollisionBoxData()&&t.textCollisionBox.collisionVertexArray.clear();const w=t.layers[0].layout,S=t.layers[0].paint,A=!!t.layers[0].dynamicFilter(),I=new Vi(null,0,!1,!1,!0),M=w.get("text-allow-overlap"),D=w.get("icon-allow-overlap"),L=w.get("text-variable-anchor"),k=w.get("text-rotation-alignment")==="map",B=w.get("text-pitch-alignment")==="map",$=S.get("symbol-z-offset"),Z=w.get("symbol-elevation-reference")==="sea",G=!$.isConstant(),te=new Vi(null,0,M&&(D||!t.hasIconData()||w.get("icon-optional")),D&&(M||!t.hasTextData()||w.get("text-optional")),!0);!t.collisionArrays&&d&&(t.hasIconCollisionBoxData()||t.hasTextCollisionBoxData())&&t.deserializeCollisionBoxes(d);const ee=(K,Q,ae)=>{for(let de=0;de<Q/4;de++)K.opacityVertexArray.emplaceBack(ae)};let le=0;m&&t.updateReplacement(g,m),this.collisionIndex.clearClippedSymbolsForBucket(t.bucketInstanceId);for(let K=0;K<t.symbolInstances.length;K++){const Q=t.symbolInstances.get(K),{numHorizontalGlyphVertices:ae,numVerticalGlyphVertices:de,crossTileID:fe,numIconVertices:be,tileAnchorX:Te,tileAnchorY:Ve}=Q;let ye=null;const Ae=this.retainedQueryData[t.bucketInstanceId];G&&Q&&Ae&&(ye=l.latestFeatureIndex.loadFeature({featureIndex:Q.featureIndex,bucketIndex:Ae.bucketIndex,sourceLayerIndex:Ae.sourceLayerIndex,layoutVertexArrayOffset:0}));const ge=$.evaluate(ye,{}),Fe=n.has(fe);let Re=this.opacities[fe];Fe?Re=I:Re||(Re=te,this.opacities[fe]=Re),n.add(fe);const De=ae>0||de>0,Ke=be>0,Be=this.placedOrientations[fe],Ge=Be===u.b0.vertical,Ze=Be===u.b0.horizontal||Be===u.b0.horizontalOnly;!De&&!Ke||Re.isHidden()||le++;let tt=!1;if((De||Ke)&&m)for(const ot of t.activeReplacements){if(u.dY(ot,p,u.dZ.Symbol,x)||ot.min.x>Te||Te>ot.max.x||ot.min.y>Ve||Ve>ot.max.y)continue;const at=u.d_(Te,Ve,g.canonical,ot.footprintTileId.canonical);if(tt=u.cm(at,ot.footprint),tt)break}if(tt&&this.collisionIndex.markSymbolAsClipped(t.bucketInstanceId,Q.featureIndex),De){const ot=tt?Il:Nh(Re.text);ee(t.text,ae,Ge?Il:ot),ee(t.text,de,Ze?Il:ot);const at=Re.text.isHidden(),{leftJustifiedTextSymbolIndex:ut,centerJustifiedTextSymbolIndex:bt,rightJustifiedTextSymbolIndex:pt,verticalPlacedTextSymbolIndex:Lt}=Q,kt=t.text.placedSymbolArray,gt=at||Ge?1:0;ut>=0&&(kt.get(ut).hidden=gt),bt>=0&&(kt.get(bt).hidden=gt),pt>=0&&(kt.get(pt).hidden=gt),Lt>=0&&(kt.get(Lt).hidden=at||Ze?1:0);const Pt=this.variableOffsets[fe];Pt&&_u(t,Pt.anchor,Q,Be);const Ct=this.placedOrientations[fe];Ct&&(_u(t,"left",Q,Ct),ma(t,Ct,Q))}if(Ke){const ot=tt?Il:Nh(Re.icon),{placedIconSymbolIndex:at,verticalPlacedIconSymbolIndex:ut}=Q,bt=t.icon.placedSymbolArray,pt=Re.icon.isHidden()?1:0;at>=0&&(ee(t.icon,be,Ge?Il:ot),bt.get(at).hidden=pt),ut>=0&&(ee(t.icon,Q.numVerticalIconVertices,Ze?Il:ot),bt.get(ut).hidden=pt)}if(t.hasIconCollisionBoxData()||t.hasTextCollisionBoxData()){const ot=t.collisionArrays[K];if(ot){let at=new u.P(0,0),ut=!0;if(ot.textBox||ot.verticalTextBox){if(L){const pt=this.variableOffsets[fe];pt?(at=zh(pt.anchor,pt.width,pt.height,pt.textOffset,pt.textScale),k&&at._rotate(B?this.transform.angle:-this.transform.angle)):ut=!1}A&&(ut=!Re.clipped),ot.textBox&&Oh(t.textCollisionBox.collisionVertexArray,Re.text.placed,!ut||Ge,ge,Z,at.x,at.y),ot.verticalTextBox&&Oh(t.textCollisionBox.collisionVertexArray,Re.text.placed,!ut||Ze,ge,Z,at.x,at.y)}const bt=ut&&!!(!Ze&&ot.verticalIconBox);ot.iconBox&&Oh(t.iconCollisionBox.collisionVertexArray,Re.icon.placed,bt,ge,Z,Q.hasIconTextFit?at.x:0,Q.hasIconTextFit?at.y:0),ot.verticalIconBox&&Oh(t.iconCollisionBox.collisionVertexArray,Re.icon.placed,!bt,ge,Z,Q.hasIconTextFit?at.x:0,Q.hasIconTextFit?at.y:0)}}}if(t.fullyClipped=le===0,t.sortFeatures(this.transform.angle),this.retainedQueryData[t.bucketInstanceId]&&(this.retainedQueryData[t.bucketInstanceId].featureSortOrder=t.featureSortOrder),t.hasTextData()&&t.text.opacityVertexBuffer&&t.text.opacityVertexBuffer.updateData(t.text.opacityVertexArray),t.hasIconData()&&t.icon.opacityVertexBuffer&&t.icon.opacityVertexBuffer.updateData(t.icon.opacityVertexArray),t.hasIconCollisionBoxData()&&t.iconCollisionBox.collisionVertexBuffer&&t.iconCollisionBox.collisionVertexBuffer.updateData(t.iconCollisionBox.collisionVertexArray),t.hasTextCollisionBoxData()&&t.textCollisionBox.collisionVertexBuffer&&t.textCollisionBox.collisionVertexBuffer.updateData(t.textCollisionBox.collisionVertexArray),t.bucketInstanceId in this.collisionCircleArrays){const K=this.collisionCircleArrays[t.bucketInstanceId];t.placementInvProjMatrix=K.invProjMatrix,t.placementViewportMatrix=K.viewportMatrix,t.collisionCircleArray=K.circles,delete this.collisionCircleArrays[t.bucketInstanceId]}}symbolFadeChange(t){return this.fadeDuration===0?1:(t-this.commitTime)/this.fadeDuration+this.prevZoomAdjustment}zoomAdjustment(t){return Math.max(0,(this.transform.zoom-t)/1.5)}hasTransitions(t){return t-this.lastPlacementChangeTime<this.fadeDuration}stillRecent(t,n){const l=this.zoomAtLastRecencyCheck===n?1-this.zoomAdjustment(n):1;return this.zoomAtLastRecencyCheck=n,this.commitTime+this.fadeDuration*l>t}isStale(){return this.stale}setStale(){this.stale=!0}}function Oh(s,t,n,l,d,p,m){s.emplaceBack(t?1:0,n?1:0,p||0,m||0,l,d?1:0),s.emplaceBack(t?1:0,n?1:0,p||0,m||0,l,d?1:0),s.emplaceBack(t?1:0,n?1:0,p||0,m||0,l,d?1:0),s.emplaceBack(t?1:0,n?1:0,p||0,m||0,l,d?1:0)}const t_=Math.pow(2,25),kh=Math.pow(2,24),Cf=Math.pow(2,17),i_=Math.pow(2,16),r_=Math.pow(2,9),Bh=Math.pow(2,8),gu=Math.pow(2,1);function Nh(s){if(s.opacity===0&&!s.placed)return 0;if(s.opacity===1&&s.placed)return 4294967295;const t=s.placed?1:0,n=Math.floor(127*s.opacity);return n*t_+t*kh+n*Cf+t*i_+n*r_+t*Bh+n*gu+t}const Il=0;class n_{constructor(t,n){this.reset(t,n)}reset(t,n){this.points=t||[],this._distances=[0];for(let l=1;l<this.points.length;l++)this._distances[l]=this._distances[l-1]+this.points[l].dist(this.points[l-1]);this.length=this._distances.at(-1),this.padding=Math.min(n||0,.5*this.length),this.paddedLength=this.length-2*this.padding}lerp(t){if(this.points.length===1)return this.points[0];t=u.as(t,0,1);let n=1,l=this._distances[n];const d=t*this.paddedLength+this.padding;for(;l<d&&n<this._distances.length;)l=this._distances[++n];const p=n-1,m=this._distances[p],g=l-m,x=g>0?(d-m)/g:0;return this.points[p].mult(1-x).add(this.points[n].mult(x))}}const Cs=100;class Mf{constructor(t,n){this.gridRightBoundary=0,this.gridBottomBoundary=0,this.clippedSymbols=new Map,this.reset(t,n)}reset(t,n){const l=t.width+200,d=t.height+200;l!==this.gridRightBoundary||d!==this.gridBottomBoundary?(this.grid=new u.e2(l,d,25),this.ignoredGrid=new u.e2(l,d,25)):(this.grid.clear(),this.ignoredGrid.clear()),this.transform=t,this.fogState=n,this.pitchfactor=Math.cos(t._pitch)*t.cameraToCenterDistance,this.screenRightBoundary=t.width+Cs,this.screenBottomBoundary=t.height+Cs,this.gridRightBoundary=l,this.gridBottomBoundary=d,this.clippedSymbols.clear()}clearClippedSymbolsForBucket(t){this.clippedSymbols.delete(t)}markSymbolAsClipped(t,n){let l=this.clippedSymbols.get(t);l||(l=new Set,this.clippedSymbols.set(t,l)),l.add(n)}placeCollisionBox(t,n,l,d,p,m,g,x,w,S,A){let I=l.projectedAnchorX,M=l.projectedAnchorY,D=l.projectedAnchorZ;const L=l.tileAnchorX,k=l.tileAnchorY,B=l.elevation,$=l.tileID,Z=t.getProjection();if(B&&$){const[be,Te,Ve]=Z.upVector($.canonical,l.tileAnchorX,l.tileAnchorY),ye=Z.upVectorScale($.canonical,this.transform.center.lat,this.transform.worldSize).metersToTile;I+=be*B*ye,M+=Te*B*ye,D+=Ve*B*ye}const G=t.projection.name==="globe",te=t.projection.name==="globe"?u.ah(this.transform.zoom):0;if($&&G&&te<1&&!m){const be=1<<$.canonical.z,Te=u.e3(L,k);u.e4(Te,Te,1/u.aj),u.e5(Te,Te,u.e3($.canonical.x,$.canonical.y)),u.e4(Te,Te,1/be),u.e6(Te,Te,u.e3(d[0],d[1])),Te[0]=u.at(Te[0],-.5,.5),u.e4(Te,Te,u.aj);const Ve=u.cv(Te[0],Te[1],u.aj/(2*Math.PI),1);u.aO(Ve,Ve,p),I=u.ai(I,Ve[0],te),M=u.ai(M,Ve[1],te),D=u.ai(D,Ve[2],te)}const ee=this.projectAndGetPerspectiveRatio(S,I,M,D,l.tileID,Z.name==="globe"||!!B||this.transform.pitch>0,Z),le=w*ee.perspectiveRatio,K=(l.x1*n+g.x-l.padding)*le+ee.point.x,Q=(l.y1*n+g.y-l.padding)*le+ee.point.y,ae=(l.x2*n+g.x+l.padding)*le+ee.point.x,de=(l.y2*n+g.y+l.padding)*le+ee.point.y,fe=ee.perspectiveRatio<=.55||ee.occluded;return!this.isInsideGrid(K,Q,ae,de)||!x&&this.grid.hitTest(K,Q,ae,de,A)||fe?{box:[],offscreen:!1,occluded:ee.occluded}:{box:[K,Q,ae,de],offscreen:this.isOffscreen(K,Q,ae,de),occluded:!1}}placeCollisionCircles(t,n,l,d,p,m,g,x,w,S,A,I,M,D,L,k){const B=[],$=this.transform.elevation,Z=t.getProjection(),G=t.elevationType==="road",te=!!$||G,ee=u.e7.getAtTileOffsetFunc(k,this.transform.center.lat,this.transform.worldSize,Z),le=new u.P(l.tileAnchorX,l.tileAnchorY),K=new u.P(l.tileAnchorX,l.tileAnchorY);let{x:Q,y:ae,z:de}=Z.projectTilePoint(K.x,K.y,k.canonical),fe=null;if(te){fe=G&&t.hdExt?t.hdExt.makeRoadSymbolElevationParams(t,t.text,d,k,ee,$,Z,this.transform.center.lat,this.transform.worldSize):{getElevation:ee,elevation:$,elevationFeature:null};const[tt,ot,at]=fe.getElevation(le,$,fe.elevationFeature);Q+=tt,ae+=ot,de+=at}const be=Z.name==="globe",Te=this.projectAndGetPerspectiveRatio(x,Q,ae,de,k,be||!!$||this.transform.pitch>0,Z),{perspectiveRatio:Ve}=Te,ye=(I?g/Ve:g*Ve)/u.e9,Ae=oo(Q,ae,de,w),ge=l.lineOffsetX*ye,Fe=l.lineOffsetY*ye,Re=u.al(t.layers[0].layout.get("text-max-angle")),De=Math.cos(Re),Ke=Te.signedDistanceFromCamera>0?hm(ye,m,ge,Fe,G&&l.flipState===1,Ae,K,l,p,w,{},te&&!I?fe:null,I&&te,Z,k,I,De):null;let Be=!1,Ge=!1,Ze=!0;if(Ke&&!Te.occluded){const tt=.5*D*Ve+L,ot=new u.P(-100,-100),at=new u.P(this.screenRightBoundary,this.screenBottomBoundary),ut=new n_,{first:bt,last:pt}=Ke,Lt=bt.path.length;let kt=[];for(let Ct=Lt-1;Ct>=1;Ct--)kt.push(bt.path[Ct]);for(let Ct=1;Ct<pt.path.length;Ct++)kt.push(pt.path[Ct]);const gt=2.5*tt;S&&(kt=kt.map(([Ct,Ut,oi],Ci)=>(te&&!be&&(oi=fe.getElevation(Ci<Lt-1?bt.tilePath[Lt-1-Ci]:pt.tilePath[Ci-Lt+2],$,fe.elevationFeature)[2]),oo(Ct,Ut,oi,S))),kt.some(Ct=>Ct[3]<=0)&&(kt=[]));let Pt=[];if(kt.length>0){let Ct=1/0,Ut=-1/0,oi=1/0,Ci=-1/0;for(const hi of kt)Ct=Math.min(Ct,hi[0]),oi=Math.min(oi,hi[1]),Ut=Math.max(Ut,hi[0]),Ci=Math.max(Ci,hi[1]);Ut>=ot.x&&Ct<=at.x&&Ci>=ot.y&&oi<=at.y&&(Pt=[kt.map(hi=>new u.P(hi[0],hi[1]))],(Ct<ot.x||Ut>at.x||oi<ot.y||Ci>at.y)&&(Pt=u.e8(Pt,ot.x,ot.y,at.x,at.y)))}for(const Ct of Pt){ut.reset(Ct,.25*tt);let Ut=0;Ut=ut.length<=.5*tt?1:Math.ceil(ut.paddedLength/gt)+1;for(let oi=0;oi<Ut;oi++){const Ci=oi/Math.max(Ut-1,1),hi=ut.lerp(Ci),Kt=hi.x+Cs,Ei=hi.y+Cs;B.push(Kt,Ei,tt,0);const mi=Kt-tt,Qi=Ei-tt,Ot=Kt+tt,$t=Ei+tt;if(Ze=Ze&&this.isOffscreen(mi,Qi,Ot,$t),Ge=Ge||this.isInsideGrid(mi,Qi,Ot,$t),!n&&this.grid.hitTestCircle(Kt,Ei,tt,M)&&(Be=!0,!A))return{circles:[],offscreen:!1,collisionDetected:Be,occluded:!1}}}}return{circles:!A&&Be||!Ge?[]:B,offscreen:Ze,collisionDetected:Be,occluded:Te.occluded}}queryRenderedSymbols(t){if(t.length===0||this.grid.keysLength()===0&&this.ignoredGrid.keysLength()===0)return{};const n=[];let l=1/0,d=1/0,p=-1/0,m=-1/0;for(const S of t){const A=new u.P(S.x+Cs,S.y+Cs);l=Math.min(l,A.x),d=Math.min(d,A.y),p=Math.max(p,A.x),m=Math.max(m,A.y),n.push(A)}const g=this.grid.query(l,d,p,m).concat(this.ignoredGrid.query(l,d,p,m)),x={},w={};for(const S of g){const A=S.key;if(x[A.bucketInstanceId]===void 0&&(x[A.bucketInstanceId]={}),x[A.bucketInstanceId][A.featureIndex])continue;const I=this.clippedSymbols.get(A.bucketInstanceId);if(I&&I.has(A.featureIndex))continue;const M=[new u.P(S.x1,S.y1),new u.P(S.x2,S.y1),new u.P(S.x2,S.y2),new u.P(S.x1,S.y2)];u.cJ(n,M)&&(x[A.bucketInstanceId][A.featureIndex]=!0,w[A.bucketInstanceId]===void 0&&(w[A.bucketInstanceId]=[]),w[A.bucketInstanceId].push(A.featureIndex))}return w}insertCollisionBox(t,n,l,d,p){(n?this.ignoredGrid:this.grid).insert({bucketInstanceId:l,featureIndex:d,collisionGroupID:p},t[0],t[1],t[2],t[3])}insertCollisionCircles(t,n,l,d,p){const m=n?this.ignoredGrid:this.grid,g={bucketInstanceId:l,featureIndex:d,collisionGroupID:p};for(let x=0;x<t.length;x+=4)m.insertCircle(g,t[x],t[x+1],t[x+2])}projectAndGetPerspectiveRatio(t,n,l,d,p,m,g){const x=[n,l,d,1];let w=!1;d||this.transform.pitch>0?(u.aO(x,x,t),this.fogState&&p&&g.name!=="globe"&&(w=(function(I,M,D,L,k,B){const $=B.calculateFogTileMatrix(k),Z=[M,D,L];return u.ad(Z,Z,$),Xu(I,u.ae(Z),B.pitch)})(this.fogState,n,l,d,p.toUnwrapped(),this.transform)>.9)):Fo(x,x,t);const S=x[3];return{point:new u.P((x[0]/S+1)/2*this.transform.width+Cs,(-x[1]/S+1)/2*this.transform.height+Cs),perspectiveRatio:Math.min(.5+this.transform.getCameraToCenterDistance(g)/S*.5,1.5),signedDistanceFromCamera:S,occluded:m&&x[2]>S||w}}isOffscreen(t,n,l,d){return l<Cs||t>=this.screenRightBoundary||d<Cs||n>this.screenBottomBoundary}isInsideGrid(t,n,l,d){return l>=0&&t<this.gridRightBoundary&&d>=0&&n<this.gridBottomBoundary}getViewportMatrix(){const t=u.aC([]);return u.aG(t,t,[-100,-100,0]),t}}const o_={default:new class{createCollisionDetector(s,t,n){return n instanceof Mf?(n.reset(s,t),n):new Mf(s,t)}shouldPause(s){return s>2}placeLayerBucketPart(s,t,n,l,d,p=1){const{bucket:m,layout:g,paint:x,posMatrix:w,textLabelPlaneMatrix:S,labelToScreenMatrix:A,clippingData:I,textPixelRatio:M,mercatorCenter:D,invMatrix:L,holdingForFade:k,collisionBoxArray:B,partiallyEvaluatedTextSize:$,partiallyEvaluatedIconSize:Z,collisionGroup:G,latestFeatureIndex:te}=t.parameters,ee=g.get("text-optional"),le=g.get("icon-optional"),K=g.get("text-allow-overlap"),Q=g.get("icon-allow-overlap"),ae=g.get("text-rotation-alignment")==="map",de=g.get("icon-rotation-alignment")==="map",fe=g.get("text-pitch-alignment")==="map",be=x.get("symbol-z-offset"),Te=g.get("symbol-elevation-reference")==="sea",Ve=g.get("symbol-placement"),[ye,Ae]=g.get("text-size-scale-range"),[ge,Fe]=g.get("icon-size-scale-range"),Re=u.as(p,ye,Ae),De=u.as(p,ge,Fe),Ke=g.get("text-variable-anchor"),Be=ae&&Ve!=="point",Ge=de&&Ve!=="point",Ze=Ke&&m.hasTextData(),tt=m.hasIconTextFit()&&Ze&&m.hasIconData();s.transform.setProjection(m.projection);const ot=Ze||Be,at=Ge||tt;let ut=K&&(Q||!m.hasIconData()||le),bt=Q&&(K||!m.hasTextData()||ee);const pt=!be.isConstant();!m.collisionArrays&&B&&m.deserializeCollisionBoxes(B),l&&d&&m.updateCollisionDebugBuffers(s.transform.zoom,B,Re,De);const Lt=(gt,Pt,Ct)=>{const{crossTileID:Ut,numVerticalGlyphVertices:oi}=gt;let Ci=null;if(I&&I.dynamicFilterNeedsFeature||pt){const ii=s.retainedQueryData[m.bucketInstanceId],di=te.loadFeature({featureIndex:gt.featureIndex,bucketIndex:ii.bucketIndex,sourceLayerIndex:ii.sourceLayerIndex,layoutVertexArrayOffset:0}),si=di.properties?di.properties.worldview:null;
3396if(m.localizable&&m.worldview&&typeof si=="string")if(si==="all")di.properties.$localized=!0;else{if(!si.split(",").includes(m.worldview))return;di.properties.$localized=!0,di.properties.worldview=m.worldview}Ci=I&&I.needGeometry?u.cW(di,!0):di}if(I&&!(0,I.dynamicFilter)({zoom:s.transform.zoom,pitch:s.transform.pitch,worldview:m.worldview},Ci,s.retainedQueryData[m.bucketInstanceId].tileID.canonical,new u.P(gt.tileAnchorX,gt.tileAnchorY),s.transform.calculateDistanceTileData(I.unwrappedTileID)))return s.placements[Ut]=new _e(!1,!1,!1,!0),void n.add(Ut);const hi=be.evaluate(Ci,{});if((gt.zOffset||0)+(hi||0)>0&&s.frontCutoffStart>0){const ii=2*s.frontCutoffStart-1,di=[gt.tileAnchorX,gt.tileAnchorY,0,1],si=u.aO(u.cw(),di,w);if(si[1]/si[3]<ii)return s.placements[Ut]=new _e(!1,!1,!1,!0),void n.add(Ut)}if(n.has(Ut))return;if(k)return void(s.placements[Ut]=new _e(!1,!1,!1));let Kt=!1,Ei=!1,mi=!0,Qi=!1,Ot=!1,$t=null,Mt={box:null,offscreen:null,occluded:null},Ii={box:null},wi=null,sr=null,Wi=null,Pr=0,kr=0,En=0;Ct.textFeatureIndex?Pr=Ct.textFeatureIndex:gt.useRuntimeCollisionCircles&&(Pr=gt.featureIndex),Ct.verticalTextFeatureIndex&&(kr=Ct.verticalTextFeatureIndex);const qr=ii=>{ii.tileID=s.retainedQueryData[m.bucketInstanceId].tileID;const di=s.transform.elevation;if(m.elevationType==="road")ii.elevation=Te?hi:hi+u.e7.getAtTileOffset(ii.tileID,new u.P(ii.tileAnchorX,ii.tileAnchorY),di,null);else{const si=m.hdExt?m.hdExt.elevationFeatures[gt.elevationFeatureIndex]:void 0;ii.elevation=Te?hi:hi+u.e7.getAtTileOffset(ii.tileID,new u.P(ii.tileAnchorX,ii.tileAnchorY),di,si)}ii.elevation+=gt.zOffset},ti=Ct.textBox;if(ti){qr(ti);const ii=si=>{let Ai=u.b0.horizontal;if(m.allowVerticalPlacement&&!si&&s.prevPlacement){const pr=s.prevPlacement.placedOrientations[Ut];pr&&(s.placedOrientations[Ut]=pr,Ai=pr,ma(m,Ai,gt))}return Ai},di=(si,Ai)=>{if(m.allowVerticalPlacement&&oi>0&&Ct.verticalTextBox){for(const pr of m.writingModes)if(pr===u.b0.vertical?(Mt=Ai(),Ii=Mt):Mt=si(),Mt&&Mt.box&&Mt.box.length)break}else Mt=si()};if(Ke){let si=Ke;if(s.prevPlacement&&s.prevPlacement.variableOffsets[Ut]){const Xi=s.prevPlacement.variableOffsets[Ut];si.indexOf(Xi.anchor)>0&&(si=si.filter(Er=>Er!==Xi.anchor),si.unshift(Xi.anchor))}const Ai=(Xi,Er,jo)=>{const wn=m.getSymbolInstanceTextSize($,gt,s.transform.zoom,Pt),Go=(Xi.x2-Xi.x1)*wn+2*Xi.padding,xa=(Xi.y2-Xi.y1)*wn+2*Xi.padding,bo=gt.hasIconTextFit&&!Q?Er:null;bo&&qr(bo);let Xn={box:[],offscreen:!1,occluded:!1};const Ja=K?2*si.length:si.length;for(let In=0;In<Ja;++In){const $o=this.attemptAnchorPlacement(s,si[In%si.length],Xi,D,L,ot,Go,xa,wn,ae,fe,M,w,G,In>=si.length,gt,Pt,m,jo,bo,$,Z);if($o&&(Xn=$o.placedGlyphBoxes,Xn&&Xn.box&&Xn.box.length)){Kt=!0,$t=$o.shift;break}}return Xn};di(()=>Ai(ti,Ct.iconBox,u.b0.horizontal),()=>{const Xi=Ct.verticalTextBox;return Xi&&qr(Xi),m.allowVerticalPlacement&&!(Mt&&Mt.box&&Mt.box.length)&&oi>0&&Xi?Ai(Xi,Ct.verticalIconBox,u.b0.vertical):{box:null,offscreen:null,occluded:null}}),Mt&&(Kt=Mt.box,mi=Mt.offscreen,Qi=Mt.occluded);const pr=ii(!(!Mt||!Mt.box));if(!Kt&&s.prevPlacement){const Xi=s.prevPlacement.variableOffsets[Ut];Xi&&(s.variableOffsets[Ut]=Xi,_u(m,Xi.anchor,gt,pr))}}else{const si=(Ai,pr)=>{const Xi=m.getSymbolInstanceTextSize($,gt,s.transform.zoom,Pt),Er=s.collisionIndex.placeCollisionBox(m,Xi,Ai,D,L,ot,new u.P(0,0),K,M,w,G.predicate);return Er&&Er.box&&Er.box.length&&(ma(m,pr,gt),s.placedOrientations[Ut]=pr),Er};di(()=>si(ti,u.b0.horizontal),()=>{const Ai=Ct.verticalTextBox;return m.allowVerticalPlacement&&oi>0&&Ai?(qr(Ai),si(Ai,u.b0.vertical)):{box:null,offscreen:null,occluded:null}}),ii(!!(Mt&&Mt.box&&Mt.box.length))}}if(wi=Mt,Kt=wi&&wi.box&&wi.box.length>0,mi=wi&&wi.offscreen,Qi=wi&&wi.occluded,gt.useRuntimeCollisionCircles){const ii=gt.centerJustifiedTextSymbolIndex>=0?gt.centerJustifiedTextSymbolIndex:gt.verticalPlacedTextSymbolIndex,di=m.text.placedSymbolArray.get(ii),si=u.b1(m.textSizeData,$,di),Ai=g.get("text-padding");sr=s.collisionIndex.placeCollisionCircles(m,K,di,ii,m.lineVertexArray,m.glyphOffsetArray,si,w,S,A,l,fe,G.predicate,gt.collisionCircleDiameter*si/u.e9,Ai,s.retainedQueryData[m.bucketInstanceId].tileID),Kt=K||sr.circles.length>0&&!sr.collisionDetected,mi=mi&&sr.offscreen,Qi=sr.occluded}if(Ct.iconFeatureIndex&&(En=Ct.iconFeatureIndex),Ct.iconBox){const ii=di=>{qr(di);const si=gt.hasIconTextFit&&$t?Fh($t.x,$t.y,ae,fe,s.transform.angle):new u.P(0,0),Ai=m.getSymbolInstanceIconSize(Z,s.transform.zoom,gt.placedIconSymbolIndex);return s.collisionIndex.placeCollisionBox(m,Ai,di,D,L,at,si,Q,M,w,G.predicate)};Ii&&Ii.box&&Ii.box.length&&Ct.verticalIconBox?(Wi=ii(Ct.verticalIconBox),Ei=Wi.box.length>0):(Wi=ii(Ct.iconBox),Ei=Wi.box.length>0),mi=mi&&Wi.offscreen,Ot=Wi.occluded}const ar=ee||gt.numHorizontalGlyphVertices===0&&oi===0,Ui=le||gt.numIconVertices===0;if(ar||Ui?Ui?ar||(Ei=Ei&&Kt):Kt=Ei&&Kt:Ei=Kt=Ei&&Kt,Kt&&wi&&wi.box&&s.collisionIndex.insertCollisionBox(wi.box,g.get("text-ignore-placement"),m.bucketInstanceId,Ii&&Ii.box&&kr?kr:Pr,G.ID),Ei&&Wi&&s.collisionIndex.insertCollisionBox(Wi.box,g.get("icon-ignore-placement"),m.bucketInstanceId,En,G.ID),sr&&(Kt&&s.collisionIndex.insertCollisionCircles(sr.circles,g.get("text-ignore-placement"),m.bucketInstanceId,Pr,G.ID),l)){const ii=m.bucketInstanceId;let di=s.collisionCircleArrays[ii];di===void 0&&(di=s.collisionCircleArrays[ii]=new e_);for(let si=0;si<sr.circles.length;si+=4)di.circles.push(sr.circles[si+0]),di.circles.push(sr.circles[si+1]),di.circles.push(sr.circles[si+2]),di.circles.push(sr.collisionDetected?1:0)}const Oi=m.projection.name!=="globe";ut=ut&&(Oi||!Qi),bt=bt&&(Oi||!Ot),s.placements[Ut]=new _e(Kt||ut,Ei||bt,mi||m.justReloaded),n.add(Ut)},kt=s.retainedQueryData[m.bucketInstanceId].tileID;if(m.elevationType==="offset"&&s.buildingIndex&&s.buildingIndex.updateZOffset(m,kt),m.elevationType==="road"&&m.hdExt&&m.hdExt.updateRoadElevation(m,kt.canonical),m.updateZOffset(),m.sortFeaturesByY){const gt=m.getSortedSymbolIndexe
3396s(s.transform.angle);for(let Pt=gt.length-1;Pt>=0;--Pt){const Ct=gt[Pt];Lt(m.symbolInstances.get(Ct),Ct,m.collisionArrays[Ct])}m.hasAnyZOffset&&u.w(`${m.layerIds[0]} layer symbol-z-elevate: symbols are not sorted by elevation if symbol-z-order is evaluated to viewport-y`)}else if(m.hasAnyZOffset){const gt=m.getSortedIndexesByZOffset();for(let Pt=0;Pt<gt.length;++Pt){const Ct=gt[Pt];Lt(m.symbolInstances.get(Ct),Ct,m.collisionArrays[Ct])}}else for(let gt=t.symbolInstanceStart;gt<t.symbolInstanceEnd;gt++)Lt(m.symbolInstances.get(gt),gt,m.collisionArrays[gt]);if(l&&m.bucketInstanceId in s.collisionCircleArrays){const gt=s.collisionCircleArrays[m.bucketInstanceId];u.aE(gt.invProjMatrix,w),gt.viewportMatrix=s.collisionIndex.getViewportMatrix()}m.justReloaded=!1}attemptAnchorPlacement(s,t,n,l,d,p,m,g,x,w,S,A,I,M,D,L,k,B,$,Z,G,te){const{textOffset0:ee,textOffset1:le,crossTileID:K}=L,Q=[ee,le],ae=zh(t,m,g,Q,x),de=s.collisionIndex.placeCollisionBox(B,x,n,l,d,p,Fh(ae.x,ae.y,w,S,s.transform.angle),D,A,I,M.predicate);if(Z){const fe=B.getSymbolInstanceIconSize(te,s.transform.zoom,L.placedIconSymbolIndex);if(s.collisionIndex.placeCollisionBox(B,fe,Z,l,d,p,Fh(ae.x,ae.y,w,S,s.transform.angle),D,A,I,M.predicate).box.length===0)return}if(de.box.length>0){let fe;return s.prevPlacement&&s.prevPlacement.variableOffsets[K]&&s.prevPlacement.placements[K]&&s.prevPlacement.placements[K].text&&(fe=s.prevPlacement.variableOffsets[K].anchor),s.variableOffsets[K]={textOffset:Q,width:m,height:g,anchor:t,textScale:x,prevAnchor:fe},_u(B,t,L,$),B.allowVerticalPlacement&&(ma(B,$,L),s.placedOrientations[K]=$),{shift:ae,placedGlyphBoxes:de}}}}};class ty{constructor(t){this._sortAcrossTiles=t.layout.get("symbol-z-order")!=="viewport-y"&&t.layout.get("symbol-sort-key").constantOr(1)!==void 0,this._currentTileIndex=0,this._currentPartIndex=0,this._seenCrossTileIDs=new Set,this._bucketParts=[]}continuePlacement(t,n,l,d,p,m){const g=this._bucketParts;for(;this._currentTileIndex<t.length;)if(n.getBucketParts(g,d,t[this._currentTileIndex],this._sortAcrossTiles,m),this._currentTileIndex++,p())return!0;for(this._sortAcrossTiles&&(this._sortAcrossTiles=!1,g.sort((x,w)=>x.sortKey-w.sortKey));this._currentPartIndex<g.length;){const x=g[this._currentPartIndex];if(n.placeLayerBucketPart(x,this._seenCrossTileIDs,l,x.symbolInstanceStart===0,m),this._currentPartIndex++,p())return!0}return!1}}class Pf{constructor(){this._retiredCI=null}startNewPlacement(t,n,l,d,p,m,g,x,w){return this.placement=new ey(t,d,p,o_[w||"default"],m,g,x,this._retiredCI),this._retiredCI=null,this._currentPlacementIndex=n.length-1,this._forceFullPlacement=!1,this._showCollisionBoxes=l,this._fadeDuration=d,this._done=!1,this._inProgressLayer=null,this}requestFullPlacement(){this._forceFullPlacement=!0}isFullPlacementRequested(){return this._forceFullPlacement}setStale(){this.placement&&(this.placement.stale=!0)}isStale(){return!!this.placement&&this.placement.stale}isDone(){return this._done}continuePlacement(t,n,l,d,p){const m=u.r.now(),g=()=>!this.isFullPlacementRequested()&&this._fadeDuration!==0&&this.placement.algorithm.shouldPause(u.r.now()-m);for(;this._currentPlacementIndex>=0;){const x=n[t[this._currentPlacementIndex]],w=this.placement.collisionIndex.transform.zoom;if(x.type==="symbol"&&x.visibility!=="none"&&(!x.minzoom||x.minzoom<=w)&&(!x.maxzoom||x.maxzoom>w)){const S=x,A=S.layout.get("symbol-z-elevate"),I=S.layout.get("symbol-sort-key").constantOr(1)!==void 0,M=S.layout.get("symbol-z-order"),D=M==="viewport-y"||M==="auto"&&!(M!=="viewport-y"&&I),L=S.layout.get("text-allow-overlap")||S.layout.get("icon-allow-overlap")||S.layout.get("text-ignore-placement")||S.layout.get("icon-ignore-placement"),k=D&&L,B=this._inProgressLayer=this._inProgressLayer||new ty(S),$=u.y(x.source,x.scope);if(B.continuePlacement(A||k?d[$]:l[$],this.placement,this._showCollisionBoxes,x,g,p))return;delete this._inProgressLayer}this._currentPlacementIndex--}this._forceFullPlacement=!1,this._done=!0}commit(t){return this._retiredCI=this.placement.prevPlacement?this.placement.prevPlacement.collisionIndex:null,this.placement.commit(t),this.placement}}const Rf=512/u.aj/2;class Hn{constructor(t,n,l){this.tileID=t,this.bucketInstanceId=l,this.index=new u.ea(n.length,16,Int32Array),this.keys=[],this.crossTileIDs=[];const d=t.canonical.x*u.aj,p=t.canonical.y*u.aj;for(let m=0;m<n.length;m++){const{key:g,crossTileID:x,tileAnchorX:w,tileAnchorY:S}=n.get(m),A=Math.floor((d+w)*Rf),I=Math.floor((p+S)*Rf);this.index.add(A,I),this.keys.push(g),this.crossTileIDs.push(x)}this.index.finish()}
vendor: 59,322 bytes, line 3396
3396findMatches(t,n,l){const d=this.tileID.canonical.z<n.canonical.z?1:Math.pow(2,this.tileID.canonical.z-n.canonical.z),p=Rf/Math.pow(2,n.canonical.z-this.tileID.canonical.z),m=n.canonical.x*u.aj,g=n.canonical.y*u.aj;for(let x=0;x<t.length;x++){const w=t.get(x);if(w.crossTileID)continue;const{key:S,tileAnchorX:A,tileAnchorY:I}=w,M=Math.floor((m+A)*p),D=Math.floor((g+I)*p),L=this.index.range(M-d,D-d,M+d,D+d).sort((k,B)=>k-B);for(const k of L){const B=this.crossTileIDs[k];if(this.keys[k]===S&&!l.has(B)){l.add(B),w.crossTileID=B;break}}}}}class Vh{constructor(){this.maxCrossTileID=0}generate(){return++this.maxCrossTileID}}class Sc{constructor(){this.indexes={},this.usedCrossTileIDs={},this.lng=0}handleWrapJump(t){const n=Math.round((t-this.lng)/360);if(n!==0)for(const l in this.indexes){const d=this.indexes[l],p={};for(const m in d){const g=d[m];g.tileID=g.tileID.unwrapTo(g.tileID.wrap+n),p[g.tileID.key]=g}this.indexes[l]=p}this.lng=t}addBucket(t,n,l){if(this.indexes[t.overscaledZ]&&this.indexes[t.overscaledZ][t.key]){if(this.indexes[t.overscaledZ][t.key].bucketInstanceId===n.bucketInstanceId)return!1;this.removeBucketCrossTileIDs(t.overscaledZ,this.indexes[t.overscaledZ][t.key])}for(let p=0;p<n.symbolInstances.length;p++)n.symbolInstances.get(p).crossTileID=0;this.usedCrossTileIDs[t.overscaledZ]||(this.usedCrossTileIDs[t.overscaledZ]=new Set);const d=this.usedCrossTileIDs[t.overscaledZ];for(const p in this.indexes){const m=this.indexes[p];if(Number(p)>t.overscaledZ)for(const g in m){const x=m[g];x.tileID.isChildOf(t)&&x.findMatches(n.symbolInstances,t,d)}else{const g=m[t.scaledTo(Number(p)).key];g&&g.findMatches(n.symbolInstances,t,d)}}for(let p=0;p<n.symbolInstances.length;p++){const m=n.symbolInstances.get(p);m.crossTileID||(m.crossTileID=l.generate(),d.add(m.crossTileID))}return this.indexes[t.overscaledZ]===void 0&&(this.indexes[t.overscaledZ]={}),this.indexes[t.overscaledZ][t.key]=new Hn(t,n.symbolInstances,n.bucketInstanceId),!0}removeBucketCrossTileIDs(t,n){for(const l of n.crossTileIDs)this.usedCrossTileIDs[t].delete(l)}removeStaleBuckets(t){let n=!1;for(const l in this.indexes){const d=this.indexes[l];for(const p in d)t[d[p].bucketInstanceId]||(this.removeBucketCrossTileIDs(l,d[p]),delete d[p],n=!0)}return n}}class s_{constructor(){this.layerIndexes={},this.crossTileIDs=new Vh,this.maxBucketInstanceId=0,this.bucketsInCurrentPlacement={}}addLayer(t,n,l,d){let p=this.layerIndexes[t.fqid];p===void 0&&(p=this.layerIndexes[t.fqid]=new Sc);let m=!1;const g={};d.name!=="globe"&&p.handleWrapJump(l);for(const x of n){const w=x.getBucket(t);w&&t.fqid===w.layerIds[0]&&(w.bucketInstanceId||(w.bucketInstanceId=++this.maxBucketInstanceId),p.addBucket(x.tileID,w,this.crossTileIDs)&&(m=!0),g[w.bucketInstanceId]=!0)}return p.removeStaleBuckets(g)&&(m=!0),m}pruneUnusedLayers(t){const n={};t.forEach(l=>{n[l]=!0});for(const l in this.layerIndexes)n[l]||delete this.layerIndexes[l]}}class Al extends u.E{constructor(t){super(),this.requestManager=t,this.models=Object.create(null),this.models[""]=Object.create(null),this.modelUris=Object.create(null),this.modelUris[""]=Object.create(null),this.modelByURL=Object.create(null),this.numModelsLoading=Object.create(null)}async loadModel(t,n){try{const l=await this.requestManager.transformRequest(n,u.R.Model);if(!this.modelByURL[n])return null;const d=await u.eb(l.url),p=u.ec(d),m=new u.ed(t,n,void 0,void 0,p);return m.computeBoundsAndApplyParent(),m}catch(l){if(l.status===404)return null;this.fire(new u.A(new Error(`Could not load model ${t} from ${n}`,{cause:l})))}}load(t,n,l={forceReload:!1}){this.models[n]||(this.models[n]=Object.create(null));const d=Object.keys(t),p=[],m=[];for(const g of d){const x=t[g];this.hasURLBeenRequested(x)&&!l.forceReload||(this.modelByURL[x]={modelId:g,scope:n},p.push(this.loadModel(g,x)),m.push(g)),this.models[n][g]||(this.models[n][g]={model:null,numReferences:1})}this.numModelsLoading[n]=(this.numModelsLoading[n]||0)+m.length,Promise.allSettled(p).then(g=>{for(let x=0;x<g.length;x++){const{status:w}=g[x];if(w==="rejected")continue;const{value:S}=g[x];this.models[n][m[x]]||(this.models[n][m[x]]={model:null,numReferences:1}),this.models[n][m[x]].model=S}this.numModelsLoading[n]-=m.length,this.fire(new u.B("data",{dataType:"style"}))}).catch(g=>{this.fire(new u.A(new Error(`Could not load models: ${g.message}`)))})}isLoaded(){for(const t in this.numModelsLoading)if(this.numModelsLoading[t]>0)return!1;return!0}hasModel(t,n,l={exactIdMatch:!1}){return!!(l.exactIdMatch?this.getModel(t,n):this.getModelByURL(this.modelUris[n][t]))}getModel(t,n){return this.models[n]||(this.models[n]=Object.create(null)),this.models[n][t]?this.models[n][t].model:void 0}getModelByURL(t){if(!t)return null;const n=this.modelByURL[t];return n?this.models[n.scope][n.modelId].model:null}hasModelBeenAdded(t,n){return this.models[n]&&this.models[n][t]!==void 0}getModelURIs(t){return this.modelUris[t]||Object.create(null)}addModel(t,n,l){this.models[l]||(this.models[l]=Object.create(null)),this.modelUris[l]||(this.modelUris[l]=Object.create(null));const d=this.requestManager.normalizeModelURL(n);if((this.hasModel(t,l,{exactIdMatch:!0})||this.hasModelBeenAdded(t,l))&&this.modelUris[l][t]===d)this.models[l][t].numReferences++;else if(this.hasURLBeenRequested(d)){const{scope:p,modelId:m}=this.modelByURL[d];this.models[p][m].numReferences++}else this.modelUris[l][t]=d,this.load({[t]:this.modelUris[l][t]},l)}addModelURLs(t,n){this.models[n]||(this.models[n]=Object.create(null)),this.modelUris[n]||(this.modelUris[n]=Object.create(null));const l=this.modelUris[n];for(const d of Object.keys(t))l[d]=this.requestManager.normalizeModelURL(t[d])}reloadModels(t){this.load(this.modelUris[t],t,{forceReload:!0})}addModelsFromBucket(t,n){this.models[n]||(this.models[n]=Object.create(null)),this.modelUris[n]||(this.modelUris[n]=Object.create(null));const l=Object.create(null);for(const d of t)this.hasModel(d,n,{exactIdMatch:!0})||this.hasURLBeenRequested(d)?this.models[n][d].numReferences++:this.modelUris[n][d]&&!this.hasURLBeenRequested(d)?l[d]=this.modelUris[n][d]:!this.hasURLBeenRequested(d)&&or(d,!1)&&(this.modelUris[n][d]=this.requestManager.normalizeModelURL(d),l[d]=this.modelUris[n][d]);this.load(l,n)}hasURLBeenRequested(t){return this.modelByURL[t]!==void 0}removeModel(t,n,l=!1,d=!1){if(this.models[n]&&this.models[n][t]&&(this.models[n][t].numReferences--,this.models[n][t].numReferences===0||d)){const p=this.modelUris[n][t];l||delete this.modelUris[n][t],delete this.modelByURL[p];const m=this.models[n][t].model;if(!m)return;delete this.models[n][t],m.destroy()}}destroy(){for(const t of Object.keys(this.models))for(const n of Object.keys(this.models[t])){const l=this.models[t][n].model;delete this.models[t][n],l&&l.destroy()}this.models=Object.create(null),this.models[""]=Object.create(null),this.modelUris=Object.create(null),this.modelUris[""]=Object.create(null),this.modelByURL=Object.create(null),this.numModelsLoading=Object.create(null)}listModels(t){return this.models[t]||(this.models[t]=Object.create(null)),Object.keys(this.models[t])}upload(t,n){this.models[n]||(this.models[n]=Object.create(null));for(const l in this.models[n])this.models[n][l].model&&this.models[n][l].model.upload(t.context)}}const yu=["RENDER_SHADOWS","NORMAL_OFFSET"],iy=new Set(["symbol","circle"]),Df=class tv{constructor(){this._queue=[],this._needsBuild=!0,this._idleHandle=null}needsBuild(){return this._needsBuild}buildQueue(t,n,l){this._idleHandle!=null&&typeof cancelIdleCallback<"u"&&cancelIdleCallback(this._idleHandle),this._idleHandle=null,this._queue=[],this._needsBuild=!1;const d=!!l.fog,p=l.hasTerrain(),m=!(!l.projection||l.projection.name!=="globe"),g=p||m,x=!(!l.directionalLight||!l.directionalLight.shadowsEnabled()),w=l.map&&l.map.painter,S=!w||!w.context.extParallelShaderCompile,A=!!w&&w.emissiveMode==="mrt-fallback",I=(M,D=[],L={})=>{this._queue.push({programId:M,params:{...L.params,defines:D,overrideFog:!!L.fog,overrideTerrain:!!L.terrain,overrideGlobe:!!L.globe,overrideRtt:!!L.rtt,precompiled:!0}})};for(const M of t){if(M.visibility==="none")continue;const D=M.getProgramIds();if(D)for(const L of D){if(iy.has(L))continue;const k=M.getDefaultProgramParams(L,n.zoom,l._styleColorTheme.lut);if(!k)continue;const B=w?w.getShaderSource(L):null,$=g&&(!B||B.usedDefines.has("RENDER_TO_TEXTURE")),Z=A&&$?(k.defines||[]).concat("USE_MRT1"):k.defines;if(S){I(L,k.defines,{params:k}),$&&I(L,Z,{params:k,rtt:!0});continue}const G=d&&(!B||B.usedDefines.has("FOG")),te=p&&!M.isDraped()&&(!B||B.usedDefines.has("TERRAIN")),ee=m&&(!B||B.usedDefines.has("GLOBE")),le=x&&M.hasElevation()&&(!B||B.usedDefines.has("RENDER_SHADOWS"));for(const K of le?[!1,!0]:[!1]){const Q=K?(k.defines||[]).concat(yu):k.defines||[];for(const ae of te?[!1,!0]:[!1])for(const de of ee?[!1,!0]:[!1])for(const fe of G?[!1,!0]:[!1])I(L,Q,{params:k,fog:fe,terrain:ae,globe:de})}$&&I(L,Z,{params:k,rtt:!0})}}if(I("clippingMask"),p)for(const M of[!1,!0])I("terrainRaster",M?["TERRAIN_VERTEX_MORPHING"]:[],{terrain:!0,fog:d});if(!S){if(t.some(M=>M.type==="hillshade")&&I("hillshadePrepare"),x)for(const M of[!1,!0])for(const D of[!1,!0]){const L=[];M&&L.push("RENDER_CUTOFF"),L.push("RENDER_SHADOWS"),D&&L.push("NORMAL_OFFSET"),I("groundShadow",L),d&&I("groundShadow",L,{fog:!0})}if(m){for(const M of[[],["TERRAIN_VERTEX_MORPHING"],["GLOBE_POLES"]])for(const D of[!1,!0]){const L=[...M,"PROJECTION_GLOBE_VIEW"];D&&L.push("CUSTOM_ANTIALIASING"),I("globeRaster",L,{terrain:p,globe:!0,fog:d})}for(const M of[!1,!0]){const D=M?["PROJECTION_GLOBE_VIEW","FOG"]:["FOG"];I("globeAtmosphere",D,{fog:!0,terrain:p,globe:M}),I("globeAtmosphere",[...D,"ALPHA_PASS"],{fog:!0,terrain:p,globe:M})}I("stars",[],{fog:d,terrain:p,globe:!0})}}}_executeBatch(t,n,l){if(l.map&&l.map.isMoving())return void(this._idleHandle=u.r.requestIdleCallback(g=>this._executeBatch(g,n,l)));n.context.sweepPendingPrograms();const d=n.context.extParallelShaderCompile?tv.DEADLINE_MARGIN_KHR_MS:tv.DEADLINE_MARGIN_SYNC_MS;let p=0;for(;this._queue.length>0;){const g=this._queue.shift();if(!g||(n.style=l,n._fogVisible=!!g.params.overrideFog,n.getOrCreateProgram(g.programId,g.params),p++,t.timeRemaining()<=d))break}const m=this._queue.length===0||t.timeRemaining()>d;p>0&&m&&n.context.gl.flush(),this._idleHandle=this._queue.length>0||n.context._pendingPrograms.size>0?u.r.requestIdleCallback(g=>this._executeBatch(g,n,l)):null}processQueue(t,n){this._queue.length!==0&&(this._idleHandle!=null&&typeof cancelIdleCallback<"u"&&cancelIdleCallback(this._idleHandle),this._idleHandle=u.r.requestIdleCallback(l=>this._executeBatch(l,t,n)))}reset(){this._idleHandle!=null&&typeof cancelIdleCallback<"u"&&cancelIdleCallback(this._idleHandle),this._queue=[],this._idleHandle=null,this._needsBuild=!0}};Df.DEADLINE_MARGIN_KHR_MS=5,Df.DEADLINE_MARGIN_SYNC_MS=25;let ry=Df;const Lf=u.m.colorTheme,ny=new u.a7({data:new u.a8(Lf.data)});function oy(s){if(!s.metadata||!s.metadata.content_area)return;const t=u.r.devicePixelRatio,{left:n,top:l,width:d,height:p}=s.metadata.content_area,m=n*t,g=l*t;return[m,g,m+d*t,g+p*t]}function a_(s){if(s)return s.map(([t,n])=>[t*u.r.devicePixelRatio,n*u.r.devicePixelRatio])}class zf{constructor(t,n,l){this.id=t,this.scope=n,this.sourceCache=l,this.pendingRequests=new Set,this.missingRequests=new Set}addPendingRequest(t){this.missingRequests.has(t.name)||this.pendingRequests.has(t.name)||this.pendingRequests.add(t.name)}hasPendingRequests(){return this.pendingRequests.size>0}resolvePendingRequests(){const t=new Map;if(!this.sourceCache.loaded())return t;const n=this.sourceCache.getVisibleCoordinates();if(n.length===0)return t;const l=this.sourceCache.getSource();if(!(l instanceof bl))return t;const d=n.map(m=>this.sourceCache.getTile(m)),p=l.getImages(d,Array.from(this.pendingRequests));for(const[m,g]of p)t.set(u.I.from({name:m,iconsetId:this.id}),g),this.pendingRequests.delete(m);for(const m of this.pendingRequests)this.missingRequests.add(m);return this.pendingRequests.clear(),t}}const Cl=(s,t)=>cl(s,t&&t.filter(n=>n.identifier!=="source.canvas")),xu=(s,t)=>{const n=s.type&&!s.array&&Array.isArray(t)?{type:s.type,"property-type":"data-constant"}:void 0;return u.n(t,n)},vu=u.b5(xt,["addLayer","removeLayer","setLights","setPaintProperty","setLayoutProperty","setLayerProperty","setSlot","setFilter","addSource","removeSource","setLayerZoomRange","setLight","setTransition","setGeoJSONSourceData","setTerrain","setFog","setSnow","setRain","setProjection","setCamera","addImport","removeImport","updateImport","addIconset","removeIconset"]),sy=u.b5(xt,["setCenter","setZoom","setBearing","setPitch"]),Sr=new Set(["background","sky","slot","custom"]),Ml={version:8,layers:[],sources:{}},Ff={duration:300,delay:0};class go extends u.E{constructor(t,n={}){super(),this.map=t,this.scope=n.scope||"",this.globalId=null,this.fragments=[],this.importDepth=n.importDepth||0,this.importsCache=n.importsCache||new Map,this.resolvedImports=n.resolvedImports||new Set,this.transition={...Ff},this._buildingIndex=new If(this),this.crossTileSymbolIndex=new s_,this._mergedOrder=[],this._drapedFirstOrder=[],this._mergedLayers=Object.create(null),this._mergedIndoor={},this._indoorEnabled=!1,this._mergedSourceCaches={},this._mergedOtherSourceCaches=Object.create(null),this._mergedSymbolSourceCaches=Object.create(null),this._mergedFillExtrusionSourceCaches=Object.create(null),this._mergedHdRoadCoverageSourceCaches=Object.create(null),this._mergedHdRoadElevationSourceCaches=Object.create(null),this._hdCoverage=null,this._hdElevation=null,this._crossSourceElevationActive=!1,this._clipLayerPresent=!1,this._hasAppearances=!1,this._has3DLayers=!1,this._hasCircleLayers=!1,this._hasSymbolLayers=!1,this._importedAsBasemap=!1,this._changes=n.styleChanges||new to,this._hasDataDrivenEmissive=!1,this.indoorManager=null,this.dispatcher=n.dispatcher?n.dispatcher:new dl(Rh(),this);const l={referrer:u.ef(),config:u.ee()};if(this.map.painter&&this.map.painter.context){const p=this.map.painter.context.maxUniformBufferBindings,m=Math.floor(this.map.painter.context.maxUniformBlockSize/4);l.contextOptions={maxBindingPoints:p,maxUniformBlockSizeDwords:m}}this.isRootStyle()&&this.dispatcher.broadcast("setGlobalParams",l),n.imageManager?this.imageManager=n.imageManager:(this.imageManager=new ue(this.map._spriteFormat),this.imageManager.setEventedParent(this)),this.imageManager.addScope(this.scope),this.glyphManager=n.glyphManager?n.glyphManager:new u.eg(t._requestManager,n.localFontFamily?u.eh.all:n.localIdeographFontFamily?u.eh.ideographs:u.eh.none,n.localFontFamily||n.localIdeographFontFamily,n.fontstackCompositing),n.modelManager?this.modelManager=n.modelManager:(this.modelManager=new Al(t._requestManager),this.modelManager.setEventedParent(this)),this._layers=Object.create(null),this._sourceCaches={},this._otherSourceCaches=Object.create(null),this._symbolSourceCaches=Object.create(null),this._fillExtrusionSourceCaches=Object.create(null),this._hdCoverage=null,this._hdElevation=null,this._crossSourceElevationActive=!1,this._loaded=!1,this._initialBroadcastDone=!1,this._programPrecompiler=this.map._precompilePrograms&&this.isRootStyle()?new ry:null,this._availableImages=[],this._availableModels={},this._order=[],this._markersNeedUpdate=!1,this.options=n.configOptions?n.configOptions:new Map,this._layerExpressionDependencies=n.layerExpressionDependencies?n.layerExpressionDependencies:new Map,this._config=n.config,this._styleColorTheme={lut:null,lutLoading:!1,lutLoadingCorrelationID:0,colorTheme:null,colorThemeOverride:n.colorThemeOverride},this._styleColorThemeForScope={},this._initialConfig=n.initialConfig;const d=this;this._rtlTextPluginCallback=go.registerForPluginStateChange(p=>{d.dispatcher.send("syncRTLPluginState",{pluginStatus:p.pluginStatus,pluginURL:p.pluginURL}).then(m=>{if(u.ei(null),m.every(g=>g))for(const g in d._sourceCaches){const x=d._sourceCaches[g],w=x.getSource().type;w!=="vector"&&w!=="geojson"||x.reload()}}).catch(m=>{u.ei(m)})}),this.on("data",p=>{if(p.dataType!=="source"||p.sourceDataType!=="metadata")return;const m=this.getOwnSource(p.sourceId);if(m&&m.vectorLayerIds)for(const g in this._layers){const x=this._layers[g];x.source===m.id&&this._validateLayer(x)}})}load(t){return t?(typeof t=="string"?this.loadURL(t):this.loadJSON(t),this):this}_getGlobalId(t){if(!t)return null;if(typeof t=="string"){if(u.e(t))return t;const n=u.ej(t);if(!n.startsWith("http"))try{return new URL(n,location.href).toString()}catch{return n}return n}return`json://${u.ek(JSON.stringify(t))}`}_diffStyle(t,n,l){this.globalId=this._getGlobalId(t);const d=(p,m)=>{try{m(null,this.setState(p,l))}catch(g){m(g,!1)}};if(typeof t=="string"){const p=this.map._requestManager.normalizeStyleURL(t),m=new AbortController;this._request={cancel:()=>m.abort()},(async()=>{const g=await this.map._requestManager.transformRequest(p,u.R.Style,m.signal),{data:x}=await u.o(g,m.signal);this._request=null,d(x,n)})().catch(g=>{this._request=null,m.signal.aborted||this.fire(new u.A(g))})}else typeof t=="object"&&d(t,n)}loadURL(t,n={}){this.fire(new u.B("dataloading",{dataType:"style"}));const l=typeof n.validate=="boolean"?n.validate:!u.e(t);this.globalId=this._getGlobalId(t),t=this.map._requestManager.normalizeStyleURL(t,n.accessToken),this.resolvedImports.add(t);const d=this.importsCache.get(t);if(d)return this._load(d,l);const p=new AbortController;this._request={cancel:()=>p.abort()},(async()=>{const m=await this.map._requestManager.transformRequest(t,u.R.Style,p.signal),{data:g}=await u.o(m,p.signal);this._request=null,this.importsCache.set(t,g),this._load(g,l)})().catch(m=>{this._request=null,p.signal.aborted||this.fire(new u.A(m))})}loadJSON(t,n={}){this.fire(new u.B("dataloading",{dataType:"style"})),this.globalId=this._getGlobalId(t),this._request=u.r.frame(()=>{this._request=null,this._load(t,n.validate!==!1)})}loadEmpty(){this.fire(new u.B("dataloading",{dataType:"style"})),this._load(Ml,!1)}_loadImports(t,n,l){if(this.importDepth>=4)return u.w("Style doesn't support nesting deeper than 5"),Promise.resolve();const d=[];for(const p of t){const m=this._createFragmentStyle(p),g=new Promise(S=>{m.once("style.import.load",S),m.once("error",S)}).then(()=>{this.mergeAll(),this.fire(new u.B("data",{dataType:"style"}))});if(d.push(g),this.resolvedImports.has(p.url)){m.loadEmpty();continue}const x=p.data||this.importsCache.get(p.url);x?(p.data?(m.fire(new u.B("dataloading",{dataType:"style"})),m.globalId=m._getGlobalId(x),queueMicrotask(()=>m._load(x,n))):m.loadJSON(x,{validate:n}),this._isInternalStyle(x)&&(m.globalId=null)):p.url?m.loadURL(p.url,{validate:n}):m.loadEmpty();const w={style:m,id:p.id,config:p.config};if(l){const S=this.fragments.findIndex(({id:A})=>A===l);this.fragments=this.fragments.slice(0,S).concat(w).concat(this.fragments.slice(S))}else this.fragments.push(w)}return Promise.allSettled(d)}getImportGlobalIds(t=this,n=new Set){for(const l of t.fragments)l.style.globalId&&n.add(l.style.globalId),this.getImportGlobalIds(l.style,n);return[...n.values()]}_createFragmentStyle(t){const n=this.scope?u.y(t.id,this.scope):t.id;let l;const d=this._initialConfig&&this._initialConfig[n];(t.config||d)&&(l={...t.config,...d});const p=new go(this.map,{scope:n,styleChanges:this._changes,importDepth:this.importDepth+1,importsCache:this.importsCache,resolvedImports:new Set(this.resolvedImports),dispatcher:this.dispatcher,imageManager:this.imageManager,glyphManager:this.glyphManager,modelManager:this.modelManager,config:l,configOptions:this.options,colorThemeOverride:t["color-theme"],layerExpressionDependencies:this._layerExpressionDependencies});return p.setEventedParent(this.map,{style:p}),p}_reloadImports(t=!1){this.mergeAll(),this._updateMapProjection(),t||this.updateConfigDependencies(),this._updateLayers(this._dependentLayerIds(n=>n.isIndoorDependent)),this.map._triggerCameraUpdate(this.camera),(!t||this.isRootStyle()||this.map.style._initialBroadcastDone)&&(t&&this.isRootStyle()?(this.forEachFragmentStyle(n=>{this.dispatcher.broadcast("setLayers",{layers:n._serializeLayers(n._order),scope:n.scope,options:n.options})}),this._initialBroadcastDone=!0):this.dispatcher.broadcast("setLayers",{layers:this._serializeLayers(this._order),scope:this.scope,options:this.options}))}_isInternalStyle(t){return this.isRootStyle()&&(t.fragment||!!t.schema&&t.fragment!==!1)}_load(t,n){if(this._isInternalStyle(t)){const p={id:"basemap",data:t,url:""},m={...Ml,imports:[p],...t.center?{center:t.center}:{},...t.bearing?{bearing:t.bearing}:{},...t.pitch?{pitch:t.pitch}:{},...t.zoom?{zoom:t.zoom}:{},...t.light?{light:t.light}:{}};return this._importedAsBasemap=!0,void this._load(m,n)}if(this.updateConfig(this._config,t.schema),n&&Cl(this,Or(t)))return;this._loaded=!0;for(const p in t.sources)this.addSource(p,t.sources[p],{validate:!1,isInitialLoad:!0});this.stylesheet=u.el(t);const l=()=>{if(t.iconsets)for(const w in t.iconsets)this.addIconset(w,t.iconsets[w]);t.sprite?this._loadIconset(t.sprite):(this.imageManager.setLoaded(!0,this.scope),this.dispatcher.broadcast("spriteLoaded",{scope:this.scope})),!this.glyphManager.url&&t.glyphs&&this.glyphManager.setURL(t.glyphs);const p=Ys(this.stylesheet.layers);if(this._order=p.map(w=>w.id),this.stylesheet.light&&u.w("The `light` root property is deprecated, prefer using `lights` with `flat` light type instead."),this.stylesheet.lights)if(this.stylesheet.lights.length===1&&this.stylesheet.lights[0].type==="flat"){const w=this.stylesheet.lights[0];this.light=new ul(w.properties,w.id)}else this.setLights(this.stylesheet.lights);this.light||(this.light=new ul(this.stylesheet.light)),this._layers=Object.create(null);let m=!1;for(const w of p){const S=u.ep(w,this.scope,this._styleColorTheme.lut,this.options);this._layerExpressionDependencies.set(S.fqid,new Co(S)),this._hasAppearances=this._hasAppearances||S.getAppearances().length!==0,S.setEventedParent(this,{layer:{id:S.id}}),this._layers[S.id]=S,this._updateHdCoverageSourceCache(S)&&(m=!0);const A=this.getOwnLayerSourceCache(S),I=!!this.directionalLight&&this.directionalLight.shadowsEnabled();A&&S.canCastShadows()&&I&&(A.castsShadows=!0)}if(m&&hu().then(()=>{if(!this.map)return;for(const S in this._layers)this._updateHdCoverageSourceCache(this._layers[S]);this.map.style.mergeAll();const w=this.map.transform;for(const S in this.map.style._mergedHdRoadCoverageSourceCaches){const A=this.map.style._mergedHdRoadCoverageSourceCaches[S];A.used=!0,w&&A.update(w)}this.map._update()}),this.glyphManager.url){const w=new Set;for(const S in this._layers){const A=this._layers[S];if(A.type==="symbol"&&A.layout){const I=A.layout.get("text-font");I&&I.value&&I.value.kind==="constant"&&w.add(I.value.value.join(","))}}for(const S of w)this.glyphManager.prefetchRange(S,0)}this.stylesheet.featuresets&&this.setFeaturesetSelectors(this.stylesheet.featuresets),this.stylesheet.models&&this.addModelURLs(this.stylesheet.models);const g=this.stylesheet.terrain;g&&(this.checkCanvasFingerprintNoise(),this.disableElevatedTerrain||this.terrainSetForDrapingOnly()||this._createTerrain(g,1)),this.stylesheet.fog&&this._createFog(this.stylesheet.fog),this.stylesheet.snow&&this._createSnow(this.stylesheet.snow),this.stylesheet.rain&&this._createRain(this.stylesheet.rain),this.stylesheet.transition&&this.setTransition(this.stylesheet.transition),this.fire(new u.B("data",{dataType:"style"}));const x=this.isRootStyle();t.imports?this._loadImports(t.imports,n).then(()=>{this._reloadImports(!0),this.fire(new u.B(x?"style.load":"style.import.load"))}).catch(w=>{this.fire(new u.A(new Error("Failed to load imports",w))),this.fire(new u.B(x?"style.load":"style.import.load"))}):(this._reloadImports(!0),this.fire(new u.B(x?"style.load":"style.import.load")))};this._styleColorTheme.colorTheme=this.stylesheet["color-theme"];const d=this._styleColorTheme.colorThemeOverride?this._styleColorTheme.colorThemeOverride:this._styleColorTheme.colorTheme;if(d){const p=this._evaluateColorThemeData(d);this._loadColorTheme(p).then(()=>{l()}).catch(m=>{u.w(`Couldn't load color theme from the stylesheet: ${m}`),l()})}else this._styleColorTheme.lut=null,l()}isRootStyle(){return this.importDepth===0}hasAppearances(){return this._hasAppearances||this.fragments.some(t=>t.style.hasAppearances())}mergeAll(){let t,n,l,d,p,m,g,x,w,S;const A={};this.terrain&&this.terrain.scope!==this.scope&&delete this.terrain,this.forEachFragmentStyle(I=>{if(I.stylesheet){if(I.disableElevatedTerrain&&(this.disableElevatedTerrain=!0),I.light!=null&&(t=I.light),I.stylesheet.lights)for(const M of I.stylesheet.lights)M.type==="ambient"&&I.ambientLight!=null&&(n=I.ambientLight),M.type==="directional"&&I.directionalLight!=null&&(l=I.directionalLight);d=this._prioritizeTerrain(d,I.terrain,I.stylesheet.terrain),I.stylesheet.fog&&I.fog!=null&&(p=I.fog),I.stylesheet.snow&&I.snow!=null&&(m=I.snow),I.stylesheet.rain&&I.rain!=null&&(g=I.rain),I.stylesheet.camera!=null&&(S=I.stylesheet.camera),I.stylesheet.projection!=null&&(x=I.stylesheet.projection),I.stylesheet.transition!=null&&(w=I.stylesheet.transition),A[I.scope]=I._styleColorTheme}}),this.light=t,this.ambientLight=n,this.directionalLight=l,this.fog=p,this.snow=m,this.rain=g,this._styleColorThemeForScope=A,d===null?delete this.terrain:this.terrain=d,this.camera=S||{"camera-projection":"perspective"},this.projection=x||{name:"mercator"},this.transition={...Ff,...w},this.mergeSources(),this.mergeLayers(),this.mergeIndoor(),this._programPrecompiler&&this._programPrecompiler.reset()}forEachFragmentStyle(t){const n=l=>{for(const d of l.fragments)n(d.style);t(l)};n(this)}_prioritizeTerrain(t,n,l){const d=t&&t.drapeRenderMode===0;return l===null?n&&n.drapeRenderMode===0?n:d?t:null:n!=null&&(!t||d||n&&n.drapeRenderMode===1)?n:t}mergeTerrain(){let t;this.terrain&&this.terrain.scope!==this.scope&&delete this.terrain,this.forEachFragmentStyle(n=>{t=this._prioritizeTerrain(t,n.terrain,n.stylesheet.terrain)}),t===null?delete this.terrain:this.terrain=t,this._programPrecompiler&&this._programPrecompiler.reset()}mergeProjection(){let t;this.forEachFragmentStyle(n=>{n.stylesheet.projection!=null&&(t=n.stylesheet.projection)}),this.projection=t||{name:"mercator"},this._programPrecompiler&&this._programPrecompiler.reset()}mergeSources(){const t={},n=Object.create(null),l=Object.create(null),d=Object.create(null),p=Object.create(null),m=Object.create(null);this.forEachFragmentStyle(g=>{for(const x in g._sourceCaches){const w=u.y(x,g.scope);t[w]=g._sourceCaches[x]}for(const x in g._otherSourceCaches){const w=u.y(x,g.scope);n[w]=g._otherSourceCaches[x]}for(const x in g._symbolSourceCaches){const w=u.y(x,g.scope);l[w]=g._symbolSourceCaches[x]}for(const x in g._fillExtrusionSourceCaches){const w=u.y(x,g.scope);d[w]=g._fillExtrusionSourceCaches[x]}if(g._hdCoverage){const x=g._hdCoverage.coverageSourceCaches;for(const w in x)p[u.y(w,g.scope)]=x[w]}if(g._hdElevation){const x=g._hdElevation.elevationSourceCaches;for(const w in x)m[w]=x[w]}}),this._mergedSourceCaches=t,this._mergedOtherSourceCaches=n,this._mergedSymbolSourceCaches=l,this._mergedFillExtrusionSourceCaches=d,this._mergedHdRoadCoverageSourceCaches=p,this._mergedHdRoadElevationSourceCaches=m,Object.keys(p).length>0&&!this._hdCoverage&&jt.HdCoverageState&&(this._hdCoverage=new jt.HdCoverageState),jt.updateCrossSourceElevationGate&&jt.updateCrossSourceElevationGate(this)}mergeIndoor(){this._mergedIndoor={},this.forEachFragmentStyle(t=>{if(t.stylesheet&&t.stylesheet.indoor)for(const n of Object.values(t.stylesheet.indoor)){const l=n,d=u.y(l.sourceId,t.scope);this._mergedIndoor[d]=new Set(l.sourceLayers||[])}}),this._updateIndoorEnabled()}_updateIndoorEnabled(){const t=this._indoorEnabled;if(this._indoorEnabled=!1,Object.keys(this._mergedIndoor).length>0)for(const n of this._mergedOrder){const l=this._mergedLayers[n];if(l.visibility!=="none"&&this._mergedIndoor[u.y(l.source,l.scope)]){this._indoorEnabled=!0;break}}!this._indoorEnabled||t||this.indoorManager||hu().then(()=>{this._initIndoorManager()})}_initIndoorManager(){if(!this.indoorManager&&jt.IndoorManager&&this.isRootStyle()&&Object.keys(this._mergedIndoor).length!==0&&(this.indoorManager=new jt.IndoorManager(this,this._loaded),this._loaded))for(const t of Object.keys(this._mergedIndoor)){const n=this._mergedSourceCaches[t]||this._mergedOtherSourceCaches[t];n&&n.reload()}}mergeLayers(){const t={},n=[],l=Object.create(null);this._mergedSlots=[],this._has3DLayers=!1,this._hasCircleLayers=!1,this._hasSymbolLayers=!1,this.forEachFragmentStyle(m=>{for(const g of m._order){const x=m._layers[g];if(x.type==="slot"){const w=u.dD(g);if(t[w])continue;t[w]=[]}x.slot&&t[x.slot]?t[x.slot].push(x):n.push(x)}}),this._mergedOrder=[];let d=-1;const p=(m=[])=>{for(const g of m)if(g.type==="slot"){const x=u.dD(g.id);t[x]&&p(t[x]),this._mergedSlots.push(x)}else{const x=u.y(g.id,g.scope);this._mergedOrder.push(x),l[x]=g,g.is3D(!!this.terrain)&&(this._has3DLayers=!0,d=this._mergedOrder.length-1),g.type==="circle"&&(this._hasCircleLayers=!0),g.type==="symbol"&&(this._hasSymbolLayers=!0),g.type==="clip"&&(this._clipLayerPresent=!0)}};if(p(n),this._has3DLayers){const m={};for(let g=0;g<this._mergedOrder.length;++g){const x=this._mergedOrder[g];m[x]=g===d?1:g<d?l[x].hasOcclusionOpacityProperties?2:0:4}this._mergedOrder.sort((g,x)=>m[g]-m[x])}this._mergedLayers=l,this.updateDrapeFirstLayers(),this._buildingIndex.processLayersChanged(),this._updateDataDrivenEmissiveStrength()}terrainSetForDrapingOnly(){return!!this.terrain&&this.terrain.drapeRenderMode===0}getCamera(){return this.stylesheet.camera}setCamera(t){return this.stylesheet.camera={...this.stylesheet.camera,...t},this.camera=this.stylesheet.camera,this}_evaluateColorThemeData(t){return t.data?(function(n,l,d){const p={...l};for(const g of Object.keys(Lf))p[g]===void 0&&(p[g]=Lf[g].default);const m=new u.a6(ny,n,new Map(d));return m.setTransitionOrValue(p,d),m.untransitioned().possiblyEvaluate(new u.aa(0,{worldview:void 0}))})(this.scope,t,this.options).get("data"):null}_loadColorTheme(t){this._styleColorTheme.lutLoading=!0,this._styleColorTheme.lutLoadingCorrelationID+=1;const n=this._styleColorTheme.lutLoadingCorrelationID;return new Promise((l,d)=>{const p="data:image/png;base64,";if(!t||t.length===0)return this._styleColorTheme.lut=null,this._styleColorTheme.lutLoading=!1,void l();let m=t;m.startsWith(p)||(m=p+m);const g=u.I.from("mapbox-reserved-lut"),x=new Image;x.src=m,x.onerror=()=>{this._styleColorTheme.lutLoading=!1,d(new Error("Failed to load image data"))},x.onload=()=>{if(this._styleColorTheme.lutLoadingCorrelationID!==n)return void l();this._styleColorTheme.lutLoading=!1;const{width:w,height:S,data:A}=u.r.getImageData(x);if(S>32)return void d(new Error("The height of the image must be less than or equal to 32 pixels."));if(w!==S*S)return void d(new Error("The width of the image must be equal to the height squared."));this.getImage(g)&&this.removeImage(g),this.addImage(g,{data:new u.t({width:w,height:S},A),pixelRatio:1,sdf:!1,usvg:!1,version:0});const I=this.imageManager.getImage(g,this.scope);I?(this._styleColorTheme.lut={image:I.data,data:t},l()):d(new Error("Missing LUT image."))}})}getLut(t){const n=this._styleColorThemeForScope[t];return n?n.lut:null}setProjection(t){t?this.stylesheet.projection=t:delete this.stylesheet.projection,this.mergeProjection(),this._updateMapProjection()}applyProjectionUpdate(){this._loaded&&(this.dispatcher.broadcast("setProjection",this.map.transform.projectionOptions),this.map.transform.projection.requiresDraping?this.hasTerrain()||this.setTerrainForDraping():this.terrainSetForDrapingOnly()&&this.setTerrain(null,0))}_updateMapProjection(){this.isRootStyle()&&(this.map._useExplicitProjection?this.applyProjectionUpdate():this.map._prioritizeAndUpdateProjection(null,this.projection))}_loadSprite(t){const n=new AbortController;this._spriteRequest=n,(function(l,d,p,m){let g,x,w;const S=u.r.devicePixelRatio>1?"@2x":"";function A(I){w||I&&p.aborted||(I&&(w=I),(function(){if(w)m(w);else if(g&&x){const M=u.r.getImageData(x),D={};for(const L in g){const{width:k,height:B,x:$,y:Z,sdf:G,pixelRatio:te,stretchX:ee,stretchY:le,content:K}=g[L],Q=new u.t({width:k,height:B});u.t.copy(M,Q,{x:$,y:Z},{x:0,y:0},{width:k,height:B},null),D[L]={data:Q,pixelRatio:te!==void 0?te:1,sdf:G!==void 0&&G,stretchX:ee,stretchY:le,content:K,usvg:!1,version:0}}m(null,D)}})())}(async function(){const I=await d.transformRequest(d.normalizeSpriteURL(l,S,".json"),u.R.SpriteJSON,p),{data:M}=await u.o(I,p);w||(g=M)})().then(()=>A(void 0),I=>A(I)),(async function(){const I=await d.transformRequest(d.normalizeSpriteURL(l,S,".png"),u.R.SpriteImage,p),{data:M}=await u.q(I,p);w||(x=M)})().then(()=>A(void 0),I=>A(I))})(t,this.map._requestManager,n.signal,(l,d)=>{if(this._spriteRequest=null,l)this.dispatcher.broadcast("spriteLoaded",{scope:this.scope}),this.fire(new u.A(l));else if(d){const p=new Map;for(const m in d)p.set(u.I.from(m),d[m]);this.addImages(p,!0)}this.imageManager.setLoaded(!0,this.scope),this.fire(new u.B("data",{dataType:"style"}))})}addIconset(t,n){if(n.type==="sprite")return void this._loadSprite(n.url);const l=this.getOwnSourceCache(n.source);if(!l)return void this.fire(new u.A(new Error(`Source "${n.source}" as specified by iconset "${t}" does not exist and cannot be used as an iconset source`)));const d=l.getSource();if(d.type!=="raster-array")return void this.fire(new u.A(new Error(`Source "${n.source}" as specified by iconset "${t}" is not a "raster-array" source and cannot be used as an iconset source`)));d.partial=!1;const p=new zf(t,this.scope,l);this.imageManager.addImageProvider(p,this.scope)}removeIconset(t){this.imageManager.removeImageProvider(t,this.scope)}_loadIconset(t){if(!u.e(t)&&this.map._spriteFormat!=="icon_set"||this.map._spriteFormat==="raster")return void this._loadSprite(t);const n=this.map._spriteFormat==="auto",l=new AbortController;this._spriteRequest=l,(async function(d,p,m,g){try{const x=await p.transformRequest(p.normalizeIconsetURL(d),u.R.Iconset,m),{data:w}=await u.da(x,m),S={},A=(function(I){const M={icons:[]};let D;for(;D=I.nextField(void 0);)D===1&&M.icons.push(io(I,I.readVarint()+I.pos));return M})(new u.d9(w));for(const I of A.icons){const M={version:1,pixelRatio:u.r.devicePixelRatio,content:oy(I),stretchX:I.metadata?a_(I.metadata.stretch_x_areas):void 0,stretchY:I.metadata?a_(I.metadata.stretch_y_areas):void 0,sdf:!1,usvg:!0,icon:I};S[I.name]=M}g(null,S)}catch(x){m.aborted||g(x)}})(t,this.map._requestManager,l.signal,(d,p)=>{if(this._spriteRequest=null,d)n?this._loadSprite(t):(this.dispatcher.broadcast("spriteLoaded",{scope:this.scope}),this.fire(new u.A(d)));else if(p){const m=new Map;for(const g in p)m.set(u.I.from(g),p[g]);this.addImages(m,!0)}this.imageManager.setLoaded(!0,this.scope),this.fire(new u.B("data",{dataType:"style"}))})}_validateLayer(t){const n=this.getOwnSource(t.source);if(!n)return;const l=t.sourceLayer;l&&(n.type==="geojson"||n.vectorLayerIds&&!n.vectorLayerIds.includes(l))&&this.fire(new u.A(new Error(`Source layer "${l}" does not exist on source "${n.id}" as specified by style layer "${t.id}"`)))}loaded(){if(!this._loaded||Object.keys(this._changes.getUpdatedSourceCaches()).length)return!1;for(const t in this._sourceCaches)if(!this._sourceCaches[t].loaded())return!1;if(!this.imageManager.isLoaded()||this.imageManager.hasPatternsInFlight()||!this.modelManager.isLoaded()||this._styleColorTheme.lutLoading)return!1;for(const{style:t}of this.fragments)if(!t.loaded())return!1;return!0}_serializeImports(){if(this.stylesheet.imports)return this.stylesheet.imports.map((t,n)=>{const l=this.fragments[n];return l&&l.style&&(t.data=l.style.serialize()),t})}_serializeSources(){const t={};for(const n in this._sourceCaches){const l=this._sourceCaches[n].getSource();t[l.id]||(t[l.id]=l.serialize())}return t}_serializeLayers(t){const n=[];for(const l of t){const d=this._layers[l];d&&d.type!=="custom"&&n.push(d.serialize())}return n}hasLightTransitions(){return!(!this.light||!this.light.hasTransition())||!(!this.ambientLight||!this.ambientLight.hasTransition())||!(!this.directionalLight||!this.directionalLight.hasTransition())}hasFogTransition(){return!!this.fog&&this.fog.hasTransition()}hasSnowTransition(){return!!this.snow&&this.snow.hasTransition()}hasRainTransition(){return!!this.rain&&this.rain.hasTransition()}hasTransitions(){if(this.hasLightTransitions()||this.hasFogTransition()||this.hasSnowTransition()||this.hasRainTransition())return!0;for(const t in this._sourceCaches)if(this._sourceCaches[t].hasTransition())return!0;for(const t in this._layers)if(this._layers[t].hasTransition())return!0;return!1}_updateDataDrivenEmissiveStrength(){for(const t in this._mergedLayers){const n=this._mergedLayers[t];if(n._transitionablePaint&&n._transitionablePaint._values){const l=n._transitionablePaint._values["line-emissive-strength"];if(l&&l.value&&l.value.isDataDriven())return void(this._hasDataDrivenEmissive=!0)}}this._hasDataDrivenEmissive=!1}hasDataDrivenEmissiveStrength(){return this._hasDataDrivenEmissive}get order(){return this.terrain?this._drapedFirstOrder:this._mergedOrder}_getOrder(t){return t?this.order:this._mergedOrder}isLayerDraped(t){return!!this.terrain&&t.isDraped(this.getLayerSourceCache(t))}_checkLoaded(){if(!this._loaded)throw new Error("Style is not done loading")}_checkLayer(t){const n=this.getOwnLayer(t);if(n)return n;this.fire(new u.A(new Error(`The layer '${t}' does not exist in the map's style.`)))}_checkSource(t){const n=this.getOwnSource(t);if(n)return n;this.fire(new u.A(new Error(`The source '${t}' does not exist in the map's style.`)))}handleIdle(){const t=this.map.painter;t&&(t.context.sweepPendingPrograms(),this._programPrecompiler&&this._programPrecompiler.processQueue(t,this))}handleContextLost(){this._programPrecompiler&&this._programPrecompiler.reset()}update(t){if(!this._loaded)return;this.ambientLight&&this.ambientLight.recalculate(t),this.directionalLight&&this.directionalLight.recalculate(t);const n=this.calculateLightsBrightness();t.brightness=n||0;let l=!1;n!==this._brightness&&(this._brightness=n,l=!0),t.worldview!==this._worldview&&(this._worldview=t.worldview,l=!0),l&&this.dispatcher.broadcast("upsertRenderParams",{brightness:this._brightness,worldview:this._worldview});const d=this._changes.isDirty();let p=!1;if(this._changes.isDirty()){const w=this._changes.getLayerUpdatesByScope();for(const S in w){const{updatedIds:A,removedIds:I}=w[S];(A||I)&&(this._updateWorkerLayers(S,A,I),p=!0)}this.updateSourceCaches(),this._updateTilesForChangedImages(),this.updateLayers(t),this.light&&this.light.updateTransitions(t),this.ambientLight&&this.ambientLight.updateTransitions(t),this.directionalLight&&this.directionalLight.updateTransitions(t),this.fog&&this.fog.updateTransitions(t),this.snow&&this.snow.updateTransitions(t),this.rain&&this.rain.updateTransitions(t),this._changes.reset()}const m={};for(const w in this._mergedSourceCaches){const S=this._mergedSourceCaches[w];m[w]=S.used,S.used=!1,S.tileCoverLift=0}const g={};for(const w of this._mergedOrder){const S=this._mergedLayers[w];if((S.visibility!=="none"||S.hasTransition())&&S.recalculate(t,this._availableImages),!S.isHidden(t.zoom)){S.mayUse("HD")&&(S.prepare(),hu()),S.mayUse("Standard")&&(S.prepare(),rf());const A=this.getLayerSourceCache(S);A&&(A.used=!0,A.tileCoverLift=Math.max(A.tileCoverLift,S.tileCoverLift()))}if(S.source){const A=u.y(S.source,S.scope),I=this._mergedHdRoadCoverageSourceCaches[A];I&&!I.used&&(I.used=!0)}if(S.type==="fill-extrusion"){const A=u.y(S.source,S.scope);if(A in this._mergedFillExtrusionSourceCaches){const I=S.layout&&S.layout.get("source-max-zoom");if(I!=null){const M=g[A];g[A]=M==null?I:Math.min(M,I)}}}}if(this._programPrecompiler&&this._programPrecompiler.needsBuild()){const w=this._mergedOrder.map(S=>this._mergedLayers[S]);this._programPrecompiler.buildQueue(w,t,this)}for(const w in this._mergedFillExtrusionSourceCaches)this._mergedFillExtrusionSourceCaches[w].setMaxzoomOverride(g[w]!=null?g[w]:null);this.terrain&&p&&this.mergeLayers();const x=this.imageManager.getPendingImageProviders();for(const w of x)w.sourceCache.used=!0;for(const w in m){const S=this._mergedSourceCaches[w];m[w]!==S.used&&S.getSource().fire(new u.B("data",{sourceDataType:"visibility",dataType:"source",sourceId:S.getSource().id}))}this.light&&this.light.recalculate(t),this.terrain&&this.terrain.recalculate(t),this.fog&&this.fog.recalculate(t),this.snow&&this.snow.recalculate(t),this.rain&&this.rain.recalculate(t),this.z=t.zoom,this._markersNeedUpdate&&(this._updateMarkersOpacity(),this._markersNeedUpdate=!1),this.imageManager.clearUpdatedImages(this.scope),d&&this.fire(new u.B("data",{dataType:"style"}))}updateImageProviders(){const t=this.imageManager.getPendingImageProviders();for(const n of t){const l=n.resolvePendingRequests(),d=this.getFragmentStyle(n.scope);d&&d.addImages(l)}}_updateTilesForChangedImages(){const t={};for(const n in this._mergedSourceCaches){const l=this._mergedSourceCaches[n].getSource().scope;t[l]=t[l]||this._changes.getUpdatedImages(l),t[l].length!==0&&this._mergedSourceCaches[n].reloadTilesForDependencies(["icons","patterns"],t[l])}for(const n in t)this._changes.resetUpdatedImages(n)}_updateWorkerLayers(t,n,l){const d=this.getFragmentStyle(t);d&&this.dispatcher.broadcast("updateLayers",{layers:n?d._serializeLayers(n):[],scope:t,removedIds:l||[],options:d.options})}setState(t,n){if(this._checkLoaded(),Cl(this,Or(t)))return!1;(t=u.el(t)).layers=Ys(t.layers);const l=(function(m,g){if(!m)return[{command:xt.setStyle,args:[g]}];let x=[];try{if(!u.b7(m.version,g.version))return[{command:xt.setStyle,args:[g]}];if(u.b7(m.center,g.center)||x.push({command:xt.setCenter,args:[g.center]}),u.b7(m.zoom,g.zoom)||x.push({command:xt.setZoom,args:[g.zoom]}),u.b7(m.bearing,g.bearing)||x.push({command:xt.setBearing,args:[g.bearing]}),u.b7(m.pitch,g.pitch)||x.push({command:xt.setPitch,args:[g.pitch]}),u.b7(m.sprite,g.sprite)||x.push({command:xt.setSprite,args:[g.sprite]}),u.b7(m.glyphs,g.glyphs)||x.push({command:xt.setGlyphs,args:[g.glyphs]}),u.b7(m.imports,g.imports)||(function(M=[],D=[],L){D=D||[];const k=(M=M||[]).map(Tc),B=D.map(Tc),$=M.reduce(ns,{}),Z=D.reduce(ns,{}),G=k.slice();let te,ee,le,K;for(te=0,ee=0;te<k.length;te++)le=k[te],Object.hasOwn(Z,le)?ee++:(L.push({command:xt.removeImport,args:[le]}),G.splice(G.indexOf(le,ee),1));for(te=0,ee=0;te<B.length;te++)le=B[B.length-1-te],G[G.length-1-te]!==le&&(Object.hasOwn($,le)?(L.push({command:xt.removeImport,args:[le]}),G.splice(G.lastIndexOf(le,G.length-ee),1)):ee++,K=G[G.length-te],L.push({command:xt.addImport,args:[Z[le],K]}),G.splice(G.length-te,0,le));for(const Q of D){const ae=$[Q.id];ae&&(delete ae.data,u.b7(ae,Q)||L.push({command:xt.updateImport,args:[Q.id,Q]}))}})(m.imports,g.imports,x),u.b7(m.transition,g.transition)||x.push({command:xt.setTransition,args:[g.transition]}),u.b7(m.light,g.light)||x.push({command:xt.setLight,args:[g.light]}),u.b7(m.fog,g.fog)||x.push({command:xt.setFog,args:[g.fog]}),u.b7(m.snow,g.snow)||x.push({command:xt.setSnow,args:[g.snow]}),u.b7(m.rain,g.rain)||x.push({command:xt.setRain,args:[g.rain]}),u.b7(m.projection,g.projection)||x.push({command:xt.setProjection,args:[g.projection]}),u.b7(m.lights,g.lights)||x.push({command:xt.setLights,args:[g.lights]}),u.b7(m.camera,g.camera)||x.push({command:xt.setCamera,args:[g.camera]}),u.b7(m.iconsets,g.iconsets)||(function(M,D,L){let k;for(k in D=D||{},M=M||{})Object.hasOwn(M,k)&&(Object.hasOwn(D,k)||L.push({command:xt.removeIconset,args:[k]}));for(k in D){if(!Object.hasOwn(D,k))continue;const B=D[k];Object.hasOwn(M,k)?u.b7(M[k],B)||(L.push({command:xt.removeIconset,args:[k]}),L.push({command:xt.addIconset,args:[k,B]})):L.push({command:xt.addIconset,args:[k,B]})}})(m.iconsets,g.iconsets,x),!u.b7(m["color-theme"],g["color-theme"]))return[{command:xt.setStyle,args:[g]}];const w={},S=[];(function(M,D,L,k){let B;for(B in D=D||{},M=M||{})Object.hasOwn(M,B)&&(Object.hasOwn(D,B)||Dh(B,L,k));for(B in D){if(!Object.hasOwn(D,B))continue;const $=D[B];Object.hasOwn(M,B)?u.b7(M[B],$)||(M[B].type==="geojson"&&$.type==="geojson"&&Qm(M,D,B)?L.push({command:xt.setGeoJSONSourceData,args:[B,$.data]}):Jm(B,D,L,k)):pu(B,D,L)}})(m.sources,g.sources,S,w);const A=[];m.layers&&m.layers.forEach(M=>{M.source&&w[M.source]?x.push({command:xt.removeLayer,args:[M.id]}):A.push(M)});let I=m.terrain;I&&w[I.source]&&(x.push({command:xt.setTerrain,args:[void 0]}),I=void 0),x=x.concat(S),u.b7(I,g.terrain)||x.push({command:xt.setTerrain,args:[g.terrain]}),(function(M,D,L){D=D||[];const k=(M=M||[]).map(Tc),B=D.map(Tc),$=M.reduce(ns,{}),Z=D.reduce(ns,{}),G=k.slice(),te=Object.create(null);let ee,le,K,Q,ae,de,fe;for(ee=0,le=0;ee<k.length;ee++)K=k[ee],Object.hasOwn(Z,K)?le++:(L.push({command:xt.removeLayer,args:[K]}),G.splice(G.indexOf(K,le),1));for(ee=0,le=0;ee<B.length;ee++)K=B[B.length-1-ee],G[G.length-1-ee]!==K&&(Object.hasOwn($,K)?(L.push({command:xt.removeLayer,args:[K]}),G.splice(G.lastIndexOf(K,G.length-le),1)):le++,de=G[G.length-ee],L.push({command:xt.addLayer,args:[Z[K],de]}),G.splice(G.length-ee,0,K),te[K]=!0);for(ee=0;ee<B.length;ee++)if(K=B[ee],Q=$[K],ae=Z[K],!te[K]&&!u.b7(Q,ae))if(u.b7(Q.source,ae.source)&&u.b7(Q["source-layer"],ae["source-layer"])&&u.b7(Q.type,ae.type)){for(fe in mu(Q.layout,ae.layout,L,K,null,xt.setLayoutProperty),mu(Q.paint,ae.paint,L,K,null,xt.setPaintProperty),u.b7(Q.slot,ae.slot)||L.push({command:xt.setSlot,args:[K,ae.slot]}),u.b7(Q.filter,ae.filter)||L.push({command:xt.setFilter,args:[K,ae.filter]}),u.b7(Q.minzoom,ae.minzoom)&&u.b7(Q.maxzoom,ae.maxzoom)||L.push({command:xt.setLayerZoomRange,args:[K,ae.minzoom,ae.maxzoom]}),Q)Object.hasOwn(Q,fe)&&fe!=="layout"&&fe!=="paint"&&fe!=="filter"&&fe!=="metadata"&&fe!=="minzoom"&&fe!=="maxzoom"&&fe!=="slot"&&(fe.indexOf("paint.")===0?mu(Q[fe],ae[fe],L,K,fe.slice(6),xt.setPaintProperty):u.b7(Q[fe],ae[fe])||L.push({command:xt.setLayerProperty,args:[K,fe,ae[fe]]}));for(fe in ae)Object.hasOwn(ae,fe)&&!Object.hasOwn(Q,fe)&&fe!=="layout"&&fe!=="paint"&&fe!=="filter"&&fe!=="metadata"&&fe!=="minzoom"&&fe!=="maxzoom"&&fe!=="slot"&&(fe.indexOf("paint.")===0?mu(Q[fe],ae[fe],L,K,fe.slice(6),xt.setPaintProperty):u.b7(Q[fe],ae[fe])||L.push({command:xt.setLayerProperty,args:[K,fe,ae[fe]]}))}else L.push({command:xt.removeLayer,args:[K]}),de=G[G.lastIndexOf(K)+1],L.push({command:xt.addLayer,args:[ae,de]})})(A,g.layers,x)}catch(w){console.warn("Unable to compute style diff:",w),x=[{command:xt.setStyle,args:[g]}]}return x})(this.serialize(),t).filter(m=>!(m.command in sy));if(l.length===0)return!1;const d=l.filter(m=>!(m.command in vu));if(d.length>0)throw new Error(`Unimplemented: ${d.map(m=>m.command).join(", ")}.`);const p=[];return l.forEach(m=>{p.push(this[m.command](...m.args))}),n&&Promise.all(p).then(n).catch(n),this.stylesheet=t,this.mergeAll(),this.dispatcher.broadcast("setLayers",{layers:this._serializeLayers(this._order),scope:this.scope,options:this.options}),!0}_updateWorkerImages(t=!1){this._availableImages=this.imageManager.listImages(this.scope);const n={scope:this.scope,images:this._availableImages};t&&(n.isSpriteLoaded=!0),this.dispatcher.broadcast("setImages",n)}_updateWorkerModels(){this._availableModels=this.modelManager.getModelURIs(this.scope),this.dispatcher.broadcast("setModels",{scope:this.scope,models:this._availableModels})}addImages(t,n){if(t.size===0)return n&&this.dispatcher.broadcast("spriteLoaded",{scope:this.scope}),this;for(const[l,d]of t.entries()){if(this.getImage(l))return this.fire(new u.A(new Error(`An image with the name "${l.name}" already exists.`)));this.imageManager.addImage(l,this.scope,d),this._changes.updateImage(l,this.scope)}return this._updateWorkerImages(n),this.fire(new u.B("data",{dataType:"style"})),this}addImage(t,n){return this.getImage(t)?this.fire(new u.A(new Error(`An image with the name "${t.name}" already exists.`))):(this.imageManager.addImage(t,this.scope,n),this._changes.updateImage(t,this.scope),this._updateWorkerImages(),this.fire(new u.B("data",{dataType:"style"})),this)}updateImage(t,n,l=!1){this.imageManager.updateImage(t,this.scope,n),l&&(this._changes.updateImage(t,this.scope),this._updateWorkerImages(),this.fire(new u.B("data",{dataType:"style"})))}getImage(t){return this.imageManager.getImage(t,this.scope)}removeImage(t){return this.getImage(t)?(this.imageManager.removeImage(t,this.scope),this._changes.updateImage(t,this.scope),this._updateWorkerImages(),this.fire(new u.B("data",{dataType:"style"})),this):this.fire(new u.A(new Error("No image with this name exists.")))}listImages(){return this._checkLoaded(),this._availableImages.slice()}getActualScope(){return this._importedAsBasemap?"basemap":this.scope}addModelURLs(t){return this.modelManager.addModelURLs(t,this.getActualScope()),this._updateWorkerModels(),this.fire(new u.B("data",{dataType:"style"})),this}addModel(t,n,l={}){return this._checkLoaded(),this._validate(om,`models.${t}`,n,null,l)||(this.modelManager.addModel(t,n,this.getActualScope()),this.fire(new u.B("data",{dataType:"style"}))),this}hasModel(t){return this.modelManager.hasModel(t,this.getActualScope())}removeModel(t){return this.hasModel(t)?(this.modelManager.removeModel(t,this.getActualScope(),!1,!0),this.fire(new u.B("data",{dataType:"style"})),this):this.fire(new u.A(new Error("No model with this ID exists.")))}listModels(){return this._checkLoaded(),this.modelManager.listModels(this.getActualScope())}addSource(t,n,l={}){if(this._checkLoaded(),this.getOwnSource(t)!==void 0)throw new Error(`There is already a source with ID "${t}".`);if(!n.type)throw new Error(`The type property must be defined, but only the following properties were given: ${Object.keys(n).join(", ")}.`);if(["vector","raster","geojson","video","image"].includes(n.type)&&this._validate(ll,`sources.${t}`,n,null,l))return;this.map&&this.map._collectResourceTiming&&(n.collectResourceTiming=!0);const d=Ph(t,n,this.dispatcher,this);d.scope=this.scope,d.setEventedParent(this,()=>({isSourceLoaded:this._isSourceCacheLoaded(d.id),source:d.serialize(),sourceId:d.id}));const p=m=>{const g=(m===u.dA.Symbol?"symbol:":m===u.dA.FillExtrusion?"fill-extrusion:":"other:")+d.id,x=u.y(g,this.scope),w=this._sourceCaches[g]=new $n(x,d,m);m===u.dA.Symbol?this._symbolSourceCaches[d.id]=w:m===u.dA.FillExtrusion?this._fillExtrusionSourceCaches[d.id]=w:this._otherSourceCaches[d.id]=w,w.onAdd(this.map)};p(u.dA.Other),n.type!=="vector"&&n.type!=="geojson"||(p(u.dA.Symbol),n.type==="vector"&&p(u.dA.FillExtrusion)),d.onAdd&&d.onAdd(this.map),l.isInitialLoad||(this.mergeSources(),this._changes.setDirty())}removeSource(t){this._checkLoaded();const n=this.getOwnSource(t);if(!n)throw new Error("There is no source with this ID");for(const d in this._layers)if(this._layers[d].source===t)return this.fire(new u.A(new Error(`Source "${t}" cannot be removed while layer "${d}" is using it.`)));if(this.terrain&&this.terrain.scope===this.scope&&this.terrain.get().source===t)return this.fire(new u.A(new Error(`Source "${t}" cannot be removed while terrain is using it.`)));if(this.stylesheet.iconsets){const d=Object.entries(this.stylesheet.iconsets).find(([p,m])=>m.type==="source"&&m.source===t);if(d)return this.fire(new u.A(new Error(`Source "${t}" cannot be removed while iconset "${d[0]}" is using it.`)))}const l=this.getOwnSourceCaches(t);for(const d of l){const p=u.dD(d.id);delete this._sourceCaches[p],this._changes.discardSourceCacheUpdate(d.id),d.fire(new u.B("data",{sourceDataType:"metadata",dataType:"source",sourceId:d.getSource().id})),d.setEventedParent(null),d.clearTiles()}return delete this._otherSourceCaches[t],delete this._symbolSourceCaches[t],delete this._fillExtrusionSourceCaches[t],this._hdCoverage&&delete this._hdCoverage.coverageSourceCaches[t],this._hdElevation&&delete this._hdElevation.elevationSourceCaches[u.y(t,this.scope)],this.mergeSources(),n.setEventedParent(null),n.onRemove&&n.onRemove(this.map),this._changes.setDirty(),this}setGeoJSONSourceData(t,n){this._checkLoaded(),this.getOwnSource(t).setData(n),this._changes.setDirty()}getOwnSource(t){const n=this.getOwnSourceCache(t);return n&&n.getSource()}getOwnSources(){const t=[];for(const n in this._otherSourceCaches){const l=this.getOwnSourceCache(n);l&&t.push(l.getSource())}return t}areTilesLoaded(){const t=this._mergedSourceCaches;for(const n in t){const l=t[n]._tiles;for(const d in l){const p=l[d];if(p.state!=="loaded"&&p.state!=="errored")return!1}}return!0}setLights(t){if(this._checkLoaded(),this._programPrecompiler&&this._programPrecompiler.reset(),!t)return delete this.ambientLight,void delete this.directionalLight;const n=this._getTransitionParameters();for(const p of t){if(this._validate(Qp,"lights",p))return;switch(p.type){case"ambient":if(this.ambientLight){const m=this.ambientLight;m.set(p),m.updateTransitions(n)}else this.ambientLight=new po(p,Ud(),this.scope,this.options);break;case"directional":if(this.directionalLight){const m=this.directionalLight;m.set(p),m.updateTransitions(n)}else this.directionalLight=new po(p,vt(),this.scope,this.options)}}const l=Object.assign(n,{worldview:this.map.getWorldview()}),d=new u.aa(this.z||0,l);this.ambientLight&&this.ambientLight.recalculate(d),this.directionalLight&&this.directionalLight.recalculate(d),this._brightness=this.calculateLightsBrightness(),this.dispatcher.broadcast("upsertRenderParams",{brightness:this._brightness})}calculateLightsBrightness(){const t=this.directionalLight,n=this.ambientLight;if(!t||!n)return;const l=I=>.2126*(I[0]<=.03928?I[0]/12.92:Math.pow((I[0]+.055)/1.055,2.4))+.7152*(I[1]<=.03928?I[1]/12.92:Math.pow((I[1]+.055)/1.055,2.4))+.0722*(I[2]<=.03928?I[2]/12.92:Math.pow((I[2]+.055)/1.055,2.4)),d=t.properties.get("color").toNonPremultipliedRenderColor(null).toArray01(),p=t.properties.get("intensity"),m=t.properties.get("direction"),g=1-u.c5(m.x,m.y,m.z)[2]/90,x=l(d)*p*g,w=n.properties.get("color").toNonPremultipliedRenderColor(null).toArray01(),S=n.properties.get("intensity"),A=l(w)*S;return Number(((x+A)/2).toFixed(6))}getBrightness(){return this._brightness}getLights(){if(!this.enable3dLights())return null;const t=[];return this.directionalLight&&t.push(this.directionalLight.get()),this.ambientLight&&t.push(this.ambientLight.get()),t}enable3dLights(){return!!this.ambientLight&&!!this.directionalLight}getFragmentStyle(t){if(t==null||t===""&&this.isRootStyle())return this;if(u.em(t)){const n=u.en(t),l=this.fragments.find(({id:p})=>p===n);if(!l)return;const d=u.dD(t);return l.style.getFragmentStyle(d)}{const n=this.fragments.find(({id:l})=>l===t);return n?n.style:void 0}}setFeaturesetSelectors(t){if(!t)return;const n=(l,d="")=>`${l}::${d}`;this._featuresetSelectors={};for(const l in t){const d={},p=this._featuresetSelectors[l]=[];for(const m of t[l].selectors){if(m.featureNamespace){const x=this.getOwnLayer(m.layer);if(!x){u.w(`Layer is undefined for selector: ${m.layer}`);continue}const w=n(x.source,x.sourceLayer);if(w in d&&d[w]!==m.featureNamespace){u.w(`"featureNamespace ${m.featureNamespace} of featureset ${l}'s selector is not associated to the same source, skip this selector`);continue}d[w]=m.featureNamespace}let g;if(m.properties)for(const x in m.properties){const w=u.n(m.properties[x]);w.result==="success"&&(g=g||{},g[x]=w.value)}p.push({layerId:m.layer,namespace:m.featureNamespace,properties:g,uniqueFeatureID:m._uniqueFeatureID})}}}getFeaturesetDescriptors(t){const n=this.getFragmentStyle(t);if(!n||!n.stylesheet.featuresets)return[];const l=[];for(const d in n.stylesheet.featuresets)l.push({featuresetId:d,importId:n.scope?n.scope:void 0});return l}getFeaturesetLayers(t,n){const l=this.getFragmentStyle(n),d=l.stylesheet.featuresets;if(!d||!d[t])return this.fire(new u.A(new Error(`The featureset '${t}' does not exist in the map's style and cannot be queried.`))),[];const p=[];for(const m of d[t].selectors){const g=l.getOwnLayer(m.layer);g&&p.push(g)}return p}getConfigProperty(t,n){const l=this.getFragmentStyle(t);if(!l)return null;const d=u.y(n,l.scope),p=l.options.get(d),m=p?p.value||p.default:null;return m?m.serialize():null}isIndoorEnabled(){return this._indoorEnabled}getIndoorSourceLayers(t,n){const l=u.y(t,n);return this._mergedIndoor[l]}setIndoorData(t,n){this.indoorManager&&this.indoorManager.setIndoorData(n)}updateIndoorDependentLayers(){this._updateLayers(this._dependentLayerIds(t=>t.isIndoorDependent)),this.map._styleDirty=!0,this.map.triggerRepaint()}setConfigProperty(t,n,l){const d=this.getFragmentStyle(t);if(!d)return;const p=d.stylesheet.schema;if(!p||!p[n])return;const m=xu(p[n],l);if(m.result!=="success")return void Cl(this,m.value);const g=m.value.expression,x=u.y(n,d.scope),w=d.options.get(x);if(!w)return;let S;const{minValue:A,maxValue:I,stepValue:M,type:D,values:L}=p[n],k=xu(p[n],p[n].default);k.result==="success"&&(S=k.value.expression),S?(this.options.set(x,{...w,value:g,default:S,minValue:A,maxValue:I,stepValue:M,type:D,values:L}),this.updateConfigDependencies(n)):this.fire(new u.A(new Error(`No schema defined for the config option "${n}" in the "${t}" fragment.`)))}getConfig(t){const n=this.getFragmentStyle(t);if(!n)return null;const l=n.stylesheet.schema;if(!l)return null;const d={};for(const p in l){const m=u.y(p,n.scope),g=n.options.get(m),x=g?g.value||g.default:null;d[p]=x?x.serialize():null}return d}setConfig(t,n){const l=this.getFragmentStyle(t);l&&(l.updateConfig(n,l.stylesheet.schema),this.updateConfigDependencies())}getSchema(t){const n=this.getFragmentStyle(t);return n?n.stylesheet.schema:null}setSchema(t,n){const l=this.getFragmentStyle(t);l&&(l.stylesheet.schema=n,l.updateConfig(l._config,n),this.updateConfigDependencies())}updateConfig(t,n){if(this._config=t,t||n)if(n)for(const l in n){let d,p;const m=xu(n[l],n[l].default);if(m.result==="success"&&(d=m.value.expression),t&&t[l]!==void 0){const I=xu(n[l],t[l]);I.result==="success"&&(p=I.value.expression)}const{minValue:g,maxValue:x,stepValue:w,type:S,values:A}=n[l];if(d){const I=u.y(l,this.scope);this.options.set(I,{default:d,value:p,minValue:g,maxValue:x,stepValue:w,type:S,values:A})}else this.fire(new u.A(new Error(`No schema defined for config option "${l}".`)))}else this.fire(new u.A(new Error("Attempting to set config for a style without schema.")))}_updateLayers(t){for(const n of t){const l=this.getLayer(n);l&&(l.possiblyEvaluateVisibility(),this._updateLayer(l),this._changes.setDirty())}}_dependentLayerIds(t){const n=[];for(const[l,d]of this._layerExpressionDependencies)t(d)&&n.push(l);return n}updateConfigDependencies(t){this._updateLayers(this._dependentLayerIds(n=>t?n.hasConfigDependency(t):n.isConfigDependent)),this.ambientLight&&this.ambientLight.updateConfig(this.options),this.directionalLight&&this.directionalLight.updateConfig(this.options),this.fog&&this.fog.updateConfig(this.options),this.snow&&this.snow.updateConfig(this.options),this.rain&&this.rain.updateConfig(this.options),this.forEachFragmentStyle(n=>{const l=n._styleColorTheme.colorThemeOverride?n._styleColorTheme.colorThemeOverride:n._styleColorTheme.colorTheme;if(l){const d=n._evaluateColorThemeData(l);(!n._styleColorTheme.lut&&d!==""||n._styleColorTheme.lut&&d!==n._styleColorTheme.lut.data)&&n.setColorTheme(l)}}),this._updateIndoorEnabled(),this._changes.setDirty()}addLayer(t,n,l={}){this._checkLoaded();const d=t.id;if(this._layers[d])return void this.fire(new u.A(new Error(`Layer with i
3396d "${d}" already exists on this map`)));let p;if(t.type==="custom"){if(Cl(this,u.eo(t)))return;p=u.ep(t,this.scope,this._styleColorTheme.lut,this.options)}else{if(typeof t.source=="object"&&(this.addSource(d,t.source),t=u.el(t),t=Object.assign(t,{source:d})),this._validate(rm,`layers.${d}`,t,{arrayIndex:-1},l))return;p=u.ep(t,this.scope,this._styleColorTheme.lut,this.options),this._validateLayer(p),p.setEventedParent(this,{layer:{id:d}})}this._layerExpressionDependencies.set(p.fqid,new Co(p));let m=this._order.length;if(n){const S=this._order.indexOf(n);if(S===-1)return void this.fire(new u.A(new Error(`Layer with id "${n}" does not exist on this map.`)));p.slot&&p.slot!==this._layers[n].slot?u.w(`Layer with id "${n}" has a different slot. Layers can only be rearranged within the same slot.`):m=S}this._order.splice(m,0,d),this._handleLayerOrderChange(),this._layers[d]=p;const g=this.getOwnLayerSourceCache(p),x=!!this.directionalLight&&this.directionalLight.shadowsEnabled();g&&p.canCastShadows()&&x&&(g.castsShadows=!0);const w=this._changes.getRemovedLayer(p);if(w&&p.source&&g&&p.type!=="custom"){this._changes.discardLayerRemoval(p);const S=u.y(p.source,p.scope);w.type!==p.type?this._changes.updateSourceCache(S,"clear"):(this._changes.updateSourceCache(S,"reload"),g.pause())}this._updateLayer(p),p.onAdd&&p.onAdd(this.map),p.scope=this.scope,this.mergeLayers()}moveLayer(t,n){this._checkLoaded();const l=this._checkLayer(t);if(!l||t===n)return;const d=this._order.indexOf(t);this._order.splice(d,1);let p=this._order.length;if(n){const m=this._order.indexOf(n);
vendor: 24,404 bytes, line 3396
3396if(m===-1)return void this.fire(new u.A(new Error(`Layer with id "${n}" does not exist on this map.`)));l.slot&&l.slot!==this._layers[n].slot?u.w(`Layer with id "${n}" has a different slot. Layers can only be rearranged within the same slot.`):p=m}this._order.splice(p,0,t),this._changes.setDirty(),this._handleLayerOrderChange(),this.mergeLayers()}removeLayer(t){this._checkLoaded();const n=this._checkLayer(t);if(!n)return;n.setEventedParent(null);const l=this._order.indexOf(t);this._order.splice(l,1),delete this._layers[t],this._changes.setDirty(),this._handleLayerOrderChange(),this._layerExpressionDependencies.delete(n.fqid),this._changes.removeLayer(n);const d=this.getOwnLayerSourceCache(n);if(d&&d.castsShadows){let p=!1;for(const m in this._layers)if(this._layers[m].source===n.source&&this._layers[m].canCastShadows()){p=!0;break}d.castsShadows=p}n.onRemove&&n.onRemove(this.map),this.mergeLayers()}getOwnLayer(t){return this._layers[t]}hasLayer(t){return t in this._mergedLayers}hasLayerType(t){for(const n in this._layers)if(this._layers[n].type===t)return!0;return!1}setLayerZoomRange(t,n,l){this._checkLoaded();const d=this._checkLayer(t);d&&(d.minzoom===n&&d.maxzoom===l||(n!=null&&(d.minzoom=n),l!=null&&(d.maxzoom=l),this._updateLayer(d)))}getSlots(){return this._checkLoaded(),this._mergedSlots}setSlot(t,n){this._checkLoaded();const l=this._checkLayer(t);l&&l.slot!==n&&(l.slot=n,this._updateLayer(l))}setFilter(t,n,l={}){this._checkLoaded();const d=this._checkLayer(t);if(!d||u.b7(d.filter,n))return;const p=this._layerExpressionDependencies.get(d.fqid);if(n==null)return d.filter=void 0,p&&p.invalidateFilter(),void this._updateLayer(d);this._validate(jc,`layers.${d.id}.filter`,n,{layerType:d.type},l)||(d.filter=u.el(n),p&&p.invalidateFilter(),this._updateLayer(d))}getFilter(t){const n=this._checkLayer(t);if(n)return u.el(n.filter)}setLayoutProperty(t,n,l,d={}){this._checkLoaded();const p=this._checkLayer(t);if(p&&!u.b7(p.getLayoutProperty(n),l)){if(l!=null&&(!d||d.validate!==!1)&&Cl(p,la.call(Or,{key:`layers.${t}.layout.${n}`,layerType:p.type,objectKey:n,value:l,styleSpec:u.m,style:{glyphs:!0,sprite:!0}})))return;p.setLayoutProperty(n,l),this._updateLayer(p)}}getLayerProperty(t,n){const l=this._checkLayer(t);if(l){switch(n){case"minzoom":return l.minzoom;case"maxzoom":return l.maxzoom;case"filter":return this.getFilter(t);case"slot":return l.slot;case"appearances":return l.getAppearances().map(d=>d.serialize())}return l.isPaintProperty(n)?this.getPaintProperty(t,n):this.getLayoutProperty(t,n)}}setLayerProperty(t,n,l,d={}){this._checkLoaded();const p=this._checkLayer(t);if(p){switch(n){case"appearances":return p.setAppearances(l),void this._updateLayer(p);case"minzoom":return this.setLayerZoomRange(t,l);case"maxzoom":return this.setLayerZoomRange(t,null,l);case"filter":return this.setFilter(t,l,d);case"slot":return this.setSlot(t,l)}p.isPaintProperty(n)?this.setPaintProperty(t,n,l,d):this.setLayoutProperty(t,n,l,d)}}getLayoutProperty(t,n){const l=this._checkLayer(t);if(l)return l.getLayoutProperty(n)}setPaintProperty(t,n,l,d={}){this._checkLoaded();const p=this._checkLayer(t);p&&(u.b7(p.getPaintProperty(n),l)||(l==null||d&&d.validate===!1||!Cl(p,nm.call(Or,{key:`layers.${t}.paint.${n}`,layerType:p.type,objectKey:n,value:l,styleSpec:u.m})))&&(p.setPaintProperty(n,l)&&this._updateLayer(p),this._changes.updatePaintProperties(p)))}getPaintProperty(t,n){const l=this._checkLayer(t);if(l)return l.getPaintProperty(n)}setFeatureState(t,n){if(this._checkLoaded(),"target"in t){if("featuresetId"in t.target){const{featuresetId:x,importId:w}=t.target,S=this.getFragmentStyle(w),A=S.getFeaturesetLayers(x);for(const{source:I,sourceLayer:M}of A)S.setFeatureState({id:t.id,source:I,sourceLayer:M},n)}else if("layerId"in t.target){const{layerId:x}=t.target,w=this.getLayer(x);if(!w)return;const S=this.getFragmentStyle(w.scope);if(!S)return;S.setFeatureState({id:t.id,source:w.source,sourceLayer:w.sourceLayer},n)}return}const l=t.source,d=t.sourceLayer,p=this._checkSource(l);if(!p)return;const m=p.type;if(m==="geojson"&&d)return void this.fire(new u.A(new Error("GeoJSON sources cannot have a sourceLayer parameter.")));if(m==="vector"&&!d)return void this.fire(new u.A(new Error("The sourceLayer parameter must be provided for vector source types.")));t.id===void 0&&this.fire(new u.A(new Error("The feature id parameter must be provided.")));const g=this.getOwnSourceCaches(l);for(const x of g)x.setFeatureState(d,t.id,n)}removeFeatureState(t,n){if(this._checkLoaded(),"target"in t){if("featuresetId"in t.target){const{featuresetId:x,importId:w}=t.target,S=this.getFragmentStyle(w),A=S.getFeaturesetLayers(x);for(const{source:I,sourceLayer:M}of A)S.removeFeatureState({id:t.id,source:I,sourceLayer:M},n)}else if("layerId"in t.target){const{layerId:x}=t.target,w=this.getLayer(x);if(!w)return;const S=this.getFragmentStyle(w.scope);if(!S)return;S.removeFeatureState({id:t.id,source:w.source,sourceLayer:w.sourceLayer},n)}return}const l=t.source,d=this._checkSource(l);if(!d)return;const p=d.type,m=p==="vector"?t.sourceLayer:void 0;if(p==="vector"&&!m)return void this.fire(new u.A(new Error("The sourceLayer parameter must be provided for vector source types.")));if(n&&typeof t.id!="string"&&typeof t.id!="number")return void this.fire(new u.A(new Error("A feature id is required to remove its specific state property.")));const g=this.getOwnSourceCaches(l);for(const x of g)x.removeFeatureState(m,t.id,n)}getFeatureState(t){if(this._checkLoaded(),"target"in t){let p;if("featuresetId"in t.target){const{featuresetId:m,importId:g}=t.target,x=this.getFragmentStyle(g),w=x.getFeaturesetLayers(m);for(const{source:S,sourceLayer:A}of w){const I=x.getFeatureState({id:t.id,source:S,sourceLayer:A});if(I&&!p)p=I;else if(!u.b7(p,I))return void this.fire(new u.A(new Error("The same feature id exists in multiple sources in the featureset, but their feature states are not consistent through the sources.")))}}else if("layerId"in t.target){const{layerId:m}=t.target,g=this.getLayer(m);if(!g)return;const x=this.getFragmentStyle(g.scope);if(!x)return;p=x.getFeatureState({id:t.id,source:g.source,sourceLayer:g.sourceLayer})}return p}const n=t.source,l=t.sourceLayer,d=this._checkSource(n);if(d){if(d.type!=="vector"||l)return t.id===void 0&&this.fire(new u.A(new Error("The feature id parameter must be provided."))),this.getOwnSourceCaches(n)[0].getFeatureState(l,t.id);this.fire(new u.A(new Error("The sourceLayer parameter must be provided for vector source types.")))}}setTransition(t){return this.stylesheet.transition={...this.stylesheet.transition,...t},this.transition=this.stylesheet.transition,this}getTransition(){return{...this.stylesheet.transition}}setWorldview(t){t!==this._worldview&&(this._worldview=t,this.dispatcher.broadcast("upsertRenderParams",{worldview:this._worldview}),this.reloadSources())}serialize(){this._checkLoaded();const t=this.getTerrain(),n=t&&this.terrain&&this.terrain.scope===this.scope?t:this.stylesheet.terrain;return u.eq({version:this.stylesheet.version,name:this.stylesheet.name,metadata:this.stylesheet.metadata,fragment:this.stylesheet.fragment,iconsets:this.stylesheet.iconsets,featuresets:this.stylesheet.featuresets,imports:this._serializeImports(),schema:this.stylesheet.schema,camera:this.stylesheet.camera,light:this.stylesheet.light,lights:this.stylesheet.lights,terrain:n,fog:this.stylesheet.fog,snow:this.stylesheet.snow,rain:this.stylesheet.rain,indoor:this.stylesheet.indoor,center:this.stylesheet.center,"color-theme":this.stylesheet["color-theme"],zoom:this.stylesheet.zoom,bearing:this.stylesheet.bearing,pitch:this.stylesheet.pitch,sprite:this.stylesheet.sprite,glyphs:this.stylesheet.glyphs,transition:this.stylesheet.transition,projection:this.stylesheet.projection,sources:this._serializeSources(),layers:this._serializeLayers(this._order)},l=>l!==void 0)}_updateFilteredLayers(t){for(const n of Object.values(this._mergedLayers))t(n)&&this._updateLayer(n)}_updateLayer(t){this._changes.updateLayer(t);const n=this.getLayerSourceCache(t),l=u.y(t.source,t.scope),d=this._changes.getUpdatedSourceCaches();t.source&&!d[l]&&n&&n.getSource().type!=="raster"&&(this._changes.updateSourceCache(l,"reload"),n.pause()),t.invalidateCompiledFilter()}_flattenAndSortRenderedFeatures(t){const n=g=>this._mergedLayers[g].is3D(!!this.terrain),l=this.order,d={},p=[];for(let g=l.length-1;g>=0;g--){const x=l[g];if(n(x)){d[x]=g;for(const w of t){const S=w[x];if(S)for(const A of S)p.push(A)}}}p.sort((g,x)=>x.intersectionZ-g.intersectionZ);const m=[];for(let g=l.length-1;g>=0;g--){const x=l[g];if(n(x))for(let w=p.length-1;w>=0;w--){const S=p[w].feature;if(S.layer&&d[S.layer.id]<g)break;m.push(S),p.pop()}else for(const w of t){const S=w[x];if(S)for(const A of S)m.push(A.feature)}}return m}queryRasterValue(t,n,l){const d=this.getOwnSource(t);return d?d.type!=="raster-array"?(this.fire(new u.A(new Error('queryRasterValue support only "raster-array" sources.'))),Promise.resolve(null)):d.queryRasterArrayValue(n,l):(this.fire(new u.A(new Error(`Source with id "${t}" does not exist in the style.`))),Promise.resolve(null))}queryRenderedFeatures(t,n,l){let d;n&&!Array.isArray(n)&&n.filter&&(this._validate(jc,"queryRenderedFeatures.filter",n.filter,null,n),d=u.cV(n.filter));const p={},m=S=>{if(Sr.has(S.type))return;const A=this.getOwnLayerSourceCache(S),I=p[A.id]=p[A.id]||{sourceCache:A,layers:{},has3DLayers:!1};S.is3D(!!this.terrain)&&(I.has3DLayers=!0),I.layers[S.fqid]=I.layers[S.fqid]||{styleLayer:S,targets:[]},I.layers[S.fqid].targets.push({filter:d})};if(n&&n.layers){if(!Array.isArray(n.layers))return this.fire(new u.A(new Error("parameters.layers must be an Array."))),[];for(const S of n.layers){const A=this._layers[S];if(!A)return this.fire(new u.A(new Error(`The layer '${S}' does not exist in the map's style and cannot be queried for features.`))),[];m(A)}}else for(const S in this._layers)m(this._layers[S]);const g=this._queryRenderedFeatures(t,p,l),x=this._flattenAndSortRenderedFeatures(g),w=[];for(const S of x)u.dE(S.layer.id)===this.scope&&w.push(S);return w}queryRenderedFeatureset(t,n,l){let d;n&&!Array.isArray(n)&&n.filter&&(this._validate(jc,"queryRenderedFeatures.filter",n.filter,null,n),d=u.cV(n.filter));const p="mock",m=[];if(n&&n.target)m.push({...n,targetId:p,filter:d});else{const S=this.getFeaturesetDescriptors();for(const A of S)m.push({targetId:p,filter:d,target:A});for(const{style:A}of this.fragments){const I=A.getFeaturesetDescriptors();for(const M of I)m.push({targetId:p,filter:d,target:M})}}const g=this.queryRenderedTargets(t,m,l),x=[],w=new Set;for(const S of g)for(const A of S.variants[p])so(A,S,w)||x.push(new u.er(S,A));return x}queryRenderedTargets(t,n,l){const d={},p=(g,x,w,S)=>{const A=d[x.id]=d[x.id]||{sourceCache:x,layers:{},has3DLayers:!1};if(A.layers[g.fqid]=A.layers[g.fqid]||{styleLayer:g,targets:[]},g.is3D(!!this.terrain)&&(A.has3DLayers=!0),!S)return w.uniqueFeatureID=!1,void A.layers[g.fqid].targets.push(w);A.layers[g.fqid].targets.push({...w,namespace:S.namespace,properties:S.properties,uniqueFeatureID:S.uniqueFeatureID})};for(const g of n)if("featuresetId"in g.target){const{featuresetId:x,importId:w}=g.target,S=this.getFragmentStyle(w);if(!S||!S._featuresetSelectors)continue;const A=S._featuresetSelectors[x];if(!A){this.fire(new u.A(new Error(`The featureset '${x}' does not exist in the map's style and cannot be queried for features.`)));continue}for(const I of A){const M=S.getOwnLayer(I.layerId);M&&!Sr.has(M.type)&&p(M,S.getOwnLayerSourceCache(M),g,I)}}else if("layerId"in g.target){const{layerId:x}=g.target,w=this.getLayer(x);if(!w||Sr.has(w.type))continue;p(w,this.getLayerSourceCache(w),g)}const m=this._queryRenderedFeatures(t,d,l);return this._flattenAndSortRenderedFeatures(m)}_queryRenderedFeatures(t,n,l){const d=[],p=!!this.map._showQueryGeometry,m=du.createFromScreenPoints(t,l);for(const g in n){const x=Sf(m,n[g],this._availableImages,l,p,this.getActualScope());Object.keys(x).length&&d.push(x)}if(this.placement)for(const g in n){if(n[g].sourceCache._renderSourceType!==u.dA.Symbol)continue;const x=qn(m.screenGeometry,n[g],this._availableImages,this.placement.collisionIndex,this.placement.retainedQueryData,this.map.getWorldview());Object.keys(x).length&&d.push(x)}return d}querySourceFeatures(t,n){const l=n&&n.filter;l&&this._validate(jc,"querySourceFeatures.filter",l,null,n);let d=[];const p=this.getOwnSourceCaches(t);for(const m of p)d=d.concat(ja(m,n));return d}addSourceType(t,n,l){return go.getSourceType(t)?l(new Error(`A source type called "${t}" already exists.`)):(go.setSourceType(t,n),l(null,null))}getFlatLight(){return this.light.getLight()}setFlatLight(t,n,l={}){this._checkLoaded();const d=this.light.getLight();let p=!1;for(const g in t)if(!u.b7(t[g],d[g])){p=!0;break}if(!p)return;const m=this._getTransitionParameters();this.light.setLight(t,n,l),this.light.updateTransitions(m)}hasTerrain(){return!!this.terrain&&this.terrain.drapeRenderMode===1}getTerrain(){return this.hasTerrain()?this.terrain.get():null}setTerrainForDraping(){this.setTerrain({source:"",exaggeration:0},0)}checkCanvasFingerprintNoise(){this.disableElevatedTerrain===void 0&&(this.disableElevatedTerrain=u.r.hasCanvasFingerprintNoise(),this.disableElevatedTerrain&&u.w("Terrain and hillshade are disabled because of Canvas2D limitations when fingerprinting protection is enabled (e.g. in private browsing mode)."))}setTerrain(t,n=1){if(this._checkLoaded(),!t)return this.terrainSetForDrapingOnly()||(delete this.terrain,this.map.transform.projection.requiresDraping&&this.setTerrainForDraping()),n===0&&delete this.terrain,t===null?this.stylesheet.terrain=null:delete this.stylesheet.terrain,this._force3DLayerUpdate(),void(this._markersNeedUpdate=!0);this.checkCanvasFingerprintNoise();let l=t;const d=!("source"in t)||t.source==null;if(n===1){if(this.disableElevatedTerrain)return;if("source"in l&&typeof l.source=="object"){const g="terrain-dem-src";this.addSource(g,l.source),l=u.el(l),l=Object.assign(l,{source:g})}const p={...l},m={};if(this.terrain&&d){p.source=this.terrain.get().source;const g=this.terrain?this.getFragmentStyle(this.terrain.scope):null;g&&(m.style=g.serialize())}if(this._validate(em,"terrain",p,m))return}if(!this.terrain||this.terrain.scope!==this.scope&&!d||this.terrain&&n!==this.terrain.drapeRenderMode){if(!l)return;this._createTerrain(l,n),this.fire(new u.B("data",{dataType:"style"}))}else{const p=this.terrain,m=p.get();for(const g of Object.keys(u.m.terrain))!Object.hasOwn(l,g)&&u.m.terrain[g].default&&(l[g]=u.m.terrain[g].default);for(const g in t)if(!u.b7(t[g],m[g])){p.set(t,this.options),this.stylesheet.terrain=t;const x=this._getTransitionParameters({duration:0});p.updateTransitions(x),this.fire(new u.B("data",{dataType:"style"}));break}}this.mergeTerrain(),this.updateDrapeFirstLayers(),this._markersNeedUpdate=!0}_createFog(t){const n=this.fog=new Yl(t,this.map.transform,this.scope,this.options);this.stylesheet.fog=n.get();const l=this._getTransitionParameters({duration:0});n.updateTransitions(l)}_createSnow(t){const n=this.snow=new Yu(t,this.map.transform,this.scope,this.options);this.stylesheet.snow=n.get();const l=this._getTransitionParameters({duration:0});n.updateTransitions(l)}_createRain(t){const n=this.rain=new Ku(t,this.map.transform,this.scope,this.options);this.stylesheet.rain=n.get();const l=this._getTransitionParameters({duration:0});n.updateTransitions(l)}_updateMarkersOpacity(){this.map._markers.length!==0&&this.map._requestDomTask(()=>{for(const t of this.map._markers)t._evaluateOpacity()})}getFog(){return this.fog?this.fog.get():null}setFog(t){if(this._checkLoaded(),t)if(this.fog){const n=this.fog;if(!u.b7(n.get(),t)){n.set(t,this.options),this.stylesheet.fog=n.get();const l=this._getTransitionParameters({duration:0});n.updateTransitions(l)}}else this._createFog(t);else delete this.fog,delete this.stylesheet.fog;this._markersNeedUpdate=!0,this._programPrecompiler&&this._programPrecompiler.reset()}getSnow(){return this.snow?this.snow.get():null}setSnow(t){if(this._checkLoaded(),!t)return delete this.snow,void delete this.stylesheet.snow;if(this.snow){const n=this.snow;if(!u.b7(n.get(),t)){n.set(t,this.options),this.stylesheet.snow=n.get();const l=this._getTransitionParameters({duration:0});n.updateTransitions(l)}}else this._createSnow(t);this._markersNeedUpdate=!0}getRain(){return this.rain?this.rain.get():null}setRain(t){if(this._checkLoaded(),!t)return delete this.rain,void delete this.stylesheet.rain;if(this.rain){const n=this.rain;if(!u.b7(n.get(),t)){n.set(t,this.options),this.stylesheet.rain=n.get();const l=this._getTransitionParameters({duration:0});n.updateTransitions(l)}}else this._createRain(t);this._markersNeedUpdate=!0}_reloadColorTheme(){const t=()=>{for(const d in this._layers)this._layers[d].lut=this._styleColorTheme.lut;for(const d in this._sourceCaches)this._sourceCaches[d].clearTiles()},n=this._styleColorTheme.colorThemeOverride?this._styleColorTheme.colorThemeOverride:this._styleColorTheme.colorTheme;if(!n)return this._styleColorTheme.lut=null,void t();const l=this._evaluateColorThemeData(n);this._loadColorTheme(l).then(()=>{this.fire(new u.B("colorthemeset")),t()}).catch(d=>{u.w(`Couldn't set color theme: ${d}`)})}setColorTheme(t){this._checkLoaded(),this._styleColorTheme.colorThemeOverride&&u.w("Note: setColorTheme is called on a style with a color-theme override, the passed color-theme won't be visible."),this._styleColorTheme.colorTheme=t,this._reloadColorTheme()}setImportColorTheme(t,n){const l=this.getFragmentStyle(t);l&&(l._styleColorTheme.colorThemeOverride=n,l._reloadColorTheme())}_getTransitionParameters(t){return{now:u.r.now(),transition:Object.assign(this.transition,t)}}updateDrapeFirstLayers(){if(!this.terrain)return;const t=[],n=[];for(const l of this._mergedOrder)this.isLayerDraped(this._mergedLayers[l])?t.push(l):n.push(l);this._drapedFirstOrder=[],this._drapedFirstOrder.push(...t),this._drapedFirstOrder.push(...n)}_createTerrain(t,n){const l=this.terrain=new sm(t,n,this.scope,this.options,this.map.getWorldview());n===1&&(this.stylesheet.terrain=t),this.mergeTerrain(),this.updateDrapeFirstLayers(),this._force3DLayerUpdate();const d=this._getTransitionParameters({duration:0});l.updateTransitions(d)}_force3DLayerUpdate(){for(const t in this._layers){const n=this._layers[t];n.type==="fill-extrusion"&&this._updateLayer(n)}}_forceSymbolLayerUpdate(){for(const t in this._layers){const n=this._layers[t];n.type==="symbol"&&this._updateLayer(n)}}_validate(t,n,l,d,p={}){if(p&&p.validate===!1)return!1;const m={...this.serialize()};return Cl(this,t.call(Or,{key:n,style:m,value:l,styleSpec:u.m,...d}))}_remove(){this._programPrecompiler&&(this._programPrecompiler.reset(),this._programPrecompiler=null),this._request&&(this._request.cancel(),this._request=null),this._spriteRequest&&(this._spriteRequest.abort(),this._spriteRequest=null),u.es.off("pluginStateChange",this._rtlTextPluginCallback);for(const t in this._mergedLayers)this._mergedLayers[t].setEventedParent(null);for(const t in this._mergedSourceCaches){const n=this._mergedSourceCaches[t];n.clearTiles(),n.setEventedParent(null);const l=n.getSource();l&&l.onRemove&&l.onRemove(this.map)}this.imageManager.removeScope(this.scope),this.imageManager.imageAtlasCache.clear(),this.setEventedParent(null),delete this.fog,delete this.snow,delete this.rain,delete this.terrain,delete this.ambientLight,delete this.directionalLight,this.indoorManager&&this.indoorManager.destroy(),this.isRootStyle()&&(this.imageManager.setEventedParent(null),this.modelManager.setEventedParent(null),this.modelManager.destroy(),this.dispatcher.remove())}clearSource(t){const n=this.getSourceCaches(t);for(const l of n)l.clearTiles()}clearSources(){for(const t in this._mergedSourceCaches)this._mergedSourceCaches[t].clearTiles()}clearLayers(){for(const t in this._mergedLayers){const n=this._mergedLayers[t];n._clear&&n._clear()}}reloadSource(t){const n=this.getSourceCaches(t);for(const l of n)l.resume(),l.reload()}reloadSources(){for(const t of this.getSources())t.reload&&t.reload()}reloadModels(){this.modelManager.reloadModels(""),this.forEachFragmentStyle(t=>{t.modelManager.reloadModels(t.scope)})}updateSources(t){let n;this.directionalLight&&(n=Hs(this.directionalLight));const l=new Set,d=new Set,p=new Set;for(const m in this._mergedLayers){const g=this._mergedLayers[m];g.type==="building"?l.add(g.source):g.type==="raster"&&g.paint&&g.paint.get("raster-elevation-reference")==="ground"&&p.add(g.source),g.hasElevation()&&!d.has(g.source)&&d.add(g.source)}this.updateFrcCoverageFadeRange();for(const m in this._mergedSourceCaches){const g=this._mergedSourceCaches[m],x=d.has(g._source.id);g._isRasterElevatedOverTerrain=p.has(g._source.id),l.has(g._source.id)&&(g._source.reparseOverscaled=!1),g.update(t,void 0,void 0,n,x)}this.updateFrcCoverage(),this.updateElevationCoverage(),jt.markElevationIngestSourceCachesUsed&&jt.markElevationIngestSourceCachesUsed(this)}_reloadSources(){for(const t in this._sourceCaches){const n=this._sourceCaches[t];n.resume(),n.reload()}}updateFrcCoverageFadeRange(){this.map.painter&&jt.updateFrcCoverageFadeRange&&jt.updateFrcCoverageFadeRange(this,this.map.painter)}updateFrcCoverage(){this._hdCoverage&&jt.updateFrcCoverage&&jt.updateFrcCoverage(this,this._hdCoverage)}updateElevationCoverage(){this.isRootStyle()&&jt.setupAndUpdateElevationCoverage&&jt.setupAndUpdateElevationCoverage(this)}_handleLayerOrderChange(){this._requestFullLabelPlacement(),this.fire(new u.B("neworder"))}_requestFullLabelPlacement(){this.pauseablePlacement||(this.pauseablePlacement=new Pf),this.pauseablePlacement.requestFullPlacement()}_setLabelPlacementStale(){this.placement&&this.placement.setStale()}_updatePlacement(t,n,l,d,p,m){this.pauseablePlacement||(this.pauseablePlacement=new Pf);let g=!1,x=!1;const w={},S={};for(const k of this._mergedOrder){const B=this._mergedLayers[k];if(B.type!=="symbol")continue;const $=u.y(B.source,B.scope);let Z=w[$];if(!Z){const te=this.getLayerSourceCache(B);if(!te)continue;const ee=te.getRenderableIds(!0).map(le=>te.getTileByID(le));S[$]=ee.slice(),Z=w[$]=ee.sort((le,K)=>K.tileID.overscaledZ-le.tileID.overscaledZ||(le.tileID.isLessThan(K.tileID)?-1:1))}const G=this.crossTileSymbolIndex.addLayer(B,Z,t.center.lng,t.projection);g=g||G}this.crossTileSymbolIndex.pruneUnusedLayers(this._mergedOrder);const A=!!(this.placement&&!t.equals(this.placement.transform)),I=!!(this.placement&&(this.placement.lastReplacementSourceUpdateTime!==0&&!p||this.placement.lastReplacementSourceUpdateTime!==p.updateTime)),M=A||I||g,D=(M||this.pauseablePlacement.isStale())&&l===0,L=this.pauseablePlacement.isDone()&&!this.placement.stillRecent(u.r.now(),t.zoom)&&l!==0;if((this.pauseablePlacement.isFullPlacementRequested()||!this.pauseablePlacement.placement||D||L)&&(this.pauseablePlacement=this.pauseablePlacement.startNewPlacement(t,this._mergedOrder,n,l,d,this.placement,this.fog&&t.projection.supportsFog?this.fog.state:null,this._buildingIndex,m),this.map.painter)){const k=this.map.painter.maxFrontCutoffRawStart;if(k>0){const B=180*t.pitch/Math.PI;if(B>=15){const $=Math.min(1,Math.max(0,(B-15)/5)),Z=$*$*(3-2*$);this.pauseablePlacement.placement.frontCutoffStart=-.5*(1-Z)+k*Z}}}if(this.pauseablePlacement.isDone()?M&&l!==0&&this.pauseablePlacement.setStale():(this.pauseablePlacement.continuePlacement(this._mergedOrder,this._mergedLayers,w,S,this.map.painter.scaleFactor),this.pauseablePlacement.isDone()&&(this.placement=this.pauseablePlacement.commit(u.r.now()),x=!0),g&&this.pauseablePlacement.setStale()),x||g){this._buildingIndex.onNewFrame(t.zoom);for(let k=0;k<this._mergedOrder.length;k++){const B=this._mergedLayers[this._mergedOrder[k]];if(B.type!=="symbol"||B.visibility==="none")continue;const $=this.isLayerClipped(B);this.placement.updateLayerOpacities(B,w[u.y(B.source,B.scope)],k,$?p:null)}}return!this.pauseablePlacement.isDone()||this.placement.isStale()||this.placement.hasTransitions(u.r.now())}_releaseSymbolFadeTiles(){for(const t in this._sourceCaches)this._sourceCaches[t].releaseSymbolFadeTiles()}addImport(t,n){if(this._checkLoaded(),new Set(["__proto__","constructor","prototype"]).has(t.id))return void this.fire(new u.A(new Error(`Import id can't be "${t.id}".`)));const l=this.stylesheet.imports=this.stylesheet.imports||[];if(l.findIndex(({id:p})=>p===t.id)!==-1)return void this.fire(new u.A(new Error(`Import with i
3396d '${t.id}' already exists in the map's style.`)));if(!n)return l.push(t),this._loadImports([t],!0);const d=l.findIndex(({id:p})=>p===n);return d===-1&&this.fire(new u.A(new Error(`Import with id "${n}" does not exist on this map.`))),this.stylesheet.imports=l.slice(0,d).concat(t).concat(l.slice(d)),this._loadImports([t],!0,n)}updateImport(t,n){this._checkLoaded();const l=this.stylesheet.imports||[],d=this.getImportIndex(t);return d===-1?this:typeof n=="string"?(this.setImportUrl(t,n),this):(n.url&&n.url!==l[d].url&&this.setImportUrl(t,n.url),u.b7(n.config,l[d].config)||this.setImportConfig(t,n.config,n.data.schema),u.b7(n.data,l[d].data)||this.setImportData(t,n.data),this)}moveImport(t,n){this._checkLoaded();let l=this.stylesheet.imports||[];const d=this.getImportIndex(t);if(d===-1)return this;const p=this.getImportIndex(n);if(p===-1)return this;const m=l[d],g=this.fragments[d];return l=l.filter(({id:x})=>x!==t),this.fragments=this.fragments.filter(({id:x})=>x!==t),this.stylesheet.imports=l.slice(0,p).concat(m).concat(l.slice(p)),this.fragments=this.fragments.slice(0,p).concat(g).concat(this.fragments.slice(p)),this.mergeLayers(),this}setImportUrl(t,n){this._checkLoaded();const l=this.stylesheet.imports||[],d=this.getImportIndex(t);if(d===-1)return this;l[d].url=n;const p=this.fragments[d];return p.style=this._createFragmentStyle(l[d]),p.style.on("style.import.load",()=>this.mergeAll()),p.style.loadURL(n),this}setImportData(t,n){this._checkLoaded();const l=this.getImportIndex(t),d=this.stylesheet.imports||[];return l===-1?this:n?(this.fragments[l].style.setState(n),this._reloadImports(),this):(delete d[l].data,this.setImportUrl(t,d[l].url))}setImportConfig(t,n,l){this._checkLoaded();const d=this.getImportIndex(t),p=this.stylesheet.imports||[];if(d===-1)return this;n?p[d].config=n:delete p[d].config;const m=this.fragments[d];l&&m.style.stylesheet&&(m.style.stylesheet.schema=l);const g=m.style.stylesheet&&m.style.stylesheet.schema;return m.config=n,m.style.updateConfig(n,g),this.updateConfigDependencies(),this}removeImport(t){this._checkLoaded();const n=this.stylesheet.imports||[],l=this.getImportIndex(t);l!==-1&&(n.splice(l,1),this.fragments[l].style._remove(),this.fragments.splice(l,1),this._reloadImports())}getImportIndex(t){const n=(this.stylesheet.imports||[]).findIndex(l=>l.id===t);return n===-1&&this.fire(new u.A(new Error(`Import '${t}' does not exist in the map's style and cannot be updated.`))),n}getLayer(t){return this._mergedLayers[t]}getSources(){const t=[];for(const n in this._mergedOtherSourceCaches){const l=this._mergedOtherSourceCaches[n];l&&t.push(l.getSource())}return t}getSource(t,n){const l=this.getSourceCache(t,n);return l&&l.getSource()}getLayerSource(t){const n=this.getLayerSourceCache(t);return n&&n.getSource()}getSourceCache(t,n){const l=u.y(t,n);return this._mergedOtherSourceCaches[l]}getLayerSourceCache(t){const n=u.y(t.source,t.scope);return t.type==="symbol"?this._mergedSymbolSourceCaches[n]:t.type==="fill-extrusion"?this._mergedFillExtrusionSourceCaches[n]||this._mergedOtherSourceCaches[n]:t.type==="fill"&&t.sourceLayer===u.dC&&this._mergedHdRoadCoverageSourceCaches[n]?this._mergedHdRoadCoverageSourceCaches[n]:this._mergedOtherSourceCaches[n]}getSourceCaches(t){if(t==null)return Object.values(this._mergedSourceCaches);const n=[];return this._mergedOtherSourceCaches[t]&&n.push(this._mergedOtherSourceCaches[t]),this._mergedSymbolSourceCaches[t]&&n.push(this._mergedSymbolSourceCaches[t]),this._mergedFillExtrusionSourceCaches[t]&&n.push(this._mergedFillExtrusionSourceCaches[t]),this._mergedHdRoadCoverageSourceCaches[t]&&n.push(this._mergedHdRoadCoverageSourceCaches[t]),this._mergedHdRoadElevationSourceCaches[t]&&n.push(this._mergedHdRoadElevationSourceCaches[t]),n}updateSourceCaches(){const t=this._changes.getUpdatedSourceCaches();for(const n in t){const l=t[n];l==="reload"?this.reloadSource(n):l==="clear"&&this.clearSource(n)}}updateLayers(t){const n=this._changes.getUpdatedPaintProperties();for(const l of n){const d=this.getLayer(l);d&&d.updateTransitions(t)}}getGlyphsUrl(){return this.stylesheet.glyphs}setGlyphsUrl(t){this.stylesheet.glyphs=t,this.glyphManager.setURL(t)}getOwnSourceCache(t){return this._otherSourceCaches[t]}getOwnLayerSourceCache(t){return t.type==="symbol"?this._symbolSourceCaches[t.source]:t.type==="fill-extrusion"&&this._fillExtrusionSourceCaches[t.source]||this._otherSourceCaches[t.source]}getOwnSourceCaches(t){const n=[];return this._otherSourceCaches[t]&&n.push(this._otherSourceCaches[t]),this._symbolSourceCaches[t]&&n.push(this._symbolSourceCaches[t]),this._fillExtrusionSourceCaches[t]&&n.push(this._fillExtrusionSourceCaches[t]),this._hdCoverage&&this._hdCoverage.coverageSourceCaches[t]&&n.push(this._hdCoverage.coverageSourceCaches[t]),this._hdElevation&&this._hdElevation.elevationSourceCaches[u.y(t,this.scope)]&&n.push(this._hdElevation.elevationSourceCaches[u.y(t,this.scope)]),n}_updateHdCoverageSourceCache(t){return jt.HdCoverageState&&jt.updateHdCoverageSourceCache?(this._hdCoverage||(this._hdCoverage=new jt.HdCoverageState),jt.updateHdCoverageSourceCache(this,this._hdCoverage,t),!1):t.type==="fill"&&t.sourceLayer===u.dC}_isSourceCacheLoaded(t){const n=this.getOwnSourceCaches(t);return n.length===0?(this.fire(new u.A(new Error(`There is no source with ID '${t}'`))),!1):n.every(l=>l.loaded())}has3DLayers(){return this._has3DLayers}hasSymbolLayers(){return this._hasSymbolLayers}hasCircleLayers(){return this._hasCircleLayers}isLayerClipped(t,n){if(!this._clipLayerPresent&&t.type!=="fill-extrusion"&&t.type!=="building")return!1;const l=t.type==="fill-extrusion"&&(t.sourceLayer==="building"||t.sourceLayer==="procedural_buildings"),d=t.type==="building";if(t.is3D(!!this.terrain)){if(l||d||n&&n.type==="batched-model"||t.type==="model")return!0}else if(t.type==="symbol")return!0;return!1}_clearWorkerCaches(){this.dispatcher.broadcast("clearCaches")}getBOMObject(){}destroy(){this._clearWorkerCaches(),this.imageManager.imageAtlasCache.clear(),this.fragments.forEac
vendor: 50,466 bytes, lines 3396-3401
3396h(t=>{t.style._remove()}),this.terrainSetForDrapingOnly()&&(delete this.terrain,delete this.stylesheet.terrain)}async getImages(t,n){const l=new Promise((x,w)=>{this.imageManager.getImages(n.icons.concat(n.patterns),n.scope,(S,A)=>{S?w(S):x(A)})});this._updateTilesForChangedImages();const d=n.icons.map(x=>u.I.toString(x)),p=n.patterns.map(x=>u.I.toString(x)),m=x=>{x&&(x.setDependencies(n.tileID.key,"icons",d),x.setDependencies(n.tileID.key,"patterns",p))},g=u.y(n.source,n.scope);return m(this._mergedOtherSourceCaches[g]),m(this._mergedSymbolSourceCaches[g]),(n.icons.some(x=>x.iconsetId)||n.patterns.some(x=>x.iconsetId))&&this.fire(new u.B("data",{dataType:"style"})),l}async rasterizeImages(t,n){return new Promise((l,d)=>{this.imageManager.rasterizeImages(n,(p,m)=>{p?d(p):l(m)})})}async checkAtlasCache(t,n){const l=this.imageManager.imageAtlasCache.findCachedAtlas(n.descriptor);return l&&l.contentDescriptor?{iconPositions:l.iconPositions,patternPositions:l.patternPositions,sourceHash:l.contentDescriptor.hash}:null}async getGlyphs(t,n){return new Promise((l,d)=>{this.glyphManager.getGlyphs(n.stacks,(p,m)=>{p?d(p):l(m)})})}}go.getSourceType=Xm,go.setSourceType=function(s,t){Tf[s]=t},go.registerForPluginStateChange=u.et;class Uh{constructor(){this.boundProgram=null,this.boundLayoutVertexBuffer=null,this.boundPaintVertexBuffers=[],this.boundIndexBuffer=null,this.boundVertexOffset=null,this.boundDynamicVertexBuffers=[],this.vao=null}bind(t,n,l,d,p,m,g,x){this.context=t;let w=this.boundPaintVertexBuffers.length!==d.length;for(let A=0;!w&&A<d.length;A++)this.boundPaintVertexBuffers[A]!==d[A]&&(w=!0);let S=this.boundDynamicVertexBuffers.length!==g.length;for(let A=0;!S&&A<g.length;A++)this.boundDynamicVertexBuffers[A]!==g[A]&&(S=!0);if(!this.vao||this.boundProgram!==n||this.boundLayoutVertexBuffer!==l||w||S||this.boundIndexBuffer!==p||this.boundVertexOffset!==m)this.freshBind(n,l,d,p,m,g,x);else{t.bindVertexArrayOES.set(this.vao);for(const A of g)A&&(A.bind(),x&&A.instanceCount&&A.setVertexAttribDivisor(t.gl,n,x));p&&p.dynamicDraw&&p.bind()}}freshBind(t,n,l,d,p,m,g){const x=this.context,w=x.gl;this.vao&&this.destroy(),this.vao=x.gl.createVertexArray(),x.bindVertexArrayOES.set(this.vao),this.boundProgram=t,this.boundLayoutVertexBuffer=n,this.boundPaintVertexBuffers=l,this.boundIndexBuffer=d,this.boundVertexOffset=p,this.boundDynamicVertexBuffers=m,n.enableAttributes(w,t),n.bind(),n.setVertexAttribPointers(w,t,p);for(const S of l)S.enableAttributes(w,t),S.bind(),S.setVertexAttribPointers(w,t,p);for(const S of m)S&&(S.enableAttributes(w,t),S.bind(),S.setVertexAttribPointers(w,t,p),g&&S.instanceCount&&S.setVertexAttribDivisor(w,t,g));d&&d.bind()}destroy(){this.vao&&(this.context.gl.deleteVertexArray(this.vao),this.vao=null)}}function bu(s,t){const n=Math.pow(2,t.canonical.z),l=t.canonical.y;return[new u.ac(0,l/n).toLngLat().lat,new u.ac(0,(l+1)/n).toLngLat().lat]}function l_(s,t,n,l,d,p,m){const g=s.context,x=g.gl,w=n.hillshadeFBO;if(!w)return;s.prepareDrawTile();const S=s.isTileAffectedByFog(t),A=[];s.terrain&&s.terrain.renderingToTexture&&s.emissiveMode==="mrt-fallback"&&A.push("USE_MRT1");const I=s.getOrCreateProgram("hillshade",{overrideFog:S,defines:A});g.activeTexture.set(x.TEXTURE0),x.bindTexture(x.TEXTURE_2D,w.colorAttachment0.get());const M=((B,$,Z,G)=>{const te=Z.paint.get("hillshade-shadow-color"),ee=Z.paint.get("hillshade-shadow-color-use-theme").constantOr("default")==="none",le=Z.paint.get("hillshade-highlight-color"),K=Z.paint.get("hillshade-highlight-color-use-theme").constantOr("default")==="none",Q=Z.paint.get("hillshade-accent-color"),ae=Z.paint.get("hillshade-accent-color-use-theme").constantOr("default")==="none",de=Z.paint.get("hillshade-emissive-strength");let fe=u.al(Z.paint.get("hillshade-illumination-direction"));if(Z.paint.get("hillshade-illumination-anchor")==="viewport")fe-=B.transform.angle;else if(B.style&&B.style.enable3dLights()&&B.style.directionalLight){const Te=B.style.directionalLight.properties.get("direction"),Ve=u.c5(Te.x,Te.y,Te.z);fe=u.al(Ve[1])}const be=!B.options.moving;return{u_matrix:G||B.transform.calculateProjMatrix($.tileID.toUnwrapped(),be),u_image:0,u_latrange:bu(0,$.tileID),u_light:[Z.paint.get("hillshade-exaggeration"),fe],u_shadow:te.toPremultipliedRenderColor(ee?null:Z.lut),u_highlight:le.toPremultipliedRenderColor(K?null:Z.lut),u_emissive_strength:de,u_accent:Q.toPremultipliedRenderColor(ae?null:Z.lut)}})(s,n,l,s.terrain?t.projMatrix:null);s.uploadCommonUniforms(g,I,t.toUnwrapped());const{tileBoundsBuffer:D,tileBoundsIndexBuffer:L,tileBoundsSegments:k}=s.getTileBoundsBuffers(n);I.draw(s,x.TRIANGLES,d,p,m,_t.disabled,M,l.id,D,L,k)}function Of(s,t,n){if(!t.needsDEMTextureUpload)return;const l=s.context,d=l.gl;l.pixelStoreUnpackPremultiplyAlpha.set(!1),t.demTexture=t.demTexture||s.getTileTexture(n.stride);const p=n.getPixels();t.demTexture?t.demTexture.update(p,{premultiply:!1}):t.demTexture=new u.T(l,p,d.R32F,{premultiply:!1}),t.needsDEMTextureUpload=!1}function wu(s,t,n){const l=s.context,d=l.gl;if(!t.dem)return;const p=t.dem;if(l.activeTexture.set(d.TEXTURE1),Of(s,t,p),!t.demTexture)return;t.demTexture.bind(d.NEAREST,d.CLAMP_TO_EDGE);const m=p.dim;l.activeTexture.set(d.TEXTURE0);let g=t.hillshadeFBO;if(!g){const I=new u.T(l,{width:m,height:m,data:null},d.RGBA8);I.bind(d.LINEAR,d.CLAMP_TO_EDGE),g=t.hillshadeFBO=l.createFramebuffer(m,m,1,"renderbuffer"),g.colorAttachment0.set(I.texture)}l.bindFramebuffer.set(g.framebuffer),l.viewport.set([0,0,m,m]);const{tileBoundsBuffer:x,tileBoundsIndexBuffer:w,tileBoundsSegments:S}=s.getMercatorTileBoundsBuffers(),A=[];s.linearFloatFilteringSupported()&&A.push("TERRAIN_DEM_FLOAT_FORMAT"),s.terrain&&s.terrain.renderingToTexture&&s.emissiveMode==="mrt-fallback"&&A.push("USE_MRT1"),s.getOrCreateProgram("hillshadePrepare",{defines:A}).draw(s,d.TRIANGLES,ct.disabled,mt.disabled,yt.unblended,_t.disabled,((I,M)=>{const D=M.stride,L=u.aS();return u.aK(L,0,u.aj,-u.aj,0,0,1),u.aG(L,L,[0,-u.aj,0]),{u_matrix:L,u_image:1,u_dimension:[D,D],u_zoom:I.overscaledZ}})(t.tileID,p),n.id,x,w,S),t.needsHillshadePrepare=!1}class Hi{constructor(t){this.gl=t.gl,this.default=this.getDefault(),this.current=this.default,this.dirty=!1}get(){return this.current}set(t){}getDefault(){return this.default}setDefault(){this.set(this.default)}}class c_ extends Hi{getDefault(){return u.C.transparent.toNonPremultipliedRenderColor(null)}set(t){const n=this.current;(t.r!==n.r||t.g!==n.g||t.b!==n.b||t.a!==n.a||this.dirty)&&(this.gl.clearColor(t.r,t.g,t.b,t.a),this.current=t,this.dirty=!1)}}class kf extends Hi{getDefault(){return 1}set(t){(t!==this.current||this.dirty)&&(this.gl.clearDepth(t),this.current=t,this.dirty=!1)}}class Bf extends Hi{getDefault(){return 0}set(t){(t!==this.current||this.dirty)&&(this.gl.clearStencil(t),this.current=t,this.dirty=!1)}}class Zn extends Hi{getDefault(){return[!0,!0,!0,!0]}set(t){const n=this.current;(t[0]!==n[0]||t[1]!==n[1]||t[2]!==n[2]||t[3]!==n[3]||this.dirty)&&(this.gl.colorMask(t[0],t[1],t[2],t[3]),this.current=t,this.dirty=!1)}}class Pl extends Hi{getDefault(){return!0}set(t){(t!==this.current||this.dirty)&&(this.gl.depthMask(t),this.current=t,this.dirty=!1)}}class Nf extends Hi{getDefault(){return 255}set(t){(t!==this.current||this.dirty)&&(this.gl.stencilMask(t),this.current=t,this.dirty=!1)}}class os extends Hi{getDefault(){return{func:this.gl.ALWAYS,ref:0,mask:255}}set(t){const n=this.current;(t.func!==n.func||t.ref!==n.ref||t.mask!==n.mask||this.dirty)&&(this.gl.stencilFunc(t.func,t.ref,t.mask),this.current=t,this.dirty=!1)}}class ss extends Hi{getDefault(){const t=this.gl;return[t.KEEP,t.KEEP,t.KEEP]}set(t){const n=this.current;(t[0]!==n[0]||t[1]!==n[1]||t[2]!==n[2]||this.dirty)&&(this.gl.stencilOp(t[0],t[1],t[2]),this.current=t,this.dirty=!1)}}class Ec extends Hi{getDefault(){return!1}set(t){if(t===this.current&&!this.dirty)return;const n=this.gl;t?n.enable(n.STENCIL_TEST):n.disable(n.STENCIL_TEST),this.current=t,this.dirty=!1}}class Rl extends Hi{getDefault(){return[0,1]}set(t){const n=this.current;(t[0]!==n[0]||t[1]!==n[1]||this.dirty)&&(this.gl.depthRange(t[0],t[1]),this.current=t,this.dirty=!1)}}class Ic extends Hi{getDefault(){return!1}set(t){if(t===this.current&&!this.dirty)return;const n=this.gl;t?n.enable(n.DEPTH_TEST):n.disable(n.DEPTH_TEST),this.current=t,this.dirty=!1}}class Vf extends Hi{getDefault(){return this.gl.LESS}set(t){(t!==this.current||this.dirty)&&(this.gl.depthFunc(t),this.current=t,this.dirty=!1)}}class ui extends Hi{getDefault(){return!1}set(t){if(t===this.current&&!this.dirty)return;const n=this.gl;t?n.enable(n.BLEND):n.disable(n.BLEND),this.current=t,this.dirty=!1}}class Ga extends Hi{getDefault(){const t=this.gl;return[t.ONE,t.ZERO,t.ONE,t.ZERO]}set(t){const n=this.current;(t[0]!==n[0]||t[1]!==n[1]||t[2]!==n[2]||t[3]!==n[3]||this.dirty)&&(this.gl.blendFuncSeparate(t[0],t[1],t[2],t[3]),this.current=t,this.dirty=!1)}}class Uf extends Hi{getDefault(){return u.C.transparent.toNonPremultipliedRenderColor(null)}set(t){const n=this.current;(t.r!==n.r||t.g!==n.g||t.b!==n.b||t.a!==n.a||this.dirty)&&(this.gl.blendColor(t.r,t.g,t.b,t.a),this.current=t,this.dirty=!1)}}class Wn extends Hi{getDefault(){return this.gl.FUNC_ADD}set(t){(t!==this.current||this.dirty)&&(this.gl.blendEquationSeparate(t,t),this.current=t,this.dirty=!1)}}class jf extends Hi{getDefault(){return!1}set(t){if(t===this.current&&!this.dirty)return;const n=this.gl;t?n.enable(n.CULL_FACE):n.disable(n.CULL_FACE),this.current=t,this.dirty=!1}}class as extends Hi{getDefault(){return this.gl.BACK}set(t){(t!==this.current||this.dirty)&&(this.gl.cullFace(t),this.current=t,this.dirty=!1)}}class u_ extends Hi{getDefault(){return this.gl.CCW}set(t){(t!==this.current||this.dirty)&&(this.gl.frontFace(t),this.current=t,this.dirty=!1)}}let Dl=class extends Hi{getDefault(){return null}set(s){(s!==this.current||this.dirty)&&(this.gl.useProgram(s),this.current=s,this.dirty=!1)}};class h_ extends Hi{getDefault(){return this.gl.TEXTURE0}set(t){(t!==this.current||this.dirty)&&(this.gl.activeTexture(t),this.current=t,this.dirty=!1)}}class yo extends Hi{getDefault(){const t=this.gl;return[0,0,t.drawingBufferWidth,t.drawingBufferHeight]}set(t){const n=this.current;(t[0]!==n[0]||t[1]!==n[1]||t[2]!==n[2]||t[3]!==n[3]||this.dirty)&&(this.gl.viewport(t[0],t[1],t[2],t[3]),this.current=t,this.dirty=!1)}}class kn extends Hi{getDefault(){return null}set(t){if(t===this.current&&!this.dirty)return;const n=this.gl;n.bindFramebuffer(n.FRAMEBUFFER,t),this.current=t,this.dirty=!1}}class Gf extends Hi{getDefault(){return null}set(t){if(t===this.current&&!this.dirty)return;const n=this.gl;n.bindRenderbuffer(n.RENDERBUFFER,t),this.current=t,this.dirty=!1}}class d_ extends Hi{getDefault(){return null}set(t){if(t===this.current&&!this.dirty)return;const n=this.gl;n.bindTexture(n.TEXTURE_2D,t),this.current=t,this.dirty=!1}}class $f extends Hi{getDefault(){return null}set(t){if(t===this.current&&!this.dirty)return;const n=this.gl;n.bindBuffer(n.ARRAY_BUFFER,t),this.current=t,this.dirty=!1}}class ay extends Hi{getDefault(){return null}set(t){const n=this.gl;n.bindBuffer(n.ELEMENT_ARRAY_BUFFER,t),this.current=t,this.dirty=!1}}class qf extends Hi{getDefault(){return null}set(t){this.gl&&(t!==this.current||this.dirty)&&(this.gl.bindVertexArray(t),this.current=t,this.dirty=!1)}}class f_ extends Hi{getDefault(){return 4}set(t){if(t===this.current&&!this.dirty)return;const n=this.gl;n.pixelStorei(n.UNPACK_ALIGNMENT,t),this.current=t,this.dirty=!1}}class ly extends Hi{getDefault(){return!1}set(t){if(t===this.current&&!this.dirty)return;const n=this.gl;n.pixelStorei(n.UNPACK_PREMULTIPLY_ALPHA_WEBGL,t),this.current=t,this.dirty=!1}}class ls extends Hi{getDefault(){return!1}set(t){if(t===this.current&&!this.dirty)return;const n=this.gl;n.pixelStorei(n.UNPACK_FLIP_Y_WEBGL,t),this.current=t,this.dirty=!1}}class Vo extends Hi{constructor(t,n){super(t),this.context=t,this.parent=n}getDefault(){return null}}class jh extends Vo{constructor(t,n,l=0){super(t,n),this.attachmentPoint=t.gl.COLOR_ATTACHMENT0+l}setDirty(){this.dirty=!0}set(t){if(t===this.current&&!this.dirty)return;this.context.bindFramebuffer.set(this.parent);const n=this.gl;n.framebufferTexture2D(n.FRAMEBUFFER,this.attachmentPoint,n.TEXTURE_2D,t,0),this.current=t,this.dirty=!1}}class Ac extends Vo{attachment(){return this.gl.DEPTH_ATTACHMENT}set(t){if(t===this.current&&!this.dirty)return;this.context.bindFramebuffer.set(this.parent);const n=this.gl;n.framebufferRenderbuffer(n.FRAMEBUFFER,this.attachment(),n.RENDERBUFFER,t),this.current=t,this.dirty=!1}}class cy extends Vo{attachment(){return this.gl.DEPTH_ATTACHMENT}set(t){if(t===this.current&&!this.dirty)return;this.context.bindFramebuffer.set(this.parent);const n=this.gl;n.framebufferTexture2D(n.FRAMEBUFFER,this.attachment(),n.TEXTURE_2D,t,0),this.current=t,this.dirty=!1}}class zi extends Ac{attachment(){return this.gl.DEPTH_STENCIL_ATTACHMENT}}const Gt=(s,t,n,l)=>({u_matrix:s,u_image0:0,u_image1:1,u_skirt_height:t,u_ground_shadow_factor:n,u_emissive_texture_available:l}),Hf=(s,t,n,l,d,p,m,g,x,w,S,A,I,M,D,L,k)=>({u_proj_matrix:Float32Array.from(s),u_globe_matrix:t,u_normalize_matrix:Float32Array.from(l),u_merc_matrix:n,u_zoom_transition:d,u_merc_center:p,u_image0:0,u_image1:1,u_frustum_tl:m,u_frustum_tr:g,u_frustum_br:x,u_frustum_bl:w,u_globe_pos:S,u_globe_radius:A,u_viewport:I,u_grid_matrix:k?Float32Array.from(k):new Float32Array(9),u_skirt_height:M,u_far_z_cutoff:D,u_emissive_texture_available:L});function _a(s,t){return s!=null&&t!=null&&!(!s.hasData()||!t.hasData())&&s.demTexture!=null&&t.demTexture!=null&&s.tileID.key!==t.tileID.key}const Ms=new class{constructor(){this.operations={}}newMorphing(s,t,n,l,d){if(s in this.operations){const p=this.operations[s];p.to.tileID.key!==n.tileID.key&&(p.queued=n)}else this.operations[s]={startTime:l,phase:0,duration:d,from:t,to:n,queued:null}}getMorphValuesForProxy(s){if(!(s in this.operations))return null;const t=this.operations[s];return{from:t.from,to:t.to,phase:t.phase}}update(s){for(const t in this.operations){const n=this.operations[t];for(n.phase=(s-n.startTime)/n.duration;n.phase>=1||!this._validOp(n);)if(!this._nextOp(n,s)){delete this.operations[t];break}}}_nextOp(s,t){return!!s.queued&&(s.from=s.to,s.to=s.queued,s.queued=null,s.phase=0,s.startTime=t,!0)}_validOp(s){return s.from.hasData()&&s.to.hasData()}};function Gh(s,t,n){if(t===0)return 0;const l=t<1&&n===514?.25/t:1;return 6*Math.pow(1.5,22-s)*Math.max(t,1)*l}function Js(s,t){const n=1<<s.z;return!t&&(s.x===0||s.x===n-1)||s.y===0||s.y===n-1}function Tu(s,t){if(!s.style||!s.style.enable3dLights())return;const n=s.context,l=n.gl;n.activeTexture.set(l.TEXTURE1),t?t.bind(l.LINEAR,l.CLAMP_TO_EDGE):s.emptyTexture.bind(l.LINEAR,l.CLAMP_TO_EDGE)}class Zf extends $n{constructor(t){const n={type:"raster-dem",maxzoom:Math.ceil(t.transform.maxZoom)},l=Ph("mock-dem",n,t.style.dispatcher,t.style);super("mock-dem",l,null),l.setEventedParent(this),this._sourceLoaded=!0}_loadTile(t,n){t.state="loaded",n(null)}}class Wf extends $n{constructor(t){const n=Ph("proxy",{type:"geojson",maxzoom:Math.ceil(t.transform.maxZoom)},t.style.dispatcher,t.style);super("proxy",n,null),n.setEventedParent(this),this.map=this.getSource().map=t,this.used=this._sourceLoaded=!0,this.renderCache=[],this.renderCachePool=[],this.proxyCachedFBO={}}update(t,n,l){if(t.freezeTileCoverage)return;this.transform=t;const d=t.coveringTiles({tileSize:this._source.tileSize,minzoom:this._source.minzoom,maxzoom:this._source.maxzoom,roundZoom:this._source.roundZoom,reparseOverscaled:this._source.reparseOverscaled}).reduce((p,m)=>{if(p[m.key]="",!this._tiles[m.key]){const g=new _c(m,this._source.tileSize*m.overscaleFactor(),t.tileZoom,void 0,void 0,this._source.worldview);g.state="loaded",this._tiles[m.key]=g}return p},{});for(const p in this._tiles)p in d||(this.freeFBO(p),this._tiles[p].unloadVectorData(),delete this._tiles[p])}freeFBO(t){const n=this.proxyCachedFBO[t];if(n!==void 0){const l=Object.values(n);this.renderCachePool.push(...l),delete this.proxyCachedFBO[t]}}deallocRenderCache(){this.renderCache.forEach(t=>t.fb.destroy()),this.renderCache=[],this.renderCachePool=[],this.proxyCachedFBO={}}}class $h extends u.br{constructor(t,n,l){super(t.overscaledZ,t.wrap,t.canonical.z,t.canonical.x,t.canonical.y),this.proxyTileKey=n,this.projMatrix=l}}class qh extends u.e7{constructor(t,n){super(),this.painter=t,this.terrainTileForTile={},this.prevTerrainTileForTile={};const[l,d,p]=(function(){const x=new u.co,w=new u.cp,S=131;x.reserve(17161),w.reserve(33800);const A=u.aj/128,I=u.aj+A/2,M=I+A;for(let L=-A;L<M;L+=A)for(let k=-A;k<M;k+=A){const B=k<0||k>I||L<0||L>I?24575:0,$=u.as(Math.round(k),0,u.aj),Z=u.as(Math.round(L),0,u.aj);x.emplaceBack($+B,Z)}const D=(L,k)=>{const B=k*S+L;w.emplaceBack(B+1,B,B+S),w.emplaceBack(B+S,B+S+1,B+1)};for(let L=1;L<129;L++)for(let k=1;k<129;k++)D(k,L);return[0,129].forEach(L=>{for(let k=0;k<130;k++)D(k,L),D(L,k)}),[x,w,32768]})(),m=t.context;this.gridBuffer=m.createVertexBuffer(l,u.cq.members),this.gridIndexBuffer=m.createIndexBuffer(d),this.gridSegments=u.cr.simpleSegment(0,0,l.length,d.length),this.gridNoSkirtSegments=u.cr.simpleSegment(0,0,l.length,p),this.proxyCoords=[],this.proxiedCoords={},this._visibleDemTiles=[],this._drapedRenderBatches=[],this._sourceTilesOverlap={},this.proxySourceCache=new Wf(n.map),this.orthoMatrix=u.aS(),u.aK(this.orthoMatrix,this.painter.transform.projection.name==="globe"?.015:0,u.aj,0,u.aj,0,1);const g=m.gl;this._overlapStencilMode=new mt({func:g.GEQUAL,mask:255},0,255,g.KEEP,g.KEEP,g.REPLACE),this._previousZoom=t.transform.zoom,this.pool=[],this._findCoveringTileCache={},this._tilesDirty={},this.style=n,this._useVertexMorphing=!0,this._exaggeration=1,this._mockSourceCache=new Zf(n.map),this._pendingGroundEffectLayers=[],this._emissiveTexture=!1,this._devtoolsFolder=null}set style(t){t.on("data",this._onStyleDataEvent.bind(this)),this._style=t,this._style.map.on("moveend",()=>{this._clearLineLayersFromRenderCache()})}update(t,n,l){if(t&&t.terrain){this._style!==t&&(this.style=t,this._evaluationZoom=void 0);const d=t.terrain.properties,p=t.terrain.drapeRenderMode===0,m=t.terrain.isZoomDependent();this._previousUpdateTimestamp=this.enabled?this._updateTimestamp:void 0,this._updateTimestamp=u.r.now();const g=t.terrain&&t.terrain.scope,x=d.get("source"),w=p?this._mockSourceCache:t.getSourceCache(x,g);if(!w)return void u.w(`Couldn't find terrain source "${x}".`);if(this.sourceCache=w,this._attenuationRange=t.terrain.getAttenuationRange(),this._exaggeration=m?this.calculateExaggeration(n):d.get("exaggeration"),!n.projection.requiresDraping&&m&&this._exaggeration===0)return void this._disable();this.enabled=!0;const S=()=>{this.sourceCache.used&&u.w(`Raster DEM source '${this.sourceCache.id}' is used both for terrain and as layer source.
3397This leads to lower resolution of hillshade. For full hillshade resolution but higher memory consumption, define another raster DEM source.`);const A=this.getScaledDemTileSize();this.sourceCache.update(n,A,!0),this.resetTileLookupCache(this.sourceCache.id)};this.sourceCache.usedForTerrain||(this.resetTileLookupCache(this.sourceCache.id),this.sourceCache.usedForTerrain=!0,S(),this._initializing=!0),S(),n.updateElevation(!0,l),this.resetTileLookupCache(this.proxySourceCache.id),this.proxySourceCache.update(n),this._emptyDEMTextureDirty=!0,this._previousZoom=n.zoom}else this._disable()}calculateExaggeration(t){if(this._attenuationRange&&t.zoom>=Math.ceil(this._attenuationRange[1]))return this._style.terrain.getExaggeration(t.zoom);const n=this._previousCameraAltitude,l=t.getFreeCameraOptions().position.z/t.pixelsPerMeter*t.worldSize;this._previousCameraAltitude=l;const d=n!=null?l-n:Number.MAX_VALUE;if(Math.abs(d)<2)return this._exaggeration;const p=t.zoom,m=this._style.terrain;if(!this._previousUpdateTimestamp)return m.getExaggeration(p);let g=p-this._previousZoom;const x=this._previousUpdateTimestamp;let w=p;this._evaluationZoom!=null&&(w=this._evaluationZoom,Math.abs(p-w)>.5&&(g=.5*(p-w+g)),g*d<0&&(w+=g)),this._evaluationZoom=w;const S=m.getExaggeration(w),A=S===m.getExaggeration(Math.max(0,w-.1));if(A&&Math.abs(S-this._exaggeration)<.01)return S;let I=Math.min(.1,.00375*(this._updateTimestamp-x));return(A||S<.1||Math.abs(g)<1e-4)&&(I=Math.min(.2,4*I)),u.ai(this._exaggeration,S,I)}resetTileLookupCache(t){this._findCoveringTileCache[t]={}}attenuationRange(){return this._attenuationRange}getDemUpscale(){return this.proxySourceCache.getSource().tileSize/128}getScaledDemTileSize(){return this.sourceCache.getSource().tileSize/128*this.proxySourceCache.getSource().tileSize}_onStyleDataEvent(t){t.dataType==="source"&&t.coord?this._clearRenderCacheForTile(t.sourceCacheId,t.coord):t.dataType==="style"&&(this.invalidateRenderCache=!0,this._evaluationZoom=void 0,this._previousUpdateTimestamp=void 0,this._previousCameraAltitude=void 0)}_disable(){if(this.enabled&&(this.enabled=!1,this._emptyDEMTextureDirty=!0,this._sharedDepthStencil=void 0,this._evaluationZoom=void 0,this._previousUpdateTimestamp=void 0,this.proxySourceCache.deallocRenderCache(),this._style))for(const t in this._style._mergedSourceCaches)this._style._mergedSourceCaches[t].usedForTerrain=!1}destroy(){this._disable(),this._emptyDEMTexture&&this._emptyDEMTexture.destroy(),this.pool.forEach(t=>t.fb.destroy()),this.pool=[],this.framebufferCopyTexture&&this.framebufferCopyTexture.destroy()}_source(){return this.enabled?this.sourceCache:null}isUsingMockSource(){return this.sourceCache===this._mockSourceCache}exaggeration(){return this.enabled?this._exaggeration:0}get visibleDemTiles(){return this._visibleDemTiles}get drapeBufferSize(){const t=2*this.proxySourceCache.getSource().tileSize;return[t,t]}set useVertexMorphing(t){this._useVertexMorphing=t}updateTileBinding(t){if(!this.enabled)return;this.prevTerrainTileForTile=this.terrainTileForTile;const n=this.proxySourceCache,l=this.painter.transform;this._initializing&&(this._initializing=l._centerAltitude===0&&this.getAtPointOrZero(u.ac.fromLngLat(l.center),-1)===-1,this._emptyDEMTextureDirty=!this._initializing);const d=this.proxyCoords=n.getIds().map(x=>{const w=n.getTileByID(x).tileID;return w.projMatrix=l.calculateProjMatrix(w.toUnwrapped()),w});(function(x,w){const S=w.transform.pointCoordinate(w.transform.getCameraPoint()),A=new u.P(S.x,S.y);x.sort((I,M)=>{if(M.overscaledZ-I.overscaledZ)return M.overscaledZ-I.overscaledZ;const D=new u.P(I.canonical.x+(1<<I.canonical.z)*I.wrap,I.canonical.y),L=new u.P(M.canonical.x+(1<<M.canonical.z)*M.wrap,M.canonical.y),k=A.mult(1<<I.canonical.z);return k.x-=.5,k.y-=.5,k.distSqr(D)-k.distSqr(L)})})(d,this.painter);const p=this.proxyToSource||{};this.proxyToSource={},d.forEach(x=>{this.proxyToSource[x.key]={}}),this.terrainTileForTile={};const m=this._style._mergedSourceCaches;for(const x in m){const w=m[x];if(!w.used||!w.transform||(w!==this.sourceCache&&this.resetTileLookupCache(w.id),this._setupProxiedCoordsForOrtho(w,t[x],p),w.usedForTerrain))continue;const S=t[x];(w.getSource().reparseOverscaled||w._isRasterElevatedOverTerrain)&&this._assignTerrainTiles(S)}this.proxiedCoords[n.id]=d.map(x=>new $h(x,x.key,this.orthoMatrix)),this._assignTerrainTiles(d),this._prepareDEMTextures(),this._setupDrapedRenderBatches(),this._initFBOPool(),this._setupRenderCache(p),this.renderingToTexture=!1;const g={};this._visibleDemTiles=[];for(const x of this.proxyCoords){const w=this.terrainTileForTile[x.key];if(!w)continue;const S=w.tileID.key;S in g||(this._visibleDemTiles.push(w),g[S]=S)}}_assignTerrainTiles(t){this._initializing||t.forEach(n=>{if(this.terrainTileForTile[n.key])return;const l=this._findTileCoveringTileID(n,this.sourceCache);l&&(this.terrainTileForTile[n.key]=l)})}_prepareDEMTextures(){const t=this.painter.context,n=t.gl;for(const l in this.terrainTileForTile){const d=this.terrainTileForTile[l],p=d.dem;!p||d.demTexture&&!d.needsDEMTextureUpload||(t.activeTexture.set(n.TEXTURE1),Of(this.painter,d,p))}}_prepareDemTileUniforms(t,n,l,d){if(!n||n.demTexture==null)return!1;const p=t.tileID.canonical,m=Math.pow(2,n.tileID.canonical.z-p.z),g=d||"";return l[`u_dem_tl${g}`]=[p.x*m%1,p.y*m%1],l[`u_dem_scale${g}`]=m,!0}get emptyDEMTexture(){return!this._emptyDEMTextureDirty&&this._emptyDEMTexture?this._emptyDEMTexture:this._updateEmptyDEMTexture()}_getLoadedAreaMinimum(){if(!this.enabled)return 0;let t=0;const n=this._visibleDemTiles.reduce((l,d)=>{if(!d.dem)return l;const p=d.dem.tree.minimums[0];return p>0&&t++,l+p},0);return t?n/t:0}_updateEmptyDEMTexture(){const t=this.painter.context,n=t.gl;t.activeTexture.set(n.TEXTURE2);const l=this._getLoadedAreaMinimum(),d=new u.ex({width:1,height:1},new Float32Array([l]));this._emptyDEMTextureDirty=!1;let p=this._emptyDEMTexture;return p?p.update(d,{premultiply:!1}):p=this._emptyDEMTexture=new u.T(t,d,n.R32F,{premultiply:!1}),p}setupElevationDraw(t,n,l){const d=this.painter.context,p=d.gl,m={u_dem:2,u_dem_prev:4,u_dem_tl:[0,0],u_dem_tl_prev:[0,0],u_dem_scale:0,u_dem_scale_prev:0,u_dem_size:0,u_dem_lerp:1,u_depth:3,u_depth_size_inv:[0,0],u_depth_range_unpack:[0,1],u_occluder_half_size:16,u_occlusion_depth_offset:-1e-4,u_exaggeration:0};m.u_exaggeration=this.exaggeration();let g=null,x=null,w=1;if(l&&l.morphing&&this._useVertexMorphing){const M=l.morphing.srcDemTile,D=l.morphing.dstDemTile;w=l.morphing.phase,M&&D&&(this._prepareDemTileUniforms(t,M,m,"_prev")&&(x=M),this._prepareDemTileUniforms(t,D,m)&&(g=D))}const S=M=>M&&M.demTexture&&this.painter.linearFloatFilteringSupported()?p.LINEAR:p.NEAREST;let A=null;var I;if(this.enabled?x&&g?(A=g.demTexture,d.activeTexture.set(p.TEXTURE4),x.demTexture.bind(S(x),p.CLAMP_TO_EDGE),m.u_dem_lerp=w):(g=this.terrainTileForTile[t.tileID.key],A=this._prepareDemTileUniforms(t,g,m)?g.demTexture:this.emptyDEMTexture):A=this.emptyDEMTexture,d.activeTexture.set(p.TEXTURE2),A&&(m.u_dem_size=(I=A).size[0]===1?1:I.size[0]-2,A.bind(S(g),p.CLAMP_TO_EDGE)),this.painter.setupDepthForOcclusion(l&&l.useDepthForOcclusion,n,m),l&&l.useMeterToDem&&g){const M=(1<<g.tileID.canonical.z)*u.aL(1,this.painter.transform.center.lat)*this.sourceCache.getSource().tileSize;m.u_meter_to_dem=M}if(l&&l.labelPlaneMatrixInv&&(m.u_label_plane_matrix_inv=l.labelPlaneMatrixInv),n.setTerrainUniformValues(d,m),this.painter.transform.projection.name==="globe"){const M=this.globeUniformValues(this.painter.transform,t.tileID.canonical,l&&l.useDenormalizedUpVectorScale);n.setGlobeUniformValues(d,M)}}globeUniformValues(t,n,l){const d=t.projection;return{u_tile_tl_up:d.upVector(n,0,0),u_tile_tr_up:d.upVector(n,u.aj,0),u_tile_br_up:d.upVector(n,u.aj,u.aj),u_tile_bl_up:d.upVector(n,0,u.aj),u_tile_up_scale:l?u.ey(1):d.upVectorScale(n,t.center.lat,t.worldSize).metersToTile}}renderToBackBuffer(t){const n=this.painter,l=this.painter.context;t.length!==0&&(l.bindFramebuffer.set(null),l.viewport.set([0,0,n.width,n.height]),n.gpuTimingDeferredRenderStart(),this.renderingToTexture=!1,(function(d,p,m,g,x){if(d.transform.projection.name==="globe")(function(w,S,A,I,M){const D=w.context,L=D.gl;let k,B;const $=w.transform,Z=u.ev(w,D,$),G=(be,Te)=>{if(B===Te)return;const Ve=[];Te===1&&Ve.push("TERRAIN_VERTEX_MORPHING"),Ve.push("PROJECTION_GLOBE_VIEW"),Z&&Ve.push("CUSTOM_ANTIALIASING");const ye=w.isTileAffectedByFog(be);k=w.getOrCreateProgram("globeRaster",{defines:Ve,overrideFog:ye}),B=Te},te=w.colorModeForRenderPass(),ee=new ct(L.LEQUAL,ct.ReadWrite,w.depthRangeFor3D);Ms.update(M);const le=u.dp($),K=[u.a_($.center.lng),u.a$($.center.lat)],Q=w.globeSharedBuffers,ae=[$.width*u.r.devicePixelRatio,$.height*u.r.devicePixelRatio],de=Float32Array.from($.globeMatrix),fe={useDenormalizedUpVectorScale:!0};{const be=w.transform,Te=Gh(be.zoom,S.exaggeration(),S.sourceCache._source.tileSize);B=-1;const Ve=L.TRIANGLES;for(const ye of I){const Ae=A.getTile(ye),ge=mt.disabled,Fe=S.prevTerrainTileForTile[ye.key],Re=S.terrainTileForTile[ye.key];_a(Fe,Re)&&Ms.newMorphing(ye.key,Fe,Re,M,250),Tu(w,Ae.emissiveTexture),D.activeTexture.set(L.TEXTURE0),Ae.texture&&Ae.texture.bind(L.LINEAR,L.CLAMP_TO_EDGE);const De=Ms.getMorphValuesForProxy(ye.key),Ke=De?1:0;De&&Object.assign(fe,{morphing:{srcDemTile:De.from,dstDemTile:De.to,phase:u.eu(De.phase)}});const Be=u.dl(ye.canonical),Ge=u.dm(Be.getCenter().lat),Ze=u.dq(ye.canonical,Be,Ge,be.worldSize/be._pixelsPerMercatorPixel),tt=u.d3(u.dn(ye.canonical)),ot=w.emissiveMode==="mrt-fallback"?1:0,at=Hf(be.expandedFarZProjMatrix,de,le,tt,u.ah(be.zoom),K,be.frustumCorners.TL,be.frustumCorners.TR,be.frustumCorners.BR,be.frustumCorners.BL,be.globeCenterInViewSpace,be.globeRadius,ae,Te,be._farZ,ot,Ze);if(G(ye,Ke),k&&(S.setupElevationDraw(Ae,k,fe),w.uploadCommonUniforms(D,k,ye.toUnwrapped()),Q)){const[ut,bt,pt]=Q.getGridBuffers(Ge,Te!==0);k.draw(w,Ve,ee,ge,te,_t.backCCW,at,"globe_raster",ut,bt,pt)}}}if(Q&&(w.renderDefaultNorthPole||w.renderDefaultSouthPole)){const be=["GLOBE_POLES","PROJECTION_GLOBE_VIEW"];Z&&be.push("CUSTOM_ANTIALIASING"),k=w.getOrCreateProgram("globeRaster",{defines:be});for(const Te of I){const{x:Ve,y:ye,z:Ae}=Te.canonical,ge=ye===0,Fe=ye===(1<<Ae)-1,[Re,De,Ke,Be]=Q.getPoleBuffers(Ae,!1);if(Be&&(ge||Fe)){const Ge=A.getTile(Te);Tu(w,Ge.emissiveTexture),D.activeTexture.set(L.TEXTURE0),Ge.texture&&Ge.texture.bind(L.LINEAR,L.CLAMP_TO_EDGE);let Ze=u.ew(Ae,Ve,$);const tt=u.d3(u.dn(Te.canonical)),ot=w.emissiveMode==="mrt-fallback"?1:0,at=(ut,bt)=>ut.draw(w,L.TRIANGLES,ee,mt.disabled,te,_t.disabled,Hf($.expandedFarZProjMatrix,Ze,Ze,tt,0,K,$.frustumCorners.TL,$.frustumCorners.TR,$.frustumCorners.BR,$.frustumCorners.BL,$.globeCenterInViewSpace,$.globeRadius,ae,0,$._farZ,ot),"globe_pole_raster",bt,Ke,Be);S.setupElevationDraw(Ge,k,fe),w.uploadCommonUniforms(D,k,Te.toUnwrapped()),ge&&w.renderDefaultNorthPole&&at(k,Re),Fe&&w.renderDefaultSouthPole&&(Ze=u.bL(u.aS(),Ze,[1,-1,1]),at(k,De))}}}})(d,p,m,g,x);else{const w=d.context,S=w.gl;let A,I;const M=d.shadowRenderer,D=Oo(d,d.longestCutoffRange),L=te=>{if(I===te)return;const ee=[];te===1&&ee.push("TERRAIN_VERTEX_MORPHING"),D.shouldRenderCutoff&&ee.push("RENDER_CUTOFF"),M&&(ee.push("RENDER_SHADOWS"),M.useNormalOffset&&ee.push("NORMAL_OFFSET")),A=d.getOrCreateProgram("terrainRaster",{defines:ee}),I=te},k=d.colorModeForRenderPass(),B=new ct(S.LEQUAL,ct.ReadWrite,d.depthRangeFor3D);Ms.update(x);const $=d.transform,Z=Gh($.zoom,p.exaggeration(),p.sourceCache._source.tileSize);let G=[0,0,0];if(M){const te=d.style.directionalLight,ee=d.style.ambientLight;te&&ee&&(G=pl(d.style,te,ee))}{I=-1;const te=S.TRIANGLES,[ee,le]=[p.gridIndexBuffer,p.gridSegments];for(const K of g){const Q=m.getTile(K),ae=mt.disabled,de=p.prevTerrainTileForTile[K.key],fe=p.terrainTileForTile[K.key];_a(de,fe)&&Ms.newMorphing(K.key,de,fe,x,250),Tu(d,Q.emissiveTexture),w.activeTexture.set(S.TEXTURE0),Q.texture&&Q.texture.bind(S.LINEAR,S.CLAMP_TO_EDGE);const be=Ms.getMorphValuesForProxy(K.key),Te=be?1:0;let Ve;be&&(Ve={morphing:{srcDemTile:be.from,dstDemTile:be.to,phase:u.eu(be.phase)}});const ye=d.emissiveMode==="mrt-fallback"?1:0,Ae=Gt(K.projMatrix,Js(K.canonical,$.renderWorldCopies)?Z/10:Z,G,ye);if(L(Te),!A)continue;p.setupElevationDraw(Q,A,Ve);const ge=K.toUnwrapped();M&&M.setupShadows(ge,A),d.uploadCommonUniforms(w,A,ge,null,D),A.draw(d,te,B,ae,k,_t.backCCW,Ae,"terrain_raster",p.gridBuffer,ee,le)}}}})(n,this,this.proxySourceCache,t,this._updateTimestamp),this.renderingToTexture=!0,n.gpuTimingDeferredRenderEnd(),t.splice(0,t.length))}renderBatch(t){if(this._drapedRenderBatches.length===0)return t+1;this.renderingToTexture=!0;const n=this.painter,l=this.painter.context,d=this.proxySourceCache,p=this.proxiedCoords[d.id],m=this._drapedRenderBatches.shift(),g=n.style.order,x=[];this._updateFBOs(n.emissiveMode==="mrt-fallback");let w=0;for(const S of p){const A=d.getTileByID(S.proxyTileKey),I=d.proxyCachedFBO[S.key]?d.proxyCachedFBO[S.key][t]:void 0,M=I!==void 0?d.renderCache[I]:this.pool[w++],D=I!==void 0;if(A.texture=M.tex,A.emissiveTexture=M.emissiveTex,D&&!M.dirty){x.push(A.tileID);continue}l.bindFramebuffer.set(M.fb.framebuffer);const L=l.gl;let k;L.drawBuffers(n.emissiveMode==="mrt-fallback"?[L.COLOR_ATTACHMENT0,L.COLOR_ATTACHMENT1]:[L.COLOR_ATTACHMENT0]),this.renderedToTile=!1,M.dirty&&(l.clear({color:u.C.transparent,stencil:0}),M.dirty=!1);for(let B=m.start;B<=m.end;++B){const $=n.style._mergedLayers[g[B]];if($.isHidden(n.transform.zoom))continue;const Z=n.style.getLayerSourceCache($),G=Z?this.proxyToSource[S.key][Z.id]:[S];if(!G)continue;const te=G;l.viewport.set([0,0,M.fb.width,M.fb.height]),k!==(Z?Z.id:null)&&(this._setupStencil(M,G,$,Z),k=Z?Z.id:null),n.renderLayer(n,Z,$,te)}if(L.drawBuffers([L.COLOR_ATTACHMENT0]),this._drapedRenderBatches.length===0)for(const B of this._pendingGroundEffectLayers){const $=n.style._mergedLayers[g[B]];if($.isHidden(n.transform.zoom))continue;const Z=n.style.getLayerSourceCache($),G=Z?this.proxyToSource[S.key][Z.id]:[S];if(!G)continue;const te=G;l.viewport.set([0,0,M.fb.width,M.fb.height]),k!==(Z?Z.id:null)&&(this._setupStencil(M,G,$,Z),k=Z?Z.id:null),n.renderLayer(n,Z,$,te)}this.renderedToTile?(M.dirty=!0,x.push(A.tileID)):D||--w,w===5&&(w=0,this.renderToBackBuffer(x))}return this.renderToBackBuffer(x),this.renderingToTexture=!1,l.bindFramebuffer.set(null),l.viewport.set([0,0,n.width,n.height]),m.end+1}postRender(){}isLayerOrderingCorrect(t){const n=t.order.length;let l=-1,d=n;for(let p=0;p<n;++p)this._style.isLayerDraped(t._mergedLayers[t.order[p]])?l=Math.max(l,p):d=Math.min(d,p);return d>l}getMinElevationBelowMSL(){let t=0;return this._visibleDemTiles.filter(n=>n.dem).forEach(n=>{t=Math.min(t,n.dem.tree.minimums[0])}),t===0?t:(t-30)*this._exaggeration}raycast(t,n,l){if(!this._visibleDemTiles)return null;const d=this._visibleDemTiles.filter(p=>p.dem).map(p=>{const m=p.tileID,g=1<<m.overscaledZ,{x,y:w}=m.canonical,S=x/g,A=(x+1)/g,I=w/g,M=(w+1)/g;return{minx:S,miny:I,maxx:A,maxy:M,t:p.dem.tree.raycastRoot(S,I,A,M,t,n,l),tile:p}});d.sort((p,m)=>(p.t!==null?p.t:Number.MAX_VALUE)-(m.t!==null?m.t:Number.MAX_VALUE));for(const p of d){if(p.t==null)return null;const m=p.tile.dem.tree.raycast(p.minx,p.miny,p.maxx,p.maxy,t,n,l);if(m!=null)return m}return null}_createFBO(){const t=this.painter.context,n=t.gl,l=this.drapeBufferSize;t.activeTexture.set(n.TEXTURE0);const d=new u.T(t,{width:l[0],height:l[1],data:null},n.RGBA8);d.bind(n.LINEAR,n.CLAMP_TO_EDGE);const p=t.createFramebuffer(l[0],l[1],1,null);let m;return p.colorAttachment0.set(d.texture),this._emissiveTexture&&(m=new u.T(t,{width:l[0],height:l[1],data:null},n.R8),m.bind(n.LINEAR,n.CLAMP_TO_EDGE),p.createColorAttachment(t,1),p.colorAttachment1.set(m.texture)),p.depthAttachment=new zi(t,p.framebuffer),this._sharedDepthStencil===void 0?(this._sharedDepthStencil=t.createRenderbuffer(t.gl.DEPTH_STENCIL,l[0],l[1]),this._stencilRef=0,p.depthAttachment.set(this._sharedDepthStencil),t.clear({stencil:0})):p.depthAttachment.set(this._sharedDepthStencil),t.extTextureFilterAnisotropic&&n.texParameterf(n.TEXTURE_2D,t.extTextureFilterAnisotropic.TEXTURE_MAX_ANISOTROPY_EXT,t.extTextureFilterAnisotropicMax),{fb:p,tex:d,emissiveTex:m,dirty:!1}}_updateFBOs(t){if(this._emissiveTexture!==t){for(const n of this.pool)this._updateFBO(n,t);for(const n of this.proxySourceCache.renderCache)this._updateFBO(n,t);this._emissiveTexture=t}}_updateFBO(t,n){const l=t.fb,d=this.painter.context,p=d.gl,m=this.drapeBufferSize;if(n){const g=new u.T(d,{width:m[0],height:m[1],data:null},p.R8);g.bind(p.LINEAR,p.CLAMP_TO_EDGE),t.emissiveTex=g,l.createColorAttachment(d,1),l.colorAttachment1.set(g.texture)}else t.emissiveTex=void 0,l.removeColorAttachment(d,1);t.dirty=!0}_initFBOPool(){for(;this.pool.length<Math.min(5,this.proxyCoords.length);)this.pool.push(this._createFBO())}_shouldDisableRenderCache(){if(this._style.hasLightTransitions())return!0;for(const t in this._style._mergedSourceCaches)if(this._style._mergedSourceCaches[t].hasTransition())return!0;return this._style.order.some(t=>{const n=this._style._mergedLayers[t],l=n.isHidden(this.painter.transform.zoom);return n.type==="hillshade"||n.type==="custom"?!l&&n.shouldRedrape():!l&&n.hasTransition()})}_clearLineLayersFromRenderCache(){let t=!1;for(const l of this._style.getSources())if(l instanceof Wm){t=!0;break}if(!t)return;const n={};for(let l=0;l<this._style.order.length;++l){const d=this._style._mergedLayers[this._style.order[l]],p=this._style.getLayerSourceCache(d);if(!p||n[p.id]||d.isHidden(this.painter.transform.zoom)||d.type!=="line")continue;const m=d.widthExpression(),g=d.emissiveStrengthExpression();if(m instanceof u.ab||g instanceof u.ab){n[p.id]=!0;for(const x of this.proxyCoords){const w=this.proxyToSource[x.key][p.id];if(w)for(const S of w)this._clearRenderCacheForTile(p.id,S)}}}}_clearRasterLayersFromRenderCache(){let t=!1;for(const l in this._style._mergedSourceCaches)if(this._style._mergedSourceCaches[l]._source instanceof gc){t=!0;break}if(!t)return;const n={};for(let l=0;l<this._style.order.length;++l){const d=this._style._mergedLayers[this._style.order[l]],p=this._style.getLayerSourceCache(d);if(!p||n[p.id]||d.isHidden(this.painter.transform.zoom)||d.type!=="raster")continue;const m=d.paint.get("raster-fade-duration");for(const g of this.proxyCoords){const x=this.proxyToSource[g.key][p.id];if(x)for(const w of x){const S=nu(p.getTile(w),p.findLoadedParent(w,0),p,this.painter.transform,m);(S.opacity!==1||S.mix!==0)&&this._clearRenderCacheForTile(p.id,w)}}}}_setupDrapedRenderBatches(){this._style.updateDrapeFirstLayers();const t=this._style.order,n=t.length;if(n===0)return;const l=[];this._pendingGroundEffectLayers=[];let d,p=0,m=this._style._mergedLayers[t[p]];for(;!this._style.isLayerDraped(m)&&m.isHidden(this.painter.transform.zoom)&&++p<n;)m=this._style._mergedLayers[t[p]];for(;p<n;++p){const g=this._style._mergedLayers[t[p]];g.isHidden(this.painter.transform.zoom)||(this._style.isLayerDraped(g)?d===void 0&&(d=p):(g.type==="fill-extrusion"&&this._pendingGroundEffectLayers.push(p),d!==void 0&&(l.push({start:d,end:p-1}),d=void 0)))}if(d!==void 0&&l.push({start:d,end:p-1}),l.length!==0){const g=l.at(-1);this._pendingGroundEffectLayers.every(x=>x>g.end)||u.w("fill-extrusion with flood lighting and/or ground ambient occlusion should be moved to be on top of all draped layers.")}this._drapedRenderBatches=l}_setupRenderCache(t){const n=this.proxySourceCache;if(this._shouldDisableRenderCache()||this.invalidateRenderCache){if(this.invalidateRenderCache=!1,n.renderCache.length>n.renderCachePool.length){const m=Object.values(n.proxyCachedFBO);n.proxyCachedFBO={};for(let g=0;g<m.length;++g){const x=Object.values(m[g]);n.renderCachePool.push(...x)}}return}this._clearRasterLayersFromRenderCache();const l=this.proxyCoords,d=this._tilesDirty;for(let m=l.length-1;m>=0;m--){const g=l[m];if(n.getTileByID(g.key),n.proxyCachedFBO[g.key]!==void 0){const x=t[g.key],w=this.proxyToSource[g.key];let S=0;for(const A in w){const I=w[A],M=x[A];if(!M||M.length!==I.length||I.some((D,L)=>D!==M[L]||d[A]&&Object.hasOwn(d[A],D.key))){S=-1;break}++S}for(const A in n.proxyCachedFBO[g.key])n.renderCache[n.proxyCachedFBO[g.key][A]].dirty=S<0||S!==Object.values(x).length}}const p=[...this._drapedRenderBatches];p.sort((m,g)=>g.end-g.start-(m.end-m.start));for(const m of p)for(const g of l){if(n.proxyCachedFBO[g.key])continue;let x=n.renderCachePool.pop();x===void 0&&n.renderCache.length<50&&(x=n.renderCache.length,n.renderCache.push(this._createFBO())),x!==void 0&&(n.proxyCachedFBO[g.key]={},n.proxyCachedFBO[g.key][m.start]=x,n.renderCache[x].dirty=!0)}this._tilesDirty={}}_setupStencil(t,n,l,d){if(!d||!this._sourceTilesOverlap[d.id])return void(this._overlapStencilType&&(this._overlapStencilType=!1));const p=this.painter.context,m=p.gl;if(n.length<=1)return void(this._overlapStencilType=!1);let g;if(l.isTileClipped())g=n.length,this._overlapStencilMode.test={func:m.EQUAL,mask:255},this._overlapStencilType="Clip";else{if(!(n[0].overscaledZ>n.at(-1).overscaledZ))return void(this._overlapStencilType=!1);g=1,this._overlapStencilMode.test={func:m.GREATER,mask:255},this._overlapStencilType="Mask"}this._stencilRef+g>255&&(p.clear({stencil:0}),this._stencilRef=0),this._stencilRef+=g,this._overlapStencilMode.ref=this._stencilRef,l.isTileClipped()&&this._renderTileClippingMasks(n,this._overlapStencilMode.ref)}clipOrMaskOverlapStencilType(){return this._overlapStencilType==="Clip"||this._overlapStencilType==="Mask"}stencilModeForRTTOverlap(t){return this.renderingToTexture&&this._overlapStencilType?(this._overlapStencilType==="Clip"&&(this._overlapStencilMode.ref=this.painter._tileClippingMaskIDs[t.key]),this._overlapStencilMode):mt.disabled}_renderTileClippingMasks(t,n){const l=this.painter,d=this.painter.context,p=d.gl;l._tileClippingMaskIDs={},d.setColorMode(yt.disabled),d.setDepthMode(ct.disabled);const m=l.getOrCreateProgram("clippingMask");for(const g of t){const x=l._tileClippingMaskIDs[g.key]=--n;m.draw(l,p.TRIANGLES,ct.disabled,new mt({func:p.ALWAYS,mask:0},x,255,p.KEEP,p.KEEP,p.REPLACE),yt.disabled,_t.disabled,wc(g.projMatrix),"$clipping",l.tileExtentBuffer,l.quadTriangleIndexBuffer,l.tileExtentSegments)}}pointCoordinate(t){const n=this.painter.transform;if(t.x<0||t.x>n.width||t.y<0||t.y>n.height)return null;const l=[t.x,t.y,1,1];u.aO(l,l,n.pixelMatrixInverse),u.bB(l,l,1/l[3]),l[0]/=n.worldSize,l[1]/=n.worldSize;const d=n._camera.position,p=u.aL(1,n.center.lat),m=[d[0],d[1],d[2]/p,0],g=u.cA([],l.slice(0,3),m);u.au(g,g);const x=this.raycast(m,g,this._exaggeration);return x!==null&&x?(u.aY(m,m,g,x),m[3]=m[2],m[2]*=p,m):null}_setupProxiedCoordsForOrtho(t,n,l){if(t.getSource()instanceof No)return this._setupProxiedCoordsForImageSource(t,n,l);this._findCoveringTileCache[t.id]=this._findCoveringTileCache[t.id]||{};const d=this.proxiedCoords[t.id]=[],p=this.proxyCoords;for(let x=0;x<p.length;x++){const w=p[x],S=this._findTileCoveringTileID(w,t);if(S){const A=this._createProxiedId(w,S,l[w.key]&&l[w.key][t.id]);d.push(A),this.proxyToSource[w.key][t.id]=[A]}}let m=!1;const g=new Set;for(let x=0;x<n.length;x++){const w=t.getTile(n[x]);if(!w||!w.hasData())continue;const S=this._findTileCoveringTileID(w.tileID,this.proxySourceCache);if(S&&S.tileID.canonical.z!==w.tileID.canonical.z){const A=this.proxyToSource[S.tileID.key][t.id],I=this._createProxiedId(S.tileID,w,l[S.tileID.key]&&l[S.tileID.key][t.id]);A?A.splice(A.length-1,0,I):this.proxyToSource[S.tileID.key][t.id]=[I];const M=this.proxyToSource[S.tileID.key][t.id];g.has(M)||g.add(M),d.push(I),m=!0}}if(this._sourceTilesOverlap[t.id]=m,m)for(const x of g)x.sort((w,S)=>S.overscaledZ-w.overscaledZ)}_setupProxiedCoordsForImageSource(t,n,l){if(!t.getSource().loaded())return;const d=this.proxiedCoords[t.id]=[],p=this.proxyCoords,m=t.getSource(),g=m.tileID;if(!g)return;const x=new u.P(g.x,g.y)._div(1<<g.z),w=m.coordinates.map(u.ac.fromLngLat).reduce((A,I)=>(A.min.x=Math.min(A.min.x,I.x-x.x),A.min.y=Math.min(A.min.y,I.y-x.y),A.max.x=Math.max(A.max.x,I.x-x.x),A.max.y=Math.max(A.max.y,I.y-x.y),A),{min:new u.P(Number.MAX_VALUE,Number.MAX_VALUE),max:new u.P(-Number.MAX_VALUE,-Number.MAX_VALUE)}),S=(A,I)=>{const M=A.wrap+A.canonical.x/(1<<A.canonical.z),D=A.canonical.y/(1<<A.canonical.z),L=u.aj/(1<<A.canonical.z),k=I.wrap+I.canonical.x/(1<<I.canonical.z),B=I.canonical.y/(1<<I.canonical.z);return M+L<k+w.min.x||M>k+w.max.x||D+L<B+w.min.y||D>B+w.max.y};for(let A=0;A<p.length;A++){const I=p[A];for(let M=0;M<n.length;M++){const D=t.getTile(n[M]);if(!D||!D.hasData()||S(I,D.tileID))continue;const L=this._createProxiedId(I,D,l[I.key]&&l[I.key][t.id]),k=this.proxyToSource[I.key][t.id];k?k.push(L):this.proxyToSource[I.key][t.id]=[L],d.push(L)}}}_createProxiedId(t,n,l){let d=this.orthoMatrix;if(l){const p=l.find(m=>m.key===n.tileID.key);if(p)return p}if(n.tileID.key!==t.key){const p=t.canonical.z-n.tileID.canonical.z;let m,g,x;d=u.aS();const w=n.tileID.wrap-t.wrap<<t.overscaledZ;p>0?(m=u.aj>>p,g=m*((n.tileID.canonical.x<<p)-t.canonical.x+w),x=m*((n.tileID.canonical.y<<p)-t.canonical.y)):(m=u.aj<<-p,g=u.aj*(n.tileID.canonical.x-(t.canonical.x+w<<-p)),x=u.aj*(n.tileID.canonical.y-(t.canonical.y<<-p))),u.aK(d,0,m,0,m,0,1),u.aG(d,d,[g,x,0])}return new $h(n.tileID,t.key,d)}_findTileCoveringTileID(t,n){let l=n.getTile(t);if(l&&l.hasData())return l;const d=this._findCoveringTileCache[n.id],p=d[t.key];if(l=p?n.getTileByID(p):null,l&&l.hasData()||p===null)return l;let m=l?l.tileID:t,g=m.overscaledZ;const x=n.getSource().minzoom,w=[];if(!p){const A=n.getSource().maxzoom;if(t.canonical.z>=A){const I=t.canonical.z-A;n.getSource().reparseOverscaled?(g=Math.max(t.canonical.z+2,n.transform.tileZoom),m=new u.br(g,t.wrap,A,t.canonical.x>>I,t.canonical.y>>I)):I!==0&&(g=A,m=new u.br(g,t.wrap,A,t.canonical.x>>I,t.canonical.y>>I))}m.key!==t.key&&(w.push(m.key),l=n.getTile(m))}const S=A=>{w.forEach(I=>{d[I]=A}),w.length=0};for(g-=1;g>=x&&(!l||!l.hasData());g--){l&&S(l.tileID.key);const A=m.calculateScaledKey(g);if(l=n.getTileByID(A),l&&l.hasData())break;const I=d[A];if(I===null)break;I===void 0?w.push(A):l=n.getTileByID(I)}return S(l?l.tileID.key:null),l&&l.hasData()?l:null}findDEMTileFor(t){return this.enabled?this._findTileCoveringTileID(t,this.sourceCache):null}prepareDrawTile(){this.renderedToTile=!0}_clearRenderCacheForTile(t,n){let l=this._tilesDirty[t];l||(l=this._tilesDirty[t]={}),l[n.key]=!0}}function cs(s,t,n){const l=(function(g,x,w){const S=u.aw(x,g),A=u.aw(w,[.2126,.7152,.0722]),I=1-.3*Math.min(A,1),M=u.ai(I,1,Math.min(S+1,1));return u.ai(.92,1,Math.asin(u.as(x[2],-1,1))/Math.PI+.5)*M})(s,[0,0,1],t),d=[0,0,0];u.av(d,n.slice(0,3),l);const p=[0,0,0];u.av(p,t.slice(0,3),s[2]);const m=[0,0,0];return u.cz(m,d,p),u.c7(m)}const $a=["fill","fillOutline","fillPattern","line","linePattern","background","backgroundPattern","hillshade","raster"],Cc=["stars","rainParticle","snowParticle","fillExtrusion","fillExtrusionGroundEffect","building","buildingBloom","elevatedStructures","model","symbol"];class Su{static cacheKey(t,n,l,d){const p=[n];d&&p.push(d.cacheKey);for(const m of l)(typeof m=="string"&&m.includes(" ")||t.usedDefines.has(m))&&p.push(m);return p.join("/")}constructor(t,n,l,d,p,m,g=!1){const x=t.gl;this.program=x.createProgram(),this._context=t,this._fixedUniformsFn=p,this._pending=!0,this._precompiled=g,this.attributes={},this.configuration=d,this.name=n,this.fixedDefines=[...m],g?t._compileStats.precompiled++:t._compileStats.onDemand++;const w=`#version 300 es
3398${(d?d.defines():[]).concat(m.map(k=>`#define ${k}`)).join(`
3399`)}`,S=[w,Oa];for(const k of l.fragmentIncludes)S.push(La[k]);S.push(l.fragmentSource);const A=S.join(`
3400`),I=[w,wm];for(const k of l.vertexIncludes)I.push(La[k]);this.forceManualRenderingForInstanceIDShaders=t.forceManualRenderingForInstanceIDShaders&&l.vertexSource.includes("gl_InstanceID"),this.forceManualRenderingForInstanceIDShaders&&I.push("uniform int u_instanceID;"),I.push(l.vertexSource);let M=I.join(`
3401`);this.forceManualRenderingForInstanceIDShaders&&(M=M.replaceAll("gl_InstanceID","u_instanceID"));const D=x.createShader(x.FRAGMENT_SHADER);if(x.isContextLost())return this.failedToCreate=!0,void(this._pending=!1);x.shaderSource(D,A),x.compileShader(D),x.attachShader(this.program,D);const L=x.createShader(x.VERTEX_SHADER);if(x.isContextLost())return this.failedToCreate=!0,void(this._pending=!1);x.shaderSource(L,M),x.compileShader(L),x.attachShader(this.program,L),x.linkProgram(this.program),this._fragmentShader=D,this._vertexShader=L,t.extParallelShaderCompile?t._pendingPrograms.add(this):this._finalize()}_finalize(){if(!this._pending)return;this._pending=!1;const t=this._context,n=t.gl;t._pendingPrograms.delete(this);const l=u.r.now(),d=n.getProgramParameter(this.program,n.LINK_STATUS),p=u.r.now()-l,m=t._compileStats;if(m.totalStallMs+=p,p>m.maxStallMs&&(m.maxStallMs=p),p>1){m.framesMissed+=Math.floor(60*p/1e3);const w=this.fixedDefines.join(",");m.stalls.push({name:`${this.name}${w?"/":""}${w}`,ms:p,timestamp:l})}if(this._fragmentShader&&(d||u.w(`Fragment shader '${this.name}': ${n.getShaderInfoLog(this._fragmentShader)}`),n.deleteShader(this._fragmentShader),this._fragmentShader=null),this._vertexShader&&(d||u.w(`Vertex shader '${this.name}': ${n.getShaderInfoLog(this._vertexShader)}`),n.deleteShader(this._vertexShader),this._vertexShader=null),!d)return u.w(`Failed to link program '${this.name}': ${n.getProgramInfoLog(this.program)}`),void(this.failedToCreate=!0);this.fixedUniforms=this._fixedUniformsFn(t),this.fixedUniformsEntries=Object.entries(this.fixedUniforms),this.binderUniforms=this.configuration?this.configuration.getUniforms(t):[],this.forceManualRenderingForInstanceIDShaders&&(this.instancingUniforms=(w=>({u_instanceID:new u.b_(w)}))(t));const g=this.fixedDefines,x=this.name;(g.includes("TERRAIN")||g.includes("ELEVATED")||x.includes("symbol")||x.includes("circle"))&&(this.terrainUniforms=(w=>({u_dem:new u.b_(w),u_dem_prev:new u.b_(w),u_dem_tl:new u.b$(w),u_dem_scale:new u.ar(w),u_dem_tl_prev:new u.b$(w),u_dem_scale_prev:new u.ar(w),u_dem_size:new u.ar(w),u_dem_lerp:new u.ar(w),u_exaggeration:new u.ar(w),u_depth:new u.b_(w),u_depth_size_inv:new u.b$(w),u_depth_range_unpack:new u.b$(w),u_occluder_half_size:new u.ar(w),u_occlusion_depth_offset:new u.ar(w),u_meter_to_dem:new u.ar(w),u_label_plane_matrix_inv:new u.ap(w)}))(t)),g.includes("GLOBE")&&(this.globeUniforms=(w=>({u_tile_tl_up:new u.aq(w),u_tile_tr_up:new u.aq(w),u_tile_br_up:new u.aq(w),u_tile_bl_up:new u.aq(w),u_tile_up_scale:new u.ar(w)}))(t)),g.includes("FOG")&&(this.fogUniforms=(w=>({u_fog_matrix:new u.ap(w),u_fog_range:new u.b$(w),u_fog_color:new u.bZ(w),u_fog_horizon_blend:new u.ar(w),u_fog_vertical_limit:new u.b$(w),u_fog_temporal_offset:new u.ar(w),u_frustum_tl:new u.aq(w),u_frustum_tr:new u.aq(w),u_frustum_br:new u.aq(w),u_frustum_bl:new u.aq(w),u_globe_pos:new u.aq(w),u_globe_radius:new u.ar(w),u_globe_transition:new u.ar(w),u_is_globe:new u.b_(w),u_viewport:new u.b$(w)}))(t)),g.includes("RENDER_CUTOFF")&&(this.cutoffUniforms=(w=>({u_cutoff_params:new u.bZ(w)}))(t)),g.includes("LIGHTING_3D_MODE")&&(this.lightsUniforms=(w=>({u_lighting_ambient_color:new u.aq(w),u_lighting_directional_dir:new u.aq(w),u_lighting_directional_color:new u.aq(w),u_ground_radiance:new u.aq(w)}))(t)),g.includes("RENDER_SHADOWS")&&(this.shadowUniforms=(w=>({u_light_matrix_0:new u.ap(w),u_light_matrix_1:new u.ap(w),u_fade_range:new u.b$(w),u_shadow_normal_offset:new u.aq(w),u_shadow_intensity:new u.ar(w),u_shadow_texel_size:new u.ar(w),u_shadow_map_resolution:new u.ar(w),u_shadow_direction:new u.aq(w),u_shadow_bias:new u.aq(w),u_shadowmap_0:new u.b_(w),u_shadowmap_1:new u.b_(w)}))(t))}
3401maybeFinalize(){if(!this._pending)return;const t=this._context.extParallelShaderCompile;t&&!this._context.gl.getProgramParameter(this.program,t.COMPLETION_STATUS_KHR)||this._finalize()}_ensureReady(){this._pending&&(this._finalize(),this._context.sweepPendingPrograms())}getAttributeLocation(t,n){this._ensureReady();let l=this.attributes[n];return l===void 0&&(l=this.attributes[n]=t.getAttribLocation(this.program,n)),l}setTerrainUniformValues(t,n){if(this._ensureReady(),!this.terrainUniforms)return;const l=this.terrainUniforms;if(!this.failedToCreate){t.program.set(this.program);for(const d in n)l[d]&&l[d].set(this.program,d,n[d])}}setGlobeUniformValues(t,n){if(this._ensureReady(),!this.globeUniforms)return;const l=this.globeUniforms;if(!this.failedToCreate){t.program.set(this.program);for(const d in n)l[d]&&l[d].set(this.program,d,n[d])}}setFogUniformValues(t,n){if(this._ensureReady(),!this.fogUniforms)return;const l=this.fogUniforms;if(!this.failedToCreate){t.program.set(this.program);for(const d in n)l[d].set(this.program,d,n[d])}}setCutoffUniformValues(t,n){if(this._ensureReady(),!this.cutoffUniforms)return;const l=this.cutoffUniforms;if(!this.failedToCreate){t.program.set(this.program);for(const d in n)l[d].set(this.program,d,n[d])}}setLightsUniformValues(t,n){if(this._ensureReady(),!this.lightsUniforms)return;const l=this.lightsUniforms;if(!this.failedToCreate){t.program.set(this.program);for(const d in n)l[d].set(this.program,d,n[d])}}setShadowUniformValues(t,n){if(this._ensureReady(),this.failedToCreate||!this.shadowUniforms)return;const l=this.shadowUniforms;t.program.set(this.program);for(const d in n)l[d].set(this.program,d,n[d])}_drawDebugWireframe(t,n,l,d,p,m,g,x,w,S){const A=t.options.wireframe;if(A.terrain===!1&&A.layers2D===!1&&A.layers3D===!1)return;const I=t.context;if(!(!(!A.terrain||this.name!=="terrainRaster"&&this.name!=="globeRaster")||!(!A.layers2D||t._terrain&&t._terrain.renderingToTexture||!$a.includes(this.name))||!(!A.layers3D||!Cc.includes(this.name))))return;const M=I.gl,D=t.wireframeDebugCache.getLinesFromTrianglesBuffer(t.frameCounter,p,I);if(!D)return;const L=[...this.fixedDefines,"DEBUG_WIREFRAME"],k=t.getOrCreateProgram(this.name,{config:this.configuration,defines:L});k._ensureReady(),I.program.set(k.program);const B=(G,te,ee)=>{if(te[G]&&ee[G])for(const le in te[G])ee[G][le]&&ee[G][le].set(ee.program,le,te[G][le].current)};w&&w.setUniforms(k.program,I,k.binderUniforms,g,{zoom:x}),B("fixedUniforms",this,k),B("terrainUniforms",this,k),B("globeUniforms",this,k),B("fogUniforms",this,k),B("lightsUniforms",this,k),B("shadowUniforms",this,k),D.bind(),I.setColorMode(new yt([M.ONE,M.ONE_MINUS_SRC_ALPHA,M.ZERO,M.ONE],u.C.transparent,[!0,!0,!0,!1])),I.setDepthMode(new ct(n.func===M.LESS?M.LEQUAL:n.func,ct.ReadOnly,n.range)),I.setStencilMode(mt.disabled);const $=3*m.primitiveLength*2,Z=3*m.primitiveOffset*2*2;if(this.forceManualRenderingForInstanceIDShaders){const G=S||1;for(let te=0;te<G;++te)k.instancingUniforms.u_instanceID.set(this.program,"u_instanceID",te),M.drawElements(M.LINES,$,M.UNSIGNED_SHORT,Z)}else S&&S>1?M.drawElementsInstanced(M.LINES,$,M.UNSIGNED_SHORT,Z,S):M.drawElements(M.LINES,$,M.UNSIGNED_SHORT,Z);p.bind(),I.program.set(this.program),I.setDepthMode(n),I.setStencilMode(l),I.setColorMode(d)}checkUniforms(t,n,l){if(this.fixedDefines.includes(n)){for(const d of Object.keys(l))if(!l[d].initialized)throw new Error(`Program '${this.name}', from draw '${t}': uniform ${d} not set but required by ${n} being defined`)}}draw(t,n,l,d,p,m,g,x,w,S,A,I,M,D,L,k){const B=t.context,$=B.gl;if(this._ensureReady(),this.failedToCreate)return;B.program.set(this.program),B.setDepthMode(l),B.setStencilMode(d),B.setColorMode(p),B.setCullFace(m);for(const[K,Q]of this.fixedUniformsEntries)Q.set(this.program,K,g[K]);D&&D.setUniforms(this.program,B,this.binderUniforms,I,{zoom:M});const Z={[$.POINTS]:1,[$.LINES]:2,[$.TRIANGLES]:3,[$.LINE_STRIP]:1}[n];this.checkUniforms(x,"RENDER_SHADOWS",this.shadowUniforms);const G=L||[],te=D?D.getPaintVertexBuffers():[],ee=n===$.TRIANGLES&&S,le=k&&k>0?1:void 0;for(const K of A.get()){const Q=K.vaos||(K.vaos={});if((Q[x]||(Q[x]=new Uh)).bind(B,this,w,te,S,K.vertexOffset,G,le),this.forceManualRenderingForInstanceIDShaders){const ae=k||1;for(let de=0;de<ae;++de)this.instancingUniforms.u_instanceID.set(this.program,"u_instanceID",de),S?$.drawElements(n,K.primitiveLength*Z,$.
vendor: 42,269 bytes, line 3401
3401UNSIGNED_SHORT,K.primitiveOffset*Z*2):$.drawArrays(n,K.vertexOffset,K.vertexLength)}else k&&k>1?$.drawElementsInstanced(n,K.primitiveLength*Z,$.UNSIGNED_SHORT,K.primitiveOffset*Z*2,k):S?$.drawElements(n,K.primitiveLength*Z,$.UNSIGNED_SHORT,K.primitiveOffset*Z*2):$.drawArrays(n,K.vertexOffset,K.vertexLength);ee&&this._drawDebugWireframe(t,l,d,p,S,K,I,M,D,k)}}}const Hh=(s,t,n)=>({u_matrix:s,u_emissive_strength:t,u_ground_shadow_factor:n,u_opacity_multiplier:1}),Zh=(s,t,n,l,d,p=0)=>Object.assign(Hh(s,t,d),Hc(n,l,p)),ga=(s,t,n,l)=>({u_matrix:s,u_world:n,u_emissive_strength:t,u_ground_shadow_factor:l,u_opacity_multiplier:1}),Xf=(s,t,n,l,d,p,m=0)=>Object.assign(Zh(s,t,n,l,p,m),{u_world:d}),us=(s,t,n)=>({u_image:s,u_texel_size:t,u_first_pass:n?1:0}),Yf=(s,t,n,l,d,p,m,g)=>{const x=u.aj/p.tileSize;return{u_matrix:s,u_inv_rot_matrix:t,u_camera_to_center_distance:n.getCameraToCenterDistance(g),u_extrude_scale:[n.pixelsToGLUnits[0]/x,n.pixelsToGLUnits[1]/x],u_zoom_transition:l,u_tile_id:m,u_merc_center:d}},Wh=(s,t,n,l)=>({u_matrix:s,u_inv_matrix:t,u_camera_to_center_distance:n.getCameraToCenterDistance(l),u_viewport_size:[n.width,n.height]}),Kf=u.aS(),Jf=(s,t,n,l,d,p,m)=>{const g=s.transform,x=g.projection.name==="globe",w=x?u.eA(g.zoom,t.canonical)*g._pixelsPerMercatorPixel:u.c1(n,1,p),S={u_matrix:t.projMatrix,u_extrude_scale:w,u_intensity:m,u_inv_rot_matrix:Kf,u_merc_center:[0,0],u_tile_id:[0,0,0],u_zoom_transition:0,u_up_dir:[0,0,0]};if(x){S.u_inv_rot_matrix=l,S.u_merc_center=d,S.u_tile_id=[t.canonical.x,t.canonical.y,1<<t.canonical.z],S.u_zoom_transition=u.ah(g.zoom);const A=d[0]*u.aj,I=d[1]*u.aj;S.u_up_dir=g.projection.upVector(new u.bu(0,0,0),A,I)}return S};function sn(s){const t=s.terrain?s.terrain.exaggeration():1;return(s.transform.pitch<15?u.ai(.07,.7,u.as((14-s.transform.zoom)/5,0,1)):.07)*t}const Xh=(s,t,n,l,d,p,m,g,x,w,S,A,I,M,D,L,k,B,$,Z,G,te)=>({u_matrix:t,u_normalize_matrix:n,u_globe_matrix:l,u_merc_matrix:d,u_grid_matrix:p,u_tl_parent:m,u_scale_parent:S,u_fade_t:A.mix,u_opacity:A.opacity*I.paint.get("raster-opacity"),u_image0:0,u_image1:1,u_brightness_low:I.paint.get("raster-brightness-min"),u_brightness_high:I.paint.get("raster-brightness-max"),u_saturation_factor:u.eD(I.paint.get("raster-saturation")),u_contrast_factor:u.eC(I.paint.get("raster-contrast")),u_spin_weights:Qf(I.paint.get("raster-hue-rotate")),u_perspective_transform:M,u_raster_elevation:D,u_zoom_transition:g,u_merc_center:x,u_cutoff_params:w,u_colorization_mix:ph(u.eB,k,$),u_colorization_offset:ru(u.eB,B,$),u_color_ramp:L,u_texture_offset:[G/(Z+2*G),Z/(Z+2*G)],u_texture_res:[Z+2*G,Z+2*G],u_emissive_strength:te,u_zbias_factor:sn(s)});function Qf(s){s*=Math.PI/180;const t=Math.sin(s),n=Math.cos(s);return[(2*n+1)/3,(-Math.sqrt(3)*t-n+1)/3,(Math.sqrt(3)*t-n+1)/3]}const Yh=u.aS(),qa=(s,t,n,l,d,p,m,g,x,w,S,A,I,M,D,L,k,B,$,Z,G,te,ee,le,K)=>{const Q=d.transform,ae={u_is_size_zoom_constant:+(s==="constant"||s==="source"),u_is_size_feature_constant:+(s==="constant"||s==="camera"),u_size_t:t?t.uSizeT:0,u_size:t?t.uSize:0,u_camera_to_center_distance:Q.getCameraToCenterDistance(Z),u_rotate_symbol:+n,u_aspect_ratio:Q.width/Q.height,u_fade_change:d.options.fadeDuration?d.symbolFadeChange:1,u_matrix:p,u_label_plane_matrix:m,u_coord_matrix:g,u_is_text:+w,u_is_sdf:+S,u_elevation_from_sea:x?1:0,u_pitch_with_map:+l,u_texsize:A,u_texsize_icon:I,u_texture:0,u_texture_icon:1,u_tile_id:[0,0,0],u_zoom_transition:0,u_inv_rot_matrix:Yh,u_merc_center:[0,0],u_camera_forward:[0,0,0],u_ecef_origin:[0,0,0],u_tile_matrix:Yh,u_up_vector:[0,-1,0],u_color_adj_mat:ee,u_icon_transition:le||0,u_gamma_scale:S?l?d.transform.getCameraToCenterDistance(Z)*Math.cos(d.terrain?0:d.transform._pitch):1:0,u_device_pixel_ratio:u.r.devicePixelRatio,u_is_halo:1,u_scale_factor:K||1,u_ground_shadow_factor:G,u_inv_matrix:u.aE(u.aS(),m),u_normal_scale:te,u_lutTexture:10,u_spp_fill_np_color:[0,0,0,1],u_spp_halo_np_color:[0,0,0,0],u_spp_opacity:1,u_spp_halo_width:0,u_spp_halo_blur:0,u_spp_emissive_strength:0,u_spp_occlusion_opacity:1,u_spp_z_offset:0,u_spp_translate_rotation:[1,0],u_spp_fill_color_zoom_factor:0,u_spp_halo_color_zoom_factor:0,u_spp_opacity_zoom_factor:0,u_spp_halo_width_zoom_factor:0,u_spp_halo_blur_zoom_factor:0,u_spp_emissive_strength_zoom_factor:0,u_spp_occlusion_opacity_zoom_factor:0,u_spp_z_offset_zoom_factor:0,u_spp_translate_zoom_factor:0,u_spp_zoom_fraction:0,u_opacity_multiplier:1};return Z.name==="globe"&&(ae.u_tile_id=[D.canonical.x,D.canonical.y,1<<D.canonical.z],ae.u_zoom_transition=L,ae.u_inv_rot_matrix=B,ae.u_merc_center=k,ae.u_camera_forward=Q._camera.forward(),ae.u_ecef_origin=u.eE(Q.globeMatrix,D.toUnwrapped()),ae.u_tile_matrix=Q.globeMatrix,ae.u_up_vector=$),ae},Kh=(s,t,n,l)=>({u_matrix:s,u_emissive_strength:t,u_opacity:n,u_color:l}),Jh=(s,t,n,l,d,p,m,g,x)=>Object.assign((function(w,S,A,I,M,D){const{width:L,height:k}=I.imageManager.getPixelSize(S),B=Math.pow(2,D.tileID.overscaledZ),$=D.tileSize*Math.pow(2,I.transform.tileZoom)/B,Z=$*(D.tileID.canonical.x+D.tileID.wrap*B),G=$*D.tileID.canonical.y;return{u_image:0,u_pattern_tl:A.tl,u_pattern_br:A.br,u_texsize:[L,k],u_pattern_size:A.displaySize,u_pattern_units_to_pixels:M?[I.transform.width,-1*I.transform.height]:[1/u.c1(D,1,I.transform.tileZoom),1/u.c1(D,1,I.transform.tileZoom)],u_pixel_coord_upper:[Z>>16,G>>16],u_pixel_coord_lower:[65535&Z,65535&G]}})(0,p,m,l,g,x),{u_matrix:s,u_emissive_strength:t,u_opacity:n}),ep={fillExtrusion:s=>({u_matrix:new u.ap(s),u_lightpos:new u.aq(s),u_lightintensity:new u.ar(s),u_lightcolor:new u.aq(s),u_vertical_gradient:new u.ar(s),u_opacity:new u.ar(s),u_edge_radius:new u.ar(s),u_width_scale:new u.ar(s),u_ao:new u.b$(s),u_height_type:new u.b_(s),u_base_type:new u.b_(s),u_tile_id:new u.aq(s),u_zoom_transition:new u.ar(s),u_inv_rot_matrix:new u.ap(s),u_merc_center:new u.b$(s),u_up_dir:new u.aq(s),u_height_lift:new u.ar(s),u_flood_light_color:new u.aq(s),u_vertical_scale:new u.ar(s),u_flood_light_intensity:new u.ar(s),u_ground_shadow_factor:new u.aq(s),u_front_cutoff_params:new u.aq(s)}),fillExtrusionPattern:s=>({u_matrix:new u.ap(s),u_lightpos:new u.aq(s),u_lightintensity:new u.ar(s),u_lightcolor:new u.aq(s),u_vertical_gradient:new u.ar(s),u_height_factor:new u.ar(s),u_edge_radius:new u.ar(s),u_width_scale:new u.ar(s),u_ao:new u.b$(s),u_height_type:new u.b_(s),u_base_type:new u.b_(s),u_tile_id:new u.aq(s),u_zoom_transition:new u.ar(s),u_inv_rot_matrix:new u.ap(s),u_merc_center:new u.b$(s),u_up_dir:new u.aq(s),u_height_lift:new u.ar(s),u_image:new u.b_(s),u_texsize:new u.b$(s),u_pixel_coord_upper:new u.b$(s),u_pixel_coord_lower:new u.b$(s),u_tile_units_to_pixels:new u.ar(s),u_opacity:new u.ar(s),u_pattern_transition:new u.ar(s)}),fill:s=>({u_matrix:new u.ap(s),u_emissive_strength:new u.ar(s),u_ground_shadow_factor:new u.aq(s),u_opacity_multiplier:new u.ar(s)}),fillPattern:s=>({u_matrix:new u.ap(s),u_emissive_strength:new u.ar(s),u_image:new u.b_(s),u_texsize:new u.b$(s),u_pixel_coord_upper:new u.b$(s),u_pixel_coord_lower:new u.b$(s),u_tile_units_to_pixels:new u.ar(s),u_ground_shadow_factor:new u.aq(s),u_pattern_transition:new u.ar(s),u_opacity_multiplier:new u.ar(s)}),fillOutline:s=>({u_matrix:new u.ap(s),u_emissive_strength:new u.ar(s),u_world:new u.b$(s),u_ground_shadow_factor:new u.aq(s),u_opacity_multiplier:new u.ar(s)}),fillOutlinePattern:s=>({u_matrix:new u.ap(s),u_emissive_strength:new u.ar(s),u_world:new u.b$(s),u_image:new u.b_(s),u_texsize:new u.b$(s),u_pixel_coord_upper:new u.b$(s),u_pixel_coord_lower:new u.b$(s),u_tile_units_to_pixels:new u.ar(s),u_ground_shadow_factor:new u.aq(s),u_pattern_transition:new u.ar(s),u_opacity_multiplier:new u.ar(s)}),lineBlendComposite:s=>({u_image:new u.b_(s),u_opacity:new u.ar(s),u_blend_mode:new u.b_(s),u_max_density:new u.ar(s)}),lineBlendReduce:s=>({u_image:new u.b_(s),u_texel_size:new u.b$(s),u_first_pass:new u.b_(s)}),circle:u.eH,collisionBox:s=>({u_matrix:new u.ap(s),u_inv_rot_matrix:new u.ap(s),u_camera_to_center_distance:new u.ar(s),u_extrude_scale:new u.b$(s),u_zoom_transition:new u.ar(s),u_merc_center:new u.b$(s),u_tile_id:new u.aq(s)}),collisionCircle:s=>({u_matrix:new u.ap(s),u_inv_matrix:new u.ap(s),u_camera_to_center_distance:new u.ar(s),u_viewport_size:new u.b$(s)}),debug:s=>({u_color:new u.c9(s),u_matrix:new u.ap(s),u_overlay:new u.b_(s),u_overlay_scale:new u.ar(s)}),clippingMask:s=>({u_matrix:new u.ap(s)}),heatmap:s=>({u_extrude_scale:new u.ar(s),u_intensity:new u.ar(s),u_matrix:new u.ap(s),u_inv_rot_matrix:new u.ap(s),u_merc_center:new u.b$(s),u_tile_id:new u.aq(s),u_zoom_transition:new u.ar(s),u_up_dir:new u.aq(s)}),heatmapTexture:s=>({u_image:new u.b_(s),u_color_ramp:new u.b_(s),u_opacity:new u.ar(s)}),hillshade:s=>({u_matrix:new u.ap(s),u_image:new u.b_(s),u_latrange:new u.b$(s),u_light:new u.b$(s),u_shadow:new u.c9(s),u_highlight:new u.c9(s),u_emissive_strength:new u.ar(s),u_accent:new u.c9(s)}),hillshadePrepare:s=>({u_matrix:new u.ap(s),u_image:new u.b_(s),u_dimension:new u.b$(s),u_zoom:new u.ar(s)}),line:u.eG,linePattern:u.eF,raster:s=>({u_matrix:new u.ap(s),u_normalize_matrix:new u.ap(s),u_globe_matrix:new u.ap(s),u_merc_matrix:new u.ap(s),u_grid_matrix:new u.cN(s),u_tl_parent:new u.b$(s),u_scale_parent:new u.ar(s),u_fade_t:new u.ar(s),u_opacity:new u.ar(s),u_image0:new u.b_(s),u_image1:new u.b_(s),u_brightness_low:new u.ar(s),u_brightness_high:new u.ar(s),u_saturation_factor:new u.ar(s),u_contrast_factor:new u.ar(s),u_spin_weights:new u.aq(s),u_perspective_transform:new u.b$(s),u_raster_elevation:new u.ar(s),u_zoom_transition:new u.ar(s),u_merc_center:new u.b$(s),u_cutoff_params:new u.bZ(s),u_colorization_mix:new u.bZ(s),u_colorization_offset:new u.ar(s),u_color_ramp:new u.b_(s),u_texture_offset:new u.b$(s),u_texture_res:new u.b$(s),u_emissive_strength:new u.ar(s),u_zbias_factor:new u.ar(s)}),symbol:s=>({u_is_size_zoom_constant:new u.b_(s),u_is_size_feature_constant:new u.b_(s),u_size_t:new u.ar(s),u_size:new u.ar(s),u_camera_to_center_distance:new u.ar(s),u_rotate_symbol:new u.b_(s),u_aspect_ratio:new u.ar(s),u_fade_change:new u.ar(s),u_matrix:new u.ap(s),u_label_plane_matrix:new u.ap(s),u_coord_matrix:new u.ap(s),u_is_text:new u.b_(s),u_is_sdf:new u.b_(s),u_elevation_from_sea:new u.b_(s),u_pitch_with_map:new u.b_(s),u_texsize:new u.b$(s),u_texsize_icon:new u.b$(s),u_texture:new u.b_(s),u_texture_icon:new u.b_(s),u_gamma_scale:new u.ar(s),u_device_pixel_ratio:new u.ar(s),u_tile_id:new u.aq(s),u_zoom_transition:new u.ar(s),u_inv_rot_matrix:new u.ap(s),u_merc_center:new u.b$(s),u_camera_forward:new u.aq(s),u_tile_matrix:new u.ap(s),u_up_vector:new u.aq(s),u_ecef_origin:new u.aq(s),u_is_halo:new u.b_(s),u_icon_transition:new u.ar(s),u_color_adj_mat:new u.ap(s),u_scale_factor:new u.ar(s),u_ground_shadow_factor:new u.aq(s),u_inv_matrix:new u.ap(s),u_normal_scale:new u.ar(s),u_lutTexture:new u.b_(s),u_spp_fill_np_color:new u.bZ(s),u_spp_halo_np_color:new u.bZ(s),u_spp_opacity:new u.ar(s),u_spp_halo_width:new u.ar(s),u_spp_halo_blur:new u.ar(s),u_spp_emissive_strength:new u.ar(s),u_spp_occlusion_opacity:new u.ar(s),u_spp_z_offset:new u.ar(s),u_spp_translate_rotation:new u.b$(s),u_spp_fill_color_zoom_factor:new u.ar(s),u_spp_halo_color_zoom_factor:new u.ar(s),u_spp_opacity_zoom_factor:new u.ar(s),u_spp_halo_width_zoom_factor:new u.ar(s),u_spp_halo_blur_zoom_factor:new u.ar(s),u_spp_emissive_strength_zoom_factor:new u.ar(s),u_spp_occlusion_opacity_zoom_factor:new u.ar(s),u_spp_z_offset_zoom_factor:new u.ar(s),u_spp_translate_zoom_factor:new u.ar(s),u_spp_zoom_fraction:new u.ar(s),u_opacity_multiplier:new u.ar(s)}),background:s=>({u_matrix:new u.ap(s),u_emissive_strength:new u.ar(s),u_opacity:new u.ar(s),u_color:new u.c9(s)}),backgroundPattern:s=>({u_matrix:new u.ap(s),u_emissive_strength:new u.ar(s),u_opacity:new u.ar(s),u_image:new u.b_(s),u_pattern_tl:new u.b$(s),u_pattern_br:new u.b$(s),u_texsize:new u.b$(s),u_pattern_size:new u.b$(s),u_pixel_coord_upper:new u.b$(s),u_pixel_coord_lower:new u.b$(s),u_pattern_units_to_pixels:new u.b$(s)}),terrainRaster:s=>({u_matrix:new u.ap(s),u_image0:new u.b_(s),u_image1:new u.b_(s),u_skirt_height:new u.ar(s),u_ground_shadow_factor:new u.aq(s),u_emissive_texture_available:new u.ar(s)}),skybox:s=>({u_matrix:new u.ap(s),u_sun_direction:new u.aq(s),u_cubemap:new u.b_(s),u_opacity:new u.ar(s),u_temporal_offset:new u.ar(s)}),skyboxGradient:s=>({u_matrix:new u.ap(s),u_color_ramp:new u.b_(s),u_center_direction:new u.aq(s),u_radius:new u.ar(s),u_opacity:new u.ar(s),u_temporal_offset:new u.ar(s)}),skyboxCapture:s=>({u_matrix_3f:new u.cN(s),u_sun_direction:new u.aq(s),u_sun_intensity:new u.ar(s),u_color_tint_r:new u.bZ(s),u_color_tint_m:new u.bZ(s),u_luminance:new u.ar(s)}),globeRaster:s=>({u_proj_matrix:new u.ap(s),u_globe_matrix:new u.ap(s),u_normalize_matrix:new u.ap(s),u_merc_matrix:new u.ap(s),u_zoom_transition:new u.ar(s),u_merc_center:new u.b$(s),u_image0:new u.b_(s),u_image1:new u.b_(s),u_grid_matrix:new u.cN(s),u_skirt_height:new u.ar(s),u_far_z_cutoff:new u.ar(s),u_frustum_tl:new u.aq(s),u_frustum_tr:new u.aq(s),u_frustum_br:new u.aq(s),u_frustum_bl:new u.aq(s),u_globe_pos:new u.aq(s),u_globe_radius:new u.ar(s),u_viewport:new u.b$(s),u_emissive_texture_available:new u.ar(s)}),globeAtmosphere:s=>({u_frustum_tl:new u.aq(s),u_frustum_tr:new u.aq(s),u_frustum_br:new u.aq(s),u_frustum_bl:new u.aq(s),u_horizon:new u.ar(s),u_transition:new u.ar(s),u_fadeout_range:new u.ar(s),u_atmosphere_fog_color:new u.bZ(s),u_high_color:new u.bZ(s),u_space_color:new u.bZ(s),u_temporal_offset:new u.ar(s),u_horizon_angle:new u.ar(s)}),stars:s=>({u_matrix:new u.ap(s),u_up:new u.aq(s),u_right:new u.aq(s),u_intensity_multiplier:new u.ar(s)}),occlusion:s=>({u_matrix:new u.ap(s),u_anchorPos:new u.aq(s),u_screenSizePx:new u.b$(s),u_occluderSizePx:new u.b$(s),u_color:new u.bZ(s)})};class xo{constructor(t,n,l,d){this.id=xo.uniqueIdxCounter,xo.uniqueIdxCounter++,this.context=t;const p=t.gl;this.buffer=p.createBuffer(),this.dynamicDraw=!!l,this.context.unbindVAO(),t.bindElementBuffer.set(this.buffer),p.bufferData(p.ELEMENT_ARRAY_BUFFER,n.arrayBuffer,this.dynamicDraw?p.DYNAMIC_DRAW:p.STATIC_DRAW),this.dynamicDraw||d||n.destroy()}bind(){this.context.bindElementBuffer.set(this.buffer)}updateData(t){this.id=xo.uniqueIdxCounter,xo.uniqueIdxCounter++;const n=this.context.gl;this.context.unbindVAO(),this.bind(),n.bufferSubData(n.ELEMENT_ARRAY_BUFFER,0,t.arrayBuffer)}destroy(){this.buffer&&(this.context.gl.deleteBuffer(this.buffer),delete this.buffer)}}xo.uniqueIdxCounter=0;const tp={Int8:"BYTE",Uint8:"UNSIGNED_BYTE",Int16:"SHORT",Uint16:"UNSIGNED_SHORT",Int32:"INT",Uint32:"UNSIGNED_INT",Float32:"FLOAT"};class Qh{constructor(t,n,l,d,p,m){this.length=n.length,this.attributes=l,this.itemSize=n.bytesPerElement,this.dynamicDraw=d,this.instanceCount=m,this.context=t;const g=t.gl;this.buffer=g.createBuffer(),t.bindVertexBuffer.set(this.buffer),g.bufferData(g.ARRAY_BUFFER,n.arrayBuffer,this.dynamicDraw?g.DYNAMIC_DRAW:g.STATIC_DRAW),this.dynamicDraw||p||n.destroy()}bind(){this.context.bindVertexBuffer.set(this.buffer)}updateData(t){const n=this.context.gl;this.bind(),n.bufferSubData(n.ARRAY_BUFFER,0,t.arrayBuffer)}enableAttributes(t,n){for(const l of this.attributes){const d=n.getAttributeLocation(t,l.name);d!==-1&&t.enableVertexAttribArray(d)}}setVertexAttribPointers(t,n,l){for(const d of this.attributes){const p=n.getAttributeLocation(t,d.name);if(p!==-1){const m=d.offset+this.itemSize*(l||0);d.type==="Float32"?t.vertexAttribPointer(p,d.components,t.FLOAT,!1,this.itemSize,m):t.vertexAttribIPointer(p,d.components,t[tp[d.type]],this.itemSize,m)}}}setVertexAttribDivisor(t,n,l){for(let d=0;d<this.attributes.length;d++){const p=n.getAttributeLocation(t,this.attributes[d].name);p!==-1&&this.instanceCount&&this.instanceCount>0&&t.vertexAttribDivisor(p,l)}}destroy(){this.buffer&&(this.context.gl.deleteBuffer(this.buffer),delete this.buffer)}}class Ha{constructor(t,n,l,d,p){this.context=t,this.width=n,this.height=l;const m=this.framebuffer=t.gl.createFramebuffer();d>0&&(this.colorAttachment0=new jh(t,m,0)),d>1&&(this.colorAttachment1=new jh(t,m,1)),p&&(this.depthAttachmentType=p,this.depthAttachment=p==="renderbuffer"?new Ac(t,m):new cy(t,m))}static createWithTexture(t,n,l,d,p){const m=t.gl;if(t.activeTexture.set(m.TEXTURE1),t.viewport.set([0,0,l,d]),n&&n.width===l&&n.height===d)return m.bindTexture(m.TEXTURE_2D,n.colorAttachment0.get()),t.bindFramebuffer.set(n.framebuffer),n;n&&n.destroy();const g=t.extRenderToTextureHalfFloat||t.extColorBufferFloat?t.gl.RGBA16F:t.gl.RGBA8,x=new u.T(t,{width:l,height:d,data:null},g);x.bind(m.LINEAR,m.CLAMP_TO_EDGE);const w=t.createFramebuffer(l,d,1,null);if(w.format=g,w.colorAttachment0.set(x.texture),p){const S=t.createRenderbuffer(m.DEPTH24_STENCIL8,l,d);t.bindFramebuffer.set(w.framebuffer),m.framebufferRenderbuffer(m.FRAMEBUFFER,m.DEPTH_STENCIL_ATTACHMENT,m.RENDERBUFFER,S),w._stencilRbo=S}return w}createColorAttachment(t,n){n===0?this.colorAttachment0=new jh(t,this.framebuffer,0):n===1&&(this.colorAttachment1=new jh(t,this.framebuffer,1))}removeColorAttachment(t,n){const l=this.context.gl;let d;n===0?(d=this.colorAttachment0.get(),this.colorAttachment0=void 0):n===1&&(d=this.colorAttachment1.get(),this.colorAttachment1=void 0),d&&l.deleteTexture(d)}destroy(){const t=this.context.gl;if(this.colorAttachment0){const n=this.colorAttachment0.get();n&&t.deleteTexture(n)}if(this.colorAttachment1){const n=this.colorAttachment1.get();n&&t.deleteTexture(n)}if(this.depthAttachment&&this.depthAttachmentType)if(this.depthAttachmentType==="renderbuffer"){const n=this.depthAttachment.get();n&&t.deleteRenderbuffer(n)}else{const n=this.depthAttachment.get();n&&t.deleteTexture(n)}this._stencilRbo&&(t.deleteRenderbuffer(this._stencilRbo),this._stencilRbo=null),t.deleteFramebuffer(this.framebuffer)}}class ed{constructor(t,n){this.gl=t,this._pendingPrograms=new Set,this._compileStats={precompiled:0,onDemand:0,totalStallMs:0,maxStallMs:0,framesMissed:0,stalls:[]},this.clearColor=new c_(this),this.clearDepth=new kf(this),this.clearStencil=new Bf(this),this.colorMask=new Zn(this),this.depthMask=new Pl(this),this.stencilMask=new Nf(this),this.stencilFunc=new os(this),this.stencilOp=new ss(this),this.stencilTest=new Ec(this),this.depthRange=new Rl(this),this.depthTest=new Ic(this),this.depthFunc=new Vf(this),this.blend=new ui(this),this.blendFunc=new Ga(this),this.blendColor=new Uf(this),this.blendEquation=new Wn(this),this.cullFace=new jf(this),this.cullFaceSide=new as(this),this.frontFace=new u_(this),this.program=new Dl(this),this.activeTexture=new h_(this),this.viewport=new yo(this),this.bindFramebuffer=new kn(this),this.bindRenderbuffer=new Gf(this),this.bindTexture=new d_(this),this.bindVertexBuffer=new $f(this),this.bindElementBuffer=new ay(this),this.bindVertexArrayOES=new qf(this),this.pixelStoreUnpack=new f_(this),this.pixelStoreUnpackPremultiplyAlpha=new ly(this),this.pixelStoreUnpackFlipY=new ls(this),this.options=n?{...n}:{},this.options.extTextureFilterAnisotropicForceOff||(this.extTextureFilterAnisotropic=t.getExtension("EXT_texture_filter_anisotropic")||t.getExtension("MOZ_EXT_texture_filter_anisotropic")||t.getExtension("WEBKIT_EXT_texture_filter_anisotropic"),this.extTextureFilterAnisotropic&&(this.extTextureFilterAnisotropicMax=t.getParameter(this.extTextureFilterAnisotropic.MAX_TEXTURE_MAX_ANISOTROPY_EXT))),this.extDebugRendererInfo=t.getExtension("WEBGL_debug_renderer_info"),this.extDebugRendererInfo&&(this.renderer=t.getParameter(this.extDebugRendererInfo.UNMASKED_RENDERER_WEBGL),this.vendor=t.getParameter(this.extDebugRendererInfo.UNMASKED_VENDOR_WEBGL)),this.forceManualRenderingForInstanceIDShaders=n&&!!n.forceManualRenderingForInstanceIDShaders||this.renderer&&this.renderer.includes("PowerVR"),this.options.extTextureFloatLinearForceOff||(this.extTextureFloatLinear=t.getExtension("OES_texture_float_linear")),this.extRenderToTextureHalfFloat=t.getExtension("EXT_color_buffer_half_float"),this.extColorBufferFloat=t.getExtension("EXT_color_buffer_float"),this.extTimerQuery=t.getExtension("EXT_disjoint_timer_query_webgl2"),this.maxTextureSize=t.getParameter(t.MAX_TEXTURE_SIZE),this.maxUniformBlockSize=Math.min(t.getParameter(t.MAX_UNIFORM_BLOCK_SIZE),32768),this.maxUniformBufferBindings=t.getParameter(t.MAX_UNIFORM_BUFFER_BINDINGS),this.extBlendFuncExtended=t.getExtension("WEBGL_blend_func_extended"),this.extParallelShaderCompile=t.getExtension("KHR_parallel_shader_compile")}sweepPendingPrograms(){if(this._pendingPrograms.size!==0)for(const t of this._pendingPrograms)t.maybeFinalize()}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.bindVertexArrayOES.dirty=!0,this.pixelStoreUnpack.dirty=!0,this.pixelStoreUnpackPremultiplyAlpha.dirty=!0,this.pixelStoreUnpackFlipY.dirty=!0}createIndexBuffer(t,n,l){return new xo(this,t,n,l)}createVertexBuffer(t,n,l,d,p){return new Qh(this,t,n,l,d,p)}createRenderbuffer(t,n,l){const d=this.gl,p=d.createRenderbuffer();return this.bindRenderbuffer.set(p),d.renderbufferStorage(d.RENDERBUFFER,t,n,l),this.bindRenderbuffer.set(null),p}createFramebuffer(t,n,l,d){return new Ha(this,t,n,l,d)}clear({color:t,depth:n,stencil:l,colorMask:d}){const p=this.gl;let m=0;t&&(m|=p.COLOR_BUFFER_BIT,this.clearColor.set(t.toNonPremultipliedRenderColor(null)),this.colorMask.set(d||[!0,!0,!0,!0])),n!==void 0&&(m|=p.DEPTH_BUFFER_BIT,this.depthRange.set([0,1]),this.clearDepth.set(n),this.depthMask.set(!0)),l!==void 0&&(m|=p.STENCIL_BUFFER_BIT,this.clearStencil.set(l),this.stencilMask.set(255)),p.clear(m)}setCullFace(t){t.enable===!1?this.cullFace.set(!1):(this.cullFace.set(!0),this.cullFaceSide.set(t.mode),this.frontFace.set(t.frontFace))}setDepthMode(t){t.func!==this.gl.ALWAYS||t.mask?(this.depthTest.set(!0),this.depthFunc.set(t.func),this.depthMask.set(t.mask),this.depthRange.set(t.range)):this.depthTest.set(!1)}setStencilMode(t){t.test.func!==this.gl.ALWAYS||t.mask?(this.stencilTest.set(!0),this.stencilMask.set(t.mask),this.stencilOp.set([t.fail,t.depthFail,t.pass]),this.stencilFunc.set({func:t.test.func,ref:t.ref,mask:t.test.mask})):this.stencilTest.set(!1)}setColorMode(t){u.b7(t.blendFunction,yt.Replace)?this.blend.set(!1):(this.blend.set(!0),this.blendFunc.set(t.blendFunction),this.blendColor.set(t.blendColor),t.blendEquation?this.blendEquation.set(t.blendEquation):this.blendEquation.setDefault()),this.colorMask.set(t.mask)}unbindVAO(){this.bindVertexArrayOES.set(null)}}let Ll;function Eu(s,t,n,l,d,p,m){const g=s.context,x=g.gl,w=s.transform,S=[u.a_(w.center.lng),u.a$(w.center.lat)],A=n.layout.get("symbol-placement"),I=n.layout.get("text-variable-anchor"),M=n.layout.get("icon-rotation-alignment")==="map",D=n.layout.get("text-rotation-alignment")==="map",L=A!=="point",k=[];let B=0,$=0;for(let K=0;K<l.length;K++){const Q=l[K],ae=t.getTile(Q),de=ae.getBucket(n);if(!de)continue;const fe=de.getProjection().createInversionMatrix(w,Q.canonical),be=[],Te=We(Q,de,w),Ve=!m&&M&&L,ye=m&&D&&L,Ae=I&&de.hasTextData(),ge=de.hasIconTextFit()&&Ae&&de.hasIconData(),Fe=Ve||ye||m&&Ae||ge,Re=de.projection.name==="globe",De=Re?u.ah(w.zoom):0;Re&&(be.push("PROJECTION_GLOBE_VIEW"),Fe&&be.push("PROJECTED_POS_ON_VIEWPORT"));const Ke=s.getOrCreateProgram("collisionBox",{defines:be});let Be=Te;d[0]===0&&d[1]===0||(Be=s.translatePosMatrix(Te,ae,d,p));const Ge=m?de.textCollisionBox:de.iconCollisionBox,Ze=de.collisionCircleArray;if(Ze.length>0){const ot=u.aS(),at=Be;u.bI(ot,de.placementInvProjMatrix,w.glCoordMatrix),u.bI(ot,ot,de.placementViewportMatrix),k.push({circleArray:Ze,circleOffset:$,transform:at,invTransform:ot,projection:de.getProjection()}),B+=Ze.length/4,$=B}if(!Ge)continue;s.terrain&&s.terrain.setupElevationDraw(ae,Ke);const tt=Re?[Q.canonical.x,Q.canonical.y,1<<Q.canonical.z]:[0,0,0];Ke.draw(s,x.LINES,ct.disabled,mt.disabled,s.colorModeForRenderPass(),_t.disabled,Yf(Be,fe,w,De,S,ae,tt,de.getProjection()),n.id,Ge.layoutVertexBuffer,Ge.indexBuffer,Ge.segments,null,w.zoom,null,[Ge.collisionVertexBuffer,Ge.collisionVertexBufferExt])}if(!m||!k.length)return;const Z=s.getOrCreateProgram("collisionCircle"),G=new u.eI;G.resize(4*B),G._trim();let te=0;for(const K of k)for(let Q=0;Q<K.circleArray.length/4;Q++){const ae=4*Q,de=K.circleArray[ae+0],fe=K.circleArray[ae+1],be=K.circleArray[ae+2],Te=K.circleArray[ae+3];G.emplace(te++,de,fe,be,Te,0),G.emplace(te++,de,fe,be,Te,1),G.emplace(te++,de,fe,be,Te,2),G.emplace(te++,de,fe,be,Te,3)}(!Ll||Ll.length<2*B)&&(Ll=(function(K){const Q=2*K,ae=new u.cp;ae.resize(Q),ae._trim();for(let de=0;de<Q;de++){const fe=6*de;ae.uint16[fe+0]=4*de+0,ae.uint16[fe+1]=4*de+1,ae.uint16[fe+2]=4*de+2,ae.uint16[fe+3]=4*de+2,ae.uint16[fe+4]=4*de+3,ae.uint16[fe+5]=4*de+0}return ae})(B));const ee=g.createIndexBuffer(Ll,!0),le=g.createVertexBuffer(G,u.eJ.members,!0);for(const K of k){const Q=Wh(K.transform,K.invTransform,w,K.projection);Z.draw(s,x.TRIANGLES,ct.disabled,mt.disabled,s.colorModeForRenderPass(),_t.disabled,Q,n.id,le,ee,u.cr.simpleSegment(0,2*K.circleOffset,K.circleArray.length,K.circleArray.length/2),null,w.zoom)}le.destroy(),ee.destroy()}const Iu=u.aS();function ip(s){const t=s._camera.getWorldToCamera(s.worldSize,1),n=u.aP([],t,s.globeMatrix);u.aE(n,n);const l=[0,0,0],d=[0,1,0,0];return u.aO(d,d,n),l[0]=d[0],l[1]=d[1],l[2]=d[2],u.au(l,l),l}function p_({width:s,height:t,anchor:n,textOffset:l,textScale:d},p){const{horizontalAlign:m,verticalAlign:g}=u.d$(n),x=-(m-.5)*s,w=-(g-.5)*t,S=u.e0(n,l);return new u.P((x/d+S[0])*p,(w/d+S[1])*p)}function m_(s,t,n,l,d,p,m,g,x,w){const S=s.text.placedSymbolArray,A=s.text.dynamicLayoutVertexArray,I=s.icon.dynamicLayoutVertexArray,M={},D=s.getProjection(),L=Xe(m,D,d),k=d.elevation,B=D.upVectorScale(m.canonical,d.center.lat,d.worldSize).metersToTile;A.clear();for(let $=0;$<S.length;$++){const Z=S.get($),{tileAnchorX:G,tileAnchorY:te,numGlyphs:ee}=Z,le=Z.hidden||!Z.crossTileID||s.allowVerticalPlacement&&!Z.placedOrientation?null:l[Z.crossTileID];if(le){let K=0,Q=0,ae=0;const de=s.elevationType==="road";if(k||de){const Re=new u.P(G,te);let De=0;if(de&&s.hdExt){const Ze=s.symbolInstances.get(s.text.symbolInstanceIndices[$]);if(s.hdExt.isCrossTileRoadElevation(Ze.elevationFeatureIndex,m.canonical)){const tt=s.hdExt.getRoadFeatureHeightForPlacedSymbol(s,s.text,$,Re,m.canonical);De=tt!==null?tt:0}else{const tt=s.hdExt.getElevationFeatureForPlacedSymbol(s,s.text,$);De=u.e7.getAtTileOffset(m,Re,k,tt!==void 0?tt:null)}}else De=u.e7.getAtTileOffset(m,Re,k,null);const[Ke,Be,Ge]=D.upVector(m.canonical,G,te);K=De*Ke*B,Q=De*Be*B,ae=De*Ge*B}let[fe,be,Te,Ve]=oo(Z.projectedAnchorX+K,Z.projectedAnchorY+Q,Z.projectedAnchorZ+ae,n?L:p);const ye=Ql(d.getCameraToCenterDistance(D),Ve);let Ae=u.b1(s.textSizeData,x,Z)*ye/u.e9;n&&(Ae*=s.tilePixelRatio/g);const ge=p_(le,Ae);n?({x:fe,y:be,z:Te}=D.projectTilePoint(G+ge.x,te+ge.y,m.canonical),[fe,be,Te]=oo(fe+K,be+Q,Te+ae,p)):(t&&ge._rotate(-d.angle),fe+=ge.x,be+=ge.y,Te=0);const Fe=s.allowVerticalPlacement&&Z.placedOrientation===u.b0.vertical?Math.PI/2:0;for(let Re=0;Re<ee;Re++)u.b3(A,fe,be,Te,Fe);w&&Z.associatedIconIndex>=0&&(M[Z.associatedIconIndex]={x:fe,y:be,z:Te,angle:Fe})}else rn(ee,A)}if(w){I.clear();const $=s.icon.placedSymbolArray;for(let Z=0;Z<$.length;Z++){const G=$.get(Z),{numGlyphs:te}=G,ee=M[Z];if(G.hidden||!ee)rn(te,I);else{const{x:le,y:K,z:Q,angle:ae}=ee;for(let de=0;de<te;de++)u.b3(I,le,K,Q,ae)}}s.icon.dynamicLayoutVertexBuffer.updateData(I)}s.text.dynamicLayoutVertexBuffer.updateData(A)}function td(s,t,n,l,d,p,m={}){const g=n.paint.get("icon-translate"),x=n.paint.get("text-translate"),w=n.paint.get("icon-translate-anchor"),S=n.paint.get("text-translate-anchor"),A=n.layout.get("icon-rotation-alignment"),I=n.layout.get("text-rotation-alignment"),M=n.layout.get("icon-pitch-alignment"),D=n.layout.get("text-pitch-alignment"),L=n.layout.get("icon-keep-upright"),k=n.layout.get("text-keep-upright"),B=n.paint.get("icon-color-saturation"),$=n.paint.get("icon-color-contrast"),Z=n.paint.get("icon-color-brightness-min"),G=n.paint.get("icon-color-brightness-max"),te=n.layout.get("symbol-elevation-reference")==="sea",ee=n.layout.get("icon-image-use-theme")==="none",le=s.context,K=le.gl,Q=s.transform,ae=A==="map",de=I==="map",fe=M==="map",be=D==="map",Te=n.layout.get("symbol-sort-key").constantOr(1)!==void 0;let Ve=!1;const ye=s.depthModeForSublayer(0,ct.ReadOnly),Ae=new ct(s.context.gl.LEQUAL,ct.ReadOnly,s.depthRangeFor3D),ge=[u.a_(Q.center.lng),u.a$(Q.center.lat)],Fe=n.layout.get("text-variable-anchor"),Re=Q.projection.name==="globe",De=[],Ke=[0,-1,0];for(const Be of l){const Ge=t.getTile(Be),Ze=Ge.getBucket(n);if(!Ze||Ze.projection.name==="mercator"&&Re||Ze.fullyClipped)continue;const tt=Ze.projection.name==="globe",ot=tt?u.ah(Q.zoom):0,at=Xe(Be,Ze.getProjection(),Q),ut=Q.calculatePixelsToTileUnitsMatrix(Ge),bt=Fe&&Ze.hasTextData(),pt=Ze.hasIconTextFit()&&bt&&Ze.hasIconData(),Lt=Ze.getProjection().createInversionMatrix(Q,Be.canonical),kt=(1<<Ge.tileID.canonical.z)*u.aj/s.transform.worldSize,gt=$t=>{let Mt=[0,0,0];if($t){const Ii=s.style.directionalLight,wi=s.style.ambientLight;Ii&&wi&&(Mt=pl(s.style,Ii,wi))}return Mt},Pt=$t=>{const Mt=Math.floor(s.context.maxUniformBlockSize/4),Ii=Math.floor(Mt/4);$t.push(`MAX_UBO_SIZE_VEC4 ${Ii}u`)},Ct=$t=>{Q.depthOcclusionForSymbolsAndCircles&&(n.hasOcclusionOpacityProperties||s.terrain)&&($t.push("DEPTH_D24"),$t.push("DEPTH_OCCLUSION"))},Ut=$t=>{n.lut&&!ee&&(n.lut.texture||(n.lut.texture=new u.ct(s.context,n.lut.image,[n.lut.image.height,n.lut.image.height,n.lut.image.height],le.gl.RGBA8)),le.activeTexture.set(le.gl.TEXTURE0+10),n.lut.texture&&n.lut.texture.bind(le.gl.LINEAR,le.gl.CLAMP_TO_EDGE),$t.push("APPLY_LUT_ON_GPU"))},oi=()=>{const $t=ae&&n.layout.get("symbol-placement")!=="point",Mt=[];Ct(Mt),Ut(Mt);const Ii=$t||pt,wi=Ze.elevationType==="road",sr=s.shadowRenderer,Wi=wi&&fe&&!!sr&&sr.enabled,Pr=gt(Wi),kr=wi&&fe&&!s.terrain?Ae:ye,En=n.paint.get("icon-image-cross-fade");s.terrainRenderModeElevated()&&fe&&Mt.push("PITCH_WITH_MAP_TERRAIN"),tt&&(Mt.push("PROJECTION_GLOBE_VIEW"),Ii&&Mt.push("PROJECTED_POS_ON_VIEWPORT")),En>0&&Ze.hasAnySecondaryIcon&&Mt.push("ICON_TRANSITION"),!Ze.icon.zOffsetVertexBuffer||wi&&s.terrain||Mt.push("Z_OFFSET"),B===0&&$===0&&Z===0&&G===1||Mt.push("COLOR_ADJUSTMENT"),Wi&&Mt.push("RENDER_SHADOWS","NORMAL_OFFSET"),wi&&fe&&!s.terrain&&Ze.icon.orientationVertexBuffer&&Mt.push("ELEVATED_ROADS"),Pt(Mt);const qr=s.getOrCreateProgram("symbol",{defines:Mt}),ti=Ge.imageAtlasTexture?Ge.imageAtlasTexture.size:[0,0],ar=Ze.iconSizeData,Ui=u.aZ(ar,Q.zoom),Oi=fe||!Q.isOrthographic,ii=$s(at,Ge.tileID.canonical,fe,ae,Q,Ze.getProjection(),ut),di=Jl(at,Ge.tileID.canonical,fe,ae,Q,Ze.getProjection(),ut),si=Ze.icon.uboBinder&&Ze.icon.uboBinder.hasPerFeatureTranslate()?[0,0]:g,Ai=s.translatePosMatrix(di,Ge,si,w,!0),pr=s.translatePosMatrix(at,Ge,si,w),Xi=Ii?Iu:ii,Er=ae&&!fe&&!$t;let jo=Ke;!Re&&!Q.mercatorFromTransition||ae||(jo=ip(Q));const wn=tt?jo:Ke,Go=n.getColorAdjustmentMatrix(B,$,Z,G),xa=qa(ar.kind,Ui,Er,fe,s,pr,Xi,Ai,te,!1,Ze.sdfIcons,ti,[0,0],0,Be,ot,ge,Lt,wn,Ze.getProjection(),Pr,kt,Go,En,null),bo=Ge.imageAtlasTexture?Ge.imageAtlasTexture:null,Xn=n.layout.get("icon-size").constantOr(0)!==1||Ze.iconsNeedLinear,Ja=Ze.sdfIcons||s.options.rotating||s.options.zooming||Xn||Oi?K.LINEAR:K.NEAREST,In=Ze.sdfIcons&&n.paint.get("icon-halo-width").constantOr(1)!==0,$o=s.terrain&&fe&&$t?u.aE(u.aS(),ii):Iu;if($t&&Ze.icon){const Lc=u.e7.getAtTileOffsetFunc(Be,Q.center.lat,Q.worldSize,Ze.getProjection()),va=pi(at,Ge.tileID.canonical,fe,ae,Q,Ze.getProjection(),ut),B_=n.layout.get("icon-size-scale-range"),N_=u.as(s.scaleFactor,B_[0],B_[1]);wr(Ze,at,s,!1,va,di,fe,L,Lc,Be,N_)}return{program:qr,buffers:Ze.icon,uniformValues:xa,atlasTexture:bo,atlasTextureIcon:null,atlasInterpolation:Ja,atlasInterpolationIcon:null,isSDF:Ze.sdfIcons,hasHalo:In,depthMode:kr,tile:Ge,renderWithShadows:Wi,labelPlaneMatrixInv:$o}},Ci=()=>{const $t=de&&n.layout.get("symbol-placement")!=="point",Mt=[],Ii=$t||Fe||pt,wi=Ze.elevationType==="road",sr=s.shadowRenderer,Wi=wi&&be&&!!sr&&sr.enabled,Pr=gt(Wi),kr=wi&&be&&!s.terrain?Ae:ye;s.terrainRenderModeElevated()&&be&&Mt.push("PITCH_WITH_MAP_TERRAIN"),tt&&(Mt.push("PROJECTION_GLOBE_VIEW"),Ii&&Mt.push("PROJECTED_POS_ON_VIEWPORT")),!Ze.text.zOffsetVertexBuffer||wi&&s.terrain||Mt.push("Z_OFFSET"),Ze.iconsInText&&Mt.push("RENDER_TEXT_AND_SYMBOL"),Wi&&Mt.push("RENDER_SHADOWS","NORMAL_OFFSET"),wi&&be&&!s.terrain&&Ze.text.orientationVertexBuffer&&Mt.push("ELEVATED_ROADS"),Ct(Mt),Pt(Mt);const En=s.getOrCreateProgram("symbol",{defines:Mt});let qr,ti=[0,0],ar=null;const Ui=Ze.textSizeData;Ze.iconsInText&&(ti=Ge.imageAtlasTexture?Ge.imageAtlasTexture.size:[0,0],ar=Ge.imageAtlasTexture?Ge.imageAtlasTexture:null,qr=be||!Q.isOrthographic||s.options.rotating||s.options.zooming||Ui.kind==="composite"||Ui.kind==="camera"?K.LINEAR:K.NEAREST);const Oi=Ge.glyphAtlasTexture?Ge.glyphAtlasTexture.size:[0,0],ii=n.layout.get("text-size-scale-range"),di=u.as(s.scaleFactor,ii[0],ii[1]),si=u.aZ(Ui,Q.zoom,di),Ai=$s(at,Ge.tileID.canonical,be,de,Q,Ze.getProjection(),ut),pr=Jl(at,Ge.tileID.canonical,be,de,Q,Ze.getProjection(),ut),Xi=Ze.text.uboBinder&&Ze.text.uboBinder.hasPerFeatureTranslate()?[0,0]:x,Er=s.translatePosMatrix(pr,Ge,Xi,S,!0),jo=s.translatePosMatrix(at,Ge,Xi,S),wn=Ii?Iu:Ai,Go=de&&!be&&!$t;let xa=Ke;!Re&&!Q.mercatorFromTransition||de||(xa=ip(Q));const bo=qa(Ui.kind,si,Go,be,s,jo,wn,Er,te,!0,!0,Oi,ti,0,Be,ot,ge,Lt,tt?xa:Ke,Ze.getProjection(),Pr,kt,null,null,di),Xn=Ge.glyphAtlasTexture?Ge.glyphAtlasTexture:null,Ja=K.LINEAR,In=n.paint.get("text-halo-width").constantOr(1)!==0,$o=s.terrain&&be&&$t?u.aE(u.aS(),Ai):Iu;if($t&&Ze.text){const Lc=u.e7.getAtTileOffsetFunc(Be,Q.center.lat,Q.worldSize,Ze.getProjection()),va=pi(at,Ge.tileID.canonical,be,de,Q,Ze.getProjection(),ut);wr(Ze,at,s,!0,va,pr,be,k,Lc,Be,di)}return{program:En,buffers:Ze.text,uniformValues:bo,atlasTexture:Xn,atlasTextureIcon:ar,atlasInterpolation:Ja,atlasInterpolationIcon:qr,isSDF:!0,hasHalo:In,depthMode:kr,tile:Ge,renderWithShadows:Wi,labelPlaneMatrixInv:$o}},hi=Ze.icon.segments.get().length,Kt=Ze.text.segments.get().length,Ei=hi&&!m.onlyText?oi():null,mi=Kt&&!m.onlyIcons?Ci():null,Qi=n.paint.get("icon-opacity").constantOr(1),Ot=n.paint.get("text-opacity").constantOr(1);if(Te&&Ze.canOverlap){Ve=!0;const $t=Qi&&!m.onlyText?Ze.icon.segments.get():[],Mt=Ot&&!m.onlyIcons?Ze.text.segments.get():[];for(const Ii of $t)De.push({segments:new u.cr([Ii]),sortKey:Ii.sortKey,state:Ei});for(const Ii of Mt)De.push({segments:new u.cr([Ii]),sortKey:Ii.sortKey,state:mi})}else m.onlyText||De.push({segments:Qi?Ze.icon.segments:new u.cr([]),sortKey:0,state:Ei}),m.onlyIcons||De.push({segments:Ot?Ze.text.segments:new u.cr([]),sortKey:0,state:mi})}Ve&&De.sort((Be,Ge)=>Be.sortKey-Ge.sortKey);for(const Be of De){const Ge=Be.state;if(Ge)if(s.terrain?s.terrain.setupElevationDraw(Ge.tile,Ge.program,{useDepthForOcclusion:Q.depthOcclusionForSymbolsAndCircles,labelPlaneMatrixInv:Ge.labelPlaneMatrixInv}):s.setupDepthForOcclusion(Q.depthOcclusionForSymbolsAndCircles,Ge.program),le.activeTexture.set(K.TEXTURE0),Ge.atlasTexture&&Ge.atlasTexture.bind(Ge.atlasInterpolation,K.CLAMP_TO_EDGE,!0),Ge.atlasTextureIcon&&(le.activeTexture.set(K.TEXTURE1),Ge.atlasTextureIcon&&Ge.atlasTextureIcon.bind(Ge.atlasInterpolationIcon,K.CLAMP_TO_EDGE,!0)),Ge.renderWithShadows&&s.shadowRenderer.setupShadows(Ge.tile.tileID.toUnwrapped(),Ge.program,"vector-tile"),s.uploadCommonLightUniforms(s.context,Ge.program),Ge.hasHalo){const Ze=Ge.uniformValues;Ze.u_is_halo=1,id(Ge.buffers,Be.segments,n,s,Ge.program,Ge.depthMode,d,p,Ze,2),Ze.u_is_halo=0}else{if(Ge.isSDF){const Ze=Ge.uniformValues;Ge.hasHalo&&(Ze.u_is_halo=1,id(Ge.buffers,Be.segments,n,s,Ge.program,Ge.depthMode,d,p,Ze,1)),Ze.u_is_halo=0}id(Ge.buffers,Be.segments,n,s,Ge.program,Ge.depthMode,d,p,Ge.uniformValues,1)}}}function id(s,t,n,l,d,p,m,g,x,w){const S=l.context,A=S.gl,I=[s.dynamicLayoutVertexBuffer,s.opacityVertexBuffer,s.iconTransitioningVertexBuffer,s.globeExtVertexBuffer,s.zOffsetVertexBuffer,s.orientationVertexBuffer];s.featureIdBuffer&&I.push(s.featureIdBuffer);const M=s.uboBinder?null:s.programConfigurations.get(n.id);if(s.uboBinder){s.uboBinder.layer=n;const k=l.transform.zoom,B=l.style.getBrightness?l.style.getBrightness():null,$=s.uboBinder.getConstantUniformValues(k,B);x.u_spp_fill_np_color=$.fill_np_color,x.u_spp_halo_np_color=$.halo_np_color,x.u_spp_opacity=$.opacity,x.u_spp_halo_width=$.halo_width,x.u_spp_halo_blur=$.halo_blur,x.u_spp_emissive_strength=$.emissive_strength,x.u_spp_occlusion_opacity=$.occlusion_opacity,x.u_spp_z_offset=$.z_offset;const Z=$.zoomFactors;x.u_spp_fill_color_zoom_factor=Z[0],x.u_spp_halo_color_zoom_factor=Z[1],x.u_spp_opacity_zoom_factor=Z[2],x.u_spp_halo_width_zoom_factor=Z[3],x.u_spp_halo_blur_zoom_factor=Z[4],x.u_spp_emissive_strength_zoom_factor=Z[5],x.u_spp_occlusion_opacity_zoom_factor=Z[6],x.u_spp_z_offset_zoom_factor=Z[7],x.u_spp_translate_zoom_factor=Z[8],x.u_spp_zoom_fraction=k-Math.floor(k);const G=n.paint.get(s.uboBinder.isText?"text-translate-anchor":"icon-translate-anchor"),te=s.uboBinder.hasPerFeatureTranslate()&&G==="map"?l.transform.angle:0;x.u_spp_translate_rotation=[Math.cos(te),Math.sin(te)]}const{batchIndices:D,batchSegments:L}=s.getBatchGrouping(t);for(const k of D){const B=L.get(k);s.uboBinder&&s.uboBinder.bind(S,d.program,k),d.draw(l,A.TRIANGLES,p,m,g,_t.disabled,x,n.id,s.layoutVertexBuffer,s.indexBuffer,B,n.paint,l.transform.zoom,M,I,w)}}function rd(s,t,n,l,d,p){const m=n.paint.get("line-width"),g=n.paint.get("line-emissive-strength").isConstant(),x=n.paint.get("line-emissive-strength").constantOr(0),w=n.paint.get("line-occlusion-opacity"),S=n.layout.get("line-elevation-reference"),A=n.layout.get("line-width-unit")==="meters",I=S==="sea",M=!(!s.terrain||!s.terrain.enabled),D=s.context,L=D.gl;if(n.hasElevatedBuckets&&s.transform.projection.name==="globe")return;const k=n.layout.get("line-cross-slope"),B=k!==void 0,$=k<1,Z=d||s.colorModeForDrapableLayerRenderPass(g?x:null),G=s.terrain&&s.terrain.renderingToTexture||p,te=G?1:u.r.devicePixelRatio,ee=n.paint.get("line-dasharray"),le=ee.constantOr(1),K=n.layout.get("line-cap"),Q=ee.constantOr(null),ae=K.constantOr(null),de=n.paint.get("line-pattern"),fe=de.constantOr(1),be=n.paint.get("line-pattern-cross-fade"),Te=de.constantOr(null),Ve=n.paint.get("line-opacity").constantOr(1);let ye=!fe&&Ve!==1||s.depthOcclusion&&w>0&&w<1;const Ae=n.paint.get("line-gradient"),ge=fe?"linePattern":"line",Fe=u.eM(n);let Re;if(G&&s.terrain&&s.terrain.clipOrMaskOverlapStencilType()&&(ye=!1),w!==0&&s.depthOcclusion){const ot=n.paint._values["line-opacity"];ot&&ot.value&&ot.value.kind==="constant"?Re=ot.value:u.w(`Occlusion opacity for layer ${n.id} is supported only when line-opacity isn't data-driven.`)}m.value.kind!=="constant"&&m.value.isLineProgressConstant===!1&&Fe.push("VARIABLE_LINE_WIDTH");const De=n.paint.get("line-emissive-strength");fe||De.value.kind==="constant"||De.value.isLineProgressConstant!==!1||Fe.push("VARIABLE_LINE_EMISSIVE_STRENGTH"),s._debugParams.showElevationIdDebug&&Fe.push("DEBUG_ELEVATION_ID"),G&&(s.emissiveMode!=="dual-source-blending"||g?s.emissiveMode==="mrt-fallback"&&Fe.push("USE_MRT1"):Fe.push("DUAL_SOURCE_BLENDING"));const Ke={},Be=[],Ge=(ot,at,ut,bt,pt,Lt)=>{for(const kt of ot){const gt=t.getTile(kt);if(fe&&!gt.patternsLoaded())continue;const Pt=gt.getBucket(n);if(!Pt||Pt.elevationType!=="none"&&!pt||Pt.elevationType==="none"&&pt)continue;s.prepareDrawTile();const Ct=[...at],Ut=Pt.elevationType==="road",oi=s.shadowRenderer,Ci=Ut&&!!oi&&oi.enabled;let hi=[0,0,0];if(Ci){const ti=s.style.directionalLight,ar=s.style.ambientLight;ti&&ar&&(hi=pl(s.style,ti,ar)),Ct.push("RENDER_SHADOWS","NORMAL_OFFSET")}const Kt=Pt.programConfigurations.get(n.id);let Ei=!1;if(Te&&gt.imageAtlas){const ti=u.cD.from(Te),ar=ti.getPrimary().scaleSelf(te).toString(),Ui=gt.imageAtlas.patternPositions.get(ar),Oi=ti.getSecondary(),ii=Oi?gt.imageAtlas.patternPositions.get(Oi.scaleSelf(te).toString()):null;Ei=!!Ui&&!!ii,Ui&&Kt.setConstantPatternPositions(Ui,ii)}be>0&&(Ei||Kt.getPatternTransitionVertexBuffer("line-pattern"))&&Ct.push("LINE_PATTERN_TRANSITION"),Pt.elevationGroundScaleVertexBuffer&&Ct.push("ELEVATION_GROUND_SCALE");const mi=s.isTileAffectedByFog(kt),Qi=s.getOrCreateProgram(ge,{config:Kt,defines:Ct,overrideFog:mi});if(!fe&&Q&&ae&&gt.lineAtlas){const ti=gt.lineAtlas.getDash(Q,ae);ti&&Kt.setConstantPatternPositions(ti)}Ci&&oi.setupShadows(gt.tileID.toUnwrapped(),Qi,"vector-tile");let[Ot,$t]=n.paint.get("line-trim-offset");(ae==="round"||ae==="square")&&Ot!==$t&&(Ot===0&&(Ot-=1),$t===1&&($t+=1));const Mt=G?kt.projMatrix:null,Ii=A?1/Pt.tileToMeter/u.c1(gt,1,s.transform.zoom):1,wi=A?1/Pt.tileToMeter/u.c1(gt,1,Math.floor(s.transform.zoom)):1,sr=le?n.paint._values["line-floorwidth"]:null;let Wi;if(sr&&sr.value.kind==="constant"){const ti=Pt.zoom;ti in Ke||(Ke[ti]=Math.max(.01,n.widthExpression().evaluate({zoom:ti}))),Wi=sr.value.value;const ar=Math.floor(s.transform.zoom);
3401sr.value.value=Ke[ti]*Math.pow(2,ar-gt.tileID.overscaledZ)}const Pr=fe?u.eN(s,gt,n,Mt,te,Ii,wi,[Ot,$t],hi,be):u.eO(s,gt,n,Mt,Pt.lineClipsArray.length,te,Ii,wi,[Ot,$t],hi);if(Ae){const ti=Pt.gradients[n.id];let ar=ti.texture;if(n.gradientVersion!==ti.version){let Ui=256;if(n.stepInterpolant){const ii=t.getSource().maxzoom,di=kt.canonical.z===ii?Math.ceil(1<<s.transform.maxZoom-kt.canonical.z):1;Ui=u.as(u.eP(Pt.maxLineLength/u.aj*1024*di),256,D.maxTextureSize)}const Oi=n.paint.get("line-gradient-use-theme").constantOr("default")==="none";ti.gradient=u.eQ({expression:n.gradientExpression(),evaluationKey:"lineProgress",resolution:Ui,image:ti.gradient||void 0,clips:Pt.lineClipsArray,lut:Oi?null:n.lut}),ti.texture?ti.texture.update(ti.gradient):ti.texture=new u.T(D,ti.gradient,L.RGBA8),ti.version=n.gradientVersion,ar=ti.texture}D.activeTexture.set(L.TEXTURE1),ar.bind(n.stepInterpolant?L.NEAREST:L.LINEAR,L.CLAMP_TO_EDGE)}le&&(D.activeTexture.set(L.TEXTURE0),gt.lineAtlasTexture&&gt.lineAtlasTexture.bind(L.LINEAR,L.REPEAT),Kt.updatePaintBuffers()),fe&&(D.activeTexture.set(L.TEXTURE0),gt.imageAtlasTexture&&gt.imageAtlasTexture.bind(L.LINEAR,L.CLAMP_TO_EDGE),Kt.updatePaintBuffers()),pt&&!Ut&&s.terrain.setupElevationDraw(gt,Qi),s.uploadCommonUniforms(D,Qi,kt.toUnwrapped());const kr=jt.drawLineFrcCoverageDetect?jt.drawLineFrcCoverageDetect(s,Pt,kt,pt,Pr,Kt,Qi,ut,Z,Be):null,En=(ti,ar,Ui)=>{ar&&ar.get().length!==0&&(Re!=null&&(Re.value=Ve*w),Ui!==void 0&&(Pr.u_opacity_multiplier=Ui),Qi.draw(s,L.TRIANGLES,ut,ti,Z,_t.disabled,Pr,n.id,Pt.layoutVertexBuffer,Pt.indexBuffer,ar,n.paint,s.transform.zoom,Kt,[Pt.layoutVertexBuffer2,Pt.patternVertexBuffer,Pt.zOffsetVertexBuffer,Pt.elevationIdColVertexBuffer,Pt.elevationGroundScaleVertexBuffer]),Ui!==void 0&&(Pr.u_opacity_multiplier=1),Re!=null&&(Re.value=Ve))},qr=ti=>{kr&&kr.active&&jt.drawLineFrcRenderLine?jt.drawLineFrcRenderLine(Pt,kr,ti,En):En(ti,Pt.segments)};if(ye&&!pt){const ti=s.stencilModeForClipping(kt).ref;ti===0&&G&&D.clear({stencil:0});const ar={func:L.EQUAL,mask:255};Pr.u_alpha_discard_threshold=.8,qr(new mt(ar,ti,255,L.KEEP,L.KEEP,L.INVERT)),Pr.u_alpha_discard_threshold=0,qr(new mt(ar,ti,255,L.KEEP,L.KEEP,L.KEEP))}else Pr.u_alpha_discard_threshold=ye&&pt&&Lt?.8:0,qr(pt?bt:s.stencilModeForClipping(kt));kr&&jt.drawLineFrcFadePass&&jt.drawLineFrcFadePass(s,Pt,kt,kr,pt,bt,En),Wi!==void 0&&(sr.value.value=Wi)}};let Ze=s.depthModeForSublayer(0,ct.ReadOnly);const tt=new ct(s.depthOcclusion?L.GREATER:L.LEQUAL,ct.ReadOnly,s.depthRangeFor3D);if(n.hasNonElevatedBuckets){const ot=!G&&s.terrain;w!==0&&ot?u.w(`Occlusion opacity for layer ${n.id} is supported on terrain only if the layer has line-z-offset enabled.`):ot?u.w(`Cannot render non-elevated lines in immediate mode when terrain is enabled. Layer: ${n.id}.`):Ge(l,Fe,Ze,mt.disabled,!1,!0)}if(n.hasElevatedBuckets){S==="hd-road-markup"?M||(Ze=tt,Fe.push("ELEVATED_ROADS")):(Fe.push("ELEVATED"),Ze=tt,B&&Fe.push($?"CROSS_SLOPE_HORIZONTAL":"CROSS_SLOPE_VERTICAL"),I&&Fe.push("ELEVATION_REFERENCE_SEA"));const ot=ye?s.stencilModeFor3D():mt.disabled;S!=="hd-road-markup"&&(s.forceTerrainMode=!0),Ge(l,Fe,Ze,ot,!0,!0),ye&&Ge(l,Fe,Ze,ot,!0,!1),S!=="hd-road-markup"&&(s.forceTerrainMode=!1)}jt.drawLineFrcCoverageSecondPass&&jt.drawLineFrcCoverageSecondPass(s,n,Be),ye&&(s.resetStencilClippingMasks(),G&&D.clear({stencil:0})),w===0||s.depthOcclusion||G||s.layersWithOcclusionOpacity.push(s.currentLayer)}class rp{destroy(){this.fbo&&(this.fbo.destroy(),this.fbo=null),this.drapeFbo&&(this.drapeFbo.destroy(),this.drapeFbo=null)}}class __{constructor(t){this.pbo=t.createBuffer(),this.sync=null,this.fboA=null,this.fboB=null,this.maxDensity=0}destroy(t){this.sync&&(t.deleteSync(this.sync),this.sync=null),t.deleteBuffer(this.pbo),this.fboA&&(this.fboA.destroy(),this.fboA=null),this.fboB&&(this.fboB.destroy(),this.fboB=null)}}const Au={additive:{clearColor:new u.C(0,0,0,0),colorMode:yt.additiveAlphaWeighted,compositeUniformValue:1},multiply:{clearColor:new u.C(1,1,1,1),colorMode:yt.multiply,compositeUniformValue:0}};function Cu(s){return!(!s.extRenderToTextureHalfFloat&&!s.extColorBufferFloat)}
vendor: 27,705 bytes, line 3401
3401function nd(s,t){return s==="additive"&&Cu(t)?yt.additiveAlphaWeightedUnboundedAlpha:Au[s].colorMode}function np(s,t,n){const l=s.context,d=l.gl;let p=n.width,m=n.height,g=n.colorAttachment0.get();t.lineBlendDensityReadback||(t.lineBlendDensityReadback=new __(d));const x=t.lineBlendDensityReadback;let w=0,S=!0;for(;p>1||m>1;){const M=Math.max(1,Math.floor(p/2)),D=Math.max(1,Math.floor(m/2)),L=w===0?"fboA":"fboB";x[L]=Ha.createWithTexture(l,x[L],M,D,!1);const k=x[L];l.bindFramebuffer.set(k.framebuffer),l.viewport.set([0,0,M,D]),l.activeTexture.set(d.TEXTURE0),d.bindTexture(d.TEXTURE_2D,g),s.getOrCreateProgram("lineBlendReduce").draw(s,d.TRIANGLES,ct.disabled,mt.disabled,yt.unblended,_t.disabled,us(0,[1/p,1/m],S),t.id,s.viewportBuffer,s.quadTriangleIndexBuffer,s.viewportSegments,t.paint,s.transform.zoom),p=M,m=D,g=k.colorAttachment0.get(),w=1-w,S=!1}const A=Cu(l),I=A?16:4;x.sync&&(d.deleteSync(x.sync),x.sync=null),d.bindBuffer(d.PIXEL_PACK_BUFFER,x.pbo),d.bufferData(d.PIXEL_PACK_BUFFER,I,d.STREAM_READ),d.readPixels(0,0,1,1,d.RGBA,A?d.FLOAT:d.UNSIGNED_BYTE,0),d.bindBuffer(d.PIXEL_PACK_BUFFER,null),x.sync=d.fenceSync(d.SYNC_GPU_COMMANDS_COMPLETE,0),l.viewport.set([0,0,s.width,s.height])}function g_(s,t,n){if(!Cu(s.context))return;const l=t.lineBlendDensityReadback;l&&l.sync?((function(d,p,m){if(d.sync&&p.getSyncParameter(d.sync,p.SYNC_STATUS)===p.SIGNALED){if(p.deleteSync(d.sync),d.sync=null,p.bindBuffer(p.PIXEL_PACK_BUFFER,d.pbo),Cu(m)){const g=new Float32Array(4);p.getBufferSubData(p.PIXEL_PACK_BUFFER,0,g);const x=g[1];d.maxDensity=Math.max(2*(x>0?g[0]/x:0),1)}else d.maxDensity=1;p.bindBuffer(p.PIXEL_PACK_BUFFER,null)}})(l,s.context.gl,s.context),l.sync||(np(s,t,n),s.style.map.triggerRepaint())):(np(s,t,n),s.style.map.triggerRepaint())}function y_(s,t,n,l,d,p){const m=s.context,g=m.gl,x=n==="additive"?1:t.paint.get("line-opacity").constantOr(1),w=n==="additive"?(function(A,I){const M=I.paint.get("line-blend-additive-clamp");if(M>0)return M;const D=I.lineBlendDensityReadback;return D&&D.maxDensity!==0?D.maxDensity:null})(0,t):1;if(w===null)return;m.bindFramebuffer.set(d),p&&m.viewport.set([0,0,p[0],p[1]]),m.activeTexture.set(g.TEXTURE0),g.bindTexture(g.TEXTURE_2D,l.colorAttachment0.get());const S=nd(n,s.context);s.getOrCreateProgram("lineBlendComposite").draw(s,g.TRIANGLES,ct.disabled,mt.disabled,S,_t.disabled,((A,I,M,D)=>({u_image:0,u_opacity:I,u_blend_mode:M,u_max_density:D}))(0,x,Au[n].compositeUniformValue,w),t.id,s.viewportBuffer,s.quadTriangleIndexBuffer,s.viewportSegments,t.paint,s.transform.zoom)}function op(s,t,n,l){const{painter:d,sourceCache:p,layer:m,coords:g,colorMode:x,elevationType:w,terrainEnabled:S,pass:A}=s,I=d.context.gl,M=m.paint.get("fill-pattern"),D=m.paint.get("fill-pattern-cross-fade"),L=M.constantOr(null);let k=w;w!=="road"||t&&!S||(k="none");const B=k==="road",$=s.painter.shadowRenderer,Z=B&&!!$&&$.enabled,G=new ct(d.context.gl.LEQUAL,ct.ReadOnly,d.depthRangeFor3D);let te=[0,0,0];if(Z){const Q=d.style.directionalLight,ae=d.style.ambientLight;Q&&ae&&(te=pl(d.style,Q,ae))}const ee=M&&M.constantOr(1),le=d.terrain&&d.terrain.renderingToTexture,K=(Q,ae)=>{let de,fe,be,Te,Ve;ae?(de=ee&&!m.getPaintProperty("fill-outline-color")?"fillOutlinePattern":"fillOutline",be=I.LINES):(de=ee?"fillPattern":"fill",be=I.TRIANGLES);const ye=[];for(const Ae of g){const ge=p.getTile(Ae);if(ee&&!ge.patternsLoaded())continue;const Fe=ge.getBucket(m);if(!Fe)continue;const Re=t?Fe.hdExt&&Fe.hdExt.elevationBufferData:Fe.bufferData;if(!Re||Re.isEmpty())continue;d.prepareDrawTile();const De=Re.programConfigurations.get(m.id),Ke=d.isTileAffectedByFog(Ae),Be=[],Ge=[];B&&(Be.push("ELEVATED_ROADS"),Ge.push(Re.elevatedLayoutVertexBuffer)),Z&&Be.push("RENDER_SHADOWS","NORMAL_OFFSET"),le&&n&&Be.push("USE_MRT1"),ee&&(d.context.activeTexture.set(I.TEXTURE0),ge.imageAtlasTexture&&ge.imageAtlasTexture.bind(I.LINEAR,I.CLAMP_TO_EDGE),De.updatePaintBuffers());let Ze=!1;if(L&&ge.imageAtlas){const Lt=ge.imageAtlas,kt=u.cD.from(L),gt=kt.getPrimary().scaleSelf(u.r.devicePixelRatio).toString(),Pt=kt.getSecondary(),Ct=Lt.patternPositions.get(gt),Ut=Pt?Lt.patternPositions.get(Pt.scaleSelf(u.r.devicePixelRatio).toString()):null;Ze=!!Ct&&!!Ut,Ct&&De.setConstantPatternPositions(Ct,Ut)}D>0&&(Ze||De.getPatternTransitionVertexBuffer("fill-pattern"))&&Be.push("FILL_PATTERN_TRANSITION");const tt=d.getOrCreateProgram(de,{config:De,overrideFog:Ke,defines:Be}),ot=d.translatePosMatrix(Ae.projMatrix,ge,m.paint.get("fill-translate"),m.paint.get("fill-translate-anchor"));Z&&$.setupShadows(ge.tileID.toUnwrapped(),tt,"vector-tile");const at=m.paint.get("fill-emissive-strength");if(ae){Te=Re.lineIndexBuffer,Ve=Re.lineSegments;const Lt=d.terrain&&d.terrain.renderingToTexture?d.terrain.drapeBufferSize:[I.drawingBufferWidth,I.drawingBufferHeight];fe=de==="fillOutlinePattern"&&ee?Xf(ot,at,d,ge,Lt,te,D):ga(ot,at,Lt,te)}else Te=Re.indexBuffer,Ve=Re.triangleSegments,fe=ee?Zh(ot,at,d,ge,te,D):Hh(ot,at,te);d.uploadCommonUniforms(d.context,tt,Ae.toUnwrapped());let ut=Q;if((w==="road"&&!S||w==="offset")&&(ut=G),!Ve||Ve.get&&Ve.get().length===0)continue;const bt=l||d.stencilModeForClipping(Ae);let pt="fallthrough";!ae&&jt.drawFillFrcCoverageFirstPass&&(pt=jt.drawFillFrcCoverageFirstPass({painter:d,layer:m,bucket:Fe,coord:Ae,elevatedGeometry:t,program:tt,programConfiguration:De,uniformValues:fe,drawMode:be,depthMode:ut,stencilMode:bt,colorMode:x,bufferData:Re,indexBuffer:Te,segments:Ve,dynamicBuffers:Ge,polygonCoverageTiles:ye})),pt==="fallthrough"&&tt.draw(d,be,ut,bt,x,_t.disabled,fe,m.id,Re.layoutVertexBuffer,Te,Ve,m.paint,d.transform.zoom,De,Ge)}!ae&&jt.drawFillFrcCoverageSecondPass&&jt.drawFillFrcCoverageSecondPass(d,m,ye,be,x)};d.renderPass===A&&K(d.depthModeForSublayer(1,d.renderPass==="opaque"?ct.ReadWrite:ct.ReadOnly),!1),k==="none"&&d.renderPass==="translucent"&&m.paint.get("fill-antialias")&&K(d.depthModeForSublayer(m.getPaintProperty("fill-outline-color")?2:0,ct.ReadOnly),!0)}function x_(s){return[s[0]*u.eR,s[1]*u.eR,s[2]*u.eR,0]}function Fi(s,t,n,l,d,p,m,g,x){const w=l.getSource(),S=n.globeSharedBuffers;if(!S)return;let A,I,M;if(t&&(A=l.getTile(t)),w instanceof No?(I=w.texture,M=u.ew(0,0,n.transform)):A&&t&&(I=A.texture,M=u.ew(t.canonical.z,t.canonical.x,n.transform)),!I||!M)return;s||(M=u.bL(u.aS(),M,[1,-1,1]));const D=n.context,L=D.gl,k=d.paint.get("raster-resampling")==="nearest"?L.NEAREST:L.LINEAR,B=n.colorModeForDrapableLayerRenderPass(p),$=m.defines;$.push("GLOBE_POLES");const Z=new ct(L.LEQUAL,ct.ReadWrite,n.depthRangeFor3D),G=n.transform.expandedFarZProjMatrix,te=Float32Array.from(u.d3(u.dn(new u.bu(0,0,0))));n.terrain&&n.terrain.prepareDrawTile(),D.activeTexture.set(L.TEXTURE0),I.bind(k,L.CLAMP_TO_EDGE),D.activeTexture.set(L.TEXTURE1),I.bind(k,L.CLAMP_TO_EDGE),"useMipmap"in I&&D.extTextureFilterAnisotropic&&n.transform.pitch>20&&L.texParameterf(L.TEXTURE_2D,D.extTextureFilterAnisotropic.TEXTURE_MAX_ANISOTROPY_EXT,D.extTextureFilterAnisotropicMax);const[ee,le,K,Q]=t?S.getPoleBuffers(t.canonical.z,!1):S.getPoleBuffers(0,!0),ae=d.paint.get("raster-elevation");let de;s?(de=ee,n.renderDefaultNorthPole=ae!==0):(de=le,n.renderDefaultSouthPole=ae!==0);const fe=x_(m.mix),be=((Ve,ye,Ae,ge,Fe,Re,De,Ke,Be,Ge,Ze,tt,ot,at)=>Xh(Ve,ye,Ae,ge,new Float32Array(16),new Float32Array(9),[0,0],Fe,[0,0],[0,0,0,0],1,{opacity:1,mix:0},De,[0,0],Be,2,Ze,tt,ot,1,0,at))(n,G,te,M,u.ah(n.transform.zoom),0,d,0,ae,0,fe,m.offset,m.range,p),Te=n.getOrCreateProgram("raster",{defines:$});n.uploadCommonUniforms(D,Te,null),Te.draw(n,L.TRIANGLES,Z,x,B,g,be,d.id,de,K,Q)}function Mc(s){if(s.isOrthographic)return[0,0,0,0];const t=s._nearZ,n=s.projection.farthestPixelDistance(s),l=n-t,d=.2*s.height,p=t+d;return[t,n,(p-d-t)/l,(p-t)/l]}function uy(s,t,n,l){if(s)return t instanceof bl&&s instanceof af?t.getTextureDescriptor(s,n,!0):{texture:s.texture,mix:x_(l.mix),offset:l.offset,buffer:0,tileSize:1}}const hy=u.aC(new Float32Array(16)),dy=new u.C(1,0,0,1),Mu=new u.C(0,1,0,1),v_=new u.C(0,0,1,1),sp=new u.C(1,0,1,1),od=new u.C(0,1,1,1);function Qs(s,t,n,l,d,p,m){const g=s.context,x=s.transform,w=g.gl,S=x.projection.name==="globe",A=S?["PROJECTION_GLOBE_VIEW"]:[];let I=u.aQ(n.projMatrix);if(S&&u.ah(x.zoom)>0){const fe=u.d2(n.canonical,x),be=u.eS(fe);I=u.aP(new Float32Array(16),x.globeMatrix,be),u.aP(I,x.projMatrix,I)}const M=u.aS();M[12]+=2*d/(u.r.devicePixelRatio*x.width),M[13]+=2*p/(u.r.devicePixelRatio*x.height),u.aP(I,M,I);const D=s.getOrCreateProgram("debug",{defines:A}),L=t.getTileByID(n.key);s.terrain&&s.terrain.setupElevationDraw(L,D);const k=ct.disabled,B=mt.disabled,$=s.colorModeForRenderPass(),Z="$debug";g.activeTexture.set(w.TEXTURE0),s.emptyTexture.bind(w.LINEAR,w.CLAMP_TO_EDGE),S?L._makeGlobeTileDebugBuffers(s.context,x):L._makeDebugTileBoundsBuffers(s.context,x.projection);const G=L._tileDebugBuffer||s.debugBuffer,te=L._tileDebugIndexBuffer||s.debugIndexBuffer,ee=L._tileDebugSegments||s.debugSegments;if(D.draw(s,w.LINE_STRIP,k,B,$,_t.disabled,Ss(I,l.toPremultipliedRenderColor(null)),Z,G,te,ee,null,null,null,[L._globeTileDebugBorderBuffer]),m){const fe=L.latestRawTileData,be=Math.floor((fe&&fe.byteLength||0)/1024);let Te=n.canonical.toString();n.overscaledZ!==n.canonical.z&&(Te+=` => ${n.overscaledZ}`),Te+=` ${L.state}`,Te+=` ${be}kb`,(function(Ve,ye){Ve.initDebugOverlayCanvas();const Ae=Ve.debugOverlayCanvas,ge=Ve.context.gl,Fe=Ve.debugOverlayCanvas.getContext("2d");Fe.clearRect(0,0,Ae.width,Ae.height),Fe.shadowColor="white",Fe.shadowBlur=2,Fe.lineWidth=1.5,Fe.strokeStyle="white",Fe.textBaseline="top",Fe.font="bold 36px Open Sans, sans-serif",Fe.fillText(ye,5,5),Fe.strokeText(ye,5,5),Ve.debugOverlayTexture.update(Ae),Ve.debugOverlayTexture.bind(ge.LINEAR,ge.CLAMP_TO_EDGE)})(s,Te)}const le=t.getTile(n).tileSize,K=512/Math.min(le,512)*(n.overscaledZ/x.zoom)*.5,Q=L._tileDebugTextBuffer||s.debugBuffer,ae=L._tileDebugTextIndexBuffer||s.quadTriangleIndexBuffer,de=L._tileDebugTextSegments||s.debugSegments;D.draw(s,w.TRIANGLES,k,B,yt.alphaBlended,_t.disabled,Ss(I,u.C.transparent.toPremultipliedRenderColor(null),K),Z,Q,ae,de,null,null,null,[L._globeTileDebugTextBuffer])}function Pu(s,t,n,l){ao(s,0,t+n/2,s.transform.width,n,l)}function gr(s,t,n,l){ao(s,t-n/2,0,n,s.transform.height,l)}function ao(s,t,n,l,d,p){const m=s.context,g=m.gl;g.enable(g.SCISSOR_TEST),g.scissor(t*u.r.devicePixelRatio,n*u.r.devicePixelRatio,l*u.r.devicePixelRatio,d*u.r.devicePixelRatio),m.clear({color:p}),g.disable(g.SCISSOR_TEST)}const Ru=u.cR([{name:"a_pos_3f",components:3,type:"Float32"}]),{members:fy}=Ru;function ea(s,t,n,l){s.emplaceBack(t,n,l)}class ap{constructor(t){this.vertexArray=new u.eT,this.indices=new u.cp,ea(this.vertexArray,-1,-1,1),ea(this.vertexArray,1,-1,1),ea(this.vertexArray,-1,1,1),ea(this.vertexArray,1,1,1),ea(this.vertexArray,-1,-1,-1),ea(this.vertexArray,1,-1,-1),ea(this.vertexArray,-1,1,-1),ea(this.vertexArray,1,1,-1),this.indices.emplaceBack(5,1,3),this.indices.emplaceBack(3,7,5),this.indices.emplaceBack(6,2,0),this.indices.emplaceBack(0,4,6),this.indices.emplaceBack(2,6,7),this.indices.emplaceBack(7,3,2),this.indices.emplaceBack(5,4,0),this.indices.emplaceBack(0,1,5),this.indices.emplaceBack(0,2,3),this.indices.emplaceBack(3,1,0),this.indices.emplaceBack(7,6,4),this.indices.emplaceBack(4,5,7),this.vertexBuffer=t.createVertexBuffer(this.vertexArray,fy),this.indexBuffer=t.createIndexBuffer(this.indices),this.segment=u.cr.simpleSegment(0,0,36,12)}}function ta(s,t,n,l,d,p){const m=s.context.gl,g=t.paint.get("sky-atmosphere-color"),x=t.paint.get("sky-atmosphere-halo-color"),w=t.paint.get("sky-atmosphere-sun-intensity"),S=((A,I,M,D,L)=>({u_matrix_3f:A,u_sun_direction:I,u_sun_intensity:M,u_color_tint_r:[D.r,D.g,D.b,D.a],u_color_tint_m:[L.r,L.g,L.b,L.a],u_luminance:5e-5}))(u.eW(u.c2(),l),d,w,g.toPremultipliedRenderColor(null),x.toPremultipliedRenderColor(null));m.framebufferTexture2D(m.FRAMEBUFFER,m.COLOR_ATTACHMENT0,m.TEXTURE_CUBE_MAP_POSITIVE_X+p,t.skyboxTexture,0),n.draw(s,m.TRIANGLES,ct.disabled,mt.disabled,yt.unblended,_t.frontCW,S,"skyboxCapture",t.skyboxGeometry.vertexBuffer,t.skyboxGeometry.indexBuffer,t.skyboxGeometry.segment)}const lp=u.cR([{type:"Float32",name:"a_pos",components:3},{type:"Float32",name:"a_uv",components:2}]);class cp{constructor(t){const n=new u.eX;n.emplaceBack(-1,1,1,0,0),n.emplaceBack(1,1,1,1,0),n.emplaceBack(1,-1,1,1,1),n.emplaceBack(-1,-1,1,0,1);const l=new u.cp;l.emplaceBack(0,1,2),l.emplaceBack(2,3,0),this.vertexBuffer=t.createVertexBuffer(n,lp.members),this.indexBuffer=t.createIndexBuffer(l),this.segments=u.cr.simpleSegment(0,0,4,2)}destroy(){this.vertexBuffer.destroy(),this.indexBuffer.destroy(),this.segments.destroy()}}const sd=u.cR([{type:"Float32",name:"a_pos_3f",components:3},{type:"Float32",name:"a_uv",components:2},{type:"Float32",name:"a_size_scale",components:1},{type:"Float32",name:"a_opacity",components:1}]);class ad{constructor(){this.colorModeAlphaBlendedWriteRGB=new yt([1,On,1,On],u.C.transparent,[!0,!0,!0,!1]),this.colorModeWriteAlpha=new yt([1,0,1,0],u.C.transparent,[!1,!1,!1,!0]),this.params={starsCount:16e3,sizeMultiplier:.15,sizeRange:100,intensityRange:200},this.updateNeeded=!0,this._painter=null,this._devtoolsFolder=null}update(t){this._painter=t;const n=t.context;if(!this.atmosphereBuffer||this.updateNeeded){this.updateNeeded=!1,this.atmosphereBuffer=new cp(n);let l=this.params;const d=l.sizeRange,p=l.intensityRange,m=(function(A){const I=u.dt(30),M=[];for(let D=0;D<A;++D){const L=2*Math.PI*I(),k=Math.acos(1-2*I())-.5*Math.PI;M.push(u.c6(Math.cos(k)*Math.cos(L),Math.cos(k)*Math.sin(L),Math.sin(k)))}return M})(l.starsCount),g=u.dt(300),x=new u.eY,w=new u.cp;let S=0;for(let A=0;A<m.length;++A){const I=u.av([],m[A],200),M=Math.max(0,1+.01*d*(1*g()-.5)),D=Math.max(0,1+.01*p*(1*g()-.5));x.emplaceBack(I[0],I[1],I[2],-1,-1,M,D),x.emplaceBack(I[0],I[1],I[2],1,-1,M,D),x.emplaceBack(I[0],I[1],I[2],1,1,M,D),x.emplaceBack(I[0],I[1],I[2],-1,1,M,D),w.emplaceBack(S+0,S+1,S+2),w.emplaceBack(S+0,S+2,S+3),S+=4}this.starsVx=n.createVertexBuffer(x,sd.members),this.starsIdx=n.createIndexBuffer(w),this.starsSegments=u.cr.simpleSegment(0,0,x.length,w.length)}}destroy(){this.atmosphereBuffer&&this.atmosphereBuffer.destroy(),this.starsVx&&this.starsVx.destroy(),this.starsIdx&&this.starsIdx.destroy(),this._painter=null}drawAtmosphereGlow(t,n){const l=t.context,d=l.gl,p=t.transform,m=new ct(d.LEQUAL,ct.ReadOnly,[0,1]),g=u.ah(p.zoom),x=t.style.getLut(n.scope),w=n.properties.get("color-use-theme")==="none",S=n.properties.get("color").toNonPremultipliedRenderColor(w?null:x),A=n.properties.get("high-color-use-theme")==="none",I=n.properties.get("high-color").toNonPremultipliedRenderColor(A?null:x),M=n.properties.get("space-color-use-theme")==="none",D=n.properties.get("space-color").toNonPremultipliedRenderColor(M?null:x),L=5e-4,k=u.eZ(n.properties.get("horizon-blend"),0,1,L,.25),B=u.ev(t,l,p)&&k===L?p.worldSize/(2*Math.PI*1.025)-1:p.globeRadius,$=t.frameCounter/1e3%1,Z=u.ae(p.globeCenterInViewSpace),G=Math.sqrt(Math.pow(Z,2)-Math.pow(B,2)),te=Math.acos(G/Z),ee=le=>{const K=p.projection.name==="globe"?["PROJECTION_GLOBE_VIEW","FOG"]:["FOG"];le&&K.push("ALPHA_PASS");const Q=t.getOrCreateProgram("globeAtmosphere",{defines:K}),ae=((fe,be,Te,Ve,ye,Ae,ge,Fe,Re,De,Ke,Be)=>({u_frustum_tl:fe,u_frustum_tr:be,u_frustum_br:Te,u_frustum_bl:Ve,u_horizon:ye,u_transition:Ae,u_fadeout_range:ge,u_atmosphere_fog_color:Fe.toArray01(),u_high_color:Re.toArray01(),u_space_color:De.toArray01(),u_temporal_offset:Ke,u_horizon_angle:Be}))(p.frustumCorners.TL,p.frustumCorners.TR,p.frustumCorners.BR,p.frustumCorners.BL,p.frustumCorners.horizon,g,k,S,I,D,$,te);t.uploadCommonUniforms(l,Q);const de=this.atmosphereBuffer;de&&Q.draw(t,d.TRIANGLES,m,mt.disabled,le?this.colorModeWriteAlpha:this.colorModeAlphaBlendedWriteRGB,_t.backCW,ae,le?"atmosphere_glow_alpha":"atmosphere_glow",de.vertexBuffer,de.indexBuffer,de.segments)};ee(!1),ee(!0)}drawStars(t,n){const l=u.as(n.properties.get("star-intensity"),0,1);if(l===0)return;const d=t.context,p=d.gl,m=t.transform,g=t.getOrCreateProgram("stars"),x=u.az([]);u.aB(x,x,-m._pitch),u.aA(x,x,-m.angle),u.aB(x,x,u.al(m._center.lat)),u.e_(x,x,-u.al(m._center.lng));const w=u.aI(new Float32Array(16),x),S=u.aP([],m.starsProjMatrix,w),A=u.eW([],w),I=u.e$([],A);let M=this.params.sizeMultiplier;const D=[0,1,0];u.c4(D,D,I),u.av(D,D,M);const L=[1,0,0];u.c4(L,L,I),u.av(L,L,M);const k=(B=D,$=L,Z=l,{u_matrix:Float32Array.from(S),u_up:B,u_right:$,u_intensity_multiplier:Z});var B,$,Z;t.uploadCommonUniforms(d,g),this.starsVx&&this.starsIdx&&g.draw(t,p.TRIANGLES,ct.disabled,mt.disabled,this.colorModeAlphaBlendedWriteRGB,_t.disabled,k,"atmosphere_stars",this.starsVx,this.starsIdx,this.starsSegments)}}class Du{}class ya{constructor(){this._storage=new Map}getLinesFromTrianglesBuffer(t,n,l){{const A=this._storage.get(n.id);if(A)return A.lastUsedFrameIdx=t,A.buf}const d=l.gl,p=d.getBufferParameter(d.ELEMENT_ARRAY_BUFFER,d.BUFFER_SIZE),m=new ArrayBuffer(p),g=new Int16Array(m);d.getBufferSubData(d.ELEMENT_ARRAY_BUFFER,0,new Int16Array(m));const x=new u.f0;for(let A=0;A<p/2;A+=3){const I=g[A],M=g[A+1],D=g[A+2];x.emplaceBack(I,M),x.emplaceBack(M,D),x.emplaceBack(D,I)}const w=l.bindVertexArrayOES.current,S=new Du;return S.buf=new xo(l,x),S.lastUsedFrameIdx=t,this._storage.set(n.id,S),l.bindVertexArrayOES.set(w),S.buf}update(t){for(const[n,l]of this._storage)t-l.lastUsedFrameIdx>30&&(l.buf.destroy(),this._storage.delete(n))}destroy(){for(const[t,n]of this._storage)n.buf.destroy(),this._storage.delete(t)}}class ia{constructor(){this.occluderSize=30,this.depthOffset=-1e-4}}const vo={symbol:function(s,t,n,l,d){if(s.renderPass!=="translucent")return;const p=mt.disabled,m=s.colorModeForRenderPass(),g=n.layout.get("text-variable-anchor"),x=n.layout.get("text-size-scale-range"),w=u.as(s.scaleFactor,x[0],x[1]);g&&(function(I,M,D,L,k,B,$,Z){const G=M.transform,te=k==="map",ee=B==="map";for(const le of I){const K=L.getTile(le),Q=K.getBucket(D);if(!Q||!Q.text||!Q.text.segments.get().length)continue;const ae=u.aZ(Q.textSizeData,G.zoom,Z),de=Xe(le,Q.getProjection(),G),fe=G.calculatePixelsToTileUnitsMatrix(K),be=$s(de,K.tileID.canonical,ee,te,G,Q.getProjection(),fe),Te=Q.hasIconTextFit()&&Q.hasIconData();ae&&m_(Q,te,ee,$,G,be,le,Math.pow(2,G.zoom-K.tileID.overscaledZ),ae,Te)}})(l,s,n,t,n.layout.get("text-rotation-alignment"),n.layout.get("text-pitch-alignment"),d,w);const S=n.paint.get("icon-opacity").constantOr(1)!==0,A=n.paint.get("text-opacity").constantOr(1)!==0;n.layout.get("symbol-sort-key").constantOr(1)!==void 0&&(S||A)?td(s,t,n,l,p,m):(S&&td(s,t,n,l,p,m,{onlyIcons:!0}),A&&td(s,t,n,l,p,m,{onlyText:!0})),t.map.showCollisionBoxes&&(Eu(s,t,n,l,n.paint.get("text-translate"),n.paint.get("text-translate-anchor"),!0),Eu(s,t,n,l,n.paint.get("icon-translate"),n.paint.get("icon-translate-anchor"),!1))},circle:function(s,t,n,l){if(s.renderPass!=="translucent")return;const d=n.paint.get("circle-opacity"),p=n.paint.get("circle-stroke-width"),m=n.paint.get("circle-stroke-opacity"),g=n.layout.get("circle-sort-key").constantOr(1)!==void 0,x=n.paint.get("circle-emissive-strength");if(d.constantOr(1)===0&&(p.constantOr(1)===0||m.constantOr(1)===0))return;const w=s.context,S=w.gl,A=s.transform,I=!(!s.terrain||!s.terrain.enabled),M=n.layout.get("circle-elevation-reference"),D=s.depthModeForSublayer(0,ct.ReadOnly),L=new ct(s.context.gl.LEQUAL,ct.ReadOnly,s.depthRangeFor3D),k=M==="none"||I?D:L,B=mt.disabled,$=s.colorModeForDrapableLayerRenderPass(x),Z=A.projection.name==="globe",G=[u.a_(A.center.lng),u.a$(A.center.lat)],te=[];for(let le=0;le<l.length;le++){const K=l[le],Q=t.getTile(K),ae=Q.getBucket(n);if(!ae||ae.projection.name!==A.projection.name)continue;const de=ae.programConfigurations.get(n.id),fe=ae.layoutVertexBuffer,be=ae.globeExtVertexBuffer,Te=ae.indexBuffer,Ve=u.eK(n),ye=[be],Ae=s.isTileAffectedByFog(K);Z&&Ve.push("PROJECTION_GLOBE_VIEW"),Ve.push("DEPTH_D24"),s.terrain&&A.depthOcclusionForSymbolsAndCircles&&Ve.push("DEPTH_OCCLUSION"),ae.hdExt&&ae.hdExt.hasElevation&&!s.terrain&&(Ve.push("ELEVATED_ROADS"),ye.push(ae.hdExt.elevatedLayoutVertexBuffer));const ge=s.getOrCreateProgram("circle",{config:de,defines:Ve,overrideFog:Ae}),Fe=A.projection.createInversionMatrix(A,K.canonical),Re={programConfiguration:de,program:ge,layoutVertexBuffer:fe,dynamicBuffers:ye,indexBuffer:Te,uniformValues:u.eL(s,K,Q,Fe,G,n),tile:Q};if(g){const De=ae.segments.get();for(const Ke of De)te.push({segments:new u.cr([Ke]),sortKey:Ke.sortKey,state:Re})}else te.push({segments:ae.segments,sortKey:0,state:Re})}g&&te.sort((le,K)=>le.sortKey-K.sortKey);const ee={useDepthForOcclusion:A.depthOcclusionForSymbolsAndCircles};for(const le of te){const{programConfiguration:K,program:Q,layoutVertexBuffer:ae,dynamicBuffers:de,indexBuffer:fe,uniformValues:be,tile:Te}=le.state,Ve=le.segments;s.terrain&&s.terrain.setupElevationDraw(Te,Q,ee),s.uploadCommonUniforms(w,Q,Te.tileID.toUnwrapped()),Q.draw(s,S.TRIANGLES,k,B,$,_t.disabled,be,n.id,ae,fe,Ve,n.paint,A.zoom,K,de)}},heatmap:function(s,t,n,l){if(n.paint.get("heatmap-opacity")!==0)if(s.renderPass==="offscreen"){const d=s.context,p=d.gl,m=mt.disabled,g=new yt([p.ONE,p.ONE,p.ONE,p.ONE],u.C.transparent,[!0,!0,!0,!0]),x=s.transform.projection.name==="globe"?.5:.25;n.heatmapFbo=Ha.createWithTexture(d,n.heatmapFbo,s.width*x,s.height*x),d.clear({color:u.C.transparent});const w=s.transform,S=w.projection.name==="globe",A=S?["PROJECTION_GLOBE_VIEW"]:[],I=S?_t.frontCCW:_t.disabled,M=[u.a_(w.center.lng),u.a$(w.center.lat)];for(let D=0;D<l.length;D++){const L=l[D];if(t.hasRenderableParent(L))continue;const k=t.getTile(L),B=k.getBucket(n);if(!B||B.projection.name!==w.projection.name)continue;const $=s.isTileAffectedByFog(L),Z=B.programConfigurations.get(n.id),G=s.getOrCreateProgram("heatmap",{config:Z,defines:A,overrideFog:$}),{zoom:te}=s.transform;s.terrain&&s.terrain.setupElevationDraw(k,G),s.uploadCommonUniforms(d,G,L.toUnwrapped());const ee=w.projection.createInversionMatrix(w,L.canonical);G.draw(s,p.TRIANGLES,ct.disabled,m,g,I,Jf(s,L,k,ee,M,te,n.paint.get("heatmap-intensity")),n.id,B.layoutVertexBuffer,B.indexBuffer,B.segments,n.paint,s.transform.zoom,Z,S?[B.globeExtVertexBuffer]:null)}d.viewport.set([0,0,s.width,s.height])}else s.renderPass==="translucent"&&(s.context.setColorMode(s.colorModeForRenderPass()),(function(d,p){const m=d.context,g=m.gl,x=p.heatmapFbo;if(!x)return;m.activeTexture.set(g.TEXTURE0),g.bindTexture(g.TEXTURE_2D,x.colorAttachment0.get()),m.activeTexture.set(g.TEXTURE1);let w=p.colorRampTexture;w||(w=p.colorRampTexture=new u.T(m,p.colorRamp,g.RGBA8)),w.bind(g.LINEAR,g.CLAMP_TO_EDGE),d.getOrCreateProgram("heatmapTexture").draw(d,g.TRIANGLES,ct.disabled,mt.disabled,d.colorModeForRenderPass(),_t.disabled,((S,A)=>({u_image:0,u_color_ramp:1,u_opacity:A.paint.get("heatmap-opacity")}))(0,p),p.id,d.viewportBuffer,d.quadTriangleIndexBuffer,d.viewportSegments,p.paint,d.transform.zoom)})(s,n))},line:function(s,t,n,l){const d=n.paint.get("line-opacity"),p=n.paint.get("line-width");if(d.constantOr(1)===0||p.constantOr(1)===0)return;const m=n.paint.get("line-blend-mode"),g=s.terrain&&s.terrain.renderingToTexture;if(m==="default"||s.transform.projection.name==="globe")s.renderPass==="translucent"&&rd(s,t,n,l);else{if(g)return void(function(x,w,S,A,I){if(x.renderPass!=="translucent")return;const M=x.context,D=M.gl,L=x.terrain;if(!L)return;const k=M.bindFramebuffer.current,B=x.emissiveMode==="mrt-fallback",$=L.drapeBufferSize[0],Z=L.drapeBufferSize[1];S.lineBlendFbos||(S.lineBlendFbos=new rp),S.lineBlendFbos.drapeFbo=Ha.createWithTexture(M,S.lineBlendFbos.drapeFbo,$,Z,!0),B&&D.drawBuffers([D.COLOR_ATTACHMENT0]),M.clear({color:Au[I].clearColor,depth:1,stencil:0});const G=x.currentStencilSource,te=x._tileClippingMaskIDs,ee=x.nextStencilID;x.currentStencilSource=void 0,x._tileClippingMaskIDs={},x.nextStencilID=1;const le=x._terrain;x._terrain=null,x._renderTileClippingMasks(S,w,A),rd(x,w,S,A,nd(I,x.context),!0),x._terrain=le,x.currentStencilSource=G,x._tileClippingMaskIDs=te,x.nextStencilID=ee,B&&D.drawBuffers([D.COLOR_ATTACHMENT0,D.COLOR_ATTACHMENT1]);const K=L.drapeBufferSize,Q=S.lineBlendFbos&&S.lineBlendFbos.drapeFbo;Q&&(I==="additive"&&g_(x,S,Q),y_(x,S,I,Q,k,K))})(s,t,n,l,m);if(s.renderPass==="offscreen")return void(function(x,w,S,A,I){const M=x.context,D=Math.ceil(x.width),L=Math.ceil(x.height);S.lineBlendFbos||(S.lineBlendFbos=new rp),S.lineBlendFbos.fbo=Ha.createWithTexture(M,S.lineBlendFbos.fbo,D,L,!0),M.clear({color:Au[I].clearColor,depth:1,stencil:0});const k=x.currentStencilSource,B=x._tileClippingMaskIDs,$=x.nextStencilID;x.currentStencilSource=void 0,x._tileClippingMaskIDs={},x.nextStencilID=1,x._renderTileClippingMasks(S,w,A);const Z=x.renderPass;x.renderPass="translucent",rd(x,w,S,A,nd(I,x.context)),x.renderPass=Z,x.currentStencilSource=k,x._tileClippingMaskIDs=B,x.nextStencilID=$,M.viewport.set([0,0,x.width,x.height]),I==="additive"&&g_(x,S,S.lineBlendFbos.fbo)})(s,t,n,l,m);if(s.renderPass==="translucent"){const x=n.lineBlendFbos&&n.lineBlendFbos.fbo;return void(x&&y_(s,n,m,x,null))}}},fill:function(s,t,n,l){const d=n.paint.get("fill-color"),p=n.paint.get("fill-opacity");if(p.constantOr(1)===0)return;const m=n.paint.get("fill-emissive-strength"),g=s.colorModeForDrapableLayerRenderPass(m),x=n.paint.get("fill-pattern"),w=s.opaquePassEnabledForLayer()&&!x.constantOr(1)&&d.constantOr(u.C.transparent).a===1&&p.constantOr(0)===1?"opaque":"translucent";let S="none";n.layout.get("fill-elevation-reference")!=="none"?S="road":n.paint.get("fill-z-offset").constantOr(1)!==0&&(S="offset");const A=!(!s.terrain||!s.terrain.enabled),I={painter:s,sourceCache:t,layer:n,coords:l,colorMode:g,elevationType:S,terrainEnabled:A,pass:w};if(s.renderPass==="shadow")return void(s.shadowRenderer&&S==="road"&&!A&&jt.drawElevatedFillShadows&&jt.drawElevatedFillShadows(I));const M=s.emissiveMode==="mrt-fallback";if(S!=="offset"){if(op(I,!1,M),S==="road"){const D=!A&&s.renderPass==="translucent";D&&jt.drawDepthPrepass&&jt.drawDepthPrepass(s,t,n,l,"geometry"),op(I,!0,M,mt.disabled),D&&jt.drawElevatedStructures&&jt.drawElevatedStructures(I)}}else op(I,!1,M,s.stencilModeFor3D())},"fill-extrusion":function(s,t,n,l){const d=n.paint.get("fill-extrusion-opacity"),p=s.context,m=p.gl,g=s.terrain,x=g&&g.renderingToTexture;if(d===0)return;const w=s.emissiveMode==="mrt-fallback",S=s.conflationActive&&s.style.isLayerClipped(n,t.getSource()),A=s.style.order.indexOf(n.fqid);if(S&&(function(I,M,D,L,k){for(const B of L){const $=M.getTile(B).getBucket(D);$&&($.updateReplacement(B,I.replacementSource,k),$.uploadCentroid(I.context))}})(s,t,n,l,A),g||S)for(const I of l){const M=t.getTile(I).getBucket(n);M&&nf(s.context,t,I,M,n,g,S)}if(s.renderPass==="shadow"&&s.shadowRenderer){if(g&&d<.65&&n._transitionablePaint._values["fill-extrusion-opacity"].value.expression instanceof u.ab)return;const I=s.shadowRenderer.getShadowPassDepthMode();dc(s,t,n,l,I,mt.disabled,yt.disabled,S)}else if(s.renderPass==="translucent"){const I=!n.paint.get("fill-extrusion-pattern").constantOr(1),M=n.paint.get("fill-extrusion-color").constantOr(u.C.white);if(!x&&M.a!==0){const L=new ct(s.context.gl.LEQUAL,ct.ReadWrite,s.depthRangeFor3D);d===1&&I?dc(s,t,n,l,L,mt.disabled,yt.unblended,S):(dc(s,t,n,l,L,mt.disabled,yt.disabled,S),dc(s,t,n,l,L,s.stencilModeFor3D(),s.colorModeForRenderPass(),S),s.resetStencilClippingMasks())}const D=s.style.enable3dLights()&&I&&(!g&&s.transform.projection.name!=="globe"||x);if(D&&!mo.drawGroundEffect&&rf(),D&&mo.drawGroundEffect){const L=n.paint.get("fill-extrusion-opacity"),k=n.paint.get("fill-extrusion-ambient-occlusion-intensity"),B=n.paint.get("fill-extrusion-ambient-occlusion-ground-radius"),$=n.paint.get("fill-extrusion-flood-light-intensity"),Z=n.paint.get("fill-extrusion-flood-light-color-use-theme").
3401constantOr("default")==="none",G=n.paint.get("fill-extrusion-flood-light-color").toNonPremultipliedRenderColor(Z?null:n.lut).toArray01().slice(0,3),te=k>0&&B>0,ee=$>0,le=new uh;le.translate=n.paint.get("fill-extrusion-translate"),le.translateAnchor=n.paint.get("fill-extrusion-translate-anchor"),le.edgeRadius=n.layout.get("fill-extrusion-edge-radius"),le.cutoffFadeRange=n.paint.get("fill-extrusion-cutoff-fade-range");const K=Q=>{const ae=s.depthModeForSublayer(1,ct.ReadOnly,m.LEQUAL,!0),de=n.paint.get(Q?"fill-extrusion-ambient-occlusion-ground-attenuation":"fill-extrusion-flood-light-ground-attenuation"),fe=u.ai(.1,3,de),be=s._showOverdrawInspector;if(!be){const Te=new mt({func:m.ALWAYS,mask:255},255,255,m.KEEP,m.KEEP,m.REPLACE),Ve=new yt([m.ONE,m.ONE,m.ONE,m.ONE],u.C.transparent,[!1,!1,!1,!0],m.MIN);mo.drawGroundEffect(le,s,t,n,l,ae,Te,Ve,_t.disabled,Q,"sdf",L,k,B,$,G,fe,S,!1)}{const Te=be?mt.disabled:new mt({func:m.EQUAL,mask:255},255,255,m.KEEP,m.DECR,m.DECR),Ve=be?s.colorModeForRenderPass():new yt([m.ONE_MINUS_DST_ALPHA,m.DST_ALPHA,m.ONE,m.ONE],u.C.transparent,[!0,!0,!0,!0]);mo.drawGroundEffect(le,s,t,n,l,ae,Te,Ve,_t.disabled,Q,"color",L,k,B,$,G,fe,S,!1)}};if(x){const Q=()=>{const de=g.drapeBufferSize[0],fe=g.drapeBufferSize[1];let be=g.framebufferCopyTexture;return be&&(!be||be.size[0]===de&&be.size[1]===fe)||(be&&be.destroy(),be=g.framebufferCopyTexture=new u.T(p,new u.t({width:de,height:fe}),m.RGBA8)),be.bind(m.LINEAR,m.CLAMP_TO_EDGE),m.copyTexSubImage2D(m.TEXTURE_2D,0,0,0,0,0,de,fe),be},ae=(de,fe,be)=>{const Te=s.depthModeForSublayer(1,ct.ReadOnly,m.LEQUAL,!1),Ve=n.paint.get(de?"fill-extrusion-ambient-occlusion-ground-attenuation":"fill-extrusion-flood-light-ground-attenuation"),ye=u.ai(.1,3,Ve);{const Ae=new yt([m.ONE,m.ONE,m.ONE,m.ONE],u.C.transparent,[!1,!1,!1,!0]);mo.drawGroundEffect(le,s,t,n,l,Te,mt.disabled,Ae,_t.disabled,de,"clear",L,k,B,$,G,ye,S,fe)}{const Ae=new mt({func:m.ALWAYS,mask:255},255,255,m.KEEP,m.KEEP,m.REPLACE),ge=new yt([m.ONE,m.ONE,m.ONE,m.ONE],u.C.transparent,[!1,!1,!1,!0],m.MIN);mo.drawGroundEffect(le,s,t,n,l,Te,Ae,ge,_t.disabled,de,"sdf",L,k,B,$,G,ye,S,fe)}w&&!de&&(be=Q());{const Ae=de?m.ZERO:m.ONE_MINUS_DST_ALPHA,ge=new mt({func:m.EQUAL,mask:255},255,255,m.KEEP,m.DECR,m.DECR),Fe=new yt([Ae,m.DST_ALPHA,m.ONE_MINUS_DST_ALPHA,m.ZERO],u.C.transparent,[!0,!0,!0,!0]);mo.drawGroundEffect(le,s,t,n,l,Te,ge,Fe,_t.disabled,de,"color",L,k,B,$,G,ye,S,fe)}if(!w||de){const Ae=new yt([m.ONE,m.ONE,m.ONE,de?m.ZERO:m.ONE],u.C.transparent,[!1,!1,!1,!0],de?m.FUNC_ADD:m.MAX);mo.drawGroundEffect(le,s,t,n,l,Te,mt.disabled,Ae,_t.disabled,de,"clear",L,k,B,$,G,ye,S,fe,be)}else{m.drawBuffers([m.NONE,m.COLOR_ATTACHMENT1]);const Ae=new mt({func:m.EQUAL,mask:255},254,255,m.KEEP,m.DECR,m.DECR),ge=new yt([m.ONE,m.ONE,m.ONE,m.ONE],u.C.transparent,[!0,!1,!1,!1],m.MAX);mo.drawGroundEffect(le,s,t,n,l,Te,Ae,ge,_t.disabled,de,"emissive",L,k,B,$,G,ye,S,fe,be),m.drawBuffers([m.COLOR_ATTACHMENT0])}};if(te||ee){let de;s.prepareDrawTile(),w&&!te||(de=Q()),te&&ae(!0,!1,de),ee&&ae(!1,!0,de)}}else te&&K(!0),ee&&K(!1),(te||ee)&&s.resetStencilClippingMasks()}}},hillshade:function(s,t,n,l){if(s.renderPass!=="offscreen"&&s.renderPass!=="translucent"||s.style.disableElevatedTerrain)return;const d=s.context,p=s.terrain&&s.terrain.renderingToTexture,[m,g]=s.renderPass!=="translucent"||p?[{},l]:s.stencilConfigForOverlap(l);for(const x of g){const w=t.getTile(x);if(w.needsHillshadePrepare&&s.renderPass==="offscreen")wu(s,w,n);else if(s.renderPass==="translucent"){const S=s.depthModeForSublayer(0,ct.ReadOnly),A=n.paint.get("hillshade-emissive-strength"),I=s.colorModeForDrapableLayerRenderPass(A),M=p&&s.terrain?s.terrain.stencilModeForRTTOverlap(x):m[x.overscaledZ];l_(s,x,w,n,S,M,I)}}d.viewport.set([0,0,s.width,s.height]),s.resetStencilClippingMasks()},raster:function(s,t,n,l,d,p){if(s.renderPass!=="translucent")return;const m=n.paint.get("raster-opacity");if(m===0)return;const g=s.transform.projection.name==="globe",x=n.paint.get("raster-elevation")!==0,w=x&&g,S=s.terrain&&s.terrain.exaggeration()>0&&x&&n.paint.get("raster-elevation-reference")==="ground",A=!g&&S;if(s.renderElevatedRasterBackface&&!w)return;const I=s.context,M=I.gl,D=t.getSource(),L=(function(Q,ae,de,fe,be){const Te=ae.paint.get("raster-color"),Ve=Q.type==="raster-array",ye=[],Ae=ae.paint.get("raster-resampling"),ge=ae.paint.get("raster-color-mix");let Fe=ae.paint.get("raster-color-range");const Re=[ge[0],ge[1],ge[2],0],De=ge[3];let Ke=Ae==="nearest"?fe.NEAREST:fe.LINEAR;if(Ve&&(ye.push("RASTER_ARRAY"),Te||ye.push("RASTER_COLOR"),Ae==="linear"&&ye.pu
3401sh("RASTER_ARRAY_LINEAR"),Ke=fe.NEAREST,!Fe&&Q.rasterLayers)){const Be=Q.rasterLayers.find(({id:Ge})=>Ge===ae.sourceLayer);Be&&Be.fields&&Be.fields.range&&(Fe=Be.fields.range)}if(Fe=Fe||[0,1],Te){ye.push("RASTER_COLOR"),de.activeTexture.set(fe.TEXTURE2),ae.updateColorRamp(Fe);let Be=ae.colorRampTexture;Be||(Be=ae.colorRampTexture=new u.T(de,ae.colorRamp,fe.RGBA8)),Be.bind(Ke,fe.CLAMP_TO_EDGE)}return be&&ye.push("USE_MRT1"),{mix:Re,range:Fe,offset:De,defines:ye,resampling:Ke}})(D,n,I,M,s.terrain&&s.terrain.renderingToTexture&&s.emissiveMode==="mrt-fallback");if(D instanceof No&&!l.length&&!g)return;const k=n.paint.get("raster-emissive-strength"),B=s.colorModeForDrapableLayerRenderPass(k),$=s.terrain&&s.terrain.renderingToTexture,Z=!s.options.moving,G=n.paint.get("raster-resampling")==="nearest"?M.NEAREST:M.LINEAR;if(D instanceof No&&!l.length&&(D.onNorthPole||D.onSouthPole)){const Q=x?s.stencilModeFor3D():mt.disabled;return void Fi(!!D.onNorthPole,null,s,t,n,k,L,_t.disabled,Q)}if(!l.length)return;const[te,ee]=D instanceof No||$?[{},l]:s.stencilConfigForOverlap(l),le=ee.at(-1).overscaledZ;w&&L.defines.push("PROJECTION_GLOBE_VIEW"),x&&L.defines.push("RENDER_CUTOFF","ELEVATED"),S&&L.defines.push("ELEVATION_REFERENCE_GROUND");const K=(Q,ae,de)=>{for(const fe of Q){const be=fe.toUnwrapped(),Te=t.getTile(fe);if($&&(!Te||!Te.hasData()))continue;I.activeTexture.set(M.TEXTURE0);const Ve=uy(Te,D,n,L);if(!Ve||!Ve.texture)continue;const{texture:ye,mix:Ae,offset:ge,tileSize:Fe,buffer:Re}=Ve;let De,Ke;$?(De=ct.disabled,Ke=fe.projMatrix):x?(De=new ct(M.LEQUAL,ct.ReadWrite,s.depthRangeFor3D),Ke=g?s.transform.expandedFarZProjMatrix:s.transform.calculateProjMatrix(be,Z)):(De=s.depthModeForSublayer(fe.overscaledZ-le,m===1?ct.ReadWrite:ct.ReadOnly,M.LESS),Ke=s.transform.calculateProjMatrix(be,Z));const Be=s.terrain&&$?s.terrain.stencilModeForRTTOverlap(fe):te[fe.overscaledZ],Ge=p?0:n.paint.get("raster-fade-duration");Te.registerFadeDuration(Ge);const Ze=t.findLoadedParent(fe,0),tt=nu(Te,Ze,t,s.transform,Ge);let ot,at;!tt.isFading&&Te.refreshedUponExpiration&&(Te.refreshedUponExpiration=!1),s.terrain&&s.terrain.prepareDrawTile(),I.activeTexture.set(M.TEXTURE0),ye.bind(G,M.CLAMP_TO_EDGE),I.activeTexture.set(M.TEXTURE1),Ze?(Ze.texture&&Ze.texture.bind(G,M.CLAMP_TO_EDGE),ot=Math.pow(2,Ze.tileID.overscaledZ-Te.tileID.overscaledZ),at=[Te.tileID.canonical.x*ot%1,Te.tileID.canonical.y*ot%1]):ye.bind(G,M.CLAMP_TO_EDGE),"useMipmap"in ye&&I.extTextureFilterAnisotropic&&s.transform.pitch>20&&M.texParameterf(M.TEXTURE_2D,I.extTextureFilterAnisotropic.TEXTURE_MAX_ANISOTROPY_EXT,I.extTextureFilterAnisotropicMax);const ut=s.transform;let bt;const pt=x?Mc(ut):[0,0,0,0];let Lt,kt,gt,Pt,Ct,Ut=0;if(w&&D instanceof No&&D.coordinates.length>3)Lt=Float32Array.from(u.d3(u.dn(new u.bu(0,0,0)))),kt=Float32Array.from(ut.globeMatrix),gt=Float32Array.from(u.dp(ut)),Pt=[u.a_(ut.center.lng),u.a$(ut.center.lat)],bt=D.elevatedGlobePerspectiveTransform,Ct=D.elevatedGlobeGridMatrix||new Float32Array(9);else if(w){const Kt=u.dl(fe.canonical);Ut=u.dm(Kt.getCenter().lat),Lt=Float32Array.from(u.d3(u.dn(fe.canonical))),kt=Float32Array.from(ut.globeMatrix),gt=Float32Array.from(u.dp(ut)),Pt=[u.a_(ut.center.lng),u.a$(ut.center.lat)],bt=[0,0],Ct=Float32Array.from(u.dq(fe.canonical,Kt,Ut,ut.worldSize/ut._pixelsPerMercatorPixel))}else bt=D instanceof No?D.perspectiveTransform:[0,0],Lt=new Float32Array(16),kt=new Float32Array(9),gt=new Float32Array(16),Pt=[0,0],Ct=new Float32Array(9);const oi=Xh(s,Ke,Lt,kt,gt,Ct,at||[0,0],u.ah(s.transform.zoom),Pt,pt,ot||1,tt,n,bt,x?n.paint.get("raster-elevation"):0,2,Ae,ge,L.range,Fe,Re,k),Ci=s.isTileAffectedByFog(fe),hi=s.getOrCreateProgram("raster",{defines:L.defines,overrideFog:Ci});if(s.uploadCommonUniforms(I,hi,be),D instanceof No){const Kt=D.elevatedGlobeVertexBuffer,Ei=D.elevatedGlobeIndexBuffer;if($||!g)D.boundsBuffer&&D.boundsSegments&&hi.draw(s,M.TRIANGLES,De,mt.disabled,B,_t.disabled,oi,n.id,D.boundsBuffer,s.quadTriangleIndexBuffer,D.boundsSegments);else if(Kt&&Ei){const mi=ut.zoom<=u.bU?D.elevatedGlobeSegments:D.getSegmentsForLongitude(ut.center.lng);mi&&hi.draw(s,M.TRIANGLES,De,mt.disabled,B,ae,oi,n.id,Kt,Ei,mi)}}else if(w){De=new ct(M.LEQUAL,ct.ReadOnly,s.depthRangeFor3D);const Kt=s.globeSharedBuffers;
vendor: 9,637 bytes, line 3401
3401if(Kt){S&&(s.terrain.setupElevationDraw(Te,hi),s.uploadCommonUniforms(I,hi,Te.tileID.toUnwrapped()));const[Ei,mi,Qi]=Kt.getGridBuffers(Ut,!1),Ot=hi.getAttributeLocation(M,"a_texture_pos");Ot!==-1&&M.vertexAttribI4ui(Ot,0,0,0,0),hi.draw(s,M.TRIANGLES,De,de||Be,s.colorModeForRenderPass(),ae,oi,n.id,Ei,mi,Qi)}}else if(A)De=new ct(M.LEQUAL,ct.ReadWrite,s.depthRangeFor3D),s.terrain.setupElevationDraw(Te,hi),s.uploadCommonUniforms(I,hi,Te.tileID.toUnwrapped()),ut.pitch>20&&hi.draw(s,M.TRIANGLES,De,mt.disabled,yt.disabled,_t.frontCCW,oi,n.id,s.terrain.gridBuffer,s.terrain.gridIndexBuffer,s.terrain.gridSegments),hi.draw(s,M.TRIANGLES,De,Be,B,_t.backCCW,oi,n.id,s.terrain.gridBuffer,s.terrain.gridIndexBuffer,s.terrain.gridSegments);else{const{tileBoundsBuffer:Kt,tileBoundsIndexBuffer:Ei,tileBoundsSegments:mi}=s.getTileBoundsBuffers(Te);hi.draw(s,M.TRIANGLES,De,Be,B,_t.disabled,oi,n.id,Kt,Ei,mi)}}if(!(D instanceof No)&&w)for(const fe of Q){const be=fe.canonical.y===(1<<fe.canonical.z)-1;fe.canonical.y===0&&Fi(!0,fe,s,t,n,k,L,ae,de||mt.disabled),be&&Fi(!1,fe,s,t,n,k,L,ae===_t.frontCW?_t.backCW:_t.frontCW,de||mt.disabled)}};w?K(ee,s.renderElevatedRasterBackface?_t.backCW:_t.frontCW,s.stencilModeFor3D()):K(ee,_t.disabled,void 0),s.resetStencilClippingMasks()},background:function(s,t,n,l){const d=n.paint.get("background-color"),p=n.paint.get("background-color-use-theme").constantOr("default")==="none",m=n.paint.get("background-opacity"),g=n.paint.get("background-emissive-strength"),x=n.paint.get("background-pitch-alignment")==="viewport";if(m===0)return;const w=s.context,S=w.gl,A=s.transform,I=A.tileSize,M=n.paint.get("background-pattern");let D;if(M!==void 0&&(M===null||(D=s.imageManager.getPattern(u.I.from(M.toString()),n.scope,s.style.getLut(n.scope)),!D)))return;const L=!M&&d.a===1&&m===1&&s.opaquePassEnabledForLayer()?"opaque":"translucent";if(s.renderPass!==L)return;const k=mt.disabled,B=s.depthModeForSublayer(0,L==="opaque"?ct.ReadWrite:ct.ReadOnly),$=s.colorModeForDrapableLayerRenderPass(g),Z=M?"backgroundPattern":"background";let G,te=l;te||(G=s.getBackgroundTiles(),te=Object.values(G).map(le=>le.tileID)),M&&(w.activeTexture.set(S.TEXTURE0),s.imageManager.bind(s.context,n.scope));const ee=[];if(s.terrain&&s.terrain.renderingToTexture&&s.emissiveMode==="mrt-fallback"&&ee.push("USE_MRT1"),x){const le=s.getOrCreateProgram(Z,{overrideFog:!1,overrideRtt:!0,defines:ee}),K=hy,Q=new u.br(0,0,0,0,0),ae=M?Jh(K,g,m,s,0,n.scope,D,x,{tileID:Q,tileSize:I}):Kh(K,g,m,d.toPremultipliedRenderColor(p?null:n.lut));return void le.draw(s,S.TRIANGLES,B,k,$,_t.disabled,ae,n.id,s.viewportBuffer,s.quadTriangleIndexBuffer,s.viewportSegments)}for(const le of te){const K=s.isTileAffectedByFog(le),Q=s.getOrCreateProgram(Z,{overrideFog:K,defines:ee}),ae=le.toUnwrapped(),de=l?le.projMatrix:s.transform.calculateProjMatrix(ae);s.prepareDrawTile();const fe=t?t.getTile(le):G?G[le.key]:new _c(le,I,A.zoom,s),be=M?Jh(de,g,m,s,0,n.scope,D,x,{tileID:le,tileSize:I}):Kh(de,g,m,d.toPremultipliedRenderColor(p?null:n.lut));s.uploadCommonUniforms(w,Q,ae);const{tileBoundsBuffer:Te,tileBoundsIndexBuffer:Ve,tileBoundsSegments:ye}=s.getTileBoundsBuffers(fe);Q.draw(s,S.TRIANGLES,B,k,$,_t.disabled,be,n.id,Te,Ve,ye)}},sky:function(s,t,n){const l=s._atmosphere?u.ah(s.transform.zoom):1,d=n.paint.get("sky-opacity")*l;if(d===0)return;const p=s.context,m=n.paint.get("sky-type"),g=new ct(p.gl.LEQUAL,ct.ReadOnly,[0,1]),x=s.frameCounter/1e3%1;m==="atmosphere"?s.renderPass==="offscreen"?n.needsSkyboxCapture(s)&&((function(w,S){const A=w.context,I=A.gl;let M=S.skyboxFbo;if(!M){M=S.skyboxFbo=A.createFramebuffer(32,32,1,null),S.skyboxGeometry=new ap(A),S.skyboxTexture=A.gl.createTexture(),I.bindTexture(I.TEXTURE_CUBE_MAP,S.skyboxTexture),I.texParameteri(I.TEXTURE_CUBE_MAP,I.TEXTURE_WRAP_S,I.CLAMP_TO_EDGE),I.texParameteri(I.TEXTURE_CUBE_MAP,I.TEXTURE_WRAP_T,I.CLAMP_TO_EDGE),I.texParameteri(I.TEXTURE_CUBE_MAP,I.TEXTURE_MIN_FILTER,I.LINEAR),I.texParameteri(I.TEXTURE_CUBE_MAP,I.TEXTURE_MAG_FILTER,I.LINEAR);for(let B=0;B<6;++B)I.texImage2D(I.TEXTURE_CUBE_MAP_POSITIVE_X+B,0,I.RGBA,32,32,0,I.RGBA,I.UNSIGNED_BYTE,null)}A.bindFramebuffer.set(M.framebuffer),A.viewport.set([0,0,32,32]);const D=S.getCenter(w,!0),L=w.getOrCreateProgram("skyboxCapture"),k=new Float64Array(16);u.eU(k,.5*-Math.PI),ta(w,S,L,k,D,0),u.eU(k,.5*Math.PI),ta(w,S,L,k,D,1),u.eV(k,.5*-Math.PI),ta(w,S,L,k,D,2),u.eV(k,.5*Math.PI),ta(w,S,L,k,D,3),u.aC(k),ta(w,S,L,k,D,4),u.eU(k,Math.PI),ta(w,S,L,k,D,5),A.viewport.set([0,0,w.width,w.height])})(s,n),n.markSkyboxValid(s)):s.renderPass==="sky"&&(function(w,S,A,I,M){const D=w.context,L=D.gl,k=w.transform,B=w.getOrCreateProgram("skybox");D.activeTexture.set(L.TEXTURE0),L.bindTexture(L.TEXTURE_CUBE_MAP,S.skyboxTexture);const $=((Z,G,te,ee,le)=>({u_matrix:Z,u_sun_direction:G,u_cubemap:0,u_opacity:ee,u_temporal_offset:le}))(k.skyboxMatrix,S.getCenter(w,!1),0,I,M);w.uploadCommonUniforms(D,B),B.draw(w,L.TRIANGLES,A,mt.disabled,w.colorModeForRenderPass(),_t.backCW,$,"skybox",S.skyboxGeometry.vertexBuffer,S.skyboxGeometry.indexBuffer,S.skyboxGeometry.segment)})(s,n,g,d,x):m==="gradient"&&s.renderPass==="sky"&&(function(w,S,A,I,M){const D=w.context,L=D.gl,k=w.transform,B=w.getOrCreateProgram("skyboxGradient");S.skyboxGeometry||(S.skyboxGeometry=new ap(D)),D.activeTexture.set(L.TEXTURE0);let $=S.colorRampTexture;$||($=S.colorRampTexture=new u.T(D,S.colorRamp,L.RGBA8)),$.bind(L.LINEAR,L.CLAMP_TO_EDGE);const Z=((G,te,ee,le,K)=>({u_matrix:G,u_color_ramp:0,u_center_direction:te,u_radius:u.al(ee),u_opacity:le,u_temporal_offset:K}))(k.skyboxMatrix,S.getCenter(w,!1),S.paint.get("sky-gradient-radius"),I,M);w.uploadCommonUniforms(D,B),B.draw(w,L.TRIANGLES,A,mt.disabled,w.colorModeForRenderPass(),_t.backCW,Z,"skyboxGradient",S.skyboxGeometry.vertexBuffer,S.skyboxGeometry.indexBuffer,S.skyboxGeometry.segment)})(s,n,g,d,x)},custom:function(s,t,n,l){const d=s.context,p=n.implementation;if(!s.transform.projection.unsupportedLayers||!s.transform.projection.unsupportedLayers.includes("custom")||s.terrain&&(s.terrain.renderingToTexture||s.renderPass==="offscreen")&&n.isDraped(t)){if(s.renderPass==="offscreen"){const m=p.prerender;if(m){if(s.setCustomLayerDefaults(),d.setColorMode(s.colorModeForRenderPass()),s.transform.projection.name==="globe"){const g=s.transform.pointMerc;m.call(p,d.gl,s.transform.customLayerMatrix(),s.transform.getProjection(),s.transform.globeToMercatorMatrix(),u.ah(s.transform.zoom),[g.x,g.y],s.transform.pixelsPerMeterRatio)}else m.call(p,d.gl,s.transform.customLayerMatrix());d.setDirty(),s.setBaseState()}}else if(s.renderPass==="translucent"){if(s.terrain&&s.terrain.renderingToTexture){const g=p.renderToTile;if(g){const x=l[0].canonical,w={x:x.x+l[0].wrap*(p.wrapTileId?0:1<<x.z),y:x.y,z:x.z};d.setDepthMode(ct.disabled),d.setStencilMode(mt.disabled),d.setColorMode(s.colorModeForRenderPass()),s.setCustomLayerDefaults();const S=d.gl;s.emissiveMode==="mrt-fallback"&&S.drawBuffers([S.COLOR_ATTACHMENT0]),g.call(p,d.gl,w),s.emissiveMode==="mrt-fallback"&&S.drawBuffers([S.COLOR_ATTACHMENT0,S.COLOR_ATTACHMENT1]),d.setDirty(),s.setBaseState()}return}s.setCustomLayerDefaults(),d.setColorMode(s.colorModeForRenderPass()),d.setStencilMode(mt.disabled);const m=p.renderingMode==="3d"?new ct(s.context.gl.LEQUAL,ct.ReadWrite,s.depthRangeFor3D):s.depthModeForSublayer(0,ct.ReadOnly);if(d.setDepthMode(m),s.transform.projection.name==="globe"){const g=s.transform.pointMerc;p.render(d.gl,s.transform.customLayerMatrix(),s.transform.getProjection(),s.transform.globeToMercatorMatrix(),u.ah(s.transform.zoom),[g.x,g.y],s.transform.pixelsPerMeterRatio)}else p.render(d.gl,s.transform.customLayerMatrix());d.setDirty(),s.setBaseState(),d.bindFramebuffer.set(null)}}else u.w("Custom layers are not yet supported with this projection. Use mercator or globe to enable usage of custom layers.")}},ra={line:function(s,t,n){if(s.hasElevatedBuckets=!1,s.hasNonElevatedBuckets=!1,s._unevaluatedLayout.getValue("line-elevation-reference")!==void 0||s._unevaluatedLayout.getValue("line-z-offset")!==void 0){if(t){const l=t.getVisibleCoordinates();for(const d of l){const p=t.getTile(d).getBucket(s);if(p&&(p.elevationType!=="none"?s.hasElevatedBuckets=!0:s.hasNonElevatedBuckets=!0,s.hasElevatedBuckets&&s.hasNonElevatedBuckets))break}}}else s.hasNonElevatedBuckets=!0},raster:function(s,t,n){const l=t.getSource();if(!(l instanceof bl&&l.loaded()))return;const d=s.sourceLayer||l.rasterLayerIds&&l.rasterLayerIds[0];if(!d)return;const p=s.paint.get("raster-array-band")||l.getInitialBand(d);if(p==null)return;const m=t.getIds().map(g=>t.getTileByID(g));for(const g of m)g.updateNeeded(s.id,p)&&l.prepareTile(g,d,s.id,p)}};async function hs(s){if(await rf(),Object.assign(vo,{model:mo.drawModels}),Object.assign(ra,{model:mo.prepare}),s&&!s._shadowRenderer){const t=mo.ShadowRenderer;t&&(s._shadowRenderer=new t(s))}}class py{constructor(t,n,l,d,p){this.context=new ed(t,n),this.transform=l,this._tileTextures={},this.frameCopies=[],this.loadTimeStamps=[],this.frcCoverageSnapshot=null,this.elevationCoverageSnapshot=null,this.elevationProvidersReady=void 0,this.frcCoverageFadeRange=null,this.frcCoverageSourceLayers=[],this.frcCoverageRenderer=jt.FrcCoverageRenderer?new jt.FrcCoverageRenderer:null,this._debugParams={averageFPS:0,fpsHistory:[],fpsWindow:30,continousRedraw:!1,enabledLayers:{},buildingsShowNormals:!1,buildingsDrawGroundAO:!0,buildingsDrawShadowPass:!0,buildingsDrawTranslucentPass:!0,showTerrainProxyTiles:!1,terrainSortTilesHiZFirst:!0,terrainDisableRenderCache:!1,forceEnablePrecipitation:!1,overrideSnowParams:!1,snowParamsOverride:null,snowRevealParamsOverride:null,snowVignetteParam
3401sOverride:null,overrideRainParams:!1,rainParamsOverride:null,rainRevealParamsOverride:null,rainVignetteParamsOverride:null,overrideStarsParams:!1,starsParamsOverride:null,show3DModelFootprints:!1,showElevationIdDebug:!1,lodSwitchDistance:-1,lodSwitchFadeDuration:.5},this.occlusionParams=new ia,this.setup(),this.numSublayers=$n.maxUnderzooming+$n.maxOverzooming+1,this.depthEpsilon=1/Math.pow(2,16),this.deferredRenderGpuTimeQueries=[],this.gpuTimers={},this.frameCounter=0,this.frameTimeDelta=0,this.lastPaintStartTimeStamp=0,this._shadowCullCache=null,this._backgroundTiles={},this.conflationActive=!1,this.replacementSource=new u.f1,this.longestCutoffRange=0,this.minCutoffZoom=0,this._fogVisible=!1,this._cachedTileFogOpacities={},this._wireframeDebugCache=new ya,this.renderDefaultNorthPole=!0,this.renderDefaultSouthPole=!0,this.layersWithOcclusionOpacity=[];const m=new u.t({width:1,height:1},Uint8Array.of(0,0,0,0));this.emptyDepthTexture=new u.T(this.context,m,t.RGBA8),this._clippingActiveLastFrame=!1,this.scaleFactor=d,this.maxFrontCutoffRawStart=0,this.worldview=p,this._forceEmissiveMode=!1,this.emissiveMode="constant"}updateTerrain(t,n){const l=!!t&&!!t.terrain&&this.transform.projection.supportsTerrain;if(!(l||this._terrain&&this._terrain.enabled))return;this._terrain||(this._terrain=new qh(this,t));const d=this._terrain;this.transform.elevation=l?d:null,d.update(t,this.transform,n),this.transform.elevation&&!d.enabled&&(this.transform.elevation=null)}_updateFog(t){const n=t.fog;if(!n||this.transform.projection.name==="globe"||n.getOpacity(this.transform.pitch)<1||n.properties.get("horizon-blend")<.03)return void(this.transform.fogCullDistSq=null);const[l,d]=n.getRangeForProjection();if(l>d)return void(this.transform.fogCullDistSq=null);const p=l+.78*(d-l);this.transform.fogCullDistSq=p*p}get terrain(){return this.transform._terrainEnabled()&&this._terrain&&this._terrain.enabled||this._forceTerrainMode?this._terrain:null}get forceTerrainMode(){return this._forceTerrainMode}set forceTerrainMode(t){t&&!this._terrain&&(this._terrain=new qh(this,this.style)),this._forceTerrainMode=t}get shadowRenderer(){return this._shadowRenderer&&this._shadowRenderer.enabled?this._shadowRenderer:null}get wireframeDebugCache(){return this._wireframeDebugCache}resize(t,n){if(this.width=t*u.r.devicePixelRatio,this.height=n*u.r.devicePixelRatio,this.context.viewport.set([0,0,this.width,this.height]),this.style)for(const l of this.style.order)this.style._mergedLayers[l].resize()}setup(){const t=this.context,n=new u.co;n.emplaceBack(0,0),n.emplaceBack(u.aj,0),n.emplaceBack(0,u.aj),n.emplaceBack(u.aj,u.aj),this.tileExtentBuffer=t.createVertexBuffer(n,u.cq.members),this.tileExtentSegments=u.cr.simpleSegment(0,0,4,2);const l=new u.co;l.emplaceBack(0,0),l.emplaceBack(u.aj,0),l.emplaceBack(0,u.aj),l.emplaceBack(u.aj,u.aj),this.debugBuffer=t.createVertexBuffer(l,u.cq.members),this.debugSegments=u.cr.simpleSegment(0,0,4,5);const d=new u.co;d.emplaceBack(-1,-1),d.emplaceBack(1,-1),d.emplaceBack(-1,1),d.emplaceBack(1,1),this.viewportBuffer=t.createVertexBuffer(d,u.cq.members),this.viewportSegments=u.cr.simpleSegment(0,0,4,2);const p=new u.cQ;p.emplaceBack(0,0,0,0),p.emplaceBack(u.aj,0,u.aj,0),p.emplaceBack(0,u.aj,0,u.aj),p.emplaceBack(u.aj,u.aj,u.aj,u.aj),this.mercatorBoundsBuffer=t.createVertexBuffer(p,_h.members),this.mercatorBoundsSegments=u.cr.simpleSegment(0,0,4,2);const m=new u.cp;m.emplaceBack(0,1,2),m.emplaceBack(2,1,3),this.quadTriangleIndexBuffer=t.createIndexBuffer(m);const g=new u.d0;for(const w of[0,1,3,2,0])g.emplaceBack(w);this.debugIndexBuffer=t.createIndexBuffer(g),this.emptyTexture=new u.T(t,new u.t({width:1,height:1},Uint8Array.of(0,0,0,0)),t.gl.RGBA8),this.identityMat=u.aS();const x=this.context.gl;this.stencilClearMode=new mt({func:x.ALWAYS,mask:0},0,255,x.ZERO,x.ZERO,x.ZERO),this.loadTimeStamps.push(performance.now())}getMercatorTileBoundsBuffers(){return{tileBoundsBuffer:this.mercatorBoundsBuffer,tileBoundsIndexBuffer:this.quadTriangleIndexBuffer,tileBoundsSegments:this.mercatorBoundsSegments}}getTileBoundsBuffers(t){return t._makeTileBoundsBuffers(this.context,this.transform.projection),t._tileBoundsBuffer?{tileBoundsBuffer:t._tileBoundsBuffer,tileBoundsIndexBuffer:t._tileBoundsIndexBuffer,tileBoundsSegments:t._tileBoundsSegments}:this.getMercatorTileBoundsBuffers()}clearStencil(){const t=this.context.gl;this.nextStencilID=1,this.currentStencilSource=void 0,this._tileClippingMaskIDs={},this.getOrCreateProgram("clippingMask").draw(this,t.TRIANGLES,ct.disabled,this.stencilClearMode,yt.disabled,_t.disabled,wc(this.identityMat),"$clipping",this.viewportBuffer,this.quadTriangleIndexBuffer,this.viewportSegments)}resetStencilClippingMasks(){this.terrain||(this.currentStencilSource=void 0,this._tileClippingMaskIDs={})}_renderTileClippingMasks(t,n,l){if(!n||this.currentStencilSource===n.id||!t.isTileClipped()||!l||l.length===0)return;if(this._tileClippingMaskIDs&&!this.terrain){let g=!1;for(const x of l)if(this._tileClippingMaskIDs[x.key]===void 0){g=!0;break}if(!g)return}this.currentStencilSource=n.id;const d=this.context,p=d.gl;this.nextStencilID+l.length>256&&this.clearStencil(),d.setColorMode(yt.disabled),d.setDepthMode(ct.disabled);const m=this.getOrCreateProgram("clippingMask");this._tileClippingMaskIDs={};for(const g of l){const x=n.getTile(g),w=this._tileClippingMaskIDs[g.key]=this.nextStencilID++,{tileBoundsBuffer:S,tileBoundsIndexBuffer:A,tileBoundsSegments:I}=this.getTileBoundsBuffers(x);m.draw(this,p.TRIANGLES,ct.disabled,new mt({func:p.ALWAYS,mask:0},w,255,p.KEEP,p.KEEP,p.REPLACE),yt.disabled,_t.disabled,wc(g.projMatrix),"$clipping",S,A,I)}}stencilModeFor3D(){this.currentStencilSource=void 0,this.nextStencilID+1>256&&this.clearStencil();const t=this.nextStencilID++,n=this.context.gl;return new mt({func:n.NOTEQUAL,mask:255},t,255,n.KEEP,n.KEEP,n.REPLACE)}stencilModeForClipping(t){if(this.terrain)return this.terrain.stencilModeForRTTOverlap(t);const n=this.context.gl;return new mt({func:n.EQUAL,mask:255},this._tileClippingMaskIDs[t.key],0,n.KEEP,n.KEEP,n.REPLACE)}stencilConfigForOverlap(t){const n=this.context.gl,l=t.sort((m,g)=>
3401g.overscaledZ-m.overscaledZ),d=l.at(-1).overscaledZ,p=l[0].overscaledZ-d+1;if(p>1){this.currentStencilSource=void 0,this.nextStencilID+p>256&&this.clearStencil();const m={};for(let g=0;g<p;g++)m[g+d]=new mt({func:n.GEQUAL,mask:255},g+this.nextStencilID,255,n.KEEP,n.KEEP,n.REPLACE);return this.nextStencilID+=p,[m,l]}return[{[d]:mt.disabled},l]}colorModeForRenderPass(){const t=this.context.gl;return this._showOverdrawInspector?new yt([t.CONSTANT_COLOR,t.ONE,t.CONSTANT_COLOR,t.ONE],new u.C(.125,.125,.125,0),[!0,!0,!0,!0]):this.renderPass==="opaque"?yt.unblended:yt.alphaBlended}colorModeForDrapableLayerRenderPass(t){const n=this.context.gl;return this.style&&this.style.enable3dLights()&&this.terrain&&this.terrain.renderingToTexture&&this.renderPass==="translucent"?t!=null&&this.emissiveMode!=="mrt-fallback"||this.emissiveMode==="constant"?new yt([n.ONE,n.ONE_MINUS_SRC_ALPHA,n.CONSTANT_ALPHA,n.ONE_MINUS_SRC_ALPHA],new u.C(0,0,0,t??0),[!0,!0,!0,!0]):this.emissiveMode==="dual-source-blending"?new yt([n.ONE,n.ONE_MINUS_SRC_ALPHA,this.context.extBlendFuncExtended.SRC1_ALPHA_WEBGL,n.ONE_MINUS_SRC_ALPHA],u.C.transparent,[!0,!0,!0,!0]):this.colorModeForRenderPass():this.colorModeForRenderPass()}depthModeForSublayer(t,n,l,d=!1){if(this.depthOcclusion)return new ct(this.context.gl.GREATER,ct.ReadOnly,this.depthRangeFor3D);if(!this.opaquePassEnabledForLayer()&&!d)return ct.disabled;const p=1-((1+this.currentLayer)*this.numSublayers+t)*this.depthEpsilon;return new ct(l||this.context.gl.LEQUAL,n,[p,p])}opaquePassEnabledForLayer(){return this.currentLayer<this.opaquePassCutoff}blitDepth(){const t=this.context.gl,n=Math.ceil(this.width),l=Math.ceil(this.height),d=this.context.bindFramebuffer.get(),p=t.getParameter(t.TEXTURE_BINDING_2D);this.depthFBO&&this.depthFBO.width===n&&this.depthFBO.height===l||(this.depthFBO&&(this.depthFBO.destroy(),this.depthFBO=void 0,this.depthTexture=void 0),n!==0&&l!==0&&(this.depthFBO=new Ha(this.context,n,l,0,"texture"),this.depthTexture=new u.T(this.context,{width:n,height:l,data:null},t.DEPTH24_STENCIL8),this.depthFBO.depthAttachment.set(this.depthTexture.texture))),this.context.bindFramebuffer.set(d),t.bindTexture(t.TEXTURE_2D,p),this.depthFBO&&(t.bindFramebuffer(t.READ_FRAMEBUFFER,null),t.bindFramebuffer(t.DRAW_FRAMEBUFFER,this.depthFBO.framebuffer),t.blitFramebuffer(0,0,n,l,0,0,n,l,t.DEPTH_BUFFER_BIT,t.NEAREST),t.bindFramebuffer(t.FRAMEBUFFER,this.context.bindFramebuffer.current))}render(t,n){this.context.sweepPendingPrograms(),this.frameTimeDelta=this.lastPaintStartTimeStamp===0?0:n.paintStartTimeStamp-this.lastPaintStartTimeStamp,this.lastPaintStartTimeStamp=n.paintStartTimeStamp,this._wireframeDebugCache.update(this.frameCounter),this.style=t,this.options=n,this.frcCoverageSnapshot&&!this.frcCoverageSnapshot.empty()&&(!this.frcCoverageRenderer&&jt.FrcCoverageRenderer&&(this.frcCoverageRenderer=new jt.FrcCoverageRenderer),this.frcCoverageRenderer&&this.frcCoverageRenderer.update(this.context,this.frcCoverageSnapshot.tiles));const l=this.style._mergedLayers,d=!(!this.terrain||!this.terrain.enabled),p=()=>this.style._getOrder(d);let m=p(),g=!1,x=!1,w=null,S=0,A=!1;for(const ye of m){const Ae=l[ye];Ae.visibility!=="none"&&(Ae.type==="circle"?g=!0:Ae.type==="building"?(w=Ae,++S):Ae.type==="symbol"&&(Ae.hasOcclusionOpacityProperties?x=!0:g=!0))}this.updateEmissiveMode();let I=m.map(ye=>l[ye]);const M=this.style._mergedSourceCaches;this.imageManager=t.imageManager,this.modelManager=t.modelManager,this.symbolFadeChange=t.placement.symbolFadeChange(u.r.now()),this.imageManager.beginFrame();for(const ye in M){const Ae=M[ye];Ae.used&&(Ae.prepare(this.context),Ae.getSource().usedInConflation&&++S)}let D=!1;for(const ye of I)ye.isHidden(this.transform.zoom)||(ye.type==="clip"&&(D=!0),this.prepareLayer(ye));const L={},k={},B={},$={},Z={};for(const ye in M){const Ae=M[ye];L[ye]=Ae.getVisibleCoordinates(),k[ye]=L[ye].slice().reverse(),B[ye]=Ae.getVisibleCoordinates(!0).reverse(),$[ye]=Ae.getShadowCasterCoordinates(),Z[ye]=Ae.sortCoordinatesByDistance(L[ye])}const G=ye=>{const Ae=this.style.getLayerSourceCache(ye);return Ae&&Ae.used?Ae.getSource():null};if(S||D||this._clippingActiveLastFrame){const ye=[],Ae=[];let ge=0;for(const Fe of I)this.isSourceForClippingOrConflation(Fe,G(Fe))&&(ye.push(Fe),Ae.push(ge)),ge++;
vendor: 98,744 bytes, lines 3401-3406
3401if(ye&&(D||ye.length>1)||this._clippingActiveLastFrame){D=!1;const Fe=[];for(let Re=0;Re<ye.length;Re++){const De=ye[Re],Ke=Ae[Re],Be=this.style.getLayerSourceCache(De);if(!Be||!Be.used||!Be.getSource().usedInConflation&&De.type!=="clip"&&De.type!=="building")continue;let Ge=u.f2,Ze=u.dZ.None;const tt=[];let ot=!0;if(De.type==="building")Ge=u.f4;else if(De.type==="clip")if(Ge=Ke,De.isHidden(this.transform.zoom))ot=!1;else{if(!De.layout){ot=!1;continue}for(const at of De.layout.get("clip-layer-types"))Ze|=at==="model"?u.dZ.Model:at==="symbol"?u.dZ.Symbol:u.dZ.FillExtrusion;for(const at of De.layout.get("clip-layer-scope"))tt.push(u.y(at,De.scope));D=!0}ot&&Fe.push({layer:De.fqid,cache:Be,order:Ge,clipMask:Ze,clipScope:tt})}this.replacementSource.setSources(Fe),A=!0}}this._clippingActiveLastFrame=D,A||this.replacementSource.clear(),this.conflationActive=A,this.minCutoffZoom=0,this.longestCutoffRange=0,this.maxFrontCutoffRawStart=0,this.opaquePassCutoff=1/0,this._lastOcclusionLayer=-1,this.layersWithOcclusionOpacity=[];for(let ye=0;ye<I.length;ye++){const Ae=I[ye];if(Ae.visibility==="none")continue;const ge=Ae.cutoffRange();if(this.longestCutoffRange=Math.max(ge,this.longestCutoffRange),ge>0){const Fe=G(Ae);Fe&&(this.minCutoffZoom=Math.max(Fe.minzoom,this.minCutoffZoom)),Ae.minzoom&&(this.minCutoffZoom=Math.max(Ae.minzoom,this.minCutoffZoom))}Ae.is3D(d)&&(this.opaquePassCutoff===1/0&&(this.opaquePassCutoff=ye),this._lastOcclusionLayer=ye)}const te=this.style&&this.style.fog;te?(this._fogVisible=te.getOpacity(this.transform.pitch)!==0,this._fogVisible&&this.transform.projection.name!=="globe"&&(this._fogVisible=te.isVisibleOnFrustum(this.transform.cameraFrustum))):this._fogVisible=!1,this._cachedTileFogOpacities={},this.terrain&&(this.terrain.updateTileBinding(B),this.opaquePassCutoff=0,m=p(),I=m.map(ye=>l[ye])),this.style.enable3dLights()&&!this._shadowRenderer&&hs(this);const ee=this._shadowRenderer;if(ee){ee.updateShadowParameters(this.transform,this.style.directionalLight);for(const ye in M)for(const Ae of L[ye]){let ge={min:0,max:0};this.terrain&&(ge=this.terrain.getMinMaxForTile(Ae)||ge),ee.addShadowReceiver(Ae.toUnwrapped(),ge.min,ge.max)}}this.transform.projection.name!=="globe"||this.globeSharedBuffers||(this.globeSharedBuffers=new u.f3(this.context)),this.style.fog&&this.transform.projection.supportsFog?(this._atmosphere||(this._atmosphere=new ad),this._atmosphere.update(this)):this._atmosphere&&(this._atmosphere.destroy(),this._atmosphere=void 0);let le=!(!this.style||!this.style.snow),K=!(!this.style||!this.style.rain);if(le&&!this._snow&&jt.Snow&&(this._snow=new jt.Snow),!le&&this._snow&&(this._snow.destroy(),delete this._snow),K&&!this._rain&&jt.Rain&&(this._rain=new jt.Rain),!K&&this._rain&&(this._rain.destroy(),delete this._rain),this._snow&&this._snow.update(this),this._rain&&this._rain.update(this),w&&(!this.buildingTileBorderManager&&jt.BuildingTileBorderManager&&(this.buildingTileBorderManager=new jt.BuildingTileBorderManager),this.buildingTileBorderManager)){const ye=this.style.getLayerSourceCache(w);this.buildingTileBorderManager.updateBorders(ye,w)}if(!eo.has(this.context.gl))return;this.renderPass="offscreen";for(const ye of I){const Ae=t.getLayerSourceCache(ye);if(!ye.hasOffscreenPass()||ye.isHidden(this.transform.zoom))continue;const ge=Ae?k[Ae.id]:void 0;(ye.type==="custom"||ye.type==="raster"||ye.type==="raster-particle"||ye.isSky()||ge&&ge.length)&&this.renderLayer(this,Ae,ye,ge)}this.depthRangeFor3D=[0,1-(I.length+2)*this.numSublayers*this.depthEpsilon],this._shadowRenderer&&(this.renderPass="shadow",this._shadowRenderer.drawShadowPass(this.style,$)),this.context.bindFramebuffer.set(null),this.context.viewport.set([0,0,this.width,this.height]);const Q=this.transform.projection.name==="globe"||this.transform.isHorizonVisible(),ae=(()=>{if(n.showOverdrawInspector)return u.C.black;const ye=this.style.fog;if(ye&&this.transform.projection.supportsFog){const Ae=this.style.getLut(ye.scope);if(!Q){const ge=ye.properties.get("color-use-theme")==="none",Fe=ye.properties.get("color").toNonPremultipliedRenderColor(ge?null:Ae).toArray01();return new u.C(...Fe)}if(Q){const ge=ye.properties.get("space-color-use-theme")==="none",Fe=ye.properties.get("space-color").toNonPremultipliedRenderColor(ge?null:Ae).toArray01();return new u.C(...Fe)}}return u.C.transparent})();if(this.context.clear({color:ae,depth:1}),this.clearStencil(),this._showOverdrawInspector=n.showOverdrawInspector,this.renderPass="opaque",this.style.fog&&this.transform.projection.supportsFog&&this._atmosphere&&!this._showOverdrawInspector&&Q&&this._atmosphere.drawStars(this,this.style.fog),!this.terrain)for(this.currentLayer=m.length-1;this.currentLayer>=0;this.currentLayer--){const ye=I[this.currentLayer],Ae=t.getLayerSourceCache(ye);if(ye.isSky())continue;const ge=Ae?(ye.is3D(d)?Z:k)[Ae.id]:void 0;this._renderTileClippingMasks(ye,Ae,ge),this.renderLayer(this,Ae,ye,ge)}if(this.style.fog&&this.transform.projection.supportsFog&&this._atmosphere&&!this._showOverdrawInspector&&Q&&this._atmosphere.drawAtmosphereGlow(this,this.style.fog),this.renderPass="sky",(!this._atmosphere||u.ah(this.transform.zoom)>0)&&(this.transform.projection.name==="globe"||this.transform.isHorizonVisible()))for(this.currentLayer=0;this.currentLayer<m.length;this.currentLayer++){const ye=I[this.currentLayer],Ae=t.getLayerSourceCache(ye);ye.isSky()&&this.renderLayer(this,Ae,ye,Ae?k[Ae.id]:void 0)}function de(ye,Ae){let ge;return Ae&&(ge=(ye.type==="symbol"?B:ye.is3D(d)?Z:k)[Ae.id]),ge}if(this.renderPass="translucent",this.transform.projection.name==="globe"){for(this.renderElevatedRasterBackface=!0,this.currentLayer=0;this.currentLayer<m.length;){const ye=I[this.currentLayer];if(ye.type==="raster"||ye.type==="raster-particle"){const Ae=t.getLayerSourceCache(ye);this.renderLayer(this,Ae,ye,de(ye,Ae))}++this.currentLayer}this.renderElevatedRasterBackface=!1}this.currentLayer=0,this.firstLightBeamLayer=Number.MAX_SAFE_INTEGER;const fe=ee?ee.getGroundShadowLayerIndex():-1;let be=!1,Te=-1;for(let ye=0;ye<m.length;++ye){const Ae=I[ye];Ae.isHidden(this.transform.zoom)||Ae.is3D(d)&&(Te=ye)}x&&Te===-1&&(g=!0);let Ve=!1;for(;this.currentLayer<m.length;){const ye=I[this.currentLayer],Ae=t.getLayerSourceCache(ye);if(ye.isSky())++this.currentLayer;else if(this.terrain&&this.style.isLayerDraped(ye)){if(ye.isHidden(this.transform.zoom)){++this.currentLayer;continue}this.currentLayer=this.terrain.renderBatch(this.currentLayer),this._lastOcclusionLayer=Math.max(this.currentLayer,this._lastOcclusionLayer)}else{if(!Ve&&ye.is3D(d)&&!d){const ge=this.currentLayer,Fe=Re=>{for(this.currentLayer=0;this.currentLayer<I.length;this.currentLayer++){const De=I[this.currentLayer];if(De.type==="fill"&&jt.drawDepthPrepass){const Ke=this.style.getLayerSourceCache(De);jt.drawDepthPrepass(this,Ke,De,de(De,Ke),Re)}}};Fe("initialize"),Fe("reset"),this.currentLayer=ge,Ve=!0}if(g&&!be&&this.terrain&&!this.transform.isOrthographic&&(be=!0,this.blitDepth()),x&&Te!==-1&&this.currentLayer===Te+1&&!this.transform.isOrthographic&&this.blitDepth(),this.terrain||this._renderTileClippingMasks(ye,Ae,Ae?L[Ae.id]:void 0),this.renderLayer(this,Ae,ye,de(ye,Ae)),!this.terrain&&ee&&this.currentLayer===fe){{this.clearStencil(),this.resetStencilClippingMasks();const ge=this.currentLayer;for(this.currentLayer=0;this.currentLayer<I.length;this.currentLayer++){const Fe=I[this.currentLayer];if(Fe.type==="fill"&&jt.drawGroundShadowMask){const Re=this.style.getLayerSourceCache(Fe);jt.drawGroundShadowMask(this,Re,Fe,de(Fe,Re))}}this.currentLayer=ge}if(ee.drawGroundShadows(),this.firstLightBeamLayer<=this.currentLayer){const ge=this.currentLayer;for(this.renderPass="light-beam",this.currentLayer=this.firstLightBeamLayer;this.currentLayer<=ge;this.currentLayer++){const Fe=I[this.currentLayer];if(!Fe.hasLightBeamPass())continue;const Re=t.getLayerSourceCache(Fe);this.renderLayer(this,Re,Fe,Re?k[Re.id]:void 0)}this.currentLayer=ge,this.renderPass="translucent"}}if(this.currentLayer>=this._lastOcclusionLayer&&this.layersWithOcclusionOpacity.length>0){const ge=this.currentLayer;this.depthOcclusion=!0;for(const Fe of this.layersWithOcclusionOpacity){this.currentLayer=Fe;const Re=I[this.currentLayer],De=t.getLayerSourceCache(Re),Ke=De?k[De.id]:void 0;this.terrain||this._renderTileClippingMasks(Re,De,De?L[De.id]:void 0),this.renderLayer(this,De,Re,Ke)}this.depthOcclusion=!1,this.currentLayer=ge,this.renderPass="translucent",this.layersWithOcclusionOpacity=[]}++this.currentLayer}}if(this.terrain&&this.terrain.postRender(),this._snow&&this._snow.draw(this),this._rain&&this._rain.draw(this),this.options.showTileBoundaries||this.options.showQueryGeometry||this.options.showTileAABBs){let ye=null;I.forEach(Ae=>{const ge=t.getLayerSourceCache(Ae);ge&&!Ae.isHidden(this.transform.zoom)&&ge.getVisibleCoordinates().length&&(!ye||ye.getSource().maxzoom<ge.getSource().maxzoom)&&(ye=ge)}),ye&&this.options.showTileBoundaries&&(function(Ae,ge,Fe,Re,De,Ke){for(let Be=0;Be<Fe.length;Be++)Qs(Ae,ge,Fe[Be],Re,0,0,Ke)})(this,ye,ye.getVisibleCoordinates(),u.C.red,0,this.options.showParseStatus)}this.options.showPadding&&(function(ye){const Ae=ye.transform.padding;Pu(ye,ye.transform.height-(Ae.top||0),3,dy),Pu(ye,Ae.bottom||0,3,Mu),gr(ye,Ae.left||0,3,v_),gr(ye,ye.transform.width-(Ae.right||0),3,sp);const ge=ye.transform.centerPoint;(function(Fe,Re,De,Ke){ao(Fe,Re-1,De-10,2,20,Ke),ao(Fe,Re-10,De-1,20,2,Ke)})(ye,ge.x,ye.transform.height-ge.y,od)})(this),this.context.setDefault(),this.frameCounter=(this.frameCounter+1)%Number.MAX_SAFE_INTEGER,this.tileLoaded&&this.options.speedIndexTiming&&(this.loadTimeStamps.push(performance.now()),this.saveCanvasCopy()),A||(this.conflationActive=!1)}prepareLayer(t){this.gpuTimingStart(t);const{unsupportedLayers:n}=this.transform.projection,l=!n||!n.includes(t.type);if(ra[t.type]&&(l||this.terrain&&t.type==="custom")){const d=this.style.getLayerSourceCache(t);ra[t.type](t,d,this)}this.gpuTimingEnd()}renderLayer(t,n,l,d){l.isHidden(this.transform.zoom)||(l.type==="background"||l.type==="sky"||l.type==="custom"||l.type==="model"||l.type==="raster"||l.type==="raster-particle"||d&&d.length)&&(this.id=l.id,this.gpuTimingStart(l),(!t.transform.projection.unsupportedLayers||!t.transform.projection.unsupportedLayers.includes(l.type)||t.terrain&&l.type==="custom")&&l.type!=="clip"&&l.type!=="slot"&&vo[l.type]&&vo[l.type](t,n,l,d,this.style.placement.variableOffsets,this.options.isInitialLoad),vo[l.type]||(l.mayUse("HD")&&(async function(){await hu(),Object.assign(vo,{building:jt.drawBuilding,"raster-particle":jt.drawRasterParticle}),Object.assign(ra,{"raster-particle":jt.prepareRasterParticle})})(),l.mayUse("Standard")&&hs(t)),this.gpuTimingEnd())}gpuTimingStart(t){if(!this.options.gpuTiming)return;const n=this.context.extTimerQuery,l=this.context.gl;let d=this.gpuTimers[t.id];d||(d=this.gpuTimers[t.id]={calls:0,cpuTime:0,query:l.createQuery()}),d.calls++,l.beginQuery(n.TIME_ELAPSED_EXT,d.query)}gpuTimingDeferredRenderStart(){if(this.options.gpuTimingDeferredRender){const t=this.context.extTimerQuery,n=this.context.gl,l=n.createQuery();this.deferredRenderGpuTimeQueries.push(l),n.beginQuery(t.TIME_ELAPSED_EXT,l)}}gpuTimingDeferredRenderEnd(){this.options.gpuTimingDeferredRender&&this.context.gl.endQuery(this.context.extTimerQuery.TIME_ELAPSED_EXT)}gpuTimingEnd(){this.options.gpuTiming&&this.context.gl.endQuery(this.context.extTimerQuery.TIME_ELAPSED_EXT)}collectGpuTimers(){const t=this.gpuTimers;return this.gpuTimers={},t}collectDeferredRenderGpuQueries(){const t=this.deferredRenderGpuTimeQueries;return this.deferredRenderGpuTimeQueries=[],t}queryGpuTimers(t){const n={};for(const l in t){const d=t[l],p=this.context.extTimerQuery,m=p.getQueryParameter(d.query,this.context.gl.QUERY_RESULT)/1e6;p.deleteQueryEXT(d.query),n[l]=m}return n}queryGpuTimeDeferredRender(t){if(!this.options.gpuTimingDeferredRender)return 0;const n=this.context.gl;let l=0;for(const d of t)l+=n.getQueryParameter(d,n.QUERY_RESULT)/1e6,n.deleteQuery(d);return l}translatePosMatrix(t,n,l,d,p){if(!l[0]&&!l[1])return t;const m=p?d==="map"?this.transform.angle:0:d==="viewport"?-this.transform.angle:0;if(m){const w=Math.sin(m),S=Math.cos(m);l=[l[0]*S-l[1]*w,l[0]*w+l[1]*S]}const g=[p?l[0]:u.c1(n,l[0],this.transform.zoom),p?l[1]:u.c1(n,l[1],this.transform.zoom),0],x=new Float32Array(16);return u.aG(x,t,g),x}saveTileTexture(t){if(t.context!==this.context)return;const n=t.size[0],l=this._tileTextures[n];l?l.push(t):this._tileTextures[n]=[t]}getTileTexture(t){const n=this._tileTextures[t];return n&&n.length>0?n.pop():null}terrainRenderModeElevated(){return this.style&&this.style.hasTerrain()&&!!this.terrain&&!this.terrain.renderingToTexture||this.forceTerrainMode}linearFloatFilteringSupported(){return this.context.extTextureFloatLinear!=null}currentGlobalDefines(t,n,l,d,p){const m=l===void 0?this.terrain&&this.terrain.renderingToTexture:l,g=d===void 0?this.terrainRenderModeElevated():d,x=p===void 0?this.transform.projection.name==="globe":p,w=[];return this.style&&this.style.enable3dLights()&&(t==="globeRaster"||t==="terrainRaster"?(w.push("LIGHTING_3D_MODE"),w.push("LIGHTING_3D_ALPHA_EMISSIVENESS")):m||w.push("LIGHTING_3D_MODE")),g&&(w.push("TERRAIN"),this.linearFloatFilteringSupported()&&w.push("TERRAIN_DEM_FLOAT_FORMAT")),x&&w.push("GLOBE"),!this._fogVisible||m||n!==void 0&&!n||w.push("FOG"),m&&w.push("RENDER_TO_TEXTURE"),this._showOverdrawInspector&&w.push("OVERDRAW_INSPECTOR"),w}getOrCreateProgram(t,n){this.cache=this.cache||{};const{defines:l,config:d,overrideFog:p,overrideRtt:m,overrideTerrain:g,overrideGlobe:x,precompiled:w}=n||{},S=this.currentGlobalDefines(t,p,m,g,x).concat(l||[]),A=this.getShaderSource(t),I=jt.programUniforms,M=mo.programUniforms,D=ep[t]||I&&I[t]||M&&M[t],L=Su.cacheKey(A,t,S,d);return this.cache[L]||(this.cache[L]=new Su(this.context,t,A,d,D,S,w)),this.cache[L]}getShaderSource(t){const n=jt.shaders,l=mo.shaders;return tf[t]||n&&n[t]||l&&l[t]}setCustomLayerDefaults(){this.context.unbindVAO(),this.context.cullFace.setDefault(),this.context.frontFace.setDefault(),this.context.cullFaceSide.setDefault(),this.context.activeTexture.setDefault(),this.context.pixelStoreUnpack.setDefault(),this.context.pixelStoreUnpackPremultiplyAlpha.setDefault(),this.context.pixelStoreUnpackFlipY.setDefault()}setBaseState(){const 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(){this.debugOverlayCanvas==null&&(this.debugOverlayCanvas=document.createElement("canvas"),this.debugOverlayCanvas.width=512,this.debugOverlayCanvas.height=512,this.debugOverlayTexture=new u.T(this.context,this.debugOverlayCanvas,this.context.gl.RGBA8))}destroy(){this._terrain&&this._terrain.destroy(),this._atmosphere&&(this._atmosphere.destroy(),this._atmosphere=void 0),this.globeSharedBuffers&&this.globeSharedBuffers.destroy(),this.emptyTexture.destroy(),this.debugOverlayTexture&&this.debugOverlayTexture.destroy(),this._wireframeDebugCache.destroy(),this.depthFBO&&(this.depthFBO.destroy(),this.depthFBO=void 0,this.depthTexture=void 0),this.emptyDepthTexture&&this.emptyDepthTexture.destroy()}prepareDrawTile(){this.terrain&&this.terrain.prepareDrawTile()}uploadCommonLightUniforms(t,n,l){if(this.style.enable3dLights()){const d=this.style.directionalLight,p=this.style.ambientLight;if(d&&p){const m=((g,x,w,S)=>{const A=g.properties.get("direction"),I=g.properties.get("color-use-theme")==="none",M=g.properties.get("color").toNonPremultipliedRenderColor(I?null:w.getLut(g.scope)).toArray01();let D=g.properties.get("intensity");const L=x.properties.get("color-use-theme")==="none",k=x.properties.get("color").toNonPremultipliedRenderColor(L?null:w.getLut(x.scope)).toArray01();let B=x.properties.get("intensity");const $=[A.x,A.y,A.z];S&&(S.ambientIntensity!==void 0&&(B=S.ambientIntensity),S.directionalIntensity!==void 0&&(D=S.directionalIntensity),S.ambientColor!==void 0&&(k[0]=S.ambientColor[0],k[1]=S.ambientColor[1],k[2]=S.ambientColor[2]),S.directionalColor!==void 0&&(M[0]=S.directionalColor[0],M[1]=S.directionalColor[1],M[2]=S.directionalColor[2]));const Z=u.ez(k,B),G=u.ez(M,D);return{u_lighting_ambient_color:Z,u_lighting_directional_dir:$,u_lighting_directional_color:G,u_ground_radiance:cs($,G,Z)}})(d,p,this.style,l);n.setLightsUniformValues(t,m)}}}uploadCommonUniforms(t,n,l,d,p,m){if(this.uploadCommonLightUniforms(t,n,m),this.terrain&&this.terrain.renderingToTexture)return;const g=this.style.fog;if(g){const x=g.getOpacity(this.transform.pitch),w=((S,A,I,M,D,L,k,B,$,Z,G,te)=>{const ee=S.transform,le=A.properties.get("color-use-theme")==="none",K=A.properties.get("color").toNonPremultipliedRenderColor(le?null:S.style.getLut(A.scope)).toArray01();K[3]=M;const Q=S.frameCounter/1e3%1,[ae,de]=A.properties.get("vertical-range");return{u_fog_matrix:I?ee.calculateFogTileMatrix(I):te||S.identityMat,u_fog_range:A.getRangeForProjection(),u_fog_color:K,u_fog_horizon_blend:A.properties.get("horizon-blend"),u_fog_vertical_limit:[Math.min(ae,de),de],u_fog_temporal_offset:Q,u_frustum_tl:D,u_frustum_tr:L,u_frustum_br:k,u_frustum_bl:B,u_globe_pos:$,u_globe_radius:Z,u_viewport:G,u_globe_transition:u.ah(ee.zoom),u_is_globe:+(ee.projection.name==="globe")}})(this,g,l,x,this.transform.frustumCorners.TL,this.transform.frustumCorners.TR,this.transform.frustumCorners.BR,this.transform.frustumCorners.BL,this.transform.globeCenterInViewSpace,this.transform.globeRadius,[this.transform.width*u.r.devicePixelRatio,this.transform.height*u.r.devicePixelRatio],d);n.setFogUniformValues(t,w)}p&&n.setCutoffUniformValues(t,p.uniformValues)}setTileLoadedFlag(t){this.tileLoaded=t}saveCanvasCopy(){const t=this.canvasCopy();t&&(this.frameCopies.push(t),this.tileLoaded=!1)}canvasCopy(){const t=this.context.gl,n=t.createTexture();return t.bindTexture(t.TEXTURE_2D,n),t.copyTexImage2D(t.TEXTURE_2D,0,t.RGBA,0,0,t.drawingBufferWidth,t.drawingBufferHeight,0),n}getCanvasCopiesAndTimestamps(){return{canvasCopies:this.frameCopies,timeStamps:this.loadTimeStamps}}averageElevationNeedsEasing(){if(!this.transform._elevation)return!1;const t=this.style&&this.style.fog;return!!t&&t.getOpacity(this.transform.pitch)!==0}getBackgroundTiles(){const t=this._backgroundTiles,n=this._backgroundTiles={},l=this.transform.coveringTiles({tileSize:512});for(const d of l)n[d.key]=t[d.key]||new _c(d,512,this.transform.tileZoom,this,void 0,this.worldview);return n}clearBackgroundTiles(){this._backgroundTiles={}}isSourceForClippingOrConflation(t,n){return!(!t.is3D(!(!this.terrain||!this.terrain.enabled))||t.type!=="clip"&&t.type!=="building"&&(t.minzoom&&t.minzoom>this.transform.zoom||(this.style._clipLayerPresent||t.sourceLayer!=="building"&&t.sourceLayer!=="procedural_buildings")&&(!n||n.type!=="batched-model")))}isTileAffectedByFog(t){if(!this.style||!this.style.fog)return!1;if(this.transform.projection.name==="globe")return!0;let n=this._cachedTileFogOpacities[t.key];return n||(this._cachedTileFogOpacities[t.key]=n=this.style.fog.getOpacityForTile(t)),n[0]>=hl||n[1]>=hl}setupDepthForOcclusion(t,n,l){const d=this.context,p=d.gl,m=!!l;var g;l||(l={u_dem:2,u_dem_prev:4,u_dem_tl:[0,0],u_dem_tl_prev:[0,0],u_dem_scale:0,u_dem_scale_prev:0,u_dem_size:0,u_dem_lerp:1,u_depth:3,u_depth_size_inv:[0,0],u_depth_range_unpack:[0,1],u_occluder_half_size:16,u_occlusion_depth_offset:-1e-4,u_exaggeration:0}),d.activeTexture.set(p.TEXTURE3),t&&this.depthFBO&&this.depthTexture?(this.depthTexture.bind(p.NEAREST,p.CLAMP_TO_EDGE),l.u_depth_size_inv=[1/this.depthFBO.width,1/this.depthFBO.height],l.u_depth_range_unpack=[2/((g=this.depthRangeFor3D)[1]-g[0]),-1-2*g[0]/(g[1]-g[0])],l.u_occluder_half_size=.5*this.occlusionParams.occluderSize,l.u_occlusion_depth_offset=this.occlusionParams.depthOffset):this.emptyDepthTexture.bind(p.NEAREST,p.CLAMP_TO_EDGE),d.activeTexture.set(p.TEXTURE0),m||n.setTerrainUniformValues(d,l)}updateEmissiveMode(){if(this._forceEmissiveMode)return;const t=this.style.hasDataDrivenEmissiveStrength();this.emissiveMode=t?this.context.extBlendFuncExtended?"dual-source-blending":"mrt-fallback":"constant"}}function b_(s,t){let n=!1,l=null;const d=()=>{l=null,n&&(s(),l=setTimeout(d,t),n=!1)};return()=>(n=!0,l||d(),l)}const my=/(#.+)?$/;class _y{constructor(t){this._hashName=t&&encodeURIComponent(t),u.cL(["_getCurrentHash","_onHashChange","_updateHash"],this),this._updateHash=b_(this._updateHashUnthrottled.bind(this),300)}addTo(t){return this._map=t,window.addEventListener("hashchange",this._onHashChange,!1),t.on("moveend",this._updateHash),this}remove(){return this._map?(this._map.off("moveend",this._updateHash),window.removeEventListener("hashchange",this._onHashChange,!1),clearTimeout(this._updateHash()),this._map=void 0,this):this}getHashString(){const t=this._map;if(!t)return"";const n=up(t);if(this._hashName){const l=this._hashName;let d=!1;const p=location.hash.slice(1).split("&").map(m=>{const g=m.split("=")[0];return g===l?(d=!0,`${g}=${n}`):m}).filter(m=>m);return d||p.push(`${l}=${n}`),`#${p.join("&")}`}return`#${n}`}_getCurrentHash(){const t=location.hash.replace("#","");if(this._hashName){let n;return t.split("&").map(l=>l.split("=")).forEach(l=>{l[0]===this._hashName&&(n=l)}),(n&&n[1]||"").split("/")}return t.split("/")}_onHashChange(){const t=this._map;if(!t)return!1;const n=this._getCurrentHash();if(n.length>=3&&!n.some(l=>isNaN(Number(l)))){const l=t.dragRotate.isEnabled()&&t.touchZoomRotate.isEnabled()?+(n[3]||0):t.getBearing();return t.jumpTo({center:[+n[2],+n[1]],zoom:+n[0],bearing:l,pitch:+(n[4]||0)}),!0}return!1}_updateHashUnthrottled(){history.replaceState(history.state,"",location.href.replace(my,this.getHashString()))}}function up(s,t){const n=s.getCenter(),l=Math.round(100*s.getZoom())/100,d=Math.ceil((l*Math.LN2+Math.log(512/360/.5))/Math.LN10),p=Math.pow(10,d),m=Math.round(n.lng*p)/p,g=Math.round(n.lat*p)/p,x=s.getBearing(),w=s.getPitch();let S=t?`/${m}/${g}/${l}`:`${l}/${g}/${m}`;return(x||w)&&(S+="/"+Math.round(10*x)/10),w&&(S+=`/${Math.round(w)}`),S}const Pc={linearity:.3,easing:u.f5(0,0,.3,1)},hp={deceleration:2500,maxSpeed:1400,...Pc},gy={deceleration:20,maxSpeed:1400,...Pc},yy={deceleration:1e3,maxSpeed:360,...Pc},xy={deceleration:1e3,maxSpeed:90,...Pc};class vy{constructor(t){this._map=t,this.clear()}clear(){this._inertiaBuffer=[]}record(t){this._drainInertiaBuffer(),this._inertiaBuffer.push({time:u.r.now(),settings:t})}_drainInertiaBuffer(){const t=this._inertiaBuffer,n=u.r.now();for(;t.length>0&&n-t[0].time>160;)t.shift()}_onMoveEnd(t){if(this._map._prefersReducedMotion()||(this._drainInertiaBuffer(),this._inertiaBuffer.length<2))return;const n={zoom:0,bearing:0,pitch:0,pan:new u.P(0,0),pinchAround:void 0,around:void 0};for(const{settings:p}of this._inertiaBuffer)n.zoom+=p.zoomDelta||0,n.bearing+=p.bearingDelta||0,n.pitch+=p.pitchDelta||0,p.panDelta&&n.pan._add(p.panDelta),p.around&&(n.around=p.around),p.pinchAround&&(n.pinchAround=p.pinchAround);const l=this._inertiaBuffer.at(-1).time-this._inertiaBuffer[0].time,d={};if(n.pan.mag()){const p=cd(n.pan.mag(),l,{...hp,...t||{}});d.offset=n.pan.mult(p.amount/n.pan.mag()),d.center=this._map.transform.center,ld(d,p)}if(n.zoom){const p=cd(n.zoom,l,gy);d.zoom=this._map.transform.zoom+p.amount,ld(d,p)}if(n.bearing){const p=cd(n.bearing,l,yy);d.bearing=this._map.transform.bearing+u.as(p.amount,-179,179),ld(d,p)}if(n.pitch){const p=cd(n.pitch,l,xy);d.pitch=this._map.transform.pitch+p.amount,ld(d,p)}if(d.zoom||d.bearing){const p=n.pinchAround===void 0?n.around:n.pinchAround;d.around=p?this._map.unproject(p):this._map.getCenter()}return this.clear(),d.noMoveStart=!0,d}}function ld(s,t){(!s.duration||s.duration<t.duration)&&(s.duration=t.duration,s.easing=t.easing)}function cd(s,t,n){const{maxSpeed:l,linearity:d,deceleration:p}=n,m=u.as(s*d/(t/1e3),-l,l),g=Math.abs(m)/(p*d);return{easing:n.easing,duration:1e3*g,amount:m*(g/2)}}class Uo extends u.B{preventDefault(){this._defaultPrevented=!0}get defaultPrevented(){return this._defaultPrevented}constructor(t,n,l,d={}){const p=hn(n.getCanvasContainer(),l);super(t,{point:p,lngLat:n.unproject(p),originalEvent:l,...d}),this._defaultPrevented=!1,this.target=n}}class ud extends u.B{preventDefault(){this._defaultPrevented=!0}get defaultPrevented(){return this._defaultPrevented}constructor(t,n,l){const d=t==="touchend"?l.changedTouches:l.touches,p=So(n.getCanvasContainer(),d),m=p.map(x=>n.unproject(x)),g=p.reduce((x,w,S,A)=>x.add(w.div(A.length)),new u.P(0,0));super(t,{points:p,point:g,lngLats:m,lngLat:n.unproject(g),originalEvent:l}),this._defaultPrevented=!1}}class by extends u.B{preventDefault(){this._defaultPrevented=!0}get defaultPrevented(){return this._defaultPrevented}constructor(t,n){super("wheel",{originalEvent:n}),this._defaultPrevented=!1}}class Za{constructor(t,n){this._map=t,this._clickTolerance=n.clickTolerance}reset(){this._mousedownPos=void 0}wheel(t){return this._firePreventable(new by(this._map,t))}mousedown(t,n){return this._mousedownPos=n,this._firePreventable(new Uo(t.type,this._map,t))}mouseup(t){this._map.fire(new Uo(t.type,this._map,t))}preclick(t){const n=new MouseEvent("preclick",t);this._map.fire(new Uo(n.type,this._map,n))}click(t,n){this._mousedownPos&&this._mousedownPos.dist(n)>=this._clickTolerance||(this.preclick(t),this._map.fire(new Uo(t.type,this._map,t)))}dblclick(t){return this._firePreventable(new Uo(t.type,this._map,t))}mouseover(t){this._map.fire(new Uo(t.type,this._map,t))}mouseout(t){this._map.fire(new Uo(t.type,this._map,t))}touchstart(t){return this._firePreventable(new ud(t.type,this._map,t))}touchmove(t){this._map.fire(new ud(t.type,this._map,t))}touchend(t){this._map.fire(new ud(t.type,this._map,t))}touchcancel(t){this._map.fire(new ud(t.type,this._map,t))}_firePreventable(t){if(this._map.fire(t),t.defaultPrevented)return{}}isEnabled(){return!0}isActive(){return!1}enable(){}disable(){}}class wy{constructor(t){this._map=t}reset(){this._delayContextMenu=!1,this._contextMenuEvent=void 0}mousemove(t){this._map.fire(new Uo(t.type,this._map,t))}mousedown(){this._delayContextMenu=!0}mouseup(){this._delayContextMenu=!1,this._contextMenuEvent&&(this._map.fire(new Uo("contextmenu",this._map,this._contextMenuEvent)),delete this._contextMenuEvent)}contextmenu(t){this._delayContextMenu?this._contextMenuEvent=t:this._map.fire(new Uo(t.type,this._map,t)),this._map.listens("contextmenu")&&t.preventDefault()}isEnabled(){return!0}isActive(){return!1}enable(){}disable(){}}class Ty{constructor(t,n){this._map=t,this._el=t.getCanvasContainer(),this._container=t.getContainer(),this._clickTolerance=n.clickTolerance||1}isEnabled(){return!!this._enabled}isActive(){return!!this._active}enable(){this.isEnabled()||(this._enabled=!0)}disable(){this.isEnabled()&&(this._enabled=!1)}mousedown(t,n){this.isEnabled()&&t.shiftKey&&t.button===0&&(_n(),this._startPos=this._lastPos=n,this._active=!0)}mousemoveWindow(t,n){if(!this._active)return;const l=n,d=this._startPos,p=this._lastPos;if(!d||!p||p.equals(l)||!this._box&&l.dist(d)<this._clickTolerance)return;this._lastPos=l,this._box||(this._box=Nt("div","mapboxgl-boxzoom",this._container),this._container.classList.add("mapboxgl-crosshair"),this._fireEvent("boxzoomstart",t));const m=Math.min(d.x,l.x),g=Math.max(d.x,l.x),x=Math.min(d.y,l.y),w=Math.max(d.y,l.y);this._map._requestDomTask(()=>{this._box&&(this._box.style.transform=`translate(${m}px,${x}px)`,this._box.style.width=g-m+"px",this._box.style.height=w-x+"px")})}mouseupWindow(t,n){if(!this._active)return;const l=this._startPos,d=n;if(l&&t.button===0){if(this.reset(),un(),l.x!==d.x||l.y!==d.y)return this._map.fire(new u.B("boxzoomend",{originalEvent:t})),{cameraAnimation:p=>p.fitScreenCoordinates(l,d,this._map.getBearing(),{linear:!1})};this._fireEvent("boxzoomcancel",t)}}keydown(t){this._active&&t.keyCode===27&&(this.reset(),this._fireEvent("boxzoomcancel",t))}blur(){this.reset()}reset(){this._active=!1,this._container.classList.remove("mapboxgl-crosshair"),this._box&&(this._box.remove(),this._box=null),gn(),delete this._startPos,delete this._lastPos}_fireEvent(t,n){return this._map.fire(new u.B(t,{originalEvent:n}))}}function dp(s,t){const n={};for(let l=0;l<s.length;l++)n[s[l].identifier]=t[l];return n}class fp{constructor(t){this.reset(),this.numTouches=t.numTouches}reset(){this.centroid=void 0,this.startTime=0,this.touches={},this.aborted=!1}touchstart(t,n,l){(this.centroid||l.length>this.numTouches)&&(this.aborted=!0),this.aborted||(this.startTime===0&&(this.startTime=t.timeStamp),l.length===this.numTouches&&(this.centroid=(function(d){const p=new u.P(0,0);for(const m of d)p._add(m);return p.div(d.length)})(n),this.touches=dp(l,n)))}touchmove(t,n,l){if(this.aborted||!this.centroid)return;const d=dp(l,n);for(const p in this.touches){const m=d[p];(!m||m.dist(this.touches[p])>30)&&(this.aborted=!0)}}touchend(t,n,l){if((!this.centroid||t.timeStamp-this.startTime>500)&&(this.aborted=!0),l.length===0){const d=!this.aborted&&this.centroid;if(this.reset(),d)return d}}}class Lu{constructor(t){this.singleTap=new fp(t),this.numTaps=t.numTaps,this.reset()}reset(){this.lastTime=1/0,this.lastTap=void 0,this.count=0,this.singleTap.reset()}touchstart(t,n,l){this.singleTap.touchstart(t,n,l)}touchmove(t,n,l){this.singleTap.touchmove(t,n,l)}touchend(t,n,l){const d=this.singleTap.touchend(t,n,l);if(d){const p=t.timeStamp-this.lastTime<500,m=!this.lastTap||this.lastTap.dist(d)<30;if(p&&m||this.reset(),this.count++,this.lastTime=t.timeStamp,this.lastTap=d,this.count===this.numTaps)return this.reset(),d}}}class Sy{constructor(){this._zoomIn=new Lu({numTouches:1,numTaps:2}),this._zoomOut=new Lu({numTouches:2,numTaps:1}),this.reset()}reset(){this._active=!1,this._zoomIn.reset(),this._zoomOut.reset()}touchstart(t,n,l){this._zoomIn.touchstart(t,n,l),this._zoomOut.touchstart(t,n,l)}touchmove(t,n,l){this._zoomIn.touchmove(t,n,l),this._zoomOut.touchmove(t,n,l)}touchend(t,n,l){const d=this._zoomIn.touchend(t,n,l),p=this._zoomOut.touchend(t,n,l);return d?(this._active=!0,t.preventDefault(),setTimeout(()=>this.reset(),0),{cameraAnimation:m=>m.easeTo({duration:300,zoom:m.getZoom()+1,around:m.unproject(d)},{originalEvent:t})}):p?(this._active=!0,t.preventDefault(),setTimeout(()=>this.reset(),0),{cameraAnimation:m=>m.easeTo({duration:300,zoom:m.getZoom()-1,around:m.unproject(p)},{originalEvent:t})}):void 0}touchcancel(){this.reset()}enable(){this._enabled=!0}disable(){this._enabled=!1,this.reset()}isEnabled(){return this._enabled}isActive(){return this._active}}const pp=0,Ey=2,mp={[pp]:1,[Ey]:2},w_={Control:"ctrlKey",Alt:"altKey",Shift:"shiftKey",Meta:"metaKey"};class zu{constructor(t){this.reset(),this._clickTolerance=t.clickTolerance||1}blur(){this.reset()}reset(){this._active=!1,this._moved=!1,this._lastPoint=void 0,this._eventButton=void 0}_correctButton(t,n){return!1}_move(t,n){return{}}mousedown(t,n){if(this._lastPoint)return;const l=uo(t);this._correctButton(t,l)&&(this._lastPoint=n,this._eventButton=l)}mousemoveWindow(t,n){const l=this._lastPoint;if(l){if(t.preventDefault(),this._eventButton!=null&&(function(d,p){const m=mp[p];return d.buttons===void 0||(d.buttons&m)!==m})(t,this._eventButton))this.reset();else if(this._moved||!(n.dist(l)<this._clickTolerance))return this._moved=!0,this._lastPoint=n,this._move(l,n)}}mouseupWindow(t){this._lastPoint&&uo(t)===this._eventButton&&(this._moved&&un(),this.reset())}enable(){this._enabled=!0}disable(){this._enabled=!1,this.reset()}isEnabled(){return this._enabled}isActive(){return this._active}}class Iy extends zu{mousedown(t,n){super.mousedown(t,n),this._lastPoint&&(this._active=!0)}_correctButton(t,n){return n===0&&!t.ctrlKey}_move(t,n){return{around:n,panDelta:n.sub(t)}}}class hd extends zu{constructor(t){super(t),this._pitchRotateKey=t.pitchRotateKey?w_[t.pitchRotateKey]:void 0}_correctButton(t,n){return this._pitchRotateKey?n===0&&t[this._pitchRotateKey]:n===0&&t.ctrlKey||n===2}_move(t,n){const l=.8*(n.x-t.x);if(l)return this._active=!0,{bearingDelta:l}}contextmenu(t){this._pitchRotateKey||t.preventDefault()}}class _p extends zu{constructor(t){super(t),this._pitchRotateKey=t.pitchRotateKey?w_[t.pitchRotateKey]:void 0}_correctButton(t,n){return this._pitchRotateKey?n===0&&t[this._pitchRotateKey]:n===0&&t.ctrlKey||n===2}_move(t,n){const l=-.5*(n.y-t.y);if(l)return this._active=!0,{pitchDelta:l}}contextmenu(t){this._pitchRotateKey||t.preventDefault()}}class T_{constructor(t,n){this._map=t,this._el=t.getCanvasContainer(),this._minTouches=1,this._clickTolerance=n.clickTolerance||1,this.reset(),u.cL(["_addTouchPanBlocker","_showTouchPanBlockerAlert"],this)}reset(){this._active=!1,this._touches={},this._sum=new u.P(0,0)}touchstart(t,n,l){return this._calculateTransform(t,n,l)}touchmove(t,n,l){if(this._active&&!(l.length<this._minTouches)){if(this._map._cooperativeGestures&&!this._map.isMoving()){if(l.length===1&&!u.f6())return void this._showTouchPanBlockerAlert();this._alertContainer.style.visibility!=="hidden"&&(this._alertContainer.style.visibility="hidden",clearTimeout(this._alertTimer))}return t.cancelable&&t.preventDefault(),this._calculateTransform(t,n,l)}}touchend(t,n,l){this._calculateTransform(t,n,l),this._active&&l.length<this._minTouches&&this.reset()}touchcancel(){this.reset()}_calculateTransform(t,n,l){l.length>0&&(this._active=!0);const d=dp(l,n),p=new u.P(0,0),m=new u.P(0,0);let g=0;for(const w in d){const S=d[w],A=this._touches[w];A&&(p._add(S),m._add(S.sub(A)),g++,d[w]=S)}if(this._touches=d,g<this._minTouches||!m.mag())return;const x=m.div(g);return this._sum._add(x),this._sum.mag()<this._clickTolerance?void 0:{around:p.div(g),panDelta:x}}enable(){this._enabled=!0,this._map._cooperativeGestures&&(this._addTouchPanBlocker(),this._el.classList.add("mapboxgl-touch-pan-blocker-override","mapboxgl-scrollable-page"))}disable(){this._enabled=!1,this._map._cooperativeGestures&&(clearTimeout(this._alertTimer),this._alertContainer.remove(),this._el.classList.remove("mapboxgl-touch-pan-blocker-override","mapboxgl-scrollable-page")),this.reset()}isEnabled(){return!!this._enabled}isActive(){return!!this._active}_addTouchPanBlocker(){this._map&&!this._alertContainer&&(this._alertContainer=Nt("div","mapboxgl-touch-pan-blocker",this._map._container),this._alertContainer.textContent=this._map._getUIString("TouchPanBlocker.Message"),this._alertContainer.style.fontSize=`${Math.max(10,Math.min(24,Math.floor(.05*this._el.clientWidth)))}px`)}_showTouchPanBlockerAlert(){this._alertContainer.style.visibility="visible",this._alertContainer.classList.add("mapboxgl-touch-pan-blocker-show"),this._alertContainer.setAttribute("role","alert"),clearTimeout(this._alertTimer),this._alertTimer=window.setTimeout(()=>{this._alertContainer.classList.remove("mapboxgl-touch-pan-blocker-show"),this._alertContainer.removeAttribute("role")},500)}}class na{constructor(){this.reset()}reset(){this._active=!1,this._firstTwoTouches=void 0}_start(t){}_move(t,n,l){return{}}touchstart(t,n,l){this._firstTwoTouches||l.length<2||(this._firstTwoTouches=[l[0].identifier,l[1].identifier],this._start([n[0],n[1]]))}touchmove(t,n,l){const d=this._firstTwoTouches;if(!d)return;t.preventDefault();const[p,m]=d,g=Fu(l,n,p),x=Fu(l,n,m);if(!g||!x)return;const w=this._aroundCenter?null:g.add(x).div(2);return this._move([g,x],w,t)}touchend(t,n,l){if(!this._firstTwoTouches)return;const[d,p]=this._firstTwoTouches,m=Fu(l,n,d),g=Fu(l,n,p);m&&g||(this._active&&un(),this.reset())}touchcancel(){this.reset()}enable(t){this._enabled=!0,this._aroundCenter=!!t&&t.around==="center"}disable(){this._enabled=!1,this.reset()}isEnabled(){return this._enabled}isActive(){return this._active}}function Fu(s,t,n){for(let l=0;l<s.length;l++)if(s[l].identifier===n)return t[l]}function zl(s,t){return Math.log2(s/t)}class Rc extends na{reset(){super.reset(),this._distance=0,this._startDistance=0}_start(t){this._startDistance=this._distance=t[0].dist(t[1])}_move(t,n){const l=this._distance;if(this._distance=t[0].dist(t[1]),this._active||!(Math.abs(zl(this._distance,this._startDistance))<.1))return this._active=!0,{zoomDelta:zl(this._distance,l),pinchAround:n}}}function dd(s,t){return 180*s.angleWith(t)/Math.PI}class Fl extends na{reset(){super.reset(),this._minDiameter=0,this._startVector=void 0,this._vector=void 0}_start(t){this._startVector=this._vector=t[0].sub(t[1]),this._minDiameter=t[0].dist(t[1])}_move(t,n){const l=this._vector;if(this._vector=t[0].sub(t[1]),l&&(this._active||!this._isBelowThreshold(this._vector)))return this._active=!0,{bearingDelta:dd(this._vector,l),pinchAround:n}}_isBelowThreshold(t){this._minDiameter=Math.min(this._minDiameter,t.mag());const n=25/(Math.PI*this._minDiameter)*360,l=this._startVector;if(!l)return!1;const d=dd(t,l);return Math.abs(d)<n}}function fd(s){return Math.abs(s.y)>Math.abs(s.x)}class S_ extends na{constructor(t){super(),this._map=t}reset(){super.reset(),this._valid=void 0,this._firstMove=void 0,this._lastPoints=void 0}_start(t){this._lastPoints=t,fd(t[0].sub(t[1]))&&(this._valid=!1)}_move(t,n,l){const d=this._lastPoints;if(!d)return;const p=t[0].sub(d[0]),m=t[1].sub(d[1]);return this._map._cooperativeGestures&&!u.f6()&&l.touches.length<3||(this._valid=this.gestureBeginsVertically(p,m,l.timeStamp),!this._valid)?void 0:(this._lastPoints=t,this._active=!0,{pitchDelta:(p.y+m.y)/2*-.5})}gestureBeginsVertically(t,n,l){if(this._valid!==void 0)return this._valid;const d=t.mag()>=2,p=n.mag()>=2;if(!d&&!p)return;if(!d||!p)return this._firstMove==null&&(this._firstMove=l),l-this._firstMove<100&&void 0;const m=t.y>0==n.y>0;return fd(t)&&fd(n)&&m}}const E_={panStep:100,bearingStep:15,pitchStep:10};class pd{constructor(){const t=E_;this._panStep=t.panStep,this._bearingStep=t.bearingStep,this._pitchStep=t.pitchStep,this._rotationDisabled=!1,this._panDisabled=!1}blur(){this.reset()}reset(){this._active=!1}keydown(t){if(t.altKey||t.ctrlKey||t.metaKey)return;let n=0,l=0,d=0,p=0,m=0;switch(t.keyCode){case 61:case 107:case 171:case 187:n=1;break;case 189:case 109:case 173:n=-1;break;case 37:t.shiftKey?l=-1:(t.preventDefault(),p=-1);break;case 39:t.shiftKey?l=1:(t.preventDefault(),p=1);break;case 38:t.shiftKey?d=1:(t.preventDefault(),m=-1);break;case 40:t.shiftKey?d=-1:(t.preventDefault(),m=1);break;default:return}return this._rotationDisabled&&(l=0,d=0),this._panDisabled&&(p=0,m=0),{cameraAnimation:g=>{const x=g.getZoom();g.easeTo({duration:300,easeId:"keyboardHandler",easing:Ay,zoom:n?Math.round(x)+n*(t.shiftKey?2:1):x,bearing:g.getBearing()+l*this._bearingStep,pitch:g.getPitch()+d*this._pitchStep,offset:[-p*this._panStep,-m*this._panStep],center:g.getCenter()},{originalEvent:t})}}}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}disablePan(){this._panDisabled=!0}enablePan(){this._panDisabled=!1}}function Ay(s){return s*(2-s)}const gp=4.000244140625,I_=1/450,A_=/(Mac|iPad)/i;class yp{constructor(t,n){this._map=t,this._el=t.getCanvasContainer(),this._handler=n,this._delta=0,this._lastDelta=0,this._defaultZoomRate=.01,this._wheelZoomRate=I_,u.cL(["_onTimeout","_addScrollZoomBlocker","_showBlockerAlert"],this)}setZoomRate(t){this._defaultZoomRate=t}setWheelZoomRate(t){this._wheelZoomRate=t}isEnabled(){return!!this._enabled}isActive(){return this._active||this._finishTimeout!==void 0}isZooming(){return!!this._zooming}enable(t){this.isEnabled()||(this._enabled=!0,this._aroundCenter=!!t&&t.around==="center",this._map._cooperativeGestures&&this._addScrollZoomBlocker())}disable(){this.isEnabled()&&(this._enabled=!1,this._map._cooperativeGestures&&(clearTimeout(this._alertTimer),this._alertContainer.remove()))}wheel(t){if(!this.isEnabled())return;if(this._map._cooperativeGestures){if(!(t.ctrlKey||t.metaKey||this.isZooming()||u.f6()))return void this._showBlockerAlert();this._alertContainer.style.visibility!=="hidden"&&(this._alertContainer.style.visibility="hidden",clearTimeout(this._alertTimer))}let n=t.deltaMode===WheelEvent.DOM_DELTA_LINE?40*t.deltaY:t.deltaY;const l=u.r.now(),d=l-(this._lastWheelEventTime||0);this._lastWheelEventTime=l,n!==0&&n%gp===0?this._type="wheel":n!==0&&Math.abs(n)<4?this._type="trackpad":d>400?(this._type=null,this._lastValue=n,this._timeout=window.setTimeout(this._onTimeout,40,t)):this._type||(this._type=Math.abs(d*n)<200?"trackpad":"wheel",this._timeout&&(clearTimeout(this._timeout),this._timeout=null,n+=this._lastValue)),t.shiftKey&&n&&(n/=4),this._type&&(this._lastWheelEvent=t,this._delta-=n,this._active||this._start(t)),t.preventDefault()}_onTimeout(t){this._type="wheel",this._delta-=this._lastValue,this._active||this._start(t)}_start(t){if(!this._delta)return;this._frameId&&(this._frameId=null),this._active=!0,this.isZooming()||(this._zooming=!0),this._finishTimeout&&(clearTimeout(this._finishTimeout),delete this._finishTimeout);const n=hn(this._el,t);this._aroundPoint=this._aroundCenter?this._map.transform.centerPoint:n,this._aroundCoord=this._map.transform.pointCoordinate3D(this._aroundPoint),this._targetZoom=void 0,this._frameId||(this._frameId=!0,this._handler._triggerRenderFrame())}renderFrame(){if(!this._frameId||(this._frameId=null,!this.isActive()))return;const t=this._map.transform;this._type==="wheel"&&t.projection.wrap&&(t._center.lng>=180||t._center.lng<=-180)&&(this._prevEase=null,this._easing=null,this._lastWheelEvent=null,this._lastWheelEventTime=0);const n=()=>t._terrainEnabled()&&this._aroundCoord?t.computeZoomRelativeTo(this._aroundCoord):t.zoom;if(this._delta!==0){const w=this._type==="wheel"&&Math.abs(this._delta)>gp?this._wheelZoomRate:this._defaultZoomRate;let S=2/(1+Math.exp(-Math.abs(this._delta*w)));this._delta<0&&S!==0&&(S=1/S);const A=n(),I=Math.pow(2,A),M=typeof this._targetZoom=="number"?t.zoomScale(this._targetZoom):I;this._targetZoom=Math.min(t.maxZoom,Math.max(t.minZoom,t.scaleZoom(M*S))),this._type==="wheel"&&(this._startZoom=A,this._easing=this._smoothOutEasing(200)),this._lastDelta=this._delta,this._delta=0}const l=typeof this._targetZoom=="number"?this._targetZoom:n(),d=this._startZoom,p=this._easing;let m,g=!1;if(this._type==="wheel"&&d&&p){const w=Math.min((u.r.now()-this._lastWheelEventTime)/200,1),S=p(w);m=u.ai(d,l,S),w<1?this._frameId||(this._frameId=!0):g=!0}else m=l,g=!0;this._active=!0,g&&(this._active=!1,this._finishTimeout=window.setTimeout(()=>{this._zooming=!1,this._handler._triggerRenderFrame(),delete this._targetZoom,delete this._finishTimeout},200));let x=m-n();return x*this._lastDelta<0&&(x=0),{noInertia:!0,needsRenderFrame:!g,zoomDelta:x,around:this._aroundPoint,aroundCoord:this._aroundCoord,originalEvent:this._lastWheelEvent}}_smoothOutEasing(t){let n=u.f7;if(this._prevEase){const l=this._prevEase,d=(u.r.now()-l.start)/l.duration,p=l.easing(d+.01)-l.easing(d),m=.27/Math.sqrt(p*p+1e-4)*.01,g=Math.sqrt(.0729-m*m);n=u.f5(m,g,.25,1)}return this._prevEase={start:u.r.now(),duration:t,easing:n},n}blur(){this.reset()}reset(){this._active=!1}_addScrollZoomBlocker(){this._map&&!this._alertContainer&&(this._alertContainer=Nt("div","mapboxgl-scroll-zoom-blocker",this._map._container),this._alertContainer.textContent=A_.test(navigator.userAgent)?this._map._getUIString("ScrollZoomBlocker.CmdMessage"):this._map._getUIString("ScrollZoomBlocker.CtrlMessage"),this._alertContainer.style.fontSize=`${Math.max(10,Math.min(24,Math.floor(.05*this._el.clientWidth)))}px`)}_showBlockerAlert(){this._alertContainer.style.visibility="visible",this._alertContainer.classList.add("mapboxgl-scroll-zoom-blocker-show"),this._alertContainer.setAttribute("role","alert"),clearTimeout(this._alertTimer),this._alertTimer=window.setTimeout(()=>{this._alertContainer.classList.remove("mapboxgl-scroll-zoom-blocker-show"),this._alertContainer.removeAttribute("role")},200)}}class Wa{constructor(t,n){this._clickZoom=t,this._tapZoom=n}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()}}class bn{constructor(){this.reset()}reset(){this._active=!1}blur(){this.reset()}dblclick(t,n){return t.preventDefault(),{cameraAnimation:l=>{l.easeTo({duration:300,zoom:l.getZoom()+(t.shiftKey?-1:1),around:l.unproject(n)},{originalEvent:t})}}}enable(){this._enabled=!0}disable(){this._enabled=!1,this.reset()}isEnabled(){return this._enabled}isActive(){return this._active}}class C_{constructor(){this._tap=new Lu({numTouches:1,numTaps:1}),this.reset()}reset(){this._active=!1,this._swipePoint=void 0,this._swipeTouch=0,this._tapTime=0,this._tap.reset()}touchstart(t,n,l){this._swipePoint||(this._tapTime&&t.timeStamp-this._tapTime>500&&this.reset(),this._tapTime?l.length>0&&(this._swipePoint=n[0],this._swipeTouch=l[0].identifier):this._tap.touchstart(t,n,l))}touchmove(t,n,l){if(this._tapTime){if(this._swipePoint){if(l[0].identifier!==this._swipeTouch)return;const d=n[0],p=d.y-this._swipePoint.y;return this._swipePoint=d,t.preventDefault(),this._active=!0,{zoomDelta:p/128}}}else this._tap.touchmove(t,n,l)}touchend(t,n,l){this._tapTime?this._swipePoint&&l.length===0&&this.reset():this._tap.touchend(t,n,l)&&(this._tapTime=t.timeStamp)}touchcancel(){this.reset()}enable(){this._enabled=!0}disable(){this._enabled=!1,this.reset()}isEnabled(){return this._enabled}isActive(){return this._active}}class M_{constructor(t,n,l){this._el=t,this._mousePan=n,this._touchPan=l}enable(t){this._inertiaOptions=t||{},this._mousePan.enable(),this._touchPan.enable(),this._el.classList.add("mapboxgl-touch-drag-pan")}disable(){this._mousePan.disable(),this._touchPan.disable(),this._el.classList.remove("mapboxgl-touch-drag-pan")}isEnabled(){return this._mousePan.isEnabled()&&this._touchPan.isEnabled()}isActive(){return this._mousePan.isActive()||this._touchPan.isActive()}}class Ps{constructor(t,n,l){this._pitchWithRotate=t.pitchWithRotate,this._mouseRotate=n,this._mousePitch=l,this._pitchDisabled=!1}enable(){this._mouseRotate.enable(),this._pitchWithRotate&&!this._pitchDisabled&&this._mousePitch.enable()}disable(){this._mouseRotate.disable(),this._mousePitch.disable()}isEnabled(){return this._mouseRotate.isEnabled()&&(!this._pitchWithRotate||this._pitchDisabled||this._mousePitch.isEnabled())}isActive(){return this._mouseRotate.isActive()||this._mousePitch.isActive()}disablePitch(){this._pitchDisabled=!0,this._mousePitch.disable()}enablePitch(){this._pitchDisabled=!1,this._pitchWithRotate&&this._mouseRotate.isEnabled()&&this._mousePitch.enable()}}class P_{constructor(t,n,l,d){this._el=t,this._touchZoom=n,this._touchRotate=l,this._tapDragZoom=d,this._rotationDisabled=!1,this._tapDragZoomDisabled=!1,this._enabled=!0}enable(t){this._touchZoom.enable(t),this._rotationDisabled||this._touchRotate.enable(t),this._tapDragZoomDisabled||this._tapDragZoom.enable(),this._el.classList.add("mapboxgl-touch-zoom-rotate")}disable(){this._touchZoom.disable(),this._touchRotate.disable(),this._tapDragZoom.disable(),this._el.classList.remove("mapboxgl-touch-zoom-rotate")}isEnabled(){return this._touchZoom.isEnabled()&&(this._rotationDisabled||this._touchRotate.isEnabled())&&(this._tapDragZoomDisabled||this._tapDragZoom.isEnabled())}isActive(){return this._touchZoom.isActive()||this._touchRotate.isActive()||this._tapDragZoom.isActive()}disableRotation(){this._rotationDisabled=!0,this._touchRotate.disable()}enableRotation(){this._rotationDisabled=!1,this._touchZoom.isEnabled()&&this._touchRotate.enable()}disableTapDragZoom(){this._tapDragZoomDisabled=!0,this._tapDragZoom.disable()}enableTapDragZoom(){this._tapDragZoomDisabled=!1,this._touchZoom.isEnabled()&&this._tapDragZoom.enable()}}const md=s=>s.zoom||s.drag||s.pitch||s.rotate;class Cy extends u.B{}class My{constructor(){this.constants=[1,1,.01],this.radius=0}setup(t,n){const l=u.aW([],n,t);this.radius=u.ae(l[2]<0?u.f9([],l,this.constants):[l[0],l[1],0])}projectRay(t){u.f9(t,t,this.constants),u.au(t,t),u.fa(t,t,this.constants);const n=u.av([],t,this.radius);if(n[2]>0){const l=u.av([],[0,0,1],u.aw(n,[0,0,1])),d=u.av([],u.au([],[n[0],n[1],0]),this.radius),p=u.cz([],n,u.av([],u.aW([],u.cz([],d,l),n),2));n[0]=p[0],n[1]=p[1]}return n}}function Dc(s){return s.panDelta&&s.panDelta.mag()||s.zoomDelta||s.bearingDelta||s.pitchDelta}class xp{constructor(t,n){this._map=t,this._el=this._map.getCanvasContainer(),this._handlers=[],this._handlersById={},this._changes=[],this._inertia=new vy(t),this._bearingSnap=n.bearingSnap,this._previousActiveHandlers={},this._trackingEllipsoid=new My,this._dragOrigin=null,this._eventsInProgress={},this._addDefaultHandlers(n),u.cL(["handleEvent","handleWindowEvent"],this);const l=this._el;this._listeners=[[l,"touchstart",{passive:!0}],[l,"touchmove",{passive:!1}],[l,"touchend",void 0],[l,"touchcancel",void 0],[l,"mousedown",void 0],[l,"mousemove",void 0],[l,"mouseup",void 0],[document,"mousemove",{capture:!0}],[document,"mouseup",void 0],[l,"mouseover",void 0],[l,"mouseout",void 0],[l,"dblclick",void 0],[l,"click",void 0],[l,"keydown",{capture:!1}],[l,"keyup",void 0],[l,"wheel",{passive:!1}],[l,"contextmenu",void 0],[window,"blur",void 0]];for(const[d,p,m]of this._listeners){const g=d===document?this.handleWindowEvent:this.handleEvent;d.addEventListener(p,g,m)}}destroy(){for(const[t,n,l]of this._listeners){const d=t===document?this.handleWindowEvent:this.handleEvent;t.removeEventListener(n,d,l)}}_addDefaultHandlers(t){const n=this._map,l=n.getCanvasContainer();this._add("mapEvent",new Za(n,t));const d=n.boxZoom=new Ty(n,t);this._add("boxZoom",d);const p=new Sy,m=new bn;n.doubleClickZoom=new Wa(m,p),this._add("tapZoom",p),this._add("clickZoom",m);const g=new C_;this._add("tapDragZoom",g);const x=n.touchPitch=new S_(n);this._add("touchPitch",x);const w=new hd(t),S=new _p(t);n.dragRotate=new Ps(t,w,S),this._add("mouseRotate",w,["mousePitch"]),this._add("mousePitch",S,["mouseRotate"]);const A=new Iy(t),I=new T_(n,t);n.dragPan=new M_(l,A,I),this._add("mousePan",A),this._add("touchPan",I,["touchZoom","touchRotate"]);const M=new Fl,D=new Rc;n.touchZoomRotate=new P_(l,D,M,g),this._add("touchRotate",M,["touchPan","touchZoom"]),this._add("touchZoom",D,["touchPan","touchRotate"]),this._add("blockableMapEvent",new wy(n));const L=n.scrollZoom=new yp(n,this);this._add("scrollZoom",L,["mousePan"]);const k=n.keyboard=new pd;this._add("keyboard",k);for(const B of["boxZoom","doubleClickZoom","tapDragZoom","touchPitch","dragRotate","dragPan","touchZoomRotate","scrollZoom","keyboard"])t.interactive&&t[B]&&n[B].enable(t[B])}_add(t,n,l){this._handlers.push({handlerName:t,handler:n,allowed:l}),this._handlersById[t]=n}stop(t){if(!this._updatingCamera){for(const{handler:n}of this._handlers)n.reset();this._inertia.clear(),this._fireEvents({},{},t),this._changes=[],this._originalZoom=void 0}}isActive(){for(const{handler:t}of this._handlers)if(t.isActive())return!0;return!1}isZooming(){return!!this._eventsInProgress.zoom||this._map.scrollZoom.isZooming()}isRotating(){return!!this._eventsInProgress.rotate}isMoving(){return!!md(this._eventsInProgress)||this.isZooming()}_isDragging(){return!!this._eventsInProgress.drag}_blockedByActive(t,n,l){for(const d in t)if(!(d===l||n&&n.includes(d)))return!0;return!1}handleWindowEvent(t){this.handleEvent(t,`${t.type}Window`)}_getMapTouches(t){const n=[];for(const l of t)this._el.contains(l.target)&&n.push(l);return n}handleEvent(t,n){this._updatingCamera=!0;const l=t.type==="renderFrame",d=l?void 0:t,p={needsRenderFrame:!1},m={},g={},x=t.touches?this._getMapTouches(t.touches):void 0,w=x?So(this._el,x):l?void 0:hn(this._el,t);for(const{handlerName:I,handler:M,allowed:D}of this._handlers){if(!M.isEnabled())continue;let L;this._blockedByActive(g,D,I)?M.reset():M[n||t.type]&&(L=M[n||t.type](t,w,x),this.mergeHandlerResult(p,m,L,I,d),L&&L.needsRenderFrame&&this._triggerRenderFrame()),(L||M.isActive())&&(g[I]=M)}const S={};for(const I in this._previousActiveHandlers)g[I]||(S[I]=d);this._previousActiveHandlers=g,(Object.keys(S).length||Dc(p))&&(this._changes.push([p,m,S]),this._triggerRenderFrame()),(Object.keys(g).length||Dc(p))&&this._map._stop(!0),this._updatingCamera=!1;const{cameraAnimation:A}=p;A&&(this._inertia.clear(),this._fireEvents({},{},!0),this._changes=[],A(this._map))}mergeHandlerResult(t,n,l,d,p){if(!l)return;Object.assign(t,l);const m={handlerName:d,originalEvent:l.originalEvent||p};l.zoomDelta!==void 0&&(n.zoom=m),l.panDelta!==void 0&&(n.drag=m),l.pitchDelta!==void 0&&(n.pitch=m),l.bearingDelta!==void 0&&(n.rotate=m)}_applyChanges(){const t={},n={},l={};for(const[d,p,m]of this._changes)d.panDelta&&(t.panDelta=(t.panDelta||new u.P(0,0))._add(d.panDelta)),d.zoomDelta&&(t.zoomDelta=(t.zoomDelta||0)+d.zoomDelta),d.bearingDelta&&(t.bearingDelta=(t.bearingDelta||0)+d.bearingDelta),d.pitchDelta&&(t.pitchDelta=(t.pitchDelta||0)+d.pitchDelta),d.around!==void 0&&(t.around=d.around),d.aroundCoord!==void 0&&(t.aroundCoord=d.aroundCoord),d.pinchAround!==void 0&&(t.pinchAround=d.pinchAround),d.noInertia&&(t.noInertia=d.noInertia),Object.assign(n,p),Object.assign(l,m);this._updateMapTransform(t,n,l),this._changes=[]}_updateMapTransform(t,n,l){const d=this._map,p=d.transform,m=$=>[$.x,$.y,$.z];if((()=>{const $=this._eventsInProgress.drag;return $&&!this._handlersById[$.handlerName].isActive()})()&&!Dc(t)){const $=p.zoom;p.cameraElevationReference="sea",this._originalZoom!=null&&p._orthographicProjectionAtLowPitch&&p.projection.name!=="globe"&&p.pitch===0?(p.cameraElevationReference="ground",p.zoom=this._originalZoom):(p.recenterOnTerrain(),p.cameraElevationReference="ground"),$!==p.zoom&&this._map._update(!0)}if(p._isCameraConstrained&&d._stop(!0),!Dc(t))return void this._fireEvents(n,l,!0);let{panDelta:g,zoomDelta:x,bearingDelta:w,pitchDelta:S,around:A,aroundCoord:I,pinchAround:M}=t;p._isCameraConstrained&&(x>0&&(x=0),p._isCameraConstrained=!1),M!==void 0&&(A=M),(x||($=>n[$]&&!this._eventsInProgress[$])("drag"))&&A&&(this._dragOrigin=m(p.pointCoordinate3D(A)),this._originalZoom=p.zoom,this._trackingEllipsoid.setup(p._camera.position,this._dragOrigin)),p.cameraElevationReference="sea",d._stop(!0),A=A||d.transform.centerPoint,w&&(p.bearing+=w),S&&(p.pitch+=S),p._updateCameraState();const D=[0,0,0];if(g)if(p.projection.name==="mercator"){const $=this._trackingEllipsoid.projectRay(p.screenPointToMercatorRay(A).dir),Z=this._trackingEllipsoid.projectRay(p.screenPointToMercatorRay(A.sub(g)).dir);D[0]=Z[0]-$[0],D[1]=Z[1]-$[1]}else{const $=p.pointCoordinate(A);if(p.projection.name==="globe"){g=g.rotate(-p.angle);const Z=p._pixelsPerMercatorPixel/p.worldSize;D[0]=-g.x*u.f8(u.aM($.y))*Z,D[1]=-g.y*u.f8(p.center.lat)*Z}else{const Z=p.pointCoordinate(A.sub(g));$&&Z&&(D[0]=Z.x-$.x,D[1]=Z.y-$.y)}}const L=p.zoom,k=[0,0,0];if(x){const $=m(I||p.pointCoordinate3D(A)),Z={dir:u.au([],u.aW([],$,p._camera.position))};if(Z.dir[2]<0){const G=p.zoomDeltaToMovement($,x);u.av(k,Z.dir,G)}}const B=u.cz(D,D,k);p._translateCameraConstrained(B),x&&Math.abs(p.zoom-L)>1e-4&&p.recenterOnTerrain(),p.cameraElevationReference="ground",this._map._update(),t.noInertia||this._inertia.record(t),this._fireEvents(n,l,!0)}_fireEvents(t,n,l){const d=md(this._eventsInProgress),p=md(t),m={};for(const S in t){const{originalEvent:A}=t[S];this._eventsInProgress[S]||(m[`${S}start`]=A),this._eventsInProgress[S]=t[S]}!d&&p&&this._fireEvent("movestart",p.originalEvent);for(const S in m)this._fireEvent(S,m[S]);p&&this._fireEvent("move",p.originalEvent);for(const S in t){const{originalEvent:A}=t[S];this._fireEvent(S,A)}const g={};let x;for(const S in this._eventsInProgress){const{handlerName:A,originalEvent:I}=this._eventsInProgress[S];this._handlersById[A].isActive()||(delete this._eventsInProgress[S],x=n[A]||I,g[`${S}end`]=x)}for(const S in g)this._fireEvent(S,g[S]);const w=md(this._eventsInProgress);if(l&&(d||p)&&!w){this._updatingCamera=!0;const S=this._inertia._onMoveEnd(this._map.dragPan._inertiaOptions),A=I=>I!==0&&-this._bearingSnap<I&&I<this._bearingSnap;S?(A(S.bearing||this._map.getBearing())&&(S.bearing=0),this._map.easeTo(S,{originalEvent:x})):(this._map.fire(new u.B("moveend",{originalEvent:x})),A(this._map.getBearing())&&this._map.resetNorth()),this._updatingCamera=!1}}_fireEvent(t,n){this._map.fire(new u.B(t,n?{originalEvent:n}:{}))}_requestFrame(){return this._map.triggerRepaint(),this._map._renderTaskQueue.add(t=>{this._frameId=void 0,this.handleEvent(new Cy("renderFrame",{timeStamp:t})),this._applyChanges()})}_triggerRenderFrame(){this._frameId===void 0&&(this._frameId=this._requestFrame())}}const R_="map.setFreeCameraOptions(...) and map.getFreeCameraOptions() are not yet supported for non-mercator projections.";class Py extends u.E{constructor(t,n){super(),this._moving=!1,this._zooming=!1,this.transform=t,this._bearingSnap=n.bearingSnap,this._respectPrefersReducedMotion=n.respectPrefersReducedMotion!==!1,u.cL(["_renderFrameCallback"],this)}getCenter(){return new u.b4(this.transform.center.lng,this.transform.center.lat)}setCenter(t,n){return this.jumpTo({center:t},n)}panBy(t,n,l){return t=u.P.convert(t).mult(-1),this.panTo(this.transform.center,{offset:t,...n},l)}panTo(t,n,l){return this.easeTo({center:t,...n},l)}getZoom(){return this.transform.zoom}setZoom(t,n){return this.jumpTo({zoom:t},n),this}zoomTo(t,n,l){return this.easeTo({zoom:t,...n},l)}zoomIn(t,n){return this.zoomTo(this.getZoom()+1,t,n),this}zoomOut(t,n){return this.zoomTo(this.getZoom()-1,t,n),this}getBearing(){return this.transform.bearing}setBearing(t,n){return this.jumpTo({bearing:t},n),this}getPadding(){return this.transform.padding}setPadding(t,n){return this.jumpTo({padding:t},n),this}rotateTo(t,n,l){return this.easeTo({bearing:t,...n},l)}resetNorth(t,n){return this.rotateTo(0,{duration:1e3,...t},n),this}resetNorthPitch(t,n){return this.easeTo({bearing:0,pitch:0,duration:1e3,...t},n),this}snapToNorth(t,n){return Math.abs(this.getBearing())<this._bearingSnap?this.resetNorth(t,n):this}getPitch(){return this.transform.pitch}setPitch(t,n){return this.jumpTo({pitch:t},n),this}cameraForBounds(t,n){t=u.bF.convert(t);const l=n&&n.bearing||0,d=n&&n.pitch||0,p=t.getNorthWest(),m=t.getSouthEast();return this._cameraForBounds(this.transform,p,m,l,d,n)}_extendPadding(t){const n={top:0,right:0,bottom:0,left:0};return t==null?{...n,...this.transform.padding}:typeof t=="number"?{top:t,bottom:t,right:t,left:t}:{...n,...t}}_extendCameraOptions(t){return(t={offset:[0,0],maxZoom:this.transform.maxZoom,...t}).padding=this._extendPadding(t.padding),t}_minimumAABBFrustumDistance(t,n){const l=n.max[0]-n.min[0],d=n.max[1]-n.min[1];return l/d>t.aspect?l/(2*Math.tan(.5*t.fovX)*t.aspect):d/(2*Math.tan(.5*t.fovY)*t.aspect)}_cameraForBoundsOnGlobe(t,n,l,d,p,m){const g=t.clone(),x=this._extendCameraOptions(m);g.bearing=d,g.pitch=p;const w=u.b4.convert(n),S=u.b4.convert(l),A=.5*(w.lat+S.lat),I=.5*(w.lng+S.lng),M=u.fb(A,I),D=u.au([],M),L=u.au([],u.ax([],D,[0,1,0])),k=u.ax([],L,D),B=[L[0],L[1],L[2],0,k[0],k[1],k[2],0,D[0],D[1],D[2],0,0,0,0,1],$=[M,u.fb(w.lat,w.lng),u.fb(S.lat,w.lng),u.fb(S.lat,S.lng),u.fb(w.lat,S.lng),u.fb(A,w.lng),u.fb(A,S.lng),u.fb(w.lat,I),u.fb(S.lat,I)];let Z=u.ca.fromPoints($.map(Re=>[u.aw(L,Re),u.aw(k,Re),u.aw(D,Re)]));const G=u.ad([],Z.center,B);u.fc(G)===0&&u.fd(G,0,0,1),u.au(G,G),u.av(G,G,u.dK),g.center=u.fe(G);const te=g.getWorldToCameraMatrix(),ee=u.aE(new Float64Array(16),te);Z=u.ca.applyTransform(Z,u.aP([],te,B));const le=this._extendAABB(Z,g,x,d);if(!le)return void u.w("Map cannot fit within canvas with the given bounds, padding, and/or offset.");Z=le,u.ad(G,G,te);const K=.5*(Z.max[2]-Z.min[2]),Q=this._minimumAABBFrustumDistance(g,Z),ae=u.av([],[0,0,1],K),de=u.cz(ae,G,ae),fe=Q+(g.pitch===0?0:u.aX(G,de)),be=g.globeCenterInViewSpace,Te=u.aW([],G,[be[0],be[1],be[2]]);u.au(Te,Te),u.av(Te,Te,fe);const Ve=u.cz([],G,Te);u.ad(Ve,Ve,ee);const ye=u.du/u.dK,Ae=u.ae(Ve),ge=u.aL(Math.max(Ae*ye-u.du,Number.EPSILON),0),Fe=Math.min(g.zoomFromMercatorZAdjusted(ge),x.maxZoom);return Fe>.5*(u.bU+u.bD)?(g.setProjection({name:"mercator"}),g.zoom=Fe,this._cameraForBounds(g,n,l,d,p,m)):{center:g.center,zoom:Fe,bearing:d,pitch:p}}_extendAABB(t,n,l,d){const p=.5*((l.padding.left||0)+(l.padding.right||0)),m=.5*((l.padding.top||0)+(l.padding.bottom||0)),g=m,x=p,w=p,S=m,A=n.width-(x+w),I=n.height-(g+S),M=u.aW([],t.max,t.min),D=Math.min(A/M[0],I/M[1]),L=Math.min(n.scaleZoom(n.scale*D),l.maxZoom);if(isNaN(L))return null;const k=n.scale/n.zoomScale(L),B=new u.ca([t.min[0]-x*k,t.min[1]-S*k,t.min[2]],[t.max[0]+w*k,t.max[1]+g*k,t.max[2]]),$=(typeof l.offset.x=="number"&&typeof l.offset.y=="number"?new u.P(l.offset.x,l.offset.y):u.P.convert(l.offset)).rotate(-u.al(d));return B.center[0]-=$.x*k,B.center[1]+=$.y*k,B}queryTerrainElevation(t,n){const l=this.transform.elevation;return l?(n={exaggerated:!0,...n},l.getAtPoint(u.ac.fromLngLat(t),null,n.exaggerated)):null}_cameraForBounds(t,n,l,d,p,m){if(t.projection.name==="globe")return this._cameraForBoundsOnGlobe(t,n,l,d,p,m);const g=t.clone(),x=this._extendCameraOptions(m);g.bearing=d,g.pitch=p;const w=u.b4.convert(n),S=u.b4.convert(l),A=new u.b4(w.lng,S.lat),I=new u.b4(S.lng,w.lat),M=g.project(w),D=g.project(S),L=this.queryTerrainElevation(w),k=this.queryTerrainElevation(S),B=this.queryTerrainElevation(A),$=this.queryTerrainElevation(I),Z=[[M.x,M.y,Math.min(L||0,k||0,B||0,$||0)],[D.x,D.y,Math.max(L||0,k||0,B||0,$||0)]];let G=u.ca.fromPoints(Z);const te=g.getWorldToCameraMatrix(),ee=u.aE(new Float64Array(16),te);G=u.ca.applyTransform(G,te);const le=this._extendAABB(G,g,x,d);if(!le)return void u.w("Map cannot fit within canvas with the given bounds, padding, and/or offset.");G=le;const K=.5*u.aW([],G.max,G.min)[2],Q=this._minimumAABBFrustumDistance(g,G),ae=[0,0,1,0];u.aO(ae,ae,te),u.ff(ae,ae);const de=u.av([],ae,Q+K),fe=u.cz([],G.center,de);u.ad(G.center,G.center,ee),u.ad(fe,fe,ee);const be=g.unproject(new u.P(G.center[0],G.center[1])),Te=u.fg(g.projection,be),Ve=Math.pow(2,Te),ye=Math.min(g._zoomFromMercatorZ(fe[2]*g.pixelsPerMeter*Ve/g.worldSize),x.maxZoom);return g.mercatorFromTransition&&ye<.5*(u.bU+u.bD)?(g.setProjection({name:"globe"}),g.zoom=ye,this._cameraForBounds(g,n,l,d,p,m)):{center:be,zoom:ye,bearing:d,pitch:p}}fitBounds(t,n,l){const d=this.cameraForBounds(t,n);return this._fitInternal(d,n,l)}fitScreenCoordinates(t,n,l,d,p){const m=u.P.convert(t),g=u.P.convert(n),x=new u.P(Math.min(m.x,g.x),Math.min(m.y,g.y)),w=new u.P(Math.max(m.x,g.x),Math.max(m.y,g.y));if(this.transform.projection.name==="mercator"&&this.transform.anyCornerOffEdge(m,g))return this;const S=this.transform.pointLocation3D(x),A=this.transform.pointLocation3D(w),I=this.transform.pointLocation3D(new u.P(x.x,w.y)),M=this.transform.pointLocation3D(new u.P(w.x,x.y)),D=[Math.min(S.lng,A.lng,I.lng,M.lng),Math.min(S.lat,A.lat,I.lat,M.lat)],L=[Math.max(S.lng,A.lng,I.lng,M.lng),Math.max(S.lat,A.lat,I.lat,M.lat)],k=d&&d.pitch?d.pitch:this.getPitch(),B=this._cameraForBounds(this.transform,D,L,l,k,d);return this._fitInternal(B,d,p)}_fitInternal(t,n,l){return t?(n=Object.assign(t,n)).linear?this.easeTo(n,l):this.flyTo(n,l):this}jumpTo(t,n){this.stop();const l=t.preloadOnly?this.transform.clone():this.transform;let d=!1,p=!1,m=!1;"zoom"in t&&l.zoom!==+t.zoom&&(d=!0,l.zoom=+t.zoom),t.center!==void 0&&(l.center=u.b4.convert(t.center)),"bearing"in t&&l.bearing!==+t.bearing&&(p=!0,l.bearing=+t.bearing),"pitch"in t&&l.pitch!==+t.pitch&&(m=!0,l.pitch=+t.pitch);const g=typeof t.padding=="number"?this._extendPadding(t.padding):t.padding;if(t.padding!=null&&!l.isPaddingEqual(g))if(t.retainPadding===!1){const x=l.clone();x.padding=g,l.setLocationAtPoint(l.center,x.centerPoint)}else l.padding=g;return t.preloadOnly?(this._preloadTiles(l),this):(this.fire(new u.B("movestart",n)).fire(new u.B("move",n)),d&&this.fire(new u.B("zoomstart",n)).fire(new u.B("zoom",n)).fire(new u.B("zoomend",n)),p&&this.fire(new u.B("rotatestart",n)).fire(new u.B("rotate",n)).fire(new u.B("rotateend",n)),m&&this.fire(new u.B("pitchstart",n)).fire(new u.B("pitch",n)).fire(new u.B("pitchend",n)),this.fire(new u.B("moveend",n)))}getFreeCameraOptions(){return this.transform.projection.supportsFreeCamera||u.w(R_),this.transform.getFreeCameraOptions()}setFreeCameraOptions(t,n){const l=this.transform;if(!l.projection.supportsFreeCamera)return u.w(R_),this;this.stop();const d=l.zoom,p=l.pitch,m=l.bearing;l.setFreeCameraOptions(t);const g=d!==l.zoom,x=p!==l.pitch,w=m!==l.bearing;return this.fire(new u.B("movestart",n)).fire(new u.B("move",n)),g&&this.fire(new u.B("zoomstart",n)).fire(new u.B("zoom",n)).fire(new u.B("zoomend",n)),w&&this.fire(new u.B("rotatestart",n)).fire(new u.B("rotate",n)).fire(new u.B("rotateend",n)),x&&this.fire(new u.B("pitchstart",n)).fire(new u.B("pitch",n)).fire(new u.B("pitchend",n)),this.fire(new u.B("moveend",n)),this}easeTo(t,n){this._stop(!1,t.easeId),((t={offset:[0,0],duration:500,easing:u.f7,...t}).animate===!1||this._prefersReducedMotion(t))&&(t.duration=0);const l=this.transform,d=this.getZoom(),p=this.getBearing(),m=this.getPitch(),g=this.getPadding(),x="zoom"in t?+t.zoom:d,w="bearing"in t?this._normalizeBearing(t.bearing,p):p,S="pitch"in t?+t.pitch:m,A=this._extendPadding(t.padding),I=u.P.convert(t.offset);let M,D,L;if(l.projection.name==="globe"){const ae=u.ac.fromLngLat(l.center),de=I.rotate(-l.angle);ae.x+=de.x/l.worldSize,ae.y+=de.y/l.worldSize;const fe=ae.toLngLat(),be=u.b4.convert(t.center||fe);this._normalizeCenter(be),M=l.centerPoint.add(de),D=new u.P(ae.x,ae.y).mult(l.worldSize),L=new u.P(u.a_(be.lng),u.a$(be.lat)).mult(l.worldSize).sub(D)}else{M=l.centerPoint.add(I);const ae=l.pointLocation(M),de=u.b4.convert(t.center||ae);this._normalizeCenter(de),D=l.project(ae),L=l.project(de).sub(D)}const k=l.zoomScale(x-d);let B,$;t.around&&(B=u.b4.convert(t.around),$=l.locationPoint(B));const Z=this._zooming||x!==d,G=this._rotating||p!==w,te=this._pitching||S!==m,ee=!l.isPaddingEqual(A),le=t.retainPadding===!1?l.clone():l,K=ae=>de=>{if(Z&&(ae.zoom=u.ai(d,x,de)),G&&(ae.bearing=u.ai(p,w,de)),te&&(ae.pitch=u.ai(m,S,de)),ee&&(le.interpolatePadding(g,A,de),M=le.centerPoint.add(I)),B)ae.setLocationAtPoint(B,$);else{const fe=ae.zoomScale(ae.zoom-d),be=x>d?Math.min(2,k):Math.max(.5,k),Te=Math.pow(be,1-de),Ve=ae.unproject(D.add(L.mult(de*Te)).mult(fe));ae.setLocationAtPoint(ae.renderWorldCopies?Ve.wrap():Ve,M)}return t.preloadOnly||this._fireMoveEvents(n),ae};if(t.preloadOnly){const ae=this._emulate(K,t.duration,l);return this._preloadTiles(ae),this}const Q={moving:this._moving,zooming:this._zooming,rotating:this._rotating,pitching:this._pitching};return this._zooming=Z,this._rotating=G,this._pitching=te,this._padding=ee,this._easeId=t.easeId,this._prepareEase(n,t.noMoveStart,Q),this._ease(K(l),ae=>{l.cameraElevationReference==="sea"&&l.recenterOnTerrain(),this._afterEase(n,ae)},t),this}_prepareEase(t,n,l={}){this._moving=!0,this.transform.cameraElevationReference="sea",this.transform._orthographicProjectionAtLowPitch&&this.transform.pitch===0&&this.transform.projection.name!=="globe"&&(this.transform.cameraElevationReference="ground"),n||l.moving||this.fire(new u.B("movestart",t)),this._zooming&&!l.zooming&&this.fire(new u.B("zoomstart",t)),this._rotating&&!l.rotating&&this.fire(new u.B("rotatestart",t)),this._pitching&&!l.pitching&&this.fire(new u.B("pitchstart",t))}_fireMoveEvents(t){this.fire(new u.B("move",t)),this._zooming&&this.fire(new u.B("zoom",t)),this._rotating&&this.fire(new u.B("rotate",t)),this._pitching&&this.fire(new u.B("pitch",t))}_afterEase(t,n){if(this._easeId&&n&&this._easeId===n)return;this._easeId=void 0,this.transform.cameraElevationReference="ground";const l=this._zooming,d=this._rotating,p=this._pitching;this._moving=!1,this._zooming=!1,this._rotating=!1,this._pitching=!1,this._padding=!1,l&&this.fire(new u.B("zoomend",t)),d&&this.fire(new u.B("rotateend",t)),p&&this.fire(new u.B("pitchend",t)),this.fire(new u.B("moveend",t))}flyTo(t,n){if(this._prefersReducedMotion(t)){const Re=u.b5(t,["center","zoom","bearing","pitch","around","padding","retainPadding"]);return this.jumpTo(Re,n)}this.stop(),t={offset:[0,0],speed:1.2,curve:1.42,easing:u.f7,...t};const l=this.transform,d=this.getZoom(),p=this.getBearing(),m=this.getPitch(),g=this.getPadding(),x="zoom"in t?u.as(+t.zoom,l.minZoom,l.maxZoom):d,w="bearing"in t?this._normalizeBearing(t.bearing,p):p,S="pitch"in t?+t.pitch:m,A=this._extendPadding(t.padding),I=l.zoomScale(x-d),M=u.P.convert(t.offset);let D=l.centerPoint.add(M);const L=l.pointLocation(D),k=u.b4.convert(t.center||L);this._normalizeCenter(k);const B=l.project(L),$=l.project(k).sub(B);let Z=t.curve;const G=Math.max(l.width,l.height),te=G/I,ee=$.mag();if("minZoom"in t){const Re=u.as(Math.min(t.minZoom,d,x),l.minZoom,l.maxZoom),De=G/l.zoomScale(Re-d);Z=Math.sqrt(De/ee*2)}const le=Z*Z;function K(Re){const De=(te*te-G*G+(Re?-1:1)*le*le*ee*ee)/(2*(Re?te:G)*le*ee);return Math.log(Math.sqrt(De*De+1)-De)}function Q(Re){return(Math.exp(Re)-Math.exp(-Re))/2}function ae(Re){return(Math.exp(Re)+Math.exp(-Re))/2}const de=K(0);let fe=function(Re){return ae(de)/ae(de+Z*Re)},be=function(Re){return G*((ae(de)*(Q(De=de+Z*Re)/ae(De))-Q(de))/le)/ee;var De},Te=(K(1)-de)/Z;if(Math.abs(ee)<1e-6||!isFinite(Te)){if(Math.abs(G-te)<1e-6)return this.easeTo(t,n);const Re=te<G?-1:1;Te=Math.abs(Math.log(te/G))/Z,be=function(){return 0},fe=function(De){return Math.exp(Re*Z*De)}}t.duration="duration"in t?+t.duration:1e3*Te/("screenSpeed"in t?+t.screenSpeed/Z:+t.speed),t.maxDuration&&t.duration>t.maxDuration&&(t.duration=0);const Ve=p!==w,ye=S!==m,Ae=!l.isPaddingEqual(A),ge=t.retainPadding===!1?l.clone():l,Fe=Re=>De=>{const Ke=De*Te,Be=1/fe(Ke);Re.zoom=De===1?x:d+Re.scaleZoom(Be),Ve&&(Re.bearing=u.ai(p,w,De)),ye&&(Re.pitch=u.ai(m,S,De)),Ae&&(ge.interpolatePadding(g,A,De),D=ge.centerPoint.add(M));const Ge=De===1?k:Re.unproject(B.add($.mult(be(Ke))).mult(Be));return Re.setLocationAtPoint(Re.renderWorldCopies?Ge.wrap():Ge,D),Re._updateCameraOnTerrain(),t.preloadOnly||this._fireMoveEvents(n),Re};if(t.preloadOnly){const Re=this._emulate(Fe,t.duration,l);return this._preloadTiles(Re),this}return this._zooming=!0,this._rotating=Ve,this._pitching=ye,this._padding=Ae,this._prepareEase(n,!1),this._ease(Fe(l),()=>this._afterEase(n),t),this}isEasing(){return!!this._easeFrameId}stop(){return this._stop()}_requestRenderFrame(t){}_cancelRenderFrame(t){}_stop(t,n){if(this._easeFrameId&&(this._cancelRenderFrame(this._easeFrameId),this._easeFrameId=void 0,this._onEaseFrame=void 0),this._onEaseEnd){const l=this._onEaseEnd;this._onEaseEnd=void 0,l.call(this,n)}if(!t){const l=this.handlers;l&&l.stop(!1)}return this}_ease(t,n,l){l.animate===!1||l.duration===0?(t(1),n()):(this._easeStart=u.r.now(),this._easeOptions=l,this._onEaseFrame=t,this._onEaseEnd=n,this._easeFrameId=this._requestRenderFrame(this._renderFrameCallback))}_renderFrameCallback(){const t=Math.min((u.r.now()-this._easeStart)/this._easeOptions.duration,1),n=this._onEaseFrame;n&&n(this._easeOptions.easing(t)),t<1?this._easeFrameId=this._requestRenderFrame(this._renderFrameCallback):this.stop()}_normalizeBearing(t,n){t=u.at(t,-180,180);const l=Math.abs(t-n);return Math.abs(t-360-n)<l&&(t-=360),Math.abs(t+360-n)<l&&(t+=360),t}_normalizeCenter(t){const n=this.transform;if(n.maxBounds||n.projection.name!=="globe"&&!n.renderWorldCopies)return;const l=t.lng-n.center.lng;t.lng+=l>180?-360:l<-180?360:0}_prefersReducedMotion(t){return this._respectPrefersReducedMotion&&u.r.prefersReducedMotion&&!(t&&t.essential)}_emulate(t,n,l){const d=Math.ceil(15*n/1e3),p=[],m=t(l.clone());for(let g=0;g<=d;g++){const x=m(g/d);p.push(x.clone())}return p}_preloadTiles(t,n){}}const Ry=/^(https?:|mailto:)/i;class Ou{constructor(t={}){this.options=t,u.cL(["_toggleAttribution","_updateEditLink","_updateData","_updateCompact"],this)}getDefaultPosition(){return"bottom-right"}onAdd(t){const n=this.options&&this.options.compact,l=t._getUIString("AttributionControl.ToggleAttribution");this._map=t,this._container=Nt("div","mapboxgl-ctrl mapboxgl-ctrl-attrib"),this._compactButton=Nt("button","mapboxgl-ctrl-attrib-button",this._container),this._compactButton.type="button",this._compactButton.addEventListener("click",this._toggleAttribution),this._compactButton.setAttribute("aria-label",l);const d=Nt("span","mapboxgl-ctrl-icon",this._compactButton);return d.setAttribute("aria-hidden","true"),d.setAttribute("title",l),this._innerContainer=Nt("div","mapboxgl-ctrl-attrib-inner",this._container),n&&this._container.classList.add("mapboxgl-compact"),this._updateAttributions(),this._updateEditLink(),this._map.on("styledata",this._updateData),this._map.on("sourcedata",this._updateData),this._map.on("moveend",this._updateEditLink),n===void 0&&(this._map.on("resize",this._updateCompact),this._updateCompact()),this._container}onRemove(){this._container.remove(),this._map.off("styledata",this._updateData),this._map.off("sourcedata",this._updateData),this._map.off("moveend",this._updateEditLink),this._map.off("resize",this._updateCompact),this._map=void 0,this._attribHTML=void 0}_toggleAttribution(){this._container.classList.contains("mapboxgl-compact-show")?(this._container.classList.remove("mapboxgl-compact-show"),this._compactButton.setAttribute("aria-expanded","false")):(this._container.classList.add("mapboxgl-compact-show"),this._compactButton.setAttribute("aria-expanded","true"))}_updateEditLink(){let t=this._editLink;t||(t=this._editLink=this._container.querySelector(".mapbox-improve-map"));const n=[{key:"owner",value:this.styleOwner},{key:"id",value:this.styleId},{key:"access_token",value:this._map._requestManager._customAccessToken||u.g.ACCESS_TOKEN}];if(t){const l=n.reduce((d,p,m)=>(p.value&&(d+=`${p.key}=${p.value}${m<n.length-1?"&":""}`),d),"?");t.href=`${u.g.FEEDBACK_URL}/${l}#${up(this._map,!0)}`,t.rel="noopener nofollow"}}_updateData(t){!t||(t.dataType!=="source"||t.sourceDataType!=="metadata"&&t.sourceDataType!=="visibility")&&t.dataType!=="style"||(this._updateAttributions(),this._updateEditLink())}_updateAttributions(){if(!this._map.style)return;let t=[];if(this._map.style.stylesheet){const d=this._map.style.stylesheet;this.styleOwner=d.owner,this.styleId=d.id}const n=this._map.style._mergedSourceCaches;for(const d in n){const p=n[d];if(p.used){const m=p.getSource();m.attribution&&!t.includes(m.attribution)&&t.push(m.attribution)}}t.sort((d,p)=>d.length-p.length),t=t.filter((d,p)=>{for(let m=p+1;m<t.length;m++)if(t[m].includes(d))return!1;return!0}),this.options.customAttribution&&(Array.isArray(this.options.customAttribution)?t=[...this.options.customAttribution,...t]:t.unshift(this.options.customAttribution));const l=t.map(d=>(function(p){const m=new DOMParser().parseFromString(p,"text/html");return Array.from(m.body.querySelectorAll("*")).reverse().forEach(g=>{const x=g.textContent||"";if(g.tagName!=="A")return void g.replaceWith(...g.childNodes);const w=g.getAttribute("href");if(!w||!Ry.test(w))return void g.replaceWith(m.createTextNode(x));const S=m.createElement("a");S.href=w,S.textContent=x,S.rel="noopener nofollow";const A=g.getAttribute("class");A&&(S.className=A),g.replaceWith(S)}),m.body.innerHTML})(d)).join(" | ");l!==this._attribHTML&&(this._attribHTML=l,t.length?(this._innerContainer.innerHTML=l,this._container.classList.remove("mapboxgl-attrib-empty")):this._container.classList.add("mapboxgl-attrib-empty"),this._editLink=null)}_updateCompact(){this._map.getCanvasContainer().offsetWidth<=640?this._container.classList.add("mapboxgl-compact"):this._container.classList.remove("mapboxgl-compact","mapboxgl-compact-show")}}class D_{constructor(){u.cL(["_updateLogo","_updateCompact"],this)}onAdd(t){this._map=t,this._container=Nt("div","mapboxgl-ctrl");const n=Nt("a","mapboxgl-ctrl-logo");return n.target="_blank",n.rel="noopener nofollow",n.href="https://www.mapbox.com/",n.setAttribute("aria-label",this._map._getUIString("LogoControl.Title")),n.setAttribute("rel","noopener nofollow"),this._container.appendChild(n),this._container.style.display="none",this._map.on("sourcedata",this._updateLogo),this._updateLogo(),this._map.on("resize",this._updateCompact),this._updateCompact(),this._container}onRemove(){this._container.remove(),this._map.off("sourcedata",this._updateLogo),this._map.off("resize",this._updateCompact)}getDefaultPosition(){return"bottom-left"}_updateLogo(t){t&&t.sourceDataType!=="metadata"||(this._container.style.display=this._logoRequired()?"block":"none")}_logoRequired(){if(!this._map.style)return!0;const t=this._map.style._sourceCaches;if(Object.entries(t).length===0)return!0;for(const n in t){const l=t[n].getSource();if(Object.hasOwn(l,"mapbox_logo")&&!l.mapbox_logo)return!1}return!0}_updateCompact(){const t=this._container.children;if(t.length){const n=t[0];this._map.getCanvasContainer().offsetWidth<250?n.classList.add("mapboxgl-compact"):n.classList.remove("mapboxgl-compact")}}}class L_{constructor(){this._queue=[],this._id=0,this._cleared=!1,this._currentlyRunning=!1}add(t){const n=++this._id;return this._queue.push({callback:t,id:n,cancelled:!1}),n}remove(t){const n=this._currentlyRunning,l=n?this._queue.concat(n):this._queue;for(const d of l)if(d.id===t)return void(d.cancelled=!0)}run(t=0){const n=this._currentlyRunning=this._queue;this._queue=[];for(const l of n)if(!l.cancelled&&(l.callback(t),this._cleared))break;this._cleared=!1,this._currentlyRunning=!1}clear(){this._currentlyRunning&&(this._cleared=!0),this._queue=[]}}class Dy{constructor(t){this.jumpTo(t)}getValue(t){if(t<=this._startTime)return this._start;if(t>=this._endTime)return this._end;const n=u.eu((t-this._startTime)/(this._endTime-this._startTime));return this._start*(1-n)+this._end*n}isEasing(t){return t>=this._startTime&&t<=this._endTime}jumpTo(t){this._startTime=-1/0,this._endTime=-1/0,this._start=t,this._end=t}easeTo(t,n,l){this._start=this.getValue(n),this._end=t,this._startTime=n,this._endTime=n+l}}const Ly={"AttributionControl.ToggleAttribution":"Toggle attribution","FullscreenControl.Enter":"Enter fullscreen","FullscreenControl.Exit":"Exit fullscreen","GeolocateControl.FindMyLocation":"Find my location","GeolocateControl.LocationNotAvailable":"Location not available","LogoControl.Title":"Mapbox homepage","Map.Title":"Map","NavigationControl.ResetBearing":"Reset bearing to north","NavigationControl.ZoomIn":"Zoom in","NavigationControl.ZoomOut":"Zoom out","ScrollZoomBlocker.CtrlMessage":"Use ctrl + scroll to zoom the map","ScrollZoomBlocker.CmdMessage":"Use ⌘ + scroll to zoom the map","TouchPanBlocker.Message":"Use two fingers to move the map"};class z_ extends u.B{constructor(t,n,l,d){const{point:p,lngLat:m,originalEvent:g,target:x}=t;super(t.type,{point:p,lngLat:m,originalEvent:g,target:x}),this.preventDefault=()=>{t.preventDefault()},this.id=n,this.interaction=l,this.feature=d}}class zy{constructor(t){this.map=t,this.interactionsByType=new Map,this.delegatedInteractions=new Map,this.typeById=new Map,this.filters=new Map,this.handleType=this.handleType.bind(this),this.handleMove=this.handleMove.bind(this),this.handleOut=this.handleOut.bind(this),this.hoveredFeatures=new Map,this.prevHoveredFeatures=new Map}add(t,n){if(this.typeById.has(t))throw new Error(`Interaction id "${t}" already exists.`);const l=n.filter;let d=n.type;l&&this.filters.set(t,u.cV(l)),d==="mouseover"&&(d="mouseenter"),d==="mouseout"&&(d="mouseleave");const p=this.interactionsByType.get(d)||new Map;d==="mouseenter"||d==="mouseleave"?(this.delegatedInteractions.size===0&&(this.map.on("mousemove",this.handleMove),this.map.on("mouseout",this.handleOut)),this.delegatedInteractions.set(t,n)):p.size===0&&this.map.on(d,this.handleType),p.size===0&&this.interactionsByType.set(d,p),p.set(t,n),this.typeById.set(t,d)}get(t){const n=this.typeById.get(t);if(!n)return;const l=this.interactionsByType.get(n);return l?l.get(t):void 0}remove(t){const n=this.typeById.get(t);if(!n)return;this.typeById.delete(t),this.filters.delete(t);const l=this.interactionsByType.get(n);l&&(l.delete(t),n==="mouseenter"||n==="mouseleave"?(this.delegatedInteractions.delete(t),this.delegatedInteractions.size===0&&(this.map.off("mousemove",this.handleMove),this.map.off("mouseout",this.handleOut))):l.size===0&&this.map.off(n,this.handleType))}queryTargets(t,n){const l=[];for(const[d,p]of n)p.target&&l.push({targetId:d,target:p.target,filter:this.filters.get(d)});return this.map.style.queryRenderedTargets(t,l,this.map.transform)}handleMove(t){this.prevHoveredFeatures=this.hoveredFeatures,this.hoveredFeatures=new Map;const n=this.queryTargets(t.point,Array.from(this.delegatedInteractions).reverse());n.length&&(t.type="mouseenter",this.handleType(t,n));const l=new Map;for(const[d,{feature:p}]of this.prevHoveredFeatures)this.hoveredFeatures.has(d)||l.set(p.id,p);l.size&&(t.type="mouseleave",this.handleType(t,Array.from(l.values())))}handleOut(t){const n=Array.from(this.hoveredFeatures.values()).map(({feature:l})=>l);n.length&&(t.type="mouseleave",this.handleType(t,n)),this.hoveredFeatures.clear()}handleType(t,n){const l=t.type==="mouseenter";if(l&&!this.interactionsByType.has(t.type))return void u.w("mouseenter interaction required for mouseleave to work.");const d=Array.from(this.interactionsByType.get(t.type)).reverse(),p=!!n;n=n||this.queryTargets(t.point,d);let m=!1;const g=new Set;for(const x of n){for(const[w,S]of d){if(!S.target)continue;const A=x.variants?x.variants[w]:null;if(A){for(const I of A){if(so(I,x,g,w))continue;const M=new u.er(x,I),D=Ym(I,x,w);p&&M.id!==void 0&&(M.state=this.map.getFeatureState(M));const L=l?this.prevHoveredFeatures.get(D):null,k=new z_(t,w,S,M),B=L?L.stop:S.handler(k);if(l&&this.hoveredFeatures.set(D,{feature:x,stop:B}),B!==!1){m=!0;break}}if(m)break}}if(m)break}if(!m)for(const[x,w]of d){const{handler:S,target:A}=w;if(!A&&S(new z_(t,x,w,null))!==!1)break}}}function Fy(s,t){if(Array.isArray(s)&&Array.isArray(t)){const n=new Set(s),l=new Set(t);return n.size===l.size&&s.every(d=>l.has(d))}return u.b7(s,t)}const Oy=/matrix.*\((.+)\)/,ky={center:[0,0],zoom:0,bearing:0,pitch:0,minZoom:-2,maxZoom:22,minPitch:0,maxPitch:85,interactive:!0,scrollZoom:!0,boxZoom:!0,dragRotate:!0,dragPan:!0,keyboard:!0,doubleClickZoom:!0,touchZoomRotate:!0,touchPitch:!0,cooperativeGestures:!1,performanceMetricsCollection:!0,bearingSnap:7,clickTolerance:3,pitchWithRotate:!0,hash:!1,attributionControl:!0,antialias:!1,failIfMajorPerformanceCaveat:!1,preserveDrawingBuffer:!1,trackResize:!0,renderWorldCopies:!0,refreshExpiredTiles:!0,minTileCacheSize:null,maxTileCacheSize:null,localIdeographFontFamily:"sans-serif",localFontFamily:null,fontstackCompositing:"client",transformRequest:null,accessToken:null,fadeDuration:300,respectPrefersReducedMotion:!0,crossSourceCollisions:!0,collectResourceTiming:!1,testMode:!1,precompilePrograms:!0,scaleFactor:1},F_={showCompass:!0,showZoom:!0,visualizePitch:!1};class By{constructor(t,n,l=!1){this._clickTolerance=10,this.element=n,this.mouseRotate=new hd({clickTolerance:t.dragRotate._mouseRotate._clickTolerance}),this.map=t,l&&(this.mousePitch=new _p({clickTolerance:t.dragRotate._mousePitch._clickTolerance})),u.cL(["mousedown","mousemove","mouseup","touchstart","touchmove","touchend","reset"],this),n.addEventListener("mousedown",this.mousedown),n.addEventListener("touchstart",this.touchstart,{passive:!1}),n.addEventListener("touchmove",this.touchmove),n.addEventListener("touchend",this.touchend),n.addEventListener("touchcancel",this.reset)}down(t,n){this.mouseRotate.mousedown(t,n),this.mousePitch&&this.mousePitch.mousedown(t,n),_n()}move(t,n){const l=this.map,d=this.mouseRotate.mousemoveWindow(t,n),p=d&&d.bearingDelta;if(p&&l.setBearing(l.getBearing()+p),this.mousePitch){const m=this.mousePitch.mousemoveWindow(t,n),g=m&&m.pitchDelta;g&&l.setPitch(l.getPitch()+g)}}off(){const t=this.element;t.removeEventListener("mousedown",this.mousedown),t.removeEventListener("touchstart",this.touchstart),t.removeEventListener("touchmove",this.touchmove),t.removeEventListener("touchend",this.touchend),t.removeEventListener("touchcancel",this.reset),this.offTemp()}offTemp(){gn(),window.removeEventListener("mousemove",this.mousemove),window.removeEventListener("mouseup",this.mouseup)}mousedown(t){this.down({...t,button:t.button,type:t.type,ctrlKey:!0,preventDefault:()=>t.preventDefault()},hn(this.element,t)),window.addEventListener("mousemove",this.mousemove),window.addEventListener("mouseup",this.mouseup)}mousemove(t){this.move(t,hn(this.element,t))}mouseup(t){this.mouseRotate.mouseupWindow(t),this.mousePitch&&this.mousePitch.mouseupWindow(t),this.offTemp()}touchstart(t){t.targetTouches.length!==1?this.reset():(this._startPos=this._lastPos=So(this.element,t.targetTouches)[0],this.down({type:"mousedown",button:0,ctrlKey:!0,preventDefault:()=>t.preventDefault()},this._startPos))}touchmove(t){t.targetTouches.length!==1?this.reset():(this._lastPos=So(this.element,t.targetTouches)[0],this.move({buttons:1,preventDefault:()=>t.preventDefault()},this._lastPos))}touchend(t){t.targetTouches.length===0&&this._startPos&&this._lastPos&&this._startPos.dist(this._lastPos)<this._clickTolerance&&this.element.click(),this.reset()}reset(){this.mouseRotate.reset(),this.mousePitch&&this.mousePitch.reset(),delete this._startPos,delete this._lastPos,this.offTemp()}}function Xa(s,t,n){if(s=new u.b4(s.lng,s.lat),t){const l=new u.b4(s.lng-360,s.lat),d=new u.b4(s.lng+360,s.lat),p=360*Math.ceil(Math.abs(s.lng-n.center.lng)/360),m=n.locationPoint3D(s).distSqr(t),g=t.x<0||t.y<0||t.x>n.width||t.y>n.height;n.locationPoint3D(l).distSqr(t)<m&&(g||Math.abs(l.lng-n.center.lng)<p)?s=l:n.locationPoint3D(d).distSqr(t)<m&&(g||Math.abs(d.lng-n.center.lng)<p)&&(s=d)}for(;Math.abs(s.lng-n.center.lng)>180;){const l=n.locationPoint3D(s);if(l.x>=0&&l.y>=0&&l.x<=n.width&&l.y<=n.height)break;s.lng>n.center.lng?s.lng-=360:s.lng+=360}return s}const Ya={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%)"},O_=/\s+/,Rs={rotation:0,rotationAlignment:"auto",pitchAlignment:"auto",occludedOpacity:.2,altitude:0};class Ol extends u.E{constructor(t,n){super(),(t instanceof HTMLElement||n)&&(t={element:t,...n}),u.cL(["_update","_onMove","_onUp","_addDragHandler","_onMapClick","_onKeyPress","_clearFadeTimer"],this);const{anchor:l="center",color:d="#3FB1CE",scale:p=1,draggable:m=!1,clickTolerance:g=0,rotation:x=Rs.rotation,rotationAlignment:w=Rs.rotationAlignment,pitchAlignment:S=Rs.pitchAlignment,occludedOpacity:A=Rs.occludedOpacity,altitude:I=Rs.altitude}=t||{};this._anchor=l,this._color=d,this._scale=p,this._draggable=m,this._clickTolerance=g,this._rotation=x,this._rotationAlignment=w,this._pitchAlignment=S,this._occludedOpacity=A,this._altitude=I,this._state="inactive",this._isDragging=!1,this._updateMoving=()=>this._update(!0),t&&t.element?(this._element=t.element,this._offset=u.P.convert(t&&t.offset||[0,0])):(this._defaultMarker=!0,this._element=this._createDefaultMarker(),this._offset=u.P.convert(t&&t.offset||[0,-14])),this._element.hasAttribute("aria-label")||this._element.setAttribute("aria-label","Map marker"),this._element.hasAttribute("role")||this._element.setAttribute("role","img"),this._element.classList.add("mapboxgl-marker"),this._element.addEventListener("dragstart",D=>{D.preventDefault()}),this._element.addEventListener("mousedown",D=>{D.preventDefault()});const M=this._element.classList;for(const D in Ya)M.remove(`mapboxgl-marker-anchor-${D}`);M.add(`mapboxgl-marker-anchor-${this._anchor}`),t&&t.className&&M.add(...t.className.trim().split(O_)),this._popup=null}_createDefaultMarker(){const t=Nt("div"),n=Si("svg",{display:"block",height:41*this._scale+"px",width:27*this._scale+"px",viewBox:"0 0 27 41"},t);this._svgElement=n;const l=Si("radialGradient",{id:"shadowGradient"},Si("defs",{},n));Si("stop",{offset:"10%","stop-opacity":.4},l),Si("stop",{offset:"100%","stop-opacity":.05},l);const d=Si("ellipse",{cx:13.5,cy:34.8,rx:10.5,ry:5.25,fill:"url(#shadowGradient)"});return this._shadowElement=d,this._altitude===0&&n.insertBefore(d,n.firstChild),Si("path",{fill:this._color,d:"M27,13.5C27,19.07 20.25,27 14.75,34.5C14.02,35.5 12.98,35.5 12.25,34.5C6.75,27 0,19.22 0,13.5C0,6.04 6.04,0 13.5,0C20.96,0 27,6.04 27,13.5Z"},n),Si("path",{opacity:.25,d:"M13.5,0C6.04,0 0,6.04 0,13.5C0,19.22 6.75,27 12.25,34.5C13,35.52 14.02,35.5 14.75,34.5C20.25,27 27,19.07 27,13.5C27,6.04 20.96,0 13.5,0ZM13.5,1C20.42,1 26,6.58 26,13.5C26,15.9 24.5,19.18 22.22,22.74C19.95,26.3 16.71,30.14 13.94,33.91C13.74,34.18 13.61,34.32 13.5,34.44C13.39,34.32 13.26,34.18 13.06,33.91C10.28,30.13 7.41,26.31 5.02,22.77C2.62,19.23 1,15.95 1,13.5C1,6.58 6.58,1 13.5,1Z"},n),Si("circle",{fill:"white",cx:13.5,cy:13.5,r:5.5},n),t}addTo(t){return t===this._map||(this.remove(),this._map=t,t.getCanvasContainer().appendChild(this._element),t.on("move",this._updateMoving),t.on("moveend",this._update),t.on("remove",this._clearFadeTimer),t._addMarker(this),this.setDraggable(this._draggable),this._update(),t.on("click",this._onMapClick)),this}remove(){const t=this._map;return t&&(t.off("click",this._onMapClick),t.off("move",this._updateMoving),t.off("moveend",this._update),t.off("mousedown",this._addDragHandler),t.off("touchstart",this._addDragHandler),t.off("mouseup",this._onUp),t.off("touchend",this._onUp),t.off("mousemove",this._onMove),t.off("touchmove",this._onMove),t.off("remove",this._clearFadeTimer),t._removeMarker(this),this._map=void 0),this._clearFadeTimer(),this._element.remove(),this._popup&&this._popup.remove(),this}getLngLat(){return this._lngLat}setLngLat(t){return this._lngLat=u.b4.convert(t),this._pos=null,this._popup&&this._popup.setLngLat(this._lngLat),this._update(!0),this}setAltitude(t){if(t===this._altitude)return this;const n=this._altitude;return this._altitude=t||Rs.altitude,this._defaultMarker&&n===0!=(this._altitude===0)&&(this._altitude===0?this._svgElement.insertBefore(this._shadowElement,this._svgElement.firstChild):this._shadowElement.remove()),this._update(),this}getAltitude(){return this._altitude}getElement(){return this._element}setPopup(t){if(this._popup&&(this._popup.remove(),this._popup=null,this._element.removeAttribute("role"),this._element.removeEventListener("keypress",this._onKeyPress),this._originalTabIndex||this._element.removeAttribute("tabindex")),t){if(!("offset"in t.options)){const d=Math.sqrt(Math.pow(13.5,2)/2);t.options.offset=this._defaultMarker?{top:[0,0],"top-left":[0,0],"top-right":[0,0],bottom:[0,-38.1],"bottom-left":[d,-1*(38.1-13.5+d)],"bottom-right":[-d,-1*(38.1-13.5+d)],left:[13.5,-1*(38.1-13.5)],right:[-13.5,-1*(38.1-13.5)]}:this._offset}this._popup=t,t._marker=this,t._altitude=this._altitude,this._lngLat&&this._popup.setLngLat(this._lngLat),this._element.setAttribute("role","button"),this._originalTabIndex=this._element.getAttribute("tabindex"),this._originalTabIndex||this._element.setAttribute("tabindex","0"),this._element.addEventListener("keypress",this._onKeyPress),this._element.setAttribute("aria-expanded","false")}return this}_onKeyPress(t){const n=t.code,l=t.charCode||t.keyCode;n!=="Space"&&n!=="Enter"&&l!==32&&l!==13||this.togglePopup()}_onMapClick(t){const n=t.originalEvent.target,l=this._element;this._popup&&(n===l||l.contains(n))&&this.togglePopup()}getPopup(){return this._popup}togglePopup(){const t=this._popup;return t?(t.isOpen()?(t.remove(),this._element.setAttribute("aria-expanded","false")):this._map&&(t.addTo(this._map),this._element.setAttribute("aria-expanded","true")),this):this}_behindTerrain(){const t=this._map,n=this._pos;if(!t||!n)return!1;const l=t.unproject(n,this._altitude),d=t.getFreeCameraOptions();if(!d.position)return!1;const p=d.position.toLngLat();return p.distanceTo(l)<.9*p.distanceTo(this._lngLat)}_evaluateOpacity(){const t=this._map;if(!t)return;const n=this._pos;if(!n||n.x<0||n.x>t.transform.width||n.y<0||n.y>t.transform.height)return void this._clearFadeTimer();const l=t.unproject(n,this._altitude);let d;t._showingGlobe()&&u.fi(t.transform,this._lngLat)?d=0:(d=1-t._queryFogOpacity(l),t.transform._terrainEnabled()&&t.style&&t.style.hasTerrain()&&this._behindTerrain()&&(d*=this._occludedOpacity)),this._element.style.opacity=`${d}`,this._element.style.pointerEvents=d>0?"auto":"none",this._popup&&this._popup._setOpacity(d),this._fadeTimer=null}_clearFadeTimer(){this._fadeTimer&&(clearTimeout(this._fadeTimer),this._fadeTimer=null)}_updateDOM(){const t=this._pos;if(!t||!this._map)return;const n=this._offset.mult(this._scale);this._element.style.transform=`
3402            translate(${t.x}px,${t.y}px)
3403            ${Ya[this._anchor]}
3404            ${this._calculateXYTransform()} ${this._calculateZTransform()}
3405            translate(${n.x}px,${n.y}px)
3406        `}_calculateXYTransform(){const t=this._pos,n=this._map,l=this.getPitchAlignment();if(!n||!t||l!=="map")return"";if(!n._showingGlobe()){const x=n.getPitch();return x?`rotateX(${x}deg)`:""}const d=u.bS(u.fj(n.transform,this._lngLat)),p=t.sub(u.fk(n.transform)),m=Math.abs(p.x)+Math.abs(p.y);if(m===0)return"";const g=d/m;return`rotateX(${-p.y*g}deg) rotateY(${p.x*g}deg)`}_calculateZTransform(){const t=this._pos,n=this._map;if(!n||!t)return"";let l=0;const d=this.getRotationAlignment();if(d==="map")if(n._showingGlobe()){const p=n.project(new u.b4(this._lngLat.lng,this._lngLat.lat+.001),this._altitude),m=n.project(new u.b4(this._lngLat.lng,this._lngLat.lat-.001),this._altitude).sub(p);l=u.bS(Math.atan2(m.y,m.x))-90}else l=-n.getBearing();else if(d==="horizon"){const p=u.af(4,6,n.getZoom()),m=u.fk(n.transform);m.y+=p*n.transform.height;const g=t.sub(m),x=u.bS(Math.atan2(g.y,g.x));l=(x>90?x-270:x+90)*(1-p)}return l+=this._rotation,l?`rotateZ(${l}deg)`:""}_update(t){cancelAnimationFrame(this._updateFrameId);const n=this._map;n&&(n.transform.renderWorldCopies&&(this._lngLat=Xa(this._lngLat,this._pos,n.transform)),this._pos=n.project(this._lngLat,this._altitude),t===!0?this._updateFrameId=requestAnimationFrame(()=>{this._element&&this._pos&&this._anchor&&(this._pos=this._pos.round(),this._updateDOM())}):this._pos=this._pos.round(),n._requestDomTask(()=>{this._map&&(this._element&&this._pos&&this._anchor&&this._updateDOM(),(n._showingGlobe()||n.style&&n.style.hasTerrain()||n.getFog())&&!this._fadeTimer&&(this._fadeTimer=window.setTimeout(this._evaluateOpacity.bind(this),60)))}))}getOffset(){return this._offset}setOffset(t){return this._offset=u.P.convert(t),this._update(),this}addClassName(t){return this._element.classList.add(t),this}removeClassName(t){return this._element.classList.remove(t),this}toggleClassName(t){return this._element.classList.toggle(t)}_onMove(t){const n=this._map;if(!n)return;const l=this._pointerdownPos,d=this._positionDelta;if(l&&d){if(!this._isDragging){const p=this._clickTolerance||n._clickTolerance;if(t.point.dist(l)<p)return;this._isDragging=!0}this._pos=t.point.sub(d),this._lngLat=n.unproject(this._pos,this._altitude),this.setLngLat(this._lngLat),this._element.style.pointerEvents="none",this._state==="pending"&&(this._state="active",this.fire(new u.B("dragstart"))),this.fire(new u.B("drag"))}}_onUp(){this._element.style.pointerEvents="auto",this._positionDelta=null,this._pointerdownPos=null,this._isDragging=!1;const t=this._map;t&&(t.off("mousemove",this._onMove),t.off("touchmove",this._onMove)),this._state==="active"&&this.fire(new u.B("dragend")),this._state="inactive"}_addDragHandler(t){const n=this._map,l=this._pos;n&&l&&this._element.contains(t.originalEvent.target)&&(t.preventDefault(),this._positionDelta=t.point.sub(l),this._pointerdownPos=t.point,this._state="pending",n.on("mousemove",this._onMove),n.on("touchmove",this._onMove),n.once("mouseup",this._onUp),n.once("touchend",this._onUp))}setDraggable(t){this._draggable=!!t;const n=this._map;return n&&(t?(n.on("mousedown",this._addDragHandler),n.on("touchstart",this._addDragHandler)):(n.off("mousedown",this._addDragHandler),n.off("touchstart",this._addDragHandler))),this}isDraggable(){return this._draggable}setRotation(t){return this._rotation=t||Rs.rotation,this._update(),this}getRotation(){return this._rotation}setRotationAlignment(t){return this._rotationAlignment=t||Rs.rotationAlignment,this._update(),this}getRotationAlignment(){return this._rotationAlignment==="auto"||this._rotationAlignment==="horizon"&&this._map&&!this._map._showingGlobe()?"viewport":this._rotationAlignment}setPitchAlignment(t){return this._pitchAlignment=t||Rs.pitchAlignment,this._update(),this}getPitchAlignment(){return this._pitchAlignment==="auto"?this.getRotationAlignment():this._pitchAlignment}setOccludedOpacity(t){return this._occludedOpacity=t||Rs.occludedOpacity,this._update(),this}getOccludedOpacity(){return this._occludedOpacity}}const an={OFF:[],WAITING_ACTIVE:["waiting","active"],ACTIVE_LOCK:["active"],ACTIVE_ERROR:["waiting","active-error"],BACKGROUND:["background"],BACKGROUND_ERROR:["waiting","background-error"]},_d=s=>`mapboxgl-ctrl-geolocate-${s}`,k_=["waiting","active","active-error","background","background-error"].map(_d),Ka={positionOptions:{enableHighAccuracy:!1,maximumAge:0,timeout:6e3},fitBoundsOptions:{maxZoom:15},trackUserLocation:!1,showAccuracyCircle:!0,showUserLocation:!0,showUserHeading:!1,showButton:!0,followUserLocation:!0},Mr={maxWidth:100,unit:"metric"},Ny={kilometer:"km",meter:"m",mile:"mi",foot:"ft","nautical-mile":"nm"},ku=/\s+/,Vy={closeButton:!0,closeOnClick:!0,focusAfterOpen:!0,className:"",maxWidth:"240px",altitude:0},Uy=["a[href]","[tabindex]:not([tabindex='-1'])","[contenteditable]:not([contenteditable='false'])","button:not([disabled])","input:not([disabled])","select:not([disabled])","textarea:not([disabled])"].join(", ");function gd(s=new u.P(0,0),t="bottom"){if(typeof s=="number"){const n=Math.round(Math.sqrt(.5*Math.pow(s,2)));switch(t){case"top":return new u.P(0,s);case"top-left":return new u.P(n,n);case"top-right":return new u.P(-n,n);case"bottom":return new u.P(0,-s);case"bottom-left":return new u.P(n,-n);case"bottom-right":return new u.P(-n,-n);case"left":return new u.P(s,0);case"right":return new u.P(-s,0)}return new u.P(0,0)}return s instanceof u.P||Array.isArray(s)?u.P.convert(s):u.P.convert(s[t]||[0,0])}const yd=typeof document<"u"?document.currentScript:null;var vp;return vp=yd&&yd.src&&u.a(yd.src)?"cdn":"other",qi=vp,{version:St,supported:function(s){return!(function(t){return typeof window<"u"&&typeof document<"u"?Object.hasOwn?(function(){const n=document.createElement("canvas");n.width=n.height=1;const l=n.getContext("2d");return!!l&&l.getImageData(0,0,1,1).width===n.width})()?(function(n){return n?(Ht===void 0&&(Ht=Wt(!0)),Ht):(Yi===void 0&&(Yi=Wt(!1)),Yi)})(t)?"":"insufficient WebGL2 support":"insufficient Canvas/getImageData support":"Object.hasOwn not supported":"not a browser"})(s)},setRTLTextPlugin:u.fn,getRTLTextPluginStatus:u.fm,setSdkInfo:function(s){typeof s!="str
3406ing"||s.length>64||!Mi.test(s)?u.w(`Invalid SDK info "${s}"; expected a "Name/version" string. Ignoring.`):Jr=s},addTileProvider:u.fl,Map:class extends Py{constructor(s){Zt.mark(Sn.create);const t=s;if((s={...ky,...s}).minZoom!=null&&s.maxZoom!=null&&s.minZoom>s.maxZoom)throw new Error("maxZoom must be greater than or equal to minZoom");if(s.minPitch!=null&&s.maxPitch!=null&&s.minPitch>s.maxPitch)throw new Error("maxPitch must be greater than or equal to minPitch");if(s.minPitch!=null&&s.minPitch<0)throw new Error("minPitch must be greater than or equal to 0");if(s.maxPitch!=null&&s.maxPitch>85)throw new Error("maxPitch must be less than or equal to 85");super(new ih(s.minZoom,s.maxZoom,s.minPitch,s.maxPitch,s.renderWorldCopies,null,null),s),this._repaint=!!s.repaint,this._interactive=s.interactive,this._minTileCacheSize=s.minTileCacheSize,this._maxTileCacheSize=s.maxTileCacheSize,this._failIfMajorPerformanceCaveat=s.failIfMajorPerformanceCaveat,this._preserveDrawingBuffer=s.preserveDrawingBuffer,this._antialias=s.antialias,this._trackResize=s.trackResize,this._bearingSnap=s.bearingSnap,this._refreshExpiredTiles=s.refreshExpiredTiles,this._fadeDuration=s.fadeDuration,this._placementAlgorithm=s.placementAlgorithm||"default",this._isInitialLoad=!0,this._crossSourceCollisions=s.crossSourceCollisions,this._collectResourceTiming=s.collectResourceTiming,this._language=this._parseLanguage(s.language),this._worldview=s.worldview,this._renderTaskQueue=new L_,this._domRenderTaskQueue=new L_,this._controls=[],this._markers=[],this._popups=[],this._mapId=u.am(),this._locale={...Ly,...s.locale},this._clickTolerance=s.clickTolerance,this._cooperativeGestures=s.cooperativeGestures,this._performanceMetricsCollection=s.performanceMetricsCollection,this._tessellationStep=s.tessellationStep,this._containerWidth=0,this._containerHeight=0,this._showParseStatus=!0,this._precompilePrograms=s.precompilePrograms,this._averageElevationLastSampledAt=-1/0,this._averageElevationExaggeration=0,this._averageElevation=new Dy(0),this._interactionRange=[1/0,-1/0],this._visibilityHidden=0,this._useExplicitProjection=!1,this._frameId=0,this._scaleFactor=s.scaleFactor,this._requestManager=new Io(s.transformRequest,s.accessToken,s.testMode);const n=yn(s.accessToken||u.g.ACCESS_TOKEN);if(n&&"atlas"in n&&typeof n.atlas=="number"&&(this._tokenExpiration=n.atlas),this._silenceAuthErrors=!!s.testMode,this._contextCreateOptions=s.contextCreateOptions?{...s.contextCreateOptions}:{},typeof s.container=="string"){const l=document.getElementById(s.container);if(!l)throw new Error(`Container '${s.container.toString()}' not found.`);this._container=l}else{if(!(s.container instanceof HTMLElement))throw new Error("Invalid type: 'container' must be a String or HTMLElement.");this._container=s.container}if(this._container.childNodes.length>0&&u.w("The map container element should be empty, otherwise the map's interactivity will be negatively impacted. If you want to display a message when WebGL is not supported, use the Mapbox GL Supported plugin instead."),s.maxBounds&&this.setMaxBounds(s.maxBounds),this._spriteFormat="auto",u.cL(["_onWindowOnline","_onWindowResize","_onVisibilityChange","_onMapScroll","_contextLost","_contextRestored"],this),this._setupContainer(),this._setupPainter(),this.painter===void 0)throw new Error("Failed to initialize WebGL.");if(this.on("move",()=>this._update(!1)),this.on("moveend",()=>this._update(!1)),this.on("zoom",()=>this._update(!0)),this._fullscreenchangeEvent="onfullscreenchange"in document?"fullscreenchange":"webkitfullscreenchange",window.addEventListener("online",this._onWindowOnline,!1),window.addEventListener("resize",this._onWindowResize,!1),window.addEventListener("orientationchange",this._onWindowResize,!1),window.addEventListener(this._fullscreenchangeEvent,this._onWindowResize,!1),window.addEventListener("visibilitychange",this._onVisibilityChange,!1),this.handlers=new xp(this,s),this._localFontFamily=s.localFontFamily,this._localIdeographFontFamily=s.localIdeographFontFamily,this._fontstackCompositing=s.fontstackCompositing,(s.style||!s.testMode)&&this.setStyle(s.style||u.g.DEFAULT_STYLE,{config:s.config,localFontFamily:this._localFontFamily,localIdeographFontFamily:this._localIdeographFontFamily,fontstackCompositing:this._fontstackCompositing}),s.projection&&this.setProjection(s.projection),s.hash&&(this._hash=new _y(typeof s.hash=="string"&&s.hash||void 0).addTo(this)),!this._hash||!this._hash._onHashChange()){t.center==null&&t.zoom==null||(this.transform._unmodified=!1),this.jumpTo({center:s.center,zoom:s.zoom,bearing:s.bearing,pitch:s.pitch});const l=s.bounds;l&&(this.resize(),this.fitBounds(l,{...s.fitBoundsOptions,duration:0}))}this.resize(),s.attributionControl&&this.addControl(new Ou({customAttribution:s.customAttribution}
vendor: 9,354 bytes, line 3406
3406)),this._logoControl=new D_,this.addControl(this._logoControl,s.logoPosition),this.on("style.load",()=>{this.transform.unmodified&&this.jumpTo(this.style.stylesheet),this._postStyleLoadEvent(),this._postStyleWithAppearanceEvent()}),this.on("data",l=>{this._update(l.dataType==="style"),this.fire(new u.B(`${l.dataType}data`,l))}),this.on("dataloading",l=>{this.fire(new u.B(`${l.dataType}dataloading`,l))}),this._interactions=new zy(this)}_getMapId(){return this._mapId}addControl(s,t){if(t===void 0&&(t=s.getDefaultPosition?s.getDefaultPosition():"top-right"),!s||!s.onAdd)return this.fire(new u.A(new Error("Invalid argument to map.addControl(). Argument must be a control with onAdd and onRemove methods.")));const n=s.onAdd(this);this._controls.push(s);const l=this._controlPositions[t];return t.includes("bottom")?l.insertBefore(n,l.firstChild):l.appendChild(n),this}removeControl(s){if(!s||!s.onRemove)return this.fire(new u.A(new Error("Invalid argument to map.removeControl(). Argument must be a control with onAdd and onRemove methods.")));const t=this._controls.indexOf(s);return t>-1&&this._controls.splice(t,1),s.onRemove(this),this}hasControl(s){return this._controls.includes(s)}getContainer(){return this._container}getCanvasContainer(){return this._canvasContainer}getCanvas(){return this._canvas}resize(s){if(this._updateContainerDimensions(),this._containerWidth===this.transform.width&&this._containerHeight===this.transform.height)return this;this._resizeCanvas(this._containerWidth,this._containerHeight),this.transform.resize(this._containerWidth,this._containerHeight),this.painter.resize(Math.ceil(this._containerWidth),Math.ceil(this._containerHeight));const t=!this._moving;return t&&this.fire(new u.B("movestart",s)).fire(new u.B("move",s)),this.fire(new u.B("resize",s)),t&&this.fire(new u.B("moveend",s)),this}getBounds(){return this.transform.getBounds()}getMaxBounds(){return this.transform.getMaxBounds()||null}setMaxBounds(s){return this.transform.setMaxBounds(u.bF.convert(s)),this._update()}setMinZoom(s){if((s=s??-2)>=-2&&s<=this.transform.maxZoom)return this.transform.minZoom=s,this._update(),this.getZoom()<s?this.setZoom(s):this.fire(new u.B("zoomstart")).fire(new u.B("zoom")).fire(new u.B("zoomend")),this;throw new Error("minZoom must be between -2 and the current maxZoom, inclusive")}getMinZoom(){return this.transform.minZoom}setMaxZoom(s){if((s=s??22)>=this.transform.minZoom)return this.transform.maxZoom=s,this._update(),this.getZoom()>s?this.setZoom(s):this.fire(new u.B("zoomstart")).fire(new u.B("zoom")).fire(new u.B("zoomend")),this;throw new Error("maxZoom must be greater than the current minZoom")}getMaxZoom(){return this.transform.maxZoom}setMinPitch(s){if((s=s??0)<0)throw new Error("minPitch must be greater than or equal to 0");if(s>=0&&s<=this.transform.maxPitch)return this.transform.minPitch=s,this._update(),this.getPitch()<s?this.setPitch(s):this.fire(new u.B("pitchstart")).fire(new u.B("pitch")).fire(new u.B("pitchend")),this;throw new Error("minPitch must be between 0 and the current maxPitch, inclusive")}getMinPitch(){return this.transform.minPitch}setMaxPitch(s){if((s=s??85)>85)throw new Error("maxPitch must be less than or equal to 85");if(s>=this.transform.minPitch)return this.transform.maxPitch=s,this._update(),this.getPitch()>s?this.setPitch(s):this.fire(new u.B("pitchstart")).fire(new u.B("pitch")).fire(new u.B("pitchend")),this;throw new Error("maxPitch must be greater than or equal to minPitch")}getMaxPitch(){return this.transform.maxPitch}getScaleFactor(){return this._scaleFactor}setScaleFactor(s){return this._scaleFactor=s,this.painter.scaleFactor=s,this.style&&this.style._setLabelPlacementStale(),this.style._updateFilteredLayers(t=>t.type==="symbol"),this._update(!0),this}getRenderWorldCopies(){return this.transform.renderWorldCopies}setRenderWorldCopies(s){return this.transform.renderWorldCopies=s,this.transform.renderWorldCopies||this._forceMarkerAndPopupUpdate(!0),this._update()}getLanguage(){return this._language}_parseLanguage(s){return s==="auto"?navigator.language:Array.isArray(s)?s.length===0?void 0:s.map(t=>t==="auto"?navigator.language:t):s}setLanguage(s){const t=this._parseLanguage(s);if(!this.style||t===this._language)return this;this._language=t,this.style.reloadSources();for(const n of this._controls)n._setLanguage&&n._setLanguage(this._language);return this}getWorldview(){return this._worldview}setWorldview(s){return this.style&&s!==this._worldview?(this._worldview=s,this._styleDirty=!0,this.style.setWorldview(s),this):this}getProjection(){return this.transform.mercatorFromTransition?{name:"globe",center:[0,0]}:this.transform.getProjection()}_showingGlobe(){return this.transform.projection.name==="globe"}setProjection(s){return this._lazyInitEmptyStyle(),s?typeof s=="string"&&(s={name:s}):s=null,this._useExplicitProjection=!!s,this._prioritizeAndUpdateProjection(s,this.style.projection)}_updateProjectionTransition(){if(this.getProjection().name!=="globe")return;const s=this.transform,t=s.projection.name;let n;t==="globe"&&s.zoom>=u.bD?(s.setMercatorFromTransition(),n=!0):t==="mercator"&&s.zoom<u.bD&&(s.setProjection({name:"globe"}),n=!0),n&&(this.style.applyProjectionUpdate(),this.style._forceSymbolLayerUpdate(),this._update(!0))}_prioritizeAndUpdateProjection(s,t){return this._updateProjection(s||t||{name:"mercator"})}_updateProjection(s){let t;const n=this.transform.mercatorFromTransition;t=s.name==="globe"&&this.transform.zoom>=u.bD?this.transform.setMercatorFromTransition():this.transform.setProjection(s),this.style.applyProjectionUpdate();const l=this.transform.getProjection().name==="mercator"&&n!==this.transform.mercatorFromTransition;return(t||l)&&(this.painter.clearBackgroundTiles(),this.style.clearSources(),this._update(!0),this._forceMarkerAndPopupUpdate(!0)),this}project(s,t){return this.transform.locationPoint3D(u.b4.convert(s),t)}unproject(s,t){return this.transform.pointLocation3D(u.P.convert(s),t)}isMoving(){return this._moving||this.handlers&&this.handlers.isMoving()||!1}isZooming(){return this._zooming||this.handlers&&this.handlers.isZooming()||!1}isRotating(){return this._rotating||this.handlers&&this.handlers.isRotating()||!1}_isDragging(){return this.handlers&&this.handlers._isDragging()||!1}_createDelegatedListener(s,t,n){const l=d=>{let p=[];if(Array.isArray(t)){const m=t.filter(g=>this.getLayer(g));p=m.length?this.queryRenderedFeatures(d,{layers:m}):[]}else p=this.queryRenderedFeatures(d,{target:t});return p};if(s==="mouseenter"||s==="mouseover"){let d=!1;return{listener:n,targets:t,delegates:{mousemove:m=>{const g=l(m.point);g.length?d||(d=!0,n.call(this,new Uo(s,this,m.originalEvent,{features:g}))):d=!1},mouseout:()=>{d=!1}}}}if(s==="mouseleave"||s==="mouseout"){let d=!1;return{listener:n,targets:t,delegates:{mousemove:g=>{l(g.point).length?d=!0:d&&(d=!1,n.call(this,new Uo(s,this,g.originalEvent)))},mouseout:g=>{d&&(d=!1,n.call(this,new Uo(s,this,g.originalEvent)))}}}}{const d=p=>{const m=l(p.point);m.length&&(p.features=m,n.call(this,p),delete p.features)};return{listener:n,targets:t,delegates:{[s]:d}}}}on(s,t,n){if(typeof t=="function"||n===void 0)return super.on(s,t);if(typeof t=="string"&&(t=[t]),!this._areTargetsValid(t))return this;const l=this._createDelegatedListener(s,t,n);this._delegatedListeners=this._delegatedListeners||{},this._delegatedListeners[s]=this._delegatedListeners[s]||[],this._delegatedListeners[s].push(l);for(const d in l.delegates)this.on(d,l.delegates[d]);return this}once(s,t,n){if(typeof t=="function"||n===void 0)return super.once(s,t);if(typeof t=="string"&&(t=[t]),!this._areTargetsValid(t))return this;const l=this._createDelegatedListener(s,t,n);for(const d in l.delegates)this.once(d,l.delegates[d]);return this}off(s,t,n){if(typeof t=="function"||n===void 0)return super.off(s,t);if(typeof t=="string"&&(t=[t]),!this._areTargetsValid(t))return this;const l=this._delegatedListeners?this._delegatedListeners[s]:void 0;return l&&(d=>{for(let p=0;p<d.length;p++){const m=d[p];if(m.listener===n&&Fy(m.targets,t)){for(const g in m.delegates)this.off(g,m.delegates[g]);return d.splice(p,1),this}}})(l),this}queryRenderedFeatures(s,t){if(!this.style)return[];if(s===void 0||s instanceof u.P||Array.isArray(s)||t!==void 0||(t=s,s=void 0),s=s||[[0,0],[this.transform.width,this.transform.height]],!t){const p=this.style.queryRenderedFeatures(s,void 0,this.transform),m=this.style.queryRenderedFeatureset(s,void 0,this.transform);return p.concat(m)}let n=!0;if(t.target&&(n=this._isTargetValid(t.target),n&&!t.layers))return this.style.queryRenderedFeatureset(s,t,this.transform);let l=!0;if(t.layers&&Array.isArray(t.layers)){for(const p of t.layers)if(!this._isValidId(p)){l=!1;break}if(l&&!t.target)return this.style.queryRenderedFeatures(s,t,this.transform)}let d=[];return l&&(d=d.concat(this.style.queryRenderedFeatures(s,t,this.transform))),n&&(d=d.concat(this.style.queryRenderedFeatureset(s,t,this.transform))),d}querySourceFeatures(s,t){return!s||typeof s=="string"&&!this._isValidId(s)?[]:this.style.querySourceFeatures(s,t)}queryRasterValue(s,t,n){return this._isValidId(s)?this.style.queryRasterValue(s,t,n):Promise.resolve(null)}isPointOnSurface(s){const{name:t}=this.transform.projection;return t!=="globe"&&t!=="mercator"&&u.w(`${t} projection does not support isPointOnSurface, this API may behave unex
3406pectedly.`),this.transform.isPointOnSurface(u.P.convert(s))}addInteraction(s,t){return this._interactions.add(s,t),this}removeInteraction(s){return this._interactions.remove(s),this}getCooperativeGestures(){return this._cooperativeGestures}setCooperativeGestures(s){return this._cooperativeGestures=s,this}setStyle(s,t){return t={localIdeographFontFamily:this._localIdeographFontFamily,localFontFamily:this._localFontFamily,fontstackCompositing:this._fontstackCompositing,...t},this.style&&s&&t.diff!==!1&&t.localFontFamily===this._localFontFamily&&t.localIdeographFontFamily===this._localIdeographFontFamily&&t.fontstackCompositing===this._fontstackCompositing&&!t.config?(this.style._diffStyle(s,(n,l)=>{if(n){const d=typeof n=="string"?n:n instanceof Error?n.message:n.error;u.w(`Unable to perform style diff: ${d}. Rebuilding the style from scratch.`),this._updateStyle(s,t)}else l&&this._update(!0)},()=>this._postStyleLoadEvent()),this):(this._localIdeographFontFamily=t.localIdeographFontFamily,this._localFontFamily=t.localFontFamily,this._fontstackCompositing=t.fontstackCompositing,this._updateStyle(s,t))}_getUIString(s){const t=this._locale[s];if(t==null)throw new Error(`Missing UI string '${s}'`);return t}_updateStyle(s,t){if(this.style&&(this.style.setEventedParent(null),this.style._remove(),this.style=void 0),s){const n={...t};t&&t.config&&(n.initialConfig=t.config,delete n.config),this.style=new go(this,n).load(s),this.style.setEventedParent(this,{style:this.style})}return this._updateTerrain(),this}_lazyInitEmptyStyle(){this.style||(this.style=new go(this,{}),this.style.setEventedParent(this,{style:this.style}),this.style.loadEmpty())}getStyle(){if(this.style)return this.style.serialize()}isStyleLoaded(){return this.style?this.style.loaded():(u.w("There is no style added to the map."),!1)}_isValidId(s){return s==null?(this.fire(new u.A(new Error("IDs can't be empty."))),!1):u.em(s)?(this.fire(new u.A(new Error(`IDs can't contain special symbols: "${s}".`))),!1):s!=="__proto__"&&s!=="constructor"&&s!=="prototype"||(this.fire(new u.A(new Error(`IDs can't be "${s}".`))),!1)}_isTargetValid(s){return"featuresetId"in s?this._isValidId("importId"in s?s.importId:s.featuresetId):"layerId"in s&&this._isValidId(s.layerId)}_areTargetsValid(s){if(Array.isArray(s)){for(const t of s)if(!this._isValidId(t))return!1;return!0}return this._isTargetValid(s)}addSource(s,t){return this._isValidId(s)?(this._lazyInitEmptyStyle(),this.style.addSource(s,t),this._update(!0)):this}isSourceLoaded(s){return!!this._isValidId(s)&&!!this.style&&this.style._isSourceCacheLoaded(s)}areTilesLoaded(){return this.style.areTilesLoaded()}addSourceType(s,t,n){this._lazyInitEmptyStyle(),this.style.addSourceType(s,t,n)}removeSource(s){return this._isValidId(s)?(this.style.removeSource(s),this._updateTerrain(),this._update(!0)):this}getSource(s){return this._isValidId(s)?this.style.getOwnSource(s):null}addImage(s,t,{pixelRatio:n=1,sdf:l=!1,stretchX:d,stretchY:p,content:m}={}){this._lazyInitEmptyStyle();const g=u.I.from(s);if(t instanceof HTMLImageElement||ImageBitmap&&t instanceof ImageBitmap){const{width:x,height:w,data:S}=u.r.getImageData(t);this.style.addImage(g,{data:new u.t({width:x,height:w},S),pixelRatio:n,stretchX:d,stretchY:p,content:m,sdf:l,version:0,usvg:!1})}else if(t.width===void 0||t.height===void 0)this.fire(new u.A(new 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`")));else{const{width:x,height:w}=t,S=t;this.style.addImage(g,{data:new u.t({width:x,height:w},new Uint8Array(S.data)),pixelRatio:n,stretchX:d,stretchY:p,content:m,sdf:l,usvg:!1,version:0,userImage:S}),S.onAdd&&S.onAdd(this,s)}}updateImage(s,t){this._lazyInitEmptyStyle();const n=u.I.from(s),l=this.style.getImage(n);if(!l)return void this.fire(new u.A(new Error("The map has no image with that id. If you are adding a new image use `map.addImage(...)` instead.")));const d=t instanceof HTMLImageElement||ImageBitmap&&t instanceof ImageBitmap?u.r.getImageData(t):t,{width:p,height:m,data:g}=d;if(p===void 0||m===void 0)return void this.fire(new u.A(new 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(p!==(l.usvg?l.icon.usvg_tree.width:l.data.width)||m!==(l.usvg?l.icon.usvg_tree.height:l.data.height))return void this.fire(new u.A(new Error(`The width and height of the updated image (${p}, ${m})
3407                must be that same as the previous version of the image
3408                (${l.data.width}, ${l.data.height})`)));const x=!(t instanceof HTMLImageElement||ImageBitmap&&t instanceof ImageBitmap);let w=!1;l.usvg?(l.data=new u.t({width:p,height:m},new Uint8Array(g)),l.usvg=!1,l.icon=void 0,w=!0):l.data.replace(g,x),this.style.updateImage(n,l,w)}hasImage(s){return s?!!this.style&&!!this.style.getImage(u.I.from(s)):(this.fire(new u.A(new Error("Missing required image id"))),!1)}removeImage(s){this.style.removeImage(u.I.from(s))}loadImage(s,t){(async()=>{const n=await this._requestManager.transformRequest(s,u.R.Image),{data:l}=await u.q(n);return l})().then(n=>
vendor: 23,424 bytes, line 3408
3408t(null,n)).catch(t)}listImages(){return this.style.listImages().map(s=>s.name)}addModel(s,t){this._lazyInitEmptyStyle(),this.style.addModel(s,t)}hasModel(s){return s?this.style.hasModel(s):(this.fire(new u.A(new Error("Missing required model id"))),!1)}removeModel(s){this.style.removeModel(s)}listModels(){return this.style.listModels()}addLayer(s,t){return this._isValidId(s.id)?(this._lazyInitEmptyStyle(),this.style.addLayer(s,t),this._update(!0)):this}getSlot(s){const t=this.getLayer(s);return t&&t.slot||null}setSlot(s,t){return this.style.setSlot(s,t),this.style.mergeLayers(),this._update(!0)}addImport(s,t){return this._isValidId(s.id)?(this.style.addImport(s,t).catch(n=>this.fire(new u.A(new Error("Failed to add import",n)))),this):this}updateImport(s,t){return typeof t!="string"&&t.id!==s?(this.removeImport(s),this.addImport(t)):(this.style.updateImport(s,t),this._update(!0))}removeImport(s){return this.style.removeImport(s),this}moveImport(s,t){return this.style.moveImport(s,t),this._update(!0)}moveLayer(s,t){return this._isValidId(s)?(this.style.moveLayer(s,t),this._update(!0)):this}removeLayer(s){return this._isValidId(s)?(this.style.removeLayer(s),this._update(!0)):this}getLayer(s){if(!this._isValidId(s))return null;const t=this.style.getOwnLayer(s);return t?t.type==="custom"?t.implementation:t.serialize():void 0}getSlots(){return this.style.getSlots()}setLayerZoomRange(s,t,n){return this._isValidId(s)?(this.style.setLayerZoomRange(s,t,n),this._update(!0)):this}setFilter(s,t,n={}){return this._isValidId(s)?(this.style.setFilter(s,t,n),this._update(!0)):this}getFilter(s){return this._isValidId(s)?this.style.getFilter(s):null}setPaintProperty(s,t,n,l={}){return this._isValidId(s)?(this.style.setPaintProperty(s,t,n,l),this._update(!0)):this}getPaintProperty(s,t){return this._isValidId(s)?this.style.getPaintProperty(s,t):null}setLayoutProperty(s,t,n,l={}){return this._isValidId(s)?(this.style.setLayoutProperty(s,t,n,l),this._update(!0)):this}getLayoutProperty(s,t){return this._isValidId(s)?this.style.getLayoutProperty(s,t):null}getLayerProperty(s,t){return this._isValidId(s)?this.style.getLayerProperty(s,t):null}setLayerProperty(s,t,n,l={}){return this._isValidId(s)?(t==="appearances"&&this._postAddingAppearancesToStyleEvent(),this.style.setLayerProperty(s,t,n,l),this._update(!0)):this}getGlyphsUrl(){return this.style.getGlyphsUrl()}setGlyphsUrl(s){return this.style.setGlyphsUrl(s),this._update(!0)}getSchema(s){return this.style.getSchema(s)}setSchema(s,t){return this.style.setSchema(s,t),this._update(!0)}getConfig(s){return this.style.getConfig(s)}setConfig(s,t){return this.style.setConfig(s,t),this._update(!0)}getConfigProperty(s,t){return this.style.getConfigProperty(s,t)}setConfigProperty(s,t,n){return this.style.setConfigProperty(s,t,n),this._update(!0)}getFeaturesetDescriptors(s){return this.style.getFeaturesetDescriptors(s)}setLights(s){if(this._lazyInitEmptyStyle(),s&&s.length===1&&s[0].type==="flat"){const t=s[0];t.properties?this.style.setFlatLight(t.properties,t.id,{}):this.style.setFlatLight({},"flat")}else this.style.setLights(s),this.painter.terrain&&(this.painter.terrain.invalidateRenderCache=!0);return this._update(!0)}getLights(){const s=this.style.getLights()||[];return s.length===0&&s.push({id:this.style.light.id,type:"flat",properties:this.style.getFlatLight()}),s}setLight(s,t={}){return console.log("The `map.setLight` function is deprecated, prefer using `map.setLights` with `flat` light type instead."),this.setLights([{id:"flat",type:"flat",properties:s}])}getLight(){return console.log("The `map.getLight` function is deprecated, prefer using `map.getLights` instead."),this.style.getFlatLight()}setTerrain(s){return this._lazyInitEmptyStyle(),!s&&this.transform.projection.requiresDraping?this.style.setTerrainForDraping():this.style.setTerrain(s),this._averageElevationLastSampledAt=-1/0,this._update(!0)}getTerrain(){return this.style?this.style.getTerrain():null}setFog(s){return this._lazyInitEmptyStyle(),this.style.setFog(s),this._update(!0)}getFog(){return this.style?this.style.getFog():null}setSnow(s){return this._lazyInitEmptyStyle(),this.style.setSnow(s),this._update(!0)}getSnow(){return this.style?this.style.getSnow():null}setRain(s){return this._lazyInitEmptyStyle(),this.style.setRain(s),this._update(!0)}getRain(){return this.style?this.style.getRain():null}setColorTheme(s){return this._lazyInitEmptyStyle(),this.style.setColorTheme(s),this._update(!0)}setImportColorTheme(s,t){return this._lazyInitEmptyStyle(),this.style.setImportColorTheme(s,t),this._update(!0)}setCamera(s){return this.style.setCamera(s),this._triggerCameraUpdate(s)}getNearClipOffset(){return this.transform.nearClipOffset}setNearClipOffset(s){const t=this.transform.nearClipOffset!==s;return this.transform.nearClipOffset=s,this._update(t)}_triggerCameraUpdate(s){return this._update(this.transform.setOrthographicProjectionAtLowPitch(s["camera-projection"]==="orthographic"))}getCamera(){return this.style.camera}_queryFogOpacity(s){return this.style&&this.style.fog?this.style.fog.getOpacityAtLatLng(u.b4.convert(s),this.transform):0}setFeatureState(s,t){return s.source&&!this._isValidId(s.source)?this:(this.style.setFeatureState(s,t),this._update())}removeFeatureState(s,t){return s.source&&!this._isValidId(s.source)?this:(this.style.removeFeatureState(s,t),this._update())}getFeatureState(s){return s.source&&!this._isValidId(s.source)?null:this.style.getFeatureState(s)}_selectIndoorFloor(s){this.style.indoorManager&&this.style.indoorManager.selectFloor(s)}_setIndoorActiveFloorsVisibility(s){this.style.indoorManager&&this.style.indoorManager.setActiveFloorsVisibility(s)}getIndoorTileOptions(s,t){return this.style&&this.style.isIndoorEnabled()&&this.style.indoorManager?this.style.indoorManager.getIndoorTileOptions(s,t):null}_updateContainerDimensions(){if(!this._container)return;const s=this._container.getBoundingClientRect().width||400,t=this._container.getBoundingClientRect().height||300;let n,l,d,p=this._container;for(;p&&(!l||!d);){const m=window.getComputedStyle(p).transform;m&&m!=="none"&&(n=m.match(Oy)[1].split(", "),n[0]&&n[0]!=="0"&&n[0]!=="1"&&(l=n[0]),n[3]&&n[3]!=="0"&&n[3]!=="1"&&(d=n[3])),p=p.parentElement}this._containerWidth=l?Math.abs(s/l):s,this._containerHeight=d?Math.abs(t/d):t}_detectMissingCSS(){window.getComputedStyle(this._missingCSSCanary).getPropertyValue("background-color")!=="rgb(250, 128, 114)"&&u.w("This page appears to be missing CSS declarations for Mapbox GL JS, which may cause the map to display incorrectly. Please ensure your page includes mapbox-gl.css, as described in https://www.mapbox.com/mapbox-gl-js/api/.")}_setupContainer(){const s=this._container;s.classList.add("mapboxgl-map"),(this._missingCSSCanary=Nt("div","mapboxgl-canary",s)).style.visibility="hidden",this._detectMissingCSS();const t=this._canvasContainer=Nt("div","mapboxgl-canvas-container",s);this._canvas=Nt("canvas","mapboxgl-canvas",t),this._interactive&&(t.classList.add("mapboxgl-interactive"),this._canvas.setAttribute("tabindex","0")),this._canvas.addEventListener("webglcontextlost",this._contextLost,!1),this._canvas.addEventListener("webglcontextrestored",this._contextRestored,!1),this._canvas.setAttribute("aria-label",this._getUIString("Map.Title")),this._canvas.setAttribute("role","region"),this._updateContainerDimensions(),this._resizeCanvas(this._containerWidth,this._containerHeight);const n=this._controlContainer=Nt("div","mapboxgl-control-container",s),l=this._controlPositions={};["top-left","top","top-right","right","bottom-right","bottom","bottom-left","left"].forEach(d=>{l[d]=Nt("div",`mapboxgl-ctrl-${d}`,n)}),this._container.addEventListener("scroll",this._onMapScroll,!1)}_resizeCanvas(s,t){const n=u.r.devicePixelRatio||1;this._canvas.width=n*Math.ceil(s),this._canvas.height=n*Math.ceil(t),this._canvas.style.width=`${s}px`,this._canvas.style.height=`${t}px`}_addMarker(s){this._markers.push(s)}_removeMarker(s){const t=this._markers.indexOf(s);t!==-1&&this._markers.splice(t,1)}_addPopup(s){this._popups.push(s)}_removePopup(s){const t=this._popups.indexOf(s);t!==-1&&this._popups.splice(t,1)}_setupPainter(){const s={...F,failIfMajorPerformanceCaveat:this._failIfMajorPerformanceCaveat,preserveDrawingBuffer:this._preserveDrawingBuffer,antialias:this._antialias||!1},t=this._canvas.getContext("webgl2",s);t?(zr(t,!0),this.painter=new py(t,this._contextCreateOptions,this.transform,this._scaleFactor,this._worldview),this.on("data",n=>{if(n.dataType==="source"){const l=this.transform.elevation?this.transform.elevation._source():null;l&&n.sourceCacheId===l.id&&this.style&&this.style._setLabelPlacementStale(),this.style&&n.sourceCacheId&&this.style._buildingIndex.hasLayerForSourceCache(n.sourceCacheId)&&this.style._requestFullLabelPlacement(),this.painter.setTileLoadedFlag(!0)}}),u.k.testSupport(t)):this.fire(new u.A(new Error("Failed to initialize WebGL")))}_contextLost(s){s.preventDefault(),this._frame&&(this._frame.cancel(),this._frame=null),this.style&&this.style.handleContextLost(),this.fire(new u.B("webglcontextlost",{originalEvent:s}))}_contextRestored(s){this._setupPainter(),this.painter.resize(Math.ceil(this._containerWidth),Math.ceil(this._containerHeight)),this._updateTerrain(),this.style&&(this.style.clearLayers(),this.style.imageManager.destroyAtlasTextures(),this.style.imageManager.imageAtlasCache.destroyTextures(),this.style.reloadModels(),this.style.clearSources()),this._update(),this.fire(new u.B("webglcontextrestored",{originalEvent:s}))}_onMapScroll(s){if(s.target===this._container)return this._container.scrollTop=0,this._container.scrollLeft=0,!1}idle(){return!this.isMoving()&&this.loaded()}loaded(){return!this._styleDirty&&!this._sourcesDirty&&!!this.style&&this.style.loaded()}frameReady(){return this.loaded()&&!this._placementDirty}_update(s){return this.style?(this._styleDirty=this._styleDirty||s,this._sourcesDirty=!0,this.triggerRepaint(),this):this}_requestRenderFrame(s){return this._update(),this._renderTaskQueue.add(s)}_cancelRenderFrame(s){this._renderTaskQueue.remove(s)}_requestDomTask(s){!this.loaded()||this.loaded()&&!this.isMoving()?s():this._domRenderTaskQueue.add(s)}_render(s){let t;this.fire(new u.B("renderstart")),++this._frameId;const n=this.painter.context.extTimerQuery,l=u.r.now(),d=this.painter.context.gl;if(this.listens("gpu-timing-frame")&&(t=d.createQuery(),d.beginQuery(n.TIME_ELAPSED_EXT,t)),this.painter.context.setDirty(),this.painter.setBaseState(),(this.isMoving()||this.isRotating()||this.isZooming())&&(this._interactionRange[0]=Math.min(this._interactionRange[0],performance.now()),this._interactionRange[1]=Math.max(this._interactionRange[1],performance.now())),this._renderTaskQueue.run(s),this._domRenderTaskQueue.run(s),this._removed)return;this._updateProjectionTransition();const p=this._isInitialLoad?0:this._fadeDuration;if(this.style&&this._styleDirty){this._styleDirty=!1;const x=this.transform.zoom,w=this.transform.pitch,S=u.r.now(),A=new u.aa(x,{now:S,fadeDuration:p,pitch:w,transition:this.style.transition,worldview:this._worldview});this.style.update(A)}this.style&&this.style.hasFogTransition()&&(this.style._markersNeedUpdate=!0,this._sourcesDirty=!0);let m=!1;if(this.style&&this._sourcesDirty?(this._sourcesDirty=!1,this.painter._updateFog(this.style),this._updateTerrain(),m=this._updateAverageElevation(l),this.style.updateSources(this.transform),this.style.updateImageProviders(),this.isMoving()||this._forceMarkerAndPopupUpdate()):m=this._updateAverageElevation(l),this.style&&(this._placementDirty=this.style._updatePlacement(this.painter.transform,this.showCollisionBoxes,p,this._crossSourceCollisions,this.painter.replacementSource,this._placementAlgorithm)),this.style&&this.painter.render(this.style,{showTileBoundaries:this.showTileBoundaries,showParseStatus:this.showParseStatus,wireframe:{terrain:this.showTerrainWireframe,layers2D:this.showLayers2DWireframe,layers3D:this.showLayers3DWireframe},showOverdrawInspector:this._showOverdrawInspector,showQueryGeometry:!!this._showQueryGeometry,showTileAABBs:this.showTileAABBs,rotating:this.isRotating(),zooming:this.isZooming(),moving:this.isMoving(),fadeDuration:p,isInitialLoad:this._isInitialLoad,showPadding:this.showPadding,gpuTiming:!!this.listens("gpu-timing-layer"),gpuTimingDeferredRender:!!this.listens("gpu-timing-deferred-render"),speedIndexTiming:this.speedIndexTiming,paintStartTimeStamp:s}),this.fire(new u.B("render")),this.loaded()&&!this._loaded&&(this._loaded=!0,Zt.mark(Sn.load),this.fire(new u.B("load"))),this.style&&this.style.hasTransitions()&&(this._styleDirty=!0),this.style&&(this.style.snow||this.style.rain)&&(this._styleDirty=!0),this.style&&this.style.imageManager.hasPatternsInFlight()&&(this._styleDirty=!0),this.style&&!this.style.modelManager.isLoaded()&&(this._styleDirty=!0),this.style&&!this._placementDirty&&this.style._releaseSymbolFadeTiles(),t){const x=u.r.now()-l;d.endQuery(n.TIME_ELAPSED_EXT),setTimeout(()=>{const w=d.getQueryParameter(t,d.QUERY_RESULT)/1e6;d.deleteQuery(t),this.fire(new u.B("gpu-timing-frame",{cpuTime:x,gpuTime:w}))},50)}if(this.listens("gpu-timing-layer")){const x=this.painter.collectGpuTimers();setTimeout(()=>{const w=this.painter.queryGpuTimers(x);this.fire(new u.B("gpu-timing-layer",{layerTimes:w}))},50)}if(this.listens("gpu-timing-deferred-render")){const x=this.painter.collectDeferredRenderGpuQueries();setTimeout(()=>{const w=this.painter.queryGpuTimeDeferredRender(x);this.fire(new u.B("gpu-timing-deferred-render",{gpuTime:w}))},50)}const g=this._sourcesDirty||this._styleDirty||this._placementDirty||m;if(g||this._repaint)this.triggerRepaint();else{const x=this.idle();if(x&&(m=this._updateAverageElevation(l,!0)),m)this.triggerRepaint();else{if(this._triggerFrame(!1),x&&(this.fire(new u.B("idle")),this._isInitialLoad=!1,this.speedIndexTiming)){const w=this._calculateSpeedIndex();this.fire(new u.B("speedindexcompleted",{speedIndex:w})),this.speedIndexTiming=!1}x&&this.style&&this.style.handleIdle()}}!this._loaded||this._fullyLoaded||g||(this._fullyLoaded=!0,Zt.mark(Sn.fullLoad),this._performanceMetricsCollection&&Qn(this._requestManager._customAccessToken,{width:this.painter.width,height:this.painter.height,interactionRange:this._interactionRange,visibilityHidden:this._visibilityHidden,terrainEnabled:this.painter.style.hasTerrain(),fogEnabled:!!this.painter.style.getFog(),projection:this.getProjection().name,zoom:this.transform.zoom,renderer:this.painter.context.renderer,vendor:this.painter.context.vendor}),this._authenticate())}_forceMarkerAndPopupUpdate(s){for(const t of this._markers)s&&!this.getRenderWorldCopies()&&(t._lngLat=t._lngLat.wrap()),t._update();for(const t of this._popups)!s||this.getRenderWorldCopies()||t._trackPointer||(t._lngLat=t._lngLat.wrap()),t._update()}_updateAverageElevation(s,t=!1){const n=d=>(this.transform.averageElevation=d,this._update(!1),!0);if(!this.painter.averageElevationNeedsEasing())return this.transform.averageElevation!==0&&n(0);const l=this.transform.elevation&&this.transform.elevation.exaggeration()!==this._averageElevationExaggeration;if(l||(t||s-this._averageElevationLastSampledAt>500)&&!this._averageElevation.isEasing(s)){const d=this.transform.averageElevation;let p=this.transform.sampleAverageElevation();this.transform.elevation!=null&&(this._averageElevationExaggeration=this.transform.elevation.exaggeration()),isNaN(p)?p=0:this._averageElevationLastSampledAt=s;const m=Math.abs(d-p);if(m>1){if(this._isInitialLoad||l)return this._averageElevation.jumpTo(p),n(p);this._averageElevation.easeTo(p,s,300)}else if(m>1e-4)return this._averageElevation.jumpTo(p),n(p)}return!!this._averageElevation.isEasing(s)&&n(this._averageElevation.getValue(s))}_isTokenExpired(){return this._tokenExpiration!=null&&Date.now()>this._tokenExpiration}_revokeAuth(){const s=this.painter.context.gl;zr(s,!1),this._logoControl instanceof D_&&this._logoControl._updateLogo(),s&&s.clear(s.DEPTH_BUFFER_BIT|s.COLOR_BUFFER_BIT|s.STENCIL_BUFFER_BIT),this._silenceAuthErrors||this.fire(new u.A(new Error("A valid Mapbox access token is required to use Mapbox GL JS. To create an account or a new access token, visit https://account.mapbox.com/")))}_authenticate(){Jo(this._getMapId(),this._requestManager._skuToken,this._requestManager._customAccessToken,s=>{s&&(s.message!==gs&&s.status!==401||this._revokeAuth())}),this._isTokenExpired()&&this._revokeAuth(),Rn(this._getMapId(),this._requestManager._skuToken,this._requestManager._customAccessToken,()=>{})}_postStyleLoadEvent(){this.style.globalId&&Ia(this._requestManager._customAccessToken,{map:this,style:this.style.globalId,importedStyles:this.style.getImportGlobalIds()})}_postStyleWithAppearanceEvent(){this.style.globalId&&this.style.hasAppearances()&&ys(this._requestManager._customAccessToken)}_postAddingAppearancesToStyleEvent(){Ko(this._requestManager._customAccessToken)}_updateTerrain(){const s=this._isDragging();this.painter.updateTerrain(this.style,s)}_calculateSpeedIndex(){const s=this.painter.canvasCopy(),t=this.painter.getCanvasCopiesAndTimestamps();t.timeStamps.push(performance.now());const n=this.painter.context.gl,l=n.createFramebuffer();function d(p){n.framebufferTexture2D(n.FRAMEBUFFER,n.COLOR_ATTACHMENT0,n.TEXTURE_2D,p,0);const m=new Uint8Array(n.drawingBufferWidth*n.drawingBufferHeight*4);return n.readPixels(0,0,n.drawingBufferWidth,n.drawingBufferHeight,n.RGBA,n.UNSIGNED_BYTE,m),m}return n.bindFramebuffer(n.FRAMEBUFFER,l),this._canvasPixelComparison(d(s),t.canvasCopies.map(d),t.timeStamps)}_canvasPixelComparison(s,t,n){let l=n[1]-n[0];const d=s.length/4;for(let p=0;p<t.length;p++){const m=t[p];let g=0;for(let x=0;x<m.length;x+=4)m[x]===s[x]&&m[x+1]===s[x+1]&&m[x+2]===s[x+2]&&m[x+3]===s[x+3]&&(g+=1);l+=(n[p+2]-n[p+1])*(1-g/d)}return l}remove(){if(this._removed)return;this._hash&&this._hash.remove();for(const t of this._controls)t.onRemove(this);this._controls=[],this._frame&&(this._frame.cancel(),this._frame=null),this._renderTaskQueue.clear(),this._domRenderTaskQueue.clear(),this.style&&this.style.destroy(),this.painter.destroy(),this.handlers&&this.handlers.destroy(),this.handlers=void 0,this.setStyle(null),window.removeEventListener("resize",this._onWindowResize,!1),window.removeEventListener("orientationchange",this._onWindowResize,!1),window.removeEventListener(this._fullscreenchangeEvent,this._onWindowResize,!1),window.removeEventListener("online",this._onWindowOnline,!1),window.removeEventListener("visibilitychange",this._onVisibilityChange,!1);const s=this.painter.context.gl.getExtension("WEBGL_lose_context");s&&s.loseContext(),this._canvas.removeEventListener("webglcontextlost",this._contextLost,!1),this._canvas.removeEventListener("webglcontextrestored",this._contextRestored,!1),this._canvasContainer.remove(),this._controlContainer.remove(),this._missingCSSCanary.remove(),this._canvas=void 0,this._canvasContainer=void 0,this._controlContainer=void 0,this._missingCSSCanary=void 0,this._container.classList.remove("mapboxgl-map"),this._container.removeEventListener("scroll",this._onMapScroll,!1),eo.delete(this.painter.context.gl),Ao.remove(),Bs.remove(),this._removed=!0,this.fire(new u.B("remove"))}triggerRepaint(){this._triggerFrame(!0)}_triggerFrame(s){this._renderNextFrame=this._renderNextFrame||s,this.style&&!this._frame&&(this._frame=u.r.frame(t=>{const n=!!this._renderNextFrame;this._frame=null,this._renderNextFrame=null,n&&this._render(t)}))}_preloadTiles(s){const t=this.style?this.style.getSourceCaches():[];return u.dB(t,(n,l)=>n._preloadTiles(s,l),()=>{this.triggerRepaint()}),this}_onWindowOnline(){this._update()}_onWindowResize(s){this._trackResize&&this.resize({originalEvent:s})._update()}_onVisibilityChange(){document.visibilityState==="hidden"&&this._visibilityHidden++}get showTileBoundaries(){return!!this._showTileBoundaries}set showTileBoundaries(s){this._showTileBoundaries!==s&&(this._showTileBoundaries=s,this._update())}get showParseStatus(){return!!this._showParseStatus}set showParseStatus(s){this._showParseStatus!==s&&(this._showParseStatus=s,this._update())}get showTerrainWireframe(){return!!this._showTerrainWireframe}set showTerrainWireframe(s){this._showTerrainWireframe!==s&&(this._showTerrainWireframe=s,this._update())}get showLayers2DWireframe(){return!!this._showLayers2DWireframe}set showLayers2DWireframe(s){this._showLayers2DWireframe!==s&&(this._showLayers2DWireframe=s,this._update())}get showLayers3DWireframe(){return!!this._showLayers3DWireframe}set showLayers3DWireframe(s){this._showLayers3DWireframe!==s&&(this._showLayers3DWireframe=s,this._update())}get showElevationIdDebug(){return!!this.painter&&this.painter._debugParams.showElevationIdDebug}set showElevationIdDebug(s){this.painter&&this.painter._debugParams.showElevationIdDebug!==s&&(this.painter._debugParams.showElevationIdDebug=s,this.style&&s?this.style._reloadSources():this._update())}get speedIndexTiming(){return!!this._speedIndexTiming}set speedIndexTiming(s){this._speedIndexTiming!==s&&(this._speedIndexTiming=s,this._update())}get showPadding(){return!!this._showPadding}set showPadding(s){this._showPadding!==s&&(this._showPadding=s,this._update())}get showCollisionBoxes(){return!!this._showCollisionBoxes}set showCollisionBoxes(s){this._showCollisionBoxes!==s&&(this._showCollisionBoxes=s,this.style&&s?this.style._reloadSources():this._update())}get showOverdrawInspector(){return!!this._showOverdrawInspector}set showOverdrawInspector(s){this._showOverdrawInspector!==s&&(this._showOverdrawInspector=s,this._update())}get repaint(){return!!this._repaint}set repaint(s){this._repaint!==s&&(this._repaint=s,this.triggerRepaint())}get vertices(){return!!this._vertices}set vertices(s){this._vertices=s,this._update()}get showTileAABBs(){return!!this._showTileAABBs}set showTileAABBs(s){this._showTileAABBs!==s&&(this._showTileAABBs=s,s&&this._update())}_setCacheLimits(s,t){u.fh(s,t)}get version(){return St}},NavigationControl:class{constructor(s={}){this.options={...F_,...s},this._container=Nt("div","mapboxgl-ctrl mapboxgl-ctrl-group"),this._container.addEventListener("contextmenu",t=>t.preventDefault()),this.options.showZoom&&(u.cL(["_setButtonTitle","_updateZoomButtons"],this),this._zoomInButton=this._createButton("mapboxgl-ctrl-zoom-in",t=>{this._map&&this._map.zoomIn({},{originalEvent:t})}),Nt("span","mapboxgl-ctrl-icon",this._zoomInButton).setAttribute("aria-hidden","true"),this._zoomOutButton=this._createButton("mapboxgl-ctrl-zoom-out",t=>{this._map&&this._map.zoomOut({},{originalEvent:t})}),Nt("span","mapboxgl-ctrl-icon",this._zoomOutButton).setAttribute("aria-hidden","true")),this.options.showCompass&&(u.cL(["_rotateCompassArrow"],this),this._compass=this._createButton("mapboxgl-ctrl-compass",t=>{const n=this._map;n&&(this.options.visualizePitch?n.resetNorthPitch({},{originalEvent:t}):n.resetNorth({},{originalEvent:t}))}),this._compassIcon=Nt("span","mapboxgl-ctrl-icon",this._compass),this._compassIcon.setAttribute("aria-hidden","true"))}_updateZoomButtons(){const s=this._map;if(!s)return;const t=s.getZoom(),n=t===s.getMaxZoom(),l=t===s.getMinZoom();this._zoomInButton.disabled=n,this._zoomOutButton.disabled=l,this._zoomInButton.setAttribute("aria-disabled",n.toString()),this._zoomOutButton.setAttribute("aria-disabled",l.toString())}_rotateCompassArrow(){const s=this._map;if(!s)return;const t=this.options.visualizePitch?`scale(${1/Math.pow(Math.cos(s.transform.pitch*(Math.PI/180)
3408),.5)}) rotateX(${s.transform.pitch}deg) rotateZ(${s.transform.angle*(180/Math.PI)}deg)`:`rotate(${s.transform.angle*(180/Math.PI)}deg)`;s._requestDomTask(()=>{this._compassIcon&&(this._compassIcon.style.transform=t)})}onAdd(s){return this._map=s,this.options.showZoom&&(this._setButtonTitle(this._zoomInButton,"ZoomIn"),this._setButtonTitle(this._zoomOutButton,"ZoomOut"),s.on("zoom",this._updateZoomButtons),this._updateZoomButtons()),this.options.showCompass&&(this._setButtonTitle(this._compass,"ResetBearing"),this.options.visualizePitch&&s.on("pitch",this._rotateCompassArrow),s.on("rotate",this._rotateCompassArrow),this._rotateCompassArrow(),this._handler=new By(s,this._compass,this.options.visualizePitch)),this._container}onRemove(){const s=this._map;s&&(this._container.remove(),this.options.showZoom&&s.off("zoom",this._updateZoomButtons),this.options.showCompass&&(this.options.visualizePitch&&s.off("pitch",this._rotateCompassArrow),s.off("rotate",this._rotateCompassArrow),this._handler&&this._handler.off(),this._handler=void 0),this._map=void 0)}_createButton(s,t){const n=Nt("button",s,this._container);return n.type="button",n.addEventListener("click",t),n}_setButtonTitle(s,t){if(!this._map)return;const n=this._map._getUIString(`NavigationControl.${t}`);s.setAttribute("aria-label",n),s.firstElementChild&&s.firstElementChild.setAttribute("title",n)}},GeolocateControl:class extends u.E{constructor(s={}){super();const t=navigator.geolocation;this.options={geolocation:t,...Ka,...s},u.cL(["_onSuccess","_onError","_onZoom","_finish","_setupUI","_updateCamera","_updateMarker","_updateMarkerRotation","_onDeviceOrientation"],this),this._updateMarkerRotationThrottled=b_(this._updateMarkerRotation,20),this._numberOfWatches=0}onAdd(s){return this._map=s,this._container=Nt("div","mapboxgl-ctrl mapboxgl-ctrl-group"),this._checkGeolocationSupport(this._setupUI),this._container}onRemove(){this._clearRequestTimeout(),this._geolocationWatchID!==void 0&&(this.options.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("zoom",this._onZoom),this._map=void 0,this._numberOfWatches=0,this._noTimeout=!1}_checkGeolocationSupport(s){const t=(n=!!this.options.geolocation)=>{this._supportsGeolocation=n,s(n)};this._supportsGeolocation!==void 0?s(this._supportsGeolocation):navigator.permissions!==void 0?navigator.permissions.query({name:"geolocation"}).then(n=>t(n.state!=="denied")).catch(()=>t()):t()}_isOutOfMapMaxBounds(s){const t=this._map.getMaxBounds(),n=s.coords;return!!t&&(n.longitude<t.getWest()||n.longitude>t.getEast()||n.latitude<t.getSouth()||n.latitude>t.getNorth())}_setWatchState(s){this._watchState=s;const t=this._geolocateButton.classList;t.remove(...k_);for(const n of an[s])t.add(_d(n))}_setButtonTitle(s){const t=this._map._getUIString(s);this._geolocateButton.setAttribute("aria-label",t),this._geolocateButton.firstElementChild&&this._geolocateButton.firstElementChild.setAttribute("title",t)}_setErrorState(){switch(this._watchState){case"WAITING_ACTIVE":case"ACTIVE_LOCK":this._setWatchState("ACTIVE_ERROR");break;case"BACKGROUND":this._setWatchState("BACKGROUND_ERROR")}}_onSuccess(s){if(this._map){if(this._clearRequestTimeout(),this._isOutOfMapMaxBounds(s))return this._setErrorState(),this.fire(new u.B("outofmaxbounds",s)),this._updateMarker(),void this._finish();if(this._lastKnownPosition=s,this.options.trackUserLocation)switch(this._watchState){case"WAITING_ACTIVE":case"ACTIVE_LOCK":case"ACTIVE_ERROR":this._setWatchState(this.options.followUserLocation?"ACTIVE_LOCK":"BACKGROUND");break;case"BACKGROUND":case"BACKGROUND_ERROR":this._setWatchState("BACKGROUND")}this.options.showUserLocation&&this._watchState!=="OFF"&&this._updateMarker(s),this.options.followUserLocation&&(!this.options.trackUserLocation||this._watchState==="ACTIVE_LOCK")&&this._updateCamera(s),this.options.showUserLocation&&this._userLocationDotMarker.removeClassName("mapboxgl-user-location-dot-stale"),this.fire(new u.B("geolocate",{coords:s.coords,timestamp:s.timestamp,...s.toJSON?{toJSON:s.toJSON.bind(s)}:{}})),this._finish()}}_updateCamera(s){const t=new u.b4(s.coords.longitude,s.coords.latitude),n=s.coords.accuracy,l={bearing:this._map.getBearing(),...this.options.fitBoundsOptions};this._map.fitBounds(t.toBounds(n),l,{geolocateSource:!0})}_updateMarker(s){if(s){const t=new u.b4(s.coords.longitude,s.coords.latitude);this.options.showAccuracyCircle?this._accuracyCircleMarker.setLngLat(t).addTo(this._map):this._accuracyCircleMarker.remove(),this._userLocationDotMarker.setLngLat(t).addTo(this._map),this._accuracy=s.coords.accuracy,this.options.showUserLocation&&this.options.showAccuracyCircle&&this._updateCircleRadius()}else this._userLocationDotMarker.remove(),this._accuracyCircleMarker.remove()}_updateCircleRadius(){const s=this._map.transform,t=u.aL(1,s._center.lat)*s.worldSize,n=Math.ceil(2*this._accuracy*t);this._circleElement.style.width=`${n}px`,this._circleElement.style.height=`${n}px`}_onZoom(){this.options.showUserLocation&&this.options.showAccuracyCircle&&this._updateCircleRadius()}_updateMarkerRotation(){this._userLocationDotMarker&&typeof this._heading=="number"?(this._userLocationDotMarker.setRotation(this._heading),this._userLocationDotMarker.addClassName("mapboxgl-user-location-show-heading")):(this._userLocationDotMarker.removeClassName("mapboxgl-user-location-show-heading"),this._userLocationDotMarker.setRotation(0))}_onError(s){if(this._map){if(this._clearRequestTimeout(),this.options.trackUserLocation)if(s.code===1)this._setWatchState("OFF"),this._geolocateButton.disabled=!0,this._setButtonTitle("GeolocateControl.LocationNotAvailable"),this._geolocationWatchID!==void 0&&this._clearWatch();else{if(s.code===3&&this._noTimeout)return;this._setErrorState()}this._watchState!=="OFF"&&this.options.showUserLocation&&this._userLocationDotMarker.addClassName("mapboxgl-user-location-dot-stale"),this.fire(new u.B("error",{code:s.code,message:s.message,PERMISSION_DENIED:s.PERMISSION_DENIED,POSITION_UNAVAILABLE:s.POSITION_UNAVAILABLE,TIMEOUT:s.TIMEOUT})),this._finish()}}_finish(){this._timeoutId&&clearTimeout(this._timeoutId),this._timeoutId=void 0}_startRequestTimeout(){this._clearRequestTimeout();const s=this.options.positionOptions.timeout;s&&(this._requestTimeoutId=window.setTimeout(()=>{this._onError({code:3,message:"Geolocation request timed out"})},s))}_clearRequestTimeout(){this._requestTimeoutId!==void 0&&(clearTimeout(this._requestTimeoutId),this._requestTimeoutId=void 0)}_setupUI(s){this._map!==void 0&&(this._container.addEventListener("contextmenu",t=>t.preventDefault()),this._geolocateButton=Nt("button","mapboxgl-ctrl-geolocate",this._container),Nt("span","mapboxgl-ctrl-icon",this._geolocateButton).setAttribute("aria-hidden","true"),this._geolocateButton.type="button",s===!1?(u.w("Geolocation support is not available so the GeolocateControl will be disabled."),this._geolocateButton.disabled=!0,this._setButtonTitle("GeolocateControl.LocationNotAvailable")):this._setButtonTitle("GeolocateControl.FindMyLocation"),this.options.trackUserLocation&&(this._geolocateButton.setAttribute("aria-pressed","fal
3408se"),this._watchState="OFF"),this.options.showUserLocation&&(this._createUserLocationMarkers(),this.options.trackUserLocation&&(this._watchState="OFF"),this._map.on("zoom",this._onZoom)),this._geolocateButton.addEventListener("click",this.trigger.bind(this)),this._setup=!0,this.options.showButton||(this._container.style.display="none"),this.options.trackUserLocation&&this._map.on("movestart",t=>{t.geolocateSource||this._watchState!=="ACTIVE_LOCK"||t.originalEvent&&t.originalEvent.type==="resize"||(this._setWatchState("BACKGROUND"),this.fire(new u.B("trackuserlocationend")))}),this.fire(new u.B("ready")))}_onDeviceOrientation(s){this._userLocationDotMarker&&(s.webkitCompassHeading?this._heading=s.webkitCompassHeading:s.absolute===!0&&(this._heading=-1*s.alpha),this._updateMarkerRotationThrottled())}trigger(){if(!this._setup)return u.w("Geolocate control triggered before added to a map"),!1;if(this.options.trackUserLocation){switch(this._watchState){case"OFF":this._setWatchState("WAITING_ACTIVE"),this.fire(new u.B("trackuserlocationstart"));break;case"WAITING_ACTIVE":case"ACTIVE_LOCK":case"ACTIVE_ERROR":case"BACKGROUND_ERROR":this._numberOfWatches--,this._noTimeout=!1,this._setWatchState("OFF"),this.fire(new u.B("trackuserlocationend"));break;case"BACKGROUND":this._setWatchState("ACTIVE_LOCK"),this._lastKnownPosition&&this._updateCamera(this._lastKnownPosition),this.fire(new u.B("trackuserlocationstart"))}if(this._watchState==="OFF"&&this._geolocationWatchID!==void 0)this._clearWatch();else if(this._geolocationWatchID===void 0){let s;this._geolocateButton.classList.add(_d("waiting")),this._geolocateButton.setAttribute("aria-pressed","true"),this._numberOfWatches++,this._numberOfWatches>1?(s={maximumAge:6e5,timeout:0},this._noTimeout=!0):(s=this.options.positionOptions,this._noTimeout=!1),this._geolocationWatchID=this.options.geolocation.watchPosition(this._onSuccess,this._onError,s),this._startRequestTimeout(),this.options.showUserHeading&&this._addDeviceOrientationListener()}}else this.options.geolocation.getCurrentPosition(this._onSuccess,this._onError,this.options.positionOptions),this._startRequestTimeout(),this._timeoutId=window.setTimeout(this._finish,1e4);return!0}setFollowUserLocation(s){return this.options.followUserLocation=s??Ka.followUserLocation,this.options.trackUserLocation&&this._watchState!=="OFF"&&(this.options.followUserLocation?this._watchState!=="BACKGROUND"&&this._watchState!=="BACKGROUND_ERROR"||(this._setWatchState("ACTIVE_LOCK"),this._lastKnownPosition&&this._updateCamera(this._lastKnownPosition),this.fire(new u.B("trackuserlocationstart"))):this._watchState!=="ACTIVE_LOCK"&&this._watchState!=="ACTIVE_ERROR"||(this._setWatchState("BACKGROUND"),this.fire(new u.B("trackuserlocationend")))),this}setShowAccuracyCircle(s){if(this.options.showAccuracyCircle=s??Ka.showAccuracyCircle,!this._accuracyCircleMarker)return this;if(this.options.showAccuracyCircle){if(this.options.showUserLocation&&this._lastKnownPosition){const{longitude:t,latitude:n,accuracy:l}=this._lastKnownPosition.coords;this._accuracy=l,this._accuracyCircleMarker.setLngLat(new u.b4(t,n)).addTo(this._map),this._updateCircleRadius()}}else this._accuracyCircleMarker.remove();return this}setShowUserHeading(s){return this.options.showUserHeading=s??Ka.showUserHeading,this._setup?(this.options.showUserHeading?this._geolocationWatchID!==void 0&&this._addDeviceOrientationListener():(this._removeDeviceOrientationListener(),this._heading=void 0,this._userLocationDotMarker&&this._updateMarkerRotation()),this):this}setFitBoundsOptions(s){return this.options.fitBoundsOptions=s??Ka.fitBoundsOptions,this}setShowUserLocation(s){return this.options.showUserLocation=s??Ka.showUserLocation,this._setup?(this.options.showUserLocation?(this._userLocationDotMarker||(this._createUserLocationMarkers(),this._map.on("zoom",this._onZoom)),!this._lastKnownPosition||this._watchState!==void 0&&this._watchState==="OFF"||this._updateMarker(this._lastKnownPosition)):(this._userLocationDotMarker&&this._userLocationDotMarker.remove(),this._accuracyCircleMarker&&this._accuracyCircleMarker.remove()),this):this}_addDeviceOrientationListener(){const s=()=>{const t="ondeviceorientationabsolute"in window?"deviceorientationabsolute":"deviceorientation";window.addEventListener(t,this._onDeviceOrientation)};typeof DeviceOrientationEvent.requestPermission=="function"?DeviceOrientationEvent.requestPermission().then(t=>{t==="granted"&&s()}).catch(console.error):s()}_removeDeviceOrientationListener(){window.removeEventListener("deviceorientation",this._onDeviceOrientation),window.removeEventListener("deviceorientationabsolute",this._onDeviceOrientation)}_createUserLocationMarkers(){this._dotElement=Nt("div","mapboxgl-user-location"),this._dotElement.appendChild(Nt("div","mapboxgl-user-location-dot")),this._dotElement.appendChild(Nt("div","mapboxgl-user-location-heading")),this._userLocationDotMarker=new Ol({element:this._dotElement,rotationAlignment:"map",pitchAlignment:"map"}),this._circleElement=Nt("div","mapboxgl-user-location-accuracy-circle"),this._accuracyCircleMarker=new Ol({element:this._circleElement,pitchAlignment:"map"})}_clearWatch(){this._clearRequestTimeout(),this.options.geolocation.clearWatch(this._geolocationWatchID),this._removeDeviceOrientationListener(),this._geolocationWatchID=void 0,this._geolocateButton.classList.remove(_d("waiting")),this._geolocateButton.setAttribute("aria-pressed","fal
3408se"),this.options.showUserLocation&&this._updateMarker(null)}},AttributionControl:Ou,ScaleControl:class{constructor(s={}){this.options={...Mr,...s},u.cL(["_update","_setScale","setUnit"],this)}getDefaultPosition(){return"bottom-left"}_update(){const s=this.options.maxWidth||100,t=this._map,n=t._containerHeight/2,l=t._containerWidth/2-s/2,d=t.unproject([l,n]),p=t.unproject([l+s,n]),m=d.distanceTo(p);if(this.options.unit==="imperial"){const g=3.2808*m;g>5280?this._setScale(s,g/5280,"mile"):this._setScale(s,g,"foot")}else this.options.unit==="nautical"?this._setScale(s,m/1852,"nautical-mile"):m>=1e3?this._setScale(s,m/1e3,"kilometer"):this._setScale(s,m,"meter")}_setScale(s,t,n){this._map._requestDomTask(()=>{const l=(function(p){const m=Math.pow(10,`${Math.floor(p)}`.length-1);let g=p/m;return g=g>=10?10:g>=5?5:g>=3?3:g>=2?2:g>=1?1:(function(x){const w=Math.pow(10,Math.ceil(-Math.log(x)/Math.LN10));return Math.round(x*w)/w})(g),m*g})(t),d=l/t;this._container.innerHTML=n!=="nautical-mile"?new Intl.NumberFormat(this._language,{style:"unit",unitDisplay:"short",unit:n}).format(l):`${l}&nbsp;${Ny[n]}`,this._container.style.width=s*d+"px"})}onAdd(s){return this._map=s,this._language=s.getLanguage(),this._container=Nt("div","mapboxgl-ctrl mapboxgl-ctrl-scale",s.getContainer()),this._container.dir="auto",this._map.on("move",this._update),this._update(),this._container}onRemove(){this._container.remove(),this._map.off("move",this._update),this._map=void 0}_setLanguage(s){this._language=s,this._update()}setUnit(s){this.options.unit=s,this._update()}},FullscreenControl:class{constructor(s={}){this._fullscreen=!1,s&&s.container&&(s.container instanceof HTMLElement?this._container=s.container:u.w("Full screen control 'container' must be a DOM element.")),u.cL(["_onClickFullscreen","_changeIcon"],this),"onfullscreenchange"in document?this._fullscreenchange="fullscreenchange":"onwebkitfullscreenchange"in document&&(this._fullscreenchange="webkitfullscreenchange")}onAdd(s){return this._map=s,this._container||(this._container=this._map.getContainer()),this._controlContainer=Nt("div","mapboxgl-ctrl mapboxgl-ctrl-group"),this._checkFullscreenSupport()?this._setupUI():(this._controlContainer.style.display="none",u.w("This device does not support fullscreen mode.")),this._controlContainer}onRemove(){this._controlContainer.remove(),this._map=null,document.removeEventListener(this._fullscreenchange,this._changeIcon)}_checkFullscreenSupport(){return!(!document.fullscreenEnabled&&!document.webkitFullscreenEnabled)}_setupUI(){const s=this._fullscreenButton=Nt("button","mapboxgl-ctrl-fullscreen",this._controlContainer);Nt("span","mapboxgl-ctrl-icon",s).setAttribute("aria-hidden","true"),s.type="button",this._updateTitle(),this._fullscreenButton.addEventListener("click",this._onClickFullscreen),document.addEventListener(this._fullscreenchange,this._changeIcon)}_updateTitle(){const s=this._getTitle();this._fullscreenButton.setAttribute("aria-label",s),this._fullscreenButton.firstElementChild&&this._fullscreenButton.firstElementChild.setAttribute("title",s)}_getTitle(){return this._map._getUIString(this._isFullscreen()?"FullscreenControl.Exit":"FullscreenControl.Enter")}_isFullscreen(){return this._fullscreen}_changeIcon(){(document.fullscreenElement||document.webkitFullscreenElement)===this._container!==this._fullscreen&&(this._fullscreen=!this._fullscreen,this._fullscreenButton.classList.toggle("mapboxgl-ctrl-shrink"),this._fullscreenButton.classList.toggle("mapboxgl-ctrl-fullscreen"),this._updateTitle())}_onClickFullscreen(){this._isFullscreen()?document.exitFullscreen?document.exitFullscreen():document.webkitCancelFullScreen&&document.webkitCancelFullScreen():this._container.requestFullscreen?this._container.requestFullscreen():this._container.webkitRequestFullscreen&&this._container.webkitRequestFullscreen()}},IndoorControl:class{constructor(){u.cL(["_onIndoorUpdate","_onStyleData","_scrollUp","_scrollDown","_toggleIndoor"],this),this._visibleFloorStart=0,this._lastSelectedFloorId=null}onAdd(s){return this._map=s,this._container=Nt("div","mapboxgl-ctrl mapboxgl-ctrl-group"),this._container.style.display="none",this._map.on("styledata",this._onStyleData),this._map.on("idle",this._onStyleData),this._updateConnection(),this._container}_onStyleData(){this._updateConnection()}_updateConnection(){if(this._map&&this._map.style&&this._map.style.indoorManager){const s=this._map.style.indoorManager;s.off("selector-update",this._onIndoorUpdate),s.on("selector-update",this._onIndoorUpdate),this._onIndoorUpdate(s.getControlState()),this._map.off("idle",this._onStyleData)}}_createButton(s,t){const n=Nt("button",s,this._container);return n.type="button",n.addEventListener("click",t),n}_setButtonTitle(s,t){s.setAttribute("aria-label",t),s.textContent=t}onRemove(){this._container&&this._container.remove(),this._map&&(this._map.off("styledata",this._onStyleData),this._map.off("idle",this._onStyleData),this._map.style&&this._map.style.indoorManager&&this._map.style.indoorManager.off("selector-update",this._onIndoorUpdate),this._map=null)}getDefaultPosition(){return"top-right"}_onIndoorUpdate(s){if(!s||!s.floors||s.floors.length===0)return this._model=s,void(this._container.style.display="none");const t=this._model;this._model=s,this._container.style.display="inline-block";const n=!t||t.floors.length!==s.floors.length||t.floors.some((l,d)=>l.id!==s.floors[d].id);if(n&&(this._visibleFloorStart=0,this._lastSelectedFloorId=null),s.selectedFloorId){if(s.selectedFloorId!==this._lastSelectedFloorId||n){const l=s.floors.findIndex(d=>d.id===s.selectedFloorId);if(l!==-1){const d=s.floors.length;let p,m;d<=5?(p=0,m=d-1):this._visibleFloorStart===0?(p=0,m=3):this._visibleFloorStart>=d-3?(p=d-3-1,m=d-1):(p=this._visibleFloorStart,m=this._visibleFloorStart+3-1),l<p?this._visibleFloorStart=l:l>m&&(this._visibleFloorStart=l-2)}}this._lastSelectedFloorId=s.selectedFloorId}this._render()}
vendor: 8,749 bytes, line 3408
3408_render(){if(!this._container||!this._model||!this._model.floors)return;this._container.innerHTML="";const s=this._createButton("mapboxgl-ctrl-indoor-toggle",this._toggleIndoor);Nt("span","mapboxgl-ctrl-icon",s).setAttribute("aria-hidden","true"),this._model.activeFloorsVisible||s.classList.add("mapboxgl-ctrl-level-button-selected"),this._container.appendChild(s);const t=this._model.floors,n=t.length;if(n<=5)return void t.forEach(m=>this._createFloorButton(m));const l=this._visibleFloorStart===0,d=this._visibleFloorStart>=n-3;if(l)this._createFloorButton(t[0]);else{const m=this._createButton("mapboxgl-ctrl-arrow-up",this._scrollUp);Nt("span","mapboxgl-ctrl-icon",m).setAttribute("aria-hidden","true"),this._container.appendChild(m)}let p=[];if(p=l?t.slice(1,4):d?t.slice(this._visibleFloorStart-1,this._visibleFloorStart+3-1):t.slice(this._visibleFloorStart,this._visibleFloorStart+3),p.forEach(m=>this._createFloorButton(m)),d)this._createFloorButton(t[n-1]);else{const m=this._createButton("mapboxgl-ctrl-arrow-down",this._scrollDown);Nt("span","mapboxgl-ctrl-icon",m).setAttribute("aria-hidden","true"),this._container.appendChild(m)}}_createFloorButton(s){const t=this._createButton("mapboxgl-ctrl-level-button",()=>{const p=s.id;this._model&&this._model.selectedFloorId===p&&this._model.activeFloorsVisible||this._map&&(this._model&&!this._model.activeFloorsVisible&&this._map.style&&this._map.style.indoorManager&&this._map.style.indoorManager.setActiveFloorsVisibility(!0),this._map._selectIndoorFloor(p))}),n=(s.name||"").trim(),l=s.zIndex.toString(),d=n?Array.from(n).slice(0,3).join(""):l;this._setButtonTitle(t,d),this._model&&this._model.activeFloorsVisible&&s.id===this._model.selectedFloorId&&t.classList.add("mapboxgl-ctrl-level-button-selected"),this._container&&this._container.appendChild(t)}_toggleIndoor(){this._map&&this._map.style&&this._map.style.indoorManager&&this._model&&this._model.activeFloorsVisible&&this._map.style.indoorManager.setActiveFloorsVisibility(!1)}_scrollUp(){if(this._visibleFloorStart>0){this._visibleFloorStart--,this._visibleFloorStart===1&&(this._visibleFloorStart=0);const s=this._model&&this._model.floors||[];if(s.length>3){const t=s.length-3;this._visibleFloorStart===t-1&&(this._visibleFloorStart=t-2)}this._render()}}_scrollDown(){if(this._model&&this._model.floors){const s=this._model.floors.length-3;this._visibleFloorStart<s&&(this._visibleFloorStart++,this._visibleFloorStart===1&&(this._visibleFloorStart=2),this._visibleFloorStart===s-1&&(this._visibleFloorStart=s),this._visibleFloorStart>s&&(this._visibleFloorStart=s),this._render())}}},Popup:class extends u.E{constructor(s){super(),this.options=Object.assign(Object.create(Vy),s),this._altitude=this.options.altitude,u.cL(["_update","_onClose","remove","_onMouseEvent"],this),this._classList=new Set(s&&s.className?s.className.trim().split(ku):[])}addTo(s){return this._map&&this.remove(),this._map=s,this.options.closeOnClick&&s.on("preclick",this._onClose),this.options.closeOnMove&&s.on("move",this._onClose),s.on("remove",this.remove),this._update(),s._addPopup(this),this._focusFirstElement(),this._trackPointer?(s.on("mousemove",this._onMouseEvent),s.on("mouseup",this._onMouseEvent),s._canvasContainer.classList.add("mapboxgl-track-pointer")):s.on("move",this._update),this.fire(new u.B("open")),this}isOpen(){return!!this._map}remove(){this._content&&this._content.remove(),this._container&&(this._container.remove(),this._container=void 0);const s=this._map;return s&&(s.off("move",this._update),s.off("move",this._onClose),s.off("preclick",this._onClose),s.off("click",this._onClose),s.off("remove",this.remove),s.off("mousemove",this._onMouseEvent),s.off("mouseup",this._onMouseEvent),s.off("drag",this._onMouseEvent),s._canvasContainer&&s._canvasContainer.classList.remove("mapboxgl-track-pointer"),s._removePopup(this),this._map=void 0),this.fire(new u.B("close")),this}getLngLat(){return this._lngLat}setLngLat(s){this._lngLat=u.b4.convert(s),this._pos=null,this._trackPointer=!1,this._update();const t=this._map;return t&&(t.on("move",this._update),t.off("mousemove",this._onMouseEvent),t._canvasContainer.classList.remove("mapboxgl-track-pointer")),this}getAltitude(){return this._altitude}setAltitude(s){return this._altitude=s,this._update(),this}trackPointer(){this._trackPointer=!0,this._pos=null,this._update();const s=this._map;return s&&(s.off("move",this._update),s.on("mousemove",this._onMouseEvent),s.on("drag",this._onMouseEvent),s._canvasContainer.classList.add("mapboxgl-track-pointer")),this}getElement(){return this._container}setText(s){return this.setDOMContent(document.createTextNode(s))}setHTML(s){const t=document.createDocumentFragment(),n=document.createElement("body");let l;for(n.innerHTML=s;l=n.firstChild,l;)t.appendChild(l);return this.setDOMContent(t)}getMaxWidth(){return this._container&&this._container.style.maxWidth}setMaxWidth(s){return this.options.maxWidth=s,this._update(),this}setDOMContent(s){let t=this._content;if(t)for(;t.hasChildNodes();)t.firstChild&&t.removeChild(t.firstChild);else t=this._content=Nt("div","mapboxgl-popup-content",this._container||void 0);if(t.appendChild(s),this.options.closeButton){const n=this._closeButton=Nt("button","mapboxgl-popup-close-button",t);n.type="button",n.setAttribute("aria-label","Close popup"),n.innerHTML='<span aria-hidden="true">&#215;</span>',n.addEventListener("click",this._onClose)}return this._update(),this._focusFirstElement(),this}addClassName(s){return this._classList.add(s),this._updateClassList(),this}removeClassName(s){return this._classList.delete(s),this._updateClassList(),this}setOffset(s){return this.options.offset=s,this._update(),this}toggleClassName(s){let t;return this._classList.delete(s)?t=!1:(this._classList.add(s),t=!0),this._updateClassList(),t}_onMouseEvent(s){this._update(s.point)}_getAnchor(s){if(this.options.anchor)return this.options.anchor;const t=this._map,n=this._container,l=this._pos;if(!t||!n||!l)return"bottom";const d=n.offsetWidth,p=n.offsetHeight,m=l.x<d/2,g=l.x>t.transform.width-d/2;if(l.y+s<p)return m?"top-left":g?"top-right":"top";if(l.y>t.transform.height-p){if(m)return"bottom-left";if(g)return"bottom-right"}return m?"left":g?"right":"bottom"}_updateClassList(){const s=this._container;if(!s)return;const t=[...this._classList];t.push("mapboxgl-popup"),this._anchor&&t.push(`mapboxgl-popup-anchor-${this._anchor}`),this._trackPointer&&t.push("mapboxgl-popup-track-pointer"),s.className=t.join(" ")}_update(s){const t=this._map,n=this._content;if(!t||!this._lngLat&&!this._trackPointer||!n)return;let l=this._container;if(l||(l=this._container=Nt("div","mapboxgl-popup",t.getContainer()),this._tip=Nt("div","mapboxgl-popup-tip",l),l.appendChild(n)),this.options.maxWidth&&l.style.maxWidth!==this.options.maxWidth&&(l.style.maxWidth=this.options.maxWidth),t.transform.renderWorldCopies&&!this._trackPointer&&(this._lngLat=Xa(this._lngLat,this._pos,t.transform)),!this._trackPointer||s){const d=this._pos=this._trackPointer&&s instanceof u.P?s:t.project(this._lngLat,this._altitude),p=gd(this.options.offset),m=this._anchor=this._getAnchor(p.y),g=gd(this.options.offset,m),x=d.add(g).round();t._requestDomTask(()=>{this._container&&m&&(this._container.style.transform=`${Ya[m]} translate(${x.x}px,${x.y}px)`)})}if(!this._marker&&t._showingGlobe()){const d=u.fi(t.transform,this._lngLat)?0:1;this._setOpacity(d)}this._updateClassList()}_focusFirstElement(){if(!this.options.focusAfterOpen||!this._container)return;const s=this._container.querySelector(Uy);s&&s.focus()}_onClose(){this.remove()}_setOpacity(s){this._container&&(this._container.style.opacity=`${s}`),this._content&&(this._content.style.pointerEvents=s?"auto":"none")}},Marker:Ol,Style:go,LngLat:u.b4,LngLatBounds:u.bF,Point:u.P,MercatorCoordinate:u.ac,FreeCameraOptions:fi,Evented:u.E,config:u.g,prewarm:function(){Rh().acquire(Ju)},clearPrewarmedResources:function(){const s=Sl;s&&(s.isPreloaded()&&s.numActive()===1?(s.release(Ju),Sl=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()"))},get accessToken(){return u.g.ACCESS_TOKEN},set accessToken(s){u.fx(s)},get baseApiUrl(){return u.g.API_URL},set baseApiUrl(s){u.fw(s)},get workerCount(){return ca.workerCount},set workerCount(s){(function(t){ca.workerCount=t})(s)},get maxParallelImageRequests(){return u.g.MAX_PARALLEL_IMAGE_REQUESTS},set maxParallelImageRequests(s){u.fv(s)},clearStorage(s){u.fu(s)},get workerUrl(){return Lo.workerUrl},set workerUrl(s){Lo.workerUrl=s},get workerClass(){return Lo.workerClass},set workerClass(s){Lo.workerClass=s},get dracoUrl(){return u.ft()}
3408,set dracoUrl(s){u.fs(s)},get meshoptUrl(){return u.fr()},set meshoptUrl(s){u.fq(s)},get buildingGenUrl(){return u.fp()},set buildingGenUrl(s){u.fo(s)},setNow:u.r.setNow,restoreNow:u.r.restoreNow}});var cn=br;return cn}))})(jg)),jg.exports}var FS=zS();const _s=pS(FS),OS={key:0,class:"rounded-lg border border-amber-200 bg-amber-50 px-4 py-3 text-sm text-amber-900"},kS={key:1,class:"rounded-lg border border-gray-200 bg-gray-50 px-4 py-8 text-center text-sm text-gray-600"},BS=Jp({__name:"ScanLocationMap",props:{points:{},token:{}},setup(Xr){const Jt=Xr,vi=ei(null);let ri=null,br=[];const Cn=()=>{br.forEach(F=>F.remove()),br=[]},cn=()=>{if(!ri)return;Cn();const F=new _s.LngLatBounds;for(const Yi of Jt.points){const Ht=Yi.color||"#2563eb",Wt=new _s.Marker({color:Ht}).setLngLat([Yi.longitude,Yi.latitude]).setPopup(new _s.Popup({offset:16}).setText(Yi.label||"Scan")).addTo(ri);br.push(Wt),F.extend([Yi.longitude,Yi.latitude])}Jt.points.length===1?ri.flyTo({center:[Jt.points[0].longitude,Jt.points[0].latitude],zoom:13}):Jt.points.length>1&&ri.fitBounds(F,{padding:48,maxZoom:14})},u=()=>{!Jt.token||!vi.value||Jt.points.length===0||(ri=new _s.Map({accessToken:Jt.token,container:vi.value,style:"mapbox://styles/mapbox/streets-v12",center:[Jt.points[0].longitude,Jt.points[0].latitude],zoom:12}),ri.addControl(new _s.NavigationControl({showCompass:!1}),"top-right"),ri.on("load",cn))};return iv(()=>{u()}),Gg(()=>[Jt.token,Jt.points.map(F=>F.id).join("|")],()=>{if(!ri){u();return}cn()}),$g(()=>{Cn(),ri?.remove(),ri=null}),(F,Yi)=>(At(),It("div",null,[Xr.token?Xr.points.length===0?(At(),It("div",kS," No scan locations with GPS yet. ")):(At(),It("div",{key:2,ref_key:"mapEl",ref:vi,class:"w-full h-72 rounded-lg overflow-hidden border border-gray-200"},null,512)):(At(),It("div",OS,[...Yi[0]||(Yi[0]=[Ar(" Mapbox is not configured. Set ",-1),je("code",{class:"text-xs"},"NUXT_PUBLIC_MAPBOX_TOKEN",-1),Ar(" to show scan locations on a map. ",-1)])]))]))}}),NS={key:0,class:"rounded-lg border border-amber-200 bg-amber-50 px-4 py-3 text-sm text-amber-900"},VS={key:1,class:"rounded-lg border border-gray-200 bg-gray-50 px-4 py-8 text-center text-sm text-gray-600"},zd="walk-route",Qx="walk-route-line",I1=Jp({__name:"WalkRouteMap",props:{coordinates:{},token:{},lineColor:{}},setup(Xr){const Jt=Xr,vi=ei(null);let ri=null,br=null,Cn=null;const cn=()=>{br?.remove(),Cn?.remove(),br=null,Cn=null},u=()=>{cn(),ri?.getLayer(Qx)&&ri.removeLayer(Qx),ri?.getSource(zd)&&ri.removeSource(zd),ri?.remove(),ri=null},F=()=>{if(!ri||Jt.coordinates.length<2)return;const Ht=Jt.coordinates.map(Nt=>[Nt.longitude,Nt.latitude]),Wt={type:"Feature",properties:{},geometry:{type:"LineString",coordinates:Ht}};ri.getSource(zd)?ri.getSource(zd).setData(Wt):(ri.addSource(zd,{type:"geojson",data:Wt}),ri.addLayer({id:Qx,type:"line",source:zd,layout:{"line-join":"round","line-cap":"round"},paint:{"line-color":Jt.lineColor||"#059669","line-width":4}})),cn();const St=Jt.coordinates[0],Ti=Jt.coordinates[Jt.coordinates.length-1];br=new _s.Marker({color:"#059669"}).setLngLat([St.longitude,St.latitude]).setPopup(new _s.Popup({offset:16}).setText("Start")).addTo(ri),Cn=new _s.Marker({color:"#dc2626"}).setLngLat([Ti.longitude,Ti.latitude]).setPopup(new _s.Popup({offset:16}).setText("End")).addTo(ri);const mn=new _s.LngLatBounds;for(const Nt of Jt.coordinates)mn.extend([Nt.longitude,Nt.latitude]);ri.fitBounds(mn,{padding:48,maxZoom:15}),ri.resize()},Yi=async()=>{if(!(!Jt.token||Jt.coordinates.length<2)&&(await P1(),!!vi.value)){if(ri){F();return}ri=new _s.Map({accessToken:Jt.token,container:vi.value,style:"mapbox://styles/mapbox/streets-v12",center:[Jt.coordinates[0].longitude,Jt.coordinates[0].latitude],zoom:13}),ri.addControl(new _s.NavigationControl({showCompass:!1}),"top-right"),ri.on("load",()=>{F()})}};return iv(()=>{Yi()}),Gg(()=>[Jt.token||"",Jt.coordinates.length,Jt.coordinates.map(Ht=>`${Ht.latitude.toFixed(5)},${Ht.longitude.toFixed(5)}`).join("|")].join("::"),async()=>{if(!Jt.token||Jt.coordinates.length<2){u();return}await Yi(),ri?.isStyleLoaded()?F():ri?.once("load",F)}),$g(()=>{u()}),(Ht,Wt)=>(At(),It("div",null,[Xr.token?Xr.coordinates.length<2?(At(),It("div",VS,Dt(Xr.coordinates.length===1?"Only one GPS point recorded for this walk — keep walking to build a route.":"No GPS route points recorded for this walk yet."),1)):xi("",!0):(At(),It("div",NS,[...Wt[0]||(Wt[0]=[Ar(" Mapbox is not configured. Set ",-1),je("code",{class:"text-xs"},"NUXT_PUBLIC_MAPBOX_TOKEN",-1),Ar(" to show walk routes. ",-1)])])),Os(je("div",{ref_key:"mapEl",ref:vi,class:"w-full h-72 rounded-lg overflow-hidden border border-gray-200"},null,512),[[M1,Xr.token&&Xr.coordinates.length>=2]])]))}}),US={key:0,class:"text-gray-500"},jS=["aria-expanded","aria-label"],GS={key:0,class:"px-3 py-4 text-xs text-amber-800 bg-amber-50"},$S={class:"border-t border-gray-100 px-3 py-2 text-xs text-gray-600"},qS=Jp({__name:"CoordMapHover",props:{latitude:{},longitude:{},token:{},color:{}},setup(Xr){const Jt=Xr,vi=ei(!1),ri=ei(null);let br=null,Cn=null,cn=null;const u=Zu(()=>Jt.latitude==null||Jt.longitude==null?"No GPS":`${Number(Jt.latitude).toFixed(4)}, ${Number(Jt.longitude).toFixed(4)}`),F=()=>{cn&&(clearTimeout(cn),cn=null)},Yi=()=>{Cn?.remove(),Cn=null,br?.remove(),br=null},Ht=async()=>
3408{if(!Jt.token||Jt.latitude==null||Jt.longitude==null||(await P1(),!ri.value))return;const mn=Number(Jt.longitude),Nt=Number(Jt.latitude);if(br){br.setCenter([mn,Nt]),Cn?.setLngLat([mn,Nt]),br.resize();return}br=new _s.Map({accessToken:Jt.token,container:ri.value,style:"mapbox://styles/mapbox/streets-v12",center:[mn,Nt],zoom:14,interactive:!1,attributionControl:!1}),Cn=new _s.Marker({color:Jt.color||"#2563eb"}).setLngLat([mn,Nt]).addTo(br),br.on("load",()=>br?.resize())},Wt=async()=>{F(),vi.value=!0,await Ht()},St=()=>{F(),cn=setTimeout(()=>{vi.value=!1},180)},Ti=async()=>{if(vi.value){vi.value=!1;return}await Wt()};return Gg(()=>[Jt.latitude,Jt.longitude,Jt.token],()=>{vi.value&&Ht()}),$g(()=>{F(),Yi()}),(mn,Nt)=>Xr.latitude==null||Xr.longitude==null?(At(),It("span",US," No GPS ")):(At(),It("span",{key:1,class:"relative inline-flex",onMouseenter:Wt,onMouseleave:St,onFocusin:Wt,onFocusout:St},[je("button",{type:"button",class:"text-blue-600 hover:text-blue-800 underline decoration-dotted underline-offset-2 font-medium tabular-nums","aria-expanded":vi.value,"aria-label":`Show map for ${Oe(u)}`,onClick:Fd(Ti,["prevent"])},Dt(Oe(u)),9,jS),Os(je("div",{class:"absolute right-0 top-full z-40 mt-2 w-64 overflow-hidden rounded-xl border border-gray-200 bg-white shadow-xl",onMouseenter:F,onMouseleave:St},[Xr.token?(At(),It("div",{key:1,ref_key:"mapEl",ref:ri,class:"h-40 w-full bg-gray-100"},null,512)):(At(),It("div",GS," Mapbox token not configured. ")),je("div",$S,Dt(Oe(u)),1)],544),[[M1,vi.value]])],32))}}),HS={class:"min-h-screen bg-gray-50 py-8"},ZS={class:"max-w-7xl mx-auto px-4 sm:px-6 lg:px-8"},WS={key:0,class:"mb-6"},XS={key:1,class:"text-center py-12"},YS={key:2,class:"bg-red-50 border border-red-200 rounded-lg p-6"},KS={class:"text-red-600"},JS={key:3,class:"max-w-3xl mx-auto"},QS={class:"bg-white rounded-2xl shadow-lg overflow-hidden"},eE={class:"h-56 bg-gray-100"},tE=["src","alt"],iE={key:1,class:"w-full h-full flex items-center justify-center text-7xl"},rE={class:"p-8"},nE={class:"text-3xl font-bold text-gray-900 mb-2"},oE={key:0,class:"text-lg text-gray-600 mb-6"},sE={class:"grid sm:grid-cols-2 gap-4 mb-6"},aE={key:0,class:"bg-gray-50 rounded-lg p-4"},lE={class:"font-medium text-gray-900 capitalize"},cE={key:1,class:"bg-gray-50 rounded-lg p-4"},uE={class:"font-medium text-gray-900"},hE={key:2,class:"bg-gray-50 rounded-lg p-4 sm:col-span-2"},dE={class:"font-mono text-sm text-gray-900"},fE={key:1,class:"mb-6"},pE={class:"text-gray-800 whitespace-pre-wrap"},mE={key:2,class:"mb-4 rounded-lg border border-green-200 bg-green-50 px-4 py-3 text-sm text-green-800"},_E={key:3,class:"mb-4 rounded-lg border border-red-200 bg-red-50 px-4 py-3 text-sm text-red-700"},gE={key:4,class:"mb-4 rounded-lg border border-green-200 bg-green-50 px-4 py-3 text-sm text-green-800"},yE={key:5,class:"mb-4 rounded-lg border border-red-200 bg-red-50 px-4 py-3 text-sm text-red-700"},xE={class:"space-y-3 mb-6"},vE={class:"grid sm:grid-cols-2 gap-3"},bE=["disabled"],wE=["disabled"],TE=["disabled"],SE={key:0,class:"text-sm text-emerald-700"},EE={key:0},IE={key:1},AE={key:2},CE={key:6,class:"mb-6"},ME={class:"border-t border-gray-100 pt-6"},PE=["disabled"],RE={key:7,class:"mt-4 text-xs text-gray-500"},DE={key:0,class:"mb-4 rounded-lg border border-red-200 bg-red-50 px-3 py-2 text-sm text-red-700"},LE=["disabled"],zE=["disabled"],FE={class:"text-xs text-gray-500 mb-4"},OE={class:"flex gap-3 justify-end"},kE=["disabled"],BE=["disabled"],NE={key:0,class:"mb-4 rounded-lg border border-red-200 bg-red-50 px-3 py-2 text-sm text-red-700"},VE=["disabled"],UE=["disabled"],jE={class:"text-xs text-gray-500 mb-4"},GE={class:"flex gap-3 justify-end"},$E=["disabled"],qE=["disabled"],HE={key:4,class:"space-y-6"},ZE={class:"bg-white rounded-lg shadow-md overflow-hidden"},WE={class:"md:flex"},XE={class:"md:w-1/3"},YE=["src","alt"],KE={key:1,class:"w-full h-64 md:h-full bg-gray-200 flex items-center justify-center"},JE={class:"md:w-2/3 p-6"},QE={class:"flex justify-between items-start mb-4"},e2={class:"text-3xl font-bold text-gray-900"},t2={key:0,class:"text-xl text-gray-600 mt-1"},i2={class:"grid md:grid-cols-2 gap-4 mt-6"},r2={key:0,class:"flex items-start"},n2={class:"text-gray-900"},o2={class:"text-sm text-gray-500"},s2={key:1,class:"flex items-start"},a2={class:"text-gray-900 capitalize"},l2={key:2,class:"flex items-start"},c2={class:"text-gray-900"},u2={key:3,class:"flex items-start"},h2={class:"text-gray-900 font-mono text-sm"},d2={key:0,class:"mt-6"},f2={class:"text-gray-900"},p2={class:"grid grid-cols-2 lg:grid-cols-4 gap-3"},m2={class:"text-xs text-blue-100"},_2={class:"text-xs text-emerald-100"},g2={class:"text-xs text-violet-100"},y2={class:"text-xs text-amber-100"},x2={class:"bg-white rounded-lg shadow-md p-6"},v2={class:"flex flex-wrap items-start justify-between gap-4 mb-4"},b2={class:"text-sm text-gray-600 mt-1"},w2={class:"flex flex-wrap gap-2"},T2=["disabled"],S2={key:0,class:"mb-4 rounded-lg border border-red-200 bg-red-50 px-4 py-3 text-sm text-red-700"},E2={key:1,class:"grid md:grid-cols-2 gap-6 items-start"},I2={class:"flex flex-col items-center"},A2=["src"],C2={class:"space-y-3"},M2={class:"flex gap-2"},P2=["value"],R2={class:"text-sm text-gray-600"},D2={class:"bg-gray-100 px-1.5 py-0.5 rounded text-xs"},L2={class:"capitalize"}
3408,z2={class:"bg-white rounded-lg shadow-md p-6"},F2={class:"flex flex-wrap items-center justify-between gap-3 mb-4"},O2=["disabled"],k2={key:0,class:"text-gray-600 text-sm"},B2={key:1,class:"text-gray-600 text-sm"},N2={key:2,class:"space-y-2"},V2={class:"font-semibold text-gray-900"},U2={class:"text-gray-500"},j2={class:"self-center"},G2={key:3,class:"mt-4 flex items-center justify-between gap-3"},$2=["disabled"],q2={class:"text-sm text-gray-600"},H2=["disabled"],Z2={class:"bg-white rounded-lg shadow-md p-6"},W2={class:"flex flex-wrap items-center justify-between gap-3 mb-4"},X2=["disabled"],Y2={class:"mb-6"},K2={key:0,class:"mb-4 rounded-lg border border-amber-200 bg-amber-50 px-4 py-3 text-sm text-amber-900"},J2={key:1,class:"text-gray-600 text-sm"},Q2={key:2,class:"text-gray-600 text-sm"},eI={key:3,class:"space-y-2"},tI={class:"font-semibold text-gray-900"},iI={class:"text-gray-500"},rI={key:0},nI={key:1,class:"text-green-700"},oI={key:0,class:"text-gray-700 mt-1"},sI={key:0},aI={key:1},lI={class:"text-gray-500 self-center"},cI={key:0},uI={key:1},hI={key:4,class:"mt-4 flex items-center justify-between gap-3"},dI=["disabled"],fI={class:"text-sm text-gray-600"},pI=["disabled"],mI={class:"bg-white rounded-lg shadow-md p-6"},_I={class:"flex flex-wrap items-center justify-between gap-3 mb-4"},gI=["disabled"],yI={key:0,class:"text-gray-600 text-sm"},xI={key:1,class:"text-gray-600 text-sm"},vI={key:2,class:"space-y-4"},bI={class:"mb-3 text-sm"},wI={class:"font-semibold text-gray-900"},TI={key:0},SI={class:"text-gray-600"},EI={key:0},II={class:"text-gray-500"},AI={key:0},CI={key:3,class:"mt-4 flex items-center justify-between gap-3"},MI=["disabled"],PI={class:"text-sm text-gray-600"},RI=["disabled"],DI={class:"bg-white rounded-lg shadow-md p-6"},LI="dh_walk_",zI=10,Hl=20,jI=Jp({__name:"index",setup(Xr){const Jt=mS(),vi=C1(),ri=A1(),br=yS(),Cn=_S(),{ensureSubscribed:cn,markSubscribed:u,clearSubscribedFlag:F,consumePendingAction:Yi,peekPendingAction:Ht,checkSubscription:Wt}=wS(),St=ei(null),Ti=ei(null),mn=ei(!0),Nt=ei(""),Si=ei("error"),co=ei(!1),Ni=ei(!1),Mn=ei(null),_n=ei({}),gn=ei(!1),Pn=ei(""),un=ei(""),hn=ei(""),So=ei(!1),uo=ev({name:"",phone:""}),ho=ei(!1),Nn=ei(""),Sn=ei(""),Zt=ei(!1),Eo=ei(!1),Yr=ei(""),ur=ei(!1),Li=ei(!1),ji=ei(null),dn=ei(null),gs=ei(0),Io=ei(0),Jn=ei(""),li=ev({name:"",phone:""}),Kr=ei([]);let ks=null,yn=null;const fn=ei(null),Jr=ei(""),Mi=ei(""),qi=ei(!1),tr=ei(""),fo=ei(!1),ir=ei({}),Xo=ei(!1),Bs=ei(!1),Rn=ei([]),Zi=ei(1),Ia=ei(0),Dn=ei(!1),ys=Zu(()=>Math.max(1,Math.ceil(Ia.value/Hl))),Yo=ei([]),Ko=ei(1),Ln=ei(0),Qn=ei(!1),Ao=Zu(()=>Math.max(1,Math.ceil(Ln.value/Hl))),Jo=ei([]),eo=ei({}),zr=ei(!1),to=ei(1),Co=ei(0),Aa=Zu(()=>Math.max(1,Math.ceil(Co.value/Hl))),xs=ei(!0),rr=ei({healthRecords:0,vaccinationsUpcoming:0,vaccinationsPast:0,medicationsActive:0,medicationsInactive:0,appointmentsUpcoming:0,appointmentsPast:0}),io=Zu(()=>String(br.public.baseUrl||"https://doghealthy.co.uk").replace(/\/$/,"")),Qo=Zu(()=>String(br.public.mapboxToken||"")),es=Zu(()=>Rn.value.filter(J=>J.latitude!=null&&J.longitude!=null).map(J=>({id:J.id,latitude:Number(J.latitude),longitude:Number(J.longitude),label:`${J.intent==="found"?"Found":"Scan"} · ${bs(J.scanned_at)}`,color:J.intent==="found"?"#dc2626":"#2563eb"}))),vs=async()=>{ri.loading&&await new Promise(J=>{const H=()=>{ri.loading?setTimeout(H,50):J()};H()})},Ns=J=>J?new Date(J).toLocaleDateString("en-GB",{year:"numeric",month:"long",day:"numeric"}):"Unknown",ts=J=>{if(!J)return"";const H=new Date(J),ve=new Date;let Le=ve.getFullYear()-H.getFullYear(),Ee=ve.getMonth()-H.getMonth();return Ee<0&&(Le--,Ee+=12),Le===0?`${Ee} month${Ee!==1?"s":""} old`:Ee===0?`${Le} year${Le!==1?"s":""} old`:`${Le} year${Le!==1?"s":""}, ${Ee} month${Ee!==1?"s":""} old`},bs=J=>new Date(J).toLocaleString("en-GB",{day:"numeric",month:"short",hour:"numeric",minute:"2-digit"}),Mo=J=>({found:"Found report",check_in:"Check in",check_out:"Check out",walk_start:"Walk started",walk_end:"Walk ended",walk:"Walk",test:"Test"})[J]||J,Po=async()=>{const{data:J}=await vi.auth.getSession();return J.session?.access_token||null},Ca=async J=>{Mi.value=await bS.toDataURL(J,{width:448,margin:2,errorCorrectionLevel:"M"})},Ue=async()=>
3408{if(!ri.userId)return null;const{data:J}=await vi.from("doghealthy_users").select("full_name, phone, billing_name, address_line1, address_line2, address_city, address_postcode, address_country, nfc_chip_status").eq("id",ri.userId).maybeSingle();return J},ro=async()=>{const J=await Ue();ir.value={billing_name:J?.billing_name||J?.full_name||"",address_line1:J?.address_line1||"",address_line2:J?.address_line2||"",address_city:J?.address_city||"",address_postcode:J?.address_postcode||"",address_country:J?.address_country||"GB",phone:J?.phone||""},fo.value=!0},Ma=async()=>{fo.value=!1,Xo.value=!0,await zn({skipSubscriptionCheck:!0,skipAddressCheck:!0}),St.value?.id&&await vS(`/nfc-tags?dogId=${St.value.id}`)},zn=async J=>{if(St.value){qi.value=!0,tr.value="";try{if(!J?.skipSubscriptionCheck&&!fn.value&&!await cn({reason:"nfc-tag",next:`/dogs/${St.value.id}?createTag=1`,pending:{action:"createTag",petId:St.value.id,createdAt:Date.now()}}))return;if(!fn.value&&!J?.skipAddressCheck&&!Xo.value){qi.value=!1,await ro();return}const H=await Po();if(!H)throw new Error("Please log in again to manage tags");const ve=()=>$fetch("/.netlify/functions/tag-ensure",{method:"POST",headers:{Authorization:`Bearer ${H}`},body:{petId:St.value.id}});let Le;try{Le=await ve()}catch(Ee){const et=(Ee?.data?.code||Ee?.statusCode)==="subscription_required"||Ee?.statusCode===402||Ee?.data?.statusCode===402;if(et&&J?.skipSubscriptionCheck){tr.value="Confirming your subscription…";for(let Xt=0;Xt<6;Xt++)if(await new Promise(Tt=>setTimeout(Tt,1500)),!!await Wt())try{Le=await ve(),tr.value="";break}catch{}if(!Le)throw Ee}else if(et){F(),await cn({reason:"nfc-tag",next:`/dogs/${St.value.id}?createTag=1`,pending:{action:"createTag",petId:St.value.id,createdAt:Date.now()}});return}else throw Ee}fn.value={id:Le.tag.id,uid:Le.tag.uid,status:Le.tag.status},Jr.value=Le.tagUrl||`${io.value}/dogs/${St.value.id}`,await Ca(Jr.value),Xo.value=!1,await Promise.all([sa(1),Vs(1),xn(1)])}catch(H){if(console.error(H),H?.data?.code==="subscription_required"||H?.statusCode===402){F(),await cn({reason:"nfc-tag",next:St.value?`/dogs/${St.value.id}?createTag=1`:void 0,pending:St.value?{action:"createTag",petId:St.value.id,createdAt:Date.now()}:void 0});return}tr.value=H?.data?.error||H?.message||"Failed to create tag"}finally{qi.value=!1}}},Vc=async()=>{if(Jr.value)try{await navigator.clipboard.writeText(Jr.value),Bs.value=!0,setTimeout(()=>{Bs.value=!1},2e3)}catch{tr.value="Could not copy URL"}},sa=async(J=1)=>{if(!fn.value){Rn.value=[],Ia.value=0,Zi.value=1;return}Dn.value=!0,Zi.value=J;try{const H=(J-1)*Hl,ve=H+Hl-1,{data:Le,error:Ee,count:it}=await vi.from("doghealthy_scans").select("id, scanned_at, ip, latitude, longitude, device, intent, sms_sent_at, finder_name, finder_phone",{count:"exact"}).eq("tag_id",fn.value.id).not("intent","in",'("check_in","check_out")').order("scanned_at",{ascending:!1}).range(H,ve);if(Ee){console.error("loadRecentScans",Ee),Rn.value=[],Ia.value=0;return}Rn.value=Le||[],Ia.value=it||0}finally{Dn.value=!1}},Vs=async(J=1)=>{if(!fn.value){Yo.value=[],Ln.value=0,Ko.value=1;return}Qn.value=!0,Ko.value=J;try{const H=(J-1)*Hl,ve=H+Hl-1,{data:Le,error:Ee,count:it}=await vi.from("doghealthy_scans").select("id, scanned_at, ip, latitude, longitude, device, intent, sms_sent_at, finder_name, finder_phone",{count:"exact"}).eq("tag_id",fn.value.id).in("intent",["check_in","check_out"]).order("scanned_at",{ascending:!1}).range(H,ve);if(Ee){console.error("loadCheckIns",Ee),Yo.value=[],Ln.value=0;return}Yo.value=Le||[],Ln.value=it||0}finally{Qn.value=!1}},Ro=J=>eo.value[J]||[],xn=async(J=1)=>{if(!St.value){Jo.value=[],eo.value={},Co.value=0,to.value=1;return}zr.value=!0,to.value=J;try{const H=(J-1)*Hl,ve=H+Hl-1,{data:Le,error:Ee,count:it}=await vi.from("doghealthy_walks").select("id, started_at, ended_at, status, point_count, distance_m, walker_name, walker_phone",{count:"exact"}).eq("pet_id",St.value.id).order("started_at",{ascending:!1}).range(H,ve);if(Ee){console.error("loadRecentWalks",Ee),Jo.value=[],eo.value={},Co.value=0;return}Jo.value=Le||[],Co.value=it||0;const et=Jo.value.map(Yt=>Yt.id);if(et.length===0){eo.value={};return}const{data:Xt,error:ht}=await vi.from("doghealthy_walk_points").select("walk_id, latitude, longitude, sequence").in("walk_id",et).order("sequence",{ascending:!0});if(ht){console.error("loadRecentWalk points",ht),eo.value={};return}const Tt={};for(const Yt of et)Tt[Yt]=[];for(const Yt of Xt||[]){const yi=String(Yt.walk_id);Tt[yi]||(Tt[yi]=[]),Tt[yi].push({latitude:Number(Yt.latitude),longitude:Number(Yt.longitude)})}eo.value=Tt}finally{zr.value=!1}},is=async()=>
3408{if(!ri.userId)return;const{data:J}=await vi.from("doghealthy_users").select("phone").eq("id",ri.userId).maybeSingle();xs.value=!!(J?.phone&&/^\+44\d{10}$/.test(String(J.phone).trim()))},sl=async J=>{const{data:H}=await vi.from("doghealthy_tags").select("id, uid, status").eq("pet_id",J).eq("status","active").maybeSingle();H&&(fn.value=H,Jr.value=`${io.value}/dogs/${J}`,await Ca(Jr.value),await Promise.all([sa(1),Vs(1),xn(1)]))},aa=async()=>{if(St.value)try{const J=St.value.id,{count:H}=await vi.from("doghealthy_health_records").select("*",{count:"exact",head:!0}).eq("dog_id",J),{data:ve}=await vi.from("doghealthy_vaccinations").select("vaccination_date, next_due_date").eq("dog_id",J),{data:Le}=await vi.from("doghealthy_medications").select("is_active").eq("dog_id",J),{data:Ee}=await vi.from("doghealthy_appointments").select("appointment_date, status").eq("dog_id",J);rr.value.healthRecords=H||0;const it=new Date;rr.value.vaccinationsUpcoming=ve?.filter(et=>et.next_due_date&&new Date(et.next_due_date)>=it).length||0,rr.value.vaccinationsPast=ve?.filter(et=>et.vaccination_date&&new Date(et.vaccination_date)<it).length||0,rr.value.medicationsActive=Le?.filter(et=>et.is_active).length||0,rr.value.medicationsInactive=Le?.filter(et=>!et.is_active).length||0,rr.value.appointmentsUpcoming=Ee?.filter(et=>new Date(et.appointment_date)>=it&&(et.status==="scheduled"||et.status==="confirmed")).length||0,rr.value.appointmentsPast=Ee?.filter(et=>new Date(et.appointment_date)<it||et.status==="completed"||et.status==="cancelled").length||0}catch(J){console.error("Error fetching counts:",J)}},Qr=()=>new Promise(J=>{if(!navigator.geolocation){J({});return}navigator.geolocation.getCurrentPosition(H=>{Ni.value=!0,J({latitude:H.coords.latitude,longitude:H.coords.longitude,accuracyM:H.coords.accuracy})},()=>J({}),{enableHighAccuracy:!0,timeout:8e3,maximumAge:15e3})}),Pa=(J,H)=>{const ve=Tt=>Tt*Math.PI/180,Ee=ve(H.latitude-J.latitude),it=ve(H.longitude-J.longitude),et=ve(J.latitude),Xt=ve(H.latitude),ht=Math.sin(Ee/2)**2+Math.cos(et)*Math.cos(Xt)*Math.sin(it/2)**2;return 2*6371e3*Math.asin(Math.sqrt(ht))},ws=J=>`${LI}${J}`,Us=J=>{!ji.value||!dn.value||sessionStorage.setItem(ws(J),JSON.stringify({walkId:ji.value,clientToken:dn.value,walkerName:Jn.value}))},al=J=>{sessionStorage.removeItem(ws(J))},js=()=>{ks!=null&&navigator.geolocation&&navigator.geolocation.clearWatch(ks),ks=null,
3408Li.value=!1},Zl=async J=>{if(!(!Ti.value||!ji.value||!dn.value))try{const H=await $fetch("/.netlify/functions/tag-walk",{method:"POST",body:{action:"point",petId:Ti.value.id,walkId:ji.value,clientToken:dn.value,...J}});typeof H.pointCount=="number"&&(gs.value=H.pointCount),typeof H.distanceM=="number"&&(Io.value=H.distanceM),H.skipped||(yn={latitude:J.latitude,longitude:J.longitude})}catch(H){console.error("walk point failed",H)}},Qt=()=>{navigator.geolocation&&(js(),Li.value=!0,ks=navigator.geolocation.watchPosition(J=>{const H={latitude:J.coords.latitude,longitude:J.coords.longitude,accuracyM:J.coords.accuracy};Ni.value=!0,!(yn&&Pa(yn,H)<zI)&&Zl(H)},()=>{},{enableHighAccuracy:!0,maximumAge:5e3,timeout:15e3}))},en=J=>{try{const H=sessionStorage.getItem(ws(J));if(!H)return;const ve=JSON.parse(H);if(!ve.walkId||!ve.clientToken)return;ji.value=ve.walkId,dn.value=ve.clientToken,Jn.value=ve.walkerName||"",Zt.value=!0,Qt()}catch{al(J)}},pe=async J=>{const H=await Qr();_n.value=H;const ve=await $fetch("/.netlify/functions/tag-record-scan",{method:"POST",body:{petId:J,...H}});Ti.value=ve.dog,Mn.value=ve.scanId,Zt.value=!!ve.onWalk,co.value=!0,Si.value="public",en(J)},O=async J=>{if(Ti.value){ho.value=!0,Nn.value="",Sn.value="";try{const H=await Qr(),ve=await $fetch("/.netlify/functions/tag-care-action",{method:"POST",body:{petId:Ti.value.id,intent:J,...H}});Nn.value=ve.message,typeof ve.onWalk=="boolean"&&(Zt.value=ve.onWalk)}catch(H){console.error(H),Sn.value=H?.data?.error||H?.message||"Could not save that action. Please try again.",typeof H?.data?.onWalk=="boolean"&&(Zt.value=H.data.onWalk)}finally{ho.value=!1}}},j=()=>{un.value="",hn.value="",So.value=!0},Y=()=>{Sn.value="",Yr.value="",Eo.value=!0},ce=async()=>{if(!Ti.value)return;const J=uo.name.trim(),H=T1(uo.phone);if(hn.value="",J.length<2){hn.value="Please enter your name";return}if(!H){hn.value="Please enter a valid UK mobile like 07XXX XXXXXX (saved as +44…). Landlines are not accepted.";return}gn.value=!0,Pn.value="",un.value="";try{const ve=await Promise.race([Qr(),new Promise(Ee=>setTimeout(()=>Ee({}),2500))]),Le=await $fetch("/.netlify/functions/tag-report-found",{method:"POST",body:{petId:Ti.value.id,scanId:Mn.value,finderName:J,finderPhone:H,...ve}});So.value=!1,Pn.value=Le.message,Le.sms?.skipped&&Le.sms.reason?Pn.value+=` (${Le.sms.reason})`:Le.sms?.sent===!1&&Le.sms?.reason&&(un.value=`Report saved, but SMS failed: ${Le.sms.reason}`)}catch(ve){console.error(ve),hn.value=ve?.data?.error||ve?.message||"Could not notify the owner. Please try again."}finally{gn.value=!1}},he=async()=>{if(!Ti.value)return;const J=li.name.trim(),H=T1(li.phone);if(Yr.value="",J.length<2){Yr.value="Please enter the walker’s name";return}if(!H){Yr.value="Please enter a valid UK mobile like 07XXX XXXXXX (saved as +44…). Landlines are not accepted.";return}ur.value=!0,Nn.value="",Sn.value="",Kr.value=[];try{const ve=await Qr();if(ve.latitude==null||ve.longitude==null)throw new Error("Location permission is required to start a walk");const Le=await $fetch("/.netlify/functions/tag-walk",{method:"POST",body:{action:"start",petId:Ti.value.id,walkerName:J,walkerPhone:H,...ve}});ji.value=Le.walkId,dn.value=Le.clientToken,Zt.value=!0,gs.value=Le.pointCount||1,Io.value=Le.distanceM||0,Jn.value=Le.walkerName||J,yn={latitude:ve.latitude,longitude:ve.longitude},Us(Ti.value.id),Eo.value=!1,Nn.value=Le.message,Qt()}catch(ve){console.error(ve),Yr.value=ve?.data?.error||ve?.message||"Could not start walk. Please try again.",typeof ve?.data?.onWalk=="boolean"&&(Zt.value=ve.data.onWalk)}finally{ur.value=!1}},ue=async()=>{if(!Ti.value||!ji.value||!dn.value){Sn.value="No active walk session on this device. If a walk was started here, keep the same browser tab open.";return}ho.value=!0,Nn.value="",Sn.value="",js();try{const J=await Qr(),H=await $fetch("/.netlify/functions/tag-walk",{method:"POST",body:{action:"end",petId:Ti.value.id,walkId:ji.value,clientToken:dn.value,...J}});Zt.value=!1,Kr.value=H.points||[],Nn.value=H.message,al(Ti.value.id),ji.value=null,dn.value=null,Jn.value="",yn=null}catch(J){console.error(J),Sn.value=J?.data?.error||J?.message||"Could not end walk. Please try again.",Zt.value&&Qt()}finally{ho.value=!1}};return iv(async()=>{mn.value=!0,Nt.value="";const J=Jt.params.id;try{if(await vs(),ri.isAuthenticated&&ri.userId){const{data:H,error:ve}=await vi.from("doghealthy_dogs").select("*").eq("id",J).eq("user_id",ri.userId).maybeSingle();if(!ve&&H){St.value=H,Si.value="owner",await Promise.all([aa(),sl(J),is()]);const Le=Ht();if(Jt.query.createTag==="1"||Jt.query.subscription==="success"||Le?.action==="createTag"&&Le.petId===J){Le?.action==="createTag"&&Le.petId===J&&Yi(),(Jt.query.subscription==="success"||Jt.query.createTag==="1")&&u(),await zn({skipSubscriptionCheck:!0});const it={...Jt.query};delete it.createTag,delete it.subscription,await Cn.replace({path:Jt.path,query:it})}return}}try{await pe(J)}catch(H){console.error(H),Nt.value=H?.data?.error||H?.message||"This pet profile is not available.",Si.value="error"}}catch(H){console.error(H),Nt.value=H?.message||"Failed to load dog details",Si.value="error"}finally{mn.value=!1}}),$g(()=>{js()}),TS(()=>{const J=St.value?.name||Ti.value?.name,H=Si.value==="public",ve=St.value?.breed||Ti.value?.breed;return J?{title:H?`${J} — DogHealthy Pet Tag Profile`:`${J} — Dog Health Profile`,description:H?`${J}${ve?` (${ve})`:""} has a DogHealthy NFC / QR tag. If you have found this dog in the UK, use the page tools to alert the owner, check in, or start a walk.`:`Manage ${J}’s health on DogHealthy — records, vaccinations, medications, appointments, NFC / QR tag and found-dog alerts for UK owners.`,keywords:H?`${J}, found dog UK, NFC dog tag, DogHealthy pet profile, lost dog alert`:`${J}, dog health profile, DogHealthy, vaccinations, medications`,path:Jt.path,index:!1}
3408:{title:"Pet Profile",description:"DogHealthy pet profile for UK dog owners — health tracking and NFC / QR found-pet tools.",path:Jt.path,index:!1}}),(J,H)=>{const ve=gS,Le=DS;return At(),It("div",HS,[je("div",ZS,[Oe(Si)==="owner"?(At(),It("div",WS,[To(ve,{to:"/dogs",class:"text-blue-600 hover:text-blue-700 font-medium inline-flex items-center"},{default:nl(()=>[...H[23]||(H[23]=[je("svg",{class:"w-5 h-5 mr-2",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24"},[je("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M10 19l-7-7m0 0l7-7m-7 7h18"})],-1),Ar(" Back to My Dogs ",-1)])]),_:1})])):xi("",!0),Oe(mn)?(At(),It("div",XS,[...H[24]||(H[24]=[je("div",{class:"inline-block animate-spin rounded-full h-12 w-12 border-b-2 border-blue-600"},null,-1),je("p",{class:"mt-4 text-gray-600"},"Loading dog details...",-1)])])):Oe(Nt)&&Oe(Si)!=="public"?(At(),It("div",YS,[H[26]||(H[26]=je("h2",{class:"text-xl font-semibold text-red-800 mb-2"},"Pet profile unavailable",-1)),je("p",KS,Dt(Oe(Nt)),1),To(ve,{to:"/",class:"mt-4 inline-block text-blue-600 hover:text-blue-700"},{default:nl(()=>[...H[25]||(H[25]=[Ar(" Go to DogHealthy ",-1)])]),_:1})])):Oe(Si)==="public"&&Oe(Ti)?(At(),It("div",JS,[je("div",QS,[je("div",eE,[Oe(Ti).photo_url?(At(),It("img",{key:0,src:Oe(Ti).photo_url,alt:Oe(Ti).name,width:"800",height:"448",class:"w-full h-full object-cover",loading:"eager",decoding:"async"},null,8,tE)):(At(),It("div",iE,"🐕"))]),je("div",rE,[H[35]||(H[35]=je("p",{class:"text-sm font-semibold text-blue-600 mb-2"},"Found pet profile",-1)),je("h1",nE,Dt(Oe(Ti).name),1),Oe(Ti).breed?(At(),It("p",oE,Dt(Oe(Ti).breed),1)):xi("",!0),je("div",sE,[Oe(Ti).gender?(At(),It("div",aE,[H[27]||(H[27]=je("p",{class:"text-xs uppercase tracking-wide text-gray-500"},"Gender",-1)),je("p",lE,Dt(Oe(Ti).gender),1)])):xi("",!0),Oe(Ti).color?(At(),It("div",cE,[H[28]||(H[28]=je("p",{class:"text-xs uppercase tracking-wide text-gray-500"},"Colour",-1)),je("p",uE,Dt(Oe(Ti).color),1)])):xi("",!0),Oe(Ti).microchip_number?(At(),It("div",hE,[H[29]||(H[29]=je("p",{class:"text-xs uppercase tracking-wide text-gray-500"},"Microchip",-1)),je("p",dE,Dt(Oe(Ti).microchip_number),1)])):xi("",!0)]),Oe(Ti).notes?(At(),It("div",fE,[H[30]||(H[30]=je("p",{class:"text-sm font-medium text-gray-500 mb-1"},"Owner notes",-1)),je("p",pE,Dt(Oe(Ti).notes),1)])):xi("",!0),H[36]||(H[36]=je("div",{class:"rounded-xl bg-amber-50 border border-amber-200 p-4 text-sm text-amber-900 mb-6"},[Ar(" DogHealthy is a "),je("strong",null,"UK-only"),Ar(" service. If you have found this dog, alert the owner below with your name and UK mobile. Walkers can check in/out or start a tracked walk (name + number required; GPS updates about every 10 metres). ")],-1)),Oe(Pn)?(At(),It("div",mE,Dt(Oe(Pn)),1)):xi("",!0),Oe(un)?(At(),It("div",_E,Dt(Oe(un)),1)):xi("",!0),Oe(Nn)?(At(),It("div",gE,Dt(Oe(Nn)),1)):xi("",!0),Oe(Sn)?(At(),It("div",yE,Dt(Oe(Sn)),1)):xi("",!0),je("div",xE,[H[32]||(H[32]=je("p",{class:"text-sm font-semibold text-gray-800"},"Care actions",-1)),je("div",vE,[je("button",{type:"button",class:"bg-blue-600 hover:bg-blue-700 disabled:opacity-60 text-white font-semibold px-4 py-3 rounded-lg",disabled:Oe(ho)||Oe(Li),onClick:H[0]||(H[0]=Ee=>O("check_in"))}," Check in ",8,bE),je("button",{type:"button",class:"bg-slate-700 hover:bg-slate-800 disabled:opacity-60 text-white font-semibold px-4 py-3 rounded-lg",disabled:Oe(ho)||Oe(Li),onClick:H[1]||(H[1]=Ee=>O("check_out"))}," Check out ",8,wE),je("button",{type:"button",class:Ug(["sm:col-span-2 font-semibold px-4 py-3 rounded-lg disabled:opacity-60 text-white",Oe(Zt)?"bg-orange-600 hover:bg-orange-700":"bg-emerald-600 hover:bg-emerald-700"]),disabled:Oe(ho)||Oe(ur),onClick:H[2]||(H[2]=Ee=>Oe(Zt)?ue():Y())},Dt(Oe(ur)||Oe(ho)?"Saving…":Oe(Zt)?"End walk":"Start walk"),11,TE)]),Oe(Zt)?(At(),It("p",SE,[Ar(" Walk in progress for "+Dt(Oe(Ti).name)+" ",1),Oe(gs)?(At(),It("span",EE," · "+Dt(Oe(gs))+" points",1)):xi("",!0),Oe(Io)?(At(),It("span",IE," · ~"+Dt(Oe(Io))+" m",1)):xi("",!0),Oe(Jn)?(At(),It("span",AE," · walker: "+Dt(Oe(Jn)),1)):xi("",!0),H[31]||(H[31]=Ar(". Keep this page open to record the route. ",-1))])):xi("",!0)]),Oe(Kr).length>=2?(At(),It("div",CE,[H[33]||(H[33]=je("p",{class:"text-sm font-semibold text-gray-800 mb
3408-2"},"Walk route just completed",-1)),To(I1,{token:Oe(Qo),coordinates:Oe(Kr)},null,8,["token","coordinates"])])):xi("",!0),je("div",ME,[H[34]||(H[34]=je("p",{class:"text-sm font-semibold text-gray-800 mb-3"},"Found this dog?",-1)),je("button",{type:"button",class:"w-full sm:w-auto bg-red-600 hover:bg-red-700 disabled:opacity-60 text-white font-semibold px-6 py-3 rounded-lg",disabled:Oe(gn),onClick:j}," I found this dog — alert owner ",8,PE)]),Oe(co)?(At(),It("p",RE," Scan recorded"+Dt(Oe(Ni)?" with approximate location":"")+". ",1)):xi("",!0)])]),Oe(So)?(At(),It("div",{key:0,class:"fixed inset-0 z-50 flex items-end sm:items-center justify-center bg-black/50 p-4",onClick:H[7]||(H[7]=Fd(Ee=>!Oe(gn)&&(So.value=!1),["self"]))},[je("div",{class:"w-full max-w-md rounded-2xl bg-white p-6 shadow-xl",onClick:H[6]||(H[6]=Fd(()=>{},["stop"]))},[H[37]||(H[37]=je("h2",{class:"text-xl font-bold text-gray-900 mb-1"},"Alert the owner",-1)),H[38]||(H[38]=je("p",{class:"text-sm text-gray-600 mb-4"}," Please leave your name and UK mobile so they can contact you. DogHealthy is UK-only. ",-1)),Oe(hn)?(At(),It("div",DE,Dt(Oe(hn)),1)):xi("",!0),H[39]||(H[39]=je("label",{class:"block text-sm font-medium text-gray-700 mb-1"},"Your name",-1)),Os(je("input",{"onUpdate:modelValue":H[3]||(H[3]=Ee=>Oe(uo).name=Ee),type:"text",maxlength:"80",autocomplete:"name",class:"w-full border border-gray-300 rounded-lg px-3 py-2 mb-3",placeholder:"Full name",disabled:Oe(gn)},null,8,LE),[[ol,Oe(uo).name]]),H[40]||(H[40]=je("label",{class:"block text-sm font-medium text-gray-700 mb-1"},"UK mobile",-1)),Os(je("input",{"onUpdate:modelValue":H[4]||(H[4]=Ee=>Oe(uo).phone=Ee),type:"tel",inputmode:"tel",autocomplete:"tel",class:"w-full border border-gray-300 rounded-lg px-3 py-2 mb-1",placeholder:"07XXX XXXXXX",disabled:Oe(gn),onKeyup:w1(ce,["enter"])},null,40,zE),[[ol,Oe(uo).phone]]),je("p",FE,Dt(Oe(S1)(Oe(uo).phone)),1),je("div",OE,[je("button",{type:"button",class:"px-4 py-2 text-sm font-medium text-gray-700",disabled:Oe(gn),onClick:H[5]||(H[5]=Ee=>So.value=!1)}," Cancel ",8,kE),je("button",{type:"button",class:"bg-red-600 hover:bg-red-700 disabled:opacity-60 text-white font-semibold px-4 py-2 rounded-lg text-sm",disabled:Oe(gn),onClick:ce},Dt(Oe(gn)?"Sending…":"Send alert"),9,BE)])])])):xi("",!0),Oe(Eo)?(At(),It("div",{key:1,class:"fixed inset-0 z-50 flex items-end sm:items-center justify-center bg-black/50 p-4",onClick:H[12]||(H[12]=Fd(Ee=>!Oe(ur)&&(Eo.value=!1),["self"]))},[je("div",{class:"w-full max-w-md rounded-2xl bg-white p-6 shadow-xl",onClick:H[11]||(H[11]=Fd(()=>{},["stop"]))},[H[41]||(H[41]=je("h2",{class:"text-xl font-bold text-gray-900 mb-1"},"Start walk",-1)),H[42]||(H[42]=je("p",{class:"text-sm text-gray-600 mb-4"}," Enter the walker’s name and UK mobile. We’ll record GPS about every 10 metres until you tap End w
3408alk. ",-1)),Oe(Yr)?(At(),It("div",NE,Dt(Oe(Yr)),1)):xi("",!0),H[43]||(H[43]=je("label",{class:"block text-sm font-medium text-gray-700 mb-1"},"Walker’s name",-1)),Os(je("input",{"onUpdate:modelValue":H[8]||(H[8]=Ee=>Oe(li).name=Ee),type:"text",maxlength:"80",autocomplete:"name",class:"w-full border border-gray-300 rounded-lg px-3 py-2 mb-3",placeholder:"Full name",disabled:Oe(ur)},null,8,VE),[[ol,Oe(li).name]]),H[44]||(H[44]=je("label",{class:"block text-sm font-medium text-gray-700 mb-1"},"UK mobile",-1)),Os(je("input",{"onUpdate:modelValue":H[9]||(H[9]=Ee=>Oe(li).phone=Ee),type:"tel",inputmode:"tel",autocomplete:"tel",class:"w-full border border-gray-300 rounded-lg px-3 py-2 mb-1",placeholder:"07XXX XXXXXX",disabled:Oe(ur),onKeyup:w1(he,["enter"])},null,40,UE),[[ol,Oe(li).phone]]),je("p",jE,Dt(Oe(S1)(Oe(li).phone)),1),je("div",GE,[je("button",{type:"button",class:"px-4 py-2 text-sm font-medium text-gray-700",disabled:Oe(ur),onClick:H[10]||(H[10]=Ee=>Eo.value=!1)}," Cancel ",8,$E),je("button",{type:"button",class:"bg-emerald-600 hover:bg-emerald-700 disabled:opacity-60 text-white font-semibold px-4 py-2 rounded-lg text-sm",disabled:Oe(ur),onClick:he},Dt(Oe(ur)?"Starting…":"Start tracking"),9,qE)])])])):xi("",!0)])):Oe(Si)==="owner"&&Oe(St)?(At(),It("div",HE,[je("div",ZE,[je("div",WE,[je("div",XE,[Oe(St).photo_url?(At(),It("img",{key:0,src:Oe(St).photo_url,alt:Oe(St).name,width:"480",height:"480",class:"w-full h-64 md:h-full object-cover",loading:"eager",decoding:"async"},null,8,YE)):(At(),It("div",KE,[...H[45]||(H[45]=[je("svg",{class:"h-24 w-24 text-gray-400",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24"},[je("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M4 16l4.586-4.586a2 2 0 012.828 0L16 16m-2-2l1.586-1.586a2 2 0 012.828 0L20 14m-6-6h.01M6 20h12a2 2 0 002-2V6a2 2 0 00-2-2H6a2 2 0 00-2 2v12a2 2 0 002 2z"})],-1)])]))]),je("div",JE,[je("div",QE,[je("div",null,[je("h1",e2,Dt(Oe(St).name),1),Oe(St).breed?(At(),It("p",t2,Dt(Oe(St).breed),1)):xi("",!0)]),To(ve,{to:`/dogs/${Oe(St).id}/edit`,class:"bg-blue-600 hover:bg-blue-700 text-white px-4 py-2 rounded-lg transition-colors"},{default:nl(()=>[...H[46]||(H[46]=[Ar(" Edit ",-1)])]),_:1},8,["to"])]),je("div",i2,[Oe(St).birth_date?(At(),It("div",r2,[je("div",null,[H[47]||(H[47]=je("p",{class:"text-sm font-medium text-gray-500"},"Date of Birth",-1)),je("p",n2,Dt(Ns(Oe(St).birth_date)),1),je("p",o2,Dt(ts(Oe(St).birth_date)),1)])])):xi("",!0),Oe(St).gender?(At(),It("div",s2,[je("div",null,[H[48]||(H[48]=je("p",{class:"text-sm font-medium text-gray-500"},"Gender",-1)),je("p",a2,Dt(Oe(St).gender),1)])])):xi("",!0),Oe(St).weight_kg?(At(),It("div",l2,[je("div",null,[H[49]||(H[49]=je("p",{class:"text-sm font-medium text-gray-500"},"Weight",-1)),je("p",c2,Dt(Oe(St).weight_kg)+" kg",1)])])):xi("",!0),Oe(St).microchip_number?(At(),It("div",u2,[je("div",null,[H[50]||(H[50]=je("p",{class:"text-sm font-medium text-gray-500"},"Microchip",-1)),je("p",h2,Dt(Oe(St).microchip_number),1)])])):xi("",!0)]),Oe(St).notes?(At(),It("div",d2,[H[51]||(H[51]=je("p",{class:"text-sm font-medium text-gray-500 mb-2"},"Notes",-1)),je("p",f2,Dt(Oe(St).notes),1)])):xi("",!0)])])]),je("div",p2,[To(ve,{to:`/dogs/${Oe(St).id}/health-records`,class:"inline-flex flex-col items-center justify-center gap-1 rounded-lg bg-blue-600 hover:bg-blue-700 text-white px-4 py-4 text-center shadow-sm transition-colors"},{default:nl(()=>[H[52]||(H[52]=je("i",{class:"bi bi-clipboard2-pulse text-2xl","aria-hidden":"true"},null,-1)),H[53]||(H[53]=je("span",{class:"font-semibold text-sm leading-tight"},"Health records",-1)),je("span",m2,Dt(Oe(rr).healthRecords)+" records",1)]),_:1},8,["to"]),To(ve,{to:`/dogs/${Oe(St).id}/vaccinations`,class:"inline-flex flex-col items-center justify-center gap-1 rounded-lg bg-emerald-600 hover:bg-emerald-700 text-white px-4 py-4 text-center shadow-sm transition-colors"},{default:nl(()=>[H[54]||(H[54]=je("svg",{class:"h-7 w-7",viewBox:"0 0 24 24",fill:"currentColor","aria-hidden":"true"},[je("path",{d:"M20.71 3.29a1 1 0 0 0-1.42 0l-1.12 1.12-1.47-1.47a1 1 0 1 0-1.41 1.41l1.47 1.47-8.6 8.6a3 3 0 0 0-.72 1.25l-.9 3.15a1 1 0 0 0 1.23 1.23l3.15-.9a3 3 0 0 0 1.25-.72l8.6-8.6 1.47 1.47a1 1 0 0 0 1.41-1.41l-1.47-1.47 1.12-1.12a1 1 0 0 0 0-1.41zM9.54 17.46l-1.17.33.33-1.17a1 1 0 0 1 .24-.42l.6-.6 1.02 1.02-.6.6a1 1 0 0 1-.42.24zm2.55-1.13-1.02-1.02 6.17-6.17 1.02 1.02-6.17 6.17z"})],-1)),H[55]||(H[55]=je("span",{class:"font-semibold text-sm leading-tight"},"Vaccinations",-1)),je("span",_2,Dt(Oe(rr).vaccinationsUpcoming)+" active",1)]),_:1},8,["to"]),To(ve,{to:`/dogs/${Oe(St).id}/medications`,class:"inline-flex flex-col items-center justify-center gap-1 rounded-lg bg-violet-600 hover:bg-violet-700 text-white px-4 py-4 text-center shadow-sm transition-colors"},{default:nl(()=>[H[56]||(H[56]=je("i",{class:"bi bi-capsule text-2xl","aria-hidden":"true"},null,-1)),H[57]||(H[57]=je("span",{class:"font-semibold text-sm leading-tight"},"Medications",-1)),je("span",g2,Dt(Oe(rr).medicationsActive)+" active",1)]),_:1},8,["to"]),To(ve,{to:`/dogs/${Oe(St).id}/appointments`,class:"inline-flex flex-col items-center justify-center gap-1 rounded-lg bg-amber-600 hover:bg-amber-700 text-white px-4 py-4 text-center shadow-sm transition-colors"},{default:nl(()=>[H[58]||(H[58]=je("i",{class:"bi bi-calendar2-event text-2xl","aria-hidden":"true"},null,-1)),H[59]||(H[59]=je("span",{class:"font-semibold text-sm leading-tight"},"Appointments",-1)),je("span",y2,Dt(Oe(rr).appointmentsUpcoming)+" upcoming",1)]),_:1},8,["to"])]),je("div",x2,[je("div",v2,[je("div",null,[H[62]||(H[62]=je("h2",{class:"text-xl font-semibold text-gray-900"},"QR / NFC tag",-1)),je("p",b2,[Ar(" Create a digital QR / NFC URL for "+Dt(Oe(St).name)+". Physical stickers are ordered in batches (2 per dog, one postage fee) via ",1),To(ve,{to:"/nfc-tags",class:"text-blue-600 hover:underline"},{default:nl(()=>[...H[60]||(H[60]=[Ar("Order NFC stickers",-1)])]),_:1}),H[61]||(H[61]=Ar(". ",-1))])]),je("div",w2,[je("button",{type:"button",class:"bg-blue-600 hover:bg-blue-700 disabled:opacity-60 text-white px-4 py-2 rounded-lg text-sm font-semibold",disabled:Oe(qi),onClick:zn},Dt(Oe(qi)?"Preparing…":Oe(fn)?"Refresh tag":"Create tag + QR"),9,T2),To(ve,{to:`/nfc-tags?dogId=${Oe(St).id}&mode=replace`,class:"bg-white border border-gray-300 hover:bg-gray-50 text-gray-800 px-4 py-2 rounded-lg text-sm font-semibold"},{default:nl(()=>[...H[63]||(H[63]=[Ar(" Order / replace stickers ",-1)])]),_:1},8,["to"])])]),Oe(tr)?(At(),It("div",S2,Dt(Oe(tr)),1)):xi("",!0),To(Le,{open:Oe(fo),"dog-name":Oe(St)?.name,"dog-id":Oe(St)?.id,initial:Oe(ir),onCancel:H[13]||(H[13]=Ee=>fo.value=!1),onSaved:Ma},null,8,["open","dog-name","dog-id","initial"]),Oe(fn)&&Oe(Jr)?(At(),It("div",E2,[je("div",I2,[Oe(Mi)?(At(),It("img",{key:0,src:Oe(Mi),alt:"QR code for pet tag",class:"w-56 h-56 border border-gray-200 rounded-lg bg-white p-2"},null,8,A2)):xi("",!0),H[64]||(H[64]=je("p",{class:"mt-2 text-xs text-gray-500"},"Scan with a phone camera to test",-1))]),je("div",C2,[je("div",null,[H[65]||(H[65]=je("p",{class:"text-xs uppercase tracking-wide text-gray-500 mb-1"},"Tag URL (write this to NFC)",-1)),je("div",M2,[je("input",{value:Oe(Jr),readonly:"",class:"flex-1 border border-gray-300 rounded-lg px-3 py-2 text-sm font-mono bg-gray-50"},null,8,P2),je("button",{type:"button",class:"px-3 py-2 rounded-lg border border-gray-300 text-sm font-medium hover:bg-gray-50",onClick:Vc},Dt(Oe(Bs)?"Copied":"Copy"),1)])]),je("p",R2,[H[66]||(H[66]=Ar(" UID: ",-1)),je("code",D2,Dt(Oe(fn).uid),1),H[67]||(H[67]=Ar(" · Status: ",-1)),je("span",L2,Dt(Oe(fn).status),1)]),H[68]||(H[68]=je("p",{class:"text-sm text-gray-500"}," Home test: copy the URL into an NFC writer app (e.g. NFC Tools), write to your sticker, then scan in a private browser window. ",-1))])])):xi("",!0)]),je("div",z2,[je("div",F2,[H[69]||(H[69]=je("h2",{class:"text-xl font-semibold text-gray-900"},"Check-ins & check-outs",-1)),je("button",{type:"button",class:"inline-flex items-center rounded-lg bg-blue-600 hover:bg-blue-700 disabled:opacity-60 text-white px-3 py-2 text-sm font-semibold",disabled:Oe(Qn),onClick:H[14]||(H[14]=Ee=>Vs(1))},Dt(Oe(Qn)?"Refreshing…":"Refresh"),9,O2)]),Oe(Qn)&&Oe(Yo).length===0?(At(),It("div",k2,"Loading…")):Oe(Yo).length===0?(At(),It("div",B2," No check-ins or check-outs yet. ")):(At(),It("ul",N2,[(At(!0),It(Kx,null,Jx(Oe(Yo),Ee=>(At(),It("li",{key:Ee.id,class:"flex flex-wrap justify-between gap-2 rounded-lg border border-slate-200 bg-slate-50 px-4 py-3 text-sm"},[je("div",null,[je("p",V2,[Ar(Dt(bs(Ee.scanned_at))+" ",1),je("span",{class:Ug(["ml-2 inline-flex items-center rounded-full px-2 py-0.5 text-xs font-semibold",Ee.intent==="check_in"?"bg-blue-100 text-blue-800":"bg-slate-200 text-slate-800"])},Dt(Mo(Ee.intent||"")),3)]),je("p",U2,Dt(Ee.device?.platform||"device unknown"),1)]),je("div",j2,[To(qS,{latitude:Ee.latitude,longitude:Ee.longitude,token:Oe(Qo),color:Ee.intent==="check_in"?"#2563eb":"#334155"},null,8,["latitude","longitude","token","color"])])]))),128))])),Oe(Ao)>1?(At(),It("div",G2,[je("button",{type:"button",class:"rounded-lg bg-slate-700 hover:bg-slate-800 disabled:opacity-40 text-white px-4 py-2 text-sm font-semibold",disabled:Oe(Ko)<=1||Oe(Qn),onClick:H[15]||(H[15]=Ee=>Vs(Oe(Ko)-1))}," Previous ",8,$2),je("span",q2,"Page "+Dt(Oe(Ko))+" of "+Dt(Oe(Ao)),1),je("button",{type:"button",class:"rounded-lg bg-slate-700 hover:bg-slate-800 disabled:opacity-40 text-white px-4 py-2 text-sm font-semibold",disabled:Oe(Ko)>=Oe(Ao)||Oe(Qn),onClick:H[16]||(H[16]=Ee=>Vs(Oe(Ko)+1))}," Next ",8,H2)])):xi("",!0)]),je("div",Z2,[je("div",W2,[H[70]||(H[70]=je("h2",{class:"text-xl font-semibold text-gray-900"},"Recent tag scans",-1)),je("button",{type:"button",class:"inline-flex items-center rounded-lg bg-blue-600 hover:bg-blue-700 disabled:opacity-60 text-white px-3 py-2 text-sm font-semibold",disabled:Oe(Dn),onClick:H[17]||(H[17]=Ee=>sa(1))},Dt(Oe(Dn)?"Refreshing…":"Refresh"),9,X2)]),je("div",Y2,[To(BS,{token:Oe(Qo),points:Oe(es)},null,8,["token","points"])]),Oe(xs)?xi("",!0):(At(),It("div",K2,[H[72]||(H[72]=Ar(" Add a UK mobile number on your ",-1)),To(ve,{to:"/profile",class:"font-semibold underline"},{default:nl(()=>[...H[71]||(H[71]=[Ar("profile",-1)])]),_:1}),Ar(" so we can SMS you when someone reports finding "+Dt(Oe(St).name)+". ",1)])),Oe(Dn)&&Oe(Rn).length===0?(At(),It("div",J2,"Loading…")):Oe(Rn).length===0?(At(),It("div",Q2," No scans yet. After someone opens the tag URL, they will appear here. ")):(At(),It("ul",eI,[(At(!0),It(Kx,null,Jx(Oe(Rn),Ee=>(At(),It("li",{key:Ee.id,class:"flex flex-wrap justify-between gap-2 rounded-lg border border-blue-100 bg-blue-50/60 px-4 py-3 text-sm"},[je("div",null,[je("p",tI,[Ar(Dt(bs(Ee.scanned_at))+" ",1),Ee.intent&&Ee.intent!=="scan"?(At(),It("span",{key:0,class:Ug(["ml-2 inline-flex items-center rounded-full px-2 py-0.5 text-xs font-semibold",Ee.intent==="found"?"bg-red-100 text-red-800":"bg-blue-100 text-blue-800"])},Dt(Mo(Ee.intent)),3)):xi("",!0)]),je("p",iI,[Ar(Dt(Ee.device?.platform||"device unknown")+" ",1),Ee.ip?(At(),It("span",rI," · "+Dt(Ee.ip),1)):xi("",!0),Ee.sms_sent_at?(At(),It("span",nI," · SMS sent")):xi("",!0)]),Ee.finder_name||Ee.finder_phone?(At(),It("p",oI,[H[73]||(H[73]=Ar(" Contact: ",-1)),Ee.finder_name?(At(),It("span",sI,Dt(Ee.finder_name),1)):xi("",!0),Ee.finder_phone?(At(),It("span",aI," · "+Dt(Ee.f
3408inder_phone),1)):xi("",!0)])):xi("",!0)]),je("div",lI,[Ee.latitude!=null&&Ee.longitude!=null?(At(),It("span",cI,Dt(Number(Ee.latitude).toFixed(4))+", "+Dt(Number(Ee.longitude).toFixed(4)),1)):(At(),It("span",uI,"No GPS"))])]))),128))])),Oe(ys)>1?(At(),It("div",hI,[je("button",{type:"button",class:"rounded-lg bg-blue-600 hover:bg-blue-700 disabled:opacity-40 text-white px-4 py-2 text-sm font-semibold",disabled:Oe(Zi)<=1||Oe(Dn),onClick:H[18]||(H[18]=Ee=>sa(Oe(Zi)-1))}," Previous ",8,dI),je("span",fI,"Page "+Dt(Oe(Zi))+" of "+Dt(Oe(ys)),1),je("button",{type:"button",class:"rounded-lg bg-blue-600 hover:bg-blue-700 disabled:opacity-40 text-white px-4 py-2 text-sm font-semibold",disabled:Oe(Zi)>=Oe(ys)||Oe(Dn),onClick:H[19]||(H[19]=Ee=>sa(Oe(Zi)+1))}," Next ",8,pI)])):xi("",!0)]),je("div",mI,[je("div",_I,[H[74]||(H[74]=je("h2",{class:"text-xl font-semibold text-gray-900"},"Recent walks",-1)),je("button",{type:"button",class:"inline-flex items-center rounded-lg bg-emerald-600 hover:bg-emerald-700 disabled:opacity-60 text-white px-3 py-2 text-sm font-semibold",disabled:Oe(zr),onClick:H[20]||(H[20]=Ee=>xn(1))},Dt(Oe(zr)?"Refreshing…":"Refresh"),9,gI)]),Oe(zr)&&Oe(Jo).length===0?(At(),It("div",yI," Loading walks… ")):Oe(Jo).length===0?(At(),It("div",xI," No tracked walks yet. When someone starts and ends a walk from the public tag page, the GPS route appears here. ")):(At(),It("div",vI,[(At(!0),It(Kx,null,Jx(Oe(Jo),Ee=>(At(),It("div",{key:Ee.id,class:"rounded-lg border border-emerald-100 bg-emerald-50/50 p-4"},[je("div",bI,[je("p",wI,[Ar(Dt(bs(Ee.started_at))+" ",1),Ee.ended_at?(At(),It("span",TI," → "+Dt(bs(Ee.ended_at)),1)):xi("",!0),je("span",{class:Ug(["ml-2 inline-flex items-center rounded-full px-2 py-0.5 text-xs font-semibold",Ee.status==="completed"?"bg-emerald-100 text-emerald-800":"bg-amber-100 text-amber-800"])},Dt(Ee.status),3)]),je("p",SI,[Ar(" Walker: "+Dt(Ee.walker_name||"Unknown")+" ",1),Ee.walker_phone?(At(),It("span",EI," · "+Dt(Ee.walker_phone),1)):xi("",!0)]),je("p",II,[Ar(Dt(Ro(Ee.id).length||Ee.point_count||0)+" GPS points ",1),Ee.distance_m?(At(),It("span",AI," · ~"+Dt(Math.round(Number(Ee.distance_m)))+" m",1)):xi("",!0)])]),To(I1,{token:Oe(Qo),coordinates:Ro(Ee.id)},null,8,["token","coordinates"])]))),128))])),Oe(Aa)>1?(At(),It("div",CI,[je("button",{type:"button",class:"rounded-lg bg-emerald-600 hover:bg-emerald-700 disabled:opacity-40 text-white px-4 py-2 text-sm font-semibold",disabled:Oe(to)<=1||Oe(zr),onClick:H[21]||(H[21]=Ee=>xn(Oe(to)-1))}," Previous ",8,MI),je("span",PI,"Page "+Dt(Oe(to))+" of "+Dt(Oe(Aa)),1),je("button",{type:"button",class:"rounded-lg bg-emerald-600 hover:bg-emerald-700 disabled:opacity-40 text-white px-4 py-2 text-sm font-semibold",disabled:Oe(to)>=Oe(Aa)||Oe(zr),onClick:H[22]||(H[22]=Ee=>xn(Oe(to)+1))}," Next ",8,RI)])):xi("",!0)]),je("div",DI,[To(xS,{"ad-slot":"dog-detail-sidebar","ad-format":"horizontal"})])])):xi("",!0)])])}}});export{jI as default};

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.